aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/extras/Mesa
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/extras/Mesa')
-rw-r--r--nx-X11/extras/Mesa/Makefile451
-rw-r--r--nx-X11/extras/Mesa/Makefile.DJ93
-rw-r--r--nx-X11/extras/Mesa/Makefile.mgw88
-rw-r--r--nx-X11/extras/Mesa/README.XF8647
-rw-r--r--nx-X11/extras/Mesa/XOrg-Xlist15
-rwxr-xr-xnx-X11/extras/Mesa/bin/installmesa69
-rwxr-xr-xnx-X11/extras/Mesa/bin/mklib698
-rw-r--r--nx-X11/extras/Mesa/configs/aix28
-rw-r--r--nx-X11/extras/Mesa/configs/aix-6428
-rw-r--r--nx-X11/extras/Mesa/configs/aix-gcc19
-rw-r--r--nx-X11/extras/Mesa/configs/aix-static23
-rw-r--r--nx-X11/extras/Mesa/configs/beos99
-rw-r--r--nx-X11/extras/Mesa/configs/darwin29
-rw-r--r--nx-X11/extras/Mesa/configs/darwin-static24
-rw-r--r--nx-X11/extras/Mesa/configs/default74
-rw-r--r--nx-X11/extras/Mesa/configs/freebsd16
-rw-r--r--nx-X11/extras/Mesa/configs/freebsd-dri45
-rw-r--r--nx-X11/extras/Mesa/configs/freebsd-dri-amd649
-rw-r--r--nx-X11/extras/Mesa/configs/freebsd-dri-x8612
-rw-r--r--nx-X11/extras/Mesa/configs/hpux1014
-rw-r--r--nx-X11/extras/Mesa/configs/hpux10-gcc16
-rw-r--r--nx-X11/extras/Mesa/configs/hpux10-static30
-rw-r--r--nx-X11/extras/Mesa/configs/hpux11-3226
-rw-r--r--nx-X11/extras/Mesa/configs/hpux11-32-static26
-rw-r--r--nx-X11/extras/Mesa/configs/hpux11-32-static-nothreads26
-rw-r--r--nx-X11/extras/Mesa/configs/hpux11-6427
-rw-r--r--nx-X11/extras/Mesa/configs/hpux11-64-static27
-rw-r--r--nx-X11/extras/Mesa/configs/hpux916
-rw-r--r--nx-X11/extras/Mesa/configs/hpux9-gcc14
-rw-r--r--nx-X11/extras/Mesa/configs/irix6-6418
-rw-r--r--nx-X11/extras/Mesa/configs/irix6-64-static25
-rw-r--r--nx-X11/extras/Mesa/configs/irix6-n3218
-rw-r--r--nx-X11/extras/Mesa/configs/irix6-n32-static25
-rw-r--r--nx-X11/extras/Mesa/configs/irix6-o3219
-rw-r--r--nx-X11/extras/Mesa/configs/irix6-o32-static25
-rw-r--r--nx-X11/extras/Mesa/configs/linux33
-rw-r--r--nx-X11/extras/Mesa/configs/linux-alpha18
-rw-r--r--nx-X11/extras/Mesa/configs/linux-alpha-static27
-rw-r--r--nx-X11/extras/Mesa/configs/linux-debug8
-rw-r--r--nx-X11/extras/Mesa/configs/linux-directfb29
-rw-r--r--nx-X11/extras/Mesa/configs/linux-dri68
-rw-r--r--nx-X11/extras/Mesa/configs/linux-dri-ppc17
-rw-r--r--nx-X11/extras/Mesa/configs/linux-dri-x8616
-rw-r--r--nx-X11/extras/Mesa/configs/linux-dri-x86-6423
-rw-r--r--nx-X11/extras/Mesa/configs/linux-fbdev10
-rw-r--r--nx-X11/extras/Mesa/configs/linux-glide20
-rw-r--r--nx-X11/extras/Mesa/configs/linux-icc21
-rw-r--r--nx-X11/extras/Mesa/configs/linux-icc-static29
-rw-r--r--nx-X11/extras/Mesa/configs/linux-indirect49
-rw-r--r--nx-X11/extras/Mesa/configs/linux-osmesa1627
-rw-r--r--nx-X11/extras/Mesa/configs/linux-osmesa16-static28
-rw-r--r--nx-X11/extras/Mesa/configs/linux-osmesa3227
-rw-r--r--nx-X11/extras/Mesa/configs/linux-ppc9
-rw-r--r--nx-X11/extras/Mesa/configs/linux-ppc-static14
-rw-r--r--nx-X11/extras/Mesa/configs/linux-profile29
-rw-r--r--nx-X11/extras/Mesa/configs/linux-solo43
-rw-r--r--nx-X11/extras/Mesa/configs/linux-solo-ia647
-rw-r--r--nx-X11/extras/Mesa/configs/linux-solo-x8612
-rw-r--r--nx-X11/extras/Mesa/configs/linux-sparc30
-rw-r--r--nx-X11/extras/Mesa/configs/linux-sparc517
-rw-r--r--nx-X11/extras/Mesa/configs/linux-static21
-rw-r--r--nx-X11/extras/Mesa/configs/linux-tcc22
-rw-r--r--nx-X11/extras/Mesa/configs/linux-ultrasparc17
-rw-r--r--nx-X11/extras/Mesa/configs/linux-x868
-rw-r--r--nx-X11/extras/Mesa/configs/linux-x86-327
-rw-r--r--nx-X11/extras/Mesa/configs/linux-x86-6413
-rw-r--r--nx-X11/extras/Mesa/configs/linux-x86-64-debug7
-rw-r--r--nx-X11/extras/Mesa/configs/linux-x86-64-static21
-rw-r--r--nx-X11/extras/Mesa/configs/linux-x86-debug9
-rw-r--r--nx-X11/extras/Mesa/configs/linux-x86-glide24
-rw-r--r--nx-X11/extras/Mesa/configs/linux-x86-static21
-rw-r--r--nx-X11/extras/Mesa/configs/linux-x86-xcb24
-rw-r--r--nx-X11/extras/Mesa/configs/netbsd14
-rw-r--r--nx-X11/extras/Mesa/configs/openbsd18
-rw-r--r--nx-X11/extras/Mesa/configs/osf116
-rw-r--r--nx-X11/extras/Mesa/configs/solaris-x8618
-rw-r--r--nx-X11/extras/Mesa/configs/solaris-x86-gcc24
-rw-r--r--nx-X11/extras/Mesa/configs/sunos412
-rw-r--r--nx-X11/extras/Mesa/configs/sunos4-gcc15
-rw-r--r--nx-X11/extras/Mesa/configs/sunos4-static25
-rw-r--r--nx-X11/extras/Mesa/configs/sunos518
-rw-r--r--nx-X11/extras/Mesa/configs/sunos5-gcc35
-rw-r--r--nx-X11/extras/Mesa/configs/sunos5-smp19
-rw-r--r--nx-X11/extras/Mesa/configs/ultrix-gcc21
-rw-r--r--nx-X11/extras/Mesa/descrip.mms22
-rw-r--r--nx-X11/extras/Mesa/docs/COPYING490
-rw-r--r--nx-X11/extras/Mesa/docs/MESA_agp_offset.spec95
-rw-r--r--nx-X11/extras/Mesa/docs/MESA_copy_sub_buffer.spec88
-rw-r--r--nx-X11/extras/Mesa/docs/MESA_pack_invert.spec138
-rw-r--r--nx-X11/extras/Mesa/docs/MESA_packed_depth_stencil.spec231
-rw-r--r--nx-X11/extras/Mesa/docs/MESA_pixmap_colormap.spec90
-rw-r--r--nx-X11/extras/Mesa/docs/MESA_program_debug.spec357
-rw-r--r--nx-X11/extras/Mesa/docs/MESA_release_buffers.spec85
-rw-r--r--nx-X11/extras/Mesa/docs/MESA_resize_buffers.spec82
-rw-r--r--nx-X11/extras/Mesa/docs/MESA_set_3dfx_mode.spec85
-rw-r--r--nx-X11/extras/Mesa/docs/MESA_sprite_point.spec191
-rw-r--r--nx-X11/extras/Mesa/docs/MESA_swap_control.spec132
-rw-r--r--nx-X11/extras/Mesa/docs/MESA_swap_frame_usage.spec201
-rw-r--r--nx-X11/extras/Mesa/docs/MESA_trace.spec360
-rw-r--r--nx-X11/extras/Mesa/docs/MESA_window_pos.spec127
-rw-r--r--nx-X11/extras/Mesa/docs/MESA_ycbcr_texture.spec204
-rw-r--r--nx-X11/extras/Mesa/docs/MiniGLX.html547
-rw-r--r--nx-X11/extras/Mesa/docs/README.3DFX830
-rw-r--r--nx-X11/extras/Mesa/docs/README.AMIWIN181
-rw-r--r--nx-X11/extras/Mesa/docs/README.BEOS137
-rw-r--r--nx-X11/extras/Mesa/docs/README.CYGWIN256
-rw-r--r--nx-X11/extras/Mesa/docs/README.D3D124
-rw-r--r--nx-X11/extras/Mesa/docs/README.DJ275
-rw-r--r--nx-X11/extras/Mesa/docs/README.GGI26
-rw-r--r--nx-X11/extras/Mesa/docs/README.LYNXOS64
-rw-r--r--nx-X11/extras/Mesa/docs/README.MINGW3290
-rw-r--r--nx-X11/extras/Mesa/docs/README.MITS102
-rw-r--r--nx-X11/extras/Mesa/docs/README.NeXT6
-rw-r--r--nx-X11/extras/Mesa/docs/README.OS296
-rw-r--r--nx-X11/extras/Mesa/docs/README.OpenStep35
-rw-r--r--nx-X11/extras/Mesa/docs/README.QUAKE208
-rw-r--r--nx-X11/extras/Mesa/docs/README.THREADS52
-rw-r--r--nx-X11/extras/Mesa/docs/README.VMS32
-rw-r--r--nx-X11/extras/Mesa/docs/README.WIN32139
-rw-r--r--nx-X11/extras/Mesa/docs/README.WINDML146
-rw-r--r--nx-X11/extras/Mesa/docs/README.X11314
-rw-r--r--nx-X11/extras/Mesa/docs/README.directfb28
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-3.1146
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-3.212
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-3.2.132
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-3.3271
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-3.422
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-3.4.122
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-3.4.222
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-3.5228
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-4.0163
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-4.0.122
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-4.0.250
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-4.0.352
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-4.1308
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-5.085
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-5.0.146
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-5.0.246
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-5.1279
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-6.087
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-6.0.150
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-6.1112
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-6.252
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-6.2.150
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-6.3115
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-6.3.149
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-6.3.237
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-6.450
-rw-r--r--nx-X11/extras/Mesa/docs/RELNOTES-6.4.147
-rw-r--r--nx-X11/extras/Mesa/docs/VERSIONS1423
-rw-r--r--nx-X11/extras/Mesa/docs/banner.html27
-rw-r--r--nx-X11/extras/Mesa/docs/bugs.html49
-rw-r--r--nx-X11/extras/Mesa/docs/conform.html695
-rw-r--r--nx-X11/extras/Mesa/docs/contents.html101
-rw-r--r--nx-X11/extras/Mesa/docs/custom.html27
-rw-r--r--nx-X11/extras/Mesa/docs/cvs_access.html106
-rw-r--r--nx-X11/extras/Mesa/docs/cvs_branches.html80
-rw-r--r--nx-X11/extras/Mesa/docs/debugging.html38
-rw-r--r--nx-X11/extras/Mesa/docs/demos.html18
-rw-r--r--nx-X11/extras/Mesa/docs/devinfo.html206
-rw-r--r--nx-X11/extras/Mesa/docs/download.html130
-rw-r--r--nx-X11/extras/Mesa/docs/enums.txt42
-rw-r--r--nx-X11/extras/Mesa/docs/envvars.html44
-rw-r--r--nx-X11/extras/Mesa/docs/extensions.html34
-rw-r--r--nx-X11/extras/Mesa/docs/faq.html394
-rw-r--r--nx-X11/extras/Mesa/docs/fbdev-dri.html315
-rw-r--r--nx-X11/extras/Mesa/docs/games.html64
-rw-r--r--nx-X11/extras/Mesa/docs/gears.pngbin0 -> 1608 bytes
-rw-r--r--nx-X11/extras/Mesa/docs/glfbdev-driver.html90
-rw-r--r--nx-X11/extras/Mesa/docs/glu.html45
-rw-r--r--nx-X11/extras/Mesa/docs/helpwanted.html74
-rw-r--r--nx-X11/extras/Mesa/docs/index.html29
-rw-r--r--nx-X11/extras/Mesa/docs/install.html309
-rw-r--r--nx-X11/extras/Mesa/docs/intro.html306
-rw-r--r--nx-X11/extras/Mesa/docs/libraries.html57
-rw-r--r--nx-X11/extras/Mesa/docs/license.html86
-rw-r--r--nx-X11/extras/Mesa/docs/lists.html55
-rw-r--r--nx-X11/extras/Mesa/docs/mangling.html28
-rw-r--r--nx-X11/extras/Mesa/docs/mesa.css33
-rw-r--r--nx-X11/extras/Mesa/docs/modelers.html70
-rw-r--r--nx-X11/extras/Mesa/docs/news.html1136
-rw-r--r--nx-X11/extras/Mesa/docs/osmesa.html77
-rw-r--r--nx-X11/extras/Mesa/docs/pbuffers.html54
-rw-r--r--nx-X11/extras/Mesa/docs/perf.html68
-rw-r--r--nx-X11/extras/Mesa/docs/precompiled.html26
-rw-r--r--nx-X11/extras/Mesa/docs/relnotes.html45
-rw-r--r--nx-X11/extras/Mesa/docs/science.html72
-rw-r--r--nx-X11/extras/Mesa/docs/sourcedocs.html26
-rw-r--r--nx-X11/extras/Mesa/docs/subset-A.html3579
-rw-r--r--nx-X11/extras/Mesa/docs/subset.html33
-rw-r--r--nx-X11/extras/Mesa/docs/systems.html56
-rw-r--r--nx-X11/extras/Mesa/docs/thanks.html134
-rw-r--r--nx-X11/extras/Mesa/docs/utilities.html26
-rw-r--r--nx-X11/extras/Mesa/docs/utility.html44
-rw-r--r--nx-X11/extras/Mesa/docs/webmaster.html24
-rw-r--r--nx-X11/extras/Mesa/include/GL/Makefile.am43
-rw-r--r--nx-X11/extras/Mesa/include/GL/amesa.h65
-rw-r--r--nx-X11/extras/Mesa/include/GL/directfbgl.h89
-rw-r--r--nx-X11/extras/Mesa/include/GL/dmesa.h160
-rw-r--r--nx-X11/extras/Mesa/include/GL/foomesa.h76
-rw-r--r--nx-X11/extras/Mesa/include/GL/fxmesa.h103
-rw-r--r--nx-X11/extras/Mesa/include/GL/ggimesa.h85
-rw-r--r--nx-X11/extras/Mesa/include/GL/gl.h2261
-rw-r--r--nx-X11/extras/Mesa/include/GL/gl_mangle.h1472
-rw-r--r--nx-X11/extras/Mesa/include/GL/glext.h6495
-rw-r--r--nx-X11/extras/Mesa/include/GL/glfbdev.h148
-rw-r--r--nx-X11/extras/Mesa/include/GL/glu.h340
-rw-r--r--nx-X11/extras/Mesa/include/GL/glu_mangle.h86
-rw-r--r--nx-X11/extras/Mesa/include/GL/glut.h748
-rw-r--r--nx-X11/extras/Mesa/include/GL/glut_h.dja340
-rw-r--r--nx-X11/extras/Mesa/include/GL/glutf90.h81
-rw-r--r--nx-X11/extras/Mesa/include/GL/glx.h551
-rw-r--r--nx-X11/extras/Mesa/include/GL/glx_mangle.h55
-rw-r--r--nx-X11/extras/Mesa/include/GL/glxext.h693
-rw-r--r--nx-X11/extras/Mesa/include/GL/internal/dri_interface.h477
-rw-r--r--nx-X11/extras/Mesa/include/GL/internal/glcore.h499
-rw-r--r--nx-X11/extras/Mesa/include/GL/internal/sarea.h94
-rw-r--r--nx-X11/extras/Mesa/include/GL/mesa_wgl.h123
-rw-r--r--nx-X11/extras/Mesa/include/GL/mglmesa.h79
-rw-r--r--nx-X11/extras/Mesa/include/GL/miniglx.h482
-rw-r--r--nx-X11/extras/Mesa/include/GL/osmesa.h280
-rw-r--r--nx-X11/extras/Mesa/include/GL/svgamesa.h97
-rw-r--r--nx-X11/extras/Mesa/include/GL/uglglutshapes.h45
-rw-r--r--nx-X11/extras/Mesa/include/GL/uglmesa.h155
-rw-r--r--nx-X11/extras/Mesa/include/GL/vms_x_fix.h880
-rw-r--r--nx-X11/extras/Mesa/include/GL/wmesa.h142
-rw-r--r--nx-X11/extras/Mesa/include/GL/xmesa.h390
-rw-r--r--nx-X11/extras/Mesa/include/GL/xmesa_x.h84
-rw-r--r--nx-X11/extras/Mesa/include/GL/xmesa_xf86.h153
-rw-r--r--nx-X11/extras/Mesa/include/GLES/egl.h274
-rw-r--r--nx-X11/extras/Mesa/include/GLES/egltypes.h45
-rw-r--r--nx-X11/extras/Mesa/mms-config.23
-rw-r--r--nx-X11/extras/Mesa/src/Makefile34
-rw-r--r--nx-X11/extras/Mesa/src/descrip.mms43
-rw-r--r--nx-X11/extras/Mesa/src/glw/GLwDrawA.c684
-rw-r--r--nx-X11/extras/Mesa/src/glw/GLwDrawA.h195
-rw-r--r--nx-X11/extras/Mesa/src/glw/GLwDrawAP.h130
-rw-r--r--nx-X11/extras/Mesa/src/glw/GLwMDrawA.c41
-rw-r--r--nx-X11/extras/Mesa/src/glw/GLwMDrawA.h41
-rw-r--r--nx-X11/extras/Mesa/src/glw/GLwMDrawAP.h41
-rw-r--r--nx-X11/extras/Mesa/src/glw/Makefile52
-rw-r--r--nx-X11/extras/Mesa/src/glw/README56
-rw-r--r--nx-X11/extras/Mesa/src/glx/Makefile12
-rw-r--r--nx-X11/extras/Mesa/src/glx/mini/Makefile86
-rw-r--r--nx-X11/extras/Mesa/src/glx/mini/NOTES115
-rw-r--r--nx-X11/extras/Mesa/src/glx/mini/dispatch.c64
-rw-r--r--nx-X11/extras/Mesa/src/glx/mini/driver.h169
-rw-r--r--nx-X11/extras/Mesa/src/glx/mini/example.miniglx.conf36
-rw-r--r--nx-X11/extras/Mesa/src/glx/mini/miniglx.c2563
-rw-r--r--nx-X11/extras/Mesa/src/glx/mini/miniglxP.h205
-rw-r--r--nx-X11/extras/Mesa/src/glx/mini/miniglx_events.c978
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/Makefile94
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/XF86dri.c617
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/clientattrib.c141
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/compsize.c190
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/dri_glx.c461
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/dri_glx.h61
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/eval.c132
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/glx_pbuffer.c556
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/glx_query.c102
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/glx_texture_compression.c347
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/glxclient.h690
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/glxcmds.c2969
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/glxext.c1864
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/glxextensions.c717
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/glxextensions.h279
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/indirect.c8472
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/indirect.h707
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/indirect_init.c779
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/indirect_init.h42
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/indirect_size.c377
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/indirect_size.h95
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/indirect_transpose_matrix.c83
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/indirect_va_private.h308
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/indirect_vertex_array.c1847
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/indirect_vertex_array.h57
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/indirect_vertex_program.c276
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/indirect_window_pos.c98
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/packrender.h249
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/packsingle.h219
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/pixel.c443
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/pixelstore.c341
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/render2.c363
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/renderpix.c215
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/single2.c833
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/singlepix.c105
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/vertarr.c203
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/xf86dri.h122
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/xf86dristr.h343
-rw-r--r--nx-X11/extras/Mesa/src/glx/x11/xfont.c377
-rw-r--r--nx-X11/extras/Mesa/src/mesa/Makefile230
-rw-r--r--nx-X11/extras/Mesa/src/mesa/Makefile.DJ168
-rw-r--r--nx-X11/extras/Mesa/src/mesa/Makefile.mgw206
-rw-r--r--nx-X11/extras/Mesa/src/mesa/array_cache/ac_context.c375
-rw-r--r--nx-X11/extras/Mesa/src/mesa/array_cache/ac_context.h99
-rw-r--r--nx-X11/extras/Mesa/src/mesa/array_cache/ac_import.c902
-rw-r--r--nx-X11/extras/Mesa/src/mesa/array_cache/acache.h132
-rw-r--r--nx-X11/extras/Mesa/src/mesa/array_cache/descrip.mms37
-rw-r--r--nx-X11/extras/Mesa/src/mesa/descrip.mms26
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/common/descrip.mms37
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/common/driverfuncs.c233
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/common/driverfuncs.h32
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/Makefile34
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/Makefile.template109
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/depthtmp.h253
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/dri_util.c1073
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/dri_util.h555
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/drirenderbuffer.c98
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/drirenderbuffer.h39
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/extension_helper.h5887
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.c496
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.h52
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/memops.h17
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/mmio.h62
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/mmx.h560
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/spantmp.h328
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/spantmp2.h609
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/spantmp_common.h81
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/stenciltmp.h182
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/texmem.c1339
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/texmem.h327
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/utils.c695
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/utils.h119
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/vblank.c347
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/vblank.h69
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlconfig.c1002
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlconfig.h124
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool.h94
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/Makefile96
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/de.po231
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/es.po219
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/fr.po225
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/gen_xmlpool.py191
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/nl.po230
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/options.h462
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/t_options.h230
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/fb/Doxyfile232
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/fb/Makefile21
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/fb/fb_dri.c786
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/fb/fb_egl.c881
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/Makefile36
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_bitmap.c159
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_bitmap.h8
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_clear.c354
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_clear.h9
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_context.h306
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_dd.c119
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_dd.h36
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_depth.c245
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_depth.h8
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_fifo.h28
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_fog.c73
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_lines.c111
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_lines.h18
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_linetmp.h81
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_lock.h37
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_points.c93
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_points.h15
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_pointtmp.h55
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_rendertmp.h646
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_span.c135
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_span.h10
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_state.c1223
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_state.h13
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_stencil.c226
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_stencil.h8
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tex.c53
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tex.h34
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tris.c945
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tris.h26
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tritmp.h239
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vb.c209
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vb.h45
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vbtmp.h151
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vtxfmt.c427
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vtxfmt.h8
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_xmesa.c753
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_xmesa.h26
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/server/ffb_dac.h367
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/server/ffb_drishare.h48
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/server/ffb_regs.h509
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/Makefile35
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_client.h6185
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_context.c226
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_context.h403
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_dd.c128
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_inithw.c551
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_lock.c59
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_lock.h84
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_macros.h324
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_regs.h659
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_render.c220
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_screen.c147
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_screen.h30
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_span.c313
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_state.c1730
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_tex.c433
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_texmem.c535
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_texstate.c216
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_tris.c659
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_tris.h36
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_tritmp.h497
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_vb.c362
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_vb.h60
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_xmesa.c266
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/server/glint_common.h64
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/server/glint_dri.h123
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/Makefile32
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810_3d_reg.h636
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810context.c572
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810context.h252
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810ioctl.c511
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810ioctl.h49
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810render.c173
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810screen.c471
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810screen.h99
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810span.c201
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810span.h14
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810state.c1025
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810state.h15
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810tex.c564
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810tex.h78
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810texmem.c183
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810texstate.c746
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810tris.c871
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810tris.h36
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810vb.c489
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810vb.h60
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/server/i810_common.h192
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/server/i810_dri.c975
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/server/i810_dri.h128
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/server/i810_reg.h992
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/Makefile31
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_3d_reg.h677
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_context.c626
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_context.h327
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_debug.c415
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_debug.h48
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_ioctl.c841
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_ioctl.h105
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_render.c226
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_screen.c557
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_screen.h113
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_span.c427
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_span.h51
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_state.c1707
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_state.h68
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_tex.c700
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_tex.h70
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_texmem.c237
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_texstate.c716
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_tris.c1056
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_tris.h37
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/server/i830_common.h288
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/server/i830_dri.h140
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/Makefile47
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_context.c122
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_context.h215
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_metaops.c733
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_reg.h641
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_state.c1089
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_tex.c345
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_texblend.c465
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_texstate.c483
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_vtbl.c456
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_context.c181
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_context.h351
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_debug.c299
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_fragprog.c1065
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_metaops.c516
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_program.c466
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_program.h163
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_reg.h833
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_state.c954
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_tex.c182
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_texprog.c668
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_texstate.c922
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_vtbl.c353
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_batchbuffer.c688
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_batchbuffer.h123
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_context.c712
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_context.h519
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_ioctl.c607
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_ioctl.h66
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_pixel.c490
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_reg.h84
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_render.c240
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_screen.c511
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_screen.h101
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_span.c379
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_span.h41
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_state.c285
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_tex.c831
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_tex.h42
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_tris.c920
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_tris.h46
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/server/i830_common.h169
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/server/i830_dri.h69
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/Makefile33
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_context.c338
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_context.h405
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_dd.c135
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_dd.h36
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_ioctl.c912
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_ioctl.h148
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_lock.c93
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_lock.h104
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_native_vb.c257
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_native_vbtmp.h562
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_reg.h406
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_screen.c553
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_screen.h78
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_span.c231
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_span.h41
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_state.c1216
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_state.h47
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_tex.c610
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_tex.h99
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_texmem.c867
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_texstate.c558
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_tris.c1921
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_tris.h43
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_vb.c642
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_vb.h77
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_vbtmp.h770
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/server/mach64_dri.h126
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/Doxyfile234
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/Makefile34
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/README26
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mga_texcombine.c672
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mga_texstate.c902
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mga_xmesa.c1020
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mga_xmesa.h155
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgacontext.h372
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgadd.c98
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgadd.h36
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaioctl.c743
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaioctl.h111
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgapixel.c664
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgapixel.h36
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaregs.h1395
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgarender.c172
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaspan.c312
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaspan.h40
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgastate.c1237
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgastate.h39
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatex.c538
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatex.h51
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatexmem.c278
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatris.c912
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatris.h52
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgavb.c480
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgavb.h66
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga.h115
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_bios.h143
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_dri.c1089
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_dri.h113
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_macros.h118
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_reg.h484
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/Makefile32
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_context.c364
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_context.h269
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_dd.c148
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_dd.h41
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_ioctl.c813
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_ioctl.h144
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_lock.c123
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_lock.h108
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_screen.c547
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_screen.h84
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_span.c368
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_span.h46
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_state.c1261
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_state.h51
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_tex.c617
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_tex.h85
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_texmem.c301
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_texobj.h68
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_texstate.c648
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_tris.c769
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_tris.h48
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/pci_ids.h57
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128.h465
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_dri.c1113
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_dri.h103
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_macros.h135
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_reg.h1394
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_version.h60
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/Doxyfile232
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/Makefile62
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_cmdbuf.c423
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_context.c694
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_context.h995
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_ioctl.c966
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_ioctl.h215
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_lock.c127
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_lock.h107
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_maos.c15
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_maos.h44
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_maos_arrays.c530
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_pixel.c492
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_pixel.h40
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_reg.h1454
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_sanity.c1341
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_sanity.h8
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_screen.c737
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_screen.h106
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_span.c367
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_span.h46
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_state.c2383
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_state.h67
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_state_init.c798
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_swtcl.c957
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_swtcl.h76
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_tcl.c583
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_tcl.h69
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_tex.c1183
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_tex.h47
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_texmem.c526
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_texstate.c1468
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt.c1227
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt.h123
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt_c.c1002
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt_sse.c234
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt_x86.c440
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxtmp_x86.S495
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/Makefile83
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/pixel_shader.h103
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_context.h822
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_ioctl.h204
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_reg.h1423
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_sanity.h7
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_state.h58
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_tcl.h50
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_tex.h51
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_cmdbuf.c655
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_cmdbuf.h118
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_context.c453
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_context.h844
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_emit.h282
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_fixed_pipelines.h294
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_fragprog.c1090
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_fragprog.h49
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_fragprog_swz.c1343
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_ioctl.c774
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_ioctl.h62
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_maos.c561
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_maos.h49
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_program.h151
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_reg.h1387
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_render.c726
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_shader.c112
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_state.c2321
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_state.h69
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_tex.c1051
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_tex.h51
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_texmem.c514
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_texprog.c270
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_texprog.h9
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_texstate.c1465
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_vertexprog.c952
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_context.c312
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_context.h249
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_ioctl.c372
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_ioctl.h53
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_lock.c166
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_lock.h122
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_screen.c879
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_screen.h112
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_span.c391
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_span.h46
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_state.c245
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_state.h45
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/vertex_shader.h91
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/Makefile42
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_compat.c302
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_context.c630
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_context.h868
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_ioctl.c1283
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_ioctl.h217
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_lighting.c682
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_lock.c135
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_lock.h108
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos.c12
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos.h44
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos_arrays.c604
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos_vbtmp.h284
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos_verts.c367
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_sanity.c1070
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_sanity.h8
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.c656
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.h103
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_span.c346
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_span.h46
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_state.c2295
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_state.h74
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_state_init.c572
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_swtcl.c983
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_swtcl.h69
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tcl.c489
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tcl.h66
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tex.c866
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tex.h50
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_texmem.c404
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_texstate.c1171
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt.c1093
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt.h120
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt_c.c922
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt_sse.c232
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt_x86.c437
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxtmp_x86.S494
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon.h202
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_dri.c1336
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_dri.h116
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_egl.c978
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_macros.h129
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_reg.h2142
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/Makefile36
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_common.h83
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_context.c258
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_context.h444
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_dd.c108
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_dri.h143
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_inithw.c79
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_lock.c62
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_lock.h99
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_macros.h229
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_regs.h367
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_render.c203
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_screen.c99
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_screen.h39
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_span.c334
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_state.c888
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tex.c554
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tex.h28
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_texmem.c582
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_texstate.c300
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tris.c850
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tris.h11
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tritmp.h958
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_vb.c339
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_vb.h39
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_xmesa.c362
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3virgetri.h383
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/Makefile30
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savage_3d_reg.h699
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savage_bci.h612
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savage_init.h168
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savage_xmesa.c1056
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagecontext.h331
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagedd.c119
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagedd.h32
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savageioctl.c657
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savageioctl.h203
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagerender.c370
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagespan.c343
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagespan.h137
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagestate.c1765
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagestate.h41
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagetex.c2133
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagetex.h83
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagetris.c1297
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagetris.h49
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/server/savage_dri.h76
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/Makefile35
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/server/sis_common.h63
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/server/sis_dri.h85
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_alloc.c243
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_alloc.h44
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_clear.c451
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_common2.h140
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_context.c523
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_context.h440
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_dd.c181
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_dd.h39
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_debug.c156
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_debug.h45
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_fog.c190
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_lock.c76
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_lock.h87
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_reg.h868
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_screen.c468
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_screen.h62
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_span.c237
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_span.h46
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_state.c853
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_state.h54
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_stencil.c185
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_stencil.h37
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tex.c484
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tex.h38
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_texstate.c672
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tris.c1071
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tris.h71
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tritmp.h70
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/BUGS64
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/Makefile37
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fastpath.S84
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fasttmp.h314
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/dri_glide.h60
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/server/tdfx_dri.c471
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/server/tdfx_dri.h28
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.c1028
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.h1007
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.c322
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.h45
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_glide.h606
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.c90
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.h144
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.c689
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.h77
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.c808
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.h50
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.c492
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.h73
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.c1427
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.h49
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.c1449
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.h61
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.c1914
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.h102
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.c994
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.h84
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.c2209
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.h44
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.c1293
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.h42
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.c353
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.h69
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h266
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/Makefile26
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_context.c472
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_context.h242
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_dd.c127
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_dri.h28
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_lock.h11
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_state.c555
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_tris.c1125
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_vb.c434
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/Makefile32
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via.h11
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_dri.c1252
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_dri.h78
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_driver.h309
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_priv.h70
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_regs.h197
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_3d_reg.h1652
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_context.c782
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_context.h412
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_drmclient.h29
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_fb.c243
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_fb.h42
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_ioctl.c970
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_ioctl.h135
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_memcpy.c138
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_render.c131
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_screen.c491
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_screen.h95
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_span.c289
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_span.h37
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_state.c1550
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_state.h39
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_tex.c970
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_tex.h41
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_texcombine.c424
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_tris.c1190
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_tris.h35
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/x11/Makefile89
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/x11/x11_dri.c487
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/dri/x11/x11_dri.h12
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/fbdev/glfbdev.c861
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/glide/fxapi.c951
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/glide/fxdd.c2197
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/glide/fxddspan.c663
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/glide/fxddtex.c1849
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/glide/fxdrv.h771
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/glide/fxg.c2309
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/glide/fxg.h382
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/glide/fxglidew.c269
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/glide/fxglidew.h228
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/glide/fxsetup.c2217
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/glide/fxsetup.h850
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/glide/fxtexman.c874
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/glide/fxtris.c1834
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/glide/fxvb.c838
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/glide/fxvbtmp.h369
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/osmesa/Makefile.win39
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/osmesa/descrip.mms41
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/osmesa/osmesa.c1333
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/osmesa/osmesa.def13
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/x11/descrip.mms51
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/x11/fakeglx.c2886
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/x11/glxapi.c1348
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/x11/glxapi.h223
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/x11/glxheader.h64
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/x11/realglx.c180
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/x11/realglx.h326
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/x11/xfonts.c377
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/x11/xfonts.h41
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_api.c2675
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_buffer.c115
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_dd.c1201
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_line.c674
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_span.c4800
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_tri.c1623
-rw-r--r--nx-X11/extras/Mesa/src/mesa/drivers/x11/xmesaP.h555
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/.cvsignore11
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/EXT_framebuffer_object.xml188
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/Makefile70
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/descrip.mms37
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/dispatch.h4151
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/extension_helper.py316
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/glX_XML.py531
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/glX_doc.py280
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/glX_proto_common.py95
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/glX_proto_send.py1044
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/glX_proto_size.py705
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/gl_API.dtd134
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/gl_API.xml11485
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/gl_SPARC_asm.py135
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/gl_XML.py813
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/gl_apitemp.py216
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/gl_enums.py217
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/gl_offsets.py105
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/gl_procs.py155
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/gl_table.py194
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/gl_x86-64_asm.py316
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/gl_x86_asm.py240
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/glapi.c1058
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/glapi.h152
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/glapioffsets.h1266
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/glapitable.h858
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/glapitemp.h6175
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/glprocs.h2043
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/glthread.c367
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/glthread.h314
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/license.py47
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/mesadef.py223
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/glapi/next_available_offset.sh39
-rw-r--r--nx-X11/extras/Mesa/src/mesa/glapi/typeexpr.py288
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/Imakefile129
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/KNOWN_BUGS21
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/Makefile.ugl364
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/Makefile.win208
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/accum.c110
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/accum.h62
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/api_arrayelt.c796
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/api_arrayelt.h37
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/api_eval.h42
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/api_loopback.c1647
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/api_loopback.h37
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/api_noop.c964
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/api_noop.h147
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/api_validate.c238
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/api_validate.h49
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/attrib.c1338
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/attrib.h68
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/blend.c579
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/blend.h78
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/bufferobj.c940
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/bufferobj.h124
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/buffers.c723
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/buffers.h78
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/clip.c160
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/clip.h49
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/colormac.h227
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/colortab.c1445
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/colortab.h110
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/config.h324
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/context.c1750
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/context.h340
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/convolve.c1527
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/convolve.h114
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/dd.h1063
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/debug.c218
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/debug.h60
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/depth.c189
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/depth.h62
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/descrip.mms210
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/dispatch.c95
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/dlist.c8434
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/dlist.h103
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/drawpix.c317
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/drawpix.h55
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/enable.c1456
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/enable.h57
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/enums.c4570
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/enums.h55
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/eval.c962
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/eval.h128
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/execmem.c132
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/extensions.c516
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/extensions.h84
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/fbobject.c1357
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/fbobject.h114
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/feedback.c541
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/feedback.h82
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/fog.c177
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/fog.h66
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/framebuffer.c528
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/framebuffer.h67
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/get.c5646
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/get.h59
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/get_gen.py1200
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/getstring.c261
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/glheader.h315
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/hash.c451
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/hash.h59
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/hint.c153
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/hint.h57
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/histogram.c1187
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/histogram.h89
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/image.c4202
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/image.h217
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/imports.c1203
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/imports.h782
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/light.c1313
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/light.h141
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/lines.c134
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/lines.h48
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/macros.h654
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/matrix.c943
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/matrix.h131
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/mesa.def491
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/mm.c220
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/mm.h115
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/mtypes.h2930
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/occlude.c353
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/occlude.h61
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/pixel.c2119
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/pixel.h153
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/points.c294
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/points.h60
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/polygon.c383
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/polygon.h69
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/rastpos.c1001
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/rastpos.h193
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/renderbuffer.c1869
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/renderbuffer.h84
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/simple_list.h197
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/state.c1040
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/state.h43
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/stencil.c466
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/stencil.h73
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/texcompress.c254
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/texcompress.h65
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/texcompress_fxt1.c1663
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/texcompress_s3tc.c555
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/texenvprogram.c1165
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/texenvprogram.h40
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/texformat.c1314
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/texformat.h229
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/texformat_tmp.h1762
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/teximage.c3330
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/teximage.h239
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/texobj.c1000
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/texobj.h95
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/texrender.c226
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/texrender.h12
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/texstate.c3271
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/texstate.h192
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/texstore.c4055
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/texstore.h261
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/varray.c994
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/varray.h160
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/version.h52
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/vsnprintf.c165
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/vtxfmt.c185
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/vtxfmt.h43
-rw-r--r--nx-X11/extras/Mesa/src/mesa/main/vtxfmt_tmp.h537
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/descrip.mms45
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_clip_tmp.h243
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_copy_tmp.h86
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_debug.h42
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_debug_clip.c371
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_debug_norm.c384
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_debug_util.h320
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_debug_xform.c338
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_dotprod_tmp.h102
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_eval.c461
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_eval.h103
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_matrix.c1622
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_matrix.h195
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_norm_tmp.h390
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_trans_tmp.h287
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_translate.c718
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_translate.h106
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_vector.c190
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_vector.h95
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_xform.c230
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_xform.h185
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/m_xform_tmp.h810
-rw-r--r--nx-X11/extras/Mesa/src/mesa/math/mathmod.h41
-rw-r--r--nx-X11/extras/Mesa/src/mesa/ppc/common_ppc.c88
-rw-r--r--nx-X11/extras/Mesa/src/mesa/ppc/common_ppc_features.h51
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/arbfragparse.c229
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/arbfragparse.h39
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/arbprogparse.c4134
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/arbprogparse.h75
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/arbprogram.c724
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/arbprogram.h128
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/arbprogram.syn2786
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/arbprogram_syn.h1327
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/arbvertparse.c207
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/arbvertparse.h36
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/asmopcodes.reg78
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/atifragshader.c439
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/atifragshader.h105
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/descrip.mms83
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/grammar/descrip.mms41
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar.c3148
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar.h103
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar.syn567
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_crt.c64
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_crt.h20
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_mesa.c87
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_mesa.h43
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_syn.h202
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/nvfragparse.c1826
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/nvfragparse.h52
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/nvfragprog.h168
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/nvprogram.c869
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/nvprogram.h119
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/nvvertexec.c851
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/nvvertexec.h43
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/nvvertparse.c1603
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/nvvertparse.h50
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/nvvertprog.h111
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/program.c1405
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/program.h298
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/shaderobjects.c1182
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/shaderobjects.h168
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/shaderobjects_3dlabs.c1052
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/shaderobjects_3dlabs.h40
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/Include/BaseTypes.h133
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/Include/Common.h288
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/Include/ConstantUnion.h50
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/Include/InfoSink.h135
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/Include/InitializeGlobals.h43
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/Include/InitializeParseContext.h44
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/Include/PoolAlloc.h346
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/Include/ResourceLimits.h61
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/Include/ShHandle.h177
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/Include/Types.h297
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/Include/intermediate.h516
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Gen_glslang.cpp2942
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Gen_glslang_tab.cpp4354
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/InfoSink.cpp107
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Initialize.cpp948
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Initialize.h58
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/IntermTraverse.cpp243
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Intermediate.cpp2110
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/MMap.h84
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/ParseHelper.cpp1452
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/ParseHelper.h143
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/PoolAlloc.cpp349
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/QualifierAlive.cpp91
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/QualifierAlive.h35
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/RemoveTree.cpp98
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/RemoveTree.h35
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/ShaderLang.cpp607
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/SymbolTable.cpp235
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/SymbolTable.h320
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/glslang.l614
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/glslang.y2009
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/glslang_tab.h260
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/intermOut.cpp496
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/localintermediate.h91
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/parseConst.cpp344
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/atom.c768
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/atom.h96
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/compile.h132
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/cpp.c1037
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/cpp.h119
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/cpp_comment_fix.c76
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/cppstruct.c185
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/memory.c191
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/memory.h89
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/parser.h126
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/preprocess.h84
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/scanner.c789
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/scanner.h118
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/slglobals.h115
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/symbols.c318
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/symbols.h145
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/tokens.c462
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/tokens.h122
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/unistd.h1
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/OGLCompilersDLL/Initialisation.cpp151
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/OGLCompilersDLL/Initialisation.h47
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/OSDependent/Linux/osinclude.h78
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/OSDependent/Linux/ossource.cpp140
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/OSDependent/Windows/osinclude.h68
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/OSDependent/Windows/ossource.cpp119
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/Public/ShaderLang.h212
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/Public/ShaderLangExt.h57
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/slang/descrip.mms52
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/library/gc_to_bin.c79
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/slang/library/gc_to_string.py55
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_common_builtin.gc1410
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_common_builtin_gc.h1410
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_common_builtin_gc_bin.h943
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_core.gc1565
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_core_gc.h1565
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_core_gc_bin.h490
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_fragment_builtin.gc366
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_fragment_builtin_gc.h366
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_fragment_builtin_gc_bin.h87
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_shader.syn1508
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_shader_syn.h758
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_version.syn118
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_version_syn.h64
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_vertex_builtin.gc262
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_vertex_builtin_gc.h262
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_vertex_builtin_gc_bin.h82
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble.c1208
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble.h145
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_assignment.c187
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_assignment.h45
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_conditional.c485
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_conditional.h67
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_constructor.c339
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_constructor.h80
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_typeinfo.c430
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_typeinfo.h67
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/slang/slang_compile.c2369
-rw-r--r--nx-X11/extras/Mesa/src/mesa/shader/slang/slang_compile.h271
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_execute.c352
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_execute.h57
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_mesa.cpp144
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_mesa.h36
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_preprocess.c87
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_preprocess.h39
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_storage.c255
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_storage.h109
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_utility.c73
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/slang_utility.h51
-rwxr-xr-xnx-X11/extras/Mesa/src/mesa/shader/slang/traverse_wrap.h112
-rw-r--r--nx-X11/extras/Mesa/src/mesa/sources335
-rw-r--r--nx-X11/extras/Mesa/src/mesa/sparc/clip.S243
-rw-r--r--nx-X11/extras/Mesa/src/mesa/sparc/glapi_sparc.S1884
-rw-r--r--nx-X11/extras/Mesa/src/mesa/sparc/norm.S609
-rw-r--r--nx-X11/extras/Mesa/src/mesa/sparc/sparc.c177
-rw-r--r--nx-X11/extras/Mesa/src/mesa/sparc/sparc.h38
-rw-r--r--nx-X11/extras/Mesa/src/mesa/sparc/sparc_matrix.h170
-rw-r--r--nx-X11/extras/Mesa/src/mesa/sparc/xform.S1393
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/NOTES55
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/descrip.mms76
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_aaline.c554
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_aaline.h39
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_aalinetemp.h329
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_aatriangle.c495
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_aatriangle.h39
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_aatritemp.h549
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_accum.c584
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_accum.h37
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_alpha.c224
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_alpha.h39
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_atifragshader.c625
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_atifragshader.h37
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_bitmap.c282
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_blend.c872
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_blend.h43
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_buffers.c408
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_context.c750
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_context.h411
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_copypix.c801
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_depth.c1365
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_depth.h56
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_drawpix.c1007
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_drawpix.h36
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_feedback.c161
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_feedback.h51
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_fog.c327
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_fog.h45
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_fragprog_to_c.c822
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_imaging.c213
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_lines.c338
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_lines.h41
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_linetemp.h454
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_logic.c244
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_logic.h44
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_masking.c172
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_masking.h58
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_nvfragprog.c1507
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_nvfragprog.h37
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_pixeltex.c111
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_pixeltex.h38
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_points.c275
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_points.h39
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_pointtemp.h419
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_readpix.c584
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_span.c1511
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_span.h75
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_spantemp.h251
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_stencil.c1221
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_stencil.h53
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_tcc.c189
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_texstore.c430
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_texture.c3963
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_texture.h42
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_triangle.c1175
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_triangle.h51
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_trispan.h31
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_tritemp.h1308
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_zoom.c428
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/s_zoom.h54
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast/swrast.h299
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast_setup/NOTES65
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast_setup/descrip.mms39
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_context.c250
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_context.h45
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_triangle.c314
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_triangle.h39
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_tritmp.h222
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_vb.h38
-rw-r--r--nx-X11/extras/Mesa/src/mesa/swrast_setup/swrast_setup.h61
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/NOTES102
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/descrip.mms74
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_array_api.c414
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_array_api.h46
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_array_import.c352
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_array_import.h36
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_context.c294
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_context.h806
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_pipeline.c218
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_pipeline.h76
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_save_api.c1724
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_save_api.h58
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_save_loopback.c342
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_save_playback.c215
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram.c1496
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram.h189
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram_sse.c1222
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_cliptmp.h270
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_cull.c97
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_fog.c266
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_light.c362
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_lighttmp.h824
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_normals.c189
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_points.c111
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_program.c281
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_render.c352
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_rendertmp.h440
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_texgen.c611
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_texmat.c130
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vb_vertex.c264
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vertex.c509
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vertex.h169
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vertex_generic.c1119
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vertex_sse.c670
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vp_build.c1497
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vp_build.h35
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_api.c995
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_api.h90
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_eval.c254
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_exec.c284
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_generic.c538
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_x86.c385
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_x86_gcc.S557
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl/tnl.h89
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/NOTES.imm112
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_capi.h419
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_napi.h226
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_primtmp.h570
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_tapi.h75
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_vapi.h159
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_vb.c204
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_vbtmp.h268
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd.c58
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_dmatmp.h1254
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_dmatmp2.h914
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_rendertmp.h434
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_triemit.h164
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_tritmp.h833
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_unfilled.h212
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_vb.c344
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_vbtmp.h675
-rw-r--r--nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_vertex.h78
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86-64/Makefile29
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86-64/calling_convention.txt50
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86-64/glapi_x86-64.S31002
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86-64/x86-64.c115
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86-64/x86-64.h32
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86-64/xform4.S458
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/3dnow.c92
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/3dnow.h39
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/3dnow_normal.S848
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/3dnow_xform1.S433
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/3dnow_xform2.S473
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/3dnow_xform3.S557
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/3dnow_xform4.S566
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/Makefile46
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/assyntax.h1746
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/clip_args.h60
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/common_x86.c448
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/common_x86_asm.S215
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/common_x86_asm.h60
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/common_x86_features.h68
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/common_x86_macros.h107
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/gen_matypes.c251
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/glapi_x86.S1155
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/mmx.h51
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/mmx_blend.S366
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/mmx_blendtmp.h114
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/norm_args.h58
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/read_rgba_span_x86.S689
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/read_rgba_span_x86.h56
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/rtasm/x86sse.c997
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/rtasm/x86sse.h223
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/sse.c123
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/sse.h39
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/sse_normal.S257
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/sse_xform1.S442
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/sse_xform2.S461
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/sse_xform3.S507
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/sse_xform4.S231
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/x86.c96
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/x86.h36
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/x86_cliptest.S403
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/x86_xform2.S570
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/x86_xform3.S640
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/x86_xform4.S673
-rw-r--r--nx-X11/extras/Mesa/src/mesa/x86/xform_args.h52
-rw-r--r--nx-X11/extras/Mesa/vms/analyze_map.com148
-rw-r--r--nx-X11/extras/Mesa/vms/xlib.opt2
-rw-r--r--nx-X11/extras/Mesa/vms/xlib_share.opt7
-rw-r--r--nx-X11/extras/Mesa/windows/VC6/mesa/gdi/gdi.dsp141
-rw-r--r--nx-X11/extras/Mesa/windows/VC6/mesa/glu/compileDebug.txt82
-rw-r--r--nx-X11/extras/Mesa/windows/VC6/mesa/glu/compileRelease.txt82
-rw-r--r--nx-X11/extras/Mesa/windows/VC6/mesa/glu/glu.dsp985
-rw-r--r--nx-X11/extras/Mesa/windows/VC6/mesa/glu/objectsDebug.txt73
-rw-r--r--nx-X11/extras/Mesa/windows/VC6/mesa/glu/objectsRelease.txt73
-rw-r--r--nx-X11/extras/Mesa/windows/VC6/mesa/mesa.dsw74
-rw-r--r--nx-X11/extras/Mesa/windows/VC6/mesa/mesa/mesa.dsp1350
-rw-r--r--nx-X11/extras/Mesa/windows/VC6/mesa/osmesa/osmesa.dsp125
-rw-r--r--nx-X11/extras/Mesa/windows/VC6/progs/demos/gears.dsp114
-rw-r--r--nx-X11/extras/Mesa/windows/VC6/progs/glut/glut.dsp333
-rw-r--r--nx-X11/extras/Mesa/windows/VC6/progs/progs.dsw41
-rw-r--r--nx-X11/extras/Mesa/windows/VC7/mesa/gdi/gdi.vcproj181
-rw-r--r--nx-X11/extras/Mesa/windows/VC7/mesa/glu/glu.vcproj752
-rw-r--r--nx-X11/extras/Mesa/windows/VC7/mesa/mesa.sln41
-rw-r--r--nx-X11/extras/Mesa/windows/VC7/mesa/mesa/mesa.vcproj1084
-rw-r--r--nx-X11/extras/Mesa/windows/VC7/mesa/osmesa/osmesa.vcproj168
-rw-r--r--nx-X11/extras/Mesa/windows/VC7/progs/demos/gears.vcproj154
-rw-r--r--nx-X11/extras/Mesa/windows/VC7/progs/glut/glut.vcproj322
-rw-r--r--nx-X11/extras/Mesa/windows/VC7/progs/progs.sln27
1447 files changed, 658409 insertions, 0 deletions
diff --git a/nx-X11/extras/Mesa/Makefile b/nx-X11/extras/Mesa/Makefile
new file mode 100644
index 000000000..ea8d6fb98
--- /dev/null
+++ b/nx-X11/extras/Mesa/Makefile
@@ -0,0 +1,451 @@
+# Top-level Mesa makefile
+
+TOP = .
+
+SUBDIRS = src progs
+
+
+default: $(TOP)/configs/current
+ @for dir in $(SUBDIRS) ; do \
+ (cd $$dir ; $(MAKE)) || exit 1 ; \
+ done
+
+
+doxygen:
+ (cd doxygen ; make) ; \
+
+clean:
+ @for dir in $(SUBDIRS) ; do \
+ (cd $$dir ; $(MAKE) clean) ; \
+ done
+
+
+realclean:
+ touch $(TOP)/configs/current
+ $(MAKE) clean
+ -rm -rf lib*
+ -rm -f $(TOP)/configs/current
+ -rm -f `find . -name \*.o`
+ -rm -f `find . -name \*.a`
+ -rm -f `find . -name \*.so`
+ -rm -f `find . -name depend`
+
+
+
+install:
+ @echo "Installing"
+ $(TOP)/bin/installmesa $(DESTDIR)
+
+# DirectFBGL module installation
+linux-directfb-install:
+ cd src/mesa/drivers/directfb && $(MAKE) install
+
+# If there's no current configuration file
+$(TOP)/configs/current:
+ @echo
+ @echo
+ @echo "Please choose a configuration from the following list:"
+ @ls -1 $(TOP)/configs | grep -v "current\|default\|CVS"
+ @echo
+ @echo "Then type 'make <config>' (ex: 'make linux-x86')"
+ @echo "(ignore the following error message)"
+ @exit 1
+
+
+# Rules to set/install a specific build configuration
+aix \
+aix-64 \
+aix-gcc \
+aix-static \
+beos \
+darwin \
+darwin-static \
+freebsd \
+freebsd-dri \
+freebsd-dri-amd64 \
+freebsd-dri-x86 \
+hpux10 \
+hpux10-gcc \
+hpux10-static \
+hpux11-32 \
+hpux11-32-static \
+hpux11-32-static-nothreads \
+hpux11-64 \
+hpux11-64-static \
+hpux9 \
+hpux9-gcc \
+irix6-64 \
+irix6-64-static \
+irix6-n32 \
+irix6-n32-static \
+irix6-o32 \
+irix6-o32-static \
+linux \
+linux-alpha \
+linux-alpha-static \
+linux-debug \
+linux-directfb \
+linux-dri \
+linux-dri-x86 \
+linux-dri-x86-64 \
+linux-dri-ppc \
+linux-indirect \
+linux-fbdev \
+linux-glide \
+linux-icc \
+linux-icc-static \
+linux-osmesa16 \
+linux-osmesa16-static \
+linux-osmesa32 \
+linux-ppc \
+linux-ppc-static \
+linux-solo \
+linux-solo-x86 \
+linux-solo-ia64 \
+linux-sparc \
+linux-sparc5 \
+linux-static \
+linux-ultrasparc \
+linux-tcc \
+linux-x86 \
+linux-x86-debug \
+linux-x86-32 \
+linux-x86-64 \
+linux-x86-64-debug \
+linux-x86-64-static \
+linux-x86-xcb \
+linux-x86-glide \
+linux-x86-static \
+netbsd \
+openbsd \
+osf1 \
+solaris-x86 \
+solaris-x86-gcc \
+sunos4 \
+sunos4-gcc \
+sunos4-static \
+sunos5 \
+sunos5-gcc \
+sunos5-smp \
+ultrix-gcc:
+ (cd configs && rm -f current && ln -s $@ current)
+ $(MAKE) default
+
+
+# Rules for making release tarballs
+
+DIRECTORY = Mesa-6.4.1
+LIB_NAME = MesaLib-6.4.1
+DEMO_NAME = MesaDemos-6.4.1
+GLUT_NAME = MesaGLUT-6.4.1
+
+MAIN_FILES = \
+ $(DIRECTORY)/Makefile* \
+ $(DIRECTORY)/descrip.mms \
+ $(DIRECTORY)/mms-config. \
+ $(DIRECTORY)/bin/mklib \
+ $(DIRECTORY)/bin/installmesa \
+ $(DIRECTORY)/configs/[a-z]* \
+ $(DIRECTORY)/docs/*.html \
+ $(DIRECTORY)/docs/COPYING \
+ $(DIRECTORY)/docs/README.* \
+ $(DIRECTORY)/docs/RELNOTES* \
+ $(DIRECTORY)/docs/VERSIONS \
+ $(DIRECTORY)/docs/*.spec \
+ $(DIRECTORY)/include/GL/internal/glcore.h \
+ $(DIRECTORY)/include/GL/amesa.h \
+ $(DIRECTORY)/include/GL/dmesa.h \
+ $(DIRECTORY)/include/GL/directfbgl.h \
+ $(DIRECTORY)/include/GL/fxmesa.h \
+ $(DIRECTORY)/include/GL/ggimesa.h \
+ $(DIRECTORY)/include/GL/gl.h \
+ $(DIRECTORY)/include/GL/glext.h \
+ $(DIRECTORY)/include/GL/gl_mangle.h \
+ $(DIRECTORY)/include/GL/glu.h \
+ $(DIRECTORY)/include/GL/glu_mangle.h \
+ $(DIRECTORY)/include/GL/glx.h \
+ $(DIRECTORY)/include/GL/glxext.h \
+ $(DIRECTORY)/include/GL/glx_mangle.h \
+ $(DIRECTORY)/include/GL/mesa_wgl.h \
+ $(DIRECTORY)/include/GL/mglmesa.h \
+ $(DIRECTORY)/include/GL/osmesa.h \
+ $(DIRECTORY)/include/GL/svgamesa.h \
+ $(DIRECTORY)/include/GL/ugl*.h \
+ $(DIRECTORY)/include/GL/vms_x_fix.h \
+ $(DIRECTORY)/include/GL/wmesa.h \
+ $(DIRECTORY)/include/GL/xmesa.h \
+ $(DIRECTORY)/include/GL/xmesa_x.h \
+ $(DIRECTORY)/include/GL/xmesa_xf86.h \
+ $(DIRECTORY)/include/GLView.h \
+ $(DIRECTORY)/src/Makefile \
+ $(DIRECTORY)/src/descrip.mms \
+ $(DIRECTORY)/src/mesa/Makefile* \
+ $(DIRECTORY)/src/mesa/sources \
+ $(DIRECTORY)/src/mesa/descrip.mms \
+ $(DIRECTORY)/src/mesa/depend \
+ $(DIRECTORY)/src/mesa/main/*.[chS] \
+ $(DIRECTORY)/src/mesa/main/descrip.mms \
+ $(DIRECTORY)/src/mesa/glapi/*.[chS] \
+ $(DIRECTORY)/src/mesa/glapi/descrip.mms \
+ $(DIRECTORY)/src/mesa/array_cache/*.[ch] \
+ $(DIRECTORY)/src/mesa/array_cache/descrip.mms \
+ $(DIRECTORY)/src/mesa/math/*.[ch] \
+ $(DIRECTORY)/src/mesa/math/descrip.mms \
+ $(DIRECTORY)/src/mesa/shader/*.[ch] \
+ $(DIRECTORY)/src/mesa/shader/descrip.mms \
+ $(DIRECTORY)/src/mesa/shader/grammar/*.[ch] \
+ $(DIRECTORY)/src/mesa/shader/grammar/descrip.mms \
+ $(DIRECTORY)/src/mesa/shader/slang/*.[ch] \
+ $(DIRECTORY)/src/mesa/shader/slang/descrip.mms \
+ $(DIRECTORY)/src/mesa/shader/slang/library/*.[ch] \
+ $(DIRECTORY)/src/mesa/swrast/*.[ch] \
+ $(DIRECTORY)/src/mesa/swrast/descrip.mms \
+ $(DIRECTORY)/src/mesa/swrast_setup/*.[ch] \
+ $(DIRECTORY)/src/mesa/swrast_setup/descrip.mms \
+ $(DIRECTORY)/src/mesa/tnl/*.[chS] \
+ $(DIRECTORY)/src/mesa/tnl/descrip.mms \
+ $(DIRECTORY)/src/mesa/tnl_dd/*.[ch] \
+ $(DIRECTORY)/src/mesa/tnl_dd/imm/*.[ch] \
+ $(DIRECTORY)/src/mesa/tnl_dd/imm/NOTES.imm \
+ $(DIRECTORY)/src/mesa/drivers/beos/*.cpp \
+ $(DIRECTORY)/src/mesa/drivers/beos/Makefile \
+ $(DIRECTORY)/src/mesa/drivers/common/*.[ch] \
+ $(DIRECTORY)/src/mesa/drivers/common/descrip.mms \
+ $(DIRECTORY)/src/mesa/drivers/directfb/*.[ch] \
+ $(DIRECTORY)/src/mesa/drivers/directfb/Makefile \
+ $(DIRECTORY)/src/mesa/drivers/dos/*.[chS] \
+ $(DIRECTORY)/src/mesa/drivers/fbdev/glfbdev.c \
+ $(DIRECTORY)/src/mesa/drivers/glide/*.[ch] \
+ $(DIRECTORY)/src/mesa/drivers/ggi/*.[ch] \
+ $(DIRECTORY)/src/mesa/drivers/ggi/ggimesa.conf.in \
+ $(DIRECTORY)/src/mesa/drivers/ggi/default/*.c \
+ $(DIRECTORY)/src/mesa/drivers/ggi/default/genkgi.conf.in \
+ $(DIRECTORY)/src/mesa/drivers/ggi/display/*.c \
+ $(DIRECTORY)/src/mesa/drivers/ggi/display/fbdev.conf.in \
+ $(DIRECTORY)/src/mesa/drivers/ggi/include/ggi/mesa/*.h \
+ $(DIRECTORY)/src/mesa/drivers/osmesa/Makefile.win \
+ $(DIRECTORY)/src/mesa/drivers/osmesa/descrip.mms \
+ $(DIRECTORY)/src/mesa/drivers/osmesa/osmesa.def \
+ $(DIRECTORY)/src/mesa/drivers/osmesa/*.[ch] \
+ $(DIRECTORY)/src/mesa/drivers/svga/*.[ch] \
+ $(DIRECTORY)/src/mesa/drivers/windows/*/*.[ch] \
+ $(DIRECTORY)/src/mesa/drivers/windows/*/*.def \
+ $(DIRECTORY)/src/mesa/drivers/x11/descrip.mms \
+ $(DIRECTORY)/src/mesa/drivers/x11/*.[ch] \
+ $(DIRECTORY)/src/mesa/ppc/*.[ch] \
+ $(DIRECTORY)/src/mesa/sparc/*.[chS] \
+ $(DIRECTORY)/src/mesa/x86/Makefile \
+ $(DIRECTORY)/src/mesa/x86/*.[ch] \
+ $(DIRECTORY)/src/mesa/x86/*.S \
+ $(DIRECTORY)/src/mesa/x86/rtasm/*.[ch] \
+ $(DIRECTORY)/src/mesa/x86-64/*.[chS] \
+ $(DIRECTORY)/src/mesa/x86-64/Makefile \
+ $(DIRECTORY)/progs/Makefile \
+ $(DIRECTORY)/progs/util/README \
+ $(DIRECTORY)/progs/util/*.[ch] \
+ $(DIRECTORY)/progs/util/sampleMakefile \
+ $(DIRECTORY)/vms/analyze_map.com \
+ $(DIRECTORY)/vms/xlib.opt \
+ $(DIRECTORY)/vms/xlib_share.opt \
+ $(DIRECTORY)/windows/VC6/mesa/gdi/gdi.dsp \
+ $(DIRECTORY)/windows/VC6/mesa/glu/*.txt \
+ $(DIRECTORY)/windows/VC6/mesa/glu/glu.dsp \
+ $(DIRECTORY)/windows/VC6/mesa/mesa.dsw \
+ $(DIRECTORY)/windows/VC6/mesa/mesa/mesa.dsp \
+ $(DIRECTORY)/windows/VC6/mesa/osmesa/osmesa.dsp \
+ $(DIRECTORY)/windows/VC7/mesa/gdi/gdi.vcproj \
+ $(DIRECTORY)/windows/VC7/mesa/glu/glu.vcproj \
+ $(DIRECTORY)/windows/VC7/mesa/mesa.sln \
+ $(DIRECTORY)/windows/VC7/mesa/mesa/mesa.vcproj \
+ $(DIRECTORY)/windows/VC7/mesa/osmesa/osmesa.vcproj
+
+DRI_FILES = \
+ $(DIRECTORY)/include/GL/internal/dri_interface.h \
+ $(DIRECTORY)/include/GL/internal/sarea.h \
+ $(DIRECTORY)/src/glx/Makefile \
+ $(DIRECTORY)/src/glx/x11/Makefile \
+ $(DIRECTORY)/src/glx/x11/*.[ch] \
+ $(DIRECTORY)/src/mesa/drivers/dri/Makefile \
+ $(DIRECTORY)/src/mesa/drivers/dri/Makefile.template \
+ $(DIRECTORY)/src/mesa/drivers/dri/common/xmlpool/*.[ch] \
+ $(DIRECTORY)/src/mesa/drivers/dri/common/xmlpool/*.po \
+ $(DIRECTORY)/src/mesa/drivers/dri/*/*.[chS] \
+ $(DIRECTORY)/src/mesa/drivers/dri/*/Makefile \
+ $(DIRECTORY)/src/mesa/drivers/dri/*/Doxyfile \
+ $(DIRECTORY)/src/mesa/drivers/dri/*/server/*.[ch]
+
+SGI_GLU_FILES = \
+ $(DIRECTORY)/src/glu/Makefile \
+ $(DIRECTORY)/src/glu/descrip.mms \
+ $(DIRECTORY)/src/glu/sgi/Makefile \
+ $(DIRECTORY)/src/glu/sgi/Makefile.win \
+ $(DIRECTORY)/src/glu/sgi/Makefile.DJ \
+ $(DIRECTORY)/src/glu/sgi/glu.def \
+ $(DIRECTORY)/src/glu/sgi/dummy.cc \
+ $(DIRECTORY)/src/glu/sgi/descrip.mms \
+ $(DIRECTORY)/src/glu/sgi/mesaglu.opt \
+ $(DIRECTORY)/src/glu/sgi/include/gluos.h \
+ $(DIRECTORY)/src/glu/sgi/libnurbs/interface/*.h \
+ $(DIRECTORY)/src/glu/sgi/libnurbs/interface/*.cc \
+ $(DIRECTORY)/src/glu/sgi/libnurbs/internals/*.h \
+ $(DIRECTORY)/src/glu/sgi/libnurbs/internals/*.cc \
+ $(DIRECTORY)/src/glu/sgi/libnurbs/nurbtess/*.h \
+ $(DIRECTORY)/src/glu/sgi/libnurbs/nurbtess/*.cc \
+ $(DIRECTORY)/src/glu/sgi/libtess/README \
+ $(DIRECTORY)/src/glu/sgi/libtess/alg-outline \
+ $(DIRECTORY)/src/glu/sgi/libtess/*.[ch] \
+ $(DIRECTORY)/src/glu/sgi/libutil/*.[ch]
+
+MESA_GLU_FILES = \
+ $(DIRECTORY)/src/glu/mesa/README[12] \
+ $(DIRECTORY)/src/glu/mesa/Makefile* \
+ $(DIRECTORY)/src/glu/mesa/descrip.mms \
+ $(DIRECTORY)/src/glu/mesa/mms_depend \
+ $(DIRECTORY)/src/glu/mesa/*.def \
+ $(DIRECTORY)/src/glu/mesa/depend \
+ $(DIRECTORY)/src/glu/mesa/*.[ch]
+
+GLW_FILES = \
+ $(DIRECTORY)/src/glw/*.[ch] \
+ $(DIRECTORY)/src/glw/Makefile* \
+ $(DIRECTORY)/src/glw/README \
+ $(DIRECTORY)/src/glw/depend
+
+DEMO_FILES = \
+ $(DIRECTORY)/progs/beos/*.cpp \
+ $(DIRECTORY)/progs/beos/Makefile \
+ $(DIRECTORY)/progs/images/*.rgb \
+ $(DIRECTORY)/progs/images/*.rgba \
+ $(DIRECTORY)/progs/demos/Makefile* \
+ $(DIRECTORY)/progs/demos/descrip.mms \
+ $(DIRECTORY)/progs/demos/*.[ch] \
+ $(DIRECTORY)/progs/demos/*.cxx \
+ $(DIRECTORY)/progs/demos/*.dat \
+ $(DIRECTORY)/progs/demos/README \
+ $(DIRECTORY)/progs/osdemos/Makefile \
+ $(DIRECTORY)/progs/osdemos/*.c \
+ $(DIRECTORY)/progs/xdemos/Makefile* \
+ $(DIRECTORY)/progs/xdemos/descrip.mms \
+ $(DIRECTORY)/progs/xdemos/*.[chf] \
+ $(DIRECTORY)/progs/redbook/Makefile* \
+ $(DIRECTORY)/progs/redbook/README \
+ $(DIRECTORY)/progs/redbook/*.[ch] \
+ $(DIRECTORY)/progs/samples/Makefile* \
+ $(DIRECTORY)/progs/samples/README \
+ $(DIRECTORY)/progs/samples/*.c \
+ $(DIRECTORY)/progs/windml/Makefile.ugl \
+ $(DIRECTORY)/progs/windml/*.c \
+ $(DIRECTORY)/progs/windml/*.bmp \
+ $(DIRECTORY)/progs/ggi/*.c \
+ $(DIRECTORY)/windows/VC6/progs/demos/*.dsp \
+ $(DIRECTORY)/windows/VC6/progs/progs.dsw \
+ $(DIRECTORY)/windows/VC7/progs/demos/*.vcproj \
+ $(DIRECTORY)/windows/VC7/progs/progs.sln
+
+GLUT_FILES = \
+ $(DIRECTORY)/include/GL/glut.h \
+ $(DIRECTORY)/include/GL/glutf90.h \
+ $(DIRECTORY)/src/glut/glx/Makefile* \
+ $(DIRECTORY)/src/glut/glx/depend \
+ $(DIRECTORY)/src/glut/glx/*def \
+ $(DIRECTORY)/src/glut/glx/descrip.mms \
+ $(DIRECTORY)/src/glut/glx/mms_depend \
+ $(DIRECTORY)/src/glut/glx/*.[ch] \
+ $(DIRECTORY)/src/glut/beos/*.[ch] \
+ $(DIRECTORY)/src/glut/beos/*.cpp \
+ $(DIRECTORY)/src/glut/beos/Makefile \
+ $(DIRECTORY)/src/glut/dos/*.[ch] \
+ $(DIRECTORY)/src/glut/dos/Makefile.DJ \
+ $(DIRECTORY)/src/glut/dos/PC_HW/*.[chS] \
+ $(DIRECTORY)/src/glut/ggi/*.[ch] \
+ $(DIRECTORY)/src/glut/ggi/Makefile \
+ $(DIRECTORY)/windows/VC6/progs/glut/glut.dsp \
+ $(DIRECTORY)/windows/VC7/progs/glut/glut.vcproj
+
+DEPEND_FILES = \
+ $(TOP)/src/mesa/depend \
+ $(TOP)/src/glw/depend \
+ $(TOP)/src/glut/glx/depend \
+ $(TOP)/src/glu/sgi/depend
+
+
+LIB_FILES = $(MAIN_FILES) $(DRI_FILES) $(SGI_GLU_FILES) $(GLW_FILES)
+
+
+# Everything for new a Mesa release:
+tarballs: rm_depend lib_gz demo_gz glut_gz lib_bz2 demo_bz2 glut_bz2 lib_zip demo_zip glut_zip md5
+
+
+rm_depend:
+ @for dep in $(DEPEND_FILES) ; do \
+ rm -f $$dep ; \
+ touch $$dep ; \
+ done
+
+lib_gz:
+ rm -f configs/current ; \
+ cd .. ; \
+ tar -cf $(LIB_NAME).tar $(LIB_FILES) ; \
+ gzip $(LIB_NAME).tar ; \
+ mv $(LIB_NAME).tar.gz $(DIRECTORY)
+
+demo_gz:
+ cd .. ; \
+ tar -cf $(DEMO_NAME).tar $(DEMO_FILES) ; \
+ gzip $(DEMO_NAME).tar ; \
+ mv $(DEMO_NAME).tar.gz $(DIRECTORY)
+
+glut_gz:
+ cd .. ; \
+ tar -cf $(GLUT_NAME).tar $(GLUT_FILES) ; \
+ gzip $(GLUT_NAME).tar ; \
+ mv $(GLUT_NAME).tar.gz $(DIRECTORY)
+
+lib_bz2:
+ rm -f configs/current ; \
+ cd .. ; \
+ tar -cf $(LIB_NAME).tar $(LIB_FILES) ; \
+ bzip2 $(LIB_NAME).tar ; \
+ mv $(LIB_NAME).tar.bz2 $(DIRECTORY)
+
+demo_bz2:
+ cd .. ; \
+ tar -cf $(DEMO_NAME).tar $(DEMO_FILES) ; \
+ bzip2 $(DEMO_NAME).tar ; \
+ mv $(DEMO_NAME).tar.bz2 $(DIRECTORY)
+
+glut_bz2:
+ cd .. ; \
+ tar -cf $(GLUT_NAME).tar $(GLUT_FILES) ; \
+ bzip2 $(GLUT_NAME).tar ; \
+ mv $(GLUT_NAME).tar.bz2 $(DIRECTORY)
+
+lib_zip:
+ rm -f configs/current ; \
+ rm -f $(LIB_NAME).zip ; \
+ cd .. ; \
+ zip -qr $(LIB_NAME).zip $(LIB_FILES) ; \
+ mv $(LIB_NAME).zip $(DIRECTORY)
+
+demo_zip:
+ rm -f $(DEMO_NAME).zip ; \
+ cd .. ; \
+ zip -qr $(DEMO_NAME).zip $(DEMO_FILES) ; \
+ mv $(DEMO_NAME).zip $(DIRECTORY)
+
+glut_zip:
+ rm -f $(GLUT_NAME).zip ; \
+ cd .. ; \
+ zip -qr $(GLUT_NAME).zip $(GLUT_FILES) ; \
+ mv $(GLUT_NAME).zip $(DIRECTORY)
+
+md5:
+ @-md5sum $(LIB_NAME).tar.gz
+ @-md5sum $(LIB_NAME).tar.bz2
+ @-md5sum $(LIB_NAME).zip
+ @-md5sum $(DEMO_NAME).tar.gz
+ @-md5sum $(DEMO_NAME).tar.bz2
+ @-md5sum $(DEMO_NAME).zip
+ @-md5sum $(GLUT_NAME).tar.gz
+ @-md5sum $(GLUT_NAME).tar.bz2
+ @-md5sum $(GLUT_NAME).zip
diff --git a/nx-X11/extras/Mesa/Makefile.DJ b/nx-X11/extras/Mesa/Makefile.DJ
new file mode 100644
index 000000000..78ebf43ef
--- /dev/null
+++ b/nx-X11/extras/Mesa/Makefile.DJ
@@ -0,0 +1,93 @@
+# Mesa 3-D graphics library
+# Version: 4.0
+#
+# Copyright (C) 1999 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.
+
+# DOS/DJGPP makefile v1.6 for Mesa
+#
+# Copyright (C) 2002 - Daniel Borca
+# Email : dborca@users.sourceforge.net
+# Web : http://www.geocities.com/dborca
+
+
+#
+# Available options:
+#
+# Environment variables:
+# GLU=[mesa|sgi] specify GLU directory; can be `sgi' (requires GNU/C++)
+# or `mesa'.
+# default = mesa
+# GLIDE path to Glide3 SDK; used with FX.
+# default = $(TOP)/glide3
+# FX=1 build for 3dfx Glide3. Note that this disables
+# compilation of most DMesa code and requires fxMesa.
+# As a consequence, you'll need the DJGPP Glide3
+# library to build any application.
+# default = no
+# X86=1 optimize for x86 (if possible, use MMX, SSE, 3DNow).
+# default = no
+#
+# Targets:
+# all: build everything
+# libgl: build GL
+# libglu: build GLU
+# libglut: build GLUT
+# clean: remove object files
+# realclean: remove all generated files
+#
+
+
+
+.PHONY : all libgl libglu libglut clean realclean
+
+GLU ?= mesa
+
+CFLAGS = -Wall -W -pedantic
+CFLAGS += -O2 -ffast-math
+
+export CFLAGS
+
+ifeq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
+UNLINK = del $(subst /,\,$(1))
+else
+UNLINK = $(RM) $(1)
+endif
+
+all: libgl libglu libglut
+
+libgl: lib
+ $(MAKE) -f Makefile.DJ -C src/mesa
+libglu: lib
+ $(MAKE) -f Makefile.DJ -C src/glu/$(GLU)
+libglut: lib
+ $(MAKE) -f Makefile.DJ -C src/glut/dos
+
+lib:
+ mkdir lib
+
+clean:
+ $(MAKE) -f Makefile.DJ clean -C src/mesa
+ $(MAKE) -f Makefile.DJ clean -C src/glu/mesa
+ $(MAKE) -f Makefile.DJ clean -C src/glu/sgi
+ $(MAKE) -f Makefile.DJ clean -C src/glut/dos
+
+realclean: clean
+ -$(call UNLINK,lib/*.a)
+ -$(call UNLINK,lib/*.dxe)
diff --git a/nx-X11/extras/Mesa/Makefile.mgw b/nx-X11/extras/Mesa/Makefile.mgw
new file mode 100644
index 000000000..70c264a8d
--- /dev/null
+++ b/nx-X11/extras/Mesa/Makefile.mgw
@@ -0,0 +1,88 @@
+# Mesa 3-D graphics library
+# Version: 4.0
+#
+# Copyright (C) 1999 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.
+
+# MinGW makefile v1.2 for Mesa
+#
+# Copyright (C) 2002 - Daniel Borca
+# Email : dborca@users.sourceforge.net
+# Web : http://www.geocities.com/dborca
+
+
+#
+# Available options:
+#
+# Environment variables:
+# GLIDE path to Glide3 SDK; used with FX.
+# default = $(TOP)/glide3
+# FX=1 build for 3dfx Glide3. Note that this disables
+# compilation of most WMesa code and requires fxMesa.
+# As a consequence, you'll need the Win32 Glide3
+# library to build any application.
+# default = no
+# ICD=1 build the installable client driver interface
+# (windows opengl driver interface)
+# default = no
+# X86=1 optimize for x86 (if possible, use MMX, SSE, 3DNow).
+# default = no
+#
+# Targets:
+# all: build everything
+# libgl: build GL
+# clean: remove object files
+# realclean: remove all generated files
+#
+
+
+
+.PHONY : all libgl clean realclean
+
+ifeq ($(ICD),1)
+ # when -std=c99 mingw will not define WIN32
+ CFLAGS = -Wall -W -Werror
+else
+ # I love c89
+ CFLAGS = -Wall -W -pedantic
+endif
+CFLAGS += -O2 -ffast-math
+
+export CFLAGS
+
+ifeq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
+UNLINK = del $(subst /,\,$(1))
+else
+UNLINK = $(RM) $(1)
+endif
+
+all: libgl
+
+libgl: lib
+ $(MAKE) -f Makefile.mgw -C src/mesa
+
+lib:
+ mkdir lib
+
+clean:
+ $(MAKE) -f Makefile.mgw clean -C src/mesa
+
+realclean: clean
+ -$(call UNLINK,lib/*.a)
+ -$(call UNLINK,lib/*.dll)
diff --git a/nx-X11/extras/Mesa/README.XF86 b/nx-X11/extras/Mesa/README.XF86
new file mode 100644
index 000000000..7d2c1af31
--- /dev/null
+++ b/nx-X11/extras/Mesa/README.XF86
@@ -0,0 +1,47 @@
+Importing Mesa.
+
+Mesa should be imported from a tree checked out from the Mesa CVS
+repository (:pserver:anonymous@cvs.mesa3d.sourceforge.net:/cvsroot/mesa3d).
+
+Instructions for importing a tagged Mesa release X.Y.
+
+1. Check out the release version from the Mesa CVS repository:
+
+ % cvs -d :pserver:anonymous@cvs.freedesktop.org:/cvsroot/mesa \
+ co -r mesa_X_Y Mesa
+
+2. Remove the CVSROOT directory:
+
+ % cd Mesa
+ % rm -fr CVSROOT
+
+3. Remove the CVS admin directories:
+
+ % find . -name CVS -print | xargs rm -fr
+
+4. Import:
+
+ % cvs import -m "Mesa version X.Y" xc/extras/Mesa MESA MESA-X_Y
+
+5. Merge:
+
+ % cvs co -j MESA_PREV -j MESA-X_Y xc/extras/Mesa
+
+ resolve conflicts, and commit.
+
+6. Check for new files that are GPL'd or which were in directories
+ previously removed. Remove them from the main branch.
+
+
+
+
+When importing a snapshot of a Mesa (stable) branch, do everything as above,
+except check out the branch with:
+
+ % cvs -d :pserver:anonymous@cvs.freedesktop.org:/cvsroot/mesa \
+ co -r mesa_X_Y_branch Mesa
+
+and import with the tag MESA-X_Y-yyyymmdd indicating the date of the snapshot.
+
+
+$XFree86: xc/extras/Mesa/README.XF86,v 1.1 2000/11/30 15:46:25 dawes Exp $
diff --git a/nx-X11/extras/Mesa/XOrg-Xlist b/nx-X11/extras/Mesa/XOrg-Xlist
new file mode 100644
index 000000000..76661f525
--- /dev/null
+++ b/nx-X11/extras/Mesa/XOrg-Xlist
@@ -0,0 +1,15 @@
+include/GLView.h
+src/egl
+src/glu
+src/glut
+src/glw/boilerplate.c
+src/mesa/drivers/allegro
+src/mesa/drivers/beos
+src/mesa/drivers/d3d
+src/mesa/drivers/directfb
+src/mesa/drivers/dos
+src/mesa/drivers/ggi
+src/mesa/drivers/svga
+src/mesa/drivers/windows
+progs
+doxygen
diff --git a/nx-X11/extras/Mesa/bin/installmesa b/nx-X11/extras/Mesa/bin/installmesa
new file mode 100755
index 000000000..0bfce33c7
--- /dev/null
+++ b/nx-X11/extras/Mesa/bin/installmesa
@@ -0,0 +1,69 @@
+#!/bin/sh
+
+#
+# Simple shell script for installing Mesa's header and library files.
+# If the copy commands below don't work on a particular system (i.e. the
+# -f or -d flags), we may need to branch on `uname` to do the right thing.
+#
+
+
+TOP=.
+
+INCLUDE_DIR="/usr/local/include"
+LIB_DIR="/usr/local/lib"
+
+if [ "x$#" = "x0" ] ; then
+echo
+echo "***** Mesa installation - You may need root privileges to do this *****"
+echo
+echo "Default directory for header files is:" ${INCLUDE_DIR}
+echo "Enter new directory or press <Enter> to accept this default."
+
+read INPUT
+if [ "x${INPUT}" != "x" ] ; then
+ INCLUDE_DIR=${INPUT}
+fi
+
+echo
+echo "Default directory for library files is:" ${LIB_DIR}
+echo "Enter new directory or press <Enter> to accept this default."
+
+read INPUT
+if [ "x${INPUT}" != "x" ] ; then
+ LIB_DIR=${INPUT}
+fi
+
+echo
+echo "About to install Mesa header files (GL/*.h) in: " ${INCLUDE_DIR}/GL
+echo "and Mesa library files (libGL.*, etc) in: " ${LIB_DIR}
+echo "Press <Enter> to continue, or <ctrl>-C to abort."
+
+read INPUT
+
+else
+INCLUDE_DIR=$1/include
+LIB_DIR=$1/lib
+fi
+
+# flags:
+# -f = force
+# -d = preserve symlinks (does not work on BSD)
+
+if [ `uname` = "FreeBSD" ] ; then
+ CP_FLAGS="-f"
+else
+ CP_FLAGS="-fd"
+fi
+
+
+set -v
+
+mkdir ${INCLUDE_DIR}
+mkdir ${INCLUDE_DIR}/GL
+mkdir ${INCLUDE_DIR}/GLES
+mkdir ${LIB_DIR}
+cp -f ${TOP}/include/GL/*.h ${INCLUDE_DIR}/GL
+# NOT YET: cp -f ${TOP}/include/GLES/*.h ${INCLUDE_DIR}/GLES
+cp ${CP_FLAGS} ${TOP}/lib*/lib* ${LIB_DIR}
+
+echo "Done."
diff --git a/nx-X11/extras/Mesa/bin/mklib b/nx-X11/extras/Mesa/bin/mklib
new file mode 100755
index 000000000..58c4fa705
--- /dev/null
+++ b/nx-X11/extras/Mesa/bin/mklib
@@ -0,0 +1,698 @@
+#!/bin/sh
+
+# Make a shared library.
+# This script should be useful for projects other than Mesa.
+# Improvements/fixes are welcome.
+
+
+# Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+#
+# Option defaults
+#
+LIBNAME=""
+MAJOR=1
+MINOR=0
+PATCH=""
+DEPS=""
+LINK=""
+CPLUSPLUS=0
+STATIC=0
+INSTALLDIR="."
+ARCH="auto"
+ARCHOPT=""
+NOPREFIX=0
+EXPORTS=""
+
+
+#
+# Parse arguments
+#
+while true
+do
+ case $1 in
+ '-h' | '--help')
+ echo 'Usage: mklib [options] objects'
+ echo 'Create a shared library from object files.'
+ echo ' -o LIBRARY specifies the name of the resulting library, without'
+ echo ' the leading "lib" or any suffix.'
+ echo ' (eg: "-o GL" might result in "libGL.so" being made)'
+ echo ' -major N specifies major version number (default is 1)'
+ echo ' -minor N specifies minor version number (default is 0)'
+ echo ' -patch N specifies patch version number (default is 0)'
+ echo ' -lLIBRARY specifies a dependency on LIBRARY'
+ echo ' -LDIR search in DIR for library dependencies'
+ echo ' -linker L explicity specify the linker program to use (eg: gcc, g++)'
+ echo ' Not observed on all systems at this time.'
+ echo ' -cplusplus link with C++ runtime'
+ echo ' -static make a static library (default is dynamic/shared)'
+ echo ' -install DIR put resulting library file(s) in DIR'
+ echo ' -arch ARCH override using `uname` to determine host system'
+ echo ' -archopt OPT specify an extra achitecture-specific option OPT'
+ echo " -noprefix don't prefix library name with 'lib' nor add any suffix"
+ echo ' -exports FILE only export the symbols listed in FILE'
+ echo ' -h, --help display this information and exit'
+ exit 1
+ ;;
+ '-o')
+ shift 1;
+ LIBNAME=$1
+ ;;
+ '-major')
+ shift 1;
+ MAJOR=$1
+ ;;
+ '-minor')
+ shift 1;
+ MINOR=$1
+ ;;
+ '-patch')
+ shift 1;
+ PATCH=$1
+ ;;
+ '-linker')
+ shift 1;
+ LINK=$1
+ ;;
+ -l*)
+ DEPS="$DEPS $1"
+ ;;
+ -L*)
+ DEPS="$DEPS $1"
+ ;;
+ '-cplusplus')
+ CPLUSPLUS=1
+ ;;
+ '-static')
+ STATIC=1
+ ;;
+ '-install')
+ shift 1;
+ INSTALLDIR=$1
+ ;;
+ '-arch')
+ shift 1;
+ ARCH=$1
+ ;;
+ '-archopt')
+ shift 1;
+ ARCHOPT=$1
+ ;;
+ '-noprefix')
+ NOPREFIX=1
+ ;;
+ '-exports')
+ shift 1;
+ EXPORTS=$1
+ ;;
+ -*)
+ echo "mklib: Unknown option: " $1 ;
+ exit 1
+ ;;
+ *)
+ # This should be the first object file, stop parsing
+ break
+ esac
+ shift 1
+done
+OBJECTS=$@
+
+
+if [ ${ARCH} = "auto" ] ; then
+ ARCH=`uname`
+fi
+
+
+#
+# Error checking
+#
+if [ "x${LIBNAME}" = "x" ] ; then
+ echo "mklib: Error: no library name specified"
+ exit 1
+fi
+if [ "x${OBJECTS}" = "x" ] ; then
+ echo "mklib: Error: no object files specified"
+ exit 1
+fi
+
+
+#
+# Debugging info
+#
+if [ ] ; then
+ echo "-----------------"
+ echo ARCH is $ARCH
+ echo LIBNAME is $LIBNAME
+ echo MAJOR is $MAJOR
+ echo MINOR is $MINOR
+ echo PATCH is $PATCH
+ echo DEPS are $DEPS
+ echo "EXPORTS in" $EXPORTS
+ echo "-----------------"
+fi
+
+
+#
+# OK, make the library now
+#
+case $ARCH in
+
+ 'Linux' | 'OpenBSD')
+ # we assume gcc
+
+ if [ "x$LINK" = "x" ] ; then
+ # -linker was not specified so set default link command now
+ if [ $CPLUSPLUS = 1 ] ; then
+ LINK=g++
+ else
+ LINK=gcc
+ fi
+ fi
+
+ if [ $NOPREFIX = 1 ] ; then
+ # No "lib" or ".so" part
+ echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}
+ #OPTS="-shared -Wl,-soname,${LIBNAME}" # soname???
+ OPTS="-shared"
+
+ # Check if objects are 32-bit and we're running in 64-bit
+ # environment. If so, pass -m32 flag to linker.
+ set ${OBJECTS}
+ ABI32=`file $1 | grep 32-bit`
+ if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
+ OPTS="-m32 ${OPTS}"
+ fi
+
+ rm -f ${LIBNAME}
+ # make lib
+ ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+ # finish up
+ FINAL_LIBS="${LIBNAME}"
+ elif [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}" # prefix with "lib"
+ echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
+ LINK="ar"
+ OPTS="-ru"
+ # make lib
+ ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
+ ranlib ${LIBNAME}.a
+ # finish up
+ FINAL_LIBS=${LIBNAME}.a
+ else
+ LIBNAME="lib${LIBNAME}" # prefix with "lib"
+ if [ $ARCH = 'Linux' ] ; then
+ OPTS="-Xlinker -Bsymbolic -shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
+ else
+ OPTS="-shared -Wl,-soname,${LIBNAME}.so.${MAJOR}"
+ fi
+ if [ $EXPORTS ] ; then
+ #OPTS="${OPTS} -Xlinker --retain-symbols-file ${EXPORTS}"
+ # Make the 'exptmp' file for --version-script option
+ echo "VERSION_${MAJOR}.${MINOR} {" > exptmp
+ echo "global:" >> exptmp
+ sed 's/$/;/' ${EXPORTS} >> exptmp
+ echo "local:" >> exptmp
+ echo "*;" >> exptmp
+ echo "};" >> exptmp
+ OPTS="${OPTS} -Xlinker --version-script=exptmp"
+ # exptmp is removed below
+ fi
+
+ # Check if objects are 32-bit and we're running in 64-bit
+ # environment. If so, pass -m32 flag to linker.
+ set ${OBJECTS}
+ ABI32=`file $1 | grep 32-bit`
+ if [ "${ABI32}" -a `uname -m` = "x86_64" ] ; then
+ OPTS="-m32 ${OPTS}"
+ fi
+
+ if [ x${PATCH} = "x" ] ; then
+ VERSION="${MAJOR}.${MINOR}"
+ else
+ VERSION="${MAJOR}.${MINOR}.${PATCH}"
+ fi
+
+ echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}.so.${VERSION}
+
+ # rm any old libs
+ rm -f ${LIBNAME}.so.${VERSION}
+ rm -f ${LIBNAME}.so.${MAJOR}
+ rm -f ${LIBNAME}.so
+
+ # make lib
+ ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
+ # make usual symlinks
+ ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
+ ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
+ # finish up
+ FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
+# rm -f exptmp
+ fi
+ ;;
+
+ 'SunOS')
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making SunOS static library: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ar -ruv ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ else
+ LIBNAME="lib${LIBNAME}.so"
+ echo "mklib: Making SunOS shared library: " ${LIBNAME}
+ # XXX OPTS for gcc should be -shared, but that doesn't work.
+ # Using -G does work though.
+ OPTS="-G"
+ if [ "x$LINK" = "x" ] ; then
+ # -linker was not specified, choose default linker now
+ if [ $CPLUSPLUS = 1 ] ; then
+ # determine linker and options for C++ code
+ if [ `which c++` ] ; then
+ # use Sun c++
+ LINK="c++"
+ elif [ `type g++` ] ; then
+ # use g++
+ LINK="g++"
+ else
+ echo "mklib: warning: can't find C++ comiler, trying CC."
+ LINK="CC"
+ fi
+ else
+ # use native Sun linker for C code
+ LINK="ld"
+ fi
+ fi
+ echo "mklib: linker is" ${LINK} ${OPTS}
+ rm -f ${LIBNAME}.${MAJOR} ${LIBNAME}
+ ${LINK} ${OPTS} -o ${LIBNAME}.${MAJOR} ${OBJECTS} ${DEPS}
+ ln -s ${LIBNAME}.${MAJOR} ${LIBNAME}
+ FINAL_LIBS="${LIBNAME}.${MAJOR} ${LIBNAME}"
+ fi
+ ;;
+
+ 'FreeBSD')
+ # we assume gcc
+
+ if [ "x$LINK" = "x" ] ; then
+ # -linker was not specified so set default link command now
+ if [ $CPLUSPLUS = 1 ] ; then
+ LINK=g++
+ else
+ LINK=gcc
+ fi
+ fi
+
+ if [ $NOPREFIX = 1 ] ; then
+ # No "lib" or ".so" part
+ echo "mklib: Making FreeBSD shared library: " ${LIBNAME}
+ OPTS="-shared"
+ rm -f ${LIBNAME}
+ ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+ FINAL_LIBS=${LIBNAME}
+ elif [ $STATIC = 1 ] ; then
+ STLIB="lib${LIBNAME}.a"
+ echo "mklib: Making FreeBSD static library: " ${STLIB}
+ rm -f ${STLIB}
+ ar cq ${STLIB} ${OBJECTS}
+ ranlib ${STLIB}
+ FINAL_LIBS=${STLIB}
+ else
+ SHLIB="lib${LIBNAME}.so.${MAJOR}"
+ OPTS="-shared -Wl,-soname,${SHLIB}"
+ echo "mklib: Making FreeBSD shared library: " ${SHLIB}
+ rm -f ${SHLIB}
+ ${LINK} ${OPTS} -o ${SHLIB} ${OBJECTS} ${DEPS}
+ ln -sf ${SHLIB} "lib${LIBNAME}.so"
+ FINAL_LIBS="${SHLIB} lib${LIBNAME}.so"
+ fi
+ ;;
+
+ 'NetBSD')
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}_pic.a"
+ echo "mklib: Making NetBSD PIC static library: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ar cq ${LIBNAME} ${OBJECTS}
+ ranlib ${LIBNAME}
+ FINAL_LIBS=${LIBNAME}
+ else
+ LIBNAME="lib${LIBNAME}.so.${MAJOR}.${MINOR}"
+ echo "mklib: Making NetBSD PIC shared library: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ld -x -Bshareable -Bforcearchive -o ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ fi
+ ;;
+
+ 'IRIX' | 'IRIX64')
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ rm -f ${LIBNAME}
+ ar rc ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ else
+ LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
+ # XXX we should run 'file' on the first object file to determine
+ # if it's o32, n32 or 64 format, as we do for Linux above.
+ if [ $ARCHOPT = "64" ] ; then
+ # 64-bit ABI
+ OPTS="-64 -shared -all"
+ echo "mklib: Making IRIX 64-bit shared library: " ${LIBNAME}
+ elif [ $ARCHOPT = "o32" ] ; then
+ # old 32-bit ABI
+ OPTS="-32 -shared -all"
+ echo "mklib: Making IRIX o32-bit shared library: " ${LIBNAME}
+ else
+ # new 32-bit ABI
+ OPTS="-n32 -shared -all"
+ echo "mklib: Making IRIX n32-bit shared library: " ${LIBNAME}
+ fi
+ if [ $CPLUSPLUS = 1 ] ; then
+ LINK="CC"
+ else
+ LINK="ld"
+ fi
+ ${LINK} ${OPTS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+ FINAL_LIBS=${LIBNAME}
+ fi
+ ;;
+
+ 'linux-cygwin')
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making linux-cygwin library: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ gnuwin32ar ruv ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ ;;
+
+ 'HP-UX')
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making HP-UX static library: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ar -ruv ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ else
+ RUNLIB="lib${LIBNAME}.${MAJOR}"
+ DEVLIB="lib${LIBNAME}.sl"
+ echo "mklib: Making HP-UX shared library: " ${RUNLIB} ${DEVLIB}
+ ld -b -o ${RUNLIB} +b ${RUNLIB} ${OBJECTS} ${DEPS}
+ ln -s ${RUNLIB} ${DEVLIB}
+ FINAL_LIBS="${RUNLIB} ${DEVLIB}"
+ fi
+ ;;
+
+ 'AIX' | 'AIX64')
+ if [ $ARCH = "AIX64" ] ; then
+ X64="-X64"
+ fi
+
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making AIX static library: " ${LIBNAME}
+ ar -ruv ${X64} ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ else
+ EXPFILE="lib${LIBNAME}.exp"
+ OFILE=shr.o #Want to be consistent with the IBM libGL.a
+ LIBNAME="lib${LIBNAME}.a" # shared objects are still stored in the .a libraries
+ if [ $ARCH = "AIX64" ] ; then
+ OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry -q64"
+ else
+ OPTS="-bE:${EXPFILE} -bM:SRE -bnoentry"
+ fi
+ rm -f ${EXPFILE} ${OFILE}
+ NM="/bin/nm -eC ${X64}"
+ echo "#! /usr/lib/${LIBNAME}" > ${EXPFILE}
+ ${NM} ${OBJECTS} | awk '{
+ if ((($2 == "T") || ($2 == "D") || ($2 == "B")) \
+ && ( substr($1,1,1) != ".")) {
+ if (substr ($1, 1, 7) != "__sinit" &&
+ substr ($1, 1, 7) != "__sterm") {
+ if (substr ($1, 1, 5) == "__tf1")
+ print (substr ($1, 7))
+ else if (substr ($1, 1, 5) == "__tf9")
+ print (substr ($1, 15))
+ else
+ print $1
+ }
+ }
+ }' | sort -u >> ${EXPFILE}
+ cc ${OPTS} -o ${OFILE} ${OBJECTS} ${DEPS}
+ ar ${X64} -r ${LIBNAME} ${OFILE}
+ FINAL_LIBS="${LIBNAME}"
+ fi
+ ;;
+
+ 'OpenSTEP')
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making OpenSTEP static library: " ${LIBNAME}
+ libtool -static -o ${LIBNAME} - ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ ;;
+
+ 'OSF1')
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making OSF/1 static library: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ar -ruv ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ else
+ VERSION="${MAJOR}.${MINOR}"
+ LIBNAME="lib${LIBNAME}.so"
+ echo "mklib: Making OSF/1 shared library: " ${LIBNAME}
+ if [ "x$LINK" = "x" ] ; then
+ if [ $CPLUSPLUS = 1 ] ; then
+ LINK=cxx
+ else
+ LINK=cc
+ fi
+ fi
+ rm -f ${LIBNAME}.${VERSION}
+ ${LINK} -o ${LIBNAME}.${VERSION} -shared -set_version ${VERSION} -soname ${LIBNAME}.${VERSION} -expect_unresolved \* -all ${OBJECTS} ${DEPS}
+ ln -sf ${LIBNAME}.${VERSION} ${LIBNAME}
+ FINAL_LIBS="${LIBNAME} ${LIBNAME}.${VERSION}"
+ fi
+ ;;
+
+ 'Darwin')
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making Darwin static library: " ${LIBNAME}
+ LINK="ar"
+ OPTS="-ruv"
+ ${LINK} ${OPTS} ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ else
+ LIBNAME="lib${LIBNAME}.dylib"
+ echo "mklib: Making Darwin shared library: " ${LIBNAME}
+ FLAGS="-dynamiclib -multiply_defined suppress -current_version ${MAJOR}.${MINOR}.0 -compatibility_version ${MAJOR}.${MINOR}.0"
+ if [ $CPLUSPLUS = 1 ] ; then
+ LINK="g++"
+ else
+ LINK="cc"
+ fi
+ ${LINK} ${FLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS}
+ FINAL_LIBS=${LIBNAME}
+ fi
+ ;;
+
+ 'LynxOS')
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making LynxOS static library: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ar ru ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ ;;
+
+ 'BeOS')
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making BeOS static library: " ${LIBNAME}
+ ar -cru "${LIBNAME}" ${OBJECTS}
+ else
+ LIBNAME="lib${LIBNAME}.so"
+ echo "mklib: Making BeOS shared library: " ${LIBNAME}
+ gcc -nostart -Xlinker "-soname=${LIBNAME}" -L/Be/develop/lib/x86 -lbe ${DEPS} ${OBJECTS} -o "${LIBNAME}"
+ mimeset -f "${LIBNAME}"
+ # XXX remove the Mesa3D stuff here since mklib isn't mesa-specific.
+ setversion "${LIBNAME}" -app ${MAJOR} ${MINOR} ${PATCH} -short "Powered by Mesa3D!" -long "Powered by Mesa3D!"
+ fi
+ FINAL_LIBS=${LIBNAME}
+ ;;
+
+ 'QNX')
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making QNX library: " ${LIBNAME}
+ wlib ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ ;;
+
+ 'MorphOS')
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making MorphOS library: " ${LIBNAME}
+ ppc-morphos-ar rc ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS="${LIBNAME}"
+ ;;
+
+ 'icc')
+ # Intel C compiler
+ # This should get merged into the Linux code, above, since this isn't
+ # really a different architecture.
+ LIBNAME="lib${LIBNAME}" # prefix with "lib"
+
+ if [ $STATIC = 1 ] ; then
+ echo "mklib: Making Intel ICC static library: " ${LIBNAME}.a
+ LINK="ar"
+ OPTS="-ruv"
+ # make lib
+ ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
+ # finish up
+ FINAL_LIBS="${LIBNAME}.a"
+ else
+ OPTS="-shared"
+ VERSION="${MAJOR}.${MINOR}.${PATCH}"
+ echo "mklib: Making Intel ICC shared library: " ${LIBNAME}.so.${VERSION}
+
+ if [ $CPLUSPLUS = 1 ] ; then
+ LINK="icc"
+ else
+ LINK="icc"
+ fi
+ # rm any old libs
+ rm -f ${LIBNAME}.so.${VERSION}
+ rm -f ${LIBNAME}.so.${MAJOR}
+ rm -f ${LIBNAME}.so
+ # make lib
+ ${LINK} ${OPTS} -o ${LIBNAME}.so.${VERSION} ${OBJECTS} ${DEPS}
+ # make usual symlinks
+ ln -s ${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR}
+ ln -s ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so
+ # finish up
+ FINAL_LIBS="${LIBNAME}.so.${VERSION} ${LIBNAME}.so.${MAJOR} ${LIBNAME}.so"
+ fi
+ ;;
+
+ 'aix-gcc')
+ # AIX with gcc
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making AIX GCC static library: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ar ru ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS=${LIBNAME}
+ else
+ LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
+ echo "mklib: Making AIX GCC shared library: " ${LIBNAME}
+ # remove old lib
+ rm -f ${LIBNAME}
+ # make the lib
+ gcc -shared -Wl,-G ${OBJECTS} ${DEPS} -o ${LIBNAME}
+ # NOTE: the application linking with this library must specify
+ # the -Wl,-brtl flags to gcc
+ FINAL_LIBS=${LIBNAME}
+ fi
+ ;;
+
+ 'ultrix')
+ # XXX untested
+ if [ $STATIC = 0 ] ; then
+ echo "mklib: Warning shared libs not supported on Ultrix"
+ fi
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making static library for Ultrix: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ar ru ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS="${LIBNAME}"
+ ;;
+
+ CYGWIN*)
+ # GCC-based environment
+ CYGNAME="cyg${LIBNAME}" # prefix with "cyg"
+ LIBNAME="lib${LIBNAME}" # prefix with "lib"
+
+ if [ $STATIC = 1 ] ; then
+ echo "mklib: Making" $ARCH "static library: " ${LIBNAME}.a
+ LINK="ar"
+ OPTS="-ru"
+ # make lib
+ ${LINK} ${OPTS} ${LIBNAME}.a ${OBJECTS}
+ ranlib ${LIBNAME}.a
+ # finish up
+ FINAL_LIBS=${LIBNAME}.a
+ else
+ OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a"
+ echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll
+
+ if [ $CPLUSPLUS = 1 ] ; then
+ LINK="g++"
+ else
+ LINK="gcc"
+ fi
+
+ # rm any old libs
+ rm -f ${LIBNAME}-${MAJOR}.dll
+ rm -f ${LIBNAME}.dll.a
+ rm -f ${LIBNAME}.a
+
+ # make lib
+ ${LINK} ${OPTS} -o ${CYGNAME}-${MAJOR}.dll ${OBJECTS} ${DEPS}
+ # make usual symlinks
+ ln -s ${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a
+ # finish up
+ FINAL_LIBS="${LIBNAME}-${MAJOR}.dll.a ${LIBNAME}.dll.a"
+ # special case for installing in bin
+ FINAL_BINS="${CYGNAME}-${MAJOR}.dll"
+ fi
+ ;;
+
+ 'example')
+ # If you're adding support for a new architecture, you can
+ # start with this:
+ if [ $STATIC = 1 ] ; then
+ LIBNAME="lib${LIBNAME}.a"
+ echo "mklib: Making static library for example arch: " ${LIBNAME}
+ rm -f ${LIBNAME}
+ ar rv ${LIBNAME} ${OBJECTS}
+ FINAL_LIBS="${LIBNAME}"
+ else
+ LIBNAME="lib${LIBNAME}.so" # prefix with "lib", suffix with ".so"
+ echo "mklib: Making shared library for example arch: " ${LIBNAME}
+ ld -o ${LIBNAME} ${OBJECTS} ${DEPS}
+ FINAL_LIBS="${LIBNAME}"
+ fi
+ ;;
+
+ *)
+ echo "mklib: ERROR: Don't know how to make a static/shared library for" ${ARCH}
+ echo "mklib: Please add necessary commands to mklib script."
+ ;;
+esac
+
+
+#
+# Put library files into installation directory if specified.
+#
+if [ ${INSTALLDIR} != "." ] ; then
+ echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
+ mv ${FINAL_LIBS} ${INSTALLDIR}/
+fi
diff --git a/nx-X11/extras/Mesa/configs/aix b/nx-X11/extras/Mesa/configs/aix
new file mode 100644
index 000000000..fe8e48cd6
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/aix
@@ -0,0 +1,28 @@
+# Configuration for AIX, dynamic libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = aix
+
+# Compiler and flags
+CC = cc
+CXX = xlC
+
+CFLAGS = -O -DAIXV3
+CXXFLAGS = -O -DAIXV3
+MKLIB_OPTIONS =
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
+GL_LIB_DEPS = -lX11 -lXext -lm
+GLU_LIB_DEPS = -L$(TOP)/lib -l$(GL_LIB) -lm -lC
+GLUT_LIB_DEPS = -L$(TOP)/lib -l$(GLU_LIB) -l$(GL_LIB) -lXi -lXmu -lX11 -lm
+GLW_LIB_DEPS = -L$(TOP)/lib -l$(GL_LIB) -lXt -lX11
+OSMESA_LIB_DEPS = -L$(TOP)/lib -l$(GL_LIB)
+APP_LIB_DEPS = -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXext -lXmu -lXi -lm -lC
+
diff --git a/nx-X11/extras/Mesa/configs/aix-64 b/nx-X11/extras/Mesa/configs/aix-64
new file mode 100644
index 000000000..0d9847529
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/aix-64
@@ -0,0 +1,28 @@
+# Configuration for AIX 64-bit, dynamic libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = aix-64
+
+# Compiler and flags
+CC = xlc
+CXX = xlC
+
+CFLAGS = -q64 -qmaxmem=16384 -O -DAIXV3
+CXXFLAGS = -q64 -qmaxmem=16384 -O -DAIXV3
+MKLIB_OPTIONS = -arch AIX64
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
+GL_LIB_DEPS = -lX11 -lXext -lm
+GLU_LIB_DEPS = -L$(TOP)/lib -l$(GL_LIB) -lm -lC
+GLUT_LIB_DEPS = -L$(TOP)/lib -l$(GLU_LIB) -l$(GL_LIB) -lXi -lXmu -lX11 -lm
+GLW_LIB_DEPS = -L$(TOP)/lib -l$(GL_LIB) -lXt -lX11
+OSMESA_LIB_DEPS = -L$(TOP)/lib -l$(GL_LIB)
+APP_LIB_DEPS = -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXext -lXmu -lXi -lm -lC
+
diff --git a/nx-X11/extras/Mesa/configs/aix-gcc b/nx-X11/extras/Mesa/configs/aix-gcc
new file mode 100644
index 000000000..5f10bf25d
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/aix-gcc
@@ -0,0 +1,19 @@
+# Configuration for AIX with gcc
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = aix-gcc
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+
+CFLAGS = -O2 -DAIXV3
+CXXFLAGS = -O2 -DAIXV3
+
+MKLIB_OPTIONS = -arch aix-gcc
+GL_LIB_DEPS = -lX11 -lXext -lm
+GLU_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -lm
+GLUT_LIB_DEPS = -L$(LIB_DIR -l$(GLU_LIB) -l$(GL_LIB) -lXi -lXmu
+APP_LIB_DEPS = -L$(LIB_DIR) -Wl,-brtl -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm -lX11 -lXext -lXmu -lXi
+
diff --git a/nx-X11/extras/Mesa/configs/aix-static b/nx-X11/extras/Mesa/configs/aix-static
new file mode 100644
index 000000000..f6f086edb
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/aix-static
@@ -0,0 +1,23 @@
+# Configuration for AIX, static libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = aix-static
+
+# Compiler and flags
+CC = cc
+CXX = xlC
+
+CFLAGS = -O -DAIXV3
+CXXFLAGS = -O -DAIXV3
+MKLIB_OPTIONS = -static
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
+APP_LIB_DEPS = -L$(LIB_DIR) -lX11 -lXext -lXmu -lXi -lm
+
diff --git a/nx-X11/extras/Mesa/configs/beos b/nx-X11/extras/Mesa/configs/beos
new file mode 100644
index 000000000..1d2eaa959
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/beos
@@ -0,0 +1,99 @@
+# Configuration for BeOS
+# Written by Philippe Houdoin
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = beos
+
+
+DEFINES = \
+ -DBEOS_THREADS
+
+MACHINE=$(shell uname -m)
+ifeq ($(MACHINE), BePC)
+ CPU = x86
+else
+ CPU = ppc
+endif
+
+ifeq ($(CPU), x86)
+ # BeOS x86 settings
+
+ DEFINES += \
+ -DGNU_ASSEMBLER \
+ -DUSE_X86_ASM \
+ -DUSE_MMX_ASM \
+ -DUSE_3DNOW_ASM \
+ -DUSE_SSE_ASM
+
+ ASM_SOURCES = $(X86_SOURCES) $(X86_API)
+
+ CC = gcc
+ CXX = g++
+ LD = gcc
+
+ CFLAGS = \
+ -Wall -Wno-multichar -Wno-ctor-dtor-privacy \
+ $(DEFINES)
+
+ CXXFLAGS = $(CFLAGS)
+
+ LDFLAGS += -Xlinker
+
+ ifdef DEBUG
+ CFLAGS += -g -O0
+ LDFLAGS += -g
+ DEFINES += -DDEBUG
+ else
+ CFLAGS += -O3
+ endif
+
+ GLUT_CFLAGS = -fexceptions
+
+else
+ # BeOS PPC settings
+
+ CC = mwcc
+ CXX = $(CC)
+ LD = mwldppc
+
+ CFLAGS = \
+ -w on -requireprotos \
+ $(DEFINES)
+
+ CXXFLAGS = $(CFLAGS)
+
+ LDFLAGS += \
+ -export pragma \
+ -init _init_routine_ \
+ -term _term_routine_ \
+ -lroot \
+ /boot/develop/lib/ppc/glue-noinit.a \
+ /boot/develop/lib/ppc/init_term_dyn.o \
+ /boot/develop/lib/ppc/start_dyn.o
+
+ ifdef DEBUG
+ CFLAGS += -g -O0
+ CXXFLAGS += -g -O0
+ LDFLAGS += -g
+ else
+ CFLAGS += -O7
+ CXXFLAGS += -O7
+ endif
+
+ GLUT_CFLAGS = -fexceptions
+endif
+
+# Directories
+SRC_DIRS = mesa glu glut/beos
+GLU_DIRS = sgi
+DRIVER_DIRS = beos
+PROGRAM_DIRS = beos samples redbook demos tests
+
+# Library/program dependencies
+GL_LIB_DEPS =
+OSMESA_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB)
+GLU_LIB_DEPS =
+GLUT_LIB_DEPS = -lgame -L$(LIB_DIR) -l$(GL_LIB)
+APP_LIB_DEPS = -lbe -L$(LIB_DIR) -l$(GL_LIB) -l$(GLUT_LIB)
+
diff --git a/nx-X11/extras/Mesa/configs/darwin b/nx-X11/extras/Mesa/configs/darwin
new file mode 100644
index 000000000..0c8a6ec47
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/darwin
@@ -0,0 +1,29 @@
+# Configuration for Darwin / MacOS X, making dynamic libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = darwin
+
+# Compiler and flags
+CC = cc
+CXX = cc
+CFLAGS = -I/usr/X11R6/include -O3 -fPIC -fno-common -ffast-math -funroll-loops -fexpensive-optimizations -no-cpp-precomp -dynamic -Ddarwin
+CXXFLAGS = -I/usr/X11R6/include -O3 -fPIC -fno-common -ffast-math -funroll-loops -fexpensive-optimizations -no-cpp-precomp -dynamic -Ddarwin
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.dylib
+GLU_LIB_NAME = libGLU.dylib
+GLUT_LIB_NAME = libglut.dylib
+GLW_LIB_NAME = libGLw.dylib
+OSMESA_LIB_NAME = libOSMesa.dylib
+
+GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread
+OSMESA_LIB_DEPS = -L$(LIB_DIR) -lGL
+GLU_LIB_DEPS = -L$(LIB_DIR) -lGL
+GLUT_LIB_DEPS = -L$(LIB_DIR) -lGL -lGLU -L/usr/X11R6/lib -lX11 -lXmu -lXi -lXext
+GLW_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXt $(TOP)/lib/GL.dylib
+APP_LIB_DEPS = -L$(TOP)/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
+
+# omit glw lib for now:
+SRC_DIRS = mesa glu glut/glx
+
diff --git a/nx-X11/extras/Mesa/configs/darwin-static b/nx-X11/extras/Mesa/configs/darwin-static
new file mode 100644
index 000000000..c7f9c5f06
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/darwin-static
@@ -0,0 +1,24 @@
+# Configuration for Darwin / MacOS X, making static libs
+
+include $(TOP)/configs/darwin
+
+CONFIG_NAME = darwin-static
+
+# Compiler and flags
+CFLAGS = -I/usr/X11R6/include -O3 -fno-common -ffast-math -funroll-loops -fexpensive-optimizations -no-cpp-precomp -dynamic -Ddarwin
+CXXFLAGS = -I/usr/X11R6/include -O3 -fno-common -ffast-math -funroll-loops -fexpensive-optimizations -no-cpp-precomp -dynamic -Ddarwin
+MKLIB_OPTIONS = -static
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
+GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread
+OSMESA_LIB_DEPS =
+GLU_LIB_DEPS =
+GLUT_LIB_DEPS =
+GLW_LIB_DEPS =
+APP_LIB_DEPS = -L$(TOP)/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
diff --git a/nx-X11/extras/Mesa/configs/default b/nx-X11/extras/Mesa/configs/default
new file mode 100644
index 000000000..e3b1bc0ec
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/default
@@ -0,0 +1,74 @@
+# Default/template configuration
+
+# This is included by other config files which may override some
+# of these variables.
+
+CONFIG_NAME = default
+
+# Version info
+MESA_MAJOR=6
+MESA_MINOR=4
+MESA_TINY=1
+
+# external projects. This should be useless now that we use libdrm.
+DRM_SOURCE_PATH=$(TOP)/../drm
+
+# Compiler and flags
+CC = cc
+CXX = CC
+CFLAGS = -O
+CXXFLAGS = -O
+GLU_CFLAGS =
+
+# Misc tools and flags
+MKLIB_OPTIONS =
+MKDEP = makedepend
+MKDEP_OPTIONS = -fdepend
+MAKE = make
+
+# Python and flags (generally only needed by the developers)
+PYTHON2 = python
+PYTHON_FLAGS = -t -O -O
+
+# Library names (base name)
+GL_LIB = GL
+GLU_LIB = GLU
+GLUT_LIB = glut
+GLW_LIB = GLw
+OSMESA_LIB = OSMesa
+
+
+# Library names (actual file names)
+GL_LIB_NAME = lib$(GL_LIB).so
+GLU_LIB_NAME = lib$(GLU_LIB).so
+GLUT_LIB_NAME = lib$(GLUT_LIB).so
+GLW_LIB_NAME = lib$(GLW_LIB).so
+OSMESA_LIB_NAME = lib$(OSMESA_LIB).so
+
+
+# Optional assembly language optimization files for libGL
+ASM_SOURCES =
+
+# GLw widget sources (Append "GLwMDrawA.c" here and add -lXm to GLW_LIB_DEPS in
+# order to build the Motif widget too)
+GLW_SOURCES = GLwDrawA.c
+
+
+# Directories
+LIB_DIR = $(TOP)/lib
+INSTALL_PREFIX = /usr/local
+SRC_DIRS = mesa glu glut/glx glw
+GLU_DIRS = sgi
+DRIVER_DIRS = x11 osmesa
+# Which subdirs under $(TOP)/progs/ to enter:
+PROGRAM_DIRS = demos redbook samples xdemos
+
+
+# Library/program dependencies
+EXTRA_LIB_PATH ?=
+GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread
+OSMESA_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB)
+GLU_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -lm
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lm
+GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lXt -lX11
+APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
diff --git a/nx-X11/extras/Mesa/configs/freebsd b/nx-X11/extras/Mesa/configs/freebsd
new file mode 100644
index 000000000..910352abd
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/freebsd
@@ -0,0 +1,16 @@
+# Configuration for FreeBSD
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = FreeBSD
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+MAKE = gmake
+
+CFLAGS = -O2 -fPIC -pedantic -I/usr/X11R6/include -DUSE_XSHM -DHZ=100
+CXXFLAGS = -O2 -fPIC -pedantic
+GLUT_CFLAGS = -fexceptions
+
+APP_LIB_DEPS = -L$(LIB_DIR) -L/usr/X11R6/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lXext -lXmu -lXi -lX11 -lm
diff --git a/nx-X11/extras/Mesa/configs/freebsd-dri b/nx-X11/extras/Mesa/configs/freebsd-dri
new file mode 100644
index 000000000..fd07dbefe
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/freebsd-dri
@@ -0,0 +1,45 @@
+# -*-makefile-*-
+# Configuration for freebsd-dri: FreeBSD DRI hardware drivers
+
+include $(TOP)/configs/freebsd
+
+CONFIG_NAME = freebsd-dri
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+WARN_FLAGS = -Wall
+OPT_FLAGS = -O
+
+EXPAT_INCLUDES = -I/usr/local/include
+X11_INCLUDES = -I/usr/X11R6/include
+DEFINES = -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER \
+ -DGLX_DIRECT_RENDERING -DHAVE_ALIAS
+CFLAGS = $(DEFINES) -Wmissing-prototypes -g -std=c99 -Wundef -fPIC \
+ -ffast-math $(X11_INCLUDES)
+CXXFLAGS = $(DEFINES) -Wall -g -ansi -pedantic -fPIC
+
+ASM_SOURCES =
+
+# Library/program dependencies
+LIBDRM_LIB = `pkg-config --libs libdrm` -ldrm
+DRI_LIB_DEPS = -L/usr/local/lib -lm -lpthread -lexpat $(LIBDRM_LIB)
+GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread $(LIBDRM_LIB)
+
+GLUT_LIB_DEPS = -L$(LIB_DIR) -L/usr/X11R6/lib -lGLU -lGL -lX11 -lXmu -lXt -lXi -lm
+GLW_LIB_DEPS = -L$(LIB_DIR) -L/usr/X11R6/lib -lGL -lXt -lXm -lX11
+
+
+# Directories
+SRC_DIRS = glx/x11 mesa glu glut/glx glw
+DRIVER_DIRS = dri
+PROGRAM_DIRS =
+WINDOW_SYSTEM=dri
+
+DRM_SOURCE_PATH=$(TOP)/../drm
+
+# ffb and gamma are missing because they have not been converted to use the new
+# interface.
+DRI_DIRS = i810 i830 i915 mach64 mga r128 r200 r300 radeon tdfx \
+ unichrome savage sis
+
diff --git a/nx-X11/extras/Mesa/configs/freebsd-dri-amd64 b/nx-X11/extras/Mesa/configs/freebsd-dri-amd64
new file mode 100644
index 000000000..ffddfd835
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/freebsd-dri-amd64
@@ -0,0 +1,9 @@
+# -*-makefile-*-
+# Configuration for freebsd-dri-amd64: FreeBSD DRI hardware drivers
+
+include $(TOP)/configs/freebsd-dri
+
+CONFIG_NAME = freebsd-dri-x86-64
+
+ASM_FLAGS = -DUSE_X86_64_ASM
+ASM_SOURCES = $(X86-64_SOURCES) $(X86-64_API)
diff --git a/nx-X11/extras/Mesa/configs/freebsd-dri-x86 b/nx-X11/extras/Mesa/configs/freebsd-dri-x86
new file mode 100644
index 000000000..31316b1f7
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/freebsd-dri-x86
@@ -0,0 +1,12 @@
+# -*-makefile-*-
+# Configuration for freebsd-dri: FreeBSD DRI hardware drivers
+
+include $(TOP)/configs/freebsd-dri
+
+CONFIG_NAME = freebsd-dri-x86
+
+# Unnecessary on x86, generally.
+PIC_FLAGS =
+
+ASM_FLAGS = -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM
+ASM_SOURCES = $(X86_SOURCES)
diff --git a/nx-X11/extras/Mesa/configs/hpux10 b/nx-X11/extras/Mesa/configs/hpux10
new file mode 100644
index 000000000..e17c8b681
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/hpux10
@@ -0,0 +1,14 @@
+# Configuration for HPUX v10, shared libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = hpux10
+
+# Compiler and flags
+CC = cc
+CXX = aCC
+
+CFLAGS = +O3 +DAportable +z -Aa -D_HPUX_SOURCE -I/usr/include/X11R6 -I/usr/contrib/X11R6/include -DUSE_XSHM
+CXXFLAGS = +O3 +DAportable +Z -Aa -D_HPUX_SOURCE
+
+APP_LIB_DEPS = -$(LIB_DIR) -L/usr/lib/X11R6 -L/usr/contrib/X11R6/lib -lXext -lXmu -lXi -lX11 -lm
diff --git a/nx-X11/extras/Mesa/configs/hpux10-gcc b/nx-X11/extras/Mesa/configs/hpux10-gcc
new file mode 100644
index 000000000..107a99a85
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/hpux10-gcc
@@ -0,0 +1,16 @@
+# Configuration for HPUX v10, with gcc
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = hpux10-gcc
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+
+CFLAGS = -ansi -O3 -D_HPUX_SOURCE -I/usr/include/X11R6 -I/usr/contrib/X11R6/include -DUSE_XSHM
+CXXFLAGS = -ansi -O3 -D_HPUX_SOURCE
+GLUT_CFLAGS = -fexceptions
+
+APP_LIB_DEPS = -L$(LIB_DIR) -L/usr/lib/X11R6 -L/usr/contrib/X11R6/lib -lXext -lXmu -lXi -lX11 -lm
+
diff --git a/nx-X11/extras/Mesa/configs/hpux10-static b/nx-X11/extras/Mesa/configs/hpux10-static
new file mode 100644
index 000000000..38a1313e6
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/hpux10-static
@@ -0,0 +1,30 @@
+# Configuration for HPUX v10, static libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = hpux10-static
+
+# Compiler and flags
+CC = cc
+CXX = aCC
+
+CFLAGS = +O3 +DAportable +z -Aa -D_HPUX_SOURCE -I/usr/include/X11R6 -I/usr/contrib/X11R6/include -DUSE_XSHM
+CXXFLAGS = +O3 +DAportable +Z -Aa -D_HPUX_SOURCE
+
+MKLIB_OPTIONS = -static
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
+# Library/program dependencies (static libs don't have dependencies)
+GL_LIB_DEPS =
+OSMESA_LIB_DEPS =
+GLU_LIB_DEPS =
+GLUT_LIB_DEPS =
+GLW_LIB_DEPS =
+APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXext -lXmu -lXt -lXi -lpthread -lm -lstdc++
+APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/lib/X11R6 -L/usr/contrib/X11R6/lib -lXext -lXmu -lXi -lX11 -lm -lstdc++
diff --git a/nx-X11/extras/Mesa/configs/hpux11-32 b/nx-X11/extras/Mesa/configs/hpux11-32
new file mode 100644
index 000000000..9ff407bd5
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/hpux11-32
@@ -0,0 +1,26 @@
+# Configuration for HPUX v11
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = hpux11-32
+
+# Compiler and flags
+CC = cc
+CXX = aCC
+
+CFLAGS = +z -Ae +O2 +Onolimit +Oaggressive -D_HPUX_SOURCE -I/usr/include/X11R6 -I/usr/contrib/X11R6/include -DUSE_XSHM -DPTHREADS
+
+CXXFLAGS = +z -Aa +O2 +Onolimit +Oaggressive -D_HPUX_SOURCE -I/usr/include/X11R6 -I/usr/contrib/X11R6/include
+
+MKLIB_OPTIONS =
+
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
+# Library/program dependencies
+APP_LIB_DEPS = -L/usr/lib/X11R6 -L/usr/contrib/X11R6/lib -lXext -lXmu -lXi -lX11 -lm
diff --git a/nx-X11/extras/Mesa/configs/hpux11-32-static b/nx-X11/extras/Mesa/configs/hpux11-32-static
new file mode 100644
index 000000000..7507ab0b0
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/hpux11-32-static
@@ -0,0 +1,26 @@
+# Configuration for HPUX v11, static libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = hpux11-32-static
+
+# Compiler and flags
+CC = cc
+CXX = aCC
+
+CFLAGS = +O3 +DA2.0 -Aa -D_HPUX_SOURCE -I/usr/include/X11R6 -I/usr/contrib/X11R6/include -DUSE_XSHM -DPTHREADS
+
+CXXFLAGS = +O3 +DA2.0 -Aa -D_HPUX_SOURCE -I/usr/include/X11R6 -I/usr/contrib/X11R6/include
+
+MKLIB_OPTIONS = -static
+
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
+# Library/program dependencies
+APP_LIB_DEPS = -L/usr/lib/X11R6 -L/usr/contrib/X11R6/lib -lXext -lXmu -lXi -lX11 -lm
diff --git a/nx-X11/extras/Mesa/configs/hpux11-32-static-nothreads b/nx-X11/extras/Mesa/configs/hpux11-32-static-nothreads
new file mode 100644
index 000000000..91b365408
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/hpux11-32-static-nothreads
@@ -0,0 +1,26 @@
+# Configuration for HPUX v11, static libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = hpux11-32-static
+
+# Compiler and flags
+CC = cc
+CXX = aCC
+
+CFLAGS = +O3 +DA2.0 -Aa -D_HPUX_SOURCE -I/usr/include/X11R6 -I/usr/contrib/X11R6/include -DUSE_XSHM
+
+CXXFLAGS = +O3 +DA2.0 -Aa -D_HPUX_SOURCE -I/usr/include/X11R6 -I/usr/contrib/X11R6/include
+
+MKLIB_OPTIONS = -static
+
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
+# Library/program dependencies
+APP_LIB_DEPS = -L/usr/lib/X11R6 -L/usr/contrib/X11R6/lib -lXext -lXmu -lXi -lX11 -lm
diff --git a/nx-X11/extras/Mesa/configs/hpux11-64 b/nx-X11/extras/Mesa/configs/hpux11-64
new file mode 100644
index 000000000..b0869cf81
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/hpux11-64
@@ -0,0 +1,27 @@
+# Configuration for HPUX v11, 64-bit
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = hpux11-64
+
+# Compiler and flags
+CC = cc
+CXX = aCC
+
+CFLAGS = +z -Ae +DD64 +O2 +Onolimit +Oaggressive -D_HPUX_SOURCE -I/usr/include/X11R6 -I/usr/contrib/X11R6/include -DUSE_XSHM -DPTHREADS
+
+CXXFLAGS = +z -Aa +DD64 +O2 +Onolimit +Oaggressive -D_HPUX_SOURCE -I/usr/include/X11R6 -I/usr/contrib/X11R6/include
+
+MKLIB_OPTIONS =
+
+LIBDIR = $(TOP)/lib64
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
+# Library/program dependencies
+APP_LIB_DEPS = -L/usr/lib/X11R6 -L/usr/contrib/X11R6/lib -lXext -lXmu -lXi -lX11 -lm
diff --git a/nx-X11/extras/Mesa/configs/hpux11-64-static b/nx-X11/extras/Mesa/configs/hpux11-64-static
new file mode 100644
index 000000000..451dc4208
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/hpux11-64-static
@@ -0,0 +1,27 @@
+# Configuration for HPUX v11, 64-bit, static libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = hpux11-64-static
+
+# Compiler and flags
+CC = cc
+CXX = aCC
+
+CFLAGS = +O3 +DA2.0W -Aa -D_HPUX_SOURCE -I/usr/include/X11R6 -I/usr/contrib/X11R6/include -DUSE_XSHM -DPTHREADS
+
+CXXFLAGS = +O3 +DA2.0W -Aa -D_HPUX_SOURCE -I/usr/include/X11R6 -I/usr/contrib/X11R6/include
+
+MKLIB_OPTIONS = -static
+
+LIBDIR = $(TOP)/lib64
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
+# Library/program dependencies
+APP_LIB_DEPS = -L/usr/lib/X11R6 -L/usr/contrib/X11R6/lib -lXext -lXmu -lXi -lX11 -lm
diff --git a/nx-X11/extras/Mesa/configs/hpux9 b/nx-X11/extras/Mesa/configs/hpux9
new file mode 100644
index 000000000..037381757
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/hpux9
@@ -0,0 +1,16 @@
+# Configuration for HPUX v9, shared libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = hpux9
+
+# Compiler and flags
+CC = cc
+# XXX fix this
+CXX = c++
+
+CFLAGS = +z +O3 +Olibcalls +ESlit -Aa +Onolimit -D_HPUX_SOURCE -I/usr/include/X11R5 -DUSE_XSHM
+CXXFLAGS = +z +O3 +Olibcalls +ESlit -Aa +Onolimit -D_HPUX_SOURCE -I/usr/include/X11R5
+
+APP_LIB_DEPS = -L$(LIB_DIR) -L/usr/lib/X11R5 -s -Wl,+s,-B,nonfatal,-B,immediate -lXext -lXmu -lXi -lX11 -lm
+
diff --git a/nx-X11/extras/Mesa/configs/hpux9-gcc b/nx-X11/extras/Mesa/configs/hpux9-gcc
new file mode 100644
index 000000000..47d579ea5
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/hpux9-gcc
@@ -0,0 +1,14 @@
+# Configuration for HPUX v10, shared libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = hpux9-gcc
+
+# Compiler and flags
+CC = cc
+CXX = aCC
+
+CFLAGS = +O3 +DAportable +z -Aa -D_HPUX_SOURCE -I/usr/include/X11R6 -I/usr/contrib/X11R6/include -DUSE_XSHM
+CXXFLAGS = +O3 +DAportable +Z -Aa -D_HPUX_SOURCE
+
+APP_LIB_DEPS = -L$(LIB_DIR) -L/usr/lib/X11R6 -L/usr/contrib/X11R6/lib -lXext -lXmu -lXi -lX11 -lm
diff --git a/nx-X11/extras/Mesa/configs/irix6-64 b/nx-X11/extras/Mesa/configs/irix6-64
new file mode 100644
index 000000000..6c33d33ba
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/irix6-64
@@ -0,0 +1,18 @@
+# Configuration for IRIX 6.x, make n64 DSOs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = irix6-64
+
+# Compiler and flags
+CC = cc
+CXX = CC
+CFLAGS = -64 -O3 -ansi -woff 1068,1069,1174,1185,1209,1474,1552 -DUSE_XSHM
+CXXFLAGS = -64 -O3 -ansi -woff 1174
+MKLIB_OPTIONS = -archopt 64
+
+GLW_SOURCES = GLwDrawA.c GLwMDrawA.c
+
+LIB_DIR = $(TOP)/lib64
+
+APP_LIB_DEPS = -L$(LIB_DIR) -64 -rpath $(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXmu -lXi -lm
diff --git a/nx-X11/extras/Mesa/configs/irix6-64-static b/nx-X11/extras/Mesa/configs/irix6-64-static
new file mode 100644
index 000000000..d66af5be8
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/irix6-64-static
@@ -0,0 +1,25 @@
+# Configuration for IRIX 6.x, make n64 static libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = irix6-64-static
+
+# Compiler and flags
+CC = cc
+CXX = CC
+CFLAGS = -64 -O3 -ansi -woff 1068,1069,1174,1185,1209,1474,1552 -DUSE_XSHM
+CXXFLAGS = -64 -O3 -ansi -woff 1174
+MKLIB_OPTIONS = -archopt 64 -static
+
+GLW_SOURCES = GLwDrawA.c GLwMDrawA.c
+
+LIB_DIR = $(TOP)/lib64
+
+APP_LIB_DEPS = -L$(LIB_DIR) -64 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXext -lXmu -lXi -lm
+
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
diff --git a/nx-X11/extras/Mesa/configs/irix6-n32 b/nx-X11/extras/Mesa/configs/irix6-n32
new file mode 100644
index 000000000..4bf296401
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/irix6-n32
@@ -0,0 +1,18 @@
+# Configuration for IRIX 6.x, make n32 DSOs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = irix6-n32
+
+# Compiler and flags
+CC = cc
+CXX = CC
+CFLAGS = -n32 -mips3 -O3 -ansi -woff 1174,1521,1552 -DUSE_XSHM
+CXXFLAGS = -n32 -mips3 -O3 -ansi -woff 1174,1552
+MKLIB_OPTIONS = -archopt n32
+
+GLW_SOURCES = GLwDrawA.c GLwMDrawA.c
+
+LIB_DIR = $(TOP)/lib32
+
+APP_LIB_DEPS = -L$(LIB_DIR) -n32 -rpath $(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXmu -lXi -lfpe -lm
diff --git a/nx-X11/extras/Mesa/configs/irix6-n32-static b/nx-X11/extras/Mesa/configs/irix6-n32-static
new file mode 100644
index 000000000..b60de380c
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/irix6-n32-static
@@ -0,0 +1,25 @@
+# Configuration for IRIX 6.x, make n32 static libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = irix6-n32-static
+
+# Compiler and flags
+CC = cc
+CXX = CC
+CFLAGS = -n32 -mips2 -O2 -ansi -woff 1521,1552 -DUSE_XSHM
+CXXFLAGS = -n32 -mips2 -O2 -ansi -woff 3262,3666
+MKLIB_OPTIONS = -archopt n32 -static
+
+GLW_SOURCES = GLwDrawA.c GLwMDrawA.c
+
+LIB_DIR = $(TOP)/lib32
+
+APP_LIB_DEPS = -L$(LIB_DIR) -n32 -glut -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXext -lXmu -lXi -lm
+
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
diff --git a/nx-X11/extras/Mesa/configs/irix6-o32 b/nx-X11/extras/Mesa/configs/irix6-o32
new file mode 100644
index 000000000..56a197960
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/irix6-o32
@@ -0,0 +1,19 @@
+# Configuration for IRIX 6.x, make o32 DSOs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = irix6-o32
+
+# Compiler and flags
+CC = cc
+CXX = CC
+CFLAGS = -32 -mips2 -O2 -ansi -woff 1521,1552 -DUSE_XSHM
+CXXFLAGS = -32 -mips2 -O2 -ansi -woff 3262,3666
+MKLIB_OPTIONS = -archopt o32
+
+GLW_SOURCES = GLwDrawA.c GLwMDrawA.c
+
+LIB_DIR = $(TOP)/lib32
+
+APP_LIB_DEPS = -L$(LIB_DIR) -32 -rpath $(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXext -lXmu -lXi -lm
+
diff --git a/nx-X11/extras/Mesa/configs/irix6-o32-static b/nx-X11/extras/Mesa/configs/irix6-o32-static
new file mode 100644
index 000000000..ac3d6ee17
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/irix6-o32-static
@@ -0,0 +1,25 @@
+# Configuration for IRIX 6.x, make o32 static libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = irix6-o32-static
+
+# Compiler and flags
+CC = cc
+CXX = CC
+CFLAGS = -32 -mips2 -O2 -ansi -woff 1521,1552 -DUSE_XSHM
+CXXFLAGS = -32 -mips2 -O2 -ansi -woff 3262,3666
+MKLIB_OPTIONS = -archopt o32 -static
+
+GLW_SOURCES = GLwDrawA.c GLwMDrawA.c
+
+LIB_DIR = $(TOP)/lib32
+
+APP_LIB_DEPS = -L$(LIB_DIR) -32 -glut -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXext -lXmu -lXi -lm
+
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
diff --git a/nx-X11/extras/Mesa/configs/linux b/nx-X11/extras/Mesa/configs/linux
new file mode 100644
index 000000000..e3119ec5c
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux
@@ -0,0 +1,33 @@
+# Configuration for generic Linux
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+
+WARN_FLAGS = -Wall
+OPT_FLAGS = -O3 -g
+PIC_FLAGS = -fPIC
+
+# Add '-DGLX_USE_TLS' to ARCH_FLAGS to enable TLS support. Add -m32
+# to build properly on 64-bit platforms.
+
+ARCH_FLAGS ?=
+
+DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
+ -D_BSD_SOURCE -DPTHREADS -DUSE_XSHM
+
+X11_INCLUDES = -I/usr/X11R6/include
+
+CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
+ $(ASM_FLAGS) $(X11_INCLUDES) -std=c99 -ffast-math
+
+CXXFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
+ $(X11_INCLUDES)
+
+GLUT_CFLAGS = -fexceptions
+
+EXTRA_LIB_PATH = -L/usr/X11R6/lib
diff --git a/nx-X11/extras/Mesa/configs/linux-alpha b/nx-X11/extras/Mesa/configs/linux-alpha
new file mode 100644
index 000000000..507c80845
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-alpha
@@ -0,0 +1,18 @@
+# Configuration for Linux on Alpha
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-alpha
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+CFLAGS = -O3 -mcpu=ev5 -ansi -mieee -pedantic -fPIC -D_XOPEN_SOURCE -DUSE_XSHM
+CXXFLAGS = -O3 -mcpu=ev5 -ansi -mieee -pedantic -fPIC -D_XOPEN_SOURCE
+GLUT_CFLAGS = -fexceptions
+
+GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
+GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -L/usr/X11R6/lib -lXt -lX11
+APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
+
diff --git a/nx-X11/extras/Mesa/configs/linux-alpha-static b/nx-X11/extras/Mesa/configs/linux-alpha-static
new file mode 100644
index 000000000..7b7ee07eb
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-alpha-static
@@ -0,0 +1,27 @@
+# Configuration for Linux on Alpha, static libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-alpha-static
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+CFLAGS = -O3 -mcpu=ev5 -ansi -mieee -pedantic -D_XOPEN_SOURCE -DUSE_XSHM
+CXXFLAGS = -O3 -mcpu=ev5 -ansi -mieee -pedantic -D_XOPEN_SOURCE
+GLUT_CFLAGS = -fexceptions
+MKLIB_OPTIONS = -static
+
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
+
+GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
+GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -L/usr/X11R6/lib -lXt -lX11
+APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm -L/usr/X11R6/lib -lX11 -lm
diff --git a/nx-X11/extras/Mesa/configs/linux-debug b/nx-X11/extras/Mesa/configs/linux-debug
new file mode 100644
index 000000000..ff4d1c33b
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-debug
@@ -0,0 +1,8 @@
+# Configuration for debugging on Linux
+
+include $(TOP)/configs/linux
+
+CONFIG_NAME = linux-debug
+
+OPT_FLAGS = -g
+DEFINES += -DDEBUG -DMESA_DEBUG -DRUN_DEBUG_BENCHMARK
diff --git a/nx-X11/extras/Mesa/configs/linux-directfb b/nx-X11/extras/Mesa/configs/linux-directfb
new file mode 100644
index 000000000..f09c69dda
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-directfb
@@ -0,0 +1,29 @@
+# Configuration for DirectFB
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-directfb
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+
+CFLAGS = -Wall -O3 -ffast-math -fPIC -std=c99 -D_GNU_SOURCE -D_POSIX_SOURCE -D_SVID_SOURCE \
+ -D_POSIX_C_SOURCE=199309L -D_BSD_SOURCE -DPTHREADS
+
+CXXFLAGS = -Wall -O3 -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
+
+HAVE_X86 = $(shell uname -m | grep 'i[3-6]86' >/dev/null && echo yes)
+ifeq ($(HAVE_X86), yes)
+ CFLAGS += -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM
+ CXXFLAGS += -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM
+ ASM_SOURCES = $(X86_SOURCES) $(X86_API)
+endif
+
+# Directories
+SRC_DIRS = mesa glu
+DRIVER_DIRS = directfb
+PROGRAM_DIRS = # disabled
+
+# Library/program dependencies
+GL_LIB_DEPS = -lm -lpthread
diff --git a/nx-X11/extras/Mesa/configs/linux-dri b/nx-X11/extras/Mesa/configs/linux-dri
new file mode 100644
index 000000000..293f2e789
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-dri
@@ -0,0 +1,68 @@
+# -*-makefile-*-
+# Configuration for linux-dri: Linux DRI hardware drivers for XFree86 & others
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-dri
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+
+MKDEP = /usr/X11R6/bin/makedepend
+#MKDEP = gcc -M
+#MKDEP_OPTIONS = -MF depend
+
+WARN_FLAGS = -Wall
+OPT_FLAGS = -O -g
+PIC_FLAGS = -fPIC
+
+# Add '-DGLX_USE_TLS' to ARCH_FLAGS to enable TLS support.
+ARCH_FLAGS ?=
+
+DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
+ -D_BSD_SOURCE -D_GNU_SOURCE \
+ -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER \
+ -DGLX_DIRECT_RENDERING -DHAVE_ALIAS
+
+X11_INCLUDES = -I/usr/X11R6/include
+
+CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
+ $(ASM_FLAGS) -std=c99 -ffast-math
+
+CXXFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
+
+
+ASM_SOURCES =
+
+# Library/program dependencies
+EXTRA_LIB_PATH=-L/usr/X11R6/lib
+
+LIBDRM_LIB = `pkg-config --libs libdrm` -ldrm
+DRI_LIB_DEPS = $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl $(LIBDRM_LIB)
+GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lm -lpthread -ldl \
+ $(LIBDRM_LIB)
+
+
+# This is now 0 by default since it seems to confuse the hell out of people
+# and generate a lot of extra noise on bugzilla. If you need to build with
+# EGL, do 'make linux-dri USING_EGL=1'
+
+USING_EGL=0
+
+# Directories
+ifeq ($(USING_EGL), 1)
+SRC_DIRS = egl glx/x11 mesa glu glut/glx glw
+PROGRAM_DIRS = egl
+else
+SRC_DIRS = glx/x11 mesa glu glut/glx glw
+PROGRAM_DIRS =
+endif
+
+DRIVER_DIRS = dri
+WINDOW_SYSTEM=dri
+
+# gamma are missing because they have not been converted to use the new
+# interface.
+DRI_DIRS = i810 i830 i915 mach64 mga r128 r200 r300 radeon s3v \
+ savage sis tdfx trident unichrome ffb
diff --git a/nx-X11/extras/Mesa/configs/linux-dri-ppc b/nx-X11/extras/Mesa/configs/linux-dri-ppc
new file mode 100644
index 000000000..fb8768806
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-dri-ppc
@@ -0,0 +1,17 @@
+# -*-makefile-*-
+# Configuration for linux-dri: Linux DRI hardware drivers for XFree86 & others
+
+include $(TOP)/configs/linux-dri
+
+CONFIG_NAME = linux-dri-ppc
+
+OPT_FLAGS = -Os -mcpu=603
+PIC_FLAGS = -fPIC
+
+ASM_FLAGS = -DUSE_PPC_ASM -DUSE_VMX_ASM
+ASM_SOURCES = $(PPC_SOURCES)
+
+# Build only the drivers for cards that exist on PowerPC. At some point MGA
+# will be added, but not yet.
+DRI_DIRS = mach64 r128 r200 r300 radeon tdfx
+
diff --git a/nx-X11/extras/Mesa/configs/linux-dri-x86 b/nx-X11/extras/Mesa/configs/linux-dri-x86
new file mode 100644
index 000000000..bef24e059
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-dri-x86
@@ -0,0 +1,16 @@
+# -*-makefile-*-
+# Configuration for linux-dri: Linux DRI hardware drivers for XFree86 & others
+
+include $(TOP)/configs/linux-dri
+
+CONFIG_NAME = linux-dri-x86
+
+# Unnecessary on x86, generally.
+PIC_FLAGS =
+
+# Add -m32 to CFLAGS:
+ARCH_FLAGS = -m32
+
+ASM_FLAGS = -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM
+ASM_SOURCES = $(X86_SOURCES)
+
diff --git a/nx-X11/extras/Mesa/configs/linux-dri-x86-64 b/nx-X11/extras/Mesa/configs/linux-dri-x86-64
new file mode 100644
index 000000000..affbe2bc6
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-dri-x86-64
@@ -0,0 +1,23 @@
+# -*-makefile-*-
+# Configuration for linux-dri: Linux DRI hardware drivers for XFree86 & others
+
+include $(TOP)/configs/linux-dri
+
+CONFIG_NAME = linux-dri-x86-64
+
+ARCH_FLAGS = -m64
+
+ASM_FLAGS = -DUSE_X86_64_ASM
+ASM_SOURCES = $(X86-64_SOURCES) $(X86-64_API)
+
+LIB_DIR = $(TOP)/lib64
+
+# Library/program dependencies
+EXTRA_LIB_PATH=-L/usr/X11R6/lib64
+
+# ffb, gamma, and sis are missing because they have not be converted to use
+# the new interface. i810 and i830 are missing because there is no x86-64
+# system where they could *ever* be used.
+#
+DRI_DIRS = i915 mach64 mga r128 r200 radeon tdfx unichrome savage r300
+
diff --git a/nx-X11/extras/Mesa/configs/linux-fbdev b/nx-X11/extras/Mesa/configs/linux-fbdev
new file mode 100644
index 000000000..c357485ea
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-fbdev
@@ -0,0 +1,10 @@
+# Configuration for Linux fbdev interface
+
+include $(TOP)/configs/linux
+
+CONFIG_NAME = linux-fbdev
+DRIVER_DIRS = fbdev
+
+CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -DUSE_GLFBDEV_DRIVER
+
+PROGRAM_DIRS = fbdev
diff --git a/nx-X11/extras/Mesa/configs/linux-glide b/nx-X11/extras/Mesa/configs/linux-glide
new file mode 100644
index 000000000..d3e0dc32d
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-glide
@@ -0,0 +1,20 @@
+# Configuration for generic Linux with 3Dfx Glide driver
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-glide
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+
+CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include -DFX -I/usr/include/glide -I/usr/local/glide/include
+CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
+GLUT_CFLAGS = -fexceptions
+
+
+# Library/program dependencies
+GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -L/usr/local/glide/lib -lglide3x -lm -lpthread
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
+GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -L/usr/X11R6/lib -lXt -lX11
+APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/local/glide/lib -lglide3x -lm
diff --git a/nx-X11/extras/Mesa/configs/linux-icc b/nx-X11/extras/Mesa/configs/linux-icc
new file mode 100644
index 000000000..0da3b836a
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-icc
@@ -0,0 +1,21 @@
+# Configuration for Linux with Intel C compiler
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-icc
+
+# Compiler and flags
+CC = icc
+CXX = g++
+CFLAGS = -O3 -tpp6 -axK -KPIC -D_GCC_LIMITS_H_ -D__GNUC__ -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM -DPTHREADS -I/usr/X11R6/include
+CXXFLAGS = -O3
+GLUT_CFLAGS = -fexceptions
+MKLIB_OPTIONS = -arch icc
+
+GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
+APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
+
+ASM_SOURCES = $(X86_SOURCES) $(X86_API)
+
+
diff --git a/nx-X11/extras/Mesa/configs/linux-icc-static b/nx-X11/extras/Mesa/configs/linux-icc-static
new file mode 100644
index 000000000..5c65f0561
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-icc-static
@@ -0,0 +1,29 @@
+# Configuration for Linux with Intel C compiler, static libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-icc-static
+
+# Compiler and flags
+CC = icc
+CXX = g++
+CFLAGS = -O3 -tpp6 -axK -D_GCC_LIMITS_H_ -D__GNUC__ -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM -DPTHREADS -I/usr/X11R6/include
+CXXFLAGS = -O3
+GLUT_CFLAGS = -fexceptions
+MKLIB_OPTIONS = -static -arch icc
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
+GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
+APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
+MKLIB_OPTIONS = -arch icc
+
+ASM_SOURCES = $(X86_SOURCES) $(X86_API)
+
+
diff --git a/nx-X11/extras/Mesa/configs/linux-indirect b/nx-X11/extras/Mesa/configs/linux-indirect
new file mode 100644
index 000000000..93166e2e9
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-indirect
@@ -0,0 +1,49 @@
+# -*-makefile-*-
+# Configuration for linux-indirect: Builds a libGL capable of indirect
+# rendering, but *NOT* capable of direct rendering.
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-dri
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+
+MKDEP = /usr/X11R6/bin/makedepend
+#MKDEP = gcc -M
+#MKDEP_OPTIONS = -MF depend
+
+WARN_FLAGS = -Wall
+OPT_FLAGS = -O -g
+PIC_FLAGS = -fPIC
+
+# Add '-DGLX_USE_TLS' to ARCH_FLAGS to enable TLS support.
+ARCH_FLAGS ?=
+
+DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
+ -D_BSD_SOURCE -D_GNU_SOURCE \
+ -DPTHREADS -DHAVE_ALIAS
+
+X11_INCLUDES = -I/usr/X11R6/include
+
+CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
+ $(ASM_FLAGS) -std=c99 -ffast-math
+
+CXXFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
+
+
+ASM_SOURCES =
+
+# Library/program dependencies
+EXTRA_LIB_PATH=-L/usr/X11R6/lib
+
+DRI_LIB_DEPS = $(EXTRA_LIB_PATH) -lm -lpthread -lexpat -ldl
+GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXxf86vm -lm -lpthread -ldl
+
+
+# Directories
+SRC_DIRS = glx/x11 glu glut/glx glw
+DRIVER_DIRS =
+PROGRAM_DIRS =
+WINDOW_SYSTEM=dri
diff --git a/nx-X11/extras/Mesa/configs/linux-osmesa16 b/nx-X11/extras/Mesa/configs/linux-osmesa16
new file mode 100644
index 000000000..16a3b0bba
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-osmesa16
@@ -0,0 +1,27 @@
+# Configuration for 16 bits/channel OSMesa library on Linux
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-osmesa16
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include -DCHAN_BITS=16 -DDEFAULT_SOFTWARE_DEPTH_BITS=31
+CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
+
+
+# Library names
+OSMESA_LIB = OSMesa16
+OSMESA_LIB_NAME = libOSMesa16.so
+
+
+# Directories
+SRC_DIRS = mesa glu
+DRIVER_DIRS = osmesa
+PROGRAM_DIRS =
+
+
+# Dependencies
+OSMESA_LIB_DEPS = -lm -lpthread
+APP_LIB_DEPS = -lOSMesa16
diff --git a/nx-X11/extras/Mesa/configs/linux-osmesa16-static b/nx-X11/extras/Mesa/configs/linux-osmesa16-static
new file mode 100644
index 000000000..664550447
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-osmesa16-static
@@ -0,0 +1,28 @@
+# Configuration for 16 bits/channel OSMesa library on Linux
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-osmesa16-static
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+CFLAGS = -O3 -ansi -pedantic -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include -DCHAN_BITS=16 -DDEFAULT_SOFTWARE_DEPTH_BITS=31
+CXXFLAGS = -O3 -ansi -pedantic -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
+MKLIB_OPTIONS = -static
+
+
+# Library names
+OSMESA_LIB = OSMesa16
+OSMESA_LIB_NAME = libOSMesa16.a
+
+
+# Directories
+SRC_DIRS = mesa glu
+DRIVER_DIRS = osmesa
+PROGRAM_DIRS =
+
+
+# Dependencies
+OSMESA_LIB_DEPS = -lm -lpthread
+APP_LIB_DEPS = -lOSMesa16
diff --git a/nx-X11/extras/Mesa/configs/linux-osmesa32 b/nx-X11/extras/Mesa/configs/linux-osmesa32
new file mode 100644
index 000000000..0ff0a6db9
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-osmesa32
@@ -0,0 +1,27 @@
+# Configuration for 32 bits/channel OSMesa library on Linux
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-osmesa32
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include -DCHAN_BITS=32 -DDEFAULT_SOFTWARE_DEPTH_BITS=31
+CXXFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
+
+
+# Library names
+OSMESA_LIB = OSMesa32
+OSMESA_LIB_NAME = libOSMesa32.so
+
+
+# Directories
+SRC_DIRS = mesa glu
+DRIVER_DIRS = osmesa
+PROGRAM_DIRS =
+
+
+# Dependencies
+OSMESA_LIB_DEPS = -lm -lpthread
+APP_LIB_DEPS = -lOSMesa32
diff --git a/nx-X11/extras/Mesa/configs/linux-ppc b/nx-X11/extras/Mesa/configs/linux-ppc
new file mode 100644
index 000000000..13cfdeb42
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-ppc
@@ -0,0 +1,9 @@
+# Configuration for Linux on PPC
+
+include $(TOP)/configs/linux
+
+CONFIG_NAME = linux-ppc
+
+OPT_FLAGS = -O3 -mcpu=603 -fsigned-char -funroll-loops
+
+# FIXME: Use of PowerPC assembly should be enabled here. \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/configs/linux-ppc-static b/nx-X11/extras/Mesa/configs/linux-ppc-static
new file mode 100644
index 000000000..d0e168811
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-ppc-static
@@ -0,0 +1,14 @@
+# Configuration for Linux on PPC, static libs
+
+include $(TOP)/configs/linux-ppc
+
+CONFIG_NAME = linux-ppc-static
+
+MKLIB_OPTIONS = -static
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
diff --git a/nx-X11/extras/Mesa/configs/linux-profile b/nx-X11/extras/Mesa/configs/linux-profile
new file mode 100644
index 000000000..b2531f562
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-profile
@@ -0,0 +1,29 @@
+# Configuration for profiling on Linux with gprof
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-profile
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+
+CFLAGS = -pg -O -ansi -pedantic -Wall -Wmissing-prototypes -Wundef -fPIC -ffast-math -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE -I/usr/X11R6/include -DUSE_XSHM -DPTHREADS -DDEBUG -DMESA_DEBUG
+
+CXXFLAGS = -pg -O -ansi -pedantic -Wall -Wundef -fPIC -ffast-math -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE -DDEBUG -DMESA_DEBUG
+
+GLUT_CFLAGS = -fexceptions
+
+# Need to have -L/usr/X11R6/lib in these:
+GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
+GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -lXt -L/usr/X11R6/lib -lX11
+
+# Need to make static libs for profiling:
+MKLIB_OPTIONS = -static
+GL_LIB_NAME = lib$(GL_LIB).a
+GLU_LIB_NAME = lib$(GLU_LIB).a
+GLUT_LIB_NAME = lib$(GLUT_LIB).a
+GLW_LIB_NAME = lib$(GLW_LIB).a
+OSMESA_LIB_NAME = lib$(OSMesa).a
+APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm -lpthread
diff --git a/nx-X11/extras/Mesa/configs/linux-solo b/nx-X11/extras/Mesa/configs/linux-solo
new file mode 100644
index 000000000..a3deb7c20
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-solo
@@ -0,0 +1,43 @@
+# Configuration for linux-solo: Linux DRI hardware drivers for fbdev
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-solo
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+
+WARN_FLAGS = -Wall -Wundef
+OPT_FLAGS = -O3 -g
+PIC_FLAGS = -fPIC
+
+# Add '-DGLX_USE_TLS' to ARCH_FLAGS to enable TLS support.
+ARCH_FLAGS ?=
+
+DEFINES = -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE \
+ -D_BSD_SOURCE -D_GNU_SOURCE \
+ -DPTHREADS -DUSE_EXTERNAL_DXTN_LIB=1 -DDRM_USE_MALLOC -DIN_DRI_DRIVER
+
+CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
+ $(ASM_FLAGS) -std=c99 -ffast-math
+
+CXXFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
+
+
+ASM_SOURCES =
+
+# Library/program dependencies
+DRI_LIB_DEPS = -lm -lpthread -lexpat -ldl -L$(LIB_DIR)
+GL_LIB_DEPS = -lm -lpthread -ldl
+GLU_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -lm
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lm
+APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm -lpthread
+
+# Directories
+SRC_DIRS = glx/mini mesa glu glut/mini
+DRIVER_DIRS = dri
+PROGRAM_DIRS = miniglx
+
+#DRI_DIRS = ffb gamma sis savage
+DRI_DIRS = i810 i830 i915 mach64 mga r128 r200 radeon tdfx unichrome fb
diff --git a/nx-X11/extras/Mesa/configs/linux-solo-ia64 b/nx-X11/extras/Mesa/configs/linux-solo-ia64
new file mode 100644
index 000000000..b2051fac8
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-solo-ia64
@@ -0,0 +1,7 @@
+# Configuration for linux-solo-ia64: Linux DRI hardware drivers for fbdev
+
+include $(TOP)/configs/linux-solo
+
+CONFIG_NAME = linux-solo-ia64
+
+DRI_DIRS = fb mach64 mga r128 r200 radeon sis tdfx unichrome
diff --git a/nx-X11/extras/Mesa/configs/linux-solo-x86 b/nx-X11/extras/Mesa/configs/linux-solo-x86
new file mode 100644
index 000000000..b4e79ba2c
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-solo-x86
@@ -0,0 +1,12 @@
+# -*-makefile-*-
+# Configuration for linux-solo-x86: Linux hardware drivers for fbdev for x86
+
+include $(TOP)/configs/linux-solo
+
+CONFIG_NAME = linux-solo-x86
+
+# Unnecessary on x86, generally.
+PIC_FLAGS =
+
+ASM_FLAGS = -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM
+ASM_SOURCES = $(X86_SOURCES)
diff --git a/nx-X11/extras/Mesa/configs/linux-sparc b/nx-X11/extras/Mesa/configs/linux-sparc
new file mode 100644
index 000000000..15e0b6d4b
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-sparc
@@ -0,0 +1,30 @@
+# Configuration for Linux on Sparc
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-sparc
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+
+WARN_FLAGS = -Wall
+OPT_FLAGS = -O2
+PIC_FLAGS = -fPIC
+
+DEFINES = -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM
+
+X11_INCLUDES = -I/usr/X11R6/include
+
+CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
+ $(ASM_FLAGS) -std=c99 -ffast-math
+
+CXXFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES)
+
+GLUT_CFLAGS = -fexceptions
+
+EXTRA_LIB_PATH=-L/usr/X11R6/lib
+
+GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lm
+GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lXt -lX11
diff --git a/nx-X11/extras/Mesa/configs/linux-sparc5 b/nx-X11/extras/Mesa/configs/linux-sparc5
new file mode 100644
index 000000000..aa9461af7
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-sparc5
@@ -0,0 +1,17 @@
+# Configuration for Linux on Sparc5
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-sparc5
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+CFLAGS = -mcpu=ultrasparc -O2 -ffast-math -ansi -pedantic -fPIC -D_SVID_SOURCE -D_BSD_SOURCE -I/usr/X11R6/include -DUSE_XSHM
+CXXFLAGS = -mcpu=ultrasparc -O2 -ffast-math -ansi -pedantic -fPIC -D_SVID_SOURCE -D_BSD_SOURCE
+GLUT_CFLAGS = -fexceptions
+
+GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
+GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -L/usr/X11R6/lib -lXt -lX11
+
diff --git a/nx-X11/extras/Mesa/configs/linux-static b/nx-X11/extras/Mesa/configs/linux-static
new file mode 100644
index 000000000..0104d3402
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-static
@@ -0,0 +1,21 @@
+# Configuration for generic Linux, making static libs
+
+include $(TOP)/configs/linux
+
+CONFIG_NAME = linux-static
+
+MKLIB_OPTIONS = -static
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
+# Library/program dependencies (static libs don't have dependencies)
+GL_LIB_DEPS =
+OSMESA_LIB_DEPS =
+GLU_LIB_DEPS =
+GLUT_LIB_DEPS =
+GLW_LIB_DEPS =
diff --git a/nx-X11/extras/Mesa/configs/linux-tcc b/nx-X11/extras/Mesa/configs/linux-tcc
new file mode 100644
index 000000000..4371fe21f
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-tcc
@@ -0,0 +1,22 @@
+# Configuration for debugging on Linux
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-tcc
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+
+TCC_DIR=/home/progs/tcc-0.9.20
+
+CFLAGS = -g -ansi -pedantic -Wall -Wmissing-prototypes -Wundef -fPIC -ffast-math -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE -I/usr/X11R6/include -DUSE_XSHM -DPTHREADS -DDEBUG -DMESA_DEBUG -DUSE_TCC -I$(TCC_DIR)
+
+CXXFLAGS = -g -ansi -pedantic -Wall -Wundef -fPIC -ffast-math -D_POSIX_SOURCE -D_SVID_SOURCE -D_BSD_SOURCE -DDEBUG -DMESA_DEBUG
+
+GLUT_CFLAGS = -fexceptions
+
+GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread -L$(TCC_DIR) -ltcc -ldl
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
+GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -lXt -L/usr/X11R6/lib -lX11
+APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
diff --git a/nx-X11/extras/Mesa/configs/linux-ultrasparc b/nx-X11/extras/Mesa/configs/linux-ultrasparc
new file mode 100644
index 000000000..e235b56de
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-ultrasparc
@@ -0,0 +1,17 @@
+# Configuration for Linux on UltraSparc
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-ultrasparc
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+CFLAGS = -mv8 -O2 -mtune=ultrasparc -ansi -pedantic -fPIC -D_SVID_SOURCE -D_BSD_SOURCE -I/usr/X11R6/include -DUSE_XSHM
+CXXFLAGS = -mv8 -O2 -mtune=ultrasparc -ansi -pedantic -fPIC -D_SVID_SOURCE -D_BSD_SOURCE
+GLUT_CFLAGS = -fexceptions
+
+GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
+GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -L/usr/X11R6/lib -lXt -lX11
+APP_LIB_DEPS = -L$(LIB_DIR)-l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
diff --git a/nx-X11/extras/Mesa/configs/linux-x86 b/nx-X11/extras/Mesa/configs/linux-x86
new file mode 100644
index 000000000..b239653e6
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-x86
@@ -0,0 +1,8 @@
+# Configuration for Linux with x86 optimizations
+
+include $(TOP)/configs/linux
+
+CONFIG_NAME = linux-x86
+
+ASM_FLAGS = -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM
+ASM_SOURCES = $(X86_SOURCES) $(X86_API)
diff --git a/nx-X11/extras/Mesa/configs/linux-x86-32 b/nx-X11/extras/Mesa/configs/linux-x86-32
new file mode 100644
index 000000000..f18ce7a45
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-x86-32
@@ -0,0 +1,7 @@
+# To build Linux x86 32-bit in an x86-64 environment
+
+include $(TOP)/configs/linux-x86
+
+CONFIG_NAME = linux-x86-32
+
+ARCH_FLAGS += -m32
diff --git a/nx-X11/extras/Mesa/configs/linux-x86-64 b/nx-X11/extras/Mesa/configs/linux-x86-64
new file mode 100644
index 000000000..f8ff5489f
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-x86-64
@@ -0,0 +1,13 @@
+# Configuration for Linux for 64-bit X86 (Opteron)
+
+include $(TOP)/configs/linux
+
+CONFIG_NAME = linux-x86-64
+
+ARCH_FLAGS = -m64
+
+ASM_SOURCES = $(X86-64_SOURCES) $(X86-64_API)
+ASM_FLAGS = -DUSE_X86_64_ASM
+
+LIB_DIR = $(TOP)/lib64
+EXTRA_LIB_PATH = -L/usr/X11R6/lib64
diff --git a/nx-X11/extras/Mesa/configs/linux-x86-64-debug b/nx-X11/extras/Mesa/configs/linux-x86-64-debug
new file mode 100644
index 000000000..bbdaec801
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-x86-64-debug
@@ -0,0 +1,7 @@
+# Configuration for Linux for 64-bit X86 (Opteron)
+
+include $(TOP)/configs/linux-x86-64
+
+CONFIG_NAME = linux-x86-64-debug
+
+DEFINES += -DDEBUG -DMESA_DEBUG -DRUN_DEBUG_BENCHMARK
diff --git a/nx-X11/extras/Mesa/configs/linux-x86-64-static b/nx-X11/extras/Mesa/configs/linux-x86-64-static
new file mode 100644
index 000000000..05f21d87a
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-x86-64-static
@@ -0,0 +1,21 @@
+# Configuration for Linux for 64-bit X86 (Opteron), static libs
+
+include $(TOP)/configs/linux-x86-64
+
+CONFIG_NAME = linux-x86-64-static
+
+MKLIB_OPTIONS = -static
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
+# Library/program dependencies (static libs don't have dependencies)
+GL_LIB_DEPS =
+OSMESA_LIB_DEPS =
+GLU_LIB_DEPS =
+GLUT_LIB_DEPS =
+GLW_LIB_DEPS =
diff --git a/nx-X11/extras/Mesa/configs/linux-x86-debug b/nx-X11/extras/Mesa/configs/linux-x86-debug
new file mode 100644
index 000000000..dbb970300
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-x86-debug
@@ -0,0 +1,9 @@
+# Configuration for Linux with x86 code, but no gcc optimizations and
+# debugging enabled.
+
+include $(TOP)/configs/linux-x86
+
+CONFIG_NAME = linux-x86-debug
+
+OPT_FLAGS = -g
+DEFINES += -DDEBUG -DMESA_DEBUG -DRUN_DEBUG_BENCHMARK
diff --git a/nx-X11/extras/Mesa/configs/linux-x86-glide b/nx-X11/extras/Mesa/configs/linux-x86-glide
new file mode 100644
index 000000000..b874b923f
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-x86-glide
@@ -0,0 +1,24 @@
+# Configuration for Linux with 3Dfx Glide driver and x86 optimizations
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-x86-glide
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+
+CFLAGS = -Wall -O3 -ansi -pedantic -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM -DPTHREADS -I/usr/X11R6/include -DFX -I/usr/include/glide -I/usr/local/glide/include
+
+CXXFLAGS = -Wall -O3 -ansi -pedantic -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE
+
+GLUT_CFLAGS = -fexceptions
+
+
+ASM_SOURCES = $(X86_SOURCES) $(X86_API)
+
+# Library/program dependencies
+GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -L/usr/local/glide/lib -lglide3x -lm -lpthread
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
+GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -L/usr/X11R6/lib -lXt -lX11
+APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/local/glide/lib -lglide3x -lm
diff --git a/nx-X11/extras/Mesa/configs/linux-x86-static b/nx-X11/extras/Mesa/configs/linux-x86-static
new file mode 100644
index 000000000..d4ccfca80
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-x86-static
@@ -0,0 +1,21 @@
+# Configuration for Linux with x86 optimizations, static libs
+
+include $(TOP)/configs/linux-x86
+
+CONFIG_NAME = linux-x86-static
+
+MKLIB_OPTIONS = -static
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
+# Library/program dependencies (static libs don't have dependencies)
+GL_LIB_DEPS =
+OSMESA_LIB_DEPS =
+GLU_LIB_DEPS =
+GLUT_LIB_DEPS =
+GLW_LIB_DEPS =
diff --git a/nx-X11/extras/Mesa/configs/linux-x86-xcb b/nx-X11/extras/Mesa/configs/linux-x86-xcb
new file mode 100644
index 000000000..7c5074c30
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/linux-x86-xcb
@@ -0,0 +1,24 @@
+# Configuration for Linux with x86 optimizations
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = linux-x86-xcb
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+
+CFLAGS = -Wall -O3 -ansi -pedantic -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_SSE_ASM -DPTHREADS -DUSE_XCB -I/usr/X11R6/include
+
+CXXFLAGS = -Wall -O3 -ansi -pedantic -fPIC -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XCB
+
+GLUT_CFLAGS = -fexceptions
+
+
+ASM_SOURCES = $(X86_SOURCES) $(X86_API)
+
+# Library/program dependencies
+GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread -lXCB
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXmu -lXt -lXi -lm
+GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -L/usr/X11R6/lib -lXt -lX11
+APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
diff --git a/nx-X11/extras/Mesa/configs/netbsd b/nx-X11/extras/Mesa/configs/netbsd
new file mode 100644
index 000000000..104daae0d
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/netbsd
@@ -0,0 +1,14 @@
+# Configuration for NetBSD
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = netbsd
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+CFLAGS = -O2 -fPIC -DUSE_XSHM -I/usr/X11R6/include -DHZ=100
+CXXFLAGS = -O2 -fPIC
+GLUT_CFLAGS = -fexceptions
+APP_LIB_DEPS = -L$(LIB_DIR) -L/usr/X11R6/lib -lXext -lXmu -lXi -lX11 -lm
+
diff --git a/nx-X11/extras/Mesa/configs/openbsd b/nx-X11/extras/Mesa/configs/openbsd
new file mode 100644
index 000000000..f769259a3
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/openbsd
@@ -0,0 +1,18 @@
+# Configuration for OpenBSD
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = openbsd
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+CFLAGS = -O2 -fPIC -I/usr/X11R6/include -DUSE_XSHM -DHZ=100
+CXXFLAGS = -O2 -fPIC -I/usr/X11R6/include -DHZ=100
+
+GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm
+OSMESA_LIB_DEPS = -lm
+GLU_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB)
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXext -lXmu -lXt -lXi -lm
+APP_LIB_DEPS = -L$(LIB_DIR) -L/usr/X11R6/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
+
diff --git a/nx-X11/extras/Mesa/configs/osf1 b/nx-X11/extras/Mesa/configs/osf1
new file mode 100644
index 000000000..bc88c2042
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/osf1
@@ -0,0 +1,16 @@
+# Configuration for OSF/1
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = osf1
+
+# Compiler and flags
+CC = cc
+CXX = cxx
+CFLAGS = -O0 -std1 -ieee_with_no_inexact -DUSE_XSHM
+CXXFLAGS = -O2 -std ansi -ieee
+
+GL_LIB_DEPS = -lX11 -lXext -lm -lpthread
+GLU_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -lm
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXmu -lXt -lXi -lm
+APP_LIB_DEPS = -L$(LIB_DIR) -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lX11 -lXext -lXmu -lXi -lm
diff --git a/nx-X11/extras/Mesa/configs/solaris-x86 b/nx-X11/extras/Mesa/configs/solaris-x86
new file mode 100644
index 000000000..7a04417f0
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/solaris-x86
@@ -0,0 +1,18 @@
+# Configuration for Solaris on x86
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = solaris-x86
+
+# Compiler and flags
+CC = cc
+CFLAGS = -Xa -xO3 -xpentium -KPIC -I/usr/openwin/include -DUSE_XSHM
+MKLIB_OPTIONS = -static
+
+APP_LIB_DEPS = -L$(LIB_DIR) -L/usr/openwin/lib -R/usr/openwin/lib -lX11 -lXext -lXmu -lXi -lm -lglut -lGLU -lGL
+
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
diff --git a/nx-X11/extras/Mesa/configs/solaris-x86-gcc b/nx-X11/extras/Mesa/configs/solaris-x86-gcc
new file mode 100644
index 000000000..01f3d86d1
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/solaris-x86-gcc
@@ -0,0 +1,24 @@
+# Configuration for Solaris on x86 with gcc, static libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = solaris-x86-gcc
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+CFLAGS = -O3 -m486 -fPIC -I/usr/openwin/include -DUSE_XSHM
+CXXFLAGS = -O3 -m486 -fPIC
+GLUT_CFLAGS = -fexceptions
+MKLIB_OPTIONS = -static
+
+GL_LIB_DEPS = -L/usr/openwin/lib -lX11 -lXext -lm -lpthread
+GLU_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -lm
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/openwin/lib -lX11 -lXmu -lXt -lXi -lm
+APP_LIB_DEPS = -L$(LIB_DIR) -L/usr/openwin/lib -R/usr/openwin/lib -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
+
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
diff --git a/nx-X11/extras/Mesa/configs/sunos4 b/nx-X11/extras/Mesa/configs/sunos4
new file mode 100644
index 000000000..483b9aa73
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/sunos4
@@ -0,0 +1,12 @@
+# Configuration for SunOS 4, shared libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = sunos4
+
+# Compiler and flags
+CC = acc
+CFLAGS = -Kpic -O -I/usr/include/X11R5 -DUSE_XSHM -DSUNOS4
+APP_LIB_DEPS = -L$(LIB_DIR) -L/usr/lib/X11R5 -lX11 -lXext -lXmu -lXi -lm
+
+
diff --git a/nx-X11/extras/Mesa/configs/sunos4-gcc b/nx-X11/extras/Mesa/configs/sunos4-gcc
new file mode 100644
index 000000000..8fb1414fa
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/sunos4-gcc
@@ -0,0 +1,15 @@
+# Configuration for SunOS 4, with gcc, shared libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = sunos4-gcc
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+CFLAGS = -fPIC -O3 -I/usr/openwin/include -I/usr/include/X11R5 -I/usr/include/X11R5 -DUSE_XSHM -DSUNOS4
+CXXFLAGS = -fPIC -O3 -I/usr/openwin/include -DSUNOS4
+GLUT_CFLAGS = -fexceptions -DSOLARIS_2_4_BUG
+
+APP_LIB_DEPS = -L$(LIB_DIR) -L/usr/openwin/lib -lX11 -lXext -lXmu -lXi -lm
+
diff --git a/nx-X11/extras/Mesa/configs/sunos4-static b/nx-X11/extras/Mesa/configs/sunos4-static
new file mode 100644
index 000000000..3e510e751
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/sunos4-static
@@ -0,0 +1,25 @@
+# Configuration for SunOS 4, static libs
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = sunos4-static
+
+# Compiler and flags
+CC = acc
+CFLAGS = -O -DUSE_XSHM -DSUNOS4
+MKLIB_OPTIONS = -static
+
+# Library names (actual file names)
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
+# Library/program dependencies (static libs don't have dependencies)
+GL_LIB_DEPS =
+OSMESA_LIB_DEPS =
+GLU_LIB_DEPS =
+GLUT_LIB_DEPS =
+GLW_LIB_DEPS =
+APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -L/usr/X11R6/lib -lX11 -lXext -lXmu -lXt -lXi -lpthread -lm
diff --git a/nx-X11/extras/Mesa/configs/sunos5 b/nx-X11/extras/Mesa/configs/sunos5
new file mode 100644
index 000000000..9347fb842
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/sunos5
@@ -0,0 +1,18 @@
+# Configuration for SunOS 5
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = sunos5
+
+# Compiler and flags
+CC = cc
+CXX = c++
+CFLAGS = -KPIC -Xa -O -I/usr/openwin/include -I/usr/dt/include -DUSE_XSHM
+CXXFLAGS = -KPIC -Xa -O -I/usr/openwin/include -I/usr/dt/include
+GLUT_CFLAGS = -DSOLARIS_2_4_BUG
+
+GL_LIB_DEPS = -L/usr/openwin/lib -L/usr/dt/lib -lX11 -lXext -lXmu -lXi -lm
+GLU_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -lm
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lm
+GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -L/usr/openwin/lib -lXt -lX11
+APP_LIB_DEPS = -L$(LIB_DIR) -lCrun -lX11 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
diff --git a/nx-X11/extras/Mesa/configs/sunos5-gcc b/nx-X11/extras/Mesa/configs/sunos5-gcc
new file mode 100644
index 000000000..7917c9b00
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/sunos5-gcc
@@ -0,0 +1,35 @@
+# Configuration for SunOS 5, with gcc
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = sunos5-gcc
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+
+WARN_FLAGS = -Wall
+OPT_FLAGS = -O3 -g -fomit-frame-pointer -pipe
+PIC_FLAGS = -fPIC
+
+ARCH_FLAGS ?=
+
+DEFINES = -D_REENTRANT -DUSE_XSHM
+
+ASM_SOURCES = $(SPARC_SOURCES) $(SPARC_API)
+ASM_FLAGS = -DUSE_SPARC_ASM
+
+CFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
+ $(ASM_FLAGS) -std=c99 -ffast-math -I/usr/openwin/include
+
+CXXFLAGS = $(WARN_FLAGS) $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(DEFINES) \
+ -I/usr/openwin/include
+
+GLUT_CFLAGS = -fexceptions -DSOLARIS_2_4_BUG
+
+# Library/program dependencies
+EXTRA_LIB_PATH=-L/usr/openwin/lib
+
+GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lXmu -lXi -lm
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lm
+APP_LIB_DEPS = -L$(LIB_DIR) -lX11 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm
diff --git a/nx-X11/extras/Mesa/configs/sunos5-smp b/nx-X11/extras/Mesa/configs/sunos5-smp
new file mode 100644
index 000000000..633bced68
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/sunos5-smp
@@ -0,0 +1,19 @@
+# Configuration for SunOS 5, SMP systems
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = sunos5-smp
+
+# Compiler and flags
+CC = cc
+CXX = c++
+CFLAGS = -KPIC -Xa -native -fast -xO5 -xlibmil -xsafe=mem -xdepend -I/usr/openwin/include -I/usr/dt/include -DUSE_XSHM -DSOLARIS_2_4_BUG
+CXXFLAGS = -KPIC -Xa -native -fast -xO5 -xlibmil -xsafe=mem -xdepend -I/usr/openwin/include -I/usr/dt/include
+GLUT_CFLAGS = -DSOLARIS_2_4_BUG
+
+GL_LIB_DEPS = -L/usr/openwin/lib -lX11 -lXext -lXmu -lXi -lm
+GLU_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -lm
+GLUT_LIB_DEPS = -L$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -lm
+GLW_LIB_DEPS = -L$(LIB_DIR) -l$(GL_LIB) -L/usr/openwin/lib -lXt -lX11
+APP_LIB_DEPS = -L$(LIB_DIR) -lX11 -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lm -lCrun
+
diff --git a/nx-X11/extras/Mesa/configs/ultrix-gcc b/nx-X11/extras/Mesa/configs/ultrix-gcc
new file mode 100644
index 000000000..c65e27582
--- /dev/null
+++ b/nx-X11/extras/Mesa/configs/ultrix-gcc
@@ -0,0 +1,21 @@
+# Configuration for Ultrix, with gcc
+
+include $(TOP)/configs/default
+
+CONFIG_NAME = ultrix-gcc
+
+# Compiler and flags
+CC = gcc
+CXX = g++
+CFLAGS = -pedantic -O2
+CXXFLAGS = -pedantic -O2
+GLUT_CFLAGS = -fexceptions
+MKLIB_OPTIONS = -static
+
+GL_LIB_NAME = libGL.a
+GLU_LIB_NAME = libGLU.a
+GLUT_LIB_NAME = libglut.a
+GLW_LIB_NAME = libGLw.a
+OSMESA_LIB_NAME = libOSMesa.a
+
+APP_LIB_DEPS = -L$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) -lXmu -lX11 -lXi -lm
diff --git a/nx-X11/extras/Mesa/descrip.mms b/nx-X11/extras/Mesa/descrip.mms
new file mode 100644
index 000000000..11d949889
--- /dev/null
+++ b/nx-X11/extras/Mesa/descrip.mms
@@ -0,0 +1,22 @@
+# Makefile for Mesa for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+
+macro :
+ @ macro=""
+.ifdef NOSHARE
+.else
+ @ if f$getsyi("HW_MODEL") .ge. 1024 then macro= "/MACRO=(SHARE=1)"
+.endif
+ $(MMS)$(MMSQUALIFIERS)'macro' all
+
+all :
+ if f$search("lib.dir") .eqs. "" then create/directory [.lib]
+ set default [.src]
+ $(MMS)$(MMSQUALIFIERS)
+ set default [-.progs.util]
+ $(MMS)$(MMSQUALIFIERS)
+ set default [-.demos]
+ $(MMS)$(MMSQUALIFIERS)
+ set default [-.xdemos]
+ $(MMS)$(MMSQUALIFIERS)
+ if f$search("[-]test.DIR") .nes. "" then pipe set default [-.test] ; $(MMS)$(MMSQUALIFIERS)
diff --git a/nx-X11/extras/Mesa/docs/COPYING b/nx-X11/extras/Mesa/docs/COPYING
new file mode 100644
index 000000000..b88946cc6
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/COPYING
@@ -0,0 +1,490 @@
+
+Some parts of Mesa are copyrighted under the GNU LGPL. See the
+Mesa/docs/COPYRIGHT file for details.
+
+The following is the standard GNU copyright file.
+----------------------------------------------------------------------
+
+
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+ 675 Mass Ave, Cambridge, MA 02139, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL. It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it. You can use it for
+your libraries, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library. If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software. To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+ Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs. This
+license, the GNU Library General Public License, applies to certain
+designated libraries. This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+ The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it. Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program. However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+ Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries. We
+concluded that weaker conditions might promote sharing better.
+
+ However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves. This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them. (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.) The hope is that this
+will lead to faster development of free libraries.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+ Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+
+ GNU LIBRARY GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License"). Each licensee is
+addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ c) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ d) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ Appendix: How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
diff --git a/nx-X11/extras/Mesa/docs/MESA_agp_offset.spec b/nx-X11/extras/Mesa/docs/MESA_agp_offset.spec
new file mode 100644
index 000000000..8dcc72379
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/MESA_agp_offset.spec
@@ -0,0 +1,95 @@
+Name
+
+ MESA_agp_offset
+
+Name Strings
+
+ GLX_MESA_agp_offset
+
+Contact
+
+ Brian Paul, Tungsten Graphics, Inc. (brian.paul 'at' tungstengraphics.com)
+ Keith Whitwell, Tungsten Graphics, Inc. (keith 'at' tungstengraphics.com)
+
+Status
+
+ Shipping (Mesa 4.0.4 and later. Only implemented in particular
+ XFree86/DRI drivers.)
+
+Version
+
+ 1.0
+
+Number
+
+ TBD
+
+Dependencies
+
+ OpenGL 1.0 or later is required
+ GLX_NV_vertex_array_range is required.
+ This extensions is written against the OpenGL 1.4 Specification.
+
+Overview
+
+ This extensions provides a way to convert pointers in an AGP memory
+ region into byte offsets into the AGP aperture.
+ Note, this extension depends on GLX_NV_vertex_array_range, for which
+ no real specification exists. See GL_NV_vertex_array_range for more
+ information.
+
+IP Status
+
+ None
+
+Issues
+
+ None
+
+New Procedures and Functions
+
+ unsigned int glXGetAGPOffsetMESA( const void *pointer )
+
+New Tokens
+
+ None
+
+Additions to the OpenGL 1.4 Specification
+
+ None
+
+Additions to Chapter 3 the GLX 1.4 Specification (Functions and Errors)
+
+ Add a new section, 3.6 as follows:
+
+ 3.6 AGP Memory Access
+
+ On "PC" computers, AGP memory can be allocated with glXAllocateMemoryNV
+ and freed with glXFreeMemoryNV. Sometimes it's useful to know where a
+ block of AGP memory is located with respect to the start of the AGP
+ aperature. The function
+
+ GLuint glXGetAGPOffsetMESA( const GLvoid *pointer )
+
+ Returns the offset of the given memory block from the start of AGP
+ memory in basic machine units (i.e. bytes). If pointer is invalid
+ the value ~0 will be returned.
+
+GLX Protocol
+
+ None. This is a client side-only extension.
+
+Errors
+
+ glXGetAGPOffsetMESA will return ~0 if the pointer does not point to
+ an AGP memory region.
+
+New State
+
+ None
+
+Revision History
+
+ 20 September 2002 - Initial draft
+ 2 October 2002 - finished GLX chapter 3 additions
+ 27 July 2004 - use unsigned int instead of GLuint, void instead of GLvoid
diff --git a/nx-X11/extras/Mesa/docs/MESA_copy_sub_buffer.spec b/nx-X11/extras/Mesa/docs/MESA_copy_sub_buffer.spec
new file mode 100644
index 000000000..43424a5f4
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/MESA_copy_sub_buffer.spec
@@ -0,0 +1,88 @@
+Name
+
+ MESA_copy_sub_buffer
+
+Name Strings
+
+ GLX_MESA_copy_sub_buffer
+
+Contact
+
+ Brian Paul (brian.paul 'at' tungstengraphics.com)
+
+Status
+
+ Shipping since Mesa 2.6 in February, 1998.
+
+Version
+
+ Last Modified Date: 8 June 2000
+
+Number
+
+ 215
+
+Dependencies
+
+ OpenGL 1.0 or later is required.
+ GLX 1.0 or later is required.
+
+Overview
+
+ The glxCopySubBufferMESA() function copies a rectangular region
+ of the back color buffer to the front color buffer. This can be
+ used to quickly repaint 3D windows in response to expose events
+ when the back color buffer cannot be damaged by other windows.
+
+IP Status
+
+ Open-source; freely implementable.
+
+Issues
+
+ None.
+
+New Procedures and Functions
+
+ void glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
+ int x, int y, int width, int height );
+
+New Tokens
+
+ None.
+
+Additions to Chapter 3 of the GLX 1.3 Specification (Functions and Errors)
+
+ Add to section 3.3.10 Double Buffering:
+
+ The function
+
+ void glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
+ int x, int y, int width, int height );
+
+ may be used to copy a rectangular region of the back color buffer to
+ the front color buffer. This can be used to quickly repaint 3D windows
+ in response to expose events when the back color buffer cannot be
+ damaged by other windows.
+
+ <x> and <y> indicates the lower-left corner of the region to copy and
+ <width> and <height> indicate the size in pixels. Coordinate (0,0)
+ corresponds to the lower-left pixel of the window, like glReadPixels.
+
+GLX Protocol
+
+ None at this time. The extension is implemented in terms of ordinary
+ Xlib protocol inside of Mesa.
+
+Errors
+
+ None.
+
+New State
+
+ None.
+
+Revision History
+
+ 8 June 2000 - initial specification
+
diff --git a/nx-X11/extras/Mesa/docs/MESA_pack_invert.spec b/nx-X11/extras/Mesa/docs/MESA_pack_invert.spec
new file mode 100644
index 000000000..53d5fca71
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/MESA_pack_invert.spec
@@ -0,0 +1,138 @@
+Name
+
+ MESA_pack_invert
+
+Name Strings
+
+ GL_MESA_pack_invert
+
+Contact
+
+ Brian Paul, Tungsten Graphics, Inc. (brian.paul 'at' tungstengraphics.com)
+ Keith Whitwell, Tungsten Graphics, Inc. (keith 'at' tungstengraphics.com)
+
+Status
+
+ Shipping (Mesa 4.0.4 and later)
+
+Version
+
+ 1.0
+
+Number
+
+ TBD
+
+Dependencies
+
+ OpenGL 1.0 or later is required
+ This extensions is written against the OpenGL 1.4 Specification.
+
+Overview
+
+ This extension adds a new pixel storage parameter to indicate that
+ images are to be packed in top-to-bottom order instead of OpenGL's
+ conventional bottom-to-top order. Only pixel packing can be
+ inverted (i.e. for glReadPixels, glGetTexImage, glGetConvolutionFilter,
+ etc).
+
+ Almost all known image file formats store images in top-to-bottom
+ order. As it is, OpenGL reads images from the frame buffer in
+ bottom-to-top order. Thus, images usually have to be inverted before
+ writing them to a file with image I/O libraries. This extension
+ allows images to be read such that inverting isn't needed.
+
+IP Status
+
+ None
+
+Issues
+
+ 1. Should we also defined UNPACK_INVERT_MESA for glDrawPixels, etc?
+
+ Resolved: No, we're only concerned with pixel packing. There are other
+ solutions for inverting images when using glDrawPixels (negative Y pixel
+ zoom) or glTexImage (invert the vertex T coordinates). It would be easy
+ enough to define a complementary extension for pixel packing in the
+ future if needed.
+
+New Procedures and Functions
+
+ None
+
+New Tokens
+
+ Accepted by the <pname> parameter of PixelStorei and PixelStoref
+ and the <pname> parameter of GetIntegerv, GetFloatv, GetDoublev
+ and GetBooleanv:
+
+ PACK_INVERT_MESA 0x8758
+
+Additions to Chapter 2 of the OpenGL 1.4 Specification (OpenGL Operation)
+
+ None
+
+Additions to Chapter 3 of the OpenGL 1.4 Specification (Rasterization)
+
+ None
+
+Additions to Chapter 4 of the OpenGL 1.4 Specification (Per-Fragment
+Operations and the Frame Buffer)
+
+ Add the following entry to table 4.4 (PixelStore parameters) on page 182:
+
+ Parameter Name Type Initial Value Valid Range
+ ---------------------------------------------------------
+ PACK_INVERT_MESA boolean FALSE TRUE/FALSE
+
+ In the section labeled "Placement in Client Memory" on page 184
+ insert the following text into the paragraph before the sentence
+ that starts with "If the format is RED, GREEN, BLUE...":
+
+ "The parameter PACK_INVERT_MESA controls whether the image is packed
+ in bottom-to-top order (the default) or top-to-bottom order. Equation
+ 3.8 is modified as follows:
+
+ ... the first element of the Nth row is indicated by
+
+ p + Nk, if PACK_INVERT_MESA is false
+ p + k * (H - 1) - Nk, if PACK_INVERT_MESA is true, where H is the
+ image height
+ "
+
+Additions to Chapter 5 of the OpenGL 1.4 Specification (Special Functions)
+
+ None
+
+Additions to Chapter 6 of the OpenGL 1.4 Specification (State and
+State Requests)
+
+ None
+
+Additions to Appendix A of the OpenGL 1.4 Specification (Invariance)
+
+ None
+
+Additions to the AGL/GLX/WGL Specifications
+
+ None
+
+GLX Protocol
+
+ None
+
+Errors
+
+ None
+
+New State
+
+ Add the following entry to table 6.20 (Pixels) on page 235:
+
+ Get Value Type Get Cmd Initial Value Description Sec Attribute
+ --------------------------------------------------------------------------------------------------
+ PACK_INVERT_MESA boolean GetBoolean FALSE Value of PACK_INVERT_MESA 4.3.2 pixel-store
+
+Revision History
+
+ 21 September 2002 - Initial draft
diff --git a/nx-X11/extras/Mesa/docs/MESA_packed_depth_stencil.spec b/nx-X11/extras/Mesa/docs/MESA_packed_depth_stencil.spec
new file mode 100644
index 000000000..f4b3e3c92
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/MESA_packed_depth_stencil.spec
@@ -0,0 +1,231 @@
+Name
+
+ MESA_packed_depth_stencil
+
+Name Strings
+
+ GL_MESA_packed_depth_stencil
+
+Contact
+
+ Keith Whitwell, VA Linux Systems Inc. (keithw 'at' valinux.com)
+ Brian Paul, VA Linux Systems Inc. (brianp 'at' valinux.com)
+
+Status
+
+ Obsolete.
+
+Version
+
+ $Id: MESA_packed_depth_stencil.spec,v 1.1.1.3 2004/08/12 23:43:24 anholt Exp $
+
+Number
+
+ ???
+
+Dependencies
+
+ EXT_abgr affects the definition of this extension
+ SGIS_texture4D affects the definition of this extension
+ EXT_cmyka affects the definition of this extension
+ ARB_packed_pixels affects the definition of this extension
+
+Overview
+
+ Provides a mechanism for DrawPixels and ReadPixels to efficiently
+ transfer depth and stencil image data. Specifically, we defined new
+ packed pixel formats and types which pack both stencil and depth
+ into one value.
+
+Issues:
+
+ 1. Is this the right way to distinguish between 24/8 and 8/24
+ pixel formats? Should we instead provide both:
+
+ GL_DEPTH_STENCIL_MESA
+ GL_STENCIL_DEPTH_MESA
+
+ And perhaps just use GL_UNSIGNED_INT, GL_UNSIGNED_SHORT ?
+
+ 2. If not, is it correct to use _REV to indicate that stencil
+ preceeds depth in the 1_15 and 8_24 formats?
+
+ 3. Do we really want the GL_UNSIGNED_SHORT formats?
+
+
+New Procedures and Functions
+
+ None.
+
+New Tokens
+
+ Accepted by the <format> parameter of ReadPixels and DrawPixels:
+
+ GL_DEPTH_STENCIL_MESA 0x8750
+
+ Accepted by the <type> parameter of ReadPixels and DrawPixels:
+
+ GL_UNSIGNED_INT_24_8_MESA 0x8751
+ GL_UNSIGNED_INT_8_24_REV_MESA 0x8752
+ GL_UNSIGNED_SHORT_15_1_MESA 0x8753
+ GL_UNSIGNED_SHORT_1_15_REV_MESA 0x8754
+
+Additions to Chapter 2 of the 1.1 Specification (OpenGL Operation)
+
+ None
+
+Additions to Chapter 3 of the 1.1 Specification (Rasterization)
+
+ One entry is added to table 3.5 (DrawPixels and ReadPixels formats).
+ The new table is:
+
+ Target
+ Format Name Buffer Element Meaning and Order
+ ----------- ------ -------------------------
+ COLOR_INDEX Color Color index
+ STENCIL_INDEX Stencil Stencil index
+ DEPTH_COMPONENT Depth Depth component
+ RED Color R component
+ GREEN Color G component
+ BLUE Color B component
+ ALPHA Color A component
+ RGB Color R, G, B components
+ RGBA Color R, G, B, A components
+ BGRA Color B, G, R, A components
+ ABGR_EXT Color A, B, G, R components
+ CMYK_EXT Color Cyan, Magenta, Yellow, Black components
+ CMYKA_EXT Color Cyan, Magenta, Yellow, Black, A components
+ LUMINANCE Color Luminance component
+ LUMINANCE_ALPHA Color Luminance, A components
+ DEPTH_STENCIL Depth, Depth component, stencil index.
+ Stencil
+
+ Table 3.5: DrawPixels and ReadPixels formats. The third column
+ gives a description of and the number and order of elements in a
+ group.
+
+ Add to the description of packed pixel formats:
+
+ <type> Parameter Data of Matching
+ Token Name Type Elements Pixel Formats
+ ---------------- ---- -------- -------------
+
+ UNSIGNED_BYTE_3_3_2 ubyte 3 RGB
+ UNSIGNED_BYTE_2_3_3_REV ubyte 3 RGB
+ UNSIGNED_SHORT_5_6_5 ushort 3 RGB
+ UNSIGNED_SHORT_5_6_5_REV ushort 3 RGB
+ UNSIGNED_SHORT_4_4_4_4 ushort 4 RGBA,BGRA,ABGR_EXT,CMYK_EXT
+ UNSIGNED_SHORT_4_4_4_4_REV ushort 4 RGBA,BGRA
+ UNSIGNED_SHORT_5_5_5_1 ushort 4 RGBA,BGRA,ABGR_EXT,CMYK_EXT
+ UNSIGNED_SHORT_1_5_5_5_REV ushort 4 RGBA,BGRA
+ UNSIGNED_INT_8_8_8_8 uint 4 RGBA,BGRA,ABGR_EXT,CMYK_EXT
+ UNSIGNED_INT_8_8_8_8_REV uint 4 RGBA,BGRA
+ UNSIGNED_INT_10_10_10_2 uint 4 RGBA,BGRA,ABGR_EXT,CMYK_EXT
+ UNSIGNED_INT_2_10_10_10_REV uint 4 RGBA,BGRA
+ UNSIGNED_SHORT_15_1_MESA ushort 2 DEPTH_STENCIL_MESA
+ UNSIGNED_SHORT_1_15_REV_MESA ushort 2 DEPTH_STENCIL_MESA
+ UNSIGNED_SHORT_24_8_MESA ushort 2 DEPTH_STENCIL_MESA
+ UNSIGNED_SHORT_8_24_REV_MESA ushort 2 DEPTH_STENCIL_MESA
+
+ UNSIGNED_INT_8_24:
+
+ 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
+ +-----------------------+-----------------------------------------------------------------------+
+ | | |
+ +-----------------------+-----------------------------------------------------------------------+
+
+ first second
+ element element
+
+
+ UNSIGNED_INT_24_8:
+
+ 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
+ +----------------------------------------------------------------------+------------------------+
+ | | |
+ +----------------------------------------------------------------------+------------------------+
+
+ first second
+ element element
+
+ UNSIGNED_SHORT_15_1:
+
+ 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
+ +-----------------------------------------------------------+---+
+ | | |
+ +-----------------------------------------------------------+---+
+
+ first second
+ element element
+
+
+ UNSIGNED_SHORT_1_15_REV:
+
+ 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
+ +---+-----------------------------------------------------------+
+ | | |
+ +---+-----------------------------------------------------------+
+
+ second first
+ element element
+
+ The assignment of elements to fields in the packed pixel is as
+ described in the table below:
+
+ First Second Third Fourth
+ Format Element Element Element Element
+ ------ ------- ------- ------- -------
+ RGB red green blue
+ RGBA red green blue alpha
+ BGRA blue green red alpha
+ ABGR_EXT alpha blue green red
+ CMYK_EXT cyan magenta yellow black
+ DEPTH_STENCIL_MESA depth stencil
+
+Additions to Chapter 4 of the 1.1 Specification (Per-Fragment Operations
+and the Frame Buffer)
+
+ The new format is added to the discussion of Obtaining Pixels from the
+ Framebuffer. It should read " If the <format> is one of RED, GREEN,
+ BLUE, ALPHA, RGB, RGBA, ABGR_EXT, LUMINANCE, or LUMINANCE_ALPHA, and
+ the GL is in color index mode, then the color index is obtained."
+
+ The new format is added to the discussion of Index Lookup. It should
+ read "If <format> is one of RED, GREEN, BLUE, ALPHA, RGB, RGBA,
+ ABGR_EXT, LUMINANCE, or LUMINANCE_ALPHA, then the index is used to
+ reference 4 tables of color components: PIXEL_MAP_I_TO_R,
+ PIXEL_MAP_I_TO_G, PIXEL_MAP_I_TO_B, and PIXEL_MAP_I_TO_A."
+
+
+Additions to Chapter 5 of the 1.1 Specification (Special Functions)
+
+ None
+
+Additions to Chapter 6 of the 1.1 Specification (State and State Requests)
+
+ None
+
+Additions to the GLX Specification
+
+ None
+
+GLX Protocol
+
+ TBD
+
+Errors
+
+ None
+
+New State
+
+ None
+
+Revision History
+
+ Version 1.0 - 23 Sep 2000
+ Keith's original version.
+
+ Version 1.1 - 3 Nov 2000
+ Brian's edits, assigned values to new enums.
+
diff --git a/nx-X11/extras/Mesa/docs/MESA_pixmap_colormap.spec b/nx-X11/extras/Mesa/docs/MESA_pixmap_colormap.spec
new file mode 100644
index 000000000..fb0b441cc
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/MESA_pixmap_colormap.spec
@@ -0,0 +1,90 @@
+Name
+
+ MESA_pixmap_colormap
+
+Name Strings
+
+ GLX_MESA_pixmap_colormap
+
+Contact
+
+ Brian Paul (brian.paul 'at' tungstengraphics.com)
+
+Status
+
+ Shipping since Mesa 1.2.8 in May, 1996.
+
+Version
+
+ Last Modified Date: 8 June 2000
+
+Number
+
+ 216
+
+Dependencies
+
+ OpenGL 1.0 or later is required.
+ GLX 1.0 or later is required.
+
+Overview
+
+ Since Mesa allows RGB rendering into drawables with PseudoColor,
+ StaticColor, GrayScale and StaticGray visuals, Mesa needs a colormap
+ in order to compute pixel values during rendering.
+
+ The colormap associated with a window can be queried with normal
+ Xlib functions but there is no colormap associated with pixmaps.
+
+ The glXCreateGLXPixmapMESA function is an alternative to glXCreateGLXPixmap
+ which allows specification of a colormap.
+
+IP Status
+
+ Open-source; freely implementable.
+
+Issues
+
+ None.
+
+New Procedures and Functions
+
+ GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual,
+ Pixmap pixmap, Colormap cmap );
+
+New Tokens
+
+ None.
+
+Additions to Chapter 3 of the GLX 1.3 Specification (Functions and Errors)
+
+ Add to section 3.4.2 Off Screen Rendering
+
+ The Mesa implementation of GLX allows RGB rendering into X windows and
+ pixmaps of any visual class, not just TrueColor or DirectColor. In order
+ to compute pixel values from RGB values Mesa requires a colormap.
+
+ The function
+
+ GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual,
+ Pixmap pixmap, Colormap cmap );
+
+ allows one to create a GLXPixmap with a specific colormap. The image
+ rendered into the pixmap may then be copied to a window (which uses the
+ same colormap and visual) with the expected results.
+
+GLX Protocol
+
+ None since this is a client-side extension.
+
+Errors
+
+ None.
+
+New State
+
+ None.
+
+Revision History
+
+ 8 June 2000 - initial specification
diff --git a/nx-X11/extras/Mesa/docs/MESA_program_debug.spec b/nx-X11/extras/Mesa/docs/MESA_program_debug.spec
new file mode 100644
index 000000000..89429d8f3
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/MESA_program_debug.spec
@@ -0,0 +1,357 @@
+Name
+
+ MESA_program_debug
+
+Name Strings
+
+ GL_MESA_program_debug
+
+Contact
+
+ Brian Paul (brian.paul 'at' tungstengraphics.com)
+
+Status
+
+ XXX - Not complete yet!!!
+
+Version
+
+ Last Modified Date: July 20, 2003
+ Author Revision: 1.0
+ $Date: 2004/08/12 23:43:24 $ $Revision: 1.1.1.3 $
+
+Number
+
+ TBD
+
+Dependencies
+
+ OpenGL 1.4 is required
+ The extension is written against the OpenGL 1.4 specification.
+ ARB_vertex_program or ARB_fragment_program or NV_vertex_program
+ or NV_fragment_program is required.
+
+Overview
+
+ The extension provides facilities for implementing debuggers for
+ vertex and fragment programs.
+
+ The concept is that vertex and fragment program debuggers will be
+ implemented outside of the GL as a utility package. This extension
+ only provides the minimal hooks required to implement a debugger.
+
+ There are facilities to do the following:
+ 1. Have the GL call a user-specified function prior to executing
+ each vertex or fragment instruction.
+ 2. Query the current program string's execution position.
+ 3. Query the current values of intermediate program values.
+
+ The main feature is the ProgramCallbackMESA function. It allows the
+ user to register a callback function with the GL. The callback will
+ be called prior to executing each vertex or fragment program instruction.
+
+ From within the callback, the user may issue Get* commands to
+ query current GL state. The GetProgramRegisterfvMESA function allows
+ current program values to be queried (such as temporaries, input
+ attributes, and result registers).
+
+ There are flags for enabling/disabling the program callbacks.
+
+ The current execution position (as an offset from the start of the
+ program string) can be queried with
+ GetIntegerv(GL_FRAGMENT_PROGRAM_POSITION_MESA, &pos) or
+ GetIntegerv(GL_VERTEX_PROGRAM_POSITION_MESA, &pos).
+
+
+IP Status
+
+ None
+
+Issues
+
+ 1. Is this the right model for a debugger?
+
+ It seems prudent to minimize the scope of this extension and leave
+ it up to the developer (or developer community) to write debuggers
+ that layer on top of this extension.
+
+ If the debugger were fully implemented within the GL it's not
+ clear how terminal and GUI-based interfaces would work, for
+ example.
+
+ 2. There aren't any other extensions that register callbacks with
+ the GL. Isn't there another solution?
+
+ If we want to be able to single-step through vertex/fragment
+ programs I don't see another way to do it.
+
+ 3. How do we prevent the user from doing something crazy in the
+ callback function, like trying to call glBegin (leading to
+ recursion)?
+
+ The rule is that the callback function can only issue glGet*()
+ functions and no other GL commands. It could be difficult to
+ enforce this, however. Therefore, calling any non-get GL
+ command from within the callback will result in undefined
+ results.
+
+ 4. Is this extension amenable to hardware implementation?
+
+ Hopefully, but if not, the GL implementation will have to fall
+ back to a software path when debugging. This may be acceptable
+ for debugging.
+
+ 5. What's the <data> parameter to ProgramCallbackMESA for?
+
+ It's a common programming practice to associate a user-supplied
+ value with callback functions.
+
+ 6. Debuggers often allow one to modify intermediate program values,
+ then continue. Does this extension support that?
+
+ No.
+
+
+New Procedures and Functions (and datatypes)
+
+ typedef void (*programcallbackMESA)(enum target, void *data)
+
+ void ProgramCallbackMESA(enum target, programcallbackMESA callback,
+ void *data)
+
+ void GetProgramRegisterfvMESA(enum target, sizei len,
+ const ubyte *registerName, float *v)
+
+New Tokens
+
+ Accepted by the <cap> parameter of Enable, Disable, IsEnabled,
+ GetBooleanv, GetDoublev, GetFloatv and GetIntegerv:
+
+ FRAGMENT_PROGRAM_CALLBACK_MESA 0x8bb1
+ VERTEX_PROGRAM_CALLBACK_MESA 0x8bb4
+
+ Accepted by the <pname> parameter GetBooleanv, GetDoublev,
+ GetFloatv and GetIntegerv:
+
+ FRAGMENT_PROGRAM_POSITION_MESA 0x8bb0
+ VERTEX_PROGRAM_POSITION_MESA 0x8bb4
+
+ Accepted by the <pname> parameter of GetPointerv:
+
+ FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA 0x8bb2
+ FRAGMENT_PROGRAM_CALLBACK_DATA_MESA 0x8bb3
+ VERTEX_PROGRAM_CALLBACK_FUNC_MESA 0x8bb6
+ VERTEX_PROGRAM_CALLBACK_DATA_MESA 0x8bb7
+
+Additions to Chapter 2 of the OpenGL 1.4 Specification (OpenGL Operation)
+
+ None.
+
+Additions to Chapter 3 of the OpenGL 1.4 Specification (Rasterization)
+
+ None.
+
+Additions to Chapter 4 of the OpenGL 1.4 Specification (Per-Fragment
+Operations and the Frame Buffer)
+
+ None.
+
+Additions to Chapter 5 of the OpenGL 1.4 Specification (Special Functions)
+
+ In section 5.4 "Display Lists", page 202, add the following command
+ to the list of those that are not compiled into display lists:
+
+ ProgramCallbackMESA.
+
+
+ Add a new section 5.7 "Callback Functions"
+
+ The function
+
+ void ProgramCallbackMESA(enum target, programcallbackMESA callback,
+ void *data)
+
+ registers a user-defined callback function with the GL. <target>
+ may be FRAGMENT_PROGRAM_ARB or VERTEX_PROGRAM_ARB. The enabled
+ callback functions registered with these targets will be called
+ prior to executing each instruction in the current fragment or
+ vertex program, respectively. The callbacks are enabled and
+ disabled by calling Enable or Disable with <cap>
+ FRAGMENT_PROGRAM_ARB or VERTEX_PROGRAM_ARB.
+
+ The callback function's signature must match the typedef
+
+ typedef void (*programcallbackMESA)(enum target, void *data)
+
+ When the callback function is called, <target> will either be
+ FRAGMENT_PROGRAM_ARB or VERTEX_PROGRAM_ARB to indicate which
+ program is currently executing and <data> will be the value
+ specified when ProgramCallbackMESA was called.
+
+ From within the callback function, only the following GL commands
+ may be called:
+
+ GetBooleanv
+ GetDoublev
+ GetFloatv
+ GetIntegerv
+ GetProgramLocalParameter
+ GetProgramEnvParameter
+ GetProgramRegisterfvMESA
+ GetProgramivARB
+ GetProgramStringARB
+ GetError
+
+ Calling any other command from within the callback results in
+ undefined behaviour.
+
+
+Additions to Chapter 6 of the OpenGL 1.4 Specification (State and
+State Requests)
+
+ Add a new section 6.1.3 "Program Value Queries":
+
+ The command
+
+ void GetProgramRegisterfvMESA(enum target, sizei len,
+ const ubyte *registerName,
+ float *v)
+
+ Is used to query the value of program variables and registers
+ during program execution. GetProgramRegisterfvMESA may only be
+ called from within a callback function registered with
+ ProgramCallbackMESA.
+
+ <registerName> and <len> specify the name a variable, input
+ attribute, temporary, or result register in the program string.
+ The current value of the named variable is returned as four
+ values in <v>. If <name> doesn't exist in the program string,
+ the error INVALID_OPERATION is generated.
+
+Additions to Appendix A of the OpenGL 1.4 Specification (Invariance)
+
+ None.
+
+Additions to the AGL/GLX/WGL Specifications
+
+ None.
+
+GLX Protocol
+
+ XXX TBD
+
+Dependencies on NV_vertex_program and NV_fragment_program
+
+ If NV_vertex_program and/or NV_fragment_program are supported,
+ vertex and/or fragment programs defined by those extensions may
+ be debugged as well. Register queries will use the syntax used
+ by those extensions (i.e. "v[X]" to query vertex attributes,
+ "o[X]" for vertex outputs, etc.)
+
+Errors
+
+ INVALID_OPERATION is generated if ProgramCallbackMESA is called
+ between Begin and End.
+
+ INVALID_ENUM is generated by ProgramCallbackMESA if <target> is not
+ a supported vertex or fragment program type.
+
+ Note: INVALID_OPERAION IS NOT generated by GetProgramRegisterfvMESA,
+ GetBooleanv, GetDoublev, GetFloatv, or GetIntegerv if called between
+ Begin and End when a vertex or fragment program is currently executing.
+
+ INVALID_ENUM is generated by ProgramCallbackMESA,
+ GetProgramRegisterfvMESA if <target> is not a program target supported
+ by ARB_vertex_program, ARB_fragment_program (or NV_vertex_program or
+ NV_fragment_program).
+
+ INVALID_VALUE is generated by GetProgramRegisterfvMESA if <registerName>
+ does not name a known program register or variable.
+
+ INVALID_OPERATION is generated by GetProgramRegisterfvMESA when a
+ register query is attempted for a program target that's not currently
+ being executed.
+
+
+New State
+
+ XXX finish
+
+(table 6.N, p. ###)
+ Initial
+ Get Value Type Get Command Value Description Sec. Attribute
+ --------- ---- ----------- ----- ----------- ---- ---------
+ FRAGMENT_PROGRAM_CALLBACK_MESA B IsEnabled FALSE XXX XXX enable
+ VERTEX_PROGRAM_CALLBACK_MESA B IsEnabled FALSE XXX XXX enable
+ FRAGMENT_PROGRAM_POSITION_MESA Z+ GetIntegerv -1 XXX XXX -
+ VERTEX_PROGRAM_POSITION_MESA Z+ GetIntegerv -1 XXX XXX -
+ FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA P GetPointerv NULL XXX XXX -
+ VERTEX_PROGRAM_CALLBACK_FUNC_MESA P GetPointerv NULL XXX XXX -
+ FRAGMENT_PROGRAM_CALLBACK_DATA_MESA P GetPointerv NULL XXX XXX -
+ VERTEX_PROGRAM_CALLBACK_DATA_MESA P GetPointerv NULL XXX XXX -
+
+ XXX more?
+
+New Implementation Dependent State
+
+ None.
+
+Revision History
+
+ 8 July 2003
+ Initial draft. (Brian Paul)
+ 11 July 2003
+ Second draft. (Brian Paul)
+ 20 July 2003
+ Third draft. Lots of fundamental changes. (Brian Paul)
+ 23 July 2003
+ Added chapter 5 and 6 spec language. (Brian Paul)
+
+Example Usage
+
+ The following is a very simple example of how this extension may
+ be used to print the values of R0, R1, R2 and R3 while executing
+ vertex programs.
+
+
+ /* This is called by the GL when the vertex program is executing.
+ * We can only make glGet* calls from within this function!
+ */
+ void DebugCallback(GLenum target, GLvoid *data)
+ {
+ GLint pos;
+ GLuint i;
+
+ /* Get PC and current instruction string */
+ glGetIntegerv(GL_VERTEX_PROGRAM_POSITION_ARB, &pos);
+
+ printf("Current position: %d\n", pos);
+
+ printf("Current temporary registers:\n");
+ for (i = 0; i < 4; i++) {
+ GLfloat v[4];
+ char s[10];
+ sprintf(s, "R%d", i);
+ glGetProgramRegisterfvMESA(GL_VERTEX_PROGRAM_ARB, strlen(s), s, v);
+ printf("R%d = %g, %g, %g, %g\n", i, v[0], v[1], v[2], v[3]);
+ }
+ }
+
+
+ /*
+ * elsewhere...
+ */
+
+ /* Register our debugger callback function */
+ glProgramCallbackMESA(GL_VERTEX_PROGRAM_ARB, DebugCallback, NULL);
+ glEnable(GL_VERTEX_PROGRAM_CALLBACK_MESA);
+
+ /* define/bind a vertex program */
+
+ glEnable(GL_VERTEX_PROGRAM);
+
+ /* render something */
+ glBegin(GL_POINTS);
+ glVertex2f(0, 0);
+ glEnd();
+
diff --git a/nx-X11/extras/Mesa/docs/MESA_release_buffers.spec b/nx-X11/extras/Mesa/docs/MESA_release_buffers.spec
new file mode 100644
index 000000000..8db9350d8
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/MESA_release_buffers.spec
@@ -0,0 +1,85 @@
+Name
+
+ MESA_release_buffers
+
+Name Strings
+
+ GLX_MESA_release_buffers
+
+Contact
+
+ Brian Paul (brian.paul 'at' tungstengraphics.com)
+
+Status
+
+ Shipping since Mesa 2.0 in October, 1996.
+
+Version
+
+ Last Modified Date: 8 June 2000
+
+Number
+
+ 217
+
+Dependencies
+
+ OpenGL 1.0 or later is required.
+ GLX 1.0 or later is required.
+
+Overview
+
+ Mesa's implementation of GLX is entirely implemented on the client side.
+ Therefore, Mesa cannot immediately detect when an X window or pixmap is
+ destroyed in order to free any ancilliary data associated with the window
+ or pixmap.
+
+ The glxMesaReleaseBuffers() function can be used to explicitly indicate
+ when the back color buffer, depth buffer, stencil buffer, and/or accum-
+ ulation buffer associated with a drawable can be freed.
+
+IP Status
+
+ Open-source; freely implementable.
+
+Issues
+
+ None.
+
+New Procedures and Functions
+
+ Bool glXReleaseBuffersMESA( Display *dpy, GLXDrawable d );
+
+New Tokens
+
+ None.
+
+Additions to Chapter 3 of the GLX 1.3 Specification (Functions and Errors)
+
+ The function
+
+ Bool glXReleaseBuffersMESA( Display *dpy, GLXDrawable d );
+
+ causes all software ancilliary buffers (back buffer, depth, stencil,
+ accum, etc) associated with the named drawable to be immediately
+ deallocated. True is returned if <d> is a valid Mesa GLX drawable,
+ else False is returned. After calling glXReleaseBuffersMESA, the
+ drawable should no longer be used for GL rendering. Results of
+ attempting to do so are undefined.
+
+
+GLX Protocol
+
+ None, since this is a client-side operation.
+
+Errors
+
+ None.
+
+New State
+
+ None.
+
+Revision History
+
+ 8 June 2000 - initial specification
diff --git a/nx-X11/extras/Mesa/docs/MESA_resize_buffers.spec b/nx-X11/extras/Mesa/docs/MESA_resize_buffers.spec
new file mode 100644
index 000000000..4f1fb164b
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/MESA_resize_buffers.spec
@@ -0,0 +1,82 @@
+Name
+
+ MESA_resize_buffers
+
+Name Strings
+
+ GL_MESA_resize_buffers
+
+Contact
+
+ Brian Paul (brian.paul 'at' tungstengraphics.com)
+
+Status
+
+ Shipping (since Mesa version 2.2)
+
+Version
+
+ $Id: MESA_resize_buffers.spec,v 1.1.1.3 2004/08/12 23:43:24 anholt Exp $
+
+Number
+
+ 196
+
+Dependencies
+
+ Mesa 2.2 or later is required.
+
+Overview
+
+ Mesa is often used as a client library with no integration with
+ the computer's window system (an X server, for example). And since
+ Mesa does not have an event loop nor window system callbacks, it
+ cannot properly respond to window system events. In particular,
+ Mesa cannot automatically detect when a window has been resized.
+
+ Mesa's glViewport command queries the current window size and updates
+ its internal data structors accordingly. This normally works fine
+ since most applications call glViewport in responce to window size
+ changes.
+
+ In some situations, however, the application may not call glViewport
+ when a window size changes but would still like Mesa to adjust to
+ the new window size. This extension exports a new function to solve
+ this problem.
+
+New Procedures and Functions
+
+ void glResizeBuffersMESA( void )
+
+New Tokens
+
+ none
+
+Additions to the OpenGL Specification (no particular section)
+
+ The glResizeBuffersMESA command may be called when the client
+ determines that a window has been resized. Calling
+ glResizeBuffersMESA causes Mesa to query the current window size
+ and adjust its internal data structures. This may include
+ reallocating depth, stencil, alpha and accumulation buffers.
+
+Additions to the AGL/GLX/WGL Specifications
+
+ None
+
+Errors
+
+ INVALID_OPERATION is generated if ResizeBuffersMESA is called betweeen
+ Begin and End.
+
+New State
+
+ None.
+
+New Implementation Dependent State
+
+ None.
+
+Revision History
+
+ * Revision 1.0 - Initial specification
diff --git a/nx-X11/extras/Mesa/docs/MESA_set_3dfx_mode.spec b/nx-X11/extras/Mesa/docs/MESA_set_3dfx_mode.spec
new file mode 100644
index 000000000..06d97ca02
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/MESA_set_3dfx_mode.spec
@@ -0,0 +1,85 @@
+Name
+
+ MESA_set_3dfx_mode
+
+Name Strings
+
+ GLX_MESA_set_3dfx_mode
+
+Contact
+
+ Brian Paul (brian.paul 'at' tungstengraphics.com)
+
+Status
+
+ Shipping since Mesa 2.6 in February, 1998.
+
+Version
+
+ Last Modified Date: 8 June 2000
+
+Number
+
+ 218
+
+Dependencies
+
+ OpenGL 1.0 or later is required.
+ GLX 1.0 or later is required.
+
+Overview
+
+ The Mesa Glide driver allows full-screen rendering or rendering into
+ an X window. The glXSet3DfxModeMESA() function allows an application
+ to switch between full-screen and windowed rendering.
+
+IP Status
+
+ Open-source; freely implementable.
+
+Issues
+
+ None.
+
+New Procedures and Functions
+
+ GLboolean glXSet3DfxModeMESA( GLint mode );
+
+New Tokens
+
+ GLX_3DFX_WINDOW_MODE_MESA 0x1
+ GLX_3DFX_FULLSCREEN_MODE_MESA 0x2
+
+Additions to Chapter 3 of the GLX 1.3 Specification (Functions and Errors)
+
+ The Mesa Glide device driver allows either rendering in full-screen
+ mode or rendering into an X window. An application can switch between
+ full-screen and window rendering with the command:
+
+ GLboolean glXSet3DfxModeMESA( GLint mode );
+
+ <mode> may either be GLX_3DFX_WINDOW_MODE_MESA to indicate window
+ rendering or GLX_3DFX_FULLSCREEN_MODE_MESA to indicate full-screen mode.
+
+ GL_TRUE is returned if <mode> is valid and the operation completed
+ normally. GL_FALSE is returned if <mode> is invalid or if the Glide
+ driver is not being used.
+
+ Note that only one drawable and context can be created at any given
+ time with the Mesa Glide driver.
+
+GLX Protocol
+
+ None since this is a client-side extension.
+
+Errors
+
+ None.
+
+New State
+
+ None.
+
+Revision History
+
+ 8 June 2000 - initial specification
diff --git a/nx-X11/extras/Mesa/docs/MESA_sprite_point.spec b/nx-X11/extras/Mesa/docs/MESA_sprite_point.spec
new file mode 100644
index 000000000..88df417cb
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/MESA_sprite_point.spec
@@ -0,0 +1,191 @@
+Name
+
+ MESA_sprite_point
+
+Name Strings
+
+ GL_MESA_sprite_point
+
+Contact
+
+ Brian Paul, VA Linux Systems Inc. (brianp 'at' valinux.com)
+
+Status
+
+ Obsolete - see GL_ARB_point_sprite.
+
+Version
+
+ $Id: MESA_sprite_point.spec,v 1.1.1.3 2004/08/12 23:43:24 anholt Exp $
+
+Number
+
+ ???
+
+Dependencies
+
+ GL_EXT_point_parameters effects the definition of this extension
+ GL_ARB_multitexture effects the definition of this extension
+
+Overview
+
+ This extension modifies the way in which points are rendered,
+ specifically when they're textured. When SPRITE_POINT_MESA is enabled
+ a point is rendered as if it were a quadrilateral with unique texture
+ coordinates at each vertex. This extension effectively turns points
+ into sprites which may be rendered more easily and quickly than using
+ conventional textured quadrilaterals.
+
+ When using point size > 1 or attenuated points this extension is an
+ effective way to render many small sprite images for particle systems
+ or other effects.
+
+Issues:
+
+ 1. How are the texture coordinates computed?
+
+ The lower-left corner has texture coordinate (0,0,r,q).
+ The lower-right, (1,0,r,q). The upper-right, (1,1,r,q).
+ The upper-left, (0,1,r,q).
+
+ 2. What about texgen and texture matrices?
+
+ Texgen and the texture matrix have no effect on the point's s and t
+ texture coordinates. The r and q coordinates may have been computed
+ by texgen or the texture matrix. Note that with a 3D texture and/or
+ texgen that the r coordinate could be used to select a slice in the
+ 3D texture.
+
+ 3. What about point smoothing?
+
+ When point smoothing is enabled, a triangle fan could be rendered
+ to approximate a circular point. This could be problematic to
+ define and implement so POINT_SMOOTH is ignored when drawing sprite
+ points.
+
+ Smoothed points can be approximated by using an appropriate texture
+ images, alpha testing and blending.
+
+ POLYGON_SMOOTH does effect the rendering of the quadrilateral, however.
+
+ 4. What about sprite rotation?
+
+ There is none. Sprite points are always rendered as window-aligned
+ squares. One could define rotated texture images if desired. A 3D
+ texture and appropriate texture r coordinates could be used to
+ effectively specify image rotation per point.
+
+ 5. What about POLYGON_MODE?
+
+ POLYGON_MODE does not effect the rasterization of the quadrilateral.
+
+ 6. What about POLYGON_CULL?
+
+ TBD. Polygon culling is normally specified and implemented in the
+ transformation stage of OpenGL. However, some rasterization hardware
+ implements it later during triangle setup.
+
+ Polygon culling wouldn't be useful for sprite points since the
+ quadrilaterals are always defined in counter-clockwise order in
+ window space. For that reason, polygon culling should probably be
+ ignored.
+
+ 7. Should sprite points be alpha-attenuated if their size is below the
+ point parameter's threshold size?
+
+ 8. Should there be an advertisized maximum sprite point size?
+
+ No. Since we're rendering the point as a quadrilateral there's no
+ need to limit the size.
+
+
+New Procedures and Functions
+
+ None.
+
+New Tokens
+
+ Accepted by the <pname> parameter of Enable, Disable, IsEnabled,
+ GetIntegerv, GetBooleanv, GetFloatv and GetDoublev:
+
+ SPRITE_POINT_MESA 0x????
+ MAX_SPRITE_POINT_SIZE_MESA 0x???? (need this?)
+
+Additions to Chapter 2 of the 1.1 Specification (OpenGL Operation)
+
+ None
+
+Additions to Chapter 3 of the 1.1 Specification (Rasterization)
+
+ Section ???.
+
+ When SPRITE_POINT_MESA is enabled points are rasterized as screen-
+ aligned quadrilaterals. If the four vertices of the quadrilateral
+ are labeled A, B, C, and D, starting at the lower-left corner and moving
+ counter-clockwise around the quadrilateral, then the vertex and
+ texture coordinates are computed as follows:
+
+ vertex window coordinate texture coordinate
+ A (x-r, y-r, z, w) (0, 0, r, q)
+ B (x+r, y-r, z, w) (1, 0, r, q)
+ C (x+r, y+r, z, w) (1, 1, r, q)
+ D (x-r, y+r, z, w) (0, 1, r, q)
+
+ where x, y, z, w are the point's window coordinates, r and q are the
+ point's 3rd and 4th texture coordinates and r is half the point's
+ size. The other vertex attributes (such as the color and fog coordinate)
+ are simply duplicated from the original point vertex.
+
+ Point size may either be specified with PointSize or computed
+ according to the EXT_point_parameters extension.
+
+ The new texture coordinates are not effected by texgen or the texture
+ matrix. Note, however, that the texture r and q coordinates are passed
+ unchanged and may have been computed with texgen and/or the texture
+ matrix.
+
+ If multiple texture units are present the same texture coordinate is
+ used for all texture units.
+
+ The point is then rendered as if it were a quadrilateral using the
+ normal point sampling rules. POLYGON_MODE does not effect the
+ rasterization of the quadrilateral but POLYGON_SMOOTH does.
+
+ POINT_SMOOTH has no effect when SPRITE_POINT_MESA is enabled.
+
+Additions to Chapter 4 of the 1.1 Specification (Per-Fragment Operations
+and the Frame Buffer)
+
+ None.
+
+Additions to Chapter 5 of the 1.1 Specification (Special Functions)
+
+ None
+
+Additions to Chapter 6 of the 1.1 Specification (State and State Requests)
+
+ None
+
+Additions to the GLX Specification
+
+ None
+
+GLX Protocol
+
+ TBD
+
+Errors
+
+ None
+
+New State
+
+ Add boolean variable SPRITE_POINT_MESA to the point attribute group.
+
+Revision History
+
+ Version 1.0 - 4 Dec 2000
+ Original draft.
+
+
+
diff --git a/nx-X11/extras/Mesa/docs/MESA_swap_control.spec b/nx-X11/extras/Mesa/docs/MESA_swap_control.spec
new file mode 100644
index 000000000..ecc674649
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/MESA_swap_control.spec
@@ -0,0 +1,132 @@
+Name
+
+ MESA_swap_control
+
+Name Strings
+
+ GLX_MESA_swap_control
+
+Contact
+
+ Ian Romanick, IBM, idr at us.ibm.com
+
+Status
+
+ Deployed in DRI drivers post-XFree86 4.3.
+
+Version
+
+ Date: 5/1/2003 Revision: 1.1
+
+Number
+
+ ???
+
+Dependencies
+
+ None
+
+ Based on GLX_SGI_swap_control version 1.9 and WGL_EXT_swap_control
+ version 1.5.
+
+Overview
+
+ This extension allows an application to specify a minimum periodicity
+ of color buffer swaps, measured in video frame periods.
+
+Issues
+
+ * Should implementations that export GLX_MESA_swap_control also export
+ GL_EXT_swap_control for compatibility with WGL_EXT_swap_control?
+
+ UNRESOLVED.
+
+New Procedures and Functions
+
+ int glXSwapIntervalMESA(int interval)
+ int glXGetSwapIntervalMESA(void)
+
+New Tokens
+
+ None
+
+Additions to Chapter 2 of the 1.4 GL Specification (OpenGL Operation)
+
+ None
+
+Additions to Chapter 3 of the 1.4 GL Specification (Rasterization)
+
+ None
+
+Additions to Chapter 4 of the 1.4 GL Specification (Per-Fragment Operations
+and the Framebuffer)
+
+ None
+
+Additions to Chapter 5 of the 1.4 GL Specification (Special Functions)
+
+ None
+
+Additions to Chapter 6 of the 1.4 GL Specification (State and State Requests)
+
+ None
+
+Additions to the GLX 1.3 Specification
+
+ [Add the following to Section 3.3.10 of the GLX Specification (Double
+ Buffering)]
+
+ glXSwapIntervalMESA specifies the minimum number of video frame periods
+ per buffer swap. (e.g. a value of two means that the color buffers
+ will be swapped at most every other video frame.) A return value
+ of zero indicates success; otherwise an error occurred. The interval
+ takes effect when glXSwapBuffers is first called subsequent to the
+ glXSwapIntervalMESA call.
+
+ A video frame period is the time required by the monitor to display a
+ full frame of video data. In the case of an interlaced monitor,
+ this is typically the time required to display both the even and odd
+ fields of a frame of video data.
+
+ If <interval> is set to a value of 0, buffer swaps are not synchron-
+ ized to a video frame. The <interval> value is silently clamped to
+ the maximum implementation-dependent value supported before being
+ stored.
+
+ The swap interval is not part of the render context state. It cannot
+ be pushed or popped. The current swap interval for the window
+ associated with the current context can be obtained by calling
+ glXGetSwapIntervalMESA. The default swap interval is 0.
+
+ On XFree86, setting the environment variable LIBGL_THROTTLE_REFRESH sets
+ the swap interval to 1.
+
+Errors
+
+ glXSwapIntervalMESA returns GLX_BAD_VALUE if parameter <interval> is
+ less than zero.
+
+ glXSwapIntervalMESA returns GLX_BAD_CONTEXT if there is no current
+ GLXContext.
+
+GLX Protocol
+
+ None. This extension only extends to direct rendering contexts.
+
+New State
+
+ Get Value Get Command Type Initial Value
+ --------- ----------- ---- -------------
+ [swap interval] GetSwapInterval Z+ 0
+
+New Implementation Dependent State
+
+ None
+
+
+Revision History
+
+ 1.1, 5/1/03 Added the issues section and contact information.
+ Changed the default swap interval to 0.
+ 1.0, 3/17/03 Initial version based on GLX_SGI_swap_control and
+ WGL_EXT_swap_control.
diff --git a/nx-X11/extras/Mesa/docs/MESA_swap_frame_usage.spec b/nx-X11/extras/Mesa/docs/MESA_swap_frame_usage.spec
new file mode 100644
index 000000000..38cf51a20
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/MESA_swap_frame_usage.spec
@@ -0,0 +1,201 @@
+Name
+
+ MESA_swap_frame_usage
+
+Name Strings
+
+ GLX_MESA_swap_frame_usage
+
+Contact
+
+ Ian Romanick, IBM, idr at us.ibm.com
+
+Status
+
+ Deployed in DRI drivers post-XFree86 4.3.
+
+Version
+
+ Date: 5/1/2003 Revision: 1.1
+
+Number
+
+ ???
+
+Dependencies
+
+ GLX_SGI_swap_control affects the definition of this extension.
+ GLX_MESA_swap_control affects the definition of this extension.
+ GLX_OML_sync_control affects the definition of this extension.
+
+ Based on WGL_I3D_swap_frame_usage version 1.3.
+
+Overview
+
+ This extension allows an application to deterine what portion of the
+ swap period has elapsed since the last swap operation completed. The
+ "usage" value is a floating point value on the range [0,max] which is
+ calculated as follows:
+
+ td
+ percent = ----
+ tf
+
+ where td is the time measured from the last completed buffer swap (or
+ call to enable the statistic) to when the next buffer swap completes, tf
+ is the entire time for a frame which may be multiple screen refreshes
+ depending on the swap interval as set by the GLX_SGI_swap_control or
+ GLX_OML_sync_control extensions.
+
+ The value, percent, indicates the amount of time spent between the
+ completion of the two swaps. If the value is in the range [0,1], the
+ buffer swap occurred within the time period required to maintain a
+ constant frame rate. If the value is in the range (1,max], a constant
+ frame rate was not achieved. The value indicates the number of frames
+ required to draw.
+
+ This definition of "percent" differs slightly from
+ WGL_I3D_swap_frame_usage. In WGL_I3D_swap_frame_usage, the measurement
+ is taken from the completion of one swap to the issuance of the next.
+ This representation may not be as useful as measuring between
+ completions, as a significant amount of time may pass between the
+ issuance of a swap and the swap actually occuring.
+
+ There is also a mechanism to determine whether a frame swap was
+ missed.
+
+New Procedures and Functions
+
+ int glXGetFrameUsageMESA(Display *dpy,
+ GLXDrawable drawable,
+ float *usage)
+
+ int glXBeginFrameTrackingMESA(Display *dpy,
+ GLXDrawable drawable)
+
+ int glXEndFrameTrackingMESA(Display *dpy,
+ GLXDrawable drawable)
+
+ int glXQueryFrameTrackingMESA(Display *dpy,
+ GLXDrawable drawable,
+ int64_t *swapCount,
+ int64_t *missedFrames,
+ float *lastMissedUsage)
+
+New Tokens
+
+ None
+
+Additions to Chapter 2 of the 1.4 GL Specification (OpenGL Operation)
+
+ None
+
+Additions to Chapter 3 of the 1.4 GL Specification (Rasterization)
+
+ None
+
+Additions to Chapter 4 of the 1.4 GL Specification (Per-Fragment Operations
+and the Framebuffer)
+
+ None
+
+Additions to Chapter 5 of the 1.4 GL Specification (Special Functions)
+
+ None
+
+Additions to Chapter 6 of the 1.4 GL Specification (State and State Requests)
+
+ None
+
+Additions to the GLX 1.3 Specification
+
+ The frame usage is measured as the percentage of the swap period elapsed
+ between two buffer-swap operations being commited. In unextened GLX the
+ swap period is the vertical refresh time. If SGI_swap_control or
+ MESA_swap_control are supported, the swap period is the vertical refresh
+ time multiplied by the swap interval (or one if the swap interval is set
+ to zero).
+
+ If OML_sync_control is supported, the swap period is the vertical
+ refresh time multiplied by the divisor parameter to
+ glXSwapBuffersMscOML. The frame usage in this case is less than 1.0 if
+ the swap is commited before target_msc, and is greater than or equal to
+ 1.0 otherwise. The actual usage value is based on the divisor and is
+ never less than 0.0.
+
+ int glXBeginFrameTrackingMESA(Display *dpy,
+ GLXDrawable drawable,
+ float *usage)
+
+ glXGetFrameUsageMESA returns a floating-point value in <usage>
+ that represents the current swap usage, as defined above.
+
+ Missed frame swaps can be tracked by calling the following function:
+
+ int glXBeginFrameTrackingMESA(Display *dpy,
+ GLXDrawable drawable)
+
+ glXBeginFrameTrackingMESA resets a "missed frame" count and
+ synchronizes with the next frame vertical sync before it returns.
+ If a swap is missed based in the rate control specified by the
+ <interval> set by glXSwapIntervalSGI or the default swap of once
+ per frame, the missed frame count is incremented.
+
+ The current missed frame count and total number of swaps since
+ the last call to glXBeginFrameTrackingMESA can be obtained by
+ callling the following function:
+
+ int glXQueryFrameTrackingMESA(Display *dpy,
+ GLXDrawable drawable,
+ int64_t *swapCount,
+ int64_t *missedFrames,
+ float *lastMissedUsage)
+
+ The location pointed to by <swapCount> will be updated with the
+ number of swaps that have been commited. This value may not match the
+ number of swaps that have been requested since swaps may be
+ queued by the implementation. This function can be called at any
+ time and does not synchronize to vertical blank.
+
+ The location pointed to by <missedFrames> will contain the number
+ swaps that missed the specified frame. The frame usage for the
+ last missed frame is returned in the location pointed to by
+ <lastMissedUsage>.
+
+ Frame tracking is disabled by calling the function
+
+ int glXEndFrameTrackingMESA(Display *dpy,
+ GLXDrawable drawable)
+
+ This function will not return until all swaps have occurred. The
+ application can call glXQueryFrameTrackingMESA for a final swap and
+ missed frame count.
+
+ If these functions are succesful, zero is returned. If the context
+ associated with dpy and drawable is not a direct context,
+ GLX_BAD_CONTEXT is returned.
+
+Errors
+
+ If the function succeeds, zero is returned. If the function
+ fails, one of the following error codes is returned:
+
+ GLX_BAD_CONTEXT The current rendering context is not a direct
+ context.
+
+GLX Protocol
+
+ None. This extension only extends to direct rendering contexts.
+
+New State
+
+ None
+
+New Implementation Dependent State
+
+ None
+
+Revision History
+
+ 1.1, 5/1/03 Added contact information.
+ 1.0, 3/17/03 Initial version based on WGL_I3D_swap_frame_usage.
diff --git a/nx-X11/extras/Mesa/docs/MESA_trace.spec b/nx-X11/extras/Mesa/docs/MESA_trace.spec
new file mode 100644
index 000000000..3db569d2b
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/MESA_trace.spec
@@ -0,0 +1,360 @@
+Name
+
+ MESA_trace
+
+Name Strings
+
+ GL_MESA_trace
+
+Contact
+
+ Bernd Kreimeier, Loki Entertainment, bk 'at' lokigames.com
+ Brian Paul, VA Linux Systems, Inc., brianp 'at' valinux.com
+
+Status
+
+ Obsolete.
+
+Version
+
+ $Id: MESA_trace.spec,v 1.1.1.3 2004/08/12 23:43:24 anholt Exp $
+
+Number
+
+ none yet
+
+Dependencies
+
+ OpenGL 1.2 is required.
+ The extension is written against the OpenGL 1.2 Specification
+
+Overview
+
+ Provides the application with means to enable and disable logging
+ of GL calls including parameters as readable text. The verbosity
+ of the generated log can be controlled. The resulting logs are
+ valid (but possibly incomplete) C code and can be compiled and
+ linked for standalone test programs. The set of calls and the
+ amount of static data that is logged can be controlled at runtime.
+ The application can add comments and enable or disable tracing of GL
+ operations at any time. The data flow from the application to GL
+ and back is unaffected except for timing.
+
+ Application-side implementation of these features raises namespace
+ and linkage issues. In the driver dispatch table a simple
+ "chain of responsibility" pattern (aka "composable piepline")
+ can be added.
+
+IP Status
+
+ The extension spec is in the public domain. The current implementation
+ in Mesa is covered by Mesa's XFree86-style copyright by the authors above.
+ This extension is partially inspired by the Quake2 QGL wrapper.
+
+Issues
+
+
+ (1) Is this Extension obsolete because it can
+ be implemented as a wrapper DLL?
+
+ RESOLVED: No. While certain operating systems (Win32) provide linkers
+ that facilitate this kind of solution, other operating systems
+ (Linux) do not support hierarchical linking, so a wrapper solution
+ would result in symbol collisions.
+ Further, IHV's might have builtin support for tracing GL execution
+ that enjoys privileged access, or that they do not wish to separate
+ the tracing code from their driver code base.
+
+ (2) Should the Trace API explicitely support the notion of "frames?
+ This would require hooking into glXSwapBuffers calls as well.
+
+ RESOLVED: No. The application can use NewTraceMESA/EndTraceMESA
+ and TraceComment along with external parsing tools to split the
+ trace into frames, in whatever way considered adequate.
+
+ (2a) Should GLX calls be traced?
+
+ PBuffers and other render-to-texture solutions demonstrate that
+ context level commands beyond SwapBuffers might have to be
+ traced. The GL DLL exports the entry points, so this would not
+ be out of the question.
+
+ (3) Should the specification mandate the actual output format?
+
+ RESOLVED: No. It is sufficient to guarantee that all data and commands
+ will be traced as requested by Enable/DisableTraceMESA, in the order
+ encountered. Whether the resulting trace is available as a readable
+ text file, binary metafile, compilable source code, much less which
+ indentation and formatting has been used, is up to the implementation.
+ For the same reason this specification does not enforce or prohibit
+ additional information added to the trace (statistics, profiling/timing,
+ warnings on possible error conditions).
+
+ (4) Should the comment strings associated with names and pointer (ranges)
+ be considered persistent state?
+
+ RESOLVED: No. The implementation is not forced to use this information
+ on subsequent occurences of name/pointer, and is free to consider it
+ transient state.
+
+ (5) Should comment commands be prohibited between Begin/End?
+
+ RESOLVED: Yes, with the exception of TraceCommentMESA. TraceCommentMESA
+ is transient, the other commands might cause storage of persistent
+ data in the context. There is no need to have the ability mark names
+ or pointers between Begin and End.
+
+
+New Procedures and Functions
+
+ void NewTraceMESA( bitfield mask, const ubyte * traceName )
+
+ void EndTraceMESA( void )
+
+ void EnableTraceMESA( bitfield mask )
+
+ void DisableTraceMESA( bitfield mask )
+
+ void TraceAssertAttribMESA( bitfield attribMask )
+
+ void TraceCommentMESA( const ubyte* comment )
+
+ void TraceTextureMESA( uint name, const ubyte* comment )
+
+ void TraceListMESA( uint name, const ubyte* comment )
+
+ void TracePointerMESA( void* pointer, const ubyte* comment )
+
+ void TracePointerRangeMESA( const void* first,
+ const void* last,
+ const ubyte* comment )
+
+New Tokens
+
+ Accepted by the <mask> parameter of EnableTrace and DisableTrace:
+
+ TRACE_ALL_BITS_MESA 0xFFFF
+ TRACE_OPERATIONS_BIT_MESA 0x0001
+ TRACE_PRIMITIVES_BIT_MESA 0x0002
+ TRACE_ARRAYS_BIT_MESA 0x0004
+ TRACE_TEXTURES_BIT_MESA 0x0008
+ TRACE_PIXELS_BIT_MESA 0x0010
+ TRACE_ERRORS_BIT_MESA 0x0020
+
+ Accepted by the <pname> parameter of GetIntegerv, GetBooleanv,
+ GetFloatv, and GetDoublev:
+
+ TRACE_MASK_MESA 0x8755
+
+ Accepted by the <pname> parameter to GetString:
+
+ TRACE_NAME_MESA 0x8756
+
+
+Additions to Chapter 2 of the OpenGL 1.2.1 Specification (OpenGL Operation)
+
+ None.
+
+Additions to Chapter 3 of the OpenGL 1.2.1 Specification (OpenGL Operation)
+
+ None.
+
+Additions to Chapter 4 of the OpenGL 1.2.1 Specification (OpenGL Operation)
+
+ None.
+
+Additions to Chapter 5 of the OpenGL 1.2.1 Specification (Special Functions)
+
+ Add a new section:
+
+ 5.7 Tracing
+
+ The tracing facility is used to record the execution of a GL program
+ to a human-readable log. The log appears as a sequence of GL commands
+ using C syntax. The primary intention of tracing is to aid in program
+ debugging.
+
+ A trace is started with the command
+
+ void NewTraceMESA( bitfield mask, const GLubyte * traceName )
+
+ <mask> may be any value accepted by PushAttrib and specifies a set of
+ attribute groups. The state values included in those attribute groups
+ is written to the trace as a sequence of GL commands.
+
+ <traceName> specifies a name or label for the trace. It is expected
+ that <traceName> will be interpreted as a filename in most implementations.
+
+ A trace is ended by calling the command
+
+ void EndTraceMESA( void )
+
+ It is illegal to call NewTraceMESA or EndTraceMESA between Begin and End.
+
+ The commands
+
+ void EnableTraceMESA( bitfield mask )
+ void DisableTraceMESA( bitfield mask )
+
+ enable or disable tracing of different classes of GL commands.
+ <mask> may be the union of any of TRACE_OPERATIONS_BIT_MESA,
+ TRACE_PRIMITIVES_BIT_MESA, TRACE_ARRAYS_BIT_MESA, TRACE_TEXTURES_BIT_MESA,
+ and TRACE_PIXELS_BIT_MESA. The special token TRACE_ALL_BITS_MESA
+ indicates all classes of commands are to be logged.
+
+ TRACE_OPERATIONS_BIT_MESA controls logging of all commands outside of
+ Begin/End, including Begin/End.
+
+ TRACE_PRIMITIVES_BIT_MESA controls logging of all commands inside of
+ Begin/End, including Begin/End.
+
+ TRACE_ARRAYS_BIT_MESA controls logging of VertexPointer, NormalPointer,
+ ColorPointer, IndexPointer, TexCoordPointer and EdgeFlagPointer commands.
+
+ TRACE_TEXTURES_BIT_MESA controls logging of texture data dereferenced by
+ TexImage1D, TexImage2D, TexImage3D, TexSubImage1D, TexSubImage2D, and
+ TexSubImage3D commands.
+
+ TRACE_PIXELS_BIT_MESA controls logging of image data dereferenced by
+ Bitmap and DrawPixels commands.
+
+ TRACE_ERRORS_BIT_MESA controls logging of all errors. If this bit is
+ set, GetError will be executed whereever applicable, and the result will
+ be added to the trace as a comment. The error returns are cached and
+ returned to the application on its GetError calls. If the user does not
+ wish the additional GetError calls to be performed, this bit should not
+ be set.
+
+ The command
+
+ void TraceCommentMESA( const ubyte* comment )
+
+ immediately adds the <comment> string to the trace output, surrounded
+ by C-style comment delimiters.
+
+ The commands
+
+ void TraceTextureMESA( uint name, const ubyte* comment )
+ void TraceListMESA( uint name, const ubyte* comment )
+
+ associates <comment> with the texture object or display list specified
+ by <name>. Logged commands which reference the named texture object or
+ display list will be annotated with <comment>. If IsTexture(name) or
+ IsList(name) fail (respectively) the command is quietly ignored.
+
+ The commands
+
+ void TracePointerMESA( void* pointer, const ubyte* comment )
+
+ void TracePointerRangeMESA( const void* first,
+ const void* last,
+ const ubyte* comment )
+
+ associate <comment> with the address specified by <pointer> or with
+ a range of addresses specified by <first> through <last>.
+ Any logged commands which reference <pointer> or an address between
+ <first> and <last> will be annotated with <comment>.
+
+ The command
+
+ void TraceAssertAttribMESA( bitfield attribMask )
+
+ will add GL state queries and assertion statements to the log to
+ confirm that the current state at the time TraceAssertAttrib is
+ executed matches the current state when the trace log is executed
+ in the future.
+
+ <attribMask> is any value accepted by PushAttrib and specifies
+ the groups of state variables which are to be asserted.
+
+ The commands NewTraceMESA, EndTraceMESA, EnableTraceMESA, DisableTraceMESA,
+ TraceAssertAttribMESA, TraceCommentMESA, TraceTextureMESA, TraceListMESA,
+ TracePointerMESA and TracePointerRangeMESA are not compiled into display lists.
+
+
+ Examples:
+
+ The command NewTraceMESA(DEPTH_BUFFER_BIT, "log") will query the state
+ variables DEPTH_TEST, DEPTH_FUNC, DEPTH_WRITEMASK, and DEPTH_CLEAR_VALUE
+ to get the values <test>, <func>, <mask>, and <clear> respectively.
+ Statements equivalent to the following will then be logged:
+
+ glEnable(GL_DEPTH_TEST); (if <test> is true)
+ glDisable(GL_DEPTH_TEST); (if <test> is false)
+ glDepthFunc(<func>);
+ glDepthMask(<mask>);
+ glClearDepth(<clear>);
+
+
+ The command TraceAssertAttribMESA(DEPTH_BUFFER_BIT) will query the state
+ variables DEPTH_TEST, DEPTH_FUNC, DEPTH_WRITEMASK, and DEPTH_CLEAR_VALUE
+ to get the values <test>, <func>, <mask>, and <clear> respectively.
+ The resulting trace might then look will like this:
+
+ {
+ GLboolean b;
+ GLint i;
+ GLfloat f;
+ b = glIsEnabled(GL_DEPTH_TEST);
+ assert(b == <test>);
+ glGetIntegerv(GL_DEPTH_FUNC, &i);
+ assert(i == <func>);
+ glGetIntegerv(GL_DEPTH_MASK, &i);
+ assert(i == <mask>);
+ glGetFloatv(GL_DEPTH_CLEAR_VALUE, &f);
+ assert(f == <clear>);
+ }
+
+
+Additions to Chapter 6 of the OpenGL 1.2.1 Specification
+ (State and State Requests)
+
+ Querying TRACE_MASK_MESA with GetIntegerv, GetFloatv, GetBooleanv or
+ GetDoublev returns the current command class trace mask.
+
+ Querying TRACE_NAME_MESA with GetString returns the current trace name.
+
+
+Additions to Appendix A of the OpenGL 1.2.1 Specification (Invariance)
+
+ The MESA_trace extension can be used in a way that does not affect data
+ flow from application to OpenGL, as well as data flow from OpenGL to
+ application, except for timing, possible print I/O. TRACE_ERRORS_BIT_MESA
+ will add additional GetError queries. Setting a trace mask with NewTraceMESA
+ as well as use of TraceAssertAttribMESA might cause additional state queries.
+ With the possible exception of performance, OpenGL rendering should not be
+ affected at all by a properly chosen logging operation.
+
+Additions to the AGL/GLX/WGL Specifications
+
+ None.
+
+GLX Protocol
+
+ None. The logging operation is carried out client-side, by exporting
+ entry points to the wrapper functions that execute the logging operation.
+
+Errors
+
+ INVALID_OPERATION is generated if any trace command except TraceCommentMESA
+ is called between Begin and End.
+
+New State
+
+ The current trace name and current command class mask are stored
+ per-context.
+
+New Implementation Dependent State
+
+ None.
+
+Revision History
+
+ * Revision 0.1 - Initial draft from template (bk000415)
+ * Revision 0.2 - Draft (bk000906)
+ * Revision 0.3 - Draft (bk000913)
+ * Revision 0.4 - Reworked text, fixed typos (bp000914)
+ * Revision 0.5 - Assigned final GLenum values (bp001103)
+ * Revision 0.6 - TRACE_ERRORS_BIT_MESA (bk000916)
+ * Revision 0.7 - Added MESA postfix (bk010126)
+
diff --git a/nx-X11/extras/Mesa/docs/MESA_window_pos.spec b/nx-X11/extras/Mesa/docs/MESA_window_pos.spec
new file mode 100644
index 000000000..5ad7fa6a6
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/MESA_window_pos.spec
@@ -0,0 +1,127 @@
+Name
+
+ MESA_window_pos
+
+Name Strings
+
+ GL_MESA_window_pos
+
+Contact
+
+ Brian Paul, brian.paul 'at' tungstengraphics.com
+
+Status
+
+ Shipping (since Mesa version 1.2.8)
+
+Version
+
+ $Id: MESA_window_pos.spec,v 1.1.1.3 2004/08/12 23:43:25 anholt Exp $
+
+Number
+
+ 197
+
+Dependencies
+
+ OpenGL 1.0 is required.
+ The extension is written against the OpenGL 1.2 Specification
+
+Overview
+
+ In order to set the current raster position to a specific window
+ coordinate with the RasterPos command, the modelview matrix, projection
+ matrix and viewport must be set very carefully. Furthermore, if the
+ desired window coordinate is outside of the window's bounds one must
+ rely on a subtle side-effect of the Bitmap command in order to circumvent
+ frustum clipping.
+
+ This extension provides a set of functions to directly set the
+ current raster position, bypassing the modelview matrix, the
+ projection matrix and the viewport to window mapping. Furthermore,
+ clip testing is not performed.
+
+ This greatly simplifies the process of setting the current raster
+ position to a specific window coordinate prior to calling DrawPixels,
+ CopyPixels or Bitmap.
+
+New Procedures and Functions
+
+ void WindowPos2dMESA(double x, double y)
+ void WindowPos2fMESA(float x, float y)
+ void WindowPos2iMESA(int x, int y)
+ void WindowPos2sMESA(short x, short y)
+ void WindowPos2ivMESA(const int *p)
+ void WindowPos2svMESA(const short *p)
+ void WindowPos2fvMESA(const float *p)
+ void WindowPos2dvMESA(const double *p)
+ void WindowPos3iMESA(int x, int y, int z)
+ void WindowPos3sMESA(short x, short y, short z)
+ void WindowPos3fMESA(float x, float y, float z)
+ void WindowPos3dMESA(double x, double y, double z)
+ void WindowPos3ivMESA(const int *p)
+ void WindowPos3svMESA(const short *p)
+ void WindowPos3fvMESA(const float *p)
+ void WindowPos3dvMESA(const double *p)
+ void WindowPos4iMESA(int x, int y, int z, int w)
+ void WindowPos4sMESA(short x, short y, short z, short w)
+ void WindowPos4fMESA(float x, float y, float z, float w)
+ void WindowPos4dMESA(double x, double y, double z, double )
+ void WindowPos4ivMESA(const int *p)
+ void WindowPos4svMESA(const short *p)
+ void WindowPos4fvMESA(const float *p)
+ void WindowPos4dvMESA(const double *p)
+
+New Tokens
+
+ none
+
+Additions to Chapter 2 of the OpenGL 1.2 Specification (OpenGL Operation)
+
+ - (2.12, p. 41) Insert after third paragraph:
+
+ Alternately, the current raster position may be set by one of the
+ WindowPosMESA commands:
+
+ void WindowPos{234}{sidf}MESA( T coords );
+ void WindowPos{234}{sidf}vMESA( T coords );
+
+ WindosPos4MESA takes four values indicating x, y, z, and w.
+ WindowPos3MESA (or WindowPos2MESA) is analaguos, but sets only
+ x, y, and z with w implicitly set to 1 (or only x and y with z
+ implicititly set to 0 and w implicitly set to 1).
+
+ WindowPosMESA operates like RasterPos except that the current modelview
+ matrix, projection matrix and viewport parameters are ignored and the
+ clip test operation always passes. The current raster position values
+ are directly set to the parameters passed to WindowPosMESA. The current
+ color, color index and texture coordinate update the current raster
+ position's associated data.
+
+Additions to the AGL/GLX/WGL Specifications
+
+ None
+
+GLX Protocol
+
+ Not specified at this time. However, a protocol message very similar
+ to that of RasterPos is expected.
+
+Errors
+
+ INVALID_OPERATION is generated if WindowPosMESA is called betweeen
+ Begin and End.
+
+New State
+
+ None.
+
+New Implementation Dependent State
+
+ None.
+
+Revision History
+
+ * Revision 1.0 - Initial specification
+ * Revision 1.1 - Minor clean-up (7 Jan 2000, Brian Paul)
+
diff --git a/nx-X11/extras/Mesa/docs/MESA_ycbcr_texture.spec b/nx-X11/extras/Mesa/docs/MESA_ycbcr_texture.spec
new file mode 100644
index 000000000..0fa1f7b39
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/MESA_ycbcr_texture.spec
@@ -0,0 +1,204 @@
+Name
+
+ MESA_ycbcr_texture
+
+Name Strings
+
+ GL_MESA_ycbcr_texture
+
+Contact
+
+ Brian Paul, Tungsten Graphics, Inc. (brian.paul 'at' tungstengraphics.com)
+ Keith Whitwell, Tungsten Graphics, Inc. (keith 'at' tungstengraphics.com)
+
+Status
+
+ Shipping (Mesa 4.0.4 and later)
+
+Version
+
+ 1.0
+
+Number
+
+ TBD
+
+Dependencies
+
+ OpenGL 1.0 or later is required
+ This extensions is written against the OpenGL 1.4 Specification.
+ NV_texture_rectangle effects the definition of this extension.
+
+Overview
+
+ This extension supports texture images stored in the YCbCr format.
+ There is no support for converting YCbCr images to RGB or vice versa
+ during pixel transfer. The texture's YCbCr colors are converted to
+ RGB during texture sampling, after-which, all the usual per-fragment
+ operations take place. Only 2D texture images are supported (not
+ glDrawPixels, glReadPixels, etc).
+
+ A YCbCr pixel (texel) is a 16-bit unsigned short with two components.
+ The first component is luminance (Y). For pixels in even-numbered
+ image columns, the second component is Cb. For pixels in odd-numbered
+ image columns, the second component is Cr. If one were to convert the
+ data to RGB one would need to examine two pixels from columns N and N+1
+ (where N is even) to deduce the RGB color.
+
+IP Status
+
+ None
+
+Issues
+
+ None
+
+New Procedures and Functions
+
+ None
+
+New Tokens
+
+ Accepted by the <internalFormat> and <format> parameters of
+ TexImage2D and TexSubImage2D:
+
+ YCBCR_MESA 0x8757
+
+ Accepted by the <type> parameter of TexImage2D and TexSubImage2D:
+
+ UNSIGNED_SHORT_8_8_MESA 0x85BA /* same as Apple's */
+ UNSIGNED_SHORT_8_8_REV_MESA 0x85BB /* same as Apple's */
+
+Additions to Chapter 2 of the OpenGL 1.4 Specification (OpenGL Operation)
+
+ None
+
+Additions to Chapter 3 of the OpenGL 1.4 Specification (Rasterization)
+
+ In section 3.6.4, Rasterization of Pixel Rectangles, on page 101,
+ add the following to Table 3.8 (Packed pixel formats):
+
+ type Parameter GL Data Number of Matching
+ Token Name Type Components Pixel Formats
+ -------------- ------- ---------- -------------
+ UNSIGNED_SHORT_8_8_MESA ushort 2 YCBCR_MESA
+ UNSIGNED_SHORT_8_8_REV_MESA ushort 2 YCBCR_MESA
+
+
+ In section 3.6.4, Rasterization of Pixel Rectangles, on page 102,
+ add the following to Table 3.10 (UNSIGNED_SHORT formats):
+
+ UNSIGNED_SHORT_8_8_MESA:
+
+ 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
+ +-------------------------------+-------------------------------+
+ | 1st | 2nd |
+ +-------------------------------+-------------------------------+
+
+ UNSIGNED_SHORT_8_8_REV_MESA:
+
+ 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
+ +-------------------------------+-------------------------------+
+ | 2nd | 1st |
+ +-------------------------------+-------------------------------+
+
+
+ In section 3.6.4, Rasterization of Pixel Rectangles, on page 104,
+ add the following to Table 3.12 (Packed pixel fiedl assignments):
+
+ First Second Third Fourth
+ Format Element Element Element Element
+ ------ ------- ------- ------- -------
+ YCBCR_MESA luminance chroma
+
+
+ In section 3.8.1, Texture Image Specification, on page 125, add
+ another item to the list of TexImage2D and TexImage3D equivalence
+ exceptions:
+
+ * The value of internalformat and format may be YCBCR_MESA to
+ indicate that the image data is in YCbCr format. type must
+ be either UNSIGNED_SHORT_8_8_MESA or UNSIGNED_SHORT_8_8_REV_MESA
+ as seen in tables 3.8 and 3.10. Table 3.12 describes the mapping
+ between Y and Cb/Cr to the components.
+ If NV_texture_rectangle is supported target may also be
+ TEXTURE_RECTANGLE_NV or PROXY_TEXTURE_RECTANGLE_NV.
+ All pixel transfer operations are bypassed. The texture is stored as
+ YCbCr, not RGB. Queries of the texture's red, green and blue component
+ sizes will return zero. The YCbCr colors are converted to RGB during
+ texture sampling using an implementation dependent conversion.
+
+
+ In section 3.8.1, Texture Image Specification, on page 126, add
+ another item to the list of TexImage1D and TexImage2D equivalence
+ exceptions:
+
+ * The value of internalformat and format can not be YCBCR_MESA.
+
+
+ In section 3.8.2, Alternate Texture Image Specification Commands, on
+ page 129, insert this paragraph after the first full paragraph on the
+ page:
+
+ "If the internal storage format of the image being updated by
+ TexSubImage2D is YCBCR_MESA then format must be YCBCR_MESA.
+ The error INVALID_OPERATION will be generated otherwise."
+
+
+Additions to Chapter 4 of the OpenGL 1.4 Specification (Per-Fragment
+Operations and the Frame Buffer)
+
+ None
+
+Additions to Chapter 5 of the OpenGL 1.4 Specification (Special Functions)
+
+ None
+
+Additions to Chapter 6 of the OpenGL 1.4 Specification (State and
+State Requests)
+
+ None
+
+Additions to Appendix A of the OpenGL 1.4 Specification (Invariance)
+
+ None
+
+Additions to the AGL/GLX/WGL Specifications
+
+ None
+
+GLX Protocol
+
+ None
+
+Errors
+
+ INVALID_ENUM is generated by TexImage2D if <internalFormat> is
+ MESA_YCBCR but <format> is not MESA_YCBCR.
+
+ INVALID_ENUM is generated by TexImage2D if <format> is MESA_YCBCR but
+ <internalFormat> is not MESA_YCBCR.
+
+ INVALID_VALUE is generated by TexImage2D if <format> is MESA_YCBCR and
+ <internalFormat> is MESA_YCBCR and <border> is not zero.
+
+ INVALID_OPERATION is generated by TexSubImage2D if the internal image
+ format is YCBCR_MESA and <format> is not YCBCR_MESA.
+
+ INVALID_OPERATION is generated by CopyTexSubImage2D if the internal
+ image is YCBCR_MESA.
+
+New State
+
+ Edit table 6.16 on page 231: change the type of TEXTURE_INTERNAL_FORMAT
+ from n x Z42 to n x Z43 to indicate that internal format may also be
+ YCBCR_MESA.
+
+Revision History
+
+ 20 September 2002 - Initial draft
+ 29 April 2003 - minor updates
+ 3 September 2003 - further clarify when YCbCr->RGB conversion takes place
+ 19 September 2003 - a few more updates prior to submitting to extension
+ registry.
+ 3 April 2004 - fix assorted inaccuracies
diff --git a/nx-X11/extras/Mesa/docs/MiniGLX.html b/nx-X11/extras/Mesa/docs/MiniGLX.html
new file mode 100644
index 000000000..342981299
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/MiniGLX.html
@@ -0,0 +1,547 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title>Mini GLX Specification</title>
+</head>
+<body>
+<h1>
+<center>Mini GLX Specification</center>
+</h1>
+<h2>
+<center>Tungsten Graphics, Inc.<br>
+<br>
+January 20, 2003<br>
+<br>
+</center>
+</h2>
+<p> Copyright &copy; 2002-2003 by Tungsten Graphics, Inc., Cedar Park,
+Texas. All Rights Reserved. <br>
+<br>
+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.<br>
+<br>
+</p>
+<h1>1. Introduction</h1>
+<p>The Mini GLX interface facilitates OpenGL rendering on embedded
+devices. The interface is a subset of the GLX interface, plus a minimal
+set of Xlib-like functions.</p>
+<p>Programs written to the Mini GLX specification should run unchanged
+on systems with the X Window System and the GLX extension. The intention
+is to allow flexibility for prototyping and testing.</p>
+<p>This document serves as both the reference guide and programming
+guide for Mini GLX.<br>
+<br>
+</p>
+<h1>2. Mini GLX Concepts</h1>
+<p>The OpenGL specification does not describe how OpenGL rendering
+contexts and drawing surfaces (i.e. the frame buffer) are created and
+managed. Rather, this is handled by an OpenGL window system interface,
+such as Mini GLX.</p>
+<p>There are three main datatypes or resources managed by Mini GLX. The
+resources and their corresponding GLX or Xlib data types are:</p>
+<table cellspacing="10" align="center">
+ <tbody>
+ <tr>
+ <td><u>Resource</u></td>
+ <td><u>Data type</u></td>
+ </tr>
+ <tr>
+ <td>pixel formats</td>
+ <td>X Visual and XVisualInfo</td>
+ </tr>
+ <tr>
+ <td>drawing surfaces</td>
+ <td>X Window or GLXDrawable</td>
+ </tr>
+ <tr>
+ <td>rendering contexts</td>
+ <td>GLXContext</td>
+ </tr>
+ </tbody>
+</table>
+<p>Pixel formats or X Visuals describe the per-pixel attributes of the
+frame buffer. For example, bits per color component, Z buffer size,
+stencil size, TrueColor vs PseudoColor, etc.</p>
+<p>Drawing surfaces or X Windows typically describe a spatial
+allocation of the frame buffer (i.e. the position and size of a
+rectangular region of pixels). Since MiniGLX doesn't really support a
+window system, the window is effectively the entire frame buffer.</p>
+<p>A rendering context represents the current OpenGL state such as
+current drawing color, line width, blending mode, texture parameters,
+etc. Several rendering contexts can be created but only one can be in
+use at any given time.</p>
+<p>The Mini GLX interface provides all the functions needed for
+choosing pixel formats, create drawing surfaces, creating rendering
+contexts and binding rendering contexts to drawing surfaces.<br>
+<br>
+</p>
+<h1>3. Using Mini GLX</h1>
+<p>To use the Mini GLX interface in your application, include the
+GL/miniglx.h header file at compile time:</p>
+<blockquote><code> #include &lt;GL/miniglx.h&gt;<br>
+ </code></blockquote>
+<code></code>Applications should link with libGL.so (i.e. <code>gcc
+myprogram.o -lGL -o myprogram</code>). &nbsp;libGL.so implements the
+MiniGLX API functions and, in turn, loads a hardware-specific device
+driver (such as <code>radeon_dri.so</code>) at runtime. &nbsp;The
+environment variable <code>LIBGL_DRIVERS_PATH</code> should name the
+directory where these modules are located.<br>
+<br>
+Prior to running a MiniGXL application, the following kernel modules
+must be installed:<br>
+<br>
+<div style="margin-left: 40px;"> agpgart.o<br>
+radeonfb.o &nbsp;(assuming Radeon hardware)<br>
+radeon.o &nbsp;(assuming Radeon hardware)<br>
+</div>
+<code></code> <br>
+Finally, MiniGLX reads a configuration file (by default,<code>
+/etc/miniglx.conf</code>) to determine basic configuration information.
+&nbsp;The configuration file may also be located in the directory
+specified by the <code>MINIGLX_CONF</code> environment variable).<br>
+<br>
+The remainder of this section describes the MiniGLX API functions.<br>
+<br>
+<h2>3.1 Initialization</h2>
+<p>The XOpenDisplay function is used to initialize the graphics system:</p>
+<blockquote>
+ <pre>Display *XOpenDisplay(const char *displayname)<br></pre>
+</blockquote>
+<p>The <code>displayName</code> parameter is currently ignored in Mini
+GLX. It is recommended that <code>NULL</code> be passed as the<code>displayName</code>
+parameter.</p>
+<p>If XOpenDisplay is able to initialize the graphics system a pointer
+to a Display will be returned. Otherwise, NULL will be returned.</p>
+<h2>3.2 Choosing a Visual</h2>
+<p>A visual (i.e. pixel format) must be chosen before a drawing surface
+or rendering context can be created. This is done with the
+glXChooseVisual function:</p>
+<blockquote>
+ <pre>XVisualInfo *glXChooseVisual(Display *dpy, int screen, const int *attribList)<br></pre>
+</blockquote>
+<p><code>dpy</code> is a pointer to the display returned by
+XOpenDisplay. </p>
+<p><code>screen</code> is currently ignored by Mini GLX and should be
+zero. </p>
+<p><code>attribList</code> is a list of GLX attributes which describe
+the desired pixel format. It is terminated by the token <code>None</code>.
+The attributes are as follows:</p>
+<blockquote>
+ <dl>
+ <dt><code>GLX_USE_GL</code></dt>
+ <dd>This attribute should always be present in order to maintain
+compatibility with GLX.</dd>
+ <dt><code>GLX_RGBA</code></dt>
+ <dd>If present, only RGBA pixel formats will be considered.
+Otherwise, only color index formats are considered.</dd>
+ <dt><code>GLX_DOUBLEBUFFER</code></dt>
+ <dd>if present, only double-buffered pixel formats will be chosen.</dd>
+ <dt><code>GLX_RED_SIZE n</code></dt>
+ <dd>Must be followed by a non-negative integer indicating the
+minimum number of bits per red pixel component that is acceptable.</dd>
+ <dt><code>GLX_GREEN_SIZE n</code></dt>
+ <dd>Must be followed by a non-negative integer indicating the
+minimum number of bits per green pixel component that is acceptable.</dd>
+ <dt><code>GLX_BLUE_SIZE n</code></dt>
+ <dd>Must be followed by a non-negative integer indicating the
+minimum number of bits per blue pixel component that is acceptable.</dd>
+ <dt><code>GLX_ALPHA_SIZE n</code></dt>
+ <dd>Must be followed by a non-negative integer indicating the
+minimum number of bits per alpha pixel component that is acceptable.</dd>
+ <dt><code>GLX_STENCIL_SIZE n</code></dt>
+ <dd>Must be followed by a non-negative integer indicating the
+minimum number of bits per stencil value that is acceptable.</dd>
+ <dt><code>None</code></dt>
+ <dd>This token is used to terminate the attribute list.</dd>
+ </dl>
+</blockquote>
+<p>glXChooseVisual will return a pointer to an XVisualInfo object which
+most closely matches the requirements of the attribute list. If there
+is no visual which matches the request, NULL will be returned.</p>
+<p>Note that visuals with accumulation buffers and depth buffers are
+not available.<br>
+<br>
+</p>
+<h2>3.3 Creating a Drawing Surface</h2>
+<p>Drawing surfaces are created as X windows. &nbsp;For Mini GLX,
+windows are <i>full-screen</i>; they cover the entire frame buffer.
+&nbsp;Also, Mini GLX imposes a limit of one window. A second window
+cannot be created until the first one is destroyed.</p>
+<h3>3.3.1 Window Creation</h3>
+<p>The XCreateWindow function is used to create a drawing surface:</p>
+<blockquote>
+ <pre>Window XCreateWindow( Display *display,<br> Window parent,<br> int x, int y,<br> unsigned int width, unsigned int height,<br> unsigned int borderWidth,<br> int depth,<br> unsigned int class,<br> Visual *visual,<br> unsigned long valuemask,<br> XSetWindowAttributes *attributes )<br></pre>
+</blockquote>
+<p>The parameters are as follows:</p>
+<blockquote>
+ <dl>
+ <dt><code>display</code></dt>
+ <dd>A Display pointer, as returned by XOpenDisplay.</dd>
+ <dt><code>parent</code></dt>
+ <dd>The parent window for the new window. For Mini GLX, this
+should be<code>RootWindow(dpy, 0)</code>.</dd>
+ <dt><code>x, y</code></dt>
+ <dd>The position of the window. For Mini GLX, both values should
+be zero.</dd>
+ <dt><code>width, height</code></dt>
+ <dd>The size of the window. For Mini GLX, this specifies the
+desired screen size such as 1024, 768 or 1280, 1024.</dd>
+ <dt><code>borderWidth</code></dt>
+ <dd>This parameter should be zero.</dd>
+ <dt><code>depth</code></dt>
+ <dd>The pixel depth for the window. For Mini GLX this should be
+the depth found in the XVisualInfo object returned by <code>glxChooseVisual</code>.</dd>
+ <dt><code>class</code></dt>
+ <dd>The window class. For Mini GLX this value should be <code>InputOutput</code>.</dd>
+ <dt><code>visual</code></dt>
+ <dd>This parameter should be the <code>visual</code> field of the <code>XVisualInfo</code>
+object returned by <code>glxChooseVisual</code>.</dd>
+ <dt><code>valuemask</code></dt>
+ <dd>This parameter indicates which fields of the <code>XSetWindowAttributes</code>
+are to be used. For Mini GLX this is typically the bitmask<code>CWBackPixel
+| CWBorderPixel | CWColormap</code>.</dd>
+ <dt><code>attributes</code></dt>
+ <dd>Initial window attributes. Of the fields in the <code>XSetWindowAttributes</code>
+structure, the<code>background_pixel</code>, <code>border_pixel</code>
+and <code>colormap</code> fields should be set. &nbsp;See the discussion
+below regarding colormaps.</dd>
+ </dl>
+</blockquote>
+<p><code>XCreateWindow</code> will return a window handle if it succeeds
+or zero if it fails.</p>
+<h3>3.3.2 Window Mapping</h3>
+<p>To display the window the XMapWindow function must be called:</p>
+<blockquote>
+ <pre>void XMapWindow(Display *dpy, Window w)</pre>
+</blockquote>
+<p>This function does nothing in Mini GLX but is required for Xlib/GLX
+compatibility</p>
+<h3>3.3.3 Colormaps<br>
+</h3>
+<p>Xlib requires specification of a colormap when creating a window.
+&nbsp;For purposes of interoperability, Mini GLX requires this as well,
+though the colormap is not actually used. &nbsp;The XCreateColormap
+function is used to create a colormap:</p>
+<blockquote><code>Colormap XCreateColormap(Display *dpy, Window window,
+Visual *visual, int alloc)</code><br>
+ <code></code></blockquote>
+<p>The parameters are as follows:<br>
+</p>
+<blockquote>
+ <dl>
+ <dt><code>dpy</code></dt>
+ <dd>The display handle as returned by XOpenDisplay.</dd>
+ <dt><code>window</code></dt>
+ <dd> This parameter is ignored by Mini GLX but should be the value
+returned by the <code>RootWindow(dpy, 0)</code> macro.<br>
+ </dd>
+ <dt><code>visual</code></dt>
+ <dd>This parameter is ignored by Mini GLX but should be the visual
+field of the XVisualInfo object returned by glXChooseVisual. </dd>
+ <dt><code>alloc</code></dt>
+ <dd>This parameter is ignored by Mini GLX but should be set to <code>AllocNone</code>.</dd>
+ </dl>
+</blockquote>
+<br>
+<h2>3.4 Creating a Rendering Context</h2>
+<p>An OpenGL rendering context is created with the <code>glXCreateContext</code>
+function:</p>
+<blockquote>
+ <pre>GLXContext glXCreateContext(Display *dpy, XVisualInfo *visInfo, GLXContext shareList, Bool direct)<br></pre>
+</blockquote>
+<p>The parameters are as follows:</p>
+<blockquote>
+ <dl>
+ <dt><code>dpy</code></dt>
+ <dd>The display handle as returned by XOpenDisplay.</dd>
+ <dt><code>visInfo</code></dt>
+ <dd>The visual as returned by glXChooseVisual.</dd>
+ <dt><code>shareList</code></dt>
+ <dd>If non-zero, texture objects and display lists are shared with
+the named rendering context. If zero, texture objects and display lists
+will (initially) be private to this context. They may be shared when a
+subsequent context is created.</dd>
+ <dt><code>direct</code></dt>
+ <dd>Specifies whether direct or indirect rendering is desired. For
+Mini GLX this value is ignored but it should be set to <code>True</code>.</dd>
+ </dl>
+</blockquote>
+<p><code>glXCreateContext</code> will return a GLXContext handle if it
+succeeds or zero if it fails due to invalid parameter or insufficient
+resources.<br>
+<br>
+</p>
+<h2>3.5 Binding a Rendering Context</h2>
+<p>The final step before beginning OpenGL rendering is to bind (i.e.
+activate) a rendering context and drawing surface with the
+glXMakeCurrent function:</p>
+<blockquote>
+ <pre>Bool glXMakeCurrent(Display *dpy, GLXDrawable drawable, GLXContext ctx)<br></pre>
+</blockquote>
+<p>The parameters are as follows:</p>
+<blockquote>
+ <dl>
+ <dt><code>dpy</code></dt>
+ <dd>The display handle, as returned by XOpenDisplay.</dd>
+ <dt><code>drawable</code></dt>
+ <dd>The window or drawable to bind to the rendering context. This
+should be the value returned by XCreateWindow.</dd>
+ <dt><code>ctx</code></dt>
+ <dd>The rendering context to bind, as returned by glXCreateContext.</dd>
+ </dl>
+</blockquote>
+<p>If glXMakeCurrent succeeds True is returned. Otherwise False is
+returned to indicate an invalid display, window or context parameter.</p>
+<p>After the rendering context has been bound to the drawing surface
+OpenGL rendering can begin.</p>
+<p>The current rendering context may be unbound by calling
+glXMakeCurrent with the window and context parameters set to zero.</p>
+<p>An application may create any number of rendering contexts and bind
+them as needed. Note that binding a rendering context is generally not a
+light-weight operation. &nbsp;Most simple OpenGL applications create
+only one rendering context.<br>
+<br>
+</p>
+<h2>3.6 Color Buffer Swapping</h2>
+<p>A double buffered window has two color buffers: a front buffer and a
+back buffer. Normally, rendering is directed to the back buffer while
+the front buffer is displayed. When rendering of a frame is finished
+the front and back buffers are swapped to provide the illusion of
+instanteous screen updates.</p>
+<p>The color buffers for a particular window (i.e. drawable) may be
+swapped with the glXSwapBuffers command:</p>
+<blockquote>
+ <pre>void glXSwapBuffers(Display *dpy, GLXDrawable drawable)<br></pre>
+</blockquote>
+Any pending rendering commands will be completed before the buffer swap
+takes place.<br>
+<br>
+Calling glXSwapBuffers on a window which is single-buffered has no
+effect.<br>
+<br>
+<h2>3.7 Releasing Resources</h2>
+<h3>3.7.1 Releasing Rendering Contexts</h3>
+<p>A rendering context may be destroyed by calling glXDestroyContext:</p>
+<blockquote>
+ <pre>void glXDestroyContext(Display *dpy, GLXContext ctx)<br></pre>
+</blockquote>
+<h3>3.7.2 Releasing Windows</h3>
+<p>A window may be destroyed by calling XDestroyWindow:</p>
+<blockquote>
+ <pre>void XDestroyWindow(Display *dpy, Window window)<br></pre>
+</blockquote>
+<h3>3.7.3 Releasing Visuals</h3>
+<p>An XVisualInfo object may be freed by calling XFree:</p>
+<blockquote>
+ <pre>void XFree(void *data)<br></pre>
+</blockquote>
+<h3>3.7.4 Releasing Colormaps</h3>
+<p>A colormap may be freed by calling XFreeColormap:</p>
+<blockquote>
+ <pre>void XFreeColormap(Display *dpy, Colormap colormap)<br></pre>
+</blockquote>
+<h3>3.7.4 Releasing Display Resources</h3>
+<p>When the application is about to exit, the resources associated with
+the graphics system can be released by calling XCloseDisplay:</p>
+<blockquote>
+ <pre>void XCloseDisplay(Display *dpy)<br></pre>
+</blockquote>
+<p>The display handle becomes invalid at this point.<br>
+<br>
+</p>
+<h2>3.8 Query Functions</h2>
+<h3>3.8.1 Querying Available Visuals</h3>
+A list of all available visuals can be obtained with the XGetVisualInfo
+function:<br>
+<br>
+<div style="margin-left: 40px;"><code>XVisualInfo
+*XGetVisualInfo(Display *dpy, long vinfo_mask, XVisualInfo
+*vinfo_template, int *nitems_return)<br>
+</code></div>
+<br>
+The parameters are as follows:<br>
+<blockquote>
+ <dl>
+ <dt><code>dpy</code></dt>
+ <dd>The display handle, as returned by XOpenDisplay.</dd>
+ <dt><code>vinfo_mask</code></dt>
+ <dd>A bitmask indicating which fields of the vinfo_template are to
+be matched. &nbsp;The value must be VisualScreenMask.</dd>
+ <dt><code>vinfo_template</code></dt>
+ <dd>A template whose fields indicate which visual attributes must
+be matched by the results. &nbsp;The screen field of this structure must
+be zero.</dd>
+ <dt><code>nitems_return</code></dt>
+ <dd>Returns the number of visuals returned. </dd>
+ </dl>
+</blockquote>
+The return value is the address of an array of all available visuals.<br>
+<br>
+An example of using XGetVisualInfo to get all available visuals follows:<br>
+<br>
+<div style="margin-left: 40px;"><code>XVisualInfo visTemplate, *results;</code><br>
+<code>int numVisuals;</code><br>
+<code>Display *dpy = XOpenDisplay(NULL);</code><br>
+<code>visTemplate.screen = 0;</code><br>
+<code>results = XGetVisualInfo(dpy, VisualScreenMask, &amp;visTemplate,
+&amp;numVisuals);</code><br>
+<code></code></div>
+<br>
+<h3>3.8.2 Querying Visual Attributes</h3>
+<p>The GLX attributes of an X visual may be queried with the
+glXGetConfig function:</p>
+<blockquote>
+ <pre>int glXGetConfig(Display *dpy, XVisualInfo *vis, int attribute, int *value)<br></pre>
+</blockquote>
+<p>The parameters are as follows:</p>
+<blockquote>
+ <dl>
+ <dt><code>dpy</code></dt>
+ <dd>The display handle, as returned by XOpenDisplay.</dd>
+ <dt><code>vis</code></dt>
+ <dd>The visual, as returned by glXChooseVisual.</dd>
+ <dt><code>attribute</code></dt>
+ <dd>The attribute to query. The attributes are listed below.</dd>
+ <dt><code>value</code></dt>
+ <dd>Pointer to an integer in which the result of the query will be
+stored. </dd>
+ </dl>
+</blockquote>
+<p>The return value will be zero if no error occurs.<code>
+&nbsp;GLX_INVALID_ATTRIBUTE</code> will be returned if the attribute
+parameter is invalid.<code> &nbsp;GLX_BAD_VISUAL</code> will be returned
+if the XVisualInfo parameter is invalid.</p>
+<p>The following attributes may be queried:</p>
+<blockquote>
+ <dl>
+ <dt><code>GLX_USE_GL</code></dt>
+ <dd>The result will be <code>True</code> or <code>False</code> to
+indicate if OpenGL rendering is supported with the visual. Mini GLX
+always return <code>True</code>.</dd>
+ <dt><code>GLX_RGBA</code></dt>
+ <dd>The result will be <code>True</code> for RGBA visuals or <code>False</code>
+for color index visuals.</dd>
+ <dt><code>GLX_DOUBLEBUFFER</code></dt>
+ <dd>The result will be <code>True</code> if the visual has two
+color buffers or <code>False</code> if the visual has one color buffer.</dd>
+ <dt><code>GLX_RED_SIZE</code></dt>
+ <dd>The result will be the number of red bits per pixel.</dd>
+ <dt><code>GLX_GREEN_SIZE</code></dt>
+ <dd>The result will be the number of green bits per pixel.</dd>
+ <dt><code>GLX_BLUE_SIZE</code></dt>
+ <dd>The result will be the number of blue bits per pixel.</dd>
+ <dt><code>GLX_ALPHA_SIZE</code></dt>
+ <dd>The result will be the number of alpha bits per pixel.</dd>
+ <dt><code>GLX_DEPTH_SIZE</code></dt>
+ <dd>The result will be the number of bits per Z value.</dd>
+ <dt><code>GLX_STENCIL_SIZE</code></dt>
+ <dd>The result will be the number of bits per stencil value.<br>
+ <br>
+ </dd>
+ </dl>
+</blockquote>
+<h3>3.8.3 Querying the Current Rendering Context</h3>
+<p>The current rendering context can be queried with
+glXGetCurrentContext: </p>
+<blockquote>
+ <pre>GLXContext glXGetCurrentContext(void)<br></pre>
+</blockquote>
+<p>Zero will be returned if no context is currently bound.<br>
+<br>
+</p>
+<h3>3.8.4 Querying the Current Drawable</h3>
+<p>The current drawable (i.e. window or drawing surface) can be queried
+with glXGetCurrentDrawable:</p>
+<blockquote>
+ <pre>GLXDrawable glXGetCurrentDrawable(void)<br></pre>
+</blockquote>
+<p>Zero will be returned if no drawable is currently bound.<br>
+<br>
+</p>
+<h3>3.8.5 Function Address Queries</h3>
+<p>The glXGetProcAddress function will return the address of any
+available OpenGL or Mini GLX function:</p>
+<blockquote>
+ <pre>void *glXGetProcAddress(const GLubyte *procName)<br></pre>
+</blockquote>
+<p>If <code>procName</code> is a valid function name, a pointer to that
+function will be returned. &nbsp;Otherwise, NULL will be returned.</p>
+<p>The purpose of glXGetProcAddress is to facilitate using future
+extensions to OpenGL or Mini GLX. If a future version of the library
+adds new extension functions they'll be accessible via
+glXGetProcAddress. The alternative is to hard-code calls to the new
+functions in the application but doing so will prevent linking the
+application with older versions of the library.<br>
+<br>
+</p>
+<h2>3.9 Versioning</h2>
+The Mini GLX version can be queried at run time with glXQueryVersion:
+<blockquote>
+ <pre>Bool glXQueryVersion(Display *dpy, int *major, int *minor)<br></pre>
+</blockquote>
+<p><code>major</code> will be set to the major version number and<code>minor</code>
+will be set to the minor version number.<code>True</code> will be
+returned if the function succeeds. <code>False</code> will be returned
+if the function fails due to invalid parameters. The <code>dpy</code>
+argument is currently ignored, but should be the value returned by
+XOpenDisplay.</p>
+<p>At compile time, the Mini GLX interface version can be tested with
+the MINI_GLX_VERSION_1_<i>x</i> preprocessor tokens. For example, if
+version 1.0 of Mini GLX is supported, then<code> MINI_GLX_VERSION_1_0</code>
+will be defined. If version 1.1 of Mini GLX is supported, then<code>
+MINI_GLX_VERSION_1_1</code> will be defined.</p>
+<p>At the time of writing the current Mini GLX version is 1.0.<br>
+<br>
+</p>
+<h1>4.0 Interoperability with GLX and Xlib</h1>
+While Mini GLX strives to be compatible with GLX and Xlib there are
+some unavoidable differences which must be taken into consideration.<br>
+<h2>4.1 Public vs Private Structures</h2>
+The structure of many X data types is public. &nbsp;For example, the <code>Display</code>
+data type is defined as a structure in /usr/include/X11/Xlib.h and
+programmers may access any fields of that structure at will. &nbsp;Mini
+GLX also defines a Display data type but its fields are hidden and not
+visiblein <code>miniglx.h</code>. &nbsp;Duplicating the Xlib
+declaration for the <code>Display</code> data type in minigl.h would
+require defining a large number of other superfluous Xlib datatypes.<br>
+<br>
+Mini GLX users are discouraged from directly accessing the fields of
+Xlib data types to maximize portability - though this is unavoidable to
+some extent. &nbsp;For example, the <code>XVisualInfo</code> and <code>XSetWindowAtttributes</code>
+data types must be completely public.
+<h2>4.2 Macros</h2>
+In some cases, Xlib defines macros which are meant to be used instead
+of direct structure accesses. &nbsp;For example, the <code>RootWindow(dpy,
+screen)</code> macro returns the root window for a given screen on a
+given display. &nbsp;Unfortunately, macros do nothing to aid in ABI
+compatibility since they are resolved at compile time instead of at
+link/run time.<br>
+<br>
+Mini GLX also defines a <code>RootWindow</code> macro since it's
+essential for creating windows. &nbsp;But the implementation of this
+macro by Xlib and Mini GLX is completely different.<br>
+<h2>4.3 Summary</h2>
+Because Xlib and Mini GLX define data types and macros differently,
+Mini GLX applications must be recompiled when retargeting Mini GLX or
+native Xlib/GLX. &nbsp;That is, applications can't simply be re-linked
+because of ABI incompatibilities.<br>
+<br>
+Nevertheless, the fact that Mini GLX programs can be recompiled for
+Xlib and GLX increases portability and flexibility for testing and
+prototyping.<br>
+<br>
+<h1>5.0 Example Program</h1>
+<p>This section shows an example program which uses the Mini GLX
+interface. The program simply draws several frames of a rotating square.<br>
+</p>
+<p>The program may be compiled for use with Xlib/GLX or Mini GLX by
+setting the <code>USE_MINIGLX</code> token to 0 or 1, respectively.
+&nbsp;Note that the only difference is the header files which are
+included.<br>
+</p>
+<p> </p>
+<pre><code><br></code>#define USE_MINIGLX 1 /* 1 = use Mini GLX, 0 = use Xlib/GLX */<br><br>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>#include &lt;GL/gl.h&gt;<br><br>#if USE_MINIGLX<br>#include &lt;GL/miniglx.h&gt;<br>#else<br>#include &lt;GL/glx.h&gt;<br>#include &lt;X11/Xlib.h&gt;<br>#endif<br><br><code>/*<br> * Create a simple double-buffered RGBA window.<br> */<br>static Window<br>MakeWindow(Display * dpy, unsigned int width, unsigned int height)<br>{<br> int visAttributes[] = {<br> GLX_RGBA,<br> GLX_RED_SIZE, 1,<br> GLX_GREEN_SIZE, 1,<br> GLX_BLUE_SIZE, 1,<br> GLX_DOUBLEBUFFER,<br> None<br> };<br> XSetWindowAttributes attr;<br> unsigned long attrMask;<br> Window root;<br> Window win;<br> GLXContext ctx;<br> XVisualInfo *visinfo;<br><br> root = RootWindow(dpy, 0);<br><br> /* Choose GLX visual / pixel format */<br> visinfo = glXChooseVisual(dpy, 0, visAttributes);<br> if (!visinfo) {<br> printf("Error: couldn't get an RGB, Double-buffered visual\n");<br> exit(1);<br> }<br><br> /* Create the window */<br> attr.background_pixel = 0;<br> attr.border_pixel = 0;<br> attr.colormap = XCreateColormap(dpy, root, visinfo-&gt;visual, AllocNone);<br> attrMask = CWBackPixel | CWBorderPixel | CWColormap;<br> win = XCreateWindow(dpy, root, 0, 0, width, height,<br> 0, visinfo-&gt;depth, InputOutput,<br> visinfo-&gt;visual, attrMask, &amp;attr);<br> if (!win) {<br> printf("Error: XCreateWindow failed\n");<br> exit(1);<br> }<br><br> /* Display the window */<br> XMapWindow(dpy, win);<br><br> /* Create GLX rendering context */<br> ctx = glXCreateContext(dpy, visinfo, NULL, True);<br> if (!ctx) {<br> printf("Error: glXCreateContext failed\n");<br> exit(1);<br> }<br><br> /* Bind the rendering context and window */<br> glXMakeCurrent(dpy, win, ctx);<br><br> return win;<br>}<br><br><br>/*<br> * Draw a few frames of a rotating square.<br> */<br>static void<br>DrawFrames(Display * dpy, Window win)<br>{<br> int angle;<br> glShadeModel(GL_FLAT);<br> glClearColor(0.5, 0.5, 0.5, 1.0);<br> for (angle = 0; angle &lt; 360; angle += 10) {<br> glClear(GL_COLOR_BUFFER_BIT);<br> glColor3f(1.0, 1.0, 0.0);<br> glPushMatrix();<br> glRotatef(angle, 0, 0, 1);<br> glRectf(-0.8, -0.8, 0.8, 0.8);<br> glPopMatrix();<br> glXSwapBuffers(dpy, win);<br> }<br>}<br><br><br>int<br>main(int argc, char *argv[])<br>{<br> Display *dpy;<br> Window win;<br><br> dpy = XOpenDisplay(NULL);<br> if (!dpy) {<br> printf("Error: XOpenDisplay failed\n");<br> return 1;<br> }<br><br> win = MakeWindow(dpy, 300, 300);<br><br> DrawFrames(dpy, win);<br><br> return 0;<br>}<br></code></pre>
+<br>
+</body>
+</html>
diff --git a/nx-X11/extras/Mesa/docs/README.3DFX b/nx-X11/extras/Mesa/docs/README.3DFX
new file mode 100644
index 000000000..037e8fa7c
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.3DFX
@@ -0,0 +1,830 @@
+
+ 3Dfx Glide device driver
+
+
+
+Requirements:
+-------------
+
+A Voodoo-based videocard/accelerator
+DOS (with DJGPP), Windows9x/2k (with MinGW), Linux
+Glide3x library for your OS
+
+http://sourceforge.net/projects/glide/
+
+
+
+How to compile:
+---------------
+
+DJGPP:
+ Place the Glide3 SDK in the top Mesa directory:
+ $(MESA)/glide3/include/
+ 3dfx.h, g3ext.h, glide.h, glidesys.h, glideutl.h, sst1vid.h
+ $(MESA)/glide3/lib/
+ libgld3x.a, libgld3i.a, glide3x.dxe
+ Type:
+ make -f Makefile.DJ X86=1 FX=1
+ Look into the makefile for further information.
+
+MinGW:
+ Place the Glide3 SDK in the top Mesa directory:
+ $(MESA)/glide3/include/
+ 3dfx.h, g3ext.h, glide.h, glidesys.h, glideutl.h, sst1vid.h
+ $(MESA)/glide3/lib/
+ libglide3x.a, glide3x.dll
+ Type:
+ make -f Makefile.mgw X86=1 FX=1
+ Look into the makefile for further information.
+
+Linux:
+ Place the Glide3 SDK in /usr/local/glide
+ /usr/local/glide/include/
+ 3dfx.h, g3ext.h, glide.h, glidesys.h, glideutl.h, sst1vid.h
+ /usr/local/glide/lib/
+ libglide3x.a, libglide3x.so
+ Type:
+ make linux-glide
+ or
+ make linux-x86-glide
+
+
+
+Compilation defines:
+--------------------
+
+FX_DEBUG
+ enable driver debug code
+FX_TRAP_GLIDE
+ enable Glide trace code
+FX_PACKEDCOLOR
+ use packed color in vertex structure
+FX_TC_NAPALM
+ map GL_COMPRESSED_RGB[A] to FXT1. Works with VSA100-based cards only.
+FX_COMPRESS_S3TC_AS_FXT1_HACK
+ map S3TC to FXT1
+FX_RESCALE_BIG_TEXURES_HACK
+ fake textures larger than HW can support
+ (see MESA_FX_MAXLOD environment variable)
+
+
+
+Environment variables:
+----------------------
+
+The following environment variables affect MesaFX. Those that affect Glide
+only, are beyond the scope of this section. Entries that don't have a "Value"
+field, can have any value whatsoever
+ ex: set MESA_FX_IGNORE_CMBEXT=y
+
+"Note" (*) means that the environment variable affects Glide, too; also, if
+the var is not found in the environment, it is searched in windoze registry.
+"Note" (!) means that the environment variable is not working as expected;
+may have undefined effects, might have effects only at Glide level or might
+not have any effect whatsoever. Caveat emptor! Those are to be revised soon.
+
+It is recommended to leave the envvars alone, so that Mesa/Glide will run with
+default values. Use them only when you experience crashes or strange behavior.
+
+FX_GLIDE_NUM_TMU
+ OS: all
+ HW: dual-TMU cards (Voodoo2, Avenger, Napalm)
+ Desc: force single-TMU
+ Note: (*)
+ Value: "1"
+FX_GLIDE_SWAPPENDINGCOUNT
+ OS: all
+ HW: all
+ Desc: max # of buffers allowed to build up
+ Note: (*) (!)
+ Value: "0", "1", "2", "3", "4", "5" or "6"
+FX_GLIDE_SWAPINTERVAL
+ OS: all
+ HW: all
+ Desc: number of vertical retraces to wait before swapping
+ Note: (*) (!) works only at Glide-level?
+SSTH3_SLI_AA_CONFIGURATION
+ OS: all
+ HW: VSA100-based cards
+ Desc: SLI/AA setup
+ Note: (*) (!) works only at Glide-level?
+ Value:
+ 1, 2, 4 chip cards
+ "0" - SLI & AA disable
+ "1" - SLI disabled, 2 sample AA enabled
+ 2, 4 chip cards
+ "2" - 2-way SLI enabled, AA disabled
+ "3" - 2-way SLI enabled, 2 sample AA enabled
+ "4" - SLI disabled, 4 sample AA enabled
+ 4 chip cards
+ "5" - 4-way SLI enabled, AA disabled
+ "6" - 4-way SLI enabled, 2 sample AA enabled
+ "7" - 2-way SLI enabled, 4 sample AA enabled
+ "8" - SLI disabled, 8 sample AA enabled
+SST_DUALHEAD
+ OS: win32
+ HW: ?
+ Desc: ?
+ Note: (!) disabled?
+MESA_FX_NO_SIGNALS
+ OS: linux
+ HW: all
+ Desc: avoid installing signals
+ Note: (!) untested!
+MESA_FX_INFO
+ OS: all
+ HW: all
+ Desc: verbose to stderr
+ Value: any; special value "r" to redirect stderr to MESA.LOG
+MESA_FX_NOSNAP
+ OS: all
+ HW: Voodoo1, Rush, Banshee
+ Desc: do not snap vertices inside Mesa
+ Note: to be used with Glide3x that snaps vertices internally
+MESA_FX_POINTCAST
+ OS: all
+ HW: dual-TMU cards (some Voodoo1, Voodoo2, Avenger, Napalm)
+ Desc: try to use pointcast palette
+ Note: may give adverse effects on UMA cards (Avenger, Napalm)
+MESA_FX_IGNORE_PALEXT
+ OS: all
+ HW: all
+ Desc: disable 6666 palette
+MESA_FX_IGNORE_PIXEXT
+ OS: all
+ HW: Napalm
+ Desc: force 565 16bpp mode (traditional Voodoo, no 32/15bpp)
+MESA_FX_IGNORE_TEXFMT
+ OS: all
+ HW: Napalm
+ Desc: disable 32bit textures
+MESA_FX_IGNORE_CMBEXT
+ OS: all
+ HW: Napalm
+ Desc: disable Napalm combiners (color/alpha/texture)
+ Note: this option allows dual-TMU cards perform single-pass
+ trilinear, but some advanced (multi)texturing modes
+ won't work (GL_EXT_texture_env_combine)
+MESA_FX_IGNORE_MIREXT
+ OS: all
+ HW: all
+ Desc: disable mirror extension
+MESA_FX_IGNORE_TEXUMA
+ OS: all
+ HW: all
+ Desc: disable UMA
+MESA_FX_IGNORE_TEXUS2
+ OS: all
+ HW: all
+ Desc: disable Texus2
+MESA_FX_MAXLOD
+ OS: all
+ HW: non VSA-100 cards
+ Desc: enable large texture support using SW rescaling
+ Value:
+ "9" - 512x512 textures
+ "10" - 1024x1024 textures
+ "11" - 2048x2048 textures
+MESA_FX_ALLOW_VP
+ OS: all
+ HW: all
+ Desc: allow vertex program extensions
+MESA_GLX_FX
+ OS: linux
+ HW: Voodoo1, Rush, Voodoo2
+ Desc: display mode
+ Note: (!) experimental
+ Value:
+ "w" - windowed mode
+ "f" - fullscreen mode
+ "d" - disable glide driver
+ OS: win32
+ HW: Rush, Banshee, Avenger, Napalm
+ Desc: display mode
+ Note: (!) experimental
+ Value:
+ "w" - windowed mode
+
+
+
+Contact:
+--------
+
+Daniel Borca <dborca 'at' users 'dot' sourceforge 'dot' net>
+Hiroshi Morii <koolsmoky 'at' users 'dot' sourceforge 'dot' net>
+
+
+
+WARNING! The info below this line is outdated (yet some of it useful). WARNING!
+*******************************************************************************
+
+
+
+Info for Mesa 4.1
+-----------------
+
+The 3dfx Glide driver in Mesa is disabled by default. Not too many people
+use this driver anymore and at some point down the road it will be dropped.
+
+To use/enable the Glide driver either do this:
+
+'./configure --with-glide=DIR' Where DIR is the location of Glide, like
+ /usr/ or /usr/local
+
+OR
+
+'make linux-x86-glide' If using the old-style Makefile system.
+
+The rest of this file hasn't changed since Mesa 3.3. Some of it's out of
+date, but some is still valid.
+
+
+
+What do you need ?
+------------------
+
+ - A PC with a 3Dfx Voodoo1/2 Graphics or Voodoo Rush based board
+ (Pure3D, Monster 3D, R3D, Obsidian, Stingray 128/3D, etc.).
+ The Quantum3D Obsidian3D-2 X-24 requires some special env. setting
+ under Linux (more information in the "Useful Glide Environment
+ Variables");
+
+ - The 3Dfx Glide library 2.3 or later for your OS (the 2.4 works fine).
+ The Voodoo2 requires the Glide library 2.51. The Glide 3.1 is not
+ compatible with the Glide 2.x so it doesn't work with the current
+ version of the driver;
+
+ - A compiler supported by the Glide library (Micro$oft VC++ (tested),
+ Watcom (tested), GCC for Linux (tested), etc.);
+
+ - It's nice to have two monitors - one for your normal graphics
+ card and one for your 3Dfx card. If something goes wrong with
+ an application using the 3Dfx hardware you can still see your
+ normal screen in order to recover.
+
+
+
+Tested on:
+----------
+ Windows 95 - David Bucciarelli
+ Windows NT - Henri Fousse
+ MS-DOS
+ Linux - Daryll Strauss, Brian Paul, David Bucciarelli
+ FreeBSD
+ BeOS - Duncan Wilcox
+ MacOS - Fazekas Miklos
+
+
+What is able to do ?
+--------------------
+
+ - It is able accelerate points, lines and polygon with flat
+ shading, gouraud shading, Z-buffer, texture mapping, blending, fog and
+ antialiasing (when possible). There is also the support for rendering
+ in a window with a slow trick for the Voodoo Graphics (available only
+ for Linux) and at full speed with the Voodoo Rush chipset.
+ Under Linux is also possible to switch on-the-fly between the fullscreen
+ and in-window rendering hack.
+ There is also the support for using more than one Voodoo Graphics in the
+ some application/PC (you can create one context for each board and use
+ multiple video outputs for driving monitors, videoprojectors or HMDs).
+ The driver is able to fallback to pure software rendering when afeature
+ isn't supported by the Voodoo hardware (however software rendering is
+ very slow compared to hardware supported rendering)
+
+
+
+How to compile:
+---------------
+
+Linux:
+------
+ Here are the basic steps for using the 3Dfx hardware with Mesa
+ on Linux:
+
+ - You'll need the Glide library and headers. Mesa expects:
+ /usr/local/glide/include/*.h // all the Glide headers
+ /usr/local/glide/lib/libglide2x.so
+
+ If your Glide libraries and headers are in a different directory
+ you'll have to modify the Mesa-config and mklib.glide files.
+
+ - Unpack the MesaLib-3.1.tar.gz and MesaDemos-3.1.tar.gz archives;
+
+ - If you're going to use a newer Mesa/Glide driver than v0.27 then
+ unpack the new driver archive over the Mesa directory.
+
+ - In the Mesa-3.1 directory type "make linux-glide"
+
+ - Compilation _should_ finish without errors;
+
+ - Set your LD_LIBRARY_PATH environment variable so that the
+ libglide2x.so and Mesa library files can be found. For example:
+ setenv LD_LIBRARY_PATH "/usr/local/glide/lib:/SOMEDIR/Mesa-3.1/lib"
+
+ - You'll have to run Glide-based programs as root or set the suid
+ bit on executables;
+
+ - Try a demo:
+ cd gdemos
+ su
+ setenv MESA_GLX_FX f
+ ./gears (hit ESC to exit)
+
+ - You can find the demos especially designed for the Voodoo driver in
+ in the Mesa-3.1/3Dfx/demos directory (type "make" in order to compile
+ everything).
+
+MacOS:
+------
+ Check the WEB page at http://valerie.inf.elte.hu/~boga/Mesa.html
+
+MS Windows:
+-----------
+
+ For the MSVC++:
+ - The glide2x.lib have to be in the default MSVC++ lib directory;
+
+ - The Glide headers have to be in the default MSVC++ include directory;
+
+ - You must have the vcvars32.bat script in your PATH;
+
+ - Go to the directory Mesa-3.1 and run the mesafx.bat;
+
+ - The script will compile everything (Mesa-3.1/lib/OpenGL32.{lib,dll},
+ Mesa-3.1/lib/GLU32.{lib,dll}, Mesa-3.1/lib/GLUT32.{lib,dll} and
+ Voodoo demos);
+
+ - At the end, you will be in the Mesa-3.1/3Dfx/demos directory;
+
+ - Try some demo (fire.exe, teapot.exe, etc.) in order to check if
+ everything is OK (you can use Alt-Tab or Ctrl-F9 to switch between
+ the Voodoo screen and the windows desktop);
+
+ - Remember to copy the Mesa OpenGL32.dll, GLU32.dll and GLUT32.dll in the
+ some directory were you run your Mesa based applications.
+
+ - I think that you can easy change the Makefile.fx files in order
+ to work with other kind of compilers;
+
+ - To discover how open the 3Dfx screen, read the sources under
+ the Mesa-3.1/3Dfx/demos directory. You can use the GLUT library or
+ the Diego Picciani's wgl emulator.
+
+ NOTE: the MSVC++ 5.0 optimizer is really buggy. Also if you install the
+ SP3, you could have some problem (you can disable optimization in order
+ solve these kind of problems).
+
+
+Doing more with Mesa & Linux Glide:
+-----------------------------------
+
+ The MESA_GLX_FX environment variable can be used to coax most
+ GLX-based programs into using Glide (and the __GLUT library
+ is GLX-based__).
+
+ Full-screen 3Dfx rendering:
+ ---------------------------
+
+ 1. Set the MESA_GLX_FX variable to "fullscreen":
+
+ ksh:
+ export MESA_GLX_FX = "fullscreen"
+ csh:
+ setenv MESA_GLX_FX fullscreen
+
+ 2. As root, run a GLX-based program (any GLUT demo on Linux).
+
+ 3. Be careful: once the 3Dfx screen appears you won't be able
+ to see the GLUT windows on your X display. This can make using
+ the mouse tricky! One solution is to hook up your 3Dfx card to
+ a second monitor. If you can do this then set these env vars
+ first:
+
+ setenv SST_VGA_PASS 1
+ setenv SST_NOSHUTDOWN
+
+ or for the Voodoo2:
+
+ setenv SSTV2_VGA_PASS 1
+ setenv SSTV2_NOSHUTDOWN
+
+ Rendering into an X window with the help of the Voodoo hardware:
+ ----------------------------------------------------------------
+
+ 1. Start your X server in 16 bpp mode (XFree86: startx -- -bpp 16)
+ in order to have the best performance and the best visual
+ quality. However you can use any visual depth supported by X.
+
+ 2. Set the following environment variables:
+ export MESA_GLX_FX="window" # to enable window rendering
+ export SST_VGA_PASS=1 # to stop video signal switching
+ export SST_NOSHUTDOWN=1 # to stop video signal switching
+ OR
+ setenv MESA_GLX_FX window
+ setenv SST_VGA_PASS 1
+ setenv SST_NOSHUTDOWN 1
+
+ (the Voodoo2 requires to use "SSTV2_" instead "SST_").
+
+ 3. As root, try running a GLX-based program
+
+ How does it work? We use the 3Dfx hardware to do rendering then
+ copy the image from the 3Dfx frame buffer into an X window when
+ the SwapBuffers() function is called. The problem with this
+ idea is it's slow. The image must be copied from the 3Dfx frame
+ buffer to main memory then copied into the X window (and when the X
+ visual depth doesn't match the Voodoo framebufffer bit per pixel, it
+ is required also a pixel format translation).
+
+ NOTE: the in-window rendering feature only works with double-buffering.
+
+
+ On the fly switching between in window rendering and full screen rendering
+ --------------------------------------------------------------------------
+
+ The Mesa 2.6 has introduced the capability of switching
+ on-the-fly between the fullscreen/fullspeed rendering and the in-window
+ hack and vice versa. The on-the-fly switching requires a direct support
+ by the application but it is really easy to add. You have to start
+ your X server in 16 bpp mode and to add the following lines to your
+ application:
+
+ #if defined(FX) && define(XMESA)
+ #include <GL/xmesa.h>
+
+ static int fullscreen=1;
+ #endif
+
+ ...
+
+ /* In the GLUT keyboard event callback */
+
+ #if defined(FX) && !define(WIN32)
+ case ' ':
+ fullscreen=(!fullscreen);
+ XMesaSetFXmode(fullscreen ? XMESA_FX_FULLSCREEN : XMESA_FX_WINDOW);
+ break;
+ #endif
+ ...
+
+ See the 3Dfx/demos/tunnel.c program
+ for an example. You have to set the -DXMESA flag in the Makefile's COPTS
+ to enable it.
+
+ Rendering into an X window with the X11 software driver:
+ --------------------------------------------------------
+
+ Set the MESA_GLX_FX variable to "disable" your GLX-based program will use
+ the X11 software driver (the 3Dfx hardware isn't used at all).
+
+
+
+Useful Glide Environment Variables:
+-----------------------------------
+
+ - To disable the 3Dfx logo, set the FX_GLIDE_NO_SPLASH variable.
+
+ - To disable video signal switching:
+ setenv SST_VGA_PASS 1
+ setenv SST_NOSHUTDOWN
+ or for the Voodoo2:
+ setenv SSTV2_VGA_PASS 1
+ setenv SSTV2_NOSHUTDOWN
+
+ - To set the default screen refresh rate:
+ setenv SST_SCREENREFRESH=75
+
+ the supported values are 60, 70, 72, 75, 80, 85, 90, 100, 120.
+
+ - To force the Mesa library to swap buffers as fast as possible,
+ without any vertical blanking synchronization (useful for benchmarks):
+ setenv FX_GLIDE_SWAPINTERVAL 0
+ setenv SST_SWAP_EN_WAIT_ON_VIDSYNC 0
+
+ - You can slight improve the performances of your Voodoo1 board with
+ the following env. var.:
+ setenv SST_FASTMEM 1
+ setenv SST_PCIRD 1
+ setenv SST_GRXCLK 57
+
+ (don't use this setting with the Quantum3D 100SB or with any other
+ SLI configuration: it will hang everything !).
+ The following setting can be used with the Voodoo2:
+ setenv SSTV2_FASTMEM_RAS_READS=1
+ setenv SSTV2_FASTPCIRD=1
+ setenv SSTV2_GRXCLK=95
+
+ - The Quantum3D Obsidian3D-2 X-24 requires some special env. setting
+ in order to work under Linux:
+
+ export SSTV2_FT_CLKDEL=5
+ export SSTV2_TF0_CLKDEL=7
+ export SSTV2_TF1_CLKDEL=7
+ export SSTV2_TF2_CLKDEL=7
+ export SSTV2_SLIM_VIN_CLKDEL=3
+ export SSTV2_SLIM_VOUT_CLKDEL=2
+ export SSTV2_SLIS_VIN_CLKDEL=3
+ export SSTV2_SLIS_VOUT_CLKDEL=2
+
+ (Thanks to Phil Ross for this trick).
+
+
+
+
+The Mesa/Voodoo Environment Variables:
+--------------------------------------
+
+ - Only for Windows/Voodoo Rush users, if you define the
+ env. var. MESA_WGL_FX:
+ export MESA_WGL_FX=fullscreen
+ you will get fullscreen rendering;
+
+ - Only for Windows/Voodoo Rush users, if you define the
+ env. var. MESA_WGL_FX:
+ export MESA_WGL_FX=window
+ you will get window rendering (default value);
+
+ - Only for Linux users, you can find more informations about
+ the env. var. MESA_GLX_FX in the "Doing more with Mesa & Linux Glide"
+ section;
+
+ - If you define the env. var. MESA_FX_SWAP_PENDING:
+ export MESA_FX_SWAP_PENDING=4
+ you will able to set the maximum number of swapbuffers
+ commands in the Voodoo FIFO after a swapbuffer (default value: 2);
+
+ - If you define the env. var. MESA_FX_INFO:
+ export MESA_FX_INFO=1
+ you will get some useful statistic.
+
+ - If you define the env. var. MESA_FX_NO_SIGNALS:
+ export MESA_FX_NO_SIGNALS=1
+ Mesa/FX will not install atexit() or signal() handlers.
+
+
+
+Know BUGS and Problems:
+-----------------------
+
+ - fog doesn't work in the right way when using the glDepthRange() function;
+
+ - Maximum texture size: 256x256 (this is an hardware limit);
+
+ - Texture border aren't yet supported;
+
+ - A GL_BLEND in a glTexEnv() is not supported (it is an hardware limit);
+
+ - Use the glBindTexture extension (standard in OpenGL 1.1) for texture
+ mapping (the old way: glTexImage inside a display list, download
+ the texture map each time that you call the display list !!!);
+
+ - Stencil buffer and Accumulation buffer are emulated in software (they are not
+ directly supported by the Hardware);
+
+ - Color index mode not implemented (this is an hardware limit);
+
+ - Thre is an know bug in the Linux Glide library so the in-window-rendering hack
+ and any other operations that requires to read the Voodoo frame buffer
+ (like the accumulation buffer support) doesn't work on Voodoo SLI cards.
+
+ - The driver switch to pure software (_slow_) rendering when:
+
+ - Stencil enabled;
+ - Using the Accumulation buffer;
+ - Blend enabled and blend equation != GL_FUNC_ADD_EXT;
+ - Color logic operation enabled and color logic operation != GL_COPY;
+ - Using GL_SEPARATE_SPECULAR_COLOR;
+ - The four values of glColorMask() aren't the some;
+ - Texture 1D or 3D enabled;
+ - Texture function is GL_BLEND;
+ - Using the Multitexture extension with Voodoo cards with only one TMU;
+ - Using the Multitexture extension with Voodoo cards with more than
+ one TMU, and texture function isn't GL_MODULATE;
+ - Point size is != 1.0 or point params vector != (1.0,0.0,0.0);
+ - Line width != 1.0 or using stipple lines.
+ - Using polygon offset or stipple polygons;
+
+ NOTE: this is list is not yet complete.
+
+
+Hints and Special Features:
+---------------------------
+
+ - Under Linux and with a Voodoo Graphics board, you can use
+ XMesaSetFXmode(XMESA_FX_FULLSCREEN or XMESA_FX_WINDOW) in order to
+ switch on the fly between fullscreen rendering and the in-window-rendering
+ hack.
+
+ - The driver is able to use all the texture memory available: 2/4MB on
+ Voodoo1 boards and 8MB (!) on high-end Voodoo1 and Voodoo2 boards.
+
+ - Trilinear filtering is fully supported on Voodoo boards with two TMUs
+ (high-end Voodoo1 boards and Voodoo2 boards). When only one TMU is
+ available the driver fallback to bilinear filter also if you ask
+ for trilinear filtering.
+
+ - The Voodoo driver support multiple Voodoo Graphics boards in the
+ some PC. Using this feature, you can write applications that use
+ multiple monitors, videoprojectors or HMDs for the output. See
+ Mesa-3.1/3Dfx/demos/tunnel2.c for an example of how setup one
+ context for each board.
+
+ - The v0.19 introduces a new powerful texture memory manager: the
+ texture memory is used as a cache of the set of all defined texture
+ maps. You can now define several MBs of texture maps also with a 2MB
+ of texture memory (the texture memory manager will do automatically
+ all the swap out/swap in
+ texture memory work). The new texture memory manager has also
+ solved a lot of other bugs/no specs compliance/problems
+ related to the texture memory usage.
+
+ - Use triangles and quads strip: they are a LOT faster than sparse
+ triangles and quads.
+
+ - The Voodoo driver supports the GL_EXT_paletted_texture. it works
+ only with GL_COLOR_INDEX8_EXT, GL_RGBA palettes and the alpha value
+ is ignored because this is a limitation of the the current Glide
+ version and of the Voodoo hardware. See Mesa-3.1/3Dfx/demos/paltex.c for
+ a demo of this extension.
+
+ - The Voodoo driver directly supports 3Dfx Global Palette extension.
+ It was written for GLQuake and I think that it isn't a good idea
+ to use this extension for any other purpose (it is a trick). See
+ Mesa-3.1/3Dfx/demos/glbpaltex.c for a demo of this extension.
+
+ - The Voodoo driver chooses the screen resolution according to the
+ requested window size. If you open a 640x480 window, you will get
+ a 640x480 screen resolution, if you open a 800x600 window, you
+ will get a 800x600 screen resolution, etc.
+ Most GLUT demos support the '-geometry' option, so you can choose
+ the screen resolution: 'tunnel -geometry 800x600'.
+ Clearly, you Voodoo board must have enough framebuffer RAM (otherwise
+ the window creation will fail).
+
+ - The glGetString(GL_RENDERER) returns more information
+ about the hardware configuration: "Mesa Glide <version>
+ <Voodoo_Graphics|Voodoo_Rush|UNKNOWN> <num> CARD/<num> FB/
+ <num> TM/<num> TMU/<NOSLI|SLI>"
+ where: <num> CARD is the card used for the current context,
+ <num> FB is the number of MB for the framebuffer,
+ <num> TM is the number of MB for the texture memory,
+ <num> TMU is the number of TMU. You can try to run
+ Mesa/demos/glinfo in order to have an example of the output.
+
+Did you find a lot BUGs and problems ? Good, send me an email.
+
+
+
+FAQ:
+----
+
+For a complete FAQ check the Bernd Kreimeier's Linux 3Dfx HOWTO
+available at http://www.gamers.org/dEngine/xf3D (it includes also
+a lot of informations not strictly related to Linux, so it can be
+useful also if you don't use Linux)
+
+1. What is 3Dfx?
+
+3Dfx Interactive, Inc. is the company which builds the VooDoo 3-D graphics
+chipset (and others) used in popular PC cards such as the Diamond Monster 3D
+and the Orchid Righteous 3D (more informations at http://www.3dfx.com).
+
+
+2. What is Glide?
+
+Glide is a "thin" programming interface for the 3Dfx hardware. It was
+originally written for Windows/Intel but has been ported to Linux/Intel
+by Daryll Strauss.
+
+3Dfx, Inc. should be applauded for allowing the Linux version of Glide
+to be written.
+
+You can directly program with the Glide library if you wish. You can
+obtain Glide from the "Developer" section of the 3Dfx website: www.3dfx.com
+There's a Linux/Glide newsgroup at news://news.3dfx.com/3dfx.glide.linux
+
+
+3. What is fxmesa?
+
+"fxmesa" is the name of the Mesa device driver for the 3Dfx Glide library.
+It was written by David Bucciarelli and others. It works on both Linux
+and Windows. Basically, it allows you to write and run OpenGL-style programs
+on the 3Dfx hardware.
+
+
+4. What is GLQuake?
+
+Quake is a very popular game from id software, Inc. See www.idsoftware.com
+GLQuake is a version of Quake written for OpenGL. There is now a Linux
+version of GLQuake with works with the Mesa/3Dfx/Glide combo.
+
+Here's what you need to run GLQuake on Linux:
+ PC with 100MHz Pentium or better
+ a 3Dfx-based card
+ Mesa 3.1 libraries: libMesaGL.so libMesaGLU.so
+ Glide 2.4 libraries: libglide2x.so libtexus.so
+ GLQuake for Linux.
+
+Also, the windows version of GLQuake works fine with the Mesa OpenGL32.dll,
+you have only to copy the Mesa-3.1/lib/OpenGL32.dll in the GLQuake directory
+in order to test 'MesaQuake'.
+
+
+5. What is GLUT?
+
+GLUT is Mark Kilgard's OpenGL Utility Toolkit. It provides an API for
+writing portable OpenGL programs with support for multiple windows, pop-
+up menus, event handling, etc.
+
+Check the Mark's home page for more informations (http://reality.sgi.com/mjk_asd).
+
+Every OpenGL programmer should check out GLUT.
+
+GLUT on Linux uses GLX.
+
+
+6. What is GLX?
+
+GLX is the OpenGL extension to the X Window System. I defines both a
+programming API (glX*() functions) and a network protocol. Mesa implements
+an emulation of GLX on Linux. A real GLX implementation would requires
+hooks into the X server. The 3Dfx hardware can be used with GLX-based
+programs via the MESA_GLX_FX environment variable.
+
+
+7. Is the Voodoo driver able to use the 4Mb texture memory of
+the Pure3D boards ?
+
+Yes, the Voodoo driver v0.20 includes the support for Voodoo
+Graphics boards with more than 2Mb of texture memory.
+
+
+8. Do the Voodoo driver support the Voodoo Rush under Windows ?
+
+Yes, Diego Picciani has developed the support for the Voodoo
+Rush but David Bucciarelli has a Pure3D and a Monster3D and Brian Paul
+has a Monster3D, so the new versions of the Mesa/Voodoo sometime are
+not tested with the Voodoo Rush.
+
+
+9. Do the Voodoo driver support the Voodoo Rush under Linux ?
+
+No because the Linux Glide doesn't (yet) support the Voodoo Rush.
+
+
+10. Can I sell my Mesa/Voodoo based software and include
+a binary copy of the Mesa in order to make the software
+working out of the box ?
+
+Yes.
+
+
+11. Which is the best make target for compiling the Mesa for
+Linux GLQuake ('make linux-glide', 'make linux-386-glide', etc.) ?
+
+'make linux-386-opt-glide' for Voodoo1 and 'make linux-386-opt-V2-glide'
+for Voodoo2 boards because it doesn't include the '-fPIC'
+option (4-5% faster).
+
+
+12. Can I use a Mesa compiled with a 'make linux-386-opt-V2-glide'
+for my applications/programs/demos ?
+
+Yes, there is only one constrain: you can't run two Mesa applications
+at the some time. This isn't a big issue with the today Voodoo Graphics.
+
+
+Thanks to:
+----------
+
+Henri Fousse (he has written several parts of the v0.15 and the old GLUT
+ emulator for Win);
+
+Diego Picciani (he has developed all the Voodoo Rush support and the wgl
+ emulator);
+
+Daryll Strauss (for the Linux Glide and the first Linux support);
+
+Brian Paul (of course);
+
+Dave 'Zoid' Kirsch (for the Linux GLQuake and Linux Quake2test/Q2 ports)
+
+Bernd Kreimeier (for the Linux 3Dfx HOWTO and for pushing companies to offer
+ a better Linux support)
+
+3Dfx and Quantum3D (for actively supporting Linux)
+
+The most update places where find Mesa VooDoo driver related informations are
+the Mesa mailing list and my driver WEB page
+(http://www-hmw.caribel.pisa.it/fxmesa/index.shtml)
+
+
+David Bucciarelli (davibu@tin.it)
+
+Humanware s.r.l.
+Via XXIV Maggio 62
+Pisa, Italy
+Tel./Fax +39-50-554108
+email: info.hmw@plus.it
+www: www-hmw.caribel.pisa.it
diff --git a/nx-X11/extras/Mesa/docs/README.AMIWIN b/nx-X11/extras/Mesa/docs/README.AMIWIN
new file mode 100644
index 000000000..47cf696cc
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.AMIWIN
@@ -0,0 +1,181 @@
+AMIGA AMIWIN PORT of MESA: THE OPENGL SOFTWARE EMULATION
+========================================================
+Port by Victor Ng-Thow-Hing (victorng@dgp.toronto.edu)
+Original Author (Brian Paul (brianp@ssec.wisc.edu)
+
+Dec.1 , 1995: Port of release Mesa 1.2.5
+ - Modifications made to minimize changes to Mesa distribution.
+
+Nov.25, 1995: Port of release Mesa 1.2.4
+
+
+HISTORY
+=======
+As a 3D graphics progammer, I was increasingly frustrated to see OpenGL
+appearing on so many platforms EXCEPT the Amiga. Up to now, the task
+of porting OpenGL directly from native Amiga drawing routines seemed like
+a daunting task. However, two important events made this port possible.
+
+First of all, Brian Paul wrote Mesa, the OpenGL software emulator that
+can be found on many platforms - except the Amiga and Atari (who cares
+about the latter!). This was pretty ironic considering that Mesa was
+originally prototyped on an Amiga! The second great event was when
+Holger Kruse developed AmiWin, the X11R6 server for the Amiga (definitely
+register for this great piece of software) and released a development kit
+so one could compile X programs with SAS/C.
+
+Since Mesa had X routines as its primitive drawing operations, this made
+a marriage of Mesa and Amiwin feasible. I copied over the sources from
+an ftp site, played with the code, wrote some Smakefiles, and voila,
+I had OpenGL programs displaying on my Amiga.
+
+Although the speed is nothing to be impressed about, this port can be
+potentially useful to those who want to quickly test their code in
+wireframe or perhaps learn more about programming with the OpenGL API.
+
+I hope Amiga developers will continue to write excellent software for
+their machine, especially more X clients for Amiwin. If you have any
+solutions so some of my problems in the porting notes, please send me
+some email!
+
+See you around,
+Vic.
+
+HOW TO CREATE THE LIBRARIES AND SAMPLE CODE
+===========================================
+
+Just run the shell script mklib.amiwin in the mesa directory. This will
+make all the libraries and copy them into the mesa/lib directory. If you
+don't want to compile everything, just go to the desired directory and
+type smake in that directory.
+
+Change any of the variables in the smakefiles as necessary. You will REQUIRE
+the Amiwin development kit to compile these libraries since you need X11.LIB
+and the shareable X libraries. Some examples require the AmiTCP4.0
+net.lib static link library and related header files for unix related
+header files and functions like sleep().
+
+HOW TO USE THE MESA LIBRARIES
+=============================
+
+Study the Smakefiles in the demos, samples and book directories for the
+proper SAS/C options and linkable libraries to use. Basically aux calls
+require Mesaaux.LIB, gl calls require MesaGL.LIB, glu calls MesaGLU.LIB,
+tk calls Mesatk.LIB. There is a preliminary port of MesaGLUT.LIB toolkit
+available in the lib directory with the other Mesa libraries. However,
+it seems to cause crashes on some of the sample code. Someone else may want
+to attempt a more stable port.
+
+PORTING NOTES TO AMIWIN
+=======================
+
+My strategy of porting was to leave as much of the code untouched as
+possible. I surrounded any amiga specific changes with
+#ifdef AMIWIN ... #endif or #ifndef AMIWIN ... #endif preprocessor
+symbols. The code was ported on an Amiga 2000, with Fusion 40 accelerator
+and a Picasso II graphics card. The SAS/C 6.56 compiler was used, with
+the AmiWin 2.16 X development kit.
+
+All compilations were done for a 68040 CPU with 68882 math coprocessor for
+maximum speed. Please edit the smakefile for other compilers.
+I wrote smakefiles for the directories I ported. I omitted the Windows
+and Widgets directories. The former is for MS Windows and the latter
+requires Motif, which is not easily available for the Amiga.
+
+Here are the changes I did per directory:
+
+* mesa
+Nov. 25, 1995 v 1.2.4
+ - added a mklib.amiwin shell script that will make all the libraries and
+ sample code for Mesa
+ - created this readme file: readme.AMIGA
+
+* mesa/include
+Dec. 1, 1995 v 1.2.5
+ - added the following to GL/xmesa.h
+ #ifdef AMIWIN
+ #include <pragmas/xlib_pragmas.h>
+ extern struct Library *XLibBase;
+ #endif
+NET CHANGE: xmesa.h
+
+* mesa/src
+Nov. 25, 1995 v 1.2.4
+ - added the necessary pragma calls for X functions to the following:
+ xmesa1.c, xmesa2.c, xmesa3.c, xfonts.c, glx.c
+ This prevents undefined symbols errors during the linking phase for
+ X library calls
+ - created smakefile
+Dec. 1, 1995 v 1.2.5
+ - removed AMIWIN includes from xmesa1.c, xmesa2.c, xmesa3.c, xfonts.c,
+ glx.c since they are now defined in include/GL/xmesa.h
+NET CHANGE: smakefile
+
+* mesa/src-tk
+Nov. 25, 1995 v 1.2.4
+ - added the necessary pragma calls for X functions to the following:
+ private.h
+ - created smakefile
+Dec. 1, 1995 v 1.2.5
+ - removed AMIWIN includes from private.h since it is now defined in
+ include/GL/xmesa.h
+NET CHANGE: smakefile
+
+* mesa/src-glu
+Nov. 25, 1995 v 1.2.4
+ - created smakefile
+NET CHANGE: smakefile
+
+* mesa/src-aux
+Nov. 25, 1995 v 1.2.4
+ - added the necessary pragma calls for X functions to the following:
+ glaux.c
+ - created smakefile
+NET CHANGE: glaux.c, smakefile
+
+* mesa/demos
+Nov. 25, 1995 v 1.2.4
+ - added the necessary pragma calls for X functions to the following:
+ xdemo.c, glxdemo.c, offset.c
+ - created smakefile
+ - put #ifndef AMIWIN ... #endif around sleep() calls in xdemo.c since
+ they are not part of AmigaDOS.
+Dec. 1, 1995 v 1.2.5
+ - removed AMIWIN defines from xdemo.c, glxdemo.c, offset.c since
+ already defined in include/GL/xmesa.h
+ - modified Smakefile to include header and includes from the AmiTCP4.0
+ net.lib linkable library to provide unix-compatible sys/time.h and
+ the sleep() function
+ - removed AMIWIN defines in xdemo.c since sleep() now defined
+NET CHANGE: smakefile
+
+* mesa/samples
+Nov. 25, 1995 v 1.2.4
+ - added the necessary pragma calls for X functions to the following:
+ oglinfo.c
+ - created smakefile
+ - put #ifndef AMIWIN ... #endif around sleep() in blendxor.c
+ - removed olympic from smakefile targets since <sys/time.h> not defined
+Dec. 1, 1995 v 1.2.5
+ - removed AMIWIN defines from oglinfo.c, since already defined in
+ include/GL/xmesa.h
+ - modified Smakefile to include header and includes from the AmiTCP4.0
+ net.lib linkable library to provide unix-compatible sys/time.h and
+ the sleep() function
+ - removed AMIWIN defines in blendxor.c for sleep()
+ - added AMIWIN defines around _MACHTEN_ in olympic.c since xrandom()
+ functions are not defined in any libraries
+ - added olympic back into the Smakefile targets
+NET CHANGE: smakefile, olympic.c
+
+* mesa/book
+Nov. 25, 1995 v 1.2.4
+- created smakefile
+- removed accpersp and dof from smakefile targets since the SAS/C compile seems to
+ confuse the near,far variables with near/far memory models.
+NET CHANGE: smakefile
+
+* mesa/windows
+Dec. 1, 1995 v 1.2.5
+- Removed directory to save space since this is only needed for Windows based
+ machines.
diff --git a/nx-X11/extras/Mesa/docs/README.BEOS b/nx-X11/extras/Mesa/docs/README.BEOS
new file mode 100644
index 000000000..6e97d6317
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.BEOS
@@ -0,0 +1,137 @@
+
+ Mesa / BeOS Information
+
+
+
+* Introduction
+
+Brian Paul added in Mesa 3.1 a driver for BeOS R4.5 operating system.
+This driver implements a clone of the BGLView class. This class,
+derived from BView, allows OpenGL rendering into any BeOS window. His
+driver was updated in Mesa 4.1 and again in version 6.1 by Philippe
+Houdoin, who's maintaining this driver since.
+
+Any application which uses the BGLView should be able to use Mesa
+instead of Be's OpenGL without changing any code.
+
+Since Be's OpenGL implementation (as of R5) is basically just the
+SGI sample implementation, it's pretty slow. You'll see that Mesa
+is considerably faster.
+
+
+* Source Code
+
+The source code for the driver is in src/mesa/drivers/beos/ directory.
+It's not 100% finished at this time but many GLUT-based demos are
+working. No optimizations have been made at this time.
+
+
+* Compiling
+
+Since Mesa 6.x, it can be build under BeOS with both the R5 builtin gcc version
+or more recent gcc versions available for BeOS, like this gcc version 2.95.3 for BeOS
+you can find at http://www.bebits.com/app/2157.
+Anyway, keep in mind that to take full advantage of Mesa x86 optimizations, you better
+want to use gcc 2.95.3 or sooner versions...
+
+To build Mesa-powered BeOS libGL.so version, open an Terminal window,
+move to Mesa root folder and type this command:
+
+$ make beos
+
+Note that the "beos" argument is only needed the first time to setup build config.
+Next times, typing "make" will be enough.
+
+When it finishes the Mesa based libGL.so library for
+BeOS will be in the lib/ directory, along libglut.so library.
+Several demo/test programs should have been build too under progs/* folders.
+If it stop when building one of the progs/* programs, you may want to ignore it
+and force make to move on next target by adding the -k make option:
+
+$ cd progs
+$ make -k
+
+To install it as Be's default libGL.so replacement, put it in your
+/boot/home/config/lib/ directory. All your GL/GLUT apps will use
+the Mesa based then.
+
+By default, it build a non-debug version library.
+The x86 (MMX, SSE and 3DNOW) optimizations are also supported for x86 target.
+For PowerPC BeOS flavor, sorry, Mesa don't have ppc (Altivec) optimizations
+yet.
+
+To build a DEBUG version, type instead this :
+
+$ DEBUG=1 make
+
+
+* Example Programs
+
+Look under progs/beos/ for some BGLView-based programs.
+You should find under progs/samples and progs/redbook directories GLUT-based programs too.
+They all should have been compiled along with the Mesa library.
+
+
+* GLUT
+
+A beta version of GLUT 3.7 port for BeOS, made by Jake Hamby, can be found at
+http://anobject.com/jehamby/Code/Glut-3.7-x86.zip.
+This is the version currently included in Mesa source code, and
+build in lib/libglut.so.
+
+A previous 3.5 version of this GLUT BeOS port used to be available at
+http://home.beoscentral.com/jehamby/Glut-3.5-x86.zip.
+
+They're special versions of GLUT for the BeOS platform. I don't
+believe Mark Kilgard's normal GLUT distribution includes BeOS
+support.
+
+
+* Special Features
+
+Mesa's implementation of the BGLView class has an extra member
+function: CopySubBufferMESA(). It basically works like SwapBuffers()
+but it only copies a sub region from the back buffer to the front
+buffer. This is a useful optimization for some applications.
+If you use this method in your code be sure that you check at runtime
+that you're actually using Mesa (with glGetString) so you don't
+cause a fatal error when running with Be's OpenGL.
+
+
+* Work Left To Do
+
+- BDirectWindow single buffering support is not implemented yet.
+- Color index mode is not implemented yet.
+- Reading pixels from the front buffer not implemented yet.
+- There is also a BGLScreen class in BeOS for full-screen OpenGL rendering.
+ This should also be implemented for Mesa.
+- Multiple renderers add-ons support, first step toward hardware acceleration
+ support.
+
+* Other contributors to this BeOS port
+
+Jake Hamby jhamby <at> anobject <dot> com
+Marcin Konicki ahwayakchih <at> neoni <dot> net
+Francois Revol revol <at> free <dot> fr
+Nathan Whitehorn nathanw <at> uchicago <dot> edu
+
+
+* Older BeOS Driver
+
+Mesa 2.6 had an earlier BeOS driver. It was based on Mesa's Off-screen
+rendering interface, not BGLView. If you're interested in the older
+driver you should get Mesa 2.6.
+
+
+* BeOS and Glide
+
+Mesa 3.0 supported the 3Dfx/Glide library on Beos. Download Mesa 3.0
+if interested. Ideally, the 3Dfx/Glide support should be updated to
+work with the new Mesa 3.1 BGLView implementation.
+
+The Glide library hasn't been updated for BeOS R4 and newer, to my knowledge,
+as of February, 1999.
+
+
+----------------------------------------------------------------------
+$Id: README.BEOS,v 1.1.1.6 2005/07/31 16:45:49 ajax Exp $
diff --git a/nx-X11/extras/Mesa/docs/README.CYGWIN b/nx-X11/extras/Mesa/docs/README.CYGWIN
new file mode 100644
index 000000000..58d5af3e2
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.CYGWIN
@@ -0,0 +1,256 @@
+
+ Mesa Cygwin/X11 Information
+
+
+WARNING
+=======
+
+If you installed X11 (packages xorg-x11-devel and xorg-x11-bin-dlls ) with the
+latest setup.exe from Cygwin the GL (Mesa) libraries and include are already
+installed in /usr/X11R6.
+
+The following will explain how to "replace" them.
+
+Installation
+============
+
+How to compile Mesa on Cygwin/X11 systems:
+
+1. Shared libs:
+ type 'make cygwin-sl'.
+
+ When finished, the Mesa DLL will be in the Mesa-x.y/lib/ and
+ Mesa-x.y/bin directories.
+
+
+2. Static libs:
+ type 'make cygwin-static'.
+ When finished, the Mesa libraries will be in the Mesa-x.y/lib/ directory.
+
+Header and library files:
+ After you've compiled Mesa and tried the demos I recommend the following
+ procedure for "installing" Mesa.
+
+ Copy the Mesa include/GL directory to /usr/X11R6/include:
+ cp -a include/GL /usr/X11R6/include
+
+ Copy the Mesa library files to /usr/X11R6/lib:
+ cp -a lib/* /usr/X11R6ocal/lib
+
+ Copy the Mesa bin files (used by the DLL stuff) to /usr/X11R6/bin:
+ cp -a lib/cyg* /usr/X11R6/bin
+
+Xt/Motif widgets:
+ If you want to use Mesa or OpenGL in your Xt/Motif program you can build
+ the widgets found in either the widgets-mesa or widgets-sgi directories.
+ The former were written for Mesa and the later are the original SGI
+ widgets. Look in those directories for more information.
+ For the Motif widgets you must have downloaded the lesstif package.
+
+
+Using the library
+=================
+
+Configuration options:
+ The file src/mesa/main/config.h has many parameters which you can adjust
+ such as maximum number of lights, clipping planes, maximum texture size,
+ etc. In particular, you may want to change DEPTH_BITS from 16 to 32
+ if a 16-bit depth buffer isn't precise enough for your application.
+
+
+Shared libraries:
+ If you compile shared libraries (Win32 DLLS) you may have to set an
+ environment variable to specify where the Mesa libraries are located.
+ Set the PATH variable to include /your-dir/Mesa-2.6/bin.
+ Otherwise, when you try to run a demo it may fail with a message saying
+ that one or more DLL couldn't be found.
+
+
+Xt/Motif Widgets:
+ Two versions of the Xt/Motif OpenGL drawing area widgets are included:
+
+ widgets-sgi/ SGI's stock widgets
+ widgets-mesa/ Mesa-tuned widgets
+
+ Look in those directories for details
+
+
+Togl:
+ Togl is an OpenGL/Mesa widget for Tcl/Tk.
+ See http://togl.sourceforge.net for more information.
+
+
+
+X Display Modes:
+ Mesa supports RGB(A) rendering into almost any X visual type and depth.
+
+ The glXChooseVisual function tries its best to pick an appropriate visual
+ for the given attribute list. However, if this doesn't suit your needs
+ you can force Mesa to use any X visual you want (any supported by your
+ X server that is) by setting the MESA_RGB_VISUAL and MESA_CI_VISUAL
+ environment variables. When an RGB visual is requested, glXChooseVisual
+ will first look if the MESA_RGB_VISUAL variable is defined. If so, it
+ will try to use the specified visual. Similarly, when a color index
+ visual is requested, glXChooseVisual will look for the MESA_CI_VISUAL
+ variable.
+
+ The format of accepted values is: <visual-class> <depth>
+ Here are some examples:
+
+ using the C-shell:
+ % setenv MESA_RGB_VISUAL "TrueColor 8" // 8-bit TrueColor
+ % setenv MESA_CI_VISUAL "PseudoColor 12" // 12-bit PseudoColor
+ % setenv MESA_RGB_VISUAL "PseudoColor 8" // 8-bit PseudoColor
+
+ using the KornShell:
+ $ export MESA_RGB_VISUAL="TrueColor 8"
+ $ export MESA_CI_VISUAL="PseudoColor 12"
+ $ export MESA_RGB_VISUAL="PseudoColor 8"
+
+
+Double buffering:
+ Mesa can use either an X Pixmap or XImage as the backbuffer when in
+ double buffer mode. Using GLX, the default is to use an XImage. The
+ MESA_BACK_BUFFER environment variable can override this. The valid
+ values for MESA_BACK_BUFFER are: Pixmap and XImage (only the first
+ letter is checked, case doesn't matter).
+
+ A pixmap is faster when drawing simple lines and polygons while an
+ XImage is faster when Mesa has to do pixel-by-pixel rendering. If you
+ need depth buffering the XImage will almost surely be faster. Exper-
+ iment with the MESA_BACK_BUFFER variable to see which is faster for
+ your application.
+
+
+Colormaps:
+ When using Mesa directly or with GLX, it's up to the application writer
+ to create a window with an appropriate colormap. The aux, tk, and GLUT
+ toolkits try to minimize colormap "flashing" by sharing colormaps when
+ possible. Specifically, if the visual and depth of the window matches
+ that of the root window, the root window's colormap will be shared by
+ the Mesa window. Otherwise, a new, private colormap will be allocated.
+
+ When sharing the root colormap, Mesa may be unable to allocate the colors
+ it needs, resulting in poor color quality. This can happen when a
+ large number of colorcells in the root colormap are already allocated.
+ To prevent colormap sharing in aux, tk and GLUT, define the environment
+ variable MESA_PRIVATE_CMAP. The value isn't significant.
+
+
+Gamma correction:
+ To compensate for the nonlinear relationship between pixel values
+ and displayed intensities, there is a gamma correction feature in
+ Mesa. Some systems, such as Silicon Graphics, support gamma
+ correction in hardware (man gamma) so you won't need to use Mesa's
+ gamma facility. Other systems, however, may need gamma adjustment
+ to produce images which look correct. If in the past you thought
+ Mesa's images were too dim, read on.
+
+ Gamma correction is controlled with the MESA_GAMMA environment
+ variable. Its value is of the form "Gr Gg Gb" or just "G" where
+ Gr is the red gamma value, Gg is the green gamma value, Gb is the
+ blue gamma value and G is one gamma value to use for all three
+ channels. Each value is a positive real number typically in the
+ range 1.0 to 2.5. The defaults are all 1.0, effectively disabling
+ gamma correction. Examples using csh:
+
+ % setenv MESA_GAMMA "2.3 2.2 2.4" // separate R,G,B values
+ % setenv MESA_GAMMA "2.0" // same gamma for R,G,B
+
+ The demos/gamma.c program may help you to determine reasonable gamma
+ value for your display. With correct gamma values, the color intensities
+ displayed in the top row (drawn by dithering) should nearly match those
+ in the bottom row (drawn as grays).
+
+ Alex De Bruyn reports that gamma values of 1.6, 1.6 and 1.9 work well
+ on HP displays using the HP-ColorRecovery technology.
+
+ Mesa implements gamma correction with a lookup table which translates
+ a "linear" pixel value to a gamma-corrected pixel value. There is a
+ small performance penalty. Gamma correction only works in RGB mode.
+ Also be aware that pixel values read back from the frame buffer will
+ not be "un-corrected" so glReadPixels may not return the same data
+ drawn with glDrawPixels.
+
+ For more information about gamma correction see:
+ http://www.inforamp.net/~poynton/notes/colour_and_gamma/GammaFAQ.html
+
+
+Overlay Planes
+
+ Overlay planes in the frame buffer are supported by Mesa but require
+ hardware and X server support. To determine if your X server has
+ overlay support you can test for the SERVER_OVERLAY_VISUALS property:
+
+ xprop -root | grep SERVER_OVERLAY_VISUALS
+
+
+HPCR glClear(GL_COLOR_BUFFER_BIT) dithering
+
+ If you set the MESA_HPCR_CLEAR environment variable then dithering
+ will be used when clearing the color buffer. This is only applicable
+ to HP systems with the HPCR (Color Recovery) system.
+
+
+Extensions
+==========
+ There are three Mesa-specific GLX extensions at this time.
+
+ GLX_MESA_pixmap_colormap
+
+ This extension adds the GLX function:
+
+ GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual,
+ Pixmap pixmap, Colormap cmap )
+
+ It is an alternative to the standard glXCreateGLXPixmap() function.
+ Since Mesa supports RGB rendering into any X visual, not just True-
+ Color or DirectColor, Mesa needs colormap information to convert RGB
+ values into pixel values. An X window carries this information but a
+ pixmap does not. This function associates a colormap to a GLX pixmap.
+ See the xdemos/glxpixmap.c file for an example of how to use this
+ extension.
+
+ GLX_MESA_release_buffers
+
+ Mesa associates a set of ancillary (depth, accumulation, stencil and
+ alpha) buffers with each X window it draws into. These ancillary
+ buffers are allocated for each X window the first time the X window
+ is passed to glXMakeCurrent(). Mesa, however, can't detect when an
+ X window has been destroyed in order to free the ancillary buffers.
+
+ The best it can do is to check for recently destroyed windows whenever
+ the client calls the glXCreateContext() or glXDestroyContext()
+ functions. This may not be sufficient in all situations though.
+
+ The GLX_MESA_release_buffers extension allows a client to explicitly
+ deallocate the ancillary buffers by calling glxReleaseBuffersMESA()
+ just before an X window is destroyed. For example:
+
+ #ifdef GLX_MESA_release_buffers
+ glXReleaseBuffersMESA( dpy, window );
+ #endif
+ XDestroyWindow( dpy, window );
+
+ This extension is new in Mesa 2.0.
+
+ GLX_MESA_copy_sub_buffer
+
+ This extension adds the glXCopySubBufferMESA() function. It works
+ like glXSwapBuffers() but only copies a sub-region of the window
+ instead of the whole window.
+
+ This extension is new in Mesa version 2.6
+
+
+
+Summary of X-related environment variables:
+ MESA_RGB_VISUAL - specifies the X visual and depth for RGB mode (X only)
+ MESA_CI_VISUAL - specifies the X visual and depth for CI mode (X only)
+ MESA_BACK_BUFFER - specifies how to implement the back color buffer (X only)
+ MESA_PRIVATE_CMAP - force aux/tk libraries to use private colormaps (X only)
+ MESA_GAMMA - gamma correction coefficients (X only)
+
+
+----------------------------------------------------------------------
+README.CYGWIN - lassauge April 2004 - based on README.X11
diff --git a/nx-X11/extras/Mesa/docs/README.D3D b/nx-X11/extras/Mesa/docs/README.D3D
new file mode 100644
index 000000000..b41fcb620
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.D3D
@@ -0,0 +1,124 @@
+
+ DirectX 6 Driver for Mesa 3.0
+
+
+This software is distributed under the terms of the GNU Library
+General Public License, see the LICENSE file for details.
+
+
+
+What do you need ?
+------------------
+
+ - A PC with a DirectX 6 video driver installed.
+
+ - Mesa 3.0
+
+ - The 3Dfx Glide library 2.3 or later for your OS (the 2.4 works fine).
+ The Voodoo2 requires the Glide library 2.51. The Glide 3.0 is not
+ compatible with the Glide 2.x so it doesn't work with the current
+ version of the driver;
+
+ - Visual C++ 5.0 is only compiler test but others should be ok with
+ changes to the makefiles (CFLAGS/LFLAGS).
+
+ - DirectX 6 SDK (was a MS download but not sure if still available).
+
+ - SoftIce or another debugger that will get DPF's is nice.
+
+
+Tested on:
+----------
+ Windows 95
+ Windows 98
+ Windows NT 5.0 (beta 2)
+
+
+What is able to do ?
+--------------------
+
+ - the driver will try and use DirectX to rasterize the OpenGL primitives
+ that are sent to the driver. The driver will fall back to SW if the rendering
+ context is too big. The fallback to SW still uses DirectDraw. If the driver
+ fails to support and operation (accum, stencil, etc) then it will try and get
+ Mesa to render it in SW. DirectX 6 features that are unsupported by the
+ installed DirectX 6 driver will be mapped to some other best fit feature.
+
+
+How to compile:
+---------------
+
+ These instructions assume you have Visual C++ installed.
+
+ You might need to increase you enviroment space. You can do this by
+ adding the following statement to you config.sys.
+
+ shell=C:\COMMAND.COM C:\ /p /e:8198
+
+ Next setup you compiler enviroment by running vcvars32.bat in the Visual C++
+ 'bin' directoy.
+
+ c:\DevStudio\VC\bin\vcvars32.bat
+
+ Modify the D3D makefile to point at your SDK install. Example has the SDK
+ installed on my 'f' drive in the root.
+
+ file: \Mesa-3.0\src\makefile.d3d
+
+ SDKROOT=f:\mssdk
+
+ Now you can simply make the project. If you look in the makefile you can see
+ I have some different targets like 'install'.
+
+ nmake /f makefile.d3d
+
+
+FAQ:
+----
+
+ 1) I don't think the driver is using my DirectX driver.
+
+ This maybe true as the current version will only select the Primary D3D driver
+ installed. If you 3D card is the secondary (3dfx) then your out of luck for this
+ release.
+
+ 2) The driver seems like its not HW accelerated.
+
+ If you have a video card with limited memory then you might want to try and
+ change your destop resolution to a low setting (640x480x16) so that the 3D part
+ of the card has more resources. Remeber the driver can't make the card better...
+
+ 3) Nothing works.
+
+ Make sure you have a DirectX '6' driver installed. Check you driver docs for this
+ info or use the SDK info utilities.
+ The final 'dll' is named opengl32.dll and is either in the same directory as the
+ OpenGL program or in your system directory (x:\windows\system or x:\winnt\system32).
+ Check your destop resolution. Most DirectX 6 drivers will only support 16bit and
+ 32bit color depth. To find out for sure you can check the DirectX Info Viewer in
+ the SDK.
+
+
+ 4) Rendering doesn't look right.
+
+ Sometimes this is because the card doesn't support a feature that that is required.
+ This is usually due to unsupported alpha functions (test/blend) or texture mapping.
+ Some cards suffer from too small of an alpha channel. The driver does its best to
+ fallback on unsupported features. This is not to say the driver may not have a bug(s).
+
+ 5) Textures look bad.
+
+ No mipmapping in this release.
+
+
+Thanks to:
+----------
+
+Brian Paul
+
+
+
+
+Leigh McRae (leigh@altsoftware.com)
+February 9, 1999
+
diff --git a/nx-X11/extras/Mesa/docs/README.DJ b/nx-X11/extras/Mesa/docs/README.DJ
new file mode 100644
index 000000000..7180223c2
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.DJ
@@ -0,0 +1,275 @@
+ Mesa 6.3 DOS/DJGPP Port v1.7
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+
+
+Description:
+~~~~~~~~~~~~
+
+Well, guess what... this is the DOS port of Mesa 6.3, for DJGPP fans... Whoa!
+The driver has its origins in ddsample.c, written by Brian Paul and found by me
+in Mesa 3.4.2.
+
+
+
+Legal:
+~~~~~~
+
+Mesa copyright applies, provided this package is used within Mesa. For anything
+else, see GPL.
+
+
+
+Installation:
+~~~~~~~~~~~~~
+
+Unzip and type:
+
+ make -f Makefile.DJ [OPTIONS...]
+
+Available options:
+
+ Environment variables:
+ CPU optimize for the given processor.
+ default = pentium
+ GLU=[mesa|sgi] specify GLU directory; can be `sgi' (requires GNU/C++)
+ or `mesa'.
+ default = mesa
+ GLIDE path to Glide3 SDK; used with FX.
+ default = $(TOP)/glide3
+ FX=1 build for 3dfx Glide3. Note that this disables
+ compilation of most DMesa code and requires fxMesa.
+ As a consequence, you'll need the DJGPP Glide3
+ library to build any application.
+ default = no
+ X86=1 optimize for x86 (if possible, use MMX, SSE, 3DNow).
+ default = no
+
+ Targets:
+ all: build everything
+ libgl: build GL
+ libglu: build GLU
+ libglut: build GLUT
+ clean: remove object files
+ realclean: remove all generated files
+
+
+
+Tested on:
+ CPU: AMD Athlon XP 1800+
+ Mainboard: GA-7VTXE w/ 512 MB DDRAM
+ Video card: Voodoo5 6000 AGP w/ 128 MB SDRAM
+ DJGPP: djdev 2.04 + gcc v3.4.3 + make v3.80
+ OS: DOS and Win98SE
+
+
+
+FAQ:
+~~~~
+
+1. Compilation
+
+ Q) `make' barfs and exits because it cannot find some stupid file.
+ A) You need LFN support.
+ A) When compiling for Glide (FX=1), pay attention to Glide path.
+
+ Q) Libraries built OK, but linker complains about `vsnprintf' every time I
+ compile some demo.
+ A) Upgrade to DJGPP 2.04.
+ A) Add `vsnprintf.c' to the CORE_SOURCES in `src/Makefile.DJ' (untested!).
+ A) Patch `src/mesa/main/imports.c' with the following line:
+ #define vsnprintf(buf, max, fmt, arg) vsprintf(buf, fmt, arg)
+ This hack should be safe in 90% of the cases, but if anything goes wrong,
+ don't come back to me crying.
+
+ Q) `make' complains about DXE3 or something, yet it builds the libraries.
+ A) DXE3 refers to the DJGPP dynamic modules. You'll need either the latest
+ DJGPP distro, or download the separate package from my web page. Read the
+ DXE3 documentation on how to use them.
+ A) When compiling for Glide (FX=1), make sure `glide3x.dxe' can be found in
+ LD_LIBRARY_PATH (or top `lib' directory).
+
+2. Using Mesa for DJGPP
+
+ Q) Every test I tried crashes badly.
+ A) If you have compiled with SSE and you're running under plain DOS, you
+ have to disable SSE at run-time. See environment variables below.
+
+ Q) DMesa is so SLOOOW! The Win32 OpenGL performs so much better...
+ A) Is that a question? If you have a 3dfx Voodoo (any model), you're
+ lucky (check http://sourceforge.net/projects/glide for the DJGPP port).
+ If you haven't, sorry; everything is done in software. Suggestions?
+
+ Q) I tried to set refresh rate w/ DMesa, but without success.
+ A) Refresh rate control works only for VESA 3.0 and the 3dfx driver (in
+ which case FX_GLIDE_REFRESH will be overwritten if it is defined and
+ is not 0).
+
+ Q) I made a simple application and it does nothing. It exits right away. Not
+ even a blank screen.
+ A) Pure software drivers (VESA/VGA/NUL) support only double-buffered modes.
+ A) Another weird "feature" is that buffer width must be multiple of 8 (I'm a
+ lazy programmer and I found that the easiest way to keep buffer handling
+ at peak performance ;-).
+
+ Q) I'm getting a "bad font!" fatal error.
+ A) Always use GLUT_STROKE_* and GLUT_BITMAP_* constants when dealing with
+ GLUT fonts. If you're using `glut.dxe', then make sure GLUT_STROKE_* and
+ GLUT_BITMAP_* are mapped to integer constants, not to the actual font
+ address (same mechanism used for Win32 _DLL).
+
+ Q) What is NUL driver good for, if I don't get any output at all?
+ A) For debugging. The NUL driver is very much like OSMesa. Everything is
+ done just the same as VESA/VGA drivers, only it doesn't touch your video
+ hardware. You can query the actual buffer by issuing:
+ DMesaGetIntegerv(DMESA_GET_BUFFER_ADDR, &buffer);
+ and dump it to a file.
+
+ Q) How do I query for a list of available video modes to choose as a visual?
+ A) This is an ugly hack, for which I'm sure I'll burn in hell.
+ First, query for a list of modes:
+ n = DMesaGetIntegerv(DMESA_GET_VIDEO_MODES, NULL);
+ If `n' is strictly positive, you allocate an array of pointers to a given
+ struct (which is guaranteed to be extended only - not changed in future):
+ struct {
+ int xres, yres;
+ int bpp;
+ } **l = malloc(n * sizeof(void *));
+ Now pass the newly allocated buffer to fill in:
+ DMesaGetIntegerv(DMESA_GET_VIDEO_MODES, (GLint *)l);
+ And collect the info:
+ for (i = 0; i < n; i++) {
+ printf("%dx%d:%d\n", l[i]->xres, l[i]->yres, l[i]->bpp);
+ }
+
+ Q) The GLUT is incomplete.
+ A) See below.
+
+
+
+libGLUT (the toolkit):
+~~~~~~~~~~~~~~~~~~~~~~
+
+Well, this "skeletal" GLUT implementation was taken from AllegGL project and
+heavily changed. Thanks should go to Bernhard Tschirren, Mark Kilgard, Brian
+Paul and probably others (or probably not ;-). GLUT functionality will be
+extended only on an "as needed" basis.
+
+GLUT talks to hardware via PC_HW package which was put together from various
+pieces I wrote long time ago. It consists from the keyboard, mouse and timer
+drivers.
+
+My keyboard driver used only scancodes; as GLUT requires ASCII values for keys,
+I borrowed the translation tables (and maybe more) from Allegro -- many thanks
+to Shawn Hargreaves et co. Ctrl-Alt-Del (plus Ctrl-Alt-End, for Windows users)
+will shut down the GLUT engine unconditionally: it will raise SIGINT, which in
+turn will (hopefully) call the destructors, thus cleaning up your/my mess ;-)
+NB: since the DJGPP guys ensured signal handlers won't go beyond program's
+space (and since dynamic modules shall) the SIGINT can't be hooked (well, it
+can, but it is useless), therefore you must live with the 'Exiting due to
+signal SIGINT' message...
+
+The mouse driver is far from complete (lack of drawing, etc), but is enough to
+make almost all the demos work. Supports the CuteMouse WheelAPI.
+
+The timer is pretty versatile for it supports multiple timers with different
+frequencies. While not being the most accurate timer in the known universe, I
+think it's OK. Take this example: you have timer A with a very high rate, and
+then you have timer B with very low rate compared to A; now, A ticks OK, but
+timer B will probably loose precision!
+
+As an addition, stdout and stderr are redirected and dumped upon exit. This
+means that `printf' can be safely called during graphics. A bit of a hack, I
+know, because all messages come in bulk, but I think it's better than nothing.
+"Borrowed" from LIBRHUTI (Robert Hoehne).
+
+Window creating defaults: (0, 0, 300, 300), 16bpp. However, the video mode is
+chosen in such a way that first window will fit. If you need high resolution
+with small windows, set initial position far to the right (or way down); then
+you can move them back to any position right before the main loop.
+
+
+
+Environment variables:
+~~~~~~~~~~~~~~~~~~~~~~
+ DMESA_NULDRV - (any value) force NUL driver
+ GLUT_FPS - print frames/second statistics to stderr
+ MESA_NO_SSE - (any value) safe option under pure DOS
+ DMESA_GLUT_REFRESH - set vertical screen refresh rate (VESA3)
+ DMESA_GLUT_BPP - set default bits per pixel (VGA needs 8)
+ DMESA_GLUT_ALPHA - set default alpha bits (8)
+ DMESA_GLUT_DEPTH - set default depth bits (16)
+ DMESA_GLUT_STENCIL - set default stencil bits (8)
+ DMESA_GLUT_ACCUM - set default accum bits (16)
+
+
+
+History:
+~~~~~~~~
+
+v1.0 (mar-2002)
+ initial release
+
+v1.1 (sep-2002)
+ + added 3dfx Glide3 support
+ + added refresh rate control
+ + added fonts in GLUT
+ * lots of minor changes
+
+v1.2 (nov-2002)
+ * synced w/ Mesa-4.1
+ - removed dmesadxe.h
+
+v1.3 (mar-2003)
+ + enabled OpenGL 1.4 support
+ + added MMX clear/blit routines
+ + enabled SGI's GLU compilation
+ + added samples makefile
+ + added new GLUT functions
+ + added color-index modes
+ + added Matrox Millennium MGA2064W driver
+ + added 8bit FakeColor (thanks to Neil Funk)
+ + added VGA support (to keep Ben Decker happy)
+ ! fixed some compilation errors (reported by Chan Kar Heng)
+ * optimized driver for faster callback access... yeah, right :)
+ * overhauled virtual buffer and internal video drivers
+ * better fxMesa integration
+ * revamped GLUT
+ * switched to DXE3
+
+v1.4 (dec-2003)
+ + enabled GLUT fonts with DXE
+ + truly added multi-window support in GLUT (for Adrian Woodward)
+ * accomodated makefiles with the new sourcetree
+ * fixed some ALPHA issues
+ * minor changes to PC_HW/timer interface
+ x hacked and slashed the 3dfx driver (w/ help from Hiroshi Morii)
+
+v1.5 (jan-2004)
+ + added interface to query available "visuals" (GLFW - Marcus Geelnard)
+ + added GLUT timer callback
+ - removed Matrox Millennium MGA2064W driver
+ x more changes to the 3dfx driver
+
+v1.6 (aug-2004)
+ + implemented NUL driver
+ + added DMesaGetProcAddress and glutGetProcAddress
+ * reorganized fxMesa wrapper to handle multiple contexts
+ ! fixed a horrible bug in VGA initialization routine
+ ! fixed partial clears
+
+v1.7 (???-2005)
+ + enabled OpenGL 2.0 support
+ + added support for sw texture compression
+ + added FreeGLUT specific functions
+ * no more GLX sources in DOS GLUT
+ * made GLUT timer callbacks less accurate but safer
+
+
+
+Contact:
+~~~~~~~~
+
+Name: Daniel Borca
+E-mail: dborca@users.sourceforge.net
+WWW: http://www.geocities.com/dborca/
diff --git a/nx-X11/extras/Mesa/docs/README.GGI b/nx-X11/extras/Mesa/docs/README.GGI
new file mode 100644
index 000000000..ddb67725f
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.GGI
@@ -0,0 +1,26 @@
+GGIMesa for LibGGI 2.x
+
+Requirements:
+-------------
+LibGGI 2.0 or greater
+
+Installation:
+-------------
+To install GGIMesa, follow the instructions in INSTALL.GNU. If you
+wish to install GGIGLUT as well, first install GGIMesa and then run
+
+make
+make install (must be root)
+
+in ggi/ggiglut.
+
+Notes:
+------
+
+* Set the environment variables GGIMESA_DEBUG and/or GGIGLUT_DEBUG
+to 255 to see lots of debugging output.
+
+* GGIGLUT contains support for all of the GLUT 3.6 API except for the
+high-level primitive drawing functions, but many of the functions (in
+particular the menu drawing functions) are just stubs.
+
diff --git a/nx-X11/extras/Mesa/docs/README.LYNXOS b/nx-X11/extras/Mesa/docs/README.LYNXOS
new file mode 100644
index 000000000..e3ab9804b
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.LYNXOS
@@ -0,0 +1,64 @@
+
+Mesa 3.0 for LynxOS builds in the following way:
+
+make lynxos
+
+This will build all the libraries and demo applications. You should have
+around 400 megabytes free for everything since everything is done with
+static
+libraries.
+
+Before using this make file however, you should perform the following
+actions:
+0) cd to the Mesa-3.0 directory
+1) Copy the GL directory under the include directory to /usr/include.
+2) Copy the files in the lib directory to /lib.
+3) Make links so that the Mesa libraries look like ordinary OpenGL
+libraries
+in /lib. This is important for compatibility with other OpenGL apps. This
+is done as follows:
+
+cd /lib
+ln -s libMesaGL.a libGL.a
+ln -s libMesaGLU.a libGLU.a
+
+Mesa 3.0 includes the GLUT (GL Utility Toolkit) by default.
+The demo applications are done using this toolkit.
+
+Mesa makefiles for building their apps could be used as well, but the
+following one is much more concise. Note that the order of the X libraries
+is important to the linker so that all symbols get resolved correctly.
+Changing the order may result in having to list a library twice to make
+sure all linkages are made correctly.
+
+----cut here for Makefile -----
+
+FILES = your_app.x
+
+SPECIAL_INCLUDES = -I/usr/include/GL
+
+SPECIAL_CFLAGS = -g -ansi -pedantic -funroll-loops -ffast-math -DSHM
+
+SPECIAL_LIBS = -lglut -lGLU -lGL -lm -L/usr/X11/lib -lXext -lXmu -lXi \
+-lX11 -lbsd -g
+
+STANDARD_OFILES = $(FILES:.x=.o)
+
+%.o: %.c
+ gcc -c $(SPECIAL_CFLAGS) $(SPECIAL_INCLUDES) $< -o $@
+
+all: $(STANDARD_OFILES)
+ gcc -o your_app $(STANDARD_OFILES) $(SPECIAL_LIBS)
+
+
+----cut here for Makefile-----
+
+I have tested Mesa under LynxOS 3.0 and 3.01. It should build fine under
+other
+versions as well. Note, however, that LynxOS versions prior to 3.0 are not
+binary compatible, so you will have to rebuild from source.
+
+
+Vik Sohal
+vik@lynx.com
+January 13, 1999
diff --git a/nx-X11/extras/Mesa/docs/README.MINGW32 b/nx-X11/extras/Mesa/docs/README.MINGW32
new file mode 100644
index 000000000..2b39f1209
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.MINGW32
@@ -0,0 +1,90 @@
+ Mesa 6.1 for MinGW32
+ ~~~~~~~~~~~~~~~~~~~~
+
+
+
+Quick & dirty start:
+--------------------
+
+ mingw32-make -f Makefile.mgw [OPTIONS...]
+
+ Look into the corresponding makefiles for further information.
+ Check README.3DFX to find out how to compile Mesa Glide3 driver
+ with MinGW32!
+
+
+
+*******************************************************************************
+The Mingw port for Mesa 3-D Graphics Library was created August 30, 1998 by Paul Garceau.
+
+Updated January 13, 2000; June 3, 2005 -- Paul Garceau <pgarceau@users.sourceforge.net>
+
+DISCLAIMER: I make this port of the Mesa 3-D Graphics Library as a service
+to the general public. I can, in no way support or make any guarantee that the
+build will work for your system.
+
+Acknowledgements:
+
+ Daniel Borca, whose work and commitment to maintaining the Mingw port of the Mesa 3-D Graphics Library has been, and will continue to be greatly appreciated by an overworked and underpaid developer such as myself.
+ Without the creative inspiration and personal commitment provided by Mumit Khan, Jan-Jaap Vanderhagen and Colin Peters, Mingw would never have existed. Acknowledgements also need to be given to all of the developers who have worked on Mingw, Mesa and Msys over the years.
+ Last, but certainly far from the least, Brian Paul, who has dedicated at least the last seven or eight years of his life to making Mesa 3-D Graphics Library what it is today and managing the development for all of those years.
+*********************************************************************************
+
+Greetings,
+
+ Feel free to modify or change things related to the Mingw build as you see fit, just remember that, the author of the current build may not be able to support any modifications you might want to make to the files which have been included for the build.
+
+Mesa core components are licensed under XFree-86 (for more on licensing of Mesa 3-D Graphics Library, check out the Mesa homepage (http://www.mesa3d.org).
+
+The Mingw generated libraries themselves are licensed under the GNU-LGPL license. Source code for Mingw can be found at http://www.mingw.org. For licensing terms on Mingw, please visit http://www.mingw.org.
+
+ It is recommended that you use the latest "stable" release of Mingw. "Candidates" are beta testing distributions for Mingw. Mingw is available at http://www.mingw.org.
+
+ This build has been tested under WinNT4/SP6. Win9x and WinNT5 remain untested by me. I have not tested any of the demos included with Mesa3d.
+
+Installation:
+
+ This readme assumes that you already have extracted the necessary files to a working directory/folder that Mingw can use to build the Mesa3D libraries and that you know where that directory/folder is located on your Windows system. If you have any questions about how to set things up properly which is specific to Mesa3D, the folks on the Mesa3D mailing lists (http://www.mesa3d.org) would probably be happy to assist you. Also you can probably ask anyone on the Mingw mailing lists for any questions specific to Mingw (http://www.mingw.org)
+
+Targets and Environment variables used for Mingw build:
+
+ Before going into the actual build of the libraries, here is a list of available targets for the make process:
+
+ "all" or "libgl" -- this target will build libopengl.a, a static library. It will not build the demos, etc.
+
+ clean -- this target will clean up most of the Mesa 3-D Graphics Library/object code from your hard drive.
+
+ realclean -- this target will clean up all of the Mesa 3D Graphics Library and the Mesa object code that it can find.
+
+ Environment Variables:
+
+ The environment variables are used to determine what sort of graphics driver support needs to be included in the finished Mesa 3-D Graphics Library.
+
+ GLIDE path to Glide3 SDK; used with FX.
+ default = $(TOP)/glide3
+ FX=1 build for 3dfx Glide3. Note that this disables
+ compilation of most WMesa code and requires fxMesa.
+ As a consequence, you'll need the Win32 Glide3
+ library to build any application.
+ default = no
+ ICD=1 build the installable client driver interface
+ (windows opengl driver interface)
+ default = no
+ X86=1 optimize for x86 (if possible, use MMX, SSE, 3DNow).
+ default = no
+
+
+Running the Build:
+
+ Launch Mingw.
+ From the Windows Command Prompt:
+ Set Environment Variables (as needed).
+ "cd" to your Mesa3D 'root' directory.
+ Enter "mingw32-make -f makefile.mgw <target>
+
+ That's all there is to it.
+
+ Enjoy!
+
+ Paul G. <pgarceau@users.sourceforge.net>
+ Daniel Borca <dborca@users.sourceforge.net>
diff --git a/nx-X11/extras/Mesa/docs/README.MITS b/nx-X11/extras/Mesa/docs/README.MITS
new file mode 100644
index 000000000..a89176a62
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.MITS
@@ -0,0 +1,102 @@
+
+ Mesa 3.0 MITS Information
+
+
+This software is distributed under the terms of the GNU Library
+General Public License, see the LICENSE file for details.
+
+
+This document is a preliminary introduction to help you get
+started. For more detaile information consult the web page.
+
+http://10-dencies.zkm.de/~mesa/
+
+
+
+Version 0.1 (Yes it's very alpha code so be warned!)
+Contributors:
+ Emil Briggs (briggs@bucky.physics.ncsu.edu)
+ David Bucciarelli (tech.hmw@plus.it)
+ Andreas Schiffler (schiffler@zkm.de)
+
+
+
+1. Requirements:
+ Mesa 3.0.
+ An SMP capable machine running Linux 2.x
+ libpthread installed on your machine.
+
+
+2. What does MITS stand for?
+ MITS stands for Mesa Internal Threading System. By adding
+ internal threading to Mesa it should be possible to improve
+ performance of OpenGL applications on SMP machines.
+
+
+3. Do applications have to be recoded to take advantage of MITS?
+ No. The threading is internal to Mesa and transparent to
+ applications.
+
+
+4. Will all applications benefit from the current implementation of MITS?
+ No. This implementation splits the processing of the vertex buffer
+ over two threads. There is a certain amount of overhead involved
+ with the thread synchronization and if there is not enough work
+ to be done the extra overhead outweighs any speedup from using
+ dual processors. You will not for example see any speedup when
+ running Quake because it uses GL_POLYGON and there is only one
+ polygon for each vertex buffer processed. Test results on a
+ dual 200 Mhz. Pentium Pro system show that one needs around
+ 100-200 vertices in the vertex buffer before any there is any
+ appreciable benefit from the threading.
+
+
+5. Are there any parameters that I can tune to try to improve performance.
+ Yes. You can try to vary the size of the vertex buffer which is
+ define in VB_MAX located in the file src/vb.h from your top level
+ Mesa distribution. The number needs to be a multiple of 12 and
+ the optimum value will probably depend on the capabilities of
+ your machine and the particular application you are running.
+
+
+6. Are there any ways I can modify the application to improve its
+ performance with the MITS?
+ Yes. Try to use as many vertices between each Begin/End pair
+ as possbile. This will reduce the thread synchronization
+ overhead.
+
+
+7. What sort of speedups can I expect?
+ On some benchmarks performance gains of up to 30% have been
+ observerd. Others may see no gain at all and in a few rare
+ cases even some degradation.
+
+
+8. What still needs to be done?
+ Lots of testing and benchmarking.
+ A portable implementation that works within the Mesa thread API.
+ Threading of additional areas of Mesa to improve performance
+ even more.
+
+
+
+Installation:
+
+ 1. This assumes that you already have a working Mesa 3.0 installation
+ from source.
+ 2. Place the tarball MITS.tar.gz in your top level Mesa directory.
+ 3. Unzip it and untar it. It will replace the following files in
+ your Mesa source tree so back them up if you want to save them.
+
+
+ README.MITS
+ Make-config
+ Makefile
+ mklib.glide
+ src/vbxform.c
+ src/vb.h
+
+ 4. Rebuild Mesa using the command
+
+ make linux-386-glide-mits
+
diff --git a/nx-X11/extras/Mesa/docs/README.NeXT b/nx-X11/extras/Mesa/docs/README.NeXT
new file mode 100644
index 000000000..1ad9a9e5c
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.NeXT
@@ -0,0 +1,6 @@
+The NeXT support has now been incorporated into the OpenStep support.
+You can build NeXT libraries simply by typing "make next", though before
+linking they will need to be ranlib'd by hand. For more information see
+the README.OpenStep file, together with the README files in OpenStep/Old_Demos.
+
+-Pete French. (pete@ohm.york.ac.uk) 28/5/1998
diff --git a/nx-X11/extras/Mesa/docs/README.OS2 b/nx-X11/extras/Mesa/docs/README.OS2
new file mode 100644
index 000000000..b3374ea23
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.OS2
@@ -0,0 +1,96 @@
+ README for port of Mesa 3.x to XFree86 on OS/2 (X/2)
+ (as of 19990514)
+
+
+ Contents:
+
+ 1) Binary release
+ 2) Building from sources
+ 3) History
+ 4) Todo
+ 5) Mesa Home Page
+
+
+1) Binary release
+
+ Though the Mesa sources should build in a quite reasonable time even on
+ a 585 class machine a binary relase is available (check topic 4) for an URL)
+ This package includes:
+
+ - lib/MesaGL.dll, MesaGL.a
+ - lib/MesaGLU.dll, MesaGLU.a
+ - lib/glut.dll, glut.a
+ - include/GL/*.h
+
+ Installing this in your XFree86 tree will enable you to build and
+ run all applications compatible with Mesa (and the current DLL
+ interface, of course ;-)
+ As usual the OMF-style libraries can be created using emxomf.
+ (e.g. "emxomf foo.a" creates the foo.lib omf-style library).
+ The static libraries are rarely used and you have to rebuild
+ Mesa to get them. They're a supported target, so you get
+ them in a straightforward way (see below).
+
+ The testing of these libraries was limited to the supplied
+ demos/examples and a quite small number of third-party apps.
+ No warranty ... as usual ... ;-)
+
+
+2) Instructions to build Mesa 3.x for XFree86/OS2 from sources:
+
+ Except the official Mesa source distribution you need:
+ - a recent version of XFree86 (3.3.x or above) including
+ the programming libraries
+ - EMX 0.9c (0.9d might work, never checked)
+ - GNU make
+ - REXX (!)
+
+ The creation of the DLLs as well as of the static libraries
+ (if you want to have them) is handled in "mklib-emx.cmd",
+ a small REXX script. Perhaps not the best idea, but this
+ way it fits best in the scheme used to build libraries
+ on all platforms in Mesa 3.x.
+
+ To actually build the libraries and demos, check mklib-emx.cmd
+ and modify it as desired. Then type
+ make os2-x11
+ and wait for completion ;-)
+
+
+3) History
+
+ Initially Darren Abbott (abbott@hiwaay.net) ported Mesa versions 2.x
+ to XFree86 OS/2. This port might still be available from
+ http://fly.HiWAAY.net/~abbott/xfree86-os2/xfree86.html
+
+ The current port picked up things during the beta test for 3.0.
+ No major changes in the source were done. The build mechanism under OS/2
+ has been made very similar to other platforms (if you treat mklib-emx.cmd
+ as a "black box").
+ Advantage is that X/2 is now a valid target and all files are
+ integrated in the official source distribution.
+ Disadvantage is that this port (i.e. the DLLs' interface itself) is
+ definitly NOT COMPATIBLE to those of version 2.x.
+ It's uncertain whether this would be at all possible but since there
+ a _very_ few those apps it's not worth to find out anyway.
+ Also some libs (MesaTK, MesaAUX) are withdrawn from the Mesa distribution,
+ and accordingly from the OS/2 port.
+
+4) Todo
+
+ By now binary compatiblity is ensured by using the function names
+ as entry points instead of ordinals. This might cost performance and
+ is subject to change in future. In addition the supplied X86 assembler
+ source is not used yet.
+
+5) Mesa Home Page
+
+ You can get the source code and more information about Mesa from
+ http://www.mesa3d.org/
+
+ The OS/2 ports should be available from
+ http://r350.ee.ntu.edu.tw/~hcchu/os2/ports
+
+--
+Alexander Mai
+st002279@hrzpub.tu-darmstadt.de
diff --git a/nx-X11/extras/Mesa/docs/README.OpenStep b/nx-X11/extras/Mesa/docs/README.OpenStep
new file mode 100644
index 000000000..a566eca67
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.OpenStep
@@ -0,0 +1,35 @@
+This is a port of the GL and GLU libraries to NeXT/Apple object
+orientated systems. As these systems have their own window handling
+systems we simply use the offscreen rendering capability of Mesa
+to generate bitmaps which may then be displayed by the application
+with a View as required. Example pieces of code may be found in the
+OpenStep directory.
+
+Sadly there are now a proliferation of different system that we need to
+support compilation for: The original NextStep system, The OpenStep
+system, the Rhapsody/Mac OS X system and also the windows implementations
+of the latter two systems. This version of the code has been compiled and
+tested under the following architectures:
+
+ NextStep 3.3
+ OpenStep 4.2
+ Rhapsody DR2
+ WebObjects for NT 3.5
+ WebObjects for NT 4.0
+
+All tests were done with Intel processors. Feedback on other systems would,
+however, be appreciated !
+
+On UNIX systems simply type "make openstep". Under Windows systems
+with WebObjects run the "win32-openstep.sh" script from within the Bourne
+shell provided with the development environment. In both cases this will
+build the libraries and place them into the "lib" directory. Some examples
+may be found in the OpenStep directory showing how to use the code in an
+actual application (MesaView) as well as some command line demos.
+
+The CC variable may be specified on the command line for doing such things
+as building FFAT libraries or using alternative compilers to the standard 'cc'
+e.g. make CC='cc -arch m68k -arch i386' openstep" will build the libraries
+with both intel and motorola architectures.
+
+-Pete French. (pete@ohm.york.ac.uk) 7/6/1999
diff --git a/nx-X11/extras/Mesa/docs/README.QUAKE b/nx-X11/extras/Mesa/docs/README.QUAKE
new file mode 100644
index 000000000..729c0e514
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.QUAKE
@@ -0,0 +1,208 @@
+
+ Info on using Mesa 3.0 with Linux Quake I and Quake II
+
+
+
+Disclaimer
+----------
+
+I am _not_ a Quake expert by any means. I pretty much only run it to
+test Mesa. There have been a lot of questions about Linux Quake and
+Mesa so I'm trying to provide some useful info here. If this file
+doesn't help you then you should look elsewhere for help. The Mesa
+mailing list or the news://news.3dfx.com/3dfx.linux.glide newsgroup
+might be good.
+
+Again, all the information I have is in this file. Please don't email
+me with questions.
+
+If you have information to contribute to this file please send it to
+me at brianp@elastic.avid.com
+
+
+
+Linux Quake
+-----------
+
+You can get Linux Quake from http://www.idsoftware.com/
+
+Quake I and II for Linux were tested with, and include, Mesa 2.6. You
+shouldn't have too many problems if you simply follow the instructions
+in the Quake distribution.
+
+
+
+RedHat 5.0 Linux problems
+-------------------------
+
+RedHat Linux 5.x uses the GNU C library ("glibc" or "libc6") whereas
+previous RedHat and other Linux distributions use "libc5" for its
+runtime C library.
+
+Linux Quake I and II were compiled for libc5. If you compile Mesa
+on a RedHat 5.x system the resulting libMesaGL.so file will not work
+with Linux Quake because of the different C runtime libraries.
+The symptom of this is a segmentation fault soon after starting Quake.
+
+If you want to use a newer version of Mesa (like 3.x) with Quake on
+RedHat 5.x then read on.
+
+The solution to the C library problem is to force Mesa to use libc5.
+libc5 is in /usr/i486-linux-libc5/lib on RedHat 5.x systems.
+
+Emil Briggs (briggs@tick.physics.ncsu.edu) nicely gave me the following
+info:
+
+> I only know what works on a RedHat 5.0 distribution. RH5 includes
+> a full set of libraries for both libc5 and glibc. The loader ld.so
+> uses the libc5 libraries in /usr/i486-linux-libc5/lib for programs
+> linked against libc5 while it uses the glibc libraries in /lib and
+> /usr/lib for programs linked against glibc.
+>
+> Anyway I changed line 41 of mklib.glide to
+> GLIDELIBS="-L/usr/local/glide/lib -lglide2x -L/usr/i486-linux-libc5/lib"
+>
+> And I started quake2 up with a script like this
+> #!/bin/csh
+> setenv LD_LIBRARY_PATH /usr/i486-linux-libc5/lib
+> setenv MESA_GLX_FX f
+> ./quake2 +set vid_ref gl
+> kbd_mode -a
+> reset
+
+
+I've already patched the mklib.glide file. You'll have to start Quake
+with the script shown above though.
+
+
+
+**********************
+
+Daryll Strauss writes:
+
+Here's my thoughts on the problem. On a RH 5.x system, you can NOT build
+a libc5 executable or library. Red Hat just doesn't include the right
+stuff to do it.
+
+Since Quake is a libc5 based application, you are in trouble. You need
+libc5 libraries.
+
+What can you do about it? Well there's a package called gcc5 that does
+MOST of the right stuff to compile with libc5. (It brings back older
+header files, makes appropriate symbolic links for libraries, and sets
+up the compiler to use the correct directories) You can find gcc5 here:
+ftp://ecg.mit.edu/pub/linux/gcc5-1.0-1.i386.rpm
+
+No, this isn't quite enough. There are still a few tricks to getting
+Mesa to compile as a libc5 application. First you have to make sure that
+every compile uses gcc5 instead of gcc. Second, in some cases the link
+line actually lists -L/usr/lib which breaks gcc5 (because it forces you
+to use the glibc version of things)
+
+If you get all the stuff correctly compiled with gcc5 it should work.
+I've run Mesa 3.0B6 and its demos in a window with my Rush on a Red Hat
+5.1 system. It is a big hassle, but it can be done. I've only made Quake
+segfault, but I think that's from my libRush using the wrong libc.
+
+Yes, mixing libc5 and glibc is a major pain. I've been working to get
+all my libraries compiling correctly with this setup. Someone should
+make an RPM out of it and feed changes back to Brian once they get it
+all working. If no one else has done so by the time I get the rest of my
+stuff straightened out, I'll try to do it myself.
+
+ - |Daryll
+
+
+
+*********************
+
+David Bucciarelli (tech.hmw@plus.it) writes:
+
+I'm using the Mesa-3.0beta7 and the RedHat 5.1 and QuakeII is
+working fine for me. I had only to make a small change to the
+Mesa-3.0/mklib.glide file, from:
+
+
+ GLIDELIBS="-L/usr/local/glide/lib -lglide2x
+-L/usr/i486-linux-libc5/lib -lm"
+
+to:
+
+ GLIDELIBS="-L/usr/i486-linux-libc5/lib -lglide2x"
+
+and to make two symbolic links:
+
+[david@localhost Mesa]$ ln -s libMesaGL.so libMesaGL.so.2
+[david@localhost Mesa]$ ln -s libMesaGLU.so libMesaGLU.so.2
+
+I'm using the Daryll's Linux glide rpm for the Voodoo2 and glibc (it
+includes also the Glide for the libc5). I'm not using the /dev/3Dfx and
+running QuakeII as root with the following env. var:
+
+export
+LD_LIBRARY_PATH=/dsk1/home/david/src/gl/Mesa/lib:/usr/i486-linux-libc5/lib
+
+I think that all problems are related to the glibc, Quake will never
+work if you get the following output:
+
+[david@localhost Mesa]$ ldd lib/libMesaGL.so
+ libglide2x.so => /usr/lib/libglide2x.so (0x400f8000)
+ libm.so.6 => /lib/libm.so.6 (0x40244000)
+ libc.so.6 => /lib/libc.so.6 (0x4025d000)
+ /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00000000)
+
+You must get the following outputs:
+
+[david@localhost Mesa]# ldd lib/libMesaGL.so
+ libglide2x.so => /usr/i486-linux-libc5/lib/libglide2x.so
+(0x400f3000)
+
+[root@localhost quake2]# ldd quake2
+ libdl.so.1 => /lib/libdl.so.1 (0x40005000)
+ libm.so.5 => /usr/i486-linux-libc5/lib/libm.so.5 (0x40008000)
+ libc.so.5 => /usr/i486-linux-libc5/lib/libc.so.5 (0x40010000)
+
+[root@localhost quake2]# ldd ref_gl.so
+ libMesaGL.so.2 =>
+/dsk1/home/david/src/gl/Mesa/lib/libMesaGL.so.2 (0x400eb000)
+ libglide2x.so => /usr/i486-linux-libc5/lib/libglide2x.so
+(0x401d9000)
+ libX11.so.6 => /usr/i486-linux-libc5/lib/libX11.so.6
+(0x40324000)
+ libXext.so.6 => /usr/i486-linux-libc5/lib/libXext.so.6
+(0x403b7000)
+ libvga.so.1 => /usr/i486-linux-libc5/lib/libvga.so.1
+(0x403c1000)
+ libm.so.5 => /usr/i486-linux-libc5/lib/libm.so.5 (0x403f5000)
+ libc.so.5 => /usr/i486-linux-libc5/lib/libc.so.5 (0x403fd000)
+
+
+***********************
+
+Steve Davies (steve@one47.demon.co.uk) writes:
+
+
+Try using:
+
+ export LD_LIBRARY_PATH=/usr/i486-linux-libc5/lib
+ ./quake2 +set vid_ref gl
+
+to start the game... Works for me, but assumes that you have the
+compatability libc5 RPMs installed.
+
+
+***************************
+
+WWW resources - you may find additional Linux Quake help at these URLs:
+
+
+http://quake.medina.net/howto
+
+http://webpages.mr.net/bobz
+
+http://www.linuxgames.com/quake2/
+
+
+
+----------------------------------------------------------------------
+$Id: README.QUAKE,v 1.1.1.3 2004/08/12 23:43:27 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/README.THREADS b/nx-X11/extras/Mesa/docs/README.THREADS
new file mode 100644
index 000000000..fb6e0ff3d
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.THREADS
@@ -0,0 +1,52 @@
+
+
+Mesa Threads README
+-------------------
+
+Thread safety was introduced in Mesa 2.6 by John Stone and
+Christoph Poliwoda.
+
+It was redesigned in Mesa 3.3 so that thread safety is
+supported by default (on systems which support threads,
+that is). There is no measurable penalty on single
+threaded applications.
+
+NOTE that the only _driver_ which is thread safe at this time
+is the OS/Mesa driver!
+
+
+At present the mthreads code supports three thread APIS:
+ 1) POSIX threads (aka pthreads).
+ 2) Solaris / Unix International threads.
+ 3) Win32 threads (Win 95/NT).
+
+Support for other thread libraries can be added src/glthread.[ch]
+
+
+In order to guarantee proper operation, it is
+necessary for both Mesa and application code to use the same threads API.
+So, if your application uses Sun's thread API, then you should build Mesa
+using one of the targets for Sun threads.
+
+The mtdemos directory contains some example programs which use
+multiple threads to render to osmesa rendering context(s).
+
+Linux users should be aware that there exist many different POSIX
+threads packages. The best solution is the linuxthreads package
+(http://pauillac.inria.fr/~xleroy/linuxthreads/) as this package is the
+only one that really supports multiprocessor machines (AFAIK). See
+http://pauillac.inria.fr/~xleroy/linuxthreads/README for further
+information about the usage of linuxthreads.
+
+If you are interested in helping with thread safety work in Mesa
+join the Mesa developers mailing list and post your proposal.
+
+
+Regards,
+ John Stone -- j.stone@acm.org johns@cs.umr.edu
+ Christoph Poliwoda -- poliwoda@volumegraphics.com
+
+
+Version info:
+ Mesa 2.6 - initial thread support.
+ Mesa 3.3 - thread support mostly rewritten (Brian Paul)
diff --git a/nx-X11/extras/Mesa/docs/README.VMS b/nx-X11/extras/Mesa/docs/README.VMS
new file mode 100644
index 000000000..c435727c0
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.VMS
@@ -0,0 +1,32 @@
+
+VMS support contributed by Jouk Jansen (joukj@hrem.stm.tudelft.nl)
+
+
+The latest version was tested on a VMSAlpha7.2 system using DECC6.0, but
+probably also works for other versions.
+
+At the moment only the libraries LIBMESGL.EXE/LIBMESGL.OLB,
+LIBMESAGLU.EXE/LIBMESAGLU.OLB and LIBGLUT.EXE/LIBGLUT.OLB and the demos of the
+directory [.DEMOS] can be build.
+However, feel free to create the missing "decrip.mms-files" in the other
+directories.
+
+ The make files were tested
+using the DIGITAL make utility called MMS. There is also a public domain
+clone available (MMK) and I think, but it is not tested, that this
+utility will give (hardly) any problem.
+
+To make everything just type MMS (or MMK) in the main directory of
+mesagl. For MMS the deafult makefile is called descrip.mms, and
+that is what I have called it. I included alse some config files,
+all having mms somewhere in the name which all the makefiles need
+(just as your unix makefiles).
+
+On Alpha platforms at default a sharable images for the libraries are created.
+To get a static library make it by typing MMS/MACRO=(NOSHARE=1).
+On VAX platforms only static libraries can be build.
+
+
+You may want to compile Mesa to use IEEE floating point arithmetic, instead
+of VAX floating point by specifying the /float=IEEE flag to the compiler.
+For more information see https://bugs.freedesktop.org/show_bug.cgi?id=4270
diff --git a/nx-X11/extras/Mesa/docs/README.WIN32 b/nx-X11/extras/Mesa/docs/README.WIN32
new file mode 100644
index 000000000..675a3b364
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.WIN32
@@ -0,0 +1,139 @@
+File: docs/README.WIN32
+
+Last updated: Jul 01, 2005 - Karl Schultz - kschultz@users.sourceforge.net
+
+Quick Start
+----- -----
+
+Unzip both ZIP files (MesaLib and MesaDemos) into the same directory.
+The libs and demos build separately, so if you do not care about the
+demos, you do not have to unzip that zip file. But if you do, it does
+need to be unzipped into the same directory as the lib zip file
+because the demos depend on the libs.
+
+The Windows build system uses Microsoft Visual Studio. Project files
+for a specific version of Visual Studio are in their own directory in
+the top-level "windows" directory. For example, Visual Studio 6 files
+are in windows/VC6. If a directory does not exist for your version of
+Visual Studio, you can try importing the project files from an earlier
+version of Visual Studio. At this time, project files exist for
+Version 6 and Version 7. The code has been built with a beta version
+of Version 8 and it runs on 64-bit Windows. If you want to try this,
+start by importing the VC7 files and create the 64-bit targets in the
+configuration manager.
+
+The project files to build the core Mesa library, Windows Mesa
+drivers, OSMesa, and GLU are in the mesa directory. The project files
+to build GLUT and some demo programs are in the progs directory.
+
+Makefiles are no longer shipped or supported, but can be generated
+from the projects using Visual Studio.
+
+
+Windows Drivers
+------- -------
+
+At this time, only the GDI driver is known to work, as it has been
+ported and rewritten to the latest Mesa DD interfaces. Source code
+also exists in the tree for other drivers in src/mesa/drivers/windows,
+but the status of this code is unknown.
+
+The GDI driver operates basically by writing pixel spans into a DIB
+section and then blitting the DIB to the window. The driver was
+recently cleaned up and rewitten and so may have bugs or may be
+missing some functionality. The older versions of the CVS source may
+be useful in figuring out any problems, or report them to me.
+
+To build Mesa with the GDI driver, build the mesa, gdi, and glu
+projects in the Visual Studio workspace found at
+
+ windows/VC6/mesa/mesa.dsw
+or
+ windows/VC7/mesa/mesa.sln
+
+The osmesa DLL can also be built with the osmesa project.
+
+The build system creates a lib top-level directory and copies
+resulting LIB and DLL files to this lib directory. The files are:
+
+ OPENGL32.LIB, GLU32.LIB, OSMESA32.LIB
+ OPENGL32.DLL, GLU32.DLL, OSMESA32.DLL
+
+If the MesaDemos ZIP file was extracted, the DLL files are also copied
+to the demos directory. This facilitates running the demos as described
+below.
+
+
+GLUT and Demos
+---- --- -----
+
+A Visual Studio workspace can be found at
+
+ windows/VC6/progs/progs.dsw
+or
+ windows/VC7/progs/progs.sln
+
+It can be used to build GLUT and a few demos. The GLUT lib and DLL
+are copied to the top-level lib directory, along with the Mesa libs.
+
+The demo build system expects to find the LIB files in the top level
+lib directory, so you must build the Mesa libs first. The demo
+executables are placed in the demos directory, because some of them
+rely on data files found there. Also, the Mesa lib DLL's were copied
+there by the Mesa lib build process. Therefore, you should be able to
+simply run the demo executables from the demo directory.
+
+If you want to run the demos from the Visual Studio, you may have to
+change the startup directory and explicitly state where the executables are.
+
+
+Build System Notes
+----- ------ -----
+
+VC6
+---
+
+Visual Studio 6 does not recognize files with the .cc extension as C++
+language files, without a lot of unnatural tweaking. So, the VC6
+build process uses custom build steps to compile these files in the
+GLU library.
+
+
+VC7
+---
+
+The above-mentioned .cc problem does not exist in this version.
+
+
+General
+-------
+
+After building, you can copy the above DLL files to a place in your
+PATH such as $SystemRoot/SYSTEM32. If you don't like putting things
+in a system directory, place them in the same directory as the
+executable(s). Be careful about accidentially overwriting files of
+the same name in the SYSTEM32 directory.
+
+The DLL files are built so that the external entry points use the
+stdcall calling convention.
+
+Static LIB files are not built. The LIB files that are built with are
+the linker import files associated with the DLL files.
+
+The si-glu sources are used to build the GLU libs. This was done
+mainly to get the better tessellator code.
+
+To build "mangled" Mesa, add the preprocessor define USE_MGL_NAMESPACE
+to the project settings. You will also need to edit src/mesa.def to
+change all the gl* symbols to mgl*. Because this is easy to do with a
+global replace operation in a text editor, no additional mangled
+version of mesa.def is maintained or shipped.
+
+If you have a Windows-related build problem or question, it is
+probably better to direct it to me (kschultz@users.sourceforge.net),
+rather than directly to the other Mesa developers. I will help you as
+much as I can. I also monitor the Mesa mailing lists and will answer
+questions in this area there as well.
+
+
+Karl Schultz
diff --git a/nx-X11/extras/Mesa/docs/README.WINDML b/nx-X11/extras/Mesa/docs/README.WINDML
new file mode 100644
index 000000000..448db71f8
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.WINDML
@@ -0,0 +1,146 @@
+
+ WindML Driver for Mesa 4.0
+
+
+Requirements
+------------
+
+Tornado 2 + WindML, Cumulative Patchs are recommended.
+
+I suppose you have a valid WindML installation. Double buffer hardware
+gives better performance than double buffer software so if you can
+compile your WindML driver with this option, just do it. I/O
+redirection is adviced in target server.
+
+
+Tested on
+---------
+
+During the development, my main target was a CoolMonster:
+- Video card: CT69000
+- CPU: PENTIUM 266MHz
+
+and my host a Windows NT + Tornado 2.
+
+
+Installation
+------------
+
+1. Mesa sources must be in root directory (C:\)
+
+2. Add the following line to your torVars.bat:
+set MESA_BASE=C:\Mesa
+
+OR copy the new torVars.bat in your bin path:
+c:/Mesa/src/ugl/tornado/torVars.sample ->
+/mnt/nt/Tornado/host/x86-win32/bin/torVars (for example)
+
+3. In a command prompt:
+$ torVars
+$ cd c:\Mesa
+$ make -f Makefile.ugl CPU=PENTIUM
+
+Take a long while...
+
+5. Include all the files from ugldemos folder to build some downloadable
+ application modules
+
+4. Download UGL/Mesa object files on target
+
+For example via the WindShell:
+ld < c:\Tornado\target\lib\objMesaGL.o
+ld < c:\Tornado\target\lib\objMesaUGL.o
+ld < c:\Tornado\target\lib\objMesaGLU.o
+ld < c:\Tornado\target\lib\objGLUTshapes.o
+ld < c:\Tornado\target\lib\objMesaOS.o
+
+You can put the previous lines in a file and use:
+< filename
+
+6. Download the application modules.
+
+7. In WindShell, run:
+-> uglalldemos
+
+During the show some messages will appear, it provides some useful
+information on key management.
+
+
+Coding
+------
+
+Sample Usage:
+
+In addition to the usual ugl calls to initialize UGL, (may be find an
+input driver), you must do the following to use the UGL/Mesa interface:
+
+1. Call uglMesaCreateContext() to create a UGL/Mesa rendering context,
+ given the display format.
+
+2. Call uglMesaMakeCurrent() to bind the UGL/Mesa buffers to an
+ UGL/Mesa Context and to make the context the current one.
+
+3. Make gl* calls to render your graphics.
+
+4. Use uglMesaSwapBuffers() when double buffering to swap front/back buffers.
+
+5. Before the UGL is destroyed, call MesaDestroyContext().
+
+6. Before exiting, call if required uglEventQDestroy and then
+ uglDeinitialize();
+
+Limitations
+-----------
+
+I found the following limitations in my driver :
+ - Color Indexed management is only in 8 bits
+ - It's possible to mix UGL/OpenGL application with a software
+ double buffer
+
+Modifications
+------------
+
+New files in Mesa:
+- Makefile.ugl
+- rules.windmlmesa
+- docs/README.UGL
+- include/GL/uglmesa.h
+- si-glu/Makefile.ugl
+- src/Makefile.ugl
+- src/ugl/torGLUTShapesInit.c
+- src/ugl/torMesaUGLInit.c
+- src/ugl/ugl_api.c
+- src/ugl/ugl_dd.c
+- src/ugl/ugl_glutshapes.c
+- src/ugl/ugl_line.c
+- src/ugl/ugl_span.c
+- src/ugl/ugl_tri.c
+- src/ugl/uglmesaP.h
+- ugldemos/*
+
+Modified files in Tornado 2.0:
+- c:\Tornado\host\x86-win32\bin\torVars.bat
+rem Command line build environments
+set WIND_HOST_TYPE=x86-win32
+set WIND_BASE=C:\Tornado
+set MESA_BASE=C:\Mesa
+set PATH=%WIND_BASE%\host\%WIND_HOST_TYPE%\bin;%PATH%
+- c:\Tornado\target\config\comps\VxWorks\01uglmesa.cdf
+- c:\Tornado\target\h\GL\*
+
+Todo
+----
+- GCC 2.96, ASM compilation
+
+Thanks to:
+----------
+
+Precision Insight team for their great job around Mesa, XFree, and DRI.
+Wind River Systems to take me as an intern.
+
+
+Stephane Raimbault
+<stephane.raimbault@windriver.com>
+<stephane.raimbault@deesse.univ-lemans.fr>
+
+July 24, 2001
diff --git a/nx-X11/extras/Mesa/docs/README.X11 b/nx-X11/extras/Mesa/docs/README.X11
new file mode 100644
index 000000000..45c424273
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.X11
@@ -0,0 +1,314 @@
+
+ Mesa Unix/X11 Information
+
+
+
+Installation
+============
+
+There are two ways to compile Mesa on Unix/X11 systems:
+
+1. The old way:
+ First type 'make' alone to see the list of system
+ configurations currently supported. If you see your configuration on the
+ list, type 'make <config>'. Most popular Unix/X workstations are currently
+ supported.
+
+ If your system configuration is not listed by 'make', you'll have to modify
+ the top-level Makefile and Make-config files. There are instructions in
+ each file.
+
+ When finished, the Mesa libraries will be in the Mesa-x.y/lib/ directory.
+
+
+2. The new way:
+ Type './configure' and then 'make'. This uses GNU autoconfig.
+ Run 'make check' to build the demos.
+ See docs/INSTALL for more details.
+ When finished, the Mesa libraries will be in the Mesa-x.y/src/.libs/,
+ Mesa-x.y/si-glu/.libs, etc directories.
+
+
+Notes on assembly language optimizations:
+
+ When using the old-style Makefiles, you can specify a configuration
+ that uses X86 assembly language optimizations (linux-3dnow for example).
+
+ The detection of MMX, 3DNow!, PIII/SSE, etc capability is done at
+ runtime. That means you can compile Mesa for 3DNow! optimizations
+ even if you don't have an AMD CPU.
+
+ However, your Linux binutils and assembler must understand the
+ special instructions in order to compile them. If you have
+ compilation problems, try upgrading your binutils.
+
+
+Header and library files:
+ After you've compiled Mesa and tried the demos I recommend the following
+ procedure for "installing" Mesa.
+
+ Copy the Mesa include/GL directory to /usr/local/include:
+ cp -r include/GL /usr/local/include
+
+ Copy the Mesa library files to /usr/local/lib:
+ cp lib/* /usr/local/lib
+
+ (actually, use "cp -d" on Linux to preserve symbolic links)
+
+
+Xt/Motif widgets:
+ If you want to use Mesa or OpenGL in your Xt/Motif program you can build
+ the widgets found in either the widgets-mesa or widgets-sgi directories.
+ The former were written for Mesa and the later are the original SGI
+ widgets. Look in those directories for more information.
+
+
+Notes:
+ HP users: a Mesa user reports that the HP-UX 10.01 C compiler has
+ a bug which effects glReadPixels. A patch for the compiler (PHSS_5743) is
+ available. Otherwise be sure your compiler is version 10.13 or later.
+
+ QNX users: if you have problems running the demos try setting the
+ stack size to 200K or larger with -N200K, for example.
+
+ SunOS 5.x users: The X shared memory extension may not work
+ correctly. If Mesa prints an error message to the effect of "Shared memory
+ error" then you'll have to append the following three lines to the end of
+ your /etc/system file then reboot:
+ set shmsys:shminfo_shmmax = 0x2000000
+ set shmsys:shminfo_shmmni = 0x1000
+ set shmsys:shminfo_shmseg = 0x100
+
+
+
+Using the library
+=================
+
+Configuration options:
+ The file src/mesa/main/config.h has many parameters which you can adjust
+ such as maximum number of lights, clipping planes, maximum texture size,
+ etc. In particular, you may want to change DEPTH_BITS from 16 to 32
+ if a 16-bit depth buffer isn't precise enough for your application.
+
+
+Shared libraries:
+ If you compile shared libraries you may have to set an environment
+ variable to specify where the Mesa libraries are located. On Linux and
+ Sun systems for example, set the LD_LIBRARY_PATH variable to include
+ /your-dir/Mesa-2.6/lib. Otherwise, when you try to run a demo it
+ may fail with a message saying that one or more libraries couldn't be
+ found.
+
+
+Remote display of OpenGL/GLX programs:
+ As of version 1.2.3, Mesa's header files use the same GLenum and GLUenum
+ values as SGI's (and most/all other vendor's) OpenGL headers. This means
+ you can freely mix object files compiled with OpenGL or Mesa headers.
+ In fact, on systems with dynamic runtime linkers it's possible to dynam-
+ ically link with Mesa or OpenGL shared libraries at runtime, without
+ recompiling or relinking anything!
+
+ Using IRIX 5.x as an example, you can run SGI's OpenGL demos with the
+ Mesa shared libraries as follows. Let's assume you're installing Mesa
+ in /usr/local/Mesa and using the C-shell:
+ % cd /usr/local/Mesa
+ % make irix5-dso
+ % setenv _RLD_LIST "/usr/local/Mesa/lib/libGL.so:DEFAULT"
+ % /usr/demos/bin/ideas_ogl // this is a test
+
+ You can now run OpenGL executables on almost any X display! There may
+ be some problems from the fact that Mesa supports many X visual types
+ that an OpenGL client may not expect (grayscale for example). In this
+ case the application may abort, print error messages, or just behave
+ strangely. You may have to experiment with the MESA_RGB_VISUAL envi-
+ ronment variable.
+
+
+Xt/Motif Widgets:
+ Two versions of the Xt/Motif OpenGL drawing area widgets are included:
+
+ widgets-sgi/ SGI's stock widgets
+ widgets-mesa/ Mesa-tuned widgets
+
+ Look in those directories for details
+
+
+Togl:
+ Togl is an OpenGL/Mesa widget for Tcl/Tk.
+ See http://togl.sourceforge.net for more information.
+
+
+
+X Display Modes:
+ Mesa supports RGB(A) rendering into almost any X visual type and depth.
+
+ The glXChooseVisual function tries its best to pick an appropriate visual
+ for the given attribute list. However, if this doesn't suit your needs
+ you can force Mesa to use any X visual you want (any supported by your
+ X server that is) by setting the MESA_RGB_VISUAL and MESA_CI_VISUAL
+ environment variables. When an RGB visual is requested, glXChooseVisual
+ will first look if the MESA_RGB_VISUAL variable is defined. If so, it
+ will try to use the specified visual. Similarly, when a color index
+ visual is requested, glXChooseVisual will look for the MESA_CI_VISUAL
+ variable.
+
+ The format of accepted values is: <visual-class> <depth>
+ Here are some examples:
+
+ using the C-shell:
+ % setenv MESA_RGB_VISUAL "TrueColor 8" // 8-bit TrueColor
+ % setenv MESA_CI_VISUAL "PseudoColor 12" // 12-bit PseudoColor
+ % setenv MESA_RGB_VISUAL "PseudoColor 8" // 8-bit PseudoColor
+
+ using the KornShell:
+ $ export MESA_RGB_VISUAL="TrueColor 8"
+ $ export MESA_CI_VISUAL="PseudoColor 12"
+ $ export MESA_RGB_VISUAL="PseudoColor 8"
+
+
+Double buffering:
+ Mesa can use either an X Pixmap or XImage as the backbuffer when in
+ double buffer mode. Using GLX, the default is to use an XImage. The
+ MESA_BACK_BUFFER environment variable can override this. The valid
+ values for MESA_BACK_BUFFER are: Pixmap and XImage (only the first
+ letter is checked, case doesn't matter).
+
+ A pixmap is faster when drawing simple lines and polygons while an
+ XImage is faster when Mesa has to do pixel-by-pixel rendering. If you
+ need depth buffering the XImage will almost surely be faster. Exper-
+ iment with the MESA_BACK_BUFFER variable to see which is faster for
+ your application.
+
+
+Colormaps:
+ When using Mesa directly or with GLX, it's up to the application writer
+ to create a window with an appropriate colormap. The aux, tk, and GLUT
+ toolkits try to minimize colormap "flashing" by sharing colormaps when
+ possible. Specifically, if the visual and depth of the window matches
+ that of the root window, the root window's colormap will be shared by
+ the Mesa window. Otherwise, a new, private colormap will be allocated.
+
+ When sharing the root colormap, Mesa may be unable to allocate the colors
+ it needs, resulting in poor color quality. This can happen when a
+ large number of colorcells in the root colormap are already allocated.
+ To prevent colormap sharing in aux, tk and GLUT, define the environment
+ variable MESA_PRIVATE_CMAP. The value isn't significant.
+
+
+Gamma correction:
+ To compensate for the nonlinear relationship between pixel values
+ and displayed intensities, there is a gamma correction feature in
+ Mesa. Some systems, such as Silicon Graphics, support gamma
+ correction in hardware (man gamma) so you won't need to use Mesa's
+ gamma facility. Other systems, however, may need gamma adjustment
+ to produce images which look correct. If in the past you thought
+ Mesa's images were too dim, read on.
+
+ Gamma correction is controlled with the MESA_GAMMA environment
+ variable. Its value is of the form "Gr Gg Gb" or just "G" where
+ Gr is the red gamma value, Gg is the green gamma value, Gb is the
+ blue gamma value and G is one gamma value to use for all three
+ channels. Each value is a positive real number typically in the
+ range 1.0 to 2.5. The defaults are all 1.0, effectively disabling
+ gamma correction. Examples using csh:
+
+ % setenv MESA_GAMMA "2.3 2.2 2.4" // separate R,G,B values
+ % setenv MESA_GAMMA "2.0" // same gamma for R,G,B
+
+ The demos/gamma.c program may help you to determine reasonable gamma
+ value for your display. With correct gamma values, the color intensities
+ displayed in the top row (drawn by dithering) should nearly match those
+ in the bottom row (drawn as grays).
+
+ Alex De Bruyn reports that gamma values of 1.6, 1.6 and 1.9 work well
+ on HP displays using the HP-ColorRecovery technology.
+
+ Mesa implements gamma correction with a lookup table which translates
+ a "linear" pixel value to a gamma-corrected pixel value. There is a
+ small performance penalty. Gamma correction only works in RGB mode.
+ Also be aware that pixel values read back from the frame buffer will
+ not be "un-corrected" so glReadPixels may not return the same data
+ drawn with glDrawPixels.
+
+ For more information about gamma correction see:
+ http://www.inforamp.net/~poynton/notes/colour_and_gamma/GammaFAQ.html
+
+
+Overlay Planes
+
+ Overlay planes in the frame buffer are supported by Mesa but require
+ hardware and X server support. To determine if your X server has
+ overlay support you can test for the SERVER_OVERLAY_VISUALS property:
+
+ xprop -root | grep SERVER_OVERLAY_VISUALS
+
+
+HPCR glClear(GL_COLOR_BUFFER_BIT) dithering
+
+ If you set the MESA_HPCR_CLEAR environment variable then dithering
+ will be used when clearing the color buffer. This is only applicable
+ to HP systems with the HPCR (Color Recovery) system.
+
+
+Extensions
+==========
+ There are three Mesa-specific GLX extensions at this time.
+
+ GLX_MESA_pixmap_colormap
+
+ This extension adds the GLX function:
+
+ GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual,
+ Pixmap pixmap, Colormap cmap )
+
+ It is an alternative to the standard glXCreateGLXPixmap() function.
+ Since Mesa supports RGB rendering into any X visual, not just True-
+ Color or DirectColor, Mesa needs colormap information to convert RGB
+ values into pixel values. An X window carries this information but a
+ pixmap does not. This function associates a colormap to a GLX pixmap.
+ See the xdemos/glxpixmap.c file for an example of how to use this
+ extension.
+
+ GLX_MESA_release_buffers
+
+ Mesa associates a set of ancillary (depth, accumulation, stencil and
+ alpha) buffers with each X window it draws into. These ancillary
+ buffers are allocated for each X window the first time the X window
+ is passed to glXMakeCurrent(). Mesa, however, can't detect when an
+ X window has been destroyed in order to free the ancillary buffers.
+
+ The best it can do is to check for recently destroyed windows whenever
+ the client calls the glXCreateContext() or glXDestroyContext()
+ functions. This may not be sufficient in all situations though.
+
+ The GLX_MESA_release_buffers extension allows a client to explicitly
+ deallocate the ancillary buffers by calling glxReleaseBuffersMESA()
+ just before an X window is destroyed. For example:
+
+ #ifdef GLX_MESA_release_buffers
+ glXReleaseBuffersMESA( dpy, window );
+ #endif
+ XDestroyWindow( dpy, window );
+
+ This extension is new in Mesa 2.0.
+
+ GLX_MESA_copy_sub_buffer
+
+ This extension adds the glXCopySubBufferMESA() function. It works
+ like glXSwapBuffers() but only copies a sub-region of the window
+ instead of the whole window.
+
+ This extension is new in Mesa version 2.6
+
+
+
+Summary of X-related environment variables:
+ MESA_RGB_VISUAL - specifies the X visual and depth for RGB mode (X only)
+ MESA_CI_VISUAL - specifies the X visual and depth for CI mode (X only)
+ MESA_BACK_BUFFER - specifies how to implement the back color buffer (X only)
+ MESA_PRIVATE_CMAP - force aux/tk libraries to use private colormaps (X only)
+ MESA_GAMMA - gamma correction coefficients (X only)
+
+
+----------------------------------------------------------------------
+$Id: README.X11,v 1.1.1.3 2004/08/12 23:43:27 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/README.directfb b/nx-X11/extras/Mesa/docs/README.directfb
new file mode 100644
index 000000000..169ebe486
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/README.directfb
@@ -0,0 +1,28 @@
+
+ Mesa DirectFB Information
+
+
+Requirements
+============
+
+ To build Mesa with DirectFB (DirectFBGL) support you need:
+ - DirectFB at least 0.9.21 (http://directfb.org)
+ - pkg-config at least 0.9 (http://pkgconfig.sf.net)
+
+
+Installation
+============
+ Run
+
+ make linux-directfb
+
+ to build Mesa and DirectFBGL module,
+
+ make install
+
+ to install OpenGL libraries and
+
+ make linux-directfb-install
+
+ to install DirectFBGL module in the proper location.
+
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-3.1 b/nx-X11/extras/Mesa/docs/RELNOTES-3.1
new file mode 100644
index 000000000..c1d5d8f9f
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-3.1
@@ -0,0 +1,146 @@
+
+ Mesa 3.1 release notes
+
+ PLEASE READ!!!!
+
+
+New copyright
+-------------
+
+Mesa 3.1 will be distributed under an XFree86-style copyright instead
+of the GNU LGPL.
+
+
+New directories
+---------------
+
+All documentation files are now in the docs/ directory.
+All shell scripts are now in the bin/ directory.
+
+
+New library names
+-----------------
+
+Formerly, the main Mesa library was named libMesaGL.so (or libMesaGL.a)
+and the GLU library was named libMesaGLU.so (or libMesaGLU.a).
+
+Now, the main library is named libGL.so (or libGL.a) and the GLU library
+is named libGLU.so (or libGLU.a).
+
+The change allows Mesa to be more easily substituted for OpenGL.
+Specifically, the linker/loader on some Unix-like systems won't
+allow libMesaGL.so to be used instead of libGL.so if the application
+was linked with the former.
+
+Warning: if you have another OpenGL implementation installed on your
+system (i.e. you have another OpenGL libGL.so) you'll have to be
+carefull about which library (OpenGL or Mesa) you link against. Be
+aware of -L linker flags and the value of the LD_LIBRARY_PATH environment
+variable.
+
+
+New library versioning
+----------------------
+
+Previously, the Mesa GL library was named libMesaGL.so.3.0
+To better support Linux/OpenGL standards, the Mesa GL library is now
+named libGL.so.1.2.030100 This indicates version 1.2 of the OpenGL spec
+and Mesa implementation 3.1.0
+
+In the long term this will allow better interoperability with other
+OpenGL implementations, especially on Linux. In the short term,
+OpenGL apps may have to be relinked to use the new library naming.
+
+
+
+New makefiles
+-------------
+
+The old Makefiles found in the various directories have been renamed
+to Makefile.X11 in order to prevent filename collisions with autoconfig-
+generated Makefiles.
+
+The top-level Makefile simply includes Makefile.X11
+If your top-level Makefile get's overwritten/destroyed you can restore
+it by copying Makefile.X11 to Makefile
+
+
+New extensions
+--------------
+
+GL_EXT_stencil_wrap
+ Implements two new stencil operations: GL_INCR_WRAP_EXT and
+ GL_DECR_WRAP_EXT which allow stencil increment and decrement
+ without clamping.
+
+GL_INGR_blend_func_separate
+ Allows specification of blend factors for RGB and Alpha independently.
+ (INGR = Intergraph)
+
+GL_ARB_multitexture
+ Multiple simultaneous textures. (ARB = Architecture Review Board)
+
+GL_NV_texgen_reflection
+ nVidia texgen extension for better reflection mapping.
+
+GL_PGI_misc_hints
+ Assorted transformation hints.
+
+GL_EXT_compiled_vertex_array
+ Compiled vertex arrays.
+
+GL_EXT_clip_volume_hint
+ Allows one to disable clip volume (frustum) testing.
+
+
+
+Extensions removed
+------------------
+
+GL_EXT_multitexture - obsolete in favor of GL_ARB_multitexture
+
+
+
+Config file
+-----------
+
+By default, /etc/mesa.conf will be read when Mesa starts. This
+file controls default hints, enable/disable of extensions, and
+more. See the CONFIG file for documentation.
+
+
+
+Optimizations
+-------------
+
+Keith Whitwell has contributed significant optimizations to Mesa's
+vertex transformation code. Basically, the whole transformation
+stage of Mesa has been rewritten.
+
+It's impossible to give a speedup factor. You'll just have to
+try your app and see how it performs.
+
+
+
+Device Driver changes
+---------------------
+
+A bunch of new device driver functions have been added. See src/dd.h
+Keith Harrison contributed many of them. I've been planning on adding
+a bunch of functions like these to make writing hardware drivers easier.
+More such function will probably be added in the near future.
+
+
+
+Miscellaneous
+-------------
+
+util/glstate.c has some handy functions for debugging. Basically, it
+offers a simple function for printing GL state variables. It's not
+finished yet. There's a LOT more GLenum records to be added (see the
+code). Anyone want to help?
+
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-3.1,v 1.1.1.3 2004/08/12 23:43:27 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-3.2 b/nx-X11/extras/Mesa/docs/RELNOTES-3.2
new file mode 100644
index 000000000..476d97545
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-3.2
@@ -0,0 +1,12 @@
+
+ Mesa 3.2 release notes
+
+ PLEASE READ!!!!
+
+
+Mesa 3.2 is a stabilization of the Mesa 3.1 release. No new features
+have been added. For a list of bug fixes please read the VERSIONS file.
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-3.2,v 1.1.1.3 2004/08/12 23:43:27 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-3.2.1 b/nx-X11/extras/Mesa/docs/RELNOTES-3.2.1
new file mode 100644
index 000000000..5245a2ed6
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-3.2.1
@@ -0,0 +1,32 @@
+
+ Mesa 3.2.1 release notes
+
+ PLEASE READ!!!!
+
+
+
+The Mesa 3.2.1 release mainly just fixes bugs since the 3.2 release.
+See the VERSIONS file for the exact list.
+
+
+
+GLU Polygon Tessellator
+-----------------------
+
+The GLU tessellator has been reverted back to the version included
+with Mesa 3.0 since it's more stable. The Mesa 3.1/3.2 tessellator
+implemented the GLU 1.3 specification but suffered from a number of
+bugs.
+
+Mesa implements GLU 1.1.
+
+Ideally, people should use the GLU 1.3 library included in SGI's
+OpenGL Sample Implementation (SI) available from
+http://oss.sgi.com/projects/ogl-sample/
+People are working to make easy-to-install Linux RPMs of the
+GLU library.
+
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-3.2.1,v 1.1.1.3 2004/08/12 23:43:27 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-3.3 b/nx-X11/extras/Mesa/docs/RELNOTES-3.3
new file mode 100644
index 000000000..552d07674
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-3.3
@@ -0,0 +1,271 @@
+
+ Mesa 3.3 release notes
+
+ July 21, 2000
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 3.3) designate new developmental releases.
+Even numbered versions (such as 3.2.1) designate stable releases.
+
+Mesa 3.3 has a undergone many internal changes since version 3.2
+and features a lot of new extensions. 3.3 is expected to be pretty
+stable, but perhaps not as stable as 3.2 which has been used by
+thousands of users over the past months.
+
+Everyone is encouraged to try Mesa 3.3. Bugs should be reported to
+the Mesa bug database on www.sourceforge.net.
+
+
+
+Header file / GLenum changes
+----------------------------
+
+The gl.h and glu.h headers now use #defines to define all GL_* tokens
+instead of C-language enums. This change improves Mesa/OpenGL
+interoperability.
+
+
+
+New API dispatch code
+---------------------
+
+The core Mesa gl* functions are now implemented with a new dispatch
+(jump table) which will allow simultaneous direct/indirect rendering.
+
+The code is found in the glapi*.[ch] files.
+
+Of interest: the actual "glFooBar" functions are generated with
+templatized code defined in glapitemp.h and included by glapi.c
+The glapitemp.h template should be reusable for all sorts of OpenGL
+projects.
+
+The new dispatch code has also optimized with x86 assembly code.
+This optimization eliminates copying the function arguments during
+dispatch.
+
+
+
+New thread support
+------------------
+
+Thread support in Mesa has been rewritten. The glthread.[ch] files
+replace mthreads.[ch]. Thread safety is always enabled (on platforms
+which support threads, that is). There is virtually no performance
+penalty for typical single-thread applications. See the glapi.c
+file for details.
+
+The Xlib driver (XMesa) is now thread-safe as well. Be sure to
+call XInitThreads() in your app first. See the xdemos/glthreads.c
+demo for an example.
+
+
+
+Make configuration changes
+--------------------------
+
+If you use the old-style (non GNU automake) method to build Mesa note
+that several of the configuration names have changed:
+
+ Old name New name
+ ------------- ----------------
+ linux-elf linux
+ linux linux-static
+ linux-386-elf linux-386
+ linux-386 linux-386-static
+ etc.
+
+
+
+New extensions
+--------------
+
+GL_ARB_transpose_matrix
+ Adds glLoadTransposeMatrixARB() and glMultTransposeMatrixARB()
+ functions.
+
+GL_ARB_texture_cube_map
+ For cube-based reflection mapping.
+
+GL_EXT_texture_add_env
+ Adds GL_ADD texture environment mode.
+ See http://www.berkelium.com/OpenGL/EXT/texture_env_add.txt
+
+GL_EXT_texture_lod_bias
+ Allows mipmapped texture blurring and sharpening.
+
+GLX_EXT_visual_rating extension
+ This extension has no effect in stand-alone Mesa (used for DRI).
+
+GL_HP_occlusion_test
+ Used for bounding box occlusion testing (see demos/occlude.c).
+
+GL_SGIX_pixel_texture / GL_SGIS_pixel_texture
+ Lets glDraw/CopyPixels draw a texture coordinate image.
+
+GL_SGI_color_matrix
+ Adds a color matrix and another set of scale and bias parameters
+ to the glDraw/CopyPixels paths.
+
+GL_SGI_color_table
+ Adds additional color tables to the glDraw/Read/CopyPixels paths.
+
+GL_EXT_histogram
+ Compute histograms for glDraw/Read/CopyPixels.
+
+GL_EXT_blend_func_separate
+ This is the same as GL_INGR_blend_func_separate.
+
+GL_ARB_texture_cube_mapping
+ 6-face cube mapping, nicer than sphere mapping
+
+GL_EXT_texture_env_combine
+ For advanced texture environment effects.
+
+
+Documentation for all these functions can be found at
+http://oss.sgi.com/projects/ogl-sample/registry/
+
+
+
+GLX_SGI_make_current_read functionality
+---------------------------------------
+
+The functionality of this extension is needed for GLX 1.3 (and required
+for the Linux/OpenGL standards base).
+
+Implementing this function required a **DEVICE DRIVER CHANGE**.
+The old SetBuffer() function has been replaced by SetReadBuffer() and
+SetDrawBuffer(). All device drivers will have to be updated because
+of this change.
+
+The new function, glXMakeContextCurrent(), in GLX 1.3 now works in Mesa.
+The xdemos/wincopy.c program demonstrates it.
+
+
+
+Image-related code changes
+--------------------------
+
+The imaging path code used by glDrawPixels, glTexImage[123]D,
+glTexSubImage[123], etc has been rewritten. It's now faster,
+uses less memory and has several bug fixes. This work was
+actually started in Mesa 3.1 with the glTexImage paths but has now
+been carried over to glDrawPixels as well.
+
+
+
+Device driver interface changes
+-------------------------------
+
+Added new functions for hardware stencil buffer support:
+ WriteStencilSpan
+ ReadStencilSpan
+ WriteStencilPixels
+ ReadStencilPixels
+
+
+Removed old depth buffer functions:
+ AllocDepthBuffer
+ DepthTestSpan
+ DepthTestPixels
+ ReadDepthSpanFloat
+ ReadDepthSpanInt
+
+
+Added new depth buffer functions:
+ WriteDepthSpan
+ ReadDepthSpan
+ WriteDepthPixels
+ ReadDepthPixels
+
+ These functions always read/write 32-bit GLuints. This will allow
+ drivers to have anywhere from 0 to 32-bit Z buffers without
+ recompiling for 16 vs 32 bits as was previously needed.
+
+
+New texture image functions
+ The entire interface for texture image specification has been updated.
+ With the new functions, it's optional for Mesa to keep an internal copy
+ of all textures. Texture download should be a lot faster when the extra
+ copy isn't made.
+
+Misc changes
+ TexEnv now takes a target argument
+ Removed UseGlobalTexturePalette (use Enable function instead)
+
+
+Also added
+ ReadPixels
+ CopyPixels
+
+
+The SetBufffer function has been replaced by SetDrawBuffer and
+SetReadBuffer functions. This lets core Mesa independently
+specify which buffer is to be used for reading and which for
+drawing.
+
+The Clear function's mask parameter has changed. Instead of
+mask being the flags specified by the user to glClear, the
+mask is now a bitmask of the DD_*_BIT flags in dd.h. Now
+multiple color buffers can be specified for clearing (ala
+glDrawBuffers). The driver's Clear function must also
+check the glColorMask glIndexMask, and glStencilMask settings
+and do the right thing. See the X/Mesa, OS/Mesa, or FX/Mesa
+drivers for examples.
+
+
+The depth buffer changes shouldn't be hard to make for existing
+drivers. In fact, it should simply the code. Be careful with
+the depthBits value passed to gl_create_context(). 1 is a bad
+value! It should normally be 0, 16, 24, or 32.
+
+
+gl_create_framebuffer() takes new arguments which explicitly tell
+core Mesa which ancillary buffers (depth, stencil, accum, alpha)
+should be implemented in software. Mesa hardware drivers should
+carefully set these flags depending on which buffers are in the
+graphics card.
+
+
+
+Internal constants
+------------------
+
+Point and line size range and granularity limits are now stored
+in the gl_constants struct, which is the Const member of GLcontext.
+The limits are initialized from values in config.h but may be
+overridden by device drivers to reflect the limits of that driver's
+hardware.
+
+Also added constants for NumAuxBuffers and SubPixelBits.
+
+
+
+OpenGL Conformance
+------------------
+
+Mesa now passes all the OpenGL 1.1 conformance tests, except for
+antialiased lines. AA lines fail on some, but not all, the tests.
+In order to fix the remaining failures, a new AA line algorithm will
+be needed (which computes coverage values for end-point fragments).
+This will be done for Mesa 3.5/3.6.
+
+
+
+OpenGL 1.2 GL_ARB_imaging subset
+--------------------------------
+
+Mesa 3.3 implements all the features of GL_ARB_imaging except for
+image convolution. This will (hopefully) be done for Mesa 3.5/3.6.
+
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-3.3,v 1.1.1.3 2004/08/12 23:43:27 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-3.4 b/nx-X11/extras/Mesa/docs/RELNOTES-3.4
new file mode 100644
index 000000000..9d61b9ded
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-3.4
@@ -0,0 +1,22 @@
+
+ Mesa 3.4 release notes
+
+ November 3, 2000
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 3.3) designate new developmental releases.
+Even numbered versions (such as 3.4) designate stable releases.
+
+Mesa 3.4 simply fixes bugs found in the Mesa 3.3 release. For details,
+see the VERSIONS file.
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-3.4,v 1.1.1.3 2004/08/12 23:43:27 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-3.4.1 b/nx-X11/extras/Mesa/docs/RELNOTES-3.4.1
new file mode 100644
index 000000000..4d343bef1
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-3.4.1
@@ -0,0 +1,22 @@
+
+ Mesa 3.4.1 release notes
+
+ February 9, 2001
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 3.3) designate new developmental releases.
+Even numbered versions (such as 3.4) designate stable releases.
+
+Mesa 3.4.1 is a maintenance release that simply fixes bugs found since
+the Mesa 3.4 release. For details, see the VERSIONS file.
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-3.4.1,v 1.1.1.3 2004/08/12 23:43:27 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-3.4.2 b/nx-X11/extras/Mesa/docs/RELNOTES-3.4.2
new file mode 100644
index 000000000..3d4be7e76
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-3.4.2
@@ -0,0 +1,22 @@
+
+ Mesa 3.4.2 release notes
+
+ May 17, 2001
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 3.3) designate new developmental releases.
+Even numbered versions (such as 3.4) designate stable releases.
+
+Mesa 3.4.2 is a maintenance release that simply fixes bugs found since
+the Mesa 3.4.1 release. For details, see the VERSIONS file.
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-3.4.2,v 1.1.1.3 2004/08/12 23:43:27 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-3.5 b/nx-X11/extras/Mesa/docs/RELNOTES-3.5
new file mode 100644
index 000000000..d0bba7f5b
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-3.5
@@ -0,0 +1,228 @@
+
+ Mesa 3.5 release notes
+
+ June 21, 2001
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 3.5) designate new developmental releases.
+Even numbered versions (such as 3.4) designate stable releases.
+
+The biggest change in Mesa 3.5 is a complete overhaul of the source
+code in order to make it more modular. This was driven by the DRI
+hardware drivers. It simplifies the DRI drivers and opens the door
+to hardware transform/clip/lighting (TCL). Keith Whitwell can take
+the credit for that.
+
+
+
+Driver Support
+--------------
+
+The device driver interface in Mesa 3.5 has changed a lot since Mesa 3.4
+Not all of the older Mesa drivers have been updated. Here's the status:
+
+Driver Status
+---------------------- -----------
+XMesa (Xlib) updated
+OSMesa (off-screen) updated
+FX (3dfx Voodoo1/2) updated
+SVGA updated
+GGI not updated
+Windows/Win32 not updated
+DOS/DJGPP not updated
+BeOS not updated
+Allegro not updated
+D3D not updated
+DOS not updated
+
+We're looking for volunteers to update the remaining drivers. Please
+post to the Mesa3d-dev mailing list if you can help.
+
+
+
+GLU 1.3
+-------
+
+Mesa 3.5 includes the SGI Sample Implementation (SI) GLU library.
+This version of GLU supports the GLU 1.3 specification. The old
+Mesa GLU library implemented the 1.1 specification. The SI GLU
+library should work much better.
+
+You'll need a C++ compiler to compile the SI GLU library. This may
+be a problem on some systems.
+
+
+
+New Extensions
+--------------
+
+GL_EXT_convolution
+ Adds image convolution to glRead/Copy/DrawPixels/TexImage.
+
+GL_ARB_imaging
+ This is the optional imaging subset of OpenGL 1.2.
+ It's the GL_EXT_convolution, GL_HP_convolution_border_modes,
+ GL_EXT_histogram, GL_EXT_color_table, GL_EXT_color_subtable
+ GL_EXT_blend_color, GL_EXT_blend_minmax, GL_EXT_blend_subtract
+ and GL_SGI_color_matrix extensions all rolled together.
+ This is supported in all software renderers but not in all
+ hardware drivers (3dfx for example).
+
+GL_ARB_texture_compression
+ This is supported in Mesa but only used by the 3dfx DRI drivers
+ for Voodoo4 and later.
+
+GL_ARB_texture_env_add
+ This is identical to GL_EXT_texture_env_add.
+
+GL_NV_blend_square
+ Adds extra blend source and dest factors which allow squaring
+ of color values.
+
+GL_EXT_fog_coord
+ Allows specification of a per-vertex fog coordinate instead of
+ having fog always computed from the eye distance.
+
+GL_EXT_secondary_color
+ Allows specifying the secondary (specular) color for each vertex
+ instead of getting it only from lighting in GL_SEPARATE_SPECULAR_COLOR
+ mode.
+
+GL_ARB_texture_env_combine
+ Basically the same as GL_EXT_texture_env_combine
+
+GL_ARB_texture_env_add extension
+ Texture addition mode.
+
+GL_ARB_texture_env_dot3 extension
+ Dot product texture environment.
+
+GL_ARB_texture_border_clamp
+ Adds GL_CLAMP_TO_BORDER_ARB texture wrap mode
+
+GL_SGIX_depth_texture, GL_SGIX_shadow and GL_SGIX_shadow_ambient
+ Implements a shadow casting algorithm based on depth map textures
+
+GL_SGIS_generate_mipmap
+ Automatically generate lower mipmap images whenever the base mipmap
+ image is changed with glTexImage, glCopyTexImage, etc.
+
+
+
+libOSMesa.so
+------------
+
+libOSMesa.so is a new library which contains the OSMesa interface for
+off-screen rendering. Apps which need the OSMesa interface should link
+with both -lOSMesa and -lGL. This change was made so that stand-alone
+Mesa works the same way as XFree86/DRI's libGL.
+
+
+
+Device Driver Changes / Core Mesa Changes
+-----------------------------------------
+
+The ctx->Driver.LogicOp() function has been removed. It used to
+be called during state update in order to determine if the driver
+could do glLogicOp() operations, and if not, set the SWLogicOpEnabled
+flag. Drivers should instead examine the LogicOp state themselves
+and choose specialized point, line, and triangle functions appropriately,
+or fall back to software rendering. The Xlib driver was the only driver
+to use this function. And since the Xlib driver no longer draws
+points, lines or triangles using Xlib, the LogicOp function isn't needed.
+
+The ctx->Driver.Dither() function has been removed. Drivers should
+detect dither enable/disable via ctx->Driver.Enable() instead.
+
+The ctx->Driver.IndexMask() and ctx->Driver.ColorMask() functions
+are now just called from glIndexMask and glColorMask like the other
+GL state-changing functions. They are no longer called from inside
+gl_update_state(). Also, they now return void. The change was made
+mostly for sake of uniformity.
+
+The NEW_DRVSTATE[0123] flags have been removed. They weren't being used
+and are obsolete w.r.t. the way state updates are done in DRI drivers.
+
+
+Removed obsolete gl_create_visual() and gl_destroy_visual().
+
+Renamed functions (new namespace):
+
+old new
+gl_create_framebuffer _mesa_create_framebuffer
+gl_destroy_framebuffer _mesa_destroy_framebuffer
+gl_create_context _mesa_create_context
+gl_destroy_context _mesa_destroy_context
+gl_context_initialize _mesa_context_initialize
+gl_copy_context _mesa_copy_context
+gl_make_current _mesa_make_current
+gl_make_current2 _mesa_make_current2
+gl_get_current_context _mesa_get_current_context
+gl_flush_vb _mesa_flush_vb
+gl_warning _mesa_warning
+gl_compile_error _mesa_compile_error
+
+
+All the drivers have been updated, but not all of them have been
+tested since I can't test some platforms (DOS, Windows, Allegro, etc).
+
+
+X/Mesa Driver
+-------------
+
+The source files for the X/Mesa driver in src/X have been renamed.
+The xmesa[1234].c files are gone. The new files are xm_api.c,
+xm_dd.c, xm_line.c, xm_span.c and xm_tri.c.
+
+
+
+Multitexture
+------------
+
+Eight texture units are now supported by default.
+
+
+
+OpenGL SI related changes
+-------------------------
+
+In an effort to make Mesa's internal interfaces more like the OpenGL
+SI interfaces, a number of changes have been made:
+
+1. Importing the SI's glcore.h file which defines a number of
+interface structures like __GLimports and __GLexports.
+
+2. Renamed "struct gl_context" to "struct __GLcontextRec".
+
+3. Added __glCoreCreateContext() and __glCoreNopDispatch() functions.
+
+4. The GLcontext member Visual is no longer a pointer.
+
+5. New file: imports.c to setup default import functions for Mesa.
+
+
+
+
+16-bit color channels
+---------------------
+
+There's experimental support for 16-bit color channels (64-bit pixels)
+in Mesa 3.5. Only the OSMesa interface can be used for 16-bit rendering.
+Type "make linux-osmesa16" in the top-level directory to build the
+special libOSMesa16.so library.
+
+This hasn't been tested very thoroughly yet so please file bug reports
+if you have trouble.
+
+In the future I hope to implement support for 32-bit, floating point
+color channels.
+
+----------------------------------------------------------------------
+$Id: RELNOTES-3.5,v 1.1.1.3 2004/08/12 23:43:27 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-4.0 b/nx-X11/extras/Mesa/docs/RELNOTES-4.0
new file mode 100644
index 000000000..125a7020e
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-4.0
@@ -0,0 +1,163 @@
+
+ Mesa 4.0 release notes
+
+ October 18, 2001
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 3.3) designate new developmental releases.
+Even numbered versions (such as 3.4) designate stable releases.
+
+Mesa version 4.0 signifies two things:
+
+ 1. A stabilization of the 3.5 development release
+ 2. Implementation of the OpenGL 1.3 specification
+
+
+Note that the Mesa major version number is incremented with the OpenGL
+minor version number:
+
+ Mesa 1.x == OpenGL 1.0
+ Mesa 2.x == OpenGL 1.1
+ Mesa 3.x == OpenGL 1.2
+ Mesa 4.x == OpenGL 1.3
+
+
+
+New Features
+------------
+
+Mesa 3.5 already had all the new features of OpenGL 1.3, implemented as
+extensions. These extensions were simply promoted to standard features:
+
+ GL_ARB_multisample
+ GL_ARB_multitexture
+ GL_ARB_texture_border_clamp
+ GL_ARB_texture_compression
+ GL_ARB_texture_cube_map
+ GL_ARB_texture_env_add
+ GL_ARB_texture_env_combine
+ GL_ARB_texture_env_dot3
+ GL_ARB_transpose_matrix
+
+In Mesa 4.0 the functions defined by these extensions are now available
+without the "ARB" suffix. For example, glLoadTransposeMatrixf() is now
+a standard API function. The new functions in OpenGL 1.3 and Mesa 4.0 are:
+
+ glActiveTexture
+ glClientActiveTexture
+ glCompressedTexImage1D
+ glCompressedTexImage2D
+ glCompressedTexImage3D
+ glCompressedTexSubImage1D
+ glCompressedTexSubImage2D
+ glCompressedTexSubImage3D
+ glGetCompressedTexImage
+ glLoadTransposeMatrixd
+ glLoadTransposeMatrixf
+ glMultiTexCoord1d
+ glMultiTexCoord1dv
+ glMultiTexCoord1f
+ glMultiTexCoord1fv
+ glMultiTexCoord1i
+ glMultiTexCoord1iv
+ glMultiTexCoord1s
+ glMultiTexCoord1sv
+ glMultiTexCoord2d
+ glMultiTexCoord2dv
+ glMultiTexCoord2f
+ glMultiTexCoord2fv
+ glMultiTexCoord2i
+ glMultiTexCoord2iv
+ glMultiTexCoord2s
+ glMultiTexCoord2sv
+ glMultiTexCoord3d
+ glMultiTexCoord3dv
+ glMultiTexCoord3f
+ glMultiTexCoord3fv
+ glMultiTexCoord3i
+ glMultiTexCoord3iv
+ glMultiTexCoord3s
+ glMultiTexCoord3sv
+ glMultiTexCoord4d
+ glMultiTexCoord4dv
+ glMultiTexCoord4f
+ glMultiTexCoord4fv
+ glMultiTexCoord4i
+ glMultiTexCoord4iv
+ glMultiTexCoord4s
+ glMultiTexCoord4sv
+ glMultTransposeMatrixd
+ glMultTransposeMatrixf
+ glSampleCoverage
+ glSamplePass
+
+
+GLX 1.4 is the companion to OpenGL 1.3. The only new features in GLX 1.4
+are support for multisampling and the GLX_ARB_get_proc_address extension.
+glXGetProcAddress() is the only new function in GLX 1.4.
+
+
+
+Multisample and Texture Compression
+-----------------------------------
+
+The OpenGL 1.3 specification allows the multisample and texture compression
+features to essentially be no-ops. For example, if you query for multisample
+support you'll find none, but the API functions work.
+
+Similarly, texture compression is not implemented by any of the software
+drivers but you can specify a generic compressed texture format (like
+GL_COMPRESSED_RGBA) to glTexImage2D and it'll be accepted.
+
+
+
+Device Drivers
+--------------
+
+Mesa advertises itself as either OpenGL 1.2 or OpenGL 1.3 depending on the
+device driver. If the driver enables all the ARB extensions which are part
+of OpenGL 1.3 then glGetString(GL_VERSION) will return "1.3". Otherwise,
+it'll return "1.2".
+
+A number of Mesa's software drivers haven't been actively maintained for
+some time. We rely on volunteers to maintain many of the drivers.
+Here's the current status of all included drivers:
+
+
+Driver Status
+---------------------- ---------------------
+XMesa (Xlib) implements OpenGL 1.3
+OSMesa (off-screen) implements OpenGL 1.3
+FX (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA implements OpenGL 1.3
+Wind River UGL implements OpenGL 1.3
+Windows/Win32 implements OpenGL 1.3
+GGI needs updating
+DOS/DJGPP needs updating
+BeOS needs updating
+Allegro needs updating
+D3D needs updating
+DOS needs updating
+
+Special thanks go to Karl Schultz for updating the Windows driver.
+
+The XFree86/DRI drivers have not yet been updated to use Mesa 4.0 as of
+September 2001, but that should happen eventually.
+
+
+
+Other Changes
+-------------
+
+See the VERSIONS file for more details about bug fixes, etc. in Mesa 4.0.
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-4.0,v 1.1.1.4 2004/08/12 23:43:27 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-4.0.1 b/nx-X11/extras/Mesa/docs/RELNOTES-4.0.1
new file mode 100644
index 000000000..52490d23b
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-4.0.1
@@ -0,0 +1,22 @@
+
+ Mesa 4.0.1 release notes
+
+ December 17, 2001
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 3.3) designate new developmental releases.
+Even numbered versions (such as 3.4) designate stable releases.
+
+Mesa 4.0.1 only contains bug fixes since version 4.0.
+
+See the docs/VERSIONS file for the list of bug fixes.
+
+----------------------------------------------------------------------
+$Id: RELNOTES-4.0.1,v 1.1.1.4 2004/08/12 23:43:27 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-4.0.2 b/nx-X11/extras/Mesa/docs/RELNOTES-4.0.2
new file mode 100644
index 000000000..ed697ca50
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-4.0.2
@@ -0,0 +1,50 @@
+
+ Mesa 4.0.2 release notes
+
+ March 25, 2002
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 3.3) designate new developmental releases.
+Even numbered versions (such as 3.4) designate stable releases.
+
+Mesa 4.0.2 only contains bug fixes and a new DOS driver since version 4.0.1.
+
+See the docs/VERSIONS file for the list of bug fixes.
+
+
+Device Drivers
+--------------
+
+Mesa advertises itself as either OpenGL 1.2 or OpenGL 1.3 depending on the
+device driver. If the driver enables all the ARB extensions which are part
+of OpenGL 1.3 then glGetString(GL_VERSION) will return "1.3". Otherwise,
+it'll return "1.2".
+
+A number of Mesa's software drivers haven't been actively maintained for
+some time. We rely on volunteers to maintain many of the drivers.
+Here's the current status of all included drivers:
+
+Driver Status
+---------------------- ---------------------
+XMesa (Xlib) implements OpenGL 1.3
+OSMesa (off-screen) implements OpenGL 1.3
+FX (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA implements OpenGL 1.3
+Wind River UGL implements OpenGL 1.3
+Windows/Win32 implements OpenGL 1.3
+DOS/DJGPP implements OpenGL 1.3 (new in Mesa 4.0.2)
+GGI needs updating
+BeOS needs updating
+Allegro needs updating
+D3D needs updating
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-4.0.2,v 1.1.1.5 2004/08/12 23:43:27 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-4.0.3 b/nx-X11/extras/Mesa/docs/RELNOTES-4.0.3
new file mode 100644
index 000000000..053813dd0
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-4.0.3
@@ -0,0 +1,52 @@
+
+ Mesa 4.0.3 release notes
+
+ June 25, 2002
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 3.3) designate new developmental releases.
+Even numbered versions (such as 3.4) designate stable releases.
+
+Mesa 4.0.3 basically just contains bug fixes version 4.0.2.
+
+See the docs/VERSIONS file for the list of bug fixes.
+
+The GGI driver has been updated, thanks to Filip Spacek.
+
+
+Device Drivers
+--------------
+
+Mesa advertises itself as either OpenGL 1.2 or OpenGL 1.3 depending on the
+device driver. If the driver enables all the ARB extensions which are part
+of OpenGL 1.3 then glGetString(GL_VERSION) will return "1.3". Otherwise,
+it'll return "1.2".
+
+A number of Mesa's software drivers haven't been actively maintained for
+some time. We rely on volunteers to maintain many of the drivers.
+Here's the current status of all included drivers:
+
+Driver Status
+---------------------- ---------------------
+XMesa (Xlib) implements OpenGL 1.3
+OSMesa (off-screen) implements OpenGL 1.3
+FX (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA implements OpenGL 1.3
+Wind River UGL implements OpenGL 1.3
+Windows/Win32 implements OpenGL 1.3
+DOS/DJGPP implements OpenGL 1.3 (new in Mesa 4.0.2)
+GGI implements OpenGL 1.3
+BeOS needs updating
+Allegro needs updating
+D3D needs updating
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-4.0.3,v 1.1.1.5 2004/08/12 23:43:27 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-4.1 b/nx-X11/extras/Mesa/docs/RELNOTES-4.1
new file mode 100644
index 000000000..7bb790190
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-4.1
@@ -0,0 +1,308 @@
+
+ Mesa 4.1 release notes
+
+ October 29, 2002
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Even numbered versions (such as 4.0) designate stable releases.
+Odd numbered versions (such as 4.1) designate new developmental releases.
+
+
+New Features in Mesa 4.1
+------------------------
+
+New extensions. Docs at http://oss.sgi.com/projects/ogl-sample/registry/
+
+GL_NV_vertex_program
+
+ NVIDIA's vertex programming extension
+
+GL_NV_vertex_program1_1
+
+ A few features built on top of GL_NV_vertex_program
+
+GL_ARB_window_pos
+
+ This is the ARB-approved version of GL_MESA_window_pos
+
+GL_ARB_depth_texture
+
+ This is the ARB-approved version of GL_SGIX_depth_texture.
+ It allows depth (Z buffer) data to be stored in textures.
+ This is used by GL_ARB_shadow
+
+GL_ARB_shadow
+
+ Shadow mapping with depth textures.
+ This is the ARB-approved version of GL_SGIX_shadow.
+
+GL_ARB_shadow_ambient
+
+ Allows one to specify the luminance of shadowed pixels.
+ This is the ARB-approved version of GL_SGIX_shadow_ambient.
+
+GL_EXT_shadow_funcs
+
+ Extends the set of GL_ARB_shadow texture comparision functions to
+ include all eight of standard OpenGL dept-test functions.
+
+GL_ARB_point_parameters
+
+ This is basically the same as GL_EXT_point_parameters.
+
+GL_ARB_texture_env_crossbar
+
+ Allows any texture combine stage to reference any texture source unit.
+
+GL_NV_point_sprite
+
+ For rendering points as textured quads. Useful for particle effects.
+
+GL_NV_texture_rectangle (new in 4.0.4 actually)
+
+ Allows one to use textures with sizes that are not powers of two.
+ Note that mipmapping and several texture wrap modes are not allowed.
+
+GL_EXT_multi_draw_arrays
+
+ Allows arrays of vertex arrays to be rendered with one call.
+
+GL_EXT_stencil_two_side
+
+ Separate stencil modes for front and back-facing polygons.
+
+GLX_SGIX_fbconfig & GLX_SGIX_pbuffer
+
+ Off-screen rendering support.
+
+GL_ATI_texture_mirror_once
+
+ Adds two new texture wrap modes: GL_MIRROR_CLAMP_ATI and
+ GL_MIRROR_CLAMP_TO_EDGE_ATI.
+
+
+
+Device Driver Status
+--------------------
+
+A number of Mesa's software drivers haven't been actively maintained for
+some time. We rely on volunteers to maintain many of these drivers.
+Here's the current status of all included drivers:
+
+
+Driver Status
+---------------------- ---------------------
+XMesa (Xlib) implements OpenGL 1.3
+OSMesa (off-screen) implements OpenGL 1.3
+FX (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA implements OpenGL 1.3
+Wind River UGL implements OpenGL 1.3
+Windows/Win32 implements OpenGL 1.3
+DOS/DJGPP implements OpenGL 1.3
+GGI implements OpenGL 1.3
+BeOS needs updating (underway)
+Allegro needs updating
+D3D needs updating
+DOS needs updating
+
+
+
+New features in GLUT
+--------------------
+
+1. Frames per second printing
+
+ GLUT now looks for an environment variable called "GLUT_FPS". If it's
+ set, GLUT will print out a frames/second statistic to stderr when
+ glutSwapBuffers() is called. By default, frames/second is computed
+ and displayed once every 5 seconds. You can specify a different
+ interval (in milliseconds) when you set the env var. For example
+ 'export GLUT_FPS=1000' or 'setenv GLUT_FPS 1000' will set the interval
+ to one second.
+
+ NOTE: the demo or application must call the glutInit() function for
+ this to work. Otherwise, the env var will be ignored.
+
+ Finally, this feature may not be reliable in multi-window programs.
+
+
+2. glutGetProcAddress() function
+
+ The new function:
+
+ void *glutGetProcAddress(const char *procName)
+
+ is a wrapper for glXGetProcAddressARB() and wglGetProcAddress(). It
+ lets you dynamically get the address of an OpenGL function at runtime.
+ The GLUT_API_VERSION has been bumped to 5, but I haven't bumped the
+ GLUT version number from 3.7 since that's probably Mark Kilgard's role.
+
+ This function should probably also be able to return the address of
+ GLUT functions themselves, but it doesn't do that yet.
+
+
+
+XXX Things To Do Yet XXXX
+-------------------------
+
+isosurf with vertex program exhibits some missing triangles (probably
+when recycling the vertex buffer for long prims).
+
+
+
+Porting Info
+------------
+
+If you're porting a DRI or other driver from Mesa 4.0.x to Mesa 4.1 here
+are some things to change:
+
+1. ctx->Texture._ReallyEnabled is obsolete.
+
+ Since there are now 5 texture targets (1D, 2D, 3D, cube and rect) that
+ left room for only 6 units (6*5 < 32) in this field.
+ This field is being replaced by ctx->Texture._EnabledUnits which has one
+ bit per texture unit. If the bit k of _EnabledUnits is set, that means
+ ctx->Texture.Unit[k]._ReallyEnabled is non-zero. You'll have to look at
+ ctx->Texture.Unit[k]._ReallyEnabled to learn if the 1D, 2D, 3D, cube or
+ rect texture is enabled for unit k.
+
+ This also means that the constants TEXTURE1_*, TEXTURE2_*, etc are
+ obsolete.
+
+ The tokens TEXTURE0_* have been replaced as well (since there's no
+ significance to the "0" part:
+
+ old token new token
+ TEXTURE0_1D TEXTURE_1D_BIT
+ TEXTURE0_2D TEXTURE_2D_BIT
+ TEXTURE0_3D TEXTURE_3D_BIT
+ TEXTURE0_CUBE TEXTURE_CUBE_BIT
+ <none> TEXTURE_RECT_BIT
+
+ These tokens are only used for the ctx->Texture.Unit[i].Enabled and
+ ctx->Texture.Unit[i]._ReallyEnabled fields. Exactly 0 or 1 bits will
+ be set in _ReallyEnabled at any time!
+
+ Q: "What's the purpose of Unit[i].Enabled vs Unit[i]._ReallyEnabled?"
+ A: The user can enable GL_TEXTURE_1D, GL_TEXTURE_2D, etc for any
+ texure unit all at once (an unusual thing to do).
+ OpenGL defines priorities that basically say GL_TEXTURE_2D has
+ higher priority than GL_TEXTURE_1D, etc. Also, just because a
+ texture target is enabled by the user doesn't mean we'll actually
+ use that texture! If a texture object is incomplete (missing mip-
+ map levels, etc) it's as if texturing is disabled for that target.
+ The _ReallyEnabled field will have a bit set ONLY if the texture
+ target is enabled and complete. This spares the driver writer from
+ examining a _lot_ of GL state to determine which texture target is
+ to be used.
+
+
+2. Tnl tokens changes
+
+ During the implementation of GL_NV_vertex_program some of the vertex
+ buffer code was changed. Specifically, the VERT_* bits defined in
+ tnl/t_context.h have been renamed to better match the conventions of
+ GL_NV_vertex_program. The old names are still present but obsolete.
+ Drivers should use the newer names.
+
+ For example: VERT_RGBA is now VERT_BIT_COLOR0 and
+ VERT_SPEC_RGB is now VERT_BIT_COLOR1.
+
+
+
+3. Read/Draw Buffer changes
+
+ The business of setting the current read/draw buffers in Mesa 4.0.x
+ was complicated. It's much simpler now in Mesa 4.1.
+
+ Here are the changes:
+
+ - Renamed ctx->Color.DrawDestMask to ctx->Color._DrawDestMask
+ - Removed ctx->Color.DriverDrawBuffer
+ - Removed ctx->Pixel.DriverReadBuffer
+ - Removed ctx->Color.MultiDrawBuffer
+ - Removed ctx->Driver.SetDrawBuffer()
+ - Removed swrast->Driver.SetReadBuffer().
+ - Added ctx->Color._DrawDestMask - a bitmask of FRONT/BACK_LEFT/RIGHT_BIT
+ values to indicate the current draw buffers.
+ - Added ctx->Pixel._ReadSrcMask to indicate the source for pixel reading.
+ The value is _one_ of the FRONT/BACK_LEFT/RIGHT_BIT values.
+ - Added ctx->Driver.DrawBuffer() and ctx->Driver.ReadBuffer().
+ These functions exactly correspond to glDrawBuffer and glReadBuffer calls.
+ Many drivers will set ctx->Driver.DrawBuffer = _swrast_DrawBuffer and
+ leave ctx->Draw.ReadBuffer NULL.
+ DRI drivers should implement their own function for ctx->Driver.DrawBuffer
+ and use it to set the current hardware drawing buffer. You'll probably
+ also want to check for GL_FRONT_AND_BACK mode and fall back to software.
+ Call _swrast_DrawBuffer() too, to update the swrast state.
+ - Added swrast->Driver.SetBuffer().
+ This function should be implemented by all device drivers that use swrast.
+ Mesa will call it to specify the buffer to use for span reading AND
+ writing and point/line/triangle rendering.
+ There should be no confusion between current read or draw buffer anymore.
+ - Added swrast->CurrentBuffer to indicate which color buffer to read/draw.
+ Will be FRONT_LEFT_BIT, BACK_LEFT_BIT, FRONT_RIGHT_BIT or BACK_RIGHT_BIT.
+ This value is usually passed to swrast->Driver.SetBuffer().
+
+
+4. _mesa_create_context() changes. This function now takes a pointer to
+ a __GLimports object. The __GLimports structure contains function
+ pointers to system functions like fprintf(), malloc(), etc.
+ The _mesa_init_default_imports() function can be used to initialize
+ a __GLimports object. Most device drivers (like the DRI drivers)
+ should use this.
+
+
+5. In tnl's struct vertex_buffer, the field "ProjectedClipCoords"
+ has been replaced by "NdcPtr" to better match the OpenGL spec's
+ terminology.
+
+
+6. Since GL_EXT_stencil_two_side has been implemented, many of the
+ ctx->Stencil fields are now 2-element arrays. For example,
+ "GLenum Ref" is now "GLenum Ref[2]" The [0] elements are the front-face
+ values and the [1] elements are the back-face values.
+ ctx->Stencil.ActiveFace is 0 or 1 to indicate the current face for
+ the glStencilOp/Func/Mask() functions.
+ ctx->Stencil.TestTwoSide controls whether or not 1 or 2-sided stenciling
+ is enabled.
+
+
+7. Removed ctx->Polygon._OffsetAny. Removed ctx->Polygon.OffsetMRD.
+
+
+8. GLfloat / GLchan changes:
+
+ - Changed ctx->Driver.ClearColor() to take GLfloat[4] instead of GLchan[4].
+ ctx->Color.ClearColor is now GLfloat[4] too.
+ - Changed ctx->Driver.AlphaRef() to take GLfloat instead of GLchan.
+ - ctx->Color.AlphaRef is now GLfloat.
+ - texObj->BorderColor is now GLfloat[4]. texObj->_BorderChan is GLchan[4].
+
+ This is part of an effort to remove all GLchan types from core Mesa so
+ that someday we can support 8, 16 and 32-bit color channels dynamically
+ at runtime, instead of at compile-time.
+
+
+9. GLboolean ctx->Tranform.ClipEnabled[MAX_CLIP_PLANES] has been replaced
+ by GLuint ctx->Transform.ClipPlanesEnabled. The later is a bitfield.
+
+
+10. There's a new matrix_stack type in mtypes.h used for the Modelview,
+ Projection, Color and Texcoord matrix stacks.
+
+
+11. The ctx->Current.* fields have changed a lot. Now, there's a
+ ctx->Current.Attrib[] array for all vertex attributes which matches
+ the NV vertex program conventions.
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-4.1,v 1.1.1.5 2004/08/12 23:43:27 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-5.0 b/nx-X11/extras/Mesa/docs/RELNOTES-5.0
new file mode 100644
index 000000000..f83e9e35b
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-5.0
@@ -0,0 +1,85 @@
+
+ Mesa 5.0 release notes
+
+ November 13, 2002
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Even-numbered versions (such as 5.0) designate stable releases.
+Odd-numbered versions (such as 4.1) designate new developmental releases.
+
+Mesa 5.0 is basically just a stabilization of Mesa 4.1. To see a list of
+bug fixes, etc. see the VERSIONS file.
+
+
+
+New Features in Mesa 5.0
+------------------------
+
+Mesa 5.0 supports OpenGL 1.4. Note Mesa's versioning convention:
+
+ OpenGL Version Mesa Version
+ ------------------------------
+ 1.0 1.x
+ 1.1 2.x
+ 1.2 3.x
+ 1.3 4.x
+ 1.4 5.x
+
+OpenGL 1.4 (and Mesa 5.0) incorporates the following OpenGL extensions as
+standard features:
+
+ GL_ARB_depth_texture
+ GL_ARB_shadow
+ GL_ARB_texture_env_crossbar
+ GL_ARB_texture_mirror_repeat
+ GL_ARB_window_pos
+ GL_EXT_blend_color
+ GL_EXT_blend_func_separate
+ GL_EXT_blend_logic_op
+ GL_EXT_blend_minmax
+ GL_EXT_blend_subtract
+ GL_EXT_fog_coord
+ GL_EXT_multi_draw_arrays
+ GL_EXT_point_parameters
+ GL_EXT_secondary_color
+ GL_EXT_stencil_wrap
+ GL_SGIS_generate_mipmap
+
+
+
+Device Driver Status
+--------------------
+
+A number of Mesa's software drivers haven't been actively maintained for
+some time. We rely on volunteers to maintain many of these drivers.
+Here's the current status of all included drivers:
+
+
+Driver Status
+---------------------- ---------------------
+XMesa (Xlib) implements OpenGL 1.4
+OSMesa (off-screen) implements OpenGL 1.4
+FX (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA implements OpenGL 1.3
+Wind River UGL implements OpenGL 1.3
+Windows/Win32 implements OpenGL 1.4
+DOS/DJGPP implements OpenGL 1.3
+GGI implements OpenGL 1.3
+DOS implements OpenGL 1.4
+BeOS needs updating (underway)
+Allegro needs updating
+D3D needs updating
+
+Note: supporting OpenGL 1.4 (vs. 1.3 or 1.2) usually only requires that the
+driver call the _mesa_enable_1_4_extensions() function.
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-5.0,v 1.1.1.5 2004/08/12 23:43:28 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-5.0.1 b/nx-X11/extras/Mesa/docs/RELNOTES-5.0.1
new file mode 100644
index 000000000..d84b46464
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-5.0.1
@@ -0,0 +1,46 @@
+
+ Mesa 5.0.1 release notes
+
+ March 30, 2003
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Even-numbered versions (such as 5.0.x) designate stable releases.
+Odd-numbered versions (such as 4.1.x) designate new developmental releases.
+
+Mesa 5.0.1 just fixes bugs found since the 5.0 release. See the VERSIONS
+file for details.
+
+
+Device Driver Status
+--------------------
+
+A number of Mesa's software drivers haven't been actively maintained for
+some time. We rely on volunteers to maintain many of these drivers.
+Here's the current status of all included drivers:
+
+
+Driver Status
+---------------------- ---------------------
+XMesa (Xlib) implements OpenGL 1.4
+OSMesa (off-screen) implements OpenGL 1.4
+FX (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA implements OpenGL 1.3
+Wind River UGL implements OpenGL 1.3
+Windows/Win32 implements OpenGL 1.4
+DJGPP implements OpenGL 1.4
+GGI implements OpenGL 1.3
+BeOS implements OpenGL 1.4
+Allegro needs updating
+D3D needs updating
+
+Note: supporting OpenGL 1.4 (vs. 1.3 or 1.2) usually only requires that the
+driver call the _mesa_enable_1_4_extensions() function.
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-5.0.1,v 1.1.1.6 2004/08/12 23:43:28 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-5.0.2 b/nx-X11/extras/Mesa/docs/RELNOTES-5.0.2
new file mode 100644
index 000000000..3d3a5e5d9
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-5.0.2
@@ -0,0 +1,46 @@
+
+ Mesa 5.0.2 release notes
+
+ September 5, 2003
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Even-numbered versions (such as 5.0.x) designate stable releases.
+Odd-numbered versions (such as 4.1.x) designate new developmental releases.
+
+Mesa 5.0.2 just fixes bugs found since the 5.0.1 release. See the VERSIONS
+file for details.
+
+
+Device Driver Status
+--------------------
+
+A number of Mesa's software drivers haven't been actively maintained for
+some time. We rely on volunteers to maintain many of these drivers.
+Here's the current status of all included drivers:
+
+
+Driver Status
+---------------------- ---------------------
+XMesa (Xlib) implements OpenGL 1.4
+OSMesa (off-screen) implements OpenGL 1.4
+FX (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA implements OpenGL 1.3
+Wind River UGL implements OpenGL 1.3
+Windows/Win32 implements OpenGL 1.4
+DJGPP implements OpenGL 1.4
+GGI implements OpenGL 1.3
+BeOS implements OpenGL 1.4
+Allegro needs updating
+D3D needs updating
+
+Note: supporting OpenGL 1.4 (vs. 1.3 or 1.2) usually only requires that the
+driver call the _mesa_enable_1_4_extensions() function.
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-5.0.2,v 1.1.1.6 2004/08/12 23:43:28 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-5.1 b/nx-X11/extras/Mesa/docs/RELNOTES-5.1
new file mode 100644
index 000000000..aed6e102b
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-5.1
@@ -0,0 +1,279 @@
+
+ Mesa 5.1 release notes
+
+ December 17, 2003
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Even-numbered versions (such as 5.0) designate stable releases.
+Odd-numbered versions (such as 5.1) designate new developmental releases.
+
+
+Bug fixes
+---------
+See the VERSIONS file for a list of bugs fixed in this release.
+
+
+
+New Features in Mesa 5.1
+------------------------
+
+GL_ARB_vertex_program / GL_ARB_fragment_program
+ Michal Krol and Karl Rasche implemented these extensions. Thanks!
+ Be aware that there may be some rough edges and lurking bugs.
+
+GL_ATI_texture_env_combine3 extension
+ This adds a few new texture combine modes.
+ Contributed by Ian Romanick.
+
+GL_SGI_texture_color_table
+ Adds a color table lookup to the RGBA texture path. There's a separate
+ color table for each texture unit.
+ Contributed by Eric Plante.
+
+GL_NV_fragment_program
+ NVIDIA's fragment-level programming feature.
+ Possible lurking bugs:
+ - the DDX and DDY commands aren't fully tested
+ - there may be bugs in the parser
+ - the TEX and TXP instructions both do perspective correction
+ - the pack/unpack instructions may not be correct
+
+GL_EXT_depth_bounds_test
+ This extension adds a scissor-like test for the Z axis. It's used to
+ optimize stencil-volume shadow algorithms.
+
+GL_NV_light_max_exponent
+ Lifts the 128 limit for max light exponent.
+
+GL_EXT_texture_rectangle
+ Identical to GL_NV_texture_rectangle
+
+GL_ARB_occlusion_query
+ Useful for visibility-based culling.
+
+GL_ARB_texture_non_power_of_two
+ Removes the restriction that texture dimensions must be powers of two.
+
+GL_ARB_vertex_buffer_object
+ Allows server-side vertex arrays, optimized host/card data transfers, etc.
+
+GL_ARB_point_sprite
+ ARB-approved version of GL_NV_point_sprite. Basically allows textures
+ to be applied to points.
+
+GL_IBM_multimode_draw_arrays
+ Allows multiple vertex arrays to be drawn with one call, including arrays
+ of different types of primitives.
+
+GL_SUN_multi_draw_arrays
+ An alias for GL_EXT_multi_draw_arrays, standard in OpenGL 1.4.
+
+Faster glDrawPixels / glCopyPixels in X11 driver
+ If your X screen is 32bpp, glDrawPixels to the front color buffer will
+ be accelerated (via XPutImage()) if the image format is GL_BGRA and the
+ type is GL_UNSIGNED_BYTE. No raster operations, such as depth test,
+ blend, fog, etc. can be enabled.
+
+ If your X screen is 16bpp, glDrawPixels to the front color buffer will
+ be accelerated (via XPutImage()) if the image format is GL_RGB and the
+ type is GL_UNSIGNED_SHORT_5_6_5. No raster operations, such as depth
+ test, blend, fog, etc. can be enabled.
+
+ glCopyPixels() calls for the front color buffer will be accelerated
+ (via XCopyArea()) if no raster operations, such as depth test, blend,
+ fog, pixel zoom, etc. are enabled.
+
+ The speed-up over typical software rendering is a factor of 10 for
+ glDrawPixels and 100 for glCopyPixels.
+
+
+With the addition of GL_ARB_occlusion_query, GL_ARB_vertex_buffer_object,
+GL_ARB_texture_non_power_of_two and GL_EXT_shadow_funcs, Mesa 5.1 supports
+all the new features of OpenGL 1.5. Mesa 6.0 (the next stable release)
+will advertise GL_VERSION = "1.5".
+
+
+
+Vertex/Fragment program debugger
+--------------------------------
+
+GL_MESA_program_debug is an experimental extension to support
+interactive debugging of vertex and fragment programs. See the
+docs/MESA_program_debug.spec file for details.
+
+The bulk of the vertex/fragment program debugger is implemented
+outside of Mesa. The GL_MESA_program_debug extension just has minimal
+hooks for stopping running programs and inspecting programs.
+
+The progs/tests/debugger.c (only in CVS) program is an example of how
+the extension can be used. Presently, the debugger code and demo code
+is in the same file. Eventually the debugger code should be moved
+into a reusable module.
+
+As it is now, the demo lets you set breakpoings in vertex/fragment
+programs, single step, and print intermediate register values. It's
+basically just a proof of concept.
+
+
+
+Directory tree reorganization
+-----------------------------
+
+The directory structure for Mesa has been overhauled to improve its layout.
+All source code for Mesa, GLU, GLUT, etc is now under the src/ directory
+in appropriate subdirectories.
+
+The Mesa source code and drivers has been reorganized under src/mesa/.
+
+All demonstration programs and tests are now in subdirectories under progs/.
+
+
+
+Build System Changes
+--------------------
+
+The GNU automake/autoconf support has been removed. As it was, it seldom
+worked on anything but Linux. The Mesa developers aren't big fans of
+automake/autoconf/libtool and didn't have the time to maintain it.
+If someone wants to contribute new automake/autoconf support (and is
+willing to maintain it), it may be re-incorporated into Mesa, subject
+to some requirements.
+
+The "old style" makefile system has been updated:
+ 1. Make-config has been trimmed down to fewer, modern configurations.
+ 2. Most of the bin/mklib.* scripts have been rolled into a new "mklib"
+ script that works on all sorts of systems. There are probably some
+ bugs in it, but it's been tested on Linux, SunOS 5.8 and IRIX 6.5.
+ Improvements/contributes are greatly appreciated.
+ 3. The Makefile.X11 files have been cleaned up in various ways
+
+
+
+Source File Changes
+-------------------
+
+The mmath.[ch] files are obsolete. Their contents have been moved
+into the imports.[ch] and macros.[ch] files.
+
+The files related to vertex and fragment programming have changed.
+Old files:
+ vpexec.[ch]
+ vpparse.[ch]
+ vpstate.[ch]
+New files:
+ program.[ch] - generic ARB/NV program code
+ arbprogram.[ch] - ARB program API functions
+ arbfragparse.[ch] - ARB fragment program parsing
+ arbvertparse.[ch] - ARB vertex program parsing
+ arbparse.[ch] - ARB vertex/fragment parsing
+ arbparse_syn.h - vertex/fragment program syntax
+ nvprogram.[ch] - NV program API functions
+ nvvertprog.h - NV vertex program definitions
+ nvfragprog.h - NV fragment program definitions
+ nvvertparse.[ch] - NV vertex program parser
+ nvfragparse.[ch] - NV fragment program parser
+ nvvertexec.[ch] - NV vertex program execution
+ swrast/s_nvfragprog.[ch] - NV fragment program execution
+
+The files related to per-vertex handling have changed.
+Old files:
+ tnl/t_eval_api.c - old per-vertex code
+ tnl/t_imm_alloc.c - old per-vertex code
+ tnl/t_imm_api.c - old per-vertex code
+ tnl/t_imm_debug.c - old per-vertex code
+ tnl/t_imm_dlist.c - old per-vertex code
+ tnl/t_imm_elt.c - old per-vertex code
+ tnl/t_imm_eval.c - old per-vertex code
+ tnl/t_imm_exec.c - old per-vertex code
+ tnl/t_imm_fixup.c - old per-vertex code
+ tnl/t_vtx_sse.c - old per-vertex code
+ tnl/t_vtx_x86.c - old per-vertex code
+New files:
+ tnl/t_save_api.c - new per-vertex code
+ tnl/t_save_loopback.c - new per-vertex code
+ tnl/t_save_playback.c - new per-vertex code
+ tnl/t_vtx_eval.c - old per-vertex code
+
+Other new files:
+ bufferobj.[ch] - GL_ARB_vertex_buffer_object functions
+ version.h - defines the Mesa version info
+
+Other removed files:
+ swrast/s_histogram.[ch] - moved into src/histogram.c
+
+
+
+Other Changes
+-------------
+
+The ctx->Driver.CreateTexture function has been removed - it wasn't used.
+
+New device driver hook functions:
+ NewTextureObject - used to allocate struct gl_texture_objects
+ NewTextureImage - used to allocate struct gl_texture_images
+
+New ctx->Texture._EnabledCoordUnits field:
+ With the addition of GL_NV_fragment_program we may need to interpolate
+ various sets of texture coordinates even when the corresponding texture
+ unit is not enabled. That is, glEnable(GL_TEXTURE_xD) may never get
+ called but we still may have to interpolate texture coordinates across
+ triangles so that the fragment program will get them.
+ This new field indicates which sets of texture coordinates are needed.
+ If a bit is set in the ctx->Texture._EnabledUnits bitmask is set, the
+ same bit MUST be set in ctx->Texture._EnabledCoordUnits.
+
+The ctx->_TriangleCaps field is deprecated.
+ Instead of testing the DD_* bits in _TriangleCaps, you should instead
+ directly test the relevant state variables, or use one of the helper
+ functions like NEED_SECONDARY_COLOR() at the bottom of context.h
+ While testing _TriangleCaps bits was fast, it was kludgey, and setting
+ the bits in the first place could be error prone.
+
+New vertex processing code.
+ The code behind glBegin, glEnd, glVertex, glNormal, etc. has been
+ totally rewritten. It's a cleaner implementation now and should use
+ less memory. (Keith)
+
+
+
+To Do
+-----
+Add screen-awareness to fakeglx.c
+
+
+
+
+Device Driver Status
+--------------------
+
+A number of Mesa's software drivers haven't been actively maintained for
+some time. We rely on volunteers to maintain many of these drivers.
+Here's the current status of all included drivers:
+
+
+Driver Status
+---------------------- ---------------------
+XMesa (Xlib) implements OpenGL 1.4
+OSMesa (off-screen) implements OpenGL 1.4
+FX (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA implements OpenGL 1.3
+Wind River UGL implements OpenGL 1.3
+Windows/Win32 implements OpenGL 1.4
+DJGPP implements OpenGL 1.4
+GGI implements OpenGL 1.3
+BeOS implements OpenGL 1.4
+Allegro needs updating
+D3D needs updating
+
+Note: supporting OpenGL 1.4 (vs. 1.3 or 1.2) usually only requires that the
+driver call the _mesa_enable_1_4_extensions() function.
+
+
+----------------------------------------------------------------------
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-6.0 b/nx-X11/extras/Mesa/docs/RELNOTES-6.0
new file mode 100644
index 000000000..c154472af
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-6.0
@@ -0,0 +1,87 @@
+
+ Mesa 6.0 release notes
+
+ January 16, 2004
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 5.1) designate new developmental releases.
+Even numbered versions (such as 6.0) designate stable releases.
+
+Mesa version 6.0 signifies two things:
+
+ 1. A stabilization of the 5.1 development release
+ 2. Implementation of the OpenGL 1.5 specification. When you query
+ glGetString(GL_VERSION) "1.5" will be returned (as long as the
+ driver supports all the required features).
+
+
+Note that the Mesa major version number is incremented with the OpenGL
+minor version number:
+
+ Mesa 1.x == OpenGL 1.0
+ Mesa 2.x == OpenGL 1.1
+ Mesa 3.x == OpenGL 1.2
+ Mesa 4.x == OpenGL 1.3
+ Mesa 5.x == OpenGL 1.4
+ Mesa 6.x == OpenGL 1.5
+
+
+
+New Features
+------------
+
+Mesa 5.1 already had all the new features of OpenGL 1.5, implemented as
+extensions. These extensions were simply promoted to standard features:
+
+ GL_ARB_occlusion_query extension
+ GL_ARB_texture_non_power_of_two extension
+ GL_ARB_vertex_buffer_object extension
+ GL_EXT_shadow_funcs
+
+
+
+Device Drivers
+--------------
+
+Mesa advertises itself as either OpenGL 1.2 or OpenGL 1.3 depending on
+the device driver. For example, if the driver enables all the ARB
+extensions which are part of OpenGL 1.3 then glGetString(GL_VERSION)
+will return "1.3". Otherwise, it'll return "1.2".
+
+A number of Mesa's software drivers haven't been actively maintained for
+some time. We rely on volunteers to maintain many of the drivers.
+Here's the current status of all included drivers:
+
+
+Driver Status
+---------------------- ---------------------
+XMesa (Xlib) implements OpenGL 1.5
+OSMesa (off-screen) implements OpenGL 1.5
+FX (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA implements OpenGL 1.3
+Wind River UGL implements OpenGL 1.3
+Windows/Win32 implements OpenGL 1.5
+DJGPP implements OpenGL 1.5
+GGI implements OpenGL 1.3
+BeOS implements OpenGL 1.5
+Allegro needs updating
+D3D needs updating
+
+
+
+
+Other Changes
+-------------
+
+See the VERSIONS file for more details about bug fixes, etc. in Mesa 6.0.
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-6.0,v 1.1.1.3 2004/08/12 23:43:28 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-6.0.1 b/nx-X11/extras/Mesa/docs/RELNOTES-6.0.1
new file mode 100644
index 000000000..063d6f2d4
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-6.0.1
@@ -0,0 +1,50 @@
+
+ Mesa 6.0.1 release notes
+
+ April 2, 2003
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Even-numbered versions (such as 6.0.x) designate stable releases.
+Odd-numbered versions (such as 6.1.x) designate new developmental releases.
+
+Mesa 6.0.1 just fixes bugs found since the 6.0 release. See the VERSIONS
+file for details.
+
+
+
+Device Drivers
+--------------
+
+Mesa advertises itself as supporting OpenGL 1.2, 1.3, 1.4 or 1.5
+depending on the device driver's capabilities. For example, if the
+driver enables all the ARB extensions which are part of OpenGL 1.5
+then glGetString(GL_VERSION) will return "1.5". Otherwise, it'll
+return "1.4" or the next lower version that implements all required
+functionality.
+
+A number of Mesa's software drivers haven't been actively maintained for
+some time. We rely on volunteers to maintain many of the drivers.
+Here's the current status of all included drivers:
+
+Driver Status
+---------------------- ---------------------
+XMesa (Xlib) implements OpenGL 1.5
+OSMesa (off-screen) implements OpenGL 1.5
+FX (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA implements OpenGL 1.3
+Wind River UGL implements OpenGL 1.3
+Windows/Win32 implements OpenGL 1.5
+DJGPP implements OpenGL 1.5
+GGI implements OpenGL 1.3
+BeOS implements OpenGL 1.5
+Allegro needs updating
+D3D needs updating
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-6.0.1,v 1.1.1.3 2004/08/12 23:43:28 anholt Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-6.1 b/nx-X11/extras/Mesa/docs/RELNOTES-6.1
new file mode 100644
index 000000000..3ae3f02c8
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-6.1
@@ -0,0 +1,112 @@
+
+ Mesa 6.1 release notes
+
+ August 18, 2004
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 6.1) designate new developmental releases.
+Even numbered versions (such as 6.0) designate stable releases.
+
+
+New Features
+------------
+
+Half-precision floating point (GLhalf) pixel formats are supported
+in Mesa, but the feature isn't exposed yet since the ARB extension
+hasn't been finalized yet.
+
+
+Texture image handling
+----------------------
+
+The code which implements image conversion, pixel transfer ops, etc
+for glTexImage commands has been rewritten.
+
+Now the gl_texture_format struct has a new StoreImage function
+pointer. Each texture format must implement this function. The
+function is totally responsible for converting the user's texture
+image into the specific format. A few helper functions makes this
+relatively simple.
+
+Overall, the code is much simpler, cleaner and easier to work with
+now. Adding new texture formats is straight-forward and there's no
+longer any distinction between "hardware" and "software" formats.
+
+Finally, the code for compressed texture images has been reorganized
+as well.
+
+Removed files:
+ texutil.c
+ texutil.h
+ texutil_tmp.h
+
+New files:
+ texcompress_s3tc.c
+ texcompress_fxt1.c
+
+
+
+Driver / context changes
+------------------------
+
+The _mesa_create_context() and _mesa_initialize_context() function
+parameters have changed. They now take a pointer to a struct
+dd_function_table. Drivers can initialize this table by calling
+_mesa_init_driver_functions(). Drivers should then plug in the special
+functions they implement. In particular, the ctx->Driver.NewTextureObject
+pointer _must_ be set so that the default texture objects created in
+_mesa_create/initialize_context() are correctly built.
+
+The _mesa_init_driver_functions() function allows a lot of redundant code
+to be removed from the device drivers (such as initializing
+ctx->Driver.Accum to point to _swrast_Accum). Adding new functions to
+the dd_function_table can be done with less hassle since the pointer can
+be initialized in _mesa_init_driver_functions() rather than in _all_ the
+drivers.
+
+
+Device Drivers
+--------------
+
+Mesa advertises itself as supporting OpenGL 1.2, 1.3, 1.4 or 1.5
+depending on the device driver's capabilities. For example, if the
+driver enables all the ARB extensions which are part of OpenGL 1.5
+then glGetString(GL_VERSION) will return "1.5". Otherwise, it'll
+return "1.4" or the next lower version that implements all required
+functionality.
+
+A number of Mesa's software drivers haven't been actively maintained for
+some time. We rely on volunteers to maintain many of the drivers.
+Here's the current status of all included drivers:
+
+Driver Status
+---------------------- ---------------------
+XMesa (Xlib) implements OpenGL 1.5
+OSMesa (off-screen) implements OpenGL 1.5
+Glide (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA implements OpenGL 1.3
+Wind River UGL implements OpenGL 1.3
+Windows/Win32 implements OpenGL 1.5
+DJGPP implements OpenGL 1.5
+GGI implements OpenGL 1.3
+BeOS implements OpenGL 1.5
+Allegro needs updating
+D3D needs updating
+
+
+
+Other Changes
+-------------
+
+See the VERSIONS file for more details about bug fixes, etc. in Mesa 6.1.
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-6.1,v 1.1.1.4 2004/08/28 04:27:00 kem Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-6.2 b/nx-X11/extras/Mesa/docs/RELNOTES-6.2
new file mode 100644
index 000000000..ad931d065
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-6.2
@@ -0,0 +1,52 @@
+
+ Mesa 6.2 release notes
+
+ October 2, 2004
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 6.1) designate new developmental releases.
+Even numbered versions (such as 6.2) designate stable releases.
+
+
+This release primarily just fixes bugs found in the Mesa 6.1 release.
+See the VERSIONS file for details.
+
+
+ToDo: PBO for polygon stipple, convolution filter, etc.
+
+
+
+Known Issues
+------------
+
+The GL_EXT_pixel_buffer_object extension isn't fully implemented for
+functions like glPolygonStipple, glConvolutionFilter, glColorTable,
+etc. The important functions like glRead/DrawPixels, glTex[Sub]Image,
+and glBitmap work with PBOs.
+
+
+
+Driver Status
+---------------------- ---------------------
+XMesa (Xlib) implements OpenGL 1.5
+OSMesa (off-screen) implements OpenGL 1.5
+Glide (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA implements OpenGL 1.3
+Wind River UGL implements OpenGL 1.3
+Windows/Win32 implements OpenGL 1.5
+DJGPP implements OpenGL 1.5
+GGI implements OpenGL 1.3
+BeOS implements OpenGL 1.5
+Allegro needs updating
+D3D needs updating
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-6.2,v 1.1.1.2 2005/07/31 16:45:50 ajax Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-6.2.1 b/nx-X11/extras/Mesa/docs/RELNOTES-6.2.1
new file mode 100644
index 000000000..ec33f9113
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-6.2.1
@@ -0,0 +1,50 @@
+
+ Mesa 6.2.1 release notes
+
+ December 9, 2004
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 6.1) designate new developmental releases.
+Even numbered versions (such as 6.2.x) designate stable releases.
+
+
+This release primarily just fixes bugs found in the Mesa 6.2 release.
+See the VERSIONS file for details.
+
+
+
+Known Issues
+------------
+
+The GL_EXT_pixel_buffer_object extension isn't fully implemented for
+functions like glPolygonStipple, glConvolutionFilter, glColorTable,
+etc. The important functions like glRead/DrawPixels, glTex[Sub]Image,
+and glBitmap work with PBOs. This has been fixed for Mesa 6.3.
+
+
+
+
+Driver Status
+---------------------- ---------------------
+XMesa (Xlib) implements OpenGL 1.5
+OSMesa (off-screen) implements OpenGL 1.5
+Glide (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA implements OpenGL 1.3
+Wind River UGL implements OpenGL 1.3
+Windows/Win32 implements OpenGL 1.5
+DJGPP implements OpenGL 1.5
+GGI implements OpenGL 1.3
+BeOS implements OpenGL 1.5
+Allegro needs updating
+D3D needs updating
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-6.2.1,v 1.1.1.2 2005/07/31 16:45:45 ajax Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-6.3 b/nx-X11/extras/Mesa/docs/RELNOTES-6.3
new file mode 100644
index 000000000..c61fa98a6
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-6.3
@@ -0,0 +1,115 @@
+
+ Mesa 6.3 release notes
+
+ July 20, 2005
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 6.3) designate new developmental releases.
+Even numbered versions (such as 6.2) designate stable releases.
+
+
+
+New Features
+------------
+
+GL_ARB_draw_buffers - allows a fragment program to write to a number of
+ separate color buffers, instead of just one.
+
+GL_OES_read_format - allows one to query the fastest glReadPixels format
+ and datatype.
+
+GL_ARB_pixel_buffer_object - buffer objects for pixel read/write functions.
+
+GL_EXT_framebuffer_object - allows render-to-texture and provides a
+ window-system indepedent Pbuffer facility.
+ The Mesa CVS tree contains a couple tests of this extension.
+
+DirectFB driver, contributed by Claudio Ciccani. See docs/README.directfb
+for details.
+
+
+
+Vertex/Fragment Program PRINT Instruction
+-----------------------------------------
+
+The GL_NV_vertex_program and GL_NV_fragment_program languages have been
+extended with a PRINT instruction.
+
+
+
+glDeleteTextures(), glDeletePrograms() and glDeleteBuffers() Changed
+--------------------------------------------------------------------
+
+To match the behaviour of other OpenGL implementations, glDeleteTextures,
+glDeletePrograms and glDeleteBuffers have been modified so that:
+
+ * The named texture/program/buffer ID is immediately freed for re-use.
+
+ * The actual texture object, program or buffers isn't really deleted until
+ it is no longer bound in any rendering context (the reference count
+ is zero).
+
+Previously, the texture/program/buffer ID wasn't freed until the object
+was really deleted.
+
+Note that textures, programs and buffers can be shared by several rendering
+contexts so they can't be deleted until they're unbound in _all_ contexts.
+
+
+
+GL_EXT_framebuffer_object changes
+---------------------------------
+
+Implementing this extension involved changing a lot of code (for the better).
+
+The gl_framebuffer object now a collection of gl_renderbuffer objects.
+Renderbuffers may store colors, stencil indices, or depth values. The
+gl_framebuffer and gl_renderbuffer types are object-oriented in design.
+
+All the old RGB, color index, stencil and depth-related span functions for
+reading/writing pixels from/to buffers has changed. Now, all pixels are
+read/written through a set of common renderbuffer functions (methods).
+
+Most device drivers have been updated for these changes, but some haven't.
+
+
+
+To Do (someday) items
+---------------------
+ Switch to freeglut
+ Increase MAX_DRAWBUFFERS
+ driver hooks for BeginQuery/EndQuery
+
+
+
+Miscellaneous
+-------------
+
+The main/get.c file is now generated with a Python script (get_gen.py).
+
+
+
+Driver Status
+---------------------- ---------------------
+XMesa (Xlib) implements OpenGL 1.5
+OSMesa (off-screen) implements OpenGL 1.5
+Glide (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA implements OpenGL 1.3
+Wind River UGL implements OpenGL 1.3
+Windows/Win32 implements OpenGL 1.5
+DJGPP implements OpenGL 1.5
+GGI implements OpenGL 1.3
+BeOS implements OpenGL 1.5
+Allegro needs updating
+D3D needs updating
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-6.3,v 1.1.1.1 2005/07/31 16:45:49 ajax Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-6.3.1 b/nx-X11/extras/Mesa/docs/RELNOTES-6.3.1
new file mode 100644
index 000000000..7d2e4d030
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-6.3.1
@@ -0,0 +1,49 @@
+
+ Mesa 6.3.1 release notes
+
+ July XX, 2005
+
+ PLEASE READ!!!!
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 6.3) designate new developmental releases.
+Even numbered versions (such as 6.2) designate stable releases.
+
+
+
+DRI drivers
+-----------
+
+This release includes the DRI drivers and GLX code for hardware rendering.
+
+
+
+Bug fixes
+---------
+
+Bugs fixed in 6.3.1 are listed in the VERSIONS file.
+
+
+
+Driver Status
+---------------------- ---------------------
+XMesa (Xlib) implements OpenGL 1.5
+OSMesa (off-screen) implements OpenGL 1.5
+Glide (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA implements OpenGL 1.3
+Wind River UGL implements OpenGL 1.3
+Windows/Win32 implements OpenGL 1.5
+DJGPP implements OpenGL 1.5
+GGI implements OpenGL 1.3
+BeOS implements OpenGL 1.5
+Allegro needs updating
+D3D needs updating
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-6.3.1,v 1.1.1.1 2005/07/31 16:45:45 ajax Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-6.3.2 b/nx-X11/extras/Mesa/docs/RELNOTES-6.3.2
new file mode 100644
index 000000000..7cdb08131
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-6.3.2
@@ -0,0 +1,37 @@
+
+ Mesa 6.3.2 Release Notes
+
+ August 19, 2005
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 6.3) designate new developmental releases.
+Even numbered versions (such as 6.2) designate stable releases.
+
+
+6.3.2 is primarily a bug-fix release. See the VERSIONS file for details.
+
+
+
+Driver Status
+---------------------- ----------------------
+DRI drivers varies with the driver
+XMesa (Xlib) implements OpenGL 1.5
+OSMesa (off-screen) implements OpenGL 1.5
+Glide (3dfx Voodoo1/2) implements OpenGL 1.3
+SVGA implements OpenGL 1.3
+Wind River UGL implements OpenGL 1.3
+Windows/Win32 implements OpenGL 1.5
+DJGPP implements OpenGL 1.5
+GGI implements OpenGL 1.3
+BeOS implements OpenGL 1.5
+Allegro needs updating
+D3D needs updating
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-6.3.2,v 1.1.1.1 2005/10/18 02:51:43 kem Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-6.4 b/nx-X11/extras/Mesa/docs/RELNOTES-6.4
new file mode 100644
index 000000000..b9ab4975e
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-6.4
@@ -0,0 +1,50 @@
+
+ Mesa 6.4 Release Notes
+
+ October 24, 2005
+
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 6.3) designate new developmental releases.
+Even numbered versions (such as 6.4) designate stable releases.
+
+
+6.4 is a bug-fix release. See the VERSIONS file for details.
+
+
+
+GLUT tarball
+------------
+
+Starting with 6.4, the GLUT library sources are distributed in a separate
+tarball. This was done at the request of Linux distro vendors who prefer
+to use freeglut.
+
+
+
+
+Driver Status
+---------------------- ----------------------
+DRI drivers varies with the driver
+XMesa (Xlib) implements OpenGL 1.5
+OSMesa (off-screen) implements OpenGL 1.5
+Windows/Win32 implements OpenGL 1.5
+Glide (3dfx Voodoo1/2) requires updates
+SVGA requires updates
+DJGPP requires updates
+GGI requires updates
+BeOS requires updates
+Allegro requires updates
+D3D requires updates
+
+The drivers which require updates mostly need to be updated to work
+with the new gl_renderbuffer / gl_framebuffer infrastructure introduced
+in Mesa 6.3.
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-6.4,v 1.1.1.2 2005/11/09 01:13:43 kem Exp $
diff --git a/nx-X11/extras/Mesa/docs/RELNOTES-6.4.1 b/nx-X11/extras/Mesa/docs/RELNOTES-6.4.1
new file mode 100644
index 000000000..0386f6026
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/RELNOTES-6.4.1
@@ -0,0 +1,47 @@
+
+ Mesa 6.4.1 Release Notes
+
+
+Introduction
+------------
+
+Mesa uses an even/odd version number scheme like the Linux kernel.
+Odd numbered versions (such as 6.3) designate new developmental releases.
+Even numbered versions (such as 6.4) designate stable releases.
+
+
+6.4.1 is a bug-fix release. See the VERSIONS file for details.
+
+
+
+GLUT tarball
+------------
+
+Starting with 6.4, the GLUT library sources are distributed in a separate
+tarball. This was done at the request of Linux distro vendors who prefer
+to use freeglut.
+
+
+
+
+Driver Status
+---------------------- ----------------------
+DRI drivers varies with the driver
+XMesa (Xlib) implements OpenGL 1.5
+OSMesa (off-screen) implements OpenGL 1.5
+Windows/Win32 implements OpenGL 1.5
+Glide (3dfx Voodoo1/2) requires updates
+SVGA requires updates
+DJGPP requires updates
+GGI requires updates
+BeOS requires updates
+Allegro requires updates
+D3D requires updates
+
+The drivers which require updates mostly need to be updated to work
+with the new gl_renderbuffer / gl_framebuffer infrastructure introduced
+in Mesa 6.3.
+
+
+----------------------------------------------------------------------
+$Id: RELNOTES-6.4.1,v 1.1.1.1 2005/12/01 03:11:29 kem Exp $
diff --git a/nx-X11/extras/Mesa/docs/VERSIONS b/nx-X11/extras/Mesa/docs/VERSIONS
new file mode 100644
index 000000000..52d394bd4
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/VERSIONS
@@ -0,0 +1,1423 @@
+
+
+Mesa Version History
+====================
+
+1.0 beta February 1995
+ Initial release
+
+1.1 beta March 4, 1995
+ Changes:
+ faster point and line drawing (2x faster)
+ more systems supported, better Makefiles
+ Renamed lib*.a files to avoid collisions
+ many small bug fixes
+ New:
+ pseudo-GLX functions added
+ new implementation of evaluators (eval2.c)
+ GLUT support
+
+1.1.1 beta March 7, 1995
+ Changes:
+ Reverted from eval2.c to eval.c due to FPE on Linux
+ more speed improvements
+ more Makefile changes
+
+1.1.2 beta March 14, 1995
+ New:
+ implementation of SGI's blending extensions
+ glXUseXFont implemented
+ added MESA_DEBUG environment variable support
+ Changes:
+ Using eval2.c again
+ more FPE-prevention checks (0-length normals are OK)
+ a few small bug fixes
+ much faster pixel logic ops!
+ faster transformation arithmetic
+
+1.1.3 beta March 31, 1995
+ New:
+ gluScaleImage() and gluBuild2DMipMaps() implemented
+ Mesa widgets for Xt/Motif
+ blendEXT demos
+ added environment variables for selecting visuals
+ Changes:
+ almost all GLUT demos work correctly now
+ faster X device driver functions
+ more bug fixes
+
+1.1.4 beta April 20, 1995
+ Bug fixes:
+ - missing #define SEEK_SET in src-tk/image.c
+ - compile glShadeModel into display lists
+ - fixed pow() domain error in src/light.c
+ - fixed "flickering bitmaps" in double buffer mode
+ - fixed tk.h and aux.h for C++
+ - state of LIGHT_MODEL_LOCAL_VIEWER was inverted
+ New features:
+ - MUCH, MUCH nicer dithering in 8-bit RGB mode
+ - updated widgets and widget demos
+ - Implemented GLXPixmap functions
+ - Added GLU 1.1 and GLX 1.1 functions
+ - Changed the X/Mesa interface API, more versatile
+ - Implemented gluPartialDisk()
+
+1.2 May 22, 1995
+ Bug fixes:
+ - IRIX 4.x makefile problem
+ - modified tk to share root colormap as needed
+ - gluLookAt normalization problem
+ - suppress Expose, NoExpose events in swapbuffers
+ - glBitmap() and glDrawPixels() clipping
+ New features:
+ - GL_BLEND, GL_MODULATE, GL_DECAL, and GL_REPLACE_EXT texture
+ modes implemented
+ - texture maps stored more efficiently
+ - texture maps can be compiled into display lists
+ - Bogdan Sikorski's GLU polygon tesselation code
+ - Linas Vepstas's sweep and extrusion library
+ - glXCreateContext()'s shareList parameter works as it's supposed to.
+ XMesaCreateContext() updated to accept a shareList parameter too.
+ - Mesa can be compiled with real OpenGL .h files
+ - MESA_BACK_BUFFER environment variable
+ - better GLX error checking
+
+1.2.1 June 22, 1995
+ Bug fixes:
+ - X/Mesa double buffer window resize crash
+ - widgets now pass PointerMotion events
+ - X/Mesa incorrect default clear color and drawing color
+ - more robust X MIT-SHM support in X/Mesa
+ - glTexImage( format=GL_LUMINANCE ) didn't work
+ - GL_LINE mode polygons with line width > 1.0 could cause a crash
+ - numerous feedback bugs
+ - glReadPixels() from depth buffer was wrong
+ - error prone depth and stencil buffer allocation
+ New features:
+ - Preliminary Microsoft Windows driver
+ - Implemented a number of missing functions: glEvalCoord[12][df]v(),
+ glGet...(), etc.
+ - Added a few missing symbols to gl.h and glu.h
+ - Faster rendering of smooth-shaded, RGBA, depth-buffered polygons.
+ - Faster rendering of lines when width=2.0
+ - Stencil-related functions now work in display lists
+ Changes:
+ - renamed aux.h as glaux.h (MS-DOS names can't start with aux)
+ - most filenames are in 8.3 format to accomodate MS-DOS
+ - use GLubytes to store arrays of colors instead of GLints
+
+1.2.2 August 2, 1995
+ New features:
+ - texture mapped points and lines
+ - NURBS! (but not 100% complete)
+ - viewports may safely extend beyond window boundaries
+ - MESA_PRIVATE_CMAP environment variable
+ - Grayscale X display support
+ - two new demos: demos/gears.c and demos/shadow.c
+ - MachTen for Macintosh configuration
+ Bug fixes:
+ - glGet*(GL_DEPTH_BITS) returned bytes, not bits
+ - point, line, and bitmap rasterization suffered from roundoff errors
+ - fixed a division by zero error in line clippping
+ - occasional wrong default background color really fixed!
+ - glDepthFunc(GL_ALWAYS) with glDepthMask(GL_FALSE) didn't work
+ - gluBuild2DMipmaps malloc problem fixed
+ - view volume clipping of smooth shaded lines resulted in bad colors
+ Changes:
+ - new visual selection method in glXChooseVisual()
+ - improved GLU quadric functions
+ - call XSync for glFinish and XFlush for glFlush
+ - glVertex() calls now use a function pointer to avoid conditionals
+ - removed contrib directory from Mesa tar file (available on ftp site)
+ - AIX shared library support
+ - Removed GLUenum type as it's not in OpenGL
+
+1.2.3 September 26, 1995
+ New features:
+ - Mesa header files now equivalent to SGI OpenGL headers
+ - Support for HP's Color Recovery dithering displays
+ - Faster vertex transformation
+ - Faster raster operations into X windows under certain conditions
+ - New configurations: HP w/ shared libs, Ultrix w/ GCC, Data General
+ - 4-bit visuals now supported
+ Bug fixes:
+ - glScissor bug fixed
+ - round-off errors in clipping lines against clip planes fixed
+ - byte swapping between hosts and display servers implemented
+ - glGetError() can be called without a current rendering context
+ - problem with accidentally culled polygons is fixed
+ - fixed some widget compilation problems
+
+1.2.4 November 17, 1995
+ New features:
+ - More speed improvements (lighting, fogging, polygon drawing)
+ - Window system and OS-independent off-screen rendering
+ - Preliminary Fortran bindings
+ - glPolygonOffsetEXT implemented
+ - glColorMask and glIndexMask now fully implemented
+ - glPixelZoom implemented
+ - display lists fully implemented
+ - gamma correction
+ - dithering in 8-bit TrueColor/DirectColor visuals
+ Changes:
+ - Improved device driver interface
+ - tk.h renamed to gltk.h to avoid conflicts with Tcl's Tk
+ - Dithering support moved from core into device driver
+ Bug fixes:
+ - glEnable/Disable( GL_LIGHTING ) didn't always take effect
+ - glReadPixels byte swapping was broken
+ - glMaterial with pname==GL_AMBIENT_AND_DIFFUSE was broken
+ - duplicate glColor4b() prototype in GL/gl.h removed
+ - stripes in wave -ci demo fixed
+ - GL_LINEAR_MIPMAP_NEAREST had wrong value
+ - bugs in HP Color Recovery support fixed
+ - fixed bug when blending lines, points, bitmaps outside of window
+
+1.2.5 November 30, 1995
+ New Features:
+ - updated MS Windows driver
+ - new implementation of StaticGray/GrayScale visual support
+ Bug fixes:
+ - pixelzooming with gamma correction or blending didn't work
+ - HP color recovery visual wasn't being picked by glXChooseVisual
+ - glClear didn't always observe glColorMask changes
+ - olympic and offset demos didn't compile on some Suns
+ - texcoord clamping wasn't correct
+ - a polygon optimization introduced an occasional sampling problem
+
+1.2.6 January 26, 1996
+ New Features:
+ - faster line and polygon rendering under certain conditions. See
+ Performance Tips 9 and 10 in README
+ - profiling
+ - lighting is a bit faster
+ - better perspective corrected texture mapping
+ - Amiga AmiWin (X11) support
+ - preliminary Linux SVGA driver
+ Changes:
+ - now using a 16-bit depth buffer, faster, smaller
+ - GL_NORMALIZE is disabled by default
+ Bug fixes:
+ - projective texture mapping
+ - fixed a memory leak in the context destroy function
+ - GL_POLYGON with less than 3 vertices caused a crash
+ - glGet*() returned wrong result for GL_INDEX_MODE
+ - reading pixels from an unmapped X window caused a BadMatch error
+
+1.2.7 March 5, 1996
+ New:
+ - faster lighting
+ - faster 16-bit TrueColor rendering on Linux
+ - faster 32-bit TrueColor rendering on Linux, HP, IBM
+ - non-depth-buffered XImage polygons are faster
+ - vertex array extension
+ - software alpha planes
+ - updated Macintosh driver
+ - new NeXT driver
+ - GLU quadric functions generate texture coordinates
+ - reflect.c demo - reflective, textured surface demo
+ Changes:
+ - gamma correction code moved into the X driver for better performance
+ Bug fixes:
+ - multiple glClipPlane()'s didn't work reliably
+ - glPolygonMode() didn't always work
+ - glCullFace( GL_FRONT_AND_BACK ) didn't work
+ - texture mapping with gamma correction was buggy
+ - floating point exceptions in texture coordinate interpolation
+ - XImage byte swapping didn't always work
+ - polygon edge flags weren't always used correctly
+
+1.2.8 May 22, 1996
+ New:
+ - overlay planes on X servers with the SERVER_OVERLAY_VISUALS property
+ - better monochrome output
+ - more IRIX 6.x configurations
+ - more robust RGB mode color allocation
+ - added MESA_XSYNC environment variable
+ - GLX_MESA_pixmap_colormap and GLX_EXT_visual_info extensions
+ - GL_MESA_window_pos extension
+ - faster glReadPixels/glDrawPixels for GL_DEPTH and GL_UNSIGNED_SHORT
+ and GL_UNSIGNED_INT
+ - driver for prototype Cirrus Mondello 3-D board
+ - updated AmigaDOS driver
+ - a few small speed optimizations in polygon rendering
+ Changes:
+ - internal device driver interface modified to simplify device
+ driver implementations and to support hardware Z buffers
+ - several changes to the X/Mesa interface (xmesa.h)
+ Bug fixes:
+ - fixed pow(0,0) domain error triggered on some systems
+ - glStencilClear() in a display list caused an infinite loop
+ - glRasterPos*() was sometimes off by +/-0.5 in X and Y
+ - color masking and blending were performed in wrong order
+ - auxSolidCylinder() sometimes drew a wire-frame cylinder
+ - fixed file writing bug in osdemo.c
+ - pixel mapping didn't always work
+ - the GL_GEQUAL stencil func didn't work
+ - the GL_INVERT stencil op didn't work
+ - the stencil write mask didn't work
+ - glPush/PopAttrib() didn't do enough error checking
+ - glIsList() didn't always work correctly
+
+2.0 October 10, 1996
+ New:
+ - Implements OpenGL 1.1 API functions
+ - all texture filtering modes supported (mipmapping)
+ - faster texture mapping, see Performance Tip 11 in README
+ - antialiased RGB points
+ - X support for line and polygon stippling
+ - glDrawBuffer( GL_FRONT_AND_BACK ) works
+ - util/ directory of useful stuff
+ - demos/texobj demo of texture objects
+ Changes:
+ - major internal changes for thread-safeness
+ - new device driver interface
+ - MESA_ALPHA env variable removed
+ - triangle rasterizer replaces polygon rasterizer
+ Bug fixes:
+ - glPopAttrib() bug
+ - glDrawBuffer(GL_NONE) works now
+
+2.1 December 14, 1996
+ New:
+ - VMS support
+ - MS-DOS driver
+ - OpenStep support
+ - updated, combined Windows 95/NT driver
+ - implemented glGetLighti() and glGetTexGen*()
+ - GLX does garbage collection of ancillary buffers
+ Bug fixes:
+ - removed unused _EXT constants from gl.h
+ - fixed polygon offset bugs
+ - Z coordinates of clipped lines were incorrect
+ - glEdgeFlag() in display lists didn't always work
+ - glLight*() in display lists didn't work
+ - fixed X line stipple bugs (Michael Pichler)
+ - glXUseXfonts XFreeFont/XFreeFontInfo bug fixed
+ - fixed a feedback bug
+ - glTexGen*() now transforms GL_EYE_PLANE by inverse modelview matrix
+ - polygons were sometimes culled instead of clipped
+ - triangle rasterizer suffered from float/int overflow exceptions
+ - fixed FP underflow exception in lighting (specular exponent)
+ - glEnable/glDisable of GL_EXT_vertex_array enums didn't work
+ - fixed free(NULL) in GLU tesselator code
+ - using 24-bit color on some X servers resulted in garbage rendering
+ - 32-bit per pixel mode for XFree86 now works
+ - glRotate(a,0,0,0) gave unpredictable results
+ - GL_LINE_STRIP with > 480 vertices had occasional clipping problems
+ - 8-bit TrueColor GLXPixmap rendering incorrectly required a colormap
+ - glMaterial() wasn't ignored when GL_COLOR_MATERIAL was enabled
+ - glEnable(GL_COLOR_MATERIAL) followed by glColor() didn't work right
+ - accumulation buffer was limited to positive values
+ - projective textures didn't work
+ - selection buffer overflows weren't handled correctly
+ Changes:
+ - restored the GL_EXT_polygon_offset extension
+ - slightly faster RGB dithering
+ - the SVGA driver works again
+ - Amiga driver now distributed separately
+ - NeXT driver updated for Mesa 2.x
+
+2.2 March 14, 1997
+ New:
+ - better color selection when dithering
+ - added GL_EXT_texture_object extension
+ - updated MS-DOS driver for DJGPP
+ - added openbsd make configuration
+ - faster dithered flat-shaded triangles
+ - various compilation problems with Motif widgets fixed
+ - gl.h, glx.h and glu.h name mangling option
+ - BeOS driver
+ - 3D texture mapping extension
+ - GL_MESA_resize_buffers extension
+ - morph3d, stex3d and spectex demos
+ - 3Dfx support
+ Bug fixes:
+ - glColorMaterial should finally work right in all respects
+ - linear interpolation of mipmap levels was incorrectly weighted
+ - readpix.c didn't compile on Macintosh
+ - GL_INVERT and related logic ops didn't work right
+ - glTexImage[12]D() didn't check its parameters consistantly
+ - fixed a memory leak in glTexImage[12]D()
+ - kludged around a SunOS 5.x/GCC compiler bug in the feedback code
+ - glReadPixels aborted instead of normally catching some errors
+ - a few 1.1 constants were missing or misnamed in gl.h
+ - glBegin(p); glBegin(q); didn't generate an error
+ - fixed a memory leak in GLX code
+ - clipping of concave polygons could cause a core dump
+ - 1-component alpha texture maps didn't work
+ - fixed a GLU polygon tesselator bug
+ - polygons with colinear vertices were sometimes culled
+ - feedback triangle colors were wrong when using smooth shading
+ - textures with borders didn't work correctly
+ - colors returned in feedback mode were wrong when using lighting
+ - spotlights didn't effect ambient lighting correctly
+ - gluPartialDisk() had a few bugs
+ Changes:
+ - device driver interface expanded to support texture mapping
+ - faster matrix inversion subroutine
+ - commented out #include "wmesa_extend.h" from src/wmesa.c
+ - fixed many compiler warnings in the demo programs
+
+2.3 June 30, 1997
+ New:
+ - Mesa distribution divided into two pieces: library code and demos
+ - faster vertex transformation, clip testing, lighting
+ - faster line drawing
+ - TrueColor visuals how have dithering (for depths < 24 bits)
+ - added MESA_NO_DITHER environment variable
+ - new device driver function: NearFar(), RenderVB(), RasterSetup()
+ - added LynxOS configuration
+ - added cygnus Win32 configuration
+ - added texcyl.c GLUT demo
+ - added XMesaDitherColor() to X/Mesa interface
+ - new NURBS code from Bogdan Sikorski
+ - added demos/shape.c (non-rectangular X window!)
+ Bug fixes:
+ - glEnable/DisableClientState() were missing from GL/gl.h
+ - GL_SPHERE_MAP texcoord generation didn't work correctly
+ - glXGetConfig() returned wrong number of depth, stencil, accum bits
+ - glDrawPixels feedback/selection didn't examine RasterPos valid bit
+ - black and white were reversed on some monochrome displays
+ - fixed potential image memory leak (wasn't setting reference counter)
+ - glDrawPixels sometimes didn't recognize some GL state changes
+ - gluProject/UnProject() didn't check for divide by zero
+ - stex3d demo called random() and srandom(), not portable
+ - fixed memory leaks in context.c and drawpix.c
+ - fixed NULL dereferencing problem in gl_update_texture_state()
+ - glReadPixels between glBegin/glEnd didn't generate an error.
+ - fixed memory leak in polygon tesselator (Randy Frank)
+ - fixed seg fault bug drawing flat-shaded, depth-tested lines
+ - clipped GL_TRIANGLE_STRIPs sometimes had wrong color when flat-shaded
+ - glBindTexture sometimes didn't work
+ - fixed a bug deep in glXReleaseBuffersMESA()
+ - fog was mistakenly applied to alpha
+ - glPopMatrix didn't set "dirty matrix" flag
+ - glPolygonStipple pattern was sometimes wrong
+ - glClear wasn't disabled during feedback and selection
+ - fixed memory leak in glTexSubImage[123]D
+ Changes:
+ - many library source files reorganized
+ - faster X color allocation, colors also freed when finished with them
+ - new texture sampling function pointer in texture objects
+ - incorporated 3Dfx VooDoo driver v0.16 into main source tree
+ - many 3Dfx driver updates
+ - cygnus Makefiles now included
+ - updated DOS driver
+ - made a few changes to dosmesa.c and wmesa.c (VB->Unclipped)
+ - internally, colors now stored in GLubytes, not GLfixed
+ - optimized changing of GL_SHININESS parameter
+
+2.4 September 18, 1997
+ New:
+ - updated 3Dfx Glide driver
+ - hacks for 3Dfx rendering into an X window or fullscreen
+ - added depth buffer access functions to X/Mesa and OS/Mesa interfaces
+ Bug fixes:
+ - pixel buffer could overflow with long, wide lines
+ - fixed FP underflow problems in lighting
+ - glTexSubImage1D() had an unitialized variable
+ - incomplete texture objects could cause a segfault
+ - glDrawPixels with GL_COMPILE_AND_EXECUTE caused infinite loop
+ - flat-shaded quads in a strip were miscolored if clipped
+ - mipmapped triangle lod computation now works correctly
+ - fixed a few under/overflow bugs in triangle rasterizer
+ - glArrayElement() assigned bad normal if normal array disabled
+ - changed argument to glXReleaseBuffersMESA()
+ - fixed small triangle underflow bugs in tritemp.h (hopefully)
+ - glBindTexture(target, 0) caused a crash
+ - glTexImage[123]D() with NULL image pointer caused crash
+ - glPixelStore parameters are now ignored during display list execution
+ - fixed a two-sided lighting w/ clipping bug (black vertices)
+ - textures with width!=height were sometimes mis-rendered
+ - "weird" projection matrices could cause div by 0, other fp errors
+ Changes:
+ - changed precompiled header symbol from PCH to PC_HEADER
+ - split api.c into api1.c and api2.c
+ - added hash.c source file (but not used yet)
+ - a few Sun and HP configuration file changes
+ - MESA_GLX_FX env var replaces MESA_FX_WINDOW and MESA_FX_FULLSCREEN
+ - fixed a few cygnus build problems (src/Makefile.cygnus, src/wmesa.c)
+
+2.5 November 20, 1997
+ New:
+ - updated 3Dfx driver (v20) for GLQuake
+ - added GL_EXT_paletted_texture extension
+ - added GL_EXT_shared_texture_palette extension
+ - added GL_EXT_point_parameters extension
+ - now including Mark Kilgard's GLUT library v3.6
+ - new GLUT-based demos in gdemos/
+ - added a few more Unix config targets
+ - added Intel X86 assembly language vertex transformation code
+ - 3Dfx/Glide driver for Mesa now recognizes SST_SCREENREFRESH env var
+ - Windows 95 S3 Virge driver
+ Bug fixes:
+ - glCopyTexImage?D would crash due to uninitialized variable
+ - glColor w/ glColorMaterial in a display list caused a bug
+ - fixed several glDrawPixels() and ReadPixels() bugs in 3Dfx driver
+ - glVertex4*() vertices weren't always projected correctly
+ - trying to use mipmapped textured points or lines caused crash
+ - glColor[34][fd]() values now clamped to [0,1] before int conversion
+ Changes:
+ - new device driver functions for texture mapping
+ - hash tables used for display list and texture object lookup
+ - fixed GLX visual handling code to avoid saving redundant visuals
+ - 3Dfx Glide libraries automatically linked to libMesaGL.so
+ - dropped the Cirrus Logic Mondello code since it's obsolete
+ - updated Cygnus Makefiles (Stephane Rehel)
+ - updated Windows MSVC++ Makefiles (Oleg Letsinsky)
+ - procedure for making library files has changed: scripts now take
+ a major and minor version arguments. Make-config changed a lot.
+ - new implementation of glTexSubImage2D()
+ - updated widgets-mesa directory to create libMesaGLwM.a (Motif widget)
+ - separate linux-glide and linux-386-glide configurations
+
+2.6 February 12, 1998
+ New:
+ - Windows WGL functions
+ - updated VMS, DOS, Windows, Cygnus, BeOS, Amiga compilation support
+ - v0.22 of 3Dfx Glide driver
+ - more X86 assembly language optimizations
+ - faster blending for some modes
+ - XMesaSetFXmode() to switch between 3Dfx window and full-screen mode
+ - added preliminary thread support
+ - added GLX_MESA_copy_sub_buffer extension
+ - some clipping optimizations
+ Bug fixes:
+ - fixed shading/material bug when drawing long primitive strips
+ - fixed clipping problem in long primitive strips
+ - fixed clipping bug when using 3Dfx driver
+ - fixed a problem when trying to use X fonts w/ 3Dfx driver
+ - fixed a texture filter bug in 3Dfx/Glide driver
+ - fixed bug in 3Dfx/Glide driver involving depth mask & clearing
+ - glLoadMatrix to set projection matrix confused the 3Dfx driver
+ - non-identity texture matrices didn't work with linux-386 configs
+ - glGenTextures() didn't reserve the returned texture IDs
+ - NULL proxy image sent to glTexImageXD() caused crash
+ - added texture state validation optimization (Henk Kok)
+ - fixed colormap reuse problem when using both RGB and CI windows
+ - 32bpp True/DirectColor X visuals weren't recognized
+ - fixed potential problem in evaluators memory allocation
+ - fixed assorted demo compilation bugs
+ Changes:
+ - replaced old Mesa/windows/ directory with Mesa/WIN32/ directory
+ - converted a few old glaux/gltk demos to GLUT
+ - renamed directories: demos -> xdemos, gdemos -> demos
+
+
+3.0 September 17, 1998
+ New:
+ - OpenGL 1.2 API
+ - GL_EXT_abgr pixel format extension
+ - GL_SGIS_texture_edge_clamp extension
+ - GL_SGIS_multitexture extension (to be replaced by GL_ARB_multitex)
+ - GL_EXT_multitexture extension (to be replaced by GL_ARB_multitex)
+ - GL_EXT_rescale_normal extension and renormal.c demo
+ - GLX_SGI_video_sync extension (a no-op)
+ - antialiased lines
+ - glGetTexImage() now implemented
+ - glDraw/Copy/ReadPixels() optimizations
+ - optimized textured triangle code (Marten Stromberg)
+ - more optimization of dithered TrueColor triangles in X driver
+ - Linux GGI driver
+ - updated MGL driver
+ Bug fixes:
+ - lots of assorted compilation fixes
+ - glInitNames didn't write initial hit record
+ - glBitmap didn't always check for invalid raster position
+ - switching between GLX and OSMesa contexts caused a crash
+ - fixed uninitialized variable in Mesa widget code
+ - fixed typo in texture code which caused book/texgen to crash
+ - fixed texture sampling bug when filter=GL_LINEAR and wrap=GL_CLAMP
+ - gluDisk() in POINT or LINE mode sometimes failed
+ - fixed texture + fog bug
+ - GL_COMPILE_AND_EXECUTE mode didn't work reliably
+ - glMultMatrix in projection matrix mode w/ 3Dfx driver could fail
+ - glDrawPixels(color index pixels) weren't converted to RGBA
+ - fixed possible getenv() buffer overflow security bug
+ - glBitmap in feedback mode was offset by xOrig, yOrig params
+ - device driver's DrawPixels hook was never used
+ - glDrawPixels with zoomY!=1 and top/bottom clipping didn't work
+ - glDrawPixels optimized for GL_LUMINANCE, GL_LUMINANCE_ALPHA, GLubyte
+ - fixed MakeCurrent bug in GLwRedrawObjects() in MesaWorkstation.c
+ - glCopyTexSubImage2D() didn't work with 3Dfx driver
+ - lines with width = 2 could cause crash
+ - glClear with scissor rect sometimes cleared whole buffer
+ - glTexSubImage2D( .. GL_COLOR_INDEX .. ) didn't work
+ - glTexImageXD( .. GL_ABGR_EXT .. ) didn't work
+ - computation of inverse modelview matrix sometimes failed
+ - fixed GL_CLAMP mode texture sampling bug
+ - textured line interpolation was somewhat broken
+ - textured triangle interpolation was also somewhat broken
+ - glGet(MODELVIEW/PROJECTION/TEXTURE_MATRIX_STACK_DEPTH) off by one
+ - evaluator state wasn't fully initialized
+ - texture coordinate clipping was buggy
+ - evaluator surfaces could be mis-colored
+ - glAccum(GL_RETURN, s) didn't obey glColorMask() settings
+ - zero area polygons shouldn't be culled if polygon mode is point/line
+ - clipped width and height of glReadPixels was sometimes off by one
+ - blending with alpha = 0 or 1.0 wasn't always exact
+ - reading of pixels from clipped region was buggy
+ - minor tweaking of X visual management in GLX emulator
+ - glPolygonStipple now obeys pixel unpacking parameters
+ - glGetPolygonStipple now obeys pixel packing parameters
+ - interleaved vertex array texture coordinates were broken
+ - query of proxy texture internal format was broken
+ - alpha channel wasn't reliably cleared
+ - fixed divide by zero error in gluScaleImage if dest size = 1 x 1
+ Conformance bug fixes:
+ - GL_SELECTION_BUFFER_POINTER and GL_SELECTION_BUFFER_SIZE were missing
+ - GL_TEXTURE_INTERNAL_FORMAT was missing
+ - glGet*(GL_POLYGON_STIPPLE) was broken
+ - glPush/PopAttrib() didn't save/restore all texture state
+ - glBitmap in feedback mode didn't work
+ - feedback of texture coords didn't always work
+ - glDrawPixels w/ format=GL_DEPTH_COMPONENT, type=GLbyte was broke
+ - glDrawPixels w/ format=GL_DEPTH_COMPONENT, type=GLubyte was broke
+ - glDrawPixels w/ format=GL_STENCIL_INDEX, type=GL_BITMAP was broke
+ Changes:
+ - upgraded GLUT to version 3.7
+ - only GL and GLU library code included in MesaLib.tar.gz
+ - GLUT and all demos now in MesaDemos.tar.gz
+ - glaux and gltk libraries removed
+ - IRIX -n32 and -64 libs go in lib32/ and lib64/ directories
+
+
+3.1 beta 1 November 19, 1998
+ New:
+ - GL_EXT_stencil_wrap extension
+ - GL_INGR_blend_func_separate extension
+ - GL_ARB_multitexture extension
+ - GL_NV_texgen_reflection extension
+ - newly optimized vertex transformation code
+ - updated GLUT 3.7 code
+ - better precision when using 32-bit Z buffer
+ - Allegro DJGPP driver
+ Bug fixes:
+ - glCopyPixels between front/back buffers didn't copy alpha correctly
+ - fixed out-of-bounds memory access in optimized 2-D texture code
+ - glPixelStorei didn't accept GL_PACK/UNPACK_IMAGE_HEIGHT parameter
+ - glGet*() didn't accept GL_MAX_3D_TEXTURE_SIZE parameter
+ - clipping of texture coordinates sometimes had bad R,Q values
+ - GL_CLAMP_TO_EDGE texture sampling was off by 0.5 texels
+ - glEdgeFlagPointer() now takes a GLvoid * instead of GLboolean *
+ - texture was sometimes applied twice with 3Dfx driver
+ - glPush/PopAttrib() fouled up texture object reference counts
+ - glDeleteLists(0, n) caused assertion failure
+ - bilinear texture sampling wasn't accurate enough
+ - glClear w/ glDepthMask(GL_FALSE) didn't work right on 3Dfx
+ - color components were reversed on big endian 32 bpp X visuals
+ Changes:
+ - removed GL_EXT_multitexture extension
+
+
+3.1 beta 2 May 24, 1999
+ New:
+ - multi-textured points and lines (mjk@nvidia.com)
+ - optimized 24bpp X rendering (bernd.paysan@gmx.de)
+ - added allegro support (bernie-t@geocities.com)
+ - cleaned-up Windows-related stuff (Ted Jump)
+ - minor stereo changes (KendallB@scitechsoft.com)
+ - new BeOS driver which implements BGLView class
+ - new Direct3D driver (see src/D3D)
+ - more efficient filled gluCylinder() function
+ - utilities: util/showbuffer.[ch] and util/glstate.[ch]
+ - fixed some IRIX compiler warnings
+ - added support for building Mesa in XFree86 with
+ SGI's GLX (kevin@precisioninsight.com)
+ Bug fixes:
+ - a variety of Windows/Mesa bug fixes (mjk@nvidia.com)
+ - packed pixel images weren't unpacked correctly
+ - patches some win32 files in GLUT (mjk@nvidia.com)
+ - glTexImage[123]D() didn't accept internalFormat == GL_COLOR_INDEX
+ - fixed lighting bug in Keith's new shading code
+ - fixed texture segfault seen in Lament screensaver
+ - fixed miscellaneous low-memory bugs
+ - glClear(GL_COLOR_BUFFER_BIT) with RGBA or CI masking was broken
+ - GL_LINEAR sampling of 3D textures was broken
+ - fixed SVR4 'cc' compiler macro problem (dawes@xfree86.org)
+ - added GL_TEXTURE_PRIORITY fix (keithh@netcomuk.co.uk)
+ - fixed wide point and wide line conformance bugs (brianp)
+ Changes:
+ - some device driver changes (see src/dd.h)
+ - new copyright on core Mesa code
+
+
+3.1 beta 3 September 17, 1999
+ New:
+ - optimized glAccum function
+ - optimized 24bpp rendering in XMesa driver
+ - GLU 1.2 polygon tessellator
+ Bug Fixes:
+ - glGetTexLevelParameter wasn't fully implemented
+ - glXUseXFont now handles multi-byte fonts
+ - glIsEnabled(GL_TEXTURE_2D / 3D) returned wrong result
+ - alpha channel of blending points, lines was sometimes incorrect
+ Changes:
+ - New library names: "libGL" instead of "libMesaGL"
+ - New library numbering: libGL.so.1.2.310
+ - New subdirectories: docs/ and bin/
+ - New Makefile-system (autoconf,automake,libtool)
+
+
+3.1 final December 14, 1999
+ New:
+ - added demos/gloss.c
+ - added xdemos/glxdpyinfo.c
+ - added GLX_ARB_get_proc_address extension
+ - rewritten glTexImage code paths (faster, less memory, bug fixes)
+ Bug Fixes:
+ - several vertex array bug fixes
+ - overlapping glCopyPixels with pixel zooming now works
+ - glXUseXFont() bitmaps were vertically shifted by one pixel
+ - glCopyPixels with pixel zooming now works
+
+
+3.2 final April 24, 2000
+ Bug fixes:
+ - fixed memcpy bugs in span.c
+ - fixed missing glEnd problem in demos/tessdemo.c
+ - fixed bug when clearing 24bpp Ximages
+ - fixed clipping problem found in Unreal Tournament
+ - fixed Loki's "ice bug" and "crazy triangles" seen in Heretic2
+ - fixed Loki's 3dfx RGB vs BGR bug
+ - fixed Loki's 3dfx smooth/flat shading bug in SoF
+ Changes:
+ - updated docs/README file
+ - use bcopy() optimizations on FreeBSD
+ - re-enabled the optimized persp_textured_triangle() function
+
+
+3.2.1 July 19, 2000
+ Bug fixes:
+ - gluBuild2DMipmaps() didn't accept GL_BGRA
+ - Fixed compile/makefile problems on IRIX
+ - fixed segfault in 3dfx driver when using GL selection/feedback
+ - no longer cull very, very tiny triangles
+ - blending w/ drawbuffer==GL_FRONT_BACK caused segfault (sw rendering)
+ - fixed Motif detection code in widgets-mesa/configure.in
+ - glColorMaterial and glMaterial updates to emissive and ambient
+ didn't always work right
+ - Specular highlights weren't always in the right place
+ - clipped GL_LINE mode polygons had interior lines appear
+ - blend term GL_ONE_MINUS_CONSTANT_ALPHA was broken
+ - GL_NICEST fog didn't always work with flat shading
+ - glRect commands in display lists were sometimes miscolored
+ - Line Z offset didn't always work
+ - fixed texgen normal vector problem (gloss's teapot)
+ - numerous GL conformance bugs fixed
+ Changes:
+ - glColorMask(false, false, false, false) handled better/faster
+ - reverted to old GLU polygon tessellator, GLU 1.1
+ - updated Win32 build files
+
+
+3.3 July 21, 2000
+ New:
+ - antialiased triangles now implemented
+ - GL_EXT_texture_env_add texture mode extension
+ - GLX 1.3 API
+ - support for separate draw/read buffers (ie GL_SGI_make_current_read)
+ - thread-safe API dispath
+ - improved glxinfo program
+ - demos/texdown program to measure texture download performance
+ - glext.h header file
+ - demos/geartrain program
+ - GL_EXT_texture_lod_bias extension
+ - demos/lodbias program
+ - further optimized glRead/DrawPixels for 16-bit TrueColor X visuals
+ - GLX_EXT_visual_rating extension (a no-op, however)
+ - GL_HP_occlusion_test extension (for X and OS/Mesa drivers)
+ - demos/occlude program
+ - GL_SGIS_pixel_texture and GL_SGIX_pixel_texture extensions
+ - demos/pixeltex program
+ - GL_SGI_color_matrix extension
+ - GL_SGI_color_table extension
+ - GL_EXT_histogram extension
+ - GL_ARB_texture_cube_map extension
+ - added xdemos/glxheads and xdemos/manywin
+ - demos/texenv.c demo
+ - GL_EXT_texture_env_combine extension (by Holger Waechtler)
+ - Xlib driver is now thread-safe (see xdemos/glthreads)
+ Bug Fixes:
+ - various GL conformance failures fixed since 3.2.1
+ Changes:
+ - gl.h now uses #defines instead of C enums for all tokens
+ - glu.h now uses #defines instead of C enums for all tokens
+ - moved programs from 3Dfx/demos/ into demos/ directory
+
+
+3.4 November 3, 2000
+ New:
+ - optimized glDrawPixels for glPixelZoom(1,-1)
+ Bug Fixes:
+ - widgets-mesa/src/*.c files were missing from 3.3 distro
+ - include/GL/mesa_wgl.h file was missing from 3.3 distro
+ - fixed some Win32 compile problems
+ - texture object priorities weren't getting initialized to 1.0
+ - glAreTexturesResident return value was wrong when using hardware
+ - glXUseXFont segfaulted when using 3dfx driver (via MESA_GLX_FX)
+ - glReadPixels with GLushort packed types was broken
+ - fixed a few bugs in the GL_EXT_texture_env_combine texture code
+ - glPush/PopAttrib(GL_ENABLE_BIT) mishandled multi-texture enables
+ - fixed some typos/bugs in the VB code
+ - glDrawPixels(GL_COLOR_INDEX) to RGB window didn't work
+ - optimized glDrawPixels paths weren't being used
+ - per-fragment fog calculation didn't work without a Z buffer
+ - improved blending accuracy, fixes Glean blendFunc test failures
+ - glPixelStore(GL_PACK/UNPACK_SKIP_IMAGES) wasn't handled correctly
+ - glXGetProcAddressARB() didn't always return the right address
+ - gluBuild[12]DMipmaps() didn't grok the GL_BGR pixel format
+ - texture matrix changes weren't always detected (GLUT projtex demo)
+ - fixed random color problem in vertex fog code
+ - fixed Glide-related bug that let Quake get a 24-bit Z buffer
+ Changes:
+ - finished internal support for compressed textures for DRI
+
+
+3.4.1 February 14, 2001
+ New:
+ - fixed some Linux build problems
+ - fixed some Windows build problems
+ - GL_EXT_texture_env_dot3 extension (Gareth Hughes)
+ Bug fixes:
+ - added RENDER_START/RENDER_FINISH macros for glCopyTexImage in DRI
+ - various state-update code changes needed for DRI bugs
+ - disabled pixel transfer ops in glColorTable commands, not needed
+ - fixed bugs in glCopyConvolutionFilter1D/2D, glGetConvolutionFilter
+ - updated sources and fixed compile problems in widgets-mesa/
+ - GLX_PBUFFER enum value was wrong in glx.h
+ - fixed a glColorMaterial lighting bug
+ - fixed bad args to Read/WriteStencilSpan in h/w stencil clear function
+ - glXCopySubBufferMESA() Y position was off by one
+ - Error checking of glTexSubImage3D() was broken (bug 128775)
+ - glPopAttrib() didn't restore all derived Mesa state correctly
+ - Better glReadPixels accuracy for 16bpp color - fixes lots of OpenGL
+ conformance problems at 16bpp.
+ - clearing depth buffer with scissoring was broken, would segfault
+ - OSMesaGetDepthBuffer() returned bad bytesPerValue value
+ - fixed a line clipping bug (reported by Craig McDaniel)
+ - fixed RGB color over/underflow bug for very tiny triangles
+ Known problems:
+ - NURBS or evaluator surfaces inside display lists don't always work
+
+
+3.4.2 May 17, 2001
+ Bug fixes:
+ - deleting the currently bound texture could cause bad problems
+ - using fog could result in random vertex alpha values
+ - AA triangle rendering could touch pixels outside right window bound
+ - fixed byteswapping problem in clear_32bit_ximage() function
+ - fixed bugs in wglUseFontBitmapsA(), by Frank Warmerdam
+ - fixed memory leak in glXUseXFont()
+ - fragment sampling in AA triangle function was off by 1/2 pixel
+ - Windows: reading pixels from framebuffer didn't always work
+ - glConvolutionFilter2D could segfault or cause FP exception
+ - fixed segfaults in FX and X drivers when using tex unit 1 but not 0
+ - GL_NAND logicop didn't work right in RGBA mode
+ - fixed a memory corruption bug in vertex buffer reset code
+ - clearing the softwara alpha buffer with scissoring was broken
+ - fixed a few color index mode fog bugs
+ - fixed some bad assertions in color index mode
+ - fixed FX line 'stipple' bug #420091
+ - fixed stencil buffer clear width/height typo
+ - fixed GL error glitches in gl[Client]ActiveTextureARB()
+ - fixed Windows compilation problem in texutil.c
+ - fixed 1/8-pixel AA triangle sampling error
+ Changes:
+ - optimized writing mono-colored pixel spans to X pixmaps
+ - increased max viewport size to 2048 x 2048
+
+
+3.5 June 21, 2001
+ New:
+ - internals of Mesa divided into modular pieces (Keith Whitwell)
+ - 100% OpenGL 1.2 conformance (passes all conformance tests)
+ - new AA line algorithm
+ - GL_EXT_convolution extension
+ - GL_ARB_imaging subset
+ - OSMesaCreateContextExt() function
+ - GL_ARB_texture_env_add extension (same as GL_EXT_texture_env_add)
+ - GL_MAX_TEXTURE_UNITS_ARB now defaults to eight
+ - GL_EXT_fog_coord extension (Keith Whitwell)
+ - GL_EXT_secondary_color extension (Keith Whitwell)
+ - GL_ARB_texture_env_add extension (same as GL_EXT_texture_env_add)
+ - GL_SGIX_depth_texture extension
+ - GL_SGIX_shadow and GL_SGIX_shadow_ambient extensions
+ - demos/shadowtex.c demo of GL_SGIX_depth_texture and GL_SGIX_shadow
+ - GL_ARB_texture_env_combine extension
+ - GL_ARB_texture_env_dot3 extension
+ - GL_ARB_texture_border_clamp (aka GL_SGIS_texture_border_clamp)
+ - OSMesaCreateContextExt() function
+ - libOSMesa.so library, contains the OSMesa driver interface
+ - GL/glxext.h header file for GLX extensions
+ - somewhat faster software texturing, fogging, depth testing
+ - all color-index conformance tests now pass (only 8bpp tested)
+ - SPARC assembly language TCL optimizations (David Miller)
+ - GL_SGIS_generate_mipmap extension
+ Bug Fixes:
+ - fbiRev and tmuRev were unitialized when using Glide3
+ - fixed a few color index mode conformance failures; all pass now
+ - now appling antialiasing coverage to alpha after texturing
+ - colors weren't getting clamped to [0,1] before color table lookup
+ - fixed RISC alignment errors caused by COPY_4UBV macro
+ - drawing wide, flat-shaded lines could cause a segfault
+ - vertices now snapped to 1/16 pixel to fix rendering of tiny triangles
+ Changes:
+ - SGI's Sample Implementation (SI) 1.3 GLU library replaces Mesa GLU
+ - new libOSMesa.so library, contains the OSMesa driver interface
+
+
+4.0 October 22, 2001
+ New:
+ - Mesa 4.0 implements the OpenGL 1.3 specification
+ - GL_IBM_rasterpos_clip extension
+ - GL_EXT_texture_edge_clamp extension (aka GL_SGIS_texture_edge_clamp)
+ - GL_ARB_texture_mirrored_repeat extension
+ - WindML UGL driver (Stephane Raimbault)
+ - added OSMESA_MAX_WIDTH/HEIGHT queries
+ - attempted compiliation fixes for Solaris 5, 7 and 8
+ - updated glext.h and glxext.h files
+ - updated Windows driver (Karl Schultz)
+ Bug fixes:
+ - added some missing GLX 1.3 tokens to include/GL/glx.h
+ - GL_COLOR_MATRIX changes weren't recognized by teximage functions
+ - glCopyPixels with scale and bias was broken
+ - glRasterPos with lighting could segfault
+ - glDeleteTextures could leave a dangling pointer
+ - Proxy textures for cube maps didn't work
+ - fixed a number of 16-bit color channel bugs
+ - fixed a few minor memory leaks
+ - GLX context sharing was broken in 3.5
+ - fixed state-update bugs in glPopClientAttrib()
+ - fixed glDrawRangeElements() bug
+ - fixed a glPush/PopAttrib() bug related to texture binding
+ - flat-shaded, textured lines were broken
+ - fixed a dangling pointer problem in the XMesa code (Chris Burghart)
+ - lighting didn't always produce the correct alpha value
+ - fixed 3DNow! code to not read past end of arrays (Andrew Lewycky)
+
+
+4.0.1 December 17, 2001
+ New:
+ - better sub-pixel sample positions for AA triangles (Ray Tice)
+ - slightly faster blending for (GL_ZERO, GL_ONE) and (GL_ONE, GL_ZERO)
+ Bug fixes:
+ - added missing break statements in glGet*() for multisample cases
+ - fixed uninitialized hash table mutex bug (display lists / texobjs)
+ - fixed bad teximage error check conditional (bug 476846)
+ - fixed demos readtex.c compilation problem on Windows (Karl Schultz)
+ - added missing glGet() query for GL_MAX_TEXTURE_LOD_BIAS_EXT
+ - silence some compiler warnings (gcc 2.96)
+ - enable the #define GL_VERSION_1_3 in GL/gl.h
+ - added GL 1.3 and GLX 1.4 entries to gl_mangle.h and glx_mangle.h
+ - fixed glu.h typedef problem found with MSDev 6.0
+ - build libGL.so with -Bsymbolic (fixes bug found with Chromium)
+ - added missing 'const' to glXGetContextIDEXT() in glxext.h
+ - fixed a few glXGetProcAddress() errors (texture compression, etc)
+ - fixed start index bug in compiled vertex arrays (Keith)
+ - fixed compilation problems in src/SPARC/glapi_sparc.S
+ - fixed triangle strip "parity" bug found in VTK medical1 demo (Keith)
+ - use glXGetProcAddressARB in GLUT to avoid extension linking problems
+ - provoking vertex of flat-shaded, color-index triangles was wrong
+ - fixed a few display list bugs (GLUT walker, molecule, etc) (Keith)
+ - glTexParameter didn't flush the vertex buffer (Ray Tice)
+ - feedback attributes for glDraw/CopyPixels and glBitmap were wrong
+ - fixed bug in normal length caching (ParaView lighting bug)
+ - fixed separate_specular color bug found in Chimera (18 Dec 2001)
+
+
+4.0.2 April 2, 2002
+ New:
+ - New DOS (DJGPP) driver written by Daniel Borca
+ - New driver interface functions for TCL drivers (such as Radeon DRI)
+ - GL_RENDERER string returns "Mesa Offscreen16" or "Mesa Offscreen32"
+ if using deep color channels
+ - latest GL/glext.h and GL/glxext.h headers from SGI
+ Bug fixes:
+ - GL_BLEND with non-black texture env color wasn't always correct
+ - GL_REPLACE with GL_RGB texture format wasn't always correct (alpha)
+ - glTexEnviv( pname != GL_TEXTURE_ENV_COLOR ) was broken
+ - glReadPixels was sometimes mistakenly clipped by the scissor box
+ - glDraw/ReadPixels didn't catch all the errors that they should have
+ - Fixed 24bpp rendering problem in Windows driver (Karl Schultz)
+ - 16-bit GLchan mode fixes (m_trans_tmp.h, s_triangle.c)
+ - Fixed 1-bit float->int conversion bug in glDrawPixels(GL_DEPTH_COMP)
+ - glColorMask as sometimes effecting glXSwapBuffers()
+ - fixed a potential bug in XMesaGarbageCollect()
+ - N threads rendering into one window didn't work reliably
+ - glCopyPixels didn't work for deep color channels
+ - improved 8 -> 16bit/channel texture image conversion (Gerk Huisma)
+ - glPopAttrib() didn't correctly restore user clip planes
+ - user clip planes failed for some perspective projections (Chromium)
+ Known bugs:
+ - mipmap LOD computation
+
+
+4.0.3 June 25, 2002
+ New:
+ - updated GL/glext.h file (version 15)
+ - corrected MMX blend code (Jose Fonseca)
+ - support for software-based alpha planes in Windows driver
+ - updated GGI driver (Filip Spacek)
+ Bug fixes:
+ - glext.h had wrong values for GL_DOT3_RGB[A]_EXT tokens
+ - OSMesaMakeCurrent() didn't recognize buffer size changes
+ - assorted conformance fixes for 16-bit/channel rendering
+ - texcombine alpha subtraction mode was broken
+ - fixed lighting bug with non-uniform scaling and display lists
+ - fixed bug when deleting shared display lists
+ - disabled SPARC cliptest assembly code (Mesa bug 544665)
+ - fixed a couple Solaris compilation/link problems
+ - blending clipped glDrawPixels didn't always work
+ - glGetTexImage() didn't accept packed pixel types
+ - glPixelMapu[is]v() could explode given too large of pixelmap
+ - glGetTexParameter[if]v() didn't accept GL_TEXTURE_MAX_ANISOTROPY_EXT
+ - glXCopyContext() could lead to segfaults
+ - glCullFace(GL_FRONT_AND_BACK) didn't work (bug 572665)
+ Changes:
+ - lots of C++ (g++) code clean-ups
+ - lots of T&L updates for the Radeon DRI driver
+ Known bugs:
+ - mipmap LOD computation (fixed for Mesa 4.1)
+
+
+4.0.4 October 3, 2002
+ New:
+ - GL_NV_texture_rectangle extension
+ - updated glext.h header (version 17)
+ - updated DOS driver (Daniel Borca)
+ - updated BeOS R5 driver (Philippe Houdoin)
+ - added GL_IBM_texture_mirror_repeat
+ - glxinfo now takes -l option to print interesting OpenGL limits info
+ - GL_MESA_ycbcr_texture extension
+ - GL_APPLE_client_storage extension (for some DRI drivers only)
+ - GL_MESA_pack_invert extension
+ Bug fixes:
+ - fixed GL_LINEAR fog bug by adding clamping
+ - fixed FP exceptions found using Alpha CPU
+ - 3dfx MESA_GLX_FX=window (render to window) didn't work
+ - fixed memory leak in wglCreateContest (Karl Schultz)
+ - define GLAPIENTRY and GLAPI if undefined in glu.h
+ - wglGetProcAddress didn't handle all API functions
+ - when testing for OpenGL 1.2 vs 1.3, check for GL_ARB_texture_cube_map
+ - removed GL_MAX_CONVOLUTION_WIDTH/HEIGHT from glGetInteger/Float/etc()
+ - error checking in compressed tex image functions had some glitches
+ - fixed AIX compile problem in src/config.c
+ - glGetTexImage was using pixel unpacking instead of packing params
+ - auto-mipmap generation for cube maps was incorrect
+ Changes:
+ - max texture units reduced to six to accomodate texture rectangles
+ - removed unfinished GL_MESA_sprite_point extension code
+
+
+4.1 October 29, 2002
+ New:
+ - GL_NV_vertex_program extension
+ - GL_NV_vertex_program1_1 extension
+ - GL_ARB_window_pos extension
+ - GL_ARB_depth_texture extension
+ - GL_ARB_shadow extension
+ - GL_ARB_shadow_ambient extension
+ - GL_EXT_shadow_funcs extension
+ - GL_ARB_point_parameters extension
+ - GL_ARB_texture_env_crossbar
+ - GL_NV_point_sprite extension
+ - GL_NV_texture_rectangle extension
+ - GL_EXT_multi_draw_arrays extension
+ - GL_EXT_stencil_two_side extension
+ - GLX_SGIX_fbconfig and GLX_SGIX_pbuffer extensions
+ - GL_ATI_texture_mirror_once extension (Ian Romanick)
+ - massive overhaul/simplification of software rasterizer module,
+ many contributions from Klaus Niederkrueger
+ - faster software texturing in some cases (i.e. trilinear filtering)
+ - new OSMesaGetProcAddress() function
+ - more blend modes implemented with MMX code (Jose Fonseca)
+ - added glutGetProcAddress() to GLUT
+ - added GLUT_FPS env var to compute frames/second in glutSwapBuffers()
+ - pbinfo and pbdemo PBuffer programs
+ - glxinfo -v prints transprent pixel info (Gerd Sussner)
+ Bug fixes:
+ - better mipmap LOD computation (prevents excessive blurriness)
+ - OSMesaMakeCurrent() didn't recognize buffer size changes
+ - assorted conformance fixes for 16-bit/channel rendering
+ - texcombine alpha subtraction mode was broken
+ - fixed some blend problems when GLchan==GLfloat (Gerk Huisma)
+ - clamp colors to [0,inf] in OSMesa if GLchan==GLfloat (Gerk Huisma)
+ - fixed divide by zero error in NURBS tessellator (Jon Perry)
+ - fixed GL_LINEAR fog bug by adding clamping
+ - fixed FP exceptions found using Alpha CPU
+ - 3dfx/glide driver render-to-window feature was broken
+ - added missing GLX_TRANSPARENT_RGB token to glx.h
+ - fixed error checking related to paletted textures
+ - fixed reference count error in glDeleteTextures (Randy Fayan)
+ Changes:
+ - New spec file and Python code to generate some GL dispatch files
+ - Glide driver defaults to "no" with autoconf/automake
+ - updated demos/stex3d with new options
+
+
+5.0 November 13, 2002
+ New:
+ - OpenGL 1.4 support (glGetString(GL_VERSION) returns "1.4")
+ - removed some overlooked debugging code
+ - glxinfo updated to support GLX_ARB_multisample
+ - GLUT now support GLX_ARB_multisample
+ - updated DOS driver (Daniel Borca)
+ Bug fixes:
+ - GL_POINT and GL_LINE-mode polygons didn't obey cull state
+ - fixed potential bug in _mesa_align_malloc/calloc()
+ - fixed missing triangle bug when running vertex programs
+ - fixed a few HPUX compilation problems
+ - FX (Glide) driver didn't compile
+ - setting GL_TEXTURE_BORDER_COLOR with glTexParameteriv() didn't work
+ - a few EXT functions, like glGenTexturesEXT, were no-ops
+ - a few OpenGL 1.4 functions like glFogCoord*, glBlendFuncSeparate,
+ glMultiDrawArrays and glMultiDrawElements were missing
+ - glGet*(GL_ACTIVE_STENCIL_FACE_EXT) was broken
+ - Pentium 4 Mobile was mistakenly identified as having 3DNow!
+ - fixed one-bit error in point/line fragment Z calculation
+ - fixed potential segfault in fakeglx code
+ - fixed color overflow problem in DOT3 texture env mode
+
+
+5.0.1 March 30, 2003
+ New:
+ - DOS driver updates from Daniel Borca
+ - updated GL/gl_mangle.h file (Bill Hoffman)
+ Bug fixes:
+ - auto mipmap generation for cube maps was broken (bug 641363)
+ - writing/clearing software alpha channels was unreliable
+ - minor compilation fixes for OS/2 (Evgeny Kotsuba)
+ - fixed some bad assertions found with shadowtex demo
+ - fixed error checking bug in glCopyTexSubImage2D (bug 659020)
+ - glRotate(angle, -x, 0, 0) was incorrect (bug 659677)
+ - fixed potential segfault in texture object validation (bug 659012)
+ - fixed some bogus code in _mesa_test_os_sse_exception_support (Linus)
+ - fix fog stride bug in tnl code for h/w drivers (Michel Danzer)
+ - fixed glActiveTexture / glMatrixMode(GL_TEXTURE) bug (#669080)
+ - glGet(GL_CURRENT_SECONDARY_COLOR) should return 4 values, not 3
+ - fixed compilation problem on Solaris7/x86 (bug 536406)
+ - fixed prefetch bug in 3DNow! code (Felix Kuhling)
+ - fixed NeXT build problem (FABSF macro)
+ - glDrawPixels Z values when glPixelZoom!=1 were invalid (bug 687811)
+ - zoomed glDraw/CopyPixels with clipping sometimes failed (bug 689964)
+ - AA line and triangle Z values are now rounded, not truncated
+ - fixed color interpolation bug when GLchan==GLfloat (bug 694461)
+ - glArePrograms/TexturesResident() wasn't 100% correct (Jose Fonseca)
+ - fixed a minor GL_COLOR_MATERIAL bug
+ - NV vertex program EXP instruction was broken
+ - glColorMask misbehaved with X window / pixmap rendering
+ - fix autoconf/libtool GLU C++ linker problem on Linux (a total hack)
+ - attempt to fix GGI compilation problem when MesaDemos not present
+ - NV vertex program ARL-relative fetches didn't work
+ Changes:
+ - use glPolygonOffset in gloss demo to avoid z-fighting artifacts
+ - updated winpos and pointblast demos to use ARB extensions
+ - disable SPARC normal transformation code (bug 673938)
+ - GLU fixes for OS/2 (Evgeny Kotsuba)
+
+
+5.0.2 September 5, 2003
+ Bug fixes:
+ - fixed texgen problem causing texcoord's Q to be zero (stex3d)
+ - default GL_TEXTURE_COMPARE_MODE_ARB was wrong
+ - GL_CURRENT_MATRIX_NV query was wrong
+ - GL_CURRENT_MATRIX_STACK_DEPTH_NV query was off by one
+ - GL_LIST_MODE query wasn't correct
+ - GL_FOG_COORDINATE_SOURCE_EXT query wasn't supported
+ - GL_SECONDARY_COLOR_ARRAY_SIZE_EXT query returned wrong value
+ - blended, wide lines didn't always work correctly (bug 711595)
+ - glVertexAttrib4svNV w component was always 1
+ - fixed bug in GL_IBM_rasterpos_clip (missing return)
+ - GL_DEPTH_TEXTURE_MODE = GL_ALPHA didn't work correctly
+ - a few Solaris compilation fixes
+ - fixed glClear() problem for DRI drivers (non-existant stencil, etc)
+ - fixed int/REAL mixup in GLU NURBS curve evaluator (Eric Cazeaux)
+ - fixed delete [] bug in SI GLU (bug 721765) (Diego Santa Cruz)
+ - glFog() didn't clamp fog colors
+ - fixed bad float/int conversion for GL_TEXTURE_PRIORITY in the
+ gl[Get]TexParameteri[v] functions
+ - fixed invalid memory references in glTexGen functions (bug 781602)
+ - integer-valued color arrays weren't handled correctly
+ - glDrawPixels(GL_DEPTH_COMPONENT) with glPixelZoom didn't work
+ - GL_EXT_texture_lod_bias is part of 1.4, overlooked in 5.0.1
+ Changes:
+ - build GLUT with -fexceptions so C++ apps propogate exceptions
+
+
+5.1 December 17, 2003
+ New:
+ - reorganized directory tree
+ - GL_ARB_vertex/fragment_program extensions (Michal Krol & Karl Rasche)
+ - GL_ATI_texture_env_combine3 extension (Ian Romanick)
+ - GL_SGI_texture_color_table extension (Eric Plante)
+ - GL_NV_fragment_program extension
+ - GL_NV_light_max_exponent extension
+ - GL_EXT_texture_rectangle (identical to GL_NV_texture_rectangle)
+ - GL_ARB_occlusion_query extension
+ - GL_ARB_point_sprite extension
+ - GL_ARB_texture_non_power_of_two extension
+ - GL_IBM_multimode_draw_arrays extension
+ - GL_EXT_texture_mirror_clamp extension (Ian Romanick)
+ - GL_ARB_vertex_buffer_object extension
+ - new X86 feature detection code (Petr Sebor)
+ - less memory used for display lists and vertex buffers
+ - demo of per-pixel lighting with a fragment program (demos/fplight.c)
+ - new version (18) of glext.h header
+ - new spriteblast.c demo of GL_ARB_point_sprite
+ - faster glDrawPixels in X11 driver in some cases (see RELNOTES-5.1)
+ - faster glCopyPixels in X11 driver in some cases (see RELNOTES-5.1)
+ Bug fixes:
+ - really enable OpenGL 1.4 features in DOS driver.
+ - fixed issues in glDrawPixels and glCopyPixels for very wide images
+ - glPixelMapf/ui/usv()'s size parameter is GLsizei, not GLint
+ - fixed some texgen bugs reported by Daniel Borca
+ - fixed wglMakeCurrent(NULL, NULL) bug (#835861)
+ - fixed glTexSubImage3D z-offset bug (Cedric Gautier)
+ - fixed RGBA blend enable bug (Ville Syrjala)
+ - glAccum is supposed to be a no-op in selection/feedback mode
+ - fixed texgen bug #597589 (John Popplewell)
+ Changes:
+ - dropped API trace feature (src/Trace/)
+ - documentation overhaul. merged with website content. more html.
+ - glxgears.c demo updated to use GLX swap rate extensions
+ - glTexImage1/2/3D now allows width/height/depth = 0
+ - disable SPARC asm code on Linux (bug 852204)
+
+
+6.0 January 16, 2004
+ New:
+ - full OpenGL 1.5 support
+ - updated GL/glext.h file to version 21
+ Changes:
+ - changed max framebuffer size to 4Kx4K (MAX_WIDTH/HEIGHT in config.h)
+ Bug fixes:
+ - fixed bug in UNCLAMPED_FLOAT_TO_UBYTE macro; solves a color
+ clamping issue
+ - updated suno5-gcc configs
+ - glColor3 functions sometimes resulted in undefined alpha values
+ - fixed FP divide by zero error seen on VMS with xlockmore, others
+ - fixed vertex/fragment program debug problem (bug 873011)
+ - building on AIX with gcc works now
+ - glDeleteProgramsARB failed for ARB fragment programs (bug 876160)
+ - glDrawRangeElements tried to modify potentially read-only storage
+ - updated files for building on Windows
+
+
+6.0.1 April 2, 2004
+ New:
+ - upgraded glext.h to version 22
+ - new build targets (Dan Schikore)
+ - new linux-x86-opteron build target (Heath Feather)
+ Bug fixes:
+ - glBindProgramARB didn't update all necessary state
+ - fixed build problems on OpenBSD
+ - omit CVS directories from tarballs
+ - glGetTexImage(GL_COLOR_INDEX) was broken
+ - fixed an infinite loop in t&l module
+ - silenced some valgrind warnings about using unitialized memory
+ - fixed some compilation/link glitches on IRIX (Mike Stephens)
+ - glBindProgram wasn't getting compiled into display lists
+ - GLX_FBCONFIG_ID wasn't recognized in glXChooseFBConfig() (bug 888079)
+ - two-sided lighting and vertex program didn't work (bug 887330)
+ - stores to program parameter registers in vertex state programs
+ didn't work.
+ - fixed glOrtho bug found with gcc 3.2.2 (RH9)
+ - glXCreateWindow() wasn't fully implemented (bug 890894)
+ - generic vertex attribute arrays didn't work in display lists
+ - vertex buffer objects' default usage and access fields were wrong
+ - glDrawArrays with start!=0 was broken
+ - fragment program PK2H, UP2H, UP4B and UP4UB instructions were broken
+ - linux-osmesa16-static config didn't work
+ - fixed a few color index rendering problems (bug 910687)
+ - glInterleavedArrays didn't respect GL_CLIENT_ACTIVE_TEXTURE
+ - OSMesa RGB and BGR modes were broken
+ - glProgramStringARB mistakenly required a null-terminated string
+ - fragment program XPD instruction was incorrect
+ - glGetMaterial() didn't work reliably
+ - ARB_fragment_program KIL instruction was incorrect
+
+
+6.1 August 18, 2004
+ New:
+ - Revamped Makefile system
+ - glXUseRotatedXFont() utility (see xdemos/xuserotfont.c)
+ - internal driver interface changes related to texture object
+ allocation, vertex/fragment programs, BlendEquationSeparate, etc.
+ - option to walk triangle edges with double-precision floats
+ (Justin Novosad of Discreet) (see config.h file)
+ - support for AUX buffers in software GLX driver
+ - updated glext.h to version 24 and glxext.h to version 6
+ - new MESA_GLX_FORCE_ALPHA and MESA_GLX_DEPTH_BITS env vars
+ - updated BeOS support (Philippe Houdoin)
+ Changes:
+ - fragment fog interpolation is perspective corrected now
+ - new glTexImage code, much cleaner, may be a bit faster
+ Bug fixes:
+ - glArrayElement in display lists didn't handle generic vertex attribs
+ - glFogCoord didn't always work properly
+ - ARB_fragment_program fog options didn't work
+ - frag prog TEX instruction no longer incorrectly divides s,t,r by q
+ - ARB frag prog TEX and TEXP instructions now use LOD=0
+ - glTexEnviv in display lists didn't work
+ - glRasterPos didn't do texgen or apply texture matrix
+ - GL_DOUBLE-valued vertex arrays were broken in some cases
+ - fixed texture rectangle edge/border sampling bugs
+ - sampling an incomplete texture in a fragment program would segfault
+ - glTexImage was missing a few error checks
+ - fixed some minor glGetTexParameter glitches
+ - GL_INTENSITY was mistakenly accepted as a <format> to glTexImage
+ - fragment program writes to RC/HC register were broken
+ - fixed a few glitches in GL_HP_occlusion_test extension
+ - glBeginQueryARB and glEndQueryARB didn't work inside display lists
+ - vertex program state references were broken
+ - fixed triangle color interpolation bug on AIX (Shane Blackett)
+ - fixed a number of minor memory leaks (bug #1002030)
+
+
+6.2 October 2, 2004
+ New:
+ - enabled GL_ARB_texture_rectangle (same as GL_NV_texture_rectangle)
+ - updated Doxygen support (Jose Fonseca)
+ Changes:
+ - some GGI driver updates (Christoph Egger, bug 1025977)
+ Bug fixes:
+ - Omit GL_ARB_texture_non_power_of_two from list of OpenGL 1.5 features
+ - fixed a few compilation issues on IRIX
+ - fixed a matrix classification bug (reported by Wes Bethel)
+ - we weren't reseting the vertex/fragment program error state
+ before parsing (Dave Reveman)
+ - adjust texcoords for sampling texture rectangles (Dave Reveman)
+ - glGet*(GL_MAX_VERTEX_ATTRIBS_ARB) wasn't implemented
+ - repeated calls to glDeleteTexture(t) could lead to a crash
+ - fixed potential ref count bugs in VBOs and vertex/fragment programs
+ - spriteblast demo didn't handle window size changes correctly
+ - glTexSubImage didn't handle pixels=NULL correctly for PBOs
+ - fixed color index mode glDrawPixels bug (Karl Schultz)
+
+
+6.2.1 December 9, 2004
+ Bug fixes:
+ - don't apply regular fog or color sum when using a fragment program
+ - glProgramEnvParameter4fARB always generated an error on
+ GL_FRAGMENT_PROGRAM_ARB (fdo bug 1645)
+ - glVertexAttrib3svNV and glVertexAttrib3svARB were broken
+ - fixed width/height mix-up in glSeparableFilter2D()
+ - fixed regression in glCopyPixels + convolution
+ - glReadPixels from a clipped front color buffer didn't always work
+ - glTexImage didn't accept GL_RED/GREEN/BLUE as the format
+ - Attempting queries/accesses of VBO 0 weren't detected as errors
+ - paletted textures failed if the palette had fewer than 256 entries
+ Changes:
+ - fixed a bunch of compiler warnings found with gcc 3.4
+ - bug reports should to go bugzilla.freedesktop.org
+
+
+6.3 July 20, 2005
+ New:
+ - GL_EXT_framebuffer_object extension
+ - GL_ARB_draw_buffers extension
+ - GL_ARB_pixel_buffer_object extension
+ - GL_OES_read_format extension (Ian Romanick)
+ - DirectFB driver (Claudio Ciccani)
+ - x86_64 vertex transformation code (Mikko T.)
+ - Updated GL/glext.h to version 29
+ Changes:
+ - added -stereo option for glxgears demo (Jacek Rosik)
+ - updated the PBuffer demo code in xdemos/ directory
+ - glDeleteTextures/Programs/Buffers() now makes the object ID
+ available for immediate re-use
+ - assorted 64-bit clean-ups fixes (x86_64 and Win64)
+ - lots of internal changes for GL_EXT_framebuffer_object
+ Bug fixes:
+ - some functions didn't support PBO functionality
+ - glGetTexImage didn't convert color index images to RGBA as required
+ - fragment program texcoords were sometimes wrong for points and lines
+ - fixed problem with negative dot product in arbfplight, fplight demos
+ - fixed bug in perspective correction of antialiased, textured lines
+ - querying GL_POST_CONVOLUTION_ALPHA_BIAS_EXT returned wrong value
+ - fixed a couple per-pixel fog bugs (Soju Matsumoto)
+ - glGetBooleanv(GL_FRAGMENT_PROGRAM_BINDING_NV) was broken
+ - fixed float parsing bug in ARB frag/vert programs (bug 2520)
+ - XMesaGetDepthBuffer() returned incorrect value for bytesPerValue
+ - GL_COLOR_MATERIAL with glColor3 didn't properly set diffuse alpha
+ - glXChooseFBConfig() crashed if attribList pointer was NULL
+ - program state.light[n].spot.direction.w was wrong value (bug 3083)
+ - fragment program fog option required glEnable(GL_FOG) - wrong.
+ - glColorTable() could produce a Mesa implementation error (bug 3135)
+ - RasterPos could get corrupted by color index rendering path
+ - Removed bad XTranslateCoordinates call when rendering to Pixmaps
+ - glPopAttrib() didn't properly restore GL_TEXTURE_GEN enable state
+ - fixed a few Darwin compilation problems
+
+
+6.3.1
+ This was an intermediate release for X.org which wasn't otherwise released.
+
+
+6.3.2 August 19, 2005
+ New:
+ - The distribution now includes the DRI drivers and GLX code
+ Changes:
+ - Made the DRI "new" driver interface standard, remove old code
+ Bug fixes:
+ - GL_ARB_vertex/fragment_shader were mistakenly listed in the
+ extensions string
+ - negative relative addressing in vertex programs was broken
+ - update/fix SPARC assembly code for vertex transformation
+ - fixed memory leak when freeing GLX drawables/renderbuffers
+ - fixed display list memory leak
+ - the GL_PIXEL_MAP_I_TO_I table is now floating point, not integer
+ - wglGetProcAddress() didn't handle wgl-functions
+ - fixed glxext.h cross-compile issue (Colin Harrison)
+ - assorted DRI driver fixes
+
+
+6.4 October 24, 2005
+ New:
+ - Added a fast XOR line drawing function in Xlib driver
+ - Added support for GL_ARB_texture_mirrored_repeat to savage
+ driver (supported only on Savage4 hardware).
+ Changes:
+ - Mesa now packaged in three parts: Library, Demos and GLUT
+ Bug fixes:
+ - GLX_X_RENDERABLE token wasn't accepted by glXChooseFBConfig
+ - Some files were present multiple times in the 6.3.2 tarballs
+ - r200_vtxtmp_x86.S file was missing from 6.3.2 tarball (bug 4207)
+ - glxgears_fbconfig demo didn't work (bug 4237)
+ - fixed bug when bilinear sampling 2d textures with borders
+ - glXCreatePbuffer() could segfault instead of returning 0 (bug 4235)
+ - fixed undefined frexp and rand in X.org libGLcore.a (bug 4242)
+ - fixed a few problems with proxy color tables (bug 4270)
+ - fixed precision problem in Z clearing (bug 4395)
+ - glBitmap, glDraw/CopyPixels mistakenly generated selection hits
+ - fixed potential segfault caused by reading pixels outside
+ of renderbuffer bounds
+ - glGetTexLevelParameter didn't accept GL_TEXTURE_DEPTH_SIZE_ARB
+ - fixed memory corruption bug involving software alpha buffers
+ - glReadPixels clipped by window bounds was sometimes broken
+ - glDraw/CopyPixels of stencil data ignored the stencil write mask
+ - glReadPixels from a texture bound to a framebuffer object didn't work
+ - glIsRender/FramebufferEXT weren't totally correct
+ - fixed a number of point size attenuation/fade bugs
+ - fixed glFogCoord bug 4729
+ - GLX encoding for transpose matrix functions was broken
+ - fixed broken fragment program KIL and SWZ instructions
+ - fragment programs that wrote result.depth.z didn't work
+
+
+6.4.1 November 30, 2005
+ Bug fixes:
+ - redefining a vertex program string didn't take effect in TNL module
+ - fixed occasional segfault upon vertex/fragment parsing error
+ - vertex program LIT instruction didn't handle 0^0=1 correctly
+ - fragment program fog option didn't work with glDrawPixels, glBitmap
+ - USE_MGL_NAMESPACE didn't work for x86-64
+ - OSMesa demos were missing from previous release tarballs
+ - fixed problem with float->ushort conversion in glClear (bug 4992)
+ - popping of GL_EYE_PLANE texgen state was broken (bug 4996)
+ - popping of GL_SPOT_DIRECTION light state was broken (bug 5005)
+ - fixed occasional triangle color interpolation problem on VMS
+ - work around invalid free() call (bug 5131)
+ - fixed BSD X server compilation problem by including stdint.h
diff --git a/nx-X11/extras/Mesa/docs/banner.html b/nx-X11/extras/Mesa/docs/banner.html
new file mode 100644
index 000000000..9cb27bb6d
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/banner.html
@@ -0,0 +1,27 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title>Banner</title>
+</head>
+<body bgcolor="#000000" text="#ffffff">
+<center>
+<table style="width: 95%; text-align: left;" border="0" cellpadding="2"
+ cellspacing="2">
+ <tbody>
+ <tr>
+ <td style="vertical-align: top;">
+ <p><img src="gears.png"> </p>
+ </td>
+ <td style="text-align: center;"><font face="sans-serif" size="5">The
+Mesa 3D Graphics Library</font></td>
+ <td style="vertical-align: top; text-align: right;">
+ <p><img src="gears.png"> </p>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<p><font face="sans-serif" size="5"><br>
+</font></p>
+</center>
+</body>
+</html>
diff --git a/nx-X11/extras/Mesa/docs/bugs.html b/nx-X11/extras/Mesa/docs/bugs.html
new file mode 100644
index 000000000..d255f4292
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/bugs.html
@@ -0,0 +1,49 @@
+<HTML>
+
+<TITLE>Mesa Bug Reporting</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Bug Database</H1>
+
+<p>
+The Mesa bug database is now hosted on
+<a href="http://freedesktop.org" target="_parent">freedesktop.org</a>
+instead of SourceForge.
+</p>
+
+<p>
+To file a Mesa bug, go to
+<a href="https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa"
+target="_parent">
+Bugzilla on freedesktop.org</a>
+</p>
+
+<p>
+Please follow these bug reporting guidelines:
+</p>
+
+<ul>
+<li>Make sure you're using the most recent version of Mesa
+<li>Make sure your bug isn't already reported
+<li>Include as much information as possible in the report
+<li>Provide a simple GLUT-based test program if possible
+<li>Check back for follow-ups to the report
+</ul>
+
+<p>
+Bug reports will automatically be forwarded to the Mesa developer's mailing
+list.
+</p>
+
+<p>
+The easier a bug is to reproduce, the sooner it will be fixed.
+Please do everything you can to facilitate quickly fixing bugs.
+If your bug report is vague or your test program doesn't compile
+easily, the problem may not be fixed very quickly.
+</p>
+
+</BODY>
+</HTML>
diff --git a/nx-X11/extras/Mesa/docs/conform.html b/nx-X11/extras/Mesa/docs/conform.html
new file mode 100644
index 000000000..3611f8c6f
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/conform.html
@@ -0,0 +1,695 @@
+<HTML>
+
+<TITLE>Conformance</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Conformance</H1>
+
+<p>
+The SGI OpenGL conformance tests verify correct operation of OpenGL
+implementations. I, Brian Paul, have been given a copy of the tests
+for testing Mesa. The tests are not publically available.
+</p>
+<p>
+This file has the latest results of testing Mesa with the OpenGL 1.2
+conformance tests. Testing with the preliminary OpenGL 1.3 tests has
+also been done. Mesa passes all the 1.3 tests.
+</p>
+<p>
+The tests were run using the software X11 device driver on 24-bpp
+and 16-bpp displays.
+</p>
+<p>
+Mesa 4.0 and later pass all conformance tests at all path levels.
+Note that this says nothing about the conformance of hardware drivers
+based upon Mesa.
+</p>
+
+
+<pre>
+
+COVERAGE TESTS
+--------------
+
+Test that all API functions accept the legal parameters and reject
+illegal parameters. The result of each test is either pass or fail.
+
+% covgl
+OpenGL Coverage Test.
+Version 1.2
+
+covgl passed.
+
+covgl passed at 1.1 level.
+
+covgl passed at 1.2 level.
+
+covgl passed for ARB_multitexture.
+
+
+% covglu
+OpenGL GLU Coverage Test.
+Version 1.3
+
+covglu passed.
+
+covglu passed at 1.1 level.
+
+
+% covglx
+OpenGL X Coverage Test.
+Version 1.1.1
+
+covglx passed.
+
+
+% primtest -v
+Open GL Primitives Test.
+Version 1.2
+
+[lots of output deleted]
+
+292159 Combinations.
+primtest passed.
+
+
+
+
+GL CONFORMANCE TEST
+===================
+
+Render test images, read them back, then test for expected results.
+
+
+----------------------------------------------------------------------
+% conform -v 2
+
+OpenGL Conformance Test
+Version 1.2
+
+Setup Report.
+ Verbose level = 2.
+ Random number seed = 1.
+ Path inactive.
+
+Visual Report.
+ Display ID = 35. Indirect Rendering.
+ Double Buffered.
+ RGBA (5, 6, 5, 0).
+ Stencil (8).
+ Depth (16).
+ Accumulation (16, 16, 16, 16).
+
+Epsilon Report.
+ zero error epsilon = 0.000122.
+ RGBA error epsilon = 0.0324, 0.016, 0.0324, 0.000122.
+ Depth buffer error epsilon = 0.000137.
+ Stencil plane error epsilon = 0.00404.
+ Accumulation error epsilon = 0.000137, 0.000137, 0.000137, 0.000137.
+
+Default State test passed.
+Must Pass test passed.
+Divide By Zero test passed.
+Viewport Clamp test passed.
+Matrix Stack test passed.
+Matrix Stack Mixing test passed.
+Vertex Order test passed.
+Transformations test passed.
+Transformation Normal test passed.
+Viewport Transformation test passed.
+Buffer Clear test passed.
+Buffer Corners test passed.
+Buffer Color test passed.
+Color Ramp test passed.
+Mask test passed.
+Buffer Invariance test passed.
+Accumulation Buffer test passed.
+Select test passed.
+Feedback test passed.
+Scissor test passed.
+Alpha Plane Function test passed.
+Stencil Plane Clear test passed.
+Stencil Plane Corners test passed.
+Stencil Plane Operation test passed.
+Stencil Plane Function test passed.
+Depth Buffer Clear test passed.
+Depth Buffer Function test passed.
+Blend test passed.
+Dither test passed.
+LogicOp Function test does not exist for an RGB visual.
+DrawPixels test passed.
+CopyPixels test passed.
+Bitmap Rasterization test passed.
+Point Rasterization test passed.
+Anti-aliased Point test passed.
+Line Rasterization test passed.
+Line Stipple test passed.
+Anti-aliased Line test passed.
+Horizontal and Vertical Line test passed.
+Triangle Rasterization test passed.
+Triangle Tile test passed.
+Triangle Stipple test passed.
+Anti-aliased Triangles test passed.
+Quad Rasterization test passed.
+Polygon Face test passed.
+Polygon Cull test passed.
+Polygon Stipple test passed.
+Polygon Edge test passed.
+Ambient Material test passed.
+Ambient Scene test passed.
+Attenuation Position test passed.
+Diffuse Light test passed.
+Diffuse Material test passed.
+Diffuse Material Normal test passed.
+Diffuse Material Positioning test passed.
+Emissive Material test passed.
+Specular Exponent test passed.
+Specular Exponent Normal test passed.
+Specular Local Eye Half Angle test passed.
+Specular Light test passed.
+Specular Material test passed.
+Specular Normal test passed.
+Spot Positioning test passed.
+Spot Exponent and Positioning test passed.
+Spot Exponent and Direction test passed.
+Fog Exponential test passed.
+Fog Linear test passed.
+Texture Decal test passed.
+Texture Border test passed.
+Mipmaps Selection test passed.
+Mipmaps Interpolation test passed.
+Display Lists test passed.
+Evaluator test passed.
+Evaluator Color test passed.
+Texture Edge Clamp test passed.
+Packed Pixels test passed.
+Texture LOD test passed.
+Rescale Normal test passed.
+Color Table test passed.
+Convolution test passed.
+Convolution Border test passed.
+Histogram test passed.
+MinMax test passed.
+MultiTexture test passed.
+
+Conform passed.
+
+----------------------------------------------------------------------
+% conform -v 2 -p 1
+
+OpenGL Conformance Test
+Version 1.2
+
+Setup Report.
+ Verbose level = 2.
+ Random number seed = 1.
+ Path level = 1.
+
+Visual Report.
+ Display ID = 35. Indirect Rendering.
+ Double Buffered.
+ RGBA (5, 6, 5, 0).
+ Stencil (8).
+ Depth (16).
+ Accumulation (16, 16, 16, 16).
+
+Epsilon Report.
+ zero error epsilon = 0.000122.
+ RGBA error epsilon = 0.0324, 0.016, 0.0324, 0.000122.
+ Depth buffer error epsilon = 0.000137.
+ Stencil plane error epsilon = 0.00404.
+ Accumulation error epsilon = 0.000137, 0.000137, 0.000137, 0.000137.
+
+Default State test passed.
+Must Pass test passed.
+Divide By Zero test passed.
+Viewport Clamp test passed.
+Matrix Stack test passed.
+Matrix Stack Mixing test passed.
+Vertex Order test passed.
+Transformations test passed.
+Transformation Normal test passed.
+Viewport Transformation test passed.
+Buffer Clear test passed.
+Buffer Corners test passed.
+Buffer Color test passed.
+Color Ramp test passed.
+Mask test passed.
+Buffer Invariance test passed.
+Accumulation Buffer test passed.
+Select test passed.
+Feedback test passed.
+Scissor test passed.
+Alpha Plane Function test passed.
+Stencil Plane Clear test passed.
+Stencil Plane Corners test passed.
+Stencil Plane Operation test passed.
+Stencil Plane Function test passed.
+Depth Buffer Clear test passed.
+Depth Buffer Function test passed.
+Blend test passed.
+Dither test passed.
+LogicOp Function test does not exist for an RGB visual.
+DrawPixels test passed.
+CopyPixels test passed.
+Bitmap Rasterization test passed.
+Point Rasterization test passed.
+Anti-aliased Point test passed.
+Line Rasterization test passed.
+Line Stipple test passed.
+Anti-aliased Line test passed.
+Horizontal and Vertical Line test passed.
+Triangle Rasterization test passed.
+Triangle Tile test passed.
+Triangle Stipple test passed.
+Anti-aliased Triangles test passed.
+Quad Rasterization test passed.
+Polygon Face test passed.
+Polygon Cull test passed.
+Polygon Stipple test passed.
+Polygon Edge test passed.
+Ambient Material test passed.
+Ambient Scene test passed.
+Attenuation Position test passed.
+Diffuse Light test passed.
+Diffuse Material test passed.
+Diffuse Material Normal test passed.
+Diffuse Material Positioning test passed.
+Emissive Material test passed.
+Specular Exponent test passed.
+Specular Exponent Normal test passed.
+Specular Local Eye Half Angle test passed.
+Specular Light test passed.
+Specular Material test passed.
+Specular Normal test passed.
+Spot Positioning test passed.
+Spot Exponent and Positioning test passed.
+Spot Exponent and Direction test passed.
+Fog Exponential test passed.
+Fog Linear test passed.
+Texture Decal test passed.
+Texture Border test passed.
+Mipmaps Selection test passed.
+Mipmaps Interpolation test passed.
+Display Lists test passed.
+Evaluator test passed.
+Evaluator Color test passed.
+Texture Edge Clamp test passed.
+Packed Pixels test passed.
+Texture LOD test passed.
+Rescale Normal test passed.
+Color Table test passed.
+Convolution test passed.
+Convolution Border test passed.
+Histogram test passed.
+MinMax test passed.
+MultiTexture test passed.
+
+Conform passed.
+
+----------------------------------------------------------------------
+% conform -v 2 -p 2
+
+OpenGL Conformance Test
+Version 1.2
+
+Setup Report.
+ Verbose level = 2.
+ Random number seed = 1.
+ Path level = 2.
+
+Visual Report.
+ Display ID = 35. Indirect Rendering.
+ Double Buffered.
+ RGBA (5, 6, 5, 0).
+ Stencil (8).
+ Depth (16).
+ Accumulation (16, 16, 16, 16).
+
+Epsilon Report.
+ zero error epsilon = 0.000122.
+ RGBA error epsilon = 0.0324, 0.016, 0.0324, 0.000122.
+ Depth buffer error epsilon = 0.000137.
+ Stencil plane error epsilon = 0.00404.
+ Accumulation error epsilon = 0.000137, 0.000137, 0.000137, 0.000137.
+
+Default State test passed.
+Must Pass test passed.
+Divide By Zero test passed.
+Viewport Clamp test passed.
+Matrix Stack test passed.
+Matrix Stack Mixing test passed.
+Vertex Order test passed.
+Transformations test passed.
+Transformation Normal test passed.
+Viewport Transformation test passed.
+Buffer Clear test passed.
+Buffer Corners test passed.
+Buffer Color test passed.
+Color Ramp test passed.
+Mask test passed.
+Buffer Invariance test passed.
+Accumulation Buffer test passed.
+Select test passed.
+Feedback test passed.
+Scissor test passed.
+Alpha Plane Function test passed.
+Stencil Plane Clear test passed.
+Stencil Plane Corners test passed.
+Stencil Plane Operation test passed.
+Stencil Plane Function test passed.
+Depth Buffer Clear test passed.
+Depth Buffer Function test passed.
+Blend test passed.
+Dither test passed.
+LogicOp Function test does not exist for an RGB visual.
+DrawPixels test passed.
+CopyPixels test passed.
+Bitmap Rasterization test passed.
+Point Rasterization test passed.
+Anti-aliased Point test passed.
+Line Rasterization test passed.
+Line Stipple test passed.
+Anti-aliased Line test passed.
+Horizontal and Vertical Line test passed.
+Triangle Rasterization test passed.
+Triangle Tile test passed.
+Triangle Stipple test passed.
+Anti-aliased Triangles test passed.
+Quad Rasterization test passed.
+Polygon Face test passed.
+Polygon Cull test passed.
+Polygon Stipple test passed.
+Polygon Edge test passed.
+Ambient Material test passed.
+Ambient Scene test passed.
+Attenuation Position test passed.
+Diffuse Light test passed.
+Diffuse Material test passed.
+Diffuse Material Normal test passed.
+Diffuse Material Positioning test passed.
+Emissive Material test passed.
+Specular Exponent test passed.
+Specular Exponent Normal test passed.
+Specular Local Eye Half Angle test passed.
+Specular Light test passed.
+Specular Material test passed.
+Specular Normal test passed.
+Spot Positioning test passed.
+Spot Exponent and Positioning test passed.
+Spot Exponent and Direction test passed.
+Fog Exponential test passed.
+Fog Linear test passed.
+Texture Decal test passed.
+Texture Border test passed.
+Mipmaps Selection test passed.
+Mipmaps Interpolation test passed.
+Display Lists test passed.
+Evaluator test passed.
+Evaluator Color test passed.
+Texture Edge Clamp test passed.
+Packed Pixels test passed.
+Texture LOD test passed.
+Rescale Normal test passed.
+Color Table test passed.
+Convolution test passed.
+Convolution Border test passed.
+Histogram test passed.
+MinMax test passed.
+MultiTexture test passed.
+
+Conform passed.
+
+----------------------------------------------------------------------
+% conform -v 2 -p 3
+
+OpenGL Conformance Test
+Version 1.2
+
+Setup Report.
+ Verbose level = 2.
+ Random number seed = 1.
+ Path level = 3.
+
+Visual Report.
+ Display ID = 35. Indirect Rendering.
+ Double Buffered.
+ RGBA (5, 6, 5, 0).
+ Stencil (8).
+ Depth (16).
+ Accumulation (16, 16, 16, 16).
+
+Epsilon Report.
+ zero error epsilon = 0.000122.
+ RGBA error epsilon = 0.0324, 0.016, 0.0324, 0.000122.
+ Depth buffer error epsilon = 0.000137.
+ Stencil plane error epsilon = 0.00404.
+ Accumulation error epsilon = 0.000137, 0.000137, 0.000137, 0.000137.
+
+Default State test passed.
+Must Pass test passed.
+Divide By Zero test passed.
+Viewport Clamp test passed.
+Matrix Stack test passed.
+Matrix Stack Mixing test passed.
+Vertex Order test passed.
+Transformations test passed.
+Transformation Normal test passed.
+Viewport Transformation test passed.
+Buffer Clear test passed.
+Buffer Corners test passed.
+Buffer Color test passed.
+Color Ramp test passed.
+Mask test passed.
+Buffer Invariance test passed.
+Accumulation Buffer test passed.
+Select test passed.
+Feedback test passed.
+Scissor test passed.
+Alpha Plane Function test passed.
+Stencil Plane Clear test passed.
+Stencil Plane Corners test passed.
+Stencil Plane Operation test passed.
+Stencil Plane Function test passed.
+Depth Buffer Clear test passed.
+Depth Buffer Function test passed.
+Blend test passed.
+Dither test passed.
+LogicOp Function test does not exist for an RGB visual.
+DrawPixels test passed.
+CopyPixels test passed.
+Bitmap Rasterization test passed.
+Point Rasterization test passed.
+Anti-aliased Point test passed.
+Line Rasterization test passed.
+Line Stipple test passed.
+Anti-aliased Line test passed.
+Horizontal and Vertical Line test passed.
+Triangle Rasterization test passed.
+Triangle Tile test passed.
+Triangle Stipple test passed.
+Anti-aliased Triangles test passed.
+Quad Rasterization test passed.
+Polygon Face test passed.
+Polygon Cull test passed.
+Polygon Stipple test passed.
+Polygon Edge test passed.
+Ambient Material test passed.
+Ambient Scene test passed.
+Attenuation Position test passed.
+Diffuse Light test passed.
+Diffuse Material test passed.
+Diffuse Material Normal test passed.
+Diffuse Material Positioning test passed.
+Emissive Material test passed.
+Specular Exponent test passed.
+Specular Exponent Normal test passed.
+Specular Local Eye Half Angle test passed.
+Specular Light test passed.
+Specular Material test passed.
+Specular Normal test passed.
+Spot Positioning test passed.
+Spot Exponent and Positioning test passed.
+Spot Exponent and Direction test passed.
+Fog Exponential test passed.
+Fog Linear test passed.
+Texture Decal test passed.
+Texture Border test passed.
+Mipmaps Selection test passed.
+Mipmaps Interpolation test passed.
+Display Lists test passed.
+Evaluator test passed.
+Evaluator Color test passed.
+Texture Edge Clamp test passed.
+Packed Pixels test passed.
+Texture LOD test passed.
+Rescale Normal test passed.
+Color Table test passed.
+Convolution test passed.
+Convolution Border test passed.
+Histogram test passed.
+MinMax test passed.
+MultiTexture test passed.
+
+Conform passed.
+
+----------------------------------------------------------------------
+% conform -v 2 -p 4
+
+OpenGL Conformance Test
+Version 1.2
+
+Setup Report.
+ Verbose level = 2.
+ Random number seed = 1.
+ Path level = 4.
+
+Visual Report.
+ Display ID = 35. Indirect Rendering.
+ Double Buffered.
+ RGBA (5, 6, 5, 0).
+ Stencil (8).
+ Depth (16).
+ Accumulation (16, 16, 16, 16).
+
+Epsilon Report.
+ zero error epsilon = 0.000122.
+ RGBA error epsilon = 0.0324, 0.016, 0.0324, 0.000122.
+ Depth buffer error epsilon = 0.000137.
+ Stencil plane error epsilon = 0.00404.
+ Accumulation error epsilon = 0.000137, 0.000137, 0.000137, 0.000137.
+
+Default State test passed.
+Must Pass test passed.
+Divide By Zero test passed.
+Viewport Clamp test passed.
+Matrix Stack test passed.
+Matrix Stack Mixing test passed.
+Vertex Order test passed.
+Transformations test passed.
+Transformation Normal test passed.
+Viewport Transformation test passed.
+Buffer Clear test passed.
+Buffer Corners test passed.
+Buffer Color test passed.
+Color Ramp test passed.
+Mask test passed.
+Buffer Invariance test passed.
+Accumulation Buffer test passed.
+Select test passed.
+Feedback test passed.
+Scissor test passed.
+Alpha Plane Function test passed.
+Stencil Plane Clear test passed.
+Stencil Plane Corners test passed.
+Stencil Plane Operation test passed.
+Stencil Plane Function test passed.
+Depth Buffer Clear test passed.
+Depth Buffer Function test passed.
+Blend test passed.
+Dither test passed.
+LogicOp Function test does not exist for an RGB visual.
+DrawPixels test passed.
+CopyPixels test passed.
+Bitmap Rasterization test passed.
+Point Rasterization test passed.
+Anti-aliased Point test passed.
+Line Rasterization test passed.
+Line Stipple test passed.
+Anti-aliased Line test passed.
+Horizontal and Vertical Line test passed.
+Triangle Rasterization test passed.
+Triangle Tile test passed.
+Triangle Stipple test passed.
+Anti-aliased Triangles test passed.
+Quad Rasterization test passed.
+Polygon Face test passed.
+Polygon Cull test passed.
+Polygon Stipple test passed.
+Polygon Edge test passed.
+Ambient Material test passed.
+Ambient Scene test passed.
+Attenuation Position test passed.
+Diffuse Light test passed.
+Diffuse Material test passed.
+Diffuse Material Normal test passed.
+Diffuse Material Positioning test passed.
+Emissive Material test passed.
+Specular Exponent test passed.
+Specular Exponent Normal test passed.
+Specular Local Eye Half Angle test passed.
+Specular Light test passed.
+Specular Material test passed.
+Specular Normal test passed.
+Spot Positioning test passed.
+Spot Exponent and Positioning test passed.
+Spot Exponent and Direction test passed.
+Fog Exponential test passed.
+Fog Linear test passed.
+Texture Decal test passed.
+Texture Border test passed.
+Mipmaps Selection test passed.
+Mipmaps Interpolation test passed.
+Display Lists test passed.
+Evaluator test passed.
+Evaluator Color test passed.
+Texture Edge Clamp test passed.
+Packed Pixels test passed.
+Texture LOD test passed.
+Rescale Normal test passed.
+Color Table test passed.
+Convolution test passed.
+Convolution Border test passed.
+Histogram test passed.
+MinMax test passed.
+MultiTexture test passed.
+
+Conform passed.
+
+
+
+GLX CONFORMANCE TEST
+====================
+
+% conformx -v 2
+
+OpenGL X Conformance Test
+Version 1.1.1
+
+Setup Report.
+ Verbose level = 2.
+ Random number seed = 1.
+ Path inactive.
+
+Visual Report.
+ Display ID = 34. Direct Rendering.
+ Double Buffered.
+ RGBA (8, 8, 8, 0).
+ Stencil (8).
+ Depth (16).
+ Accumulation (16, 16, 16, 16).
+
+Epsilon Report.
+ zero error epsilon = 0.000122.
+ RGBA error epsilon = 0.00404, 0.00404, 0.00404, 0.000122.
+ Depth buffer error epsilon = 0.000137.
+ Stencil plane error epsilon = 0.00404.
+ Accumulation error epsilon = 0.000137, 0.000137, 0.000137, 0.000137.
+
+Default State test passed.
+glReadPixels() test passed.
+Font test passed.
+
+Conformx passed.
+
+
+</pre>
+
+NOTE: conformx passes for all machine path levels (-p option).
+
+
+</body>
+</html>
diff --git a/nx-X11/extras/Mesa/docs/contents.html b/nx-X11/extras/Mesa/docs/contents.html
new file mode 100644
index 000000000..88b7bc7de
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/contents.html
@@ -0,0 +1,101 @@
+<html>
+
+<title>Contents</title>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<!--Override a few values from the style sheet: -->
+<style>
+<!--
+body {
+ background-color: #cccccc;
+ color: black;
+}
+a:link {
+ color: #000;
+}
+a:visited {
+ color: #000;
+}
+-->
+</style>
+
+
+<b>Documentation</b>
+<ul>
+<li><a href="intro.html" target="MainFrame">Introduction</a>
+<li><a href="news.html" target="MainFrame">News</a>
+<li><a href="systems.html" target="MainFrame">Platforms and Drivers</a>
+<li><a href="license.html" target="MainFrame">License & Copyright</a>
+<li><a href="faq.html" target="MainFrame">FAQ</a>
+<li><a href="VERSIONS" target="MainFrame">Version History</a>
+<li><a href="relnotes.html" target="MainFrame">Release Notes</a>
+<li><a href="thanks.html" target="MainFrame">Acknowledgements</a>
+<li><a href="conform.html" target="MainFrame">Conformance Testing</a>
+<li>more docs below...
+</ul>
+
+<b>Download / Install</b>
+<ul>
+<li><a href="download.html" target="MainFrame">Downloading/Unpacking</a>
+<li><a href="install.html" target="MainFrame">Compilation/Installation</a>
+<li><a href="glu.html" target="MainFrame">SGI's GLU</a>
+<li><a href="precompiled.html" target="MainFrame">Precompiled Libraries</a>
+</ul>
+
+<b>Resources</b>
+<ul>
+<li><a href="lists.html" target="MainFrame">Mailing Lists</a>
+<li><a href="bugs.html" target="MainFrame">Bug Database</a>
+<li><a href="webmaster.html" target="MainFrame">Webmaster</a>
+</ul>
+
+<b>User Topics</b>
+<ul>
+<LI><A HREF="envvars.html" target="MainFrame">Environment Variables</A>
+<LI><A HREF="osmesa.html" target="MainFrame">Off-Screen Rendering</A>
+<LI><A HREF="pbuffers.html" target="MainFrame">Pbuffer Rendering</A>
+<LI><A HREF="debugging.html" target="MainFrame">Debugging Tips</A>
+<LI><A HREF="perf.html" target="MainFrame">Performance Tips</A>
+<LI><A HREF="extensions.html" target="MainFrame">Mesa Extensions</A>
+<LI><A HREF="mangling.html" target="MainFrame">Function Name Mangling</A>
+</ul>
+
+<b>Developer Topics</b>
+<ul>
+<li><a href="http://sourceforge.net/projects/mesa3d" target="_parent">SourceForge homepage</a>
+<li><a href="cvs_access.html" target="MainFrame">CVS Access</a>
+<li><a href="cvs_branches.html" target="MainFrame">CVS Branch Info</a>
+<li><a href="utilities.html" target="MainFrame">Utilities</a>
+<li><a href="helpwanted.html" target="MainFrame">Help Wanted</a>
+<li><a href="devinfo.html" target="MainFrame">Development Notes</a>
+<li><a href="sourcedocs.html" target="MainFrame">Source Documentation</a>
+<li><a href="subset.html" target="MainFrame">Subset Information</a>
+<li><a href="fbdev-dri.html" target="MainFrame">fbdev/DRI Environment</a>
+<li><a href="glfbdev-driver.html" target="MainFrame">glFBDev Driver</a>
+<LI><A HREF="custom.html" target="MainFrame">Custom Development</A>
+</ul>
+
+<b>Links</b>
+<ul>
+<li><a href="http://www.opengl.org" target="_parent">OpenGL website</a>
+<li><a href="http://dri.sourceforge.net" target="_parent">DRI website</a>
+<li><a href="http://www.freedesktop.org" target="_parent">freedesktop.org</a>
+<li><a href="games.html" target="MainFrame">Games and Entertainment</a>
+<li><a href="libraries.html" target="MainFrame">Libraries and Toolkits</a>
+<li><a href="modelers.html" target="MainFrame">Modeling and Rendering</a>
+<li><a href="science.html" target="MainFrame">Science and Technical</a>
+<li><a href="utility.html" target="MainFrame">Utilities</a>
+<li><a href="demos.html" target="MainFrame">Demos / other</a>
+</ul>
+
+<b>Hosted by:</b>
+<br>
+<blockquote>
+<A HREF="http://sourceforge.net"
+target="_parent"><IMG SRC="http://sourceforge.net/sflogo.php?group_id=3&type=1"
+WIDTH="88" HEIGHT="31" ALIGN="BOTTOM" ALT="Sourceforge.net" BORDER="0"></A>
+</blockquote>
+
+</body>
+</html> \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/docs/custom.html b/nx-X11/extras/Mesa/docs/custom.html
new file mode 100644
index 000000000..e9beba6fa
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/custom.html
@@ -0,0 +1,27 @@
+<HTML>
+
+<TITLE>Custom Development</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Custom Development</H1>
+
+<p>
+Mesa is primarily developed and maintained on a volunteer basis.
+Some Mesa development work has been done in conjuction with contracted
+projects, such as the XFree86/DRI drivers.
+</p>
+
+<p>
+<pre>[Begin shameless plug]</pre>
+If you have a need for specific or custom Mesa development work,
+<a href="http://www.tungstengraphics.com/" target="_parent">
+Tungsten Graphics, Inc.</a> may be able to help you.
+<pre>[End shameless plug]</pre>
+</p>
+
+
+</body>
+</html>
diff --git a/nx-X11/extras/Mesa/docs/cvs_access.html b/nx-X11/extras/Mesa/docs/cvs_access.html
new file mode 100644
index 000000000..c57f1c832
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/cvs_access.html
@@ -0,0 +1,106 @@
+<HTML>
+
+<TITLE>CVS Access</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<h1>CVS Access</h1>
+
+<p>
+Mesa's CVS repository (code management system) is hosted on
+<a href="http://www.freedesktop.org" target="_parent">freedesktop.org</a>.
+</p>
+
+<p>
+You may access the repository either as an
+<a href="#anonymous">anonymous user</a> (read-only) or as a
+<a href="#developer">developer</a>
+(read/write).
+</p>
+
+<p>
+You may also
+<a href="http://freedesktop.org/cgi-bin/viewcvs.cgi/mesa/Mesa/"
+target="_parent">browse the CVS repository</a>.
+</p>
+
+
+<a name="anonymous">
+<H2>Anonymous CVS Access</H2>
+
+<p>
+Anonymous, public, read-only access to the CVS repository is available.
+Here are the basic instructions for Unix systems:
+</p>
+
+<ol>
+<li>Install CVS client software on your computer if needed.
+ Version 1.9.28 is known to work.
+<li>Login as an anonymous user:
+ <pre>
+ cvs -d:pserver:anonymous@pdx.freedesktop.org:/cvs/mesa login
+ </pre>
+ Just press Enter/Return when prompted for a password.
+ <br>
+ <br>
+<li>Check out the code:
+ <pre>
+ cvs -d:pserver:anonymous@pdx.freedesktop.org:/cvs/mesa co Mesa
+ </pre>
+</ol>
+
+
+<p>To update your Mesa CVS source to the latest CVS source:</p>
+
+<ol>
+<li><code>cd Mesa</code>
+<li><code>cvs -z3 -d:pserver:anonymous@pdx.freedesktop.org:/cvs/mesa update</code>
+</ol>
+
+
+<a name="developer">
+<H2>Developer CVS Access</H2>
+
+<p>
+Mesa developers working with the Mesa CVS repository need to first
+have an account on <a href="http://www.freedesktop.org" target="_parent">
+freedesktop.org</a>.
+To get an account, please ask Brian or the other Mesa developers for
+permission.
+Then, if there are no objections, follow this
+<a href="http://www.freedesktop.org/wiki/AccountRequests" target="_parent">
+procedure</a>.
+</p>
+
+<p>
+Once your account is established, you can check out the Mesa CVS tree
+with:
+<pre>
+ setenv CVS_RSH ssh (if using a csh-like shell)
+</pre>
+<em>OR</em>
+<pre>
+ export CVS_RSH=rsh (if using a bash-like shell)
+</pre>
+followed by:
+<pre>
+ cvs -d:ext:yourusername@pdx.freedesktop.org:/cvs/mesa co Mesa
+</pre>
+
+<p>
+Of course, replace <em>yourusername</em> with your actual login name.
+</p>
+
+<p>
+Subsequent updates should only require:
+</p>
+<pre>
+ cvs update
+</pre>
+
+
+
+</body>
+</html>
diff --git a/nx-X11/extras/Mesa/docs/cvs_branches.html b/nx-X11/extras/Mesa/docs/cvs_branches.html
new file mode 100644
index 000000000..98df3d0f4
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/cvs_branches.html
@@ -0,0 +1,80 @@
+<HTML>
+
+<TITLE>CVS Branches</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>CVS Branch Information</H1>
+
+<p>
+At any given time, there may be several active branches in Mesa's
+CVS repository.
+
+Generally, the CVS trunk contains the latest development (unstable)
+code while a CVS branch has the latest stable code.
+</p>
+
+<p>
+Currently (Oct 2004), the trunk is the Mesa 6.3 development code
+while the mesa_6_2_branch branch has the stable Mesa 6.2.x code.
+</p>
+
+<p>
+Mesa releases use an even/odd numbering scheme to represent stable/development
+releases.
+
+For example, Mesa 6.2 (0 is considered even) is a stable release while
+Mesa 6.3 is a development release.
+</p>
+
+<p>
+To checkout a specific CVS branch pass <code>-r</code> and
+the branch tag after your CVS command.
+
+For example <code>cvs checkout -r mesa_6_2_branch Mesa</code> will
+checkout the 6.2 branch and <code>cvs update -r
+mesa_6_2_branch</code> will convert your current CVS tree to the 6.2
+branch.
+
+Consult <a href="http://www.durak.org/cvswebsites/doc/cvs_5.php3#SEC54"
+target="_parent">http://www.durak.org/cvswebsites/doc/cvs_5.php3#SEC54</a>
+for more on branching in CVS.
+</p>
+
+<p>
+To see a list of all the CVS branches run <code>cvs log README</code> (or any
+other file) and look for the section labeled <code>symbolic names</code>.
+You'll see something like this:
+</p>
+
+<pre> symbolic names:
+ mesa_4_0: 1.3
+ mesa_4_0_branch: 1.3.0.6
+ mesa_3_5: 1.3
+ mesa_3_4_2: 1.3
+ mesa_3_4_1: 1.3
+ mesa_3_4: 1.3
+ mesa_3_4_branch: 1.3.0.4
+ mesa_3_3: 1.3
+ mesa_3_2_1: 1.1.1.1
+ mesa_3_3_texture_env_combine2: 1.3.0.2
+ mesa_3_2: 1.1.1.1
+ mesa_3_2_beta_1: 1.1.1.1
+ mesa_3_1: 1.1.1.1
+ mesa_3_2_dev: 1.1.1.1.0.2
+ mesa_3_1_beta_3: 1.1.1.1
+ start: 1.1.1.1
+ mesa: 1.1.1
+</pre>
+
+<p>
+Most will be obsolete branches. Generally, the newer branches are at
+the top. Ask on the mesa3d-dev mailing list to learn which branches
+are active.
+</p>
+
+
+</body>
+</html> \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/docs/debugging.html b/nx-X11/extras/Mesa/docs/debugging.html
new file mode 100644
index 000000000..2df62f56e
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/debugging.html
@@ -0,0 +1,38 @@
+<HTML>
+
+<TITLE>Debugging Tips</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Debugging Tips</H1>
+
+<p>
+ Normally Mesa (and OpenGL) records but does not notify the user of
+ errors. It is up to the application to call
+ <code>glGetError</code> to check for errors. Mesa supports an
+ environment variable, MESA_DEBUG, to help with debugging. If
+ MESA_DEBUG is defined, a message will be printed to stdout whenever
+ an error occurs.
+</p>
+
+<p>
+ More extensive error checking is done when Mesa is compiled with the
+ DEBUG symbol defined. You'll have to edit the Make-config file and
+ add -DDEBUG to the CFLAGS line for your system configuration. You may
+ also want to replace any optimization flags with the -g flag so you can
+ use your debugger. After you've edited Make-config type 'make clean'
+ before recompiling.
+</p>
+<p>
+ In your debugger you can set a breakpoint in _mesa_error() to trap Mesa
+ errors.
+</p>
+<p>
+ There is a display list printing/debugging facility. See the end of
+ src/dlist.c for details.
+</p>
+
+</BODY>
+</HTML>
diff --git a/nx-X11/extras/Mesa/docs/demos.html b/nx-X11/extras/Mesa/docs/demos.html
new file mode 100644
index 000000000..b4a2cc5e3
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/demos.html
@@ -0,0 +1,18 @@
+<HTML>
+
+<TITLE>Demos</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Demos</H1>
+
+
+<ul>
+<li><a href="http://www.geocities.com/shobhand/homepage.html">Shobhan Dutta's Geartrain and Walkthrough Demos</a>
+</li></ul>
+
+
+</body>
+</html> \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/docs/devinfo.html b/nx-X11/extras/Mesa/docs/devinfo.html
new file mode 100644
index 000000000..9fcd8cf53
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/devinfo.html
@@ -0,0 +1,206 @@
+<HTML>
+
+<TITLE>Development Notes</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Development Notes</H1>
+
+
+<H2>Adding Extentions</H2>
+
+<p>
+To add a new GL extension to Mesa you have to do at least the following.
+
+<ul>
+<li>
+ If glext.h doesn't define the extension, edit include/GL/gl.h and add
+ code like this:
+ <pre>
+ #ifndef GL_EXT_the_extension_name
+ #define GL_EXT_the_extension_name 1
+ /* declare the new enum tokens */
+ /* prototype the new functions */
+ /* TYPEDEFS for the new functions */
+ #endif
+ </pre>
+</li>
+<li>
+ In the src/mesa/glapi/ directory, add the new extension functions and
+ enums to the gl_API.xml file.
+ Then, a bunch of source files must be regenerated by executing the
+ corresponding Python scripts.
+</li>
+<li>
+ Find an existing extension that's similar to the new one and search
+ the sources for code related to that extension.
+ Implement new code as needed.
+ In general, new state variables will be added to mtypes.h. If the
+ extension is rather large, try to implement it in a new source file.
+</li>
+<li>
+ If the new extension adds new GL state, the functions in get.c, enable.c
+ and attrib.c will most likely require new code.
+</li>
+</ul>
+
+
+
+<H2>Coding Style</H2>
+
+<p>
+Mesa's code style has changed over the years. Here's the latest.
+</p>
+
+<p>
+Comment your code! It's extremely important that open-source code be
+well documented. Also, strive to write clean, easily understandable code.
+</p>
+
+<p>
+3-space indentation
+</p>
+
+<p>
+If you use tabs, set them to 8 columns
+</p>
+
+<p>
+Brace example:
+</p>
+<pre>
+ if (condition) {
+ foo;
+ }
+ else {
+ bar;
+ }
+</pre>
+
+<p>
+Here's the GNU indent command which will best approximate my preferred style:
+</p>
+<pre>
+ indent -br -i3 -npcs infile.c -o outfile.c
+</pre>
+
+
+<p>
+Local variable name example: localVarName (no underscores)
+</p>
+
+<p>
+Constants and macros are ALL_UPPERCASE, with _ between words
+</p>
+
+<p>
+Global variables are not allowed.
+</p>
+
+<p>
+Function name examples:
+</p>
+<pre>
+ glFooBar() - a public GL entry point (in dispatch.c)
+ _mesa_FooBar() - the internal immediate mode function
+ save_FooBar() - retained mode (display list) function in dlist.c
+ foo_bar() - a static (private) function
+ _mesa_foo_bar() - an internal non-static Mesa function
+</pre>
+
+
+<H2>Making a New Mesa Release</H2>
+
+<p>
+These are the instructions for making a new Mesa release.
+</p>
+
+<H3>Get latest source files</H3>
+<p>
+Use "cvs update -dAP " to get the latest Mesa files from CVS.
+</p>
+
+
+<H3>Verify and update version info</H3>
+<p>
+Create/edit the docs/RELNOTES-X.Y file to document what's new in the release.
+Add the new RELNOTES-X.Y file to <a href="relnotes.html">relnotes.html</a>.
+Update the docs/VERSIONS file too.
+</p>
+
+<p>
+Edit configs/default and change the MESA_MAJOR, MESA_MINOR and MESA_TINY
+version numbers.
+</p>
+
+<p>
+Make sure the values in src/mesa/main/version.h is correct.
+</p>
+
+<p>
+Edit the top-level Makefile and verify that DIRECTORY, LIB_NAME and
+DEMO_NAME are correct.
+</p>
+
+<p>
+Update the docs/news.html file and docs/contents.html files.
+</p>
+
+<p>
+Check in all updates to CVS.
+</p>
+
+<p>
+Tag the CVS files with the release name (in the form <b>mesa_X_Y</b>).
+</p>
+
+
+<H3>Make the tarballs</H3>
+<p>
+Make a symbolic link from $(DIRECTORY) to 'Mesa'. For example,
+ln -s Mesa Mesa-6.3
+This is needed in order to make a correct tar file in the next step.
+</p>
+
+<p>
+Make the distribution files. From inside the Mesa directory:
+<pre>
+ make tarballs
+</pre>
+
+<p>
+After the tarballs are created, the md5 checksums for the files will
+be computed.
+Add them to the docs/news.html file.
+</p>
+
+<p>
+Copy the distribution files to a temporary directory, unpack them,
+compile everything, and run some demos to be sure everything works.
+</p>
+
+<H3>Update the website and announce the release</H3>
+<p>
+Follow the directions on SourceForge for creating a new "release" and
+uploading the tarballs.
+</p>
+
+<p>
+Update the web site by copying the docs/ directory's files to
+/home/users/b/br/brianp/mesa-www/htdocs/
+</p>
+
+<p>
+Make an announcement on the mailing lists:
+<em>m</em><em>e</em><em>s</em><em>a</em><em>3</em><em>d</em><em>-</em><em>d</em><em>e</em><em>v</em><em>@</em><em>l</em><em>i</em><em>s</em><em>t</em><em>s</em><em>.</em><em>s</em><em>f</em><em>.</em><em>n</em><em>e</em><em>t</em>,
+<em>m</em><em>e</em><em>s</em><em>a</em><em>3</em><em>d</em><em>-</em><em>u</em><em>s</em><em>e</em><em>r</em><em>s</em><em>@</em><em>l</em><em>i</em><em>s</em><em>t</em><em>s</em><em>.</em><em>s</em><em>f</em><em>.</em><em>n</em><em>e</em><em>t</em>
+and
+<em>m</em><em>e</em><em>s</em><em>a</em><em>3</em><em>d</em><em>-</em><em>a</em><em>n</em><em>n</em><em>o</em><em>u</em><em>n</em><em>c</em><em>e</em><em>@</em><em>l</em><em>i</em><em>s</em><em>t</em><em>s</em><em>.</em><em>s</em><em>f</em><em>.</em><em>n</em><em>e</em><em>t</em>
+</p>
+
+
+
+</body>
+</html>
diff --git a/nx-X11/extras/Mesa/docs/download.html b/nx-X11/extras/Mesa/docs/download.html
new file mode 100644
index 000000000..60d76756e
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/download.html
@@ -0,0 +1,130 @@
+<HTML>
+
+<TITLE>Getting Mesa</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Downloading</H1>
+
+<p>
+Current stable release: <b>6.4.1</b>
+</p>
+
+<p>
+Primary download site:
+<a href="http://sourceforge.net/project/showfiles.php?group_id=3"
+target="_parent">SourceForge</a>
+</p>
+
+
+<p>
+Mesa is distributed in several parts:
+</p>
+<ul>
+<li><b>MesaLib-x.y.z</b> - the main Mesa library source code, drivers
+ and documentation.
+</li>
+<li><b>MesaDemos-x.y.z</b> - OpenGL demonstration and test programs.
+ Most of the programs require GLUT (either the
+ <a href="http://www.opengl.org/resources/libraries/glut.html"
+ target="_parent">original GLUT by Mark Kilgard</a> or
+ <a href="http://freeglut.sourceforge.net" target="_parent">freeglut</a> or
+ <a href="http://freeglut.sourceforge.net" target="_parent">OpenGLUT</a>).
+</li>
+<li><b>MesaGLUT-x.y.z</b> - Mark Kilgard's GLUT, easily compiled and used
+ with Mesa. Plus, other implementation of GLUT for DOS, OS/2, BeOS, etc.
+</li>
+</ul>
+
+<p>
+If you're not interested in running the demos, you'll only need the first
+package.
+</p>
+
+<p>
+The packages are available in .tar.gz, .tar.bz2 and .zip formats.
+Other organizations might offer additional package formats.
+</p>
+
+<H1>Unpacking</H1>
+
+<p>
+All the packages should be in the same directory prior to unpacking.
+</p>
+
+<ul>
+<li>To unpack .tar.gz files:
+<pre>
+ tar zxf MesaLib-X.Y.tar.gz
+ tar zxf MesaDemos-X.Y.tar.gz
+ tar zxf MesaGLUT-X.Y.tar.gz
+</pre>
+or
+<pre>
+ gzcat MesaLib-X.Y.tar.gz | tar xf -
+ gzcat MesaDemos-X.Y.tar.gz | tar xf -
+ gzcat MesaGLUT-X.Y.tar.gz | tar xf -
+</pre>
+or
+<pre>
+ gunzip MesaLib-X.Y.tar.gz ; tar xf MesaLib-X.Y.tar
+ gunzip MesaDemos-X.Y.tar.gz ; tar xf MesaDemos-X.Y.tar
+ gunzip MesaGLUT-X.Y.tar.gz ; tar xf MesaGLUT-X.Y.tar
+</pre>
+<li>To unpack .tar.bz2 files:
+<pre>
+ bunzip2 -c MesaLib-X.Y.tar.gz | tar xf -
+ bunzip2 -c MesaDemos-X.Y.tar.gz | tar xf -
+ bunzip2 -c MesaGLUT-X.Y.tar.gz | tar xf -
+</pre>
+<li>To unpack .zip files:
+<pre>
+ unzip MesaLib-X.Y.zip
+ unzip MesaDemos-X.Y.zip
+ unzip MesaGLUT-X.Y.zip
+</pre>
+</ul>
+
+
+<h1>Contents</h1>
+
+<p>
+After unpacking you'll have these directories:
+</p>
+<pre>
+Makefile - top-level Makefile for most systems
+configs/ - makefile parameter files for various systems
+include/ - GL header (include) files
+bin/ - shell scripts for making shared libraries, etc
+docs/ - documentation
+src/ - source code for libraries
+src/mesa - sources for the main Mesa library and device drivers
+src/glu - libGLU source code
+src/glw - Xt/Motif/OpenGL widget code
+</pre>
+
+If you downloaded and unpacked the MesaDemos.X.Y package:
+
+<pre>
+progs/demos - original Mesa demos
+progs/xdemos - GLX OpenGL/Mesa demos
+progs/redbook - examples from the OpenGL Programming Guide
+progs/samples - examples from SGI
+progs/images/ - image files
+</pre>
+
+If you downloaded and unpacked the MesaGLUT.X.Y package:
+<pre>
+src/glut - GLUT library source code
+</pre>
+
+<p>
+Proceed to the <a href="install.html">compilation and installation
+instructions</a>.
+</p>
+
+
+</BODY>
+</HTML>
diff --git a/nx-X11/extras/Mesa/docs/enums.txt b/nx-X11/extras/Mesa/docs/enums.txt
new file mode 100644
index 000000000..218391c30
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/enums.txt
@@ -0,0 +1,42 @@
+
+Blocks allocated to Mesa:
+ 0x8750-0x875F
+ 0x8BB0-0x8BBF
+
+
+GL_MESA_packed_depth_stencil
+ GL_DEPTH_STENCIL_MESA 0x8750
+ GL_UNSIGNED_INT_24_8_MESA 0x8751
+ GL_UNSIGNED_INT_8_24_REV_MESA 0x8752
+ GL_UNSIGNED_SHORT_15_1_MESA 0x8753
+ GL_UNSIGNED_SHORT_1_15_REV_MESA 0x8754
+
+GL_MESA_trace.spec:
+ GL_TRACE_ALL_BITS_MESA 0xFFFF
+ GL_TRACE_OPERATIONS_BIT_MESA 0x0001
+ GL_TRACE_PRIMITIVES_BIT_MESA 0x0002
+ GL_TRACE_ARRAYS_BIT_MESA 0x0004
+ GL_TRACE_TEXTURES_BIT_MESA 0x0008
+ GL_TRACE_PIXELS_BIT_MESA 0x0010
+ GL_TRACE_ERRORS_BIT_MESA 0x0020
+ GL_TRACE_MASK_MESA 0x8755
+ GL_TRACE_NAME_MESA 0x8756
+
+MESA_ycbcr_texture.spec:
+ GL_YCBCR_MESA 0x8757
+ GL_UNSIGNED_SHORT_8_8_MESA 0x85BA /* same as Apple's */
+ GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB /* same as Apple's */
+
+GL_MESA_pack_invert.spec
+ GL_PACK_INVERT_MESA 0x8758
+
+GL_MESA_program_debug.spec:
+ GL_FRAGMENT_PROGRAM_CALLBACK_MESA 0x????
+ GL_VERTEX_PROGRAM_CALLBACK_MESA 0x????
+ GL_FRAGMENT_PROGRAM_POSITION_MESA 0x????
+ GL_VERTEX_PROGRAM_POSITION_MESA 0x????
+ GL_FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA 0x????
+ GL_FRAGMENT_PROGRAM_CALLBACK_DATA_MESA 0x????
+ GL_VERTEX_PROGRAM_CALLBACK_FUNC_MESA 0x????
+ GL_VERTEX_PROGRAM_CALLBACK_DATA_MESA 0x????
+
diff --git a/nx-X11/extras/Mesa/docs/envvars.html b/nx-X11/extras/Mesa/docs/envvars.html
new file mode 100644
index 000000000..60cfd3f0c
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/envvars.html
@@ -0,0 +1,44 @@
+<HTML>
+
+<TITLE>Environment Variables</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Environment Variables</H1>
+
+<p>
+Mesa supports the following environment variables:
+</p>
+<ul>
+<li>MESA_NO_ASM - if set, disables all assembly language optimizations
+<li>MESA_NO_MMX - if set, disables Intel MMX optimizations
+<li>MESA_NO_3DNOW - if set, disables AMD 3DNow! optimizations
+<li>MESA_NO_SSE - if set, disables Intel SSE optimizations
+<li>MESA_DEBUG - if set, error messages are printed to stderr.
+If the value of MESA_DEBUG is "FP" floating point arithmetic errors will
+generate exceptions.
+<li>MESA_NO_DITHER - if set, disables dithering, overriding glEnable(GL_DITHER)
+</ul>
+
+<p>
+The following environment variables are only applicable to the Xlib/X11
+software driver:
+</p>
+<ul>
+<li>MESA_RGB_VISUAL - specifies the X visual and depth for RGB mode (X only)
+<li>MESA_CI_VISUAL - specifies the X visual and depth for CI mode (X only)
+<li>MESA_BACK_BUFFER - specifies how to implement the back color buffer (X only)
+<li>MESA_GAMMA - gamma correction coefficients (X only)
+<li>MESA_XSYNC - enable synchronous X behavior (for X debugging only)
+<li>MESA_GLX_FORCE_CI - if set, force GLX to treak 8bpp visuals as CI visuals
+<li>MESA_GLX_FX - set to either "fullscreen" for full-screen rendering,
+ "window" to render into a window, or "disable" to disable the Glide driver.
+<li>MESA_GLX_FORCE_ALPHA - if set, forces RGB windows to have an alpha channel.
+<li>MESA_GLX_DEPTH_BITS - specifies default number of bits for depth buffer.
+</ul>
+
+
+</BODY>
+</HTML>
diff --git a/nx-X11/extras/Mesa/docs/extensions.html b/nx-X11/extras/Mesa/docs/extensions.html
new file mode 100644
index 000000000..dbb8ebada
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/extensions.html
@@ -0,0 +1,34 @@
+<HTML>
+
+<TITLE>Mesa Extensions</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Mesa Extensions</H1>
+
+<p>
+A number of extensions have been developed especially for Mesa.
+The specifications follow.
+</p>
+
+
+<UL>
+<LI><A HREF="MESA_agp_offset.spec">MESA_agp_offset.spec</A>
+<LI><A HREF="MESA_copy_sub_buffer.spec">MESA_copy_sub_buffer.spec</A>
+<LI><A HREF="MESA_packed_depth_stencil.spec">MESA_packed_depth_stencil.spec</A>
+<LI><A HREF="MESA_pack_invert.spec">MESA_pack_invert.spec</A>
+<LI><A HREF="MESA_pixmap_colormap.spec">MESA_pixmap_colormap.spec</A>
+<LI><A HREF="MESA_release_buffers.spec">MESA_release_buffers.spec</A>
+<LI><A HREF="MESA_resize_buffers.spec">MESA_resize_buffers.spec</A>
+<LI><A HREF="MESA_set_3dfx_mode.spec">MESA_set_3dfx_mode.spec</A>
+<LI><A HREF="MESA_sprite_point.spec">MESA_sprite_point.spec</A> (obsolete)
+<LI><A HREF="MESA_trace.spec">MESA_trace.spec</A> (obsolete)
+<LI><A HREF="MESA_window_pos.spec">MESA_window_pos.spec</A>
+<LI><A HREF="MESA_ycbcr_texture.spec">MESA_ycbcr_texture.spec</A>
+</UL>
+
+
+</BODY>
+</HTML>
diff --git a/nx-X11/extras/Mesa/docs/faq.html b/nx-X11/extras/Mesa/docs/faq.html
new file mode 100644
index 000000000..b93d5007d
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/faq.html
@@ -0,0 +1,394 @@
+<html>
+
+<head><title>Mesa FAQ</title></head>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+
+<center>
+<h1>Mesa Frequently Asked Questions</h1>
+Last updated: 21 October 2004
+</center>
+
+<br>
+<br>
+<h2>Index</h2>
+<a href="#part1">1. High-level Questions and Answers</a>
+<br>
+<a href="#part2">2. Compilation and Installation Problems</a>
+<br>
+<a href="#part3">3. Runtime / Rendering Problems</a>
+<br>
+<a href="#part4">4. Developer Questions</a>
+<br>
+<br>
+<br>
+
+
+
+<a name="part1">
+</a><h1><a name="part1">1. High-level Questions and Answers</a></h1>
+
+<h2><a name="part1">1.1 What is Mesa?</a></h2>
+<p>
+<a name="part1">Mesa is an open-source implementation of the OpenGL specification.
+OpenGL is a programming library for writing interactive 3D applications.
+See the </a><a href="http://www.opengl.org/">OpenGL website</a> for more
+information.
+</p>
+<p>
+Mesa 6.x supports the OpenGL 1.5 specification.
+</p>
+
+
+<h2>1.2 Does Mesa support/use graphics hardware?</h2>
+<p>
+Yes. Specifically, Mesa serves as the OpenGL core for the open-source DRI
+drivers for XFree86/X.org. See the <a href="http://dri.sf.net/">DRI
+website</a> for more information.
+</p>
+<p>
+There have been other hardware drivers for Mesa over the years (such as
+the 3Dfx Glide/Voodoo driver, an old S3 driver, etc) but the DRI drivers
+are the modern ones.
+</p>
+
+<h2>1.3 What purpose does Mesa serve today?</h2>
+<p>
+Hardware-accelerated OpenGL implementations are available for most popular
+operating systems today.
+Still, Mesa serves at least these purposes:
+</p>
+<ul>
+<li>Mesa is used as the core of the open-source XFree86/X.org DRI
+ hardware drivers.
+</li>
+<li>Mesa is quite portable and allows OpenGL to be used on systems
+ that have no other OpenGL solution.
+</li>
+<li>Software rendering with Mesa serves as a reference for validating the
+ hardware drivers.
+</li>
+<li>A software implementation of OpenGL is useful for experimentation,
+ such as testing new rendering techniques.
+</li>
+<li>Mesa can render images with deep color channels: 16-bit integer
+ and 32-bit floating point color channels are supported.
+ This capability is only now appearing in hardware.
+</li>
+<li>Mesa's internal limits (max lights, clip planes, texture size, etc) can be
+ changed for special needs (hardware limits are hard to overcome).
+</li>
+</ul>
+
+
+<h2>1.4 What's the difference between"Stand-Alone" Mesa and the DRI drivers?</h2>
+<p>
+<em>Stand-alone Mesa</em> is the original incarnation of Mesa.
+On systems running the X Window System it does all its rendering through
+the Xlib API:
+<ul>
+<li>The GLX API is supported, but it's really just an emulation of the
+ real thing.
+<li>The GLX wire protocol is not supported and there's no OpenGL extension
+ loaded by the X server.
+<li>There is no hardware acceleration.
+<li>The OpenGL library, libGL.so, contains everything (the programming API,
+ the GLX functions and all the rendering code).
+</ul>
+</p>
+<p>
+Alternately, Mesa acts as the core for a number of OpenGL hardware drivers
+within the DRI (Direct Rendering Infrastructure):
+<ul>
+<li>The libGL.so library provides the GL and GLX API functions, a GLX
+ protocol encoder, and a device driver loader.
+<li>The device driver modules (such as r200_dri.so) contain a built-in
+ copy of the core Mesa code.
+<li>The X server loads the GLX module.
+ The GLX module decodes incoming GLX protocol and dispatches the commands
+ to a rendering module.
+ For the DRI, this module is basically a software Mesa renderer.
+</ul>
+
+
+
+<h2>1.5 How do I upgrade my DRI installation to use a new Mesa release?</h2>
+<p>
+This wasn't easy in the past.
+Now, the DRI drivers are included in the Mesa tree and can be compiled
+separately from the X server.
+Just follow the Mesa <a href="install.html">compilation instructions</a>.
+</p>
+
+
+<h2>1.6 Are there other open-source implementations of OpenGL?</h2>
+<p>
+Yes, SGI's <a href="http://oss.sgi.com/projects/ogl-sample/index.html"
+target="_parent">
+OpenGL Sample Implemenation (SI)</a> is available.
+The SI was written during the time that OpenGL was originally designed.
+Unfortunately, development of the SI has stagnated.
+Mesa is much more up to date with modern features and extensions.
+</p>
+
+<p>
+<a href="http://ogl-es.sourceforge.net" target="_parent">Vincent</a> is
+an open-source implementation of OpenGL ES for mobile devices.
+
+<p>
+<a href="http://www.dsbox.com/minigl.html" target="_parent">miniGL</a>
+is a subset of OpenGL for PalmOS devices.
+
+<p>
+<a href="http://fabrice.bellard.free.fr/TinyGL/"
+target="_parent">TinyGL</a> is a subset of OpenGL.
+</p>
+
+<p>
+<a href="http://softgl.studierstube.org/" target="_parent">SoftGL</a>
+is an OpenGL subset for mobile devices.
+</p>
+
+<p>
+<a href="http://chromium.sourceforge.net/" target="_parent">Chromium</a>
+isn't a conventional OpenGL implementation (it's layered upon OpenGL),
+but it does export the OpenGL API. It allows tiled rendering, sort-last
+rendering, etc.
+</p>
+
+<p>
+There may be other open OpenGL implementations, but Mesa is the most
+popular and feature-complete.
+</p>
+
+
+
+<br>
+<br>
+
+
+<a name="part2">
+</a><h1><a name="part2">2. Compilation and Installation Problems</a></h1>
+
+
+<h2><a name="part2">2.1 What's the easiest way to install Mesa?</a></h2>
+<p>
+<a name="part2">If you're using a Linux-based system, your distro CD most likely already
+has Mesa packages (like RPM or DEB) which you can easily install.
+</a></p>
+
+
+<h2><a name="part2">2.2 Running <code>configure; make</code> doesn't Work</a></h2>
+<p>
+Mesa no longer supports GNU autoconf/automake. Why?
+<ul>
+<li>It seemed to seldom work on anything but Linux
+<li>The config files were hard to maintain and hard to understand
+<li>libtool caused a lot of grief
+</ul>
+
+<p>
+Now Mesa again uses a conventional Makefile system (as it did originally).
+Basically, each Makefile in the tree includes one of the configuration
+files from the config/ directory.
+The config files specify all the variables for a variety of popular systems.
+</p>
+
+
+<h2><a name="part2">2.3 I get undefined symbols such as bgnpolygon, v3f, etc...</a></h2>
+<p>
+<a name="part2">You're application is written in IRIS GL, not OpenGL.
+IRIS GL was the predecessor to OpenGL and is a different thing (almost)
+entirely.
+Mesa's not the solution.
+</a></p>
+
+
+<h2><a name="part2">2.4 Where is the GLUT library?</a></h2>
+<p>
+<a name="part2">GLUT (OpenGL Utility Toolkit) is in the separate MesaGLUT-x.y.z.tar.gz file.
+If you don't already have GLUT installed, you should grab the MesaGLUT
+package and compile it with the rest of Mesa.
+</a></p>
+
+
+
+<h2><a name="part2">2.5 What's the proper place for the libraries and headers?</a></h2>
+<p>
+<a name="part2">On Linux-based systems you'll want to follow the
+</a><a href="http://oss.sgi.com/projects/ogl-sample/ABI/index.html"
+target="_parent">Linux ABI</a> standard.
+Basically you'll want the following:
+</p>
+<ul>
+<li>/usr/include/GL/gl.h - the main OpenGL header
+</li><li>/usr/include/GL/glu.h - the OpenGL GLU (utility) header
+</li><li>/usr/include/GL/glx.h - the OpenGL GLX header
+</li><li>/usr/include/GL/glext.h - the OpenGL extensions header
+</li><li>/usr/include/GL/glxext.h - the OpenGL GLX extensions header
+</li><li>/usr/include/GL/osmesa.h - the Mesa off-screen rendering header
+</li><li>/usr/lib/libGL.so - a symlink to libGL.so.1
+</li><li>/usr/lib/libGL.so.1 - a symlink to libGL.so.1.xyz
+</li><li>/usr/lib/libGL.so.xyz - the actual OpenGL/Mesa library. xyz denotes the
+Mesa version number.
+</li><li>/usr/lib/libGLU.so - a symlink to libGLU.so.1
+</li><li>/usr/lib/libGLU.so.1 - a symlink to libGLU.so.1.3.xyz
+</li><li>/usr/lib/libGLU.so.xyz - the OpenGL Utility library. xyz denotes the Mesa
+version number.
+</li></ul>
+<p>
+After installing XFree86/X.org and the DRI drivers, some of these files
+may be symlinks into the /usr/X11R6/ tree.
+</p>
+<p>
+The old-style Makefile system doesn't install the Mesa libraries; it's
+up to you to copy them (and the headers) to the right place.
+</p>
+<p>
+The GLUT header and library should go in the same directories.
+</p>
+<br>
+<br>
+
+
+<a name="part3">
+</a><h1><a name="part3">3. Runtime / Rendering Problems</a></h1>
+
+<h2><a name="part3">3.1 Rendering is slow / why isn't my graphics hardware being used?</a></h2>
+<p>
+<a name="part3">Stand-alone Mesa (downloaded as MesaLib-x.y.z.tar.gz) doesn't have any
+support for hardware acceleration (with the exception of the 3DFX Voodoo
+driver).
+</a></p>
+<p>
+<a name="part3">What you really want is a DRI or NVIDIA (or another vendor's OpenGL) driver
+for your particular hardware.
+</a></p>
+<p>
+<a name="part3">You can run the <code>glxinfo</code> program to learn about your OpenGL
+library.
+Look for the GL_VENDOR and GL_RENDERER values.
+That will identify who's OpenGL library you're using and what sort of
+hardware it has detected.
+</a></p>
+<p>
+<a name="part3">If your DRI-based driver isn't working, go to the
+</a><a href="http://dri.sf.net/" target="_parent">DRI website</a> for trouble-shooting information.
+</p>
+
+
+<h2>3.2 I'm seeing errors in depth (Z) buffering. Why?</h2>
+<p>
+Make sure the ratio of the far to near clipping planes isn't too great.
+Look
+<a href="http://www.sgi.com/software/opengl/advanced97/notes/node18.html"
+target="_parent">
+here</a> for details.
+</p>
+<p>
+Mesa uses a 16-bit depth buffer by default which is smaller and faster
+to clear than a 32-bit buffer but not as accurate.
+If you need a deeper you can modify the parameters to
+<code> glXChooseVisual</code> in your code.
+</p>
+
+
+<h2>3.3 Why Isn't depth buffering working at all?</h2>
+<p>
+Be sure you're requesting a depth buffered-visual. If you set the MESA_DEBUG
+environment variable it will warn you about trying to enable depth testing
+when you don't have a depth buffer.
+</p>
+<p>Specifically, make sure <code>glutInitDisplayMode</code> is being called
+with <code>GLUT_DEPTH</code> or <code>glXChooseVisual</code> is being
+called with a non-zero value for GLX_DEPTH_SIZE.
+</p>
+<p>This discussion applies to stencil buffers, accumulation buffers and
+alpha channels too.
+</p>
+
+
+<h2>3.4 Why does glGetString() always return NULL?</h2>
+<p>
+Be sure you have an active/current OpenGL rendering context before
+calling glGetString.
+</p>
+
+
+<h2>3.5 GL_POINTS and GL_LINES don't touch the right pixels</h2>
+<p>
+If you're trying to draw a filled region by using GL_POINTS or GL_LINES
+and seeing holes or gaps it's because of a float-to-int rounding problem.
+But this is not a bug.
+See Appendix H of the OpenGL Programming Guide - "OpenGL Correctness Tips".
+Basically, applying a translation of (0.375, 0.375, 0.0) to your coordinates
+will fix the problem.
+</p>
+
+<br>
+<br>
+
+
+<a name="part4">
+</a><h1><a name="part4">4. Developer Questions</a></h1>
+
+<h2><a name="part4">4.1 How can I contribute?</a></h2>
+<p>
+<a name="part4">First, join the Mesa3d-dev mailing list. That's where Mesa development
+is discussed.
+</a></p>
+<p>
+<a name="part4">The </a><a href="http://www.opengl.org/developers/documentation/specs.html" target="_parent">
+OpenGL Specification</a> is the bible for OpenGL implemention work.
+You should read it.
+</p>
+<p>Most of the Mesa development work involves implementing new OpenGL
+extensions, writing hardware drivers (for the DRI), and code optimization.
+</p>
+
+<h2>4.2 How do I write a new device driver?</h2>
+<p>
+Unfortunately, writing a device driver isn't easy.
+It requires detailed understanding of OpenGL, the Mesa code, and your
+target hardware/operating system.
+3D graphics are not simple.
+</p>
+<p>
+The best way to get started is to use an existing driver as your starting
+point.
+For a software driver, the X11 and OSMesa drivers are good examples.
+For a hardware driver, the Radeon and R200 DRI drivers are good examples.
+</p>
+<p>The DRI website has more information about writing hardware drivers.
+The process isn't well document because the Mesa driver interface changes
+over time, and we seldome have spare time for writing documentation.
+That being said, many people have managed to figure out the process.
+</p>
+<p>
+Joining the appropriate mailing lists and asking questions (and searching
+the archives) is a good way to get information.
+</p>
+
+
+<h2>4.3 Why isn't GL_EXT_texture_compression_s3tc implemented in Mesa and/or the DRI drivers?</h2>
+<p>
+The <a href="http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_compression_s3tc.txt" target="_parent">specification for the extension</a>
+indicates that there are intellectual property (IP) and/or patent issues
+to be dealt with.
+</p>
+<p>We've been unsucessful in getting a response from S3 (or whoever owns
+the IP nowadays) to indicate whether or not an open source project can
+implement the extension (specifically the compression/decompression
+algorithms).
+</p>
+<p>
+Until we can get official permission to do so, this extension will not
+be implemented in Mesa.
+</p>
+
+
+</body>
+</html>
diff --git a/nx-X11/extras/Mesa/docs/fbdev-dri.html b/nx-X11/extras/Mesa/docs/fbdev-dri.html
new file mode 100644
index 000000000..18b0ca815
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/fbdev-dri.html
@@ -0,0 +1,315 @@
+<html>
+
+<TITLE>Mesa fbdev/DRI Environment</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<center><H1>Mesa fbdev/DRI Drivers</H1></center>
+
+
+<H1>1. Introduction</H1>
+
+<p>
+The fbdev/DRI sub-project within Mesa brings hardware accelerated OpenGL
+rendering to the Linux fbdev environment.
+The X Window System / XFree86 is not needed.
+</p>
+
+<p>
+Basically, the <a href="http://dri.sf.net/">DRI</a> drivers for hardware
+accelerated OpenGL for XFree86 have been ported to fbdev so that X is
+not needed.
+This means fbdev/DRI works in full-screen mode only.
+</p>
+
+<p>
+DRI driver writers may find this simplified environment easier to work in,
+compared to the full XFree86/DRI environment.
+</p>
+
+<p>
+Much of the work for this project has been done by Jon Smirl and
+Keith Whitwell.
+</p>
+
+<p>
+To use fbdev/DRI, you'll need a Linux 2.4 or 2.6 kernel.
+</p>
+
+<h3>Background Info</h3>
+
+<p>
+The Mesa-based DRI drivers used to be hosted in the DRI tree (which is
+basically a copy of the XFree86 tree).
+Since the Mesa-based DRI drivers are moreso "Mesa drivers" than "XFree86
+drivers" and the fact that with some work, the drivers could be used
+without X, the driver code was moved into the Mesa tree.
+</p>
+
+<p>
+So now the DRI drivers can be compiled for two different environments:
+fbdev and XFree86.
+To build the drivers for XFree86, one has to download/build the DRI
+source tree.
+Eventually, we'd like to be able to build the drivers for XFree86 outside
+of the XFree86/DRI trees.
+</p>
+
+
+
+
+<h1>2. Compilation</h1>
+
+<h2>2.1 Compiling the DRM modules</h2>
+
+<p>
+First, you'll need the DRM (Direct Rendering Manager) kernel module sources.
+They're found in a module of the DRI CVS tree.
+To obtain the code do the following:
+</p>
+<pre>
+ cvs -d:pserver:anonymous@pdx.freedesktop.org:/cvs/dri login
+</pre>
+<p>
+Press Enter/Return when prompted for a password. Then,
+</p>
+<pre>
+ cvs -d:pserver:anonymous@pdx.freedesktop.org:/cvs/dri co drm
+</pre>
+
+<p>
+Compile the DRM kernel modules:
+</p>
+<pre>
+ cd drm/linux
+ make
+</pre>
+
+<p>
+Note: you may need to be root in order to make a few symlinks.
+</p>
+<p>
+When compilation is done, you should have at least the following
+kernel modules:
+</p>
+<pre>
+ gamma.o
+ i810.o
+ i830.o
+ mach64.o
+ mga.o
+ r128.o
+ radeon.o
+ savage.o
+ sis.o
+ tdfx.o
+ via.o
+</pre>
+<p>
+You'll probably want to copy/move them into your kernel module directory
+(for example: <code>/lib/modules/2.4.18-14/kernel/drivers/char/drm/</code>).
+</p>
+
+
+
+<h2>2.2 Compiling the Mesa drivers</h2>
+
+<p>
+Begin by editing the <code>Mesa/configs/default</code> file to set
+the <code>DRM_SOURCE_PATH</code> variable.
+Set it to the location where the DRM module sources are located.
+For example, if your current directory in step 2.1 was <code>/home/fred/</code>
+set DRM_SOURCE_PATH to <code>/home/fred/drm</code>
+</p>
+
+<p>
+Next, assuming you're starting with a fresh Mesa CVS checkout,
+do the following:
+</p>
+<pre>
+ make linux-solo
+</pre>
+
+<p>
+If you previously built the source tree, run <code>make realclean</code>
+first to remove the old object files.
+</p>
+
+<p>
+When this is finished, check the <code>Mesa/lib/</code> directory
+to verify that the following files were made:
+</p>
+
+<ul>
+<li><code>libGL.so.1.2</code> - the client-side OpenGL library
+ (and a few symlinks to it).
+<li><code>libGLU.so.1.1</code> - the GLU library (and a few symlinks to it).
+<li><code>libglut.so.3.7</code> - the GLUT library (and a few symlinks to it).
+<li><code>mga_dri.so</code> - DRI driver for Matrox G200/G400 cards.
+<li><code>r128_dri.so</code> - DRI driver for ATI Rage 128 cards.
+<li><code>r200_dri.so</code> - DRI driver for ATI R200 Radeon cards.
+<li><code>radeon_dri.so</code> - DRI driver for original ATI Radeon cards.
+<li><code>i810_dri.so</code> - DRI driver for Intel i810/i815 chips.
+<li><code>i830_dri.so</code> - DRI driver for Intel i830/i845 chips.
+<li><code>mga_dri.so</code> - DRI driver for Matrox G200/G400 cards.
+<li><code>sis_dri.so</code> - DRI driver for SIS cards.
+<li><code>tdfx_dri.so</code> - DRI driver for 3dfx Voodoo 3/4/5 cards.
+<li><code>gamma_dri.so</code> - DRI driver for 3Dlabs gamma cards.
+<li><code>fb_dri.so</code> - software-only fbdev driver.
+<li><code>miniglx.conf</code> - configuration file for the MiniGLX interface
+</ul>
+
+
+<h1>3. Using fbdev/DRI</h1>
+
+<p>
+If XFree86 is currently running, exit/stop the X server so you're
+working from the console.
+</p>
+
+
+<h2>3.1 Load Kernel Modules</h2>
+
+<p>
+You'll need to load the kernel modules specific to your graphics hardware.
+Typically, this consists of the agpgart module, an fbdev driver module
+and the DRM kernel module (from step 2.1).
+</p>
+
+
+<p>
+If you have ATI Radeon/R200 hardware, run as root:
+</p>
+<pre>
+ modprobe agpgart # the AGP GART module
+ modprobe radeonfb # the Radeon fbdev driver
+ modprobe radeon # the Radeon DRI kernel module
+</pre>
+
+<p>
+If you have ATI Rage 128 hardware, run as root:
+</p>
+<pre>
+ modprobe agpgart # the AGP GART module
+ modprobe aty128fb # the Rage 128 fbdev driver
+ modprobe r128 # the Rage 128 DRI kernel module
+</pre>
+
+<p>
+If you have Matrox G200/G400 hardware, run as root:
+</p>
+<pre>
+ modprobe agpgart # the AGP GART module
+ modprobe mgafb # the Matrox fbdev driver
+ modprobe mga # the Matrox DRI kernel module
+</pre>
+
+<p>
+Then run <code>lsmod</code> to be sure the modules are loaded.
+For a Radeon card, you should see something like this:
+</p>
+<pre>
+Module Size Used by Not tainted
+radeon 110308 0 (unused)
+radeonfb 21900 0 (unused)
+agpgart 43072 1
+</pre>
+
+
+
+<h2>3.2 Configuration File</h2>
+
+<p>
+The <code>Mesa/lib/miniglx.conf</code> file should be installed
+in <code>/etc/</code>.
+</p>
+
+<p>
+Edit <code>/etc/miniglx.conf</code> to be sure it's set up correctly
+for your hardware.
+Comments in the file explain the options.
+</p>
+
+
+<h2>3.3 Running fbdev/DRI Programs</h2>
+
+<p>
+Make sure your LD_LIBRARY_PATH environment variable is set to the
+<code>Mesa/lib/</code> directory.
+</p>
+
+<p>
+Change to the <code>Mesa/progs/miniglx/</code> directory and
+start the sample_server program in the background:
+</p>
+<pre>
+ ./sample_server &
+</pre>
+
+<p>
+Then try running the <code>miniglxtest</code> program:
+</p>
+<pre>
+ ./miniglxtest
+</pre>
+<p>
+You should see a rotating quadrilateral which changes color as it rotates.
+It will exit automatically after a bit.
+</p>
+
+<p>
+If you run other tests in the miniglx/ directory, you may want to run
+them from a remote shell so that you can stop them with ctrl-C.
+</p>
+
+
+
+<h1>4.0 Troubleshooting</h1>
+
+<p>
+If you try to run miniglxtest and get the following:
+</p>
+<pre>
+ [miniglx] failed to probe chipset
+ connect: Connection refused
+ server connection lost
+</pre>
+<p>
+It means that the sample_server process is not running.
+</p>
+
+
+
+
+<h1>5.0 Programming Information</h1>
+
+<p>
+The full OpenGL API is available with fbdev/DRI.
+</p>
+
+<p>
+OpenGL/Mesa is interfaced to fbdev via the <a href="MiniGLX.html">MiniGLX</a>
+interface.
+MiniGLX is a subset of Xlib and GLX API functions which provides just
+enough functionality to setup OpenGL rendering and respond to simple
+input events.
+</p>
+
+<p>
+Since MiniGLX is a subset of the usual Xlib and GLX APIs, programs written
+to the MiniGLX API can also be run on full Xlib/GLX implementations.
+This allows some degree of flexibility for software development and testing.
+</p>
+
+<p>
+However, the MiniGLX API is not binary-compatible with full Xlib/GLX.
+Some of the structures are different and some macros/functions work
+differently.
+See the <code>GL/miniglx.h</code> header file for details.
+</p>
+
+
+</body>
+</html>
diff --git a/nx-X11/extras/Mesa/docs/games.html b/nx-X11/extras/Mesa/docs/games.html
new file mode 100644
index 000000000..dcf5cf2d0
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/games.html
@@ -0,0 +1,64 @@
+<HTML>
+
+<TITLE>Games</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Games</H1>
+
+
+<ul>
+ <li><a href="http://www.psc.edu/%7Esmp/a3d/">Asteroids3D</a> - 3D asteroids game
+ </li><li><a href="http://evlweb.eecs.uic.edu/aej/AndyBattalion.html" target="_parent">Battalion</a>
+ - battle game
+ </li><li><a href="http://bzflag.sourceforge.net/" target="_parent">BZFLAG</a> - 3-D tank
+ battle game
+ </li><li><a href="http://www.speakeasy.org/%7Emorse/copter-commander">Copter Commander</a> - 2d multiplayer side scroller
+ </li><li><a href="http://www.crystalspace.org/" target="_parent">CrystalSpace</a> - Free
+ 3d game engine
+ </li><li><a href="http://www.afn.org/%7Ecthugha/" target="_parent">Cthugha</a> - music-sync'ed
+ graphical effects
+ </li><li><a href="http://www.sics.se/dive/" target="_parent">DIVE</a> - Distributed Interactive
+ Virtual Environment
+ </li><li><a href="http://www.newdoom.com/doomlegacy/" target="_parent">Doom Legacy</a>
+ - an OpenGL port of id software's popular game, Doom
+ </li><li><a href="http://www.asimov.de/intern_dropit.html" target="_parent">DropIt</a> - 3-D tetris game
+ </li><li><a href="http://www.flightgear.org/" target="_parent">Flight Gear</a> - Flight
+ simulator
+ </li><li><a href="http://freetrek.linuxgames.com/" target="_parent">Free Trek</a> - Star
+ Trek battle simulator
+ </li><li><a href="http://mesa3d.sourceforge.net/notfound.html">Gepetto</a> - Dance Choreography
+ </li><li><a href="http://glchess.sourceforge.net/" target="_parent">GLChess</a> - chess game
+ </li><li><a href="http://heretic.linuxgames.com/" target="_parent">GLHeretic</a> - Heretic
+ for Linux
+ </li><li><a href="http://glider3d.free.fr/" target="_parent">Glider3D</a> - flight simulator
+ </li><li><a href="http://www.gltron.org/" target="_parent">glTron</a> - Tron lightcycles
+ game
+ </li><li><a href="http://gracer.sourceforge.net/" target="_parent">GRacer</a> - 3D Motor
+ Sports Simulator
+ </li><li><a href="http://jongl.home.pages.de/" target="_parent">JONGL</a> - Juggling simulator
+ </li><li><a href="http://samba.anu.edu.au/KnightCap/" target="_parent">KnightCap</a> -
+ chess game
+ </li><li><a href="http://www.hackcraft.de/games/linwarrior_3d/">LinWarrior 3D</a> - A Battle Mech Simulator
+ </li><li><a href="http://www.nada.kth.se/%7Ef96-lfo/lunar/" target="_parent">Lunar Lander
+ 2000</a> - 3D version of the classis lunar lander game
+ </li><li><a href="http://www.majik3d.org/" target="_parent">Majik 3D</a> - an online role-playing
+ world
+ </li><li><a href="http://www.pobox.com/%7Eshankel/opentrek.html" target="_parent">OpenTrek</a>
+ - Super Star Trek
+ </li><li><a href="http://www.idsoftware.com/" target="_parent">Quake(2,3)</a> - the popular
+ games from id software
+ </li><li><a href="http://torcs.free.fr/indexm.html" target="_parent">TORCS</a> - car racing
+ simulator
+ </li><li><a href="http://www.woodsoup.org/projs/tux_aqfh" target="_parent">TUX-AQFH</a>
+ - Tux the Penguin - a Quest for Herring
+ </li><li><a href="http://mordred.8m.com/voidrunner/" target="_parent">Void Runner</a>
+ - freeware arcade style game
+ </li><li><a href="http://xracer.annexia.org/" target="_parent">XRacer</a> - Free spaceship
+ racing game, similar to Wipeout
+</li></ul>
+
+
+</body></html> \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/docs/gears.png b/nx-X11/extras/Mesa/docs/gears.png
new file mode 100644
index 000000000..4052b30ed
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/gears.png
Binary files differ
diff --git a/nx-X11/extras/Mesa/docs/glfbdev-driver.html b/nx-X11/extras/Mesa/docs/glfbdev-driver.html
new file mode 100644
index 000000000..b49950eb9
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/glfbdev-driver.html
@@ -0,0 +1,90 @@
+<HTML>
+
+<TITLE>Mesa glFBDev Driver</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<center><H1>Mesa glFBDev Driver</H1></center>
+
+
+<H1>1. Introduction</H1>
+
+<p>
+The GLFBDev driver interface allows one to do OpenGL rendering into a
+framebuffer managed with the Linux's fbdev interface.
+</p>
+
+<p>
+Basically, the programmer uses the fbdev functions to initialize the
+graphics hardware and setup the framebuffer.
+Then, using a calls to Mesa's glFBDev API functions, one can render
+into the framebuffer with the OpenGL API functions.
+</p>
+
+<p>
+Note, only software rendering is supported; there is no hardware
+acceleration.
+</p>
+
+
+<p>
+The GL/glfbdev.h header file defines the glFBDev interface.
+</p>
+
+<p>
+The progs/fbdev/glfbdevtest.c demonstrates how to use the glFBDev interface.
+</p>
+
+<p>
+For more information about fbdev, see the
+<a href="http://www.tldp.org/HOWTO/Framebuffer-HOWTO.html" target="_parent">
+Framebuffer Howto</a>
+</p>
+
+
+<h1>2. Compilation</h1>
+
+<p>
+To compile Mesa with support for the glFBDev interface:
+<pre>
+ XXX todo
+</pre>
+
+<p>
+When compilation is finished look in progs/glfbdev/ for the glfbdevtest demo.
+</p>
+
+</p>
+xxx todo
+</p>
+
+
+<h1>3. Compiling and linking glFBDev programs</h1>
+
+<p>
+xxx todo
+</p>
+
+
+
+<h1>4. Running glFBDev programs</h1>
+
+<p>
+First, you need to have a working fbdev environment.
+See the
+<a href="http://www.tldp.org/HOWTO/Framebuffer-HOWTO.html" target="_parent">
+Framebuffer Howto</a> for information.
+</p>
+
+<p>
+Programs must be run with root permission.
+</p>
+
+</p>
+
+
+
+</body>
+</html>
diff --git a/nx-X11/extras/Mesa/docs/glu.html b/nx-X11/extras/Mesa/docs/glu.html
new file mode 100644
index 000000000..8adaf42bc
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/glu.html
@@ -0,0 +1,45 @@
+<HTML>
+
+<TITLE>SGI GLU</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>SGI SI GLU</H1>
+
+(Silicon Graphics, Inc. Sample Implementation of the OpenGL Utility library)
+
+<p>
+SGI open-sourced their OpenGL Sample Implementation (SI) in January, 2000.
+This includes the GLU library.
+</p>
+
+<p>
+The SI GLU library implements GLU version 1.3 whereas the original
+Mesa GLU library only implemented version 1.2.
+We recommend using the SI GLU library instead of Mesa's GLU library
+since it's more up-to-date, complete and reliable.
+We're no longer developing the original Mesa GLU library.
+</p>
+
+<p>
+The SI GLU library code is included in the Mesa distribution.
+You don't have to download it separately.
+</p>
+
+
+<p>
+<b>Olivier Michel</b> has made Linux RPMs of GLU for i386 and PowerPC.
+You can download them from the
+<a href="http://www.sourceforge.net/project/showfiles.php?group_id=3"
+target="_parent">download area</a> under <b>Miscellaneous</b>.
+</p>
+
+<p>
+Visit the <a href="http://oss.sgi.com/projects/ogl-sample/" target="_parent">
+OpenGL Sample Implementation home page</a> for more information about the SI.
+</p>
+
+</body>
+</html>
diff --git a/nx-X11/extras/Mesa/docs/helpwanted.html b/nx-X11/extras/Mesa/docs/helpwanted.html
new file mode 100644
index 000000000..346f093d6
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/helpwanted.html
@@ -0,0 +1,74 @@
+<HTML>
+
+<TITLE>Help Wanted</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Help Wanted</H1>
+
+<p>
+We can always use more help with the Mesa project.
+Here are some specific ideas and areas where help would be appreciated:
+</p>
+
+<ol>
+<li><p>
+ Generate the src/mesa/main/enums.c file with a Python script which
+ uses the gl_API.xml file.
+ </p>
+<li><p>
+ Try to auto-generate the display list "save" functions seen in dlist.c
+ using a Python script and the gl_API.xml file.
+ The gl_API.xml file will probably need a new tag to indicate whether or
+ not each function gets compiled into display lists.
+ </p>
+<li><p>
+ Maintenance of assembly language files on Linux, Windows and SPARC systems.
+ </p>
+<li><p>
+ Help to incorporate the 3Dlabs' shading language compiler for OpenGL 2.0.
+ </p>
+<li><p>
+ Implement assembly language (SSE/MMX) code generation for
+ vertex/fragment programs.
+ </p>
+<li><p>
+ Windows 98/NT driver building, maintenance and testing
+ (Karl Schultz has been doing a great job of this lately).
+ </p>
+<li><p>
+ Maintenance and testing of various drivers, such as DOS/DJGPP, GGI, etc.
+ </p>
+<li><p>
+ Write new tests for Glean.
+ </p>
+</ol>
+
+
+<p>
+If you want to help with Mesa, first join the Mesa developer's
+mailing list.
+Then post a message to propose what you want to do, just to make sure
+there's no issues.
+</p>
+
+</p>
+Anyone is welcome to contribute code to the Mesa project.
+By doing so, it's assumed that you agree to the code's licensing terms.
+</p>
+
+<p>
+Finally:
+<p>
+
+<ol>
+<li>Try to write high-quality code that follows the existing style.
+<li>Use uniform indentation, write comments, use meaningful identifiers, etc.
+<li>Test your code thoroughly. Include test programs if appropriate.
+</ol>
+
+
+</BODY>
+</HTML>
diff --git a/nx-X11/extras/Mesa/docs/index.html b/nx-X11/extras/Mesa/docs/index.html
new file mode 100644
index 000000000..eec4d725c
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/index.html
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
+<html>
+
+<head>
+<title>Mesa Home Page</title>
+</head>
+
+<frameset rows="80,*" border="0" frameborder="yes">
+
+ <frame src="banner.html" name="BannerFrame"
+ scrolling="no" marginwidth="1" marginheight="1">
+
+ <frameset cols="28%,72% " border="1" frameborder="yes">
+
+ <frame src="contents.html" name="ContentsFrame"
+ marginwidth="2" marginheight="1" noresize="noresize">
+
+ <frame src="news.html" name="MainFrame"
+ marginwidth="3" marginheight="1" noresize="noresize">
+
+ </frameset>
+
+<noframes>
+<p>Sorry, this site requires frame support</p>
+</noframes>
+
+</frameset>
+
+</html>
diff --git a/nx-X11/extras/Mesa/docs/install.html b/nx-X11/extras/Mesa/docs/install.html
new file mode 100644
index 000000000..129daced4
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/install.html
@@ -0,0 +1,309 @@
+<HTML>
+
+<TITLE>Compilation and Installation</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+
+<H1>Compilation and Installation</H1>
+
+<ol>
+<li><a href="#unix-x11">Unix / X11</a>
+<li><a href="#windows">Windows</a>
+<li><a href="#vms">VMS</a>
+<li><a href="#other">Other</a>
+</ol>
+
+
+
+<a name="unix-x11">
+<H2>1. Unix/X11 Compilation and Installation</H1>
+
+<h3>1.1 Compilation</h3>
+
+<p>
+Mesa may be compiled in several different ways:
+</p>
+<ul>
+<li><b><em>Stand-alone/Xlib mode</em></b> - Mesa is compiled as
+a software renderer using Xlib to do all rendering.
+libGL.so is a self-contained rendering library.
+<p>
+To compile stand-alone Mesa type <b>make</b> in the top-level directory.
+You'll see a list of supported system configurations.
+Choose one from the list (such as linux-x86), and type:
+</p>
+<pre>
+ make linux-x86
+</pre>
+<p>This will produce libGL.so and several other libraries</p>
+</li>
+
+<li><b><em>DRI/accelerated</em></b> - The DRI hardware drivers (for ATI,
+Intel, Matrox, etc) are built.
+libGL.so implements the GLX extension and dynamically loads the DRI drivers.
+<p>
+To build the DRI drivers you'll first need to have the DRM (Direct
+Rendering Manager) kernel drivers and header files.
+They're available from the <a href="http://dri.sf.net/" target="_parent">DRI</a> project.
+</p>
+<p>
+You can get them from CVS by doing:
+<pre>
+cvs -d:pserver:anonymous@pds.freedesktop.org:/cvs/dri login
+(hit enter when prompted for a password)
+cvs -z3 -d:pserver:anonymous@pdx.freedesktop.org:/cvs/dri co drm
+</pre>
+<p>
+Make note of the directory in which the drm files are placed.
+</p>
+<p>
+See the <a href="http://dri.freedesktop.org/wiki/Building" target="_parent">
+DRI Building Instructions</a> for the steps to build the DRM modules.
+</p>
+<p>
+Next, in the <code>Mesa-x.y.z/configs/default</code> file, set the
+<code>DRM_SOURCE_PATH</code> variable to indicate where the DRM files
+are located.
+</p>
+<p>
+Now build Mesa and the DRI drivers by running
+</p>
+<pre>
+make linux-dri
+</pre>
+<p>
+There are also <code>linux-dri-x86</code>, <code>linux-dri-x86-64</code>,
+and <code>linux-ppc</code> configurations, optimized for those architectures.
+</p>
+
+<p>
+Finally, you'll need a DRI-enabled X server from
+<a href="http://freedesktop.org/wiki/Software_2fXserver" target="_parent">
+X.org</a> or <a href="http://www.xfree86.org" target="_parent">XFree86</a>.
+Visit those projects' home pages for more information.
+</p>
+
+</li>
+</ul>
+
+
+<p>
+Later, if you want to rebuild for a different configuration run
+<code>make realclean</code> before rebuilding.
+</p>
+
+
+<h3>1.2 The libraries</h3>
+
+<p>
+When compilation has finished, look in the top-level <code>lib/</code>
+directory.
+You'll see a set of library files similar to this:
+</p>
+<pre>
+lrwxrwxrwx 1 brian users 10 Mar 26 07:53 libGL.so -> libGL.so.1*
+lrwxrwxrwx 1 brian users 19 Mar 26 07:53 libGL.so.1 -> libGL.so.1.5.060100*
+-rwxr-xr-x 1 brian users 3375861 Mar 26 07:53 libGL.so.1.5.060100*
+lrwxrwxrwx 1 brian users 11 Mar 26 07:53 libGLU.so -> libGLU.so.1*
+lrwxrwxrwx 1 brian users 20 Mar 26 07:53 libGLU.so.1 -> libGLU.so.1.3.060100*
+-rwxr-xr-x 1 brian users 549269 Mar 26 07:53 libGLU.so.1.3.060100*
+lrwxrwxrwx 1 brian users 12 Mar 26 07:53 libglut.so -> libglut.so.3*
+lrwxrwxrwx 1 brian users 16 Mar 26 07:53 libglut.so.3 -> libglut.so.3.7.1*
+-rwxr-xr-x 1 brian users 597754 Mar 26 07:53 libglut.so.3.7.1*
+lrwxrwxrwx 1 brian users 11 Mar 26 08:04 libGLw.so -> libGLw.so.1*
+lrwxrwxrwx 1 brian users 15 Mar 26 08:04 libGLw.so.1 -> libGLw.so.1.0.0*
+-rwxr-xr-x 1 brian users 20750 Mar 26 08:04 libGLw.so.1.0.0*
+lrwxrwxrwx 1 brian users 14 Mar 26 07:53 libOSMesa.so -> libOSMesa.so.6*
+lrwxrwxrwx 1 brian users 23 Mar 26 07:53 libOSMesa.so.6 -> libOSMesa.so.6.1.060100*
+-rwxr-xr-x 1 brian users 23871 Mar 26 07:53 libOSMesa.so.6.1.060100*
+</pre>
+
+<p>
+<b>libGL</b> is the main OpenGL library (i.e. Mesa).
+<br>
+<b>libGLU</b> is the OpenGL Utility library.
+<br>
+<b>libglut</b> is the GLUT library.
+<br>
+<b>libGLw</b> is the Xt/Motif OpenGL drawing area widget library.
+<br>
+<b>libOSMesa</b> is the OSMesa (Off-Screen) interface library.
+</p>
+
+<p>
+If you built the DRI hardware drivers, you'll also see the DRI drivers:
+</p>
+<pre>
+-rwxr-xr-x 1 brian users 11320803 Jul 21 12:11 mach64_dri.so
+-rwxr-xr-x 1 brian users 11418014 Jul 21 12:12 mga_dri.so
+-rwxr-xr-x 1 brian users 11064426 Jul 21 12:12 r128_dri.so
+-rwxr-xr-x 1 brian users 11849858 Jul 21 12:12 r200_dri.so
+-rwxr-xr-x 1 brian users 11757388 Jul 21 12:12 radeon_dri.so
+-rwxr-xr-x 1 brian users 11232304 Jul 21 12:13 s3v_dri.so
+-rwxr-xr-x 1 brian users 11062970 Jul 21 12:13 savage_dri.so
+-rwxr-xr-x 1 brian users 11214212 Jul 21 12:13 sis_dri.so
+-rwxr-xr-x 1 brian users 11368736 Jul 21 12:13 tdfx_dri.so
+-rwxr-xr-x 1 brian users 10598868 Jul 21 12:13 trident_dri.so
+-rwxr-xr-x 1 brian users 10997120 Jul 21 12:13 unichrome_dri.so
+</pre>
+
+
+<h3>1.3 Running the demos</h3>
+
+<p>
+If you downloaded/unpacked the MesaDemos-x.y.z.tar.gz archive or
+obtained Mesa from CVS, the <b>progs/</b> directory will contain a
+bunch of demonstration programs.
+</p>
+
+<p>
+Before running a demo, you may have to set an environment variable
+(such as <b>LD_LIBRARY_PATH</b> on Linux) to indicate where the
+libraries are located. For example:
+<p>
+<blockquote>
+<b>cd</b> into the Mesa <b>lib/</b> directory.
+<br>
+<b>setenv LD_LIBRARY_PATH ${cwd}</b> (if using csh or tcsh shell)
+<br>
+or,
+<br>
+<b>export LD_LIBRARY_PATH=${PWD}</b> (if using bash or sh shell)
+</blockquote>
+
+<p>
+Next, change to the Mesa/demos/ directory:
+</p>
+<blockquote>
+<b>cd ../progs/demos</b>
+</blockquote>
+
+<p>
+Run a demo such as gears:
+</p>
+<blockquote>
+<b>./gears</b>
+</blockquote>
+
+<p>
+If this doesn't work, try the <b>Mesa/progs/xdemos/glxinfo</b> program
+and see that it prints the expected Mesa version number.
+</p>
+
+<p>
+If you're using Linux or a similar OS, verify that the demo program is
+being linked with the proper library files:
+</p>
+<blockquote>
+<b>ldd gears</b>
+</blockquote>
+
+<p>
+You should see something like this:
+</p>
+<pre>
+ libglut.so.3 => /home/brian/Mesa/lib/libglut.so.3 (0x40013000)
+ libGLU.so.1 => /home/brian/Mesa/lib/libGLU.so.1 (0x40051000)
+ libGL.so.1 => /home/brian/Mesa/lib/libGL.so.1 (0x400e0000)
+ libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
+ libm.so.6 => /lib/i686/libm.so.6 (0x403da000)
+ libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x403fc000)
+ libXmu.so.6 => /usr/X11R6/lib/libXmu.so.6 (0x404da000)
+ libXt.so.6 => /usr/X11R6/lib/libXt.so.6 (0x404f1000)
+ libXi.so.6 => /usr/X11R6/lib/libXi.so.6 (0x40543000)
+ libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x4054b000)
+ libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x405fd000)
+ libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x40605000)
+ libpthread.so.0 => /lib/i686/libpthread.so.0 (0x40613000)
+ /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
+ libdl.so.2 => /lib/libdl.so.2 (0x40644000)
+ libSM.so.6 => /usr/X11R6/lib/libSM.so.6 (0x40647000)
+ libICE.so.6 => /usr/X11R6/lib/libICE.so.6 (0x40650000)
+</pre>
+
+<p>
+Retrace your steps if this doesn't look right.
+</p>
+
+
+<H3>1.4 Installing the header and library files</H3>
+
+<p>
+The standard location for the OpenGL header files on Unix-type systems is
+in <code>/usr/include/GL/</code>.
+The standard location for the libraries is <code>/usr/lib/</code>.
+For more information see, the
+<a href="http://oss.sgi.com/projects/ogl-sample/ABI/" target="_parent">
+Linux/OpenGL ABI specification</a>.
+</p>
+
+<p>
+If you'd like Mesa to co-exist with another implementation of OpenGL that's
+already installed, you'll have to choose different directories, like
+<code>/usr/local/include/GL/</code> and <code>/usr/local/lib/</code>.
+</p>
+
+<p>
+To install Mesa's headers and libraries, run <code>make install</code>
+You'll be prompted to enter alternative directories for the headers
+and libraries.
+</p>
+
+<p>
+Note: at runtime, you can set the LD_LIBRARY_PATH (on Linux) to switch
+between the Mesa libs and another vendor libs whenever you want.
+This is a handy way to compare multiple OpenGL implementations.
+</p>
+
+
+
+<a name="windows">
+<H2>2. Windows Compilation and Installation</H1>
+
+<p>
+Please see the <a href="README.WIN32">README.WIN32</a> file.
+</p>
+
+
+
+
+<a name="vms">
+<H2>3. VMS Compilation and Installation</H1>
+
+<p>
+Please see the <a href="README.VMS">README.VMS</a> file.
+</p>
+
+
+
+
+<a name="other">
+<H2>4. Other systems</H1>
+
+<p>
+Documentation for other environments (some may be very out of date):
+</p>
+
+<UL>
+<LI><A HREF="README.GGI">README.GGI</A> - GGI
+<LI><A HREF="README.3DFX">README.3DFX</A> - 3Dfx/Glide driver
+<LI><A HREF="README.AMIWIN">README.AMIWIN</A> - Amiga Amiwin
+<LI><A HREF="README.BEOS">README.BEOS</A> - BeOS
+<LI><A HREF="README.D3D">README.D3D</A> - Direct3D driver
+<LI><A HREF="README.DJ">README.DJ</A> - DJGPP
+<LI><A HREF="README.LYNXOS">README.LYNXOS</A> - LynxOS
+<LI><A HREF="README.MINGW32">README.MINGW32</A> - Mingw32
+<LI><A HREF="README.NeXT">README.NeXT</A> - NeXT
+<LI><A HREF="README.OpenStep">README.OpenStep</A> - OpenStep
+<LI><A HREF="README.OS2">README.OS2</A> - OS/2
+<LI><A HREF="README.WINDML">README.WINDML</A> - WindML
+</UL>
+
+
+
+
+</body>
+</html>
diff --git a/nx-X11/extras/Mesa/docs/intro.html b/nx-X11/extras/Mesa/docs/intro.html
new file mode 100644
index 000000000..374d124b3
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/intro.html
@@ -0,0 +1,306 @@
+<HTML>
+
+<TITLE>Mesa Introduction</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Introduction</H1>
+
+<p>
+Mesa is a 3-D graphics library with an API which is very similar to
+that of <a href="http://www.opengl.org/" target="_parent">OpenGL</a>.*
+To the extent that Mesa utilizes the OpenGL command syntax or state
+machine, it is being used with authorization from <a
+href="http://www.sgi.com/" target="_parent">Silicon Graphics,
+Inc.</a>(SGI). However, the author does not possess an OpenGL license
+from SGI, and makes no claim that Mesa is in any way a compatible
+replacement for OpenGL or associated with SGI. Those who want a
+licensed implementation of OpenGL should contact a licensed
+vendor.
+</p>
+
+<p>
+Please do not refer to the library as <em>MesaGL</em> (for legal
+reasons). It's just <em>Mesa</em> or <em>The Mesa 3-D graphics
+library</em>. <br>
+</p>
+
+<p>
+* OpenGL is a trademark of <a href="http://www.sgi.com/"
+target="_parent">Silicon Graphics Incorporated</a>.
+</p>
+
+
+<H1>Project History</H1>
+
+<p>
+The Mesa project was founded by me, Brian Paul. Here's a short history
+of the project.
+</p>
+
+<p>
+August, 1993: I begin working on Mesa in my spare time. The project
+has no name at that point. I was simply interested in writing a simple
+3D graphics library that used the then-new OpenGL API. I was partially
+inspired by the <em>VOGL</em> library which emulated a subset of IRIS GL.
+I had been programming with IRIS GL since 1991.
+</p>
+
+<p>
+November 1994: I contact SGI to ask permission to distribute my OpenGL-like
+graphics library on the internet. SGI was generally receptive to the
+idea and after negotiations with SGI's legal department, I get permission
+to release it.
+</p>
+
+<p>
+February 1995: Mesa 1.0 is released on the internet. I expected that
+a few people would be interested in it, but not thousands.
+I was soon receiving patches, new features and thank-you notes on a
+daily basis. That encouraged me to continue working on Mesa. The
+name Mesa just popped into my head one day. SGI had asked me not to use
+the terms <em>"Open"</em> or <em>"GL"</em> in the project name and I didn't
+want to make up a new acronym. Later, I heard of the Mesa programming
+language and the Mesa spreadsheet for NeXTStep.
+</p>
+
+<p>
+In the early days, OpenGL wasn't available on too many systems.
+It even took a while for SGI to support it across their product line.
+Mesa filled a big hole during that time.
+For a lot of people, Mesa was their first introduction to OpenGL.
+I think SGI recognized that Mesa actually helped to promote
+the OpenGL API, so they didn't feel threatened by the project.
+</p>
+
+
+<p>
+1995-1996: I continue working on Mesa both during my spare time and during
+my work hours at the Space Science and Engineering Center at the University
+of Wisconsin in Madison. My supervisor, Bill Hibbard, lets me do this because
+Mesa is now being using for the <a href="http://www.ssec.wisc.edu/%7Ebillh/vis.html" target="_parent">Vis5D</a> project.
+</p><p>
+October 1996: Mesa 2.0 is released. It implements the OpenGL 1.1 specification.
+</p>
+
+<p>
+March 1997: Mesa 2.2 is released. It supports the new 3dfx Voodoo graphics
+card via the Glide library. It's the first really popular hardware OpenGL
+implementation for Linux.
+</p>
+
+<p>
+September 1998: Mesa 3.0 is released. It's the first publicly-available
+implementation of the OpenGL 1.2 API.
+</p>
+
+<p>
+March 1999: I attend my first OpenGL ARB meeting. I contribute to the
+development of several official OpenGL extensions over the years.
+</p>
+
+<p>
+September 1999: I'm hired by Precision Insight, Inc. Mesa is a key
+component of 3D hardware acceleration in the new DRI project for XFree86.
+Drivers for 3dfx, 3dLabs, Intel, Matrox and ATI hardware soon follow.
+</p>
+
+<p>
+October 2001: Mesa 4.0 is released.
+It implements the OpenGL 1.3 specification.
+</p>
+
+
+<p>
+November 2001: I cofound <a href="http://www.tungstengraphics.com" target="_parent">
+Tungsten Graphics, Inc.</a> with Keith Whitwell, Jens Owen, David Dawes and
+Frank LaMonica.
+I continue to develop Mesa as part of my resposibilities with Tungsten
+Graphics and as a spare-time project.
+</p>
+
+<p>
+November 2002: Mesa 5.0 is released.
+It implements the OpenGL 1.4 specification.
+</p>
+
+<p>
+January 2003: Mesa 6.0 is released. It implements the OpenGL 1.5
+specification as well as the GL_ARB_vertex_program and
+GL_ARB_fragment_program extensions.
+</p>
+
+
+<p>
+Ongoing: Mesa is used as the core of many hardware OpenGL drivers for
+the XFree86 X.org X servers within the
+<A href="http://dri.sourceforge.net/" target="_parent">DRI project</A>.
+I continue to enhance Mesa with new extensions and features.
+</p>
+
+
+
+<H1>Major Versions</H1>
+
+<p>
+This is a summary of the major versions of Mesa. Note that Mesa's major
+version number tracks OpenGL's minor version number (+1).
+Work is underway to implement the OpenGL 2.0 specification.
+</p>
+
+
+<H2>Version 6.x features</H2>
+<p>
+Version 6.x of Mesa implements the OpenGL 1.5 API with the following
+extensions incorporated as standard features:
+</p>
+<ul>
+<li>GL_ARB_occlusion_query
+<li>GL_ARB_vertex_buffer_object
+<li>GL_EXT_shadow_funcs
+</ul>
+<p>
+Also note that several OpenGL tokens were renamed in OpenGL 1.5
+for the sake of consistency.
+The old tokens are still available.
+</p>
+<pre>
+New Token Old Token
+------------------------------------------------------------
+GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE
+GL_FOG_COORD GL_FOG_COORDINATE
+GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE
+GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE
+GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE
+GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER
+GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY
+GL_SRC0_RGB GL_SOURCE0_RGB
+GL_SRC1_RGB GL_SOURCE1_RGB
+GL_SRC2_RGB GL_SOURCE2_RGB
+GL_SRC0_ALPHA GL_SOURCE0_ALPHA
+GL_SRC1_ALPHA GL_SOURCE1_ALPHA
+GL_SRC2_ALPHA GL_SOURCE2_ALPHA
+</pre>
+<p>
+See the
+<a href="http://www.opengl.org/documentation/spec.html" target="_parent">
+OpenGL specification</a> for more details.
+</p>
+
+
+
+<H2>Version 5.x features</H2>
+<p>
+Version 5.x of Mesa implements the OpenGL 1.4 API with the following
+extensions incorporated as standard features:
+</p>
+<ul>
+<li>GL_ARB_depth_texture
+<li>GL_ARB_shadow
+<li>GL_ARB_texture_env_crossbar
+<li>GL_ARB_texture_mirror_repeat
+<li>GL_ARB_window_pos
+<li>GL_EXT_blend_color
+<li>GL_EXT_blend_func_separate
+<li>GL_EXT_blend_logic_op
+<li>GL_EXT_blend_minmax
+<li>GL_EXT_blend_subtract
+<li>GL_EXT_fog_coord
+<li>GL_EXT_multi_draw_arrays
+<li>GL_EXT_point_parameters
+<li>GL_EXT_secondary_color
+<li>GL_EXT_stencil_wrap
+<li>GL_EXT_texture_lod_bias (plus, a per-texture LOD bias parameter)
+<li>GL_SGIS_generate_mipmap
+</ul>
+
+
+<H2>Version 4.x features</H2>
+
+<p>
+Version 4.x of Mesa implements the OpenGL 1.3 API with the following
+extensions incorporated as standard features:
+</p>
+
+<ul>
+<li>GL_ARB_multisample
+<li>GL_ARB_multitexture
+<li>GL_ARB_texture_border_clamp
+<li>GL_ARB_texture_compression
+<li>GL_ARB_texture_cube_map
+<li>GL_ARB_texture_env_add
+<li>GL_ARB_texture_env_combine
+<li>GL_ARB_texture_env_dot3
+<li>GL_ARB_transpose_matrix
+</ul>
+
+<H2>Version 3.x features</H2>
+
+<p>
+Version 3.x of Mesa implements the OpenGL 1.2 API with the following
+features:
+</p>
+<ul>
+<li>BGR, BGRA and packed pixel formats
+<li>New texture border clamp mode
+<li>glDrawRangeElements()
+<li>standard 3-D texturing
+<li>advanced MIPMAP control
+<li>separate specular color interpolation
+</ul>
+
+
+<H2>Version 2.x features</H2>
+<p>
+Version 2.x of Mesa implements the OpenGL 1.1 API with the following
+features.
+</p>
+<ul>
+<li>Texture mapping:
+ <ul>
+ <li>glAreTexturesResident
+ <li>glBindTexture
+ <li>glCopyTexImage1D
+ <li>glCopyTexImage2D
+ <li>glCopyTexSubImage1D
+ <li>glCopyTexSubImage2D
+ <li>glDeleteTextures
+ <li>glGenTextures
+ <li>glIsTexture
+ <li>glPrioritizeTextures
+ <li>glTexSubImage1D
+ <li>glTexSubImage2D
+ </ul>
+<li>Vertex Arrays:
+ <ul>
+ <li>glArrayElement
+ <li>glColorPointer
+ <li>glDrawElements
+ <li>glEdgeFlagPointer
+ <li>glIndexPointer
+ <li>glInterleavedArrays
+ <li>glNormalPointer
+ <li>glTexCoordPointer
+ <li>glVertexPointer
+ </ul>
+<li>Client state management:
+ <ul>
+ <li>glDisableClientState
+ <li>glEnableClientState
+ <li>glPopClientAttrib
+ <li>glPushClientAttrib
+ </ul>
+<li>Misc:
+ <ul>
+ <li>glGetPointer
+ <li>glIndexub
+ <li>glIndexubv
+ <li>glPolygonOffset
+ </ul>
+</ul>
+
+
+</body>
+</html>
diff --git a/nx-X11/extras/Mesa/docs/libraries.html b/nx-X11/extras/Mesa/docs/libraries.html
new file mode 100644
index 000000000..ce0ee70e6
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/libraries.html
@@ -0,0 +1,57 @@
+<HTML>
+
+<TITLE>Libraries and Toolkits</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Libraries and Toolkits</H1>
+
+<ul>
+<li><a href="http://mrpowers.com/Apprentice/">Apprentice</a> - free OpenInventor work-alike
+<li><a href="http://www.coin3d.org/coin.html" target="_parent">Coin</a> - OSS Open Inventor clone
+<li><a href="http://www.softintegration.com/products/toolkit/opengl/" target="_parent">Ch</a> - OpenGL bindings for the Ch C/C++ interpreter
+<li><a href="http://www.cfdrc.com/FOX/fox.html" target="_parent">FOX</a> - GUI Library
+<li><a href="http://www.jausoft.com/gl4java.html" target="_parent">GL4Java</a> - a Java wrapper for OpenGL
+<li><a href="http://www.student.oulu.fi/%7Ejlof/gtkglarea/" target="_parent">GtkGLArea</a> - OpenGL Gtk widget
+<li><a href="http://www.ece.ucdavis.edu/%7Ekenelson/gtk-glarea/" target="_parent">GtkGLArea--</a> - OpenGL Gtk-- widget for C++
+<li><a href="http://gtkpas.sourceforge.net/" target="_parent">GTKpas</a> - OpenGL Gtk widget for <a href="http://www.freepascal.org/" target="_parent">FreePascal</a>
+<li><a href="http://freeglut.sourceforge.net/" target="_parent">FreeGLUT</a> - a GLUT work-alike
+<li><a href="http://math.nist.gov/f90gl" target="_parent">Fortran77/90 bindings for OpenGL and Mesa</a> - by William Mitchell
+<li><a href="http://glow.sourceforge.net/" target="_parent">GLOW</a> - a GUI toolkit for GLUT and OpenGL
+<li><a href="http://www.nigels.com/glt/">Glt</a> - an OpenGL C++ toolkit
+<li><a href="http://www.opengl.org/developers/documentation/glut/" target="_parent">GLUT (GL Utility Toolkit)</a> - by Mark Kilgard
+<li><a href="http://atrey.karlin.mff.cuni.cz/%7E0rfelyus/guileGL/" target="_parent">GuileGL</a> - OpenGL and GtkGLArea language bindings for Guile
+<li><a href="http://www.rsinc.com/" target="_parent">IDL</a> - Interactive Data Language
+<li><a href="http://www.newplanetsoftware.com/jx/" target="_parent">JX</a> - C++ application framework and GUI library
+<li><a href="http://www.vrs3d.org/" target="_parent">MAM/VRS</a> - object-oriented toolkit for 3D graphics
+<li><a href="http://www.jwdt.com/%7Epaysan/bigforth.html" target="_parent">MINOS</a> - GUI library
+<li><a href="http://sourceforge.net/project/?group_id=2795" target="_parent">OglCLib</a> - C++ wrapper for OpenGL
+<li><a href="http://oss.sgi.com/projects/inventor" target="_parent"> Open Inventor</a> - the Open Inventor toolkit from SGI
+<li><a href="http://www.tgs.com/" target="_parent">Open Inventor</a> - the Open Inventor toolkit from Template Graphics Software, Inc.
+<li><a href="http://openrm.sourceforge.net/" target="_parent">OpenRM</a>
+- Open Source, multithreaded, parallel scene graph API
+<li><a href="http://www.opensg.org/OpenSGPLUS/index.EN.html" target="_parent">
+Open SG PLUS</a> - a scene-graph library
+<li><a href="http://www.openscenegraph.org/" target="_parent">Open Scene Graph
+</a> - a scene-graph library
+<li><a href="http://www.openvrml.org/" target="_parent">OpenVRML</a>
+- a VRML parsing/display library with "lookat" - an example VRML browser
+<li><a href="http://plib.sourceforge.net/" target="_parent">PLIB</a> - A collection of portable games libraries, including an OpenGL GUI and a simple Scene Graph API
+<li><a href="ftp://ftp.troll.no/contest/Pryan-1.2.tar.gz" target="_parent">Pryan</a> - an OpenInventor-like toolkit
+<li><a href="http://starship.python.net:9673/crew/da/Code/PyOpenGL" target="_parent">PyOpenGL</a> - OpenGL interface for Python
+<li><a href="http://www.quesa.org/" target="_parent">Quesa</a> - QuickDraw3D-compatible library based on OpenGL, Mesa or Direct3D
+<li><a href="http://www.mesa3d.org/brianp/repgl.txt" target="_parent">repGL</a> - IRIS GL emulated with OpenGL
+<li><a href="http://www.scitechsoft.com/dp_mgl.html" target="_parent">SciTech MGL</a> - A multiplatform (Windows, Linux, OS/2, DOS, QNX, SMX, RT-Target &amp; more) graphics library
+<li><a href="http://sgl.sourceforge.net/" target="_parent">SGL</a> - a 3D Scene Graph Library
+<li><a href="http://www.lal.in2p3.fr/SI/SoFree/" target="_parent">SoFree</a> - a free implementation of Open Inventor
+<li><a href="http://togl.sourceforge.net/" target="_parent">Togl</a> - Tcl/Tk widget for OpenGL
+<li><a href="http://mesa3d.sourceforge.net/notfound.html">VLE</a> - Virtual Reality Toolkit
+<li><a href="http://www.int.com/" target="_parent">View3D Widget</a> - 3-D GUI widget
+<li><a href="http://www.vtk.org/" target="_parent">VTK</a> - Visualization Toolkit
+<li><a href="http://home.earthlink.net/%7Erzeh/YAJOGLB/doc/YAJOGLB.html" target="_parent">YAJOGL</a> - Yet Another Java GL Binding.
+</ul>
+
+
+</body></html> \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/docs/license.html b/nx-X11/extras/Mesa/docs/license.html
new file mode 100644
index 000000000..dd878619b
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/license.html
@@ -0,0 +1,86 @@
+<HTML>
+
+<TITLE>License / Cppyright Information</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>License / Copyright Information</H1>
+
+<p>
+The Mesa distribution consists of several components. Different copyrights
+and licenses apply to different components. For example, GLUT is copyrighted
+by Mark Kilgard, some demo programs are copyrighted by SGI, some of the Mesa
+device drivers are copyrighted by their authors. See below for a list of
+Mesa's main components and the license for each.
+</p>
+<p>
+The core Mesa library is licensed according to the terms of the MIT license.
+This allows integration with the XFree86, Xorg and DRI projects.
+</p>
+<p>
+The default Mesa license is as follows:
+</p>
+
+<pre>
+Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the "Software"),
+to deal in the Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+</pre>
+
+
+<H1>Attention, Contributors</H1>
+
+<p>
+When contributing to the Mesa project you must agree to the licensing terms
+of the component to which you're contributing.
+The following section lists the primary components of the Mesa distribution
+and their respective licenses.
+</p>
+
+
+<H1>Mesa Component Licenses</H1>
+
+<pre>
+Component Location Primary Author License
+----------------------------------------------------------------------------
+Main Mesa code src/mesa/ Brian Paul Mesa (MIT)
+
+Device drivers src/mesa/drivers/* See drivers See drivers
+
+Ext headers include/GL/glext.h SGI SGI Free B
+ include/GL/glxext.h
+
+GLUT src/glut/ Mark Kilgard Mark's copyright
+
+Mesa GLU library src/glu/mesa/ Brian Paul GNU-LGPL
+
+SGI GLU library src/glu/sgi/ SGI SGI Free B
+
+demo programs progs/demos/ various see source files
+
+X demos progs/xdemos/ Brian Paul see source files
+
+SGI demos progs/samples/ SGI SGI copyright
+
+RedBook demos progs/redbook/ SGI SGI copyright
+</pre>
+
+</body>
+</html>
diff --git a/nx-X11/extras/Mesa/docs/lists.html b/nx-X11/extras/Mesa/docs/lists.html
new file mode 100644
index 000000000..76ebf32c3
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/lists.html
@@ -0,0 +1,55 @@
+<HTML>
+
+<TITLE>Mesa Mailing Lists</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Mailing Lists</H1>
+
+
+<p>There are four Mesa mailing lists:</p>
+<ul>
+<li><b>mesa3d-users</b> - intended for users of the Mesa library.
+Newbie questions are appropriate, but please try reading the Mesa documentation first.
+</li><li><b>mesa3d-dev</b> - intended for developers of the Mesa library.
+This is not for beginners.
+</li><li><b>mesa3d-cvs</b> - CVS check-in messages are sent to this list.
+This is useful for tracking ongoing development changes.
+</li><li><b>mesa3d-announce</b> - announcements of new Mesa versions are sent to this list.
+</li></ul>
+
+<p>
+To subscribe or unsubscribe, go to the
+<a href="http://www.sourceforge.net/mail/?group_id=3" target="_parent">
+SourceForge lists page.</a>
+</p>
+
+<p>The mailing lists are managed by SourceForge. If you're having trouble
+with the mailing lists please contact the SourceForge administrators for help.</p>
+
+<p>Archives of the old Mesa mailing list which was hosted by unicamp.br
+are available <a href="http://groups.yahoo.com/group/mesa/messages/"
+target="_parent">here</a>.</p>
+
+<p>
+Here are some other OpenGL-related forums you might find useful:
+</p>
+
+<p>
+Usenet newsgroups:
+<ul>
+<li>comp.graphics.algorithms
+<li>comp.graphics.api.opengl
+<li>comp.os.linux.x
+</ul>
+</p>
+
+<p>
+<a href="http://www.opengl.org/" target="_parent">OpenGL discussion forums</A>
+at www.opengl.org
+</p>
+
+</HTML>
+</BODY>
diff --git a/nx-X11/extras/Mesa/docs/mangling.html b/nx-X11/extras/Mesa/docs/mangling.html
new file mode 100644
index 000000000..cb19e7568
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/mangling.html
@@ -0,0 +1,28 @@
+<HTML>
+
+<TITLE>Function Name Mangling</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Function Name Mangling</H1>
+
+<p>
+If you want to use Mesa and native OpenGL in the same application at
+the same time you may find it useful to compile Mesa with
+<i>name mangling</i>.
+This results in all the Mesa functions being prefixed with
+<b>mgl</b> instead of <b>gl</b>.
+</p>
+
+<p>
+To do this, recompile Mesa with the compiler flag -DUSE_MGL_NAMESPACE.
+Add the flag to the other compiler flags in Make-config (if using the
+old-style build system) or in src/Makefile if using GNU autoconf/
+automake to build Mesa.
+</p>
+
+
+</BODY>
+</HTML>
diff --git a/nx-X11/extras/Mesa/docs/mesa.css b/nx-X11/extras/Mesa/docs/mesa.css
new file mode 100644
index 000000000..a53a9df8b
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/mesa.css
@@ -0,0 +1,33 @@
+/* Mesa CSS */
+body {
+ background-color: #ffffff;
+ font: 14px 'Lucida Grande', Geneva, Arial, Verdana, sans-serif;
+ color: black;
+ link: #111188;
+}
+
+h1 {
+ font: 24px 'Lucida Grande', Geneva, Arial, Verdana, sans-serif;
+ font-weight: bold;
+ color: black;
+}
+
+h2 {
+ font: 18px 'Lucida Grande', Geneva, Arial, Verdana, sans-serif, bold;
+ font-weight: bold;
+ color: black;
+}
+
+code {
+ font-family: monospace;
+ font-size: 10pt;
+ color: black;
+}
+
+
+pre {
+ /*font-family: monospace;*/
+ font-size: 10pt;
+ /*color: black;*/
+}
+
diff --git a/nx-X11/extras/Mesa/docs/modelers.html b/nx-X11/extras/Mesa/docs/modelers.html
new file mode 100644
index 000000000..617a03159
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/modelers.html
@@ -0,0 +1,70 @@
+<HTML>
+
+<TITLE>Modelers, Renderers and Viewers</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Modelers, Renderers and Viewers</H1>
+
+<ul>
+ <li><a href="http://www.aqsis.com/" target="_parent">Aqsis</a> - a RenderMan compatible renderer</li>
+ <li><a href="http://www.ac3d.org/" target="_parent">AC3D</a> - 3-D modeler
+ </li><li><a href="http://mesa3d.sourceforge.net/notfound.html">ARCAD</a> - CAD program
+ </li><li><a href="http://www.mediascape.com/" target="_parent">Artstream</a> - provides
+ functionality like Corel Draw and Illustrator
+ </li><li><a href="http://www.blender.nl/" target="_parent">Blender</a> - 3-D animation
+ software
+ </li><li><a href="http://www.arq.net/%7Ekasten/demtools/" target="_parent">Demtools</a>
+ - Map viewer
+ </li><li><a href="http://www.holometric.de/dimension/" target="_parent">DIMENSION</a>
+ - freeform surface reconstruction
+ </li><li><a href="http://www.vectaport.com/vhclmaps/demviewer.html" target="_parent">demviewer</a>
+ - interactive terrain viewer
+ </li><li><a href="http://www.crc.ca/FreeWRL" target="_parent">FreeWRL</a> - VRML browser
+ </li><li><a href="http://www.geomview.org/" target="_parent">Geomview</a> - 3-D geometry
+ exploration
+ </li><li><a href="http://innovation3d.sourceforge.net/" target="_parent">Innovation3D</a>
+ - 3D modeling program
+ </li><li><a href="http://mesa3d.sourceforge.net/notfound.html" target="_parent">KWRL</a> - VRML browser
+ </li><li><a href="http://www.vermontel.com/%7Ecmorley/vrml.html" target="_parent">LibVRML97/Lookat</a>
+ - VRML viewer
+ </li><li><a href="http://aig.cs.man.ac.uk/systems/Maverik/" target="_parent">Maverik</a>
+ - VR graphics and interaction system
+ </li><li><a href="http://www.swissquake.ch/chumbalum-soft/md2v" target="_parent">MD2 Viewer</a>
+ - View .MD2 files
+ </li><li><a href="http://www.megacads.dlr.de/" target="_parent">MegaCads</a>
+ - Multiblock-Elliptic-Grid-Generation-And-CAD-System
+ </li><li><a href="http://www.swissquake.ch/chumbalum-soft/" target="_parent">MilkShape
+ 3D</a> - 3D modeler/animator
+ </li><li><a href="http://mindseye.sourceforge.net/" target="_parent">Mindseye</a> - Rendering/Modeling
+ Package
+ </li><li><a href="http://mesa3d.sourceforge.net/notfound.html">Moonlight Atelier</a> - modeling and rendering package
+ </li><li><a href="http://www.neuralvr.com/" target="_parent">Pansophica</a> - Virtual Reality web organizer
+ </li><li><a href="http://www.sim.no/reducer.html" target="_parent">Rational Reducer</a>
+ - polygon reduction tool
+ </li><li><a href="http://www.cs.kuleuven.ac.be/cwis/research/graphics/RENDERPARK/" target="_parent">RenderPark</a>
+ - photorealistic rendering
+ </li><li><a href="http://www.hardgeus.com/revolution" target="_parent">Revolution 3D Engine</a>
+ - .3ds rendering engine
+ </li><li><a href="http://www.dgp.toronto.edu/%7Emjmcguff/eversion/" target="_parent">sphereEversion</a>
+ - inside-out sphere visualization
+ </li><li><a href="http://www.cs.kuleuven.ac.be/cwis/research/graphics/3DOM/" target="_parent">3Dom</a>
+ - 3-D modeler
+ </li><li><a href="http://mesa3d.sourceforge.net/notfound.html">3D Studio file viewer</a> - by David Farrell
+ </li><li><a href="http://www.microform.se/" target="_parent">VARKON</a> - product engineering,
+ design, modeling
+ </li><li><a href="http://www.sim.no/vrmlview.html" target="_parent">VRMLview</a> - VRML
+ model viewer
+ </li><li><a href="http://www.iicm.edu/vrwave/" target="_parent">VRWave</a> - a VRML 2.0
+ browser
+ </li><li><a href="http://mesa3d.sourceforge.net/notfound.html">VRweb</a> - VRML browser
+ </li><li><a href="http://www.csv.ica.uni-stuttgart.de/vrml/dune/" target="_parent">white_dune</a>
+ - graphical VRML97 Editor and animation tool
+ </li><li><a href="http://www.wings3d.org/" target="_parent">Wings 3D</a> - static 3D modeller
+ with VRML export. Uses SDL library.
+</li></ul>
+
+
+</body></html>
diff --git a/nx-X11/extras/Mesa/docs/news.html b/nx-X11/extras/Mesa/docs/news.html
new file mode 100644
index 000000000..8e9d5d33e
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/news.html
@@ -0,0 +1,1136 @@
+<HTML>
+
+<TITLE>Mesa News</TITLE>
+
+<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<body bgcolor="#eeeeee">
+
+<H1>News</H1>
+
+
+<h2>November 29, 2005</h2>
+<p>
+Mesa 6.4.1 has been released. This is a stable, bug-fix release.
+</p>
+<pre>
+ Bug fixes:
+ - redefining a vertex program string didn't take effect in TNL module
+ - fixed occasional segfault upon vertex/fragment parsing error
+ - vertex program LIT instruction didn't handle 0^0=1 correctly
+ - fragment program fog option didn't work with glDrawPixels, glBitmap
+ - USE_MGL_NAMESPACE didn't work for x86-64
+ - OSMesa demos were missing from previous release tarballs
+ - fixed problem with float->ushort conversion in glClear (bug 4992)
+ - popping of GL_EYE_PLANE texgen state was broken (bug 4996)
+ - popping of GL_SPOT_DIRECTION light state was broken (bug 5005)
+ - fixed occasional triangle color interpolation problem on VMS
+ - work around invalid free() call (bug 5131)
+ - fixed BSD X server compilation problem by including stdint.h
+</pre>
+<p>
+The MD5 checksums are:
+</p>
+<pre>
+TBD
+</pre>
+
+
+
+
+<h2>October 24, 2005</h2>
+<p>
+Mesa 6.4 has been released. This is a stable, bug-fix release.
+</p>
+<pre>
+ New:
+ - Added a fast XOR line drawing function in Xlib driver
+ - Added support for GL_ARB_texture_mirrored_repeat to savage
+ driver (supported only on Savage4 hardware).
+ Changes:
+ - Mesa now packaged in three parts: Library, Demos and GLUT
+ Bug fixes:
+ - GLX_X_RENDERABLE token wasn't accepted by glXChooseFBConfig
+ - Some files were present multiple times in the 6.3.2 tarballs
+ - r200_vtxtmp_x86.S file was missing from 6.3.2 tarball (bug 4207)
+ - glxgears_fbconfig demo didn't work (bug 4237)
+ - fixed bug when bilinear sampling 2d textures with borders
+ - glXCreatePbuffer() could segfault instead of returning 0 (bug 4235)
+ - fixed undefined frexp and rand in X.org libGLcore.a (bug 4242)
+ - fixed a few problems with proxy color tables (bug 4270)
+ - fixed precision problem in Z clearing (bug 4395)
+ - glBitmap, glDraw/CopyPixels mistakenly generated selection hits
+ - fixed potential segfault caused by reading pixels outside
+ of renderbuffer bounds
+ - glGetTexLevelParameter didn't accept GL_TEXTURE_DEPTH_SIZE_ARB
+ - fixed memory corruption bug involving software alpha buffers
+ - glReadPixels clipped by window bounds was sometimes broken
+ - glDraw/CopyPixels of stencil data ignored the stencil write mask
+ - glReadPixels from a texture bound to a framebuffer object didn't work
+ - glIsRender/FramebufferEXT weren't totally correct
+ - fixed a number of point size attenuation/fade bugs
+ - fixed glFogCoord bug 4729
+ - GLX encoding for transpose matrix functions was broken
+ - fixed broken fragment program KIL and SWZ instructions
+</pre>
+<p>
+The MD5 checksums are:
+</p>
+<pre>
+1cce0c1eb4fd15e9dfe837a1ce0c9812 MesaLib-6.4.tar.gz
+85a84e47a3f718f752f306b9e0954ef6 MesaLib-6.4.tar.bz2
+b976fea4f3ee06354c53f91b6e3f2ffc MesaLib-6.4.zip
+d8734f2c69bcf7ef9f5ae454a85743ba MesaDemos-6.4.tar.gz
+1a8c4d4fc699233f5fdb902b8753099e MesaDemos-6.4.tar.bz2
+607ab7c7a7de0cc5febbdde2bfa03098 MesaDemos-6.4.zip
+3260156f66174322a092be0767962d34 MesaGLUT-6.4.tar.gz
+0465d053f83775f44a12dec4050dfd78 MesaGLUT-6.4.tar.bz2
+02abfcdcdf72ba938ae00f6e3b70fbe0 MesaGLUT-6.4.zip
+</pre>
+
+
+<h2>August 19, 2005</h2>
+<p>
+Mesa 6.3.2 has been released.
+Note: there was no public release of version 6.3.1.
+</p>
+<pre>
+ New:
+ - The distribution now includes the DRI drivers and GLX code
+ Changes:
+ - Made the DRI "new" driver interface standard, remove old code
+ Bug fixes:
+ - GL_ARB_vertex/fragment_shader were mistakenly listed in the
+ extensions string
+ - negative relative addressing in vertex programs was broken
+ - update/fix SPARC assembly code for vertex transformation
+ - fixed memory leak when freeing GLX drawables/renderbuffers
+ - fixed display list memory leak
+ - the GL_PIXEL_MAP_I_TO_I table is now floating point, not integer
+ - wglGetProcAddress() didn't handle wgl-functions
+ - fixed glxext.h cross-compile issue (Colin Harrison)
+ - assorted DRI driver fixes
+</pre>
+<p>
+The MD5 checksums are:
+</p>
+<pre>
+98192e45ed8d69113688f89f90869346 MesaLib-6.3.2.tar.gz
+0df27701df0924d17ddf41185efa8ce1 MesaLib-6.3.2.tar.bz2
+ccb2423aab77fc7e81ce628734586140 MesaLib-6.3.2.zip
+9d0fca0a7d051c34a0b485423fb3e85d MesaDemos-6.3.2.tar.gz
+96708868450c188205e42229b5d813c4 MesaDemos-6.3.2.tar.bz2
+c5102501e609aa8996d832fafacb8ab9 MesaDemos-6.3.2.zip
+</pre>
+
+
+<h2>July 20, 2005</h2>
+<p>
+Mesa 6.3 has been released.
+This is a development release with new features, changes and bug fixes.
+</p>
+<pre>
+ New:
+ - GL_EXT_framebuffer_object extension
+ - GL_ARB_draw_buffers extension
+ - GL_ARB_pixel_buffer_object extension
+ - GL_OES_read_format extension (Ian Romanick)
+ - DirectFB driver (Claudio Ciccani)
+ - x86_64 vertex transformation code (Mikko T.)
+ Changes:
+ - added -stereo option for glxgears demo (Jacek Rosik)
+ - updated the PBuffer demo code in xdemos/ directory
+ - glDeleteTextures/Programs/Buffers() now makes the object ID
+ available for immediate re-use
+ - assorted 64-bit clean-ups fixes (x86_64 and Win64)
+ - lots of internal changes for GL_EXT_framebuffer_object
+ Bug fixes:
+ - some functions didn't support PBO functionality
+ - glGetTexImage didn't convert color index images to RGBA as required
+ - fragment program texcoords were sometimes wrong for points and lines
+ - fixed problem with negative dot product in arbfplight, fplight demos
+ - fixed bug in perspective correction of antialiased, textured lines
+ - querying GL_POST_CONVOLUTION_ALPHA_BIAS_EXT returned wrong value
+ - fixed a couple per-pixel fog bugs (Soju Matsumoto)
+ - glGetBooleanv(GL_FRAGMENT_PROGRAM_BINDING_NV) was broken
+ - fixed float parsing bug in ARB frag/vert programs (bug 2520)
+ - XMesaGetDepthBuffer() returned incorrect value for bytesPerValue
+ - GL_COLOR_MATERIAL with glColor3 didn't properly set diffuse alpha
+ - glXChooseFBConfig() crashed if attribList pointer was NULL
+ - program state.light[n].spot.direction.w was wrong value (bug 3083)
+ - fragment program fog option required glEnable(GL_FOG) - wrong.
+ - glColorTable() could produce a Mesa implementation error (bug 3135)
+ - RasterPos could get corrupted by color index rendering path
+ - Removed bad XTranslateCoordinates call when rendering to Pixmaps
+ - glPopAttrib() didn't properly restore GL_TEXTURE_GEN enable state
+ - fixed a few Darwin compilation problems
+</pre>
+<p>
+The MD5 checksums are:
+</p>
+<pre>
+0236f552d37514776945d5a013e5bb7b MesaLib-6.3.tar.gz
+60e1a8f78c4a8c7750a1e95753190986 MesaLib-6.3.tar.bz2
+ca7c950fbace68c70caa822322db7223 MesaLib-6.3.zip
+25ea801645b376c014051804fe4974b2 MesaDemos-6.3.tar.gz
+9248e74872ea88c57ec25c900c295057 MesaDemos-6.3.tar.bz2
+8537dfa734ef258dcc7272097558d434 MesaDemos-6.3.zip
+</pre>
+
+
+<h2>December 9, 2004</h2>
+<p>
+Mesa 6.2.1 has been released.
+This is a stable release which just fixes bugs since the 6.2 release.
+</p>
+<pre>
+ Bug fixes:
+ - don't apply regular fog or color sum when using a fragment program
+ - glProgramEnvParameter4fARB always generated an error on
+ GL_FRAGMENT_PROGRAM_ARB (fdo bug 1645)
+ - glVertexAttrib3svNV and glVertexAttrib3svARB were broken
+ - fixed width/height mix-up in glSeparableFilter2D()
+ - fixed regression in glCopyPixels + convolution
+ - glReadPixels from a clipped front color buffer didn't always work
+ - glTexImage didn't accept GL_RED/GREEN/BLUE as the format
+ - Attempting queries/accesses of VBO 0 weren't detected as errors
+ - paletted textures failed if the palette had fewer than 256 entries
+ Changes:
+ - fixed a bunch of compiler warnings found with gcc 3.4
+ - bug reports should to go bugzilla.freedesktop.org
+</pre>
+<p>
+The MD5 checksums are:
+</p>
+<pre>
+80008a92f6e055d3bfdde2cf331ec3fa MesaLib-6.2.1.tar.gz
+f43228cd2bf70f583ef3275c1c545421 MesaLib-6.2.1.tar.bz2
+dec26cfd40116ad021020fea2d94f652 MesaLib-6.2.1.zip
+2c7af3c986a7571c8713c8bfee7e49e3 MesaDemos-6.2.1.tar.gz
+3cac74667b50bcbd4f67f594fb4224a2 MesaDemos-6.2.1.tar.bz2
+75b3edd12eb2b370caf05f29b99e508a MesaDemos-6.2.1.zip
+</pre>
+
+
+<h2>October 2, 2004</h2>
+<p>
+Mesa 6.2 has been released.
+This is a stable release which just fixes bugs since the 6.1 release.
+</p>
+<pre>
+ New:
+ - enabled GL_ARB_texture_rectangle (same as GL_NV_texture_rectangle)
+ - updated Doxygen support (Jose Fonseca)
+ Changes:
+ - some GGI driver updates (Christoph Egger, bug 1025977)
+ Bug fixes:
+ - Omit GL_ARB_texture_non_power_of_two from list of OpenGL 1.5 features
+ - fixed a few compilation issues on IRIX
+ - fixed a matrix classification bug (reported by Wes Bethel)
+ - we weren't reseting the vertex/fragment program error state
+ before parsing (Dave Reveman)
+ - adjust texcoords for sampling texture rectangles (Dave Reveman)
+ - glGet*(GL_MAX_VERTEX_ATTRIBS_ARB) wasn't implemented
+ - repeated calls to glDeleteTexture(t) could lead to a crash
+ - fixed potential ref count bugs in VBOs and vertex/fragment programs
+ - spriteblast demo didn't handle window size changes correctly
+ - glTexSubImage didn't handle pixels=NULL correctly for PBOs
+ - fixed color index mode glDrawPixels bug (Karl Schultz)
+</pre>
+<p>
+The MD5 checksums are:
+</p>
+<pre>
+9e8f34b059272dbb8e1f2c968b33bbf0 MesaLib-6.2.tar.gz
+3d6a6362390b6a37d3cb2e615f3ac7db MesaLib-6.2.tar.bz2
+6cfd7895d28e695c0dbbed9469564091 MesaLib-6.2.zip
+3e06e33b0809f09855cb60883b8bdfef MesaDemos-6.2.tar.gz
+9d160009c3dfdb35fe7e4088c9ba8f85 MesaDemos-6.2.tar.bz2
+856f7ec947122eb3c8985ebc2f654dcd MesaDemos-6.2.zip
+</pre>
+
+
+<h2>August 18, 2004</h2>
+<p>
+Mesa 6.1 has been released.
+This is a new development release (version 6.2 will be a stabilization
+release).
+</p>
+<pre>
+ New:
+ - Revamped Makefile system
+ - glXUseRotatedXFont() utility (see xdemos/xuserotfont.c)
+ - internal driver interface changes related to texture object
+ allocation, vertex/fragment programs, BlendEquationSeparate, etc.
+ - option to walk triangle edges with double-precision floats
+ (Justin Novosad of Discreet) (see config.h file)
+ - support for AUX buffers in software GLX driver
+ - updated glext.h to version 24 and glxext.h to version 6
+ - new MESA_GLX_FORCE_ALPHA and MESA_GLX_DEPTH_BITS env vars
+ - updated BeOS support (Philippe Houdoin)
+ Changes:
+ - fragment fog interpolation is perspective corrected now
+ - new glTexImage code, much cleaner, may be a bit faster
+ Bug fixes:
+ - glArrayElement in display lists didn't handle generic vertex attribs
+ - glFogCoord didn't always work properly
+ - ARB_fragment_program fog options didn't work
+ - frag prog TEX instruction no longer incorrectly divides s,t,r by q
+ - ARB frag prog TEX and TEXP instructions now use LOD=0
+ - glTexEnviv in display lists didn't work
+ - glRasterPos didn't do texgen or apply texture matrix
+ - GL_DOUBLE-valued vertex arrays were broken in some cases
+ - fixed texture rectangle edge/border sampling bugs
+ - sampling an incomplete texture in a fragment program would segfault
+ - glTexImage was missing a few error checks
+ - fixed some minor glGetTexParameter glitches
+ - GL_INTENSITY was mistakenly accepted as a <format> to glTexImage
+ - fragment program writes to RC/HC register were broken
+ - fixed a few glitches in GL_HP_occlusion_test extension
+ - glBeginQueryARB and glEndQueryARB didn't work inside display lists
+ - vertex program state references were broken
+ - fixed triangle color interpolation bug on AIX (Shane Blackett)
+ - fixed a number of minor memory leaks (bug #1002030)
+</pre>
+The MD5 checksums are:
+</p>
+<pre>
+c9284d295ebcd2e0486cc3cd54e5863c MesaLib-6.1.tar.gz
+5de1f53ec0709f60fc68fdfed57351f3 MesaLib-6.1.tar.bz2
+483e77cac4789a5d36c42f3c0136d6d8 MesaLib-6.1.zip
+8c46cfa6f9732acc6f6c25724aad0246 MesaDemos-6.1.tar.gz
+89bfe0f6c69b39fd0ebd9fff481a4e9b MesaDemos-6.1.tar.bz2
+161268531fcc6f0c5a056430ee97e0c1 MesaDemos-6.1.zip
+</pre>
+
+
+
+<h2>April 2, 2004</h2>
+
+<p>
+Mesa 6.0.1 has been released.
+This release basically just fixes bugs since the 6.0. release.
+</p>
+<pre>
+ New:
+ - upgraded glext.h to version 22
+ - new build targets (Dan Schikore)
+ - new linux-x86-opteron build target (Heath Feather)
+ Bug fixes:
+ - glBindProgramARB didn't update all necessary state
+ - fixed build problems on OpenBSD
+ - omit CVS directories from tarballs
+ - glGetTexImage(GL_COLOR_INDEX) was broken
+ - fixed an infinite loop in t&l module
+ - silenced some valgrind warnings about using unitialized memory
+ - fixed some compilation/link glitches on IRIX (Mike Stephens)
+ - glBindProgram wasn't getting compiled into display lists
+ - GLX_FBCONFIG_ID wasn't recognized in glXChooseFBConfig() (bug 888079)
+ - two-sided lighting and vertex program didn't work (bug 887330)
+ - stores to program parameter registers in vertex state programs
+ didn't work.
+ - fixed glOrtho bug found with gcc 3.2.2 (RH9)
+ - glXCreateWindow() wasn't fully implemented (bug 890894)
+ - generic vertex attribute arrays didn't work in display lists
+ - vertex buffer objects' default usage and access fields were wrong
+ - glDrawArrays with start!=0 was broken
+ - fragment program PK2H, UP2H, UP4B and UP4UB instructions were broken
+ - linux-osmesa16-static config didn't work
+ - fixed a few color index rendering problems (bug 910687)
+ - glInterleavedArrays didn't respect GL_CLIENT_ACTIVE_TEXTURE
+ - OSMesa RGB and BGR modes were broken
+ - glProgramStringARB mistakenly required a null-terminated string
+ - fragment program XPD instruction was incorrect
+ - glGetMaterial() didn't work reliably
+</pre>
+The MD5 checksums are:
+</p>
+<pre>
+011be0e79666c7a6eb9693fbf9348653 MesaLib-6.0.1.tar.gz
+b7f14088c5c2f14490d2739a91102112 MesaLib-6.0.1.tar.bz2
+bf0510cf0a2b87d64cdd317eca3f1db1 MesaLib-6.0.1.zip
+b7b648599e0aaee1c4ffc554a2a9139e MesaDemos-6.0.1.tar.gz
+dd6aadfd9ca8e1cfa90c6ee492bc6f43 MesaDemos-6.0.1.tar.bz2
+eff71d59c211825e949199852f5a2316 MesaDemos-6.0.1.zip
+</pre>
+
+
+
+<h2>January 16, 2004</h2>
+
+<p>
+Mesa 6.0 has been released. This is a stabilization of the 5.1 release
+and primarily just incorporates bug fixes.
+</p>
+<pre>
+ New:
+ - full OpenGL 1.5 support
+ - updated GL/glext.h file to version 21
+ Changes:
+ - changed max framebuffer size to 4Kx4K (MAX_WIDTH/HEIGHT in config.h)
+ Bug fixes:
+ - fixed bug in UNCLAMPED_FLOAT_TO_UBYTE macro; solves a color
+ clamping issue
+ - updated suno5-gcc configs
+ - glColor3 functions sometimes resulted in undefined alpha values
+ - fixed FP divide by zero error seen on VMS with xlockmore, others
+ - fixed vertex/fragment program debug problem (bug 873011)
+ - building on AIX with gcc works now
+ - glDeleteProgramsARB failed for ARB fragment programs (bug 876160)
+ - glDrawRangeElements tried to modify potentially read-only storage
+ - updated files for building on Windows
+</pre>
+
+
+
+<h2>December 28, 2003</h2>
+
+<p>
+The Mesa CVS server has been moved to <a href="http://www.freedesktop.org"
+target="_parent">
+freedesktop.org</a> because of problems with SourceForge's anonymous
+CVS service.
+</p>
+
+<p>Please see the <a href="cvs_access.html">CVS access page</a> for details.
+</p>
+
+
+<h2>December 17, 2003</h2>
+
+<p>
+Mesa 5.1 has been released. This is a new development release.
+Mesa 6.0 will be the next stable release and will support all
+OpenGL 1.5 features.
+</p>
+<pre>
+ New features:
+ - reorganized directory tree
+ - GL_ARB_vertex/fragment_program extensions (Michal Krol & Karl Rasche)
+ - GL_ATI_texture_env_combine3 extension (Ian Romanick)
+ - GL_SGI_texture_color_table extension (Eric Plante)
+ - GL_NV_fragment_program extension
+ - GL_NV_light_max_exponent extension
+ - GL_EXT_texture_rectangle (identical to GL_NV_texture_rectangle)
+ - GL_ARB_occlusion_query extension
+ - GL_ARB_point_sprite extension
+ - GL_ARB_texture_non_power_of_two extension
+ - GL_IBM_multimode_draw_arrays extension
+ - GL_EXT_texture_mirror_clamp extension (Ian Romanick)
+ - GL_ARB_vertex_buffer_object extension
+ - new X86 feature detection code (Petr Sebor)
+ - less memory used for display lists and vertex buffers
+ - demo of per-pixel lighting with a fragment program (demos/fplight.c)
+ - new version (18) of glext.h header
+ - new spriteblast.c demo of GL_ARB_point_sprite
+ - faster glDrawPixels in X11 driver in some cases (see RELNOTES-5.1)
+ - faster glCopyPixels in X11 driver in some cases (see RELNOTES-5.1)
+ Bug fixes:
+ - really enable OpenGL 1.4 features in DOS driver.
+ - fixed issues in glDrawPixels and glCopyPixels for very wide images
+ - glPixelMapf/ui/usv()'s size parameter is GLsizei, not GLint
+ - fixed some texgen bugs reported by Daniel Borca
+ - fixed wglMakeCurrent(NULL, NULL) bug (#835861)
+ - fixed glTexSubImage3D z-offset bug (Cedric Gautier)
+ - fixed RGBA blend enable bug (Ville Syrjala)
+ - glAccum is supposed to be a no-op in selection/feedback mode
+ - fixed texgen bug #597589 (John Popplewell)
+ Changes:
+ - dropped API trace feature (src/Trace/)
+ - documentation overhaul. merged with website content. more html.
+ - glxgears.c demo updated to use GLX swap rate extensions
+ - glTexImage1/2/3D now allows width/height/depth = 0
+ - disable SPARC asm code on Linux (bug 852204)
+</pre>
+
+The MD5 checksums are:
+</p>
+<pre>
+78f452f6c55478471a744f07147612b5 MesaLib-5.1.tar.gz
+67b3b8d3f7f4c8c44904551b851d01af MesaLib-5.1.tar.bz2
+6dd19ffa750ec7f634e370a987505c9d MesaLib-5.1.zip
+e0214d4ebb22409dfa9262f2b52fd828 MesaDemos-5.1.tar.gz
+066c9aff4fd924405de1ae9bad5ec9a7 MesaDemos-5.1.tar.bz2
+d2b5ba32b53e0ad0576c637a4cc1fb41 MesaDemos-5.1.zip
+</pre>
+
+
+<H2>November 12, 2003</H2>
+
+<p>
+New Mesa 5.0.2 tarballs have been uploaded to SourceForge which fix a
+number of automake/libtool problems.
+</p>
+<p>
+The new MD5 checksums are:
+</p>
+<pre>
+a9dcf3ff9ad1b7d6ce73a0df7cff8b5b MesaLib-5.0.2.tar.gz
+7b4bf9261657c2fca03796d4955e6f50 MesaLib-5.0.2.tar.bz2
+79c141bddcbad557647535d02194f346 MesaLib-5.0.2.zip
+952d9dc823dd818981d1a648d7b2668a MesaDemos-5.0.2.tar.gz
+b81fafff90995025d2f25ea02b786642 MesaDemos-5.0.2.tar.bz2
+a21be975589e8a2d1871b6bb7874fffa MesaDemos-5.0.2.zip
+</pre>
+
+
+
+<h2>September 5, 2003</h2>
+
+<p>
+Mesa 5.0.2 has been released. This is a stable, bug-fix release.
+</p>
+<pre>
+ Bug fixes:
+ - fixed texgen problem causing texcoord's Q to be zero (stex3d)
+ - default GL_TEXTURE_COMPARE_MODE_ARB was wrong
+ - GL_CURRENT_MATRIX_NV query was wrong
+ - GL_CURRENT_MATRIX_STACK_DEPTH_NV query was off by one
+ - GL_LIST_MODE query wasn't correct
+ - GL_FOG_COORDINATE_SOURCE_EXT query wasn't supported
+ - GL_SECONDARY_COLOR_ARRAY_SIZE_EXT query returned wrong value
+ - blended, wide lines didn't always work correctly (bug 711595)
+ - glVertexAttrib4svNV w component was always 1
+ - fixed bug in GL_IBM_rasterpos_clip (missing return)
+ - GL_DEPTH_TEXTURE_MODE = GL_ALPHA didn't work correctly
+ - a few Solaris compilation fixes
+ - fixed glClear() problem for DRI drivers (non-existant stencil, etc)
+ - fixed int/REAL mixup in GLU NURBS curve evaluator (Eric Cazeaux)
+ - fixed delete [] bug in SI GLU (bug 721765) (Diego Santa Cruz)
+ - glFog() didn't clamp fog colors
+ - fixed bad float/int conversion for GL_TEXTURE_PRIORITY in the
+ gl[Get]TexParameteri[v] functions
+ - fixed invalid memory references in glTexGen functions (bug 781602)
+ - integer-valued color arrays weren't handled correctly
+ - glDrawPixels(GL_DEPTH_COMPONENT) with glPixelZoom didn't work
+ - GL_EXT_texture_lod_bias is part of 1.4, overlooked in 5.0.1
+ Changes:
+ - build GLUT with -fexceptions so C++ apps propogate exceptions
+</pre>
+
+
+
+<h2>June 2003</h2>
+
+<p>
+Mesa's directory tree has been overhauled.
+Things are better organized now with some thought toward future needs.
+</p>
+<p>
+In CVS, the latest Mesa 5.1 development code is now rooted under the
+<b>Mesa-newtree/</b> directory. The old top-level <b>Mesa/</b> directory
+holds the Mesa 5.0.x code which will be abandoned at some point.
+</p>
+
+
+
+<h2>March 30, 2003</h2>
+
+<p>
+Mesa 5.0.1 has been released. This is a stable, bug-fix release.
+</p>
+<pre>
+ New:
+ - DOS driver updates from Daniel Borca
+ - updated GL/gl_mangle.h file (Bill Hoffman)
+ Bug fixes:
+ - auto mipmap generation for cube maps was broken (bug 641363)
+ - writing/clearing software alpha channels was unreliable
+ - minor compilation fixes for OS/2 (Evgeny Kotsuba)
+ - fixed some bad assertions found with shadowtex demo
+ - fixed error checking bug in glCopyTexSubImage2D (bug 659020)
+ - glRotate(angle, -x, 0, 0) was incorrect (bug 659677)
+ - fixed potential segfault in texture object validation (bug 659012)
+ - fixed some bogus code in _mesa_test_os_sse_exception_support (Linus)
+ - fix fog stride bug in tnl code for h/w drivers (Michel Danzer)
+ - fixed glActiveTexture / glMatrixMode(GL_TEXTURE) bug (#669080)
+ - glGet(GL_CURRENT_SECONDARY_COLOR) should return 4 values, not 3
+ - fixed compilation problem on Solaris7/x86 (bug 536406)
+ - fixed prefetch bug in 3DNow! code (Felix Kuhling)
+ - fixed NeXT build problem (FABSF macro)
+ - glDrawPixels Z values when glPixelZoom!=1 were invalid (bug 687811)
+ - zoomed glDraw/CopyPixels with clipping sometimes failed (bug 689964)
+ - AA line and triangle Z values are now rounded, not truncated
+ - fixed color interpolation bug when GLchan==GLfloat (bug 694461)
+ - glArePrograms/TexturesResident() wasn't 100% correct (Jose Fonseca)
+ - fixed a minor GL_COLOR_MATERIAL bug
+ - NV vertex program EXP instruction was broken
+ - glColorMask misbehaved with X window / pixmap rendering
+ - fix autoconf/libtool GLU C++ linker problem on Linux (a total hack)
+ - attempt to fix GGI compilation problem when MesaDemos not present
+ - NV vertex program ARL-relative fetches didn't work
+ Changes:
+ - use glPolygonOffset in gloss demo to avoid z-fighting artifacts
+ - updated winpos and pointblast demos to use ARB extensions
+ - disable SPARC normal transformation code (bug 673938)
+ - GLU fixes for OS/2 (Evgeny Kotsuba)
+</pre>
+<p>
+MD5 checksums follow:
+</p>
+<pre>
+b80f8b5d53a3e9f19b9fde5af0c542f0 MesaLib-5.0.1.tar.gz
+513b4bbd7d38951f05027179063d876b MesaLib-5.0.1.tar.bz2
+eebd395678f4520d33b267e5d5c22651 MesaLib-5.0.1.zip
+49d7feaec6dc1d2091d7c3cc72a9b320 MesaDemos-5.0.1.tar.gz
+37190374a98c3c892f0698be9ca3acf0 MesaDemos-5.0.1.tar.bz2
+becd8bf17f5791361b4a54ba2a78e5c9 MesaDemos-5.0.1.zip
+</pre>
+
+
+
+<h2>March 7, 2003</h2>
+<p>
+Website and documentation overhaul.
+</p>
+<p>
+The website content and Mesa documentation (from the doc/ directory) have
+been merged together.
+All the documentation files have been entered into the CVS repository.
+Many of the old plain-text files have been converted to html and modernized.
+</p>
+
+
+<h2>November 13, 2002</h2>
+<p>Mesa 5.0 has been released. This is a stable release which
+implements the OpenGL 1.4 specification.
+</p><pre>New:
+ - OpenGL 1.4 support (glGetString(GL_VERSION) returns "1.4")
+ - removed some overlooked debugging code
+ - glxinfo updated to support GLX_ARB_multisample
+ - GLUT now support GLX_ARB_multisample
+ - updated DOS driver (Daniel Borca)
+Bug fixes:
+ - GL_POINT and GL_LINE-mode polygons didn't obey cull state
+ - fixed potential bug in _mesa_align_malloc/calloc()
+ - fixed missing triangle bug when running vertex programs
+ - fixed a few HPUX compilation problems
+ - FX (Glide) driver didn't compile
+ - setting GL_TEXTURE_BORDER_COLOR with glTexParameteriv() didn't work
+ - a few EXT functions, like glGenTexturesEXT, were no-ops
+ - a few OpenGL 1.4 functions like glFogCoord*, glBlendFuncSeparate,
+ glMultiDrawArrays and glMultiDrawElements were missing
+ - glGet*(GL_ACTIVE_STENCIL_FACE_EXT) was broken
+ - Pentium 4 Mobile was mistakenly identified as having 3DNow!
+ - fixed one-bit error in point/line fragment Z calculation
+ - fixed potential segfault in fakeglx code
+ - fixed color overflow problem in DOT3 texture env mode
+</pre>
+
+
+<h2>October 29, 2002</h2>
+<p>Mesa 4.1 has been released. This is a new development release.
+For a stable release, get 4.0.4.
+</p><pre>New:
+ - GL_NV_vertex_program extension
+ - GL_NV_vertex_program1_1 extension
+ - GL_ARB_window_pos extension
+ - GL_ARB_depth_texture extension
+ - GL_ARB_shadow extension
+ - GL_ARB_shadow_ambient extension
+ - GL_EXT_shadow_funcs extension
+ - GL_ARB_point_parameters extension
+ - GL_ARB_texture_env_crossbar
+ - GL_NV_point_sprite extension
+ - GL_NV_texture_rectangle extension
+ - GL_EXT_multi_draw_arrays extension
+ - GL_EXT_stencil_two_side extension
+ - GLX_SGIX_fbconfig and GLX_SGIX_pbuffer extensions
+ - GL_ATI_texture_mirror_once extension (Ian Romanick)
+ - massive overhaul/simplification of software rasterizer module,
+ many contributions from Klaus Niederkrueger
+ - faster software texturing in some cases (i.e. trilinear filtering)
+ - new OSMesaGetProcAddress() function
+ - more blend modes implemented with MMX code (Jose Fonseca)
+ - added glutGetProcAddress() to GLUT
+ - added GLUT_FPS env var to compute frames/second in glutSwapBuffers()
+ - pbinfo and pbdemo PBuffer programs
+ - glxinfo -v prints transprent pixel info (Gerd Sussner)
+Bug fixes:
+ - better mipmap LOD computation (prevents excessive blurriness)
+ - OSMesaMakeCurrent() didn't recognize buffer size changes
+ - assorted conformance fixes for 16-bit/channel rendering
+ - texcombine alpha subtraction mode was broken
+ - fixed some blend problems when GLchan==GLfloat (Gerk Huisma)
+ - clamp colors to [0,1] in OSMesa if GLchan==GLfloat (Gerk Huisma)
+ - fixed divide by zero error in NURBS tessellator (Jon Perry)
+ - fixed GL_LINEAR fog bug by adding clamping
+ - fixed FP exceptions found using Alpha CPU
+ - 3dfx/glide driver render-to-window feature was broken
+ - added missing GLX_TRANSPARENT_RGB token to glx.h
+ - fixed error checking related to paletted textures
+ - fixed reference count error in glDeleteTextures (Randy Fayan)
+Changes:
+ - New spec file and Python code to generate some GL dispatch files
+ - Glide driver defaults to "no" with autoconf/automake
+ - floating point color channels now clamped to [0,inf)
+ - updated demos/stex3d with new options
+</pre>
+
+
+<h2>October 4, 2002</h2>
+<p>
+The <a href="http://mesa3d.sourceforge.net/docs/MesaFAQ.html">Mesa FAQ</a> has been rewritten.
+</p>
+
+<h2>October 3, 2002</h2>
+<p>Mesa 4.0.4 has been released. This is a stable bug-fix release.
+</p><pre> New:
+ - GL_NV_texture_rectangle extension
+ - updated glext.h header (version 17)
+ - updated DOS driver (Daniel Borca)
+ - updated BeOS R5 driver (Philippe Houdoin)
+ - added GL_IBM_texture_mirror_repeat
+ - glxinfo now takes -l option to print interesting OpenGL limits info
+ - GL_MESA_ycbcr_texture extension
+ - GL_APPLE_client_storage extension (for some DRI drivers only)
+ - GL_MESA_pack_invert extension
+ Bug fixes:
+ - fixed GL_LINEAR fog bug by adding clamping
+ - fixed FP exceptions found using Alpha CPU
+ - 3dfx MESA_GLX_FX=window (render to window) didn't work
+ - fixed memory leak in wglCreateContest (Karl Schultz)
+ - define GLAPIENTRY and GLAPI if undefined in glu.h
+ - wglGetProcAddress didn't handle all API functions
+ - when testing for OpenGL 1.2 vs 1.3, check for GL_ARB_texture_cube_map
+ - removed GL_MAX_CONVOLUTION_WIDTH/HEIGHT from glGetInteger/Float/etc()
+ - error checking in compressed tex image functions had some glitches
+ - fixed AIX compile problem in src/config.c
+ - glGetTexImage was using pixel unpacking instead of packing params
+ - auto-mipmap generation for cube maps was incorrect
+ Changes:
+ - max texture units reduced to six to accomodate texture rectangles
+ - removed unfinished GL_MESA_sprite_point extension code
+</pre>
+
+<h2>June 25, 2002</h2>
+<p>Mesa 4.0.3 has been released. This is a stable bug-fix release.
+</p><pre> New:
+ - updated GL/glext.h file (version 15)
+ - corrected MMX blend code (Jose Fonseca)
+ - support for software-based alpha planes in Windows driver
+ - updated GGI driver (Filip Spacek)
+ Bug fixes:
+ - glext.h had wrong values for GL_DOT3_RGB[A]_EXT tokens
+ - OSMesaMakeCurrent() didn't recognize buffer size changes
+ - assorted conformance fixes for 16-bit/channel rendering
+ - texcombine alpha subtraction mode was broken
+ - fixed lighting bug with non-uniform scaling and display lists
+ - fixed bug when deleting shared display lists
+ - disabled SPARC cliptest assembly code (Mesa bug 544665)
+ - fixed a couple Solaris compilation/link problems
+ - blending clipped glDrawPixels didn't always work
+ - glGetTexImage() didn't accept packed pixel types
+ - glPixelMapu[is]v() could explode given too large of pixelmap
+ - glGetTexParameter[if]v() didn't accept GL_TEXTURE_MAX_ANISOTROPY_EXT
+ - glXCopyContext() could lead to segfaults
+ - glCullFace(GL_FRONT_AND_BACK) didn't work (bug 572665)
+ Changes:
+ - lots of C++ (g++) code clean-ups
+ - lots of T&amp;L updates for the Radeon DRI driver
+ Known bugs:
+ - mipmap LOD computation (fixed for Mesa 4.1)
+</pre>
+
+<h2>April 2, 2002</h2>
+<p>Mesa 4.0.2 has been released. This is a stable bug-fix release.
+</p><pre> New:
+ - New DOS (DJGPP) driver written by Daniel Borca
+ - New driver interface functions for TCL drivers (such as Radeon DRI)
+ - GL_RENDERER string returns "Mesa Offscreen16" or "Mesa Offscreen32"
+ if using deep color channels
+ - latest GL/glext.h and GL/glxext.h headers from SGI
+ Bug fixes:
+ - GL_BLEND with non-black texture env color wasn't always correct
+ - GL_REPLACE with GL_RGB texture format wasn't always correct (alpha)
+ - glTexEnviv( pname != GL_TEXTURE_ENV_COLOR ) was broken
+ - glReadPixels was sometimes mistakenly clipped by the scissor box
+ - glDraw/ReadPixels didn't catch all the errors that they should have
+ - Fixed 24bpp rendering problem in Windows driver (Karl Schultz)
+ - 16-bit GLchan mode fixes (m_trans_tmp.h, s_triangle.c)
+ - Fixed 1-bit float-&gt;int conversion bug in glDrawPixels(GL_DEPTH_COMP)
+ - glColorMask as sometimes effecting glXSwapBuffers()
+ - fixed a potential bug in XMesaGarbageCollect()
+ - N threads rendering into one window didn't work reliably
+ - glCopyPixels didn't work for deep color channels
+ - improved 8 -&gt; 16bit/channel texture image conversion (Gerk Huisma)
+ - glPopAttrib() didn't correctly restore user clip planes
+ - user clip planes failed for some perspective projections (Chromium)
+</pre>
+
+<h2>December 17, 2001</h2>
+<p>Mesa 4.0.1 has been released. This is a stable bug-fix release.
+</p><pre> New:
+ - better sub-pixel sample positions for AA triangles (Ray Tice)
+ - slightly faster blending for (GL_ZERO, GL_ONE) and (GL_ONE, GL_ZERO)
+ Bug fixes:
+ - added missing break statements in glGet*() for multisample cases
+ - fixed uninitialized hash table mutex bug (display lists / texobjs)
+ - fixed bad teximage error check conditional (bug 476846)
+ - fixed demos readtex.c compilation problem on Windows (Karl Schultz)
+ - added missing glGet() query for GL_MAX_TEXTURE_LOD_BIAS_EXT
+ - silence some compiler warnings (gcc 2.96)
+ - enable the #define GL_VERSION_1_3 in GL/gl.h
+ - added GL 1.3 and GLX 1.4 entries to gl_mangle.h and glx_mangle.h
+ - fixed glu.h typedef problem found with MSDev 6.0
+ - build libGL.so with -Bsymbolic (fixes bug found with Chromium)
+ - added missing 'const' to glXGetContextIDEXT() in glxext.h
+ - fixed a few glXGetProcAddress() errors (texture compression, etc)
+ - fixed start index bug in compiled vertex arrays (Keith)
+ - fixed compilation problems in src/SPARC/glapi_sparc.S
+ - fixed triangle strip "parity" bug found in VTK medical1 demo (Keith)
+ - use glXGetProcAddressARB in GLUT to avoid extension linking problems
+ - provoking vertex of flat-shaded, color-index triangles was wrong
+ - fixed a few display list bugs (GLUT walker, molecule, etc) (Keith)
+ - glTexParameter didn't flush the vertex buffer (Ray Tice)
+ - feedback attributes for glDraw/CopyPixels and glBitmap were wrong
+ - fixed bug in normal length caching (ParaView lighting bug)
+</pre>
+
+<h2>October 22, 2001</h2>
+<p>Mesa 4.0 has been released. This is a stable release.
+</p><pre> New:
+ - Mesa 4.0 implements the OpenGL 1.3 specification
+ - GL_IBM_rasterpos_clip extension
+ - GL_EXT_texture_edge_clamp extension (aka GL_SGIS_texture_edge_clamp)
+ - GL_ARB_texture_mirrored_repeat extension
+ - WindML UGL driver (Stephane Raimbault)
+ - added OSMESA_MAX_WIDTH/HEIGHT queries
+ - attempted compiliation fixes for Solaris 5, 7 and 8
+ - updated glext.h and glxext.h files
+ - updated Windows driver (Karl Schultz)
+ Bug fixes:
+ - added some missing GLX 1.3 tokens to include/GL/glx.h
+ - GL_COLOR_MATRIX changes weren't recognized by teximage functions
+ - glCopyPixels with scale and bias was broken
+ - glRasterPos with lighting could segfault
+ - glDeleteTextures could leave a dangling pointer
+ - Proxy textures for cube maps didn't work
+ - fixed a number of 16-bit color channel bugs
+ - fixed a few minor memory leaks
+ - GLX context sharing was broken in 3.5
+ - fixed state-update bugs in glPopClientAttrib()
+ - fixed glDrawRangeElements() bug
+ - fixed a glPush/PopAttrib() bug related to texture binding
+ - flat-shaded, textured lines were broken
+ - fixed a dangling pointer problem in the XMesa code (Chris Burghart)
+ - lighting didn't always produce the correct alpha value
+ - fixed 3DNow! code to not read past end of arrays (Andrew Lewycky)
+</pre>
+
+
+<h2>June 21, 2001</h2>
+<p>Mesa 3.5 has been released. This is a new development release.
+</p><pre> New:
+ - internals of Mesa divided into modular pieces (Keith Whitwell)
+ - 100% OpenGL 1.2 conformance (passes all conformance tests)
+ - new AA line algorithm
+ - GL_EXT_convolution extension
+ - GL_ARB_imaging subset
+ - OSMesaCreateContextExt() function
+ - GL_ARB_texture_env_add extension (same as GL_EXT_texture_env_add)
+ - GL_MAX_TEXTURE_UNITS_ARB now defaults to eight
+ - GL_EXT_fog_coord extension (Keith Whitwell)
+ - GL_EXT_secondary_color extension (Keith Whitwell)
+ - GL_ARB_texture_env_add extension (same as GL_EXT_texture_env_add)
+ - GL_SGIX_depth_texture extension
+ - GL_SGIX_shadow and GL_SGIX_shadow_ambient extensions
+ - demos/shadowtex.c demo of GL_SGIX_depth_texture and GL_SGIX_shadow
+ - GL_ARB_texture_env_combine extension
+ - GL_ARB_texture_env_dot3 extension
+ - GL_ARB_texture_border_clamp (aka GL_SGIS_texture_border_clamp)
+ - OSMesaCreateContextExt() function
+ - libOSMesa.so library, contains the OSMesa driver interface
+ - GL/glxext.h header file for GLX extensions
+ - somewhat faster software texturing, fogging, depth testing
+ - all color-index conformance tests now pass (only 8bpp tested)
+ - SPARC assembly language TCL optimizations (David Miller)
+ - GL_SGIS_generate_mipmap extension
+ Bug Fixes:
+ - fbiRev and tmuRev were unitialized when using Glide3
+ - fixed a few color index mode conformance failures; all pass now
+ - now appling antialiasing coverage to alpha after texturing
+ - colors weren't getting clamped to [0,1] before color table lookup
+ - fixed RISC alignment errors caused by COPY_4UBV macro
+ - drawing wide, flat-shaded lines could cause a segfault
+ - vertices now snapped to 1/16 pixel to fix rendering of tiny triangles
+ Changes:
+ - SGI's Sample Implementation (SI) 1.3 GLU library replaces Mesa GLU
+ - new libOSMesa.so library, contains the OSMesa driver interface
+</pre>
+
+
+<h2>May 17, 2001</h2>
+<p>Mesa 3.4.2 has been released. This is basically just a bug-fix release.
+Here's what's new:</p>
+<pre> Bug fixes:
+ - deleting the currently bound texture could cause bad problems
+ - using fog could result in random vertex alpha values
+ - AA triangle rendering could touch pixels outside right window bound
+ - fixed byteswapping problem in clear_32bit_ximage() function
+ - fixed bugs in wglUseFontBitmapsA(), by Frank Warmerdam
+ - fixed memory leak in glXUseXFont()
+ - fragment sampling in AA triangle function was off by 1/2 pixel
+ - Windows: reading pixels from framebuffer didn't always work
+ - glConvolutionFilter2D could segfault or cause FP exception
+ - fixed segfaults in FX and X drivers when using tex unit 1 but not 0
+ - GL_NAND logicop didn't work right in RGBA mode
+ - fixed a memory corruption bug in vertex buffer reset code
+ - clearing the softwara alpha buffer with scissoring was broken
+ - fixed a few color index mode fog bugs
+ - fixed some bad assertions in color index mode
+ - fixed FX line 'stipple' bug #420091
+ Changes:
+ - optimized writing mono-colored pixel spans to X pixmaps
+ - increased max viewport size to 2048 x 2048
+</pre>
+
+
+<h2>April 29, 2001</h2>
+<p>New Mesa website</p>
+<p>Mark Manning produced the new website.<br>Thanks, Mark!</p>
+
+
+<h2>February 14, 2001</h2>
+<p>Mesa 3.4.1 has been released. Here's what's new:</p>
+<pre> New:
+ - fixed some Linux build problems
+ - fixed some Windows build problems
+ - GL_EXT_texture_env_dot3 extension (Gareth Hughes)
+ Bug fixes:
+ - added RENDER_START/RENDER_FINISH macros for glCopyTexImage in DRI
+ - various state-update code changes needed for DRI bugs
+ - disabled pixel transfer ops in glColorTable commands, not needed
+ - fixed bugs in glCopyConvolutionFilter1D/2D, glGetConvolutionFilter
+ - updated sources and fixed compile problems in widgets-mesa/
+ - GLX_PBUFFER enum value was wrong in glx.h
+ - fixed a glColorMaterial lighting bug
+ - fixed bad args to Read/WriteStencilSpan in h/w stencil clear function
+ - glXCopySubBufferMESA() Y position was off by one
+ - Error checking of glTexSubImage3D() was broken (bug 128775)
+ - glPopAttrib() didn't restore all derived Mesa state correctly
+ - Better glReadPixels accuracy for 16bpp color - fixes lots of OpenGL
+ conformance problems at 16bpp.
+ - clearing depth buffer with scissoring was broken, would segfault
+ - OSMesaGetDepthBuffer() returned bad bytesPerValue value
+ - fixed a line clipping bug (reported by Craig McDaniel)
+ - fixed RGB color over/underflow bug for very tiny triangles
+ Known problems:
+ - NURBS or evaluator surfaces inside display lists don't always work
+</pre>
+<p>
+</p><h2>November 3, 2000</h2>
+<p>Mesa 3.4 has been released. Here's what's new since the 3.3 release:</p>
+<pre> New:
+ - optimized glDrawPixels for glPixelZoom(1,-1)
+ Bug Fixes:
+ - widgets-mesa/src/*.c files were missing from 3.3 distro
+ - include/GL/mesa_wgl.h file was missing from 3.3 distro
+ - fixed some Win32 compile problems
+ - texture object priorities weren't getting initialized to 1.0
+ - glAreTexturesResident return value was wrong when using hardware
+ - glXUseXFont segfaulted when using 3dfx driver (via MESA_GLX_FX)
+ - glReadPixels with GLushort packed types was broken
+ - fixed a few bugs in the GL_EXT_texture_env_combine texture code
+ - glPush/PopAttrib(GL_ENABLE_BIT) mishandled multi-texture enables
+ - fixed some typos/bugs in the VB code
+ - glDrawPixels(GL_COLOR_INDEX) to RGB window didn't work
+ - optimized glDrawPixels paths weren't being used
+ - per-fragment fog calculation didn't work without a Z buffer
+ - improved blending accuracy, fixes Glean blendFunc test failures
+ - glPixelStore(GL_PACK/UNPACK_SKIP_IMAGES) wasn't handled correctly
+ - glXGetProcAddressARB() didn't always return the right address
+ - gluBuild[12]DMipmaps() didn't grok the GL_BGR pixel format
+ - texture matrix changes weren't always detected (GLUT projtex demo)
+ - fixed random color problem in vertex fog code
+ - fixed Glide-related bug that let Quake get a 24-bit Z buffer
+ Changes:
+ - finished internal support for compressed textures for DRI
+</pre>
+<p>
+</p><h2>April 24, 2000</h2>
+<p>Mesa 3.2 has been released. Here's what's new since the beta release:</p>
+<pre> Bug fixes:
+ - fixed memcpy bugs in span.c
+ - fixed missing glEnd problem in demos/tessdemo.c
+ - fixed bug when clearing 24bpp Ximages
+ - fixed clipping problem found in Unreal Tournament
+ - fixed Loki's "ice bug" and "crazy triangles" seen in Heretic2
+ - fixed Loki's 3dfx RGB vs BGR bug
+ - fixed Loki's 3dfx smooth/flat shading bug in SoF
+ Changes:
+ - updated docs/README file
+ - use bcopy() optimizations on FreeBSD
+ - re-enabled the optimized persp_textured_triangle() function
+</pre>
+<p>
+</p><h2>March 23, 2000</h2>
+<p>I've just upload the Mesa 3.2 beta 1 files to SourceForge at <a href="http://sourceforge.net/project/showfiles.php?group_id=3" target="_parent">http://sourceforge.net/project/filelist.php?group_id=3</a><a href="http://sourceforge.net/project/showfiles.php?group_id=3"></a></p>
+<p>3.2 (note even number) is a stabilization release of Mesa 3.1 meaning it's mainly
+just bug fixes.</p>
+<p>Here's what's changed:
+
+</p><ul>
+ Bug fixes:
+ <ul>
+ - mixed drawing of lines and bitmaps sometimes had wrong colors<br>
+ - added missing glHintPGI() function<br>
+ - fixed a polygon culling bug<br>
+ - fixed bugs in gluPartialDisk()<br>
+ - Z values in selection mode were wrong<br>
+ - added missing tokens:
+ <ul>
+ GL_SMOOTH_POINT_SIZE_RANGE<br>
+ GL_SMOOTH_POINT_SIZE_GRANULARITY<br>
+ GL_SMOOTH_LINE_WIDTH_RANGE<br>
+ GL_SMOOTH_LINE_WIDTH_GRANULARITY<br>
+ GL_ALIASED_POINT_SIZE_RANGE<br>
+ GL_ALIASED_LINE_WIDTH_RANGE
+ </ul>
+ - fixed glCopyPixels when copying from back to front buffer<br>
+ - GL_EXT_compiled_vertex_array tokens had _SGI suffix instead of _EXT<br>
+ - glDrawRangeElements(GL_LINES, 0, 1, 2, type, indices) was broken<br>
+ - glDeleteTextures() didn't decrement reference count correctly<br>
+ - GL_SRCA_ALPHA_SATURATE blend mode didn't work correctly<br>
+ - Actual depth of transformation matrix stacks was off by one<br>
+ - 24bpp visuals didn't address pixels correctly<br>
+ - mipmap level of detail (lambda) calculation simplified, more accurate<br>
+ - 101691 - Polygon clipping and GL_LINE<br>
+ - 101928 - Polygon clipping and GL_LINE (same fix as above)<br>
+ - 101808 - Non-glVertexArrays tristrip bug<br>
+ - 101971 - find_last_3f on Dec OSF (worked around)<br>
+ - 102369 - segv on dec osf (possibly a duplicate of the above)<br>
+ - 102893 - orientations of modelview cause segfault
+ </ul>
+ New:
+ <ul>
+ - updated SVGA Linux driver<br>
+ - added the MESA_FX_NO_SIGNALS env var, see docs/README.3DFX<br>
+ - build libGLw.a (Xt/OpenGL drawing area widget) library by default<br>
+ - changed -O2 to -O3 for a number of gcc configs
+ </ul>
+ Changes:
+ <ul>
+ - glXCopyContext's mask parameter is now unsigned long, per GLX spec
+ </ul>
+</ul>
+
+<p>Please report any problems with this release ASAP. Bugs should be filed on the
+Mesa3D website at sourceforge.<br>
+After 3.2 is wrapped up I hope to release 3.3 beta 1 soon afterward.</p>
+<p>-- Brian</p>
+<p>
+</p><h2>December 17, 1999</h2>
+<p>A Slashdot interview with Brian about Mesa (questions submitted by Slashdot readers)
+can be found at <a href="http://slashdot.org/interviews/99/12/17/0927212.shtml" target="_parent">http://slashdot.org/interviews/99/12/17/0927212.shtml</a>.</p>
+<p>
+</p><h2>December 14, 1999</h2>
+<p>Mesa 3.1 is released!</p>
+<p>
+</p><h2>September 21, 1999</h2>
+<p>There appear to be two new files on the ftp site, <a href="ftp://ftp.mesa3d.org/mesa/beta/MesaLib-3.1beta3.tar.gz">MesaLib-3.1beta3.tar.gz</a>
+and <a href="ftp://ftp.mesa3d.org/mesa/beta/MesaDemos-3.1beta3.tar.gz">MesaDemos-3.1beta3.tar.gz</a>,
+that seem to be... yes, I've just received confirmation from the beta center, they
+are indeed the <b>THIRD</b> beta release of Mesa 3.1! Happy Days. Happy Days. Thanks
+Keith Whitwell for preparing these for us during Brian's absence.</p>
+<p>
+</p><h2>August 30, 1999</h2>
+<p>I'm pleased to announce that I've accepted a position with Precision Insight,
+Inc. effective October, 1999. I'll be leaving Avid Technology in September.</p>
+<p>I've been working on Mesa in my spare time for over five years. With Precision
+Insight I now have the opportunity to devote my full attention to advancing Mesa
+and OpenGL on Linux.</p>
+<p>While I'll be focused on Linux, the X Window System, and hardware acceleration,
+my work will continue to be open sourced and available to any other programmers who
+may want to contribute to it, or use it for other projects or platforms</p>
+<p>PS: I'm going to be traveling until Sep 6 and won't be reading email until then.</p>
+<p>
+</p><h2>August 23, 1999</h2>
+<p>Anonymous CVS access is back online so suck up all the bandwidth you can afford.
+Note that this is a new archive, so you will need to re-checkout the archive. That
+means don't <i>cvs update</i> from a previous download.</p>
+<p>
+</p><h2>August 17, 1999</h2>
+<p>A report from the SIGGRAPH '99 Linux/OpenGL
+BOF meeting is now available.</p>
+<p>-Brian</p>
+<p>
+</p><h2>August 14, 1999</h2>
+<p>www.mesa3d.org is having technical problems due to hardware failures at VA Linux
+systems. The Mac pages, ftp, and CVS services aren't fully restored yet. Please be
+patient.</p>
+<p>-Brian</p>
+<p>
+</p><h2>June 7, 1999</h2>
+<p>RPMS of the nVidia RIVA server can be found at <a href="ftp://ftp.mesa3d.org/mesa/misc/nVidia/">ftp://ftp.mesa3d.org/mesa/misc/nVidia/</a>.</p>
+<p>
+</p><h2>June 2, 1999</h2>
+<p><a href="http://www.nvidia.com/">nVidia</a> has released some Linux binaries for
+xfree86 3.3.3.1, along with the <b>full source</b>, which includes GLX acceleration
+based on Mesa 3.0. They can be downloaded from <a href="http://www.nvidia.com/Products.nsf/htmlmedia/software_drivers.html">http://www.nvidia.com/Products.nsf/htmlmedia/software_drivers.html</a>.</p>
+<p>
+</p><h2>May 24, 1999</h2>
+<p>Beta 2 of Mesa 3.1 has been make available at <a href="ftp://ftp.mesa3d.org/mesa/beta/">ftp://ftp.mesa3d.org/mesa/beta/</a>.
+If you are into the quake scene, you may want to try this out, as it contains some
+optimizations specifically in the Q3A rendering path.
+<p>
+</p><h2>May 13, 1999</h2>
+<p>For those interested in the integration of Mesa into XFree86 4.0, Precision Insight
+has posted their lowlevel design documents at http://www.precisioninsight.com.</p>
+<p>
+</p><h2>May 13, 1999</h2>
+<pre>May 1999 - John Carmack of id Software, Inc. has made a donation of
+US$10,000 to the Mesa project to support its continuing development.
+Mesa is a free implementation of the OpenGL 3D graphics library and id's
+newest game, Quake 3 Arena, will use Mesa as the 3D renderer on Linux.
+
+The donation will go to Keith Whitwell, who has been optimizing Mesa to
+improve performance on 3d hardware. Thanks to Keith's work, many
+applications using Mesa 3.1 will see a dramatic performance increase
+over Mesa 3.0. The donation will allow Keith to continue working on
+Mesa full time for some time to come.
+
+For more information about Mesa see www.mesa3d.org. For more
+information about id Software, Inc. see www.idsoftware.com.
+
+--------------------------------
+
+This donation from John/id is very generous. Keith and I are very
+grateful.
+
+</pre>
+<p>
+</p><h2>May 1, 1999</h2>
+<p>John Carmack made an interesting .plan update yesterday:
+
+</p><ul>
+ <i>"I put together a document on optimizing OpenGL drivers for Q3 that
+ should be helpful to the various Linux 3D teams. <br>
+ </i>http://www.quake3arena.com/news/glopt.html</i>"
+</ul>
+
+<p>
+</p><h2>April 7, 1999</h2>
+<p>Updated the Mesa contributors section and added links to RPM Mesa packages.</p>
+<p>
+</p><h2>March 18, 1999</h2>
+<p>The new webpages are now online. Enjoy, and let me know if you find any errors.
+For an eye-candy free version you can use <a href="http://www.mesa3d.org/txt/">http://www.mesa3d.org/txt/</a>.</p>
+<p>
+</p><h2>February 16, 1999</h2>
+<p><a href="http://www.sgi.com/">SGI</a> releases its <a href="http://www.sgi.com/software/opensource/glx/">GLX
+source code</a>.</p>
+<p>
+</p><h2>January 22, 1999</h2>
+<p>www.mesa3d.org established</p>
+
+
+</p>
+
+
+<hr>
+$Id: news.html,v 1.1.1.8 2005/12/01 03:11:30 kem Exp $
+</body>
+</html>
diff --git a/nx-X11/extras/Mesa/docs/osmesa.html b/nx-X11/extras/Mesa/docs/osmesa.html
new file mode 100644
index 000000000..6feb8df52
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/osmesa.html
@@ -0,0 +1,77 @@
+<HTML>
+
+<TITLE>Off-screen Rendering</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Off-screen Rendering</H1>
+
+
+<p>
+Mesa 1.2.4 introduced off-screen rendering, a facility for generating
+3-D imagery without having to open a window on your display. Mesa's
+simple off-screen rendering interface is completely operating system
+and window system independent so programs which use off-screen
+rendering should be very portable. This feature effectively
+enables you to use Mesa as an off-line, batch-oriented renderer.
+</p>
+<p>
+The "OSMesa" API provides 3 functions for making off-screen
+renderings: OSMesaCreateContext(), OSMesaMakeCurrent(), and
+OSMesaDestroyContext(). See the Mesa/include/GL/osmesa.h header for
+more information. See the demos/osdemo.c file for an example program.
+There is no facility for writing images to files. That's up to you.
+</p>
+<p>
+If you want to generate large images (larger than 1280x1024) you'll
+have to edit the src/config.h file to change MAX_WIDTH and MAX_HEIGHT
+then recompile Mesa. Image size should only be limited by available
+memory.
+</p>
+
+
+<H2>Deep color channels</H2>
+
+<p>
+ For some applications 8-bit color channels don't have sufficient
+ accuracy (film and IBR, for example). If you're in this situation
+ you'll be happy to know that Mesa supports 16-bit and 32-bit color
+ channels through the OSMesa interface. When using 16-bit channels,
+ channels are GLushorts and RGBA pixels occupy 8 bytes. When using 32-bit
+ channels, channels are GLfloats and RGBA pixels occupy 16 bytes.
+</p>
+<p>
+ To build Mesa/OSMesa with 16-bit color channels:
+<pre>
+ make realclean
+ make linux-osmesa16
+</pre>
+
+ For 32-bit channels:
+<pre>
+ make realclean
+ make linux-osmesa32
+</pre>
+
+<p>
+You'll wind up with a library named libOSMesa16.so or libOSMesa32.so.
+</p>
+
+<p>
+If you need to compile on a non-Linux platform, copy Mesa/configs/linux-osmesa16
+to a new config file and edit it as needed. Then, add the new config name to
+the top-level Makefile. Send a patch to the Mesa developers too, if you're
+inclined.
+</p>
+
+<p>
+BE WARNED: 16 and 32-bit channel support has not been exhaustively
+tested and there may be some bugs. However, a number of people have
+been using this feature successfully so it can't be too broken.
+</p>
+
+
+</BODY>
+</HTML>
diff --git a/nx-X11/extras/Mesa/docs/pbuffers.html b/nx-X11/extras/Mesa/docs/pbuffers.html
new file mode 100644
index 000000000..259910155
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/pbuffers.html
@@ -0,0 +1,54 @@
+<HTML>
+
+<TITLE>PBuffer Rendering</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>PBuffer Rendering</H1>
+
+<p>
+Basically, FBconfigs and PBuffers allow you to do off-screen rendering
+with OpenGL. The OSMesa interface does basically the same thing, but
+fbconfigs and pbuffers are supported by more vendors.
+PBuffer rendering may also be hardware accelerated.
+</p>
+
+<p>
+PBuffers are getting more use nowadays, though they've actually been
+around for a long time on IRIX systems and other workstations.
+</p>
+
+<p>
+The
+<a href="http://oss.sgi.com/projects/ogl-sample/registry/SGIX/fbconfig.txt"
+target="_parent">GL_SGIX_fbconfig</a>
+and
+<a href="http://oss.sgi.com/projects/ogl-sample/registry/SGIX/pbuffer.txt"
+target="_parent">
+GL_SGIX_pbuffer</a> extensions describe the functionality.
+More recently, these extensions have been promoted to ARB extensions (on
+Windows at least).
+</p>
+
+<p>
+The Mesa/progs/xdemos/ directory has some useful code for working
+with pbuffers:
+</p>
+
+<ul>
+<li><b>pbinfo.c</b> - like glxinfo, it prints a list of available
+ fbconfigs and whether each supports pbuffers.
+<li><b>pbutil.c</b> - a few utility functions for dealing with
+ fbconfigs and pbuffers.
+<li><b>pbdemo.c</b> - a demonstration of off-screen rendering with pbuffers.
+</ul>
+
+<p>
+Mesa 4.1 and later support GL_SGIX_fbconfig and GL_SGIX_pbuffer (software
+rendering only).
+</p>
+
+</BODY>
+</HTML>
diff --git a/nx-X11/extras/Mesa/docs/perf.html b/nx-X11/extras/Mesa/docs/perf.html
new file mode 100644
index 000000000..ee9c4b117
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/perf.html
@@ -0,0 +1,68 @@
+<HTML>
+
+<TITLE>Performance Tips</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Performance Tips</H1>
+
+<p>
+Performance tips for software rendering:
+</P>
+<ol>
+
+<li> Turn off smooth shading when you don't need it (glShadeModel)
+<li> Turn off depth buffering when you don't need it.
+<li> Turn off dithering when not needed.
+<li> Use double buffering as it's often faster than single buffering
+<li> Compile in the X Shared Memory extension option if it's supported
+ on your system by adding -DSHM to CFLAGS and -lXext to XLIBS for
+ your system in the Make-config file.
+<li> Recompile Mesa with more optimization if possible.
+<li> Try to maximize the amount of drawing done between glBegin/glEnd pairs.
+<li> Use the MESA_BACK_BUFFER variable to find best performance in double
+ buffered mode. (X users only)
+<li> Optimized polygon rasterizers are employed when:
+ rendering into back buffer which is an XImage
+ RGB mode, not grayscale, not monochrome
+ depth buffering is GL_LESS, or disabled
+ flat or smooth shading
+ dithered or non-dithered
+ no other rasterization operations enabled (blending, stencil, etc)
+<li> Optimized line drawing is employed when:
+ rendering into back buffer which is an XImage
+ RGB mode, not grayscale, not monochrome
+ depth buffering is GL_LESS or disabled
+ flat shading
+ dithered or non-dithered
+ no other rasterization operations enabled (blending, stencil, etc)
+<li> Textured polygons are fastest when:
+ using a 3-component (RGB), 2-D texture
+ minification and magnification filters are GL_NEAREST
+ texture coordinate wrap modes for S and T are GL_REPEAT
+ GL_DECAL environment mode
+ glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST )
+ depth buffering is GL_LESS or disabled
+<li> Lighting is fastest when:
+ Two-sided lighting is disabled
+ GL_LIGHT_MODEL_LOCAL_VIEWER is false
+ GL_COLOR_MATERIAL is disabled
+ No spot lights are used (all GL_SPOT_CUTOFFs are 180.0)
+ No local lights are used (all position W's are 0.0)
+ All material and light coefficients are >= zero
+<li> XFree86 users: if you want to use 24-bit color try starting your
+ X server in 32-bit per pixel mode for better performance. That is,
+ start your X server with
+ startx -- -bpp 32
+ instead of
+ startx -- -bpp 24
+<li> Try disabling dithering with the MESA_NO_DITHER environment variable.
+ If this env var is defined Mesa will disable dithering and the
+ command glEnable(GL_DITHER) will be ignored.
+</ol>
+
+
+</BODY>
+</HTML>
diff --git a/nx-X11/extras/Mesa/docs/precompiled.html b/nx-X11/extras/Mesa/docs/precompiled.html
new file mode 100644
index 000000000..166d33d82
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/precompiled.html
@@ -0,0 +1,26 @@
+<HTML>
+
+<TITLE>Precompiled libraries</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Precompiled Libraries</H1>
+
+<p>
+In general, precompiled libraries are not available.
+However, people occasionally prepare packages of precompiled libraries
+for some systems.
+</p>
+
+<H2>Mesa-6.0 for Solaris</H2>
+
+<p>
+Steve Christensen has submitted precompiled Mesa-6.0 libraries for
+Solaris at <a href="http://sunfreeware.com/" target="_parent">
+sunfreeware.com</a>.
+</p>
+
+</BODY>
+</HTML>
diff --git a/nx-X11/extras/Mesa/docs/relnotes.html b/nx-X11/extras/Mesa/docs/relnotes.html
new file mode 100644
index 000000000..fb4321e73
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/relnotes.html
@@ -0,0 +1,45 @@
+<HTML>
+
+<TITLE>Mesa Release Notes</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Release Notes</H1>
+
+<p>
+The release notes summarize what's new or changed in each Mesa release.
+</p>
+
+<UL>
+<LI><A HREF="RELNOTES-6.4.1">RELNOTES-6.4.1</A>
+<LI><A HREF="RELNOTES-6.4">RELNOTES-6.4</A>
+<LI><A HREF="RELNOTES-6.3.2">RELNOTES-6.3.2</A>
+<LI><A HREF="RELNOTES-6.3">RELNOTES-6.3</A>
+<LI><A HREF="RELNOTES-6.2.1">RELNOTES-6.2.1</A>
+<LI><A HREF="RELNOTES-6.2">RELNOTES-6.2</A>
+<LI><A HREF="RELNOTES-6.1">RELNOTES-6.1</A>
+<LI><A HREF="RELNOTES-6.0">RELNOTES-6.0</A>
+<LI><A HREF="RELNOTES-5.1">RELNOTES-5.1</A>
+<LI><A HREF="RELNOTES-5.0.2">RELNOTES-5.0.2</A>
+<LI><A HREF="RELNOTES-5.0.1">RELNOTES-5.0.1</A>
+<LI><A HREF="RELNOTES-5.0">RELNOTES-5.0</A>
+<LI><A HREF="RELNOTES-4.1">RELNOTES-4.1</A>
+<LI><A HREF="RELNOTES-4.0.3">RELNOTES-4.0.3</A>
+<LI><A HREF="RELNOTES-4.0.2">RELNOTES-4.0.2</A>
+<LI><A HREF="RELNOTES-4.0.1">RELNOTES-4.0.1</A>
+<LI><A HREF="RELNOTES-4.0">RELNOTES-4.0</A>
+<LI><A HREF="RELNOTES-3.5">RELNOTES-3.5</A>
+<LI><A HREF="RELNOTES-3.4.2">RELNOTES-3.4.2</A>
+<LI><A HREF="RELNOTES-3.4.1">RELNOTES-3.4.1</A>
+<LI><A HREF="RELNOTES-3.4">RELNOTES-3.4</A>
+<LI><A HREF="RELNOTES-3.3">RELNOTES-3.3</A>
+<LI><A HREF="RELNOTES-3.2.1">RELNOTES-3.2.1</A>
+<LI><A HREF="RELNOTES-3.2">RELNOTES-3.2</A>
+<LI><A HREF="RELNOTES-3.1">RELNOTES-3.1</A>
+</UL>
+
+
+</BODY>
+</HTML>
diff --git a/nx-X11/extras/Mesa/docs/science.html b/nx-X11/extras/Mesa/docs/science.html
new file mode 100644
index 000000000..f55cf3124
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/science.html
@@ -0,0 +1,72 @@
+<HTML>
+
+<TITLE>Science and Technical</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Science and Technical</H1>
+
+<ul>
+ <li><a href="http://www.softintegration.com/products/toolkit/opengl/" target="_parent">Ch</a> - OpenGL bindings for the Ch C/C++ interpreter
+ </li><li><a href="http://mesa3d.sourceforge.net/notfound.html">CLEO3D</a> - event displayer for the CLEOIII detector
+ </li><li><a href="http://www.bioz.unibas.ch/%7Exray/dino/" target="_parent">DINO</a> - Visualizing
+ Structural Biology
+ </li><li><a href="http://www-xdiv.lanl.gov/XCM/gmv/GMVHome.html" target="_parent">General
+ Mesh Viewer (GMV)</a> - scientific vis.
+ </li><li><a href="http://gid.cimne.upc.es/" target="_parent">GiD</a> - finite element
+ analysis
+ </li><li><a href="http://sig.co.za/download.htm" target="_parent">glpoisson</a> - A finite
+ element analysis program that simulates wave in an arbitrary region.
+ </li><li><a href="http://glwaves.sourceforge.net/" target="_parent">GLWaves</a> -
+ Electromagnetic wave visualization
+ </li><li><a href="http://www.geuz.org/gmsh/" target="_parent">Gmsh</a> -
+ finite element mesh generator / viewer
+ </li><li><a href="http://laaksonen.csc.fi/gopenmol/gopenmol.htmls" target="_parent">gOpenMol</a>
+ - computational chemistry
+ </li><li><a href="http://www.mgix.com/gps3d/" target="_parent">GPS 3D</a> - GPS-based map visualization
+ </li><li><a href="http://hirame.hiram.edu/%7Eworleyam/" target="_parent">Hitchhiker</a>
+ - virtual solar system
+ </li><li><a href="http://www-xdiv.lanl.gov/XCM/Hydra/" target="_parent">Hydra</a> - physics
+ and engineering pkg
+ </li><li><a href="http://fox.mit.edu/skunk/soft/lightspeed/" target="_parent">Light Speed</a>
+ - a real-time, interactive relativistic simulator
+ </li><li><a href="http://linkwinds.jpl.nasa.gov/" target="_parent">LinkWinds</a> - scientific
+ vis
+ </li><li><a href="http://mesa3d.sourceforge.net/notfound.html" target="_parent">MathGL3d</a> - Mathematica viewer
+ </li><li><a href="http://www.mathworks.com/products/matlab" target="_parent">Mathworks</a>
+ - mathematics and visualization
+ </li><li><a href="http://www-rocq.inria.fr/gamma/medit/medit.html" target="_parent">Medit</a> - 3D surface mesh viewer
+ </li><li><a href="http://www.mol.biol.ethz.ch/wuthrich/software/molmol/" target="_parent">MOLMOL</a>
+ - molecular modeling and analysis
+ </li><li><a href="http://www.avatar.se/molscript/" target="_parent">Molscript</a> - molecular
+ modeling
+ </li>
+ <li><a href="http://www.opendx.org/" target="_parent">OpenDX</a> - Data visualization
+ system
+ </li>
+ <li><a href="http://orsa.sourceforge.net/" target="_parent">ORSA</a> - An interactive tool for Celestial Mechanics
+ </li>
+ <li><a href="http://www.paraview.org/" target="_parent">ParaView</a> - Scientific visualization package
+ </li>
+ <li><a href="http://mesa3d.sourceforge.net/notfound.html">PHLEX</a> - Finite element vis
+ </li><li><a href="http://root.cern.ch/" target="_parent">ROOT</a> - Object Oriented Data
+ Analysis Framework
+ </li><li><a href="http://www.slffea.com/" target="_parent">SLFFEA</a> - GNU finite element
+ package
+ </li><li><a href="http://quorum.tamu.edu/jon/spock" target="_parent">Spock</a> - molecular
+ modeling
+ </li><li><a href="http://www1.las.es/%7Eamil/ssystem" target="_parent">Ssystem</a> - solar
+ system simulation
+ </li><li><a href="http://mesa3d.sourceforge.net/notfound.html">SPARROW</a> - robot simulation
+ </li><li><a href="http://www.ssec.wisc.edu/%7Ebillh/vis5d.html" target="_parent">Vis5D</a>
+ - atmospheric visualization
+ </li><li><a href="http://www.ks.uiuc.edu/Research/vmd/" target="_parent">VMD</a> - molecular
+ modeling
+ </li><li><a href="http://www.cyberbotics.com/" target="_parent">Webots</a> - 3-D mobile
+ robot simulator
+</li></ul>
+
+
+</body></html> \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/docs/sourcedocs.html b/nx-X11/extras/Mesa/docs/sourcedocs.html
new file mode 100644
index 000000000..a5248d988
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/sourcedocs.html
@@ -0,0 +1,26 @@
+<HTML>
+
+<TITLE>Source Code Documentation</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Source Code Documentation</H1>
+
+<p>
+<A HREF="http://www.doxygen.org" target="_parent">Doxygen</A>
+is used to automatically
+produce cross-referenced documentation from the Mesa sources.
+This is not included in the normal Mesa distribution.
+Download Mesa from CVS if interested.
+</P>
+
+<P>
+If you're reading this page from your local copy of Mesa, and have
+run the doxygen scripts, you can read the documentation
+<A HREF="../doxygen/main/index.html" target="_parent">here</A>
+</P>
+
+</BODY>
+</HTML>
diff --git a/nx-X11/extras/Mesa/docs/subset-A.html b/nx-X11/extras/Mesa/docs/subset-A.html
new file mode 100644
index 000000000..dac66a61b
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/subset-A.html
@@ -0,0 +1,3579 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title>Mini GLX Specification</title>
+</head>
+<body>
+<span style="font-style: italic;"></span><span
+ style="font-weight: bold;"></span>
+<h1>
+<center>Mesa Subset Specification</center>
+</h1>
+<h2>
+<center>
+<h3>Tungsten Graphics, Inc.</h3>
+<h3>February 26, 2003<br>
+</h3>
+</center>
+</h2>
+<p> Copyright &copy; 2002-2003 by <a
+ href="http://www.tungstengraphics.com/">Tungsten Graphics, Inc.</a>,
+Cedar Park, Texas. All Rights Reserved. <br>
+<br>
+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.<br>
+</p>
+<p> OpenGL is a trademark of <a href="http://www.sgi.com">Silicon
+Graphics, Inc.</a>.</p>
+<h1>1. Introduction</h1>
+This document describes a subset of the Mesa implemented by Tungsten
+Graphics, Inc. for embedded devices. &nbsp;Prior to reading this
+document the reader should be familiar with the OpenGL 1.2.1
+specification dated April 1, 1999 (available from <a
+ href="http://www.opengl.org/developers/documentation/specs.html">http://www.opengl.org/developers/documentation/specs.html</a>.)
+&nbsp;Experience with OpenGL programming is highly advisable.<a
+ href="http://www.opengl.org/developers/documentation/specs.html"><br>
+</a><br>
+Tungsten Graphics, Inc. is working with industry standards
+organizations +in an attempt to standardize this Mesa subset and any
+other possible subsets +as a result of this work. <br>
+<br>
+Appendix A contains a list of issues of which some may not be resolved.<br>
+<br>
+To summarize, the following major features of Mesa are omitted from the
+subset:<br>
+<ul>
+ <li>Vertex arrays</li>
+ <li>Texture coordinate generation</li>
+ <li>Lighting</li>
+ <li>Point size</li>
+ <li>Polygon stipple</li>
+ <li>DrawPixels, CopyPixels, PixelZoom</li>
+ <li>1-D and 3-D textures</li>
+ <li>CopyTex[Sub]Image</li>
+ <li>Fog</li>
+ <li>Depth test</li>
+ <li>Color Index mode</li>
+ <li>Accumulation buffer</li>
+ <li>Feedback mode</li>
+ <li>Evaluators</li>
+ <li>Push/Pop attributes</li>
+ <li>Display lists<br>
+ </li>
+</ul>
+<p>Further reductions are made at a lower level of detail.<br>
+</p>
+<p>Mesa function names are printed in <span style="font-weight: bold;">bold
+face</span>. &nbsp;Function parameters are printed in <span
+ style="font-style: italic;">italics</span>.<br>
+</p>
+<p>The Tungsten Graphics, Inc. Mesa subset library is hereafter
+referred to as <span style="font-style: italic;">the subset.</span><br>
+<br>
+</p>
+<h1>2. Primitive Specification</h1>
+<h2>2.1 glBegin, glEnd and glVertex Commands</h2>
+The basic rendering primitives are points, lines and triangles.
+&nbsp;Quadrilaterals and polygons are composed of triangles.
+&nbsp;Primitives are drawn with the <span style="font-weight: bold;">glBegin</span>
+and <span style="font-weight: bold;">glEnd</span> commands and a subset
+of the <span style="font-weight: bold;">glVertex</span> commands:<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glBegin</span>(GLenum<span
+ style="font-style: italic;">mode</span>)<br>
+void <span style="font-weight: bold;">glEnd</span>(void)<br>
+<br>
+void <span style="font-weight: bold;">glVertex2f</span>(GLfloat <span
+ style="font-style: italic;">x</span>, GLfloat <span
+ style="font-style: italic;">y</span>)<br>
+void <span style="font-weight: bold;">glVertex2fv</span>(const GLfloat
+*<span style="font-style: italic;">v</span>)<br>
+void <span style="font-weight: bold;">glVertex3f</span>(GLfloat <span
+ style="font-style: italic;">x</span>, GLfloat <span
+ style="font-style: italic;">y</span>, GLfloat <span
+ style="font-style: italic;">z</span>)<br>
+void <span style="font-weight: bold;">glVertex3fv</span>(const GLfloat
+*<span style="font-style: italic;">v</span>)<br>
+</div>
+<br>
+The <span style="font-style: italic;">mode</span> parameter to <span
+ style="font-weight: bold;">glBegin</span> may be one of the following<br>
+<br>
+<div style="margin-left: 40px;">GL_POINTS - a series of individual
+points<br>
+GL_LINES - a series of disjoint line segments<br>
+GL_LINE_STRIP - series of connected line segments<br>
+GL_LINE_LOOP - a closed loop of line segments<br>
+GL_TRIANGLES - a series of individual triangles<br>
+GL_TRIANGLE_STRIP - a connected strip of triangles<br>
+GL_TRIANGLE_FAN - a sequence of triangles all sharing a common vertex<br>
+GL_QUADS - a sequence of individual quadrilaterals<br>
+GL_QUAD_STRIP - a connected strip of quadrilaterals<br>
+GL_POLYGON - a closed, convex polygon<br>
+<br>
+</div>
+<br>
+The <span style="font-weight: bold;">glVertex</span> commands take two
+or three floating point coordinates, or a pointer to an array of two or
+three floating point coordinates. &nbsp;Vertices are actually 4-element
+homogeneous coordinates. &nbsp;The fourth component, unspecified by the
+subset's <span style="font-weight: bold;">glVertex</span> commands, is
+one.<br>
+<br>
+<span style="font-weight: bold;"></span>
+<h2>2.2 Other Per-vertex Commands<br>
+</h2>
+The <span style="font-weight: bold;">glColor</span> and <span
+ style="font-weight: bold;">glTexCoord</span> commands may be used to
+specify colors and texture coordinates for each vertex:<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glColor3f</span>(GLfloat<span
+ style="font-style: italic;">red</span>, GLfloat <span
+ style="font-style: italic;">green</span>, GLfloat <span
+ style="font-style: italic;">blue</span>)<br>
+void <span style="font-weight: bold;">glColor3fv</span>(const GLfloat *<span
+ style="font-style: italic;">rgb</span>)<br>
+void <span style="font-weight: bold;">glColor4f</span>(GLfloat <span
+ style="font-style: italic;">red,</span> GLfloat <span
+ style="font-style: italic;">green,</span> GLfloat <span
+ style="font-style: italic;">blue,</span> GLfloat <span
+ style="font-style: italic;">alpha</span>)<br>
+void <span style="font-weight: bold;">glColor4fv</span>(const GLfloat *<span
+ style="font-style: italic;">rgba</span>)<br>
+void <span style="font-weight: bold;">glTexCoord2f</span>(GLfloat <span
+ style="font-style: italic;">s</span>, GLfloat<span
+ style="font-style: italic;"> t</span>)<br>
+void <span style="font-weight: bold;">glTexCoord2fv</span>(const
+GLfloat *<span style="font-style: italic;">c</span>)<br>
+<br>
+</div>
+The <span style="font-weight: bold;">glColor</span> commands specify
+the color and optionally, the alpha value, for subsequent vertices.
+&nbsp;For the <span style="font-weight: bold;">glColor3</span> commands,
+alpha is set to one.<br>
+<br>
+The <span style="font-weight: bold;">glTexCoord2</span> commands
+specify the texture coordinate for subsequent vertices. &nbsp;Texture
+coordinates are actually four-component coordinates: (s, t, r, q).
+&nbsp;The <span style="font-weight: bold;">glTexCoord2</span> commands
+set s and t explicitly. &nbsp;The r and q components are zero and one,
+respectively.<br>
+<br>
+<span style="font-weight: bold;"></span>Only <span
+ style="font-weight: bold;">glVertex, glColor</span> and <span
+ style="font-weight: bold;">glTexCoord</span> commands are allowed
+between <span style="font-weight: bold;">glBegin</span> and <span
+ style="font-weight: bold;">glEnd.</span> &nbsp;Calling any other
+command between <span style="font-weight: bold;">glBegin</span> and <span
+ style="font-weight: bold;">glEnd</span> will result in the error
+GL_INVALID_OPERATION.<br>
+<br>
+<h2>2.3 Unsupported Commands</h2>
+None of the following commands related to primitive specification are
+supported by the subset:<br>
+<br>
+<div style="margin-left: 40px;">Per-Vertex commands:<br>
+</div>
+<div style="margin-left: 40px;">
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glVertex2d,
+glVertex2i, glVertex2s, glVertex3d, glVertex3i, glVertex3s, glVertex4d,
+glVertex4i, glVertex4s, glVertex2dv, glVertex2iv, glVertex2sv,
+glVertex3dv, glVertex3iv, glVertex3sv, glVertex4dv, glVertex4iv,
+glVertex4sv,<br>
+glNormal3b, glNormal3d, glNormal3f, glNormal3i, glNormal3s, </span><span
+ style="font-weight: bold;">glNormal3bv, glNormal3dv, glNormal3fv,
+glNormal3iv, glNormal3sv,<br>
+glIndexd, glIndexf, glIndexi, glIndexs, glIndexub, glIndexdv,
+glIndexfv, glIndexiv, glIndexsv, glIndexubv,<br>
+glColor3b, glColor3d, glColor3i, glColor3s, glColor3ub, glColor3ui,
+glColor3us, </span><span style="font-weight: bold;">glColor3bv,
+glColor3dv, glColor3iv, glColor3sv, glColor3ubv, glColor3uiv,
+glColor3usv,</span><span style="font-weight: bold;"> lColor4b,
+glColor4d, glColor4i, glColor4s, glColor4ub, glColor4ui, glColor4us, </span><span
+ style="font-weight: bold;">glColor4bv, glColor4dv, glColor4iv,
+glColor4sv, glColor4ubv, glColor4uiv, glColor4usv,<br>
+</span><span style="font-weight: bold;">glTexCoord1d, glTexCoord1f,
+glTexCoord1i, glTexCoord1s, glTexCoord2d, glTexCoord2i, glTexCoord2s,
+glTexCoord3d, glTexCoord3f, glTexCoord3i, glTexCoord3s, glTexCoord4d,
+glTexCoord4f, glTexCoord4i, glTexCoord4s, glTexCoord1dv, glTexCoord1fv,
+glTexCoord1iv, glTexCoord1sv, glTexCoord2dv, glTexCoord2iv,
+glTexCoord2sv, glTexCoord3dv, glTexCoord3fv, glTexCoord3iv,
+glTexCoord3sv, glTexCoord4dv, glTexCoord4fv, glTexCoord4iv,
+glTexCoord4sv,<br>
+glEdgeFlag, glEdgeFlagv</span><br style="font-weight: bold;">
+<br>
+</div>
+Vertex array commands:<br>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glVertexPointer,
+glColorPointer, glIndexPointer, glTexCoordPointer, glEdgeFlagPointer,
+glNormalPointer, glInterleavedArrays, glArrayElement, glDrawArrays,
+glDrawElements, glDrawRangeElements, glEnableClientState,
+glDisableClientState</span><br>
+</div>
+</div>
+<div style="margin-left: 40px;"><br>
+Rectangle commands:<br>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glRects,
+glRecti, glRectf, glRectd, glRectsv, glRectiv, glRectfv, glRectdv,<br>
+<br>
+</span></div>
+</div>
+<div style="margin-left: 40px;">Lighting commands:<br>
+</div>
+<div style="margin-left: 80px;"><span style="font-weight: bold;">glMaterialf,
+glMateriali, glMaterialfv, glMaterialiv<br>
+</span><br>
+</div>
+<div style="margin-left: 40px;"> Evaluator commands:<br>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glEvalCoord1d,
+glEvalCoord1f, glEvalCoord1dv, glEvalCoord1fv,&nbsp;</span><span
+ style="font-weight: bold;">glEvalCoord2d, glEvalCoord2f,
+glEvalCoord2dv, glEvalCoord2fv,<br>
+</span><span style="font-weight: bold;">glEvalPoint1, glEvalPoint2</span><br>
+<br>
+</div>
+</div>
+<h1>3. Coordinate Transformation</h1>
+<h2>3.1 Vertex Transformation</h2>
+Vertex coordinates are transformed by the current modelview and
+projection matrices then mapped to window coordinates as specified by
+the viewport. &nbsp;The following coordinate transformation commands are
+supported by the subset<br>
+<br>
+<div style="margin-left: 40px; font-weight: bold;">glMatrixMode<span
+ style="font-weight: normal;">(GLenum <span style="font-style: italic;">mode</span>)</span><br>
+glLoadIdentity<span style="font-weight: normal;">(void)</span><br>
+glPushMatrix<span style="font-weight: normal;">(void)</span><br>
+glPopMatrix<span style="font-weight: normal;">(void)</span><br>
+glLoadMatrixf<span style="font-weight: normal;">(const GLfloat *<span
+ style="font-style: italic;">m</span>)</span><br>
+glMultMatrixf<span style="font-weight: normal;">(const GLfloat *<span
+ style="font-style: italic;">m</span>)</span><br>
+glRotatef<span style="font-weight: normal;">(GLfloat <span
+ style="font-style: italic;">angle</span>, GLfloat <span
+ style="font-style: italic;">x</span>, GLfloat <span
+ style="font-style: italic;">y</span>, GLfloat <span
+ style="font-style: italic;">z</span>)</span><br>
+glTranslatef<span style="font-weight: normal;">(GLfloat <span
+ style="font-style: italic;">x</span>, GLfloat <span
+ style="font-style: italic;">y</span>, GLfloat <span
+ style="font-style: italic;">z</span>)</span><br>
+glScalef<span style="font-weight: normal;">(GLfloat <span
+ style="font-style: italic;">x</span>, GLfloat <span
+ style="font-style: italic;">y</span>, GLfloat <span
+ style="font-style: italic;">z</span>)<br>
+<span style="font-weight: bold;">glFrustum(</span>GLdouble <span
+ style="font-style: italic;">left,</span> GLdouble <span
+ style="font-style: italic;">right,</span> GLdouble <span
+ style="font-style: italic;">bottom,</span> GLdouble <span
+ style="font-style: italic;">top,</span> GLdouble <span
+ style="font-style: italic;">near,</span> GLdouble <span
+ style="font-style: italic;">far</span>)</span><br>
+<span style="font-weight: normal;"><span style="font-weight: bold;">glOrtho(</span>GLdouble<span
+ style="font-style: italic;"> left,</span> GLdouble <span
+ style="font-style: italic;">right,</span> GLdouble <span
+ style="font-style: italic;">bottom,</span> GLdouble <span
+ style="font-style: italic;">top,</span> GLdouble <span
+ style="font-style: italic;">near,</span> GLdouble <span
+ style="font-style: italic;">far</span>)</span><br>
+glViewport<span style="font-weight: normal;">(GLint <span
+ style="font-style: italic;">x</span>, GLint <span
+ style="font-style: italic;">y</span>, GLsize <span
+ style="font-style: italic;">width,</span> GLsizei <span
+ style="font-style: italic;">height</span>)</span><br>
+</div>
+<br>
+The <span style="font-weight: bold;">glMatrixMode</span> command
+specifies the <span style="font-style: italic;">current matrix.</span>
+&nbsp;The mode parameter may be GL_MODELVIEW or GL_PROJECTION to specify
+the modelview matrix or projection matrix. &nbsp;Subsequent matrix
+commands will effect the current matrix. &nbsp;Also associated with the
+modelview and projection matrices are a modelview matrix stack and
+projection matrix stack.<br>
+<br>
+The <span style="font-weight: bold;">glLoadIdentity</span> command
+replaces the current matrix with the identity matrix. &nbsp;The matrix
+elements are specified in column-major order.<br>
+<br>
+The <span style="font-weight: bold;">glPushMatrix</span> command pushes
+a copy of the current matrix onto either the modelview matrix stack or
+the projection matrix stack. &nbsp;The <span style="font-weight: bold;">glPopMatrix</span>
+command replaces the current matrix with a copy of the top matrix off
+the modelview matrix stack or projection matrix stack, the pops the
+stack. &nbsp;Matrix stacks are useful for traversing and rendering
+hierarchical models.<br>
+<br>
+The <span style="font-weight: bold;">glMultMatrixf</span> command
+post-multiplies the current matrix by the specified matrix. &nbsp;The
+matrix elements are specified in column-major order.<br>
+<br>
+The <span style="font-weight: bold;">glRotatef</span> command
+post-multiplies the current matrix by a rotation matrix defined by the
+angle and rotation axis defined by x, y and z.<br>
+<br>
+The <span style="font-weight: bold;">glTranslatef</span> command
+post-multiplies the current matrix by a translation matrix defined by
+the <span style="font-style: italic;">x</span>, <span
+ style="font-style: italic;">y</span> and <span
+ style="font-style: italic;">z</span> translation parameters.<br>
+<span style="font-weight: bold;"></span><br>
+The <span style="font-weight: bold;">glScalef</span> command
+post-multiplies the current matrix by a scaling matrix defined by the <span
+ style="font-style: italic;">x</span>, <span
+ style="font-style: italic;">y</span> and <span
+ style="font-style: italic;">z</span> scale factors.<br>
+<span style="font-weight: bold;"></span><br>
+The <span style="font-weight: bold;">glFrustum</span> command
+post-multiplies the current matrix by a perspective projection matrix.
+&nbsp;The <span style="font-style: italic;">near</span> and <span
+ style="font-style: italic;">far</span> values specify the position of
+the hither and yon Z-axis clipping planes. &nbsp;The <span
+ style="font-style: italic;">left, right, bottom</span> and <span
+ style="font-style: italic;">top</span> parameters are the X and Y
+extents at the near clipping plane. &nbsp;<span
+ style="font-weight: bold;">glFrustum</span> is normally used to modify
+the projection matrix.<br>
+<br>
+The <span style="font-weight: bold;">glOrtho</span> command
+post-multiplies the current matrix by an orthographic projection matrix.
+&nbsp;The <span style="font-style: italic;">near</span> and <span
+ style="font-style: italic;">far</span> values specify the position of
+the hither and yon Z-axis clipping planes. &nbsp;The <span
+ style="font-style: italic;">left, right, bottom</span> and <span
+ style="font-style: italic;">top</span> parameters specify the X and
+Y-axis clipping planes. &nbsp;<span style="font-weight: bold;">glOrtho</span>
+is normally used to modify the projection matrix.<br>
+<br>
+The <span style="font-weight: bold;">glViewport</span> command
+specifies the mapping of coordinates from normalized device coordinates
+to window coordinates. &nbsp;The <span style="font-style: italic;">x</span>
+and <span style="font-style: italic;">y</span> parameters specify the
+viewport's lower-left corner in the window and the <span
+ style="font-style: italic;">width</span> and <span
+ style="font-style: italic;">height</span> parameters specify the size
+of the viewport. &nbsp;<span style="font-weight: bold;">glViewport</span>
+does not effect the current matrix.<br>
+<br>
+A coordinate transformed to window coordinates is hereafter known as (x<sub>w</sub>,
+y<sub>w</sub>, z<sub>w</sub>).<br>
+<br>
+<h2>3.2 Clipping</h2>
+View-volume clipping automatically discards or trims primitives which
+lie completely or partially outside of the view volume specified by <span
+ style="font-weight: bold;">glFrustum</span> and <span
+ style="font-weight: bold;">glOrtho</span>. &nbsp;Note that the <span
+ style="font-weight: bold;">glViewport</span> command does not define a
+clipping region.<br>
+<br>
+Clipping occurs in <span style="font-style: italic;">clip coordinate
+space - </span>the coordinates produced after applying the projection
+matrix.<br>
+<br>
+<h2>3.3 Current Raster Position</h2>
+The current raster position specifies the location for drawing images
+with <span style="font-weight: bold;">glBitmap.</span> &nbsp;The current
+raster position is set with the commands:<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glRasterPos2f</span>(GLfloat<span
+ style="font-style: italic;">x</span>, GLfloat <span
+ style="font-style: italic;">y</span>)<br>
+void <span style="font-weight: bold;">glRasterPos2fv</span>(const
+GLfloat *<span style="font-style: italic;">v</span>)<br>
+void <span style="font-weight: bold;">glRasterPos2i</span>(GLint <span
+ style="font-style: italic;">x</span>, GLint <span
+ style="font-style: italic;">y</span>)<br>
+void <span style="font-weight: bold;">glRasterPos2iv</span>(const
+GLint *<span style="font-style: italic;">v</span>)<br>
+</div>
+<br>
+<span style="font-weight: bold;">glRasterPos</span> specifies a
+4-component coordinate (x, y, 0, 1). &nbsp;The coordinate is processed
+like a vertex; it is transformed by the modelview matrix, the projection
+matrix and mapped to the viewport. &nbsp;The resulting window coordinate
+is stored as the current raster position. &nbsp;The coordinate is
+clipped-tested against the frustum like a vertex. &nbsp;If the
+coordinate is clipped, then the current raster position becomes invalid
+and subsequent <span style="font-weight: bold;">glBitmap</span> commands
+have no effect.<br>
+<br>
+<span style="font-weight: bold;">glRasterPos</span> also updates the
+current raster color and current raster texture coordinates. &nbsp;The
+current raster color is updated (copied) from the current color (as
+specified by <span style="font-weight: bold;">glColor</span>).
+&nbsp;The current raster texture coordinate is updated (copied) from the
+current texture coordinate (as specified by <span
+ style="font-weight: bold;">glTexCoord</span>).<br>
+<br>
+<h2>3.4 Unsupported Commands</h2>
+The following commands related to vertex transformation are not
+supported by the subset:<br>
+<br>
+<div style="margin-left: 40px;">User-defined clip plane commands:<br>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glClipPlane</span><br>
+</div>
+<span style="font-weight: bold;"></span></div>
+<br>
+<div style="margin-left: 40px;">Lighting and material commands:</div>
+<div style="margin-left: 80px;"><span style="font-weight: bold;">glLightModeli,
+glLightModelf,&nbsp;</span><span style="font-weight: bold;">glLightModeliv,
+glLightModelfv,</span><span style="font-weight: bold;"> glLightf,
+glLighti, glLightfv, glLightiv, glColorMaterial</span><br>
+</div>
+<br>
+<div style="margin-left: 40px;">Automatic texture coordinate generation
+commands:<br>
+</div>
+<div style="margin-left: 40px;">
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glTexGend,
+glTexGenf, glTexGeni, </span><span style="font-weight: bold;">glTexGendv,
+glTexGenfv, glTexGeniv, </span><br>
+<br style="font-weight: bold;">
+</div>
+Double-valued commands:<br>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glLoadMatrixd,
+glMultMatrixd, glRotated, glTranslated, glScaled</span><br
+ style="font-weight: bold;">
+</div>
+<br>
+Depth Range command:<br>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glDepthRange</span>
+(the near value is always 0.0 and the far value is always 1.0)<br>
+</div>
+<br>
+Extra RasterPos commands:<br>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glRasterPos2d,
+glRasterPos2s, glRasterPos3d, glRasterPos3f, glRasterPos3i,
+glRasterPos3s, glRasterPos4d, glRasterPos4f, glRasterPos4i,
+glRasterPos4s, glRasterPos2dv, glRasterPos2sv, glRasterPos3dv,
+glRasterPos3fv, glRasterPos3iv, glRasterPos3sv, glRasterPos4dv,
+glRasterPos4fv, glRasterPos4iv, glRasterPos4sv</span><br>
+</div>
+<br>
+<br>
+</div>
+<h1>4. Rasterization</h1>
+This section describes the commands and options for drawing points,
+lines, triangles and bitmaps. &nbsp;<span style="font-style: italic;">Rasterization</span>
+is the term for the process which produces fragments from the geometric
+description of a primitive (a point, line, polygon or bitmap). &nbsp;For
+example, given the two coordinates for the end-points of a line segment,
+rasterization determines which pixels in the frame buffer are modified
+to <span style="font-style: italic;">draw</span> the line. &nbsp;A
+fragment is a tuple which consists of a window coordinate, colors and
+texture coordinates. &nbsp;The fragments produced by rasterization are
+subsequently processed by the per-fragment operations described later.<br>
+<br>
+<h2>4.1 Point Rasterization</h2>
+Points are rendered with the command sequence <span
+ style="font-weight: bold;">glBegin</span>(GL_POINTS), <span
+ style="font-weight: bold;">glVertex</span>, ... <span
+ style="font-weight: bold;">glEnd</span>. &nbsp;The window coordinate (x<sub>w</sub>,
+y<sub>w</sub>, z<sub>w</sub>) is truncated to rasterize the point.
+&nbsp;The truncated coordinate with its associated color and texture
+coordinate is sent as a single fragment to the per-fragment processing
+stages.<br>
+<br>
+The <span style="font-weight: bold;">glPointSize</span> command is not
+supported; only 1-pixel points are supported.<br>
+<br>
+Point smoothing (antialiasing) is also not supported.<br>
+<br>
+<h2>4.2 Line Rasterization</h2>
+Lines are rendered with the command sequence <span
+ style="font-weight: bold;">glBegin</span>(<span
+ style="font-style: italic;">mode</span>), <span
+ style="font-weight: bold;">glVertex</span>, <span
+ style="font-weight: bold;">glVertex</span>, ... <span
+ style="font-weight: bold;">glEnd</span> where <span
+ style="font-style: italic;">mode</span> is one of GL_LINES,
+GL_LINE_STRIP or GL_LINE_LOOP. &nbsp;Lines are rasterized as described
+in the OpenGL specification. &nbsp;Note that OpenGL specifies the <span
+ style="font-style: italic;">half-open</span> convention for drawing
+lines: the last fragment in a line segment is omitted so that endpoint
+pixels shared by two line segments will only be drawn once instead of
+twice.<br>
+<br>
+<h3>4.2.1 Line Width</h3>
+The width of lines can be controlled by<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glLineWidth</span>(GLfloat<span
+ style="font-style: italic;">width</span>)<br>
+</div>
+<br>
+where <span style="font-style: italic;">width</span> is the line width
+in pixels. &nbsp;The width defaults to 1.0. &nbsp;Attempting to set the
+width to a value less than or equal to zero will raise the error
+GL_INVALID_VALUE.<br>
+<br>
+<h3>4.2.2 Line Stipple<br>
+</h3>
+Lines may be stippled (i.e. dashed) with the command<br>
+<br>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glLineStipple</span>(GLint<span
+ style="font-style: italic;">factor</span>, GLushort <span
+ style="font-style: italic;">pattern</span>)<br>
+</div>
+<br>
+<span style="font-style: italic;">pattern</span> describes an on/off
+pattern for the fragments produced by rasterization and <span
+ style="font-style: italic;">factor</span> specifies how many subsequent
+fragments are kept or culled for each pattern bit. &nbsp;Line stippling
+can be enabled or disabled by the commands <span
+ style="font-weight: bold;">glEnable</span>(GL_LINE_STIPPLE) and <span
+ style="font-weight: bold;">glDisable</span>(GL_LINE_STIPPLE).<br>
+<br>
+<h3>4.2.3 Line Antialiasing</h3>
+Lines may be antialiased. &nbsp;For antialiased lines, each fragment
+produced by rasterization is assigned a <span
+ style="font-style: italic;">coverage value</span> which describes how
+much of the fragment's area is considered to be <span
+ style="font-style: italic;">inside</span> the line. &nbsp;Later, the
+alpha value of each fragment is multiplied by the coverage value.
+&nbsp;By blending the fragments into the frame buffer, the edges of
+lines appear smoothed.<br>
+<br>
+Line antialiasing can be enabled or disabled with the commands <span
+ style="font-weight: bold;">glEnable</span>(GL_LINE_SMOOTH) and <span
+ style="font-weight: bold;">glDisable</span>(GL_LINE_SMOOTH).<br>
+<br>
+<h2>4.3 Polygon Rasterization</h2>
+Polygons, quadrilaterals and triangles share the same polygon
+rasterization options. <br>
+<br>
+Triangles are rendered by the command sequence <span
+ style="font-weight: bold;">glBegin</span><span
+ style="font-style: italic;"><span style="font-style: italic;">(mode</span></span>),<span
+ style="font-weight: bold;">glVertex</span>, <span
+ style="font-weight: bold;">glVertex</span>, ... <span
+ style="font-weight: bold;">glEnd</span> where <span
+ style="font-style: italic;">mode</span> may be one of GL_TRIANGLES,
+GL_TRIANGLE_STRIP or GL_TRIANGLE_FAN.<span style="font-weight: bold;"></span>
+&nbsp;For GL_TRIANGLES mode, the number of vertices should be a multiple
+of three - extra vertices will be ignored. &nbsp;For GL_TRIANGLE_STRIP
+and GL_TRIANGLE_FAN, at least three vertices should be specified.
+&nbsp;If less than three are specified, nothing is drawn. &nbsp;<br>
+<br>
+Quadrilaterals are <span style="font-weight: bold;"></span>rendered by
+the command sequence <span style="font-weight: bold;">glBegin</span>(<span
+ style="font-style: italic;"><span style="font-style: italic;">mode</span></span>),<span
+ style="font-weight: bold;">glVertex</span>, <span
+ style="font-weight: bold;">glVertex</span>, ... <span
+ style="font-weight: bold;">glEnd</span> where <span
+ style="font-style: italic;">mode</span> may be one of GL_QUADS or
+GL_QUAD_STRIP.<span style="font-weight: bold;"></span> &nbsp; For
+GL_QUADS, the number of vertices should be a multiple of four - extra
+vertices will be ignored. &nbsp;For GL_QUAD_STRIP, the number of
+vertices should be even and at least four. &nbsp;Extra vertices (one)
+will be ignored.<br>
+<br>
+Convex polygons are <span style="font-weight: bold;"></span>rendered
+by the command sequence <span style="font-weight: bold;">glBegin</span><span
+ style="font-style: italic;"><span style="font-style: italic;"></span></span>(GL_POLYGON),<span
+ style="font-weight: bold;">glVertex</span>, <span
+ style="font-weight: bold;">glVertex</span>, ... <span
+ style="font-weight: bold;">glEnd</span>.<span
+ style="font-style: italic;"></span><span style="font-weight: bold;"></span>
+&nbsp;If less than three vertices are specified, nothing is drawn.<br>
+<br>
+<h3>4.3.1 Polygon Orientation</h3>
+The <span style="font-style: italic;">winding order</span> of vertices
+(clockwise or counter-clockwise) is significant. &nbsp;It is used to
+determine the <span style="font-style: italic;">front-facing</span> or <span
+ style="font-style: italic;">back-facing</span> orientation of polygons.
+&nbsp;By default, a front-facing polygon's vertices are in
+counter-clockwise order (in window coordinates). &nbsp;Figures 2.4 and
+2.5 of the OpenGL 1.2.1 specification illustrate the winding order for
+front-facing triangles and quadrilaterals, respectively.<br>
+<br>
+The command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glFrontFace</span>(GLenum<span
+ style="font-style: italic;"> mode</span>)<br>
+</div>
+<br>
+specifies whether clockwise or counter-clockwise winding indicates a
+front-facing polygon. &nbsp;If <span style="font-style: italic;">mode</span>
+is GL_CW then polygons with clockwise winding are front-facing. &nbsp;If <span
+ style="font-style: italic;">mode</span> is GL_CCW then polygons with
+counter-clockwise winding are front-facing. &nbsp;The default value is
+GL_CCW. &nbsp;If <span style="font-style: italic;">mode</span> is not
+GL_CCW or GL_CW then the error GL_INVALID_ENUM will be raised.<span
+ style="font-style: italic;"></span><span style="font-style: italic;"></span><br>
+<br>
+<h3>4.3.2 Polygon Culling</h3>
+Polygons may be culled (discarded) depending on whether they are
+front-facing or back-facing. &nbsp;The command<br>
+<br>
+<div style="margin-left: 40px;">void<span style="font-weight: bold;">
+glCullFace</span>(GLenum <span style="font-style: italic;">mode</span>)<br>
+</div>
+<br>
+specifies whether front-facing, back-facing or all polygons should be
+culled. &nbsp;If <span style="font-style: italic;">mode</span> is
+GL_FRONT then front-facing polygons will be culled. &nbsp;If <span
+ style="font-style: italic;">mode</span> is GL_BACK then back-facing
+polygons will be culled. Otherwise, if <span style="font-style: italic;">mode</span>
+is GL_FRONT_AND_BACK then all polygons will be culled. &nbsp;Any other
+value for <span style="font-style: italic;">mode</span> will raise the
+error GL_INVALID_ENUM.<br>
+<br>
+Polygon culling is enabled and disabled with the commands <span
+ style="font-weight: bold;">glEnable</span>(GL_CULL_FACE) and <span
+ style="font-weight: bold;">glDisable</span>(GL_CULL_FACE),
+respectively.<br>
+<br>
+<h3>4.3.3 Polygon Antialiasing</h3>
+Polygons may be antialiased in order to smooth their edges.
+&nbsp;Polygon antialiasing is enabled and disabled with the commands <span
+ style="font-weight: bold;">glEnable</span>(GL_POLYGON_SMOOTH) and <span
+ style="font-weight: bold;">glDisable</span>(GL_POLYGON_SMOOTH).<br>
+<br>
+When polygon antialiasing is enabled each fragment produced by polygon,
+triangle and quadrilateral rasterization will be given a <span
+ style="font-style: italic;">coverage</span> value which indicates how
+much of the fragment is covered by the polygon. &nbsp;Fragments
+completely inside the polygon have coverage 1.0. &nbsp;Fragments
+completely outside the polygon have zero coverage (in theory).
+&nbsp;Fragments which intersect the polygon's edge have a coverage value
+in the range (0, 1).<br>
+<br>
+The fragment's alpha value is multiplied by the coverage value.
+&nbsp;By enabling the appropriate blending mode, polygon edges will
+appear smoothed.<br>
+<br>
+<h2>4.4 Shading</h2>
+The command<br>
+<br>
+<div style="margin-left: 40px;"> void <span style="font-weight: bold;">glShadeModel</span>(GLenum<span
+ style="font-style: italic;">mode</span>)<br>
+</div>
+<br>
+determines whether colors are interpolated between vertices during
+rasterization. &nbsp;If <span style="font-style: italic;">mode</span> is
+GL_FLAT then vertex colors are not interpolated. &nbsp;The color used
+for drawing lines, triangles and quadrilaterals is that of the last
+vertex used to specify each primitive. &nbsp;For polygons, the color of
+the first vertex specifies the color for the entire polygon. &nbsp;If <span
+ style="font-style: italic;">mode</span> is GL_SMOOTH then vertex colors
+are linearly interpolated to produce the fragment colors.<br>
+<br>
+<h2>4.5 Bitmap Rasterization</h2>
+A bitmap is a monochromatic, binary image in which each image element
+(or pixel) is represented by one bit. &nbsp;Fragments are only generated
+for the bits (pixels) which are set. &nbsp;Bitmaps are commonly used to
+draw text (glyphs) and markers.<br>
+<br>
+A bitmap is drawn with the command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glBitmap</span>(GLsizei<span
+ style="font-style: italic;">width</span>, GLsizei <span
+ style="font-style: italic;">height</span>, GLfloat <span
+ style="font-style: italic;">xOrig</span>, GLfloat <span
+ style="font-style: italic;">yOrig</span>, GLfloat <span
+ style="font-style: italic;">xMove</span>, GLfloat <span
+ style="font-style: italic;">yMove</span>, const &nbsp;GLubyte *<span
+ style="font-style: italic;">image</span>)<br>
+</div>
+<br>
+<span style="font-style: italic;">width </span>and <span
+ style="font-style: italic;">height</span> specify the image size in
+pixels. &nbsp;<span style="font-style: italic;">xOrig</span> and <span
+ style="font-style: italic;">yOrig</span> specify the bitmap origin.
+&nbsp;<span style="font-style: italic;">xMove</span> and <span
+ style="font-style: italic;">yMove</span> are added to the current
+raster position after the bitmap is rasterized. &nbsp;<span
+ style="font-style: italic;">image</span> is a pointer to the bitmap
+data.<br>
+<br>
+If the current raster position is not valid, <span
+ style="font-weight: bold;">glBitmap</span> has no effect.<br>
+<br>
+<h3>4.5.1 Bitmap Unpacking</h3>
+The first step in bitmap rendering is <span style="font-style: italic;">unpacking.
+&nbsp;</span>Unpacking is the process of extracting image data from
+client memory subject to byte swapping, non-default row strides, etc.
+&nbsp;The unpacking parameters are specified with the command<br>
+<br>
+<div style="margin-left: 40px;">void<span style="font-weight: bold;">
+glPixelStorei</span>(GLenum pname, GLint value)<br>
+</div>
+<span style="font-style: italic;"></span><br>
+The following unpacking parameters may be set:<br>
+<br>
+<table cellpadding="2" cellspacing="2" border="1"
+ style="text-align: left; width: 90%; margin-left: auto; margin-right: auto;">
+ <tbody>
+ <tr>
+ <td style="vertical-align: top;">Parameter (<span
+ style="font-style: italic;">pname</span>)<br>
+ </td>
+ <td style="vertical-align: top;">Value (<span
+ style="font-style: italic;">value</span>)<br>
+ </td>
+ <td style="vertical-align: top;">Default<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_UNPACK_ROW_LENGTH<br>
+ </td>
+ <td style="vertical-align: top;">Width of the image in memory, in
+pixels.<br>
+ </td>
+ <td style="vertical-align: top;">0<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_UNPACK_LSB_FIRST<br>
+ </td>
+ <td style="vertical-align: top;">GL_FALSE indicates that the most
+significant bit is unpacked first from each byte. &nbsp;GL_TRUE
+indicates that the least significant bit is unpacked first from each
+byte. <br>
+ </td>
+ <td style="vertical-align: top;">GL_FALSE<br>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<br>
+<br>
+The GL_UNPACK_ROW_LENGTH specifies the stride (in pixels) for advancing
+from one row of the image to the next.&nbsp; If it's zero, the <span
+ style="font-style: italic;">width</span> parameter to <span
+ style="font-weight: bold;">glBitmap</span> specifies the width of the
+image in memory.<br>
+<br>
+GL_UNPACK_LSB_FIRST determines whether the least significant or most
+significant bit in each byte is unpacked first. &nbsp;Unpacking occurs
+in left to right order (in image space).<br>
+<br>
+The value of bit (i, j) of the image (where i is the image row and j is
+the image column) is found as follows:<br>
+<br>
+<div style="margin-left: 40px;">rowLength = (GL_UNPACK_ROW_LENGTH != 0)
+? GL_UNPACK_ROW_LENGTH : <span style="font-style: italic;">width</span>;<br>
+<br>
+byte = <span style="font-style: italic;">image</span>[((rowLength + 7)
+/ 8) * i + j / 8];<br>
+<br>
+if (GL_UNPACK_LSB_FIRST != 0)<br>
+&nbsp;&nbsp;&nbsp; bitMask = 1 &lt;&lt; (j % 8);<br>
+else<br>
+&nbsp;&nbsp;&nbsp; bitMask = 128 &gt;&gt; (j % 8);<br>
+<br>
+if (byte &amp; bitMask)<br>
+&nbsp;&nbsp;&nbsp; bit = 1;<br>
+else<br>
+&nbsp;&nbsp;&nbsp; bit = 0;<br>
+<br>
+</div>
+<span style="font-style: italic;"><span style="font-style: italic;"></span></span>
+<h3>4.5.2 Rasterization</h3>
+If the current raster position is (x<sub>rp</sub>, y<sub>rp</sub>, z<sub>rp</sub>,
+w<sub>rp</sub>), then the bitmap is rasterized according to the
+following algorithm:<br>
+<br>
+for (j = 0; j &lt; <span style="font-style: italic;">height</span>;
+j++) {<br>
+&nbsp;&nbsp;&nbsp; for (i = 0; i &lt; <span style="font-style: italic;">width</span>;
+i++) {<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if (bit(i,j)) {<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fragment.x =
+floor(x<sub>rp</sub> - <span style="font-style: italic;">xOrig</span>)
++ i;<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fragment.y =
+floor(y<sub>rp</sub> - <span style="font-style: italic;">yOrig</span>)
++ j;<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; fragment.color
+= GL_CURRENT_RASTER_COLOR;<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
+fragment.texture = GL_CURRENT_RASTER_TEXTURE_COORDS;<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
+ProcessFragment(fragment)<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>
+&nbsp;&nbsp;&nbsp; }<br>
+}<br>
+<br>
+After the bitmap has been rendered the current raster position is
+updated as follows:<br>
+<br>
+<div style="margin-left: 40px;">x<sub>rp</sub> = x<sub>rp</sub> + <span
+ style="font-style: italic;">xMove</span><br>
+y<sub>rp</sub> = y<sub>rp</sub> + <span style="font-style: italic;">yMove</span><br>
+</div>
+<br>
+<h3>4.5.3 Per-fragment Operations</h3>
+XXX supported? &nbsp;See issue in appendix A.<br>
+<br>
+<h2>4.6 Unsupported Commands</h2>
+The following commands related to rasterization are not supported by
+the subset.<br>
+<br>
+<div style="margin-left: 40px;">Point commands:<br>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glPointSize</span><br>
+</div>
+<br>
+Polygon commands:<br>
+<div style="margin-left: 40px; font-weight: bold;">glPolygonStipple<br>
+glPolygonOffset<br>
+glPolygonMode<br>
+<br>
+</div>
+</div>
+<div style="margin-left: 40px;">Pixel storage commands:<br>
+</div>
+<div style="font-weight: bold; margin-left: 80px;">glPixelStoref<br>
+</div>
+<br>
+<br>
+<h1>5. Texture Mapping<br>
+</h1>
+There are four elements to texture mapping: texture coordinate
+specification, texture image specification, texture sampling and texture
+application.<br>
+<br>
+Texture mapping is enabled and disabled with the commands <span
+ style="font-weight: bold;">glEnable</span>(GL_TEXTURE_2D) and <span
+ style="font-weight: bold;">glDisable</span>(GL_TEXTURE_2D).<br>
+<br>
+<h2>5.1 Texture Image Specification</h2>
+A texture image is specified with the command:<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glTexImage2D</span>(GLenum<span
+ style="font-style: italic;"> target</span>, GLint <span
+ style="font-style: italic;">level</span>, GLint <span
+ style="font-style: italic;">internalFormat,</span> GLsizei <span
+ style="font-style: italic;">width,</span> GLsizei <span
+ style="font-style: italic;">height,</span> GLint <span
+ style="font-style: italic;">border,</span> GLenum <span
+ style="font-style: italic;">format,</span> GLenum <span
+ style="font-style: italic;">type,</span> const GLvoid *<span
+ style="font-style: italic;">pixels</span> )<br>
+</div>
+<br>
+<span style="font-style: italic;">target</span> must be GL_TEXTURE_2D.
+&nbsp;<span style="font-style: italic;">level </span>indicates the
+mipmap level for mipmap textures. &nbsp;<span style="font-style: italic;">internalFormat</span>
+is a hint to indicate the preferred internal storage format for the
+texture. &nbsp;<span style="font-style: italic;">width</span> and <span
+ style="font-style: italic;">height </span>indicate the image size in
+pixels (or texels). &nbsp;<span style="font-style: italic;">border </span>must
+be zero. &nbsp;<span style="font-style: italic;">format</span> and <span
+ style="font-style: italic;">type</span> describe the pixel format and
+data type for the incoming image. &nbsp;<span style="font-style: italic;">pixels</span>
+points to the incoming texture image. &nbsp;These parameters are
+described in more detail below.<br>
+<br>
+<h3>5.1.1 Texture Image Size and Mipmaps</h3>
+<h3><span style="font-style: italic;"></span></h3>
+Texture images must have dimensions (width and height) that are powers
+of two. For example: 256 x 256, 32 x 1024, 1 x 8, etc. &nbsp;That is, it
+must be the case that <span style="font-style: italic;">width </span>=
+2<sup>n</sup> and <span style="font-style: italic;">height</span> = 2<sup>m</sup>
+for some positive integers n and m.<br>
+<br>
+Mipmapping is a method of antialiasing or filtering textures to improve
+their appearance. &nbsp;A mipmap is a set of images consisting of a base
+image and a set of filtered, reduced-resolution images. &nbsp;If the
+base image (<span style="font-style: italic;">level</span>=0) is of
+width 2<sup>n</sup> and height 2<sup>m</sup> then the level 1 image must
+be of width 2<sup>n-1</sup> and height 2<sup>m-1</sup>. &nbsp;Each mipmap
+level is half the width and height of the previous level, or at least
+one. &nbsp;The last mipmap level has a width and height of one.<br>
+<br>
+The following is an example of a mipmap's image levels:<br>
+<br>
+<table cellpadding="2" cellspacing="2" border="1"
+ style="text-align: left; width: 50%; margin-left: auto; margin-right: auto;">
+ <tbody>
+ <tr>
+ <td style="vertical-align: top;">mipmap level<br>
+ </td>
+ <td style="vertical-align: top;">width<br>
+ </td>
+ <td style="vertical-align: top;">height<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">0<br>
+ </td>
+ <td style="vertical-align: top;">256<br>
+ </td>
+ <td style="vertical-align: top;">64<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">128<br>
+ </td>
+ <td style="vertical-align: top;">32<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">2<br>
+ </td>
+ <td style="vertical-align: top;">64<br>
+ </td>
+ <td style="vertical-align: top;">16<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">3<br>
+ </td>
+ <td style="vertical-align: top;">32<br>
+ </td>
+ <td style="vertical-align: top;">8<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">4<br>
+ </td>
+ <td style="vertical-align: top;">16<br>
+ </td>
+ <td style="vertical-align: top;">4<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">5<br>
+ </td>
+ <td style="vertical-align: top;">8<br>
+ </td>
+ <td style="vertical-align: top;">2<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">6<br>
+ </td>
+ <td style="vertical-align: top;">4<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">7<br>
+ </td>
+ <td style="vertical-align: top;">2<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">8<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<br>
+If the <span style="font-style: italic;">width</span> or <span
+ style="font-style: italic;">height</span> parameters are not powers of
+two, the error GL_INVALID_VALUE is raised. &nbsp;If the image levels in
+a mipmap do not satisfy the restrictions listed above the texture is
+considered to be <span style="font-style: italic;">inconsistent</span>
+and the system will behave as if the texturing is disabled.<br>
+<br>
+<h3>5.1.2 Texture Image Formats and Unpacking</h3>
+The <span style="font-weight: bold;">glTexImage2D</span> command's <span
+ style="font-style: italic;"><span style="font-weight: bold;"></span></span><span
+ style="font-style: italic;">format</span> and <span
+ style="font-style: italic;">type</span> parameters describe the format
+of the incoming texture image.&nbsp; Accepted values for <span
+ style="font-style: italic;">format</span> are GL_INTENSITY, GL_RGB and
+GL_RGBA. &nbsp;The <span style="font-style: italic;">type</span>
+parameter must be GL_UNSIGNED_BYTE. &nbsp;Pixel component values are
+thus in the range 0 through 255.<br>
+<br>
+If <span style="font-style: italic;">format</span> is GL_INTENSITY then
+the image has one byte per pixel which specifies the pixel's red, green,
+blue and alpha values.<span style="font-style: italic;"></span><br>
+<br>
+If <span style="font-style: italic;">format</span> is GL_RGB then the
+image has three bytes per pixel which specify the pixel's red, green and
+blue values (in that order). &nbsp;The alpha value defaults to 255.<br>
+<br>
+If <span style="font-style: italic;">format</span> is GL_RGBA then the
+image has four bytes per pixel which specify the pixel's red, green,
+blue and alpha values (in that order).<br>
+<br>
+The command<br>
+<br>
+<div style="margin-left: 40px;">void<span style="font-weight: bold;">
+glPixelStorei</span>(GLenum <span style="font-style: italic;">pname</span>,
+GLint <span style="font-style: italic;">value</span>)<br>
+</div>
+<br>
+controls the unpacking of texture image data from client memory. &nbsp;<span
+ style="font-style: italic;">pname</span> may be GL_UNPACK_ROW_LENGTH to
+indicate the stride, in pixels, between subsequent rows of the image in
+client memory. &nbsp;If GL_UNPACK_ROW_LENGTH is zero (the default) then
+the <span style="font-style: italic;">width</span> parameter to <span
+ style="font-weight: bold;">glTexImage2D </span>determines the stride.<span
+ style="font-style: italic;"></span><br>
+<br>
+<h3>5.1.3 Internal Texture Format</h3>
+<span style="font-weight: bold;">glTexImage2D<span
+ style="font-style: italic;"> </span></span>converts the incoming
+texture image to one of the supported internal texture formats.<br>
+<br>
+The <span style="font-style: italic;">internalFormat</span> parameter
+indicates the desired internal format for the texture and may be either
+GL_INTENSITY8, GL_RGB5 or GL_RGBA8.<br>
+<br>
+If <span style="font-style: italic;">internalFormat</span> is
+GL_INTENSITY8 then the texture has one byte per texel (texture element)
+which indicates the texel's intensity (or brightness). &nbsp;The
+intensity is obtained from the incoming image's red channel.<br>
+<br>
+If <span style="font-style: italic;">internalFormat</span> is GL_RGB5
+then the texture is stored with two bytes per texel: &nbsp;5 bits per
+red value, 5 bits per green value and 5 bits per blue value.<br>
+<br>
+If <span style="font-style: italic;">internalFormat </span>is
+GL_RGBA8 then the texture is stored with four bytes per texel: &nbsp;8
+bits for each of the red, green, &nbsp;blue and alpha values.<br>
+<br>
+The internal format is also significant to texture application (see
+section 5.4).<br>
+<br>
+<h2>5.2 Texture Coordinates</h2>
+Texture coordinates control the mapping from local polygon space to
+texture image space. &nbsp;Texture coordinates are set for each vertex
+with the <span style="font-weight: bold;">glTexCoord</span> commands.
+&nbsp;During line and polygon rasterization the vertex's texture
+coordinates are interpolated across the primitive to produce a texture
+coordinate for each fragment. &nbsp;The fragment texture coordinates are
+used to sample the current texture image.<br>
+<br>
+Texture coordinates are normally in the range [0, 1]. &nbsp;Values
+outside that range are processed according to the <span
+ style="font-style: italic;">texture wrap mode</span>. &nbsp;The
+texture wrap mode is set with the command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glTexParameteri</span>(GLenum<span
+ style="font-style: italic;"> target</span>, GLenum <span
+ style="font-style: italic;">pname</span>, GLint <span
+ style="font-style: italic;">value</span>)<br>
+<br>
+</div>
+<span style="font-style: italic;">target</span> must be GL_TEXTURE_2D.
+&nbsp;If <span style="font-style: italic;">pname</span> is
+GL_TEXTURE_WRAP_S or GL_TEXTURE_WRAP_T then <span
+ style="font-style: italic;">value</span> must be either
+GL_CLAMP_TO_EDGE or GL_REPEAT.<br>
+<br>
+For GL_CLAMP_TO_EDGE, texture coordinates are effectively clamped to
+the interval [0, 1].<br>
+<br>
+For GL_REPEAT, the integer part of texture coordinates is ignored; only
+the fractional part of the texture coordinates is used. &nbsp;This
+allows texture images to repeated or tiled across an object.<br>
+<br>
+<h2>5.3 Texture Sampling</h2>
+Texture sampling is the process of using texture coordinates to extract
+a color from the texture image. &nbsp;Multiple, weighted samples may be
+taken from the texture and combined during the filtering step.<br>
+<br>
+During texture coordinate interpolation a <span
+ style="font-style: italic;">level of detail</span> value (lambda) is
+computed for each fragment. &nbsp;For a mipmapped texture, lambda
+determines which level (or levels) of the mipmap will be sampled to
+obtain the texture color.<br>
+<br>
+If lambda indicates that multiple texels map to a single screen pixel,
+then the texture <span style="font-style: italic;">minification</span>
+filter will be used. &nbsp;Otherwise, if lambda indicates that a single
+texel maps to multiple screen pixels, then the texture <span
+ style="font-style: italic;">magnification</span> filter will be used.<br>
+<span style="font-weight: bold;"></span><span
+ style="font-style: italic;"></span><br>
+<h3>5.3.1 Texture Minification</h3>
+The texture minification filter is set with the <span
+ style="font-weight: bold;">glTexParameteri </span><span
+ style="font-style: italic;"></span><span style="font-weight: bold;"></span><span
+ style="font-style: italic;"></span> command by setting <span
+ style="font-style: italic;">target</span> to GL_TEXTURE_2D, setting <span
+ style="font-style: italic;">pname</span> to GL_TEXTURE_MIN_FILTER and
+setting <span style="font-style: italic;">value</span> to GL_NEAREST,
+GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST,&nbsp;
+GL_NEAREST_MIPMAP_LINEAR,&nbsp; &nbsp;GL_LINEAR_MIPMAP_NEAREST or
+GL_LINEAR_MIPMAP_LINEAR.<br>
+<br>
+GL_NEAREST samples the texel nearest the texture coordinate in the
+level 0 texture image.<br>
+<br>
+GL_LINEAR samples the four texels around the texture coordinate in the
+level 0 texture image. &nbsp;The four texels are linearly weighted to
+compute the final texel value.<br>
+<br>
+GL_NEAREST_MIPMAP_NEAREST samples the texel nearest the texture
+coordinate in the level N texture image. &nbsp;N is the level of detail
+and is computed by the partial derivatives of the texture coordinates
+with respect to the window coordinates.<br>
+<br>
+GL_NEAREST_MIPMAP_LINEAR samples two texels nearest the texture
+coordinates in the level N and N+1 texture images. &nbsp;The two texels
+are linearly weighted to compute the final texel value. &nbsp;N is the
+level of detail and is computed by the partial derivatives of the
+texture coordinates with respect to the window coordinates.<br>
+<br>
+GL_LINEAR_MIPMAP_NEAREST samples four texels around the texture
+coordinate in the level N texture image. &nbsp;The four texels are
+linearly weighted to compute the final texel value. &nbsp;N is the level
+of detail and is computed by the partial derivatives of the texture
+coordinates with respect to the window coordinates.<br>
+<br>
+GL_LINEAR_MIPMAP_LINEAR samples four texels around the texture
+coordinate in the level N texture image and four texels around the
+texture coordinate in the level N+1 texture image. &nbsp;The eight
+texels are linearly weighted to compute the final texel value. &nbsp;N
+is the level of detail and is computed by the partial derivatives of the
+texture coordinates with respect to the window coordinates.<br>
+<br>
+Filter modes other than GL_LINEAR and GL_NEAREST requires that the
+texture have a complete set of mipmaps. &nbsp;If the mipmap is
+incomplete, it is as if texturing is disabled.<br>
+&nbsp;<br>
+<h3>5.3.2 Texture Magnification</h3>
+The texture magnification filter is set with the <span
+ style="font-weight: bold;">glTexParameteri </span><span
+ style="font-style: italic;"></span><span style="font-weight: bold;"></span>command
+by setting <span style="font-style: italic;">target</span> to
+GL_TEXTURE_2D, setting <span style="font-style: italic;">pname</span> to
+GL_TEXTURE_MAG_FILTER and setting <span style="font-style: italic;">value</span>
+to GL_NEAREST or GL_LINEAR.<br>
+<br>
+GL_NEAREST samples the texel nearest the texture coordinate in the
+level 0 texture image.<br>
+<br>
+GL_LINEAR samples the four texels around the texture coordinate in the
+level 0 texture image. &nbsp;The four texels are linearly weighted to
+compute the final texel value.<br>
+<br>
+<h2>5.4 Texture Application</h2>
+The sampled texture value is combined with the incoming fragment color
+to produce a new fragment color. &nbsp;The fragment and texture colors
+are combined according to the texture environment mode and the current
+texture's base internal format. &nbsp;The texture environment mode is
+set with the command<br>
+<br>
+<div style="margin-left: 40px;">void<span style="font-weight: bold;">
+glTexEnvi</span>(GLenum <span style="font-style: italic;">target</span>,
+GLenum <span style="font-style: italic;">pname</span>, GLint <span
+ style="font-style: italic;">value</span>)<br>
+</div>
+<br>
+<span style="font-style: italic;">target</span> must be GL_TEXTURE_ENV.
+&nbsp;If <span style="font-style: italic;">pname</span> is
+GL_TEXTURE_ENV_MODE then <span style="font-style: italic;">value</span>
+must be one of GL_REPLACE, GL_MODULATE, GL_DECAL, or GL_BLEND.<br>
+<br>
+There is also a <span style="font-style: italic;">texture environment
+color</span> that can factor into texture application. &nbsp;The texture
+environment color can be set with the command<br>
+<br>
+<div style="margin-left: 40px;">void<span style="font-weight: bold;">
+glTexEnvfv</span>(GLenum <span style="font-style: italic;">target</span>,
+GLenum <span style="font-style: italic;">pname</span>, const GLfloat *<span
+ style="font-style: italic;">value</span>)<br>
+</div>
+<span style="font-style: italic;"></span><br>
+<span style="font-style: italic;">target</span> must be GL_TEXTURE_ENV.
+&nbsp;If <span style="font-style: italic;">pname</span> is
+GL_TEXTURE_ENV_COLOR then <span style="font-style: italic;">value </span>must
+point to an array of four values which specify the red, green, blue,
+and alpha values of the texture environment color. &nbsp;The values are
+clamped to the range [0, 1]. &nbsp;The default color is (0, 0, 0, 0).<br>
+<span style="font-style: italic;"></span><br>
+The following table describes the arithmetic used for each combination
+of environment mode and base internal format. &nbsp;(Rf, Gf, Bf, Af) is
+the incoming fragment color. &nbsp;(Rt, Gt, Bt, At) is the sampled
+texture color. &nbsp;Lt is the sampled texture luminance. &nbsp;<span
+ style="font-style: italic;"></span>'It' is the sampled texture
+intensity. &nbsp;(Rc, Gc, Bc, Ac) is the texture environment color.
+&nbsp;(Rv, Gv, Bv, Av) is the resulting value.<br>
+<br>
+<br>
+<table cellpadding="2" cellspacing="2" border="1"
+ style="text-align: left; width: 90%; margin-left: auto; margin-right: auto;">
+ <tbody>
+ <tr>
+ <td style="vertical-align: top;">Base Internal Format<br>
+ </td>
+ <td style="vertical-align: top;">GL_REPLACE<br>
+ </td>
+ <td style="vertical-align: top;">GL_MODULATE<br>
+ </td>
+ <td style="vertical-align: top;">GL_DECAL<br>
+ </td>
+ <td style="vertical-align: top;">GL_BLEND<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_INTENSITY<br>
+ </td>
+ <td style="vertical-align: top;">Rv = It<br>
+Gv = It<br>
+Bv = It<br>
+Bf = It<br>
+ </td>
+ <td style="vertical-align: top;">Rv = Rf * It<br>
+Gv = Gf * It<br>
+Bv = Bf * It<br>
+Av = Af * It</td>
+ <td style="vertical-align: top;">undefined<br>
+ </td>
+ <td style="vertical-align: top;">Rv = Rf*(1-It) + Rc*It<br>
+Gv = Gf*(1-It) + Gc*It<br>
+Bv = Bf*(1-It) + Bc*It<br>
+Av = Af*(1-It) + Ac*It</td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_RGB<br>
+ </td>
+ <td style="vertical-align: top;">Rv = Rt<br>
+Gv = Gt<br>
+Bv = Bt<br>
+Av = Af<br>
+ </td>
+ <td style="vertical-align: top;">Rv = Rf * Rt<br>
+Gv = Gf * Gt<br>
+Bv = Bf * Bt<br>
+Av = Af<br>
+ </td>
+ <td style="vertical-align: top;">Rv = Rt<br>
+Gv = Gt<br>
+Bv = Bt<br>
+Av = Af</td>
+ <td style="vertical-align: top;">Rv = Rf*(1-Rt) + Rc*Rt<br>
+Gv = Gf*(1-Gt) + Gc*Gt<br>
+Bv = Bf*(1-Bt) + Bc*Bt<br>
+Av = Af</td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_RGBA<br>
+ </td>
+ <td style="vertical-align: top;">Rv = Rt<br>
+Gv = Gt<br>
+Bv = Bt<br>
+Av = At<br>
+ </td>
+ <td style="vertical-align: top;">Rv = Rf * Rt<br>
+Gv = Gf * Gt<br>
+Bv = Bf * Bt<br>
+Av = Af * At</td>
+ <td style="vertical-align: top;">Rv = Rf*(1-At) + Rt*At<br>
+Gv = Gf*(1-At) + Gt*At<br>
+Bv = Bf*(1-At) + Bt*At<br>
+Av = Af<br>
+ </td>
+ <td style="vertical-align: top;">Rv = Rf*(1-Rt) + Rc*Rt<br>
+Gv = Gf*(1-Gt) + Gc*Gt<br>
+Bv = Bf*(1-Bt) + Bc*Bt<br>
+Av = Af*At</td>
+ </tr>
+ </tbody>
+</table>
+<br>
+<br>
+<br>
+<h2>5.5 Texture Objects</h2>
+Texture objects encapsulate a set of texture images (mipmap) and
+related state into a named object. &nbsp;This facilitates use of
+multiple textures in an application. &nbsp;Texture objects are named
+with GLuints (unsigned integers). &nbsp;There is a default texture
+object with the name/identifier zero which can never be deleted.<br>
+<br>
+<h3>5.5.1 Creating Texture Objects</h3>
+A texture object is created by binding a new GLuint identifier to the
+GL_TEXTURE_2D target with the command:<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glBindTexture</span>(GLenum<span
+ style="font-style: italic;"> target</span>, GLuint <span
+ style="font-style: italic;">textureID</span>)<br>
+</div>
+<br>
+<span style="font-style: italic;">target</span> must be GL_TEXTURE_2D.
+&nbsp;<span style="font-style: italic;">textureID</span> may be any
+unsigned integer. &nbsp;If <span style="font-style: italic;">textureID</span>
+does not name an existing texture object, a new texture object with that
+ID will be created, initialized to the default state. &nbsp;Whether the
+ID is new or existed previously, that named texture object is bound as
+the <span style="font-style: italic;">current texture object</span>.
+&nbsp;Subsequent <span style="font-weight: bold;">glTexParameter </span>and<span
+ style="font-weight: bold;">glTexImage2D<span
+ style="font-style: italic;"> </span></span>calls will effect the
+current texture object.<br>
+<span style="font-style: italic;"></span><span
+ style="font-weight: bold;"><span style="font-style: italic;"> </span></span><br>
+<h3>5.5.2 Deleting Texture Objects</h3>
+One or more texture objects may be deleted with the command:<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glDeleteTextures</span>(GLsizei<span
+ style="font-style: italic;">n</span>, const GLuint *<span
+ style="font-style: italic;">textureIDs</span>)<br>
+</div>
+<br>
+<span style="font-style: italic;">textureIDs</span> is an array of <span
+ style="font-style: italic;">n</span> texture IDs. &nbsp;The named
+texture objects will be deleted. &nbsp;If the current texture object is
+deleted the default texture object (number 0) will be bound as the
+current texture object.<br>
+<br>
+<h3>5.5.3 Allocating Texture Object Identifiers</h3>
+A list of new, unused texture IDs can be obtained by calling the command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glGenTextures</span>(GLsizei<span
+ style="font-style: italic;"> n</span>, GLuint *<span
+ style="font-style: italic;">textureIDs</span>)<br>
+</div>
+<br>
+An array of <span style="font-style: italic;">n</span> unused texture
+IDs will be returned in the <span style="font-style: italic;">textureIDs</span>
+array.<br>
+<br>
+<br>
+<h1>6. Per-fragment Operations</h1>
+The fragments produced by rasterization are subjected to a number of
+operations which either modify the fragment or test the fragment
+(discarding the fragment if the test fails.) &nbsp;This chapter
+describes the per-fragment operations. &nbsp;They are presented in the
+order in which they're performed. &nbsp;If a fragment fails a test it is
+discarded and not subjected to subsequent tests or modifications.<br>
+<br>
+<h2>6.1 Scissor Test</h2>
+The scissor test limits rendering to a 2-D rectangular region of the
+framebuffer. &nbsp;The command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glScissor</span>(GLint<span
+ style="font-style: italic;">x</span>, GLint <span
+ style="font-style: italic;">y</span>, GLsizei <span
+ style="font-style: italic;">width</span>, GLsizei<span
+ style="font-style: italic;"> height</span>)<br>
+</div>
+<br>
+defines a clipping region with the lower-left corner at (<span
+ style="font-style: italic;">x, y</span>) and the given <span
+ style="font-style: italic;">width</span> and <span
+ style="font-style: italic;">height</span>. &nbsp;The scissor test is
+enabled and disabled with the command <span style="font-weight: bold;">glEnable</span>(GL_SCISSOR_TEST)
+and <span style="font-weight: bold;">glDisable</span>(GL_SCISSOR_TEST).<br>
+<br>
+If the incoming fragment's position is (x<sub>f</sub>, y<sub>f</sub>)
+then the fragment will pass the test if <span
+ style="font-style: italic;">x</span> &lt;= x<sub>f</sub> &lt; <span
+ style="font-style: italic;">x</span> + <span
+ style="font-style: italic;">width</span> and <span
+ style="font-style: italic;">y</span> &lt;= y<sub>f</sub> &lt; <span
+ style="font-style: italic;">y</span> + <span
+ style="font-style: italic;">height. &nbsp;</span>Otherwise, the
+fragment is discarded.<br>
+<br>
+If <span style="font-style: italic;">width</span> or <span
+ style="font-style: italic;">height</span> is less than zero the error
+GL_INVALID_VALUE is raised. &nbsp;The default scissor rectangle bounds
+are (0, 0, w, h) where w is the initial window width and h is the
+initial window height. &nbsp;The scissor test is disabled by default.<br>
+<br>
+<h2>6.2 Alpha Test</h2>
+The alpha test compares the fragment's alpha value against a reference
+value and discards the fragment if the comparison fails. &nbsp;The test
+is specified by the command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glAlphaFunc</span>(GLenum<span
+ style="font-style: italic;">mode</span>, GLclampf <span
+ style="font-style: italic;">reference</span>)<br>
+</div>
+<br>
+<span style="font-style: italic;">mode</span> specifies an inequality
+and <span style="font-style: italic;">reference</span> specifies a value
+to compare against. &nbsp;The following table lists all possible
+modes&nbsp;<span style="font-style: italic;"></span>and the
+corresponding test:<br>
+<br>
+<table cellpadding="2" cellspacing="2" border="1"
+ style="text-align: left; width: 50%; margin-left: auto; margin-right: auto;">
+ <tbody>
+ <tr>
+ <td style="vertical-align: top;">Comparison mode<br>
+ </td>
+ <td style="vertical-align: top;">The test passes if<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_LESS<br>
+ </td>
+ <td style="vertical-align: top;">alpha &lt; <span
+ style="font-style: italic;">reference</span><br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_LEQUAL<br>
+ </td>
+ <td style="vertical-align: top;">alpha &lt;= <span
+ style="font-style: italic;">reference</span></td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_GREATER<br>
+ </td>
+ <td style="vertical-align: top;">alpha &gt; <span
+ style="font-style: italic;">reference</span></td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_GEQUAL<br>
+ </td>
+ <td style="vertical-align: top;">alpha &gt;= <span
+ style="font-style: italic;">reference</span></td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_EQUAL<br>
+ </td>
+ <td style="vertical-align: top;">alpha == <span
+ style="font-style: italic;">reference</span></td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_NOTEQUAL<br>
+ </td>
+ <td style="vertical-align: top;">alpha != <span
+ style="font-style: italic;">reference</span></td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_NEVER<br>
+ </td>
+ <td style="vertical-align: top;">never pass<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_ALWAYS<br>
+ </td>
+ <td style="vertical-align: top;">always passes<br>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<br>
+The <span style="font-style: italic;">reference</span> parameter is
+clamped to the range [0, 1].<br>
+<br>
+The alpha test is enabled and disabled with the commands <span
+ style="font-weight: bold;">glEnable</span>(GL_ALPHA_TEST) and <span
+ style="font-weight: bold;">glDisable</span>(GL_ALPHA_TEST).<br>
+<br>
+The default mode is GL_ALWAYS and the default reference value is 0.<br>
+<br>
+<h2>6.3 Stencil Test</h2>
+The stencil buffer stores an N-bit integer value for each pixel in the
+frame buffer. &nbsp;The stencil test compares the stencil buffer value
+at the fragment's position to a reference value and possibly discards
+the fragment based on the outcome. &nbsp;Furthermore, the stencil buffer
+value may be updated or modified depending on the outcome. &nbsp;If
+there is no stencil buffer the stencil test is bypassed.<br>
+<br>
+Stenciling is controlled by the commands<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glStencilFunc</span>(GLenum<span
+ style="font-style: italic;">func</span>, GLint <span
+ style="font-style: italic;">ref</span>, GLuint <span
+ style="font-style: italic;">mask</span>)<br>
+void <span style="font-weight: bold;">glStencilOp</span>(GLenum <span
+ style="font-style: italic;">stencilFail</span>, GLenum <span
+ style="font-style: italic;">depthTestFail</span>, GLenum <span
+ style="font-style: italic;">depthTestPass</span>)<br>
+</div>
+<br>
+The <span style="font-weight: bold;">glStencilFunc<span
+ style="font-style: italic;"> </span></span>command controls the
+stencil test while <span style="font-weight: bold;">glStencilOp</span>
+command controls the how the stencil buffer is updated/modified after
+the test.<br>
+<br>
+<span style="font-style: italic;">ref</span> is clamped to the range [0,
+2<sup>N</sup>-1] where N is the number of bits per stencil value in the
+stencil buffer.<span style="font-style: italic;"></span><br>
+<br>
+The following table lists all possible values for the <span
+ style="font-style: italic;">func</span> parameter and when the stencil
+test will pass. &nbsp;Both the stencil buffer value and the stencil
+reference value are bit-wise ANDed with the <span
+ style="font-style: italic;">mask</span> parameter before the test.<br>
+<br>
+<span style="font-style: italic;"></span><span
+ style="font-style: italic;"></span><span style="font-style: italic;"></span>
+<table
+ style="text-align: left; margin-left: auto; margin-right: auto; width: 70%;"
+ border="1" cellspacing="2" cellpadding="2">
+ <tbody>
+ <tr>
+ <td style="vertical-align: top;">Stencil <span
+ style="font-style: italic;">func</span> value<br>
+ </td>
+ <td style="vertical-align: top;">Stencil test passes if<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_LESS<br>
+ </td>
+ <td style="vertical-align: top;"><span style="font-style: italic;">(ref</span>&amp;<span
+ style="font-style: italic;">mask)</span> &lt; (stencil buffer value
+&amp; <span style="font-style: italic;">mask)</span><br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_LEQUAL<br>
+ </td>
+ <td style="vertical-align: top;"><span style="font-style: italic;">(ref</span>
+&amp; <span style="font-style: italic;">mask) </span>&lt;= (stencil
+buffer value &amp; <span style="font-style: italic;">mask)</span></td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_GREATER<br>
+ </td>
+ <td style="vertical-align: top;"><span style="font-style: italic;">(ref</span>
+&amp; <span style="font-style: italic;">mask) </span>&gt; (stencil
+buffer value &amp; <span style="font-style: italic;">mask)</span></td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_GEQUAL<br>
+ </td>
+ <td style="vertical-align: top;"><span style="font-style: italic;">(ref</span>
+&amp; <span style="font-style: italic;">mask) </span>&gt;= (stencil
+buffer value &amp; <span style="font-style: italic;">mask)</span></td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_EQUAL<br>
+ </td>
+ <td style="vertical-align: top;"><span style="font-style: italic;">(ref</span>
+&amp; <span style="font-style: italic;">mask) </span>== (stencil
+buffer value &amp; <span style="font-style: italic;">mask)</span></td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_NOTEQUAL<br>
+ </td>
+ <td style="vertical-align: top;"><span style="font-style: italic;">(ref</span>
+&amp; <span style="font-style: italic;">mask) </span>!= (stencil
+buffer value &amp; <span style="font-style: italic;">mask)</span></td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_NEVER<br>
+ </td>
+ <td style="vertical-align: top;">never passes<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_ALWAYS<br>
+ </td>
+ <td style="vertical-align: top;">always passes<br>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<br>
+<span style="font-style: italic;"></span><br>
+If the stencil test passes, the fragment is passed to the next
+per-fragment operation. &nbsp;Otherwise, if the stencil test fails, the
+value in the stencil buffer is updated according to the value of the <span
+ style="font-style: italic;">stencilFail</span> parameter to <span
+ style="font-weight: bold;">glStencilOp</span>.<br>
+<br>
+<table cellpadding="2" cellspacing="2" border="1"
+ style="text-align: left; width: 70%; margin-left: auto; margin-right: auto;">
+ <tbody>
+ <tr>
+ <td style="vertical-align: top;"><span style="font-style: italic;">stencilFail</span>
+value<br>
+ </td>
+ <td style="vertical-align: top;">New stencil buffer value<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_KEEP<br>
+ </td>
+ <td style="vertical-align: top;">originalValue<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_ZERO<br>
+ </td>
+ <td style="vertical-align: top;">0<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_INVERT<br>
+ </td>
+ <td style="vertical-align: top;">BitWiseInvert(originalValue)
+i.e. ~originalValue<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_REPLACE<br>
+ </td>
+ <td style="vertical-align: top;"><span style="font-style: italic;">ref</span><br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_INCR<br>
+ </td>
+ <td style="vertical-align: top;">originalValue + 1, clamped to
+[0, 2<sup>N</sup>-1]</td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_DECR<br>
+ </td>
+ <td style="vertical-align: top;">originalValue - 1, clamped to
+[0, 2<sup>N</sup>-1]</td>
+ </tr>
+ </tbody>
+</table>
+<span style="font-style: italic;"></span><span
+ style="font-style: italic;"></span><br>
+<br>
+The <span style="font-style: italic;">depthTestFail</span> and <span
+ style="font-style: italic;">depthTestPass</span> parameters to <span
+ style="font-weight: bold;">glStencilOp</span> are ignored. &nbsp;Values
+for <span style="font-style: italic;">func</span> and <span
+ style="font-style: italic;">stencilFail</span> other than those listed
+in the table will cause the error GL_INVALID_ENUM to be raised.<br>
+<br>
+The stencil test is enabled and disabled with the commands <span
+ style="font-weight: bold;">glEnable</span>(GL_STENCIL_TEST) and <span
+ style="font-weight: bold;">glDisable</span>(GL_STENCIL_TEST).<br>
+<br>
+The default stencil function is GL_ALWAYS. &nbsp;The default stencil
+reference value is 0. &nbsp;The default stencil mask is ~0. &nbsp;The
+default stencil fail operation is GL_KEEP.<br>
+<br>
+Values written into the stencil buffer are masked with the command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glStencilMask</span>(GLuint<span
+ style="font-style: italic;">mask</span>)<br>
+</div>
+<br>
+Only the bits which are set in <span style="font-style: italic;">mask</span>
+will be modified in the stencil buffer when written to. &nbsp;If each
+stencil buffer value has N bits, only the least significant N bits of <span
+ style="font-style: italic;">mask</span> are relevant. &nbsp;The default
+stencil mask is ~0.<br>
+<br>
+<h2>6.4 Blending and Logicop</h2>
+Blending or a logic operation combines the incoming fragment color with
+the destination frame buffer color according to a blending equation or
+bit-wise Boolean logical operation.<br>
+<br>
+Blending is enabled and disabled with the commands <span
+ style="font-weight: bold;">glEnable</span>(GL_BLEND) and <span
+ style="font-weight: bold;">glDisable</span>(GL_BLEND).<br>
+<br>
+The logic operation is enabled and disabled with the commands <span
+ style="font-weight: bold;">glEnable</span>(GL_LOGIC_OP) and <span
+ style="font-weight: bold;">glDisable</span>(GL_LOGIC_OP).<br>
+<br>
+If both blending and the logic operation are enabled, the logic
+operation has higher priority; blending is bypassed.<br>
+<br>
+<h3>6.4.1 Logic Op</h3>
+The command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glLogicop</span>(GLenum<span
+ style="font-style: italic;">mode</span>)<br>
+<br>
+</div>
+Specifies the Boolean logic operation for combining the incoming
+fragment color with the destination frame buffer color. &nbsp;Both the
+incoming fragment color and destination frame buffer colors are
+interpreted as four-tuples of unsigned integer color components in the
+range [0, 2<sup>N</sup>-1] where N is the number of bits per color
+channel. &nbsp;N may not be the same for all color channels.<br>
+<br>
+The following table lists all values for <span
+ style="font-style: italic;">mode</span> and the boolean arithmetic used
+to combine the incoming fragment color value (src)<span
+ style="font-style: italic;"></span><span style="font-style: italic;"></span><span
+ style="font-style: italic;"></span><span style="font-style: italic;"></span><span
+ style="font-style: italic;"></span> with the destination framebuffer
+color value (dst). &nbsp;Standard ANSI C operators used.<br>
+<br>
+<table cellpadding="2" cellspacing="2" border="1"
+ style="text-align: left; width: 50%; margin-left: auto; margin-right: auto;">
+ <tbody>
+ <tr>
+ <td style="vertical-align: top;">LogicOp <span
+ style="font-style: italic;">mode</span><br>
+ </td>
+ <td style="vertical-align: top;">Resulting channel value<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_CLEAR<br>
+ </td>
+ <td style="vertical-align: top;">0<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_SET<br>
+ </td>
+ <td style="vertical-align: top;">~0<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_COPY<br>
+ </td>
+ <td style="vertical-align: top;">src<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_COPY_INVERTED<br>
+ </td>
+ <td style="vertical-align: top;">~s<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_NOOP<br>
+ </td>
+ <td style="vertical-align: top;">dst<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_INVERT<br>
+ </td>
+ <td style="vertical-align: top;">~dst<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_AND<br>
+ </td>
+ <td style="vertical-align: top;">src &amp; dst<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_NAND<br>
+ </td>
+ <td style="vertical-align: top;">~(src &amp; dst)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_AND_REVERSE<br>
+ </td>
+ <td style="vertical-align: top;">src &amp; ~dst<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_AND_INVERTED<br>
+ </td>
+ <td style="vertical-align: top;">~src &amp; dst<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_OR<br>
+ </td>
+ <td style="vertical-align: top;">src | dst<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_NOR<br>
+ </td>
+ <td style="vertical-align: top;">~(src | dst)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_OR_REVERSE<br>
+ </td>
+ <td style="vertical-align: top;">src | ~dst<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_OR_INVERTED<br>
+ </td>
+ <td style="vertical-align: top;">~src | dst<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_XOR<br>
+ </td>
+ <td style="vertical-align: top;">src ^ dst<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_EQUIV<br>
+ </td>
+ <td style="vertical-align: top;">~(src ^ dst)<br>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<br>
+The fragment's color is replaced by the result of the logic operation.<br>
+<br>
+Specifying any value for <span style="font-style: italic;">mode</span>
+other than those listed in the above table will cause the error
+GL_INVALID_ENUM to be raised.<br>
+<br>
+The default value for <span style="font-style: italic;">mode</span> is
+GL_COPY. &nbsp;The logic operation is disabled by default.<br>
+<br>
+<h3>6.4.2 Blending</h3>
+The command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glBlendFunc</span>(GLenum<span
+ style="font-style: italic;">srcTerm</span>, GLenum <span
+ style="font-style: italic;">dstTerm</span>)<br>
+</div>
+<br>
+specifies the terms of the blending equation. &nbsp;If Cf = (Rf, Gf,
+Bf, Af) is the incoming fragment color and Cb = (Rb, Gb, Bb, Ab) is the
+frame buffer color, then the resulting color Cv = (Rv, Gv, Bv, Av) is
+computed by:<br>
+<br>
+<div style="margin-left: 40px;">Cv = Cf * <span
+ style="font-style: italic;">srcTerm</span> + Cb * <span
+ style="font-style: italic;">dstTerm</span><br>
+<span style="font-style: italic;"></span></div>
+<span style="font-style: italic;"> </span><br>
+All possible values for <span style="font-style: italic;">srcTerm</span>
+and the corresponding arithmetic term are listed in the following table:<br>
+<br>
+<table cellpadding="2" cellspacing="2" border="1"
+ style="text-align: left; width: 70%; margin-left: auto; margin-right: auto;">
+ <tbody>
+ <tr>
+ <td style="vertical-align: top;"><span style="font-style: italic;">srcTerm</span><br>
+ </td>
+ <td style="vertical-align: top;"><span style="font-style: italic;">srcTerm</span>Arithmetic<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_ZERO<br>
+ </td>
+ <td style="vertical-align: top;">(0, 0, 0, 0)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_ONE<br>
+ </td>
+ <td style="vertical-align: top;">(1, 1, 1, 1)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_DST_COLOR<br>
+ </td>
+ <td style="vertical-align: top;">(Rb, Gb, Bb, Ab)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_ONE_MINUS_DST_COLOR<br>
+ </td>
+ <td style="vertical-align: top;">(1-Rb, 1-Gb, 1-Bb, 1-Ab)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_SRC_ALPHA<br>
+ </td>
+ <td style="vertical-align: top;">(Af, Af, Af, AF)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_ONE_MINUS_SRC_ALPHA<br>
+ </td>
+ <td style="vertical-align: top;">(1-Af, 1-Af, 1-Af, 1-Af)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_DST_ALPHA<br>
+ </td>
+ <td style="vertical-align: top;">(Ab, Ab, Ab, Ab)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_ONE_MINUS_DST_ALPHA<br>
+ </td>
+ <td style="vertical-align: top;">(1-Ab, 1-Ab, 1-Ab, 1-Ab)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_SRC_ALPHA_SATURATE<br>
+ </td>
+ <td style="vertical-align: top;">(m, m, m, 1) where m = MIN(Af,
+1-Ab)<br>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<br>
+All possible values for <span style="font-style: italic;">srcTerm</span>
+and the corresponding arithmetic term are listed in the following table:<br>
+<br>
+<table cellpadding="2" cellspacing="2" border="1"
+ style="text-align: left; width: 70%; margin-left: auto; margin-right: auto;">
+ <tbody>
+ <tr>
+ <td style="vertical-align: top;"><span style="font-style: italic;">dstTerm</span><br>
+ </td>
+ <td style="vertical-align: top;"><span style="font-style: italic;">dstTerm</span>Arithmetic<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_ZERO<br>
+ </td>
+ <td style="vertical-align: top;">(0, 0, 0, 0)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_ONE<br>
+ </td>
+ <td style="vertical-align: top;">(1, 1, 1, 1)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_SRC_COLOR<br>
+ </td>
+ <td style="vertical-align: top;">(Rf, Gf, Bf, Af)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_ONE_MINUS_SRC_COLOR<br>
+ </td>
+ <td style="vertical-align: top;">(1-Rf, 1-Gf, 1-Bf, 1-Af)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_SRC_ALPHA<br>
+ </td>
+ <td style="vertical-align: top;">(Af, Af, Af, AF)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_ONE_MINUS_SRC_ALPHA<br>
+ </td>
+ <td style="vertical-align: top;">(1-Af, 1-Af, 1-Af, 1-Af)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_DST_ALPHA<br>
+ </td>
+ <td style="vertical-align: top;">(Ab, Ab, Ab, Ab)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_ONE_MINUS_DST_ALPHA<br>
+ </td>
+ <td style="vertical-align: top;">(1-Ab, 1-Ab, 1-Ab, 1-Ab)<br>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<br>
+The fragment's color is replaced by the result of the blending equation.<br>
+<br>
+Values for <span style="font-style: italic;">srcTerm</span> and <span
+ style="font-style: italic;">dstTerm</span> other than those listed in
+the table will cause the error GL_INVALID_ENUM to be raised.<br>
+<br>
+The default value for <span style="font-style: italic;">srcTerm</span>
+is GL_ONE. &nbsp;The default value for <span style="font-style: italic;">dstTerm</span>
+is GL_ZERO. &nbsp;Blending is disabled by default.<br>
+<br>
+<h2>6.5 Color Mask</h2>
+The final fragment color is written into the current color buffer at
+the end of the per-fragment operations. &nbsp;Normally, all color
+channels in the frame buffer are replaced with the final fragment color.
+&nbsp;However, the command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glColorMask</span>(GLboolean<span
+ style="font-style: italic;">redMask</span>, GLboolean <span
+ style="font-style: italic;">greenMask</span>, GLboolean <span
+ style="font-style: italic;">blueMask</span>, GLboolean <span
+ style="font-style: italic;">alphaMask</span>)<br>
+</div>
+<br>
+allows selective writing to individual color channels. &nbsp;If <span
+ style="font-style: italic;">redMask</span> is GL_TRUE then writing to
+the red color channel is enabled, otherwise it's disabled.
+&nbsp;Similarly, the green, blue and alpha channels can also be masked.<br>
+<br>
+Initially all four mask values are GL_TRUE.<br>
+<br>
+Color masking is not enabled/disabled with the <span
+ style="font-weight: bold;">glEnable</span>/<span
+ style="font-weight: bold;">glDisable</span> commands.<br>
+<br>
+<h1>7. Frame Buffer Operations</h1>
+The frame buffer is considered to be a two-dimensional array of pixels.
+&nbsp;The frame buffer is also organized into layers or logical buffers.
+&nbsp;There may be a front color buffer, back color buffer and stencil
+buffer. &nbsp;A double-buffered frame buffer has both a front color
+buffer and back color buffer. &nbsp;A single-buffered framebuffer only
+has a front color buffer. &nbsp;Each pixel in a color buffer has a red,
+green and blue value and an optional alpha value.<br>
+<br>
+<h2>7.1 Clearing Buffers</h2>
+Buffers are cleared (set to uniform values) with the command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glClear</span>(GLbitfield<span
+ style="font-style: italic;">buffers</span>)<br>
+</div>
+<br>
+<span style="font-style: italic;">buffers</span> is a bitmask for which
+the value may be the bitwise-OR of the values GL_COLOR_BUFFER_BIT and
+GL_STENCIL_BUFFER_BIT. &nbsp;If the GL_COLOR_BUFFER_BIT bit is
+specified, the current color buffer will be cleared. &nbsp;If the
+GL_STENCIL_BUFFER_BIT bit is specified, the stencil buffer will be
+cleared.<br>
+<br>
+The current color buffer is specified with the command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glDrawBuffer</span>(GLenum<span
+ style="font-style: italic;"> buffer</span>)<br>
+</div>
+<br>
+<span style="font-style: italic;">buffer</span> may be either GL_FRONT,
+GL_BACK or GL_NONE. &nbsp;GL_FRONT indicates that the front color buffer
+will be modified by <span style="font-weight: bold;">glClear</span> and
+any drawing command. &nbsp;GL_BACK indicates that the back color buffer
+will be modified by <span style="font-weight: bold;">glClear</span> and
+any drawing command. &nbsp;GL_NONE indicates that neither color buffer
+will be modified by <span style="font-weight: bold;">glClear</span> or
+any drawing command. &nbsp;GL_BACK is only valid for double-buffered
+frame buffers.<br>
+<br>
+The current scissor rectangle, set by the <span
+ style="font-weight: bold;">glScissor</span> command, effects <span
+ style="font-weight: bold;">glClear</span><span
+ style="font-style: italic;">,</span><span style="font-style: italic;"> </span>limiting
+the clear to the scissor rectangle, if it's enabled. &nbsp;Furthermore, <span
+ style="font-weight: bold;"></span>only the color channels enabled by <span
+ style="font-weight: bold;">glColorMask</span> will be effected by <span
+ style="font-weight: bold;">glClear</span>(GL_COLOR_BUFFER_BIT).
+&nbsp;Likewise, only the stencil bits enabled by <span
+ style="font-weight: bold;">glStencilMask</span> will be effected by <span
+ style="font-weight: bold;">glClear</span>(GL_STENCIL_BUFFER_BIT).<br>
+<br>
+The current clear color is set with the command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glClearColor</span>(GLclampf<span
+ style="font-style: italic;">red</span>, GLclampf <span
+ style="font-style: italic;">green</span>, GLclampf <span
+ style="font-style: italic;">blue</span>, GLclampf <span
+ style="font-style: italic;">alpha</span>)<br>
+</div>
+<br>
+Subsequent calls to <span style="font-weight: bold;">glClear</span>
+will use the color (<span style="font-style: italic;">red, green, blue,
+alpha</span>) to clear the front or back color buffers.<br>
+<span style="font-style: italic;"></span><br>
+The current stencil clear value is set with the command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glClearStencil</span>(GLint<span
+ style="font-style: italic;">clearValue</span>)<br>
+</div>
+<br>
+If the stencil buffer is N bits deep, the least significant N bits of <span
+ style="font-style: italic;">clearValue</span> will be used to clear the
+stencil buffer.<br>
+<br>
+<br>
+<h1>8. Other Features</h1>
+<h2>8.1 Frame Buffer Readback</h2>
+A rectangular region of pixels can be read from the frame buffer and
+placed in client memory with the command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glReadPixels</span>(GLint<span
+ style="font-style: italic;">x</span>, GLint <span
+ style="font-style: italic;">y</span>, GLsizei <span
+ style="font-style: italic;">width</span>, GLsizei <span
+ style="font-style: italic;">height</span>, GLenum <span
+ style="font-style: italic;">format</span>, GLenum <span
+ style="font-style: italic;">type</span>, GLvoid *<span
+ style="font-style: italic;">data</span>)<br>
+</div>
+<br>
+<span style="font-style: italic;">x</span> and <span
+ style="font-style: italic;">y</span> specify the coordinate of the
+lower-left corner of the region to read and <span
+ style="font-style: italic;">width</span> and <span
+ style="font-style: italic;">height</span> specify the size of the
+rectangular region to read. &nbsp;<span style="font-style: italic;">format</span>
+specifies the format of image data and must be either GL_RGB or
+GL_RGBA.&nbsp; <span style="font-style: italic;">type</span> specify the
+data type of the image data and must be either GL_UNSIGNED_BYTE or
+GL_FLOAT. &nbsp;Other values for <span style="font-style: italic;">format</span>
+or <span style="font-style: italic;">type</span> will cause the error
+GL_INVALID_ENUM to be raised.<br>
+<br>
+The framebuffer may contain 3-component colors (red, green, blue) or
+4-component colors (red, green, blue, alpha). &nbsp;If an alpha channel
+is not present, alpha values default to 1.0.<br>
+<br>
+The frame buffer color components (red, green, blue, alpha) are either
+converted to 8-bit unsigned integers in the range[0, 255] if <span
+ style="font-style: italic;">type </span>is GL_UNSIGNED_BYTE or
+converted to floating point values in the range [0, 1] if <span
+ style="font-style: italic;">type</span> is GL_FLOAT. &nbsp;The (red,
+green, blue, alpha) tuples are then stored as GL_RGB triplets (by
+dropping the alpha component) or GL_RGBA quadruples in client memory.<br>
+<br>
+Image data is <span style="font-style: italic;">packed</span> into
+client memory according to the pixel packing parameters which are set by
+the command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glPixelStorei</span>(GLenum<span
+ style="font-style: italic;"> pname</span>, GLint <span
+ style="font-style: italic;">value</span>)<br>
+</div>
+<br>
+<span style="font-style: italic;">pname</span> must be
+GL_PACK_ROW_LENGTH. &nbsp;<span style="font-style: italic;">value</span>
+indicates the stride (in pixels) between subsequent rows in the
+destination image. &nbsp;If GL_PACK_ROW_LENGTH is zero (the default)
+then the <span style="font-style: italic;">width</span> parameter to <span
+ style="font-weight: bold;">glReadPixels</span> indicates the row stride.<br>
+<br>
+Pixel readback takes place as follows:<br>
+<br>
+<div style="margin-left: 40px;">if (GL_PACK_ROW_LENGTH == 0)<br>
+&nbsp;&nbsp;&nbsp; rowLength = <span style="font-style: italic;">width</span>;<br>
+else<br>
+&nbsp;&nbsp;&nbsp; rowLength = GL_PACK_ROW_LENGTH<br>
+<br>
+if (<span style="font-style: italic;">format</span> == GL_RGB) {<br>
+&nbsp;&nbsp;&nbsp; for (i = 0; i &lt; <span style="font-style: italic;">height</span>;
+i++) {<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (j = 0; j &lt; <span
+ style="font-style: italic;">width</span>; j++) {<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; k = (i *
+rowLength + j) * 3;<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span
+ style="font-style: italic;">data</span>[k+0] = FrameBuffer(<span
+ style="font-style: italic;">x</span> + j, <span
+ style="font-style: italic;">y</span> + i).red;<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; <span
+ style="font-style: italic;">data</span>[k+1] = FrameBuffer(<span
+ style="font-style: italic;">x</span> + j, <span
+ style="font-style: italic;">y</span> + i).green;<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span
+ style="font-style: italic;">data</span>[k+2] = FrameBuffer(<span
+ style="font-style: italic;">x</span> + j, <span
+ style="font-style: italic;">y</span> + i).blue;<span
+ style="font-style: italic;"></span><br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp;&nbsp; }<br>
+}<br>
+else {<br>
+&nbsp;&nbsp;&nbsp; for (i = 0; i &lt; <span style="font-style: italic;">height</span>;
+i++) {<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (j = 0; j &lt; <span
+ style="font-style: italic;">width</span>; j++) {<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; k = (i *
+rowLength + j) * 4;<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span
+ style="font-style: italic;">data</span>[k+0] = FrameBuffer(<span
+ style="font-style: italic;">x</span> + j, <span
+ style="font-style: italic;">y</span> + i).red;<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp;&nbsp; <span
+ style="font-style: italic;">data</span>[k+1] = FrameBuffer(<span
+ style="font-style: italic;">x</span> + j, <span
+ style="font-style: italic;">y</span> + i).green;<br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span
+ style="font-style: italic;">data</span>[k+2] = FrameBuffer(<span
+ style="font-style: italic;">x</span> + j, <span
+ style="font-style: italic;">y</span> + i).blue;<span
+ style="font-style: italic;"></span><br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <span
+ style="font-style: italic;">data</span>[k+3] = FrameBuffer(<span
+ style="font-style: italic;">x</span> + j, <span
+ style="font-style: italic;">y</span> + i).alpha;<span
+ style="font-style: italic;"></span><br>
+&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
+&nbsp;&nbsp;&nbsp; }<br>
+}<br>
+</div>
+<br>
+The function FrameBuffer(<span style="font-style: italic;">c, r</span>)
+returns the pixel in the frame buffer at column <span
+ style="font-style: italic;">c</span> of row <span
+ style="font-style: italic;">r. &nbsp;</span><span
+ style="font-style: italic;">data</span> is considered to be either a
+GLubyte pointer or a GLfloat pointer, depending on the <span
+ style="font-style: italic;">type</span> parameter. &nbsp;Similarly, the
+FrameBuffer function returns either GLubyte values in the range [0, 255]
+or GLfloat values in the range [0,1], depending on the <span
+ style="font-style: italic;">type</span> parameter.<br>
+<br>
+Pixels may be read from either the front or back color buffer.
+&nbsp;The command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glReadBuffer</span>(GLenum<span
+ style="font-style: italic;">buffer</span>)<br>
+</div>
+<br>
+specifies the source for reading images with <span
+ style="font-weight: bold;">glReadPixels</span>. &nbsp;If <span
+ style="font-style: italic;">buffer</span> is GL_FRONT then front color
+buffer is the source. &nbsp;If <span style="font-style: italic;">buffer</span>
+is GL_BACK then the back color buffer is the source. &nbsp;It is illegal
+to specify GL_BACK when the color buffer is not double buffered.
+&nbsp;Any invalid value for <span style="font-style: italic;">buffer</span>
+will raise the error GL_INVALID_ENUM.<br>
+<br>
+The default read source is GL_BACK if the frame buffer is double
+buffered. &nbsp;Otherwise, the default read source is GL_FRONT.<br>
+<br>
+<h2>8.2 Selection Mode</h2>
+Selection mode is typically used to implement <span
+ style="font-style: italic;">picking</span>: determining which
+primitive(s) are present at particular window positions. &nbsp;The
+command<br>
+<br>
+<div style="margin-left: 40px;">GLint <span style="font-weight: bold;">glRenderMode</span>(GLenum<span
+ style="font-style: italic;">mode</span>)<br>
+</div>
+<br>
+is used to enable selection mode. &nbsp;If <span
+ style="font-style: italic;">mode</span> is GL_SELECTION the graphics
+library is put into selection mode. &nbsp;If <span
+ style="font-style: italic;">mode</span> is GL_RENDER the graphic
+library is put into normal rendering mode. &nbsp;Any other value for <span
+ style="font-style: italic;">mode</span> will raise the error
+GL_INVALID_ENUM.<br>
+<br>
+When in selection mode rendering commands will not effect the
+framebuffer. &nbsp;Instead, a record of the primitives that would have
+been drawn is placed in the <span style="font-style: italic;">selection</span> <span
+ style="font-style: italic;">buffer</span>. &nbsp;The selection buffer
+is specified with the command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glSelectionBuffer</span>(GLsizei<span
+ style="font-style: italic;">n</span>, GLuint *<span
+ style="font-style: italic;">buffer</span>)<br>
+</div>
+<span style="font-style: italic;"></span><span
+ style="font-style: italic;"><br>
+buffer</span> is an array of <span style="font-style: italic;">n</span>
+unsigned integers. &nbsp;No more than <span style="font-style: italic;">n</span>
+values will be placed in the buffer.<br>
+<br>
+The <span style="font-style: italic;">name stack</span> is a stack
+(LIFO) of unsigned integer names. &nbsp;The following commands
+manipulate the name stack:<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glInitNames</span>(void)<br>
+void <span style="font-weight: bold;">glPushName</span>(GLuint <span
+ style="font-style: italic;">name</span>)<br>
+void <span style="font-weight: bold;">glPopName</span>(void)<br>
+void <span style="font-weight: bold;">glLoadName</span>(GLuint <span
+ style="font-style: italic;">name</span>)<br>
+</div>
+<br>
+<span style="font-weight: bold;">glInitNames</span> resets the name
+stack to an empty state. &nbsp;<span style="font-weight: bold;">glPushName<span
+ style="font-style: italic;"> </span></span>pushes the given <span
+ style="font-style: italic;">name</span> value onto the stack. &nbsp;<span
+ style="font-weight: bold;">glPopName</span> pops the top name from the
+stack. &nbsp;<span style="font-weight: bold;">glLoadName<span
+ style="font-style: italic;"> </span></span>replaces the top value on
+the stack with the specified <span style="font-style: italic;">name</span>.
+&nbsp;Stack underflow and overflow conditions cause the errors
+GL_STACK_OVERFLOW and GL_STACK_UNDERFLOW to be raised.<br>
+<br>
+While in selection mode, primitives (points, lines, polygons) are
+transformed and clip-tested normally. &nbsp;Primitives which aren't
+discarded by clipping cause the <span style="font-style: italic;">hit</span> <span
+ style="font-style: italic;">data</span> to be updated. &nbsp;The hit
+data consists of three pieces of information: a hit flag, a minimum Z
+value and a maximum Z value. &nbsp;First, the hit flag is set.
+&nbsp;Then, for each of the primitive's vertices, the vertex Z value is
+compared to the minimum and maximum Z values. &nbsp;The minimum Z value
+is updated if the vertex's Z value is less than the minimum Z value.
+&nbsp;The maximum Z value is updated if the vertex's Z value is greater
+than the maximum Z value.<br>
+<br>
+When any of <span style="font-weight: bold;">glInitNames</span><span
+ style="font-style: italic;"><span style="font-style: italic;">, </span></span><span
+ style="font-weight: bold;">glPushName</span>, <span
+ style="font-weight: bold;">glPopName</span>, <span
+ style="font-weight: bold;">glLoadName</span> or <span
+ style="font-weight: bold;">glRenderMode</span> are called and the hit
+flag is set, a <span style="font-style: italic;">hit record</span> is
+written to the selection buffer.<br>
+<br>
+A hit record consists of a sequence of unsigned integers. &nbsp;The
+first value is the size of the name stack. &nbsp;The second value is the
+minimum Z value multiplied by 2<sup>32</sup>-1. &nbsp;The third value is
+the maximum Z value multiplied by 2<sup>32</sup>-1. &nbsp;The remaining
+values are the values in the name stack, in bottom to top order.
+&nbsp;The hit flag is cleared after a hit record is written to the
+selection buffer. &nbsp;Hit records are places sequentially into the
+selection buffer until it is full or selection mode is terminated.<br>
+<br>
+Selection mode is terminated by calling <span
+ style="font-weight: bold;">glRenderMode</span>(GL_RENDER). &nbsp; The
+return value of <span style="font-weight: bold;">glRenderMode</span>
+will be -1 if the selection buffer overflowed. &nbsp;Otherwise, the
+return value will indicate the number of values written into the
+selection buffer.<br>
+<br>
+<h2>8.3 Synchronization</h2>
+The command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glFlush</span>(void)<br>
+</div>
+<br>
+makes the graphics library to flush all pending graphics commands.
+&nbsp;The command<br>
+<div style="margin-left: 40px;"><br>
+void <span style="font-weight: bold;">glFinish</span>(void)<br>
+</div>
+<br>
+makes the graphics library flush the command queue and wait until those
+commands are completed. &nbsp;<span style="font-weight: bold;">glFlush</span>
+will not return until all previous graphics commands have been fully
+completed.<br>
+<br>
+These commands are typically used to force completion of rendering to
+the front color buffer. &nbsp;Otherwise, rendering to the front color
+buffer may not appear. &nbsp;The <span style="font-style: italic;">swapbuffers</span>
+command (part of the window system binding library) does an implicit
+flush before swapping the front and back color buffers. &nbsp;The <span
+ style="font-weight: bold;">glReadPixels</span> command also does an
+implicit flush before reading pixel data from the frame buffer.<br>
+<br>
+<h1>9. State Queries</h1>
+The current value of nearly all library state variables can be queried.
+&nbsp;This chapter describes the commands used for querying the value of
+state variables.<br>
+<br>
+<h2>9.1 General State Queries</h2>
+The command<br>
+<br>
+<div style="margin-left: 40px;">void <span style="font-weight: bold;">glGetFloatv</span>(GLenum<span
+ style="font-style: italic;">pname</span>, GLfloat *<span
+ style="font-style: italic;">values</span>)<br>
+</div>
+<br>
+returns the value(s) of the state variable specified by <span
+ style="font-style: italic;">pname</span>. &nbsp;The following table
+lists all accepted values for <span style="font-style: italic;">pname</span>
+and a description of the value(s). &nbsp;Specifying any other value for <span
+ style="font-style: italic;">pname</span> causes the error
+GL_INVALID_ENUM to be raised.<br>
+<br>
+<table cellpadding="2" cellspacing="2" border="1"
+ style="text-align: left; width: 90%; margin-left: auto; margin-right: auto;">
+ <tbody>
+ <tr>
+ <td style="vertical-align: top;">Variable (<span
+ style="font-style: italic;">pname)</span><br>
+ </td>
+ <td style="vertical-align: top;">Number of values<br>
+ </td>
+ <td style="vertical-align: top;">Value(s) Description<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_ALPHA_BITS<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Number of bits per alpha value
+in the frame buffer.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_ALPHA_TEST<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Zero if the alpha test is
+disabled.<br>
+One if the alpha test is enabled.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_ALPHA_TEST_FUNC<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">The alpha test function.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_BLEND<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Zero if blending is disabled.<br>
+One if blending is enabled.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_BLEND_DST<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Blend destination function/term.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_BLEND_SRC<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Blend source function/term.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_BLUE_BITS<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Number of bits per blue value in
+the frame buffer.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_COLOR_CLEAR_VALUE<br>
+ </td>
+ <td style="vertical-align: top;">4<br>
+ </td>
+ <td style="vertical-align: top;">Clear color (red, green, blue,
+alpha).<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_COLOR_WRITE_MASK<br>
+ </td>
+ <td style="vertical-align: top;">4<br>
+ </td>
+ <td style="vertical-align: top;">Color buffer writemask (red,
+green, blue, alpha).<br>
+Zero if writing is disabled.<br>
+One if writing is enabled.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_CULL_FACE<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Zero if polygon culling is
+disabled.<br>
+One if polygon culling is enabled.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_CULL_FACE_MODE<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Polygon cull mode: GL_FRONT,
+GL_BACK or GL_FRONT_AND_BACK.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_CURRENT_COLOR<br>
+ </td>
+ <td style="vertical-align: top;">4<br>
+ </td>
+ <td style="vertical-align: top;">Current color (red, green, blue,
+alpha).<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_CURRENT_RASTER_COLOR<br>
+ </td>
+ <td style="vertical-align: top;">4<br>
+ </td>
+ <td style="vertical-align: top;">Current raster position color
+(red, green, blue, alpha).<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_CURRENT_RASTER_TEXTURE_COORDS<br>
+ </td>
+ <td style="vertical-align: top;">4<br>
+ </td>
+ <td style="vertical-align: top;">Current raster position texture
+coordinates (s, t, r, q).<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_CURRENT_RASTER_POSITION<br>
+ </td>
+ <td style="vertical-align: top;">4<br>
+ </td>
+ <td style="vertical-align: top;">Current raster position (x, y,
+z, w).<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_CURRENT_POSITION_VALID<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Zero if current raster position
+is invalid.<br>
+One if current raster position is valid.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_CURRENT_TEXTURE_COORDS<br>
+ </td>
+ <td style="vertical-align: top;">4<br>
+ </td>
+ <td style="vertical-align: top;">Current texture coordinates (s,
+t, r, q)<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_DOUBLEBUFFER<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Zero if color buffer is
+single-buffered.<br>
+One if color buffer is double-buffered.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_DRAW_BUFFER<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Current color draw buffer:
+GL_FRONT or GL_BACK.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_FRONT_FACE</td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Polygon front-face winding:
+GL_CW or GL_CCW.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_GREEN_BITS<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Number of bits per green value
+in the frame buffer.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_LINE_SMOOTH<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Zero if line smoothing is
+disabled.<br>
+One if line smoothing is enabled.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_LINE_STIPPLE<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Zero if line stippling is
+disabled.<br>
+One if line stippling is enabled.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_LINE_STIPPLE_PATTERN<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Line stipple pattern.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_LINE_STIPPLE_REPEAT<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Line stipple repeat factor.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_LINE_WIDTH<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Line width in pixels.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_LINE_WIDTH_GRANULARITY<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Aliased line width granularity.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_LINE_WIDTH_RANGE<br>
+ </td>
+ <td style="vertical-align: top;">2<br>
+ </td>
+ <td style="vertical-align: top;">Minimum and maximum aliased line
+widths.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_ALIASED_LINE_WIDTH_RANGE<br>
+ </td>
+ <td style="vertical-align: top;">2<br>
+ </td>
+ <td style="vertical-align: top;">Minimum and maximum antialiased
+line widths.</td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_COLOR_LOGIC_OP<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Zero if logicop is disabled.<br>
+One if logicop is enabled.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_LOGIC_OP_MODE<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Logicop function.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_MATRIX_MODE<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Matrix mode: GL_MODELVIEW or
+GL_PROJECTION.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_MAX_MODELVIEW_STACK_DEPTH<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Maximum size of the modelview
+matrix stack.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_MAX_NAME_STACK_DEPTH<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Maximum size of the selection
+name stack.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_MAX_PROJECTION_STACK_DEPTH<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Maximum size of the projection
+matrix stack.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_MAX_TEXTURE_SIZE<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Maximum 2D texture image width
+and height.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_MAX_VIEWPORT_DIMS<br>
+ </td>
+ <td style="vertical-align: top;">2</td>
+ <td style="vertical-align: top;">Maximum viewport width and
+height in pixels.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_MODELVIEW_MATRIX<br>
+ </td>
+ <td style="vertical-align: top;">16<br>
+ </td>
+ <td style="vertical-align: top;">Current/top modelview matrix
+values.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_MODELVIEW_MATRIX_STACK_DEPTH<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Current size of the modelview
+matrix stack.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_NAME_STACK_DEPTH<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Current size of the selection
+name stack.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_PACK_ROW_LENGTH<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Pixel packing row length.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_POLYGON_SMOOTH<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Zero if polygon smoothing is
+disabled.<br>
+One if polygon smoothing is enabled.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_PROJECTION_MATRIX<br>
+ </td>
+ <td style="vertical-align: top;">16<br>
+ </td>
+ <td style="vertical-align: top;">Current/top projection matrix
+values.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_PROJECTION_STACK_DEPTH<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Current size of projection
+matrix stack.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_READ_BUFFER<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Current read buffer: GL_FRONT or
+GL_BACK.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_RED_BITS<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Number of bits per red value in
+the frame buffer.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_RENDER_MODE<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Current rendering mode:
+GL_RENDER or GL_SELECTION.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_RGBA_MODE<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Always one.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_SCISSOR_BOX<br>
+ </td>
+ <td style="vertical-align: top;">4<br>
+ </td>
+ <td style="vertical-align: top;">Scissor box (x, y, width,
+height).<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_SCISSOR_TEST<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Zero if scissor test is disabled.<br>
+One if scissor test is enabled.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_SELECTION_BUFFER_SIZE<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Size of selection buffer.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_SHADE_MODEL<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Shade model: GL_FLAT or
+GL_SMOOTH.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_STENCIL_BITS<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Number of bits per stencil value
+in the frame buffer.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_STENCIL_CLEAR_VALUE<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Stencil buffer clear value.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_STENCIL_FAIL<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Stencil fail operation.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_STENCIL_FUNC<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Stencil function.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_STENCIL_REF<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Stencil reference value.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_STENCIL_TEST<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Zero if stencil test is disabled.<br>
+One if stencil test is enabled.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_STENCIL_VALUE_MASK<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Stencil mask value.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_STENCIL_WRITE_MASK<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Stencil buffer write mask.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_TEXTURE_2D<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Zero if 2D texture mapping is
+disabled.<br>
+One if 2D texture mapping is enabled.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_TEXTURE_BINDING_2D</td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Name of currently bound 2D
+texture object.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_TEXTURE_ENV_COLOR<br>
+ </td>
+ <td style="vertical-align: top;">4<br>
+ </td>
+ <td style="vertical-align: top;">Texture environment color (red,
+green, blue, alpha).<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_TEXTURE_ENV_MODE<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Texture environment mode.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_UNPACK_ROW_LENGTH<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Pixel unpacking row length.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_UNPACK_LSB_FIRST<br>
+ </td>
+ <td style="vertical-align: top;">1<br>
+ </td>
+ <td style="vertical-align: top;">Zero if most significant bit is
+unpacked first for bitmaps.<br>
+One if least significant bit is unpacked first for bitmaps.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_VIEWPORT<br>
+ </td>
+ <td style="vertical-align: top;">4<br>
+ </td>
+ <td style="vertical-align: top;">Current viewport (x, y, width,
+height).<br>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<br>
+<br>
+<h2>9.2 String Queries</h2>
+The command<br>
+<br>
+<div style="margin-left: 40px;">const GLubyte *<span
+ style="font-weight: bold;">glGetString</span>(GLenum <span
+ style="font-style: italic;">name</span>)<br>
+</div>
+<br>
+is used to query string-valued values. &nbsp;The legal values for <span
+ style="font-style: italic;">name</span> are described in the following
+table:<br>
+<br>
+<table cellpadding="2" cellspacing="2" border="1"
+ style="text-align: left; width: 80%; margin-left: auto; margin-right: auto;">
+ <tbody>
+ <tr>
+ <td style="vertical-align: top;"><span style="font-style: italic;">name</span><br>
+ </td>
+ <td style="vertical-align: top;">Return value<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_VERSION<br>
+ </td>
+ <td style="vertical-align: top;">The library version, such as
+"1.2".<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_RENDERER<br>
+ </td>
+ <td style="vertical-align: top;">The renderer, such as "Mesa DRI
+Radeon".<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_VENDOR<br>
+ </td>
+ <td style="vertical-align: top;">The vendor of this
+implementation, such as "Tungsten Graphics, Inc."<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_EXTENSIONS<br>
+ </td>
+ <td style="vertical-align: top;">A white-space separated list of
+the supported extensions. </td>
+ </tr>
+ </tbody>
+</table>
+<br>
+<h2>9.3 Error Queries</h2>
+The command<br>
+<br>
+<div style="margin-left: 40px;">GLenum <span style="font-weight: bold;">glGetError</span>(void)<br>
+</div>
+<br>
+returns the current error code. &nbsp;The current error code will be
+set by a GL command when an error condition has been detected. &nbsp;If
+the current error code is already set, subsequent errors will not be
+recorded. &nbsp;The error code is reset/cleared to GL_NO_ERROR when <span
+ style="font-weight: bold;">glGetError</span> returns. &nbsp;The
+following error codes are possible:<br>
+<br>
+<table cellpadding="2" cellspacing="2" border="1"
+ style="text-align: left; width: 80%; margin-left: auto; margin-right: auto;">
+ <tbody>
+ <tr>
+ <td style="vertical-align: top;">Error code<br>
+ </td>
+ <td style="vertical-align: top;">Meaning<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_NO_ERROR<br>
+ </td>
+ <td style="vertical-align: top;">No error has been recorded.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_INVALID_ENUM<br>
+ </td>
+ <td style="vertical-align: top;">An enum parameter had an invalid
+value.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_INVALID_VALUE<br>
+ </td>
+ <td style="vertical-align: top;">A numeric parameter had an
+invalid value.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_INVALID_OPERATION<br>
+ </td>
+ <td style="vertical-align: top;">A function was called when not
+legal to do so.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_STACK_OVERFLOW<br>
+ </td>
+ <td style="vertical-align: top;">The current transformation
+matrix stack is full.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_STACK_UNDERFLOW<br>
+ </td>
+ <td style="vertical-align: top;">The current transformation
+matrix stack is empty.<br>
+ </td>
+ </tr>
+ <tr>
+ <td style="vertical-align: top;">GL_OUT_OF_MEMORY<br>
+ </td>
+ <td style="vertical-align: top;">The system ran out of dynamic
+memory.<br>
+ </td>
+ </tr>
+ </tbody>
+</table>
+<br>
+<br>
+<h1>10. Unsupported Features</h1>
+This section lists other features and functions which are not supported
+and not previously discussed.<br>
+<br>
+<h2>10.1 Feedback Mode</h2>
+Feedback mode and the following related functions are not supported.<br>
+<br>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glFeedbackBuffer</span><br>
+<span style="font-weight: bold;">glPassThrough</span><br>
+</div>
+<br>
+<h2>10.2 1D and 3D Textures<br>
+</h2>
+Only 2D texture images are supported. &nbsp;The following functions
+used to specify 1D and 3D texture images are not supported:<br>
+<br>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glTexImage1D</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glTexImage3D</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glTexSubImage1D</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;"> glTexSubImage3D</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glCopyTexImage1D</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;"> glCopyTexSubImage1D</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;"> glCopyTexSubImage3D</span><br>
+</div>
+<br>
+<h2>10.3 Alternate Texture Image Commands<br>
+</h2>
+Texture images may only be specified with <span
+ style="font-weight: bold;">glTexImage2D</span>. &nbsp;The following
+alternate texture image commands are not supported:<br>
+<br>
+<div style="margin-left: 40px; font-weight: bold;">glTexSubImage2D<br>
+glCopyTexImage2D<br>
+glCopyTexSubImage2D<br>
+</div>
+<br>
+<h2>10.4 Proxy Textures</h2>
+Proxy textures are not supported and the GL_PROXY_TEXTURE_2D token is
+not supported by any function.<br>
+<br>
+<br>
+<h2>10.5 Other Texture Commands</h2>
+The following commands related to texture mapping are not supported by
+the subset:<br>
+<br>
+<div style="margin-left: 40px; font-weight: bold;"> glPrioritizeTextures<br>
+glAreTexturesResident<br>
+glIsTexture<br>
+glTexEnviv<br>
+glTexEnvf<br>
+glTexParameterf<br>
+glTexParameteriv<br>
+glTexParameterfv<br>
+</div>
+<br>
+<br>
+<h2>10.6 Copy and Draw Pixels<br>
+</h2>
+The following commands are not supported:<br>
+<br>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glDrawPixels<br>
+glCopyPixels<br>
+glPixelZoom<br>
+<br>
+</span></div>
+<h2>10.7 Color Index Mode<br>
+</h2>
+Color index mode and the following related commands are not supported:<br>
+<br>
+<span style="font-weight: bold;"></span>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glIndexub<br>
+</span><span style="font-weight: bold;">glIndexi</span><br>
+<span style="font-weight: bold;">glIndexs<br>
+glIndexf<br>
+glIndexd<br>
+</span><span style="font-weight: bold;">glIndexubv<br>
+</span><span style="font-weight: bold;">glIndexiv</span><br>
+<span style="font-weight: bold;">glIndexsv<br>
+glIndexfv<br>
+glIndexdv</span><span style="font-weight: bold;"><br>
+glIndexMask<br>
+</span><span style="font-weight: bold;">glClearIndex<br>
+glIndexPointer</span><br style="font-weight: bold;">
+<br>
+</div>
+<h2>10.8 Pixel Transfer Operations</h2>
+The pixel transfer operations (scale, bias, look-up table, etc) are not
+supported and the following commands are omitted:<br>
+<br style="font-weight: bold;">
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glPixelTransferf</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glPixelTransferi</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glPixelMapfv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glPixelMapuiv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glPixelMapusv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glGetPixelMapfv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glGetPixelMapuiv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glGetPixelMapusv</span><br>
+</div>
+<br>
+<h2>10.9 Hints</h2>
+Hints and the following related command is not supported:<br>
+<br>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glHint<br>
+</span><br>
+</div>
+<h2>10.10 State Query Commands<br>
+</h2>
+The following state query commands are not supported:<br>
+<br>
+<div style="margin-left: 40px; font-weight: bold;">glGetBooleanv<br>
+glGetIntegerv<br>
+glGetDoublev<br>
+glGetPointerv<br>
+glGetTexEnvi<br>
+glGetTexEnvf<br>
+glGetTexParameteriv<br>
+glGetTexParameterfv<br>
+glGetTexLevelParameteriv<br>
+glGetTexLevelParameterfv<br>
+glGetTexImage<br>
+glGetClipPlane<br>
+</div>
+<br>
+<h2>10.11 Attribute Stacks</h2>
+State attribute stacks and the following related commands are not
+supported:<br>
+<br>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glPushAttrib</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glPopAtttrib</span><br>
+<br style="font-weight: bold;">
+</div>
+<h2>10.12 Double-Valued Functions</h2>
+All functions which take double-precision floating point values, but
+for which there is an equivalent single-precision valued function, are
+omitted. &nbsp;This includes, but is not limited to:<br>
+<br>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glVertex2d</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glVertex2dv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glVertex3d</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;"> glVertex3dv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glVertex4d</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;"> glVertex4dv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glColor3d</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glColor3d</span><span
+ style="font-weight: bold;">v</span><br style="font-weight: bold;">
+<span style="font-weight: bold;">glColor4d</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;"> glColor4dv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glTexCoord1d</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glTexCoord1d</span><span
+ style="font-weight: bold;">v</span><br style="font-weight: bold;">
+<span style="font-weight: bold;">glTexCoord2d</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;"> glTexCoord2dv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glTexCoord3d</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;"> glTexCoord3dv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glTexCoord4d</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;"> glTexCoord4dv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glRasterPos2d</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;"> glRasterPos2dv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glRasterPos3d</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;"> glRasterPos3dv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glRasterPos4d</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;"> glRasterPos4dv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glLoadMatrixd</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glMultMatrixd</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glScaled</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glRotated</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glTranslated<br>
+glRectd<br>
+glRectdv<br>
+</span> <span style="font-weight: bold;"><br>
+</span> </div>
+<h2>10.13 Evaluators</h2>
+Evaluators and the following related commands are not supported:<br>
+<br>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glMap1f</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glMap2d</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glMap2f</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glGetMapdv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glGetMapfv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glGetMapiv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glEvalCoord1d</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glEvalCoord1f</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glEvalCoord1dv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glEvalCoord1fv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glEvalCoord2d</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glEvalCoord2f</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glEvalCoord2dv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glEvalCoord2fv</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glMapGrid1d</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glMapGrid1f</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glMapGrid2d</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glMapGrid2f</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glEvalPoint1</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glEvalPoint2</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glEvalMesh1</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glEvalMesh2</span><br
+ style="font-weight: bold;">
+</div>
+<br>
+<h2>10.14 Display Lists</h2>
+Display lists and the following related commands are not supported:<br>
+<br>
+<div style="margin-left: 40px; font-weight: bold;">glIsList<br>
+glDeleteLists<br>
+glGenLists<br>
+glNewList<br>
+glEndList<br>
+glCallList<br>
+glCallLists<br>
+glListBase<br>
+</div>
+<br>
+<h2>10.15 Accumulation Buffer</h2>
+The accumulation buffer and the following related commands are not
+supported:<br>
+<br style="font-weight: bold;">
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glAccum</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glClearAccum</span><br>
+</div>
+<br>
+<h2>10.16 Fog</h2>
+Fog and the following related commands are not supported:<br>
+<br>
+<div style="margin-left: 40px; font-weight: bold;"> glFogi<br>
+glFogf<br>
+glFogiv<br>
+glFogfv<br>
+</div>
+<br>
+<h2>10.17 Depth Test</h2>
+Depth testing and the following related commands are not supported:<br>
+<br>
+<div style="margin-left: 40px;"><span style="font-weight: bold;">glDepthFunc</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glDepthMask</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glDepthRange</span><br
+ style="font-weight: bold;">
+<span style="font-weight: bold;">glClearDepth</span><br>
+</div>
+<br>
+<h2>10.18 Imaging Subset</h2>
+The OpenGL imaging subset (which implements features such as
+convolution, histogram, min/max recording, color matrix and color
+tables) is not supported.<br>
+<br>
+<br>
+<h1>Appendix A: Issues</h1>
+This appendix lists documentation and subset issues with their current
+status. &nbsp;For items which are still open, the documentation (above)
+follows the recommended solution.<br>
+<br>
+<h2>A.1 Vertex Arrays</h2>
+Should vertex arrays be supported? &nbsp;Is there a performance
+advantage?<br>
+<br>
+RESOLUTION: No, there isn't enough of a performance advantage to
+justify them.<br>
+<br>
+<h2>A.2 Polygon Antialiasing and Edge Flags</h2>
+Should edge flags be supported for antialiasing?<br>
+<br>
+Edge flags don't effect antialiasing, at least not normally. &nbsp;A
+number of approaches to antialiasing have been summarized in email.<br>
+<br>
+RECOMMENDATION: don't support edge flags. &nbsp;They don't effect
+polygon antialiasing.<br>
+<br>
+RESOLUTION: closed, as of 26 Feb 2003.<br>
+<br>
+<h2>A.3 glRasterPos vs. glWindowPos</h2>
+Should glRasterPos and/or glWindowPos commands be supported?<br>
+<br>
+RESOLUTION: Closed: implement glRasterPos commands, but not glWindowPos
+commands.<br>
+<br>
+<h2>A.4 GL_IBM_rasterpos_clip extension</h2>
+Should the GL_IBM_rasterpos_clip extension be implemented?<br>
+<br>
+RESOLUTION: &nbsp;No. &nbsp;It's not required.<br>
+<br>
+<h2>A.5 Image Formats and Types</h2>
+Which image formats and types should be supported for <span
+ style="font-weight: bold;">glTexImage2D</span> and <span
+ style="font-weight: bold;">glReadPixels</span>?<br>
+<br>
+OpenGL specifies a <span style="font-weight: bold;">large</span>
+variety of image formats and data types. &nbsp;Only a few are commonly
+used.<br>
+<br>
+RECOMMENDATION: &nbsp;we propose a subset:<br>
+<br>
+For <span style="font-weight: bold;">glTexImage2D</span> only allow <span
+ style="font-style: italic;">type</span>=GL_UNSIGNED_BYTE and <span
+ style="font-style: italic;">format</span>=GL_RGBA, GL_RGB,
+GL_INTENSITY. &nbsp; Only allow <span style="font-style: italic;">internalFormat</span>
+to be GL_RGBA, GL_RGB or GL_INTENSITY as well.&nbsp; Basically, only
+support image formats/types that are directly supported by the Radeon
+hardware. &nbsp;This will allow <span style="font-weight: bold;">glTexImage2D</span>
+to basically just use <span style="font-weight: bold;">memcpy</span> to
+copy texture images.<br>
+<br>
+For <span style="font-weight: bold;">glReadPixels</span>, only allow <span
+ style="font-style: italic;">type</span> = GL_UNSIGNED_BYTE or GL_FLOAT.
+&nbsp;Only allow <span style="font-style: italic;">format</span> =
+GL_RGB or GL_RGBA. &nbsp;This is just enough to support the OpenGL
+conformance tests.<br>
+<br>
+RESOLUTION: open<br>
+<br>
+<h2>A.6 Texture Environment Modes</h2>
+Which texture environment modes should be supported? &nbsp;OpenGL 1.2
+has GL_REPLACE, GL_MODULATE, GL_DECAL and GL_BLEND. &nbsp;GL_DECAL isn't
+defined for all base internal texture formats. &nbsp;GL_ADD is another
+useful mode. &nbsp;Perhaps drop GL_DECAL mode and add GL_ADD mode.<br>
+<br>
+RECOMMENDATION: implement the standard modes GL_REPLACE, GL_MODULATE,
+GL_DECAL and GL_BLEND.<br>
+<br>
+RESOLUTION: open<br>
+<br>
+<h2>A.7 Truncated Mipmaps and LOD Control</h2>
+Should we support the GL_TEXTURE_BASE_LEVEL, GL_TEXTURE_MAX_LEVEL,
+GL_TEXTURE_MIN_LOD and GL_TEXTURE_MAX_LOD texture parameters?<br>
+<br>
+RECOMMENDATION: &nbsp;We propose omitting these features at this time,
+in the interest of simplifying the driver.<br>
+<br>
+RESOLUTION: open<br>
+<br>
+<h2>A.8 Texture Priorities and Residency</h2>
+Should the subset support texture priorities via <span
+ style="font-weight: bold;">glPrioritizeTextures</span> and the <span
+ style="font-weight: bold;">glAreTexturesResident</span> command?<br>
+<br>
+RECOMMENDATION: &nbsp;Few applications use these features and
+functions. &nbsp;We propose omitting them to simplify the driver.<br>
+<br>
+RESOLUTION: open<br>
+<br>
+<h2>A.9 Pixel Pack/Unpack Alignment Control</h2>
+Should we support the GL_PACK_ALIGNMENT and GL_UNPACK_ALIGNMENT options?<br>
+<br>
+These are used to align pixel data addresses to 1, 2 and 4-byte
+multiples for <span style="font-weight: bold;">glBitmap, glTexImage2D</span>
+and <span style="font-weight: bold;">glReadPixels</span>. &nbsp;These
+aren't strictly needed since the user can provide a 1, 2 or 4-byte
+aligned address and appropriate GL_PACK_ROW_LENGTH or
+GL_UNPACK_ROW_LENGTH values instead.<br>
+<br>
+RECOMMENDATION: &nbsp;We recommend omitting them to simplify the driver.<br>
+<br>
+RESOLUTION: open<br>
+<br>
+<h2>A.10 Pixel Pack/Unpack Skip Rows/Pixels Control</h2>
+Should we support the GL_UNPACK_SKIP_PIXELS, GL_UNPACK_SKIP_ROWS,
+GL_PACK_SKIP_PIXELS and GL_PACK_SKIP_ROWS options for pixel
+unpacking/packing?<br>
+<br>
+These options aren't really needed since the user can adjust the start
+address and GL_PACK/UNPACK_ROW_LENGTH parameters to achieve the same
+effect.<br>
+<br>
+RECOMMENDATION: &nbsp;omit these parameters.<br>
+<br>
+RESOLUTION: open<br>
+<br>
+<h2>A.11 Texture State Queries</h2>
+Should we support the command <span style="font-weight: bold;">glGetTexEnvi/fv,
+glGetTexParameteri/fv</span> and <span style="font-weight: bold;">glGetTexLevelParameteri/fv</span>?<br>
+<br>
+RECOMMENDATION: &nbsp;No.&nbsp;They're seldom needed and their
+implementation is several hundred lines of code in length.<br>
+<br>
+RESOLUTION: &nbsp;open<br>
+<br>
+<h2>A.12 glGetIntegerv, glGetBooleanv and glGetDoublev</h2>
+Should we support the commands <span style="font-weight: bold;">glGetIntegerv,
+glGetBooleanv </span>and <span style="font-weight: bold;">glGetDoublev</span>
+in addition to <span style="font-weight: bold;">glGetFloatv</span>?<br>
+<br>
+RECOMMENDATION: &nbsp;Omit the boolean, integer and double-valued
+functions. All state values which can be queried by these commands can
+be expressed as floating point values and queried with <span
+ style="font-weight: bold;">glGetFloatv</span>. &nbsp;The
+implementation of the other three commands involves many lines of code.<br>
+<br>
+RESOLUTION: &nbsp;open<br>
+<br>
+<h2>A.13 glBitmap and Per-Fragment Operations</h2>
+Should bitmaps rendered with <span style="font-weight: bold;">glBitmap</span>
+be subjected to the per-fragment operations?<br>
+<br>
+If bitmaps are implemented with points it will be easy to implement the
+per-fragment operations. &nbsp;Otherwise, it could be difficult.<br>
+<br>
+RECOMMENDATION: &nbsp;Implement glBitmap by drawing points/pixels with
+the hardware. &nbsp;This will make supporting the per-fragments
+trivially easy. &nbsp;Also, it makes portrait-mode display relatively
+easy.<br>
+<br>
+RESOLUTION: &nbsp;open<br>
+<br>
+<h2>A.14 Reduced gl.h Header File</h2>
+Should we produce a reduced gl.h header file which only defines the
+tokens and functions which are implemented by the subset?<br>
+<br>
+RECOMMENDATION: yes. &nbsp;It would be a useful reference to
+programmers to quickly determine which functions and tokens are
+supported.<br>
+<br>
+RESOLUTION: open<br>
+<br>
+<h2>A.15 glPolygonMode</h2>
+Is <span style="font-weight: bold;">glPolygonMode</span> needed?<br>
+<br>
+RECOMMENDATION: No. &nbsp;Omit it.<br>
+<br>
+RESOLUTION: closed, as of 26 Feb 2003<br>
+<br>
+<br>
+<p> </p>
+</body>
+</html>
diff --git a/nx-X11/extras/Mesa/docs/subset.html b/nx-X11/extras/Mesa/docs/subset.html
new file mode 100644
index 000000000..dd1d742a8
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/subset.html
@@ -0,0 +1,33 @@
+<HTML>
+
+<TITLE>Mesa Subset</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Mesa Subset</H1>
+
+<p>
+In 2002/2003 Tungsten Graphics was contracted to develop a subset Mesa/Radeon
+driver for an embedded environment. The result is a reduced-size DRI driver
+for the ATI R200 chip, for use with Linux fbdev rather than XFree86.
+</p>
+
+<p>
+The specification for this subset can be found
+<a href="subset-A.html">here</a>.
+</p>
+
+<p>
+The <a href="MiniGLX.html">MiniGLX specification</a> describes the
+interface between fbdev and Mesa.
+</p>
+
+<p>
+More info to come...
+</p>
+
+
+</BODY>
+</HTML>
diff --git a/nx-X11/extras/Mesa/docs/systems.html b/nx-X11/extras/Mesa/docs/systems.html
new file mode 100644
index 000000000..3a6594f5f
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/systems.html
@@ -0,0 +1,56 @@
+<HTML>
+
+<TITLE>Supported Systems and Drivers</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Supported Systems and Drivers</H1>
+
+<p>
+Mesa was originally designed for Unix/X11 systems and is still best
+supported on those systems. All you need is an ANSI C compiler and the
+X development environment to use Mesa.
+</p>
+
+<p>
+The DRI hardware drivers for the X.org server and XFree86 provide
+hardware accelerated rendering for chips from ATI, Intel, Matrox, 3dfx
+and others on Linux and FreeBSD.
+</p>
+
+<p>
+Drivers for other assorted platforms include:
+the Amiga, Apple Macintosh, BeOS, NeXT, OS/2, MS-DOS, VMS, Windows
+9x/NT, and Direct3D.
+</p>
+
+<p>
+Details about particular drivers follows.
+Be warned that some drivers may be out of date and no longer function.
+</p>
+
+<UL>
+<LI>Xlib driver for the X Window System <A HREF="README.X11">(README.X11)</A>
+<li><a href="http://dri.sourceforge.net/" target="_parent">
+DRI hardware drivers</a> for the X window system
+<LI>Microsoft Windows <A HREF="README.WIN32">(README.WIN32)</A>
+<LI>DEC VMS <A HREF="README.VMS">(README.VMS)</A>
+<LI>3dfx/Glide <A HREF="README.3DFX">(README.3DFX)</A>
+<LI>GGI <A HREF="README.GGI">(README.GGI)</A>
+<LI>Amiga Amiwin <A HREF="README.AMIWIN">(README.AMIWIN)</A>
+<LI>BeOS <A HREF="README.BEOS">(README.BEOS)</A>
+<LI>Direct3D driver <A HREF="README.D3D">(README.D3D)</A>
+<LI>DJGPP <A HREF="README.DJ">(README.DJ)</A>
+<LI>LynxOS <A HREF="README.LYNXOS">(README.LYNXOS)</A>
+<LI>Mingw32 <A HREF="README.MINGW32">(README.MINGW32)</A>
+<LI>NeXT <A HREF="README.NeXT">(README.NeXT)</A>
+<LI>OpenStep <A HREF="README.OpenStep">(README.OpenStep)</A>
+<LI>OS/2 <A HREF="README.OS2">(README.OS2)</A>
+<LI>WindML <A HREF="README.WINDML">(README.WINDML)</A>
+<LI><a href="http://utah-glx.sourceforge.net/" target="_parent">Utah GLX drivers</a>
+</UL>
+
+</body>
+</html> \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/docs/thanks.html b/nx-X11/extras/Mesa/docs/thanks.html
new file mode 100644
index 000000000..78b9e3e5e
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/thanks.html
@@ -0,0 +1,134 @@
+<HTML>
+
+<HEAD>
+<TITLE>Acknowledgements</TITLE>
+</HEAD>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Acknowledgments</H1>
+
+
+The following individuals and groups are to be acknowledged for their
+contributions to Mesa over the years.
+This list is far from complete and somewhat dated, unfortunately.
+
+
+<ul>
+<li>Early Mesa development was done while Brian was part of the
+<A HREF="http://www.ssec.wisc.edu/~billh/vis.html"
+target="_parent">SSEC Visualization Project</A> at the University of
+Wisconsin. He'd like to thank Bill Hibbard for letting him work on
+Mesa as part of that project.
+<br>
+<br>
+<li>John Carmack of id Software, Inc. funded Keith Whitwell in 1999 in
+order to optimize Mesa's vertex transformation module. This is a very
+substantial piece of work.
+<br>
+<br>
+<li>Precision Insight, Inc., VA Linux Systems, Inc., and most recently,
+Tungsten Graphics, Inc. have supported the ongoing development of Mesa.
+<br>
+<br>
+<li>The
+<A HREF="http://sourceforge.net/projects/mesa3d" target="_parent">Mesa</A>
+website is hosted by
+<A HREF="http://sourceforge.net" target="_parent">
+<IMG SRC="http://sourceforge.net/sflogo.php?group_id=3&type=1"
+WIDTH="88" HEIGHT="31" ALIGN="BOTTOM" ALT="Sourceforge.net" BORDER="0"></A>
+<br>
+<br>
+
+<li>The Mesa CVS repository is hosted by
+<a href="http://freedesktop.org/" target="_parent">freedesktop.org</a>.
+<br>
+<br>
+
+
+<li><a href="http://www.altsoftware.com/"
+target="_parent">alt.software</a> contributed the Direct3D driver.
+
+<li><b>Bernd Barsuhn</b> wrote the evaluator code for (splines,
+patches) in Mesa.
+
+<li><b>Bernhard Tschirren</b> wrote the Allegro DJGPP driver.
+
+<li><b>Bogdan Sikorski</b> wrote the GLU NURBS and polygon tessellator
+in Mesa.
+
+<li><b>Charlie Wallace</b> wrote the MS-DOS driver.
+
+<li><b>CJ Beyer</b> was the www.mesa3d.org webmaster.
+
+<li><b>Darren Abbott</b> provided the OS/2 driver.
+
+<li><b>David Bucciarelli</b> wrote and maintained the 3Dfx Glide
+driver. Thousands of Linux/Quake players thank David!
+
+<li><b>Gareth Hughes</b> wrote new GLU 1.2 Polygon Tessellation code
+(now superceded by SGI SI GLU).
+
+<li><b>Holger Waechtler</b> contributed AMD 3DNow! assembly code which
+accelerates vertex transformation in Mesa 3.1. Holger also implemented
+the GL_EXT_texture_env_combine extension.
+
+<li><b>Jeroen van der Zijp</b> and <b>Thorsten Ohl</b> contributed the
+Xt/Motif widget code.
+
+<li><b>John Stone</b> provided the multi-threading support in Mesa 3.0.
+
+<li><b>John Watson</b> assisted with web page design.
+
+<li><b>Josh Vanderhoof</b> contributed Intel x86 assembly code which
+accelerates vertex transformation in Mesa 3.x.
+
+<li><b>Jouk Jansen</b> contributed and continues to maintain the VMS
+support.
+
+<li><b>Karl Schultz</b> has been maintaining the Windows driver.
+
+<li><b>Keith Whitwell</b> has made extension contributions to Mesa
+since 1999.
+
+<li><b>Kendall Bennett</b> wrote the SciTech MGL driver.
+
+<li><b>Klaus Niederkrueger</b> contributed many improvements to Mesa's
+software rasterizer.
+
+<li><b>Mark Kilgard</b> contributed antialiased line improvements and
+several extensions.
+
+<li><b>Michael Pichler</b> contributed <em>many</em> bug fixes
+
+<li><b>Miklos Fazekas</b> wrote and maintains the Macintosh driver.
+
+<li><b>Pascal Thibaudeau</b> wrote the NeXT driver.
+
+<li><b>Pedro Vazquez</b> setup and maintains the Mesa Mailing list.
+
+<li><b>Randy Frank</b> contributed <em>many</em> bug fixes.
+
+<li><b>Stefan Zivkovic</b> wrote the Amiga driver.
+
+<li><b>Stephane Rehel</b> provided the Cygnus Win32 support
+
+<li><b>Ted Jump</b> maintained the
+makefiles and project files for Windows 95/98/NT compilation for some time.
+
+<li><b>Uwe Maurer</b> wrote the LibGGI driver for Mesa-3.0.
+
+<li><b>Victor Ng-Thow-Hing</b> wrote the Amiwin driver for the Amiga.
+
+</ul>
+
+<p>
+Apologies to anyone who's been omitted.
+Please send corrections and additions to Brian.
+</p>
+
+
+</BODY>
+</HTML>
diff --git a/nx-X11/extras/Mesa/docs/utilities.html b/nx-X11/extras/Mesa/docs/utilities.html
new file mode 100644
index 000000000..4693639b8
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/utilities.html
@@ -0,0 +1,26 @@
+<HTML>
+
+<TITLE>Development Utilities</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Development Utilities</H1>
+
+<ul>
+
+<li>The Mesa distribution includes several utility routines in the
+progs/util/ directory
+
+<li>Allen Akin's <a href="http://glean.sourceforge.net/"
+target="_parent">glean</a> is a framework for OpenGL testing.
+
+<li><a href="http://developer.kde.org/~sewardj/"
+target="_parent">Valgrind</a> is a very useful tool for tracking down
+memory-related problems in your code.
+
+</ul>
+
+</body>
+</html> \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/docs/utility.html b/nx-X11/extras/Mesa/docs/utility.html
new file mode 100644
index 000000000..c7cad0114
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/utility.html
@@ -0,0 +1,44 @@
+<HTML>
+
+<TITLE>Utilities</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Utilities</H1>
+
+<ul>
+<li><a href="http://fsv.sourceforge.net/"
+ target="_parent">fsv</a> - 3D file system visualizer
+
+<li><a href="http://www.dgp.utoronto.ca/%7Emac/projects/glbiff.html"
+ target="_parent">glbiff</a> - GL version of xbiff
+
+<li><a href="http://glload.netpedia.net/" target="_parent">glload</a>
+ - CPU load meter
+
+<li><a href="http://www.scitechsoft.com/gldirect.html"
+ target="_parent">SciTech GLDirect</a> - Driver to run OpenGL
+ apps using Direct3D under Windows
+
+<li><a href="http://threedsia.sourceforge.net/"
+ target="_parent">3Dsia</a> - 3D user interface
+
+<li><a href="http://mesa3d.sourceforge.net/notfound.html">VRML Site
+Map</a> - 3D GUI
+
+<li><a href="http://www.vros.com/" target="_parent">VR/OS</a> - VR
+user interface
+
+<li><a href="http://wauug.erols.com/%7Ebagleyd/"
+target="_parent">xlockmore</a> - an X screen saver
+
+<li><a href="http://www.jwz.org/xscreensaver"
+target="_parent">xscreensaver</a> - X screen saver
+
+</ul>
+
+
+</body>
+</html>
diff --git a/nx-X11/extras/Mesa/docs/webmaster.html b/nx-X11/extras/Mesa/docs/webmaster.html
new file mode 100644
index 000000000..e645b90ba
--- /dev/null
+++ b/nx-X11/extras/Mesa/docs/webmaster.html
@@ -0,0 +1,24 @@
+<HTML>
+
+<TITLE>Mesa Introduction</TITLE>
+
+<link rel="stylesheet" type="text/css" href="mesa.css"></head>
+
+<BODY>
+
+<H1>Webmaster</font></H1>
+
+<p>
+If you have problems, edits or additions for this website send them
+to Brian
+(<em>b</em><em>r</em><em>i</em><em>a</em><em>n</em><em>_</em><em>e</em><em>_</em><em>p</em><em>a</em><em>u</em><em>l</em><em>@</em><em>y</em><em>a</em><em>h</em><em>o</em><em>o</em><em>.</em><em>c</em><em>o</em><em>m</em>)</a>.
+</p>
+
+<p>
+Mark Manning made the frame-based layout for the website.
+Brian's modified it a lot since then.
+</p>
+
+
+</body>
+</html> \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/include/GL/Makefile.am b/nx-X11/extras/Mesa/include/GL/Makefile.am
new file mode 100644
index 000000000..199bd5c8f
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/Makefile.am
@@ -0,0 +1,43 @@
+## Process this file with automake to produce Makefile.in
+
+GLincludedir = $(includedir)/GL
+
+INC_FX = fxmesa.h
+INC_GGI = ggimesa.h
+INC_OSMESA = osmesa.h
+INC_SVGA = svgamesa.h
+INC_X11 = glx.h glxext.h glx_mangle.h xmesa.h xmesa_x.h xmesa_xf86.h
+INC_GLUT = glut.h glutf90.h
+
+if HAVE_FX
+sel_inc_fx = $(INC_FX)
+endif
+
+if HAVE_GGI
+sel_inc_ggi = $(INC_GGI)
+endif
+
+if HAVE_OSMESA
+sel_inc_osmesa = $(INC_OSMESA)
+endif
+
+if HAVE_SVGA
+sel_inc_svga = $(INC_SVGA)
+endif
+
+if HAVE_X11
+sel_inc_x11 = $(INC_X11)
+endif
+
+if NEED_GLUT
+sel_inc_glut = $(INC_GLUT)
+endif
+
+EXTRA_HEADERS = amesa.h dosmesa.h foomesa.h glut_h.dja mesa_wgl.h mglmesa.h \
+ vms_x_fix.h wmesa.h \
+ $(INC_FX) $(INC_GGI) $(INC_OSMESA) $(INC_SVGA) $(INC_X11) $(INC_GLUT)
+
+GLinclude_HEADERS = gl.h glext.h gl_mangle.h glu.h glu_mangle.h \
+ $(sel_inc_fx) $(sel_inc_ggi) $(sel_inc_osmesa) $(sel_inc_svga) \
+ $(sel_inc_x11) $(sel_inc_glut)
+include $(top_srcdir)/common_rules.make
diff --git a/nx-X11/extras/Mesa/include/GL/amesa.h b/nx-X11/extras/Mesa/include/GL/amesa.h
new file mode 100644
index 000000000..852d34cf4
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/amesa.h
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+
+/* Allegro (DJGPP) driver by Bernhard Tschirren (bernie-t@geocities.com) */
+
+
+#ifndef AMESA_H
+#define AMESA_H
+
+
+#define AMESA_MAJOR_VERSION 3
+#define AMESA_MINOR_VERSION 3
+
+
+typedef struct amesa_visual *AMesaVisual;
+typedef struct amesa_buffer *AMesaBuffer;
+typedef struct amesa_context *AMesaContext;
+
+
+extern AMesaVisual AMesaCreateVisual(GLboolean dbFlag, GLint depth,
+ GLint depthSize,
+ GLint stencilSize,
+ GLint accumSize);
+
+extern void AMesaDestroyVisual(AMesaVisual visual);
+
+extern AMesaBuffer AMesaCreateBuffer(AMesaVisual visual,
+ GLint width, GLint height);
+
+extern void AMesaDestroyBuffer(AMesaBuffer buffer);
+
+
+extern AMesaContext AMesaCreateContext(AMesaVisual visual,
+ AMesaContext sharelist);
+
+extern void AMesaDestroyContext(AMesaContext context);
+
+extern GLboolean AMesaMakeCurrent(AMesaContext context, AMesaBuffer buffer);
+
+extern void AMesaSwapBuffers(AMesaBuffer buffer);
+
+
+#endif /* AMESA_H */
diff --git a/nx-X11/extras/Mesa/include/GL/directfbgl.h b/nx-X11/extras/Mesa/include/GL/directfbgl.h
new file mode 100644
index 000000000..984c4b142
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/directfbgl.h
@@ -0,0 +1,89 @@
+/*
+ (c) Copyright 2001 convergence integrated media GmbH.
+ All rights reserved.
+
+ Written by Denis Oliver Kropp <dok@convergence.de> and
+ Andreas Hundt <andi@convergence.de>.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+#ifndef __DIRECTFBGL_H__
+#define __DIRECTFBGL_H__
+
+#include <directfb.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+typedef struct {
+ int buffer_size;
+ int depth_size;
+ int stencil_size;
+ int aux_buffers;
+
+ int red_size;
+ int green_size;
+ int blue_size;
+ int alpha_size;
+
+ int accum_red_size;
+ int accum_green_size;
+ int accum_blue_size;
+ int accum_alpha_size;
+
+ DFBBoolean double_buffer;
+ DFBBoolean stereo;
+} DFBGLAttributes;
+
+
+DEFINE_INTERFACE( IDirectFBGL,
+
+ /** Context handling **/
+
+ /*
+ * Acquire the hardware lock.
+ */
+ DFBResult (*Lock) (
+ IDirectFBGL *thiz
+ );
+
+ /*
+ * Release the lock.
+ */
+ DFBResult (*Unlock) (
+ IDirectFBGL *thiz
+ );
+
+ /*
+ * Query the OpenGL attributes.
+ */
+ DFBResult (*GetAttributes) (
+ IDirectFBGL *thiz,
+ DFBGLAttributes *attributes
+ );
+)
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/include/GL/dmesa.h b/nx-X11/extras/Mesa/include/GL/dmesa.h
new file mode 100644
index 000000000..e67b3426f
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/dmesa.h
@@ -0,0 +1,160 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+/*
+ * DOS/DJGPP device driver v1.7 for Mesa
+ *
+ * Copyright (C) 2002 - Daniel Borca
+ * Email : dborca@users.sourceforge.net
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#ifndef DMESA_H_included
+#define DMESA_H_included
+
+#define DMESA_MAJOR_VERSION 6
+#define DMESA_MINOR_VERSION 3
+
+/* Sample Usage:
+ *
+ * 1. Call DMesaCreateVisual() to initialize graphics.
+ * 2. Call DMesaCreateContext() to create a DMesa rendering context.
+ * 3. Call DMesaCreateBuffer() to define the window.
+ * 4. Call DMesaMakeCurrent() to bind the DMesaBuffer to a DMesaContext.
+ * 5. Make gl* calls to render your graphics.
+ * 6. Use DMesaSwapBuffers() when double buffering to swap front/back buffers.
+ * 7. Before exiting, destroy DMesaBuffer, DMesaContext and DMesaVisual.
+ */
+
+typedef struct dmesa_context *DMesaContext;
+typedef struct dmesa_visual *DMesaVisual;
+typedef struct dmesa_buffer *DMesaBuffer;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Create a new Visual and set graphics mode.
+ */
+DMesaVisual DMesaCreateVisual (GLint width, /* X res */
+ GLint height, /* Y res */
+ GLint colDepth, /* BPP */
+ GLint refresh, /* refresh rate: 0=default */
+ GLboolean dbFlag, /* double-buffered */
+ GLboolean rgbFlag, /* RGB mode */
+ GLint alphaSize, /* requested bits/alpha */
+ GLint depthSize, /* requested bits/depth */
+ GLint stencilSize, /* requested bits/stencil */
+ GLint accumSize); /* requested bits/accum */
+
+/*
+ * Destroy Visual and restore screen.
+ */
+void DMesaDestroyVisual (DMesaVisual v);
+
+
+
+/*
+ * Create a new Context for rendering.
+ */
+DMesaContext DMesaCreateContext (DMesaVisual visual, DMesaContext share);
+
+/*
+ * Destroy Context.
+ */
+void DMesaDestroyContext (DMesaContext c);
+
+/*
+ * Return a handle to the current context.
+ */
+DMesaContext DMesaGetCurrentContext (void);
+
+
+
+/*
+ * Create a new Buffer (window).
+ */
+DMesaBuffer DMesaCreateBuffer (DMesaVisual visual,
+ GLint xpos, GLint ypos,
+ GLint width, GLint height);
+
+/*
+ * Destroy Buffer.
+ */
+void DMesaDestroyBuffer (DMesaBuffer b);
+
+/*
+ * Return a handle to the current buffer.
+ */
+DMesaBuffer DMesaGetCurrentBuffer (void);
+
+/*
+ * Swap the front and back buffers for the given Buffer.
+ * No action is taken if the buffer is not double buffered.
+ */
+void DMesaSwapBuffers (DMesaBuffer b);
+
+/*
+ * Bind Buffer to Context and make the Context the current one.
+ */
+GLboolean DMesaMakeCurrent (DMesaContext c, DMesaBuffer b);
+
+
+
+/*
+ * Move/Resize current Buffer.
+ */
+GLboolean DMesaMoveBuffer (GLint xpos, GLint ypos);
+GLboolean DMesaResizeBuffer (GLint width, GLint height);
+
+/*
+ * Set palette index, using normalized values.
+ */
+void DMesaSetCI (int ndx, GLfloat red, GLfloat green, GLfloat blue);
+
+/*
+ * DMesa functions
+ */
+typedef void (*DMesaProc) (void);
+DMesaProc DMesaGetProcAddress (const char *name);
+
+/*
+ * DMesa state retrieval.
+ */
+#define DMESA_GET_SCREEN_SIZE 0x0100
+#define DMESA_GET_DRIVER_CAPS 0x0200
+#define DMESA_GET_VIDEO_MODES 0x0300
+#define DMESA_GET_BUFFER_ADDR 0x0400
+
+#define DMESA_DRIVER_SWDB_BIT 0x1 /* software double-buffered */
+#define DMESA_DRIVER_LLWO_BIT 0x2 /* lower-left window origin */
+int DMesaGetIntegerv (GLenum pname, GLint *params);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/foomesa.h b/nx-X11/extras/Mesa/include/GL/foomesa.h
new file mode 100644
index 000000000..8517d8838
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/foomesa.h
@@ -0,0 +1,76 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.0
+ * Copyright (C) 1995-1998 Brian Paul
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+/*
+ * Example Foo/Mesa interface. See src/ddsample.c for more info.
+ */
+
+
+
+#ifndef FOOMESA_H
+#define FOOMESA_H
+
+
+
+typedef struct foo_mesa_visual *FooMesaVisual;
+
+typedef struct foo_mesa_buffer *FooMesaBuffer;
+
+typedef struct foo_mesa_context *FooMesaContext;
+
+
+
+#ifdef BEOS
+#pragma export on
+#endif
+
+
+extern FooMesaVisual FooMesaChooseVisual( /* your params */ );
+
+extern void FooMesaDestroyVisual( FooMesaVisual visual );
+
+
+extern FooMesaBuffer FooMesaCreateBuffer( FooMesaVisual visual,
+ void *your_window_id );
+
+extern void FooMesaDestroyBuffer( FooMesaBuffer buffer );
+
+
+extern FooMesaContext FooMesaCreateContext( FooMesaVisual visual,
+ FooMesaContext sharelist );
+
+extern void FooMesaDestroyContext( FooMesaContext context );
+
+
+extern void FooMesaMakeCurrent( FooMesaContext context, FooMesaBuffer buffer );
+
+
+extern void FooMesaSwapBuffers( FooMesaBuffer buffer );
+
+
+/* Probably some more functions... */
+
+
+#ifdef BEOS
+#pragma export off
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/fxmesa.h b/nx-X11/extras/Mesa/include/GL/fxmesa.h
new file mode 100644
index 000000000..f8e9661f9
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/fxmesa.h
@@ -0,0 +1,103 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.0
+ * Copyright (C) 1995-2001 Brian Paul
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+/*
+ * FXMesa - 3Dfx Glide driver for Mesa. Contributed by David Bucciarelli
+ *
+ * NOTE: This version requires Glide3 (http://sourceforge.net/projects/glide)
+ */
+
+
+#ifndef FXMESA_H
+#define FXMESA_H
+
+
+#include <glide.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define FXMESA_MAJOR_VERSION 6
+#define FXMESA_MINOR_VERSION 3
+
+
+/*
+ * Values for attribList parameter to fxMesaCreateContext():
+ */
+#define FXMESA_NONE 0 /* to terminate attribList */
+#define FXMESA_DOUBLEBUFFER 10
+#define FXMESA_ALPHA_SIZE 11 /* followed by an integer */
+#define FXMESA_DEPTH_SIZE 12 /* followed by an integer */
+#define FXMESA_STENCIL_SIZE 13 /* followed by an integer */
+#define FXMESA_ACCUM_SIZE 14 /* followed by an integer */
+#define FXMESA_COLORDEPTH 20 /* followed by an integer */
+#define FXMESA_SHARE_CONTEXT 990099 /* keep in sync with xmesa1.c! */
+
+
+
+typedef struct tfxMesaContext *fxMesaContext;
+
+
+#if defined (__BEOS__)
+#pragma export on
+#endif
+
+
+GLAPI fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win, GrScreenResolution_t,
+ GrScreenRefresh_t,
+ const GLint attribList[]);
+
+GLAPI fxMesaContext GLAPIENTRY fxMesaCreateBestContext(GLuint win,
+ GLint width, GLint height,
+ const GLint attribList[]);
+GLAPI void GLAPIENTRY fxMesaDestroyContext(fxMesaContext ctx);
+
+GLAPI GLint GLAPIENTRY fxMesaSelectCurrentBoard(int n);
+
+GLAPI void GLAPIENTRY fxMesaMakeCurrent(fxMesaContext ctx);
+
+GLAPI fxMesaContext GLAPIENTRY fxMesaGetCurrentContext(void);
+
+GLAPI void GLAPIENTRY fxMesaSwapBuffers(void);
+
+GLAPI void GLAPIENTRY fxMesaSetNearFar(GLfloat nearVal, GLfloat farVal);
+
+GLAPI void GLAPIENTRY fxMesaUpdateScreenSize(fxMesaContext ctx);
+
+GLAPI void GLAPIENTRY fxCloseHardware(void);
+
+GLAPI void GLAPIENTRY fxGetScreenGeometry (GLint *w, GLint *h);
+
+
+#if defined (__BEOS__)
+#pragma export off
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/ggimesa.h b/nx-X11/extras/Mesa/include/GL/ggimesa.h
new file mode 100644
index 000000000..90e0b4222
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/ggimesa.h
@@ -0,0 +1,85 @@
+/*
+ * Mesa 3-D graphics library GGI bindings (GGIGL [giggle])
+ * Version: 4.0
+ * Copyright (C) 1995-2000 Brian Paul
+ * Copyright (C) 1998 Uwe Maurer
+ * Copyrigth (C) 2001 Filip Spacek
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#ifndef GGIMESA_H
+#define GGIMESA_H
+
+#define GGIMESA_MAJOR_VERSION 4
+#define GGIMESA_MINOR_VERSION 0
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <ggi/ggi.h>
+#include "GL/gl.h"
+
+typedef struct ggi_mesa_context *ggi_mesa_context_t;
+
+/*
+ * Initialize Mesa GGI extension
+ */
+int ggiMesaInit(void);
+/*
+ * Clean up Mesa GGI exension
+ */
+int ggiMesaExit(void);
+
+/*
+ * Attach Mesa GGI extension to the visual 'vis'
+ */
+int ggiMesaAttach(ggi_visual_t vis);
+/*
+ * Detach Mesa GGI extension from the visual 'vis'
+ */
+int ggiMesaDetach(ggi_visual_t vis);
+
+int ggiMesaExtendVisual(ggi_visual_t vis, GLboolean alpha_flag,
+ GLboolean stereo_flag, GLint depth_size,
+ GLint stencil_size, GLint accum_red_size,
+ GLint accum_green_size, GLint accum_blue_size,
+ GLint accum_alpha_size, GLint num_samples);
+
+/*
+ * Create a new context capable of displaying on the visual vis.
+ */
+ggi_mesa_context_t ggiMesaCreateContext(ggi_visual_t vis);
+/*
+ * Destroy the context 'ctx'
+ */
+void ggiMesaDestroyContext(ggi_mesa_context_t ctx);
+
+/*
+ * Make context 'ctx' the current context and bind it to visual 'vis'.
+ * Note that the context must have been created with respect to that visual.
+ */
+void ggiMesaMakeCurrent(ggi_mesa_context_t ctx, ggi_visual_t vis);
+
+void ggiMesaSwapBuffers(void);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/gl.h b/nx-X11/extras/Mesa/include/GL/gl.h
new file mode 100644
index 000000000..1ea97f390
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/gl.h
@@ -0,0 +1,2261 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef __gl_h_
+#define __gl_h_
+
+#if defined(USE_MGL_NAMESPACE)
+#include "gl_mangle.h"
+#endif
+
+
+/**********************************************************************
+ * Begin system-specific stuff. Do not do any of this when building
+ * for SciTech SNAP, as this is all done before this header file is
+ * included.
+ */
+#if !defined(__SCITECH_SNAP__)
+
+#if defined(__BEOS__)
+#include <stdlib.h> /* to get some BeOS-isms */
+#endif
+
+#if !defined(OPENSTEP) && (defined(NeXT) || defined(NeXT_PDO))
+#define OPENSTEP
+#endif
+
+#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__)
+#define __WIN32__
+#endif
+
+#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__))
+# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
+# define GLAPI __declspec(dllexport)
+# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
+# define GLAPI __declspec(dllimport)
+# else /* for use with static link lib build of Win32 edition only */
+# define GLAPI extern
+# endif /* _STATIC_MESA support */
+# define GLAPIENTRY __stdcall
+#elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */
+# define GLAPI extern
+# define GLAPIENTRY __stdcall
+#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
+# define GLAPI __attribute__((visibility("default")))
+# define GLAPIENTRY
+#endif /* WIN32 && !CYGWIN */
+
+#if (defined(__BEOS__) && defined(__POWERPC__)) || defined(__QUICKDRAW__)
+# define PRAGMA_EXPORT_SUPPORTED 1
+#endif
+
+/*
+ * WINDOWS: Include windows.h here to define APIENTRY.
+ * It is also useful when applications include this file by
+ * including only glut.h, since glut.h depends on windows.h.
+ * Applications needing to include windows.h with parms other
+ * than "WIN32_LEAN_AND_MEAN" may include windows.h before
+ * glut.h or gl.h.
+ */
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(__CYGWIN__)
+#include <GL/mesa_wgl.h>
+#endif
+
+#if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED
+#pragma import on
+#endif
+
+#ifndef GLAPI
+#define GLAPI extern
+#endif
+
+#ifndef GLAPIENTRY
+#define GLAPIENTRY
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY GLAPIENTRY
+#endif
+
+/* "P" suffix to be used for a pointer to a function */
+#ifndef APIENTRYP
+#define APIENTRYP APIENTRY *
+#endif
+
+#ifndef GLAPIENTRYP
+#define GLAPIENTRYP GLAPIENTRY *
+#endif
+
+#ifdef CENTERLINE_CLPP
+#define signed
+#endif
+
+#if defined(PRAGMA_EXPORT_SUPPORTED)
+#pragma export on
+#endif
+
+#endif /* !__SCITECH_SNAP__ */
+/*
+ * End system-specific stuff.
+ **********************************************************************/
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+#define GL_VERSION_1_1 1
+#define GL_VERSION_1_2 1
+#define GL_VERSION_1_3 1
+#define GL_ARB_imaging 1
+
+
+/*
+ * Datatypes
+ */
+typedef unsigned int GLenum;
+typedef unsigned char GLboolean;
+typedef unsigned int GLbitfield;
+typedef void GLvoid;
+typedef signed char GLbyte; /* 1-byte signed */
+typedef short GLshort; /* 2-byte signed */
+typedef int GLint; /* 4-byte signed */
+typedef unsigned char GLubyte; /* 1-byte unsigned */
+typedef unsigned short GLushort; /* 2-byte unsigned */
+typedef unsigned int GLuint; /* 4-byte unsigned */
+typedef int GLsizei; /* 4-byte signed */
+typedef float GLfloat; /* single precision float */
+typedef float GLclampf; /* single precision float in [0,1] */
+typedef double GLdouble; /* double precision float */
+typedef double GLclampd; /* double precision float in [0,1] */
+
+
+
+/*
+ * Constants
+ */
+
+/* Boolean values */
+#define GL_FALSE 0x0
+#define GL_TRUE 0x1
+
+/* Data types */
+#define GL_BYTE 0x1400
+#define GL_UNSIGNED_BYTE 0x1401
+#define GL_SHORT 0x1402
+#define GL_UNSIGNED_SHORT 0x1403
+#define GL_INT 0x1404
+#define GL_UNSIGNED_INT 0x1405
+#define GL_FLOAT 0x1406
+#define GL_2_BYTES 0x1407
+#define GL_3_BYTES 0x1408
+#define GL_4_BYTES 0x1409
+#define GL_DOUBLE 0x140A
+
+/* Primitives */
+#define GL_POINTS 0x0000
+#define GL_LINES 0x0001
+#define GL_LINE_LOOP 0x0002
+#define GL_LINE_STRIP 0x0003
+#define GL_TRIANGLES 0x0004
+#define GL_TRIANGLE_STRIP 0x0005
+#define GL_TRIANGLE_FAN 0x0006
+#define GL_QUADS 0x0007
+#define GL_QUAD_STRIP 0x0008
+#define GL_POLYGON 0x0009
+
+/* Vertex Arrays */
+#define GL_VERTEX_ARRAY 0x8074
+#define GL_NORMAL_ARRAY 0x8075
+#define GL_COLOR_ARRAY 0x8076
+#define GL_INDEX_ARRAY 0x8077
+#define GL_TEXTURE_COORD_ARRAY 0x8078
+#define GL_EDGE_FLAG_ARRAY 0x8079
+#define GL_VERTEX_ARRAY_SIZE 0x807A
+#define GL_VERTEX_ARRAY_TYPE 0x807B
+#define GL_VERTEX_ARRAY_STRIDE 0x807C
+#define GL_NORMAL_ARRAY_TYPE 0x807E
+#define GL_NORMAL_ARRAY_STRIDE 0x807F
+#define GL_COLOR_ARRAY_SIZE 0x8081
+#define GL_COLOR_ARRAY_TYPE 0x8082
+#define GL_COLOR_ARRAY_STRIDE 0x8083
+#define GL_INDEX_ARRAY_TYPE 0x8085
+#define GL_INDEX_ARRAY_STRIDE 0x8086
+#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088
+#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089
+#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A
+#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C
+#define GL_VERTEX_ARRAY_POINTER 0x808E
+#define GL_NORMAL_ARRAY_POINTER 0x808F
+#define GL_COLOR_ARRAY_POINTER 0x8090
+#define GL_INDEX_ARRAY_POINTER 0x8091
+#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092
+#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093
+#define GL_V2F 0x2A20
+#define GL_V3F 0x2A21
+#define GL_C4UB_V2F 0x2A22
+#define GL_C4UB_V3F 0x2A23
+#define GL_C3F_V3F 0x2A24
+#define GL_N3F_V3F 0x2A25
+#define GL_C4F_N3F_V3F 0x2A26
+#define GL_T2F_V3F 0x2A27
+#define GL_T4F_V4F 0x2A28
+#define GL_T2F_C4UB_V3F 0x2A29
+#define GL_T2F_C3F_V3F 0x2A2A
+#define GL_T2F_N3F_V3F 0x2A2B
+#define GL_T2F_C4F_N3F_V3F 0x2A2C
+#define GL_T4F_C4F_N3F_V4F 0x2A2D
+
+/* Matrix Mode */
+#define GL_MATRIX_MODE 0x0BA0
+#define GL_MODELVIEW 0x1700
+#define GL_PROJECTION 0x1701
+#define GL_TEXTURE 0x1702
+
+/* Points */
+#define GL_POINT_SMOOTH 0x0B10
+#define GL_POINT_SIZE 0x0B11
+#define GL_POINT_SIZE_GRANULARITY 0x0B13
+#define GL_POINT_SIZE_RANGE 0x0B12
+
+/* Lines */
+#define GL_LINE_SMOOTH 0x0B20
+#define GL_LINE_STIPPLE 0x0B24
+#define GL_LINE_STIPPLE_PATTERN 0x0B25
+#define GL_LINE_STIPPLE_REPEAT 0x0B26
+#define GL_LINE_WIDTH 0x0B21
+#define GL_LINE_WIDTH_GRANULARITY 0x0B23
+#define GL_LINE_WIDTH_RANGE 0x0B22
+
+/* Polygons */
+#define GL_POINT 0x1B00
+#define GL_LINE 0x1B01
+#define GL_FILL 0x1B02
+#define GL_CW 0x0900
+#define GL_CCW 0x0901
+#define GL_FRONT 0x0404
+#define GL_BACK 0x0405
+#define GL_POLYGON_MODE 0x0B40
+#define GL_POLYGON_SMOOTH 0x0B41
+#define GL_POLYGON_STIPPLE 0x0B42
+#define GL_EDGE_FLAG 0x0B43
+#define GL_CULL_FACE 0x0B44
+#define GL_CULL_FACE_MODE 0x0B45
+#define GL_FRONT_FACE 0x0B46
+#define GL_POLYGON_OFFSET_FACTOR 0x8038
+#define GL_POLYGON_OFFSET_UNITS 0x2A00
+#define GL_POLYGON_OFFSET_POINT 0x2A01
+#define GL_POLYGON_OFFSET_LINE 0x2A02
+#define GL_POLYGON_OFFSET_FILL 0x8037
+
+/* Display Lists */
+#define GL_COMPILE 0x1300
+#define GL_COMPILE_AND_EXECUTE 0x1301
+#define GL_LIST_BASE 0x0B32
+#define GL_LIST_INDEX 0x0B33
+#define GL_LIST_MODE 0x0B30
+
+/* Depth buffer */
+#define GL_NEVER 0x0200
+#define GL_LESS 0x0201
+#define GL_EQUAL 0x0202
+#define GL_LEQUAL 0x0203
+#define GL_GREATER 0x0204
+#define GL_NOTEQUAL 0x0205
+#define GL_GEQUAL 0x0206
+#define GL_ALWAYS 0x0207
+#define GL_DEPTH_TEST 0x0B71
+#define GL_DEPTH_BITS 0x0D56
+#define GL_DEPTH_CLEAR_VALUE 0x0B73
+#define GL_DEPTH_FUNC 0x0B74
+#define GL_DEPTH_RANGE 0x0B70
+#define GL_DEPTH_WRITEMASK 0x0B72
+#define GL_DEPTH_COMPONENT 0x1902
+
+/* Lighting */
+#define GL_LIGHTING 0x0B50
+#define GL_LIGHT0 0x4000
+#define GL_LIGHT1 0x4001
+#define GL_LIGHT2 0x4002
+#define GL_LIGHT3 0x4003
+#define GL_LIGHT4 0x4004
+#define GL_LIGHT5 0x4005
+#define GL_LIGHT6 0x4006
+#define GL_LIGHT7 0x4007
+#define GL_SPOT_EXPONENT 0x1205
+#define GL_SPOT_CUTOFF 0x1206
+#define GL_CONSTANT_ATTENUATION 0x1207
+#define GL_LINEAR_ATTENUATION 0x1208
+#define GL_QUADRATIC_ATTENUATION 0x1209
+#define GL_AMBIENT 0x1200
+#define GL_DIFFUSE 0x1201
+#define GL_SPECULAR 0x1202
+#define GL_SHININESS 0x1601
+#define GL_EMISSION 0x1600
+#define GL_POSITION 0x1203
+#define GL_SPOT_DIRECTION 0x1204
+#define GL_AMBIENT_AND_DIFFUSE 0x1602
+#define GL_COLOR_INDEXES 0x1603
+#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
+#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51
+#define GL_LIGHT_MODEL_AMBIENT 0x0B53
+#define GL_FRONT_AND_BACK 0x0408
+#define GL_SHADE_MODEL 0x0B54
+#define GL_FLAT 0x1D00
+#define GL_SMOOTH 0x1D01
+#define GL_COLOR_MATERIAL 0x0B57
+#define GL_COLOR_MATERIAL_FACE 0x0B55
+#define GL_COLOR_MATERIAL_PARAMETER 0x0B56
+#define GL_NORMALIZE 0x0BA1
+
+/* User clipping planes */
+#define GL_CLIP_PLANE0 0x3000
+#define GL_CLIP_PLANE1 0x3001
+#define GL_CLIP_PLANE2 0x3002
+#define GL_CLIP_PLANE3 0x3003
+#define GL_CLIP_PLANE4 0x3004
+#define GL_CLIP_PLANE5 0x3005
+
+/* Accumulation buffer */
+#define GL_ACCUM_RED_BITS 0x0D58
+#define GL_ACCUM_GREEN_BITS 0x0D59
+#define GL_ACCUM_BLUE_BITS 0x0D5A
+#define GL_ACCUM_ALPHA_BITS 0x0D5B
+#define GL_ACCUM_CLEAR_VALUE 0x0B80
+#define GL_ACCUM 0x0100
+#define GL_ADD 0x0104
+#define GL_LOAD 0x0101
+#define GL_MULT 0x0103
+#define GL_RETURN 0x0102
+
+/* Alpha testing */
+#define GL_ALPHA_TEST 0x0BC0
+#define GL_ALPHA_TEST_REF 0x0BC2
+#define GL_ALPHA_TEST_FUNC 0x0BC1
+
+/* Blending */
+#define GL_BLEND 0x0BE2
+#define GL_BLEND_SRC 0x0BE1
+#define GL_BLEND_DST 0x0BE0
+#define GL_ZERO 0x0
+#define GL_ONE 0x1
+#define GL_SRC_COLOR 0x0300
+#define GL_ONE_MINUS_SRC_COLOR 0x0301
+#define GL_SRC_ALPHA 0x0302
+#define GL_ONE_MINUS_SRC_ALPHA 0x0303
+#define GL_DST_ALPHA 0x0304
+#define GL_ONE_MINUS_DST_ALPHA 0x0305
+#define GL_DST_COLOR 0x0306
+#define GL_ONE_MINUS_DST_COLOR 0x0307
+#define GL_SRC_ALPHA_SATURATE 0x0308
+
+/* Render Mode */
+#define GL_FEEDBACK 0x1C01
+#define GL_RENDER 0x1C00
+#define GL_SELECT 0x1C02
+
+/* Feedback */
+#define GL_2D 0x0600
+#define GL_3D 0x0601
+#define GL_3D_COLOR 0x0602
+#define GL_3D_COLOR_TEXTURE 0x0603
+#define GL_4D_COLOR_TEXTURE 0x0604
+#define GL_POINT_TOKEN 0x0701
+#define GL_LINE_TOKEN 0x0702
+#define GL_LINE_RESET_TOKEN 0x0707
+#define GL_POLYGON_TOKEN 0x0703
+#define GL_BITMAP_TOKEN 0x0704
+#define GL_DRAW_PIXEL_TOKEN 0x0705
+#define GL_COPY_PIXEL_TOKEN 0x0706
+#define GL_PASS_THROUGH_TOKEN 0x0700
+#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0
+#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1
+#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2
+
+/* Selection */
+#define GL_SELECTION_BUFFER_POINTER 0x0DF3
+#define GL_SELECTION_BUFFER_SIZE 0x0DF4
+
+/* Fog */
+#define GL_FOG 0x0B60
+#define GL_FOG_MODE 0x0B65
+#define GL_FOG_DENSITY 0x0B62
+#define GL_FOG_COLOR 0x0B66
+#define GL_FOG_INDEX 0x0B61
+#define GL_FOG_START 0x0B63
+#define GL_FOG_END 0x0B64
+#define GL_LINEAR 0x2601
+#define GL_EXP 0x0800
+#define GL_EXP2 0x0801
+
+/* Logic Ops */
+#define GL_LOGIC_OP 0x0BF1
+#define GL_INDEX_LOGIC_OP 0x0BF1
+#define GL_COLOR_LOGIC_OP 0x0BF2
+#define GL_LOGIC_OP_MODE 0x0BF0
+#define GL_CLEAR 0x1500
+#define GL_SET 0x150F
+#define GL_COPY 0x1503
+#define GL_COPY_INVERTED 0x150C
+#define GL_NOOP 0x1505
+#define GL_INVERT 0x150A
+#define GL_AND 0x1501
+#define GL_NAND 0x150E
+#define GL_OR 0x1507
+#define GL_NOR 0x1508
+#define GL_XOR 0x1506
+#define GL_EQUIV 0x1509
+#define GL_AND_REVERSE 0x1502
+#define GL_AND_INVERTED 0x1504
+#define GL_OR_REVERSE 0x150B
+#define GL_OR_INVERTED 0x150D
+
+/* Stencil */
+#define GL_STENCIL_TEST 0x0B90
+#define GL_STENCIL_WRITEMASK 0x0B98
+#define GL_STENCIL_BITS 0x0D57
+#define GL_STENCIL_FUNC 0x0B92
+#define GL_STENCIL_VALUE_MASK 0x0B93
+#define GL_STENCIL_REF 0x0B97
+#define GL_STENCIL_FAIL 0x0B94
+#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
+#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
+#define GL_STENCIL_CLEAR_VALUE 0x0B91
+#define GL_STENCIL_INDEX 0x1901
+#define GL_KEEP 0x1E00
+#define GL_REPLACE 0x1E01
+#define GL_INCR 0x1E02
+#define GL_DECR 0x1E03
+
+/* Buffers, Pixel Drawing/Reading */
+#define GL_NONE 0x0
+#define GL_LEFT 0x0406
+#define GL_RIGHT 0x0407
+/*GL_FRONT 0x0404 */
+/*GL_BACK 0x0405 */
+/*GL_FRONT_AND_BACK 0x0408 */
+#define GL_FRONT_LEFT 0x0400
+#define GL_FRONT_RIGHT 0x0401
+#define GL_BACK_LEFT 0x0402
+#define GL_BACK_RIGHT 0x0403
+#define GL_AUX0 0x0409
+#define GL_AUX1 0x040A
+#define GL_AUX2 0x040B
+#define GL_AUX3 0x040C
+#define GL_COLOR_INDEX 0x1900
+#define GL_RED 0x1903
+#define GL_GREEN 0x1904
+#define GL_BLUE 0x1905
+#define GL_ALPHA 0x1906
+#define GL_LUMINANCE 0x1909
+#define GL_LUMINANCE_ALPHA 0x190A
+#define GL_ALPHA_BITS 0x0D55
+#define GL_RED_BITS 0x0D52
+#define GL_GREEN_BITS 0x0D53
+#define GL_BLUE_BITS 0x0D54
+#define GL_INDEX_BITS 0x0D51
+#define GL_SUBPIXEL_BITS 0x0D50
+#define GL_AUX_BUFFERS 0x0C00
+#define GL_READ_BUFFER 0x0C02
+#define GL_DRAW_BUFFER 0x0C01
+#define GL_DOUBLEBUFFER 0x0C32
+#define GL_STEREO 0x0C33
+#define GL_BITMAP 0x1A00
+#define GL_COLOR 0x1800
+#define GL_DEPTH 0x1801
+#define GL_STENCIL 0x1802
+#define GL_DITHER 0x0BD0
+#define GL_RGB 0x1907
+#define GL_RGBA 0x1908
+
+/* Implementation limits */
+#define GL_MAX_LIST_NESTING 0x0B31
+#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35
+#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36
+#define GL_MAX_NAME_STACK_DEPTH 0x0D37
+#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38
+#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39
+#define GL_MAX_EVAL_ORDER 0x0D30
+#define GL_MAX_LIGHTS 0x0D31
+#define GL_MAX_CLIP_PLANES 0x0D32
+#define GL_MAX_TEXTURE_SIZE 0x0D33
+#define GL_MAX_PIXEL_MAP_TABLE 0x0D34
+#define GL_MAX_VIEWPORT_DIMS 0x0D3A
+#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B
+
+/* Gets */
+#define GL_ATTRIB_STACK_DEPTH 0x0BB0
+#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1
+#define GL_COLOR_CLEAR_VALUE 0x0C22
+#define GL_COLOR_WRITEMASK 0x0C23
+#define GL_CURRENT_INDEX 0x0B01
+#define GL_CURRENT_COLOR 0x0B00
+#define GL_CURRENT_NORMAL 0x0B02
+#define GL_CURRENT_RASTER_COLOR 0x0B04
+#define GL_CURRENT_RASTER_DISTANCE 0x0B09
+#define GL_CURRENT_RASTER_INDEX 0x0B05
+#define GL_CURRENT_RASTER_POSITION 0x0B07
+#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06
+#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08
+#define GL_CURRENT_TEXTURE_COORDS 0x0B03
+#define GL_INDEX_CLEAR_VALUE 0x0C20
+#define GL_INDEX_MODE 0x0C30
+#define GL_INDEX_WRITEMASK 0x0C21
+#define GL_MODELVIEW_MATRIX 0x0BA6
+#define GL_MODELVIEW_STACK_DEPTH 0x0BA3
+#define GL_NAME_STACK_DEPTH 0x0D70
+#define GL_PROJECTION_MATRIX 0x0BA7
+#define GL_PROJECTION_STACK_DEPTH 0x0BA4
+#define GL_RENDER_MODE 0x0C40
+#define GL_RGBA_MODE 0x0C31
+#define GL_TEXTURE_MATRIX 0x0BA8
+#define GL_TEXTURE_STACK_DEPTH 0x0BA5
+#define GL_VIEWPORT 0x0BA2
+
+/* Evaluators */
+#define GL_AUTO_NORMAL 0x0D80
+#define GL_MAP1_COLOR_4 0x0D90
+#define GL_MAP1_INDEX 0x0D91
+#define GL_MAP1_NORMAL 0x0D92
+#define GL_MAP1_TEXTURE_COORD_1 0x0D93
+#define GL_MAP1_TEXTURE_COORD_2 0x0D94
+#define GL_MAP1_TEXTURE_COORD_3 0x0D95
+#define GL_MAP1_TEXTURE_COORD_4 0x0D96
+#define GL_MAP1_VERTEX_3 0x0D97
+#define GL_MAP1_VERTEX_4 0x0D98
+#define GL_MAP2_COLOR_4 0x0DB0
+#define GL_MAP2_INDEX 0x0DB1
+#define GL_MAP2_NORMAL 0x0DB2
+#define GL_MAP2_TEXTURE_COORD_1 0x0DB3
+#define GL_MAP2_TEXTURE_COORD_2 0x0DB4
+#define GL_MAP2_TEXTURE_COORD_3 0x0DB5
+#define GL_MAP2_TEXTURE_COORD_4 0x0DB6
+#define GL_MAP2_VERTEX_3 0x0DB7
+#define GL_MAP2_VERTEX_4 0x0DB8
+#define GL_MAP1_GRID_DOMAIN 0x0DD0
+#define GL_MAP1_GRID_SEGMENTS 0x0DD1
+#define GL_MAP2_GRID_DOMAIN 0x0DD2
+#define GL_MAP2_GRID_SEGMENTS 0x0DD3
+#define GL_COEFF 0x0A00
+#define GL_DOMAIN 0x0A02
+#define GL_ORDER 0x0A01
+
+/* Hints */
+#define GL_FOG_HINT 0x0C54
+#define GL_LINE_SMOOTH_HINT 0x0C52
+#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
+#define GL_POINT_SMOOTH_HINT 0x0C51
+#define GL_POLYGON_SMOOTH_HINT 0x0C53
+#define GL_DONT_CARE 0x1100
+#define GL_FASTEST 0x1101
+#define GL_NICEST 0x1102
+
+/* Scissor box */
+#define GL_SCISSOR_TEST 0x0C11
+#define GL_SCISSOR_BOX 0x0C10
+
+/* Pixel Mode / Transfer */
+#define GL_MAP_COLOR 0x0D10
+#define GL_MAP_STENCIL 0x0D11
+#define GL_INDEX_SHIFT 0x0D12
+#define GL_INDEX_OFFSET 0x0D13
+#define GL_RED_SCALE 0x0D14
+#define GL_RED_BIAS 0x0D15
+#define GL_GREEN_SCALE 0x0D18
+#define GL_GREEN_BIAS 0x0D19
+#define GL_BLUE_SCALE 0x0D1A
+#define GL_BLUE_BIAS 0x0D1B
+#define GL_ALPHA_SCALE 0x0D1C
+#define GL_ALPHA_BIAS 0x0D1D
+#define GL_DEPTH_SCALE 0x0D1E
+#define GL_DEPTH_BIAS 0x0D1F
+#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1
+#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0
+#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2
+#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3
+#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4
+#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5
+#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6
+#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7
+#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8
+#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9
+#define GL_PIXEL_MAP_S_TO_S 0x0C71
+#define GL_PIXEL_MAP_I_TO_I 0x0C70
+#define GL_PIXEL_MAP_I_TO_R 0x0C72
+#define GL_PIXEL_MAP_I_TO_G 0x0C73
+#define GL_PIXEL_MAP_I_TO_B 0x0C74
+#define GL_PIXEL_MAP_I_TO_A 0x0C75
+#define GL_PIXEL_MAP_R_TO_R 0x0C76
+#define GL_PIXEL_MAP_G_TO_G 0x0C77
+#define GL_PIXEL_MAP_B_TO_B 0x0C78
+#define GL_PIXEL_MAP_A_TO_A 0x0C79
+#define GL_PACK_ALIGNMENT 0x0D05
+#define GL_PACK_LSB_FIRST 0x0D01
+#define GL_PACK_ROW_LENGTH 0x0D02
+#define GL_PACK_SKIP_PIXELS 0x0D04
+#define GL_PACK_SKIP_ROWS 0x0D03
+#define GL_PACK_SWAP_BYTES 0x0D00
+#define GL_UNPACK_ALIGNMENT 0x0CF5
+#define GL_UNPACK_LSB_FIRST 0x0CF1
+#define GL_UNPACK_ROW_LENGTH 0x0CF2
+#define GL_UNPACK_SKIP_PIXELS 0x0CF4
+#define GL_UNPACK_SKIP_ROWS 0x0CF3
+#define GL_UNPACK_SWAP_BYTES 0x0CF0
+#define GL_ZOOM_X 0x0D16
+#define GL_ZOOM_Y 0x0D17
+
+/* Texture mapping */
+#define GL_TEXTURE_ENV 0x2300
+#define GL_TEXTURE_ENV_MODE 0x2200
+#define GL_TEXTURE_1D 0x0DE0
+#define GL_TEXTURE_2D 0x0DE1
+#define GL_TEXTURE_WRAP_S 0x2802
+#define GL_TEXTURE_WRAP_T 0x2803
+#define GL_TEXTURE_MAG_FILTER 0x2800
+#define GL_TEXTURE_MIN_FILTER 0x2801
+#define GL_TEXTURE_ENV_COLOR 0x2201
+#define GL_TEXTURE_GEN_S 0x0C60
+#define GL_TEXTURE_GEN_T 0x0C61
+#define GL_TEXTURE_GEN_MODE 0x2500
+#define GL_TEXTURE_BORDER_COLOR 0x1004
+#define GL_TEXTURE_WIDTH 0x1000
+#define GL_TEXTURE_HEIGHT 0x1001
+#define GL_TEXTURE_BORDER 0x1005
+#define GL_TEXTURE_COMPONENTS 0x1003
+#define GL_TEXTURE_RED_SIZE 0x805C
+#define GL_TEXTURE_GREEN_SIZE 0x805D
+#define GL_TEXTURE_BLUE_SIZE 0x805E
+#define GL_TEXTURE_ALPHA_SIZE 0x805F
+#define GL_TEXTURE_LUMINANCE_SIZE 0x8060
+#define GL_TEXTURE_INTENSITY_SIZE 0x8061
+#define GL_NEAREST_MIPMAP_NEAREST 0x2700
+#define GL_NEAREST_MIPMAP_LINEAR 0x2702
+#define GL_LINEAR_MIPMAP_NEAREST 0x2701
+#define GL_LINEAR_MIPMAP_LINEAR 0x2703
+#define GL_OBJECT_LINEAR 0x2401
+#define GL_OBJECT_PLANE 0x2501
+#define GL_EYE_LINEAR 0x2400
+#define GL_EYE_PLANE 0x2502
+#define GL_SPHERE_MAP 0x2402
+#define GL_DECAL 0x2101
+#define GL_MODULATE 0x2100
+#define GL_NEAREST 0x2600
+#define GL_REPEAT 0x2901
+#define GL_CLAMP 0x2900
+#define GL_S 0x2000
+#define GL_T 0x2001
+#define GL_R 0x2002
+#define GL_Q 0x2003
+#define GL_TEXTURE_GEN_R 0x0C62
+#define GL_TEXTURE_GEN_Q 0x0C63
+
+/* Utility */
+#define GL_VENDOR 0x1F00
+#define GL_RENDERER 0x1F01
+#define GL_VERSION 0x1F02
+#define GL_EXTENSIONS 0x1F03
+
+/* Errors */
+#define GL_NO_ERROR 0x0
+#define GL_INVALID_VALUE 0x0501
+#define GL_INVALID_ENUM 0x0500
+#define GL_INVALID_OPERATION 0x0502
+#define GL_STACK_OVERFLOW 0x0503
+#define GL_STACK_UNDERFLOW 0x0504
+#define GL_OUT_OF_MEMORY 0x0505
+
+/* glPush/PopAttrib bits */
+#define GL_CURRENT_BIT 0x00000001
+#define GL_POINT_BIT 0x00000002
+#define GL_LINE_BIT 0x00000004
+#define GL_POLYGON_BIT 0x00000008
+#define GL_POLYGON_STIPPLE_BIT 0x00000010
+#define GL_PIXEL_MODE_BIT 0x00000020
+#define GL_LIGHTING_BIT 0x00000040
+#define GL_FOG_BIT 0x00000080
+#define GL_DEPTH_BUFFER_BIT 0x00000100
+#define GL_ACCUM_BUFFER_BIT 0x00000200
+#define GL_STENCIL_BUFFER_BIT 0x00000400
+#define GL_VIEWPORT_BIT 0x00000800
+#define GL_TRANSFORM_BIT 0x00001000
+#define GL_ENABLE_BIT 0x00002000
+#define GL_COLOR_BUFFER_BIT 0x00004000
+#define GL_HINT_BIT 0x00008000
+#define GL_EVAL_BIT 0x00010000
+#define GL_LIST_BIT 0x00020000
+#define GL_TEXTURE_BIT 0x00040000
+#define GL_SCISSOR_BIT 0x00080000
+#define GL_ALL_ATTRIB_BITS 0x000FFFFF
+
+
+/* OpenGL 1.1 */
+#define GL_PROXY_TEXTURE_1D 0x8063
+#define GL_PROXY_TEXTURE_2D 0x8064
+#define GL_TEXTURE_PRIORITY 0x8066
+#define GL_TEXTURE_RESIDENT 0x8067
+#define GL_TEXTURE_BINDING_1D 0x8068
+#define GL_TEXTURE_BINDING_2D 0x8069
+#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
+#define GL_ALPHA4 0x803B
+#define GL_ALPHA8 0x803C
+#define GL_ALPHA12 0x803D
+#define GL_ALPHA16 0x803E
+#define GL_LUMINANCE4 0x803F
+#define GL_LUMINANCE8 0x8040
+#define GL_LUMINANCE12 0x8041
+#define GL_LUMINANCE16 0x8042
+#define GL_LUMINANCE4_ALPHA4 0x8043
+#define GL_LUMINANCE6_ALPHA2 0x8044
+#define GL_LUMINANCE8_ALPHA8 0x8045
+#define GL_LUMINANCE12_ALPHA4 0x8046
+#define GL_LUMINANCE12_ALPHA12 0x8047
+#define GL_LUMINANCE16_ALPHA16 0x8048
+#define GL_INTENSITY 0x8049
+#define GL_INTENSITY4 0x804A
+#define GL_INTENSITY8 0x804B
+#define GL_INTENSITY12 0x804C
+#define GL_INTENSITY16 0x804D
+#define GL_R3_G3_B2 0x2A10
+#define GL_RGB4 0x804F
+#define GL_RGB5 0x8050
+#define GL_RGB8 0x8051
+#define GL_RGB10 0x8052
+#define GL_RGB12 0x8053
+#define GL_RGB16 0x8054
+#define GL_RGBA2 0x8055
+#define GL_RGBA4 0x8056
+#define GL_RGB5_A1 0x8057
+#define GL_RGBA8 0x8058
+#define GL_RGB10_A2 0x8059
+#define GL_RGBA12 0x805A
+#define GL_RGBA16 0x805B
+#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001
+#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002
+#define GL_ALL_CLIENT_ATTRIB_BITS 0xFFFFFFFF
+#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF
+
+
+
+/*
+ * Miscellaneous
+ */
+
+GLAPI void GLAPIENTRY glClearIndex( GLfloat c );
+
+GLAPI void GLAPIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha );
+
+GLAPI void GLAPIENTRY glClear( GLbitfield mask );
+
+GLAPI void GLAPIENTRY glIndexMask( GLuint mask );
+
+GLAPI void GLAPIENTRY glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha );
+
+GLAPI void GLAPIENTRY glAlphaFunc( GLenum func, GLclampf ref );
+
+GLAPI void GLAPIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor );
+
+GLAPI void GLAPIENTRY glLogicOp( GLenum opcode );
+
+GLAPI void GLAPIENTRY glCullFace( GLenum mode );
+
+GLAPI void GLAPIENTRY glFrontFace( GLenum mode );
+
+GLAPI void GLAPIENTRY glPointSize( GLfloat size );
+
+GLAPI void GLAPIENTRY glLineWidth( GLfloat width );
+
+GLAPI void GLAPIENTRY glLineStipple( GLint factor, GLushort pattern );
+
+GLAPI void GLAPIENTRY glPolygonMode( GLenum face, GLenum mode );
+
+GLAPI void GLAPIENTRY glPolygonOffset( GLfloat factor, GLfloat units );
+
+GLAPI void GLAPIENTRY glPolygonStipple( const GLubyte *mask );
+
+GLAPI void GLAPIENTRY glGetPolygonStipple( GLubyte *mask );
+
+GLAPI void GLAPIENTRY glEdgeFlag( GLboolean flag );
+
+GLAPI void GLAPIENTRY glEdgeFlagv( const GLboolean *flag );
+
+GLAPI void GLAPIENTRY glScissor( GLint x, GLint y, GLsizei width, GLsizei height);
+
+GLAPI void GLAPIENTRY glClipPlane( GLenum plane, const GLdouble *equation );
+
+GLAPI void GLAPIENTRY glGetClipPlane( GLenum plane, GLdouble *equation );
+
+GLAPI void GLAPIENTRY glDrawBuffer( GLenum mode );
+
+GLAPI void GLAPIENTRY glReadBuffer( GLenum mode );
+
+GLAPI void GLAPIENTRY glEnable( GLenum cap );
+
+GLAPI void GLAPIENTRY glDisable( GLenum cap );
+
+GLAPI GLboolean GLAPIENTRY glIsEnabled( GLenum cap );
+
+
+GLAPI void GLAPIENTRY glEnableClientState( GLenum cap ); /* 1.1 */
+
+GLAPI void GLAPIENTRY glDisableClientState( GLenum cap ); /* 1.1 */
+
+
+GLAPI void GLAPIENTRY glGetBooleanv( GLenum pname, GLboolean *params );
+
+GLAPI void GLAPIENTRY glGetDoublev( GLenum pname, GLdouble *params );
+
+GLAPI void GLAPIENTRY glGetFloatv( GLenum pname, GLfloat *params );
+
+GLAPI void GLAPIENTRY glGetIntegerv( GLenum pname, GLint *params );
+
+
+GLAPI void GLAPIENTRY glPushAttrib( GLbitfield mask );
+
+GLAPI void GLAPIENTRY glPopAttrib( void );
+
+
+GLAPI void GLAPIENTRY glPushClientAttrib( GLbitfield mask ); /* 1.1 */
+
+GLAPI void GLAPIENTRY glPopClientAttrib( void ); /* 1.1 */
+
+
+GLAPI GLint GLAPIENTRY glRenderMode( GLenum mode );
+
+GLAPI GLenum GLAPIENTRY glGetError( void );
+
+GLAPI const GLubyte * GLAPIENTRY glGetString( GLenum name );
+
+GLAPI void GLAPIENTRY glFinish( void );
+
+GLAPI void GLAPIENTRY glFlush( void );
+
+GLAPI void GLAPIENTRY glHint( GLenum target, GLenum mode );
+
+
+/*
+ * Depth Buffer
+ */
+
+GLAPI void GLAPIENTRY glClearDepth( GLclampd depth );
+
+GLAPI void GLAPIENTRY glDepthFunc( GLenum func );
+
+GLAPI void GLAPIENTRY glDepthMask( GLboolean flag );
+
+GLAPI void GLAPIENTRY glDepthRange( GLclampd near_val, GLclampd far_val );
+
+
+/*
+ * Accumulation Buffer
+ */
+
+GLAPI void GLAPIENTRY glClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha );
+
+GLAPI void GLAPIENTRY glAccum( GLenum op, GLfloat value );
+
+
+/*
+ * Transformation
+ */
+
+GLAPI void GLAPIENTRY glMatrixMode( GLenum mode );
+
+GLAPI void GLAPIENTRY glOrtho( GLdouble left, GLdouble right,
+ GLdouble bottom, GLdouble top,
+ GLdouble near_val, GLdouble far_val );
+
+GLAPI void GLAPIENTRY glFrustum( GLdouble left, GLdouble right,
+ GLdouble bottom, GLdouble top,
+ GLdouble near_val, GLdouble far_val );
+
+GLAPI void GLAPIENTRY glViewport( GLint x, GLint y,
+ GLsizei width, GLsizei height );
+
+GLAPI void GLAPIENTRY glPushMatrix( void );
+
+GLAPI void GLAPIENTRY glPopMatrix( void );
+
+GLAPI void GLAPIENTRY glLoadIdentity( void );
+
+GLAPI void GLAPIENTRY glLoadMatrixd( const GLdouble *m );
+GLAPI void GLAPIENTRY glLoadMatrixf( const GLfloat *m );
+
+GLAPI void GLAPIENTRY glMultMatrixd( const GLdouble *m );
+GLAPI void GLAPIENTRY glMultMatrixf( const GLfloat *m );
+
+GLAPI void GLAPIENTRY glRotated( GLdouble angle,
+ GLdouble x, GLdouble y, GLdouble z );
+GLAPI void GLAPIENTRY glRotatef( GLfloat angle,
+ GLfloat x, GLfloat y, GLfloat z );
+
+GLAPI void GLAPIENTRY glScaled( GLdouble x, GLdouble y, GLdouble z );
+GLAPI void GLAPIENTRY glScalef( GLfloat x, GLfloat y, GLfloat z );
+
+GLAPI void GLAPIENTRY glTranslated( GLdouble x, GLdouble y, GLdouble z );
+GLAPI void GLAPIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z );
+
+
+/*
+ * Display Lists
+ */
+
+GLAPI GLboolean GLAPIENTRY glIsList( GLuint list );
+
+GLAPI void GLAPIENTRY glDeleteLists( GLuint list, GLsizei range );
+
+GLAPI GLuint GLAPIENTRY glGenLists( GLsizei range );
+
+GLAPI void GLAPIENTRY glNewList( GLuint list, GLenum mode );
+
+GLAPI void GLAPIENTRY glEndList( void );
+
+GLAPI void GLAPIENTRY glCallList( GLuint list );
+
+GLAPI void GLAPIENTRY glCallLists( GLsizei n, GLenum type,
+ const GLvoid *lists );
+
+GLAPI void GLAPIENTRY glListBase( GLuint base );
+
+
+/*
+ * Drawing Functions
+ */
+
+GLAPI void GLAPIENTRY glBegin( GLenum mode );
+
+GLAPI void GLAPIENTRY glEnd( void );
+
+
+GLAPI void GLAPIENTRY glVertex2d( GLdouble x, GLdouble y );
+GLAPI void GLAPIENTRY glVertex2f( GLfloat x, GLfloat y );
+GLAPI void GLAPIENTRY glVertex2i( GLint x, GLint y );
+GLAPI void GLAPIENTRY glVertex2s( GLshort x, GLshort y );
+
+GLAPI void GLAPIENTRY glVertex3d( GLdouble x, GLdouble y, GLdouble z );
+GLAPI void GLAPIENTRY glVertex3f( GLfloat x, GLfloat y, GLfloat z );
+GLAPI void GLAPIENTRY glVertex3i( GLint x, GLint y, GLint z );
+GLAPI void GLAPIENTRY glVertex3s( GLshort x, GLshort y, GLshort z );
+
+GLAPI void GLAPIENTRY glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w );
+GLAPI void GLAPIENTRY glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w );
+GLAPI void GLAPIENTRY glVertex4i( GLint x, GLint y, GLint z, GLint w );
+GLAPI void GLAPIENTRY glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w );
+
+GLAPI void GLAPIENTRY glVertex2dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glVertex2fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glVertex2iv( const GLint *v );
+GLAPI void GLAPIENTRY glVertex2sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glVertex3dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glVertex3fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glVertex3iv( const GLint *v );
+GLAPI void GLAPIENTRY glVertex3sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glVertex4dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glVertex4fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glVertex4iv( const GLint *v );
+GLAPI void GLAPIENTRY glVertex4sv( const GLshort *v );
+
+
+GLAPI void GLAPIENTRY glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz );
+GLAPI void GLAPIENTRY glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz );
+GLAPI void GLAPIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz );
+GLAPI void GLAPIENTRY glNormal3i( GLint nx, GLint ny, GLint nz );
+GLAPI void GLAPIENTRY glNormal3s( GLshort nx, GLshort ny, GLshort nz );
+
+GLAPI void GLAPIENTRY glNormal3bv( const GLbyte *v );
+GLAPI void GLAPIENTRY glNormal3dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glNormal3fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glNormal3iv( const GLint *v );
+GLAPI void GLAPIENTRY glNormal3sv( const GLshort *v );
+
+
+GLAPI void GLAPIENTRY glIndexd( GLdouble c );
+GLAPI void GLAPIENTRY glIndexf( GLfloat c );
+GLAPI void GLAPIENTRY glIndexi( GLint c );
+GLAPI void GLAPIENTRY glIndexs( GLshort c );
+GLAPI void GLAPIENTRY glIndexub( GLubyte c ); /* 1.1 */
+
+GLAPI void GLAPIENTRY glIndexdv( const GLdouble *c );
+GLAPI void GLAPIENTRY glIndexfv( const GLfloat *c );
+GLAPI void GLAPIENTRY glIndexiv( const GLint *c );
+GLAPI void GLAPIENTRY glIndexsv( const GLshort *c );
+GLAPI void GLAPIENTRY glIndexubv( const GLubyte *c ); /* 1.1 */
+
+GLAPI void GLAPIENTRY glColor3b( GLbyte red, GLbyte green, GLbyte blue );
+GLAPI void GLAPIENTRY glColor3d( GLdouble red, GLdouble green, GLdouble blue );
+GLAPI void GLAPIENTRY glColor3f( GLfloat red, GLfloat green, GLfloat blue );
+GLAPI void GLAPIENTRY glColor3i( GLint red, GLint green, GLint blue );
+GLAPI void GLAPIENTRY glColor3s( GLshort red, GLshort green, GLshort blue );
+GLAPI void GLAPIENTRY glColor3ub( GLubyte red, GLubyte green, GLubyte blue );
+GLAPI void GLAPIENTRY glColor3ui( GLuint red, GLuint green, GLuint blue );
+GLAPI void GLAPIENTRY glColor3us( GLushort red, GLushort green, GLushort blue );
+
+GLAPI void GLAPIENTRY glColor4b( GLbyte red, GLbyte green,
+ GLbyte blue, GLbyte alpha );
+GLAPI void GLAPIENTRY glColor4d( GLdouble red, GLdouble green,
+ GLdouble blue, GLdouble alpha );
+GLAPI void GLAPIENTRY glColor4f( GLfloat red, GLfloat green,
+ GLfloat blue, GLfloat alpha );
+GLAPI void GLAPIENTRY glColor4i( GLint red, GLint green,
+ GLint blue, GLint alpha );
+GLAPI void GLAPIENTRY glColor4s( GLshort red, GLshort green,
+ GLshort blue, GLshort alpha );
+GLAPI void GLAPIENTRY glColor4ub( GLubyte red, GLubyte green,
+ GLubyte blue, GLubyte alpha );
+GLAPI void GLAPIENTRY glColor4ui( GLuint red, GLuint green,
+ GLuint blue, GLuint alpha );
+GLAPI void GLAPIENTRY glColor4us( GLushort red, GLushort green,
+ GLushort blue, GLushort alpha );
+
+
+GLAPI void GLAPIENTRY glColor3bv( const GLbyte *v );
+GLAPI void GLAPIENTRY glColor3dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glColor3fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glColor3iv( const GLint *v );
+GLAPI void GLAPIENTRY glColor3sv( const GLshort *v );
+GLAPI void GLAPIENTRY glColor3ubv( const GLubyte *v );
+GLAPI void GLAPIENTRY glColor3uiv( const GLuint *v );
+GLAPI void GLAPIENTRY glColor3usv( const GLushort *v );
+
+GLAPI void GLAPIENTRY glColor4bv( const GLbyte *v );
+GLAPI void GLAPIENTRY glColor4dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glColor4fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glColor4iv( const GLint *v );
+GLAPI void GLAPIENTRY glColor4sv( const GLshort *v );
+GLAPI void GLAPIENTRY glColor4ubv( const GLubyte *v );
+GLAPI void GLAPIENTRY glColor4uiv( const GLuint *v );
+GLAPI void GLAPIENTRY glColor4usv( const GLushort *v );
+
+
+GLAPI void GLAPIENTRY glTexCoord1d( GLdouble s );
+GLAPI void GLAPIENTRY glTexCoord1f( GLfloat s );
+GLAPI void GLAPIENTRY glTexCoord1i( GLint s );
+GLAPI void GLAPIENTRY glTexCoord1s( GLshort s );
+
+GLAPI void GLAPIENTRY glTexCoord2d( GLdouble s, GLdouble t );
+GLAPI void GLAPIENTRY glTexCoord2f( GLfloat s, GLfloat t );
+GLAPI void GLAPIENTRY glTexCoord2i( GLint s, GLint t );
+GLAPI void GLAPIENTRY glTexCoord2s( GLshort s, GLshort t );
+
+GLAPI void GLAPIENTRY glTexCoord3d( GLdouble s, GLdouble t, GLdouble r );
+GLAPI void GLAPIENTRY glTexCoord3f( GLfloat s, GLfloat t, GLfloat r );
+GLAPI void GLAPIENTRY glTexCoord3i( GLint s, GLint t, GLint r );
+GLAPI void GLAPIENTRY glTexCoord3s( GLshort s, GLshort t, GLshort r );
+
+GLAPI void GLAPIENTRY glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q );
+GLAPI void GLAPIENTRY glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q );
+GLAPI void GLAPIENTRY glTexCoord4i( GLint s, GLint t, GLint r, GLint q );
+GLAPI void GLAPIENTRY glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q );
+
+GLAPI void GLAPIENTRY glTexCoord1dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glTexCoord1fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glTexCoord1iv( const GLint *v );
+GLAPI void GLAPIENTRY glTexCoord1sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glTexCoord2dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glTexCoord2fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glTexCoord2iv( const GLint *v );
+GLAPI void GLAPIENTRY glTexCoord2sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glTexCoord3dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glTexCoord3fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glTexCoord3iv( const GLint *v );
+GLAPI void GLAPIENTRY glTexCoord3sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glTexCoord4dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glTexCoord4fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glTexCoord4iv( const GLint *v );
+GLAPI void GLAPIENTRY glTexCoord4sv( const GLshort *v );
+
+
+GLAPI void GLAPIENTRY glRasterPos2d( GLdouble x, GLdouble y );
+GLAPI void GLAPIENTRY glRasterPos2f( GLfloat x, GLfloat y );
+GLAPI void GLAPIENTRY glRasterPos2i( GLint x, GLint y );
+GLAPI void GLAPIENTRY glRasterPos2s( GLshort x, GLshort y );
+
+GLAPI void GLAPIENTRY glRasterPos3d( GLdouble x, GLdouble y, GLdouble z );
+GLAPI void GLAPIENTRY glRasterPos3f( GLfloat x, GLfloat y, GLfloat z );
+GLAPI void GLAPIENTRY glRasterPos3i( GLint x, GLint y, GLint z );
+GLAPI void GLAPIENTRY glRasterPos3s( GLshort x, GLshort y, GLshort z );
+
+GLAPI void GLAPIENTRY glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w );
+GLAPI void GLAPIENTRY glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w );
+GLAPI void GLAPIENTRY glRasterPos4i( GLint x, GLint y, GLint z, GLint w );
+GLAPI void GLAPIENTRY glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w );
+
+GLAPI void GLAPIENTRY glRasterPos2dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glRasterPos2fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glRasterPos2iv( const GLint *v );
+GLAPI void GLAPIENTRY glRasterPos2sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glRasterPos3dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glRasterPos3fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glRasterPos3iv( const GLint *v );
+GLAPI void GLAPIENTRY glRasterPos3sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glRasterPos4dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glRasterPos4fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glRasterPos4iv( const GLint *v );
+GLAPI void GLAPIENTRY glRasterPos4sv( const GLshort *v );
+
+
+GLAPI void GLAPIENTRY glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 );
+GLAPI void GLAPIENTRY glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 );
+GLAPI void GLAPIENTRY glRecti( GLint x1, GLint y1, GLint x2, GLint y2 );
+GLAPI void GLAPIENTRY glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 );
+
+
+GLAPI void GLAPIENTRY glRectdv( const GLdouble *v1, const GLdouble *v2 );
+GLAPI void GLAPIENTRY glRectfv( const GLfloat *v1, const GLfloat *v2 );
+GLAPI void GLAPIENTRY glRectiv( const GLint *v1, const GLint *v2 );
+GLAPI void GLAPIENTRY glRectsv( const GLshort *v1, const GLshort *v2 );
+
+
+/*
+ * Vertex Arrays (1.1)
+ */
+
+GLAPI void GLAPIENTRY glVertexPointer( GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glNormalPointer( GLenum type, GLsizei stride,
+ const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glColorPointer( GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glIndexPointer( GLenum type, GLsizei stride,
+ const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glTexCoordPointer( GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glEdgeFlagPointer( GLsizei stride, const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glGetPointerv( GLenum pname, GLvoid **params );
+
+GLAPI void GLAPIENTRY glArrayElement( GLint i );
+
+GLAPI void GLAPIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count );
+
+GLAPI void GLAPIENTRY glDrawElements( GLenum mode, GLsizei count,
+ GLenum type, const GLvoid *indices );
+
+GLAPI void GLAPIENTRY glInterleavedArrays( GLenum format, GLsizei stride,
+ const GLvoid *pointer );
+
+/*
+ * Lighting
+ */
+
+GLAPI void GLAPIENTRY glShadeModel( GLenum mode );
+
+GLAPI void GLAPIENTRY glLightf( GLenum light, GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glLighti( GLenum light, GLenum pname, GLint param );
+GLAPI void GLAPIENTRY glLightfv( GLenum light, GLenum pname,
+ const GLfloat *params );
+GLAPI void GLAPIENTRY glLightiv( GLenum light, GLenum pname,
+ const GLint *params );
+
+GLAPI void GLAPIENTRY glGetLightfv( GLenum light, GLenum pname,
+ GLfloat *params );
+GLAPI void GLAPIENTRY glGetLightiv( GLenum light, GLenum pname,
+ GLint *params );
+
+GLAPI void GLAPIENTRY glLightModelf( GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glLightModeli( GLenum pname, GLint param );
+GLAPI void GLAPIENTRY glLightModelfv( GLenum pname, const GLfloat *params );
+GLAPI void GLAPIENTRY glLightModeliv( GLenum pname, const GLint *params );
+
+GLAPI void GLAPIENTRY glMaterialf( GLenum face, GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glMateriali( GLenum face, GLenum pname, GLint param );
+GLAPI void GLAPIENTRY glMaterialfv( GLenum face, GLenum pname, const GLfloat *params );
+GLAPI void GLAPIENTRY glMaterialiv( GLenum face, GLenum pname, const GLint *params );
+
+GLAPI void GLAPIENTRY glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params );
+GLAPI void GLAPIENTRY glGetMaterialiv( GLenum face, GLenum pname, GLint *params );
+
+GLAPI void GLAPIENTRY glColorMaterial( GLenum face, GLenum mode );
+
+
+/*
+ * Raster functions
+ */
+
+GLAPI void GLAPIENTRY glPixelZoom( GLfloat xfactor, GLfloat yfactor );
+
+GLAPI void GLAPIENTRY glPixelStoref( GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glPixelStorei( GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glPixelTransferf( GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glPixelTransferi( GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glPixelMapfv( GLenum map, GLsizei mapsize,
+ const GLfloat *values );
+GLAPI void GLAPIENTRY glPixelMapuiv( GLenum map, GLsizei mapsize,
+ const GLuint *values );
+GLAPI void GLAPIENTRY glPixelMapusv( GLenum map, GLsizei mapsize,
+ const GLushort *values );
+
+GLAPI void GLAPIENTRY glGetPixelMapfv( GLenum map, GLfloat *values );
+GLAPI void GLAPIENTRY glGetPixelMapuiv( GLenum map, GLuint *values );
+GLAPI void GLAPIENTRY glGetPixelMapusv( GLenum map, GLushort *values );
+
+GLAPI void GLAPIENTRY glBitmap( GLsizei width, GLsizei height,
+ GLfloat xorig, GLfloat yorig,
+ GLfloat xmove, GLfloat ymove,
+ const GLubyte *bitmap );
+
+GLAPI void GLAPIENTRY glReadPixels( GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLvoid *pixels );
+
+GLAPI void GLAPIENTRY glDrawPixels( GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *pixels );
+
+GLAPI void GLAPIENTRY glCopyPixels( GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum type );
+
+/*
+ * Stenciling
+ */
+
+GLAPI void GLAPIENTRY glStencilFunc( GLenum func, GLint ref, GLuint mask );
+
+GLAPI void GLAPIENTRY glStencilMask( GLuint mask );
+
+GLAPI void GLAPIENTRY glStencilOp( GLenum fail, GLenum zfail, GLenum zpass );
+
+GLAPI void GLAPIENTRY glClearStencil( GLint s );
+
+
+
+/*
+ * Texture mapping
+ */
+
+GLAPI void GLAPIENTRY glTexGend( GLenum coord, GLenum pname, GLdouble param );
+GLAPI void GLAPIENTRY glTexGenf( GLenum coord, GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glTexGeni( GLenum coord, GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glTexGendv( GLenum coord, GLenum pname, const GLdouble *params );
+GLAPI void GLAPIENTRY glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params );
+GLAPI void GLAPIENTRY glTexGeniv( GLenum coord, GLenum pname, const GLint *params );
+
+GLAPI void GLAPIENTRY glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params );
+GLAPI void GLAPIENTRY glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params );
+GLAPI void GLAPIENTRY glGetTexGeniv( GLenum coord, GLenum pname, GLint *params );
+
+
+GLAPI void GLAPIENTRY glTexEnvf( GLenum target, GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glTexEnvi( GLenum target, GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params );
+GLAPI void GLAPIENTRY glTexEnviv( GLenum target, GLenum pname, const GLint *params );
+
+GLAPI void GLAPIENTRY glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params );
+GLAPI void GLAPIENTRY glGetTexEnviv( GLenum target, GLenum pname, GLint *params );
+
+
+GLAPI void GLAPIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glTexParameterfv( GLenum target, GLenum pname,
+ const GLfloat *params );
+GLAPI void GLAPIENTRY glTexParameteriv( GLenum target, GLenum pname,
+ const GLint *params );
+
+GLAPI void GLAPIENTRY glGetTexParameterfv( GLenum target,
+ GLenum pname, GLfloat *params);
+GLAPI void GLAPIENTRY glGetTexParameteriv( GLenum target,
+ GLenum pname, GLint *params );
+
+GLAPI void GLAPIENTRY glGetTexLevelParameterfv( GLenum target, GLint level,
+ GLenum pname, GLfloat *params );
+GLAPI void GLAPIENTRY glGetTexLevelParameteriv( GLenum target, GLint level,
+ GLenum pname, GLint *params );
+
+
+GLAPI void GLAPIENTRY glTexImage1D( GLenum target, GLint level,
+ GLint internalFormat,
+ GLsizei width, GLint border,
+ GLenum format, GLenum type,
+ const GLvoid *pixels );
+
+GLAPI void GLAPIENTRY glTexImage2D( GLenum target, GLint level,
+ GLint internalFormat,
+ GLsizei width, GLsizei height,
+ GLint border, GLenum format, GLenum type,
+ const GLvoid *pixels );
+
+GLAPI void GLAPIENTRY glGetTexImage( GLenum target, GLint level,
+ GLenum format, GLenum type,
+ GLvoid *pixels );
+
+
+/* 1.1 functions */
+
+GLAPI void GLAPIENTRY glGenTextures( GLsizei n, GLuint *textures );
+
+GLAPI void GLAPIENTRY glDeleteTextures( GLsizei n, const GLuint *textures);
+
+GLAPI void GLAPIENTRY glBindTexture( GLenum target, GLuint texture );
+
+GLAPI void GLAPIENTRY glPrioritizeTextures( GLsizei n,
+ const GLuint *textures,
+ const GLclampf *priorities );
+
+GLAPI GLboolean GLAPIENTRY glAreTexturesResident( GLsizei n,
+ const GLuint *textures,
+ GLboolean *residences );
+
+GLAPI GLboolean GLAPIENTRY glIsTexture( GLuint texture );
+
+
+GLAPI void GLAPIENTRY glTexSubImage1D( GLenum target, GLint level,
+ GLint xoffset,
+ GLsizei width, GLenum format,
+ GLenum type, const GLvoid *pixels );
+
+
+GLAPI void GLAPIENTRY glTexSubImage2D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *pixels );
+
+
+GLAPI void GLAPIENTRY glCopyTexImage1D( GLenum target, GLint level,
+ GLenum internalformat,
+ GLint x, GLint y,
+ GLsizei width, GLint border );
+
+
+GLAPI void GLAPIENTRY glCopyTexImage2D( GLenum target, GLint level,
+ GLenum internalformat,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLint border );
+
+
+GLAPI void GLAPIENTRY glCopyTexSubImage1D( GLenum target, GLint level,
+ GLint xoffset, GLint x, GLint y,
+ GLsizei width );
+
+
+GLAPI void GLAPIENTRY glCopyTexSubImage2D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height );
+
+
+/*
+ * Evaluators
+ */
+
+GLAPI void GLAPIENTRY glMap1d( GLenum target, GLdouble u1, GLdouble u2,
+ GLint stride,
+ GLint order, const GLdouble *points );
+GLAPI void GLAPIENTRY glMap1f( GLenum target, GLfloat u1, GLfloat u2,
+ GLint stride,
+ GLint order, const GLfloat *points );
+
+GLAPI void GLAPIENTRY glMap2d( GLenum target,
+ GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
+ GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
+ const GLdouble *points );
+GLAPI void GLAPIENTRY glMap2f( GLenum target,
+ GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
+ GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
+ const GLfloat *points );
+
+GLAPI void GLAPIENTRY glGetMapdv( GLenum target, GLenum query, GLdouble *v );
+GLAPI void GLAPIENTRY glGetMapfv( GLenum target, GLenum query, GLfloat *v );
+GLAPI void GLAPIENTRY glGetMapiv( GLenum target, GLenum query, GLint *v );
+
+GLAPI void GLAPIENTRY glEvalCoord1d( GLdouble u );
+GLAPI void GLAPIENTRY glEvalCoord1f( GLfloat u );
+
+GLAPI void GLAPIENTRY glEvalCoord1dv( const GLdouble *u );
+GLAPI void GLAPIENTRY glEvalCoord1fv( const GLfloat *u );
+
+GLAPI void GLAPIENTRY glEvalCoord2d( GLdouble u, GLdouble v );
+GLAPI void GLAPIENTRY glEvalCoord2f( GLfloat u, GLfloat v );
+
+GLAPI void GLAPIENTRY glEvalCoord2dv( const GLdouble *u );
+GLAPI void GLAPIENTRY glEvalCoord2fv( const GLfloat *u );
+
+GLAPI void GLAPIENTRY glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 );
+GLAPI void GLAPIENTRY glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 );
+
+GLAPI void GLAPIENTRY glMapGrid2d( GLint un, GLdouble u1, GLdouble u2,
+ GLint vn, GLdouble v1, GLdouble v2 );
+GLAPI void GLAPIENTRY glMapGrid2f( GLint un, GLfloat u1, GLfloat u2,
+ GLint vn, GLfloat v1, GLfloat v2 );
+
+GLAPI void GLAPIENTRY glEvalPoint1( GLint i );
+
+GLAPI void GLAPIENTRY glEvalPoint2( GLint i, GLint j );
+
+GLAPI void GLAPIENTRY glEvalMesh1( GLenum mode, GLint i1, GLint i2 );
+
+GLAPI void GLAPIENTRY glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 );
+
+
+/*
+ * Fog
+ */
+
+GLAPI void GLAPIENTRY glFogf( GLenum pname, GLfloat param );
+
+GLAPI void GLAPIENTRY glFogi( GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glFogfv( GLenum pname, const GLfloat *params );
+
+GLAPI void GLAPIENTRY glFogiv( GLenum pname, const GLint *params );
+
+
+/*
+ * Selection and Feedback
+ */
+
+GLAPI void GLAPIENTRY glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer );
+
+GLAPI void GLAPIENTRY glPassThrough( GLfloat token );
+
+GLAPI void GLAPIENTRY glSelectBuffer( GLsizei size, GLuint *buffer );
+
+GLAPI void GLAPIENTRY glInitNames( void );
+
+GLAPI void GLAPIENTRY glLoadName( GLuint name );
+
+GLAPI void GLAPIENTRY glPushName( GLuint name );
+
+GLAPI void GLAPIENTRY glPopName( void );
+
+
+
+/*
+ * OpenGL 1.2
+ */
+
+#define GL_RESCALE_NORMAL 0x803A
+#define GL_CLAMP_TO_EDGE 0x812F
+#define GL_MAX_ELEMENTS_VERTICES 0x80E8
+#define GL_MAX_ELEMENTS_INDICES 0x80E9
+#define GL_BGR 0x80E0
+#define GL_BGRA 0x80E1
+#define GL_UNSIGNED_BYTE_3_3_2 0x8032
+#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
+#define GL_UNSIGNED_SHORT_5_6_5 0x8363
+#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
+#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
+#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
+#define GL_UNSIGNED_INT_8_8_8_8 0x8035
+#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
+#define GL_UNSIGNED_INT_10_10_10_2 0x8036
+#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
+#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8
+#define GL_SINGLE_COLOR 0x81F9
+#define GL_SEPARATE_SPECULAR_COLOR 0x81FA
+#define GL_TEXTURE_MIN_LOD 0x813A
+#define GL_TEXTURE_MAX_LOD 0x813B
+#define GL_TEXTURE_BASE_LEVEL 0x813C
+#define GL_TEXTURE_MAX_LEVEL 0x813D
+#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
+#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
+#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
+#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
+#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
+#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
+#define GL_PACK_SKIP_IMAGES 0x806B
+#define GL_PACK_IMAGE_HEIGHT 0x806C
+#define GL_UNPACK_SKIP_IMAGES 0x806D
+#define GL_UNPACK_IMAGE_HEIGHT 0x806E
+#define GL_TEXTURE_3D 0x806F
+#define GL_PROXY_TEXTURE_3D 0x8070
+#define GL_TEXTURE_DEPTH 0x8071
+#define GL_TEXTURE_WRAP_R 0x8072
+#define GL_MAX_3D_TEXTURE_SIZE 0x8073
+#define GL_TEXTURE_BINDING_3D 0x806A
+
+GLAPI void GLAPIENTRY glDrawRangeElements( GLenum mode, GLuint start,
+ GLuint end, GLsizei count, GLenum type, const GLvoid *indices );
+
+GLAPI void GLAPIENTRY glTexImage3D( GLenum target, GLint level,
+ GLint internalFormat,
+ GLsizei width, GLsizei height,
+ GLsizei depth, GLint border,
+ GLenum format, GLenum type,
+ const GLvoid *pixels );
+
+GLAPI void GLAPIENTRY glTexSubImage3D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint zoffset, GLsizei width,
+ GLsizei height, GLsizei depth,
+ GLenum format,
+ GLenum type, const GLvoid *pixels);
+
+GLAPI void GLAPIENTRY glCopyTexSubImage3D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint zoffset, GLint x,
+ GLint y, GLsizei width,
+ GLsizei height );
+
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+
+
+/*
+ * GL_ARB_imaging
+ */
+
+#define GL_CONSTANT_COLOR 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
+#define GL_CONSTANT_ALPHA 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
+#define GL_COLOR_TABLE 0x80D0
+#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1
+#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2
+#define GL_PROXY_COLOR_TABLE 0x80D3
+#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4
+#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5
+#define GL_COLOR_TABLE_SCALE 0x80D6
+#define GL_COLOR_TABLE_BIAS 0x80D7
+#define GL_COLOR_TABLE_FORMAT 0x80D8
+#define GL_COLOR_TABLE_WIDTH 0x80D9
+#define GL_COLOR_TABLE_RED_SIZE 0x80DA
+#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB
+#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC
+#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD
+#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE
+#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF
+#define GL_CONVOLUTION_1D 0x8010
+#define GL_CONVOLUTION_2D 0x8011
+#define GL_SEPARABLE_2D 0x8012
+#define GL_CONVOLUTION_BORDER_MODE 0x8013
+#define GL_CONVOLUTION_FILTER_SCALE 0x8014
+#define GL_CONVOLUTION_FILTER_BIAS 0x8015
+#define GL_REDUCE 0x8016
+#define GL_CONVOLUTION_FORMAT 0x8017
+#define GL_CONVOLUTION_WIDTH 0x8018
+#define GL_CONVOLUTION_HEIGHT 0x8019
+#define GL_MAX_CONVOLUTION_WIDTH 0x801A
+#define GL_MAX_CONVOLUTION_HEIGHT 0x801B
+#define GL_POST_CONVOLUTION_RED_SCALE 0x801C
+#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D
+#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E
+#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F
+#define GL_POST_CONVOLUTION_RED_BIAS 0x8020
+#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021
+#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022
+#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023
+#define GL_CONSTANT_BORDER 0x8151
+#define GL_REPLICATE_BORDER 0x8153
+#define GL_CONVOLUTION_BORDER_COLOR 0x8154
+#define GL_COLOR_MATRIX 0x80B1
+#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2
+#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3
+#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4
+#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5
+#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6
+#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7
+#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8
+#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9
+#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA
+#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB
+#define GL_HISTOGRAM 0x8024
+#define GL_PROXY_HISTOGRAM 0x8025
+#define GL_HISTOGRAM_WIDTH 0x8026
+#define GL_HISTOGRAM_FORMAT 0x8027
+#define GL_HISTOGRAM_RED_SIZE 0x8028
+#define GL_HISTOGRAM_GREEN_SIZE 0x8029
+#define GL_HISTOGRAM_BLUE_SIZE 0x802A
+#define GL_HISTOGRAM_ALPHA_SIZE 0x802B
+#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C
+#define GL_HISTOGRAM_SINK 0x802D
+#define GL_MINMAX 0x802E
+#define GL_MINMAX_FORMAT 0x802F
+#define GL_MINMAX_SINK 0x8030
+#define GL_TABLE_TOO_LARGE 0x8031
+#define GL_BLEND_EQUATION 0x8009
+#define GL_MIN 0x8007
+#define GL_MAX 0x8008
+#define GL_FUNC_ADD 0x8006
+#define GL_FUNC_SUBTRACT 0x800A
+#define GL_FUNC_REVERSE_SUBTRACT 0x800B
+#define GL_BLEND_COLOR 0x8005
+
+
+GLAPI void GLAPIENTRY glColorTable( GLenum target, GLenum internalformat,
+ GLsizei width, GLenum format,
+ GLenum type, const GLvoid *table );
+
+GLAPI void GLAPIENTRY glColorSubTable( GLenum target,
+ GLsizei start, GLsizei count,
+ GLenum format, GLenum type,
+ const GLvoid *data );
+
+GLAPI void GLAPIENTRY glColorTableParameteriv(GLenum target, GLenum pname,
+ const GLint *params);
+
+GLAPI void GLAPIENTRY glColorTableParameterfv(GLenum target, GLenum pname,
+ const GLfloat *params);
+
+GLAPI void GLAPIENTRY glCopyColorSubTable( GLenum target, GLsizei start,
+ GLint x, GLint y, GLsizei width );
+
+GLAPI void GLAPIENTRY glCopyColorTable( GLenum target, GLenum internalformat,
+ GLint x, GLint y, GLsizei width );
+
+GLAPI void GLAPIENTRY glGetColorTable( GLenum target, GLenum format,
+ GLenum type, GLvoid *table );
+
+GLAPI void GLAPIENTRY glGetColorTableParameterfv( GLenum target, GLenum pname,
+ GLfloat *params );
+
+GLAPI void GLAPIENTRY glGetColorTableParameteriv( GLenum target, GLenum pname,
+ GLint *params );
+
+GLAPI void GLAPIENTRY glBlendEquation( GLenum mode );
+
+GLAPI void GLAPIENTRY glBlendColor( GLclampf red, GLclampf green,
+ GLclampf blue, GLclampf alpha );
+
+GLAPI void GLAPIENTRY glHistogram( GLenum target, GLsizei width,
+ GLenum internalformat, GLboolean sink );
+
+GLAPI void GLAPIENTRY glResetHistogram( GLenum target );
+
+GLAPI void GLAPIENTRY glGetHistogram( GLenum target, GLboolean reset,
+ GLenum format, GLenum type,
+ GLvoid *values );
+
+GLAPI void GLAPIENTRY glGetHistogramParameterfv( GLenum target, GLenum pname,
+ GLfloat *params );
+
+GLAPI void GLAPIENTRY glGetHistogramParameteriv( GLenum target, GLenum pname,
+ GLint *params );
+
+GLAPI void GLAPIENTRY glMinmax( GLenum target, GLenum internalformat,
+ GLboolean sink );
+
+GLAPI void GLAPIENTRY glResetMinmax( GLenum target );
+
+GLAPI void GLAPIENTRY glGetMinmax( GLenum target, GLboolean reset,
+ GLenum format, GLenum types,
+ GLvoid *values );
+
+GLAPI void GLAPIENTRY glGetMinmaxParameterfv( GLenum target, GLenum pname,
+ GLfloat *params );
+
+GLAPI void GLAPIENTRY glGetMinmaxParameteriv( GLenum target, GLenum pname,
+ GLint *params );
+
+GLAPI void GLAPIENTRY glConvolutionFilter1D( GLenum target,
+ GLenum internalformat, GLsizei width, GLenum format, GLenum type,
+ const GLvoid *image );
+
+GLAPI void GLAPIENTRY glConvolutionFilter2D( GLenum target,
+ GLenum internalformat, GLsizei width, GLsizei height, GLenum format,
+ GLenum type, const GLvoid *image );
+
+GLAPI void GLAPIENTRY glConvolutionParameterf( GLenum target, GLenum pname,
+ GLfloat params );
+
+GLAPI void GLAPIENTRY glConvolutionParameterfv( GLenum target, GLenum pname,
+ const GLfloat *params );
+
+GLAPI void GLAPIENTRY glConvolutionParameteri( GLenum target, GLenum pname,
+ GLint params );
+
+GLAPI void GLAPIENTRY glConvolutionParameteriv( GLenum target, GLenum pname,
+ const GLint *params );
+
+GLAPI void GLAPIENTRY glCopyConvolutionFilter1D( GLenum target,
+ GLenum internalformat, GLint x, GLint y, GLsizei width );
+
+GLAPI void GLAPIENTRY glCopyConvolutionFilter2D( GLenum target,
+ GLenum internalformat, GLint x, GLint y, GLsizei width,
+ GLsizei height);
+
+GLAPI void GLAPIENTRY glGetConvolutionFilter( GLenum target, GLenum format,
+ GLenum type, GLvoid *image );
+
+GLAPI void GLAPIENTRY glGetConvolutionParameterfv( GLenum target, GLenum pname,
+ GLfloat *params );
+
+GLAPI void GLAPIENTRY glGetConvolutionParameteriv( GLenum target, GLenum pname,
+ GLint *params );
+
+GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target,
+ GLenum internalformat, GLsizei width, GLsizei height, GLenum format,
+ GLenum type, const GLvoid *row, const GLvoid *column );
+
+GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format,
+ GLenum type, GLvoid *row, GLvoid *column, GLvoid *span );
+
+typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target);
+
+
+
+/*
+ * OpenGL 1.3
+ */
+
+/* multitexture */
+#define GL_TEXTURE0 0x84C0
+#define GL_TEXTURE1 0x84C1
+#define GL_TEXTURE2 0x84C2
+#define GL_TEXTURE3 0x84C3
+#define GL_TEXTURE4 0x84C4
+#define GL_TEXTURE5 0x84C5
+#define GL_TEXTURE6 0x84C6
+#define GL_TEXTURE7 0x84C7
+#define GL_TEXTURE8 0x84C8
+#define GL_TEXTURE9 0x84C9
+#define GL_TEXTURE10 0x84CA
+#define GL_TEXTURE11 0x84CB
+#define GL_TEXTURE12 0x84CC
+#define GL_TEXTURE13 0x84CD
+#define GL_TEXTURE14 0x84CE
+#define GL_TEXTURE15 0x84CF
+#define GL_TEXTURE16 0x84D0
+#define GL_TEXTURE17 0x84D1
+#define GL_TEXTURE18 0x84D2
+#define GL_TEXTURE19 0x84D3
+#define GL_TEXTURE20 0x84D4
+#define GL_TEXTURE21 0x84D5
+#define GL_TEXTURE22 0x84D6
+#define GL_TEXTURE23 0x84D7
+#define GL_TEXTURE24 0x84D8
+#define GL_TEXTURE25 0x84D9
+#define GL_TEXTURE26 0x84DA
+#define GL_TEXTURE27 0x84DB
+#define GL_TEXTURE28 0x84DC
+#define GL_TEXTURE29 0x84DD
+#define GL_TEXTURE30 0x84DE
+#define GL_TEXTURE31 0x84DF
+#define GL_ACTIVE_TEXTURE 0x84E0
+#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1
+#define GL_MAX_TEXTURE_UNITS 0x84E2
+/* texture_cube_map */
+#define GL_NORMAL_MAP 0x8511
+#define GL_REFLECTION_MAP 0x8512
+#define GL_TEXTURE_CUBE_MAP 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
+/* texture_compression */
+#define GL_COMPRESSED_ALPHA 0x84E9
+#define GL_COMPRESSED_LUMINANCE 0x84EA
+#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB
+#define GL_COMPRESSED_INTENSITY 0x84EC
+#define GL_COMPRESSED_RGB 0x84ED
+#define GL_COMPRESSED_RGBA 0x84EE
+#define GL_TEXTURE_COMPRESSION_HINT 0x84EF
+#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0
+#define GL_TEXTURE_COMPRESSED 0x86A1
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
+/* multisample */
+#define GL_MULTISAMPLE 0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
+#define GL_SAMPLE_COVERAGE 0x80A0
+#define GL_SAMPLE_BUFFERS 0x80A8
+#define GL_SAMPLES 0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
+#define GL_MULTISAMPLE_BIT 0x20000000
+/* transpose_matrix */
+#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3
+#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4
+#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5
+#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6
+/* texture_env_combine */
+#define GL_COMBINE 0x8570
+#define GL_COMBINE_RGB 0x8571
+#define GL_COMBINE_ALPHA 0x8572
+#define GL_SOURCE0_RGB 0x8580
+#define GL_SOURCE1_RGB 0x8581
+#define GL_SOURCE2_RGB 0x8582
+#define GL_SOURCE0_ALPHA 0x8588
+#define GL_SOURCE1_ALPHA 0x8589
+#define GL_SOURCE2_ALPHA 0x858A
+#define GL_OPERAND0_RGB 0x8590
+#define GL_OPERAND1_RGB 0x8591
+#define GL_OPERAND2_RGB 0x8592
+#define GL_OPERAND0_ALPHA 0x8598
+#define GL_OPERAND1_ALPHA 0x8599
+#define GL_OPERAND2_ALPHA 0x859A
+#define GL_RGB_SCALE 0x8573
+#define GL_ADD_SIGNED 0x8574
+#define GL_INTERPOLATE 0x8575
+#define GL_SUBTRACT 0x84E7
+#define GL_CONSTANT 0x8576
+#define GL_PRIMARY_COLOR 0x8577
+#define GL_PREVIOUS 0x8578
+/* texture_env_dot3 */
+#define GL_DOT3_RGB 0x86AE
+#define GL_DOT3_RGBA 0x86AF
+/* texture_border_clamp */
+#define GL_CLAMP_TO_BORDER 0x812D
+
+GLAPI void GLAPIENTRY glActiveTexture( GLenum texture );
+
+GLAPI void GLAPIENTRY glClientActiveTexture( GLenum texture );
+
+GLAPI void GLAPIENTRY glCompressedTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data );
+
+GLAPI void GLAPIENTRY glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data );
+
+GLAPI void GLAPIENTRY glCompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data );
+
+GLAPI void GLAPIENTRY glCompressedTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data );
+
+GLAPI void GLAPIENTRY glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data );
+
+GLAPI void GLAPIENTRY glCompressedTexSubImage3D( 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 GLAPIENTRY glGetCompressedTexImage( GLenum target, GLint lod, GLvoid *img );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1d( GLenum target, GLdouble s );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1dv( GLenum target, const GLdouble *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1f( GLenum target, GLfloat s );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1fv( GLenum target, const GLfloat *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1i( GLenum target, GLint s );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1iv( GLenum target, const GLint *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1s( GLenum target, GLshort s );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1sv( GLenum target, const GLshort *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2d( GLenum target, GLdouble s, GLdouble t );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2dv( GLenum target, const GLdouble *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2f( GLenum target, GLfloat s, GLfloat t );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2fv( GLenum target, const GLfloat *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2i( GLenum target, GLint s, GLint t );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2iv( GLenum target, const GLint *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2s( GLenum target, GLshort s, GLshort t );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2sv( GLenum target, const GLshort *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3d( GLenum target, GLdouble s, GLdouble t, GLdouble r );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3dv( GLenum target, const GLdouble *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3f( GLenum target, GLfloat s, GLfloat t, GLfloat r );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3fv( GLenum target, const GLfloat *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3i( GLenum target, GLint s, GLint t, GLint r );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3iv( GLenum target, const GLint *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3s( GLenum target, GLshort s, GLshort t, GLshort r );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3sv( GLenum target, const GLshort *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4d( GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4dv( GLenum target, const GLdouble *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4fv( GLenum target, const GLfloat *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4i( GLenum target, GLint s, GLint t, GLint r, GLint q );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4iv( GLenum target, const GLint *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4s( GLenum target, GLshort s, GLshort t, GLshort r, GLshort q );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4sv( GLenum target, const GLshort *v );
+
+
+GLAPI void GLAPIENTRY glLoadTransposeMatrixd( const GLdouble m[16] );
+
+GLAPI void GLAPIENTRY glLoadTransposeMatrixf( const GLfloat m[16] );
+
+GLAPI void GLAPIENTRY glMultTransposeMatrixd( const GLdouble m[16] );
+
+GLAPI void GLAPIENTRY glMultTransposeMatrixf( const GLfloat m[16] );
+
+GLAPI void GLAPIENTRY glSampleCoverage( GLclampf value, GLboolean invert );
+
+typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m);
+typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (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 (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img);
+
+
+/*
+ * 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);
+
+typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);
+
+#endif /* GL_ARB_multitexture */
+
+
+
+/*
+ * Define this token if you want "old-style" header file behaviour (extensions
+ * defined in gl.h). Otherwise, extensions will be included from glext.h.
+ */
+#if defined(GL_GLEXT_LEGACY)
+
+/* All extensions that used to be here are now found in glext.h */
+
+#else /* GL_GLEXT_LEGACY */
+
+#include <GL/glext.h>
+
+#endif /* GL_GLEXT_LEGACY */
+
+
+
+/*
+ * ???. GL_MESA_trace
+ * XXX obsolete
+ */
+#ifndef GL_MESA_trace
+#define GL_MESA_trace 1
+
+#define GL_TRACE_ALL_BITS_MESA 0xFFFF
+#define GL_TRACE_OPERATIONS_BIT_MESA 0x0001
+#define GL_TRACE_PRIMITIVES_BIT_MESA 0x0002
+#define GL_TRACE_ARRAYS_BIT_MESA 0x0004
+#define GL_TRACE_TEXTURES_BIT_MESA 0x0008
+#define GL_TRACE_PIXELS_BIT_MESA 0x0010
+#define GL_TRACE_ERRORS_BIT_MESA 0x0020
+#define GL_TRACE_MASK_MESA 0x8755
+#define GL_TRACE_NAME_MESA 0x8756
+
+GLAPI void GLAPIENTRY glEnableTraceMESA( GLbitfield mask );
+GLAPI void GLAPIENTRY glDisableTraceMESA( GLbitfield mask );
+GLAPI void GLAPIENTRY glNewTraceMESA( GLbitfield mask, const GLubyte * traceName );
+GLAPI void GLAPIENTRY glEndTraceMESA( void );
+GLAPI void GLAPIENTRY glTraceAssertAttribMESA( GLbitfield attribMask );
+GLAPI void GLAPIENTRY glTraceCommentMESA( const GLubyte * comment );
+GLAPI void GLAPIENTRY glTraceTextureMESA( GLuint name, const GLubyte* comment );
+GLAPI void GLAPIENTRY glTraceListMESA( GLuint name, const GLubyte* comment );
+GLAPI void GLAPIENTRY glTracePointerMESA( GLvoid* pointer, const GLubyte* comment );
+GLAPI void GLAPIENTRY glTracePointerRangeMESA( const GLvoid* first, const GLvoid* last, const GLubyte* comment );
+
+#endif /* GL_MESA_trace */
+
+
+/*
+ * ???. GL_MESA_packed_depth_stencil
+ * XXX obsolete
+ */
+#ifndef GL_MESA_packed_depth_stencil
+#define GL_MESA_packed_depth_stencil 1
+
+#define GL_DEPTH_STENCIL_MESA 0x8750
+#define GL_UNSIGNED_INT_24_8_MESA 0x8751
+#define GL_UNSIGNED_INT_8_24_REV_MESA 0x8752
+#define GL_UNSIGNED_SHORT_15_1_MESA 0x8753
+#define GL_UNSIGNED_SHORT_1_15_REV_MESA 0x8754
+
+#endif /* GL_MESA_packed_depth_stencil */
+
+
+#ifndef GL_MESA_program_debug
+#define GL_MESA_program_debug 1
+
+#define GL_FRAGMENT_PROGRAM_POSITION_MESA 0x8bb0
+#define GL_FRAGMENT_PROGRAM_CALLBACK_MESA 0x8bb1
+#define GL_FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA 0x8bb2
+#define GL_FRAGMENT_PROGRAM_CALLBACK_DATA_MESA 0x8bb3
+#define GL_VERTEX_PROGRAM_POSITION_MESA 0x8bb4
+#define GL_VERTEX_PROGRAM_CALLBACK_MESA 0x8bb5
+#define GL_VERTEX_PROGRAM_CALLBACK_FUNC_MESA 0x8bb6
+#define GL_VERTEX_PROGRAM_CALLBACK_DATA_MESA 0x8bb7
+
+typedef void (*GLprogramcallbackMESA)(GLenum target, GLvoid *data);
+
+GLAPI void GLAPIENTRY glProgramCallbackMESA(GLenum target, GLprogramcallbackMESA callback, GLvoid *data);
+
+GLAPI void GLAPIENTRY glGetProgramRegisterfvMESA(GLenum target, GLsizei len, const GLubyte *name, GLfloat *v);
+
+#endif /* GL_MESA_program_debug */
+
+
+#ifndef GL_ATI_blend_equation_separate
+#define GL_ATI_blend_equation_separate 1
+
+#define GL_ALPHA_BLEND_EQUATION_ATI 0x883D
+
+GLAPI void GLAPIENTRY glBlendEquationSeparateATI( GLenum modeRGB, GLenum modeA );
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEATIPROC) (GLenum modeRGB, GLenum modeA);
+
+#endif /* GL_ATI_blend_equation_separate */
+
+
+/**
+ ** NOTE!!!!! If you add new functions to this file, or update
+ ** glext.h be sure to regenerate the gl_mangle.h file. See comments
+ ** in that file for details.
+ **/
+
+
+
+/**********************************************************************
+ * Begin system-specific stuff
+ */
+#if defined(PRAGMA_EXPORT_SUPPORTED)
+#pragma export off
+#endif
+
+#if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED
+#pragma import off
+#endif
+/*
+ * End system-specific stuff
+ **********************************************************************/
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gl_h_ */
diff --git a/nx-X11/extras/Mesa/include/GL/gl_mangle.h b/nx-X11/extras/Mesa/include/GL/gl_mangle.h
new file mode 100644
index 000000000..c1b443c6b
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/gl_mangle.h
@@ -0,0 +1,1472 @@
+#if 0
+#define GL_MANGLE_C1 "DO NOT EDIT!!! - TO REGENERATE from gl.h, EXECUTE THIS FILE IN SHELL (/bin/sh) and save the output"
+#define GL_MANGLE_C2 "This file is used to create GL function protypes and aliases for the function names"
+ files="gl.h glext.h"
+#define GL_MANGLE_C3 "get regeneration header - copy everything in this file above the 'REGENERATE_TO_END' line"
+ awk '!done; /^\/\*REGENERATE_TO_END/ {done=1}' $0
+ echo ""
+#define GL_MANGLE_C4 get aliases
+ grep '^GLAPI' $files | sed -e 's/.*ENTRY gl\([^( ]*\).*$/#define gl\1 MANGLE(\1)/' | sort | uniq
+ echo ""
+ echo "#endif /* GL_MANGLE_H */"
+ exit
+#endif /* REGENERATION */
+
+/*
+ * If you compile Mesa with USE_MGL_NAMESPACE defined then you can link
+ * your application both with OpenGL and Mesa. The Mesa functions will
+ * be redefined so they are prefixed with "mgl" instead of "gl".
+ * Mgl contributed by Randy Frank (rfrank@rsinc.com)
+ * Regneration code contributed by Ray Tice (rayt@ma.ultra.net)
+ */
+
+#ifndef GL_MANGLE_H
+#define GL_MANGLE_H
+
+#ifndef MANGLE
+#define MANGLE(x) mgl##x
+#endif /*MANGLE*/
+
+/* Internal symbols which may collide with other OpenGL implementations. */
+#define __glCoreCreateContext __mglCoreCreateContext
+#define __glCoreNopDispatch __mglCoreNopDispatch
+
+/*REGENERATE_TO_END-----------ALL LINES BELOW HERE GET REPLACED ON REGENERATION */
+
+#define glAccum MANGLE(Accum)
+#define glActiveStencilFaceEXT MANGLE(ActiveStencilFaceEXT)
+#define glActiveTextureARB MANGLE(ActiveTextureARB)
+#define glActiveTexture MANGLE(ActiveTexture)
+#define glAlphaFragmentOp1ATI MANGLE(AlphaFragmentOp1ATI)
+#define glAlphaFragmentOp2ATI MANGLE(AlphaFragmentOp2ATI)
+#define glAlphaFragmentOp3ATI MANGLE(AlphaFragmentOp3ATI)
+#define glAlphaFunc MANGLE(AlphaFunc)
+#define glApplyTextureEXT MANGLE(ApplyTextureEXT)
+#define glAreProgramsResidentNV MANGLE(AreProgramsResidentNV)
+#define glAreTexturesResidentEXT MANGLE(AreTexturesResidentEXT)
+#define glAreTexturesResident MANGLE(AreTexturesResident)
+#define glArrayElementEXT MANGLE(ArrayElementEXT)
+#define glArrayElement MANGLE(ArrayElement)
+#define glArrayObjectATI MANGLE(ArrayObjectATI)
+#define glAsyncMarkerSGIX MANGLE(AsyncMarkerSGIX)
+#define glAttachObjectARB MANGLE(AttachObjectARB)
+#define glAttachShader MANGLE(AttachShader)
+#define glBeginFragmentShaderATI MANGLE(BeginFragmentShaderATI)
+#define glBegin MANGLE(Begin)
+#define glBeginOcclusionQueryNV MANGLE(BeginOcclusionQueryNV)
+#define glBeginQueryARB MANGLE(BeginQueryARB)
+#define glBeginQuery MANGLE(BeginQuery)
+#define glBeginVertexShaderEXT MANGLE(BeginVertexShaderEXT)
+#define glBindAttribLocationARB MANGLE(BindAttribLocationARB)
+#define glBindAttribLocation MANGLE(BindAttribLocation)
+#define glBindBufferARB MANGLE(BindBufferARB)
+#define glBindBuffer MANGLE(BindBuffer)
+#define glBindFragmentShaderATI MANGLE(BindFragmentShaderATI)
+#define glBindFramebufferEXT MANGLE(BindFramebufferEXT)
+#define glBindLightParameterEXT MANGLE(BindLightParameterEXT)
+#define glBindMaterialParameterEXT MANGLE(BindMaterialParameterEXT)
+#define glBindParameterEXT MANGLE(BindParameterEXT)
+#define glBindProgramARB MANGLE(BindProgramARB)
+#define glBindProgramNV MANGLE(BindProgramNV)
+#define glBindRenderbufferEXT MANGLE(BindRenderbufferEXT)
+#define glBindTexGenParameterEXT MANGLE(BindTexGenParameterEXT)
+#define glBindTextureEXT MANGLE(BindTextureEXT)
+#define glBindTexture MANGLE(BindTexture)
+#define glBindTextureUnitParameterEXT MANGLE(BindTextureUnitParameterEXT)
+#define glBindVertexArrayAPPLE MANGLE(BindVertexArrayAPPLE)
+#define glBindVertexShaderEXT MANGLE(BindVertexShaderEXT)
+#define glBinormal3bEXT MANGLE(Binormal3bEXT)
+#define glBinormal3bvEXT MANGLE(Binormal3bvEXT)
+#define glBinormal3dEXT MANGLE(Binormal3dEXT)
+#define glBinormal3dvEXT MANGLE(Binormal3dvEXT)
+#define glBinormal3fEXT MANGLE(Binormal3fEXT)
+#define glBinormal3fvEXT MANGLE(Binormal3fvEXT)
+#define glBinormal3iEXT MANGLE(Binormal3iEXT)
+#define glBinormal3ivEXT MANGLE(Binormal3ivEXT)
+#define glBinormal3sEXT MANGLE(Binormal3sEXT)
+#define glBinormal3svEXT MANGLE(Binormal3svEXT)
+#define glBinormalPointerEXT MANGLE(BinormalPointerEXT)
+#define glBitmap MANGLE(Bitmap)
+#define glBlendColorEXT MANGLE(BlendColorEXT)
+#define glBlendColor MANGLE(BlendColor)
+#define glBlendEquationEXT MANGLE(BlendEquationEXT)
+#define glBlendEquation MANGLE(BlendEquation)
+#define glBlendEquationSeparateATI MANGLE(BlendEquationSeparateATI)
+#define glBlendEquationSeparateEXT MANGLE(BlendEquationSeparateEXT)
+#define glBlendEquationSeparate MANGLE(BlendEquationSeparate)
+#define glBlendFunc MANGLE(BlendFunc)
+#define glBlendFuncSeparateEXT MANGLE(BlendFuncSeparateEXT)
+#define glBlendFuncSeparateINGR MANGLE(BlendFuncSeparateINGR)
+#define glBlendFuncSeparate MANGLE(BlendFuncSeparate)
+#define glBufferDataARB MANGLE(BufferDataARB)
+#define glBufferData MANGLE(BufferData)
+#define glBufferSubDataARB MANGLE(BufferSubDataARB)
+#define glBufferSubData MANGLE(BufferSubData)
+#define glCallList MANGLE(CallList)
+#define glCallLists MANGLE(CallLists)
+#define glCheckFramebufferStatusEXT MANGLE(CheckFramebufferStatusEXT)
+#define glClampColorARB MANGLE(ClampColorARB)
+#define glClearAccum MANGLE(ClearAccum)
+#define glClearColor MANGLE(ClearColor)
+#define glClearDepth MANGLE(ClearDepth)
+#define glClearIndex MANGLE(ClearIndex)
+#define glClear MANGLE(Clear)
+#define glClearStencil MANGLE(ClearStencil)
+#define glClientActiveTextureARB MANGLE(ClientActiveTextureARB)
+#define glClientActiveTexture MANGLE(ClientActiveTexture)
+#define glClientActiveVertexStreamATI MANGLE(ClientActiveVertexStreamATI)
+#define glClipPlane MANGLE(ClipPlane)
+#define glColor3b MANGLE(Color3b)
+#define glColor3bv MANGLE(Color3bv)
+#define glColor3d MANGLE(Color3d)
+#define glColor3dv MANGLE(Color3dv)
+#define glColor3f MANGLE(Color3f)
+#define glColor3fVertex3fSUN MANGLE(Color3fVertex3fSUN)
+#define glColor3fVertex3fvSUN MANGLE(Color3fVertex3fvSUN)
+#define glColor3fv MANGLE(Color3fv)
+#define glColor3hNV MANGLE(Color3hNV)
+#define glColor3hvNV MANGLE(Color3hvNV)
+#define glColor3i MANGLE(Color3i)
+#define glColor3iv MANGLE(Color3iv)
+#define glColor3s MANGLE(Color3s)
+#define glColor3sv MANGLE(Color3sv)
+#define glColor3ub MANGLE(Color3ub)
+#define glColor3ubv MANGLE(Color3ubv)
+#define glColor3ui MANGLE(Color3ui)
+#define glColor3uiv MANGLE(Color3uiv)
+#define glColor3us MANGLE(Color3us)
+#define glColor3usv MANGLE(Color3usv)
+#define glColor4b MANGLE(Color4b)
+#define glColor4bv MANGLE(Color4bv)
+#define glColor4d MANGLE(Color4d)
+#define glColor4dv MANGLE(Color4dv)
+#define glColor4f MANGLE(Color4f)
+#define glColor4fNormal3fVertex3fSUN MANGLE(Color4fNormal3fVertex3fSUN)
+#define glColor4fNormal3fVertex3fvSUN MANGLE(Color4fNormal3fVertex3fvSUN)
+#define glColor4fv MANGLE(Color4fv)
+#define glColor4hNV MANGLE(Color4hNV)
+#define glColor4hvNV MANGLE(Color4hvNV)
+#define glColor4i MANGLE(Color4i)
+#define glColor4iv MANGLE(Color4iv)
+#define glColor4s MANGLE(Color4s)
+#define glColor4sv MANGLE(Color4sv)
+#define glColor4ub MANGLE(Color4ub)
+#define glColor4ubVertex2fSUN MANGLE(Color4ubVertex2fSUN)
+#define glColor4ubVertex2fvSUN MANGLE(Color4ubVertex2fvSUN)
+#define glColor4ubVertex3fSUN MANGLE(Color4ubVertex3fSUN)
+#define glColor4ubVertex3fvSUN MANGLE(Color4ubVertex3fvSUN)
+#define glColor4ubv MANGLE(Color4ubv)
+#define glColor4ui MANGLE(Color4ui)
+#define glColor4uiv MANGLE(Color4uiv)
+#define glColor4us MANGLE(Color4us)
+#define glColor4usv MANGLE(Color4usv)
+#define glColorFragmentOp1ATI MANGLE(ColorFragmentOp1ATI)
+#define glColorFragmentOp2ATI MANGLE(ColorFragmentOp2ATI)
+#define glColorFragmentOp3ATI MANGLE(ColorFragmentOp3ATI)
+#define glColorMask MANGLE(ColorMask)
+#define glColorMaterial MANGLE(ColorMaterial)
+#define glColorPointerEXT MANGLE(ColorPointerEXT)
+#define glColorPointerListIBM MANGLE(ColorPointerListIBM)
+#define glColorPointer MANGLE(ColorPointer)
+#define glColorPointervINTEL MANGLE(ColorPointervINTEL)
+#define glColorSubTableEXT MANGLE(ColorSubTableEXT)
+#define glColorSubTable MANGLE(ColorSubTable)
+#define glColorTableEXT MANGLE(ColorTableEXT)
+#define glColorTable MANGLE(ColorTable)
+#define glColorTableParameterfv MANGLE(ColorTableParameterfv)
+#define glColorTableParameterfvSGI MANGLE(ColorTableParameterfvSGI)
+#define glColorTableParameteriv MANGLE(ColorTableParameteriv)
+#define glColorTableParameterivSGI MANGLE(ColorTableParameterivSGI)
+#define glColorTableSGI MANGLE(ColorTableSGI)
+#define glCombinerInputNV MANGLE(CombinerInputNV)
+#define glCombinerOutputNV MANGLE(CombinerOutputNV)
+#define glCombinerParameterfNV MANGLE(CombinerParameterfNV)
+#define glCombinerParameterfvNV MANGLE(CombinerParameterfvNV)
+#define glCombinerParameteriNV MANGLE(CombinerParameteriNV)
+#define glCombinerParameterivNV MANGLE(CombinerParameterivNV)
+#define glCombinerStageParameterfvNV MANGLE(CombinerStageParameterfvNV)
+#define glCompileShaderARB MANGLE(CompileShaderARB)
+#define glCompileShader MANGLE(CompileShader)
+#define glCompressedTexImage1DARB MANGLE(CompressedTexImage1DARB)
+#define glCompressedTexImage1D MANGLE(CompressedTexImage1D)
+#define glCompressedTexImage2DARB MANGLE(CompressedTexImage2DARB)
+#define glCompressedTexImage2D MANGLE(CompressedTexImage2D)
+#define glCompressedTexImage3DARB MANGLE(CompressedTexImage3DARB)
+#define glCompressedTexImage3D MANGLE(CompressedTexImage3D)
+#define glCompressedTexSubImage1DARB MANGLE(CompressedTexSubImage1DARB)
+#define glCompressedTexSubImage1D MANGLE(CompressedTexSubImage1D)
+#define glCompressedTexSubImage2DARB MANGLE(CompressedTexSubImage2DARB)
+#define glCompressedTexSubImage2D MANGLE(CompressedTexSubImage2D)
+#define glCompressedTexSubImage3DARB MANGLE(CompressedTexSubImage3DARB)
+#define glCompressedTexSubImage3D MANGLE(CompressedTexSubImage3D)
+#define glConvolutionFilter1DEXT MANGLE(ConvolutionFilter1DEXT)
+#define glConvolutionFilter1D MANGLE(ConvolutionFilter1D)
+#define glConvolutionFilter2DEXT MANGLE(ConvolutionFilter2DEXT)
+#define glConvolutionFilter2D MANGLE(ConvolutionFilter2D)
+#define glConvolutionParameterfEXT MANGLE(ConvolutionParameterfEXT)
+#define glConvolutionParameterf MANGLE(ConvolutionParameterf)
+#define glConvolutionParameterfvEXT MANGLE(ConvolutionParameterfvEXT)
+#define glConvolutionParameterfv MANGLE(ConvolutionParameterfv)
+#define glConvolutionParameteriEXT MANGLE(ConvolutionParameteriEXT)
+#define glConvolutionParameteri MANGLE(ConvolutionParameteri)
+#define glConvolutionParameterivEXT MANGLE(ConvolutionParameterivEXT)
+#define glConvolutionParameteriv MANGLE(ConvolutionParameteriv)
+#define glCopyColorSubTableEXT MANGLE(CopyColorSubTableEXT)
+#define glCopyColorSubTable MANGLE(CopyColorSubTable)
+#define glCopyColorTable MANGLE(CopyColorTable)
+#define glCopyColorTableSGI MANGLE(CopyColorTableSGI)
+#define glCopyConvolutionFilter1DEXT MANGLE(CopyConvolutionFilter1DEXT)
+#define glCopyConvolutionFilter1D MANGLE(CopyConvolutionFilter1D)
+#define glCopyConvolutionFilter2DEXT MANGLE(CopyConvolutionFilter2DEXT)
+#define glCopyConvolutionFilter2D MANGLE(CopyConvolutionFilter2D)
+#define glCopyPixels MANGLE(CopyPixels)
+#define glCopyTexImage1DEXT MANGLE(CopyTexImage1DEXT)
+#define glCopyTexImage1D MANGLE(CopyTexImage1D)
+#define glCopyTexImage2DEXT MANGLE(CopyTexImage2DEXT)
+#define glCopyTexImage2D MANGLE(CopyTexImage2D)
+#define glCopyTexSubImage1DEXT MANGLE(CopyTexSubImage1DEXT)
+#define glCopyTexSubImage1D MANGLE(CopyTexSubImage1D)
+#define glCopyTexSubImage2DEXT MANGLE(CopyTexSubImage2DEXT)
+#define glCopyTexSubImage2D MANGLE(CopyTexSubImage2D)
+#define glCopyTexSubImage3DEXT MANGLE(CopyTexSubImage3DEXT)
+#define glCopyTexSubImage3D MANGLE(CopyTexSubImage3D)
+#define glCreateProgram MANGLE(CreateProgram)
+#define glCreateProgramObjectARB MANGLE(CreateProgramObjectARB)
+#define glCreateShader MANGLE(CreateShader)
+#define glCreateShaderObjectARB MANGLE(CreateShaderObjectARB)
+#define glCullFace MANGLE(CullFace)
+#define glCullParameterdvEXT MANGLE(CullParameterdvEXT)
+#define glCullParameterfvEXT MANGLE(CullParameterfvEXT)
+#define glCurrentPaletteMatrixARB MANGLE(CurrentPaletteMatrixARB)
+#define glDeformationMap3dSGIX MANGLE(DeformationMap3dSGIX)
+#define glDeformationMap3fSGIX MANGLE(DeformationMap3fSGIX)
+#define glDeformSGIX MANGLE(DeformSGIX)
+#define glDeleteAsyncMarkersSGIX MANGLE(DeleteAsyncMarkersSGIX)
+#define glDeleteBuffersARB MANGLE(DeleteBuffersARB)
+#define glDeleteBuffers MANGLE(DeleteBuffers)
+#define glDeleteFencesAPPLE MANGLE(DeleteFencesAPPLE)
+#define glDeleteFencesNV MANGLE(DeleteFencesNV)
+#define glDeleteFragmentShaderATI MANGLE(DeleteFragmentShaderATI)
+#define glDeleteFramebuffersEXT MANGLE(DeleteFramebuffersEXT)
+#define glDeleteLists MANGLE(DeleteLists)
+#define glDeleteObjectARB MANGLE(DeleteObjectARB)
+#define glDeleteOcclusionQueriesNV MANGLE(DeleteOcclusionQueriesNV)
+#define glDeleteProgram MANGLE(DeleteProgram)
+#define glDeleteProgramsARB MANGLE(DeleteProgramsARB)
+#define glDeleteProgramsNV MANGLE(DeleteProgramsNV)
+#define glDeleteQueriesARB MANGLE(DeleteQueriesARB)
+#define glDeleteQueries MANGLE(DeleteQueries)
+#define glDeleteRenderbuffersEXT MANGLE(DeleteRenderbuffersEXT)
+#define glDeleteShader MANGLE(DeleteShader)
+#define glDeleteTexturesEXT MANGLE(DeleteTexturesEXT)
+#define glDeleteTextures MANGLE(DeleteTextures)
+#define glDeleteVertexArraysAPPLE MANGLE(DeleteVertexArraysAPPLE)
+#define glDeleteVertexShaderEXT MANGLE(DeleteVertexShaderEXT)
+#define glDepthBoundsEXT MANGLE(DepthBoundsEXT)
+#define glDepthFunc MANGLE(DepthFunc)
+#define glDepthMask MANGLE(DepthMask)
+#define glDepthRange MANGLE(DepthRange)
+#define glDetachObjectARB MANGLE(DetachObjectARB)
+#define glDetachShader MANGLE(DetachShader)
+#define glDetailTexFuncSGIS MANGLE(DetailTexFuncSGIS)
+#define glDisableClientState MANGLE(DisableClientState)
+#define glDisable MANGLE(Disable)
+#define glDisableTraceMESA MANGLE(DisableTraceMESA)
+#define glDisableVariantClientStateEXT MANGLE(DisableVariantClientStateEXT)
+#define glDisableVertexAttribArrayARB MANGLE(DisableVertexAttribArrayARB)
+#define glDisableVertexAttribArray MANGLE(DisableVertexAttribArray)
+#define glDrawArraysEXT MANGLE(DrawArraysEXT)
+#define glDrawArrays MANGLE(DrawArrays)
+#define glDrawBuffer MANGLE(DrawBuffer)
+#define glDrawBuffersARB MANGLE(DrawBuffersARB)
+#define glDrawBuffersATI MANGLE(DrawBuffersATI)
+#define glDrawBuffers MANGLE(DrawBuffers)
+#define glDrawElementArrayAPPLE MANGLE(DrawElementArrayAPPLE)
+#define glDrawElementArrayATI MANGLE(DrawElementArrayATI)
+#define glDrawElements MANGLE(DrawElements)
+#define glDrawMeshArraysSUN MANGLE(DrawMeshArraysSUN)
+#define glDrawPixels MANGLE(DrawPixels)
+#define glDrawRangeElementArrayAPPLE MANGLE(DrawRangeElementArrayAPPLE)
+#define glDrawRangeElementArrayATI MANGLE(DrawRangeElementArrayATI)
+#define glDrawRangeElementsEXT MANGLE(DrawRangeElementsEXT)
+#define glDrawRangeElements MANGLE(DrawRangeElements)
+#define glEdgeFlag MANGLE(EdgeFlag)
+#define glEdgeFlagPointerEXT MANGLE(EdgeFlagPointerEXT)
+#define glEdgeFlagPointerListIBM MANGLE(EdgeFlagPointerListIBM)
+#define glEdgeFlagPointer MANGLE(EdgeFlagPointer)
+#define glEdgeFlagv MANGLE(EdgeFlagv)
+#define glElementPointerAPPLE MANGLE(ElementPointerAPPLE)
+#define glElementPointerATI MANGLE(ElementPointerATI)
+#define glEnableClientState MANGLE(EnableClientState)
+#define glEnable MANGLE(Enable)
+#define glEnableTraceMESA MANGLE(EnableTraceMESA)
+#define glEnableVariantClientStateEXT MANGLE(EnableVariantClientStateEXT)
+#define glEnableVertexAttribArrayARB MANGLE(EnableVertexAttribArrayARB)
+#define glEnableVertexAttribArray MANGLE(EnableVertexAttribArray)
+#define glEndFragmentShaderATI MANGLE(EndFragmentShaderATI)
+#define glEndList MANGLE(EndList)
+#define glEnd MANGLE(End)
+#define glEndOcclusionQueryNV MANGLE(EndOcclusionQueryNV)
+#define glEndQueryARB MANGLE(EndQueryARB)
+#define glEndQuery MANGLE(EndQuery)
+#define glEndTraceMESA MANGLE(EndTraceMESA)
+#define glEndVertexShaderEXT MANGLE(EndVertexShaderEXT)
+#define glEvalCoord1d MANGLE(EvalCoord1d)
+#define glEvalCoord1dv MANGLE(EvalCoord1dv)
+#define glEvalCoord1f MANGLE(EvalCoord1f)
+#define glEvalCoord1fv MANGLE(EvalCoord1fv)
+#define glEvalCoord2d MANGLE(EvalCoord2d)
+#define glEvalCoord2dv MANGLE(EvalCoord2dv)
+#define glEvalCoord2f MANGLE(EvalCoord2f)
+#define glEvalCoord2fv MANGLE(EvalCoord2fv)
+#define glEvalMapsNV MANGLE(EvalMapsNV)
+#define glEvalMesh1 MANGLE(EvalMesh1)
+#define glEvalMesh2 MANGLE(EvalMesh2)
+#define glEvalPoint1 MANGLE(EvalPoint1)
+#define glEvalPoint2 MANGLE(EvalPoint2)
+#define glExecuteProgramNV MANGLE(ExecuteProgramNV)
+#define glExtractComponentEXT MANGLE(ExtractComponentEXT)
+#define glFeedbackBuffer MANGLE(FeedbackBuffer)
+#define glFinalCombinerInputNV MANGLE(FinalCombinerInputNV)
+#define glFinishAsyncSGIX MANGLE(FinishAsyncSGIX)
+#define glFinishFenceAPPLE MANGLE(FinishFenceAPPLE)
+#define glFinishFenceNV MANGLE(FinishFenceNV)
+#define glFinish MANGLE(Finish)
+#define glFinishObjectAPPLE MANGLE(FinishObjectAPPLE)
+#define glFinishTextureSUNX MANGLE(FinishTextureSUNX)
+#define glFlush MANGLE(Flush)
+#define glFlushPixelDataRangeNV MANGLE(FlushPixelDataRangeNV)
+#define glFlushRasterSGIX MANGLE(FlushRasterSGIX)
+#define glFlushVertexArrayRangeAPPLE MANGLE(FlushVertexArrayRangeAPPLE)
+#define glFlushVertexArrayRangeNV MANGLE(FlushVertexArrayRangeNV)
+#define glFogCoorddEXT MANGLE(FogCoorddEXT)
+#define glFogCoordd MANGLE(FogCoordd)
+#define glFogCoorddvEXT MANGLE(FogCoorddvEXT)
+#define glFogCoorddv MANGLE(FogCoorddv)
+#define glFogCoordfEXT MANGLE(FogCoordfEXT)
+#define glFogCoordf MANGLE(FogCoordf)
+#define glFogCoordfvEXT MANGLE(FogCoordfvEXT)
+#define glFogCoordfv MANGLE(FogCoordfv)
+#define glFogCoordhNV MANGLE(FogCoordhNV)
+#define glFogCoordhvNV MANGLE(FogCoordhvNV)
+#define glFogCoordPointerEXT MANGLE(FogCoordPointerEXT)
+#define glFogCoordPointerListIBM MANGLE(FogCoordPointerListIBM)
+#define glFogCoordPointer MANGLE(FogCoordPointer)
+#define glFogf MANGLE(Fogf)
+#define glFogFuncSGIS MANGLE(FogFuncSGIS)
+#define glFogfv MANGLE(Fogfv)
+#define glFogi MANGLE(Fogi)
+#define glFogiv MANGLE(Fogiv)
+#define glFragmentColorMaterialSGIX MANGLE(FragmentColorMaterialSGIX)
+#define glFragmentLightfSGIX MANGLE(FragmentLightfSGIX)
+#define glFragmentLightfvSGIX MANGLE(FragmentLightfvSGIX)
+#define glFragmentLightiSGIX MANGLE(FragmentLightiSGIX)
+#define glFragmentLightivSGIX MANGLE(FragmentLightivSGIX)
+#define glFragmentLightModelfSGIX MANGLE(FragmentLightModelfSGIX)
+#define glFragmentLightModelfvSGIX MANGLE(FragmentLightModelfvSGIX)
+#define glFragmentLightModeliSGIX MANGLE(FragmentLightModeliSGIX)
+#define glFragmentLightModelivSGIX MANGLE(FragmentLightModelivSGIX)
+#define glFragmentMaterialfSGIX MANGLE(FragmentMaterialfSGIX)
+#define glFragmentMaterialfvSGIX MANGLE(FragmentMaterialfvSGIX)
+#define glFragmentMaterialiSGIX MANGLE(FragmentMaterialiSGIX)
+#define glFragmentMaterialivSGIX MANGLE(FragmentMaterialivSGIX)
+#define glFramebufferRenderbufferEXT MANGLE(FramebufferRenderbufferEXT)
+#define glFramebufferTexture1DEXT MANGLE(FramebufferTexture1DEXT)
+#define glFramebufferTexture2DEXT MANGLE(FramebufferTexture2DEXT)
+#define glFramebufferTexture3DEXT MANGLE(FramebufferTexture3DEXT)
+#define glFrameZoomSGIX MANGLE(FrameZoomSGIX)
+#define glFreeObjectBufferATI MANGLE(FreeObjectBufferATI)
+#define glFrontFace MANGLE(FrontFace)
+#define glFrustum MANGLE(Frustum)
+#define glGenAsyncMarkersSGIX MANGLE(GenAsyncMarkersSGIX)
+#define glGenBuffersARB MANGLE(GenBuffersARB)
+#define glGenBuffers MANGLE(GenBuffers)
+#define glGenerateMipmapEXT MANGLE(GenerateMipmapEXT)
+#define glGenFencesAPPLE MANGLE(GenFencesAPPLE)
+#define glGenFencesNV MANGLE(GenFencesNV)
+#define glGenFragmentShadersATI MANGLE(GenFragmentShadersATI)
+#define glGenFramebuffersEXT MANGLE(GenFramebuffersEXT)
+#define glGenLists MANGLE(GenLists)
+#define glGenOcclusionQueriesNV MANGLE(GenOcclusionQueriesNV)
+#define glGenProgramsARB MANGLE(GenProgramsARB)
+#define glGenProgramsNV MANGLE(GenProgramsNV)
+#define glGenQueriesARB MANGLE(GenQueriesARB)
+#define glGenQueries MANGLE(GenQueries)
+#define glGenRenderbuffersEXT MANGLE(GenRenderbuffersEXT)
+#define glGenSymbolsEXT MANGLE(GenSymbolsEXT)
+#define glGenTexturesEXT MANGLE(GenTexturesEXT)
+#define glGenTextures MANGLE(GenTextures)
+#define glGenVertexArraysAPPLE MANGLE(GenVertexArraysAPPLE)
+#define glGenVertexShadersEXT MANGLE(GenVertexShadersEXT)
+#define glGetActiveAttribARB MANGLE(GetActiveAttribARB)
+#define glGetActiveAttrib MANGLE(GetActiveAttrib)
+#define glGetActiveUniformARB MANGLE(GetActiveUniformARB)
+#define glGetActiveUniform MANGLE(GetActiveUniform)
+#define glGetArrayObjectfvATI MANGLE(GetArrayObjectfvATI)
+#define glGetArrayObjectivATI MANGLE(GetArrayObjectivATI)
+#define glGetAttachedObjectsARB MANGLE(GetAttachedObjectsARB)
+#define glGetAttachedShaders MANGLE(GetAttachedShaders)
+#define glGetAttribLocationARB MANGLE(GetAttribLocationARB)
+#define glGetAttribLocation MANGLE(GetAttribLocation)
+#define glGetBooleanv MANGLE(GetBooleanv)
+#define glGetBufferParameterivARB MANGLE(GetBufferParameterivARB)
+#define glGetBufferParameteriv MANGLE(GetBufferParameteriv)
+#define glGetBufferPointervARB MANGLE(GetBufferPointervARB)
+#define glGetBufferPointerv MANGLE(GetBufferPointerv)
+#define glGetBufferSubDataARB MANGLE(GetBufferSubDataARB)
+#define glGetBufferSubData MANGLE(GetBufferSubData)
+#define glGetClipPlane MANGLE(GetClipPlane)
+#define glGetColorTableEXT MANGLE(GetColorTableEXT)
+#define glGetColorTable MANGLE(GetColorTable)
+#define glGetColorTableParameterfvEXT MANGLE(GetColorTableParameterfvEXT)
+#define glGetColorTableParameterfv MANGLE(GetColorTableParameterfv)
+#define glGetColorTableParameterfvSGI MANGLE(GetColorTableParameterfvSGI)
+#define glGetColorTableParameterivEXT MANGLE(GetColorTableParameterivEXT)
+#define glGetColorTableParameteriv MANGLE(GetColorTableParameteriv)
+#define glGetColorTableParameterivSGI MANGLE(GetColorTableParameterivSGI)
+#define glGetColorTableSGI MANGLE(GetColorTableSGI)
+#define glGetCombinerInputParameterfvNV MANGLE(GetCombinerInputParameterfvNV)
+#define glGetCombinerInputParameterivNV MANGLE(GetCombinerInputParameterivNV)
+#define glGetCombinerOutputParameterfvNV MANGLE(GetCombinerOutputParameterfvNV)
+#define glGetCombinerOutputParameterivNV MANGLE(GetCombinerOutputParameterivNV)
+#define glGetCombinerStageParameterfvNV MANGLE(GetCombinerStageParameterfvNV)
+#define glGetCompressedTexImageARB MANGLE(GetCompressedTexImageARB)
+#define glGetCompressedTexImage MANGLE(GetCompressedTexImage)
+#define glGetConvolutionFilterEXT MANGLE(GetConvolutionFilterEXT)
+#define glGetConvolutionFilter MANGLE(GetConvolutionFilter)
+#define glGetConvolutionParameterfvEXT MANGLE(GetConvolutionParameterfvEXT)
+#define glGetConvolutionParameterfv MANGLE(GetConvolutionParameterfv)
+#define glGetConvolutionParameterivEXT MANGLE(GetConvolutionParameterivEXT)
+#define glGetConvolutionParameteriv MANGLE(GetConvolutionParameteriv)
+#define glGetDetailTexFuncSGIS MANGLE(GetDetailTexFuncSGIS)
+#define glGetDoublev MANGLE(GetDoublev)
+#define glGetError MANGLE(GetError)
+#define glGetFenceivNV MANGLE(GetFenceivNV)
+#define glGetFinalCombinerInputParameterfvNV MANGLE(GetFinalCombinerInputParameterfvNV)
+#define glGetFinalCombinerInputParameterivNV MANGLE(GetFinalCombinerInputParameterivNV)
+#define glGetFloatv MANGLE(GetFloatv)
+#define glGetFogFuncSGIS MANGLE(GetFogFuncSGIS)
+#define glGetFragmentLightfvSGIX MANGLE(GetFragmentLightfvSGIX)
+#define glGetFragmentLightivSGIX MANGLE(GetFragmentLightivSGIX)
+#define glGetFragmentMaterialfvSGIX MANGLE(GetFragmentMaterialfvSGIX)
+#define glGetFragmentMaterialivSGIX MANGLE(GetFragmentMaterialivSGIX)
+#define glGetFramebufferAttachmentParameterivEXT MANGLE(GetFramebufferAttachmentParameterivEXT)
+#define glGetHandleARB MANGLE(GetHandleARB)
+#define glGetHistogramEXT MANGLE(GetHistogramEXT)
+#define glGetHistogram MANGLE(GetHistogram)
+#define glGetHistogramParameterfvEXT MANGLE(GetHistogramParameterfvEXT)
+#define glGetHistogramParameterfv MANGLE(GetHistogramParameterfv)
+#define glGetHistogramParameterivEXT MANGLE(GetHistogramParameterivEXT)
+#define glGetHistogramParameteriv MANGLE(GetHistogramParameteriv)
+#define glGetImageTransformParameterfvHP MANGLE(GetImageTransformParameterfvHP)
+#define glGetImageTransformParameterivHP MANGLE(GetImageTransformParameterivHP)
+#define glGetInfoLogARB MANGLE(GetInfoLogARB)
+#define glGetInstrumentsSGIX MANGLE(GetInstrumentsSGIX)
+#define glGetIntegerv MANGLE(GetIntegerv)
+#define glGetInvariantBooleanvEXT MANGLE(GetInvariantBooleanvEXT)
+#define glGetInvariantFloatvEXT MANGLE(GetInvariantFloatvEXT)
+#define glGetInvariantIntegervEXT MANGLE(GetInvariantIntegervEXT)
+#define glGetLightfv MANGLE(GetLightfv)
+#define glGetLightiv MANGLE(GetLightiv)
+#define glGetListParameterfvSGIX MANGLE(GetListParameterfvSGIX)
+#define glGetListParameterivSGIX MANGLE(GetListParameterivSGIX)
+#define glGetLocalConstantBooleanvEXT MANGLE(GetLocalConstantBooleanvEXT)
+#define glGetLocalConstantFloatvEXT MANGLE(GetLocalConstantFloatvEXT)
+#define glGetLocalConstantIntegervEXT MANGLE(GetLocalConstantIntegervEXT)
+#define glGetMapAttribParameterfvNV MANGLE(GetMapAttribParameterfvNV)
+#define glGetMapAttribParameterivNV MANGLE(GetMapAttribParameterivNV)
+#define glGetMapControlPointsNV MANGLE(GetMapControlPointsNV)
+#define glGetMapdv MANGLE(GetMapdv)
+#define glGetMapfv MANGLE(GetMapfv)
+#define glGetMapiv MANGLE(GetMapiv)
+#define glGetMapParameterfvNV MANGLE(GetMapParameterfvNV)
+#define glGetMapParameterivNV MANGLE(GetMapParameterivNV)
+#define glGetMaterialfv MANGLE(GetMaterialfv)
+#define glGetMaterialiv MANGLE(GetMaterialiv)
+#define glGetMinmaxEXT MANGLE(GetMinmaxEXT)
+#define glGetMinmax MANGLE(GetMinmax)
+#define glGetMinmaxParameterfvEXT MANGLE(GetMinmaxParameterfvEXT)
+#define glGetMinmaxParameterfv MANGLE(GetMinmaxParameterfv)
+#define glGetMinmaxParameterivEXT MANGLE(GetMinmaxParameterivEXT)
+#define glGetMinmaxParameteriv MANGLE(GetMinmaxParameteriv)
+#define glGetObjectBufferfvATI MANGLE(GetObjectBufferfvATI)
+#define glGetObjectBufferivATI MANGLE(GetObjectBufferivATI)
+#define glGetObjectParameterfvARB MANGLE(GetObjectParameterfvARB)
+#define glGetObjectParameterivARB MANGLE(GetObjectParameterivARB)
+#define glGetOcclusionQueryivNV MANGLE(GetOcclusionQueryivNV)
+#define glGetOcclusionQueryuivNV MANGLE(GetOcclusionQueryuivNV)
+#define glGetPixelMapfv MANGLE(GetPixelMapfv)
+#define glGetPixelMapuiv MANGLE(GetPixelMapuiv)
+#define glGetPixelMapusv MANGLE(GetPixelMapusv)
+#define glGetPixelTexGenParameterfvSGIS MANGLE(GetPixelTexGenParameterfvSGIS)
+#define glGetPixelTexGenParameterivSGIS MANGLE(GetPixelTexGenParameterivSGIS)
+#define glGetPointervEXT MANGLE(GetPointervEXT)
+#define glGetPointerv MANGLE(GetPointerv)
+#define glGetPolygonStipple MANGLE(GetPolygonStipple)
+#define glGetProgramEnvParameterdvARB MANGLE(GetProgramEnvParameterdvARB)
+#define glGetProgramEnvParameterfvARB MANGLE(GetProgramEnvParameterfvARB)
+#define glGetProgramInfoLog MANGLE(GetProgramInfoLog)
+#define glGetProgramivARB MANGLE(GetProgramivARB)
+#define glGetProgramiv MANGLE(GetProgramiv)
+#define glGetProgramivNV MANGLE(GetProgramivNV)
+#define glGetProgramLocalParameterdvARB MANGLE(GetProgramLocalParameterdvARB)
+#define glGetProgramLocalParameterfvARB MANGLE(GetProgramLocalParameterfvARB)
+#define glGetProgramNamedParameterdvNV MANGLE(GetProgramNamedParameterdvNV)
+#define glGetProgramNamedParameterfvNV MANGLE(GetProgramNamedParameterfvNV)
+#define glGetProgramParameterdvNV MANGLE(GetProgramParameterdvNV)
+#define glGetProgramParameterfvNV MANGLE(GetProgramParameterfvNV)
+#define glGetProgramRegisterfvMESA MANGLE(GetProgramRegisterfvMESA)
+#define glGetProgramStringARB MANGLE(GetProgramStringARB)
+#define glGetProgramStringNV MANGLE(GetProgramStringNV)
+#define glGetQueryivARB MANGLE(GetQueryivARB)
+#define glGetQueryiv MANGLE(GetQueryiv)
+#define glGetQueryObjectivARB MANGLE(GetQueryObjectivARB)
+#define glGetQueryObjectiv MANGLE(GetQueryObjectiv)
+#define glGetQueryObjectuivARB MANGLE(GetQueryObjectuivARB)
+#define glGetQueryObjectuiv MANGLE(GetQueryObjectuiv)
+#define glGetRenderbufferParameterivEXT MANGLE(GetRenderbufferParameterivEXT)
+#define glGetSeparableFilterEXT MANGLE(GetSeparableFilterEXT)
+#define glGetSeparableFilter MANGLE(GetSeparableFilter)
+#define glGetShaderInfoLog MANGLE(GetShaderInfoLog)
+#define glGetShaderiv MANGLE(GetShaderiv)
+#define glGetShaderSourceARB MANGLE(GetShaderSourceARB)
+#define glGetShaderSource MANGLE(GetShaderSource)
+#define glGetSharpenTexFuncSGIS MANGLE(GetSharpenTexFuncSGIS)
+#define glGetString MANGLE(GetString)
+#define glGetTexBumpParameterfvATI MANGLE(GetTexBumpParameterfvATI)
+#define glGetTexBumpParameterivATI MANGLE(GetTexBumpParameterivATI)
+#define glGetTexEnvfv MANGLE(GetTexEnvfv)
+#define glGetTexEnviv MANGLE(GetTexEnviv)
+#define glGetTexFilterFuncSGIS MANGLE(GetTexFilterFuncSGIS)
+#define glGetTexGendv MANGLE(GetTexGendv)
+#define glGetTexGenfv MANGLE(GetTexGenfv)
+#define glGetTexGeniv MANGLE(GetTexGeniv)
+#define glGetTexImage MANGLE(GetTexImage)
+#define glGetTexLevelParameterfv MANGLE(GetTexLevelParameterfv)
+#define glGetTexLevelParameteriv MANGLE(GetTexLevelParameteriv)
+#define glGetTexParameterfv MANGLE(GetTexParameterfv)
+#define glGetTexParameteriv MANGLE(GetTexParameteriv)
+#define glGetTrackMatrixivNV MANGLE(GetTrackMatrixivNV)
+#define glGetUniformfvARB MANGLE(GetUniformfvARB)
+#define glGetUniformfv MANGLE(GetUniformfv)
+#define glGetUniformivARB MANGLE(GetUniformivARB)
+#define glGetUniformiv MANGLE(GetUniformiv)
+#define glGetUniformLocationARB MANGLE(GetUniformLocationARB)
+#define glGetUniformLocation MANGLE(GetUniformLocation)
+#define glGetVariantArrayObjectfvATI MANGLE(GetVariantArrayObjectfvATI)
+#define glGetVariantArrayObjectivATI MANGLE(GetVariantArrayObjectivATI)
+#define glGetVariantBooleanvEXT MANGLE(GetVariantBooleanvEXT)
+#define glGetVariantFloatvEXT MANGLE(GetVariantFloatvEXT)
+#define glGetVariantIntegervEXT MANGLE(GetVariantIntegervEXT)
+#define glGetVariantPointervEXT MANGLE(GetVariantPointervEXT)
+#define glGetVertexAttribArrayObjectfvATI MANGLE(GetVertexAttribArrayObjectfvATI)
+#define glGetVertexAttribArrayObjectivATI MANGLE(GetVertexAttribArrayObjectivATI)
+#define glGetVertexAttribdvARB MANGLE(GetVertexAttribdvARB)
+#define glGetVertexAttribdv MANGLE(GetVertexAttribdv)
+#define glGetVertexAttribdvNV MANGLE(GetVertexAttribdvNV)
+#define glGetVertexAttribfvARB MANGLE(GetVertexAttribfvARB)
+#define glGetVertexAttribfv MANGLE(GetVertexAttribfv)
+#define glGetVertexAttribfvNV MANGLE(GetVertexAttribfvNV)
+#define glGetVertexAttribivARB MANGLE(GetVertexAttribivARB)
+#define glGetVertexAttribiv MANGLE(GetVertexAttribiv)
+#define glGetVertexAttribivNV MANGLE(GetVertexAttribivNV)
+#define glGetVertexAttribPointervARB MANGLE(GetVertexAttribPointervARB)
+#define glGetVertexAttribPointerv MANGLE(GetVertexAttribPointerv)
+#define glGetVertexAttribPointervNV MANGLE(GetVertexAttribPointervNV)
+#define glGlobalAlphaFactorbSUN MANGLE(GlobalAlphaFactorbSUN)
+#define glGlobalAlphaFactordSUN MANGLE(GlobalAlphaFactordSUN)
+#define glGlobalAlphaFactorfSUN MANGLE(GlobalAlphaFactorfSUN)
+#define glGlobalAlphaFactoriSUN MANGLE(GlobalAlphaFactoriSUN)
+#define glGlobalAlphaFactorsSUN MANGLE(GlobalAlphaFactorsSUN)
+#define glGlobalAlphaFactorubSUN MANGLE(GlobalAlphaFactorubSUN)
+#define glGlobalAlphaFactoruiSUN MANGLE(GlobalAlphaFactoruiSUN)
+#define glGlobalAlphaFactorusSUN MANGLE(GlobalAlphaFactorusSUN)
+#define glHint MANGLE(Hint)
+#define glHintPGI MANGLE(HintPGI)
+#define glHistogramEXT MANGLE(HistogramEXT)
+#define glHistogram MANGLE(Histogram)
+#define glIglooInterfaceSGIX MANGLE(IglooInterfaceSGIX)
+#define glImageTransformParameterfHP MANGLE(ImageTransformParameterfHP)
+#define glImageTransformParameterfvHP MANGLE(ImageTransformParameterfvHP)
+#define glImageTransformParameteriHP MANGLE(ImageTransformParameteriHP)
+#define glImageTransformParameterivHP MANGLE(ImageTransformParameterivHP)
+#define glIndexd MANGLE(Indexd)
+#define glIndexdv MANGLE(Indexdv)
+#define glIndexf MANGLE(Indexf)
+#define glIndexFuncEXT MANGLE(IndexFuncEXT)
+#define glIndexfv MANGLE(Indexfv)
+#define glIndexi MANGLE(Indexi)
+#define glIndexiv MANGLE(Indexiv)
+#define glIndexMask MANGLE(IndexMask)
+#define glIndexMaterialEXT MANGLE(IndexMaterialEXT)
+#define glIndexPointerEXT MANGLE(IndexPointerEXT)
+#define glIndexPointerListIBM MANGLE(IndexPointerListIBM)
+#define glIndexPointer MANGLE(IndexPointer)
+#define glIndexs MANGLE(Indexs)
+#define glIndexsv MANGLE(Indexsv)
+#define glIndexub MANGLE(Indexub)
+#define glIndexubv MANGLE(Indexubv)
+#define glInitNames MANGLE(InitNames)
+#define glInsertComponentEXT MANGLE(InsertComponentEXT)
+#define glInstrumentsBufferSGIX MANGLE(InstrumentsBufferSGIX)
+#define glInterleavedArrays MANGLE(InterleavedArrays)
+#define glIsAsyncMarkerSGIX MANGLE(IsAsyncMarkerSGIX)
+#define glIsBufferARB MANGLE(IsBufferARB)
+#define glIsBuffer MANGLE(IsBuffer)
+#define glIsEnabled MANGLE(IsEnabled)
+#define glIsFenceAPPLE MANGLE(IsFenceAPPLE)
+#define glIsFenceNV MANGLE(IsFenceNV)
+#define glIsFramebufferEXT MANGLE(IsFramebufferEXT)
+#define glIsList MANGLE(IsList)
+#define glIsObjectBufferATI MANGLE(IsObjectBufferATI)
+#define glIsOcclusionQueryNV MANGLE(IsOcclusionQueryNV)
+#define glIsProgramARB MANGLE(IsProgramARB)
+#define glIsProgram MANGLE(IsProgram)
+#define glIsProgramNV MANGLE(IsProgramNV)
+#define glIsQueryARB MANGLE(IsQueryARB)
+#define glIsQuery MANGLE(IsQuery)
+#define glIsRenderbufferEXT MANGLE(IsRenderbufferEXT)
+#define glIsShader MANGLE(IsShader)
+#define glIsTextureEXT MANGLE(IsTextureEXT)
+#define glIsTexture MANGLE(IsTexture)
+#define glIsVariantEnabledEXT MANGLE(IsVariantEnabledEXT)
+#define glIsVertexArrayAPPLE MANGLE(IsVertexArrayAPPLE)
+#define glLightEnviSGIX MANGLE(LightEnviSGIX)
+#define glLightf MANGLE(Lightf)
+#define glLightfv MANGLE(Lightfv)
+#define glLighti MANGLE(Lighti)
+#define glLightiv MANGLE(Lightiv)
+#define glLightModelf MANGLE(LightModelf)
+#define glLightModelfv MANGLE(LightModelfv)
+#define glLightModeli MANGLE(LightModeli)
+#define glLightModeliv MANGLE(LightModeliv)
+#define glLineStipple MANGLE(LineStipple)
+#define glLineWidth MANGLE(LineWidth)
+#define glLinkProgramARB MANGLE(LinkProgramARB)
+#define glLinkProgram MANGLE(LinkProgram)
+#define glListBase MANGLE(ListBase)
+#define glListParameterfSGIX MANGLE(ListParameterfSGIX)
+#define glListParameterfvSGIX MANGLE(ListParameterfvSGIX)
+#define glListParameteriSGIX MANGLE(ListParameteriSGIX)
+#define glListParameterivSGIX MANGLE(ListParameterivSGIX)
+#define glLoadIdentityDeformationMapSGIX MANGLE(LoadIdentityDeformationMapSGIX)
+#define glLoadIdentity MANGLE(LoadIdentity)
+#define glLoadMatrixd MANGLE(LoadMatrixd)
+#define glLoadMatrixf MANGLE(LoadMatrixf)
+#define glLoadName MANGLE(LoadName)
+#define glLoadProgramNV MANGLE(LoadProgramNV)
+#define glLoadTransposeMatrixdARB MANGLE(LoadTransposeMatrixdARB)
+#define glLoadTransposeMatrixd MANGLE(LoadTransposeMatrixd)
+#define glLoadTransposeMatrixfARB MANGLE(LoadTransposeMatrixfARB)
+#define glLoadTransposeMatrixf MANGLE(LoadTransposeMatrixf)
+#define glLockArraysEXT MANGLE(LockArraysEXT)
+#define glLogicOp MANGLE(LogicOp)
+#define glMap1d MANGLE(Map1d)
+#define glMap1f MANGLE(Map1f)
+#define glMap2d MANGLE(Map2d)
+#define glMap2f MANGLE(Map2f)
+#define glMapBufferARB MANGLE(MapBufferARB)
+#define glMapBuffer MANGLE(MapBuffer)
+#define glMapControlPointsNV MANGLE(MapControlPointsNV)
+#define glMapGrid1d MANGLE(MapGrid1d)
+#define glMapGrid1f MANGLE(MapGrid1f)
+#define glMapGrid2d MANGLE(MapGrid2d)
+#define glMapGrid2f MANGLE(MapGrid2f)
+#define glMapObjectBufferATI MANGLE(MapObjectBufferATI)
+#define glMapParameterfvNV MANGLE(MapParameterfvNV)
+#define glMapParameterivNV MANGLE(MapParameterivNV)
+#define glMaterialf MANGLE(Materialf)
+#define glMaterialfv MANGLE(Materialfv)
+#define glMateriali MANGLE(Materiali)
+#define glMaterialiv MANGLE(Materialiv)
+#define glMatrixIndexPointerARB MANGLE(MatrixIndexPointerARB)
+#define glMatrixIndexubvARB MANGLE(MatrixIndexubvARB)
+#define glMatrixIndexuivARB MANGLE(MatrixIndexuivARB)
+#define glMatrixIndexusvARB MANGLE(MatrixIndexusvARB)
+#define glMatrixMode MANGLE(MatrixMode)
+#define glMinmaxEXT MANGLE(MinmaxEXT)
+#define glMinmax MANGLE(Minmax)
+#define glMultiDrawArraysEXT MANGLE(MultiDrawArraysEXT)
+#define glMultiDrawArrays MANGLE(MultiDrawArrays)
+#define glMultiDrawElementArrayAPPLE MANGLE(MultiDrawElementArrayAPPLE)
+#define glMultiDrawElementsEXT MANGLE(MultiDrawElementsEXT)
+#define glMultiDrawElements MANGLE(MultiDrawElements)
+#define glMultiDrawRangeElementArrayAPPLE MANGLE(MultiDrawRangeElementArrayAPPLE)
+#define glMultiModeDrawArraysIBM MANGLE(MultiModeDrawArraysIBM)
+#define glMultiModeDrawElementsIBM MANGLE(MultiModeDrawElementsIBM)
+#define glMultiTexCoord1dARB MANGLE(MultiTexCoord1dARB)
+#define glMultiTexCoord1d MANGLE(MultiTexCoord1d)
+#define glMultiTexCoord1dvARB MANGLE(MultiTexCoord1dvARB)
+#define glMultiTexCoord1dv MANGLE(MultiTexCoord1dv)
+#define glMultiTexCoord1fARB MANGLE(MultiTexCoord1fARB)
+#define glMultiTexCoord1f MANGLE(MultiTexCoord1f)
+#define glMultiTexCoord1fvARB MANGLE(MultiTexCoord1fvARB)
+#define glMultiTexCoord1fv MANGLE(MultiTexCoord1fv)
+#define glMultiTexCoord1hNV MANGLE(MultiTexCoord1hNV)
+#define glMultiTexCoord1hvNV MANGLE(MultiTexCoord1hvNV)
+#define glMultiTexCoord1iARB MANGLE(MultiTexCoord1iARB)
+#define glMultiTexCoord1i MANGLE(MultiTexCoord1i)
+#define glMultiTexCoord1ivARB MANGLE(MultiTexCoord1ivARB)
+#define glMultiTexCoord1iv MANGLE(MultiTexCoord1iv)
+#define glMultiTexCoord1sARB MANGLE(MultiTexCoord1sARB)
+#define glMultiTexCoord1s MANGLE(MultiTexCoord1s)
+#define glMultiTexCoord1svARB MANGLE(MultiTexCoord1svARB)
+#define glMultiTexCoord1sv MANGLE(MultiTexCoord1sv)
+#define glMultiTexCoord2dARB MANGLE(MultiTexCoord2dARB)
+#define glMultiTexCoord2d MANGLE(MultiTexCoord2d)
+#define glMultiTexCoord2dvARB MANGLE(MultiTexCoord2dvARB)
+#define glMultiTexCoord2dv MANGLE(MultiTexCoord2dv)
+#define glMultiTexCoord2fARB MANGLE(MultiTexCoord2fARB)
+#define glMultiTexCoord2f MANGLE(MultiTexCoord2f)
+#define glMultiTexCoord2fvARB MANGLE(MultiTexCoord2fvARB)
+#define glMultiTexCoord2fv MANGLE(MultiTexCoord2fv)
+#define glMultiTexCoord2hNV MANGLE(MultiTexCoord2hNV)
+#define glMultiTexCoord2hvNV MANGLE(MultiTexCoord2hvNV)
+#define glMultiTexCoord2iARB MANGLE(MultiTexCoord2iARB)
+#define glMultiTexCoord2i MANGLE(MultiTexCoord2i)
+#define glMultiTexCoord2ivARB MANGLE(MultiTexCoord2ivARB)
+#define glMultiTexCoord2iv MANGLE(MultiTexCoord2iv)
+#define glMultiTexCoord2sARB MANGLE(MultiTexCoord2sARB)
+#define glMultiTexCoord2s MANGLE(MultiTexCoord2s)
+#define glMultiTexCoord2svARB MANGLE(MultiTexCoord2svARB)
+#define glMultiTexCoord2sv MANGLE(MultiTexCoord2sv)
+#define glMultiTexCoord3dARB MANGLE(MultiTexCoord3dARB)
+#define glMultiTexCoord3d MANGLE(MultiTexCoord3d)
+#define glMultiTexCoord3dvARB MANGLE(MultiTexCoord3dvARB)
+#define glMultiTexCoord3dv MANGLE(MultiTexCoord3dv)
+#define glMultiTexCoord3fARB MANGLE(MultiTexCoord3fARB)
+#define glMultiTexCoord3f MANGLE(MultiTexCoord3f)
+#define glMultiTexCoord3fvARB MANGLE(MultiTexCoord3fvARB)
+#define glMultiTexCoord3fv MANGLE(MultiTexCoord3fv)
+#define glMultiTexCoord3hNV MANGLE(MultiTexCoord3hNV)
+#define glMultiTexCoord3hvNV MANGLE(MultiTexCoord3hvNV)
+#define glMultiTexCoord3iARB MANGLE(MultiTexCoord3iARB)
+#define glMultiTexCoord3i MANGLE(MultiTexCoord3i)
+#define glMultiTexCoord3ivARB MANGLE(MultiTexCoord3ivARB)
+#define glMultiTexCoord3iv MANGLE(MultiTexCoord3iv)
+#define glMultiTexCoord3sARB MANGLE(MultiTexCoord3sARB)
+#define glMultiTexCoord3s MANGLE(MultiTexCoord3s)
+#define glMultiTexCoord3svARB MANGLE(MultiTexCoord3svARB)
+#define glMultiTexCoord3sv MANGLE(MultiTexCoord3sv)
+#define glMultiTexCoord4dARB MANGLE(MultiTexCoord4dARB)
+#define glMultiTexCoord4d MANGLE(MultiTexCoord4d)
+#define glMultiTexCoord4dvARB MANGLE(MultiTexCoord4dvARB)
+#define glMultiTexCoord4dv MANGLE(MultiTexCoord4dv)
+#define glMultiTexCoord4fARB MANGLE(MultiTexCoord4fARB)
+#define glMultiTexCoord4f MANGLE(MultiTexCoord4f)
+#define glMultiTexCoord4fvARB MANGLE(MultiTexCoord4fvARB)
+#define glMultiTexCoord4fv MANGLE(MultiTexCoord4fv)
+#define glMultiTexCoord4hNV MANGLE(MultiTexCoord4hNV)
+#define glMultiTexCoord4hvNV MANGLE(MultiTexCoord4hvNV)
+#define glMultiTexCoord4iARB MANGLE(MultiTexCoord4iARB)
+#define glMultiTexCoord4i MANGLE(MultiTexCoord4i)
+#define glMultiTexCoord4ivARB MANGLE(MultiTexCoord4ivARB)
+#define glMultiTexCoord4iv MANGLE(MultiTexCoord4iv)
+#define glMultiTexCoord4sARB MANGLE(MultiTexCoord4sARB)
+#define glMultiTexCoord4s MANGLE(MultiTexCoord4s)
+#define glMultiTexCoord4svARB MANGLE(MultiTexCoord4svARB)
+#define glMultiTexCoord4sv MANGLE(MultiTexCoord4sv)
+#define glMultMatrixd MANGLE(MultMatrixd)
+#define glMultMatrixf MANGLE(MultMatrixf)
+#define glMultTransposeMatrixdARB MANGLE(MultTransposeMatrixdARB)
+#define glMultTransposeMatrixd MANGLE(MultTransposeMatrixd)
+#define glMultTransposeMatrixfARB MANGLE(MultTransposeMatrixfARB)
+#define glMultTransposeMatrixf MANGLE(MultTransposeMatrixf)
+#define glNewList MANGLE(NewList)
+#define glNewObjectBufferATI MANGLE(NewObjectBufferATI)
+#define glNewTraceMESA MANGLE(NewTraceMESA)
+#define glNormal3b MANGLE(Normal3b)
+#define glNormal3bv MANGLE(Normal3bv)
+#define glNormal3d MANGLE(Normal3d)
+#define glNormal3dv MANGLE(Normal3dv)
+#define glNormal3f MANGLE(Normal3f)
+#define glNormal3fVertex3fSUN MANGLE(Normal3fVertex3fSUN)
+#define glNormal3fVertex3fvSUN MANGLE(Normal3fVertex3fvSUN)
+#define glNormal3fv MANGLE(Normal3fv)
+#define glNormal3hNV MANGLE(Normal3hNV)
+#define glNormal3hvNV MANGLE(Normal3hvNV)
+#define glNormal3i MANGLE(Normal3i)
+#define glNormal3iv MANGLE(Normal3iv)
+#define glNormal3s MANGLE(Normal3s)
+#define glNormal3sv MANGLE(Normal3sv)
+#define glNormalPointerEXT MANGLE(NormalPointerEXT)
+#define glNormalPointerListIBM MANGLE(NormalPointerListIBM)
+#define glNormalPointer MANGLE(NormalPointer)
+#define glNormalPointervINTEL MANGLE(NormalPointervINTEL)
+#define glNormalStream3bATI MANGLE(NormalStream3bATI)
+#define glNormalStream3bvATI MANGLE(NormalStream3bvATI)
+#define glNormalStream3dATI MANGLE(NormalStream3dATI)
+#define glNormalStream3dvATI MANGLE(NormalStream3dvATI)
+#define glNormalStream3fATI MANGLE(NormalStream3fATI)
+#define glNormalStream3fvATI MANGLE(NormalStream3fvATI)
+#define glNormalStream3iATI MANGLE(NormalStream3iATI)
+#define glNormalStream3ivATI MANGLE(NormalStream3ivATI)
+#define glNormalStream3sATI MANGLE(NormalStream3sATI)
+#define glNormalStream3svATI MANGLE(NormalStream3svATI)
+#define glOrtho MANGLE(Ortho)
+#define glPassTexCoordATI MANGLE(PassTexCoordATI)
+#define glPassThrough MANGLE(PassThrough)
+#define glPixelDataRangeNV MANGLE(PixelDataRangeNV)
+#define glPixelMapfv MANGLE(PixelMapfv)
+#define glPixelMapuiv MANGLE(PixelMapuiv)
+#define glPixelMapusv MANGLE(PixelMapusv)
+#define glPixelStoref MANGLE(PixelStoref)
+#define glPixelStorei MANGLE(PixelStorei)
+#define glPixelTexGenParameterfSGIS MANGLE(PixelTexGenParameterfSGIS)
+#define glPixelTexGenParameterfvSGIS MANGLE(PixelTexGenParameterfvSGIS)
+#define glPixelTexGenParameteriSGIS MANGLE(PixelTexGenParameteriSGIS)
+#define glPixelTexGenParameterivSGIS MANGLE(PixelTexGenParameterivSGIS)
+#define glPixelTexGenSGIX MANGLE(PixelTexGenSGIX)
+#define glPixelTransferf MANGLE(PixelTransferf)
+#define glPixelTransferi MANGLE(PixelTransferi)
+#define glPixelTransformParameterfEXT MANGLE(PixelTransformParameterfEXT)
+#define glPixelTransformParameterfvEXT MANGLE(PixelTransformParameterfvEXT)
+#define glPixelTransformParameteriEXT MANGLE(PixelTransformParameteriEXT)
+#define glPixelTransformParameterivEXT MANGLE(PixelTransformParameterivEXT)
+#define glPixelZoom MANGLE(PixelZoom)
+#define glPNTrianglesfATI MANGLE(PNTrianglesfATI)
+#define glPNTrianglesiATI MANGLE(PNTrianglesiATI)
+#define glPointParameterfARB MANGLE(PointParameterfARB)
+#define glPointParameterfEXT MANGLE(PointParameterfEXT)
+#define glPointParameterf MANGLE(PointParameterf)
+#define glPointParameterfSGIS MANGLE(PointParameterfSGIS)
+#define glPointParameterfvARB MANGLE(PointParameterfvARB)
+#define glPointParameterfvEXT MANGLE(PointParameterfvEXT)
+#define glPointParameterfv MANGLE(PointParameterfv)
+#define glPointParameterfvSGIS MANGLE(PointParameterfvSGIS)
+#define glPointParameteri MANGLE(PointParameteri)
+#define glPointParameteriNV MANGLE(PointParameteriNV)
+#define glPointParameteriv MANGLE(PointParameteriv)
+#define glPointParameterivNV MANGLE(PointParameterivNV)
+#define glPointSize MANGLE(PointSize)
+#define glPollAsyncSGIX MANGLE(PollAsyncSGIX)
+#define glPollInstrumentsSGIX MANGLE(PollInstrumentsSGIX)
+#define glPolygonMode MANGLE(PolygonMode)
+#define glPolygonOffsetEXT MANGLE(PolygonOffsetEXT)
+#define glPolygonOffset MANGLE(PolygonOffset)
+#define glPolygonStipple MANGLE(PolygonStipple)
+#define glPopAttrib MANGLE(PopAttrib)
+#define glPopClientAttrib MANGLE(PopClientAttrib)
+#define glPopMatrix MANGLE(PopMatrix)
+#define glPopName MANGLE(PopName)
+#define glPrimitiveRestartIndexNV MANGLE(PrimitiveRestartIndexNV)
+#define glPrimitiveRestartNV MANGLE(PrimitiveRestartNV)
+#define glPrioritizeTexturesEXT MANGLE(PrioritizeTexturesEXT)
+#define glPrioritizeTextures MANGLE(PrioritizeTextures)
+#define glProgramCallbackMESA MANGLE(ProgramCallbackMESA)
+#define glProgramEnvParameter4dARB MANGLE(ProgramEnvParameter4dARB)
+#define glProgramEnvParameter4dvARB MANGLE(ProgramEnvParameter4dvARB)
+#define glProgramEnvParameter4fARB MANGLE(ProgramEnvParameter4fARB)
+#define glProgramEnvParameter4fvARB MANGLE(ProgramEnvParameter4fvARB)
+#define glProgramLocalParameter4dARB MANGLE(ProgramLocalParameter4dARB)
+#define glProgramLocalParameter4dvARB MANGLE(ProgramLocalParameter4dvARB)
+#define glProgramLocalParameter4fARB MANGLE(ProgramLocalParameter4fARB)
+#define glProgramLocalParameter4fvARB MANGLE(ProgramLocalParameter4fvARB)
+#define glProgramNamedParameter4dNV MANGLE(ProgramNamedParameter4dNV)
+#define glProgramNamedParameter4dvNV MANGLE(ProgramNamedParameter4dvNV)
+#define glProgramNamedParameter4fNV MANGLE(ProgramNamedParameter4fNV)
+#define glProgramNamedParameter4fvNV MANGLE(ProgramNamedParameter4fvNV)
+#define glProgramParameter4dNV MANGLE(ProgramParameter4dNV)
+#define glProgramParameter4dvNV MANGLE(ProgramParameter4dvNV)
+#define glProgramParameter4fNV MANGLE(ProgramParameter4fNV)
+#define glProgramParameter4fvNV MANGLE(ProgramParameter4fvNV)
+#define glProgramParameters4dvNV MANGLE(ProgramParameters4dvNV)
+#define glProgramParameters4fvNV MANGLE(ProgramParameters4fvNV)
+#define glProgramStringARB MANGLE(ProgramStringARB)
+#define glPushAttrib MANGLE(PushAttrib)
+#define glPushClientAttrib MANGLE(PushClientAttrib)
+#define glPushMatrix MANGLE(PushMatrix)
+#define glPushName MANGLE(PushName)
+#define glRasterPos2d MANGLE(RasterPos2d)
+#define glRasterPos2dv MANGLE(RasterPos2dv)
+#define glRasterPos2f MANGLE(RasterPos2f)
+#define glRasterPos2fv MANGLE(RasterPos2fv)
+#define glRasterPos2i MANGLE(RasterPos2i)
+#define glRasterPos2iv MANGLE(RasterPos2iv)
+#define glRasterPos2s MANGLE(RasterPos2s)
+#define glRasterPos2sv MANGLE(RasterPos2sv)
+#define glRasterPos3d MANGLE(RasterPos3d)
+#define glRasterPos3dv MANGLE(RasterPos3dv)
+#define glRasterPos3f MANGLE(RasterPos3f)
+#define glRasterPos3fv MANGLE(RasterPos3fv)
+#define glRasterPos3i MANGLE(RasterPos3i)
+#define glRasterPos3iv MANGLE(RasterPos3iv)
+#define glRasterPos3s MANGLE(RasterPos3s)
+#define glRasterPos3sv MANGLE(RasterPos3sv)
+#define glRasterPos4d MANGLE(RasterPos4d)
+#define glRasterPos4dv MANGLE(RasterPos4dv)
+#define glRasterPos4f MANGLE(RasterPos4f)
+#define glRasterPos4fv MANGLE(RasterPos4fv)
+#define glRasterPos4i MANGLE(RasterPos4i)
+#define glRasterPos4iv MANGLE(RasterPos4iv)
+#define glRasterPos4s MANGLE(RasterPos4s)
+#define glRasterPos4sv MANGLE(RasterPos4sv)
+#define glReadBuffer MANGLE(ReadBuffer)
+#define glReadInstrumentsSGIX MANGLE(ReadInstrumentsSGIX)
+#define glReadPixels MANGLE(ReadPixels)
+#define glRectd MANGLE(Rectd)
+#define glRectdv MANGLE(Rectdv)
+#define glRectf MANGLE(Rectf)
+#define glRectfv MANGLE(Rectfv)
+#define glRecti MANGLE(Recti)
+#define glRectiv MANGLE(Rectiv)
+#define glRects MANGLE(Rects)
+#define glRectsv MANGLE(Rectsv)
+#define glReferencePlaneSGIX MANGLE(ReferencePlaneSGIX)
+#define glRenderbufferStorageEXT MANGLE(RenderbufferStorageEXT)
+#define glRenderMode MANGLE(RenderMode)
+#define glReplacementCodePointerSUN MANGLE(ReplacementCodePointerSUN)
+#define glReplacementCodeubSUN MANGLE(ReplacementCodeubSUN)
+#define glReplacementCodeubvSUN MANGLE(ReplacementCodeubvSUN)
+#define glReplacementCodeuiColor3fVertex3fSUN MANGLE(ReplacementCodeuiColor3fVertex3fSUN)
+#define glReplacementCodeuiColor3fVertex3fvSUN MANGLE(ReplacementCodeuiColor3fVertex3fvSUN)
+#define glReplacementCodeuiColor4fNormal3fVertex3fSUN MANGLE(ReplacementCodeuiColor4fNormal3fVertex3fSUN)
+#define glReplacementCodeuiColor4fNormal3fVertex3fvSUN MANGLE(ReplacementCodeuiColor4fNormal3fVertex3fvSUN)
+#define glReplacementCodeuiColor4ubVertex3fSUN MANGLE(ReplacementCodeuiColor4ubVertex3fSUN)
+#define glReplacementCodeuiColor4ubVertex3fvSUN MANGLE(ReplacementCodeuiColor4ubVertex3fvSUN)
+#define glReplacementCodeuiNormal3fVertex3fSUN MANGLE(ReplacementCodeuiNormal3fVertex3fSUN)
+#define glReplacementCodeuiNormal3fVertex3fvSUN MANGLE(ReplacementCodeuiNormal3fVertex3fvSUN)
+#define glReplacementCodeuiSUN MANGLE(ReplacementCodeuiSUN)
+#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN MANGLE(ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN)
+#define glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN MANGLE(ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN)
+#define glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN MANGLE(ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN)
+#define glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN MANGLE(ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN)
+#define glReplacementCodeuiTexCoord2fVertex3fSUN MANGLE(ReplacementCodeuiTexCoord2fVertex3fSUN)
+#define glReplacementCodeuiTexCoord2fVertex3fvSUN MANGLE(ReplacementCodeuiTexCoord2fVertex3fvSUN)
+#define glReplacementCodeuiVertex3fSUN MANGLE(ReplacementCodeuiVertex3fSUN)
+#define glReplacementCodeuiVertex3fvSUN MANGLE(ReplacementCodeuiVertex3fvSUN)
+#define glReplacementCodeuivSUN MANGLE(ReplacementCodeuivSUN)
+#define glReplacementCodeusSUN MANGLE(ReplacementCodeusSUN)
+#define glReplacementCodeusvSUN MANGLE(ReplacementCodeusvSUN)
+#define glRequestResidentProgramsNV MANGLE(RequestResidentProgramsNV)
+#define glResetHistogramEXT MANGLE(ResetHistogramEXT)
+#define glResetHistogram MANGLE(ResetHistogram)
+#define glResetMinmaxEXT MANGLE(ResetMinmaxEXT)
+#define glResetMinmax MANGLE(ResetMinmax)
+#define glResizeBuffersMESA MANGLE(ResizeBuffersMESA)
+#define glRotated MANGLE(Rotated)
+#define glRotatef MANGLE(Rotatef)
+#define glSampleCoverageARB MANGLE(SampleCoverageARB)
+#define glSampleCoverage MANGLE(SampleCoverage)
+#define glSampleMapATI MANGLE(SampleMapATI)
+#define glSampleMaskEXT MANGLE(SampleMaskEXT)
+#define glSampleMaskSGIS MANGLE(SampleMaskSGIS)
+#define glSamplePatternEXT MANGLE(SamplePatternEXT)
+#define glSamplePatternSGIS MANGLE(SamplePatternSGIS)
+#define glScaled MANGLE(Scaled)
+#define glScalef MANGLE(Scalef)
+#define glScissor MANGLE(Scissor)
+#define glSecondaryColor3bEXT MANGLE(SecondaryColor3bEXT)
+#define glSecondaryColor3b MANGLE(SecondaryColor3b)
+#define glSecondaryColor3bvEXT MANGLE(SecondaryColor3bvEXT)
+#define glSecondaryColor3bv MANGLE(SecondaryColor3bv)
+#define glSecondaryColor3dEXT MANGLE(SecondaryColor3dEXT)
+#define glSecondaryColor3d MANGLE(SecondaryColor3d)
+#define glSecondaryColor3dvEXT MANGLE(SecondaryColor3dvEXT)
+#define glSecondaryColor3dv MANGLE(SecondaryColor3dv)
+#define glSecondaryColor3fEXT MANGLE(SecondaryColor3fEXT)
+#define glSecondaryColor3f MANGLE(SecondaryColor3f)
+#define glSecondaryColor3fvEXT MANGLE(SecondaryColor3fvEXT)
+#define glSecondaryColor3fv MANGLE(SecondaryColor3fv)
+#define glSecondaryColor3hNV MANGLE(SecondaryColor3hNV)
+#define glSecondaryColor3hvNV MANGLE(SecondaryColor3hvNV)
+#define glSecondaryColor3iEXT MANGLE(SecondaryColor3iEXT)
+#define glSecondaryColor3i MANGLE(SecondaryColor3i)
+#define glSecondaryColor3ivEXT MANGLE(SecondaryColor3ivEXT)
+#define glSecondaryColor3iv MANGLE(SecondaryColor3iv)
+#define glSecondaryColor3sEXT MANGLE(SecondaryColor3sEXT)
+#define glSecondaryColor3s MANGLE(SecondaryColor3s)
+#define glSecondaryColor3svEXT MANGLE(SecondaryColor3svEXT)
+#define glSecondaryColor3sv MANGLE(SecondaryColor3sv)
+#define glSecondaryColor3ubEXT MANGLE(SecondaryColor3ubEXT)
+#define glSecondaryColor3ub MANGLE(SecondaryColor3ub)
+#define glSecondaryColor3ubvEXT MANGLE(SecondaryColor3ubvEXT)
+#define glSecondaryColor3ubv MANGLE(SecondaryColor3ubv)
+#define glSecondaryColor3uiEXT MANGLE(SecondaryColor3uiEXT)
+#define glSecondaryColor3ui MANGLE(SecondaryColor3ui)
+#define glSecondaryColor3uivEXT MANGLE(SecondaryColor3uivEXT)
+#define glSecondaryColor3uiv MANGLE(SecondaryColor3uiv)
+#define glSecondaryColor3usEXT MANGLE(SecondaryColor3usEXT)
+#define glSecondaryColor3us MANGLE(SecondaryColor3us)
+#define glSecondaryColor3usvEXT MANGLE(SecondaryColor3usvEXT)
+#define glSecondaryColor3usv MANGLE(SecondaryColor3usv)
+#define glSecondaryColorPointerEXT MANGLE(SecondaryColorPointerEXT)
+#define glSecondaryColorPointerListIBM MANGLE(SecondaryColorPointerListIBM)
+#define glSecondaryColorPointer MANGLE(SecondaryColorPointer)
+#define glSelectBuffer MANGLE(SelectBuffer)
+#define glSeparableFilter2DEXT MANGLE(SeparableFilter2DEXT)
+#define glSeparableFilter2D MANGLE(SeparableFilter2D)
+#define glSetFenceAPPLE MANGLE(SetFenceAPPLE)
+#define glSetFenceNV MANGLE(SetFenceNV)
+#define glSetFragmentShaderConstantATI MANGLE(SetFragmentShaderConstantATI)
+#define glSetInvariantEXT MANGLE(SetInvariantEXT)
+#define glSetLocalConstantEXT MANGLE(SetLocalConstantEXT)
+#define glShadeModel MANGLE(ShadeModel)
+#define glShaderOp1EXT MANGLE(ShaderOp1EXT)
+#define glShaderOp2EXT MANGLE(ShaderOp2EXT)
+#define glShaderOp3EXT MANGLE(ShaderOp3EXT)
+#define glShaderSourceARB MANGLE(ShaderSourceARB)
+#define glShaderSource MANGLE(ShaderSource)
+#define glSharpenTexFuncSGIS MANGLE(SharpenTexFuncSGIS)
+#define glSpriteParameterfSGIX MANGLE(SpriteParameterfSGIX)
+#define glSpriteParameterfvSGIX MANGLE(SpriteParameterfvSGIX)
+#define glSpriteParameteriSGIX MANGLE(SpriteParameteriSGIX)
+#define glSpriteParameterivSGIX MANGLE(SpriteParameterivSGIX)
+#define glStartInstrumentsSGIX MANGLE(StartInstrumentsSGIX)
+#define glStencilFunc MANGLE(StencilFunc)
+#define glStencilFuncSeparateATI MANGLE(StencilFuncSeparateATI)
+#define glStencilFuncSeparate MANGLE(StencilFuncSeparate)
+#define glStencilMask MANGLE(StencilMask)
+#define glStencilMaskSeparate MANGLE(StencilMaskSeparate)
+#define glStencilOp MANGLE(StencilOp)
+#define glStencilOpSeparateATI MANGLE(StencilOpSeparateATI)
+#define glStencilOpSeparate MANGLE(StencilOpSeparate)
+#define glStopInstrumentsSGIX MANGLE(StopInstrumentsSGIX)
+#define glStringMarkerGREMEDY MANGLE(StringMarkerGREMEDY)
+#define glSwizzleEXT MANGLE(SwizzleEXT)
+#define glTagSampleBufferSGIX MANGLE(TagSampleBufferSGIX)
+#define glTangent3bEXT MANGLE(Tangent3bEXT)
+#define glTangent3bvEXT MANGLE(Tangent3bvEXT)
+#define glTangent3dEXT MANGLE(Tangent3dEXT)
+#define glTangent3dvEXT MANGLE(Tangent3dvEXT)
+#define glTangent3fEXT MANGLE(Tangent3fEXT)
+#define glTangent3fvEXT MANGLE(Tangent3fvEXT)
+#define glTangent3iEXT MANGLE(Tangent3iEXT)
+#define glTangent3ivEXT MANGLE(Tangent3ivEXT)
+#define glTangent3sEXT MANGLE(Tangent3sEXT)
+#define glTangent3svEXT MANGLE(Tangent3svEXT)
+#define glTangentPointerEXT MANGLE(TangentPointerEXT)
+#define glTbufferMask3DFX MANGLE(TbufferMask3DFX)
+#define glTestFenceAPPLE MANGLE(TestFenceAPPLE)
+#define glTestFenceNV MANGLE(TestFenceNV)
+#define glTestObjectAPPLE MANGLE(TestObjectAPPLE)
+#define glTexBumpParameterfvATI MANGLE(TexBumpParameterfvATI)
+#define glTexBumpParameterivATI MANGLE(TexBumpParameterivATI)
+#define glTexCoord1d MANGLE(TexCoord1d)
+#define glTexCoord1dv MANGLE(TexCoord1dv)
+#define glTexCoord1f MANGLE(TexCoord1f)
+#define glTexCoord1fv MANGLE(TexCoord1fv)
+#define glTexCoord1hNV MANGLE(TexCoord1hNV)
+#define glTexCoord1hvNV MANGLE(TexCoord1hvNV)
+#define glTexCoord1i MANGLE(TexCoord1i)
+#define glTexCoord1iv MANGLE(TexCoord1iv)
+#define glTexCoord1s MANGLE(TexCoord1s)
+#define glTexCoord1sv MANGLE(TexCoord1sv)
+#define glTexCoord2d MANGLE(TexCoord2d)
+#define glTexCoord2dv MANGLE(TexCoord2dv)
+#define glTexCoord2fColor3fVertex3fSUN MANGLE(TexCoord2fColor3fVertex3fSUN)
+#define glTexCoord2fColor3fVertex3fvSUN MANGLE(TexCoord2fColor3fVertex3fvSUN)
+#define glTexCoord2fColor4fNormal3fVertex3fSUN MANGLE(TexCoord2fColor4fNormal3fVertex3fSUN)
+#define glTexCoord2fColor4fNormal3fVertex3fvSUN MANGLE(TexCoord2fColor4fNormal3fVertex3fvSUN)
+#define glTexCoord2fColor4ubVertex3fSUN MANGLE(TexCoord2fColor4ubVertex3fSUN)
+#define glTexCoord2fColor4ubVertex3fvSUN MANGLE(TexCoord2fColor4ubVertex3fvSUN)
+#define glTexCoord2f MANGLE(TexCoord2f)
+#define glTexCoord2fNormal3fVertex3fSUN MANGLE(TexCoord2fNormal3fVertex3fSUN)
+#define glTexCoord2fNormal3fVertex3fvSUN MANGLE(TexCoord2fNormal3fVertex3fvSUN)
+#define glTexCoord2fVertex3fSUN MANGLE(TexCoord2fVertex3fSUN)
+#define glTexCoord2fVertex3fvSUN MANGLE(TexCoord2fVertex3fvSUN)
+#define glTexCoord2fv MANGLE(TexCoord2fv)
+#define glTexCoord2hNV MANGLE(TexCoord2hNV)
+#define glTexCoord2hvNV MANGLE(TexCoord2hvNV)
+#define glTexCoord2i MANGLE(TexCoord2i)
+#define glTexCoord2iv MANGLE(TexCoord2iv)
+#define glTexCoord2s MANGLE(TexCoord2s)
+#define glTexCoord2sv MANGLE(TexCoord2sv)
+#define glTexCoord3d MANGLE(TexCoord3d)
+#define glTexCoord3dv MANGLE(TexCoord3dv)
+#define glTexCoord3f MANGLE(TexCoord3f)
+#define glTexCoord3fv MANGLE(TexCoord3fv)
+#define glTexCoord3hNV MANGLE(TexCoord3hNV)
+#define glTexCoord3hvNV MANGLE(TexCoord3hvNV)
+#define glTexCoord3i MANGLE(TexCoord3i)
+#define glTexCoord3iv MANGLE(TexCoord3iv)
+#define glTexCoord3s MANGLE(TexCoord3s)
+#define glTexCoord3sv MANGLE(TexCoord3sv)
+#define glTexCoord4d MANGLE(TexCoord4d)
+#define glTexCoord4dv MANGLE(TexCoord4dv)
+#define glTexCoord4fColor4fNormal3fVertex4fSUN MANGLE(TexCoord4fColor4fNormal3fVertex4fSUN)
+#define glTexCoord4fColor4fNormal3fVertex4fvSUN MANGLE(TexCoord4fColor4fNormal3fVertex4fvSUN)
+#define glTexCoord4f MANGLE(TexCoord4f)
+#define glTexCoord4fVertex4fSUN MANGLE(TexCoord4fVertex4fSUN)
+#define glTexCoord4fVertex4fvSUN MANGLE(TexCoord4fVertex4fvSUN)
+#define glTexCoord4fv MANGLE(TexCoord4fv)
+#define glTexCoord4hNV MANGLE(TexCoord4hNV)
+#define glTexCoord4hvNV MANGLE(TexCoord4hvNV)
+#define glTexCoord4i MANGLE(TexCoord4i)
+#define glTexCoord4iv MANGLE(TexCoord4iv)
+#define glTexCoord4s MANGLE(TexCoord4s)
+#define glTexCoord4sv MANGLE(TexCoord4sv)
+#define glTexCoordPointerEXT MANGLE(TexCoordPointerEXT)
+#define glTexCoordPointerListIBM MANGLE(TexCoordPointerListIBM)
+#define glTexCoordPointer MANGLE(TexCoordPointer)
+#define glTexCoordPointervINTEL MANGLE(TexCoordPointervINTEL)
+#define glTexEnvf MANGLE(TexEnvf)
+#define glTexEnvfv MANGLE(TexEnvfv)
+#define glTexEnvi MANGLE(TexEnvi)
+#define glTexEnviv MANGLE(TexEnviv)
+#define glTexFilterFuncSGIS MANGLE(TexFilterFuncSGIS)
+#define glTexGend MANGLE(TexGend)
+#define glTexGendv MANGLE(TexGendv)
+#define glTexGenf MANGLE(TexGenf)
+#define glTexGenfv MANGLE(TexGenfv)
+#define glTexGeni MANGLE(TexGeni)
+#define glTexGeniv MANGLE(TexGeniv)
+#define glTexImage1D MANGLE(TexImage1D)
+#define glTexImage2D MANGLE(TexImage2D)
+#define glTexImage3DEXT MANGLE(TexImage3DEXT)
+#define glTexImage3D MANGLE(TexImage3D)
+#define glTexImage4DSGIS MANGLE(TexImage4DSGIS)
+#define glTexParameterf MANGLE(TexParameterf)
+#define glTexParameterfv MANGLE(TexParameterfv)
+#define glTexParameteri MANGLE(TexParameteri)
+#define glTexParameteriv MANGLE(TexParameteriv)
+#define glTexSubImage1DEXT MANGLE(TexSubImage1DEXT)
+#define glTexSubImage1D MANGLE(TexSubImage1D)
+#define glTexSubImage2DEXT MANGLE(TexSubImage2DEXT)
+#define glTexSubImage2D MANGLE(TexSubImage2D)
+#define glTexSubImage3DEXT MANGLE(TexSubImage3DEXT)
+#define glTexSubImage3D MANGLE(TexSubImage3D)
+#define glTexSubImage4DSGIS MANGLE(TexSubImage4DSGIS)
+#define glTextureColorMaskSGIS MANGLE(TextureColorMaskSGIS)
+#define glTextureLightEXT MANGLE(TextureLightEXT)
+#define glTextureMaterialEXT MANGLE(TextureMaterialEXT)
+#define glTextureNormalEXT MANGLE(TextureNormalEXT)
+#define glTraceAssertAttribMESA MANGLE(TraceAssertAttribMESA)
+#define glTraceCommentMESA MANGLE(TraceCommentMESA)
+#define glTraceListMESA MANGLE(TraceListMESA)
+#define glTracePointerMESA MANGLE(TracePointerMESA)
+#define glTracePointerRangeMESA MANGLE(TracePointerRangeMESA)
+#define glTraceTextureMESA MANGLE(TraceTextureMESA)
+#define glTrackMatrixNV MANGLE(TrackMatrixNV)
+#define glTranslated MANGLE(Translated)
+#define glTranslatef MANGLE(Translatef)
+#define glUniform1fARB MANGLE(Uniform1fARB)
+#define glUniform1f MANGLE(Uniform1f)
+#define glUniform1fvARB MANGLE(Uniform1fvARB)
+#define glUniform1fv MANGLE(Uniform1fv)
+#define glUniform1iARB MANGLE(Uniform1iARB)
+#define glUniform1i MANGLE(Uniform1i)
+#define glUniform1ivARB MANGLE(Uniform1ivARB)
+#define glUniform1iv MANGLE(Uniform1iv)
+#define glUniform2fARB MANGLE(Uniform2fARB)
+#define glUniform2f MANGLE(Uniform2f)
+#define glUniform2fvARB MANGLE(Uniform2fvARB)
+#define glUniform2fv MANGLE(Uniform2fv)
+#define glUniform2iARB MANGLE(Uniform2iARB)
+#define glUniform2i MANGLE(Uniform2i)
+#define glUniform2ivARB MANGLE(Uniform2ivARB)
+#define glUniform2iv MANGLE(Uniform2iv)
+#define glUniform3fARB MANGLE(Uniform3fARB)
+#define glUniform3f MANGLE(Uniform3f)
+#define glUniform3fvARB MANGLE(Uniform3fvARB)
+#define glUniform3fv MANGLE(Uniform3fv)
+#define glUniform3iARB MANGLE(Uniform3iARB)
+#define glUniform3i MANGLE(Uniform3i)
+#define glUniform3ivARB MANGLE(Uniform3ivARB)
+#define glUniform3iv MANGLE(Uniform3iv)
+#define glUniform4fARB MANGLE(Uniform4fARB)
+#define glUniform4f MANGLE(Uniform4f)
+#define glUniform4fvARB MANGLE(Uniform4fvARB)
+#define glUniform4fv MANGLE(Uniform4fv)
+#define glUniform4iARB MANGLE(Uniform4iARB)
+#define glUniform4i MANGLE(Uniform4i)
+#define glUniform4ivARB MANGLE(Uniform4ivARB)
+#define glUniform4iv MANGLE(Uniform4iv)
+#define glUniformMatrix2fvARB MANGLE(UniformMatrix2fvARB)
+#define glUniformMatrix2fv MANGLE(UniformMatrix2fv)
+#define glUniformMatrix3fvARB MANGLE(UniformMatrix3fvARB)
+#define glUniformMatrix3fv MANGLE(UniformMatrix3fv)
+#define glUniformMatrix4fvARB MANGLE(UniformMatrix4fvARB)
+#define glUniformMatrix4fv MANGLE(UniformMatrix4fv)
+#define glUnlockArraysEXT MANGLE(UnlockArraysEXT)
+#define glUnmapBufferARB MANGLE(UnmapBufferARB)
+#define glUnmapBuffer MANGLE(UnmapBuffer)
+#define glUnmapObjectBufferATI MANGLE(UnmapObjectBufferATI)
+#define glUpdateObjectBufferATI MANGLE(UpdateObjectBufferATI)
+#define glUseProgram MANGLE(UseProgram)
+#define glUseProgramObjectARB MANGLE(UseProgramObjectARB)
+#define glValidateProgramARB MANGLE(ValidateProgramARB)
+#define glValidateProgram MANGLE(ValidateProgram)
+#define glVariantArrayObjectATI MANGLE(VariantArrayObjectATI)
+#define glVariantbvEXT MANGLE(VariantbvEXT)
+#define glVariantdvEXT MANGLE(VariantdvEXT)
+#define glVariantfvEXT MANGLE(VariantfvEXT)
+#define glVariantivEXT MANGLE(VariantivEXT)
+#define glVariantPointerEXT MANGLE(VariantPointerEXT)
+#define glVariantsvEXT MANGLE(VariantsvEXT)
+#define glVariantubvEXT MANGLE(VariantubvEXT)
+#define glVariantuivEXT MANGLE(VariantuivEXT)
+#define glVariantusvEXT MANGLE(VariantusvEXT)
+#define glVertex2d MANGLE(Vertex2d)
+#define glVertex2dv MANGLE(Vertex2dv)
+#define glVertex2f MANGLE(Vertex2f)
+#define glVertex2fv MANGLE(Vertex2fv)
+#define glVertex2hNV MANGLE(Vertex2hNV)
+#define glVertex2hvNV MANGLE(Vertex2hvNV)
+#define glVertex2i MANGLE(Vertex2i)
+#define glVertex2iv MANGLE(Vertex2iv)
+#define glVertex2s MANGLE(Vertex2s)
+#define glVertex2sv MANGLE(Vertex2sv)
+#define glVertex3d MANGLE(Vertex3d)
+#define glVertex3dv MANGLE(Vertex3dv)
+#define glVertex3f MANGLE(Vertex3f)
+#define glVertex3fv MANGLE(Vertex3fv)
+#define glVertex3hNV MANGLE(Vertex3hNV)
+#define glVertex3hvNV MANGLE(Vertex3hvNV)
+#define glVertex3i MANGLE(Vertex3i)
+#define glVertex3iv MANGLE(Vertex3iv)
+#define glVertex3s MANGLE(Vertex3s)
+#define glVertex3sv MANGLE(Vertex3sv)
+#define glVertex4d MANGLE(Vertex4d)
+#define glVertex4dv MANGLE(Vertex4dv)
+#define glVertex4f MANGLE(Vertex4f)
+#define glVertex4fv MANGLE(Vertex4fv)
+#define glVertex4hNV MANGLE(Vertex4hNV)
+#define glVertex4hvNV MANGLE(Vertex4hvNV)
+#define glVertex4i MANGLE(Vertex4i)
+#define glVertex4iv MANGLE(Vertex4iv)
+#define glVertex4s MANGLE(Vertex4s)
+#define glVertex4sv MANGLE(Vertex4sv)
+#define glVertexArrayParameteriAPPLE MANGLE(VertexArrayParameteriAPPLE)
+#define glVertexArrayRangeAPPLE MANGLE(VertexArrayRangeAPPLE)
+#define glVertexArrayRangeNV MANGLE(VertexArrayRangeNV)
+#define glVertexAttrib1dARB MANGLE(VertexAttrib1dARB)
+#define glVertexAttrib1d MANGLE(VertexAttrib1d)
+#define glVertexAttrib1dNV MANGLE(VertexAttrib1dNV)
+#define glVertexAttrib1dvARB MANGLE(VertexAttrib1dvARB)
+#define glVertexAttrib1dv MANGLE(VertexAttrib1dv)
+#define glVertexAttrib1dvNV MANGLE(VertexAttrib1dvNV)
+#define glVertexAttrib1fARB MANGLE(VertexAttrib1fARB)
+#define glVertexAttrib1f MANGLE(VertexAttrib1f)
+#define glVertexAttrib1fNV MANGLE(VertexAttrib1fNV)
+#define glVertexAttrib1fvARB MANGLE(VertexAttrib1fvARB)
+#define glVertexAttrib1fv MANGLE(VertexAttrib1fv)
+#define glVertexAttrib1fvNV MANGLE(VertexAttrib1fvNV)
+#define glVertexAttrib1hNV MANGLE(VertexAttrib1hNV)
+#define glVertexAttrib1hvNV MANGLE(VertexAttrib1hvNV)
+#define glVertexAttrib1sARB MANGLE(VertexAttrib1sARB)
+#define glVertexAttrib1s MANGLE(VertexAttrib1s)
+#define glVertexAttrib1sNV MANGLE(VertexAttrib1sNV)
+#define glVertexAttrib1svARB MANGLE(VertexAttrib1svARB)
+#define glVertexAttrib1sv MANGLE(VertexAttrib1sv)
+#define glVertexAttrib1svNV MANGLE(VertexAttrib1svNV)
+#define glVertexAttrib2dARB MANGLE(VertexAttrib2dARB)
+#define glVertexAttrib2d MANGLE(VertexAttrib2d)
+#define glVertexAttrib2dNV MANGLE(VertexAttrib2dNV)
+#define glVertexAttrib2dvARB MANGLE(VertexAttrib2dvARB)
+#define glVertexAttrib2dv MANGLE(VertexAttrib2dv)
+#define glVertexAttrib2dvNV MANGLE(VertexAttrib2dvNV)
+#define glVertexAttrib2fARB MANGLE(VertexAttrib2fARB)
+#define glVertexAttrib2f MANGLE(VertexAttrib2f)
+#define glVertexAttrib2fNV MANGLE(VertexAttrib2fNV)
+#define glVertexAttrib2fvARB MANGLE(VertexAttrib2fvARB)
+#define glVertexAttrib2fv MANGLE(VertexAttrib2fv)
+#define glVertexAttrib2fvNV MANGLE(VertexAttrib2fvNV)
+#define glVertexAttrib2hNV MANGLE(VertexAttrib2hNV)
+#define glVertexAttrib2hvNV MANGLE(VertexAttrib2hvNV)
+#define glVertexAttrib2sARB MANGLE(VertexAttrib2sARB)
+#define glVertexAttrib2s MANGLE(VertexAttrib2s)
+#define glVertexAttrib2sNV MANGLE(VertexAttrib2sNV)
+#define glVertexAttrib2svARB MANGLE(VertexAttrib2svARB)
+#define glVertexAttrib2sv MANGLE(VertexAttrib2sv)
+#define glVertexAttrib2svNV MANGLE(VertexAttrib2svNV)
+#define glVertexAttrib3dARB MANGLE(VertexAttrib3dARB)
+#define glVertexAttrib3d MANGLE(VertexAttrib3d)
+#define glVertexAttrib3dNV MANGLE(VertexAttrib3dNV)
+#define glVertexAttrib3dvARB MANGLE(VertexAttrib3dvARB)
+#define glVertexAttrib3dv MANGLE(VertexAttrib3dv)
+#define glVertexAttrib3dvNV MANGLE(VertexAttrib3dvNV)
+#define glVertexAttrib3fARB MANGLE(VertexAttrib3fARB)
+#define glVertexAttrib3f MANGLE(VertexAttrib3f)
+#define glVertexAttrib3fNV MANGLE(VertexAttrib3fNV)
+#define glVertexAttrib3fvARB MANGLE(VertexAttrib3fvARB)
+#define glVertexAttrib3fv MANGLE(VertexAttrib3fv)
+#define glVertexAttrib3fvNV MANGLE(VertexAttrib3fvNV)
+#define glVertexAttrib3hNV MANGLE(VertexAttrib3hNV)
+#define glVertexAttrib3hvNV MANGLE(VertexAttrib3hvNV)
+#define glVertexAttrib3sARB MANGLE(VertexAttrib3sARB)
+#define glVertexAttrib3s MANGLE(VertexAttrib3s)
+#define glVertexAttrib3sNV MANGLE(VertexAttrib3sNV)
+#define glVertexAttrib3svARB MANGLE(VertexAttrib3svARB)
+#define glVertexAttrib3sv MANGLE(VertexAttrib3sv)
+#define glVertexAttrib3svNV MANGLE(VertexAttrib3svNV)
+#define glVertexAttrib4bvARB MANGLE(VertexAttrib4bvARB)
+#define glVertexAttrib4bv MANGLE(VertexAttrib4bv)
+#define glVertexAttrib4dARB MANGLE(VertexAttrib4dARB)
+#define glVertexAttrib4d MANGLE(VertexAttrib4d)
+#define glVertexAttrib4dNV MANGLE(VertexAttrib4dNV)
+#define glVertexAttrib4dvARB MANGLE(VertexAttrib4dvARB)
+#define glVertexAttrib4dv MANGLE(VertexAttrib4dv)
+#define glVertexAttrib4dvNV MANGLE(VertexAttrib4dvNV)
+#define glVertexAttrib4fARB MANGLE(VertexAttrib4fARB)
+#define glVertexAttrib4f MANGLE(VertexAttrib4f)
+#define glVertexAttrib4fNV MANGLE(VertexAttrib4fNV)
+#define glVertexAttrib4fvARB MANGLE(VertexAttrib4fvARB)
+#define glVertexAttrib4fv MANGLE(VertexAttrib4fv)
+#define glVertexAttrib4fvNV MANGLE(VertexAttrib4fvNV)
+#define glVertexAttrib4hNV MANGLE(VertexAttrib4hNV)
+#define glVertexAttrib4hvNV MANGLE(VertexAttrib4hvNV)
+#define glVertexAttrib4ivARB MANGLE(VertexAttrib4ivARB)
+#define glVertexAttrib4iv MANGLE(VertexAttrib4iv)
+#define glVertexAttrib4NbvARB MANGLE(VertexAttrib4NbvARB)
+#define glVertexAttrib4Nbv MANGLE(VertexAttrib4Nbv)
+#define glVertexAttrib4NivARB MANGLE(VertexAttrib4NivARB)
+#define glVertexAttrib4Niv MANGLE(VertexAttrib4Niv)
+#define glVertexAttrib4NsvARB MANGLE(VertexAttrib4NsvARB)
+#define glVertexAttrib4Nsv MANGLE(VertexAttrib4Nsv)
+#define glVertexAttrib4NubARB MANGLE(VertexAttrib4NubARB)
+#define glVertexAttrib4Nub MANGLE(VertexAttrib4Nub)
+#define glVertexAttrib4NubvARB MANGLE(VertexAttrib4NubvARB)
+#define glVertexAttrib4Nubv MANGLE(VertexAttrib4Nubv)
+#define glVertexAttrib4NuivARB MANGLE(VertexAttrib4NuivARB)
+#define glVertexAttrib4Nuiv MANGLE(VertexAttrib4Nuiv)
+#define glVertexAttrib4NusvARB MANGLE(VertexAttrib4NusvARB)
+#define glVertexAttrib4Nusv MANGLE(VertexAttrib4Nusv)
+#define glVertexAttrib4sARB MANGLE(VertexAttrib4sARB)
+#define glVertexAttrib4s MANGLE(VertexAttrib4s)
+#define glVertexAttrib4sNV MANGLE(VertexAttrib4sNV)
+#define glVertexAttrib4svARB MANGLE(VertexAttrib4svARB)
+#define glVertexAttrib4sv MANGLE(VertexAttrib4sv)
+#define glVertexAttrib4svNV MANGLE(VertexAttrib4svNV)
+#define glVertexAttrib4ubNV MANGLE(VertexAttrib4ubNV)
+#define glVertexAttrib4ubvARB MANGLE(VertexAttrib4ubvARB)
+#define glVertexAttrib4ubv MANGLE(VertexAttrib4ubv)
+#define glVertexAttrib4ubvNV MANGLE(VertexAttrib4ubvNV)
+#define glVertexAttrib4uivARB MANGLE(VertexAttrib4uivARB)
+#define glVertexAttrib4uiv MANGLE(VertexAttrib4uiv)
+#define glVertexAttrib4usvARB MANGLE(VertexAttrib4usvARB)
+#define glVertexAttrib4usv MANGLE(VertexAttrib4usv)
+#define glVertexAttribArrayObjectATI MANGLE(VertexAttribArrayObjectATI)
+#define glVertexAttribPointerARB MANGLE(VertexAttribPointerARB)
+#define glVertexAttribPointer MANGLE(VertexAttribPointer)
+#define glVertexAttribPointerNV MANGLE(VertexAttribPointerNV)
+#define glVertexAttribs1dvNV MANGLE(VertexAttribs1dvNV)
+#define glVertexAttribs1fvNV MANGLE(VertexAttribs1fvNV)
+#define glVertexAttribs1hvNV MANGLE(VertexAttribs1hvNV)
+#define glVertexAttribs1svNV MANGLE(VertexAttribs1svNV)
+#define glVertexAttribs2dvNV MANGLE(VertexAttribs2dvNV)
+#define glVertexAttribs2fvNV MANGLE(VertexAttribs2fvNV)
+#define glVertexAttribs2hvNV MANGLE(VertexAttribs2hvNV)
+#define glVertexAttribs2svNV MANGLE(VertexAttribs2svNV)
+#define glVertexAttribs3dvNV MANGLE(VertexAttribs3dvNV)
+#define glVertexAttribs3fvNV MANGLE(VertexAttribs3fvNV)
+#define glVertexAttribs3hvNV MANGLE(VertexAttribs3hvNV)
+#define glVertexAttribs3svNV MANGLE(VertexAttribs3svNV)
+#define glVertexAttribs4dvNV MANGLE(VertexAttribs4dvNV)
+#define glVertexAttribs4fvNV MANGLE(VertexAttribs4fvNV)
+#define glVertexAttribs4hvNV MANGLE(VertexAttribs4hvNV)
+#define glVertexAttribs4svNV MANGLE(VertexAttribs4svNV)
+#define glVertexAttribs4ubvNV MANGLE(VertexAttribs4ubvNV)
+#define glVertexBlendARB MANGLE(VertexBlendARB)
+#define glVertexBlendEnvfATI MANGLE(VertexBlendEnvfATI)
+#define glVertexBlendEnviATI MANGLE(VertexBlendEnviATI)
+#define glVertexPointerEXT MANGLE(VertexPointerEXT)
+#define glVertexPointerListIBM MANGLE(VertexPointerListIBM)
+#define glVertexPointer MANGLE(VertexPointer)
+#define glVertexPointervINTEL MANGLE(VertexPointervINTEL)
+#define glVertexStream1dATI MANGLE(VertexStream1dATI)
+#define glVertexStream1dvATI MANGLE(VertexStream1dvATI)
+#define glVertexStream1fATI MANGLE(VertexStream1fATI)
+#define glVertexStream1fvATI MANGLE(VertexStream1fvATI)
+#define glVertexStream1iATI MANGLE(VertexStream1iATI)
+#define glVertexStream1ivATI MANGLE(VertexStream1ivATI)
+#define glVertexStream1sATI MANGLE(VertexStream1sATI)
+#define glVertexStream1svATI MANGLE(VertexStream1svATI)
+#define glVertexStream2dATI MANGLE(VertexStream2dATI)
+#define glVertexStream2dvATI MANGLE(VertexStream2dvATI)
+#define glVertexStream2fATI MANGLE(VertexStream2fATI)
+#define glVertexStream2fvATI MANGLE(VertexStream2fvATI)
+#define glVertexStream2iATI MANGLE(VertexStream2iATI)
+#define glVertexStream2ivATI MANGLE(VertexStream2ivATI)
+#define glVertexStream2sATI MANGLE(VertexStream2sATI)
+#define glVertexStream2svATI MANGLE(VertexStream2svATI)
+#define glVertexStream3dATI MANGLE(VertexStream3dATI)
+#define glVertexStream3dvATI MANGLE(VertexStream3dvATI)
+#define glVertexStream3fATI MANGLE(VertexStream3fATI)
+#define glVertexStream3fvATI MANGLE(VertexStream3fvATI)
+#define glVertexStream3iATI MANGLE(VertexStream3iATI)
+#define glVertexStream3ivATI MANGLE(VertexStream3ivATI)
+#define glVertexStream3sATI MANGLE(VertexStream3sATI)
+#define glVertexStream3svATI MANGLE(VertexStream3svATI)
+#define glVertexStream4dATI MANGLE(VertexStream4dATI)
+#define glVertexStream4dvATI MANGLE(VertexStream4dvATI)
+#define glVertexStream4fATI MANGLE(VertexStream4fATI)
+#define glVertexStream4fvATI MANGLE(VertexStream4fvATI)
+#define glVertexStream4iATI MANGLE(VertexStream4iATI)
+#define glVertexStream4ivATI MANGLE(VertexStream4ivATI)
+#define glVertexStream4sATI MANGLE(VertexStream4sATI)
+#define glVertexStream4svATI MANGLE(VertexStream4svATI)
+#define glVertexWeightfEXT MANGLE(VertexWeightfEXT)
+#define glVertexWeightfvEXT MANGLE(VertexWeightfvEXT)
+#define glVertexWeighthNV MANGLE(VertexWeighthNV)
+#define glVertexWeighthvNV MANGLE(VertexWeighthvNV)
+#define glVertexWeightPointerEXT MANGLE(VertexWeightPointerEXT)
+#define glViewport MANGLE(Viewport)
+#define glWeightbvARB MANGLE(WeightbvARB)
+#define glWeightdvARB MANGLE(WeightdvARB)
+#define glWeightfvARB MANGLE(WeightfvARB)
+#define glWeightivARB MANGLE(WeightivARB)
+#define glWeightPointerARB MANGLE(WeightPointerARB)
+#define glWeightsvARB MANGLE(WeightsvARB)
+#define glWeightubvARB MANGLE(WeightubvARB)
+#define glWeightuivARB MANGLE(WeightuivARB)
+#define glWeightusvARB MANGLE(WeightusvARB)
+#define glWindowPos2dARB MANGLE(WindowPos2dARB)
+#define glWindowPos2d MANGLE(WindowPos2d)
+#define glWindowPos2dMESA MANGLE(WindowPos2dMESA)
+#define glWindowPos2dvARB MANGLE(WindowPos2dvARB)
+#define glWindowPos2dv MANGLE(WindowPos2dv)
+#define glWindowPos2dvMESA MANGLE(WindowPos2dvMESA)
+#define glWindowPos2fARB MANGLE(WindowPos2fARB)
+#define glWindowPos2f MANGLE(WindowPos2f)
+#define glWindowPos2fMESA MANGLE(WindowPos2fMESA)
+#define glWindowPos2fvARB MANGLE(WindowPos2fvARB)
+#define glWindowPos2fv MANGLE(WindowPos2fv)
+#define glWindowPos2fvMESA MANGLE(WindowPos2fvMESA)
+#define glWindowPos2iARB MANGLE(WindowPos2iARB)
+#define glWindowPos2i MANGLE(WindowPos2i)
+#define glWindowPos2iMESA MANGLE(WindowPos2iMESA)
+#define glWindowPos2ivARB MANGLE(WindowPos2ivARB)
+#define glWindowPos2iv MANGLE(WindowPos2iv)
+#define glWindowPos2ivMESA MANGLE(WindowPos2ivMESA)
+#define glWindowPos2sARB MANGLE(WindowPos2sARB)
+#define glWindowPos2s MANGLE(WindowPos2s)
+#define glWindowPos2sMESA MANGLE(WindowPos2sMESA)
+#define glWindowPos2svARB MANGLE(WindowPos2svARB)
+#define glWindowPos2sv MANGLE(WindowPos2sv)
+#define glWindowPos2svMESA MANGLE(WindowPos2svMESA)
+#define glWindowPos3dARB MANGLE(WindowPos3dARB)
+#define glWindowPos3d MANGLE(WindowPos3d)
+#define glWindowPos3dMESA MANGLE(WindowPos3dMESA)
+#define glWindowPos3dvARB MANGLE(WindowPos3dvARB)
+#define glWindowPos3dv MANGLE(WindowPos3dv)
+#define glWindowPos3dvMESA MANGLE(WindowPos3dvMESA)
+#define glWindowPos3fARB MANGLE(WindowPos3fARB)
+#define glWindowPos3f MANGLE(WindowPos3f)
+#define glWindowPos3fMESA MANGLE(WindowPos3fMESA)
+#define glWindowPos3fvARB MANGLE(WindowPos3fvARB)
+#define glWindowPos3fv MANGLE(WindowPos3fv)
+#define glWindowPos3fvMESA MANGLE(WindowPos3fvMESA)
+#define glWindowPos3iARB MANGLE(WindowPos3iARB)
+#define glWindowPos3i MANGLE(WindowPos3i)
+#define glWindowPos3iMESA MANGLE(WindowPos3iMESA)
+#define glWindowPos3ivARB MANGLE(WindowPos3ivARB)
+#define glWindowPos3iv MANGLE(WindowPos3iv)
+#define glWindowPos3ivMESA MANGLE(WindowPos3ivMESA)
+#define glWindowPos3sARB MANGLE(WindowPos3sARB)
+#define glWindowPos3s MANGLE(WindowPos3s)
+#define glWindowPos3sMESA MANGLE(WindowPos3sMESA)
+#define glWindowPos3svARB MANGLE(WindowPos3svARB)
+#define glWindowPos3sv MANGLE(WindowPos3sv)
+#define glWindowPos3svMESA MANGLE(WindowPos3svMESA)
+#define glWindowPos4dMESA MANGLE(WindowPos4dMESA)
+#define glWindowPos4dvMESA MANGLE(WindowPos4dvMESA)
+#define glWindowPos4fMESA MANGLE(WindowPos4fMESA)
+#define glWindowPos4fvMESA MANGLE(WindowPos4fvMESA)
+#define glWindowPos4iMESA MANGLE(WindowPos4iMESA)
+#define glWindowPos4ivMESA MANGLE(WindowPos4ivMESA)
+#define glWindowPos4sMESA MANGLE(WindowPos4sMESA)
+#define glWindowPos4svMESA MANGLE(WindowPos4svMESA)
+#define glWriteMaskEXT MANGLE(WriteMaskEXT)
+
+#endif /* GL_MANGLE_H */
diff --git a/nx-X11/extras/Mesa/include/GL/glext.h b/nx-X11/extras/Mesa/include/GL/glext.h
new file mode 100644
index 000000000..7bb8e6e7c
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/glext.h
@@ -0,0 +1,6495 @@
+#ifndef __glext_h_
+#define __glext_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+#ifndef APIENTRYP
+#define APIENTRYP APIENTRY *
+#endif
+#ifndef GLAPI
+#define GLAPI extern
+#endif
+
+/*************************************************************/
+
+/* Header file version number, required by OpenGL ABI for Linux */
+/* glext.h last updated 2005/06/20 */
+/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */
+#define GL_GLEXT_VERSION 29
+
+#ifndef GL_VERSION_1_2
+#define GL_UNSIGNED_BYTE_3_3_2 0x8032
+#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
+#define GL_UNSIGNED_INT_8_8_8_8 0x8035
+#define GL_UNSIGNED_INT_10_10_10_2 0x8036
+#define GL_RESCALE_NORMAL 0x803A
+#define GL_TEXTURE_BINDING_3D 0x806A
+#define GL_PACK_SKIP_IMAGES 0x806B
+#define GL_PACK_IMAGE_HEIGHT 0x806C
+#define GL_UNPACK_SKIP_IMAGES 0x806D
+#define GL_UNPACK_IMAGE_HEIGHT 0x806E
+#define GL_TEXTURE_3D 0x806F
+#define GL_PROXY_TEXTURE_3D 0x8070
+#define GL_TEXTURE_DEPTH 0x8071
+#define GL_TEXTURE_WRAP_R 0x8072
+#define GL_MAX_3D_TEXTURE_SIZE 0x8073
+#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
+#define GL_UNSIGNED_SHORT_5_6_5 0x8363
+#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
+#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
+#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
+#define GL_BGR 0x80E0
+#define GL_BGRA 0x80E1
+#define GL_MAX_ELEMENTS_VERTICES 0x80E8
+#define GL_MAX_ELEMENTS_INDICES 0x80E9
+#define GL_CLAMP_TO_EDGE 0x812F
+#define GL_TEXTURE_MIN_LOD 0x813A
+#define GL_TEXTURE_MAX_LOD 0x813B
+#define GL_TEXTURE_BASE_LEVEL 0x813C
+#define GL_TEXTURE_MAX_LEVEL 0x813D
+#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8
+#define GL_SINGLE_COLOR 0x81F9
+#define GL_SEPARATE_SPECULAR_COLOR 0x81FA
+#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
+#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
+#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
+#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
+#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
+#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
+#endif
+
+#ifndef GL_ARB_imaging
+#define GL_CONSTANT_COLOR 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
+#define GL_CONSTANT_ALPHA 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
+#define GL_BLEND_COLOR 0x8005
+#define GL_FUNC_ADD 0x8006
+#define GL_MIN 0x8007
+#define GL_MAX 0x8008
+#define GL_BLEND_EQUATION 0x8009
+#define GL_FUNC_SUBTRACT 0x800A
+#define GL_FUNC_REVERSE_SUBTRACT 0x800B
+#define GL_CONVOLUTION_1D 0x8010
+#define GL_CONVOLUTION_2D 0x8011
+#define GL_SEPARABLE_2D 0x8012
+#define GL_CONVOLUTION_BORDER_MODE 0x8013
+#define GL_CONVOLUTION_FILTER_SCALE 0x8014
+#define GL_CONVOLUTION_FILTER_BIAS 0x8015
+#define GL_REDUCE 0x8016
+#define GL_CONVOLUTION_FORMAT 0x8017
+#define GL_CONVOLUTION_WIDTH 0x8018
+#define GL_CONVOLUTION_HEIGHT 0x8019
+#define GL_MAX_CONVOLUTION_WIDTH 0x801A
+#define GL_MAX_CONVOLUTION_HEIGHT 0x801B
+#define GL_POST_CONVOLUTION_RED_SCALE 0x801C
+#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D
+#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E
+#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F
+#define GL_POST_CONVOLUTION_RED_BIAS 0x8020
+#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021
+#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022
+#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023
+#define GL_HISTOGRAM 0x8024
+#define GL_PROXY_HISTOGRAM 0x8025
+#define GL_HISTOGRAM_WIDTH 0x8026
+#define GL_HISTOGRAM_FORMAT 0x8027
+#define GL_HISTOGRAM_RED_SIZE 0x8028
+#define GL_HISTOGRAM_GREEN_SIZE 0x8029
+#define GL_HISTOGRAM_BLUE_SIZE 0x802A
+#define GL_HISTOGRAM_ALPHA_SIZE 0x802B
+#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C
+#define GL_HISTOGRAM_SINK 0x802D
+#define GL_MINMAX 0x802E
+#define GL_MINMAX_FORMAT 0x802F
+#define GL_MINMAX_SINK 0x8030
+#define GL_TABLE_TOO_LARGE 0x8031
+#define GL_COLOR_MATRIX 0x80B1
+#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2
+#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3
+#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4
+#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5
+#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6
+#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7
+#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8
+#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9
+#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA
+#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB
+#define GL_COLOR_TABLE 0x80D0
+#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1
+#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2
+#define GL_PROXY_COLOR_TABLE 0x80D3
+#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4
+#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5
+#define GL_COLOR_TABLE_SCALE 0x80D6
+#define GL_COLOR_TABLE_BIAS 0x80D7
+#define GL_COLOR_TABLE_FORMAT 0x80D8
+#define GL_COLOR_TABLE_WIDTH 0x80D9
+#define GL_COLOR_TABLE_RED_SIZE 0x80DA
+#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB
+#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC
+#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD
+#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE
+#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF
+#define GL_CONSTANT_BORDER 0x8151
+#define GL_REPLICATE_BORDER 0x8153
+#define GL_CONVOLUTION_BORDER_COLOR 0x8154
+#endif
+
+#ifndef GL_VERSION_1_3
+#define GL_TEXTURE0 0x84C0
+#define GL_TEXTURE1 0x84C1
+#define GL_TEXTURE2 0x84C2
+#define GL_TEXTURE3 0x84C3
+#define GL_TEXTURE4 0x84C4
+#define GL_TEXTURE5 0x84C5
+#define GL_TEXTURE6 0x84C6
+#define GL_TEXTURE7 0x84C7
+#define GL_TEXTURE8 0x84C8
+#define GL_TEXTURE9 0x84C9
+#define GL_TEXTURE10 0x84CA
+#define GL_TEXTURE11 0x84CB
+#define GL_TEXTURE12 0x84CC
+#define GL_TEXTURE13 0x84CD
+#define GL_TEXTURE14 0x84CE
+#define GL_TEXTURE15 0x84CF
+#define GL_TEXTURE16 0x84D0
+#define GL_TEXTURE17 0x84D1
+#define GL_TEXTURE18 0x84D2
+#define GL_TEXTURE19 0x84D3
+#define GL_TEXTURE20 0x84D4
+#define GL_TEXTURE21 0x84D5
+#define GL_TEXTURE22 0x84D6
+#define GL_TEXTURE23 0x84D7
+#define GL_TEXTURE24 0x84D8
+#define GL_TEXTURE25 0x84D9
+#define GL_TEXTURE26 0x84DA
+#define GL_TEXTURE27 0x84DB
+#define GL_TEXTURE28 0x84DC
+#define GL_TEXTURE29 0x84DD
+#define GL_TEXTURE30 0x84DE
+#define GL_TEXTURE31 0x84DF
+#define GL_ACTIVE_TEXTURE 0x84E0
+#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1
+#define GL_MAX_TEXTURE_UNITS 0x84E2
+#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3
+#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4
+#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5
+#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6
+#define GL_MULTISAMPLE 0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
+#define GL_SAMPLE_COVERAGE 0x80A0
+#define GL_SAMPLE_BUFFERS 0x80A8
+#define GL_SAMPLES 0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
+#define GL_MULTISAMPLE_BIT 0x20000000
+#define GL_NORMAL_MAP 0x8511
+#define GL_REFLECTION_MAP 0x8512
+#define GL_TEXTURE_CUBE_MAP 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
+#define GL_COMPRESSED_ALPHA 0x84E9
+#define GL_COMPRESSED_LUMINANCE 0x84EA
+#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB
+#define GL_COMPRESSED_INTENSITY 0x84EC
+#define GL_COMPRESSED_RGB 0x84ED
+#define GL_COMPRESSED_RGBA 0x84EE
+#define GL_TEXTURE_COMPRESSION_HINT 0x84EF
+#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0
+#define GL_TEXTURE_COMPRESSED 0x86A1
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
+#define GL_CLAMP_TO_BORDER 0x812D
+#define GL_COMBINE 0x8570
+#define GL_COMBINE_RGB 0x8571
+#define GL_COMBINE_ALPHA 0x8572
+#define GL_SOURCE0_RGB 0x8580
+#define GL_SOURCE1_RGB 0x8581
+#define GL_SOURCE2_RGB 0x8582
+#define GL_SOURCE0_ALPHA 0x8588
+#define GL_SOURCE1_ALPHA 0x8589
+#define GL_SOURCE2_ALPHA 0x858A
+#define GL_OPERAND0_RGB 0x8590
+#define GL_OPERAND1_RGB 0x8591
+#define GL_OPERAND2_RGB 0x8592
+#define GL_OPERAND0_ALPHA 0x8598
+#define GL_OPERAND1_ALPHA 0x8599
+#define GL_OPERAND2_ALPHA 0x859A
+#define GL_RGB_SCALE 0x8573
+#define GL_ADD_SIGNED 0x8574
+#define GL_INTERPOLATE 0x8575
+#define GL_SUBTRACT 0x84E7
+#define GL_CONSTANT 0x8576
+#define GL_PRIMARY_COLOR 0x8577
+#define GL_PREVIOUS 0x8578
+#define GL_DOT3_RGB 0x86AE
+#define GL_DOT3_RGBA 0x86AF
+#endif
+
+#ifndef GL_VERSION_1_4
+#define GL_BLEND_DST_RGB 0x80C8
+#define GL_BLEND_SRC_RGB 0x80C9
+#define GL_BLEND_DST_ALPHA 0x80CA
+#define GL_BLEND_SRC_ALPHA 0x80CB
+#define GL_POINT_SIZE_MIN 0x8126
+#define GL_POINT_SIZE_MAX 0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128
+#define GL_POINT_DISTANCE_ATTENUATION 0x8129
+#define GL_GENERATE_MIPMAP 0x8191
+#define GL_GENERATE_MIPMAP_HINT 0x8192
+#define GL_DEPTH_COMPONENT16 0x81A5
+#define GL_DEPTH_COMPONENT24 0x81A6
+#define GL_DEPTH_COMPONENT32 0x81A7
+#define GL_MIRRORED_REPEAT 0x8370
+#define GL_FOG_COORDINATE_SOURCE 0x8450
+#define GL_FOG_COORDINATE 0x8451
+#define GL_FRAGMENT_DEPTH 0x8452
+#define GL_CURRENT_FOG_COORDINATE 0x8453
+#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454
+#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455
+#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456
+#define GL_FOG_COORDINATE_ARRAY 0x8457
+#define GL_COLOR_SUM 0x8458
+#define GL_CURRENT_SECONDARY_COLOR 0x8459
+#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A
+#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B
+#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C
+#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D
+#define GL_SECONDARY_COLOR_ARRAY 0x845E
+#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
+#define GL_TEXTURE_FILTER_CONTROL 0x8500
+#define GL_TEXTURE_LOD_BIAS 0x8501
+#define GL_INCR_WRAP 0x8507
+#define GL_DECR_WRAP 0x8508
+#define GL_TEXTURE_DEPTH_SIZE 0x884A
+#define GL_DEPTH_TEXTURE_MODE 0x884B
+#define GL_TEXTURE_COMPARE_MODE 0x884C
+#define GL_TEXTURE_COMPARE_FUNC 0x884D
+#define GL_COMPARE_R_TO_TEXTURE 0x884E
+#endif
+
+#ifndef GL_VERSION_1_5
+#define GL_BUFFER_SIZE 0x8764
+#define GL_BUFFER_USAGE 0x8765
+#define GL_QUERY_COUNTER_BITS 0x8864
+#define GL_CURRENT_QUERY 0x8865
+#define GL_QUERY_RESULT 0x8866
+#define GL_QUERY_RESULT_AVAILABLE 0x8867
+#define GL_ARRAY_BUFFER 0x8892
+#define GL_ELEMENT_ARRAY_BUFFER 0x8893
+#define GL_ARRAY_BUFFER_BINDING 0x8894
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
+#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896
+#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897
+#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898
+#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899
+#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
+#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B
+#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C
+#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D
+#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
+#define GL_READ_ONLY 0x88B8
+#define GL_WRITE_ONLY 0x88B9
+#define GL_READ_WRITE 0x88BA
+#define GL_BUFFER_ACCESS 0x88BB
+#define GL_BUFFER_MAPPED 0x88BC
+#define GL_BUFFER_MAP_POINTER 0x88BD
+#define GL_STREAM_DRAW 0x88E0
+#define GL_STREAM_READ 0x88E1
+#define GL_STREAM_COPY 0x88E2
+#define GL_STATIC_DRAW 0x88E4
+#define GL_STATIC_READ 0x88E5
+#define GL_STATIC_COPY 0x88E6
+#define GL_DYNAMIC_DRAW 0x88E8
+#define GL_DYNAMIC_READ 0x88E9
+#define GL_DYNAMIC_COPY 0x88EA
+#define GL_SAMPLES_PASSED 0x8914
+#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE
+#define GL_FOG_COORD GL_FOG_COORDINATE
+#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE
+#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE
+#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE
+#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER
+#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY
+#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING
+#define GL_SRC0_RGB GL_SOURCE0_RGB
+#define GL_SRC1_RGB GL_SOURCE1_RGB
+#define GL_SRC2_RGB GL_SOURCE2_RGB
+#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA
+#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA
+#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA
+#endif
+
+#ifndef GL_VERSION_2_0
+#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
+#define GL_CURRENT_VERTEX_ATTRIB 0x8626
+#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
+#define GL_STENCIL_BACK_FUNC 0x8800
+#define GL_STENCIL_BACK_FAIL 0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
+#define GL_MAX_DRAW_BUFFERS 0x8824
+#define GL_DRAW_BUFFER0 0x8825
+#define GL_DRAW_BUFFER1 0x8826
+#define GL_DRAW_BUFFER2 0x8827
+#define GL_DRAW_BUFFER3 0x8828
+#define GL_DRAW_BUFFER4 0x8829
+#define GL_DRAW_BUFFER5 0x882A
+#define GL_DRAW_BUFFER6 0x882B
+#define GL_DRAW_BUFFER7 0x882C
+#define GL_DRAW_BUFFER8 0x882D
+#define GL_DRAW_BUFFER9 0x882E
+#define GL_DRAW_BUFFER10 0x882F
+#define GL_DRAW_BUFFER11 0x8830
+#define GL_DRAW_BUFFER12 0x8831
+#define GL_DRAW_BUFFER13 0x8832
+#define GL_DRAW_BUFFER14 0x8833
+#define GL_DRAW_BUFFER15 0x8834
+#define GL_BLEND_EQUATION_ALPHA 0x883D
+#define GL_POINT_SPRITE 0x8861
+#define GL_COORD_REPLACE 0x8862
+#define GL_MAX_VERTEX_ATTRIBS 0x8869
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
+#define GL_MAX_TEXTURE_COORDS 0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
+#define GL_FRAGMENT_SHADER 0x8B30
+#define GL_VERTEX_SHADER 0x8B31
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
+#define GL_MAX_VARYING_FLOATS 0x8B4B
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
+#define GL_SHADER_TYPE 0x8B4F
+#define GL_FLOAT_VEC2 0x8B50
+#define GL_FLOAT_VEC3 0x8B51
+#define GL_FLOAT_VEC4 0x8B52
+#define GL_INT_VEC2 0x8B53
+#define GL_INT_VEC3 0x8B54
+#define GL_INT_VEC4 0x8B55
+#define GL_BOOL 0x8B56
+#define GL_BOOL_VEC2 0x8B57
+#define GL_BOOL_VEC3 0x8B58
+#define GL_BOOL_VEC4 0x8B59
+#define GL_FLOAT_MAT2 0x8B5A
+#define GL_FLOAT_MAT3 0x8B5B
+#define GL_FLOAT_MAT4 0x8B5C
+#define GL_SAMPLER_1D 0x8B5D
+#define GL_SAMPLER_2D 0x8B5E
+#define GL_SAMPLER_3D 0x8B5F
+#define GL_SAMPLER_CUBE 0x8B60
+#define GL_SAMPLER_1D_SHADOW 0x8B61
+#define GL_SAMPLER_2D_SHADOW 0x8B62
+#define GL_DELETE_STATUS 0x8B80
+#define GL_COMPILE_STATUS 0x8B81
+#define GL_LINK_STATUS 0x8B82
+#define GL_VALIDATE_STATUS 0x8B83
+#define GL_INFO_LOG_LENGTH 0x8B84
+#define GL_ATTACHED_SHADERS 0x8B85
+#define GL_ACTIVE_UNIFORMS 0x8B86
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
+#define GL_SHADER_SOURCE_LENGTH 0x8B88
+#define GL_ACTIVE_ATTRIBUTES 0x8B89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
+#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
+#define GL_CURRENT_PROGRAM 0x8B8D
+#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0
+#define GL_LOWER_LEFT 0x8CA1
+#define GL_UPPER_LEFT 0x8CA2
+#define GL_STENCIL_BACK_REF 0x8CA3
+#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
+#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
+#endif
+
+#ifndef GL_ARB_multitexture
+#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
+#endif
+
+#ifndef GL_ARB_transpose_matrix
+#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
+#endif
+
+#ifndef GL_ARB_multisample
+#define GL_MULTISAMPLE_ARB 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_SAMPLE_BUFFERS_ARB 0x80A8
+#define GL_SAMPLES_ARB 0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB
+#define GL_MULTISAMPLE_BIT_ARB 0x20000000
+#endif
+
+#ifndef GL_ARB_texture_env_add
+#endif
+
+#ifndef GL_ARB_texture_cube_map
+#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
+
+#ifndef GL_ARB_texture_compression
+#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
+#endif
+
+#ifndef GL_ARB_texture_border_clamp
+#define GL_CLAMP_TO_BORDER_ARB 0x812D
+#endif
+
+#ifndef GL_ARB_point_parameters
+#define GL_POINT_SIZE_MIN_ARB 0x8126
+#define GL_POINT_SIZE_MAX_ARB 0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128
+#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129
+#endif
+
+#ifndef GL_ARB_vertex_blend
+#define GL_MAX_VERTEX_UNITS_ARB 0x86A4
+#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5
+#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6
+#define GL_VERTEX_BLEND_ARB 0x86A7
+#define GL_CURRENT_WEIGHT_ARB 0x86A8
+#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9
+#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA
+#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB
+#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC
+#define GL_WEIGHT_ARRAY_ARB 0x86AD
+#define GL_MODELVIEW0_ARB 0x1700
+#define GL_MODELVIEW1_ARB 0x850A
+#define GL_MODELVIEW2_ARB 0x8722
+#define GL_MODELVIEW3_ARB 0x8723
+#define GL_MODELVIEW4_ARB 0x8724
+#define GL_MODELVIEW5_ARB 0x8725
+#define GL_MODELVIEW6_ARB 0x8726
+#define GL_MODELVIEW7_ARB 0x8727
+#define GL_MODELVIEW8_ARB 0x8728
+#define GL_MODELVIEW9_ARB 0x8729
+#define GL_MODELVIEW10_ARB 0x872A
+#define GL_MODELVIEW11_ARB 0x872B
+#define GL_MODELVIEW12_ARB 0x872C
+#define GL_MODELVIEW13_ARB 0x872D
+#define GL_MODELVIEW14_ARB 0x872E
+#define GL_MODELVIEW15_ARB 0x872F
+#define GL_MODELVIEW16_ARB 0x8730
+#define GL_MODELVIEW17_ARB 0x8731
+#define GL_MODELVIEW18_ARB 0x8732
+#define GL_MODELVIEW19_ARB 0x8733
+#define GL_MODELVIEW20_ARB 0x8734
+#define GL_MODELVIEW21_ARB 0x8735
+#define GL_MODELVIEW22_ARB 0x8736
+#define GL_MODELVIEW23_ARB 0x8737
+#define GL_MODELVIEW24_ARB 0x8738
+#define GL_MODELVIEW25_ARB 0x8739
+#define GL_MODELVIEW26_ARB 0x873A
+#define GL_MODELVIEW27_ARB 0x873B
+#define GL_MODELVIEW28_ARB 0x873C
+#define GL_MODELVIEW29_ARB 0x873D
+#define GL_MODELVIEW30_ARB 0x873E
+#define GL_MODELVIEW31_ARB 0x873F
+#endif
+
+#ifndef GL_ARB_matrix_palette
+#define GL_MATRIX_PALETTE_ARB 0x8840
+#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841
+#define GL_MAX_PALETTE_MATRICES_ARB 0x8842
+#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843
+#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844
+#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845
+#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846
+#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847
+#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848
+#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849
+#endif
+
+#ifndef GL_ARB_texture_env_combine
+#define GL_COMBINE_ARB 0x8570
+#define GL_COMBINE_RGB_ARB 0x8571
+#define GL_COMBINE_ALPHA_ARB 0x8572
+#define GL_SOURCE0_RGB_ARB 0x8580
+#define GL_SOURCE1_RGB_ARB 0x8581
+#define GL_SOURCE2_RGB_ARB 0x8582
+#define GL_SOURCE0_ALPHA_ARB 0x8588
+#define GL_SOURCE1_ALPHA_ARB 0x8589
+#define GL_SOURCE2_ALPHA_ARB 0x858A
+#define GL_OPERAND0_RGB_ARB 0x8590
+#define GL_OPERAND1_RGB_ARB 0x8591
+#define GL_OPERAND2_RGB_ARB 0x8592
+#define GL_OPERAND0_ALPHA_ARB 0x8598
+#define GL_OPERAND1_ALPHA_ARB 0x8599
+#define GL_OPERAND2_ALPHA_ARB 0x859A
+#define GL_RGB_SCALE_ARB 0x8573
+#define GL_ADD_SIGNED_ARB 0x8574
+#define GL_INTERPOLATE_ARB 0x8575
+#define GL_SUBTRACT_ARB 0x84E7
+#define GL_CONSTANT_ARB 0x8576
+#define GL_PRIMARY_COLOR_ARB 0x8577
+#define GL_PREVIOUS_ARB 0x8578
+#endif
+
+#ifndef GL_ARB_texture_env_crossbar
+#endif
+
+#ifndef GL_ARB_texture_env_dot3
+#define GL_DOT3_RGB_ARB 0x86AE
+#define GL_DOT3_RGBA_ARB 0x86AF
+#endif
+
+#ifndef GL_ARB_texture_mirrored_repeat
+#define GL_MIRRORED_REPEAT_ARB 0x8370
+#endif
+
+#ifndef GL_ARB_depth_texture
+#define GL_DEPTH_COMPONENT16_ARB 0x81A5
+#define GL_DEPTH_COMPONENT24_ARB 0x81A6
+#define GL_DEPTH_COMPONENT32_ARB 0x81A7
+#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A
+#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B
+#endif
+
+#ifndef GL_ARB_shadow
+#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C
+#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D
+#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E
+#endif
+
+#ifndef GL_ARB_shadow_ambient
+#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF
+#endif
+
+#ifndef GL_ARB_window_pos
+#endif
+
+#ifndef GL_ARB_vertex_program
+#define GL_COLOR_SUM_ARB 0x8458
+#define GL_VERTEX_PROGRAM_ARB 0x8620
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625
+#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626
+#define GL_PROGRAM_LENGTH_ARB 0x8627
+#define GL_PROGRAM_STRING_ARB 0x8628
+#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E
+#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F
+#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640
+#define GL_CURRENT_MATRIX_ARB 0x8641
+#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645
+#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B
+#define GL_PROGRAM_BINDING_ARB 0x8677
+#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A
+#define GL_PROGRAM_ERROR_STRING_ARB 0x8874
+#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875
+#define GL_PROGRAM_FORMAT_ARB 0x8876
+#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0
+#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1
+#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2
+#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3
+#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4
+#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5
+#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6
+#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7
+#define GL_PROGRAM_PARAMETERS_ARB 0x88A8
+#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9
+#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA
+#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB
+#define GL_PROGRAM_ATTRIBS_ARB 0x88AC
+#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD
+#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE
+#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF
+#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0
+#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1
+#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2
+#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3
+#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4
+#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5
+#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6
+#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7
+#define GL_MATRIX0_ARB 0x88C0
+#define GL_MATRIX1_ARB 0x88C1
+#define GL_MATRIX2_ARB 0x88C2
+#define GL_MATRIX3_ARB 0x88C3
+#define GL_MATRIX4_ARB 0x88C4
+#define GL_MATRIX5_ARB 0x88C5
+#define GL_MATRIX6_ARB 0x88C6
+#define GL_MATRIX7_ARB 0x88C7
+#define GL_MATRIX8_ARB 0x88C8
+#define GL_MATRIX9_ARB 0x88C9
+#define GL_MATRIX10_ARB 0x88CA
+#define GL_MATRIX11_ARB 0x88CB
+#define GL_MATRIX12_ARB 0x88CC
+#define GL_MATRIX13_ARB 0x88CD
+#define GL_MATRIX14_ARB 0x88CE
+#define GL_MATRIX15_ARB 0x88CF
+#define GL_MATRIX16_ARB 0x88D0
+#define GL_MATRIX17_ARB 0x88D1
+#define GL_MATRIX18_ARB 0x88D2
+#define GL_MATRIX19_ARB 0x88D3
+#define GL_MATRIX20_ARB 0x88D4
+#define GL_MATRIX21_ARB 0x88D5
+#define GL_MATRIX22_ARB 0x88D6
+#define GL_MATRIX23_ARB 0x88D7
+#define GL_MATRIX24_ARB 0x88D8
+#define GL_MATRIX25_ARB 0x88D9
+#define GL_MATRIX26_ARB 0x88DA
+#define GL_MATRIX27_ARB 0x88DB
+#define GL_MATRIX28_ARB 0x88DC
+#define GL_MATRIX29_ARB 0x88DD
+#define GL_MATRIX30_ARB 0x88DE
+#define GL_MATRIX31_ARB 0x88DF
+#endif
+
+#ifndef GL_ARB_fragment_program
+#define GL_FRAGMENT_PROGRAM_ARB 0x8804
+#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805
+#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806
+#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807
+#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808
+#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809
+#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A
+#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B
+#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C
+#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D
+#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E
+#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F
+#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810
+#define GL_MAX_TEXTURE_COORDS_ARB 0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872
+#endif
+
+#ifndef GL_ARB_vertex_buffer_object
+#define GL_BUFFER_SIZE_ARB 0x8764
+#define GL_BUFFER_USAGE_ARB 0x8765
+#define GL_ARRAY_BUFFER_ARB 0x8892
+#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893
+#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895
+#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896
+#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897
+#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898
+#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899
+#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A
+#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B
+#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C
+#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D
+#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F
+#define GL_READ_ONLY_ARB 0x88B8
+#define GL_WRITE_ONLY_ARB 0x88B9
+#define GL_READ_WRITE_ARB 0x88BA
+#define GL_BUFFER_ACCESS_ARB 0x88BB
+#define GL_BUFFER_MAPPED_ARB 0x88BC
+#define GL_BUFFER_MAP_POINTER_ARB 0x88BD
+#define GL_STREAM_DRAW_ARB 0x88E0
+#define GL_STREAM_READ_ARB 0x88E1
+#define GL_STREAM_COPY_ARB 0x88E2
+#define GL_STATIC_DRAW_ARB 0x88E4
+#define GL_STATIC_READ_ARB 0x88E5
+#define GL_STATIC_COPY_ARB 0x88E6
+#define GL_DYNAMIC_DRAW_ARB 0x88E8
+#define GL_DYNAMIC_READ_ARB 0x88E9
+#define GL_DYNAMIC_COPY_ARB 0x88EA
+#endif
+
+#ifndef GL_ARB_occlusion_query
+#define GL_QUERY_COUNTER_BITS_ARB 0x8864
+#define GL_CURRENT_QUERY_ARB 0x8865
+#define GL_QUERY_RESULT_ARB 0x8866
+#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867
+#define GL_SAMPLES_PASSED_ARB 0x8914
+#endif
+
+#ifndef GL_ARB_shader_objects
+#define GL_PROGRAM_OBJECT_ARB 0x8B40
+#define GL_SHADER_OBJECT_ARB 0x8B48
+#define GL_OBJECT_TYPE_ARB 0x8B4E
+#define GL_OBJECT_SUBTYPE_ARB 0x8B4F
+#define GL_FLOAT_VEC2_ARB 0x8B50
+#define GL_FLOAT_VEC3_ARB 0x8B51
+#define GL_FLOAT_VEC4_ARB 0x8B52
+#define GL_INT_VEC2_ARB 0x8B53
+#define GL_INT_VEC3_ARB 0x8B54
+#define GL_INT_VEC4_ARB 0x8B55
+#define GL_BOOL_ARB 0x8B56
+#define GL_BOOL_VEC2_ARB 0x8B57
+#define GL_BOOL_VEC3_ARB 0x8B58
+#define GL_BOOL_VEC4_ARB 0x8B59
+#define GL_FLOAT_MAT2_ARB 0x8B5A
+#define GL_FLOAT_MAT3_ARB 0x8B5B
+#define GL_FLOAT_MAT4_ARB 0x8B5C
+#define GL_SAMPLER_1D_ARB 0x8B5D
+#define GL_SAMPLER_2D_ARB 0x8B5E
+#define GL_SAMPLER_3D_ARB 0x8B5F
+#define GL_SAMPLER_CUBE_ARB 0x8B60
+#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61
+#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62
+#define GL_SAMPLER_2D_RECT_ARB 0x8B63
+#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64
+#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80
+#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81
+#define GL_OBJECT_LINK_STATUS_ARB 0x8B82
+#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83
+#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84
+#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85
+#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86
+#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87
+#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88
+#endif
+
+#ifndef GL_ARB_vertex_shader
+#define GL_VERTEX_SHADER_ARB 0x8B31
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A
+#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D
+#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89
+#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A
+#endif
+
+#ifndef GL_ARB_fragment_shader
+#define GL_FRAGMENT_SHADER_ARB 0x8B30
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B
+#endif
+
+#ifndef GL_ARB_shading_language_100
+#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C
+#endif
+
+#ifndef GL_ARB_texture_non_power_of_two
+#endif
+
+#ifndef GL_ARB_point_sprite
+#define GL_POINT_SPRITE_ARB 0x8861
+#define GL_COORD_REPLACE_ARB 0x8862
+#endif
+
+#ifndef GL_ARB_fragment_program_shadow
+#endif
+
+#ifndef GL_ARB_draw_buffers
+#define GL_MAX_DRAW_BUFFERS_ARB 0x8824
+#define GL_DRAW_BUFFER0_ARB 0x8825
+#define GL_DRAW_BUFFER1_ARB 0x8826
+#define GL_DRAW_BUFFER2_ARB 0x8827
+#define GL_DRAW_BUFFER3_ARB 0x8828
+#define GL_DRAW_BUFFER4_ARB 0x8829
+#define GL_DRAW_BUFFER5_ARB 0x882A
+#define GL_DRAW_BUFFER6_ARB 0x882B
+#define GL_DRAW_BUFFER7_ARB 0x882C
+#define GL_DRAW_BUFFER8_ARB 0x882D
+#define GL_DRAW_BUFFER9_ARB 0x882E
+#define GL_DRAW_BUFFER10_ARB 0x882F
+#define GL_DRAW_BUFFER11_ARB 0x8830
+#define GL_DRAW_BUFFER12_ARB 0x8831
+#define GL_DRAW_BUFFER13_ARB 0x8832
+#define GL_DRAW_BUFFER14_ARB 0x8833
+#define GL_DRAW_BUFFER15_ARB 0x8834
+#endif
+
+#ifndef GL_ARB_texture_rectangle
+#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
+#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6
+#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8
+#endif
+
+#ifndef GL_ARB_color_buffer_float
+#define GL_RGBA_FLOAT_MODE_ARB 0x8820
+#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A
+#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B
+#define GL_CLAMP_READ_COLOR_ARB 0x891C
+#define GL_FIXED_ONLY_ARB 0x891D
+#endif
+
+#ifndef GL_ARB_half_float_pixel
+#define GL_HALF_FLOAT_ARB 0x140B
+#endif
+
+#ifndef GL_ARB_texture_float
+#define GL_TEXTURE_RED_TYPE_ARB 0x8C10
+#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11
+#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12
+#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13
+#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14
+#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15
+#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16
+#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17
+#define GL_RGBA32F_ARB 0x8814
+#define GL_RGB32F_ARB 0x8815
+#define GL_ALPHA32F_ARB 0x8816
+#define GL_INTENSITY32F_ARB 0x8817
+#define GL_LUMINANCE32F_ARB 0x8818
+#define GL_LUMINANCE_ALPHA32F_ARB 0x8819
+#define GL_RGBA16F_ARB 0x881A
+#define GL_RGB16F_ARB 0x881B
+#define GL_ALPHA16F_ARB 0x881C
+#define GL_INTENSITY16F_ARB 0x881D
+#define GL_LUMINANCE16F_ARB 0x881E
+#define GL_LUMINANCE_ALPHA16F_ARB 0x881F
+#endif
+
+#ifndef GL_ARB_pixel_buffer_object
+#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB
+#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF
+#endif
+
+#ifndef GL_EXT_abgr
+#define GL_ABGR_EXT 0x8000
+#endif
+
+#ifndef GL_EXT_blend_color
+#define GL_CONSTANT_COLOR_EXT 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002
+#define GL_CONSTANT_ALPHA_EXT 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004
+#define GL_BLEND_COLOR_EXT 0x8005
+#endif
+
+#ifndef GL_EXT_polygon_offset
+#define GL_POLYGON_OFFSET_EXT 0x8037
+#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038
+#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039
+#endif
+
+#ifndef GL_EXT_texture
+#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
+#define GL_TEXTURE_TOO_LARGE_EXT 0x8065
+#endif
+
+#ifndef GL_EXT_texture3D
+#define GL_PACK_SKIP_IMAGES_EXT 0x806B
+#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C
+#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D
+#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E
+#define GL_TEXTURE_3D_EXT 0x806F
+#define GL_PROXY_TEXTURE_3D_EXT 0x8070
+#define GL_TEXTURE_DEPTH_EXT 0x8071
+#define GL_TEXTURE_WRAP_R_EXT 0x8072
+#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073
+#endif
+
+#ifndef GL_SGIS_texture_filter4
+#define GL_FILTER4_SGIS 0x8146
+#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147
+#endif
+
+#ifndef GL_EXT_subtexture
+#endif
+
+#ifndef GL_EXT_copy_texture
+#endif
+
+#ifndef GL_EXT_histogram
+#define GL_HISTOGRAM_EXT 0x8024
+#define GL_PROXY_HISTOGRAM_EXT 0x8025
+#define GL_HISTOGRAM_WIDTH_EXT 0x8026
+#define GL_HISTOGRAM_FORMAT_EXT 0x8027
+#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028
+#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029
+#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A
+#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B
+#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C
+#define GL_HISTOGRAM_SINK_EXT 0x802D
+#define GL_MINMAX_EXT 0x802E
+#define GL_MINMAX_FORMAT_EXT 0x802F
+#define GL_MINMAX_SINK_EXT 0x8030
+#define GL_TABLE_TOO_LARGE_EXT 0x8031
+#endif
+
+#ifndef GL_EXT_convolution
+#define GL_CONVOLUTION_1D_EXT 0x8010
+#define GL_CONVOLUTION_2D_EXT 0x8011
+#define GL_SEPARABLE_2D_EXT 0x8012
+#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013
+#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014
+#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015
+#define GL_REDUCE_EXT 0x8016
+#define GL_CONVOLUTION_FORMAT_EXT 0x8017
+#define GL_CONVOLUTION_WIDTH_EXT 0x8018
+#define GL_CONVOLUTION_HEIGHT_EXT 0x8019
+#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A
+#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B
+#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C
+#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D
+#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E
+#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F
+#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020
+#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021
+#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022
+#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023
+#endif
+
+#ifndef GL_SGI_color_matrix
+#define GL_COLOR_MATRIX_SGI 0x80B1
+#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2
+#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3
+#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4
+#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5
+#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6
+#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7
+#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8
+#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9
+#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA
+#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB
+#endif
+
+#ifndef GL_SGI_color_table
+#define GL_COLOR_TABLE_SGI 0x80D0
+#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
+#endif
+
+#ifndef GL_SGIS_pixel_texture
+#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
+#endif
+
+#ifndef GL_SGIX_pixel_texture
+#define GL_PIXEL_TEX_GEN_SGIX 0x8139
+#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B
+#endif
+
+#ifndef GL_SGIS_texture4D
+#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
+#endif
+
+#ifndef GL_SGI_texture_color_table
+#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC
+#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD
+#endif
+
+#ifndef GL_EXT_cmyka
+#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
+
+#ifndef GL_EXT_texture_object
+#define GL_TEXTURE_PRIORITY_EXT 0x8066
+#define GL_TEXTURE_RESIDENT_EXT 0x8067
+#define GL_TEXTURE_1D_BINDING_EXT 0x8068
+#define GL_TEXTURE_2D_BINDING_EXT 0x8069
+#define GL_TEXTURE_3D_BINDING_EXT 0x806A
+#endif
+
+#ifndef GL_SGIS_detail_texture
+#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095
+#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096
+#define GL_LINEAR_DETAIL_SGIS 0x8097
+#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098
+#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099
+#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A
+#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B
+#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C
+#endif
+
+#ifndef GL_SGIS_sharpen_texture
+#define GL_LINEAR_SHARPEN_SGIS 0x80AD
+#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE
+#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF
+#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0
+#endif
+
+#ifndef GL_EXT_packed_pixels
+#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032
+#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034
+#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035
+#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036
+#endif
+
+#ifndef GL_SGIS_texture_lod
+#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
+
+#ifndef GL_SGIS_multisample
+#define GL_MULTISAMPLE_SGIS 0x809D
+#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F
+#define GL_SAMPLE_MASK_SGIS 0x80A0
+#define GL_1PASS_SGIS 0x80A1
+#define GL_2PASS_0_SGIS 0x80A2
+#define GL_2PASS_1_SGIS 0x80A3
+#define GL_4PASS_0_SGIS 0x80A4
+#define GL_4PASS_1_SGIS 0x80A5
+#define GL_4PASS_2_SGIS 0x80A6
+#define GL_4PASS_3_SGIS 0x80A7
+#define GL_SAMPLE_BUFFERS_SGIS 0x80A8
+#define GL_SAMPLES_SGIS 0x80A9
+#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA
+#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB
+#define GL_SAMPLE_PATTERN_SGIS 0x80AC
+#endif
+
+#ifndef GL_EXT_rescale_normal
+#define GL_RESCALE_NORMAL_EXT 0x803A
+#endif
+
+#ifndef GL_EXT_vertex_array
+#define GL_VERTEX_ARRAY_EXT 0x8074
+#define GL_NORMAL_ARRAY_EXT 0x8075
+#define GL_COLOR_ARRAY_EXT 0x8076
+#define GL_INDEX_ARRAY_EXT 0x8077
+#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078
+#define GL_EDGE_FLAG_ARRAY_EXT 0x8079
+#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A
+#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B
+#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C
+#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D
+#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E
+#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F
+#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080
+#define GL_COLOR_ARRAY_SIZE_EXT 0x8081
+#define GL_COLOR_ARRAY_TYPE_EXT 0x8082
+#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083
+#define GL_COLOR_ARRAY_COUNT_EXT 0x8084
+#define GL_INDEX_ARRAY_TYPE_EXT 0x8085
+#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086
+#define GL_INDEX_ARRAY_COUNT_EXT 0x8087
+#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088
+#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089
+#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A
+#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B
+#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C
+#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D
+#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E
+#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F
+#define GL_COLOR_ARRAY_POINTER_EXT 0x8090
+#define GL_INDEX_ARRAY_POINTER_EXT 0x8091
+#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092
+#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093
+#endif
+
+#ifndef GL_EXT_misc_attribute
+#endif
+
+#ifndef GL_SGIS_generate_mipmap
+#define GL_GENERATE_MIPMAP_SGIS 0x8191
+#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192
+#endif
+
+#ifndef GL_SGIX_clipmap
+#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
+#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D
+#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E
+#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F
+#endif
+
+#ifndef GL_SGIX_shadow
+#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
+
+#ifndef GL_SGIS_texture_edge_clamp
+#define GL_CLAMP_TO_EDGE_SGIS 0x812F
+#endif
+
+#ifndef GL_SGIS_texture_border_clamp
+#define GL_CLAMP_TO_BORDER_SGIS 0x812D
+#endif
+
+#ifndef GL_EXT_blend_minmax
+#define GL_FUNC_ADD_EXT 0x8006
+#define GL_MIN_EXT 0x8007
+#define GL_MAX_EXT 0x8008
+#define GL_BLEND_EQUATION_EXT 0x8009
+#endif
+
+#ifndef GL_EXT_blend_subtract
+#define GL_FUNC_SUBTRACT_EXT 0x800A
+#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B
+#endif
+
+#ifndef GL_EXT_blend_logic_op
+#endif
+
+#ifndef GL_SGIX_interlace
+#define GL_INTERLACE_SGIX 0x8094
+#endif
+
+#ifndef GL_SGIX_pixel_tiles
+#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E
+#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F
+#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140
+#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141
+#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142
+#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143
+#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144
+#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145
+#endif
+
+#ifndef GL_SGIS_texture_select
+#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_QUAD_ALPHA4_SGIS 0x811E
+#define GL_QUAD_ALPHA8_SGIS 0x811F
+#define GL_QUAD_LUMINANCE4_SGIS 0x8120
+#define GL_QUAD_LUMINANCE8_SGIS 0x8121
+#define GL_QUAD_INTENSITY4_SGIS 0x8122
+#define GL_QUAD_INTENSITY8_SGIS 0x8123
+#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124
+#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125
+#endif
+
+#ifndef GL_SGIX_sprite
+#define GL_SPRITE_SGIX 0x8148
+#define GL_SPRITE_MODE_SGIX 0x8149
+#define GL_SPRITE_AXIS_SGIX 0x814A
+#define GL_SPRITE_TRANSLATION_SGIX 0x814B
+#define GL_SPRITE_AXIAL_SGIX 0x814C
+#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D
+#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E
+#endif
+
+#ifndef GL_SGIX_texture_multi_buffer
+#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E
+#endif
+
+#ifndef GL_EXT_point_parameters
+#define GL_POINT_SIZE_MIN_EXT 0x8126
+#define GL_POINT_SIZE_MAX_EXT 0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128
+#define GL_DISTANCE_ATTENUATION_EXT 0x8129
+#endif
+
+#ifndef GL_SGIS_point_parameters
+#define GL_POINT_SIZE_MIN_SGIS 0x8126
+#define GL_POINT_SIZE_MAX_SGIS 0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128
+#define GL_DISTANCE_ATTENUATION_SGIS 0x8129
+#endif
+
+#ifndef GL_SGIX_instruments
+#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180
+#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181
+#endif
+
+#ifndef GL_SGIX_texture_scale_bias
+#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
+
+#ifndef GL_SGIX_framezoom
+#define GL_FRAMEZOOM_SGIX 0x818B
+#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C
+#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D
+#endif
+
+#ifndef GL_SGIX_tag_sample_buffer
+#endif
+
+#ifndef GL_FfdMaskSGIX
+#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001
+#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002
+#endif
+
+#ifndef GL_SGIX_polynomial_ffd
+#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194
+#define GL_TEXTURE_DEFORMATION_SGIX 0x8195
+#define GL_DEFORMATIONS_MASK_SGIX 0x8196
+#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197
+#endif
+
+#ifndef GL_SGIX_reference_plane
+#define GL_REFERENCE_PLANE_SGIX 0x817D
+#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E
+#endif
+
+#ifndef GL_SGIX_flush_raster
+#endif
+
+#ifndef GL_SGIX_depth_texture
+#define GL_DEPTH_COMPONENT16_SGIX 0x81A5
+#define GL_DEPTH_COMPONENT24_SGIX 0x81A6
+#define GL_DEPTH_COMPONENT32_SGIX 0x81A7
+#endif
+
+#ifndef GL_SGIS_fog_function
+#define GL_FOG_FUNC_SGIS 0x812A
+#define GL_FOG_FUNC_POINTS_SGIS 0x812B
+#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C
+#endif
+
+#ifndef GL_SGIX_fog_offset
+#define GL_FOG_OFFSET_SGIX 0x8198
+#define GL_FOG_OFFSET_VALUE_SGIX 0x8199
+#endif
+
+#ifndef GL_HP_image_transform
+#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
+#endif
+
+#ifndef GL_HP_convolution_border_modes
+#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
+
+#ifndef GL_INGR_palette_buffer
+#endif
+
+#ifndef GL_SGIX_texture_add_env
+#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE
+#endif
+
+#ifndef GL_EXT_color_subtable
+#endif
+
+#ifndef GL_PGI_vertex_hints
+#define GL_VERTEX_DATA_HINT_PGI 0x1A22A
+#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B
+#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C
+#define GL_MAX_VERTEX_HINT_PGI 0x1A22D
+#define GL_COLOR3_BIT_PGI 0x00010000
+#define GL_COLOR4_BIT_PGI 0x00020000
+#define GL_EDGEFLAG_BIT_PGI 0x00040000
+#define GL_INDEX_BIT_PGI 0x00080000
+#define GL_MAT_AMBIENT_BIT_PGI 0x00100000
+#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000
+#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000
+#define GL_MAT_EMISSION_BIT_PGI 0x00800000
+#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000
+#define GL_MAT_SHININESS_BIT_PGI 0x02000000
+#define GL_MAT_SPECULAR_BIT_PGI 0x04000000
+#define GL_NORMAL_BIT_PGI 0x08000000
+#define GL_TEXCOORD1_BIT_PGI 0x10000000
+#define GL_TEXCOORD2_BIT_PGI 0x20000000
+#define GL_TEXCOORD3_BIT_PGI 0x40000000
+#define GL_TEXCOORD4_BIT_PGI 0x80000000
+#define GL_VERTEX23_BIT_PGI 0x00000004
+#define GL_VERTEX4_BIT_PGI 0x00000008
+#endif
+
+#ifndef GL_PGI_misc_hints
+#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8
+#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD
+#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE
+#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202
+#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203
+#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204
+#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C
+#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D
+#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E
+#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F
+#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210
+#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211
+#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216
+#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217
+#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218
+#define GL_FULL_STIPPLE_HINT_PGI 0x1A219
+#define GL_CLIP_NEAR_HINT_PGI 0x1A220
+#define GL_CLIP_FAR_HINT_PGI 0x1A221
+#define GL_WIDE_LINE_HINT_PGI 0x1A222
+#define GL_BACK_NORMALS_HINT_PGI 0x1A223
+#endif
+
+#ifndef GL_EXT_paletted_texture
+#define GL_COLOR_INDEX1_EXT 0x80E2
+#define GL_COLOR_INDEX2_EXT 0x80E3
+#define GL_COLOR_INDEX4_EXT 0x80E4
+#define GL_COLOR_INDEX8_EXT 0x80E5
+#define GL_COLOR_INDEX12_EXT 0x80E6
+#define GL_COLOR_INDEX16_EXT 0x80E7
+#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED
+#endif
+
+#ifndef GL_EXT_clip_volume_hint
+#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0
+#endif
+
+#ifndef GL_SGIX_list_priority
+#define GL_LIST_PRIORITY_SGIX 0x8182
+#endif
+
+#ifndef GL_SGIX_ir_instrument1
+#define GL_IR_INSTRUMENT1_SGIX 0x817F
+#endif
+
+#ifndef GL_SGIX_calligraphic_fragment
+#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183
+#endif
+
+#ifndef GL_SGIX_texture_lod_bias
+#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
+
+#ifndef GL_SGIX_shadow_ambient
+#define GL_SHADOW_AMBIENT_SGIX 0x80BF
+#endif
+
+#ifndef GL_EXT_index_texture
+#endif
+
+#ifndef GL_EXT_index_material
+#define GL_INDEX_MATERIAL_EXT 0x81B8
+#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9
+#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA
+#endif
+
+#ifndef GL_EXT_index_func
+#define GL_INDEX_TEST_EXT 0x81B5
+#define GL_INDEX_TEST_FUNC_EXT 0x81B6
+#define GL_INDEX_TEST_REF_EXT 0x81B7
+#endif
+
+#ifndef GL_EXT_index_array_formats
+#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
+
+#ifndef GL_EXT_compiled_vertex_array
+#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8
+#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9
+#endif
+
+#ifndef GL_EXT_cull_vertex
+#define GL_CULL_VERTEX_EXT 0x81AA
+#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB
+#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC
+#endif
+
+#ifndef GL_SGIX_ycrcb
+#define GL_YCRCB_422_SGIX 0x81BB
+#define GL_YCRCB_444_SGIX 0x81BC
+#endif
+
+#ifndef GL_SGIX_fragment_lighting
+#define GL_FRAGMENT_LIGHTING_SGIX 0x8400
+#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401
+#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402
+#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403
+#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404
+#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405
+#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406
+#define GL_LIGHT_ENV_MODE_SGIX 0x8407
+#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408
+#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409
+#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A
+#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B
+#define GL_FRAGMENT_LIGHT0_SGIX 0x840C
+#define GL_FRAGMENT_LIGHT1_SGIX 0x840D
+#define GL_FRAGMENT_LIGHT2_SGIX 0x840E
+#define GL_FRAGMENT_LIGHT3_SGIX 0x840F
+#define GL_FRAGMENT_LIGHT4_SGIX 0x8410
+#define GL_FRAGMENT_LIGHT5_SGIX 0x8411
+#define GL_FRAGMENT_LIGHT6_SGIX 0x8412
+#define GL_FRAGMENT_LIGHT7_SGIX 0x8413
+#endif
+
+#ifndef GL_IBM_rasterpos_clip
+#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262
+#endif
+
+#ifndef GL_HP_texture_lighting
+#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167
+#define GL_TEXTURE_POST_SPECULAR_HP 0x8168
+#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169
+#endif
+
+#ifndef GL_EXT_draw_range_elements
+#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8
+#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9
+#endif
+
+#ifndef GL_WIN_phong_shading
+#define GL_PHONG_WIN 0x80EA
+#define GL_PHONG_HINT_WIN 0x80EB
+#endif
+
+#ifndef GL_WIN_specular_fog
+#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC
+#endif
+
+#ifndef GL_EXT_light_texture
+#define GL_FRAGMENT_MATERIAL_EXT 0x8349
+#define GL_FRAGMENT_NORMAL_EXT 0x834A
+#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
+/* reuse GL_FRAGMENT_DEPTH_EXT */
+#endif
+
+#ifndef GL_SGIX_blend_alpha_minmax
+#define GL_ALPHA_MIN_SGIX 0x8320
+#define GL_ALPHA_MAX_SGIX 0x8321
+#endif
+
+#ifndef GL_SGIX_impact_pixel_texture
+#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184
+#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185
+#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186
+#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187
+#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188
+#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189
+#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A
+#endif
+
+#ifndef GL_EXT_bgra
+#define GL_BGR_EXT 0x80E0
+#define GL_BGRA_EXT 0x80E1
+#endif
+
+#ifndef GL_SGIX_async
+#define GL_ASYNC_MARKER_SGIX 0x8329
+#endif
+
+#ifndef GL_SGIX_async_pixel
+#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C
+#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D
+#define GL_ASYNC_READ_PIXELS_SGIX 0x835E
+#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F
+#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360
+#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361
+#endif
+
+#ifndef GL_SGIX_async_histogram
+#define GL_ASYNC_HISTOGRAM_SGIX 0x832C
+#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D
+#endif
+
+#ifndef GL_INTEL_texture_scissor
+#endif
+
+#ifndef GL_INTEL_parallel_arrays
+#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
+#endif
+
+#ifndef GL_HP_occlusion_test
+#define GL_OCCLUSION_TEST_HP 0x8165
+#define GL_OCCLUSION_TEST_RESULT_HP 0x8166
+#endif
+
+#ifndef GL_EXT_pixel_transform
+#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330
+#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_STACK_DEPTH_EXT 0x8336
+#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337
+#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338
+#endif
+
+#ifndef GL_EXT_pixel_transform_color_table
+#endif
+
+#ifndef GL_EXT_shared_texture_palette
+#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
+#endif
+
+#ifndef GL_EXT_separate_specular_color
+#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8
+#define GL_SINGLE_COLOR_EXT 0x81F9
+#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA
+#endif
+
+#ifndef GL_EXT_secondary_color
+#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
+#endif
+
+#ifndef GL_EXT_texture_perturb_normal
+#define GL_PERTURB_EXT 0x85AE
+#define GL_TEXTURE_NORMAL_EXT 0x85AF
+#endif
+
+#ifndef GL_EXT_multi_draw_arrays
+#endif
+
+#ifndef GL_EXT_fog_coord
+#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450
+#define GL_FOG_COORDINATE_EXT 0x8451
+#define GL_FRAGMENT_DEPTH_EXT 0x8452
+#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453
+#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454
+#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455
+#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456
+#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457
+#endif
+
+#ifndef GL_REND_screen_coordinates
+#define GL_SCREEN_COORDINATES_REND 0x8490
+#define GL_INVERTED_SCREEN_W_REND 0x8491
+#endif
+
+#ifndef GL_EXT_coordinate_frame
+#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
+#endif
+
+#ifndef GL_EXT_texture_env_combine
+#define GL_COMBINE_EXT 0x8570
+#define GL_COMBINE_RGB_EXT 0x8571
+#define GL_COMBINE_ALPHA_EXT 0x8572
+#define GL_RGB_SCALE_EXT 0x8573
+#define GL_ADD_SIGNED_EXT 0x8574
+#define GL_INTERPOLATE_EXT 0x8575
+#define GL_CONSTANT_EXT 0x8576
+#define GL_PRIMARY_COLOR_EXT 0x8577
+#define GL_PREVIOUS_EXT 0x8578
+#define GL_SOURCE0_RGB_EXT 0x8580
+#define GL_SOURCE1_RGB_EXT 0x8581
+#define GL_SOURCE2_RGB_EXT 0x8582
+#define GL_SOURCE0_ALPHA_EXT 0x8588
+#define GL_SOURCE1_ALPHA_EXT 0x8589
+#define GL_SOURCE2_ALPHA_EXT 0x858A
+#define GL_OPERAND0_RGB_EXT 0x8590
+#define GL_OPERAND1_RGB_EXT 0x8591
+#define GL_OPERAND2_RGB_EXT 0x8592
+#define GL_OPERAND0_ALPHA_EXT 0x8598
+#define GL_OPERAND1_ALPHA_EXT 0x8599
+#define GL_OPERAND2_ALPHA_EXT 0x859A
+#endif
+
+#ifndef GL_APPLE_specular_vector
+#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0
+#endif
+
+#ifndef GL_APPLE_transform_hint
+#define GL_TRANSFORM_HINT_APPLE 0x85B1
+#endif
+
+#ifndef GL_SGIX_fog_scale
+#define GL_FOG_SCALE_SGIX 0x81FC
+#define GL_FOG_SCALE_VALUE_SGIX 0x81FD
+#endif
+
+#ifndef GL_SUNX_constant_data
+#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5
+#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6
+#endif
+
+#ifndef GL_SUN_global_alpha
+#define GL_GLOBAL_ALPHA_SUN 0x81D9
+#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA
+#endif
+
+#ifndef GL_SUN_triangle_list
+#define GL_RESTART_SUN 0x0001
+#define GL_REPLACE_MIDDLE_SUN 0x0002
+#define GL_REPLACE_OLDEST_SUN 0x0003
+#define GL_TRIANGLE_LIST_SUN 0x81D7
+#define GL_REPLACEMENT_CODE_SUN 0x81D8
+#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
+#endif
+
+#ifndef GL_SUN_vertex
+#endif
+
+#ifndef GL_EXT_blend_func_separate
+#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
+#endif
+
+#ifndef GL_INGR_color_clamp
+#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
+
+#ifndef GL_INGR_interlace_read
+#define GL_INTERLACE_READ_INGR 0x8568
+#endif
+
+#ifndef GL_EXT_stencil_wrap
+#define GL_INCR_WRAP_EXT 0x8507
+#define GL_DECR_WRAP_EXT 0x8508
+#endif
+
+#ifndef GL_EXT_422_pixels
+#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
+
+#ifndef GL_NV_texgen_reflection
+#define GL_NORMAL_MAP_NV 0x8511
+#define GL_REFLECTION_MAP_NV 0x8512
+#endif
+
+#ifndef GL_EXT_texture_cube_map
+#define GL_NORMAL_MAP_EXT 0x8511
+#define GL_REFLECTION_MAP_EXT 0x8512
+#define GL_TEXTURE_CUBE_MAP_EXT 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C
+#endif
+
+#ifndef GL_SUN_convolution_border_modes
+#define GL_WRAP_BORDER_SUN 0x81D4
+#endif
+
+#ifndef GL_EXT_texture_env_add
+#endif
+
+#ifndef GL_EXT_texture_lod_bias
+#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD
+#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500
+#define GL_TEXTURE_LOD_BIAS_EXT 0x8501
+#endif
+
+#ifndef GL_EXT_texture_filter_anisotropic
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
+#endif
+
+#ifndef GL_EXT_vertex_weighting
+#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH
+#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502
+#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX
+#define GL_MODELVIEW1_MATRIX_EXT 0x8506
+#define GL_VERTEX_WEIGHTING_EXT 0x8509
+#define GL_MODELVIEW0_EXT GL_MODELVIEW
+#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_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510
+#endif
+
+#ifndef GL_NV_light_max_exponent
+#define GL_MAX_SHININESS_NV 0x8504
+#define GL_MAX_SPOT_EXPONENT_NV 0x8505
+#endif
+
+#ifndef GL_NV_vertex_array_range
+#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
+#endif
+
+#ifndef GL_NV_register_combiners
+#define GL_REGISTER_COMBINERS_NV 0x8522
+#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_DISCARD_NV 0x8530
+#define GL_E_TIMES_F_NV 0x8531
+#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532
+#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_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_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_MAX_GENERAL_COMBINERS_NV 0x854D
+#define GL_NUM_GENERAL_COMBINERS_NV 0x854E
+#define GL_COLOR_SUM_CLAMP_NV 0x854F
+#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
+/* reuse GL_TEXTURE0_ARB */
+/* reuse GL_TEXTURE1_ARB */
+/* reuse GL_ZERO */
+/* reuse GL_NONE */
+/* reuse GL_FOG */
+#endif
+
+#ifndef GL_NV_fog_distance
+#define GL_FOG_DISTANCE_MODE_NV 0x855A
+#define GL_EYE_RADIAL_NV 0x855B
+#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C
+/* reuse GL_EYE_PLANE */
+#endif
+
+#ifndef GL_NV_texgen_emboss
+#define GL_EMBOSS_LIGHT_NV 0x855D
+#define GL_EMBOSS_CONSTANT_NV 0x855E
+#define GL_EMBOSS_MAP_NV 0x855F
+#endif
+
+#ifndef GL_NV_blend_square
+#endif
+
+#ifndef GL_NV_texture_env_combine4
+#define GL_COMBINE4_NV 0x8503
+#define GL_SOURCE3_RGB_NV 0x8583
+#define GL_SOURCE3_ALPHA_NV 0x858B
+#define GL_OPERAND3_RGB_NV 0x8593
+#define GL_OPERAND3_ALPHA_NV 0x859B
+#endif
+
+#ifndef GL_MESA_resize_buffers
+#endif
+
+#ifndef GL_MESA_window_pos
+#endif
+
+#ifndef GL_EXT_texture_compression_s3tc
+#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
+
+#ifndef GL_IBM_cull_vertex
+#define GL_CULL_VERTEX_IBM 103050
+#endif
+
+#ifndef GL_IBM_multimode_draw_arrays
+#endif
+
+#ifndef GL_IBM_vertex_array_lists
+#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
+#endif
+
+#ifndef GL_SGIX_subsample
+#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0
+#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1
+#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2
+#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3
+#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4
+#endif
+
+#ifndef GL_SGIX_ycrcb_subsample
+#endif
+
+#ifndef GL_SGIX_ycrcba
+#define GL_YCRCB_SGIX 0x8318
+#define GL_YCRCBA_SGIX 0x8319
+#endif
+
+#ifndef GL_SGI_depth_pass_instrument
+#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310
+#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311
+#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312
+#endif
+
+#ifndef GL_3DFX_texture_compression_FXT1
+#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0
+#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1
+#endif
+
+#ifndef GL_3DFX_multisample
+#define GL_MULTISAMPLE_3DFX 0x86B2
+#define GL_SAMPLE_BUFFERS_3DFX 0x86B3
+#define GL_SAMPLES_3DFX 0x86B4
+#define GL_MULTISAMPLE_BIT_3DFX 0x20000000
+#endif
+
+#ifndef GL_3DFX_tbuffer
+#endif
+
+#ifndef GL_EXT_multisample
+#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
+#define GL_1PASS_EXT 0x80A1
+#define GL_2PASS_0_EXT 0x80A2
+#define GL_2PASS_1_EXT 0x80A3
+#define GL_4PASS_0_EXT 0x80A4
+#define GL_4PASS_1_EXT 0x80A5
+#define GL_4PASS_2_EXT 0x80A6
+#define GL_4PASS_3_EXT 0x80A7
+#define GL_SAMPLE_BUFFERS_EXT 0x80A8
+#define GL_SAMPLES_EXT 0x80A9
+#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA
+#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB
+#define GL_SAMPLE_PATTERN_EXT 0x80AC
+#define GL_MULTISAMPLE_BIT_EXT 0x20000000
+#endif
+
+#ifndef GL_SGIX_vertex_preclip
+#define GL_VERTEX_PRECLIP_SGIX 0x83EE
+#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF
+#endif
+
+#ifndef GL_SGIX_convolution_accuracy
+#define GL_CONVOLUTION_HINT_SGIX 0x8316
+#endif
+
+#ifndef GL_SGIX_resample
+#define GL_PACK_RESAMPLE_SGIX 0x842C
+#define GL_UNPACK_RESAMPLE_SGIX 0x842D
+#define GL_RESAMPLE_REPLICATE_SGIX 0x842E
+#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F
+#define GL_RESAMPLE_DECIMATE_SGIX 0x8430
+#endif
+
+#ifndef GL_SGIS_point_line_texgen
+#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0
+#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1
+#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2
+#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3
+#define GL_EYE_POINT_SGIS 0x81F4
+#define GL_OBJECT_POINT_SGIS 0x81F5
+#define GL_EYE_LINE_SGIS 0x81F6
+#define GL_OBJECT_LINE_SGIS 0x81F7
+#endif
+
+#ifndef GL_SGIS_texture_color_mask
+#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF
+#endif
+
+#ifndef GL_EXT_texture_env_dot3
+#define GL_DOT3_RGB_EXT 0x8740
+#define GL_DOT3_RGBA_EXT 0x8741
+#endif
+
+#ifndef GL_ATI_texture_mirror_once
+#define GL_MIRROR_CLAMP_ATI 0x8742
+#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743
+#endif
+
+#ifndef GL_NV_fence
+#define GL_ALL_COMPLETED_NV 0x84F2
+#define GL_FENCE_STATUS_NV 0x84F3
+#define GL_FENCE_CONDITION_NV 0x84F4
+#endif
+
+#ifndef GL_IBM_texture_mirrored_repeat
+#define GL_MIRRORED_REPEAT_IBM 0x8370
+#endif
+
+#ifndef GL_NV_evaluators
+#define GL_EVAL_2D_NV 0x86C0
+#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1
+#define GL_MAP_TESSELLATION_NV 0x86C2
+#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3
+#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4
+#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5
+#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6
+#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7
+#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8
+#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9
+#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA
+#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB
+#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC
+#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD
+#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE
+#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF
+#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0
+#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1
+#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2
+#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3
+#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4
+#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5
+#define GL_MAX_MAP_TESSELLATION_NV 0x86D6
+#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7
+#endif
+
+#ifndef GL_NV_packed_depth_stencil
+#define GL_DEPTH_STENCIL_NV 0x84F9
+#define GL_UNSIGNED_INT_24_8_NV 0x84FA
+#endif
+
+#ifndef GL_NV_register_combiners2
+#define GL_PER_STAGE_CONSTANTS_NV 0x8535
+#endif
+
+#ifndef GL_NV_texture_compression_vtc
+#endif
+
+#ifndef GL_NV_texture_rectangle
+#define GL_TEXTURE_RECTANGLE_NV 0x84F5
+#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6
+#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8
+#endif
+
+#ifndef GL_NV_texture_shader
+#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C
+#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D
+#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E
+#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9
+#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA
+#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB
+#define GL_DSDT_MAG_INTENSITY_NV 0x86DC
+#define GL_SHADER_CONSISTENT_NV 0x86DD
+#define GL_TEXTURE_SHADER_NV 0x86DE
+#define GL_SHADER_OPERATION_NV 0x86DF
+#define GL_CULL_MODES_NV 0x86E0
+#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1
+#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2
+#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3
+#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV
+#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV
+#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV
+#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4
+#define GL_CONST_EYE_NV 0x86E5
+#define GL_PASS_THROUGH_NV 0x86E6
+#define GL_CULL_FRAGMENT_NV 0x86E7
+#define GL_OFFSET_TEXTURE_2D_NV 0x86E8
+#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9
+#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA
+#define GL_DOT_PRODUCT_NV 0x86EC
+#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED
+#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE
+#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0
+#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1
+#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2
+#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3
+#define GL_HILO_NV 0x86F4
+#define GL_DSDT_NV 0x86F5
+#define GL_DSDT_MAG_NV 0x86F6
+#define GL_DSDT_MAG_VIB_NV 0x86F7
+#define GL_HILO16_NV 0x86F8
+#define GL_SIGNED_HILO_NV 0x86F9
+#define GL_SIGNED_HILO16_NV 0x86FA
+#define GL_SIGNED_RGBA_NV 0x86FB
+#define GL_SIGNED_RGBA8_NV 0x86FC
+#define GL_SIGNED_RGB_NV 0x86FE
+#define GL_SIGNED_RGB8_NV 0x86FF
+#define GL_SIGNED_LUMINANCE_NV 0x8701
+#define GL_SIGNED_LUMINANCE8_NV 0x8702
+#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703
+#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704
+#define GL_SIGNED_ALPHA_NV 0x8705
+#define GL_SIGNED_ALPHA8_NV 0x8706
+#define GL_SIGNED_INTENSITY_NV 0x8707
+#define GL_SIGNED_INTENSITY8_NV 0x8708
+#define GL_DSDT8_NV 0x8709
+#define GL_DSDT8_MAG8_NV 0x870A
+#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B
+#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C
+#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D
+#define GL_HI_SCALE_NV 0x870E
+#define GL_LO_SCALE_NV 0x870F
+#define GL_DS_SCALE_NV 0x8710
+#define GL_DT_SCALE_NV 0x8711
+#define GL_MAGNITUDE_SCALE_NV 0x8712
+#define GL_VIBRANCE_SCALE_NV 0x8713
+#define GL_HI_BIAS_NV 0x8714
+#define GL_LO_BIAS_NV 0x8715
+#define GL_DS_BIAS_NV 0x8716
+#define GL_DT_BIAS_NV 0x8717
+#define GL_MAGNITUDE_BIAS_NV 0x8718
+#define GL_VIBRANCE_BIAS_NV 0x8719
+#define GL_TEXTURE_BORDER_VALUES_NV 0x871A
+#define GL_TEXTURE_HI_SIZE_NV 0x871B
+#define GL_TEXTURE_LO_SIZE_NV 0x871C
+#define GL_TEXTURE_DS_SIZE_NV 0x871D
+#define GL_TEXTURE_DT_SIZE_NV 0x871E
+#define GL_TEXTURE_MAG_SIZE_NV 0x871F
+#endif
+
+#ifndef GL_NV_texture_shader2
+#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF
+#endif
+
+#ifndef GL_NV_vertex_array_range2
+#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533
+#endif
+
+#ifndef GL_NV_vertex_program
+#define GL_VERTEX_PROGRAM_NV 0x8620
+#define GL_VERTEX_STATE_PROGRAM_NV 0x8621
+#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623
+#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624
+#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625
+#define GL_CURRENT_ATTRIB_NV 0x8626
+#define GL_PROGRAM_LENGTH_NV 0x8627
+#define GL_PROGRAM_STRING_NV 0x8628
+#define GL_MODELVIEW_PROJECTION_NV 0x8629
+#define GL_IDENTITY_NV 0x862A
+#define GL_INVERSE_NV 0x862B
+#define GL_TRANSPOSE_NV 0x862C
+#define GL_INVERSE_TRANSPOSE_NV 0x862D
+#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E
+#define GL_MAX_TRACK_MATRICES_NV 0x862F
+#define GL_MATRIX0_NV 0x8630
+#define GL_MATRIX1_NV 0x8631
+#define GL_MATRIX2_NV 0x8632
+#define GL_MATRIX3_NV 0x8633
+#define GL_MATRIX4_NV 0x8634
+#define GL_MATRIX5_NV 0x8635
+#define GL_MATRIX6_NV 0x8636
+#define GL_MATRIX7_NV 0x8637
+#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640
+#define GL_CURRENT_MATRIX_NV 0x8641
+#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643
+#define GL_PROGRAM_PARAMETER_NV 0x8644
+#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645
+#define GL_PROGRAM_TARGET_NV 0x8646
+#define GL_PROGRAM_RESIDENT_NV 0x8647
+#define GL_TRACK_MATRIX_NV 0x8648
+#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649
+#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A
+#define GL_PROGRAM_ERROR_POSITION_NV 0x864B
+#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650
+#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651
+#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652
+#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653
+#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654
+#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655
+#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656
+#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657
+#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658
+#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659
+#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A
+#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B
+#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C
+#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D
+#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E
+#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F
+#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660
+#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661
+#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662
+#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663
+#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664
+#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665
+#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666
+#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667
+#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668
+#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669
+#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A
+#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B
+#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C
+#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D
+#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E
+#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F
+#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670
+#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671
+#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672
+#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673
+#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674
+#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675
+#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676
+#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677
+#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678
+#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679
+#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A
+#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B
+#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C
+#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D
+#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E
+#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F
+#endif
+
+#ifndef GL_SGIX_texture_coordinate_clamp
+#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369
+#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A
+#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B
+#endif
+
+#ifndef GL_SGIX_scalebias_hint
+#define GL_SCALEBIAS_HINT_SGIX 0x8322
+#endif
+
+#ifndef GL_OML_interlace
+#define GL_INTERLACE_OML 0x8980
+#define GL_INTERLACE_READ_OML 0x8981
+#endif
+
+#ifndef GL_OML_subsample
+#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982
+#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983
+#endif
+
+#ifndef GL_OML_resample
+#define GL_PACK_RESAMPLE_OML 0x8984
+#define GL_UNPACK_RESAMPLE_OML 0x8985
+#define GL_RESAMPLE_REPLICATE_OML 0x8986
+#define GL_RESAMPLE_ZERO_FILL_OML 0x8987
+#define GL_RESAMPLE_AVERAGE_OML 0x8988
+#define GL_RESAMPLE_DECIMATE_OML 0x8989
+#endif
+
+#ifndef GL_NV_copy_depth_to_color
+#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E
+#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F
+#endif
+
+#ifndef GL_ATI_envmap_bumpmap
+#define GL_BUMP_ROT_MATRIX_ATI 0x8775
+#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776
+#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777
+#define GL_BUMP_TEX_UNITS_ATI 0x8778
+#define GL_DUDV_ATI 0x8779
+#define GL_DU8DV8_ATI 0x877A
+#define GL_BUMP_ENVMAP_ATI 0x877B
+#define GL_BUMP_TARGET_ATI 0x877C
+#endif
+
+#ifndef GL_ATI_fragment_shader
+#define GL_FRAGMENT_SHADER_ATI 0x8920
+#define GL_REG_0_ATI 0x8921
+#define GL_REG_1_ATI 0x8922
+#define GL_REG_2_ATI 0x8923
+#define GL_REG_3_ATI 0x8924
+#define GL_REG_4_ATI 0x8925
+#define GL_REG_5_ATI 0x8926
+#define GL_REG_6_ATI 0x8927
+#define GL_REG_7_ATI 0x8928
+#define GL_REG_8_ATI 0x8929
+#define GL_REG_9_ATI 0x892A
+#define GL_REG_10_ATI 0x892B
+#define GL_REG_11_ATI 0x892C
+#define GL_REG_12_ATI 0x892D
+#define GL_REG_13_ATI 0x892E
+#define GL_REG_14_ATI 0x892F
+#define GL_REG_15_ATI 0x8930
+#define GL_REG_16_ATI 0x8931
+#define GL_REG_17_ATI 0x8932
+#define GL_REG_18_ATI 0x8933
+#define GL_REG_19_ATI 0x8934
+#define GL_REG_20_ATI 0x8935
+#define GL_REG_21_ATI 0x8936
+#define GL_REG_22_ATI 0x8937
+#define GL_REG_23_ATI 0x8938
+#define GL_REG_24_ATI 0x8939
+#define GL_REG_25_ATI 0x893A
+#define GL_REG_26_ATI 0x893B
+#define GL_REG_27_ATI 0x893C
+#define GL_REG_28_ATI 0x893D
+#define GL_REG_29_ATI 0x893E
+#define GL_REG_30_ATI 0x893F
+#define GL_REG_31_ATI 0x8940
+#define GL_CON_0_ATI 0x8941
+#define GL_CON_1_ATI 0x8942
+#define GL_CON_2_ATI 0x8943
+#define GL_CON_3_ATI 0x8944
+#define GL_CON_4_ATI 0x8945
+#define GL_CON_5_ATI 0x8946
+#define GL_CON_6_ATI 0x8947
+#define GL_CON_7_ATI 0x8948
+#define GL_CON_8_ATI 0x8949
+#define GL_CON_9_ATI 0x894A
+#define GL_CON_10_ATI 0x894B
+#define GL_CON_11_ATI 0x894C
+#define GL_CON_12_ATI 0x894D
+#define GL_CON_13_ATI 0x894E
+#define GL_CON_14_ATI 0x894F
+#define GL_CON_15_ATI 0x8950
+#define GL_CON_16_ATI 0x8951
+#define GL_CON_17_ATI 0x8952
+#define GL_CON_18_ATI 0x8953
+#define GL_CON_19_ATI 0x8954
+#define GL_CON_20_ATI 0x8955
+#define GL_CON_21_ATI 0x8956
+#define GL_CON_22_ATI 0x8957
+#define GL_CON_23_ATI 0x8958
+#define GL_CON_24_ATI 0x8959
+#define GL_CON_25_ATI 0x895A
+#define GL_CON_26_ATI 0x895B
+#define GL_CON_27_ATI 0x895C
+#define GL_CON_28_ATI 0x895D
+#define GL_CON_29_ATI 0x895E
+#define GL_CON_30_ATI 0x895F
+#define GL_CON_31_ATI 0x8960
+#define GL_MOV_ATI 0x8961
+#define GL_ADD_ATI 0x8963
+#define GL_MUL_ATI 0x8964
+#define GL_SUB_ATI 0x8965
+#define GL_DOT3_ATI 0x8966
+#define GL_DOT4_ATI 0x8967
+#define GL_MAD_ATI 0x8968
+#define GL_LERP_ATI 0x8969
+#define GL_CND_ATI 0x896A
+#define GL_CND0_ATI 0x896B
+#define GL_DOT2_ADD_ATI 0x896C
+#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D
+#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E
+#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F
+#define GL_NUM_PASSES_ATI 0x8970
+#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971
+#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972
+#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973
+#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974
+#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975
+#define GL_SWIZZLE_STR_ATI 0x8976
+#define GL_SWIZZLE_STQ_ATI 0x8977
+#define GL_SWIZZLE_STR_DR_ATI 0x8978
+#define GL_SWIZZLE_STQ_DQ_ATI 0x8979
+#define GL_SWIZZLE_STRQ_ATI 0x897A
+#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B
+#define GL_RED_BIT_ATI 0x00000001
+#define GL_GREEN_BIT_ATI 0x00000002
+#define GL_BLUE_BIT_ATI 0x00000004
+#define GL_2X_BIT_ATI 0x00000001
+#define GL_4X_BIT_ATI 0x00000002
+#define GL_8X_BIT_ATI 0x00000004
+#define GL_HALF_BIT_ATI 0x00000008
+#define GL_QUARTER_BIT_ATI 0x00000010
+#define GL_EIGHTH_BIT_ATI 0x00000020
+#define GL_SATURATE_BIT_ATI 0x00000040
+#define GL_COMP_BIT_ATI 0x00000002
+#define GL_NEGATE_BIT_ATI 0x00000004
+#define GL_BIAS_BIT_ATI 0x00000008
+#endif
+
+#ifndef GL_ATI_pn_triangles
+#define GL_PN_TRIANGLES_ATI 0x87F0
+#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1
+#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2
+#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3
+#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4
+#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5
+#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6
+#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7
+#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8
+#endif
+
+#ifndef GL_ATI_vertex_array_object
+#define GL_STATIC_ATI 0x8760
+#define GL_DYNAMIC_ATI 0x8761
+#define GL_PRESERVE_ATI 0x8762
+#define GL_DISCARD_ATI 0x8763
+#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764
+#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765
+#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766
+#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767
+#endif
+
+#ifndef GL_EXT_vertex_shader
+#define GL_VERTEX_SHADER_EXT 0x8780
+#define GL_VERTEX_SHADER_BINDING_EXT 0x8781
+#define GL_OP_INDEX_EXT 0x8782
+#define GL_OP_NEGATE_EXT 0x8783
+#define GL_OP_DOT3_EXT 0x8784
+#define GL_OP_DOT4_EXT 0x8785
+#define GL_OP_MUL_EXT 0x8786
+#define GL_OP_ADD_EXT 0x8787
+#define GL_OP_MADD_EXT 0x8788
+#define GL_OP_FRAC_EXT 0x8789
+#define GL_OP_MAX_EXT 0x878A
+#define GL_OP_MIN_EXT 0x878B
+#define GL_OP_SET_GE_EXT 0x878C
+#define GL_OP_SET_LT_EXT 0x878D
+#define GL_OP_CLAMP_EXT 0x878E
+#define GL_OP_FLOOR_EXT 0x878F
+#define GL_OP_ROUND_EXT 0x8790
+#define GL_OP_EXP_BASE_2_EXT 0x8791
+#define GL_OP_LOG_BASE_2_EXT 0x8792
+#define GL_OP_POWER_EXT 0x8793
+#define GL_OP_RECIP_EXT 0x8794
+#define GL_OP_RECIP_SQRT_EXT 0x8795
+#define GL_OP_SUB_EXT 0x8796
+#define GL_OP_CROSS_PRODUCT_EXT 0x8797
+#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798
+#define GL_OP_MOV_EXT 0x8799
+#define GL_OUTPUT_VERTEX_EXT 0x879A
+#define GL_OUTPUT_COLOR0_EXT 0x879B
+#define GL_OUTPUT_COLOR1_EXT 0x879C
+#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D
+#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E
+#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F
+#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0
+#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1
+#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2
+#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3
+#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4
+#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5
+#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6
+#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7
+#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8
+#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9
+#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA
+#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB
+#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC
+#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD
+#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE
+#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF
+#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0
+#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1
+#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2
+#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3
+#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4
+#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5
+#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6
+#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7
+#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8
+#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9
+#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA
+#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB
+#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC
+#define GL_OUTPUT_FOG_EXT 0x87BD
+#define GL_SCALAR_EXT 0x87BE
+#define GL_VECTOR_EXT 0x87BF
+#define GL_MATRIX_EXT 0x87C0
+#define GL_VARIANT_EXT 0x87C1
+#define GL_INVARIANT_EXT 0x87C2
+#define GL_LOCAL_CONSTANT_EXT 0x87C3
+#define GL_LOCAL_EXT 0x87C4
+#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5
+#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6
+#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7
+#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8
+#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE
+#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF
+#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0
+#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1
+#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2
+#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3
+#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4
+#define GL_X_EXT 0x87D5
+#define GL_Y_EXT 0x87D6
+#define GL_Z_EXT 0x87D7
+#define GL_W_EXT 0x87D8
+#define GL_NEGATIVE_X_EXT 0x87D9
+#define GL_NEGATIVE_Y_EXT 0x87DA
+#define GL_NEGATIVE_Z_EXT 0x87DB
+#define GL_NEGATIVE_W_EXT 0x87DC
+#define GL_ZERO_EXT 0x87DD
+#define GL_ONE_EXT 0x87DE
+#define GL_NEGATIVE_ONE_EXT 0x87DF
+#define GL_NORMALIZED_RANGE_EXT 0x87E0
+#define GL_FULL_RANGE_EXT 0x87E1
+#define GL_CURRENT_VERTEX_EXT 0x87E2
+#define GL_MVP_MATRIX_EXT 0x87E3
+#define GL_VARIANT_VALUE_EXT 0x87E4
+#define GL_VARIANT_DATATYPE_EXT 0x87E5
+#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6
+#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7
+#define GL_VARIANT_ARRAY_EXT 0x87E8
+#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9
+#define GL_INVARIANT_VALUE_EXT 0x87EA
+#define GL_INVARIANT_DATATYPE_EXT 0x87EB
+#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC
+#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED
+#endif
+
+#ifndef GL_ATI_vertex_streams
+#define GL_MAX_VERTEX_STREAMS_ATI 0x876B
+#define GL_VERTEX_STREAM0_ATI 0x876C
+#define GL_VERTEX_STREAM1_ATI 0x876D
+#define GL_VERTEX_STREAM2_ATI 0x876E
+#define GL_VERTEX_STREAM3_ATI 0x876F
+#define GL_VERTEX_STREAM4_ATI 0x8770
+#define GL_VERTEX_STREAM5_ATI 0x8771
+#define GL_VERTEX_STREAM6_ATI 0x8772
+#define GL_VERTEX_STREAM7_ATI 0x8773
+#define GL_VERTEX_SOURCE_ATI 0x8774
+#endif
+
+#ifndef GL_ATI_element_array
+#define GL_ELEMENT_ARRAY_ATI 0x8768
+#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769
+#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A
+#endif
+
+#ifndef GL_SUN_mesh_array
+#define GL_QUAD_MESH_SUN 0x8614
+#define GL_TRIANGLE_MESH_SUN 0x8615
+#endif
+
+#ifndef GL_SUN_slice_accum
+#define GL_SLICE_ACCUM_SUN 0x85CC
+#endif
+
+#ifndef GL_NV_multisample_filter_hint
+#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534
+#endif
+
+#ifndef GL_NV_depth_clamp
+#define GL_DEPTH_CLAMP_NV 0x864F
+#endif
+
+#ifndef GL_NV_occlusion_query
+#define GL_PIXEL_COUNTER_BITS_NV 0x8864
+#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865
+#define GL_PIXEL_COUNT_NV 0x8866
+#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867
+#endif
+
+#ifndef GL_NV_point_sprite
+#define GL_POINT_SPRITE_NV 0x8861
+#define GL_COORD_REPLACE_NV 0x8862
+#define GL_POINT_SPRITE_R_MODE_NV 0x8863
+#endif
+
+#ifndef GL_NV_texture_shader3
+#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850
+#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851
+#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852
+#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853
+#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854
+#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855
+#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856
+#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857
+#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858
+#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859
+#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A
+#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B
+#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C
+#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D
+#define GL_HILO8_NV 0x885E
+#define GL_SIGNED_HILO8_NV 0x885F
+#define GL_FORCE_BLUE_TO_ONE_NV 0x8860
+#endif
+
+#ifndef GL_NV_vertex_program1_1
+#endif
+
+#ifndef GL_EXT_shadow_funcs
+#endif
+
+#ifndef GL_EXT_stencil_two_side
+#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910
+#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911
+#endif
+
+#ifndef GL_ATI_text_fragment_shader
+#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200
+#endif
+
+#ifndef GL_APPLE_client_storage
+#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2
+#endif
+
+#ifndef GL_APPLE_element_array
+#define GL_ELEMENT_ARRAY_APPLE 0x8768
+#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769
+#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A
+#endif
+
+#ifndef GL_APPLE_fence
+#define GL_DRAW_PIXELS_APPLE 0x8A0A
+#define GL_FENCE_APPLE 0x8A0B
+#endif
+
+#ifndef GL_APPLE_vertex_array_object
+#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5
+#endif
+
+#ifndef GL_APPLE_vertex_array_range
+#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D
+#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E
+#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F
+#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521
+#define GL_STORAGE_CACHED_APPLE 0x85BE
+#define GL_STORAGE_SHARED_APPLE 0x85BF
+#endif
+
+#ifndef GL_APPLE_ycbcr_422
+#define GL_YCBCR_422_APPLE 0x85B9
+#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA
+#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB
+#endif
+
+#ifndef GL_S3_s3tc
+#define GL_RGB_S3TC 0x83A0
+#define GL_RGB4_S3TC 0x83A1
+#define GL_RGBA_S3TC 0x83A2
+#define GL_RGBA4_S3TC 0x83A3
+#endif
+
+#ifndef GL_ATI_draw_buffers
+#define GL_MAX_DRAW_BUFFERS_ATI 0x8824
+#define GL_DRAW_BUFFER0_ATI 0x8825
+#define GL_DRAW_BUFFER1_ATI 0x8826
+#define GL_DRAW_BUFFER2_ATI 0x8827
+#define GL_DRAW_BUFFER3_ATI 0x8828
+#define GL_DRAW_BUFFER4_ATI 0x8829
+#define GL_DRAW_BUFFER5_ATI 0x882A
+#define GL_DRAW_BUFFER6_ATI 0x882B
+#define GL_DRAW_BUFFER7_ATI 0x882C
+#define GL_DRAW_BUFFER8_ATI 0x882D
+#define GL_DRAW_BUFFER9_ATI 0x882E
+#define GL_DRAW_BUFFER10_ATI 0x882F
+#define GL_DRAW_BUFFER11_ATI 0x8830
+#define GL_DRAW_BUFFER12_ATI 0x8831
+#define GL_DRAW_BUFFER13_ATI 0x8832
+#define GL_DRAW_BUFFER14_ATI 0x8833
+#define GL_DRAW_BUFFER15_ATI 0x8834
+#endif
+
+#ifndef GL_ATI_pixel_format_float
+#define GL_TYPE_RGBA_FLOAT_ATI 0x8820
+#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835
+#endif
+
+#ifndef GL_ATI_texture_env_combine3
+#define GL_MODULATE_ADD_ATI 0x8744
+#define GL_MODULATE_SIGNED_ADD_ATI 0x8745
+#define GL_MODULATE_SUBTRACT_ATI 0x8746
+#endif
+
+#ifndef GL_ATI_texture_float
+#define GL_RGBA_FLOAT32_ATI 0x8814
+#define GL_RGB_FLOAT32_ATI 0x8815
+#define GL_ALPHA_FLOAT32_ATI 0x8816
+#define GL_INTENSITY_FLOAT32_ATI 0x8817
+#define GL_LUMINANCE_FLOAT32_ATI 0x8818
+#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819
+#define GL_RGBA_FLOAT16_ATI 0x881A
+#define GL_RGB_FLOAT16_ATI 0x881B
+#define GL_ALPHA_FLOAT16_ATI 0x881C
+#define GL_INTENSITY_FLOAT16_ATI 0x881D
+#define GL_LUMINANCE_FLOAT16_ATI 0x881E
+#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F
+#endif
+
+#ifndef GL_NV_float_buffer
+#define GL_FLOAT_R_NV 0x8880
+#define GL_FLOAT_RG_NV 0x8881
+#define GL_FLOAT_RGB_NV 0x8882
+#define GL_FLOAT_RGBA_NV 0x8883
+#define GL_FLOAT_R16_NV 0x8884
+#define GL_FLOAT_R32_NV 0x8885
+#define GL_FLOAT_RG16_NV 0x8886
+#define GL_FLOAT_RG32_NV 0x8887
+#define GL_FLOAT_RGB16_NV 0x8888
+#define GL_FLOAT_RGB32_NV 0x8889
+#define GL_FLOAT_RGBA16_NV 0x888A
+#define GL_FLOAT_RGBA32_NV 0x888B
+#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C
+#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D
+#define GL_FLOAT_RGBA_MODE_NV 0x888E
+#endif
+
+#ifndef GL_NV_fragment_program
+#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868
+#define GL_FRAGMENT_PROGRAM_NV 0x8870
+#define GL_MAX_TEXTURE_COORDS_NV 0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872
+#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873
+#define GL_PROGRAM_ERROR_STRING_NV 0x8874
+#endif
+
+#ifndef GL_NV_half_float
+#define GL_HALF_FLOAT_NV 0x140B
+#endif
+
+#ifndef GL_NV_pixel_data_range
+#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878
+#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879
+#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A
+#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B
+#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C
+#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D
+#endif
+
+#ifndef GL_NV_primitive_restart
+#define GL_PRIMITIVE_RESTART_NV 0x8558
+#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559
+#endif
+
+#ifndef GL_NV_texture_expand_normal
+#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F
+#endif
+
+#ifndef GL_NV_vertex_program2
+#endif
+
+#ifndef GL_ATI_map_object_buffer
+#endif
+
+#ifndef GL_ATI_separate_stencil
+#define GL_STENCIL_BACK_FUNC_ATI 0x8800
+#define GL_STENCIL_BACK_FAIL_ATI 0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803
+#endif
+
+#ifndef GL_ATI_vertex_attrib_array_object
+#endif
+
+#ifndef GL_OES_read_format
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B
+#endif
+
+#ifndef GL_EXT_depth_bounds_test
+#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890
+#define GL_DEPTH_BOUNDS_EXT 0x8891
+#endif
+
+#ifndef GL_EXT_texture_mirror_clamp
+#define GL_MIRROR_CLAMP_EXT 0x8742
+#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743
+#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912
+#endif
+
+#ifndef GL_EXT_blend_equation_separate
+#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION
+#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D
+#endif
+
+#ifndef GL_MESA_pack_invert
+#define GL_PACK_INVERT_MESA 0x8758
+#endif
+
+#ifndef GL_MESA_ycbcr_texture
+#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA
+#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB
+#define GL_YCBCR_MESA 0x8757
+#endif
+
+#ifndef GL_EXT_pixel_buffer_object
+#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB
+#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF
+#endif
+
+#ifndef GL_NV_fragment_program_option
+#endif
+
+#ifndef GL_NV_fragment_program2
+#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4
+#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5
+#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6
+#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7
+#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8
+#endif
+
+#ifndef GL_NV_vertex_program2_option
+/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
+/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */
+#endif
+
+#ifndef GL_NV_vertex_program3
+/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */
+#endif
+
+#ifndef GL_EXT_framebuffer_object
+#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506
+#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8
+#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6
+#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4
+#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9
+#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA
+#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB
+#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC
+#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD
+#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
+#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
+#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
+#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
+#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
+#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
+#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
+#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
+#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
+#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
+#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
+#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
+#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
+#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
+#define GL_COLOR_ATTACHMENT13_EXT 0x8CED
+#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
+#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
+#define GL_DEPTH_ATTACHMENT_EXT 0x8D00
+#define GL_STENCIL_ATTACHMENT_EXT 0x8D20
+#define GL_FRAMEBUFFER_EXT 0x8D40
+#define GL_RENDERBUFFER_EXT 0x8D41
+#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42
+#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44
+#define GL_STENCIL_INDEX1_EXT 0x8D46
+#define GL_STENCIL_INDEX4_EXT 0x8D47
+#define GL_STENCIL_INDEX8_EXT 0x8D48
+#define GL_STENCIL_INDEX16_EXT 0x8D49
+#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55
+#endif
+
+#ifndef GL_GREMEDY_string_marker
+#endif
+
+
+/*************************************************************/
+
+#include <stddef.h>
+#ifndef GL_VERSION_2_0
+/* GL type for program/shader text */
+typedef char GLchar; /* native character */
+#endif
+
+#ifndef GL_VERSION_1_5
+/* GL types for handling large vertex buffer objects */
+typedef ptrdiff_t GLintptr;
+typedef ptrdiff_t GLsizeiptr;
+#endif
+
+#ifndef GL_ARB_vertex_buffer_object
+/* GL types for handling large vertex buffer objects */
+typedef ptrdiff_t GLintptrARB;
+typedef ptrdiff_t GLsizeiptrARB;
+#endif
+
+#ifndef GL_ARB_shader_objects
+/* GL types for handling shader object handles and program/shader text */
+typedef char GLcharARB; /* native character */
+typedef unsigned int GLhandleARB; /* shader object handle */
+#endif
+
+/* GL types for "half" precision (s10e5) float data in host memory */
+#ifndef GL_ARB_half_float_pixel
+typedef unsigned short GLhalfARB;
+#endif
+
+#ifndef GL_NV_half_float
+typedef unsigned short GLhalfNV;
+#endif
+
+#ifndef GL_VERSION_1_2
+#define GL_VERSION_1_2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf);
+GLAPI void APIENTRY glBlendEquation (GLenum);
+GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *);
+GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei);
+GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei);
+GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint);
+GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei);
+GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei);
+GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *);
+GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *);
+GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean);
+GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean);
+GLAPI void APIENTRY glResetHistogram (GLenum);
+GLAPI void APIENTRY glResetMinmax (GLenum);
+GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+#endif
+
+#ifndef GL_VERSION_1_3
+#define GL_VERSION_1_3 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glActiveTexture (GLenum);
+GLAPI void APIENTRY glClientActiveTexture (GLenum);
+GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble);
+GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat);
+GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint);
+GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort);
+GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *);
+GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble);
+GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat);
+GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint);
+GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort);
+GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *);
+GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint);
+GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *);
+GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *);
+GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *);
+GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *);
+GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *);
+GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *);
+GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean);
+GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m);
+typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (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 (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img);
+#endif
+
+#ifndef GL_VERSION_1_4
+#define GL_VERSION_1_4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum);
+GLAPI void APIENTRY glFogCoordf (GLfloat);
+GLAPI void APIENTRY glFogCoordfv (const GLfloat *);
+GLAPI void APIENTRY glFogCoordd (GLdouble);
+GLAPI void APIENTRY glFogCoorddv (const GLdouble *);
+GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei);
+GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
+GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat);
+GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *);
+GLAPI void APIENTRY glPointParameteri (GLenum, GLint);
+GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *);
+GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte);
+GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *);
+GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *);
+GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *);
+GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint);
+GLAPI void APIENTRY glSecondaryColor3iv (const GLint *);
+GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *);
+GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte);
+GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *);
+GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *);
+GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort);
+GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *);
+GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble);
+GLAPI void APIENTRY glWindowPos2dv (const GLdouble *);
+GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat);
+GLAPI void APIENTRY glWindowPos2fv (const GLfloat *);
+GLAPI void APIENTRY glWindowPos2i (GLint, GLint);
+GLAPI void APIENTRY glWindowPos2iv (const GLint *);
+GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort);
+GLAPI void APIENTRY glWindowPos2sv (const GLshort *);
+GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glWindowPos3dv (const GLdouble *);
+GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glWindowPos3fv (const GLfloat *);
+GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint);
+GLAPI void APIENTRY glWindowPos3iv (const GLint *);
+GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glWindowPos3sv (const GLshort *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord);
+typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord);
+typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord);
+typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord);
+typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v);
+#endif
+
+#ifndef GL_VERSION_1_5
+#define GL_VERSION_1_5 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *);
+GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *);
+GLAPI GLboolean APIENTRY glIsQuery (GLuint);
+GLAPI void APIENTRY glBeginQuery (GLenum, GLuint);
+GLAPI void APIENTRY glEndQuery (GLenum);
+GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *);
+GLAPI void APIENTRY glBindBuffer (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *);
+GLAPI GLboolean APIENTRY glIsBuffer (GLuint);
+GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum);
+GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *);
+GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *);
+GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum);
+GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum);
+GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids);
+typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids);
+typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id);
+typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
+typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers);
+typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
+typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
+typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
+typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access);
+typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params);
+#endif
+
+#ifndef GL_VERSION_2_0
+#define GL_VERSION_2_0 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum);
+GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *);
+GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum);
+GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint);
+GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint);
+GLAPI void APIENTRY glAttachShader (GLuint, GLuint);
+GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *);
+GLAPI void APIENTRY glCompileShader (GLuint);
+GLAPI GLuint APIENTRY glCreateProgram (void);
+GLAPI GLuint APIENTRY glCreateShader (GLenum);
+GLAPI void APIENTRY glDeleteProgram (GLuint);
+GLAPI void APIENTRY glDeleteShader (GLuint);
+GLAPI void APIENTRY glDetachShader (GLuint, GLuint);
+GLAPI void APIENTRY glDisableVertexAttribArray (GLuint);
+GLAPI void APIENTRY glEnableVertexAttribArray (GLuint);
+GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *);
+GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *);
+GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *);
+GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *);
+GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *);
+GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *);
+GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *);
+GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *);
+GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *);
+GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *);
+GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *);
+GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *);
+GLAPI GLboolean APIENTRY glIsProgram (GLuint);
+GLAPI GLboolean APIENTRY glIsShader (GLuint);
+GLAPI void APIENTRY glLinkProgram (GLuint);
+GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *);
+GLAPI void APIENTRY glUseProgram (GLuint);
+GLAPI void APIENTRY glUniform1f (GLint, GLfloat);
+GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat);
+GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glUniform1i (GLint, GLint);
+GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint);
+GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glValidateProgram (GLuint);
+GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble);
+GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat);
+GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort);
+GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *);
+GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte);
+GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *);
+GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *);
+GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *);
+GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *);
+GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *);
+GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);
+typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs);
+typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
+typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask);
+typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);
+typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name);
+typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader);
+typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void);
+typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type);
+typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader);
+typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);
+typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj);
+typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
+typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
+typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program);
+typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader);
+typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length);
+typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0);
+typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1);
+typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0);
+typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1);
+typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_ARB_multitexture
+#define GL_ARB_multitexture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glActiveTextureARB (GLenum);
+GLAPI void APIENTRY glClientActiveTextureARB (GLenum);
+GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble);
+GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat);
+GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint);
+GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort);
+GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *);
+GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble);
+GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat);
+GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint);
+GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort);
+GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *);
+GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint);
+GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *);
+GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);
+#endif
+
+#ifndef GL_ARB_transpose_matrix
+#define GL_ARB_transpose_matrix 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *);
+GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *);
+GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *);
+GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m);
+#endif
+
+#ifndef GL_ARB_multisample
+#define GL_ARB_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert);
+#endif
+
+#ifndef GL_ARB_texture_env_add
+#define GL_ARB_texture_env_add 1
+#endif
+
+#ifndef GL_ARB_texture_cube_map
+#define GL_ARB_texture_cube_map 1
+#endif
+
+#ifndef GL_ARB_texture_compression
+#define GL_ARB_texture_compression 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP 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 (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img);
+#endif
+
+#ifndef GL_ARB_texture_border_clamp
+#define GL_ARB_texture_border_clamp 1
+#endif
+
+#ifndef GL_ARB_point_parameters
+#define GL_ARB_point_parameters 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat);
+GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params);
+#endif
+
+#ifndef GL_ARB_vertex_blend
+#define GL_ARB_vertex_blend 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *);
+GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *);
+GLAPI void APIENTRY glWeightivARB (GLint, const GLint *);
+GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *);
+GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *);
+GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *);
+GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *);
+GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *);
+GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glVertexBlendARB (GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights);
+typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights);
+typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights);
+typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights);
+typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights);
+typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights);
+typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights);
+typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights);
+typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count);
+#endif
+
+#ifndef GL_ARB_matrix_palette
+#define GL_ARB_matrix_palette 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint);
+GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *);
+GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *);
+GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *);
+GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index);
+typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices);
+typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices);
+typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices);
+typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_ARB_texture_env_combine
+#define GL_ARB_texture_env_combine 1
+#endif
+
+#ifndef GL_ARB_texture_env_crossbar
+#define GL_ARB_texture_env_crossbar 1
+#endif
+
+#ifndef GL_ARB_texture_env_dot3
+#define GL_ARB_texture_env_dot3 1
+#endif
+
+#ifndef GL_ARB_texture_mirrored_repeat
+#define GL_ARB_texture_mirrored_repeat 1
+#endif
+
+#ifndef GL_ARB_depth_texture
+#define GL_ARB_depth_texture 1
+#endif
+
+#ifndef GL_ARB_shadow
+#define GL_ARB_shadow 1
+#endif
+
+#ifndef GL_ARB_shadow_ambient
+#define GL_ARB_shadow_ambient 1
+#endif
+
+#ifndef GL_ARB_window_pos
+#define GL_ARB_window_pos 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble);
+GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *);
+GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat);
+GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *);
+GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint);
+GLAPI void APIENTRY glWindowPos2ivARB (const GLint *);
+GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort);
+GLAPI void APIENTRY glWindowPos2svARB (const GLshort *);
+GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *);
+GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *);
+GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint);
+GLAPI void APIENTRY glWindowPos3ivARB (const GLint *);
+GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glWindowPos3svARB (const GLshort *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v);
+#endif
+
+#ifndef GL_ARB_vertex_program
+#define GL_ARB_vertex_program 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble);
+GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat);
+GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort);
+GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *);
+GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte);
+GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *);
+GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *);
+GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *);
+GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *);
+GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *);
+GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint);
+GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint);
+GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *);
+GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *);
+GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *);
+GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *);
+GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *);
+GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *);
+GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *);
+GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *);
+GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *);
+GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *);
+GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *);
+GLAPI GLboolean APIENTRY glIsProgramARB (GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string);
+typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program);
+typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs);
+typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
+typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program);
+#endif
+
+#ifndef GL_ARB_fragment_program
+#define GL_ARB_fragment_program 1
+/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */
+#endif
+
+#ifndef GL_ARB_vertex_buffer_object
+#define GL_ARB_vertex_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *);
+GLAPI GLboolean APIENTRY glIsBufferARB (GLuint);
+GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum);
+GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *);
+GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *);
+GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum);
+GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum);
+GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer);
+typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers);
+typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers);
+typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage);
+typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data);
+typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access);
+typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params);
+#endif
+
+#ifndef GL_ARB_occlusion_query
+#define GL_ARB_occlusion_query 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *);
+GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *);
+GLAPI GLboolean APIENTRY glIsQueryARB (GLuint);
+GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint);
+GLAPI void APIENTRY glEndQueryARB (GLenum);
+GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids);
+typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids);
+typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id);
+typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params);
+#endif
+
+#ifndef GL_ARB_shader_objects
+#define GL_ARB_shader_objects 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB);
+GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum);
+GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB);
+GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum);
+GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *);
+GLAPI void APIENTRY glCompileShaderARB (GLhandleARB);
+GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void);
+GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB);
+GLAPI void APIENTRY glLinkProgramARB (GLhandleARB);
+GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB);
+GLAPI void APIENTRY glValidateProgramARB (GLhandleARB);
+GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat);
+GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat);
+GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glUniform1iARB (GLint, GLint);
+GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint);
+GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *);
+GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *);
+GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *);
+GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *);
+GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *);
+GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *);
+GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *);
+GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj);
+typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname);
+typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj);
+typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType);
+typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length);
+typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj);
+typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void);
+typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj);
+typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj);
+typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj);
+typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj);
+typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0);
+typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1);
+typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0);
+typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1);
+typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
+typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj);
+typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
+typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params);
+typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source);
+#endif
+
+#ifndef GL_ARB_vertex_shader
+#define GL_ARB_vertex_shader 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *);
+GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *);
+GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name);
+typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
+typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
+#endif
+
+#ifndef GL_ARB_fragment_shader
+#define GL_ARB_fragment_shader 1
+#endif
+
+#ifndef GL_ARB_shading_language_100
+#define GL_ARB_shading_language_100 1
+#endif
+
+#ifndef GL_ARB_texture_non_power_of_two
+#define GL_ARB_texture_non_power_of_two 1
+#endif
+
+#ifndef GL_ARB_point_sprite
+#define GL_ARB_point_sprite 1
+#endif
+
+#ifndef GL_ARB_fragment_program_shadow
+#define GL_ARB_fragment_program_shadow 1
+#endif
+
+#ifndef GL_ARB_draw_buffers
+#define GL_ARB_draw_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs);
+#endif
+
+#ifndef GL_ARB_texture_rectangle
+#define GL_ARB_texture_rectangle 1
+#endif
+
+#ifndef GL_ARB_color_buffer_float
+#define GL_ARB_color_buffer_float 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glClampColorARB (GLenum, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp);
+#endif
+
+#ifndef GL_ARB_half_float_pixel
+#define GL_ARB_half_float_pixel 1
+#endif
+
+#ifndef GL_ARB_texture_float
+#define GL_ARB_texture_float 1
+#endif
+
+#ifndef GL_ARB_pixel_buffer_object
+#define GL_ARB_pixel_buffer_object 1
+#endif
+
+#ifndef GL_EXT_abgr
+#define GL_EXT_abgr 1
+#endif
+
+#ifndef GL_EXT_blend_color
+#define GL_EXT_blend_color 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+#endif
+
+#ifndef GL_EXT_polygon_offset
+#define GL_EXT_polygon_offset 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias);
+#endif
+
+#ifndef GL_EXT_texture
+#define GL_EXT_texture 1
+#endif
+
+#ifndef GL_EXT_texture3D
+#define GL_EXT_texture3D 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+#endif
+
+#ifndef GL_SGIS_texture_filter4
+#define GL_SGIS_texture_filter4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights);
+typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights);
+#endif
+
+#ifndef GL_EXT_subtexture
+#define GL_EXT_subtexture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+#endif
+
+#ifndef GL_EXT_copy_texture
+#define GL_EXT_copy_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint);
+GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);
+GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei);
+GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+#endif
+
+#ifndef GL_EXT_histogram
+#define GL_EXT_histogram 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean);
+GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean);
+GLAPI void APIENTRY glResetHistogramEXT (GLenum);
+GLAPI void APIENTRY glResetMinmaxEXT (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target);
+#endif
+
+#ifndef GL_EXT_convolution
+#define GL_EXT_convolution 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint);
+GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei);
+GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei);
+GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *);
+GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+#endif
+
+#ifndef GL_EXT_color_matrix
+#define GL_EXT_color_matrix 1
+#endif
+
+#ifndef GL_SGI_color_table
+#define GL_SGI_color_table 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei);
+GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_SGIX_pixel_texture
+#define GL_SGIX_pixel_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPixelTexGenSGIX (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode);
+#endif
+
+#ifndef GL_SGIS_pixel_texture
+#define GL_SGIS_pixel_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint);
+GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *);
+GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat);
+GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *);
+GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *);
+GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_SGIS_texture4D
+#define GL_SGIS_texture4D 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (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);
+#endif
+
+#ifndef GL_SGI_texture_color_table
+#define GL_SGI_texture_color_table 1
+#endif
+
+#ifndef GL_EXT_cmyka
+#define GL_EXT_cmyka 1
+#endif
+
+#ifndef GL_EXT_texture_object
+#define GL_EXT_texture_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *);
+GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *);
+GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint);
+GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences);
+typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture);
+typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures);
+typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures);
+typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture);
+typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities);
+#endif
+
+#ifndef GL_SGIS_detail_texture
+#define GL_SGIS_detail_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points);
+typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points);
+#endif
+
+#ifndef GL_SGIS_sharpen_texture
+#define GL_SGIS_sharpen_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points);
+typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points);
+#endif
+
+#ifndef GL_EXT_packed_pixels
+#define GL_EXT_packed_pixels 1
+#endif
+
+#ifndef GL_SGIS_texture_lod
+#define GL_SGIS_texture_lod 1
+#endif
+
+#ifndef GL_SGIS_multisample
+#define GL_SGIS_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean);
+GLAPI void APIENTRY glSamplePatternSGIS (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert);
+typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern);
+#endif
+
+#ifndef GL_EXT_rescale_normal
+#define GL_EXT_rescale_normal 1
+#endif
+
+#ifndef GL_EXT_vertex_array
+#define GL_EXT_vertex_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glArrayElementEXT (GLint);
+GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei);
+GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *);
+GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *);
+GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i);
+typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count);
+typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer);
+typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params);
+typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+#endif
+
+#ifndef GL_EXT_misc_attribute
+#define GL_EXT_misc_attribute 1
+#endif
+
+#ifndef GL_SGIS_generate_mipmap
+#define GL_SGIS_generate_mipmap 1
+#endif
+
+#ifndef GL_SGIX_clipmap
+#define GL_SGIX_clipmap 1
+#endif
+
+#ifndef GL_SGIX_shadow
+#define GL_SGIX_shadow 1
+#endif
+
+#ifndef GL_SGIS_texture_edge_clamp
+#define GL_SGIS_texture_edge_clamp 1
+#endif
+
+#ifndef GL_SGIS_texture_border_clamp
+#define GL_SGIS_texture_border_clamp 1
+#endif
+
+#ifndef GL_EXT_blend_minmax
+#define GL_EXT_blend_minmax 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendEquationEXT (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode);
+#endif
+
+#ifndef GL_EXT_blend_subtract
+#define GL_EXT_blend_subtract 1
+#endif
+
+#ifndef GL_EXT_blend_logic_op
+#define GL_EXT_blend_logic_op 1
+#endif
+
+#ifndef GL_SGIX_interlace
+#define GL_SGIX_interlace 1
+#endif
+
+#ifndef GL_SGIX_pixel_tiles
+#define GL_SGIX_pixel_tiles 1
+#endif
+
+#ifndef GL_SGIX_texture_select
+#define GL_SGIX_texture_select 1
+#endif
+
+#ifndef GL_SGIX_sprite
+#define GL_SGIX_sprite 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat);
+GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *);
+GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint);
+GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params);
+#endif
+
+#ifndef GL_SGIX_texture_multi_buffer
+#define GL_SGIX_texture_multi_buffer 1
+#endif
+
+#ifndef GL_EXT_point_parameters
+#define GL_EXT_point_parameters 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat);
+GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params);
+#endif
+
+#ifndef GL_SGIS_point_parameters
+#define GL_SGIS_point_parameters 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat);
+GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params);
+#endif
+
+#ifndef GL_SGIX_instruments
+#define GL_SGIX_instruments 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLint APIENTRY glGetInstrumentsSGIX (void);
+GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *);
+GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *);
+GLAPI void APIENTRY glReadInstrumentsSGIX (GLint);
+GLAPI void APIENTRY glStartInstrumentsSGIX (void);
+GLAPI void APIENTRY glStopInstrumentsSGIX (GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void);
+typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer);
+typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p);
+typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker);
+typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void);
+typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker);
+#endif
+
+#ifndef GL_SGIX_texture_scale_bias
+#define GL_SGIX_texture_scale_bias 1
+#endif
+
+#ifndef GL_SGIX_framezoom
+#define GL_SGIX_framezoom 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFrameZoomSGIX (GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor);
+#endif
+
+#ifndef GL_SGIX_tag_sample_buffer
+#define GL_SGIX_tag_sample_buffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTagSampleBufferSGIX (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void);
+#endif
+
+#ifndef GL_SGIX_polynomial_ffd
+#define GL_SGIX_polynomial_ffd 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *);
+GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *);
+GLAPI void APIENTRY glDeformSGIX (GLbitfield);
+GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points);
+typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points);
+typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask);
+typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask);
+#endif
+
+#ifndef GL_SGIX_reference_plane
+#define GL_SGIX_reference_plane 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation);
+#endif
+
+#ifndef GL_SGIX_flush_raster
+#define GL_SGIX_flush_raster 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFlushRasterSGIX (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void);
+#endif
+
+#ifndef GL_SGIX_depth_texture
+#define GL_SGIX_depth_texture 1
+#endif
+
+#ifndef GL_SGIS_fog_function
+#define GL_SGIS_fog_function 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *);
+GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points);
+typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points);
+#endif
+
+#ifndef GL_SGIX_fog_offset
+#define GL_SGIX_fog_offset 1
+#endif
+
+#ifndef GL_HP_image_transform
+#define GL_HP_image_transform 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint);
+GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_HP_convolution_border_modes
+#define GL_HP_convolution_border_modes 1
+#endif
+
+#ifndef GL_SGIX_texture_add_env
+#define GL_SGIX_texture_add_env 1
+#endif
+
+#ifndef GL_EXT_color_subtable
+#define GL_EXT_color_subtable 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+#endif
+
+#ifndef GL_PGI_vertex_hints
+#define GL_PGI_vertex_hints 1
+#endif
+
+#ifndef GL_PGI_misc_hints
+#define GL_PGI_misc_hints 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glHintPGI (GLenum, GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode);
+#endif
+
+#ifndef GL_EXT_paletted_texture
+#define GL_EXT_paletted_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_EXT_clip_volume_hint
+#define GL_EXT_clip_volume_hint 1
+#endif
+
+#ifndef GL_SGIX_list_priority
+#define GL_SGIX_list_priority 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat);
+GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *);
+GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint);
+GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params);
+#endif
+
+#ifndef GL_SGIX_ir_instrument1
+#define GL_SGIX_ir_instrument1 1
+#endif
+
+#ifndef GL_SGIX_calligraphic_fragment
+#define GL_SGIX_calligraphic_fragment 1
+#endif
+
+#ifndef GL_SGIX_texture_lod_bias
+#define GL_SGIX_texture_lod_bias 1
+#endif
+
+#ifndef GL_SGIX_shadow_ambient
+#define GL_SGIX_shadow_ambient 1
+#endif
+
+#ifndef GL_EXT_index_texture
+#define GL_EXT_index_texture 1
+#endif
+
+#ifndef GL_EXT_index_material
+#define GL_EXT_index_material 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode);
+#endif
+
+#ifndef GL_EXT_index_func
+#define GL_EXT_index_func 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref);
+#endif
+
+#ifndef GL_EXT_index_array_formats
+#define GL_EXT_index_array_formats 1
+#endif
+
+#ifndef GL_EXT_compiled_vertex_array
+#define GL_EXT_compiled_vertex_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei);
+GLAPI void APIENTRY glUnlockArraysEXT (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count);
+typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void);
+#endif
+
+#ifndef GL_EXT_cull_vertex
+#define GL_EXT_cull_vertex 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *);
+GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_SGIX_ycrcb
+#define GL_SGIX_ycrcb 1
+#endif
+
+#ifndef GL_SGIX_fragment_lighting
+#define GL_SGIX_fragment_lighting 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum);
+GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint);
+GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat);
+GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *);
+GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint);
+GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *);
+GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint);
+GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param);
+#endif
+
+#ifndef GL_IBM_rasterpos_clip
+#define GL_IBM_rasterpos_clip 1
+#endif
+
+#ifndef GL_HP_texture_lighting
+#define GL_HP_texture_lighting 1
+#endif
+
+#ifndef GL_EXT_draw_range_elements
+#define GL_EXT_draw_range_elements 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+#endif
+
+#ifndef GL_WIN_phong_shading
+#define GL_WIN_phong_shading 1
+#endif
+
+#ifndef GL_WIN_specular_fog
+#define GL_WIN_specular_fog 1
+#endif
+
+#ifndef GL_EXT_light_texture
+#define GL_EXT_light_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glApplyTextureEXT (GLenum);
+GLAPI void APIENTRY glTextureLightEXT (GLenum);
+GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname);
+typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode);
+#endif
+
+#ifndef GL_SGIX_blend_alpha_minmax
+#define GL_SGIX_blend_alpha_minmax 1
+#endif
+
+#ifndef GL_EXT_bgra
+#define GL_EXT_bgra 1
+#endif
+
+#ifndef GL_SGIX_async
+#define GL_SGIX_async 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint);
+GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *);
+GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *);
+GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei);
+GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei);
+GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker);
+typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp);
+typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp);
+typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range);
+typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range);
+typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker);
+#endif
+
+#ifndef GL_SGIX_async_pixel
+#define GL_SGIX_async_pixel 1
+#endif
+
+#ifndef GL_SGIX_async_histogram
+#define GL_SGIX_async_histogram 1
+#endif
+
+#ifndef GL_INTEL_parallel_arrays
+#define GL_INTEL_parallel_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *);
+GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *);
+GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *);
+GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
+typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer);
+typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
+typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
+#endif
+
+#ifndef GL_HP_occlusion_test
+#define GL_HP_occlusion_test 1
+#endif
+
+#ifndef GL_EXT_pixel_transform
+#define GL_EXT_pixel_transform 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint);
+GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params);
+#endif
+
+#ifndef GL_EXT_pixel_transform_color_table
+#define GL_EXT_pixel_transform_color_table 1
+#endif
+
+#ifndef GL_EXT_shared_texture_palette
+#define GL_EXT_shared_texture_palette 1
+#endif
+
+#ifndef GL_EXT_separate_specular_color
+#define GL_EXT_separate_specular_color 1
+#endif
+
+#ifndef GL_EXT_secondary_color
+#define GL_EXT_secondary_color 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte);
+GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *);
+GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *);
+GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *);
+GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint);
+GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *);
+GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *);
+GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte);
+GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *);
+GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *);
+GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort);
+GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *);
+GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_EXT_texture_perturb_normal
+#define GL_EXT_texture_perturb_normal 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTextureNormalEXT (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode);
+#endif
+
+#ifndef GL_EXT_multi_draw_arrays
+#define GL_EXT_multi_draw_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei);
+GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
+#endif
+
+#ifndef GL_EXT_fog_coord
+#define GL_EXT_fog_coord 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFogCoordfEXT (GLfloat);
+GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *);
+GLAPI void APIENTRY glFogCoorddEXT (GLdouble);
+GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *);
+GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord);
+typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord);
+typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord);
+typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord);
+typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_REND_screen_coordinates
+#define GL_REND_screen_coordinates 1
+#endif
+
+#ifndef GL_EXT_coordinate_frame
+#define GL_EXT_coordinate_frame 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte);
+GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *);
+GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *);
+GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *);
+GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint);
+GLAPI void APIENTRY glTangent3ivEXT (const GLint *);
+GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glTangent3svEXT (const GLshort *);
+GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte);
+GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *);
+GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *);
+GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *);
+GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint);
+GLAPI void APIENTRY glBinormal3ivEXT (const GLint *);
+GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glBinormal3svEXT (const GLshort *);
+GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz);
+typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v);
+typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz);
+typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz);
+typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz);
+typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz);
+typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz);
+typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v);
+typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz);
+typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz);
+typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz);
+typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz);
+typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_EXT_texture_env_combine
+#define GL_EXT_texture_env_combine 1
+#endif
+
+#ifndef GL_APPLE_specular_vector
+#define GL_APPLE_specular_vector 1
+#endif
+
+#ifndef GL_APPLE_transform_hint
+#define GL_APPLE_transform_hint 1
+#endif
+
+#ifndef GL_SGIX_fog_scale
+#define GL_SGIX_fog_scale 1
+#endif
+
+#ifndef GL_SUNX_constant_data
+#define GL_SUNX_constant_data 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFinishTextureSUNX (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void);
+#endif
+
+#ifndef GL_SUN_global_alpha
+#define GL_SUN_global_alpha 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte);
+GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort);
+GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint);
+GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat);
+GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble);
+GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte);
+GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort);
+GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor);
+#endif
+
+#ifndef GL_SUN_triangle_list
+#define GL_SUN_triangle_list 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint);
+GLAPI void APIENTRY glReplacementCodeusSUN (GLushort);
+GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte);
+GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *);
+GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *);
+GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *);
+GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer);
+#endif
+
+#ifndef GL_SUN_vertex
+#define GL_SUN_vertex 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat);
+GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *);
+GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *);
+GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *);
+GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *);
+GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *);
+GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (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 (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (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 (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (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 (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+#endif
+
+#ifndef GL_EXT_blend_func_separate
+#define GL_EXT_blend_func_separate 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+#endif
+
+#ifndef GL_INGR_blend_func_separate
+#define GL_INGR_blend_func_separate 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+#endif
+
+#ifndef GL_INGR_color_clamp
+#define GL_INGR_color_clamp 1
+#endif
+
+#ifndef GL_INGR_interlace_read
+#define GL_INGR_interlace_read 1
+#endif
+
+#ifndef GL_EXT_stencil_wrap
+#define GL_EXT_stencil_wrap 1
+#endif
+
+#ifndef GL_EXT_422_pixels
+#define GL_EXT_422_pixels 1
+#endif
+
+#ifndef GL_NV_texgen_reflection
+#define GL_NV_texgen_reflection 1
+#endif
+
+#ifndef GL_SUN_convolution_border_modes
+#define GL_SUN_convolution_border_modes 1
+#endif
+
+#ifndef GL_EXT_texture_env_add
+#define GL_EXT_texture_env_add 1
+#endif
+
+#ifndef GL_EXT_texture_lod_bias
+#define GL_EXT_texture_lod_bias 1
+#endif
+
+#ifndef GL_EXT_texture_filter_anisotropic
+#define GL_EXT_texture_filter_anisotropic 1
+#endif
+
+#ifndef GL_EXT_vertex_weighting
+#define GL_EXT_vertex_weighting 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexWeightfEXT (GLfloat);
+GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *);
+GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight);
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight);
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_NV_light_max_exponent
+#define GL_NV_light_max_exponent 1
+#endif
+
+#ifndef GL_NV_vertex_array_range
+#define GL_NV_vertex_array_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFlushVertexArrayRangeNV (void);
+GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void);
+typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer);
+#endif
+
+#ifndef GL_NV_register_combiners
+#define GL_NV_register_combiners 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *);
+GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat);
+GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *);
+GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint);
+GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum);
+GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean);
+GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum);
+GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);
+typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_NV_fog_distance
+#define GL_NV_fog_distance 1
+#endif
+
+#ifndef GL_NV_texgen_emboss
+#define GL_NV_texgen_emboss 1
+#endif
+
+#ifndef GL_NV_blend_square
+#define GL_NV_blend_square 1
+#endif
+
+#ifndef GL_NV_texture_env_combine4
+#define GL_NV_texture_env_combine4 1
+#endif
+
+#ifndef GL_MESA_resize_buffers
+#define GL_MESA_resize_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glResizeBuffersMESA (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void);
+#endif
+
+#ifndef GL_MESA_window_pos
+#define GL_MESA_window_pos 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble);
+GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *);
+GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat);
+GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *);
+GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint);
+GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *);
+GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort);
+GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *);
+GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *);
+GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *);
+GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint);
+GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *);
+GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *);
+GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *);
+GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *);
+GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *);
+GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v);
+#endif
+
+#ifndef GL_IBM_cull_vertex
+#define GL_IBM_cull_vertex 1
+#endif
+
+#ifndef GL_IBM_multimode_draw_arrays
+#define GL_IBM_multimode_draw_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint);
+GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride);
+typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride);
+#endif
+
+#ifndef GL_IBM_vertex_array_lists
+#define GL_IBM_vertex_array_lists 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint);
+GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint);
+GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint);
+GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint);
+GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint);
+GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint);
+GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint);
+GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+#endif
+
+#ifndef GL_SGIX_subsample
+#define GL_SGIX_subsample 1
+#endif
+
+#ifndef GL_SGIX_ycrcba
+#define GL_SGIX_ycrcba 1
+#endif
+
+#ifndef GL_SGIX_ycrcb_subsample
+#define GL_SGIX_ycrcb_subsample 1
+#endif
+
+#ifndef GL_SGIX_depth_pass_instrument
+#define GL_SGIX_depth_pass_instrument 1
+#endif
+
+#ifndef GL_3DFX_texture_compression_FXT1
+#define GL_3DFX_texture_compression_FXT1 1
+#endif
+
+#ifndef GL_3DFX_multisample
+#define GL_3DFX_multisample 1
+#endif
+
+#ifndef GL_3DFX_tbuffer
+#define GL_3DFX_tbuffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTbufferMask3DFX (GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask);
+#endif
+
+#ifndef GL_EXT_multisample
+#define GL_EXT_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean);
+GLAPI void APIENTRY glSamplePatternEXT (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert);
+typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern);
+#endif
+
+#ifndef GL_SGIX_vertex_preclip
+#define GL_SGIX_vertex_preclip 1
+#endif
+
+#ifndef GL_SGIX_convolution_accuracy
+#define GL_SGIX_convolution_accuracy 1
+#endif
+
+#ifndef GL_SGIX_resample
+#define GL_SGIX_resample 1
+#endif
+
+#ifndef GL_SGIS_point_line_texgen
+#define GL_SGIS_point_line_texgen 1
+#endif
+
+#ifndef GL_SGIS_texture_color_mask
+#define GL_SGIS_texture_color_mask 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+#endif
+
+#ifndef GL_SGIX_igloo_interface
+#define GL_SGIX_igloo_interface 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params);
+#endif
+
+#ifndef GL_EXT_texture_env_dot3
+#define GL_EXT_texture_env_dot3 1
+#endif
+
+#ifndef GL_ATI_texture_mirror_once
+#define GL_ATI_texture_mirror_once 1
+#endif
+
+#ifndef GL_NV_fence
+#define GL_NV_fence 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *);
+GLAPI GLboolean APIENTRY glIsFenceNV (GLuint);
+GLAPI GLboolean APIENTRY glTestFenceNV (GLuint);
+GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glFinishFenceNV (GLuint);
+GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences);
+typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences);
+typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence);
+typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence);
+typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);
+typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
+#endif
+
+#ifndef GL_NV_evaluators
+#define GL_NV_evaluators 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *);
+GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *);
+GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points);
+typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points);
+typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode);
+#endif
+
+#ifndef GL_NV_packed_depth_stencil
+#define GL_NV_packed_depth_stencil 1
+#endif
+
+#ifndef GL_NV_register_combiners2
+#define GL_NV_register_combiners2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_NV_texture_compression_vtc
+#define GL_NV_texture_compression_vtc 1
+#endif
+
+#ifndef GL_NV_texture_rectangle
+#define GL_NV_texture_rectangle 1
+#endif
+
+#ifndef GL_NV_texture_shader
+#define GL_NV_texture_shader 1
+#endif
+
+#ifndef GL_NV_texture_shader2
+#define GL_NV_texture_shader2 1
+#endif
+
+#ifndef GL_NV_vertex_array_range2
+#define GL_NV_vertex_array_range2 1
+#endif
+
+#ifndef GL_NV_vertex_program
+#define GL_NV_vertex_program 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *);
+GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *);
+GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *);
+GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *);
+GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *);
+GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *);
+GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *);
+GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *);
+GLAPI GLboolean APIENTRY glIsProgramNV (GLuint);
+GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *);
+GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *);
+GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *);
+GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *);
+GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *);
+GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *);
+GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum);
+GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble);
+GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat);
+GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort);
+GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte);
+GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *);
+GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *);
+GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *);
+GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *);
+GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *);
+GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *);
+GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *);
+GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *);
+GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *);
+GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences);
+typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id);
+typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs);
+typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs);
+typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program);
+typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
+typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs);
+typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v);
+#endif
+
+#ifndef GL_SGIX_texture_coordinate_clamp
+#define GL_SGIX_texture_coordinate_clamp 1
+#endif
+
+#ifndef GL_SGIX_scalebias_hint
+#define GL_SGIX_scalebias_hint 1
+#endif
+
+#ifndef GL_OML_interlace
+#define GL_OML_interlace 1
+#endif
+
+#ifndef GL_OML_subsample
+#define GL_OML_subsample 1
+#endif
+
+#ifndef GL_OML_resample
+#define GL_OML_resample 1
+#endif
+
+#ifndef GL_NV_copy_depth_to_color
+#define GL_NV_copy_depth_to_color 1
+#endif
+
+#ifndef GL_ATI_envmap_bumpmap
+#define GL_ATI_envmap_bumpmap 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *);
+GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *);
+GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *);
+GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param);
+typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param);
+typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param);
+typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param);
+#endif
+
+#ifndef GL_ATI_fragment_shader
+#define GL_ATI_fragment_shader 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint);
+GLAPI void APIENTRY glBindFragmentShaderATI (GLuint);
+GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint);
+GLAPI void APIENTRY glBeginFragmentShaderATI (void);
+GLAPI void APIENTRY glEndFragmentShaderATI (void);
+GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum);
+GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum);
+GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range);
+typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void);
+typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void);
+typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle);
+typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle);
+typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
+typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
+typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
+typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
+typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
+typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
+typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value);
+#endif
+
+#ifndef GL_ATI_pn_triangles
+#define GL_ATI_pn_triangles 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint);
+GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param);
+#endif
+
+#ifndef GL_ATI_vertex_array_object
+#define GL_ATI_vertex_array_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum);
+GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint);
+GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum);
+GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glFreeObjectBufferATI (GLuint);
+GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint);
+GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint);
+GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage);
+typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve);
+typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
+typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
+typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_EXT_vertex_shader
+#define GL_EXT_vertex_shader 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBeginVertexShaderEXT (void);
+GLAPI void APIENTRY glEndVertexShaderEXT (void);
+GLAPI void APIENTRY glBindVertexShaderEXT (GLuint);
+GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint);
+GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint);
+GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint);
+GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum);
+GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum);
+GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint);
+GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint);
+GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *);
+GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *);
+GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *);
+GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *);
+GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *);
+GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *);
+GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *);
+GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *);
+GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *);
+GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint);
+GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint);
+GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum);
+GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum);
+GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum);
+GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum);
+GLAPI GLuint APIENTRY glBindParameterEXT (GLenum);
+GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum);
+GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *);
+GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *);
+GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *);
+GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *);
+GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void);
+typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void);
+typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id);
+typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range);
+typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1);
+typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2);
+typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3);
+typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
+typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
+typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);
+typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);
+typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components);
+typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr);
+typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr);
+typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr);
+typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr);
+typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr);
+typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr);
+typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr);
+typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr);
+typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr);
+typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr);
+typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr);
+typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);
+typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value);
+typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value);
+typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value);
+typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value);
+typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value);
+typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap);
+typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
+typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
+typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data);
+typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
+typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
+typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
+typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
+#endif
+
+#ifndef GL_ATI_vertex_streams
+#define GL_ATI_vertex_streams 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort);
+GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *);
+GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint);
+GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *);
+GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat);
+GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *);
+GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble);
+GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *);
+GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort);
+GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *);
+GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint);
+GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *);
+GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *);
+GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *);
+GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *);
+GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint);
+GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *);
+GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *);
+GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *);
+GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *);
+GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *);
+GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *);
+GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *);
+GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte);
+GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *);
+GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *);
+GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint);
+GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *);
+GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *);
+GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *);
+GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum);
+GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint);
+GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream);
+typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param);
+#endif
+
+#ifndef GL_ATI_element_array
+#define GL_ATI_element_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *);
+GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei);
+GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count);
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count);
+#endif
+
+#ifndef GL_SUN_mesh_array
+#define GL_SUN_mesh_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width);
+#endif
+
+#ifndef GL_SUN_slice_accum
+#define GL_SUN_slice_accum 1
+#endif
+
+#ifndef GL_NV_multisample_filter_hint
+#define GL_NV_multisample_filter_hint 1
+#endif
+
+#ifndef GL_NV_depth_clamp
+#define GL_NV_depth_clamp 1
+#endif
+
+#ifndef GL_NV_occlusion_query
+#define GL_NV_occlusion_query 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *);
+GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *);
+GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint);
+GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint);
+GLAPI void APIENTRY glEndOcclusionQueryNV (void);
+GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids);
+typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids);
+typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void);
+typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params);
+#endif
+
+#ifndef GL_NV_point_sprite
+#define GL_NV_point_sprite 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint);
+GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
+#endif
+
+#ifndef GL_NV_texture_shader3
+#define GL_NV_texture_shader3 1
+#endif
+
+#ifndef GL_NV_vertex_program1_1
+#define GL_NV_vertex_program1_1 1
+#endif
+
+#ifndef GL_EXT_shadow_funcs
+#define GL_EXT_shadow_funcs 1
+#endif
+
+#ifndef GL_EXT_stencil_two_side
+#define GL_EXT_stencil_two_side 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face);
+#endif
+
+#ifndef GL_ATI_text_fragment_shader
+#define GL_ATI_text_fragment_shader 1
+#endif
+
+#ifndef GL_APPLE_client_storage
+#define GL_APPLE_client_storage 1
+#endif
+
+#ifndef GL_APPLE_element_array
+#define GL_APPLE_element_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *);
+GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei);
+GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei);
+GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei);
+GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count);
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount);
+#endif
+
+#ifndef GL_APPLE_fence
+#define GL_APPLE_fence 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *);
+GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *);
+GLAPI void APIENTRY glSetFenceAPPLE (GLuint);
+GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint);
+GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint);
+GLAPI void APIENTRY glFinishFenceAPPLE (GLuint);
+GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint);
+GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences);
+typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences);
+typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence);
+typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence);
+typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence);
+typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence);
+typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name);
+typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name);
+#endif
+
+#ifndef GL_APPLE_vertex_array_object
+#define GL_APPLE_vertex_array_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint);
+GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, const GLuint *);
+GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array);
+typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays);
+typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays);
+typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array);
+#endif
+
+#ifndef GL_APPLE_vertex_array_range
+#define GL_APPLE_vertex_array_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *);
+GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *);
+GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer);
+typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer);
+typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param);
+#endif
+
+#ifndef GL_APPLE_ycbcr_422
+#define GL_APPLE_ycbcr_422 1
+#endif
+
+#ifndef GL_S3_s3tc
+#define GL_S3_s3tc 1
+#endif
+
+#ifndef GL_ATI_draw_buffers
+#define GL_ATI_draw_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs);
+#endif
+
+#ifndef GL_ATI_pixel_format_float
+#define GL_ATI_pixel_format_float 1
+/* This is really a WGL extension, but defines some associated GL enums.
+ * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string.
+ */
+#endif
+
+#ifndef GL_ATI_texture_env_combine3
+#define GL_ATI_texture_env_combine3 1
+#endif
+
+#ifndef GL_ATI_texture_float
+#define GL_ATI_texture_float 1
+#endif
+
+#ifndef GL_NV_float_buffer
+#define GL_NV_float_buffer 1
+#endif
+
+#ifndef GL_NV_fragment_program
+#define GL_NV_fragment_program 1
+/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *);
+GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *);
+GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *);
+GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v);
+typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v);
+typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params);
+#endif
+
+#ifndef GL_NV_half_float
+#define GL_NV_half_float 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV);
+GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV);
+GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *);
+GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *);
+GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *);
+GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *);
+GLAPI void APIENTRY glFogCoordhNV (GLhalfNV);
+GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *);
+GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV);
+GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *);
+GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV);
+GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *);
+GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *);
+GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *);
+GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *);
+GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *);
+GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *);
+GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *);
+GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y);
+typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z);
+typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
+typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz);
+typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
+typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha);
+typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s);
+typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t);
+typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r);
+typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
+typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog);
+typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight);
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+#endif
+
+#ifndef GL_NV_pixel_data_range
+#define GL_NV_pixel_data_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *);
+GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer);
+typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target);
+#endif
+
+#ifndef GL_NV_primitive_restart
+#define GL_NV_primitive_restart 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPrimitiveRestartNV (void);
+GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void);
+typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index);
+#endif
+
+#ifndef GL_NV_texture_expand_normal
+#define GL_NV_texture_expand_normal 1
+#endif
+
+#ifndef GL_NV_vertex_program2
+#define GL_NV_vertex_program2 1
+#endif
+
+#ifndef GL_ATI_map_object_buffer
+#define GL_ATI_map_object_buffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint);
+GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer);
+#endif
+
+#ifndef GL_ATI_separate_stencil
+#define GL_ATI_separate_stencil 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum);
+GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
+#endif
+
+#ifndef GL_ATI_vertex_attrib_array_object
+#define GL_ATI_vertex_attrib_array_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint);
+GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_OES_read_format
+#define GL_OES_read_format 1
+#endif
+
+#ifndef GL_EXT_depth_bounds_test
+#define GL_EXT_depth_bounds_test 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax);
+#endif
+
+#ifndef GL_EXT_texture_mirror_clamp
+#define GL_EXT_texture_mirror_clamp 1
+#endif
+
+#ifndef GL_EXT_blend_equation_separate
+#define GL_EXT_blend_equation_separate 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha);
+#endif
+
+#ifndef GL_MESA_pack_invert
+#define GL_MESA_pack_invert 1
+#endif
+
+#ifndef GL_MESA_ycbcr_texture
+#define GL_MESA_ycbcr_texture 1
+#endif
+
+#ifndef GL_EXT_pixel_buffer_object
+#define GL_EXT_pixel_buffer_object 1
+#endif
+
+#ifndef GL_NV_fragment_program_option
+#define GL_NV_fragment_program_option 1
+#endif
+
+#ifndef GL_NV_fragment_program2
+#define GL_NV_fragment_program2 1
+#endif
+
+#ifndef GL_NV_vertex_program2_option
+#define GL_NV_vertex_program2_option 1
+#endif
+
+#ifndef GL_NV_vertex_program3
+#define GL_NV_vertex_program3 1
+#endif
+
+#ifndef GL_EXT_framebuffer_object
+#define GL_EXT_framebuffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint);
+GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *);
+GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei);
+GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *);
+GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint);
+GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *);
+GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum);
+GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint);
+GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint);
+GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint);
+GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint);
+GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGenerateMipmapEXT (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers);
+typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers);
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer);
+typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer);
+typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers);
+typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers);
+typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target);
+#endif
+
+#ifndef GL_GREMEDY_string_marker
+#define GL_GREMEDY_string_marker 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string);
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/glfbdev.h b/nx-X11/extras/Mesa/include/GL/glfbdev.h
new file mode 100644
index 000000000..6af3ac314
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/glfbdev.h
@@ -0,0 +1,148 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef GLFBDEV_H
+#define GLFBDEV_H
+
+
+/* avoid including linux/fb.h */
+struct fb_fix_screeninfo;
+struct fb_var_screeninfo;
+
+
+/* public types */
+typedef struct GLFBDevVisualRec *GLFBDevVisualPtr;
+typedef struct GLFBDevBufferRec *GLFBDevBufferPtr;
+typedef struct GLFBDevContextRec *GLFBDevContextPtr;
+
+
+/* API version */
+#define GLFBDEV_VERSION_1_0 1
+
+
+/* For glFBDevCreateVisual */
+#define GLFBDEV_DOUBLE_BUFFER 100
+#define GLFBDEV_COLOR_INDEX 101
+#define GLFBDEV_DEPTH_SIZE 102
+#define GLFBDEV_STENCIL_SIZE 103
+#define GLFBDEV_ACCUM_SIZE 104
+#define GLFBDEV_LEVEL 105
+#define GLFBDEV_NONE 0
+
+/* For glFBDevGetString */
+#define GLFBDEV_VERSION 200
+#define GLFBDEV_VENDOR 201
+
+
+/* Misc functions */
+
+extern const char *
+glFBDevGetString( int str );
+
+
+typedef void (*GLFBDevProc)();
+
+
+extern const GLFBDevProc
+glFBDevGetProcAddress( const char *procName );
+
+
+
+/**
+ * Create a GLFBDevVisual.
+ * \param fixInfo - needed to get the visual types, etc.
+ * \param varInfo - needed to get the bits_per_pixel, etc.
+ * \param attribs - for requesting depth, stencil, accum buffers, etc.
+ */
+extern GLFBDevVisualPtr
+glFBDevCreateVisual( const struct fb_fix_screeninfo *fixInfo,
+ const struct fb_var_screeninfo *varInfo,
+ const int *attribs );
+
+extern void
+glFBDevDestroyVisual( GLFBDevVisualPtr visual );
+
+extern int
+glFBDevGetVisualAttrib( const GLFBDevVisualPtr visual, int attrib);
+
+
+
+/**
+ * Create a GLFBDevBuffer.
+ * \param fixInfo, varInfo - needed in order to get the screen size
+ * (resolution), etc.
+ * \param visual - as returned by glFBDevCreateVisual()
+ * \param frontBuffer - address of front color buffer
+ * \param backBuffer - address of back color buffer (may be NULL)
+ * \param size - size of the color buffer(s) in bytes.
+ */
+extern GLFBDevBufferPtr
+glFBDevCreateBuffer( const struct fb_fix_screeninfo *fixInfo,
+ const struct fb_var_screeninfo *varInfo,
+ const GLFBDevVisualPtr visual,
+ void *frontBuffer, void *backBuffer, size_t size );
+
+extern void
+glFBDevDestroyBuffer( GLFBDevBufferPtr buffer );
+
+extern int
+glFBDevGetBufferAttrib( const GLFBDevBufferPtr buffer, int attrib);
+
+extern GLFBDevBufferPtr
+glFBDevGetCurrentDrawBuffer( void );
+
+extern GLFBDevBufferPtr
+glFBDevGetCurrentReadBuffer( void );
+
+extern void
+glFBDevSwapBuffers( GLFBDevBufferPtr buffer );
+
+
+
+/**
+ * Create a GLFBDevContext.
+ * \param visual - as created by glFBDevCreateVisual.
+ * \param share - specifies another context with which to share textures,
+ * display lists, etc. (may be NULL).
+ */
+extern GLFBDevContextPtr
+glFBDevCreateContext( const GLFBDevVisualPtr visual, GLFBDevContextPtr share );
+
+extern void
+glFBDevDestroyContext( GLFBDevContextPtr context );
+
+extern int
+glFBDevGetContextAttrib( const GLFBDevContextPtr context, int attrib);
+
+extern GLFBDevContextPtr
+glFBDevGetCurrentContext( void );
+
+extern int
+glFBDevMakeCurrent( GLFBDevContextPtr context,
+ GLFBDevBufferPtr drawBuffer,
+ GLFBDevBufferPtr readBuffer );
+
+
+#endif /* GLFBDEV_H */
diff --git a/nx-X11/extras/Mesa/include/GL/glu.h b/nx-X11/extras/Mesa/include/GL/glu.h
new file mode 100644
index 000000000..c0bac75a8
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/glu.h
@@ -0,0 +1,340 @@
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+#ifndef __glu_h__
+#define __glu_h__
+
+#if defined(USE_MGL_NAMESPACE)
+#include "glu_mangle.h"
+#endif
+
+#include <GL/gl.h>
+
+#ifndef GLAPIENTRY
+#define GLAPIENTRY
+#endif
+
+#ifndef GLAPIENTRYP
+#define GLAPIENTRYP GLAPIENTRY *
+#endif
+
+#ifndef GLAPI
+#define GLAPI
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*************************************************************/
+
+/* Extensions */
+#define GLU_EXT_object_space_tess 1
+#define GLU_EXT_nurbs_tessellator 1
+
+/* Boolean */
+#define GLU_FALSE 0
+#define GLU_TRUE 1
+
+/* Version */
+#define GLU_VERSION_1_1 1
+#define GLU_VERSION_1_2 1
+#define GLU_VERSION_1_3 1
+
+/* StringName */
+#define GLU_VERSION 100800
+#define GLU_EXTENSIONS 100801
+
+/* ErrorCode */
+#define GLU_INVALID_ENUM 100900
+#define GLU_INVALID_VALUE 100901
+#define GLU_OUT_OF_MEMORY 100902
+#define GLU_INCOMPATIBLE_GL_VERSION 100903
+#define GLU_INVALID_OPERATION 100904
+
+/* NurbsDisplay */
+/* GLU_FILL */
+#define GLU_OUTLINE_POLYGON 100240
+#define GLU_OUTLINE_PATCH 100241
+
+/* NurbsCallback */
+#define GLU_NURBS_ERROR 100103
+#define GLU_ERROR 100103
+#define GLU_NURBS_BEGIN 100164
+#define GLU_NURBS_BEGIN_EXT 100164
+#define GLU_NURBS_VERTEX 100165
+#define GLU_NURBS_VERTEX_EXT 100165
+#define GLU_NURBS_NORMAL 100166
+#define GLU_NURBS_NORMAL_EXT 100166
+#define GLU_NURBS_COLOR 100167
+#define GLU_NURBS_COLOR_EXT 100167
+#define GLU_NURBS_TEXTURE_COORD 100168
+#define GLU_NURBS_TEX_COORD_EXT 100168
+#define GLU_NURBS_END 100169
+#define GLU_NURBS_END_EXT 100169
+#define GLU_NURBS_BEGIN_DATA 100170
+#define GLU_NURBS_BEGIN_DATA_EXT 100170
+#define GLU_NURBS_VERTEX_DATA 100171
+#define GLU_NURBS_VERTEX_DATA_EXT 100171
+#define GLU_NURBS_NORMAL_DATA 100172
+#define GLU_NURBS_NORMAL_DATA_EXT 100172
+#define GLU_NURBS_COLOR_DATA 100173
+#define GLU_NURBS_COLOR_DATA_EXT 100173
+#define GLU_NURBS_TEXTURE_COORD_DATA 100174
+#define GLU_NURBS_TEX_COORD_DATA_EXT 100174
+#define GLU_NURBS_END_DATA 100175
+#define GLU_NURBS_END_DATA_EXT 100175
+
+/* NurbsError */
+#define GLU_NURBS_ERROR1 100251
+#define GLU_NURBS_ERROR2 100252
+#define GLU_NURBS_ERROR3 100253
+#define GLU_NURBS_ERROR4 100254
+#define GLU_NURBS_ERROR5 100255
+#define GLU_NURBS_ERROR6 100256
+#define GLU_NURBS_ERROR7 100257
+#define GLU_NURBS_ERROR8 100258
+#define GLU_NURBS_ERROR9 100259
+#define GLU_NURBS_ERROR10 100260
+#define GLU_NURBS_ERROR11 100261
+#define GLU_NURBS_ERROR12 100262
+#define GLU_NURBS_ERROR13 100263
+#define GLU_NURBS_ERROR14 100264
+#define GLU_NURBS_ERROR15 100265
+#define GLU_NURBS_ERROR16 100266
+#define GLU_NURBS_ERROR17 100267
+#define GLU_NURBS_ERROR18 100268
+#define GLU_NURBS_ERROR19 100269
+#define GLU_NURBS_ERROR20 100270
+#define GLU_NURBS_ERROR21 100271
+#define GLU_NURBS_ERROR22 100272
+#define GLU_NURBS_ERROR23 100273
+#define GLU_NURBS_ERROR24 100274
+#define GLU_NURBS_ERROR25 100275
+#define GLU_NURBS_ERROR26 100276
+#define GLU_NURBS_ERROR27 100277
+#define GLU_NURBS_ERROR28 100278
+#define GLU_NURBS_ERROR29 100279
+#define GLU_NURBS_ERROR30 100280
+#define GLU_NURBS_ERROR31 100281
+#define GLU_NURBS_ERROR32 100282
+#define GLU_NURBS_ERROR33 100283
+#define GLU_NURBS_ERROR34 100284
+#define GLU_NURBS_ERROR35 100285
+#define GLU_NURBS_ERROR36 100286
+#define GLU_NURBS_ERROR37 100287
+
+/* NurbsProperty */
+#define GLU_AUTO_LOAD_MATRIX 100200
+#define GLU_CULLING 100201
+#define GLU_SAMPLING_TOLERANCE 100203
+#define GLU_DISPLAY_MODE 100204
+#define GLU_PARAMETRIC_TOLERANCE 100202
+#define GLU_SAMPLING_METHOD 100205
+#define GLU_U_STEP 100206
+#define GLU_V_STEP 100207
+#define GLU_NURBS_MODE 100160
+#define GLU_NURBS_MODE_EXT 100160
+#define GLU_NURBS_TESSELLATOR 100161
+#define GLU_NURBS_TESSELLATOR_EXT 100161
+#define GLU_NURBS_RENDERER 100162
+#define GLU_NURBS_RENDERER_EXT 100162
+
+/* NurbsSampling */
+#define GLU_OBJECT_PARAMETRIC_ERROR 100208
+#define GLU_OBJECT_PARAMETRIC_ERROR_EXT 100208
+#define GLU_OBJECT_PATH_LENGTH 100209
+#define GLU_OBJECT_PATH_LENGTH_EXT 100209
+#define GLU_PATH_LENGTH 100215
+#define GLU_PARAMETRIC_ERROR 100216
+#define GLU_DOMAIN_DISTANCE 100217
+
+/* NurbsTrim */
+#define GLU_MAP1_TRIM_2 100210
+#define GLU_MAP1_TRIM_3 100211
+
+/* QuadricDrawStyle */
+#define GLU_POINT 100010
+#define GLU_LINE 100011
+#define GLU_FILL 100012
+#define GLU_SILHOUETTE 100013
+
+/* QuadricCallback */
+/* GLU_ERROR */
+
+/* QuadricNormal */
+#define GLU_SMOOTH 100000
+#define GLU_FLAT 100001
+#define GLU_NONE 100002
+
+/* QuadricOrientation */
+#define GLU_OUTSIDE 100020
+#define GLU_INSIDE 100021
+
+/* TessCallback */
+#define GLU_TESS_BEGIN 100100
+#define GLU_BEGIN 100100
+#define GLU_TESS_VERTEX 100101
+#define GLU_VERTEX 100101
+#define GLU_TESS_END 100102
+#define GLU_END 100102
+#define GLU_TESS_ERROR 100103
+#define GLU_TESS_EDGE_FLAG 100104
+#define GLU_EDGE_FLAG 100104
+#define GLU_TESS_COMBINE 100105
+#define GLU_TESS_BEGIN_DATA 100106
+#define GLU_TESS_VERTEX_DATA 100107
+#define GLU_TESS_END_DATA 100108
+#define GLU_TESS_ERROR_DATA 100109
+#define GLU_TESS_EDGE_FLAG_DATA 100110
+#define GLU_TESS_COMBINE_DATA 100111
+
+/* TessContour */
+#define GLU_CW 100120
+#define GLU_CCW 100121
+#define GLU_INTERIOR 100122
+#define GLU_EXTERIOR 100123
+#define GLU_UNKNOWN 100124
+
+/* TessProperty */
+#define GLU_TESS_WINDING_RULE 100140
+#define GLU_TESS_BOUNDARY_ONLY 100141
+#define GLU_TESS_TOLERANCE 100142
+
+/* TessError */
+#define GLU_TESS_ERROR1 100151
+#define GLU_TESS_ERROR2 100152
+#define GLU_TESS_ERROR3 100153
+#define GLU_TESS_ERROR4 100154
+#define GLU_TESS_ERROR5 100155
+#define GLU_TESS_ERROR6 100156
+#define GLU_TESS_ERROR7 100157
+#define GLU_TESS_ERROR8 100158
+#define GLU_TESS_MISSING_BEGIN_POLYGON 100151
+#define GLU_TESS_MISSING_BEGIN_CONTOUR 100152
+#define GLU_TESS_MISSING_END_POLYGON 100153
+#define GLU_TESS_MISSING_END_CONTOUR 100154
+#define GLU_TESS_COORD_TOO_LARGE 100155
+#define GLU_TESS_NEED_COMBINE_CALLBACK 100156
+
+/* TessWinding */
+#define GLU_TESS_WINDING_ODD 100130
+#define GLU_TESS_WINDING_NONZERO 100131
+#define GLU_TESS_WINDING_POSITIVE 100132
+#define GLU_TESS_WINDING_NEGATIVE 100133
+#define GLU_TESS_WINDING_ABS_GEQ_TWO 100134
+
+/*************************************************************/
+
+
+#ifdef __cplusplus
+class GLUnurbs;
+class GLUquadric;
+class GLUtesselator;
+#else
+typedef struct GLUnurbs GLUnurbs;
+typedef struct GLUquadric GLUquadric;
+typedef struct GLUtesselator GLUtesselator;
+#endif
+
+typedef GLUnurbs GLUnurbsObj;
+typedef GLUquadric GLUquadricObj;
+typedef GLUtesselator GLUtesselatorObj;
+typedef GLUtesselator GLUtriangulatorObj;
+
+#define GLU_TESS_MAX_COORD 1.0e150
+
+/* Internal convenience typedefs */
+typedef void (GLAPIENTRYP _GLUfuncptr)();
+
+GLAPI void GLAPIENTRY gluBeginCurve (GLUnurbs* nurb);
+GLAPI void GLAPIENTRY gluBeginPolygon (GLUtesselator* tess);
+GLAPI void GLAPIENTRY gluBeginSurface (GLUnurbs* nurb);
+GLAPI void GLAPIENTRY gluBeginTrim (GLUnurbs* nurb);
+GLAPI GLint GLAPIENTRY gluBuild1DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
+GLAPI GLint GLAPIENTRY gluBuild1DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void *data);
+GLAPI GLint GLAPIENTRY gluBuild2DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
+GLAPI GLint GLAPIENTRY gluBuild2DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data);
+GLAPI GLint GLAPIENTRY gluBuild3DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
+GLAPI GLint GLAPIENTRY gluBuild3DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data);
+GLAPI GLboolean GLAPIENTRY gluCheckExtension (const GLubyte *extName, const GLubyte *extString);
+GLAPI void GLAPIENTRY gluCylinder (GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks);
+GLAPI void GLAPIENTRY gluDeleteNurbsRenderer (GLUnurbs* nurb);
+GLAPI void GLAPIENTRY gluDeleteQuadric (GLUquadric* quad);
+GLAPI void GLAPIENTRY gluDeleteTess (GLUtesselator* tess);
+GLAPI void GLAPIENTRY gluDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops);
+GLAPI void GLAPIENTRY gluEndCurve (GLUnurbs* nurb);
+GLAPI void GLAPIENTRY gluEndPolygon (GLUtesselator* tess);
+GLAPI void GLAPIENTRY gluEndSurface (GLUnurbs* nurb);
+GLAPI void GLAPIENTRY gluEndTrim (GLUnurbs* nurb);
+GLAPI const GLubyte * GLAPIENTRY gluErrorString (GLenum error);
+GLAPI void GLAPIENTRY gluGetNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat* data);
+GLAPI const GLubyte * GLAPIENTRY gluGetString (GLenum name);
+GLAPI void GLAPIENTRY gluGetTessProperty (GLUtesselator* tess, GLenum which, GLdouble* data);
+GLAPI void GLAPIENTRY gluLoadSamplingMatrices (GLUnurbs* nurb, const GLfloat *model, const GLfloat *perspective, const GLint *view);
+GLAPI void GLAPIENTRY gluLookAt (GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ, GLdouble upX, GLdouble upY, GLdouble upZ);
+GLAPI GLUnurbs* GLAPIENTRY gluNewNurbsRenderer (void);
+GLAPI GLUquadric* GLAPIENTRY gluNewQuadric (void);
+GLAPI GLUtesselator* GLAPIENTRY gluNewTess (void);
+GLAPI void GLAPIENTRY gluNextContour (GLUtesselator* tess, GLenum type);
+GLAPI void GLAPIENTRY gluNurbsCallback (GLUnurbs* nurb, GLenum which, _GLUfuncptr CallBackFunc);
+GLAPI void GLAPIENTRY gluNurbsCallbackData (GLUnurbs* nurb, GLvoid* userData);
+GLAPI void GLAPIENTRY gluNurbsCallbackDataEXT (GLUnurbs* nurb, GLvoid* userData);
+GLAPI void GLAPIENTRY gluNurbsCurve (GLUnurbs* nurb, GLint knotCount, GLfloat *knots, GLint stride, GLfloat *control, GLint order, GLenum type);
+GLAPI void GLAPIENTRY gluNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat value);
+GLAPI void GLAPIENTRY gluNurbsSurface (GLUnurbs* nurb, GLint sKnotCount, GLfloat* sKnots, GLint tKnotCount, GLfloat* tKnots, GLint sStride, GLint tStride, GLfloat* control, GLint sOrder, GLint tOrder, GLenum type);
+GLAPI void GLAPIENTRY gluOrtho2D (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top);
+GLAPI void GLAPIENTRY gluPartialDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops, GLdouble start, GLdouble sweep);
+GLAPI void GLAPIENTRY gluPerspective (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
+GLAPI void GLAPIENTRY gluPickMatrix (GLdouble x, GLdouble y, GLdouble delX, GLdouble delY, GLint *viewport);
+GLAPI GLint GLAPIENTRY gluProject (GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* winX, GLdouble* winY, GLdouble* winZ);
+GLAPI void GLAPIENTRY gluPwlCurve (GLUnurbs* nurb, GLint count, GLfloat* data, GLint stride, GLenum type);
+GLAPI void GLAPIENTRY gluQuadricCallback (GLUquadric* quad, GLenum which, _GLUfuncptr CallBackFunc);
+GLAPI void GLAPIENTRY gluQuadricDrawStyle (GLUquadric* quad, GLenum draw);
+GLAPI void GLAPIENTRY gluQuadricNormals (GLUquadric* quad, GLenum normal);
+GLAPI void GLAPIENTRY gluQuadricOrientation (GLUquadric* quad, GLenum orientation);
+GLAPI void GLAPIENTRY gluQuadricTexture (GLUquadric* quad, GLboolean texture);
+GLAPI GLint GLAPIENTRY gluScaleImage (GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void *dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid* dataOut);
+GLAPI void GLAPIENTRY gluSphere (GLUquadric* quad, GLdouble radius, GLint slices, GLint stacks);
+GLAPI void GLAPIENTRY gluTessBeginContour (GLUtesselator* tess);
+GLAPI void GLAPIENTRY gluTessBeginPolygon (GLUtesselator* tess, GLvoid* data);
+GLAPI void GLAPIENTRY gluTessCallback (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc);
+GLAPI void GLAPIENTRY gluTessEndContour (GLUtesselator* tess);
+GLAPI void GLAPIENTRY gluTessEndPolygon (GLUtesselator* tess);
+GLAPI void GLAPIENTRY gluTessNormal (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ);
+GLAPI void GLAPIENTRY gluTessProperty (GLUtesselator* tess, GLenum which, GLdouble data);
+GLAPI void GLAPIENTRY gluTessVertex (GLUtesselator* tess, GLdouble *location, GLvoid* data);
+GLAPI GLint GLAPIENTRY gluUnProject (GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* objX, GLdouble* objY, GLdouble* objZ);
+GLAPI GLint GLAPIENTRY gluUnProject4 (GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble nearVal, GLdouble farVal, GLdouble* objX, GLdouble* objY, GLdouble* objZ, GLdouble* objW);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __glu_h__ */
diff --git a/nx-X11/extras/Mesa/include/GL/glu_mangle.h b/nx-X11/extras/Mesa/include/GL/glu_mangle.h
new file mode 100644
index 000000000..9c25aa864
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/glu_mangle.h
@@ -0,0 +1,86 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.0
+ * Copyright (C) 1995-1998 Brian Paul
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#ifndef GLU_MANGLE_H
+#define GLU_MANGLE_H
+
+
+#define gluLookAt mgluLookAt
+#define gluOrtho2D mgluOrtho2D
+#define gluPerspective mgluPerspective
+#define gluPickMatrix mgluPickMatrix
+#define gluProject mgluProject
+#define gluUnProject mgluUnProject
+#define gluErrorString mgluErrorString
+#define gluScaleImage mgluScaleImage
+#define gluBuild1DMipmaps mgluBuild1DMipmaps
+#define gluBuild2DMipmaps mgluBuild2DMipmaps
+#define gluNewQuadric mgluNewQuadric
+#define gluDeleteQuadric mgluDeleteQuadric
+#define gluQuadricDrawStyle mgluQuadricDrawStyle
+#define gluQuadricOrientation mgluQuadricOrientation
+#define gluQuadricNormals mgluQuadricNormals
+#define gluQuadricTexture mgluQuadricTexture
+#define gluQuadricCallback mgluQuadricCallback
+#define gluCylinder mgluCylinder
+#define gluSphere mgluSphere
+#define gluDisk mgluDisk
+#define gluPartialDisk mgluPartialDisk
+#define gluNewNurbsRenderer mgluNewNurbsRenderer
+#define gluDeleteNurbsRenderer mgluDeleteNurbsRenderer
+#define gluLoadSamplingMatrices mgluLoadSamplingMatrices
+#define gluNurbsProperty mgluNurbsProperty
+#define gluGetNurbsProperty mgluGetNurbsProperty
+#define gluBeginCurve mgluBeginCurve
+#define gluEndCurve mgluEndCurve
+#define gluNurbsCurve mgluNurbsCurve
+#define gluBeginSurface mgluBeginSurface
+#define gluEndSurface mgluEndSurface
+#define gluNurbsSurface mgluNurbsSurface
+#define gluBeginTrim mgluBeginTrim
+#define gluEndTrim mgluEndTrim
+#define gluPwlCurve mgluPwlCurve
+#define gluNurbsCallback mgluNurbsCallback
+#define gluNewTess mgluNewTess
+#define gluDeleteTess mgluDeleteTess
+#define gluTessBeginPolygon mgluTessBeginPolygon
+#define gluTessBeginContour mgluTessBeginContour
+#define gluTessVertex mgluTessVertex
+#define gluTessEndPolygon mgluTessEndPolygon
+#define gluTessEndContour mgluTessEndContour
+#define gluTessProperty mgluTessProperty
+#define gluTessNormal mgluTessNormal
+#define gluTessCallback mgluTessCallback
+#define gluGetTessProperty mgluGetTessProperty
+#define gluBeginPolygon mgluBeginPolygon
+#define gluNextContour mgluNextContour
+#define gluEndPolygon mgluEndPolygon
+#define gluGetString mgluGetString
+#define gluBuild1DMipmapLevels mgluBuild1DMipmapLevels
+#define gluBuild2DMipmapLevels mgluBuild2DMipmapLevels
+#define gluBuild3DMipmapLevels mgluBuild3DMipmapLevels
+#define gluBuild3DMipmaps mgluBuild3DMipmaps
+#define gluCheckExtension mgluCheckExtension
+#define gluUnProject4 mgluUnProject4
+#define gluNurbsCallbackData mgluNurbsCallbackData
+#define gluNurbsCallbackDataEXT mgluNurbsCallbackDataEXT
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/glut.h b/nx-X11/extras/Mesa/include/GL/glut.h
new file mode 100644
index 000000000..23c740ee1
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/glut.h
@@ -0,0 +1,748 @@
+#ifndef __glut_h__
+#define __glut_h__
+
+/* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996, 1998. */
+
+/* This program is freely distributable without licensing fees and is
+ provided without guarantee or warrantee expressed or implied. This
+ program is -not- in the public domain. */
+
+#include <GL/gl.h>
+#include <GL/glu.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined(_WIN32)
+
+/* GLUT 3.7 now tries to avoid including <windows.h>
+ to avoid name space pollution, but Win32's <GL/gl.h>
+ needs APIENTRY and WINGDIAPI defined properly.
+
+ tjump@spgs.com contributes:
+ If users are building glut code on MS Windows, then they should
+ make sure they include windows.h early, let's not get into a
+ header definitions war since MS has proven it's capability to
+ change header dependencies w/o publishing they have done so.
+
+ So, let's not include windows.h here, as it's not really required and
+ MS own gl/gl.h *should* include it if the dependency is there. */
+
+/* To disable automatic library usage for GLUT, define GLUT_NO_LIB_PRAGMA
+ in your compile preprocessor options. */
+# if !defined(GLUT_BUILDING_LIB) && !defined(GLUT_NO_LIB_PRAGMA)
+# pragma comment (lib, "winmm.lib") /* link with Windows MultiMedia lib */
+/* To enable automatic SGI OpenGL for Windows library usage for GLUT,
+ define GLUT_USE_SGI_OPENGL in your compile preprocessor options. */
+# ifdef GLUT_USE_SGI_OPENGL
+# pragma comment (lib, "opengl.lib") /* link with SGI OpenGL for Windows lib */
+# pragma comment (lib, "glu.lib") /* link with SGI OpenGL Utility lib */
+# pragma comment (lib, "glut.lib") /* link with Win32 GLUT for SGI OpenGL lib */
+# else
+# pragma comment (lib, "opengl32.lib") /* link with Microsoft OpenGL lib */
+# pragma comment (lib, "glu32.lib") /* link with Microsoft OpenGL Utility lib */
+# pragma comment (lib, "glut32.lib") /* link with Win32 GLUT lib */
+# endif
+# endif
+
+/* To disable supression of annoying warnings about floats being promoted
+ to doubles, define GLUT_NO_WARNING_DISABLE in your compile preprocessor
+ options. */
+# ifndef GLUT_NO_WARNING_DISABLE
+# pragma warning (disable:4244) /* Disable bogus VC++ 4.2 conversion warnings. */
+# pragma warning (disable:4305) /* VC++ 5.0 version of above warning. */
+# endif
+
+/* Win32 has an annoying issue where there are multiple C run-time
+ libraries (CRTs). If the executable is linked with a different CRT
+ from the GLUT DLL, the GLUT DLL will not share the same CRT static
+ data seen by the executable. In particular, atexit callbacks registered
+ in the executable will not be called if GLUT calls its (different)
+ exit routine). GLUT is typically built with the
+ "/MD" option (the CRT with multithreading DLL support), but the Visual
+ C++ linker default is "/ML" (the single threaded CRT).
+
+ One workaround to this issue is requiring users to always link with
+ the same CRT as GLUT is compiled with. That requires users supply a
+ non-standard option. GLUT 3.7 has its own built-in workaround where
+ the executable's "exit" function pointer is covertly passed to GLUT.
+ GLUT then calls the executable's exit function pointer to ensure that
+ any "atexit" calls registered by the application are called if GLUT
+ needs to exit.
+
+ Note that the __glut*WithExit routines should NEVER be called directly.
+ To avoid the atexit workaround, #define GLUT_DISABLE_ATEXIT_HACK. */
+
+/* XXX This is from Win32's <process.h> */
+# if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__cdecl)
+ /* Define __cdecl for non-Microsoft compilers. */
+# define __cdecl
+# define GLUT_DEFINED___CDECL
+# endif
+# ifndef _CRTIMP
+# ifdef _NTSDK
+ /* Definition compatible with NT SDK */
+# define _CRTIMP
+# else
+ /* Current definition */
+# ifdef _DLL
+# define _CRTIMP __declspec(dllimport)
+# else
+# define _CRTIMP
+# endif
+# endif
+# define GLUT_DEFINED__CRTIMP
+# endif
+# ifndef GLUT_BUILDING_LIB
+extern _CRTIMP void __cdecl exit(int);
+# endif
+
+/* GLUT callback calling convention for Win32. */
+# define GLUTCALLBACK __cdecl
+
+/* for callback/function pointer defs */
+# define GLUTAPIENTRYV __cdecl
+
+/* glut-win32 specific macros, defined to prevent collision with
+ and redifinition of Windows system defs, also removes requirement of
+ pretty much any standard windows header from this file */
+
+#if (_MSC_VER >= 800) || defined(__MINGW32__) || defined(_STDCALL_SUPPORTED) || defined(__CYGWIN32__)
+# define GLUTAPIENTRY __stdcall
+#else
+# define GLUTAPIENTRY
+#endif
+
+/* GLUT API entry point declarations for Win32. */
+#if defined(GLUT_BUILDING_LIB) && defined(_DLL)
+# define GLUTAPI __declspec(dllexport)
+#elif defined(_DLL)
+# define GLUTAPI __declspec(dllimport)
+#else
+# define GLUTAPI extern
+#endif
+
+#if defined(_WIN32) && !defined(_WINDEF_) && !defined(MESA)
+# if !defined(MESA_MINWARN)
+# pragma message( "note: WINDOWS.H not included, providing Mesa definition of CALLBACK macro" )
+# pragma message( "----: and PROC typedef. If you receive compiler warnings about either ")
+# pragma message( "----: being multiply defined you should include WINDOWS.H priot to gl/glut.h" )
+# endif
+# define CALLBACK __stdcall
+typedef int (GLUTAPIENTRY *PROC)();
+typedef void *HGLRC;
+typedef void *HDC;
+typedef unsigned long COLORREF;
+#endif
+
+#if defined(_WIN32) && !defined(_WINGDI_) && !defined(MESA)
+# if !defined(MESA_MINWARN)
+# pragma message( "note: WINDOWS.H not included, providing Mesa definition of wgl functions" )
+# pragma message( "----: and macros. If you receive compiler warnings about any being multiply ")
+# pragma message( "----: defined you should include WINDOWS.H priot to gl/glut.h" )
+# endif
+# 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;
+# pragma warning( push )
+# pragma warning( disable : 4273 ) /* 'function' : inconsistent DLL linkage. dllexport assumed. */
+# define WGLAPI __declspec(dllimport)
+WGLAPI int GLAPIENTRY wglDeleteContext(HGLRC);
+WGLAPI int GLAPIENTRY wglMakeCurrent(HDC,HGLRC);
+WGLAPI int GLAPIENTRY wglSetPixelFormat(HDC, int, const PIXELFORMATDESCRIPTOR *);
+WGLAPI int GLAPIENTRY wglSwapBuffers(HDC hdc);
+WGLAPI HDC GLAPIENTRY wglGetCurrentDC(void);
+WGLAPI HGLRC GLAPIENTRY wglCreateContext(HDC);
+WGLAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC,int);
+WGLAPI HGLRC GLAPIENTRY wglGetCurrentContext(void);
+WGLAPI PROC GLAPIENTRY wglGetProcAddress(const char*);
+WGLAPI int GLAPIENTRY wglChoosePixelFormat(HDC, const PIXELFORMATDESCRIPTOR *);
+WGLAPI int GLAPIENTRY wglCopyContext(HGLRC, HGLRC, unsigned int);
+WGLAPI int GLAPIENTRY wglDeleteContext(HGLRC);
+WGLAPI int GLAPIENTRY wglDescribeLayerPlane(HDC, int, int, unsigned int,LPLAYERPLANEDESCRIPTOR);
+WGLAPI int GLAPIENTRY wglDescribePixelFormat(HDC,int, unsigned int, LPPIXELFORMATDESCRIPTOR);
+WGLAPI int GLAPIENTRY wglGetLayerPaletteEntries(HDC, int, int, int,COLORREF *);
+WGLAPI int GLAPIENTRY wglGetPixelFormat(HDC hdc);
+WGLAPI int GLAPIENTRY wglMakeCurrent(HDC, HGLRC);
+WGLAPI int GLAPIENTRY wglRealizeLayerPalette(HDC, int, int);
+WGLAPI int GLAPIENTRY wglSetLayerPaletteEntries(HDC, int, int, int,const COLORREF *);
+WGLAPI int GLAPIENTRY wglShareLists(HGLRC, HGLRC);
+WGLAPI int GLAPIENTRY wglSwapLayerBuffers(HDC, unsigned int);
+WGLAPI int GLAPIENTRY wglUseFontBitmapsA(HDC, unsigned long, unsigned long, unsigned long);
+WGLAPI int GLAPIENTRY wglUseFontBitmapsW(HDC, unsigned long, unsigned long, unsigned long);
+WGLAPI int GLAPIENTRY wglUseFontOutlinesA(HDC, unsigned long, unsigned long, unsigned long, float,float, int, LPGLYPHMETRICSFLOAT);
+WGLAPI int GLAPIENTRY wglUseFontOutlinesW(HDC, unsigned long, unsigned long, unsigned long, float,float, int, LPGLYPHMETRICSFLOAT);
+WGLAPI int GLAPIENTRY SwapBuffers(HDC);
+WGLAPI int GLAPIENTRY ChoosePixelFormat(HDC,const PIXELFORMATDESCRIPTOR *);
+WGLAPI int GLAPIENTRY DescribePixelFormat(HDC,int,unsigned int,LPPIXELFORMATDESCRIPTOR);
+WGLAPI int GLAPIENTRY GetPixelFormat(HDC);
+WGLAPI int GLAPIENTRY SetPixelFormat(HDC,int,const PIXELFORMATDESCRIPTOR *);
+# undef WGLAPI
+# pragma warning( pop )
+#endif
+
+#else /* _WIN32 not defined */
+
+/* Define GLUTAPIENTRY and GLUTCALLBACK to nothing if we aren't on Win32. */
+# define GLUTAPIENTRY GLAPIENTRY
+# define GLUTAPIENTRYV
+# define GLUTCALLBACK
+# define GLUTAPI extern
+
+#endif
+
+
+/**
+ GLUT API revision history:
+
+ GLUT_API_VERSION is updated to reflect incompatible GLUT
+ API changes (interface changes, semantic changes, deletions,
+ or additions).
+
+ GLUT_API_VERSION=1 First public release of GLUT. 11/29/94
+
+ GLUT_API_VERSION=2 Added support for OpenGL/GLX multisampling,
+ extension. Supports new input devices like tablet, dial and button
+ box, and Spaceball. Easy to query OpenGL extensions.
+
+ GLUT_API_VERSION=3 glutMenuStatus added.
+
+ GLUT_API_VERSION=4 glutInitDisplayString, glutWarpPointer,
+ glutBitmapLength, glutStrokeLength, glutWindowStatusFunc, dynamic
+ video resize subAPI, glutPostWindowRedisplay, glutKeyboardUpFunc,
+ glutSpecialUpFunc, glutIgnoreKeyRepeat, glutSetKeyRepeat,
+ glutJoystickFunc, glutForceJoystickFunc (NOT FINALIZED!).
+
+ GLUT_API_VERSION=5 glutGetProcAddress (added by BrianP)
+**/
+#ifndef GLUT_API_VERSION /* allow this to be overriden */
+#define GLUT_API_VERSION 5
+#endif
+
+/**
+ GLUT implementation revision history:
+
+ GLUT_XLIB_IMPLEMENTATION is updated to reflect both GLUT
+ API revisions and implementation revisions (ie, bug fixes).
+
+ GLUT_XLIB_IMPLEMENTATION=1 mjk's first public release of
+ GLUT Xlib-based implementation. 11/29/94
+
+ GLUT_XLIB_IMPLEMENTATION=2 mjk's second public release of
+ GLUT Xlib-based implementation providing GLUT version 2
+ interfaces.
+
+ GLUT_XLIB_IMPLEMENTATION=3 mjk's GLUT 2.2 images. 4/17/95
+
+ GLUT_XLIB_IMPLEMENTATION=4 mjk's GLUT 2.3 images. 6/?/95
+
+ GLUT_XLIB_IMPLEMENTATION=5 mjk's GLUT 3.0 images. 10/?/95
+
+ GLUT_XLIB_IMPLEMENTATION=7 mjk's GLUT 3.1+ with glutWarpPoitner. 7/24/96
+
+ GLUT_XLIB_IMPLEMENTATION=8 mjk's GLUT 3.1+ with glutWarpPoitner
+ and video resize. 1/3/97
+
+ GLUT_XLIB_IMPLEMENTATION=9 mjk's GLUT 3.4 release with early GLUT 4 routines.
+
+ GLUT_XLIB_IMPLEMENTATION=11 Mesa 2.5's GLUT 3.6 release.
+
+ GLUT_XLIB_IMPLEMENTATION=12 mjk's GLUT 3.6 release with early GLUT 4 routines + signal handling.
+
+ GLUT_XLIB_IMPLEMENTATION=13 mjk's GLUT 3.7 beta with GameGLUT support.
+
+ GLUT_XLIB_IMPLEMENTATION=14 mjk's GLUT 3.7 beta with f90gl friend interface.
+
+ GLUT_XLIB_IMPLEMENTATION=15 mjk's GLUT 3.7 beta sync'ed with Mesa <GL/glut.h>
+**/
+#ifndef GLUT_XLIB_IMPLEMENTATION /* Allow this to be overriden. */
+#define GLUT_XLIB_IMPLEMENTATION 15
+#endif
+
+/* Display mode bit masks. */
+#define GLUT_RGB 0
+#define GLUT_RGBA GLUT_RGB
+#define GLUT_INDEX 1
+#define GLUT_SINGLE 0
+#define GLUT_DOUBLE 2
+#define GLUT_ACCUM 4
+#define GLUT_ALPHA 8
+#define GLUT_DEPTH 16
+#define GLUT_STENCIL 32
+#if (GLUT_API_VERSION >= 2)
+#define GLUT_MULTISAMPLE 128
+#define GLUT_STEREO 256
+#endif
+#if (GLUT_API_VERSION >= 3)
+#define GLUT_LUMINANCE 512
+#endif
+
+/* Mouse buttons. */
+#define GLUT_LEFT_BUTTON 0
+#define GLUT_MIDDLE_BUTTON 1
+#define GLUT_RIGHT_BUTTON 2
+
+/* Mouse button state. */
+#define GLUT_DOWN 0
+#define GLUT_UP 1
+
+#if (GLUT_API_VERSION >= 2)
+/* function keys */
+#define GLUT_KEY_F1 1
+#define GLUT_KEY_F2 2
+#define GLUT_KEY_F3 3
+#define GLUT_KEY_F4 4
+#define GLUT_KEY_F5 5
+#define GLUT_KEY_F6 6
+#define GLUT_KEY_F7 7
+#define GLUT_KEY_F8 8
+#define GLUT_KEY_F9 9
+#define GLUT_KEY_F10 10
+#define GLUT_KEY_F11 11
+#define GLUT_KEY_F12 12
+/* directional keys */
+#define GLUT_KEY_LEFT 100
+#define GLUT_KEY_UP 101
+#define GLUT_KEY_RIGHT 102
+#define GLUT_KEY_DOWN 103
+#define GLUT_KEY_PAGE_UP 104
+#define GLUT_KEY_PAGE_DOWN 105
+#define GLUT_KEY_HOME 106
+#define GLUT_KEY_END 107
+#define GLUT_KEY_INSERT 108
+#endif
+
+/* Entry/exit state. */
+#define GLUT_LEFT 0
+#define GLUT_ENTERED 1
+
+/* Menu usage state. */
+#define GLUT_MENU_NOT_IN_USE 0
+#define GLUT_MENU_IN_USE 1
+
+/* Visibility state. */
+#define GLUT_NOT_VISIBLE 0
+#define GLUT_VISIBLE 1
+
+/* Window status state. */
+#define GLUT_HIDDEN 0
+#define GLUT_FULLY_RETAINED 1
+#define GLUT_PARTIALLY_RETAINED 2
+#define GLUT_FULLY_COVERED 3
+
+/* Color index component selection values. */
+#define GLUT_RED 0
+#define GLUT_GREEN 1
+#define GLUT_BLUE 2
+
+/* Layers for use. */
+#define GLUT_NORMAL 0
+#define GLUT_OVERLAY 1
+
+#if defined(_WIN32) || defined (GLUT_IMPORT_LIB)
+/* Stroke font constants (use these in GLUT program). */
+#define GLUT_STROKE_ROMAN ((void*)0)
+#define GLUT_STROKE_MONO_ROMAN ((void*)1)
+
+/* Bitmap font constants (use these in GLUT program). */
+#define GLUT_BITMAP_9_BY_15 ((void*)2)
+#define GLUT_BITMAP_8_BY_13 ((void*)3)
+#define GLUT_BITMAP_TIMES_ROMAN_10 ((void*)4)
+#define GLUT_BITMAP_TIMES_ROMAN_24 ((void*)5)
+#if (GLUT_API_VERSION >= 3)
+#define GLUT_BITMAP_HELVETICA_10 ((void*)6)
+#define GLUT_BITMAP_HELVETICA_12 ((void*)7)
+#define GLUT_BITMAP_HELVETICA_18 ((void*)8)
+#endif
+#else
+/* Stroke font opaque addresses (use constants instead in source code). */
+GLUTAPI void *glutStrokeRoman;
+GLUTAPI void *glutStrokeMonoRoman;
+
+/* Stroke font constants (use these in GLUT program). */
+#define GLUT_STROKE_ROMAN (&glutStrokeRoman)
+#define GLUT_STROKE_MONO_ROMAN (&glutStrokeMonoRoman)
+
+/* Bitmap font opaque addresses (use constants instead in source code). */
+GLUTAPI void *glutBitmap9By15;
+GLUTAPI void *glutBitmap8By13;
+GLUTAPI void *glutBitmapTimesRoman10;
+GLUTAPI void *glutBitmapTimesRoman24;
+GLUTAPI void *glutBitmapHelvetica10;
+GLUTAPI void *glutBitmapHelvetica12;
+GLUTAPI void *glutBitmapHelvetica18;
+
+/* Bitmap font constants (use these in GLUT program). */
+#define GLUT_BITMAP_9_BY_15 (&glutBitmap9By15)
+#define GLUT_BITMAP_8_BY_13 (&glutBitmap8By13)
+#define GLUT_BITMAP_TIMES_ROMAN_10 (&glutBitmapTimesRoman10)
+#define GLUT_BITMAP_TIMES_ROMAN_24 (&glutBitmapTimesRoman24)
+#if (GLUT_API_VERSION >= 3)
+#define GLUT_BITMAP_HELVETICA_10 (&glutBitmapHelvetica10)
+#define GLUT_BITMAP_HELVETICA_12 (&glutBitmapHelvetica12)
+#define GLUT_BITMAP_HELVETICA_18 (&glutBitmapHelvetica18)
+#endif
+#endif
+
+/* glutGet parameters. */
+#define GLUT_WINDOW_X 100
+#define GLUT_WINDOW_Y 101
+#define GLUT_WINDOW_WIDTH 102
+#define GLUT_WINDOW_HEIGHT 103
+#define GLUT_WINDOW_BUFFER_SIZE 104
+#define GLUT_WINDOW_STENCIL_SIZE 105
+#define GLUT_WINDOW_DEPTH_SIZE 106
+#define GLUT_WINDOW_RED_SIZE 107
+#define GLUT_WINDOW_GREEN_SIZE 108
+#define GLUT_WINDOW_BLUE_SIZE 109
+#define GLUT_WINDOW_ALPHA_SIZE 110
+#define GLUT_WINDOW_ACCUM_RED_SIZE 111
+#define GLUT_WINDOW_ACCUM_GREEN_SIZE 112
+#define GLUT_WINDOW_ACCUM_BLUE_SIZE 113
+#define GLUT_WINDOW_ACCUM_ALPHA_SIZE 114
+#define GLUT_WINDOW_DOUBLEBUFFER 115
+#define GLUT_WINDOW_RGBA 116
+#define GLUT_WINDOW_PARENT 117
+#define GLUT_WINDOW_NUM_CHILDREN 118
+#define GLUT_WINDOW_COLORMAP_SIZE 119
+#if (GLUT_API_VERSION >= 2)
+#define GLUT_WINDOW_NUM_SAMPLES 120
+#define GLUT_WINDOW_STEREO 121
+#endif
+#if (GLUT_API_VERSION >= 3)
+#define GLUT_WINDOW_CURSOR 122
+#endif
+#define GLUT_SCREEN_WIDTH 200
+#define GLUT_SCREEN_HEIGHT 201
+#define GLUT_SCREEN_WIDTH_MM 202
+#define GLUT_SCREEN_HEIGHT_MM 203
+#define GLUT_MENU_NUM_ITEMS 300
+#define GLUT_DISPLAY_MODE_POSSIBLE 400
+#define GLUT_INIT_WINDOW_X 500
+#define GLUT_INIT_WINDOW_Y 501
+#define GLUT_INIT_WINDOW_WIDTH 502
+#define GLUT_INIT_WINDOW_HEIGHT 503
+#define GLUT_INIT_DISPLAY_MODE 504
+#if (GLUT_API_VERSION >= 2)
+#define GLUT_ELAPSED_TIME 700
+#endif
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
+#define GLUT_WINDOW_FORMAT_ID 123
+#endif
+
+#if (GLUT_API_VERSION >= 2)
+/* glutDeviceGet parameters. */
+#define GLUT_HAS_KEYBOARD 600
+#define GLUT_HAS_MOUSE 601
+#define GLUT_HAS_SPACEBALL 602
+#define GLUT_HAS_DIAL_AND_BUTTON_BOX 603
+#define GLUT_HAS_TABLET 604
+#define GLUT_NUM_MOUSE_BUTTONS 605
+#define GLUT_NUM_SPACEBALL_BUTTONS 606
+#define GLUT_NUM_BUTTON_BOX_BUTTONS 607
+#define GLUT_NUM_DIALS 608
+#define GLUT_NUM_TABLET_BUTTONS 609
+#endif
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
+#define GLUT_DEVICE_IGNORE_KEY_REPEAT 610
+#define GLUT_DEVICE_KEY_REPEAT 611
+#define GLUT_HAS_JOYSTICK 612
+#define GLUT_OWNS_JOYSTICK 613
+#define GLUT_JOYSTICK_BUTTONS 614
+#define GLUT_JOYSTICK_AXES 615
+#define GLUT_JOYSTICK_POLL_RATE 616
+#endif
+
+#if (GLUT_API_VERSION >= 3)
+/* glutLayerGet parameters. */
+#define GLUT_OVERLAY_POSSIBLE 800
+#define GLUT_LAYER_IN_USE 801
+#define GLUT_HAS_OVERLAY 802
+#define GLUT_TRANSPARENT_INDEX 803
+#define GLUT_NORMAL_DAMAGED 804
+#define GLUT_OVERLAY_DAMAGED 805
+
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
+/* glutVideoResizeGet parameters. */
+#define GLUT_VIDEO_RESIZE_POSSIBLE 900
+#define GLUT_VIDEO_RESIZE_IN_USE 901
+#define GLUT_VIDEO_RESIZE_X_DELTA 902
+#define GLUT_VIDEO_RESIZE_Y_DELTA 903
+#define GLUT_VIDEO_RESIZE_WIDTH_DELTA 904
+#define GLUT_VIDEO_RESIZE_HEIGHT_DELTA 905
+#define GLUT_VIDEO_RESIZE_X 906
+#define GLUT_VIDEO_RESIZE_Y 907
+#define GLUT_VIDEO_RESIZE_WIDTH 908
+#define GLUT_VIDEO_RESIZE_HEIGHT 909
+#endif
+
+/* glutUseLayer parameters. */
+#define GLUT_NORMAL 0
+#define GLUT_OVERLAY 1
+
+/* glutGetModifiers return mask. */
+#define GLUT_ACTIVE_SHIFT 1
+#define GLUT_ACTIVE_CTRL 2
+#define GLUT_ACTIVE_ALT 4
+
+/* glutSetCursor parameters. */
+/* Basic arrows. */
+#define GLUT_CURSOR_RIGHT_ARROW 0
+#define GLUT_CURSOR_LEFT_ARROW 1
+/* Symbolic cursor shapes. */
+#define GLUT_CURSOR_INFO 2
+#define GLUT_CURSOR_DESTROY 3
+#define GLUT_CURSOR_HELP 4
+#define GLUT_CURSOR_CYCLE 5
+#define GLUT_CURSOR_SPRAY 6
+#define GLUT_CURSOR_WAIT 7
+#define GLUT_CURSOR_TEXT 8
+#define GLUT_CURSOR_CROSSHAIR 9
+/* Directional cursors. */
+#define GLUT_CURSOR_UP_DOWN 10
+#define GLUT_CURSOR_LEFT_RIGHT 11
+/* Sizing cursors. */
+#define GLUT_CURSOR_TOP_SIDE 12
+#define GLUT_CURSOR_BOTTOM_SIDE 13
+#define GLUT_CURSOR_LEFT_SIDE 14
+#define GLUT_CURSOR_RIGHT_SIDE 15
+#define GLUT_CURSOR_TOP_LEFT_CORNER 16
+#define GLUT_CURSOR_TOP_RIGHT_CORNER 17
+#define GLUT_CURSOR_BOTTOM_RIGHT_CORNER 18
+#define GLUT_CURSOR_BOTTOM_LEFT_CORNER 19
+/* Inherit from parent window. */
+#define GLUT_CURSOR_INHERIT 100
+/* Blank cursor. */
+#define GLUT_CURSOR_NONE 101
+/* Fullscreen crosshair (if available). */
+#define GLUT_CURSOR_FULL_CROSSHAIR 102
+#endif
+
+/* GLUT initialization sub-API. */
+GLUTAPI void GLUTAPIENTRY glutInit(int *argcp, char **argv);
+#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
+GLUTAPI void GLUTAPIENTRY __glutInitWithExit(int *argcp, char **argv, void (__cdecl *exitfunc)(int));
+#ifndef GLUT_BUILDING_LIB
+static void GLUTAPIENTRY glutInit_ATEXIT_HACK(int *argcp, char **argv) { __glutInitWithExit(argcp, argv, exit); }
+#define glutInit glutInit_ATEXIT_HACK
+#endif
+#endif
+GLUTAPI void GLUTAPIENTRY glutInitDisplayMode(unsigned int mode);
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
+GLUTAPI void GLUTAPIENTRY glutInitDisplayString(const char *string);
+#endif
+GLUTAPI void GLUTAPIENTRY glutInitWindowPosition(int x, int y);
+GLUTAPI void GLUTAPIENTRY glutInitWindowSize(int width, int height);
+GLUTAPI void GLUTAPIENTRY glutMainLoop(void);
+
+/* GLUT window sub-API. */
+GLUTAPI int GLUTAPIENTRY glutCreateWindow(const char *title);
+#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
+GLUTAPI int GLUTAPIENTRY __glutCreateWindowWithExit(const char *title, void (__cdecl *exitfunc)(int));
+#ifndef GLUT_BUILDING_LIB
+static int GLUTAPIENTRY glutCreateWindow_ATEXIT_HACK(const char *title) { return __glutCreateWindowWithExit(title, exit); }
+#define glutCreateWindow glutCreateWindow_ATEXIT_HACK
+#endif
+#endif
+GLUTAPI int GLUTAPIENTRY glutCreateSubWindow(int win, int x, int y, int width, int height);
+GLUTAPI void GLUTAPIENTRY glutDestroyWindow(int win);
+GLUTAPI void GLUTAPIENTRY glutPostRedisplay(void);
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11)
+GLUTAPI void GLUTAPIENTRY glutPostWindowRedisplay(int win);
+#endif
+GLUTAPI void GLUTAPIENTRY glutSwapBuffers(void);
+GLUTAPI int GLUTAPIENTRY glutGetWindow(void);
+GLUTAPI void GLUTAPIENTRY glutSetWindow(int win);
+GLUTAPI void GLUTAPIENTRY glutSetWindowTitle(const char *title);
+GLUTAPI void GLUTAPIENTRY glutSetIconTitle(const char *title);
+GLUTAPI void GLUTAPIENTRY glutPositionWindow(int x, int y);
+GLUTAPI void GLUTAPIENTRY glutReshapeWindow(int width, int height);
+GLUTAPI void GLUTAPIENTRY glutPopWindow(void);
+GLUTAPI void GLUTAPIENTRY glutPushWindow(void);
+GLUTAPI void GLUTAPIENTRY glutIconifyWindow(void);
+GLUTAPI void GLUTAPIENTRY glutShowWindow(void);
+GLUTAPI void GLUTAPIENTRY glutHideWindow(void);
+#if (GLUT_API_VERSION >= 3)
+GLUTAPI void GLUTAPIENTRY glutFullScreen(void);
+GLUTAPI void GLUTAPIENTRY glutSetCursor(int cursor);
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
+GLUTAPI void GLUTAPIENTRY glutWarpPointer(int x, int y);
+#endif
+
+/* GLUT overlay sub-API. */
+GLUTAPI void GLUTAPIENTRY glutEstablishOverlay(void);
+GLUTAPI void GLUTAPIENTRY glutRemoveOverlay(void);
+GLUTAPI void GLUTAPIENTRY glutUseLayer(GLenum layer);
+GLUTAPI void GLUTAPIENTRY glutPostOverlayRedisplay(void);
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 11)
+GLUTAPI void GLUTAPIENTRY glutPostWindowOverlayRedisplay(int win);
+#endif
+GLUTAPI void GLUTAPIENTRY glutShowOverlay(void);
+GLUTAPI void GLUTAPIENTRY glutHideOverlay(void);
+#endif
+
+/* GLUT menu sub-API. */
+GLUTAPI int GLUTAPIENTRY glutCreateMenu(void (GLUTCALLBACK *func)(int));
+#if defined(_WIN32) && !defined(GLUT_DISABLE_ATEXIT_HACK)
+GLUTAPI int GLUTAPIENTRY __glutCreateMenuWithExit(void (GLUTCALLBACK *func)(int), void (__cdecl *exitfunc)(int));
+#ifndef GLUT_BUILDING_LIB
+static int GLUTAPIENTRY glutCreateMenu_ATEXIT_HACK(void (GLUTCALLBACK *func)(int)) { return __glutCreateMenuWithExit(func, exit); }
+#define glutCreateMenu glutCreateMenu_ATEXIT_HACK
+#endif
+#endif
+GLUTAPI void GLUTAPIENTRY glutDestroyMenu(int menu);
+GLUTAPI int GLUTAPIENTRY glutGetMenu(void);
+GLUTAPI void GLUTAPIENTRY glutSetMenu(int menu);
+GLUTAPI void GLUTAPIENTRY glutAddMenuEntry(const char *label, int value);
+GLUTAPI void GLUTAPIENTRY glutAddSubMenu(const char *label, int submenu);
+GLUTAPI void GLUTAPIENTRY glutChangeToMenuEntry(int item, const char *label, int value);
+GLUTAPI void GLUTAPIENTRY glutChangeToSubMenu(int item, const char *label, int submenu);
+GLUTAPI void GLUTAPIENTRY glutRemoveMenuItem(int item);
+GLUTAPI void GLUTAPIENTRY glutAttachMenu(int button);
+GLUTAPI void GLUTAPIENTRY glutDetachMenu(int button);
+
+/* GLUT window callback sub-API. */
+GLUTAPI void GLUTAPIENTRY glutDisplayFunc(void (GLUTCALLBACK *func)(void));
+GLUTAPI void GLUTAPIENTRY glutReshapeFunc(void (GLUTCALLBACK *func)(int width, int height));
+GLUTAPI void GLUTAPIENTRY glutKeyboardFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y));
+GLUTAPI void GLUTAPIENTRY glutMouseFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y));
+GLUTAPI void GLUTAPIENTRY glutMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
+GLUTAPI void GLUTAPIENTRY glutPassiveMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
+GLUTAPI void GLUTAPIENTRY glutEntryFunc(void (GLUTCALLBACK *func)(int state));
+GLUTAPI void GLUTAPIENTRY glutVisibilityFunc(void (GLUTCALLBACK *func)(int state));
+GLUTAPI void GLUTAPIENTRY glutIdleFunc(void (GLUTCALLBACK *func)(void));
+GLUTAPI void GLUTAPIENTRY glutTimerFunc(unsigned int millis, void (GLUTCALLBACK *func)(int value), int value);
+GLUTAPI void GLUTAPIENTRY glutMenuStateFunc(void (GLUTCALLBACK *func)(int state));
+#if (GLUT_API_VERSION >= 2)
+GLUTAPI void GLUTAPIENTRY glutSpecialFunc(void (GLUTCALLBACK *func)(int key, int x, int y));
+GLUTAPI void GLUTAPIENTRY glutSpaceballMotionFunc(void (GLUTCALLBACK *func)(int x, int y, int z));
+GLUTAPI void GLUTAPIENTRY glutSpaceballRotateFunc(void (GLUTCALLBACK *func)(int x, int y, int z));
+GLUTAPI void GLUTAPIENTRY glutSpaceballButtonFunc(void (GLUTCALLBACK *func)(int button, int state));
+GLUTAPI void GLUTAPIENTRY glutButtonBoxFunc(void (GLUTCALLBACK *func)(int button, int state));
+GLUTAPI void GLUTAPIENTRY glutDialsFunc(void (GLUTCALLBACK *func)(int dial, int value));
+GLUTAPI void GLUTAPIENTRY glutTabletMotionFunc(void (GLUTCALLBACK *func)(int x, int y));
+GLUTAPI void GLUTAPIENTRY glutTabletButtonFunc(void (GLUTCALLBACK *func)(int button, int state, int x, int y));
+#if (GLUT_API_VERSION >= 3)
+GLUTAPI void GLUTAPIENTRY glutMenuStatusFunc(void (GLUTCALLBACK *func)(int status, int x, int y));
+GLUTAPI void GLUTAPIENTRY glutOverlayDisplayFunc(void (GLUTCALLBACK *func)(void));
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
+GLUTAPI void GLUTAPIENTRY glutWindowStatusFunc(void (GLUTCALLBACK *func)(int state));
+#endif
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
+GLUTAPI void GLUTAPIENTRY glutKeyboardUpFunc(void (GLUTCALLBACK *func)(unsigned char key, int x, int y));
+GLUTAPI void GLUTAPIENTRY glutSpecialUpFunc(void (GLUTCALLBACK *func)(int key, int x, int y));
+GLUTAPI void GLUTAPIENTRY glutJoystickFunc(void (GLUTCALLBACK *func)(unsigned int buttonMask, int x, int y, int z), int pollInterval);
+#endif
+#endif
+#endif
+
+/* GLUT color index sub-API. */
+GLUTAPI void GLUTAPIENTRY glutSetColor(int ndx, GLfloat red, GLfloat green, GLfloat blue);
+GLUTAPI GLfloat GLUTAPIENTRY glutGetColor(int ndx, int component);
+GLUTAPI void GLUTAPIENTRY glutCopyColormap(int win);
+
+/* GLUT state retrieval sub-API. */
+GLUTAPI int GLUTAPIENTRY glutGet(GLenum type);
+GLUTAPI int GLUTAPIENTRY glutDeviceGet(GLenum type);
+#if (GLUT_API_VERSION >= 2)
+/* GLUT extension support sub-API */
+GLUTAPI int GLUTAPIENTRY glutExtensionSupported(const char *name);
+#endif
+#if (GLUT_API_VERSION >= 3)
+GLUTAPI int GLUTAPIENTRY glutGetModifiers(void);
+GLUTAPI int GLUTAPIENTRY glutLayerGet(GLenum type);
+#endif
+#if (GLUT_API_VERSION >= 5)
+typedef void (*GLUTproc)();
+GLUTAPI GLUTproc GLUTAPIENTRY glutGetProcAddress(const char *procName);
+#endif
+
+/* GLUT font sub-API */
+GLUTAPI void GLUTAPIENTRY glutBitmapCharacter(void *font, int character);
+GLUTAPI int GLUTAPIENTRY glutBitmapWidth(void *font, int character);
+GLUTAPI void GLUTAPIENTRY glutStrokeCharacter(void *font, int character);
+GLUTAPI int GLUTAPIENTRY glutStrokeWidth(void *font, int character);
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
+GLUTAPI int GLUTAPIENTRY glutBitmapLength(void *font, const unsigned char *string);
+GLUTAPI int GLUTAPIENTRY glutStrokeLength(void *font, const unsigned char *string);
+#endif
+
+/* GLUT pre-built models sub-API */
+GLUTAPI void GLUTAPIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks);
+GLUTAPI void GLUTAPIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks);
+GLUTAPI void GLUTAPIENTRY glutWireCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);
+GLUTAPI void GLUTAPIENTRY glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);
+GLUTAPI void GLUTAPIENTRY glutWireCube(GLdouble size);
+GLUTAPI void GLUTAPIENTRY glutSolidCube(GLdouble size);
+GLUTAPI void GLUTAPIENTRY glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);
+GLUTAPI void GLUTAPIENTRY glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);
+GLUTAPI void GLUTAPIENTRY glutWireDodecahedron(void);
+GLUTAPI void GLUTAPIENTRY glutSolidDodecahedron(void);
+GLUTAPI void GLUTAPIENTRY glutWireTeapot(GLdouble size);
+GLUTAPI void GLUTAPIENTRY glutSolidTeapot(GLdouble size);
+GLUTAPI void GLUTAPIENTRY glutWireOctahedron(void);
+GLUTAPI void GLUTAPIENTRY glutSolidOctahedron(void);
+GLUTAPI void GLUTAPIENTRY glutWireTetrahedron(void);
+GLUTAPI void GLUTAPIENTRY glutSolidTetrahedron(void);
+GLUTAPI void GLUTAPIENTRY glutWireIcosahedron(void);
+GLUTAPI void GLUTAPIENTRY glutSolidIcosahedron(void);
+
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
+/* GLUT video resize sub-API. */
+GLUTAPI int GLUTAPIENTRY glutVideoResizeGet(GLenum param);
+GLUTAPI void GLUTAPIENTRY glutSetupVideoResizing(void);
+GLUTAPI void GLUTAPIENTRY glutStopVideoResizing(void);
+GLUTAPI void GLUTAPIENTRY glutVideoResize(int x, int y, int width, int height);
+GLUTAPI void GLUTAPIENTRY glutVideoPan(int x, int y, int width, int height);
+
+/* GLUT debugging sub-API. */
+GLUTAPI void GLUTAPIENTRY glutReportErrors(void);
+#endif
+
+#if (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 13)
+/* GLUT device control sub-API. */
+/* glutSetKeyRepeat modes. */
+#define GLUT_KEY_REPEAT_OFF 0
+#define GLUT_KEY_REPEAT_ON 1
+#define GLUT_KEY_REPEAT_DEFAULT 2
+
+/* Joystick button masks. */
+#define GLUT_JOYSTICK_BUTTON_A 1
+#define GLUT_JOYSTICK_BUTTON_B 2
+#define GLUT_JOYSTICK_BUTTON_C 4
+#define GLUT_JOYSTICK_BUTTON_D 8
+
+GLUTAPI void GLUTAPIENTRY glutIgnoreKeyRepeat(int ignore);
+GLUTAPI void GLUTAPIENTRY glutSetKeyRepeat(int repeatMode);
+GLUTAPI void GLUTAPIENTRY glutForceJoystickFunc(void);
+
+/* GLUT game mode sub-API. */
+/* glutGameModeGet. */
+#define GLUT_GAME_MODE_ACTIVE 0
+#define GLUT_GAME_MODE_POSSIBLE 1
+#define GLUT_GAME_MODE_WIDTH 2
+#define GLUT_GAME_MODE_HEIGHT 3
+#define GLUT_GAME_MODE_PIXEL_DEPTH 4
+#define GLUT_GAME_MODE_REFRESH_RATE 5
+#define GLUT_GAME_MODE_DISPLAY_CHANGED 6
+
+GLUTAPI void GLUTAPIENTRY glutGameModeString(const char *string);
+GLUTAPI int GLUTAPIENTRY glutEnterGameMode(void);
+GLUTAPI void GLUTAPIENTRY glutLeaveGameMode(void);
+GLUTAPI int GLUTAPIENTRY glutGameModeGet(GLenum mode);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __glut_h__ */
diff --git a/nx-X11/extras/Mesa/include/GL/glut_h.dja b/nx-X11/extras/Mesa/include/GL/glut_h.dja
new file mode 100644
index 000000000..e76dcb985
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/glut_h.dja
@@ -0,0 +1,340 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.1
+ * Copyright (C) 1995-1998 Brian Paul
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+/*
+ * This header file is based on the REAL glut.h by Mark J. Kilgard.
+ *
+ * The DJGPP/ALLEGRO (DJA) GLUT implementation was written by
+ * Bernhard Tschirren (bernie-t@geocities.com) for the sole purpose
+ * of compiling all the sample programs (which use GLUT). Therefore,
+ * is NOT AT ALL a complete version of GLUT!
+ */
+
+
+#ifndef __AGLUT_H__
+#define __AGLUT_H__
+
+#include <GL/gl.h>
+#include <GL/glu.h>
+
+#define GLUTCALLBACK
+#define APIENTRY
+#define GLUTAPI extern
+
+#define GLUT_RGB 0
+#define GLUT_RGBA GLUT_RGB
+#define GLUT_INDEX 1
+#define GLUT_SINGLE 0
+#define GLUT_DOUBLE 2
+#define GLUT_ACCUM 4
+#define GLUT_ALPHA 8
+#define GLUT_DEPTH 16
+#define GLUT_STENCIL 32
+
+/* Mouse buttons. */
+#define GLUT_LEFT_BUTTON 0
+#define GLUT_MIDDLE_BUTTON 1
+#define GLUT_RIGHT_BUTTON 2
+
+/* Mouse button state. */
+#define GLUT_DOWN 0
+#define GLUT_UP 1
+
+/* function keys */
+#define GLUT_KEY_F1 1
+#define GLUT_KEY_F2 2
+#define GLUT_KEY_F3 3
+#define GLUT_KEY_F4 4
+#define GLUT_KEY_F5 5
+#define GLUT_KEY_F6 6
+#define GLUT_KEY_F7 7
+#define GLUT_KEY_F8 8
+#define GLUT_KEY_F9 9
+#define GLUT_KEY_F10 10
+#define GLUT_KEY_F11 11
+#define GLUT_KEY_F12 12
+
+/* directional keys */
+#define GLUT_KEY_LEFT 100
+#define GLUT_KEY_UP 101
+#define GLUT_KEY_RIGHT 102
+#define GLUT_KEY_DOWN 103
+#define GLUT_KEY_PAGE_UP 104
+#define GLUT_KEY_PAGE_DOWN 105
+#define GLUT_KEY_HOME 106
+#define GLUT_KEY_END 107
+#define GLUT_KEY_INSERT 108
+
+/* Entry/exit state. */
+#define GLUT_LEFT 0
+#define GLUT_ENTERED 1
+
+/* Visibility state. */
+#define GLUT_NOT_VISIBLE 0
+#define GLUT_VISIBLE 1
+
+/* Color index component selection values. */
+#define GLUT_RED 0
+#define GLUT_GREEN 1
+#define GLUT_BLUE 2
+
+/* Layers for use. */
+#define GLUT_NORMAL 0
+#define GLUT_OVERLAY 1
+
+/* Stroke font constants (use these in GLUT program). */
+#define GLUT_STROKE_ROMAN ((void*)0)
+#define GLUT_STROKE_MONO_ROMAN ((void*)1)
+
+/* Bitmap font constants (use these in GLUT program). */
+#define GLUT_BITMAP_9_BY_15 ((void*)2)
+#define GLUT_BITMAP_8_BY_13 ((void*)3)
+#define GLUT_BITMAP_TIMES_ROMAN_10 ((void*)4)
+#define GLUT_BITMAP_TIMES_ROMAN_24 ((void*)5)
+#define GLUT_BITMAP_HELVETICA_10 ((void*)6)
+#define GLUT_BITMAP_HELVETICA_12 ((void*)7)
+#define GLUT_BITMAP_HELVETICA_18 ((void*)8)
+
+/* glutGet parameters. */
+#define GLUT_WINDOW_X 100
+#define GLUT_WINDOW_Y 101
+#define GLUT_WINDOW_WIDTH 102
+#define GLUT_WINDOW_HEIGHT 103
+#define GLUT_WINDOW_BUFFER_SIZE 104
+#define GLUT_WINDOW_STENCIL_SIZE 105
+#define GLUT_WINDOW_DEPTH_SIZE 106
+#define GLUT_WINDOW_RED_SIZE 107
+#define GLUT_WINDOW_GREEN_SIZE 108
+#define GLUT_WINDOW_BLUE_SIZE 109
+#define GLUT_WINDOW_ALPHA_SIZE 110
+#define GLUT_WINDOW_ACCUM_RED_SIZE 111
+#define GLUT_WINDOW_ACCUM_GREEN_SIZE 112
+#define GLUT_WINDOW_ACCUM_BLUE_SIZE 113
+#define GLUT_WINDOW_ACCUM_ALPHA_SIZE 114
+#define GLUT_WINDOW_DOUBLEBUFFER 115
+#define GLUT_WINDOW_RGBA 116
+#define GLUT_WINDOW_PARENT 117
+#define GLUT_WINDOW_NUM_CHILDREN 118
+#define GLUT_WINDOW_COLORMAP_SIZE 119
+#define GLUT_WINDOW_NUM_SAMPLES 120
+#define GLUT_WINDOW_STEREO 121
+#define GLUT_WINDOW_CURSOR 122
+#define GLUT_SCREEN_WIDTH 200
+#define GLUT_SCREEN_HEIGHT 201
+#define GLUT_SCREEN_WIDTH_MM 202
+#define GLUT_SCREEN_HEIGHT_MM 203
+#define GLUT_MENU_NUM_ITEMS 300
+#define GLUT_DISPLAY_MODE_POSSIBLE 400
+#define GLUT_INIT_WINDOW_X 500
+#define GLUT_INIT_WINDOW_Y 501
+#define GLUT_INIT_WINDOW_WIDTH 502
+#define GLUT_INIT_WINDOW_HEIGHT 503
+#define GLUT_INIT_DISPLAY_MODE 504
+#define GLUT_ELAPSED_TIME 700
+#define GLUT_WINDOW_FORMAT_ID 123
+
+/* glutDeviceGet parameters. */
+#define GLUT_HAS_KEYBOARD 600
+#define GLUT_HAS_MOUSE 601
+#define GLUT_HAS_SPACEBALL 602
+#define GLUT_HAS_DIAL_AND_BUTTON_BOX 603
+#define GLUT_HAS_TABLET 604
+#define GLUT_NUM_MOUSE_BUTTONS 605
+#define GLUT_NUM_SPACEBALL_BUTTONS 606
+#define GLUT_NUM_BUTTON_BOX_BUTTONS 607
+#define GLUT_NUM_DIALS 608
+#define GLUT_NUM_TABLET_BUTTONS 609
+#define GLUT_DEVICE_IGNORE_KEY_REPEAT 610
+#define GLUT_DEVICE_KEY_REPEAT 611
+#define GLUT_HAS_JOYSTICK 612
+#define GLUT_OWNS_JOYSTICK 613
+#define GLUT_JOYSTICK_BUTTONS 614
+#define GLUT_JOYSTICK_AXES 615
+#define GLUT_JOYSTICK_POLL_RATE 616
+
+/* glutLayerGet parameters. */
+#define GLUT_OVERLAY_POSSIBLE 800
+#define GLUT_LAYER_IN_USE 801
+#define GLUT_HAS_OVERLAY 802
+#define GLUT_TRANSPARENT_INDEX 803
+#define GLUT_NORMAL_DAMAGED 804
+#define GLUT_OVERLAY_DAMAGED 805
+
+/* glutVideoResizeGet parameters. */
+#define GLUT_VIDEO_RESIZE_POSSIBLE 900
+#define GLUT_VIDEO_RESIZE_IN_USE 901
+#define GLUT_VIDEO_RESIZE_X_DELTA 902
+#define GLUT_VIDEO_RESIZE_Y_DELTA 903
+#define GLUT_VIDEO_RESIZE_WIDTH_DELTA 904
+#define GLUT_VIDEO_RESIZE_HEIGHT_DELTA 905
+#define GLUT_VIDEO_RESIZE_X 906
+#define GLUT_VIDEO_RESIZE_Y 907
+#define GLUT_VIDEO_RESIZE_WIDTH 908
+#define GLUT_VIDEO_RESIZE_HEIGHT 909
+
+/* glutUseLayer parameters. */
+#define GLUT_NORMAL 0
+#define GLUT_OVERLAY 1
+
+/* glutGetModifiers return mask. */
+#define GLUT_ACTIVE_SHIFT 1
+#define GLUT_ACTIVE_CTRL 2
+#define GLUT_ACTIVE_ALT 4
+
+/* glutSetCursor parameters. */
+/* Basic arrows. */
+#define GLUT_CURSOR_RIGHT_ARROW 0
+#define GLUT_CURSOR_LEFT_ARROW 1
+/* Symbolic cursor shapes. */
+#define GLUT_CURSOR_INFO 2
+#define GLUT_CURSOR_DESTROY 3
+#define GLUT_CURSOR_HELP 4
+#define GLUT_CURSOR_CYCLE 5
+#define GLUT_CURSOR_SPRAY 6
+#define GLUT_CURSOR_WAIT 7
+#define GLUT_CURSOR_TEXT 8
+#define GLUT_CURSOR_CROSSHAIR 9
+/* Directional cursors. */
+#define GLUT_CURSOR_UP_DOWN 10
+#define GLUT_CURSOR_LEFT_RIGHT 11
+/* Sizing cursors. */
+#define GLUT_CURSOR_TOP_SIDE 12
+#define GLUT_CURSOR_BOTTOM_SIDE 13
+#define GLUT_CURSOR_LEFT_SIDE 14
+#define GLUT_CURSOR_RIGHT_SIDE 15
+#define GLUT_CURSOR_TOP_LEFT_CORNER 16
+#define GLUT_CURSOR_TOP_RIGHT_CORNER 17
+#define GLUT_CURSOR_BOTTOM_RIGHT_CORNER 18
+#define GLUT_CURSOR_BOTTOM_LEFT_CORNER 19
+/* Inherit from parent window. */
+#define GLUT_CURSOR_INHERIT 100
+/* Blank cursor. */
+#define GLUT_CURSOR_NONE 101
+/* Fullscreen crosshair (if available). */
+#define GLUT_CURSOR_FULL_CROSSHAIR 102
+
+/* GLUT initialization sub-API. */
+GLUTAPI void APIENTRY glutInit(int *argcp, char **argv);
+GLUTAPI void APIENTRY glutInitDisplayMode(unsigned int mode);
+GLUTAPI void APIENTRY glutInitWindowPosition(int x, int y);
+GLUTAPI void APIENTRY glutInitWindowSize(int width, int height);
+GLUTAPI void APIENTRY glutMainLoop(void);
+
+/* GLUT window sub-API. */
+GLUTAPI int APIENTRY glutCreateWindow(const char *title);
+GLUTAPI int APIENTRY glutCreateSubWindow(int win, int x, int y, int width, int height);
+GLUTAPI void APIENTRY glutDestroyWindow(int win);
+GLUTAPI void APIENTRY glutPostRedisplay(void);
+GLUTAPI void APIENTRY glutSwapBuffers(void);
+GLUTAPI int APIENTRY glutGetWindow(void);
+GLUTAPI void APIENTRY glutSetWindow(int win);
+GLUTAPI void APIENTRY glutSetWindowTitle(const char *title);
+GLUTAPI void APIENTRY glutSetIconTitle(const char *title);
+GLUTAPI void APIENTRY glutPositionWindow(int x, int y);
+GLUTAPI void APIENTRY glutReshapeWindow(int width, int height);
+GLUTAPI void APIENTRY glutPopWindow(void);
+GLUTAPI void APIENTRY glutPushWindow(void);
+GLUTAPI void APIENTRY glutIconifyWindow(void);
+GLUTAPI void APIENTRY glutShowWindow(void);
+GLUTAPI void APIENTRY glutHideWindow(void);
+
+/* GLUT overlay sub-API. */
+GLUTAPI void APIENTRY glutEstablishOverlay(void);
+GLUTAPI void APIENTRY glutRemoveOverlay(void);
+GLUTAPI void APIENTRY glutUseLayer(GLenum layer);
+GLUTAPI void APIENTRY glutPostOverlayRedisplay(void);
+GLUTAPI void APIENTRY glutShowOverlay(void);
+GLUTAPI void APIENTRY glutHideOverlay(void);
+
+/* GLUT menu sub-API. */
+GLUTAPI int APIENTRY glutCreateMenu(void (GLUTCALLBACK *)(int));
+GLUTAPI void APIENTRY glutDestroyMenu(int menu);
+GLUTAPI int APIENTRY glutGetMenu(void);
+GLUTAPI void APIENTRY glutSetMenu(int menu);
+GLUTAPI void APIENTRY glutAddMenuEntry(const char *label, int value);
+GLUTAPI void APIENTRY glutAddSubMenu(const char *label, int submenu);
+GLUTAPI void APIENTRY glutChangeToMenuEntry(int item, const char *label, int value);
+GLUTAPI void APIENTRY glutChangeToSubMenu(int item, const char *label, int submenu);
+GLUTAPI void APIENTRY glutRemoveMenuItem(int item);
+GLUTAPI void APIENTRY glutAttachMenu(int button);
+GLUTAPI void APIENTRY glutDetachMenu(int button);
+
+/* GLUT window callback sub-API. */
+GLUTAPI void APIENTRY glutDisplayFunc(void (GLUTCALLBACK * func)(void));
+GLUTAPI void APIENTRY glutReshapeFunc(void (GLUTCALLBACK * func)(int width, int height));
+GLUTAPI void APIENTRY glutKeyboardFunc(void (GLUTCALLBACK * func)(unsigned char key, int x, int y));
+GLUTAPI void APIENTRY glutMouseFunc(void (GLUTCALLBACK * func)(int button, int state, int x, int y));
+GLUTAPI void APIENTRY glutMotionFunc(void (GLUTCALLBACK * func)(int x, int y));
+GLUTAPI void APIENTRY glutPassiveMotionFunc(void (GLUTCALLBACK * func)(int x, int y));
+GLUTAPI void APIENTRY glutEntryFunc(void (GLUTCALLBACK * func)(int state));
+GLUTAPI void APIENTRY glutVisibilityFunc(void (GLUTCALLBACK * func)(int state));
+GLUTAPI void APIENTRY glutIdleFunc(void (GLUTCALLBACK * func)(void));
+GLUTAPI void APIENTRY glutTimerFunc(unsigned int millis, void (GLUTCALLBACK * func)(int value), int value);
+GLUTAPI void APIENTRY glutMenuStateFunc(void (GLUTCALLBACK * func)(int state));
+GLUTAPI void APIENTRY glutSpecialFunc(void (GLUTCALLBACK * func)(int key, int x, int y));
+GLUTAPI void APIENTRY glutSpaceballMotionFunc(void (GLUTCALLBACK * func)(int x, int y, int z));
+GLUTAPI void APIENTRY glutSpaceballRotateFunc(void (GLUTCALLBACK * func)(int x, int y, int z));
+GLUTAPI void APIENTRY glutSpaceballButtonFunc(void (GLUTCALLBACK * func)(int button, int state));
+GLUTAPI void APIENTRY glutButtonBoxFunc(void (GLUTCALLBACK * func)(int button, int state));
+GLUTAPI void APIENTRY glutDialsFunc(void (GLUTCALLBACK * func)(int dial, int value));
+GLUTAPI void APIENTRY glutTabletMotionFunc(void (GLUTCALLBACK * func)(int x, int y));
+GLUTAPI void APIENTRY glutTabletButtonFunc(void (GLUTCALLBACK * func)(int button, int state, int x, int y));
+GLUTAPI void APIENTRY glutMenuStatusFunc(void (GLUTCALLBACK * func)(int status, int x, int y));
+GLUTAPI void APIENTRY glutOverlayDisplayFunc(void (GLUTCALLBACK * func)(void));
+GLUTAPI void APIENTRY glutWindowStatusFunc(void (GLUTCALLBACK * func)(int state));
+
+/* GLUT color index sub-API. */
+GLUTAPI void APIENTRY glutSetColor(int, GLfloat red, GLfloat green, GLfloat blue);
+GLUTAPI GLfloat APIENTRY glutGetColor(int ndx, int component);
+GLUTAPI void APIENTRY glutCopyColormap(int win);
+
+/* GLUT state retrieval sub-API. */
+GLUTAPI int APIENTRY glutGet(GLenum type);
+GLUTAPI int APIENTRY glutDeviceGet(GLenum type);
+
+/* GLUT font sub-API */
+GLUTAPI void APIENTRY glutBitmapCharacter(void *font, int character);
+GLUTAPI int APIENTRY glutBitmapWidth(void *font, int character);
+GLUTAPI void APIENTRY glutStrokeCharacter(void *font, int character);
+GLUTAPI int APIENTRY glutStrokeWidth(void *font, int character);
+
+/* GLUT pre-built models sub-API */
+GLUTAPI void APIENTRY glutWireSphere(GLdouble radius, GLint slices, GLint stacks);
+GLUTAPI void APIENTRY glutSolidSphere(GLdouble radius, GLint slices, GLint stacks);
+GLUTAPI void APIENTRY glutWireCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);
+GLUTAPI void APIENTRY glutSolidCone(GLdouble base, GLdouble height, GLint slices, GLint stacks);
+GLUTAPI void APIENTRY glutWireCube(GLdouble size);
+GLUTAPI void APIENTRY glutSolidCube(GLdouble size);
+GLUTAPI void APIENTRY glutWireTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);
+GLUTAPI void APIENTRY glutSolidTorus(GLdouble innerRadius, GLdouble outerRadius, GLint sides, GLint rings);
+GLUTAPI void APIENTRY glutWireDodecahedron(void);
+GLUTAPI void APIENTRY glutSolidDodecahedron(void);
+GLUTAPI void APIENTRY glutWireTeapot(GLdouble size);
+GLUTAPI void APIENTRY glutSolidTeapot(GLdouble size);
+GLUTAPI void APIENTRY glutWireOctahedron(void);
+GLUTAPI void APIENTRY glutSolidOctahedron(void);
+GLUTAPI void APIENTRY glutWireTetrahedron(void);
+GLUTAPI void APIENTRY glutSolidTetrahedron(void);
+GLUTAPI void APIENTRY glutWireIcosahedron(void);
+GLUTAPI void APIENTRY glutSolidIcosahedron(void);
+
+#endif /* __AGLUT_H__ */
diff --git a/nx-X11/extras/Mesa/include/GL/glutf90.h b/nx-X11/extras/Mesa/include/GL/glutf90.h
new file mode 100644
index 000000000..7ba3e19ef
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/glutf90.h
@@ -0,0 +1,81 @@
+#ifndef __glutf90_h__
+#define __glutf90_h__
+
+/* Copyright (c) Mark J. Kilgard & Willam F. Mitchell, 1998. */
+
+/* This program is freely distributable without licensing fees
+ and is provided without guarantee or warrantee expressed or
+ implied. This program is -not- in the public domain. */
+
+/* This header provides the binding interface for William Mitchell's
+ f90gl Fortran 90 GLUT binding. Other GLUT language bindings
+ can and should use this interace. */
+
+/* I appreciate the guidance from William Mitchell
+ (mitchell@cam.nist.gov) in developing this friend interface
+ for use by the f90gl package. See ../../README.fortran */
+
+#include <GL/glut.h>
+
+/* Which callback enumerants for the __glutSetFCB/__glutGetFCB routines. */
+/* NOTE These values are part of a binary interface for the f90gl Fortran
+ 90 binding and so must NOT changes (additions are allowed). */
+
+/* GLUTwindow callbacks. */
+#define GLUT_FCB_DISPLAY 0 /* GLUTdisplayFCB */
+#define GLUT_FCB_RESHAPE 1 /* GLUTreshapeFCB */
+#define GLUT_FCB_MOUSE 2 /* GLUTmouseFCB */
+#define GLUT_FCB_MOTION 3 /* GLUTmotionFCB */
+#define GLUT_FCB_PASSIVE 4 /* GLUTpassiveFCB */
+#define GLUT_FCB_ENTRY 5 /* GLUTentryFCB */
+#define GLUT_FCB_KEYBOARD 6 /* GLUTkeyboardFCB */
+#define GLUT_FCB_KEYBOARD_UP 7 /* GLUTkeyboardFCB */
+#define GLUT_FCB_WINDOW_STATUS 8 /* GLUTwindowStatusFCB */
+#define GLUT_FCB_VISIBILITY 9 /* GLUTvisibilityFCB */
+#define GLUT_FCB_SPECIAL 10 /* GLUTspecialFCB */
+#define GLUT_FCB_SPECIAL_UP 11 /* GLUTspecialFCB */
+#define GLUT_FCB_BUTTON_BOX 12 /* GLUTbuttonBoxFCB */
+#define GLUT_FCB_DIALS 13 /* GLUTdialsFCB */
+#define GLUT_FCB_SPACE_MOTION 14 /* GLUTspaceMotionFCB */
+#define GLUT_FCB_SPACE_ROTATE 15 /* GLUTspaceRotateFCB */
+#define GLUT_FCB_SPACE_BUTTON 16 /* GLUTspaceButtonFCB */
+#define GLUT_FCB_TABLET_MOTION 17 /* GLUTtabletMotionFCB */
+#define GLUT_FCB_TABLET_BUTTON 18 /* GLUTtabletButtonFCB */
+#define GLUT_FCB_JOYSTICK 19 /* GLUTjoystickFCB */
+/* Non-GLUTwindow callbacks. */
+#define GLUT_FCB_OVERLAY_DISPLAY 100 /* GLUTdisplayFCB */
+#define GLUT_FCB_SELECT 101 /* GLUTselectFCB */
+#define GLUT_FCB_TIMER 102 /* GLUTtimerFCB */
+
+/* GLUT Fortran callback function types. */
+typedef void (GLUTCALLBACK *GLUTdisplayFCB) (void);
+typedef void (GLUTCALLBACK *GLUTreshapeFCB) (int *, int *);
+/* NOTE the pressed key is int, not unsigned char for Fortran! */
+typedef void (GLUTCALLBACK *GLUTkeyboardFCB) (int *, int *, int *);
+typedef void (GLUTCALLBACK *GLUTmouseFCB) (int *, int *, int *, int *);
+typedef void (GLUTCALLBACK *GLUTmotionFCB) (int *, int *);
+typedef void (GLUTCALLBACK *GLUTpassiveFCB) (int *, int *);
+typedef void (GLUTCALLBACK *GLUTentryFCB) (int *);
+typedef void (GLUTCALLBACK *GLUTwindowStatusFCB) (int *);
+typedef void (GLUTCALLBACK *GLUTvisibilityFCB) (int *);
+typedef void (GLUTCALLBACK *GLUTspecialFCB) (int *, int *, int *);
+typedef void (GLUTCALLBACK *GLUTbuttonBoxFCB) (int *, int *);
+typedef void (GLUTCALLBACK *GLUTdialsFCB) (int *, int *);
+typedef void (GLUTCALLBACK *GLUTspaceMotionFCB) (int *, int *, int *);
+typedef void (GLUTCALLBACK *GLUTspaceRotateFCB) (int *, int *, int *);
+typedef void (GLUTCALLBACK *GLUTspaceButtonFCB) (int *, int *);
+typedef void (GLUTCALLBACK *GLUTtabletMotionFCB) (int *, int *);
+typedef void (GLUTCALLBACK *GLUTtabletButtonFCB) (int *, int *, int *, int *);
+typedef void (GLUTCALLBACK *GLUTjoystickFCB) (unsigned int *buttonMask, int *x, int *y, int *z);
+
+typedef void (GLUTCALLBACK *GLUTselectFCB) (int *);
+typedef void (GLUTCALLBACK *GLUTtimerFCB) (int *);
+typedef void (GLUTCALLBACK *GLUTmenuStateFCB) (int *); /* DEPRICATED. */
+typedef void (GLUTCALLBACK *GLUTmenuStatusFCB) (int *, int *, int *);
+typedef void (GLUTCALLBACK *GLUTidleFCB) (void);
+
+/* Functions that set and return Fortran callback functions. */
+GLUTAPI void* APIENTRY __glutGetFCB(int which);
+GLUTAPI void APIENTRY __glutSetFCB(int which, void *func);
+
+#endif /* __glutf90_h__ */
diff --git a/nx-X11/extras/Mesa/include/GL/glx.h b/nx-X11/extras/Mesa/include/GL/glx.h
new file mode 100644
index 000000000..ab0467c18
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/glx.h
@@ -0,0 +1,551 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef GLX_H
+#define GLX_H
+
+
+#ifdef __VMS
+#include <GL/vms_x_fix.h>
+# ifdef __cplusplus
+/* VMS Xlib.h gives problems with C++.
+ * this avoids a bunch of trivial warnings */
+#pragma message disable nosimpint
+#endif
+#endif
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#ifdef __VMS
+# ifdef __cplusplus
+#pragma message enable nosimpint
+#endif
+#endif
+#include <GL/gl.h>
+
+
+#if defined(USE_MGL_NAMESPACE)
+#include "glx_mangle.h"
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define GLX_VERSION_1_1 1
+#define GLX_VERSION_1_2 1
+#define GLX_VERSION_1_3 1
+#define GLX_VERSION_1_4 1
+
+#define GLX_EXTENSION_NAME "GLX"
+
+
+
+/*
+ * Tokens for glXChooseVisual and glXGetConfig:
+ */
+#define GLX_USE_GL 1
+#define GLX_BUFFER_SIZE 2
+#define GLX_LEVEL 3
+#define GLX_RGBA 4
+#define GLX_DOUBLEBUFFER 5
+#define GLX_STEREO 6
+#define GLX_AUX_BUFFERS 7
+#define GLX_RED_SIZE 8
+#define GLX_GREEN_SIZE 9
+#define GLX_BLUE_SIZE 10
+#define GLX_ALPHA_SIZE 11
+#define GLX_DEPTH_SIZE 12
+#define GLX_STENCIL_SIZE 13
+#define GLX_ACCUM_RED_SIZE 14
+#define GLX_ACCUM_GREEN_SIZE 15
+#define GLX_ACCUM_BLUE_SIZE 16
+#define GLX_ACCUM_ALPHA_SIZE 17
+
+
+/*
+ * Error codes returned by glXGetConfig:
+ */
+#define GLX_BAD_SCREEN 1
+#define GLX_BAD_ATTRIBUTE 2
+#define GLX_NO_EXTENSION 3
+#define GLX_BAD_VISUAL 4
+#define GLX_BAD_CONTEXT 5
+#define GLX_BAD_VALUE 6
+#define GLX_BAD_ENUM 7
+
+
+/*
+ * GLX 1.1 and later:
+ */
+#define GLX_VENDOR 1
+#define GLX_VERSION 2
+#define GLX_EXTENSIONS 3
+
+
+/*
+ * GLX 1.3 and later:
+ */
+#define GLX_CONFIG_CAVEAT 0x20
+#define GLX_DONT_CARE 0xFFFFFFFF
+#define GLX_X_VISUAL_TYPE 0x22
+#define GLX_TRANSPARENT_TYPE 0x23
+#define GLX_TRANSPARENT_INDEX_VALUE 0x24
+#define GLX_TRANSPARENT_RED_VALUE 0x25
+#define GLX_TRANSPARENT_GREEN_VALUE 0x26
+#define GLX_TRANSPARENT_BLUE_VALUE 0x27
+#define GLX_TRANSPARENT_ALPHA_VALUE 0x28
+#define GLX_WINDOW_BIT 0x00000001
+#define GLX_PIXMAP_BIT 0x00000002
+#define GLX_PBUFFER_BIT 0x00000004
+#define GLX_AUX_BUFFERS_BIT 0x00000010
+#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001
+#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002
+#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004
+#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008
+#define GLX_DEPTH_BUFFER_BIT 0x00000020
+#define GLX_STENCIL_BUFFER_BIT 0x00000040
+#define GLX_ACCUM_BUFFER_BIT 0x00000080
+#define GLX_NONE 0x8000
+#define GLX_SLOW_CONFIG 0x8001
+#define GLX_TRUE_COLOR 0x8002
+#define GLX_DIRECT_COLOR 0x8003
+#define GLX_PSEUDO_COLOR 0x8004
+#define GLX_STATIC_COLOR 0x8005
+#define GLX_GRAY_SCALE 0x8006
+#define GLX_STATIC_GRAY 0x8007
+#define GLX_TRANSPARENT_RGB 0x8008
+#define GLX_TRANSPARENT_INDEX 0x8009
+#define GLX_VISUAL_ID 0x800B
+#define GLX_SCREEN 0x800C
+#define GLX_NON_CONFORMANT_CONFIG 0x800D
+#define GLX_DRAWABLE_TYPE 0x8010
+#define GLX_RENDER_TYPE 0x8011
+#define GLX_X_RENDERABLE 0x8012
+#define GLX_FBCONFIG_ID 0x8013
+#define GLX_RGBA_TYPE 0x8014
+#define GLX_COLOR_INDEX_TYPE 0x8015
+#define GLX_MAX_PBUFFER_WIDTH 0x8016
+#define GLX_MAX_PBUFFER_HEIGHT 0x8017
+#define GLX_MAX_PBUFFER_PIXELS 0x8018
+#define GLX_PRESERVED_CONTENTS 0x801B
+#define GLX_LARGEST_PBUFFER 0x801C
+#define GLX_WIDTH 0x801D
+#define GLX_HEIGHT 0x801E
+#define GLX_EVENT_MASK 0x801F
+#define GLX_DAMAGED 0x8020
+#define GLX_SAVED 0x8021
+#define GLX_WINDOW 0x8022
+#define GLX_PBUFFER 0x8023
+#define GLX_PBUFFER_HEIGHT 0x8040
+#define GLX_PBUFFER_WIDTH 0x8041
+#define GLX_RGBA_BIT 0x00000001
+#define GLX_COLOR_INDEX_BIT 0x00000002
+#define GLX_PBUFFER_CLOBBER_MASK 0x08000000
+
+
+/*
+ * GLX 1.4 and later:
+ */
+#define GLX_SAMPLE_BUFFERS 0x186a0 /*100000*/
+#define GLX_SAMPLES 0x186a1 /*100001*/
+
+
+
+typedef struct __GLXcontextRec *GLXContext;
+typedef XID GLXPixmap;
+typedef XID GLXDrawable;
+/* GLX 1.3 and later */
+typedef struct __GLXFBConfigRec *GLXFBConfig;
+typedef XID GLXFBConfigID;
+typedef XID GLXContextID;
+typedef XID GLXWindow;
+typedef XID GLXPbuffer;
+
+
+
+extern XVisualInfo* glXChooseVisual( Display *dpy, int screen,
+ int *attribList );
+
+extern GLXContext glXCreateContext( Display *dpy, XVisualInfo *vis,
+ GLXContext shareList, Bool direct );
+
+extern void glXDestroyContext( Display *dpy, GLXContext ctx );
+
+extern Bool glXMakeCurrent( Display *dpy, GLXDrawable drawable,
+ GLXContext ctx);
+
+extern void glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
+ unsigned long mask );
+
+extern void glXSwapBuffers( Display *dpy, GLXDrawable drawable );
+
+extern GLXPixmap glXCreateGLXPixmap( Display *dpy, XVisualInfo *visual,
+ Pixmap pixmap );
+
+extern void glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap );
+
+extern Bool glXQueryExtension( Display *dpy, int *errorb, int *event );
+
+extern Bool glXQueryVersion( Display *dpy, int *maj, int *min );
+
+extern Bool glXIsDirect( Display *dpy, GLXContext ctx );
+
+extern int glXGetConfig( Display *dpy, XVisualInfo *visual,
+ int attrib, int *value );
+
+extern GLXContext glXGetCurrentContext( void );
+
+extern GLXDrawable glXGetCurrentDrawable( void );
+
+extern void glXWaitGL( void );
+
+extern void glXWaitX( void );
+
+extern void glXUseXFont( Font font, int first, int count, int list );
+
+
+
+/* GLX 1.1 and later */
+extern const char *glXQueryExtensionsString( Display *dpy, int screen );
+
+extern const char *glXQueryServerString( Display *dpy, int screen, int name );
+
+extern const char *glXGetClientString( Display *dpy, int name );
+
+
+/* GLX 1.2 and later */
+extern Display *glXGetCurrentDisplay( void );
+
+
+/* GLX 1.3 and later */
+extern GLXFBConfig *glXChooseFBConfig( Display *dpy, int screen,
+ const int *attribList, int *nitems );
+
+extern int glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
+ int attribute, int *value );
+
+extern GLXFBConfig *glXGetFBConfigs( Display *dpy, int screen,
+ int *nelements );
+
+extern XVisualInfo *glXGetVisualFromFBConfig( Display *dpy,
+ GLXFBConfig config );
+
+extern GLXWindow glXCreateWindow( Display *dpy, GLXFBConfig config,
+ Window win, const int *attribList );
+
+extern void glXDestroyWindow( Display *dpy, GLXWindow window );
+
+extern GLXPixmap glXCreatePixmap( Display *dpy, GLXFBConfig config,
+ Pixmap pixmap, const int *attribList );
+
+extern void glXDestroyPixmap( Display *dpy, GLXPixmap pixmap );
+
+extern GLXPbuffer glXCreatePbuffer( Display *dpy, GLXFBConfig config,
+ const int *attribList );
+
+extern void glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf );
+
+extern void glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
+ unsigned int *value );
+
+extern GLXContext glXCreateNewContext( Display *dpy, GLXFBConfig config,
+ int renderType, GLXContext shareList,
+ Bool direct );
+
+extern Bool glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
+ GLXDrawable read, GLXContext ctx );
+
+extern GLXDrawable glXGetCurrentReadDrawable( void );
+
+extern int glXQueryContext( Display *dpy, GLXContext ctx, int attribute,
+ int *value );
+
+extern void glXSelectEvent( Display *dpy, GLXDrawable drawable,
+ unsigned long mask );
+
+extern void glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
+ unsigned long *mask );
+
+
+/* GLX 1.4 and later */
+extern void (*glXGetProcAddress(const GLubyte *procname))( void );
+
+
+#ifndef GLX_GLXEXT_LEGACY
+
+#include <GL/glxext.h>
+
+#else
+
+
+/*
+ * 28. GLX_EXT_visual_info extension
+ */
+#ifndef GLX_EXT_visual_info
+#define GLX_EXT_visual_info 1
+
+#define GLX_X_VISUAL_TYPE_EXT 0x22
+#define GLX_TRANSPARENT_TYPE_EXT 0x23
+#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24
+#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25
+#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26
+#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27
+#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28
+#define GLX_TRUE_COLOR_EXT 0x8002
+#define GLX_DIRECT_COLOR_EXT 0x8003
+#define GLX_PSEUDO_COLOR_EXT 0x8004
+#define GLX_STATIC_COLOR_EXT 0x8005
+#define GLX_GRAY_SCALE_EXT 0x8006
+#define GLX_STATIC_GRAY_EXT 0x8007
+#define GLX_NONE_EXT 0x8000
+#define GLX_TRANSPARENT_RGB_EXT 0x8008
+#define GLX_TRANSPARENT_INDEX_EXT 0x8009
+
+#endif /* 28. GLX_EXT_visual_info extension */
+
+
+
+/*
+ * 41. GLX_SGI_video_sync
+ */
+#ifndef GLX_SGI_video_sync
+#define GLX_SGI_video_sync 1
+
+extern int glXGetVideoSyncSGI(unsigned int *count);
+extern int glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count);
+
+#endif /* GLX_SGI_video_sync */
+
+
+
+/*
+ * 42. GLX_EXT_visual_rating
+ */
+#ifndef GLX_EXT_visual_rating
+#define GLX_EXT_visual_rating 1
+
+#define GLX_VISUAL_CAVEAT_EXT 0x20
+/*#define GLX_NONE_EXT 0x8000*/
+#define GLX_SLOW_VISUAL_EXT 0x8001
+#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D
+
+#endif /* GLX_EXT_visual_rating */
+
+
+
+/*
+ * 47. GLX_EXT_import_context
+ */
+#ifndef GLX_EXT_import_context
+#define GLX_EXT_import_context 1
+
+#define GLX_SHARE_CONTEXT_EXT 0x800A
+#define GLX_VISUAL_ID_EXT 0x800B
+#define GLX_SCREEN_EXT 0x800C
+
+extern void glXFreeContextEXT(Display *dpy, GLXContext context);
+
+extern GLXContextID glXGetContextIDEXT(const GLXContext context);
+
+extern Display *glXGetCurrentDisplayEXT(void);
+
+extern GLXContext glXImportContextEXT(Display *dpy, GLXContextID contextID);
+
+extern int glXQueryContextInfoEXT(Display *dpy, GLXContext context,
+ int attribute,int *value);
+
+#endif /* GLX_EXT_import_context */
+
+
+
+/*
+ * 215. GLX_MESA_copy_sub_buffer
+ */
+#ifndef GLX_MESA_copy_sub_buffer
+#define GLX_MESA_copy_sub_buffer 1
+
+extern void glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
+ int x, int y, int width, int height );
+
+#endif
+
+
+
+/*
+ * 216. GLX_MESA_pixmap_colormap
+ */
+#ifndef GLX_MESA_pixmap_colormap
+#define GLX_MESA_pixmap_colormap 1
+
+extern GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual,
+ Pixmap pixmap, Colormap cmap );
+
+#endif /* GLX_MESA_pixmap_colormap */
+
+
+
+/*
+ * 217. GLX_MESA_release_buffers
+ */
+#ifndef GLX_MESA_release_buffers
+#define GLX_MESA_release_buffers 1
+
+extern Bool glXReleaseBuffersMESA( Display *dpy, GLXDrawable d );
+
+#endif /* GLX_MESA_release_buffers */
+
+
+
+/*
+ * 218. GLX_MESA_set_3dfx_mode
+ */
+#ifndef GLX_MESA_set_3dfx_mode
+#define GLX_MESA_set_3dfx_mode 1
+
+#define GLX_3DFX_WINDOW_MODE_MESA 0x1
+#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2
+
+extern Bool glXSet3DfxModeMESA( int mode );
+
+#endif /* GLX_MESA_set_3dfx_mode */
+
+
+
+/*
+ * ARB 2. GLX_ARB_get_proc_address
+ */
+#ifndef GLX_ARB_get_proc_address
+#define GLX_ARB_get_proc_address 1
+
+extern void (*glXGetProcAddressARB(const GLubyte *procName))();
+
+#endif /* GLX_ARB_get_proc_address */
+
+
+
+#endif /* GLX_GLXEXT_LEGACY */
+
+
+/**
+ ** The following aren't in glxext.h yet.
+ **/
+
+
+/*
+ * ???. GLX_NV_vertex_array_range
+ */
+#ifndef GLX_NV_vertex_array_range
+#define GLX_NV_vertex_array_range
+
+extern void *glXAllocateMemoryNV(GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
+extern void glXFreeMemoryNV(GLvoid *pointer);
+typedef void * ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
+typedef void ( * PFNGLXFREEMEMORYNVPROC) (GLvoid *pointer);
+
+#endif /* GLX_NV_vertex_array_range */
+
+
+
+/*
+ * ???. GLX_MESA_agp_offset
+ */
+#ifndef GLX_MESA_agp_offset
+#define GLX_MESA_agp_offset 1
+
+extern GLuint glXGetAGPOffsetMESA(const GLvoid *pointer);
+typedef GLuint (* PFNGLXGETAGPOFFSETMESAPROC) (const GLvoid *pointer);
+
+#endif /* GLX_MESA_agp_offset */
+
+
+/*
+ * ???. GLX_MESA_allocate_memory
+ */
+#ifndef GLX_MESA_allocate_memory
+#define GLX_MESA_allocate_memory 1
+
+extern void *glXAllocateMemoryMESA(Display *dpy, int scrn, size_t size, float readfreq, float writefreq, float priority);
+extern void glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer);
+extern GLuint glXGetMemoryOffsetMESA(Display *dpy, int scrn, const void *pointer);
+typedef void * ( * PFNGLXALLOCATEMEMORYMESAPROC) (Display *dpy, int scrn, size_t size, float readfreq, float writefreq, float priority);
+typedef void ( * PFNGLXFREEMEMORYMESAPROC) (Display *dpy, int scrn, void *pointer);
+typedef GLuint (* PFNGLXGETMEMORYOFFSETMESAPROC) (Display *dpy, int scrn, const void *pointer);
+
+#endif /* GLX_MESA_allocate_memory */
+
+/*
+ * ARB ?. GLX_ARB_render_texture
+ */
+#ifndef GLX_ARB_render_texture
+#define GLX_ARB_render_texture 1
+
+extern Bool glXBindTexImageARB(Display *dpy, GLXPbuffer pbuffer, int buffer);
+extern Bool glXReleaseTexImageARB(Display *dpy, GLXPbuffer pbuffer, int buffer);
+extern Bool glXDrawableAttribARB(Display *dpy, GLXDrawable draw, const int *attribList);
+
+#endif /* GLX_ARB_render_texture */
+
+
+/*
+ * Remove this when glxext.h is updated.
+ */
+#ifndef GLX_NV_float_buffer
+#define GLX_NV_float_buffer 1
+
+#define GLX_FLOAT_COMPONENTS_NV 0x20B0
+
+#endif /* GLX_NV_float_buffer */
+
+
+/*** Should these go here, or in another header? */
+/*
+** GLX Events
+*/
+typedef struct {
+ int event_type; /* GLX_DAMAGED or GLX_SAVED */
+ int draw_type; /* GLX_WINDOW or GLX_PBUFFER */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came for SendEvent request */
+ Display *display; /* display the event was read from */
+ GLXDrawable drawable; /* XID of Drawable */
+ unsigned int buffer_mask; /* mask indicating which buffers are affected */
+ unsigned int aux_buffer; /* which aux buffer was affected */
+ int x, y;
+ int width, height;
+ int count; /* if nonzero, at least this many more */
+} GLXPbufferClobberEvent;
+
+typedef union __GLXEvent {
+ GLXPbufferClobberEvent glxpbufferclobber;
+ long pad[24];
+} GLXEvent;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/glx_mangle.h b/nx-X11/extras/Mesa/include/GL/glx_mangle.h
new file mode 100644
index 000000000..d0b47d94e
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/glx_mangle.h
@@ -0,0 +1,55 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ * Copyright (C) 1995-1998 Brian Paul
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#ifndef GLX_MANGLE_H
+#define GLX_MANGLE_H
+
+#define glXChooseVisual mglXChooseVisual
+#define glXCreateContext mglXCreateContext
+#define glXDestroyContext mglXDestroyContext
+#define glXMakeCurrent mglXMakeCurrent
+#define glXCopyContext mglXCopyContext
+#define glXSwapBuffers mglXSwapBuffers
+#define glXCreateGLXPixmap mglXCreateGLXPixmap
+#define glXDestroyGLXPixmap mglXDestroyGLXPixmap
+#define glXQueryExtension mglXQueryExtension
+#define glXQueryVersion mglXQueryVersion
+#define glXIsDirect mglXIsDirect
+#define glXGetConfig mglXGetConfig
+#define glXGetCurrentContext mglXGetCurrentContext
+#define glXGetCurrentDrawable mglXGetCurrentDrawable
+#define glXWaitGL mglXWaitGL
+#define glXWaitX mglXWaitX
+#define glXUseXFont mglXUseXFont
+#define glXQueryExtensionsString mglXQueryExtensionsString
+#define glXQueryServerString mglXQueryServerString
+#define glXGetClientString mglXGetClientString
+#define glXCreateGLXPixmapMESA mglXCreateGLXPixmapMESA
+#define glXReleaseBuffersMESA mglXReleaseBuffersMESA
+#define glXCopySubBufferMESA mglXCopySubBufferMESA
+#define glXGetVideoSyncSGI mglXGetVideoSyncSGI
+#define glXWaitVideoSyncSGI mglXWaitVideoSyncSGI
+
+/* GLX 1.4 */
+#define glXGetProcAddress mglXGetProcAddress
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/glxext.h b/nx-X11/extras/Mesa/include/GL/glxext.h
new file mode 100644
index 000000000..589d1ef36
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/glxext.h
@@ -0,0 +1,693 @@
+#ifndef __glxext_h_
+#define __glxext_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+#ifndef APIENTRYP
+#define APIENTRYP APIENTRY *
+#endif
+#ifndef GLAPI
+#define GLAPI extern
+#endif
+
+/*************************************************************/
+
+/* Header file version number, required by OpenGL ABI for Linux */
+/* glxext.h last updated 2004/07/26 */
+/* Current version at http://oss.sgi.com/projects/ogl-sample/registry/ */
+#define GLX_GLXEXT_VERSION 6
+
+#ifndef GLX_VERSION_1_3
+#define GLX_WINDOW_BIT 0x00000001
+#define GLX_PIXMAP_BIT 0x00000002
+#define GLX_PBUFFER_BIT 0x00000004
+#define GLX_RGBA_BIT 0x00000001
+#define GLX_COLOR_INDEX_BIT 0x00000002
+#define GLX_PBUFFER_CLOBBER_MASK 0x08000000
+#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001
+#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002
+#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004
+#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008
+#define GLX_AUX_BUFFERS_BIT 0x00000010
+#define GLX_DEPTH_BUFFER_BIT 0x00000020
+#define GLX_STENCIL_BUFFER_BIT 0x00000040
+#define GLX_ACCUM_BUFFER_BIT 0x00000080
+#define GLX_CONFIG_CAVEAT 0x20
+#define GLX_X_VISUAL_TYPE 0x22
+#define GLX_TRANSPARENT_TYPE 0x23
+#define GLX_TRANSPARENT_INDEX_VALUE 0x24
+#define GLX_TRANSPARENT_RED_VALUE 0x25
+#define GLX_TRANSPARENT_GREEN_VALUE 0x26
+#define GLX_TRANSPARENT_BLUE_VALUE 0x27
+#define GLX_TRANSPARENT_ALPHA_VALUE 0x28
+#define GLX_DONT_CARE 0xFFFFFFFF
+#define GLX_NONE 0x8000
+#define GLX_SLOW_CONFIG 0x8001
+#define GLX_TRUE_COLOR 0x8002
+#define GLX_DIRECT_COLOR 0x8003
+#define GLX_PSEUDO_COLOR 0x8004
+#define GLX_STATIC_COLOR 0x8005
+#define GLX_GRAY_SCALE 0x8006
+#define GLX_STATIC_GRAY 0x8007
+#define GLX_TRANSPARENT_RGB 0x8008
+#define GLX_TRANSPARENT_INDEX 0x8009
+#define GLX_VISUAL_ID 0x800B
+#define GLX_SCREEN 0x800C
+#define GLX_NON_CONFORMANT_CONFIG 0x800D
+#define GLX_DRAWABLE_TYPE 0x8010
+#define GLX_RENDER_TYPE 0x8011
+#define GLX_X_RENDERABLE 0x8012
+#define GLX_FBCONFIG_ID 0x8013
+#define GLX_RGBA_TYPE 0x8014
+#define GLX_COLOR_INDEX_TYPE 0x8015
+#define GLX_MAX_PBUFFER_WIDTH 0x8016
+#define GLX_MAX_PBUFFER_HEIGHT 0x8017
+#define GLX_MAX_PBUFFER_PIXELS 0x8018
+#define GLX_PRESERVED_CONTENTS 0x801B
+#define GLX_LARGEST_PBUFFER 0x801C
+#define GLX_WIDTH 0x801D
+#define GLX_HEIGHT 0x801E
+#define GLX_EVENT_MASK 0x801F
+#define GLX_DAMAGED 0x8020
+#define GLX_SAVED 0x8021
+#define GLX_WINDOW 0x8022
+#define GLX_PBUFFER 0x8023
+#define GLX_PBUFFER_HEIGHT 0x8040
+#define GLX_PBUFFER_WIDTH 0x8041
+#endif
+
+#ifndef GLX_VERSION_1_4
+#define GLX_SAMPLE_BUFFERS 100000
+#define GLX_SAMPLES 100001
+#endif
+
+#ifndef GLX_ARB_get_proc_address
+#endif
+
+#ifndef GLX_ARB_multisample
+#define GLX_SAMPLE_BUFFERS_ARB 100000
+#define GLX_SAMPLES_ARB 100001
+#endif
+
+#ifndef GLX_SGIS_multisample
+#define GLX_SAMPLE_BUFFERS_SGIS 100000
+#define GLX_SAMPLES_SGIS 100001
+#endif
+
+#ifndef GLX_EXT_visual_info
+#define GLX_X_VISUAL_TYPE_EXT 0x22
+#define GLX_TRANSPARENT_TYPE_EXT 0x23
+#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24
+#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25
+#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26
+#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27
+#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28
+#define GLX_NONE_EXT 0x8000
+#define GLX_TRUE_COLOR_EXT 0x8002
+#define GLX_DIRECT_COLOR_EXT 0x8003
+#define GLX_PSEUDO_COLOR_EXT 0x8004
+#define GLX_STATIC_COLOR_EXT 0x8005
+#define GLX_GRAY_SCALE_EXT 0x8006
+#define GLX_STATIC_GRAY_EXT 0x8007
+#define GLX_TRANSPARENT_RGB_EXT 0x8008
+#define GLX_TRANSPARENT_INDEX_EXT 0x8009
+#endif
+
+#ifndef GLX_SGI_swap_control
+#endif
+
+#ifndef GLX_SGI_video_sync
+#endif
+
+#ifndef GLX_SGI_make_current_read
+#endif
+
+#ifndef GLX_SGIX_video_source
+#endif
+
+#ifndef GLX_EXT_visual_rating
+#define GLX_VISUAL_CAVEAT_EXT 0x20
+#define GLX_SLOW_VISUAL_EXT 0x8001
+#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D
+/* reuse GLX_NONE_EXT */
+#endif
+
+#ifndef GLX_EXT_import_context
+#define GLX_SHARE_CONTEXT_EXT 0x800A
+#define GLX_VISUAL_ID_EXT 0x800B
+#define GLX_SCREEN_EXT 0x800C
+#endif
+
+#ifndef GLX_SGIX_fbconfig
+#define GLX_WINDOW_BIT_SGIX 0x00000001
+#define GLX_PIXMAP_BIT_SGIX 0x00000002
+#define GLX_RGBA_BIT_SGIX 0x00000001
+#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002
+#define GLX_DRAWABLE_TYPE_SGIX 0x8010
+#define GLX_RENDER_TYPE_SGIX 0x8011
+#define GLX_X_RENDERABLE_SGIX 0x8012
+#define GLX_FBCONFIG_ID_SGIX 0x8013
+#define GLX_RGBA_TYPE_SGIX 0x8014
+#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015
+/* reuse GLX_SCREEN_EXT */
+#endif
+
+#ifndef GLX_SGIX_pbuffer
+#define GLX_PBUFFER_BIT_SGIX 0x00000004
+#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000
+#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001
+#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002
+#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004
+#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008
+#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010
+#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020
+#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040
+#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080
+#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100
+#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016
+#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017
+#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018
+#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019
+#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A
+#define GLX_PRESERVED_CONTENTS_SGIX 0x801B
+#define GLX_LARGEST_PBUFFER_SGIX 0x801C
+#define GLX_WIDTH_SGIX 0x801D
+#define GLX_HEIGHT_SGIX 0x801E
+#define GLX_EVENT_MASK_SGIX 0x801F
+#define GLX_DAMAGED_SGIX 0x8020
+#define GLX_SAVED_SGIX 0x8021
+#define GLX_WINDOW_SGIX 0x8022
+#define GLX_PBUFFER_SGIX 0x8023
+#endif
+
+#ifndef GLX_SGI_cushion
+#endif
+
+#ifndef GLX_SGIX_video_resize
+#define GLX_SYNC_FRAME_SGIX 0x00000000
+#define GLX_SYNC_SWAP_SGIX 0x00000001
+#endif
+
+#ifndef GLX_SGIX_dmbuffer
+#define GLX_DIGITAL_MEDIA_PBUFFER_SGIX 0x8024
+#endif
+
+#ifndef GLX_SGIX_swap_group
+#endif
+
+#ifndef GLX_SGIX_swap_barrier
+#endif
+
+#ifndef GLX_SGIS_blended_overlay
+#define GLX_BLENDED_RGBA_SGIS 0x8025
+#endif
+
+#ifndef GLX_SGIS_shared_multisample
+#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026
+#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027
+#endif
+
+#ifndef GLX_SUN_get_transparent_index
+#endif
+
+#ifndef GLX_3DFX_multisample
+#define GLX_SAMPLE_BUFFERS_3DFX 0x8050
+#define GLX_SAMPLES_3DFX 0x8051
+#endif
+
+#ifndef GLX_MESA_copy_sub_buffer
+#endif
+
+#ifndef GLX_MESA_pixmap_colormap
+#endif
+
+#ifndef GLX_MESA_release_buffers
+#endif
+
+#ifndef GLX_MESA_set_3dfx_mode
+#define GLX_3DFX_WINDOW_MODE_MESA 0x1
+#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2
+#endif
+
+#ifndef GLX_SGIX_visual_select_group
+#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028
+#endif
+
+#ifndef GLX_OML_swap_method
+#define GLX_SWAP_METHOD_OML 0x8060
+#define GLX_SWAP_EXCHANGE_OML 0x8061
+#define GLX_SWAP_COPY_OML 0x8062
+#define GLX_SWAP_UNDEFINED_OML 0x8063
+#endif
+
+#ifndef GLX_OML_sync_control
+#endif
+
+#ifndef GLX_SGIX_hyperpipe_group
+#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80
+#define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91
+#define GLX_BAD_HYPERPIPE_SGIX 92
+#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001
+#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002
+#define GLX_PIPE_RECT_SGIX 0x00000001
+#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002
+#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003
+#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004
+#define GLX_HYPERPIPE_ID_SGIX 0x8030
+#endif
+
+#ifndef GLX_MESA_agp_offset
+#endif
+
+
+/*************************************************************/
+
+#ifndef GLX_ARB_get_proc_address
+typedef void (*__GLXextFuncPtr)(void);
+#endif
+
+#ifndef GLX_SGIX_video_source
+typedef XID GLXVideoSourceSGIX;
+#endif
+
+#ifndef GLX_SGIX_fbconfig
+typedef XID GLXFBConfigIDSGIX;
+typedef struct __GLXFBConfigRec *GLXFBConfigSGIX;
+#endif
+
+#ifndef GLX_SGIX_pbuffer
+typedef XID GLXPbufferSGIX;
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came for SendEvent request */
+ Display *display; /* display the event was read from */
+ GLXDrawable drawable; /* i.d. of Drawable */
+ int event_type; /* GLX_DAMAGED_SGIX or GLX_SAVED_SGIX */
+ int draw_type; /* GLX_WINDOW_SGIX or GLX_PBUFFER_SGIX */
+ unsigned int mask; /* mask indicating which buffers are affected*/
+ int x, y;
+ int width, height;
+ int count; /* if nonzero, at least this many more */
+} GLXBufferClobberEventSGIX;
+#endif
+
+#if defined(__sun__)
+#include <inttypes.h>
+#if defined(__STDC__)
+#if defined(__arch64__)
+typedef long int int64_t;
+#else
+typedef long long int int64_t;
+#endif /* __arch64__ */
+#endif /* __STDC__ */
+#elif defined(__UNIXOS2__) || defined(__SOL64__)
+typedef long int int32_t;
+typedef long long int int64_t;
+#elif defined( __VMS )
+#include <inttypes.h>
+#elif defined(__SCO__) || defined(__USLC__)
+#include <stdint.h>
+#elif defined(WIN32) && defined(__GNUC__)
+#include <stdint.h>
+#endif
+
+#ifndef GLX_VERSION_1_3
+#define GLX_VERSION_1_3 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern GLXFBConfig * glXGetFBConfigs (Display *, int, int *);
+extern GLXFBConfig * glXChooseFBConfig (Display *, int, const int *, int *);
+extern int glXGetFBConfigAttrib (Display *, GLXFBConfig, int, int *);
+extern XVisualInfo * glXGetVisualFromFBConfig (Display *, GLXFBConfig);
+extern GLXWindow glXCreateWindow (Display *, GLXFBConfig, Window, const int *);
+extern void glXDestroyWindow (Display *, GLXWindow);
+extern GLXPixmap glXCreatePixmap (Display *, GLXFBConfig, Pixmap, const int *);
+extern void glXDestroyPixmap (Display *, GLXPixmap);
+extern GLXPbuffer glXCreatePbuffer (Display *, GLXFBConfig, const int *);
+extern void glXDestroyPbuffer (Display *, GLXPbuffer);
+extern void glXQueryDrawable (Display *, GLXDrawable, int, unsigned int *);
+extern GLXContext glXCreateNewContext (Display *, GLXFBConfig, int, GLXContext, Bool);
+extern Bool glXMakeContextCurrent (Display *, GLXDrawable, GLXDrawable, GLXContext);
+extern GLXDrawable glXGetCurrentReadDrawable (void);
+extern Display * glXGetCurrentDisplay (void);
+extern int glXQueryContext (Display *, GLXContext, int, int *);
+extern void glXSelectEvent (Display *, GLXDrawable, unsigned long);
+extern void glXGetSelectedEvent (Display *, GLXDrawable, unsigned long *);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef GLXFBConfig * ( * PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements);
+typedef GLXFBConfig * ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements);
+typedef int ( * PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value);
+typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config);
+typedef GLXWindow ( * PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list);
+typedef void ( * PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win);
+typedef GLXPixmap ( * PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list);
+typedef void ( * PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap);
+typedef GLXPbuffer ( * PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list);
+typedef void ( * PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf);
+typedef void ( * PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
+typedef GLXContext ( * PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct);
+typedef Bool ( * PFNGLXMAKECONTEXTCURRENTPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
+typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLEPROC) (void);
+typedef Display * ( * PFNGLXGETCURRENTDISPLAYPROC) (void);
+typedef int ( * PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value);
+typedef void ( * PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask);
+typedef void ( * PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask);
+#endif
+
+#ifndef GLX_VERSION_1_4
+#define GLX_VERSION_1_4 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern __GLXextFuncPtr glXGetProcAddress (const GLubyte *);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName);
+#endif
+
+#ifndef GLX_ARB_get_proc_address
+#define GLX_ARB_get_proc_address 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef __GLXextFuncPtr ( * PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName);
+#endif
+
+#ifndef GLX_ARB_multisample
+#define GLX_ARB_multisample 1
+#endif
+
+#ifndef GLX_SGIS_multisample
+#define GLX_SGIS_multisample 1
+#endif
+
+#ifndef GLX_EXT_visual_info
+#define GLX_EXT_visual_info 1
+#endif
+
+#ifndef GLX_SGI_swap_control
+#define GLX_SGI_swap_control 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern int glXSwapIntervalSGI (int);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval);
+#endif
+
+#ifndef GLX_SGI_video_sync
+#define GLX_SGI_video_sync 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern int glXGetVideoSyncSGI (unsigned int *);
+extern int glXWaitVideoSyncSGI (int, int, unsigned int *);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int *count);
+typedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int *count);
+#endif
+
+#ifndef GLX_SGI_make_current_read
+#define GLX_SGI_make_current_read 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern Bool glXMakeCurrentReadSGI (Display *, GLXDrawable, GLXDrawable, GLXContext);
+extern GLXDrawable glXGetCurrentReadDrawableSGI (void);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
+typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void);
+#endif
+
+#ifndef GLX_SGIX_video_source
+#define GLX_SGIX_video_source 1
+#ifdef _VL_H
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX (Display *, int, VLServer, VLPath, int, VLNode);
+extern void glXDestroyGLXVideoSourceSGIX (Display *, GLXVideoSourceSGIX);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef GLXVideoSourceSGIX ( * PFNGLXCREATEGLXVIDEOSOURCESGIXPROC) (Display *display, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode);
+typedef void ( * PFNGLXDESTROYGLXVIDEOSOURCESGIXPROC) (Display *dpy, GLXVideoSourceSGIX glxvideosource);
+#endif /* _VL_H */
+#endif
+
+#ifndef GLX_EXT_visual_rating
+#define GLX_EXT_visual_rating 1
+#endif
+
+#ifndef GLX_EXT_import_context
+#define GLX_EXT_import_context 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern Display * glXGetCurrentDisplayEXT (void);
+extern int glXQueryContextInfoEXT (Display *, GLXContext, int, int *);
+extern GLXContextID glXGetContextIDEXT (const GLXContext);
+extern GLXContext glXImportContextEXT (Display *, GLXContextID);
+extern void glXFreeContextEXT (Display *, GLXContext);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef Display * ( * PFNGLXGETCURRENTDISPLAYEXTPROC) (void);
+typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display *dpy, GLXContext context, int attribute, int *value);
+typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context);
+typedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display *dpy, GLXContextID contextID);
+typedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display *dpy, GLXContext context);
+#endif
+
+#ifndef GLX_SGIX_fbconfig
+#define GLX_SGIX_fbconfig 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern int glXGetFBConfigAttribSGIX (Display *, GLXFBConfigSGIX, int, int *);
+extern GLXFBConfigSGIX * glXChooseFBConfigSGIX (Display *, int, int *, int *);
+extern GLXPixmap glXCreateGLXPixmapWithConfigSGIX (Display *, GLXFBConfigSGIX, Pixmap);
+extern GLXContext glXCreateContextWithConfigSGIX (Display *, GLXFBConfigSGIX, int, GLXContext, Bool);
+extern XVisualInfo * glXGetVisualFromFBConfigSGIX (Display *, GLXFBConfigSGIX);
+extern GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX (Display *, XVisualInfo *);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value);
+typedef GLXFBConfigSGIX * ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, int *attrib_list, int *nelements);
+typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap);
+typedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct);
+typedef XVisualInfo * ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfigSGIX config);
+typedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display *dpy, XVisualInfo *vis);
+#endif
+
+#ifndef GLX_SGIX_pbuffer
+#define GLX_SGIX_pbuffer 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern GLXPbufferSGIX glXCreateGLXPbufferSGIX (Display *, GLXFBConfigSGIX, unsigned int, unsigned int, int *);
+extern void glXDestroyGLXPbufferSGIX (Display *, GLXPbufferSGIX);
+extern int glXQueryGLXPbufferSGIX (Display *, GLXPbufferSGIX, int, unsigned int *);
+extern void glXSelectEventSGIX (Display *, GLXDrawable, unsigned long);
+extern void glXGetSelectedEventSGIX (Display *, GLXDrawable, unsigned long *);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef GLXPbufferSGIX ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list);
+typedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf);
+typedef int ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value);
+typedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long mask);
+typedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display *dpy, GLXDrawable drawable, unsigned long *mask);
+#endif
+
+#ifndef GLX_SGI_cushion
+#define GLX_SGI_cushion 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern void glXCushionSGI (Display *, Window, float);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef void ( * PFNGLXCUSHIONSGIPROC) (Display *dpy, Window window, float cushion);
+#endif
+
+#ifndef GLX_SGIX_video_resize
+#define GLX_SGIX_video_resize 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern int glXBindChannelToWindowSGIX (Display *, int, int, Window);
+extern int glXChannelRectSGIX (Display *, int, int, int, int, int, int);
+extern int glXQueryChannelRectSGIX (Display *, int, int, int *, int *, int *, int *);
+extern int glXQueryChannelDeltasSGIX (Display *, int, int, int *, int *, int *, int *);
+extern int glXChannelRectSyncSGIX (Display *, int, int, GLenum);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display *display, int screen, int channel, Window window);
+typedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int x, int y, int w, int h);
+typedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display *display, int screen, int channel, int *dx, int *dy, int *dw, int *dh);
+typedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display *display, int screen, int channel, int *x, int *y, int *w, int *h);
+typedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display *display, int screen, int channel, GLenum synctype);
+#endif
+
+#ifndef GLX_SGIX_dmbuffer
+#define GLX_SGIX_dmbuffer 1
+#ifdef _DM_BUFFER_H_
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern Bool glXAssociateDMPbufferSGIX (Display *, GLXPbufferSGIX, DMparams *, DMbuffer);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef Bool ( * PFNGLXASSOCIATEDMPBUFFERSGIXPROC) (Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer);
+#endif /* _DM_BUFFER_H_ */
+#endif
+
+#ifndef GLX_SGIX_swap_group
+#define GLX_SGIX_swap_group 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern void glXJoinSwapGroupSGIX (Display *, GLXDrawable, GLXDrawable);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member);
+#endif
+
+#ifndef GLX_SGIX_swap_barrier
+#define GLX_SGIX_swap_barrier 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern void glXBindSwapBarrierSGIX (Display *, GLXDrawable, int);
+extern Bool glXQueryMaxSwapBarriersSGIX (Display *, int, int *);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier);
+typedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max);
+#endif
+
+#ifndef GLX_SUN_get_transparent_index
+#define GLX_SUN_get_transparent_index 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern Status glXGetTransparentIndexSUN (Display *, Window, Window, long *);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display *dpy, Window overlay, Window underlay, long *pTransparentIndex);
+#endif
+
+#ifndef GLX_MESA_copy_sub_buffer
+#define GLX_MESA_copy_sub_buffer 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern void glXCopySubBufferMESA (Display *, GLXDrawable, int, int, int, int);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);
+#endif
+
+#ifndef GLX_MESA_pixmap_colormap
+#define GLX_MESA_pixmap_colormap 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern GLXPixmap glXCreateGLXPixmapMESA (Display *, XVisualInfo *, Pixmap, Colormap);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display *dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap);
+#endif
+
+#ifndef GLX_MESA_release_buffers
+#define GLX_MESA_release_buffers 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern Bool glXReleaseBuffersMESA (Display *, GLXDrawable);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display *dpy, GLXDrawable drawable);
+#endif
+
+#ifndef GLX_MESA_set_3dfx_mode
+#define GLX_MESA_set_3dfx_mode 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern Bool glXSet3DfxModeMESA (int);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef Bool ( * PFNGLXSET3DFXMODEMESAPROC) (int mode);
+#endif
+
+#ifndef GLX_SGIX_visual_select_group
+#define GLX_SGIX_visual_select_group 1
+#endif
+
+#ifndef GLX_OML_swap_method
+#define GLX_OML_swap_method 1
+#endif
+
+#ifndef GLX_OML_sync_control
+#define GLX_OML_sync_control 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern Bool glXGetSyncValuesOML (Display *, GLXDrawable, int64_t *, int64_t *, int64_t *);
+extern Bool glXGetMscRateOML (Display *, GLXDrawable, int32_t *, int32_t *);
+extern int64_t glXSwapBuffersMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t);
+extern Bool glXWaitForMscOML (Display *, GLXDrawable, int64_t, int64_t, int64_t, int64_t *, int64_t *, int64_t *);
+extern Bool glXWaitForSbcOML (Display *, GLXDrawable, int64_t, int64_t *, int64_t *, int64_t *);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t *ust, int64_t *msc, int64_t *sbc);
+typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display *dpy, GLXDrawable drawable, int32_t *numerator, int32_t *denominator);
+typedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder);
+typedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc);
+typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display *dpy, GLXDrawable drawable, int64_t target_sbc, int64_t *ust, int64_t *msc, int64_t *sbc);
+#endif
+
+#ifndef GLX_SGIX_hyperpipe_group
+#define GLX_SGIX_hyperpipe_group 1
+
+typedef struct {
+ char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
+ int networkId;
+} GLXHyperpipeNetworkSGIX;
+
+typedef struct {
+ char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
+ int channel;
+ unsigned int
+ participationType;
+ int timeSlice;
+} GLXHyperpipeConfigSGIX;
+
+typedef struct {
+ char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
+ int srcXOrigin, srcYOrigin, srcWidth, srcHeight;
+ int destXOrigin, destYOrigin, destWidth, destHeight;
+} GLXPipeRect;
+
+typedef struct {
+ char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX];
+ int XOrigin, YOrigin, maxHeight, maxWidth;
+} GLXPipeRectLimits;
+
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern GLXHyperpipeNetworkSGIX * glXQueryHyperpipeNetworkSGIX (Display *, int *);
+extern int glXHyperpipeConfigSGIX (Display *, int, int, GLXHyperpipeConfigSGIX *, int *);
+extern GLXHyperpipeConfigSGIX * glXQueryHyperpipeConfigSGIX (Display *, int, int *);
+extern int glXDestroyHyperpipeConfigSGIX (Display *, int);
+extern int glXBindHyperpipeSGIX (Display *, int);
+extern int glXQueryHyperpipeBestAttribSGIX (Display *, int, int, int, void *, void *);
+extern int glXHyperpipeAttribSGIX (Display *, int, int, int, void *);
+extern int glXQueryHyperpipeAttribSGIX (Display *, int, int, int, void *);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes);
+typedef int ( * PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId);
+typedef GLXHyperpipeConfigSGIX * ( * PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes);
+typedef int ( * PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId);
+typedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId);
+typedef int ( * PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList);
+typedef int ( * PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList);
+typedef int ( * PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList);
+#endif
+
+#ifndef GLX_MESA_agp_offset
+#define GLX_MESA_agp_offset 1
+#ifdef GLX_GLXEXT_PROTOTYPES
+extern unsigned int glXGetAGPOffsetMESA (const void *);
+#endif /* GLX_GLXEXT_PROTOTYPES */
+typedef unsigned int ( * PFNGLXGETAGPOFFSETMESAPROC) (const void *pointer);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/internal/dri_interface.h b/nx-X11/extras/Mesa/include/GL/internal/dri_interface.h
new file mode 100644
index 000000000..0f3555b57
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/internal/dri_interface.h
@@ -0,0 +1,477 @@
+/*
+ * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file dri_interface.h
+ *
+ * This file contains all the types and functions that define the interface
+ * between a DRI driver and driver loader. Currently, the most common driver
+ * loader is the XFree86 libGL.so. However, other loaders do exist, and in
+ * the future the server-side libglx.a will also be a loader.
+ *
+ * \author Kevin E. Martin <kevin@precisioninsight.com>
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#ifndef DRI_INTERFACE_H
+#define DRI_INTERFACE_H
+
+#include <GL/internal/glcore.h>
+#include <drm.h>
+
+/**
+ * \name DRI interface structures
+ *
+ * The following structures define the interface between the GLX client
+ * side library and the DRI (direct rendering infrastructure).
+ */
+/*@{*/
+typedef struct __DRIdisplayRec __DRIdisplay;
+typedef struct __DRIscreenRec __DRIscreen;
+typedef struct __DRIcontextRec __DRIcontext;
+typedef struct __DRIdrawableRec __DRIdrawable;
+typedef struct __DRIdriverRec __DRIdriver;
+typedef struct __DRIframebufferRec __DRIframebuffer;
+typedef struct __DRIversionRec __DRIversion;
+typedef struct __DRIinterfaceMethodsRec __DRIinterfaceMethods;
+typedef unsigned long __DRIid;
+typedef void __DRInativeDisplay;
+/*@}*/
+
+
+/**
+ * \name Functions provided by the driver loader.
+ */
+/*@{*/
+/**
+ * Type of a pointer to \c glXGetScreenDriver, as returned by
+ * \c glXGetProcAddress. This function is used to get the name of the DRI
+ * driver for the specified screen of the specified display. The driver
+ * name is typically used with \c glXGetDriverConfig.
+ *
+ * \sa glXGetScreenDriver, glXGetProcAddress, glXGetDriverConfig
+ */
+typedef const char * (* PFNGLXGETSCREENDRIVERPROC) (__DRInativeDisplay *dpy, int scrNum);
+
+/**
+ * Type of a pointer to \c glXGetDriverConfig, as returned by
+ * \c glXGetProcAddress. This function is used to get the XML document
+ * describing the configuration options available for the specified driver.
+ *
+ * \sa glXGetDriverConfig, glXGetProcAddress, glXGetScreenDriver
+ */
+typedef const char * (* PFNGLXGETDRIVERCONFIGPROC) (const char *driverName);
+
+/**
+ * Type of a pointer to \c glxEnableExtension, as returned by
+ * \c __DRIinterfaceMethods::getProcAddress. This function is used to enable
+ * a GLX extension on the specified screen.
+ */
+typedef void (* PFNGLXSCRENABLEEXTENSIONPROC) ( void *psc, const char * name );
+/*@}*/
+
+
+/**
+ * \name Functions and data provided by the driver.
+ */
+/*@{*/
+
+typedef void *(CREATENEWSCREENFUNC)(__DRInativeDisplay *dpy, int scrn,
+ __DRIscreen *psc, const __GLcontextModes * modes,
+ const __DRIversion * ddx_version, const __DRIversion * dri_version,
+ const __DRIversion * drm_version, const __DRIframebuffer * frame_buffer,
+ void * pSAREA, int fd, int internal_api_version,
+ const __DRIinterfaceMethods * interface,
+ __GLcontextModes ** driver_modes);
+typedef CREATENEWSCREENFUNC* PFNCREATENEWSCREENFUNC;
+extern CREATENEWSCREENFUNC __driCreateNewScreen_20050727;
+
+
+/**
+ * XML document describing the configuration options supported by the
+ * driver.
+ */
+extern const char __driConfigOptions[];
+
+/*@}*/
+
+
+/**
+ * Stored version of some component (i.e., server-side DRI module, kernel-side
+ * DRM, etc.).
+ *
+ * \todo
+ * There are several data structures that explicitly store a major version,
+ * minor version, and patch level. These structures should be modified to
+ * have a \c __DRIversionRec instead.
+ */
+struct __DRIversionRec {
+ int major; /**< Major version number. */
+ int minor; /**< Minor version number. */
+ int patch; /**< Patch-level. */
+};
+
+
+typedef void (*__DRIfuncPtr)(void);
+
+struct __DRIinterfaceMethodsRec {
+ /**
+ * Get pointer to named function.
+ */
+ __DRIfuncPtr (*getProcAddress)( const char * proc_name );
+
+ /**
+ * Create a list of \c __GLcontextModes structures.
+ */
+ __GLcontextModes * (*createContextModes)(unsigned count,
+ size_t minimum_bytes_per_struct);
+
+ /**
+ * Destroy a list of \c __GLcontextModes structures.
+ *
+ * \todo
+ * Determine if the drivers actually need to call this.
+ */
+ void (*destroyContextModes)( __GLcontextModes * modes );
+
+ /**
+ * Get the \c __DRIscreen for a given display and screen number.
+ */
+ __DRIscreen *(*getScreen)(__DRInativeDisplay *dpy, int screenNum);
+
+
+ /**
+ * \name Client/server protocol functions.
+ *
+ * These functions implement the DRI client/server protocol for
+ * context and drawable operations. Platforms that do not implement
+ * the wire protocol (e.g., EGL) will implement glorified no-op functions.
+ */
+ /*@{*/
+ /**
+ * Determine if the specified window ID still exists.
+ *
+ * \note
+ * Implementations may assume that the driver will only pass an ID into
+ * this function that actually corresponds to a window. On
+ * implementations where windows can only be destroyed by the DRI driver
+ * (e.g., EGL), this function is allowed to always return \c GL_TRUE.
+ */
+ GLboolean (*windowExists)(__DRInativeDisplay *dpy, __DRIid draw);
+
+ /**
+ * Create the server-side portion of the GL context.
+ */
+ GLboolean (* createContext)( __DRInativeDisplay *dpy, int screenNum,
+ int configID, void * contextID, drm_context_t * hw_context );
+
+ /**
+ * Destroy the server-side portion of the GL context.
+ */
+ GLboolean (* destroyContext)( __DRInativeDisplay *dpy, int screenNum,
+ __DRIid context );
+
+ /**
+ * Create the server-side portion of the drawable.
+ */
+ GLboolean (*createDrawable)( __DRInativeDisplay * ndpy, int screen,
+ __DRIid drawable, drm_drawable_t * hHWDrawable );
+
+ /**
+ * Destroy the server-side portion of the drawable.
+ */
+ GLboolean (*destroyDrawable)( __DRInativeDisplay * ndpy, int screen,
+ __DRIid drawable );
+
+ /**
+ * This function is used to get information about the position, size, and
+ * clip rects of a drawable.
+ */
+ GLboolean (* getDrawableInfo) ( __DRInativeDisplay *dpy, int scrn,
+ __DRIid draw, unsigned int * index, unsigned int * stamp,
+ int * x, int * y, int * width, int * height,
+ int * numClipRects, drm_clip_rect_t ** pClipRects,
+ int * backX, int * backY,
+ int * numBackClipRects, drm_clip_rect_t ** pBackClipRects );
+ /*@}*/
+
+
+ /**
+ * \name Timing related functions.
+ */
+ /*@{*/
+ /**
+ * Get the 64-bit unadjusted system time (UST).
+ */
+ int (*getUST)(int64_t * ust);
+
+ /**
+ * Get the media stream counter (MSC) rate.
+ *
+ * Matching the definition in GLX_OML_sync_control, this function returns
+ * the rate of the "media stream counter". In practical terms, this is
+ * the frame refresh rate of the display.
+ */
+ GLboolean (*getMSCRate)(__DRInativeDisplay * dpy, __DRIid drawable,
+ int32_t * numerator, int32_t * denominator);
+ /*@}*/
+};
+
+
+/**
+ * Framebuffer information record. Used by libGL to communicate information
+ * about the framebuffer to the driver's \c __driCreateNewScreen function.
+ *
+ * In XFree86, most of this information is derrived from data returned by
+ * calling \c XF86DRIGetDeviceInfo.
+ *
+ * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
+ * __driUtilCreateNewScreen CallCreateNewScreen
+ *
+ * \bug This structure could be better named.
+ */
+struct __DRIframebufferRec {
+ unsigned char *base; /**< Framebuffer base address in the CPU's
+ * address space. This value is calculated by
+ * calling \c drmMap on the framebuffer handle
+ * returned by \c XF86DRIGetDeviceInfo (or a
+ * similar function).
+ */
+ int size; /**< Framebuffer size, in bytes. */
+ int stride; /**< Number of bytes from one line to the next. */
+ int width; /**< Pixel width of the framebuffer. */
+ int height; /**< Pixel height of the framebuffer. */
+ int dev_priv_size; /**< Size of the driver's dev-priv structure. */
+ void *dev_priv; /**< Pointer to the driver's dev-priv structure. */
+};
+
+
+/**
+ * Screen dependent methods. This structure is initialized during the
+ * \c __DRIdisplayRec::createScreen call.
+ */
+struct __DRIscreenRec {
+ /**
+ * Method to destroy the private DRI screen data.
+ */
+ void (*destroyScreen)(__DRInativeDisplay *dpy, int scrn, void *screenPrivate);
+
+ /**
+ * Method to create the private DRI drawable data and initialize the
+ * drawable dependent methods.
+ */
+ void *(*createNewDrawable)(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
+ __DRIid draw, __DRIdrawable *pdraw,
+ int renderType, const int *attrs);
+
+ /**
+ * Method to return a pointer to the DRI drawable data.
+ */
+ __DRIdrawable *(*getDrawable)(__DRInativeDisplay *dpy, __DRIid draw,
+ void *drawablePrivate);
+
+ /**
+ * Opaque pointer to private per screen direct rendering data. \c NULL
+ * if direct rendering is not supported on this screen. Never
+ * dereferenced in libGL.
+ */
+ void *private;
+
+ /**
+ * Get the number of vertical refreshes since some point in time before
+ * this function was first called (i.e., system start up).
+ *
+ * \since Internal API version 20030317.
+ */
+ int (*getMSC)( void *screenPrivate, int64_t *msc );
+
+ /**
+ * Opaque pointer that points back to the containing
+ * \c __GLXscreenConfigs. This data structure is shared with DRI drivers
+ * but \c __GLXscreenConfigs is not. However, they are needed by some GLX
+ * functions called by DRI drivers.
+ *
+ * \since Internal API version 20030813.
+ */
+ void *screenConfigs;
+
+ /**
+ * Functions associated with MESA_allocate_memory.
+ *
+ * \since Internal API version 20030815.
+ */
+ /*@{*/
+ void *(*allocateMemory)(__DRInativeDisplay *dpy, int scrn, GLsizei size,
+ GLfloat readfreq, GLfloat writefreq,
+ GLfloat priority);
+
+ void (*freeMemory)(__DRInativeDisplay *dpy, int scrn, GLvoid *pointer);
+
+ GLuint (*memoryOffset)(__DRInativeDisplay *dpy, int scrn, const GLvoid *pointer);
+ /*@}*/
+
+ /**
+ * Method to create the private DRI context data and initialize the
+ * context dependent methods.
+ *
+ * \since Internal API version 20031201.
+ */
+ void * (*createNewContext)(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
+ int render_type,
+ void *sharedPrivate, __DRIcontext *pctx);
+};
+
+/**
+ * Context dependent methods. This structure is initialized during the
+ * \c __DRIscreenRec::createContext call.
+ */
+struct __DRIcontextRec {
+ /**
+ * Method to destroy the private DRI context data.
+ */
+ void (*destroyContext)(__DRInativeDisplay *dpy, int scrn, void *contextPrivate);
+
+ /**
+ * Opaque pointer to private per context direct rendering data.
+ * \c NULL if direct rendering is not supported on the display or
+ * screen used to create this context. Never dereferenced in libGL.
+ */
+ void *private;
+
+ /**
+ * Pointer to the mode used to create this context.
+ *
+ * \since Internal API version 20040317.
+ */
+ const __GLcontextModes * mode;
+
+ /**
+ * Method to bind a DRI drawable to a DRI graphics context.
+ *
+ * \since Internal API version 20050727.
+ */
+ GLboolean (*bindContext)(__DRInativeDisplay *dpy, int scrn, __DRIid draw,
+ __DRIid read, __DRIcontext *ctx);
+
+ /**
+ * Method to unbind a DRI drawable from a DRI graphics context.
+ *
+ * \since Internal API version 20050727.
+ */
+ GLboolean (*unbindContext)(__DRInativeDisplay *dpy, int scrn, __DRIid draw,
+ __DRIid read, __DRIcontext *ctx);
+};
+
+/**
+ * Drawable dependent methods. This structure is initialized during the
+ * \c __DRIscreenRec::createDrawable call. \c createDrawable is not called
+ * by libGL at this time. It's currently used via the dri_util.c utility code
+ * instead.
+ */
+struct __DRIdrawableRec {
+ /**
+ * Method to destroy the private DRI drawable data.
+ */
+ void (*destroyDrawable)(__DRInativeDisplay *dpy, void *drawablePrivate);
+
+ /**
+ * Method to swap the front and back buffers.
+ */
+ void (*swapBuffers)(__DRInativeDisplay *dpy, void *drawablePrivate);
+
+ /**
+ * Opaque pointer to private per drawable direct rendering data.
+ * \c NULL if direct rendering is not supported on the display or
+ * screen used to create this drawable. Never dereferenced in libGL.
+ */
+ void *private;
+
+ /**
+ * Get the number of completed swap buffers for this drawable.
+ *
+ * \since Internal API version 20030317.
+ */
+ int (*getSBC)(__DRInativeDisplay *dpy, void *drawablePrivate, int64_t *sbc );
+
+ /**
+ * Wait for the SBC to be greater than or equal target_sbc.
+ *
+ * \since Internal API version 20030317.
+ */
+ int (*waitForSBC)( __DRInativeDisplay * dpy, void *drawablePriv,
+ int64_t target_sbc,
+ int64_t * msc, int64_t * sbc );
+
+ /**
+ * Wait for the MSC to equal target_msc, or, if that has already passed,
+ * the next time (MSC % divisor) is equal to remainder. If divisor is
+ * zero, the function will return as soon as MSC is greater than or equal
+ * to target_msc.
+ *
+ * \since Internal API version 20030317.
+ */
+ int (*waitForMSC)( __DRInativeDisplay * dpy, void *drawablePriv,
+ int64_t target_msc, int64_t divisor, int64_t remainder,
+ int64_t * msc, int64_t * sbc );
+
+ /**
+ * Like \c swapBuffers, but does NOT have an implicit \c glFlush. Once
+ * rendering is complete, waits until MSC is equal to target_msc, or
+ * if that has already passed, waits until (MSC % divisor) is equal
+ * to remainder. If divisor is zero, the swap will happen as soon as
+ * MSC is greater than or equal to target_msc.
+ *
+ * \since Internal API version 20030317.
+ */
+ int64_t (*swapBuffersMSC)(__DRInativeDisplay *dpy, void *drawablePrivate,
+ int64_t target_msc,
+ int64_t divisor, int64_t remainder);
+
+ /**
+ * Enable or disable frame usage tracking.
+ *
+ * \since Internal API version 20030317.
+ */
+ int (*frameTracking)(__DRInativeDisplay *dpy, void *drawablePrivate, GLboolean enable);
+
+ /**
+ * Retrieve frame usage information.
+ *
+ * \since Internal API version 20030317.
+ */
+ int (*queryFrameTracking)(__DRInativeDisplay *dpy, void *drawablePrivate,
+ int64_t * sbc, int64_t * missedFrames,
+ float * lastMissedUsage, float * usage );
+
+ /**
+ * Used by drivers that implement the GLX_SGI_swap_control or
+ * GLX_MESA_swap_control extension.
+ *
+ * \since Internal API version 20030317.
+ */
+ unsigned swap_interval;
+};
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/internal/glcore.h b/nx-X11/extras/Mesa/include/GL/internal/glcore.h
new file mode 100644
index 000000000..9626dc698
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/internal/glcore.h
@@ -0,0 +1,499 @@
+/* $XFree86: xc/lib/GL/include/GL/internal/glcore.h,v 1.7 2001/03/25 05:32:00 tsi Exp $ */
+#ifndef __gl_core_h_
+#define __gl_core_h_
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#ifndef XFree86LOADER
+#include <sys/types.h>
+#endif
+
+#ifdef CAPI
+#undef CAPI
+#endif
+#define CAPI
+
+#define GL_CORE_SGI 1
+#define GL_CORE_MESA 2
+#define GL_CORE_APPLE 4
+#define GL_CORE_WINDOWS 8
+
+typedef struct __GLcontextRec __GLcontext;
+typedef struct __GLinterfaceRec __GLinterface;
+
+/*
+** This file defines the interface between the GL core and the surrounding
+** "operating system" that supports it (currently the GLX or WGL extensions).
+**
+** Members (data and function pointers) are documented as imported or
+** exported according to how they are used by the core rendering functions.
+** Imported members are initialized by the "operating system" and used by
+** the core functions. Exported members are initialized by the core functions
+** and used by the "operating system".
+*/
+
+/*
+** Mode and limit information for a context. This information is
+** kept around in the context so that values can be used during
+** command execution, and for returning information about the
+** context to the application.
+*/
+typedef struct __GLcontextModesRec {
+ struct __GLcontextModesRec * next;
+
+ GLboolean rgbMode;
+ GLboolean floatMode;
+ GLboolean colorIndexMode;
+ GLuint doubleBufferMode;
+ GLuint stereoMode;
+
+ GLboolean haveAccumBuffer;
+ GLboolean haveDepthBuffer;
+ GLboolean haveStencilBuffer;
+
+ GLint redBits, greenBits, blueBits, alphaBits; /* bits per comp */
+ GLuint redMask, greenMask, blueMask, alphaMask;
+ GLint rgbBits; /* total bits for rgb */
+ GLint indexBits; /* total bits for colorindex */
+
+ GLint accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits;
+ GLint depthBits;
+ GLint stencilBits;
+
+ GLint numAuxBuffers;
+
+ GLint level;
+
+ GLint pixmapMode;
+
+ /* GLX */
+ GLint visualID;
+ GLint visualType; /**< One of the GLX X visual types. (i.e.,
+ * \c GLX_TRUE_COLOR, etc.)
+ */
+
+ /* EXT_visual_rating / GLX 1.2 */
+ GLint visualRating;
+
+ /* EXT_visual_info / GLX 1.2 */
+ GLint transparentPixel;
+ /* colors are floats scaled to ints */
+ GLint transparentRed, transparentGreen, transparentBlue, transparentAlpha;
+ GLint transparentIndex;
+
+ /* ARB_multisample / SGIS_multisample */
+ GLint sampleBuffers;
+ GLint samples;
+
+ /* SGIX_fbconfig / GLX 1.3 */
+ GLint drawableType;
+ GLint renderType;
+ GLint xRenderable;
+ GLint fbconfigID;
+
+ /* SGIX_pbuffer / GLX 1.3 */
+ GLint maxPbufferWidth;
+ GLint maxPbufferHeight;
+ GLint maxPbufferPixels;
+ GLint optimalPbufferWidth; /* Only for SGIX_pbuffer. */
+ GLint optimalPbufferHeight; /* Only for SGIX_pbuffer. */
+
+ /* SGIX_visual_select_group */
+ GLint visualSelectGroup;
+
+ /* OML_swap_method */
+ GLint swapMethod;
+
+ GLint screen;
+} __GLcontextModes;
+
+/* Several fields of __GLcontextModes can take these as values. Since
+ * GLX header files may not be available everywhere they need to be used,
+ * redefine them here.
+ */
+#define GLX_NONE 0x8000
+#define GLX_SLOW_CONFIG 0x8001
+#define GLX_TRUE_COLOR 0x8002
+#define GLX_DIRECT_COLOR 0x8003
+#define GLX_PSEUDO_COLOR 0x8004
+#define GLX_STATIC_COLOR 0x8005
+#define GLX_GRAY_SCALE 0x8006
+#define GLX_STATIC_GRAY 0x8007
+#define GLX_TRANSPARENT_RGB 0x8008
+#define GLX_TRANSPARENT_INDEX 0x8009
+#define GLX_NON_CONFORMANT_CONFIG 0x800D
+#define GLX_SWAP_EXCHANGE_OML 0x8061
+#define GLX_SWAP_COPY_OML 0x8062
+#define GLX_SWAP_UNDEFINED_OML 0x8063
+
+#define GLX_DONT_CARE 0xFFFFFFFF
+
+#define GLX_RGBA_BIT 0x00000001
+#define GLX_COLOR_INDEX_BIT 0x00000002
+#define GLX_WINDOW_BIT 0x00000001
+#define GLX_PIXMAP_BIT 0x00000002
+#define GLX_PBUFFER_BIT 0x00000004
+
+/************************************************************************/
+
+/*
+** Structure used for allocating and freeing drawable private memory.
+** (like software buffers, for example).
+**
+** The memory allocation routines are provided by the surrounding
+** "operating system" code, and they are to be used for allocating
+** software buffers and things which are associated with the drawable,
+** and used by any context which draws to that drawable. There are
+** separate memory allocation functions for drawables and contexts
+** since drawables and contexts can be created and destroyed independently
+** of one another, and the "operating system" may want to use separate
+** allocation arenas for each.
+**
+** The freePrivate function is filled in by the core routines when they
+** allocates software buffers, and stick them in "private". The freePrivate
+** function will destroy anything allocated to this drawable (to be called
+** when the drawable is destroyed).
+*/
+typedef struct __GLdrawableRegionRec __GLdrawableRegion;
+typedef struct __GLdrawableBufferRec __GLdrawableBuffer;
+typedef struct __GLdrawablePrivateRec __GLdrawablePrivate;
+
+typedef struct __GLregionRectRec {
+ /* lower left (inside the rectangle) */
+ GLint x0, y0;
+ /* upper right (outside the rectangle) */
+ GLint x1, y1;
+} __GLregionRect;
+
+struct __GLdrawableRegionRec {
+ GLint numRects;
+ __GLregionRect *rects;
+ __GLregionRect boundingRect;
+};
+
+/************************************************************************/
+
+/* masks for the buffers */
+#define __GL_FRONT_BUFFER_MASK 0x00000001
+#define __GL_FRONT_LEFT_BUFFER_MASK 0x00000001
+#define __GL_FRONT_RIGHT_BUFFER_MASK 0x00000002
+#define __GL_BACK_BUFFER_MASK 0x00000004
+#define __GL_BACK_LEFT_BUFFER_MASK 0x00000004
+#define __GL_BACK_RIGHT_BUFFER_MASK 0x00000008
+#define __GL_ACCUM_BUFFER_MASK 0x00000010
+#define __GL_DEPTH_BUFFER_MASK 0x00000020
+#define __GL_STENCIL_BUFFER_MASK 0x00000040
+#define __GL_AUX_BUFFER_MASK(i) (0x0000080 << (i))
+
+#define __GL_ALL_BUFFER_MASK 0xffffffff
+
+/* what Resize routines return if resize resorted to fallback case */
+#define __GL_BUFFER_FALLBACK 0x10
+
+typedef void (*__GLbufFallbackInitFn)(__GLdrawableBuffer *buf,
+ __GLdrawablePrivate *glPriv, GLint bits);
+typedef void (*__GLbufMainInitFn)(__GLdrawableBuffer *buf,
+ __GLdrawablePrivate *glPriv, GLint bits,
+ __GLbufFallbackInitFn back);
+
+/*
+** A drawable buffer
+**
+** This data structure describes the context side of a drawable.
+**
+** According to the spec there could be multiple contexts bound to the same
+** drawable at the same time (from different threads). In order to avoid
+** multiple-access conflicts, locks are used to serialize access. When a
+** thread needs to access (read or write) a member of the drawable, it takes
+** a lock first. Some of the entries in the drawable are treated "mostly
+** constant", so we take the freedom of allowing access to them without
+** taking a lock (for optimization reasons).
+**
+** For more details regarding locking, see buffers.h in the GL core
+*/
+struct __GLdrawableBufferRec {
+ /*
+ ** Buffer dimensions
+ */
+ GLint width, height, depth;
+
+ /*
+ ** Framebuffer base address
+ */
+ void *base;
+
+ /*
+ ** Framebuffer size (in bytes)
+ */
+ GLuint size;
+
+ /*
+ ** Size (in bytes) of each element in the framebuffer
+ */
+ GLuint elementSize;
+ GLuint elementSizeLog2;
+
+ /*
+ ** Element skip from one scanline to the next.
+ ** If the buffer is part of another buffer (for example, fullscreen
+ ** front buffer), outerWidth is the width of that buffer.
+ */
+ GLint outerWidth;
+
+ /*
+ ** outerWidth * elementSize
+ */
+ GLint byteWidth;
+
+ /*
+ ** Allocation/deallocation is done based on this handle. A handle
+ ** is conceptually different from the framebuffer 'base'.
+ */
+ void *handle;
+
+ /* imported */
+ GLboolean (*resize)(__GLdrawableBuffer *buf,
+ GLint x, GLint y, GLuint width, GLuint height,
+ __GLdrawablePrivate *glPriv, GLuint bufferMask);
+ void (*lock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
+ void (*unlock)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
+ void (*fill)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv,
+ GLuint val, GLint x, GLint y, GLint w, GLint h);
+ void (*free)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
+
+ /* exported */
+ void (*freePrivate)(__GLdrawableBuffer *buf, __GLdrawablePrivate *glPriv);
+#ifdef __cplusplus
+ void *privatePtr;
+#else
+ void *private;
+#endif
+
+ /* private */
+ void *other; /* implementation private data */
+ __GLbufMainInitFn mainInit;
+ __GLbufFallbackInitFn fallbackInit;
+};
+
+/*
+** The context side of the drawable private
+*/
+struct __GLdrawablePrivateRec {
+ /*
+ ** Drawable Modes
+ */
+ __GLcontextModes *modes;
+
+ /*
+ ** Drawable size
+ */
+ GLuint width, height;
+
+ /*
+ ** Origin in screen coordinates of the drawable
+ */
+ GLint xOrigin, yOrigin;
+#ifdef __GL_ALIGNED_BUFFERS
+ /*
+ ** Drawable offset from screen origin
+ */
+ GLint xOffset, yOffset;
+
+ /*
+ ** Alignment restriction
+ */
+ GLint xAlignment, yAlignment;
+#endif
+ /*
+ ** Should we invert the y axis?
+ */
+ GLint yInverted;
+
+ /*
+ ** Mask specifying which buffers are renderable by the hw
+ */
+ GLuint accelBufferMask;
+
+ /*
+ ** the buffers themselves
+ */
+ __GLdrawableBuffer frontBuffer;
+ __GLdrawableBuffer backBuffer;
+ __GLdrawableBuffer accumBuffer;
+ __GLdrawableBuffer depthBuffer;
+ __GLdrawableBuffer stencilBuffer;
+#if defined(__GL_NUMBER_OF_AUX_BUFFERS) && (__GL_NUMBER_OF_AUX_BUFFERS > 0)
+ __GLdrawableBuffer *auxBuffer;
+#endif
+
+ __GLdrawableRegion ownershipRegion;
+
+ /*
+ ** Lock for the drawable private structure
+ */
+ void *lock;
+#ifdef DEBUG
+ /* lock debugging info */
+ int lockRefCount;
+ int lockLine[10];
+ char *lockFile[10];
+#endif
+
+ /* imported */
+ void *(*malloc)(size_t size);
+ void *(*calloc)(size_t numElem, size_t elemSize);
+ void *(*realloc)(void *oldAddr, size_t newSize);
+ void (*free)(void *addr);
+
+ GLboolean (*addSwapRect)(__GLdrawablePrivate *glPriv,
+ GLint x, GLint y, GLsizei width, GLsizei height);
+ void (*setClipRect)(__GLdrawablePrivate *glPriv,
+ GLint x, GLint y, GLsizei width, GLsizei height);
+ void (*updateClipRegion)(__GLdrawablePrivate *glPriv);
+ GLboolean (*resize)(__GLdrawablePrivate *glPriv);
+ void (*getDrawableSize)(__GLdrawablePrivate *glPriv,
+ GLint *x, GLint *y, GLuint *width, GLuint *height);
+
+ void (*lockDP)(__GLdrawablePrivate *glPriv, __GLcontext *gc);
+ void (*unlockDP)(__GLdrawablePrivate *glPriv);
+
+ /* exported */
+#ifdef __cplusplus
+ void *privatePtr;
+#else
+ void *private;
+#endif
+ void (*freePrivate)(__GLdrawablePrivate *);
+
+ /* client data */
+ void *other;
+};
+
+/*
+** Macros to lock/unlock the drawable private
+*/
+#if defined(DEBUG)
+#define __GL_LOCK_DP(glPriv,gc) \
+ (*(glPriv)->lockDP)(glPriv,gc); \
+ (glPriv)->lockLine[(glPriv)->lockRefCount] = __LINE__; \
+ (glPriv)->lockFile[(glPriv)->lockRefCount] = __FILE__; \
+ (glPriv)->lockRefCount++
+#define __GL_UNLOCK_DP(glPriv) \
+ (glPriv)->lockRefCount--; \
+ (glPriv)->lockLine[(glPriv)->lockRefCount] = 0; \
+ (glPriv)->lockFile[(glPriv)->lockRefCount] = NULL; \
+ (*(glPriv)->unlockDP)(glPriv)
+#else /* DEBUG */
+#define __GL_LOCK_DP(glPriv,gc) (*(glPriv)->lockDP)(glPriv,gc)
+#define __GL_UNLOCK_DP(glPriv) (*(glPriv)->unlockDP)(glPriv)
+#endif /* DEBUG */
+
+
+/*
+** Procedures which are imported by the GL from the surrounding
+** "operating system". Math functions are not considered part of the
+** "operating system".
+*/
+typedef struct __GLimportsRec {
+ /* Memory management */
+ void * (*malloc)(__GLcontext *gc, size_t size);
+ void *(*calloc)(__GLcontext *gc, size_t numElem, size_t elemSize);
+ void *(*realloc)(__GLcontext *gc, void *oldAddr, size_t newSize);
+ void (*free)(__GLcontext *gc, void *addr);
+
+ /* Error handling */
+ void (*warning)(__GLcontext *gc, char *fmt);
+ void (*fatal)(__GLcontext *gc, char *fmt);
+
+ /* other system calls */
+ char *(CAPI *getenv)(__GLcontext *gc, const char *var);
+ int (CAPI *atoi)(__GLcontext *gc, const char *str);
+ int (CAPI *sprintf)(__GLcontext *gc, char *str, const char *fmt, ...);
+ void *(CAPI *fopen)(__GLcontext *gc, const char *path, const char *mode);
+ int (CAPI *fclose)(__GLcontext *gc, void *stream);
+ int (CAPI *fprintf)(__GLcontext *gc, void *stream, const char *fmt, ...);
+
+ /* Drawing surface management */
+ __GLdrawablePrivate *(*getDrawablePrivate)(__GLcontext *gc);
+ __GLdrawablePrivate *(*getReadablePrivate)(__GLcontext *gc);
+
+ /* Operating system dependent data goes here */
+ void *other;
+} __GLimports;
+
+/************************************************************************/
+
+/*
+** Procedures which are exported by the GL to the surrounding "operating
+** system" so that it can manage multiple GL context's.
+*/
+typedef struct __GLexportsRec {
+ /* Context management (return GL_FALSE on failure) */
+ GLboolean (*destroyContext)(__GLcontext *gc);
+ GLboolean (*loseCurrent)(__GLcontext *gc);
+ /* oldglPriv isn't used anymore, kept for backwards compatibility */
+ GLboolean (*makeCurrent)(__GLcontext *gc);
+ GLboolean (*shareContext)(__GLcontext *gc, __GLcontext *gcShare);
+ GLboolean (*copyContext)(__GLcontext *dst, const __GLcontext *src, GLuint mask);
+ GLboolean (*forceCurrent)(__GLcontext *gc);
+
+ /* Drawing surface notification callbacks */
+ GLboolean (*notifyResize)(__GLcontext *gc);
+ void (*notifyDestroy)(__GLcontext *gc);
+ void (*notifySwapBuffers)(__GLcontext *gc);
+
+ /* Dispatch table override control for external agents like libGLS */
+ struct __GLdispatchStateRec* (*dispatchExec)(__GLcontext *gc);
+ void (*beginDispatchOverride)(__GLcontext *gc);
+ void (*endDispatchOverride)(__GLcontext *gc);
+} __GLexports;
+
+/************************************************************************/
+
+/*
+** This must be the first member of a __GLcontext structure. This is the
+** only part of a context that is exposed to the outside world; everything
+** else is opaque.
+*/
+struct __GLinterfaceRec {
+ __GLimports imports;
+ __GLexports exports;
+};
+
+extern __GLcontext *__glCoreCreateContext(__GLimports *, __GLcontextModes *);
+extern void __glCoreNopDispatch(void);
+
+#endif /* __gl_core_h_ */
diff --git a/nx-X11/extras/Mesa/include/GL/internal/sarea.h b/nx-X11/extras/Mesa/include/GL/internal/sarea.h
new file mode 100644
index 000000000..77c16e0ef
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/internal/sarea.h
@@ -0,0 +1,94 @@
+/* $XFree86: xc/programs/Xserver/GL/dri/sarea.h,v 1.11 2002/10/30 12:52:03 alanh Exp $ */
+/**
+ * \file sarea.h
+ * SAREA definitions.
+ *
+ * \author Kevin E. Martin <kevin@precisioninsight.com>
+ * \author Jens Owen <jens@tungstengraphics.com>
+ * \author Rickard E. (Rik) Faith <faith@valinux.com>
+ */
+
+/*
+ * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc.
+ * 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.
+ */
+
+/* $XFree86: xc/programs/Xserver/GL/dri/sarea.h,v 1.11 2002/10/30 12:52:03 alanh Exp $ */
+
+#ifndef _SAREA_H_
+#define _SAREA_H_
+
+#include "xf86drm.h"
+
+/* SAREA area needs to be at least a page */
+#if defined(__alpha__)
+#define SAREA_MAX 0x2000
+#elif defined(__ia64__)
+#define SAREA_MAX 0x10000 /* 64kB */
+#else
+/* Intel 830M driver needs at least 8k SAREA */
+#define SAREA_MAX 0x2000
+#endif
+
+#define SAREA_MAX_DRAWABLES 256
+
+#define SAREA_DRAWABLE_CLAIMED_ENTRY 0x80000000
+
+/**
+ * SAREA per drawable information.
+ *
+ * \sa _XF86DRISAREA.
+ */
+typedef struct _XF86DRISAREADrawable {
+ unsigned int stamp;
+ unsigned int flags;
+} XF86DRISAREADrawableRec, *XF86DRISAREADrawablePtr;
+
+/**
+ * SAREA frame information.
+ *
+ * \sa _XF86DRISAREA.
+ */
+typedef struct _XF86DRISAREAFrame {
+ unsigned int x;
+ unsigned int y;
+ unsigned int width;
+ unsigned int height;
+ unsigned int fullscreen;
+} XF86DRISAREAFrameRec, *XF86DRISAREAFramePtr;
+
+/**
+ * SAREA definition.
+ */
+typedef struct _XF86DRISAREA {
+ /** first thing is always the DRM locking structure */
+ drmLock lock;
+ /** \todo Use readers/writer lock for drawable_lock */
+ drmLock drawable_lock;
+ XF86DRISAREADrawableRec drawableTable[SAREA_MAX_DRAWABLES];
+ XF86DRISAREAFrameRec frame;
+ drm_context_t dummy_context;
+} XF86DRISAREARec, *XF86DRISAREAPtr;
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/mesa_wgl.h b/nx-X11/extras/Mesa/include/GL/mesa_wgl.h
new file mode 100644
index 000000000..21473763e
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/mesa_wgl.h
@@ -0,0 +1,123 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.1
+ *
+ * Copyright (C) 1999 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.
+ */
+
+
+/* prototypes for the Mesa WGL functions */
+/* relocated here so that I could make GLUT get them properly */
+
+#define _mesa_wgl_h_
+
+#ifndef _mesa_wgl_h_
+#define _mesa_wgl_h_
+
+
+#include <GL/gl.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#if !defined(OPENSTEP) && (defined(__WIN32__) || defined(__CYGWIN32__))
+# if (defined(_MSC_VER) || defined(__MINGW32__)) && 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(__MINGW32__)) && 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
+#else
+/* non-Windows compilation */
+# define GLAPI extern
+# define GLAPIENTRY
+#endif /* WIN32 / CYGWIN32 bracket */
+
+
+#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP)
+#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;
+#endif
+
+
+#ifdef _MSC_VER
+# pragma warning( disable : 4615 ) /* pragma warning : unknown user warning type*/
+# pragma warning( push )
+# pragma warning( disable : 4273 ) /* 'function' : inconsistent DLL linkage. dllexport assumed. */
+#endif
+
+WGLAPI int GLAPIENTRY wglDeleteContext(HGLRC);
+WGLAPI int GLAPIENTRY wglMakeCurrent(HDC,HGLRC);
+WGLAPI int GLAPIENTRY wglSetPixelFormat(HDC, int, const PIXELFORMATDESCRIPTOR *);
+WGLAPI int GLAPIENTRY wglSwapBuffers(HDC hdc);
+WGLAPI HDC GLAPIENTRY wglGetCurrentDC(void);
+WGLAPI HGLRC GLAPIENTRY wglCreateContext(HDC);
+WGLAPI HGLRC GLAPIENTRY wglCreateLayerContext(HDC,int);
+WGLAPI HGLRC GLAPIENTRY wglGetCurrentContext(void);
+WGLAPI PROC GLAPIENTRY wglGetProcAddress(const char*);
+WGLAPI int GLAPIENTRY wglChoosePixelFormat(HDC, const PIXELFORMATDESCRIPTOR *);
+WGLAPI int GLAPIENTRY wglCopyContext(HGLRC, HGLRC, unsigned int);
+WGLAPI int GLAPIENTRY wglDeleteContext(HGLRC);
+WGLAPI int GLAPIENTRY wglDescribeLayerPlane(HDC, int, int, unsigned int,LPLAYERPLANEDESCRIPTOR);
+WGLAPI int GLAPIENTRY wglDescribePixelFormat(HDC,int, unsigned int, LPPIXELFORMATDESCRIPTOR);
+WGLAPI int GLAPIENTRY wglGetLayerPaletteEntries(HDC, int, int, int,COLORREF *);
+WGLAPI int GLAPIENTRY wglGetPixelFormat(HDC hdc);
+WGLAPI int GLAPIENTRY wglMakeCurrent(HDC, HGLRC);
+WGLAPI int GLAPIENTRY wglRealizeLayerPalette(HDC, int, int);
+WGLAPI int GLAPIENTRY wglSetLayerPaletteEntries(HDC, int, int, int,const COLORREF *);
+WGLAPI int GLAPIENTRY wglShareLists(HGLRC, HGLRC);
+WGLAPI int GLAPIENTRY wglSwapLayerBuffers(HDC, unsigned int);
+WGLAPI int GLAPIENTRY wglUseFontBitmapsA(HDC, unsigned long, unsigned long, unsigned long);
+WGLAPI int GLAPIENTRY wglUseFontBitmapsW(HDC, unsigned long, unsigned long, unsigned long);
+WGLAPI int GLAPIENTRY wglUseFontOutlinesA(HDC, unsigned long, unsigned long, unsigned long, float,float, int, LPGLYPHMETRICSFLOAT);
+WGLAPI int GLAPIENTRY wglUseFontOutlinesW(HDC, unsigned long, unsigned long, unsigned long, float,float, int, LPGLYPHMETRICSFLOAT);
+WGLAPI int GLAPIENTRY SwapBuffers(HDC);
+WGLAPI int GLAPIENTRY ChoosePixelFormat(HDC,const PIXELFORMATDESCRIPTOR *);
+WGLAPI int GLAPIENTRY DescribePixelFormat(HDC,int,unsigned int,LPPIXELFORMATDESCRIPTOR);
+WGLAPI int GLAPIENTRY GetPixelFormat(HDC);
+WGLAPI int GLAPIENTRY SetPixelFormat(HDC,int,const PIXELFORMATDESCRIPTOR *);
+
+#ifdef _MSC_VER
+# pragma warning( pop )
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _mesa_wgl_h_ */
diff --git a/nx-X11/extras/Mesa/include/GL/mglmesa.h b/nx-X11/extras/Mesa/include/GL/mglmesa.h
new file mode 100644
index 000000000..d9ba61c17
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/mglmesa.h
@@ -0,0 +1,79 @@
+/****************************************************************************
+*
+* Mesa bindings for SciTech MGL
+*
+* Copyright (C) 1996 SciTech Software.
+* All rights reserved.
+*
+* Filename: mglmesa.h
+* Version: Revision: 1.1.1.1
+*
+* Language: ANSI C
+* Environment: Any
+*
+* Description: Header file for the Mesa/OpenGL interface bindings for the
+* SciTech MGL graphics library. Uses the MGL internal
+* device context structures to get direct access to the
+* high performance MGL rasterization functions for maximum
+* performance. Utilizes the VESA VBE/AF Accelerator Functions
+* via the MGL's accelerated device driver functions, as well
+* as basic DirectDraw accelerated functions provided by the
+* MGL.
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Library General Public
+* License as published by the Free Software Foundation; either
+* version 2 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Library General Public License for more details.
+*
+* You should have received a copy of the GNU Library General Public
+* License along with this library; if not, write to the Free
+* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*
+*
+****************************************************************************/
+
+#ifndef __MGLMESA_H
+#define __MGLMESA_H
+
+#include "mgraph.h"
+
+/*------------------------- Function Prototypes ---------------------------*/
+
+#ifdef __cplusplus
+extern "C" { /* Use "C" linkage when in C++ mode */
+#endif
+
+#ifndef __WINDOWS__
+#define GLAPIENTRY
+#endif
+
+#ifdef __WINDOWS__
+bool GLAPIENTRY MGLMesaInitDLL(MGLCallbacks *cb,char *version);
+#endif
+void GLAPIENTRY MGLMesaChooseVisual(MGLDC *dc,MGLVisual *visual);
+bool GLAPIENTRY MGLMesaSetVisual(MGLDC *dc,MGLVisual *visual);
+bool GLAPIENTRY MGLMesaCreateContext(MGLDC *dc,bool forceMemDC);
+void GLAPIENTRY MGLMesaDestroyContext(MGLDC *dc);
+void GLAPIENTRY MGLMesaMakeCurrent(MGLDC *dc);
+void GLAPIENTRY MGLMesaSwapBuffers(MGLDC *dc,bool waitVRT);
+
+/* Palette manipulation support. The reason we provide palette manipulation
+ * routines is so that when rendering in double buffered modes with a
+ * software backbuffer, the palette for the backbuffer is kept consistent
+ * with the hardware front buffer.
+ */
+
+void GLAPIENTRY MGLMesaSetPaletteEntry(MGLDC *dc,int entry,uchar red,uchar green,uchar blue);
+void GLAPIENTRY MGLMesaSetPalette(MGLDC *dc,palette_t *pal,int numColors,int startIndex);
+void GLAPIENTRY MGLMesaRealizePalette(MGLDC *dc,int numColors,int startIndex,int waitVRT);
+
+#ifdef __cplusplus
+} /* End of "C" linkage for C++ */
+#endif /* __cplusplus */
+
+#endif /* __MGLMESA_H */
diff --git a/nx-X11/extras/Mesa/include/GL/miniglx.h b/nx-X11/extras/Mesa/include/GL/miniglx.h
new file mode 100644
index 000000000..8c6180be6
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/miniglx.h
@@ -0,0 +1,482 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file miniglx.h
+ * \brief Mini GLX interface functions.
+ * \author Brian Paul
+ *
+ * See comments miniglx.c for more information.
+ */
+
+#ifndef MINIGLX_H
+#define MINIGLX_H
+
+#include <GL/gl.h>
+#include <stdlib.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * \name Replacement Xlib/GLX types
+ */
+/*@{*/
+/**
+ * \brief Boolean type.
+ *
+ * It can have the values #True or #False.
+ */
+#ifndef MINIGLX_NO_XTYPES
+typedef int Bool;
+#endif
+typedef int MINI_Bool;
+
+/**
+ * \brief Color map.
+ *
+ * Alias for private ::MiniGLXColormapRec structure.
+ */
+typedef struct MiniGLXColormapRec *MINI_Colormap;
+#ifndef MINIGLX_NO_XTYPES
+typedef struct MiniGLXColormapRec *Colormap;
+#endif
+
+/**
+ * \brief Window attributes.
+ */
+typedef struct MiniGLXSetWindowAttributesRec {
+ int background_pixel; /**< \brief background pixel */
+ int border_pixel; /**< \brief border pixel value */
+ MINI_Colormap colormap; /**< \brief color map to be associated with window */
+ int event_mask; /**< \brief set of events that should be saved */
+} XSetWindowAttributes;
+
+/**
+ * \brief Visual.
+ *
+ * Alias for the private ::MiniGLXVisualRec structure.
+ *
+ * \sa \ref datatypes.
+ */
+typedef struct MiniGLXVisualRec Visual;
+
+/**
+ * \brief Visual information.
+ *
+ * \sa \ref datatypes.
+ */
+#ifndef MINIGLX_NO_XTYPES
+typedef unsigned long VisualID;
+#endif
+typedef unsigned long MINI_VisualID;
+typedef struct MiniGLXXVisualInfoRec {
+ Visual *visual; /**< \brief pointer to the GLX Visual */
+ MINI_VisualID visualid; /**< \brief visual ID */
+ int screen; /**< \brief screen number */
+ int depth; /**< \brief bit depth */
+#if defined(__cplusplus) || defined(c_plusplus)
+ int c_class; /**< \brief class */
+#else
+ int class; /**< \brief class */
+#endif
+ int bits_per_rgb; /**< \brief total bits per pixel */
+} XVisualInfo;
+
+/**
+ * \brief GLX Frame Buffer Configuration (for pbuffers)
+ * \sa \ref datatypes.
+ */
+typedef struct MiniGLXFBConfigRec {
+ XVisualInfo *visInfo;
+} GLXFBConfig;
+
+
+/**
+ * \brief Display handle.
+ *
+ * Alias for the private ::MiniGLXDisplayRec structure.
+ *
+ * \sa \ref datatypes.
+ */
+#ifndef MINIGLX_NO_XTYPES
+typedef struct MiniGLXDisplayRec Display;
+#endif
+typedef struct MiniGLXDisplayRec MINI_Display;
+
+/**
+ * \brief Window handle.
+ *
+ * Alias for the private ::MiniGLXWindowRec structure.
+ *
+ * \sa \ref datatypes.
+ */
+#ifndef MINIGLX_NO_XTYPES
+typedef struct MiniGLXWindowRec *Window;
+#endif
+typedef struct MiniGLXWindowRec *MINI_Window;
+
+/**
+ * \brief Drawable.
+ *
+ * Alias for the private ::MiniGLXWindowRec structure.
+ *
+ * For Mini GLX only the full-screen window can be used as source and
+ * destination in graphics operations.
+ *
+ * \sa \ref datatypes.
+ */
+#ifndef MINIGLX_NO_XTYPES
+typedef struct MiniGLXWindowRec *Drawable;
+#endif
+typedef struct MiniGLXWindowRec *MINI_Drawable;
+
+/**
+ * \brief GLX drawable.
+ *
+ * Alias for the private ::MiniGLXWindowRec structure.
+ *
+ * Same as #Drawable.
+ *
+ * \sa \ref datatypes.
+ */
+typedef struct MiniGLXWindowRec *GLXDrawable;
+
+/**
+ * \brief GLX pbuffer.
+ *
+ * Alias for the private ::MiniGLXWindowRec structure.
+ *
+ * Same as #Drawable.
+ *
+ * \sa \ref datatypes.
+ */
+typedef struct MiniGLXWindowRec *GLXPbuffer;
+
+/**
+ * \brief GLX context.
+ *
+ * Alias for the private ::MiniGLXContext structure.
+ *
+ * \sa \ref datatypes.
+ */
+typedef struct MiniGLXContextRec *GLXContext;
+/*@}*/
+
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ MINI_Bool send_event; /* true if this came from a SendEvent request */
+ MINI_Display *display; /* Display the event was read from */
+ MINI_Window window;
+ int x, y;
+ int width, height;
+ int count; /* if non-zero, at least this many more */
+} XExposeEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ MINI_Bool send_event; /* true if this came from a SendEvent request */
+ MINI_Display *display; /* Display the event was read from */
+ MINI_Window parent; /* parent of the window */
+ MINI_Window window; /* window id of window created */
+ int x, y; /* window location */
+ int width, height; /* size of window */
+ int border_width; /* border width */
+ MINI_Bool override_redirect; /* creation should be overridden */
+} XCreateWindowEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ MINI_Bool send_event; /* true if this came from a SendEvent request */
+ MINI_Display *display; /* Display the event was read from */
+ MINI_Window event;
+ MINI_Window window;
+} XDestroyWindowEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ MINI_Bool send_event; /* true if this came from a SendEvent request */
+ MINI_Display *display; /* Display the event was read from */
+ MINI_Window event;
+ MINI_Window window;
+ MINI_Bool from_configure;
+} XUnmapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ MINI_Bool send_event; /* true if this came from a SendEvent request */
+ MINI_Display *display; /* Display the event was read from */
+ MINI_Window event;
+ MINI_Window window;
+ MINI_Bool override_redirect; /* boolean, is override set... */
+} XMapEvent;
+
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ MINI_Bool send_event; /* true if this came from a SendEvent request */
+ MINI_Display *display; /* Display the event was read from */
+ MINI_Window parent;
+ MINI_Window window;
+} XMapRequestEvent;
+
+typedef union _XEvent {
+ int type; /* must not be changed; first element */
+ XExposeEvent xexpose;
+ XCreateWindowEvent xcreatewindow;
+ XDestroyWindowEvent xdestroywindow;
+ XUnmapEvent xunmap;
+ XMapEvent xmap;
+ XMapRequestEvent xmaprequest;
+ long pad[24];
+} XEvent;
+
+
+/**
+ * \name Xlib constants
+ */
+/*@{*/
+#define False 0
+#define True 1
+#define None 0
+#define AllocNone 0
+#define InputOutput 1
+#define ExposureMask (1L<<15)
+#define StructureNotifyMask (1L<<17)
+#define CWBackPixel (1L<<1)
+#define CWBorderPixel (1L<<3)
+#define CWEventMask (1L<<11)
+#define CWColormap (1L<<13)
+#define PseudoColor 3
+#define TrueColor 4
+#define VisualIDMask 0x1
+#define VisualScreenMask 0x2
+#define Expose 12
+#define CreateNotify 16
+#define DestroyNotify 17
+#define UnmapNotify 18
+#define MapNotify 19
+#define MapRequest 20
+
+/*@}*/
+
+/**
+ * \name Standard GLX tokens
+ */
+/*@{*/
+#define GLX_USE_GL 1
+#define GLX_BUFFER_SIZE 2
+#define GLX_LEVEL 3
+#define GLX_RGBA 4
+#define GLX_DOUBLEBUFFER 5
+#define GLX_STEREO 6
+#define GLX_AUX_BUFFERS 7
+#define GLX_RED_SIZE 8
+#define GLX_GREEN_SIZE 9
+#define GLX_BLUE_SIZE 10
+#define GLX_ALPHA_SIZE 11
+#define GLX_DEPTH_SIZE 12
+#define GLX_STENCIL_SIZE 13
+#define GLX_ACCUM_RED_SIZE 14
+#define GLX_ACCUM_GREEN_SIZE 15
+#define GLX_ACCUM_BLUE_SIZE 16
+#define GLX_ACCUM_ALPHA_SIZE 17
+#define GLX_BAD_ATTRIBUTE 1
+#define GLX_BAD_VISUAL 4
+/*@}*/
+
+
+/**
+ * \name Unique to Mini GLX
+ *
+ * At compile time, the Mini GLX interface version can be tested with the
+ * MINI_GLX_VERSION_1_x preprocessor tokens.
+ *
+ * \sa glXQueryVersion()
+ */
+/*@{*/
+/** \brief Defined if version 1.0 of Mini GLX is supported. */
+#define MINI_GLX_VERSION_1_0 1
+/** \brief Defined if version 1.1 of Mini GLX is supported. */
+#define MINI_GLX_VERSION_1_1 1
+/*@}*/
+
+
+/**
+ * \name Server-specific functions
+ */
+extern MINI_Display *
+__miniglx_StartServer( const char *display_name );
+
+extern int
+__miniglx_Select( MINI_Display *dpy, int maxfd,
+ fd_set *rfds, fd_set *wfds, fd_set *xfds,
+ struct timeval *tv );
+
+
+/**
+ * \name Simulated Xlib functions
+ */
+/*@{*/
+extern MINI_Display *
+XOpenDisplay( const char *dpy_name );
+
+
+extern void
+XCloseDisplay( MINI_Display *display );
+
+extern MINI_Window
+XCreateWindow( MINI_Display *display, MINI_Window parent, int x, int y,
+ unsigned int width, unsigned int height,
+ unsigned int border_width, int depth, unsigned int winclass,
+ Visual *visual, unsigned long valuemask,
+ XSetWindowAttributes *attributes );
+
+extern int
+XNextEvent(MINI_Display *display, XEvent *event_return);
+
+extern MINI_Bool
+XCheckMaskEvent( MINI_Display *dpy, long event_mask, XEvent *event_return );
+
+/**
+ * \brief Return the root window.
+ *
+ * \param display the display handle. It is ignored by Mini GLX, but should be
+ * the value returned by XOpenDisplay().
+ * \param screen the screen number on the host server. It is ignored by Mini
+ * GLX but should be zero.
+ *
+ * \return the root window. Always zero on Mini GLX.
+ */
+#define RootWindow(display, screen) 0
+#define DefaultScreen(dpy) 0
+
+extern void
+XDestroyWindow( MINI_Display *display, MINI_Window w );
+
+extern void
+XMapWindow( MINI_Display *display, MINI_Window w );
+
+/* Should clients have access to this?
+ */
+extern void
+XUnmapWindow( MINI_Display *display, MINI_Window w );
+
+extern MINI_Colormap
+XCreateColormap( MINI_Display *display, MINI_Window w, Visual *visual, int alloc );
+
+extern void
+XFreeColormap( MINI_Display *display, MINI_Colormap cmap );
+
+extern void
+XFree( void *data );
+
+extern XVisualInfo *
+XGetVisualInfo( MINI_Display *display, long vinfo_mask,
+ XVisualInfo *vinfo_template, int *nitems_return );
+/*@}*/
+
+
+
+/**
+ * \name GLX functions
+ */
+/*@{*/
+extern XVisualInfo*
+glXChooseVisual( MINI_Display *dpy, int screen, int *attribList );
+
+extern int
+glXGetConfig( MINI_Display *dpy, XVisualInfo *vis, int attrib, int *value );
+
+extern GLXContext
+glXCreateContext( MINI_Display *dpy, XVisualInfo *vis,
+ GLXContext shareList, MINI_Bool direct );
+
+extern void
+glXDestroyContext( MINI_Display *dpy, GLXContext ctx );
+
+extern MINI_Bool
+glXMakeCurrent( MINI_Display *dpy, GLXDrawable drawable, GLXContext ctx);
+
+extern void
+glXSwapBuffers( MINI_Display *dpy, GLXDrawable drawable );
+
+extern GLXContext
+glXGetCurrentContext( void );
+
+extern GLXDrawable
+glXGetCurrentDrawable( void );
+
+extern void
+(*glXGetProcAddress(const GLubyte *procname))( void );
+
+extern MINI_Bool
+glXQueryVersion( MINI_Display *dpy, int *major, int *minor );
+
+/* Added in MiniGLX 1.1 */
+extern GLXPbuffer
+glXCreatePbuffer( MINI_Display *dpy, GLXFBConfig config, const int *attribList );
+
+extern void
+glXDestroyPbuffer( MINI_Display *dpy, GLXPbuffer pbuf );
+
+extern GLXFBConfig *
+glXChooseFBConfig( MINI_Display *dpy, int screen, const int *attribList,
+ int *nitems );
+
+extern XVisualInfo *
+glXGetVisualFromFBConfig( MINI_Display *dpy, GLXFBConfig config );
+
+extern void *glXAllocateMemoryMESA(Display *dpy, int scrn,
+ size_t size, float readFreq,
+ float writeFreq, float priority);
+
+extern void glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer);
+
+extern GLuint glXGetMemoryOffsetMESA( Display *dpy, int scrn,
+ const void *pointer );
+/*@}*/
+
+extern void
+__glXScrEnableExtension( void *, const char * name );
+
+/*@}*/
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* MINIGLX_H */
diff --git a/nx-X11/extras/Mesa/include/GL/osmesa.h b/nx-X11/extras/Mesa/include/GL/osmesa.h
new file mode 100644
index 000000000..ef645905c
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/osmesa.h
@@ -0,0 +1,280 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2003 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 6
+#define OSMESA_MINOR_VERSION 3
+#define OSMESA_PATCH_VERSION 0
+
+
+
+/*
+ * 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
+#define OSMESA_RGB_565 0x5
+
+
+/*
+ * 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
+#define OSMESA_MAX_WIDTH 0x24 /* new in 4.0 */
+#define OSMESA_MAX_HEIGHT 0x25 /* new in 4.0 */
+
+
+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 );
+
+
+
+/*
+ * Create an Off-Screen Mesa rendering context and specify desired
+ * size of depth buffer, stencil buffer and accumulation buffer.
+ * If you specify zero for depthBits, stencilBits, accumBits you
+ * can save some memory.
+ *
+ * New in Mesa 3.5
+ */
+GLAPI OSMesaContext GLAPIENTRY
+OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
+ GLint accumBits, 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 );
+
+
+
+/**
+ * This typedef is new in Mesa 6.3.
+ */
+typedef void (*OSMESAproc)();
+
+
+/*
+ * Return pointer to the named function.
+ * New in Mesa 4.1
+ * Return OSMESAproc in 6.3.
+ */
+GLAPI OSMESAproc GLAPIENTRY
+OSMesaGetProcAddress( const char *funcName );
+
+
+#if defined(__BEOS__) || defined(__QUICKDRAW__)
+#pragma export off
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/svgamesa.h b/nx-X11/extras/Mesa/include/GL/svgamesa.h
new file mode 100644
index 000000000..67c0e4c5c
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/svgamesa.h
@@ -0,0 +1,97 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.0
+ * Copyright (C) 1995-2001 Brian Paul
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+/*
+ * SVGA/Mesa interface for Linux.
+ */
+
+
+/*
+ * Intro to using the VGA/Mesa interface
+ *
+ * 1. #include the <vga.h> file
+ * 2. Call vga_init() to initialize the SVGA library.
+ * 3. Call vga_setmode() to specify the screen size and color depth.
+ * 4. Call SVGAMesaCreateContext() to setup a Mesa context. If using 8-bit
+ * color Mesa assumes color index mode, if using 16-bit or deeper color
+ * Mesa assumes RGB mode.
+ * 5. Call SVGAMesaMakeCurrent() to activate the Mesa context.
+ * 6. You can now use the Mesa API functions.
+ * 7. Before exiting, call SVGAMesaDestroyContext() then vga_setmode(TEXT)
+ * to restore the original text screen.
+ *
+ * Notes
+ * 1. You must run your executable as root (or use the set UID-bit) because
+ * the SVGA library requires it.
+ * 2. The SVGA driver is not fully implemented yet. See svgamesa.c for what
+ * has to be done yet.
+ */
+
+
+#ifndef SVGAMESA_H
+#define SVGAMESA_H
+
+
+#define SVGAMESA_MAJOR_VERSION 4
+#define SVGAMESA_MINOR_VERSION 0
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include "GL/gl.h"
+
+
+
+/*
+ * This is the SVGAMesa context 'handle':
+ */
+typedef struct svgamesa_context *SVGAMesaContext;
+
+
+
+/*
+ * doubleBuffer flag new in version 2.4
+ */
+extern int SVGAMesaInit( int GraphMode );
+
+extern int SVGAMesaClose( void );
+
+extern SVGAMesaContext SVGAMesaCreateContext( GLboolean doubleBuffer );
+
+extern void SVGAMesaDestroyContext( SVGAMesaContext ctx );
+
+extern void SVGAMesaMakeCurrent( SVGAMesaContext ctx );
+
+extern void SVGAMesaSwapBuffers( void );
+
+extern void SVGAMesaSetCI(int ndx, GLubyte red, GLubyte green, GLubyte blue);
+
+extern SVGAMesaContext SVGAMesaGetCurrentContext( void );
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/uglglutshapes.h b/nx-X11/extras/Mesa/include/GL/uglglutshapes.h
new file mode 100644
index 000000000..28192de2d
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/uglglutshapes.h
@@ -0,0 +1,45 @@
+/* uglglutshapes.h - Public header GLUT Shapes */
+
+/* Copyright (c) Mark J. Kilgard, 1994, 1995, 1996, 1998. */
+
+/* This program is freely distributable without licensing fees and is
+ provided without guarantee or warrantee expressed or implied. This
+ program is -not- in the public domain. */
+
+#ifndef GLUTSHAPES_H
+#define GLUTSHAPES_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <GL/gl.h>
+
+void glutWireSphere (GLdouble radius, GLint slices, GLint stacks);
+void glutSolidSphere (GLdouble radius, GLint slices, GLint stacks);
+void glutWireCone (GLdouble base, GLdouble height,
+ GLint slices, GLint stacks);
+void glutSolidCone (GLdouble base, GLdouble height,
+ GLint slices, GLint stacks);
+void glutWireCube (GLdouble size);
+void glutSolidCube (GLdouble size);
+void glutWireTorus (GLdouble innerRadius, GLdouble outerRadius,
+ GLint sides, GLint rings);
+void glutSolidTorus (GLdouble innerRadius, GLdouble outerRadius,
+ GLint sides, GLint rings);
+void glutWireDodecahedron (void);
+void glutSolidDodecahedron (void);
+void glutWireOctahedron (void);
+void glutSolidOctahedron (void);
+void glutWireTetrahedron (void);
+void glutSolidTetrahedron (void);
+void glutWireIcosahedron (void);
+void glutSolidIcosahedron (void);
+void glutWireTeapot (GLdouble size);
+void glutSolidTeapot (GLdouble size);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/uglmesa.h b/nx-X11/extras/Mesa/include/GL/uglmesa.h
new file mode 100644
index 000000000..7ef584350
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/uglmesa.h
@@ -0,0 +1,155 @@
+/* uglmesa.h - Public header UGL/Mesa */
+
+/* Copyright (C) 2001 by Wind River Systems, Inc */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.0
+ *
+ * The MIT License
+ * 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
+ * THE AUTHORS OR COPYRIGHT 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:
+ * Stephane Raimbault <stephane.raimbault@windriver.com>
+ */
+
+#ifndef UGLMESA_H
+#define UGLMESA_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define UGL_MESA_MAJOR_VERSION 4
+#define UGL_MESA_MINOR_VERSION 0
+
+#include <GL/gl.h>
+#include <ugl/ugl.h>
+
+/*
+ * Values for display mode of uglMesaCreateContext ()
+ */
+
+/*
+ * With these mask values, it's possible to test double buffer mode
+ * with UGL_MESA_DOUBLE mask
+ *
+ * SINGLE 0000 0001
+ * DOUBLE 0000 0110
+ * - SOFT 0000 0010
+ * - HARD 0000 0100
+ * WINDML 0001 0000
+ *
+ *
+ */
+#define UGL_MESA_SINGLE 0x01
+#define UGL_MESA_DOUBLE 0x06
+#define UGL_MESA_DOUBLE_SOFTWARE 0x02
+#define UGL_MESA_DOUBLE_HARDWARE 0x04
+
+#define UGL_MESA_WINDML_EXCLUSIVE 0x10
+
+#define UGL_MESA_FULLSCREEN_WIDTH 0x0
+#define UGL_MESA_FULLSCREEN_HEIGHT 0x0
+
+/*
+ * uglMesaPixelStore() parameters:
+ */
+
+#define UGL_MESA_ROW_LENGTH 0x20
+#define UGL_MESA_Y_UP 0x21
+
+/*
+ * Accepted by uglMesaGetIntegerv:
+ */
+
+#define UGL_MESA_LEFT_X 0x01
+#define UGL_MESA_TOP_Y 0x02
+#define UGL_MESA_WIDTH 0x03
+#define UGL_MESA_HEIGHT 0x04
+#define UGL_MESA_DISPLAY_WIDTH 0x05
+#define UGL_MESA_DISPLAY_HEIGHT 0x06
+#define UGL_MESA_COLOR_FORMAT 0x07
+#define UGL_MESA_COLOR_MODEL 0x08
+#define UGL_MESA_PIXEL_FORMAT 0x09
+#define UGL_MESA_TYPE 0x0A
+#define UGL_MESA_RGB 0x0B
+#define UGL_MESA_COLOR_INDEXED 0x0C
+#define UGL_MESA_SINGLE_BUFFER 0x0D
+#define UGL_MESA_DOUBLE_BUFFER 0x0E
+#define UGL_MESA_DOUBLE_BUFFER_SOFTWARE 0x0F
+#define UGL_MESA_DOUBLE_BUFFER_HARDWARE 0x10
+
+/*
+ * typedefs
+ */
+
+typedef struct uglMesaContext * UGL_MESA_CONTEXT;
+
+UGL_MESA_CONTEXT uglMesaCreateNewContext (GLenum mode,
+ UGL_MESA_CONTEXT share_list);
+
+UGL_MESA_CONTEXT uglMesaCreateNewContextExt (GLenum mode,
+ GLint depth_bits,
+ GLint stencil_bits,
+ GLint accum_red_bits,
+ GLint accum_green_bits,
+ GLint accum_blue_bits,
+ GLint accum_alpha_bits,
+ UGL_MESA_CONTEXT share_list);
+
+GLboolean uglMesaMakeCurrentContext (UGL_MESA_CONTEXT umc,
+ GLsizei left, GLsizei top,
+ GLsizei width, GLsizei height);
+
+GLboolean uglMesaMoveWindow (GLsizei dx, GLsizei dy);
+
+GLboolean uglMesaMoveToWindow (GLsizei left, GLsizei top);
+
+GLboolean uglMesaResizeWindow (GLsizei dw, GLsizei dh);
+
+GLboolean uglMesaResizeToWindow (GLsizei width, GLsizei height);
+
+void uglMesaDestroyContext (void);
+
+UGL_MESA_CONTEXT uglMesaGetCurrentContext (void);
+
+void uglMesaSwapBuffers (void);
+
+void uglMesaPixelStore (GLint pname, GLint value);
+
+void uglMesaGetIntegerv (GLint pname, GLint *value);
+
+GLboolean uglMesaGetDepthBuffer (GLint *width, GLint *height,
+ GLint *bytesPerValue, void **buffer);
+
+GLboolean uglMesaGetColorBuffer (GLint *width, GLint *height,
+ GLint *format, void **buffer);
+
+GLboolean uglMesaSetColor (GLubyte index, GLfloat red,
+ GLfloat green, GLfloat blue);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/vms_x_fix.h b/nx-X11/extras/Mesa/include/GL/vms_x_fix.h
new file mode 100644
index 000000000..db754f655
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/vms_x_fix.h
@@ -0,0 +1,880 @@
+/***************************************************************************
+ * *
+ * Repair definitions of Xlib when compileing with /name=(as_is) on VMS *
+ * *
+ * Author : Jouk Jansen (joukj@hrem.stm.tudelft.nl) *
+ * *
+ * Last revision : 22 August 2000 *
+ * *
+ ***************************************************************************/
+
+#ifndef VMS_X_FIX
+#define VMS_X_FIX
+
+#define _XRegisterFilterByType _XREGISTERFILTERBYTYPE
+#define XAllocClassHint XALLOCCLASSHINT
+#define XAllocColor XALLOCCOLOR
+#define XAllocColorCells XALLOCCOLORCELLS
+#define XAllocSizeHints XALLOCSIZEHINTS
+#define XAllocWMHints XALLOCWMHINTS
+#define XAutoRepeatOff XAUTOREPEATOFF
+#define XAutoRepeatOn XAUTOREPEATON
+#define XBaseFontNameListOfFontSet XBASEFONTNAMELISTOFFONTSET
+#define XBell XBELL
+#define XBitmapPad XBITMAPPAD
+#define XChangeActivePointerGrab XCHANGEACTIVEPOINTERGRAB
+#define XChangeGC XCHANGEGC
+#define XChangeProperty XCHANGEPROPERTY
+#define XChangeWindowAttributes XCHANGEWINDOWATTRIBUTES
+#define XCheckIfEvent XCHECKIFEVENT
+#define XCheckMaskEvent XCHECKMASKEVENT
+#define XCheckTypedWindowEvent XCHECKTYPEDWINDOWEVENT
+#define XCheckWindowEvent XCHECKWINDOWEVENT
+#define XClearArea XCLEARAREA
+#define XClearWindow XCLEARWINDOW
+#define XClipBox XCLIPBOX
+#define XCloseDisplay XCLOSEDISPLAY
+#define XCloseIM XCLOSEIM
+#define XConfigureWindow XCONFIGUREWINDOW
+#define XConvertSelection XCONVERTSELECTION
+#define XCopyArea XCOPYAREA
+#define XCopyGC XCOPYGC
+#define XCopyPlane XCOPYPLANE
+#define XCreateBitmapFromData XCREATEBITMAPFROMDATA
+#define XCreateColormap XCREATECOLORMAP
+#define XCreateFontCursor XCREATEFONTCURSOR
+#define XCreateFontSet XCREATEFONTSET
+#define XCreateGC XCREATEGC
+#define XCreateIC XCREATEIC
+#define XCreateImage XCREATEIMAGE
+#define XCreatePixmap XCREATEPIXMAP
+#define XCreatePixmapCursor XCREATEPIXMAPCURSOR
+#define XCreatePixmapFromBitmapData XCREATEPIXMAPFROMBITMAPDATA
+#define XCreateRegion XCREATEREGION
+#define XCreateSimpleWindow XCREATESIMPLEWINDOW
+#define XCreateWindow XCREATEWINDOW
+#define XDefaultScreenOfDisplay XDEFAULTSCREENOFDISPLAY
+#define XDefineCursor XDEFINECURSOR
+#define XDeleteProperty XDELETEPROPERTY
+#define XDestroyIC XDESTROYIC
+#define XDestroyRegion XDESTROYREGION
+#define XDestroyWindow XDESTROYWINDOW
+#define XDisplayName XDISPLAYNAME
+#define XDisplayOfScreen XDISPLAYOFSCREEN
+#define XDrawArc XDRAWARC
+#define XDrawImageString XDRAWIMAGESTRING
+#define XDrawImageString16 XDRAWIMAGESTRING16
+#define XDrawLine XDRAWLINE
+#define XDrawLines XDRAWLINES
+#define XDrawPoint XDRAWPOINT
+#define XDrawPoints XDRAWPOINTS
+#define XDrawRectangle XDRAWRECTANGLE
+#define XDrawSegments XDRAWSEGMENTS
+#define XDrawString XDRAWSTRING
+#define XDrawString16 XDRAWSTRING16
+#define XEmptyRegion XEMPTYREGION
+#define XEqualRegion XEQUALREGION
+#define XEventsQueued XEVENTSQUEUED
+#define XExtentsOfFontSet XEXTENTSOFFONTSET
+#define XFillArc XFILLARC
+#define XFillPolygon XFILLPOLYGON
+#define XFillRectangle XFILLRECTANGLE
+#define XFillRectangles XFILLRECTANGLES
+#define XFilterEvent XFILTEREVENT
+#define XFlush XFLUSH
+#define XFontsOfFontSet XFONTSOFFONTSET
+#define XFree XFREE
+#define XFreeColormap XFREECOLORMAP
+#define XFreeColors XFREECOLORS
+#define XFreeCursor XFREECURSOR
+#define XFreeFont XFREEFONT
+#define XFreeFontInfo XFREEFONTINFO
+#define XFreeFontNames XFREEFONTNAMES
+#define XFreeFontSet XFREEFONTSET
+#define XFreeGC XFREEGC
+#define XFreeModifiermap XFREEMODIFIERMAP
+#define XFreePixmap XFREEPIXMAP
+#define XFreeStringList XFREESTRINGLIST
+#define XGetAtomName XGETATOMNAME
+#define XGetDefault XGETDEFAULT
+#define XGetErrorDatabaseText XGETERRORDATABASETEXT
+#define XGetErrorText XGETERRORTEXT
+#define XGetFontProperty XGETFONTPROPERTY
+#define XGetGCValues XGETGCVALUES
+#define XGetGeometry XGETGEOMETRY
+#define XGetICValues XGETICVALUES
+#define XGetIMValues XGETIMVALUES
+#define XGetImage XGETIMAGE
+#define XGetKeyboardControl XGETKEYBOARDCONTROL
+#define XGetModifierMapping XGETMODIFIERMAPPING
+#define XGetMotionEvents XGETMOTIONEVENTS
+#define XGetNormalHints XGETNORMALHINTS
+#define XGetSelectionOwner XGETSELECTIONOWNER
+#define XGetSubImage XGETSUBIMAGE
+#define XGetVisualInfo XGETVISUALINFO
+#define XGetWMColormapWindows XGETWMCOLORMAPWINDOWS
+#define XGetWMHints XGETWMHINTS
+#define XGetWMName XGETWMNAME
+#define XGetWMNormalHints XGETWMNORMALHINTS
+#define XGetWindowAttributes XGETWINDOWATTRIBUTES
+#define XGetWindowProperty XGETWINDOWPROPERTY
+#define XGrabKeyboard XGRABKEYBOARD
+#define XGrabPointer XGRABPOINTER
+#define XGrabServer XGRABSERVER
+#define XHeightOfScreen XHEIGHTOFSCREEN
+#define XIfEvent XIFEVENT
+#define XInternAtom XINTERNATOM
+#define XIntersectRegion XINTERSECTREGION
+#define XKeycodeToKeysym XKEYCODETOKEYSYM
+#define XKeysymToKeycode XKEYSYMTOKEYCODE
+#define XKeysymToString XKEYSYMTOSTRING
+#define XListFonts XLISTFONTS
+#define XListFontsWithInfo XLISTFONTSWITHINFO
+#define XListPixmapFormats XLISTPIXMAPFORMATS
+#define XListProperties XLISTPROPERTIES
+#define XLoadQueryFont XLOADQUERYFONT
+#define XLookupString XLOOKUPSTRING
+#define XLowerWindow XLOWERWINDOW
+#define XMapRaised XMAPRAISED
+#define XMapWindow XMAPWINDOW
+#define XMatchVisualInfo XMATCHVISUALINFO
+#define XMoveResizeWindow XMOVERESIZEWINDOW
+#define XMoveWindow XMOVEWINDOW
+#define XNextEvent XNEXTEVENT
+#define XOffsetRegion XOFFSETREGION
+#define XOpenDisplay XOPENDISPLAY
+#define XOpenIM XOPENIM
+#define XParseColor XPARSECOLOR
+#define XParseGeometry XPARSEGEOMETRY
+#define XPeekEvent XPEEKEVENT
+#define XPending XPENDING
+#define XPointInRegion XPOINTINREGION
+#define XPolygonRegion XPOLYGONREGION
+#define XPutBackEvent XPUTBACKEVENT
+#define XPutImage XPUTIMAGE
+#define XQueryColor XQUERYCOLOR
+#define XQueryColors XQUERYCOLORS
+#define XQueryExtension XQUERYEXTENSION
+#define XQueryPointer XQUERYPOINTER
+#define XQueryTree XQUERYTREE
+#define XRaiseWindow XRAISEWINDOW
+#define XReconfigureWMWindow XRECONFIGUREWMWINDOW
+#define XRectInRegion XRECTINREGION
+#define XRefreshKeyboardMapping XREFRESHKEYBOARDMAPPING
+#define XReparentWindow XREPARENTWINDOW
+#define XResizeWindow XRESIZEWINDOW
+#define XRestackWindows XRESTACKWINDOWS
+#define XRootWindowOfScreen XROOTWINDOWOFSCREEN
+#define XScreenNumberOfScreen XSCREENNUMBEROFSCREEN
+#define XSelectAsyncEvent XSELECTASYNCEVENT
+#define XSelectAsyncInput XSELECTASYNCINPUT
+#define XSelectInput XSELECTINPUT
+#define XSendEvent XSENDEVENT
+#define XServerVendor XSERVERVENDOR
+#define XSetBackground XSETBACKGROUND
+#define XSetClassHint XSETCLASSHINT
+#define XSetClipMask XSETCLIPMASK
+#define XSetClipOrigin XSETCLIPORIGIN
+#define XSetClipRectangles XSETCLIPRECTANGLES
+#define XSetCloseDownMode XSETCLOSEDOWNMODE
+#define XSetCommand XSETCOMMAND
+#define XSetDashes XSETDASHES
+#define XSetErrorHandler XSETERRORHANDLER
+#define XSetFillStyle XSETFILLSTYLE
+#define XSetFont XSETFONT
+#define XSetForeground XSETFOREGROUND
+#define XSetFunction XSETFUNCTION
+#define XSetGraphicsExposures XSETGRAPHICSEXPOSURES
+#define XSetICFocus XSETICFOCUS
+#define XSetICValues XSETICVALUES
+#define XSetIOErrorHandler XSETIOERRORHANDLER
+#define XSetInputFocus XSETINPUTFOCUS
+#define XSetLineAttributes XSETLINEATTRIBUTES
+#define XSetLocaleModifiers XSETLOCALEMODIFIERS
+#define XSetNormalHints XSETNORMALHINTS
+#define XSetRegion XSETREGION
+#define XSetSelectionOwner XSETSELECTIONOWNER
+#define XSetStipple XSETSTIPPLE
+#define XSetSubwindowMode XSETSUBWINDOWMODE
+#define XSetTSOrigin XSETTSORIGIN
+#define XSetTile XSETTILE
+#define XSetTransientForHint XSETTRANSIENTFORHINT
+#define XSetWMColormapWindows XSETWMCOLORMAPWINDOWS
+#define XSetWMHints XSETWMHINTS
+#define XSetWMIconName XSETWMICONNAME
+#define XSetWMName XSETWMNAME
+#define XSetWMNormalHints XSETWMNORMALHINTS
+#define XSetWMProperties XSETWMPROPERTIES
+#define XSetWMProtocols XSETWMPROTOCOLS
+#define XSetWindowBackground XSETWINDOWBACKGROUND
+#define XSetWindowBackgroundPixmap XSETWINDOWBACKGROUNDPIXMAP
+#define XSetWindowColormap XSETWINDOWCOLORMAP
+#define XShapeCombineMask XSHAPECOMBINEMASK
+#define XShapeCombineRectangles XSHAPECOMBINERECTANGLES
+#define XShapeGetRectangles XSHAPEGETRECTANGLES
+#define XShrinkRegion XSHRINKREGION
+#define XStoreColor XSTORECOLOR
+#define XStoreColors XSTORECOLORS
+#define XStoreName XSTORENAME
+#define XStringToKeysym XSTRINGTOKEYSYM
+#define XSubtractRegion XSUBTRACTREGION
+#define XSupportsLocale XSUPPORTSLOCALE
+#define XSync XSYNC
+#define XSynchronize XSYNCHRONIZE
+#define XTextExtents XTEXTEXTENTS
+#define XTextExtents16 XTEXTEXTENTS16
+#define XTextWidth XTEXTWIDTH
+#define XTextWidth16 XTEXTWIDTH16
+#define XTranslateCoordinates XTRANSLATECOORDINATES
+#define XUndefineCursor XUNDEFINECURSOR
+#define XUngrabKeyboard XUNGRABKEYBOARD
+#define XUngrabPointer XUNGRABPOINTER
+#define XUngrabServer XUNGRABSERVER
+#define XUnionRectWithRegion XUNIONRECTWITHREGION
+#define XUnionRegion XUNIONREGION
+#define XUnmapWindow XUNMAPWINDOW
+#define _XUnregisterFilter _XUNREGISTERFILTER
+#define XUnsetICFocus XUNSETICFOCUS
+#define XVaCreateNestedList XVACREATENESTEDLIST
+#define XVisualIDFromVisual XVISUALIDFROMVISUAL
+#define XWidthOfScreen XWIDTHOFSCREEN
+#define XWindowEvent XWINDOWEVENT
+#define XWithdrawWindow XWITHDRAWWINDOW
+#define XXorRegion XXORREGION
+#define XmAddProtocolCallback XMADDPROTOCOLCALLBACK
+#define XmAddProtocols XMADDPROTOCOLS
+#define XmChangeColor XMCHANGECOLOR
+#define XmClipboardCopy XMCLIPBOARDCOPY
+#define XmClipboardEndCopy XMCLIPBOARDENDCOPY
+#define XmClipboardInquireLength XMCLIPBOARDINQUIRELENGTH
+#define XmClipboardLock XMCLIPBOARDLOCK
+#define XmClipboardRetrieve XMCLIPBOARDRETRIEVE
+#define XmClipboardStartCopy XMCLIPBOARDSTARTCOPY
+#define XmClipboardUnlock XMCLIPBOARDUNLOCK
+#define XmCreateArrowButton XMCREATEARROWBUTTON
+#define XmCreateArrowButtonGadget XMCREATEARROWBUTTONGADGET
+#define XmCreateCascadeButton XMCREATECASCADEBUTTON
+#define XmCreateDialogShell XMCREATEDIALOGSHELL
+#define XmCreateDragIcon XMCREATEDRAGICON
+#define XmCreateDrawingArea XMCREATEDRAWINGAREA
+#define XmCreateDrawnButton XMCREATEDRAWNBUTTON
+#define XmCreateFileSelectionBox XMCREATEFILESELECTIONBOX
+#define XmCreateFileSelectionDialog XMCREATEFILESELECTIONDIALOG
+#define XmCreateForm XMCREATEFORM
+#define XmCreateFormDialog XMCREATEFORMDIALOG
+#define XmCreateFrame XMCREATEFRAME
+#define XmCreateInformationDialog XMCREATEINFORMATIONDIALOG
+#define XmCreateLabelGadget XMCREATELABELGADGET
+#define XmCreateMainWindow XMCREATEMAINWINDOW
+#define XmCreateMenuBar XMCREATEMENUBAR
+#define XmCreateMessageBox XMCREATEMESSAGEBOX
+#define XmCreateMessageDialog XMCREATEMESSAGEDIALOG
+#define XmCreateOptionMenu XMCREATEOPTIONMENU
+#define XmCreatePanedWindow XMCREATEPANEDWINDOW
+#define XmCreatePopupMenu XMCREATEPOPUPMENU
+#define XmCreatePromptDialog XMCREATEPROMPTDIALOG
+#define XmCreatePulldownMenu XMCREATEPULLDOWNMENU
+#define XmCreatePushButton XMCREATEPUSHBUTTON
+#define XmCreatePushButtonGadget XMCREATEPUSHBUTTONGADGET
+#define XmCreateQuestionDialog XMCREATEQUESTIONDIALOG
+#define XmCreateRadioBox XMCREATERADIOBOX
+#define XmCreateRowColumn XMCREATEROWCOLUMN
+#define XmCreateScale XMCREATESCALE
+#define XmCreateScrollBar XMCREATESCROLLBAR
+#define XmCreateScrolledList XMCREATESCROLLEDLIST
+#define XmCreateScrolledText XMCREATESCROLLEDTEXT
+#define XmCreateScrolledWindow XMCREATESCROLLEDWINDOW
+#define XmCreateSelectionDialog XMCREATESELECTIONDIALOG
+#define XmCreateSeparator XMCREATESEPARATOR
+#define XmCreateSeparatorGadget XMCREATESEPARATORGADGET
+#define XmCreateTemplateDialog XMCREATETEMPLATEDIALOG
+#define XmCreateText XMCREATETEXT
+#define XmCreateTextField XMCREATETEXTFIELD
+#define XmCreateToggleButton XMCREATETOGGLEBUTTON
+#define XmCreateToggleButtonGadget XMCREATETOGGLEBUTTONGADGET
+#define XmDragStart XMDRAGSTART
+#define XmDropSiteRegister XMDROPSITEREGISTER
+#define XmDropSiteUnregister XMDROPSITEUNREGISTER
+#define XmDropSiteUpdate XMDROPSITEUPDATE
+#define XmDropTransferStart XMDROPTRANSFERSTART
+#define XmFileSelectionBoxGetChild XMFILESELECTIONBOXGETCHILD
+#define XmFileSelectionDoSearch XMFILESELECTIONDOSEARCH
+#define XmFontListAppendEntry XMFONTLISTAPPENDENTRY
+#define XmFontListCopy XMFONTLISTCOPY
+#define XmFontListCreate XMFONTLISTCREATE
+#define XmFontListEntryCreate XMFONTLISTENTRYCREATE
+#define XmFontListEntryFree XMFONTLISTENTRYFREE
+#define XmFontListEntryGetFont XMFONTLISTENTRYGETFONT
+#define XmFontListEntryGetTag XMFONTLISTENTRYGETTAG
+#define XmFontListEntryLoad XMFONTLISTENTRYLOAD
+#define XmFontListFree XMFONTLISTFREE
+#define XmFontListFreeFontContext XMFONTLISTFREEFONTCONTEXT
+#define XmFontListGetNextFont XMFONTLISTGETNEXTFONT
+#define XmFontListInitFontContext XMFONTLISTINITFONTCONTEXT
+#define XmFontListNextEntry XMFONTLISTNEXTENTRY
+#define XmGetColors XMGETCOLORS
+#define XmGetFocusWidget XMGETFOCUSWIDGET
+#define XmGetMenuCursor XMGETMENUCURSOR
+#define XmGetPixmapByDepth XMGETPIXMAPBYDEPTH
+#define XmGetTearOffControl XMGETTEAROFFCONTROL
+#define XmGetXmDisplay XMGETXMDISPLAY
+#define XmImMbLookupString XMIMMBLOOKUPSTRING
+#define XmImRegister XMIMREGISTER
+#define XmImSetFocusValues XMIMSETFOCUSVALUES
+#define XmImSetValues XMIMSETVALUES
+#define XmImUnregister XMIMUNREGISTER
+#define XmImUnsetFocus XMIMUNSETFOCUS
+#define XmInternAtom XMINTERNATOM
+#define XmIsMotifWMRunning XMISMOTIFWMRUNNING
+#define XmListAddItem XMLISTADDITEM
+#define XmListAddItemUnselected XMLISTADDITEMUNSELECTED
+#define XmListAddItemsUnselected XMLISTADDITEMSUNSELECTED
+#define XmListDeleteAllItems XMLISTDELETEALLITEMS
+#define XmListDeleteItemsPos XMLISTDELETEITEMSPOS
+#define XmListDeletePos XMLISTDELETEPOS
+#define XmListDeselectAllItems XMLISTDESELECTALLITEMS
+#define XmListDeselectPos XMLISTDESELECTPOS
+#define XmListGetKbdItemPos XMLISTGETKBDITEMPOS
+#define XmListGetMatchPos XMLISTGETMATCHPOS
+#define XmListGetSelectedPos XMLISTGETSELECTEDPOS
+#define XmListPosSelected XMLISTPOSSELECTED
+#define XmListSelectItem XMLISTSELECTITEM
+#define XmListSelectPos XMLISTSELECTPOS
+#define XmListSetBottomPos XMLISTSETBOTTOMPOS
+#define XmListSetItem XMLISTSETITEM
+#define XmListSetKbdItemPos XMLISTSETKBDITEMPOS
+#define XmListSetPos XMLISTSETPOS
+#define XmMainWindowSetAreas XMMAINWINDOWSETAREAS
+#define XmMenuPosition XMMENUPOSITION
+#define XmMessageBoxGetChild XMMESSAGEBOXGETCHILD
+#define XmOptionButtonGadget XMOPTIONBUTTONGADGET
+#define XmOptionLabelGadget XMOPTIONLABELGADGET
+#define XmProcessTraversal XMPROCESSTRAVERSAL
+#define XmQmotif XMQMOTIF
+#define XmRemoveProtocolCallback XMREMOVEPROTOCOLCALLBACK
+#define XmRepTypeGetId XMREPTYPEGETID
+#define XmRepTypeGetRecord XMREPTYPEGETRECORD
+#define XmRepTypeRegister XMREPTYPEREGISTER
+#define XmRepTypeValidValue XMREPTYPEVALIDVALUE
+#define XmScrollBarSetValues XMSCROLLBARSETVALUES
+#define XmScrolledWindowSetAreas XMSCROLLEDWINDOWSETAREAS
+#define XmSelectionBoxGetChild XMSELECTIONBOXGETCHILD
+#define XmStringByteCompare XMSTRINGBYTECOMPARE
+#define XmStringCompare XMSTRINGCOMPARE
+#define XmStringConcat XMSTRINGCONCAT
+#define XmStringCopy XMSTRINGCOPY
+#define XmStringCreate XMSTRINGCREATE
+#define XmStringCreateLocalized XMSTRINGCREATELOCALIZED
+#define XmStringCreateLtoR XMSTRINGCREATELTOR
+#define XmStringCreateSimple XMSTRINGCREATESIMPLE
+#define XmStringDraw XMSTRINGDRAW
+#define XmStringDrawUnderline XMSTRINGDRAWUNDERLINE
+#define XmStringExtent XMSTRINGEXTENT
+#define XmStringFree XMSTRINGFREE
+#define XmStringFreeContext XMSTRINGFREECONTEXT
+#define XmStringGetLtoR XMSTRINGGETLTOR
+#define XmStringGetNextComponent XMSTRINGGETNEXTCOMPONENT
+#define XmStringGetNextSegment XMSTRINGGETNEXTSEGMENT
+#define XmStringInitContext XMSTRINGINITCONTEXT
+#define XmStringLength XMSTRINGLENGTH
+#define XmStringLtoRCreate XMSTRINGLTORCREATE
+#define XmStringNConcat XMSTRINGNCONCAT
+#define XmStringSegmentCreate XMSTRINGSEGMENTCREATE
+#define XmStringWidth XMSTRINGWIDTH
+#define XmTextClearSelection XMTEXTCLEARSELECTION
+#define XmTextFieldGetEditable XMTEXTFIELDGETEDITABLE
+#define XmTextFieldGetInsertionPosition XMTEXTFIELDGETINSERTIONPOSITION
+#define XmTextFieldGetLastPosition XMTEXTFIELDGETLASTPOSITION
+#define XmTextFieldGetSelection XMTEXTFIELDGETSELECTION
+#define XmTextFieldGetString XMTEXTFIELDGETSTRING
+#define XmTextFieldInsert XMTEXTFIELDINSERT
+#define XmTextFieldRemove XMTEXTFIELDREMOVE
+#define XmTextFieldSetSelection XMTEXTFIELDSETSELECTION
+#define XmTextFieldSetString XMTEXTFIELDSETSTRING
+#define XmTextGetCursorPosition XMTEXTGETCURSORPOSITION
+#define XmTextGetInsertionPosition XMTEXTGETINSERTIONPOSITION
+#define XmTextGetLastPosition XMTEXTGETLASTPOSITION
+#define XmTextGetMaxLength XMTEXTGETMAXLENGTH
+#define XmTextGetSelection XMTEXTGETSELECTION
+#define XmTextGetSelectionPosition XMTEXTGETSELECTIONPOSITION
+#define XmTextGetString XMTEXTGETSTRING
+#define XmTextInsert XMTEXTINSERT
+#define XmTextRemove XMTEXTREMOVE
+#define XmTextReplace XMTEXTREPLACE
+#define XmTextSetCursorPosition XMTEXTSETCURSORPOSITION
+#define XmTextSetHighlight XMTEXTSETHIGHLIGHT
+#define XmTextSetInsertionPosition XMTEXTSETINSERTIONPOSITION
+#define XmTextSetSelection XMTEXTSETSELECTION
+#define XmTextSetString XMTEXTSETSTRING
+#define XmToggleButtonGadgetGetState XMTOGGLEBUTTONGADGETGETSTATE
+#define XmToggleButtonGadgetSetState XMTOGGLEBUTTONGADGETSETSTATE
+#define XmToggleButtonGetState XMTOGGLEBUTTONGETSTATE
+#define XmToggleButtonSetState XMTOGGLEBUTTONSETSTATE
+#define XmUpdateDisplay XMUPDATEDISPLAY
+#define XmVaCreateSimpleRadioBox XMVACREATESIMPLERADIOBOX
+#define XmbDrawString XMBDRAWSTRING
+#define XmbLookupString XMBLOOKUPSTRING
+#define XmbResetIC XMBRESETIC
+#define XmbSetWMProperties XMBSETWMPROPERTIES
+#define XmbTextEscapement XMBTEXTESCAPEMENT
+#define XmbTextExtents XMBTEXTEXTENTS
+#define XmbTextListToTextProperty XMBTEXTLISTTOTEXTPROPERTY
+#define XmbTextPropertyToTextList XMBTEXTPROPERTYTOTEXTLIST
+#define XmuClientWindow XMUCLIENTWINDOW
+#define XmuPrintDefaultErrorMessage XMUPRINTDEFAULTERRORMESSAGE
+#define XrmGetDatabase XRMGETDATABASE
+#define XrmGetResource XRMGETRESOURCE
+#define XrmPutStringResource XRMPUTSTRINGRESOURCE
+#define XrmQuarkToString XRMQUARKTOSTRING
+#define XrmStringToQuark XRMSTRINGTOQUARK
+#define XtAddCallback XTADDCALLBACK
+#define XtAddCallbacks XTADDCALLBACKS
+#define XtAddEventHandler XTADDEVENTHANDLER
+#define XtAddGrab XTADDGRAB
+#define XtAllocateGC XTALLOCATEGC
+#define XtAppAddActions XTAPPADDACTIONS
+#define XtAppAddInput XTAPPADDINPUT
+#define XtAppAddTimeOut XTAPPADDTIMEOUT
+#define XtAppCreateShell XTAPPCREATESHELL
+#define XtAppInitialize XTAPPINITIALIZE
+#define XtAppNextEvent XTAPPNEXTEVENT
+#define XtAppPeekEvent XTAPPPEEKEVENT
+#define XtAppPending XTAPPPENDING
+#define XtAppProcessEvent XTAPPPROCESSEVENT
+#define XtAppSetErrorHandler XTAPPSETERRORHANDLER
+#define XtAppSetFallbackResources XTAPPSETFALLBACKRESOURCES
+#define XtAppSetWarningHandler XTAPPSETWARNINGHANDLER
+#define XtAppSetWarningMsgHandler XTAPPSETWARNINGMSGHANDLER
+#define XtAppWarning XTAPPWARNING
+#define XtCallActionProc XTCALLACTIONPROC
+#define XtCallCallbackList XTCALLCALLBACKLIST
+#define XtCallCallbacks XTCALLCALLBACKS
+#define XtConfigureWidget XTCONFIGUREWIDGET
+#define XtConvertAndStore XTCONVERTANDSTORE
+#define XtCreateApplicationContext XTCREATEAPPLICATIONCONTEXT
+#define XtCreateManagedWidget XTCREATEMANAGEDWIDGET
+#define XtCreatePopupShell XTCREATEPOPUPSHELL
+#define XtCreateWidget XTCREATEWIDGET
+#define XtDatabase XTDATABASE
+#define XtDestroyWidget XTDESTROYWIDGET
+#define XtDisownSelection XTDISOWNSELECTION
+#define XtDispatchEvent XTDISPATCHEVENT
+#define XtDisplayOfObject XTDISPLAYOFOBJECT
+#define XtDisplayStringConvWarning XTDISPLAYSTRINGCONVWARNING
+#define XtDisplayToApplicationContext XTDISPLAYTOAPPLICATIONCONTEXT
+#define XtAppAddWorkProc XTAPPADDWORKPROC
+#define XtRemoveWorkProc XTREMOVEWORKPROC
+#define XtFree XTFREE
+#define XtGetActionKeysym XTGETACTIONKEYSYM
+#define XtGetActionList XTGETACTIONLIST
+#define XtGetApplicationNameAndClass XTGETAPPLICATIONNAMEANDCLASS
+#define XtGetApplicationResources XTGETAPPLICATIONRESOURCES
+#define XtGetGC XTGETGC
+#define XtGetMultiClickTime XTGETMULTICLICKTIME
+#define XtGetSelectionValue XTGETSELECTIONVALUE
+#define XtGetSelectionValues XTGETSELECTIONVALUES
+#define XtGetSubresources XTGETSUBRESOURCES
+#define XtGetValues XTGETVALUES
+#define XtGrabKeyboard XTGRABKEYBOARD
+#define XtGrabPointer XTGRABPOINTER
+#define XtHasCallbacks XTHASCALLBACKS
+#define XtInitializeWidgetClass XTINITIALIZEWIDGETCLASS
+#define XtInsertEventHandler XTINSERTEVENTHANDLER
+#define XtIsManaged XTISMANAGED
+#define XtIsObject XTISOBJECT
+#define XtIsSensitive XTISSENSITIVE
+#define XtIsSubclass XTISSUBCLASS
+#define XtLastTimestampProcessed XTLASTTIMESTAMPPROCESSED
+#define XtMakeGeometryRequest XTMAKEGEOMETRYREQUEST
+#define XtMakeResizeRequest XTMAKERESIZEREQUEST
+#define XtMalloc XTMALLOC
+#define XtManageChild XTMANAGECHILD
+#define XtManageChildren XTMANAGECHILDREN
+#define XtMergeArgLists XTMERGEARGLISTS
+#define XtMoveWidget XTMOVEWIDGET
+#define XtName XTNAME
+#define XtNameToWidget XTNAMETOWIDGET
+#define XtOpenDisplay XTOPENDISPLAY
+#define XtOverrideTranslations XTOVERRIDETRANSLATIONS
+#define XtOwnSelection XTOWNSELECTION
+#define XtParseTranslationTable XTPARSETRANSLATIONTABLE
+#define XtPopdown XTPOPDOWN
+#define XtPopup XTPOPUP
+#define XtQueryGeometry XTQUERYGEOMETRY
+#define XtRealizeWidget XTREALIZEWIDGET
+#define XtRealloc XTREALLOC
+#define XtReleaseGC XTRELEASEGC
+#define XtRemoveAllCallbacks XTREMOVEALLCALLBACKS
+#define XtRemoveCallback XTREMOVECALLBACK
+#define XtRemoveEventHandler XTREMOVEEVENTHANDLER
+#define XtRemoveGrab XTREMOVEGRAB
+#define XtRemoveInput XTREMOVEINPUT
+#define XtRemoveTimeOut XTREMOVETIMEOUT
+#define XtResizeWidget XTRESIZEWIDGET
+#define XtResolvePathname XTRESOLVEPATHNAME
+#define XtSetKeyboardFocus XTSETKEYBOARDFOCUS
+#define XtSetMappedWhenManaged XTSETMAPPEDWHENMANAGED
+#define XtSetSensitive XTSETSENSITIVE
+#define XtSetTypeConverter XTSETTYPECONVERTER
+#define XtSetValues XTSETVALUES
+#define XtShellStrings XTSHELLSTRINGS
+#define XtStrings XTSTRINGS
+#define XtToolkitInitialize XTTOOLKITINITIALIZE
+#define XtTranslateCoords XTTRANSLATECOORDS
+#define XtTranslateKeycode XTTRANSLATEKEYCODE
+#define XtUngrabKeyboard XTUNGRABKEYBOARD
+#define XtUngrabPointer XTUNGRABPOINTER
+#define XtUnmanageChild XTUNMANAGECHILD
+#define XtUnmanageChildren XTUNMANAGECHILDREN
+#define XtUnrealizeWidget XTUNREALIZEWIDGET
+#define XtVaCreateManagedWidget XTVACREATEMANAGEDWIDGET
+#define XtVaCreateWidget XTVACREATEWIDGET
+#define XtVaGetValues XTVAGETVALUES
+#define XtVaSetValues XTVASETVALUES
+#define XtWarning XTWARNING
+#define XtWidgetToApplicationContext XTWIDGETTOAPPLICATIONCONTEXT
+#define XtWindowOfObject XTWINDOWOFOBJECT
+#define XtWindowToWidget XTWINDOWTOWIDGET
+#define XwcDrawString XWCDRAWSTRING
+#define XwcFreeStringList XWCFREESTRINGLIST
+#define XwcTextEscapement XWCTEXTESCAPEMENT
+#define XwcTextExtents XWCTEXTEXTENTS
+#define XwcTextListToTextProperty XWCTEXTLISTTOTEXTPROPERTY
+#define XwcTextPropertyToTextList XWCTEXTPROPERTYTOTEXTLIST
+#define _XmBottomShadowColorDefault _XMBOTTOMSHADOWCOLORDEFAULT
+#define _XmClearBorder _XMCLEARBORDER
+#define _XmConfigureObject _XMCONFIGUREOBJECT
+#define _XmDestroyParentCallback _XMDESTROYPARENTCALLBACK
+#define _XmDrawArrow _XMDRAWARROW
+#define _XmDrawShadows _XMDRAWSHADOWS
+#define _XmFontListGetDefaultFont _XMFONTLISTGETDEFAULTFONT
+#define _XmFromHorizontalPixels _XMFROMHORIZONTALPIXELS
+#define _XmFromVerticalPixels _XMFROMVERTICALPIXELS
+#define _XmGetClassExtensionPtr _XMGETCLASSEXTENSIONPTR
+#define _XmGetDefaultFontList _XMGETDEFAULTFONTLIST
+#define _XmGetTextualDragIcon _XMGETTEXTUALDRAGICON
+#define _XmGetWidgetExtData _XMGETWIDGETEXTDATA
+#define _XmGrabKeyboard _XMGRABKEYBOARD
+#define _XmGrabPointer _XMGRABPOINTER
+#define _XmInheritClass _XMINHERITCLASS
+#define _XmInputInGadget _XMINPUTINGADGET
+#define _XmMakeGeometryRequest _XMMAKEGEOMETRYREQUEST
+#define _XmMenuPopDown _XMMENUPOPDOWN
+#define _XmMoveObject _XMMOVEOBJECT
+#define _XmNavigChangeManaged _XMNAVIGCHANGEMANAGED
+#define _XmOSBuildFileList _XMOSBUILDFILELIST
+#define _XmOSFileCompare _XMOSFILECOMPARE
+#define _XmOSFindPatternPart _XMOSFINDPATTERNPART
+#define _XmOSQualifyFileSpec _XMOSQUALIFYFILESPEC
+#define _XmPostPopupMenu _XMPOSTPOPUPMENU
+#define _XmPrimitiveEnter _XMPRIMITIVEENTER
+#define _XmPrimitiveLeave _XMPRIMITIVELEAVE
+#define _XmRedisplayGadgets _XMREDISPLAYGADGETS
+#define _XmShellIsExclusive _XMSHELLISEXCLUSIVE
+#define _XmStringDraw _XMSTRINGDRAW
+#define _XmStringGetTextConcat _XMSTRINGGETTEXTCONCAT
+#define _XmStrings _XMSTRINGS
+#define _XmToHorizontalPixels _XMTOHORIZONTALPIXELS
+#define _XmToVerticalPixels _XMTOVERTICALPIXELS
+#define _XmTopShadowColorDefault _XMTOPSHADOWCOLORDEFAULT
+#define _Xm_fastPtr _XM_FASTPTR
+#define _XtCheckSubclassFlag _XTCHECKSUBCLASSFLAG
+#define _XtInherit _XTINHERIT
+#define _XtInheritTranslations _XTINHERITTRANSLATIONS
+#define applicationShellWidgetClass APPLICATIONSHELLWIDGETCLASS
+#define compositeWidgetClass COMPOSITEWIDGETCLASS
+#define overrideShellWidgetClass OVERRIDESHELLWIDGETCLASS
+#define shellWidgetClass SHELLWIDGETCLASS
+#define topLevelShellClassRec TOPLEVELSHELLCLASSREC
+#define topLevelShellWidgetClass TOPLEVELSHELLWIDGETCLASS
+#define transientShellWidgetClass TRANSIENTSHELLWIDGETCLASS
+#define vendorShellClassRec VENDORSHELLCLASSREC
+#define vendorShellWidgetClass VENDORSHELLWIDGETCLASS
+#define wmShellWidgetClass WMSHELLWIDGETCLASS
+#define xmArrowButtonWidgetClass XMARROWBUTTONWIDGETCLASS
+#define xmCascadeButtonClassRec XMCASCADEBUTTONCLASSREC
+#define xmCascadeButtonGadgetClass XMCASCADEBUTTONGADGETCLASS
+#define xmCascadeButtonWidgetClass XMCASCADEBUTTONWIDGETCLASS
+#define xmDialogShellWidgetClass XMDIALOGSHELLWIDGETCLASS
+#define xmDrawingAreaWidgetClass XMDRAWINGAREAWIDGETCLASS
+#define xmDrawnButtonWidgetClass XMDRAWNBUTTONWIDGETCLASS
+#define xmFileSelectionBoxWidgetClass XMFILESELECTIONBOXWIDGETCLASS
+#define xmFormWidgetClass XMFORMWIDGETCLASS
+#define xmFrameWidgetClass XMFRAMEWIDGETCLASS
+#define xmGadgetClass XMGADGETCLASS
+#define xmLabelGadgetClass XMLABELGADGETCLASS
+#define xmLabelWidgetClass XMLABELWIDGETCLASS
+#define xmListWidgetClass XMLISTWIDGETCLASS
+#define xmMainWindowWidgetClass XMMAINWINDOWWIDGETCLASS
+#define xmManagerClassRec XMMANAGERCLASSREC
+#define xmManagerWidgetClass XMMANAGERWIDGETCLASS
+#define xmMenuShellWidgetClass XMMENUSHELLWIDGETCLASS
+#define xmMessageBoxWidgetClass XMMESSAGEBOXWIDGETCLASS
+#define xmPrimitiveClassRec XMPRIMITIVECLASSREC
+#define xmPrimitiveWidgetClass XMPRIMITIVEWIDGETCLASS
+#define xmPushButtonClassRec XMPUSHBUTTONCLASSREC
+#define xmPushButtonGadgetClass XMPUSHBUTTONGADGETCLASS
+#define xmPushButtonWidgetClass XMPUSHBUTTONWIDGETCLASS
+#define xmRowColumnWidgetClass XMROWCOLUMNWIDGETCLASS
+#define xmSashWidgetClass XMSASHWIDGETCLASS
+#define xmScrollBarWidgetClass XMSCROLLBARWIDGETCLASS
+#define xmScrolledWindowClassRec XMSCROLLEDWINDOWCLASSREC
+#define xmScrolledWindowWidgetClass XMSCROLLEDWINDOWWIDGETCLASS
+#define xmSeparatorGadgetClass XMSEPARATORGADGETCLASS
+#define xmSeparatorWidgetClass XMSEPARATORWIDGETCLASS
+#define xmTextFieldWidgetClass XMTEXTFIELDWIDGETCLASS
+#define xmTextWidgetClass XMTEXTWIDGETCLASS
+#define xmToggleButtonGadgetClass XMTOGGLEBUTTONGADGETCLASS
+#define xmToggleButtonWidgetClass XMTOGGLEBUTTONWIDGETCLASS
+#define XtRegisterDrawable _XTREGISTERWINDOW
+#define XtUnregisterDrawable _XTUNREGISTERWINDOW
+#define XQueryFont XQUERYFONT
+#define XSetPlaneMask XSETPLANEMASK
+#define XChangeKeyboardControl XCHANGEKEYBOARDCONTROL
+#define XDestroySubwindows XDESTROYSUBWINDOWS
+#define XFreeDeviceList XFREEDEVICELIST
+#define XFreeDeviceState XFREEDEVICESTATE
+#define XGetExtensionVersion XGETEXTENSIONVERSION
+#define XGetRGBColormaps XGETRGBCOLORMAPS
+#define XIconifyWindow XICONIFYWINDOW
+#define XInstallColormap XINSTALLCOLORMAP
+#define XListInputDevices XLISTINPUTDEVICES
+#define XLookupKeysym XLOOKUPKEYSYM
+#define XOpenDevice XOPENDEVICE
+#define XQueryDeviceState XQUERYDEVICESTATE
+#define XSelectExtensionEvent XSELECTEXTENSIONEVENT
+#define XWarpPointer XWARPPOINTER
+#define XmuLookupStandardColormap XMULOOKUPSTANDARDCOLORMAP
+#define XAllocNamedColor XALLOCNAMEDCOLOR
+#define XBlackPixelOfScreen XBLACKPIXELOFSCREEN
+#define XDefaultColormap XDEFAULTCOLORMAP
+#define XDefaultColormapOfScreen XDEFAULTCOLORMAPOFSCREEN
+#define XDefaultDepth XDEFAULTDEPTH
+#define XDefaultScreen XDEFAULTSCREEN
+#define XDefaultVisual XDEFAULTVISUAL
+#define XSetIconName XSETICONNAME
+#define XtInitialize XTINITIALIZE
+#define XtMainLoop XTMAINLOOP
+#define DtSaverGetWindows DTSAVERGETWINDOWS
+#define XAddHosts XADDHOSTS
+#define XDisableAccessControl XDISABLEACCESSCONTROL
+#define XEnableAccessControl XENABLEACCESSCONTROL
+#define XFillArcs XFILLARCS
+#define XForceScreenSaver XFORCESCREENSAVER
+#define XGetScreenSaver XGETSCREENSAVER
+#define XListHosts XLISTHOSTS
+#define XReadBitmapFile XREADBITMAPFILE
+#define XRemoveHosts XREMOVEHOSTS
+#define XResetScreenSaver XRESETSCREENSAVER
+#define XResourceManagerString XRESOURCEMANAGERSTRING
+#define XSetScreenSaver XSETSCREENSAVER
+#define XStringListToTextProperty XSTRINGLISTTOTEXTPROPERTY
+#define XrmDestroyDatabase XRMDESTROYDATABASE
+#define XrmGetFileDatabase XRMGETFILEDATABASE
+#define XrmGetStringDatabase XRMGETSTRINGDATABASE
+#define XrmInitialize XRMINITIALIZE
+#define XrmMergeDatabases XRMMERGEDATABASES
+#define XrmParseCommand XRMPARSECOMMAND
+#define XrmPutLineResource XRMPUTLINERESOURCE
+#define XrmQPutStringResource XRMQPUTSTRINGRESOURCE
+#define XrmStringToBindingQuarkList XRMSTRINGTOBINDINGQUARKLIST
+#define XrmStringToQuark XRMSTRINGTOQUARK
+#define XmCreateLabel XMCREATELABEL
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+extern void XtFree(char*);
+#ifdef __cplusplus
+}
+#endif
+
+#define pthread_attr_create PTHREAD_ATTR_CREATE
+#define pthread_attr_delete PTHREAD_ATTR_DELETE
+#define pthread_attr_destroy PTHREAD_ATTR_DESTROY
+#define pthread_attr_getdetach_np PTHREAD_ATTR_GETDETACH_NP
+#define pthread_attr_getguardsize_np PTHREAD_ATTR_GETGUARDSIZE_NP
+#define pthread_attr_getinheritsched PTHREAD_ATTR_GETINHERITSCHED
+#define pthread_attr_getprio PTHREAD_ATTR_GETPRIO
+#define pthread_attr_getsched PTHREAD_ATTR_GETSCHED
+#define pthread_attr_getschedparam PTHREAD_ATTR_GETSCHEDPARAM
+#define pthread_attr_getstacksize PTHREAD_ATTR_GETSTACKSIZE
+#define pthread_attr_init PTHREAD_ATTR_INIT
+#define pthread_attr_setdetach_np PTHREAD_ATTR_SETDETACH_NP
+#define pthread_attr_setdetachstate PTHREAD_ATTR_SETDETACHSTATE
+#define pthread_attr_setguardsize_np PTHREAD_ATTR_SETGUARDSIZE_NP
+#define pthread_attr_setinheritsched PTHREAD_ATTR_SETINHERITSCHED
+#define pthread_attr_setprio PTHREAD_ATTR_SETPRIO
+#define pthread_attr_setsched PTHREAD_ATTR_SETSCHED
+#define pthread_attr_setschedparam PTHREAD_ATTR_SETSCHEDPARAM
+#define pthread_attr_setschedpolicy PTHREAD_ATTR_SETSCHEDPOLICY
+#define pthread_attr_setstacksize PTHREAD_ATTR_SETSTACKSIZE
+#define pthread_cancel PTHREAD_CANCEL
+#define pthread_cancel_e PTHREAD_CANCEL_E
+#define pthread_cond_broadcast PTHREAD_COND_BROADCAST
+#define pthread_cond_destroy PTHREAD_COND_DESTROY
+#define pthread_cond_init PTHREAD_COND_INIT
+#define pthread_cond_sig_preempt_int_np PTHREAD_COND_SIG_PREEMPT_INT_NP
+#define pthread_cond_signal PTHREAD_COND_SIGNAL
+#define pthread_cond_signal_int_np PTHREAD_COND_SIGNAL_INT_NP
+#define pthread_cond_timedwait PTHREAD_COND_TIMEDWAIT
+#define pthread_cond_wait PTHREAD_COND_WAIT
+#define pthread_condattr_create PTHREAD_CONDATTR_CREATE
+#define pthread_condattr_delete PTHREAD_CONDATTR_DELETE
+#define pthread_condattr_init PTHREAD_CONDATTR_INIT
+#define pthread_create PTHREAD_CREATE
+#define pthread_delay_np PTHREAD_DELAY_NP
+#define pthread_detach PTHREAD_DETACH
+#define pthread_equal PTHREAD_EQUAL
+#define pthread_exc_fetch_fp_np PTHREAD_EXC_FETCH_FP_NP
+#define pthread_exc_handler_np PTHREAD_EXC_HANDLER_NP
+#define pthread_exc_pop_ctx_np PTHREAD_EXC_POP_CTX_NP
+#define pthread_exc_push_ctx_np PTHREAD_EXC_PUSH_CTX_NP
+#define pthread_exc_savecontext_np PTHREAD_EXC_SAVECONTEXT_NP
+#define pthread_exit PTHREAD_EXIT
+#define pthread_get_expiration_np PTHREAD_GET_EXPIRATION_NP
+#define pthread_getprio PTHREAD_GETPRIO
+#define pthread_getschedparam PTHREAD_GETSCHEDPARAM
+#define pthread_getscheduler PTHREAD_GETSCHEDULER
+#define pthread_getspecific PTHREAD_GETSPECIFIC
+#define pthread_getunique_np PTHREAD_GETUNIQUE_NP
+#define pthread_join PTHREAD_JOIN
+#define pthread_join32 PTHREAD_JOIN32
+#define pthread_keycreate PTHREAD_KEYCREATE
+#define pthread_key_create PTHREAD_KEY_CREATE
+#define pthread_kill PTHREAD_KILL
+#define pthread_lock_global_np PTHREAD_LOCK_GLOBAL_NP
+#define pthread_mutex_destroy PTHREAD_MUTEX_DESTROY
+#define pthread_mutex_init PTHREAD_MUTEX_INIT
+#define pthread_mutex_lock PTHREAD_MUTEX_LOCK
+#define pthread_mutex_trylock PTHREAD_MUTEX_TRYLOCK
+#define pthread_mutex_unlock PTHREAD_MUTEX_UNLOCK
+#define pthread_mutexattr_create PTHREAD_MUTEXATTR_CREATE
+#define pthread_mutexattr_delete PTHREAD_MUTEXATTR_DELETE
+#define pthread_mutexattr_destroy PTHREAD_MUTEXATTR_DESTROY
+#define pthread_mutexattr_getkind_np PTHREAD_MUTEXATTR_GETKIND_NP
+#define pthread_mutexattr_init PTHREAD_MUTEXATTR_INIT
+#define pthread_mutexattr_setkind_np PTHREAD_MUTEXATTR_SETKIND_NP
+#define pthread_mutexattr_settype_np PTHREAD_MUTEXATTR_SETTYPE_NP
+#define pthread_once PTHREAD_ONCE
+#define pthread_resume_np PTHREAD_RESUME_NP
+#define pthread_self PTHREAD_SELF
+#define pthread_setasynccancel PTHREAD_SETASYNCCANCEL
+#define pthread_setcancel PTHREAD_SETCANCEL
+#define pthread_setcancelstate PTHREAD_SETCANCELSTATE
+#define pthread_setprio PTHREAD_SETPRIO
+#define pthread_setschedparam PTHREAD_SETSCHEDPARAM
+#define pthread_setscheduler PTHREAD_SETSCHEDULER
+#define pthread_setspecific PTHREAD_SETSPECIFIC
+#define pthread_suspend_np PTHREAD_SUSPEND_NP
+#define pthread_testcancel PTHREAD_TESTCANCEL
+#define pthread_unlock_global_np PTHREAD_UNLOCK_GLOBAL_NP
+#define pthread_yield PTHREAD_YIELD
+#define pthread_yield_np PTHREAD_YIELD_NP
+#define XDefaultRootWindow XDEFAULTROOTWINDOW
+#define XDisplayCells XDISPLAYCELLS
+#define XMaxRequestSize XMAXREQUESTSIZE
+#define XScreenOfDisplay XSCREENOFDISPLAY
+#define XSetFillRule XSETFILLRULE
+#define XmActivateProtocol XMACTIVATEPROTOCOL
+#define XmCreateBulletinBoardDialog XMCREATEBULLETINBOARDDIALOG
+#define XmCreateErrorDialog XMCREATEERRORDIALOG
+#define XmCreateWarningDialog XMCREATEWARNINGDIALOG
+#define XmCvtCTToXmString XMCVTCTTOXMSTRING
+#define XmDestroyPixmap XMDESTROYPIXMAP
+#define XmGetPixmap XMGETPIXMAP
+#define XmInstallImage XMINSTALLIMAGE
+#define XmListAddItems XMLISTADDITEMS
+#define XmListDeleteItem XMLISTDELETEITEM
+#define XmListItemExists XMLISTITEMEXISTS
+#define XmListItemPos XMLISTITEMPOS
+#define XmListReplaceItems XMLISTREPLACEITEMS
+#define XmListReplaceItemsPos XMLISTREPLACEITEMSPOS
+#define XmRemoveProtocols XMREMOVEPROTOCOLS
+#define XmRemoveTabGroup XMREMOVETABGROUP
+#define XmSetColorCalculation XMSETCOLORCALCULATION
+#define XmTextCopy XMTEXTCOPY
+#define XmTextCut XMTEXTCUT
+#define XmTextFieldClearSelection XMTEXTFIELDCLEARSELECTION
+#define XmTextFieldCopy XMTEXTFIELDCOPY
+#define XmTextFieldCut XMTEXTFIELDCUT
+#define XmTextFieldGetMaxLength XMTEXTFIELDGETMAXLENGTH
+#define XmTextFieldGetSelectionPosition XMTEXTFIELDGETSELECTIONPOSITION
+#define XmTextFieldPaste XMTEXTFIELDPASTE
+#define XmTextFieldReplace XMTEXTFIELDREPLACE
+#define XmTextFieldSetAddMode XMTEXTFIELDSETADDMODE
+#define XmTextFieldSetHighlight XMTEXTFIELDSETHIGHLIGHT
+#define XmTextFieldSetInsertionPosition XMTEXTFIELDSETINSERTIONPOSITION
+#define XmTextFieldSetMaxLength XMTEXTFIELDSETMAXLENGTH
+#define XmTextFieldShowPosition XMTEXTFIELDSHOWPOSITION
+#define XmTextGetEditable XMTEXTGETEDITABLE
+#define XmTextPaste XMTEXTPASTE
+#define XmTextPosToXY XMTEXTPOSTOXY
+#define XmTextSetEditable XMTEXTSETEDITABLE
+#define XmTextShowPosition XMTEXTSHOWPOSITION
+#define XmUninstallImage XMUNINSTALLIMAGE
+#define XmuCvtStringToBitmap XMUCVTSTRINGTOBITMAP
+#define XrmPutFileDatabase XRMPUTFILEDATABASE
+#define XtAddConverter XTADDCONVERTER
+#define XtError XTERROR
+#define XtVaCreatePopupShell XTVACREATEPOPUPSHELL
+#define pthread_attr_getschedpolicy PTHREAD_ATTR_GETSCHEDPOLICY
+#define pthread_key_delete PTHREAD_KEY_DELETE
+#define xmBulletinBoardWidgetClass XMBULLETINBOARDWIDGETCLASS
+#define xmScaleWidgetClass XMSCALEWIDGETCLASS
+#define XtDisplay XTDISPLAY
+#define XtScreen XTSCREEN
+#define XAllocIconSize XALLOCICONSIZE
+#define XAllocStandardColormap XALLOCSTANDARDCOLORMAP
+#define XAllowEvents XALLOWEVENTS
+#define XBlackPixel XBLACKPIXEL
+#define XCopyColormapAndFree XCOPYCOLORMAPANDFREE
+#define XDefaultGC XDEFAULTGC
+#define XDisplayHeight XDISPLAYHEIGHT
+#define XDisplayWidth XDISPLAYWIDTH
+#define XGetCommand XGETCOMMAND
+#define XGetIconSizes XGETICONSIZES
+#define XKillClient XKILLCLIENT
+#define XListInstalledColormaps XLISTINSTALLEDCOLORMAPS
+#define XRootWindow XROOTWINDOW
+#define XWMGeometry XWMGEOMETRY
+#define XWhitePixel XWHITEPIXEL
+#define XrmCombineDatabase XRMCOMBINEDATABASE
+#define XrmCombineFileDatabase XRMCOMBINEFILEDATABASE
+#define XSetStandardProperties XSETSTANDARDPROPERTIES
+#define XSetState XSETSTATE
+#define XDrawRectangles XDRAWRECTANGLES
+#define XGrabButton XGRABBUTTON
+#define XLookupColor XLOOKUPCOLOR
+#define XMapSubwindows XMAPSUBWINDOWS
+#define XRecolorCursor XRECOLORCURSOR
+#define XStoreBytes XSTOREBYTES
+#define XUngrabButton XUNGRABBUTTON
+#define XUninstallColormap XUNINSTALLCOLORMAP
+#define lib$wait LIB$WAIT
+#define lib$find_file LIB$FIND_FILE
+#define lib$find_file_end LIB$FIND_FILE_END
+#define lib$set_symbol LIB$SET_SYMBOL
+#define lib$sfree1_dd LIB$SFREE1_DD
+#define lib$spawn LIB$SPAWN
+#define sys$assign SYS$ASSIGN
+#define sys$crembx SYS$CREMBX
+#define sys$dassgn SYS$DASSGN
+#define sys$dclexh SYS$DCLEXH
+#define sys$getdviw SYS$GETDVIW
+#define sys$getsyiw SYS$GETSYIW
+#define sys$qio SYS$QIO
+#define sys$qiow SYS$QIOW
+#define sys$setef SYS$SETEF
+#define sys$synch SYS$SYNCH
+#define XDrawText XDRAWTEXT
+#define XtCloseDisplay XTCLOSEDISPLAY
+#define XtDestroyApplicationContext XTDESTROYAPPLICATIONCONTEXT
+#define lib$ediv LIB$EDIV
+#define lib$subx LIB$SUBX
+#define sys$bintim SYS$BINTIM
+#define sys$gettim SYS$GETTIM
+#define XFetchName XFETCHNAME
+#define XPeekIfEvent XPEEKIFEVENT
+#define XQueryKeymap XQUERYKEYMAP
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/wmesa.h b/nx-X11/extras/Mesa/include/GL/wmesa.h
new file mode 100644
index 000000000..0a6e8b642
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/wmesa.h
@@ -0,0 +1,142 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.0
+ * Copyright (C) 1995-1998 Brian Paul
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+
+/*
+ * Windows driver by: Mark E. Peterson (markp@ic.mankato.mn.us)
+ * Updated by Li Wei (liwei@aiar.xjtu.edu.cn)
+ *
+ *
+ ***************************************************************
+ * WMesa *
+ * version 2.3 *
+ * *
+ * By *
+ * Li Wei *
+ * Institute of Artificial Intelligence & Robotics *
+ * Xi'an Jiaotong University *
+ * Email: liwei@aiar.xjtu.edu.cn *
+ * Web page: http://sun.aiar.xjtu.edu.cn *
+ * *
+ * July 7th, 1997 *
+ ***************************************************************
+ */
+
+
+#ifndef WMESA_H
+#define WMESA_H
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include "GL/gl.h"
+
+#if defined(_MSV_VER) && !defined(__GNUC__)
+# pragma warning (disable:4273)
+# 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 : 4013 ) /* 'function' undefined; assuming extern returning int */
+# pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */
+# pragma warning( disable : 4273 ) /* 'identifier' : inconsistent DLL linkage. dllexport assumed */
+# if (MESA_WARNQUIET>1)
+# pragma warning( disable : 4146 ) /* unary minus operator applied to unsigned type, result still unsigned */
+# endif
+#endif
+
+/*
+ * This is the WMesa context 'handle':
+ */
+typedef struct wmesa_context *WMesaContext;
+
+
+
+/*
+ * Create a new WMesaContext for rendering into a window. You must
+ * have already created the window of correct visual type and with an
+ * appropriate colormap.
+ *
+ * Input:
+ * hWnd - Window handle
+ * Pal - Palette to use
+ * rgb_flag - GL_TRUE = RGB mode,
+ * GL_FALSE = color index mode
+ * db_flag - GL_TRUE = double-buffered,
+ * GL_FALSE = single buffered
+ * alpha_flag - GL_TRUE = create software alpha buffer,
+ * GL_FALSE = no software alpha buffer
+ *
+ * Note: Indexed mode requires double buffering under Windows.
+ *
+ * Return: a WMesa_context or NULL if error.
+ */
+extern WMesaContext WMesaCreateContext(HWND hWnd,HPALETTE* pPal,
+ GLboolean rgb_flag,
+ GLboolean db_flag,
+ GLboolean alpha_flag);
+
+
+/*
+ * Destroy a rendering context as returned by WMesaCreateContext()
+ */
+/*extern void WMesaDestroyContext( WMesaContext ctx );*/
+extern void WMesaDestroyContext( void );
+
+
+
+/*
+ * Make the specified context the current one.
+ */
+extern void WMesaMakeCurrent( WMesaContext ctx );
+
+
+/*
+ * Return a handle to the current context.
+ */
+extern WMesaContext WMesaGetCurrentContext( void );
+
+
+/*
+ * Swap the front and back buffers for the current context. No action
+ * taken if the context is not double buffered.
+ */
+extern void WMesaSwapBuffers(void);
+
+
+/*
+ * In indexed color mode we need to know when the palette changes.
+ */
+extern void WMesaPaletteChange(HPALETTE Pal);
+
+extern void WMesaMove(void);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/include/GL/xmesa.h b/nx-X11/extras/Mesa/include/GL/xmesa.h
new file mode 100644
index 000000000..ab813b23b
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/xmesa.h
@@ -0,0 +1,390 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 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/X11 interface. This header file serves as the documentation for
+ * the Mesa/X11 interface functions.
+ *
+ * Note: this interface isn't intended for user programs. It's primarily
+ * just for implementing the pseudo-GLX interface.
+ */
+
+
+/* Sample Usage:
+
+In addition to the usual X calls to select a visual, create a colormap
+and create a window, you must do the following to use the X/Mesa interface:
+
+1. Call XMesaCreateVisual() to make an XMesaVisual from an XVisualInfo.
+
+2. Call XMesaCreateContext() to create an X/Mesa rendering context, given
+ the XMesaVisual.
+
+3. Call XMesaCreateWindowBuffer() to create an XMesaBuffer from an X window
+ and XMesaVisual.
+
+4. Call XMesaMakeCurrent() to bind the XMesaBuffer to an XMesaContext and
+ to make the context the current one.
+
+5. Make gl* calls to render your graphics.
+
+6. Use XMesaSwapBuffers() when double buffering to swap front/back buffers.
+
+7. Before the X window is destroyed, call XMesaDestroyBuffer().
+
+8. Before exiting, call XMesaDestroyVisual and XMesaDestroyContext.
+
+*/
+
+
+
+
+#ifndef XMESA_H
+#define XMESA_H
+
+#ifdef __VMS
+#include <GL/vms_x_fix.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef XFree86Server
+#include "xmesa_xf86.h"
+#else
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include "xmesa_x.h"
+#endif
+#include "GL/gl.h"
+
+#ifdef AMIWIN
+#include <pragmas/xlib_pragmas.h>
+extern struct Library *XLibBase;
+#endif
+
+
+#define XMESA_MAJOR_VERSION 6
+#define XMESA_MINOR_VERSION 3
+
+
+
+/*
+ * Values passed to XMesaGetString:
+ */
+#define XMESA_VERSION 1
+#define XMESA_EXTENSIONS 2
+
+
+/*
+ * Values passed to XMesaSetFXmode:
+ */
+#define XMESA_FX_WINDOW 1
+#define XMESA_FX_FULLSCREEN 2
+
+
+
+typedef struct xmesa_context *XMesaContext;
+
+typedef struct xmesa_visual *XMesaVisual;
+
+typedef struct xmesa_buffer *XMesaBuffer;
+
+
+
+/*
+ * Create a new X/Mesa visual.
+ * 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.
+ */
+extern 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_red_size,
+ GLint accum_green_size,
+ GLint accum_blue_size,
+ GLint accum_alpha_size,
+ GLint num_samples,
+ GLint level,
+ GLint visualCaveat );
+
+/*
+ * Destroy an XMesaVisual, but not the associated XVisualInfo.
+ */
+extern void XMesaDestroyVisual( XMesaVisual v );
+
+
+
+/*
+ * Create a new XMesaContext for rendering into an X11 window.
+ *
+ * Input: visual - an XMesaVisual
+ * share_list - another XMesaContext with which to share display
+ * lists or NULL if no sharing is wanted.
+ * Return: an XMesaContext or NULL if error.
+ */
+extern XMesaContext XMesaCreateContext( XMesaVisual v,
+ XMesaContext share_list );
+
+
+/*
+ * Destroy a rendering context as returned by XMesaCreateContext()
+ */
+extern void XMesaDestroyContext( XMesaContext c );
+
+
+/*
+ * Create an XMesaBuffer from an X window.
+ */
+extern XMesaBuffer XMesaCreateWindowBuffer( XMesaVisual v, XMesaWindow w );
+
+
+/*
+ * Create an XMesaBuffer from an X pixmap.
+ */
+extern XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v,
+ XMesaPixmap p,
+ XMesaColormap cmap );
+
+
+/*
+ * Destroy an XMesaBuffer, but not the corresponding window or pixmap.
+ */
+extern void XMesaDestroyBuffer( XMesaBuffer b );
+
+
+/*
+ * Return the XMesaBuffer handle which corresponds to an X drawable, if any.
+ *
+ * New in Mesa 2.3.
+ */
+extern XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy,
+ XMesaDrawable d );
+
+
+
+/*
+ * Bind a buffer to a context and make the context the current one.
+ */
+extern GLboolean XMesaMakeCurrent( XMesaContext c,
+ XMesaBuffer b );
+
+
+/*
+ * Bind two buffers (read and draw) to a context and make the
+ * context the current one.
+ * New in Mesa 3.3
+ */
+extern GLboolean XMesaMakeCurrent2( XMesaContext c,
+ XMesaBuffer drawBuffer,
+ XMesaBuffer readBuffer );
+
+
+/*
+ * Unbind the current context from its buffer.
+ */
+extern GLboolean XMesaUnbindContext( XMesaContext c );
+
+
+/*
+ * Return a handle to the current context.
+ */
+extern XMesaContext XMesaGetCurrentContext( void );
+
+
+/*
+ * Return handle to the current (draw) buffer.
+ */
+extern XMesaBuffer XMesaGetCurrentBuffer( void );
+
+
+/*
+ * Return handle to the current read buffer.
+ * New in Mesa 3.3
+ */
+extern XMesaBuffer XMesaGetCurrentReadBuffer( void );
+
+
+/*
+ * Swap the front and back buffers for the given buffer. No action is
+ * taken if the buffer is not double buffered.
+ */
+extern void XMesaSwapBuffers( XMesaBuffer b );
+
+
+/*
+ * Copy a sub-region of the back buffer to the front buffer.
+ *
+ * New in Mesa 2.6
+ */
+extern void XMesaCopySubBuffer( XMesaBuffer b,
+ int x,
+ int y,
+ int width,
+ int height );
+
+
+/*
+ * Return a pointer to the the Pixmap or XImage being used as the back
+ * color buffer of an XMesaBuffer. This function is a way to get "under
+ * the hood" of X/Mesa so one can manipulate the back buffer directly.
+ * Input: b - the XMesaBuffer
+ * Output: pixmap - pointer to back buffer's Pixmap, or 0
+ * ximage - pointer to back buffer's XImage, or NULL
+ * Return: GL_TRUE = context is double buffered
+ * GL_FALSE = context is single buffered
+ */
+extern GLboolean XMesaGetBackBuffer( XMesaBuffer b,
+ XMesaPixmap *pixmap,
+ XMesaImage **ximage );
+
+
+
+/*
+ * Return the depth buffer associated with an XMesaBuffer.
+ * Input: b - the XMesa buffer handle
+ * 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.
+ */
+extern GLboolean XMesaGetDepthBuffer( XMesaBuffer b,
+ GLint *width,
+ GLint *height,
+ GLint *bytesPerValue,
+ void **buffer );
+
+
+
+/*
+ * Flush/sync a context
+ */
+extern void XMesaFlush( XMesaContext c );
+
+
+
+/*
+ * Get an X/Mesa-specific string.
+ * Input: name - either XMESA_VERSION or XMESA_EXTENSIONS
+ */
+extern const char *XMesaGetString( XMesaContext c, int name );
+
+
+
+/*
+ * Scan for XMesaBuffers whose window/pixmap has been destroyed, then free
+ * any memory used by that buffer.
+ *
+ * New in Mesa 2.3.
+ */
+extern void XMesaGarbageCollect( void );
+
+
+
+/*
+ * Return a dithered pixel value.
+ * Input: c - XMesaContext
+ * x, y - window coordinate
+ * red, green, blue, alpha - color components in [0,1]
+ * Return: pixel value
+ *
+ * New in Mesa 2.3.
+ */
+extern unsigned long XMesaDitherColor( XMesaContext xmesa,
+ GLint x,
+ GLint y,
+ GLfloat red,
+ GLfloat green,
+ GLfloat blue,
+ GLfloat alpha );
+
+
+
+/*
+ * 3Dfx Glide driver only!
+ * Set 3Dfx/Glide full-screen or window rendering mode.
+ * Input: mode - either XMESA_FX_WINDOW (window rendering mode) or
+ * XMESA_FX_FULLSCREEN (full-screen rendering mode)
+ * Return: GL_TRUE if success
+ * GL_FALSE if invalid mode or if not using 3Dfx driver
+ *
+ * New in Mesa 2.6.
+ */
+extern GLboolean XMesaSetFXmode( GLint mode );
+
+
+
+/*
+ * Reallocate the back/depth/stencil/accum/etc/ buffers associated with
+ * buffer <b> if its size has changed.
+ *
+ * New in Mesa 4.0.2
+ */
+extern void XMesaResizeBuffers( XMesaBuffer b );
+
+
+
+/*
+ * Create a pbuffer.
+ * New in Mesa 4.1
+ */
+extern XMesaBuffer XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap,
+ unsigned int width, unsigned int height);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/xmesa_x.h b/nx-X11/extras/Mesa/include/GL/xmesa_x.h
new file mode 100644
index 000000000..1455c88ad
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/xmesa_x.h
@@ -0,0 +1,84 @@
+
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ * When we're building the XMesa driver for stand-alone Mesa we
+ * include this file when building the xm_*.c files.
+ * We need to define some types and macros differently when building
+ * in the Xserver vs. stand-alone Mesa.
+ */
+
+#ifndef _XMESA_X_H_
+#define _XMESA_X_H_
+
+typedef Display XMesaDisplay;
+typedef Pixmap XMesaPixmap;
+typedef Colormap XMesaColormap;
+typedef Drawable XMesaDrawable;
+typedef Window XMesaWindow;
+typedef GC XMesaGC;
+typedef XVisualInfo *XMesaVisualInfo;
+typedef XImage XMesaImage;
+typedef XPoint XMesaPoint;
+typedef XColor XMesaColor;
+
+#define XMesaDestroyImage XDestroyImage
+
+#define XMesaPutPixel XPutPixel
+#define XMesaGetPixel XGetPixel
+
+#define XMesaSetForeground XSetForeground
+#define XMesaSetBackground XSetBackground
+#define XMesaSetPlaneMask XSetPlaneMask
+#define XMesaSetFunction XSetFunction
+#define XMesaSetFillStyle XSetFillStyle
+#define XMesaSetTile XSetTile
+
+#define XMesaDrawPoint XDrawPoint
+#define XMesaDrawPoints XDrawPoints
+#define XMesaFillRectangle XFillRectangle
+#define XMesaPutImage XPutImage
+#define XMesaCopyArea XCopyArea
+
+#define XMesaCreatePixmap XCreatePixmap
+#define XMesaFreePixmap XFreePixmap
+#define XMesaFreeGC XFreeGC
+
+#define GET_COLORMAP_SIZE(__v) __v->visinfo->colormap_size
+#define GET_REDMASK(__v) __v->mesa_visual.redMask
+#define GET_GREENMASK(__v) __v->mesa_visual.greenMask
+#define GET_BLUEMASK(__v) __v->mesa_visual.blueMask
+#define GET_VISUAL_DEPTH(__v) __v->visinfo->depth
+#define GET_BLACK_PIXEL(__v) BlackPixel(__v->display, __v->mesa_visual.screen)
+#define CHECK_BYTE_ORDER(__v) host_byte_order()==ImageByteOrder(__v->display)
+#define CHECK_FOR_HPCR(__v) XInternAtom(__v->display, "_HP_RGB_SMOOTH_MAP_LIST", True)
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GL/xmesa_xf86.h b/nx-X11/extras/Mesa/include/GL/xmesa_xf86.h
new file mode 100644
index 000000000..63a8e57db
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GL/xmesa_xf86.h
@@ -0,0 +1,153 @@
+
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ * When we're building the XMesa driver for use in the X server (as the
+ * indirect render) we include this file when building the xm_*.c files.
+ * We need to define some types and macros differently when building
+ * in the Xserver vs. stand-alone Mesa.
+ */
+
+#ifndef _XMESA_XF86_H_
+#define _XMESA_XF86_H_
+
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+
+typedef struct _XMesaImageRec XMesaImage;
+
+typedef ScreenRec XMesaDisplay;
+typedef PixmapPtr XMesaPixmap;
+typedef ColormapPtr XMesaColormap;
+typedef DrawablePtr XMesaDrawable;
+typedef WindowPtr XMesaWindow;
+typedef GCPtr XMesaGC;
+typedef VisualPtr XMesaVisualInfo;
+typedef DDXPointRec XMesaPoint;
+typedef xColorItem XMesaColor;
+
+#define XMesaSetGeneric(__d,__gc,__val,__mask) \
+do { \
+ CARD32 __v[1]; \
+ (void) __d; \
+ __v[0] = __val; \
+ dixChangeGC(NullClient, __gc, __mask, __v, NULL); \
+} while (0)
+
+#define XMesaSetGenericPtr(__d,__gc,__pval,__mask) \
+do { \
+ ChangeGCVal __v[1]; \
+ (void) __d; \
+ __v[0].ptr = __pval; \
+ dixChangeGC(NullClient, __gc, __mask, NULL, __v); \
+} while (0)
+
+#define XMesaSetForeground(d,gc,v) XMesaSetGeneric(d,gc,v,GCForeground)
+#define XMesaSetBackground(d,gc,v) XMesaSetGeneric(d,gc,v,GCBackground)
+#define XMesaSetPlaneMask(d,gc,v) XMesaSetGeneric(d,gc,v,GCPlaneMask)
+#define XMesaSetFunction(d,gc,v) XMesaSetGeneric(d,gc,v,GCFunction)
+#define XMesaSetFillStyle(d,gc,v) XMesaSetGeneric(d,gc,v,GCFillStyle)
+
+#define XMesaSetTile(d,gc,v) XMesaSetGenericPtr(d,gc,v,GCTile)
+
+#define XMesaDrawPoint(__d,__b,__gc,__x,__y) \
+do { \
+ XMesaPoint __p[1]; \
+ (void) __d; \
+ __p[0].x = __x; \
+ __p[0].y = __y; \
+ ValidateGC(__b, __gc); \
+ (*gc->ops->PolyPoint)(__b, __gc, CoordModeOrigin, 1, __p); \
+} while (0)
+
+#define XMesaDrawPoints(__d,__b,__gc,__p,__n,__m) \
+do { \
+ (void) __d; \
+ ValidateGC(__b, __gc); \
+ (*gc->ops->PolyPoint)(__b, __gc, __m, __n, __p); \
+} while (0)
+
+#define XMesaFillRectangle(__d,__b,__gc,__x,__y,__w,__h) \
+do { \
+ xRectangle __r[1]; \
+ (void) __d; \
+ ValidateGC((DrawablePtr)__b, __gc); \
+ __r[0].x = __x; \
+ __r[0].y = __y; \
+ __r[0].width = __w; \
+ __r[0].height = __h; \
+ (*__gc->ops->PolyFillRect)((DrawablePtr)__b, __gc, 1, __r); \
+} while (0)
+
+#define XMesaPutImage(__d,__b,__gc,__i,__sx,__sy,__x,__y,__w,__h) \
+do { \
+ /* Assumes: Images are always in ZPixmap format */ \
+ (void) __d; \
+ if (__sx || __sy) /* The non-trivial case */ \
+ XMesaPutImageHelper(__d,__b,__gc,__i,__sx,__sy,__x,__y,__w,__h); \
+ ValidateGC(__b, __gc); \
+ (*__gc->ops->PutImage)(__b, __gc, ((XMesaDrawable)(__b))->depth, \
+ __x, __y, __w, __h, 0, ZPixmap, \
+ ((XMesaImage *)(__i))->data); \
+} while (0)
+
+#define XMesaCopyArea(__d,__sb,__db,__gc,__sx,__sy,__w,__h,__x,__y) \
+do { \
+ (void) __d; \
+ ValidateGC(__db, __gc); \
+ (*__gc->ops->CopyArea)((DrawablePtr)__sb, __db, __gc, \
+ __sx, __sy, __w, __h, __x, __y); \
+} while (0)
+
+
+/* CreatePixmap returns a PixmapPtr; so, it cannot be inside braces */
+#define XMesaCreatePixmap(__d,__b,__w,__h,__depth) \
+ (*__d->CreatePixmap)(__d, __w, __h, __depth)
+
+#define XMesaFreePixmap(__d,__b) \
+ (*__d->DestroyPixmap)(__b)
+
+#define XMesaFreeGC(__d,__gc) \
+do { \
+ (void) __d; \
+ FreeScratchGC(__gc); \
+} while (0)
+
+#define GET_COLORMAP_SIZE(__v) __v->ColormapEntries
+#define GET_REDMASK(__v) __v->mesa_visual.redMask
+#define GET_GREENMASK(__v) __v->mesa_visual.greenMask
+#define GET_BLUEMASK(__v) __v->mesa_visual.blueMask
+#define GET_VISUAL_DEPTH(__v) __v->nplanes
+#define GET_BLACK_PIXEL(__v) __v->display->blackPixel
+#define CHECK_BYTE_ORDER(__v) GL_TRUE
+#define CHECK_FOR_HPCR(__v) GL_FALSE
+
+#endif
diff --git a/nx-X11/extras/Mesa/include/GLES/egl.h b/nx-X11/extras/Mesa/include/GLES/egl.h
new file mode 100644
index 000000000..d62786d03
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GLES/egl.h
@@ -0,0 +1,274 @@
+#ifndef _EGL_H
+#define _EGL_H
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.0 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2004 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+*/
+
+#if 0/*XXX TEMPORARY HACK*/
+#include <GLES/gl.h>
+#else
+#include <GL/gl.h>
+#endif
+#include <GLES/egltypes.h>
+
+/* XXX should go in eglext.h */
+#define GL_OES_VERSION_1_0 1
+#define GL_OES_read_format 1
+#define GL_OES_compressed_paletted_texture 1
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B
+#define GL_PALETTE4_RGB8_OES 0x8B90
+#define GL_PALETTE4_RGBA8_OES 0x8B91
+#define GL_PALETTE4_R5_G6_B5_OES 0x8B92
+#define GL_PALETTE4_RGBA4_OES 0x8B93
+#define GL_PALETTE4_RGB5_A1_OES 0x8B94
+#define GL_PALETTE8_RGB8_OES 0x8B95
+#define GL_PALETTE8_RGBA8_OES 0x8B96
+#define GL_PALETTE8_R5_G6_B5_OES 0x8B97
+#define GL_PALETTE8_RGBA4_OES 0x8B98
+#define GL_PALETTE8_RGB5_A1_OES 0x8B99
+/* XXX */
+
+/*
+** Versioning and extensions
+*/
+#define EGL_VERSION_1_0 1
+#if 0
+#define EGL_VERSION_1_1 1
+#endif
+
+/*
+** Boolean
+*/
+#define EGL_FALSE 0
+#define EGL_TRUE 1
+
+/*
+** Errors
+*/
+#define EGL_SUCCESS 0x3000
+#define EGL_NOT_INITIALIZED 0x3001
+#define EGL_BAD_ACCESS 0x3002
+#define EGL_BAD_ALLOC 0x3003
+#define EGL_BAD_ATTRIBUTE 0x3004
+#define EGL_BAD_CONFIG 0x3005
+#define EGL_BAD_CONTEXT 0x3006
+#define EGL_BAD_CURRENT_SURFACE 0x3007
+#define EGL_BAD_DISPLAY 0x3008
+#define EGL_BAD_MATCH 0x3009
+#define EGL_BAD_NATIVE_PIXMAP 0x300A
+#define EGL_BAD_NATIVE_WINDOW 0x300B
+#define EGL_BAD_PARAMETER 0x300C
+#define EGL_BAD_SURFACE 0x300D
+#define EGL_CONTEXT_LOST 0x300E
+/* 0x300F - 0x301F reserved for additional errors. */
+
+/*
+** Config attributes
+*/
+#define EGL_BUFFER_SIZE 0x3020
+#define EGL_ALPHA_SIZE 0x3021
+#define EGL_BLUE_SIZE 0x3022
+#define EGL_GREEN_SIZE 0x3023
+#define EGL_RED_SIZE 0x3024
+#define EGL_DEPTH_SIZE 0x3025
+#define EGL_STENCIL_SIZE 0x3026
+#define EGL_CONFIG_CAVEAT 0x3027
+#define EGL_CONFIG_ID 0x3028
+#define EGL_LEVEL 0x3029
+#define EGL_MAX_PBUFFER_HEIGHT 0x302A
+#define EGL_MAX_PBUFFER_PIXELS 0x302B
+#define EGL_MAX_PBUFFER_WIDTH 0x302C
+#define EGL_NATIVE_RENDERABLE 0x302D
+#define EGL_NATIVE_VISUAL_ID 0x302E
+#define EGL_NATIVE_VISUAL_TYPE 0x302F
+/*#define EGL_PRESERVED_RESOURCES 0x3030*/
+#define EGL_SAMPLES 0x3031
+#define EGL_SAMPLE_BUFFERS 0x3032
+#define EGL_SURFACE_TYPE 0x3033
+#define EGL_TRANSPARENT_TYPE 0x3034
+#define EGL_TRANSPARENT_BLUE_VALUE 0x3035
+#define EGL_TRANSPARENT_GREEN_VALUE 0x3036
+#define EGL_TRANSPARENT_RED_VALUE 0x3037
+#define EGL_NONE 0x3038 /* Also a config value */
+#define EGL_BIND_TO_TEXTURE_RGB 0x3039
+#define EGL_BIND_TO_TEXTURE_RGBA 0x303A
+#define EGL_MIN_SWAP_INTERVAL 0x303B
+#define EGL_MAX_SWAP_INTERVAL 0x303C
+
+/*
+** Config values
+*/
+#define EGL_DONT_CARE ((EGLint) -1)
+
+#define EGL_SLOW_CONFIG 0x3050 /* EGL_CONFIG_CAVEAT value */
+#define EGL_NON_CONFORMANT_CONFIG 0x3051 /* " */
+#define EGL_TRANSPARENT_RGB 0x3052 /* EGL_TRANSPARENT_TYPE value */
+#define EGL_NO_TEXTURE 0x305C /* EGL_TEXTURE_FORMAT/TARGET value */
+#define EGL_TEXTURE_RGB 0x305D /* EGL_TEXTURE_FORMAT value */
+#define EGL_TEXTURE_RGBA 0x305E /* " */
+#define EGL_TEXTURE_2D 0x305F /* EGL_TEXTURE_TARGET value */
+
+/*
+** Config attribute mask bits
+*/
+#define EGL_PBUFFER_BIT 0x01 /* EGL_SURFACE_TYPE mask bit */
+#define EGL_PIXMAP_BIT 0x02 /* " */
+#define EGL_WINDOW_BIT 0x04 /* " */
+
+/*
+** String names
+*/
+#define EGL_VENDOR 0x3053 /* eglQueryString target */
+#define EGL_VERSION 0x3054 /* " */
+#define EGL_EXTENSIONS 0x3055 /* " */
+
+/*
+** Surface attributes
+*/
+#define EGL_HEIGHT 0x3056
+#define EGL_WIDTH 0x3057
+#define EGL_LARGEST_PBUFFER 0x3058
+#define EGL_TEXTURE_FORMAT 0x3080 /* For pbuffers bound as textures */
+#define EGL_TEXTURE_TARGET 0x3081 /* " */
+#define EGL_MIPMAP_TEXTURE 0x3082 /* " */
+#define EGL_MIPMAP_LEVEL 0x3083 /* " */
+
+/*
+** BindTexImage / ReleaseTexImage buffer target
+*/
+#define EGL_BACK_BUFFER 0x3084
+
+/*
+** Current surfaces
+*/
+#define EGL_DRAW 0x3059
+#define EGL_READ 0x305A
+
+/*
+** Engines
+*/
+#define EGL_CORE_NATIVE_ENGINE 0x305B
+
+/* 0x305C-0x3FFFF reserved for future use */
+
+/*
+** Functions
+*/
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+GLAPI EGLint APIENTRY eglGetError (void);
+
+GLAPI EGLDisplay APIENTRY eglGetDisplay (NativeDisplayType display);
+GLAPI EGLBoolean APIENTRY eglInitialize (EGLDisplay dpy, EGLint *major, EGLint *minor);
+GLAPI EGLBoolean APIENTRY eglTerminate (EGLDisplay dpy);
+GLAPI const char * APIENTRY eglQueryString (EGLDisplay dpy, EGLint name);
+GLAPI void (* APIENTRY eglGetProcAddress (const char *procname))(void);
+
+GLAPI EGLBoolean APIENTRY eglGetConfigs (EGLDisplay dpy, EGLConfig *configs, EGLint config_size, EGLint *num_config);
+GLAPI EGLBoolean APIENTRY eglChooseConfig (EGLDisplay dpy, const EGLint *attrib_list, EGLConfig *configs, EGLint config_size, EGLint *num_config);
+GLAPI EGLBoolean APIENTRY eglGetConfigAttrib (EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint *value);
+
+GLAPI EGLSurface APIENTRY eglCreateWindowSurface (EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list);
+GLAPI EGLSurface APIENTRY eglCreatePixmapSurface (EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list);
+GLAPI EGLSurface APIENTRY eglCreatePbufferSurface (EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
+GLAPI EGLBoolean APIENTRY eglDestroySurface (EGLDisplay dpy, EGLSurface surface);
+GLAPI EGLBoolean APIENTRY eglQuerySurface (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint *value);
+
+/* EGL 1.1 render-to-texture APIs */
+GLAPI EGLBoolean APIENTRY eglSurfaceAttrib (EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
+GLAPI EGLBoolean APIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+GLAPI EGLBoolean APIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
+
+/* EGL 1.1 swap control API */
+GLAPI EGLBoolean APIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval);
+
+GLAPI EGLContext APIENTRY eglCreateContext (EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list);
+GLAPI EGLBoolean APIENTRY eglDestroyContext (EGLDisplay dpy, EGLContext ctx);
+GLAPI EGLBoolean APIENTRY eglMakeCurrent (EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
+GLAPI EGLContext APIENTRY eglGetCurrentContext (void);
+GLAPI EGLSurface APIENTRY eglGetCurrentSurface (EGLint readdraw);
+GLAPI EGLDisplay APIENTRY eglGetCurrentDisplay (void);
+GLAPI EGLBoolean APIENTRY eglQueryContext (EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint *value);
+
+GLAPI EGLBoolean APIENTRY eglWaitGL (void);
+GLAPI EGLBoolean APIENTRY eglWaitNative (EGLint engine);
+GLAPI EGLBoolean APIENTRY eglSwapBuffers (EGLDisplay dpy, EGLSurface draw);
+GLAPI EGLBoolean APIENTRY eglCopyBuffers (EGLDisplay dpy, EGLSurface surface, NativePixmapType target);
+
+
+
+/* EGL_MESA_screen extension >>> PRELIMINARY <<< */
+#ifndef EGL_MESA_screen_surface
+#define EGL_MESA_screen_surface 1
+
+#define EGL_BAD_SCREEN_MESA 0x4000
+#define EGL_BAD_MODE_MESA 0x4001
+#define EGL_SCREEN_COUNT_MESA 0x4002
+#define EGL_SCREEN_POSITION_MESA 0x4003
+#define EGL_MODE_ID_MESA 0x4004
+#define EGL_REFRESH_RATE_MESA 0x4005
+#define EGL_OPTIMAL_MODE_MESA 0x4006
+#define EGL_SCREEN_BIT_MESA 0x08
+
+GLAPI EGLBoolean APIENTRY eglChooseModeMESA(EGLDisplay dpy, EGLScreenMESA screen, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
+GLAPI EGLBoolean APIENTRY eglGetModesMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
+GLAPI EGLBoolean APIENTRY eglGetModeAttribMESA(EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint *value);
+GLAPI EGLBoolean APIENTRY eglGetScreensMESA(EGLDisplay dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens);
+GLAPI EGLSurface APIENTRY eglCreateScreenSurfaceMESA(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
+GLAPI EGLBoolean APIENTRY eglShowSurfaceMESA(EGLDisplay dpy, EGLint screen, EGLSurface surface, EGLModeMESA mode);
+GLAPI EGLBoolean APIENTRY eglScreenPositionMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y);
+GLAPI EGLBoolean APIENTRY eglQueryScreenMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLint attribute, EGLint *value);
+GLAPI EGLBoolean APIENTRY eglQueryScreenSurfaceMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLSurface *surface);
+GLAPI EGLBoolean APIENTRY eglQueryScreenModeMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode);
+GLAPI const char * APIENTRY eglQueryModeStringMESA(EGLDisplay dpy, EGLModeMESA mode);
+
+#endif /* EGL_MESA_screen_surface */
+
+
+#ifndef EGL_MESA_copy_context
+#define EGL_MESA_copy_context 1
+
+GLAPI EGLBoolean APIENTRY eglCopyContextMESA(EGLDisplay dpy, EGLContext source, EGLContext dest, EGLint mask);
+
+#endif /* EGL_MESA_copy_context */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _EGL_H */
diff --git a/nx-X11/extras/Mesa/include/GLES/egltypes.h b/nx-X11/extras/Mesa/include/GLES/egltypes.h
new file mode 100644
index 000000000..65cba8d57
--- /dev/null
+++ b/nx-X11/extras/Mesa/include/GLES/egltypes.h
@@ -0,0 +1,45 @@
+/*
+** egltypes.h for Mesa
+**
+** ONLY egl.h SHOULD INCLUDE THIS FILE!
+**
+** See comments about egltypes.h in the standard egl.h file.
+*/
+
+
+#include <sys/types.h>
+
+
+/*
+** These opaque EGL types are implemented as unsigned 32-bit integers:
+*/
+typedef u_int32_t EGLDisplay;
+typedef u_int32_t EGLConfig;
+typedef u_int32_t EGLSurface;
+typedef u_int32_t EGLContext;
+
+/* EGL_MESA_screen_surface */
+typedef u_int32_t EGLModeMESA;
+typedef u_int32_t EGLScreenMESA;
+
+
+/*
+** Other basic EGL types:
+*/
+typedef u_int8_t EGLBoolean;
+typedef int32_t EGLint;
+
+typedef void * NativeDisplayType;
+typedef int NativePixmapType;
+typedef int NativeWindowType;
+
+/*
+** EGL and native handle null values:
+*/
+#define EGL_DEFAULT_DISPLAY ((NativeDisplayType) 0)
+#define EGL_NO_CONTEXT ((EGLContext) 0)
+#define EGL_NO_DISPLAY ((EGLDisplay) 0)
+#define EGL_NO_SURFACE ((EGLSurface) 0)
+
+/* EGL_MESA_screen_surface */
+#define EGL_NO_MODE_MESA ((EGLModeMESA) 0)
diff --git a/nx-X11/extras/Mesa/mms-config. b/nx-X11/extras/Mesa/mms-config.
new file mode 100644
index 000000000..6a960084b
--- /dev/null
+++ b/nx-X11/extras/Mesa/mms-config.
@@ -0,0 +1,23 @@
+# Makefile for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+
+
+#vms
+.ifdef SHARE
+GL_SHAR = libMesaGL.exe
+GLU_SHAR = libMesaGLU.exe
+GLUT_SHAR = libglut.exe
+.endif
+GL_LIB = libMesaGL.olb
+GLU_LIB = libMesaGLU.olb
+GLUT_LIB = libglut.olb
+CC = cc
+CXX = cxx/define=(LIBRARYBUILD=1)/assume=(nostdnew,noglobal_array_new)
+CFLAGS1 =
+MAKELIB = library/create
+RANLIB = true
+.ifdef SHARE
+XLIBS = [--.vms]xlib_share/opt
+.else
+XLIBS = [--.vms]xlib/opt
+.endif
diff --git a/nx-X11/extras/Mesa/src/Makefile b/nx-X11/extras/Mesa/src/Makefile
new file mode 100644
index 000000000..ffe2dbc6a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/Makefile
@@ -0,0 +1,34 @@
+# src/Makefile
+
+TOP = ..
+
+include $(TOP)/configs/current
+
+SUBDIRS = $(SRC_DIRS)
+
+
+default: message $(LIB_DIR) subdirs
+
+
+message:
+ @echo "Making sources for" $(CONFIG_NAME)
+
+
+subdirs:
+ @for dir in $(SUBDIRS) ; do \
+ if [ -d $$dir ] ; then \
+ (cd $$dir ; $(MAKE)) || exit 1 ; \
+ fi \
+ done
+
+
+$(LIB_DIR):
+ -mkdir $(LIB_DIR)
+
+
+clean:
+ @for dir in $(SUBDIRS) ; do \
+ if [ -d $$dir ] ; then \
+ (cd $$dir ; $(MAKE) clean) ; \
+ fi \
+ done
diff --git a/nx-X11/extras/Mesa/src/descrip.mms b/nx-X11/extras/Mesa/src/descrip.mms
new file mode 100644
index 000000000..71b8ea16a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/descrip.mms
@@ -0,0 +1,43 @@
+# Makefile for Mesa for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+
+.include [-]mms-config.
+
+all :
+ set default [.mesa]
+ $(MMS)$(MMSQUALIFIERS)
+ set default [-]
+.ifdef SHARE
+ $(MMS)$(MMSQUALIFIERS) [-.lib]$(GL_SHAR)
+.endif
+ set default [.glu]
+ $(MMS)$(MMSQUALIFIERS)
+ set default [-.glut.glx]
+ $(MMS)$(MMSQUALIFIERS)
+ set default [--]
+
+[-.lib]$(GL_SHAR) : [-.lib]$(GL_LIB)
+ @ WRITE_ SYS$OUTPUT " generating libmesa.opt"
+ @ library/extract=* [-.lib]$(GL_LIB)
+ @ OPEN_/WRITE FILE libmesa.opt
+ @ WRITE_ FILE "!"
+ @ WRITE_ FILE "! libmesa.opt generated by DESCRIP.$(MMS_EXT)"
+ @ WRITE_ FILE "!"
+ @ WRITE_ FILE "IDENTIFICATION=""mesa5.1"""
+ @ WRITE_ FILE "GSMATCH=LEQUAL,5,1
+ @ WRITE_ FILE "libmesagl.obj"
+ @ write_ file "sys$share:decw$xextlibshr/share"
+ @ write_ file "sys$share:decw$xlibshr/share"
+ @ write_ file "sys$share:pthread$rtl/share"
+ @ CLOSE_ FILE
+ @ $(MMS)$(MMSQUALIFIERS)/ignore=warning mesa_vms
+ @ WRITE_ SYS$OUTPUT " linking ..."
+ @ LINK_/NODEB/SHARE=[-.lib]$(GL_SHAR)/MAP=libmesa.map/FULL libmesa.opt/opt,\
+ mesa_vms.opt/opt
+ @ delete libmesagl.obj;*
+
+mesa_vms :
+ @ WRITE_ SYS$OUTPUT " generating libmesa.map ..."
+ @ LINK_/NODEB/NOSHARE/NOEXE/MAP=libmesa.map/FULL libmesa.opt/OPT
+ @ WRITE_ SYS$OUTPUT " analyzing libmesa.map ..."
+ @ @[-.vms]analyze_map.com libmesa.map mesa_vms.opt
diff --git a/nx-X11/extras/Mesa/src/glw/GLwDrawA.c b/nx-X11/extras/Mesa/src/glw/GLwDrawA.c
new file mode 100644
index 000000000..30304a408
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glw/GLwDrawA.c
@@ -0,0 +1,684 @@
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+
+/*
+ *
+ * This file has been slightly modified from the original for use with Mesa
+ *
+ * Jeroen van der Zijp
+ *
+ * jvz@cyberia.cfdrc.com
+ *
+ */
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <GL/glx.h>
+#include <GL/gl.h>
+#ifdef __GLX_MOTIF
+#include <Xm/PrimitiveP.h>
+#include "GLwMDrawAP.h"
+#else
+#include "GLwDrawAP.h"
+#endif
+#include <assert.h>
+#include <stdio.h>
+
+#ifdef __GLX_MOTIF
+#define GLwDrawingAreaWidget GLwMDrawingAreaWidget
+#define GLwDrawingAreaClassRec GLwMDrawingAreaClassRec
+#define glwDrawingAreaClassRec glwMDrawingAreaClassRec
+#define glwDrawingAreaWidgetClass glwMDrawingAreaWidgetClass
+#define GLwDrawingAreaRec GLwMDrawingAreaRec
+#endif
+
+#define ATTRIBLIST_SIZE 32
+
+#define offset(field) XtOffset(GLwDrawingAreaWidget,glwDrawingArea.field)
+
+
+/* forward definitions */
+static void createColormap(GLwDrawingAreaWidget w,int offset,XrmValue *value);
+static void Initialize(GLwDrawingAreaWidget req,GLwDrawingAreaWidget neww,ArgList args,Cardinal *num_args);
+static void Realize(Widget w,Mask *valueMask,XSetWindowAttributes *attributes);
+static void Redraw(GLwDrawingAreaWidget w,XEvent *event,Region region);
+static void Resize(GLwDrawingAreaWidget glw);
+static void Destroy(GLwDrawingAreaWidget glw);
+static void glwInput(GLwDrawingAreaWidget glw,XEvent *event,String *params,Cardinal *numParams);
+
+
+
+static char defaultTranslations[] =
+#ifdef __GLX_MOTIF
+ "<Key>osfHelp:PrimitiveHelp() \n"
+#endif
+ "<KeyDown>: glwInput() \n\
+ <KeyUp>: glwInput() \n\
+ <BtnDown>: glwInput() \n\
+ <BtnUp>: glwInput() \n\
+ <BtnMotion>: glwInput() ";
+
+
+static XtActionsRec actions[] = {
+ {"glwInput",(XtActionProc)glwInput}, /* key or mouse input */
+ };
+
+
+/*
+ * There is a bit of unusual handling of the resources here.
+ * Because Xt insists on allocating the colormap resource when it is
+ * processing the core resources (even if we redeclare the colormap
+ * resource here, we need to do a little trick. When Xt first allocates
+ * the colormap, we allow it to allocate the default one, since we have
+ * not yet determined the appropriate visual (which is determined from
+ * resources parsed after the colormap). We also let it allocate colors
+ * in that default colormap.
+ *
+ * In the initialize proc we calculate the actual visual. Then, we
+ * reobtain the colormap resource using XtGetApplicationResources in
+ * the initialize proc. If requested, we also reallocate colors in
+ * that colormap using the same method.
+ */
+
+static XtResource resources[] = {
+ /* The GLX attributes. Add any new attributes here */
+
+ {GLwNbufferSize, GLwCBufferSize, XtRInt, sizeof (int),
+ offset(bufferSize), XtRImmediate, (XtPointer) 0},
+
+ {GLwNlevel, GLwCLevel, XtRInt, sizeof (int),
+ offset(level), XtRImmediate, (XtPointer) 0},
+
+ {GLwNrgba, GLwCRgba, XtRBoolean, sizeof (Boolean),
+ offset(rgba), XtRImmediate, (XtPointer) FALSE},
+
+ {GLwNdoublebuffer, GLwCDoublebuffer, XtRBoolean, sizeof (Boolean),
+ offset(doublebuffer), XtRImmediate, (XtPointer) FALSE},
+
+ {GLwNstereo, GLwCStereo, XtRBoolean, sizeof (Boolean),
+ offset(stereo), XtRImmediate, (XtPointer) FALSE},
+
+ {GLwNauxBuffers, GLwCAuxBuffers, XtRInt, sizeof (int),
+ offset(auxBuffers), XtRImmediate, (XtPointer) 0},
+
+ {GLwNredSize, GLwCColorSize, XtRInt, sizeof (int),
+ offset(redSize), XtRImmediate, (XtPointer) 1},
+
+ {GLwNgreenSize, GLwCColorSize, XtRInt, sizeof (int),
+ offset(greenSize), XtRImmediate, (XtPointer) 1},
+
+ {GLwNblueSize, GLwCColorSize, XtRInt, sizeof (int),
+ offset(blueSize), XtRImmediate, (XtPointer) 1},
+
+ {GLwNalphaSize, GLwCAlphaSize, XtRInt, sizeof (int),
+ offset(alphaSize), XtRImmediate, (XtPointer) 0},
+
+ {GLwNdepthSize, GLwCDepthSize, XtRInt, sizeof (int),
+ offset(depthSize), XtRImmediate, (XtPointer) 0},
+
+ {GLwNstencilSize, GLwCStencilSize, XtRInt, sizeof (int),
+ offset(stencilSize), XtRImmediate, (XtPointer) 0},
+
+ {GLwNaccumRedSize, GLwCAccumColorSize, XtRInt, sizeof (int),
+ offset(accumRedSize), XtRImmediate, (XtPointer) 0},
+
+ {GLwNaccumGreenSize, GLwCAccumColorSize, XtRInt, sizeof (int),
+ offset(accumGreenSize), XtRImmediate, (XtPointer) 0},
+
+ {GLwNaccumBlueSize, GLwCAccumColorSize, XtRInt, sizeof (int),
+ offset(accumBlueSize), XtRImmediate, (XtPointer) 0},
+
+ {GLwNaccumAlphaSize, GLwCAccumAlphaSize, XtRInt, sizeof (int),
+ offset(accumAlphaSize), XtRImmediate, (XtPointer) 0},
+
+ /* the attribute list */
+ {GLwNattribList, GLwCAttribList, XtRPointer, sizeof(int *),
+ offset(attribList), XtRImmediate, (XtPointer) NULL},
+
+ /* the visual info */
+ {GLwNvisualInfo, GLwCVisualInfo, GLwRVisualInfo, sizeof (XVisualInfo *),
+ offset(visualInfo), XtRImmediate, (XtPointer) NULL},
+
+ /* miscellaneous resources */
+ {GLwNinstallColormap, GLwCInstallColormap, XtRBoolean, sizeof (Boolean),
+ offset(installColormap), XtRImmediate, (XtPointer) TRUE},
+
+ {GLwNallocateBackground, GLwCAllocateColors, XtRBoolean, sizeof (Boolean),
+ offset(allocateBackground), XtRImmediate, (XtPointer) FALSE},
+
+ {GLwNallocateOtherColors, GLwCAllocateColors, XtRBoolean, sizeof (Boolean),
+ offset(allocateOtherColors), XtRImmediate, (XtPointer) FALSE},
+
+ {GLwNinstallBackground, GLwCInstallBackground, XtRBoolean, sizeof (Boolean),
+ offset(installBackground), XtRImmediate, (XtPointer) TRUE},
+
+ {GLwNginitCallback, GLwCCallback, XtRCallback, sizeof (XtCallbackList),
+ offset(ginitCallback), XtRImmediate, (XtPointer) NULL},
+
+ {GLwNinputCallback, GLwCCallback, XtRCallback, sizeof (XtCallbackList),
+ offset(inputCallback), XtRImmediate, (XtPointer) NULL},
+
+ {GLwNresizeCallback, GLwCCallback, XtRCallback, sizeof (XtCallbackList),
+ offset(resizeCallback), XtRImmediate, (XtPointer) NULL},
+
+ {GLwNexposeCallback, GLwCCallback, XtRCallback, sizeof (XtCallbackList),
+ offset(exposeCallback), XtRImmediate, (XtPointer) NULL},
+
+ /* Changes to Motif primitive resources */
+#ifdef __GLX_MOTIF
+ {XmNtraversalOn, XmCTraversalOn, XmRBoolean, sizeof (Boolean),
+ XtOffset (GLwDrawingAreaWidget, primitive.traversal_on), XmRImmediate,
+ (XtPointer)FALSE},
+
+ /* highlighting is normally disabled, as when Motif tries to disable
+ * highlighting, it tries to reset the color back to the parent's
+ * background (usually Motif blue). Unfortunately, that is in a
+ * different colormap, and doesn't work too well.
+ */
+ {XmNhighlightOnEnter, XmCHighlightOnEnter, XmRBoolean, sizeof (Boolean),
+ XtOffset (GLwDrawingAreaWidget, primitive.highlight_on_enter),
+ XmRImmediate, (XtPointer) FALSE},
+
+ {XmNhighlightThickness, XmCHighlightThickness, XmRHorizontalDimension,
+ sizeof (Dimension),
+ XtOffset (GLwDrawingAreaWidget, primitive.highlight_thickness),
+ XmRImmediate, (XtPointer) 0},
+#endif
+ };
+
+
+/*
+** The following resources are reobtained using XtGetApplicationResources
+** in the initialize proc.
+*/
+
+/* The colormap */
+static XtResource initializeResources[] = {
+ /* reobtain the colormap with the new visual */
+ {XtNcolormap, XtCColormap, XtRColormap, sizeof(Colormap),
+ XtOffset(GLwDrawingAreaWidget, core.colormap),
+ XtRCallProc,(XtPointer) createColormap},
+ };
+
+
+/* reallocate any colors we need in the new colormap */
+
+/* The background is obtained only if the allocateBackground resource is TRUE*/
+static XtResource backgroundResources[] = {
+#ifdef __GLX_MOTIF
+ {XmNbackground, XmCBackground,XmRPixel,
+ sizeof(Pixel),XtOffset(GLwDrawingAreaWidget,core.background_pixel),
+ XmRString,(XtPointer)"lightgrey"},
+ /*XmRCallProc,(XtPointer)_XmBackgroundColorDefault},*/
+
+ {XmNbackgroundPixmap,XmCPixmap,XmRXmBackgroundPixmap,
+ sizeof(Pixmap),XtOffset(GLwDrawingAreaWidget,core.background_pixmap),
+ XmRImmediate,(XtPointer)XmUNSPECIFIED_PIXMAP},
+
+#else
+ {XtNbackground,XtCBackground,XtRPixel,sizeof(Pixel),
+ XtOffset(GLwDrawingAreaWidget,core.background_pixel),
+ XtRString,(XtPointer)"lightgrey"},
+ /*XtRString,(XtPointer)"XtDefaultBackground"},*/
+
+ {XtNbackgroundPixmap, XtCPixmap, XtRPixmap, sizeof(Pixmap),
+ XtOffset(GLwDrawingAreaWidget,core.background_pixmap),
+ XtRImmediate,(XtPointer)XtUnspecifiedPixmap},
+#endif
+ };
+
+
+
+/* The other colors such as the foreground are allocated only if
+ * allocateOtherColors are set. These resources only exist in Motif.
+ */
+#ifdef __GLX_MOTIF
+static XtResource otherColorResources[] = {
+ {XmNforeground,XmCForeground,XmRPixel,
+ sizeof(Pixel),XtOffset(GLwDrawingAreaWidget,primitive.foreground),
+ XmRString,(XtPointer)"lighgrey"},
+ /*XmRCallProc, (XtPointer) _XmForegroundColorDefault},*/
+
+ {XmNhighlightColor,XmCHighlightColor,XmRPixel,sizeof(Pixel),
+ XtOffset(GLwDrawingAreaWidget,primitive.highlight_color),
+ XmRString,(XtPointer)"lightgrey"},
+ /*XmRCallProc,(XtPointer)_XmHighlightColorDefault},*/
+
+ {XmNhighlightPixmap,XmCHighlightPixmap,XmRPrimHighlightPixmap,
+ sizeof(Pixmap),
+ XtOffset(GLwDrawingAreaWidget,primitive.highlight_pixmap),
+ XmRImmediate,(XtPointer)XmUNSPECIFIED_PIXMAP},
+ /*XmRCallProc,(XtPointer)_XmPrimitiveHighlightPixmapDefault},*/
+ };
+#endif
+
+
+#undef offset
+
+
+GLwDrawingAreaClassRec glwDrawingAreaClassRec = {
+ { /* core fields */
+#ifdef __GLX_MOTIF
+ /* superclass */ (WidgetClass) &xmPrimitiveClassRec,
+ /* class_name */ "GLwMDrawingArea",
+#else /* not __GLX_MOTIF */
+ /* superclass */ (WidgetClass) &widgetClassRec,
+ /* class_name */ "GLwDrawingArea",
+#endif /* __GLX_MOTIF */
+ /* widget_size */ sizeof(GLwDrawingAreaRec),
+ /* class_initialize */ NULL,
+ /* class_part_initialize */ NULL,
+ /* class_inited */ FALSE,
+ /* initialize */ (XtInitProc) Initialize,
+ /* initialize_hook */ NULL,
+ /* realize */ Realize,
+ /* actions */ actions,
+ /* num_actions */ XtNumber(actions),
+ /* resources */ resources,
+ /* num_resources */ XtNumber(resources),
+ /* xrm_class */ NULLQUARK,
+ /* compress_motion */ TRUE,
+ /* compress_exposure */ TRUE,
+ /* compress_enterleave */ TRUE,
+ /* visible_interest */ TRUE,
+ /* destroy */ (XtWidgetProc) Destroy,
+ /* resize */ (XtWidgetProc) Resize,
+ /* expose */ (XtExposeProc) Redraw,
+ /* set_values */ NULL,
+ /* set_values_hook */ NULL,
+ /* set_values_almost */ XtInheritSetValuesAlmost,
+ /* get_values_hook */ NULL,
+ /* accept_focus */ NULL,
+ /* version */ XtVersion,
+ /* callback_private */ NULL,
+ /* tm_table */ defaultTranslations,
+ /* query_geometry */ XtInheritQueryGeometry,
+ /* display_accelerator */ XtInheritDisplayAccelerator,
+ /* extension */ NULL
+ },
+#ifdef __GLX_MOTIF /* primitive resources */
+ {
+ /* border_highlight */ XmInheritBorderHighlight,
+ /* border_unhighlight */ XmInheritBorderUnhighlight,
+ /* translations */ XtInheritTranslations,
+ /* arm_and_activate */ NULL,
+ /* get_resources */ NULL,
+ /* num get_resources */ 0,
+ /* extension */ NULL,
+ }
+#endif
+ };
+
+WidgetClass glwDrawingAreaWidgetClass=(WidgetClass)&glwDrawingAreaClassRec;
+
+
+
+static void error(Widget w,char* string){
+ char buf[100];
+#ifdef __GLX_MOTIF
+ sprintf(buf,"GLwMDrawingArea: %s\n",string);
+#else
+ sprintf(buf,"GLwDrawingArea: %s\n",string);
+#endif
+ XtAppError(XtWidgetToApplicationContext(w),buf);
+ }
+
+
+static void warning(Widget w,char* string){
+ char buf[100];
+#ifdef __GLX_MOTIF
+ sprintf (buf, "GLwMDraw: %s\n", string);
+#else
+ sprintf (buf, "GLwDraw: %s\n", string);
+#endif
+ XtAppWarning(XtWidgetToApplicationContext(w), buf);
+ }
+
+
+
+/* Initialize the attribList based on the attributes */
+static void createAttribList(GLwDrawingAreaWidget w){
+ int *ptr;
+ w->glwDrawingArea.attribList = (int*)XtMalloc(ATTRIBLIST_SIZE*sizeof(int));
+ if(!w->glwDrawingArea.attribList){
+ error((Widget)w,"Unable to allocate attribute list");
+ }
+ ptr = w->glwDrawingArea.attribList;
+ *ptr++ = GLX_BUFFER_SIZE;
+ *ptr++ = w->glwDrawingArea.bufferSize;
+ *ptr++ = GLX_LEVEL;
+ *ptr++ = w->glwDrawingArea.level;
+ if(w->glwDrawingArea.rgba) *ptr++ = GLX_RGBA;
+ if(w->glwDrawingArea.doublebuffer) *ptr++ = GLX_DOUBLEBUFFER;
+ if(w->glwDrawingArea.stereo) *ptr++ = GLX_STEREO;
+ *ptr++ = GLX_AUX_BUFFERS;
+ *ptr++ = w->glwDrawingArea.auxBuffers;
+ *ptr++ = GLX_RED_SIZE;
+ *ptr++ = w->glwDrawingArea.redSize;
+ *ptr++ = GLX_GREEN_SIZE;
+ *ptr++ = w->glwDrawingArea.greenSize;
+ *ptr++ = GLX_BLUE_SIZE;
+ *ptr++ = w->glwDrawingArea.blueSize;
+ *ptr++ = GLX_ALPHA_SIZE;
+ *ptr++ = w->glwDrawingArea.alphaSize;
+ *ptr++ = GLX_DEPTH_SIZE;
+ *ptr++ = w->glwDrawingArea.depthSize;
+ *ptr++ = GLX_STENCIL_SIZE;
+ *ptr++ = w->glwDrawingArea.stencilSize;
+ *ptr++ = GLX_ACCUM_RED_SIZE;
+ *ptr++ = w->glwDrawingArea.accumRedSize;
+ *ptr++ = GLX_ACCUM_GREEN_SIZE;
+ *ptr++ = w->glwDrawingArea.accumGreenSize;
+ *ptr++ = GLX_ACCUM_BLUE_SIZE;
+ *ptr++ = w->glwDrawingArea.accumBlueSize;
+ *ptr++ = GLX_ACCUM_ALPHA_SIZE;
+ *ptr++ = w->glwDrawingArea.accumAlphaSize;
+ *ptr++ = None;
+ assert((ptr-w->glwDrawingArea.attribList)<ATTRIBLIST_SIZE);
+ }
+
+
+
+/* Initialize the visualInfo based on the attribute list */
+static void createVisualInfo(GLwDrawingAreaWidget w){
+ assert(w->glwDrawingArea.attribList);
+ w->glwDrawingArea.visualInfo=glXChooseVisual(XtDisplay(w),XScreenNumberOfScreen(XtScreen(w)),w->glwDrawingArea.attribList);
+ if(!w->glwDrawingArea.visualInfo) error((Widget)w,"requested visual not supported");
+ }
+
+
+
+/* Initialize the colormap based on the visual info.
+ * This routine maintains a cache of visual-infos to colormaps. If two
+ * widgets share the same visual info, they share the same colormap.
+ * This function is called by the callProc of the colormap resource entry.
+ */
+static void createColormap(GLwDrawingAreaWidget w,int offset,XrmValue *value){
+ static struct cmapCache { Visual *visual; Colormap cmap; } *cmapCache;
+ static int cacheEntries=0;
+ static int cacheMalloced=0;
+ register int i;
+
+ assert(w->glwDrawingArea.visualInfo);
+
+ /* see if we can find it in the cache */
+ for(i=0; i<cacheEntries; i++){
+ if(cmapCache[i].visual==w->glwDrawingArea.visualInfo->visual){
+ value->addr=(XtPointer)(&cmapCache[i].cmap);
+ return;
+ }
+ }
+
+ /* not in the cache, create a new entry */
+ if(cacheEntries >= cacheMalloced){
+ /* need to malloc a new one. Since we are likely to have only a
+ * few colormaps, we allocate one the first time, and double
+ * each subsequent time.
+ */
+ if(cacheMalloced==0){
+ cacheMalloced=1;
+ cmapCache=(struct cmapCache*)XtMalloc(sizeof(struct cmapCache));
+ }
+ else{
+ cacheMalloced<<=1;
+ cmapCache=(struct cmapCache*)XtRealloc((char*)cmapCache,sizeof(struct cmapCache)*cacheMalloced);
+ }
+ }
+
+ cmapCache[cacheEntries].cmap=XCreateColormap(XtDisplay(w),
+ RootWindow(XtDisplay(w),
+ w->glwDrawingArea.visualInfo->screen),
+ w->glwDrawingArea.visualInfo->visual,
+ AllocNone);
+ cmapCache[cacheEntries].visual=w->glwDrawingArea.visualInfo->visual;
+ value->addr=(XtPointer)(&cmapCache[cacheEntries++].cmap);
+ }
+
+
+
+static void Initialize(GLwDrawingAreaWidget req,GLwDrawingAreaWidget neww,ArgList args,Cardinal *num_args){
+
+ /* fix size */
+ if(req->core.width==0) neww->core.width=100;
+ if(req->core.height==0) neww->core.width=100;
+
+ /* create the attribute list if needed */
+ neww->glwDrawingArea.myList=FALSE;
+ if(neww->glwDrawingArea.attribList==NULL){
+ neww->glwDrawingArea.myList=TRUE;
+ createAttribList(neww);
+ }
+
+ /* Gotta have it */
+ assert(neww->glwDrawingArea.attribList);
+
+ /* determine the visual info if needed */
+ neww->glwDrawingArea.myVisual=FALSE;
+ if(neww->glwDrawingArea.visualInfo==NULL){
+ neww->glwDrawingArea.myVisual=TRUE;
+ createVisualInfo(neww);
+ }
+
+ /* Gotta have that too */
+ assert(neww->glwDrawingArea.visualInfo);
+
+ neww->core.depth=neww->glwDrawingArea.visualInfo->depth;
+
+ /* Reobtain the colormap and colors in it using XtGetApplicationResources*/
+ XtGetApplicationResources((Widget)neww,neww,initializeResources,XtNumber(initializeResources),args,*num_args);
+
+ /* obtain the color resources if appropriate */
+ if(req->glwDrawingArea.allocateBackground){
+ XtGetApplicationResources((Widget)neww,neww,backgroundResources,XtNumber(backgroundResources),args,*num_args);
+ }
+
+#ifdef __GLX_MOTIF
+ if(req->glwDrawingArea.allocateOtherColors){
+ XtGetApplicationResources((Widget)neww,neww,otherColorResources,XtNumber(otherColorResources),args,*num_args);
+ }
+#endif
+ }
+
+
+
+static void Realize(Widget w,Mask *valueMask,XSetWindowAttributes *attributes){
+ register GLwDrawingAreaWidget glw=(GLwDrawingAreaWidget)w;
+ GLwDrawingAreaCallbackStruct cb;
+ Widget parentShell;
+ Status status;
+ Window windows[2],*windowsReturn,*windowList;
+ int countReturn,i;
+
+ /* if we haven't requested that the background be both installed and
+ * allocated, don't install it.
+ */
+ if(!(glw->glwDrawingArea.installBackground && glw->glwDrawingArea.allocateBackground)){
+ *valueMask&=~CWBackPixel;
+ }
+
+ XtCreateWindow(w,(unsigned int)InputOutput,glw->glwDrawingArea.visualInfo->visual,*valueMask,attributes);
+
+ /* if appropriate, call XSetWMColormapWindows to install the colormap */
+ if(glw->glwDrawingArea.installColormap){
+
+ /* Get parent shell */
+ for(parentShell=XtParent(w); parentShell&&!XtIsShell(parentShell); parentShell=XtParent(parentShell));
+
+ if(parentShell && XtWindow(parentShell)){
+
+ /* check to see if there is already a property */
+ status=XGetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),&windowsReturn,&countReturn);
+
+ /* if no property, just create one */
+ if(!status){
+ windows[0]=XtWindow(w);
+ windows[1]=XtWindow(parentShell);
+ XSetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),windows,2);
+ }
+
+ /* there was a property, add myself to the beginning */
+ else{
+ windowList=(Window *)XtMalloc((sizeof(Window))*(countReturn+1));
+ windowList[0]=XtWindow(w);
+ for(i=0; i<countReturn; i++) windowList[i+1]=windowsReturn[i];
+ XSetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),windowList,countReturn+1);
+ XtFree((char*)windowList);
+ XtFree((char*)windowsReturn);
+ }
+ }
+ else{
+ warning(w,"Could not set colormap property on parent shell");
+ }
+ }
+
+ /* Invoke callbacks */
+ cb.reason=GLwCR_GINIT;
+ cb.event=NULL;
+ cb.width=glw->core.width;
+ cb.height=glw->core.height;
+ XtCallCallbackList((Widget)glw,glw->glwDrawingArea.ginitCallback,&cb);
+ }
+
+
+
+static void Redraw(GLwDrawingAreaWidget w,XEvent *event,Region region){
+ GLwDrawingAreaCallbackStruct cb;
+ if(!XtIsRealized((Widget)w)) return;
+ cb.reason=GLwCR_EXPOSE;
+ cb.event=event;
+ cb.width=w->core.width;
+ cb.height=w->core.height;
+ XtCallCallbackList((Widget)w,w->glwDrawingArea.exposeCallback,&cb);
+ }
+
+
+
+static void Resize(GLwDrawingAreaWidget glw){
+ GLwDrawingAreaCallbackStruct cb;
+ if(!XtIsRealized((Widget)glw)) return;
+ cb.reason=GLwCR_RESIZE;
+ cb.event=NULL;
+ cb.width=glw->core.width;
+ cb.height=glw->core.height;
+ XtCallCallbackList((Widget)glw,glw->glwDrawingArea.resizeCallback,&cb);
+ }
+
+
+
+static void Destroy(GLwDrawingAreaWidget glw){
+ Window *windowsReturn;
+ Widget parentShell;
+ Status status;
+ int countReturn;
+ register int i;
+
+ if(glw->glwDrawingArea.myList && glw->glwDrawingArea.attribList){
+ XtFree((XtPointer)glw->glwDrawingArea.attribList);
+ }
+
+ if(glw->glwDrawingArea.myVisual && glw->glwDrawingArea.visualInfo){
+ XtFree((XtPointer)glw->glwDrawingArea.visualInfo);
+ }
+
+ /* if my colormap was installed, remove it */
+ if(glw->glwDrawingArea.installColormap){
+
+ /* Get parent shell */
+ for(parentShell=XtParent(glw); parentShell&&!XtIsShell(parentShell); parentShell=XtParent(parentShell));
+
+ if(parentShell && XtWindow(parentShell)){
+
+ /* make sure there is a property */
+ status=XGetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),&windowsReturn,&countReturn);
+
+ /* if no property, just return. If there was a property, continue */
+ if(status){
+
+ /* search for a match */
+ for(i=0; i<countReturn; i++){
+ if(windowsReturn[i]==XtWindow(glw)){
+
+ /* we found a match, now copy the rest down */
+ for(i++; i<countReturn; i++){ windowsReturn[i-1]=windowsReturn[i]; }
+
+ XSetWMColormapWindows(XtDisplay(parentShell),XtWindow(parentShell),windowsReturn,countReturn-1);
+ break;
+ }
+ }
+ XtFree((char *)windowsReturn);
+ }
+ }
+ }
+ }
+
+
+
+/* Action routine for keyboard and mouse events */
+static void glwInput(GLwDrawingAreaWidget glw,XEvent *event,String *params,Cardinal *numParams){
+ GLwDrawingAreaCallbackStruct cb;
+ cb.reason=GLwCR_INPUT;
+ cb.event=event;
+ cb.width=glw->core.width;
+ cb.height=glw->core.height;
+ XtCallCallbackList((Widget)glw,glw->glwDrawingArea.inputCallback,&cb);
+ }
+
+
+#ifdef __GLX_MOTIF
+
+/* Create routine */
+Widget GLwCreateMDrawingArea(Widget parent, char *name,ArgList arglist,Cardinal argcount){
+ return XtCreateWidget(name,glwMDrawingAreaWidgetClass, parent, arglist,argcount);
+ }
+
+#endif
+
+
+#ifndef __GLX_MOTIF
+
+/* Make context current */
+void GLwDrawingAreaMakeCurrent(Widget w,GLXContext ctx){
+ glXMakeCurrent(XtDisplay(w),XtWindow(w),ctx);
+ }
+
+
+/* Swap buffers convenience function */
+void GLwDrawingAreaSwapBuffers(Widget w){
+ glXSwapBuffers(XtDisplay(w),XtWindow(w));
+ }
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/glw/GLwDrawA.h b/nx-X11/extras/Mesa/src/glw/GLwDrawA.h
new file mode 100644
index 000000000..cd631b4fb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glw/GLwDrawA.h
@@ -0,0 +1,195 @@
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+#ifndef _GLwDrawA_h
+#define _GLwDrawA_h
+
+#include <GL/glx.h>
+#include <GL/gl.h>
+
+/****************************************************************
+ *
+ * GLwDrawingArea widgets
+ *
+ ****************************************************************/
+
+/* Resources:
+
+ Name Class RepType Default Value
+ ---- ----- ------- -------------
+ attribList AttribList int * NULL
+ visualInfo VisualInfo VisualInfo NULL
+ installColormap InstallColormap Boolean TRUE
+ allocateBackground AllocateColors Boolean FALSE
+ allocateOtherColors AllocateColors Boolean FALSE
+ installBackground InstallBackground Boolean TRUE
+ exposeCallback Callback Pointer NULL
+ ginitCallback Callback Pointer NULL
+ inputCallback Callback Pointer NULL
+ resizeCallback Callback Pointer NULL
+
+*** The following resources all correspond to the GLX configuration
+*** attributes and are used to create the attribList if it is NULL
+ bufferSize BufferSize int 0
+ level Level int 0
+ rgba Rgba Boolean FALSE
+ doublebuffer Doublebuffer Boolean FALSE
+ stereo Stereo Boolean FALSE
+ auxBuffers AuxBuffers int 0
+ redSize ColorSize int 1
+ greenSize ColorSize int 1
+ blueSize ColorSize int 1
+ alphaSize AlphaSize int 0
+ depthSize DepthSize int 0
+ stencilSize StencilSize int 0
+ accumRedSize AccumColorSize int 0
+ accumGreenSize AccumColorSize int 0
+ accumBlueSize AccumColorSize int 0
+ accumAlphaSize AccumAlphaSize int 0
+*/
+
+#define GLwNattribList "attribList"
+#define GLwCAttribList "AttribList"
+#define GLwNvisualInfo "visualInfo"
+#define GLwCVisualInfo "VisualInfo"
+#define GLwRVisualInfo "VisualInfo"
+
+#define GLwNinstallColormap "installColormap"
+#define GLwCInstallColormap "InstallColormap"
+#define GLwNallocateBackground "allocateBackground"
+#define GLwNallocateOtherColors "allocateOtherColors"
+#define GLwCAllocateColors "AllocateColors"
+#define GLwNinstallBackground "installBackground"
+#define GLwCInstallBackground "InstallBackground"
+
+#define GLwCCallback "Callback"
+#define GLwNexposeCallback "exposeCallback"
+#define GLwNginitCallback "ginitCallback"
+#define GLwNresizeCallback "resizeCallback"
+#define GLwNinputCallback "inputCallback"
+
+#define GLwNbufferSize "bufferSize"
+#define GLwCBufferSize "BufferSize"
+#define GLwNlevel "level"
+#define GLwCLevel "Level"
+#define GLwNrgba "rgba"
+#define GLwCRgba "Rgba"
+#define GLwNdoublebuffer "doublebuffer"
+#define GLwCDoublebuffer "Doublebuffer"
+#define GLwNstereo "stereo"
+#define GLwCStereo "Stereo"
+#define GLwNauxBuffers "auxBuffers"
+#define GLwCAuxBuffers "AuxBuffers"
+#define GLwNredSize "redSize"
+#define GLwNgreenSize "greenSize"
+#define GLwNblueSize "blueSize"
+#define GLwCColorSize "ColorSize"
+#define GLwNalphaSize "alphaSize"
+#define GLwCAlphaSize "AlphaSize"
+#define GLwNdepthSize "depthSize"
+#define GLwCDepthSize "DepthSize"
+#define GLwNstencilSize "stencilSize"
+#define GLwCStencilSize "StencilSize"
+#define GLwNaccumRedSize "accumRedSize"
+#define GLwNaccumGreenSize "accumGreenSize"
+#define GLwNaccumBlueSize "accumBlueSize"
+#define GLwCAccumColorSize "AccumColorSize"
+#define GLwNaccumAlphaSize "accumAlphaSize"
+#define GLwCAccumAlphaSize "AccumAlphaSize"
+
+#ifdef __GLX_MOTIF
+
+typedef struct _GLwMDrawingAreaClassRec *GLwMDrawingAreaWidgetClass;
+typedef struct _GLwMDrawingAreaRec *GLwMDrawingAreaWidget;
+
+extern WidgetClass glwMDrawingAreaWidgetClass;
+
+
+#else
+
+typedef struct _GLwDrawingAreaClassRec *GLwDrawingAreaWidgetClass;
+typedef struct _GLwDrawingAreaRec *GLwDrawingAreaWidget;
+
+extern WidgetClass glwDrawingAreaWidgetClass;
+
+
+#endif
+
+
+/* Callback reasons */
+#ifdef __GLX_MOTIF
+#define GLwCR_EXPOSE XmCR_EXPOSE
+#define GLwCR_RESIZE XmCR_RESIZE
+#define GLwCR_INPUT XmCR_INPUT
+#else
+/* The same values as Motif, but don't use Motif constants */
+#define GLwCR_EXPOSE 38
+#define GLwCR_RESIZE 39
+#define GLwCR_INPUT 40
+#endif
+
+#define GLwCR_GINIT 32135 /* Arbitrary number that should neverr clash */
+
+typedef struct
+ {
+ int reason;
+ XEvent *event;
+ Dimension width,height;
+ }
+ GLwDrawingAreaCallbackStruct;
+
+#if defined(__cplusplus) || defined(c_plusplus)
+extern "C" {
+#endif
+
+/* front ends to glXMakeCurrent and glXSwapBuffers */
+extern void GLwDrawingAreaMakeCurrent(Widget w,GLXContext ctx);
+extern void GLwDrawingAreaSwapBuffers(Widget w);
+
+#ifdef __GLX_MOTIF
+#ifdef _NO_PROTO
+GLAPI Widget GLwCreateMDrawingArea();
+#else
+GLAPI Widget GLwCreateMDrawingArea(Widget parent,char *name,ArgList arglist,Cardinal argcount);
+#endif
+#endif
+
+#if defined(__cplusplus) || defined(c_plusplus)
+}
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/glw/GLwDrawAP.h b/nx-X11/extras/Mesa/src/glw/GLwDrawAP.h
new file mode 100644
index 000000000..f12170195
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glw/GLwDrawAP.h
@@ -0,0 +1,130 @@
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+#ifndef _GLwDrawAP_h
+#define _GLwDrawAP_h
+
+
+/* MOTIF */
+#ifdef __GLX_MOTIF
+#include "GLwMDrawA.h"
+#else
+#include "GLwDrawA.h"
+#endif
+
+typedef struct _GLwDrawingAreaClassPart {
+ caddr_t extension;
+ } GLwDrawingAreaClassPart;
+
+
+#ifdef __GLX_MOTIF
+typedef struct _GLwMDrawingAreaClassRec {
+ CoreClassPart core_class;
+ XmPrimitiveClassPart primitive_class;
+ GLwDrawingAreaClassPart glwDrawingArea_class;
+ } GLwMDrawingAreaClassRec;
+
+
+extern GLwMDrawingAreaClassRec glwMDrawingAreaClassRec;
+
+
+/* XT */
+#else
+
+typedef struct _GLwDrawingAreaClassRec {
+ CoreClassPart core_class;
+ GLwDrawingAreaClassPart glwDrawingArea_class;
+ } GLwDrawingAreaClassRec;
+
+extern GLwDrawingAreaClassRec glwDrawingAreaClassRec;
+
+
+#endif
+
+
+
+typedef struct {
+ /* resources */
+ int * attribList;
+ XVisualInfo * visualInfo;
+ Boolean myList; /* TRUE if we malloced the attribList*/
+ Boolean myVisual; /* TRUE if we created the visualInfo*/
+ Boolean installColormap;
+ Boolean allocateBackground;
+ Boolean allocateOtherColors;
+ Boolean installBackground;
+ XtCallbackList ginitCallback;
+ XtCallbackList resizeCallback;
+ XtCallbackList exposeCallback;
+ XtCallbackList inputCallback;
+ /* specific attributes; add as we get new attributes */
+ int bufferSize;
+ int level;
+ Boolean rgba;
+ Boolean doublebuffer;
+ Boolean stereo;
+ int auxBuffers;
+ int redSize;
+ int greenSize;
+ int blueSize;
+ int alphaSize;
+ int depthSize;
+ int stencilSize;
+ int accumRedSize;
+ int accumGreenSize;
+ int accumBlueSize;
+ int accumAlphaSize;
+ } GLwDrawingAreaPart;
+
+#ifdef __GLX_MOTIF
+
+typedef struct _GLwMDrawingAreaRec {
+ CorePart core;
+ XmPrimitivePart primitive;
+ GLwDrawingAreaPart glwDrawingArea;
+ } GLwMDrawingAreaRec;
+
+#else
+
+typedef struct _GLwDrawingAreaRec {
+ CorePart core;
+ GLwDrawingAreaPart glwDrawingArea;
+ } GLwDrawingAreaRec;
+
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/glw/GLwMDrawA.c b/nx-X11/extras/Mesa/src/glw/GLwMDrawA.c
new file mode 100644
index 000000000..bdefe92a6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glw/GLwMDrawA.c
@@ -0,0 +1,41 @@
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+#ifndef __GLX_MOTIF
+#define __GLX_MOTIF 1
+#endif
+#include "GLwDrawA.c"
diff --git a/nx-X11/extras/Mesa/src/glw/GLwMDrawA.h b/nx-X11/extras/Mesa/src/glw/GLwMDrawA.h
new file mode 100644
index 000000000..2e2458904
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glw/GLwMDrawA.h
@@ -0,0 +1,41 @@
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+#ifndef __GLX_MOTIF
+#define __GLX_MOTIF 1
+#endif
+#include "GLwDrawA.h"
diff --git a/nx-X11/extras/Mesa/src/glw/GLwMDrawAP.h b/nx-X11/extras/Mesa/src/glw/GLwMDrawAP.h
new file mode 100644
index 000000000..a0a689bb9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glw/GLwMDrawAP.h
@@ -0,0 +1,41 @@
+/*
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
+ */
+#ifndef __GLX_MOTIF
+#define __GLX_MOTIF 1
+#endif
+#include "GLwDrawAP.h"
diff --git a/nx-X11/extras/Mesa/src/glw/Makefile b/nx-X11/extras/Mesa/src/glw/Makefile
new file mode 100644
index 000000000..3c66c6778
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glw/Makefile
@@ -0,0 +1,52 @@
+# src/glw/Makefile
+
+TOP = ../..
+include $(TOP)/configs/current
+
+MAJOR = 1
+MINOR = 0
+TINY = 0
+
+INCDIRS = -I$(TOP)/include -I/usr/include/Motif1.2 -I/usr/contrib/X11R6/include -I/usr/X11R6/include
+
+
+OBJECTS = $(GLW_SOURCES:.c=.o)
+
+
+
+##### RULES #####
+
+.c.o:
+ $(CC) -c $(INCDIRS) $(CFLAGS) $<
+
+
+
+##### TARGETS #####
+
+default: $(LIB_DIR)/$(GLW_LIB_NAME)
+
+
+clean:
+ -rm depend depend.bak
+ -rm -f *.o *~
+
+
+# Make the library
+$(LIB_DIR)/$(GLW_LIB_NAME): $(OBJECTS)
+ $(TOP)/bin/mklib -o $(GLW_LIB) -linker '$(CC)' \
+ -major $(MAJOR) -minor $(MINOR) -patch $(TINY) \
+ $(MKLIB_OPTIONS) -install $(LIB_DIR) \
+ $(GLW_LIB_DEPS) $(OBJECTS)
+
+
+#
+# Run 'make depend' to update the dependencies if you change what's included
+# by any source file.
+#
+depend: $(GLW_SOURCES)
+ touch depend
+ $(MKDEP) $(MKDEP_OPTIONS) -I$(TOP)/include $(GLW_SOURCES) \
+ > /dev/null
+
+
+include depend
diff --git a/nx-X11/extras/Mesa/src/glw/README b/nx-X11/extras/Mesa/src/glw/README
new file mode 100644
index 000000000..70f4f7bc2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glw/README
@@ -0,0 +1,56 @@
+
+ widgets README file
+
+
+This directory contains the source code for SGI's OpenGL Xt/Motif widgets,
+slightly modified by Jeroen van der Zijp to work better with Mesa.
+
+To compile the widget code (producing lib/libGLw.a) cd to the widgets/
+directory and type 'make <config>' where <config> is the system configuration
+you used to compile Mesa (like 'make linux'). This hasn't been tested on
+many systems so let us know if you have trouble.
+
+If you want to make a Linux ELF shared lib instead of the non-shared .a
+file see the notes in the Makefile.
+
+If you want to build with Motif support, edit Makefile.X11, looking
+for the "Motif" information.
+
+The SGI copyright is as follows.
+
+
+ * (c) Copyright 1993, Silicon Graphics, Inc.
+ * ALL RIGHTS RESERVED
+ * Permission to use, copy, modify, and distribute this software for
+ * any purpose and without fee is hereby granted, provided that the above
+ * copyright notice appear in all copies and that both the copyright notice
+ * and this permission notice appear in supporting documentation, and that
+ * the name of Silicon Graphics, Inc. not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission.
+ *
+ * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
+ * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
+ * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
+ * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
+ * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
+ * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
+ * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
+ * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * US Government Users Restricted Rights
+ * Use, duplication, or disclosure by the Government is subject to
+ * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
+ * (c)(1)(ii) of the Rights in Technical Data and Computer Software
+ * clause at DFARS 252.227-7013 and/or in similar or successor
+ * clauses in the FAR or the DOD or NASA FAR Supplement.
+ * Unpublished-- rights reserved under the copyright laws of the
+ * United States. Contractor/manufacturer is Silicon Graphics,
+ * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311.
+ *
+ * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
diff --git a/nx-X11/extras/Mesa/src/glx/Makefile b/nx-X11/extras/Mesa/src/glx/Makefile
new file mode 100644
index 000000000..bd486cf81
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/Makefile
@@ -0,0 +1,12 @@
+
+TOP = ../..
+include $(TOP)/configs/current
+
+
+default:
+ cd mini ; $(MAKE)
+
+
+clean:
+ cd mini ; $(MAKE) clean
+
diff --git a/nx-X11/extras/Mesa/src/glx/mini/Makefile b/nx-X11/extras/Mesa/src/glx/mini/Makefile
new file mode 100644
index 000000000..e87905acb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/mini/Makefile
@@ -0,0 +1,86 @@
+# Build a subset DRI-based libGL.so library.
+# Indirect rendering not supported, etc.
+
+TOP = ../../..
+include $(TOP)/configs/current
+
+
+DEFINES += -DGLX_DIRECT_RENDERING -DIN_MINI_GLX -UIN_DRI_DRIVER
+
+C_SOURCES = \
+ $(TOP)/src/mesa/main/dispatch.c \
+ $(TOP)/src/mesa/glapi/glapi.c \
+ $(TOP)/src/mesa/glapi/glthread.c \
+ $(TOP)/src/mesa/drivers/dri/common/glcontextmodes.c \
+ $(DRM_SOURCE_PATH)/libdrm/xf86drm.c \
+ $(DRM_SOURCE_PATH)/libdrm/xf86drmHash.c \
+ $(DRM_SOURCE_PATH)/libdrm/xf86drmRandom.c \
+ miniglx.c \
+ miniglx_events.c
+
+X86_SOURCES = $(TOP)/src/mesa/x86/glapi_x86.S
+
+OBJECTS = $(C_SOURCES:.c=.o) \
+ $(ASM_SOURCES:.S=.o)
+
+INCLUDES = -I. $(INCLUDE_DIRS)
+
+INCLUDE_DIRS = \
+ -I$(TOP)/include \
+ -I$(TOP)/src/mesa \
+ -I$(TOP)/src/mesa/main \
+ -I$(TOP)/src/mesa/glapi \
+ -I$(TOP)/src/mesa/math \
+ -I$(TOP)/src/mesa/transform \
+ -I$(TOP)/src/mesa/swrast \
+ -I$(TOP)/src/mesa/swrast_setup \
+ -I$(TOP)/src/mesa/drivers/dri/common \
+ -I$(DRM_SOURCE_PATH)/libdrm \
+ -I$(DRM_SOURCE_PATH)/shared
+
+
+##### RULES #####
+
+.c.o:
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+.S.o:
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+
+##### TARGETS #####
+
+default: depend $(LIB_DIR)/$(GL_LIB_NAME)
+
+
+# Make libGL
+$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) Makefile
+ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
+ -major 1 -minor 2 $(MKLIB_OPTIONS) \
+ -install $(LIB_DIR) $(GL_LIB_DEPS) $(OBJECTS)
+ rm -f $(LIB_DIR)/miniglx.conf
+ install example.miniglx.conf $(LIB_DIR)/miniglx.conf
+
+
+drmtest: xf86drm.o drmtest.o
+ rm -f drmtest && $(CC) -o drmtest xf86drm.o drmtest.o
+
+
+depend: $(C_SOURCES) $(ASM_SOURCES)
+ touch depend
+ $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) $(ASM_SOURCES) \
+ > /dev/null
+
+
+# Emacs tags
+tags:
+ etags `find . -name \*.[ch]` `find ../include`
+
+
+# Remove .o and backup files
+clean:
+ -rm -f drmtest $(LIB_DIR)/libGL.so*
+ -rm -f *.o *~
+ -rm -f depend
+
+include depend
diff --git a/nx-X11/extras/Mesa/src/glx/mini/NOTES b/nx-X11/extras/Mesa/src/glx/mini/NOTES
new file mode 100644
index 000000000..1774107d6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/mini/NOTES
@@ -0,0 +1,115 @@
+
+
+Getting MiniGLX up and running
+------------------------------
+
+It's necessary to do a bit of work to set up an environment to run miniglx.
+
+For the radeon driver, it's necessary to get the right set of kernel
+modules installed before attempting to run any programs:
+
+ rmmod radeon agpgart;
+ insmod agpgart;
+ insmod $(MESA)/src/kernel/radeonfb/radeonfb.o;
+ insmod $(MESA)/src/kernel/radeon/radeon.o;
+
+For all drivers, its necessary to reach the compiled libraries, and
+tell MiniGLX where to find it's configuration file:
+
+ export LD_LIBRARY_PATH=$(MESA)/lib;
+ export MINIGLX_CONF=$(MESA)/lib/miniglx.conf
+
+------------------------------------------------------------
+
+MiniGLX Example Programs
+------------------------
+
+The following programs will work with miniglx:
+
+ $(MESA)/tests/miniglx
+ $(MESA)/xdemos/glxgears
+
+Thanks to the miniglut stub library, most of the mesa glut demos will
+work. In particular, the following have been tested. (Note there is
+no keyboard or mouse interaction with these demos).
+
+ $(MESA)/demos/gears
+ $(MESA)/demos/geartrain
+ $(MESA)/demos/morph3d
+ $(MESA)/demos/isosurf
+ $(MESA)/demos/texobj
+ $(MESA)/demos/texcyl
+ $(MESA)/demos/gloss
+ $(MESA)/demos/fire
+ $(MESA)/demos/tunnel
+ $(MESA)/demos/teapot
+ $(MESA)/samples/prim
+ $(MESA)/samples/olympic
+ $(MESA)/samples/star
+ $(MESA)/samples/wave
+ ...etc
+
+In fact most of the glut demos seem to work within the constraints of
+having no keyboard/mouse interactivity. Furthermore, the use of the
+glut wrapper means that these programs don't require recompilation to
+run under MiniGLX -- the same binary works with both regular GLX and
+MiniGLX.
+
+
+------------------------------------------------------------
+
+Porting GLX apps to MiniGLX
+---------------------------
+
+A quick list of issues encountered in porting existing GLX apps to
+MiniGLX. Listed in no particular order.
+
+1) No input events
+
+MiniGLX doesn't provide an input layer, so any X11 input event
+handling in the existing app will have to be redone for whatever
+input devices exist on the target.
+
+2) No configuration, expose events
+
+Many GLX and Xlib programs wait on an event to ensure the window has
+become visible after being mapped. MiniGLX provides no equivalent
+facility.
+
+3) Different headers
+
+X11/Xlib.h, GL/GLX.h, etc must not be used if the program is being
+compiled against MiniGLX.
+
+The equivalent header is GL/MiniGLX.h.
+
+4) Different library
+
+It may be necessary to link directly against the minGLX libGL.so.
+
+5) Reduced number of Xlib and GLX entrypoints.
+
+By definition (MiniGLX is a subset of GLX), many Xlib and GLX
+entrypoints, structures and macros are not present in MiniGLX. It
+will be necessary to find and eliminate all references to
+non-supported entrypoints.
+
+
+---------------------------------------------------------------
+
+Bugs in radeonfb.o -- the radeon framebuffer driver.
+----------------------------------------------------
+
+Several bugs have been found in the radeonfb.o framebuffer driver.
+Most of these are resolved in the version included in the MiniGLX
+sources, but some remain:
+
+1) Occasionally, after entering graphics mode, colors appear 'shifted'
+or 'translated', particularly in higher resolution modes. This is
+definitely a bug in radeonfb.o as this can be provoked even when using
+the software dri driver (fb_dri.so). Importance: High. Workaround:
+Use 800x600 as it seems to be less frequent at this resolution,
+otherwise, restart the application.
+
+
+
diff --git a/nx-X11/extras/Mesa/src/glx/mini/dispatch.c b/nx-X11/extras/Mesa/src/glx/mini/dispatch.c
new file mode 100644
index 000000000..ac24df9e7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/mini/dispatch.c
@@ -0,0 +1,64 @@
+/**
+ * \file miniglx/dispatch.c
+ *
+ * \brief C-based dispatch of the OpenGL entry points (glAccum(), glBegin(),
+ * etc).
+ *
+ * \author Brian Paul <brian@precisioninsight.com>
+ *
+ * \note This code IS NOT USED if we're compiling on an x86 system and using
+ * the glapi_x86.S assembly code.
+ */
+
+/*
+ * 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.
+ */
+
+#include "glheader.h"
+#include "glapi.h"
+#include "glapitable.h"
+
+
+#if !(defined(USE_X86_ASM) || defined(USE_SPARC_ASM))
+
+#define KEYWORD1
+
+#define KEYWORD2
+
+#define NAME(func) gl##func
+
+#define DISPATCH(func, args, msg) \
+ const struct _glapi_table *dispatch; \
+ dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\
+ (dispatch->func) args
+
+#define RETURN_DISPATCH(func, args, msg) \
+ const struct _glapi_table *dispatch; \
+ dispatch = _glapi_Dispatch ? _glapi_Dispatch : _glapi_get_dispatch();\
+ return (dispatch->func) args
+
+
+#include "glapitemp.h"
+
+#endif /* USE_X86_ASM */
diff --git a/nx-X11/extras/Mesa/src/glx/mini/driver.h b/nx-X11/extras/Mesa/src/glx/mini/driver.h
new file mode 100644
index 000000000..27402641b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/mini/driver.h
@@ -0,0 +1,169 @@
+/**
+ * \file driver.h
+ * \brief DRI utility functions definitions.
+ *
+ * This module acts as glue between GLX and the actual hardware driver. A DRI
+ * driver doesn't really \e have to use any of this - it's optional. But, some
+ * useful stuff is done here that otherwise would have to be duplicated in most
+ * drivers.
+ *
+ * Basically, these utility functions take care of some of the dirty details of
+ * screen initialization, context creation, context binding, DRM setup, etc.
+ *
+ * These functions are compiled into each DRI driver so libGL.so knows nothing
+ * about them.
+ *
+ * Look for more comments in the dri_util.c file.
+ *
+ * \author Kevin E. Martin <kevin@precisioninsight.com>
+ * \author Brian Paul <brian@precisioninsight.com>
+ */
+
+/*
+ * 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.
+ */
+
+#ifndef _driver_H_
+#define _driver_H_
+
+#define CAPI /* XXX this should be globally defined somewhere */
+
+#include "GL/gl.h"
+#include "GL/internal/glcore.h"
+
+#include "drm.h"
+#include "drm_sarea.h"
+
+/**
+ * \brief DRIDriverContext type.
+ */
+typedef struct DRIDriverContextRec {
+ const char *pciBusID;
+ int pciBus;
+ int pciDevice;
+ int pciFunc;
+ int chipset;
+ int bpp;
+ int cpp;
+ int agpmode;
+ int isPCI;
+
+ int colorTiling; /**< \brief color tiling is enabled */
+
+ unsigned long FBStart; /**< \brief physical address of the framebuffer */
+ unsigned long MMIOStart; /**< \brief physical address of the MMIO region */
+
+ int FBSize; /**< \brief size of the mmap'd framebuffer in bytes */
+ int MMIOSize; /**< \brief size of the mmap'd MMIO region in bytes */
+
+ void *FBAddress; /**< \brief start of the mmap'd framebuffer */
+ void *MMIOAddress; /**< \brief start of the mmap'd MMIO region */
+
+ /**
+ * \brief Client configuration details
+ *
+ * These are computed on the server and sent to clients as part of
+ * the initial handshaking.
+ */
+ struct {
+ unsigned long hSAREA;
+ int SAREASize;
+ unsigned long hFrameBuffer;
+ int fbOrigin;
+ int fbSize;
+ int fbStride;
+ int virtualWidth;
+ int virtualHeight;
+ } shared;
+
+ /**
+ * \name From DRIInfoRec
+ */
+ /*@{*/
+ int drmFD; /**< \brief DRM device file descriptor */
+ drm_sarea_t *pSAREA;
+ unsigned int serverContext; /**< \brief DRM context only active on server */
+ /*@}*/
+
+
+ /**
+ * \name Driver private
+ *
+ * Populated by __driInitFBDev()
+ */
+ /*@{*/
+ void *driverPrivate;
+ void *driverClientMsg;
+ int driverClientMsgSize;
+ /*@}*/
+} DRIDriverContext;
+
+/**
+ * \brief Interface to the DRI driver.
+ *
+ * This structure is retrieved from the loadable driver by the \e
+ * __driDriver symbol to access the Mini GLX specific hardware
+ * initialization and take down routines.
+ */
+typedef struct DRIDriverRec {
+ /**
+ * \brief Validate the framebuffer device mode
+ */
+ int (*validateMode)( const DRIDriverContext *context );
+
+ /**
+ * \brief Examine mode returned by fbdev (may differ from the one
+ * requested), restore any hw regs clobbered by fbdev.
+ */
+ int (*postValidateMode)( const DRIDriverContext *context );
+
+ /**
+ * \brief Initialize the framebuffer device.
+ */
+ int (*initFBDev)( DRIDriverContext *context );
+
+ /**
+ * \brief Halt the framebuffer device.
+ */
+ void (*haltFBDev)( DRIDriverContext *context );
+
+
+ /**
+ * \brief Idle and shutdown hardware in preparation for a VT switch.
+ */
+ int (*shutdownHardware)( const DRIDriverContext *context );
+
+ /**
+ * \brief Restore hardware state after regaining the VT.
+ */
+ int (*restoreHardware)( const DRIDriverContext *context );
+
+ /**
+ * \brief Notify hardware driver of gain/loose focus. May be zero
+ * as this is of limited utility for most drivers.
+ */
+ void (*notifyFocus)( int have_focus );
+} DRIDriver;
+
+#endif /* _driver_H_ */
diff --git a/nx-X11/extras/Mesa/src/glx/mini/example.miniglx.conf b/nx-X11/extras/Mesa/src/glx/mini/example.miniglx.conf
new file mode 100644
index 000000000..62dd4f65e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/mini/example.miniglx.conf
@@ -0,0 +1,36 @@
+# Example miniglx configuration file (/etc/miniglx.conf)
+#
+
+# Framebuffer device to open: Might need to change this on dual-head
+# systems.
+fbdevDevice=/dev/fb0
+
+# Which driver?
+# radeon_dri.so -- HW accelerated radeon driver
+# fb_dri.so -- Software rasterizer
+clientDriverName=radeon_dri.so
+
+# The pci bus id of the video card. Find this with scanpci, lspci or
+# look in /proc/pci.
+pciBusID=PCI:1:0:0
+
+# Is the card PCI or AGP ?
+isPCI=0
+
+# Virtual screen dimensions. Can reduce this to save videocard memory
+# at the expense of maximum window size available.
+virtualWidth=1280
+virtualHeight=1024
+
+# Screen depth. Only 16 & 32bpp supported.
+bpp=32
+
+# AGP Mode. Not all cards supported (1, 2 or 4)
+agpmode=1
+
+# Rotated monitor? -- NOTE: only works with subsetted radeon driver!
+rotateMode=0
+
+# Do we want to use color tiling ?
+colorTiling=0
+
diff --git a/nx-X11/extras/Mesa/src/glx/mini/miniglx.c b/nx-X11/extras/Mesa/src/glx/mini/miniglx.c
new file mode 100644
index 000000000..c1c4446ab
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/mini/miniglx.c
@@ -0,0 +1,2563 @@
+/**
+ * \file miniglx.c
+ * \brief Mini GLX interface functions.
+ * \author Brian Paul
+ *
+ * The Mini GLX interface is a subset of the GLX interface, plus a
+ * minimal set of Xlib functions.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.0.1
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+/**
+ * \mainpage Mini GLX
+ *
+ * \section miniglxIntro Introduction
+ *
+ * The Mini GLX interface facilitates OpenGL rendering on embedded devices. The
+ * interface is a subset of the GLX interface, plus a minimal set of Xlib-like
+ * functions.
+ *
+ * Programs written to the Mini GLX specification should run unchanged
+ * on systems with the X Window System and the GLX extension (after
+ * recompilation). The intention is to allow flexibility for
+ * prototyping and testing.
+ *
+ * The files in the src/miniglx/ directory are compiled to build the
+ * libGL.so library. This is the library which applications link with.
+ * libGL.so in turn, loads the hardware-specific device driver.
+ *
+ *
+ * \section miniglxDoxygen About Doxygen
+ *
+ * For a list of all files, select <b>File List</b>. Choose a file from
+ * the list for a list of all functions in the file.
+ *
+ * For a list of all functions, types, constants, etc.
+ * select <b>File Members</b>.
+ *
+ *
+ * \section miniglxReferences References
+ *
+ * - <A HREF="file:../../docs/MiniGLX.html">Mini GLX Specification</A>,
+ * Tungsten Graphics, Inc.
+ * - OpenGL Graphics with the X Window System, Silicon Graphics, Inc.,
+ * ftp://ftp.sgi.com/opengl/doc/opengl1.2/glx1.3.ps
+ * - Xlib - C Language X Interface, X Consortium Standard, X Version 11,
+ * Release 6.4, ftp://ftp.x.org/pub/R6.4/xc/doc/hardcopy/X11/xlib.PS.gz
+ * - XFree86 Man pages, The XFree86 Project, Inc.,
+ * http://www.xfree86.org/current/manindex3.html
+ *
+ */
+
+/**
+ * \page datatypes Notes on the XVisualInfo, Visual, and __GLXvisualConfig data types
+ *
+ * -# X (unfortunately) has two (or three) data types which
+ * describe visuals. Ideally, there would just be one.
+ * -# We need the #__GLXvisualConfig type to augment #XVisualInfo and #Visual
+ * because we need to describe the GLX-specific attributes of visuals.
+ * -# In this interface there is a one-to-one-to-one correspondence between
+ * the three types and they're all interconnected.
+ * -# The #XVisualInfo type has a pointer to a #Visual. The #Visual structure
+ * (aka MiniGLXVisualRec) has a pointer to the #__GLXvisualConfig. The
+ * #Visual structure also has a pointer pointing back to the #XVisualInfo.
+ * -# The #XVisualInfo structure is the only one who's contents are public.
+ * -# The glXChooseVisual() and XGetVisualInfo() are the only functions that
+ * return #XVisualInfo structures. They can be freed with XFree(), though
+ * there is a small memory leak.
+ */
+
+
+#include <assert.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/time.h> /* for gettimeofday */
+#include <linux/kd.h>
+#include <linux/vt.h>
+
+#include "miniglxP.h"
+#include "dri_util.h"
+
+#include "imports.h"
+#include "glcontextmodes.h"
+#include "glapi.h"
+
+
+static GLboolean __glXCreateContextWithConfig(__DRInativeDisplay *dpy,
+ int screen, int fbconfigID, void *contextID,
+ drm_context_t *hHWContext);
+
+static GLboolean __glXGetDrawableInfo(__DRInativeDisplay *dpy, int scrn,
+ __DRIid draw, unsigned int * index, unsigned int * stamp,
+ int * x, int * y, int * width, int * height,
+ int * numClipRects, drm_clip_rect_t ** pClipRects,
+ int * backX, int * backY,
+ int * numBackClipRects, drm_clip_rect_t ** pBackClipRects);
+
+static __DRIscreen * __glXFindDRIScreen(__DRInativeDisplay *dpy, int scrn);
+
+static GLboolean __glXWindowExists(__DRInativeDisplay *dpy, __DRIid draw);
+
+static int __glXGetUST( int64_t * ust );
+
+static GLboolean __glXGetMscRate(__DRInativeDisplay * dpy, __DRIid drawable,
+ int32_t * numerator, int32_t * denominator);
+
+static GLboolean xf86DRI_DestroyContext(__DRInativeDisplay *dpy, int screen,
+ __DRIid context_id );
+
+static GLboolean xf86DRI_CreateDrawable(__DRInativeDisplay *dpy, int screen,
+ __DRIid drawable, drm_drawable_t *hHWDrawable );
+
+static GLboolean xf86DRI_DestroyDrawable(__DRInativeDisplay *dpy, int screen,
+ __DRIid drawable);
+
+
+/** Wrapper around either malloc() */
+void *
+_mesa_malloc(size_t bytes)
+{
+ return malloc(bytes);
+}
+
+/** Wrapper around either calloc() */
+void *
+_mesa_calloc(size_t bytes)
+{
+ return calloc(1, bytes);
+}
+
+/** Wrapper around either free() */
+void
+_mesa_free(void *ptr)
+{
+ free(ptr);
+}
+
+
+/**
+ * \brief Current GLX context.
+ *
+ * \sa glXGetCurrentContext().
+ */
+static GLXContext CurrentContext = NULL;
+
+
+
+static Display *SignalDisplay = 0;
+
+static void SwitchVT(int sig)
+{
+ fprintf(stderr, "SwitchVT %d dpy %p\n", sig, SignalDisplay);
+
+ if (SignalDisplay) {
+ SignalDisplay->vtSignalFlag = 1;
+ switch( sig )
+ {
+ case SIGUSR1: /* vt has been released */
+ SignalDisplay->haveVT = 0;
+ break;
+ case SIGUSR2: /* vt has been acquired */
+ SignalDisplay->haveVT = 1;
+ break;
+ }
+ }
+}
+
+/**********************************************************************/
+/** \name Framebuffer device functions */
+/**********************************************************************/
+/*@{*/
+
+/**
+ * \brief Do the first part of setting up the framebuffer device.
+ *
+ * \param dpy the display handle.
+ * \param use_vt use a VT for display or not
+ *
+ * \return GL_TRUE on success, or GL_FALSE on failure.
+ *
+ * \sa This is called during XOpenDisplay().
+ *
+ * \internal
+ * Gets the VT number, opens the respective console TTY device. Saves its state
+ * to restore when exiting and goes into graphics mode.
+ *
+ * Opens the framebuffer device and make a copy of the original variable screen
+ * information and gets the fixed screen information. Maps the framebuffer and
+ * MMIO region into the process address space.
+ */
+static GLboolean
+OpenFBDev( Display *dpy, int use_vt )
+{
+ char ttystr[1000];
+ int fd, vtnumber, ttyfd;
+
+ assert(dpy);
+
+ if (geteuid()) {
+ fprintf(stderr, "error: you need to be root\n");
+ return GL_FALSE;
+ }
+
+ if (use_vt) {
+
+ /* open /dev/tty0 and get the VT number */
+ if ((fd = open("/dev/tty0", O_WRONLY, 0)) < 0) {
+ fprintf(stderr, "error opening /dev/tty0\n");
+ return GL_FALSE;
+ }
+ if (ioctl(fd, VT_OPENQRY, &vtnumber) < 0 || vtnumber < 0) {
+ fprintf(stderr, "error: couldn't get a free vt\n");
+ return GL_FALSE;
+ }
+
+ fprintf(stderr, "*** got vt nr: %d\n", vtnumber);
+ close(fd);
+
+ /* open the console tty */
+ sprintf(ttystr, "/dev/tty%d", vtnumber); /* /dev/tty1-64 */
+ dpy->ConsoleFD = open(ttystr, O_RDWR | O_NDELAY, 0);
+ if (dpy->ConsoleFD < 0) {
+ fprintf(stderr, "error couldn't open console fd\n");
+ return GL_FALSE;
+ }
+
+ /* save current vt number */
+ {
+ struct vt_stat vts;
+ if (ioctl(dpy->ConsoleFD, VT_GETSTATE, &vts) == 0)
+ dpy->OriginalVT = vts.v_active;
+ }
+
+ /* disconnect from controlling tty */
+ ttyfd = open("/dev/tty", O_RDWR);
+ if (ttyfd >= 0) {
+ ioctl(ttyfd, TIOCNOTTY, 0);
+ close(ttyfd);
+ }
+
+ /* some magic to restore the vt when we exit */
+ {
+ struct vt_mode vt;
+ struct sigaction sig_tty;
+
+ /* Set-up tty signal handler to catch the signal we request below */
+ SignalDisplay = dpy;
+ memset( &sig_tty, 0, sizeof( sig_tty ) );
+ sig_tty.sa_handler = SwitchVT;
+ sigemptyset( &sig_tty.sa_mask );
+ if( sigaction( SIGUSR1, &sig_tty, &dpy->OrigSigUsr1 ) ||
+ sigaction( SIGUSR2, &sig_tty, &dpy->OrigSigUsr2 ) )
+ {
+ fprintf(stderr, "error: can't set up signal handler (%s)",
+ strerror(errno) );
+ return GL_FALSE;
+ }
+
+
+
+ vt.mode = VT_PROCESS;
+ vt.waitv = 0;
+ vt.relsig = SIGUSR1;
+ vt.acqsig = SIGUSR2;
+ if (ioctl(dpy->ConsoleFD, VT_SETMODE, &vt) < 0) {
+ fprintf(stderr, "error: ioctl(VT_SETMODE) failed: %s\n",
+ strerror(errno));
+ return GL_FALSE;
+ }
+
+
+ if (ioctl(dpy->ConsoleFD, VT_ACTIVATE, vtnumber) != 0)
+ printf("ioctl VT_ACTIVATE: %s\n", strerror(errno));
+ if (ioctl(dpy->ConsoleFD, VT_WAITACTIVE, vtnumber) != 0)
+ printf("ioctl VT_WAITACTIVE: %s\n", strerror(errno));
+
+ if (ioctl(dpy->ConsoleFD, VT_GETMODE, &vt) < 0) {
+ fprintf(stderr, "error: ioctl VT_GETMODE: %s\n", strerror(errno));
+ return GL_FALSE;
+ }
+
+
+
+ }
+
+ /* go into graphics mode */
+ if (ioctl(dpy->ConsoleFD, KDSETMODE, KD_GRAPHICS) < 0) {
+ fprintf(stderr, "error: ioctl(KDSETMODE, KD_GRAPHICS) failed: %s\n",
+ strerror(errno));
+ return GL_FALSE;
+ }
+ }
+
+ /* open the framebuffer device */
+ dpy->FrameBufferFD = open(dpy->fbdevDevice, O_RDWR);
+ if (dpy->FrameBufferFD < 0) {
+ fprintf(stderr, "Error opening /dev/fb0: %s\n", strerror(errno));
+ return GL_FALSE;
+ }
+
+ /* get the original variable screen info */
+ if (ioctl(dpy->FrameBufferFD, FBIOGET_VSCREENINFO, &dpy->OrigVarInfo)) {
+ fprintf(stderr, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n",
+ strerror(errno));
+ return GL_FALSE;
+ }
+
+ /* make copy */
+ dpy->VarInfo = dpy->OrigVarInfo; /* structure copy */
+
+ /* Turn off hw accels (otherwise mmap of mmio region will be
+ * refused)
+ */
+ dpy->VarInfo.accel_flags = 0;
+ if (ioctl(dpy->FrameBufferFD, FBIOPUT_VSCREENINFO, &dpy->VarInfo)) {
+ fprintf(stderr, "error: ioctl(FBIOPUT_VSCREENINFO) failed: %s\n",
+ strerror(errno));
+ return GL_FALSE;
+ }
+
+
+
+ /* Get the fixed screen info */
+ if (ioctl(dpy->FrameBufferFD, FBIOGET_FSCREENINFO, &dpy->FixedInfo)) {
+ fprintf(stderr, "error: ioctl(FBIOGET_FSCREENINFO) failed: %s\n",
+ strerror(errno));
+ return GL_FALSE;
+ }
+
+
+
+ /* mmap the framebuffer into our address space */
+ dpy->driverContext.FBStart = dpy->FixedInfo.smem_start;
+ dpy->driverContext.FBSize = dpy->FixedInfo.smem_len;
+ dpy->driverContext.shared.fbSize = dpy->FixedInfo.smem_len;
+ dpy->driverContext.FBAddress = (caddr_t) mmap(0, /* start */
+ dpy->driverContext.shared.fbSize, /* bytes */
+ PROT_READ | PROT_WRITE, /* prot */
+ MAP_SHARED, /* flags */
+ dpy->FrameBufferFD, /* fd */
+ 0 /* offset */);
+ if (dpy->driverContext.FBAddress == (caddr_t) - 1) {
+ fprintf(stderr, "error: unable to mmap framebuffer: %s\n",
+ strerror(errno));
+ return GL_FALSE;
+ }
+
+ /* mmap the MMIO region into our address space */
+ dpy->driverContext.MMIOStart = dpy->FixedInfo.mmio_start;
+ dpy->driverContext.MMIOSize = dpy->FixedInfo.mmio_len;
+ dpy->driverContext.MMIOAddress = (caddr_t) mmap(0, /* start */
+ dpy->driverContext.MMIOSize, /* bytes */
+ PROT_READ | PROT_WRITE, /* prot */
+ MAP_SHARED, /* flags */
+ dpy->FrameBufferFD, /* fd */
+ dpy->FixedInfo.smem_len /* offset */);
+ if (dpy->driverContext.MMIOAddress == (caddr_t) - 1) {
+ fprintf(stderr, "error: unable to mmap mmio region: %s\n",
+ strerror(errno));
+ return GL_FALSE;
+ }
+
+ fprintf(stderr, "got MMIOAddress %p offset %d\n",
+ dpy->driverContext.MMIOAddress,
+ dpy->FixedInfo.smem_len);
+
+ return GL_TRUE;
+}
+
+
+
+
+/**
+ * \brief Setup up the desired framebuffer device mode.
+ *
+ * \param dpy the display handle.
+ *
+ * \return GL_TRUE on success, or GL_FALSE on failure.
+ *
+ * \sa This is called during __miniglx_StartServer().
+ *
+ * \internal
+ *
+ * Bumps the size of the window the the next supported mode. Sets the
+ * variable screen information according to the desired mode and asks
+ * the driver to validate the mode. Certifies that a DirectColor or
+ * TrueColor visual is used from the updated fixed screen information.
+ * In the case of DirectColor visuals, sets up an 'identity' colormap to
+ * mimic a TrueColor visual.
+ *
+ * Calls the driver hooks 'ValidateMode' and 'PostValidateMode' to
+ * allow the driver to make modifications to the chosen mode according
+ * to hardware constraints, or to save and restore videocard registers
+ * that may be clobbered by the fbdev driver.
+ *
+ * \todo Timings are hard-coded in the source for a set of supported modes.
+ */
+static GLboolean
+SetupFBDev( Display *dpy )
+{
+ int width, height;
+
+ assert(dpy);
+
+ width = dpy->driverContext.shared.virtualWidth;
+ height = dpy->driverContext.shared.virtualHeight;
+
+ if (width==832)
+ width=800;
+ /* Bump size up to next supported mode.
+ */
+ if (width <= 720 && height <= 480) {
+ width = 720; height = 480;
+ }
+ else if (width <= 960 && height <= 540) {
+ width = 960; height = 540;
+ }
+ else if (width <= 800 && height <= 600) {
+ width = 800; height = 600;
+ }
+ else if (width <= 1024 && height <= 768) {
+ width = 1024; height = 768;
+ }
+ else if (width <= 768 && height <= 1024) {
+ width = 768; height = 1024;
+ }
+ else if (width <= 1280 && height <= 1024) {
+ width = 1280; height = 1024;
+ }
+
+
+ dpy->driverContext.shared.fbStride = width * (dpy->driverContext.bpp / 8);
+
+ /* set the depth, resolution, etc */
+ dpy->VarInfo = dpy->OrigVarInfo;
+ dpy->VarInfo.bits_per_pixel = dpy->driverContext.bpp;
+ dpy->VarInfo.xres_virtual = dpy->driverContext.shared.virtualWidth;
+ dpy->VarInfo.yres_virtual = dpy->driverContext.shared.virtualHeight;
+ dpy->VarInfo.xres = width;
+ dpy->VarInfo.yres = height;
+ dpy->VarInfo.xoffset = 0;
+ dpy->VarInfo.yoffset = 0;
+ dpy->VarInfo.nonstd = 0;
+ dpy->VarInfo.vmode &= ~FB_VMODE_YWRAP; /* turn off scrolling */
+
+ if (dpy->VarInfo.bits_per_pixel == 32) {
+ dpy->VarInfo.red.offset = 16;
+ dpy->VarInfo.green.offset = 8;
+ dpy->VarInfo.blue.offset = 0;
+ dpy->VarInfo.transp.offset = 24;
+ dpy->VarInfo.red.length = 8;
+ dpy->VarInfo.green.length = 8;
+ dpy->VarInfo.blue.length = 8;
+ dpy->VarInfo.transp.length = 8;
+ }
+ else if (dpy->VarInfo.bits_per_pixel == 16) {
+ dpy->VarInfo.red.offset = 11;
+ dpy->VarInfo.green.offset = 5;
+ dpy->VarInfo.blue.offset = 0;
+ dpy->VarInfo.red.length = 5;
+ dpy->VarInfo.green.length = 6;
+ dpy->VarInfo.blue.length = 5;
+ dpy->VarInfo.transp.offset = 0;
+ dpy->VarInfo.transp.length = 0;
+ }
+ else {
+ fprintf(stderr, "Only 32bpp and 16bpp modes supported at the moment\n");
+ return 0;
+ }
+
+ if (!dpy->driver->validateMode( &dpy->driverContext )) {
+ fprintf(stderr, "Driver validateMode() failed\n");
+ return 0;
+ }
+
+ /* These should be calculated with the gtf.c program, and then we could
+ remove all this... AlanH. */
+ if (dpy->VarInfo.xres == 1280 &&
+ dpy->VarInfo.yres == 1024) {
+ /* timing values taken from /etc/fb.modes (1280x1024 @ 75Hz) */
+ dpy->VarInfo.pixclock = 7408;
+ dpy->VarInfo.left_margin = 248;
+ dpy->VarInfo.right_margin = 16;
+ dpy->VarInfo.upper_margin = 38;
+ dpy->VarInfo.lower_margin = 1;
+ dpy->VarInfo.hsync_len = 144;
+ dpy->VarInfo.vsync_len = 3;
+ }
+ else if (dpy->VarInfo.xres == 1024 &&
+ dpy->VarInfo.yres == 768) {
+ /* timing values taken from /etc/fb.modes (1024x768 @ 75Hz) */
+ dpy->VarInfo.pixclock = 12699;
+ dpy->VarInfo.left_margin = 176;
+ dpy->VarInfo.right_margin = 16;
+ dpy->VarInfo.upper_margin = 28;
+ dpy->VarInfo.lower_margin = 1;
+ dpy->VarInfo.hsync_len = 96;
+ dpy->VarInfo.vsync_len = 3;
+ }
+ else if (dpy->VarInfo.xres == 800 &&
+ dpy->VarInfo.yres == 600) {
+ /* timing values taken from /etc/fb.modes (800x600 @ 75Hz) */
+ dpy->VarInfo.pixclock = 27778;
+ dpy->VarInfo.left_margin = 128;
+ dpy->VarInfo.right_margin = 24;
+ dpy->VarInfo.upper_margin = 22;
+ dpy->VarInfo.lower_margin = 1;
+ dpy->VarInfo.hsync_len = 72;
+ dpy->VarInfo.vsync_len = 2;
+ }
+ else if (dpy->VarInfo.xres == 720 &&
+ dpy->VarInfo.yres == 480) {
+ dpy->VarInfo.pixclock = 37202;
+ dpy->VarInfo.left_margin = 88;
+ dpy->VarInfo.right_margin = 16;
+ dpy->VarInfo.upper_margin = 14;
+ dpy->VarInfo.lower_margin = 1;
+ dpy->VarInfo.hsync_len = 72;
+ dpy->VarInfo.vsync_len = 3;
+ }
+ else if (dpy->VarInfo.xres == 960 &&
+ dpy->VarInfo.yres == 540) {
+ dpy->VarInfo.pixclock = 24273;
+ dpy->VarInfo.left_margin = 128;
+ dpy->VarInfo.right_margin = 32;
+ dpy->VarInfo.upper_margin = 16;
+ dpy->VarInfo.lower_margin = 1;
+ dpy->VarInfo.hsync_len = 96;
+ dpy->VarInfo.vsync_len = 3;
+ }
+ else if (dpy->VarInfo.xres == 768 &&
+ dpy->VarInfo.yres == 1024) {
+ /* timing values for 768x1024 @ 75Hz */
+ dpy->VarInfo.pixclock = 11993;
+ dpy->VarInfo.left_margin = 136;
+ dpy->VarInfo.right_margin = 32;
+ dpy->VarInfo.upper_margin = 41;
+ dpy->VarInfo.lower_margin = 1;
+ dpy->VarInfo.hsync_len = 80;
+ dpy->VarInfo.vsync_len = 3;
+ }
+ else {
+ /* XXX need timings for other screen sizes */
+ fprintf(stderr, "XXXX screen size %d x %d not supported at this time!\n",
+ dpy->VarInfo.xres, dpy->VarInfo.yres);
+ return GL_FALSE;
+ }
+
+ fprintf(stderr, "[miniglx] Setting mode: visible %dx%d virtual %dx%dx%d\n",
+ dpy->VarInfo.xres, dpy->VarInfo.yres,
+ dpy->VarInfo.xres_virtual, dpy->VarInfo.yres_virtual,
+ dpy->VarInfo.bits_per_pixel);
+
+ /* set variable screen info */
+ if (ioctl(dpy->FrameBufferFD, FBIOPUT_VSCREENINFO, &dpy->VarInfo)) {
+ fprintf(stderr, "error: ioctl(FBIOPUT_VSCREENINFO) failed: %s\n",
+ strerror(errno));
+ return GL_FALSE;
+ }
+
+ /* get the variable screen info, in case it has been modified */
+ if (ioctl(dpy->FrameBufferFD, FBIOGET_VSCREENINFO, &dpy->VarInfo)) {
+ fprintf(stderr, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n",
+ strerror(errno));
+ return GL_FALSE;
+ }
+
+
+ fprintf(stderr, "[miniglx] Readback mode: visible %dx%d virtual %dx%dx%d\n",
+ dpy->VarInfo.xres, dpy->VarInfo.yres,
+ dpy->VarInfo.xres_virtual, dpy->VarInfo.yres_virtual,
+ dpy->VarInfo.bits_per_pixel);
+
+ /* Get the fixed screen info */
+ if (ioctl(dpy->FrameBufferFD, FBIOGET_FSCREENINFO, &dpy->FixedInfo)) {
+ fprintf(stderr, "error: ioctl(FBIOGET_FSCREENINFO) failed: %s\n",
+ strerror(errno));
+ return GL_FALSE;
+ }
+
+ if (dpy->FixedInfo.visual != FB_VISUAL_TRUECOLOR &&
+ dpy->FixedInfo.visual != FB_VISUAL_DIRECTCOLOR) {
+ fprintf(stderr, "non-TRUECOLOR visuals not supported.\n");
+ return GL_FALSE;
+ }
+
+ if (dpy->FixedInfo.visual == FB_VISUAL_DIRECTCOLOR) {
+ struct fb_cmap cmap;
+ unsigned short red[256], green[256], blue[256];
+ int rcols = 1 << dpy->VarInfo.red.length;
+ int gcols = 1 << dpy->VarInfo.green.length;
+ int bcols = 1 << dpy->VarInfo.blue.length;
+ int i;
+
+ cmap.start = 0;
+ cmap.len = gcols;
+ cmap.red = red;
+ cmap.green = green;
+ cmap.blue = blue;
+ cmap.transp = NULL;
+
+ for (i = 0; i < rcols ; i++)
+ red[i] = (65536/(rcols-1)) * i;
+
+ for (i = 0; i < gcols ; i++)
+ green[i] = (65536/(gcols-1)) * i;
+
+ for (i = 0; i < bcols ; i++)
+ blue[i] = (65536/(bcols-1)) * i;
+
+ if (ioctl(dpy->FrameBufferFD, FBIOPUTCMAP, (void *) &cmap) < 0) {
+ fprintf(stderr, "ioctl(FBIOPUTCMAP) failed [%d]\n", i);
+ exit(1);
+ }
+ }
+
+ /* May need to restore regs fbdev has clobbered:
+ */
+ if (!dpy->driver->postValidateMode( &dpy->driverContext )) {
+ fprintf(stderr, "Driver postValidateMode() failed\n");
+ return 0;
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * \brief Restore the framebuffer device to state it was in before we started
+ *
+ * Undoes the work done by SetupFBDev().
+ *
+ * \param dpy the display handle.
+ *
+ * \return GL_TRUE on success, or GL_FALSE on failure.
+ *
+ * \sa Called from XDestroyWindow().
+ *
+ * \internal
+ * Restores the original variable screen info.
+ */
+static GLboolean
+RestoreFBDev( Display *dpy )
+{
+ /* restore original variable screen info */
+ if (ioctl(dpy->FrameBufferFD, FBIOPUT_VSCREENINFO, &dpy->OrigVarInfo)) {
+ fprintf(stderr, "ioctl(FBIOPUT_VSCREENINFO failed): %s\n",
+ strerror(errno));
+ return GL_FALSE;
+ }
+ dpy->VarInfo = dpy->OrigVarInfo;
+
+ return GL_TRUE;
+}
+
+
+/**
+ * \brief Close the framebuffer device.
+ *
+ * \param dpy the display handle.
+ *
+ * \sa Called from XCloseDisplay().
+ *
+ * \internal
+ * Unmaps the framebuffer and MMIO region. Restores the text mode and the
+ * original virtual terminal. Closes the console and framebuffer devices.
+ */
+static void
+CloseFBDev( Display *dpy )
+{
+ struct vt_mode VT;
+
+ munmap(dpy->driverContext.FBAddress, dpy->driverContext.FBSize);
+ munmap(dpy->driverContext.MMIOAddress, dpy->driverContext.MMIOSize);
+
+ if (dpy->ConsoleFD) {
+ /* restore text mode */
+ ioctl(dpy->ConsoleFD, KDSETMODE, KD_TEXT);
+
+ /* set vt */
+ if (ioctl(dpy->ConsoleFD, VT_GETMODE, &VT) != -1) {
+ VT.mode = VT_AUTO;
+ ioctl(dpy->ConsoleFD, VT_SETMODE, &VT);
+ }
+
+ /* restore original vt */
+ if (dpy->OriginalVT >= 0) {
+ ioctl(dpy->ConsoleFD, VT_ACTIVATE, dpy->OriginalVT);
+ dpy->OriginalVT = -1;
+ }
+
+ close(dpy->ConsoleFD);
+ }
+ close(dpy->FrameBufferFD);
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Misc functions needed for DRI drivers */
+/**********************************************************************/
+/*@{*/
+
+/**
+ * \brief Find the DRI screen dependent methods associated with the display.
+ *
+ * \param dpy a display handle, as returned by XOpenDisplay().
+ * \param scrn the screen number. Not referenced.
+ *
+ * \returns a pointer to a __DRIscreenRec structure.
+ *
+ * \internal
+ * Returns the MiniGLXDisplayRec::driScreen attribute.
+ */
+static __DRIscreen *
+__glXFindDRIScreen(__DRInativeDisplay *dpy, int scrn)
+{
+ (void) scrn;
+ return &((Display*)dpy)->driScreen;
+}
+
+/**
+ * \brief Validate a drawable.
+ *
+ * \param dpy a display handle, as returned by XOpenDisplay().
+ * \param draw drawable to validate.
+ *
+ * \internal
+ * Since Mini GLX only supports one window, compares the specified drawable with
+ * the MiniGLXDisplayRec::TheWindow attribute.
+ */
+static GLboolean
+__glXWindowExists(__DRInativeDisplay *dpy, __DRIid draw)
+{
+ const Display * const display = (Display*)dpy;
+ if (display->TheWindow == (Window) draw)
+ return True;
+ else
+ return False;
+}
+
+/**
+ * \brief Get current thread ID.
+ *
+ * \return thread ID.
+ *
+ * \internal
+ * Always returns 0.
+ */
+/*unsigned long
+_glthread_GetID(void)
+{
+ return 0;
+}*/
+
+/*@}*/
+
+
+/**
+ * \brief Scan Linux /prog/bus/pci/devices file to determine hardware
+ * chipset based on supplied bus ID.
+ *
+ * \return probed chipset (non-zero) on success, zero otherwise.
+ *
+ * \internal
+ */
+static int get_chipset_from_busid( Display *dpy )
+{
+ char buf[0x200];
+ FILE *file;
+ const char *fname = "/proc/bus/pci/devices";
+ int retval = 0;
+
+ if (!(file = fopen(fname,"r"))) {
+ fprintf(stderr, "couldn't open %s: %s\n", fname, strerror(errno));
+ return 0;
+ }
+
+ while (fgets(buf, sizeof(buf)-1, file)) {
+ unsigned int nr, bus, dev, fn, vendor, device, encode;
+ nr = sscanf(buf, "%04x\t%04x%04x", &encode,
+ &vendor, &device);
+
+ bus = encode >> 8;
+ dev = (encode & 0xFF) >> 3;
+ fn = encode & 0x7;
+
+ if (nr != 3)
+ break;
+
+ if (bus == dpy->driverContext.pciBus &&
+ dev == dpy->driverContext.pciDevice &&
+ fn == dpy->driverContext.pciFunc) {
+ retval = device;
+ break;
+ }
+ }
+
+ fclose(file);
+
+ if (retval)
+ fprintf(stderr, "[miniglx] probed chipset 0x%x\n", retval);
+ else
+ fprintf(stderr, "[miniglx] failed to probe chipset\n");
+
+ return retval;
+}
+
+
+/**
+ * \brief Read settings from a configuration file.
+ *
+ * The configuration file is usually "/etc/miniglx.conf", but can be overridden
+ * with the MINIGLX_CONF environment variable.
+ *
+ * The format consists in \code option = value \endcode lines. The option names
+ * corresponds to the fields in MiniGLXDisplayRec.
+ *
+ * \param dpy the display handle as.
+ *
+ * \return non-zero on success, zero otherwise.
+ *
+ * \internal
+ * Sets some defaults. Opens and parses the the Mini GLX configuration file and
+ * fills in the MiniGLXDisplayRec field that corresponds for each option.
+ */
+static int __read_config_file( Display *dpy )
+{
+ FILE *file;
+ const char *fname;
+
+ /* Fallback/defaults
+ */
+ dpy->fbdevDevice = "/dev/fb0";
+ dpy->clientDriverName = "fb_dri.so";
+ dpy->driverContext.pciBus = 0;
+ dpy->driverContext.pciDevice = 0;
+ dpy->driverContext.pciFunc = 0;
+ dpy->driverContext.chipset = 0;
+ dpy->driverContext.pciBusID = 0;
+ dpy->driverContext.shared.virtualWidth = 1280;
+ dpy->driverContext.shared.virtualHeight = 1024;
+ dpy->driverContext.bpp = 32;
+ dpy->driverContext.cpp = 4;
+ dpy->rotateMode = 0;
+ dpy->driverContext.agpmode = 1;
+ dpy->driverContext.isPCI = 0;
+ dpy->driverContext.colorTiling = 0;
+
+ fname = getenv("MINIGLX_CONF");
+ if (!fname) fname = "/etc/miniglx.conf";
+
+ file = fopen(fname, "r");
+ if (!file) {
+ fprintf(stderr, "couldn't open config file %s: %s\n", fname, strerror(errno));
+ return 0;
+ }
+
+
+ while (!feof(file)) {
+ char buf[81], *opt = buf, *val, *tmp1, *tmp2;
+ fgets(buf, sizeof(buf), file);
+
+ /* Parse 'opt = val' -- must be easier ways to do this.
+ */
+ while (isspace(*opt)) opt++;
+ val = opt;
+ if (*val == '#') continue; /* comment */
+ while (!isspace(*val) && *val != '=' && *val) val++;
+ tmp1 = val;
+ while (isspace(*val)) val++;
+ if (*val != '=') continue;
+ *tmp1 = 0;
+ val++;
+ while (isspace(*val)) val++;
+ tmp2 = val;
+ while (!isspace(*tmp2) && *tmp2 != '\n' && *tmp2) tmp2++;
+ *tmp2 = 0;
+
+
+ if (strcmp(opt, "fbdevDevice") == 0)
+ dpy->fbdevDevice = strdup(val);
+ else if (strcmp(opt, "clientDriverName") == 0)
+ dpy->clientDriverName = strdup(val);
+ else if (strcmp(opt, "rotateMode") == 0)
+ dpy->rotateMode = atoi(val) ? 1 : 0;
+ else if (strcmp(opt, "pciBusID") == 0) {
+ if (sscanf(val, "PCI:%d:%d:%d",
+ &dpy->driverContext.pciBus,
+ &dpy->driverContext.pciDevice,
+ &dpy->driverContext.pciFunc) != 3) {
+ fprintf(stderr, "malformed bus id: %s\n", val);
+ continue;
+ }
+ dpy->driverContext.pciBusID = strdup(val);
+ }
+ else if (strcmp(opt, "chipset") == 0) {
+ if (sscanf(val, "0x%x", &dpy->driverContext.chipset) != 1)
+ fprintf(stderr, "malformed chipset: %s\n", opt);
+ }
+ else if (strcmp(opt, "virtualWidth") == 0) {
+ if (sscanf(val, "%d", &dpy->driverContext.shared.virtualWidth) != 1)
+ fprintf(stderr, "malformed virtualWidth: %s\n", opt);
+ }
+ else if (strcmp(opt, "virtualHeight") == 0) {
+ if (sscanf(val, "%d", &dpy->driverContext.shared.virtualHeight) != 1)
+ fprintf(stderr, "malformed virutalHeight: %s\n", opt);
+ }
+ else if (strcmp(opt, "bpp") == 0) {
+ if (sscanf(val, "%d", &dpy->driverContext.bpp) != 1)
+ fprintf(stderr, "malformed bpp: %s\n", opt);
+ dpy->driverContext.cpp = dpy->driverContext.bpp / 8;
+ }
+ else if (strcmp(opt, "agpmode") == 0) {
+ if (sscanf(val, "%d", &dpy->driverContext.agpmode) != 1)
+ fprintf(stderr, "malformed agpmode: %s\n", opt);
+ }
+ else if (strcmp(opt, "isPCI") == 0) {
+ dpy->driverContext.isPCI = atoi(val) ? 1 : 0;
+ }
+ else if (strcmp(opt, "colorTiling") == 0) {
+ dpy->driverContext.colorTiling = atoi(val) ? 1 : 0;
+ }
+ }
+
+ fclose(file);
+
+ if (dpy->driverContext.chipset == 0 && dpy->driverContext.pciBusID != 0)
+ dpy->driverContext.chipset = get_chipset_from_busid( dpy );
+
+ return 1;
+}
+
+/**
+ * Versioned name of the expected \c __driCreateNewScreen function.
+ *
+ * The version of the last incompatible loader/driver inteface change is
+ * appended to the name of the \c __driCreateNewScreen function. This
+ * prevents loaders from trying to load drivers that are too old.
+ *
+ * \todo
+ * Create a macro or something so that this is automatically updated.
+ */
+static const char createNewScreenName[] = "__driCreateNewScreen_20050727";
+
+
+static int InitDriver( Display *dpy )
+{
+ /*
+ * Begin DRI setup.
+ * We're kind of combining the per-display and per-screen information
+ * which was kept separate in XFree86/DRI's libGL.
+ */
+ dpy->dlHandle = dlopen(dpy->clientDriverName, RTLD_NOW | RTLD_GLOBAL);
+ if (!dpy->dlHandle) {
+ fprintf(stderr, "Unable to open %s: %s\n", dpy->clientDriverName,
+ dlerror());
+ goto failed;
+ }
+
+ /* Pull in Mini GLX specific hooks:
+ */
+ dpy->driver = (struct DRIDriverRec *) dlsym(dpy->dlHandle,
+ "__driDriver");
+ if (!dpy->driver) {
+ fprintf(stderr, "Couldn't find __driDriver in %s\n",
+ dpy->clientDriverName);
+ goto failed;
+ }
+
+ /* Pull in standard DRI client-side driver hooks:
+ */
+ dpy->createNewScreen = (PFNCREATENEWSCREENFUNC)
+ dlsym(dpy->dlHandle, createNewScreenName);
+ if (!dpy->createNewScreen) {
+ fprintf(stderr, "Couldn't find %s in %s\n", createNewScreenName,
+ dpy->clientDriverName);
+ goto failed;
+ }
+
+ return GL_TRUE;
+
+failed:
+ if (dpy->dlHandle) {
+ dlclose(dpy->dlHandle);
+ dpy->dlHandle = 0;
+ }
+ return GL_FALSE;
+}
+
+
+/**********************************************************************/
+/** \name Public API functions (Xlib and GLX) */
+/**********************************************************************/
+/*@{*/
+
+
+/**
+ * \brief Initialize the graphics system.
+ *
+ * \param display_name currently ignored. It is recommended to pass it as NULL.
+ * \return a pointer to a #Display if the function is able to initialize
+ * the graphics system, NULL otherwise.
+ *
+ * Allocates a MiniGLXDisplayRec structure and fills in with information from a
+ * configuration file.
+ *
+ * Calls OpenFBDev() to open the framebuffer device and calls
+ * DRIDriverRec::initFBDev to do the client-side initialization on it.
+ *
+ * Loads the DRI driver and pulls in Mini GLX specific hooks into a
+ * DRIDriverRec structure, and the standard DRI \e __driCreateScreen hook.
+ * Asks the driver for a list of supported visuals. Performs the per-screen
+ * client-side initialization. Also setups the callbacks in the screen private
+ * information.
+ *
+ * Does the framebuffer device setup. Calls __miniglx_open_connections() to
+ * serve clients.
+ */
+Display *
+__miniglx_StartServer( const char *display_name )
+{
+ Display *dpy;
+ int use_vt = 0;
+
+ dpy = (Display *)calloc(1, sizeof(Display));
+ if (!dpy)
+ return NULL;
+
+ dpy->IsClient = False;
+
+ if (!__read_config_file( dpy )) {
+ fprintf(stderr, "Couldn't get configuration details\n");
+ free(dpy);
+ return NULL;
+ }
+
+ /* Open the fbdev device
+ */
+ if (!OpenFBDev(dpy, use_vt)) {
+ fprintf(stderr, "OpenFBDev failed\n");
+ free(dpy);
+ return NULL;
+ }
+
+ if (!InitDriver(dpy)) {
+ fprintf(stderr, "InitDriver failed\n");
+ free(dpy);
+ return NULL;
+ }
+
+ /* Perform the initialization normally done in the X server
+ */
+ if (!dpy->driver->initFBDev( &dpy->driverContext )) {
+ fprintf(stderr, "%s: __driInitFBDev failed\n", __FUNCTION__);
+ dlclose(dpy->dlHandle);
+ return GL_FALSE;
+ }
+
+ /* do fbdev setup
+ */
+ if (!SetupFBDev(dpy)) {
+ fprintf(stderr, "SetupFBDev failed\n");
+ free(dpy);
+ return NULL;
+ }
+
+ /* unlock here if not using VT -- JDS */
+ if (!use_vt) {
+ if (dpy->driver->restoreHardware)
+ dpy->driver->restoreHardware( &dpy->driverContext );
+ DRM_UNLOCK( dpy->driverContext.drmFD,
+ dpy->driverContext.pSAREA,
+ dpy->driverContext.serverContext );
+ dpy->hwActive = 1;
+ }
+
+ /* Ready for clients:
+ */
+ if (!__miniglx_open_connections(dpy)) {
+ free(dpy);
+ return NULL;
+ }
+
+ return dpy;
+}
+
+
+/**
+ * Implement \c __DRIinterfaceMethods::getProcAddress.
+ */
+static __DRIfuncPtr get_proc_address( const char * proc_name )
+{
+ (void) proc_name;
+ return NULL;
+}
+
+
+/**
+ * Table of functions exported by the loader to the driver.
+ */
+static const __DRIinterfaceMethods interface_methods = {
+ get_proc_address,
+
+ _gl_context_modes_create,
+ _gl_context_modes_destroy,
+
+ __glXFindDRIScreen,
+ __glXWindowExists,
+
+ __glXCreateContextWithConfig,
+ xf86DRI_DestroyContext,
+
+ xf86DRI_CreateDrawable,
+ xf86DRI_DestroyDrawable,
+ __glXGetDrawableInfo,
+
+ __glXGetUST,
+ __glXGetMscRate,
+};
+
+
+static void *
+CallCreateNewScreen(Display *dpy, int scrn, __DRIscreen *psc)
+{
+ void *psp = NULL;
+ drm_handle_t hSAREA;
+ drmAddress pSAREA;
+ const char *BusID;
+ int i;
+ __DRIversion ddx_version;
+ __DRIversion dri_version;
+ __DRIversion drm_version;
+ __DRIframebuffer framebuffer;
+ int fd = -1;
+ int status;
+ const char * err_msg;
+ const char * err_extra;
+ drmVersionPtr version;
+ drm_handle_t hFB;
+ drm_magic_t magic;
+
+
+ hSAREA = dpy->driverContext.shared.hSAREA;
+ BusID = dpy->driverContext.pciBusID;
+
+ fd = drmOpen(NULL, BusID);
+
+ err_msg = "open DRM";
+ err_extra = strerror( -fd );
+
+ if (fd < 0) goto done;
+
+ err_msg = "drmGetMagic";
+ err_extra = NULL;
+
+ if (drmGetMagic(fd, &magic)) goto done;
+
+ dpy->authorized = False;
+ send_char_msg( dpy, 0, _Authorize );
+ send_msg( dpy, 0, &magic, sizeof(magic));
+
+ /* force net buffer flush */
+ while (!dpy->authorized)
+ handle_fd_events( dpy, 0 );
+
+ version = drmGetVersion(fd);
+ if (version) {
+ drm_version.major = version->version_major;
+ drm_version.minor = version->version_minor;
+ drm_version.patch = version->version_patchlevel;
+ drmFreeVersion(version);
+ }
+ else {
+ drm_version.major = -1;
+ drm_version.minor = -1;
+ drm_version.patch = -1;
+ }
+
+ /*
+ * Get device name (like "tdfx") and the ddx version numbers.
+ * We'll check the version in each DRI driver's "createScreen"
+ * function.
+ */
+ ddx_version.major = 4;
+ ddx_version.minor = 0;
+ ddx_version.patch = 0;
+
+ /*
+ * Get the DRI X extension version.
+ */
+ dri_version.major = 4;
+ dri_version.minor = 0;
+ dri_version.patch = 0;
+
+ /*
+ * Get device-specific info. pDevPriv will point to a struct
+ * (such as DRIRADEONRec in xfree86/driver/ati/radeon_dri.h)
+ * that has information about the screen size, depth, pitch,
+ * ancilliary buffers, DRM mmap handles, etc.
+ */
+ hFB = dpy->driverContext.shared.hFrameBuffer;
+ framebuffer.size = dpy->driverContext.shared.fbSize;
+ framebuffer.stride = dpy->driverContext.shared.fbStride;
+ framebuffer.dev_priv_size = dpy->driverContext.driverClientMsgSize;
+ framebuffer.dev_priv = dpy->driverContext.driverClientMsg;
+ framebuffer.width = dpy->driverContext.shared.virtualWidth;
+ framebuffer.height = dpy->driverContext.shared.virtualHeight;
+
+ /*
+ * Map the framebuffer region.
+ */
+ status = drmMap(fd, hFB, framebuffer.size,
+ (drmAddressPtr)&framebuffer.base);
+
+ err_msg = "drmMap of framebuffer";
+ err_extra = strerror( -status );
+
+ if ( status != 0 ) goto done;
+
+ /*
+ * Map the SAREA region. Further mmap regions may be setup in
+ * each DRI driver's "createScreen" function.
+ */
+ status = drmMap(fd, hSAREA, SAREA_MAX, &pSAREA);
+
+ err_msg = "drmMap of sarea";
+ err_extra = strerror( -status );
+
+ if ( status == 0 ) {
+ err_msg = "InitDriver";
+ err_extra = NULL;
+ psp = dpy->createNewScreen(dpy, scrn, psc, NULL,
+ & ddx_version,
+ & dri_version,
+ & drm_version,
+ & framebuffer,
+ pSAREA,
+ fd,
+ 20050727,
+ & interface_methods,
+ (__GLcontextModes **) &dpy->driver_modes);
+
+ /* fill in dummy visual ids */
+ {
+ __GLcontextModes *temp;
+ temp = (__GLcontextModes *)dpy->driver_modes;
+ i = 1;
+ while (temp)
+ {
+ temp->visualID = i++;
+ temp=temp->next;
+ }
+ }
+ }
+
+done:
+ if ( psp == NULL ) {
+ if ( pSAREA != MAP_FAILED ) {
+ (void)drmUnmap(pSAREA, SAREA_MAX);
+ }
+
+ if ( framebuffer.base != MAP_FAILED ) {
+ (void)drmUnmap((drmAddress)framebuffer.base, framebuffer.size);
+ }
+
+ if ( framebuffer.dev_priv != NULL ) {
+ free(framebuffer.dev_priv);
+ }
+
+ if ( fd >= 0 ) {
+ (void)drmClose(fd);
+ }
+
+ if ( err_extra != NULL ) {
+ fprintf(stderr, "libGL error: %s failed (%s)\n", err_msg,
+ err_extra);
+ }
+ else {
+ fprintf(stderr, "libGL error: %s failed\n", err_msg );
+ }
+
+ fprintf(stderr, "libGL error: reverting to (slow) indirect rendering\n");
+ }
+
+ return psp;
+}
+
+/**
+ * \brief Initialize the graphics system.
+ *
+ * \param display_name currently ignored. It is recommended to pass it as NULL.
+ * \return a pointer to a #Display if the function is able to initialize
+ * the graphics system, NULL otherwise.
+ *
+ * Allocates a MiniGLXDisplayRec structure and fills in with information from a
+ * configuration file.
+ *
+ * Calls __miniglx_open_connections() to connect to the server.
+ *
+ * Loads the DRI driver and pulls in Mini GLX specific hooks into a
+ * DRIDriverRec structure, and the standard DRI \e __driCreateScreen hook.
+ * Asks the driver for a list of supported visuals. Performs the per-screen
+ * client-side initialization. Also setups the callbacks in the screen private
+ * information.
+ *
+ * \todo
+ * - read config file
+ * - what about virtualWidth, etc?
+ * - determine dpy->driverClientMsgSize,
+ * - allocate dpy->driverClientMsg
+ */
+Display *
+XOpenDisplay( const char *display_name )
+{
+ Display *dpy;
+
+ dpy = (Display *)calloc(1, sizeof(Display));
+ if (!dpy)
+ return NULL;
+
+ dpy->IsClient = True;
+
+ /* read config file
+ */
+ if (!__read_config_file( dpy )) {
+ fprintf(stderr, "Couldn't get configuration details\n");
+ free(dpy);
+ return NULL;
+ }
+
+ /* Connect to the server and receive driverClientMsg
+ */
+ if (!__miniglx_open_connections(dpy)) {
+ free(dpy);
+ return NULL;
+ }
+
+ /* dlopen the driver .so file
+ */
+ if (!InitDriver(dpy)) {
+ fprintf(stderr, "InitDriver failed\n");
+ free(dpy);
+ return NULL;
+ }
+
+ /* Perform the client-side initialization.
+ *
+ * Clearly there is a limit of one on the number of windows in
+ * existence at any time.
+ *
+ * Need to shut down DRM and free DRI data in XDestroyWindow(), too.
+ */
+ dpy->driScreen.private = CallCreateNewScreen(dpy, 0, &dpy->driScreen);
+ if (!dpy->driScreen.private) {
+ fprintf(stderr, "%s: __driCreateScreen failed\n", __FUNCTION__);
+ dlclose(dpy->dlHandle);
+ free(dpy);
+ return NULL;
+ }
+
+ /* Anything more to do?
+ */
+ return dpy;
+}
+
+
+/**
+ * \brief Release display resources.
+ *
+ * When the application is about to exit, the resources associated with the
+ * graphics system can be released by calling this function.
+ *
+ * \param dpy display handle. It becomes invalid at this point.
+ *
+ * Destroys the window if any, and destroys the per-screen
+ * driver private information.
+ * Calls __miniglx_close_connections().
+ *
+ * If a server, puts the the framebuffer back into the initial state.
+ *
+ * Finally frees the display structure.
+ */
+void
+XCloseDisplay( Display *dpy )
+{
+ glXMakeCurrent( dpy, NULL, NULL);
+
+ if (dpy->NumWindows)
+ XDestroyWindow( dpy, dpy->TheWindow );
+
+ /* As this is done in XOpenDisplay, need to undo it here:
+ */
+ dpy->driScreen.destroyScreen(dpy, 0, dpy->driScreen.private);
+
+ __miniglx_close_connections( dpy );
+
+ if (!dpy->IsClient) {
+ /* put framebuffer back to initial state
+ */
+ (*dpy->driver->haltFBDev)( &dpy->driverContext );
+ RestoreFBDev(dpy);
+ CloseFBDev(dpy);
+ }
+
+ dlclose(dpy->dlHandle);
+ free(dpy);
+}
+
+
+/**
+ * \brief Window creation.
+ *
+ * \param display a display handle, as returned by XOpenDisplay().
+ * \param parent the parent window for the new window. For Mini GLX this should
+ * be
+ * \code RootWindow(display, 0) \endcode
+ * \param x the window abscissa. For Mini GLX, it should be zero.
+ * \param y the window ordinate. For Mini GLX, it should be zero.
+ * \param width the window width. For Mini GLX, this specifies the desired
+ * screen width such as 1024 or 1280.
+ * \param height the window height. For Mini GLX, this specifies the desired
+ * screen height such as 768 or 1024.
+ * \param border_width the border width. For Mini GLX, it should be zero.
+ * \param depth the window pixel depth. For Mini GLX, this should be the depth
+ * found in the #XVisualInfo object returned by glXChooseVisual()
+ * \param winclass the window class. For Mini GLX this value should be
+ * #InputOutput.
+ * \param visual the visual type. It should be the visual field of the
+ * #XVisualInfo object returned by glXChooseVisual().
+ * \param valuemask which fields of the XSetWindowAttributes() are to be used.
+ * For Mini GLX this is typically the bitmask
+ * \code CWBackPixel | CWBorderPixel | CWColormap \endcode
+ * \param attributes initial window attributes. The
+ * XSetWindowAttributes::background_pixel, XSetWindowAttributes::border_pixel
+ * and XSetWindowAttributes::colormap fields should be set.
+ *
+ * \return a window handle if it succeeds or zero if it fails.
+ *
+ * \note For Mini GLX, windows are full-screen; they cover the entire frame
+ * buffer. Also, Mini GLX imposes a limit of one window. A second window
+ * cannot be created until the first one is destroyed.
+ *
+ * This function creates and initializes a ::MiniGLXWindowRec structure after
+ * ensuring that there is no other window created. Performs the per-drawable
+ * client-side initialization calling the __DRIscreenRec::createDrawable
+ * method.
+ *
+ */
+Window
+XCreateWindow( Display *dpy, Window parent, int x, int y,
+ unsigned int width, unsigned int height,
+ unsigned int border_width, int depth, unsigned int winclass,
+ Visual *visual, unsigned long valuemask,
+ XSetWindowAttributes *attributes )
+{
+ const int empty_attribute_list[1] = { None };
+
+ Window win;
+
+ /* ignored */
+ (void) x;
+ (void) y;
+ (void) border_width;
+ (void) depth;
+ (void) winclass;
+ (void) valuemask;
+ (void) attributes;
+
+ if (!dpy->IsClient) {
+ fprintf(stderr, "Server process may not create windows (currently)\n");
+ return NULL;
+ }
+
+ if (dpy->NumWindows > 0)
+ return NULL; /* only allow one window */
+
+ assert(dpy->TheWindow == NULL);
+
+ win = malloc(sizeof(struct MiniGLXWindowRec));
+ if (!win)
+ return NULL;
+
+ /* In rotated mode, translate incoming x,y,width,height into
+ * 'normal' coordinates.
+ */
+ if (dpy->rotateMode) {
+ int tmp;
+ tmp = width; width = height; height = tmp;
+ tmp = x; x = y; y = tmp;
+ }
+
+ /* init other per-window fields */
+ win->x = 0;
+ win->y = 0;
+ win->w = width;
+ win->h = height;
+ win->visual = visual; /* ptr assignment */
+
+ win->bytesPerPixel = dpy->driverContext.cpp;
+ win->rowStride = dpy->driverContext.shared.virtualWidth * win->bytesPerPixel;
+ win->size = win->rowStride * height;
+ win->frontStart = dpy->driverContext.FBAddress;
+ win->frontBottom = (GLubyte *) win->frontStart + (height-1) * win->rowStride;
+
+ /* This is incorrect: the hardware driver could put the backbuffer
+ * just about anywhere. These fields, including the above are
+ * hardware dependent & don't really belong here.
+ */
+ if (visual->mode->doubleBufferMode) {
+ win->backStart = (GLubyte *) win->frontStart +
+ win->rowStride * dpy->driverContext.shared.virtualHeight;
+ win->backBottom = (GLubyte *) win->backStart
+ + (height - 1) * win->rowStride;
+ win->curBottom = win->backBottom;
+ }
+ else {
+ /* single buffered */
+ win->backStart = NULL;
+ win->backBottom = NULL;
+ win->curBottom = win->frontBottom;
+ }
+
+ dpy->driScreen.createNewDrawable(dpy, visual->mode, (int) win,
+ &win->driDrawable, GLX_WINDOW_BIT, empty_attribute_list);
+
+ if (!win->driDrawable.private) {
+ fprintf(stderr, "%s: dri.createDrawable failed\n", __FUNCTION__);
+ free(win);
+ return NULL;
+ }
+
+ dpy->NumWindows++;
+ dpy->TheWindow = win;
+
+ return win;
+}
+
+
+/**
+ * \brief Destroy window.
+ *
+ * \param display display handle.
+ * \param w window handle.
+ *
+ * This function calls XUnmapWindow() and frees window \p w.
+ *
+ * In case of destroying the current buffer first unbinds the GLX context
+ * by calling glXMakeCurrent() with no drawable.
+ */
+void
+XDestroyWindow( Display *display, Window win )
+{
+ if (display && display->IsClient && win) {
+ /* check if destroying the current buffer */
+ Window curDraw = glXGetCurrentDrawable();
+ if (win == curDraw) {
+ glXMakeCurrent( display, NULL, NULL);
+ }
+
+ XUnmapWindow( display, win );
+
+ /* Destroy the drawable. */
+ win->driDrawable.destroyDrawable(display, win->driDrawable.private);
+ free(win);
+
+ /* unlink window from display */
+ display->NumWindows--;
+ assert(display->NumWindows == 0);
+ display->TheWindow = NULL;
+ }
+}
+
+
+
+
+/**
+ * \brief Create color map structure.
+ *
+ * \param dpy the display handle as returned by XOpenDisplay().
+ * \param w the window on whose screen you want to create a color map. This
+ * parameter is ignored by Mini GLX but should be the value returned by the
+ * \code RootWindow(display, 0) \endcode macro.
+ * \param visual a visual type supported on the screen. This parameter is
+ * ignored by Mini GLX but should be the XVisualInfo::visual returned by
+ * glXChooseVisual().
+ * \param alloc the color map entries to be allocated. This parameter is ignored
+ * by Mini GLX but should be set to #AllocNone.
+ *
+ * \return the color map.
+ *
+ * This function is only provided to ease porting. Practically a no-op -
+ * returns a pointer to a dynamically allocated chunk of memory (one byte).
+ */
+Colormap
+XCreateColormap( Display *dpy, Window w, Visual *visual, int alloc )
+{
+ (void) dpy;
+ (void) w;
+ (void) visual;
+ (void) alloc;
+ return (Colormap) malloc(1);
+}
+
+
+/**
+ * \brief Destroy color map structure.
+ *
+ * \param display The display handle as returned by XOpenDisplay().
+ * \param colormap the color map to destroy.
+ *
+ * This function is only provided to ease porting. Practically a no-op.
+ *
+ * Frees the memory pointed by \p colormap.
+ */
+void
+XFreeColormap( Display *display, Colormap colormap )
+{
+ (void) display;
+ (void) colormap;
+ free(colormap);
+}
+
+
+/**
+ * \brief Free client data.
+ *
+ * \param data the data that is to be freed.
+ *
+ * Frees the memory pointed by \p data.
+ */
+void
+XFree( void *data )
+{
+ free(data);
+}
+
+
+/**
+ * \brief Query available visuals.
+ *
+ * \param dpy the display handle, as returned by XOpenDisplay().
+ * \param vinfo_mask a bitmask indicating which fields of the \p vinfo_template
+ * are to be matched. The value must be \c VisualScreenMask.
+ * \param vinfo_template a template whose fields indicate which visual
+ * attributes must be matched by the results. The XVisualInfo::screen field of
+ * this structure must be zero.
+ * \param nitens_return will hold the number of visuals returned.
+ *
+ * \return the address of an array of all available visuals.
+ *
+ * An example of using XGetVisualInfo() to get all available visuals follows:
+ *
+ * \code
+ * XVisualInfo vinfo_template, *results;
+ * int nitens_return;
+ * Display *dpy = XOpenDisplay(NULL);
+ * vinfo_template.screen = 0;
+ * results = XGetVisualInfo(dpy, VisualScreenMask, &vinfo_template, &nitens_return);
+ * \endcode
+ *
+ * Returns the list of all ::XVisualInfo available, one per
+ * ::__GLcontextMode stored in MiniGLXDisplayRec::modes.
+ */
+XVisualInfo *
+XGetVisualInfo( Display *dpy, long vinfo_mask, XVisualInfo *vinfo_template, int *nitens_return )
+{
+ const __GLcontextModes *mode;
+ XVisualInfo *results;
+ Visual *visResults;
+ int i, n=0;
+
+ // ASSERT(vinfo_mask == VisualScreenMask);
+ ASSERT(vinfo_template.screen == 0);
+
+ if (vinfo_mask == VisualIDMask)
+ {
+ for ( mode = dpy->driver_modes ; mode != NULL ; mode= mode->next )
+ if (mode->visualID == vinfo_template->visualid)
+ n=1;
+
+ if (n==0)
+ return NULL;
+
+ results = (XVisualInfo *)calloc(1, n * sizeof(XVisualInfo));
+ if (!results) {
+ *nitens_return = 0;
+ return NULL;
+ }
+
+ visResults = (Visual *)calloc(1, n * sizeof(Visual));
+ if (!results) {
+ free(results);
+ *nitens_return = 0;
+ return NULL;
+ }
+
+ for ( mode = dpy->driver_modes ; mode != NULL ; mode= mode->next )
+ if (mode->visualID == vinfo_template->visualid)
+ {
+ visResults[0].mode=mode;
+ visResults[0].visInfo = results;
+ visResults[0].dpy = dpy;
+ if (dpy->driverContext.bpp == 32)
+ visResults[0].pixelFormat = PF_B8G8R8A8; /* XXX: FIX ME */
+ else
+ visResults[0].pixelFormat = PF_B5G6R5; /* XXX: FIX ME */
+
+ results[0].visual = visResults;
+ results[0].visualid = mode->visualID;
+#if defined(__cplusplus) || defined(c_plusplus)
+ results[0].c_class = TrueColor;
+#else
+ results[0].class = TrueColor;
+#endif
+ results[0].depth = mode->redBits +
+ mode->redBits +
+ mode->redBits +
+ mode->redBits;
+ results[0].bits_per_rgb = dpy->driverContext.bpp;
+
+ }
+
+ }
+ else // if (vinfo_mask == VisualScreenMask)
+ {
+ n = 0;
+ for ( mode = dpy->driver_modes ; mode != NULL ; mode = mode->next )
+ n++;
+
+ results = (XVisualInfo *)calloc(1, n * sizeof(XVisualInfo));
+ if (!results) {
+ *nitens_return = 0;
+ return NULL;
+ }
+
+ visResults = (Visual *)calloc(1, n * sizeof(Visual));
+ if (!results) {
+ free(results);
+ *nitens_return = 0;
+ return NULL;
+ }
+
+ for ( mode = dpy->driver_modes, i = 0 ; mode != NULL ; mode = mode->next, i++ ) {
+ visResults[i].mode = mode;
+ visResults[i].visInfo = results + i;
+ visResults[i].dpy = dpy;
+
+ if (dpy->driverContext.bpp == 32)
+ visResults[i].pixelFormat = PF_B8G8R8A8; /* XXX: FIX ME */
+ else
+ visResults[i].pixelFormat = PF_B5G6R5; /* XXX: FIX ME */
+
+ results[i].visual = visResults + i;
+ results[i].visualid = mode->visualID;
+#if defined(__cplusplus) || defined(c_plusplus)
+ results[i].c_class = TrueColor;
+#else
+ results[i].class = TrueColor;
+#endif
+ results[i].depth = mode->redBits +
+ mode->redBits +
+ mode->redBits +
+ mode->redBits;
+ results[i].bits_per_rgb = dpy->driverContext.bpp;
+ }
+ }
+ *nitens_return = n;
+ return results;
+}
+
+
+/**
+ * \brief Return a visual that matches specified attributes.
+ *
+ * \param dpy the display handle, as returned by XOpenDisplay().
+ * \param screen the screen number. It is currently ignored by Mini GLX and
+ * should be zero.
+ * \param attribList a list of GLX attributes which describe the desired pixel
+ * format. It is terminated by the token \c None.
+ *
+ * The attributes are as follows:
+ * \arg GLX_USE_GL:
+ * This attribute should always be present in order to maintain compatibility
+ * with GLX.
+ * \arg GLX_RGBA:
+ * If present, only RGBA pixel formats will be considered. Otherwise, only
+ * color index formats are considered.
+ * \arg GLX_DOUBLEBUFFER:
+ * if present, only double-buffered pixel formats will be chosen.
+ * \arg GLX_RED_SIZE \e n:
+ * Must be followed by a non-negative integer indicating the minimum number of
+ * bits per red pixel component that is acceptable.
+ * \arg GLX_GREEN_SIZE \e n:
+ * Must be followed by a non-negative integer indicating the minimum number of
+ * bits per green pixel component that is acceptable.
+ * \arg GLX_BLUE_SIZE \e n:
+ * Must be followed by a non-negative integer indicating the minimum number of
+ * bits per blue pixel component that is acceptable.
+ * \arg GLX_ALPHA_SIZE \e n:
+ * Must be followed by a non-negative integer indicating the minimum number of
+ * bits per alpha pixel component that is acceptable.
+ * \arg GLX_STENCIL_SIZE \e n:
+ * Must be followed by a non-negative integer indicating the minimum number of
+ * bits per stencil value that is acceptable.
+ * \arg GLX_DEPTH_SIZE \e n:
+ * Must be followed by a non-negative integer indicating the minimum number of
+ * bits per depth component that is acceptable.
+ * \arg None:
+ * This token is used to terminate the attribute list.
+ *
+ * \return a pointer to an #XVisualInfo object which most closely matches the
+ * requirements of the attribute list. If there is no visual which matches the
+ * request, \c NULL will be returned.
+ *
+ * \note Visuals with accumulation buffers are not available.
+ *
+ * This function searches the list of available visual configurations in
+ * MiniGLXDisplayRec::configs for a configuration which best matches the GLX
+ * attribute list parameter. A new ::XVisualInfo object is created which
+ * describes the visual configuration. The match criteria is described in the
+ * specification.
+ */
+XVisualInfo*
+glXChooseVisual( Display *dpy, int screen, int *attribList )
+{
+ const __GLcontextModes *mode;
+ Visual *vis;
+ XVisualInfo *visInfo;
+ const int *attrib;
+ GLboolean rgbFlag = GL_FALSE, dbFlag = GL_FALSE, stereoFlag = GL_FALSE;
+ GLint redBits = 0, greenBits = 0, blueBits = 0, alphaBits = 0;
+ GLint indexBits = 0, depthBits = 0, stencilBits = 0;
+ GLint numSamples = 0;
+ int i=0;
+
+ /*
+ * XXX in the future, <screen> might be interpreted as a VT
+ */
+ ASSERT(dpy);
+ ASSERT(screen == 0);
+
+ vis = (Visual *)calloc(1, sizeof(Visual));
+ if (!vis)
+ return NULL;
+
+ visInfo = (XVisualInfo *)malloc(sizeof(XVisualInfo));
+ if (!visInfo) {
+ free(vis);
+ return NULL;
+ }
+
+ visInfo->visual = vis;
+ vis->visInfo = visInfo;
+ vis->dpy = dpy;
+
+ /* parse the attribute list */
+ for (attrib = attribList; attrib && *attrib != None; attrib++) {
+ switch (attrib[0]) {
+ case GLX_DOUBLEBUFFER:
+ dbFlag = GL_TRUE;
+ break;
+ case GLX_RGBA:
+ rgbFlag = GL_TRUE;
+ break;
+ case GLX_RED_SIZE:
+ redBits = attrib[1];
+ attrib++;
+ break;
+ case GLX_GREEN_SIZE:
+ greenBits = attrib[1];
+ attrib++;
+ break;
+ case GLX_BLUE_SIZE:
+ blueBits = attrib[1];
+ attrib++;
+ break;
+ case GLX_ALPHA_SIZE:
+ alphaBits = attrib[1];
+ attrib++;
+ break;
+ case GLX_STENCIL_SIZE:
+ stencilBits = attrib[1];
+ attrib++;
+ break;
+ case GLX_DEPTH_SIZE:
+ depthBits = attrib[1];
+ attrib++;
+ break;
+#if 0
+ case GLX_ACCUM_RED_SIZE:
+ accumRedBits = attrib[1];
+ attrib++;
+ break;
+ case GLX_ACCUM_GREEN_SIZE:
+ accumGreenBits = attrib[1];
+ attrib++;
+ break;
+ case GLX_ACCUM_BLUE_SIZE:
+ accumBlueBits = attrib[1];
+ attrib++;
+ break;
+ case GLX_ACCUM_ALPHA_SIZE:
+ accumAlphaBits = attrib[1];
+ attrib++;
+ break;
+ case GLX_LEVEL:
+ /* ignored for now */
+ break;
+#endif
+ default:
+ /* unexpected token */
+ fprintf(stderr, "unexpected token in glXChooseVisual attrib list\n");
+ free(vis);
+ free(visInfo);
+ return NULL;
+ }
+ }
+
+ /* search screen configs for suitable visual */
+ (void) numSamples;
+ (void) indexBits;
+ (void) redBits;
+ (void) greenBits;
+ (void) blueBits;
+ (void) alphaBits;
+ (void) stereoFlag;
+ for ( mode = dpy->driver_modes ; mode != NULL ; mode = mode->next ) {
+ i++;
+ if (mode->rgbMode == rgbFlag &&
+ mode->doubleBufferMode == dbFlag &&
+ mode->redBits >= redBits &&
+ mode->greenBits >= greenBits &&
+ mode->blueBits >= blueBits &&
+ mode->alphaBits >= alphaBits &&
+ mode->depthBits >= depthBits &&
+ mode->stencilBits >= stencilBits) {
+ /* found it */
+ visInfo->visualid = i;
+ vis->mode = mode;
+ break;
+ }
+ }
+ if (!vis->mode)
+ return NULL;
+
+ /* compute depth and bpp */
+ if (rgbFlag) {
+ /* XXX maybe support depth 16 someday */
+#if defined(__cplusplus) || defined(c_plusplus)
+ visInfo->c_class = TrueColor;
+#else
+ visInfo->class = TrueColor;
+#endif
+ visInfo->depth = dpy->driverContext.bpp;
+ visInfo->bits_per_rgb = dpy->driverContext.bpp;
+ if (dpy->driverContext.bpp == 32)
+ vis->pixelFormat = PF_B8G8R8A8;
+ else
+ vis->pixelFormat = PF_B5G6R5;
+ }
+ else {
+ /* color index mode */
+#if defined(__cplusplus) || defined(c_plusplus)
+ visInfo->c_class = PseudoColor;
+#else
+ visInfo->class = PseudoColor;
+#endif
+ visInfo->depth = 8;
+ visInfo->bits_per_rgb = 8; /* bits/pixel */
+ vis->pixelFormat = PF_CI8;
+ }
+
+ return visInfo;
+}
+
+
+/**
+ * \brief Return information about GLX visuals.
+ *
+ * \param dpy the display handle, as returned by XOpenDisplay().
+ * \param vis the visual to be queried, as returned by glXChooseVisual().
+ * \param attrib the visual attribute to be returned.
+ * \param value pointer to an integer in which the result of the query will be
+ * stored.
+ *
+ * \return zero if no error occurs, \c GLX_INVALID_ATTRIBUTE if the attribute
+ * parameter is invalid, or \c GLX_BAD_VISUAL if the \p vis parameter is
+ * invalid.
+ *
+ * Returns the appropriate attribute of ::__GLXvisualConfig pointed by
+ * MiniGLXVisualRec::glxConfig of XVisualInfo::visual.
+ *
+ * \sa data types.
+ */
+int
+glXGetConfig( Display *dpy, XVisualInfo *vis, int attrib, int *value )
+{
+ const __GLcontextModes *mode = vis->visual->mode;
+ if (!mode) {
+ *value = 0;
+ return GLX_BAD_VISUAL;
+ }
+
+ switch (attrib) {
+ case GLX_USE_GL:
+ *value = True;
+ return 0;
+ case GLX_RGBA:
+ *value = mode->rgbMode;
+ return 0;
+ case GLX_DOUBLEBUFFER:
+ *value = mode->doubleBufferMode;
+ return 0;
+ case GLX_RED_SIZE:
+ *value = mode->redBits;
+ return 0;
+ case GLX_GREEN_SIZE:
+ *value = mode->greenBits;
+ return 0;
+ case GLX_BLUE_SIZE:
+ *value = mode->blueBits;
+ return 0;
+ case GLX_ALPHA_SIZE:
+ *value = mode->alphaBits;
+ return 0;
+ case GLX_DEPTH_SIZE:
+ *value = mode->depthBits;
+ return 0;
+ case GLX_STENCIL_SIZE:
+ *value = mode->stencilBits;
+ return 0;
+ default:
+ *value = 0;
+ return GLX_BAD_ATTRIBUTE;
+ }
+ return 0;
+}
+
+
+/**
+ * \brief Create a new GLX rendering context.
+ *
+ * \param dpy the display handle, as returned by XOpenDisplay().
+ * \param vis the visual that defines the frame buffer resources available to
+ * the rendering context, as returned by glXChooseVisual().
+ * \param shareList If non-zero, texture objects and display lists are shared
+ * with the named rendering context. If zero, texture objects and display lists
+ * will (initially) be private to this context. They may be shared when a
+ * subsequent context is created.
+ * \param direct whether direct or indirect rendering is desired. For Mini GLX
+ * this value is ignored but it should be set to \c True.
+ *
+ * \return a ::GLXContext handle if it succeeds or zero if it fails due to
+ * invalid parameter or insufficient resources.
+ *
+ * This function creates and initializes a ::MiniGLXContextRec structure and
+ * calls the __DRIscreenRec::createContext method to initialize the client
+ * private data.
+ */
+GLXContext
+glXCreateContext( Display *dpy, XVisualInfo *vis,
+ GLXContext shareList, Bool direct )
+{
+ GLXContext ctx;
+ void *sharePriv;
+
+ ASSERT(vis);
+
+ ctx = (struct MiniGLXContextRec *)calloc(1, sizeof(struct MiniGLXContextRec));
+ if (!ctx)
+ return NULL;
+
+ ctx->vid = vis->visualid;
+
+ if (shareList)
+ sharePriv = shareList->driContext.private;
+ else
+ sharePriv = NULL;
+
+ ctx->driContext.mode = vis->visual->mode;
+ ctx->driContext.private = dpy->driScreen.createNewContext(dpy, vis->visual->mode,
+ GLX_WINDOW_BIT, sharePriv, &ctx->driContext);
+
+ if (!ctx->driContext.private) {
+ free(ctx);
+ return NULL;
+ }
+
+ return ctx;
+}
+
+
+/**
+ * \brief Destroy a GLX context.
+ *
+ * \param dpy the display handle, as returned by XOpenDisplay().
+ * \param ctx the GLX context to be destroyed.
+ *
+ * This function frees the \p ctx parameter after unbinding the current context
+ * by calling the __DRIcontextRec::bindContext method with zeros and calling
+ * the __DRIcontextRec::destroyContext method.
+ */
+void
+glXDestroyContext( Display *dpy, GLXContext ctx )
+{
+ GLXContext glxctx = glXGetCurrentContext();
+
+ if (ctx) {
+ if (glxctx == ctx) {
+ /* destroying current context */
+ ctx->driContext.bindContext(dpy, 0, 0, 0, 0);
+ CurrentContext = 0;
+ }
+ ctx->driContext.destroyContext(dpy, 0, ctx->driContext.private);
+ free(ctx);
+ }
+}
+
+
+/**
+ * \brief Bind a GLX context to a window or a pixmap.
+ *
+ * \param dpy the display handle, as returned by XOpenDisplay().
+ * \param drawable the window or drawable to bind to the rendering context.
+ * This should be the value returned by XCreateWindow().
+ * \param ctx the GLX context to be destroyed.
+ *
+ * \return \c True if it succeeds, \c False otherwise to indicate an invalid
+ * display, window or context parameter.
+ *
+ * The current rendering context may be unbound by calling glXMakeCurrent()
+ * with the window and context parameters set to zero.
+ *
+ * An application may create any number of rendering contexts and bind them as
+ * needed. Note that binding a rendering context is generally not a
+ * light-weight operation. Most simple OpenGL applications create only one
+ * rendering context.
+ *
+ * This function first unbinds any old context via
+ * __DRIcontextRec::unbindContext and binds the new one via
+ * __DRIcontextRec::bindContext.
+ *
+ * If \p drawable is zero it unbinds the GLX context by calling
+ * __DRIcontextRec::bindContext with zeros.
+ */
+Bool
+glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx)
+{
+ if (dpy && drawable && ctx) {
+ GLXContext oldContext = glXGetCurrentContext();
+ GLXDrawable oldDrawable = glXGetCurrentDrawable();
+ /* unbind old */
+ if (oldContext) {
+ oldContext->driContext.unbindContext(dpy, 0,
+ (__DRIid) oldDrawable, (__DRIid) oldDrawable,
+ &oldContext->driContext);
+ }
+ /* bind new */
+ CurrentContext = ctx;
+ ctx->driContext.bindContext(dpy, 0, (__DRIid) drawable,
+ (__DRIid) drawable, &ctx->driContext);
+ ctx->drawBuffer = drawable;
+ ctx->curBuffer = drawable;
+ }
+ else if (ctx && dpy) {
+ /* unbind */
+ ctx->driContext.bindContext(dpy, 0, 0, 0, 0);
+ }
+ else if (dpy) {
+ CurrentContext = 0; /* kw: this seems to be intended??? */
+ }
+
+ return True;
+}
+
+
+/**
+ * \brief Exchange front and back buffers.
+ *
+ * \param dpy the display handle, as returned by XOpenDisplay().
+ * \param drawable the drawable whose buffers are to be swapped.
+ *
+ * Any pending rendering commands will be completed before the buffer swap
+ * takes place.
+ *
+ * Calling glXSwapBuffers() on a window which is single-buffered has no effect.
+ *
+ * This function just calls the __DRIdrawableRec::swapBuffers method to do the
+ * work.
+ */
+void
+glXSwapBuffers( Display *dpy, GLXDrawable drawable )
+{
+ if (!dpy || !drawable)
+ return;
+
+ drawable->driDrawable.swapBuffers(dpy, drawable->driDrawable.private);
+}
+
+
+/**
+ * \brief Return the current context
+ *
+ * \return the current context, as specified by glXMakeCurrent(), or zero if no
+ * context is currently bound.
+ *
+ * \sa glXCreateContext(), glXMakeCurrent()
+ *
+ * Returns the value of the ::CurrentContext global variable.
+ */
+GLXContext
+glXGetCurrentContext( void )
+{
+ return CurrentContext;
+}
+
+
+/**
+ * \brief Return the current drawable.
+ *
+ * \return the current drawable, as specified by glXMakeCurrent(), or zero if
+ * no drawable is currently bound.
+ *
+ * This function gets the current context via glXGetCurrentContext() and
+ * returns the MiniGLXContextRec::drawBuffer attribute.
+ */
+GLXDrawable
+glXGetCurrentDrawable( void )
+{
+ GLXContext glxctx = glXGetCurrentContext();
+ if (glxctx)
+ return glxctx->drawBuffer;
+ else
+ return NULL;
+}
+
+
+static GLboolean
+__glXCreateContextWithConfig(__DRInativeDisplay *dpy, int screen,
+ int fbconfigID, void *contextID, drm_context_t *hHWContext)
+{
+ __DRIscreen *pDRIScreen;
+ __DRIscreenPrivate *psp;
+
+ pDRIScreen = __glXFindDRIScreen(dpy, screen);
+ if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
+ return GL_FALSE;
+ }
+
+ psp = (__DRIscreenPrivate *) pDRIScreen->private;
+
+ if (psp->fd) {
+ if (drmCreateContext(psp->fd, hHWContext)) {
+ fprintf(stderr, ">>> drmCreateContext failed\n");
+ return GL_FALSE;
+ }
+ *(void**)contextID = (void*) *hHWContext;
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+__glXGetDrawableInfo(__DRInativeDisplay *dpy, int scrn,
+ __DRIid draw, unsigned int * index, unsigned int * stamp,
+ int * x, int * y, int * width, int * height,
+ int * numClipRects, drm_clip_rect_t ** pClipRects,
+ int * backX, int * backY,
+ int * numBackClipRects, drm_clip_rect_t ** pBackClipRects)
+{
+ GLXDrawable drawable = (GLXDrawable) draw;
+ drm_clip_rect_t * cliprect;
+ Display* display = (Display*)dpy;
+ __DRIcontextPrivate *pcp = (__DRIcontextPrivate *)CurrentContext->driContext.private;
+ if (drawable == 0) {
+ return GL_FALSE;
+ }
+
+ cliprect = (drm_clip_rect_t*) _mesa_malloc(sizeof(drm_clip_rect_t));
+ cliprect->x1 = drawable->x;
+ cliprect->y1 = drawable->y;
+ cliprect->x2 = drawable->x + drawable->w;
+ cliprect->y2 = drawable->y + drawable->h;
+
+ /* the drawable index is by client id */
+ *index = display->clientID;
+
+ *stamp = pcp->driScreenPriv->pSAREA->drawableTable[display->clientID].stamp;
+ *x = drawable->x;
+ *y = drawable->y;
+ *width = drawable->w;
+ *height = drawable->h;
+ *numClipRects = 1;
+ *pClipRects = cliprect;
+
+ *backX = drawable->x;
+ *backY = drawable->y;
+ *numBackClipRects = 0;
+ *pBackClipRects = 0;
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+xf86DRI_DestroyContext(__DRInativeDisplay *dpy, int screen, __DRIid context_id )
+{
+ return GL_TRUE;
+}
+
+
+static GLboolean
+xf86DRI_CreateDrawable(__DRInativeDisplay *dpy, int screen, __DRIid drawable,
+ drm_drawable_t *hHWDrawable )
+{
+ return GL_TRUE;
+}
+
+
+static GLboolean
+xf86DRI_DestroyDrawable(__DRInativeDisplay *dpy, int screen, __DRIid drawable)
+{
+ return GL_TRUE;
+}
+
+
+/**
+ * \brief Query function address.
+ *
+ * The glXGetProcAddress() function will return the address of any available
+ * OpenGL or Mini GLX function.
+ *
+ * \param procName name of the function to be returned.
+ *
+ * \return If \p procName is a valid function name, a pointer to that function
+ * will be returned. Otherwise, \c NULL will be returned.
+ *
+ * The purpose of glXGetProcAddress() is to facilitate using future extensions
+ * to OpenGL or Mini GLX. If a future version of the library adds new extension
+ * functions they'll be accessible via glXGetProcAddress(). The alternative is
+ * to hard-code calls to the new functions in the application but doing so will
+ * prevent linking the application with older versions of the library.
+ *
+ * Returns the function address by looking up its name in a static (name,
+ * address) pair list.
+ */
+void (*glXGetProcAddress(const GLubyte *procname))( void )
+{
+ struct name_address {
+ const char *name;
+ const void *func;
+ };
+ static const struct name_address functions[] = {
+ { "glXChooseVisual", (void *) glXChooseVisual },
+ { "glXCreateContext", (void *) glXCreateContext },
+ { "glXDestroyContext", (void *) glXDestroyContext },
+ { "glXMakeCurrent", (void *) glXMakeCurrent },
+ { "glXSwapBuffers", (void *) glXSwapBuffers },
+ { "glXGetCurrentContext", (void *) glXGetCurrentContext },
+ { "glXGetCurrentDrawable", (void *) glXGetCurrentDrawable },
+ { "glXGetProcAddress", (void *) glXGetProcAddress },
+ { "XOpenDisplay", (void *) XOpenDisplay },
+ { "XCloseDisplay", (void *) XCloseDisplay },
+ { "XCreateWindow", (void *) XCreateWindow },
+ { "XDestroyWindow", (void *) XDestroyWindow },
+ { "XMapWindow", (void *) XMapWindow },
+ { "XCreateColormap", (void *) XCreateColormap },
+ { "XFreeColormap", (void *) XFreeColormap },
+ { "XFree", (void *) XFree },
+ { "XGetVisualinfo", (void *) XGetVisualInfo },
+ { "glXCreatePbuffer", (void *) glXCreatePbuffer },
+ { "glXDestroyPbuffer", (void *) glXDestroyPbuffer },
+ { "glXChooseFBConfig", (void *) glXChooseFBConfig },
+ { "glXGetVisualFromFBConfig", (void *) glXGetVisualFromFBConfig },
+ { NULL, NULL }
+ };
+ const struct name_address *entry;
+ for (entry = functions; entry->name; entry++) {
+ if (strcmp(entry->name, (const char *) procname) == 0) {
+ return entry->func;
+ }
+ }
+ return _glapi_get_proc_address((const char *) procname);
+}
+
+
+/**
+ * \brief Query the Mini GLX version.
+ *
+ * \param dpy the display handle. It is currently ignored, but should be the
+ * value returned by XOpenDisplay().
+ * \param major receives the major version number of Mini GLX.
+ * \param minor receives the minor version number of Mini GLX.
+ *
+ * \return \c True if the function succeeds, \c False if the function fails due
+ * to invalid parameters.
+ *
+ * \sa #MINI_GLX_VERSION_1_0.
+ *
+ * Returns the hard-coded Mini GLX version.
+ */
+Bool
+glXQueryVersion( Display *dpy, int *major, int *minor )
+{
+ (void) dpy;
+ *major = 1;
+ *minor = 0;
+ return True;
+}
+
+
+/**
+ * \brief Create a new pbuffer.
+ */
+GLXPbuffer
+glXCreatePbuffer( Display *dpy, GLXFBConfig config, const int *attribList )
+{
+ return NULL;
+}
+
+
+void
+glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf )
+{
+ free(pbuf);
+}
+
+
+GLXFBConfig *
+glXChooseFBConfig( Display *dpy, int screen, const int *attribList,
+ int *nitems )
+{
+ GLXFBConfig *f = (GLXFBConfig *) malloc(sizeof(GLXFBConfig));
+ f->visInfo = glXChooseVisual( dpy, screen, (int *) attribList );
+ if (f->visInfo) {
+ *nitems = 1;
+ return f;
+ }
+ else {
+ *nitems = 0;
+ free(f);
+ return NULL;
+ }
+}
+
+
+XVisualInfo *
+glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config )
+{
+ /* XVisualInfo and GLXFBConfig are the same structure */
+ (void) dpy;
+ return config.visInfo;
+}
+
+void *glXAllocateMemoryMESA(Display *dpy, int scrn,
+ size_t size, float readFreq,
+ float writeFreq, float priority)
+{
+ if (dpy->driScreen.private && dpy->driScreen.allocateMemory) {
+ return (*dpy->driScreen.allocateMemory)( dpy, scrn, size,
+ readFreq, writeFreq,
+ priority );
+ }
+
+ return NULL;
+}
+
+void glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer)
+{
+ if (dpy->driScreen.private && dpy->driScreen.freeMemory) {
+ (*dpy->driScreen.freeMemory)( dpy, scrn, pointer );
+ }
+}
+
+GLuint glXGetMemoryOffsetMESA( Display *dpy, int scrn,
+ const void *pointer )
+{
+ if (dpy->driScreen.private && dpy->driScreen.memoryOffset) {
+ return (*dpy->driScreen.memoryOffset)( dpy, scrn, pointer );
+ }
+
+ return 0;
+}
+
+
+/**
+ * Get the unadjusted system time (UST). Currently, the UST is measured in
+ * microseconds since Epoc. The actual resolution of the UST may vary from
+ * system to system, and the units may vary from release to release.
+ * Drivers should not call this function directly. They should instead use
+ * \c glXGetProcAddress to obtain a pointer to the function.
+ *
+ * \param ust Location to store the 64-bit UST
+ * \returns Zero on success or a negative errno value on failure.
+ *
+ * \note
+ * This function was copied directly from src/glx/x11/glxcmds.c.
+ */
+static int __glXGetUST( int64_t * ust )
+{
+ struct timeval tv;
+
+ if ( ust == NULL ) {
+ return -EFAULT;
+ }
+
+ if ( gettimeofday( & tv, NULL ) == 0 ) {
+ ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec;
+ return 0;
+ } else {
+ return -errno;
+ }
+}
+
+
+/**
+ *
+ * \bug
+ * This needs to be implemented for miniGlx.
+ */
+static GLboolean __glXGetMscRate(__DRInativeDisplay * dpy, __DRIid drawable,
+ int32_t * numerator, int32_t * denominator)
+{
+ *numerator = 0;
+ *denominator = 0;
+ return False;
+}
+/*@}*/
diff --git a/nx-X11/extras/Mesa/src/glx/mini/miniglxP.h b/nx-X11/extras/Mesa/src/glx/mini/miniglxP.h
new file mode 100644
index 000000000..96ed0e81c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/mini/miniglxP.h
@@ -0,0 +1,205 @@
+/**
+ * \file miniglxP.h
+ * \brief Define replacements for some X data types and define the DRI-related
+ * data structures.
+ *
+ * \note Cut down version of glxclient.h.
+ *
+ */
+
+#ifndef _mini_GLX_client_h_
+#define _mini_GLX_client_h_
+
+#include <signal.h>
+#include <linux/fb.h>
+
+#include <GL/miniglx.h>
+#include "glheader.h"
+#include "mtypes.h"
+
+#include "driver.h"
+#include "GL/internal/dri_interface.h"
+
+/**
+ * \brief Supported pixel formats.
+ */
+enum PixelFormat {
+ PF_B8G8R8, /**< \brief 24-bit BGR */
+ PF_B8G8R8A8, /**< \brief 32-bit BGRA */
+ PF_B5G6R5, /**< \brief 16-bit BGR */
+ PF_B5G5R5, /**< \brief 15-bit BGR */
+ PF_CI8 /**< \brief 8-bit color index */
+};
+
+/**
+ * \brief X Visual type.
+ *
+ * \sa ::Visual, \ref datatypes.
+ */
+struct MiniGLXVisualRec {
+ /** \brief GLX visual information */
+ const __GLcontextModes *mode;
+
+ /** \brief pointer back to corresponding ::XVisualInfo */
+ XVisualInfo *visInfo;
+
+ /** \brief display handle */
+ Display *dpy;
+
+ /** \brief pixel format */
+ enum PixelFormat pixelFormat;
+};
+
+
+
+/**
+ * \brief X Window type.
+ *
+ * \sa ::Window, \ref datatypes.
+ */
+struct MiniGLXWindowRec {
+ Visual *visual;
+ /** \brief position (always 0,0) */
+ int x, y;
+ /** \brief size */
+ unsigned int w, h;
+ void *frontStart; /**< \brief start of front color buffer */
+ void *backStart; /**< \brief start of back color buffer */
+ size_t size; /**< \brief color buffer size, in bytes */
+ GLuint bytesPerPixel;
+ GLuint rowStride; /**< \brief in bytes */
+ GLubyte *frontBottom; /**< \brief pointer to last row */
+ GLubyte *backBottom; /**< \brief pointer to last row */
+ GLubyte *curBottom; /**< = frontBottom or backBottom */
+ __DRIdrawable driDrawable;
+ GLuint ismapped;
+};
+
+
+/**
+ * \brief GLXContext type.
+ *
+ * \sa ::GLXContext, \ref datatypes.
+ */
+struct MiniGLXContextRec {
+ Window drawBuffer; /**< \brief drawing buffer */
+ Window curBuffer; /**< \brief current buffer */
+ VisualID vid; /**< \brief visual ID */
+ __DRIcontext driContext; /**< \brief context dependent methods */
+};
+
+#define MINIGLX_BUF_SIZE 512
+#define MINIGLX_MAX_SERVER_FDS 10
+#define MINIGLX_MAX_CLIENT_FDS 1
+#define MINIGLX_EVENT_QUEUE_SZ 16
+#define MINIGLX_EVENT_QUEUE_MASK (MINIGLX_EVENT_QUEUE_SZ-1)
+
+/**
+ * A connection to/from the server
+ *
+ * All information is to/from the server is buffered and then dispatched by
+ * __miniglx_Select() to avoid blocking the server.
+ */
+struct MiniGLXConnection {
+ int fd; /**< \brief file descriptor */
+ char readbuf[MINIGLX_BUF_SIZE]; /**< \brief read buffer */
+ char writebuf[MINIGLX_BUF_SIZE]; /**< \brief write buffer */
+ int readbuf_count; /**< \brief count of bytes waiting to be read */
+ int writebuf_count; /**< \brief count of bytes waiting to be written */
+};
+
+
+/**
+ * \brief X Display type
+ *
+ * \sa ::Display, \ref datatypes.
+ */
+struct MiniGLXDisplayRec {
+ /** \brief fixed framebuffer screen info */
+ struct fb_fix_screeninfo FixedInfo;
+ /** \brief original and current variable framebuffer screen info */
+ struct fb_var_screeninfo OrigVarInfo, VarInfo;
+ struct sigaction OrigSigUsr1;
+ struct sigaction OrigSigUsr2;
+ int OriginalVT;
+ int ConsoleFD; /**< \brief console TTY device file descriptor */
+ int FrameBufferFD; /**< \brief framebuffer device file descriptor */
+ int NumWindows; /**< \brief number of open windows */
+ Window TheWindow; /**< \brief open window - only allow one window for now */
+ int rotateMode;
+
+
+ volatile int vtSignalFlag;
+ volatile int haveVT; /**< \brief whether the VT is hold */
+ int hwActive; /**< \brief whether the hardware is active -- mimics
+ the variations of MiniGLXDisplayRec::haveVT */
+
+
+ int IsClient; /**< \brief whether it's a client or the server */
+ int clientID;
+ int nrFds; /**< \brief number of connections (usually just one for the clients) */
+ struct MiniGLXConnection *fd; /**< \brief connections */
+ int drmFd; /**< \brief handle to drm device */
+ int authorized; /**< \brief has server authorized this process? */
+
+ struct {
+ int nr, head, tail;
+ XEvent queue[MINIGLX_EVENT_QUEUE_SZ];
+ } eventqueue;
+
+ /**
+ * \name Visuals
+ *
+ * Visuals (configs) in this screen.
+ */
+ /*@{*/
+ const __GLcontextModes *driver_modes; /**< \brief Modes filtered by driver. */
+ /*@}*/
+
+ /**
+ * \name From __GLXdisplayPrivate
+ */
+ /*@{*/
+ PFNCREATENEWSCREENFUNC createNewScreen; /**< \brief \e __driCreateScreen hook */
+ __DRIscreen driScreen; /**< \brief Screen dependent methods */
+ void *dlHandle; /**<
+ * \brief handle to the client dynamic
+ * library
+ */
+ /*@}*/
+
+ /**
+ * \brief Mini GLX specific driver hooks
+ */
+ struct DRIDriverRec *driver;
+ struct DRIDriverContextRec driverContext;
+
+ /**
+ * \name Configuration details
+ *
+ * They are read from a configuration file by __read_config_file().
+ */
+ /*@{*/
+ const char *fbdevDevice;
+ const char *clientDriverName;
+ /*@}*/
+};
+
+/** Character messages. */
+enum msgs {
+ _CanIHaveFocus,
+ _IDontWantFocus,
+ _YouveGotFocus,
+ _YouveLostFocus,
+ _RepaintPlease,
+ _Authorize,
+};
+extern int send_msg( Display *dpy, int i, const void *msg, size_t sz );
+extern int send_char_msg( Display *dpy, int i, char msg );
+extern int blocking_read( Display *dpy, int connection, char *msg, size_t msg_size );
+extern int handle_fd_events( Display *dpy, int nonblock );
+
+extern int __miniglx_open_connections( Display *dpy );
+extern void __miniglx_close_connections( Display *dpy );
+
+#endif /* !_mini_GLX_client_h_ */
diff --git a/nx-X11/extras/Mesa/src/glx/mini/miniglx_events.c b/nx-X11/extras/Mesa/src/glx/mini/miniglx_events.c
new file mode 100644
index 000000000..7e54ec491
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/mini/miniglx_events.c
@@ -0,0 +1,978 @@
+/**
+ * \file miniglx_events.c
+ * \brief Mini GLX client/server communication functions.
+ * \author Keith Whitwell
+ *
+ * The Mini GLX interface is a subset of the GLX interface, plus a
+ * minimal set of Xlib functions. This file adds interfaces to
+ * arbitrate a single cliprect between multiple direct rendering
+ * clients.
+ *
+ * A fairly complete client/server non-blocking communication
+ * mechanism. Probably overkill given that none of our messages
+ * currently exceed 1 byte in length and take place over the
+ * relatively benign channel provided by a Unix domain socket.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.0
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+/* $Id: miniglx_events.c,v 1.1.1.3 2005/10/18 02:51:50 kem Exp $ */
+
+
+#include <assert.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/stat.h>
+
+#include <linux/kd.h>
+#include <linux/vt.h>
+
+#include "xf86drm.h"
+#include "miniglxP.h"
+
+
+#define MINIGLX_FIFO_NAME "/tmp/miniglx.fifo"
+
+/**
+ * \brief Allocate an XEvent structure on the event queue.
+ *
+ * \param dpy the display handle.
+ *
+ * \return Pointer to the queued event structure or NULL on failure.
+ *
+ * \internal
+ * If there is space on the XEvent queue, return a pointer
+ * to the next free event and increment the eventqueue tail value.
+ * Otherwise return null.
+ */
+static XEvent *queue_event( Display *dpy )
+{
+ int incr = (dpy->eventqueue.tail + 1) & MINIGLX_EVENT_QUEUE_MASK;
+ if (incr == dpy->eventqueue.head) {
+ return 0;
+ }
+ else {
+ XEvent *ev = &dpy->eventqueue.queue[dpy->eventqueue.tail];
+ dpy->eventqueue.tail = incr;
+ return ev;
+ }
+}
+
+/**
+ * \brief Dequeue an XEvent and copy it into provided storage.
+ *
+ * \param dpy the display handle.
+ * \param event_return pointer to copy the queued event to.
+ *
+ * \return True or False depending on success.
+ *
+ * \internal
+ * If there is a queued XEvent on the queue, copy it to the provided
+ * pointer and increment the eventqueue head value. Otherwise return
+ * null.
+ */
+static int dequeue_event( Display *dpy, XEvent *event_return )
+{
+ if (dpy->eventqueue.tail == dpy->eventqueue.head) {
+ return False;
+ }
+ else {
+ *event_return = dpy->eventqueue.queue[dpy->eventqueue.head];
+ dpy->eventqueue.head += 1;
+ dpy->eventqueue.head &= MINIGLX_EVENT_QUEUE_MASK;
+ return True;
+ }
+}
+
+/**
+ * \brief Shutdown a socket connection.
+ *
+ * \param dpy the display handle.
+ * \param i the index in dpy->fd of the socket connection.
+ *
+ * \internal
+ * Shutdown and close the file descriptor. If this is the special
+ * connection in fd[0], issue an error message and exit - there's been
+ * some sort of failure somewhere. Otherwise, let the application
+ * know about whats happened by issuing a DestroyNotify event.
+ */
+static void shut_fd( Display *dpy, int i )
+{
+ if (dpy->fd[i].fd < 0)
+ return;
+
+ shutdown (dpy->fd[i].fd, SHUT_RDWR);
+ close (dpy->fd[i].fd);
+ dpy->fd[i].fd = -1;
+ dpy->fd[i].readbuf_count = 0;
+ dpy->fd[i].writebuf_count = 0;
+
+ if (i == 0) {
+ fprintf(stderr, "server connection lost\n");
+ exit(1);
+ }
+ else {
+ /* Pass this to the application as a DestroyNotify event.
+ */
+ XEvent *er = queue_event(dpy);
+ if (!er) return;
+ er->xdestroywindow.type = DestroyNotify;
+ er->xdestroywindow.serial = 0;
+ er->xdestroywindow.send_event = 0;
+ er->xdestroywindow.display = dpy;
+ er->xdestroywindow.window = (Window)i;
+ }
+}
+
+/**
+ * \brief Send a message to a socket connection.
+ *
+ * \param dpy the display handle.
+ * \param i the index in dpy->fd of the socket connection.
+ * \param msg the message to send.
+ * \param sz the size of the message
+ *
+ * \internal
+ * Copy the message to the write buffer for the nominated connection.
+ * This will be actually sent to that file descriptor from
+ * __miniglx_Select().
+ */
+int send_msg( Display *dpy, int i,
+ const void *msg, size_t sz )
+{
+ int cnt = dpy->fd[i].writebuf_count;
+ if (MINIGLX_BUF_SIZE - cnt < sz) {
+ fprintf(stderr, "client %d: writebuf overflow\n", i);
+ return False;
+ }
+
+ memcpy( dpy->fd[i].writebuf + cnt, msg, sz ); cnt += sz;
+ dpy->fd[i].writebuf_count = cnt;
+ return True;
+}
+
+/**
+ * \brief Send a message to a socket connection.
+ *
+ * \param dpy the display handle.
+ * \param i the index in dpy->fd of the socket connection.
+ * \param msg the message to send.
+ *
+ * \internal
+ * Use send_msg() to send a one-byte message to a socket.
+ */
+int send_char_msg( Display *dpy, int i, char msg )
+{
+ return send_msg( dpy, i, &msg, sizeof(char));
+}
+
+
+/**
+ * \brief Block and receive a message from a socket connection.
+ *
+ * \param dpy the display handle.
+ * \param connection the index in dpy->fd of the socket connection.
+ * \param msg storage for the received message.
+ * \param msg_size the number of bytes to read.
+ *
+ * \internal
+ * Block and read from the connection's file descriptor
+ * until msg_size bytes have been received.
+ *
+ * Only called from welcome_message_part().
+ */
+int blocking_read( Display *dpy, int connection,
+ char *msg, size_t msg_size )
+{
+ int i, r;
+
+ for (i = 0 ; i < msg_size ; i += r) {
+ r = read(dpy->fd[connection].fd, msg + i, msg_size - i);
+ if (r < 1) {
+ fprintf(stderr, "blocking_read: %d %s\n", r, strerror(errno));
+ shut_fd(dpy,connection);
+ return False;
+ }
+ }
+
+ return True;
+}
+
+/**
+ * \brief Send/receive a part of the welcome message.
+ *
+ * \param dpy the display handle.
+ * \param i the index in dpy->fd of the socket connection.
+ * \param msg storage for the sent/received message.
+ * \param sz the number of bytes to write/read.
+ *
+ * \return True on success, or False on failure.
+ *
+ * This function is called by welcome_message_part(), to either send or receive
+ * (via blocking_read()) part of the welcome message, according to whether
+ * Display::IsClient is set.
+ *
+ * Each part of the welcome message on the wire consists of a count and then the
+ * actual message data with that number of bytes.
+ */
+static int welcome_message_part( Display *dpy, int i, void **msg, int sz )
+{
+ if (dpy->IsClient) {
+ int sz;
+ if (!blocking_read( dpy, i, (char *)&sz, sizeof(sz))) return False;
+ if (!*msg) *msg = malloc(sz);
+ if (!*msg) return False;
+ if (!blocking_read( dpy, i, *msg, sz )) return False;
+ return sz;
+ }
+ else {
+ if (!send_msg( dpy, i, &sz, sizeof(sz))) return False;
+ if (!send_msg( dpy, i, *msg, sz )) return False;
+ }
+
+ return True;
+}
+
+/**
+ * \brief Send/receive the welcome message.
+ *
+ * \param dpy the display handle.
+ * \param i the index in dpy->fd of the socket connection.
+ *
+ * \return True on success, or False on failure.
+ *
+ * Using welcome_message_part(), sends/receives the client ID, the client
+ * configuration details in DRIDriverContext::shared, and the driver private
+ * message in DRIDriverContext::driverClientMsg.
+ */
+static int welcome_message( Display *dpy, int i )
+{
+ void *tmp = &dpy->driverContext.shared;
+ int *clientid = dpy->IsClient ? &dpy->clientID : &i;
+ int size;
+ if (!welcome_message_part( dpy, i, (void **)&clientid, sizeof(*clientid)))
+ return False;
+
+ if (!welcome_message_part( dpy, i, &tmp, sizeof(dpy->driverContext.shared)))
+ return False;
+
+ size=welcome_message_part( dpy, i,
+ (void **)&dpy->driverContext.driverClientMsg,
+ dpy->driverContext.driverClientMsgSize );
+ if (!size)
+ return False;
+ if (dpy->IsClient) {
+ dpy->driverContext.driverClientMsgSize = size;
+ }
+ return True;
+}
+
+
+/**
+ * \brief Handle a new client connection.
+ *
+ * \param dpy the display handle.
+ *
+ * \return True on success or False on failure.
+ *
+ * Accepts the connection, sets it in non-blocking operation, and finds a free
+ * slot in Display::fd for it.
+ */
+static int handle_new_client( Display *dpy )
+{
+ struct sockaddr_un client_address;
+ unsigned int l = sizeof(client_address);
+ int r, i;
+
+ r = accept(dpy->fd[0].fd, (struct sockaddr *) &client_address, &l);
+ if (r < 0) {
+ perror ("accept()");
+ shut_fd(dpy,0);
+ return False;
+ }
+
+ if (fcntl(r, F_SETFL, O_NONBLOCK) != 0) {
+ perror("fcntl");
+ close(r);
+ return False;
+ }
+
+
+ /* Some rough & ready adaption of the XEvent semantics.
+ */
+ for (i = 1 ; i < dpy->nrFds ; i++) {
+ if (dpy->fd[i].fd < 0) {
+ XEvent *er = queue_event(dpy);
+ if (!er) {
+ close(r);
+ return False;
+ }
+
+ dpy->fd[i].fd = r;
+ er->xcreatewindow.type = CreateNotify;
+ er->xcreatewindow.serial = 0;
+ er->xcreatewindow.send_event = 0;
+ er->xcreatewindow.display = dpy;
+ er->xcreatewindow.window = (Window)i; /* fd slot == window, now? */
+
+ /* Send the driver client message - this is expected as the
+ * first message on a new connection. The recpient already
+ * knows the size of the message.
+ */
+ welcome_message( dpy, i );
+ return True;
+ }
+ }
+
+
+ fprintf(stderr, "[miniglx] %s: Max nr clients exceeded\n", __FUNCTION__);
+ close(r);
+ return False;
+}
+
+/**
+ * This routine "puffs out" the very basic communications between
+ * client and server to full-sized X Events that can be handled by the
+ * application.
+ *
+ * \param dpy the display handle.
+ * \param i the index in dpy->fd of the socket connection.
+ *
+ * \return True on success or False on failure.
+ *
+ * \internal
+ * Interprets the message (see msg) into a XEvent and advances the file FIFO
+ * buffer.
+ */
+static int
+handle_fifo_read( Display *dpy, int i )
+{
+ drm_magic_t magic;
+ int err;
+
+ while (dpy->fd[i].readbuf_count) {
+ char id = dpy->fd[i].readbuf[0];
+ XEvent *er;
+ int count = 1;
+
+ if (dpy->IsClient) {
+ switch (id) {
+ /* The server has called XMapWindow on a client window */
+ case _YouveGotFocus:
+ er = queue_event(dpy);
+ if (!er) return False;
+ er->xmap.type = MapNotify;
+ er->xmap.serial = 0;
+ er->xmap.send_event = False;
+ er->xmap.display = dpy;
+ er->xmap.event = dpy->TheWindow;
+ er->xmap.window = dpy->TheWindow;
+ er->xmap.override_redirect = False;
+ if (dpy->driver->notifyFocus)
+ dpy->driver->notifyFocus( 1 );
+ break;
+
+ /* The server has called XMapWindow on a client window */
+ case _RepaintPlease:
+ er = queue_event(dpy);
+ if (!er) return False;
+ er->xexpose.type = Expose;
+ er->xexpose.serial = 0;
+ er->xexpose.send_event = False;
+ er->xexpose.display = dpy;
+ er->xexpose.window = dpy->TheWindow;
+ if (dpy->rotateMode) {
+ er->xexpose.x = dpy->TheWindow->y;
+ er->xexpose.y = dpy->TheWindow->x;
+ er->xexpose.width = dpy->TheWindow->h;
+ er->xexpose.height = dpy->TheWindow->w;
+ }
+ else {
+ er->xexpose.x = dpy->TheWindow->x;
+ er->xexpose.y = dpy->TheWindow->y;
+ er->xexpose.width = dpy->TheWindow->w;
+ er->xexpose.height = dpy->TheWindow->h;
+ }
+ er->xexpose.count = 0;
+ break;
+
+ /* The server has called 'XUnmapWindow' on a client
+ * window.
+ */
+ case _YouveLostFocus:
+ er = queue_event(dpy);
+ if (!er) return False;
+ er->xunmap.type = UnmapNotify;
+ er->xunmap.serial = 0;
+ er->xunmap.send_event = False;
+ er->xunmap.display = dpy;
+ er->xunmap.event = dpy->TheWindow;
+ er->xunmap.window = dpy->TheWindow;
+ er->xunmap.from_configure = False;
+ if (dpy->driver->notifyFocus)
+ dpy->driver->notifyFocus( 0 );
+ break;
+
+ case _Authorize:
+ dpy->authorized = True;
+ break;
+
+ default:
+ fprintf(stderr, "Client received unhandled message type %d\n", id);
+ shut_fd(dpy, i); /* Actually shuts down the client */
+ return False;
+ }
+ }
+ else {
+ switch (id) {
+ /* Lets the server know that the client is ready to render
+ * (having called 'XMapWindow' locally).
+ */
+ case _CanIHaveFocus:
+ er = queue_event(dpy);
+ if (!er) return False;
+ er->xmaprequest.type = MapRequest;
+ er->xmaprequest.serial = 0;
+ er->xmaprequest.send_event = False;
+ er->xmaprequest.display = dpy;
+ er->xmaprequest.parent = 0;
+ er->xmaprequest.window = (Window)i;
+ break;
+
+ /* Both _YouveLostFocus and _IDontWantFocus generate unmap
+ * events. The idea is that _YouveLostFocus lets the client
+ * know that it has had focus revoked by the server, whereas
+ * _IDontWantFocus lets the server know that the client has
+ * unmapped its own window.
+ */
+ case _IDontWantFocus:
+ er = queue_event(dpy);
+ if (!er) return False;
+ er->xunmap.type = UnmapNotify;
+ er->xunmap.serial = 0;
+ er->xunmap.send_event = False;
+ er->xunmap.display = dpy;
+ er->xunmap.event = (Window)i;
+ er->xunmap.window = (Window)i;
+ er->xunmap.from_configure = False;
+ break;
+
+ case _Authorize:
+ /* is full message here yet? */
+ if (dpy->fd[i].readbuf_count < count + sizeof(magic)) {
+ count = 0;
+ break;
+ }
+ memcpy(&magic, dpy->fd[i].readbuf + count, sizeof(magic));
+ fprintf(stderr, "Authorize - magic %d\n", magic);
+
+ err = drmAuthMagic(dpy->driverContext.drmFD, magic);
+ count += sizeof(magic);
+
+ send_char_msg( dpy, i, _Authorize );
+ break;
+
+ default:
+ fprintf(stderr, "Server received unhandled message type %d\n", id);
+ shut_fd(dpy, i); /* Generates DestroyNotify event */
+ return False;
+ }
+ }
+
+ dpy->fd[i].readbuf_count -= count;
+
+ if (dpy->fd[i].readbuf_count) {
+ memmove(dpy->fd[i].readbuf,
+ dpy->fd[i].readbuf + count,
+ dpy->fd[i].readbuf_count);
+ }
+ }
+
+ return True;
+}
+
+/**
+ * Handle a VT signal
+ *
+ * \param dpy display handle.
+ *
+ * The VT switches is detected by comparing Display::haveVT and
+ * Display::hwActive. When loosing the VT the hardware lock is acquired, the
+ * hardware is shutdown via a call to DRIDriverRec::shutdownHardware(), and the
+ * VT released. When acquiring the VT back the hardware state is restored via a
+ * call to DRIDriverRec::restoreHardware() and the hardware lock released.
+ */
+static void __driHandleVtSignals( Display *dpy )
+{
+ dpy->vtSignalFlag = 0;
+
+ fprintf(stderr, "%s: haveVT %d hwActive %d\n", __FUNCTION__,
+ dpy->haveVT, dpy->hwActive);
+
+ if (!dpy->haveVT && dpy->hwActive) {
+ /* Need to get lock and shutdown hardware */
+ DRM_LIGHT_LOCK( dpy->driverContext.drmFD,
+ dpy->driverContext.pSAREA,
+ dpy->driverContext.serverContext );
+ dpy->driver->shutdownHardware( &dpy->driverContext );
+
+ /* Can now give up control of the VT */
+ ioctl( dpy->ConsoleFD, VT_RELDISP, 1 );
+ dpy->hwActive = 0;
+ }
+ else if (dpy->haveVT && !dpy->hwActive) {
+ /* Get VT (wait??) */
+ ioctl( dpy->ConsoleFD, VT_RELDISP, VT_ACTIVATE );
+
+ /* restore HW state, release lock */
+ dpy->driver->restoreHardware( &dpy->driverContext );
+ DRM_UNLOCK( dpy->driverContext.drmFD,
+ dpy->driverContext.pSAREA,
+ dpy->driverContext.serverContext );
+ dpy->hwActive = 1;
+ }
+}
+
+
+#undef max
+#define max(x,y) ((x) > (y) ? (x) : (y))
+
+/**
+ * Logic for the select() call.
+ *
+ * \param dpy display handle.
+ * \param n highest fd in any set plus one.
+ * \param rfds fd set to be watched for reading, or NULL to create one.
+ * \param wfds fd set to be watched for writing, or NULL to create one.
+ * \param xfds fd set to be watched for exceptions or error, or NULL to create one.
+ * \param tv timeout value, or NULL for no timeout.
+ *
+ * \return number of file descriptors contained in the sets, or a negative number on failure.
+ *
+ * \note
+ * This all looks pretty complex, but is necessary especially on the
+ * server side to prevent a poorly-behaved client from causing the
+ * server to block in a read or write and hence not service the other
+ * clients.
+ *
+ * \sa
+ * See select_tut in the Linux manual pages for more discussion.
+ *
+ * \internal
+ * Creates and initializes the file descriptor sets by inspecting Display::fd
+ * if these aren't passed in the function call. Calls select() and fulfill the
+ * demands by trying to fill MiniGLXConnection::readbuf and draining
+ * MiniGLXConnection::writebuf.
+ * The server fd[0] is handled specially for new connections, by calling
+ * handle_new_client().
+ *
+ */
+int
+__miniglx_Select( Display *dpy, int n, fd_set *rfds, fd_set *wfds, fd_set *xfds,
+ struct timeval *tv )
+{
+ int i;
+ int retval;
+ fd_set my_rfds, my_wfds;
+ struct timeval my_tv;
+
+ if (!rfds) {
+ rfds = &my_rfds;
+ FD_ZERO(rfds);
+ }
+
+ if (!wfds) {
+ wfds = &my_wfds;
+ FD_ZERO(wfds);
+ }
+
+ /* Don't block if there are events queued. Review this if the
+ * flush in XMapWindow is changed to blocking. (Test case:
+ * miniglxtest).
+ */
+ if (dpy->eventqueue.head != dpy->eventqueue.tail) {
+ my_tv.tv_sec = my_tv.tv_usec = 0;
+ tv = &my_tv;
+ }
+
+ for (i = 0 ; i < dpy->nrFds; i++) {
+ if (dpy->fd[i].fd < 0)
+ continue;
+
+ if (dpy->fd[i].writebuf_count)
+ FD_SET(dpy->fd[i].fd, wfds);
+
+ if (dpy->fd[i].readbuf_count < MINIGLX_BUF_SIZE)
+ FD_SET(dpy->fd[i].fd, rfds);
+
+ n = max(n, dpy->fd[i].fd + 1);
+ }
+
+ if (dpy->vtSignalFlag)
+ __driHandleVtSignals( dpy );
+
+ retval = select( n, rfds, wfds, xfds, tv );
+
+ if (dpy->vtSignalFlag) {
+ int tmp = errno;
+ __driHandleVtSignals( dpy );
+ errno = tmp;
+ }
+
+ if (retval < 0) {
+ FD_ZERO(rfds);
+ FD_ZERO(wfds);
+ return retval;
+ }
+
+ /* Handle server fd[0] specially on the server - accept new client
+ * connections.
+ */
+ if (!dpy->IsClient) {
+ if (FD_ISSET(dpy->fd[0].fd, rfds)) {
+ FD_CLR(dpy->fd[0].fd, rfds);
+ handle_new_client( dpy );
+ }
+ }
+
+ /* Otherwise, try and fill readbuffer and drain writebuffer:
+ */
+ for (i = 0 ; i < dpy->nrFds ; i++) {
+ if (dpy->fd[i].fd < 0)
+ continue;
+
+ /* If there aren't any event slots left, don't examine
+ * any more file events. This will prevent lost events.
+ */
+ if (dpy->eventqueue.head ==
+ ((dpy->eventqueue.tail + 1) & MINIGLX_EVENT_QUEUE_MASK)) {
+ fprintf(stderr, "leaving event loop as event queue is full\n");
+ return retval;
+ }
+
+ if (FD_ISSET(dpy->fd[i].fd, wfds)) {
+ int r = write(dpy->fd[i].fd,
+ dpy->fd[i].writebuf,
+ dpy->fd[i].writebuf_count);
+
+ if (r < 1)
+ shut_fd(dpy,i);
+ else {
+ dpy->fd[i].writebuf_count -= r;
+ if (dpy->fd[i].writebuf_count) {
+ memmove(dpy->fd[i].writebuf,
+ dpy->fd[i].writebuf + r,
+ dpy->fd[i].writebuf_count);
+ }
+ }
+ }
+
+ if (FD_ISSET(dpy->fd[i].fd, rfds)) {
+ int r = read(dpy->fd[i].fd,
+ dpy->fd[i].readbuf + dpy->fd[i].readbuf_count,
+ MINIGLX_BUF_SIZE - dpy->fd[i].readbuf_count);
+
+ if (r < 1)
+ shut_fd(dpy,i);
+ else {
+ dpy->fd[i].readbuf_count += r;
+
+ handle_fifo_read( dpy, i );
+ }
+ }
+ }
+
+ return retval;
+}
+
+/**
+ * \brief Handle socket events.
+ *
+ * \param dpy the display handle.
+ * \param nonblock whether to return immediately or wait for an event.
+ *
+ * \return True on success, False on failure. Aborts on critical error.
+ *
+ * \internal
+ * This function is the select() main loop.
+ */
+int handle_fd_events( Display *dpy, int nonblock )
+{
+ while (1) {
+ struct timeval tv = {0, 0};
+ int r = __miniglx_Select( dpy, 0, 0, 0, 0, nonblock ? &tv : 0 );
+ if (r >= 0)
+ return True;
+ if (errno == EINTR || errno == EAGAIN)
+ continue;
+ perror ("select()");
+ exit (1);
+ }
+}
+
+/**
+ * Initializes the connections.
+ *
+ * \param dpy the display handle.
+ *
+ * \return True on success or False on failure.
+ *
+ * Allocates and initializes the Display::fd array and create a Unix socket on
+ * the first entry. For a server binds the socket to a filename and listen for
+ * connections. For a client connects to the server and waits for a welcome
+ * message. Sets the socket in nonblocking mode.
+ */
+int __miniglx_open_connections( Display *dpy )
+{
+ struct sockaddr_un sa;
+ int i;
+
+ dpy->nrFds = dpy->IsClient ? 1 : MINIGLX_MAX_SERVER_FDS;
+ dpy->fd = calloc(1, dpy->nrFds * sizeof(struct MiniGLXConnection));
+ if (!dpy->fd)
+ return False;
+
+ for (i = 0 ; i < dpy->nrFds ; i++)
+ dpy->fd[i].fd = -1;
+
+ if (!dpy->IsClient) {
+ if (unlink(MINIGLX_FIFO_NAME) != 0 && errno != ENOENT) {
+ perror("unlink " MINIGLX_FIFO_NAME);
+ return False;
+ }
+
+ }
+
+ /* Create a Unix socket -- Note this is *not* a network connection!
+ */
+ dpy->fd[0].fd = socket(PF_UNIX, SOCK_STREAM, 0);
+ if (dpy->fd[0].fd < 0) {
+ perror("socket " MINIGLX_FIFO_NAME);
+ return False;
+ }
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sun_family = AF_UNIX;
+ strcpy(sa.sun_path, MINIGLX_FIFO_NAME);
+
+ if (dpy->IsClient) {
+ /* Connect to server
+ */
+ if (connect(dpy->fd[0].fd, (struct sockaddr *)&sa, sizeof(sa)) != 0) {
+ perror("connect");
+ shut_fd(dpy,0);
+ return False;
+ }
+
+ /* Wait for configuration messages from the server.
+ */
+ welcome_message( dpy, 0 );
+ }
+ else {
+ mode_t tmp = umask( 0000 ); /* open to everybody ? */
+
+ /* Bind socket to our filename
+ */
+ if (bind(dpy->fd[0].fd, (struct sockaddr *)&sa, sizeof(sa)) != 0) {
+ perror("bind");
+ shut_fd(dpy,0);
+ return False;
+ }
+
+ umask( tmp );
+
+ /* Listen for connections
+ */
+ if (listen(dpy->fd[0].fd, 5) != 0) {
+ perror("listen");
+ shut_fd(dpy,0);
+ return False;
+ }
+ }
+
+ if (fcntl(dpy->fd[0].fd, F_SETFL, O_NONBLOCK) != 0) {
+ perror("fcntl");
+ shut_fd(dpy,0);
+ return False;
+ }
+
+
+ return True;
+}
+
+
+/**
+ * Frees the connections initialized by __miniglx_open_connections().
+ *
+ * \param dpy the display handle.
+ */
+void __miniglx_close_connections( Display *dpy )
+{
+ int i;
+
+ for (i = 0 ; i < dpy->nrFds ; i++) {
+ if (dpy->fd[i].fd >= 0) {
+ shutdown (dpy->fd[i].fd, SHUT_RDWR);
+ close (dpy->fd[i].fd);
+ }
+ }
+
+ dpy->nrFds = 0;
+ free(dpy->fd);
+}
+
+
+/**
+ * Set a drawable flag.
+ *
+ * \param dpy the display handle.
+ * \param w drawable (window).
+ * \param flag flag.
+ *
+ * Sets the specified drawable flag in the SAREA and increment its stamp while
+ * holding the light hardware lock.
+ */
+static void set_drawable_flag( Display *dpy, int w, int flag )
+{
+ if (dpy->driverContext.pSAREA) {
+ if (dpy->hwActive)
+ DRM_LIGHT_LOCK( dpy->driverContext.drmFD,
+ dpy->driverContext.pSAREA,
+ dpy->driverContext.serverContext );
+
+ dpy->driverContext.pSAREA->drawableTable[w].stamp++;
+ dpy->driverContext.pSAREA->drawableTable[w].flags = flag;
+
+ if (dpy->hwActive)
+ DRM_UNLOCK( dpy->driverContext.drmFD,
+ dpy->driverContext.pSAREA,
+ dpy->driverContext.serverContext );
+ }
+}
+
+
+
+/**
+ * \brief Map Window.
+ *
+ * \param dpy the display handle as returned by XOpenDisplay().
+ * \param w the window handle.
+ *
+ * If called by a client, sends a request for focus to the server. If
+ * called by the server, will generate a MapNotify and Expose event at
+ * the client.
+ *
+ */
+void
+XMapWindow( Display *dpy, Window w )
+{
+ if (dpy->IsClient)
+ send_char_msg( dpy, 0, _CanIHaveFocus );
+ else {
+ set_drawable_flag( dpy, (int)w, 1 );
+ send_char_msg( dpy, (int)w, _YouveGotFocus );
+ send_char_msg( dpy, (int)w, _RepaintPlease );
+ dpy->TheWindow = w;
+ }
+ handle_fd_events( dpy, 0 ); /* flush write queue */
+}
+
+/**
+ * \brief Unmap Window.
+ *
+ * \param dpy the display handle as returned by XOpenDisplay().
+ * \param w the window handle.
+ *
+ * Called from the client: Lets the server know that the window won't
+ * be updated anymore.
+ *
+ * Called from the server: Tells the specified client that it no longer
+ * holds the focus.
+ */
+void
+XUnmapWindow( Display *dpy, Window w )
+{
+ if (dpy->IsClient) {
+ send_char_msg( dpy, 0, _IDontWantFocus );
+ }
+ else {
+ dpy->TheWindow = 0;
+ set_drawable_flag( dpy, (int)w, 0 );
+ send_char_msg( dpy, (int)w, _YouveLostFocus );
+ }
+ handle_fd_events( dpy, 0 ); /* flush write queue */
+}
+
+
+/**
+ * \brief Block and wait for next X event.
+ *
+ * \param dpy the display handle as returned by XOpenDisplay().
+ * \param event_return a pointer to an XEvent structure for the returned data.
+ *
+ * Wait until there is a new XEvent pending.
+ */
+int XNextEvent(Display *dpy, XEvent *event_return)
+{
+ for (;;) {
+ if ( dpy->eventqueue.head != dpy->eventqueue.tail )
+ return dequeue_event( dpy, event_return );
+
+ handle_fd_events( dpy, 0 );
+ }
+}
+
+/**
+ * \brief Non-blocking check for next X event.
+ *
+ * \param dpy the display handle as returned by XOpenDisplay().
+ * \param event_mask ignored.
+ * \param event_return a pointer to an XEvent structure for the returned data.
+ *
+ * Check if there is a new XEvent pending. Note that event_mask is
+ * ignored and any pending event will be returned.
+ */
+Bool XCheckMaskEvent(Display *dpy, long event_mask, XEvent *event_return)
+{
+ if ( dpy->eventqueue.head != dpy->eventqueue.tail )
+ return dequeue_event( dpy, event_return );
+
+ handle_fd_events( dpy, 1 );
+
+ return dequeue_event( dpy, event_return );
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/Makefile b/nx-X11/extras/Mesa/src/glx/x11/Makefile
new file mode 100644
index 000000000..415ec02dd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/Makefile
@@ -0,0 +1,94 @@
+TOP = ../../..
+include $(TOP)/configs/current
+
+DEFINES += -DXF86VIDMODE -D_REENTRANT -UIN_DRI_DRIVER
+
+C_SOURCES = \
+ $(TOP)/src/mesa/glapi/glapi.c \
+ $(TOP)/src/mesa/glapi/glthread.c \
+ $(TOP)/src/mesa/main/dispatch.c \
+ glcontextmodes.c \
+ clientattrib.c \
+ compsize.c \
+ eval.c \
+ glxcmds.c \
+ glxext.c \
+ glxextensions.c \
+ indirect.c \
+ indirect_init.c \
+ indirect_size.c \
+ indirect_window_pos.c \
+ indirect_transpose_matrix.c \
+ indirect_vertex_array.c \
+ indirect_vertex_program.c \
+ pixel.c \
+ pixelstore.c \
+ render2.c \
+ renderpix.c \
+ single2.c \
+ singlepix.c \
+ vertarr.c \
+ xfont.c \
+ glx_pbuffer.c \
+ glx_query.c \
+ glx_texture_compression.c \
+ dri_glx.c \
+ XF86dri.c \
+
+X86_SOURCES = $(TOP)/src/mesa/x86/glapi_x86.S
+X86-64_SOURCES = $(TOP)/src/mesa/x86-64/glapi_x86-64.S
+
+# ASM_SOURCES = $(X86_SOURCES)
+
+OBJECTS = $(C_SOURCES:.c=.o) \
+ $(ASM_SOURCES:.S=.o)
+
+INCLUDES = -I. \
+ -I$(TOP)/include \
+ -I$(TOP)/include/GL/internal \
+ -I$(TOP)/src/mesa/main \
+ -I$(TOP)/src/mesa/glapi \
+ -I$(TOP)/src/mesa/drivers/dri/common \
+ `pkg-config --cflags libdrm` \
+ $(X11_INCLUDES)
+
+
+##### RULES #####
+
+.c.o:
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+.S.o:
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+##### TARGETS #####
+
+default: depend $(LIB_DIR)/$(GL_LIB_NAME)
+
+glcontextmodes.c:
+ ln -s $(TOP)/src/mesa/drivers/dri/common/glcontextmodes.c .
+
+# Make libGL
+$(LIB_DIR)/$(GL_LIB_NAME): $(OBJECTS) Makefile
+ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
+ -major 1 -minor 2 $(MKLIB_OPTIONS) \
+ -install $(LIB_DIR) $(GL_LIB_DEPS) $(OBJECTS)
+
+
+depend: $(C_SOURCES) $(ASM_SOURCES) Makefile
+ touch depend
+ $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(C_SOURCES) $(ASM_SOURCES)
+
+
+# Emacs tags
+tags:
+ etags `find . -name \*.[ch]` `find ../include`
+
+
+# Remove .o and backup files
+clean:
+ -rm -f $(LIB_DIR)/libGL.so*
+ -rm -f *.o *~
+ -rm -f depend
+
+include depend
diff --git a/nx-X11/extras/Mesa/src/glx/x11/XF86dri.c b/nx-X11/extras/Mesa/src/glx/x11/XF86dri.c
new file mode 100644
index 000000000..03fa4e57b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/XF86dri.c
@@ -0,0 +1,617 @@
+/* $XFree86: xc/lib/GL/dri/XF86dri.c,v 1.13 2002/10/30 12:51:25 alanh Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <martin@valinux.com>
+ * Jens Owen <jens@tungstengraphics.com>
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+/* THIS IS NOT AN X CONSORTIUM STANDARD */
+
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include "glheader.h"
+#include "xf86dristr.h"
+
+static XExtensionInfo _xf86dri_info_data;
+static XExtensionInfo *xf86dri_info = &_xf86dri_info_data;
+static char xf86dri_extension_name[] = XF86DRINAME;
+
+#define XF86DRICheckExtension(dpy,i,val) \
+ XextCheckExtension (dpy, i, xf86dri_extension_name, val)
+
+/*****************************************************************************
+ * *
+ * private utility routines *
+ * *
+ *****************************************************************************/
+
+static int close_display(Display *dpy, XExtCodes *extCodes);
+static /* const */ XExtensionHooks xf86dri_extension_hooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
+};
+
+static XEXT_GENERATE_FIND_DISPLAY (find_display, xf86dri_info,
+ xf86dri_extension_name,
+ &xf86dri_extension_hooks,
+ 0, NULL)
+
+static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info)
+
+
+/*****************************************************************************
+ * *
+ * public XFree86-DRI Extension routines *
+ * *
+ *****************************************************************************/
+
+#if 0
+#include <stdio.h>
+#define TRACE(msg) fprintf(stderr,"XF86DRI%s\n", msg);
+#else
+#define TRACE(msg)
+#endif
+
+
+PUBLIC Bool XF86DRIQueryExtension (dpy, event_basep, error_basep)
+ Display *dpy;
+ int *event_basep, *error_basep;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+
+ TRACE("QueryExtension...");
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ TRACE("QueryExtension... return True");
+ return True;
+ } else {
+ TRACE("QueryExtension... return False");
+ return False;
+ }
+}
+
+PUBLIC Bool XF86DRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion)
+ Display* dpy;
+ int* majorVersion;
+ int* minorVersion;
+ int* patchVersion;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIQueryVersionReply rep;
+ xXF86DRIQueryVersionReq *req;
+
+ TRACE("QueryVersion...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIQueryVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryVersion... return False");
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ *patchVersion = rep.patchVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryVersion... return True");
+ return True;
+}
+
+PUBLIC Bool XF86DRIQueryDirectRenderingCapable(dpy, screen, isCapable)
+ Display* dpy;
+ int screen;
+ Bool* isCapable;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIQueryDirectRenderingCapableReply rep;
+ xXF86DRIQueryDirectRenderingCapableReq *req;
+
+ TRACE("QueryDirectRenderingCapable...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIQueryDirectRenderingCapable, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIQueryDirectRenderingCapable;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryDirectRenderingCapable... return False");
+ return False;
+ }
+ *isCapable = rep.isCapable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryDirectRenderingCapable... return True");
+ return True;
+}
+
+PUBLIC Bool XF86DRIOpenConnection(dpy, screen, hSAREA, busIdString)
+ Display* dpy;
+ int screen;
+ drm_handle_t * hSAREA;
+ char **busIdString;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIOpenConnectionReply rep;
+ xXF86DRIOpenConnectionReq *req;
+
+ TRACE("OpenConnection...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIOpenConnection, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIOpenConnection;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("OpenConnection... return False");
+ return False;
+ }
+
+ *hSAREA = rep.hSAREALow;
+#ifdef LONG64
+ *hSAREA |= ((drm_handle_t)rep.hSAREAHigh) << 32;
+#endif
+
+ if (rep.length) {
+ if (!(*busIdString = (char *)Xcalloc(rep.busIdStringLength + 1, 1))) {
+ _XEatData(dpy, ((rep.busIdStringLength+3) & ~3));
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("OpenConnection... return False");
+ return False;
+ }
+ _XReadPad(dpy, *busIdString, rep.busIdStringLength);
+ } else {
+ *busIdString = NULL;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("OpenConnection... return True");
+ return True;
+}
+
+PUBLIC Bool XF86DRIAuthConnection(dpy, screen, magic)
+ Display* dpy;
+ int screen;
+ drm_magic_t magic;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIAuthConnectionReq *req;
+ xXF86DRIAuthConnectionReply rep;
+
+ TRACE("AuthConnection...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIAuthConnection, req);
+ req->reqType = info->codes->major_opcode;
+ 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();
+ TRACE("AuthConnection... return False");
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("AuthConnection... return True");
+ return True;
+}
+
+PUBLIC Bool XF86DRICloseConnection(dpy, screen)
+ Display* dpy;
+ int screen;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRICloseConnectionReq *req;
+
+ TRACE("CloseConnection...");
+
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRICloseConnection, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRICloseConnection;
+ req->screen = screen;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CloseConnection... return True");
+ return True;
+}
+
+PUBLIC Bool XF86DRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion,
+ ddxDriverMinorVersion, ddxDriverPatchVersion, clientDriverName)
+ Display* dpy;
+ int screen;
+ int* ddxDriverMajorVersion;
+ int* ddxDriverMinorVersion;
+ int* ddxDriverPatchVersion;
+ char** clientDriverName;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIGetClientDriverNameReply rep;
+ xXF86DRIGetClientDriverNameReq *req;
+
+ TRACE("GetClientDriverName...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIGetClientDriverName, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIGetClientDriverName;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetClientDriverName... return False");
+ return False;
+ }
+
+ *ddxDriverMajorVersion = rep.ddxDriverMajorVersion;
+ *ddxDriverMinorVersion = rep.ddxDriverMinorVersion;
+ *ddxDriverPatchVersion = rep.ddxDriverPatchVersion;
+
+ if (rep.length) {
+ if (!(*clientDriverName = (char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) {
+ _XEatData(dpy, ((rep.clientDriverNameLength+3) & ~3));
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetClientDriverName... return False");
+ return False;
+ }
+ _XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength);
+ } else {
+ *clientDriverName = NULL;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetClientDriverName... return True");
+ return True;
+}
+
+PUBLIC Bool XF86DRICreateContextWithConfig(dpy, screen, configID, context,
+ hHWContext)
+ Display* dpy;
+ int screen;
+ int configID;
+ XID* context;
+ drm_context_t * hHWContext;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRICreateContextReply rep;
+ xXF86DRICreateContextReq *req;
+
+ TRACE("CreateContext...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRICreateContext, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRICreateContext;
+ req->visual = configID;
+ req->screen = screen;
+ *context = XAllocID(dpy);
+ req->context = *context;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateContext... return False");
+ return False;
+ }
+ *hHWContext = rep.hHWContext;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateContext... return True");
+ return True;
+}
+
+PUBLIC Bool XF86DRICreateContext(dpy, screen, visual, context, hHWContext)
+ Display* dpy;
+ int screen;
+ Visual* visual;
+ XID* context;
+ drm_context_t * hHWContext;
+{
+ return XF86DRICreateContextWithConfig( dpy, screen, visual->visualid,
+ context, hHWContext );
+}
+
+PUBLIC GLboolean XF86DRIDestroyContext( __DRInativeDisplay * ndpy, int screen,
+ __DRIid context )
+{
+ Display * const dpy = (Display *) ndpy;
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIDestroyContextReq *req;
+
+ TRACE("DestroyContext...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIDestroyContext, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIDestroyContext;
+ req->screen = screen;
+ req->context = context;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("DestroyContext... return True");
+ return True;
+}
+
+PUBLIC GLboolean XF86DRICreateDrawable( __DRInativeDisplay * ndpy, int screen,
+ __DRIid drawable, drm_drawable_t * hHWDrawable )
+{
+ Display * const dpy = (Display *) ndpy;
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRICreateDrawableReply rep;
+ xXF86DRICreateDrawableReq *req;
+
+ TRACE("CreateDrawable...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRICreateDrawable, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRICreateDrawable;
+ req->screen = screen;
+ req->drawable = drawable;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateDrawable... return False");
+ return False;
+ }
+ *hHWDrawable = rep.hHWDrawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateDrawable... return True");
+ return True;
+}
+
+PUBLIC GLboolean XF86DRIDestroyDrawable( __DRInativeDisplay * ndpy, int screen,
+ __DRIid drawable )
+{
+ Display * const dpy = (Display *) ndpy;
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIDestroyDrawableReq *req;
+
+ TRACE("DestroyDrawable...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIDestroyDrawable, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIDestroyDrawable;
+ req->screen = screen;
+ req->drawable = drawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("DestroyDrawable... return True");
+ return True;
+}
+
+PUBLIC Bool XF86DRIGetDrawableInfo(Display* dpy, int screen, Drawable drawable,
+ unsigned int* index, unsigned int* stamp,
+ int* X, int* Y, int* W, int* H,
+ int* numClipRects, drm_clip_rect_t ** pClipRects,
+ int* backX, int* backY,
+ int* numBackClipRects, drm_clip_rect_t ** pBackClipRects )
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIGetDrawableInfoReply rep;
+ xXF86DRIGetDrawableInfoReq *req;
+ int total_rects;
+
+ TRACE("GetDrawableInfo...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIGetDrawableInfo, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIGetDrawableInfo;
+ req->screen = screen;
+ req->drawable = drawable;
+
+ if (!_XReply(dpy, (xReply *)&rep, 1, xFalse))
+ {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDrawableInfo... return False");
+ return False;
+ }
+ *index = rep.drawableTableIndex;
+ *stamp = rep.drawableTableStamp;
+ *X = (int)rep.drawableX;
+ *Y = (int)rep.drawableY;
+ *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 0
+ /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks
+ * backwards compatibility (Because of the >> 2 shift) but the fix
+ * enables multi-threaded apps to work.
+ */
+ if (rep.length != ((((SIZEOF(xXF86DRIGetDrawableInfoReply) -
+ SIZEOF(xGenericReply) +
+ total_rects * sizeof(drm_clip_rect_t)) + 3) & ~3) >> 2)) {
+ _XEatData(dpy, rep.length);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDrawableInfo... return False");
+ return False;
+ }
+#endif
+
+ if (*numClipRects) {
+ int len = sizeof(drm_clip_rect_t) * (*numClipRects);
+
+ *pClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
+ if (*pClipRects)
+ _XRead(dpy, (char*)*pClipRects, len);
+ } else {
+ *pClipRects = NULL;
+ }
+
+ if (*numBackClipRects) {
+ int len = sizeof(drm_clip_rect_t) * (*numBackClipRects);
+
+ *pBackClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
+ if (*pBackClipRects)
+ _XRead(dpy, (char*)*pBackClipRects, len);
+ } else {
+ *pBackClipRects = NULL;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDrawableInfo... return True");
+ return True;
+}
+
+PUBLIC Bool XF86DRIGetDeviceInfo(dpy, screen, hFrameBuffer,
+ fbOrigin, fbSize, fbStride, devPrivateSize, pDevPrivate)
+ Display* dpy;
+ int screen;
+ drm_handle_t * hFrameBuffer;
+ int* fbOrigin;
+ int* fbSize;
+ int* fbStride;
+ int* devPrivateSize;
+ void** pDevPrivate;
+{
+ XExtDisplayInfo *info = find_display (dpy);
+ xXF86DRIGetDeviceInfoReply rep;
+ xXF86DRIGetDeviceInfoReq *req;
+
+ TRACE("GetDeviceInfo...");
+ XF86DRICheckExtension (dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIGetDeviceInfo, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIGetDeviceInfo;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDeviceInfo... return False");
+ return False;
+ }
+
+ *hFrameBuffer = rep.hFrameBufferLow;
+#ifdef LONG64
+ *hFrameBuffer |= ((drm_handle_t)rep.hFrameBufferHigh) << 32;
+#endif
+
+ *fbOrigin = rep.framebufferOrigin;
+ *fbSize = rep.framebufferSize;
+ *fbStride = rep.framebufferStride;
+ *devPrivateSize = rep.devPrivateSize;
+
+ if (rep.length) {
+ if (!(*pDevPrivate = (void *)Xcalloc(rep.devPrivateSize, 1))) {
+ _XEatData(dpy, ((rep.devPrivateSize+3) & ~3));
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDeviceInfo... return False");
+ return False;
+ }
+ _XRead(dpy, (char*)*pDevPrivate, rep.devPrivateSize);
+ } else {
+ *pDevPrivate = NULL;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDeviceInfo... return True");
+ return True;
+}
+
+PUBLIC Bool XF86DRIOpenFullScreen(dpy, screen, drawable)
+ Display* dpy;
+ int screen;
+ Drawable drawable;
+{
+ /* This function and the underlying X protocol are deprecated.
+ */
+ (void) dpy;
+ (void) screen;
+ (void) drawable;
+ return False;
+}
+
+PUBLIC Bool XF86DRICloseFullScreen(dpy, screen, drawable)
+ Display* dpy;
+ int screen;
+ Drawable drawable;
+{
+ /* This function and the underlying X protocol are deprecated.
+ */
+ (void) dpy;
+ (void) screen;
+ (void) drawable;
+ return True;
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/clientattrib.c b/nx-X11/extras/Mesa/src/glx/x11/clientattrib.c
new file mode 100644
index 000000000..bfb263ced
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/clientattrib.c
@@ -0,0 +1,141 @@
+/* $XFree86: xc/lib/GL/glx/clientattrib.c,v 1.5 2001/03/21 16:04:39 dawes Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#include <assert.h>
+#include "glxclient.h"
+#include "indirect.h"
+#include "indirect_vertex_array.h"
+
+/*****************************************************************************/
+
+static void
+do_enable_disable(GLenum array, GLboolean val )
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ unsigned index = 0;
+
+ if ( array == GL_TEXTURE_COORD_ARRAY ) {
+ index = __glXGetActiveTextureUnit( state );
+ }
+
+ if ( ! __glXSetArrayEnable( state, array, index, val ) ) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ }
+}
+
+void __indirect_glEnableClientState(GLenum array)
+{
+ do_enable_disable( array, GL_TRUE );
+}
+
+void __indirect_glDisableClientState(GLenum array)
+{
+ do_enable_disable( array, GL_FALSE );
+}
+
+/************************************************************************/
+
+void __indirect_glPushClientAttrib(GLuint mask)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ __GLXattribute **spp = gc->attributes.stackPointer, *sp;
+
+ if (spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]) {
+ if (!(sp = *spp)) {
+ sp = (__GLXattribute *)Xmalloc(sizeof(__GLXattribute));
+ *spp = sp;
+ }
+ sp->mask = mask;
+ gc->attributes.stackPointer = spp + 1;
+ if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
+ sp->storePack = state->storePack;
+ sp->storeUnpack = state->storeUnpack;
+ }
+ if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
+ __glXPushArrayState( state );
+ }
+ } else {
+ __glXSetError(gc, GL_STACK_OVERFLOW);
+ return;
+ }
+}
+
+void __indirect_glPopClientAttrib(void)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ __GLXattribute **spp = gc->attributes.stackPointer, *sp;
+ GLuint mask;
+
+ if (spp > &gc->attributes.stack[0]) {
+ --spp;
+ sp = *spp;
+ assert(sp != 0);
+ mask = sp->mask;
+ gc->attributes.stackPointer = spp;
+
+ if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
+ state->storePack = sp->storePack;
+ state->storeUnpack = sp->storeUnpack;
+ }
+ if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
+ __glXPopArrayState( state );
+ }
+
+ sp->mask = 0;
+ } else {
+ __glXSetError(gc, GL_STACK_UNDERFLOW);
+ return;
+ }
+}
+
+void __glFreeAttributeState(__GLXcontext *gc)
+{
+ __GLXattribute *sp, **spp;
+
+ for (spp = &gc->attributes.stack[0];
+ spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];
+ spp++) {
+ sp = *spp;
+ if (sp) {
+ XFree((char *)sp);
+ } else {
+ break;
+ }
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/compsize.c b/nx-X11/extras/Mesa/src/glx/x11/compsize.c
new file mode 100644
index 000000000..193570c84
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/compsize.c
@@ -0,0 +1,190 @@
+/* $XFree86: xc/lib/GL/glx/compsize.c,v 1.6 2004/01/28 18:11:38 alanh Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#include <GL/gl.h>
+#include "indirect_size.h"
+
+/*
+** Return the number of elements per group of a specified format
+*/
+GLint __glElementsPerGroup(GLenum format, GLenum type)
+{
+ /*
+ ** To make row length computation valid for image extraction,
+ ** packed pixel types assume elements per group equals one.
+ */
+ switch(type) {
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_SHORT_8_8_APPLE:
+ case GL_UNSIGNED_SHORT_8_8_REV_APPLE:
+ case GL_UNSIGNED_SHORT_15_1_MESA:
+ case GL_UNSIGNED_SHORT_1_15_REV_MESA:
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ case GL_UNSIGNED_INT_24_8_NV:
+ case GL_UNSIGNED_INT_24_8_MESA:
+ case GL_UNSIGNED_INT_8_24_REV_MESA:
+ return 1;
+ default:
+ break;
+ }
+
+ switch(format) {
+ case GL_RGB:
+ case GL_BGR:
+ return 3;
+ case GL_422_EXT:
+ case GL_422_REV_EXT:
+ case GL_422_AVERAGE_EXT:
+ case GL_422_REV_AVERAGE_EXT:
+ case GL_YCBCR_422_APPLE:
+ case GL_LUMINANCE_ALPHA:
+ return 2;
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_ABGR_EXT:
+ return 4;
+ case GL_COLOR_INDEX:
+ case GL_STENCIL_INDEX:
+ case GL_DEPTH_COMPONENT:
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_INTENSITY:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+/*
+** Return the number of bytes per element, based on the element type (other
+** than GL_BITMAP).
+*/
+GLint __glBytesPerElement(GLenum type)
+{
+ switch(type) {
+ case GL_UNSIGNED_SHORT:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_SHORT_8_8_APPLE:
+ case GL_UNSIGNED_SHORT_8_8_REV_APPLE:
+ case GL_UNSIGNED_SHORT_15_1_MESA:
+ case GL_UNSIGNED_SHORT_1_15_REV_MESA:
+ return 2;
+ case GL_UNSIGNED_BYTE:
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ return 1;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ case GL_UNSIGNED_INT_24_8_NV:
+ case GL_UNSIGNED_INT_24_8_MESA:
+ case GL_UNSIGNED_INT_8_24_REV_MESA:
+ return 4;
+ default:
+ return 0;
+ }
+}
+
+/*
+** Compute memory required for internal packed array of data of given type
+** and format.
+*/
+GLint __glImageSize(GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type, GLenum target)
+{
+ int bytes_per_row;
+ int components;
+
+ switch( target ) {
+ case GL_PROXY_TEXTURE_1D:
+ case GL_PROXY_TEXTURE_2D:
+ case GL_PROXY_TEXTURE_3D:
+ case GL_PROXY_TEXTURE_4D_SGIS:
+ case GL_PROXY_TEXTURE_CUBE_MAP:
+ case GL_PROXY_TEXTURE_RECTANGLE_ARB:
+ case GL_PROXY_HISTOGRAM:
+ case GL_PROXY_COLOR_TABLE:
+ case GL_PROXY_TEXTURE_COLOR_TABLE_SGI:
+ case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
+ case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
+ case GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP:
+ return 0;
+ }
+
+ if (width < 0 || height < 0 || depth < 0) {
+ return 0;
+ }
+
+ /*
+ ** Zero is returned if either format or type are invalid.
+ */
+ components = __glElementsPerGroup(format,type);
+ if (type == GL_BITMAP) {
+ if (format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX) {
+ bytes_per_row = (width + 7) >> 3;
+ } else {
+ return 0;
+ }
+ } else {
+ bytes_per_row = __glBytesPerElement(type) * width;
+ }
+
+ return bytes_per_row * height * depth * components;
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/dri_glx.c b/nx-X11/extras/Mesa/src/glx/x11/dri_glx.c
new file mode 100644
index 000000000..516ca508c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/dri_glx.c
@@ -0,0 +1,461 @@
+/**************************************************************************
+
+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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/dri/dri_glx.c,v 1.14 2003/07/16 00:54:00 dawes Exp $ */
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ * Brian Paul <brian@precisioninsight.com>
+ *
+ */
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include <unistd.h>
+#include <X11/Xlibint.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include "glxclient.h"
+#include "xf86dri.h"
+#include "sarea.h"
+#include <stdio.h>
+#include <dlfcn.h>
+#include "dri_glx.h"
+#include <sys/types.h>
+#include <stdarg.h>
+
+#ifndef RTLD_NOW
+#define RTLD_NOW 0
+#endif
+#ifndef RTLD_GLOBAL
+#define RTLD_GLOBAL 0
+#endif
+
+
+#ifndef DEFAULT_DRIVER_DIR
+/* this is normally defined in the Imakefile */
+#define DEFAULT_DRIVER_DIR "/usr/X11R6/lib/modules/dri"
+#endif
+
+static __DRIdriver *Drivers = NULL;
+
+
+/*
+ * printf wrappers
+ */
+
+static void InfoMessageF(const char *f, ...)
+{
+ va_list args;
+ const char *env;
+
+ if ((env = getenv("LIBGL_DEBUG")) && strstr(env, "verbose")) {
+ fprintf(stderr, "libGL: ");
+ va_start(args, f);
+ vfprintf(stderr, f, args);
+ va_end(args);
+ }
+}
+
+static void ErrorMessageF(const char *f, ...)
+{
+ va_list args;
+
+ if (getenv("LIBGL_DEBUG")) {
+ fprintf(stderr, "libGL error: ");
+ va_start(args, f);
+ vfprintf(stderr, f, args);
+ va_end(args);
+ }
+}
+
+
+/**
+ * Extract the ith directory path out of a colon-separated list of paths. No
+ * more than \c dirLen characters, including the terminating \c NUL, will be
+ * written to \c dir.
+ *
+ * \param index Index of path to extract (starting at zero)
+ * \param paths The colon-separated list of paths
+ * \param dirLen Maximum length of result to store in \c dir
+ * \param dir Buffer to hold the extracted directory path
+ *
+ * \returns
+ * The number of characters that would have been written to \c dir had there
+ * been enough room. This does not include the terminating \c NUL. When
+ * extraction fails, zero will be returned.
+ *
+ * \todo
+ * It seems like this function could be rewritten to use \c strchr.
+ */
+static size_t
+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 0;
+ }
+ 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;
+
+ return( end - start );
+}
+
+
+/**
+ * Versioned name of the expected \c __driCreateNewScreen function.
+ *
+ * The version of the last incompatible loader/driver inteface change is
+ * appended to the name of the \c __driCreateNewScreen function. This
+ * prevents loaders from trying to load drivers that are too old.
+ *
+ * \todo
+ * Create a macro or something so that this is automatically updated.
+ */
+static const char createNewScreenName[] = "__driCreateNewScreen_20050727";
+
+
+/**
+ * Try to \c dlopen the named driver.
+ *
+ * This function adds the "_dri.so" suffix to the driver name and searches the
+ * directories specified by the \c LIBGL_DRIVERS_PATH environment variable in
+ * order to find the driver.
+ *
+ * \param driverName - a name like "tdfx", "i810", "mga", etc.
+ *
+ * \returns
+ * A handle from \c dlopen, or \c NULL if driver file not found.
+ */
+static __DRIdriver *OpenDriver(const char *driverName)
+{
+ char *libPaths = NULL;
+ char libDir[1000];
+ int i;
+ __DRIdriver *driver;
+
+ /* First, search Drivers list to see if we've already opened this driver */
+ for (driver = Drivers; driver; driver = driver->next) {
+ if (strcmp(driver->name, driverName) == 0) {
+ /* found it */
+ return driver;
+ }
+ }
+
+ 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 ; ExtractDir(i, libPaths, 1000, libDir) != 0 ; i++ ) {
+ char realDriverName[200];
+ void *handle = NULL;
+
+
+ /* If TLS support is enabled, try to open the TLS version of the driver
+ * binary first. If that fails, try the non-TLS version.
+ */
+#ifdef GLX_USE_TLS
+ snprintf(realDriverName, 200, "%s/tls/%s_dri.so", libDir, driverName);
+ InfoMessageF("OpenDriver: trying %s\n", realDriverName);
+ handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL);
+#endif
+
+ if ( handle == NULL ) {
+ snprintf(realDriverName, 200, "%s/%s_dri.so", libDir, driverName);
+ InfoMessageF("OpenDriver: trying %s\n", realDriverName);
+ handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL);
+ }
+
+ if ( handle != NULL ) {
+ /* allocate __DRIdriver struct */
+ driver = (__DRIdriver *) Xmalloc(sizeof(__DRIdriver));
+ if (!driver)
+ return NULL; /* out of memory! */
+ /* init the struct */
+ driver->name = __glXstrdup(driverName);
+ if (!driver->name) {
+ Xfree(driver);
+ return NULL; /* out of memory! */
+ }
+
+ driver->createNewScreenFunc = (PFNCREATENEWSCREENFUNC)
+ dlsym(handle, createNewScreenName);
+
+ if ( driver->createNewScreenFunc == NULL ) {
+ /* If the driver doesn't have this symbol then something's
+ * really, really wrong.
+ */
+ ErrorMessageF("%s not defined in %s_dri.so!\n"
+ "Your driver may be too old for this libGL.\n",
+ createNewScreenName, driverName);
+ Xfree(driver);
+ dlclose(handle);
+ continue;
+ }
+ driver->handle = handle;
+ /* put at head of linked list */
+ driver->next = Drivers;
+ Drivers = driver;
+ return driver;
+ }
+ else {
+ ErrorMessageF("dlopen %s failed (%s)\n", realDriverName, dlerror());
+ }
+ }
+
+ ErrorMessageF("unable to find driver: %s_dri.so\n", driverName);
+ return NULL;
+}
+
+
+/*
+ * Given a display pointer and screen number, determine the name of
+ * the DRI driver for the screen. (I.e. "r128", "tdfx", etc).
+ * Return True for success, False for failure.
+ */
+static Bool GetDriverName(Display *dpy, int scrNum, char **driverName)
+{
+ int directCapable;
+ Bool b;
+ int driverMajor, driverMinor, driverPatch;
+
+ *driverName = NULL;
+
+ if (!XF86DRIQueryDirectRenderingCapable(dpy, scrNum, &directCapable)) {
+ ErrorMessageF("XF86DRIQueryDirectRenderingCapable failed\n");
+ return False;
+ }
+ if (!directCapable) {
+ ErrorMessageF("XF86DRIQueryDirectRenderingCapable returned false\n");
+ return False;
+ }
+
+ b = XF86DRIGetClientDriverName(dpy, scrNum, &driverMajor, &driverMinor,
+ &driverPatch, driverName);
+ if (!b) {
+ ErrorMessageF("Cannot determine driver name for screen %d\n", scrNum);
+ return False;
+ }
+
+ InfoMessageF("XF86DRIGetClientDriverName: %d.%d.%d %s (screen %d)\n",
+ driverMajor, driverMinor, driverPatch, *driverName, scrNum);
+
+ return True;
+}
+
+
+/*
+ * Given a display pointer and screen number, return a __DRIdriver handle.
+ * Return NULL if anything goes wrong.
+ */
+__DRIdriver *driGetDriver(Display *dpy, int scrNum)
+{
+ char *driverName;
+ if (GetDriverName(dpy, scrNum, &driverName)) {
+ __DRIdriver *ret;
+ ret = OpenDriver(driverName);
+ if (driverName)
+ Xfree(driverName);
+ return ret;
+ }
+ return NULL;
+}
+
+
+/*
+ * Exported function for querying the DRI driver for a given screen.
+ *
+ * The returned char pointer points to a static array that will be
+ * overwritten by subsequent calls.
+ */
+const char *glXGetScreenDriver (Display *dpy, int scrNum) {
+ static char ret[32];
+ char *driverName;
+ if (GetDriverName(dpy, scrNum, &driverName)) {
+ int len;
+ if (!driverName)
+ return NULL;
+ len = strlen (driverName);
+ if (len >= 31)
+ return NULL;
+ memcpy (ret, driverName, len+1);
+ Xfree(driverName);
+ return ret;
+ }
+ return NULL;
+}
+
+
+/*
+ * Exported function for obtaining a driver's option list (UTF-8 encoded XML).
+ *
+ * The returned char pointer points directly into the driver. Therefore
+ * it should be treated as a constant.
+ *
+ * If the driver was not found or does not support configuration NULL is
+ * returned.
+ *
+ * Note: The driver remains opened after this function returns.
+ */
+const char *glXGetDriverConfig (const char *driverName) {
+ __DRIdriver *driver = OpenDriver (driverName);
+ if (driver)
+ return dlsym (driver->handle, "__driConfigOptions");
+ else
+ return NULL;
+}
+
+
+/* This function isn't currently used.
+ */
+static void driDestroyDisplay(Display *dpy, void *private)
+{
+ __DRIdisplayPrivate *pdpyp = (__DRIdisplayPrivate *)private;
+
+ if (pdpyp) {
+ const int numScreens = ScreenCount(dpy);
+ int i;
+ for (i = 0; i < numScreens; i++) {
+ if (pdpyp->libraryHandles[i])
+ dlclose(pdpyp->libraryHandles[i]);
+ }
+ Xfree(pdpyp->libraryHandles);
+ Xfree(pdpyp);
+ }
+}
+
+
+/*
+ * Allocate, initialize and return a __DRIdisplayPrivate object.
+ * This is called from __glXInitialize() when we are given a new
+ * display pointer.
+ */
+void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp)
+{
+ const int numScreens = ScreenCount(dpy);
+ __DRIdisplayPrivate *pdpyp;
+ int eventBase, errorBase;
+ int major, minor, patch;
+ int scrn;
+
+ /* Initialize these fields to NULL in case we fail.
+ * If we don't do this we may later get segfaults trying to free random
+ * addresses when the display is closed.
+ */
+ pdisp->private = NULL;
+ pdisp->destroyDisplay = NULL;
+
+ if (!XF86DRIQueryExtension(dpy, &eventBase, &errorBase)) {
+ return NULL;
+ }
+
+ if (!XF86DRIQueryVersion(dpy, &major, &minor, &patch)) {
+ return NULL;
+ }
+
+ pdpyp = (__DRIdisplayPrivate *)Xmalloc(sizeof(__DRIdisplayPrivate));
+ if (!pdpyp) {
+ return NULL;
+ }
+
+ pdpyp->driMajor = major;
+ pdpyp->driMinor = minor;
+ pdpyp->driPatch = patch;
+
+ pdisp->destroyDisplay = driDestroyDisplay;
+
+ /* allocate array of pointers to createNewScreen funcs */
+ pdisp->createNewScreen = (PFNCREATENEWSCREENFUNC *)
+ Xmalloc(numScreens * sizeof(void *));
+ if (!pdisp->createNewScreen) {
+ Xfree(pdpyp);
+ return NULL;
+ }
+
+ /* allocate array of library handles */
+ pdpyp->libraryHandles = (void **) Xmalloc(numScreens * sizeof(void*));
+ if (!pdpyp->libraryHandles) {
+ Xfree(pdisp->createNewScreen);
+ Xfree(pdpyp);
+ return NULL;
+ }
+
+ /* dynamically discover DRI drivers for all screens, saving each
+ * driver's "__driCreateScreen" function pointer. That's the bootstrap
+ * entrypoint for all DRI drivers.
+ */
+ for (scrn = 0; scrn < numScreens; scrn++) {
+ __DRIdriver *driver = driGetDriver(dpy, scrn);
+ if (driver) {
+ pdisp->createNewScreen[scrn] = driver->createNewScreenFunc;
+ pdpyp->libraryHandles[scrn] = driver->handle;
+ }
+ else {
+ pdisp->createNewScreen[scrn] = NULL;
+ pdpyp->libraryHandles[scrn] = NULL;
+ }
+ }
+
+ return (void *)pdpyp;
+}
+
+#endif /* GLX_DIRECT_RENDERING */
diff --git a/nx-X11/extras/Mesa/src/glx/x11/dri_glx.h b/nx-X11/extras/Mesa/src/glx/x11/dri_glx.h
new file mode 100644
index 000000000..75561685c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/dri_glx.h
@@ -0,0 +1,61 @@
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ * Brian Paul <brian@precisioninsight.com>
+ *
+ */
+
+#ifndef _DRI_GLX_H_
+#define _DRI_GLX_H_
+
+#ifdef GLX_DIRECT_RENDERING
+
+struct __DRIdisplayPrivateRec {
+ /*
+ ** XFree86-DRI version information
+ */
+ int driMajor;
+ int driMinor;
+ int driPatch;
+
+ /*
+ ** Array of library handles [indexed by screen number]
+ */
+ void **libraryHandles;
+};
+
+typedef struct __DRIdisplayPrivateRec __DRIdisplayPrivate;
+typedef struct __DRIscreenPrivateRec __DRIscreenPrivate;
+typedef struct __DRIvisualPrivateRec __DRIvisualPrivate;
+typedef struct __DRIcontextPrivateRec __DRIcontextPrivate;
+typedef struct __DRIdrawablePrivateRec __DRIdrawablePrivate;
+
+#endif
+#endif /* _DRI_GLX_H_ */
diff --git a/nx-X11/extras/Mesa/src/glx/x11/eval.c b/nx-X11/extras/Mesa/src/glx/x11/eval.c
new file mode 100644
index 000000000..0f94e6da6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/eval.c
@@ -0,0 +1,132 @@
+/* $XFree86$ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#include "packrender.h"
+
+/*
+** Routines to pack evaluator maps into the transport buffer. Maps are
+** allowed to have extra arbitrary data, so these routines extract just
+** the information that the GL needs.
+*/
+
+void __glFillMap1f(GLint k, GLint order, GLint stride,
+ const GLfloat *points, GLubyte *pc)
+{
+ if (stride == k) {
+ /* Just copy the data */
+ __GLX_PUT_FLOAT_ARRAY(0, points, order * k);
+ } else {
+ GLint i;
+
+ for (i = 0; i < order; i++) {
+ __GLX_PUT_FLOAT_ARRAY(0, points, k);
+ points += stride;
+ pc += k * __GLX_SIZE_FLOAT32;
+ }
+ }
+}
+
+void __glFillMap1d(GLint k, GLint order, GLint stride,
+ const GLdouble *points, GLubyte *pc)
+{
+ if (stride == k) {
+ /* Just copy the data */
+ __GLX_PUT_DOUBLE_ARRAY(0, points, order * k);
+ } else {
+ GLint i;
+ for (i = 0; i < order; i++) {
+ __GLX_PUT_DOUBLE_ARRAY(0, points, k);
+ points += stride;
+ pc += k * __GLX_SIZE_FLOAT64;
+ }
+ }
+}
+
+void __glFillMap2f(GLint k, GLint majorOrder, GLint minorOrder,
+ GLint majorStride, GLint minorStride,
+ const GLfloat *points, GLfloat *data)
+{
+ GLint i, j, x;
+
+ if ((minorStride == k) && (majorStride == minorOrder*k)) {
+ /* Just copy the data */
+ __GLX_MEM_COPY(data, points, majorOrder * majorStride *
+ __GLX_SIZE_FLOAT32);
+ return;
+ }
+ for (i = 0; i < majorOrder; i++) {
+ for (j = 0; j < minorOrder; j++) {
+ for (x = 0; x < k; x++) {
+ data[x] = points[x];
+ }
+ points += minorStride;
+ data += k;
+ }
+ points += majorStride - minorStride * minorOrder;
+ }
+}
+
+void __glFillMap2d(GLint k, GLint majorOrder, GLint minorOrder,
+ GLint majorStride, GLint minorStride,
+ const GLdouble *points, GLdouble *data)
+{
+ int i,j,x;
+
+ if ((minorStride == k) && (majorStride == minorOrder*k)) {
+ /* Just copy the data */
+ __GLX_MEM_COPY(data, points, majorOrder * majorStride *
+ __GLX_SIZE_FLOAT64);
+ return;
+ }
+
+#ifdef __GLX_ALIGN64
+ x = k * __GLX_SIZE_FLOAT64;
+#endif
+ for (i = 0; i<majorOrder; i++) {
+ for (j = 0; j<minorOrder; j++) {
+#ifdef __GLX_ALIGN64
+ __GLX_MEM_COPY(data, points, x);
+#else
+ for (x = 0; x<k; x++) {
+ data[x] = points[x];
+ }
+#endif
+ points += minorStride;
+ data += k;
+ }
+ points += majorStride - minorStride * minorOrder;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/glx_pbuffer.c b/nx-X11/extras/Mesa/src/glx/x11/glx_pbuffer.c
new file mode 100644
index 000000000..83c550559
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/glx_pbuffer.c
@@ -0,0 +1,556 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file glx_pbuffer.c
+ * Implementation of pbuffer related functions.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include <inttypes.h>
+#include "glxclient.h"
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/Xext.h>
+#include <assert.h>
+#include <string.h>
+#include "glapi.h"
+#include "glxextensions.h"
+#include "glcontextmodes.h"
+#include "glheader.h"
+
+static void ChangeDrawableAttribute( Display * dpy, GLXDrawable drawable,
+ const CARD32 * attribs, size_t num_attribs );
+
+static void DestroyPbuffer( Display * dpy, GLXDrawable drawable );
+
+static GLXDrawable CreatePbuffer( Display *dpy,
+ const __GLcontextModes * fbconfig, unsigned int width, unsigned int height,
+ const int *attrib_list, GLboolean size_in_attribs );
+
+static int GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
+ int attribute, unsigned int *value );
+
+
+/**
+ * Change a drawable's attribute.
+ *
+ * This function is used to implement \c glXSelectEvent and
+ * \c glXSelectEventSGIX.
+ *
+ * \note
+ * This function dynamically determines whether to use the SGIX_pbuffer
+ * version of the protocol or the GLX 1.3 version of the protocol.
+ *
+ * \todo
+ * This function needs to be modified to work with direct-rendering drivers.
+ */
+static void
+ChangeDrawableAttribute( Display * dpy, GLXDrawable drawable,
+ const CARD32 * attribs, size_t num_attribs )
+{
+ __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+ CARD32 * output;
+
+
+ if ( (dpy == NULL) || (drawable == 0) ) {
+ return;
+ }
+
+
+ LockDisplay(dpy);
+
+ if ( (priv->majorVersion > 1) || (priv->minorVersion >= 3) ) {
+ xGLXChangeDrawableAttributesReq *req;
+
+ GetReqExtra( GLXChangeDrawableAttributes, 8 + (8 * num_attribs), req );
+ output = (CARD32 *) (req + 1);
+
+ req->reqType = __glXSetupForCommand(dpy);
+ req->glxCode = X_GLXChangeDrawableAttributes;
+ req->drawable = drawable;
+ req->numAttribs = (CARD32) num_attribs;
+ }
+ else {
+ xGLXVendorPrivateWithReplyReq *vpreq;
+
+ GetReqExtra( GLXVendorPrivateWithReply, 4 + (8 * num_attribs), vpreq );
+ output = (CARD32 *) (vpreq + 1);
+
+ vpreq->reqType = __glXSetupForCommand(dpy);
+ vpreq->glxCode = X_GLXVendorPrivateWithReply;
+ vpreq->vendorCode = X_GLXvop_ChangeDrawableAttributesSGIX;
+
+ output[0] = (CARD32) drawable;
+ output++;
+ }
+
+ (void) memcpy( output, attribs, sizeof( CARD32 ) * 2 * num_attribs );
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return;
+}
+
+
+/**
+ * Destroy a pbuffer.
+ *
+ * This function is used to implement \c glXDestroyPbuffer and
+ * \c glXDestroyGLXPbufferSGIX.
+ *
+ * \note
+ * This function dynamically determines whether to use the SGIX_pbuffer
+ * version of the protocol or the GLX 1.3 version of the protocol.
+ *
+ * \todo
+ * This function needs to be modified to work with direct-rendering drivers.
+ */
+static void
+DestroyPbuffer( Display * dpy, GLXDrawable drawable )
+{
+ __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+
+ if ( (dpy == NULL) || (drawable == 0) ) {
+ return;
+ }
+
+
+ LockDisplay(dpy);
+
+ if ( (priv->majorVersion > 1) || (priv->minorVersion >= 3) ) {
+ xGLXDestroyPbufferReq * req;
+
+ GetReqExtra( GLXDestroyPbuffer, 4, req );
+ req->reqType = __glXSetupForCommand(dpy);
+ req->glxCode = X_GLXDestroyPbuffer;
+ req->pbuffer = (GLXPbuffer) drawable;
+ }
+ else {
+ xGLXVendorPrivateWithReplyReq *vpreq;
+ CARD32 * data;
+
+ GetReqExtra( GLXVendorPrivateWithReply, 4, vpreq );
+ data = (CARD32 *) (vpreq + 1);
+
+ data[0] = (CARD32) drawable;
+
+ vpreq->reqType = __glXSetupForCommand(dpy);
+ vpreq->glxCode = X_GLXVendorPrivateWithReply;
+ vpreq->vendorCode = X_GLXvop_DestroyGLXPbufferSGIX;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return;
+}
+
+
+/**
+ * Get a drawable's attribute.
+ *
+ * This function is used to implement \c glXGetSelectedEvent and
+ * \c glXGetSelectedEventSGIX.
+ *
+ * \note
+ * This function dynamically determines whether to use the SGIX_pbuffer
+ * version of the protocol or the GLX 1.3 version of the protocol.
+ *
+ * \todo
+ * The number of attributes returned is likely to be small, probably less than
+ * 10. Given that, this routine should try to use an array on the stack to
+ * capture the reply rather than always calling Xmalloc.
+ *
+ * \todo
+ * This function needs to be modified to work with direct-rendering drivers.
+ */
+static int
+GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
+ int attribute, unsigned int *value )
+{
+ __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+ xGLXGetDrawableAttributesReply reply;
+ CARD32 * data;
+ unsigned int length;
+ unsigned int i;
+ unsigned int num_attributes;
+ GLboolean use_glx_1_3 = ((priv->majorVersion > 1)
+ || (priv->minorVersion >= 3));
+
+
+ if ( (dpy == NULL) || (drawable == 0) ) {
+ return 0;
+ }
+
+
+ LockDisplay(dpy);
+
+ if ( use_glx_1_3 ) {
+ xGLXGetDrawableAttributesReq *req;
+
+ GetReqExtra( GLXGetDrawableAttributes, 4, req );
+ req->reqType = __glXSetupForCommand(dpy);
+ req->glxCode = X_GLXGetDrawableAttributes;
+ req->drawable = drawable;
+ }
+ else {
+ xGLXVendorPrivateWithReplyReq *vpreq;
+
+ GetReqExtra( GLXVendorPrivateWithReply, 4, vpreq );
+ data = (CARD32 *) (vpreq + 1);
+ data[0] = (CARD32) drawable;
+
+ vpreq->reqType = __glXSetupForCommand(dpy);
+ vpreq->glxCode = X_GLXVendorPrivateWithReply;
+ vpreq->vendorCode = X_GLXvop_GetDrawableAttributesSGIX;
+ }
+
+ _XReply(dpy, (xReply*) &reply, 0, False);
+
+ length = reply.length;
+ num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2;
+ data = (CARD32 *) Xmalloc( length * sizeof(CARD32) );
+ if ( data == NULL ) {
+ /* Throw data on the floor */
+ _XEatData(dpy, length);
+ } else {
+ _XRead(dpy, (char *)data, length * sizeof(CARD32) );
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+
+ /* Search the set of returned attributes for the attribute requested by
+ * the caller.
+ */
+
+ for ( i = 0 ; i < num_attributes ; i++ ) {
+ if ( data[i*2] == attribute ) {
+ *value = data[ (i*2) + 1 ];
+ break;
+ }
+ }
+
+ Xfree( data );
+
+ return 0;
+}
+
+
+/**
+ * Create a non-pbuffer GLX drawable.
+ *
+ * \todo
+ * This function needs to be modified to work with direct-rendering drivers.
+ */
+static GLXDrawable
+CreateDrawable( Display *dpy, const __GLcontextModes * fbconfig,
+ Drawable drawable, const int *attrib_list,
+ CARD8 glxCode )
+{
+ xGLXCreateWindowReq * req;
+ CARD32 * data;
+ unsigned int i;
+
+ i = 0;
+ if (attrib_list) {
+ while (attrib_list[i * 2] != None)
+ i++;
+ }
+
+ LockDisplay(dpy);
+ GetReqExtra( GLXCreateWindow, 8 * i, req );
+ data = (CARD32 *) (req + 1);
+
+ req->reqType = __glXSetupForCommand(dpy);
+ req->glxCode = glxCode;
+ req->screen = (CARD32) fbconfig->screen;
+ req->fbconfig = fbconfig->fbconfigID;
+ req->window = (GLXPbuffer) drawable;
+ req->glxwindow = (GLXWindow) XAllocID(dpy);
+ req->numAttribs = (CARD32) i;
+
+ memcpy( data, attrib_list, 8 * i );
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return (GLXDrawable)req->glxwindow;
+}
+
+
+/**
+ * Destroy a non-pbuffer GLX drawable.
+ *
+ * \todo
+ * This function needs to be modified to work with direct-rendering drivers.
+ */
+static void
+DestroyDrawable( Display * dpy, GLXDrawable drawable, CARD32 glxCode )
+{
+ xGLXDestroyPbufferReq * req;
+
+ if ( (dpy == NULL) || (drawable == 0) ) {
+ return;
+ }
+
+
+ LockDisplay(dpy);
+
+ GetReqExtra( GLXDestroyPbuffer, 4, req );
+ req->reqType = __glXSetupForCommand(dpy);
+ req->glxCode = glxCode;
+ req->pbuffer = (GLXPbuffer) drawable;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return;
+}
+
+
+/**
+ * Create a pbuffer.
+ *
+ * This function is used to implement \c glXCreatePbuffer and
+ * \c glXCreateGLXPbufferSGIX.
+ *
+ * \note
+ * This function dynamically determines whether to use the SGIX_pbuffer
+ * version of the protocol or the GLX 1.3 version of the protocol.
+ *
+ * \todo
+ * This function needs to be modified to work with direct-rendering drivers.
+ */
+static GLXDrawable
+CreatePbuffer( Display *dpy, const __GLcontextModes * fbconfig,
+ unsigned int width, unsigned int height,
+ const int *attrib_list, GLboolean size_in_attribs )
+{
+ __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+ GLXDrawable id = 0;
+ CARD32 * data;
+ unsigned int i;
+
+ i = 0;
+ if (attrib_list) {
+ while (attrib_list[i * 2])
+ i++;
+ }
+
+ LockDisplay(dpy);
+ id = XAllocID(dpy);
+
+ if ( (priv->majorVersion > 1) || (priv->minorVersion >= 3) ) {
+ xGLXCreatePbufferReq * req;
+ unsigned int extra = (size_in_attribs) ? 0 : 2;
+
+ GetReqExtra( GLXCreatePbuffer, (8 * (i + extra)), req );
+ data = (CARD32 *) (req + 1);
+
+ req->reqType = __glXSetupForCommand(dpy);
+ req->glxCode = X_GLXCreatePbuffer;
+ req->screen = (CARD32) fbconfig->screen;
+ req->fbconfig = fbconfig->fbconfigID;
+ req->pbuffer = (GLXPbuffer) id;
+ req->numAttribs = (CARD32) (i + extra);
+
+ if ( ! size_in_attribs ) {
+ data[(2 * i) + 0] = GLX_PBUFFER_WIDTH;
+ data[(2 * i) + 1] = width;
+ data[(2 * i) + 2] = GLX_PBUFFER_HEIGHT;
+ data[(2 * i) + 3] = height;
+ data += 4;
+ }
+ }
+ else {
+ xGLXVendorPrivateReq *vpreq;
+
+ GetReqExtra( GLXVendorPrivate, 20 + (8 * i), vpreq );
+ data = (CARD32 *) (vpreq + 1);
+
+ vpreq->reqType = __glXSetupForCommand(dpy);
+ vpreq->glxCode = X_GLXVendorPrivate;
+ vpreq->vendorCode = X_GLXvop_CreateGLXPbufferSGIX;
+
+ data[0] = (CARD32) fbconfig->screen;
+ data[1] = (CARD32) fbconfig->fbconfigID;
+ data[2] = (CARD32) id;
+ data[3] = (CARD32) width;
+ data[4] = (CARD32) height;
+ data += 5;
+ }
+
+ (void) memcpy( data, attrib_list, sizeof(CARD32) * 2 * i );
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return id;
+}
+
+
+/**
+ * Create a new pbuffer.
+ */
+PUBLIC GLXPbufferSGIX
+glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config,
+ unsigned int width, unsigned int height,
+ int *attrib_list)
+{
+ return (GLXPbufferSGIX) CreatePbuffer( dpy, (__GLcontextModes *) config,
+ width, height,
+ attrib_list, GL_FALSE );
+}
+
+
+/**
+ * Create a new pbuffer.
+ */
+PUBLIC GLXPbuffer
+glXCreatePbuffer(Display *dpy, GLXFBConfig config, const int *attrib_list)
+{
+ return (GLXPbuffer) CreatePbuffer( dpy, (__GLcontextModes *) config,
+ 0, 0,
+ attrib_list, GL_TRUE );
+}
+
+
+/**
+ * Destroy an existing pbuffer.
+ */
+PUBLIC void
+glXDestroyPbuffer(Display *dpy, GLXPbuffer pbuf)
+{
+ DestroyPbuffer( dpy, pbuf );
+}
+
+
+/**
+ * Query an attribute of a drawable.
+ */
+PUBLIC void
+glXQueryDrawable(Display *dpy, GLXDrawable drawable,
+ int attribute, unsigned int *value)
+{
+ GetDrawableAttribute( dpy, drawable, attribute, value );
+}
+
+
+/**
+ * Query an attribute of a pbuffer.
+ */
+PUBLIC int
+glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX drawable,
+ int attribute, unsigned int *value)
+{
+ return GetDrawableAttribute( dpy, drawable, attribute, value );
+}
+
+
+/**
+ * Select the event mask for a drawable.
+ */
+PUBLIC void
+glXSelectEvent(Display *dpy, GLXDrawable drawable, unsigned long mask)
+{
+ CARD32 attribs[2];
+
+ attribs[0] = (CARD32) GLX_EVENT_MASK;
+ attribs[1] = (CARD32) mask;
+
+ ChangeDrawableAttribute( dpy, drawable, attribs, 1 );
+}
+
+
+/**
+ * Get the selected event mask for a drawable.
+ */
+PUBLIC void
+glXGetSelectedEvent(Display *dpy, GLXDrawable drawable, unsigned long *mask)
+{
+ unsigned int value;
+
+
+ /* The non-sense with value is required because on LP64 platforms
+ * sizeof(unsigned int) != sizeof(unsigned long). On little-endian
+ * we could just type-cast the pointer, but why?
+ */
+
+ GetDrawableAttribute( dpy, drawable, GLX_EVENT_MASK_SGIX, & value );
+ *mask = value;
+}
+
+
+PUBLIC GLXPixmap
+glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
+ const int *attrib_list )
+{
+ return CreateDrawable( dpy, (__GLcontextModes *) config,
+ (Drawable) pixmap, attrib_list,
+ X_GLXCreatePixmap );
+}
+
+
+PUBLIC GLXWindow
+glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
+ const int *attrib_list )
+{
+ return CreateDrawable( dpy, (__GLcontextModes *) config,
+ (Drawable) win, attrib_list,
+ X_GLXCreateWindow );
+}
+
+
+PUBLIC void
+glXDestroyPixmap(Display *dpy, GLXPixmap pixmap)
+{
+ DestroyDrawable( dpy, (GLXDrawable) pixmap, X_GLXDestroyPixmap );
+}
+
+
+PUBLIC void
+glXDestroyWindow(Display *dpy, GLXWindow win)
+{
+ DestroyDrawable( dpy, (GLXDrawable) win, X_GLXDestroyWindow );
+}
+
+
+PUBLIC GLX_ALIAS_VOID(glXDestroyGLXPbufferSGIX,
+ (Display *dpy, GLXPbufferSGIX pbuf),
+ (dpy, pbuf),
+ glXDestroyPbuffer)
+
+PUBLIC GLX_ALIAS_VOID(glXSelectEventSGIX,
+ (Display *dpy, GLXDrawable drawable, unsigned long mask),
+ (dpy, drawable, mask),
+ glXSelectEvent)
+
+PUBLIC GLX_ALIAS_VOID(glXGetSelectedEventSGIX,
+ (Display *dpy, GLXDrawable drawable, unsigned long *mask),
+ (dpy, drawable, mask),
+ glXGetSelectedEvent)
diff --git a/nx-X11/extras/Mesa/src/glx/x11/glx_query.c b/nx-X11/extras/Mesa/src/glx/x11/glx_query.c
new file mode 100644
index 000000000..e93cd2afd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/glx_query.c
@@ -0,0 +1,102 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file glx_query.c
+ * Generic utility functions to query internal data from the server.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include "glxclient.h"
+
+/**
+ * GLX protocol structure for the ficticious "GXLGenericGetString" request.
+ *
+ * This is a non-existant protocol packet. It just so happens that all of
+ * the real protocol packets used to request a string from the server have
+ * an identical binary layout. The only difference between them is the
+ * meaning of the \c for_whom field and the value of the \c glxCode.
+ */
+typedef struct GLXGenericGetString {
+ CARD8 reqType;
+ CARD8 glxCode;
+ CARD16 length B16;
+ CARD32 for_whom B32;
+ CARD32 name B32;
+} xGLXGenericGetStringReq;
+
+/* These defines are only needed to make the GetReq macro happy.
+ */
+#define sz_xGLXGenericGetStringReq 12
+#define X_GLXGenericGetString 0
+
+/**
+ * Query the Server GLX string and cache it in the display private.
+ * This routine will allocate the necessay space for the string.
+ */
+char *
+__glXGetStringFromServer( Display * dpy, int opcode, CARD32 glxCode,
+ CARD32 for_whom, CARD32 name )
+{
+ xGLXGenericGetStringReq *req;
+ xGLXSingleReply reply;
+ int length;
+ int numbytes;
+ char * buf;
+
+
+ LockDisplay( dpy );
+
+
+ /* All of the GLX protocol requests for getting a string from the server
+ * look the same. The exact meaning of the for_whom field is usually
+ * either the screen number (for glXQueryServerString) or the context tag
+ * (for GLXSingle).
+ */
+
+ GetReq( GLXGenericGetString, req );
+ req->reqType = opcode;
+ req->glxCode = glxCode;
+ req->for_whom = for_whom;
+ req->name = name;
+
+ _XReply( dpy, (xReply *) & reply, 0, False );
+
+ length = reply.length * 4;
+ numbytes = reply.size;
+
+ buf = (char *) Xmalloc( numbytes );
+ if ( buf != NULL ) {
+ _XRead( dpy, buf, numbytes );
+ length -= numbytes;
+ }
+
+ _XEatData( dpy, length );
+
+ UnlockDisplay( dpy );
+ SyncHandle();
+
+ return buf;
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/glx_texture_compression.c b/nx-X11/extras/Mesa/src/glx/x11/glx_texture_compression.c
new file mode 100644
index 000000000..567685801
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/glx_texture_compression.c
@@ -0,0 +1,347 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file glx_texture_compression.c
+ * Contains the routines required to implement GLX protocol for
+ * ARB_texture_compression and related extensions.
+ *
+ * \sa http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_compression.txt
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include "packrender.h"
+#include "packsingle.h"
+#include "indirect.h"
+
+#include <assert.h>
+
+
+void
+__indirect_glGetCompressedTexImageARB( GLenum target, GLint level,
+ GLvoid * img )
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXGetTexImageReply reply;
+ size_t image_bytes;
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN( X_GLsop_GetCompressedTexImage, 8 );
+ __GLX_SINGLE_PUT_LONG( 0, target );
+ __GLX_SINGLE_PUT_LONG( 4, level );
+ __GLX_SINGLE_READ_XREPLY();
+
+ image_bytes = reply.width;
+ assert( image_bytes <= ((4 * reply.length) - 0) );
+ assert( image_bytes >= ((4 * reply.length) - 3) );
+
+ if ( image_bytes != 0 ) {
+ _XRead( dpy, (char *) img, image_bytes );
+ if ( image_bytes < (4 * reply.length) ) {
+ _XEatData( dpy, (4 * reply.length) - image_bytes );
+ }
+ }
+
+ __GLX_SINGLE_END();
+}
+
+
+/**
+ * Internal function used for \c glCompressedTexImage1D and
+ * \c glCompressedTexImage2D.
+ */
+static void
+CompressedTexImage1D2D( GLenum target, GLint level,
+ GLenum internal_format,
+ GLsizei width, GLsizei height,
+ GLint border, GLsizei image_size,
+ const GLvoid *data, CARD32 rop )
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if ( gc->currentDpy == NULL ) {
+ return;
+ }
+
+ if ( (target == GL_PROXY_TEXTURE_1D)
+ || (target == GL_PROXY_TEXTURE_2D)
+ || (target == GL_PROXY_TEXTURE_CUBE_MAP) ) {
+ compsize = 0;
+ }
+ else {
+ compsize = image_size;
+ }
+
+ cmdlen = __GLX_PAD( __GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE
+ + compsize );
+ if ( cmdlen <= gc->maxSmallRenderCommandSize ) {
+ __GLX_BEGIN_VARIABLE( rop, cmdlen );
+ __GLX_PUT_LONG( 4, target );
+ __GLX_PUT_LONG( 8, level );
+ __GLX_PUT_LONG( 12, internal_format );
+ __GLX_PUT_LONG( 16, width );
+ __GLX_PUT_LONG( 20, height );
+ __GLX_PUT_LONG( 24, border );
+ __GLX_PUT_LONG( 28, image_size );
+ if ( compsize != 0 ) {
+ __GLX_PUT_CHAR_ARRAY( __GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE,
+ data, image_size );
+ }
+ __GLX_END( cmdlen );
+ }
+ else {
+ assert( compsize != 0 );
+
+ __GLX_BEGIN_VARIABLE_LARGE( rop, cmdlen + 4 );
+ __GLX_PUT_LONG( 8, target );
+ __GLX_PUT_LONG( 12, level );
+ __GLX_PUT_LONG( 16, internal_format );
+ __GLX_PUT_LONG( 20, width );
+ __GLX_PUT_LONG( 24, height );
+ __GLX_PUT_LONG( 28, border );
+ __GLX_PUT_LONG( 32, image_size );
+ __glXSendLargeCommand( gc, gc->pc,
+ __GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE + 4,
+ data, image_size );
+ }
+}
+
+
+/**
+ * Internal function used for \c glCompressedTexSubImage1D and
+ * \c glCompressedTexSubImage2D.
+ */
+static void
+CompressedTexSubImage1D2D( GLenum target, GLint level,
+ GLsizei xoffset, GLsizei yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLsizei image_size,
+ const GLvoid *data, CARD32 rop )
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if ( gc->currentDpy == NULL ) {
+ return;
+ }
+
+ if ( target == GL_PROXY_TEXTURE_3D ) {
+ compsize = 0;
+ }
+ else {
+ compsize = image_size;
+ }
+
+ cmdlen = __GLX_PAD( __GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE
+ + compsize );
+ if ( cmdlen <= gc->maxSmallRenderCommandSize ) {
+ __GLX_BEGIN_VARIABLE( rop, cmdlen );
+ __GLX_PUT_LONG( 4, target );
+ __GLX_PUT_LONG( 8, level );
+ __GLX_PUT_LONG( 12, xoffset );
+ __GLX_PUT_LONG( 16, yoffset );
+ __GLX_PUT_LONG( 20, width );
+ __GLX_PUT_LONG( 24, height );
+ __GLX_PUT_LONG( 28, format );
+ __GLX_PUT_LONG( 32, image_size );
+ if ( compsize != 0 ) {
+ __GLX_PUT_CHAR_ARRAY( __GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE,
+ data, image_size );
+ }
+ __GLX_END( cmdlen );
+ }
+ else {
+ assert( compsize != 0 );
+
+ __GLX_BEGIN_VARIABLE_LARGE( rop, cmdlen + 4 );
+ __GLX_PUT_LONG( 8, target );
+ __GLX_PUT_LONG( 12, level );
+ __GLX_PUT_LONG( 16, xoffset );
+ __GLX_PUT_LONG( 20, yoffset );
+ __GLX_PUT_LONG( 24, width );
+ __GLX_PUT_LONG( 28, height );
+ __GLX_PUT_LONG( 32, format );
+ __GLX_PUT_LONG( 36, image_size );
+ __glXSendLargeCommand( gc, gc->pc,
+ __GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE + 4,
+ data, image_size );
+ }
+}
+
+
+void
+__indirect_glCompressedTexImage1DARB( GLenum target, GLint level,
+ GLenum internal_format, GLsizei width,
+ GLint border, GLsizei image_size,
+ const GLvoid *data )
+{
+ CompressedTexImage1D2D( target, level, internal_format, width, 0,
+ border, image_size, data,
+ X_GLrop_CompressedTexImage1D );
+}
+
+
+void
+__indirect_glCompressedTexImage2DARB( GLenum target, GLint level,
+ GLenum internal_format,
+ GLsizei width, GLsizei height,
+ GLint border, GLsizei image_size,
+ const GLvoid *data )
+{
+ CompressedTexImage1D2D( target, level, internal_format, width, height,
+ border, image_size, data,
+ X_GLrop_CompressedTexImage2D );
+}
+
+
+void
+__indirect_glCompressedTexImage3DARB( GLenum target, GLint level,
+ GLenum internal_format,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLint border, GLsizei image_size,
+ const GLvoid *data )
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if ( gc->currentDpy == NULL ) {
+ return;
+ }
+
+ cmdlen = __GLX_PAD( __GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE
+ + image_size );
+ if ( cmdlen <= gc->maxSmallRenderCommandSize ) {
+ __GLX_BEGIN_VARIABLE( X_GLrop_CompressedTexImage3D, cmdlen );
+ __GLX_PUT_LONG( 4, target );
+ __GLX_PUT_LONG( 8, level );
+ __GLX_PUT_LONG( 12, internal_format );
+ __GLX_PUT_LONG( 16, width );
+ __GLX_PUT_LONG( 20, height );
+ __GLX_PUT_LONG( 24, depth );
+ __GLX_PUT_LONG( 28, border );
+ __GLX_PUT_LONG( 32, image_size );
+ if ( image_size != 0 ) {
+ __GLX_PUT_CHAR_ARRAY( __GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE,
+ data, image_size );
+ }
+ __GLX_END( cmdlen );
+ }
+ else {
+ __GLX_BEGIN_VARIABLE_LARGE( X_GLrop_CompressedTexImage3D,
+ cmdlen + 4 );
+ __GLX_PUT_LONG( 8, target );
+ __GLX_PUT_LONG( 12, level );
+ __GLX_PUT_LONG( 16, internal_format );
+ __GLX_PUT_LONG( 20, width );
+ __GLX_PUT_LONG( 24, height );
+ __GLX_PUT_LONG( 28, depth );
+ __GLX_PUT_LONG( 32, border );
+ __GLX_PUT_LONG( 36, image_size );
+ __glXSendLargeCommand( gc, gc->pc,
+ __GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE + 4,
+ data, image_size );
+ }
+}
+
+
+void
+__indirect_glCompressedTexSubImage1DARB( GLenum target, GLint level,
+ GLint xoffset,
+ GLsizei width,
+ GLenum format, GLsizei image_size,
+ const GLvoid *data )
+{
+ CompressedTexSubImage1D2D( target, level, xoffset, 0, width, 0,
+ format, image_size, data,
+ X_GLrop_CompressedTexSubImage1D );
+}
+
+
+void
+__indirect_glCompressedTexSubImage2DARB( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLsizei image_size,
+ const GLvoid *data )
+{
+ CompressedTexSubImage1D2D( target, level, xoffset, yoffset, width, height,
+ format, image_size, data,
+ X_GLrop_CompressedTexSubImage2D );
+}
+
+
+void
+__indirect_glCompressedTexSubImage3DARB( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLsizei image_size,
+ const GLvoid *data )
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if ( gc->currentDpy == NULL ) {
+ return;
+ }
+
+ cmdlen = __GLX_PAD( __GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE
+ + image_size );
+ if ( cmdlen <= gc->maxSmallRenderCommandSize ) {
+ __GLX_BEGIN_VARIABLE( X_GLrop_CompressedTexSubImage3D, cmdlen );
+ __GLX_PUT_LONG( 4, target );
+ __GLX_PUT_LONG( 8, level );
+ __GLX_PUT_LONG( 12, xoffset );
+ __GLX_PUT_LONG( 16, yoffset );
+ __GLX_PUT_LONG( 20, zoffset );
+ __GLX_PUT_LONG( 24, width );
+ __GLX_PUT_LONG( 28, height );
+ __GLX_PUT_LONG( 32, depth );
+ __GLX_PUT_LONG( 36, format );
+ __GLX_PUT_LONG( 40, image_size );
+ if ( image_size != 0 ) {
+ __GLX_PUT_CHAR_ARRAY( __GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE,
+ data, image_size );
+ }
+ __GLX_END( cmdlen );
+ }
+ else {
+ __GLX_BEGIN_VARIABLE_LARGE( X_GLrop_CompressedTexSubImage3D,
+ cmdlen + 4 );
+ __GLX_PUT_LONG( 8, target );
+ __GLX_PUT_LONG( 12, level );
+ __GLX_PUT_LONG( 16, xoffset );
+ __GLX_PUT_LONG( 20, yoffset );
+ __GLX_PUT_LONG( 24, zoffset );
+ __GLX_PUT_LONG( 28, width );
+ __GLX_PUT_LONG( 32, height );
+ __GLX_PUT_LONG( 36, depth );
+ __GLX_PUT_LONG( 40, format );
+ __GLX_PUT_LONG( 44, image_size );
+ __glXSendLargeCommand( gc, gc->pc,
+ __GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE + 4,
+ data, image_size );
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/glxclient.h b/nx-X11/extras/Mesa/src/glx/x11/glxclient.h
new file mode 100644
index 000000000..bc9a94c5d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/glxclient.h
@@ -0,0 +1,690 @@
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+*/
+/* $XFree86: xc/lib/GL/glx/glxclient.h,v 1.21 2004/02/09 23:46:31 alanh Exp $ */
+
+/**
+ * \file glxclient.h
+ * Direct rendering support added by Precision Insight, Inc.
+ *
+ * \author Kevin E. Martin <kevin@precisioninsight.com>
+ */
+
+#ifndef _GLX_client_h_
+#define _GLX_client_h_
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include <X11/Xproto.h>
+#include <X11/Xlibint.h>
+#define GLX_GLXEXT_PROTOTYPES
+#include <GL/glx.h>
+#include <GL/glxext.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#ifdef WIN32
+#include <stdint.h>
+#endif
+#include "GL/glxint.h"
+#include "GL/glxproto.h"
+#include "GL/internal/glcore.h"
+#include "glapitable.h"
+#include "glxextensions.h"
+#if defined( USE_XTHREADS )
+# include <X11/Xthreads.h>
+#elif defined( PTHREADS )
+# include <pthread.h>
+#endif
+
+#define GLX_MAJOR_VERSION 1 /* current version numbers */
+#define GLX_MINOR_VERSION 4
+
+#define __GLX_MAX_TEXTURE_UNITS 32
+
+typedef struct __GLXcontextRec __GLXcontext;
+typedef struct __GLXdisplayPrivateRec __GLXdisplayPrivate;
+typedef struct _glapi_table __GLapi;
+
+/************************************************************************/
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include <GL/internal/dri_interface.h>
+
+
+/**
+ * Display dependent methods. This structure is initialized during the
+ * \c driCreateDisplay call.
+ */
+struct __DRIdisplayRec {
+ /**
+ * Method to destroy the private DRI display data.
+ */
+ void (*destroyDisplay)(Display *dpy, void *displayPrivate);
+
+ /**
+ * Opaque pointer to private per display direct rendering data.
+ * \c NULL if direct rendering is not supported on this display.
+ */
+ struct __DRIdisplayPrivateRec *private;
+
+ /**
+ * Array of pointers to methods to create and initialize the private DRI
+ * screen data.
+ */
+ PFNCREATENEWSCREENFUNC * createNewScreen;
+};
+
+
+/*
+** We keep a linked list of these structures, one per DRI device driver.
+*/
+struct __DRIdriverRec {
+ const char *name;
+ void *handle;
+ PFNCREATENEWSCREENFUNC createNewScreenFunc;
+ struct __DRIdriverRec *next;
+};
+
+/*
+** Function to create and DRI display data and initialize the display
+** dependent methods.
+*/
+extern void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp);
+
+extern __DRIdriver *driGetDriver(Display *dpy, int scrNum);
+
+extern void DRI_glXUseXFont( Font font, int first, int count, int listbase );
+
+/*
+** Functions to obtain driver configuration information from a direct
+** rendering client application
+*/
+extern const char *glXGetScreenDriver (Display *dpy, int scrNum);
+
+extern const char *glXGetDriverConfig (const char *driverName);
+
+extern Bool __glXWindowExists(Display *dpy, GLXDrawable draw);
+
+#endif
+
+/************************************************************************/
+
+#define __GL_CLIENT_ATTRIB_STACK_DEPTH 16
+
+typedef struct __GLXpixelStoreModeRec {
+ GLboolean swapEndian;
+ GLboolean lsbFirst;
+ GLuint rowLength;
+ GLuint imageHeight;
+ GLuint imageDepth;
+ GLuint skipRows;
+ GLuint skipPixels;
+ GLuint skipImages;
+ GLuint alignment;
+} __GLXpixelStoreMode;
+
+
+typedef struct __GLXattributeRec {
+ GLuint mask;
+
+ /**
+ * Pixel storage state. Most of the pixel store mode state is kept
+ * here and used by the client code to manage the packing and
+ * unpacking of data sent to/received from the server.
+ */
+ __GLXpixelStoreMode storePack, storeUnpack;
+
+ /**
+ * Is EXT_vertex_array / GL 1.1 DrawArrays protocol specifically
+ * disabled?
+ */
+ GLboolean NoDrawArraysProtocol;
+
+ /**
+ * Vertex Array storage state. The vertex array component
+ * state is stored here and is used to manage the packing of
+ * DrawArrays data sent to the server.
+ */
+ struct array_state_vector * array_state;
+} __GLXattribute;
+
+typedef struct __GLXattributeMachineRec {
+ __GLXattribute *stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];
+ __GLXattribute **stackPointer;
+} __GLXattributeMachine;
+
+/**
+ * GLX state that needs to be kept on the client. One of these records
+ * exist for each context that has been made current by this client.
+ */
+struct __GLXcontextRec {
+ /**
+ * \name Drawing command buffer.
+ *
+ * Drawing commands are packed into this buffer before being sent as a
+ * single GLX protocol request. The buffer is sent when it overflows or
+ * is flushed by \c __glXFlushRenderBuffer. \c pc is the next location
+ * in the buffer to be filled. \c limit is described above in the buffer
+ * slop discussion.
+ *
+ * Commands that require large amounts of data to be transfered will
+ * also use this buffer to hold a header that describes the large
+ * command.
+ *
+ * These must be the first 6 fields since they are static initialized
+ * in the dummy context in glxext.c
+ */
+ /*@{*/
+ GLubyte *buf;
+ GLubyte *pc;
+ GLubyte *limit;
+ GLubyte *bufEnd;
+ GLint bufSize;
+ /*@}*/
+
+ /**
+ * The XID of this rendering context. When the context is created a
+ * new XID is allocated. This is set to None when the context is
+ * destroyed but is still current to some thread. In this case the
+ * context will be freed on next MakeCurrent.
+ */
+ XID xid;
+
+ /**
+ * The XID of the \c shareList context.
+ */
+ XID share_xid;
+
+ /**
+ * Visual id.
+ *
+ * \deprecated
+ * This filed has been largely been replaced by the \c mode field, but
+ * the work is not quite done.
+ */
+ VisualID vid;
+
+ /**
+ * Screen number.
+ */
+ GLint screen;
+
+ /**
+ * \c GL_TRUE if the context was created with ImportContext, which
+ * means the server-side context was created by another X client.
+ */
+ GLboolean imported;
+
+ /**
+ * The context tag returned by MakeCurrent when this context is made
+ * current. This tag is used to identify the context that a thread has
+ * current so that proper server context management can be done. It is
+ * used for all context specific commands (i.e., \c Render, \c RenderLarge,
+ * \c WaitX, \c WaitGL, \c UseXFont, and \c MakeCurrent (for the old
+ * context)).
+ */
+ GLXContextTag currentContextTag;
+
+ /**
+ * \name Rendering mode
+ *
+ * The rendering mode is kept on the client as well as the server.
+ * When \c glRenderMode is called, the buffer associated with the
+ * previous rendering mode (feedback or select) is filled.
+ */
+ /*@{*/
+ GLenum renderMode;
+ GLfloat *feedbackBuf;
+ GLuint *selectBuf;
+ /*@}*/
+
+ /**
+ * This is \c GL_TRUE if the pixel unpack modes are such that an image
+ * can be unpacked from the clients memory by just copying. It may
+ * still be true that the server will have to do some work. This
+ * just promises that a straight copy will fetch the correct bytes.
+ */
+ GLboolean fastImageUnpack;
+
+ /**
+ * Fill newImage with the unpacked form of \c oldImage getting it
+ * ready for transport to the server.
+ */
+ void (*fillImage)(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
+ GLenum, const GLvoid*, GLubyte*, GLubyte*);
+
+ /**
+ * Client side attribs.
+ */
+ __GLXattributeMachine attributes;
+
+ /**
+ * Client side error code. This is set when client side gl API
+ * routines need to set an error because of a bad enumerant or
+ * running out of memory, etc.
+ */
+ GLenum error;
+
+ /**
+ * Whether this context does direct rendering.
+ */
+ Bool isDirect;
+
+ /**
+ * \c dpy of current display for this context. Will be \c NULL if not
+ * current to any display, or if this is the "dummy context".
+ */
+ Display *currentDpy;
+
+ /**
+ * The current drawable for this context. Will be None if this
+ * context is not current to any drawable. currentReadable is below.
+ */
+ GLXDrawable currentDrawable;
+
+ /**
+ * \name GL Constant Strings
+ *
+ * Constant strings that describe the server implementation
+ * These pertain to GL attributes, not to be confused with
+ * GLX versioning attributes.
+ */
+ /*@{*/
+ GLubyte *vendor;
+ GLubyte *renderer;
+ GLubyte *version;
+ GLubyte *extensions;
+ /*@}*/
+
+ /**
+ * Record the dpy this context was created on for later freeing
+ */
+ Display *createDpy;
+
+ /**
+ * Maximum small render command size. This is the smaller of 64k and
+ * the size of the above buffer.
+ */
+ GLint maxSmallRenderCommandSize;
+
+ /**
+ * Major opcode for the extension. Copied here so a lookup isn't
+ * needed.
+ */
+ GLint majorOpcode;
+
+#ifdef GLX_DIRECT_RENDERING
+ /**
+ * Per context direct rendering interface functions and data.
+ */
+ __DRIcontext driContext;
+#endif
+
+ /**
+ * \c GLXFBConfigID used to create this context. May be \c None. This
+ * field has been replaced by the \c mode field.
+ *
+ * \since Internal API version 20030317.
+ *
+ * \deprecated
+ * This filed has been largely been replaced by the \c mode field, but
+ * the work is not quite done.
+ */
+ GLXFBConfigID fbconfigID;
+
+ /**
+ * The current read-drawable for this context. Will be None if this
+ * context is not current to any drawable.
+ *
+ * \since Internal API version 20030606.
+ */
+ GLXDrawable currentReadable;
+
+ /**
+ * Pointer to client-state data that is private to libGL. This is only
+ * used for indirect rendering contexts.
+ *
+ * No internal API version change was made for this change. Client-side
+ * drivers should NEVER use this data or even care that it exists.
+ */
+ void * client_state_private;
+
+ /**
+ * Stored value for \c glXQueryContext attribute \c GLX_RENDER_TYPE.
+ */
+ int renderType;
+
+ /**
+ * \name Raw server GL version
+ *
+ * True core GL version supported by the server. This is the raw value
+ * returned by the server, and it may not reflect what is actually
+ * supported (or reported) by the client-side library.
+ */
+ /*@{*/
+ int server_major; /**< Major version number. */
+ int server_minor; /**< Minor version number. */
+ /*@}*/
+
+ char gl_extension_bits[ __GL_EXT_BYTES ];
+};
+
+#define __glXSetError(gc,code) \
+ if (!(gc)->error) { \
+ (gc)->error = code; \
+ }
+
+extern void __glFreeAttributeState(__GLXcontext *);
+
+/************************************************************************/
+
+/**
+ * The size of the largest drawing command known to the implementation
+ * that will use the GLXRender GLX command. In this case it is
+ * \c glPolygonStipple.
+ */
+#define __GLX_MAX_SMALL_RENDER_CMD_SIZE 156
+
+/**
+ * To keep the implementation fast, the code uses a "limit" pointer
+ * to determine when the drawing command buffer is too full to hold
+ * another fixed size command. This constant defines the amount of
+ * space that must always be available in the drawing command buffer
+ * at all times for the implementation to work. It is important that
+ * the number be just large enough, but not so large as to reduce the
+ * efficacy of the buffer. The "+32" is just to keep the code working
+ * in case somebody counts wrong.
+ */
+#define __GLX_BUFFER_LIMIT_SIZE (__GLX_MAX_SMALL_RENDER_CMD_SIZE + 32)
+
+/**
+ * This implementation uses a smaller threshold for switching
+ * to the RenderLarge protocol than the protcol requires so that
+ * large copies don't occur.
+ */
+#define __GLX_RENDER_CMD_SIZE_LIMIT 4096
+
+/**
+ * One of these records exists per screen of the display. It contains
+ * a pointer to the config data for that screen (if the screen supports GL).
+ */
+typedef struct __GLXscreenConfigsRec {
+ /**
+ * GLX extension string reported by the X-server.
+ */
+ const char *serverGLXexts;
+
+ /**
+ * GLX extension string to be reported to applications. This is the
+ * set of extensions that the application can actually use.
+ */
+ char *effectiveGLXexts;
+
+#ifdef GLX_DIRECT_RENDERING
+ /**
+ * Per screen direct rendering interface functions and data.
+ */
+ __DRIscreen driScreen;
+#endif
+
+ /**
+ * Linked list of configurations for this screen.
+ */
+ __GLcontextModes *configs;
+
+ /**
+ * Per-screen dynamic GLX extension tracking. The \c direct_support
+ * field only contains enough bits for 64 extensions. Should libGL
+ * ever need to track more than 64 GLX extensions, we can safely grow
+ * this field. The \c __GLXscreenConfigs structure is not used outside
+ * libGL.
+ */
+ /*@{*/
+ unsigned char direct_support[8];
+ GLboolean ext_list_first_time;
+ /*@}*/
+
+} __GLXscreenConfigs;
+
+/**
+ * Per display private data. One of these records exists for each display
+ * that is using the OpenGL (GLX) extension.
+ */
+struct __GLXdisplayPrivateRec {
+ /**
+ * Back pointer to the display
+ */
+ Display *dpy;
+
+ /**
+ * The \c majorOpcode is common to all connections to the same server.
+ * It is also copied into the context structure.
+ */
+ int majorOpcode;
+
+ /**
+ * \name Server Version
+ *
+ * Major and minor version returned by the server during initialization.
+ */
+ /*@{*/
+ int majorVersion, minorVersion;
+ /*@}*/
+
+ /**
+ * \name Storage for the servers GLX vendor and versions strings.
+ *
+ * These are the same for all screens on this display. These fields will
+ * be filled in on demand.
+ */
+ /*@{*/
+ const char *serverGLXvendor;
+ const char *serverGLXversion;
+ /*@}*/
+
+ /**
+ * Configurations of visuals for all screens on this display.
+ * Also, per screen data which now includes the server \c GLX_EXTENSION
+ * string.
+ */
+ __GLXscreenConfigs *screenConfigs;
+
+#ifdef GLX_DIRECT_RENDERING
+ /**
+ * Per display direct rendering interface functions and data.
+ */
+ __DRIdisplay driDisplay;
+#endif
+};
+
+void __glXFreeContext(__GLXcontext*);
+
+extern GLubyte *__glXFlushRenderBuffer(__GLXcontext*, GLubyte*);
+
+extern void __glXSendLargeChunk(__GLXcontext *gc, GLint requestNumber,
+ GLint totalRequests,
+ const GLvoid * data, GLint dataLen);
+
+extern void __glXSendLargeCommand(__GLXcontext *, const GLvoid *, GLint,
+ const GLvoid *, GLint);
+
+/* Initialize the GLX extension for dpy */
+extern __GLXdisplayPrivate *__glXInitialize(Display*);
+
+/************************************************************************/
+
+extern int __glXDebug;
+
+/* This is per-thread storage in an MT environment */
+#if defined( USE_XTHREADS ) || defined( PTHREADS )
+
+extern void __glXSetCurrentContext(__GLXcontext *c);
+
+# if defined( GLX_USE_TLS )
+
+extern __thread void * __glX_tls_Context
+ __attribute__((tls_model("initial-exec")));
+
+# define __glXGetCurrentContext() __glX_tls_Context
+
+# else
+
+extern __GLXcontext *__glXGetCurrentContext(void);
+
+# endif /* defined( GLX_USE_TLS ) */
+
+#else
+
+extern __GLXcontext *__glXcurrentContext;
+#define __glXGetCurrentContext() __glXcurrentContext
+#define __glXSetCurrentContext(gc) __glXcurrentContext = gc
+
+#endif /* defined( USE_XTHREADS ) || defined( PTHREADS ) */
+
+
+/*
+** Global lock for all threads in this address space using the GLX
+** extension
+*/
+#if defined( USE_XTHREADS )
+extern xmutex_rec __glXmutex;
+#define __glXLock() xmutex_lock(&__glXmutex)
+#define __glXUnlock() xmutex_unlock(&__glXmutex)
+#elif defined( PTHREADS )
+extern pthread_mutex_t __glXmutex;
+#define __glXLock() pthread_mutex_lock(&__glXmutex)
+#define __glXUnlock() pthread_mutex_unlock(&__glXmutex)
+#else
+#define __glXLock()
+#define __glXUnlock()
+#endif
+
+/*
+** Setup for a command. Initialize the extension for dpy if necessary.
+*/
+extern CARD8 __glXSetupForCommand(Display *dpy);
+
+/************************************************************************/
+
+/*
+** Data conversion and packing support.
+*/
+
+extern const GLuint __glXDefaultPixelStore[9];
+
+/* Send an image to the server using RenderLarge. */
+extern void __glXSendLargeImage(__GLXcontext *gc, GLint compsize, GLint dim,
+ GLint width, GLint height, GLint depth, GLenum format, GLenum type,
+ const GLvoid *src, GLubyte *pc, GLubyte *modes);
+
+/* Return the size, in bytes, of some pixel data */
+extern GLint __glImageSize(GLint, GLint, GLint, GLenum, GLenum, GLenum);
+
+/* Return the number of elements per group of a specified format*/
+extern GLint __glElementsPerGroup(GLenum format, GLenum type);
+
+/* Return the number of bytes per element, based on the element type (other
+** than GL_BITMAP).
+*/
+extern GLint __glBytesPerElement(GLenum type);
+
+/*
+** Fill the transport buffer with the data from the users buffer,
+** applying some of the pixel store modes (unpack modes) to the data
+** first. As a side effect of this call, the "modes" field is
+** updated to contain the modes needed by the server to decode the
+** sent data.
+*/
+extern void __glFillImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
+ GLenum, const GLvoid*, GLubyte*, GLubyte*);
+
+/* Copy map data with a stride into a packed buffer */
+extern void __glFillMap1f(GLint, GLint, GLint, const GLfloat *, GLubyte *);
+extern void __glFillMap1d(GLint, GLint, GLint, const GLdouble *, GLubyte *);
+extern void __glFillMap2f(GLint, GLint, GLint, GLint, GLint,
+ const GLfloat *, GLfloat *);
+extern void __glFillMap2d(GLint, GLint, GLint, GLint, GLint,
+ const GLdouble *, GLdouble *);
+
+/*
+** Empty an image out of the reply buffer into the clients memory applying
+** the pack modes to pack back into the clients requested format.
+*/
+extern void __glEmptyImage(__GLXcontext*, GLint, GLint, GLint, GLint, GLenum,
+ GLenum, const GLubyte *, GLvoid *);
+
+
+/*
+** Allocate and Initialize Vertex Array client state
+*/
+extern void __glXInitVertexArrayState(__GLXcontext*);
+
+/*
+** Inform the Server of the major and minor numbers and of the client
+** libraries extension string.
+*/
+extern void __glXClientInfo ( Display *dpy, int opcode );
+
+/************************************************************************/
+
+/*
+** Declarations that should be in Xlib
+*/
+#ifdef __GL_USE_OUR_PROTOTYPES
+extern void _XFlush(Display*);
+extern Status _XReply(Display*, xReply*, int, Bool);
+extern void _XRead(Display*, void*, long);
+extern void _XSend(Display*, const void*, long);
+#endif
+
+
+extern void __glXInitializeVisualConfigFromTags( __GLcontextModes *config,
+ int count, const INT32 *bp, Bool tagged_only, Bool fbconfig_style_tags );
+
+extern char * __glXGetStringFromServer( Display * dpy, int opcode,
+ CARD32 glxCode, CARD32 for_whom, CARD32 name );
+
+extern char *__glXstrdup(const char *str);
+
+
+extern const char __glXGLClientVersion[];
+extern const char __glXGLClientExtensions[];
+
+/* Determine the internal API version */
+extern int __glXGetInternalVersion(void);
+
+/* Get the unadjusted system time */
+extern int __glXGetUST( int64_t * ust );
+
+#endif /* !__GLX_client_h__ */
diff --git a/nx-X11/extras/Mesa/src/glx/x11/glxcmds.c b/nx-X11/extras/Mesa/src/glx/x11/glxcmds.c
new file mode 100644
index 000000000..6a31f24dd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/glxcmds.c
@@ -0,0 +1,2969 @@
+/* $XFree86: xc/lib/GL/glx/glxcmds.c,v 1.30 2004/01/30 20:33:06 alanh Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+/**
+ * \file glxcmds.c
+ * Client-side GLX interface.
+ */
+
+#include <inttypes.h>
+#include "glxclient.h"
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/Xext.h>
+#include <assert.h>
+#include <string.h>
+#include "glapi.h"
+#ifdef GLX_DIRECT_RENDERING
+#include "indirect_init.h"
+#include <X11/extensions/xf86vmode.h>
+#include "xf86dri.h"
+#endif
+#include "glxextensions.h"
+#include "glcontextmodes.h"
+#include "glheader.h"
+#include <sys/time.h>
+
+static const char __glXGLXClientVendorName[] = "SGI";
+static const char __glXGLXClientVersion[] = "1.4";
+
+
+/****************************************************************************/
+/**
+ * Get the __DRIdrawable for the drawable associated with a GLXContext
+ *
+ * \param dpy The display associated with \c drawable.
+ * \param drawable GLXDrawable whose __DRIdrawable part is to be retrieved.
+ * \returns A pointer to the context's __DRIdrawable on success, or NULL if
+ * the drawable is not associated with a direct-rendering context.
+ */
+
+#ifdef GLX_DIRECT_RENDERING
+static __DRIdrawable *
+GetDRIDrawable( Display *dpy, GLXDrawable drawable, int * const scrn_num )
+{
+ __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
+
+ if ( (priv != NULL) && (priv->driDisplay.private != NULL) ) {
+ const unsigned screen_count = ScreenCount(dpy);
+ unsigned i;
+
+ for ( i = 0 ; i < screen_count ; i++ ) {
+ __DRIscreen * const psc = &priv->screenConfigs[i].driScreen;
+ __DRIdrawable * const pdraw = (psc->private != NULL)
+ ? (*psc->getDrawable)(dpy, drawable, psc->private) : NULL;
+
+ if ( pdraw != NULL ) {
+ if ( scrn_num != NULL ) {
+ *scrn_num = i;
+ }
+ return pdraw;
+ }
+ }
+ }
+
+ return NULL;
+}
+#endif
+
+
+/**
+ * Get the GLX per-screen data structure associated with a GLX context.
+ *
+ * \param dpy Display for which the GLX per-screen information is to be
+ * retrieved.
+ * \param scrn Screen on \c dpy for which the GLX per-screen information is
+ * to be retrieved.
+ * \returns A pointer to the GLX per-screen data if \c dpy and \c scrn
+ * specify a valid GLX screen, or NULL otherwise.
+ *
+ * \todo Should this function validate that \c scrn is within the screen
+ * number range for \c dpy?
+ */
+
+static __GLXscreenConfigs *
+GetGLXScreenConfigs(Display *dpy, int scrn)
+{
+ __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
+
+ return (priv->screenConfigs != NULL) ? &priv->screenConfigs[scrn] : NULL;
+}
+
+
+static int
+GetGLXPrivScreenConfig( Display *dpy, int scrn, __GLXdisplayPrivate ** ppriv,
+ __GLXscreenConfigs ** ppsc )
+{
+ /* Initialize the extension, if needed . This has the added value
+ * of initializing/allocating the display private
+ */
+
+ if ( dpy == NULL ) {
+ return GLX_NO_EXTENSION;
+ }
+
+ *ppriv = __glXInitialize(dpy);
+ if ( *ppriv == NULL ) {
+ return GLX_NO_EXTENSION;
+ }
+
+ /* Check screen number to see if its valid */
+ if ((scrn < 0) || (scrn >= ScreenCount(dpy))) {
+ return GLX_BAD_SCREEN;
+ }
+
+ /* Check to see if the GL is supported on this screen */
+ *ppsc = &((*ppriv)->screenConfigs[scrn]);
+ if ( (*ppsc)->configs == NULL ) {
+ /* No support for GL on this screen regardless of visual */
+ return GLX_BAD_VISUAL;
+ }
+
+ return Success;
+}
+
+
+/**
+ * Determine if a \c GLXFBConfig supplied by the application is valid.
+ *
+ * \param dpy Application supplied \c Display pointer.
+ * \param config Application supplied \c GLXFBConfig.
+ *
+ * \returns If the \c GLXFBConfig is valid, the a pointer to the matching
+ * \c __GLcontextModes structure is returned. Otherwise, \c NULL
+ * is returned.
+ */
+static __GLcontextModes *
+ValidateGLXFBConfig( Display * dpy, GLXFBConfig config )
+{
+ __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
+ const unsigned num_screens = ScreenCount(dpy);
+ unsigned i;
+ const __GLcontextModes * modes;
+
+
+ if ( priv != NULL ) {
+ for ( i = 0 ; i < num_screens ; i++ ) {
+ for ( modes = priv->screenConfigs[i].configs
+ ; modes != NULL
+ ; modes = modes->next ) {
+ if ( modes == (__GLcontextModes *) config ) {
+ return (__GLcontextModes *) config;
+ }
+ }
+ }
+ }
+
+ return NULL;
+}
+
+
+/**
+ * \todo It should be possible to move the allocate of \c client_state_private
+ * later in the function for direct-rendering contexts. Direct-rendering
+ * contexts don't need to track client state, so they don't need that memory
+ * at all.
+ *
+ * \todo Eliminate \c __glXInitVertexArrayState. Replace it with a new
+ * function called \c __glXAllocateClientState that allocates the memory and
+ * does all the initialization (including the pixel pack / unpack).
+ */
+static
+GLXContext AllocateGLXContext( Display *dpy )
+{
+ GLXContext gc;
+ int bufSize;
+ CARD8 opcode;
+ __GLXattribute *state;
+
+ if (!dpy)
+ return NULL;
+
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return NULL;
+ }
+
+ /* Allocate our context record */
+ gc = (GLXContext) Xmalloc(sizeof(struct __GLXcontextRec));
+ if (!gc) {
+ /* Out of memory */
+ return NULL;
+ }
+ memset(gc, 0, sizeof(struct __GLXcontextRec));
+
+ state = Xmalloc(sizeof(struct __GLXattributeRec));
+ if (state == NULL) {
+ /* Out of memory */
+ Xfree(gc);
+ return NULL;
+ }
+ gc->client_state_private = state;
+ memset(gc->client_state_private, 0, sizeof(struct __GLXattributeRec));
+ state->NoDrawArraysProtocol = (getenv("LIBGL_NO_DRAWARRAYS") != NULL);
+
+ /*
+ ** Create a temporary buffer to hold GLX rendering commands. The size
+ ** of the buffer is selected so that the maximum number of GLX rendering
+ ** commands can fit in a single X packet and still have room in the X
+ ** packet for the GLXRenderReq header.
+ */
+
+ bufSize = (XMaxRequestSize(dpy) * 4) - sz_xGLXRenderReq;
+ gc->buf = (GLubyte *) Xmalloc(bufSize);
+ if (!gc->buf) {
+ Xfree(gc->client_state_private);
+ Xfree(gc);
+ return NULL;
+ }
+ gc->bufSize = bufSize;
+
+ /* Fill in the new context */
+ gc->renderMode = GL_RENDER;
+
+ state->storePack.alignment = 4;
+ state->storeUnpack.alignment = 4;
+
+ gc->attributes.stackPointer = &gc->attributes.stack[0];
+
+ /*
+ ** PERFORMANCE NOTE: A mode dependent fill image can speed things up.
+ ** Other code uses the fastImageUnpack bit, but it is never set
+ ** to GL_TRUE.
+ */
+ gc->fastImageUnpack = GL_FALSE;
+ gc->fillImage = __glFillImage;
+ gc->isDirect = GL_FALSE;
+ gc->pc = gc->buf;
+ gc->bufEnd = gc->buf + bufSize;
+ if (__glXDebug) {
+ /*
+ ** Set limit register so that there will be one command per packet
+ */
+ gc->limit = gc->buf;
+ } else {
+ gc->limit = gc->buf + bufSize - __GLX_BUFFER_LIMIT_SIZE;
+ }
+ gc->createDpy = dpy;
+ gc->majorOpcode = opcode;
+
+ /*
+ ** Constrain the maximum drawing command size allowed to be
+ ** transfered using the X_GLXRender protocol request. First
+ ** constrain by a software limit, then constrain by the protocl
+ ** limit.
+ */
+ if (bufSize > __GLX_RENDER_CMD_SIZE_LIMIT) {
+ bufSize = __GLX_RENDER_CMD_SIZE_LIMIT;
+ }
+ if (bufSize > __GLX_MAX_RENDER_CMD_SIZE) {
+ bufSize = __GLX_MAX_RENDER_CMD_SIZE;
+ }
+ gc->maxSmallRenderCommandSize = bufSize;
+ return gc;
+}
+
+
+/**
+ * Create a new context. Exactly one of \c vis and \c fbconfig should be
+ * non-NULL.
+ *
+ * \param use_glx_1_3 For FBConfigs, should GLX 1.3 protocol or
+ * SGIX_fbconfig protocol be used?
+ * \param renderType For FBConfigs, what is the rendering type?
+ */
+
+static GLXContext
+CreateContext(Display *dpy, XVisualInfo *vis,
+ const __GLcontextModes * const fbconfig,
+ GLXContext shareList,
+ Bool allowDirect, GLXContextID contextID,
+ Bool use_glx_1_3, int renderType)
+{
+ GLXContext gc;
+
+ if ( dpy == NULL )
+ return NULL;
+
+ gc = AllocateGLXContext(dpy);
+ if (!gc)
+ return NULL;
+
+ if (None == contextID) {
+ if ( (vis == NULL) && (fbconfig == NULL) )
+ return NULL;
+
+#ifdef GLX_DIRECT_RENDERING
+ if (allowDirect) {
+ int screen = (fbconfig == NULL) ? vis->screen : fbconfig->screen;
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
+ const __GLcontextModes * mode;
+
+ /* The value of fbconfig cannot change because it is tested
+ * later in the function.
+ */
+ if ( fbconfig == NULL ) {
+ /* FIXME: Is it possible for the __GLcontextModes structure
+ * FIXME: to not be found?
+ */
+ mode = _gl_context_modes_find_visual( psc->configs,
+ vis->visualid );
+ assert( mode != NULL );
+ assert( mode->screen == screen );
+ }
+ else {
+ mode = fbconfig;
+ }
+
+ if (psc && psc->driScreen.private) {
+ void * const shared = (shareList != NULL)
+ ? shareList->driContext.private : NULL;
+ gc->driContext.private =
+ (*psc->driScreen.createNewContext)( dpy, mode, renderType,
+ shared,
+ &gc->driContext );
+ if (gc->driContext.private) {
+ gc->isDirect = GL_TRUE;
+ gc->screen = mode->screen;
+ gc->vid = mode->visualID;
+ gc->fbconfigID = mode->fbconfigID;
+ gc->driContext.mode = mode;
+ }
+ }
+ }
+#endif
+
+ LockDisplay(dpy);
+ if ( fbconfig == NULL ) {
+ xGLXCreateContextReq *req;
+
+ /* Send the glXCreateContext request */
+ GetReq(GLXCreateContext,req);
+ req->reqType = gc->majorOpcode;
+ req->glxCode = X_GLXCreateContext;
+ req->context = gc->xid = XAllocID(dpy);
+ req->visual = vis->visualid;
+ req->screen = vis->screen;
+ req->shareList = shareList ? shareList->xid : None;
+ req->isDirect = gc->isDirect;
+ }
+ else if ( use_glx_1_3 ) {
+ xGLXCreateNewContextReq *req;
+
+ /* Send the glXCreateNewContext request */
+ GetReq(GLXCreateNewContext,req);
+ req->reqType = gc->majorOpcode;
+ req->glxCode = X_GLXCreateNewContext;
+ req->context = gc->xid = XAllocID(dpy);
+ req->fbconfig = fbconfig->fbconfigID;
+ req->screen = fbconfig->screen;
+ req->renderType = renderType;
+ req->shareList = shareList ? shareList->xid : None;
+ req->isDirect = gc->isDirect;
+ }
+ else {
+ xGLXVendorPrivateWithReplyReq *vpreq;
+ xGLXCreateContextWithConfigSGIXReq *req;
+
+ /* Send the glXCreateNewContext request */
+ GetReqExtra(GLXVendorPrivateWithReply,
+ sz_xGLXCreateContextWithConfigSGIXReq-sz_xGLXVendorPrivateWithReplyReq,vpreq);
+ req = (xGLXCreateContextWithConfigSGIXReq *)vpreq;
+ req->reqType = gc->majorOpcode;
+ req->glxCode = X_GLXVendorPrivateWithReply;
+ req->vendorCode = X_GLXvop_CreateContextWithConfigSGIX;
+ req->context = gc->xid = XAllocID(dpy);
+ req->fbconfig = fbconfig->fbconfigID;
+ req->screen = fbconfig->screen;
+ req->renderType = renderType;
+ req->shareList = shareList ? shareList->xid : None;
+ req->isDirect = gc->isDirect;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ gc->imported = GL_FALSE;
+ }
+ else {
+ gc->xid = contextID;
+ gc->imported = GL_TRUE;
+ }
+
+ return gc;
+}
+
+PUBLIC GLXContext glXCreateContext(Display *dpy, XVisualInfo *vis,
+ GLXContext shareList, Bool allowDirect)
+{
+ return CreateContext(dpy, vis, NULL, shareList, allowDirect, None,
+ False, 0);
+}
+
+void __glXFreeContext(__GLXcontext *gc)
+{
+ if (gc->vendor) XFree((char *) gc->vendor);
+ if (gc->renderer) XFree((char *) gc->renderer);
+ if (gc->version) XFree((char *) gc->version);
+ if (gc->extensions) XFree((char *) gc->extensions);
+ __glFreeAttributeState(gc);
+ XFree((char *) gc->buf);
+ Xfree((char *) gc->client_state_private);
+ XFree((char *) gc);
+
+}
+
+/*
+** Destroy the named context
+*/
+static void
+DestroyContext(Display *dpy, GLXContext gc)
+{
+ xGLXDestroyContextReq *req;
+ GLXContextID xid;
+ CARD8 opcode;
+ GLboolean imported;
+
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode || !gc) {
+ return;
+ }
+
+ __glXLock();
+ xid = gc->xid;
+ imported = gc->imported;
+ gc->xid = None;
+
+#ifdef GLX_DIRECT_RENDERING
+ /* Destroy the direct rendering context */
+ if (gc->isDirect) {
+ if (gc->driContext.private) {
+ (*gc->driContext.destroyContext)(dpy, gc->screen,
+ gc->driContext.private);
+ gc->driContext.private = NULL;
+ }
+ }
+#endif
+
+ if (gc->currentDpy) {
+ /* Have to free later cuz it's in use now */
+ __glXUnlock();
+ } else {
+ /* Destroy the handle if not current to anybody */
+ __glXUnlock();
+ __glXFreeContext(gc);
+ }
+
+ if (!imported) {
+ /*
+ ** This dpy also created the server side part of the context.
+ ** Send the glXDestroyContext request.
+ */
+ LockDisplay(dpy);
+ GetReq(GLXDestroyContext,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXDestroyContext;
+ req->context = xid;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+}
+
+PUBLIC void glXDestroyContext(Display *dpy, GLXContext gc)
+{
+ DestroyContext(dpy, gc);
+}
+
+/*
+** Return the major and minor version #s for the GLX extension
+*/
+PUBLIC Bool glXQueryVersion(Display *dpy, int *major, int *minor)
+{
+ __GLXdisplayPrivate *priv;
+
+ /* Init the extension. This fetches the major and minor version. */
+ priv = __glXInitialize(dpy);
+ if (!priv) return GL_FALSE;
+
+ if (major) *major = priv->majorVersion;
+ if (minor) *minor = priv->minorVersion;
+ return GL_TRUE;
+}
+
+/*
+** Query the existance of the GLX extension
+*/
+PUBLIC Bool glXQueryExtension(Display *dpy, int *errorBase, int *eventBase)
+{
+ int major_op, erb, evb;
+ Bool rv;
+
+ rv = XQueryExtension(dpy, GLX_EXTENSION_NAME, &major_op, &evb, &erb);
+ if (rv) {
+ if (errorBase) *errorBase = erb;
+ if (eventBase) *eventBase = evb;
+ }
+ return rv;
+}
+
+/*
+** Put a barrier in the token stream that forces the GL to finish its
+** work before X can proceed.
+*/
+PUBLIC void glXWaitGL(void)
+{
+ xGLXWaitGLReq *req;
+ GLXContext gc = __glXGetCurrentContext();
+ Display *dpy = gc->currentDpy;
+
+ if (!dpy) return;
+
+ /* Flush any pending commands out */
+ __glXFlushRenderBuffer(gc, gc->pc);
+
+#ifdef GLX_DIRECT_RENDERING
+ if (gc->isDirect) {
+/* This bit of ugliness unwraps the glFinish function */
+#ifdef glFinish
+#undef glFinish
+#endif
+ glFinish();
+ return;
+ }
+#endif
+
+ /* Send the glXWaitGL request */
+ LockDisplay(dpy);
+ GetReq(GLXWaitGL,req);
+ req->reqType = gc->majorOpcode;
+ req->glxCode = X_GLXWaitGL;
+ req->contextTag = gc->currentContextTag;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+/*
+** Put a barrier in the token stream that forces X to finish its
+** work before GL can proceed.
+*/
+PUBLIC void glXWaitX(void)
+{
+ xGLXWaitXReq *req;
+ GLXContext gc = __glXGetCurrentContext();
+ Display *dpy = gc->currentDpy;
+
+ if (!dpy) return;
+
+ /* Flush any pending commands out */
+ __glXFlushRenderBuffer(gc, gc->pc);
+
+#ifdef GLX_DIRECT_RENDERING
+ if (gc->isDirect) {
+ XSync(dpy, False);
+ return;
+ }
+#endif
+
+ /*
+ ** Send the glXWaitX request.
+ */
+ LockDisplay(dpy);
+ GetReq(GLXWaitX,req);
+ req->reqType = gc->majorOpcode;
+ req->glxCode = X_GLXWaitX;
+ req->contextTag = gc->currentContextTag;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+PUBLIC void glXUseXFont(Font font, int first, int count, int listBase)
+{
+ xGLXUseXFontReq *req;
+ GLXContext gc = __glXGetCurrentContext();
+ Display *dpy = gc->currentDpy;
+
+ if (!dpy) return;
+
+ /* Flush any pending commands out */
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+
+#ifdef GLX_DIRECT_RENDERING
+ if (gc->isDirect) {
+ DRI_glXUseXFont(font, first, count, listBase);
+ return;
+ }
+#endif
+
+ /* Send the glXUseFont request */
+ LockDisplay(dpy);
+ GetReq(GLXUseXFont,req);
+ req->reqType = gc->majorOpcode;
+ req->glxCode = X_GLXUseXFont;
+ req->contextTag = gc->currentContextTag;
+ req->font = font;
+ req->first = first;
+ req->count = count;
+ req->listBase = listBase;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+/************************************************************************/
+
+/*
+** Copy the source context to the destination context using the
+** attribute "mask".
+*/
+PUBLIC void glXCopyContext(Display *dpy, GLXContext source,
+ GLXContext dest, unsigned long mask)
+{
+ xGLXCopyContextReq *req;
+ GLXContext gc = __glXGetCurrentContext();
+ GLXContextTag tag;
+ CARD8 opcode;
+
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return;
+ }
+
+#ifdef GLX_DIRECT_RENDERING
+ if (gc->isDirect) {
+ /* NOT_DONE: This does not work yet */
+ }
+#endif
+
+ /*
+ ** If the source is the current context, send its tag so that the context
+ ** can be flushed before the copy.
+ */
+ if (source == gc && dpy == gc->currentDpy) {
+ tag = gc->currentContextTag;
+ } else {
+ tag = 0;
+ }
+
+ /* Send the glXCopyContext request */
+ LockDisplay(dpy);
+ GetReq(GLXCopyContext,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXCopyContext;
+ req->source = source ? source->xid : None;
+ req->dest = dest ? dest->xid : None;
+ req->mask = mask;
+ req->contextTag = tag;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+
+/**
+ * Determine if a context uses direct rendering.
+ *
+ * \param dpy Display where the context was created.
+ * \param contextID ID of the context to be tested.
+ *
+ * \returns \c GL_TRUE if the context is direct rendering or not.
+ */
+static Bool __glXIsDirect(Display *dpy, GLXContextID contextID)
+{
+ xGLXIsDirectReq *req;
+ xGLXIsDirectReply reply;
+ CARD8 opcode;
+
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return GL_FALSE;
+ }
+
+ /* Send the glXIsDirect request */
+ LockDisplay(dpy);
+ GetReq(GLXIsDirect,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXIsDirect;
+ req->context = contextID;
+ _XReply(dpy, (xReply*) &reply, 0, False);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return reply.isDirect;
+}
+
+/**
+ * \todo
+ * Shouldn't this function \b always return \c GL_FALSE when
+ * \c GLX_DIRECT_RENDERING is not defined? Do we really need to bother with
+ * the GLX protocol here at all?
+ */
+PUBLIC Bool glXIsDirect(Display *dpy, GLXContext gc)
+{
+ if (!gc) {
+ return GL_FALSE;
+#ifdef GLX_DIRECT_RENDERING
+ } else if (gc->isDirect) {
+ return GL_TRUE;
+#endif
+ }
+ return __glXIsDirect(dpy, gc->xid);
+}
+
+PUBLIC GLXPixmap glXCreateGLXPixmap(Display *dpy, XVisualInfo *vis,
+ Pixmap pixmap)
+{
+ xGLXCreateGLXPixmapReq *req;
+ GLXPixmap xid;
+ CARD8 opcode;
+
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return None;
+ }
+
+ /* Send the glXCreateGLXPixmap request */
+ LockDisplay(dpy);
+ GetReq(GLXCreateGLXPixmap,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXCreateGLXPixmap;
+ req->screen = vis->screen;
+ req->visual = vis->visualid;
+ req->pixmap = pixmap;
+ req->glxpixmap = xid = XAllocID(dpy);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return xid;
+}
+
+/*
+** Destroy the named pixmap
+*/
+PUBLIC void glXDestroyGLXPixmap(Display *dpy, GLXPixmap glxpixmap)
+{
+ xGLXDestroyGLXPixmapReq *req;
+ CARD8 opcode;
+
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return;
+ }
+
+ /* Send the glXDestroyGLXPixmap request */
+ LockDisplay(dpy);
+ GetReq(GLXDestroyGLXPixmap,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXDestroyGLXPixmap;
+ req->glxpixmap = glxpixmap;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+PUBLIC void glXSwapBuffers(Display *dpy, GLXDrawable drawable)
+{
+ xGLXSwapBuffersReq *req;
+ GLXContext gc;
+ GLXContextTag tag;
+ CARD8 opcode;
+#ifdef GLX_DIRECT_RENDERING
+ __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, NULL );
+
+ if ( pdraw != NULL ) {
+ (*pdraw->swapBuffers)(dpy, pdraw->private);
+ return;
+ }
+#endif
+
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return;
+ }
+
+ /*
+ ** The calling thread may or may not have a current context. If it
+ ** does, send the context tag so the server can do a flush.
+ */
+ gc = __glXGetCurrentContext();
+ if ((gc != NULL) && (dpy == gc->currentDpy) &&
+ ((drawable == gc->currentDrawable) || (drawable == gc->currentReadable)) ) {
+ tag = gc->currentContextTag;
+ } else {
+ tag = 0;
+ }
+
+ /* Send the glXSwapBuffers request */
+ LockDisplay(dpy);
+ GetReq(GLXSwapBuffers,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXSwapBuffers;
+ req->drawable = drawable;
+ req->contextTag = tag;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ XFlush(dpy);
+}
+
+
+/*
+** Return configuration information for the given display, screen and
+** visual combination.
+*/
+PUBLIC int glXGetConfig(Display *dpy, XVisualInfo *vis, int attribute,
+ int *value_return)
+{
+ __GLXdisplayPrivate *priv;
+ __GLXscreenConfigs *psc;
+ int status;
+
+ status = GetGLXPrivScreenConfig( dpy, vis->screen, & priv, & psc );
+ if ( status == Success ) {
+ const __GLcontextModes * const modes = _gl_context_modes_find_visual(
+ psc->configs, vis->visualid );
+
+ /* Lookup attribute after first finding a match on the visual */
+ if ( modes != NULL ) {
+ return _gl_get_context_mode_data( modes, attribute, value_return );
+ }
+
+ status = GLX_BAD_VISUAL;
+ }
+
+ /*
+ ** If we can't find the config for this visual, this visual is not
+ ** supported by the OpenGL implementation on the server.
+ */
+ if ( (status == GLX_BAD_VISUAL) && (attribute == GLX_USE_GL) ) {
+ *value_return = GL_FALSE;
+ status = Success;
+ }
+
+ return status;
+}
+
+/************************************************************************/
+
+static void
+init_fbconfig_for_chooser( __GLcontextModes * config,
+ GLboolean fbconfig_style_tags )
+{
+ memset( config, 0, sizeof( __GLcontextModes ) );
+ config->visualID = (XID) GLX_DONT_CARE;
+ config->visualType = GLX_DONT_CARE;
+
+ /* glXChooseFBConfig specifies different defaults for these two than
+ * glXChooseVisual.
+ */
+ if ( fbconfig_style_tags ) {
+ config->rgbMode = GL_TRUE;
+ config->doubleBufferMode = GLX_DONT_CARE;
+ }
+
+ config->visualRating = GLX_DONT_CARE;
+ config->transparentPixel = GLX_NONE;
+ config->transparentRed = GLX_DONT_CARE;
+ config->transparentGreen = GLX_DONT_CARE;
+ config->transparentBlue = GLX_DONT_CARE;
+ config->transparentAlpha = GLX_DONT_CARE;
+ config->transparentIndex = GLX_DONT_CARE;
+
+ config->drawableType = GLX_WINDOW_BIT;
+ config->renderType = (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
+ config->xRenderable = GLX_DONT_CARE;
+ config->fbconfigID = (GLXFBConfigID)(GLX_DONT_CARE);
+
+ config->swapMethod = GLX_DONT_CARE;
+}
+
+#define MATCH_DONT_CARE( param ) \
+ do { \
+ if ( (a-> param != GLX_DONT_CARE) \
+ && (a-> param != b-> param) ) { \
+ return False; \
+ } \
+ } while ( 0 )
+
+#define MATCH_MINIMUM( param ) \
+ do { \
+ if ( (a-> param != GLX_DONT_CARE) \
+ && (a-> param > b-> param) ) { \
+ return False; \
+ } \
+ } while ( 0 )
+
+#define MATCH_EXACT( param ) \
+ do { \
+ if ( a-> param != b-> param) { \
+ return False; \
+ } \
+ } while ( 0 )
+
+/**
+ * Determine if two GLXFBConfigs are compatible.
+ *
+ * \param a Application specified config to test.
+ * \param b Server specified config to test against \c a.
+ */
+static Bool
+fbconfigs_compatible( const __GLcontextModes * const a,
+ const __GLcontextModes * const b )
+{
+ MATCH_DONT_CARE( doubleBufferMode );
+ MATCH_DONT_CARE( visualType );
+ MATCH_DONT_CARE( visualRating );
+ MATCH_DONT_CARE( xRenderable );
+ MATCH_DONT_CARE( fbconfigID );
+ MATCH_DONT_CARE( swapMethod );
+
+ MATCH_MINIMUM( rgbBits );
+ MATCH_MINIMUM( numAuxBuffers );
+ MATCH_MINIMUM( redBits );
+ MATCH_MINIMUM( greenBits );
+ MATCH_MINIMUM( blueBits );
+ MATCH_MINIMUM( alphaBits );
+ MATCH_MINIMUM( depthBits );
+ MATCH_MINIMUM( stencilBits );
+ MATCH_MINIMUM( accumRedBits );
+ MATCH_MINIMUM( accumGreenBits );
+ MATCH_MINIMUM( accumBlueBits );
+ MATCH_MINIMUM( accumAlphaBits );
+ MATCH_MINIMUM( sampleBuffers );
+ MATCH_MINIMUM( maxPbufferWidth );
+ MATCH_MINIMUM( maxPbufferHeight );
+ MATCH_MINIMUM( maxPbufferPixels );
+ MATCH_MINIMUM( samples );
+
+ MATCH_DONT_CARE( stereoMode );
+ MATCH_EXACT( level );
+
+ if ( ((a->drawableType & b->drawableType) == 0)
+ || ((a->renderType & b->renderType) == 0) ) {
+ return False;
+ }
+
+
+ /* There is a bug in a few of the XFree86 DDX drivers. They contain
+ * visuals with a "transparent type" of 0 when they really mean GLX_NONE.
+ * Technically speaking, it is a bug in the DDX driver, but there is
+ * enough of an installed base to work around the problem here. In any
+ * case, 0 is not a valid value of the transparent type, so we'll treat 0
+ * from the app as GLX_DONT_CARE. We'll consider GLX_NONE from the app and
+ * 0 from the server to be a match to maintain backward compatibility with
+ * the (broken) drivers.
+ */
+
+ if ( a->transparentPixel != GLX_DONT_CARE
+ && a->transparentPixel != 0 ) {
+ if ( a->transparentPixel == GLX_NONE ) {
+ if ( b->transparentPixel != GLX_NONE && b->transparentPixel != 0 )
+ return False;
+ } else {
+ MATCH_EXACT( transparentPixel );
+ }
+
+ switch ( a->transparentPixel ) {
+ case GLX_TRANSPARENT_RGB:
+ MATCH_DONT_CARE( transparentRed );
+ MATCH_DONT_CARE( transparentGreen );
+ MATCH_DONT_CARE( transparentBlue );
+ MATCH_DONT_CARE( transparentAlpha );
+ break;
+
+ case GLX_TRANSPARENT_INDEX:
+ MATCH_DONT_CARE( transparentIndex );
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ return True;
+}
+
+
+/* There's some trickly language in the GLX spec about how this is supposed
+ * to work. Basically, if a given component size is either not specified
+ * or the requested size is zero, it is supposed to act like PERFER_SMALLER.
+ * Well, that's really hard to do with the code as-is. This behavior is
+ * closer to correct, but still not technically right.
+ */
+#define PREFER_LARGER_OR_ZERO(comp) \
+ do { \
+ if ( ((*a)-> comp) != ((*b)-> comp) ) { \
+ if ( ((*a)-> comp) == 0 ) { \
+ return -1; \
+ } \
+ else if ( ((*b)-> comp) == 0 ) { \
+ return 1; \
+ } \
+ else { \
+ return ((*b)-> comp) - ((*a)-> comp) ; \
+ } \
+ } \
+ } while( 0 )
+
+#define PREFER_LARGER(comp) \
+ do { \
+ if ( ((*a)-> comp) != ((*b)-> comp) ) { \
+ return ((*b)-> comp) - ((*a)-> comp) ; \
+ } \
+ } while( 0 )
+
+#define PREFER_SMALLER(comp) \
+ do { \
+ if ( ((*a)-> comp) != ((*b)-> comp) ) { \
+ return ((*a)-> comp) - ((*b)-> comp) ; \
+ } \
+ } while( 0 )
+
+/**
+ * Compare two GLXFBConfigs. This function is intended to be used as the
+ * compare function passed in to qsort.
+ *
+ * \returns If \c a is a "better" config, according to the specification of
+ * SGIX_fbconfig, a number less than zero is returned. If \c b is
+ * better, then a number greater than zero is return. If both are
+ * equal, zero is returned.
+ * \sa qsort, glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX
+ */
+static int
+fbconfig_compare( const __GLcontextModes * const * const a,
+ const __GLcontextModes * const * const b )
+{
+ /* The order of these comparisons must NOT change. It is defined by
+ * the GLX 1.3 spec and ARB_multisample.
+ */
+
+ PREFER_SMALLER( visualSelectGroup );
+
+ /* The sort order for the visualRating is GLX_NONE, GLX_SLOW, and
+ * GLX_NON_CONFORMANT_CONFIG. It just so happens that this is the
+ * numerical sort order of the enums (0x8000, 0x8001, and 0x800D).
+ */
+ PREFER_SMALLER( visualRating );
+
+ /* This isn't quite right. It is supposed to compare the sum of the
+ * components the user specifically set minimums for.
+ */
+ PREFER_LARGER_OR_ZERO( redBits );
+ PREFER_LARGER_OR_ZERO( greenBits );
+ PREFER_LARGER_OR_ZERO( blueBits );
+ PREFER_LARGER_OR_ZERO( alphaBits );
+
+ PREFER_SMALLER( rgbBits );
+
+ if ( ((*a)->doubleBufferMode != (*b)->doubleBufferMode) ) {
+ /* Prefer single-buffer.
+ */
+ return ( !(*a)->doubleBufferMode ) ? -1 : 1;
+ }
+
+ PREFER_SMALLER( numAuxBuffers );
+
+ PREFER_LARGER_OR_ZERO( depthBits );
+ PREFER_SMALLER( stencilBits );
+
+ /* This isn't quite right. It is supposed to compare the sum of the
+ * components the user specifically set minimums for.
+ */
+ PREFER_LARGER_OR_ZERO( accumRedBits );
+ PREFER_LARGER_OR_ZERO( accumGreenBits );
+ PREFER_LARGER_OR_ZERO( accumBlueBits );
+ PREFER_LARGER_OR_ZERO( accumAlphaBits );
+
+ PREFER_SMALLER( visualType );
+
+ /* None of the multisample specs say where this comparison should happen,
+ * so I put it near the end.
+ */
+ PREFER_SMALLER( sampleBuffers );
+ PREFER_SMALLER( samples );
+
+ /* None of the pbuffer or fbconfig specs say that this comparison needs
+ * to happen at all, but it seems like it should.
+ */
+ PREFER_LARGER( maxPbufferWidth );
+ PREFER_LARGER( maxPbufferHeight );
+ PREFER_LARGER( maxPbufferPixels );
+
+ return 0;
+}
+
+
+/**
+ * Selects and sorts a subset of the supplied configs based on the attributes.
+ * This function forms to basis of \c glXChooseVisual, \c glXChooseFBConfig,
+ * and \c glXChooseFBConfigSGIX.
+ *
+ * \param configs Array of pointers to possible configs. The elements of
+ * this array that do not meet the criteria will be set to
+ * NULL. The remaining elements will be sorted according to
+ * the various visual / FBConfig selection rules.
+ * \param num_configs Number of elements in the \c configs array.
+ * \param attribList Attributes used select from \c configs. This array is
+ * terminated by a \c None tag. The array can either take
+ * the form expected by \c glXChooseVisual (where boolean
+ * tags do not have a value) or by \c glXChooseFBConfig
+ * (where every tag has a value).
+ * \param fbconfig_style_tags Selects whether \c attribList is in
+ * \c glXChooseVisual style or
+ * \c glXChooseFBConfig style.
+ * \returns The number of valid elements left in \c configs.
+ *
+ * \sa glXChooseVisual, glXChooseFBConfig, glXChooseFBConfigSGIX
+ */
+static int
+choose_visual( __GLcontextModes ** configs, int num_configs,
+ const int *attribList, GLboolean fbconfig_style_tags )
+{
+ __GLcontextModes test_config;
+ int base;
+ int i;
+
+ /* This is a fairly direct implementation of the selection method
+ * described by GLX_SGIX_fbconfig. Start by culling out all the
+ * configs that are not compatible with the selected parameter
+ * list.
+ */
+
+ init_fbconfig_for_chooser( & test_config, fbconfig_style_tags );
+ __glXInitializeVisualConfigFromTags( & test_config, 512,
+ (const INT32 *) attribList,
+ GL_TRUE, fbconfig_style_tags );
+
+ base = 0;
+ for ( i = 0 ; i < num_configs ; i++ ) {
+ if ( fbconfigs_compatible( & test_config, configs[i] ) ) {
+ configs[ base ] = configs[ i ];
+ base++;
+ }
+ }
+
+ if ( base == 0 ) {
+ return 0;
+ }
+
+ if ( base < num_configs ) {
+ (void) memset( & configs[ base ], 0,
+ sizeof( void * ) * (num_configs - base) );
+ }
+
+ /* After the incompatible configs are removed, the resulting
+ * list is sorted according to the rules set out in the various
+ * specifications.
+ */
+
+ qsort( configs, base, sizeof( __GLcontextModes * ),
+ (int (*)(const void*, const void*)) fbconfig_compare );
+ return base;
+}
+
+
+
+
+/*
+** Return the visual that best matches the template. Return None if no
+** visual matches the template.
+*/
+PUBLIC XVisualInfo *glXChooseVisual(Display *dpy, int screen, int *attribList)
+{
+ XVisualInfo *visualList = NULL;
+ __GLXdisplayPrivate *priv;
+ __GLXscreenConfigs *psc;
+ __GLcontextModes test_config;
+ __GLcontextModes *modes;
+ const __GLcontextModes *best_config = NULL;
+
+ /*
+ ** Get a list of all visuals, return if list is empty
+ */
+ if ( GetGLXPrivScreenConfig( dpy, screen, & priv, & psc ) != Success ) {
+ return None;
+ }
+
+
+ /*
+ ** Build a template from the defaults and the attribute list
+ ** Free visual list and return if an unexpected token is encountered
+ */
+ init_fbconfig_for_chooser( & test_config, GL_FALSE );
+ __glXInitializeVisualConfigFromTags( & test_config, 512,
+ (const INT32 *) attribList,
+ GL_TRUE, GL_FALSE );
+
+ /*
+ ** Eliminate visuals that don't meet minimum requirements
+ ** Compute a score for those that do
+ ** Remember which visual, if any, got the highest score
+ */
+ for ( modes = psc->configs ; modes != NULL ; modes = modes->next ) {
+ if ( fbconfigs_compatible( & test_config, modes )
+ && ((best_config == NULL)
+ || (fbconfig_compare( (const __GLcontextModes * const * const)&modes, &best_config ) < 0)) ) {
+ best_config = modes;
+ }
+ }
+
+ /*
+ ** If no visual is acceptable, return None
+ ** Otherwise, create an XVisualInfo list with just the selected X visual
+ ** and return this.
+ */
+ if (best_config != NULL) {
+ XVisualInfo visualTemplate;
+ int i;
+
+ visualTemplate.screen = screen;
+ visualTemplate.visualid = best_config->visualID;
+ visualList = XGetVisualInfo( dpy, VisualScreenMask|VisualIDMask,
+ &visualTemplate, &i );
+ }
+
+ return visualList;
+}
+
+
+PUBLIC const char *glXQueryExtensionsString( Display *dpy, int screen )
+{
+ __GLXscreenConfigs *psc;
+ __GLXdisplayPrivate *priv;
+
+ if ( GetGLXPrivScreenConfig( dpy, screen, & priv, & psc ) != Success ) {
+ return NULL;
+ }
+
+ if (!psc->effectiveGLXexts) {
+ if (!psc->serverGLXexts) {
+ psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
+ X_GLXQueryServerString,
+ screen, GLX_EXTENSIONS);
+ }
+
+ __glXCalculateUsableExtensions(psc,
+#ifdef GLX_DIRECT_RENDERING
+ (psc->driScreen.private != NULL),
+#else
+ GL_FALSE,
+#endif
+ priv->minorVersion);
+ }
+
+ return psc->effectiveGLXexts;
+}
+
+PUBLIC const char *glXGetClientString( Display *dpy, int name )
+{
+ switch(name) {
+ case GLX_VENDOR:
+ return (__glXGLXClientVendorName);
+ case GLX_VERSION:
+ return (__glXGLXClientVersion);
+ case GLX_EXTENSIONS:
+ return (__glXGetClientExtensions());
+ default:
+ return NULL;
+ }
+}
+
+PUBLIC const char *glXQueryServerString( Display *dpy, int screen, int name )
+{
+ __GLXscreenConfigs *psc;
+ __GLXdisplayPrivate *priv;
+ const char ** str;
+
+
+ if ( GetGLXPrivScreenConfig( dpy, screen, & priv, & psc ) != Success ) {
+ return NULL;
+ }
+
+ switch(name) {
+ case GLX_VENDOR:
+ str = & priv->serverGLXvendor;
+ break;
+ case GLX_VERSION:
+ str = & priv->serverGLXversion;
+ break;
+ case GLX_EXTENSIONS:
+ str = & psc->serverGLXexts;
+ break;
+ default:
+ return NULL;
+ }
+
+ if ( *str == NULL ) {
+ *str = __glXGetStringFromServer(dpy, priv->majorOpcode,
+ X_GLXQueryServerString, screen, name);
+ }
+
+ return *str;
+}
+
+void __glXClientInfo ( Display *dpy, int opcode )
+{
+ xGLXClientInfoReq *req;
+ int size;
+ char * ext_str = __glXGetClientGLExtensionString();
+
+ /* Send the glXClientInfo request */
+ LockDisplay(dpy);
+ GetReq(GLXClientInfo,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXClientInfo;
+ req->major = GLX_MAJOR_VERSION;
+ req->minor = GLX_MINOR_VERSION;
+
+ size = strlen( ext_str ) + 1;
+ req->length += (size + 3) >> 2;
+ req->numbytes = size;
+ Data(dpy, ext_str, size);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ Xfree( ext_str );
+}
+
+
+/*
+** EXT_import_context
+*/
+
+PUBLIC Display *glXGetCurrentDisplay(void)
+{
+ GLXContext gc = __glXGetCurrentContext();
+ if (NULL == gc) return NULL;
+ return gc->currentDpy;
+}
+
+PUBLIC GLX_ALIAS(Display *, glXGetCurrentDisplayEXT, (void), (),
+ glXGetCurrentDisplay)
+
+/**
+ * Used internally by libGL to send \c xGLXQueryContextinfoExtReq requests
+ * to the X-server.
+ *
+ * \param dpy Display where \c ctx was created.
+ * \param ctx Context to query.
+ * \returns \c Success on success. \c GLX_BAD_CONTEXT if \c ctx is invalid,
+ * or zero if the request failed due to internal problems (i.e.,
+ * unable to allocate temporary memory, etc.)
+ *
+ * \note
+ * This function dynamically determines whether to use the EXT_import_context
+ * version of the protocol or the GLX 1.3 version of the protocol.
+ */
+static int __glXQueryContextInfo(Display *dpy, GLXContext ctx)
+{
+ __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+ xGLXQueryContextReply reply;
+ CARD8 opcode;
+ GLuint numValues;
+ int retval;
+
+ if (ctx == NULL) {
+ return GLX_BAD_CONTEXT;
+ }
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return 0;
+ }
+
+ /* Send the glXQueryContextInfoEXT request */
+ LockDisplay(dpy);
+
+ if ( (priv->majorVersion > 1) || (priv->minorVersion >= 3) ) {
+ xGLXQueryContextReq *req;
+
+ GetReq(GLXQueryContext, req);
+
+ req->reqType = opcode;
+ req->glxCode = X_GLXQueryContext;
+ req->context = (unsigned int)(ctx->xid);
+ }
+ else {
+ xGLXVendorPrivateReq *vpreq;
+ xGLXQueryContextInfoEXTReq *req;
+
+ GetReqExtra( GLXVendorPrivate,
+ sz_xGLXQueryContextInfoEXTReq - sz_xGLXVendorPrivateReq,
+ vpreq );
+ req = (xGLXQueryContextInfoEXTReq *)vpreq;
+ req->reqType = opcode;
+ req->glxCode = X_GLXVendorPrivateWithReply;
+ req->vendorCode = X_GLXvop_QueryContextInfoEXT;
+ req->context = (unsigned int)(ctx->xid);
+ }
+
+ _XReply(dpy, (xReply*) &reply, 0, False);
+
+ numValues = reply.n;
+ if (numValues == 0)
+ retval = Success;
+ else if (numValues > __GLX_MAX_CONTEXT_PROPS)
+ retval = 0;
+ else
+ {
+ int *propList, *pProp;
+ int nPropListBytes;
+ int i;
+
+ nPropListBytes = numValues << 3;
+ propList = (int *) Xmalloc(nPropListBytes);
+ if (NULL == propList) {
+ retval = 0;
+ } else {
+ _XRead(dpy, (char *)propList, nPropListBytes);
+ pProp = propList;
+ for (i=0; i < numValues; i++) {
+ switch (*pProp++) {
+ case GLX_SHARE_CONTEXT_EXT:
+ ctx->share_xid = *pProp++;
+ break;
+ case GLX_VISUAL_ID_EXT:
+ ctx->vid = *pProp++;
+ break;
+ case GLX_SCREEN:
+ ctx->screen = *pProp++;
+ break;
+ case GLX_FBCONFIG_ID:
+ ctx->fbconfigID = *pProp++;
+ break;
+ case GLX_RENDER_TYPE:
+ ctx->renderType = *pProp++;
+ break;
+ default:
+ pProp++;
+ continue;
+ }
+ }
+ Xfree((char *)propList);
+ retval = Success;
+ }
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return retval;
+}
+
+PUBLIC int
+glXQueryContext(Display *dpy, GLXContext ctx, int attribute, int *value)
+{
+ int retVal;
+
+ /* get the information from the server if we don't have it already */
+ if (!ctx->isDirect && (ctx->vid == None)) {
+ retVal = __glXQueryContextInfo(dpy, ctx);
+ if (Success != retVal) return retVal;
+ }
+ switch (attribute) {
+ case GLX_SHARE_CONTEXT_EXT:
+ *value = (int)(ctx->share_xid);
+ break;
+ case GLX_VISUAL_ID_EXT:
+ *value = (int)(ctx->vid);
+ break;
+ case GLX_SCREEN:
+ *value = (int)(ctx->screen);
+ break;
+ case GLX_FBCONFIG_ID:
+ *value = (int)(ctx->fbconfigID);
+ break;
+ case GLX_RENDER_TYPE:
+ *value = (int)(ctx->renderType);
+ break;
+ default:
+ return GLX_BAD_ATTRIBUTE;
+ }
+ return Success;
+}
+
+PUBLIC GLX_ALIAS( int, glXQueryContextInfoEXT,
+ (Display *dpy, GLXContext ctx, int attribute, int *value),
+ (dpy, ctx, attribute, value),
+ glXQueryContext )
+
+PUBLIC GLXContextID glXGetContextIDEXT(const GLXContext ctx)
+{
+ return ctx->xid;
+}
+
+PUBLIC GLXContext glXImportContextEXT(Display *dpy, GLXContextID contextID)
+{
+ GLXContext ctx;
+
+ if (contextID == None) {
+ return NULL;
+ }
+ if (__glXIsDirect(dpy, contextID)) {
+ return NULL;
+ }
+
+ ctx = CreateContext(dpy, NULL, NULL, NULL, False, contextID, False, 0);
+ if (NULL != ctx) {
+ if (Success != __glXQueryContextInfo(dpy, ctx)) {
+ return NULL;
+ }
+ }
+ return ctx;
+}
+
+PUBLIC void glXFreeContextEXT(Display *dpy, GLXContext ctx)
+{
+ DestroyContext(dpy, ctx);
+}
+
+
+
+/*
+ * GLX 1.3 functions - these are just stubs for now!
+ */
+
+PUBLIC GLXFBConfig *glXChooseFBConfig(Display *dpy, int screen,
+ const int *attribList, int *nitems)
+{
+ __GLcontextModes ** config_list;
+ int list_size;
+
+
+ config_list = (__GLcontextModes **)
+ glXGetFBConfigs( dpy, screen, & list_size );
+
+ if ( (config_list != NULL) && (list_size > 0) && (attribList != NULL) ) {
+ list_size = choose_visual( config_list, list_size, attribList,
+ GL_TRUE );
+ if ( list_size == 0 ) {
+ XFree( config_list );
+ config_list = NULL;
+ }
+ }
+
+ *nitems = list_size;
+ return (GLXFBConfig *) config_list;
+}
+
+
+PUBLIC GLXContext glXCreateNewContext(Display *dpy, GLXFBConfig config,
+ int renderType, GLXContext shareList,
+ Bool allowDirect)
+{
+ return CreateContext( dpy, NULL, (__GLcontextModes *) config, shareList,
+ allowDirect, None, True, renderType );
+}
+
+
+PUBLIC GLXDrawable glXGetCurrentReadDrawable(void)
+{
+ GLXContext gc = __glXGetCurrentContext();
+ return gc->currentReadable;
+}
+
+
+PUBLIC GLXFBConfig *glXGetFBConfigs(Display *dpy, int screen, int *nelements)
+{
+ __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+ __GLcontextModes ** config = NULL;
+ int i;
+
+ if ( (priv->screenConfigs != NULL)
+ && (screen >= 0) && (screen <= ScreenCount(dpy))
+ && (priv->screenConfigs[screen].configs != NULL)
+ && (priv->screenConfigs[screen].configs->fbconfigID != GLX_DONT_CARE) ) {
+ unsigned num_configs = 0;
+ __GLcontextModes * modes;
+
+
+ for ( modes = priv->screenConfigs[screen].configs
+ ; modes != NULL
+ ; modes = modes->next ) {
+ if ( modes->fbconfigID != GLX_DONT_CARE ) {
+ num_configs++;
+ }
+ }
+
+ config = (__GLcontextModes **) Xmalloc( sizeof(__GLcontextModes *)
+ * num_configs );
+ if ( config != NULL ) {
+ *nelements = num_configs;
+ i = 0;
+ for ( modes = priv->screenConfigs[screen].configs
+ ; modes != NULL
+ ; modes = modes->next ) {
+ config[i] = modes;
+ i++;
+ }
+ }
+ }
+ return (GLXFBConfig *) config;
+}
+
+
+PUBLIC int glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config,
+ int attribute, int *value)
+{
+ __GLcontextModes * const modes = ValidateGLXFBConfig( dpy, config );
+
+ return (modes != NULL)
+ ? _gl_get_context_mode_data( modes, attribute, value )
+ : GLXBadFBConfig;
+}
+
+
+PUBLIC XVisualInfo *glXGetVisualFromFBConfig(Display *dpy, GLXFBConfig config)
+{
+ XVisualInfo visualTemplate;
+ __GLcontextModes * fbconfig = (__GLcontextModes *) config;
+ int count;
+
+ /*
+ ** Get a list of all visuals, return if list is empty
+ */
+ visualTemplate.visualid = fbconfig->visualID;
+ return XGetVisualInfo(dpy,VisualIDMask,&visualTemplate,&count);
+}
+
+
+/*
+** GLX_SGI_make_current_read
+*/
+
+PUBLIC GLX_ALIAS(GLXDrawable, glXGetCurrentReadDrawableSGI, (void), (),
+ glXGetCurrentReadDrawable)
+
+
+/*
+** GLX_SGI_swap_control
+*/
+PUBLIC int glXSwapIntervalSGI(int interval)
+{
+ xGLXVendorPrivateReq *req;
+ GLXContext gc = __glXGetCurrentContext();
+ Display * dpy;
+ CARD32 * interval_ptr;
+ CARD8 opcode;
+
+ if ( gc == NULL ) {
+ return GLX_BAD_CONTEXT;
+ }
+
+ if ( interval <= 0 ) {
+ return GLX_BAD_VALUE;
+ }
+
+#ifdef GLX_DIRECT_RENDERING
+ if ( gc->isDirect ) {
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
+ gc->screen );
+ __DRIdrawable * const pdraw = GetDRIDrawable( gc->currentDpy,
+ gc->currentDrawable,
+ NULL );
+ if ( __glXExtensionBitIsEnabled( psc, SGI_swap_control_bit )
+ && (pdraw != NULL) ) {
+ pdraw->swap_interval = interval;
+ return 0;
+ }
+ else {
+ return GLX_BAD_CONTEXT;
+ }
+ }
+#endif
+ dpy = gc->currentDpy;
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return 0;
+ }
+
+ /* Send the glXSwapIntervalSGI request */
+ LockDisplay(dpy);
+ GetReqExtra(GLXVendorPrivate,sizeof(CARD32),req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXVendorPrivate;
+ req->vendorCode = X_GLXvop_SwapIntervalSGI;
+ req->contextTag = gc->currentContextTag;
+
+ interval_ptr = (CARD32 *) req + 1;
+ *interval_ptr = interval;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ XFlush(dpy);
+
+ return 0;
+}
+
+
+/*
+** GLX_MESA_swap_control
+*/
+PUBLIC GLint glXSwapIntervalMESA(unsigned interval)
+{
+#ifdef GLX_DIRECT_RENDERING
+ GLXContext gc = __glXGetCurrentContext();
+
+ if ( interval < 0 ) {
+ return GLX_BAD_VALUE;
+ }
+
+ if ( (gc != NULL) && gc->isDirect ) {
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
+ gc->screen );
+
+ if ( (psc != NULL) && (psc->driScreen.private != NULL)
+ && __glXExtensionBitIsEnabled( psc, MESA_swap_control_bit ) ) {
+ __DRIdrawable * const pdraw =
+ (*psc->driScreen.getDrawable)(gc->currentDpy,
+ gc->currentDrawable,
+ psc->driScreen.private);
+ if ( pdraw != NULL ) {
+ pdraw->swap_interval = interval;
+ return 0;
+ }
+ }
+ }
+#else
+ (void) interval;
+#endif
+
+ return GLX_BAD_CONTEXT;
+}
+
+PUBLIC GLint glXGetSwapIntervalMESA( void )
+{
+#ifdef GLX_DIRECT_RENDERING
+ GLXContext gc = __glXGetCurrentContext();
+
+ if ( (gc != NULL) && gc->isDirect ) {
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
+ gc->screen );
+
+ if ( (psc != NULL) && (psc->driScreen.private != NULL)
+ && __glXExtensionBitIsEnabled( psc, MESA_swap_control_bit ) ) {
+ __DRIdrawable * const pdraw =
+ (*psc->driScreen.getDrawable)(gc->currentDpy,
+ gc->currentDrawable,
+ psc->driScreen.private);
+ if ( pdraw != NULL ) {
+ return pdraw->swap_interval;
+ }
+ }
+ }
+#endif
+
+ return 0;
+}
+
+
+/*
+** GLX_MESA_swap_frame_usage
+*/
+
+PUBLIC GLint glXBeginFrameTrackingMESA(Display *dpy, GLXDrawable drawable)
+{
+ int status = GLX_BAD_CONTEXT;
+#ifdef GLX_DIRECT_RENDERING
+ int screen;
+ __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen);
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
+
+ if ( (pdraw != NULL) && (pdraw->frameTracking != NULL)
+ && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) {
+ status = pdraw->frameTracking( dpy, pdraw->private, GL_TRUE );
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+#endif
+ return status;
+}
+
+
+PUBLIC GLint glXEndFrameTrackingMESA(Display *dpy, GLXDrawable drawable)
+{
+ int status = GLX_BAD_CONTEXT;
+#ifdef GLX_DIRECT_RENDERING
+ int screen;
+ __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen);
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
+
+ if ( (pdraw != NULL) && (pdraw->frameTracking != NULL)
+ && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) {
+ status = pdraw->frameTracking( dpy, pdraw->private, GL_FALSE );
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+#endif
+ return status;
+}
+
+
+PUBLIC GLint glXGetFrameUsageMESA(Display *dpy, GLXDrawable drawable,
+ GLfloat *usage)
+{
+ int status = GLX_BAD_CONTEXT;
+#ifdef GLX_DIRECT_RENDERING
+ int screen;
+ __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen);
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
+
+ if ( (pdraw != NULL ) && (pdraw->queryFrameTracking != NULL)
+ && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) {
+ int64_t sbc, missedFrames;
+ float lastMissedUsage;
+
+ status = pdraw->queryFrameTracking( dpy, pdraw->private, &sbc,
+ &missedFrames, &lastMissedUsage,
+ usage );
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+ (void) usage;
+#endif
+ return status;
+}
+
+
+PUBLIC GLint glXQueryFrameTrackingMESA(Display *dpy, GLXDrawable drawable,
+ int64_t *sbc, int64_t *missedFrames,
+ GLfloat *lastMissedUsage)
+{
+ int status = GLX_BAD_CONTEXT;
+#ifdef GLX_DIRECT_RENDERING
+ int screen;
+ __DRIdrawable * const pdraw = GetDRIDrawable(dpy, drawable, & screen);
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
+
+ if ( (pdraw != NULL ) && (pdraw->queryFrameTracking != NULL)
+ && __glXExtensionBitIsEnabled( psc, MESA_swap_frame_usage_bit ) ) {
+ float usage;
+
+ status = pdraw->queryFrameTracking( dpy, pdraw->private, sbc,
+ missedFrames, lastMissedUsage,
+ & usage );
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+ (void) sbc;
+ (void) missedFrames;
+ (void) lastMissedUsage;
+#endif
+ return status;
+}
+
+
+/*
+** GLX_SGI_video_sync
+*/
+PUBLIC int glXGetVideoSyncSGI(unsigned int *count)
+{
+ /* FIXME: Looking at the GLX_SGI_video_sync spec in the extension registry,
+ * FIXME: there should be a GLX encoding for this call. I can find no
+ * FIXME: documentation for the GLX encoding.
+ */
+#ifdef GLX_DIRECT_RENDERING
+ GLXContext gc = __glXGetCurrentContext();
+
+
+ if ( (gc != NULL) && gc->isDirect ) {
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
+ gc->screen );
+ if ( __glXExtensionBitIsEnabled( psc, SGI_video_sync_bit )
+ && psc->driScreen.private && psc->driScreen.getMSC) {
+ int ret;
+ int64_t temp;
+
+ ret = psc->driScreen.getMSC( psc->driScreen.private, & temp );
+ *count = (unsigned) temp;
+ return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
+ }
+ }
+#else
+ (void) count;
+#endif
+ return GLX_BAD_CONTEXT;
+}
+
+PUBLIC int glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
+{
+#ifdef GLX_DIRECT_RENDERING
+ GLXContext gc = __glXGetCurrentContext();
+
+ if ( divisor <= 0 || remainder < 0 )
+ return GLX_BAD_VALUE;
+
+ if ( (gc != NULL) && gc->isDirect ) {
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( gc->currentDpy,
+ gc->screen );
+ if ( __glXExtensionBitIsEnabled( psc, SGI_video_sync_bit )
+ && psc->driScreen.private ) {
+ __DRIdrawable * const pdraw =
+ (*psc->driScreen.getDrawable)(gc->currentDpy,
+ gc->currentDrawable,
+ psc->driScreen.private);
+ if ( (pdraw != NULL) && (pdraw->waitForMSC != NULL) ) {
+ int ret;
+ int64_t msc;
+ int64_t sbc;
+
+ ret = (*pdraw->waitForMSC)( gc->currentDpy, pdraw->private,
+ 0, divisor, remainder,
+ & msc, & sbc );
+ *count = (unsigned) msc;
+ return (ret == 0) ? 0 : GLX_BAD_CONTEXT;
+ }
+ }
+ }
+#else
+ (void) count;
+#endif
+ return GLX_BAD_CONTEXT;
+}
+
+
+/*
+** GLX_SGIS_video_source
+*/
+#if defined(_VL_H)
+
+PUBLIC GLXVideoSourceSGIX glXCreateGLXVideoSourceSGIX(Display *dpy,
+ int screen, VLServer server, VLPath path,
+ int nodeClass, VLNode drainNode)
+{
+ (void) dpy;
+ (void) screen;
+ (void) server;
+ (void) path;
+ (void) nodeClass;
+ (void) drainNode;
+ return 0;
+}
+
+PUBLIC void glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
+{
+ (void) dpy;
+ (void) src;
+}
+
+#endif
+
+
+/*
+** GLX_SGIX_fbconfig
+** Many of these functions are aliased to GLX 1.3 entry points in the
+** GLX_functions table.
+*/
+
+PUBLIC GLX_ALIAS(int, glXGetFBConfigAttribSGIX,
+ (Display *dpy, GLXFBConfigSGIX config, int attribute, int *value),
+ (dpy, config, attribute, value),
+ glXGetFBConfigAttrib)
+
+PUBLIC GLX_ALIAS(GLXFBConfigSGIX *, glXChooseFBConfigSGIX,
+ (Display *dpy, int screen, int *attrib_list, int *nelements),
+ (dpy, screen, attrib_list, nelements),
+ glXChooseFBConfig)
+
+PUBLIC GLX_ALIAS(XVisualInfo *, glXGetVisualFromFBConfigSGIX,
+ (Display * dpy, GLXFBConfigSGIX config),
+ (dpy, config),
+ glXGetVisualFromFBConfig)
+
+PUBLIC GLXPixmap glXCreateGLXPixmapWithConfigSGIX(Display *dpy,
+ GLXFBConfigSGIX config, Pixmap pixmap)
+{
+ xGLXVendorPrivateWithReplyReq *vpreq;
+ xGLXCreateGLXPixmapWithConfigSGIXReq *req;
+ GLXPixmap xid = None;
+ CARD8 opcode;
+ const __GLcontextModes * const fbconfig = (__GLcontextModes *) config;
+ __GLXscreenConfigs * psc;
+
+
+ if ( (dpy == NULL) || (config == NULL) ) {
+ return None;
+ }
+
+ psc = GetGLXScreenConfigs( dpy, fbconfig->screen );
+ if ( (psc != NULL)
+ && __glXExtensionBitIsEnabled( psc, SGIX_fbconfig_bit ) ) {
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return None;
+ }
+
+ /* Send the glXCreateGLXPixmapWithConfigSGIX request */
+ LockDisplay(dpy);
+ GetReqExtra(GLXVendorPrivateWithReply,
+ sz_xGLXCreateGLXPixmapWithConfigSGIXReq-sz_xGLXVendorPrivateWithReplyReq,vpreq);
+ req = (xGLXCreateGLXPixmapWithConfigSGIXReq *)vpreq;
+ req->reqType = opcode;
+ req->glxCode = X_GLXVendorPrivateWithReply;
+ req->vendorCode = X_GLXvop_CreateGLXPixmapWithConfigSGIX;
+ req->screen = fbconfig->screen;
+ req->fbconfig = fbconfig->fbconfigID;
+ req->pixmap = pixmap;
+ req->glxpixmap = xid = XAllocID(dpy);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+
+ return xid;
+}
+
+PUBLIC GLXContext glXCreateContextWithConfigSGIX(Display *dpy,
+ GLXFBConfigSGIX config, int renderType,
+ GLXContext shareList, Bool allowDirect)
+{
+ GLXContext gc = NULL;
+ const __GLcontextModes * const fbconfig = (__GLcontextModes *) config;
+ __GLXscreenConfigs * psc;
+
+
+ if ( (dpy == NULL) || (config == NULL) ) {
+ return None;
+ }
+
+ psc = GetGLXScreenConfigs( dpy, fbconfig->screen );
+ if ( (psc != NULL)
+ && __glXExtensionBitIsEnabled( psc, SGIX_fbconfig_bit ) ) {
+ gc = CreateContext( dpy, NULL, (__GLcontextModes *) config, shareList,
+ allowDirect, None, False, renderType );
+ }
+
+ return gc;
+}
+
+
+PUBLIC GLXFBConfigSGIX glXGetFBConfigFromVisualSGIX(Display *dpy,
+ XVisualInfo *vis)
+{
+ __GLXdisplayPrivate *priv;
+ __GLXscreenConfigs *psc;
+
+ if ( (GetGLXPrivScreenConfig( dpy, vis->screen, & priv, & psc ) != Success)
+ && __glXExtensionBitIsEnabled( psc, SGIX_fbconfig_bit )
+ && (psc->configs->fbconfigID != GLX_DONT_CARE) ) {
+ return (GLXFBConfigSGIX) _gl_context_modes_find_visual( psc->configs,
+ vis->visualid );
+ }
+
+ return NULL;
+}
+
+
+/*
+** GLX_SGI_cushion
+*/
+PUBLIC void glXCushionSGI(Display *dpy, Window win, float cushion)
+{
+ (void) dpy;
+ (void) win;
+ (void) cushion;
+}
+
+
+/*
+** GLX_SGIX_video_resize
+*/
+PUBLIC int glXBindChannelToWindowSGIX(Display *dpy, int screen,
+ int channel , Window window)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) window;
+ return 0;
+}
+
+PUBLIC int glXChannelRectSGIX(Display *dpy, int screen, int channel,
+ int x, int y, int w, int h)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) x;
+ (void) y;
+ (void) w;
+ (void) h;
+ return 0;
+}
+
+PUBLIC int glXQueryChannelRectSGIX(Display *dpy, int screen, int channel,
+ int *x, int *y, int *w, int *h)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) x;
+ (void) y;
+ (void) w;
+ (void) h;
+ return 0;
+}
+
+int glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel,
+ int *dx, int *dy, int *dw, int *dh)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) dx;
+ (void) dy;
+ (void) dw;
+ (void) dh;
+ return 0;
+}
+
+PUBLIC int glXChannelRectSyncSGIX(Display *dpy, int screen,
+ int channel, GLenum synctype)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) synctype;
+ return 0;
+}
+
+
+#if defined(_DM_BUFFER_H_)
+
+PUBLIC Bool glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer,
+ DMparams *params, DMbuffer dmbuffer)
+{
+ (void) dpy;
+ (void) pbuffer;
+ (void) params;
+ (void) dmbuffer;
+ return False;
+}
+
+#endif
+
+
+/*
+** GLX_SGIX_swap_group
+*/
+PUBLIC void glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable,
+ GLXDrawable member)
+{
+ (void) dpy;
+ (void) drawable;
+ (void) member;
+}
+
+
+/*
+** GLX_SGIX_swap_barrier
+*/
+PUBLIC void glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable,
+ int barrier)
+{
+ (void) dpy;
+ (void) drawable;
+ (void) barrier;
+}
+
+PUBLIC Bool glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
+{
+ (void) dpy;
+ (void) screen;
+ (void) max;
+ return False;
+}
+
+
+/*
+** GLX_SUN_get_transparent_index
+*/
+PUBLIC Status glXGetTransparentIndexSUN(Display *dpy, Window overlay,
+ Window underlay, long *pTransparent)
+{
+ (void) dpy;
+ (void) overlay;
+ (void) underlay;
+ (void) pTransparent;
+ return 0;
+}
+
+
+/*
+** GLX_OML_sync_control
+*/
+PUBLIC Bool glXGetSyncValuesOML(Display *dpy, GLXDrawable drawable,
+ int64_t *ust, int64_t *msc, int64_t *sbc)
+{
+#ifdef GLX_DIRECT_RENDERING
+ __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
+
+ if ( priv != NULL ) {
+ int i;
+ __DRIdrawable * const pdraw = GetDRIDrawable( dpy, drawable, & i );
+ __GLXscreenConfigs * const psc = &priv->screenConfigs[i];
+
+ assert( (pdraw == NULL) || (i != -1) );
+ return ( (pdraw && pdraw->getSBC && psc->driScreen.getMSC)
+ && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit )
+ && ((*psc->driScreen.getMSC)( psc->driScreen.private, msc ) == 0)
+ && ((*pdraw->getSBC)( dpy, psc->driScreen.private, sbc ) == 0)
+ && (__glXGetUST( ust ) == 0) );
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+ (void) ust;
+ (void) msc;
+ (void) sbc;
+#endif
+ return False;
+}
+
+
+/**
+ * Determine the refresh rate of the specified drawable and display.
+ *
+ * \param dpy Display whose refresh rate is to be determined.
+ * \param drawable Drawable whose refresh rate is to be determined.
+ * \param numerator Numerator of the refresh rate.
+ * \param demoninator Denominator of the refresh rate.
+ * \return If the refresh rate for the specified display and drawable could
+ * be calculated, True is returned. Otherwise False is returned.
+ *
+ * \note This function is implemented entirely client-side. A lot of other
+ * functionality is required to export GLX_OML_sync_control, so on
+ * XFree86 this function can be called for direct-rendering contexts
+ * when GLX_OML_sync_control appears in the client extension string.
+ */
+
+PUBLIC Bool glXGetMscRateOML(Display * dpy, GLXDrawable drawable,
+ int32_t * numerator, int32_t * denominator)
+{
+#if defined( GLX_DIRECT_RENDERING ) && defined( XF86VIDMODE )
+ __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
+
+
+ if ( priv != NULL ) {
+ XF86VidModeModeLine mode_line;
+ int dot_clock;
+ int screen_num;
+ int i;
+
+
+ GetDRIDrawable( dpy, drawable, & screen_num );
+ if ( (screen_num != -1)
+ && XF86VidModeQueryVersion( dpy, & i, & i )
+ && XF86VidModeGetModeLine( dpy, screen_num, & dot_clock,
+ & mode_line ) ) {
+ unsigned n = dot_clock * 1000;
+ unsigned d = mode_line.vtotal * mode_line.htotal;
+
+# define V_INTERLACE 0x010
+# define V_DBLSCAN 0x020
+
+ if ( (mode_line.flags & V_INTERLACE) ) {
+ n *= 2;
+ }
+ else if ( (mode_line.flags & V_DBLSCAN) ) {
+ d *= 2;
+ }
+
+ /* The OML_sync_control spec requires that if the refresh rate is a
+ * whole number, that the returned numerator be equal to the refresh
+ * rate and the denominator be 1.
+ */
+
+ if ( (n % d) == 0 ) {
+ n /= d;
+ d = 1;
+ }
+ else {
+ static const unsigned f[] = { 13, 11, 7, 5, 3, 2, 0 };
+
+
+ /* This is a poor man's way to reduce a fraction. It's far from
+ * perfect, but it will work well enough for this situation.
+ */
+
+ for ( i = 0 ; f[i] != 0 ; i++ ) {
+ while ( ((n % f[i]) == 0) && ((d % f[i]) == 0) ) {
+ d /= f[i];
+ n /= f[i];
+ }
+ }
+ }
+
+ *numerator = n;
+ *denominator = d;
+
+ (void) drawable;
+ return True;
+ }
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+ (void) numerator;
+ (void) denominator;
+#endif
+ return False;
+}
+
+
+PUBLIC int64_t glXSwapBuffersMscOML(Display *dpy, GLXDrawable drawable,
+ int64_t target_msc, int64_t divisor,
+ int64_t remainder)
+{
+#ifdef GLX_DIRECT_RENDERING
+ int screen;
+ __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
+
+ /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE
+ * error", but it also says "It [glXSwapBuffersMscOML] will return a value
+ * of -1 if the function failed because of errors detected in the input
+ * parameters"
+ */
+ if ( divisor < 0 || remainder < 0 || target_msc < 0 )
+ return -1;
+ if ( divisor > 0 && remainder >= divisor )
+ return -1;
+
+ if ( (pdraw != NULL) && (pdraw->swapBuffersMSC != NULL)
+ && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) ) {
+ return (*pdraw->swapBuffersMSC)(dpy, pdraw->private, target_msc,
+ divisor, remainder);
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+ (void) target_msc;
+ (void) divisor;
+ (void) remainder;
+#endif
+ return 0;
+}
+
+
+PUBLIC Bool glXWaitForMscOML(Display * dpy, GLXDrawable drawable,
+ int64_t target_msc, int64_t divisor,
+ int64_t remainder, int64_t *ust,
+ int64_t *msc, int64_t *sbc)
+{
+#ifdef GLX_DIRECT_RENDERING
+ int screen;
+ __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
+ int ret;
+
+ /* The OML_sync_control spec says these should "generate a GLX_BAD_VALUE
+ * error", but the return type in the spec is Bool.
+ */
+ if ( divisor < 0 || remainder < 0 || target_msc < 0 )
+ return False;
+ if ( divisor > 0 && remainder >= divisor )
+ return False;
+
+ if ( (pdraw != NULL) && (pdraw->waitForMSC != NULL)
+ && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit ) ) {
+ ret = (*pdraw->waitForMSC)( dpy, pdraw->private, target_msc,
+ divisor, remainder, msc, sbc );
+
+ /* __glXGetUST returns zero on success and non-zero on failure.
+ * This function returns True on success and False on failure.
+ */
+ return ( (ret == 0) && (__glXGetUST( ust ) == 0) );
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+ (void) target_msc;
+ (void) divisor;
+ (void) remainder;
+ (void) ust;
+ (void) msc;
+ (void) sbc;
+#endif
+ return False;
+}
+
+
+PUBLIC Bool glXWaitForSbcOML(Display * dpy, GLXDrawable drawable,
+ int64_t target_sbc, int64_t *ust,
+ int64_t *msc, int64_t *sbc )
+{
+#ifdef GLX_DIRECT_RENDERING
+ int screen;
+ __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
+ int ret;
+
+ /* The OML_sync_control spec says this should "generate a GLX_BAD_VALUE
+ * error", but the return type in the spec is Bool.
+ */
+ if ( target_sbc < 0 )
+ return False;
+
+ if ( (pdraw != NULL) && (pdraw->waitForSBC != NULL)
+ && __glXExtensionBitIsEnabled( psc, OML_sync_control_bit )) {
+ ret = (*pdraw->waitForSBC)( dpy, pdraw->private, target_sbc, msc, sbc );
+
+ /* __glXGetUST returns zero on success and non-zero on failure.
+ * This function returns True on success and False on failure.
+ */
+ return( (ret == 0) && (__glXGetUST( ust ) == 0) );
+ }
+#else
+ (void) dpy;
+ (void) drawable;
+ (void) target_sbc;
+ (void) ust;
+ (void) msc;
+ (void) sbc;
+#endif
+ return False;
+}
+
+
+/**
+ * GLX_MESA_allocate_memory
+ */
+/*@{*/
+
+PUBLIC void *glXAllocateMemoryMESA(Display *dpy, int scrn,
+ size_t size, float readFreq,
+ float writeFreq, float priority)
+{
+#ifdef GLX_DIRECT_RENDERING
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn );
+
+ if ( __glXExtensionBitIsEnabled( psc, MESA_allocate_memory_bit ) ) {
+ if (psc && psc->driScreen.private && psc->driScreen.allocateMemory) {
+ return (*psc->driScreen.allocateMemory)( dpy, scrn, size,
+ readFreq, writeFreq,
+ priority );
+ }
+ }
+#else
+ (void) dpy;
+ (void) scrn;
+ (void) size;
+ (void) readFreq;
+ (void) writeFreq;
+ (void) priority;
+#endif /* GLX_DIRECT_RENDERING */
+
+ return NULL;
+}
+
+
+PUBLIC void glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer)
+{
+#ifdef GLX_DIRECT_RENDERING
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn );
+
+ if ( __glXExtensionBitIsEnabled( psc, MESA_allocate_memory_bit ) ) {
+ if (psc && psc->driScreen.private && psc->driScreen.freeMemory) {
+ (*psc->driScreen.freeMemory)( dpy, scrn, pointer );
+ }
+ }
+#else
+ (void) dpy;
+ (void) scrn;
+ (void) pointer;
+#endif /* GLX_DIRECT_RENDERING */
+}
+
+
+PUBLIC GLuint glXGetMemoryOffsetMESA( Display *dpy, int scrn,
+ const void *pointer )
+{
+#ifdef GLX_DIRECT_RENDERING
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, scrn );
+
+ if ( __glXExtensionBitIsEnabled( psc, MESA_allocate_memory_bit ) ) {
+ if (psc && psc->driScreen.private && psc->driScreen.memoryOffset) {
+ return (*psc->driScreen.memoryOffset)( dpy, scrn, pointer );
+ }
+ }
+#else
+ (void) dpy;
+ (void) scrn;
+ (void) pointer;
+#endif /* GLX_DIRECT_RENDERING */
+
+ return ~0L;
+}
+/*@}*/
+
+
+/**
+ * Mesa extension stubs. These will help reduce portability problems.
+ */
+/*@{*/
+
+/**
+ * Release all buffers associated with the specified GLX drawable.
+ *
+ * \todo
+ * This function was intended for stand-alone Mesa. The issue there is that
+ * the library doesn't get any notification when a window is closed. In
+ * DRI there is a similar but slightly different issue. When GLX 1.3 is
+ * supported, there are 3 different functions to destroy a drawable. It
+ * should be possible to create GLX protocol (or have it determine which
+ * protocol to use based on the type of the drawable) to have one function
+ * do the work of 3. For the direct-rendering case, this function could
+ * just call the driver's \c __DRIdrawableRec::destroyDrawable function.
+ * This would reduce the frequency with which \c __driGarbageCollectDrawables
+ * would need to be used. This really should be done as part of the new DRI
+ * interface work.
+ *
+ * \sa http://oss.sgi.com/projects/ogl-sample/registry/MESA/release_buffers.txt
+ * __driGarbageCollectDrawables
+ * glXDestroyGLXPixmap
+ * glXDestroyPbuffer glXDestroyPixmap glXDestroyWindow
+ * glXDestroyGLXPbufferSGIX glXDestroyGLXVideoSourceSGIX
+ */
+PUBLIC Bool glXReleaseBuffersMESA( Display *dpy, GLXDrawable d )
+{
+ (void) dpy;
+ (void) d;
+ return False;
+}
+
+
+PUBLIC GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual,
+ Pixmap pixmap, Colormap cmap )
+{
+ (void) dpy;
+ (void) visual;
+ (void) pixmap;
+ (void) cmap;
+ return 0;
+}
+
+
+PUBLIC 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;
+}
+
+
+PUBLIC Bool glXSet3DfxModeMESA( int mode )
+{
+ (void) mode;
+ return GL_FALSE;
+}
+/*@}*/
+
+
+
+/**
+ * \c strdup is actually not a standard ANSI C or POSIX routine.
+ * Irix will not define it if ANSI mode is in effect.
+ *
+ * \sa strdup
+ */
+char *
+__glXstrdup(const char *str)
+{
+ char *copy;
+ copy = (char *) Xmalloc(strlen(str) + 1);
+ if (!copy)
+ return NULL;
+ strcpy(copy, str);
+ return copy;
+}
+
+/*
+** glXGetProcAddress support
+*/
+
+struct name_address_pair {
+ const char *Name;
+ GLvoid *Address;
+};
+
+#define GLX_FUNCTION(f) { # f, (GLvoid *) f }
+#define GLX_FUNCTION2(n,f) { # n, (GLvoid *) f }
+
+static const struct name_address_pair GLX_functions[] = {
+ /*** GLX_VERSION_1_0 ***/
+ GLX_FUNCTION( glXChooseVisual ),
+ GLX_FUNCTION( glXCopyContext ),
+ GLX_FUNCTION( glXCreateContext ),
+ GLX_FUNCTION( glXCreateGLXPixmap ),
+ GLX_FUNCTION( glXDestroyContext ),
+ GLX_FUNCTION( glXDestroyGLXPixmap ),
+ GLX_FUNCTION( glXGetConfig ),
+ GLX_FUNCTION( glXGetCurrentContext ),
+ GLX_FUNCTION( glXGetCurrentDrawable ),
+ GLX_FUNCTION( glXIsDirect ),
+ GLX_FUNCTION( glXMakeCurrent ),
+ GLX_FUNCTION( glXQueryExtension ),
+ GLX_FUNCTION( glXQueryVersion ),
+ GLX_FUNCTION( glXSwapBuffers ),
+ GLX_FUNCTION( glXUseXFont ),
+ GLX_FUNCTION( glXWaitGL ),
+ GLX_FUNCTION( glXWaitX ),
+
+ /*** GLX_VERSION_1_1 ***/
+ GLX_FUNCTION( glXGetClientString ),
+ GLX_FUNCTION( glXQueryExtensionsString ),
+ GLX_FUNCTION( glXQueryServerString ),
+
+ /*** GLX_VERSION_1_2 ***/
+ GLX_FUNCTION( glXGetCurrentDisplay ),
+
+ /*** GLX_VERSION_1_3 ***/
+ GLX_FUNCTION( glXChooseFBConfig ),
+ GLX_FUNCTION( glXCreateNewContext ),
+ GLX_FUNCTION( glXCreatePbuffer ),
+ GLX_FUNCTION( glXCreatePixmap ),
+ GLX_FUNCTION( glXCreateWindow ),
+ GLX_FUNCTION( glXDestroyPbuffer ),
+ GLX_FUNCTION( glXDestroyPixmap ),
+ GLX_FUNCTION( glXDestroyWindow ),
+ GLX_FUNCTION( glXGetCurrentReadDrawable ),
+ GLX_FUNCTION( glXGetFBConfigAttrib ),
+ GLX_FUNCTION( glXGetFBConfigs ),
+ GLX_FUNCTION( glXGetSelectedEvent ),
+ GLX_FUNCTION( glXGetVisualFromFBConfig ),
+ GLX_FUNCTION( glXMakeContextCurrent ),
+ GLX_FUNCTION( glXQueryContext ),
+ GLX_FUNCTION( glXQueryDrawable ),
+ GLX_FUNCTION( glXSelectEvent ),
+
+ /*** GLX_SGI_swap_control ***/
+ GLX_FUNCTION( glXSwapIntervalSGI ),
+
+ /*** GLX_SGI_video_sync ***/
+ GLX_FUNCTION( glXGetVideoSyncSGI ),
+ GLX_FUNCTION( glXWaitVideoSyncSGI ),
+
+ /*** GLX_SGI_make_current_read ***/
+ GLX_FUNCTION2( glXMakeCurrentReadSGI, glXMakeContextCurrent ),
+ GLX_FUNCTION2( glXGetCurrentReadDrawableSGI, glXGetCurrentReadDrawable ),
+
+ /*** GLX_SGIX_video_source ***/
+#if defined(_VL_H)
+ GLX_FUNCTION( glXCreateGLXVideoSourceSGIX ),
+ GLX_FUNCTION( glXDestroyGLXVideoSourceSGIX ),
+#endif
+
+ /*** GLX_EXT_import_context ***/
+ GLX_FUNCTION( glXFreeContextEXT ),
+ GLX_FUNCTION( glXGetContextIDEXT ),
+ GLX_FUNCTION2( glXGetCurrentDisplayEXT, glXGetCurrentDisplay ),
+ GLX_FUNCTION( glXImportContextEXT ),
+ GLX_FUNCTION2( glXQueryContextInfoEXT, glXQueryContext ),
+
+ /*** GLX_SGIX_fbconfig ***/
+ GLX_FUNCTION2( glXGetFBConfigAttribSGIX, glXGetFBConfigAttrib ),
+ GLX_FUNCTION2( glXChooseFBConfigSGIX, glXChooseFBConfig ),
+ GLX_FUNCTION( glXCreateGLXPixmapWithConfigSGIX ),
+ GLX_FUNCTION( glXCreateContextWithConfigSGIX ),
+ GLX_FUNCTION2( glXGetVisualFromFBConfigSGIX, glXGetVisualFromFBConfig ),
+ GLX_FUNCTION( glXGetFBConfigFromVisualSGIX ),
+
+ /*** GLX_SGIX_pbuffer ***/
+ GLX_FUNCTION( glXCreateGLXPbufferSGIX ),
+ GLX_FUNCTION( glXDestroyGLXPbufferSGIX ),
+ GLX_FUNCTION( glXQueryGLXPbufferSGIX ),
+ GLX_FUNCTION( glXSelectEventSGIX ),
+ GLX_FUNCTION( glXGetSelectedEventSGIX ),
+
+ /*** GLX_SGI_cushion ***/
+ GLX_FUNCTION( glXCushionSGI ),
+
+ /*** GLX_SGIX_video_resize ***/
+ GLX_FUNCTION( glXBindChannelToWindowSGIX ),
+ GLX_FUNCTION( glXChannelRectSGIX ),
+ GLX_FUNCTION( glXQueryChannelRectSGIX ),
+ GLX_FUNCTION( glXQueryChannelDeltasSGIX ),
+ GLX_FUNCTION( glXChannelRectSyncSGIX ),
+
+ /*** GLX_SGIX_dmbuffer **/
+#if defined(_DM_BUFFER_H_)
+ GLX_FUNCTION( glXAssociateDMPbufferSGIX ),
+#endif
+
+ /*** GLX_SGIX_swap_group ***/
+ GLX_FUNCTION( glXJoinSwapGroupSGIX ),
+
+ /*** GLX_SGIX_swap_barrier ***/
+ GLX_FUNCTION( glXBindSwapBarrierSGIX ),
+ GLX_FUNCTION( glXQueryMaxSwapBarriersSGIX ),
+
+ /*** GLX_SUN_get_transparent_index ***/
+ GLX_FUNCTION( glXGetTransparentIndexSUN ),
+
+ /*** GLX_MESA_allocate_memory ***/
+ GLX_FUNCTION( glXAllocateMemoryMESA ),
+ GLX_FUNCTION( glXFreeMemoryMESA ),
+ GLX_FUNCTION( glXGetMemoryOffsetMESA ),
+
+ /*** GLX_MESA_copy_sub_buffer ***/
+ GLX_FUNCTION( glXCopySubBufferMESA ),
+
+ /*** GLX_MESA_pixmap_colormap ***/
+ GLX_FUNCTION( glXCreateGLXPixmapMESA ),
+
+ /*** GLX_MESA_release_buffers ***/
+ GLX_FUNCTION( glXReleaseBuffersMESA ),
+
+ /*** GLX_MESA_set_3dfx_mode ***/
+ GLX_FUNCTION( glXSet3DfxModeMESA ),
+
+ /*** GLX_MESA_swap_control ***/
+ GLX_FUNCTION( glXSwapIntervalMESA ),
+ GLX_FUNCTION( glXGetSwapIntervalMESA ),
+
+ /*** GLX_MESA_swap_frame_usage ***/
+ GLX_FUNCTION( glXBeginFrameTrackingMESA ),
+ GLX_FUNCTION( glXEndFrameTrackingMESA ),
+ GLX_FUNCTION( glXGetFrameUsageMESA ),
+ GLX_FUNCTION( glXQueryFrameTrackingMESA ),
+
+ /*** GLX_ARB_get_proc_address ***/
+ GLX_FUNCTION( glXGetProcAddressARB ),
+
+ /*** GLX 1.4 ***/
+ GLX_FUNCTION2( glXGetProcAddress, glXGetProcAddressARB ),
+
+ /*** GLX_OML_sync_control ***/
+ GLX_FUNCTION( glXWaitForSbcOML ),
+ GLX_FUNCTION( glXWaitForMscOML ),
+ GLX_FUNCTION( glXSwapBuffersMscOML ),
+ GLX_FUNCTION( glXGetMscRateOML ),
+ GLX_FUNCTION( glXGetSyncValuesOML ),
+
+#ifdef GLX_DIRECT_RENDERING
+ /*** DRI configuration ***/
+ GLX_FUNCTION( glXGetScreenDriver ),
+ GLX_FUNCTION( glXGetDriverConfig ),
+#endif
+
+ { NULL, NULL } /* end of list */
+};
+
+
+static const GLvoid *
+get_glx_proc_address(const char *funcName)
+{
+ GLuint i;
+
+ /* try static functions */
+ for (i = 0; GLX_functions[i].Name; i++) {
+ if (strcmp(GLX_functions[i].Name, funcName) == 0)
+ return GLX_functions[i].Address;
+ }
+
+ return NULL;
+}
+
+
+/**
+ * Get the address of a named GL function. This is the pre-GLX 1.4 name for
+ * \c glXGetProcAddress.
+ *
+ * \param procName Name of a GL or GLX function.
+ * \returns A pointer to the named function
+ *
+ * \sa glXGetProcAddress
+ */
+PUBLIC void (*glXGetProcAddressARB(const GLubyte *procName))( void )
+{
+ typedef void (*gl_function)( void );
+ gl_function f;
+
+
+ /* Search the table of GLX and internal functions first. If that
+ * fails and the supplied name could be a valid core GL name, try
+ * searching the core GL function table. This check is done to prevent
+ * DRI based drivers from searching the core GL function table for
+ * internal API functions.
+ */
+
+ f = (gl_function) get_glx_proc_address((const char *) procName);
+ if ( (f == NULL) && (procName[0] == 'g') && (procName[1] == 'l')
+ && (procName[2] != 'X') ) {
+ f = (gl_function) _glapi_get_proc_address((const char *) procName);
+ }
+
+ return f;
+}
+
+/**
+ * Get the address of a named GL function. This is the GLX 1.4 name for
+ * \c glXGetProcAddressARB.
+ *
+ * \param procName Name of a GL or GLX function.
+ * \returns A pointer to the named function
+ *
+ * \sa glXGetProcAddressARB
+ */
+PUBLIC void (*glXGetProcAddress(const GLubyte *procName))( void )
+#if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED)
+ __attribute__ ((alias ("glXGetProcAddressARB")));
+#else
+{
+ return glXGetProcAddressARB(procName);
+}
+#endif /* __GNUC__ */
+
+
+#ifdef GLX_DIRECT_RENDERING
+/**
+ * Retrieves the verion of the internal libGL API in YYYYMMDD format. This
+ * might be used by the DRI drivers to determine how new libGL is at runtime.
+ * Drivers should not call this function directly. They should instead use
+ * \c glXGetProcAddress to obtain a pointer to the function.
+ *
+ * \returns An 8-digit decimal number representing the internal libGL API in
+ * YYYYMMDD format.
+ *
+ * \sa glXGetProcAddress, PFNGLXGETINTERNALVERSIONPROC
+ *
+ * \since Internal API version 20021121.
+ */
+int __glXGetInternalVersion(void)
+{
+ /* History:
+ * 20021121 - Initial version
+ * 20021128 - Added __glXWindowExists() function
+ * 20021207 - Added support for dynamic GLX extensions,
+ * GLX_SGI_swap_control, GLX_SGI_video_sync,
+ * GLX_OML_sync_control, and GLX_MESA_swap_control.
+ * Never officially released. Do NOT test against
+ * this version. Use 20030317 instead.
+ * 20030317 - Added support GLX_SGIX_fbconfig,
+ * GLX_MESA_swap_frame_usage, GLX_OML_swap_method,
+ * GLX_{ARB,SGIS}_multisample, and
+ * GLX_SGIX_visual_select_group.
+ * 20030606 - Added support for GLX_SGI_make_current_read.
+ * 20030813 - Made support for dynamic extensions multi-head aware.
+ * 20030818 - Added support for GLX_MESA_allocate_memory in place of the
+ * deprecated GLX_NV_vertex_array_range & GLX_MESA_agp_offset
+ * interfaces.
+ * 20031201 - Added support for the first round of DRI interface changes.
+ * Do NOT test against this version! It has binary
+ * compatibility bugs, use 20040317 instead.
+ * 20040317 - Added the 'mode' field to __DRIcontextRec.
+ * 20040415 - Added support for bindContext3 and unbindContext3.
+ * 20040602 - Add __glXGetDrawableInfo. I though that was there
+ * months ago. :(
+ * 20050727 - Gut all the old interfaces. This breaks compatability with
+ * any DRI driver built to any previous version.
+ */
+ return 20050727;
+}
+
+
+
+static Bool windowExistsFlag;
+
+static int windowExistsErrorHandler(Display *dpy, XErrorEvent *xerr)
+{
+ if (xerr->error_code == BadWindow) {
+ windowExistsFlag = GL_FALSE;
+ }
+ return 0;
+}
+
+/**
+ * Determine if a window associated with a \c GLXDrawable exists on the
+ * X-server. This function is not used internally by libGL. It is provided
+ * as a utility function for DRI drivers.
+ * Drivers should not call this function directly. They should instead use
+ * \c glXGetProcAddress to obtain a pointer to the function.
+ *
+ * \param dpy Display associated with the drawable to be queried.
+ * \param draw \c GLXDrawable to test.
+ *
+ * \returns \c GL_TRUE if a window exists that is associated with \c draw,
+ * otherwise \c GL_FALSE is returned.
+ *
+ * \warning This function is not currently thread-safe.
+ *
+ * \sa glXGetProcAddress
+ *
+ * \since Internal API version 20021128.
+ */
+Bool __glXWindowExists(Display *dpy, GLXDrawable draw)
+{
+ XWindowAttributes xwa;
+ int (*oldXErrorHandler)(Display *, XErrorEvent *);
+
+ XSync(dpy, GL_FALSE);
+ windowExistsFlag = GL_TRUE;
+ oldXErrorHandler = XSetErrorHandler(windowExistsErrorHandler);
+ XGetWindowAttributes(dpy, draw, &xwa); /* dummy request */
+ XSetErrorHandler(oldXErrorHandler);
+ return windowExistsFlag;
+}
+
+
+/**
+ * Get the unadjusted system time (UST). Currently, the UST is measured in
+ * microseconds since Epoc. The actual resolution of the UST may vary from
+ * system to system, and the units may vary from release to release.
+ * Drivers should not call this function directly. They should instead use
+ * \c glXGetProcAddress to obtain a pointer to the function.
+ *
+ * \param ust Location to store the 64-bit UST
+ * \returns Zero on success or a negative errno value on failure.
+ *
+ * \sa glXGetProcAddress, PFNGLXGETUSTPROC
+ *
+ * \since Internal API version 20030317.
+ */
+int __glXGetUST( int64_t * ust )
+{
+ struct timeval tv;
+
+ if ( ust == NULL ) {
+ return -EFAULT;
+ }
+
+ if ( gettimeofday( & tv, NULL ) == 0 ) {
+ ust[0] = (tv.tv_sec * 1000000) + tv.tv_usec;
+ return 0;
+ } else {
+ return -errno;
+ }
+}
+#endif /* GLX_DIRECT_RENDERING */
diff --git a/nx-X11/extras/Mesa/src/glx/x11/glxext.c b/nx-X11/extras/Mesa/src/glx/x11/glxext.c
new file mode 100644
index 000000000..eb6e870e9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/glxext.c
@@ -0,0 +1,1864 @@
+/* $XFree86: xc/lib/GL/glx/glxext.c,v 1.22 2003/12/08 17:35:28 dawes Exp $ */
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+/**
+ * \file glxext.c
+ * GLX protocol interface boot-strap code.
+ *
+ * Direct rendering support added by Precision Insight, Inc.
+ *
+ * \author Kevin E. Martin <kevin@precisioninsight.com>
+ */
+
+#include "glxclient.h"
+#include <stdio.h>
+#include <X11/extensions/Xext.h>
+#include <X11/extensions/extutil.h>
+#include <assert.h>
+#include "indirect_init.h"
+#include "glapi.h"
+#include "glxextensions.h"
+#include "glcontextmodes.h"
+#include "glheader.h"
+
+#ifdef GLX_DIRECT_RENDERING
+#include <inttypes.h>
+#include <sys/mman.h>
+#include "xf86dri.h"
+#include "sarea.h"
+#include "dri_glx.h"
+#endif
+
+#ifdef USE_XCB
+#include <X11/xcl.h>
+#include <X11/XCB/xcb.h>
+#include <X11/XCB/glx.h>
+#endif
+
+#include <assert.h>
+
+#ifdef DEBUG
+void __glXDumpDrawBuffer(__GLXcontext *ctx);
+#endif
+
+#ifdef USE_SPARC_ASM
+/*
+ * This is where our dispatch table's bounds are.
+ * And the static mesa_init is taken directly from
+ * Mesa's 'sparc.c' initializer.
+ *
+ * We need something like this here, because this version
+ * of openGL/glx never initializes a Mesa context, and so
+ * the address of the dispatch table pointer never gets stuffed
+ * into the dispatch jump table otherwise.
+ *
+ * It matters only on SPARC, and only if you are using assembler
+ * code instead of C-code indirect dispatch.
+ *
+ * -- FEM, 04.xii.03
+ */
+extern unsigned int _mesa_sparc_glapi_begin;
+extern unsigned int _mesa_sparc_glapi_end;
+extern void __glapi_sparc_icache_flush(unsigned int *);
+static void _glx_mesa_init_sparc_glapi_relocs(void);
+static int _mesa_sparc_needs_init = 1;
+#define INIT_MESA_SPARC { \
+ if(_mesa_sparc_needs_init) { \
+ _glx_mesa_init_sparc_glapi_relocs(); \
+ _mesa_sparc_needs_init = 0; \
+ } \
+}
+#else
+#define INIT_MESA_SPARC
+#endif
+
+#ifdef GLX_DIRECT_RENDERING
+static __DRIscreen *__glXFindDRIScreen(__DRInativeDisplay *dpy, int scrn);
+#endif /* GLX_DIRECT_RENDERING */
+
+static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
+ GLXDrawable read, GLXContext gc);
+
+/*
+** We setup some dummy structures here so that the API can be used
+** even if no context is current.
+*/
+
+static GLubyte dummyBuffer[__GLX_BUFFER_LIMIT_SIZE];
+
+/*
+** Dummy context used by small commands when there is no current context.
+** All the
+** gl and glx entry points are designed to operate as nop's when using
+** the dummy context structure.
+*/
+static __GLXcontext dummyContext = {
+ &dummyBuffer[0],
+ &dummyBuffer[0],
+ &dummyBuffer[0],
+ &dummyBuffer[__GLX_BUFFER_LIMIT_SIZE],
+ sizeof(dummyBuffer),
+};
+
+
+/*
+** All indirect rendering contexts will share the same indirect dispatch table.
+*/
+static __GLapi *IndirectAPI = NULL;
+
+
+/*
+ * Current context management and locking
+ */
+
+#if defined( USE_XTHREADS )
+
+/* thread safe */
+static GLboolean TSDinitialized = GL_FALSE;
+static xthread_key_t ContextTSD;
+
+__GLXcontext *__glXGetCurrentContext(void)
+{
+ if (!TSDinitialized) {
+ xthread_key_create(&ContextTSD, NULL);
+ TSDinitialized = GL_TRUE;
+ return &dummyContext;
+ }
+ else {
+ void *p;
+ xthread_get_specific(ContextTSD, &p);
+ if (!p)
+ return &dummyContext;
+ else
+ return (__GLXcontext *) p;
+ }
+}
+
+void __glXSetCurrentContext(__GLXcontext *c)
+{
+ if (!TSDinitialized) {
+ xthread_key_create(&ContextTSD, NULL);
+ TSDinitialized = GL_TRUE;
+ }
+ xthread_set_specific(ContextTSD, c);
+}
+
+
+/* Used by the __glXLock() and __glXUnlock() macros */
+xmutex_rec __glXmutex;
+
+#elif defined( PTHREADS )
+
+pthread_mutex_t __glXmutex = PTHREAD_MUTEX_INITIALIZER;
+
+# if defined( GLX_USE_TLS )
+
+/**
+ * Per-thread GLX context pointer.
+ *
+ * \c __glXSetCurrentContext is written is such a way that this pointer can
+ * \b never be \c NULL. This is important! Because of this
+ * \c __glXGetCurrentContext can be implemented as trivial macro.
+ */
+__thread void * __glX_tls_Context __attribute__((tls_model("initial-exec")))
+ = &dummyContext;
+
+void __glXSetCurrentContext( __GLXcontext * c )
+{
+ __glX_tls_Context = (c != NULL) ? c : &dummyContext;
+}
+
+# else
+
+static pthread_once_t once_control = PTHREAD_ONCE_INIT;
+
+/**
+ * Per-thread data key.
+ *
+ * Once \c init_thread_data has been called, the per-thread data key will
+ * take a value of \c NULL. As each new thread is created the default
+ * value, in that thread, will be \c NULL.
+ */
+static pthread_key_t ContextTSD;
+
+/**
+ * Initialize the per-thread data key.
+ *
+ * This function is called \b exactly once per-process (not per-thread!) to
+ * initialize the per-thread data key. This is ideally done using the
+ * \c pthread_once mechanism.
+ */
+static void init_thread_data( void )
+{
+ if ( pthread_key_create( & ContextTSD, NULL ) != 0 ) {
+ perror( "pthread_key_create" );
+ exit( -1 );
+ }
+}
+
+void __glXSetCurrentContext( __GLXcontext * c )
+{
+ pthread_once( & once_control, init_thread_data );
+ pthread_setspecific( ContextTSD, c );
+}
+
+__GLXcontext * __glXGetCurrentContext( void )
+{
+ void * v;
+
+ pthread_once( & once_control, init_thread_data );
+
+ v = pthread_getspecific( ContextTSD );
+ return (v == NULL) ? & dummyContext : (__GLXcontext *) v;
+}
+
+# endif /* defined( GLX_USE_TLS ) */
+
+#elif defined( THREADS )
+
+#error Unknown threading method specified.
+
+#else
+
+/* not thread safe */
+__GLXcontext *__glXcurrentContext = &dummyContext;
+
+#endif
+
+
+/*
+** You can set this cell to 1 to force the gl drawing stuff to be
+** one command per packet
+*/
+int __glXDebug = 0;
+
+/*
+** forward prototype declarations
+*/
+int __glXCloseDisplay(Display *dpy, XExtCodes *codes);
+
+
+/************************************************************************/
+
+/* Extension required boiler plate */
+
+static char *__glXExtensionName = GLX_EXTENSION_NAME;
+XExtensionInfo *__glXExtensionInfo = NULL;
+
+static /* const */ char *error_list[] = {
+ "GLXBadContext",
+ "GLXBadContextState",
+ "GLXBadDrawable",
+ "GLXBadPixmap",
+ "GLXBadContextTag",
+ "GLXBadCurrentWindow",
+ "GLXBadRenderRequest",
+ "GLXBadLargeRequest",
+ "GLXUnsupportedPrivateRequest",
+};
+
+int __glXCloseDisplay(Display *dpy, XExtCodes *codes)
+{
+ GLXContext gc;
+
+ gc = __glXGetCurrentContext();
+ if (dpy == gc->currentDpy) {
+ __glXSetCurrentContext(&dummyContext);
+#ifdef GLX_DIRECT_RENDERING
+ _glapi_set_dispatch(NULL); /* no-op functions */
+#endif
+ __glXFreeContext(gc);
+ }
+
+ return XextRemoveDisplay(__glXExtensionInfo, dpy);
+}
+
+
+static XEXT_GENERATE_ERROR_STRING(__glXErrorString, __glXExtensionName,
+ __GLX_NUMBER_ERRORS, error_list)
+
+static /* const */ XExtensionHooks __glXExtensionHooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ __glXCloseDisplay, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ __glXErrorString, /* error_string */
+};
+
+static
+XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo,
+ __glXExtensionName, &__glXExtensionHooks,
+ __GLX_NUMBER_EVENTS, NULL)
+
+/************************************************************************/
+
+/*
+** Free the per screen configs data as well as the array of
+** __glXScreenConfigs.
+*/
+static void FreeScreenConfigs(__GLXdisplayPrivate *priv)
+{
+ __GLXscreenConfigs *psc;
+ GLint i, screens;
+
+ /* Free screen configuration information */
+ psc = priv->screenConfigs;
+ screens = ScreenCount(priv->dpy);
+ for (i = 0; i < screens; i++, psc++) {
+ if (psc->configs) {
+ _gl_context_modes_destroy( psc->configs );
+ if(psc->effectiveGLXexts)
+ Xfree(psc->effectiveGLXexts);
+
+ psc->configs = NULL; /* NOTE: just for paranoia */
+ }
+
+#ifdef GLX_DIRECT_RENDERING
+ /* Free the direct rendering per screen data */
+ if (psc->driScreen.private)
+ (*psc->driScreen.destroyScreen)(priv->dpy, i,
+ psc->driScreen.private);
+ psc->driScreen.private = NULL;
+#endif
+ }
+ XFree((char*) priv->screenConfigs);
+}
+
+/*
+** Release the private memory referred to in a display private
+** structure. The caller will free the extension structure.
+*/
+static int __glXFreeDisplayPrivate(XExtData *extension)
+{
+ __GLXdisplayPrivate *priv;
+
+ priv = (__GLXdisplayPrivate*) extension->private_data;
+ FreeScreenConfigs(priv);
+ if(priv->serverGLXvendor) {
+ Xfree((char*)priv->serverGLXvendor);
+ priv->serverGLXvendor = 0x0; /* to protect against double free's */
+ }
+ if(priv->serverGLXversion) {
+ Xfree((char*)priv->serverGLXversion);
+ priv->serverGLXversion = 0x0; /* to protect against double free's */
+ }
+
+#if 0 /* GLX_DIRECT_RENDERING */
+ /* Free the direct rendering per display data */
+ if (priv->driDisplay.private)
+ (*priv->driDisplay.destroyDisplay)(priv->dpy,
+ priv->driDisplay.private);
+ priv->driDisplay.private = NULL;
+#endif
+
+ Xfree((char*) priv);
+ return 0;
+}
+
+/************************************************************************/
+
+/*
+** Query the version of the GLX extension. This procedure works even if
+** the client extension is not completely set up.
+*/
+static Bool QueryVersion(Display *dpy, int opcode, int *major, int *minor)
+{
+ xGLXQueryVersionReq *req;
+ xGLXQueryVersionReply reply;
+
+ /* Send the glXQueryVersion request */
+ LockDisplay(dpy);
+ GetReq(GLXQueryVersion,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXQueryVersion;
+ req->majorVersion = GLX_MAJOR_VERSION;
+ req->minorVersion = GLX_MINOR_VERSION;
+ _XReply(dpy, (xReply*) &reply, 0, False);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ if (reply.majorVersion != GLX_MAJOR_VERSION) {
+ /*
+ ** The server does not support the same major release as this
+ ** client.
+ */
+ return GL_FALSE;
+ }
+ *major = reply.majorVersion;
+ *minor = min(reply.minorVersion, GLX_MINOR_VERSION);
+ return GL_TRUE;
+}
+
+
+void
+__glXInitializeVisualConfigFromTags( __GLcontextModes *config, int count,
+ const INT32 *bp, Bool tagged_only,
+ Bool fbconfig_style_tags )
+{
+ int i;
+
+ if (!tagged_only) {
+ /* Copy in the first set of properties */
+ config->visualID = *bp++;
+
+ config->visualType = _gl_convert_from_x_visual_type( *bp++ );
+
+ config->rgbMode = *bp++;
+
+ config->redBits = *bp++;
+ config->greenBits = *bp++;
+ config->blueBits = *bp++;
+ config->alphaBits = *bp++;
+ config->accumRedBits = *bp++;
+ config->accumGreenBits = *bp++;
+ config->accumBlueBits = *bp++;
+ config->accumAlphaBits = *bp++;
+
+ config->doubleBufferMode = *bp++;
+ config->stereoMode = *bp++;
+
+ config->rgbBits = *bp++;
+ config->depthBits = *bp++;
+ config->stencilBits = *bp++;
+ config->numAuxBuffers = *bp++;
+ config->level = *bp++;
+
+ count -= __GLX_MIN_CONFIG_PROPS;
+ }
+
+ /*
+ ** Additional properties may be in a list at the end
+ ** of the reply. They are in pairs of property type
+ ** and property value.
+ */
+
+#define FETCH_OR_SET(tag) \
+ config-> tag = ( fbconfig_style_tags ) ? *bp++ : 1
+
+ for (i = 0; i < count; i += 2 ) {
+ switch(*bp++) {
+ case GLX_RGBA:
+ FETCH_OR_SET( rgbMode );
+ break;
+ case GLX_BUFFER_SIZE:
+ config->rgbBits = *bp++;
+ break;
+ case GLX_LEVEL:
+ config->level = *bp++;
+ break;
+ case GLX_DOUBLEBUFFER:
+ FETCH_OR_SET( doubleBufferMode );
+ break;
+ case GLX_STEREO:
+ FETCH_OR_SET( stereoMode );
+ break;
+ case GLX_AUX_BUFFERS:
+ config->numAuxBuffers = *bp++;
+ break;
+ case GLX_RED_SIZE:
+ config->redBits = *bp++;
+ break;
+ case GLX_GREEN_SIZE:
+ config->greenBits = *bp++;
+ break;
+ case GLX_BLUE_SIZE:
+ config->blueBits = *bp++;
+ break;
+ case GLX_ALPHA_SIZE:
+ config->alphaBits = *bp++;
+ break;
+ case GLX_DEPTH_SIZE:
+ config->depthBits = *bp++;
+ break;
+ case GLX_STENCIL_SIZE:
+ config->stencilBits = *bp++;
+ break;
+ case GLX_ACCUM_RED_SIZE:
+ config->accumRedBits = *bp++;
+ break;
+ case GLX_ACCUM_GREEN_SIZE:
+ config->accumGreenBits = *bp++;
+ break;
+ case GLX_ACCUM_BLUE_SIZE:
+ config->accumBlueBits = *bp++;
+ break;
+ case GLX_ACCUM_ALPHA_SIZE:
+ config->accumAlphaBits = *bp++;
+ break;
+ case GLX_VISUAL_CAVEAT_EXT:
+ config->visualRating = *bp++;
+ break;
+ case GLX_X_VISUAL_TYPE:
+ config->visualType = *bp++;
+ break;
+ case GLX_TRANSPARENT_TYPE:
+ config->transparentPixel = *bp++;
+ break;
+ case GLX_TRANSPARENT_INDEX_VALUE:
+ config->transparentIndex = *bp++;
+ break;
+ case GLX_TRANSPARENT_RED_VALUE:
+ config->transparentRed = *bp++;
+ break;
+ case GLX_TRANSPARENT_GREEN_VALUE:
+ config->transparentGreen = *bp++;
+ break;
+ case GLX_TRANSPARENT_BLUE_VALUE:
+ config->transparentBlue = *bp++;
+ break;
+ case GLX_TRANSPARENT_ALPHA_VALUE:
+ config->transparentAlpha = *bp++;
+ break;
+ case GLX_VISUAL_ID:
+ config->visualID = *bp++;
+ break;
+ case GLX_DRAWABLE_TYPE:
+ config->drawableType = *bp++;
+ break;
+ case GLX_RENDER_TYPE:
+ config->renderType = *bp++;
+ break;
+ case GLX_X_RENDERABLE:
+ config->xRenderable = *bp++;
+ break;
+ case GLX_FBCONFIG_ID:
+ config->fbconfigID = *bp++;
+ break;
+ case GLX_MAX_PBUFFER_WIDTH:
+ config->maxPbufferWidth = *bp++;
+ break;
+ case GLX_MAX_PBUFFER_HEIGHT:
+ config->maxPbufferHeight = *bp++;
+ break;
+ case GLX_MAX_PBUFFER_PIXELS:
+ config->maxPbufferPixels = *bp++;
+ break;
+ case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
+ config->optimalPbufferWidth = *bp++;
+ break;
+ case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX:
+ config->optimalPbufferHeight = *bp++;
+ break;
+ case GLX_VISUAL_SELECT_GROUP_SGIX:
+ config->visualSelectGroup = *bp++;
+ break;
+ case GLX_SWAP_METHOD_OML:
+ config->swapMethod = *bp++;
+ break;
+ case GLX_SAMPLE_BUFFERS_SGIS:
+ config->sampleBuffers = *bp++;
+ break;
+ case GLX_SAMPLES_SGIS:
+ config->samples = *bp++;
+ break;
+ case None:
+ i = count;
+ break;
+ default:
+ break;
+ }
+ }
+
+ config->renderType = (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
+
+ config->haveAccumBuffer = ((config->accumRedBits +
+ config->accumGreenBits +
+ config->accumBlueBits +
+ config->accumAlphaBits) > 0);
+ config->haveDepthBuffer = (config->depthBits > 0);
+ config->haveStencilBuffer = (config->stencilBits > 0);
+}
+
+
+#ifdef GLX_DIRECT_RENDERING
+static unsigned
+filter_modes( __GLcontextModes ** server_modes,
+ const __GLcontextModes * driver_modes )
+{
+ __GLcontextModes * m;
+ __GLcontextModes ** prev_next;
+ const __GLcontextModes * check;
+ unsigned modes_count = 0;
+
+ if ( driver_modes == NULL ) {
+ fprintf(stderr, "libGL warning: 3D driver returned no fbconfigs.\n");
+ return 0;
+ }
+
+ /* For each mode in server_modes, check to see if a matching mode exists
+ * in driver_modes. If not, then the mode is not available.
+ */
+
+ prev_next = server_modes;
+ for ( m = *prev_next ; m != NULL ; m = *prev_next ) {
+ GLboolean do_delete = GL_TRUE;
+
+ for ( check = driver_modes ; check != NULL ; check = check->next ) {
+ if ( _gl_context_modes_are_same( m, check ) ) {
+ do_delete = GL_FALSE;
+ break;
+ }
+ }
+
+ /* The 3D has to support all the modes that match the GLX visuals
+ * sent from the X server.
+ */
+ if ( do_delete && (m->visualID != 0) ) {
+ do_delete = GL_FALSE;
+
+ fprintf(stderr, "libGL warning: 3D driver claims to not support "
+ "visual 0x%02x\n", m->visualID);
+ }
+
+ if ( do_delete ) {
+ *prev_next = m->next;
+
+ m->next = NULL;
+ _gl_context_modes_destroy( m );
+ }
+ else {
+ modes_count++;
+ prev_next = & m->next;
+ }
+ }
+
+ return modes_count;
+}
+
+
+/**
+ * Implement \c __DRIinterfaceMethods::getProcAddress.
+ */
+static __DRIfuncPtr get_proc_address( const char * proc_name )
+{
+ if (strcmp( proc_name, "glxEnableExtension" ) == 0) {
+ return (__DRIfuncPtr) __glXScrEnableExtension;
+ }
+
+ return NULL;
+}
+
+
+/**
+ * Table of functions exported by the loader to the driver.
+ */
+static const __DRIinterfaceMethods interface_methods = {
+ get_proc_address,
+
+ _gl_context_modes_create,
+ _gl_context_modes_destroy,
+
+ __glXFindDRIScreen,
+ __glXWindowExists,
+
+ XF86DRICreateContextWithConfig,
+ XF86DRIDestroyContext,
+
+ XF86DRICreateDrawable,
+ XF86DRIDestroyDrawable,
+ XF86DRIGetDrawableInfo,
+
+ __glXGetUST,
+ glXGetMscRateOML,
+};
+
+
+/**
+ * Perform the required libGL-side initialization and call the client-side
+ * driver's \c __driCreateNewScreen function.
+ *
+ * \param dpy Display pointer.
+ * \param scrn Screen number on the display.
+ * \param psc DRI screen information.
+ * \param driDpy DRI display information.
+ * \param createNewScreen Pointer to the client-side driver's
+ * \c __driCreateNewScreen function.
+ * \returns A pointer to the \c __DRIscreenPrivate structure returned by
+ * the client-side driver on success, or \c NULL on failure.
+ *
+ * \todo This function needs to be modified to remove context-modes from the
+ * list stored in the \c __GLXscreenConfigsRec to match the list
+ * returned by the client-side driver.
+ */
+static void *
+CallCreateNewScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ __DRIdisplay * driDpy,
+ PFNCREATENEWSCREENFUNC createNewScreen)
+{
+ __DRIscreenPrivate *psp = NULL;
+#ifndef GLX_USE_APPLEGL
+ drm_handle_t hSAREA;
+ drmAddress pSAREA = MAP_FAILED;
+ char *BusID;
+ __DRIversion ddx_version;
+ __DRIversion dri_version;
+ __DRIversion drm_version;
+ __DRIframebuffer framebuffer;
+ int fd = -1;
+ int status;
+ const char * err_msg;
+ const char * err_extra;
+ int api_ver = __glXGetInternalVersion();
+
+
+ dri_version.major = driDpy->private->driMajor;
+ dri_version.minor = driDpy->private->driMinor;
+ dri_version.patch = driDpy->private->driPatch;
+
+
+ err_msg = "XF86DRIOpenConnection";
+ err_extra = NULL;
+
+ framebuffer.base = MAP_FAILED;
+ framebuffer.dev_priv = NULL;
+
+ if (XF86DRIOpenConnection(dpy, scrn, &hSAREA, &BusID)) {
+ fd = drmOpen(NULL,BusID);
+ Xfree(BusID); /* No longer needed */
+
+ err_msg = "open DRM";
+ err_extra = strerror( -fd );
+
+ if (fd >= 0) {
+ drm_magic_t magic;
+
+ err_msg = "drmGetMagic";
+ err_extra = NULL;
+
+ if (!drmGetMagic(fd, &magic)) {
+ drmVersionPtr version = drmGetVersion(fd);
+ if (version) {
+ drm_version.major = version->version_major;
+ drm_version.minor = version->version_minor;
+ drm_version.patch = version->version_patchlevel;
+ drmFreeVersion(version);
+ }
+ else {
+ drm_version.major = -1;
+ drm_version.minor = -1;
+ drm_version.patch = -1;
+ }
+
+ err_msg = "XF86DRIAuthConnection";
+ if (XF86DRIAuthConnection(dpy, scrn, magic)) {
+ char *driverName;
+
+ /*
+ * Get device name (like "tdfx") and the ddx version
+ * numbers. We'll check the version in each DRI driver's
+ * "createNewScreen" function.
+ */
+ err_msg = "XF86DRIGetClientDriverName";
+ if (XF86DRIGetClientDriverName(dpy, scrn,
+ &ddx_version.major,
+ &ddx_version.minor,
+ &ddx_version.patch,
+ &driverName)) {
+ drm_handle_t hFB;
+ int junk;
+
+ /* No longer needed. */
+ Xfree( driverName );
+
+
+ /*
+ * Get device-specific info. pDevPriv will point to a struct
+ * (such as DRIRADEONRec in xfree86/driver/ati/radeon_dri.h)
+ * that has information about the screen size, depth, pitch,
+ * ancilliary buffers, DRM mmap handles, etc.
+ */
+ err_msg = "XF86DRIGetDeviceInfo";
+ if (XF86DRIGetDeviceInfo(dpy, scrn,
+ &hFB,
+ &junk,
+ &framebuffer.size,
+ &framebuffer.stride,
+ &framebuffer.dev_priv_size,
+ &framebuffer.dev_priv)) {
+ framebuffer.width = DisplayWidth(dpy, scrn);
+ framebuffer.height = DisplayHeight(dpy, scrn);
+
+ /*
+ * Map the framebuffer region.
+ */
+ status = drmMap(fd, hFB, framebuffer.size,
+ (drmAddressPtr)&framebuffer.base);
+
+ err_msg = "drmMap of framebuffer";
+ err_extra = strerror( -status );
+
+ if ( status == 0 ) {
+ /*
+ * Map the SAREA region. Further mmap regions
+ * may be setup in each DRI driver's
+ * "createNewScreen" function.
+ */
+ status = drmMap(fd, hSAREA, SAREA_MAX,
+ &pSAREA);
+
+ err_msg = "drmMap of sarea";
+ err_extra = strerror( -status );
+
+ if ( status == 0 ) {
+ __GLcontextModes * driver_modes = NULL;
+ __GLXscreenConfigs *configs = psc->screenConfigs;
+
+ err_msg = "InitDriver";
+ err_extra = NULL;
+ psp = (*createNewScreen)(dpy, scrn,
+ psc,
+ configs->configs,
+ & ddx_version,
+ & dri_version,
+ & drm_version,
+ & framebuffer,
+ pSAREA,
+ fd,
+ api_ver,
+ & interface_methods,
+ & driver_modes );
+
+ filter_modes( & configs->configs,
+ driver_modes );
+ _gl_context_modes_destroy( driver_modes );
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if ( psp == NULL ) {
+ if ( pSAREA != MAP_FAILED ) {
+ (void)drmUnmap(pSAREA, SAREA_MAX);
+ }
+
+ if ( framebuffer.base != MAP_FAILED ) {
+ (void)drmUnmap((drmAddress)framebuffer.base, framebuffer.size);
+ }
+
+ if ( framebuffer.dev_priv != NULL ) {
+ Xfree(framebuffer.dev_priv);
+ }
+
+ if ( fd >= 0 ) {
+ (void)drmClose(fd);
+ }
+
+ (void)XF86DRICloseConnection(dpy, scrn);
+
+ if ( err_extra != NULL ) {
+ fprintf(stderr, "libGL error: %s failed (%s)\n", err_msg,
+ err_extra);
+ }
+ else {
+ fprintf(stderr, "libGL error: %s failed\n", err_msg );
+ }
+
+ fprintf(stderr, "libGL error: reverting to (slow) indirect rendering\n");
+ }
+#endif /* !GLX_USE_APPLEGL */
+
+ return psp;
+}
+#endif /* GLX_DIRECT_RENDERING */
+
+
+/*
+** Allocate the memory for the per screen configs for each screen.
+** If that works then fetch the per screen configs data.
+*/
+static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv)
+{
+ xGLXGetVisualConfigsReq *req;
+ xGLXGetFBConfigsReq *fb_req;
+ xGLXVendorPrivateWithReplyReq *vpreq;
+ xGLXGetFBConfigsSGIXReq *sgi_req;
+ xGLXGetVisualConfigsReply reply;
+ __GLXscreenConfigs *psc;
+ __GLcontextModes *config;
+ GLint i, j, nprops, screens;
+ INT32 buf[__GLX_TOTAL_CONFIG], *props;
+ unsigned supported_request = 0;
+ unsigned prop_size;
+
+ /*
+ ** First allocate memory for the array of per screen configs.
+ */
+ screens = ScreenCount(dpy);
+ psc = (__GLXscreenConfigs*) Xmalloc(screens * sizeof(__GLXscreenConfigs));
+ if (!psc) {
+ return GL_FALSE;
+ }
+ memset(psc, 0, screens * sizeof(__GLXscreenConfigs));
+ priv->screenConfigs = psc;
+
+ priv->serverGLXversion = __glXGetStringFromServer(dpy, priv->majorOpcode,
+ X_GLXQueryServerString,
+ 0, GLX_VERSION);
+ if ( priv->serverGLXversion == NULL ) {
+ FreeScreenConfigs(priv);
+ return GL_FALSE;
+ }
+
+ if ( atof( priv->serverGLXversion ) >= 1.3 ) {
+ supported_request = 1;
+ }
+
+ /*
+ ** Now fetch each screens configs structures. If a screen supports
+ ** GL (by returning a numVisuals > 0) then allocate memory for our
+ ** config structure and then fill it in.
+ */
+ for (i = 0; i < screens; i++, psc++) {
+ if ( supported_request != 1 ) {
+ psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
+ X_GLXQueryServerString,
+ i, GLX_EXTENSIONS);
+ if ( strstr( psc->serverGLXexts, "GLX_SGIX_fbconfig" ) != NULL ) {
+ supported_request = 2;
+ }
+ else {
+ supported_request = 3;
+ }
+ }
+
+
+ LockDisplay(dpy);
+ switch( supported_request ) {
+ case 1:
+ GetReq(GLXGetFBConfigs,fb_req);
+ fb_req->reqType = priv->majorOpcode;
+ fb_req->glxCode = X_GLXGetFBConfigs;
+ fb_req->screen = i;
+ break;
+
+ case 2:
+ GetReqExtra(GLXVendorPrivateWithReply,
+ sz_xGLXGetFBConfigsSGIXReq-sz_xGLXVendorPrivateWithReplyReq,vpreq);
+ sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq;
+ sgi_req->reqType = priv->majorOpcode;
+ sgi_req->glxCode = X_GLXVendorPrivateWithReply;
+ sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX;
+ sgi_req->screen = i;
+ break;
+
+ case 3:
+ GetReq(GLXGetVisualConfigs,req);
+ req->reqType = priv->majorOpcode;
+ req->glxCode = X_GLXGetVisualConfigs;
+ req->screen = i;
+ break;
+ }
+
+ if (!_XReply(dpy, (xReply*) &reply, 0, False)) {
+ /* Something is busted. Punt. */
+ UnlockDisplay(dpy);
+ FreeScreenConfigs(priv);
+ return GL_FALSE;
+ }
+
+ UnlockDisplay(dpy);
+ if (!reply.numVisuals) {
+ /* This screen does not support GL rendering */
+ UnlockDisplay(dpy);
+ continue;
+ }
+
+ /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for
+ * FIXME: FBconfigs?
+ */
+ /* Check number of properties */
+ nprops = reply.numProps;
+ if ((nprops < __GLX_MIN_CONFIG_PROPS) ||
+ (nprops > __GLX_MAX_CONFIG_PROPS)) {
+ /* Huh? Not in protocol defined limits. Punt */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ FreeScreenConfigs(priv);
+ return GL_FALSE;
+ }
+
+ /* Allocate memory for our config structure */
+ psc->configs = _gl_context_modes_create(reply.numVisuals,
+ sizeof(__GLcontextModes));
+ if (!psc->configs) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ FreeScreenConfigs(priv);
+ return GL_FALSE;
+ }
+
+ /* Allocate memory for the properties, if needed */
+ if ( supported_request != 3 ) {
+ nprops *= 2;
+ }
+
+ prop_size = nprops * __GLX_SIZE_INT32;
+
+ if (prop_size <= sizeof(buf)) {
+ props = buf;
+ } else {
+ props = (INT32 *) Xmalloc(prop_size);
+ }
+
+ /* Read each config structure and convert it into our format */
+ config = psc->configs;
+ for (j = 0; j < reply.numVisuals; j++) {
+ assert( config != NULL );
+ _XRead(dpy, (char *)props, prop_size);
+
+ if ( supported_request != 3 ) {
+ config->rgbMode = GL_TRUE;
+ config->drawableType = GLX_WINDOW_BIT;
+ }
+ else {
+ config->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
+ }
+
+ __glXInitializeVisualConfigFromTags( config, nprops, props,
+ (supported_request != 3),
+ GL_TRUE );
+ if ( config->fbconfigID == GLX_DONT_CARE ) {
+ config->fbconfigID = config->visualID;
+ }
+ config->screen = i;
+ config = config->next;
+ }
+ if (props != buf) {
+ Xfree((char *)props);
+ }
+ UnlockDisplay(dpy);
+
+#ifdef GLX_DIRECT_RENDERING
+ /* Initialize per screen dynamic client GLX extensions */
+ psc->ext_list_first_time = GL_TRUE;
+ /* Initialize the direct rendering per screen data and functions */
+ if (priv->driDisplay.private != NULL) {
+ /* FIXME: Should it be some sort of an error if createNewScreen[i]
+ * FIXME: is NULL?
+ */
+ if (priv->driDisplay.createNewScreen &&
+ priv->driDisplay.createNewScreen[i]) {
+
+ psc->driScreen.screenConfigs = (void *)psc;
+ psc->driScreen.private =
+ CallCreateNewScreen(dpy, i, & psc->driScreen,
+ & priv->driDisplay,
+ priv->driDisplay.createNewScreen[i] );
+ }
+ }
+#endif
+ }
+ SyncHandle();
+ return GL_TRUE;
+}
+
+/*
+** Initialize the client side extension code.
+*/
+__GLXdisplayPrivate *__glXInitialize(Display* dpy)
+{
+ XExtDisplayInfo *info = __glXFindDisplay(dpy);
+ XExtData **privList, *private, *found;
+ __GLXdisplayPrivate *dpyPriv;
+ XEDataObject dataObj;
+ int major, minor;
+
+#if defined(USE_XTHREADS)
+ {
+ static int firstCall = 1;
+ if (firstCall) {
+ /* initialize the GLX mutexes */
+ xmutex_init(&__glXmutex);
+ firstCall = 0;
+ }
+ }
+#endif
+
+ INIT_MESA_SPARC
+ /* The one and only long long lock */
+ __glXLock();
+
+ if (!XextHasExtension(info)) {
+ /* No GLX extension supported by this server. Oh well. */
+ __glXUnlock();
+ XMissingExtension(dpy, __glXExtensionName);
+ return 0;
+ }
+
+ /* See if a display private already exists. If so, return it */
+ dataObj.display = dpy;
+ privList = XEHeadOfExtensionList(dataObj);
+ found = XFindOnExtensionList(privList, info->codes->extension);
+ if (found) {
+ __glXUnlock();
+ return (__GLXdisplayPrivate *) found->private_data;
+ }
+
+ /* See if the versions are compatible */
+ if (!QueryVersion(dpy, info->codes->major_opcode, &major, &minor)) {
+ /* The client and server do not agree on versions. Punt. */
+ __glXUnlock();
+ return 0;
+ }
+
+ /*
+ ** Allocate memory for all the pieces needed for this buffer.
+ */
+ private = (XExtData *) Xmalloc(sizeof(XExtData));
+ if (!private) {
+ __glXUnlock();
+ return 0;
+ }
+ dpyPriv = (__GLXdisplayPrivate *) Xmalloc(sizeof(__GLXdisplayPrivate));
+ if (!dpyPriv) {
+ __glXUnlock();
+ Xfree((char*) private);
+ return 0;
+ }
+
+ /*
+ ** Init the display private and then read in the screen config
+ ** structures from the server.
+ */
+ dpyPriv->majorOpcode = info->codes->major_opcode;
+ dpyPriv->majorVersion = major;
+ dpyPriv->minorVersion = minor;
+ dpyPriv->dpy = dpy;
+
+ dpyPriv->serverGLXvendor = 0x0;
+ dpyPriv->serverGLXversion = 0x0;
+
+#ifdef GLX_DIRECT_RENDERING
+ /*
+ ** Initialize the direct rendering per display data and functions.
+ ** Note: This _must_ be done before calling any other DRI routines
+ ** (e.g., those called in AllocAndFetchScreenConfigs).
+ */
+ if (getenv("LIBGL_ALWAYS_INDIRECT")) {
+ /* Assinging zero here assures we'll never go direct */
+ dpyPriv->driDisplay.private = 0;
+ dpyPriv->driDisplay.destroyDisplay = 0;
+ }
+ else {
+ dpyPriv->driDisplay.private =
+ driCreateDisplay(dpy, &dpyPriv->driDisplay);
+ }
+#endif
+
+ if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) {
+ __glXUnlock();
+ Xfree((char*) dpyPriv);
+ Xfree((char*) private);
+ return 0;
+ }
+
+ /*
+ ** Fill in the private structure. This is the actual structure that
+ ** hangs off of the Display structure. Our private structure is
+ ** referred to by this structure. Got that?
+ */
+ private->number = info->codes->extension;
+ private->next = 0;
+ private->free_private = __glXFreeDisplayPrivate;
+ private->private_data = (char *) dpyPriv;
+ XAddToExtensionList(privList, private);
+
+ if (dpyPriv->majorVersion == 1 && dpyPriv->minorVersion >= 1) {
+ __glXClientInfo(dpy, dpyPriv->majorOpcode);
+ }
+ __glXUnlock();
+
+ return dpyPriv;
+}
+
+/*
+** Setup for sending a GLX command on dpy. Make sure the extension is
+** initialized. Try to avoid calling __glXInitialize as its kinda slow.
+*/
+CARD8 __glXSetupForCommand(Display *dpy)
+{
+ GLXContext gc;
+ __GLXdisplayPrivate *priv;
+
+ /* If this thread has a current context, flush its rendering commands */
+ gc = __glXGetCurrentContext();
+ if (gc->currentDpy) {
+ /* Flush rendering buffer of the current context, if any */
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+
+ if (gc->currentDpy == dpy) {
+ /* Use opcode from gc because its right */
+ INIT_MESA_SPARC
+ return gc->majorOpcode;
+ } else {
+ /*
+ ** Have to get info about argument dpy because it might be to
+ ** a different server
+ */
+ }
+ }
+
+ /* Forced to lookup extension via the slow initialize route */
+ priv = __glXInitialize(dpy);
+ if (!priv) {
+ return 0;
+ }
+ return priv->majorOpcode;
+}
+
+/**
+ * Flush the drawing command transport buffer.
+ *
+ * \param ctx Context whose transport buffer is to be flushed.
+ * \param pc Pointer to first unused buffer location.
+ *
+ * \todo
+ * Modify this function to use \c ctx->pc instead of the explicit
+ * \c pc parameter.
+ */
+GLubyte *__glXFlushRenderBuffer(__GLXcontext *ctx, GLubyte *pc)
+{
+ Display * const dpy = ctx->currentDpy;
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+#else
+ xGLXRenderReq *req;
+#endif /* USE_XCB */
+ const GLint size = pc - ctx->buf;
+
+ if ( (dpy != NULL) && (size > 0) ) {
+#ifdef USE_XCB
+ XCBGlxRender(c, ctx->currentContextTag, size, (char *)ctx->buf);
+#else
+ /* Send the entire buffer as an X request */
+ LockDisplay(dpy);
+ GetReq(GLXRender,req);
+ req->reqType = ctx->majorOpcode;
+ req->glxCode = X_GLXRender;
+ req->contextTag = ctx->currentContextTag;
+ req->length += (size + 3) >> 2;
+ _XSend(dpy, (char *)ctx->buf, size);
+ UnlockDisplay(dpy);
+ SyncHandle();
+#endif
+ }
+
+ /* Reset pointer and return it */
+ ctx->pc = ctx->buf;
+ return ctx->pc;
+}
+
+
+/**
+ * Send a portion of a GLXRenderLarge command to the server. The advantage of
+ * this function over \c __glXSendLargeCommand is that callers can use the
+ * data buffer in the GLX context and may be able to avoid allocating an
+ * extra buffer. The disadvantage is the clients will have to do more
+ * GLX protocol work (i.e., calculating \c totalRequests, etc.).
+ *
+ * \sa __glXSendLargeCommand
+ *
+ * \param gc GLX context
+ * \param requestNumber Which part of the whole command is this? The first
+ * request is 1.
+ * \param totalRequests How many requests will there be?
+ * \param data Command data.
+ * \param dataLen Size, in bytes, of the command data.
+ */
+void __glXSendLargeChunk(__GLXcontext *gc, GLint requestNumber,
+ GLint totalRequests,
+ const GLvoid * data, GLint dataLen)
+{
+ Display *dpy = gc->currentDpy;
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ XCBGlxRenderLarge(c, gc->currentContextTag, requestNumber, totalRequests, dataLen, data);
+#else
+ xGLXRenderLargeReq *req;
+
+ if ( requestNumber == 1 ) {
+ LockDisplay(dpy);
+ }
+
+ GetReq(GLXRenderLarge,req);
+ req->reqType = gc->majorOpcode;
+ req->glxCode = X_GLXRenderLarge;
+ req->contextTag = gc->currentContextTag;
+ req->length += (dataLen + 3) >> 2;
+ req->requestNumber = requestNumber;
+ req->requestTotal = totalRequests;
+ req->dataBytes = dataLen;
+ Data(dpy, data, dataLen);
+
+ if ( requestNumber == totalRequests ) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+#endif /* USE_XCB */
+}
+
+
+/**
+ * Send a command that is too large for the GLXRender protocol request.
+ *
+ * Send a large command, one that is too large for some reason to
+ * send using the GLXRender protocol request. One reason to send
+ * a large command is to avoid copying the data.
+ *
+ * \param ctx GLX context
+ * \param header Header data.
+ * \param headerLen Size, in bytes, of the header data. It is assumed that
+ * the header data will always be small enough to fit in
+ * a single X protocol packet.
+ * \param data Command data.
+ * \param dataLen Size, in bytes, of the command data.
+ */
+void __glXSendLargeCommand(__GLXcontext *ctx,
+ const GLvoid *header, GLint headerLen,
+ const GLvoid *data, GLint dataLen)
+{
+ GLint maxSize;
+ GLint totalRequests, requestNumber;
+
+ /*
+ ** Calculate the maximum amount of data can be stuffed into a single
+ ** packet. sz_xGLXRenderReq is added because bufSize is the maximum
+ ** packet size minus sz_xGLXRenderReq.
+ */
+ maxSize = (ctx->bufSize + sz_xGLXRenderReq) - sz_xGLXRenderLargeReq;
+ totalRequests = 1 + (dataLen / maxSize);
+ if (dataLen % maxSize) totalRequests++;
+
+ /*
+ ** Send all of the command, except the large array, as one request.
+ */
+ assert( headerLen <= maxSize );
+ __glXSendLargeChunk(ctx, 1, totalRequests, header, headerLen);
+
+ /*
+ ** Send enough requests until the whole array is sent.
+ */
+ for ( requestNumber = 2 ; requestNumber <= (totalRequests - 1) ; requestNumber++ ) {
+ __glXSendLargeChunk(ctx, requestNumber, totalRequests, data, maxSize);
+ data = (const GLvoid *) (((const GLubyte *) data) + maxSize);
+ dataLen -= maxSize;
+ assert( dataLen > 0 );
+ }
+
+ assert( dataLen <= maxSize );
+ __glXSendLargeChunk(ctx, requestNumber, totalRequests, data, dataLen);
+}
+
+/************************************************************************/
+
+GLXContext glXGetCurrentContext(void)
+{
+ GLXContext cx = __glXGetCurrentContext();
+
+ if (cx == &dummyContext) {
+ return NULL;
+ } else {
+ return cx;
+ }
+}
+
+GLXDrawable glXGetCurrentDrawable(void)
+{
+ GLXContext gc = __glXGetCurrentContext();
+ return gc->currentDrawable;
+}
+
+
+/************************************************************************/
+
+#ifdef GLX_DIRECT_RENDERING
+/* Return the DRI per screen structure */
+__DRIscreen *__glXFindDRIScreen(__DRInativeDisplay *dpy, int scrn)
+{
+ __DRIscreen *pDRIScreen = NULL;
+ XExtDisplayInfo *info = __glXFindDisplay(dpy);
+ XExtData **privList, *found;
+ __GLXdisplayPrivate *dpyPriv;
+ XEDataObject dataObj;
+
+ __glXLock();
+ dataObj.display = dpy;
+ privList = XEHeadOfExtensionList(dataObj);
+ found = XFindOnExtensionList(privList, info->codes->extension);
+ __glXUnlock();
+
+ if (found) {
+ dpyPriv = (__GLXdisplayPrivate *)found->private_data;
+ pDRIScreen = &dpyPriv->screenConfigs[scrn].driScreen;
+ }
+
+ return pDRIScreen;
+}
+#endif
+
+/************************************************************************/
+
+static Bool SendMakeCurrentRequest( Display *dpy, CARD8 opcode,
+ GLXContextID gc, GLXContextTag old_gc, GLXDrawable draw, GLXDrawable read,
+ xGLXMakeCurrentReply * reply );
+
+/**
+ * Sends a GLX protocol message to the specified display to make the context
+ * and the drawables current.
+ *
+ * \param dpy Display to send the message to.
+ * \param opcode Major opcode value for the display.
+ * \param gc_id Context tag for the context to be made current.
+ * \param draw Drawable ID for the "draw" drawable.
+ * \param read Drawable ID for the "read" drawable.
+ * \param reply Space to store the X-server's reply.
+ *
+ * \warning
+ * This function assumes that \c dpy is locked with \c LockDisplay on entry.
+ */
+static Bool SendMakeCurrentRequest( Display *dpy, CARD8 opcode,
+ GLXContextID gc_id, GLXContextTag gc_tag,
+ GLXDrawable draw, GLXDrawable read,
+ xGLXMakeCurrentReply * reply )
+{
+ if ( draw == read ) {
+ xGLXMakeCurrentReq *req;
+
+ GetReq(GLXMakeCurrent,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXMakeCurrent;
+ req->drawable = draw;
+ req->context = gc_id;
+ req->oldContextTag = gc_tag;
+ }
+ else {
+ __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+
+ /* If the server can support the GLX 1.3 version, we should
+ * perfer that. Not only that, some servers support GLX 1.3 but
+ * not the SGI extension.
+ */
+
+ if ( (priv->majorVersion > 1) || (priv->minorVersion >= 3) ) {
+ xGLXMakeContextCurrentReq *req;
+
+ GetReq(GLXMakeContextCurrent,req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXMakeContextCurrent;
+ req->drawable = draw;
+ req->readdrawable = read;
+ req->context = gc_id;
+ req->oldContextTag = gc_tag;
+ }
+ else {
+ xGLXVendorPrivateWithReplyReq *vpreq;
+ xGLXMakeCurrentReadSGIReq *req;
+
+ GetReqExtra(GLXVendorPrivateWithReply,
+ sz_xGLXMakeCurrentReadSGIReq-sz_xGLXVendorPrivateWithReplyReq,vpreq);
+ req = (xGLXMakeCurrentReadSGIReq *)vpreq;
+ req->reqType = opcode;
+ req->glxCode = X_GLXVendorPrivateWithReply;
+ req->vendorCode = X_GLXvop_MakeCurrentReadSGI;
+ req->drawable = draw;
+ req->readable = read;
+ req->context = gc_id;
+ req->oldContextTag = gc_tag;
+ }
+ }
+
+ return _XReply(dpy, (xReply*) reply, 0, False);
+}
+
+
+#ifdef GLX_DIRECT_RENDERING
+static Bool BindContextWrapper( Display *dpy, GLXContext gc,
+ GLXDrawable draw, GLXDrawable read )
+{
+ return (*gc->driContext.bindContext)(dpy, gc->screen, draw, read,
+ & gc->driContext);
+}
+
+
+static Bool UnbindContextWrapper( GLXContext gc )
+{
+ return (*gc->driContext.unbindContext)(gc->currentDpy, gc->screen,
+ gc->currentDrawable,
+ gc->currentReadable,
+ & gc->driContext );
+}
+#endif /* GLX_DIRECT_RENDERING */
+
+
+/*
+** Make a particular context current.
+** NOTE: this is in this file so that it can access dummyContext.
+*/
+USED static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
+ GLXDrawable read, GLXContext gc)
+{
+ xGLXMakeCurrentReply reply;
+ GLXContext oldGC;
+ CARD8 opcode, oldOpcode;
+ Bool sentRequestToOldDpy = False;
+ Bool bindReturnValue = True;
+
+ opcode = __glXSetupForCommand(dpy);
+ if (!opcode) {
+ return GL_FALSE;
+ }
+
+ /*
+ ** Make sure that the new context has a nonzero ID. In the request,
+ ** a zero context ID is used only to mean that we bind to no current
+ ** context.
+ */
+ if ((gc != NULL) && (gc->xid == None)) {
+ return GL_FALSE;
+ }
+
+ oldGC = __glXGetCurrentContext();
+ oldOpcode = (gc == oldGC) ? opcode : __glXSetupForCommand(dpy);
+ if (!oldOpcode) {
+ return GL_FALSE;
+ }
+
+ if ((dpy != oldGC->currentDpy || (gc && gc->isDirect)) &&
+ !oldGC->isDirect && oldGC != &dummyContext) {
+ /*
+ ** We are either switching from one dpy to another and have to
+ ** send a request to the previous dpy to unbind the previous
+ ** context, or we are switching away from a indirect context to
+ ** a direct context and have to send a request to the dpy to
+ ** unbind the previous context.
+ */
+ sentRequestToOldDpy = True;
+ LockDisplay(oldGC->currentDpy);
+ if ( ! SendMakeCurrentRequest( oldGC->currentDpy, oldOpcode, None,
+ oldGC->currentContextTag, None, None,
+ &reply ) ) {
+ /* The make current failed. Just return GL_FALSE. */
+ UnlockDisplay(oldGC->currentDpy);
+ SyncHandle();
+ return GL_FALSE;
+ }
+
+ oldGC->currentContextTag = 0;
+ }
+
+ _glapi_check_multithread();
+
+#ifdef GLX_DIRECT_RENDERING
+ /* Unbind the old direct rendering context */
+ if (oldGC->isDirect) {
+ if (oldGC->driContext.private) {
+ if (! UnbindContextWrapper( oldGC )) {
+ /* The make current failed. Just return GL_FALSE. */
+ return GL_FALSE;
+ }
+ }
+ oldGC->currentContextTag = 0;
+ }
+
+ /* Bind the direct rendering context to the drawable */
+ if (gc && gc->isDirect) {
+ if (gc->driContext.private) {
+ bindReturnValue = BindContextWrapper( dpy, gc, draw, read );
+ }
+ } else {
+#endif
+ /* Send a glXMakeCurrent request to bind the new context. */
+ LockDisplay(dpy);
+
+ bindReturnValue = SendMakeCurrentRequest( dpy, opcode,
+ gc ? gc->xid : None,
+ oldGC->currentContextTag,
+ draw, read, &reply );
+ UnlockDisplay(dpy);
+#ifdef GLX_DIRECT_RENDERING
+ }
+#endif
+
+
+ if (!bindReturnValue) {
+ /* The make current failed. */
+ if (gc && !gc->isDirect) {
+ SyncHandle();
+ }
+
+#ifdef GLX_DIRECT_RENDERING
+ /* If the old context was direct rendering, then re-bind to it. */
+ if (oldGC->isDirect) {
+ if (oldGC->driContext.private) {
+ if (! BindContextWrapper( oldGC->currentDpy, oldGC,
+ oldGC->currentDrawable,
+ oldGC->currentReadable )) {
+ /*
+ ** The request failed; this cannot happen with the
+ ** current API. If in the future the API is
+ ** extended to allow context sharing between
+ ** clients, then this may fail (because another
+ ** client may have grabbed the context); in that
+ ** case, we cannot undo the previous request, and
+ ** cannot adhere to the "no-op" behavior.
+ */
+ }
+ }
+ } else
+#endif
+ /*
+ ** If we had just sent a request to a previous dpy, we have to
+ ** undo that request (because if a command fails, it should act
+ ** like a no-op) by making current to the previous context and
+ ** drawable.
+ */
+ if (sentRequestToOldDpy) {
+ if ( !SendMakeCurrentRequest( oldGC->currentDpy, oldOpcode,
+ oldGC->xid, 0,
+ oldGC->currentDrawable,
+ oldGC->currentReadable, &reply ) ) {
+ UnlockDisplay(oldGC->currentDpy);
+ SyncHandle();
+ /*
+ ** The request failed; this cannot happen with the
+ ** current API. If in the future the API is extended to
+ ** allow context sharing between clients, then this may
+ ** fail (because another client may have grabbed the
+ ** context); in that case, we cannot undo the previous
+ ** request, and cannot adhere to the "no-op" behavior.
+ */
+ }
+ else {
+ UnlockDisplay(oldGC->currentDpy);
+ }
+ oldGC->currentContextTag = reply.contextTag;
+ }
+ return GL_FALSE;
+ }
+
+ /* Update our notion of what is current */
+ __glXLock();
+ if (gc == oldGC) {
+ /*
+ ** Even though the contexts are the same the drawable might have
+ ** changed. Note that gc cannot be the dummy, and that oldGC
+ ** cannot be NULL, therefore if they are the same, gc is not
+ ** NULL and not the dummy.
+ */
+ gc->currentDrawable = draw;
+ gc->currentReadable = read;
+ } else {
+ if (oldGC != &dummyContext) {
+ /* Old current context is no longer current to anybody */
+ oldGC->currentDpy = 0;
+ oldGC->currentDrawable = None;
+ oldGC->currentReadable = None;
+ oldGC->currentContextTag = 0;
+
+ if (oldGC->xid == None) {
+ /*
+ ** We are switching away from a context that was
+ ** previously destroyed, so we need to free the memory
+ ** for the old handle.
+ */
+#ifdef GLX_DIRECT_RENDERING
+ /* Destroy the old direct rendering context */
+ if (oldGC->isDirect) {
+ if (oldGC->driContext.private) {
+ (*oldGC->driContext.destroyContext)
+ (dpy, oldGC->screen, oldGC->driContext.private);
+ oldGC->driContext.private = NULL;
+ }
+ }
+#endif
+ __glXFreeContext(oldGC);
+ }
+ }
+ if (gc) {
+ __glXSetCurrentContext(gc);
+#ifdef GLX_DIRECT_RENDERING
+ if (!gc->isDirect) {
+ if (!IndirectAPI)
+ IndirectAPI = __glXNewIndirectAPI();
+ _glapi_set_dispatch(IndirectAPI);
+# ifdef GLX_USE_APPLEGL
+ do {
+ extern void XAppleDRIUseIndirectDispatch(void);
+ XAppleDRIUseIndirectDispatch();
+ } while (0);
+# endif
+ }
+#else
+ /* if not direct rendering, always need indirect dispatch */
+ if (!IndirectAPI)
+ IndirectAPI = __glXNewIndirectAPI();
+ _glapi_set_dispatch(IndirectAPI);
+#endif
+ gc->currentDpy = dpy;
+ gc->currentDrawable = draw;
+ gc->currentReadable = read;
+
+ if ( ! gc->isDirect ) {
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+
+ gc->currentContextTag = reply.contextTag;
+ if ( state->array_state == NULL ) {
+ (void) glGetString( GL_EXTENSIONS );
+ (void) glGetString( GL_VERSION );
+ __glXInitVertexArrayState(gc);
+ }
+ }
+ else {
+ gc->currentContextTag = -1;
+ }
+ } else {
+ __glXSetCurrentContext(&dummyContext);
+#ifdef GLX_DIRECT_RENDERING
+ _glapi_set_dispatch(NULL); /* no-op functions */
+#endif
+ }
+ }
+ __glXUnlock();
+ return GL_TRUE;
+}
+
+
+PUBLIC Bool glXMakeCurrent(Display *dpy, GLXDrawable draw, GLXContext gc)
+{
+ return MakeContextCurrent( dpy, draw, draw, gc );
+}
+
+PUBLIC GLX_ALIAS(Bool, glXMakeCurrentReadSGI,
+ (Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
+ (dpy, d, r, ctx), MakeContextCurrent)
+
+PUBLIC GLX_ALIAS(Bool, glXMakeContextCurrent,
+ (Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
+ (dpy, d, r, ctx), MakeContextCurrent)
+
+
+#ifdef DEBUG
+void __glXDumpDrawBuffer(__GLXcontext *ctx)
+{
+ GLubyte *p = ctx->buf;
+ GLubyte *end = ctx->pc;
+ GLushort opcode, length;
+
+ while (p < end) {
+ /* Fetch opcode */
+ opcode = *((GLushort*) p);
+ length = *((GLushort*) (p + 2));
+ printf("%2x: %5d: ", opcode, length);
+ length -= 4;
+ p += 4;
+ while (length > 0) {
+ printf("%08x ", *((unsigned *) p));
+ p += 4;
+ length -= 4;
+ }
+ printf("\n");
+ }
+}
+#endif
+
+#ifdef USE_SPARC_ASM
+/*
+ * Used only when we are sparc, using sparc assembler.
+ *
+ */
+
+static void
+_glx_mesa_init_sparc_glapi_relocs(void)
+{
+ unsigned int *insn_ptr, *end_ptr;
+ unsigned long disp_addr;
+
+ insn_ptr = &_mesa_sparc_glapi_begin;
+ end_ptr = &_mesa_sparc_glapi_end;
+ disp_addr = (unsigned long) &_glapi_Dispatch;
+
+ /*
+ * Verbatim from Mesa sparc.c. It's needed because there doesn't
+ * seem to be a better way to do this:
+ *
+ * UNCONDITIONAL_JUMP ( (*_glapi_Dispatch) + entry_offset )
+ *
+ * This code is patching in the ADDRESS of the pointer to the
+ * dispatch table. Hence, it must be called exactly once, because
+ * that address is not going to change.
+ *
+ * What it points to can change, but Mesa (and hence, we) assume
+ * that there is only one pointer.
+ *
+ */
+ while (insn_ptr < end_ptr) {
+#if ( defined(__sparc_v9__) && ( !defined(__linux__) || defined(__linux_64__) ) )
+/*
+ This code patches for 64-bit addresses. This had better
+ not happen for Sparc/Linux, no matter what architecture we
+ are building for. So, don't do this.
+
+ The 'defined(__linux_64__)' is used here as a placeholder for
+ when we do do 64-bit usermode on sparc linux.
+ */
+ insn_ptr[0] |= (disp_addr >> (32 + 10));
+ insn_ptr[1] |= ((disp_addr & 0xffffffff) >> 10);
+ __glapi_sparc_icache_flush(&insn_ptr[0]);
+ insn_ptr[2] |= ((disp_addr >> 32) & ((1 << 10) - 1));
+ insn_ptr[3] |= (disp_addr & ((1 << 10) - 1));
+ __glapi_sparc_icache_flush(&insn_ptr[2]);
+ insn_ptr += 11;
+#else
+ insn_ptr[0] |= (disp_addr >> 10);
+ insn_ptr[1] |= (disp_addr & ((1 << 10) - 1));
+ __glapi_sparc_icache_flush(&insn_ptr[0]);
+ insn_ptr += 5;
+#endif
+ }
+}
+#endif /* sparc ASM in use */
+
diff --git a/nx-X11/extras/Mesa/src/glx/x11/glxextensions.c b/nx-X11/extras/Mesa/src/glx/x11/glxextensions.c
new file mode 100644
index 000000000..d2597981c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/glxextensions.c
@@ -0,0 +1,717 @@
+/*
+ * (C) Copyright IBM Corporation 2002, 2004
+ * 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
+ * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file glxextensions.c
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include "glxclient.h"
+#include <X11/extensions/extutil.h>
+#include <X11/extensions/Xext.h>
+#include <string.h>
+#include "glapi.h"
+#include "glxextensions.h"
+#include "simple_list.h"
+
+#define SET_BIT(m,b) (m[ (b) / 8 ] |= (1U << ((b) % 8)))
+#define CLR_BIT(m,b) (m[ (b) / 8 ] &= ~(1U << ((b) % 8)))
+#define IS_SET(m,b) ((m[ (b) / 8 ] & (1U << ((b) % 8))) != 0)
+#define CONCAT(a,b) a ## b
+#define GLX(n) "GLX_" # n, 4 + sizeof( # n ) - 1, CONCAT(n,_bit)
+#define GL(n) "GL_" # n, 3 + sizeof( # n ) - 1, GL_ ## n ## _bit
+#define VER(a,b) a, b
+#define Y 1
+#define N 0
+#define EXT_ENABLED(bit,supported) (IS_SET( supported, bit ))
+
+
+struct extension_info {
+ const char * const name;
+ unsigned name_len;
+
+ unsigned char bit;
+
+ /* This is the lowest version of GLX that "requires" this extension.
+ * For example, GLX 1.3 requires SGIX_fbconfig, SGIX_pbuffer, and
+ * SGI_make_current_read. If the extension is not required by any known
+ * version of GLX, use 0, 0.
+ */
+ unsigned char version_major;
+ unsigned char version_minor;
+ unsigned char client_support;
+ unsigned char direct_support;
+ unsigned char client_only; /** Is the extension client-side only? */
+ unsigned char direct_only; /** Is the extension for direct
+ * contexts only?
+ */
+};
+
+static const struct extension_info known_glx_extensions[] = {
+ { GLX(ARB_get_proc_address), VER(1,4), Y, N, Y, N },
+ { GLX(ARB_multisample), VER(1,4), Y, Y, N, N },
+ { GLX(ARB_render_texture), VER(0,0), N, N, N, N },
+ { GLX(ATI_pixel_format_float), VER(0,0), N, N, N, N },
+ { GLX(EXT_import_context), VER(0,0), Y, Y, N, N },
+ { GLX(EXT_visual_info), VER(0,0), Y, Y, N, N },
+ { GLX(EXT_visual_rating), VER(0,0), Y, Y, N, N },
+ { GLX(MESA_agp_offset), VER(0,0), N, N, N, Y }, /* Deprecated */
+ { GLX(MESA_allocate_memory), VER(0,0), Y, N, N, Y },
+ { GLX(MESA_copy_sub_buffer), VER(0,0), N, N, N, N }, /* Deprecated? */
+ { GLX(MESA_pixmap_colormap), VER(0,0), N, N, N, N }, /* Deprecated */
+ { GLX(MESA_release_buffers), VER(0,0), N, N, N, N }, /* Deprecated */
+ { GLX(MESA_set_3dfx_mode), VER(0,0), N, N, N, N }, /* Deprecated */
+ { GLX(MESA_swap_control), VER(0,0), Y, N, N, Y },
+ { GLX(MESA_swap_frame_usage), VER(0,0), Y, N, N, Y },
+ { GLX(NV_float_buffer), VER(0,0), N, N, N, N },
+ { GLX(NV_render_depth_texture), VER(0,0), N, N, N, N },
+ { GLX(NV_render_texture_rectangle), VER(0,0), N, N, N, N },
+ { GLX(NV_vertex_array_range), VER(0,0), N, N, N, Y }, /* Deprecated */
+ { GLX(OML_swap_method), VER(0,0), Y, Y, N, N },
+ { GLX(OML_sync_control), VER(0,0), Y, N, N, Y },
+ { GLX(SGI_cushion), VER(0,0), N, N, N, N },
+ { GLX(SGI_make_current_read), VER(1,3), Y, N, N, N },
+ { GLX(SGI_swap_control), VER(0,0), Y, N, N, N },
+ { GLX(SGI_video_sync), VER(0,0), Y, N, N, Y },
+ { GLX(SGIS_blended_overlay), VER(0,0), N, N, N, N },
+ { GLX(SGIS_color_range), VER(0,0), N, N, N, N },
+ { GLX(SGIS_multisample), VER(0,0), Y, Y, N, N },
+ { GLX(SGIX_dm_buffer), VER(0,0), N, N, N, N },
+ { GLX(SGIX_fbconfig), VER(1,3), Y, Y, N, N },
+ { GLX(SGIX_pbuffer), VER(1,3), Y, N, N, N },
+ { GLX(SGIX_swap_barrier), VER(0,0), N, N, N, N },
+ { GLX(SGIX_swap_group), VER(0,0), N, N, N, N },
+ { GLX(SGIX_video_resize), VER(0,0), N, N, N, N },
+ { GLX(SGIX_video_source), VER(0,0), N, N, N, N },
+ { GLX(SGIX_visual_select_group), VER(0,0), Y, Y, N, N },
+ { GLX(SUN_get_transparent_index), VER(0,0), N, N, N, N },
+ { NULL }
+};
+
+static const struct extension_info known_gl_extensions[] = {
+ { GL(ARB_depth_texture), VER(1,4), Y, N, N, N },
+ { GL(ARB_draw_buffers), VER(0,0), Y, N, N, N },
+ { GL(ARB_fragment_program), VER(0,0), Y, N, N, N },
+ { GL(ARB_fragment_program_shadow), VER(0,0), Y, N, N, N },
+ { GL(ARB_imaging), VER(0,0), Y, N, N, N },
+ { GL(ARB_multisample), VER(1,3), Y, N, N, N },
+ { GL(ARB_multitexture), VER(1,3), Y, N, N, N },
+ { GL(ARB_occlusion_query), VER(1,5), Y, N, N, N },
+ { GL(ARB_point_parameters), VER(1,4), Y, N, N, N },
+ { GL(ARB_point_sprite), VER(0,0), Y, N, N, N },
+ { GL(ARB_shadow), VER(1,4), Y, N, N, N },
+ { GL(ARB_shadow_ambient), VER(0,0), Y, N, N, N },
+ { GL(ARB_texture_border_clamp), VER(1,3), Y, N, N, N },
+ { GL(ARB_texture_compression), VER(1,3), Y, N, N, N },
+ { GL(ARB_texture_cube_map), VER(1,3), Y, N, N, N },
+ { GL(ARB_texture_env_add), VER(1,3), Y, N, N, N },
+ { GL(ARB_texture_env_combine), VER(1,3), Y, N, N, N },
+ { GL(ARB_texture_env_crossbar), VER(1,4), Y, N, N, N },
+ { GL(ARB_texture_env_dot3), VER(1,3), Y, N, N, N },
+ { GL(ARB_texture_mirrored_repeat), VER(1,4), Y, N, N, N },
+ { GL(ARB_texture_non_power_of_two), VER(1,5), Y, N, N, N },
+ { GL(ARB_texture_rectangle), VER(0,0), Y, N, N, N },
+ { GL(ARB_transpose_matrix), VER(1,3), Y, N, Y, N },
+ { GL(ARB_vertex_buffer_object), VER(1,5), N, N, N, N },
+ { GL(ARB_vertex_program), VER(0,0), Y, N, N, N },
+ { GL(ARB_window_pos), VER(1,4), Y, N, N, N },
+ { GL(EXT_abgr), VER(0,0), Y, N, N, N },
+ { GL(EXT_bgra), VER(1,2), Y, N, N, N },
+ { GL(EXT_blend_color), VER(1,4), Y, N, N, N },
+ { GL(EXT_blend_equation_separate), VER(0,0), N, N, N, N },
+ { GL(EXT_blend_func_separate), VER(1,4), Y, N, N, N },
+ { GL(EXT_blend_logic_op), VER(1,4), Y, N, N, N },
+ { GL(EXT_blend_minmax), VER(1,4), Y, N, N, N },
+ { GL(EXT_blend_subtract), VER(1,4), Y, N, N, N },
+ { GL(EXT_clip_volume_hint), VER(0,0), Y, N, N, N },
+ { GL(EXT_compiled_vertex_array), VER(0,0), N, N, N, N },
+ { GL(EXT_convolution), VER(0,0), N, N, N, N },
+ { GL(EXT_copy_texture), VER(1,1), Y, N, N, N },
+ { GL(EXT_cull_vertex), VER(0,0), N, N, N, N },
+ { GL(EXT_depth_bounds_test), VER(0,0), N, N, N, N },
+ { GL(EXT_draw_range_elements), VER(1,2), Y, N, Y, N },
+ { GL(EXT_fog_coord), VER(1,4), Y, N, N, N },
+ { GL(EXT_multi_draw_arrays), VER(1,4), Y, N, Y, N },
+ { GL(EXT_packed_pixels), VER(1,2), Y, N, N, N },
+ { GL(EXT_paletted_texture), VER(0,0), Y, N, N, N },
+ { GL(EXT_pixel_buffer_object), VER(0,0), N, N, N, N },
+ { GL(EXT_point_parameters), VER(1,4), Y, N, N, N },
+ { GL(EXT_polygon_offset), VER(1,1), Y, N, N, N },
+ { GL(EXT_rescale_normal), VER(1,2), Y, N, N, N },
+ { GL(EXT_secondary_color), VER(1,4), Y, N, N, N },
+ { GL(EXT_separate_specular_color), VER(1,2), Y, N, N, N },
+ { GL(EXT_shadow_funcs), VER(1,5), Y, N, N, N },
+ { GL(EXT_shared_texture_palette), VER(0,0), Y, N, N, N },
+ { GL(EXT_stencil_two_side), VER(0,0), Y, N, N, N },
+ { GL(EXT_stencil_wrap), VER(1,4), Y, N, N, N },
+ { GL(EXT_subtexture), VER(1,1), Y, N, N, N },
+ { GL(EXT_texture), VER(1,1), Y, N, N, N },
+ { GL(EXT_texture3D), VER(1,2), Y, N, N, N },
+ { GL(EXT_texture_compression_dxt1), VER(0,0), Y, N, N, N },
+ { GL(EXT_texture_compression_s3tc), VER(0,0), Y, N, N, N },
+ { GL(EXT_texture_edge_clamp), VER(1,2), Y, N, N, N },
+ { GL(EXT_texture_env_add), VER(1,3), Y, N, N, N },
+ { GL(EXT_texture_env_combine), VER(1,3), Y, N, N, N },
+ { GL(EXT_texture_env_dot3), VER(0,0), Y, N, N, N },
+ { GL(EXT_texture_filter_anisotropic), VER(0,0), Y, N, N, N },
+ { GL(EXT_texture_lod), VER(1,2), Y, N, N, N },
+ { GL(EXT_texture_lod_bias), VER(1,4), Y, N, N, N },
+ { GL(EXT_texture_mirror_clamp), VER(0,0), Y, N, N, N },
+ { GL(EXT_texture_object), VER(1,1), Y, N, N, N },
+ { GL(EXT_texture_rectangle), VER(0,0), Y, N, N, N },
+ { GL(EXT_vertex_array), VER(0,0), Y, N, N, N },
+ { GL(3DFX_texture_compression_FXT1), VER(0,0), Y, N, N, N },
+ { GL(APPLE_packed_pixels), VER(1,2), Y, N, N, N },
+ { GL(APPLE_ycbcr_422), VER(0,0), Y, N, N, N },
+ { GL(ATI_draw_buffers), VER(0,0), Y, N, N, N },
+ { GL(ATI_text_fragment_shader), VER(0,0), Y, N, N, N },
+ { GL(ATI_texture_env_combine3), VER(0,0), Y, N, N, N },
+ { GL(ATI_texture_float), VER(0,0), Y, N, N, N },
+ { GL(ATI_texture_mirror_once), VER(0,0), Y, N, N, N },
+ { GL(ATIX_texture_env_combine3), VER(0,0), Y, N, N, N },
+ { GL(HP_convolution_border_modes), VER(0,0), Y, N, N, N },
+ { GL(HP_occlusion_test), VER(0,0), Y, N, N, N },
+ { GL(IBM_cull_vertex), VER(0,0), Y, N, N, N },
+ { GL(IBM_pixel_filter_hint), VER(0,0), Y, N, N, N },
+ { GL(IBM_rasterpos_clip), VER(0,0), Y, N, N, N },
+ { GL(IBM_texture_clamp_nodraw), VER(0,0), Y, N, N, N },
+ { GL(IBM_texture_mirrored_repeat), VER(0,0), Y, N, N, N },
+ { GL(INGR_blend_func_separate), VER(0,0), Y, N, N, N },
+ { GL(INGR_interlace_read), VER(0,0), Y, N, N, N },
+ { GL(MESA_pack_invert), VER(0,0), Y, N, N, N },
+ { GL(MESA_ycbcr_texture), VER(0,0), Y, N, N, N },
+ { GL(NV_blend_square), VER(1,4), Y, N, N, N },
+ { GL(NV_copy_depth_to_color), VER(0,0), Y, N, N, N },
+ { GL(NV_depth_clamp), VER(0,0), Y, N, N, N },
+ { GL(NV_fog_distance), VER(0,0), Y, N, N, N },
+ { GL(NV_fragment_program), VER(0,0), Y, N, N, N },
+ { GL(NV_fragment_program_option), VER(0,0), Y, N, N, N },
+ { GL(NV_fragment_program2), VER(0,0), Y, N, N, N },
+ { GL(NV_light_max_exponent), VER(0,0), Y, N, N, N },
+ { GL(NV_multisample_filter_hint), VER(0,0), Y, N, N, N },
+ { GL(NV_point_sprite), VER(0,0), Y, N, N, N },
+ { GL(NV_texgen_reflection), VER(0,0), Y, N, N, N },
+ { GL(NV_texture_compression_vtc), VER(0,0), Y, N, N, N },
+ { GL(NV_texture_env_combine4), VER(0,0), Y, N, N, N },
+ { GL(NV_texture_rectangle), VER(0,0), Y, N, N, N },
+ { GL(NV_vertex_program), VER(0,0), Y, N, N, N },
+ { GL(NV_vertex_program1_1), VER(0,0), Y, N, N, N },
+ { GL(NV_vertex_program2), VER(0,0), Y, N, N, N },
+ { GL(NV_vertex_program2_option), VER(0,0), Y, N, N, N },
+ { GL(NV_vertex_program3), VER(0,0), Y, N, N, N },
+ { GL(OES_read_format), VER(0,0), Y, N, N, N },
+ { GL(OES_compressed_paletted_texture),VER(0,0), Y, N, N, N },
+ { GL(SGI_color_matrix), VER(0,0), Y, N, N, N },
+ { GL(SGI_texture_color_table), VER(0,0), Y, N, N, N },
+ { GL(SGIS_generate_mipmap), VER(1,4), Y, N, N, N },
+ { GL(SGIS_multisample), VER(0,0), Y, N, N, N },
+ { GL(SGIS_texture_border_clamp), VER(1,3), Y, N, N, N },
+ { GL(SGIS_texture_edge_clamp), VER(1,2), Y, N, N, N },
+ { GL(SGIS_texture_lod), VER(1,2), Y, N, N, N },
+ { GL(SGIX_blend_alpha_minmax), VER(0,0), Y, N, N, N },
+ { GL(SGIX_clipmap), VER(0,0), Y, N, N, N },
+ { GL(SGIX_depth_texture), VER(0,0), Y, N, N, N },
+ { GL(SGIX_fog_offset), VER(0,0), Y, N, N, N },
+ { GL(SGIX_shadow), VER(0,0), Y, N, N, N },
+ { GL(SGIX_shadow_ambient), VER(0,0), Y, N, N, N },
+ { GL(SGIX_texture_coordinate_clamp), VER(0,0), Y, N, N, N },
+ { GL(SGIX_texture_lod_bias), VER(0,0), Y, N, N, N },
+ { GL(SGIX_texture_range), VER(0,0), Y, N, N, N },
+ { GL(SGIX_texture_scale_bias), VER(0,0), Y, N, N, N },
+ { GL(SGIX_vertex_preclip), VER(0,0), Y, N, N, N },
+ { GL(SGIX_vertex_preclip_hint), VER(0,0), Y, N, N, N },
+ { GL(SGIX_ycrcb), VER(0,0), Y, N, N, N },
+ { GL(SUN_convolution_border_modes), VER(0,0), Y, N, N, N },
+ { GL(SUN_multi_draw_arrays), VER(0,0), Y, N, Y, N },
+ { GL(SUN_slice_accum), VER(0,0), Y, N, N, N },
+ { NULL }
+};
+
+
+/* global bit-fields of available extensions and their characteristics */
+static unsigned char client_glx_support[8];
+static unsigned char client_glx_only[8];
+static unsigned char direct_glx_only[8];
+static unsigned char client_gl_support[ __GL_EXT_BYTES ];
+static unsigned char client_gl_only[ __GL_EXT_BYTES ];
+
+/**
+ * Bits representing the set of extensions that are enabled by default in all
+ * direct rendering drivers.
+ */
+static unsigned char direct_glx_support[8];
+
+/**
+ * Highest core GL version that can be supported for indirect rendering.
+ */
+static const unsigned gl_major = 1;
+static const unsigned gl_minor = 4;
+
+/* client extensions string */
+static const char * __glXGLXClientExtensions = NULL;
+
+static void __glXExtensionsCtr( void );
+static void __glXExtensionsCtrScreen( __GLXscreenConfigs *psc );
+static void __glXProcessServerString( const struct extension_info * ext,
+ const char * server_string, unsigned char * server_support );
+
+/**
+ * Set the state of a GLX extension.
+ *
+ * \param name Name of the extension.
+ * \param name_len Length, in characters, of the extension name.
+ * \param state New state (either enabled or disabled) of the extension.
+ * \param supported Table in which the state of the extension is to be set.
+ */
+static void
+set_glx_extension( const struct extension_info * ext,
+ const char * name, unsigned name_len, GLboolean state,
+ unsigned char * supported )
+{
+ unsigned i;
+
+
+ for ( i = 0 ; ext[i].name != NULL ; i++ ) {
+ if ( (name_len == ext[i].name_len)
+ && (strncmp( ext[i].name, name, name_len ) == 0) ) {
+ if ( state ) {
+ SET_BIT( supported, ext[i].bit );
+ }
+ else {
+ CLR_BIT( supported, ext[i].bit );
+ }
+
+ return;
+ }
+ }
+}
+
+
+#define NUL '\0'
+#define SEPARATOR ' '
+
+/**
+ * Convert the server's extension string to a bit-field.
+ *
+ * \param server_string GLX extension string from the server.
+ * \param server_support Bit-field of supported extensions.
+ */
+static void
+__glXProcessServerString( const struct extension_info * ext,
+ const char * server_string,
+ unsigned char * server_support )
+{
+ unsigned base;
+ unsigned len;
+
+ (void) memset( server_support, 0, sizeof( server_support ) );
+
+ for ( base = 0 ; server_string[ base ] != NUL ; /* empty */ ) {
+ /* Determine the length of the next extension name.
+ */
+ for ( len = 0
+ ; (server_string[ base + len ] != SEPARATOR)
+ && (server_string[ base + len ] != NUL)
+ ; len++ ) {
+ /* empty */
+ }
+
+ /* Set the bit for the extension in the server_support table.
+ */
+ set_glx_extension( ext, & server_string[ base ], len, GL_TRUE,
+ server_support );
+
+
+ /* Advance to the next extension string. This means that we skip
+ * over the previous string and any trialing white-space.
+ */
+ for ( base += len ;
+ (server_string[ base ] == SEPARATOR)
+ && (server_string[ base ] != NUL)
+ ; base++ ) {
+ /* empty */
+ }
+ }
+}
+
+
+/**
+ * Enable a named GLX extension on a given screen.
+ * Drivers should not call this function directly. They should instead use
+ * \c glXGetProcAddress to obtain a pointer to the function.
+ *
+ * \param psc Pointer to GLX per-screen record.
+ * \param name Name of the extension to enable.
+ *
+ * \sa glXGetProcAddress
+ *
+ * \since Internal API version 20030813.
+ */
+void
+__glXScrEnableExtension( __GLXscreenConfigs *psc, const char * name )
+{
+ __glXExtensionsCtr();
+ __glXExtensionsCtrScreen(psc);
+ set_glx_extension( known_glx_extensions, name, strlen( name ), GL_TRUE,
+ psc->direct_support );
+}
+
+
+/**
+ * Initialize global extension support tables.
+ */
+
+static void
+__glXExtensionsCtr( void )
+{
+ unsigned i;
+ static GLboolean ext_list_first_time = GL_TRUE;
+
+
+ if ( ext_list_first_time ) {
+ ext_list_first_time = GL_FALSE;
+
+ (void) memset( client_glx_support, 0, sizeof( client_glx_support ) );
+ (void) memset( direct_glx_support, 0, sizeof( direct_glx_support ) );
+ (void) memset( client_glx_only, 0, sizeof( client_glx_only ) );
+ (void) memset( direct_glx_only, 0, sizeof( direct_glx_only ) );
+
+ (void) memset( client_gl_support, 0, sizeof( client_gl_support ) );
+ (void) memset( client_gl_only, 0, sizeof( client_gl_only ) );
+
+ for ( i = 0 ; known_glx_extensions[i].name != NULL ; i++ ) {
+ const unsigned bit = known_glx_extensions[i].bit;
+
+ if ( known_glx_extensions[i].client_support ) {
+ SET_BIT( client_glx_support, bit );
+ }
+
+ if ( known_glx_extensions[i].direct_support ) {
+ SET_BIT( direct_glx_support, bit );
+ }
+
+ if ( known_glx_extensions[i].client_only ) {
+ SET_BIT( client_glx_only, bit );
+ }
+
+ if ( known_glx_extensions[i].direct_only ) {
+ SET_BIT( direct_glx_only, bit );
+ }
+ }
+
+ for ( i = 0 ; known_gl_extensions[i].name != NULL ; i++ ) {
+ const unsigned bit = known_gl_extensions[i].bit;
+
+ if ( known_gl_extensions[i].client_support ) {
+ SET_BIT( client_gl_support, bit );
+ }
+
+ if ( known_gl_extensions[i].client_only ) {
+ SET_BIT( client_gl_only, bit );
+ }
+ }
+
+#if 0
+ fprintf( stderr, "[%s:%u] Maximum client library version: %u.%u\n",
+ __func__, __LINE__, gl_major, gl_minor );
+#endif
+ }
+}
+
+
+/**
+ * Make sure that per-screen direct-support table is initialized.
+ *
+ * \param psc Pointer to GLX per-screen record.
+ */
+
+static void
+__glXExtensionsCtrScreen( __GLXscreenConfigs *psc )
+{
+ if (psc->ext_list_first_time) {
+ psc->ext_list_first_time = GL_FALSE;
+ (void) memcpy( psc->direct_support, direct_glx_support,
+ sizeof( direct_glx_support ) );
+ }
+}
+
+
+/**
+ * Check if a certain extension is enabled on a given screen.
+ *
+ * \param psc Pointer to GLX per-screen record.
+ * \param bit Bit index in the direct-support table.
+ * \returns If the extension bit is enabled for the screen, \c GL_TRUE is
+ * returned. If the extension bit is not enabled or if \c psc is
+ * \c NULL, then \c GL_FALSE is returned.
+ */
+GLboolean
+__glXExtensionBitIsEnabled( __GLXscreenConfigs *psc, unsigned bit )
+{
+ GLboolean enabled = GL_FALSE;
+
+ if ( psc != NULL ) {
+ __glXExtensionsCtr();
+ __glXExtensionsCtrScreen( psc );
+ enabled = EXT_ENABLED( bit, psc->direct_support );
+ }
+
+ return enabled;
+}
+
+
+/**
+ * Check if a certain extension is enabled in a given context.
+ *
+ */
+GLboolean
+__glExtensionBitIsEnabled( const __GLXcontext * gc, unsigned bit )
+{
+ GLboolean enabled = GL_FALSE;
+
+ if ( gc != NULL ) {
+ enabled = EXT_ENABLED( bit, gc->gl_extension_bits );
+ }
+
+ return enabled;
+}
+
+
+
+/**
+ * Convert a bit-field to a string of supported extensions.
+ */
+static char *
+__glXGetStringFromTable( const struct extension_info * ext,
+ const unsigned char * supported )
+{
+ unsigned i;
+ unsigned ext_str_len;
+ char * ext_str;
+ char * point;
+
+
+ ext_str_len = 0;
+ for ( i = 0 ; ext[i].name != NULL ; i++ ) {
+ if ( EXT_ENABLED( ext[i].bit, supported ) ) {
+ ext_str_len += ext[i].name_len + 1;
+ }
+ }
+
+ ext_str = Xmalloc( ext_str_len + 1 );
+ if ( ext_str != NULL ) {
+ point = ext_str;
+
+ for ( i = 0 ; ext[i].name != NULL ; i++ ) {
+ if ( EXT_ENABLED( ext[i].bit, supported ) ) {
+ (void) memcpy( point, ext[i].name, ext[i].name_len );
+ point += ext[i].name_len;
+
+ *point = ' ';
+ point++;
+ }
+ }
+
+ *point = '\0';
+ }
+
+ return ext_str;
+}
+
+
+/**
+ * Get the string of client library supported extensions.
+ */
+const char *
+__glXGetClientExtensions( void )
+{
+ if ( __glXGLXClientExtensions == NULL ) {
+ __glXExtensionsCtr();
+ __glXGLXClientExtensions = __glXGetStringFromTable( known_glx_extensions,
+ client_glx_support );
+ }
+
+ return __glXGLXClientExtensions;
+}
+
+
+/**
+ * Calculate the list of application usable extensions. The resulting
+ * string is stored in \c psc->effectiveGLXexts.
+ *
+ * \param psc Pointer to GLX per-screen record.
+ * \param display_is_direct_capable True if the display is capable of
+ * direct rendering.
+ * \param minor_version GLX minor version from the server.
+ */
+
+void
+__glXCalculateUsableExtensions( __GLXscreenConfigs *psc,
+ GLboolean display_is_direct_capable,
+ int minor_version )
+{
+ unsigned char server_support[8];
+ unsigned char usable[8];
+ unsigned i;
+
+ __glXExtensionsCtr();
+ __glXExtensionsCtrScreen( psc );
+ __glXProcessServerString( known_glx_extensions,
+ psc->serverGLXexts, server_support );
+
+
+ /* This is a hack. Some servers support GLX 1.3 but don't export
+ * all of the extensions implied by GLX 1.3. If the server claims
+ * support for GLX 1.3, enable support for the extensions that can be
+ * "emulated" as well.
+ */
+
+ if ( minor_version >= 3 ) {
+ SET_BIT( server_support, EXT_visual_info_bit );
+ SET_BIT( server_support, EXT_visual_rating_bit );
+ SET_BIT( server_support, SGI_make_current_read_bit );
+ SET_BIT( server_support, SGIX_fbconfig_bit );
+ SET_BIT( server_support, SGIX_pbuffer_bit );
+
+ /* This one is a little iffy. GLX 1.3 doesn't incorporate all of this
+ * extension. However, the only part that is not strictly client-side
+ * is shared. That's the glXQueryContext / glXQueryContextInfoEXT
+ * function.
+ */
+
+ SET_BIT( server_support, EXT_import_context_bit );
+ }
+
+
+ /* An extension is supported if the client-side (i.e., libGL) supports
+ * it and the "server" supports it. In this case that means that either
+ * the true server supports it or it is only for direct-rendering and
+ * the direct rendering driver supports it.
+ *
+ * If the display is not capable of direct rendering, then the extension
+ * is enabled if and only if the client-side library and the server
+ * support it.
+ */
+
+ if ( display_is_direct_capable ) {
+ for ( i = 0 ; i < 8 ; i++ ) {
+ usable[i] = (client_glx_support[i] & client_glx_only[i])
+ | (client_glx_support[i] & psc->direct_support[i] & server_support[i])
+ | (client_glx_support[i] & psc->direct_support[i] & direct_glx_only[i]);
+ }
+ }
+ else {
+ for ( i = 0 ; i < 8 ; i++ ) {
+ usable[i] = (client_glx_support[i] & client_glx_only[i])
+ | (client_glx_support[i] & server_support[i]);
+ }
+ }
+
+ psc->effectiveGLXexts = __glXGetStringFromTable( known_glx_extensions,
+ usable );
+}
+
+
+/**
+ * Calculate the list of application usable extensions. The resulting
+ * string is stored in \c gc->extensions.
+ *
+ * \param gc Pointer to GLX context.
+ * \param server_string Extension string from the server.
+ * \param major_version GL major version from the server.
+ * \param minor_version GL minor version from the server.
+ */
+
+void
+__glXCalculateUsableGLExtensions( __GLXcontext * gc,
+ const char * server_string,
+ int major_version, int minor_version )
+{
+ unsigned char server_support[ __GL_EXT_BYTES ];
+ unsigned char usable[ __GL_EXT_BYTES ];
+ unsigned i;
+
+
+ __glXExtensionsCtr();
+
+ (void) memset( server_support, 0, sizeof( server_support ) );
+ __glXProcessServerString( known_gl_extensions, server_string,
+ server_support );
+
+
+ /* Handle lazy servers that don't export all the extensions strings that
+ * are part of the GL core version that they support.
+ */
+
+ for ( i = 0 ; i < __GL_EXT_BYTES ; i++ ) {
+ if ( (known_gl_extensions[i].version_major != 0)
+ && ((major_version > known_gl_extensions[i].version_major)
+ || ((major_version == known_gl_extensions[i].version_major)
+ && (minor_version >= known_gl_extensions[i].version_minor))) ) {
+ SET_BIT( server_support, known_gl_extensions[i].bit );
+ }
+ }
+
+
+ /* An extension is supported if the client-side (i.e., libGL) supports
+ * it and the server supports it or the client-side library supports it
+ * and it only needs client-side support.
+ */
+
+ for ( i = 0 ; i < __GL_EXT_BYTES ; i++ ) {
+ usable[i] = (client_gl_support[i] & client_gl_only[i])
+ | (client_gl_support[i] & server_support[i]);
+ }
+
+ gc->extensions = (unsigned char *)
+ __glXGetStringFromTable( known_gl_extensions, usable );
+ (void) memcpy( gc->gl_extension_bits, usable, sizeof( usable ) );
+}
+
+
+/**
+ * Calculates the maximum core GL version that can be supported for indirect
+ * rendering.
+ */
+void
+__glXGetGLVersion( int * major_version, int * minor_version )
+{
+ __glXExtensionsCtr();
+ *major_version = gl_major;
+ *minor_version = gl_minor;
+}
+
+
+/**
+ * Get a string representing the set of extensions supported by the client
+ * library. This is currently only used to send the list of extensions
+ * supported by the client to the server.
+ */
+char *
+__glXGetClientGLExtensionString( void )
+{
+ __glXExtensionsCtr();
+ return __glXGetStringFromTable( known_gl_extensions, client_gl_support );
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/glxextensions.h b/nx-X11/extras/Mesa/src/glx/x11/glxextensions.h
new file mode 100644
index 000000000..b4b03729c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/glxextensions.h
@@ -0,0 +1,279 @@
+/*
+ * (C) Copyright IBM Corporation 2002, 2004
+ * 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
+ * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file glxextensions.h
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#ifndef GLX_GLXEXTENSIONS_H
+#define GLX_GLXEXTENSIONS_H
+
+enum {
+ ARB_get_proc_address_bit = 0,
+ ARB_multisample_bit,
+ ARB_render_texture_bit,
+ ATI_pixel_format_float_bit,
+ EXT_visual_info_bit,
+ EXT_visual_rating_bit,
+ EXT_import_context_bit,
+ MESA_agp_offset_bit,
+ MESA_allocate_memory_bit, /* Replaces MESA_agp_offset & NV_vertex_array_range */
+ MESA_copy_sub_buffer_bit,
+ MESA_depth_float_bit,
+ MESA_pixmap_colormap_bit,
+ MESA_release_buffers_bit,
+ MESA_set_3dfx_mode_bit,
+ MESA_swap_control_bit,
+ MESA_swap_frame_usage_bit,
+ NV_float_buffer_bit,
+ NV_render_depth_texture_bit,
+ NV_render_texture_rectangle_bit,
+ NV_vertex_array_range_bit,
+ OML_swap_method_bit,
+ OML_sync_control_bit,
+ SGI_cushion_bit,
+ SGI_make_current_read_bit,
+ SGI_swap_control_bit,
+ SGI_video_sync_bit,
+ SGIS_blended_overlay_bit,
+ SGIS_color_range_bit,
+ SGIS_multisample_bit,
+ SGIX_dm_buffer_bit,
+ SGIX_fbconfig_bit,
+ SGIX_pbuffer_bit,
+ SGIX_swap_barrier_bit,
+ SGIX_swap_group_bit,
+ SGIX_video_resize_bit,
+ SGIX_video_source_bit,
+ SGIX_visual_select_group_bit,
+ SUN_get_transparent_index_bit
+};
+
+enum {
+ GL_ARB_depth_texture_bit = 0,
+ GL_ARB_draw_buffers_bit,
+ GL_ARB_fragment_program_bit,
+ GL_ARB_fragment_program_shadow_bit,
+ GL_ARB_imaging_bit,
+ GL_ARB_multisample_bit,
+ GL_ARB_multitexture_bit,
+ GL_ARB_occlusion_query_bit,
+ GL_ARB_point_parameters_bit,
+ GL_ARB_point_sprite_bit,
+ GL_ARB_shadow_bit,
+ GL_ARB_shadow_ambient_bit,
+ GL_ARB_texture_border_clamp_bit,
+ GL_ARB_texture_cube_map_bit,
+ GL_ARB_texture_compression_bit,
+ GL_ARB_texture_env_add_bit,
+ GL_ARB_texture_env_combine_bit,
+ GL_ARB_texture_env_crossbar_bit,
+ GL_ARB_texture_env_dot3_bit,
+ GL_ARB_texture_mirrored_repeat_bit,
+ GL_ARB_texture_non_power_of_two_bit,
+ GL_ARB_texture_rectangle_bit,
+ GL_ARB_transpose_matrix_bit,
+ GL_ARB_vertex_buffer_object_bit,
+ GL_ARB_vertex_program_bit,
+ GL_ARB_window_pos_bit,
+ GL_EXT_abgr_bit,
+ GL_EXT_bgra_bit,
+ GL_EXT_blend_color_bit,
+ GL_EXT_blend_equation_separate_bit,
+ GL_EXT_blend_func_separate_bit,
+ GL_EXT_blend_logic_op_bit,
+ GL_EXT_blend_minmax_bit,
+ GL_EXT_blend_subtract_bit,
+ GL_EXT_clip_volume_hint_bit,
+ GL_EXT_compiled_vertex_array_bit,
+ GL_EXT_convolution_bit,
+ GL_EXT_copy_texture_bit,
+ GL_EXT_cull_vertex_bit,
+ GL_EXT_depth_bounds_test_bit,
+ GL_EXT_draw_range_elements_bit,
+ GL_EXT_fog_coord_bit,
+ GL_EXT_multi_draw_arrays_bit,
+ GL_EXT_packed_pixels_bit,
+ GL_EXT_paletted_texture_bit,
+ GL_EXT_pixel_buffer_object_bit,
+ GL_EXT_polygon_offset_bit,
+ GL_EXT_rescale_normal_bit,
+ GL_EXT_secondary_color_bit,
+ GL_EXT_separate_specular_color_bit,
+ GL_EXT_shadow_funcs_bit,
+ GL_EXT_shared_texture_palette_bit,
+ GL_EXT_stencil_two_side_bit,
+ GL_EXT_stencil_wrap_bit,
+ GL_EXT_subtexture_bit,
+ GL_EXT_texture_bit,
+ GL_EXT_texture3D_bit,
+ GL_EXT_texture_compression_dxt1_bit,
+ GL_EXT_texture_compression_s3tc_bit,
+ GL_EXT_texture_edge_clamp_bit,
+ GL_EXT_texture_env_combine_bit,
+ GL_EXT_texture_env_dot3_bit,
+ GL_EXT_texture_filter_anisotropic_bit,
+ GL_EXT_texture_lod_bit,
+ GL_EXT_texture_lod_bias_bit,
+ GL_EXT_texture_mirror_clamp_bit,
+ GL_EXT_texture_object_bit,
+ GL_EXT_vertex_array_bit,
+ GL_3DFX_texture_compression_FXT1_bit,
+ GL_APPLE_packed_pixels_bit,
+ GL_APPLE_ycbcr_422_bit,
+ GL_ATI_text_fragment_shader_bit,
+ GL_ATI_texture_env_combine3_bit,
+ GL_ATI_texture_float_bit,
+ GL_ATI_texture_mirror_once_bit,
+ GL_HP_convolution_border_modes_bit,
+ GL_HP_occlusion_test_bit,
+ GL_IBM_cull_vertex_bit,
+ GL_IBM_pixel_filter_hint_bit,
+ GL_IBM_rasterpos_clip_bit,
+ GL_IBM_texture_clamp_nodraw_bit,
+ GL_INGR_interlace_read_bit,
+ GL_MESA_pack_invert_bit,
+ GL_MESA_ycbcr_texture_bit,
+ GL_NV_blend_square_bit,
+ GL_NV_copy_depth_to_color_bit,
+ GL_NV_depth_clamp_bit,
+ GL_NV_fog_distance_bit,
+ GL_NV_fragment_program_bit,
+ GL_NV_fragment_program_option_bit,
+ GL_NV_fragment_program2_bit,
+ GL_NV_light_max_exponent_bit,
+ GL_NV_multisample_filter_hint_bit,
+ GL_NV_point_sprite_bit,
+ GL_NV_texgen_reflection_bit,
+ GL_NV_texture_compression_vtc_bit,
+ GL_NV_texture_env_combine4_bit,
+ GL_NV_vertex_program_bit,
+ GL_NV_vertex_program1_1_bit,
+ GL_NV_vertex_program2_bit,
+ GL_NV_vertex_program2_option_bit,
+ GL_NV_vertex_program3_bit,
+ GL_OES_compressed_paletted_texture_bit,
+ GL_OES_read_format_bit,
+ GL_SGI_color_matrix_bit,
+ GL_SGI_texture_color_table_bit,
+ GL_SGIS_generate_mipmap_bit,
+ GL_SGIS_multisample_bit,
+ GL_SGIS_texture_lod_bit,
+ GL_SGIX_blend_alpha_minmax_bit,
+ GL_SGIX_clipmap_bit,
+ GL_SGIX_depth_texture_bit,
+ GL_SGIX_fog_offset_bit,
+ GL_SGIX_shadow_bit,
+ GL_SGIX_texture_coordinate_clamp_bit,
+ GL_SGIX_texture_lod_bias_bit,
+ GL_SGIX_texture_range_bit,
+ GL_SGIX_texture_scale_bias_bit,
+ GL_SGIX_vertex_preclip_bit,
+ GL_SGIX_vertex_preclip_hint_bit,
+ GL_SGIX_ycrcb_bit,
+ GL_SUN_convolution_border_modes_bit,
+ GL_SUN_slice_accum_bit,
+
+ /* This *MUST* go here. If it gets put after the duplicate values it will
+ * get the value after the last duplicate.
+ */
+ __NUM_GL_EXTS,
+
+
+ /* Alias extension bits. These extensions exist in either vendor-specific
+ * or EXT form and were later promoted to either EXT or ARB form. In all
+ * cases, the meaning is *exactly* the same. That's why
+ * EXT_texture_env_combine is *NOT* an alias of ARB_texture_env_combine and
+ * EXT_texture_env_dot3 is *NOT* an alias of ARB_texture_env_dot3. Be
+ * careful! When in doubt, src/mesa/main/extensions.c in the Mesa tree
+ * is a great reference.
+ */
+
+ GL_ATI_blend_equation_separate_bit = GL_EXT_blend_equation_separate_bit,
+ GL_ATI_draw_buffers_bit = GL_ARB_draw_buffers_bit,
+ GL_ATIX_texture_env_combine3_bit = GL_ATI_texture_env_combine3_bit,
+ GL_EXT_point_parameters_bit = GL_ARB_point_parameters_bit,
+ GL_EXT_texture_env_add_bit = GL_ARB_texture_env_add_bit,
+ GL_EXT_texture_rectangle_bit = GL_ARB_texture_rectangle_bit,
+ GL_IBM_texture_mirrored_repeat_bit = GL_ARB_texture_mirrored_repeat_bit,
+ GL_INGR_blend_func_separate_bit = GL_EXT_blend_func_separate_bit,
+ GL_MESA_window_pos_bit = GL_ARB_window_pos_bit,
+ GL_NV_texture_rectangle_bit = GL_ARB_texture_rectangle_bit,
+ GL_SGIS_texture_border_clamp_bit = GL_ARB_texture_border_clamp_bit,
+ GL_SGIS_texture_edge_clamp_bit = GL_EXT_texture_edge_clamp_bit,
+ GL_SGIX_shadow_ambient_bit = GL_ARB_shadow_ambient_bit,
+ GL_SUN_multi_draw_arrays_bit = GL_EXT_multi_draw_arrays_bit
+};
+
+#define __GL_EXT_BYTES ((__NUM_GL_EXTS + 7) / 8)
+
+struct __GLXscreenConfigsRec;
+struct __GLXcontextRec;
+
+extern GLboolean __glXExtensionBitIsEnabled( struct __GLXscreenConfigsRec *psc, unsigned bit );
+extern const char * __glXGetClientExtensions( void );
+extern void __glXCalculateUsableExtensions( struct __GLXscreenConfigsRec *psc,
+ GLboolean display_is_direct_capable, int server_minor_version );
+extern void __glXScrEnableExtension( struct __GLXscreenConfigsRec *psc, const char * name );
+extern void __glXCalculateUsableGLExtensions( struct __GLXcontextRec * gc,
+ const char * server_string, int major_version, int minor_version );
+extern void __glXGetGLVersion( int * major_version, int * minor_version );
+extern char * __glXGetClientGLExtensionString( void );
+
+extern GLboolean __glExtensionBitIsEnabled( const struct __GLXcontextRec * gc,
+ unsigned bit );
+
+
+/* Source-level backwards compatibility with old drivers. They won't
+ * find the respective functions, though.
+ */
+typedef void (* PFNGLXENABLEEXTENSIONPROC) ( const char * name,
+ GLboolean force_client );
+typedef void (* PFNGLXDISABLEEXTENSIONPROC) ( const char * name );
+
+/* GLX_ALIAS should be used for functions with a non-void return type.
+ GLX_ALIAS_VOID is for functions with a void return type. */
+#ifdef GLX_NO_STATIC_EXTENSION_FUNCTIONS
+# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func)
+# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func)
+#else
+# if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED)
+# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) \
+ return_type real_func proto_args \
+ __attribute__ ((alias( # aliased_func ) ));
+# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func) \
+ GLX_ALIAS(void, real_func, proto_args, args, aliased_func)
+# else
+# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) \
+ return_type real_func proto_args \
+ { return aliased_func args ; }
+# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func) \
+ void real_func proto_args \
+ { aliased_func args ; }
+# endif /* __GNUC__ */
+#endif /* GLX_NO_STATIC_EXTENSION_FUNCTIONS */
+
+#endif /* GLX_GLXEXTENSIONS_H */
diff --git a/nx-X11/extras/Mesa/src/glx/x11/indirect.c b/nx-X11/extras/Mesa/src/glx/x11/indirect.c
new file mode 100644
index 000000000..2a4db6578
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/indirect.c
@@ -0,0 +1,8472 @@
+/* DO NOT EDIT - This file generated automatically by glX_proto_send.py (from Mesa) script */
+
+/*
+ * (C) Copyright IBM Corporation 2004, 2005
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#include <GL/gl.h>
+#include "indirect.h"
+#include "glxclient.h"
+#include "indirect_size.h"
+#include <GL/glxproto.h>
+#ifdef USE_XCB
+#include <X11/xcl.h>
+#include <X11/XCB/xcb.h>
+#include <X11/XCB/glx.h>
+#endif /* USE_XCB */
+
+#define __GLX_PAD(n) (((n) + 3) & ~3)
+
+# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__)
+# define FASTCALL __attribute__((fastcall))
+# else
+# define FASTCALL
+# endif
+# if defined(__GNUC__)
+# define NOINLINE __attribute__((noinline))
+# else
+# define NOINLINE
+# endif
+
+#if !defined __GNUC__ || __GNUC__ < 3
+# define __builtin_expect(x, y) x
+#endif
+
+/* If the size and opcode values are known at compile-time, this will, on
+ * x86 at least, emit them with a single instruction.
+ */
+#define emit_header(dest, op, size) \
+ do { union { short s[2]; int i; } temp; \
+ temp.s[0] = (size); temp.s[1] = (op); \
+ *((int *)(dest)) = temp.i; } while(0)
+
+NOINLINE CARD32
+__glXReadReply( Display *dpy, size_t size, void * dest, GLboolean reply_is_always_array )
+{
+ xGLXSingleReply reply;
+
+ (void) _XReply(dpy, (xReply *) & reply, 0, False);
+ if (size != 0) {
+ if ((reply.length > 0) || reply_is_always_array) {
+ const GLint bytes = (reply_is_always_array)
+ ? (4 * reply.length) : (reply.size * size);
+ const GLint extra = 4 - (bytes & 3);
+
+ _XRead(dpy, dest, bytes);
+ if ( extra < 4 ) {
+ _XEatData(dpy, extra);
+ }
+ }
+ else {
+ (void) memcpy( dest, &(reply.pad3), size);
+ }
+ }
+
+ return reply.retval;
+}
+
+NOINLINE void
+__glXReadPixelReply( Display *dpy, __GLXcontext * gc, unsigned max_dim,
+ GLint width, GLint height, GLint depth, GLenum format, GLenum type,
+ void * dest, GLboolean dimensions_in_reply )
+{
+ xGLXSingleReply reply;
+ GLint size;
+
+ (void) _XReply(dpy, (xReply *) & reply, 0, False);
+
+ if ( dimensions_in_reply ) {
+ width = reply.pad3;
+ height = reply.pad4;
+ depth = reply.pad5;
+
+ if ((height == 0) || (max_dim < 2)) { height = 1; }
+ if ((depth == 0) || (max_dim < 3)) { depth = 1; }
+ }
+
+ size = reply.length * 4;
+ if (size != 0) {
+ void * buf = Xmalloc( size );
+
+ if ( buf == NULL ) {
+ _XEatData(dpy, size);
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ }
+ else {
+ const GLint extra = 4 - (size & 3);
+
+ _XRead(dpy, buf, size);
+ if ( extra < 4 ) {
+ _XEatData(dpy, extra);
+ }
+
+ __glEmptyImage(gc, 3, width, height, depth, format, type,
+ buf, dest);
+ Xfree(buf);
+ }
+ }
+}
+
+#define X_GLXSingle 0
+
+NOINLINE FASTCALL GLubyte *
+__glXSetupSingleRequest( __GLXcontext * gc, GLint sop, GLint cmdlen )
+{
+ xGLXSingleReq * req;
+ Display * const dpy = gc->currentDpy;
+
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ LockDisplay(dpy);
+ GetReqExtra(GLXSingle, cmdlen, req);
+ req->reqType = gc->majorOpcode;
+ req->contextTag = gc->currentContextTag;
+ req->glxCode = sop;
+ return (GLubyte *)(req) + sz_xGLXSingleReq;
+}
+
+NOINLINE FASTCALL GLubyte *
+__glXSetupVendorRequest( __GLXcontext * gc, GLint code, GLint vop, GLint cmdlen )
+{
+ xGLXVendorPrivateReq * req;
+ Display * const dpy = gc->currentDpy;
+
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ LockDisplay(dpy);
+ GetReqExtra(GLXVendorPrivate, cmdlen, req);
+ req->reqType = gc->majorOpcode;
+ req->glxCode = code;
+ req->vendorCode = vop;
+ req->contextTag = gc->currentContextTag;
+ return (GLubyte *)(req) + sz_xGLXVendorPrivateReq;
+}
+
+const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 };
+
+#define zero (__glXDefaultPixelStore+0)
+#define one (__glXDefaultPixelStore+8)
+#define default_pixel_store_1D (__glXDefaultPixelStore+4)
+#define default_pixel_store_1D_size 20
+#define default_pixel_store_2D (__glXDefaultPixelStore+4)
+#define default_pixel_store_2D_size 20
+#define default_pixel_store_3D (__glXDefaultPixelStore+0)
+#define default_pixel_store_3D_size 36
+#define default_pixel_store_4D (__glXDefaultPixelStore+0)
+#define default_pixel_store_4D_size 36
+
+static FASTCALL NOINLINE void
+generic_3_byte( GLint rop, const void * ptr )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+
+ emit_header(gc->pc, rop, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), ptr, 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+static FASTCALL NOINLINE void
+generic_4_byte( GLint rop, const void * ptr )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+
+ emit_header(gc->pc, rop, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), ptr, 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+static FASTCALL NOINLINE void
+generic_6_byte( GLint rop, const void * ptr )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+
+ emit_header(gc->pc, rop, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), ptr, 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+static FASTCALL NOINLINE void
+generic_8_byte( GLint rop, const void * ptr )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+
+ emit_header(gc->pc, rop, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), ptr, 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+static FASTCALL NOINLINE void
+generic_12_byte( GLint rop, const void * ptr )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+
+ emit_header(gc->pc, rop, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), ptr, 12);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+static FASTCALL NOINLINE void
+generic_16_byte( GLint rop, const void * ptr )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+
+ emit_header(gc->pc, rop, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), ptr, 16);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+static FASTCALL NOINLINE void
+generic_24_byte( GLint rop, const void * ptr )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+
+ emit_header(gc->pc, rop, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), ptr, 24);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+static FASTCALL NOINLINE void
+generic_32_byte( GLint rop, const void * ptr )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 36;
+
+ emit_header(gc->pc, rop, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), ptr, 32);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLsop_NewList 101
+void
+__indirect_glNewList(GLuint list, GLenum mode)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxNewList(c, gc->currentContextTag, list, mode);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_NewList, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&list), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&mode), 4);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_EndList 102
+void
+__indirect_glEndList(void)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 0;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxEndList(c, gc->currentContextTag);
+#else
+ (void) __glXSetupSingleRequest(gc, X_GLsop_EndList, cmdlen);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLrop_CallList 1
+void
+__indirect_glCallList(GLuint list)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_CallList, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&list), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_CallLists 2
+void
+__indirect_glCallLists(GLsizei n, GLenum type, const GLvoid * lists)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glCallLists_size(type);
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * n));
+ if (__builtin_expect((n >= 0) && (gc->currentDpy != NULL), 1)) {
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ if ( (gc->pc + cmdlen) > gc->bufEnd ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ emit_header(gc->pc, X_GLrop_CallLists, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&type), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(lists), (compsize * n));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+ else {
+ const GLint op = X_GLrop_CallLists;
+ const GLuint cmdlenLarge = cmdlen + 4;
+ GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
+ (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&op), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&n), 4);
+ (void) memcpy((void *)(pc + 12), (void *)(&type), 4);
+ __glXSendLargeCommand(gc, pc, 16, lists, (compsize * n));
+ }
+ }
+}
+
+#define X_GLsop_DeleteLists 103
+void
+__indirect_glDeleteLists(GLuint list, GLsizei range)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxDeleteLists(c, gc->currentContextTag, list, range);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_DeleteLists, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&list), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&range), 4);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GenLists 104
+GLuint
+__indirect_glGenLists(GLsizei range)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ GLuint retval = (GLuint) 0;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGenListsRep *reply = XCBGlxGenListsReply(c, XCBGlxGenLists(c, gc->currentContextTag, range), NULL);
+ retval = reply->ret_val;
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GenLists, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&range), 4);
+ retval = (GLuint) __glXReadReply(dpy, 0, NULL, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return retval;
+}
+
+#define X_GLrop_ListBase 3
+void
+__indirect_glListBase(GLuint base)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_ListBase, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&base), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Begin 4
+void
+__indirect_glBegin(GLenum mode)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_Begin, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&mode), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Bitmap 5
+void
+__indirect_glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = (bitmap != NULL) ? __glImageSize(width, height, 1, GL_COLOR_INDEX, GL_BITMAP, 0) : 0;
+ const GLuint cmdlen = 48 + __GLX_PAD(compsize);
+ if (__builtin_expect(gc->currentDpy != NULL, 1)) {
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ if ( (gc->pc + cmdlen) > gc->bufEnd ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ emit_header(gc->pc, X_GLrop_Bitmap, cmdlen);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&height), 4);
+ (void) memcpy((void *)(gc->pc + 32), (void *)(&xorig), 4);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&yorig), 4);
+ (void) memcpy((void *)(gc->pc + 40), (void *)(&xmove), 4);
+ (void) memcpy((void *)(gc->pc + 44), (void *)(&ymove), 4);
+ if (compsize > 0) {
+ (*gc->fillImage)(gc, 2, width, height, 1, GL_COLOR_INDEX, GL_BITMAP, bitmap, gc->pc + 48, gc->pc + 4);
+ }
+ else {
+ (void) memcpy( gc->pc + 4, default_pixel_store_2D, default_pixel_store_2D_size );
+ }
+ gc->pc += cmdlen;
+ if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+ else {
+ const GLint op = X_GLrop_Bitmap;
+ const GLuint cmdlenLarge = cmdlen + 4;
+ GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
+ (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&op), 4);
+ (void) memcpy((void *)(pc + 28), (void *)(&width), 4);
+ (void) memcpy((void *)(pc + 32), (void *)(&height), 4);
+ (void) memcpy((void *)(pc + 36), (void *)(&xorig), 4);
+ (void) memcpy((void *)(pc + 40), (void *)(&yorig), 4);
+ (void) memcpy((void *)(pc + 44), (void *)(&xmove), 4);
+ (void) memcpy((void *)(pc + 48), (void *)(&ymove), 4);
+ __glXSendLargeImage(gc, compsize, 2, width, height, 1, GL_COLOR_INDEX, GL_BITMAP, bitmap, pc + 52, pc + 8);
+ }
+ }
+}
+
+#define X_GLrop_Color3bv 6
+void
+__indirect_glColor3b(GLbyte red, GLbyte green, GLbyte blue)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_Color3bv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 1);
+ (void) memcpy((void *)(gc->pc + 5), (void *)(&green), 1);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&blue), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Color3bv 6
+void
+__indirect_glColor3bv(const GLbyte * v)
+{
+ generic_3_byte( X_GLrop_Color3bv, v );
+}
+
+#define X_GLrop_Color3dv 7
+void
+__indirect_glColor3d(GLdouble red, GLdouble green, GLdouble blue)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_Color3dv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&green), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&blue), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Color3dv 7
+void
+__indirect_glColor3dv(const GLdouble * v)
+{
+ generic_24_byte( X_GLrop_Color3dv, v );
+}
+
+#define X_GLrop_Color3fv 8
+void
+__indirect_glColor3f(GLfloat red, GLfloat green, GLfloat blue)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_Color3fv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&green), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&blue), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Color3fv 8
+void
+__indirect_glColor3fv(const GLfloat * v)
+{
+ generic_12_byte( X_GLrop_Color3fv, v );
+}
+
+#define X_GLrop_Color3iv 9
+void
+__indirect_glColor3i(GLint red, GLint green, GLint blue)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_Color3iv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&green), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&blue), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Color3iv 9
+void
+__indirect_glColor3iv(const GLint * v)
+{
+ generic_12_byte( X_GLrop_Color3iv, v );
+}
+
+#define X_GLrop_Color3sv 10
+void
+__indirect_glColor3s(GLshort red, GLshort green, GLshort blue)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_Color3sv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 2);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&green), 2);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&blue), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Color3sv 10
+void
+__indirect_glColor3sv(const GLshort * v)
+{
+ generic_6_byte( X_GLrop_Color3sv, v );
+}
+
+#define X_GLrop_Color3ubv 11
+void
+__indirect_glColor3ub(GLubyte red, GLubyte green, GLubyte blue)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_Color3ubv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 1);
+ (void) memcpy((void *)(gc->pc + 5), (void *)(&green), 1);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&blue), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Color3ubv 11
+void
+__indirect_glColor3ubv(const GLubyte * v)
+{
+ generic_3_byte( X_GLrop_Color3ubv, v );
+}
+
+#define X_GLrop_Color3uiv 12
+void
+__indirect_glColor3ui(GLuint red, GLuint green, GLuint blue)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_Color3uiv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&green), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&blue), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Color3uiv 12
+void
+__indirect_glColor3uiv(const GLuint * v)
+{
+ generic_12_byte( X_GLrop_Color3uiv, v );
+}
+
+#define X_GLrop_Color3usv 13
+void
+__indirect_glColor3us(GLushort red, GLushort green, GLushort blue)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_Color3usv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 2);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&green), 2);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&blue), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Color3usv 13
+void
+__indirect_glColor3usv(const GLushort * v)
+{
+ generic_6_byte( X_GLrop_Color3usv, v );
+}
+
+#define X_GLrop_Color4bv 14
+void
+__indirect_glColor4b(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_Color4bv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 1);
+ (void) memcpy((void *)(gc->pc + 5), (void *)(&green), 1);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&blue), 1);
+ (void) memcpy((void *)(gc->pc + 7), (void *)(&alpha), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Color4bv 14
+void
+__indirect_glColor4bv(const GLbyte * v)
+{
+ generic_4_byte( X_GLrop_Color4bv, v );
+}
+
+#define X_GLrop_Color4dv 15
+void
+__indirect_glColor4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 36;
+ emit_header(gc->pc, X_GLrop_Color4dv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&green), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&blue), 8);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&alpha), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Color4dv 15
+void
+__indirect_glColor4dv(const GLdouble * v)
+{
+ generic_32_byte( X_GLrop_Color4dv, v );
+}
+
+#define X_GLrop_Color4fv 16
+void
+__indirect_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_Color4fv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&green), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&blue), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&alpha), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Color4fv 16
+void
+__indirect_glColor4fv(const GLfloat * v)
+{
+ generic_16_byte( X_GLrop_Color4fv, v );
+}
+
+#define X_GLrop_Color4iv 17
+void
+__indirect_glColor4i(GLint red, GLint green, GLint blue, GLint alpha)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_Color4iv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&green), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&blue), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&alpha), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Color4iv 17
+void
+__indirect_glColor4iv(const GLint * v)
+{
+ generic_16_byte( X_GLrop_Color4iv, v );
+}
+
+#define X_GLrop_Color4sv 18
+void
+__indirect_glColor4s(GLshort red, GLshort green, GLshort blue, GLshort alpha)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_Color4sv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 2);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&green), 2);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&blue), 2);
+ (void) memcpy((void *)(gc->pc + 10), (void *)(&alpha), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Color4sv 18
+void
+__indirect_glColor4sv(const GLshort * v)
+{
+ generic_8_byte( X_GLrop_Color4sv, v );
+}
+
+#define X_GLrop_Color4ubv 19
+void
+__indirect_glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_Color4ubv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 1);
+ (void) memcpy((void *)(gc->pc + 5), (void *)(&green), 1);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&blue), 1);
+ (void) memcpy((void *)(gc->pc + 7), (void *)(&alpha), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Color4ubv 19
+void
+__indirect_glColor4ubv(const GLubyte * v)
+{
+ generic_4_byte( X_GLrop_Color4ubv, v );
+}
+
+#define X_GLrop_Color4uiv 20
+void
+__indirect_glColor4ui(GLuint red, GLuint green, GLuint blue, GLuint alpha)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_Color4uiv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&green), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&blue), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&alpha), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Color4uiv 20
+void
+__indirect_glColor4uiv(const GLuint * v)
+{
+ generic_16_byte( X_GLrop_Color4uiv, v );
+}
+
+#define X_GLrop_Color4usv 21
+void
+__indirect_glColor4us(GLushort red, GLushort green, GLushort blue, GLushort alpha)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_Color4usv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 2);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&green), 2);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&blue), 2);
+ (void) memcpy((void *)(gc->pc + 10), (void *)(&alpha), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Color4usv 21
+void
+__indirect_glColor4usv(const GLushort * v)
+{
+ generic_8_byte( X_GLrop_Color4usv, v );
+}
+
+#define X_GLrop_EdgeFlagv 22
+void
+__indirect_glEdgeFlag(GLboolean flag)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_EdgeFlagv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&flag), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_EdgeFlagv 22
+void
+__indirect_glEdgeFlagv(const GLboolean * flag)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_EdgeFlagv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(flag), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_End 23
+void
+__indirect_glEnd(void)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 4;
+ emit_header(gc->pc, X_GLrop_End, cmdlen);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Indexdv 24
+void
+__indirect_glIndexd(GLdouble c)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_Indexdv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&c), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Indexdv 24
+void
+__indirect_glIndexdv(const GLdouble * c)
+{
+ generic_8_byte( X_GLrop_Indexdv, c );
+}
+
+#define X_GLrop_Indexfv 25
+void
+__indirect_glIndexf(GLfloat c)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_Indexfv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&c), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Indexfv 25
+void
+__indirect_glIndexfv(const GLfloat * c)
+{
+ generic_4_byte( X_GLrop_Indexfv, c );
+}
+
+#define X_GLrop_Indexiv 26
+void
+__indirect_glIndexi(GLint c)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_Indexiv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&c), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Indexiv 26
+void
+__indirect_glIndexiv(const GLint * c)
+{
+ generic_4_byte( X_GLrop_Indexiv, c );
+}
+
+#define X_GLrop_Indexsv 27
+void
+__indirect_glIndexs(GLshort c)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_Indexsv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&c), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Indexsv 27
+void
+__indirect_glIndexsv(const GLshort * c)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_Indexsv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(c), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Normal3bv 28
+void
+__indirect_glNormal3b(GLbyte nx, GLbyte ny, GLbyte nz)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_Normal3bv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&nx), 1);
+ (void) memcpy((void *)(gc->pc + 5), (void *)(&ny), 1);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&nz), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Normal3bv 28
+void
+__indirect_glNormal3bv(const GLbyte * v)
+{
+ generic_3_byte( X_GLrop_Normal3bv, v );
+}
+
+#define X_GLrop_Normal3dv 29
+void
+__indirect_glNormal3d(GLdouble nx, GLdouble ny, GLdouble nz)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_Normal3dv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&nx), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&ny), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&nz), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Normal3dv 29
+void
+__indirect_glNormal3dv(const GLdouble * v)
+{
+ generic_24_byte( X_GLrop_Normal3dv, v );
+}
+
+#define X_GLrop_Normal3fv 30
+void
+__indirect_glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_Normal3fv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&nx), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&ny), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&nz), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Normal3fv 30
+void
+__indirect_glNormal3fv(const GLfloat * v)
+{
+ generic_12_byte( X_GLrop_Normal3fv, v );
+}
+
+#define X_GLrop_Normal3iv 31
+void
+__indirect_glNormal3i(GLint nx, GLint ny, GLint nz)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_Normal3iv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&nx), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&ny), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&nz), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Normal3iv 31
+void
+__indirect_glNormal3iv(const GLint * v)
+{
+ generic_12_byte( X_GLrop_Normal3iv, v );
+}
+
+#define X_GLrop_Normal3sv 32
+void
+__indirect_glNormal3s(GLshort nx, GLshort ny, GLshort nz)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_Normal3sv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&nx), 2);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&ny), 2);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&nz), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Normal3sv 32
+void
+__indirect_glNormal3sv(const GLshort * v)
+{
+ generic_6_byte( X_GLrop_Normal3sv, v );
+}
+
+#define X_GLrop_RasterPos2dv 33
+void
+__indirect_glRasterPos2d(GLdouble x, GLdouble y)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_RasterPos2dv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_RasterPos2dv 33
+void
+__indirect_glRasterPos2dv(const GLdouble * v)
+{
+ generic_16_byte( X_GLrop_RasterPos2dv, v );
+}
+
+#define X_GLrop_RasterPos2fv 34
+void
+__indirect_glRasterPos2f(GLfloat x, GLfloat y)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_RasterPos2fv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_RasterPos2fv 34
+void
+__indirect_glRasterPos2fv(const GLfloat * v)
+{
+ generic_8_byte( X_GLrop_RasterPos2fv, v );
+}
+
+#define X_GLrop_RasterPos2iv 35
+void
+__indirect_glRasterPos2i(GLint x, GLint y)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_RasterPos2iv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_RasterPos2iv 35
+void
+__indirect_glRasterPos2iv(const GLint * v)
+{
+ generic_8_byte( X_GLrop_RasterPos2iv, v );
+}
+
+#define X_GLrop_RasterPos2sv 36
+void
+__indirect_glRasterPos2s(GLshort x, GLshort y)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_RasterPos2sv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 2);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&y), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_RasterPos2sv 36
+void
+__indirect_glRasterPos2sv(const GLshort * v)
+{
+ generic_4_byte( X_GLrop_RasterPos2sv, v );
+}
+
+#define X_GLrop_RasterPos3dv 37
+void
+__indirect_glRasterPos3d(GLdouble x, GLdouble y, GLdouble z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_RasterPos3dv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&z), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_RasterPos3dv 37
+void
+__indirect_glRasterPos3dv(const GLdouble * v)
+{
+ generic_24_byte( X_GLrop_RasterPos3dv, v );
+}
+
+#define X_GLrop_RasterPos3fv 38
+void
+__indirect_glRasterPos3f(GLfloat x, GLfloat y, GLfloat z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_RasterPos3fv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&z), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_RasterPos3fv 38
+void
+__indirect_glRasterPos3fv(const GLfloat * v)
+{
+ generic_12_byte( X_GLrop_RasterPos3fv, v );
+}
+
+#define X_GLrop_RasterPos3iv 39
+void
+__indirect_glRasterPos3i(GLint x, GLint y, GLint z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_RasterPos3iv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&z), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_RasterPos3iv 39
+void
+__indirect_glRasterPos3iv(const GLint * v)
+{
+ generic_12_byte( X_GLrop_RasterPos3iv, v );
+}
+
+#define X_GLrop_RasterPos3sv 40
+void
+__indirect_glRasterPos3s(GLshort x, GLshort y, GLshort z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_RasterPos3sv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 2);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&y), 2);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&z), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_RasterPos3sv 40
+void
+__indirect_glRasterPos3sv(const GLshort * v)
+{
+ generic_6_byte( X_GLrop_RasterPos3sv, v );
+}
+
+#define X_GLrop_RasterPos4dv 41
+void
+__indirect_glRasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 36;
+ emit_header(gc->pc, X_GLrop_RasterPos4dv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&z), 8);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&w), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_RasterPos4dv 41
+void
+__indirect_glRasterPos4dv(const GLdouble * v)
+{
+ generic_32_byte( X_GLrop_RasterPos4dv, v );
+}
+
+#define X_GLrop_RasterPos4fv 42
+void
+__indirect_glRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_RasterPos4fv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&z), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&w), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_RasterPos4fv 42
+void
+__indirect_glRasterPos4fv(const GLfloat * v)
+{
+ generic_16_byte( X_GLrop_RasterPos4fv, v );
+}
+
+#define X_GLrop_RasterPos4iv 43
+void
+__indirect_glRasterPos4i(GLint x, GLint y, GLint z, GLint w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_RasterPos4iv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&z), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&w), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_RasterPos4iv 43
+void
+__indirect_glRasterPos4iv(const GLint * v)
+{
+ generic_16_byte( X_GLrop_RasterPos4iv, v );
+}
+
+#define X_GLrop_RasterPos4sv 44
+void
+__indirect_glRasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_RasterPos4sv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 2);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&y), 2);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&z), 2);
+ (void) memcpy((void *)(gc->pc + 10), (void *)(&w), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_RasterPos4sv 44
+void
+__indirect_glRasterPos4sv(const GLshort * v)
+{
+ generic_8_byte( X_GLrop_RasterPos4sv, v );
+}
+
+#define X_GLrop_Rectdv 45
+void
+__indirect_glRectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 36;
+ emit_header(gc->pc, X_GLrop_Rectdv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x1), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y1), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&x2), 8);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&y2), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Rectdv 45
+void
+__indirect_glRectdv(const GLdouble * v1, const GLdouble * v2)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 36;
+ emit_header(gc->pc, X_GLrop_Rectdv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(v1), 16);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(v2), 16);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Rectfv 46
+void
+__indirect_glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_Rectfv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x1), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y1), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&x2), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&y2), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Rectfv 46
+void
+__indirect_glRectfv(const GLfloat * v1, const GLfloat * v2)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_Rectfv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(v1), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(v2), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Rectiv 47
+void
+__indirect_glRecti(GLint x1, GLint y1, GLint x2, GLint y2)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_Rectiv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x1), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y1), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&x2), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&y2), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Rectiv 47
+void
+__indirect_glRectiv(const GLint * v1, const GLint * v2)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_Rectiv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(v1), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(v2), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Rectsv 48
+void
+__indirect_glRects(GLshort x1, GLshort y1, GLshort x2, GLshort y2)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_Rectsv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x1), 2);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&y1), 2);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x2), 2);
+ (void) memcpy((void *)(gc->pc + 10), (void *)(&y2), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Rectsv 48
+void
+__indirect_glRectsv(const GLshort * v1, const GLshort * v2)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_Rectsv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(v1), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v2), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord1dv 49
+void
+__indirect_glTexCoord1d(GLdouble s)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_TexCoord1dv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord1dv 49
+void
+__indirect_glTexCoord1dv(const GLdouble * v)
+{
+ generic_8_byte( X_GLrop_TexCoord1dv, v );
+}
+
+#define X_GLrop_TexCoord1fv 50
+void
+__indirect_glTexCoord1f(GLfloat s)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_TexCoord1fv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord1fv 50
+void
+__indirect_glTexCoord1fv(const GLfloat * v)
+{
+ generic_4_byte( X_GLrop_TexCoord1fv, v );
+}
+
+#define X_GLrop_TexCoord1iv 51
+void
+__indirect_glTexCoord1i(GLint s)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_TexCoord1iv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord1iv 51
+void
+__indirect_glTexCoord1iv(const GLint * v)
+{
+ generic_4_byte( X_GLrop_TexCoord1iv, v );
+}
+
+#define X_GLrop_TexCoord1sv 52
+void
+__indirect_glTexCoord1s(GLshort s)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_TexCoord1sv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord1sv 52
+void
+__indirect_glTexCoord1sv(const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_TexCoord1sv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(v), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord2dv 53
+void
+__indirect_glTexCoord2d(GLdouble s, GLdouble t)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_TexCoord2dv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&t), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord2dv 53
+void
+__indirect_glTexCoord2dv(const GLdouble * v)
+{
+ generic_16_byte( X_GLrop_TexCoord2dv, v );
+}
+
+#define X_GLrop_TexCoord2fv 54
+void
+__indirect_glTexCoord2f(GLfloat s, GLfloat t)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_TexCoord2fv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&t), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord2fv 54
+void
+__indirect_glTexCoord2fv(const GLfloat * v)
+{
+ generic_8_byte( X_GLrop_TexCoord2fv, v );
+}
+
+#define X_GLrop_TexCoord2iv 55
+void
+__indirect_glTexCoord2i(GLint s, GLint t)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_TexCoord2iv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&t), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord2iv 55
+void
+__indirect_glTexCoord2iv(const GLint * v)
+{
+ generic_8_byte( X_GLrop_TexCoord2iv, v );
+}
+
+#define X_GLrop_TexCoord2sv 56
+void
+__indirect_glTexCoord2s(GLshort s, GLshort t)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_TexCoord2sv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 2);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&t), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord2sv 56
+void
+__indirect_glTexCoord2sv(const GLshort * v)
+{
+ generic_4_byte( X_GLrop_TexCoord2sv, v );
+}
+
+#define X_GLrop_TexCoord3dv 57
+void
+__indirect_glTexCoord3d(GLdouble s, GLdouble t, GLdouble r)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_TexCoord3dv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&t), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&r), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord3dv 57
+void
+__indirect_glTexCoord3dv(const GLdouble * v)
+{
+ generic_24_byte( X_GLrop_TexCoord3dv, v );
+}
+
+#define X_GLrop_TexCoord3fv 58
+void
+__indirect_glTexCoord3f(GLfloat s, GLfloat t, GLfloat r)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_TexCoord3fv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&t), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&r), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord3fv 58
+void
+__indirect_glTexCoord3fv(const GLfloat * v)
+{
+ generic_12_byte( X_GLrop_TexCoord3fv, v );
+}
+
+#define X_GLrop_TexCoord3iv 59
+void
+__indirect_glTexCoord3i(GLint s, GLint t, GLint r)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_TexCoord3iv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&t), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&r), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord3iv 59
+void
+__indirect_glTexCoord3iv(const GLint * v)
+{
+ generic_12_byte( X_GLrop_TexCoord3iv, v );
+}
+
+#define X_GLrop_TexCoord3sv 60
+void
+__indirect_glTexCoord3s(GLshort s, GLshort t, GLshort r)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_TexCoord3sv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 2);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&t), 2);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&r), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord3sv 60
+void
+__indirect_glTexCoord3sv(const GLshort * v)
+{
+ generic_6_byte( X_GLrop_TexCoord3sv, v );
+}
+
+#define X_GLrop_TexCoord4dv 61
+void
+__indirect_glTexCoord4d(GLdouble s, GLdouble t, GLdouble r, GLdouble q)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 36;
+ emit_header(gc->pc, X_GLrop_TexCoord4dv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&t), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&r), 8);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&q), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord4dv 61
+void
+__indirect_glTexCoord4dv(const GLdouble * v)
+{
+ generic_32_byte( X_GLrop_TexCoord4dv, v );
+}
+
+#define X_GLrop_TexCoord4fv 62
+void
+__indirect_glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_TexCoord4fv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&t), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&r), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&q), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord4fv 62
+void
+__indirect_glTexCoord4fv(const GLfloat * v)
+{
+ generic_16_byte( X_GLrop_TexCoord4fv, v );
+}
+
+#define X_GLrop_TexCoord4iv 63
+void
+__indirect_glTexCoord4i(GLint s, GLint t, GLint r, GLint q)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_TexCoord4iv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&t), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&r), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&q), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord4iv 63
+void
+__indirect_glTexCoord4iv(const GLint * v)
+{
+ generic_16_byte( X_GLrop_TexCoord4iv, v );
+}
+
+#define X_GLrop_TexCoord4sv 64
+void
+__indirect_glTexCoord4s(GLshort s, GLshort t, GLshort r, GLshort q)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_TexCoord4sv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 2);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&t), 2);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&r), 2);
+ (void) memcpy((void *)(gc->pc + 10), (void *)(&q), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexCoord4sv 64
+void
+__indirect_glTexCoord4sv(const GLshort * v)
+{
+ generic_8_byte( X_GLrop_TexCoord4sv, v );
+}
+
+#define X_GLrop_Vertex2dv 65
+void
+__indirect_glVertex2d(GLdouble x, GLdouble y)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_Vertex2dv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Vertex2dv 65
+void
+__indirect_glVertex2dv(const GLdouble * v)
+{
+ generic_16_byte( X_GLrop_Vertex2dv, v );
+}
+
+#define X_GLrop_Vertex2fv 66
+void
+__indirect_glVertex2f(GLfloat x, GLfloat y)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_Vertex2fv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Vertex2fv 66
+void
+__indirect_glVertex2fv(const GLfloat * v)
+{
+ generic_8_byte( X_GLrop_Vertex2fv, v );
+}
+
+#define X_GLrop_Vertex2iv 67
+void
+__indirect_glVertex2i(GLint x, GLint y)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_Vertex2iv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Vertex2iv 67
+void
+__indirect_glVertex2iv(const GLint * v)
+{
+ generic_8_byte( X_GLrop_Vertex2iv, v );
+}
+
+#define X_GLrop_Vertex2sv 68
+void
+__indirect_glVertex2s(GLshort x, GLshort y)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_Vertex2sv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 2);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&y), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Vertex2sv 68
+void
+__indirect_glVertex2sv(const GLshort * v)
+{
+ generic_4_byte( X_GLrop_Vertex2sv, v );
+}
+
+#define X_GLrop_Vertex3dv 69
+void
+__indirect_glVertex3d(GLdouble x, GLdouble y, GLdouble z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_Vertex3dv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&z), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Vertex3dv 69
+void
+__indirect_glVertex3dv(const GLdouble * v)
+{
+ generic_24_byte( X_GLrop_Vertex3dv, v );
+}
+
+#define X_GLrop_Vertex3fv 70
+void
+__indirect_glVertex3f(GLfloat x, GLfloat y, GLfloat z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_Vertex3fv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&z), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Vertex3fv 70
+void
+__indirect_glVertex3fv(const GLfloat * v)
+{
+ generic_12_byte( X_GLrop_Vertex3fv, v );
+}
+
+#define X_GLrop_Vertex3iv 71
+void
+__indirect_glVertex3i(GLint x, GLint y, GLint z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_Vertex3iv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&z), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Vertex3iv 71
+void
+__indirect_glVertex3iv(const GLint * v)
+{
+ generic_12_byte( X_GLrop_Vertex3iv, v );
+}
+
+#define X_GLrop_Vertex3sv 72
+void
+__indirect_glVertex3s(GLshort x, GLshort y, GLshort z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_Vertex3sv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 2);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&y), 2);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&z), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Vertex3sv 72
+void
+__indirect_glVertex3sv(const GLshort * v)
+{
+ generic_6_byte( X_GLrop_Vertex3sv, v );
+}
+
+#define X_GLrop_Vertex4dv 73
+void
+__indirect_glVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 36;
+ emit_header(gc->pc, X_GLrop_Vertex4dv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&z), 8);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&w), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Vertex4dv 73
+void
+__indirect_glVertex4dv(const GLdouble * v)
+{
+ generic_32_byte( X_GLrop_Vertex4dv, v );
+}
+
+#define X_GLrop_Vertex4fv 74
+void
+__indirect_glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_Vertex4fv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&z), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&w), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Vertex4fv 74
+void
+__indirect_glVertex4fv(const GLfloat * v)
+{
+ generic_16_byte( X_GLrop_Vertex4fv, v );
+}
+
+#define X_GLrop_Vertex4iv 75
+void
+__indirect_glVertex4i(GLint x, GLint y, GLint z, GLint w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_Vertex4iv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&z), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&w), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Vertex4iv 75
+void
+__indirect_glVertex4iv(const GLint * v)
+{
+ generic_16_byte( X_GLrop_Vertex4iv, v );
+}
+
+#define X_GLrop_Vertex4sv 76
+void
+__indirect_glVertex4s(GLshort x, GLshort y, GLshort z, GLshort w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_Vertex4sv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 2);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&y), 2);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&z), 2);
+ (void) memcpy((void *)(gc->pc + 10), (void *)(&w), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Vertex4sv 76
+void
+__indirect_glVertex4sv(const GLshort * v)
+{
+ generic_8_byte( X_GLrop_Vertex4sv, v );
+}
+
+#define X_GLrop_ClipPlane 77
+void
+__indirect_glClipPlane(GLenum plane, const GLdouble * equation)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 40;
+ emit_header(gc->pc, X_GLrop_ClipPlane, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(equation), 32);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&plane), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ColorMaterial 78
+void
+__indirect_glColorMaterial(GLenum face, GLenum mode)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_ColorMaterial, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&face), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&mode), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_CullFace 79
+void
+__indirect_glCullFace(GLenum mode)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_CullFace, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&mode), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Fogf 80
+void
+__indirect_glFogf(GLenum pname, GLfloat param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_Fogf, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Fogfv 81
+void
+__indirect_glFogfv(GLenum pname, const GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glFogfv_size(pname);
+ const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_Fogfv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Fogi 82
+void
+__indirect_glFogi(GLenum pname, GLint param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_Fogi, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Fogiv 83
+void
+__indirect_glFogiv(GLenum pname, const GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glFogiv_size(pname);
+ const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_Fogiv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_FrontFace 84
+void
+__indirect_glFrontFace(GLenum mode)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_FrontFace, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&mode), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Hint 85
+void
+__indirect_glHint(GLenum target, GLenum mode)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_Hint, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&mode), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Lightf 86
+void
+__indirect_glLightf(GLenum light, GLenum pname, GLfloat param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_Lightf, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&light), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Lightfv 87
+void
+__indirect_glLightfv(GLenum light, GLenum pname, const GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glLightfv_size(pname);
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_Lightfv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&light), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Lighti 88
+void
+__indirect_glLighti(GLenum light, GLenum pname, GLint param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_Lighti, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&light), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Lightiv 89
+void
+__indirect_glLightiv(GLenum light, GLenum pname, const GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glLightiv_size(pname);
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_Lightiv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&light), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_LightModelf 90
+void
+__indirect_glLightModelf(GLenum pname, GLfloat param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_LightModelf, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_LightModelfv 91
+void
+__indirect_glLightModelfv(GLenum pname, const GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glLightModelfv_size(pname);
+ const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_LightModelfv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_LightModeli 92
+void
+__indirect_glLightModeli(GLenum pname, GLint param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_LightModeli, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_LightModeliv 93
+void
+__indirect_glLightModeliv(GLenum pname, const GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glLightModeliv_size(pname);
+ const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_LightModeliv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_LineStipple 94
+void
+__indirect_glLineStipple(GLint factor, GLushort pattern)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_LineStipple, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&factor), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pattern), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_LineWidth 95
+void
+__indirect_glLineWidth(GLfloat width)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_LineWidth, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&width), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Materialf 96
+void
+__indirect_glMaterialf(GLenum face, GLenum pname, GLfloat param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_Materialf, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&face), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Materialfv 97
+void
+__indirect_glMaterialfv(GLenum face, GLenum pname, const GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glMaterialfv_size(pname);
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_Materialfv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&face), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Materiali 98
+void
+__indirect_glMateriali(GLenum face, GLenum pname, GLint param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_Materiali, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&face), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Materialiv 99
+void
+__indirect_glMaterialiv(GLenum face, GLenum pname, const GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glMaterialiv_size(pname);
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_Materialiv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&face), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PointSize 100
+void
+__indirect_glPointSize(GLfloat size)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_PointSize, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&size), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PolygonMode 101
+void
+__indirect_glPolygonMode(GLenum face, GLenum mode)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_PolygonMode, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&face), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&mode), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PolygonStipple 102
+void
+__indirect_glPolygonStipple(const GLubyte * mask)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = (mask != NULL) ? __glImageSize(32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, 0) : 0;
+ const GLuint cmdlen = 24 + __GLX_PAD(compsize);
+ emit_header(gc->pc, X_GLrop_PolygonStipple, cmdlen);
+ if (compsize > 0) {
+ (*gc->fillImage)(gc, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, mask, gc->pc + 24, gc->pc + 4);
+ }
+ else {
+ (void) memcpy( gc->pc + 4, default_pixel_store_2D, default_pixel_store_2D_size );
+ }
+ gc->pc += cmdlen;
+ if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Scissor 103
+void
+__indirect_glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_Scissor, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&height), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ShadeModel 104
+void
+__indirect_glShadeModel(GLenum mode)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_ShadeModel, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&mode), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexParameterf 105
+void
+__indirect_glTexParameterf(GLenum target, GLenum pname, GLfloat param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_TexParameterf, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexParameterfv 106
+void
+__indirect_glTexParameterfv(GLenum target, GLenum pname, const GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glTexParameterfv_size(pname);
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_TexParameterfv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexParameteri 107
+void
+__indirect_glTexParameteri(GLenum target, GLenum pname, GLint param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_TexParameteri, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexParameteriv 108
+void
+__indirect_glTexParameteriv(GLenum target, GLenum pname, const GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glTexParameteriv_size(pname);
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_TexParameteriv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+static void
+__glx_TexImage_1D2D( unsigned opcode, unsigned dim, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glImageSize(width, height, 1, format, type, target);
+ const GLuint cmdlen = 56 + __GLX_PAD(compsize);
+ if (__builtin_expect(gc->currentDpy != NULL, 1)) {
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ if ( (gc->pc + cmdlen) > gc->bufEnd ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ emit_header(gc->pc, opcode, cmdlen);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&level), 4);
+ (void) memcpy((void *)(gc->pc + 32), (void *)(&internalformat), 4);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 40), (void *)(&height), 4);
+ (void) memcpy((void *)(gc->pc + 44), (void *)(&border), 4);
+ (void) memcpy((void *)(gc->pc + 48), (void *)(&format), 4);
+ (void) memcpy((void *)(gc->pc + 52), (void *)(&type), 4);
+ if ((compsize > 0) && (pixels != NULL)) {
+ (*gc->fillImage)(gc, dim, width, height, 1, format, type, pixels, gc->pc + 56, gc->pc + 4);
+ }
+ else {
+ (void) memcpy( gc->pc + 4, default_pixel_store_2D, default_pixel_store_2D_size );
+ }
+ gc->pc += cmdlen;
+ if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+ else {
+ const GLint op = opcode;
+ const GLuint cmdlenLarge = cmdlen + 4;
+ GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
+ (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&op), 4);
+ (void) memcpy((void *)(pc + 28), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 32), (void *)(&level), 4);
+ (void) memcpy((void *)(pc + 36), (void *)(&internalformat), 4);
+ (void) memcpy((void *)(pc + 40), (void *)(&width), 4);
+ (void) memcpy((void *)(pc + 44), (void *)(&height), 4);
+ (void) memcpy((void *)(pc + 48), (void *)(&border), 4);
+ (void) memcpy((void *)(pc + 52), (void *)(&format), 4);
+ (void) memcpy((void *)(pc + 56), (void *)(&type), 4);
+ __glXSendLargeImage(gc, compsize, dim, width, height, 1, format, type, pixels, pc + 60, pc + 8);
+ }
+ }
+}
+
+#define X_GLrop_TexImage1D 109
+void
+__indirect_glTexImage1D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ __glx_TexImage_1D2D(X_GLrop_TexImage1D, 1, target, level, internalformat, width, 1, border, format, type, pixels );
+}
+
+#define X_GLrop_TexImage2D 110
+void
+__indirect_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ __glx_TexImage_1D2D(X_GLrop_TexImage2D, 2, target, level, internalformat, width, height, border, format, type, pixels );
+}
+
+#define X_GLrop_TexEnvf 111
+void
+__indirect_glTexEnvf(GLenum target, GLenum pname, GLfloat param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_TexEnvf, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexEnvfv 112
+void
+__indirect_glTexEnvfv(GLenum target, GLenum pname, const GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glTexEnvfv_size(pname);
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_TexEnvfv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexEnvi 113
+void
+__indirect_glTexEnvi(GLenum target, GLenum pname, GLint param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_TexEnvi, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexEnviv 114
+void
+__indirect_glTexEnviv(GLenum target, GLenum pname, const GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glTexEnviv_size(pname);
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_TexEnviv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexGend 115
+void
+__indirect_glTexGend(GLenum coord, GLenum pname, GLdouble param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_TexGend, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&param), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&coord), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&pname), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexGendv 116
+void
+__indirect_glTexGendv(GLenum coord, GLenum pname, const GLdouble * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glTexGendv_size(pname);
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 8));
+ emit_header(gc->pc, X_GLrop_TexGendv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&coord), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), (compsize * 8));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexGenf 117
+void
+__indirect_glTexGenf(GLenum coord, GLenum pname, GLfloat param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_TexGenf, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&coord), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexGenfv 118
+void
+__indirect_glTexGenfv(GLenum coord, GLenum pname, const GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glTexGenfv_size(pname);
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_TexGenfv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&coord), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexGeni 119
+void
+__indirect_glTexGeni(GLenum coord, GLenum pname, GLint param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_TexGeni, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&coord), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_TexGeniv 120
+void
+__indirect_glTexGeniv(GLenum coord, GLenum pname, const GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glTexGeniv_size(pname);
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_TexGeniv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&coord), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_InitNames 121
+void
+__indirect_glInitNames(void)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 4;
+ emit_header(gc->pc, X_GLrop_InitNames, cmdlen);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_LoadName 122
+void
+__indirect_glLoadName(GLuint name)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_LoadName, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&name), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PassThrough 123
+void
+__indirect_glPassThrough(GLfloat token)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_PassThrough, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&token), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PopName 124
+void
+__indirect_glPopName(void)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 4;
+ emit_header(gc->pc, X_GLrop_PopName, cmdlen);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PushName 125
+void
+__indirect_glPushName(GLuint name)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_PushName, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&name), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_DrawBuffer 126
+void
+__indirect_glDrawBuffer(GLenum mode)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_DrawBuffer, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&mode), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Clear 127
+void
+__indirect_glClear(GLbitfield mask)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_Clear, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&mask), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ClearAccum 128
+void
+__indirect_glClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_ClearAccum, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&green), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&blue), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&alpha), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ClearIndex 129
+void
+__indirect_glClearIndex(GLfloat c)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_ClearIndex, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&c), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ClearColor 130
+void
+__indirect_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_ClearColor, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&green), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&blue), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&alpha), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ClearStencil 131
+void
+__indirect_glClearStencil(GLint s)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_ClearStencil, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ClearDepth 132
+void
+__indirect_glClearDepth(GLclampd depth)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_ClearDepth, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&depth), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_StencilMask 133
+void
+__indirect_glStencilMask(GLuint mask)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_StencilMask, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&mask), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ColorMask 134
+void
+__indirect_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_ColorMask, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 1);
+ (void) memcpy((void *)(gc->pc + 5), (void *)(&green), 1);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&blue), 1);
+ (void) memcpy((void *)(gc->pc + 7), (void *)(&alpha), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_DepthMask 135
+void
+__indirect_glDepthMask(GLboolean flag)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_DepthMask, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&flag), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_IndexMask 136
+void
+__indirect_glIndexMask(GLuint mask)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_IndexMask, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&mask), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Accum 137
+void
+__indirect_glAccum(GLenum op, GLfloat value)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_Accum, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&op), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&value), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PopAttrib 141
+void
+__indirect_glPopAttrib(void)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 4;
+ emit_header(gc->pc, X_GLrop_PopAttrib, cmdlen);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PushAttrib 142
+void
+__indirect_glPushAttrib(GLbitfield mask)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_PushAttrib, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&mask), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MapGrid1d 147
+void
+__indirect_glMapGrid1d(GLint un, GLdouble u1, GLdouble u2)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_MapGrid1d, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&u1), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&u2), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&un), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MapGrid1f 148
+void
+__indirect_glMapGrid1f(GLint un, GLfloat u1, GLfloat u2)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_MapGrid1f, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&un), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&u1), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&u2), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MapGrid2d 149
+void
+__indirect_glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 44;
+ emit_header(gc->pc, X_GLrop_MapGrid2d, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&u1), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&u2), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&v1), 8);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&v2), 8);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&un), 4);
+ (void) memcpy((void *)(gc->pc + 40), (void *)(&vn), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MapGrid2f 150
+void
+__indirect_glMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_MapGrid2f, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&un), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&u1), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&u2), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&vn), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&v1), 4);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&v2), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_EvalCoord1dv 151
+void
+__indirect_glEvalCoord1d(GLdouble u)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_EvalCoord1dv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&u), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_EvalCoord1dv 151
+void
+__indirect_glEvalCoord1dv(const GLdouble * u)
+{
+ generic_8_byte( X_GLrop_EvalCoord1dv, u );
+}
+
+#define X_GLrop_EvalCoord1fv 152
+void
+__indirect_glEvalCoord1f(GLfloat u)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_EvalCoord1fv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&u), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_EvalCoord1fv 152
+void
+__indirect_glEvalCoord1fv(const GLfloat * u)
+{
+ generic_4_byte( X_GLrop_EvalCoord1fv, u );
+}
+
+#define X_GLrop_EvalCoord2dv 153
+void
+__indirect_glEvalCoord2d(GLdouble u, GLdouble v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_EvalCoord2dv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&u), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&v), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_EvalCoord2dv 153
+void
+__indirect_glEvalCoord2dv(const GLdouble * u)
+{
+ generic_16_byte( X_GLrop_EvalCoord2dv, u );
+}
+
+#define X_GLrop_EvalCoord2fv 154
+void
+__indirect_glEvalCoord2f(GLfloat u, GLfloat v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_EvalCoord2fv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&u), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&v), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_EvalCoord2fv 154
+void
+__indirect_glEvalCoord2fv(const GLfloat * u)
+{
+ generic_8_byte( X_GLrop_EvalCoord2fv, u );
+}
+
+#define X_GLrop_EvalMesh1 155
+void
+__indirect_glEvalMesh1(GLenum mode, GLint i1, GLint i2)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_EvalMesh1, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&mode), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&i1), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&i2), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_EvalPoint1 156
+void
+__indirect_glEvalPoint1(GLint i)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_EvalPoint1, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&i), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_EvalMesh2 157
+void
+__indirect_glEvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_EvalMesh2, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&mode), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&i1), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&i2), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&j1), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&j2), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_EvalPoint2 158
+void
+__indirect_glEvalPoint2(GLint i, GLint j)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_EvalPoint2, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&i), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&j), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_AlphaFunc 159
+void
+__indirect_glAlphaFunc(GLenum func, GLclampf ref)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_AlphaFunc, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&func), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&ref), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_BlendFunc 160
+void
+__indirect_glBlendFunc(GLenum sfactor, GLenum dfactor)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_BlendFunc, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&sfactor), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&dfactor), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_LogicOp 161
+void
+__indirect_glLogicOp(GLenum opcode)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_LogicOp, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&opcode), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_StencilFunc 162
+void
+__indirect_glStencilFunc(GLenum func, GLint ref, GLuint mask)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_StencilFunc, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&func), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&ref), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&mask), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_StencilOp 163
+void
+__indirect_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_StencilOp, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&fail), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&zfail), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&zpass), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_DepthFunc 164
+void
+__indirect_glDepthFunc(GLenum func)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_DepthFunc, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&func), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PixelZoom 165
+void
+__indirect_glPixelZoom(GLfloat xfactor, GLfloat yfactor)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_PixelZoom, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&xfactor), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&yfactor), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PixelTransferf 166
+void
+__indirect_glPixelTransferf(GLenum pname, GLfloat param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_PixelTransferf, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PixelTransferi 167
+void
+__indirect_glPixelTransferi(GLenum pname, GLint param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_PixelTransferi, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PixelMapfv 168
+void
+__indirect_glPixelMapfv(GLenum map, GLsizei mapsize, const GLfloat * values)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12 + __GLX_PAD((mapsize * 4));
+ if (__builtin_expect((mapsize >= 0) && (gc->currentDpy != NULL), 1)) {
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ if ( (gc->pc + cmdlen) > gc->bufEnd ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ emit_header(gc->pc, X_GLrop_PixelMapfv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&map), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&mapsize), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(values), (mapsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+ else {
+ const GLint op = X_GLrop_PixelMapfv;
+ const GLuint cmdlenLarge = cmdlen + 4;
+ GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
+ (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&op), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&map), 4);
+ (void) memcpy((void *)(pc + 12), (void *)(&mapsize), 4);
+ __glXSendLargeCommand(gc, pc, 16, values, (mapsize * 4));
+ }
+ }
+}
+
+#define X_GLrop_PixelMapuiv 169
+void
+__indirect_glPixelMapuiv(GLenum map, GLsizei mapsize, const GLuint * values)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12 + __GLX_PAD((mapsize * 4));
+ if (__builtin_expect((mapsize >= 0) && (gc->currentDpy != NULL), 1)) {
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ if ( (gc->pc + cmdlen) > gc->bufEnd ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ emit_header(gc->pc, X_GLrop_PixelMapuiv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&map), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&mapsize), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(values), (mapsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+ else {
+ const GLint op = X_GLrop_PixelMapuiv;
+ const GLuint cmdlenLarge = cmdlen + 4;
+ GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
+ (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&op), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&map), 4);
+ (void) memcpy((void *)(pc + 12), (void *)(&mapsize), 4);
+ __glXSendLargeCommand(gc, pc, 16, values, (mapsize * 4));
+ }
+ }
+}
+
+#define X_GLrop_PixelMapusv 170
+void
+__indirect_glPixelMapusv(GLenum map, GLsizei mapsize, const GLushort * values)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12 + __GLX_PAD((mapsize * 2));
+ if (__builtin_expect((mapsize >= 0) && (gc->currentDpy != NULL), 1)) {
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ if ( (gc->pc + cmdlen) > gc->bufEnd ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ emit_header(gc->pc, X_GLrop_PixelMapusv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&map), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&mapsize), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(values), (mapsize * 2));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+ else {
+ const GLint op = X_GLrop_PixelMapusv;
+ const GLuint cmdlenLarge = cmdlen + 4;
+ GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
+ (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&op), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&map), 4);
+ (void) memcpy((void *)(pc + 12), (void *)(&mapsize), 4);
+ __glXSendLargeCommand(gc, pc, 16, values, (mapsize * 2));
+ }
+ }
+}
+
+#define X_GLrop_ReadBuffer 171
+void
+__indirect_glReadBuffer(GLenum mode)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_ReadBuffer, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&mode), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_CopyPixels 172
+void
+__indirect_glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_CopyPixels, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&height), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&type), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLsop_ReadPixels 111
+void
+__indirect_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * pixels)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const __GLXattribute * const state = gc->client_state_private;
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 28;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxReadPixelsRep *reply = XCBGlxReadPixelsReply(c, XCBGlxReadPixels(c, gc->currentContextTag, x, y, width, height, format, type, state->storePack.swapEndian, 0), NULL);
+ (void)memcpy(pixels, XCBGlxReadPixelsData(reply), XCBGlxReadPixelsDataLength(reply) * sizeof(GLvoid));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_ReadPixels, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&x), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&y), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&width), 4);
+ (void) memcpy((void *)(pc + 12), (void *)(&height), 4);
+ (void) memcpy((void *)(pc + 16), (void *)(&format), 4);
+ (void) memcpy((void *)(pc + 20), (void *)(&type), 4);
+ *(int32_t *)(pc + 24) = 0;
+ * (int8_t *)(pc + 24) = state->storePack.swapEndian;
+ __glXReadPixelReply(dpy, gc, 2, width, height, 1, format, type, pixels, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLrop_DrawPixels 173
+void
+__indirect_glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = (pixels != NULL) ? __glImageSize(width, height, 1, format, type, 0) : 0;
+ const GLuint cmdlen = 40 + __GLX_PAD(compsize);
+ if (__builtin_expect(gc->currentDpy != NULL, 1)) {
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ if ( (gc->pc + cmdlen) > gc->bufEnd ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ emit_header(gc->pc, X_GLrop_DrawPixels, cmdlen);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&height), 4);
+ (void) memcpy((void *)(gc->pc + 32), (void *)(&format), 4);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&type), 4);
+ if (compsize > 0) {
+ (*gc->fillImage)(gc, 2, width, height, 1, format, type, pixels, gc->pc + 40, gc->pc + 4);
+ }
+ else {
+ (void) memcpy( gc->pc + 4, default_pixel_store_2D, default_pixel_store_2D_size );
+ }
+ gc->pc += cmdlen;
+ if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+ else {
+ const GLint op = X_GLrop_DrawPixels;
+ const GLuint cmdlenLarge = cmdlen + 4;
+ GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
+ (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&op), 4);
+ (void) memcpy((void *)(pc + 28), (void *)(&width), 4);
+ (void) memcpy((void *)(pc + 32), (void *)(&height), 4);
+ (void) memcpy((void *)(pc + 36), (void *)(&format), 4);
+ (void) memcpy((void *)(pc + 40), (void *)(&type), 4);
+ __glXSendLargeImage(gc, compsize, 2, width, height, 1, format, type, pixels, pc + 44, pc + 8);
+ }
+ }
+}
+
+#define X_GLsop_GetClipPlane 113
+void
+__indirect_glGetClipPlane(GLenum plane, GLdouble * equation)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetClipPlaneRep *reply = XCBGlxGetClipPlaneReply(c, XCBGlxGetClipPlane(c, gc->currentContextTag, plane), NULL);
+ (void)memcpy(equation, XCBGlxGetClipPlaneData(reply), XCBGlxGetClipPlaneDataLength(reply) * sizeof(GLdouble));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetClipPlane, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&plane), 4);
+ (void) __glXReadReply(dpy, 8, equation, GL_TRUE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetLightfv 118
+void
+__indirect_glGetLightfv(GLenum light, GLenum pname, GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetLightfvRep *reply = XCBGlxGetLightfvReply(c, XCBGlxGetLightfv(c, gc->currentContextTag, light, pname), NULL);
+ if (XCBGlxGetLightfvDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetLightfvData(reply), XCBGlxGetLightfvDataLength(reply) * sizeof(GLfloat));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetLightfv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&light), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetLightiv 119
+void
+__indirect_glGetLightiv(GLenum light, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetLightivRep *reply = XCBGlxGetLightivReply(c, XCBGlxGetLightiv(c, gc->currentContextTag, light, pname), NULL);
+ if (XCBGlxGetLightivDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetLightivData(reply), XCBGlxGetLightivDataLength(reply) * sizeof(GLint));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetLightiv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&light), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetMapdv 120
+void
+__indirect_glGetMapdv(GLenum target, GLenum query, GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetMapdvRep *reply = XCBGlxGetMapdvReply(c, XCBGlxGetMapdv(c, gc->currentContextTag, target, query), NULL);
+ if (XCBGlxGetMapdvDataLength(reply) == 0)
+ (void)memcpy(v, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(v, XCBGlxGetMapdvData(reply), XCBGlxGetMapdvDataLength(reply) * sizeof(GLdouble));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetMapdv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&query), 4);
+ (void) __glXReadReply(dpy, 8, v, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetMapfv 121
+void
+__indirect_glGetMapfv(GLenum target, GLenum query, GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetMapfvRep *reply = XCBGlxGetMapfvReply(c, XCBGlxGetMapfv(c, gc->currentContextTag, target, query), NULL);
+ if (XCBGlxGetMapfvDataLength(reply) == 0)
+ (void)memcpy(v, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(v, XCBGlxGetMapfvData(reply), XCBGlxGetMapfvDataLength(reply) * sizeof(GLfloat));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetMapfv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&query), 4);
+ (void) __glXReadReply(dpy, 4, v, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetMapiv 122
+void
+__indirect_glGetMapiv(GLenum target, GLenum query, GLint * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetMapivRep *reply = XCBGlxGetMapivReply(c, XCBGlxGetMapiv(c, gc->currentContextTag, target, query), NULL);
+ if (XCBGlxGetMapivDataLength(reply) == 0)
+ (void)memcpy(v, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(v, XCBGlxGetMapivData(reply), XCBGlxGetMapivDataLength(reply) * sizeof(GLint));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetMapiv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&query), 4);
+ (void) __glXReadReply(dpy, 4, v, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetMaterialfv 123
+void
+__indirect_glGetMaterialfv(GLenum face, GLenum pname, GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetMaterialfvRep *reply = XCBGlxGetMaterialfvReply(c, XCBGlxGetMaterialfv(c, gc->currentContextTag, face, pname), NULL);
+ if (XCBGlxGetMaterialfvDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetMaterialfvData(reply), XCBGlxGetMaterialfvDataLength(reply) * sizeof(GLfloat));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetMaterialfv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&face), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetMaterialiv 124
+void
+__indirect_glGetMaterialiv(GLenum face, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetMaterialivRep *reply = XCBGlxGetMaterialivReply(c, XCBGlxGetMaterialiv(c, gc->currentContextTag, face, pname), NULL);
+ if (XCBGlxGetMaterialivDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetMaterialivData(reply), XCBGlxGetMaterialivDataLength(reply) * sizeof(GLint));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetMaterialiv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&face), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetPixelMapfv 125
+void
+__indirect_glGetPixelMapfv(GLenum map, GLfloat * values)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetPixelMapfvRep *reply = XCBGlxGetPixelMapfvReply(c, XCBGlxGetPixelMapfv(c, gc->currentContextTag, map), NULL);
+ if (XCBGlxGetPixelMapfvDataLength(reply) == 0)
+ (void)memcpy(values, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(values, XCBGlxGetPixelMapfvData(reply), XCBGlxGetPixelMapfvDataLength(reply) * sizeof(GLfloat));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetPixelMapfv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&map), 4);
+ (void) __glXReadReply(dpy, 4, values, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetPixelMapuiv 126
+void
+__indirect_glGetPixelMapuiv(GLenum map, GLuint * values)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetPixelMapuivRep *reply = XCBGlxGetPixelMapuivReply(c, XCBGlxGetPixelMapuiv(c, gc->currentContextTag, map), NULL);
+ if (XCBGlxGetPixelMapuivDataLength(reply) == 0)
+ (void)memcpy(values, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(values, XCBGlxGetPixelMapuivData(reply), XCBGlxGetPixelMapuivDataLength(reply) * sizeof(GLuint));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetPixelMapuiv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&map), 4);
+ (void) __glXReadReply(dpy, 4, values, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetPixelMapusv 127
+void
+__indirect_glGetPixelMapusv(GLenum map, GLushort * values)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetPixelMapusvRep *reply = XCBGlxGetPixelMapusvReply(c, XCBGlxGetPixelMapusv(c, gc->currentContextTag, map), NULL);
+ if (XCBGlxGetPixelMapusvDataLength(reply) == 0)
+ (void)memcpy(values, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(values, XCBGlxGetPixelMapusvData(reply), XCBGlxGetPixelMapusvDataLength(reply) * sizeof(GLushort));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetPixelMapusv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&map), 4);
+ (void) __glXReadReply(dpy, 2, values, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetPolygonStipple 128
+void
+__indirect_glGetPolygonStipple(GLubyte * mask)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const __GLXattribute * const state = gc->client_state_private;
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetPolygonStippleRep *reply = XCBGlxGetPolygonStippleReply(c, XCBGlxGetPolygonStipple(c, gc->currentContextTag, 0), NULL);
+ (void)memcpy(mask, XCBGlxGetPolygonStippleData(reply), XCBGlxGetPolygonStippleDataLength(reply) * sizeof(GLubyte));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetPolygonStipple, cmdlen);
+ *(int32_t *)(pc + 0) = 0;
+ __glXReadPixelReply(dpy, gc, 2, 32, 32, 1, GL_COLOR_INDEX, GL_BITMAP, mask, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetTexEnvfv 130
+void
+__indirect_glGetTexEnvfv(GLenum target, GLenum pname, GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetTexEnvfvRep *reply = XCBGlxGetTexEnvfvReply(c, XCBGlxGetTexEnvfv(c, gc->currentContextTag, target, pname), NULL);
+ if (XCBGlxGetTexEnvfvDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetTexEnvfvData(reply), XCBGlxGetTexEnvfvDataLength(reply) * sizeof(GLfloat));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetTexEnvfv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetTexEnviv 131
+void
+__indirect_glGetTexEnviv(GLenum target, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetTexEnvivRep *reply = XCBGlxGetTexEnvivReply(c, XCBGlxGetTexEnviv(c, gc->currentContextTag, target, pname), NULL);
+ if (XCBGlxGetTexEnvivDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetTexEnvivData(reply), XCBGlxGetTexEnvivDataLength(reply) * sizeof(GLint));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetTexEnviv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetTexGendv 132
+void
+__indirect_glGetTexGendv(GLenum coord, GLenum pname, GLdouble * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetTexGendvRep *reply = XCBGlxGetTexGendvReply(c, XCBGlxGetTexGendv(c, gc->currentContextTag, coord, pname), NULL);
+ if (XCBGlxGetTexGendvDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetTexGendvData(reply), XCBGlxGetTexGendvDataLength(reply) * sizeof(GLdouble));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetTexGendv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&coord), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 8, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetTexGenfv 133
+void
+__indirect_glGetTexGenfv(GLenum coord, GLenum pname, GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetTexGenfvRep *reply = XCBGlxGetTexGenfvReply(c, XCBGlxGetTexGenfv(c, gc->currentContextTag, coord, pname), NULL);
+ if (XCBGlxGetTexGenfvDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetTexGenfvData(reply), XCBGlxGetTexGenfvDataLength(reply) * sizeof(GLfloat));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetTexGenfv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&coord), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetTexGeniv 134
+void
+__indirect_glGetTexGeniv(GLenum coord, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetTexGenivRep *reply = XCBGlxGetTexGenivReply(c, XCBGlxGetTexGeniv(c, gc->currentContextTag, coord, pname), NULL);
+ if (XCBGlxGetTexGenivDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetTexGenivData(reply), XCBGlxGetTexGenivDataLength(reply) * sizeof(GLint));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetTexGeniv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&coord), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetTexImage 135
+void
+__indirect_glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid * pixels)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const __GLXattribute * const state = gc->client_state_private;
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 20;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetTexImageRep *reply = XCBGlxGetTexImageReply(c, XCBGlxGetTexImage(c, gc->currentContextTag, target, level, format, type, state->storePack.swapEndian), NULL);
+ (void)memcpy(pixels, XCBGlxGetTexImageData(reply), XCBGlxGetTexImageDataLength(reply) * sizeof(GLvoid));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetTexImage, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&level), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&format), 4);
+ (void) memcpy((void *)(pc + 12), (void *)(&type), 4);
+ *(int32_t *)(pc + 16) = 0;
+ * (int8_t *)(pc + 16) = state->storePack.swapEndian;
+ __glXReadPixelReply(dpy, gc, 3, 0, 0, 0, format, type, pixels, GL_TRUE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetTexParameterfv 136
+void
+__indirect_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetTexParameterfvRep *reply = XCBGlxGetTexParameterfvReply(c, XCBGlxGetTexParameterfv(c, gc->currentContextTag, target, pname), NULL);
+ if (XCBGlxGetTexParameterfvDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetTexParameterfvData(reply), XCBGlxGetTexParameterfvDataLength(reply) * sizeof(GLfloat));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetTexParameterfv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetTexParameteriv 137
+void
+__indirect_glGetTexParameteriv(GLenum target, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetTexParameterivRep *reply = XCBGlxGetTexParameterivReply(c, XCBGlxGetTexParameteriv(c, gc->currentContextTag, target, pname), NULL);
+ if (XCBGlxGetTexParameterivDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetTexParameterivData(reply), XCBGlxGetTexParameterivDataLength(reply) * sizeof(GLint));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetTexParameteriv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetTexLevelParameterfv 138
+void
+__indirect_glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 12;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetTexLevelParameterfvRep *reply = XCBGlxGetTexLevelParameterfvReply(c, XCBGlxGetTexLevelParameterfv(c, gc->currentContextTag, target, level, pname), NULL);
+ if (XCBGlxGetTexLevelParameterfvDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetTexLevelParameterfvData(reply), XCBGlxGetTexLevelParameterfvDataLength(reply) * sizeof(GLfloat));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetTexLevelParameterfv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&level), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetTexLevelParameteriv 139
+void
+__indirect_glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 12;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetTexLevelParameterivRep *reply = XCBGlxGetTexLevelParameterivReply(c, XCBGlxGetTexLevelParameteriv(c, gc->currentContextTag, target, level, pname), NULL);
+ if (XCBGlxGetTexLevelParameterivDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetTexLevelParameterivData(reply), XCBGlxGetTexLevelParameterivDataLength(reply) * sizeof(GLint));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetTexLevelParameteriv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&level), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_IsList 141
+GLboolean
+__indirect_glIsList(GLuint list)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ GLboolean retval = (GLboolean) 0;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxIsListRep *reply = XCBGlxIsListReply(c, XCBGlxIsList(c, gc->currentContextTag, list), NULL);
+ retval = reply->ret_val;
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_IsList, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&list), 4);
+ retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return retval;
+}
+
+#define X_GLrop_DepthRange 174
+void
+__indirect_glDepthRange(GLclampd zNear, GLclampd zFar)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_DepthRange, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&zNear), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&zFar), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Frustum 175
+void
+__indirect_glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 52;
+ emit_header(gc->pc, X_GLrop_Frustum, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&left), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&right), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&bottom), 8);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&top), 8);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&zNear), 8);
+ (void) memcpy((void *)(gc->pc + 44), (void *)(&zFar), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_LoadIdentity 176
+void
+__indirect_glLoadIdentity(void)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 4;
+ emit_header(gc->pc, X_GLrop_LoadIdentity, cmdlen);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_LoadMatrixf 177
+void
+__indirect_glLoadMatrixf(const GLfloat * m)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 68;
+ emit_header(gc->pc, X_GLrop_LoadMatrixf, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(m), 64);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_LoadMatrixd 178
+void
+__indirect_glLoadMatrixd(const GLdouble * m)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 132;
+ emit_header(gc->pc, X_GLrop_LoadMatrixd, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(m), 128);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MatrixMode 179
+void
+__indirect_glMatrixMode(GLenum mode)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_MatrixMode, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&mode), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultMatrixf 180
+void
+__indirect_glMultMatrixf(const GLfloat * m)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 68;
+ emit_header(gc->pc, X_GLrop_MultMatrixf, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(m), 64);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultMatrixd 181
+void
+__indirect_glMultMatrixd(const GLdouble * m)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 132;
+ emit_header(gc->pc, X_GLrop_MultMatrixd, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(m), 128);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Ortho 182
+void
+__indirect_glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 52;
+ emit_header(gc->pc, X_GLrop_Ortho, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&left), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&right), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&bottom), 8);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&top), 8);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&zNear), 8);
+ (void) memcpy((void *)(gc->pc + 44), (void *)(&zFar), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PopMatrix 183
+void
+__indirect_glPopMatrix(void)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 4;
+ emit_header(gc->pc, X_GLrop_PopMatrix, cmdlen);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PushMatrix 184
+void
+__indirect_glPushMatrix(void)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 4;
+ emit_header(gc->pc, X_GLrop_PushMatrix, cmdlen);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Rotated 185
+void
+__indirect_glRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 36;
+ emit_header(gc->pc, X_GLrop_Rotated, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&angle), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&y), 8);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&z), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Rotatef 186
+void
+__indirect_glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_Rotatef, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&angle), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&z), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Scaled 187
+void
+__indirect_glScaled(GLdouble x, GLdouble y, GLdouble z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_Scaled, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&z), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Scalef 188
+void
+__indirect_glScalef(GLfloat x, GLfloat y, GLfloat z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_Scalef, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&z), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Translated 189
+void
+__indirect_glTranslated(GLdouble x, GLdouble y, GLdouble z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_Translated, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&z), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Translatef 190
+void
+__indirect_glTranslatef(GLfloat x, GLfloat y, GLfloat z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_Translatef, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&z), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Viewport 191
+void
+__indirect_glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_Viewport, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&height), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_BindTexture 4117
+void
+__indirect_glBindTexture(GLenum target, GLuint texture)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_BindTexture, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&texture), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Indexubv 194
+void
+__indirect_glIndexub(GLubyte c)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_Indexubv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&c), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Indexubv 194
+void
+__indirect_glIndexubv(const GLubyte * c)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_Indexubv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(c), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PolygonOffset 192
+void
+__indirect_glPolygonOffset(GLfloat factor, GLfloat units)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_PolygonOffset, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&factor), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&units), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLsop_AreTexturesResident 143
+GLboolean
+__indirect_glAreTexturesResident(GLsizei n, const GLuint * textures, GLboolean * residences)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ GLboolean retval = (GLboolean) 0;
+ const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
+ if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxAreTexturesResidentRep *reply = XCBGlxAreTexturesResidentReply(c, XCBGlxAreTexturesResident(c, gc->currentContextTag, n, textures), NULL);
+ (void)memcpy(residences, XCBGlxAreTexturesResidentData(reply), XCBGlxAreTexturesResidentDataLength(reply) * sizeof(GLboolean));
+ retval = reply->ret_val;
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_AreTexturesResident, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&n), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(textures), (n * 4));
+ retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_TRUE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return retval;
+}
+
+#define X_GLrop_CopyTexImage1D 4119
+void
+__indirect_glCopyTexImage1D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 32;
+ emit_header(gc->pc, X_GLrop_CopyTexImage1D, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&level), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&internalformat), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&border), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_CopyTexImage2D 4120
+void
+__indirect_glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 36;
+ emit_header(gc->pc, X_GLrop_CopyTexImage2D, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&level), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&internalformat), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&height), 4);
+ (void) memcpy((void *)(gc->pc + 32), (void *)(&border), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_CopyTexSubImage1D 4121
+void
+__indirect_glCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_CopyTexSubImage1D, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&level), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&xoffset), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&width), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_CopyTexSubImage2D 4122
+void
+__indirect_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 36;
+ emit_header(gc->pc, X_GLrop_CopyTexSubImage2D, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&level), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&xoffset), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&yoffset), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 32), (void *)(&height), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLvop_DeleteTextures 12
+void
+__indirect_glDeleteTextures(GLsizei n, const GLuint * textures)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
+ if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivate, X_GLvop_DeleteTextures, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&n), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(textures), (n * 4));
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLsop_GenTextures 145
+void
+__indirect_glGenTextures(GLsizei n, GLuint * textures)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGenTexturesRep *reply = XCBGlxGenTexturesReply(c, XCBGlxGenTextures(c, gc->currentContextTag, n), NULL);
+ (void)memcpy(textures, XCBGlxGenTexturesData(reply), XCBGlxGenTexturesDataLength(reply) * sizeof(GLuint));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GenTextures, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&n), 4);
+ (void) __glXReadReply(dpy, 4, textures, GL_TRUE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_IsTexture 146
+GLboolean
+__indirect_glIsTexture(GLuint texture)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ GLboolean retval = (GLboolean) 0;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxIsTextureRep *reply = XCBGlxIsTextureReply(c, XCBGlxIsTexture(c, gc->currentContextTag, texture), NULL);
+ retval = reply->ret_val;
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_IsTexture, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&texture), 4);
+ retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return retval;
+}
+
+#define X_GLrop_PrioritizeTextures 4118
+void
+__indirect_glPrioritizeTextures(GLsizei n, const GLuint * textures, const GLclampf * priorities)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8 + __GLX_PAD((n * 4)) + __GLX_PAD((n * 4));
+ if (__builtin_expect(n >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_PrioritizeTextures, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(textures), (n * 4));
+ (void) memcpy((void *)(gc->pc + 8 + (n * 4)), (void *)(priorities), (n * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+static void
+__glx_TexSubImage_1D2D( unsigned opcode, unsigned dim, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = (pixels != NULL) ? __glImageSize(width, height, 1, format, type, target) : 0;
+ const GLuint cmdlen = 60 + __GLX_PAD(compsize);
+ if (__builtin_expect(gc->currentDpy != NULL, 1)) {
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ if ( (gc->pc + cmdlen) > gc->bufEnd ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ emit_header(gc->pc, opcode, cmdlen);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&level), 4);
+ (void) memcpy((void *)(gc->pc + 32), (void *)(&xoffset), 4);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&yoffset), 4);
+ (void) memcpy((void *)(gc->pc + 40), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 44), (void *)(&height), 4);
+ (void) memcpy((void *)(gc->pc + 48), (void *)(&format), 4);
+ (void) memcpy((void *)(gc->pc + 52), (void *)(&type), 4);
+ (void) memcpy((void *)(gc->pc + 56), (void *)((pixels == NULL) ? one : zero), 4);
+ if (compsize > 0) {
+ (*gc->fillImage)(gc, dim, width, height, 1, format, type, pixels, gc->pc + 60, gc->pc + 4);
+ }
+ else {
+ (void) memcpy( gc->pc + 4, default_pixel_store_2D, default_pixel_store_2D_size );
+ }
+ gc->pc += cmdlen;
+ if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+ else {
+ const GLint op = opcode;
+ const GLuint cmdlenLarge = cmdlen + 4;
+ GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
+ (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&op), 4);
+ (void) memcpy((void *)(pc + 28), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 32), (void *)(&level), 4);
+ (void) memcpy((void *)(pc + 36), (void *)(&xoffset), 4);
+ (void) memcpy((void *)(pc + 40), (void *)(&yoffset), 4);
+ (void) memcpy((void *)(pc + 44), (void *)(&width), 4);
+ (void) memcpy((void *)(pc + 48), (void *)(&height), 4);
+ (void) memcpy((void *)(pc + 52), (void *)(&format), 4);
+ (void) memcpy((void *)(pc + 56), (void *)(&type), 4);
+ (void) memcpy((void *)(pc + 60), zero, 4);
+ __glXSendLargeImage(gc, compsize, dim, width, height, 1, format, type, pixels, pc + 64, pc + 8);
+ }
+ }
+}
+
+#define X_GLrop_TexSubImage1D 4099
+void
+__indirect_glTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ __glx_TexSubImage_1D2D(X_GLrop_TexSubImage1D, 1, target, level, xoffset, 1, width, 1, format, type, pixels );
+}
+
+#define X_GLrop_TexSubImage2D 4100
+void
+__indirect_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ __glx_TexSubImage_1D2D(X_GLrop_TexSubImage2D, 2, target, level, xoffset, yoffset, width, height, format, type, pixels );
+}
+
+#define X_GLrop_BlendColor 4096
+void
+__indirect_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_BlendColor, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&green), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&blue), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&alpha), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_BlendEquation 4097
+void
+__indirect_glBlendEquation(GLenum mode)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_BlendEquation, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&mode), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ColorTable 2053
+void
+__indirect_glColorTable(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * table)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = (table != NULL) ? __glImageSize(width, 1, 1, format, type, target) : 0;
+ const GLuint cmdlen = 44 + __GLX_PAD(compsize);
+ if (__builtin_expect(gc->currentDpy != NULL, 1)) {
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ if ( (gc->pc + cmdlen) > gc->bufEnd ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ emit_header(gc->pc, X_GLrop_ColorTable, cmdlen);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&internalformat), 4);
+ (void) memcpy((void *)(gc->pc + 32), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&format), 4);
+ (void) memcpy((void *)(gc->pc + 40), (void *)(&type), 4);
+ if (compsize > 0) {
+ (*gc->fillImage)(gc, 1, width, 1, 1, format, type, table, gc->pc + 44, gc->pc + 4);
+ }
+ else {
+ (void) memcpy( gc->pc + 4, default_pixel_store_1D, default_pixel_store_1D_size );
+ }
+ gc->pc += cmdlen;
+ if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+ else {
+ const GLint op = X_GLrop_ColorTable;
+ const GLuint cmdlenLarge = cmdlen + 4;
+ GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
+ (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&op), 4);
+ (void) memcpy((void *)(pc + 28), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 32), (void *)(&internalformat), 4);
+ (void) memcpy((void *)(pc + 36), (void *)(&width), 4);
+ (void) memcpy((void *)(pc + 40), (void *)(&format), 4);
+ (void) memcpy((void *)(pc + 44), (void *)(&type), 4);
+ __glXSendLargeImage(gc, compsize, 1, width, 1, 1, format, type, table, pc + 48, pc + 8);
+ }
+ }
+}
+
+#define X_GLrop_ColorTableParameterfv 2054
+void
+__indirect_glColorTableParameterfv(GLenum target, GLenum pname, const GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glColorTableParameterfv_size(pname);
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_ColorTableParameterfv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ColorTableParameteriv 2055
+void
+__indirect_glColorTableParameteriv(GLenum target, GLenum pname, const GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glColorTableParameteriv_size(pname);
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_ColorTableParameteriv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_CopyColorTable 2056
+void
+__indirect_glCopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_CopyColorTable, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&internalformat), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&width), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLsop_GetColorTable 147
+void
+__indirect_glGetColorTable(GLenum target, GLenum format, GLenum type, GLvoid * table)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const __GLXattribute * const state = gc->client_state_private;
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 16;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetColorTableRep *reply = XCBGlxGetColorTableReply(c, XCBGlxGetColorTable(c, gc->currentContextTag, target, format, type, state->storePack.swapEndian), NULL);
+ (void)memcpy(table, XCBGlxGetColorTableData(reply), XCBGlxGetColorTableDataLength(reply) * sizeof(GLvoid));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetColorTable, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&format), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&type), 4);
+ *(int32_t *)(pc + 12) = 0;
+ * (int8_t *)(pc + 12) = state->storePack.swapEndian;
+ __glXReadPixelReply(dpy, gc, 1, 0, 0, 0, format, type, table, GL_TRUE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetColorTableParameterfv 148
+void
+__indirect_glGetColorTableParameterfv(GLenum target, GLenum pname, GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetColorTableParameterfvRep *reply = XCBGlxGetColorTableParameterfvReply(c, XCBGlxGetColorTableParameterfv(c, gc->currentContextTag, target, pname), NULL);
+ if (XCBGlxGetColorTableParameterfvDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetColorTableParameterfvData(reply), XCBGlxGetColorTableParameterfvDataLength(reply) * sizeof(GLfloat));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetColorTableParameterfv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetColorTableParameteriv 149
+void
+__indirect_glGetColorTableParameteriv(GLenum target, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetColorTableParameterivRep *reply = XCBGlxGetColorTableParameterivReply(c, XCBGlxGetColorTableParameteriv(c, gc->currentContextTag, target, pname), NULL);
+ if (XCBGlxGetColorTableParameterivDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetColorTableParameterivData(reply), XCBGlxGetColorTableParameterivDataLength(reply) * sizeof(GLint));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetColorTableParameteriv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLrop_ColorSubTable 195
+void
+__indirect_glColorSubTable(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid * data)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = (data != NULL) ? __glImageSize(count, 1, 1, format, type, target) : 0;
+ const GLuint cmdlen = 44 + __GLX_PAD(compsize);
+ if (__builtin_expect(gc->currentDpy != NULL, 1)) {
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ if ( (gc->pc + cmdlen) > gc->bufEnd ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ emit_header(gc->pc, X_GLrop_ColorSubTable, cmdlen);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&start), 4);
+ (void) memcpy((void *)(gc->pc + 32), (void *)(&count), 4);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&format), 4);
+ (void) memcpy((void *)(gc->pc + 40), (void *)(&type), 4);
+ if (compsize > 0) {
+ (*gc->fillImage)(gc, 1, count, 1, 1, format, type, data, gc->pc + 44, gc->pc + 4);
+ }
+ else {
+ (void) memcpy( gc->pc + 4, default_pixel_store_1D, default_pixel_store_1D_size );
+ }
+ gc->pc += cmdlen;
+ if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+ else {
+ const GLint op = X_GLrop_ColorSubTable;
+ const GLuint cmdlenLarge = cmdlen + 4;
+ GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
+ (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&op), 4);
+ (void) memcpy((void *)(pc + 28), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 32), (void *)(&start), 4);
+ (void) memcpy((void *)(pc + 36), (void *)(&count), 4);
+ (void) memcpy((void *)(pc + 40), (void *)(&format), 4);
+ (void) memcpy((void *)(pc + 44), (void *)(&type), 4);
+ __glXSendLargeImage(gc, compsize, 1, count, 1, 1, format, type, data, pc + 48, pc + 8);
+ }
+ }
+}
+
+#define X_GLrop_CopyColorSubTable 196
+void
+__indirect_glCopyColorSubTable(GLenum target, GLsizei start, GLint x, GLint y, GLsizei width)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_CopyColorSubTable, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&start), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&width), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+static void
+__glx_ConvolutionFilter_1D2D( unsigned opcode, unsigned dim, GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * image )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = (image != NULL) ? __glImageSize(width, height, 1, format, type, target) : 0;
+ const GLuint cmdlen = 48 + __GLX_PAD(compsize);
+ if (__builtin_expect(gc->currentDpy != NULL, 1)) {
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ if ( (gc->pc + cmdlen) > gc->bufEnd ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ emit_header(gc->pc, opcode, cmdlen);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&internalformat), 4);
+ (void) memcpy((void *)(gc->pc + 32), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&height), 4);
+ (void) memcpy((void *)(gc->pc + 40), (void *)(&format), 4);
+ (void) memcpy((void *)(gc->pc + 44), (void *)(&type), 4);
+ if (compsize > 0) {
+ (*gc->fillImage)(gc, dim, width, height, 1, format, type, image, gc->pc + 48, gc->pc + 4);
+ }
+ else {
+ (void) memcpy( gc->pc + 4, default_pixel_store_2D, default_pixel_store_2D_size );
+ }
+ gc->pc += cmdlen;
+ if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+ else {
+ const GLint op = opcode;
+ const GLuint cmdlenLarge = cmdlen + 4;
+ GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
+ (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&op), 4);
+ (void) memcpy((void *)(pc + 28), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 32), (void *)(&internalformat), 4);
+ (void) memcpy((void *)(pc + 36), (void *)(&width), 4);
+ (void) memcpy((void *)(pc + 40), (void *)(&height), 4);
+ (void) memcpy((void *)(pc + 44), (void *)(&format), 4);
+ (void) memcpy((void *)(pc + 48), (void *)(&type), 4);
+ __glXSendLargeImage(gc, compsize, dim, width, height, 1, format, type, image, pc + 52, pc + 8);
+ }
+ }
+}
+
+#define X_GLrop_ConvolutionFilter1D 4101
+void
+__indirect_glConvolutionFilter1D(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * image)
+{
+ __glx_ConvolutionFilter_1D2D(X_GLrop_ConvolutionFilter1D, 1, target, internalformat, width, 1, format, type, image );
+}
+
+#define X_GLrop_ConvolutionFilter2D 4102
+void
+__indirect_glConvolutionFilter2D(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * image)
+{
+ __glx_ConvolutionFilter_1D2D(X_GLrop_ConvolutionFilter2D, 2, target, internalformat, width, height, format, type, image );
+}
+
+#define X_GLrop_ConvolutionParameterf 4103
+void
+__indirect_glConvolutionParameterf(GLenum target, GLenum pname, GLfloat params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_ConvolutionParameterf, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&params), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ConvolutionParameterfv 4104
+void
+__indirect_glConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glConvolutionParameterfv_size(pname);
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_ConvolutionParameterfv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ConvolutionParameteri 4105
+void
+__indirect_glConvolutionParameteri(GLenum target, GLenum pname, GLint params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_ConvolutionParameteri, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&params), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ConvolutionParameteriv 4106
+void
+__indirect_glConvolutionParameteriv(GLenum target, GLenum pname, const GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glConvolutionParameteriv_size(pname);
+ const GLuint cmdlen = 12 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_ConvolutionParameteriv, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_CopyConvolutionFilter1D 4107
+void
+__indirect_glCopyConvolutionFilter1D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_CopyConvolutionFilter1D, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&internalformat), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&width), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_CopyConvolutionFilter2D 4108
+void
+__indirect_glCopyConvolutionFilter2D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_CopyConvolutionFilter2D, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&internalformat), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&height), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLsop_GetConvolutionFilter 150
+void
+__indirect_glGetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid * image)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const __GLXattribute * const state = gc->client_state_private;
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 16;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetConvolutionFilterRep *reply = XCBGlxGetConvolutionFilterReply(c, XCBGlxGetConvolutionFilter(c, gc->currentContextTag, target, format, type, state->storePack.swapEndian), NULL);
+ (void)memcpy(image, XCBGlxGetConvolutionFilterData(reply), XCBGlxGetConvolutionFilterDataLength(reply) * sizeof(GLvoid));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetConvolutionFilter, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&format), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&type), 4);
+ *(int32_t *)(pc + 12) = 0;
+ * (int8_t *)(pc + 12) = state->storePack.swapEndian;
+ __glXReadPixelReply(dpy, gc, 2, 0, 0, 0, format, type, image, GL_TRUE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetConvolutionParameterfv 151
+void
+__indirect_glGetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetConvolutionParameterfvRep *reply = XCBGlxGetConvolutionParameterfvReply(c, XCBGlxGetConvolutionParameterfv(c, gc->currentContextTag, target, pname), NULL);
+ if (XCBGlxGetConvolutionParameterfvDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetConvolutionParameterfvData(reply), XCBGlxGetConvolutionParameterfvDataLength(reply) * sizeof(GLfloat));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetConvolutionParameterfv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetConvolutionParameteriv 152
+void
+__indirect_glGetConvolutionParameteriv(GLenum target, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetConvolutionParameterivRep *reply = XCBGlxGetConvolutionParameterivReply(c, XCBGlxGetConvolutionParameteriv(c, gc->currentContextTag, target, pname), NULL);
+ if (XCBGlxGetConvolutionParameterivDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetConvolutionParameterivData(reply), XCBGlxGetConvolutionParameterivDataLength(reply) * sizeof(GLint));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetConvolutionParameteriv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetHistogram 154
+void
+__indirect_glGetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const __GLXattribute * const state = gc->client_state_private;
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 16;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetHistogramRep *reply = XCBGlxGetHistogramReply(c, XCBGlxGetHistogram(c, gc->currentContextTag, target, reset, format, type, state->storePack.swapEndian), NULL);
+ (void)memcpy(values, XCBGlxGetHistogramData(reply), XCBGlxGetHistogramDataLength(reply) * sizeof(GLvoid));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetHistogram, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&format), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&type), 4);
+ *(int32_t *)(pc + 12) = 0;
+ * (int8_t *)(pc + 12) = state->storePack.swapEndian;
+ * (int8_t *)(pc + 13) = reset;
+ __glXReadPixelReply(dpy, gc, 1, 0, 0, 0, format, type, values, GL_TRUE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetHistogramParameterfv 155
+void
+__indirect_glGetHistogramParameterfv(GLenum target, GLenum pname, GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetHistogramParameterfvRep *reply = XCBGlxGetHistogramParameterfvReply(c, XCBGlxGetHistogramParameterfv(c, gc->currentContextTag, target, pname), NULL);
+ if (XCBGlxGetHistogramParameterfvDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetHistogramParameterfvData(reply), XCBGlxGetHistogramParameterfvDataLength(reply) * sizeof(GLfloat));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetHistogramParameterfv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetHistogramParameteriv 156
+void
+__indirect_glGetHistogramParameteriv(GLenum target, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetHistogramParameterivRep *reply = XCBGlxGetHistogramParameterivReply(c, XCBGlxGetHistogramParameteriv(c, gc->currentContextTag, target, pname), NULL);
+ if (XCBGlxGetHistogramParameterivDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetHistogramParameterivData(reply), XCBGlxGetHistogramParameterivDataLength(reply) * sizeof(GLint));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetHistogramParameteriv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetMinmax 157
+void
+__indirect_glGetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const __GLXattribute * const state = gc->client_state_private;
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 16;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetMinmaxRep *reply = XCBGlxGetMinmaxReply(c, XCBGlxGetMinmax(c, gc->currentContextTag, target, reset, format, type, state->storePack.swapEndian), NULL);
+ (void)memcpy(values, XCBGlxGetMinmaxData(reply), XCBGlxGetMinmaxDataLength(reply) * sizeof(GLvoid));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetMinmax, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&format), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&type), 4);
+ *(int32_t *)(pc + 12) = 0;
+ * (int8_t *)(pc + 12) = state->storePack.swapEndian;
+ * (int8_t *)(pc + 13) = reset;
+ __glXReadPixelReply(dpy, gc, 1, 2, 1, 1, format, type, values, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetMinmaxParameterfv 158
+void
+__indirect_glGetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetMinmaxParameterfvRep *reply = XCBGlxGetMinmaxParameterfvReply(c, XCBGlxGetMinmaxParameterfv(c, gc->currentContextTag, target, pname), NULL);
+ if (XCBGlxGetMinmaxParameterfvDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetMinmaxParameterfvData(reply), XCBGlxGetMinmaxParameterfvDataLength(reply) * sizeof(GLfloat));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetMinmaxParameterfv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetMinmaxParameteriv 159
+void
+__indirect_glGetMinmaxParameteriv(GLenum target, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetMinmaxParameterivRep *reply = XCBGlxGetMinmaxParameterivReply(c, XCBGlxGetMinmaxParameteriv(c, gc->currentContextTag, target, pname), NULL);
+ if (XCBGlxGetMinmaxParameterivDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetMinmaxParameterivData(reply), XCBGlxGetMinmaxParameterivDataLength(reply) * sizeof(GLint));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetMinmaxParameteriv, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLrop_Histogram 4110
+void
+__indirect_glHistogram(GLenum target, GLsizei width, GLenum internalformat, GLboolean sink)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_Histogram, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&internalformat), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&sink), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_Minmax 4111
+void
+__indirect_glMinmax(GLenum target, GLenum internalformat, GLboolean sink)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_Minmax, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&internalformat), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&sink), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ResetHistogram 4112
+void
+__indirect_glResetHistogram(GLenum target)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_ResetHistogram, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ResetMinmax 4113
+void
+__indirect_glResetMinmax(GLenum target)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_ResetMinmax, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+static void
+__glx_TexImage_3D4D( unsigned opcode, unsigned dim, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLint border, GLenum format, GLenum type, const GLvoid * pixels )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = (pixels != NULL) ? __glImageSize(width, height, depth, format, type, target) : 0;
+ const GLuint cmdlen = 84 + __GLX_PAD(compsize);
+ if (__builtin_expect(gc->currentDpy != NULL, 1)) {
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ if ( (gc->pc + cmdlen) > gc->bufEnd ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ emit_header(gc->pc, opcode, cmdlen);
+ (void) memcpy((void *)(gc->pc + 40), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 44), (void *)(&level), 4);
+ (void) memcpy((void *)(gc->pc + 48), (void *)(&internalformat), 4);
+ (void) memcpy((void *)(gc->pc + 52), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 56), (void *)(&height), 4);
+ (void) memcpy((void *)(gc->pc + 60), (void *)(&depth), 4);
+ (void) memcpy((void *)(gc->pc + 64), (void *)(&extent), 4);
+ (void) memcpy((void *)(gc->pc + 68), (void *)(&border), 4);
+ (void) memcpy((void *)(gc->pc + 72), (void *)(&format), 4);
+ (void) memcpy((void *)(gc->pc + 76), (void *)(&type), 4);
+ (void) memcpy((void *)(gc->pc + 80), (void *)((pixels == NULL) ? one : zero), 4);
+ if (compsize > 0) {
+ (*gc->fillImage)(gc, dim, width, height, depth, format, type, pixels, gc->pc + 84, gc->pc + 4);
+ }
+ else {
+ (void) memcpy( gc->pc + 4, default_pixel_store_4D, default_pixel_store_4D_size );
+ }
+ gc->pc += cmdlen;
+ if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+ else {
+ const GLint op = opcode;
+ const GLuint cmdlenLarge = cmdlen + 4;
+ GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
+ (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&op), 4);
+ (void) memcpy((void *)(pc + 44), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 48), (void *)(&level), 4);
+ (void) memcpy((void *)(pc + 52), (void *)(&internalformat), 4);
+ (void) memcpy((void *)(pc + 56), (void *)(&width), 4);
+ (void) memcpy((void *)(pc + 60), (void *)(&height), 4);
+ (void) memcpy((void *)(pc + 64), (void *)(&depth), 4);
+ (void) memcpy((void *)(pc + 68), (void *)(&extent), 4);
+ (void) memcpy((void *)(pc + 72), (void *)(&border), 4);
+ (void) memcpy((void *)(pc + 76), (void *)(&format), 4);
+ (void) memcpy((void *)(pc + 80), (void *)(&type), 4);
+ (void) memcpy((void *)(pc + 84), zero, 4);
+ __glXSendLargeImage(gc, compsize, dim, width, height, depth, format, type, pixels, pc + 88, pc + 8);
+ }
+ }
+}
+
+#define X_GLrop_TexImage3D 4114
+void
+__indirect_glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ __glx_TexImage_3D4D(X_GLrop_TexImage3D, 3, target, level, internalformat, width, height, depth, 1, border, format, type, pixels );
+}
+
+static void
+__glx_TexSubImage_3D4D( unsigned opcode, unsigned dim, 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 GLvoid * pixels )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = (pixels != NULL) ? __glImageSize(width, height, depth, format, type, target) : 0;
+ const GLuint cmdlen = 92 + __GLX_PAD(compsize);
+ if (__builtin_expect(gc->currentDpy != NULL, 1)) {
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ if ( (gc->pc + cmdlen) > gc->bufEnd ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ emit_header(gc->pc, opcode, cmdlen);
+ (void) memcpy((void *)(gc->pc + 40), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 44), (void *)(&level), 4);
+ (void) memcpy((void *)(gc->pc + 48), (void *)(&xoffset), 4);
+ (void) memcpy((void *)(gc->pc + 52), (void *)(&yoffset), 4);
+ (void) memcpy((void *)(gc->pc + 56), (void *)(&zoffset), 4);
+ (void) memcpy((void *)(gc->pc + 60), (void *)(&woffset), 4);
+ (void) memcpy((void *)(gc->pc + 64), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 68), (void *)(&height), 4);
+ (void) memcpy((void *)(gc->pc + 72), (void *)(&depth), 4);
+ (void) memcpy((void *)(gc->pc + 76), (void *)(&extent), 4);
+ (void) memcpy((void *)(gc->pc + 80), (void *)(&format), 4);
+ (void) memcpy((void *)(gc->pc + 84), (void *)(&type), 4);
+ (void) memcpy((void *)(gc->pc + 88), (void *)((pixels == NULL) ? one : zero), 4);
+ if (compsize > 0) {
+ (*gc->fillImage)(gc, dim, width, height, depth, format, type, pixels, gc->pc + 92, gc->pc + 4);
+ }
+ else {
+ (void) memcpy( gc->pc + 4, default_pixel_store_4D, default_pixel_store_4D_size );
+ }
+ gc->pc += cmdlen;
+ if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+ else {
+ const GLint op = opcode;
+ const GLuint cmdlenLarge = cmdlen + 4;
+ GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
+ (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&op), 4);
+ (void) memcpy((void *)(pc + 44), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 48), (void *)(&level), 4);
+ (void) memcpy((void *)(pc + 52), (void *)(&xoffset), 4);
+ (void) memcpy((void *)(pc + 56), (void *)(&yoffset), 4);
+ (void) memcpy((void *)(pc + 60), (void *)(&zoffset), 4);
+ (void) memcpy((void *)(pc + 64), (void *)(&woffset), 4);
+ (void) memcpy((void *)(pc + 68), (void *)(&width), 4);
+ (void) memcpy((void *)(pc + 72), (void *)(&height), 4);
+ (void) memcpy((void *)(pc + 76), (void *)(&depth), 4);
+ (void) memcpy((void *)(pc + 80), (void *)(&extent), 4);
+ (void) memcpy((void *)(pc + 84), (void *)(&format), 4);
+ (void) memcpy((void *)(pc + 88), (void *)(&type), 4);
+ (void) memcpy((void *)(pc + 92), zero, 4);
+ __glXSendLargeImage(gc, compsize, dim, width, height, depth, format, type, pixels, pc + 96, pc + 8);
+ }
+ }
+}
+
+#define X_GLrop_TexSubImage3D 4115
+void
+__indirect_glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ __glx_TexSubImage_3D4D(X_GLrop_TexSubImage3D, 3, target, level, xoffset, yoffset, zoffset, 1, width, height, depth, 1, format, type, pixels );
+}
+
+#define X_GLrop_CopyTexSubImage3D 4123
+void
+__indirect_glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 40;
+ emit_header(gc->pc, X_GLrop_CopyTexSubImage3D, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&level), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&xoffset), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&yoffset), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&zoffset), 4);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 32), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&height), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ActiveTextureARB 197
+void
+__indirect_glActiveTextureARB(GLenum texture)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_ActiveTextureARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&texture), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord1dvARB 198
+void
+__indirect_glMultiTexCoord1dARB(GLenum target, GLdouble s)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord1dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&target), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord1dvARB 198
+void
+__indirect_glMultiTexCoord1dvARB(GLenum target, const GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord1dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(v), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&target), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord1fvARB 199
+void
+__indirect_glMultiTexCoord1fARB(GLenum target, GLfloat s)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord1fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&s), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord1fvARB 199
+void
+__indirect_glMultiTexCoord1fvARB(GLenum target, const GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord1fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord1ivARB 200
+void
+__indirect_glMultiTexCoord1iARB(GLenum target, GLint s)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord1ivARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&s), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord1ivARB 200
+void
+__indirect_glMultiTexCoord1ivARB(GLenum target, const GLint * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord1ivARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord1svARB 201
+void
+__indirect_glMultiTexCoord1sARB(GLenum target, GLshort s)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord1svARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&s), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord1svARB 201
+void
+__indirect_glMultiTexCoord1svARB(GLenum target, const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord1svARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord2dvARB 202
+void
+__indirect_glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord2dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&t), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&target), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord2dvARB 202
+void
+__indirect_glMultiTexCoord2dvARB(GLenum target, const GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord2dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(v), 16);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&target), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord2fvARB 203
+void
+__indirect_glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord2fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&s), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&t), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord2fvARB 203
+void
+__indirect_glMultiTexCoord2fvARB(GLenum target, const GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord2fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord2ivARB 204
+void
+__indirect_glMultiTexCoord2iARB(GLenum target, GLint s, GLint t)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord2ivARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&s), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&t), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord2ivARB 204
+void
+__indirect_glMultiTexCoord2ivARB(GLenum target, const GLint * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord2ivARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord2svARB 205
+void
+__indirect_glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord2svARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&s), 2);
+ (void) memcpy((void *)(gc->pc + 10), (void *)(&t), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord2svARB 205
+void
+__indirect_glMultiTexCoord2svARB(GLenum target, const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord2svARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord3dvARB 206
+void
+__indirect_glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 32;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord3dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&t), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&r), 8);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&target), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord3dvARB 206
+void
+__indirect_glMultiTexCoord3dvARB(GLenum target, const GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 32;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord3dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(v), 24);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&target), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord3fvARB 207
+void
+__indirect_glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord3fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&s), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&t), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&r), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord3fvARB 207
+void
+__indirect_glMultiTexCoord3fvARB(GLenum target, const GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord3fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 12);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord3ivARB 208
+void
+__indirect_glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord3ivARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&s), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&t), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&r), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord3ivARB 208
+void
+__indirect_glMultiTexCoord3ivARB(GLenum target, const GLint * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord3ivARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 12);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord3svARB 209
+void
+__indirect_glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord3svARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&s), 2);
+ (void) memcpy((void *)(gc->pc + 10), (void *)(&t), 2);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&r), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord3svARB 209
+void
+__indirect_glMultiTexCoord3svARB(GLenum target, const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord3svARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 6);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord4dvARB 210
+void
+__indirect_glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 40;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord4dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&s), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&t), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&r), 8);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&q), 8);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&target), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord4dvARB 210
+void
+__indirect_glMultiTexCoord4dvARB(GLenum target, const GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 40;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord4dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(v), 32);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&target), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord4fvARB 211
+void
+__indirect_glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord4fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&s), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&t), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&r), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&q), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord4fvARB 211
+void
+__indirect_glMultiTexCoord4fvARB(GLenum target, const GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord4fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 16);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord4ivARB 212
+void
+__indirect_glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord4ivARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&s), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&t), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&r), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&q), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord4ivARB 212
+void
+__indirect_glMultiTexCoord4ivARB(GLenum target, const GLint * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord4ivARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 16);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord4svARB 213
+void
+__indirect_glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord4svARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&s), 2);
+ (void) memcpy((void *)(gc->pc + 10), (void *)(&t), 2);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&r), 2);
+ (void) memcpy((void *)(gc->pc + 14), (void *)(&q), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_MultiTexCoord4svARB 213
+void
+__indirect_glMultiTexCoord4svARB(GLenum target, const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_MultiTexCoord4svARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_SampleCoverageARB 229
+void
+__indirect_glSampleCoverageARB(GLclampf value, GLboolean invert)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_SampleCoverageARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&value), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&invert), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_DrawBuffersARB 233
+void
+__indirect_glDrawBuffersARB(GLsizei n, const GLenum * bufs)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8 + __GLX_PAD((n * 4));
+ if (__builtin_expect((n >= 0) && (gc->currentDpy != NULL), 1)) {
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ if ( (gc->pc + cmdlen) > gc->bufEnd ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ emit_header(gc->pc, X_GLrop_DrawBuffersARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(bufs), (n * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+ else {
+ const GLint op = X_GLrop_DrawBuffersARB;
+ const GLuint cmdlenLarge = cmdlen + 4;
+ GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
+ (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&op), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&n), 4);
+ __glXSendLargeCommand(gc, pc, 12, bufs, (n * 4));
+ }
+ }
+}
+
+#define X_GLvop_AreTexturesResidentEXT 11
+GLboolean
+__indirect_glAreTexturesResidentEXT(GLsizei n, const GLuint * textures, GLboolean * residences)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ GLboolean retval = (GLboolean) 0;
+ const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
+ if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_AreTexturesResidentEXT, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&n), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(textures), (n * 4));
+ retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_TRUE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return retval;
+}
+
+#define X_GLvop_GenTexturesEXT 13
+void
+__indirect_glGenTexturesEXT(GLsizei n, GLuint * textures)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GenTexturesEXT, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&n), 4);
+ (void) __glXReadReply(dpy, 4, textures, GL_TRUE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLvop_IsTextureEXT 14
+GLboolean
+__indirect_glIsTextureEXT(GLuint texture)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ GLboolean retval = (GLboolean) 0;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_IsTextureEXT, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&texture), 4);
+ retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return retval;
+}
+
+#define X_GLrop_SampleMaskSGIS 2048
+void
+__indirect_glSampleMaskSGIS(GLclampf value, GLboolean invert)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_SampleMaskSGIS, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&value), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&invert), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_SamplePatternSGIS 2049
+void
+__indirect_glSamplePatternSGIS(GLenum pattern)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_SamplePatternSGIS, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&pattern), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PointParameterfEXT 2065
+void
+__indirect_glPointParameterfEXT(GLenum pname, GLfloat param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_PointParameterfEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PointParameterfvEXT 2066
+void
+__indirect_glPointParameterfvEXT(GLenum pname, const GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glPointParameterfvEXT_size(pname);
+ const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_PointParameterfvEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_WindowPos3fvMESA 230
+void
+__indirect_glWindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_WindowPos3fvMESA, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&z), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_WindowPos3fvMESA 230
+void
+__indirect_glWindowPos3fvMESA(const GLfloat * v)
+{
+ generic_12_byte( X_GLrop_WindowPos3fvMESA, v );
+}
+
+#define X_GLrop_BlendFuncSeparateEXT 4134
+void
+__indirect_glBlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_BlendFuncSeparateEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&sfactorRGB), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&dfactorRGB), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&sfactorAlpha), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&dfactorAlpha), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_FogCoordfvEXT 4124
+void
+__indirect_glFogCoordfEXT(GLfloat coord)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_FogCoordfvEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&coord), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_FogCoordfvEXT 4124
+void
+__indirect_glFogCoordfvEXT(const GLfloat * coord)
+{
+ generic_4_byte( X_GLrop_FogCoordfvEXT, coord );
+}
+
+#define X_GLrop_FogCoorddvEXT 4125
+void
+__indirect_glFogCoorddEXT(GLdouble coord)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_FogCoorddvEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&coord), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_FogCoorddvEXT 4125
+void
+__indirect_glFogCoorddvEXT(const GLdouble * coord)
+{
+ generic_8_byte( X_GLrop_FogCoorddvEXT, coord );
+}
+
+#define X_GLrop_SecondaryColor3bvEXT 4126
+void
+__indirect_glSecondaryColor3bEXT(GLbyte red, GLbyte green, GLbyte blue)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_SecondaryColor3bvEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 1);
+ (void) memcpy((void *)(gc->pc + 5), (void *)(&green), 1);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&blue), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_SecondaryColor3bvEXT 4126
+void
+__indirect_glSecondaryColor3bvEXT(const GLbyte * v)
+{
+ generic_3_byte( X_GLrop_SecondaryColor3bvEXT, v );
+}
+
+#define X_GLrop_SecondaryColor3dvEXT 4130
+void
+__indirect_glSecondaryColor3dEXT(GLdouble red, GLdouble green, GLdouble blue)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_SecondaryColor3dvEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&green), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&blue), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_SecondaryColor3dvEXT 4130
+void
+__indirect_glSecondaryColor3dvEXT(const GLdouble * v)
+{
+ generic_24_byte( X_GLrop_SecondaryColor3dvEXT, v );
+}
+
+#define X_GLrop_SecondaryColor3fvEXT 4129
+void
+__indirect_glSecondaryColor3fEXT(GLfloat red, GLfloat green, GLfloat blue)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_SecondaryColor3fvEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&green), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&blue), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_SecondaryColor3fvEXT 4129
+void
+__indirect_glSecondaryColor3fvEXT(const GLfloat * v)
+{
+ generic_12_byte( X_GLrop_SecondaryColor3fvEXT, v );
+}
+
+#define X_GLrop_SecondaryColor3ivEXT 4128
+void
+__indirect_glSecondaryColor3iEXT(GLint red, GLint green, GLint blue)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_SecondaryColor3ivEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&green), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&blue), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_SecondaryColor3ivEXT 4128
+void
+__indirect_glSecondaryColor3ivEXT(const GLint * v)
+{
+ generic_12_byte( X_GLrop_SecondaryColor3ivEXT, v );
+}
+
+#define X_GLrop_SecondaryColor3svEXT 4127
+void
+__indirect_glSecondaryColor3sEXT(GLshort red, GLshort green, GLshort blue)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_SecondaryColor3svEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 2);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&green), 2);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&blue), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_SecondaryColor3svEXT 4127
+void
+__indirect_glSecondaryColor3svEXT(const GLshort * v)
+{
+ generic_6_byte( X_GLrop_SecondaryColor3svEXT, v );
+}
+
+#define X_GLrop_SecondaryColor3ubvEXT 4131
+void
+__indirect_glSecondaryColor3ubEXT(GLubyte red, GLubyte green, GLubyte blue)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_SecondaryColor3ubvEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 1);
+ (void) memcpy((void *)(gc->pc + 5), (void *)(&green), 1);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&blue), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_SecondaryColor3ubvEXT 4131
+void
+__indirect_glSecondaryColor3ubvEXT(const GLubyte * v)
+{
+ generic_3_byte( X_GLrop_SecondaryColor3ubvEXT, v );
+}
+
+#define X_GLrop_SecondaryColor3uivEXT 4133
+void
+__indirect_glSecondaryColor3uiEXT(GLuint red, GLuint green, GLuint blue)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_SecondaryColor3uivEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&green), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&blue), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_SecondaryColor3uivEXT 4133
+void
+__indirect_glSecondaryColor3uivEXT(const GLuint * v)
+{
+ generic_12_byte( X_GLrop_SecondaryColor3uivEXT, v );
+}
+
+#define X_GLrop_SecondaryColor3usvEXT 4132
+void
+__indirect_glSecondaryColor3usEXT(GLushort red, GLushort green, GLushort blue)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_SecondaryColor3usvEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&red), 2);
+ (void) memcpy((void *)(gc->pc + 6), (void *)(&green), 2);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&blue), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_SecondaryColor3usvEXT 4132
+void
+__indirect_glSecondaryColor3usvEXT(const GLushort * v)
+{
+ generic_6_byte( X_GLrop_SecondaryColor3usvEXT, v );
+}
+
+#define X_GLvop_AreProgramsResidentNV 1293
+GLboolean
+__indirect_glAreProgramsResidentNV(GLsizei n, const GLuint * ids, GLboolean * residences)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ GLboolean retval = (GLboolean) 0;
+ const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
+ if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_AreProgramsResidentNV, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&n), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(ids), (n * 4));
+ retval = (GLboolean) __glXReadReply(dpy, 1, residences, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return retval;
+}
+
+#define X_GLrop_BindProgramNV 4180
+void
+__indirect_glBindProgramNV(GLenum target, GLuint program)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_BindProgramNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&program), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLvop_DeleteProgramsNV 1294
+void
+__indirect_glDeleteProgramsNV(GLsizei n, const GLuint * programs)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
+ if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivate, X_GLvop_DeleteProgramsNV, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&n), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(programs), (n * 4));
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLrop_ExecuteProgramNV 4181
+void
+__indirect_glExecuteProgramNV(GLenum target, GLuint id, const GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_ExecuteProgramNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&id), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), 16);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLvop_GenProgramsNV 1295
+void
+__indirect_glGenProgramsNV(GLsizei n, GLuint * programs)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GenProgramsNV, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&n), 4);
+ (void) __glXReadReply(dpy, 4, programs, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLvop_GetProgramParameterdvNV 1297
+void
+__indirect_glGetProgramParameterdvNV(GLenum target, GLuint index, GLenum pname, GLdouble * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 12;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GetProgramParameterdvNV, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 8, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLvop_GetProgramParameterfvNV 1296
+void
+__indirect_glGetProgramParameterfvNV(GLenum target, GLuint index, GLenum pname, GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 12;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GetProgramParameterfvNV, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLvop_GetProgramivNV 1298
+void
+__indirect_glGetProgramivNV(GLuint id, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GetProgramivNV, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&id), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLvop_GetProgramStringNV 1299
+void
+__indirect_glGetProgramStringNV(GLuint id, GLenum pname, GLubyte * program)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GetProgramStringNV, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&id), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 1, program, GL_TRUE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLvop_GetTrackMatrixivNV 1300
+void
+__indirect_glGetTrackMatrixivNV(GLenum target, GLuint address, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 12;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GetTrackMatrixivNV, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&address), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLvop_IsProgramNV 1304
+GLboolean
+__indirect_glIsProgramNV(GLuint program)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ GLboolean retval = (GLboolean) 0;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_IsProgramNV, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&program), 4);
+ retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return retval;
+}
+
+#define X_GLrop_LoadProgramNV 4183
+void
+__indirect_glLoadProgramNV(GLenum target, GLuint id, GLsizei len, const GLubyte * program)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16 + __GLX_PAD(len);
+ if (__builtin_expect(len >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_LoadProgramNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&id), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&len), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(program), len);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_ProgramParameter4dvNV 4185
+void
+__indirect_glProgramParameter4dNV(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 44;
+ emit_header(gc->pc, X_GLrop_ProgramParameter4dvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&y), 8);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&z), 8);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&w), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ProgramParameter4dvNV 4185
+void
+__indirect_glProgramParameter4dvNV(GLenum target, GLuint index, const GLdouble * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 44;
+ emit_header(gc->pc, X_GLrop_ProgramParameter4dvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), 32);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ProgramParameter4fvNV 4184
+void
+__indirect_glProgramParameter4fNV(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_ProgramParameter4fvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&z), 4);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&w), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ProgramParameter4fvNV 4184
+void
+__indirect_glProgramParameter4fvNV(GLenum target, GLuint index, const GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_ProgramParameter4fvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), 16);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ProgramParameters4dvNV 4187
+void
+__indirect_glProgramParameters4dvNV(GLenum target, GLuint index, GLuint num, const GLdouble * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16 + __GLX_PAD((num * 32));
+ if (__builtin_expect(num >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_ProgramParameters4dvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&num), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(params), (num * 32));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_ProgramParameters4fvNV 4186
+void
+__indirect_glProgramParameters4fvNV(GLenum target, GLuint index, GLuint num, const GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16 + __GLX_PAD((num * 16));
+ if (__builtin_expect(num >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_ProgramParameters4fvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&num), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(params), (num * 16));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_RequestResidentProgramsNV 4182
+void
+__indirect_glRequestResidentProgramsNV(GLsizei n, const GLuint * ids)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8 + __GLX_PAD((n * 4));
+ if (__builtin_expect(n >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_RequestResidentProgramsNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(ids), (n * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_TrackMatrixNV 4188
+void
+__indirect_glTrackMatrixNV(GLenum target, GLuint address, GLenum matrix, GLenum transform)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_TrackMatrixNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&address), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&matrix), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&transform), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib1dvARB 4197
+void
+__indirect_glVertexAttrib1dARB(GLuint index, GLdouble x)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib1dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&index), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib1dvARB 4197
+void
+__indirect_glVertexAttrib1dvARB(GLuint index, const GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib1dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(v), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&index), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib1fvARB 4193
+void
+__indirect_glVertexAttrib1fARB(GLuint index, GLfloat x)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib1fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib1fvARB 4193
+void
+__indirect_glVertexAttrib1fvARB(GLuint index, const GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib1fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib1svARB 4189
+void
+__indirect_glVertexAttrib1sARB(GLuint index, GLshort x)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib1svARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib1svARB 4189
+void
+__indirect_glVertexAttrib1svARB(GLuint index, const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib1svARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib2dvARB 4198
+void
+__indirect_glVertexAttrib2dARB(GLuint index, GLdouble x, GLdouble y)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_VertexAttrib2dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&index), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib2dvARB 4198
+void
+__indirect_glVertexAttrib2dvARB(GLuint index, const GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_VertexAttrib2dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(v), 16);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&index), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib2fvARB 4194
+void
+__indirect_glVertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib2fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib2fvARB 4194
+void
+__indirect_glVertexAttrib2fvARB(GLuint index, const GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib2fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib2svARB 4190
+void
+__indirect_glVertexAttrib2sARB(GLuint index, GLshort x, GLshort y)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib2svARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 2);
+ (void) memcpy((void *)(gc->pc + 10), (void *)(&y), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib2svARB 4190
+void
+__indirect_glVertexAttrib2svARB(GLuint index, const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib2svARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib3dvARB 4199
+void
+__indirect_glVertexAttrib3dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 32;
+ emit_header(gc->pc, X_GLrop_VertexAttrib3dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&z), 8);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&index), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib3dvARB 4199
+void
+__indirect_glVertexAttrib3dvARB(GLuint index, const GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 32;
+ emit_header(gc->pc, X_GLrop_VertexAttrib3dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(v), 24);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&index), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib3fvARB 4195
+void
+__indirect_glVertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_VertexAttrib3fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&z), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib3fvARB 4195
+void
+__indirect_glVertexAttrib3fvARB(GLuint index, const GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_VertexAttrib3fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 12);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib3svARB 4191
+void
+__indirect_glVertexAttrib3sARB(GLuint index, GLshort x, GLshort y, GLshort z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib3svARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 2);
+ (void) memcpy((void *)(gc->pc + 10), (void *)(&y), 2);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&z), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib3svARB 4191
+void
+__indirect_glVertexAttrib3svARB(GLuint index, const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib3svARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 6);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4dvARB 4200
+void
+__indirect_glVertexAttrib4dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 40;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&z), 8);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&w), 8);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&index), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4dvARB 4200
+void
+__indirect_glVertexAttrib4dvARB(GLuint index, const GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 40;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(v), 32);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&index), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4fvARB 4196
+void
+__indirect_glVertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&z), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&w), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4fvARB 4196
+void
+__indirect_glVertexAttrib4fvARB(GLuint index, const GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 16);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4svARB 4192
+void
+__indirect_glVertexAttrib4sARB(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4svARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 2);
+ (void) memcpy((void *)(gc->pc + 10), (void *)(&y), 2);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&z), 2);
+ (void) memcpy((void *)(gc->pc + 14), (void *)(&w), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4svARB 4192
+void
+__indirect_glVertexAttrib4svARB(GLuint index, const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4svARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4NubvARB 4201
+void
+__indirect_glVertexAttrib4NubARB(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4NubvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 1);
+ (void) memcpy((void *)(gc->pc + 9), (void *)(&y), 1);
+ (void) memcpy((void *)(gc->pc + 10), (void *)(&z), 1);
+ (void) memcpy((void *)(gc->pc + 11), (void *)(&w), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4NubvARB 4201
+void
+__indirect_glVertexAttrib4NubvARB(GLuint index, const GLubyte * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4NubvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttribs1dvNV 4210
+void
+__indirect_glVertexAttribs1dvNV(GLuint index, GLsizei n, const GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 8));
+ if (__builtin_expect(n >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_VertexAttribs1dvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 8));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_VertexAttribs1fvNV 4206
+void
+__indirect_glVertexAttribs1fvNV(GLuint index, GLsizei n, const GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 4));
+ if (__builtin_expect(n >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_VertexAttribs1fvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_VertexAttribs1svNV 4202
+void
+__indirect_glVertexAttribs1svNV(GLuint index, GLsizei n, const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 2));
+ if (__builtin_expect(n >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_VertexAttribs1svNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 2));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_VertexAttribs2dvNV 4211
+void
+__indirect_glVertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 16));
+ if (__builtin_expect(n >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_VertexAttribs2dvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 16));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_VertexAttribs2fvNV 4207
+void
+__indirect_glVertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 8));
+ if (__builtin_expect(n >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_VertexAttribs2fvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 8));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_VertexAttribs2svNV 4203
+void
+__indirect_glVertexAttribs2svNV(GLuint index, GLsizei n, const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 4));
+ if (__builtin_expect(n >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_VertexAttribs2svNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_VertexAttribs3dvNV 4212
+void
+__indirect_glVertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 24));
+ if (__builtin_expect(n >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_VertexAttribs3dvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 24));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_VertexAttribs3fvNV 4208
+void
+__indirect_glVertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 12));
+ if (__builtin_expect(n >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_VertexAttribs3fvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 12));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_VertexAttribs3svNV 4204
+void
+__indirect_glVertexAttribs3svNV(GLuint index, GLsizei n, const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 6));
+ if (__builtin_expect(n >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_VertexAttribs3svNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 6));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_VertexAttribs4dvNV 4213
+void
+__indirect_glVertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 32));
+ if (__builtin_expect(n >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_VertexAttribs4dvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 32));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_VertexAttribs4fvNV 4209
+void
+__indirect_glVertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 16));
+ if (__builtin_expect(n >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_VertexAttribs4fvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 16));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_VertexAttribs4svNV 4205
+void
+__indirect_glVertexAttribs4svNV(GLuint index, GLsizei n, const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 8));
+ if (__builtin_expect(n >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_VertexAttribs4svNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 8));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_VertexAttribs4ubvNV 4214
+void
+__indirect_glVertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12 + __GLX_PAD((n * 4));
+ if (__builtin_expect(n >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_VertexAttribs4ubvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(v), (n * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_PointParameteriNV 4221
+void
+__indirect_glPointParameteriNV(GLenum pname, GLint param)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_PointParameteriNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&param), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_PointParameterivNV 4222
+void
+__indirect_glPointParameterivNV(GLenum pname, const GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint compsize = __glPointParameterivNV_size(pname);
+ const GLuint cmdlen = 8 + __GLX_PAD((compsize * 4));
+ emit_header(gc->pc, X_GLrop_PointParameterivNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&pname), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(params), (compsize * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ActiveStencilFaceEXT 4220
+void
+__indirect_glActiveStencilFaceEXT(GLenum face)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_ActiveStencilFaceEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&face), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4bvARB 4230
+void
+__indirect_glVertexAttrib4bvARB(GLuint index, const GLbyte * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4bvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4ivARB 4231
+void
+__indirect_glVertexAttrib4ivARB(GLuint index, const GLint * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4ivARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 16);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4ubvARB 4232
+void
+__indirect_glVertexAttrib4ubvARB(GLuint index, const GLubyte * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4ubvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4usvARB 4233
+void
+__indirect_glVertexAttrib4usvARB(GLuint index, const GLushort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4usvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4uivARB 4234
+void
+__indirect_glVertexAttrib4uivARB(GLuint index, const GLuint * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4uivARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 16);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4NbvARB 4235
+void
+__indirect_glVertexAttrib4NbvARB(GLuint index, const GLbyte * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4NbvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4NsvARB 4236
+void
+__indirect_glVertexAttrib4NsvARB(GLuint index, const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4NsvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4NivARB 4237
+void
+__indirect_glVertexAttrib4NivARB(GLuint index, const GLint * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4NivARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 16);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4NusvARB 4238
+void
+__indirect_glVertexAttrib4NusvARB(GLuint index, const GLushort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4NusvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4NuivARB 4239
+void
+__indirect_glVertexAttrib4NuivARB(GLuint index, const GLuint * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4NuivARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 16);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ProgramStringARB 4217
+void
+__indirect_glProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid * string)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16 + __GLX_PAD(len);
+ if (__builtin_expect((len >= 0) && (gc->currentDpy != NULL), 1)) {
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ if ( (gc->pc + cmdlen) > gc->bufEnd ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ emit_header(gc->pc, X_GLrop_ProgramStringARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&format), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&len), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(string), len);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+ else {
+ const GLint op = X_GLrop_ProgramStringARB;
+ const GLuint cmdlenLarge = cmdlen + 4;
+ GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);
+ (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&op), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 12), (void *)(&format), 4);
+ (void) memcpy((void *)(pc + 16), (void *)(&len), 4);
+ __glXSendLargeCommand(gc, pc, 20, string, len);
+ }
+ }
+}
+
+#define X_GLrop_ProgramEnvParameter4dvARB 4185
+void
+__indirect_glProgramEnvParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 44;
+ emit_header(gc->pc, X_GLrop_ProgramEnvParameter4dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&y), 8);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&z), 8);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&w), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ProgramEnvParameter4dvARB 4185
+void
+__indirect_glProgramEnvParameter4dvARB(GLenum target, GLuint index, const GLdouble * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 44;
+ emit_header(gc->pc, X_GLrop_ProgramEnvParameter4dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), 32);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ProgramEnvParameter4fvARB 4184
+void
+__indirect_glProgramEnvParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_ProgramEnvParameter4fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&z), 4);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&w), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ProgramEnvParameter4fvARB 4184
+void
+__indirect_glProgramEnvParameter4fvARB(GLenum target, GLuint index, const GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_ProgramEnvParameter4fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), 16);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ProgramLocalParameter4dvARB 4216
+void
+__indirect_glProgramLocalParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 44;
+ emit_header(gc->pc, X_GLrop_ProgramLocalParameter4dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&y), 8);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&z), 8);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&w), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ProgramLocalParameter4dvARB 4216
+void
+__indirect_glProgramLocalParameter4dvARB(GLenum target, GLuint index, const GLdouble * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 44;
+ emit_header(gc->pc, X_GLrop_ProgramLocalParameter4dvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), 32);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ProgramLocalParameter4fvARB 4215
+void
+__indirect_glProgramLocalParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_ProgramLocalParameter4fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&z), 4);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&w), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_ProgramLocalParameter4fvARB 4215
+void
+__indirect_glProgramLocalParameter4fvARB(GLenum target, GLuint index, const GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_ProgramLocalParameter4fvARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(params), 16);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLvop_GetProgramivARB 1307
+void
+__indirect_glGetProgramivARB(GLenum target, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GetProgramivARB, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLvop_GetProgramStringARB 1308
+void
+__indirect_glGetProgramStringARB(GLenum target, GLenum pname, GLvoid * string)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GetProgramStringARB, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 1, string, GL_TRUE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLrop_ProgramNamedParameter4fvNV 4218
+void
+__indirect_glProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28 + __GLX_PAD(len);
+ if (__builtin_expect(len >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_ProgramNamedParameter4fvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&id), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&len), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&z), 4);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&w), 4);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(name), len);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_ProgramNamedParameter4dvNV 4219
+void
+__indirect_glProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte * name, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 44 + __GLX_PAD(len);
+ if (__builtin_expect(len >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_ProgramNamedParameter4dvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 8);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&z), 8);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(&w), 8);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&id), 4);
+ (void) memcpy((void *)(gc->pc + 40), (void *)(&len), 4);
+ (void) memcpy((void *)(gc->pc + 44), (void *)(name), len);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_ProgramNamedParameter4fvNV 4218
+void
+__indirect_glProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte * name, const GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28 + __GLX_PAD(len);
+ if (__builtin_expect(len >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_ProgramNamedParameter4fvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&id), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&len), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(v), 16);
+ (void) memcpy((void *)(gc->pc + 28), (void *)(name), len);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLrop_ProgramNamedParameter4dvNV 4219
+void
+__indirect_glProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte * name, const GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 44 + __GLX_PAD(len);
+ if (__builtin_expect(len >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_ProgramNamedParameter4dvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(v), 32);
+ (void) memcpy((void *)(gc->pc + 36), (void *)(&id), 4);
+ (void) memcpy((void *)(gc->pc + 40), (void *)(&len), 4);
+ (void) memcpy((void *)(gc->pc + 44), (void *)(name), len);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLvop_GetProgramNamedParameterfvNV 1310
+void
+__indirect_glGetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte * name, GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8 + __GLX_PAD(len);
+ if (__builtin_expect((len >= 0) && (dpy != NULL), 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GetProgramNamedParameterfvNV, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&id), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&len), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(name), len);
+ (void) __glXReadReply(dpy, 4, params, GL_TRUE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLvop_GetProgramNamedParameterdvNV 1311
+void
+__indirect_glGetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte * name, GLdouble * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8 + __GLX_PAD(len);
+ if (__builtin_expect((len >= 0) && (dpy != NULL), 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GetProgramNamedParameterdvNV, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&id), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&len), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(name), len);
+ (void) __glXReadReply(dpy, 8, params, GL_TRUE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLsop_GenQueriesARB 162
+void
+__indirect_glGenQueriesARB(GLsizei n, GLuint * ids)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGenQueriesARBRep *reply = XCBGlxGenQueriesARBReply(c, XCBGlxGenQueriesARB(c, gc->currentContextTag, n), NULL);
+ (void)memcpy(ids, XCBGlxGenQueriesARBData(reply), XCBGlxGenQueriesARBDataLength(reply) * sizeof(GLuint));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GenQueriesARB, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&n), 4);
+ (void) __glXReadReply(dpy, 4, ids, GL_TRUE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_DeleteQueriesARB 161
+void
+__indirect_glDeleteQueriesARB(GLsizei n, const GLuint * ids)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 4 + __GLX_PAD((n * 4));
+ if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxDeleteQueriesARB(c, gc->currentContextTag, n, ids);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_DeleteQueriesARB, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&n), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(ids), (n * 4));
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_IsQueryARB 163
+GLboolean
+__indirect_glIsQueryARB(GLuint id)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ GLboolean retval = (GLboolean) 0;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxIsQueryARBRep *reply = XCBGlxIsQueryARBReply(c, XCBGlxIsQueryARB(c, gc->currentContextTag, id), NULL);
+ retval = reply->ret_val;
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_IsQueryARB, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&id), 4);
+ retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return retval;
+}
+
+#define X_GLrop_BeginQueryARB 231
+void
+__indirect_glBeginQueryARB(GLenum target, GLuint id)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_BeginQueryARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&id), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_EndQueryARB 232
+void
+__indirect_glEndQueryARB(GLenum target)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_EndQueryARB, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLsop_GetQueryivARB 164
+void
+__indirect_glGetQueryivARB(GLenum target, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetQueryivARBRep *reply = XCBGlxGetQueryivARBReply(c, XCBGlxGetQueryivARB(c, gc->currentContextTag, target, pname), NULL);
+ if (XCBGlxGetQueryivARBDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetQueryivARBData(reply), XCBGlxGetQueryivARBDataLength(reply) * sizeof(GLint));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetQueryivARB, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetQueryObjectivARB 165
+void
+__indirect_glGetQueryObjectivARB(GLuint id, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetQueryObjectivARBRep *reply = XCBGlxGetQueryObjectivARBReply(c, XCBGlxGetQueryObjectivARB(c, gc->currentContextTag, id, pname), NULL);
+ if (XCBGlxGetQueryObjectivARBDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetQueryObjectivARBData(reply), XCBGlxGetQueryObjectivARBDataLength(reply) * sizeof(GLint));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetQueryObjectivARB, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&id), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLsop_GetQueryObjectuivARB 166
+void
+__indirect_glGetQueryObjectuivARB(GLuint id, GLenum pname, GLuint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+#ifdef USE_XCB
+ XCBConnection *c = XCBConnectionOfDisplay(dpy);
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ XCBGlxGetQueryObjectuivARBRep *reply = XCBGlxGetQueryObjectuivARBReply(c, XCBGlxGetQueryObjectuivARB(c, gc->currentContextTag, id, pname), NULL);
+ if (XCBGlxGetQueryObjectuivARBDataLength(reply) == 0)
+ (void)memcpy(params, &reply->datum, sizeof(reply->datum));
+ else
+ (void)memcpy(params, XCBGlxGetQueryObjectuivARBData(reply), XCBGlxGetQueryObjectuivARBDataLength(reply) * sizeof(GLuint));
+ free(reply);
+#else
+ GLubyte const * pc = __glXSetupSingleRequest(gc, X_GLsop_GetQueryObjectuivARB, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&id), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+#endif /* USE_XCB */
+ }
+ return;
+}
+
+#define X_GLvop_GetVertexAttribdvNV 1301
+void
+__indirect_glGetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GetVertexAttribdvNV, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&index), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 8, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLvop_GetVertexAttribfvNV 1302
+void
+__indirect_glGetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GetVertexAttribfvNV, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&index), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLvop_GetVertexAttribivNV 1303
+void
+__indirect_glGetVertexAttribivNV(GLuint index, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GetVertexAttribivNV, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&index), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLrop_VertexAttrib1dvNV 4197
+void
+__indirect_glVertexAttrib1dNV(GLuint index, GLdouble x)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib1dvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib1dvNV 4197
+void
+__indirect_glVertexAttrib1dvNV(GLuint index, const GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib1dvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib1fvNV 4193
+void
+__indirect_glVertexAttrib1fNV(GLuint index, GLfloat x)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib1fvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib1fvNV 4193
+void
+__indirect_glVertexAttrib1fvNV(GLuint index, const GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib1fvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib1svNV 4189
+void
+__indirect_glVertexAttrib1sNV(GLuint index, GLshort x)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib1svNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib1svNV 4189
+void
+__indirect_glVertexAttrib1svNV(GLuint index, const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib1svNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib2dvNV 4198
+void
+__indirect_glVertexAttrib2dNV(GLuint index, GLdouble x, GLdouble y)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_VertexAttrib2dvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&y), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib2dvNV 4198
+void
+__indirect_glVertexAttrib2dvNV(GLuint index, const GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_VertexAttrib2dvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 16);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib2fvNV 4194
+void
+__indirect_glVertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib2fvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib2fvNV 4194
+void
+__indirect_glVertexAttrib2fvNV(GLuint index, const GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib2fvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib2svNV 4190
+void
+__indirect_glVertexAttrib2sNV(GLuint index, GLshort x, GLshort y)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib2svNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 2);
+ (void) memcpy((void *)(gc->pc + 10), (void *)(&y), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib2svNV 4190
+void
+__indirect_glVertexAttrib2svNV(GLuint index, const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib2svNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib3dvNV 4199
+void
+__indirect_glVertexAttrib3dNV(GLuint index, GLdouble x, GLdouble y, GLdouble z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 32;
+ emit_header(gc->pc, X_GLrop_VertexAttrib3dvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&y), 8);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&z), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib3dvNV 4199
+void
+__indirect_glVertexAttrib3dvNV(GLuint index, const GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 32;
+ emit_header(gc->pc, X_GLrop_VertexAttrib3dvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 24);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib3fvNV 4195
+void
+__indirect_glVertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_VertexAttrib3fvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&z), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib3fvNV 4195
+void
+__indirect_glVertexAttrib3fvNV(GLuint index, const GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_VertexAttrib3fvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 12);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib3svNV 4191
+void
+__indirect_glVertexAttrib3sNV(GLuint index, GLshort x, GLshort y, GLshort z)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib3svNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 2);
+ (void) memcpy((void *)(gc->pc + 10), (void *)(&y), 2);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&z), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib3svNV 4191
+void
+__indirect_glVertexAttrib3svNV(GLuint index, const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib3svNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 6);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4dvNV 4200
+void
+__indirect_glVertexAttrib4dNV(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 40;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4dvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 8);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&y), 8);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&z), 8);
+ (void) memcpy((void *)(gc->pc + 32), (void *)(&w), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4dvNV 4200
+void
+__indirect_glVertexAttrib4dvNV(GLuint index, const GLdouble * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 40;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4dvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 32);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4fvNV 4196
+void
+__indirect_glVertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4fvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&y), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&z), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&w), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4fvNV 4196
+void
+__indirect_glVertexAttrib4fvNV(GLuint index, const GLfloat * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4fvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 16);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4svNV 4192
+void
+__indirect_glVertexAttrib4sNV(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4svNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 2);
+ (void) memcpy((void *)(gc->pc + 10), (void *)(&y), 2);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&z), 2);
+ (void) memcpy((void *)(gc->pc + 14), (void *)(&w), 2);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4svNV 4192
+void
+__indirect_glVertexAttrib4svNV(GLuint index, const GLshort * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 16;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4svNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 8);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4ubvNV 4201
+void
+__indirect_glVertexAttrib4ubNV(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4ubvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&x), 1);
+ (void) memcpy((void *)(gc->pc + 9), (void *)(&y), 1);
+ (void) memcpy((void *)(gc->pc + 10), (void *)(&z), 1);
+ (void) memcpy((void *)(gc->pc + 11), (void *)(&w), 1);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_VertexAttrib4ubvNV 4201
+void
+__indirect_glVertexAttrib4ubvNV(GLuint index, const GLubyte * v)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_VertexAttrib4ubvNV, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&index), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(v), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLvop_IsRenderbufferEXT 1422
+GLboolean
+__indirect_glIsRenderbufferEXT(GLuint renderbuffer)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ GLboolean retval = (GLboolean) 0;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_IsRenderbufferEXT, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&renderbuffer), 4);
+ retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return retval;
+}
+
+#define X_GLrop_BindRenderbufferEXT 4316
+void
+__indirect_glBindRenderbufferEXT(GLenum target, GLuint renderbuffer)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_BindRenderbufferEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&renderbuffer), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_DeleteRenderbuffersEXT 4317
+void
+__indirect_glDeleteRenderbuffersEXT(GLsizei n, const GLuint * renderbuffers)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8 + __GLX_PAD((n * 4));
+ if (__builtin_expect(n >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_DeleteRenderbuffersEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(renderbuffers), (n * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLvop_GenRenderbuffersEXT 1423
+void
+__indirect_glGenRenderbuffersEXT(GLsizei n, GLuint * renderbuffers)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GenRenderbuffersEXT, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&n), 4);
+ (void) __glXReadReply(dpy, 4, renderbuffers, GL_TRUE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLrop_RenderbufferStorageEXT 4318
+void
+__indirect_glRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_RenderbufferStorageEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&internalformat), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&width), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&height), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLvop_GetRenderbufferParameterivEXT 1424
+void
+__indirect_glGetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GetRenderbufferParameterivEXT, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLvop_IsFramebufferEXT 1425
+GLboolean
+__indirect_glIsFramebufferEXT(GLuint framebuffer)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ GLboolean retval = (GLboolean) 0;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_IsFramebufferEXT, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&framebuffer), 4);
+ retval = (GLboolean) __glXReadReply(dpy, 0, NULL, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return retval;
+}
+
+#define X_GLrop_BindFramebufferEXT 4319
+void
+__indirect_glBindFramebufferEXT(GLenum target, GLuint framebuffer)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 12;
+ emit_header(gc->pc, X_GLrop_BindFramebufferEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&framebuffer), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_DeleteFramebuffersEXT 4320
+void
+__indirect_glDeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8 + __GLX_PAD((n * 4));
+ if (__builtin_expect(n >= 0, 1)) {
+ emit_header(gc->pc, X_GLrop_DeleteFramebuffersEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&n), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(framebuffers), (n * 4));
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+ }
+}
+
+#define X_GLvop_GenFramebuffersEXT 1426
+void
+__indirect_glGenFramebuffersEXT(GLsizei n, GLuint * framebuffers)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect((n >= 0) && (dpy != NULL), 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GenFramebuffersEXT, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&n), 4);
+ (void) __glXReadReply(dpy, 4, framebuffers, GL_TRUE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLvop_CheckFramebufferStatusEXT 1427
+GLenum
+__indirect_glCheckFramebufferStatusEXT(GLenum target)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ GLenum retval = (GLenum) 0;
+ const GLuint cmdlen = 4;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_CheckFramebufferStatusEXT, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ retval = (GLenum) __glXReadReply(dpy, 0, NULL, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return retval;
+}
+
+#define X_GLrop_FramebufferTexture1DEXT 4321
+void
+__indirect_glFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_FramebufferTexture1DEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&attachment), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&textarget), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&texture), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&level), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_FramebufferTexture2DEXT 4322
+void
+__indirect_glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 24;
+ emit_header(gc->pc, X_GLrop_FramebufferTexture2DEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&attachment), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&textarget), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&texture), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&level), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_FramebufferTexture3DEXT 4323
+void
+__indirect_glFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 28;
+ emit_header(gc->pc, X_GLrop_FramebufferTexture3DEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&attachment), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&textarget), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&texture), 4);
+ (void) memcpy((void *)(gc->pc + 20), (void *)(&level), 4);
+ (void) memcpy((void *)(gc->pc + 24), (void *)(&zoffset), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLrop_FramebufferRenderbufferEXT 4324
+void
+__indirect_glFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 20;
+ emit_header(gc->pc, X_GLrop_FramebufferRenderbufferEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ (void) memcpy((void *)(gc->pc + 8), (void *)(&attachment), 4);
+ (void) memcpy((void *)(gc->pc + 12), (void *)(&renderbuffertarget), 4);
+ (void) memcpy((void *)(gc->pc + 16), (void *)(&renderbuffer), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+#define X_GLvop_GetFramebufferAttachmentParameterivEXT 1428
+void
+__indirect_glGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint * params)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 12;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply, X_GLvop_GetFramebufferAttachmentParameterivEXT, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&target), 4);
+ (void) memcpy((void *)(pc + 4), (void *)(&attachment), 4);
+ (void) memcpy((void *)(pc + 8), (void *)(&pname), 4);
+ (void) __glXReadReply(dpy, 4, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+#define X_GLrop_GenerateMipmapEXT 4325
+void
+__indirect_glGenerateMipmapEXT(GLenum target)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = 8;
+ emit_header(gc->pc, X_GLrop_GenerateMipmapEXT, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), (void *)(&target), 4);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+
+
+# undef FASTCALL
+# undef NOINLINE
diff --git a/nx-X11/extras/Mesa/src/glx/x11/indirect.h b/nx-X11/extras/Mesa/src/glx/x11/indirect.h
new file mode 100644
index 000000000..1c45fa28a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/indirect.h
@@ -0,0 +1,707 @@
+/* DO NOT EDIT - This file generated automatically by glX_proto_send.py (from Mesa) script */
+
+/*
+ * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+ * (C) Copyright IBM Corporation 2004
+ * 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, IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#if !defined( _INDIRECT_H_ )
+# define _INDIRECT_H_
+
+/**
+ * \file
+ * Prototypes for indirect rendering functions.
+ *
+ * \author Kevin E. Martin <kevin@precisioninsight.com>
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__)
+# define HIDDEN __attribute__((visibility("hidden")))
+# else
+# define HIDDEN
+# endif
+# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__)
+# define FASTCALL __attribute__((fastcall))
+# else
+# define FASTCALL
+# endif
+# if defined(__GNUC__)
+# define NOINLINE __attribute__((noinline))
+# else
+# define NOINLINE
+# endif
+
+#include "glxclient.h"
+
+extern HIDDEN NOINLINE CARD32 __glXReadReply( Display *dpy, size_t size,
+ void * dest, GLboolean reply_is_always_array );
+
+extern HIDDEN NOINLINE void __glXReadPixelReply( Display *dpy,
+ __GLXcontext * gc, unsigned max_dim, GLint width, GLint height,
+ GLint depth, GLenum format, GLenum type, void * dest,
+ GLboolean dimensions_in_reply );
+
+extern HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupSingleRequest(
+ __GLXcontext * gc, GLint sop, GLint cmdlen );
+
+extern HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupVendorRequest(
+ __GLXcontext * gc, GLint code, GLint vop, GLint cmdlen );
+
+extern HIDDEN void __indirect_glNewList(GLuint list, GLenum mode);
+extern HIDDEN void __indirect_glEndList(void);
+extern HIDDEN void __indirect_glCallList(GLuint list);
+extern HIDDEN void __indirect_glCallLists(GLsizei n, GLenum type, const GLvoid * lists);
+extern HIDDEN void __indirect_glDeleteLists(GLuint list, GLsizei range);
+extern HIDDEN GLuint __indirect_glGenLists(GLsizei range);
+extern HIDDEN void __indirect_glListBase(GLuint base);
+extern HIDDEN void __indirect_glBegin(GLenum mode);
+extern HIDDEN void __indirect_glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap);
+extern HIDDEN void __indirect_glColor3b(GLbyte red, GLbyte green, GLbyte blue);
+extern HIDDEN void __indirect_glColor3bv(const GLbyte * v);
+extern HIDDEN void __indirect_glColor3d(GLdouble red, GLdouble green, GLdouble blue);
+extern HIDDEN void __indirect_glColor3dv(const GLdouble * v);
+extern HIDDEN void __indirect_glColor3f(GLfloat red, GLfloat green, GLfloat blue);
+extern HIDDEN void __indirect_glColor3fv(const GLfloat * v);
+extern HIDDEN void __indirect_glColor3i(GLint red, GLint green, GLint blue);
+extern HIDDEN void __indirect_glColor3iv(const GLint * v);
+extern HIDDEN void __indirect_glColor3s(GLshort red, GLshort green, GLshort blue);
+extern HIDDEN void __indirect_glColor3sv(const GLshort * v);
+extern HIDDEN void __indirect_glColor3ub(GLubyte red, GLubyte green, GLubyte blue);
+extern HIDDEN void __indirect_glColor3ubv(const GLubyte * v);
+extern HIDDEN void __indirect_glColor3ui(GLuint red, GLuint green, GLuint blue);
+extern HIDDEN void __indirect_glColor3uiv(const GLuint * v);
+extern HIDDEN void __indirect_glColor3us(GLushort red, GLushort green, GLushort blue);
+extern HIDDEN void __indirect_glColor3usv(const GLushort * v);
+extern HIDDEN void __indirect_glColor4b(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha);
+extern HIDDEN void __indirect_glColor4bv(const GLbyte * v);
+extern HIDDEN void __indirect_glColor4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha);
+extern HIDDEN void __indirect_glColor4dv(const GLdouble * v);
+extern HIDDEN void __indirect_glColor4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+extern HIDDEN void __indirect_glColor4fv(const GLfloat * v);
+extern HIDDEN void __indirect_glColor4i(GLint red, GLint green, GLint blue, GLint alpha);
+extern HIDDEN void __indirect_glColor4iv(const GLint * v);
+extern HIDDEN void __indirect_glColor4s(GLshort red, GLshort green, GLshort blue, GLshort alpha);
+extern HIDDEN void __indirect_glColor4sv(const GLshort * v);
+extern HIDDEN void __indirect_glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha);
+extern HIDDEN void __indirect_glColor4ubv(const GLubyte * v);
+extern HIDDEN void __indirect_glColor4ui(GLuint red, GLuint green, GLuint blue, GLuint alpha);
+extern HIDDEN void __indirect_glColor4uiv(const GLuint * v);
+extern HIDDEN void __indirect_glColor4us(GLushort red, GLushort green, GLushort blue, GLushort alpha);
+extern HIDDEN void __indirect_glColor4usv(const GLushort * v);
+extern HIDDEN void __indirect_glEdgeFlag(GLboolean flag);
+extern HIDDEN void __indirect_glEdgeFlagv(const GLboolean * flag);
+extern HIDDEN void __indirect_glEnd(void);
+extern HIDDEN void __indirect_glIndexd(GLdouble c);
+extern HIDDEN void __indirect_glIndexdv(const GLdouble * c);
+extern HIDDEN void __indirect_glIndexf(GLfloat c);
+extern HIDDEN void __indirect_glIndexfv(const GLfloat * c);
+extern HIDDEN void __indirect_glIndexi(GLint c);
+extern HIDDEN void __indirect_glIndexiv(const GLint * c);
+extern HIDDEN void __indirect_glIndexs(GLshort c);
+extern HIDDEN void __indirect_glIndexsv(const GLshort * c);
+extern HIDDEN void __indirect_glNormal3b(GLbyte nx, GLbyte ny, GLbyte nz);
+extern HIDDEN void __indirect_glNormal3bv(const GLbyte * v);
+extern HIDDEN void __indirect_glNormal3d(GLdouble nx, GLdouble ny, GLdouble nz);
+extern HIDDEN void __indirect_glNormal3dv(const GLdouble * v);
+extern HIDDEN void __indirect_glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz);
+extern HIDDEN void __indirect_glNormal3fv(const GLfloat * v);
+extern HIDDEN void __indirect_glNormal3i(GLint nx, GLint ny, GLint nz);
+extern HIDDEN void __indirect_glNormal3iv(const GLint * v);
+extern HIDDEN void __indirect_glNormal3s(GLshort nx, GLshort ny, GLshort nz);
+extern HIDDEN void __indirect_glNormal3sv(const GLshort * v);
+extern HIDDEN void __indirect_glRasterPos2d(GLdouble x, GLdouble y);
+extern HIDDEN void __indirect_glRasterPos2dv(const GLdouble * v);
+extern HIDDEN void __indirect_glRasterPos2f(GLfloat x, GLfloat y);
+extern HIDDEN void __indirect_glRasterPos2fv(const GLfloat * v);
+extern HIDDEN void __indirect_glRasterPos2i(GLint x, GLint y);
+extern HIDDEN void __indirect_glRasterPos2iv(const GLint * v);
+extern HIDDEN void __indirect_glRasterPos2s(GLshort x, GLshort y);
+extern HIDDEN void __indirect_glRasterPos2sv(const GLshort * v);
+extern HIDDEN void __indirect_glRasterPos3d(GLdouble x, GLdouble y, GLdouble z);
+extern HIDDEN void __indirect_glRasterPos3dv(const GLdouble * v);
+extern HIDDEN void __indirect_glRasterPos3f(GLfloat x, GLfloat y, GLfloat z);
+extern HIDDEN void __indirect_glRasterPos3fv(const GLfloat * v);
+extern HIDDEN void __indirect_glRasterPos3i(GLint x, GLint y, GLint z);
+extern HIDDEN void __indirect_glRasterPos3iv(const GLint * v);
+extern HIDDEN void __indirect_glRasterPos3s(GLshort x, GLshort y, GLshort z);
+extern HIDDEN void __indirect_glRasterPos3sv(const GLshort * v);
+extern HIDDEN void __indirect_glRasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+extern HIDDEN void __indirect_glRasterPos4dv(const GLdouble * v);
+extern HIDDEN void __indirect_glRasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+extern HIDDEN void __indirect_glRasterPos4fv(const GLfloat * v);
+extern HIDDEN void __indirect_glRasterPos4i(GLint x, GLint y, GLint z, GLint w);
+extern HIDDEN void __indirect_glRasterPos4iv(const GLint * v);
+extern HIDDEN void __indirect_glRasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w);
+extern HIDDEN void __indirect_glRasterPos4sv(const GLshort * v);
+extern HIDDEN void __indirect_glRectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2);
+extern HIDDEN void __indirect_glRectdv(const GLdouble * v1, const GLdouble * v2);
+extern HIDDEN void __indirect_glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
+extern HIDDEN void __indirect_glRectfv(const GLfloat * v1, const GLfloat * v2);
+extern HIDDEN void __indirect_glRecti(GLint x1, GLint y1, GLint x2, GLint y2);
+extern HIDDEN void __indirect_glRectiv(const GLint * v1, const GLint * v2);
+extern HIDDEN void __indirect_glRects(GLshort x1, GLshort y1, GLshort x2, GLshort y2);
+extern HIDDEN void __indirect_glRectsv(const GLshort * v1, const GLshort * v2);
+extern HIDDEN void __indirect_glTexCoord1d(GLdouble s);
+extern HIDDEN void __indirect_glTexCoord1dv(const GLdouble * v);
+extern HIDDEN void __indirect_glTexCoord1f(GLfloat s);
+extern HIDDEN void __indirect_glTexCoord1fv(const GLfloat * v);
+extern HIDDEN void __indirect_glTexCoord1i(GLint s);
+extern HIDDEN void __indirect_glTexCoord1iv(const GLint * v);
+extern HIDDEN void __indirect_glTexCoord1s(GLshort s);
+extern HIDDEN void __indirect_glTexCoord1sv(const GLshort * v);
+extern HIDDEN void __indirect_glTexCoord2d(GLdouble s, GLdouble t);
+extern HIDDEN void __indirect_glTexCoord2dv(const GLdouble * v);
+extern HIDDEN void __indirect_glTexCoord2f(GLfloat s, GLfloat t);
+extern HIDDEN void __indirect_glTexCoord2fv(const GLfloat * v);
+extern HIDDEN void __indirect_glTexCoord2i(GLint s, GLint t);
+extern HIDDEN void __indirect_glTexCoord2iv(const GLint * v);
+extern HIDDEN void __indirect_glTexCoord2s(GLshort s, GLshort t);
+extern HIDDEN void __indirect_glTexCoord2sv(const GLshort * v);
+extern HIDDEN void __indirect_glTexCoord3d(GLdouble s, GLdouble t, GLdouble r);
+extern HIDDEN void __indirect_glTexCoord3dv(const GLdouble * v);
+extern HIDDEN void __indirect_glTexCoord3f(GLfloat s, GLfloat t, GLfloat r);
+extern HIDDEN void __indirect_glTexCoord3fv(const GLfloat * v);
+extern HIDDEN void __indirect_glTexCoord3i(GLint s, GLint t, GLint r);
+extern HIDDEN void __indirect_glTexCoord3iv(const GLint * v);
+extern HIDDEN void __indirect_glTexCoord3s(GLshort s, GLshort t, GLshort r);
+extern HIDDEN void __indirect_glTexCoord3sv(const GLshort * v);
+extern HIDDEN void __indirect_glTexCoord4d(GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+extern HIDDEN void __indirect_glTexCoord4dv(const GLdouble * v);
+extern HIDDEN void __indirect_glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+extern HIDDEN void __indirect_glTexCoord4fv(const GLfloat * v);
+extern HIDDEN void __indirect_glTexCoord4i(GLint s, GLint t, GLint r, GLint q);
+extern HIDDEN void __indirect_glTexCoord4iv(const GLint * v);
+extern HIDDEN void __indirect_glTexCoord4s(GLshort s, GLshort t, GLshort r, GLshort q);
+extern HIDDEN void __indirect_glTexCoord4sv(const GLshort * v);
+extern HIDDEN void __indirect_glVertex2d(GLdouble x, GLdouble y);
+extern HIDDEN void __indirect_glVertex2dv(const GLdouble * v);
+extern HIDDEN void __indirect_glVertex2f(GLfloat x, GLfloat y);
+extern HIDDEN void __indirect_glVertex2fv(const GLfloat * v);
+extern HIDDEN void __indirect_glVertex2i(GLint x, GLint y);
+extern HIDDEN void __indirect_glVertex2iv(const GLint * v);
+extern HIDDEN void __indirect_glVertex2s(GLshort x, GLshort y);
+extern HIDDEN void __indirect_glVertex2sv(const GLshort * v);
+extern HIDDEN void __indirect_glVertex3d(GLdouble x, GLdouble y, GLdouble z);
+extern HIDDEN void __indirect_glVertex3dv(const GLdouble * v);
+extern HIDDEN void __indirect_glVertex3f(GLfloat x, GLfloat y, GLfloat z);
+extern HIDDEN void __indirect_glVertex3fv(const GLfloat * v);
+extern HIDDEN void __indirect_glVertex3i(GLint x, GLint y, GLint z);
+extern HIDDEN void __indirect_glVertex3iv(const GLint * v);
+extern HIDDEN void __indirect_glVertex3s(GLshort x, GLshort y, GLshort z);
+extern HIDDEN void __indirect_glVertex3sv(const GLshort * v);
+extern HIDDEN void __indirect_glVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+extern HIDDEN void __indirect_glVertex4dv(const GLdouble * v);
+extern HIDDEN void __indirect_glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+extern HIDDEN void __indirect_glVertex4fv(const GLfloat * v);
+extern HIDDEN void __indirect_glVertex4i(GLint x, GLint y, GLint z, GLint w);
+extern HIDDEN void __indirect_glVertex4iv(const GLint * v);
+extern HIDDEN void __indirect_glVertex4s(GLshort x, GLshort y, GLshort z, GLshort w);
+extern HIDDEN void __indirect_glVertex4sv(const GLshort * v);
+extern HIDDEN void __indirect_glClipPlane(GLenum plane, const GLdouble * equation);
+extern HIDDEN void __indirect_glColorMaterial(GLenum face, GLenum mode);
+extern HIDDEN void __indirect_glCullFace(GLenum mode);
+extern HIDDEN void __indirect_glFogf(GLenum pname, GLfloat param);
+extern HIDDEN void __indirect_glFogfv(GLenum pname, const GLfloat * params);
+extern HIDDEN void __indirect_glFogi(GLenum pname, GLint param);
+extern HIDDEN void __indirect_glFogiv(GLenum pname, const GLint * params);
+extern HIDDEN void __indirect_glFrontFace(GLenum mode);
+extern HIDDEN void __indirect_glHint(GLenum target, GLenum mode);
+extern HIDDEN void __indirect_glLightf(GLenum light, GLenum pname, GLfloat param);
+extern HIDDEN void __indirect_glLightfv(GLenum light, GLenum pname, const GLfloat * params);
+extern HIDDEN void __indirect_glLighti(GLenum light, GLenum pname, GLint param);
+extern HIDDEN void __indirect_glLightiv(GLenum light, GLenum pname, const GLint * params);
+extern HIDDEN void __indirect_glLightModelf(GLenum pname, GLfloat param);
+extern HIDDEN void __indirect_glLightModelfv(GLenum pname, const GLfloat * params);
+extern HIDDEN void __indirect_glLightModeli(GLenum pname, GLint param);
+extern HIDDEN void __indirect_glLightModeliv(GLenum pname, const GLint * params);
+extern HIDDEN void __indirect_glLineStipple(GLint factor, GLushort pattern);
+extern HIDDEN void __indirect_glLineWidth(GLfloat width);
+extern HIDDEN void __indirect_glMaterialf(GLenum face, GLenum pname, GLfloat param);
+extern HIDDEN void __indirect_glMaterialfv(GLenum face, GLenum pname, const GLfloat * params);
+extern HIDDEN void __indirect_glMateriali(GLenum face, GLenum pname, GLint param);
+extern HIDDEN void __indirect_glMaterialiv(GLenum face, GLenum pname, const GLint * params);
+extern HIDDEN void __indirect_glPointSize(GLfloat size);
+extern HIDDEN void __indirect_glPolygonMode(GLenum face, GLenum mode);
+extern HIDDEN void __indirect_glPolygonStipple(const GLubyte * mask);
+extern HIDDEN void __indirect_glScissor(GLint x, GLint y, GLsizei width, GLsizei height);
+extern HIDDEN void __indirect_glShadeModel(GLenum mode);
+extern HIDDEN void __indirect_glTexParameterf(GLenum target, GLenum pname, GLfloat param);
+extern HIDDEN void __indirect_glTexParameterfv(GLenum target, GLenum pname, const GLfloat * params);
+extern HIDDEN void __indirect_glTexParameteri(GLenum target, GLenum pname, GLint param);
+extern HIDDEN void __indirect_glTexParameteriv(GLenum target, GLenum pname, const GLint * params);
+extern HIDDEN void __indirect_glTexImage1D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid * pixels);
+extern HIDDEN void __indirect_glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels);
+extern HIDDEN void __indirect_glTexEnvf(GLenum target, GLenum pname, GLfloat param);
+extern HIDDEN void __indirect_glTexEnvfv(GLenum target, GLenum pname, const GLfloat * params);
+extern HIDDEN void __indirect_glTexEnvi(GLenum target, GLenum pname, GLint param);
+extern HIDDEN void __indirect_glTexEnviv(GLenum target, GLenum pname, const GLint * params);
+extern HIDDEN void __indirect_glTexGend(GLenum coord, GLenum pname, GLdouble param);
+extern HIDDEN void __indirect_glTexGendv(GLenum coord, GLenum pname, const GLdouble * params);
+extern HIDDEN void __indirect_glTexGenf(GLenum coord, GLenum pname, GLfloat param);
+extern HIDDEN void __indirect_glTexGenfv(GLenum coord, GLenum pname, const GLfloat * params);
+extern HIDDEN void __indirect_glTexGeni(GLenum coord, GLenum pname, GLint param);
+extern HIDDEN void __indirect_glTexGeniv(GLenum coord, GLenum pname, const GLint * params);
+extern HIDDEN void __indirect_glFeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer);
+extern HIDDEN void __indirect_glSelectBuffer(GLsizei size, GLuint * buffer);
+extern HIDDEN GLint __indirect_glRenderMode(GLenum mode);
+extern HIDDEN void __indirect_glInitNames(void);
+extern HIDDEN void __indirect_glLoadName(GLuint name);
+extern HIDDEN void __indirect_glPassThrough(GLfloat token);
+extern HIDDEN void __indirect_glPopName(void);
+extern HIDDEN void __indirect_glPushName(GLuint name);
+extern HIDDEN void __indirect_glDrawBuffer(GLenum mode);
+extern HIDDEN void __indirect_glClear(GLbitfield mask);
+extern HIDDEN void __indirect_glClearAccum(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
+extern HIDDEN void __indirect_glClearIndex(GLfloat c);
+extern HIDDEN void __indirect_glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+extern HIDDEN void __indirect_glClearStencil(GLint s);
+extern HIDDEN void __indirect_glClearDepth(GLclampd depth);
+extern HIDDEN void __indirect_glStencilMask(GLuint mask);
+extern HIDDEN void __indirect_glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+extern HIDDEN void __indirect_glDepthMask(GLboolean flag);
+extern HIDDEN void __indirect_glIndexMask(GLuint mask);
+extern HIDDEN void __indirect_glAccum(GLenum op, GLfloat value);
+extern HIDDEN void __indirect_glDisable(GLenum cap);
+extern HIDDEN void __indirect_glEnable(GLenum cap);
+extern HIDDEN void __indirect_glFinish(void);
+extern HIDDEN void __indirect_glFlush(void);
+extern HIDDEN void __indirect_glPopAttrib(void);
+extern HIDDEN void __indirect_glPushAttrib(GLbitfield mask);
+extern HIDDEN void __indirect_glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble * points);
+extern HIDDEN void __indirect_glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat * points);
+extern HIDDEN void __indirect_glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble * points);
+extern HIDDEN void __indirect_glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat * points);
+extern HIDDEN void __indirect_glMapGrid1d(GLint un, GLdouble u1, GLdouble u2);
+extern HIDDEN void __indirect_glMapGrid1f(GLint un, GLfloat u1, GLfloat u2);
+extern HIDDEN void __indirect_glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2);
+extern HIDDEN void __indirect_glMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2);
+extern HIDDEN void __indirect_glEvalCoord1d(GLdouble u);
+extern HIDDEN void __indirect_glEvalCoord1dv(const GLdouble * u);
+extern HIDDEN void __indirect_glEvalCoord1f(GLfloat u);
+extern HIDDEN void __indirect_glEvalCoord1fv(const GLfloat * u);
+extern HIDDEN void __indirect_glEvalCoord2d(GLdouble u, GLdouble v);
+extern HIDDEN void __indirect_glEvalCoord2dv(const GLdouble * u);
+extern HIDDEN void __indirect_glEvalCoord2f(GLfloat u, GLfloat v);
+extern HIDDEN void __indirect_glEvalCoord2fv(const GLfloat * u);
+extern HIDDEN void __indirect_glEvalMesh1(GLenum mode, GLint i1, GLint i2);
+extern HIDDEN void __indirect_glEvalPoint1(GLint i);
+extern HIDDEN void __indirect_glEvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2);
+extern HIDDEN void __indirect_glEvalPoint2(GLint i, GLint j);
+extern HIDDEN void __indirect_glAlphaFunc(GLenum func, GLclampf ref);
+extern HIDDEN void __indirect_glBlendFunc(GLenum sfactor, GLenum dfactor);
+extern HIDDEN void __indirect_glLogicOp(GLenum opcode);
+extern HIDDEN void __indirect_glStencilFunc(GLenum func, GLint ref, GLuint mask);
+extern HIDDEN void __indirect_glStencilOp(GLenum fail, GLenum zfail, GLenum zpass);
+extern HIDDEN void __indirect_glDepthFunc(GLenum func);
+extern HIDDEN void __indirect_glPixelZoom(GLfloat xfactor, GLfloat yfactor);
+extern HIDDEN void __indirect_glPixelTransferf(GLenum pname, GLfloat param);
+extern HIDDEN void __indirect_glPixelTransferi(GLenum pname, GLint param);
+extern HIDDEN void __indirect_glPixelStoref(GLenum pname, GLfloat param);
+extern HIDDEN void __indirect_glPixelStorei(GLenum pname, GLint param);
+extern HIDDEN void __indirect_glPixelMapfv(GLenum map, GLsizei mapsize, const GLfloat * values);
+extern HIDDEN void __indirect_glPixelMapuiv(GLenum map, GLsizei mapsize, const GLuint * values);
+extern HIDDEN void __indirect_glPixelMapusv(GLenum map, GLsizei mapsize, const GLushort * values);
+extern HIDDEN void __indirect_glReadBuffer(GLenum mode);
+extern HIDDEN void __indirect_glCopyPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type);
+extern HIDDEN void __indirect_glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * pixels);
+extern HIDDEN void __indirect_glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels);
+extern HIDDEN void __indirect_glGetBooleanv(GLenum pname, GLboolean * params);
+extern HIDDEN void __indirect_glGetClipPlane(GLenum plane, GLdouble * equation);
+extern HIDDEN void __indirect_glGetDoublev(GLenum pname, GLdouble * params);
+extern HIDDEN GLenum __indirect_glGetError(void);
+extern HIDDEN void __indirect_glGetFloatv(GLenum pname, GLfloat * params);
+extern HIDDEN void __indirect_glGetIntegerv(GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glGetLightfv(GLenum light, GLenum pname, GLfloat * params);
+extern HIDDEN void __indirect_glGetLightiv(GLenum light, GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glGetMapdv(GLenum target, GLenum query, GLdouble * v);
+extern HIDDEN void __indirect_glGetMapfv(GLenum target, GLenum query, GLfloat * v);
+extern HIDDEN void __indirect_glGetMapiv(GLenum target, GLenum query, GLint * v);
+extern HIDDEN void __indirect_glGetMaterialfv(GLenum face, GLenum pname, GLfloat * params);
+extern HIDDEN void __indirect_glGetMaterialiv(GLenum face, GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glGetPixelMapfv(GLenum map, GLfloat * values);
+extern HIDDEN void __indirect_glGetPixelMapuiv(GLenum map, GLuint * values);
+extern HIDDEN void __indirect_glGetPixelMapusv(GLenum map, GLushort * values);
+extern HIDDEN void __indirect_glGetPolygonStipple(GLubyte * mask);
+extern HIDDEN const GLubyte * __indirect_glGetString(GLenum name);
+extern HIDDEN void __indirect_glGetTexEnvfv(GLenum target, GLenum pname, GLfloat * params);
+extern HIDDEN void __indirect_glGetTexEnviv(GLenum target, GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glGetTexGendv(GLenum coord, GLenum pname, GLdouble * params);
+extern HIDDEN void __indirect_glGetTexGenfv(GLenum coord, GLenum pname, GLfloat * params);
+extern HIDDEN void __indirect_glGetTexGeniv(GLenum coord, GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, GLvoid * pixels);
+extern HIDDEN void __indirect_glGetTexParameterfv(GLenum target, GLenum pname, GLfloat * params);
+extern HIDDEN void __indirect_glGetTexParameteriv(GLenum target, GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glGetTexLevelParameterfv(GLenum target, GLint level, GLenum pname, GLfloat * params);
+extern HIDDEN void __indirect_glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint * params);
+extern HIDDEN GLboolean __indirect_glIsEnabled(GLenum cap);
+extern HIDDEN GLboolean __indirect_glIsList(GLuint list);
+extern HIDDEN void __indirect_glDepthRange(GLclampd zNear, GLclampd zFar);
+extern HIDDEN void __indirect_glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+extern HIDDEN void __indirect_glLoadIdentity(void);
+extern HIDDEN void __indirect_glLoadMatrixf(const GLfloat * m);
+extern HIDDEN void __indirect_glLoadMatrixd(const GLdouble * m);
+extern HIDDEN void __indirect_glMatrixMode(GLenum mode);
+extern HIDDEN void __indirect_glMultMatrixf(const GLfloat * m);
+extern HIDDEN void __indirect_glMultMatrixd(const GLdouble * m);
+extern HIDDEN void __indirect_glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+extern HIDDEN void __indirect_glPopMatrix(void);
+extern HIDDEN void __indirect_glPushMatrix(void);
+extern HIDDEN void __indirect_glRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
+extern HIDDEN void __indirect_glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+extern HIDDEN void __indirect_glScaled(GLdouble x, GLdouble y, GLdouble z);
+extern HIDDEN void __indirect_glScalef(GLfloat x, GLfloat y, GLfloat z);
+extern HIDDEN void __indirect_glTranslated(GLdouble x, GLdouble y, GLdouble z);
+extern HIDDEN void __indirect_glTranslatef(GLfloat x, GLfloat y, GLfloat z);
+extern HIDDEN void __indirect_glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
+extern HIDDEN void __indirect_glArrayElement(GLint i);
+extern HIDDEN void __indirect_glBindTexture(GLenum target, GLuint texture);
+extern HIDDEN void __indirect_glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer);
+extern HIDDEN void __indirect_glDisableClientState(GLenum array);
+extern HIDDEN void __indirect_glDrawArrays(GLenum mode, GLint first, GLsizei count);
+extern HIDDEN void __indirect_glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid * indices);
+extern HIDDEN void __indirect_glEdgeFlagPointer(GLsizei stride, const GLvoid * pointer);
+extern HIDDEN void __indirect_glEnableClientState(GLenum array);
+extern HIDDEN void __indirect_glIndexPointer(GLenum type, GLsizei stride, const GLvoid * pointer);
+extern HIDDEN void __indirect_glIndexub(GLubyte c);
+extern HIDDEN void __indirect_glIndexubv(const GLubyte * c);
+extern HIDDEN void __indirect_glInterleavedArrays(GLenum format, GLsizei stride, const GLvoid * pointer);
+extern HIDDEN void __indirect_glNormalPointer(GLenum type, GLsizei stride, const GLvoid * pointer);
+extern HIDDEN void __indirect_glPolygonOffset(GLfloat factor, GLfloat units);
+extern HIDDEN void __indirect_glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer);
+extern HIDDEN void __indirect_glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer);
+extern HIDDEN GLboolean __indirect_glAreTexturesResident(GLsizei n, const GLuint * textures, GLboolean * residences);
+extern HIDDEN void __indirect_glCopyTexImage1D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+extern HIDDEN void __indirect_glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+extern HIDDEN void __indirect_glCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+extern HIDDEN void __indirect_glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+extern HIDDEN void __indirect_glDeleteTextures(GLsizei n, const GLuint * textures);
+extern HIDDEN void __indirect_glGenTextures(GLsizei n, GLuint * textures);
+extern HIDDEN void __indirect_glGetPointerv(GLenum pname, GLvoid ** params);
+extern HIDDEN GLboolean __indirect_glIsTexture(GLuint texture);
+extern HIDDEN void __indirect_glPrioritizeTextures(GLsizei n, const GLuint * textures, const GLclampf * priorities);
+extern HIDDEN void __indirect_glTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid * pixels);
+extern HIDDEN void __indirect_glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels);
+extern HIDDEN void __indirect_glPopClientAttrib(void);
+extern HIDDEN void __indirect_glPushClientAttrib(GLbitfield mask);
+extern HIDDEN void __indirect_glBlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+extern HIDDEN void __indirect_glBlendEquation(GLenum mode);
+extern HIDDEN void __indirect_glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices);
+extern HIDDEN void __indirect_glColorTable(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * table);
+extern HIDDEN void __indirect_glColorTableParameterfv(GLenum target, GLenum pname, const GLfloat * params);
+extern HIDDEN void __indirect_glColorTableParameteriv(GLenum target, GLenum pname, const GLint * params);
+extern HIDDEN void __indirect_glCopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+extern HIDDEN void __indirect_glGetColorTable(GLenum target, GLenum format, GLenum type, GLvoid * table);
+extern HIDDEN void __indirect_glGetColorTableParameterfv(GLenum target, GLenum pname, GLfloat * params);
+extern HIDDEN void __indirect_glGetColorTableParameteriv(GLenum target, GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glColorSubTable(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid * data);
+extern HIDDEN void __indirect_glCopyColorSubTable(GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+extern HIDDEN void __indirect_glConvolutionFilter1D(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * image);
+extern HIDDEN void __indirect_glConvolutionFilter2D(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * image);
+extern HIDDEN void __indirect_glConvolutionParameterf(GLenum target, GLenum pname, GLfloat params);
+extern HIDDEN void __indirect_glConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat * params);
+extern HIDDEN void __indirect_glConvolutionParameteri(GLenum target, GLenum pname, GLint params);
+extern HIDDEN void __indirect_glConvolutionParameteriv(GLenum target, GLenum pname, const GLint * params);
+extern HIDDEN void __indirect_glCopyConvolutionFilter1D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+extern HIDDEN void __indirect_glCopyConvolutionFilter2D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+extern HIDDEN void __indirect_glGetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid * image);
+extern HIDDEN void __indirect_glGetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat * params);
+extern HIDDEN void __indirect_glGetConvolutionParameteriv(GLenum target, GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span);
+extern HIDDEN void __indirect_glSeparableFilter2D(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * row, const GLvoid * column);
+extern HIDDEN void __indirect_glGetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values);
+extern HIDDEN void __indirect_glGetHistogramParameterfv(GLenum target, GLenum pname, GLfloat * params);
+extern HIDDEN void __indirect_glGetHistogramParameteriv(GLenum target, GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glGetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values);
+extern HIDDEN void __indirect_glGetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat * params);
+extern HIDDEN void __indirect_glGetMinmaxParameteriv(GLenum target, GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glHistogram(GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+extern HIDDEN void __indirect_glMinmax(GLenum target, GLenum internalformat, GLboolean sink);
+extern HIDDEN void __indirect_glResetHistogram(GLenum target);
+extern HIDDEN void __indirect_glResetMinmax(GLenum target);
+extern HIDDEN void __indirect_glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * pixels);
+extern HIDDEN void __indirect_glTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid * pixels);
+extern HIDDEN void __indirect_glCopyTexSubImage3D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+extern HIDDEN void __indirect_glActiveTextureARB(GLenum texture);
+extern HIDDEN void __indirect_glClientActiveTextureARB(GLenum texture);
+extern HIDDEN void __indirect_glMultiTexCoord1dARB(GLenum target, GLdouble s);
+extern HIDDEN void __indirect_glMultiTexCoord1dvARB(GLenum target, const GLdouble * v);
+extern HIDDEN void __indirect_glMultiTexCoord1fARB(GLenum target, GLfloat s);
+extern HIDDEN void __indirect_glMultiTexCoord1fvARB(GLenum target, const GLfloat * v);
+extern HIDDEN void __indirect_glMultiTexCoord1iARB(GLenum target, GLint s);
+extern HIDDEN void __indirect_glMultiTexCoord1ivARB(GLenum target, const GLint * v);
+extern HIDDEN void __indirect_glMultiTexCoord1sARB(GLenum target, GLshort s);
+extern HIDDEN void __indirect_glMultiTexCoord1svARB(GLenum target, const GLshort * v);
+extern HIDDEN void __indirect_glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t);
+extern HIDDEN void __indirect_glMultiTexCoord2dvARB(GLenum target, const GLdouble * v);
+extern HIDDEN void __indirect_glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t);
+extern HIDDEN void __indirect_glMultiTexCoord2fvARB(GLenum target, const GLfloat * v);
+extern HIDDEN void __indirect_glMultiTexCoord2iARB(GLenum target, GLint s, GLint t);
+extern HIDDEN void __indirect_glMultiTexCoord2ivARB(GLenum target, const GLint * v);
+extern HIDDEN void __indirect_glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t);
+extern HIDDEN void __indirect_glMultiTexCoord2svARB(GLenum target, const GLshort * v);
+extern HIDDEN void __indirect_glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r);
+extern HIDDEN void __indirect_glMultiTexCoord3dvARB(GLenum target, const GLdouble * v);
+extern HIDDEN void __indirect_glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r);
+extern HIDDEN void __indirect_glMultiTexCoord3fvARB(GLenum target, const GLfloat * v);
+extern HIDDEN void __indirect_glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r);
+extern HIDDEN void __indirect_glMultiTexCoord3ivARB(GLenum target, const GLint * v);
+extern HIDDEN void __indirect_glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r);
+extern HIDDEN void __indirect_glMultiTexCoord3svARB(GLenum target, const GLshort * v);
+extern HIDDEN void __indirect_glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+extern HIDDEN void __indirect_glMultiTexCoord4dvARB(GLenum target, const GLdouble * v);
+extern HIDDEN void __indirect_glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+extern HIDDEN void __indirect_glMultiTexCoord4fvARB(GLenum target, const GLfloat * v);
+extern HIDDEN void __indirect_glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q);
+extern HIDDEN void __indirect_glMultiTexCoord4ivARB(GLenum target, const GLint * v);
+extern HIDDEN void __indirect_glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+extern HIDDEN void __indirect_glMultiTexCoord4svARB(GLenum target, const GLshort * v);
+extern HIDDEN void __indirect_glLoadTransposeMatrixfARB(const GLfloat * m);
+extern HIDDEN void __indirect_glLoadTransposeMatrixdARB(const GLdouble * m);
+extern HIDDEN void __indirect_glMultTransposeMatrixfARB(const GLfloat * m);
+extern HIDDEN void __indirect_glMultTransposeMatrixdARB(const GLdouble * m);
+extern HIDDEN void __indirect_glSampleCoverageARB(GLclampf value, GLboolean invert);
+extern HIDDEN void __indirect_glDrawBuffersARB(GLsizei n, const GLenum * bufs);
+extern HIDDEN GLboolean __indirect_glAreTexturesResidentEXT(GLsizei n, const GLuint * textures, GLboolean * residences);
+extern HIDDEN void __indirect_glGenTexturesEXT(GLsizei n, GLuint * textures);
+extern HIDDEN GLboolean __indirect_glIsTextureEXT(GLuint texture);
+extern HIDDEN void __indirect_glSampleMaskSGIS(GLclampf value, GLboolean invert);
+extern HIDDEN void __indirect_glSamplePatternSGIS(GLenum pattern);
+extern HIDDEN void __indirect_glColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer);
+extern HIDDEN void __indirect_glEdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean * pointer);
+extern HIDDEN void __indirect_glIndexPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer);
+extern HIDDEN void __indirect_glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer);
+extern HIDDEN void __indirect_glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer);
+extern HIDDEN void __indirect_glVertexPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer);
+extern HIDDEN void __indirect_glPointParameterfEXT(GLenum pname, GLfloat param);
+extern HIDDEN void __indirect_glPointParameterfvEXT(GLenum pname, const GLfloat * params);
+extern HIDDEN void __indirect_glWindowPos2dMESA(GLdouble x, GLdouble y);
+extern HIDDEN void __indirect_glWindowPos2dvMESA(const GLdouble * v);
+extern HIDDEN void __indirect_glWindowPos2fMESA(GLfloat x, GLfloat y);
+extern HIDDEN void __indirect_glWindowPos2fvMESA(const GLfloat * v);
+extern HIDDEN void __indirect_glWindowPos2iMESA(GLint x, GLint y);
+extern HIDDEN void __indirect_glWindowPos2ivMESA(const GLint * v);
+extern HIDDEN void __indirect_glWindowPos2sMESA(GLshort x, GLshort y);
+extern HIDDEN void __indirect_glWindowPos2svMESA(const GLshort * v);
+extern HIDDEN void __indirect_glWindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z);
+extern HIDDEN void __indirect_glWindowPos3dvMESA(const GLdouble * v);
+extern HIDDEN void __indirect_glWindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z);
+extern HIDDEN void __indirect_glWindowPos3fvMESA(const GLfloat * v);
+extern HIDDEN void __indirect_glWindowPos3iMESA(GLint x, GLint y, GLint z);
+extern HIDDEN void __indirect_glWindowPos3ivMESA(const GLint * v);
+extern HIDDEN void __indirect_glWindowPos3sMESA(GLshort x, GLshort y, GLshort z);
+extern HIDDEN void __indirect_glWindowPos3svMESA(const GLshort * v);
+extern HIDDEN void __indirect_glBlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+extern HIDDEN void __indirect_glFogCoordfEXT(GLfloat coord);
+extern HIDDEN void __indirect_glFogCoordfvEXT(const GLfloat * coord);
+extern HIDDEN void __indirect_glFogCoorddEXT(GLdouble coord);
+extern HIDDEN void __indirect_glFogCoorddvEXT(const GLdouble * coord);
+extern HIDDEN void __indirect_glFogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid * pointer);
+extern HIDDEN void __indirect_glCompressedTexImage3DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid * data);
+extern HIDDEN void __indirect_glCompressedTexImage2DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid * data);
+extern HIDDEN void __indirect_glCompressedTexImage1DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid * data);
+extern HIDDEN void __indirect_glCompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid * data);
+extern HIDDEN void __indirect_glCompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid * data);
+extern HIDDEN void __indirect_glCompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid * data);
+extern HIDDEN void __indirect_glGetCompressedTexImageARB(GLenum target, GLint level, GLvoid * img);
+extern HIDDEN void __indirect_glSecondaryColor3bEXT(GLbyte red, GLbyte green, GLbyte blue);
+extern HIDDEN void __indirect_glSecondaryColor3bvEXT(const GLbyte * v);
+extern HIDDEN void __indirect_glSecondaryColor3dEXT(GLdouble red, GLdouble green, GLdouble blue);
+extern HIDDEN void __indirect_glSecondaryColor3dvEXT(const GLdouble * v);
+extern HIDDEN void __indirect_glSecondaryColor3fEXT(GLfloat red, GLfloat green, GLfloat blue);
+extern HIDDEN void __indirect_glSecondaryColor3fvEXT(const GLfloat * v);
+extern HIDDEN void __indirect_glSecondaryColor3iEXT(GLint red, GLint green, GLint blue);
+extern HIDDEN void __indirect_glSecondaryColor3ivEXT(const GLint * v);
+extern HIDDEN void __indirect_glSecondaryColor3sEXT(GLshort red, GLshort green, GLshort blue);
+extern HIDDEN void __indirect_glSecondaryColor3svEXT(const GLshort * v);
+extern HIDDEN void __indirect_glSecondaryColor3ubEXT(GLubyte red, GLubyte green, GLubyte blue);
+extern HIDDEN void __indirect_glSecondaryColor3ubvEXT(const GLubyte * v);
+extern HIDDEN void __indirect_glSecondaryColor3uiEXT(GLuint red, GLuint green, GLuint blue);
+extern HIDDEN void __indirect_glSecondaryColor3uivEXT(const GLuint * v);
+extern HIDDEN void __indirect_glSecondaryColor3usEXT(GLushort red, GLushort green, GLushort blue);
+extern HIDDEN void __indirect_glSecondaryColor3usvEXT(const GLushort * v);
+extern HIDDEN void __indirect_glSecondaryColorPointerEXT(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer);
+extern HIDDEN GLboolean __indirect_glAreProgramsResidentNV(GLsizei n, const GLuint * ids, GLboolean * residences);
+extern HIDDEN void __indirect_glBindProgramNV(GLenum target, GLuint program);
+extern HIDDEN void __indirect_glDeleteProgramsNV(GLsizei n, const GLuint * programs);
+extern HIDDEN void __indirect_glExecuteProgramNV(GLenum target, GLuint id, const GLfloat * params);
+extern HIDDEN void __indirect_glGenProgramsNV(GLsizei n, GLuint * programs);
+extern HIDDEN void __indirect_glGetProgramParameterdvNV(GLenum target, GLuint index, GLenum pname, GLdouble * params);
+extern HIDDEN void __indirect_glGetProgramParameterfvNV(GLenum target, GLuint index, GLenum pname, GLfloat * params);
+extern HIDDEN void __indirect_glGetProgramivNV(GLuint id, GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glGetProgramStringNV(GLuint id, GLenum pname, GLubyte * program);
+extern HIDDEN void __indirect_glGetTrackMatrixivNV(GLenum target, GLuint address, GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glGetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble * params);
+extern HIDDEN void __indirect_glGetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat * params);
+extern HIDDEN void __indirect_glGetVertexAttribivARB(GLuint index, GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glGetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid ** params);
+extern HIDDEN GLboolean __indirect_glIsProgramNV(GLuint program);
+extern HIDDEN void __indirect_glLoadProgramNV(GLenum target, GLuint id, GLsizei len, const GLubyte * program);
+extern HIDDEN void __indirect_glProgramParameter4dNV(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+extern HIDDEN void __indirect_glProgramParameter4dvNV(GLenum target, GLuint index, const GLdouble * params);
+extern HIDDEN void __indirect_glProgramParameter4fNV(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+extern HIDDEN void __indirect_glProgramParameter4fvNV(GLenum target, GLuint index, const GLfloat * params);
+extern HIDDEN void __indirect_glProgramParameters4dvNV(GLenum target, GLuint index, GLuint num, const GLdouble * params);
+extern HIDDEN void __indirect_glProgramParameters4fvNV(GLenum target, GLuint index, GLuint num, const GLfloat * params);
+extern HIDDEN void __indirect_glRequestResidentProgramsNV(GLsizei n, const GLuint * ids);
+extern HIDDEN void __indirect_glTrackMatrixNV(GLenum target, GLuint address, GLenum matrix, GLenum transform);
+extern HIDDEN void __indirect_glVertexAttribPointerNV(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer);
+extern HIDDEN void __indirect_glVertexAttrib1dARB(GLuint index, GLdouble x);
+extern HIDDEN void __indirect_glVertexAttrib1dvARB(GLuint index, const GLdouble * v);
+extern HIDDEN void __indirect_glVertexAttrib1fARB(GLuint index, GLfloat x);
+extern HIDDEN void __indirect_glVertexAttrib1fvARB(GLuint index, const GLfloat * v);
+extern HIDDEN void __indirect_glVertexAttrib1sARB(GLuint index, GLshort x);
+extern HIDDEN void __indirect_glVertexAttrib1svARB(GLuint index, const GLshort * v);
+extern HIDDEN void __indirect_glVertexAttrib2dARB(GLuint index, GLdouble x, GLdouble y);
+extern HIDDEN void __indirect_glVertexAttrib2dvARB(GLuint index, const GLdouble * v);
+extern HIDDEN void __indirect_glVertexAttrib2fARB(GLuint index, GLfloat x, GLfloat y);
+extern HIDDEN void __indirect_glVertexAttrib2fvARB(GLuint index, const GLfloat * v);
+extern HIDDEN void __indirect_glVertexAttrib2sARB(GLuint index, GLshort x, GLshort y);
+extern HIDDEN void __indirect_glVertexAttrib2svARB(GLuint index, const GLshort * v);
+extern HIDDEN void __indirect_glVertexAttrib3dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z);
+extern HIDDEN void __indirect_glVertexAttrib3dvARB(GLuint index, const GLdouble * v);
+extern HIDDEN void __indirect_glVertexAttrib3fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z);
+extern HIDDEN void __indirect_glVertexAttrib3fvARB(GLuint index, const GLfloat * v);
+extern HIDDEN void __indirect_glVertexAttrib3sARB(GLuint index, GLshort x, GLshort y, GLshort z);
+extern HIDDEN void __indirect_glVertexAttrib3svARB(GLuint index, const GLshort * v);
+extern HIDDEN void __indirect_glVertexAttrib4dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+extern HIDDEN void __indirect_glVertexAttrib4dvARB(GLuint index, const GLdouble * v);
+extern HIDDEN void __indirect_glVertexAttrib4fARB(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+extern HIDDEN void __indirect_glVertexAttrib4fvARB(GLuint index, const GLfloat * v);
+extern HIDDEN void __indirect_glVertexAttrib4sARB(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+extern HIDDEN void __indirect_glVertexAttrib4svARB(GLuint index, const GLshort * v);
+extern HIDDEN void __indirect_glVertexAttrib4NubARB(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+extern HIDDEN void __indirect_glVertexAttrib4NubvARB(GLuint index, const GLubyte * v);
+extern HIDDEN void __indirect_glVertexAttribs1dvNV(GLuint index, GLsizei n, const GLdouble * v);
+extern HIDDEN void __indirect_glVertexAttribs1fvNV(GLuint index, GLsizei n, const GLfloat * v);
+extern HIDDEN void __indirect_glVertexAttribs1svNV(GLuint index, GLsizei n, const GLshort * v);
+extern HIDDEN void __indirect_glVertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble * v);
+extern HIDDEN void __indirect_glVertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat * v);
+extern HIDDEN void __indirect_glVertexAttribs2svNV(GLuint index, GLsizei n, const GLshort * v);
+extern HIDDEN void __indirect_glVertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble * v);
+extern HIDDEN void __indirect_glVertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat * v);
+extern HIDDEN void __indirect_glVertexAttribs3svNV(GLuint index, GLsizei n, const GLshort * v);
+extern HIDDEN void __indirect_glVertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble * v);
+extern HIDDEN void __indirect_glVertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat * v);
+extern HIDDEN void __indirect_glVertexAttribs4svNV(GLuint index, GLsizei n, const GLshort * v);
+extern HIDDEN void __indirect_glVertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte * v);
+extern HIDDEN void __indirect_glPointParameteriNV(GLenum pname, GLint param);
+extern HIDDEN void __indirect_glPointParameterivNV(GLenum pname, const GLint * params);
+extern HIDDEN void __indirect_glMultiDrawArraysEXT(GLenum mode, GLint * first, GLsizei * count, GLsizei primcount);
+extern HIDDEN void __indirect_glMultiDrawElementsEXT(GLenum mode, const GLsizei * count, GLenum type, const GLvoid ** indices, GLsizei primcount);
+extern HIDDEN void __indirect_glActiveStencilFaceEXT(GLenum face);
+extern HIDDEN void __indirect_glVertexAttrib4bvARB(GLuint index, const GLbyte * v);
+extern HIDDEN void __indirect_glVertexAttrib4ivARB(GLuint index, const GLint * v);
+extern HIDDEN void __indirect_glVertexAttrib4ubvARB(GLuint index, const GLubyte * v);
+extern HIDDEN void __indirect_glVertexAttrib4usvARB(GLuint index, const GLushort * v);
+extern HIDDEN void __indirect_glVertexAttrib4uivARB(GLuint index, const GLuint * v);
+extern HIDDEN void __indirect_glVertexAttrib4NbvARB(GLuint index, const GLbyte * v);
+extern HIDDEN void __indirect_glVertexAttrib4NsvARB(GLuint index, const GLshort * v);
+extern HIDDEN void __indirect_glVertexAttrib4NivARB(GLuint index, const GLint * v);
+extern HIDDEN void __indirect_glVertexAttrib4NusvARB(GLuint index, const GLushort * v);
+extern HIDDEN void __indirect_glVertexAttrib4NuivARB(GLuint index, const GLuint * v);
+extern HIDDEN void __indirect_glVertexAttribPointerARB(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer);
+extern HIDDEN void __indirect_glEnableVertexAttribArrayARB(GLuint index);
+extern HIDDEN void __indirect_glDisableVertexAttribArrayARB(GLuint index);
+extern HIDDEN void __indirect_glProgramStringARB(GLenum target, GLenum format, GLsizei len, const GLvoid * string);
+extern HIDDEN void __indirect_glProgramEnvParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+extern HIDDEN void __indirect_glProgramEnvParameter4dvARB(GLenum target, GLuint index, const GLdouble * params);
+extern HIDDEN void __indirect_glProgramEnvParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+extern HIDDEN void __indirect_glProgramEnvParameter4fvARB(GLenum target, GLuint index, const GLfloat * params);
+extern HIDDEN void __indirect_glProgramLocalParameter4dARB(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+extern HIDDEN void __indirect_glProgramLocalParameter4dvARB(GLenum target, GLuint index, const GLdouble * params);
+extern HIDDEN void __indirect_glProgramLocalParameter4fARB(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+extern HIDDEN void __indirect_glProgramLocalParameter4fvARB(GLenum target, GLuint index, const GLfloat * params);
+extern HIDDEN void __indirect_glGetProgramEnvParameterdvARB(GLenum target, GLuint index, GLdouble * params);
+extern HIDDEN void __indirect_glGetProgramEnvParameterfvARB(GLenum target, GLuint index, GLfloat * params);
+extern HIDDEN void __indirect_glGetProgramLocalParameterdvARB(GLenum target, GLuint index, GLdouble * params);
+extern HIDDEN void __indirect_glGetProgramLocalParameterfvARB(GLenum target, GLuint index, GLfloat * params);
+extern HIDDEN void __indirect_glGetProgramivARB(GLenum target, GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glGetProgramStringARB(GLenum target, GLenum pname, GLvoid * string);
+extern HIDDEN void __indirect_glProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte * name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+extern HIDDEN void __indirect_glProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte * name, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+extern HIDDEN void __indirect_glProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte * name, const GLfloat * v);
+extern HIDDEN void __indirect_glProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte * name, const GLdouble * v);
+extern HIDDEN void __indirect_glGetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte * name, GLfloat * params);
+extern HIDDEN void __indirect_glGetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte * name, GLdouble * params);
+extern HIDDEN void __indirect_glGenQueriesARB(GLsizei n, GLuint * ids);
+extern HIDDEN void __indirect_glDeleteQueriesARB(GLsizei n, const GLuint * ids);
+extern HIDDEN GLboolean __indirect_glIsQueryARB(GLuint id);
+extern HIDDEN void __indirect_glBeginQueryARB(GLenum target, GLuint id);
+extern HIDDEN void __indirect_glEndQueryARB(GLenum target);
+extern HIDDEN void __indirect_glGetQueryivARB(GLenum target, GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glGetQueryObjectivARB(GLuint id, GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glGetQueryObjectuivARB(GLuint id, GLenum pname, GLuint * params);
+extern HIDDEN void __indirect_glGetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble * params);
+extern HIDDEN void __indirect_glGetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat * params);
+extern HIDDEN void __indirect_glGetVertexAttribivNV(GLuint index, GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glVertexAttrib1dNV(GLuint index, GLdouble x);
+extern HIDDEN void __indirect_glVertexAttrib1dvNV(GLuint index, const GLdouble * v);
+extern HIDDEN void __indirect_glVertexAttrib1fNV(GLuint index, GLfloat x);
+extern HIDDEN void __indirect_glVertexAttrib1fvNV(GLuint index, const GLfloat * v);
+extern HIDDEN void __indirect_glVertexAttrib1sNV(GLuint index, GLshort x);
+extern HIDDEN void __indirect_glVertexAttrib1svNV(GLuint index, const GLshort * v);
+extern HIDDEN void __indirect_glVertexAttrib2dNV(GLuint index, GLdouble x, GLdouble y);
+extern HIDDEN void __indirect_glVertexAttrib2dvNV(GLuint index, const GLdouble * v);
+extern HIDDEN void __indirect_glVertexAttrib2fNV(GLuint index, GLfloat x, GLfloat y);
+extern HIDDEN void __indirect_glVertexAttrib2fvNV(GLuint index, const GLfloat * v);
+extern HIDDEN void __indirect_glVertexAttrib2sNV(GLuint index, GLshort x, GLshort y);
+extern HIDDEN void __indirect_glVertexAttrib2svNV(GLuint index, const GLshort * v);
+extern HIDDEN void __indirect_glVertexAttrib3dNV(GLuint index, GLdouble x, GLdouble y, GLdouble z);
+extern HIDDEN void __indirect_glVertexAttrib3dvNV(GLuint index, const GLdouble * v);
+extern HIDDEN void __indirect_glVertexAttrib3fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z);
+extern HIDDEN void __indirect_glVertexAttrib3fvNV(GLuint index, const GLfloat * v);
+extern HIDDEN void __indirect_glVertexAttrib3sNV(GLuint index, GLshort x, GLshort y, GLshort z);
+extern HIDDEN void __indirect_glVertexAttrib3svNV(GLuint index, const GLshort * v);
+extern HIDDEN void __indirect_glVertexAttrib4dNV(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+extern HIDDEN void __indirect_glVertexAttrib4dvNV(GLuint index, const GLdouble * v);
+extern HIDDEN void __indirect_glVertexAttrib4fNV(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+extern HIDDEN void __indirect_glVertexAttrib4fvNV(GLuint index, const GLfloat * v);
+extern HIDDEN void __indirect_glVertexAttrib4sNV(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+extern HIDDEN void __indirect_glVertexAttrib4svNV(GLuint index, const GLshort * v);
+extern HIDDEN void __indirect_glVertexAttrib4ubNV(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+extern HIDDEN void __indirect_glVertexAttrib4ubvNV(GLuint index, const GLubyte * v);
+extern HIDDEN GLboolean __indirect_glIsRenderbufferEXT(GLuint renderbuffer);
+extern HIDDEN void __indirect_glBindRenderbufferEXT(GLenum target, GLuint renderbuffer);
+extern HIDDEN void __indirect_glDeleteRenderbuffersEXT(GLsizei n, const GLuint * renderbuffers);
+extern HIDDEN void __indirect_glGenRenderbuffersEXT(GLsizei n, GLuint * renderbuffers);
+extern HIDDEN void __indirect_glRenderbufferStorageEXT(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+extern HIDDEN void __indirect_glGetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint * params);
+extern HIDDEN GLboolean __indirect_glIsFramebufferEXT(GLuint framebuffer);
+extern HIDDEN void __indirect_glBindFramebufferEXT(GLenum target, GLuint framebuffer);
+extern HIDDEN void __indirect_glDeleteFramebuffersEXT(GLsizei n, const GLuint * framebuffers);
+extern HIDDEN void __indirect_glGenFramebuffersEXT(GLsizei n, GLuint * framebuffers);
+extern HIDDEN GLenum __indirect_glCheckFramebufferStatusEXT(GLenum target);
+extern HIDDEN void __indirect_glFramebufferTexture1DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+extern HIDDEN void __indirect_glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+extern HIDDEN void __indirect_glFramebufferTexture3DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+extern HIDDEN void __indirect_glFramebufferRenderbufferEXT(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+extern HIDDEN void __indirect_glGetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment, GLenum pname, GLint * params);
+extern HIDDEN void __indirect_glGenerateMipmapEXT(GLenum target);
+
+# undef HIDDEN
+# undef FASTCALL
+# undef NOINLINE
+
+#endif /* !defined( _INDIRECT_H_ ) */
diff --git a/nx-X11/extras/Mesa/src/glx/x11/indirect_init.c b/nx-X11/extras/Mesa/src/glx/x11/indirect_init.c
new file mode 100644
index 000000000..6627edfeb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/indirect_init.c
@@ -0,0 +1,779 @@
+/* DO NOT EDIT - This file generated automatically by glX_proto_send.py (from Mesa) script */
+
+/*
+ * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+ * (C) Copyright IBM Corporation 2004
+ * 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, IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/**
+ * \file indirect_init.c
+ * Initialize indirect rendering dispatch table.
+ *
+ * \author Kevin E. Martin <kevin@precisioninsight.com>
+ * \author Brian Paul <brian@precisioninsight.com>
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include "indirect_init.h"
+#include "indirect.h"
+#include "glapi.h"
+
+
+/**
+ * No-op function used to initialize functions that have no GLX protocol
+ * support.
+ */
+static int NoOp(void)
+{
+ return 0;
+}
+
+/**
+ * Create and initialize a new GL dispatch table. The table is initialized
+ * with GLX indirect rendering protocol functions.
+ */
+__GLapi * __glXNewIndirectAPI( void )
+{
+ __GLapi *glAPI;
+ GLuint entries;
+
+ entries = _glapi_get_dispatch_table_size();
+ glAPI = (__GLapi *) Xmalloc(entries * sizeof(void *));
+
+ /* first, set all entries to point to no-op functions */
+ {
+ int i;
+ void **dispatch = (void **) glAPI;
+ for (i = 0; i < entries; i++) {
+ dispatch[i] = (void *) NoOp;
+ }
+ }
+
+ /* now, initialize the entries we understand */
+
+ /* 1.0 */
+
+ glAPI->NewList = __indirect_glNewList;
+ glAPI->EndList = __indirect_glEndList;
+ glAPI->CallList = __indirect_glCallList;
+ glAPI->CallLists = __indirect_glCallLists;
+ glAPI->DeleteLists = __indirect_glDeleteLists;
+ glAPI->GenLists = __indirect_glGenLists;
+ glAPI->ListBase = __indirect_glListBase;
+ glAPI->Begin = __indirect_glBegin;
+ glAPI->Bitmap = __indirect_glBitmap;
+ glAPI->Color3b = __indirect_glColor3b;
+ glAPI->Color3bv = __indirect_glColor3bv;
+ glAPI->Color3d = __indirect_glColor3d;
+ glAPI->Color3dv = __indirect_glColor3dv;
+ glAPI->Color3f = __indirect_glColor3f;
+ glAPI->Color3fv = __indirect_glColor3fv;
+ glAPI->Color3i = __indirect_glColor3i;
+ glAPI->Color3iv = __indirect_glColor3iv;
+ glAPI->Color3s = __indirect_glColor3s;
+ glAPI->Color3sv = __indirect_glColor3sv;
+ glAPI->Color3ub = __indirect_glColor3ub;
+ glAPI->Color3ubv = __indirect_glColor3ubv;
+ glAPI->Color3ui = __indirect_glColor3ui;
+ glAPI->Color3uiv = __indirect_glColor3uiv;
+ glAPI->Color3us = __indirect_glColor3us;
+ glAPI->Color3usv = __indirect_glColor3usv;
+ glAPI->Color4b = __indirect_glColor4b;
+ glAPI->Color4bv = __indirect_glColor4bv;
+ glAPI->Color4d = __indirect_glColor4d;
+ glAPI->Color4dv = __indirect_glColor4dv;
+ glAPI->Color4f = __indirect_glColor4f;
+ glAPI->Color4fv = __indirect_glColor4fv;
+ glAPI->Color4i = __indirect_glColor4i;
+ glAPI->Color4iv = __indirect_glColor4iv;
+ glAPI->Color4s = __indirect_glColor4s;
+ glAPI->Color4sv = __indirect_glColor4sv;
+ glAPI->Color4ub = __indirect_glColor4ub;
+ glAPI->Color4ubv = __indirect_glColor4ubv;
+ glAPI->Color4ui = __indirect_glColor4ui;
+ glAPI->Color4uiv = __indirect_glColor4uiv;
+ glAPI->Color4us = __indirect_glColor4us;
+ glAPI->Color4usv = __indirect_glColor4usv;
+ glAPI->EdgeFlag = __indirect_glEdgeFlag;
+ glAPI->EdgeFlagv = __indirect_glEdgeFlagv;
+ glAPI->End = __indirect_glEnd;
+ glAPI->Indexd = __indirect_glIndexd;
+ glAPI->Indexdv = __indirect_glIndexdv;
+ glAPI->Indexf = __indirect_glIndexf;
+ glAPI->Indexfv = __indirect_glIndexfv;
+ glAPI->Indexi = __indirect_glIndexi;
+ glAPI->Indexiv = __indirect_glIndexiv;
+ glAPI->Indexs = __indirect_glIndexs;
+ glAPI->Indexsv = __indirect_glIndexsv;
+ glAPI->Normal3b = __indirect_glNormal3b;
+ glAPI->Normal3bv = __indirect_glNormal3bv;
+ glAPI->Normal3d = __indirect_glNormal3d;
+ glAPI->Normal3dv = __indirect_glNormal3dv;
+ glAPI->Normal3f = __indirect_glNormal3f;
+ glAPI->Normal3fv = __indirect_glNormal3fv;
+ glAPI->Normal3i = __indirect_glNormal3i;
+ glAPI->Normal3iv = __indirect_glNormal3iv;
+ glAPI->Normal3s = __indirect_glNormal3s;
+ glAPI->Normal3sv = __indirect_glNormal3sv;
+ glAPI->RasterPos2d = __indirect_glRasterPos2d;
+ glAPI->RasterPos2dv = __indirect_glRasterPos2dv;
+ glAPI->RasterPos2f = __indirect_glRasterPos2f;
+ glAPI->RasterPos2fv = __indirect_glRasterPos2fv;
+ glAPI->RasterPos2i = __indirect_glRasterPos2i;
+ glAPI->RasterPos2iv = __indirect_glRasterPos2iv;
+ glAPI->RasterPos2s = __indirect_glRasterPos2s;
+ glAPI->RasterPos2sv = __indirect_glRasterPos2sv;
+ glAPI->RasterPos3d = __indirect_glRasterPos3d;
+ glAPI->RasterPos3dv = __indirect_glRasterPos3dv;
+ glAPI->RasterPos3f = __indirect_glRasterPos3f;
+ glAPI->RasterPos3fv = __indirect_glRasterPos3fv;
+ glAPI->RasterPos3i = __indirect_glRasterPos3i;
+ glAPI->RasterPos3iv = __indirect_glRasterPos3iv;
+ glAPI->RasterPos3s = __indirect_glRasterPos3s;
+ glAPI->RasterPos3sv = __indirect_glRasterPos3sv;
+ glAPI->RasterPos4d = __indirect_glRasterPos4d;
+ glAPI->RasterPos4dv = __indirect_glRasterPos4dv;
+ glAPI->RasterPos4f = __indirect_glRasterPos4f;
+ glAPI->RasterPos4fv = __indirect_glRasterPos4fv;
+ glAPI->RasterPos4i = __indirect_glRasterPos4i;
+ glAPI->RasterPos4iv = __indirect_glRasterPos4iv;
+ glAPI->RasterPos4s = __indirect_glRasterPos4s;
+ glAPI->RasterPos4sv = __indirect_glRasterPos4sv;
+ glAPI->Rectd = __indirect_glRectd;
+ glAPI->Rectdv = __indirect_glRectdv;
+ glAPI->Rectf = __indirect_glRectf;
+ glAPI->Rectfv = __indirect_glRectfv;
+ glAPI->Recti = __indirect_glRecti;
+ glAPI->Rectiv = __indirect_glRectiv;
+ glAPI->Rects = __indirect_glRects;
+ glAPI->Rectsv = __indirect_glRectsv;
+ glAPI->TexCoord1d = __indirect_glTexCoord1d;
+ glAPI->TexCoord1dv = __indirect_glTexCoord1dv;
+ glAPI->TexCoord1f = __indirect_glTexCoord1f;
+ glAPI->TexCoord1fv = __indirect_glTexCoord1fv;
+ glAPI->TexCoord1i = __indirect_glTexCoord1i;
+ glAPI->TexCoord1iv = __indirect_glTexCoord1iv;
+ glAPI->TexCoord1s = __indirect_glTexCoord1s;
+ glAPI->TexCoord1sv = __indirect_glTexCoord1sv;
+ glAPI->TexCoord2d = __indirect_glTexCoord2d;
+ glAPI->TexCoord2dv = __indirect_glTexCoord2dv;
+ glAPI->TexCoord2f = __indirect_glTexCoord2f;
+ glAPI->TexCoord2fv = __indirect_glTexCoord2fv;
+ glAPI->TexCoord2i = __indirect_glTexCoord2i;
+ glAPI->TexCoord2iv = __indirect_glTexCoord2iv;
+ glAPI->TexCoord2s = __indirect_glTexCoord2s;
+ glAPI->TexCoord2sv = __indirect_glTexCoord2sv;
+ glAPI->TexCoord3d = __indirect_glTexCoord3d;
+ glAPI->TexCoord3dv = __indirect_glTexCoord3dv;
+ glAPI->TexCoord3f = __indirect_glTexCoord3f;
+ glAPI->TexCoord3fv = __indirect_glTexCoord3fv;
+ glAPI->TexCoord3i = __indirect_glTexCoord3i;
+ glAPI->TexCoord3iv = __indirect_glTexCoord3iv;
+ glAPI->TexCoord3s = __indirect_glTexCoord3s;
+ glAPI->TexCoord3sv = __indirect_glTexCoord3sv;
+ glAPI->TexCoord4d = __indirect_glTexCoord4d;
+ glAPI->TexCoord4dv = __indirect_glTexCoord4dv;
+ glAPI->TexCoord4f = __indirect_glTexCoord4f;
+ glAPI->TexCoord4fv = __indirect_glTexCoord4fv;
+ glAPI->TexCoord4i = __indirect_glTexCoord4i;
+ glAPI->TexCoord4iv = __indirect_glTexCoord4iv;
+ glAPI->TexCoord4s = __indirect_glTexCoord4s;
+ glAPI->TexCoord4sv = __indirect_glTexCoord4sv;
+ glAPI->Vertex2d = __indirect_glVertex2d;
+ glAPI->Vertex2dv = __indirect_glVertex2dv;
+ glAPI->Vertex2f = __indirect_glVertex2f;
+ glAPI->Vertex2fv = __indirect_glVertex2fv;
+ glAPI->Vertex2i = __indirect_glVertex2i;
+ glAPI->Vertex2iv = __indirect_glVertex2iv;
+ glAPI->Vertex2s = __indirect_glVertex2s;
+ glAPI->Vertex2sv = __indirect_glVertex2sv;
+ glAPI->Vertex3d = __indirect_glVertex3d;
+ glAPI->Vertex3dv = __indirect_glVertex3dv;
+ glAPI->Vertex3f = __indirect_glVertex3f;
+ glAPI->Vertex3fv = __indirect_glVertex3fv;
+ glAPI->Vertex3i = __indirect_glVertex3i;
+ glAPI->Vertex3iv = __indirect_glVertex3iv;
+ glAPI->Vertex3s = __indirect_glVertex3s;
+ glAPI->Vertex3sv = __indirect_glVertex3sv;
+ glAPI->Vertex4d = __indirect_glVertex4d;
+ glAPI->Vertex4dv = __indirect_glVertex4dv;
+ glAPI->Vertex4f = __indirect_glVertex4f;
+ glAPI->Vertex4fv = __indirect_glVertex4fv;
+ glAPI->Vertex4i = __indirect_glVertex4i;
+ glAPI->Vertex4iv = __indirect_glVertex4iv;
+ glAPI->Vertex4s = __indirect_glVertex4s;
+ glAPI->Vertex4sv = __indirect_glVertex4sv;
+ glAPI->ClipPlane = __indirect_glClipPlane;
+ glAPI->ColorMaterial = __indirect_glColorMaterial;
+ glAPI->CullFace = __indirect_glCullFace;
+ glAPI->Fogf = __indirect_glFogf;
+ glAPI->Fogfv = __indirect_glFogfv;
+ glAPI->Fogi = __indirect_glFogi;
+ glAPI->Fogiv = __indirect_glFogiv;
+ glAPI->FrontFace = __indirect_glFrontFace;
+ glAPI->Hint = __indirect_glHint;
+ glAPI->Lightf = __indirect_glLightf;
+ glAPI->Lightfv = __indirect_glLightfv;
+ glAPI->Lighti = __indirect_glLighti;
+ glAPI->Lightiv = __indirect_glLightiv;
+ glAPI->LightModelf = __indirect_glLightModelf;
+ glAPI->LightModelfv = __indirect_glLightModelfv;
+ glAPI->LightModeli = __indirect_glLightModeli;
+ glAPI->LightModeliv = __indirect_glLightModeliv;
+ glAPI->LineStipple = __indirect_glLineStipple;
+ glAPI->LineWidth = __indirect_glLineWidth;
+ glAPI->Materialf = __indirect_glMaterialf;
+ glAPI->Materialfv = __indirect_glMaterialfv;
+ glAPI->Materiali = __indirect_glMateriali;
+ glAPI->Materialiv = __indirect_glMaterialiv;
+ glAPI->PointSize = __indirect_glPointSize;
+ glAPI->PolygonMode = __indirect_glPolygonMode;
+ glAPI->PolygonStipple = __indirect_glPolygonStipple;
+ glAPI->Scissor = __indirect_glScissor;
+ glAPI->ShadeModel = __indirect_glShadeModel;
+ glAPI->TexParameterf = __indirect_glTexParameterf;
+ glAPI->TexParameterfv = __indirect_glTexParameterfv;
+ glAPI->TexParameteri = __indirect_glTexParameteri;
+ glAPI->TexParameteriv = __indirect_glTexParameteriv;
+ glAPI->TexImage1D = __indirect_glTexImage1D;
+ glAPI->TexImage2D = __indirect_glTexImage2D;
+ glAPI->TexEnvf = __indirect_glTexEnvf;
+ glAPI->TexEnvfv = __indirect_glTexEnvfv;
+ glAPI->TexEnvi = __indirect_glTexEnvi;
+ glAPI->TexEnviv = __indirect_glTexEnviv;
+ glAPI->TexGend = __indirect_glTexGend;
+ glAPI->TexGendv = __indirect_glTexGendv;
+ glAPI->TexGenf = __indirect_glTexGenf;
+ glAPI->TexGenfv = __indirect_glTexGenfv;
+ glAPI->TexGeni = __indirect_glTexGeni;
+ glAPI->TexGeniv = __indirect_glTexGeniv;
+ glAPI->FeedbackBuffer = __indirect_glFeedbackBuffer;
+ glAPI->SelectBuffer = __indirect_glSelectBuffer;
+ glAPI->RenderMode = __indirect_glRenderMode;
+ glAPI->InitNames = __indirect_glInitNames;
+ glAPI->LoadName = __indirect_glLoadName;
+ glAPI->PassThrough = __indirect_glPassThrough;
+ glAPI->PopName = __indirect_glPopName;
+ glAPI->PushName = __indirect_glPushName;
+ glAPI->DrawBuffer = __indirect_glDrawBuffer;
+ glAPI->Clear = __indirect_glClear;
+ glAPI->ClearAccum = __indirect_glClearAccum;
+ glAPI->ClearIndex = __indirect_glClearIndex;
+ glAPI->ClearColor = __indirect_glClearColor;
+ glAPI->ClearStencil = __indirect_glClearStencil;
+ glAPI->ClearDepth = __indirect_glClearDepth;
+ glAPI->StencilMask = __indirect_glStencilMask;
+ glAPI->ColorMask = __indirect_glColorMask;
+ glAPI->DepthMask = __indirect_glDepthMask;
+ glAPI->IndexMask = __indirect_glIndexMask;
+ glAPI->Accum = __indirect_glAccum;
+ glAPI->Disable = __indirect_glDisable;
+ glAPI->Enable = __indirect_glEnable;
+ glAPI->Finish = __indirect_glFinish;
+ glAPI->Flush = __indirect_glFlush;
+ glAPI->PopAttrib = __indirect_glPopAttrib;
+ glAPI->PushAttrib = __indirect_glPushAttrib;
+ glAPI->Map1d = __indirect_glMap1d;
+ glAPI->Map1f = __indirect_glMap1f;
+ glAPI->Map2d = __indirect_glMap2d;
+ glAPI->Map2f = __indirect_glMap2f;
+ glAPI->MapGrid1d = __indirect_glMapGrid1d;
+ glAPI->MapGrid1f = __indirect_glMapGrid1f;
+ glAPI->MapGrid2d = __indirect_glMapGrid2d;
+ glAPI->MapGrid2f = __indirect_glMapGrid2f;
+ glAPI->EvalCoord1d = __indirect_glEvalCoord1d;
+ glAPI->EvalCoord1dv = __indirect_glEvalCoord1dv;
+ glAPI->EvalCoord1f = __indirect_glEvalCoord1f;
+ glAPI->EvalCoord1fv = __indirect_glEvalCoord1fv;
+ glAPI->EvalCoord2d = __indirect_glEvalCoord2d;
+ glAPI->EvalCoord2dv = __indirect_glEvalCoord2dv;
+ glAPI->EvalCoord2f = __indirect_glEvalCoord2f;
+ glAPI->EvalCoord2fv = __indirect_glEvalCoord2fv;
+ glAPI->EvalMesh1 = __indirect_glEvalMesh1;
+ glAPI->EvalPoint1 = __indirect_glEvalPoint1;
+ glAPI->EvalMesh2 = __indirect_glEvalMesh2;
+ glAPI->EvalPoint2 = __indirect_glEvalPoint2;
+ glAPI->AlphaFunc = __indirect_glAlphaFunc;
+ glAPI->BlendFunc = __indirect_glBlendFunc;
+ glAPI->LogicOp = __indirect_glLogicOp;
+ glAPI->StencilFunc = __indirect_glStencilFunc;
+ glAPI->StencilOp = __indirect_glStencilOp;
+ glAPI->DepthFunc = __indirect_glDepthFunc;
+ glAPI->PixelZoom = __indirect_glPixelZoom;
+ glAPI->PixelTransferf = __indirect_glPixelTransferf;
+ glAPI->PixelTransferi = __indirect_glPixelTransferi;
+ glAPI->PixelStoref = __indirect_glPixelStoref;
+ glAPI->PixelStorei = __indirect_glPixelStorei;
+ glAPI->PixelMapfv = __indirect_glPixelMapfv;
+ glAPI->PixelMapuiv = __indirect_glPixelMapuiv;
+ glAPI->PixelMapusv = __indirect_glPixelMapusv;
+ glAPI->ReadBuffer = __indirect_glReadBuffer;
+ glAPI->CopyPixels = __indirect_glCopyPixels;
+ glAPI->ReadPixels = __indirect_glReadPixels;
+ glAPI->DrawPixels = __indirect_glDrawPixels;
+ glAPI->GetBooleanv = __indirect_glGetBooleanv;
+ glAPI->GetClipPlane = __indirect_glGetClipPlane;
+ glAPI->GetDoublev = __indirect_glGetDoublev;
+ glAPI->GetError = __indirect_glGetError;
+ glAPI->GetFloatv = __indirect_glGetFloatv;
+ glAPI->GetIntegerv = __indirect_glGetIntegerv;
+ glAPI->GetLightfv = __indirect_glGetLightfv;
+ glAPI->GetLightiv = __indirect_glGetLightiv;
+ glAPI->GetMapdv = __indirect_glGetMapdv;
+ glAPI->GetMapfv = __indirect_glGetMapfv;
+ glAPI->GetMapiv = __indirect_glGetMapiv;
+ glAPI->GetMaterialfv = __indirect_glGetMaterialfv;
+ glAPI->GetMaterialiv = __indirect_glGetMaterialiv;
+ glAPI->GetPixelMapfv = __indirect_glGetPixelMapfv;
+ glAPI->GetPixelMapuiv = __indirect_glGetPixelMapuiv;
+ glAPI->GetPixelMapusv = __indirect_glGetPixelMapusv;
+ glAPI->GetPolygonStipple = __indirect_glGetPolygonStipple;
+ glAPI->GetString = __indirect_glGetString;
+ glAPI->GetTexEnvfv = __indirect_glGetTexEnvfv;
+ glAPI->GetTexEnviv = __indirect_glGetTexEnviv;
+ glAPI->GetTexGendv = __indirect_glGetTexGendv;
+ glAPI->GetTexGenfv = __indirect_glGetTexGenfv;
+ glAPI->GetTexGeniv = __indirect_glGetTexGeniv;
+ glAPI->GetTexImage = __indirect_glGetTexImage;
+ glAPI->GetTexParameterfv = __indirect_glGetTexParameterfv;
+ glAPI->GetTexParameteriv = __indirect_glGetTexParameteriv;
+ glAPI->GetTexLevelParameterfv = __indirect_glGetTexLevelParameterfv;
+ glAPI->GetTexLevelParameteriv = __indirect_glGetTexLevelParameteriv;
+ glAPI->IsEnabled = __indirect_glIsEnabled;
+ glAPI->IsList = __indirect_glIsList;
+ glAPI->DepthRange = __indirect_glDepthRange;
+ glAPI->Frustum = __indirect_glFrustum;
+ glAPI->LoadIdentity = __indirect_glLoadIdentity;
+ glAPI->LoadMatrixf = __indirect_glLoadMatrixf;
+ glAPI->LoadMatrixd = __indirect_glLoadMatrixd;
+ glAPI->MatrixMode = __indirect_glMatrixMode;
+ glAPI->MultMatrixf = __indirect_glMultMatrixf;
+ glAPI->MultMatrixd = __indirect_glMultMatrixd;
+ glAPI->Ortho = __indirect_glOrtho;
+ glAPI->PopMatrix = __indirect_glPopMatrix;
+ glAPI->PushMatrix = __indirect_glPushMatrix;
+ glAPI->Rotated = __indirect_glRotated;
+ glAPI->Rotatef = __indirect_glRotatef;
+ glAPI->Scaled = __indirect_glScaled;
+ glAPI->Scalef = __indirect_glScalef;
+ glAPI->Translated = __indirect_glTranslated;
+ glAPI->Translatef = __indirect_glTranslatef;
+ glAPI->Viewport = __indirect_glViewport;
+
+ /* 1.1 */
+
+ glAPI->ArrayElement = __indirect_glArrayElement;
+ glAPI->BindTexture = __indirect_glBindTexture;
+ glAPI->ColorPointer = __indirect_glColorPointer;
+ glAPI->DisableClientState = __indirect_glDisableClientState;
+ glAPI->DrawArrays = __indirect_glDrawArrays;
+ glAPI->DrawElements = __indirect_glDrawElements;
+ glAPI->EdgeFlagPointer = __indirect_glEdgeFlagPointer;
+ glAPI->EnableClientState = __indirect_glEnableClientState;
+ glAPI->IndexPointer = __indirect_glIndexPointer;
+ glAPI->Indexub = __indirect_glIndexub;
+ glAPI->Indexubv = __indirect_glIndexubv;
+ glAPI->InterleavedArrays = __indirect_glInterleavedArrays;
+ glAPI->NormalPointer = __indirect_glNormalPointer;
+ glAPI->PolygonOffset = __indirect_glPolygonOffset;
+ glAPI->TexCoordPointer = __indirect_glTexCoordPointer;
+ glAPI->VertexPointer = __indirect_glVertexPointer;
+ glAPI->AreTexturesResident = __indirect_glAreTexturesResident;
+ glAPI->CopyTexImage1D = __indirect_glCopyTexImage1D;
+ glAPI->CopyTexImage2D = __indirect_glCopyTexImage2D;
+ glAPI->CopyTexSubImage1D = __indirect_glCopyTexSubImage1D;
+ glAPI->CopyTexSubImage2D = __indirect_glCopyTexSubImage2D;
+ glAPI->DeleteTextures = __indirect_glDeleteTextures;
+ glAPI->GenTextures = __indirect_glGenTextures;
+ glAPI->GetPointerv = __indirect_glGetPointerv;
+ glAPI->IsTexture = __indirect_glIsTexture;
+ glAPI->PrioritizeTextures = __indirect_glPrioritizeTextures;
+ glAPI->TexSubImage1D = __indirect_glTexSubImage1D;
+ glAPI->TexSubImage2D = __indirect_glTexSubImage2D;
+ glAPI->PopClientAttrib = __indirect_glPopClientAttrib;
+ glAPI->PushClientAttrib = __indirect_glPushClientAttrib;
+
+ /* 1.2 */
+
+ glAPI->BlendColor = __indirect_glBlendColor;
+ glAPI->BlendEquation = __indirect_glBlendEquation;
+ glAPI->DrawRangeElements = __indirect_glDrawRangeElements;
+ glAPI->ColorTable = __indirect_glColorTable;
+ glAPI->ColorTableParameterfv = __indirect_glColorTableParameterfv;
+ glAPI->ColorTableParameteriv = __indirect_glColorTableParameteriv;
+ glAPI->CopyColorTable = __indirect_glCopyColorTable;
+ glAPI->GetColorTable = __indirect_glGetColorTable;
+ glAPI->GetColorTableParameterfv = __indirect_glGetColorTableParameterfv;
+ glAPI->GetColorTableParameteriv = __indirect_glGetColorTableParameteriv;
+ glAPI->ColorSubTable = __indirect_glColorSubTable;
+ glAPI->CopyColorSubTable = __indirect_glCopyColorSubTable;
+ glAPI->ConvolutionFilter1D = __indirect_glConvolutionFilter1D;
+ glAPI->ConvolutionFilter2D = __indirect_glConvolutionFilter2D;
+ glAPI->ConvolutionParameterf = __indirect_glConvolutionParameterf;
+ glAPI->ConvolutionParameterfv = __indirect_glConvolutionParameterfv;
+ glAPI->ConvolutionParameteri = __indirect_glConvolutionParameteri;
+ glAPI->ConvolutionParameteriv = __indirect_glConvolutionParameteriv;
+ glAPI->CopyConvolutionFilter1D = __indirect_glCopyConvolutionFilter1D;
+ glAPI->CopyConvolutionFilter2D = __indirect_glCopyConvolutionFilter2D;
+ glAPI->GetConvolutionFilter = __indirect_glGetConvolutionFilter;
+ glAPI->GetConvolutionParameterfv = __indirect_glGetConvolutionParameterfv;
+ glAPI->GetConvolutionParameteriv = __indirect_glGetConvolutionParameteriv;
+ glAPI->GetSeparableFilter = __indirect_glGetSeparableFilter;
+ glAPI->SeparableFilter2D = __indirect_glSeparableFilter2D;
+ glAPI->GetHistogram = __indirect_glGetHistogram;
+ glAPI->GetHistogramParameterfv = __indirect_glGetHistogramParameterfv;
+ glAPI->GetHistogramParameteriv = __indirect_glGetHistogramParameteriv;
+ glAPI->GetMinmax = __indirect_glGetMinmax;
+ glAPI->GetMinmaxParameterfv = __indirect_glGetMinmaxParameterfv;
+ glAPI->GetMinmaxParameteriv = __indirect_glGetMinmaxParameteriv;
+ glAPI->Histogram = __indirect_glHistogram;
+ glAPI->Minmax = __indirect_glMinmax;
+ glAPI->ResetHistogram = __indirect_glResetHistogram;
+ glAPI->ResetMinmax = __indirect_glResetMinmax;
+ glAPI->TexImage3D = __indirect_glTexImage3D;
+ glAPI->TexSubImage3D = __indirect_glTexSubImage3D;
+ glAPI->CopyTexSubImage3D = __indirect_glCopyTexSubImage3D;
+
+ /* 1. GL_ARB_multitexture */
+
+ glAPI->MultiTexCoord2dARB = __indirect_glMultiTexCoord2dARB;
+ glAPI->MultiTexCoord2dvARB = __indirect_glMultiTexCoord2dvARB;
+ glAPI->MultiTexCoord2fARB = __indirect_glMultiTexCoord2fARB;
+ glAPI->MultiTexCoord2fvARB = __indirect_glMultiTexCoord2fvARB;
+ glAPI->MultiTexCoord2iARB = __indirect_glMultiTexCoord2iARB;
+ glAPI->MultiTexCoord2ivARB = __indirect_glMultiTexCoord2ivARB;
+ glAPI->MultiTexCoord2sARB = __indirect_glMultiTexCoord2sARB;
+ glAPI->MultiTexCoord2svARB = __indirect_glMultiTexCoord2svARB;
+ glAPI->MultiTexCoord3dARB = __indirect_glMultiTexCoord3dARB;
+ glAPI->MultiTexCoord3dvARB = __indirect_glMultiTexCoord3dvARB;
+ glAPI->MultiTexCoord3fARB = __indirect_glMultiTexCoord3fARB;
+ glAPI->MultiTexCoord3fvARB = __indirect_glMultiTexCoord3fvARB;
+ glAPI->MultiTexCoord3iARB = __indirect_glMultiTexCoord3iARB;
+ glAPI->MultiTexCoord3ivARB = __indirect_glMultiTexCoord3ivARB;
+ glAPI->MultiTexCoord3sARB = __indirect_glMultiTexCoord3sARB;
+ glAPI->MultiTexCoord3svARB = __indirect_glMultiTexCoord3svARB;
+ glAPI->MultiTexCoord4dARB = __indirect_glMultiTexCoord4dARB;
+ glAPI->MultiTexCoord4dvARB = __indirect_glMultiTexCoord4dvARB;
+ glAPI->MultiTexCoord4fARB = __indirect_glMultiTexCoord4fARB;
+ glAPI->MultiTexCoord4fvARB = __indirect_glMultiTexCoord4fvARB;
+ glAPI->MultiTexCoord4iARB = __indirect_glMultiTexCoord4iARB;
+ glAPI->MultiTexCoord4ivARB = __indirect_glMultiTexCoord4ivARB;
+ glAPI->MultiTexCoord4sARB = __indirect_glMultiTexCoord4sARB;
+ glAPI->MultiTexCoord4svARB = __indirect_glMultiTexCoord4svARB;
+ glAPI->ActiveTextureARB = __indirect_glActiveTextureARB;
+ glAPI->ClientActiveTextureARB = __indirect_glClientActiveTextureARB;
+ glAPI->MultiTexCoord1dARB = __indirect_glMultiTexCoord1dARB;
+ glAPI->MultiTexCoord1dvARB = __indirect_glMultiTexCoord1dvARB;
+ glAPI->MultiTexCoord1fARB = __indirect_glMultiTexCoord1fARB;
+ glAPI->MultiTexCoord1fvARB = __indirect_glMultiTexCoord1fvARB;
+ glAPI->MultiTexCoord1iARB = __indirect_glMultiTexCoord1iARB;
+ glAPI->MultiTexCoord1ivARB = __indirect_glMultiTexCoord1ivARB;
+ glAPI->MultiTexCoord1sARB = __indirect_glMultiTexCoord1sARB;
+ glAPI->MultiTexCoord1svARB = __indirect_glMultiTexCoord1svARB;
+
+ /* 3. GL_ARB_transpose_matrix */
+
+ glAPI->LoadTransposeMatrixfARB = __indirect_glLoadTransposeMatrixfARB;
+ glAPI->LoadTransposeMatrixdARB = __indirect_glLoadTransposeMatrixdARB;
+ glAPI->MultTransposeMatrixfARB = __indirect_glMultTransposeMatrixfARB;
+ glAPI->MultTransposeMatrixdARB = __indirect_glMultTransposeMatrixdARB;
+
+ /* 5. GL_ARB_multisample */
+
+ glAPI->SampleCoverageARB = __indirect_glSampleCoverageARB;
+
+ /* 12. GL_ARB_texture_compression */
+
+ glAPI->CompressedTexImage3DARB = __indirect_glCompressedTexImage3DARB;
+ glAPI->CompressedTexImage2DARB = __indirect_glCompressedTexImage2DARB;
+ glAPI->CompressedTexImage1DARB = __indirect_glCompressedTexImage1DARB;
+ glAPI->CompressedTexSubImage3DARB = __indirect_glCompressedTexSubImage3DARB;
+ glAPI->CompressedTexSubImage2DARB = __indirect_glCompressedTexSubImage2DARB;
+ glAPI->CompressedTexSubImage1DARB = __indirect_glCompressedTexSubImage1DARB;
+ glAPI->GetCompressedTexImageARB = __indirect_glGetCompressedTexImageARB;
+
+ /* 26. GL_ARB_vertex_program */
+
+ glAPI->VertexAttrib4bvARB = __indirect_glVertexAttrib4bvARB;
+ glAPI->VertexAttrib4ivARB = __indirect_glVertexAttrib4ivARB;
+ glAPI->VertexAttrib4ubvARB = __indirect_glVertexAttrib4ubvARB;
+ glAPI->VertexAttrib4usvARB = __indirect_glVertexAttrib4usvARB;
+ glAPI->VertexAttrib4uivARB = __indirect_glVertexAttrib4uivARB;
+ glAPI->VertexAttrib4NbvARB = __indirect_glVertexAttrib4NbvARB;
+ glAPI->VertexAttrib4NsvARB = __indirect_glVertexAttrib4NsvARB;
+ glAPI->VertexAttrib4NivARB = __indirect_glVertexAttrib4NivARB;
+ glAPI->VertexAttrib4NusvARB = __indirect_glVertexAttrib4NusvARB;
+ glAPI->VertexAttrib4NuivARB = __indirect_glVertexAttrib4NuivARB;
+ glAPI->VertexAttribPointerARB = __indirect_glVertexAttribPointerARB;
+ glAPI->EnableVertexAttribArrayARB = __indirect_glEnableVertexAttribArrayARB;
+ glAPI->DisableVertexAttribArrayARB = __indirect_glDisableVertexAttribArrayARB;
+ glAPI->ProgramStringARB = __indirect_glProgramStringARB;
+ glAPI->ProgramEnvParameter4dARB = __indirect_glProgramEnvParameter4dARB;
+ glAPI->ProgramEnvParameter4dvARB = __indirect_glProgramEnvParameter4dvARB;
+ glAPI->ProgramEnvParameter4fARB = __indirect_glProgramEnvParameter4fARB;
+ glAPI->ProgramEnvParameter4fvARB = __indirect_glProgramEnvParameter4fvARB;
+ glAPI->ProgramLocalParameter4dARB = __indirect_glProgramLocalParameter4dARB;
+ glAPI->ProgramLocalParameter4dvARB = __indirect_glProgramLocalParameter4dvARB;
+ glAPI->ProgramLocalParameter4fARB = __indirect_glProgramLocalParameter4fARB;
+ glAPI->ProgramLocalParameter4fvARB = __indirect_glProgramLocalParameter4fvARB;
+ glAPI->GetProgramEnvParameterdvARB = __indirect_glGetProgramEnvParameterdvARB;
+ glAPI->GetProgramEnvParameterfvARB = __indirect_glGetProgramEnvParameterfvARB;
+ glAPI->GetProgramLocalParameterdvARB = __indirect_glGetProgramLocalParameterdvARB;
+ glAPI->GetProgramLocalParameterfvARB = __indirect_glGetProgramLocalParameterfvARB;
+ glAPI->GetProgramivARB = __indirect_glGetProgramivARB;
+ glAPI->GetProgramStringARB = __indirect_glGetProgramStringARB;
+ glAPI->GetVertexAttribdvARB = __indirect_glGetVertexAttribdvARB;
+ glAPI->GetVertexAttribfvARB = __indirect_glGetVertexAttribfvARB;
+ glAPI->GetVertexAttribivARB = __indirect_glGetVertexAttribivARB;
+ glAPI->VertexAttrib1dARB = __indirect_glVertexAttrib1dARB;
+ glAPI->VertexAttrib1dvARB = __indirect_glVertexAttrib1dvARB;
+ glAPI->VertexAttrib1fARB = __indirect_glVertexAttrib1fARB;
+ glAPI->VertexAttrib1fvARB = __indirect_glVertexAttrib1fvARB;
+ glAPI->VertexAttrib1sARB = __indirect_glVertexAttrib1sARB;
+ glAPI->VertexAttrib1svARB = __indirect_glVertexAttrib1svARB;
+ glAPI->VertexAttrib2dARB = __indirect_glVertexAttrib2dARB;
+ glAPI->VertexAttrib2dvARB = __indirect_glVertexAttrib2dvARB;
+ glAPI->VertexAttrib2fARB = __indirect_glVertexAttrib2fARB;
+ glAPI->VertexAttrib2fvARB = __indirect_glVertexAttrib2fvARB;
+ glAPI->VertexAttrib2sARB = __indirect_glVertexAttrib2sARB;
+ glAPI->VertexAttrib2svARB = __indirect_glVertexAttrib2svARB;
+ glAPI->VertexAttrib3dARB = __indirect_glVertexAttrib3dARB;
+ glAPI->VertexAttrib3dvARB = __indirect_glVertexAttrib3dvARB;
+ glAPI->VertexAttrib3fARB = __indirect_glVertexAttrib3fARB;
+ glAPI->VertexAttrib3fvARB = __indirect_glVertexAttrib3fvARB;
+ glAPI->VertexAttrib3sARB = __indirect_glVertexAttrib3sARB;
+ glAPI->VertexAttrib3svARB = __indirect_glVertexAttrib3svARB;
+ glAPI->VertexAttrib4dARB = __indirect_glVertexAttrib4dARB;
+ glAPI->VertexAttrib4dvARB = __indirect_glVertexAttrib4dvARB;
+ glAPI->VertexAttrib4fARB = __indirect_glVertexAttrib4fARB;
+ glAPI->VertexAttrib4fvARB = __indirect_glVertexAttrib4fvARB;
+ glAPI->VertexAttrib4sARB = __indirect_glVertexAttrib4sARB;
+ glAPI->VertexAttrib4svARB = __indirect_glVertexAttrib4svARB;
+ glAPI->VertexAttrib4NubARB = __indirect_glVertexAttrib4NubARB;
+ glAPI->VertexAttrib4NubvARB = __indirect_glVertexAttrib4NubvARB;
+
+ /* 29. GL_ARB_occlusion_query */
+
+ glAPI->EndQueryARB = __indirect_glEndQueryARB;
+ glAPI->GetQueryivARB = __indirect_glGetQueryivARB;
+ glAPI->GetQueryObjectivARB = __indirect_glGetQueryObjectivARB;
+ glAPI->GetQueryObjectuivARB = __indirect_glGetQueryObjectuivARB;
+ glAPI->GenQueriesARB = __indirect_glGenQueriesARB;
+ glAPI->DeleteQueriesARB = __indirect_glDeleteQueriesARB;
+ glAPI->IsQueryARB = __indirect_glIsQueryARB;
+ glAPI->BeginQueryARB = __indirect_glBeginQueryARB;
+
+ /* 37. GL_ARB_draw_buffers */
+
+ glAPI->DrawBuffersARB = __indirect_glDrawBuffersARB;
+
+ /* 20. GL_EXT_texture_object */
+
+ glAPI->GenTexturesEXT = __indirect_glGenTexturesEXT;
+ glAPI->IsTextureEXT = __indirect_glIsTextureEXT;
+ glAPI->AreTexturesResidentEXT = __indirect_glAreTexturesResidentEXT;
+
+ /* 25. GL_SGIS_multisample */
+
+ glAPI->SampleMaskSGIS = __indirect_glSampleMaskSGIS;
+ glAPI->SamplePatternSGIS = __indirect_glSamplePatternSGIS;
+
+ /* 30. GL_EXT_vertex_array */
+
+ glAPI->ColorPointerEXT = __indirect_glColorPointerEXT;
+ glAPI->EdgeFlagPointerEXT = __indirect_glEdgeFlagPointerEXT;
+ glAPI->IndexPointerEXT = __indirect_glIndexPointerEXT;
+ glAPI->NormalPointerEXT = __indirect_glNormalPointerEXT;
+ glAPI->TexCoordPointerEXT = __indirect_glTexCoordPointerEXT;
+ glAPI->VertexPointerEXT = __indirect_glVertexPointerEXT;
+
+ /* 54. GL_EXT_point_parameters */
+
+ glAPI->PointParameterfEXT = __indirect_glPointParameterfEXT;
+ glAPI->PointParameterfvEXT = __indirect_glPointParameterfvEXT;
+
+ /* 145. GL_EXT_secondary_color */
+
+ glAPI->SecondaryColor3usvEXT = __indirect_glSecondaryColor3usvEXT;
+ glAPI->SecondaryColorPointerEXT = __indirect_glSecondaryColorPointerEXT;
+ glAPI->SecondaryColor3bEXT = __indirect_glSecondaryColor3bEXT;
+ glAPI->SecondaryColor3bvEXT = __indirect_glSecondaryColor3bvEXT;
+ glAPI->SecondaryColor3dEXT = __indirect_glSecondaryColor3dEXT;
+ glAPI->SecondaryColor3dvEXT = __indirect_glSecondaryColor3dvEXT;
+ glAPI->SecondaryColor3fEXT = __indirect_glSecondaryColor3fEXT;
+ glAPI->SecondaryColor3fvEXT = __indirect_glSecondaryColor3fvEXT;
+ glAPI->SecondaryColor3iEXT = __indirect_glSecondaryColor3iEXT;
+ glAPI->SecondaryColor3ivEXT = __indirect_glSecondaryColor3ivEXT;
+ glAPI->SecondaryColor3sEXT = __indirect_glSecondaryColor3sEXT;
+ glAPI->SecondaryColor3svEXT = __indirect_glSecondaryColor3svEXT;
+ glAPI->SecondaryColor3ubEXT = __indirect_glSecondaryColor3ubEXT;
+ glAPI->SecondaryColor3ubvEXT = __indirect_glSecondaryColor3ubvEXT;
+ glAPI->SecondaryColor3uiEXT = __indirect_glSecondaryColor3uiEXT;
+ glAPI->SecondaryColor3uivEXT = __indirect_glSecondaryColor3uivEXT;
+ glAPI->SecondaryColor3usEXT = __indirect_glSecondaryColor3usEXT;
+
+ /* 148. GL_EXT_multi_draw_arrays */
+
+ glAPI->MultiDrawArraysEXT = __indirect_glMultiDrawArraysEXT;
+ glAPI->MultiDrawElementsEXT = __indirect_glMultiDrawElementsEXT;
+
+ /* 149. GL_EXT_fog_coord */
+
+ glAPI->FogCoordfEXT = __indirect_glFogCoordfEXT;
+ glAPI->FogCoordfvEXT = __indirect_glFogCoordfvEXT;
+ glAPI->FogCoorddEXT = __indirect_glFogCoorddEXT;
+ glAPI->FogCoorddvEXT = __indirect_glFogCoorddvEXT;
+ glAPI->FogCoordPointerEXT = __indirect_glFogCoordPointerEXT;
+
+ /* 173. GL_EXT_blend_func_separate */
+
+ glAPI->BlendFuncSeparateEXT = __indirect_glBlendFuncSeparateEXT;
+
+ /* 197. GL_MESA_window_pos */
+
+ glAPI->WindowPos2dMESA = __indirect_glWindowPos2dMESA;
+ glAPI->WindowPos2dvMESA = __indirect_glWindowPos2dvMESA;
+ glAPI->WindowPos2fMESA = __indirect_glWindowPos2fMESA;
+ glAPI->WindowPos2fvMESA = __indirect_glWindowPos2fvMESA;
+ glAPI->WindowPos2iMESA = __indirect_glWindowPos2iMESA;
+ glAPI->WindowPos2ivMESA = __indirect_glWindowPos2ivMESA;
+ glAPI->WindowPos2sMESA = __indirect_glWindowPos2sMESA;
+ glAPI->WindowPos2svMESA = __indirect_glWindowPos2svMESA;
+ glAPI->WindowPos3dMESA = __indirect_glWindowPos3dMESA;
+ glAPI->WindowPos3dvMESA = __indirect_glWindowPos3dvMESA;
+ glAPI->WindowPos3fMESA = __indirect_glWindowPos3fMESA;
+ glAPI->WindowPos3fvMESA = __indirect_glWindowPos3fvMESA;
+ glAPI->WindowPos3iMESA = __indirect_glWindowPos3iMESA;
+ glAPI->WindowPos3ivMESA = __indirect_glWindowPos3ivMESA;
+ glAPI->WindowPos3sMESA = __indirect_glWindowPos3sMESA;
+ glAPI->WindowPos3svMESA = __indirect_glWindowPos3svMESA;
+
+ /* 233. GL_NV_vertex_program */
+
+ glAPI->VertexAttribs4svNV = __indirect_glVertexAttribs4svNV;
+ glAPI->VertexAttribs4ubvNV = __indirect_glVertexAttribs4ubvNV;
+ glAPI->VertexAttrib3fNV = __indirect_glVertexAttrib3fNV;
+ glAPI->VertexAttrib3fvNV = __indirect_glVertexAttrib3fvNV;
+ glAPI->VertexAttrib3sNV = __indirect_glVertexAttrib3sNV;
+ glAPI->VertexAttrib3svNV = __indirect_glVertexAttrib3svNV;
+ glAPI->VertexAttrib4dNV = __indirect_glVertexAttrib4dNV;
+ glAPI->VertexAttrib3dvNV = __indirect_glVertexAttrib3dvNV;
+ glAPI->VertexAttrib4fNV = __indirect_glVertexAttrib4fNV;
+ glAPI->VertexAttrib4fvNV = __indirect_glVertexAttrib4fvNV;
+ glAPI->VertexAttrib4sNV = __indirect_glVertexAttrib4sNV;
+ glAPI->VertexAttrib4svNV = __indirect_glVertexAttrib4svNV;
+ glAPI->VertexAttrib4ubNV = __indirect_glVertexAttrib4ubNV;
+ glAPI->VertexAttrib4ubvNV = __indirect_glVertexAttrib4ubvNV;
+ glAPI->VertexAttrib1fvNV = __indirect_glVertexAttrib1fvNV;
+ glAPI->VertexAttrib3dNV = __indirect_glVertexAttrib3dNV;
+ glAPI->VertexAttrib4dvNV = __indirect_glVertexAttrib4dvNV;
+ glAPI->VertexAttrib1sNV = __indirect_glVertexAttrib1sNV;
+ glAPI->VertexAttrib1fNV = __indirect_glVertexAttrib1fNV;
+ glAPI->VertexAttrib1svNV = __indirect_glVertexAttrib1svNV;
+ glAPI->VertexAttrib1dvNV = __indirect_glVertexAttrib1dvNV;
+ glAPI->AreProgramsResidentNV = __indirect_glAreProgramsResidentNV;
+ glAPI->BindProgramNV = __indirect_glBindProgramNV;
+ glAPI->DeleteProgramsNV = __indirect_glDeleteProgramsNV;
+ glAPI->ExecuteProgramNV = __indirect_glExecuteProgramNV;
+ glAPI->GenProgramsNV = __indirect_glGenProgramsNV;
+ glAPI->GetProgramParameterdvNV = __indirect_glGetProgramParameterdvNV;
+ glAPI->GetProgramParameterfvNV = __indirect_glGetProgramParameterfvNV;
+ glAPI->GetProgramivNV = __indirect_glGetProgramivNV;
+ glAPI->GetProgramStringNV = __indirect_glGetProgramStringNV;
+ glAPI->GetTrackMatrixivNV = __indirect_glGetTrackMatrixivNV;
+ glAPI->GetVertexAttribPointervNV = __indirect_glGetVertexAttribPointervNV;
+ glAPI->IsProgramNV = __indirect_glIsProgramNV;
+ glAPI->LoadProgramNV = __indirect_glLoadProgramNV;
+ glAPI->ProgramParameter4dNV = __indirect_glProgramParameter4dNV;
+ glAPI->ProgramParameter4dvNV = __indirect_glProgramParameter4dvNV;
+ glAPI->ProgramParameter4fNV = __indirect_glProgramParameter4fNV;
+ glAPI->ProgramParameter4fvNV = __indirect_glProgramParameter4fvNV;
+ glAPI->ProgramParameters4dvNV = __indirect_glProgramParameters4dvNV;
+ glAPI->ProgramParameters4fvNV = __indirect_glProgramParameters4fvNV;
+ glAPI->RequestResidentProgramsNV = __indirect_glRequestResidentProgramsNV;
+ glAPI->TrackMatrixNV = __indirect_glTrackMatrixNV;
+ glAPI->VertexAttribPointerNV = __indirect_glVertexAttribPointerNV;
+ glAPI->VertexAttrib2dNV = __indirect_glVertexAttrib2dNV;
+ glAPI->VertexAttrib2sNV = __indirect_glVertexAttrib2sNV;
+ glAPI->VertexAttrib2dvNV = __indirect_glVertexAttrib2dvNV;
+ glAPI->VertexAttrib2fNV = __indirect_glVertexAttrib2fNV;
+ glAPI->VertexAttrib2svNV = __indirect_glVertexAttrib2svNV;
+ glAPI->VertexAttrib2fvNV = __indirect_glVertexAttrib2fvNV;
+ glAPI->GetVertexAttribdvNV = __indirect_glGetVertexAttribdvNV;
+ glAPI->GetVertexAttribfvNV = __indirect_glGetVertexAttribfvNV;
+ glAPI->GetVertexAttribivNV = __indirect_glGetVertexAttribivNV;
+ glAPI->VertexAttrib1dNV = __indirect_glVertexAttrib1dNV;
+ glAPI->VertexAttribs1dvNV = __indirect_glVertexAttribs1dvNV;
+ glAPI->VertexAttribs1fvNV = __indirect_glVertexAttribs1fvNV;
+ glAPI->VertexAttribs1svNV = __indirect_glVertexAttribs1svNV;
+ glAPI->VertexAttribs2dvNV = __indirect_glVertexAttribs2dvNV;
+ glAPI->VertexAttribs2fvNV = __indirect_glVertexAttribs2fvNV;
+ glAPI->VertexAttribs2svNV = __indirect_glVertexAttribs2svNV;
+ glAPI->VertexAttribs3dvNV = __indirect_glVertexAttribs3dvNV;
+ glAPI->VertexAttribs3fvNV = __indirect_glVertexAttribs3fvNV;
+ glAPI->VertexAttribs3svNV = __indirect_glVertexAttribs3svNV;
+ glAPI->VertexAttribs4dvNV = __indirect_glVertexAttribs4dvNV;
+ glAPI->VertexAttribs4fvNV = __indirect_glVertexAttribs4fvNV;
+
+ /* 262. GL_NV_point_sprite */
+
+ glAPI->PointParameteriNV = __indirect_glPointParameteriNV;
+ glAPI->PointParameterivNV = __indirect_glPointParameterivNV;
+
+ /* 268. GL_EXT_stencil_two_side */
+
+ glAPI->ActiveStencilFaceEXT = __indirect_glActiveStencilFaceEXT;
+
+ /* 282. GL_NV_fragment_program */
+
+ glAPI->ProgramNamedParameter4fNV = __indirect_glProgramNamedParameter4fNV;
+ glAPI->ProgramNamedParameter4dNV = __indirect_glProgramNamedParameter4dNV;
+ glAPI->ProgramNamedParameter4fvNV = __indirect_glProgramNamedParameter4fvNV;
+ glAPI->ProgramNamedParameter4dvNV = __indirect_glProgramNamedParameter4dvNV;
+ glAPI->GetProgramNamedParameterfvNV = __indirect_glGetProgramNamedParameterfvNV;
+ glAPI->GetProgramNamedParameterdvNV = __indirect_glGetProgramNamedParameterdvNV;
+
+ /* 310. GL_EXT_framebuffer_object */
+
+ glAPI->RenderbufferStorageEXT = __indirect_glRenderbufferStorageEXT;
+ glAPI->GetRenderbufferParameterivEXT = __indirect_glGetRenderbufferParameterivEXT;
+ glAPI->IsFramebufferEXT = __indirect_glIsFramebufferEXT;
+ glAPI->BindFramebufferEXT = __indirect_glBindFramebufferEXT;
+ glAPI->DeleteFramebuffersEXT = __indirect_glDeleteFramebuffersEXT;
+ glAPI->GenFramebuffersEXT = __indirect_glGenFramebuffersEXT;
+ glAPI->CheckFramebufferStatusEXT = __indirect_glCheckFramebufferStatusEXT;
+ glAPI->FramebufferTexture1DEXT = __indirect_glFramebufferTexture1DEXT;
+ glAPI->FramebufferTexture2DEXT = __indirect_glFramebufferTexture2DEXT;
+ glAPI->FramebufferTexture3DEXT = __indirect_glFramebufferTexture3DEXT;
+ glAPI->FramebufferRenderbufferEXT = __indirect_glFramebufferRenderbufferEXT;
+ glAPI->GetFramebufferAttachmentParameterivEXT = __indirect_glGetFramebufferAttachmentParameterivEXT;
+ glAPI->GenerateMipmapEXT = __indirect_glGenerateMipmapEXT;
+ glAPI->IsRenderbufferEXT = __indirect_glIsRenderbufferEXT;
+ glAPI->BindRenderbufferEXT = __indirect_glBindRenderbufferEXT;
+ glAPI->DeleteRenderbuffersEXT = __indirect_glDeleteRenderbuffersEXT;
+ glAPI->GenRenderbuffersEXT = __indirect_glGenRenderbuffersEXT;
+
+ return glAPI;
+}
+
diff --git a/nx-X11/extras/Mesa/src/glx/x11/indirect_init.h b/nx-X11/extras/Mesa/src/glx/x11/indirect_init.h
new file mode 100644
index 000000000..62d04ba6d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/indirect_init.h
@@ -0,0 +1,42 @@
+/* $XFree86: xc/lib/GL/glx/indirect_init.h,v 1.2 2000/02/08 17:18:33 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:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _INDIRECT_INIT_H_
+#define _INDIRECT_INIT_H_
+
+#include "glxclient.h"
+
+extern __GLapi *__glXNewIndirectAPI(void);
+
+#endif /* _INDIRECT_INIT_H_ */
diff --git a/nx-X11/extras/Mesa/src/glx/x11/indirect_size.c b/nx-X11/extras/Mesa/src/glx/x11/indirect_size.c
new file mode 100644
index 000000000..1fce2f5ca
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/indirect_size.c
@@ -0,0 +1,377 @@
+/* DO NOT EDIT - This file generated automatically by glX_proto_size.py (from Mesa) script */
+
+/*
+ * (C) Copyright IBM Corporation 2004
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+#include <GL/gl.h>
+#include "indirect_size.h"
+
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+# define PURE __attribute__((pure))
+# else
+# define PURE
+# endif
+
+# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__)
+# define FASTCALL __attribute__((fastcall))
+# else
+# define FASTCALL
+# endif
+
+# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__)
+# define INTERNAL __attribute__((visibility("internal")))
+# else
+# define INTERNAL
+# endif
+
+# if defined(__CYGWIN__) || defined(__MINGW32__)
+# undef FASTCALL
+# define FASTCALL
+# undef HAVE_ALIAS
+# undef INTERNAL
+# define INTERNAL
+# endif
+
+#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__)
+# undef HAVE_ALIAS
+#endif
+#ifdef HAVE_ALIAS
+# define ALIAS2(from,to) \
+ INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \
+ __attribute__ ((alias( # to )));
+# define ALIAS(from,to) ALIAS2( from, __gl ## to ## _size )
+#else
+# define ALIAS(from,to) \
+ INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \
+ { return __gl ## to ## _size( e ); }
+#endif
+
+
+INTERNAL PURE FASTCALL GLint
+__glCallLists_size( GLenum e )
+{
+ switch( e ) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ return 1;
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_2_BYTES:
+ return 2;
+ case GL_3_BYTES:
+ return 3;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ case GL_4_BYTES:
+ return 4;
+ default: return 0;
+ }
+}
+
+INTERNAL PURE FASTCALL GLint
+__glFogfv_size( GLenum e )
+{
+ switch( e ) {
+ case GL_FOG_INDEX:
+ case GL_FOG_DENSITY:
+ case GL_FOG_START:
+ case GL_FOG_END:
+ case GL_FOG_MODE:
+ case GL_FOG_OFFSET_VALUE_SGIX:
+ case GL_FOG_DISTANCE_MODE_NV:
+ return 1;
+ case GL_FOG_COLOR:
+ return 4;
+ default: return 0;
+ }
+}
+
+INTERNAL PURE FASTCALL GLint
+__glLightfv_size( GLenum e )
+{
+ switch( e ) {
+ case GL_SPOT_EXPONENT:
+ case GL_SPOT_CUTOFF:
+ case GL_CONSTANT_ATTENUATION:
+ case GL_LINEAR_ATTENUATION:
+ case GL_QUADRATIC_ATTENUATION:
+ return 1;
+ case GL_SPOT_DIRECTION:
+ return 3;
+ case GL_AMBIENT:
+ case GL_DIFFUSE:
+ case GL_SPECULAR:
+ case GL_POSITION:
+ return 4;
+ default: return 0;
+ }
+}
+
+INTERNAL PURE FASTCALL GLint
+__glLightModelfv_size( GLenum e )
+{
+ switch( e ) {
+ case GL_LIGHT_MODEL_LOCAL_VIEWER:
+ case GL_LIGHT_MODEL_TWO_SIDE:
+ case GL_LIGHT_MODEL_COLOR_CONTROL:
+/* case GL_LIGHT_MODEL_COLOR_CONTROL_EXT:*/
+ return 1;
+ case GL_LIGHT_MODEL_AMBIENT:
+ return 4;
+ default: return 0;
+ }
+}
+
+INTERNAL PURE FASTCALL GLint
+__glMaterialfv_size( GLenum e )
+{
+ switch( e ) {
+ case GL_SHININESS:
+ return 1;
+ case GL_COLOR_INDEXES:
+ return 3;
+ case GL_AMBIENT:
+ case GL_DIFFUSE:
+ case GL_SPECULAR:
+ case GL_EMISSION:
+ case GL_AMBIENT_AND_DIFFUSE:
+ return 4;
+ default: return 0;
+ }
+}
+
+INTERNAL PURE FASTCALL GLint
+__glTexParameterfv_size( GLenum e )
+{
+ switch( e ) {
+ case GL_TEXTURE_MAG_FILTER:
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ case GL_TEXTURE_PRIORITY:
+ case GL_TEXTURE_WRAP_R:
+ case GL_TEXTURE_COMPARE_FAIL_VALUE_ARB:
+/* case GL_SHADOW_AMBIENT_SGIX:*/
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ case GL_TEXTURE_CLIPMAP_FRAME_SGIX:
+ case GL_TEXTURE_LOD_BIAS_S_SGIX:
+ case GL_TEXTURE_LOD_BIAS_T_SGIX:
+ case GL_TEXTURE_LOD_BIAS_R_SGIX:
+ case GL_GENERATE_MIPMAP:
+/* case GL_GENERATE_MIPMAP_SGIS:*/
+ case GL_TEXTURE_COMPARE_SGIX:
+ case GL_TEXTURE_COMPARE_OPERATOR_SGIX:
+ case GL_TEXTURE_MAX_CLAMP_S_SGIX:
+ case GL_TEXTURE_MAX_CLAMP_T_SGIX:
+ case GL_TEXTURE_MAX_CLAMP_R_SGIX:
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+ case GL_TEXTURE_LOD_BIAS:
+/* case GL_TEXTURE_LOD_BIAS_EXT:*/
+ case GL_DEPTH_TEXTURE_MODE:
+/* case GL_DEPTH_TEXTURE_MODE_ARB:*/
+ case GL_TEXTURE_COMPARE_MODE:
+/* case GL_TEXTURE_COMPARE_MODE_ARB:*/
+ case GL_TEXTURE_COMPARE_FUNC:
+/* case GL_TEXTURE_COMPARE_FUNC_ARB:*/
+ case GL_TEXTURE_UNSIGNED_REMAP_MODE_NV:
+ return 1;
+ case GL_TEXTURE_CLIPMAP_CENTER_SGIX:
+ case GL_TEXTURE_CLIPMAP_OFFSET_SGIX:
+ return 2;
+ case GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX:
+ return 3;
+ case GL_TEXTURE_BORDER_COLOR:
+ case GL_POST_TEXTURE_FILTER_BIAS_SGIX:
+ case GL_POST_TEXTURE_FILTER_SCALE_SGIX:
+ return 4;
+ default: return 0;
+ }
+}
+
+INTERNAL PURE FASTCALL GLint
+__glTexEnvfv_size( GLenum e )
+{
+ switch( e ) {
+ case GL_ALPHA_SCALE:
+ case GL_TEXTURE_ENV_MODE:
+ case GL_TEXTURE_LOD_BIAS:
+ case GL_COMBINE_RGB:
+ case GL_COMBINE_ALPHA:
+ case GL_RGB_SCALE:
+ case GL_SOURCE0_RGB:
+ case GL_SOURCE1_RGB:
+ case GL_SOURCE2_RGB:
+ case GL_SOURCE3_RGB_NV:
+ case GL_SOURCE0_ALPHA:
+ case GL_SOURCE1_ALPHA:
+ case GL_SOURCE2_ALPHA:
+ case GL_SOURCE3_ALPHA_NV:
+ case GL_OPERAND0_RGB:
+ case GL_OPERAND1_RGB:
+ case GL_OPERAND2_RGB:
+ case GL_OPERAND3_RGB_NV:
+ case GL_OPERAND0_ALPHA:
+ case GL_OPERAND1_ALPHA:
+ case GL_OPERAND2_ALPHA:
+ case GL_OPERAND3_ALPHA_NV:
+ case GL_COORD_REPLACE_ARB:
+/* case GL_COORD_REPLACE_NV:*/
+ return 1;
+ case GL_TEXTURE_ENV_COLOR:
+ return 4;
+ default: return 0;
+ }
+}
+
+INTERNAL PURE FASTCALL GLint
+__glTexGendv_size( GLenum e )
+{
+ switch( e ) {
+ case GL_TEXTURE_GEN_MODE:
+ return 1;
+ case GL_OBJECT_PLANE:
+ case GL_EYE_PLANE:
+ return 4;
+ default: return 0;
+ }
+}
+
+INTERNAL PURE FASTCALL GLint
+__glMap1d_size( GLenum e )
+{
+ switch( e ) {
+ case GL_MAP1_INDEX:
+ case GL_MAP1_TEXTURE_COORD_1:
+ return 1;
+ case GL_MAP1_TEXTURE_COORD_2:
+ return 2;
+ case GL_MAP1_NORMAL:
+ case GL_MAP1_TEXTURE_COORD_3:
+ case GL_MAP1_VERTEX_3:
+ return 3;
+ case GL_MAP1_COLOR_4:
+ case GL_MAP1_TEXTURE_COORD_4:
+ case GL_MAP1_VERTEX_4:
+ return 4;
+ default: return 0;
+ }
+}
+
+INTERNAL PURE FASTCALL GLint
+__glMap2d_size( GLenum e )
+{
+ switch( e ) {
+ case GL_MAP2_INDEX:
+ case GL_MAP2_TEXTURE_COORD_1:
+ return 1;
+ case GL_MAP2_TEXTURE_COORD_2:
+ return 2;
+ case GL_MAP2_NORMAL:
+ case GL_MAP2_TEXTURE_COORD_3:
+ case GL_MAP2_VERTEX_3:
+ return 3;
+ case GL_MAP2_COLOR_4:
+ case GL_MAP2_TEXTURE_COORD_4:
+ case GL_MAP2_VERTEX_4:
+ return 4;
+ default: return 0;
+ }
+}
+
+INTERNAL PURE FASTCALL GLint
+__glColorTableParameterfv_size( GLenum e )
+{
+ switch( e ) {
+ case GL_COLOR_TABLE_SCALE:
+ case GL_COLOR_TABLE_BIAS:
+ return 4;
+ default: return 0;
+ }
+}
+
+INTERNAL PURE FASTCALL GLint
+__glConvolutionParameterfv_size( GLenum e )
+{
+ switch( e ) {
+ case GL_CONVOLUTION_BORDER_MODE:
+/* case GL_CONVOLUTION_BORDER_MODE_EXT:*/
+ return 1;
+ case GL_CONVOLUTION_FILTER_SCALE:
+/* case GL_CONVOLUTION_FILTER_SCALE_EXT:*/
+ case GL_CONVOLUTION_FILTER_BIAS:
+/* case GL_CONVOLUTION_FILTER_BIAS_EXT:*/
+ case GL_CONVOLUTION_BORDER_COLOR:
+/* case GL_CONVOLUTION_BORDER_COLOR_HP:*/
+ return 4;
+ default: return 0;
+ }
+}
+
+INTERNAL PURE FASTCALL GLint
+__glPointParameterfvEXT_size( GLenum e )
+{
+ switch( e ) {
+ case GL_POINT_SIZE_MIN:
+/* case GL_POINT_SIZE_MIN_ARB:*/
+/* case GL_POINT_SIZE_MIN_SGIS:*/
+ case GL_POINT_SIZE_MAX:
+/* case GL_POINT_SIZE_MAX_ARB:*/
+/* case GL_POINT_SIZE_MAX_SGIS:*/
+ case GL_POINT_FADE_THRESHOLD_SIZE:
+/* case GL_POINT_FADE_THRESHOLD_SIZE_ARB:*/
+/* case GL_POINT_FADE_THRESHOLD_SIZE_SGIS:*/
+ case GL_POINT_SPRITE_R_MODE_NV:
+ case GL_POINT_SPRITE_COORD_ORIGIN:
+ return 1;
+ case GL_POINT_DISTANCE_ATTENUATION:
+/* case GL_POINT_DISTANCE_ATTENUATION_ARB:*/
+/* case GL_POINT_DISTANCE_ATTENUATION_SGIS:*/
+ return 3;
+ default: return 0;
+ }
+}
+
+ALIAS( Fogiv, Fogfv )
+ALIAS( Lightiv, Lightfv )
+ALIAS( LightModeliv, LightModelfv )
+ALIAS( Materialiv, Materialfv )
+ALIAS( TexParameteriv, TexParameterfv )
+ALIAS( TexEnviv, TexEnvfv )
+ALIAS( TexGenfv, TexGendv )
+ALIAS( TexGeniv, TexGendv )
+ALIAS( Map1f, Map1d )
+ALIAS( Map2f, Map2d )
+ALIAS( ColorTableParameteriv, ColorTableParameterfv )
+ALIAS( ConvolutionParameteriv, ConvolutionParameterfv )
+ALIAS( PointParameterivNV, PointParameterfvEXT )
+
+# undef PURE
+# undef FASTCALL
+# undef INTERNAL
diff --git a/nx-X11/extras/Mesa/src/glx/x11/indirect_size.h b/nx-X11/extras/Mesa/src/glx/x11/indirect_size.h
new file mode 100644
index 000000000..4c980973f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/indirect_size.h
@@ -0,0 +1,95 @@
+/* DO NOT EDIT - This file generated automatically by glX_proto_size.py (from Mesa) script */
+
+/*
+ * (C) Copyright IBM Corporation 2004
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#if !defined( _INDIRECT_SIZE_H_ )
+# define _INDIRECT_SIZE_H_
+
+/**
+ * \file
+ * Prototypes for functions used to determine the number of data elements in
+ * various GLX protocol messages.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+# define PURE __attribute__((pure))
+# else
+# define PURE
+# endif
+
+# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__)
+# define FASTCALL __attribute__((fastcall))
+# else
+# define FASTCALL
+# endif
+
+# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__)
+# define INTERNAL __attribute__((visibility("internal")))
+# else
+# define INTERNAL
+# endif
+
+# if defined(__CYGWIN__) || defined(__MINGW32__)
+# undef FASTCALL
+# define FASTCALL
+# undef INTERNAL
+# define INTERNAL
+# endif
+
+extern INTERNAL PURE FASTCALL GLint __glCallLists_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glFogfv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glFogiv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glLightfv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glLightiv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glLightModelfv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glLightModeliv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glMaterialfv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glMaterialiv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glTexParameterfv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glTexParameteriv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glTexEnvfv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glTexEnviv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glTexGendv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glTexGenfv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glTexGeniv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glMap1d_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glMap1f_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glMap2d_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glMap2f_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glColorTableParameterfv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glColorTableParameteriv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glConvolutionParameterfv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glConvolutionParameteriv_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glPointParameterfvEXT_size(GLenum);
+extern INTERNAL PURE FASTCALL GLint __glPointParameterivNV_size(GLenum);
+
+# undef PURE
+# undef FASTCALL
+# undef INTERNAL
+
+#endif /* !defined( _INDIRECT_SIZE_H_ ) */
diff --git a/nx-X11/extras/Mesa/src/glx/x11/indirect_transpose_matrix.c b/nx-X11/extras/Mesa/src/glx/x11/indirect_transpose_matrix.c
new file mode 100644
index 000000000..2144410e5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/indirect_transpose_matrix.c
@@ -0,0 +1,83 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * THE COPYRIGHT HOLDERS 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.
+ */
+
+#include <GL/gl.h>
+#include "indirect.h"
+
+static void TransposeMatrixf(const GLfloat s[16], GLfloat d[16])
+{
+ int i, j;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ d[i*4+j] = s[j*4+i];
+ }
+ }
+}
+
+static void TransposeMatrixd(const GLdouble s[16], GLdouble d[16])
+{
+ int i, j;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ d[i*4+j] = s[j*4+i];
+ }
+ }
+}
+
+
+void
+__indirect_glLoadTransposeMatrixdARB( const GLdouble * m )
+{
+ GLdouble mt[16];
+
+ TransposeMatrixd( m, mt );
+ __indirect_glLoadMatrixd( mt );
+}
+
+void
+__indirect_glLoadTransposeMatrixfARB( const GLfloat * m )
+{
+ GLfloat mt[16];
+
+ TransposeMatrixf( m, mt );
+ __indirect_glLoadMatrixf( mt );
+}
+
+void
+__indirect_glMultTransposeMatrixdARB( const GLdouble * m )
+{
+ GLdouble mt[16];
+
+ TransposeMatrixd( m, mt );
+ __indirect_glMultMatrixd( mt );
+}
+
+void
+__indirect_glMultTransposeMatrixfARB( const GLfloat * m )
+{
+ GLfloat mt[16];
+
+ TransposeMatrixf( m, mt );
+ __indirect_glMultMatrixf( mt );
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/indirect_va_private.h b/nx-X11/extras/Mesa/src/glx/x11/indirect_va_private.h
new file mode 100644
index 000000000..ab97dc645
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/indirect_va_private.h
@@ -0,0 +1,308 @@
+/*
+ * (C) Copyright IBM Corporation 2004, 2005
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef _INDIRECT_VA_PRIVATE_
+#define _INDIRECT_VA_PRIVATE_
+
+/**
+ * \file indirect_va_private.h
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include <inttypes.h>
+
+#include "glxclient.h"
+#include "indirect.h"
+#include <GL/glxproto.h>
+
+
+/**
+ * State descriptor for a single array of vertex data.
+ */
+struct array_state {
+ /**
+ * Pointer to the application supplied data.
+ */
+ const void * data;
+
+ /**
+ * Enum representing the type of the application supplied data.
+ */
+ GLenum data_type;
+
+ /**
+ * Stride value supplied by the application. This value is not used
+ * internally. It is only kept so that it can be queried by the
+ * application using glGet*v.
+ */
+ GLsizei user_stride;
+
+ /**
+ * Calculated size, in bytes, of a single element in the array. This
+ * is calculated based on \c count and the size of the data type
+ * represented by \c data_type.
+ */
+ GLsizei element_size;
+
+ /**
+ * Actual byte-stride from one element to the next. This value will
+ * be equal to either \c user_stride or \c element_stride.
+ */
+ GLsizei true_stride;
+
+ /**
+ * Number of data values in each element.
+ */
+ GLint count;
+
+ /**
+ * "Normalized" data is on the range [0,1] (unsigned) or [-1,1] (signed).
+ * This is used for mapping integral types to floating point types.
+ */
+ GLboolean normalized;
+
+ /**
+ * Pre-calculated GLX protocol command header.
+ */
+ uint32_t header[2];
+
+ /**
+ * Size of the header data. For simple data, like glColorPointerfv,
+ * this is 4. For complex data that requires either a count (e.g.,
+ * glWeightfvARB), an index (e.g., glVertexAttrib1fvARB), or a
+ * selector enum (e.g., glMultiTexCoord2fv) this is 8.
+ */
+ unsigned header_size;
+
+ /**
+ * Set to \c GL_TRUE if this array is enabled. Otherwise, it is set
+ * to \c GL_FALSE.
+ */
+ GLboolean enabled;
+
+ /**
+ * For multi-arrayed data (e.g., texture coordinates, generic vertex
+ * program attributes, etc.), this specifies which array this is.
+ */
+ unsigned index;
+
+ /**
+ * Per-array-type key. For most arrays, this will be the GL enum for
+ * that array (e.g., GL_VERTEX_ARRAY for vertex data, GL_NORMAL_ARRAY
+ * for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data,
+ * etc.).
+ */
+ GLenum key;
+
+ /**
+ * If this array can be used with the "classic" \c glDrawArrays protocol,
+ * this is set to \c GL_TRUE. Otherwise, it is set to \c GL_FALSE.
+ */
+ GLboolean old_DrawArrays_possible;
+};
+
+
+/**
+ * Array state that is pushed / poped by \c glPushClientAttrib and
+ * \c glPopClientAttrib.
+ */
+struct array_stack_state {
+ /**
+ * Pointer to the application supplied data.
+ */
+ const void * data;
+
+ /**
+ * Enum representing the type of the application supplied data.
+ */
+ GLenum data_type;
+
+ /**
+ * Stride value supplied by the application. This value is not used
+ * internally. It is only kept so that it can be queried by the
+ * application using glGet*v.
+ */
+ GLsizei user_stride;
+
+ /**
+ * Number of data values in each element.
+ */
+ GLint count;
+
+ /**
+ * Per-array-type key. For most arrays, this will be the GL enum for
+ * that array (e.g., GL_VERTEX_ARRAY for vertex data, GL_NORMAL_ARRAY
+ * for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data,
+ * etc.).
+ */
+ GLenum key;
+
+ /**
+ * For multi-arrayed data (e.g., texture coordinates, generic vertex
+ * program attributes, etc.), this specifies which array this is.
+ */
+ unsigned index;
+
+ /**
+ * Set to \c GL_TRUE if this array is enabled. Otherwise, it is set
+ * to \c GL_FALSE.
+ */
+ GLboolean enabled;
+};
+
+
+/**
+ * Collection of all the vertex array state.
+ */
+struct array_state_vector {
+ /**
+ * Number of arrays tracked by \c ::arrays.
+ */
+ size_t num_arrays;
+
+ /**
+ * Array of vertex array state. This array contains all of the valid
+ * vertex arrays. If a vertex array isn't in this array, then it isn't
+ * valid. For example, if an implementation does not support
+ * EXT_fog_coord, there won't be a GL_FOG_COORD_ARRAY entry in this
+ * array.
+ */
+ struct array_state * arrays;
+
+ /**
+ * Number of currently enabled client-side arrays. The value of this
+ * field is only valid if \c array_info_cache_valid is true.
+ */
+ size_t enabled_client_array_count;
+
+ /**
+ * \name ARRAY_INFO cache.
+ *
+ * These fields track the state of the ARRAY_INFO cache. The
+ * \c array_info_cache_size is the size of the actual data stored in
+ * \c array_info_cache. \c array_info_cache_buffer_size is the size of
+ * the buffer. This will always be greater than or equal to
+ * \c array_info_cache_size.
+ *
+ * \note
+ * There are some bytes of extra data before \c array_info_cache that is
+ * used to hold the header for RenderLarge commands. This is
+ * \b not included in \c array_info_cache_size or
+ * \c array_info_cache_buffer_size. \c array_info_cache_base stores a
+ * pointer to the true start of the buffer (i.e., what malloc returned).
+ */
+ /*@{*/
+ size_t array_info_cache_size;
+ size_t array_info_cache_buffer_size;
+ void * array_info_cache;
+ void * array_info_cache_base;
+ /*@}*/
+
+
+ /**
+ * Is the cache of ARRAY_INFO data valid? The cache can become invalid
+ * when one of several state changes occur. Among these chages are
+ * modifying the array settings for an enabled array and enabling /
+ * disabling an array.
+ */
+ GLboolean array_info_cache_valid;
+
+ /**
+ * Is it possible to use the GL 1.1 / EXT_vertex_arrays protocol? Use
+ * of this protocol is disabled with really old servers (i.e., servers
+ * that don't support GL 1.1 or EXT_vertex_arrays) or when an environment
+ * variable is set.
+ *
+ * \todo
+ * GL 1.1 and EXT_vertex_arrays use identical protocol, but have different
+ * opcodes for \c glDrawArrays. For servers that advertise one or the
+ * other, there should be a way to select which opcode to use.
+ */
+ GLboolean old_DrawArrays_possible;
+
+ /**
+ * Is it possible to use the new GL X.X / ARB_vertex_buffer_object
+ * protocol?
+ *
+ * \todo
+ * This protocol has not yet been defined by the ARB, but is currently a
+ * work in progress. This field is a place-holder.
+ */
+ GLboolean new_DrawArrays_possible;
+
+ /**
+ * Active texture unit set by \c glClientActiveTexture.
+ *
+ * \sa __glXGetActiveTextureUnit
+ */
+ unsigned active_texture_unit;
+
+ /**
+ * Number of supported texture units. Even if ARB_multitexture /
+ * GL 1.3 are not supported, this will be at least 1. When multitexture
+ * is supported, this will be the value queried by calling
+ * \c glGetIntegerv with \c GL_MAX_TEXTURE_UNITS.
+ *
+ * \todo
+ * Investigate if this should be the value of \c GL_MAX_TEXTURE_COORDS
+ * instead (if GL 2.0 / ARB_fragment_shader / ARB_fragment_program /
+ * NV_fragment_program are supported).
+ */
+ unsigned num_texture_units;
+
+ /**
+ * Number of generic vertex program attribs. If GL_ARB_vertex_program
+ * is not supported, this will be zero. Otherwise it will be the value
+ * queries by calling \c glGetProgramiv with \c GL_VERTEX_PROGRAM_ARB
+ * and \c GL_MAX_PROGRAM_ATTRIBS_ARB.
+ */
+ unsigned num_vertex_program_attribs;
+
+ /**
+ * \n Methods for implementing various GL functions.
+ *
+ * These method pointers are only valid \c array_info_cache_valid is set.
+ * When each function starts, it much check \c array_info_cache_valid.
+ * If it is not set, it must call \c fill_array_info_cache and call
+ * the new method.
+ *
+ * \sa fill_array_info_cache
+ *
+ * \todo
+ * Write code to plug these functions directly into the dispatch table.
+ */
+ /*@{*/
+ void (*DrawArrays)( GLenum, GLint, GLsizei );
+ void (*DrawElements)( GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices );
+ /*@}*/
+
+ struct array_stack_state * stack;
+ unsigned active_texture_unit_stack[ __GL_CLIENT_ATTRIB_STACK_DEPTH ];
+ unsigned stack_index;
+};
+
+#endif /* _INDIRECT_VA_PRIVATE_ */
diff --git a/nx-X11/extras/Mesa/src/glx/x11/indirect_vertex_array.c b/nx-X11/extras/Mesa/src/glx/x11/indirect_vertex_array.c
new file mode 100644
index 000000000..62a101e66
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/indirect_vertex_array.c
@@ -0,0 +1,1847 @@
+/*
+ * (C) Copyright IBM Corporation 2004, 2005
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <inttypes.h>
+#include <assert.h>
+#include <string.h>
+
+#include "glxclient.h"
+#include "indirect.h"
+#include <GL/glxproto.h>
+#include "glxextensions.h"
+#include "indirect_vertex_array.h"
+#include "indirect_va_private.h"
+
+#define __GLX_PAD(n) (((n)+3) & ~3)
+
+/**
+ * \file indirect_vertex_array.c
+ * Implement GLX protocol for vertex arrays and vertex buffer objects.
+ *
+ * The most important function in this fill is \c fill_array_info_cache.
+ * The \c array_state_vector contains a cache of the ARRAY_INFO data sent
+ * in the DrawArrays protocol. Certain operations, such as enabling or
+ * disabling an array, can invalidate this cache. \c fill_array_info_cache
+ * fills-in this data. Additionally, it examines the enabled state and
+ * other factors to determine what "version" of DrawArrays protocoal can be
+ * used.
+ *
+ * Current, only two versions of DrawArrays protocol are implemented. The
+ * first version is the "none" protocol. This is the fallback when the
+ * server does not support GL 1.1 / EXT_vertex_arrays. It is implemented
+ * by sending batches of immediate mode commands that are equivalent to the
+ * DrawArrays protocol.
+ *
+ * The other protocol that is currently implemented is the "old" protocol.
+ * This is the GL 1.1 DrawArrays protocol. The only difference between GL
+ * 1.1 and EXT_vertex_arrays is the opcode used for the DrawArrays command.
+ * This protocol is called "old" because the ARB is in the process of
+ * defining a new protocol, which will probably be called wither "new" or
+ * "vbo", to support multiple texture coordinate arrays, generic attributes,
+ * and vertex buffer objects.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+static void emit_DrawArrays_none( GLenum mode, GLint first, GLsizei count );
+static void emit_DrawArrays_old ( GLenum mode, GLint first, GLsizei count );
+
+static void emit_DrawElements_none( GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices );
+static void emit_DrawElements_old ( GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices );
+
+
+static GLubyte * emit_element_none( GLubyte * dst,
+ const struct array_state_vector * arrays, unsigned index );
+static GLubyte * emit_element_old( GLubyte * dst,
+ const struct array_state_vector * arrays, unsigned index );
+static struct array_state * get_array_entry(
+ const struct array_state_vector * arrays, GLenum key, unsigned index );
+static void fill_array_info_cache( struct array_state_vector * arrays );
+static GLboolean validate_mode(__GLXcontext *gc, GLenum mode);
+static GLboolean validate_count(__GLXcontext *gc, GLsizei count);
+static GLboolean validate_type(__GLXcontext *gc, GLenum type);
+
+
+/**
+ * Table of sizes, in bytes, of a GL types. All of the type enums are be in
+ * the range 0x1400 - 0x140F. That includes types added by extensions (i.e.,
+ * \c GL_HALF_FLOAT_NV). This elements of this table correspond to the
+ * type enums masked with 0x0f.
+ *
+ * \notes
+ * \c GL_HALF_FLOAT_NV is not included. Neither are \c GL_2_BYTES,
+ * \c GL_3_BYTES, or \c GL_4_BYTES.
+ */
+const GLuint __glXTypeSize_table[16] = {
+ 1, 1, 2, 2, 4, 4, 4, 0, 0, 0, 8, 0, 0, 0, 0, 0
+};
+
+
+
+/**
+ * Initialize vertex array state of a GLX context.
+ *
+ * \param gc GLX context whose vertex array state is to be initialized.
+ *
+ * \warning
+ * This function may only be called after __GLXcontext::gl_extension_bits,
+ * __GLXcontext::server_minor, and __GLXcontext::server_major have been
+ * initialized. These values are used to determine what vertex arrays are
+ * supported.
+ *
+ * \bug
+ * Return values from malloc are not properly tested.
+ */
+void
+__glXInitVertexArrayState( __GLXcontext * gc )
+{
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays;
+
+ unsigned array_count;
+ unsigned texture_units = 1;
+ unsigned i;
+ unsigned j;
+ unsigned vertex_program_attribs = 0;
+
+ GLboolean got_fog = GL_FALSE;
+ GLboolean got_secondary_color = GL_FALSE;
+
+
+ arrays = calloc( 1, sizeof( struct array_state_vector ) );
+ state->array_state = arrays;
+
+ arrays->old_DrawArrays_possible = !state->NoDrawArraysProtocol;
+ arrays->new_DrawArrays_possible = GL_FALSE;
+ arrays->DrawArrays = NULL;
+
+ arrays->active_texture_unit = 0;
+
+
+ /* Determine how many arrays are actually needed. Only arrays that
+ * are supported by the server are create. For example, if the server
+ * supports only 2 texture units, then only 2 texture coordinate arrays
+ * are created.
+ *
+ * At the very least, GL_VERTEX_ARRAY, GL_NORMAL_ARRAY,
+ * GL_COLOR_ARRAY, GL_INDEX_ARRAY, GL_TEXTURE_COORD_ARRAY, and
+ * GL_EDGE_FLAG_ARRAY are supported.
+ */
+
+ array_count = 5;
+
+ if ( __glExtensionBitIsEnabled( gc, GL_EXT_fog_coord_bit )
+ || (gc->server_major > 1) || (gc->server_minor >= 4) ) {
+ got_fog = GL_TRUE;
+ array_count++;
+ }
+
+ if ( __glExtensionBitIsEnabled( gc, GL_EXT_secondary_color_bit )
+ || (gc->server_major > 1) || (gc->server_minor >= 4) ) {
+ got_secondary_color = GL_TRUE;
+ array_count++;
+ }
+
+ if ( __glExtensionBitIsEnabled( gc, GL_ARB_multitexture_bit )
+ || (gc->server_major > 1) || (gc->server_minor >= 3) ) {
+ __indirect_glGetIntegerv( GL_MAX_TEXTURE_UNITS, & texture_units );
+ }
+
+ if ( __glExtensionBitIsEnabled( gc, GL_ARB_vertex_program_bit ) ) {
+ __indirect_glGetProgramivARB( GL_VERTEX_PROGRAM_ARB,
+ GL_MAX_PROGRAM_ATTRIBS_ARB,
+ & vertex_program_attribs );
+ }
+
+ arrays->num_texture_units = texture_units;
+ arrays->num_vertex_program_attribs = vertex_program_attribs;
+ array_count += texture_units + vertex_program_attribs;
+ arrays->num_arrays = array_count;
+ arrays->arrays = calloc( array_count, sizeof( struct array_state ) );
+
+ arrays->arrays[0].data_type = GL_FLOAT;
+ arrays->arrays[0].count = 3;
+ arrays->arrays[0].key = GL_NORMAL_ARRAY;
+ arrays->arrays[0].normalized = GL_TRUE;
+ arrays->arrays[0].old_DrawArrays_possible = GL_TRUE;
+
+ arrays->arrays[1].data_type = GL_FLOAT;
+ arrays->arrays[1].count = 4;
+ arrays->arrays[1].key = GL_COLOR_ARRAY;
+ arrays->arrays[1].normalized = GL_TRUE;
+ arrays->arrays[1].old_DrawArrays_possible = GL_TRUE;
+
+ arrays->arrays[2].data_type = GL_FLOAT;
+ arrays->arrays[2].count = 1;
+ arrays->arrays[2].key = GL_INDEX_ARRAY;
+ arrays->arrays[2].old_DrawArrays_possible = GL_TRUE;
+
+ arrays->arrays[3].data_type = GL_UNSIGNED_BYTE;
+ arrays->arrays[3].count = 1;
+ arrays->arrays[3].key = GL_EDGE_FLAG_ARRAY;
+ arrays->arrays[3].old_DrawArrays_possible = GL_TRUE;
+
+ for ( i = 0 ; i < texture_units ; i++ ) {
+ arrays->arrays[4 + i].data_type = GL_FLOAT;
+ arrays->arrays[4 + i].count = 4;
+ arrays->arrays[4 + i].key = GL_TEXTURE_COORD_ARRAY;
+
+ arrays->arrays[4 + i].old_DrawArrays_possible = (i == 0);
+ arrays->arrays[4 + i].index = i;
+
+ arrays->arrays[4 + i].header[1] = i + GL_TEXTURE0;
+ }
+
+ i = 4 + texture_units;
+
+ if ( got_fog ) {
+ arrays->arrays[i].data_type = GL_FLOAT;
+ arrays->arrays[i].count = 1;
+ arrays->arrays[i].key = GL_FOG_COORDINATE_ARRAY;
+ arrays->arrays[i].old_DrawArrays_possible = GL_TRUE;
+ i++;
+ }
+
+ if ( got_secondary_color ) {
+ arrays->arrays[i].data_type = GL_FLOAT;
+ arrays->arrays[i].count = 3;
+ arrays->arrays[i].key = GL_SECONDARY_COLOR_ARRAY;
+ arrays->arrays[i].old_DrawArrays_possible = GL_TRUE;
+ arrays->arrays[i].normalized = GL_TRUE;
+ i++;
+ }
+
+
+ for ( j = 0 ; j < vertex_program_attribs ; j++ ) {
+ const unsigned idx = (vertex_program_attribs - (j + 1));
+
+
+ arrays->arrays[idx + i].data_type = GL_FLOAT;
+ arrays->arrays[idx + i].count = 4;
+ arrays->arrays[idx + i].key = GL_VERTEX_ATTRIB_ARRAY_POINTER;
+
+ arrays->arrays[idx + i].old_DrawArrays_possible = 0;
+ arrays->arrays[idx + i].index = idx;
+
+ arrays->arrays[idx + i].header[1] = idx;
+ }
+
+ i += vertex_program_attribs;
+
+
+ /* Vertex array *must* be last becuase of the way that
+ * emit_DrawArrays_none works.
+ */
+
+ arrays->arrays[i].data_type = GL_FLOAT;
+ arrays->arrays[i].count = 4;
+ arrays->arrays[i].key = GL_VERTEX_ARRAY;
+ arrays->arrays[i].old_DrawArrays_possible = GL_TRUE;
+
+ assert( (i + 1) == arrays->num_arrays );
+
+ arrays->stack_index = 0;
+ arrays->stack = malloc( sizeof( struct array_stack_state )
+ * arrays->num_arrays );
+}
+
+
+/**
+ * Calculate the size of a single vertex for the "none" protocol. This is
+ * essentially the size of all the immediate-mode commands required to
+ * implement the enabled vertex arrays.
+ */
+static size_t
+calculate_single_vertex_size_none( const struct array_state_vector * arrays )
+{
+ size_t single_vertex_size = 0;
+ unsigned i;
+
+
+ for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
+ if ( arrays->arrays[i].enabled ) {
+ single_vertex_size += ((uint16_t *)arrays->arrays[i].header)[0];
+ }
+ }
+
+ return single_vertex_size;
+}
+
+
+/**
+ * Emit a single element using non-DrawArrays protocol.
+ */
+GLubyte *
+emit_element_none( GLubyte * dst,
+ const struct array_state_vector * arrays,
+ unsigned index )
+{
+ unsigned i;
+
+
+ for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
+ if ( arrays->arrays[i].enabled ) {
+ const size_t offset = index * arrays->arrays[i].true_stride;
+
+ /* The generic attributes can have more data than is in the
+ * elements. This is because a vertex array can be a 2 element,
+ * normalized, unsigned short, but the "closest" immediate mode
+ * protocol is for a 4Nus. Since the sizes are small, the
+ * performance impact on modern processors should be negligible.
+ */
+ (void) memset( dst, 0,
+ ((uint16_t *)arrays->arrays[i].header)[0] );
+
+ (void) memcpy( dst, arrays->arrays[i].header,
+ arrays->arrays[i].header_size );
+
+ dst += arrays->arrays[i].header_size;
+
+ (void) memcpy( dst, ((GLubyte *) arrays->arrays[i].data) + offset,
+ arrays->arrays[i].element_size );
+
+ dst += __GLX_PAD( arrays->arrays[i].element_size );
+ }
+ }
+
+ return dst;
+}
+
+
+/**
+ * Emit a single element using "old" DrawArrays protocol from
+ * EXT_vertex_arrays / OpenGL 1.1.
+ */
+GLubyte *
+emit_element_old( GLubyte * dst,
+ const struct array_state_vector * arrays,
+ unsigned index )
+{
+ unsigned i;
+
+
+ for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
+ if ( arrays->arrays[i].enabled ) {
+ const size_t offset = index * arrays->arrays[i].true_stride;
+
+ (void) memcpy( dst, ((GLubyte *) arrays->arrays[i].data) + offset,
+ arrays->arrays[i].element_size );
+
+ dst += __GLX_PAD( arrays->arrays[i].element_size );
+ }
+ }
+
+ return dst;
+}
+
+
+struct array_state *
+get_array_entry( const struct array_state_vector * arrays,
+ GLenum key, unsigned index )
+{
+ unsigned i;
+
+ for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
+ if ( (arrays->arrays[i].key == key)
+ && (arrays->arrays[i].index == index) ) {
+ return & arrays->arrays[i];
+ }
+ }
+
+ return NULL;
+}
+
+
+static GLboolean
+allocate_array_info_cache( struct array_state_vector * arrays,
+ size_t required_size )
+{
+#define MAX_HEADER_SIZE 20
+ if ( arrays->array_info_cache_buffer_size < required_size ) {
+ GLubyte * temp = realloc( arrays->array_info_cache_base,
+ required_size + MAX_HEADER_SIZE );
+
+ if ( temp == NULL ) {
+ return GL_FALSE;
+ }
+
+ arrays->array_info_cache_base = temp;
+ arrays->array_info_cache = temp + MAX_HEADER_SIZE;
+ arrays->array_info_cache_buffer_size = required_size;
+ }
+
+ arrays->array_info_cache_size = required_size;
+ return GL_TRUE;
+}
+
+
+/**
+ */
+void
+fill_array_info_cache( struct array_state_vector * arrays )
+{
+ GLboolean old_DrawArrays_possible;
+ unsigned i;
+
+
+ /* Determine how many arrays are enabled.
+ */
+
+ arrays->enabled_client_array_count = 0;
+ old_DrawArrays_possible = arrays->old_DrawArrays_possible;
+ for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
+ if ( arrays->arrays[i].enabled ) {
+ arrays->enabled_client_array_count++;
+ old_DrawArrays_possible &= arrays->arrays[i].old_DrawArrays_possible;
+ }
+ }
+
+
+ if ( arrays->new_DrawArrays_possible ) {
+ assert( ! arrays->new_DrawArrays_possible );
+ }
+ else if ( old_DrawArrays_possible ) {
+ const size_t required_size = arrays->enabled_client_array_count * 12;
+ uint32_t * info;
+
+
+ if ( ! allocate_array_info_cache( arrays, required_size ) ) {
+ return;
+ }
+
+
+ info = (uint32_t *) arrays->array_info_cache;
+ for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
+ if ( arrays->arrays[i].enabled ) {
+ *(info++) = arrays->arrays[i].data_type;
+ *(info++) = arrays->arrays[i].count;
+ *(info++) = arrays->arrays[i].key;
+ }
+ }
+
+ arrays->DrawArrays = emit_DrawArrays_old;
+ arrays->DrawElements = emit_DrawElements_old;
+ }
+ else {
+ arrays->DrawArrays = emit_DrawArrays_none;
+ arrays->DrawElements = emit_DrawElements_none;
+ }
+
+ arrays->array_info_cache_valid = GL_TRUE;
+}
+
+
+/**
+ * Emit a \c glDrawArrays command using the "none" protocol. That is,
+ * emit immediate-mode commands that are equivalent to the requiested
+ * \c glDrawArrays command. This is used with servers that don't support
+ * the OpenGL 1.1 / EXT_vertex_arrays DrawArrays protocol or in cases where
+ * vertex state is enabled that is not compatible with that protocol.
+ */
+void
+emit_DrawArrays_none( GLenum mode, GLint first, GLsizei count )
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute * state =
+ (const __GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+
+ size_t single_vertex_size;
+ GLubyte * pc;
+ unsigned i;
+ static const uint16_t begin_cmd[2] = { 8, X_GLrop_Begin };
+ static const uint16_t end_cmd[2] = { 4, X_GLrop_End };
+
+
+ single_vertex_size = calculate_single_vertex_size_none( arrays );
+
+ pc = gc->pc;
+
+ (void) memcpy( pc, begin_cmd, 4 );
+ *(int *)(pc + 4) = mode;
+
+ pc += 8;
+
+ for ( i = 0 ; i < count ; i++ ) {
+ if ( (pc + single_vertex_size) >= gc->bufEnd ) {
+ pc = __glXFlushRenderBuffer(gc, gc->pc);
+ }
+
+ pc = emit_element_none( pc, arrays, first + i );
+ }
+
+ if ( (pc + 4) >= gc->bufEnd ) {
+ pc = __glXFlushRenderBuffer(gc, gc->pc);
+ }
+
+ (void) memcpy( pc, end_cmd, 4 );
+ pc += 4;
+
+ gc->pc = pc;
+ if ( gc->pc > gc->limit ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+}
+
+
+/**
+ * Emit the header data for the GL 1.1 / EXT_vertex_arrays DrawArrays
+ * protocol.
+ *
+ * \param gc GLX context.
+ * \param arrays Array state.
+ * \param elements_per_request Location to store the number of elements that
+ * can fit in a single Render / RenderLarge
+ * command.
+ * \param total_request Total number of requests for a RenderLarge
+ * command. If a Render command is used, this
+ * will be zero.
+ * \param mode Drawing mode.
+ * \param count Number of vertices.
+ *
+ * \returns
+ * A pointer to the buffer for array data.
+ */
+static GLubyte *
+emit_DrawArrays_header_old( __GLXcontext * gc,
+ struct array_state_vector * arrays,
+ size_t * elements_per_request,
+ size_t * total_requests,
+ GLenum mode, GLsizei count )
+{
+ size_t command_size;
+ size_t single_vertex_size;
+ const unsigned header_size = 16;
+ unsigned i;
+ GLubyte * pc;
+
+
+ /* Determine the size of the whole command. This includes the header,
+ * the ARRAY_INFO data and the array data. Once this size is calculated,
+ * it will be known whether a Render or RenderLarge command is needed.
+ */
+
+ single_vertex_size = 0;
+ for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
+ if ( arrays->arrays[i].enabled ) {
+ single_vertex_size += __GLX_PAD( arrays->arrays[i].element_size );
+ }
+ }
+
+ command_size = arrays->array_info_cache_size + header_size
+ + (single_vertex_size * count);
+
+
+ /* Write the header for either a Render command or a RenderLarge
+ * command. After the header is written, write the ARRAY_INFO data.
+ */
+
+ if ( command_size > gc->maxSmallRenderCommandSize ) {
+ /* maxSize is the maximum amount of data can be stuffed into a single
+ * packet. sz_xGLXRenderReq is added because bufSize is the maximum
+ * packet size minus sz_xGLXRenderReq.
+ */
+ const size_t maxSize = (gc->bufSize + sz_xGLXRenderReq)
+ - sz_xGLXRenderLargeReq;
+ unsigned vertex_requests;
+
+
+ /* Calculate the number of data packets that will be required to send
+ * the whole command. To do this, the number of verticies that
+ * will fit in a single buffer must be calculated.
+ *
+ * The important value here is elements_per_request. This is the
+ * number of complete array elements that will fit in a single
+ * buffer. There may be some wasted space at the end of the buffer,
+ * but splitting elements across buffer boundries would be painful.
+ */
+
+ elements_per_request[0] = maxSize / single_vertex_size;
+
+ vertex_requests = (count + elements_per_request[0] - 1)
+ / elements_per_request[0];
+
+ *total_requests = vertex_requests + 1;
+
+
+ __glXFlushRenderBuffer(gc, gc->pc);
+
+ command_size += 4;
+
+ pc = ((GLubyte *) arrays->array_info_cache) - (header_size + 4);
+ *(uint32_t *)(pc + 0) = command_size;
+ *(uint32_t *)(pc + 4) = X_GLrop_DrawArrays;
+ *(uint32_t *)(pc + 8) = count;
+ *(uint32_t *)(pc + 12) = arrays->enabled_client_array_count;
+ *(uint32_t *)(pc + 16) = mode;
+
+ __glXSendLargeChunk( gc, 1, *total_requests, pc,
+ header_size + 4 + arrays->array_info_cache_size );
+
+ pc = gc->pc;
+ }
+ else {
+ if ( (gc->pc + command_size) >= gc->bufEnd ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+
+ pc = gc->pc;
+ *(uint16_t *)(pc + 0) = command_size;
+ *(uint16_t *)(pc + 2) = X_GLrop_DrawArrays;
+ *(uint32_t *)(pc + 4) = count;
+ *(uint32_t *)(pc + 8) = arrays->enabled_client_array_count;
+ *(uint32_t *)(pc + 12) = mode;
+
+ pc += header_size;
+
+ (void) memcpy( pc, arrays->array_info_cache,
+ arrays->array_info_cache_size );
+ pc += arrays->array_info_cache_size;
+
+ *elements_per_request = count;
+ *total_requests = 0;
+ }
+
+
+ return pc;
+}
+
+
+/**
+ */
+void
+emit_DrawArrays_old( GLenum mode, GLint first, GLsizei count )
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute * state =
+ (const __GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+
+ GLubyte * pc;
+ size_t elements_per_request;
+ unsigned total_requests = 0;
+ unsigned i;
+ size_t total_sent = 0;
+
+
+ pc = emit_DrawArrays_header_old( gc, arrays, & elements_per_request,
+ & total_requests, mode, count);
+
+
+ /* Write the arrays.
+ */
+
+ if ( total_requests == 0 ) {
+ assert( elements_per_request >= count );
+
+ for ( i = 0 ; i < count ; i++ ) {
+ pc = emit_element_old( pc, arrays, i + first );
+ }
+
+ assert( pc <= gc->bufEnd );
+
+ gc->pc = pc;
+ if ( gc->pc > gc->limit ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ }
+ else {
+ unsigned req;
+
+
+ for ( req = 2 ; req <= total_requests ; req++ ) {
+ if ( count < elements_per_request ) {
+ elements_per_request = count;
+ }
+
+ pc = gc->pc;
+ for ( i = 0 ; i < elements_per_request ; i++ ) {
+ pc = emit_element_old( pc, arrays, i + first );
+ }
+
+ first += elements_per_request;
+
+ total_sent += (size_t) (pc - gc->pc);
+ __glXSendLargeChunk( gc, req, total_requests, gc->pc,
+ pc - gc->pc );
+
+ count -= elements_per_request;
+ }
+ }
+}
+
+
+void
+emit_DrawElements_none( GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices )
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute * state =
+ (const __GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+ static const uint16_t begin_cmd[2] = { 8, X_GLrop_Begin };
+ static const uint16_t end_cmd[2] = { 4, X_GLrop_End };
+
+ GLubyte * pc;
+ size_t single_vertex_size;
+ unsigned i;
+
+
+ single_vertex_size = calculate_single_vertex_size_none( arrays );
+
+
+ if ( (gc->pc + single_vertex_size) >= gc->bufEnd ) {
+ gc->pc = __glXFlushRenderBuffer(gc, gc->pc);
+ }
+
+ pc = gc->pc;
+
+ (void) memcpy( pc, begin_cmd, 4 );
+ *(int *)(pc + 4) = mode;
+
+ pc += 8;
+
+ for ( i = 0 ; i < count ; i++ ) {
+ unsigned index = 0;
+
+ if ( (pc + single_vertex_size) >= gc->bufEnd ) {
+ pc = __glXFlushRenderBuffer(gc, gc->pc);
+ }
+
+ switch( type ) {
+ case GL_UNSIGNED_INT:
+ index = (unsigned) (((GLuint *) indices)[i]);
+ break;
+ case GL_UNSIGNED_SHORT:
+ index = (unsigned) (((GLushort *) indices)[i]);
+ break;
+ case GL_UNSIGNED_BYTE:
+ index = (unsigned) (((GLubyte *) indices)[i]);
+ break;
+ }
+ pc = emit_element_none( pc, arrays, index );
+ }
+
+ if ( (pc + 4) >= gc->bufEnd ) {
+ pc = __glXFlushRenderBuffer(gc, gc->pc);
+ }
+
+ (void) memcpy( pc, end_cmd, 4 );
+ pc += 4;
+
+ gc->pc = pc;
+ if ( gc->pc > gc->limit ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+}
+
+
+/**
+ */
+void
+emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices )
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute * state =
+ (const __GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+
+ GLubyte * pc;
+ size_t elements_per_request;
+ unsigned total_requests = 0;
+ unsigned i;
+ unsigned req;
+
+
+ pc = emit_DrawArrays_header_old( gc, arrays, & elements_per_request,
+ & total_requests, mode, count);
+
+
+ /* Write the arrays.
+ */
+
+ req = 2;
+ while ( count > 0 ) {
+ if ( count < elements_per_request ) {
+ elements_per_request = count;
+ }
+
+ switch( type ) {
+ case GL_UNSIGNED_INT: {
+ const GLuint * ui_ptr = (const GLuint *) indices;
+
+ for ( i = 0 ; i < elements_per_request ; i++ ) {
+ const GLint index = (GLint) *(ui_ptr++);
+ pc = emit_element_old( pc, arrays, index );
+ }
+ break;
+ }
+ case GL_UNSIGNED_SHORT: {
+ const GLushort * us_ptr = (const GLushort *) indices;
+
+ for ( i = 0 ; i < elements_per_request ; i++ ) {
+ const GLint index = (GLint) *(us_ptr++);
+ pc = emit_element_old( pc, arrays, index );
+ }
+ break;
+ }
+ case GL_UNSIGNED_BYTE: {
+ const GLubyte * ub_ptr = (const GLubyte *) indices;
+
+ for ( i = 0 ; i < elements_per_request ; i++ ) {
+ const GLint index = (GLint) *(ub_ptr++);
+ pc = emit_element_old( pc, arrays, index );
+ }
+ break;
+ }
+ }
+
+ if ( total_requests != 0 ) {
+ __glXSendLargeChunk( gc, req, total_requests, gc->pc,
+ pc - gc->pc );
+ pc = gc->pc;
+ req++;
+ }
+
+ count -= elements_per_request;
+ }
+
+
+ assert( (total_requests == 0) || ((req - 1) == total_requests) );
+
+ if ( total_requests == 0 ) {
+ assert( pc <= gc->bufEnd );
+
+ gc->pc = pc;
+ if ( gc->pc > gc->limit ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ }
+}
+
+
+/**
+ * Validate that the \c mode parameter to \c glDrawArrays, et. al. is valid.
+ * If it is not valid, then an error code is set in the GLX context.
+ *
+ * \returns
+ * \c GL_TRUE if the argument is valid, \c GL_FALSE if is not.
+ */
+static GLboolean
+validate_mode(__GLXcontext *gc, GLenum mode)
+{
+ switch(mode) {
+ case GL_POINTS:
+ case GL_LINE_STRIP:
+ case GL_LINE_LOOP:
+ case GL_LINES:
+ case GL_TRIANGLE_STRIP:
+ case GL_TRIANGLE_FAN:
+ case GL_TRIANGLES:
+ case GL_QUAD_STRIP:
+ case GL_QUADS:
+ case GL_POLYGON:
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Validate that the \c count parameter to \c glDrawArrays, et. al. is valid.
+ * A value less than zero is invalid and will result in \c GL_INVALID_VALUE
+ * being set. A value of zero will not result in an error being set, but
+ * will result in \c GL_FALSE being returned.
+ *
+ * \returns
+ * \c GL_TRUE if the argument is valid, \c GL_FALSE if it is not.
+ */
+static GLboolean
+validate_count(__GLXcontext *gc, GLsizei count)
+{
+ if (count < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ }
+
+ return (count > 0);
+}
+
+
+/**
+ * Validate that the \c type parameter to \c glDrawElements, et. al. is
+ * valid. Only \c GL_UNSIGNED_BYTE, \c GL_UNSIGNED_SHORT, and
+ * \c GL_UNSIGNED_INT are valid.
+ *
+ * \returns
+ * \c GL_TRUE if the argument is valid, \c GL_FALSE if it is not.
+ */
+static GLboolean validate_type(__GLXcontext *gc, GLenum type)
+{
+ switch( type ) {
+ case GL_UNSIGNED_INT:
+ case GL_UNSIGNED_SHORT:
+ case GL_UNSIGNED_BYTE:
+ return GL_TRUE;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return GL_FALSE;
+ }
+}
+
+
+void __indirect_glDrawArrays(GLenum mode, GLint first, GLsizei count)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute * state =
+ (const __GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+
+
+ if ( validate_mode(gc, mode) && validate_count(gc, count) ) {
+ if ( ! arrays->array_info_cache_valid ) {
+ fill_array_info_cache( arrays );
+ }
+
+ arrays->DrawArrays(mode, first, count);
+ }
+}
+
+
+void __indirect_glArrayElement(GLint index)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute * state =
+ (const __GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+
+ size_t single_vertex_size;
+
+
+ single_vertex_size = calculate_single_vertex_size_none( arrays );
+
+ if ( (gc->pc + single_vertex_size) >= gc->bufEnd ) {
+ gc->pc = __glXFlushRenderBuffer(gc, gc->pc);
+ }
+
+ gc->pc = emit_element_none( gc->pc, arrays, index );
+
+ if ( gc->pc > gc->limit ) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+}
+
+
+void __indirect_glDrawElements(GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute * state =
+ (const __GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+
+
+ if ( validate_mode(gc, mode) && validate_count(gc, count)
+ && validate_type(gc, type) ) {
+ if ( ! arrays->array_info_cache_valid ) {
+ fill_array_info_cache( arrays );
+ }
+
+ arrays->DrawElements(mode, count, type, indices);
+ }
+}
+
+
+void __indirect_glDrawRangeElements(GLenum mode, GLuint start, GLuint end,
+ GLsizei count, GLenum type,
+ const GLvoid *indices)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute * state =
+ (const __GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+
+
+ if ( validate_mode(gc, mode) && validate_count(gc, count)
+ && validate_type(gc, type) ) {
+ if (end < start) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ if ( ! arrays->array_info_cache_valid ) {
+ fill_array_info_cache( arrays );
+ }
+
+ arrays->DrawElements(mode, count, type, indices);
+ }
+}
+
+
+void __indirect_glMultiDrawArraysEXT(GLenum mode, GLint *first, GLsizei *count,
+ GLsizei primcount)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute * state =
+ (const __GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+ GLsizei i;
+
+
+ if ( validate_mode(gc, mode) ) {
+ if ( ! arrays->array_info_cache_valid ) {
+ fill_array_info_cache( arrays );
+ }
+
+ for ( i = 0 ; i < primcount ; i++ ) {
+ if ( validate_count( gc, count[i] ) ) {
+ arrays->DrawArrays(mode, first[i], count[i]);
+ }
+ }
+ }
+}
+
+
+void __indirect_glMultiDrawElementsEXT(GLenum mode, const GLsizei *count,
+ GLenum type, const GLvoid ** indices,
+ GLsizei primcount)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute * state =
+ (const __GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+ GLsizei i;
+
+
+ if ( validate_mode(gc, mode) && validate_type(gc, type) ) {
+ if ( ! arrays->array_info_cache_valid ) {
+ fill_array_info_cache( arrays );
+ }
+
+ for ( i = 0 ; i < primcount ; i++ ) {
+ if ( validate_count( gc, count[i] ) ) {
+ arrays->DrawElements(mode, count[i], type, indices[i]);
+ }
+ }
+ }
+}
+
+
+#define COMMON_ARRAY_DATA_INIT(a, PTR, TYPE, STRIDE, COUNT, NORMALIZED, HDR_SIZE, OPCODE) \
+ do { \
+ (a)->data = PTR; \
+ (a)->data_type = TYPE; \
+ (a)->user_stride = STRIDE; \
+ (a)->count = COUNT; \
+ (a)->normalized = NORMALIZED; \
+ \
+ (a)->element_size = __glXTypeSize( TYPE ) * COUNT; \
+ (a)->true_stride = (STRIDE == 0) \
+ ? (a)->element_size : STRIDE; \
+ \
+ (a)->header_size = HDR_SIZE; \
+ ((uint16_t *) (a)->header)[0] = __GLX_PAD((a)->header_size + (a)->element_size); \
+ ((uint16_t *) (a)->header)[1] = OPCODE; \
+ } while(0)
+
+
+void __indirect_glVertexPointer( GLint size, GLenum type, GLsizei stride,
+ const GLvoid * pointer )
+{
+ static const uint16_t short_ops[5] = {
+ 0, 0, X_GLrop_Vertex2sv, X_GLrop_Vertex3sv, X_GLrop_Vertex4sv
+ };
+ static const uint16_t int_ops[5] = {
+ 0, 0, X_GLrop_Vertex2iv, X_GLrop_Vertex3iv, X_GLrop_Vertex4iv
+ };
+ static const uint16_t float_ops[5] = {
+ 0, 0, X_GLrop_Vertex2fv, X_GLrop_Vertex3fv, X_GLrop_Vertex4fv
+ };
+ static const uint16_t double_ops[5] = {
+ 0, 0, X_GLrop_Vertex2dv, X_GLrop_Vertex3dv, X_GLrop_Vertex4dv
+ };
+ uint16_t opcode;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+ struct array_state * a;
+
+
+ if (size < 2 || size > 4 || stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ switch ( type ) {
+ case GL_SHORT: opcode = short_ops[size]; break;
+ case GL_INT: opcode = int_ops[size]; break;
+ case GL_FLOAT: opcode = float_ops[size]; break;
+ case GL_DOUBLE: opcode = double_ops[size]; break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ a = get_array_entry( arrays, GL_VERTEX_ARRAY, 0 );
+ assert( a != NULL );
+ COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, GL_FALSE, 4,
+ opcode );
+
+ if ( a->enabled ) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
+}
+
+
+void __indirect_glNormalPointer( GLenum type, GLsizei stride,
+ const GLvoid * pointer )
+{
+ uint16_t opcode;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+ struct array_state * a;
+
+
+ if (stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ switch ( type ) {
+ case GL_BYTE: opcode = X_GLrop_Normal3bv; break;
+ case GL_SHORT: opcode = X_GLrop_Normal3sv; break;
+ case GL_INT: opcode = X_GLrop_Normal3iv; break;
+ case GL_FLOAT: opcode = X_GLrop_Normal3fv; break;
+ case GL_DOUBLE: opcode = X_GLrop_Normal3dv; break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ a = get_array_entry( arrays, GL_NORMAL_ARRAY, 0 );
+ assert( a != NULL );
+ COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, 3, GL_TRUE, 4,
+ opcode );
+
+ if ( a->enabled ) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
+}
+
+
+void __indirect_glColorPointer( GLint size, GLenum type, GLsizei stride,
+ const GLvoid * pointer )
+{
+ static const uint16_t byte_ops[5] = {
+ 0, 0, 0, X_GLrop_Color3bv, X_GLrop_Color4bv
+ };
+ static const uint16_t ubyte_ops[5] = {
+ 0, 0, 0, X_GLrop_Color3ubv, X_GLrop_Color4ubv
+ };
+ static const uint16_t short_ops[5] = {
+ 0, 0, 0, X_GLrop_Color3sv, X_GLrop_Color4sv
+ };
+ static const uint16_t ushort_ops[5] = {
+ 0, 0, 0, X_GLrop_Color3usv, X_GLrop_Color4usv
+ };
+ static const uint16_t int_ops[5] = {
+ 0, 0, 0, X_GLrop_Color3iv, X_GLrop_Color4iv
+ };
+ static const uint16_t uint_ops[5] = {
+ 0, 0, 0, X_GLrop_Color3uiv, X_GLrop_Color4uiv
+ };
+ static const uint16_t float_ops[5] = {
+ 0, 0, 0, X_GLrop_Color3fv, X_GLrop_Color4fv
+ };
+ static const uint16_t double_ops[5] = {
+ 0, 0, 0, X_GLrop_Color3dv, X_GLrop_Color4dv
+ };
+ uint16_t opcode;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+ struct array_state * a;
+
+
+ if (size < 3 || size > 4 || stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ switch ( type ) {
+ case GL_BYTE: opcode = byte_ops[size]; break;
+ case GL_UNSIGNED_BYTE: opcode = ubyte_ops[size]; break;
+ case GL_SHORT: opcode = short_ops[size]; break;
+ case GL_UNSIGNED_SHORT: opcode = ushort_ops[size]; break;
+ case GL_INT: opcode = int_ops[size]; break;
+ case GL_UNSIGNED_INT: opcode = uint_ops[size]; break;
+ case GL_FLOAT: opcode = float_ops[size]; break;
+ case GL_DOUBLE: opcode = double_ops[size]; break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ a = get_array_entry( arrays, GL_COLOR_ARRAY, 0 );
+ assert( a != NULL );
+ COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, GL_TRUE, 4,
+ opcode );
+
+ if ( a->enabled ) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
+}
+
+
+void __indirect_glIndexPointer( GLenum type, GLsizei stride,
+ const GLvoid * pointer )
+{
+ uint16_t opcode;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+ struct array_state * a;
+
+
+ if (stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ switch ( type ) {
+ case GL_UNSIGNED_BYTE: opcode = X_GLrop_Indexubv; break;
+ case GL_SHORT: opcode = X_GLrop_Indexsv; break;
+ case GL_INT: opcode = X_GLrop_Indexiv; break;
+ case GL_FLOAT: opcode = X_GLrop_Indexfv; break;
+ case GL_DOUBLE: opcode = X_GLrop_Indexdv; break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ a = get_array_entry( arrays, GL_INDEX_ARRAY, 0 );
+ assert( a != NULL );
+ COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, 1, GL_FALSE, 4,
+ opcode );
+
+ if ( a->enabled ) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
+}
+
+
+void __indirect_glEdgeFlagPointer( GLsizei stride, const GLvoid * pointer )
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+ struct array_state * a;
+
+
+ if (stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+
+ a = get_array_entry( arrays, GL_EDGE_FLAG_ARRAY, 0 );
+ assert( a != NULL );
+ COMMON_ARRAY_DATA_INIT( a, pointer, GL_UNSIGNED_BYTE, stride, 1, GL_FALSE,
+ 4, X_GLrop_EdgeFlagv );
+
+ if ( a->enabled ) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
+}
+
+
+void __indirect_glTexCoordPointer( GLint size, GLenum type, GLsizei stride,
+ const GLvoid * pointer )
+{
+ static const uint16_t short_ops[5] = {
+ 0, X_GLrop_TexCoord1sv, X_GLrop_TexCoord2sv, X_GLrop_TexCoord3sv, X_GLrop_TexCoord4sv
+ };
+ static const uint16_t int_ops[5] = {
+ 0, X_GLrop_TexCoord1iv, X_GLrop_TexCoord2iv, X_GLrop_TexCoord3iv, X_GLrop_TexCoord4iv
+ };
+ static const uint16_t float_ops[5] = {
+ 0, X_GLrop_TexCoord1dv, X_GLrop_TexCoord2fv, X_GLrop_TexCoord3fv, X_GLrop_TexCoord4fv
+ };
+ static const uint16_t double_ops[5] = {
+ 0, X_GLrop_TexCoord1dv, X_GLrop_TexCoord2dv, X_GLrop_TexCoord3dv, X_GLrop_TexCoord4dv
+ };
+
+ static const uint16_t mshort_ops[5] = {
+ 0, X_GLrop_MultiTexCoord1svARB, X_GLrop_MultiTexCoord2svARB, X_GLrop_MultiTexCoord3svARB, X_GLrop_MultiTexCoord4svARB
+ };
+ static const uint16_t mint_ops[5] = {
+ 0, X_GLrop_MultiTexCoord1ivARB, X_GLrop_MultiTexCoord2ivARB, X_GLrop_MultiTexCoord3ivARB, X_GLrop_MultiTexCoord4ivARB
+ };
+ static const uint16_t mfloat_ops[5] = {
+ 0, X_GLrop_MultiTexCoord1dvARB, X_GLrop_MultiTexCoord2fvARB, X_GLrop_MultiTexCoord3fvARB, X_GLrop_MultiTexCoord4fvARB
+ };
+ static const uint16_t mdouble_ops[5] = {
+ 0, X_GLrop_MultiTexCoord1dvARB, X_GLrop_MultiTexCoord2dvARB, X_GLrop_MultiTexCoord3dvARB, X_GLrop_MultiTexCoord4dvARB
+ };
+
+ uint16_t opcode;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+ struct array_state * a;
+ unsigned header_size;
+ unsigned index;
+
+
+ if (size < 1 || size > 4 || stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ index = arrays->active_texture_unit;
+ if ( index == 0 ) {
+ switch ( type ) {
+ case GL_SHORT: opcode = short_ops[size]; break;
+ case GL_INT: opcode = int_ops[size]; break;
+ case GL_FLOAT: opcode = float_ops[size]; break;
+ case GL_DOUBLE: opcode = double_ops[size]; break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ header_size = 4;
+ }
+ else {
+ switch ( type ) {
+ case GL_SHORT: opcode = mshort_ops[size]; break;
+ case GL_INT: opcode = mint_ops[size]; break;
+ case GL_FLOAT: opcode = mfloat_ops[size]; break;
+ case GL_DOUBLE: opcode = mdouble_ops[size]; break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ header_size = 8;
+ }
+
+ a = get_array_entry( arrays, GL_TEXTURE_COORD_ARRAY, index );
+ assert( a != NULL );
+ COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, GL_FALSE,
+ header_size, opcode );
+
+ if ( a->enabled ) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
+}
+
+
+void __indirect_glSecondaryColorPointerEXT( GLint size, GLenum type, GLsizei stride,
+ const GLvoid * pointer )
+{
+ uint16_t opcode;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+ struct array_state * a;
+
+
+ if (size != 3 || stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ switch ( type ) {
+ case GL_BYTE: opcode = 4126; break;
+ case GL_UNSIGNED_BYTE: opcode = 4131; break;
+ case GL_SHORT: opcode = 4127; break;
+ case GL_UNSIGNED_SHORT: opcode = 4132; break;
+ case GL_INT: opcode = 4128; break;
+ case GL_UNSIGNED_INT: opcode = 4133; break;
+ case GL_FLOAT: opcode = 4129; break;
+ case GL_DOUBLE: opcode = 4130; break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ a = get_array_entry( arrays, GL_SECONDARY_COLOR_ARRAY, 0 );
+ if ( a == NULL ) {
+ __glXSetError(gc, GL_INVALID_OPERATION);
+ return;
+ }
+
+ COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, GL_TRUE, 4,
+ opcode );
+
+ if ( a->enabled ) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
+}
+
+
+void __indirect_glFogCoordPointerEXT( GLenum type, GLsizei stride,
+ const GLvoid * pointer )
+{
+ uint16_t opcode;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+ struct array_state * a;
+
+
+ if (stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ switch ( type ) {
+ case GL_FLOAT: opcode = 4124; break;
+ case GL_DOUBLE: opcode = 4125; break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ a = get_array_entry( arrays, GL_FOG_COORD_ARRAY, 0 );
+ if ( a == NULL ) {
+ __glXSetError(gc, GL_INVALID_OPERATION);
+ return;
+ }
+
+ COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, 1, GL_FALSE, 4,
+ opcode );
+
+ if ( a->enabled ) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
+}
+
+
+void __indirect_glVertexAttribPointerARB(GLuint index, GLint size,
+ GLenum type, GLboolean normalized,
+ GLsizei stride,
+ const GLvoid * pointer)
+{
+ static const uint16_t short_ops[5] = { 0, 4189, 4190, 4191, 4192 };
+ static const uint16_t float_ops[5] = { 0, 4193, 4194, 4195, 4196 };
+ static const uint16_t double_ops[5] = { 0, 4197, 4198, 4199, 4200 };
+
+ uint16_t opcode;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * arrays = state->array_state;
+ struct array_state * a;
+ unsigned true_immediate_count;
+ unsigned true_immediate_size;
+
+
+ if ( (size < 1) || (size > 4) || (stride < 0)
+ || (index > arrays->num_vertex_program_attribs) ){
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ if ( normalized && (type != GL_FLOAT) && (type != GL_DOUBLE)) {
+ switch( type ) {
+ case GL_BYTE: opcode = X_GLrop_VertexAttrib4NbvARB; break;
+ case GL_UNSIGNED_BYTE: opcode = X_GLrop_VertexAttrib4NubvARB; break;
+ case GL_SHORT: opcode = X_GLrop_VertexAttrib4NsvARB; break;
+ case GL_UNSIGNED_SHORT: opcode = X_GLrop_VertexAttrib4NusvARB; break;
+ case GL_INT: opcode = X_GLrop_VertexAttrib4NivARB; break;
+ case GL_UNSIGNED_INT: opcode = X_GLrop_VertexAttrib4NuivARB; break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ true_immediate_count = 4;
+ }
+ else {
+ true_immediate_count = size;
+
+ switch( type ) {
+ case GL_BYTE:
+ opcode = X_GLrop_VertexAttrib4bvARB;
+ true_immediate_count = 4;
+ break;
+ case GL_UNSIGNED_BYTE:
+ opcode = X_GLrop_VertexAttrib4ubvARB;
+ true_immediate_count = 4;
+ break;
+ case GL_SHORT:
+ opcode = short_ops[size];
+ break;
+ case GL_UNSIGNED_SHORT:
+ opcode = X_GLrop_VertexAttrib4usvARB;
+ true_immediate_count = 4;
+ break;
+ case GL_INT:
+ opcode = X_GLrop_VertexAttrib4ivARB;
+ true_immediate_count = 4;
+ break;
+ case GL_UNSIGNED_INT:
+ opcode = X_GLrop_VertexAttrib4uivARB;
+ true_immediate_count = 4;
+ break;
+ case GL_FLOAT:
+ opcode = float_ops[size];
+ break;
+ case GL_DOUBLE:
+ opcode = double_ops[size];
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+ }
+
+ a = get_array_entry( arrays, GL_VERTEX_ATTRIB_ARRAY_POINTER, index );
+ if ( a == NULL ) {
+ __glXSetError(gc, GL_INVALID_OPERATION);
+ return;
+ }
+
+ COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, normalized, 8,
+ opcode );
+
+ true_immediate_size = __glXTypeSize(type) * true_immediate_count;
+ ((uint16_t *) (a)->header)[0] = __GLX_PAD(a->header_size
+ + true_immediate_size);
+
+ if ( a->enabled ) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
+}
+
+
+/**
+ * I don't have 100% confidence that this is correct. The different rules
+ * about whether or not generic vertex attributes alias "classic" vertex
+ * attributes (i.e., attrib1 ?= primary color) between ARB_vertex_program,
+ * ARB_vertex_shader, and NV_vertex_program are a bit confusing. My
+ * feeling is that the client-side doesn't have to worry about it. The
+ * client just sends all the data to the server and lets the server deal
+ * with it.
+ */
+void __indirect_glVertexAttribPointerNV( GLuint index, GLint size,
+ GLenum type, GLsizei stride,
+ const GLvoid * pointer)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ GLboolean normalized = GL_FALSE;
+
+
+ switch( type ) {
+ case GL_UNSIGNED_BYTE:
+ if ( size != 4 ) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ normalized = GL_TRUE;
+
+ case GL_SHORT:
+ case GL_FLOAT:
+ case GL_DOUBLE:
+ __indirect_glVertexAttribPointerARB(index, size, type,
+ normalized,
+ stride, pointer);
+ return;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+}
+
+
+void __indirect_glClientActiveTextureARB(GLenum texture)
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ __GLXattribute * const state = (__GLXattribute *)(gc->client_state_private);
+ struct array_state_vector * const arrays = state->array_state;
+ const GLint unit = (GLint) texture - GL_TEXTURE0;
+
+
+ if ( (unit < 0) || (unit > arrays->num_texture_units) ) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ arrays->active_texture_unit = unit;
+}
+
+
+/**
+ */
+GLboolean
+__glXSetArrayEnable( __GLXattribute * state,
+ GLenum key, unsigned index, GLboolean enable )
+{
+ struct array_state_vector * arrays = state->array_state;
+ struct array_state * a;
+
+
+ if ( key == GL_TEXTURE_COORD_ARRAY ) {
+ index = arrays->active_texture_unit;
+ }
+
+ a = get_array_entry( arrays, key, index );
+
+ if ( (a != NULL) && (a->enabled != enable) ) {
+ a->enabled = enable;
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
+
+ return (a != NULL);
+}
+
+
+void
+__glXArrayDisableAll( __GLXattribute * state )
+{
+ struct array_state_vector * arrays = state->array_state;
+ unsigned i;
+
+
+ for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
+ arrays->arrays[i].enabled = GL_FALSE;
+ }
+
+ arrays->array_info_cache_valid = GL_FALSE;
+}
+
+
+/**
+ */
+GLboolean
+__glXGetArrayEnable( const __GLXattribute * const state,
+ GLenum key, unsigned index, GLintptr * dest )
+{
+ const struct array_state_vector * arrays = state->array_state;
+ const struct array_state * a = get_array_entry( (struct array_state_vector *) arrays,
+ key, index );
+
+ if ( a != NULL ) {
+ *dest = (GLintptr) a->enabled;
+ }
+
+ return (a != NULL);
+}
+
+
+/**
+ */
+GLboolean
+__glXGetArrayType( const __GLXattribute * const state,
+ GLenum key, unsigned index, GLintptr * dest )
+{
+ const struct array_state_vector * arrays = state->array_state;
+ const struct array_state * a = get_array_entry( (struct array_state_vector *) arrays,
+ key, index );
+
+ if ( a != NULL ) {
+ *dest = (GLintptr) a->enabled;
+ }
+
+ return (a != NULL);
+}
+
+
+/**
+ */
+GLboolean
+__glXGetArraySize( const __GLXattribute * const state,
+ GLenum key, unsigned index, GLintptr * dest )
+{
+ const struct array_state_vector * arrays = state->array_state;
+ const struct array_state * a = get_array_entry( (struct array_state_vector *) arrays,
+ key, index );
+
+ if ( a != NULL ) {
+ *dest = (GLintptr) a->count;
+ }
+
+ return (a != NULL);
+}
+
+
+/**
+ */
+GLboolean
+__glXGetArrayStride( const __GLXattribute * const state,
+ GLenum key, unsigned index, GLintptr * dest )
+{
+ const struct array_state_vector * arrays = state->array_state;
+ const struct array_state * a = get_array_entry( (struct array_state_vector *) arrays,
+ key, index );
+
+ if ( a != NULL ) {
+ *dest = (GLintptr) a->user_stride;
+ }
+
+ return (a != NULL);
+}
+
+
+/**
+ */
+GLboolean
+__glXGetArrayPointer( const __GLXattribute * const state,
+ GLenum key, unsigned index, void ** dest )
+{
+ const struct array_state_vector * arrays = state->array_state;
+ const struct array_state * a = get_array_entry( (struct array_state_vector *) arrays,
+ key, index );
+
+
+ if ( a != NULL ) {
+ *dest = (void *) (a->data);
+ }
+
+ return (a != NULL);
+}
+
+
+/**
+ */
+GLboolean
+__glXGetArrayNormalized( const __GLXattribute * const state,
+ GLenum key, unsigned index, GLintptr * dest )
+{
+ const struct array_state_vector * arrays = state->array_state;
+ const struct array_state * a = get_array_entry( (struct array_state_vector *) arrays,
+ key, index );
+
+
+ if ( a != NULL ) {
+ *dest = (GLintptr) a->normalized;
+ }
+
+ return (a != NULL);
+}
+
+
+/**
+ */
+GLuint
+__glXGetActiveTextureUnit( const __GLXattribute * const state )
+{
+ return state->array_state->active_texture_unit;
+}
+
+
+void
+__glXPushArrayState( __GLXattribute * state )
+{
+ struct array_state_vector * arrays = state->array_state;
+ struct array_stack_state * stack = & arrays->stack[ (arrays->stack_index * arrays->num_arrays)];
+ unsigned i;
+
+
+ for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
+ stack[i].data = arrays->arrays[i].data;
+ stack[i].data_type = arrays->arrays[i].data_type;
+ stack[i].user_stride = arrays->arrays[i].user_stride;
+ stack[i].count = arrays->arrays[i].count;
+ stack[i].key = arrays->arrays[i].key;
+ stack[i].enabled = arrays->arrays[i].enabled;
+ }
+
+ arrays->active_texture_unit_stack[ arrays->stack_index ] =
+ arrays->active_texture_unit;
+
+ arrays->stack_index++;
+}
+
+
+void
+__glXPopArrayState( __GLXattribute * state )
+{
+ struct array_state_vector * arrays = state->array_state;
+ struct array_stack_state * stack;
+ unsigned i;
+
+
+ arrays->stack_index--;
+ stack = & arrays->stack[ (arrays->stack_index * arrays->num_arrays) ];
+
+ for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
+ switch ( stack[i].key ) {
+ case GL_NORMAL_ARRAY:
+ __indirect_glNormalPointer( stack[i].data_type,
+ stack[i].user_stride,
+ stack[i].data );
+ break;
+ case GL_COLOR_ARRAY:
+ __indirect_glColorPointer( stack[i].count,
+ stack[i].data_type,
+ stack[i].user_stride,
+ stack[i].data );
+ break;
+ case GL_INDEX_ARRAY:
+ __indirect_glIndexPointer( stack[i].data_type,
+ stack[i].user_stride,
+ stack[i].data );
+ break;
+ case GL_EDGE_FLAG_ARRAY:
+ __indirect_glEdgeFlagPointer( stack[i].user_stride,
+ stack[i].data );
+ break;
+ case GL_TEXTURE_COORD_ARRAY:
+ arrays->active_texture_unit = stack[i].index;
+ __indirect_glTexCoordPointer( stack[i].count,
+ stack[i].data_type,
+ stack[i].user_stride,
+ stack[i].data );
+ break;
+ case GL_SECONDARY_COLOR_ARRAY:
+ __indirect_glSecondaryColorPointerEXT( stack[i].count,
+ stack[i].data_type,
+ stack[i].user_stride,
+ stack[i].data );
+ break;
+ case GL_FOG_COORDINATE_ARRAY:
+ __indirect_glFogCoordPointerEXT( stack[i].data_type,
+ stack[i].user_stride,
+ stack[i].data );
+ break;
+
+ }
+
+ __glXSetArrayEnable( state, stack[i].key, stack[i].index,
+ stack[i].enabled );
+ }
+
+ arrays->active_texture_unit =
+ arrays->active_texture_unit_stack[ arrays->stack_index ];
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/indirect_vertex_array.h b/nx-X11/extras/Mesa/src/glx/x11/indirect_vertex_array.h
new file mode 100644
index 000000000..caab62b67
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/indirect_vertex_array.h
@@ -0,0 +1,57 @@
+/*
+ * (C) Copyright IBM Corporation 2004, 2005
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#ifndef INDIRECT_VERTEX_ARRAY_H
+#define INDIRECT_VERTEX_ARRAY_H
+
+extern const GLuint __glXTypeSize_table[16];
+
+#define __glXTypeSize(e) ((((e) & ~0x0f) != 0x1400) \
+ ? 0 : __glXTypeSize_table[ (e) & 0x0f ])
+
+extern void __glXArrayDisableAll( __GLXattribute * state );
+
+extern GLboolean __glXSetArrayEnable( __GLXattribute * state,
+ GLenum key, unsigned index, GLboolean enable );
+
+extern GLboolean __glXGetArrayEnable( const __GLXattribute * const state,
+ GLenum key, unsigned index, GLintptr * dest );
+extern GLboolean __glXGetArraySize( const __GLXattribute * const state,
+ GLenum key, unsigned index, GLintptr * dest );
+extern GLboolean __glXGetArrayType( const __GLXattribute * const state,
+ GLenum key, unsigned index, GLintptr * dest );
+extern GLboolean __glXGetArrayStride( const __GLXattribute * const state,
+ GLenum key, unsigned index, GLintptr * dest );
+extern GLboolean __glXGetArrayPointer( const __GLXattribute * const state,
+ GLenum key, unsigned index, void ** dest );
+extern GLboolean __glXGetArrayNormalized( const __GLXattribute * const state,
+ GLenum key, unsigned index, GLintptr * dest );
+
+extern void __glXPushArrayState( __GLXattribute * state );
+extern void __glXPopArrayState( __GLXattribute * state );
+
+extern GLuint __glXGetActiveTextureUnit( const __GLXattribute * const state );
+
+#endif /* INDIRECT_VERTEX_ARRAY_H */
diff --git a/nx-X11/extras/Mesa/src/glx/x11/indirect_vertex_program.c b/nx-X11/extras/Mesa/src/glx/x11/indirect_vertex_program.c
new file mode 100644
index 000000000..158327175
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/indirect_vertex_program.c
@@ -0,0 +1,276 @@
+/*
+ * (C) Copyright IBM Corporation 2005
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <inttypes.h>
+#include <GL/gl.h>
+#include "indirect.h"
+#include "glxclient.h"
+#include "indirect_vertex_array.h"
+#include <GL/glxproto.h>
+
+#if !defined __GNUC__ || __GNUC__ < 3
+# define __builtin_expect(x, y) x
+#endif
+
+void do_vertex_attrib_enable( GLuint index, GLboolean val )
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+
+ if ( ! __glXSetArrayEnable( state, GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB,
+ index, val ) ) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ }
+}
+
+
+void __indirect_glEnableVertexAttribArrayARB( GLuint index )
+{
+ do_vertex_attrib_enable( index, GL_TRUE );
+}
+
+
+void __indirect_glDisableVertexAttribArrayARB( GLuint index )
+{
+ do_vertex_attrib_enable( index, GL_FALSE );
+}
+
+
+static void
+get_parameter( unsigned opcode, unsigned size, GLenum target, GLuint index,
+ void * params )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 12;
+
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupVendorRequest(gc,
+ X_GLXVendorPrivateWithReply,
+ opcode, cmdlen);
+
+ *((GLenum *)(pc + 0)) = target;
+ *((GLuint *)(pc + 4)) = index;
+ *((GLuint *)(pc + 8)) = 0;
+
+ (void) __glXReadReply(dpy, size, params, GL_FALSE);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+
+void __indirect_glGetProgramEnvParameterfvARB( GLenum target, GLuint index,
+ GLfloat * params )
+{
+ get_parameter( 1296, 4, target, index, params );
+}
+
+
+void __indirect_glGetProgramEnvParameterdvARB( GLenum target, GLuint index,
+ GLdouble * params )
+{
+ get_parameter( 1297, 8, target, index, params );
+}
+
+
+void __indirect_glGetProgramLocalParameterfvARB( GLenum target, GLuint index,
+ GLfloat * params )
+{
+ get_parameter( 1305, 4, target, index, params );
+}
+
+
+void __indirect_glGetProgramLocalParameterdvARB( GLenum target, GLuint index,
+ GLdouble * params )
+{
+ get_parameter( 1306, 8, target, index, params );
+}
+
+
+void __indirect_glGetVertexAttribPointervNV( GLuint index, GLenum pname,
+ GLvoid ** pointer )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+
+ if ( pname != GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB ) {
+ __glXSetError( gc, GL_INVALID_ENUM );
+ }
+
+ if ( ! __glXGetArrayPointer( state, GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB,
+ index, pointer ) ) {
+ __glXSetError( gc, GL_INVALID_VALUE );
+ }
+}
+
+
+/**
+ * Get the selected attribute from the vertex array state vector.
+ *
+ * \returns
+ * On success \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned.
+ */
+static GLboolean
+get_attrib_array_data( __GLXattribute * state, GLuint index, GLenum cap,
+ GLintptr * data )
+{
+ GLboolean retval = GL_FALSE;
+ const GLenum attrib = GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB;
+
+ switch( cap ) {
+ case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB:
+ retval = __glXGetArrayEnable( state, attrib, index, data );
+ break;
+
+ case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB:
+ retval = __glXGetArraySize( state, attrib, index, data );
+ break;
+
+ case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB:
+ retval = __glXGetArrayStride( state, attrib, index, data );
+ break;
+
+ case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB:
+ retval = __glXGetArrayType( state, attrib, index, data );
+ break;
+
+ case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB:
+ retval = __glXGetArrayNormalized( state, attrib, index, data );
+ break;
+ }
+
+
+ return retval;
+}
+
+
+static void get_vertex_attrib( __GLXcontext * gc, unsigned vop,
+ GLuint index, GLenum pname,
+ xReply * reply )
+{
+ Display * const dpy = gc->currentDpy;
+ GLubyte * const pc = __glXSetupVendorRequest(gc,
+ X_GLXVendorPrivateWithReply,
+ vop, 8);
+
+ *((uint32_t *)(pc + 0)) = index;
+ *((uint32_t *)(pc + 4)) = pname;
+
+ (void) _XReply( dpy, reply, 0, False );
+}
+
+
+void __indirect_glGetVertexAttribivARB( GLuint index, GLenum pname,
+ GLint * params )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ xGLXSingleReply reply;
+
+
+ get_vertex_attrib( gc, 1303, index, pname, (xReply *) & reply );
+
+ if ( reply.size != 0 ) {
+ if ( ! get_attrib_array_data( state, index, pname, params ) ) {
+ if (reply.size == 1) {
+ *params = (GLint) reply.pad3;
+ }
+ else {
+ _XRead(dpy, (void *) params, 4 * reply.size);
+ }
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+
+void __indirect_glGetVertexAttribfvARB( GLuint index, GLenum pname,
+ GLfloat * params )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ xGLXSingleReply reply;
+
+
+ get_vertex_attrib( gc, 1302, index, pname, (xReply *) & reply );
+
+ if ( reply.size != 0 ) {
+ GLintptr data;
+
+
+ if ( get_attrib_array_data( state, index, pname, & data ) ) {
+ *params = (GLfloat) data;
+ }
+ else {
+ if (reply.size == 1) {
+ (void) memcpy( params, & reply.pad3, sizeof( GLfloat ) );
+ }
+ else {
+ _XRead(dpy, (void *) params, 4 * reply.size);
+ }
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
+
+void __indirect_glGetVertexAttribdvARB( GLuint index, GLenum pname,
+ GLdouble * params )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ Display * const dpy = gc->currentDpy;
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ xGLXSingleReply reply;
+
+
+ get_vertex_attrib( gc, 1301, index, pname, (xReply *) & reply );
+
+ if ( reply.size != 0 ) {
+ GLintptr data;
+
+
+ if ( get_attrib_array_data( state, index, pname, & data ) ) {
+ *params = (GLdouble) data;
+ }
+ else {
+ if (reply.size == 1) {
+ (void) memcpy( params, & reply.pad3, sizeof( GLdouble ) );
+ }
+ else {
+ _XRead(dpy, (void *) params, 8 * reply.size);
+ }
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/indirect_window_pos.c b/nx-X11/extras/Mesa/src/glx/x11/indirect_window_pos.c
new file mode 100644
index 000000000..533f8ef1a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/indirect_window_pos.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+ * (C) Copyright IBM Corporation 2004
+ * 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, IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <GL/gl.h>
+#include "indirect.h"
+
+void __indirect_glWindowPos2dMESA(GLdouble x, GLdouble y)
+{
+ __indirect_glWindowPos3fMESA(x, y, 0.0);
+}
+
+void __indirect_glWindowPos2iMESA(GLint x, GLint y)
+{
+ __indirect_glWindowPos3fMESA(x, y, 0.0);
+}
+
+void __indirect_glWindowPos2fMESA(GLfloat x, GLfloat y)
+{
+ __indirect_glWindowPos3fMESA(x, y, 0.0);
+}
+
+void __indirect_glWindowPos2sMESA(GLshort x, GLshort y)
+{
+ __indirect_glWindowPos3fMESA(x, y, 0.0);
+}
+
+void __indirect_glWindowPos2dvMESA(const GLdouble * p)
+{
+ __indirect_glWindowPos3fMESA(p[0], p[1], 0.0);
+}
+
+void __indirect_glWindowPos2fvMESA(const GLfloat * p)
+{
+ __indirect_glWindowPos3fMESA(p[0], p[1], 0.0);
+}
+
+void __indirect_glWindowPos2ivMESA(const GLint * p)
+{
+ __indirect_glWindowPos3fMESA(p[0], p[1], 0.0);
+}
+
+void __indirect_glWindowPos2svMESA(const GLshort * p)
+{
+ __indirect_glWindowPos3fMESA(p[0], p[1], 0.0);
+}
+
+void __indirect_glWindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
+{
+ __indirect_glWindowPos3fMESA(x, y, z);
+}
+
+void __indirect_glWindowPos3iMESA(GLint x, GLint y, GLint z)
+{
+ __indirect_glWindowPos3fMESA(x, y, z);
+}
+
+void __indirect_glWindowPos3sMESA(GLshort x, GLshort y, GLshort z)
+{
+ __indirect_glWindowPos3fMESA(x, y, z);
+}
+
+void __indirect_glWindowPos3dvMESA(const GLdouble * p)
+{
+ __indirect_glWindowPos3fMESA(p[0], p[1], p[2]);
+}
+
+void __indirect_glWindowPos3ivMESA(const GLint * p)
+{
+ __indirect_glWindowPos3fMESA(p[0], p[1], p[2]);
+}
+
+void __indirect_glWindowPos3svMESA(const GLshort * p)
+{
+ __indirect_glWindowPos3fMESA(p[0], p[1], p[2]);
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/packrender.h b/nx-X11/extras/Mesa/src/glx/x11/packrender.h
new file mode 100644
index 000000000..ce2a1616d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/packrender.h
@@ -0,0 +1,249 @@
+/* $XFree86: xc/lib/GL/glx/packrender.h,v 1.7tsi Exp $ */
+#ifndef __GLX_packrender_h__
+#define __GLX_packrender_h__
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#include "glxclient.h"
+
+/*
+** The macros in this header convert the client machine's native data types to
+** wire protocol data types. The header is part of the porting layer of the
+** client library, and it is intended that hardware vendors will rewrite this
+** header to suit their own machines.
+*/
+
+/*
+** Pad a count of bytes to the nearest multiple of 4. The X protocol
+** transfers data in 4 byte quantities, so this macro is used to
+** insure the right amount of data being sent.
+*/
+#define __GLX_PAD(a) (((a)+3) & ~3)
+
+/*
+ ** Network size parameters
+ */
+#define sz_double 8
+
+/* Setup for all commands */
+#define __GLX_DECLARE_VARIABLES() \
+ __GLXcontext *gc; \
+ GLubyte *pc, *pixelHeaderPC; \
+ GLuint compsize, cmdlen
+
+#define __GLX_LOAD_VARIABLES() \
+ gc = __glXGetCurrentContext(); \
+ pc = gc->pc; \
+ /* Muffle compilers */ \
+ cmdlen = 0; (void)cmdlen; \
+ compsize = 0; (void)compsize; \
+ pixelHeaderPC = 0; (void)pixelHeaderPC
+
+/*
+** Variable sized command support macro. This macro is used by calls
+** that are potentially larger than __GLX_SMALL_RENDER_CMD_SIZE.
+** Because of their size, they may not automatically fit in the buffer.
+** If the buffer can't hold the command then it is flushed so that
+** the command will fit in the next buffer.
+*/
+#define __GLX_BEGIN_VARIABLE(opcode,size) \
+ if (pc + (size) > gc->bufEnd) { \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ } \
+ __GLX_PUT_SHORT(0,size); \
+ __GLX_PUT_SHORT(2,opcode)
+
+#define __GLX_BEGIN_VARIABLE_LARGE(opcode,size) \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ __GLX_PUT_LONG(0,size); \
+ __GLX_PUT_LONG(4,opcode)
+
+#define __GLX_BEGIN_VARIABLE_WITH_PIXEL(opcode,size) \
+ if (pc + (size) > gc->bufEnd) { \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ } \
+ __GLX_PUT_SHORT(0,size); \
+ __GLX_PUT_SHORT(2,opcode); \
+ pc += __GLX_RENDER_HDR_SIZE; \
+ pixelHeaderPC = pc; \
+ pc += __GLX_PIXEL_HDR_SIZE
+
+#define __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(opcode,size) \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ __GLX_PUT_LONG(0,size); \
+ __GLX_PUT_LONG(4,opcode); \
+ pc += __GLX_RENDER_LARGE_HDR_SIZE; \
+ pixelHeaderPC = pc; \
+ pc += __GLX_PIXEL_HDR_SIZE
+
+#define __GLX_BEGIN_VARIABLE_WITH_PIXEL_3D(opcode,size) \
+ if (pc + (size) > gc->bufEnd) { \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ } \
+ __GLX_PUT_SHORT(0,size); \
+ __GLX_PUT_SHORT(2,opcode); \
+ pc += __GLX_RENDER_HDR_SIZE; \
+ pixelHeaderPC = pc; \
+ pc += __GLX_PIXEL_3D_HDR_SIZE
+
+#define __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL_3D(opcode,size) \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ __GLX_PUT_LONG(0,size); \
+ __GLX_PUT_LONG(4,opcode); \
+ pc += __GLX_RENDER_LARGE_HDR_SIZE; \
+ pixelHeaderPC = pc; \
+ pc += __GLX_PIXEL_3D_HDR_SIZE
+
+/*
+** Fixed size command support macro. This macro is used by calls that
+** are never larger than __GLX_SMALL_RENDER_CMD_SIZE. Because they
+** always fit in the buffer, and because the buffer promises to
+** maintain enough room for them, we don't need to check for space
+** before doing the storage work.
+*/
+#define __GLX_BEGIN(opcode,size) \
+ __GLX_PUT_SHORT(0,size); \
+ __GLX_PUT_SHORT(2,opcode)
+
+/*
+** Finish a rendering command by advancing the pc. If the pc is now past
+** the limit pointer then there is no longer room for a
+** __GLX_SMALL_RENDER_CMD_SIZE sized command, which will break the
+** assumptions present in the __GLX_BEGIN macro. In this case the
+** rendering buffer is flushed out into the X protocol stream (which may
+** or may not do I/O).
+*/
+#define __GLX_END(size) \
+ pc += size; \
+ if (pc > gc->limit) { \
+ (void) __glXFlushRenderBuffer(gc, pc); \
+ } else { \
+ gc->pc = pc; \
+ }
+
+/* Array copy macros */
+#define __GLX_MEM_COPY(dest,src,bytes) \
+ if (src && dest) \
+ memcpy(dest, src, bytes)
+
+/* Single item copy macros */
+#define __GLX_PUT_CHAR(offset,a) \
+ *((INT8 *) (pc + offset)) = a
+
+#ifndef _CRAY
+#define __GLX_PUT_SHORT(offset,a) \
+ *((INT16 *) (pc + offset)) = a
+
+#define __GLX_PUT_LONG(offset,a) \
+ *((INT32 *) (pc + offset)) = a
+
+#define __GLX_PUT_FLOAT(offset,a) \
+ *((FLOAT32 *) (pc + offset)) = a
+
+#else
+#define __GLX_PUT_SHORT(offset,a) \
+ { GLubyte *cp = (pc+offset); \
+ int shift = (64-16) - ((int)(cp) >> (64-6)); \
+ *(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); }
+
+#define __GLX_PUT_LONG(offset,a) \
+ { GLubyte *cp = (pc+offset); \
+ int shift = (64-32) - ((int)(cp) >> (64-6)); \
+ *(int *)cp = (*(int *)cp & ~(0xffffffff << shift)) | ((a & 0xffffffff) << shift); }
+
+#define __GLX_PUT_FLOAT(offset,a) \
+ gl_put_float((pc + offset),a)
+
+#define __GLX_PUT_DOUBLE(offset,a) \
+ gl_put_double(pc + offset, a)
+
+extern void gl_put_float(/*GLubyte *, struct cray_single*/);
+extern void gl_put_double(/*GLubyte *, struct cray_double*/);
+#endif
+
+#ifndef _CRAY
+
+#ifdef __GLX_ALIGN64
+/*
+** This can certainly be done better for a particular machine
+** architecture!
+*/
+#define __GLX_PUT_DOUBLE(offset,a) \
+ __GLX_MEM_COPY(pc + offset, &a, 8)
+#else
+#define __GLX_PUT_DOUBLE(offset,a) \
+ *((FLOAT64 *) (pc + offset)) = a
+#endif
+
+#endif
+
+#define __GLX_PUT_CHAR_ARRAY(offset,a,alen) \
+ __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT8)
+
+#ifndef _CRAY
+#define __GLX_PUT_SHORT_ARRAY(offset,a,alen) \
+ __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT16)
+
+#define __GLX_PUT_LONG_ARRAY(offset,a,alen) \
+ __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT32)
+
+#define __GLX_PUT_FLOAT_ARRAY(offset,a,alen) \
+ __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_FLOAT32)
+
+#define __GLX_PUT_DOUBLE_ARRAY(offset,a,alen) \
+ __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_FLOAT64)
+
+#else
+#define __GLX_PUT_SHORT_ARRAY(offset,a,alen) \
+ gl_put_short_array((GLubyte *)(pc + offset), a, alen * __GLX_SIZE_INT16)
+
+#define __GLX_PUT_LONG_ARRAY(offset,a,alen) \
+ gl_put_long_array((GLubyte *)(pc + offset), (long *)a, alen * __GLX_SIZE_INT32)
+
+#define __GLX_PUT_FLOAT_ARRAY(offset,a,alen) \
+ gl_put_float_array((GLubyte *)(pc + offset), (float *)a, alen * __GLX_SIZE_FLOAT32)
+
+#define __GLX_PUT_DOUBLE_ARRAY(offset,a,alen) \
+ gl_put_double_array((GLubyte *)(pc + offset), (double *)a, alen * __GLX_SIZE_FLOAT64)
+
+extern gl_put_short_array (GLubyte *, short *, int);
+extern gl_put_long_array (GLubyte *, long *, int);
+extern gl_put_float_array (GLubyte *, float *, int);
+extern gl_put_double_array (GLubyte *, double *, int);
+
+#endif /* _CRAY */
+
+#endif /* !__GLX_packrender_h__ */
diff --git a/nx-X11/extras/Mesa/src/glx/x11/packsingle.h b/nx-X11/extras/Mesa/src/glx/x11/packsingle.h
new file mode 100644
index 000000000..16b054f1e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/packsingle.h
@@ -0,0 +1,219 @@
+/* $XFree86: xc/lib/GL/glx/packsingle.h,v 1.5tsi Exp $ */
+#ifndef __GLX_packsingle_h__
+#define __GLX_packsingle_h__
+
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#include "packrender.h"
+
+/*
+** The macros in this header convert wire protocol data types to the client
+** machine's native data types. The header is part of the porting layer of
+** the client library, and it is intended that hardware vendors will rewrite
+** this header to suit their own machines.
+*/
+
+/*
+** Dummy define to make the GetReqExtra macro happy. The value is not
+** used, but instead the code in __GLX_SINGLE_BEGIN issues its own store
+** to req->reqType with the proper code (our extension code).
+*/
+#define X_GLXSingle 0
+
+/* Declare common variables used during a single command */
+#define __GLX_SINGLE_DECLARE_VARIABLES() \
+ __GLXcontext *gc = __glXGetCurrentContext(); \
+ GLubyte *pc, *pixelHeaderPC; \
+ GLuint compsize, cmdlen; \
+ Display *dpy = gc->currentDpy; \
+ xGLXSingleReq *req
+
+#define __GLX_SINGLE_LOAD_VARIABLES() \
+ pc = gc->pc; \
+ /* Muffle compilers */ \
+ pixelHeaderPC = 0; (void)pixelHeaderPC; \
+ compsize = 0; (void)compsize; \
+ cmdlen = 0; (void)cmdlen
+
+/* Start a single command */
+#define __GLX_SINGLE_BEGIN(opcode,bytes) \
+ if (dpy) { \
+ (void) __glXFlushRenderBuffer(gc, pc); \
+ LockDisplay(dpy); \
+ GetReqExtra(GLXSingle,bytes,req); \
+ req->reqType = gc->majorOpcode; \
+ req->glxCode = opcode; \
+ req->contextTag = gc->currentContextTag; \
+ pc = ((GLubyte *)(req) + sz_xGLXSingleReq)
+
+/* End a single command */
+#define __GLX_SINGLE_END() \
+ UnlockDisplay(dpy); \
+ SyncHandle(); \
+ }
+
+/* Store data to sending for a single command */
+#define __GLX_SINGLE_PUT_CHAR(offset,a) \
+ *((INT8 *) (pc + offset)) = a
+
+#ifndef CRAY
+#define __GLX_SINGLE_PUT_SHORT(offset,a) \
+ *((INT16 *) (pc + offset)) = a
+
+#define __GLX_SINGLE_PUT_LONG(offset,a) \
+ *((INT32 *) (pc + offset)) = a
+
+#define __GLX_SINGLE_PUT_FLOAT(offset,a) \
+ *((FLOAT32 *) (pc + offset)) = a
+
+#else
+#define __GLX_SINGLE_PUT_SHORT(offset,a) \
+ { GLubyte *cp = (pc+offset); \
+ int shift = (64-16) - ((int)(cp) >> (64-6)); \
+ *(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); }
+
+#define __GLX_SINGLE_PUT_LONG(offset,a) \
+ { GLubyte *cp = (pc+offset); \
+ int shift = (64-32) - ((int)(cp) >> (64-6)); \
+ *(int *)cp = (*(int *)cp & ~(0xffffffff << shift)) | ((a & 0xffffffff) << shift); }
+
+#define __GLX_SINGLE_PUT_FLOAT(offset,a) \
+ gl_put_float(pc + offset, a)
+#endif
+
+/* Read support macros */
+#define __GLX_SINGLE_READ_XREPLY() \
+ (void) _XReply(dpy, (xReply*) &reply, 0, False)
+
+#define __GLX_SINGLE_GET_RETVAL(a,cast) \
+ a = (cast) reply.retval
+
+#define __GLX_SINGLE_GET_SIZE(a) \
+ a = (GLint) reply.size
+
+#ifndef _CRAY
+#define __GLX_SINGLE_GET_CHAR(p) \
+ *p = *(GLbyte *)&reply.pad3;
+
+#define __GLX_SINGLE_GET_SHORT(p) \
+ *p = *(GLshort *)&reply.pad3;
+
+#define __GLX_SINGLE_GET_LONG(p) \
+ *p = *(GLint *)&reply.pad3;
+
+#define __GLX_SINGLE_GET_FLOAT(p) \
+ *p = *(GLfloat *)&reply.pad3;
+
+#else
+#define __GLX_SINGLE_GET_CHAR(p) \
+ *p = reply.pad3 >> 24;
+
+#define __GLX_SINGLE_GET_SHORT(p) \
+ {int t = reply.pad3 >> 16; \
+ *p = (t & 0x8000) ? (t | ~0xffff) : (t & 0xffff);}
+
+#define __GLX_SINGLE_GET_LONG(p) \
+ {int t = reply.pad3; \
+ *p = (t & 0x80000000) ? (t | ~0xffffffff) : (t & 0xffffffff);}
+
+#define PAD3OFFSET 16
+#define __GLX_SINGLE_GET_FLOAT(p) \
+ *p = gl_ntoh_float((GLubyte *)&reply + PAD3OFFSET);
+
+#define __GLX_SINGLE_GET_DOUBLE(p) \
+ *p = gl_ntoh_double((GLubyte *)&reply + PAD3OFFSET);
+
+extern float gl_ntoh_float(GLubyte *);
+extern float gl_ntoh_double(GLubyte *);
+#endif
+
+#ifndef _CRAY
+
+#ifdef __GLX_ALIGN64
+#define __GLX_SINGLE_GET_DOUBLE(p) \
+ __GLX_MEM_COPY(p, &reply.pad3, 8)
+#else
+#define __GLX_SINGLE_GET_DOUBLE(p) \
+ *p = *(GLdouble *)&reply.pad3
+#endif
+
+#endif
+
+/* Get an array of typed data */
+#define __GLX_SINGLE_GET_VOID_ARRAY(a,alen) \
+{ \
+ GLint slop = alen*__GLX_SIZE_INT8 & 3; \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \
+ if (slop) _XEatData(dpy,4-slop); \
+}
+
+#define __GLX_SINGLE_GET_CHAR_ARRAY(a,alen) \
+{ \
+ GLint slop = alen*__GLX_SIZE_INT8 & 3; \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \
+ if (slop) _XEatData(dpy,4-slop); \
+}
+
+
+#define __GLX_SINGLE_GET_SHORT_ARRAY(a,alen) \
+{ \
+ GLint slop = (alen*__GLX_SIZE_INT16) & 3; \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT16);\
+ if (slop) _XEatData(dpy,4-slop); \
+}
+
+#define __GLX_SINGLE_GET_LONG_ARRAY(a,alen) \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT32);
+
+#ifndef _CRAY
+#define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT32);
+
+#define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT64);
+
+#else
+#define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \
+ gl_get_float_array(dpy,a,alen);
+
+#define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \
+ gl_get_double_array(dpy, a, alen);
+
+extern void gl_get_float_array(Display *dpy, float *a, int alen);
+extern void gl_get_double_array(Display *dpy, double *a, int alen);
+#endif
+
+#endif /* !__GLX_packsingle_h__ */
diff --git a/nx-X11/extras/Mesa/src/glx/x11/pixel.c b/nx-X11/extras/Mesa/src/glx/x11/pixel.c
new file mode 100644
index 000000000..3b3a1811a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/pixel.c
@@ -0,0 +1,443 @@
+/* $XFree86: xc/lib/GL/glx/pixel.c,v 1.8 2003/09/28 20:15:04 alanh Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#include "packrender.h"
+
+static const GLubyte MsbToLsbTable[256] = {
+ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+ 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+ 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+ 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+ 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+ 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+ 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+ 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+ 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+ 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+ 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+ 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+ 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+ 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+ 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+ 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+ 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+ 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+ 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+ 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+ 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+ 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+ 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+ 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+ 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+ 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+ 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+ 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+ 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+ 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+ 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+ 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
+};
+
+static const GLubyte LowBitsMask[9] = {
+ 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff,
+};
+
+static const GLubyte HighBitsMask[9] = {
+ 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff,
+};
+
+
+/*
+** Copy bitmap data from clients packed memory applying unpacking modes as the
+** data is transfered into the destImage buffer. Return in modes the
+** set of pixel modes that are to be done by the server.
+*/
+static void FillBitmap(__GLXcontext *gc, GLint width, GLint height,
+ GLenum format, const GLvoid *userdata,
+ GLubyte *destImage)
+{
+ const __GLXattribute * state = gc->client_state_private;
+ GLint rowLength = state->storeUnpack.rowLength;
+ GLint alignment = state->storeUnpack.alignment;
+ GLint skipPixels = state->storeUnpack.skipPixels;
+ GLint skipRows = state->storeUnpack.skipRows;
+ GLint lsbFirst = state->storeUnpack.lsbFirst;
+ GLint elementsLeft, bitOffset, currentByte, nextByte, highBitMask;
+ GLint lowBitMask, i;
+ GLint components, groupsPerRow, rowSize, padding, elementsPerRow;
+ const GLubyte *start, *iter;
+
+ if (rowLength > 0) {
+ groupsPerRow = rowLength;
+ } else {
+ groupsPerRow = width;
+ }
+ components = __glElementsPerGroup(format,GL_BITMAP);
+ rowSize = (groupsPerRow * components + 7) >> 3;
+ padding = (rowSize % alignment);
+ if (padding) {
+ rowSize += alignment - padding;
+ }
+ start = ((const GLubyte*) userdata) + skipRows * rowSize +
+ ((skipPixels * components) >> 3);
+ bitOffset = (skipPixels * components) & 7;
+ highBitMask = LowBitsMask[8-bitOffset];
+ lowBitMask = HighBitsMask[bitOffset];
+ elementsPerRow = width * components;
+ for (i = 0; i < height; i++) {
+ elementsLeft = elementsPerRow;
+ iter = start;
+ while (elementsLeft) {
+ /* First retrieve low bits from current byte */
+ if (lsbFirst) {
+ currentByte = MsbToLsbTable[iter[0]];
+ } else {
+ currentByte = iter[0];
+ }
+ if (bitOffset) {
+ /* Need to read next byte to finish current byte */
+ if (elementsLeft > (8 - bitOffset)) {
+ if (lsbFirst) {
+ nextByte = MsbToLsbTable[iter[1]];
+ } else {
+ nextByte = iter[1];
+ }
+ currentByte =
+ ((currentByte & highBitMask) << bitOffset) |
+ ((nextByte & lowBitMask) >> (8 - bitOffset));
+ } else {
+ currentByte =
+ ((currentByte & highBitMask) << bitOffset);
+ }
+ }
+ if (elementsLeft >= 8) {
+ *destImage = currentByte;
+ elementsLeft -= 8;
+ } else {
+ *destImage = currentByte & HighBitsMask[elementsLeft];
+ elementsLeft = 0;
+ }
+ destImage++;
+ iter++;
+ }
+ start += rowSize;
+ }
+}
+
+/*
+** Extract array from user's data applying all pixel store modes.
+** The internal packed array format used has LSB_FIRST = FALSE and
+** ALIGNMENT = 1.
+*/
+void __glFillImage(__GLXcontext *gc, GLint dim, GLint width, GLint height,
+ GLint depth, GLenum format, GLenum type,
+ const GLvoid *userdata, GLubyte *newimage, GLubyte *modes)
+{
+ const __GLXattribute * state = gc->client_state_private;
+ GLint rowLength = state->storeUnpack.rowLength;
+ GLint imageHeight = state->storeUnpack.imageHeight;
+ GLint alignment = state->storeUnpack.alignment;
+ GLint skipPixels = state->storeUnpack.skipPixels;
+ GLint skipRows = state->storeUnpack.skipRows;
+ GLint skipImages = state->storeUnpack.skipImages;
+ GLint swapBytes = state->storeUnpack.swapEndian;
+ GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize;
+ GLint elementsPerRow, imageSize, rowsPerImage, h, i, j, k;
+ const GLubyte *start, *iter, *itera, *iterb, *iterc;
+ GLubyte *iter2;
+
+ if (type == GL_BITMAP) {
+ FillBitmap(gc, width, height, format, userdata, newimage);
+ } else {
+ components = __glElementsPerGroup(format,type);
+ if (rowLength > 0) {
+ groupsPerRow = rowLength;
+ } else {
+ groupsPerRow = width;
+ }
+ if (imageHeight > 0) {
+ rowsPerImage = imageHeight;
+ } else {
+ rowsPerImage = height;
+ }
+
+ elementSize = __glBytesPerElement(type);
+ groupSize = elementSize * components;
+ if (elementSize == 1) swapBytes = 0;
+
+ rowSize = groupsPerRow * groupSize;
+ padding = (rowSize % alignment);
+ if (padding) {
+ rowSize += alignment - padding;
+ }
+ imageSize = rowSize * rowsPerImage;
+ start = ((const GLubyte*) userdata) + skipImages * imageSize +
+ skipRows * rowSize + skipPixels * groupSize;
+ iter2 = newimage;
+ elementsPerRow = width * components;
+
+ if (swapBytes) {
+ itera = start;
+ for (h = 0; h < depth; h++) {
+ iterb = itera;
+ for (i = 0; i < height; i++) {
+ iterc = iterb;
+ for (j = 0; j < elementsPerRow; j++) {
+ for (k = 1; k <= elementSize; k++) {
+ iter2[k-1] = iterc[elementSize - k];
+ }
+ iter2 += elementSize;
+ iterc += elementSize;
+ }
+ iterb += rowSize;
+ }
+ itera += imageSize;
+ }
+ } else {
+ itera = start;
+ for (h = 0; h < depth; h++) {
+ if (rowSize == elementsPerRow * elementSize) {
+ /* Ha! This is mondo easy! */
+ __GLX_MEM_COPY(iter2, itera,
+ elementsPerRow * elementSize * height);
+ iter2 += elementsPerRow * elementSize * height;
+ } else {
+ iter = itera;
+ for (i = 0; i < height; i++) {
+ __GLX_MEM_COPY(iter2, iter, elementsPerRow*elementSize);
+ iter2 += elementsPerRow * elementSize;
+ iter += rowSize;
+ }
+ }
+ itera += imageSize;
+ }
+ }
+ }
+
+ /* Setup store modes that describe what we just did */
+ if (modes) {
+ if ( dim < 3 ) {
+ (void) memcpy( modes, __glXDefaultPixelStore + 4, 20 );
+ }
+ else {
+ (void) memcpy( modes, __glXDefaultPixelStore + 0, 36 );
+ }
+ }
+}
+
+/*
+** Empty a bitmap in LSB_FIRST=GL_FALSE and ALIGNMENT=4 format packing it
+** into the clients memory using the pixel store PACK modes.
+*/
+static void EmptyBitmap(__GLXcontext *gc, GLint width, GLint height,
+ GLenum format, const GLubyte *sourceImage,
+ GLvoid *userdata)
+{
+ const __GLXattribute * state = gc->client_state_private;
+ GLint rowLength = state->storePack.rowLength;
+ GLint alignment = state->storePack.alignment;
+ GLint skipPixels = state->storePack.skipPixels;
+ GLint skipRows = state->storePack.skipRows;
+ GLint lsbFirst = state->storePack.lsbFirst;
+ GLint components, groupsPerRow, rowSize, padding, elementsPerRow;
+ GLint sourceRowSize, sourcePadding, sourceSkip;
+ GLubyte *start, *iter;
+ GLint elementsLeft, bitOffset, currentByte, highBitMask, lowBitMask;
+ GLint writeMask, i;
+ GLubyte writeByte;
+
+ components = __glElementsPerGroup(format,GL_BITMAP);
+ if (rowLength > 0) {
+ groupsPerRow = rowLength;
+ } else {
+ groupsPerRow = width;
+ }
+
+ rowSize = (groupsPerRow * components + 7) >> 3;
+ padding = (rowSize % alignment);
+ if (padding) {
+ rowSize += alignment - padding;
+ }
+ sourceRowSize = (width * components + 7) >> 3;
+ sourcePadding = (sourceRowSize % 4);
+ if (sourcePadding) {
+ sourceSkip = 4 - sourcePadding;
+ } else {
+ sourceSkip = 0;
+ }
+ start = ((GLubyte*) userdata) + skipRows * rowSize +
+ ((skipPixels * components) >> 3);
+ bitOffset = (skipPixels * components) & 7;
+ highBitMask = LowBitsMask[8-bitOffset];
+ lowBitMask = HighBitsMask[bitOffset];
+ elementsPerRow = width * components;
+ for (i = 0; i < height; i++) {
+ elementsLeft = elementsPerRow;
+ iter = start;
+ writeMask = highBitMask;
+ writeByte = 0;
+ while (elementsLeft) {
+ /* Set up writeMask (to write to current byte) */
+ if (elementsLeft + bitOffset < 8) {
+ /* Need to trim writeMask */
+ writeMask &= HighBitsMask[bitOffset+elementsLeft];
+ }
+
+ if (lsbFirst) {
+ currentByte = MsbToLsbTable[iter[0]];
+ } else {
+ currentByte = iter[0];
+ }
+
+ if (bitOffset) {
+ writeByte |= (sourceImage[0] >> bitOffset);
+ currentByte = (currentByte & ~writeMask) |
+ (writeByte & writeMask);
+ writeByte = (sourceImage[0] << (8 - bitOffset));
+ } else {
+ currentByte = (currentByte & ~writeMask) |
+ (sourceImage[0] & writeMask);
+ }
+
+ if (lsbFirst) {
+ iter[0] = MsbToLsbTable[currentByte];
+ } else {
+ iter[0] = currentByte;
+ }
+
+ if (elementsLeft >= 8) {
+ elementsLeft -= 8;
+ } else {
+ elementsLeft = 0;
+ }
+ sourceImage++;
+ iter++;
+ writeMask = 0xff;
+ }
+ if (writeByte) {
+ /* Some data left over that still needs writing */
+ writeMask &= lowBitMask;
+ if (lsbFirst) {
+ currentByte = MsbToLsbTable[iter[0]];
+ } else {
+ currentByte = iter[0];
+ }
+ currentByte = (currentByte & ~writeMask) | (writeByte & writeMask);
+ if (lsbFirst) {
+ iter[0] = MsbToLsbTable[currentByte];
+ } else {
+ iter[0] = currentByte;
+ }
+ }
+ start += rowSize;
+ sourceImage += sourceSkip;
+ }
+}
+
+/*
+** Insert array into user's data applying all pixel store modes.
+** The packed array format from the server is LSB_FIRST = FALSE,
+** SWAP_BYTES = the current pixel storage pack mode, and ALIGNMENT = 4.
+** Named __glEmptyImage() because it is the opposite of __glFillImage().
+*/
+/* ARGSUSED */
+void __glEmptyImage(__GLXcontext *gc, GLint dim, GLint width, GLint height,
+ GLint depth, GLenum format, GLenum type,
+ const GLubyte *sourceImage, GLvoid *userdata)
+{
+ const __GLXattribute * state = gc->client_state_private;
+ GLint rowLength = state->storePack.rowLength;
+ GLint imageHeight = state->storePack.imageHeight;
+ GLint alignment = state->storePack.alignment;
+ GLint skipPixels = state->storePack.skipPixels;
+ GLint skipRows = state->storePack.skipRows;
+ GLint skipImages = state->storePack.skipImages;
+ GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize;
+ GLint elementsPerRow, sourceRowSize, sourcePadding, h, i;
+ GLint imageSize, rowsPerImage;
+ GLubyte *start, *iter, *itera;
+
+ if (type == GL_BITMAP) {
+ EmptyBitmap(gc, width, height, format, sourceImage, userdata);
+ } else {
+ components = __glElementsPerGroup(format,type);
+ if (rowLength > 0) {
+ groupsPerRow = rowLength;
+ } else {
+ groupsPerRow = width;
+ }
+ if (imageHeight > 0) {
+ rowsPerImage = imageHeight;
+ } else {
+ rowsPerImage = height;
+ }
+ elementSize = __glBytesPerElement(type);
+ groupSize = elementSize * components;
+ rowSize = groupsPerRow * groupSize;
+ padding = (rowSize % alignment);
+ if (padding) {
+ rowSize += alignment - padding;
+ }
+ sourceRowSize = width * groupSize;
+ sourcePadding = (sourceRowSize % 4);
+ if (sourcePadding) {
+ sourceRowSize += 4 - sourcePadding;
+ }
+ imageSize = sourceRowSize * rowsPerImage;
+ start = ((GLubyte*) userdata) + skipImages * imageSize +
+ skipRows * rowSize + skipPixels * groupSize;
+ elementsPerRow = width * components;
+
+ itera = start;
+ for (h = 0; h < depth; h++) {
+ if ((rowSize == sourceRowSize) && (sourcePadding == 0)) {
+ /* Ha! This is mondo easy! */
+ __GLX_MEM_COPY(itera, sourceImage,
+ elementsPerRow * elementSize * height);
+ sourceImage += elementsPerRow * elementSize * height;
+ } else {
+ iter = itera;
+ for (i = 0; i < height; i++) {
+ __GLX_MEM_COPY(iter, sourceImage,
+ elementsPerRow * elementSize);
+ sourceImage += sourceRowSize;
+ iter += rowSize;
+ }
+ }
+ itera += imageSize;
+ }
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/pixelstore.c b/nx-X11/extras/Mesa/src/glx/x11/pixelstore.c
new file mode 100644
index 000000000..8996ee879
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/pixelstore.c
@@ -0,0 +1,341 @@
+/* $XFree86: xc/lib/GL/glx/pixelstore.c,v 1.4 2004/01/28 18:11:43 alanh Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#include "glxclient.h"
+#include "indirect.h"
+
+#if !defined __GNUC__ || __GNUC__ < 3
+# define __builtin_expect(x, y) x
+#endif
+
+/**
+ * Send glPixelStore command to the server
+ *
+ * \param gc Current GLX context
+ * \param sop Either \c X_GLsop_PixelStoref or \c X_GLsop_PixelStorei
+ * \param pname Selector of which pixel parameter is to be set.
+ * \param param Value that \c pname is set to.
+ *
+ * \sa __indirect_glPixelStorei, __indirect_glPixelStoref
+ */
+static void
+send_PixelStore( __GLXcontext * gc, unsigned sop, GLenum pname,
+ const void * param )
+{
+ Display * const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const * pc = __glXSetupSingleRequest(gc, sop, cmdlen);
+ (void) memcpy((void *)(pc + 0), (void *)(&pname), 4);
+ (void) memcpy((void *)(pc + 4), param, 4);
+ UnlockDisplay(dpy); SyncHandle();
+ }
+ return;
+}
+
+/*
+** Specify parameters that control the storage format of pixel arrays.
+*/
+void __indirect_glPixelStoref(GLenum pname, GLfloat param)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = gc->client_state_private;
+ Display *dpy = gc->currentDpy;
+ GLuint a;
+
+ if (!dpy) return;
+
+ switch (pname) {
+ case GL_PACK_ROW_LENGTH:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.rowLength = a;
+ break;
+ case GL_PACK_IMAGE_HEIGHT:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.imageHeight = a;
+ break;
+ case GL_PACK_SKIP_ROWS:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipRows = a;
+ break;
+ case GL_PACK_SKIP_PIXELS:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipPixels = a;
+ break;
+ case GL_PACK_SKIP_IMAGES:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipImages = a;
+ break;
+ case GL_PACK_ALIGNMENT:
+ a = (GLint) (param + 0.5);
+ switch (a) {
+ case 1: case 2: case 4: case 8:
+ state->storePack.alignment = a;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ break;
+ case GL_PACK_SWAP_BYTES:
+ state->storePack.swapEndian = (param != 0);
+ break;
+ case GL_PACK_LSB_FIRST:
+ state->storePack.lsbFirst = (param != 0);
+ break;
+
+ case GL_UNPACK_ROW_LENGTH:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.rowLength = a;
+ break;
+ case GL_UNPACK_IMAGE_HEIGHT:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.imageHeight = a;
+ break;
+ case GL_UNPACK_SKIP_ROWS:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipRows = a;
+ break;
+ case GL_UNPACK_SKIP_PIXELS:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipPixels = a;
+ break;
+ case GL_UNPACK_SKIP_IMAGES:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipImages = a;
+ break;
+ case GL_UNPACK_ALIGNMENT:
+ a = (GLint) (param + 0.5);
+ switch (a) {
+ case 1: case 2: case 4: case 8:
+ state->storeUnpack.alignment = a;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ break;
+ case GL_UNPACK_SWAP_BYTES:
+ state->storeUnpack.swapEndian = (param != 0);
+ break;
+ case GL_UNPACK_LSB_FIRST:
+ state->storeUnpack.lsbFirst = (param != 0);
+ break;
+
+ /* Group all of the pixel store modes that need to be sent to the
+ * server here. Care must be used to only send modes to the server that
+ * won't affect the size of the data sent to or received from the
+ * server. GL_PACK_INVERT_MESA is safe in this respect, but other,
+ * future modes may not be.
+ */
+ case GL_PACK_INVERT_MESA:
+ send_PixelStore( gc, X_GLsop_PixelStoref, pname, & param );
+ break;
+
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ break;
+ }
+}
+
+void __indirect_glPixelStorei(GLenum pname, GLint param)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = gc->client_state_private;
+ Display *dpy = gc->currentDpy;
+
+ if (!dpy) return;
+
+ switch (pname) {
+ case GL_PACK_ROW_LENGTH:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.rowLength = param;
+ break;
+ case GL_PACK_IMAGE_HEIGHT:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.imageHeight = param;
+ break;
+ case GL_PACK_SKIP_ROWS:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipRows = param;
+ break;
+ case GL_PACK_SKIP_PIXELS:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipPixels = param;
+ break;
+ case GL_PACK_SKIP_IMAGES:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipImages = param;
+ break;
+ case GL_PACK_ALIGNMENT:
+ switch (param) {
+ case 1: case 2: case 4: case 8:
+ state->storePack.alignment = param;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ break;
+ case GL_PACK_SWAP_BYTES:
+ state->storePack.swapEndian = (param != 0);
+ break;
+ case GL_PACK_LSB_FIRST:
+ state->storePack.lsbFirst = (param != 0);
+ break;
+
+ case GL_UNPACK_ROW_LENGTH:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.rowLength = param;
+ break;
+ case GL_UNPACK_IMAGE_HEIGHT:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.imageHeight = param;
+ break;
+ case GL_UNPACK_SKIP_ROWS:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipRows = param;
+ break;
+ case GL_UNPACK_SKIP_PIXELS:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipPixels = param;
+ break;
+ case GL_UNPACK_SKIP_IMAGES:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipImages = param;
+ break;
+ case GL_UNPACK_ALIGNMENT:
+ switch (param) {
+ case 1: case 2: case 4: case 8:
+ state->storeUnpack.alignment = param;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ break;
+ case GL_UNPACK_SWAP_BYTES:
+ state->storeUnpack.swapEndian = (param != 0);
+ break;
+ case GL_UNPACK_LSB_FIRST:
+ state->storeUnpack.lsbFirst = (param != 0);
+ break;
+
+ /* Group all of the pixel store modes that need to be sent to the
+ * server here. Care must be used to only send modes to the server that
+ * won't affect the size of the data sent to or received from the
+ * server. GL_PACK_INVERT_MESA is safe in this respect, but other,
+ * future modes may not be.
+ */
+ case GL_PACK_INVERT_MESA:
+ send_PixelStore( gc, X_GLsop_PixelStorei, pname, & param );
+ break;
+
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ break;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/render2.c b/nx-X11/extras/Mesa/src/glx/x11/render2.c
new file mode 100644
index 000000000..21ba27099
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/render2.c
@@ -0,0 +1,363 @@
+/* $XFree86: xc/lib/GL/glx/render2.c,v 1.6 2004/01/31 09:29:33 alanh Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#include "packrender.h"
+#include "indirect.h"
+#include "indirect_size.h"
+
+/*
+** This file contains routines that might need to be transported as
+** GLXRender or GLXRenderLarge commands, and these commands don't
+** use the pixel header. See renderpix.c for those routines.
+*/
+
+void __indirect_glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
+ GLint order, const GLdouble *pnts)
+{
+ __GLX_DECLARE_VARIABLES();
+ GLint k;
+
+ __GLX_LOAD_VARIABLES();
+ k = __glMap1d_size(target);
+ if (k == 0) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ } else if (stride < k || order <= 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ compsize = k * order * __GLX_SIZE_FLOAT64;
+ cmdlen = 28+compsize;
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE(X_GLrop_Map1d,cmdlen);
+ __GLX_PUT_DOUBLE(4,u1);
+ __GLX_PUT_DOUBLE(12,u2);
+ __GLX_PUT_LONG(20,target);
+ __GLX_PUT_LONG(24,order);
+ /*
+ ** NOTE: the doubles that follow are not aligned because of 3
+ ** longs preceeding
+ */
+ __glFillMap1d(k, order, stride, pnts, (pc+28));
+ __GLX_END(cmdlen);
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1d,cmdlen+4);
+ __GLX_PUT_DOUBLE(8,u1);
+ __GLX_PUT_DOUBLE(16,u2);
+ __GLX_PUT_LONG(24,target);
+ __GLX_PUT_LONG(28,order);
+
+ /*
+ ** NOTE: the doubles that follow are not aligned because of 3
+ ** longs preceeding
+ */
+ if (stride != k) {
+ GLubyte *buf;
+
+ buf = (GLubyte *) Xmalloc(compsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+ __glFillMap1d(k, order, stride, pnts, buf);
+ __glXSendLargeCommand(gc, pc, 32, buf, compsize);
+ Xfree((char*) buf);
+ } else {
+ /* Data is already packed. Just send it out */
+ __glXSendLargeCommand(gc, pc, 32, pnts, compsize);
+ }
+ }
+}
+
+void __indirect_glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
+ GLint order, const GLfloat *pnts)
+{
+ __GLX_DECLARE_VARIABLES();
+ GLint k;
+
+ __GLX_LOAD_VARIABLES();
+ k = __glMap1f_size(target);
+ if (k == 0) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ } else if (stride < k || order <= 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ compsize = k * order * __GLX_SIZE_FLOAT32;
+ cmdlen = 20+compsize;
+ if (!gc->currentDpy) return;
+
+ /*
+ ** The order that arguments are packed is different from the order
+ ** for glMap1d.
+ */
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE(X_GLrop_Map1f,cmdlen);
+ __GLX_PUT_LONG(4,target);
+ __GLX_PUT_FLOAT(8,u1);
+ __GLX_PUT_FLOAT(12,u2);
+ __GLX_PUT_LONG(16,order);
+ __glFillMap1f(k, order, stride, pnts, (GLubyte*) (pc+20));
+ __GLX_END(cmdlen);
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1f,cmdlen+4);
+ __GLX_PUT_LONG(8,target);
+ __GLX_PUT_FLOAT(12,u1);
+ __GLX_PUT_FLOAT(16,u2);
+ __GLX_PUT_LONG(20,order);
+
+ if (stride != k) {
+ GLubyte *buf;
+
+ buf = (GLubyte *) Xmalloc(compsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+ __glFillMap1f(k, order, stride, pnts, buf);
+ __glXSendLargeCommand(gc, pc, 24, buf, compsize);
+ Xfree((char*) buf);
+ } else {
+ /* Data is already packed. Just send it out */
+ __glXSendLargeCommand(gc, pc, 24, pnts, compsize);
+ }
+ }
+}
+
+void __indirect_glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustr, GLint uord,
+ GLdouble v1, GLdouble v2, GLint vstr, GLint vord,
+ const GLdouble *pnts)
+{
+ __GLX_DECLARE_VARIABLES();
+ GLint k;
+
+ __GLX_LOAD_VARIABLES();
+ k = __glMap2d_size(target);
+ if (k == 0) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ } else if (vstr < k || ustr < k || vord <= 0 || uord <= 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ compsize = k * uord * vord * __GLX_SIZE_FLOAT64;
+ cmdlen = 48+compsize;
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE(X_GLrop_Map2d,cmdlen);
+ __GLX_PUT_DOUBLE(4,u1);
+ __GLX_PUT_DOUBLE(12,u2);
+ __GLX_PUT_DOUBLE(20,v1);
+ __GLX_PUT_DOUBLE(28,v2);
+ __GLX_PUT_LONG(36,target);
+ __GLX_PUT_LONG(40,uord);
+ __GLX_PUT_LONG(44,vord);
+ /*
+ ** Pack into a u-major ordering.
+ ** NOTE: the doubles that follow are not aligned because of 5
+ ** longs preceeding
+ */
+ __glFillMap2d(k, uord, vord, ustr, vstr, pnts, (GLdouble*) (pc+48));
+ __GLX_END(cmdlen);
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2d,cmdlen+4);
+ __GLX_PUT_DOUBLE(8,u1);
+ __GLX_PUT_DOUBLE(16,u2);
+ __GLX_PUT_DOUBLE(24,v1);
+ __GLX_PUT_DOUBLE(32,v2);
+ __GLX_PUT_LONG(40,target);
+ __GLX_PUT_LONG(44,uord);
+ __GLX_PUT_LONG(48,vord);
+
+ /*
+ ** NOTE: the doubles that follow are not aligned because of 5
+ ** longs preceeding
+ */
+ if ((vstr != k) || (ustr != k*vord)) {
+ GLdouble *buf;
+
+ buf = (GLdouble *) Xmalloc(compsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+ /*
+ ** Pack into a u-major ordering.
+ */
+ __glFillMap2d(k, uord, vord, ustr, vstr, pnts, buf);
+ __glXSendLargeCommand(gc, pc, 52, buf, compsize);
+ Xfree((char*) buf);
+ } else {
+ /* Data is already packed. Just send it out */
+ __glXSendLargeCommand(gc, pc, 52, pnts, compsize);
+ }
+ }
+}
+
+void __indirect_glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustr, GLint uord,
+ GLfloat v1, GLfloat v2, GLint vstr, GLint vord,
+ const GLfloat *pnts)
+{
+ __GLX_DECLARE_VARIABLES();
+ GLint k;
+
+ __GLX_LOAD_VARIABLES();
+ k = __glMap2f_size(target);
+ if (k == 0) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ } else if (vstr < k || ustr < k || vord <= 0 || uord <= 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ compsize = k * uord * vord * __GLX_SIZE_FLOAT32;
+ cmdlen = 32+compsize;
+ if (!gc->currentDpy) return;
+
+ /*
+ ** The order that arguments are packed is different from the order
+ ** for glMap2d.
+ */
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE(X_GLrop_Map2f,cmdlen);
+ __GLX_PUT_LONG(4,target);
+ __GLX_PUT_FLOAT(8,u1);
+ __GLX_PUT_FLOAT(12,u2);
+ __GLX_PUT_LONG(16,uord);
+ __GLX_PUT_FLOAT(20,v1);
+ __GLX_PUT_FLOAT(24,v2);
+ __GLX_PUT_LONG(28,vord);
+ /*
+ ** Pack into a u-major ordering.
+ */
+ __glFillMap2f(k, uord, vord, ustr, vstr, pnts, (GLfloat*) (pc+32));
+ __GLX_END(cmdlen);
+ } else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2f,cmdlen+4);
+ __GLX_PUT_LONG(8,target);
+ __GLX_PUT_FLOAT(12,u1);
+ __GLX_PUT_FLOAT(16,u2);
+ __GLX_PUT_LONG(20,uord);
+ __GLX_PUT_FLOAT(24,v1);
+ __GLX_PUT_FLOAT(28,v2);
+ __GLX_PUT_LONG(32,vord);
+
+ if ((vstr != k) || (ustr != k*vord)) {
+ GLfloat *buf;
+
+ buf = (GLfloat *) Xmalloc(compsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+ /*
+ ** Pack into a u-major ordering.
+ */
+ __glFillMap2f(k, uord, vord, ustr, vstr, pnts, buf);
+ __glXSendLargeCommand(gc, pc, 36, buf, compsize);
+ Xfree((char*) buf);
+ } else {
+ /* Data is already packed. Just send it out */
+ __glXSendLargeCommand(gc, pc, 36, pnts, compsize);
+ }
+ }
+}
+
+void __indirect_glEnable(GLenum cap)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (!gc->currentDpy) return;
+
+ switch(cap) {
+ case GL_COLOR_ARRAY:
+ case GL_EDGE_FLAG_ARRAY:
+ case GL_INDEX_ARRAY:
+ case GL_NORMAL_ARRAY:
+ case GL_TEXTURE_COORD_ARRAY:
+ case GL_VERTEX_ARRAY:
+ case GL_SECONDARY_COLOR_ARRAY:
+ case GL_FOG_COORD_ARRAY:
+ __indirect_glEnableClientState(cap);
+ return;
+ default:
+ break;
+ }
+
+ __GLX_BEGIN(X_GLrop_Enable,8);
+ __GLX_PUT_LONG(4,cap);
+ __GLX_END(8);
+}
+
+void __indirect_glDisable(GLenum cap)
+{
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (!gc->currentDpy) return;
+
+ switch(cap) {
+ case GL_COLOR_ARRAY:
+ case GL_EDGE_FLAG_ARRAY:
+ case GL_INDEX_ARRAY:
+ case GL_NORMAL_ARRAY:
+ case GL_TEXTURE_COORD_ARRAY:
+ case GL_VERTEX_ARRAY:
+ case GL_SECONDARY_COLOR_ARRAY:
+ case GL_FOG_COORD_ARRAY:
+ __indirect_glDisableClientState(cap);
+ return;
+ default:
+ break;
+ }
+
+ __GLX_BEGIN(X_GLrop_Disable,8);
+ __GLX_PUT_LONG(4,cap);
+ __GLX_END(8);
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/renderpix.c b/nx-X11/extras/Mesa/src/glx/x11/renderpix.c
new file mode 100644
index 000000000..b7d01dc67
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/renderpix.c
@@ -0,0 +1,215 @@
+/* $XFree86: xc/lib/GL/glx/renderpix.c,v 1.5 2003/09/28 20:15:04 alanh Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+/*
+ * (C) Copyright IBM Corporation 2005
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "packrender.h"
+#include "indirect.h"
+
+/**
+ * Send a large image to the server. If necessary, a buffer is allocated
+ * to hold the unpacked data that is copied from the clients memory.
+ *
+ * \param gc Current GLX context
+ * \param compsize Size, in bytes, of the image portion
+ * \param dim Number of dimensions of the image
+ * \param width Width of the image
+ * \param height Height of the image, must be 1 for 1D images
+ * \param depth Depth of the image, must be 1 for 1D or 2D images
+ * \param format Format of the image
+ * \param type Data type of the image
+ * \param src Pointer to the image data
+ * \param pc Pointer to end of the command header
+ * \param modes Pointer to the pixel unpack data
+ *
+ * \todo
+ * Modify this function so that \c NULL images are sent using
+ * \c __glXSendLargeChunk instead of __glXSendLargeCommand. Doing this
+ * will eliminate the need to allocate a buffer for that case.
+ *
+ * \bugs
+ * The \c fastImageUnpack path, which is thankfully never used, is completely
+ * broken.
+ */
+void
+__glXSendLargeImage(__GLXcontext *gc, GLint compsize, GLint dim,
+ GLint width, GLint height, GLint depth,
+ GLenum format, GLenum type, const GLvoid *src,
+ GLubyte *pc, GLubyte *modes)
+{
+ if ( !gc->fastImageUnpack || (src == NULL) ) {
+ /* Allocate a temporary holding buffer */
+ GLubyte *buf = (GLubyte *) Xmalloc(compsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+
+ /* Apply pixel store unpack modes to copy data into buf */
+ if ( src != NULL ) {
+ (*gc->fillImage)(gc, dim, width, height, depth, format, type,
+ src, buf, modes);
+ }
+ else {
+ if ( dim < 3 ) {
+ (void) memcpy( modes, __glXDefaultPixelStore + 4, 20 );
+ }
+ else {
+ (void) memcpy( modes, __glXDefaultPixelStore + 0, 36 );
+ }
+ }
+
+ /* Send large command */
+ __glXSendLargeCommand(gc, gc->pc, pc - gc->pc, buf, compsize);
+
+ /* Free buffer */
+ Xfree((char*) buf);
+ } else {
+ /* Just send the data straight as is */
+ __glXSendLargeCommand(gc, gc->pc, pc - gc->pc, pc, compsize);
+ }
+}
+
+/************************************************************************/
+
+/**
+ * Implement GLX protocol for \c glSeparableFilter2D.
+ *
+ * \bugs
+ * The \c fastImageUnpack path, which is thankfully never used, is completely
+ * broken.
+ */
+void __indirect_glSeparableFilter2D(GLenum target, GLenum internalformat,
+ GLsizei width, GLsizei height, GLenum format,
+ GLenum type, const GLvoid *row,
+ const GLvoid *column)
+{
+ __GLX_DECLARE_VARIABLES();
+ GLuint compsize2, hdrlen, totalhdrlen, image1len, image2len;
+
+ __GLX_LOAD_VARIABLES();
+ compsize = __glImageSize(width, 1, 1, format, type, 0);
+ compsize2 = __glImageSize(height, 1, 1, format, type, 0);
+ totalhdrlen = __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE);
+ hdrlen = __GLX_PAD(__GLX_CONV_FILT_HDR_SIZE);
+ image1len = __GLX_PAD(compsize);
+ image2len = __GLX_PAD(compsize2);
+ cmdlen = totalhdrlen + image1len + image2len;
+ if (!gc->currentDpy) return;
+
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_SeparableFilter2D, cmdlen);
+ __GLX_PUT_LONG(0,target);
+ __GLX_PUT_LONG(4,internalformat);
+ __GLX_PUT_LONG(8,width);
+ __GLX_PUT_LONG(12,height);
+ __GLX_PUT_LONG(16,format);
+ __GLX_PUT_LONG(20,type);
+ pc += hdrlen;
+ if (compsize > 0) {
+ (*gc->fillImage)(gc, 1, width, 1, 1, format, type,
+ row, pc, pixelHeaderPC);
+ pc += image1len;
+ }
+ if (compsize2 > 0) {
+ (*gc->fillImage)(gc, 1, height, 1, 1, format, type,
+ column, pc, NULL);
+ pc += image2len;
+ }
+ if ((compsize == 0) && (compsize2 == 0)) {
+ /* Setup default store modes */
+ (void) memcpy( pixelHeaderPC, __glXDefaultPixelStore + 4, 20 );
+ }
+ __GLX_END(0);
+ } else {
+ const GLint bufsize = image1len + image2len;
+
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_SeparableFilter2D,cmdlen+4);
+ __GLX_PUT_LONG(0,target);
+ __GLX_PUT_LONG(4,internalformat);
+ __GLX_PUT_LONG(8,width);
+ __GLX_PUT_LONG(12,height);
+ __GLX_PUT_LONG(16,format);
+ __GLX_PUT_LONG(20,type);
+ pc += hdrlen;
+
+ if (!gc->fastImageUnpack) {
+ /* Allocate a temporary holding buffer */
+ GLubyte *buf = (GLubyte *) Xmalloc(bufsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+ (*gc->fillImage)(gc, 1, width, 1, 1, format, type, row, buf, pixelHeaderPC);
+
+ (*gc->fillImage)(gc, 1, height, 1, 1, format, type, column,
+ buf + image1len, pixelHeaderPC);
+
+ /* Send large command */
+ __glXSendLargeCommand(gc, gc->pc, (GLint)(pc - gc->pc), buf, bufsize);
+ /* Free buffer */
+ Xfree((char*) buf);
+ } else {
+ /* Just send the data straight as is */
+ __glXSendLargeCommand(gc, gc->pc, (GLint)(pc - gc->pc), pc, bufsize);
+ }
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/single2.c b/nx-X11/extras/Mesa/src/glx/x11/single2.c
new file mode 100644
index 000000000..1c3b8f08e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/single2.c
@@ -0,0 +1,833 @@
+/* $XFree86: xc/lib/GL/glx/single2.c,v 1.10 2004/02/11 19:48:16 dawes Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#include <stdio.h>
+#include <assert.h>
+#include "glxclient.h"
+#include "packsingle.h"
+#include "glxextensions.h"
+#include "indirect.h"
+#include "indirect_vertex_array.h"
+
+/* Used for GL_ARB_transpose_matrix */
+static void TransposeMatrixf(GLfloat m[16])
+{
+ int i, j;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < i; j++) {
+ GLfloat tmp = m[i*4+j];
+ m[i*4+j] = m[j*4+i];
+ m[j*4+i] = tmp;
+ }
+ }
+}
+
+/* Used for GL_ARB_transpose_matrix */
+static void TransposeMatrixb(GLboolean m[16])
+{
+ int i, j;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < i; j++) {
+ GLboolean tmp = m[i*4+j];
+ m[i*4+j] = m[j*4+i];
+ m[j*4+i] = tmp;
+ }
+ }
+}
+
+/* Used for GL_ARB_transpose_matrix */
+static void TransposeMatrixd(GLdouble m[16])
+{
+ int i, j;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < i; j++) {
+ GLdouble tmp = m[i*4+j];
+ m[i*4+j] = m[j*4+i];
+ m[j*4+i] = tmp;
+ }
+ }
+}
+
+/* Used for GL_ARB_transpose_matrix */
+static void TransposeMatrixi(GLint m[16])
+{
+ int i, j;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < i; j++) {
+ GLint tmp = m[i*4+j];
+ m[i*4+j] = m[j*4+i];
+ m[j*4+i] = tmp;
+ }
+ }
+}
+
+
+/**
+ * Remap a transpose-matrix enum to a non-transpose-matrix enum. Enums
+ * that are not transpose-matrix enums are unaffected.
+ */
+static GLenum
+RemapTransposeEnum( GLenum e )
+{
+ switch( e ) {
+ case GL_TRANSPOSE_MODELVIEW_MATRIX:
+ case GL_TRANSPOSE_PROJECTION_MATRIX:
+ case GL_TRANSPOSE_TEXTURE_MATRIX:
+ return e - (GL_TRANSPOSE_MODELVIEW_MATRIX - GL_MODELVIEW_MATRIX);
+ case GL_TRANSPOSE_COLOR_MATRIX:
+ return GL_COLOR_MATRIX;
+ default:
+ return e;
+ };
+}
+
+
+GLenum __indirect_glGetError(void)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ GLuint retval = GL_NO_ERROR;
+ xGLXGetErrorReply reply;
+
+ if (gc->error) {
+ /* Use internal error first */
+ retval = gc->error;
+ gc->error = GL_NO_ERROR;
+ return retval;
+ }
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetError,0);
+ __GLX_SINGLE_READ_XREPLY();
+ retval = reply.error;
+ __GLX_SINGLE_END();
+
+ return retval;
+}
+
+
+/**
+ * Get the selected attribute from the client state.
+ *
+ * \returns
+ * On success \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned.
+ */
+static GLboolean
+get_client_data( __GLXattribute * state, GLenum cap, GLintptr * data )
+{
+ GLboolean retval = GL_TRUE;
+ const GLint tex_unit = __glXGetActiveTextureUnit( state );
+
+
+ switch( cap ) {
+ case GL_VERTEX_ARRAY:
+ case GL_NORMAL_ARRAY:
+ case GL_COLOR_ARRAY:
+ case GL_INDEX_ARRAY:
+ case GL_EDGE_FLAG_ARRAY:
+ case GL_SECONDARY_COLOR_ARRAY:
+ case GL_FOG_COORD_ARRAY:
+ retval = __glXGetArrayEnable( state, cap, 0, data );
+ break;
+
+ case GL_VERTEX_ARRAY_SIZE:
+ retval = __glXGetArraySize( state, GL_VERTEX_ARRAY, 0, data );
+ break;
+ case GL_COLOR_ARRAY_SIZE:
+ retval = __glXGetArraySize( state, GL_COLOR_ARRAY, 0, data );
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_SIZE:
+ retval = __glXGetArraySize( state, GL_SECONDARY_COLOR_ARRAY, 0, data );
+ break;
+
+ case GL_VERTEX_ARRAY_TYPE:
+ retval = __glXGetArrayType( state, GL_VERTEX_ARRAY, 0, data );
+ break;
+ case GL_NORMAL_ARRAY_TYPE:
+ retval = __glXGetArrayType( state, GL_NORMAL_ARRAY, 0, data );
+ break;
+ case GL_INDEX_ARRAY_TYPE:
+ retval = __glXGetArrayType( state, GL_INDEX_ARRAY, 0, data );
+ break;
+ case GL_COLOR_ARRAY_TYPE:
+ retval = __glXGetArrayType( state, GL_COLOR_ARRAY, 0, data );
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_TYPE:
+ retval = __glXGetArrayType( state, GL_SECONDARY_COLOR_ARRAY, 0, data );
+ break;
+ case GL_FOG_COORD_ARRAY_TYPE:
+ retval = __glXGetArrayType( state, GL_FOG_COORD_ARRAY, 0, data );
+ break;
+
+ case GL_VERTEX_ARRAY_STRIDE:
+ retval = __glXGetArrayStride( state, GL_VERTEX_ARRAY, 0, data );
+ break;
+ case GL_NORMAL_ARRAY_STRIDE:
+ retval = __glXGetArrayStride( state, GL_NORMAL_ARRAY, 0, data );
+ break;
+ case GL_INDEX_ARRAY_STRIDE:
+ retval = __glXGetArrayStride( state, GL_INDEX_ARRAY, 0, data );
+ break;
+ case GL_EDGE_FLAG_ARRAY_STRIDE:
+ retval = __glXGetArrayStride( state, GL_EDGE_FLAG_ARRAY, 0, data );
+ break;
+ case GL_COLOR_ARRAY_STRIDE:
+ retval = __glXGetArrayStride( state, GL_COLOR_ARRAY, 0, data );
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_STRIDE:
+ retval = __glXGetArrayStride( state, GL_SECONDARY_COLOR_ARRAY, 0, data );
+ break;
+ case GL_FOG_COORD_ARRAY_STRIDE:
+ retval = __glXGetArrayStride( state, GL_FOG_COORD_ARRAY, 0, data );
+ break;
+
+ case GL_TEXTURE_COORD_ARRAY:
+ retval = __glXGetArrayEnable( state, GL_TEXTURE_COORD_ARRAY, tex_unit, data );
+ break;
+ case GL_TEXTURE_COORD_ARRAY_SIZE:
+ retval = __glXGetArraySize( state, GL_TEXTURE_COORD_ARRAY, tex_unit, data );
+ break;
+ case GL_TEXTURE_COORD_ARRAY_TYPE:
+ retval = __glXGetArrayType( state, GL_TEXTURE_COORD_ARRAY, tex_unit, data );
+ break;
+ case GL_TEXTURE_COORD_ARRAY_STRIDE:
+ retval = __glXGetArrayStride( state, GL_TEXTURE_COORD_ARRAY, tex_unit, data );
+ break;
+
+ case GL_MAX_ELEMENTS_VERTICES:
+ case GL_MAX_ELEMENTS_INDICES:
+ retval = GL_TRUE;
+ *data = ~0UL;
+ break;
+
+
+ case GL_PACK_ROW_LENGTH:
+ *data = (GLintptr)state->storePack.rowLength;
+ break;
+ case GL_PACK_IMAGE_HEIGHT:
+ *data = (GLintptr)state->storePack.imageHeight;
+ break;
+ case GL_PACK_SKIP_ROWS:
+ *data = (GLintptr)state->storePack.skipRows;
+ break;
+ case GL_PACK_SKIP_PIXELS:
+ *data = (GLintptr)state->storePack.skipPixels;
+ break;
+ case GL_PACK_SKIP_IMAGES:
+ *data = (GLintptr)state->storePack.skipImages;
+ break;
+ case GL_PACK_ALIGNMENT:
+ *data = (GLintptr)state->storePack.alignment;
+ break;
+ case GL_PACK_SWAP_BYTES:
+ *data = (GLintptr)state->storePack.swapEndian;
+ break;
+ case GL_PACK_LSB_FIRST:
+ *data = (GLintptr)state->storePack.lsbFirst;
+ break;
+ case GL_UNPACK_ROW_LENGTH:
+ *data = (GLintptr)state->storeUnpack.rowLength;
+ break;
+ case GL_UNPACK_IMAGE_HEIGHT:
+ *data = (GLintptr)state->storeUnpack.imageHeight;
+ break;
+ case GL_UNPACK_SKIP_ROWS:
+ *data = (GLintptr)state->storeUnpack.skipRows;
+ break;
+ case GL_UNPACK_SKIP_PIXELS:
+ *data = (GLintptr)state->storeUnpack.skipPixels;
+ break;
+ case GL_UNPACK_SKIP_IMAGES:
+ *data = (GLintptr)state->storeUnpack.skipImages;
+ break;
+ case GL_UNPACK_ALIGNMENT:
+ *data = (GLintptr)state->storeUnpack.alignment;
+ break;
+ case GL_UNPACK_SWAP_BYTES:
+ *data = (GLintptr)state->storeUnpack.swapEndian;
+ break;
+ case GL_UNPACK_LSB_FIRST:
+ *data = (GLintptr)state->storeUnpack.lsbFirst;
+ break;
+ case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
+ *data = (GLintptr)__GL_CLIENT_ATTRIB_STACK_DEPTH;
+ break;
+ case GL_CLIENT_ACTIVE_TEXTURE:
+ *data = (GLintptr)(tex_unit + GL_TEXTURE0);
+ break;
+
+ default:
+ retval = GL_FALSE;
+ break;
+ }
+
+
+ return retval;
+}
+
+
+void __indirect_glGetBooleanv(GLenum val, GLboolean *b)
+{
+ const GLenum origVal = val;
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ xGLXSingleReply reply;
+
+ val = RemapTransposeEnum( val );
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetBooleanv,4);
+ __GLX_SINGLE_PUT_LONG(0,val);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+
+ if (compsize == 0) {
+ /*
+ ** Error occured; don't modify user's buffer.
+ */
+ } else {
+ GLintptr data;
+
+ /*
+ ** We still needed to send the request to the server in order to
+ ** find out whether it was legal to make a query (it's illegal,
+ ** for example, to call a query between glBegin() and glEnd()).
+ */
+
+ if ( get_client_data( state, val, & data ) ) {
+ *b = (GLboolean) data;
+ }
+ else {
+ /*
+ ** Not a local value, so use what we got from the server.
+ */
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_CHAR(b);
+ } else {
+ __GLX_SINGLE_GET_CHAR_ARRAY(b,compsize);
+ if (val != origVal) {
+ /* matrix transpose */
+ TransposeMatrixb(b);
+ }
+ }
+ }
+ }
+ __GLX_SINGLE_END();
+}
+
+void __indirect_glGetDoublev(GLenum val, GLdouble *d)
+{
+ const GLenum origVal = val;
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ xGLXSingleReply reply;
+
+ val = RemapTransposeEnum( val );
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetDoublev,4);
+ __GLX_SINGLE_PUT_LONG(0,val);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+
+ if (compsize == 0) {
+ /*
+ ** Error occured; don't modify user's buffer.
+ */
+ } else {
+ GLintptr data;
+
+ /*
+ ** We still needed to send the request to the server in order to
+ ** find out whether it was legal to make a query (it's illegal,
+ ** for example, to call a query between glBegin() and glEnd()).
+ */
+
+ if ( get_client_data( state, val, & data ) ) {
+ *d = (GLdouble) data;
+ }
+ else {
+ /*
+ ** Not a local value, so use what we got from the server.
+ */
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_DOUBLE(d);
+ } else {
+ __GLX_SINGLE_GET_DOUBLE_ARRAY(d,compsize);
+ if (val != origVal) {
+ /* matrix transpose */
+ TransposeMatrixd(d);
+ }
+ }
+ }
+ }
+ __GLX_SINGLE_END();
+}
+
+void __indirect_glGetFloatv(GLenum val, GLfloat *f)
+{
+ const GLenum origVal = val;
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ xGLXSingleReply reply;
+
+ val = RemapTransposeEnum( val );
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetFloatv,4);
+ __GLX_SINGLE_PUT_LONG(0,val);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+
+ if (compsize == 0) {
+ /*
+ ** Error occured; don't modify user's buffer.
+ */
+ } else {
+ GLintptr data;
+
+ /*
+ ** We still needed to send the request to the server in order to
+ ** find out whether it was legal to make a query (it's illegal,
+ ** for example, to call a query between glBegin() and glEnd()).
+ */
+
+ if ( get_client_data( state, val, & data ) ) {
+ *f = (GLfloat) data;
+ }
+ else {
+ /*
+ ** Not a local value, so use what we got from the server.
+ */
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_FLOAT(f);
+ } else {
+ __GLX_SINGLE_GET_FLOAT_ARRAY(f,compsize);
+ if (val != origVal) {
+ /* matrix transpose */
+ TransposeMatrixf(f);
+ }
+ }
+ }
+ }
+ __GLX_SINGLE_END();
+}
+
+void __indirect_glGetIntegerv(GLenum val, GLint *i)
+{
+ const GLenum origVal = val;
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ xGLXSingleReply reply;
+
+ val = RemapTransposeEnum( val );
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetIntegerv,4);
+ __GLX_SINGLE_PUT_LONG(0,val);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+
+ if (compsize == 0) {
+ /*
+ ** Error occured; don't modify user's buffer.
+ */
+ } else {
+ GLintptr data;
+
+ /*
+ ** We still needed to send the request to the server in order to
+ ** find out whether it was legal to make a query (it's illegal,
+ ** for example, to call a query between glBegin() and glEnd()).
+ */
+
+ if ( get_client_data( state, val, & data ) ) {
+ *i = (GLint) data;
+ }
+ else {
+ /*
+ ** Not a local value, so use what we got from the server.
+ */
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_LONG(i);
+ } else {
+ __GLX_SINGLE_GET_LONG_ARRAY(i,compsize);
+ if (val != origVal) {
+ /* matrix transpose */
+ TransposeMatrixi(i);
+ }
+ }
+ }
+ }
+ __GLX_SINGLE_END();
+}
+
+/*
+** Send all pending commands to server.
+*/
+void __indirect_glFlush(void)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+
+ if (!dpy) return;
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_Flush,0);
+ __GLX_SINGLE_END();
+
+ /* And finally flush the X protocol data */
+ XFlush(dpy);
+}
+
+void __indirect_glFeedbackBuffer(GLsizei size, GLenum type, GLfloat *buffer)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+
+ if (!dpy) return;
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_FeedbackBuffer,8);
+ __GLX_SINGLE_PUT_LONG(0,size);
+ __GLX_SINGLE_PUT_LONG(4,type);
+ __GLX_SINGLE_END();
+
+ gc->feedbackBuf = buffer;
+}
+
+void __indirect_glSelectBuffer(GLsizei numnames, GLuint *buffer)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+
+ if (!dpy) return;
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_SelectBuffer,4);
+ __GLX_SINGLE_PUT_LONG(0,numnames);
+ __GLX_SINGLE_END();
+
+ gc->selectBuf = buffer;
+}
+
+GLint __indirect_glRenderMode(GLenum mode)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ GLint retval = 0;
+ xGLXRenderModeReply reply;
+
+ if (!dpy) return -1;
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_RenderMode,4);
+ __GLX_SINGLE_PUT_LONG(0,mode);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_RETVAL(retval,GLint);
+
+ if (reply.newMode != mode) {
+ /*
+ ** Switch to new mode did not take effect, therefore an error
+ ** occured. When an error happens the server won't send us any
+ ** other data.
+ */
+ } else {
+ /* Read the feedback or selection data */
+ if (gc->renderMode == GL_FEEDBACK) {
+ __GLX_SINGLE_GET_SIZE(compsize);
+ __GLX_SINGLE_GET_FLOAT_ARRAY(gc->feedbackBuf, compsize);
+ } else
+ if (gc->renderMode == GL_SELECT) {
+ __GLX_SINGLE_GET_SIZE(compsize);
+ __GLX_SINGLE_GET_LONG_ARRAY(gc->selectBuf, compsize);
+ }
+ gc->renderMode = mode;
+ }
+ __GLX_SINGLE_END();
+
+ return retval;
+}
+
+void __indirect_glFinish(void)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_Finish,0);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_END();
+}
+
+
+/**
+ * Extract the major and minor version numbers from a version string.
+ */
+static void
+version_from_string( const char * ver,
+ int * major_version, int * minor_version )
+{
+ const char * end;
+ long major;
+ long minor;
+
+ major = strtol( ver, (char **) & end, 10 );
+ minor = strtol( end + 1, NULL, 10 );
+ *major_version = major;
+ *minor_version = minor;
+}
+
+
+const GLubyte *__indirect_glGetString(GLenum name)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ Display *dpy = gc->currentDpy;
+ GLubyte *s = NULL;
+
+ if (!dpy) return 0;
+
+ /*
+ ** Return the cached copy if the string has already been fetched
+ */
+ switch(name) {
+ case GL_VENDOR:
+ if (gc->vendor) return gc->vendor;
+ break;
+ case GL_RENDERER:
+ if (gc->renderer) return gc->renderer;
+ break;
+ case GL_VERSION:
+ if (gc->version) return gc->version;
+ break;
+ case GL_EXTENSIONS:
+ if (gc->extensions) return gc->extensions;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return 0;
+ }
+
+ /*
+ ** Get requested string from server
+ */
+
+ (void) __glXFlushRenderBuffer( gc, gc->pc );
+ s = (GLubyte *) __glXGetStringFromServer( dpy, gc->majorOpcode,
+ X_GLsop_GetString, gc->currentContextTag,
+ name );
+ if (!s) {
+ /* Throw data on the floor */
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ } else {
+ /*
+ ** Update local cache
+ */
+ switch(name) {
+ case GL_VENDOR:
+ gc->vendor = s;
+ break;
+
+ case GL_RENDERER:
+ gc->renderer = s;
+ break;
+
+ case GL_VERSION: {
+ int client_major;
+ int client_minor;
+
+ version_from_string( (char *) s,
+ & gc->server_major, & gc->server_minor );
+ __glXGetGLVersion( & client_major, & client_minor );
+
+ if ( (gc->server_major < client_major)
+ || ((gc->server_major == client_major)
+ && (gc->server_minor <= client_minor)) ) {
+ gc->version = s;
+ }
+ else {
+ /* Allow 7 bytes for the client-side GL version. This allows
+ * for upto version 999.999. I'm not holding my breath for
+ * that one! The extra 4 is for the ' ()\0' that will be
+ * added.
+ */
+ const size_t size = 7 + strlen( (char *) s ) + 4;
+
+ gc->version = Xmalloc( size );
+ if ( gc->version == NULL ) {
+ /* If we couldn't allocate memory for the new string,
+ * make a best-effort and just copy the client-side version
+ * to the string and use that. It probably doesn't
+ * matter what is done here. If there not memory available
+ * for a short string, the system is probably going to die
+ * soon anyway.
+ */
+ snprintf( (char *) s, strlen( (char *) s ) + 1, "%u.%u",
+ client_major, client_minor );
+ gc->version = s;
+ }
+ else {
+ snprintf( (char *)gc->version, size, "%u.%u (%s)",
+ client_major, client_minor, s );
+ Xfree( s );
+ s = gc->version;
+ }
+ }
+ break;
+ }
+
+ case GL_EXTENSIONS: {
+ int major = 1;
+ int minor = 0;
+
+ /* This code is currently disabled. I was reminded that some
+ * vendors intentionally exclude some extensions from their
+ * extension string that are part of the core version they
+ * advertise. In particular, on Nvidia drivers this means that
+ * the functionality is supported by the driver, but is not
+ * hardware accelerated. For example, a TNT will show core
+ * version 1.5, but most of the post-1.2 functionality is a
+ * software fallback.
+ *
+ * I don't want to break applications that rely on this odd
+ * behavior. At the same time, the code is written and tested,
+ * so I didn't want to throw it away. Therefore, the code is here
+ * but disabled. In the future, we may wish to and an environment
+ * variable to enable it.
+ */
+
+#if 0
+ /* Call glGetString just to make sure that gc->server_major and
+ * gc->server_minor are set. This version may be higher than we
+ * can completely support, but it may imply support for some
+ * extensions that we can support.
+ *
+ * For example, at the time of this writing, the client-side
+ * library only supports upto core GL version 1.2. However, cubic
+ * textures, multitexture, multisampling, and some other 1.3
+ * features are supported. If the server reports back version
+ * 1.3, but does not report all of those extensions, we will
+ * enable them.
+ */
+ (void *) glGetString( GL_VERSION );
+ major = gc->server_major,
+ minor = gc->server_minor;
+#endif
+
+ __glXCalculateUsableGLExtensions( gc, (char *) s, major, minor );
+ XFree( s );
+ s = gc->extensions;
+ break;
+ }
+ }
+ }
+ return s;
+}
+
+GLboolean __indirect_glIsEnabled(GLenum cap)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ xGLXSingleReply reply;
+ GLboolean retval = 0;
+ GLintptr enable;
+
+ if (!dpy) return 0;
+
+ switch(cap) {
+ case GL_VERTEX_ARRAY:
+ case GL_NORMAL_ARRAY:
+ case GL_COLOR_ARRAY:
+ case GL_INDEX_ARRAY:
+ case GL_EDGE_FLAG_ARRAY:
+ case GL_SECONDARY_COLOR_ARRAY:
+ case GL_FOG_COORD_ARRAY:
+ retval = __glXGetArrayEnable( state, cap, 0, & enable );
+ assert( retval );
+ return (GLboolean) enable;
+ break;
+ case GL_TEXTURE_COORD_ARRAY:
+ retval = __glXGetArrayEnable( state, GL_TEXTURE_COORD_ARRAY,
+ __glXGetActiveTextureUnit( state ), & enable );
+ assert( retval );
+ return (GLboolean) enable;
+ break;
+ }
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_IsEnabled,4);
+ __GLX_SINGLE_PUT_LONG(0,cap);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_RETVAL(retval, GLboolean);
+ __GLX_SINGLE_END();
+ return retval;
+}
+
+void __indirect_glGetPointerv(GLenum pname, void **params)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ Display *dpy = gc->currentDpy;
+
+ if (!dpy) return;
+
+ switch(pname) {
+ case GL_VERTEX_ARRAY_POINTER:
+ case GL_NORMAL_ARRAY_POINTER:
+ case GL_COLOR_ARRAY_POINTER:
+ case GL_INDEX_ARRAY_POINTER:
+ case GL_EDGE_FLAG_ARRAY_POINTER:
+ __glXGetArrayPointer( state, pname - GL_VERTEX_ARRAY_POINTER
+ + GL_VERTEX_ARRAY,
+ 0, params );
+ return;
+ case GL_TEXTURE_COORD_ARRAY_POINTER:
+ __glXGetArrayPointer( state, GL_TEXTURE_COORD_ARRAY,
+ __glXGetActiveTextureUnit( state ), params );
+ return;
+ case GL_SECONDARY_COLOR_ARRAY_POINTER:
+ case GL_FOG_COORD_ARRAY_POINTER:
+ __glXGetArrayPointer( state, pname - GL_FOG_COORD_ARRAY_POINTER
+ + GL_FOG_COORD_ARRAY,
+ 0, params );
+ return;
+ case GL_FEEDBACK_BUFFER_POINTER:
+ *params = (void *)gc->feedbackBuf;
+ return;
+ case GL_SELECTION_BUFFER_POINTER:
+ *params = (void *)gc->selectBuf;
+ return;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+}
+
diff --git a/nx-X11/extras/Mesa/src/glx/x11/singlepix.c b/nx-X11/extras/Mesa/src/glx/x11/singlepix.c
new file mode 100644
index 000000000..4a10083b8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/singlepix.c
@@ -0,0 +1,105 @@
+/* $XFree86: xc/lib/GL/glx/singlepix.c,v 1.3 2001/03/21 16:04:39 dawes Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#include "packsingle.h"
+#include "indirect.h"
+
+void __indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type,
+ GLvoid *row, GLvoid *column, GLvoid *span)
+{
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ const __GLXattribute * state;
+ xGLXGetSeparableFilterReply reply;
+ GLubyte *rowBuf, *colBuf;
+
+ if (!dpy) return;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ state = gc->client_state_private;
+
+ /* Send request */
+ __GLX_SINGLE_BEGIN(X_GLsop_GetSeparableFilter, __GLX_PAD(13));
+ __GLX_SINGLE_PUT_LONG(0,target);
+ __GLX_SINGLE_PUT_LONG(4,format);
+ __GLX_SINGLE_PUT_LONG(8,type);
+ __GLX_SINGLE_PUT_CHAR(12,state->storePack.swapEndian);
+ __GLX_SINGLE_READ_XREPLY();
+ compsize = reply.length << 2;
+
+ if (compsize != 0) {
+ GLint width, height;
+ GLint widthsize, heightsize;
+
+ width = reply.width;
+ height = reply.height;
+
+ widthsize = __glImageSize(width,1,1,format, type, 0);
+ heightsize = __glImageSize(height,1,1,format, type, 0);
+
+ /* Allocate a holding buffer to transform the data from */
+ rowBuf = (GLubyte*) Xmalloc(widthsize);
+ if (!rowBuf) {
+ /* Throw data away */
+ _XEatData(dpy, compsize);
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return;
+ } else {
+ __GLX_SINGLE_GET_CHAR_ARRAY(((char*)rowBuf),widthsize);
+ __glEmptyImage(gc, 1, width, 1, 1, format, type, rowBuf, row);
+ Xfree((char*) rowBuf);
+ }
+ colBuf = (GLubyte*) Xmalloc(heightsize);
+ if (!colBuf) {
+ /* Throw data away */
+ _XEatData(dpy, compsize - __GLX_PAD(widthsize));
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return;
+ } else {
+ __GLX_SINGLE_GET_CHAR_ARRAY(((char*)colBuf),heightsize);
+ __glEmptyImage(gc, 1, height, 1, 1, format, type, colBuf, column);
+ Xfree((char*) colBuf);
+ }
+ } else {
+ /*
+ ** don't modify user's buffer.
+ */
+ }
+ __GLX_SINGLE_END();
+
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/vertarr.c b/nx-X11/extras/Mesa/src/glx/x11/vertarr.c
new file mode 100644
index 000000000..483a166ea
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/vertarr.c
@@ -0,0 +1,203 @@
+/* $XFree86: xc/lib/GL/glx/vertarr.c,v 1.4 2001/03/25 05:32:00 tsi Exp $ */
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: The application programming interfaces
+** established by SGI in conjunction with the Original Code are The
+** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
+** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
+** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
+** Window System(R) (Version 1.3), released October 19, 1998. This software
+** was created using the OpenGL(R) version 1.2.1 Sample Implementation
+** published by SGI, but has not been independently verified as being
+** compliant with the OpenGL(R) version 1.2.1 Specification.
+**
+*/
+
+#include "glxclient.h"
+#include "indirect.h"
+#include "indirect_vertex_array.h"
+
+
+/*****************************************************************************/
+
+/**
+ * \name Vertex array pointer bridge functions
+ *
+ * When EXT_vertex_array was moved into the core GL spec, the \c count
+ * parameter was lost. This libGL really only wants to implement the GL 1.1
+ * version, but we need to support applications that were written to the old
+ * interface. These bridge functions are part of the glue that makes this
+ * happen.
+ */
+/*@{*/
+void __indirect_glColorPointerEXT(GLint size, GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid * pointer )
+{
+ (void) count; __indirect_glColorPointer( size, type, stride, pointer );
+}
+
+void __indirect_glEdgeFlagPointerEXT(GLsizei stride,
+ GLsizei count, const GLboolean * pointer )
+{
+ (void) count; __indirect_glEdgeFlagPointer( stride, pointer );
+}
+
+void __indirect_glIndexPointerEXT(GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid * pointer )
+{
+ (void) count; __indirect_glIndexPointer( type, stride, pointer );
+}
+
+void __indirect_glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
+ const GLvoid * pointer )
+{
+ (void) count; __indirect_glNormalPointer( type, stride, pointer );
+}
+
+void __indirect_glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid * pointer )
+{
+ (void) count; __indirect_glTexCoordPointer( size, type, stride, pointer );
+}
+
+void __indirect_glVertexPointerEXT(GLint size, GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid * pointer )
+{
+ (void) count; __indirect_glVertexPointer( size, type, stride, pointer );
+}
+/*@}*/
+
+/*****************************************************************************/
+
+void __indirect_glInterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
+{
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+
+#define NONE {0, 0, 0}
+#define F(x) {GL_FLOAT, x, x * sizeof(GLfloat)}
+#define UB4 {GL_UNSIGNED_BYTE, 4, 4 * sizeof(GLubyte)}
+
+ /* Each row in this array describes the elements of a particular
+ * interleaved array mode. Each column describes, in the order in which
+ * they appear in the interleaved arrays, one of the four possible types
+ * of vertex data that can appear in an interleaved array.
+ */
+ struct {
+ /**
+ * The enum describing the GL type, as would be passed to the
+ * appropriate gl*Pointer function.
+ */
+ GLushort type;
+
+ /**
+ * Number of elements in the subarray, as would be passed (as the
+ * \c size parameter) to the appropriate gl*Pointer function.
+ */
+ GLubyte count;
+
+ /**
+ * True size of a single element in the subarray, as would be passed
+ * (as the \c stride parameter) to the appropriate gl*Pointer
+ * function.
+ */
+ GLubyte size;
+ }
+ static const modes[14][4] = {
+ /* texture color normal vertex */
+ {NONE, NONE, NONE, F(2)}, /* GL_V2F */
+ {NONE, NONE, NONE, F(3)}, /* GL_V3F */
+ {NONE, UB4, NONE, F(2)}, /* GL_C4UB_V2F */
+ {NONE, UB4, NONE, F(3)}, /* GL_C4UB_V3F */
+ {NONE, F(3), NONE, F(3)}, /* GL_C3F_V3F */
+ {NONE, NONE, F(3), F(3)}, /* GL_N3F_V3F */
+ {NONE, F(4), F(3), F(3)}, /* GL_C4F_N3F_V3F */
+ {F(2), NONE, NONE, F(3)}, /* GL_T2F_V3F */
+ {F(4), NONE, NONE, F(4)}, /* GL_T4F_V4F */
+ {F(2), UB4, NONE, F(3)}, /* GL_T2F_C4UB_V3F */
+ {F(2), F(3), NONE, F(3)}, /* GL_T2F_C3F_V3F */
+ {F(2), NONE, F(3), F(3)}, /* GL_T2F_N3F_V3F */
+ {F(2), F(4), F(3), F(3)}, /* GL_T2F_C4F_N3F_V3F */
+ {F(4), F(4), F(3), F(4)}, /* GL_T4F_C4F_N3F_V4F */
+ };
+#undef NONE
+#undef F
+#undef UB4
+
+ GLint trueStride, size;
+ int offsets[4];
+ unsigned i;
+ const int idx = format - GL_V2F;
+
+
+ /* All valid formats are on the range [GL_V2F, GL_V2F+0x0D]. Since idx
+ * is just the format biased by -GL_V2F, all valid idx values are on the
+ * range [0, 0x0D].
+ */
+ if ( (idx < 0) || (idx > 0x0D) ) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ if ( stride < 0 ) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+
+ /* If the 'count' for a subarray is non-zero, then the offset of its
+ * first element is at the currently accumulated 'size'.
+ */
+ size = 0;
+ for ( i = 0 ; i < 4 ; i++ ) {
+ offsets[i] = (modes[idx][i].count != 0) ? size : -1;
+ size += modes[idx][i].size;
+ }
+
+ trueStride = (stride == 0) ? size : stride;
+
+ __glXArrayDisableAll( state );
+
+ if ( offsets[0] >= 0 ) {
+ __indirect_glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ __indirect_glTexCoordPointer( modes[idx][0].count, GL_FLOAT,
+ trueStride,
+ (const char *) pointer );
+ }
+ if ( offsets[1] >= 0 ) {
+ __indirect_glEnableClientState(GL_COLOR_ARRAY);
+ __indirect_glColorPointer( modes[idx][1].count, modes[idx][1].type,
+ trueStride,
+ (const char *) pointer + offsets[1] );
+ }
+ if ( offsets[2] >= 0 ) {
+ __indirect_glEnableClientState(GL_NORMAL_ARRAY);
+ __indirect_glNormalPointer( GL_FLOAT, trueStride,
+ (const char *)pointer + offsets[2] );
+ }
+ __indirect_glEnableClientState(GL_VERTEX_ARRAY);
+ __indirect_glVertexPointer( modes[idx][3].count, GL_FLOAT,
+ trueStride,
+ (const char *)pointer + offsets[3] );
+}
diff --git a/nx-X11/extras/Mesa/src/glx/x11/xf86dri.h b/nx-X11/extras/Mesa/src/glx/x11/xf86dri.h
new file mode 100644
index 000000000..0a2bb2497
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/xf86dri.h
@@ -0,0 +1,122 @@
+/* $XFree86: xc/lib/GL/dri/xf86dri.h,v 1.8 2002/10/30 12:51:25 alanh Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+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.
+
+**************************************************************************/
+
+/**
+ * \file xf86dri.h
+ * Protocol numbers and function prototypes for DRI X protocol.
+ *
+ * \author Kevin E. Martin <martin@valinux.com>
+ * \author Jens Owen <jens@tungstengraphics.com>
+ * \author Rickard E. (Rik) Faith <faith@valinux.com>
+ */
+
+#ifndef _XF86DRI_H_
+#define _XF86DRI_H_
+
+#include <X11/Xfuncproto.h>
+#include <xf86drm.h>
+
+#define X_XF86DRIQueryVersion 0
+#define X_XF86DRIQueryDirectRenderingCapable 1
+#define X_XF86DRIOpenConnection 2
+#define X_XF86DRICloseConnection 3
+#define X_XF86DRIGetClientDriverName 4
+#define X_XF86DRICreateContext 5
+#define X_XF86DRIDestroyContext 6
+#define X_XF86DRICreateDrawable 7
+#define X_XF86DRIDestroyDrawable 8
+#define X_XF86DRIGetDrawableInfo 9
+#define X_XF86DRIGetDeviceInfo 10
+#define X_XF86DRIAuthConnection 11
+#define X_XF86DRIOpenFullScreen 12 /* Deprecated */
+#define X_XF86DRICloseFullScreen 13 /* Deprecated */
+
+#define XF86DRINumberEvents 0
+
+#define XF86DRIClientNotLocal 0
+#define XF86DRIOperationNotSupported 1
+#define XF86DRINumberErrors (XF86DRIOperationNotSupported + 1)
+
+#ifndef _XF86DRI_SERVER_
+
+#include <GL/internal/dri_interface.h>
+
+_XFUNCPROTOBEGIN
+
+Bool XF86DRIQueryExtension( Display *dpy, int *event_base, int *error_base );
+
+Bool XF86DRIQueryVersion( Display *dpy, int *majorVersion, int *minorVersion,
+ int *patchVersion );
+
+Bool XF86DRIQueryDirectRenderingCapable( Display *dpy, int screen,
+ Bool *isCapable );
+
+Bool XF86DRIOpenConnection( Display *dpy, int screen, drm_handle_t *hSAREA,
+ char **busIDString );
+
+Bool XF86DRIAuthConnection( Display *dpy, int screen, drm_magic_t magic );
+
+Bool XF86DRICloseConnection( Display *dpy, int screen );
+
+Bool XF86DRIGetClientDriverName( Display *dpy, int screen,
+ int *ddxDriverMajorVersion, int *ddxDriverMinorVersion,
+ int *ddxDriverPatchVersion, char **clientDriverName );
+
+Bool XF86DRICreateContext( Display *dpy, int screen, Visual *visual,
+ XID *ptr_to_returned_context_id, drm_context_t *hHWContext );
+
+Bool XF86DRICreateContextWithConfig( Display *dpy, int screen, int configID,
+ XID *ptr_to_returned_context_id, drm_context_t *hHWContext );
+
+extern GLboolean XF86DRIDestroyContext( __DRInativeDisplay *dpy, int screen,
+ __DRIid context_id );
+
+extern GLboolean XF86DRICreateDrawable( __DRInativeDisplay *dpy, int screen,
+ __DRIid drawable, drm_drawable_t *hHWDrawable );
+
+extern GLboolean XF86DRIDestroyDrawable( __DRInativeDisplay *dpy, int screen,
+ __DRIid drawable);
+
+Bool XF86DRIGetDrawableInfo( Display *dpy, int screen, Drawable drawable,
+ unsigned int *index, unsigned int *stamp,
+ int *X, int *Y, int *W, int *H,
+ int *numClipRects, drm_clip_rect_t ** pClipRects,
+ int *backX, int *backY,
+ int *numBackClipRects, drm_clip_rect_t **pBackClipRects );
+
+Bool XF86DRIGetDeviceInfo( Display *dpy, int screen,
+ drm_handle_t *hFrameBuffer, int *fbOrigin, int *fbSize,
+ int *fbStride, int *devPrivateSize, void **pDevPrivate );
+
+_XFUNCPROTOEND
+
+#endif /* _XF86DRI_SERVER_ */
+
+#endif /* _XF86DRI_H_ */
+
diff --git a/nx-X11/extras/Mesa/src/glx/x11/xf86dristr.h b/nx-X11/extras/Mesa/src/glx/x11/xf86dristr.h
new file mode 100644
index 000000000..ac05b183b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/xf86dristr.h
@@ -0,0 +1,343 @@
+/* $XFree86: xc/lib/GL/dri/xf86dristr.h,v 1.10 2002/10/30 12:51:25 alanh Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+Copyright 2000 VA Linux Systems, Inc.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Kevin E. Martin <martin@valinux.com>
+ * Jens Owen <jens@tungstengraphics.com>
+ * Rickard E. (Rik) Fiath <faith@valinux.com>
+ *
+ */
+
+#ifndef _XF86DRISTR_H_
+#define _XF86DRISTR_H_
+
+#include "xf86dri.h"
+
+#define XF86DRINAME "XFree86-DRI"
+
+/* The DRI version number. This was originally set to be the same of the
+ * XFree86 version number. However, this version is really indepedent of
+ * the XFree86 version.
+ *
+ * Version History:
+ * 4.0.0: Original
+ * 4.0.1: Patch to bump clipstamp when windows are destroyed, 28 May 02
+ * 4.1.0: Add transition from single to multi in DRMInfo rec, 24 Jun 02
+ */
+#define XF86DRI_MAJOR_VERSION 4
+#define XF86DRI_MINOR_VERSION 1
+#define XF86DRI_PATCH_VERSION 0
+
+typedef struct _XF86DRIQueryVersion {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIQueryVersion */
+ CARD16 length B16;
+} xXF86DRIQueryVersionReq;
+#define sz_xXF86DRIQueryVersionReq 4
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD16 majorVersion B16; /* major version of DRI protocol */
+ CARD16 minorVersion B16; /* minor version of DRI protocol */
+ CARD32 patchVersion B32; /* patch version of DRI protocol */
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xXF86DRIQueryVersionReply;
+#define sz_xXF86DRIQueryVersionReply 32
+
+typedef struct _XF86DRIQueryDirectRenderingCapable {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xXF86DRIQueryDirectRenderingCapableReq;
+#define sz_xXF86DRIQueryDirectRenderingCapableReq 8
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ BOOL isCapable;
+ BOOL pad2;
+ BOOL pad3;
+ BOOL pad4;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+ CARD32 pad7 B32;
+ CARD32 pad8 B32;
+ CARD32 pad9 B32;
+} xXF86DRIQueryDirectRenderingCapableReply;
+#define sz_xXF86DRIQueryDirectRenderingCapableReply 32
+
+typedef struct _XF86DRIOpenConnection {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIOpenConnection */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xXF86DRIOpenConnectionReq;
+#define sz_xXF86DRIOpenConnectionReq 8
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 hSAREALow B32;
+ CARD32 hSAREAHigh B32;
+ CARD32 busIdStringLength B32;
+ CARD32 pad6 B32;
+ CARD32 pad7 B32;
+ CARD32 pad8 B32;
+} xXF86DRIOpenConnectionReply;
+#define sz_xXF86DRIOpenConnectionReply 32
+
+typedef struct _XF86DRIAuthConnection {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICloseConnection */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 magic B32;
+} 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 */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xXF86DRICloseConnectionReq;
+#define sz_xXF86DRICloseConnectionReq 8
+
+typedef struct _XF86DRIGetClientDriverName {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIGetClientDriverName */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xXF86DRIGetClientDriverNameReq;
+#define sz_xXF86DRIGetClientDriverNameReq 8
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 ddxDriverMajorVersion B32;
+ CARD32 ddxDriverMinorVersion B32;
+ CARD32 ddxDriverPatchVersion B32;
+ CARD32 clientDriverNameLength B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xXF86DRIGetClientDriverNameReply;
+#define sz_xXF86DRIGetClientDriverNameReply 32
+
+typedef struct _XF86DRICreateContext {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICreateContext */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 visual B32;
+ CARD32 context B32;
+} xXF86DRICreateContextReq;
+#define sz_xXF86DRICreateContextReq 16
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 hHWContext B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xXF86DRICreateContextReply;
+#define sz_xXF86DRICreateContextReply 32
+
+typedef struct _XF86DRIDestroyContext {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIDestroyContext */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 context B32;
+} xXF86DRIDestroyContextReq;
+#define sz_xXF86DRIDestroyContextReq 12
+
+typedef struct _XF86DRICreateDrawable {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICreateDrawable */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+} xXF86DRICreateDrawableReq;
+#define sz_xXF86DRICreateDrawableReq 12
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 hHWDrawable B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xXF86DRICreateDrawableReply;
+#define sz_xXF86DRICreateDrawableReply 32
+
+typedef struct _XF86DRIDestroyDrawable {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIDestroyDrawable */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+} xXF86DRIDestroyDrawableReq;
+#define sz_xXF86DRIDestroyDrawableReq 12
+
+typedef struct _XF86DRIGetDrawableInfo {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIGetDrawableInfo */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+} xXF86DRIGetDrawableInfoReq;
+#define sz_xXF86DRIGetDrawableInfoReq 12
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 drawableTableIndex B32;
+ CARD32 drawableTableStamp B32;
+ INT16 drawableX B16;
+ INT16 drawableY B16;
+ INT16 drawableWidth B16;
+ INT16 drawableHeight B16;
+ CARD32 numClipRects B32;
+ INT16 backX B16;
+ INT16 backY B16;
+ CARD32 numBackClipRects B32;
+} xXF86DRIGetDrawableInfoReply;
+
+#define sz_xXF86DRIGetDrawableInfoReply 36
+
+
+typedef struct _XF86DRIGetDeviceInfo {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIGetDeviceInfo */
+ CARD16 length B16;
+ CARD32 screen B32;
+} xXF86DRIGetDeviceInfoReq;
+#define sz_xXF86DRIGetDeviceInfoReq 8
+
+typedef struct {
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 hFrameBufferLow B32;
+ CARD32 hFrameBufferHigh B32;
+ CARD32 framebufferOrigin B32;
+ CARD32 framebufferSize B32;
+ CARD32 framebufferStride B32;
+ CARD32 devPrivateSize B32;
+} xXF86DRIGetDeviceInfoReply;
+#define sz_xXF86DRIGetDeviceInfoReply 32
+
+typedef struct _XF86DRIOpenFullScreen {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIOpenFullScreen */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+} xXF86DRIOpenFullScreenReq;
+#define sz_xXF86DRIOpenFullScreenReq 12
+
+typedef struct {
+ BYTE type;
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 isFullScreen B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+} xXF86DRIOpenFullScreenReply;
+#define sz_xXF86DRIOpenFullScreenReply 32
+
+typedef struct _XF86DRICloseFullScreen {
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICloseFullScreen */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
+} xXF86DRICloseFullScreenReq;
+#define sz_xXF86DRICloseFullScreenReq 12
+
+typedef struct {
+ BYTE type;
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+ CARD32 pad7 B32;
+} xXF86DRICloseFullScreenReply;
+#define sz_xXF86DRICloseFullScreenReply 32
+
+
+#endif /* _XF86DRISTR_H_ */
diff --git a/nx-X11/extras/Mesa/src/glx/x11/xfont.c b/nx-X11/extras/Mesa/src/glx/x11/xfont.c
new file mode 100644
index 000000000..5f23a7962
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/glx/x11/xfont.c
@@ -0,0 +1,377 @@
+/* $XFree86: xc/lib/GL/glx/xfont.c,v 1.6 2001/05/02 15:06:02 dawes Exp $ */
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.1
+ *
+ * Copyright (C) 1999 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.
+ */
+
+
+/* xfonts.c -- glXUseXFont() for Mesa written by
+ * Copyright (C) 1995 Thorsten.Ohl @ Physik.TH-Darmstadt.de
+ */
+
+/*
+ This was take from Mesa and modified to work in the real GLX structure.
+ It provides a fully client side implementation of glXUseXFont and is
+ called by that routine when direct rendering is enabled.
+*/
+
+
+#include "glxclient.h"
+
+/* Some debugging info. */
+
+#ifdef DEBUG
+#undef _R
+#undef _G
+#undef _B
+#include <ctype.h>
+
+int debug_xfonts = 0;
+
+static void
+dump_char_struct (XCharStruct *ch, char *prefix)
+{
+ printf ("%slbearing = %d, rbearing = %d, width = %d\n",
+ prefix, ch->lbearing, ch->rbearing, ch->width);
+ printf ("%sascent = %d, descent = %d, attributes = %u\n",
+ prefix, ch->ascent, ch->descent, (unsigned int) ch->attributes);
+}
+
+static void
+dump_font_struct (XFontStruct *font)
+{
+ printf ("ascent = %d, descent = %d\n", font->ascent, font->descent);
+ printf ("char_or_byte2 = (%u,%u)\n",
+ font->min_char_or_byte2, font->max_char_or_byte2);
+ printf ("byte1 = (%u,%u)\n", font->min_byte1, font->max_byte1);
+ printf ("all_chars_exist = %s\n", font->all_chars_exist ? "True" :
+"False");
+ printf ("default_char = %c (\\%03o)\n",
+ (char) (isprint (font->default_char) ? font->default_char : ' '),
+ font->default_char);
+ dump_char_struct (&font->min_bounds, "min> ");
+ dump_char_struct (&font->max_bounds, "max> ");
+#if 0
+ for (c = font->min_char_or_byte2; c <= font->max_char_or_byte2; c++)
+ {
+ char prefix[8];
+ sprintf (prefix, "%d> ", c);
+ dump_char_struct (&font->per_char[c], prefix);
+ }
+#endif
+}
+
+static void
+dump_bitmap (unsigned int width, unsigned int height, GLubyte *bitmap)
+{
+ unsigned int x, y;
+
+ printf (" ");
+ for (x = 0; x < 8*width; x++)
+ printf ("%o", 7 - (x % 8));
+ putchar ('\n');
+ for (y = 0; y < height; y++)
+ {
+ printf ("%3o:", y);
+ for (x = 0; x < 8*width; x++)
+ putchar ((bitmap[width*(height - y - 1) + x/8] & (1 << (7 - (x %
+8))))
+ ? '*' : '.');
+ printf (" ");
+ for (x = 0; x < width; x++)
+ printf ("0x%02x, ", bitmap[width*(height - y - 1) + x]);
+ putchar ('\n');
+ }
+}
+#endif /* DEBUG */
+
+
+/* Implementation. */
+
+/* Fill a BITMAP with a character C from thew current font
+ in the graphics context GC. WIDTH is the width in bytes
+ and HEIGHT is the height in bits.
+
+ Note that the generated bitmaps must be used with
+
+ glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE);
+ glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE);
+ glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
+ glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
+ glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
+ glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+
+ Possible optimizations:
+
+ * use only one reusable pixmap with the maximum dimensions.
+ * draw the entire font into a single pixmap (careful with
+ proportional fonts!).
+*/
+
+
+/*
+ * Generate OpenGL-compatible bitmap.
+ */
+static void
+fill_bitmap (Display *dpy, Window win, GC gc,
+ unsigned int width, unsigned int height,
+ int x0, int y0, unsigned int c, GLubyte *bitmap)
+{
+ XImage *image;
+ unsigned int x, y;
+ Pixmap pixmap;
+ XChar2b char2b;
+
+ pixmap = XCreatePixmap (dpy, win, 8*width, height, 1);
+ XSetForeground(dpy, gc, 0);
+ XFillRectangle (dpy, pixmap, gc, 0, 0, 8*width, height);
+ XSetForeground(dpy, gc, 1);
+
+ char2b.byte1 = (c >> 8) & 0xff;
+ char2b.byte2 = (c & 0xff);
+
+ XDrawString16 (dpy, pixmap, gc, x0, y0, &char2b, 1);
+
+ image = XGetImage (dpy, pixmap, 0, 0, 8*width, height, 1, XYPixmap);
+ if (image) {
+ /* Fill the bitmap (X11 and OpenGL are upside down wrt each other). */
+ for (y = 0; y < height; y++)
+ for (x = 0; x < 8*width; x++)
+ if (XGetPixel (image, x, y))
+ bitmap[width*(height - y - 1) + x/8] |= (1 << (7 - (x % 8)));
+ XDestroyImage (image);
+ }
+
+ XFreePixmap (dpy, pixmap);
+}
+
+/*
+ * determine if a given glyph is valid and return the
+ * corresponding XCharStruct.
+ */
+static XCharStruct *isvalid(XFontStruct *fs, int which)
+{
+ unsigned int rows,pages;
+ int byte1 = 0, byte2 = 0;
+ int i,valid = 1;
+
+ rows = fs->max_byte1 - fs->min_byte1 + 1;
+ pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
+
+ if (rows == 1) {
+ /* "linear" fonts */
+ if ((fs->min_char_or_byte2 > which) ||
+ (fs->max_char_or_byte2 < which)) valid = 0;
+ } else {
+ /* "matrix" fonts */
+ byte2 = which & 0xff;
+ byte1 = which >> 8;
+ if ((fs->min_char_or_byte2 > byte2) ||
+ (fs->max_char_or_byte2 < byte2) ||
+ (fs->min_byte1 > byte1) ||
+ (fs->max_byte1 < byte1)) valid = 0;
+ }
+
+ if (valid) {
+ if (fs->per_char) {
+ if (rows == 1) {
+ /* "linear" fonts */
+ return(fs->per_char + (which-fs->min_char_or_byte2) );
+ } else {
+ /* "matrix" fonts */
+ i = ((byte1 - fs->min_byte1) * pages) +
+ (byte2 - fs->min_char_or_byte2);
+ return(fs->per_char + i);
+ }
+ } else {
+ return(&fs->min_bounds);
+ }
+ }
+ return(NULL);
+}
+
+
+void DRI_glXUseXFont( Font font, int first, int count, int listbase )
+{
+ GLXContext CC;
+ Display *dpy;
+ Window win;
+ Pixmap pixmap;
+ GC gc;
+ XGCValues values;
+ unsigned long valuemask;
+ XFontStruct *fs;
+
+ GLint swapbytes, lsbfirst, rowlength;
+ GLint skiprows, skippixels, alignment;
+
+ unsigned int max_width, max_height, max_bm_width, max_bm_height;
+ GLubyte *bm;
+
+ int i;
+
+ CC = __glXGetCurrentContext();
+ dpy = CC->currentDpy;
+ win = CC->currentDrawable;
+
+ fs = XQueryFont (dpy, font);
+ if (!fs)
+ {
+ __glXSetError(CC, GL_INVALID_VALUE);
+ return;
+ }
+
+ /* Allocate a bitmap that can fit all characters. */
+ max_width = fs->max_bounds.rbearing - fs->min_bounds.lbearing;
+ max_height = fs->max_bounds.ascent + fs->max_bounds.descent;
+ max_bm_width = (max_width + 7) / 8;
+ max_bm_height = max_height;
+
+ bm = (GLubyte *) Xmalloc((max_bm_width * max_bm_height) * sizeof
+(GLubyte));
+ if (!bm) {
+ XFreeFontInfo( NULL, fs, 1 );
+ __glXSetError(CC, GL_OUT_OF_MEMORY);
+ return;
+ }
+
+#if 0
+ /* get the page info */
+ pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
+ firstchar = (fs->min_byte1 << 8) + fs->min_char_or_byte2;
+ lastchar = (fs->max_byte1 << 8) + fs->max_char_or_byte2;
+ rows = fs->max_byte1 - fs->min_byte1 + 1;
+ unsigned int first_char, last_char, pages, rows;
+#endif
+
+ /* Save the current packing mode for bitmaps. */
+ glGetIntegerv (GL_UNPACK_SWAP_BYTES, &swapbytes);
+ glGetIntegerv (GL_UNPACK_LSB_FIRST, &lsbfirst);
+ glGetIntegerv (GL_UNPACK_ROW_LENGTH, &rowlength);
+ glGetIntegerv (GL_UNPACK_SKIP_ROWS, &skiprows);
+ glGetIntegerv (GL_UNPACK_SKIP_PIXELS, &skippixels);
+ glGetIntegerv (GL_UNPACK_ALIGNMENT, &alignment);
+
+ /* Enforce a standard packing mode which is compatible with
+ fill_bitmap() from above. This is actually the default mode,
+ except for the (non)alignment. */
+ glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE);
+ glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE);
+ glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
+ glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
+ glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
+ glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+
+ pixmap = XCreatePixmap (dpy, win, 10, 10, 1);
+ values.foreground = BlackPixel (dpy, DefaultScreen (dpy));
+ values.background = WhitePixel (dpy, DefaultScreen (dpy));
+ values.font = fs->fid;
+ valuemask = GCForeground | GCBackground | GCFont;
+ gc = XCreateGC (dpy, pixmap, valuemask, &values);
+ XFreePixmap (dpy, pixmap);
+
+#ifdef DEBUG
+ if (debug_xfonts)
+ dump_font_struct (fs);
+#endif
+
+ for (i = 0; i < count; i++)
+ {
+ unsigned int width, height, bm_width, bm_height;
+ GLfloat x0, y0, dx, dy;
+ XCharStruct *ch;
+ int x, y;
+ unsigned int c = first + i;
+ int list = listbase + i;
+ int valid;
+
+ /* check on index validity and get the bounds */
+ ch = isvalid(fs, c);
+ if (!ch) {
+ ch = &fs->max_bounds;
+ valid = 0;
+ } else {
+ valid = 1;
+ }
+
+#ifdef DEBUG
+ if (debug_xfonts) {
+ char s[7];
+ sprintf (s, isprint (c) ? "%c> " : "\\%03o> ", c);
+ dump_char_struct (ch, s);
+ }
+#endif
+
+ /* glBitmap()' parameters:
+ straight from the glXUseXFont(3) manpage. */
+ width = ch->rbearing - ch->lbearing;
+ height = ch->ascent + ch->descent;
+ x0 = - ch->lbearing;
+ y0 = ch->descent - 1;
+ dx = ch->width;
+ dy = 0;
+
+ /* X11's starting point. */
+ x = - ch->lbearing;
+ y = ch->ascent;
+
+ /* Round the width to a multiple of eight. We will use this also
+ for the pixmap for capturing the X11 font. This is slightly
+ inefficient, but it makes the OpenGL part real easy. */
+ bm_width = (width + 7) / 8;
+ bm_height = height;
+
+ glNewList (list, GL_COMPILE);
+ if (valid && (bm_width > 0) && (bm_height > 0)) {
+
+ memset (bm, '\0', bm_width * bm_height);
+ fill_bitmap (dpy, win, gc, bm_width, bm_height, x, y, c, bm);
+
+ glBitmap (width, height, x0, y0, dx, dy, bm);
+#ifdef DEBUG
+ if (debug_xfonts) {
+ printf ("width/height = %u/%u\n", width, height);
+ printf ("bm_width/bm_height = %u/%u\n", bm_width,
+bm_height);
+ dump_bitmap (bm_width, bm_height, bm);
+ }
+#endif
+ } else {
+ glBitmap (0, 0, 0.0, 0.0, dx, dy, NULL);
+ }
+ glEndList ();
+ }
+
+ Xfree(bm);
+ XFreeFontInfo( NULL, fs, 1 );
+ XFreeGC (dpy, gc);
+
+ /* Restore saved packing modes. */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
+}
+
+/* The End. */
diff --git a/nx-X11/extras/Mesa/src/mesa/Makefile b/nx-X11/extras/Mesa/src/mesa/Makefile
new file mode 100644
index 000000000..b6c0b85f4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/Makefile
@@ -0,0 +1,230 @@
+# src/mesa/Makefile
+
+TOP = ../..
+include $(TOP)/configs/current
+
+include sources
+
+
+GL_MAJOR = 1
+GL_MINOR = 5
+GL_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY)
+
+
+.SUFFIXES : .cpp
+
+.c.o:
+ $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
+
+.cpp.o:
+ $(CXX) -c $(INCLUDE_DIRS) $(CXXFLAGS) $< -o $@
+
+.S.o:
+ $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $< -o $@
+
+
+# Figure out what to make here
+default:
+ @if [ "${DRIVER_DIRS}" = "dri" ] ; then \
+ $(MAKE) linux-solo ; \
+ elif [ "${DRIVER_DIRS}" = "osmesa" ] ; then \
+ $(MAKE) osmesa-only ; \
+ elif [ "$(DRIVER_DIRS)" = "beos" ]; then \
+ $(MAKE) beos ; \
+ elif [ "$(DRIVER_DIRS)" = "directfb" ]; then \
+ $(MAKE) directfb; \
+ else \
+ $(MAKE) stand-alone ; \
+ fi
+
+# BeOS driver target
+beos: depend subdirs mesa.a
+ cd drivers/beos; $(MAKE)
+
+
+install: default
+ @if [ "${DRIVER_DIRS}" = "dri" ] ; then \
+ cd drivers/dri ; $(MAKE) install ; \
+ fi
+
+######################################################################
+# Linux solo DRI drivers
+
+SOLO_C_SOURCES = \
+ $(MAIN_SOURCES) \
+ $(MATH_SOURCES) \
+ $(ARRAY_CACHE_SOURCES) \
+ $(TNL_SOURCES) \
+ $(SWRAST_SOURCES) \
+ $(SWRAST_SETUP_SOURCES) \
+ $(SHADER_SOURCES) \
+ $(SLANG_SOURCES) \
+ $(ASM_C_SOURCES)
+
+SOLO_OBJECTS = $(SOLO_C_SOURCES:.c=.o) \
+ $(ASM_SOURCES:.S=.o)
+
+linux-solo: depend subdirs mesa.a drivers-dri
+
+# Make archive of core object files
+mesa.a: $(SOLO_OBJECTS)
+ rm -f $@
+ ar rcv $@ $(SOLO_OBJECTS)
+ ranlib $@
+ @if [ "${CONFIG_NAME}" = "beos" ] ; then \
+ mimeset -f "$@" ; \
+ fi
+
+# note: cannot use the name of the directory ("drivers") as the
+# target, otherwise make will look & see that the "drivers" directory
+# already exists, so not try to rebuild it...
+drivers-dri:
+ cd drivers/dri ; $(MAKE)
+
+
+
+#####################################################################
+# Stand-alone Mesa libGL, no built-in drivers (DirectFB)
+
+LIBGL_CORE_SOURCES = \
+ $(CORE_SOURCES) \
+ $(ASM_SOURCES)
+
+LIBGL_CORE_OBJECTS = \
+ $(CORE_OBJECTS) \
+ $(ASM_SOURCES:.S=.o)
+
+# Make libGL from core object files
+libgl-core: $(LIBGL_CORE_OBJECTS)
+ @ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
+ -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
+ -install $(LIB_DIR) $(MKLIB_OPTIONS) $(LIBGL_CORE_OBJECTS) $(GL_LIB_DEPS)
+
+# DirectFB driver target
+directfb: depend subdirs libgl-core
+ cd drivers/directfb; $(MAKE)
+
+
+
+######################################################################
+# Stand-alone Mesa libGL and libOSMesa
+
+STAND_ALONE_DRIVER_SOURCES = \
+ $(COMMON_DRIVER_SOURCES) \
+ $(X11_DRIVER_SOURCES) \
+ $(GLIDE_DRIVER_SOURCES) \
+ $(SVGA_DRIVER_SOURCES) \
+ $(FBDEV_DRIVER_SOURCES)
+
+STAND_ALONE_SOURCES = \
+ $(CORE_SOURCES) \
+ $(ASM_SOURCES) \
+ $(STAND_ALONE_DRIVER_SOURCES)
+
+# ASM_SOURCES is defined in the config file
+ASM_OBJECTS = $(ASM_SOURCES:.S=.o)
+
+STAND_ALONE_DRIVER_OBJECTS = $(STAND_ALONE_DRIVER_SOURCES:.c=.o)
+
+STAND_ALONE_OBJECTS = \
+ $(CORE_OBJECTS) \
+ $(ASM_OBJECTS) \
+ $(STAND_ALONE_DRIVER_OBJECTS)
+
+# For libOSMesa16 or libOSMesa32 we link _all_ the objects into the library,
+# not just the osmesa.o object (i.e. we don't have a libGL).
+OSMESA16_OBJECTS = \
+ $(CORE_OBJECTS) \
+ $(ASM_OBJECTS) \
+ $(COMMON_DRIVER_OBJECTS) \
+ $(OSMESA_DRIVER_OBJECTS)
+
+
+stand-alone: depend subdirs $(LIB_DIR)/$(GL_LIB_NAME) $(LIB_DIR)/$(OSMESA_LIB_NAME)
+
+osmesa-only: depend subdirs $(LIB_DIR)/$(OSMESA_LIB_NAME)
+
+subdirs:
+ @ (cd x86 ; $(MAKE))
+ @ (cd x86-64 ; $(MAKE))
+
+# Make the GL library
+$(LIB_DIR)/$(GL_LIB_NAME): $(STAND_ALONE_OBJECTS)
+ @ $(TOP)/bin/mklib -o $(GL_LIB) -linker '$(CC)' \
+ -major $(GL_MAJOR) -minor $(GL_MINOR) -patch $(GL_TINY) \
+ -install $(LIB_DIR) \
+ $(MKLIB_OPTIONS) $(GL_LIB_DEPS) $(STAND_ALONE_OBJECTS)
+
+# Make the OSMesa library
+$(LIB_DIR)/$(OSMESA_LIB_NAME): $(OSMESA_DRIVER_OBJECTS) $(OSMESA16_OBJECTS)
+ @ if [ "${DRIVER_DIRS}" = "osmesa" ] ; then \
+ $(TOP)/bin/mklib -o $(OSMESA_LIB) -linker '$(CC)' \
+ -major $(MESA_MAJOR) \
+ -minor $(MESA_MINOR) -patch $(MESA_TINY) \
+ -install $(LIB_DIR) $(MKLIB_OPTIONS) \
+ $(OSMESA_LIB_DEPS) $(OSMESA16_OBJECTS) ; \
+ else \
+ $(TOP)/bin/mklib -o $(OSMESA_LIB) -linker '$(CC)' \
+ -major $(MESA_MAJOR) \
+ -minor $(MESA_MINOR) -patch $(GL_TINY) \
+ -install $(LIB_DIR) $(MKLIB_OPTIONS) \
+ $(OSMESA_LIB_DEPS) $(OSMESA_DRIVER_OBJECTS) ; \
+ fi
+
+
+######################################################################
+# 16 (or 32) bit/channel OSMesa
+
+# $(LIB_DIR)/$(OSMESA_LIB_NAME): $(OSMESA16_OBJECTS)
+# $(TOP)/bin/mklib -o $(OSMESA_LIB) \
+# -major $(MESA_MAJOR) -minor $(MESA_MINOR) -patch $(MESA_TINY) \
+# -install $(LIB_DIR) \
+# $(MKLIB_OPTIONS) $(GL_LIB_DEPS) $(OSMESA16_OBJECTS)
+
+
+
+######################################################################
+# Generic stuff
+
+ALL_SOURCES = \
+ $(GLAPI_SOURCES) \
+ $(MAIN_SOURCES) \
+ $(MATH_SOURCES) \
+ $(ARRAY_CACHE_SOURCES) \
+ $(TNL_SOURCES) \
+ $(SHADER_SOURCES) \
+ $(SWRAST_SOURCES) \
+ $(SWRAST_SETUP_SOURCES) \
+ $(ASM_C_SOURCES) \
+ $(X86_SOURCES) \
+ $(COMMON_DRIVER_SOURCES)\
+ $(X11_DRIVER_SOURCES) \
+ $(OSMESA_DRIVER_SOURCES)
+
+
+SUBDIRS = array_cache drivers/dri glapi main math sparc swrast swrast_setup \
+ tnl tnl_dd
+
+
+# Update dependencies
+depend: $(ALL_SOURCES)
+ @ echo "running $(MKDEP)"
+ @ touch depend
+ $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDE_DIRS) $(ALL_SOURCES) \
+ > /dev/null
+
+
+# Emacs tags
+tags:
+ etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h
+
+clean:
+ -rm -f */*.o
+ -rm -f */*/*.o
+ -rm -f depend depend.bak mesa.a
+ -rm -f drivers/*/*.o
+ (cd drivers/dri ; $(MAKE) clean)
+ (cd x86 ; $(MAKE) clean)
+ (cd x86-64 ; $(MAKE) clean)
+
+include depend
diff --git a/nx-X11/extras/Mesa/src/mesa/Makefile.DJ b/nx-X11/extras/Mesa/src/mesa/Makefile.DJ
new file mode 100644
index 000000000..53c437070
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/Makefile.DJ
@@ -0,0 +1,168 @@
+# Mesa 3-D graphics library
+# Version: 5.1
+#
+# Copyright (C) 1999-2003 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.
+
+# DOS/DJGPP core makefile v1.7 for Mesa
+#
+# Copyright (C) 2002 - Daniel Borca
+# Email : dborca@users.sourceforge.net
+# Web : http://www.geocities.com/dborca
+
+
+#
+# Available options:
+#
+# Environment variables:
+# CFLAGS
+#
+# GLIDE path to Glide3 SDK; used with FX.
+# default = $(TOP)/glide3
+# FX=1 build for 3dfx Glide3. Note that this disables
+# compilation of most DMesa code and requires fxMesa.
+# As a consequence, you'll need the DJGPP Glide3
+# library to build any application.
+# default = no
+# X86=1 optimize for x86 (if possible, use MMX, SSE, 3DNow).
+# default = no
+#
+# Targets:
+# all: build GL
+# clean: remove object files
+#
+
+
+
+.PHONY: all clean
+.INTERMEDIATE: x86/gen_matypes.exe
+
+TOP = ../..
+GLIDE ?= $(TOP)/glide3
+LIBDIR = $(TOP)/lib
+GL_LIB = libgl.a
+GL_DXE = gl.dxe
+GL_IMP = libigl.a
+
+export LD_LIBRARY_PATH := $(LD_LIBRARY_PATH);$(LIBDIR);$(GLIDE)/lib
+
+CC = gcc
+CFLAGS += $(INCLUDE_DIRS)
+CFLAGS += -DUSE_EXTERNAL_DXTN_LIB=1
+ifeq ($(FX),1)
+CFLAGS += -D__DOS__
+CFLAGS += -I$(GLIDE)/include -DFX
+LIBNAME = "Mesa/FX DJGPP"
+else
+LIBNAME = "Mesa DJGPP"
+endif
+
+AR = ar
+ARFLAGS = crus
+
+HAVEDXE3 = $(wildcard $(DJDIR)/bin/dxe3gen.exe)
+
+ifeq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
+UNLINK = del $(subst /,\,$(1))
+else
+UNLINK = $(RM) $(1)
+endif
+
+include sources
+
+ifeq ($(X86),1)
+CFLAGS += -DUSE_X86_ASM
+CFLAGS += -DUSE_MMX_ASM
+CFLAGS += -DUSE_SSE_ASM
+CFLAGS += -DUSE_3DNOW_ASM
+X86_SOURCES += $(X86_API)
+else
+X86_SOURCES =
+endif
+
+DRIVER_SOURCES = \
+ drivers/dos/dmesa.c
+ifeq ($(FX),1)
+DRIVER_SOURCES += \
+ $(GLIDE_DRIVER_SOURCES)
+else
+DRIVER_SOURCES += \
+ drivers/dos/video.c \
+ drivers/dos/virtual.S \
+ drivers/dos/vesa.c \
+ drivers/dos/blit.S \
+ drivers/dos/vga.c \
+ drivers/dos/null.c \
+ drivers/dos/dpmi.c
+endif
+
+#DRIVER_SOURCES += $(OSMESA_DRIVER_SOURCES)
+
+SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(COMMON_DRIVER_SOURCES) $(DRIVER_SOURCES)
+
+OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
+
+X86_OBJECTS = $(addsuffix .o,$(basename $(X86_SOURCES)))
+
+.c.o:
+ $(CC) -o $@ $(CFLAGS) -c $<
+.S.o:
+ $(CC) -o $@ $(CFLAGS) -c $<
+.s.o:
+ $(CC) -o $@ $(CFLAGS) -x assembler-with-cpp -c $<
+
+all: $(LIBDIR)/$(GL_LIB) $(LIBDIR)/$(GL_DXE) $(LIBDIR)/$(GL_IMP)
+
+$(LIBDIR)/$(GL_LIB): $(OBJECTS)
+ $(AR) $(ARFLAGS) $@ $^
+
+$(LIBDIR)/$(GL_DXE) $(LIBDIR)/$(GL_IMP): $(OBJECTS)
+ifeq ($(HAVEDXE3),)
+ $(warning Missing DXE3 package... Skipping $(GL_DXE))
+else
+ifeq ($(FX),1)
+ -dxe3gen -o $(LIBDIR)/$(GL_DXE) -Y $(LIBDIR)/$(GL_IMP) -D $(LIBNAME) -E _gl -E _DMesa -P glide3x.dxe -U $^
+else
+ -dxe3gen -o $(LIBDIR)/$(GL_DXE) -Y $(LIBDIR)/$(GL_IMP) -D $(LIBNAME) -E _gl -E _DMesa -U $^
+endif
+endif
+
+$(X86_OBJECTS): x86/matypes.h
+
+x86/matypes.h: x86/gen_matypes.exe
+ $< > $@
+
+x86/gen_matypes.exe: x86/gen_matypes.c
+ $(CC) -o $@ $(CFLAGS) -s $<
+
+clean:
+ -$(call UNLINK,array_cache/*.o)
+ -$(call UNLINK,glapi/*.o)
+ -$(call UNLINK,main/*.o)
+ -$(call UNLINK,math/*.o)
+ -$(call UNLINK,shader/*.o)
+ -$(call UNLINK,sparc/*.o)
+ -$(call UNLINK,ppc/*.o)
+ -$(call UNLINK,swrast/*.o)
+ -$(call UNLINK,swrast_setup/*.o)
+ -$(call UNLINK,tnl/*.o)
+ -$(call UNLINK,x86/*.o)
+ -$(call UNLINK,drivers/common/*.o)
+ -$(call UNLINK,drivers/dos/*.o)
+ -$(call UNLINK,drivers/glide/*.o)
diff --git a/nx-X11/extras/Mesa/src/mesa/Makefile.mgw b/nx-X11/extras/Mesa/src/mesa/Makefile.mgw
new file mode 100644
index 000000000..ebec5c055
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/Makefile.mgw
@@ -0,0 +1,206 @@
+# Mesa 3-D graphics library
+# Version: 5.1
+#
+# Copyright (C) 1999-2003 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.
+
+# MinGW core makefile v1.4 for Mesa
+#
+# Copyright (C) 2002 - Daniel Borca
+# Email : dborca@users.sourceforge.net
+# Web : http://www.geocities.com/dborca
+
+
+#
+# Available options:
+#
+# Environment variables:
+# CFLAGS
+#
+# GLIDE path to Glide3 SDK; used with FX.
+# default = $(TOP)/glide3
+# FX=1 build for 3dfx Glide3. Note that this disables
+# compilation of most WMesa code and requires fxMesa.
+# As a consequence, you'll need the Win32 Glide3
+# library to build any application.
+# default = no
+# ICD=1 build the installable client driver interface
+# (windows opengl driver interface)
+# default = no
+# X86=1 optimize for x86 (if possible, use MMX, SSE, 3DNow).
+# default = no
+#
+# Targets:
+# all: build GL
+# clean: remove object files
+#
+
+
+
+.PHONY: all clean
+.INTERMEDIATE: x86/gen_matypes.exe
+.SUFFIXES: .rc .res
+
+# Set this to the prefix of your build tools, i.e. mingw32-
+TOOLS_PREFIX = mingw32-
+
+TOP = ../..
+GLIDE ?= $(TOP)/glide3
+LIBDIR = $(TOP)/lib
+ifeq ($(ICD),1)
+ GL_DLL = mesa32.dll
+ GL_IMP = libmesa32.a
+else
+ GL_DLL = opengl32.dll
+ GL_IMP = libopengl32.a
+endif
+
+LDLIBS = -lgdi32
+
+CC = $(TOOLS_PREFIX)gcc
+CFLAGS += -DBUILD_GL32 -D_OPENGL32_
+CFLAGS += $(INCLUDE_DIRS)
+CFLAGS += -DUSE_EXTERNAL_DXTN_LIB=1
+ifeq ($(FX),1)
+ CFLAGS += -I$(GLIDE)/include -DFX
+ LDLIBS += -L$(GLIDE)/lib -lglide3x
+ GL_DEF = drivers/windows/fx/fxopengl.def
+ GL_RES = drivers/windows/fx/fx.rc
+else
+ ifeq ($(ICD),1)
+ CFLAGS += -DUSE_MGL_NAMESPACE
+ GL_DEF = drivers/windows/icd/mesa.def
+ else
+ GL_DEF = drivers/windows/gdi/mesa.def
+ endif
+endif
+
+AR = ar
+ARFLAGS = crus
+
+UNLINK = del $(subst /,\,$(1))
+ifneq ($(wildcard $(addsuffix /rm.exe,$(subst ;, ,$(PATH)))),)
+UNLINK = $(RM) $(1)
+endif
+ifneq ($(wildcard $(addsuffix /rm,$(subst :, ,$(PATH)))),)
+UNLINK = $(RM) $(1)
+endif
+
+include sources
+
+ifeq ($(X86),1)
+CFLAGS += -DUSE_X86_ASM
+CFLAGS += -DUSE_MMX_ASM
+CFLAGS += -DUSE_SSE_ASM
+CFLAGS += -DUSE_3DNOW_ASM
+X86_SOURCES += $(X86_API)
+else
+X86_SOURCES =
+endif
+
+ifeq ($(FX),1)
+DRIVER_SOURCES = \
+ $(GLIDE_DRIVER_SOURCES) \
+ drivers/windows/fx/fxwgl.c
+else
+ifeq ($(ICD),1)
+DRIVER_SOURCES = \
+ drivers/windows/gdi/wmesa.c \
+ drivers/windows/icd/icd.c
+else
+DRIVER_SOURCES = \
+ drivers/windows/gdi/wmesa.c \
+ drivers/windows/gdi/wgl.c
+endif
+endif
+
+SOURCES = $(CORE_SOURCES) $(X86_SOURCES) $(COMMON_DRIVER_SOURCES) $(DRIVER_SOURCES)
+
+OBJECTS = $(addsuffix .o,$(basename $(SOURCES)))
+
+X86_OBJECTS = $(addsuffix .o,$(basename $(X86_SOURCES)))
+
+RESOURCE = $(GL_RES:.rc=.res)
+
+.c.o:
+ $(CC) -o $@ $(CFLAGS) -c $<
+.S.o:
+ $(CC) -o $@ $(CFLAGS) -c $<
+.s.o:
+ $(CC) -o $@ $(CFLAGS) -x assembler-with-cpp -c $<
+.rc.res:
+ windres -o $@ -Irc -Ocoff $<
+
+all: $(LIBDIR) $(LIBDIR)/$(GL_DLL) $(LIBDIR)/$(GL_IMP)
+
+$(LIBDIR):
+ mkdir -p $(LIBDIR)
+
+$(LIBDIR)/$(GL_DLL) $(LIBDIR)/$(GL_IMP): $(OBJECTS) $(RESOURCE)
+ $(TOOLS_PREFIX)dllwrap -o $(LIBDIR)/$(GL_DLL) --output-lib $(LIBDIR)/$(GL_IMP) \
+ --target i386-mingw32 --def $(GL_DEF) -Wl,-enable-stdcall-fixup \
+ $^ $(LDLIBS)
+
+$(X86_OBJECTS): x86/matypes.h
+
+x86/matypes.h: x86/gen_matypes.exe
+ $(subst /,\,$< > $@)
+
+x86/gen_matypes.exe: x86/gen_matypes.c
+ $(CC) -o $@ $(CFLAGS) -s $<
+
+# [dBorca]
+# glapi_x86.S needs some adjustments
+# in order to generate correct entrypoints
+# Trick: change the following condition to
+# be always false if you need C entrypoints
+# with USE_X86_ASM (useful for trace/debug)
+ifeq (1,1)
+x86/glapi_x86.o: x86/glapi_x86.S
+ $(CC) -o $@ $(CFLAGS) -DSTDCALL_API -c $<
+else
+main/dispatch.o: main/dispatch.c
+ $(CC) -o $@ $(CFLAGS) -UUSE_X86_ASM -c $<
+glapi/glapi.o: glapi/glapi.c
+ $(CC) -o $@ $(CFLAGS) -UUSE_X86_ASM -c $<
+endif
+
+# [dBorca]
+# if we want codegen, we have to stdcall
+tnl/t_vtx_x86_gcc.o: tnl/t_vtx_x86_gcc.S
+ $(CC) -o $@ $(CFLAGS) -DSTDCALL_API -c $<
+
+clean:
+ -$(call UNLINK,array_cache/*.o)
+ -$(call UNLINK,glapi/*.o)
+ -$(call UNLINK,main/*.o)
+ -$(call UNLINK,math/*.o)
+ -$(call UNLINK,shader/*.o)
+ -$(call UNLINK,sparc/*.o)
+ -$(call UNLINK,ppc/*.o)
+ -$(call UNLINK,swrast/*.o)
+ -$(call UNLINK,swrast_setup/*.o)
+ -$(call UNLINK,tnl/*.o)
+ -$(call UNLINK,x86/*.o)
+ -$(call UNLINK,drivers/common/*.o)
+ -$(call UNLINK,drivers/glide/*.o)
+ -$(call UNLINK,drivers/windows/fx/*.o)
+ -$(call UNLINK,drivers/windows/fx/*.res)
+ -$(call UNLINK,drivers/windows/gdi/*.o)
+ -$(call UNLINK,drivers/windows/icd/*.o)
diff --git a/nx-X11/extras/Mesa/src/mesa/array_cache/ac_context.c b/nx-X11/extras/Mesa/src/mesa/array_cache/ac_context.c
new file mode 100644
index 000000000..ebf3a3dc4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/array_cache/ac_context.c
@@ -0,0 +1,375 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2002 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+
+#include "array_cache/ac_context.h"
+
+
+/*
+ * Initialize the array fallbacks. That is, by default the fallback arrays
+ * point into the current vertex attribute values in ctx->Current.Attrib[]
+ */
+static void _ac_fallbacks_init( GLcontext *ctx )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+ struct gl_client_array *cl;
+ GLuint i;
+
+ cl = &ac->Fallback.Normal;
+ cl->Size = 3;
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = 0;
+ cl->Ptr = (GLubyte *) ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
+ cl->Enabled = 1;
+ cl->Flags = CA_CLIENT_DATA; /* hack */
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
+
+ cl = &ac->Fallback.Color;
+ cl->Size = 4;
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = 0;
+ cl->Ptr = (GLubyte *) ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
+ cl->Enabled = 1;
+ cl->Flags = CA_CLIENT_DATA; /* hack */
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
+
+ cl = &ac->Fallback.SecondaryColor;
+ cl->Size = 3;
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = 0;
+ cl->Ptr = (GLubyte *) ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
+ cl->Enabled = 1;
+ cl->Flags = CA_CLIENT_DATA; /* hack */
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
+
+ cl = &ac->Fallback.FogCoord;
+ cl->Size = 1;
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = 0;
+ cl->Ptr = (GLubyte *) &ctx->Current.Attrib[VERT_ATTRIB_FOG];
+ cl->Enabled = 1;
+ cl->Flags = CA_CLIENT_DATA; /* hack */
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
+
+ cl = &ac->Fallback.Index;
+ cl->Size = 1;
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = 0;
+ cl->Ptr = (GLubyte *) &ctx->Current.Index;
+ cl->Enabled = 1;
+ cl->Flags = CA_CLIENT_DATA; /* hack */
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
+
+ for (i = 0 ; i < MAX_TEXTURE_COORD_UNITS ; i++) {
+ cl = &ac->Fallback.TexCoord[i];
+ cl->Size = 4;
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = 0;
+ cl->Ptr = (GLubyte *) ctx->Current.Attrib[VERT_ATTRIB_TEX0 + i];
+ cl->Enabled = 1;
+ cl->Flags = CA_CLIENT_DATA; /* hack */
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
+ }
+
+ cl = &ac->Fallback.EdgeFlag;
+ cl->Size = 1;
+ cl->Type = GL_UNSIGNED_BYTE;
+ cl->Stride = 0;
+ cl->StrideB = 0;
+ cl->Ptr = (GLubyte *) &ctx->Current.EdgeFlag;
+ cl->Enabled = 1;
+ cl->Flags = CA_CLIENT_DATA; /* hack */
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
+
+ for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+ cl = &ac->Fallback.Attrib[i];
+ cl->Size = 4;
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = 0;
+ cl->Ptr = (GLubyte *) ctx->Current.Attrib[i];
+ cl->Enabled = 1;
+ cl->Flags = CA_CLIENT_DATA; /* hack */
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
+ }
+}
+
+
+/*
+ * Initialize the array cache pointers, types, strides, etc.
+ */
+static void _ac_cache_init( GLcontext *ctx )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+ struct gl_client_array *cl;
+ GLuint size = ctx->Const.MaxArrayLockSize + MAX_CLIPPED_VERTICES;
+ GLuint i;
+
+ cl = &ac->Cache.Vertex;
+ cl->Size = 4;
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = 4 * sizeof(GLfloat);
+ cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
+ cl->Enabled = 1;
+ cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
+
+ cl = &ac->Cache.Normal;
+ cl->Size = 3;
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = 3 * sizeof(GLfloat);
+ cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
+ cl->Enabled = 1;
+ cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
+
+ cl = &ac->Cache.Color;
+ cl->Size = 4;
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = 4 * sizeof(GLfloat);
+ cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
+ cl->Enabled = 1;
+ cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
+
+ cl = &ac->Cache.SecondaryColor;
+ cl->Size = 3;
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = 4 * sizeof(GLfloat);
+ cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
+ cl->Enabled = 1;
+ cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
+
+ cl = &ac->Cache.FogCoord;
+ cl->Size = 1;
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = sizeof(GLfloat);
+ cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
+ cl->Enabled = 1;
+ cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
+
+ cl = &ac->Cache.Index;
+ cl->Size = 1;
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = sizeof(GLfloat);
+ cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
+ cl->Enabled = 1;
+ cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
+
+ for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
+ cl = &ac->Cache.TexCoord[i];
+ cl->Size = 4;
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = 4 * sizeof(GLfloat);
+ cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
+ cl->Enabled = 1;
+ cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
+ }
+
+ cl = &ac->Cache.EdgeFlag;
+ cl->Size = 1;
+ cl->Type = GL_UNSIGNED_BYTE;
+ cl->Stride = 0;
+ cl->StrideB = sizeof(GLubyte);
+ cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
+ cl->Enabled = 1;
+ cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
+
+ for (i = 0 ; i < VERT_ATTRIB_MAX; i++) {
+ cl = &ac->Cache.Attrib[i];
+ cl->Size = 4;
+ cl->Type = GL_FLOAT;
+ cl->Stride = 0;
+ cl->StrideB = 4 * sizeof(GLfloat);
+ cl->Ptr = (GLubyte *) MALLOC( cl->StrideB * size );
+ cl->Enabled = 1;
+ cl->Flags = 0;
+#if FEATURE_ARB_vertex_buffer_object
+ cl->BufferObj = ctx->Array.NullBufferObj;
+#endif
+ }
+}
+
+
+/* This storage used to hold translated client data if type or stride
+ * need to be fixed.
+ */
+static void _ac_elts_init( GLcontext *ctx )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+ GLuint size = 1000;
+
+ ac->Elts = (GLuint *)MALLOC( sizeof(GLuint) * size );
+ ac->elt_size = size;
+}
+
+static void _ac_raw_init( GLcontext *ctx )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+ GLuint i;
+
+ ac->Raw.Color = ac->Fallback.Color;
+ ac->Raw.EdgeFlag = ac->Fallback.EdgeFlag;
+ ac->Raw.FogCoord = ac->Fallback.FogCoord;
+ ac->Raw.Index = ac->Fallback.Index;
+ ac->Raw.Normal = ac->Fallback.Normal;
+ ac->Raw.SecondaryColor = ac->Fallback.SecondaryColor;
+ ac->Raw.Vertex = ctx->Array.Vertex;
+
+ ac->IsCached.Color = GL_FALSE;
+ ac->IsCached.EdgeFlag = GL_FALSE;
+ ac->IsCached.FogCoord = GL_FALSE;
+ ac->IsCached.Index = GL_FALSE;
+ ac->IsCached.Normal = GL_FALSE;
+ ac->IsCached.SecondaryColor = GL_FALSE;
+ ac->IsCached.Vertex = GL_FALSE;
+
+ for (i = 0 ; i < MAX_TEXTURE_COORD_UNITS ; i++) {
+ ac->Raw.TexCoord[i] = ac->Fallback.TexCoord[i];
+ ac->IsCached.TexCoord[i] = GL_FALSE;
+ }
+
+ for (i = 0 ; i < VERT_ATTRIB_MAX ; i++) {
+ ac->Raw.Attrib[i] = ac->Fallback.Attrib[i];
+ ac->IsCached.Attrib[i] = GL_FALSE;
+ }
+}
+
+GLboolean _ac_CreateContext( GLcontext *ctx )
+{
+ ctx->acache_context = CALLOC(sizeof(ACcontext));
+ if (ctx->acache_context) {
+ _ac_cache_init( ctx );
+ _ac_fallbacks_init( ctx );
+ _ac_raw_init( ctx );
+ _ac_elts_init( ctx );
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+}
+
+void _ac_DestroyContext( GLcontext *ctx )
+{
+ struct gl_buffer_object *nullObj = ctx->Array.NullBufferObj;
+ ACcontext *ac = AC_CONTEXT(ctx);
+ GLint i;
+
+ /* only free vertex data if it's really a pointer to vertex data and
+ * not an offset into a buffer object.
+ */
+ if (ac->Cache.Vertex.Ptr && ac->Cache.Vertex.BufferObj == nullObj)
+ FREE( (void *) ac->Cache.Vertex.Ptr );
+ if (ac->Cache.Normal.Ptr && ac->Cache.Normal.BufferObj == nullObj)
+ FREE( (void *) ac->Cache.Normal.Ptr );
+ if (ac->Cache.Color.Ptr && ac->Cache.Color.BufferObj == nullObj)
+ FREE( (void *) ac->Cache.Color.Ptr );
+ if (ac->Cache.SecondaryColor.Ptr && ac->Cache.SecondaryColor.BufferObj == nullObj)
+ FREE( (void *) ac->Cache.SecondaryColor.Ptr );
+ if (ac->Cache.EdgeFlag.Ptr && ac->Cache.EdgeFlag.BufferObj == nullObj)
+ FREE( (void *) ac->Cache.EdgeFlag.Ptr );
+ if (ac->Cache.Index.Ptr && ac->Cache.Index.BufferObj == nullObj)
+ FREE( (void *) ac->Cache.Index.Ptr );
+ if (ac->Cache.FogCoord.Ptr && ac->Cache.FogCoord.BufferObj == nullObj)
+ FREE( (void *) ac->Cache.FogCoord.Ptr );
+
+ for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
+ if (ac->Cache.TexCoord[i].Ptr && ac->Cache.TexCoord[i].BufferObj == nullObj)
+ FREE( (void *) ac->Cache.TexCoord[i].Ptr );
+ }
+
+ for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+ if (ac->Cache.Attrib[i].Ptr && ac->Cache.Attrib[i].BufferObj == nullObj)
+ FREE( (void *) ac->Cache.Attrib[i].Ptr );
+ }
+
+ if (ac->Elts)
+ FREE( ac->Elts );
+
+ /* Free the context structure itself */
+ FREE(ac);
+ ctx->acache_context = NULL;
+}
+
+void _ac_InvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ AC_CONTEXT(ctx)->NewState |= new_state;
+ AC_CONTEXT(ctx)->NewArrayState |= ctx->Array.NewState;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/array_cache/ac_context.h b/nx-X11/extras/Mesa/src/mesa/array_cache/ac_context.h
new file mode 100644
index 000000000..36aded315
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/array_cache/ac_context.h
@@ -0,0 +1,99 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2002 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef _AC_CONTEXT_H
+#define _AC_CONTEXT_H
+
+#include "glheader.h"
+#include "mtypes.h"
+
+#include "array_cache/acache.h"
+
+/* These are used to make the ctx->Current values look like
+ * arrays (with zero StrideB).
+ */
+struct ac_arrays {
+ struct gl_client_array Vertex;
+ struct gl_client_array Normal;
+ struct gl_client_array Color;
+ struct gl_client_array SecondaryColor;
+ struct gl_client_array FogCoord;
+ struct gl_client_array Index;
+ struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
+ struct gl_client_array EdgeFlag;
+ struct gl_client_array Attrib[VERT_ATTRIB_MAX]; /* GL_NV_vertex_program */
+};
+
+struct ac_array_pointers {
+ struct gl_client_array *Vertex;
+ struct gl_client_array *Normal;
+ struct gl_client_array *Color;
+ struct gl_client_array *SecondaryColor;
+ struct gl_client_array *FogCoord;
+ struct gl_client_array *Index;
+ struct gl_client_array *TexCoord[MAX_TEXTURE_COORD_UNITS];
+ struct gl_client_array *EdgeFlag;
+ struct gl_client_array *Attrib[VERT_ATTRIB_MAX]; /* GL_NV_vertex_program */
+};
+
+struct ac_array_flags {
+ GLboolean Vertex;
+ GLboolean Normal;
+ GLboolean Color;
+ GLboolean SecondaryColor;
+ GLboolean FogCoord;
+ GLboolean Index;
+ GLboolean TexCoord[MAX_TEXTURE_COORD_UNITS];
+ GLboolean EdgeFlag;
+ GLboolean Attrib[VERT_ATTRIB_MAX]; /* GL_NV_vertex_program */
+};
+
+
+typedef struct {
+ GLuint NewState; /* not needed? */
+ GLuint NewArrayState;
+
+ /* Facility for importing and caching array data:
+ */
+ struct ac_arrays Fallback;
+ struct ac_arrays Cache;
+ struct ac_arrays Raw;
+ struct ac_array_flags IsCached;
+ GLuint start;
+ GLuint count;
+
+ /* Facility for importing element lists:
+ */
+ GLuint *Elts;
+ GLuint elt_size;
+
+} ACcontext;
+
+#define AC_CONTEXT(ctx) ((ACcontext *)ctx->acache_context)
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/array_cache/ac_import.c b/nx-X11/extras/Mesa/src/mesa/array_cache/ac_import.c
new file mode 100644
index 000000000..416b2e793
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/array_cache/ac_import.c
@@ -0,0 +1,902 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+
+#include "math/m_translate.h"
+#include "array_cache/ac_context.h"
+#include "math/m_translate.h"
+
+#define STRIDE_ARRAY( array, offset ) \
+do { \
+ GLubyte *tmp = ADD_POINTERS( (array).BufferObj->Data, (array).Ptr ) \
+ + (offset) * (array).StrideB; \
+ (array).Ptr = tmp; \
+} while (0)
+
+
+/* Set the array pointer back to its source when the cached data is
+ * invalidated:
+ */
+static void
+reset_texcoord( GLcontext *ctx, GLuint unit )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ if (ctx->Array.TexCoord[unit].Enabled) {
+ ac->Raw.TexCoord[unit] = ctx->Array.TexCoord[unit];
+ STRIDE_ARRAY(ac->Raw.TexCoord[unit], ac->start);
+ }
+ else {
+ ac->Raw.TexCoord[unit] = ac->Fallback.TexCoord[unit];
+
+ if (ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][3] != 1.0)
+ ac->Raw.TexCoord[unit].Size = 4;
+ else if (ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit][2] != 0.0)
+ ac->Raw.TexCoord[unit].Size = 3;
+ else
+ ac->Raw.TexCoord[unit].Size = 2;
+ }
+
+ ac->IsCached.TexCoord[unit] = GL_FALSE;
+ ac->NewArrayState &= ~_NEW_ARRAY_TEXCOORD(unit);
+}
+
+static void
+reset_vertex( GLcontext *ctx )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+ ASSERT(ctx->Array.Vertex.Enabled
+ || (ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[0].Enabled));
+ ac->Raw.Vertex = ctx->Array.Vertex;
+ STRIDE_ARRAY(ac->Raw.Vertex, ac->start);
+ ac->IsCached.Vertex = GL_FALSE;
+ ac->NewArrayState &= ~_NEW_ARRAY_VERTEX;
+}
+
+
+static void
+reset_normal( GLcontext *ctx )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ if (ctx->Array.Normal.Enabled) {
+ ac->Raw.Normal = ctx->Array.Normal;
+ STRIDE_ARRAY(ac->Raw.Normal, ac->start);
+ }
+ else {
+ ac->Raw.Normal = ac->Fallback.Normal;
+ }
+
+ ac->IsCached.Normal = GL_FALSE;
+ ac->NewArrayState &= ~_NEW_ARRAY_NORMAL;
+}
+
+
+static void
+reset_color( GLcontext *ctx )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ if (ctx->Array.Color.Enabled) {
+ ac->Raw.Color = ctx->Array.Color;
+ STRIDE_ARRAY(ac->Raw.Color, ac->start);
+ }
+ else
+ ac->Raw.Color = ac->Fallback.Color;
+
+ ac->IsCached.Color = GL_FALSE;
+ ac->NewArrayState &= ~_NEW_ARRAY_COLOR0;
+}
+
+
+static void
+reset_secondarycolor( GLcontext *ctx )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ if (ctx->Array.SecondaryColor.Enabled) {
+ ac->Raw.SecondaryColor = ctx->Array.SecondaryColor;
+ STRIDE_ARRAY(ac->Raw.SecondaryColor, ac->start);
+ }
+ else
+ ac->Raw.SecondaryColor = ac->Fallback.SecondaryColor;
+
+ ac->IsCached.SecondaryColor = GL_FALSE;
+ ac->NewArrayState &= ~_NEW_ARRAY_COLOR1;
+}
+
+
+static void
+reset_index( GLcontext *ctx )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ if (ctx->Array.Index.Enabled) {
+ ac->Raw.Index = ctx->Array.Index;
+ STRIDE_ARRAY(ac->Raw.Index, ac->start);
+ }
+ else
+ ac->Raw.Index = ac->Fallback.Index;
+
+ ac->IsCached.Index = GL_FALSE;
+ ac->NewArrayState &= ~_NEW_ARRAY_INDEX;
+}
+
+
+static void
+reset_fogcoord( GLcontext *ctx )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ if (ctx->Array.FogCoord.Enabled) {
+ ac->Raw.FogCoord = ctx->Array.FogCoord;
+ STRIDE_ARRAY(ac->Raw.FogCoord, ac->start);
+ }
+ else
+ ac->Raw.FogCoord = ac->Fallback.FogCoord;
+
+ ac->IsCached.FogCoord = GL_FALSE;
+ ac->NewArrayState &= ~_NEW_ARRAY_FOGCOORD;
+}
+
+
+static void
+reset_edgeflag( GLcontext *ctx )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ if (ctx->Array.EdgeFlag.Enabled) {
+ ac->Raw.EdgeFlag = ctx->Array.EdgeFlag;
+ STRIDE_ARRAY(ac->Raw.EdgeFlag, ac->start);
+ }
+ else
+ ac->Raw.EdgeFlag = ac->Fallback.EdgeFlag;
+
+ ac->IsCached.EdgeFlag = GL_FALSE;
+ ac->NewArrayState &= ~_NEW_ARRAY_EDGEFLAG;
+}
+
+
+static void
+reset_attrib( GLcontext *ctx, GLuint index )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ if (ctx->Array.VertexAttrib[index].Enabled) {
+ ac->Raw.Attrib[index] = ctx->Array.VertexAttrib[index];
+ STRIDE_ARRAY(ac->Raw.Attrib[index], ac->start);
+ }
+ else
+ ac->Raw.Attrib[index] = ac->Fallback.Attrib[index];
+
+ ac->IsCached.Attrib[index] = GL_FALSE;
+ ac->NewArrayState &= ~_NEW_ARRAY_ATTRIB(index);
+}
+
+
+/**
+ * Generic import function for color data
+ */
+static void
+import( const GLcontext *ctx,
+ GLenum destType,
+ struct gl_client_array *to,
+ const struct gl_client_array *from )
+{
+ const ACcontext *ac = AC_CONTEXT(ctx);
+
+ if (destType == 0)
+ destType = from->Type;
+
+ switch (destType) {
+ case GL_FLOAT:
+ _math_trans_4fc( (GLfloat (*)[4]) to->Ptr,
+ from->Ptr,
+ from->StrideB,
+ from->Type,
+ from->Size,
+ 0,
+ ac->count - ac->start);
+
+ to->StrideB = 4 * sizeof(GLfloat);
+ to->Type = GL_FLOAT;
+ break;
+
+ case GL_UNSIGNED_BYTE:
+ _math_trans_4ub( (GLubyte (*)[4]) to->Ptr,
+ from->Ptr,
+ from->StrideB,
+ from->Type,
+ from->Size,
+ 0,
+ ac->count - ac->start);
+
+ to->StrideB = 4 * sizeof(GLubyte);
+ to->Type = GL_UNSIGNED_BYTE;
+ break;
+
+ case GL_UNSIGNED_SHORT:
+ _math_trans_4us( (GLushort (*)[4]) to->Ptr,
+ from->Ptr,
+ from->StrideB,
+ from->Type,
+ from->Size,
+ 0,
+ ac->count - ac->start);
+
+ to->StrideB = 4 * sizeof(GLushort);
+ to->Type = GL_UNSIGNED_SHORT;
+ break;
+
+ default:
+ _mesa_problem(ctx, "Unexpected dest format in import()");
+ break;
+ }
+}
+
+
+
+/*
+ * Functions to import array ranges with specified types and strides.
+ * For example, if the vertex data is GLshort[2] and we want GLfloat[3]
+ * we'll use an import function to do the data conversion.
+ */
+
+static void
+import_texcoord( GLcontext *ctx, GLuint unit, GLenum type, GLuint stride )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+ const struct gl_client_array *from = &ac->Raw.TexCoord[unit];
+ struct gl_client_array *to = &ac->Cache.TexCoord[unit];
+ (void) type; (void) stride;
+
+ ASSERT(unit < ctx->Const.MaxTextureCoordUnits);
+
+ /* Limited choices at this stage:
+ */
+ ASSERT(type == GL_FLOAT);
+ ASSERT(stride == 4*sizeof(GLfloat) || stride == 0);
+ ASSERT(ac->count - ac->start < ctx->Const.MaxArrayLockSize);
+
+ _math_trans_4f( (GLfloat (*)[4]) to->Ptr,
+ from->Ptr,
+ from->StrideB,
+ from->Type,
+ from->Size,
+ 0,
+ ac->count - ac->start);
+
+ to->Size = from->Size;
+ to->StrideB = 4 * sizeof(GLfloat);
+ to->Type = GL_FLOAT;
+ ac->IsCached.TexCoord[unit] = GL_TRUE;
+}
+
+static void
+import_vertex( GLcontext *ctx, GLenum type, GLuint stride )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+ const struct gl_client_array *from = &ac->Raw.Vertex;
+ struct gl_client_array *to = &ac->Cache.Vertex;
+ (void) type; (void) stride;
+
+ /* Limited choices at this stage:
+ */
+ ASSERT(type == GL_FLOAT);
+ ASSERT(stride == 4*sizeof(GLfloat) || stride == 0);
+
+ _math_trans_4f( (GLfloat (*)[4]) to->Ptr,
+ from->Ptr,
+ from->StrideB,
+ from->Type,
+ from->Size,
+ 0,
+ ac->count - ac->start);
+
+ to->Size = from->Size;
+ to->StrideB = 4 * sizeof(GLfloat);
+ to->Type = GL_FLOAT;
+ ac->IsCached.Vertex = GL_TRUE;
+}
+
+static void
+import_normal( GLcontext *ctx, GLenum type, GLuint stride )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+ const struct gl_client_array *from = &ac->Raw.Normal;
+ struct gl_client_array *to = &ac->Cache.Normal;
+ (void) type; (void) stride;
+
+ /* Limited choices at this stage:
+ */
+ ASSERT(type == GL_FLOAT);
+ ASSERT(stride == 3*sizeof(GLfloat) || stride == 0);
+
+ _math_trans_3f( (GLfloat (*)[3]) to->Ptr,
+ from->Ptr,
+ from->StrideB,
+ from->Type,
+ 0,
+ ac->count - ac->start);
+
+ to->StrideB = 3 * sizeof(GLfloat);
+ to->Type = GL_FLOAT;
+ ac->IsCached.Normal = GL_TRUE;
+}
+
+static void
+import_color( GLcontext *ctx, GLenum type, GLuint stride )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+ const struct gl_client_array *from = &ac->Raw.Color;
+ struct gl_client_array *to = &ac->Cache.Color;
+ (void) stride;
+
+ import( ctx, type, to, from );
+
+ ac->IsCached.Color = GL_TRUE;
+}
+
+static void
+import_index( GLcontext *ctx, GLenum type, GLuint stride )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+ const struct gl_client_array *from = &ac->Raw.Index;
+ struct gl_client_array *to = &ac->Cache.Index;
+ (void) type; (void) stride;
+
+ /* Limited choices at this stage:
+ */
+ ASSERT(type == GL_UNSIGNED_INT);
+ ASSERT(stride == sizeof(GLuint) || stride == 0);
+
+ _math_trans_1ui( (GLuint *) to->Ptr,
+ from->Ptr,
+ from->StrideB,
+ from->Type,
+ 0,
+ ac->count - ac->start);
+
+ to->StrideB = sizeof(GLuint);
+ to->Type = GL_UNSIGNED_INT;
+ ac->IsCached.Index = GL_TRUE;
+}
+
+static void
+import_secondarycolor( GLcontext *ctx, GLenum type, GLuint stride )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+ const struct gl_client_array *from = &ac->Raw.SecondaryColor;
+ struct gl_client_array *to = &ac->Cache.SecondaryColor;
+ (void) stride;
+
+ import( ctx, type, to, from );
+
+ ac->IsCached.SecondaryColor = GL_TRUE;
+}
+
+static void
+import_fogcoord( GLcontext *ctx, GLenum type, GLuint stride )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+ const struct gl_client_array *from = &ac->Raw.FogCoord;
+ struct gl_client_array *to = &ac->Cache.FogCoord;
+ (void) type; (void) stride;
+
+ /* Limited choices at this stage:
+ */
+ ASSERT(type == GL_FLOAT);
+ ASSERT(stride == sizeof(GLfloat) || stride == 0);
+
+ _math_trans_1f( (GLfloat *) to->Ptr,
+ from->Ptr,
+ from->StrideB,
+ from->Type,
+ 0,
+ ac->count - ac->start);
+
+ to->StrideB = sizeof(GLfloat);
+ to->Type = GL_FLOAT;
+ ac->IsCached.FogCoord = GL_TRUE;
+}
+
+static void
+import_edgeflag( GLcontext *ctx, GLenum type, GLuint stride )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+ const struct gl_client_array *from = &ac->Raw.EdgeFlag;
+ struct gl_client_array *to = &ac->Cache.EdgeFlag;
+ (void) type; (void) stride;
+
+ /* Limited choices at this stage:
+ */
+ ASSERT(type == GL_UNSIGNED_BYTE);
+ ASSERT(stride == sizeof(GLubyte) || stride == 0);
+
+ _math_trans_1ub( (GLubyte *) to->Ptr,
+ from->Ptr,
+ from->StrideB,
+ from->Type,
+ 0,
+ ac->count - ac->start);
+
+ to->StrideB = sizeof(GLubyte);
+ to->Type = GL_UNSIGNED_BYTE;
+ ac->IsCached.EdgeFlag = GL_TRUE;
+}
+
+static void
+import_attrib( GLcontext *ctx, GLuint index, GLenum type, GLuint stride )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+ const struct gl_client_array *from = &ac->Raw.Attrib[index];
+ struct gl_client_array *to = &ac->Cache.Attrib[index];
+ (void) type; (void) stride;
+
+ ASSERT(index < MAX_VERTEX_PROGRAM_ATTRIBS);
+
+ /* Limited choices at this stage:
+ */
+ ASSERT(type == GL_FLOAT);
+ ASSERT(stride == 4*sizeof(GLfloat) || stride == 0);
+ ASSERT(ac->count - ac->start < ctx->Const.MaxArrayLockSize);
+
+ _math_trans_4f( (GLfloat (*)[4]) to->Ptr,
+ from->Ptr,
+ from->StrideB,
+ from->Type,
+ from->Size,
+ 0,
+ ac->count - ac->start);
+
+ to->Size = from->Size;
+ to->StrideB = 4 * sizeof(GLfloat);
+ to->Type = GL_FLOAT;
+ ac->IsCached.Attrib[index] = GL_TRUE;
+}
+
+
+
+/*
+ * Externals to request arrays with specific properties:
+ */
+
+
+struct gl_client_array *
+_ac_import_texcoord( GLcontext *ctx,
+ GLuint unit,
+ GLenum type,
+ GLuint reqstride,
+ GLuint reqsize,
+ GLboolean reqwriteable,
+ GLboolean *writeable )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ ASSERT(unit < ctx->Const.MaxTextureCoordUnits);
+
+ /* Can we keep the existing version?
+ */
+ if (ac->NewArrayState & _NEW_ARRAY_TEXCOORD(unit))
+ reset_texcoord( ctx, unit );
+
+ /* Is the request impossible?
+ */
+ if (reqsize != 0 && ac->Raw.TexCoord[unit].Size > (GLint) reqsize)
+ return NULL;
+
+ /* Do we need to pull in a copy of the client data:
+ */
+ if (ac->Raw.TexCoord[unit].Type != type ||
+ (reqstride != 0 && ac->Raw.TexCoord[unit].StrideB != (GLint)reqstride) ||
+ reqwriteable)
+ {
+ if (!ac->IsCached.TexCoord[unit])
+ import_texcoord(ctx, unit, type, reqstride );
+ *writeable = GL_TRUE;
+ return &ac->Cache.TexCoord[unit];
+ }
+ else {
+ *writeable = GL_FALSE;
+ return &ac->Raw.TexCoord[unit];
+ }
+}
+
+struct gl_client_array *
+_ac_import_vertex( GLcontext *ctx,
+ GLenum type,
+ GLuint reqstride,
+ GLuint reqsize,
+ GLboolean reqwriteable,
+ GLboolean *writeable )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ /* Can we keep the existing version?
+ */
+ if (ac->NewArrayState & _NEW_ARRAY_VERTEX)
+ reset_vertex( ctx );
+
+ /* Is the request impossible?
+ */
+ if (reqsize != 0 && ac->Raw.Vertex.Size > (GLint) reqsize)
+ return NULL;
+
+ /* Do we need to pull in a copy of the client data:
+ */
+ if (ac->Raw.Vertex.Type != type ||
+ (reqstride != 0 && ac->Raw.Vertex.StrideB != (GLint) reqstride) ||
+ reqwriteable)
+ {
+ if (!ac->IsCached.Vertex)
+ import_vertex(ctx, type, reqstride );
+ *writeable = GL_TRUE;
+ return &ac->Cache.Vertex;
+ }
+ else {
+ *writeable = GL_FALSE;
+ return &ac->Raw.Vertex;
+ }
+}
+
+struct gl_client_array *
+_ac_import_normal( GLcontext *ctx,
+ GLenum type,
+ GLuint reqstride,
+ GLboolean reqwriteable,
+ GLboolean *writeable )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ /* Can we keep the existing version?
+ */
+ if (ac->NewArrayState & _NEW_ARRAY_NORMAL)
+ reset_normal( ctx );
+
+ /* Do we need to pull in a copy of the client data:
+ */
+ if (ac->Raw.Normal.Type != type ||
+ (reqstride != 0 && ac->Raw.Normal.StrideB != (GLint) reqstride) ||
+ reqwriteable)
+ {
+ if (!ac->IsCached.Normal)
+ import_normal(ctx, type, reqstride );
+ *writeable = GL_TRUE;
+ return &ac->Cache.Normal;
+ }
+ else {
+ *writeable = GL_FALSE;
+ return &ac->Raw.Normal;
+ }
+}
+
+struct gl_client_array *
+_ac_import_color( GLcontext *ctx,
+ GLenum type,
+ GLuint reqstride,
+ GLuint reqsize,
+ GLboolean reqwriteable,
+ GLboolean *writeable )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ /* Can we keep the existing version?
+ */
+ if (ac->NewArrayState & _NEW_ARRAY_COLOR0)
+ reset_color( ctx );
+
+ /* Is the request impossible?
+ */
+ if (reqsize != 0 && ac->Raw.Color.Size > (GLint) reqsize) {
+ return NULL;
+ }
+
+ /* Do we need to pull in a copy of the client data:
+ */
+ if ((type != 0 && ac->Raw.Color.Type != type) ||
+ (reqstride != 0 && ac->Raw.Color.StrideB != (GLint) reqstride) ||
+ reqwriteable)
+ {
+ if (!ac->IsCached.Color) {
+ import_color(ctx, type, reqstride );
+ }
+ *writeable = GL_TRUE;
+ return &ac->Cache.Color;
+ }
+ else {
+ *writeable = GL_FALSE;
+ return &ac->Raw.Color;
+ }
+}
+
+struct gl_client_array *
+_ac_import_index( GLcontext *ctx,
+ GLenum type,
+ GLuint reqstride,
+ GLboolean reqwriteable,
+ GLboolean *writeable )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ /* Can we keep the existing version?
+ */
+ if (ac->NewArrayState & _NEW_ARRAY_INDEX)
+ reset_index( ctx );
+
+
+ /* Do we need to pull in a copy of the client data:
+ */
+ if (ac->Raw.Index.Type != type ||
+ (reqstride != 0 && ac->Raw.Index.StrideB != (GLint) reqstride) ||
+ reqwriteable)
+ {
+ if (!ac->IsCached.Index)
+ import_index(ctx, type, reqstride );
+ *writeable = GL_TRUE;
+ return &ac->Cache.Index;
+ }
+ else {
+ *writeable = GL_FALSE;
+ return &ac->Raw.Index;
+ }
+}
+
+struct gl_client_array *
+_ac_import_secondarycolor( GLcontext *ctx,
+ GLenum type,
+ GLuint reqstride,
+ GLuint reqsize,
+ GLboolean reqwriteable,
+ GLboolean *writeable )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ /* Can we keep the existing version?
+ */
+ if (ac->NewArrayState & _NEW_ARRAY_COLOR1)
+ reset_secondarycolor( ctx );
+
+ /* Is the request impossible?
+ */
+ if (reqsize != 0 && ac->Raw.SecondaryColor.Size > (GLint) reqsize)
+ return NULL;
+
+ /* Do we need to pull in a copy of the client data:
+ */
+ if ((type != 0 && ac->Raw.SecondaryColor.Type != type) ||
+ (reqstride != 0 && ac->Raw.SecondaryColor.StrideB != (GLint)reqstride) ||
+ reqwriteable)
+ {
+ if (!ac->IsCached.SecondaryColor)
+ import_secondarycolor(ctx, type, reqstride );
+ *writeable = GL_TRUE;
+ return &ac->Cache.SecondaryColor;
+ }
+ else {
+ *writeable = GL_FALSE;
+ return &ac->Raw.SecondaryColor;
+ }
+}
+
+struct gl_client_array *
+_ac_import_fogcoord( GLcontext *ctx,
+ GLenum type,
+ GLuint reqstride,
+ GLboolean reqwriteable,
+ GLboolean *writeable )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ /* Can we keep the existing version?
+ */
+ if (ac->NewArrayState & _NEW_ARRAY_FOGCOORD)
+ reset_fogcoord( ctx );
+
+ /* Do we need to pull in a copy of the client data:
+ */
+ if (ac->Raw.FogCoord.Type != type ||
+ (reqstride != 0 && ac->Raw.FogCoord.StrideB != (GLint) reqstride) ||
+ reqwriteable)
+ {
+ if (!ac->IsCached.FogCoord)
+ import_fogcoord(ctx, type, reqstride );
+ *writeable = GL_TRUE;
+ return &ac->Cache.FogCoord;
+ }
+ else {
+ *writeable = GL_FALSE;
+ return &ac->Raw.FogCoord;
+ }
+}
+
+struct gl_client_array *
+_ac_import_edgeflag( GLcontext *ctx,
+ GLenum type,
+ GLuint reqstride,
+ GLboolean reqwriteable,
+ GLboolean *writeable )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ /* Can we keep the existing version?
+ */
+ if (ac->NewArrayState & _NEW_ARRAY_EDGEFLAG)
+ reset_edgeflag( ctx );
+
+ /* Do we need to pull in a copy of the client data:
+ */
+ if (ac->Raw.EdgeFlag.Type != type ||
+ (reqstride != 0 && ac->Raw.EdgeFlag.StrideB != (GLint) reqstride) ||
+ reqwriteable)
+ {
+ if (!ac->IsCached.EdgeFlag)
+ import_edgeflag(ctx, type, reqstride );
+ *writeable = GL_TRUE;
+ return &ac->Cache.EdgeFlag;
+ }
+ else {
+ *writeable = GL_FALSE;
+ return &ac->Raw.EdgeFlag;
+ }
+}
+
+/* GL_NV_vertex_program */
+struct gl_client_array *
+_ac_import_attrib( GLcontext *ctx,
+ GLuint index,
+ GLenum type,
+ GLuint reqstride,
+ GLuint reqsize,
+ GLboolean reqwriteable,
+ GLboolean *writeable )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ ASSERT(index < VERT_ATTRIB_MAX);
+
+ /* Can we keep the existing version?
+ */
+ if (ac->NewArrayState & _NEW_ARRAY_ATTRIB(index))
+ reset_attrib( ctx, index );
+
+ /* Is the request impossible?
+ */
+ if (reqsize != 0 && ac->Raw.Attrib[index].Size > (GLint) reqsize)
+ return NULL;
+
+ /* Do we need to pull in a copy of the client data:
+ */
+ if (ac->Raw.Attrib[index].Type != type ||
+ (reqstride != 0 && ac->Raw.Attrib[index].StrideB != (GLint)reqstride) ||
+ reqwriteable)
+ {
+ if (!ac->IsCached.Attrib[index])
+ import_attrib(ctx, index, type, reqstride );
+ *writeable = GL_TRUE;
+ return &ac->Cache.Attrib[index];
+ }
+ else {
+ *writeable = GL_FALSE;
+ return &ac->Raw.Attrib[index];
+ }
+}
+
+
+/* Clients must call this function to validate state and set bounds
+ * before importing any data:
+ */
+void
+_ac_import_range( GLcontext *ctx, GLuint start, GLuint count )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ if (!ctx->Array.LockCount) {
+ /* Not locked, discard cached data. Changes to lock
+ * status are caught via. _ac_invalidate_state().
+ */
+ ac->NewArrayState = _NEW_ARRAY_ALL;
+ ac->start = start;
+ ac->count = count;
+ }
+ else {
+ /* Locked, discard data for any disabled arrays. Require that
+ * the whole locked range always be dealt with, otherwise hard to
+ * maintain cached data in the face of clipping.
+ */
+ ac->NewArrayState |= ~ctx->Array._Enabled;
+ ac->start = ctx->Array.LockFirst;
+ ac->count = ctx->Array.LockCount;
+ ASSERT(ac->start == start); /* hmm? */
+ ASSERT(ac->count == count);
+ }
+}
+
+
+
+/* Additional convienence function for importing the element list
+ * for glDrawElements() and glDrawRangeElements().
+ */
+CONST void *
+_ac_import_elements( GLcontext *ctx,
+ GLenum new_type,
+ GLuint count,
+ GLenum old_type,
+ CONST void *indices )
+{
+ ACcontext *ac = AC_CONTEXT(ctx);
+
+ if (old_type == new_type)
+ return indices;
+
+ if (ac->elt_size < count * sizeof(GLuint)) {
+ if (ac->Elts) FREE(ac->Elts);
+ while (ac->elt_size < count * sizeof(GLuint))
+ ac->elt_size *= 2;
+ ac->Elts = (GLuint *) MALLOC(ac->elt_size);
+ }
+
+ switch (new_type) {
+ case GL_UNSIGNED_BYTE:
+ ASSERT(0);
+ return NULL;
+ case GL_UNSIGNED_SHORT:
+ ASSERT(0);
+ return NULL;
+ case GL_UNSIGNED_INT: {
+ GLuint *out = (GLuint *)ac->Elts;
+ GLuint i;
+
+ switch (old_type) {
+ case GL_UNSIGNED_BYTE: {
+ CONST GLubyte *in = (CONST GLubyte *)indices;
+ for (i = 0 ; i < count ; i++)
+ out[i] = in[i];
+ break;
+ }
+ case GL_UNSIGNED_SHORT: {
+ CONST GLushort *in = (CONST GLushort *)indices;
+ for (i = 0 ; i < count ; i++)
+ out[i] = in[i];
+ break;
+ }
+ default:
+ ASSERT(0);
+ }
+
+ return (CONST void *)out;
+ }
+ default:
+ ASSERT(0);
+ break;
+ }
+
+ return NULL;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/array_cache/acache.h b/nx-X11/extras/Mesa/src/mesa/array_cache/acache.h
new file mode 100644
index 000000000..2bb64f365
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/array_cache/acache.h
@@ -0,0 +1,132 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef _ARRAYCACHE_H
+#define _ARRAYCACHE_H
+
+#include "mtypes.h"
+
+
+extern GLboolean
+_ac_CreateContext( GLcontext *ctx );
+
+extern void
+_ac_DestroyContext( GLcontext *ctx );
+
+extern void
+_ac_InvalidateState( GLcontext *ctx, GLuint new_state );
+
+extern struct gl_client_array *
+_ac_import_vertex( GLcontext *ctx,
+ GLenum type,
+ GLuint reqstride,
+ GLuint reqsize,
+ GLboolean reqwritable,
+ GLboolean *writable );
+
+extern struct gl_client_array *
+_ac_import_normal( GLcontext *ctx,
+ GLenum type,
+ GLuint reqstride,
+ GLboolean reqwritable,
+ GLboolean *writable );
+
+extern struct gl_client_array *
+_ac_import_color( GLcontext *ctx,
+ GLenum type,
+ GLuint reqstride,
+ GLuint reqsize,
+ GLboolean reqwritable,
+ GLboolean *writable );
+
+extern struct gl_client_array *
+_ac_import_index( GLcontext *ctx,
+ GLenum type,
+ GLuint reqstride,
+ GLboolean reqwritable,
+ GLboolean *writable );
+
+extern struct gl_client_array *
+_ac_import_secondarycolor( GLcontext *ctx,
+ GLenum type,
+ GLuint reqstride,
+ GLuint reqsize,
+ GLboolean reqwritable,
+ GLboolean *writable );
+
+extern struct gl_client_array *
+_ac_import_fogcoord( GLcontext *ctx,
+ GLenum type,
+ GLuint reqstride,
+ GLboolean reqwritable,
+ GLboolean *writable );
+
+extern struct gl_client_array *
+_ac_import_edgeflag( GLcontext *ctx,
+ GLenum type,
+ GLuint reqstride,
+ GLboolean reqwritable,
+ GLboolean *writable );
+
+extern struct gl_client_array *
+_ac_import_texcoord( GLcontext *ctx,
+ GLuint unit,
+ GLenum type,
+ GLuint reqstride,
+ GLuint reqsize,
+ GLboolean reqwritable,
+ GLboolean *writable );
+
+extern struct gl_client_array *
+_ac_import_attrib( GLcontext *ctx,
+ GLuint index,
+ GLenum type,
+ GLuint reqstride,
+ GLuint reqsize,
+ GLboolean reqwritable,
+ GLboolean *writable );
+
+
+/* Clients must call this function to validate state and set bounds
+ * before importing any data:
+ */
+extern void
+_ac_import_range( GLcontext *ctx, GLuint start, GLuint count );
+
+
+/* Additional convenience function:
+ */
+extern CONST void *
+_ac_import_elements( GLcontext *ctx,
+ GLenum new_type,
+ GLuint count,
+ GLenum old_type,
+ CONST void *indices );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/array_cache/descrip.mms b/nx-X11/extras/Mesa/src/mesa/array_cache/descrip.mms
new file mode 100644
index 000000000..3555f83d8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/array_cache/descrip.mms
@@ -0,0 +1,37 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+# Last revision : 16 June 2003
+
+.first
+ define gl [---.include.gl]
+ define math [-.math]
+ define array_cache [-.array_cache]
+
+.include [---]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [---.include],[-.main],[-.glapi]
+LIBDIR = [---.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)
+
+SOURCES = ac_context.c ac_import.c
+
+OBJECTS = ac_context.obj,ac_import.obj
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+ @ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
+
+clean :
+ purge
+ delete *.obj;*
+
+ac_context.obj : ac_context.c
+ac_import.obj : ac_import.c
diff --git a/nx-X11/extras/Mesa/src/mesa/descrip.mms b/nx-X11/extras/Mesa/src/mesa/descrip.mms
new file mode 100644
index 000000000..a12e3fc1b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/descrip.mms
@@ -0,0 +1,26 @@
+# Makefile for Mesa for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+
+all :
+ set default [.main]
+ $(MMS)$(MMSQUALIFIERS)
+ set default [-.glapi]
+ $(MMS)$(MMSQUALIFIERS)
+ set default [-.shader]
+ $(MMS)$(MMSQUALIFIERS)
+ set default [-.drivers.common]
+ $(MMS)$(MMSQUALIFIERS)
+ set default [-.x11]
+ $(MMS)$(MMSQUALIFIERS)
+ set default [-.osmesa]
+ $(MMS)$(MMSQUALIFIERS)
+ set default [--.math]
+ $(MMS)$(MMSQUALIFIERS)
+ set default [-.tnl]
+ $(MMS)$(MMSQUALIFIERS)
+ set default [-.swrast]
+ $(MMS)$(MMSQUALIFIERS)
+ set default [-.swrast_setup]
+ $(MMS)$(MMSQUALIFIERS)
+ set default [-.array_cache]
+ $(MMS)$(MMSQUALIFIERS)
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/common/descrip.mms b/nx-X11/extras/Mesa/src/mesa/drivers/common/descrip.mms
new file mode 100644
index 000000000..aa4b8ae21
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/common/descrip.mms
@@ -0,0 +1,37 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+# Last revision : 16 June 2003
+
+.first
+ define gl [----.include.gl]
+ define math [--.math]
+ define swrast [--.swrast]
+
+.include [----]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [----.include],[--.main],[--.glapi],[--.shader]
+LIBDIR = [----.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)
+
+SOURCES = driverfuncs.c
+
+OBJECTS =driverfuncs.obj
+
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+ @ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
+
+clean :
+ purge
+ delete *.obj;*
+
+driverfuncs.obj : driverfuncs.c
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/common/driverfuncs.c b/nx-X11/extras/Mesa/src/mesa/drivers/common/driverfuncs.c
new file mode 100644
index 000000000..0177490f7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/common/driverfuncs.c
@@ -0,0 +1,233 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "buffers.h"
+#include "context.h"
+#include "framebuffer.h"
+#include "program.h"
+#include "renderbuffer.h"
+#include "texcompress.h"
+#include "texformat.h"
+#include "teximage.h"
+#include "texobj.h"
+#include "texstore.h"
+#if FEATURE_ARB_vertex_buffer_object
+#include "bufferobj.h"
+#endif
+#if FEATURE_EXT_framebuffer_object
+#include "fbobject.h"
+#include "texrender.h"
+#endif
+
+#include "driverfuncs.h"
+#include "swrast/swrast.h"
+#include "tnl/tnl.h"
+
+
+
+/**
+ * Plug in default functions for all pointers in the dd_function_table
+ * structure.
+ * Device drivers should call this function and then plug in any
+ * functions which it wants to override.
+ * Some functions (pointers) MUST be implemented by all drivers (REQUIRED).
+ *
+ * \param table the dd_function_table to initialize
+ */
+void
+_mesa_init_driver_functions(struct dd_function_table *driver)
+{
+ _mesa_bzero(driver, sizeof(*driver));
+
+ driver->GetString = NULL; /* REQUIRED! */
+ driver->UpdateState = NULL; /* REQUIRED! */
+ driver->GetBufferSize = NULL; /* REQUIRED! */
+ driver->ResizeBuffers = _mesa_resize_framebuffer;
+ driver->Error = NULL;
+
+ driver->Finish = NULL;
+ driver->Flush = NULL;
+
+ /* framebuffer/image functions */
+ driver->Clear = _swrast_Clear;
+ driver->Accum = _swrast_Accum;
+ driver->DrawPixels = _swrast_DrawPixels;
+ driver->ReadPixels = _swrast_ReadPixels;
+ driver->CopyPixels = _swrast_CopyPixels;
+ driver->Bitmap = _swrast_Bitmap;
+
+ /* Texture functions */
+ driver->ChooseTextureFormat = _mesa_choose_tex_format;
+ driver->TexImage1D = _mesa_store_teximage1d;
+ driver->TexImage2D = _mesa_store_teximage2d;
+ driver->TexImage3D = _mesa_store_teximage3d;
+ driver->TexSubImage1D = _mesa_store_texsubimage1d;
+ driver->TexSubImage2D = _mesa_store_texsubimage2d;
+ driver->TexSubImage3D = _mesa_store_texsubimage3d;
+ driver->GetTexImage = _mesa_get_teximage;
+ driver->CopyTexImage1D = _swrast_copy_teximage1d;
+ driver->CopyTexImage2D = _swrast_copy_teximage2d;
+ driver->CopyTexSubImage1D = _swrast_copy_texsubimage1d;
+ driver->CopyTexSubImage2D = _swrast_copy_texsubimage2d;
+ driver->CopyTexSubImage3D = _swrast_copy_texsubimage3d;
+ driver->TestProxyTexImage = _mesa_test_proxy_teximage;
+ driver->CompressedTexImage1D = _mesa_store_compressed_teximage1d;
+ driver->CompressedTexImage2D = _mesa_store_compressed_teximage2d;
+ driver->CompressedTexImage3D = _mesa_store_compressed_teximage3d;
+ driver->CompressedTexSubImage1D = _mesa_store_compressed_texsubimage1d;
+ driver->CompressedTexSubImage2D = _mesa_store_compressed_texsubimage2d;
+ driver->CompressedTexSubImage3D = _mesa_store_compressed_texsubimage3d;
+ driver->GetCompressedTexImage = _mesa_get_compressed_teximage;
+ driver->CompressedTextureSize = _mesa_compressed_texture_size;
+ driver->BindTexture = NULL;
+ driver->NewTextureObject = _mesa_new_texture_object;
+ driver->DeleteTexture = _mesa_delete_texture_object;
+ driver->NewTextureImage = _mesa_new_texture_image;
+ driver->FreeTexImageData = _mesa_free_texture_image_data;
+ driver->TextureMemCpy = _mesa_memcpy;
+ driver->IsTextureResident = NULL;
+ driver->PrioritizeTexture = NULL;
+ driver->ActiveTexture = NULL;
+ driver->UpdateTexturePalette = NULL;
+
+ /* imaging */
+ driver->CopyColorTable = _swrast_CopyColorTable;
+ driver->CopyColorSubTable = _swrast_CopyColorSubTable;
+ driver->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ driver->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+
+ /* Vertex/fragment programs */
+ driver->BindProgram = NULL;
+ driver->NewProgram = _mesa_new_program;
+ driver->DeleteProgram = _mesa_delete_program;
+
+ /* simple state commands */
+ driver->AlphaFunc = NULL;
+ driver->BlendColor = NULL;
+ driver->BlendEquationSeparate = NULL;
+ driver->BlendFuncSeparate = NULL;
+ driver->ClearColor = NULL;
+ driver->ClearDepth = NULL;
+ driver->ClearIndex = NULL;
+ driver->ClearStencil = NULL;
+ driver->ClipPlane = NULL;
+ driver->ColorMask = NULL;
+ driver->ColorMaterial = NULL;
+ driver->CullFace = NULL;
+ driver->DrawBuffer = _swrast_DrawBuffer;
+ driver->DrawBuffers = NULL; /***_swrast_DrawBuffers;***/
+ driver->FrontFace = NULL;
+ driver->DepthFunc = NULL;
+ driver->DepthMask = NULL;
+ driver->DepthRange = NULL;
+ driver->Enable = NULL;
+ driver->Fogfv = NULL;
+ driver->Hint = NULL;
+ driver->IndexMask = NULL;
+ driver->Lightfv = NULL;
+ driver->LightModelfv = NULL;
+ driver->LineStipple = NULL;
+ driver->LineWidth = NULL;
+ driver->LogicOpcode = NULL;
+ driver->PointParameterfv = NULL;
+ driver->PointSize = NULL;
+ driver->PolygonMode = NULL;
+ driver->PolygonOffset = NULL;
+ driver->PolygonStipple = NULL;
+ driver->ReadBuffer = NULL;
+ driver->RenderMode = NULL;
+ driver->Scissor = NULL;
+ driver->ShadeModel = NULL;
+ driver->StencilFunc = NULL;
+ driver->StencilMask = NULL;
+ driver->StencilOp = NULL;
+ driver->ActiveStencilFace = NULL;
+ driver->TexGen = NULL;
+ driver->TexEnv = NULL;
+ driver->TexParameter = NULL;
+ driver->TextureMatrix = NULL;
+ driver->Viewport = NULL;
+
+ /* vertex arrays */
+ driver->VertexPointer = NULL;
+ driver->NormalPointer = NULL;
+ driver->ColorPointer = NULL;
+ driver->FogCoordPointer = NULL;
+ driver->IndexPointer = NULL;
+ driver->SecondaryColorPointer = NULL;
+ driver->TexCoordPointer = NULL;
+ driver->EdgeFlagPointer = NULL;
+ driver->VertexAttribPointer = NULL;
+ driver->LockArraysEXT = NULL;
+ driver->UnlockArraysEXT = NULL;
+
+ /* state queries */
+ driver->GetBooleanv = NULL;
+ driver->GetDoublev = NULL;
+ driver->GetFloatv = NULL;
+ driver->GetIntegerv = NULL;
+ driver->GetPointerv = NULL;
+
+#if FEATURE_ARB_vertex_buffer_object
+ driver->NewBufferObject = _mesa_new_buffer_object;
+ driver->DeleteBuffer = _mesa_delete_buffer_object;
+ driver->BindBuffer = NULL;
+ driver->BufferData = _mesa_buffer_data;
+ driver->BufferSubData = _mesa_buffer_subdata;
+ driver->GetBufferSubData = _mesa_buffer_get_subdata;
+ driver->MapBuffer = _mesa_buffer_map;
+ driver->UnmapBuffer = _mesa_buffer_unmap;
+#endif
+
+#if FEATURE_EXT_framebuffer_object
+ driver->NewFramebuffer = _mesa_new_framebuffer;
+ driver->NewRenderbuffer = _mesa_new_soft_renderbuffer;
+ driver->RenderbufferTexture = _mesa_renderbuffer_texture;
+ driver->FramebufferRenderbuffer = _mesa_framebuffer_renderbuffer;
+#endif
+
+ /* T&L stuff */
+ driver->NeedValidate = GL_FALSE;
+ driver->ValidateTnlModule = NULL;
+ driver->CurrentExecPrimitive = 0;
+ driver->CurrentSavePrimitive = 0;
+ driver->NeedFlush = 0;
+ driver->SaveNeedFlush = 0;
+
+ driver->FlushVertices = NULL;
+ driver->SaveFlushVertices = NULL;
+ driver->NotifySaveBegin = NULL;
+ driver->LightingSpaceChange = NULL;
+ driver->MakeCurrent = NULL;
+ driver->ProgramStringNotify = _tnl_program_string;
+
+ /* display list */
+ driver->NewList = NULL;
+ driver->EndList = NULL;
+ driver->BeginCallList = NULL;
+ driver->EndCallList = NULL;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/common/driverfuncs.h b/nx-X11/extras/Mesa/src/mesa/drivers/common/driverfuncs.h
new file mode 100644
index 000000000..64f56d91f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/common/driverfuncs.h
@@ -0,0 +1,32 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef DRIVERFUNCS_H
+#define DRIVERFUNCS_H
+
+extern void
+_mesa_init_driver_functions(struct dd_function_table *driver);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/Makefile
new file mode 100644
index 000000000..8db675431
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/Makefile
@@ -0,0 +1,34 @@
+# src/mesa/drivers/dri/Makefile
+
+TOP = ../../../..
+
+include $(TOP)/configs/current
+
+
+
+default: $(LIB_DIR) subdirs
+
+
+$(LIB_DIR):
+ -mkdir $(LIB_DIR)
+
+
+subdirs:
+ echo $(DRI_DIRS)
+ @for dir in $(DRI_DIRS) ; do \
+ echo $$dir ; \
+ (cd $$dir ; $(MAKE)) || exit 1; \
+ done
+
+
+install:
+ @for dir in $(DRI_DIRS) ; do \
+ (cd $$dir ; $(MAKE) install) || exit 1; \
+ done
+
+
+clean:
+ @for dir in $(DRI_DIRS) ; do \
+ (cd $$dir ; $(MAKE) clean) ; \
+ done
+ -rm -f common/*.o
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/Makefile.template b/nx-X11/extras/Mesa/src/mesa/drivers/dri/Makefile.template
new file mode 100644
index 000000000..c8fef8aac
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/Makefile.template
@@ -0,0 +1,109 @@
+# -*-makefile-*-
+
+MESA_MODULES = $(TOP)/src/mesa/mesa.a
+
+COMMON_SOURCES = \
+ ../../common/driverfuncs.c \
+ ../common/utils.c \
+ ../common/texmem.c \
+ ../common/vblank.c \
+ ../common/dri_util.c \
+ ../common/xmlconfig.c \
+ ../common/drirenderbuffer.c
+
+ifeq ($(WINDOW_SYSTEM),dri)
+WINOBJ=
+WINLIB=
+INCLUDES = $(SHARED_INCLUDES) $(EXPAT_INCLUDES) \
+ `pkg-config --cflags libdrm`
+
+OBJECTS = $(C_SOURCES:.c=.o) \
+ $(ASM_SOURCES:.S=.o)
+
+else
+WINOBJ=
+WINLIB=-L$(MESA)/src/glx/mini
+MINIGLX_INCLUDES = -I$(TOP)/src/glx/mini
+INCLUDES = $(MINIGLX_INCLUDES) \
+ -I$(DRM_SOURCE_PATH)/shared-core \
+ -I$(DRM_SOURCE_PATH)/libdrm \
+ $(SHARED_INCLUDES)
+
+OBJECTS = $(C_SOURCES:.c=.o) \
+ $(MINIGLX_SOURCES:.c=.o) \
+ $(ASM_SOURCES:.S=.o)
+endif
+
+
+### Include directories
+SHARED_INCLUDES = \
+ -I. \
+ -I$(TOP)/src/mesa/drivers/dri/common \
+ -Iserver \
+ -I$(DRM_SOURCE_PATH)/shared-core \
+ -I$(TOP)/include \
+ -I$(TOP)/include/GL/internal \
+ -I$(TOP)/src/mesa \
+ -I$(TOP)/src/mesa/main \
+ -I$(TOP)/src/mesa/glapi \
+ -I$(TOP)/src/mesa/math \
+ -I$(TOP)/src/mesa/transform \
+ -I$(TOP)/src/mesa/shader \
+ -I$(TOP)/src/mesa/swrast \
+ -I$(TOP)/src/mesa/swrast_setup \
+ -I$(TOP)/src/egl/main \
+ -I$(TOP)/src/egl/drivers/dri
+
+##### RULES #####
+
+.c.o:
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+.S.o:
+ $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
+
+
+##### TARGETS #####
+
+default: depend symlinks $(LIBNAME) $(LIB_DIR)/$(LIBNAME)
+
+
+#$(LIB_DIR)/$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(WINOBJ) Makefile
+# @echo BUILDING FOR: $(WINDOW_SYSTEM)
+# $(TOP)/bin/mklib -o $(LIBNAME) -noprefix -install $(LIB_DIR) \
+# $(WINLIB) $(LIB_DEPS) $(WINOBJ) $(MESA_MODULES) $(OBJECTS)
+
+# XXX we should use the mklib script here
+$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(WINOBJ) Makefile $(TOP)/src/mesa/drivers/dri/Makefile.template
+ rm -f $@
+ $(CC) $(ARCH_FLAGS) -o $@ -shared $(OBJECTS) $(MESA_MODULES) $(WINOBJ) $(DRI_LIB_DEPS)
+
+
+$(LIB_DIR)/$(LIBNAME): $(LIBNAME)
+ install $(LIBNAME) $(LIB_DIR)
+
+
+
+# Run 'make depend' to update the dependencies if you change
+# what's included by any source file.
+.PHONY: depend
+depend: $(C_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
+ touch depend
+ $(MKDEP) $(MKDEP_OPTIONS) $(DEFINES) $(INCLUDES) $(C_SOURCES) $(ASM_SOURCES) \
+ > /dev/null
+
+
+# Emacs tags
+tags:
+ etags `find . -name \*.[ch]` `find ../include`
+
+
+# Remove .o and backup files
+clean:
+ -rm -f *.o */*.o *~ *.so *~ server/*.o $(SYMLINKS)
+ -rm -f depend depend.bak
+
+install: $(LIBNAME)
+ install $(LIBNAME) /usr/X11R6/lib/modules/dri/$(LIBNAME)
+
+include depend
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/depthtmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/depthtmp.h
new file mode 100644
index 000000000..1875d157b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/depthtmp.h
@@ -0,0 +1,253 @@
+
+/*
+ * Notes:
+ * 1. These functions plug into the gl_renderbuffer structure.
+ * 2. The 'values' parameter always points to GLuint values, regardless of
+ * the actual Z buffer depth.
+ */
+
+
+#include "spantmp_common.h"
+
+#ifndef DBG
+#define DBG 0
+#endif
+
+#ifndef HAVE_HW_DEPTH_SPANS
+#define HAVE_HW_DEPTH_SPANS 0
+#endif
+
+#ifndef HAVE_HW_DEPTH_PIXELS
+#define HAVE_HW_DEPTH_PIXELS 0
+#endif
+
+static void TAG(WriteDepthSpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *values,
+ const GLubyte mask[] )
+{
+ HW_WRITE_LOCK()
+ {
+ const GLuint *depth = (const GLuint *) values;
+ GLint x1;
+ GLint n1;
+ LOCAL_DEPTH_VARS;
+
+ y = Y_FLIP( y );
+
+#if HAVE_HW_DEPTH_SPANS
+ (void) x1; (void) n1;
+
+ if ( DBG ) fprintf( stderr, "WriteDepthSpan 0..%d (x1 %d)\n",
+ (int)n, (int)x );
+
+ WRITE_DEPTH_SPAN();
+#else
+ HW_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN( x, y, n, x1, n1, i );
+
+ if ( DBG ) fprintf( stderr, "WriteDepthSpan %d..%d (x1 %d) (mask %p)\n",
+ (int)i, (int)n1, (int)x1, mask );
+
+ if ( mask ) {
+ for ( ; n1>0 ; i++, x1++, n1-- ) {
+ if ( mask[i] ) WRITE_DEPTH( x1, y, depth[i] );
+ }
+ } else {
+ for ( ; n1>0 ; i++, x1++, n1-- ) {
+ WRITE_DEPTH( x1, y, depth[i] );
+ }
+ }
+ }
+ HW_ENDCLIPLOOP();
+#endif
+ }
+ HW_WRITE_UNLOCK();
+}
+
+
+#if HAVE_HW_DEPTH_SPANS
+/* implement MonoWriteDepthSpan() in terms of WriteDepthSpan() */
+static void
+TAG(WriteMonoDepthSpan)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *value, const GLubyte mask[] )
+{
+ const GLuint depthVal = *((GLuint *) value);
+ GLuint depths[MAX_WIDTH];
+ GLuint i;
+ for (i = 0; i < n; i++)
+ depths[i] = depthVal;
+ TAG(WriteDepthSpan)(ctx, rb, n, x, y, depths, mask);
+}
+#else
+static void TAG(WriteMonoDepthSpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *value,
+ const GLubyte mask[] )
+{
+ HW_WRITE_LOCK()
+ {
+ const GLuint depth = *((GLuint *) value);
+ GLint x1;
+ GLint n1;
+ LOCAL_DEPTH_VARS;
+
+ y = Y_FLIP( y );
+
+ HW_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN( x, y, n, x1, n1, i );
+
+ if ( DBG ) fprintf( stderr, "%s %d..%d (x1 %d) = %u\n",
+ __FUNCTION__, (int)i, (int)n1, (int)x1, (GLuint)depth );
+
+ if ( mask ) {
+ for ( ; n1>0 ; i++, x1++, n1-- ) {
+ if ( mask[i] ) WRITE_DEPTH( x1, y, depth );
+ }
+ } else {
+ for ( ; n1>0 ; x1++, n1-- ) {
+ WRITE_DEPTH( x1, y, depth );
+ }
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_WRITE_UNLOCK();
+}
+#endif
+
+
+static void TAG(WriteDepthPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n,
+ const GLint x[],
+ const GLint y[],
+ const void *values,
+ const GLubyte mask[] )
+{
+ HW_WRITE_LOCK()
+ {
+ const GLuint *depth = (const GLuint *) values;
+ GLuint i;
+ LOCAL_DEPTH_VARS;
+
+ if ( DBG ) fprintf( stderr, "WriteDepthPixels\n" );
+
+#if HAVE_HW_DEPTH_PIXELS
+ (void) i;
+
+ WRITE_DEPTH_PIXELS();
+#else
+ HW_CLIPLOOP()
+ {
+ if ( mask ) {
+ for ( i = 0 ; i < n ; i++ ) {
+ if ( mask[i] ) {
+ const int fy = Y_FLIP( y[i] );
+ if ( CLIPPIXEL( x[i], fy ) )
+ WRITE_DEPTH( x[i], fy, depth[i] );
+ }
+ }
+ }
+ else {
+ for ( i = 0 ; i < n ; i++ ) {
+ const int fy = Y_FLIP( y[i] );
+ if ( CLIPPIXEL( x[i], fy ) )
+ WRITE_DEPTH( x[i], fy, depth[i] );
+ }
+ }
+ }
+ HW_ENDCLIPLOOP();
+#endif
+ }
+ HW_WRITE_UNLOCK();
+}
+
+
+/* Read depth spans and pixels
+ */
+static void TAG(ReadDepthSpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ void *values )
+{
+ HW_READ_LOCK()
+ {
+ GLuint *depth = (GLuint *) values;
+ GLint x1, n1;
+ LOCAL_DEPTH_VARS;
+
+ y = Y_FLIP( y );
+
+ if ( DBG ) fprintf( stderr, "ReadDepthSpan\n" );
+
+#if HAVE_HW_DEPTH_SPANS
+ (void) x1; (void) n1;
+
+ READ_DEPTH_SPAN();
+#else
+ HW_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN( x, y, n, x1, n1, i );
+ for ( ; n1>0 ; i++, n1-- ) {
+ READ_DEPTH( depth[i], x+i, y );
+ }
+ }
+ HW_ENDCLIPLOOP();
+#endif
+ }
+ HW_READ_UNLOCK();
+}
+
+static void TAG(ReadDepthPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ void *values )
+{
+ HW_READ_LOCK()
+ {
+ GLuint *depth = (GLuint *) values;
+ GLuint i;
+ LOCAL_DEPTH_VARS;
+
+ if ( DBG ) fprintf( stderr, "ReadDepthPixels\n" );
+
+#if HAVE_HW_DEPTH_PIXELS
+ (void) i;
+
+ READ_DEPTH_PIXELS();
+#else
+ HW_CLIPLOOP()
+ {
+ for ( i = 0 ; i < n ;i++ ) {
+ int fy = Y_FLIP( y[i] );
+ if ( CLIPPIXEL( x[i], fy ) )
+ READ_DEPTH( depth[i], x[i], fy );
+ }
+ }
+ HW_ENDCLIPLOOP();
+#endif
+ }
+ HW_READ_UNLOCK();
+}
+
+
+#if HAVE_HW_DEPTH_SPANS
+#undef WRITE_DEPTH_SPAN
+#undef WRITE_DEPTH_PIXELS
+#undef READ_DEPTH_SPAN
+#undef READ_DEPTH_PIXELS
+#else
+#undef WRITE_DEPTH
+#undef READ_DEPTH
+#endif
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/dri_util.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/dri_util.c
new file mode 100644
index 000000000..3edeb03f9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/dri_util.c
@@ -0,0 +1,1073 @@
+/* $XFree86: xc/lib/GL/dri/dri_util.c,v 1.7 2003/04/28 17:01:25 dawes Exp $ */
+/**
+ * \file dri_util.c
+ * DRI utility functions.
+ *
+ * This module acts as glue between GLX and the actual hardware driver. A DRI
+ * driver doesn't really \e have to use any of this - it's optional. But, some
+ * useful stuff is done here that otherwise would have to be duplicated in most
+ * drivers.
+ *
+ * Basically, these utility functions take care of some of the dirty details of
+ * screen initialization, context creation, context binding, DRM setup, etc.
+ *
+ * These functions are compiled into each DRI driver so libGL.so knows nothing
+ * about them.
+ */
+
+
+#include <assert.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <stdio.h>
+
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+#include "imports.h"
+#define None 0
+
+#include "dri_util.h"
+#include "drm_sarea.h"
+
+#ifndef GLX_OML_sync_control
+typedef GLboolean ( * PFNGLXGETMSCRATEOMLPROC) (__DRInativeDisplay *dpy, __DRIid drawable, int32_t *numerator, int32_t *denominator);
+#endif
+
+/* This pointer *must* be set by the driver's __driCreateNewScreen funciton!
+ */
+const __DRIinterfaceMethods * dri_interface = NULL;
+
+/**
+ * This is used in a couple of places that call \c driCreateNewDrawable.
+ */
+static const int empty_attribute_list[1] = { None };
+
+
+/**
+ * Cached copy of the internal API version used by libGL and the client-side
+ * DRI driver.
+ */
+static int api_ver = 0;
+
+/* forward declarations */
+static int driQueryFrameTracking( __DRInativeDisplay * dpy, void * priv,
+ int64_t * sbc, int64_t * missedFrames, float * lastMissedUsage,
+ float * usage );
+
+static void *driCreateNewDrawable(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
+ __DRIid draw, __DRIdrawable *pdraw, int renderType, const int *attrs);
+
+static void driDestroyDrawable(__DRInativeDisplay *dpy, void *drawablePrivate);
+
+
+/**
+ * Print message to \c stderr if the \c LIBGL_DEBUG environment variable
+ * is set.
+ *
+ * Is called from the drivers.
+ *
+ * \param f \c printf like format string.
+ */
+void
+__driUtilMessage(const char *f, ...)
+{
+ va_list args;
+
+ if (getenv("LIBGL_DEBUG")) {
+ fprintf(stderr, "libGL error: \n");
+ va_start(args, f);
+ vfprintf(stderr, f, args);
+ va_end(args);
+ fprintf(stderr, "\n");
+ }
+}
+
+
+/*****************************************************************/
+/** \name Drawable list management */
+/*****************************************************************/
+/*@{*/
+
+static GLboolean __driAddDrawable(void *drawHash, __DRIdrawable *pdraw)
+{
+ __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private;
+
+ if (drmHashInsert(drawHash, pdp->draw, pdraw))
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
+static __DRIdrawable *__driFindDrawable(void *drawHash, __DRIid draw)
+{
+ int retcode;
+ __DRIdrawable *pdraw;
+
+ retcode = drmHashLookup(drawHash, draw, (void *)&pdraw);
+ if (retcode)
+ return NULL;
+
+ return pdraw;
+}
+
+
+/**
+ * Find drawables in the local hash that have been destroyed on the
+ * server.
+ *
+ * \param drawHash Hash-table containing all know drawables.
+ */
+static void __driGarbageCollectDrawables(void *drawHash)
+{
+ __DRIid draw;
+ __DRInativeDisplay *dpy;
+ __DRIdrawable *pdraw;
+
+ if (drmHashFirst(drawHash, &draw, (void *)&pdraw) == 1) {
+ do {
+ __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private;
+ dpy = pdp->driScreenPriv->display;
+ if (! (*dri_interface->windowExists)(dpy, draw)) {
+ /* Destroy the local drawable data, if the drawable no
+ longer exists in the Xserver */
+ (*pdraw->destroyDrawable)(dpy, pdraw->private);
+ _mesa_free(pdraw);
+ }
+ } while (drmHashNext(drawHash, &draw, (void *)&pdraw) == 1);
+ }
+}
+
+/*@}*/
+
+
+/*****************************************************************/
+/** \name Context (un)binding functions */
+/*****************************************************************/
+/*@{*/
+
+/**
+ * Unbind context.
+ *
+ * \param dpy the display handle.
+ * \param scrn the screen number.
+ * \param draw drawable.
+ * \param read Current reading drawable.
+ * \param gc context.
+ *
+ * \return \c GL_TRUE on success, or \c GL_FALSE on failure.
+ *
+ * \internal
+ * This function calls __DriverAPIRec::UnbindContext, and then decrements
+ * __DRIdrawablePrivateRec::refcount which must be non-zero for a successful
+ * return.
+ *
+ * While casting the opaque private pointers associated with the parameters
+ * into their respective real types it also assures they are not \c NULL.
+ */
+static GLboolean driUnbindContext(__DRInativeDisplay *dpy, int scrn,
+ __DRIid draw, __DRIid read,
+ __DRIcontext *ctx)
+{
+ __DRIscreen *pDRIScreen;
+ __DRIdrawable *pdraw;
+ __DRIdrawable *pread;
+ __DRIcontextPrivate *pcp;
+ __DRIscreenPrivate *psp;
+ __DRIdrawablePrivate *pdp;
+ __DRIdrawablePrivate *prp;
+
+ /*
+ ** Assume error checking is done properly in glXMakeCurrent before
+ ** calling driUnbindContext.
+ */
+
+ if (ctx == NULL || draw == None || read == None) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ pDRIScreen = (*dri_interface->getScreen)(dpy, scrn);
+ if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ psp = (__DRIscreenPrivate *)pDRIScreen->private;
+ pcp = (__DRIcontextPrivate *)ctx->private;
+
+ pdraw = __driFindDrawable(psp->drawHash, draw);
+ if (!pdraw) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+ pdp = (__DRIdrawablePrivate *)pdraw->private;
+
+ pread = __driFindDrawable(psp->drawHash, read);
+ if (!pread) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+ prp = (__DRIdrawablePrivate *)pread->private;
+
+
+ /* Let driver unbind drawable from context */
+ (*psp->DriverAPI.UnbindContext)(pcp);
+
+
+ if (pdp->refcount == 0) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ pdp->refcount--;
+
+ if (prp != pdp) {
+ if (prp->refcount == 0) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ prp->refcount--;
+ }
+
+
+ /* XXX this is disabled so that if we call SwapBuffers on an unbound
+ * window we can determine the last context bound to the window and
+ * use that context's lock. (BrianP, 2-Dec-2000)
+ */
+#if 0
+ /* Unbind the drawable */
+ pcp->driDrawablePriv = NULL;
+ pdp->driContextPriv = &psp->dummyContextPriv;
+#endif
+
+ return GL_TRUE;
+}
+
+
+/**
+ * This function takes both a read buffer and a draw buffer. This is needed
+ * for \c glXMakeCurrentReadSGI or GLX 1.3's \c glXMakeContextCurrent
+ * function.
+ *
+ * \bug This function calls \c driCreateNewDrawable in two places with the
+ * \c renderType hard-coded to \c GLX_WINDOW_BIT. Some checking might
+ * be needed in those places when support for pbuffers and / or pixmaps
+ * is added. Is it safe to assume that the drawable is a window?
+ */
+static GLboolean DoBindContext(__DRInativeDisplay *dpy,
+ __DRIid draw, __DRIid read,
+ __DRIcontext *ctx, const __GLcontextModes * modes,
+ __DRIscreenPrivate *psp)
+{
+ __DRIdrawable *pdraw;
+ __DRIdrawablePrivate *pdp;
+ __DRIdrawable *pread;
+ __DRIdrawablePrivate *prp;
+ __DRIcontextPrivate * const pcp = ctx->private;
+
+
+ /* Find the _DRIdrawable which corresponds to the writing drawable. */
+ pdraw = __driFindDrawable(psp->drawHash, draw);
+ if (!pdraw) {
+ /* Allocate a new drawable */
+ pdraw = (__DRIdrawable *)_mesa_malloc(sizeof(__DRIdrawable));
+ if (!pdraw) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ /* Create a new drawable */
+ driCreateNewDrawable(dpy, modes, draw, pdraw, GLX_WINDOW_BIT,
+ empty_attribute_list);
+ if (!pdraw->private) {
+ /* ERROR!!! */
+ _mesa_free(pdraw);
+ return GL_FALSE;
+ }
+
+ }
+ pdp = (__DRIdrawablePrivate *) pdraw->private;
+
+ /* Find the _DRIdrawable which corresponds to the reading drawable. */
+ if (read == draw) {
+ /* read buffer == draw buffer */
+ prp = pdp;
+ }
+ else {
+ pread = __driFindDrawable(psp->drawHash, read);
+ if (!pread) {
+ /* Allocate a new drawable */
+ pread = (__DRIdrawable *)_mesa_malloc(sizeof(__DRIdrawable));
+ if (!pread) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ /* Create a new drawable */
+ driCreateNewDrawable(dpy, modes, read, pread, GLX_WINDOW_BIT,
+ empty_attribute_list);
+ if (!pread->private) {
+ /* ERROR!!! */
+ _mesa_free(pread);
+ return GL_FALSE;
+ }
+ }
+ prp = (__DRIdrawablePrivate *) pread->private;
+ }
+
+ /* Bind the drawable to the context */
+ pcp->driDrawablePriv = pdp;
+ pdp->driContextPriv = pcp;
+ pdp->refcount++;
+ if ( pdp != prp ) {
+ prp->refcount++;
+ }
+
+ /*
+ ** Now that we have a context associated with this drawable, we can
+ ** initialize the drawable information if has not been done before.
+ */
+ if (!pdp->pStamp || *pdp->pStamp != pdp->lastStamp) {
+ DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
+ __driUtilUpdateDrawableInfo(pdp);
+ DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
+ }
+
+ /* Call device-specific MakeCurrent */
+ (*psp->DriverAPI.MakeCurrent)(pcp, pdp, prp);
+
+ return GL_TRUE;
+}
+
+
+/**
+ * This function takes both a read buffer and a draw buffer. This is needed
+ * for \c glXMakeCurrentReadSGI or GLX 1.3's \c glXMakeContextCurrent
+ * function.
+ */
+static GLboolean driBindContext(__DRInativeDisplay *dpy, int scrn,
+ __DRIid draw, __DRIid read,
+ __DRIcontext * ctx)
+{
+ __DRIscreen *pDRIScreen;
+
+ /*
+ ** Assume error checking is done properly in glXMakeCurrent before
+ ** calling driBindContext.
+ */
+
+ if (ctx == NULL || draw == None || read == None) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ pDRIScreen = (*dri_interface->getScreen)(dpy, scrn);
+ if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
+ /* ERROR!!! */
+ return GL_FALSE;
+ }
+
+ return DoBindContext( dpy, draw, read, ctx, ctx->mode,
+ (__DRIscreenPrivate *)pDRIScreen->private );
+}
+/*@}*/
+
+
+/*****************************************************************/
+/** \name Drawable handling functions */
+/*****************************************************************/
+/*@{*/
+
+/**
+ * Update private drawable information.
+ *
+ * \param pdp pointer to the private drawable information to update.
+ *
+ * This function basically updates the __DRIdrawablePrivate struct's
+ * cliprect information by calling \c __DRIinterfaceMethods::getDrawableInfo.
+ * This is usually called by the DRI_VALIDATE_DRAWABLE_INFO macro which
+ * compares the __DRIdrwablePrivate pStamp and lastStamp values. If
+ * the values are different that means we have to update the clipping
+ * info.
+ */
+void
+__driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp)
+{
+ __DRIscreenPrivate *psp;
+ __DRIcontextPrivate *pcp = pdp->driContextPriv;
+
+ if (!pcp || (pdp != pcp->driDrawablePriv)) {
+ /* ERROR!!! */
+ return;
+ }
+
+ psp = pdp->driScreenPriv;
+ if (!psp) {
+ /* ERROR!!! */
+ return;
+ }
+
+ if (pdp->pClipRects) {
+ _mesa_free(pdp->pClipRects);
+ }
+
+ if (pdp->pBackClipRects) {
+ _mesa_free(pdp->pBackClipRects);
+ }
+
+ DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
+
+ if (!__driFindDrawable(psp->drawHash, pdp->draw) ||
+ ! (*dri_interface->getDrawableInfo)(pdp->display, pdp->screen, pdp->draw,
+ &pdp->index, &pdp->lastStamp,
+ &pdp->x, &pdp->y, &pdp->w, &pdp->h,
+ &pdp->numClipRects, &pdp->pClipRects,
+ &pdp->backX,
+ &pdp->backY,
+ &pdp->numBackClipRects,
+ &pdp->pBackClipRects )) {
+ /* Error -- eg the window may have been destroyed. Keep going
+ * with no cliprects.
+ */
+ pdp->pStamp = &pdp->lastStamp; /* prevent endless loop */
+ pdp->numClipRects = 0;
+ pdp->pClipRects = NULL;
+ pdp->numBackClipRects = 0;
+ pdp->pBackClipRects = NULL;
+ }
+ else
+ pdp->pStamp = &(psp->pSAREA->drawableTable[pdp->index].stamp);
+
+ DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID);
+
+}
+
+/*@}*/
+
+/*****************************************************************/
+/** \name GLX callbacks */
+/*****************************************************************/
+/*@{*/
+
+/**
+ * Swap buffers.
+ *
+ * \param dpy the display handle.
+ * \param drawablePrivate opaque pointer to the per-drawable private info.
+ *
+ * \internal
+ * This function calls __DRIdrawablePrivate::swapBuffers.
+ *
+ * Is called directly from glXSwapBuffers().
+ */
+static void driSwapBuffers( __DRInativeDisplay *dpy, void *drawablePrivate )
+{
+ __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
+ dPriv->swapBuffers(dPriv);
+ (void) dpy;
+}
+
+/**
+ * Called directly from a number of higher-level GLX functions.
+ */
+static int driGetMSC( void *screenPrivate, int64_t *msc )
+{
+ __DRIscreenPrivate *sPriv = (__DRIscreenPrivate *) screenPrivate;
+
+ return sPriv->DriverAPI.GetMSC( sPriv, msc );
+}
+
+/**
+ * Called directly from a number of higher-level GLX functions.
+ */
+static int driGetSBC( __DRInativeDisplay *dpy, void *drawablePrivate, int64_t *sbc )
+{
+ __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
+ __DRIswapInfo sInfo;
+ int status;
+
+
+ status = dPriv->driScreenPriv->DriverAPI.GetSwapInfo( dPriv, & sInfo );
+ *sbc = sInfo.swap_count;
+
+ return status;
+}
+
+static int driWaitForSBC( __DRInativeDisplay * dpy, void *drawablePriv,
+ int64_t target_sbc,
+ int64_t * msc, int64_t * sbc )
+{
+ __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePriv;
+
+ return dPriv->driScreenPriv->DriverAPI.WaitForSBC( dPriv, target_sbc,
+ msc, sbc );
+}
+
+static int driWaitForMSC( __DRInativeDisplay * dpy, void *drawablePriv,
+ int64_t target_msc,
+ int64_t divisor, int64_t remainder,
+ int64_t * msc, int64_t * sbc )
+{
+ __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePriv;
+ __DRIswapInfo sInfo;
+ int status;
+
+
+ status = dPriv->driScreenPriv->DriverAPI.WaitForMSC( dPriv, target_msc,
+ divisor, remainder,
+ msc );
+
+ /* GetSwapInfo() may not be provided by the driver if GLX_SGI_video_sync
+ * is supported but GLX_OML_sync_control is not. Therefore, don't return
+ * an error value if GetSwapInfo() is not implemented.
+ */
+ if ( status == 0
+ && dPriv->driScreenPriv->DriverAPI.GetSwapInfo ) {
+ status = dPriv->driScreenPriv->DriverAPI.GetSwapInfo( dPriv, & sInfo );
+ *sbc = sInfo.swap_count;
+ }
+
+ return status;
+}
+
+static int64_t driSwapBuffersMSC( __DRInativeDisplay * dpy, void *drawablePriv,
+ int64_t target_msc,
+ int64_t divisor, int64_t remainder )
+{
+ __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePriv;
+
+ return dPriv->driScreenPriv->DriverAPI.SwapBuffersMSC( dPriv, target_msc,
+ divisor,
+ remainder );
+}
+
+
+/**
+ * This is called via __DRIscreenRec's createNewDrawable pointer.
+ */
+static void *driCreateNewDrawable(__DRInativeDisplay *dpy,
+ const __GLcontextModes *modes,
+ __DRIid draw,
+ __DRIdrawable *pdraw,
+ int renderType,
+ const int *attrs)
+{
+ __DRIscreen * const pDRIScreen = (*dri_interface->getScreen)(dpy, modes->screen);
+ __DRIscreenPrivate *psp;
+ __DRIdrawablePrivate *pdp;
+
+
+ pdraw->private = NULL;
+
+ /* Since pbuffers are not yet supported, no drawable attributes are
+ * supported either.
+ */
+ (void) attrs;
+
+ if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
+ return NULL;
+ }
+
+ pdp = (__DRIdrawablePrivate *)_mesa_malloc(sizeof(__DRIdrawablePrivate));
+ if (!pdp) {
+ return NULL;
+ }
+
+ if (!(*dri_interface->createDrawable)(dpy, modes->screen, draw, &pdp->hHWDrawable)) {
+ _mesa_free(pdp);
+ return NULL;
+ }
+
+ pdp->draw = draw;
+ pdp->pdraw = pdraw;
+ pdp->refcount = 0;
+ pdp->pStamp = NULL;
+ pdp->lastStamp = 0;
+ pdp->index = 0;
+ pdp->x = 0;
+ pdp->y = 0;
+ pdp->w = 0;
+ pdp->h = 0;
+ pdp->numClipRects = 0;
+ pdp->numBackClipRects = 0;
+ pdp->pClipRects = NULL;
+ pdp->pBackClipRects = NULL;
+ pdp->display = dpy;
+ pdp->screen = modes->screen;
+
+ psp = (__DRIscreenPrivate *)pDRIScreen->private;
+ pdp->driScreenPriv = psp;
+ pdp->driContextPriv = &psp->dummyContextPriv;
+
+ if (!(*psp->DriverAPI.CreateBuffer)(psp, pdp, modes,
+ renderType == GLX_PIXMAP_BIT)) {
+ (void)(*dri_interface->destroyDrawable)(dpy, modes->screen, pdp->draw);
+ _mesa_free(pdp);
+ return NULL;
+ }
+
+ pdraw->private = pdp;
+ pdraw->destroyDrawable = driDestroyDrawable;
+ pdraw->swapBuffers = driSwapBuffers; /* called by glXSwapBuffers() */
+
+ pdraw->getSBC = driGetSBC;
+ pdraw->waitForSBC = driWaitForSBC;
+ pdraw->waitForMSC = driWaitForMSC;
+ pdraw->swapBuffersMSC = driSwapBuffersMSC;
+ pdraw->frameTracking = NULL;
+ pdraw->queryFrameTracking = driQueryFrameTracking;
+
+ /* This special default value is replaced with the configured
+ * default value when the drawable is first bound to a direct
+ * rendering context.
+ */
+ pdraw->swap_interval = (unsigned)-1;
+
+ pdp->swapBuffers = psp->DriverAPI.SwapBuffers;
+
+ /* Add pdraw to drawable list */
+ if (!__driAddDrawable(psp->drawHash, pdraw)) {
+ /* ERROR!!! */
+ (*pdraw->destroyDrawable)(dpy, pdp);
+ _mesa_free(pdp);
+ pdp = NULL;
+ pdraw->private = NULL;
+ }
+
+ return (void *) pdp;
+}
+
+static __DRIdrawable *driGetDrawable(__DRInativeDisplay *dpy, __DRIid draw,
+ void *screenPrivate)
+{
+ __DRIscreenPrivate *psp = (__DRIscreenPrivate *) screenPrivate;
+
+ /*
+ ** Make sure this routine returns NULL if the drawable is not bound
+ ** to a direct rendering context!
+ */
+ return __driFindDrawable(psp->drawHash, draw);
+}
+
+static void driDestroyDrawable(__DRInativeDisplay *dpy, void *drawablePrivate)
+{
+ __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *) drawablePrivate;
+ __DRIscreenPrivate *psp = pdp->driScreenPriv;
+ int scrn = psp->myNum;
+
+ if (pdp) {
+ (*psp->DriverAPI.DestroyBuffer)(pdp);
+ if ((*dri_interface->windowExists)(dpy, pdp->draw))
+ (void)(*dri_interface->destroyDrawable)(dpy, scrn, pdp->draw);
+ drmHashDelete(psp->drawHash, pdp->draw);
+ if (pdp->pClipRects) {
+ _mesa_free(pdp->pClipRects);
+ pdp->pClipRects = NULL;
+ }
+ if (pdp->pBackClipRects) {
+ _mesa_free(pdp->pBackClipRects);
+ pdp->pBackClipRects = NULL;
+ }
+ _mesa_free(pdp);
+ }
+}
+
+/*@}*/
+
+
+/*****************************************************************/
+/** \name Context handling functions */
+/*****************************************************************/
+/*@{*/
+
+/**
+ * Destroy the per-context private information.
+ *
+ * \param dpy the display handle.
+ * \param scrn the screen number.
+ * \param contextPrivate opaque pointer to the per-drawable private info.
+ *
+ * \internal
+ * This function calls __DriverAPIRec::DestroyContext on \p contextPrivate, calls
+ * drmDestroyContext(), and finally frees \p contextPrivate.
+ */
+static void driDestroyContext(__DRInativeDisplay *dpy, int scrn, void *contextPrivate)
+{
+ __DRIcontextPrivate *pcp = (__DRIcontextPrivate *) contextPrivate;
+
+ if (pcp) {
+ (*pcp->driScreenPriv->DriverAPI.DestroyContext)(pcp);
+ __driGarbageCollectDrawables(pcp->driScreenPriv->drawHash);
+ (void) (*dri_interface->destroyContext)(dpy, scrn, pcp->contextID);
+ _mesa_free(pcp);
+ }
+}
+
+
+/**
+ * Create the per-drawable private driver information.
+ *
+ * \param dpy The display handle.
+ * \param modes Mode used to create the new context.
+ * \param render_type Type of rendering target. \c GLX_RGBA is the only
+ * type likely to ever be supported for direct-rendering.
+ * \param sharedPrivate The shared context dependent methods or \c NULL if
+ * non-existent.
+ * \param pctx DRI context to receive the context dependent methods.
+ *
+ * \returns An opaque pointer to the per-context private information on
+ * success, or \c NULL on failure.
+ *
+ * \internal
+ * This function allocates and fills a __DRIcontextPrivateRec structure. It
+ * performs some device independent initialization and passes all the
+ * relevent information to __DriverAPIRec::CreateContext to create the
+ * context.
+ *
+ */
+static void *
+driCreateNewContext(__DRInativeDisplay *dpy, const __GLcontextModes *modes,
+ int render_type, void *sharedPrivate, __DRIcontext *pctx)
+{
+ __DRIscreen *pDRIScreen;
+ __DRIcontextPrivate *pcp;
+ __DRIcontextPrivate *pshare = (__DRIcontextPrivate *) sharedPrivate;
+ __DRIscreenPrivate *psp;
+ void * const shareCtx = (pshare != NULL) ? pshare->driverPrivate : NULL;
+
+ pDRIScreen = (*dri_interface->getScreen)(dpy, modes->screen);
+ if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) {
+ /* ERROR!!! */
+ return NULL;
+ }
+
+ psp = (__DRIscreenPrivate *)pDRIScreen->private;
+
+ pcp = (__DRIcontextPrivate *)_mesa_malloc(sizeof(__DRIcontextPrivate));
+ if (!pcp) {
+ return NULL;
+ }
+
+ if (! (*dri_interface->createContext)(dpy, modes->screen, modes->fbconfigID,
+ &pcp->contextID, &pcp->hHWContext)) {
+ _mesa_free(pcp);
+ return NULL;
+ }
+
+ pcp->display = dpy;
+ pcp->driScreenPriv = psp;
+ pcp->driDrawablePriv = NULL;
+
+ /* When the first context is created for a screen, initialize a "dummy"
+ * context.
+ */
+
+ if (!psp->dummyContextPriv.driScreenPriv) {
+ psp->dummyContextPriv.contextID = 0;
+ psp->dummyContextPriv.hHWContext = psp->pSAREA->dummy_context;
+ psp->dummyContextPriv.driScreenPriv = psp;
+ psp->dummyContextPriv.driDrawablePriv = NULL;
+ psp->dummyContextPriv.driverPrivate = NULL;
+ /* No other fields should be used! */
+ }
+
+ pctx->destroyContext = driDestroyContext;
+ pctx->bindContext = driBindContext;
+ pctx->unbindContext = driUnbindContext;
+
+ if ( !(*psp->DriverAPI.CreateContext)(modes, pcp, shareCtx) ) {
+ (void) (*dri_interface->destroyContext)(dpy, modes->screen,
+ pcp->contextID);
+ _mesa_free(pcp);
+ return NULL;
+ }
+
+ __driGarbageCollectDrawables(pcp->driScreenPriv->drawHash);
+
+ return pcp;
+}
+/*@}*/
+
+
+/*****************************************************************/
+/** \name Screen handling functions */
+/*****************************************************************/
+/*@{*/
+
+/**
+ * Destroy the per-screen private information.
+ *
+ * \param dpy the display handle.
+ * \param scrn the screen number.
+ * \param screenPrivate opaque pointer to the per-screen private information.
+ *
+ * \internal
+ * This function calls __DriverAPIRec::DestroyScreen on \p screenPrivate, calls
+ * drmClose(), and finally frees \p screenPrivate.
+ */
+static void driDestroyScreen(__DRInativeDisplay *dpy, int scrn, void *screenPrivate)
+{
+ __DRIscreenPrivate *psp = (__DRIscreenPrivate *) screenPrivate;
+
+ if (psp) {
+ /* No interaction with the X-server is possible at this point. This
+ * routine is called after XCloseDisplay, so there is no protocol
+ * stream open to the X-server anymore.
+ */
+
+ if (psp->DriverAPI.DestroyScreen)
+ (*psp->DriverAPI.DestroyScreen)(psp);
+
+ (void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX);
+ (void)drmUnmap((drmAddress)psp->pFB, psp->fbSize);
+ _mesa_free(psp->pDevPriv);
+ (void)drmClose(psp->fd);
+ if ( psp->modes != NULL ) {
+ (*dri_interface->destroyContextModes)( psp->modes );
+ }
+ _mesa_free(psp);
+ }
+}
+
+
+/**
+ * Utility function used to create a new driver-private screen structure.
+ *
+ * \param dpy Display pointer
+ * \param scrn Index of the screen
+ * \param psc DRI screen data (not driver private)
+ * \param modes Linked list of known display modes. This list is, at a
+ * minimum, a list of modes based on the current display mode.
+ * These roughly match the set of available X11 visuals, but it
+ * need not be limited to X11! The calling libGL should create
+ * a list that will inform the driver of the current display
+ * mode (i.e., color buffer depth, depth buffer depth, etc.).
+ * \param ddx_version Version of the 2D DDX. This may not be meaningful for
+ * all drivers.
+ * \param dri_version Version of the "server-side" DRI.
+ * \param drm_version Version of the kernel DRM.
+ * \param frame_buffer Data describing the location and layout of the
+ * framebuffer.
+ * \param pSAREA Pointer the the SAREA.
+ * \param fd Device handle for the DRM.
+ * \param internal_api_version Version of the internal interface between the
+ * driver and libGL.
+ * \param driverAPI Driver API functions used by other routines in dri_util.c.
+ *
+ * \note
+ * There is no need to check the minimum API version in this function. Since
+ * the \c __driCreateNewScreen function is versioned, it is impossible for a
+ * loader that is too old to even load this driver.
+ */
+__DRIscreenPrivate *
+__driUtilCreateNewScreen(__DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
+ __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drm_sarea_t *pSAREA,
+ int fd,
+ int internal_api_version,
+ const struct __DriverAPIRec *driverAPI)
+{
+ __DRIscreenPrivate *psp;
+
+
+ api_ver = internal_api_version;
+
+ psp = (__DRIscreenPrivate *)_mesa_malloc(sizeof(__DRIscreenPrivate));
+ if (!psp) {
+ return NULL;
+ }
+
+ /* Create the hash table */
+ psp->drawHash = drmHashCreate();
+ if ( psp->drawHash == NULL ) {
+ _mesa_free( psp );
+ return NULL;
+ }
+
+ psp->display = dpy;
+ psp->myNum = scrn;
+ psp->psc = psc;
+ psp->modes = modes;
+
+ /*
+ ** NOT_DONE: This is used by the X server to detect when the client
+ ** has died while holding the drawable lock. The client sets the
+ ** drawable lock to this value.
+ */
+ psp->drawLockID = 1;
+
+ psp->drmMajor = drm_version->major;
+ psp->drmMinor = drm_version->minor;
+ psp->drmPatch = drm_version->patch;
+ psp->ddxMajor = ddx_version->major;
+ psp->ddxMinor = ddx_version->minor;
+ psp->ddxPatch = ddx_version->patch;
+ psp->driMajor = dri_version->major;
+ psp->driMinor = dri_version->minor;
+ psp->driPatch = dri_version->patch;
+
+ /* install driver's callback functions */
+ memcpy( &psp->DriverAPI, driverAPI, sizeof(struct __DriverAPIRec) );
+
+ psp->pSAREA = pSAREA;
+
+ psp->pFB = frame_buffer->base;
+ psp->fbSize = frame_buffer->size;
+ psp->fbStride = frame_buffer->stride;
+ psp->fbWidth = frame_buffer->width;
+ psp->fbHeight = frame_buffer->height;
+ psp->devPrivSize = frame_buffer->dev_priv_size;
+ psp->pDevPriv = frame_buffer->dev_priv;
+ psp->fbBPP = psp->fbStride * 8 / frame_buffer->width;
+
+ psp->fd = fd;
+
+ /*
+ ** Do not init dummy context here; actual initialization will be
+ ** done when the first DRI context is created. Init screen priv ptr
+ ** to NULL to let CreateContext routine that it needs to be inited.
+ */
+ psp->dummyContextPriv.driScreenPriv = NULL;
+
+ psc->destroyScreen = driDestroyScreen;
+ psc->createNewDrawable = driCreateNewDrawable;
+ psc->getDrawable = driGetDrawable;
+ psc->getMSC = driGetMSC;
+ psc->createNewContext = driCreateNewContext;
+
+ if ( (psp->DriverAPI.InitDriver != NULL)
+ && !(*psp->DriverAPI.InitDriver)(psp) ) {
+ _mesa_free( psp );
+ return NULL;
+ }
+
+
+ return psp;
+}
+
+
+/**
+ * Compare the current GLX API version with a driver supplied required version.
+ *
+ * The minimum required version is compared with the API version exported by
+ * the \c __glXGetInternalVersion function (in libGL.so).
+ *
+ * \param required_version Minimum required internal GLX API version.
+ * \return A tri-value return, as from strcmp is returned. A value less
+ * than, equal to, or greater than zero will be returned if the
+ * internal GLX API version is less than, equal to, or greater
+ * than \c required_version.
+ *
+ * \sa __glXGetInternalVersion().
+ */
+int driCompareGLXAPIVersion( GLint required_version )
+{
+ if ( api_ver > required_version ) {
+ return 1;
+ }
+ else if ( api_ver == required_version ) {
+ return 0;
+ }
+
+ return -1;
+}
+
+
+static int
+driQueryFrameTracking( __DRInativeDisplay * dpy, void * priv,
+ int64_t * sbc, int64_t * missedFrames,
+ float * lastMissedUsage, float * usage )
+{
+ __DRIswapInfo sInfo;
+ int status;
+ int64_t ust;
+ __DRIdrawablePrivate * dpriv = (__DRIdrawablePrivate *) priv;
+
+
+ status = dpriv->driScreenPriv->DriverAPI.GetSwapInfo( dpriv, & sInfo );
+ if ( status == 0 ) {
+ *sbc = sInfo.swap_count;
+ *missedFrames = sInfo.swap_missed_count;
+ *lastMissedUsage = sInfo.swap_missed_usage;
+
+ (*dri_interface->getUST)( & ust );
+ *usage = driCalculateSwapUsage( dpriv, sInfo.swap_ust, ust );
+ }
+
+ return status;
+}
+
+
+/**
+ * Calculate amount of swap interval used between GLX buffer swaps.
+ *
+ * The usage value, on the range [0,max], is the fraction of total swap
+ * interval time used between GLX buffer swaps is calculated.
+ *
+ * \f$p = t_d / (i * t_r)\f$
+ *
+ * Where \f$t_d\f$ is the time since the last GLX buffer swap, \f$i\f$ is the
+ * swap interval (as set by \c glXSwapIntervalSGI), and \f$t_r\f$ time
+ * required for a single vertical refresh period (as returned by \c
+ * glXGetMscRateOML).
+ *
+ * See the documentation for the GLX_MESA_swap_frame_usage extension for more
+ * details.
+ *
+ * \param dPriv Pointer to the private drawable structure.
+ * \return If less than a single swap interval time period was required
+ * between GLX buffer swaps, a number greater than 0 and less than
+ * 1.0 is returned. If exactly one swap interval time period is
+ * required, 1.0 is returned, and if more than one is required then
+ * a number greater than 1.0 will be returned.
+ *
+ * \sa glXSwapIntervalSGI glXGetMscRateOML
+ *
+ * \todo Instead of caching the \c glXGetMscRateOML function pointer, would it
+ * be possible to cache the sync rate?
+ */
+float
+driCalculateSwapUsage( __DRIdrawablePrivate *dPriv, int64_t last_swap_ust,
+ int64_t current_ust )
+{
+ int32_t n;
+ int32_t d;
+ int interval;
+ float usage = 1.0;
+
+
+ if ( (*dri_interface->getMSCRate)( dPriv->display, dPriv->draw, &n, &d ) ) {
+ interval = (dPriv->pdraw->swap_interval != 0)
+ ? dPriv->pdraw->swap_interval : 1;
+
+
+ /* We want to calculate
+ * (current_UST - last_swap_UST) / (interval * us_per_refresh). We get
+ * current_UST by calling __glXGetUST. last_swap_UST is stored in
+ * dPriv->swap_ust. interval has already been calculated.
+ *
+ * The only tricky part is us_per_refresh. us_per_refresh is
+ * 1000000 / MSC_rate. We know the MSC_rate is n / d. We can flip it
+ * around and say us_per_refresh = 1000000 * d / n. Since this goes in
+ * the denominator of the final calculation, we calculate
+ * (interval * 1000000 * d) and move n into the numerator.
+ */
+
+ usage = (current_ust - last_swap_ust);
+ usage *= n;
+ usage /= (interval * d);
+ usage /= 1000000.0;
+ }
+
+ return usage;
+}
+
+/*@}*/
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/dri_util.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/dri_util.h
new file mode 100644
index 000000000..b9b38f39c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/dri_util.h
@@ -0,0 +1,555 @@
+/* $XFree86: xc/lib/GL/dri/dri_util.h,v 1.1 2002/02/22 21:32:52 dawes Exp $ */
+/**
+ * \file dri_util.h
+ * DRI utility functions definitions.
+ *
+ * This module acts as glue between GLX and the actual hardware driver. A DRI
+ * driver doesn't really \e have to use any of this - it's optional. But, some
+ * useful stuff is done here that otherwise would have to be duplicated in most
+ * drivers.
+ *
+ * Basically, these utility functions take care of some of the dirty details of
+ * screen initialization, context creation, context binding, DRM setup, etc.
+ *
+ * These functions are compiled into each DRI driver so libGL.so knows nothing
+ * about them.
+ *
+ * \sa dri_util.c.
+ *
+ * \author Kevin E. Martin <kevin@precisioninsight.com>
+ * \author Brian Paul <brian@precisioninsight.com>
+ */
+
+/*
+ * 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.
+ */
+
+
+#ifndef _DRI_UTIL_H_
+#define _DRI_UTIL_H_
+
+#define CAPI /* XXX this should be globally defined somewhere */
+
+#include <GL/gl.h>
+#include "drm.h"
+#include "drm_sarea.h"
+#include "xf86drm.h"
+#include "GL/internal/glcore.h"
+#include "GL/internal/dri_interface.h"
+
+#define GLX_BAD_CONTEXT 5
+
+typedef struct __DRIdisplayPrivateRec __DRIdisplayPrivate;
+typedef struct __DRIscreenPrivateRec __DRIscreenPrivate;
+typedef struct __DRIcontextPrivateRec __DRIcontextPrivate;
+typedef struct __DRIdrawablePrivateRec __DRIdrawablePrivate;
+typedef struct __DRIswapInfoRec __DRIswapInfo;
+typedef struct __DRIutilversionRec2 __DRIutilversion2;
+
+
+/**
+ * Used by DRI_VALIDATE_DRAWABLE_INFO
+ */
+#define DRI_VALIDATE_DRAWABLE_INFO_ONCE(pDrawPriv) \
+ do { \
+ if (*(pDrawPriv->pStamp) != pDrawPriv->lastStamp) { \
+ __driUtilUpdateDrawableInfo(pDrawPriv); \
+ } \
+ } while (0)
+
+
+/**
+ * Utility macro to validate the drawable information.
+ *
+ * See __DRIdrawablePrivate::pStamp and __DRIdrawablePrivate::lastStamp.
+ */
+#define DRI_VALIDATE_DRAWABLE_INFO(psp, pdp) \
+do { \
+ while (*(pdp->pStamp) != pdp->lastStamp) { \
+ DRM_UNLOCK(psp->fd, &psp->pSAREA->lock, \
+ pdp->driContextPriv->hHWContext); \
+ \
+ DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
+ DRI_VALIDATE_DRAWABLE_INFO_ONCE(pdp); \
+ DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
+ \
+ DRM_LIGHT_LOCK(psp->fd, &psp->pSAREA->lock, \
+ pdp->driContextPriv->hHWContext); \
+ } \
+} while (0)
+
+
+/**
+ * Driver callback functions.
+ *
+ * Each DRI driver must have one of these structures with all the pointers set
+ * to appropriate functions within the driver.
+ *
+ * When glXCreateContext() is called, for example, it'll call a helper function
+ * dri_util.c which in turn will jump through the \a CreateContext pointer in
+ * this structure.
+ */
+struct __DriverAPIRec {
+ /**
+ * Driver initialization callback
+ */
+ GLboolean (*InitDriver)(__DRIscreenPrivate *driScrnPriv);
+
+ /**
+ * Screen destruction callback
+ */
+ void (*DestroyScreen)(__DRIscreenPrivate *driScrnPriv);
+
+ /**
+ * Context creation callback
+ */
+ GLboolean (*CreateContext)(const __GLcontextModes *glVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate);
+
+ /**
+ * Context destruction callback
+ */
+ void (*DestroyContext)(__DRIcontextPrivate *driContextPriv);
+
+ /**
+ * Buffer (drawable) creation callback
+ */
+ GLboolean (*CreateBuffer)(__DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *glVis,
+ GLboolean pixmapBuffer);
+
+ /**
+ * Buffer (drawable) destruction callback
+ */
+ void (*DestroyBuffer)(__DRIdrawablePrivate *driDrawPriv);
+
+ /**
+ * Buffer swapping callback
+ */
+ void (*SwapBuffers)(__DRIdrawablePrivate *driDrawPriv);
+
+ /**
+ * Context activation callback
+ */
+ GLboolean (*MakeCurrent)(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv);
+
+ /**
+ * Context unbinding callback
+ */
+ GLboolean (*UnbindContext)(__DRIcontextPrivate *driContextPriv);
+
+ /**
+ * Retrieves statistics about buffer swap operations. Required if
+ * GLX_OML_sync_control or GLX_MESA_swap_frame_usage is supported.
+ */
+ int (*GetSwapInfo)( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo );
+
+
+ /**
+ * Required if GLX_SGI_video_sync or GLX_OML_sync_control is
+ * supported.
+ */
+ int (*GetMSC)( __DRIscreenPrivate * priv, int64_t * count );
+
+ /**
+ * These are required if GLX_OML_sync_control is supported.
+ */
+ /*@{*/
+ int (*WaitForMSC)( __DRIdrawablePrivate *priv, int64_t target_msc,
+ int64_t divisor, int64_t remainder,
+ int64_t * msc );
+ int (*WaitForSBC)( __DRIdrawablePrivate *priv, int64_t target_sbc,
+ int64_t * msc, int64_t * sbc );
+
+ int64_t (*SwapBuffersMSC)( __DRIdrawablePrivate *priv, int64_t target_msc,
+ int64_t divisor, int64_t remainder );
+ /*@}*/
+};
+
+
+struct __DRIswapInfoRec {
+ /**
+ * Number of swapBuffers operations that have been *completed*.
+ */
+ u_int64_t swap_count;
+
+ /**
+ * Unadjusted system time of the last buffer swap. This is the time
+ * when the swap completed, not the time when swapBuffers was called.
+ */
+ int64_t swap_ust;
+
+ /**
+ * Number of swap operations that occurred after the swap deadline. That
+ * is if a swap happens more than swap_interval frames after the previous
+ * swap, it has missed its deadline. If swap_interval is 0, then the
+ * swap deadline is 1 frame after the previous swap.
+ */
+ u_int64_t swap_missed_count;
+
+ /**
+ * Amount of time used by the last swap that missed its deadline. This
+ * is calculated as (__glXGetUST() - swap_ust) / (swap_interval *
+ * time_for_single_vrefresh)). If the actual value of swap_interval is
+ * 0, then 1 is used instead. If swap_missed_count is non-zero, this
+ * should be greater-than 1.0.
+ */
+ float swap_missed_usage;
+};
+
+
+/**
+ * Per-drawable private DRI driver information.
+ */
+struct __DRIdrawablePrivateRec {
+ /**
+ * Kernel drawable handle
+ */
+ drm_drawable_t hHWDrawable;
+
+ /**
+ * Driver's private drawable information.
+ *
+ * This structure is opaque.
+ */
+ void *driverPrivate;
+
+ /**
+ * X's drawable ID associated with this private drawable.
+ */
+ __DRIid draw;
+ __DRIdrawable *pdraw;
+
+ /**
+ * Reference count for number of context's currently bound to this
+ * drawable.
+ *
+ * Once it reaches zero, the drawable can be destroyed.
+ *
+ * \note This behavior will change with GLX 1.3.
+ */
+ int refcount;
+
+ /**
+ * Index of this drawable information in the SAREA.
+ */
+ unsigned int index;
+
+ /**
+ * Pointer to the "drawable has changed ID" stamp in the SAREA.
+ */
+ unsigned int *pStamp;
+
+ /**
+ * Last value of the stamp.
+ *
+ * If this differs from the value stored at __DRIdrawablePrivate::pStamp,
+ * then the drawable information has been modified by the X server, and the
+ * drawable information (below) should be retrieved from the X server.
+ */
+ unsigned int lastStamp;
+
+ /**
+ * \name Drawable
+ *
+ * Drawable information used in software fallbacks.
+ */
+ /*@{*/
+ int x;
+ int y;
+ int w;
+ int h;
+ int numClipRects;
+ drm_clip_rect_t *pClipRects;
+ /*@}*/
+
+ /**
+ * \name Back and depthbuffer
+ *
+ * Information about the back and depthbuffer where different from above.
+ */
+ /*@{*/
+ int backX;
+ int backY;
+ int backClipRectType;
+ int numBackClipRects;
+ drm_clip_rect_t *pBackClipRects;
+ /*@}*/
+
+ /**
+ * Pointer to context to which this drawable is currently bound.
+ */
+ __DRIcontextPrivate *driContextPriv;
+
+ /**
+ * Pointer to screen on which this drawable was created.
+ */
+ __DRIscreenPrivate *driScreenPriv;
+
+ /**
+ * \name Display and screen information.
+ *
+ * Basically just need these for when the locking code needs to call
+ * \c __driUtilUpdateDrawableInfo.
+ */
+ /*@{*/
+ __DRInativeDisplay *display;
+ int screen;
+ /*@}*/
+
+ /**
+ * Called via glXSwapBuffers().
+ */
+ void (*swapBuffers)( __DRIdrawablePrivate *dPriv );
+};
+
+/**
+ * Per-context private driver information.
+ */
+struct __DRIcontextPrivateRec {
+ /**
+ * Kernel context handle used to access the device lock.
+ */
+ __DRIid contextID;
+
+ /**
+ * Kernel context handle used to access the device lock.
+ */
+ drm_context_t hHWContext;
+
+ /**
+ * Device driver's private context data. This structure is opaque.
+ */
+ void *driverPrivate;
+
+ /**
+ * This context's display pointer.
+ */
+ __DRInativeDisplay *display;
+
+ /**
+ * Pointer to drawable currently bound to this context.
+ */
+ __DRIdrawablePrivate *driDrawablePriv;
+
+ /**
+ * Pointer to screen on which this context was created.
+ */
+ __DRIscreenPrivate *driScreenPriv;
+};
+
+/**
+ * Per-screen private driver information.
+ */
+struct __DRIscreenPrivateRec {
+ /**
+ * Display for this screen
+ */
+ __DRInativeDisplay *display;
+
+ /**
+ * Current screen's number
+ */
+ int myNum;
+
+ /**
+ * Callback functions into the hardware-specific DRI driver code.
+ */
+ struct __DriverAPIRec DriverAPI;
+
+ /**
+ * \name DDX version
+ * DDX / 2D driver version information.
+ * \todo Replace these fields with a \c __DRIversionRec.
+ */
+ /*@{*/
+ int ddxMajor;
+ int ddxMinor;
+ int ddxPatch;
+ /*@}*/
+
+ /**
+ * \name DRI version
+ * DRI X extension version information.
+ * \todo Replace these fields with a \c __DRIversionRec.
+ */
+ /*@{*/
+ int driMajor;
+ int driMinor;
+ int driPatch;
+ /*@}*/
+
+ /**
+ * \name DRM version
+ * DRM (kernel module) version information.
+ * \todo Replace these fields with a \c __DRIversionRec.
+ */
+ /*@{*/
+ int drmMajor;
+ int drmMinor;
+ int drmPatch;
+ /*@}*/
+
+ /**
+ * ID used when the client sets the drawable lock.
+ *
+ * The X server uses this value to detect if the client has died while
+ * holding the drawable lock.
+ */
+ int drawLockID;
+
+ /**
+ * File descriptor returned when the kernel device driver is opened.
+ *
+ * Used to:
+ * - authenticate client to kernel
+ * - map the frame buffer, SAREA, etc.
+ * - close the kernel device driver
+ */
+ int fd;
+
+ /**
+ * SAREA pointer
+ *
+ * Used to access:
+ * - the device lock
+ * - the device-independent per-drawable and per-context(?) information
+ */
+ drm_sarea_t *pSAREA;
+
+ /**
+ * \name Direct frame buffer access information
+ * Used for software fallbacks.
+ */
+ /*@{*/
+ unsigned char *pFB;
+ int fbSize;
+ int fbOrigin;
+ int fbStride;
+ int fbWidth;
+ int fbHeight;
+ int fbBPP;
+ /*@}*/
+
+ /**
+ * \name Device-dependent private information (stored in the SAREA).
+ *
+ * This data is accessed by the client driver only.
+ */
+ /*@{*/
+ void *pDevPriv;
+ int devPrivSize;
+ /*@}*/
+
+ /**
+ * Dummy context to which drawables are bound when not bound to any
+ * other context.
+ *
+ * A dummy hHWContext is created for this context, and is used by the GL
+ * core when a hardware lock is required but the drawable is not currently
+ * bound (e.g., potentially during a SwapBuffers request). The dummy
+ * context is created when the first "real" context is created on this
+ * screen.
+ */
+ __DRIcontextPrivate dummyContextPriv;
+
+ /**
+ * Hash table to hold the drawable information for this screen.
+ */
+ void *drawHash;
+
+ /**
+ * Device-dependent private information (not stored in the SAREA).
+ *
+ * This pointer is never touched by the DRI layer.
+ */
+ void *private;
+
+ /**
+ * GLX visuals / FBConfigs for this screen. These are stored as a
+ * linked list.
+ *
+ * \note
+ * This field is \b only used in conjunction with the old interfaces. If
+ * the new interfaces are used, this field will be set to \c NULL and will
+ * not be dereferenced.
+ */
+ __GLcontextModes *modes;
+
+ /**
+ * Pointer back to the \c __DRIscreen that contains this structure.
+ */
+
+ __DRIscreen *psc;
+};
+
+
+/**
+ * Used to store a version which includes a major range instead of a single
+ * major version number.
+ */
+struct __DRIutilversionRec2 {
+ int major_min; /** min allowed Major version number. */
+ int major_max; /** max allowed Major version number. */
+ int minor; /**< Minor version number. */
+ int patch; /**< Patch-level. */
+};
+
+
+extern void
+__driUtilMessage(const char *f, ...);
+
+
+extern void
+__driUtilUpdateDrawableInfo(__DRIdrawablePrivate *pdp);
+
+
+extern __DRIscreenPrivate * __driUtilCreateNewScreen( __DRInativeDisplay *dpy,
+ int scrn, __DRIscreen *psc, __GLcontextModes * modes,
+ const __DRIversion * ddx_version, const __DRIversion * dri_version,
+ const __DRIversion * drm_version, const __DRIframebuffer * frame_buffer,
+ drm_sarea_t *pSAREA, int fd, int internal_api_version,
+ const struct __DriverAPIRec *driverAPI );
+
+/* Test the version of the internal GLX API. Returns a value like strcmp. */
+extern int
+driCompareGLXAPIVersion( GLint required_version );
+
+extern float
+driCalculateSwapUsage( __DRIdrawablePrivate *dPriv,
+ int64_t last_swap_ust, int64_t current_ust );
+
+/**
+ * Pointer to the \c __DRIinterfaceMethods passed to the driver by the loader.
+ *
+ * This pointer is set in the driver's \c __driCreateNewScreen function and
+ * is defined in dri_util.c.
+ */
+extern const __DRIinterfaceMethods * dri_interface;
+
+#endif /* _DRI_UTIL_H_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/drirenderbuffer.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/drirenderbuffer.c
new file mode 100644
index 000000000..44826958d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/drirenderbuffer.c
@@ -0,0 +1,98 @@
+
+#include "mtypes.h"
+#include "drirenderbuffer.h"
+#include "renderbuffer.h"
+#include "imports.h"
+
+
+/**
+ * This will get called when a window is resized.
+ * Just update width, height and internal format fields for now.
+ * There's usually no memory allocation above because the present
+ * DRI drivers use statically-allocated full-screen buffers.
+ */
+static GLboolean
+driRenderbufferStorage(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ rb->Width = width;
+ rb->Height = height;
+ rb->InternalFormat = internalFormat;
+ return GL_TRUE;
+}
+
+
+/**
+ * Allocate a new driRenderbuffer object.
+ * Individual drivers are free to implement different versions of
+ * this function.
+ * \param format Either GL_RGBA, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT24,
+ * GL_DEPTH_COMPONENT32, or GL_STENCIL_INDEX8_EXT (for now).
+ * \param cpp chars or bytes per pixel
+ * \param offset start of buffer with respect to framebuffer address
+ * \param pitch pixels per row
+ */
+driRenderbuffer *
+driNewRenderbuffer(GLenum format, GLint cpp, GLint offset, GLint pitch)
+{
+ driRenderbuffer *drb;
+
+ assert(format == GL_RGBA ||
+ format == GL_DEPTH_COMPONENT16 ||
+ format == GL_DEPTH_COMPONENT24 ||
+ format == GL_DEPTH_COMPONENT32 ||
+ format == GL_STENCIL_INDEX8_EXT);
+
+ assert(cpp > 0);
+ assert(pitch > 0);
+
+ drb = _mesa_calloc(sizeof(driRenderbuffer));
+ if (drb) {
+ const GLuint name = 0;
+
+ _mesa_init_renderbuffer(&drb->Base, name);
+
+ /* Make sure we're using a null-valued GetPointer routine */
+ assert(drb->Base.GetPointer(NULL, &drb->Base, 0, 0) == NULL);
+
+ drb->Base.InternalFormat = format;
+
+ if (format == GL_RGBA) {
+ /* Color */
+ drb->Base._BaseFormat = GL_RGBA;
+ drb->Base.DataType = GL_UNSIGNED_BYTE;
+ }
+ else if (format == GL_DEPTH_COMPONENT16) {
+ /* Depth */
+ drb->Base._BaseFormat = GL_DEPTH_COMPONENT;
+ /* we always Get/Put 32-bit Z values */
+ drb->Base.DataType = GL_UNSIGNED_INT;
+ }
+ else if (format == GL_DEPTH_COMPONENT24) {
+ /* Depth */
+ drb->Base._BaseFormat = GL_DEPTH_COMPONENT;
+ /* we always Get/Put 32-bit Z values */
+ drb->Base.DataType = GL_UNSIGNED_INT;
+ }
+ else {
+ /* Stencil */
+ ASSERT(format == GL_STENCIL_INDEX8);
+ drb->Base._BaseFormat = GL_STENCIL_INDEX;
+ drb->Base.DataType = GL_UNSIGNED_BYTE;
+ }
+
+ /* XXX if we were allocating a user-created renderbuffer, we'd have
+ * to fill in the ComponentSizes[] array too.
+ */
+
+ drb->Base.AllocStorage = driRenderbufferStorage;
+ /* using default Delete function */
+
+
+ /* DRI renderbuffer-specific fields: */
+ drb->offset = offset;
+ drb->pitch = pitch;
+ drb->cpp = cpp;
+ }
+ return drb;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/drirenderbuffer.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/drirenderbuffer.h
new file mode 100644
index 000000000..627f1d41d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/drirenderbuffer.h
@@ -0,0 +1,39 @@
+
+/**
+ * A driRenderbuffer is dervied from gl_renderbuffer.
+ * It describes a color buffer (front or back), a depth buffer, or stencil
+ * buffer etc.
+ * Specific to DRI drivers are the offset and pitch fields.
+ */
+
+
+#ifndef DRIRENDERBUFFER_H
+#define DRIRENDERBUFFER_H
+
+#include "mtypes.h"
+
+typedef struct {
+ struct gl_renderbuffer Base;
+
+ /* Chars or bytes per pixel. If Z and Stencil are stored together this
+ * will typically be 32 whether this a depth or stencil renderbuffer.
+ */
+ GLint cpp;
+
+ /* Buffer position and pitch (row stride). Recall that for today's DRI
+ * drivers, we have statically allocated color/depth/stencil buffers.
+ * So this information describes the whole screen, not just a window.
+ * To address pixels in a window, we need to know the window's position
+ * and size with respect to the screen.
+ */
+ GLint offset; /* in bytes */
+ GLint pitch; /* in pixels */
+
+} driRenderbuffer;
+
+
+driRenderbuffer *
+driNewRenderbuffer(GLenum format, GLint cpp, GLint offset, GLint pitch);
+
+
+#endif /* DRIRENDERBUFFER_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/extension_helper.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/extension_helper.h
new file mode 100644
index 000000000..4a6606819
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/extension_helper.h
@@ -0,0 +1,5887 @@
+/* DO NOT EDIT - This file generated automatically by extension_helper.py (from Mesa) script */
+
+/*
+ * (C) Copyright IBM Corporation 2005
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "utils.h"
+#include "dispatch.h"
+
+#ifndef NULL
+# define NULL 0
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char UniformMatrix3fvARB_names[] =
+ "iiip\0" /* Parameter signature */
+ "glUniformMatrix3fvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char ProgramParameter4fNV_names[] =
+ "iiffff\0" /* Parameter signature */
+ "glProgramParameter4fNV\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_multisample)
+static const char SampleCoverageARB_names[] =
+ "fi\0" /* Parameter signature */
+ "glSampleCoverage\0"
+ "glSampleCoverageARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_convolution)
+static const char ConvolutionFilter1D_names[] =
+ "iiiiip\0" /* Parameter signature */
+ "glConvolutionFilter1D\0"
+ "glConvolutionFilter1DEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_occlusion_query)
+static const char BeginQueryARB_names[] =
+ "ii\0" /* Parameter signature */
+ "glBeginQuery\0"
+ "glBeginQueryARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_NV_point_sprite)
+static const char PointParameteriNV_names[] =
+ "ii\0" /* Parameter signature */
+ "glPointParameteri\0"
+ "glPointParameteriNV\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord3sARB_names[] =
+ "iiii\0" /* Parameter signature */
+ "glMultiTexCoord3s\0"
+ "glMultiTexCoord3sARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
+static const char SecondaryColor3iEXT_names[] =
+ "iii\0" /* Parameter signature */
+ "glSecondaryColor3i\0"
+ "glSecondaryColor3iEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
+static const char WindowPos3fMESA_names[] =
+ "fff\0" /* Parameter signature */
+ "glWindowPos3f\0"
+ "glWindowPos3fARB\0"
+ "glWindowPos3fMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_pixel_texture)
+static const char PixelTexGenParameterfvSGIS_names[] =
+ "ip\0" /* Parameter signature */
+ "glPixelTexGenParameterfvSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char ActiveTextureARB_names[] =
+ "i\0" /* Parameter signature */
+ "glActiveTexture\0"
+ "glActiveTextureARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib4ubvNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4ubvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SGI_color_table)
+static const char GetColorTableParameterfvSGI_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetColorTableParameterfvSGI\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_fragment_program)
+static const char GetProgramNamedParameterdvNV_names[] =
+ "iipp\0" /* Parameter signature */
+ "glGetProgramNamedParameterdvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_histogram)
+static const char Histogram_names[] =
+ "iiii\0" /* Parameter signature */
+ "glHistogram\0"
+ "glHistogramEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_texture4D)
+static const char TexImage4DSGIS_names[] =
+ "iiiiiiiiiip\0" /* Parameter signature */
+ "glTexImage4DSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
+static const char WindowPos2dvMESA_names[] =
+ "p\0" /* Parameter signature */
+ "glWindowPos2dv\0"
+ "glWindowPos2dvARB\0"
+ "glWindowPos2dvMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char ReplacementCodeuiColor3fVertex3fvSUN_names[] =
+ "ppp\0" /* Parameter signature */
+ "glReplacementCodeuiColor3fVertex3fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_paletted_texture)
+static const char GetColorTableParameterivEXT_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetColorTableParameterivEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_blend_equation_separate) || defined(need_GL_ATI_blend_equation_separate)
+static const char BlendEquationSeparateEXT_names[] =
+ "ii\0" /* Parameter signature */
+ "glBlendEquationSeparateEXT\0"
+ "glBlendEquationSeparateATI\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_list_priority)
+static const char ListParameterfSGIX_names[] =
+ "iif\0" /* Parameter signature */
+ "glListParameterfSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
+static const char SecondaryColor3bEXT_names[] =
+ "iii\0" /* Parameter signature */
+ "glSecondaryColor3b\0"
+ "glSecondaryColor3bEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char TexCoord4fColor4fNormal3fVertex4fvSUN_names[] =
+ "pppp\0" /* Parameter signature */
+ "glTexCoord4fColor4fNormal3fVertex4fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib4svNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4svNV\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
+static const char GetBufferSubDataARB_names[] =
+ "iiip\0" /* Parameter signature */
+ "glGetBufferSubData\0"
+ "glGetBufferSubDataARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
+static const char BufferSubDataARB_names[] =
+ "iiip\0" /* Parameter signature */
+ "glBufferSubData\0"
+ "glBufferSubDataARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char TexCoord2fColor4ubVertex3fvSUN_names[] =
+ "ppp\0" /* Parameter signature */
+ "glTexCoord2fColor4ubVertex3fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char ProgramEnvParameter4dvARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glProgramEnvParameter4dvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib2fARB_names[] =
+ "iff\0" /* Parameter signature */
+ "glVertexAttrib2fARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_histogram)
+static const char GetHistogramParameterivEXT_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetHistogramParameterivEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib3fARB_names[] =
+ "ifff\0" /* Parameter signature */
+ "glVertexAttrib3fARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_occlusion_query)
+static const char GetQueryivARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetQueryiv\0"
+ "glGetQueryivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_texture3D)
+static const char TexImage3D_names[] =
+ "iiiiiiiiip\0" /* Parameter signature */
+ "glTexImage3D\0"
+ "glTexImage3DEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char ReplacementCodeuiVertex3fvSUN_names[] =
+ "pp\0" /* Parameter signature */
+ "glReplacementCodeuiVertex3fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_occlusion_query)
+static const char GetQueryObjectivARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetQueryObjectiv\0"
+ "glGetQueryObjectivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char ReplacementCodeuiTexCoord2fVertex3fvSUN_names[] =
+ "ppp\0" /* Parameter signature */
+ "glReplacementCodeuiTexCoord2fVertex3fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_texture_compression)
+static const char CompressedTexSubImage2DARB_names[] =
+ "iiiiiiiip\0" /* Parameter signature */
+ "glCompressedTexSubImage2D\0"
+ "glCompressedTexSubImage2DARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char Uniform2fARB_names[] =
+ "iff\0" /* Parameter signature */
+ "glUniform2fARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib1svARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib1svARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttribs1dvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glVertexAttribs1dvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char Uniform2ivARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glUniform2ivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_HP_image_transform)
+static const char GetImageTransformParameterfvHP_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetImageTransformParameterfvHP\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_blend)
+static const char WeightubvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glWeightubvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_convolution)
+static const char CopyConvolutionFilter1D_names[] =
+ "iiiii\0" /* Parameter signature */
+ "glCopyConvolutionFilter1D\0"
+ "glCopyConvolutionFilter1DEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char ReplacementCodeuiNormal3fVertex3fSUN_names[] =
+ "iffffff\0" /* Parameter signature */
+ "glReplacementCodeuiNormal3fVertex3fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char FragmentMaterialfvSGIX_names[] =
+ "iip\0" /* Parameter signature */
+ "glFragmentMaterialfvSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_blend_color)
+static const char BlendColor_names[] =
+ "ffff\0" /* Parameter signature */
+ "glBlendColor\0"
+ "glBlendColorEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char UniformMatrix4fvARB_names[] =
+ "iiip\0" /* Parameter signature */
+ "glUniformMatrix4fvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_instruments)
+static const char ReadInstrumentsSGIX_names[] =
+ "i\0" /* Parameter signature */
+ "glReadInstrumentsSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char Color4ubVertex3fvSUN_names[] =
+ "pp\0" /* Parameter signature */
+ "glColor4ubVertex3fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_list_priority)
+static const char GetListParameterivSGIX_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetListParameterivSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4NusvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4NusvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_MESA_window_pos)
+static const char WindowPos4svMESA_names[] =
+ "p\0" /* Parameter signature */
+ "glWindowPos4svMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char CreateProgramObjectARB_names[] =
+ "\0" /* Parameter signature */
+ "glCreateProgramObjectARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char FragmentLightModelivSGIX_names[] =
+ "ip\0" /* Parameter signature */
+ "glFragmentLightModelivSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_ATI_fragment_shader)
+static const char ColorFragmentOp3ATI_names[] =
+ "iiiiiiiiiiiii\0" /* Parameter signature */
+ "glColorFragmentOp3ATI\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_texture_object)
+static const char PrioritizeTextures_names[] =
+ "ipp\0" /* Parameter signature */
+ "glPrioritizeTextures\0"
+ "glPrioritizeTexturesEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_async)
+static const char AsyncMarkerSGIX_names[] =
+ "i\0" /* Parameter signature */
+ "glAsyncMarkerSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_global_alpha)
+static const char GlobalAlphaFactorubSUN_names[] =
+ "i\0" /* Parameter signature */
+ "glGlobalAlphaFactorubSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_histogram)
+static const char ResetHistogram_names[] =
+ "i\0" /* Parameter signature */
+ "glResetHistogram\0"
+ "glResetHistogramEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_fragment_program)
+static const char GetProgramNamedParameterfvNV_names[] =
+ "iipp\0" /* Parameter signature */
+ "glGetProgramNamedParameterfvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_point_parameters) || defined(need_GL_EXT_point_parameters) || defined(need_GL_SGIS_point_parameters)
+static const char PointParameterfEXT_names[] =
+ "if\0" /* Parameter signature */
+ "glPointParameterf\0"
+ "glPointParameterfARB\0"
+ "glPointParameterfEXT\0"
+ "glPointParameterfSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_polynomial_ffd)
+static const char LoadIdentityDeformationMapSGIX_names[] =
+ "i\0" /* Parameter signature */
+ "glLoadIdentityDeformationMapSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_fence)
+static const char GenFencesNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glGenFencesNV\0"
+ "";
+#endif
+
+#if defined(need_GL_HP_image_transform)
+static const char ImageTransformParameterfHP_names[] =
+ "iif\0" /* Parameter signature */
+ "glImageTransformParameterfHP\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_matrix_palette)
+static const char MatrixIndexusvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMatrixIndexusvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char ProgramParameter4dvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glProgramParameter4dvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char DisableVertexAttribArrayARB_names[] =
+ "i\0" /* Parameter signature */
+ "glDisableVertexAttribArrayARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_2_0)
+static const char StencilMaskSeparate_names[] =
+ "ii\0" /* Parameter signature */
+ "glStencilMaskSeparate\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char ProgramLocalParameter4dARB_names[] =
+ "iidddd\0" /* Parameter signature */
+ "glProgramLocalParameter4dARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_texture_compression)
+static const char CompressedTexImage3DARB_names[] =
+ "iiiiiiiip\0" /* Parameter signature */
+ "glCompressedTexImage3D\0"
+ "glCompressedTexImage3DARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib1fARB_names[] =
+ "if\0" /* Parameter signature */
+ "glVertexAttrib1fARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_fence)
+static const char TestFenceNV_names[] =
+ "i\0" /* Parameter signature */
+ "glTestFenceNV\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord1fvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMultiTexCoord1fv\0"
+ "glMultiTexCoord1fvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ATI_fragment_shader)
+static const char ColorFragmentOp2ATI_names[] =
+ "iiiiiiiiii\0" /* Parameter signature */
+ "glColorFragmentOp2ATI\0"
+ "";
+#endif
+
+#if defined(need_GL_IBM_vertex_array_lists)
+static const char SecondaryColorPointerListIBM_names[] =
+ "iiipi\0" /* Parameter signature */
+ "glSecondaryColorPointerListIBM\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_pixel_texture)
+static const char GetPixelTexGenParameterivSGIS_names[] =
+ "ip\0" /* Parameter signature */
+ "glGetPixelTexGenParameterivSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib4fNV_names[] =
+ "iffff\0" /* Parameter signature */
+ "glVertexAttrib4fNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_triangle_list)
+static const char ReplacementCodeubSUN_names[] =
+ "i\0" /* Parameter signature */
+ "glReplacementCodeubSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_async)
+static const char FinishAsyncSGIX_names[] =
+ "p\0" /* Parameter signature */
+ "glFinishAsyncSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_fog_coord)
+static const char FogCoorddEXT_names[] =
+ "d\0" /* Parameter signature */
+ "glFogCoordd\0"
+ "glFogCoorddEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char Color4ubVertex3fSUN_names[] =
+ "iiiifff\0" /* Parameter signature */
+ "glColor4ubVertex3fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_fog_coord)
+static const char FogCoordfEXT_names[] =
+ "f\0" /* Parameter signature */
+ "glFogCoordf\0"
+ "glFogCoordfEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char TexCoord2fVertex3fSUN_names[] =
+ "fffff\0" /* Parameter signature */
+ "glTexCoord2fVertex3fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_global_alpha)
+static const char GlobalAlphaFactoriSUN_names[] =
+ "i\0" /* Parameter signature */
+ "glGlobalAlphaFactoriSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib2dNV_names[] =
+ "idd\0" /* Parameter signature */
+ "glVertexAttrib2dNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4NbvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4NbvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_shader)
+static const char GetActiveAttribARB_names[] =
+ "iiipppp\0" /* Parameter signature */
+ "glGetActiveAttribARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib4ubNV_names[] =
+ "iiiii\0" /* Parameter signature */
+ "glVertexAttrib4ubNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char TexCoord2fColor4fNormal3fVertex3fSUN_names[] =
+ "ffffffffffff\0" /* Parameter signature */
+ "glTexCoord2fColor4fNormal3fVertex3fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_histogram)
+static const char GetMinmaxEXT_names[] =
+ "iiiip\0" /* Parameter signature */
+ "glGetMinmaxEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_register_combiners)
+static const char CombinerParameterfvNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glCombinerParameterfvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttribs3dvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glVertexAttribs3dvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttribs4fvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glVertexAttribs4fvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char FragmentLightiSGIX_names[] =
+ "iii\0" /* Parameter signature */
+ "glFragmentLightiSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_polygon_offset)
+static const char PolygonOffsetEXT_names[] =
+ "ff\0" /* Parameter signature */
+ "glPolygonOffsetEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_async)
+static const char PollAsyncSGIX_names[] =
+ "p\0" /* Parameter signature */
+ "glPollAsyncSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_ATI_fragment_shader)
+static const char DeleteFragmentShaderATI_names[] =
+ "i\0" /* Parameter signature */
+ "glDeleteFragmentShaderATI\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char TexCoord2fNormal3fVertex3fvSUN_names[] =
+ "ppp\0" /* Parameter signature */
+ "glTexCoord2fNormal3fVertex3fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_transpose_matrix)
+static const char MultTransposeMatrixdARB_names[] =
+ "p\0" /* Parameter signature */
+ "glMultTransposeMatrixd\0"
+ "glMultTransposeMatrixdARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
+static const char WindowPos2svMESA_names[] =
+ "p\0" /* Parameter signature */
+ "glWindowPos2sv\0"
+ "glWindowPos2svARB\0"
+ "glWindowPos2svMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_texture_compression)
+static const char CompressedTexImage1DARB_names[] =
+ "iiiiiip\0" /* Parameter signature */
+ "glCompressedTexImage1D\0"
+ "glCompressedTexImage1DARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib2sNV_names[] =
+ "iii\0" /* Parameter signature */
+ "glVertexAttrib2sNV\0"
+ "";
+#endif
+
+#if defined(need_GL_IBM_vertex_array_lists)
+static const char NormalPointerListIBM_names[] =
+ "iipi\0" /* Parameter signature */
+ "glNormalPointerListIBM\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_vertex_array)
+static const char IndexPointerEXT_names[] =
+ "iiip\0" /* Parameter signature */
+ "glIndexPointerEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_vertex_array)
+static const char NormalPointerEXT_names[] =
+ "iiip\0" /* Parameter signature */
+ "glNormalPointerEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord3dARB_names[] =
+ "iddd\0" /* Parameter signature */
+ "glMultiTexCoord3d\0"
+ "glMultiTexCoord3dARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord2iARB_names[] =
+ "iii\0" /* Parameter signature */
+ "glMultiTexCoord2i\0"
+ "glMultiTexCoord2iARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN_names[] =
+ "iffffffff\0" /* Parameter signature */
+ "glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord2svARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMultiTexCoord2sv\0"
+ "glMultiTexCoord2svARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_triangle_list)
+static const char ReplacementCodeubvSUN_names[] =
+ "p\0" /* Parameter signature */
+ "glReplacementCodeubvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char Uniform3iARB_names[] =
+ "iiii\0" /* Parameter signature */
+ "glUniform3iARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char GetFragmentMaterialfvSGIX_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetFragmentMaterialfvSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Binormal3fEXT_names[] =
+ "fff\0" /* Parameter signature */
+ "glBinormal3fEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_blend)
+static const char WeightivARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glWeightivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_global_alpha)
+static const char GlobalAlphaFactordSUN_names[] =
+ "d\0" /* Parameter signature */
+ "glGlobalAlphaFactordSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttribs3fvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glVertexAttribs3fvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const char GenerateMipmapEXT_names[] =
+ "i\0" /* Parameter signature */
+ "glGenerateMipmapEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char ProgramParameter4dNV_names[] =
+ "iidddd\0" /* Parameter signature */
+ "glProgramParameter4dNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ATI_fragment_shader)
+static const char SetFragmentShaderConstantATI_names[] =
+ "ip\0" /* Parameter signature */
+ "glSetFragmentShaderConstantATI\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_evaluators)
+static const char GetMapAttribParameterivNV_names[] =
+ "iiip\0" /* Parameter signature */
+ "glGetMapAttribParameterivNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char CreateShaderObjectARB_names[] =
+ "i\0" /* Parameter signature */
+ "glCreateShaderObjectARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_sharpen_texture)
+static const char GetSharpenTexFuncSGIS_names[] =
+ "ip\0" /* Parameter signature */
+ "glGetSharpenTexFuncSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
+static const char BufferDataARB_names[] =
+ "iipi\0" /* Parameter signature */
+ "glBufferData\0"
+ "glBufferDataARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_array_range)
+static const char FlushVertexArrayRangeNV_names[] =
+ "\0" /* Parameter signature */
+ "glFlushVertexArrayRangeNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ATI_fragment_shader)
+static const char SampleMapATI_names[] =
+ "iii\0" /* Parameter signature */
+ "glSampleMapATI\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_vertex_array)
+static const char VertexPointerEXT_names[] =
+ "iiiip\0" /* Parameter signature */
+ "glVertexPointerEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_texture_filter4)
+static const char GetTexFilterFuncSGIS_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetTexFilterFuncSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_register_combiners)
+static const char GetCombinerOutputParameterfvNV_names[] =
+ "iiip\0" /* Parameter signature */
+ "glGetCombinerOutputParameterfvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_subtexture)
+static const char TexSubImage1D_names[] =
+ "iiiiiip\0" /* Parameter signature */
+ "glTexSubImage1D\0"
+ "glTexSubImage1DEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib1sARB_names[] =
+ "ii\0" /* Parameter signature */
+ "glVertexAttrib1sARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_register_combiners)
+static const char FinalCombinerInputNV_names[] =
+ "iiii\0" /* Parameter signature */
+ "glFinalCombinerInputNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_histogram)
+static const char GetHistogramParameterfvEXT_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetHistogramParameterfvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_flush_raster)
+static const char FlushRasterSGIX_names[] =
+ "\0" /* Parameter signature */
+ "glFlushRasterSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char ReplacementCodeuiTexCoord2fVertex3fSUN_names[] =
+ "ifffff\0" /* Parameter signature */
+ "glReplacementCodeuiTexCoord2fVertex3fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_draw_buffers) || defined(need_GL_ATI_draw_buffers)
+static const char DrawBuffersARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glDrawBuffersARB\0"
+ "glDrawBuffersATI\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const char IsRenderbufferEXT_names[] =
+ "i\0" /* Parameter signature */
+ "glIsRenderbufferEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_2_0)
+static const char StencilOpSeparate_names[] =
+ "iiii\0" /* Parameter signature */
+ "glStencilOpSeparate\0"
+ "";
+#endif
+
+#if defined(need_GL_SGI_color_table)
+static const char ColorTableParameteriv_names[] =
+ "iip\0" /* Parameter signature */
+ "glColorTableParameteriv\0"
+ "glColorTableParameterivSGI\0"
+ "";
+#endif
+
+#if defined(need_GL_IBM_vertex_array_lists)
+static const char FogCoordPointerListIBM_names[] =
+ "iipi\0" /* Parameter signature */
+ "glFogCoordPointerListIBM\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
+static const char WindowPos3dMESA_names[] =
+ "ddd\0" /* Parameter signature */
+ "glWindowPos3d\0"
+ "glWindowPos3dARB\0"
+ "glWindowPos3dMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_point_parameters) || defined(need_GL_EXT_point_parameters) || defined(need_GL_SGIS_point_parameters)
+static const char PointParameterfvEXT_names[] =
+ "ip\0" /* Parameter signature */
+ "glPointParameterfv\0"
+ "glPointParameterfvARB\0"
+ "glPointParameterfvEXT\0"
+ "glPointParameterfvSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
+static const char WindowPos2fvMESA_names[] =
+ "p\0" /* Parameter signature */
+ "glWindowPos2fv\0"
+ "glWindowPos2fvARB\0"
+ "glWindowPos2fvMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
+static const char SecondaryColor3bvEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glSecondaryColor3bv\0"
+ "glSecondaryColor3bvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_histogram)
+static const char GetHistogramEXT_names[] =
+ "iiiip\0" /* Parameter signature */
+ "glGetHistogramEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_IBM_vertex_array_lists)
+static const char VertexPointerListIBM_names[] =
+ "iiipi\0" /* Parameter signature */
+ "glVertexPointerListIBM\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char GetProgramLocalParameterfvARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetProgramLocalParameterfvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char FragmentMaterialfSGIX_names[] =
+ "iif\0" /* Parameter signature */
+ "glFragmentMaterialfSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_paletted_texture)
+static const char GetColorTableEXT_names[] =
+ "iiip\0" /* Parameter signature */
+ "glGetColorTableEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const char RenderbufferStorageEXT_names[] =
+ "iiii\0" /* Parameter signature */
+ "glRenderbufferStorageEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_fence)
+static const char IsFenceNV_names[] =
+ "i\0" /* Parameter signature */
+ "glIsFenceNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char AttachObjectARB_names[] =
+ "ii\0" /* Parameter signature */
+ "glAttachObjectARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char GetFragmentLightivSGIX_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetFragmentLightivSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char UniformMatrix2fvARB_names[] =
+ "iiip\0" /* Parameter signature */
+ "glUniformMatrix2fvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord2fARB_names[] =
+ "iff\0" /* Parameter signature */
+ "glMultiTexCoord2f\0"
+ "glMultiTexCoord2fARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGI_color_table) || defined(need_GL_EXT_paletted_texture)
+static const char ColorTable_names[] =
+ "iiiiip\0" /* Parameter signature */
+ "glColorTable\0"
+ "glColorTableSGI\0"
+ "glColorTableEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_evaluators)
+static const char MapControlPointsNV_names[] =
+ "iiiiiiiip\0" /* Parameter signature */
+ "glMapControlPointsNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_convolution)
+static const char ConvolutionFilter2D_names[] =
+ "iiiiiip\0" /* Parameter signature */
+ "glConvolutionFilter2D\0"
+ "glConvolutionFilter2DEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_evaluators)
+static const char MapParameterfvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glMapParameterfvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib3dvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib3dvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_PGI_misc_hints)
+static const char HintPGI_names[] =
+ "ii\0" /* Parameter signature */
+ "glHintPGI\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_convolution)
+static const char ConvolutionParameteriv_names[] =
+ "iip\0" /* Parameter signature */
+ "glConvolutionParameteriv\0"
+ "glConvolutionParameterivEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_cull_vertex)
+static const char CullParameterdvEXT_names[] =
+ "ip\0" /* Parameter signature */
+ "glCullParameterdvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_fragment_program)
+static const char ProgramNamedParameter4fNV_names[] =
+ "iipffff\0" /* Parameter signature */
+ "glProgramNamedParameter4fNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char Color3fVertex3fSUN_names[] =
+ "ffffff\0" /* Parameter signature */
+ "glColor3fVertex3fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char ProgramEnvParameter4fvARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glProgramEnvParameter4fvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char FragmentLightModeliSGIX_names[] =
+ "ii\0" /* Parameter signature */
+ "glFragmentLightModeliSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_convolution)
+static const char ConvolutionParameterfv_names[] =
+ "iip\0" /* Parameter signature */
+ "glConvolutionParameterfv\0"
+ "glConvolutionParameterfvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_3DFX_tbuffer)
+static const char TbufferMask3DFX_names[] =
+ "i\0" /* Parameter signature */
+ "glTbufferMask3DFX\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char LoadProgramNV_names[] =
+ "iiip\0" /* Parameter signature */
+ "glLoadProgramNV\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib4fvNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4fvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char GetAttachedObjectsARB_names[] =
+ "iipp\0" /* Parameter signature */
+ "glGetAttachedObjectsARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char Uniform3fvARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glUniform3fvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_draw_range_elements)
+static const char DrawRangeElements_names[] =
+ "iiiiip\0" /* Parameter signature */
+ "glDrawRangeElements\0"
+ "glDrawRangeElementsEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_sprite)
+static const char SpriteParameterfvSGIX_names[] =
+ "ip\0" /* Parameter signature */
+ "glSpriteParameterfvSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const char CheckFramebufferStatusEXT_names[] =
+ "i\0" /* Parameter signature */
+ "glCheckFramebufferStatusEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_global_alpha)
+static const char GlobalAlphaFactoruiSUN_names[] =
+ "i\0" /* Parameter signature */
+ "glGlobalAlphaFactoruiSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char GetHandleARB_names[] =
+ "i\0" /* Parameter signature */
+ "glGetHandleARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char GetVertexAttribivARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetVertexAttribivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_register_combiners)
+static const char GetCombinerInputParameterfvNV_names[] =
+ "iiiip\0" /* Parameter signature */
+ "glGetCombinerInputParameterfvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char ReplacementCodeuiNormal3fVertex3fvSUN_names[] =
+ "ppp\0" /* Parameter signature */
+ "glReplacementCodeuiNormal3fVertex3fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_transpose_matrix)
+static const char LoadTransposeMatrixdARB_names[] =
+ "p\0" /* Parameter signature */
+ "glLoadTransposeMatrixd\0"
+ "glLoadTransposeMatrixdARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_2_0)
+static const char StencilFuncSeparate_names[] =
+ "iiii\0" /* Parameter signature */
+ "glStencilFuncSeparate\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
+static const char SecondaryColor3sEXT_names[] =
+ "iii\0" /* Parameter signature */
+ "glSecondaryColor3s\0"
+ "glSecondaryColor3sEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char Color3fVertex3fvSUN_names[] =
+ "pp\0" /* Parameter signature */
+ "glColor3fVertex3fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_global_alpha)
+static const char GlobalAlphaFactorbSUN_names[] =
+ "i\0" /* Parameter signature */
+ "glGlobalAlphaFactorbSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_HP_image_transform)
+static const char ImageTransformParameterfvHP_names[] =
+ "iip\0" /* Parameter signature */
+ "glImageTransformParameterfvHP\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4ivARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4ivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib3fNV_names[] =
+ "ifff\0" /* Parameter signature */
+ "glVertexAttrib3fNV\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttribs2dvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glVertexAttribs2dvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord3fvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMultiTexCoord3fv\0"
+ "glMultiTexCoord3fvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
+static const char SecondaryColor3dEXT_names[] =
+ "ddd\0" /* Parameter signature */
+ "glSecondaryColor3d\0"
+ "glSecondaryColor3dEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char GetProgramParameterfvNV_names[] =
+ "iiip\0" /* Parameter signature */
+ "glGetProgramParameterfvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char TangentPointerEXT_names[] =
+ "iip\0" /* Parameter signature */
+ "glTangentPointerEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char Color4fNormal3fVertex3fvSUN_names[] =
+ "ppp\0" /* Parameter signature */
+ "glColor4fNormal3fVertex3fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_instruments)
+static const char GetInstrumentsSGIX_names[] =
+ "\0" /* Parameter signature */
+ "glGetInstrumentsSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_evaluators)
+static const char EvalMapsNV_names[] =
+ "ii\0" /* Parameter signature */
+ "glEvalMapsNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_subtexture)
+static const char TexSubImage2D_names[] =
+ "iiiiiiiip\0" /* Parameter signature */
+ "glTexSubImage2D\0"
+ "glTexSubImage2DEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char FragmentLightivSGIX_names[] =
+ "iip\0" /* Parameter signature */
+ "glFragmentLightivSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const char DeleteRenderbuffersEXT_names[] =
+ "ip\0" /* Parameter signature */
+ "glDeleteRenderbuffersEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_pixel_transform)
+static const char PixelTransformParameterfvEXT_names[] =
+ "iip\0" /* Parameter signature */
+ "glPixelTransformParameterfvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4bvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4bvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ATI_fragment_shader)
+static const char AlphaFragmentOp2ATI_names[] =
+ "iiiiiiiii\0" /* Parameter signature */
+ "glAlphaFragmentOp2ATI\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_convolution)
+static const char GetSeparableFilterEXT_names[] =
+ "iiippp\0" /* Parameter signature */
+ "glGetSeparableFilterEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord4sARB_names[] =
+ "iiiii\0" /* Parameter signature */
+ "glMultiTexCoord4s\0"
+ "glMultiTexCoord4sARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char GetFragmentMaterialivSGIX_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetFragmentMaterialivSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_MESA_window_pos)
+static const char WindowPos4dMESA_names[] =
+ "dddd\0" /* Parameter signature */
+ "glWindowPos4dMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_blend)
+static const char WeightPointerARB_names[] =
+ "iiip\0" /* Parameter signature */
+ "glWeightPointerARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
+static const char WindowPos2dMESA_names[] =
+ "dd\0" /* Parameter signature */
+ "glWindowPos2d\0"
+ "glWindowPos2dARB\0"
+ "glWindowPos2dMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const char FramebufferTexture3DEXT_names[] =
+ "iiiiii\0" /* Parameter signature */
+ "glFramebufferTexture3DEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_blend_minmax)
+static const char BlendEquation_names[] =
+ "i\0" /* Parameter signature */
+ "glBlendEquation\0"
+ "glBlendEquationEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib3dNV_names[] =
+ "iddd\0" /* Parameter signature */
+ "glVertexAttrib3dNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib3dARB_names[] =
+ "iddd\0" /* Parameter signature */
+ "glVertexAttrib3dARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN_names[] =
+ "ppppp\0" /* Parameter signature */
+ "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4fARB_names[] =
+ "iffff\0" /* Parameter signature */
+ "glVertexAttrib4fARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_index_func)
+static const char IndexFuncEXT_names[] =
+ "if\0" /* Parameter signature */
+ "glIndexFuncEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_list_priority)
+static const char GetListParameterfvSGIX_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetListParameterfvSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord2dvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMultiTexCoord2dv\0"
+ "glMultiTexCoord2dvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_cull_vertex)
+static const char CullParameterfvEXT_names[] =
+ "ip\0" /* Parameter signature */
+ "glCullParameterfvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_fragment_program)
+static const char ProgramNamedParameter4fvNV_names[] =
+ "iipp\0" /* Parameter signature */
+ "glProgramNamedParameter4fvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
+static const char SecondaryColorPointerEXT_names[] =
+ "iiip\0" /* Parameter signature */
+ "glSecondaryColorPointer\0"
+ "glSecondaryColorPointerEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4fvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4fvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_IBM_vertex_array_lists)
+static const char ColorPointerListIBM_names[] =
+ "iiipi\0" /* Parameter signature */
+ "glColorPointerListIBM\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char GetActiveUniformARB_names[] =
+ "iiipppp\0" /* Parameter signature */
+ "glGetActiveUniformARB\0"
+ "";
+#endif
+
+#if defined(need_GL_HP_image_transform)
+static const char ImageTransformParameteriHP_names[] =
+ "iii\0" /* Parameter signature */
+ "glImageTransformParameteriHP\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord1svARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMultiTexCoord1sv\0"
+ "glMultiTexCoord1svARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_occlusion_query)
+static const char EndQueryARB_names[] =
+ "i\0" /* Parameter signature */
+ "glEndQuery\0"
+ "glEndQueryARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_fence)
+static const char DeleteFencesNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glDeleteFencesNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_polynomial_ffd)
+static const char DeformationMap3dSGIX_names[] =
+ "iddiiddiiddiip\0" /* Parameter signature */
+ "glDeformationMap3dSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_HP_image_transform)
+static const char GetImageTransformParameterivHP_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetImageTransformParameterivHP\0"
+ "";
+#endif
+
+#if defined(need_GL_MESA_window_pos)
+static const char WindowPos4ivMESA_names[] =
+ "p\0" /* Parameter signature */
+ "glWindowPos4ivMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord3svARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMultiTexCoord3sv\0"
+ "glMultiTexCoord3svARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord4iARB_names[] =
+ "iiiii\0" /* Parameter signature */
+ "glMultiTexCoord4i\0"
+ "glMultiTexCoord4iARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Binormal3ivEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glBinormal3ivEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_MESA_resize_buffers)
+static const char ResizeBuffersMESA_names[] =
+ "\0" /* Parameter signature */
+ "glResizeBuffersMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char GetUniformivARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetUniformivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_pixel_texture)
+static const char PixelTexGenParameteriSGIS_names[] =
+ "ii\0" /* Parameter signature */
+ "glPixelTexGenParameteriSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_INTEL_parallel_arrays)
+static const char VertexPointervINTEL_names[] =
+ "iip\0" /* Parameter signature */
+ "glVertexPointervINTEL\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char ReplacementCodeuiColor4fNormal3fVertex3fvSUN_names[] =
+ "pppp\0" /* Parameter signature */
+ "glReplacementCodeuiColor4fNormal3fVertex3fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
+static const char SecondaryColor3uiEXT_names[] =
+ "iii\0" /* Parameter signature */
+ "glSecondaryColor3ui\0"
+ "glSecondaryColor3uiEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_instruments)
+static const char StartInstrumentsSGIX_names[] =
+ "\0" /* Parameter signature */
+ "glStartInstrumentsSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
+static const char SecondaryColor3usvEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glSecondaryColor3usv\0"
+ "glSecondaryColor3usvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib2fvNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib2fvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char ProgramLocalParameter4dvARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glProgramLocalParameter4dvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_matrix_palette)
+static const char MatrixIndexuivARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMatrixIndexuivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Tangent3sEXT_names[] =
+ "iii\0" /* Parameter signature */
+ "glTangent3sEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_global_alpha)
+static const char GlobalAlphaFactorfSUN_names[] =
+ "f\0" /* Parameter signature */
+ "glGlobalAlphaFactorfSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord3iARB_names[] =
+ "iiii\0" /* Parameter signature */
+ "glMultiTexCoord3i\0"
+ "glMultiTexCoord3iARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_convolution)
+static const char GetConvolutionFilterEXT_names[] =
+ "iiip\0" /* Parameter signature */
+ "glGetConvolutionFilterEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_IBM_vertex_array_lists)
+static const char TexCoordPointerListIBM_names[] =
+ "iiipi\0" /* Parameter signature */
+ "glTexCoordPointerListIBM\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_global_alpha)
+static const char GlobalAlphaFactorusSUN_names[] =
+ "i\0" /* Parameter signature */
+ "glGlobalAlphaFactorusSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib2dvNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib2dvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const char FramebufferRenderbufferEXT_names[] =
+ "iiii\0" /* Parameter signature */
+ "glFramebufferRenderbufferEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib1dvNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib1dvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_fence)
+static const char SetFenceNV_names[] =
+ "ii\0" /* Parameter signature */
+ "glSetFenceNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const char FramebufferTexture1DEXT_names[] =
+ "iiiii\0" /* Parameter signature */
+ "glFramebufferTexture1DEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_register_combiners)
+static const char GetCombinerOutputParameterivNV_names[] =
+ "iiip\0" /* Parameter signature */
+ "glGetCombinerOutputParameterivNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_pixel_texture)
+static const char PixelTexGenParameterivSGIS_names[] =
+ "ip\0" /* Parameter signature */
+ "glPixelTexGenParameterivSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_texture_perturb_normal)
+static const char TextureNormalEXT_names[] =
+ "i\0" /* Parameter signature */
+ "glTextureNormalEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_IBM_vertex_array_lists)
+static const char IndexPointerListIBM_names[] =
+ "iipi\0" /* Parameter signature */
+ "glIndexPointerListIBM\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_blend)
+static const char WeightfvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glWeightfvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char ProgramParameter4fvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glProgramParameter4fvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_MESA_window_pos)
+static const char WindowPos4fMESA_names[] =
+ "ffff\0" /* Parameter signature */
+ "glWindowPos4fMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
+static const char WindowPos3dvMESA_names[] =
+ "p\0" /* Parameter signature */
+ "glWindowPos3dv\0"
+ "glWindowPos3dvARB\0"
+ "glWindowPos3dvMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord1dARB_names[] =
+ "id\0" /* Parameter signature */
+ "glMultiTexCoord1d\0"
+ "glMultiTexCoord1dARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_NV_point_sprite)
+static const char PointParameterivNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glPointParameteriv\0"
+ "glPointParameterivNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char Uniform2fvARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glUniform2fvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord3dvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMultiTexCoord3dv\0"
+ "glMultiTexCoord3dvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN_names[] =
+ "pppp\0" /* Parameter signature */
+ "glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char DeleteObjectARB_names[] =
+ "i\0" /* Parameter signature */
+ "glDeleteObjectARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char UseProgramObjectARB_names[] =
+ "i\0" /* Parameter signature */
+ "glUseProgramObjectARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_fragment_program)
+static const char ProgramNamedParameter4dvNV_names[] =
+ "iipp\0" /* Parameter signature */
+ "glProgramNamedParameter4dvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Tangent3fvEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glTangent3fvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const char BindFramebufferEXT_names[] =
+ "ii\0" /* Parameter signature */
+ "glBindFramebufferEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4usvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4usvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_compiled_vertex_array)
+static const char UnlockArraysEXT_names[] =
+ "\0" /* Parameter signature */
+ "glUnlockArraysEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char TexCoord2fColor3fVertex3fSUN_names[] =
+ "ffffffff\0" /* Parameter signature */
+ "glTexCoord2fColor3fVertex3fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
+static const char WindowPos3fvMESA_names[] =
+ "p\0" /* Parameter signature */
+ "glWindowPos3fv\0"
+ "glWindowPos3fvARB\0"
+ "glWindowPos3fvMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib1svNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib1svNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_copy_texture)
+static const char CopyTexSubImage3D_names[] =
+ "iiiiiiiii\0" /* Parameter signature */
+ "glCopyTexSubImage3D\0"
+ "glCopyTexSubImage3DEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib2dARB_names[] =
+ "idd\0" /* Parameter signature */
+ "glVertexAttrib2dARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_texture_color_mask)
+static const char TextureColorMaskSGIS_names[] =
+ "iiii\0" /* Parameter signature */
+ "glTextureColorMaskSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_SGI_color_table)
+static const char CopyColorTable_names[] =
+ "iiiii\0" /* Parameter signature */
+ "glCopyColorTable\0"
+ "glCopyColorTableSGI\0"
+ "";
+#endif
+
+#if defined(need_GL_INTEL_parallel_arrays)
+static const char ColorPointervINTEL_names[] =
+ "iip\0" /* Parameter signature */
+ "glColorPointervINTEL\0"
+ "";
+#endif
+
+#if defined(need_GL_ATI_fragment_shader)
+static const char AlphaFragmentOp1ATI_names[] =
+ "iiiiii\0" /* Parameter signature */
+ "glAlphaFragmentOp1ATI\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord3ivARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMultiTexCoord3iv\0"
+ "glMultiTexCoord3ivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord2sARB_names[] =
+ "iii\0" /* Parameter signature */
+ "glMultiTexCoord2s\0"
+ "glMultiTexCoord2sARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib1dvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib1dvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_texture_object)
+static const char DeleteTextures_names[] =
+ "ip\0" /* Parameter signature */
+ "glDeleteTextures\0"
+ "glDeleteTexturesEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_vertex_array)
+static const char TexCoordPointerEXT_names[] =
+ "iiiip\0" /* Parameter signature */
+ "glTexCoordPointerEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_texture4D)
+static const char TexSubImage4DSGIS_names[] =
+ "iiiiiiiiiiiip\0" /* Parameter signature */
+ "glTexSubImage4DSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_register_combiners2)
+static const char CombinerStageParameterfvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glCombinerStageParameterfvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_instruments)
+static const char StopInstrumentsSGIX_names[] =
+ "i\0" /* Parameter signature */
+ "glStopInstrumentsSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char TexCoord4fColor4fNormal3fVertex4fSUN_names[] =
+ "fffffffffffffff\0" /* Parameter signature */
+ "glTexCoord4fColor4fNormal3fVertex4fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_polynomial_ffd)
+static const char DeformSGIX_names[] =
+ "i\0" /* Parameter signature */
+ "glDeformSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char GetVertexAttribfvARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetVertexAttribfvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
+static const char SecondaryColor3ivEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glSecondaryColor3iv\0"
+ "glSecondaryColor3ivEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_detail_texture)
+static const char GetDetailTexFuncSGIS_names[] =
+ "ip\0" /* Parameter signature */
+ "glGetDetailTexFuncSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_register_combiners2)
+static const char GetCombinerStageParameterfvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetCombinerStageParameterfvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char Color4ubVertex2fvSUN_names[] =
+ "pp\0" /* Parameter signature */
+ "glColor4ubVertex2fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_texture_filter4)
+static const char TexFilterFuncSGIS_names[] =
+ "iiip\0" /* Parameter signature */
+ "glTexFilterFuncSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_multisample) || defined(need_GL_EXT_multisample)
+static const char SampleMaskSGIS_names[] =
+ "fi\0" /* Parameter signature */
+ "glSampleMaskSGIS\0"
+ "glSampleMaskEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_shader)
+static const char GetAttribLocationARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glGetAttribLocationARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4ubvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4ubvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_detail_texture)
+static const char DetailTexFuncSGIS_names[] =
+ "iip\0" /* Parameter signature */
+ "glDetailTexFuncSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char Normal3fVertex3fSUN_names[] =
+ "ffffff\0" /* Parameter signature */
+ "glNormal3fVertex3fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_copy_texture)
+static const char CopyTexImage2D_names[] =
+ "iiiiiiii\0" /* Parameter signature */
+ "glCopyTexImage2D\0"
+ "glCopyTexImage2DEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
+static const char GetBufferPointervARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetBufferPointerv\0"
+ "glGetBufferPointervARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char ProgramEnvParameter4fARB_names[] =
+ "iiffff\0" /* Parameter signature */
+ "glProgramEnvParameter4fARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char Uniform3ivARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glUniform3ivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_fence)
+static const char GetFenceivNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetFenceivNV\0"
+ "";
+#endif
+
+#if defined(need_GL_MESA_window_pos)
+static const char WindowPos4dvMESA_names[] =
+ "p\0" /* Parameter signature */
+ "glWindowPos4dvMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_color_subtable)
+static const char ColorSubTable_names[] =
+ "iiiiip\0" /* Parameter signature */
+ "glColorSubTable\0"
+ "glColorSubTableEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord4ivARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMultiTexCoord4iv\0"
+ "glMultiTexCoord4ivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_evaluators)
+static const char GetMapAttribParameterfvNV_names[] =
+ "iiip\0" /* Parameter signature */
+ "glGetMapAttribParameterfvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4sARB_names[] =
+ "iiiii\0" /* Parameter signature */
+ "glVertexAttrib4sARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_occlusion_query)
+static const char GetQueryObjectuivARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetQueryObjectuiv\0"
+ "glGetQueryObjectuivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_evaluators)
+static const char MapParameterivNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glMapParameterivNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const char GenRenderbuffersEXT_names[] =
+ "ip\0" /* Parameter signature */
+ "glGenRenderbuffersEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_convolution)
+static const char GetConvolutionParameterfvEXT_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetConvolutionParameterfvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_histogram)
+static const char GetMinmaxParameterfvEXT_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetMinmaxParameterfvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib2dvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib2dvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_vertex_array)
+static const char EdgeFlagPointerEXT_names[] =
+ "iip\0" /* Parameter signature */
+ "glEdgeFlagPointerEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttribs2svNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glVertexAttribs2svNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_blend)
+static const char WeightbvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glWeightbvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib2fvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib2fvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
+static const char GetBufferParameterivARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetBufferParameteriv\0"
+ "glGetBufferParameterivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_list_priority)
+static const char ListParameteriSGIX_names[] =
+ "iii\0" /* Parameter signature */
+ "glListParameteriSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char ReplacementCodeuiColor4fNormal3fVertex3fSUN_names[] =
+ "iffffffffff\0" /* Parameter signature */
+ "glReplacementCodeuiColor4fNormal3fVertex3fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_instruments)
+static const char InstrumentsBufferSGIX_names[] =
+ "ip\0" /* Parameter signature */
+ "glInstrumentsBufferSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4NivARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4NivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_triangle_list)
+static const char ReplacementCodeuivSUN_names[] =
+ "p\0" /* Parameter signature */
+ "glReplacementCodeuivSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
+static const char WindowPos2iMESA_names[] =
+ "ii\0" /* Parameter signature */
+ "glWindowPos2i\0"
+ "glWindowPos2iARB\0"
+ "glWindowPos2iMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
+static const char SecondaryColor3fvEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glSecondaryColor3fv\0"
+ "glSecondaryColor3fvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_texture_compression)
+static const char CompressedTexSubImage1DARB_names[] =
+ "iiiiiip\0" /* Parameter signature */
+ "glCompressedTexSubImage1D\0"
+ "glCompressedTexSubImage1DARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char TexCoord2fNormal3fVertex3fSUN_names[] =
+ "ffffffff\0" /* Parameter signature */
+ "glTexCoord2fNormal3fVertex3fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char GetVertexAttribivNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetVertexAttribivNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char GetProgramStringARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetProgramStringARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char CompileShaderARB_names[] =
+ "i\0" /* Parameter signature */
+ "glCompileShaderARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_register_combiners)
+static const char CombinerOutputNV_names[] =
+ "iiiiiiiiii\0" /* Parameter signature */
+ "glCombinerOutputNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_list_priority)
+static const char ListParameterfvSGIX_names[] =
+ "iip\0" /* Parameter signature */
+ "glListParameterfvSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Tangent3dvEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glTangent3dvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char GetVertexAttribfvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetVertexAttribfvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
+static const char WindowPos3sMESA_names[] =
+ "iii\0" /* Parameter signature */
+ "glWindowPos3s\0"
+ "glWindowPos3sARB\0"
+ "glWindowPos3sMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib2svNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib2svNV\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttribs1fvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glVertexAttribs1fvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char TexCoord2fVertex3fvSUN_names[] =
+ "pp\0" /* Parameter signature */
+ "glTexCoord2fVertex3fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_MESA_window_pos)
+static const char WindowPos4sMESA_names[] =
+ "iiii\0" /* Parameter signature */
+ "glWindowPos4sMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4NuivARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4NuivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char ClientActiveTextureARB_names[] =
+ "i\0" /* Parameter signature */
+ "glClientActiveTexture\0"
+ "glClientActiveTextureARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_pixel_texture)
+static const char PixelTexGenSGIX_names[] =
+ "i\0" /* Parameter signature */
+ "glPixelTexGenSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_triangle_list)
+static const char ReplacementCodeusvSUN_names[] =
+ "p\0" /* Parameter signature */
+ "glReplacementCodeusvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char Uniform4fARB_names[] =
+ "iffff\0" /* Parameter signature */
+ "glUniform4fARB\0"
+ "";
+#endif
+
+#if defined(need_GL_IBM_multimode_draw_arrays)
+static const char MultiModeDrawArraysIBM_names[] =
+ "pppii\0" /* Parameter signature */
+ "glMultiModeDrawArraysIBM\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program) || defined(need_GL_NV_vertex_program)
+static const char IsProgramNV_names[] =
+ "i\0" /* Parameter signature */
+ "glIsProgramARB\0"
+ "glIsProgramNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_triangle_list)
+static const char ReplacementCodePointerSUN_names[] =
+ "iip\0" /* Parameter signature */
+ "glReplacementCodePointerSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char ProgramEnvParameter4dARB_names[] =
+ "iidddd\0" /* Parameter signature */
+ "glProgramEnvParameter4dARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGI_color_table)
+static const char ColorTableParameterfv_names[] =
+ "iip\0" /* Parameter signature */
+ "glColorTableParameterfv\0"
+ "glColorTableParameterfvSGI\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char FragmentLightModelfSGIX_names[] =
+ "if\0" /* Parameter signature */
+ "glFragmentLightModelfSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Binormal3bvEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glBinormal3bvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_vertex_weighting)
+static const char VertexWeightfvEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glVertexWeightfvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib1dARB_names[] =
+ "id\0" /* Parameter signature */
+ "glVertexAttrib1dARB\0"
+ "";
+#endif
+
+#if defined(need_GL_HP_image_transform)
+static const char ImageTransformParameterivHP_names[] =
+ "iip\0" /* Parameter signature */
+ "glImageTransformParameterivHP\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_occlusion_query)
+static const char DeleteQueriesARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glDeleteQueries\0"
+ "glDeleteQueriesARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char Color4ubVertex2fSUN_names[] =
+ "iiiiff\0" /* Parameter signature */
+ "glColor4ubVertex2fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char FragmentColorMaterialSGIX_names[] =
+ "ii\0" /* Parameter signature */
+ "glFragmentColorMaterialSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_matrix_palette)
+static const char CurrentPaletteMatrixARB_names[] =
+ "i\0" /* Parameter signature */
+ "glCurrentPaletteMatrixARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib4sNV_names[] =
+ "iiiii\0" /* Parameter signature */
+ "glVertexAttrib4sNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_multisample) || defined(need_GL_EXT_multisample)
+static const char SamplePatternSGIS_names[] =
+ "i\0" /* Parameter signature */
+ "glSamplePatternSGIS\0"
+ "glSamplePatternEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_occlusion_query)
+static const char IsQueryARB_names[] =
+ "i\0" /* Parameter signature */
+ "glIsQuery\0"
+ "glIsQueryARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char ReplacementCodeuiColor4ubVertex3fSUN_names[] =
+ "iiiiifff\0" /* Parameter signature */
+ "glReplacementCodeuiColor4ubVertex3fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char LinkProgramARB_names[] =
+ "i\0" /* Parameter signature */
+ "glLinkProgramARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib2fNV_names[] =
+ "iff\0" /* Parameter signature */
+ "glVertexAttrib2fNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char ShaderSourceARB_names[] =
+ "iipp\0" /* Parameter signature */
+ "glShaderSourceARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char FragmentMaterialiSGIX_names[] =
+ "iii\0" /* Parameter signature */
+ "glFragmentMaterialiSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib3svARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib3svARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_texture_compression)
+static const char CompressedTexSubImage3DARB_names[] =
+ "iiiiiiiiiip\0" /* Parameter signature */
+ "glCompressedTexSubImage3D\0"
+ "glCompressedTexSubImage3DARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
+static const char WindowPos2ivMESA_names[] =
+ "p\0" /* Parameter signature */
+ "glWindowPos2iv\0"
+ "glWindowPos2ivARB\0"
+ "glWindowPos2ivMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const char IsFramebufferEXT_names[] =
+ "i\0" /* Parameter signature */
+ "glIsFramebufferEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char Uniform4ivARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glUniform4ivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char GetVertexAttribdvARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetVertexAttribdvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Binormal3dEXT_names[] =
+ "ddd\0" /* Parameter signature */
+ "glBinormal3dEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_sprite)
+static const char SpriteParameteriSGIX_names[] =
+ "ii\0" /* Parameter signature */
+ "glSpriteParameteriSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char RequestResidentProgramsNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glRequestResidentProgramsNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_tag_sample_buffer)
+static const char TagSampleBufferSGIX_names[] =
+ "\0" /* Parameter signature */
+ "glTagSampleBufferSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_triangle_list)
+static const char ReplacementCodeusSUN_names[] =
+ "i\0" /* Parameter signature */
+ "glReplacementCodeusSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_list_priority)
+static const char ListParameterivSGIX_names[] =
+ "iip\0" /* Parameter signature */
+ "glListParameterivSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_multi_draw_arrays)
+static const char MultiDrawElementsEXT_names[] =
+ "ipipi\0" /* Parameter signature */
+ "glMultiDrawElements\0"
+ "glMultiDrawElementsEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char Uniform1ivARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glUniform1ivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
+static const char WindowPos2sMESA_names[] =
+ "ii\0" /* Parameter signature */
+ "glWindowPos2s\0"
+ "glWindowPos2sARB\0"
+ "glWindowPos2sMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_blend)
+static const char WeightusvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glWeightusvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_fog_coord)
+static const char FogCoordPointerEXT_names[] =
+ "iip\0" /* Parameter signature */
+ "glFogCoordPointer\0"
+ "glFogCoordPointerEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_index_material)
+static const char IndexMaterialEXT_names[] =
+ "ii\0" /* Parameter signature */
+ "glIndexMaterialEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
+static const char SecondaryColor3ubvEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glSecondaryColor3ubv\0"
+ "glSecondaryColor3ubvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4dvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4dvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_shader)
+static const char BindAttribLocationARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glBindAttribLocationARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord2dARB_names[] =
+ "idd\0" /* Parameter signature */
+ "glMultiTexCoord2d\0"
+ "glMultiTexCoord2dARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char ExecuteProgramNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glExecuteProgramNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char LightEnviSGIX_names[] =
+ "ii\0" /* Parameter signature */
+ "glLightEnviSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_SGI_color_table)
+static const char GetColorTableParameterivSGI_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetColorTableParameterivSGI\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_triangle_list)
+static const char ReplacementCodeuiSUN_names[] =
+ "i\0" /* Parameter signature */
+ "glReplacementCodeuiSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const char FramebufferTexture2DEXT_names[] =
+ "iiiii\0" /* Parameter signature */
+ "glFramebufferTexture2DEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttribPointerNV_names[] =
+ "iiiip\0" /* Parameter signature */
+ "glVertexAttribPointerNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const char GetFramebufferAttachmentParameterivEXT_names[] =
+ "iiip\0" /* Parameter signature */
+ "glGetFramebufferAttachmentParameterivEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord4dvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMultiTexCoord4dv\0"
+ "glMultiTexCoord4dvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_pixel_transform)
+static const char PixelTransformParameteriEXT_names[] =
+ "iii\0" /* Parameter signature */
+ "glPixelTransformParameteriEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char ValidateProgramARB_names[] =
+ "i\0" /* Parameter signature */
+ "glValidateProgramARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char TexCoord2fColor4ubVertex3fSUN_names[] =
+ "ffiiiifff\0" /* Parameter signature */
+ "glTexCoord2fColor4ubVertex3fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char Uniform1iARB_names[] =
+ "ii\0" /* Parameter signature */
+ "glUniform1iARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttribPointerARB_names[] =
+ "iiiiip\0" /* Parameter signature */
+ "glVertexAttribPointerARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_sharpen_texture)
+static const char SharpenTexFuncSGIS_names[] =
+ "iip\0" /* Parameter signature */
+ "glSharpenTexFuncSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord4fvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMultiTexCoord4fv\0"
+ "glMultiTexCoord4fvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char TrackMatrixNV_names[] =
+ "iiii\0" /* Parameter signature */
+ "glTrackMatrixNV\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_register_combiners)
+static const char CombinerParameteriNV_names[] =
+ "ii\0" /* Parameter signature */
+ "glCombinerParameteriNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_async)
+static const char DeleteAsyncMarkersSGIX_names[] =
+ "ii\0" /* Parameter signature */
+ "glDeleteAsyncMarkersSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_async)
+static const char IsAsyncMarkerSGIX_names[] =
+ "i\0" /* Parameter signature */
+ "glIsAsyncMarkerSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_framezoom)
+static const char FrameZoomSGIX_names[] =
+ "i\0" /* Parameter signature */
+ "glFrameZoomSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char Normal3fVertex3fvSUN_names[] =
+ "pp\0" /* Parameter signature */
+ "glNormal3fVertex3fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4NsvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4NsvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib3fvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib3fvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const char DeleteFramebuffersEXT_names[] =
+ "ip\0" /* Parameter signature */
+ "glDeleteFramebuffersEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_global_alpha)
+static const char GlobalAlphaFactorsSUN_names[] =
+ "i\0" /* Parameter signature */
+ "glGlobalAlphaFactorsSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_texture3D)
+static const char TexSubImage3D_names[] =
+ "iiiiiiiiiip\0" /* Parameter signature */
+ "glTexSubImage3D\0"
+ "glTexSubImage3DEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Tangent3fEXT_names[] =
+ "fff\0" /* Parameter signature */
+ "glTangent3fEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
+static const char SecondaryColor3uivEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glSecondaryColor3uiv\0"
+ "glSecondaryColor3uivEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_matrix_palette)
+static const char MatrixIndexubvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMatrixIndexubvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char Color4fNormal3fVertex3fSUN_names[] =
+ "ffffffffff\0" /* Parameter signature */
+ "glColor4fNormal3fVertex3fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_pixel_texture)
+static const char PixelTexGenParameterfSGIS_names[] =
+ "if\0" /* Parameter signature */
+ "glPixelTexGenParameterfSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char TexCoord2fColor4fNormal3fVertex3fvSUN_names[] =
+ "pppp\0" /* Parameter signature */
+ "glTexCoord2fColor4fNormal3fVertex3fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char FragmentLightModelfvSGIX_names[] =
+ "ip\0" /* Parameter signature */
+ "glFragmentLightModelfvSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord3fARB_names[] =
+ "ifff\0" /* Parameter signature */
+ "glMultiTexCoord3f\0"
+ "glMultiTexCoord3fARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_pixel_texture)
+static const char GetPixelTexGenParameterfvSGIS_names[] =
+ "ip\0" /* Parameter signature */
+ "glGetPixelTexGenParameterfvSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const char GenFramebuffersEXT_names[] =
+ "ip\0" /* Parameter signature */
+ "glGenFramebuffersEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char GetProgramParameterdvNV_names[] =
+ "iiip\0" /* Parameter signature */
+ "glGetProgramParameterdvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_pixel_transform)
+static const char PixelTransformParameterfEXT_names[] =
+ "iif\0" /* Parameter signature */
+ "glPixelTransformParameterfEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char FragmentLightfvSGIX_names[] =
+ "iip\0" /* Parameter signature */
+ "glFragmentLightfvSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib3sNV_names[] =
+ "iiii\0" /* Parameter signature */
+ "glVertexAttrib3sNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4NubARB_names[] =
+ "iiiii\0" /* Parameter signature */
+ "glVertexAttrib4NubARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char GetProgramEnvParameterfvARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetProgramEnvParameterfvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char GetTrackMatrixivNV_names[] =
+ "iiip\0" /* Parameter signature */
+ "glGetTrackMatrixivNV\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib3svNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib3svNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char Uniform4fvARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glUniform4fvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_transpose_matrix)
+static const char MultTransposeMatrixfARB_names[] =
+ "p\0" /* Parameter signature */
+ "glMultTransposeMatrixf\0"
+ "glMultTransposeMatrixfARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ATI_fragment_shader)
+static const char ColorFragmentOp1ATI_names[] =
+ "iiiiiii\0" /* Parameter signature */
+ "glColorFragmentOp1ATI\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char GetUniformfvARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetUniformfvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN_names[] =
+ "iffffffffffff\0" /* Parameter signature */
+ "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char DetachObjectARB_names[] =
+ "ii\0" /* Parameter signature */
+ "glDetachObjectARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_blend)
+static const char VertexBlendARB_names[] =
+ "i\0" /* Parameter signature */
+ "glVertexBlendARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
+static const char WindowPos3iMESA_names[] =
+ "iii\0" /* Parameter signature */
+ "glWindowPos3i\0"
+ "glWindowPos3iARB\0"
+ "glWindowPos3iMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_convolution)
+static const char SeparableFilter2D_names[] =
+ "iiiiiipp\0" /* Parameter signature */
+ "glSeparableFilter2D\0"
+ "glSeparableFilter2DEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char ReplacementCodeuiColor4ubVertex3fvSUN_names[] =
+ "ppp\0" /* Parameter signature */
+ "glReplacementCodeuiColor4ubVertex3fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_texture_compression)
+static const char CompressedTexImage2DARB_names[] =
+ "iiiiiiip\0" /* Parameter signature */
+ "glCompressedTexImage2D\0"
+ "glCompressedTexImage2DARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_vertex_array)
+static const char ArrayElement_names[] =
+ "i\0" /* Parameter signature */
+ "glArrayElement\0"
+ "glArrayElementEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_depth_bounds_test)
+static const char DepthBoundsEXT_names[] =
+ "dd\0" /* Parameter signature */
+ "glDepthBoundsEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char ProgramParameters4fvNV_names[] =
+ "iiip\0" /* Parameter signature */
+ "glProgramParameters4fvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_polynomial_ffd)
+static const char DeformationMap3fSGIX_names[] =
+ "iffiiffiiffiip\0" /* Parameter signature */
+ "glDeformationMap3fSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char GetProgramivNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetProgramivNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_copy_texture)
+static const char CopyTexImage1D_names[] =
+ "iiiiiii\0" /* Parameter signature */
+ "glCopyTexImage1D\0"
+ "glCopyTexImage1DEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ATI_fragment_shader)
+static const char AlphaFragmentOp3ATI_names[] =
+ "iiiiiiiiiiii\0" /* Parameter signature */
+ "glAlphaFragmentOp3ATI\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char GetVertexAttribdvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetVertexAttribdvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib3fvNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib3fvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_register_combiners)
+static const char GetFinalCombinerInputParameterivNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetFinalCombinerInputParameterivNV\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_evaluators)
+static const char GetMapParameterivNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetMapParameterivNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char Uniform4iARB_names[] =
+ "iiiii\0" /* Parameter signature */
+ "glUniform4iARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_convolution)
+static const char ConvolutionParameteri_names[] =
+ "iii\0" /* Parameter signature */
+ "glConvolutionParameteri\0"
+ "glConvolutionParameteriEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Binormal3sEXT_names[] =
+ "iii\0" /* Parameter signature */
+ "glBinormal3sEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_convolution)
+static const char ConvolutionParameterf_names[] =
+ "iif\0" /* Parameter signature */
+ "glConvolutionParameterf\0"
+ "glConvolutionParameterfEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttribs2fvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glVertexAttribs2fvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_matrix_palette)
+static const char MatrixIndexPointerARB_names[] =
+ "iiip\0" /* Parameter signature */
+ "glMatrixIndexPointerARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_evaluators)
+static const char GetMapParameterfvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetMapParameterfvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ATI_fragment_shader)
+static const char PassTexCoordATI_names[] =
+ "iii\0" /* Parameter signature */
+ "glPassTexCoordATI\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib1fvNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib1fvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Tangent3ivEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glTangent3ivEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Tangent3dEXT_names[] =
+ "ddd\0" /* Parameter signature */
+ "glTangent3dEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
+static const char SecondaryColor3dvEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glSecondaryColor3dv\0"
+ "glSecondaryColor3dvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_multi_draw_arrays)
+static const char MultiDrawArraysEXT_names[] =
+ "ippi\0" /* Parameter signature */
+ "glMultiDrawArrays\0"
+ "glMultiDrawArraysEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const char BindRenderbufferEXT_names[] =
+ "ii\0" /* Parameter signature */
+ "glBindRenderbufferEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord4dARB_names[] =
+ "idddd\0" /* Parameter signature */
+ "glMultiTexCoord4d\0"
+ "glMultiTexCoord4dARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGI_color_table)
+static const char GetColorTableSGI_names[] =
+ "iiip\0" /* Parameter signature */
+ "glGetColorTableSGI\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
+static const char SecondaryColor3usEXT_names[] =
+ "iii\0" /* Parameter signature */
+ "glSecondaryColor3us\0"
+ "glSecondaryColor3usEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char ProgramLocalParameter4fvARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glProgramLocalParameter4fvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program) || defined(need_GL_NV_vertex_program)
+static const char DeleteProgramsNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glDeleteProgramsARB\0"
+ "glDeleteProgramsNV\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord1sARB_names[] =
+ "ii\0" /* Parameter signature */
+ "glMultiTexCoord1s\0"
+ "glMultiTexCoord1sARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char ReplacementCodeuiColor3fVertex3fSUN_names[] =
+ "iffffff\0" /* Parameter signature */
+ "glReplacementCodeuiColor3fVertex3fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program) || defined(need_GL_NV_vertex_program)
+static const char GetVertexAttribPointervNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetVertexAttribPointervARB\0"
+ "glGetVertexAttribPointervNV\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord1dvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMultiTexCoord1dv\0"
+ "glMultiTexCoord1dvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char Uniform2iARB_names[] =
+ "iii\0" /* Parameter signature */
+ "glUniform2iARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_convolution)
+static const char GetConvolutionParameterivEXT_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetConvolutionParameterivEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char GetProgramStringNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetProgramStringNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_vertex_array)
+static const char ColorPointerEXT_names[] =
+ "iiiip\0" /* Parameter signature */
+ "glColorPointerEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
+static const char MapBufferARB_names[] =
+ "ii\0" /* Parameter signature */
+ "glMapBuffer\0"
+ "glMapBufferARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Binormal3svEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glBinormal3svEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_light_texture)
+static const char ApplyTextureEXT_names[] =
+ "i\0" /* Parameter signature */
+ "glApplyTextureEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_light_texture)
+static const char TextureMaterialEXT_names[] =
+ "ii\0" /* Parameter signature */
+ "glTextureMaterialEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_light_texture)
+static const char TextureLightEXT_names[] =
+ "i\0" /* Parameter signature */
+ "glTextureLightEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_histogram)
+static const char ResetMinmax_names[] =
+ "i\0" /* Parameter signature */
+ "glResetMinmax\0"
+ "glResetMinmaxEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_texture_object)
+static const char GenTexturesEXT_names[] =
+ "ip\0" /* Parameter signature */
+ "glGenTexturesEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_sprite)
+static const char SpriteParameterfSGIX_names[] =
+ "if\0" /* Parameter signature */
+ "glSpriteParameterfSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_histogram)
+static const char GetMinmaxParameterivEXT_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetMinmaxParameterivEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttribs4dvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glVertexAttribs4dvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4dARB_names[] =
+ "idddd\0" /* Parameter signature */
+ "glVertexAttrib4dARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_fragment_program)
+static const char ProgramNamedParameter4dNV_names[] =
+ "iipdddd\0" /* Parameter signature */
+ "glProgramNamedParameter4dNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_vertex_weighting)
+static const char VertexWeightfEXT_names[] =
+ "f\0" /* Parameter signature */
+ "glVertexWeightfEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_fog_coord)
+static const char FogCoordfvEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glFogCoordfv\0"
+ "glFogCoordfvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord1ivARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMultiTexCoord1iv\0"
+ "glMultiTexCoord1ivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
+static const char SecondaryColor3ubEXT_names[] =
+ "iii\0" /* Parameter signature */
+ "glSecondaryColor3ub\0"
+ "glSecondaryColor3ubEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord2ivARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMultiTexCoord2iv\0"
+ "glMultiTexCoord2ivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_fog_function)
+static const char FogFuncSGIS_names[] =
+ "ip\0" /* Parameter signature */
+ "glFogFuncSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_copy_texture)
+static const char CopyTexSubImage2D_names[] =
+ "iiiiiiii\0" /* Parameter signature */
+ "glCopyTexSubImage2D\0"
+ "glCopyTexSubImage2DEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char GetObjectParameterivARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetObjectParameterivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char TexCoord4fVertex4fSUN_names[] =
+ "ffffffff\0" /* Parameter signature */
+ "glTexCoord4fVertex4fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char GetProgramLocalParameterdvARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetProgramLocalParameterdvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord1iARB_names[] =
+ "ii\0" /* Parameter signature */
+ "glMultiTexCoord1i\0"
+ "glMultiTexCoord1iARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char GetProgramivARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetProgramivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_blend_func_separate) || defined(need_GL_INGR_blend_func_separate)
+static const char BlendFuncSeparateEXT_names[] =
+ "iiii\0" /* Parameter signature */
+ "glBlendFuncSeparate\0"
+ "glBlendFuncSeparateEXT\0"
+ "glBlendFuncSeparateINGR\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char ProgramParameters4dvNV_names[] =
+ "iiip\0" /* Parameter signature */
+ "glProgramParameters4dvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char TexCoord2fColor3fVertex3fvSUN_names[] =
+ "ppp\0" /* Parameter signature */
+ "glTexCoord2fColor3fVertex3fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Binormal3dvEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glBinormal3dvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_texture_object)
+static const char AreTexturesResidentEXT_names[] =
+ "ipp\0" /* Parameter signature */
+ "glAreTexturesResidentEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIS_fog_function)
+static const char GetFogFuncSGIS_names[] =
+ "p\0" /* Parameter signature */
+ "glGetFogFuncSGIS\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char GetUniformLocationARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glGetUniformLocationARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
+static const char SecondaryColor3fEXT_names[] =
+ "fff\0" /* Parameter signature */
+ "glSecondaryColor3f\0"
+ "glSecondaryColor3fEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_register_combiners)
+static const char CombinerInputNV_names[] =
+ "iiiiii\0" /* Parameter signature */
+ "glCombinerInputNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib3sARB_names[] =
+ "iiii\0" /* Parameter signature */
+ "glVertexAttrib3sARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char ProgramStringARB_names[] =
+ "iiip\0" /* Parameter signature */
+ "glProgramStringARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char TexCoord4fVertex4fvSUN_names[] =
+ "pp\0" /* Parameter signature */
+ "glTexCoord4fVertex4fvSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib1fNV_names[] =
+ "if\0" /* Parameter signature */
+ "glVertexAttrib1fNV\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char FragmentLightfSGIX_names[] =
+ "iif\0" /* Parameter signature */
+ "glFragmentLightfSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_texture_compression)
+static const char GetCompressedTexImageARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetCompressedTexImage\0"
+ "glGetCompressedTexImageARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_vertex_weighting)
+static const char VertexWeightPointerEXT_names[] =
+ "iiip\0" /* Parameter signature */
+ "glVertexWeightPointerEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_stencil_two_side)
+static const char ActiveStencilFaceEXT_names[] =
+ "i\0" /* Parameter signature */
+ "glActiveStencilFaceEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_paletted_texture)
+static const char GetColorTableParameterfvEXT_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetColorTableParameterfvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char GetShaderSourceARB_names[] =
+ "iipp\0" /* Parameter signature */
+ "glGetShaderSourceARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_igloo_interface)
+static const char IglooInterfaceSGIX_names[] =
+ "ip\0" /* Parameter signature */
+ "glIglooInterfaceSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib4dNV_names[] =
+ "idddd\0" /* Parameter signature */
+ "glVertexAttrib4dNV\0"
+ "";
+#endif
+
+#if defined(need_GL_IBM_multimode_draw_arrays)
+static const char MultiModeDrawElementsIBM_names[] =
+ "ppipii\0" /* Parameter signature */
+ "glMultiModeDrawElementsIBM\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord4svARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMultiTexCoord4sv\0"
+ "glMultiTexCoord4svARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_occlusion_query)
+static const char GenQueriesARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glGenQueries\0"
+ "glGenQueriesARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const char ReplacementCodeuiVertex3fSUN_names[] =
+ "ifff\0" /* Parameter signature */
+ "glReplacementCodeuiVertex3fSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Tangent3iEXT_names[] =
+ "iii\0" /* Parameter signature */
+ "glTangent3iEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SUN_mesh_array)
+static const char DrawMeshArraysSUN_names[] =
+ "iiii\0" /* Parameter signature */
+ "glDrawMeshArraysSUN\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_evaluators)
+static const char GetMapControlPointsNV_names[] =
+ "iiiiiip\0" /* Parameter signature */
+ "glGetMapControlPointsNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char Uniform1fARB_names[] =
+ "if\0" /* Parameter signature */
+ "glUniform1fARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char ProgramLocalParameter4fARB_names[] =
+ "iiffff\0" /* Parameter signature */
+ "glProgramLocalParameter4fARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_sprite)
+static const char SpriteParameterivSGIX_names[] =
+ "ip\0" /* Parameter signature */
+ "glSpriteParameterivSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord1fARB_names[] =
+ "if\0" /* Parameter signature */
+ "glMultiTexCoord1f\0"
+ "glMultiTexCoord1fARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttribs4ubvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glVertexAttribs4ubvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_blend)
+static const char WeightsvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glWeightsvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char Uniform1fvARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glUniform1fvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_copy_texture)
+static const char CopyTexSubImage1D_names[] =
+ "iiiiii\0" /* Parameter signature */
+ "glCopyTexSubImage1D\0"
+ "glCopyTexSubImage1DEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_texture_object)
+static const char BindTexture_names[] =
+ "ii\0" /* Parameter signature */
+ "glBindTexture\0"
+ "glBindTextureEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ATI_fragment_shader)
+static const char BeginFragmentShaderATI_names[] =
+ "\0" /* Parameter signature */
+ "glBeginFragmentShaderATI\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord4fARB_names[] =
+ "iffff\0" /* Parameter signature */
+ "glMultiTexCoord4f\0"
+ "glMultiTexCoord4fARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttribs3svNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glVertexAttribs3svNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char EnableVertexAttribArrayARB_names[] =
+ "i\0" /* Parameter signature */
+ "glEnableVertexAttribArrayARB\0"
+ "";
+#endif
+
+#if defined(need_GL_INTEL_parallel_arrays)
+static const char NormalPointervINTEL_names[] =
+ "ip\0" /* Parameter signature */
+ "glNormalPointervINTEL\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_convolution)
+static const char CopyConvolutionFilter2D_names[] =
+ "iiiiii\0" /* Parameter signature */
+ "glCopyConvolutionFilter2D\0"
+ "glCopyConvolutionFilter2DEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
+static const char WindowPos3ivMESA_names[] =
+ "p\0" /* Parameter signature */
+ "glWindowPos3iv\0"
+ "glWindowPos3ivARB\0"
+ "glWindowPos3ivMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_fence)
+static const char FinishFenceNV_names[] =
+ "i\0" /* Parameter signature */
+ "glFinishFenceNV\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
+static const char IsBufferARB_names[] =
+ "i\0" /* Parameter signature */
+ "glIsBuffer\0"
+ "glIsBufferARB\0"
+ "";
+#endif
+
+#if defined(need_GL_MESA_window_pos)
+static const char WindowPos4iMESA_names[] =
+ "iiii\0" /* Parameter signature */
+ "glWindowPos4iMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4uivARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4uivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Tangent3bvEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glTangent3bvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_reference_plane)
+static const char ReferencePlaneSGIX_names[] =
+ "p\0" /* Parameter signature */
+ "glReferencePlaneSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Binormal3fvEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glBinormal3fvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_texture_object)
+static const char IsTextureEXT_names[] =
+ "i\0" /* Parameter signature */
+ "glIsTextureEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_INTEL_parallel_arrays)
+static const char TexCoordPointervINTEL_names[] =
+ "iip\0" /* Parameter signature */
+ "glTexCoordPointervINTEL\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
+static const char DeleteBuffersARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glDeleteBuffers\0"
+ "glDeleteBuffersARB\0"
+ "";
+#endif
+
+#if defined(need_GL_MESA_window_pos)
+static const char WindowPos4fvMESA_names[] =
+ "p\0" /* Parameter signature */
+ "glWindowPos4fvMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib1sNV_names[] =
+ "ii\0" /* Parameter signature */
+ "glVertexAttrib1sNV\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_secondary_color)
+static const char SecondaryColor3svEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glSecondaryColor3sv\0"
+ "glSecondaryColor3svEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3) || defined(need_GL_ARB_transpose_matrix)
+static const char LoadTransposeMatrixfARB_names[] =
+ "p\0" /* Parameter signature */
+ "glLoadTransposeMatrixf\0"
+ "glLoadTransposeMatrixfARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_vertex_array)
+static const char GetPointerv_names[] =
+ "ip\0" /* Parameter signature */
+ "glGetPointerv\0"
+ "glGetPointervEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Tangent3bEXT_names[] =
+ "iii\0" /* Parameter signature */
+ "glTangent3bEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_register_combiners)
+static const char CombinerParameterfNV_names[] =
+ "if\0" /* Parameter signature */
+ "glCombinerParameterfNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program) || defined(need_GL_NV_vertex_program)
+static const char BindProgramNV_names[] =
+ "ii\0" /* Parameter signature */
+ "glBindProgramARB\0"
+ "glBindProgramNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4svARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4svARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char Uniform3fARB_names[] =
+ "ifff\0" /* Parameter signature */
+ "glUniform3fARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ATI_fragment_shader)
+static const char BindFragmentShaderATI_names[] =
+ "i\0" /* Parameter signature */
+ "glBindFragmentShaderATI\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
+static const char UnmapBufferARB_names[] =
+ "i\0" /* Parameter signature */
+ "glUnmapBuffer\0"
+ "glUnmapBufferARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_histogram)
+static const char Minmax_names[] =
+ "iii\0" /* Parameter signature */
+ "glMinmax\0"
+ "glMinmaxEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_EXT_fog_coord)
+static const char FogCoorddvEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glFogCoorddv\0"
+ "glFogCoorddvEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SUNX_constant_data)
+static const char FinishTextureSUNX_names[] =
+ "\0" /* Parameter signature */
+ "glFinishTextureSUNX\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char GetFragmentLightfvSGIX_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetFragmentLightfvSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_register_combiners)
+static const char GetFinalCombinerInputParameterfvNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetFinalCombinerInputParameterfvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib2svARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib2svARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char AreProgramsResidentNV_names[] =
+ "ipp\0" /* Parameter signature */
+ "glAreProgramsResidentNV\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
+static const char WindowPos3svMESA_names[] =
+ "p\0" /* Parameter signature */
+ "glWindowPos3sv\0"
+ "glWindowPos3svARB\0"
+ "glWindowPos3svMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_color_subtable)
+static const char CopyColorSubTable_names[] =
+ "iiiii\0" /* Parameter signature */
+ "glCopyColorSubTable\0"
+ "glCopyColorSubTableEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_blend)
+static const char WeightdvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glWeightdvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_instruments)
+static const char PollInstrumentsSGIX_names[] =
+ "p\0" /* Parameter signature */
+ "glPollInstrumentsSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib4NubvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4NubvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib3dvNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib3dvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char GetObjectParameterfvARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetObjectParameterfvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char GetProgramEnvParameterdvARB_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetProgramEnvParameterdvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_compiled_vertex_array)
+static const char LockArraysEXT_names[] =
+ "ii\0" /* Parameter signature */
+ "glLockArraysEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_pixel_transform)
+static const char PixelTransformParameterivEXT_names[] =
+ "iip\0" /* Parameter signature */
+ "glPixelTransformParameterivEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char BinormalPointerEXT_names[] =
+ "iip\0" /* Parameter signature */
+ "glBinormalPointerEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib1dNV_names[] =
+ "id\0" /* Parameter signature */
+ "glVertexAttrib1dNV\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_register_combiners)
+static const char GetCombinerInputParameterivNV_names[] =
+ "iiiip\0" /* Parameter signature */
+ "glGetCombinerInputParameterivNV\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const char MultiTexCoord2fvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glMultiTexCoord2fv\0"
+ "glMultiTexCoord2fvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const char GetRenderbufferParameterivEXT_names[] =
+ "iip\0" /* Parameter signature */
+ "glGetRenderbufferParameterivEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_register_combiners)
+static const char CombinerParameterivNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glCombinerParameterivNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ATI_fragment_shader)
+static const char GenFragmentShadersATI_names[] =
+ "i\0" /* Parameter signature */
+ "glGenFragmentShadersATI\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_vertex_array)
+static const char DrawArrays_names[] =
+ "iii\0" /* Parameter signature */
+ "glDrawArrays\0"
+ "glDrawArraysEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_blend)
+static const char WeightuivARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glWeightuivARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib2sARB_names[] =
+ "iii\0" /* Parameter signature */
+ "glVertexAttrib2sARB\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_async)
+static const char GenAsyncMarkersSGIX_names[] =
+ "i\0" /* Parameter signature */
+ "glGenAsyncMarkersSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Tangent3svEXT_names[] =
+ "p\0" /* Parameter signature */
+ "glTangent3svEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
+static const char BindBufferARB_names[] =
+ "ii\0" /* Parameter signature */
+ "glBindBuffer\0"
+ "glBindBufferARB\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const char GetInfoLogARB_names[] =
+ "iipp\0" /* Parameter signature */
+ "glGetInfoLogARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttribs4svNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glVertexAttribs4svNV\0"
+ "";
+#endif
+
+#if defined(need_GL_IBM_vertex_array_lists)
+static const char EdgeFlagPointerListIBM_names[] =
+ "ipi\0" /* Parameter signature */
+ "glEdgeFlagPointerListIBM\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const char VertexAttrib1fvARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib1fvARB\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_5) || defined(need_GL_ARB_vertex_buffer_object)
+static const char GenBuffersARB_names[] =
+ "ip\0" /* Parameter signature */
+ "glGenBuffers\0"
+ "glGenBuffersARB\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttribs1svNV_names[] =
+ "iip\0" /* Parameter signature */
+ "glVertexAttribs1svNV\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Binormal3bEXT_names[] =
+ "iii\0" /* Parameter signature */
+ "glBinormal3bEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const char FragmentMaterialivSGIX_names[] =
+ "iip\0" /* Parameter signature */
+ "glFragmentMaterialivSGIX\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_array_range)
+static const char VertexArrayRangeNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexArrayRangeNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ARB_vertex_program) || defined(need_GL_NV_vertex_program)
+static const char GenProgramsNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glGenProgramsARB\0"
+ "glGenProgramsNV\0"
+ "";
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const char VertexAttrib4dvNV_names[] =
+ "ip\0" /* Parameter signature */
+ "glVertexAttrib4dvNV\0"
+ "";
+#endif
+
+#if defined(need_GL_ATI_fragment_shader)
+static const char EndFragmentShaderATI_names[] =
+ "\0" /* Parameter signature */
+ "glEndFragmentShaderATI\0"
+ "";
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const char Binormal3iEXT_names[] =
+ "iii\0" /* Parameter signature */
+ "glBinormal3iEXT\0"
+ "";
+#endif
+
+#if defined(need_GL_VERSION_1_4) || defined(need_GL_ARB_window_pos) || defined(need_GL_MESA_window_pos)
+static const char WindowPos2fMESA_names[] =
+ "ff\0" /* Parameter signature */
+ "glWindowPos2f\0"
+ "glWindowPos2fARB\0"
+ "glWindowPos2fMESA\0"
+ "";
+#endif
+
+#if defined(need_GL_3DFX_tbuffer)
+static const struct dri_extension_function GL_3DFX_tbuffer_functions[] = {
+ { TbufferMask3DFX_names, TbufferMask3DFX_remap_index, 553 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_ARB_draw_buffers)
+static const struct dri_extension_function GL_ARB_draw_buffers_functions[] = {
+ { DrawBuffersARB_names, DrawBuffersARB_remap_index, 413 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_ARB_matrix_palette)
+static const struct dri_extension_function GL_ARB_matrix_palette_functions[] = {
+ { MatrixIndexusvARB_names, MatrixIndexusvARB_remap_index, -1 },
+ { MatrixIndexuivARB_names, MatrixIndexuivARB_remap_index, -1 },
+ { CurrentPaletteMatrixARB_names, CurrentPaletteMatrixARB_remap_index, -1 },
+ { MatrixIndexubvARB_names, MatrixIndexubvARB_remap_index, -1 },
+ { MatrixIndexPointerARB_names, MatrixIndexPointerARB_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_ARB_multisample)
+static const struct dri_extension_function GL_ARB_multisample_functions[] = {
+ { SampleCoverageARB_names, SampleCoverageARB_remap_index, 412 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_ARB_occlusion_query)
+static const struct dri_extension_function GL_ARB_occlusion_query_functions[] = {
+ { BeginQueryARB_names, BeginQueryARB_remap_index, 703 },
+ { GetQueryivARB_names, GetQueryivARB_remap_index, 705 },
+ { GetQueryObjectivARB_names, GetQueryObjectivARB_remap_index, 706 },
+ { EndQueryARB_names, EndQueryARB_remap_index, 704 },
+ { GetQueryObjectuivARB_names, GetQueryObjectuivARB_remap_index, 707 },
+ { DeleteQueriesARB_names, DeleteQueriesARB_remap_index, 701 },
+ { IsQueryARB_names, IsQueryARB_remap_index, 702 },
+ { GenQueriesARB_names, GenQueriesARB_remap_index, 700 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_ARB_point_parameters)
+static const struct dri_extension_function GL_ARB_point_parameters_functions[] = {
+ { PointParameterfEXT_names, PointParameterfEXT_remap_index, 458 },
+ { PointParameterfvEXT_names, PointParameterfvEXT_remap_index, 459 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_ARB_shader_objects)
+static const struct dri_extension_function GL_ARB_shader_objects_functions[] = {
+ { UniformMatrix3fvARB_names, UniformMatrix3fvARB_remap_index, 739 },
+ { Uniform2fARB_names, Uniform2fARB_remap_index, 723 },
+ { Uniform2ivARB_names, Uniform2ivARB_remap_index, 735 },
+ { UniformMatrix4fvARB_names, UniformMatrix4fvARB_remap_index, 740 },
+ { CreateProgramObjectARB_names, CreateProgramObjectARB_remap_index, 717 },
+ { Uniform3iARB_names, Uniform3iARB_remap_index, 728 },
+ { CreateShaderObjectARB_names, CreateShaderObjectARB_remap_index, 714 },
+ { AttachObjectARB_names, AttachObjectARB_remap_index, 718 },
+ { UniformMatrix2fvARB_names, UniformMatrix2fvARB_remap_index, 738 },
+ { GetAttachedObjectsARB_names, GetAttachedObjectsARB_remap_index, 744 },
+ { Uniform3fvARB_names, Uniform3fvARB_remap_index, 732 },
+ { GetHandleARB_names, GetHandleARB_remap_index, 712 },
+ { GetActiveUniformARB_names, GetActiveUniformARB_remap_index, 746 },
+ { GetUniformivARB_names, GetUniformivARB_remap_index, 748 },
+ { Uniform2fvARB_names, Uniform2fvARB_remap_index, 731 },
+ { DeleteObjectARB_names, DeleteObjectARB_remap_index, 711 },
+ { UseProgramObjectARB_names, UseProgramObjectARB_remap_index, 720 },
+ { Uniform3ivARB_names, Uniform3ivARB_remap_index, 736 },
+ { CompileShaderARB_names, CompileShaderARB_remap_index, 716 },
+ { Uniform4fARB_names, Uniform4fARB_remap_index, 725 },
+ { LinkProgramARB_names, LinkProgramARB_remap_index, 719 },
+ { ShaderSourceARB_names, ShaderSourceARB_remap_index, 715 },
+ { Uniform4ivARB_names, Uniform4ivARB_remap_index, 737 },
+ { Uniform1ivARB_names, Uniform1ivARB_remap_index, 734 },
+ { ValidateProgramARB_names, ValidateProgramARB_remap_index, 721 },
+ { Uniform1iARB_names, Uniform1iARB_remap_index, 726 },
+ { Uniform4fvARB_names, Uniform4fvARB_remap_index, 733 },
+ { GetUniformfvARB_names, GetUniformfvARB_remap_index, 747 },
+ { DetachObjectARB_names, DetachObjectARB_remap_index, 713 },
+ { Uniform4iARB_names, Uniform4iARB_remap_index, 729 },
+ { Uniform2iARB_names, Uniform2iARB_remap_index, 727 },
+ { GetObjectParameterivARB_names, GetObjectParameterivARB_remap_index, 742 },
+ { GetUniformLocationARB_names, GetUniformLocationARB_remap_index, 745 },
+ { GetShaderSourceARB_names, GetShaderSourceARB_remap_index, 749 },
+ { Uniform1fARB_names, Uniform1fARB_remap_index, 722 },
+ { Uniform1fvARB_names, Uniform1fvARB_remap_index, 730 },
+ { Uniform3fARB_names, Uniform3fARB_remap_index, 724 },
+ { GetObjectParameterfvARB_names, GetObjectParameterfvARB_remap_index, 741 },
+ { GetInfoLogARB_names, GetInfoLogARB_remap_index, 743 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_ARB_texture_compression)
+static const struct dri_extension_function GL_ARB_texture_compression_functions[] = {
+ { CompressedTexSubImage2DARB_names, CompressedTexSubImage2DARB_remap_index, 558 },
+ { CompressedTexImage3DARB_names, CompressedTexImage3DARB_remap_index, 554 },
+ { CompressedTexImage1DARB_names, CompressedTexImage1DARB_remap_index, 556 },
+ { CompressedTexSubImage1DARB_names, CompressedTexSubImage1DARB_remap_index, 559 },
+ { CompressedTexSubImage3DARB_names, CompressedTexSubImage3DARB_remap_index, 557 },
+ { CompressedTexImage2DARB_names, CompressedTexImage2DARB_remap_index, 555 },
+ { GetCompressedTexImageARB_names, GetCompressedTexImageARB_remap_index, 560 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_ARB_transpose_matrix)
+static const struct dri_extension_function GL_ARB_transpose_matrix_functions[] = {
+ { MultTransposeMatrixdARB_names, MultTransposeMatrixdARB_remap_index, 411 },
+ { LoadTransposeMatrixdARB_names, LoadTransposeMatrixdARB_remap_index, 409 },
+ { MultTransposeMatrixfARB_names, MultTransposeMatrixfARB_remap_index, 410 },
+ { LoadTransposeMatrixfARB_names, LoadTransposeMatrixfARB_remap_index, 408 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_ARB_vertex_blend)
+static const struct dri_extension_function GL_ARB_vertex_blend_functions[] = {
+ { WeightubvARB_names, WeightubvARB_remap_index, -1 },
+ { WeightivARB_names, WeightivARB_remap_index, -1 },
+ { WeightPointerARB_names, WeightPointerARB_remap_index, -1 },
+ { WeightfvARB_names, WeightfvARB_remap_index, -1 },
+ { WeightbvARB_names, WeightbvARB_remap_index, -1 },
+ { WeightusvARB_names, WeightusvARB_remap_index, -1 },
+ { VertexBlendARB_names, VertexBlendARB_remap_index, -1 },
+ { WeightsvARB_names, WeightsvARB_remap_index, -1 },
+ { WeightdvARB_names, WeightdvARB_remap_index, -1 },
+ { WeightuivARB_names, WeightuivARB_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_ARB_vertex_buffer_object)
+static const struct dri_extension_function GL_ARB_vertex_buffer_object_functions[] = {
+ { GetBufferSubDataARB_names, GetBufferSubDataARB_remap_index, 695 },
+ { BufferSubDataARB_names, BufferSubDataARB_remap_index, 690 },
+ { BufferDataARB_names, BufferDataARB_remap_index, 689 },
+ { GetBufferPointervARB_names, GetBufferPointervARB_remap_index, 694 },
+ { GetBufferParameterivARB_names, GetBufferParameterivARB_remap_index, 693 },
+ { MapBufferARB_names, MapBufferARB_remap_index, 697 },
+ { IsBufferARB_names, IsBufferARB_remap_index, 696 },
+ { DeleteBuffersARB_names, DeleteBuffersARB_remap_index, 691 },
+ { UnmapBufferARB_names, UnmapBufferARB_remap_index, 698 },
+ { BindBufferARB_names, BindBufferARB_remap_index, 688 },
+ { GenBuffersARB_names, GenBuffersARB_remap_index, 692 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_ARB_vertex_program)
+static const struct dri_extension_function GL_ARB_vertex_program_functions[] = {
+ { ProgramEnvParameter4dvARB_names, ProgramEnvParameter4dvARB_remap_index, 669 },
+ { VertexAttrib2fARB_names, VertexAttrib2fARB_remap_index, 611 },
+ { VertexAttrib3fARB_names, VertexAttrib3fARB_remap_index, 617 },
+ { VertexAttrib1svARB_names, VertexAttrib1svARB_remap_index, 608 },
+ { VertexAttrib4NusvARB_names, VertexAttrib4NusvARB_remap_index, 662 },
+ { DisableVertexAttribArrayARB_names, DisableVertexAttribArrayARB_remap_index, 666 },
+ { ProgramLocalParameter4dARB_names, ProgramLocalParameter4dARB_remap_index, 672 },
+ { VertexAttrib1fARB_names, VertexAttrib1fARB_remap_index, 605 },
+ { VertexAttrib4NbvARB_names, VertexAttrib4NbvARB_remap_index, 659 },
+ { VertexAttrib1sARB_names, VertexAttrib1sARB_remap_index, 607 },
+ { GetProgramLocalParameterfvARB_names, GetProgramLocalParameterfvARB_remap_index, 679 },
+ { VertexAttrib3dvARB_names, VertexAttrib3dvARB_remap_index, 616 },
+ { ProgramEnvParameter4fvARB_names, ProgramEnvParameter4fvARB_remap_index, 671 },
+ { GetVertexAttribivARB_names, GetVertexAttribivARB_remap_index, 590 },
+ { VertexAttrib4ivARB_names, VertexAttrib4ivARB_remap_index, 655 },
+ { VertexAttrib4bvARB_names, VertexAttrib4bvARB_remap_index, 654 },
+ { VertexAttrib3dARB_names, VertexAttrib3dARB_remap_index, 615 },
+ { VertexAttrib4fARB_names, VertexAttrib4fARB_remap_index, 623 },
+ { VertexAttrib4fvARB_names, VertexAttrib4fvARB_remap_index, 624 },
+ { ProgramLocalParameter4dvARB_names, ProgramLocalParameter4dvARB_remap_index, 673 },
+ { VertexAttrib4usvARB_names, VertexAttrib4usvARB_remap_index, 657 },
+ { VertexAttrib2dARB_names, VertexAttrib2dARB_remap_index, 609 },
+ { VertexAttrib1dvARB_names, VertexAttrib1dvARB_remap_index, 604 },
+ { GetVertexAttribfvARB_names, GetVertexAttribfvARB_remap_index, 589 },
+ { VertexAttrib4ubvARB_names, VertexAttrib4ubvARB_remap_index, 656 },
+ { ProgramEnvParameter4fARB_names, ProgramEnvParameter4fARB_remap_index, 670 },
+ { VertexAttrib4sARB_names, VertexAttrib4sARB_remap_index, 625 },
+ { VertexAttrib2dvARB_names, VertexAttrib2dvARB_remap_index, 610 },
+ { VertexAttrib2fvARB_names, VertexAttrib2fvARB_remap_index, 612 },
+ { VertexAttrib4NivARB_names, VertexAttrib4NivARB_remap_index, 661 },
+ { GetProgramStringARB_names, GetProgramStringARB_remap_index, 681 },
+ { VertexAttrib4NuivARB_names, VertexAttrib4NuivARB_remap_index, 663 },
+ { IsProgramNV_names, IsProgramNV_remap_index, 592 },
+ { ProgramEnvParameter4dARB_names, ProgramEnvParameter4dARB_remap_index, 668 },
+ { VertexAttrib1dARB_names, VertexAttrib1dARB_remap_index, 603 },
+ { VertexAttrib3svARB_names, VertexAttrib3svARB_remap_index, 620 },
+ { GetVertexAttribdvARB_names, GetVertexAttribdvARB_remap_index, 588 },
+ { VertexAttrib4dvARB_names, VertexAttrib4dvARB_remap_index, 622 },
+ { VertexAttribPointerARB_names, VertexAttribPointerARB_remap_index, 664 },
+ { VertexAttrib4NsvARB_names, VertexAttrib4NsvARB_remap_index, 660 },
+ { VertexAttrib3fvARB_names, VertexAttrib3fvARB_remap_index, 618 },
+ { VertexAttrib4NubARB_names, VertexAttrib4NubARB_remap_index, 627 },
+ { GetProgramEnvParameterfvARB_names, GetProgramEnvParameterfvARB_remap_index, 677 },
+ { ProgramLocalParameter4fvARB_names, ProgramLocalParameter4fvARB_remap_index, 675 },
+ { DeleteProgramsNV_names, DeleteProgramsNV_remap_index, 580 },
+ { GetVertexAttribPointervNV_names, GetVertexAttribPointervNV_remap_index, 591 },
+ { VertexAttrib4dARB_names, VertexAttrib4dARB_remap_index, 621 },
+ { GetProgramLocalParameterdvARB_names, GetProgramLocalParameterdvARB_remap_index, 678 },
+ { GetProgramivARB_names, GetProgramivARB_remap_index, 680 },
+ { VertexAttrib3sARB_names, VertexAttrib3sARB_remap_index, 619 },
+ { ProgramStringARB_names, ProgramStringARB_remap_index, 667 },
+ { ProgramLocalParameter4fARB_names, ProgramLocalParameter4fARB_remap_index, 674 },
+ { EnableVertexAttribArrayARB_names, EnableVertexAttribArrayARB_remap_index, 665 },
+ { VertexAttrib4uivARB_names, VertexAttrib4uivARB_remap_index, 658 },
+ { BindProgramNV_names, BindProgramNV_remap_index, 579 },
+ { VertexAttrib4svARB_names, VertexAttrib4svARB_remap_index, 626 },
+ { VertexAttrib2svARB_names, VertexAttrib2svARB_remap_index, 614 },
+ { VertexAttrib4NubvARB_names, VertexAttrib4NubvARB_remap_index, 628 },
+ { GetProgramEnvParameterdvARB_names, GetProgramEnvParameterdvARB_remap_index, 676 },
+ { VertexAttrib2sARB_names, VertexAttrib2sARB_remap_index, 613 },
+ { VertexAttrib1fvARB_names, VertexAttrib1fvARB_remap_index, 606 },
+ { GenProgramsNV_names, GenProgramsNV_remap_index, 582 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_ARB_vertex_shader)
+static const struct dri_extension_function GL_ARB_vertex_shader_functions[] = {
+ { GetActiveAttribARB_names, GetActiveAttribARB_remap_index, 751 },
+ { GetAttribLocationARB_names, GetAttribLocationARB_remap_index, 752 },
+ { BindAttribLocationARB_names, BindAttribLocationARB_remap_index, 750 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_ARB_window_pos)
+static const struct dri_extension_function GL_ARB_window_pos_functions[] = {
+ { WindowPos3fMESA_names, WindowPos3fMESA_remap_index, 523 },
+ { WindowPos2dvMESA_names, WindowPos2dvMESA_remap_index, 514 },
+ { WindowPos2svMESA_names, WindowPos2svMESA_remap_index, 520 },
+ { WindowPos3dMESA_names, WindowPos3dMESA_remap_index, 521 },
+ { WindowPos2fvMESA_names, WindowPos2fvMESA_remap_index, 516 },
+ { WindowPos2dMESA_names, WindowPos2dMESA_remap_index, 513 },
+ { WindowPos3dvMESA_names, WindowPos3dvMESA_remap_index, 522 },
+ { WindowPos3fvMESA_names, WindowPos3fvMESA_remap_index, 524 },
+ { WindowPos2iMESA_names, WindowPos2iMESA_remap_index, 517 },
+ { WindowPos3sMESA_names, WindowPos3sMESA_remap_index, 527 },
+ { WindowPos2ivMESA_names, WindowPos2ivMESA_remap_index, 518 },
+ { WindowPos2sMESA_names, WindowPos2sMESA_remap_index, 519 },
+ { WindowPos3iMESA_names, WindowPos3iMESA_remap_index, 525 },
+ { WindowPos3ivMESA_names, WindowPos3ivMESA_remap_index, 526 },
+ { WindowPos3svMESA_names, WindowPos3svMESA_remap_index, 528 },
+ { WindowPos2fMESA_names, WindowPos2fMESA_remap_index, 515 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_ATI_blend_equation_separate)
+static const struct dri_extension_function GL_ATI_blend_equation_separate_functions[] = {
+ { BlendEquationSeparateEXT_names, BlendEquationSeparateEXT_remap_index, 710 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_ATI_draw_buffers)
+static const struct dri_extension_function GL_ATI_draw_buffers_functions[] = {
+ { DrawBuffersARB_names, DrawBuffersARB_remap_index, 413 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_ATI_fragment_shader)
+static const struct dri_extension_function GL_ATI_fragment_shader_functions[] = {
+ { ColorFragmentOp3ATI_names, ColorFragmentOp3ATI_remap_index, 791 },
+ { ColorFragmentOp2ATI_names, ColorFragmentOp2ATI_remap_index, 790 },
+ { DeleteFragmentShaderATI_names, DeleteFragmentShaderATI_remap_index, 784 },
+ { SetFragmentShaderConstantATI_names, SetFragmentShaderConstantATI_remap_index, 795 },
+ { SampleMapATI_names, SampleMapATI_remap_index, 788 },
+ { AlphaFragmentOp2ATI_names, AlphaFragmentOp2ATI_remap_index, 793 },
+ { AlphaFragmentOp1ATI_names, AlphaFragmentOp1ATI_remap_index, 792 },
+ { ColorFragmentOp1ATI_names, ColorFragmentOp1ATI_remap_index, 789 },
+ { AlphaFragmentOp3ATI_names, AlphaFragmentOp3ATI_remap_index, 794 },
+ { PassTexCoordATI_names, PassTexCoordATI_remap_index, 787 },
+ { BeginFragmentShaderATI_names, BeginFragmentShaderATI_remap_index, 785 },
+ { BindFragmentShaderATI_names, BindFragmentShaderATI_remap_index, 783 },
+ { GenFragmentShadersATI_names, GenFragmentShadersATI_remap_index, 782 },
+ { EndFragmentShaderATI_names, EndFragmentShaderATI_remap_index, 786 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_blend_color)
+static const struct dri_extension_function GL_EXT_blend_color_functions[] = {
+ { BlendColor_names, -1, 336 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_blend_equation_separate)
+static const struct dri_extension_function GL_EXT_blend_equation_separate_functions[] = {
+ { BlendEquationSeparateEXT_names, BlendEquationSeparateEXT_remap_index, 710 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_blend_func_separate)
+static const struct dri_extension_function GL_EXT_blend_func_separate_functions[] = {
+ { BlendFuncSeparateEXT_names, BlendFuncSeparateEXT_remap_index, 537 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_blend_minmax)
+static const struct dri_extension_function GL_EXT_blend_minmax_functions[] = {
+ { BlendEquation_names, -1, 337 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_color_subtable)
+static const struct dri_extension_function GL_EXT_color_subtable_functions[] = {
+ { ColorSubTable_names, -1, 346 },
+ { CopyColorSubTable_names, -1, 347 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_compiled_vertex_array)
+static const struct dri_extension_function GL_EXT_compiled_vertex_array_functions[] = {
+ { UnlockArraysEXT_names, UnlockArraysEXT_remap_index, 541 },
+ { LockArraysEXT_names, LockArraysEXT_remap_index, 540 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_convolution)
+static const struct dri_extension_function GL_EXT_convolution_functions[] = {
+ { ConvolutionFilter1D_names, -1, 348 },
+ { CopyConvolutionFilter1D_names, -1, 354 },
+ { ConvolutionFilter2D_names, -1, 349 },
+ { ConvolutionParameteriv_names, -1, 353 },
+ { ConvolutionParameterfv_names, -1, 351 },
+ { GetSeparableFilterEXT_names, GetSeparableFilterEXT_remap_index, 426 },
+ { GetConvolutionFilterEXT_names, GetConvolutionFilterEXT_remap_index, 423 },
+ { GetConvolutionParameterfvEXT_names, GetConvolutionParameterfvEXT_remap_index, 424 },
+ { SeparableFilter2D_names, -1, 360 },
+ { ConvolutionParameteri_names, -1, 352 },
+ { ConvolutionParameterf_names, -1, 350 },
+ { GetConvolutionParameterivEXT_names, GetConvolutionParameterivEXT_remap_index, 425 },
+ { CopyConvolutionFilter2D_names, -1, 355 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_coordinate_frame)
+static const struct dri_extension_function GL_EXT_coordinate_frame_functions[] = {
+ { Binormal3fEXT_names, Binormal3fEXT_remap_index, -1 },
+ { TangentPointerEXT_names, TangentPointerEXT_remap_index, -1 },
+ { Binormal3ivEXT_names, Binormal3ivEXT_remap_index, -1 },
+ { Tangent3sEXT_names, Tangent3sEXT_remap_index, -1 },
+ { Tangent3fvEXT_names, Tangent3fvEXT_remap_index, -1 },
+ { Tangent3dvEXT_names, Tangent3dvEXT_remap_index, -1 },
+ { Binormal3bvEXT_names, Binormal3bvEXT_remap_index, -1 },
+ { Binormal3dEXT_names, Binormal3dEXT_remap_index, -1 },
+ { Tangent3fEXT_names, Tangent3fEXT_remap_index, -1 },
+ { Binormal3sEXT_names, Binormal3sEXT_remap_index, -1 },
+ { Tangent3ivEXT_names, Tangent3ivEXT_remap_index, -1 },
+ { Tangent3dEXT_names, Tangent3dEXT_remap_index, -1 },
+ { Binormal3svEXT_names, Binormal3svEXT_remap_index, -1 },
+ { Binormal3dvEXT_names, Binormal3dvEXT_remap_index, -1 },
+ { Tangent3iEXT_names, Tangent3iEXT_remap_index, -1 },
+ { Tangent3bvEXT_names, Tangent3bvEXT_remap_index, -1 },
+ { Binormal3fvEXT_names, Binormal3fvEXT_remap_index, -1 },
+ { Tangent3bEXT_names, Tangent3bEXT_remap_index, -1 },
+ { BinormalPointerEXT_names, BinormalPointerEXT_remap_index, -1 },
+ { Tangent3svEXT_names, Tangent3svEXT_remap_index, -1 },
+ { Binormal3bEXT_names, Binormal3bEXT_remap_index, -1 },
+ { Binormal3iEXT_names, Binormal3iEXT_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_copy_texture)
+static const struct dri_extension_function GL_EXT_copy_texture_functions[] = {
+ { CopyTexSubImage3D_names, -1, 373 },
+ { CopyTexImage2D_names, -1, 324 },
+ { CopyTexImage1D_names, -1, 323 },
+ { CopyTexSubImage2D_names, -1, 326 },
+ { CopyTexSubImage1D_names, -1, 325 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_cull_vertex)
+static const struct dri_extension_function GL_EXT_cull_vertex_functions[] = {
+ { CullParameterdvEXT_names, CullParameterdvEXT_remap_index, 542 },
+ { CullParameterfvEXT_names, CullParameterfvEXT_remap_index, 543 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_depth_bounds_test)
+static const struct dri_extension_function GL_EXT_depth_bounds_test_functions[] = {
+ { DepthBoundsEXT_names, DepthBoundsEXT_remap_index, 699 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_draw_range_elements)
+static const struct dri_extension_function GL_EXT_draw_range_elements_functions[] = {
+ { DrawRangeElements_names, -1, 338 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_fog_coord)
+static const struct dri_extension_function GL_EXT_fog_coord_functions[] = {
+ { FogCoorddEXT_names, FogCoorddEXT_remap_index, 547 },
+ { FogCoordfEXT_names, FogCoordfEXT_remap_index, 545 },
+ { FogCoordPointerEXT_names, FogCoordPointerEXT_remap_index, 549 },
+ { FogCoordfvEXT_names, FogCoordfvEXT_remap_index, 546 },
+ { FogCoorddvEXT_names, FogCoorddvEXT_remap_index, 548 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_framebuffer_object)
+static const struct dri_extension_function GL_EXT_framebuffer_object_functions[] = {
+ { GenerateMipmapEXT_names, GenerateMipmapEXT_remap_index, 812 },
+ { IsRenderbufferEXT_names, IsRenderbufferEXT_remap_index, 796 },
+ { RenderbufferStorageEXT_names, RenderbufferStorageEXT_remap_index, 800 },
+ { CheckFramebufferStatusEXT_names, CheckFramebufferStatusEXT_remap_index, 806 },
+ { DeleteRenderbuffersEXT_names, DeleteRenderbuffersEXT_remap_index, 798 },
+ { FramebufferTexture3DEXT_names, FramebufferTexture3DEXT_remap_index, 809 },
+ { FramebufferRenderbufferEXT_names, FramebufferRenderbufferEXT_remap_index, 810 },
+ { FramebufferTexture1DEXT_names, FramebufferTexture1DEXT_remap_index, 807 },
+ { BindFramebufferEXT_names, BindFramebufferEXT_remap_index, 803 },
+ { GenRenderbuffersEXT_names, GenRenderbuffersEXT_remap_index, 799 },
+ { IsFramebufferEXT_names, IsFramebufferEXT_remap_index, 802 },
+ { FramebufferTexture2DEXT_names, FramebufferTexture2DEXT_remap_index, 808 },
+ { GetFramebufferAttachmentParameterivEXT_names, GetFramebufferAttachmentParameterivEXT_remap_index, 811 },
+ { DeleteFramebuffersEXT_names, DeleteFramebuffersEXT_remap_index, 804 },
+ { GenFramebuffersEXT_names, GenFramebuffersEXT_remap_index, 805 },
+ { BindRenderbufferEXT_names, BindRenderbufferEXT_remap_index, 797 },
+ { GetRenderbufferParameterivEXT_names, GetRenderbufferParameterivEXT_remap_index, 801 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_histogram)
+static const struct dri_extension_function GL_EXT_histogram_functions[] = {
+ { Histogram_names, -1, 367 },
+ { GetHistogramParameterivEXT_names, GetHistogramParameterivEXT_remap_index, 419 },
+ { ResetHistogram_names, -1, 369 },
+ { GetMinmaxEXT_names, GetMinmaxEXT_remap_index, 420 },
+ { GetHistogramParameterfvEXT_names, GetHistogramParameterfvEXT_remap_index, 418 },
+ { GetHistogramEXT_names, GetHistogramEXT_remap_index, 417 },
+ { GetMinmaxParameterfvEXT_names, GetMinmaxParameterfvEXT_remap_index, 421 },
+ { ResetMinmax_names, -1, 370 },
+ { GetMinmaxParameterivEXT_names, GetMinmaxParameterivEXT_remap_index, 422 },
+ { Minmax_names, -1, 368 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_index_func)
+static const struct dri_extension_function GL_EXT_index_func_functions[] = {
+ { IndexFuncEXT_names, IndexFuncEXT_remap_index, 539 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_index_material)
+static const struct dri_extension_function GL_EXT_index_material_functions[] = {
+ { IndexMaterialEXT_names, IndexMaterialEXT_remap_index, 538 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_light_texture)
+static const struct dri_extension_function GL_EXT_light_texture_functions[] = {
+ { ApplyTextureEXT_names, ApplyTextureEXT_remap_index, -1 },
+ { TextureMaterialEXT_names, TextureMaterialEXT_remap_index, -1 },
+ { TextureLightEXT_names, TextureLightEXT_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_multi_draw_arrays)
+static const struct dri_extension_function GL_EXT_multi_draw_arrays_functions[] = {
+ { MultiDrawElementsEXT_names, MultiDrawElementsEXT_remap_index, 645 },
+ { MultiDrawArraysEXT_names, MultiDrawArraysEXT_remap_index, 644 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_multisample)
+static const struct dri_extension_function GL_EXT_multisample_functions[] = {
+ { SampleMaskSGIS_names, SampleMaskSGIS_remap_index, 446 },
+ { SamplePatternSGIS_names, SamplePatternSGIS_remap_index, 447 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_paletted_texture)
+static const struct dri_extension_function GL_EXT_paletted_texture_functions[] = {
+ { GetColorTableParameterivEXT_names, GetColorTableParameterivEXT_remap_index, 551 },
+ { GetColorTableEXT_names, GetColorTableEXT_remap_index, 550 },
+ { ColorTable_names, -1, 339 },
+ { GetColorTableParameterfvEXT_names, GetColorTableParameterfvEXT_remap_index, 552 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_pixel_transform)
+static const struct dri_extension_function GL_EXT_pixel_transform_functions[] = {
+ { PixelTransformParameterfvEXT_names, PixelTransformParameterfvEXT_remap_index, -1 },
+ { PixelTransformParameteriEXT_names, PixelTransformParameteriEXT_remap_index, -1 },
+ { PixelTransformParameterfEXT_names, PixelTransformParameterfEXT_remap_index, -1 },
+ { PixelTransformParameterivEXT_names, PixelTransformParameterivEXT_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_point_parameters)
+static const struct dri_extension_function GL_EXT_point_parameters_functions[] = {
+ { PointParameterfEXT_names, PointParameterfEXT_remap_index, 458 },
+ { PointParameterfvEXT_names, PointParameterfvEXT_remap_index, 459 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_polygon_offset)
+static const struct dri_extension_function GL_EXT_polygon_offset_functions[] = {
+ { PolygonOffsetEXT_names, PolygonOffsetEXT_remap_index, 414 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_secondary_color)
+static const struct dri_extension_function GL_EXT_secondary_color_functions[] = {
+ { SecondaryColor3iEXT_names, SecondaryColor3iEXT_remap_index, 567 },
+ { SecondaryColor3bEXT_names, SecondaryColor3bEXT_remap_index, 561 },
+ { SecondaryColor3bvEXT_names, SecondaryColor3bvEXT_remap_index, 562 },
+ { SecondaryColor3sEXT_names, SecondaryColor3sEXT_remap_index, 569 },
+ { SecondaryColor3dEXT_names, SecondaryColor3dEXT_remap_index, 563 },
+ { SecondaryColorPointerEXT_names, SecondaryColorPointerEXT_remap_index, 577 },
+ { SecondaryColor3uiEXT_names, SecondaryColor3uiEXT_remap_index, 573 },
+ { SecondaryColor3usvEXT_names, SecondaryColor3usvEXT_remap_index, 576 },
+ { SecondaryColor3ivEXT_names, SecondaryColor3ivEXT_remap_index, 568 },
+ { SecondaryColor3fvEXT_names, SecondaryColor3fvEXT_remap_index, 566 },
+ { SecondaryColor3ubvEXT_names, SecondaryColor3ubvEXT_remap_index, 572 },
+ { SecondaryColor3uivEXT_names, SecondaryColor3uivEXT_remap_index, 574 },
+ { SecondaryColor3dvEXT_names, SecondaryColor3dvEXT_remap_index, 564 },
+ { SecondaryColor3usEXT_names, SecondaryColor3usEXT_remap_index, 575 },
+ { SecondaryColor3ubEXT_names, SecondaryColor3ubEXT_remap_index, 571 },
+ { SecondaryColor3fEXT_names, SecondaryColor3fEXT_remap_index, 565 },
+ { SecondaryColor3svEXT_names, SecondaryColor3svEXT_remap_index, 570 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_stencil_two_side)
+static const struct dri_extension_function GL_EXT_stencil_two_side_functions[] = {
+ { ActiveStencilFaceEXT_names, ActiveStencilFaceEXT_remap_index, 646 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_subtexture)
+static const struct dri_extension_function GL_EXT_subtexture_functions[] = {
+ { TexSubImage1D_names, -1, 332 },
+ { TexSubImage2D_names, -1, 333 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_texture3D)
+static const struct dri_extension_function GL_EXT_texture3D_functions[] = {
+ { TexImage3D_names, -1, 371 },
+ { TexSubImage3D_names, -1, 372 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_texture_object)
+static const struct dri_extension_function GL_EXT_texture_object_functions[] = {
+ { PrioritizeTextures_names, -1, 331 },
+ { DeleteTextures_names, -1, 327 },
+ { GenTexturesEXT_names, GenTexturesEXT_remap_index, 440 },
+ { AreTexturesResidentEXT_names, AreTexturesResidentEXT_remap_index, 439 },
+ { BindTexture_names, -1, 307 },
+ { IsTextureEXT_names, IsTextureEXT_remap_index, 441 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_texture_perturb_normal)
+static const struct dri_extension_function GL_EXT_texture_perturb_normal_functions[] = {
+ { TextureNormalEXT_names, TextureNormalEXT_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_vertex_array)
+static const struct dri_extension_function GL_EXT_vertex_array_functions[] = {
+ { IndexPointerEXT_names, IndexPointerEXT_remap_index, 450 },
+ { NormalPointerEXT_names, NormalPointerEXT_remap_index, 451 },
+ { VertexPointerEXT_names, VertexPointerEXT_remap_index, 453 },
+ { TexCoordPointerEXT_names, TexCoordPointerEXT_remap_index, 452 },
+ { EdgeFlagPointerEXT_names, EdgeFlagPointerEXT_remap_index, 449 },
+ { ArrayElement_names, -1, 306 },
+ { ColorPointerEXT_names, ColorPointerEXT_remap_index, 448 },
+ { GetPointerv_names, -1, 329 },
+ { DrawArrays_names, -1, 310 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_EXT_vertex_weighting)
+static const struct dri_extension_function GL_EXT_vertex_weighting_functions[] = {
+ { VertexWeightfvEXT_names, VertexWeightfvEXT_remap_index, 495 },
+ { VertexWeightfEXT_names, VertexWeightfEXT_remap_index, 494 },
+ { VertexWeightPointerEXT_names, VertexWeightPointerEXT_remap_index, 496 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_HP_image_transform)
+static const struct dri_extension_function GL_HP_image_transform_functions[] = {
+ { GetImageTransformParameterfvHP_names, GetImageTransformParameterfvHP_remap_index, -1 },
+ { ImageTransformParameterfHP_names, ImageTransformParameterfHP_remap_index, -1 },
+ { ImageTransformParameterfvHP_names, ImageTransformParameterfvHP_remap_index, -1 },
+ { ImageTransformParameteriHP_names, ImageTransformParameteriHP_remap_index, -1 },
+ { GetImageTransformParameterivHP_names, GetImageTransformParameterivHP_remap_index, -1 },
+ { ImageTransformParameterivHP_names, ImageTransformParameterivHP_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_IBM_multimode_draw_arrays)
+static const struct dri_extension_function GL_IBM_multimode_draw_arrays_functions[] = {
+ { MultiModeDrawArraysIBM_names, MultiModeDrawArraysIBM_remap_index, 708 },
+ { MultiModeDrawElementsIBM_names, MultiModeDrawElementsIBM_remap_index, 709 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_IBM_vertex_array_lists)
+static const struct dri_extension_function GL_IBM_vertex_array_lists_functions[] = {
+ { SecondaryColorPointerListIBM_names, SecondaryColorPointerListIBM_remap_index, -1 },
+ { NormalPointerListIBM_names, NormalPointerListIBM_remap_index, -1 },
+ { FogCoordPointerListIBM_names, FogCoordPointerListIBM_remap_index, -1 },
+ { VertexPointerListIBM_names, VertexPointerListIBM_remap_index, -1 },
+ { ColorPointerListIBM_names, ColorPointerListIBM_remap_index, -1 },
+ { TexCoordPointerListIBM_names, TexCoordPointerListIBM_remap_index, -1 },
+ { IndexPointerListIBM_names, IndexPointerListIBM_remap_index, -1 },
+ { EdgeFlagPointerListIBM_names, EdgeFlagPointerListIBM_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_INGR_blend_func_separate)
+static const struct dri_extension_function GL_INGR_blend_func_separate_functions[] = {
+ { BlendFuncSeparateEXT_names, BlendFuncSeparateEXT_remap_index, 537 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_INTEL_parallel_arrays)
+static const struct dri_extension_function GL_INTEL_parallel_arrays_functions[] = {
+ { VertexPointervINTEL_names, VertexPointervINTEL_remap_index, -1 },
+ { ColorPointervINTEL_names, ColorPointervINTEL_remap_index, -1 },
+ { NormalPointervINTEL_names, NormalPointervINTEL_remap_index, -1 },
+ { TexCoordPointervINTEL_names, TexCoordPointervINTEL_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_MESA_resize_buffers)
+static const struct dri_extension_function GL_MESA_resize_buffers_functions[] = {
+ { ResizeBuffersMESA_names, ResizeBuffersMESA_remap_index, 512 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_MESA_window_pos)
+static const struct dri_extension_function GL_MESA_window_pos_functions[] = {
+ { WindowPos3fMESA_names, WindowPos3fMESA_remap_index, 523 },
+ { WindowPos2dvMESA_names, WindowPos2dvMESA_remap_index, 514 },
+ { WindowPos4svMESA_names, WindowPos4svMESA_remap_index, 536 },
+ { WindowPos2svMESA_names, WindowPos2svMESA_remap_index, 520 },
+ { WindowPos3dMESA_names, WindowPos3dMESA_remap_index, 521 },
+ { WindowPos2fvMESA_names, WindowPos2fvMESA_remap_index, 516 },
+ { WindowPos4dMESA_names, WindowPos4dMESA_remap_index, 529 },
+ { WindowPos2dMESA_names, WindowPos2dMESA_remap_index, 513 },
+ { WindowPos4ivMESA_names, WindowPos4ivMESA_remap_index, 534 },
+ { WindowPos4fMESA_names, WindowPos4fMESA_remap_index, 531 },
+ { WindowPos3dvMESA_names, WindowPos3dvMESA_remap_index, 522 },
+ { WindowPos3fvMESA_names, WindowPos3fvMESA_remap_index, 524 },
+ { WindowPos4dvMESA_names, WindowPos4dvMESA_remap_index, 530 },
+ { WindowPos2iMESA_names, WindowPos2iMESA_remap_index, 517 },
+ { WindowPos3sMESA_names, WindowPos3sMESA_remap_index, 527 },
+ { WindowPos4sMESA_names, WindowPos4sMESA_remap_index, 535 },
+ { WindowPos2ivMESA_names, WindowPos2ivMESA_remap_index, 518 },
+ { WindowPos2sMESA_names, WindowPos2sMESA_remap_index, 519 },
+ { WindowPos3iMESA_names, WindowPos3iMESA_remap_index, 525 },
+ { WindowPos3ivMESA_names, WindowPos3ivMESA_remap_index, 526 },
+ { WindowPos4iMESA_names, WindowPos4iMESA_remap_index, 533 },
+ { WindowPos4fvMESA_names, WindowPos4fvMESA_remap_index, 532 },
+ { WindowPos3svMESA_names, WindowPos3svMESA_remap_index, 528 },
+ { WindowPos2fMESA_names, WindowPos2fMESA_remap_index, 515 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_NV_evaluators)
+static const struct dri_extension_function GL_NV_evaluators_functions[] = {
+ { GetMapAttribParameterivNV_names, GetMapAttribParameterivNV_remap_index, -1 },
+ { MapControlPointsNV_names, MapControlPointsNV_remap_index, -1 },
+ { MapParameterfvNV_names, MapParameterfvNV_remap_index, -1 },
+ { EvalMapsNV_names, EvalMapsNV_remap_index, -1 },
+ { GetMapAttribParameterfvNV_names, GetMapAttribParameterfvNV_remap_index, -1 },
+ { MapParameterivNV_names, MapParameterivNV_remap_index, -1 },
+ { GetMapParameterivNV_names, GetMapParameterivNV_remap_index, -1 },
+ { GetMapParameterfvNV_names, GetMapParameterfvNV_remap_index, -1 },
+ { GetMapControlPointsNV_names, GetMapControlPointsNV_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_NV_fence)
+static const struct dri_extension_function GL_NV_fence_functions[] = {
+ { GenFencesNV_names, GenFencesNV_remap_index, 648 },
+ { TestFenceNV_names, TestFenceNV_remap_index, 650 },
+ { IsFenceNV_names, IsFenceNV_remap_index, 649 },
+ { DeleteFencesNV_names, DeleteFencesNV_remap_index, 647 },
+ { SetFenceNV_names, SetFenceNV_remap_index, 653 },
+ { GetFenceivNV_names, GetFenceivNV_remap_index, 651 },
+ { FinishFenceNV_names, FinishFenceNV_remap_index, 652 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_NV_fragment_program)
+static const struct dri_extension_function GL_NV_fragment_program_functions[] = {
+ { GetProgramNamedParameterdvNV_names, GetProgramNamedParameterdvNV_remap_index, 687 },
+ { GetProgramNamedParameterfvNV_names, GetProgramNamedParameterfvNV_remap_index, 686 },
+ { ProgramNamedParameter4fNV_names, ProgramNamedParameter4fNV_remap_index, 682 },
+ { ProgramNamedParameter4fvNV_names, ProgramNamedParameter4fvNV_remap_index, 684 },
+ { ProgramNamedParameter4dvNV_names, ProgramNamedParameter4dvNV_remap_index, 685 },
+ { ProgramNamedParameter4dNV_names, ProgramNamedParameter4dNV_remap_index, 683 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_NV_point_sprite)
+static const struct dri_extension_function GL_NV_point_sprite_functions[] = {
+ { PointParameteriNV_names, PointParameteriNV_remap_index, 642 },
+ { PointParameterivNV_names, PointParameterivNV_remap_index, 643 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_NV_register_combiners)
+static const struct dri_extension_function GL_NV_register_combiners_functions[] = {
+ { CombinerParameterfvNV_names, CombinerParameterfvNV_remap_index, 499 },
+ { GetCombinerOutputParameterfvNV_names, GetCombinerOutputParameterfvNV_remap_index, 508 },
+ { FinalCombinerInputNV_names, FinalCombinerInputNV_remap_index, 505 },
+ { GetCombinerInputParameterfvNV_names, GetCombinerInputParameterfvNV_remap_index, 506 },
+ { GetCombinerOutputParameterivNV_names, GetCombinerOutputParameterivNV_remap_index, 509 },
+ { CombinerOutputNV_names, CombinerOutputNV_remap_index, 504 },
+ { CombinerParameteriNV_names, CombinerParameteriNV_remap_index, 502 },
+ { GetFinalCombinerInputParameterivNV_names, GetFinalCombinerInputParameterivNV_remap_index, 511 },
+ { CombinerInputNV_names, CombinerInputNV_remap_index, 503 },
+ { CombinerParameterfNV_names, CombinerParameterfNV_remap_index, 500 },
+ { GetFinalCombinerInputParameterfvNV_names, GetFinalCombinerInputParameterfvNV_remap_index, 510 },
+ { GetCombinerInputParameterivNV_names, GetCombinerInputParameterivNV_remap_index, 507 },
+ { CombinerParameterivNV_names, CombinerParameterivNV_remap_index, 501 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_NV_register_combiners2)
+static const struct dri_extension_function GL_NV_register_combiners2_functions[] = {
+ { CombinerStageParameterfvNV_names, CombinerStageParameterfvNV_remap_index, -1 },
+ { GetCombinerStageParameterfvNV_names, GetCombinerStageParameterfvNV_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_NV_vertex_array_range)
+static const struct dri_extension_function GL_NV_vertex_array_range_functions[] = {
+ { FlushVertexArrayRangeNV_names, FlushVertexArrayRangeNV_remap_index, 497 },
+ { VertexArrayRangeNV_names, VertexArrayRangeNV_remap_index, 498 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_NV_vertex_program)
+static const struct dri_extension_function GL_NV_vertex_program_functions[] = {
+ { ProgramParameter4fNV_names, ProgramParameter4fNV_remap_index, 596 },
+ { VertexAttrib4ubvNV_names, VertexAttrib4ubvNV_remap_index, 781 },
+ { VertexAttrib4svNV_names, VertexAttrib4svNV_remap_index, 779 },
+ { VertexAttribs1dvNV_names, VertexAttribs1dvNV_remap_index, 629 },
+ { ProgramParameter4dvNV_names, ProgramParameter4dvNV_remap_index, 595 },
+ { VertexAttrib4fNV_names, VertexAttrib4fNV_remap_index, 776 },
+ { VertexAttrib2dNV_names, VertexAttrib2dNV_remap_index, 762 },
+ { VertexAttrib4ubNV_names, VertexAttrib4ubNV_remap_index, 780 },
+ { VertexAttribs3dvNV_names, VertexAttribs3dvNV_remap_index, 635 },
+ { VertexAttribs4fvNV_names, VertexAttribs4fvNV_remap_index, 639 },
+ { VertexAttrib2sNV_names, VertexAttrib2sNV_remap_index, 766 },
+ { VertexAttribs3fvNV_names, VertexAttribs3fvNV_remap_index, 636 },
+ { ProgramParameter4dNV_names, ProgramParameter4dNV_remap_index, 594 },
+ { LoadProgramNV_names, LoadProgramNV_remap_index, 593 },
+ { VertexAttrib4fvNV_names, VertexAttrib4fvNV_remap_index, 777 },
+ { VertexAttrib3fNV_names, VertexAttrib3fNV_remap_index, 770 },
+ { VertexAttribs2dvNV_names, VertexAttribs2dvNV_remap_index, 632 },
+ { GetProgramParameterfvNV_names, GetProgramParameterfvNV_remap_index, 584 },
+ { VertexAttrib3dNV_names, VertexAttrib3dNV_remap_index, 768 },
+ { VertexAttrib2fvNV_names, VertexAttrib2fvNV_remap_index, 765 },
+ { VertexAttrib2dvNV_names, VertexAttrib2dvNV_remap_index, 763 },
+ { VertexAttrib1dvNV_names, VertexAttrib1dvNV_remap_index, 757 },
+ { ProgramParameter4fvNV_names, ProgramParameter4fvNV_remap_index, 597 },
+ { VertexAttrib1svNV_names, VertexAttrib1svNV_remap_index, 761 },
+ { VertexAttribs2svNV_names, VertexAttribs2svNV_remap_index, 634 },
+ { GetVertexAttribivNV_names, GetVertexAttribivNV_remap_index, 755 },
+ { GetVertexAttribfvNV_names, GetVertexAttribfvNV_remap_index, 754 },
+ { VertexAttrib2svNV_names, VertexAttrib2svNV_remap_index, 767 },
+ { VertexAttribs1fvNV_names, VertexAttribs1fvNV_remap_index, 630 },
+ { IsProgramNV_names, IsProgramNV_remap_index, 592 },
+ { VertexAttrib4sNV_names, VertexAttrib4sNV_remap_index, 778 },
+ { VertexAttrib2fNV_names, VertexAttrib2fNV_remap_index, 764 },
+ { RequestResidentProgramsNV_names, RequestResidentProgramsNV_remap_index, 600 },
+ { ExecuteProgramNV_names, ExecuteProgramNV_remap_index, 581 },
+ { VertexAttribPointerNV_names, VertexAttribPointerNV_remap_index, 602 },
+ { TrackMatrixNV_names, TrackMatrixNV_remap_index, 601 },
+ { GetProgramParameterdvNV_names, GetProgramParameterdvNV_remap_index, 583 },
+ { VertexAttrib3sNV_names, VertexAttrib3sNV_remap_index, 772 },
+ { GetTrackMatrixivNV_names, GetTrackMatrixivNV_remap_index, 587 },
+ { VertexAttrib3svNV_names, VertexAttrib3svNV_remap_index, 773 },
+ { ProgramParameters4fvNV_names, ProgramParameters4fvNV_remap_index, 599 },
+ { GetProgramivNV_names, GetProgramivNV_remap_index, 585 },
+ { GetVertexAttribdvNV_names, GetVertexAttribdvNV_remap_index, 753 },
+ { VertexAttrib3fvNV_names, VertexAttrib3fvNV_remap_index, 771 },
+ { VertexAttribs2fvNV_names, VertexAttribs2fvNV_remap_index, 633 },
+ { VertexAttrib1fvNV_names, VertexAttrib1fvNV_remap_index, 759 },
+ { DeleteProgramsNV_names, DeleteProgramsNV_remap_index, 580 },
+ { GetVertexAttribPointervNV_names, GetVertexAttribPointervNV_remap_index, 591 },
+ { GetProgramStringNV_names, GetProgramStringNV_remap_index, 586 },
+ { VertexAttribs4dvNV_names, VertexAttribs4dvNV_remap_index, 638 },
+ { ProgramParameters4dvNV_names, ProgramParameters4dvNV_remap_index, 598 },
+ { VertexAttrib1fNV_names, VertexAttrib1fNV_remap_index, 758 },
+ { VertexAttrib4dNV_names, VertexAttrib4dNV_remap_index, 774 },
+ { VertexAttribs4ubvNV_names, VertexAttribs4ubvNV_remap_index, 641 },
+ { VertexAttribs3svNV_names, VertexAttribs3svNV_remap_index, 637 },
+ { VertexAttrib1sNV_names, VertexAttrib1sNV_remap_index, 760 },
+ { BindProgramNV_names, BindProgramNV_remap_index, 579 },
+ { AreProgramsResidentNV_names, AreProgramsResidentNV_remap_index, 578 },
+ { VertexAttrib3dvNV_names, VertexAttrib3dvNV_remap_index, 769 },
+ { VertexAttrib1dNV_names, VertexAttrib1dNV_remap_index, 756 },
+ { VertexAttribs4svNV_names, VertexAttribs4svNV_remap_index, 640 },
+ { VertexAttribs1svNV_names, VertexAttribs1svNV_remap_index, 631 },
+ { GenProgramsNV_names, GenProgramsNV_remap_index, 582 },
+ { VertexAttrib4dvNV_names, VertexAttrib4dvNV_remap_index, 775 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_PGI_misc_hints)
+static const struct dri_extension_function GL_PGI_misc_hints_functions[] = {
+ { HintPGI_names, HintPGI_remap_index, 544 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIS_detail_texture)
+static const struct dri_extension_function GL_SGIS_detail_texture_functions[] = {
+ { GetDetailTexFuncSGIS_names, GetDetailTexFuncSGIS_remap_index, 443 },
+ { DetailTexFuncSGIS_names, DetailTexFuncSGIS_remap_index, 442 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIS_fog_function)
+static const struct dri_extension_function GL_SGIS_fog_function_functions[] = {
+ { FogFuncSGIS_names, FogFuncSGIS_remap_index, -1 },
+ { GetFogFuncSGIS_names, GetFogFuncSGIS_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIS_multisample)
+static const struct dri_extension_function GL_SGIS_multisample_functions[] = {
+ { SampleMaskSGIS_names, SampleMaskSGIS_remap_index, 446 },
+ { SamplePatternSGIS_names, SamplePatternSGIS_remap_index, 447 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIS_pixel_texture)
+static const struct dri_extension_function GL_SGIS_pixel_texture_functions[] = {
+ { PixelTexGenParameterfvSGIS_names, PixelTexGenParameterfvSGIS_remap_index, 434 },
+ { GetPixelTexGenParameterivSGIS_names, GetPixelTexGenParameterivSGIS_remap_index, 435 },
+ { PixelTexGenParameteriSGIS_names, PixelTexGenParameteriSGIS_remap_index, 431 },
+ { PixelTexGenParameterivSGIS_names, PixelTexGenParameterivSGIS_remap_index, 432 },
+ { PixelTexGenParameterfSGIS_names, PixelTexGenParameterfSGIS_remap_index, 433 },
+ { GetPixelTexGenParameterfvSGIS_names, GetPixelTexGenParameterfvSGIS_remap_index, 436 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIS_point_parameters)
+static const struct dri_extension_function GL_SGIS_point_parameters_functions[] = {
+ { PointParameterfEXT_names, PointParameterfEXT_remap_index, 458 },
+ { PointParameterfvEXT_names, PointParameterfvEXT_remap_index, 459 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIS_sharpen_texture)
+static const struct dri_extension_function GL_SGIS_sharpen_texture_functions[] = {
+ { GetSharpenTexFuncSGIS_names, GetSharpenTexFuncSGIS_remap_index, 445 },
+ { SharpenTexFuncSGIS_names, SharpenTexFuncSGIS_remap_index, 444 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIS_texture4D)
+static const struct dri_extension_function GL_SGIS_texture4D_functions[] = {
+ { TexImage4DSGIS_names, TexImage4DSGIS_remap_index, 437 },
+ { TexSubImage4DSGIS_names, TexSubImage4DSGIS_remap_index, 438 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIS_texture_color_mask)
+static const struct dri_extension_function GL_SGIS_texture_color_mask_functions[] = {
+ { TextureColorMaskSGIS_names, TextureColorMaskSGIS_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIS_texture_filter4)
+static const struct dri_extension_function GL_SGIS_texture_filter4_functions[] = {
+ { GetTexFilterFuncSGIS_names, GetTexFilterFuncSGIS_remap_index, 415 },
+ { TexFilterFuncSGIS_names, TexFilterFuncSGIS_remap_index, 416 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIX_async)
+static const struct dri_extension_function GL_SGIX_async_functions[] = {
+ { AsyncMarkerSGIX_names, AsyncMarkerSGIX_remap_index, -1 },
+ { FinishAsyncSGIX_names, FinishAsyncSGIX_remap_index, -1 },
+ { PollAsyncSGIX_names, PollAsyncSGIX_remap_index, -1 },
+ { DeleteAsyncMarkersSGIX_names, DeleteAsyncMarkersSGIX_remap_index, -1 },
+ { IsAsyncMarkerSGIX_names, IsAsyncMarkerSGIX_remap_index, -1 },
+ { GenAsyncMarkersSGIX_names, GenAsyncMarkersSGIX_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIX_flush_raster)
+static const struct dri_extension_function GL_SGIX_flush_raster_functions[] = {
+ { FlushRasterSGIX_names, FlushRasterSGIX_remap_index, 469 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIX_fragment_lighting)
+static const struct dri_extension_function GL_SGIX_fragment_lighting_functions[] = {
+ { FragmentMaterialfvSGIX_names, FragmentMaterialfvSGIX_remap_index, 486 },
+ { FragmentLightModelivSGIX_names, FragmentLightModelivSGIX_remap_index, 484 },
+ { FragmentLightiSGIX_names, FragmentLightiSGIX_remap_index, 479 },
+ { GetFragmentMaterialfvSGIX_names, GetFragmentMaterialfvSGIX_remap_index, 491 },
+ { FragmentMaterialfSGIX_names, FragmentMaterialfSGIX_remap_index, 485 },
+ { GetFragmentLightivSGIX_names, GetFragmentLightivSGIX_remap_index, 490 },
+ { FragmentLightModeliSGIX_names, FragmentLightModeliSGIX_remap_index, 483 },
+ { FragmentLightivSGIX_names, FragmentLightivSGIX_remap_index, 480 },
+ { GetFragmentMaterialivSGIX_names, GetFragmentMaterialivSGIX_remap_index, 492 },
+ { FragmentLightModelfSGIX_names, FragmentLightModelfSGIX_remap_index, 481 },
+ { FragmentColorMaterialSGIX_names, FragmentColorMaterialSGIX_remap_index, 476 },
+ { FragmentMaterialiSGIX_names, FragmentMaterialiSGIX_remap_index, 487 },
+ { LightEnviSGIX_names, LightEnviSGIX_remap_index, 493 },
+ { FragmentLightModelfvSGIX_names, FragmentLightModelfvSGIX_remap_index, 482 },
+ { FragmentLightfvSGIX_names, FragmentLightfvSGIX_remap_index, 478 },
+ { FragmentLightfSGIX_names, FragmentLightfSGIX_remap_index, 477 },
+ { GetFragmentLightfvSGIX_names, GetFragmentLightfvSGIX_remap_index, 489 },
+ { FragmentMaterialivSGIX_names, FragmentMaterialivSGIX_remap_index, 488 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIX_framezoom)
+static const struct dri_extension_function GL_SGIX_framezoom_functions[] = {
+ { FrameZoomSGIX_names, FrameZoomSGIX_remap_index, 466 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIX_igloo_interface)
+static const struct dri_extension_function GL_SGIX_igloo_interface_functions[] = {
+ { IglooInterfaceSGIX_names, IglooInterfaceSGIX_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIX_instruments)
+static const struct dri_extension_function GL_SGIX_instruments_functions[] = {
+ { ReadInstrumentsSGIX_names, ReadInstrumentsSGIX_remap_index, 463 },
+ { GetInstrumentsSGIX_names, GetInstrumentsSGIX_remap_index, 460 },
+ { StartInstrumentsSGIX_names, StartInstrumentsSGIX_remap_index, 464 },
+ { StopInstrumentsSGIX_names, StopInstrumentsSGIX_remap_index, 465 },
+ { InstrumentsBufferSGIX_names, InstrumentsBufferSGIX_remap_index, 461 },
+ { PollInstrumentsSGIX_names, PollInstrumentsSGIX_remap_index, 462 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIX_list_priority)
+static const struct dri_extension_function GL_SGIX_list_priority_functions[] = {
+ { ListParameterfSGIX_names, ListParameterfSGIX_remap_index, 472 },
+ { GetListParameterivSGIX_names, GetListParameterivSGIX_remap_index, 471 },
+ { GetListParameterfvSGIX_names, GetListParameterfvSGIX_remap_index, 470 },
+ { ListParameteriSGIX_names, ListParameteriSGIX_remap_index, 474 },
+ { ListParameterfvSGIX_names, ListParameterfvSGIX_remap_index, 473 },
+ { ListParameterivSGIX_names, ListParameterivSGIX_remap_index, 475 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIX_pixel_texture)
+static const struct dri_extension_function GL_SGIX_pixel_texture_functions[] = {
+ { PixelTexGenSGIX_names, PixelTexGenSGIX_remap_index, 430 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIX_polynomial_ffd)
+static const struct dri_extension_function GL_SGIX_polynomial_ffd_functions[] = {
+ { LoadIdentityDeformationMapSGIX_names, LoadIdentityDeformationMapSGIX_remap_index, -1 },
+ { DeformationMap3dSGIX_names, DeformationMap3dSGIX_remap_index, -1 },
+ { DeformSGIX_names, DeformSGIX_remap_index, -1 },
+ { DeformationMap3fSGIX_names, DeformationMap3fSGIX_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIX_reference_plane)
+static const struct dri_extension_function GL_SGIX_reference_plane_functions[] = {
+ { ReferencePlaneSGIX_names, ReferencePlaneSGIX_remap_index, 468 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIX_sprite)
+static const struct dri_extension_function GL_SGIX_sprite_functions[] = {
+ { SpriteParameterfvSGIX_names, SpriteParameterfvSGIX_remap_index, 455 },
+ { SpriteParameteriSGIX_names, SpriteParameteriSGIX_remap_index, 456 },
+ { SpriteParameterfSGIX_names, SpriteParameterfSGIX_remap_index, 454 },
+ { SpriteParameterivSGIX_names, SpriteParameterivSGIX_remap_index, 457 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGIX_tag_sample_buffer)
+static const struct dri_extension_function GL_SGIX_tag_sample_buffer_functions[] = {
+ { TagSampleBufferSGIX_names, TagSampleBufferSGIX_remap_index, 467 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SGI_color_table)
+static const struct dri_extension_function GL_SGI_color_table_functions[] = {
+ { GetColorTableParameterfvSGI_names, GetColorTableParameterfvSGI_remap_index, 428 },
+ { ColorTableParameteriv_names, -1, 341 },
+ { ColorTable_names, -1, 339 },
+ { CopyColorTable_names, -1, 342 },
+ { ColorTableParameterfv_names, -1, 340 },
+ { GetColorTableParameterivSGI_names, GetColorTableParameterivSGI_remap_index, 429 },
+ { GetColorTableSGI_names, GetColorTableSGI_remap_index, 427 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SUNX_constant_data)
+static const struct dri_extension_function GL_SUNX_constant_data_functions[] = {
+ { FinishTextureSUNX_names, FinishTextureSUNX_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SUN_global_alpha)
+static const struct dri_extension_function GL_SUN_global_alpha_functions[] = {
+ { GlobalAlphaFactorubSUN_names, GlobalAlphaFactorubSUN_remap_index, -1 },
+ { GlobalAlphaFactoriSUN_names, GlobalAlphaFactoriSUN_remap_index, -1 },
+ { GlobalAlphaFactordSUN_names, GlobalAlphaFactordSUN_remap_index, -1 },
+ { GlobalAlphaFactoruiSUN_names, GlobalAlphaFactoruiSUN_remap_index, -1 },
+ { GlobalAlphaFactorbSUN_names, GlobalAlphaFactorbSUN_remap_index, -1 },
+ { GlobalAlphaFactorfSUN_names, GlobalAlphaFactorfSUN_remap_index, -1 },
+ { GlobalAlphaFactorusSUN_names, GlobalAlphaFactorusSUN_remap_index, -1 },
+ { GlobalAlphaFactorsSUN_names, GlobalAlphaFactorsSUN_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SUN_mesh_array)
+static const struct dri_extension_function GL_SUN_mesh_array_functions[] = {
+ { DrawMeshArraysSUN_names, DrawMeshArraysSUN_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SUN_triangle_list)
+static const struct dri_extension_function GL_SUN_triangle_list_functions[] = {
+ { ReplacementCodeubSUN_names, ReplacementCodeubSUN_remap_index, -1 },
+ { ReplacementCodeubvSUN_names, ReplacementCodeubvSUN_remap_index, -1 },
+ { ReplacementCodeuivSUN_names, ReplacementCodeuivSUN_remap_index, -1 },
+ { ReplacementCodeusvSUN_names, ReplacementCodeusvSUN_remap_index, -1 },
+ { ReplacementCodePointerSUN_names, ReplacementCodePointerSUN_remap_index, -1 },
+ { ReplacementCodeusSUN_names, ReplacementCodeusSUN_remap_index, -1 },
+ { ReplacementCodeuiSUN_names, ReplacementCodeuiSUN_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_SUN_vertex)
+static const struct dri_extension_function GL_SUN_vertex_functions[] = {
+ { ReplacementCodeuiColor3fVertex3fvSUN_names, ReplacementCodeuiColor3fVertex3fvSUN_remap_index, -1 },
+ { TexCoord4fColor4fNormal3fVertex4fvSUN_names, TexCoord4fColor4fNormal3fVertex4fvSUN_remap_index, -1 },
+ { TexCoord2fColor4ubVertex3fvSUN_names, TexCoord2fColor4ubVertex3fvSUN_remap_index, -1 },
+ { ReplacementCodeuiVertex3fvSUN_names, ReplacementCodeuiVertex3fvSUN_remap_index, -1 },
+ { ReplacementCodeuiTexCoord2fVertex3fvSUN_names, ReplacementCodeuiTexCoord2fVertex3fvSUN_remap_index, -1 },
+ { ReplacementCodeuiNormal3fVertex3fSUN_names, ReplacementCodeuiNormal3fVertex3fSUN_remap_index, -1 },
+ { Color4ubVertex3fvSUN_names, Color4ubVertex3fvSUN_remap_index, -1 },
+ { Color4ubVertex3fSUN_names, Color4ubVertex3fSUN_remap_index, -1 },
+ { TexCoord2fVertex3fSUN_names, TexCoord2fVertex3fSUN_remap_index, -1 },
+ { TexCoord2fColor4fNormal3fVertex3fSUN_names, TexCoord2fColor4fNormal3fVertex3fSUN_remap_index, -1 },
+ { TexCoord2fNormal3fVertex3fvSUN_names, TexCoord2fNormal3fVertex3fvSUN_remap_index, -1 },
+ { ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN_names, ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN_remap_index, -1 },
+ { ReplacementCodeuiTexCoord2fVertex3fSUN_names, ReplacementCodeuiTexCoord2fVertex3fSUN_remap_index, -1 },
+ { Color3fVertex3fSUN_names, Color3fVertex3fSUN_remap_index, -1 },
+ { ReplacementCodeuiNormal3fVertex3fvSUN_names, ReplacementCodeuiNormal3fVertex3fvSUN_remap_index, -1 },
+ { Color3fVertex3fvSUN_names, Color3fVertex3fvSUN_remap_index, -1 },
+ { Color4fNormal3fVertex3fvSUN_names, Color4fNormal3fVertex3fvSUN_remap_index, -1 },
+ { ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN_names, ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN_remap_index, -1 },
+ { ReplacementCodeuiColor4fNormal3fVertex3fvSUN_names, ReplacementCodeuiColor4fNormal3fVertex3fvSUN_remap_index, -1 },
+ { ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN_names, ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN_remap_index, -1 },
+ { TexCoord2fColor3fVertex3fSUN_names, TexCoord2fColor3fVertex3fSUN_remap_index, -1 },
+ { TexCoord4fColor4fNormal3fVertex4fSUN_names, TexCoord4fColor4fNormal3fVertex4fSUN_remap_index, -1 },
+ { Color4ubVertex2fvSUN_names, Color4ubVertex2fvSUN_remap_index, -1 },
+ { Normal3fVertex3fSUN_names, Normal3fVertex3fSUN_remap_index, -1 },
+ { ReplacementCodeuiColor4fNormal3fVertex3fSUN_names, ReplacementCodeuiColor4fNormal3fVertex3fSUN_remap_index, -1 },
+ { TexCoord2fNormal3fVertex3fSUN_names, TexCoord2fNormal3fVertex3fSUN_remap_index, -1 },
+ { TexCoord2fVertex3fvSUN_names, TexCoord2fVertex3fvSUN_remap_index, -1 },
+ { Color4ubVertex2fSUN_names, Color4ubVertex2fSUN_remap_index, -1 },
+ { ReplacementCodeuiColor4ubVertex3fSUN_names, ReplacementCodeuiColor4ubVertex3fSUN_remap_index, -1 },
+ { TexCoord2fColor4ubVertex3fSUN_names, TexCoord2fColor4ubVertex3fSUN_remap_index, -1 },
+ { Normal3fVertex3fvSUN_names, Normal3fVertex3fvSUN_remap_index, -1 },
+ { Color4fNormal3fVertex3fSUN_names, Color4fNormal3fVertex3fSUN_remap_index, -1 },
+ { TexCoord2fColor4fNormal3fVertex3fvSUN_names, TexCoord2fColor4fNormal3fVertex3fvSUN_remap_index, -1 },
+ { ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN_names, ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN_remap_index, -1 },
+ { ReplacementCodeuiColor4ubVertex3fvSUN_names, ReplacementCodeuiColor4ubVertex3fvSUN_remap_index, -1 },
+ { ReplacementCodeuiColor3fVertex3fSUN_names, ReplacementCodeuiColor3fVertex3fSUN_remap_index, -1 },
+ { TexCoord4fVertex4fSUN_names, TexCoord4fVertex4fSUN_remap_index, -1 },
+ { TexCoord2fColor3fVertex3fvSUN_names, TexCoord2fColor3fVertex3fvSUN_remap_index, -1 },
+ { TexCoord4fVertex4fvSUN_names, TexCoord4fVertex4fvSUN_remap_index, -1 },
+ { ReplacementCodeuiVertex3fSUN_names, ReplacementCodeuiVertex3fSUN_remap_index, -1 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_VERSION_1_3)
+static const struct dri_extension_function GL_VERSION_1_3_functions[] = {
+ { SampleCoverageARB_names, SampleCoverageARB_remap_index, 412 },
+ { MultiTexCoord3sARB_names, -1, 398 },
+ { ActiveTextureARB_names, -1, 374 },
+ { CompressedTexSubImage2DARB_names, CompressedTexSubImage2DARB_remap_index, 558 },
+ { CompressedTexImage3DARB_names, CompressedTexImage3DARB_remap_index, 554 },
+ { MultiTexCoord1fvARB_names, -1, 379 },
+ { MultTransposeMatrixdARB_names, MultTransposeMatrixdARB_remap_index, 411 },
+ { CompressedTexImage1DARB_names, CompressedTexImage1DARB_remap_index, 556 },
+ { MultiTexCoord3dARB_names, -1, 392 },
+ { MultiTexCoord2iARB_names, -1, 388 },
+ { MultiTexCoord2svARB_names, -1, 391 },
+ { MultiTexCoord2fARB_names, -1, 386 },
+ { LoadTransposeMatrixdARB_names, LoadTransposeMatrixdARB_remap_index, 409 },
+ { MultiTexCoord3fvARB_names, -1, 395 },
+ { MultiTexCoord4sARB_names, -1, 406 },
+ { MultiTexCoord2dvARB_names, -1, 385 },
+ { MultiTexCoord1svARB_names, -1, 383 },
+ { MultiTexCoord3svARB_names, -1, 399 },
+ { MultiTexCoord4iARB_names, -1, 404 },
+ { MultiTexCoord3iARB_names, -1, 396 },
+ { MultiTexCoord1dARB_names, -1, 376 },
+ { MultiTexCoord3dvARB_names, -1, 393 },
+ { MultiTexCoord3ivARB_names, -1, 397 },
+ { MultiTexCoord2sARB_names, -1, 390 },
+ { MultiTexCoord4ivARB_names, -1, 405 },
+ { CompressedTexSubImage1DARB_names, CompressedTexSubImage1DARB_remap_index, 559 },
+ { ClientActiveTextureARB_names, -1, 375 },
+ { CompressedTexSubImage3DARB_names, CompressedTexSubImage3DARB_remap_index, 557 },
+ { MultiTexCoord2dARB_names, -1, 384 },
+ { MultiTexCoord4dvARB_names, -1, 401 },
+ { MultiTexCoord4fvARB_names, -1, 403 },
+ { MultiTexCoord3fARB_names, -1, 394 },
+ { MultTransposeMatrixfARB_names, MultTransposeMatrixfARB_remap_index, 410 },
+ { CompressedTexImage2DARB_names, CompressedTexImage2DARB_remap_index, 555 },
+ { MultiTexCoord4dARB_names, -1, 400 },
+ { MultiTexCoord1sARB_names, -1, 382 },
+ { MultiTexCoord1dvARB_names, -1, 377 },
+ { MultiTexCoord1ivARB_names, -1, 381 },
+ { MultiTexCoord2ivARB_names, -1, 389 },
+ { MultiTexCoord1iARB_names, -1, 380 },
+ { GetCompressedTexImageARB_names, GetCompressedTexImageARB_remap_index, 560 },
+ { MultiTexCoord4svARB_names, -1, 407 },
+ { MultiTexCoord1fARB_names, -1, 378 },
+ { MultiTexCoord4fARB_names, -1, 402 },
+ { LoadTransposeMatrixfARB_names, LoadTransposeMatrixfARB_remap_index, 408 },
+ { MultiTexCoord2fvARB_names, -1, 387 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_VERSION_1_4)
+static const struct dri_extension_function GL_VERSION_1_4_functions[] = {
+ { PointParameteriNV_names, PointParameteriNV_remap_index, 642 },
+ { SecondaryColor3iEXT_names, SecondaryColor3iEXT_remap_index, 567 },
+ { WindowPos3fMESA_names, WindowPos3fMESA_remap_index, 523 },
+ { WindowPos2dvMESA_names, WindowPos2dvMESA_remap_index, 514 },
+ { SecondaryColor3bEXT_names, SecondaryColor3bEXT_remap_index, 561 },
+ { PointParameterfEXT_names, PointParameterfEXT_remap_index, 458 },
+ { FogCoorddEXT_names, FogCoorddEXT_remap_index, 547 },
+ { FogCoordfEXT_names, FogCoordfEXT_remap_index, 545 },
+ { WindowPos2svMESA_names, WindowPos2svMESA_remap_index, 520 },
+ { WindowPos3dMESA_names, WindowPos3dMESA_remap_index, 521 },
+ { PointParameterfvEXT_names, PointParameterfvEXT_remap_index, 459 },
+ { WindowPos2fvMESA_names, WindowPos2fvMESA_remap_index, 516 },
+ { SecondaryColor3bvEXT_names, SecondaryColor3bvEXT_remap_index, 562 },
+ { SecondaryColor3sEXT_names, SecondaryColor3sEXT_remap_index, 569 },
+ { SecondaryColor3dEXT_names, SecondaryColor3dEXT_remap_index, 563 },
+ { WindowPos2dMESA_names, WindowPos2dMESA_remap_index, 513 },
+ { SecondaryColorPointerEXT_names, SecondaryColorPointerEXT_remap_index, 577 },
+ { SecondaryColor3uiEXT_names, SecondaryColor3uiEXT_remap_index, 573 },
+ { SecondaryColor3usvEXT_names, SecondaryColor3usvEXT_remap_index, 576 },
+ { WindowPos3dvMESA_names, WindowPos3dvMESA_remap_index, 522 },
+ { PointParameterivNV_names, PointParameterivNV_remap_index, 643 },
+ { WindowPos3fvMESA_names, WindowPos3fvMESA_remap_index, 524 },
+ { SecondaryColor3ivEXT_names, SecondaryColor3ivEXT_remap_index, 568 },
+ { WindowPos2iMESA_names, WindowPos2iMESA_remap_index, 517 },
+ { SecondaryColor3fvEXT_names, SecondaryColor3fvEXT_remap_index, 566 },
+ { WindowPos3sMESA_names, WindowPos3sMESA_remap_index, 527 },
+ { WindowPos2ivMESA_names, WindowPos2ivMESA_remap_index, 518 },
+ { MultiDrawElementsEXT_names, MultiDrawElementsEXT_remap_index, 645 },
+ { WindowPos2sMESA_names, WindowPos2sMESA_remap_index, 519 },
+ { FogCoordPointerEXT_names, FogCoordPointerEXT_remap_index, 549 },
+ { SecondaryColor3ubvEXT_names, SecondaryColor3ubvEXT_remap_index, 572 },
+ { SecondaryColor3uivEXT_names, SecondaryColor3uivEXT_remap_index, 574 },
+ { WindowPos3iMESA_names, WindowPos3iMESA_remap_index, 525 },
+ { SecondaryColor3dvEXT_names, SecondaryColor3dvEXT_remap_index, 564 },
+ { MultiDrawArraysEXT_names, MultiDrawArraysEXT_remap_index, 644 },
+ { SecondaryColor3usEXT_names, SecondaryColor3usEXT_remap_index, 575 },
+ { FogCoordfvEXT_names, FogCoordfvEXT_remap_index, 546 },
+ { SecondaryColor3ubEXT_names, SecondaryColor3ubEXT_remap_index, 571 },
+ { BlendFuncSeparateEXT_names, BlendFuncSeparateEXT_remap_index, 537 },
+ { SecondaryColor3fEXT_names, SecondaryColor3fEXT_remap_index, 565 },
+ { WindowPos3ivMESA_names, WindowPos3ivMESA_remap_index, 526 },
+ { SecondaryColor3svEXT_names, SecondaryColor3svEXT_remap_index, 570 },
+ { FogCoorddvEXT_names, FogCoorddvEXT_remap_index, 548 },
+ { WindowPos3svMESA_names, WindowPos3svMESA_remap_index, 528 },
+ { WindowPos2fMESA_names, WindowPos2fMESA_remap_index, 515 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_VERSION_1_5)
+static const struct dri_extension_function GL_VERSION_1_5_functions[] = {
+ { BeginQueryARB_names, BeginQueryARB_remap_index, 703 },
+ { GetBufferSubDataARB_names, GetBufferSubDataARB_remap_index, 695 },
+ { BufferSubDataARB_names, BufferSubDataARB_remap_index, 690 },
+ { GetQueryivARB_names, GetQueryivARB_remap_index, 705 },
+ { GetQueryObjectivARB_names, GetQueryObjectivARB_remap_index, 706 },
+ { BufferDataARB_names, BufferDataARB_remap_index, 689 },
+ { EndQueryARB_names, EndQueryARB_remap_index, 704 },
+ { GetBufferPointervARB_names, GetBufferPointervARB_remap_index, 694 },
+ { GetQueryObjectuivARB_names, GetQueryObjectuivARB_remap_index, 707 },
+ { GetBufferParameterivARB_names, GetBufferParameterivARB_remap_index, 693 },
+ { DeleteQueriesARB_names, DeleteQueriesARB_remap_index, 701 },
+ { IsQueryARB_names, IsQueryARB_remap_index, 702 },
+ { MapBufferARB_names, MapBufferARB_remap_index, 697 },
+ { GenQueriesARB_names, GenQueriesARB_remap_index, 700 },
+ { IsBufferARB_names, IsBufferARB_remap_index, 696 },
+ { DeleteBuffersARB_names, DeleteBuffersARB_remap_index, 691 },
+ { UnmapBufferARB_names, UnmapBufferARB_remap_index, 698 },
+ { BindBufferARB_names, BindBufferARB_remap_index, 688 },
+ { GenBuffersARB_names, GenBuffersARB_remap_index, 692 },
+ { NULL, 0, 0 }
+};
+#endif
+
+#if defined(need_GL_VERSION_2_0)
+static const struct dri_extension_function GL_VERSION_2_0_functions[] = {
+ { StencilMaskSeparate_names, StencilMaskSeparate_remap_index, 815 },
+ { StencilOpSeparate_names, StencilOpSeparate_remap_index, 814 },
+ { StencilFuncSeparate_names, StencilFuncSeparate_remap_index, 813 },
+ { NULL, 0, 0 }
+};
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.c
new file mode 100644
index 000000000..5e9e352f2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.c
@@ -0,0 +1,496 @@
+/*
+ * (C) Copyright IBM Corporation 2003
+ * 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
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file glcontextmodes.c
+ * Utility routines for working with \c __GLcontextModes structures. At
+ * some point most or all of these functions will be moved to the Mesa
+ * code base.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#if defined(IN_MINI_GLX)
+# include <stdlib.h>
+# include <string.h>
+# include <GL/gl.h>
+# include "GL/internal/dri_interface.h"
+# include "imports.h"
+# define __glXMemset memset
+#else
+# include <X11/X.h>
+# include <GL/glx.h>
+# include "GL/glxint.h"
+
+# ifdef XFree86Server
+# include "GL/glx_ansic.h"
+extern void * __glXMalloc( size_t size );
+extern void __glXFree( void * ptr );
+# define _mesa_malloc(b) __glXMalloc(b)
+# define _mesa_free(m) __glXFree(m)
+# else
+# include <X11/Xlibint.h>
+# define __glXMemset memset
+# define _mesa_malloc(b) Xmalloc(b)
+# define _mesa_free(m) Xfree(m)
+# endif /* XFree86Server */
+#endif /* !defined(IN_MINI_GLX) */
+
+#include "glcontextmodes.h"
+
+#if !defined(IN_MINI_GLX)
+#define NUM_VISUAL_TYPES 6
+
+/**
+ * Convert an X visual type to a GLX visual type.
+ *
+ * \param visualType X visual type (i.e., \c TrueColor, \c StaticGray, etc.)
+ * to be converted.
+ * \return If \c visualType is a valid X visual type, a GLX visual type will
+ * be returned. Otherwise \c GLX_NONE will be returned.
+ */
+GLint
+_gl_convert_from_x_visual_type( int visualType )
+{
+ static const int glx_visual_types[ NUM_VISUAL_TYPES ] = {
+ GLX_STATIC_GRAY, GLX_GRAY_SCALE,
+ GLX_STATIC_COLOR, GLX_PSEUDO_COLOR,
+ GLX_TRUE_COLOR, GLX_DIRECT_COLOR
+ };
+
+ return ( (unsigned) visualType < NUM_VISUAL_TYPES )
+ ? glx_visual_types[ visualType ] : GLX_NONE;
+}
+
+
+/**
+ * Convert a GLX visual type to an X visual type.
+ *
+ * \param visualType GLX visual type (i.e., \c GLX_TRUE_COLOR,
+ * \c GLX_STATIC_GRAY, etc.) to be converted.
+ * \return If \c visualType is a valid GLX visual type, an X visual type will
+ * be returned. Otherwise -1 will be returned.
+ */
+GLint
+_gl_convert_to_x_visual_type( int visualType )
+{
+ static const int x_visual_types[ NUM_VISUAL_TYPES ] = {
+ TrueColor, DirectColor,
+ PseudoColor, StaticColor,
+ GrayScale, StaticGray
+ };
+
+ return ( (unsigned) (visualType - GLX_TRUE_COLOR) <= NUM_VISUAL_TYPES )
+ ? x_visual_types[ visualType - GLX_TRUE_COLOR ] : -1;
+}
+
+
+/**
+ * Copy a GLX visual config structure to a GL context mode structure. All
+ * of the fields in \c config are copied to \c mode. Additional fields in
+ * \c mode that can be derrived from the fields of \c config (i.e.,
+ * \c haveDepthBuffer) are also filled in. The remaining fields in \c mode
+ * that cannot be derrived are set to default values.
+ *
+ * \param mode Destination GL context mode.
+ * \param config Source GLX visual config.
+ *
+ * \note
+ * The \c fbconfigID and \c visualID fields of the \c __GLcontextModes
+ * structure will be set to the \c vid of the \c __GLXvisualConfig structure.
+ */
+void
+_gl_copy_visual_to_context_mode( __GLcontextModes * mode,
+ const __GLXvisualConfig * config )
+{
+ __GLcontextModes * const next = mode->next;
+
+ (void) __glXMemset( mode, 0, sizeof( __GLcontextModes ) );
+ mode->next = next;
+
+ mode->visualID = config->vid;
+ mode->visualType = _gl_convert_from_x_visual_type( config->class );
+ mode->xRenderable = GL_TRUE;
+ mode->fbconfigID = config->vid;
+ mode->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
+
+ mode->rgbMode = (config->rgba != 0);
+ mode->renderType = (mode->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
+
+ mode->colorIndexMode = !(mode->rgbMode);
+ mode->doubleBufferMode = (config->doubleBuffer != 0);
+ mode->stereoMode = (config->stereo != 0);
+
+ mode->haveAccumBuffer = ((config->accumRedSize +
+ config->accumGreenSize +
+ config->accumBlueSize +
+ config->accumAlphaSize) > 0);
+ mode->haveDepthBuffer = (config->depthSize > 0);
+ mode->haveStencilBuffer = (config->stencilSize > 0);
+
+ mode->redBits = config->redSize;
+ mode->greenBits = config->greenSize;
+ mode->blueBits = config->blueSize;
+ mode->alphaBits = config->alphaSize;
+ mode->redMask = config->redMask;
+ mode->greenMask = config->greenMask;
+ mode->blueMask = config->blueMask;
+ mode->alphaMask = config->alphaMask;
+ mode->rgbBits = mode->rgbMode ? config->bufferSize : 0;
+ mode->indexBits = mode->colorIndexMode ? config->bufferSize : 0;
+
+ mode->accumRedBits = config->accumRedSize;
+ mode->accumGreenBits = config->accumGreenSize;
+ mode->accumBlueBits = config->accumBlueSize;
+ mode->accumAlphaBits = config->accumAlphaSize;
+ mode->depthBits = config->depthSize;
+ mode->stencilBits = config->stencilSize;
+
+ mode->numAuxBuffers = config->auxBuffers;
+ mode->level = config->level;
+
+ mode->visualRating = config->visualRating;
+ mode->transparentPixel = config->transparentPixel;
+ mode->transparentRed = config->transparentRed;
+ mode->transparentGreen = config->transparentGreen;
+ mode->transparentBlue = config->transparentBlue;
+ mode->transparentAlpha = config->transparentAlpha;
+ mode->transparentIndex = config->transparentIndex;
+
+ mode->swapMethod = GLX_SWAP_UNDEFINED_OML;
+}
+
+
+/**
+ * Get data from a GL context mode.
+ *
+ * \param mode GL context mode whose data is to be returned.
+ * \param attribute Attribute of \c mode that is to be returned.
+ * \param value_return Location to store the data member of \c mode.
+ * \return If \c attribute is a valid attribute of \c mode, zero is
+ * returned. Otherwise \c GLX_BAD_ATTRIBUTE is returned.
+ */
+int
+_gl_get_context_mode_data(const __GLcontextModes *mode, int attribute,
+ int *value_return)
+{
+ switch (attribute) {
+ case GLX_USE_GL:
+ *value_return = GL_TRUE;
+ return 0;
+ case GLX_BUFFER_SIZE:
+ *value_return = mode->rgbBits;
+ return 0;
+ case GLX_RGBA:
+ *value_return = mode->rgbMode;
+ return 0;
+ case GLX_RED_SIZE:
+ *value_return = mode->redBits;
+ return 0;
+ case GLX_GREEN_SIZE:
+ *value_return = mode->greenBits;
+ return 0;
+ case GLX_BLUE_SIZE:
+ *value_return = mode->blueBits;
+ return 0;
+ case GLX_ALPHA_SIZE:
+ *value_return = mode->alphaBits;
+ return 0;
+ case GLX_DOUBLEBUFFER:
+ *value_return = mode->doubleBufferMode;
+ return 0;
+ case GLX_STEREO:
+ *value_return = mode->stereoMode;
+ return 0;
+ case GLX_AUX_BUFFERS:
+ *value_return = mode->numAuxBuffers;
+ return 0;
+ case GLX_DEPTH_SIZE:
+ *value_return = mode->depthBits;
+ return 0;
+ case GLX_STENCIL_SIZE:
+ *value_return = mode->stencilBits;
+ return 0;
+ case GLX_ACCUM_RED_SIZE:
+ *value_return = mode->accumRedBits;
+ return 0;
+ case GLX_ACCUM_GREEN_SIZE:
+ *value_return = mode->accumGreenBits;
+ return 0;
+ case GLX_ACCUM_BLUE_SIZE:
+ *value_return = mode->accumBlueBits;
+ return 0;
+ case GLX_ACCUM_ALPHA_SIZE:
+ *value_return = mode->accumAlphaBits;
+ return 0;
+ case GLX_LEVEL:
+ *value_return = mode->level;
+ return 0;
+ case GLX_TRANSPARENT_TYPE_EXT:
+ *value_return = mode->transparentPixel;
+ return 0;
+ case GLX_TRANSPARENT_RED_VALUE:
+ *value_return = mode->transparentRed;
+ return 0;
+ case GLX_TRANSPARENT_GREEN_VALUE:
+ *value_return = mode->transparentGreen;
+ return 0;
+ case GLX_TRANSPARENT_BLUE_VALUE:
+ *value_return = mode->transparentBlue;
+ return 0;
+ case GLX_TRANSPARENT_ALPHA_VALUE:
+ *value_return = mode->transparentAlpha;
+ return 0;
+ case GLX_TRANSPARENT_INDEX_VALUE:
+ *value_return = mode->transparentIndex;
+ return 0;
+ case GLX_X_VISUAL_TYPE:
+ *value_return = mode->visualType;
+ return 0;
+ case GLX_CONFIG_CAVEAT:
+ *value_return = mode->visualRating;
+ return 0;
+ case GLX_VISUAL_ID:
+ *value_return = mode->visualID;
+ return 0;
+ case GLX_DRAWABLE_TYPE:
+ *value_return = mode->drawableType;
+ return 0;
+ case GLX_RENDER_TYPE:
+ *value_return = mode->renderType;
+ return 0;
+ case GLX_X_RENDERABLE:
+ *value_return = mode->xRenderable;
+ return 0;
+ case GLX_FBCONFIG_ID:
+ *value_return = mode->fbconfigID;
+ return 0;
+ case GLX_MAX_PBUFFER_WIDTH:
+ *value_return = mode->maxPbufferWidth;
+ return 0;
+ case GLX_MAX_PBUFFER_HEIGHT:
+ *value_return = mode->maxPbufferHeight;
+ return 0;
+ case GLX_MAX_PBUFFER_PIXELS:
+ *value_return = mode->maxPbufferPixels;
+ return 0;
+ case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
+ *value_return = mode->optimalPbufferWidth;
+ return 0;
+ case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX:
+ *value_return = mode->optimalPbufferHeight;
+ return 0;
+ case GLX_SWAP_METHOD_OML:
+ *value_return = mode->swapMethod;
+ return 0;
+ case GLX_SAMPLE_BUFFERS_SGIS:
+ *value_return = mode->sampleBuffers;
+ return 0;
+ case GLX_SAMPLES_SGIS:
+ *value_return = mode->samples;
+ return 0;
+
+ /* Applications are NOT allowed to query GLX_VISUAL_SELECT_GROUP_SGIX.
+ * It is ONLY for communication between the GLX client and the GLX
+ * server.
+ */
+ case GLX_VISUAL_SELECT_GROUP_SGIX:
+ default:
+ return GLX_BAD_ATTRIBUTE;
+ }
+}
+#endif /* !defined(IN_MINI_GLX) */
+
+
+/**
+ * Allocate a linked list of \c __GLcontextModes structures. The fields of
+ * each structure will be initialized to "reasonable" default values. In
+ * most cases this is the default value defined by table 3.4 of the GLX
+ * 1.3 specification. This means that most values are either initialized to
+ * zero or \c GLX_DONT_CARE (which is -1). As support for additional
+ * extensions is added, the new values will be initialized to appropriate
+ * values from the extension specification.
+ *
+ * \param count Number of structures to allocate.
+ * \param minimum_size Minimum size of a structure to allocate. This allows
+ * for differences in the version of the
+ * \c __GLcontextModes stucture used in libGL and in a
+ * DRI-based driver.
+ * \returns A pointer to the first element in a linked list of \c count
+ * stuctures on success, or \c NULL on failure.
+ *
+ * \warning Use of \c minimum_size does \b not guarantee binary compatibility.
+ * The fundamental assumption is that if the \c minimum_size
+ * specified by the driver and the size of the \c __GLcontextModes
+ * structure in libGL is the same, then the meaning of each byte in
+ * the structure is the same in both places. \b Be \b careful!
+ * Basically this means that fields have to be added in libGL and
+ * then propagated to drivers. Drivers should \b never arbitrarilly
+ * extend the \c __GLcontextModes data-structure.
+ */
+__GLcontextModes *
+_gl_context_modes_create( unsigned count, size_t minimum_size )
+{
+ const size_t size = (minimum_size > sizeof( __GLcontextModes ))
+ ? minimum_size : sizeof( __GLcontextModes );
+ __GLcontextModes * base = NULL;
+ __GLcontextModes ** next;
+ unsigned i;
+
+ next = & base;
+ for ( i = 0 ; i < count ; i++ ) {
+ *next = (__GLcontextModes *) _mesa_malloc( size );
+ if ( *next == NULL ) {
+ _gl_context_modes_destroy( base );
+ base = NULL;
+ break;
+ }
+
+ (void) __glXMemset( *next, 0, size );
+ (*next)->visualID = GLX_DONT_CARE;
+ (*next)->visualType = GLX_DONT_CARE;
+ (*next)->visualRating = GLX_NONE;
+ (*next)->transparentPixel = GLX_NONE;
+ (*next)->transparentRed = GLX_DONT_CARE;
+ (*next)->transparentGreen = GLX_DONT_CARE;
+ (*next)->transparentBlue = GLX_DONT_CARE;
+ (*next)->transparentAlpha = GLX_DONT_CARE;
+ (*next)->transparentIndex = GLX_DONT_CARE;
+ (*next)->xRenderable = GLX_DONT_CARE;
+ (*next)->fbconfigID = GLX_DONT_CARE;
+ (*next)->swapMethod = GLX_SWAP_UNDEFINED_OML;
+
+ next = & ((*next)->next);
+ }
+
+ return base;
+}
+
+
+/**
+ * Destroy a linked list of \c __GLcontextModes structures created by
+ * \c _gl_context_modes_create.
+ *
+ * \param modes Linked list of structures to be destroyed. All structres
+ * in the list will be freed.
+ */
+void
+_gl_context_modes_destroy( __GLcontextModes * modes )
+{
+ while ( modes != NULL ) {
+ __GLcontextModes * const next = modes->next;
+
+ _mesa_free( modes );
+ modes = next;
+ }
+}
+
+
+/**
+ * Find a context mode matching a Visual ID.
+ *
+ * \param modes List list of context-mode structures to be searched.
+ * \param vid Visual ID to be found.
+ * \returns A pointer to a context-mode in \c modes if \c vid was found in
+ * the list, or \c NULL if it was not.
+ */
+
+__GLcontextModes *
+_gl_context_modes_find_visual( __GLcontextModes * modes, int vid )
+{
+ while ( modes != NULL ) {
+ if ( modes->visualID == vid ) {
+ break;
+ }
+
+ modes = modes->next;
+ }
+
+ return modes;
+}
+
+
+/**
+ * Determine if two context-modes are the same. This is intended to be used
+ * by libGL implementations to compare to sets of driver generated FBconfigs.
+ *
+ * \param a Context-mode to be compared.
+ * \param b Context-mode to be compared.
+ * \returns \c GL_TRUE if the two context-modes are the same. \c GL_FALSE is
+ * returned otherwise.
+ */
+GLboolean
+_gl_context_modes_are_same( const __GLcontextModes * a,
+ const __GLcontextModes * b )
+{
+ return( (a->rgbMode == b->rgbMode) &&
+ (a->floatMode == b->floatMode) &&
+ (a->colorIndexMode == b->colorIndexMode) &&
+ (a->doubleBufferMode == b->doubleBufferMode) &&
+ (a->stereoMode == b->stereoMode) &&
+ (a->redBits == b->redBits) &&
+ (a->greenBits == b->greenBits) &&
+ (a->blueBits == b->blueBits) &&
+ (a->alphaBits == b->alphaBits) &&
+#if 0 /* For some reason these don't get set on the client-side in libGL. */
+ (a->redMask == b->redMask) &&
+ (a->greenMask == b->greenMask) &&
+ (a->blueMask == b->blueMask) &&
+ (a->alphaMask == b->alphaMask) &&
+#endif
+ (a->rgbBits == b->rgbBits) &&
+ (a->indexBits == b->indexBits) &&
+ (a->accumRedBits == b->accumRedBits) &&
+ (a->accumGreenBits == b->accumGreenBits) &&
+ (a->accumBlueBits == b->accumBlueBits) &&
+ (a->accumAlphaBits == b->accumAlphaBits) &&
+ (a->depthBits == b->depthBits) &&
+ (a->stencilBits == b->stencilBits) &&
+ (a->numAuxBuffers == b->numAuxBuffers) &&
+ (a->level == b->level) &&
+ (a->pixmapMode == b->pixmapMode) &&
+ (a->visualRating == b->visualRating) &&
+
+ (a->transparentPixel == b->transparentPixel) &&
+
+ ((a->transparentPixel != GLX_TRANSPARENT_RGB) ||
+ ((a->transparentRed == b->transparentRed) &&
+ (a->transparentGreen == b->transparentGreen) &&
+ (a->transparentBlue == b->transparentBlue) &&
+ (a->transparentAlpha == b->transparentAlpha))) &&
+
+ ((a->transparentPixel != GLX_TRANSPARENT_INDEX) ||
+ (a->transparentIndex == b->transparentIndex)) &&
+
+ (a->sampleBuffers == b->sampleBuffers) &&
+ (a->samples == b->samples) &&
+ ((a->drawableType & b->drawableType) != 0) &&
+ (a->renderType == b->renderType) &&
+ (a->maxPbufferWidth == b->maxPbufferWidth) &&
+ (a->maxPbufferHeight == b->maxPbufferHeight) &&
+ (a->maxPbufferPixels == b->maxPbufferPixels) &&
+ (a->optimalPbufferWidth == b->optimalPbufferWidth) &&
+ (a->optimalPbufferHeight == b->optimalPbufferHeight) &&
+ (a->swapMethod == b->swapMethod) );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.h
new file mode 100644
index 000000000..4b5c6f68b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/glcontextmodes.h
@@ -0,0 +1,52 @@
+/*
+ * (C) Copyright IBM Corporation 2003
+ * 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
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file glcontextmodes.h
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#ifndef GLCONTEXTMODES_H
+#define GLCONTEXTMODES_H
+
+#include "GL/internal/glcore.h"
+
+#if !defined(IN_MINI_GLX)
+extern GLint _gl_convert_from_x_visual_type( int visualType );
+extern GLint _gl_convert_to_x_visual_type( int visualType );
+extern void _gl_copy_visual_to_context_mode( __GLcontextModes * mode,
+ const __GLXvisualConfig * config );
+extern int _gl_get_context_mode_data( const __GLcontextModes *mode,
+ int attribute, int *value_return );
+#endif /* !defined(IN_MINI_GLX) */
+
+extern __GLcontextModes * _gl_context_modes_create( unsigned count,
+ size_t minimum_size );
+extern void _gl_context_modes_destroy( __GLcontextModes * modes );
+extern __GLcontextModes * _gl_context_modes_find_visual(
+ __GLcontextModes * modes, int vid );
+extern GLboolean _gl_context_modes_are_same( const __GLcontextModes * a,
+ const __GLcontextModes * b );
+
+#endif /* GLCONTEXTMODES_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/memops.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/memops.h
new file mode 100644
index 000000000..4952d788e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/memops.h
@@ -0,0 +1,17 @@
+#ifndef DRIMEMSETIO_H
+#define DRIMEMSETIO_H
+/*
+* memset an area in I/O space
+* We need to be careful about this on some archs
+*/
+static __inline__ void drimemsetio(void* address, int c, int size)
+{
+#if defined(__powerpc__) || defined(__ia64__)
+ int i;
+ for(i=0;i<size;i++)
+ *((char *)address + i)=c;
+#else
+ memset(address,c,size);
+#endif
+}
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/mmio.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/mmio.h
new file mode 100644
index 000000000..2b7b4123e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/mmio.h
@@ -0,0 +1,62 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file mmio.h
+ * Functions for properly handling memory mapped IO on various platforms.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+
+#ifndef MMIO_H
+#define MMIO_H
+
+#include "glheader.h"
+
+#if defined( __powerpc__ )
+
+static __inline__ u_int32_t
+read_MMIO_LE32( volatile void * base, unsigned long offset )
+{
+ u_int32_t val;
+
+ __asm__ __volatile__( "lwbrx %0, %1, %2 ; eieio"
+ : "=r" (val)
+ : "b" (base), "r" (offset) );
+ return val;
+}
+
+#else
+
+static __inline__ u_int32_t
+read_MMIO_LE32( volatile void * base, unsigned long offset )
+{
+ volatile u_int32_t * p = (volatile u_int32_t *) (((volatile char *) base) + offset);
+ return LE32_TO_CPU( p[0] );
+}
+
+#endif
+
+#endif /* MMIO_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/mmx.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/mmx.h
new file mode 100644
index 000000000..49ce7e3e3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/mmx.h
@@ -0,0 +1,560 @@
+/* mmx.h
+
+ MultiMedia eXtensions GCC interface library for IA32.
+
+ To use this library, simply include this header file
+ and compile with GCC. You MUST have inlining enabled
+ in order for mmx_ok() to work; this can be done by
+ simply using -O on the GCC command line.
+
+ Compiling with -DMMX_TRACE will cause detailed trace
+ output to be sent to stderr for each mmx operation.
+ This adds lots of code, and obviously slows execution to
+ a crawl, but can be very useful for debugging.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY
+ EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
+ LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR ANY PARTICULAR PURPOSE.
+
+ 1997-98 by H. Dietz and R. Fisher
+
+ History:
+ 97-98* R.Fisher Early versions
+ 980501 R.Fisher Original Release
+ 980611* H.Dietz Rewrite, correctly implementing inlines, and
+ R.Fisher including direct register accesses.
+ 980616 R.Fisher Release of 980611 as 980616.
+ 980714 R.Fisher Minor corrections to Makefile, etc.
+ 980715 R.Fisher mmx_ok() now prevents optimizer from using
+ clobbered values.
+ mmx_ok() now checks if cpuid instruction is
+ available before trying to use it.
+ 980726* R.Fisher mm_support() searches for AMD 3DNow, Cyrix
+ Extended MMX, and standard MMX. It returns a
+ value which is positive if any of these are
+ supported, and can be masked with constants to
+ see which. mmx_ok() is now a call to this
+ 980726* R.Fisher Added i2r support for shift functions
+ 980919 R.Fisher Fixed AMD extended feature recognition bug.
+ 980921 R.Fisher Added definition/check for _MMX_H.
+ Added "float s[2]" to mmx_t for use with
+ 3DNow and EMMX. So same mmx_t can be used.
+ 981013 R.Fisher Fixed cpuid function 1 bug (looked at wrong reg)
+ Fixed psllq_i2r error in mmxtest.c
+
+ * Unreleased (internal or interim) versions
+
+ Notes:
+ It appears that the latest gas has the pand problem fixed, therefore
+ I'll undefine BROKEN_PAND by default.
+ String compares may be quicker than the multiple test/jumps in vendor
+ test sequence in mmx_ok(), but I'm not concerned with that right now.
+
+ Acknowledgments:
+ Jussi Laako for pointing out the errors ultimately found to be
+ connected to the failure to notify the optimizer of clobbered values.
+ Roger Hardiman for reminding us that CPUID isn't everywhere, and that
+ someone may actually try to use this on a machine without CPUID.
+ Also for suggesting code for checking this.
+ Robert Dale for pointing out the AMD recognition bug.
+ Jimmy Mayfield and Carl Witty for pointing out the Intel recognition
+ bug.
+ Carl Witty for pointing out the psllq_i2r test bug.
+*/
+
+#ifndef _MMX_H
+#define _MMX_H
+
+//#define MMX_TRACE
+
+/* Warning: at this writing, the version of GAS packaged
+ with most Linux distributions does not handle the
+ parallel AND operation mnemonic correctly. If the
+ symbol BROKEN_PAND is defined, a slower alternative
+ coding will be used. If execution of mmxtest results
+ in an illegal instruction fault, define this symbol.
+*/
+#undef BROKEN_PAND
+
+
+/* The type of an value that fits in an MMX register
+ (note that long long constant values MUST be suffixed
+ by LL and unsigned long long values by ULL, lest
+ they be truncated by the compiler)
+*/
+typedef union {
+ long long q; /* Quadword (64-bit) value */
+ unsigned long long uq; /* Unsigned Quadword */
+ int d[2]; /* 2 Doubleword (32-bit) values */
+ unsigned int ud[2]; /* 2 Unsigned Doubleword */
+ short w[4]; /* 4 Word (16-bit) values */
+ unsigned short uw[4]; /* 4 Unsigned Word */
+ char b[8]; /* 8 Byte (8-bit) values */
+ unsigned char ub[8]; /* 8 Unsigned Byte */
+ float s[2]; /* Single-precision (32-bit) value */
+} mmx_t;
+
+/* Helper functions for the instruction macros that follow...
+ (note that memory-to-register, m2r, instructions are nearly
+ as efficient as register-to-register, r2r, instructions;
+ however, memory-to-memory instructions are really simulated
+ as a convenience, and are only 1/3 as efficient)
+*/
+#ifdef MMX_TRACE
+
+/* Include the stuff for printing a trace to stderr...
+*/
+
+#include <stdio.h>
+
+#define mmx_i2r(op, imm, reg) \
+ { \
+ mmx_t mmx_trace; \
+ mmx_trace = (imm); \
+ fprintf(stderr, #op "_i2r(" #imm "=0x%016llx, ", mmx_trace.q); \
+ __asm__ __volatile__ ("movq %%" #reg ", %0" \
+ : "=X" (mmx_trace) \
+ : /* nothing */ ); \
+ fprintf(stderr, #reg "=0x%016llx) => ", mmx_trace.q); \
+ __asm__ __volatile__ (#op " %0, %%" #reg \
+ : /* nothing */ \
+ : "X" (imm)); \
+ __asm__ __volatile__ ("movq %%" #reg ", %0" \
+ : "=X" (mmx_trace) \
+ : /* nothing */ ); \
+ fprintf(stderr, #reg "=0x%016llx\n", mmx_trace.q); \
+ }
+
+#define mmx_m2r(op, mem, reg) \
+ { \
+ mmx_t mmx_trace; \
+ mmx_trace = (mem); \
+ fprintf(stderr, #op "_m2r(" #mem "=0x%016llx, ", mmx_trace.q); \
+ __asm__ __volatile__ ("movq %%" #reg ", %0" \
+ : "=X" (mmx_trace) \
+ : /* nothing */ ); \
+ fprintf(stderr, #reg "=0x%016llx) => ", mmx_trace.q); \
+ __asm__ __volatile__ (#op " %0, %%" #reg \
+ : /* nothing */ \
+ : "X" (mem)); \
+ __asm__ __volatile__ ("movq %%" #reg ", %0" \
+ : "=X" (mmx_trace) \
+ : /* nothing */ ); \
+ fprintf(stderr, #reg "=0x%016llx\n", mmx_trace.q); \
+ }
+
+#define mmx_r2m(op, reg, mem) \
+ { \
+ mmx_t mmx_trace; \
+ __asm__ __volatile__ ("movq %%" #reg ", %0" \
+ : "=X" (mmx_trace) \
+ : /* nothing */ ); \
+ fprintf(stderr, #op "_r2m(" #reg "=0x%016llx, ", mmx_trace.q); \
+ mmx_trace = (mem); \
+ fprintf(stderr, #mem "=0x%016llx) => ", mmx_trace.q); \
+ __asm__ __volatile__ (#op " %%" #reg ", %0" \
+ : "=X" (mem) \
+ : /* nothing */ ); \
+ mmx_trace = (mem); \
+ fprintf(stderr, #mem "=0x%016llx\n", mmx_trace.q); \
+ }
+
+#define mmx_r2r(op, regs, regd) \
+ { \
+ mmx_t mmx_trace; \
+ __asm__ __volatile__ ("movq %%" #regs ", %0" \
+ : "=X" (mmx_trace) \
+ : /* nothing */ ); \
+ fprintf(stderr, #op "_r2r(" #regs "=0x%016llx, ", mmx_trace.q); \
+ __asm__ __volatile__ ("movq %%" #regd ", %0" \
+ : "=X" (mmx_trace) \
+ : /* nothing */ ); \
+ fprintf(stderr, #regd "=0x%016llx) => ", mmx_trace.q); \
+ __asm__ __volatile__ (#op " %" #regs ", %" #regd); \
+ __asm__ __volatile__ ("movq %%" #regd ", %0" \
+ : "=X" (mmx_trace) \
+ : /* nothing */ ); \
+ fprintf(stderr, #regd "=0x%016llx\n", mmx_trace.q); \
+ }
+
+#define mmx_m2m(op, mems, memd) \
+ { \
+ mmx_t mmx_trace; \
+ mmx_trace = (mems); \
+ fprintf(stderr, #op "_m2m(" #mems "=0x%016llx, ", mmx_trace.q); \
+ mmx_trace = (memd); \
+ fprintf(stderr, #memd "=0x%016llx) => ", mmx_trace.q); \
+ __asm__ __volatile__ ("movq %0, %%mm0\n\t" \
+ #op " %1, %%mm0\n\t" \
+ "movq %%mm0, %0" \
+ : "=X" (memd) \
+ : "X" (mems)); \
+ mmx_trace = (memd); \
+ fprintf(stderr, #memd "=0x%016llx\n", mmx_trace.q); \
+ }
+
+#else
+
+/* These macros are a lot simpler without the tracing...
+*/
+
+#define mmx_i2r(op, imm, reg) \
+ __asm__ __volatile__ (#op " $" #imm ", %%" #reg \
+ : /* nothing */ \
+ : /* nothing */);
+
+#define mmx_m2r(op, mem, reg) \
+ __asm__ __volatile__ (#op " %0, %%" #reg \
+ : /* nothing */ \
+ : "X" (mem))
+
+#define mmx_r2m(op, reg, mem) \
+ __asm__ __volatile__ (#op " %%" #reg ", %0" \
+ : "=X" (mem) \
+ : /* nothing */ )
+
+#define mmx_r2r(op, regs, regd) \
+ __asm__ __volatile__ (#op " %" #regs ", %" #regd)
+
+#define mmx_m2m(op, mems, memd) \
+ __asm__ __volatile__ ("movq %0, %%mm0\n\t" \
+ #op " %1, %%mm0\n\t" \
+ "movq %%mm0, %0" \
+ : "=X" (memd) \
+ : "X" (mems))
+
+#endif
+
+
+/* 1x64 MOVe Quadword
+ (this is both a load and a store...
+ in fact, it is the only way to store)
+*/
+#define movq_m2r(var, reg) mmx_m2r(movq, var, reg)
+#define movq_r2m(reg, var) mmx_r2m(movq, reg, var)
+#define movq_r2r(regs, regd) mmx_r2r(movq, regs, regd)
+#define movq(vars, vard) \
+ __asm__ __volatile__ ("movq %1, %%mm0\n\t" \
+ "movq %%mm0, %0" \
+ : "=X" (vard) \
+ : "X" (vars))
+
+
+/* 1x32 MOVe Doubleword
+ (like movq, this is both load and store...
+ but is most useful for moving things between
+ mmx registers and ordinary registers)
+*/
+#define movd_m2r(var, reg) mmx_m2r(movd, var, reg)
+#define movd_r2m(reg, var) mmx_r2m(movd, reg, var)
+#define movd_r2r(regs, regd) mmx_r2r(movd, regs, regd)
+#define movd(vars, vard) \
+ __asm__ __volatile__ ("movd %1, %%mm0\n\t" \
+ "movd %%mm0, %0" \
+ : "=X" (vard) \
+ : "X" (vars))
+
+
+/* 2x32, 4x16, and 8x8 Parallel ADDs
+*/
+#define paddd_m2r(var, reg) mmx_m2r(paddd, var, reg)
+#define paddd_r2r(regs, regd) mmx_r2r(paddd, regs, regd)
+#define paddd(vars, vard) mmx_m2m(paddd, vars, vard)
+
+#define paddw_m2r(var, reg) mmx_m2r(paddw, var, reg)
+#define paddw_r2r(regs, regd) mmx_r2r(paddw, regs, regd)
+#define paddw(vars, vard) mmx_m2m(paddw, vars, vard)
+
+#define paddb_m2r(var, reg) mmx_m2r(paddb, var, reg)
+#define paddb_r2r(regs, regd) mmx_r2r(paddb, regs, regd)
+#define paddb(vars, vard) mmx_m2m(paddb, vars, vard)
+
+
+/* 4x16 and 8x8 Parallel ADDs using Saturation arithmetic
+*/
+#define paddsw_m2r(var, reg) mmx_m2r(paddsw, var, reg)
+#define paddsw_r2r(regs, regd) mmx_r2r(paddsw, regs, regd)
+#define paddsw(vars, vard) mmx_m2m(paddsw, vars, vard)
+
+#define paddsb_m2r(var, reg) mmx_m2r(paddsb, var, reg)
+#define paddsb_r2r(regs, regd) mmx_r2r(paddsb, regs, regd)
+#define paddsb(vars, vard) mmx_m2m(paddsb, vars, vard)
+
+
+/* 4x16 and 8x8 Parallel ADDs using Unsigned Saturation arithmetic
+*/
+#define paddusw_m2r(var, reg) mmx_m2r(paddusw, var, reg)
+#define paddusw_r2r(regs, regd) mmx_r2r(paddusw, regs, regd)
+#define paddusw(vars, vard) mmx_m2m(paddusw, vars, vard)
+
+#define paddusb_m2r(var, reg) mmx_m2r(paddusb, var, reg)
+#define paddusb_r2r(regs, regd) mmx_r2r(paddusb, regs, regd)
+#define paddusb(vars, vard) mmx_m2m(paddusb, vars, vard)
+
+
+/* 2x32, 4x16, and 8x8 Parallel SUBs
+*/
+#define psubd_m2r(var, reg) mmx_m2r(psubd, var, reg)
+#define psubd_r2r(regs, regd) mmx_r2r(psubd, regs, regd)
+#define psubd(vars, vard) mmx_m2m(psubd, vars, vard)
+
+#define psubw_m2r(var, reg) mmx_m2r(psubw, var, reg)
+#define psubw_r2r(regs, regd) mmx_r2r(psubw, regs, regd)
+#define psubw(vars, vard) mmx_m2m(psubw, vars, vard)
+
+#define psubb_m2r(var, reg) mmx_m2r(psubb, var, reg)
+#define psubb_r2r(regs, regd) mmx_r2r(psubb, regs, regd)
+#define psubb(vars, vard) mmx_m2m(psubb, vars, vard)
+
+
+/* 4x16 and 8x8 Parallel SUBs using Saturation arithmetic
+*/
+#define psubsw_m2r(var, reg) mmx_m2r(psubsw, var, reg)
+#define psubsw_r2r(regs, regd) mmx_r2r(psubsw, regs, regd)
+#define psubsw(vars, vard) mmx_m2m(psubsw, vars, vard)
+
+#define psubsb_m2r(var, reg) mmx_m2r(psubsb, var, reg)
+#define psubsb_r2r(regs, regd) mmx_r2r(psubsb, regs, regd)
+#define psubsb(vars, vard) mmx_m2m(psubsb, vars, vard)
+
+
+/* 4x16 and 8x8 Parallel SUBs using Unsigned Saturation arithmetic
+*/
+#define psubusw_m2r(var, reg) mmx_m2r(psubusw, var, reg)
+#define psubusw_r2r(regs, regd) mmx_r2r(psubusw, regs, regd)
+#define psubusw(vars, vard) mmx_m2m(psubusw, vars, vard)
+
+#define psubusb_m2r(var, reg) mmx_m2r(psubusb, var, reg)
+#define psubusb_r2r(regs, regd) mmx_r2r(psubusb, regs, regd)
+#define psubusb(vars, vard) mmx_m2m(psubusb, vars, vard)
+
+
+/* 4x16 Parallel MULs giving Low 4x16 portions of results
+*/
+#define pmullw_m2r(var, reg) mmx_m2r(pmullw, var, reg)
+#define pmullw_r2r(regs, regd) mmx_r2r(pmullw, regs, regd)
+#define pmullw(vars, vard) mmx_m2m(pmullw, vars, vard)
+
+
+/* 4x16 Parallel MULs giving High 4x16 portions of results
+*/
+#define pmulhw_m2r(var, reg) mmx_m2r(pmulhw, var, reg)
+#define pmulhw_r2r(regs, regd) mmx_r2r(pmulhw, regs, regd)
+#define pmulhw(vars, vard) mmx_m2m(pmulhw, vars, vard)
+
+
+/* 4x16->2x32 Parallel Mul-ADD
+ (muls like pmullw, then adds adjacent 16-bit fields
+ in the multiply result to make the final 2x32 result)
+*/
+#define pmaddwd_m2r(var, reg) mmx_m2r(pmaddwd, var, reg)
+#define pmaddwd_r2r(regs, regd) mmx_r2r(pmaddwd, regs, regd)
+#define pmaddwd(vars, vard) mmx_m2m(pmaddwd, vars, vard)
+
+
+/* 1x64 bitwise AND
+*/
+#ifdef BROKEN_PAND
+#define pand_m2r(var, reg) \
+ { \
+ mmx_m2r(pandn, (mmx_t) -1LL, reg); \
+ mmx_m2r(pandn, var, reg); \
+ }
+#define pand_r2r(regs, regd) \
+ { \
+ mmx_m2r(pandn, (mmx_t) -1LL, regd); \
+ mmx_r2r(pandn, regs, regd) \
+ }
+#define pand(vars, vard) \
+ { \
+ movq_m2r(vard, mm0); \
+ mmx_m2r(pandn, (mmx_t) -1LL, mm0); \
+ mmx_m2r(pandn, vars, mm0); \
+ movq_r2m(mm0, vard); \
+ }
+#else
+#define pand_m2r(var, reg) mmx_m2r(pand, var, reg)
+#define pand_r2r(regs, regd) mmx_r2r(pand, regs, regd)
+#define pand(vars, vard) mmx_m2m(pand, vars, vard)
+#endif
+
+
+/* 1x64 bitwise AND with Not the destination
+*/
+#define pandn_m2r(var, reg) mmx_m2r(pandn, var, reg)
+#define pandn_r2r(regs, regd) mmx_r2r(pandn, regs, regd)
+#define pandn(vars, vard) mmx_m2m(pandn, vars, vard)
+
+
+/* 1x64 bitwise OR
+*/
+#define por_m2r(var, reg) mmx_m2r(por, var, reg)
+#define por_r2r(regs, regd) mmx_r2r(por, regs, regd)
+#define por(vars, vard) mmx_m2m(por, vars, vard)
+
+
+/* 1x64 bitwise eXclusive OR
+*/
+#define pxor_m2r(var, reg) mmx_m2r(pxor, var, reg)
+#define pxor_r2r(regs, regd) mmx_r2r(pxor, regs, regd)
+#define pxor(vars, vard) mmx_m2m(pxor, vars, vard)
+
+
+/* 2x32, 4x16, and 8x8 Parallel CoMPare for EQuality
+ (resulting fields are either 0 or -1)
+*/
+#define pcmpeqd_m2r(var, reg) mmx_m2r(pcmpeqd, var, reg)
+#define pcmpeqd_r2r(regs, regd) mmx_r2r(pcmpeqd, regs, regd)
+#define pcmpeqd(vars, vard) mmx_m2m(pcmpeqd, vars, vard)
+
+#define pcmpeqw_m2r(var, reg) mmx_m2r(pcmpeqw, var, reg)
+#define pcmpeqw_r2r(regs, regd) mmx_r2r(pcmpeqw, regs, regd)
+#define pcmpeqw(vars, vard) mmx_m2m(pcmpeqw, vars, vard)
+
+#define pcmpeqb_m2r(var, reg) mmx_m2r(pcmpeqb, var, reg)
+#define pcmpeqb_r2r(regs, regd) mmx_r2r(pcmpeqb, regs, regd)
+#define pcmpeqb(vars, vard) mmx_m2m(pcmpeqb, vars, vard)
+
+
+/* 2x32, 4x16, and 8x8 Parallel CoMPare for Greater Than
+ (resulting fields are either 0 or -1)
+*/
+#define pcmpgtd_m2r(var, reg) mmx_m2r(pcmpgtd, var, reg)
+#define pcmpgtd_r2r(regs, regd) mmx_r2r(pcmpgtd, regs, regd)
+#define pcmpgtd(vars, vard) mmx_m2m(pcmpgtd, vars, vard)
+
+#define pcmpgtw_m2r(var, reg) mmx_m2r(pcmpgtw, var, reg)
+#define pcmpgtw_r2r(regs, regd) mmx_r2r(pcmpgtw, regs, regd)
+#define pcmpgtw(vars, vard) mmx_m2m(pcmpgtw, vars, vard)
+
+#define pcmpgtb_m2r(var, reg) mmx_m2r(pcmpgtb, var, reg)
+#define pcmpgtb_r2r(regs, regd) mmx_r2r(pcmpgtb, regs, regd)
+#define pcmpgtb(vars, vard) mmx_m2m(pcmpgtb, vars, vard)
+
+
+/* 1x64, 2x32, and 4x16 Parallel Shift Left Logical
+*/
+#define psllq_i2r(imm, reg) mmx_i2r(psllq, imm, reg)
+#define psllq_m2r(var, reg) mmx_m2r(psllq, var, reg)
+#define psllq_r2r(regs, regd) mmx_r2r(psllq, regs, regd)
+#define psllq(vars, vard) mmx_m2m(psllq, vars, vard)
+
+#define pslld_i2r(imm, reg) mmx_i2r(pslld, imm, reg)
+#define pslld_m2r(var, reg) mmx_m2r(pslld, var, reg)
+#define pslld_r2r(regs, regd) mmx_r2r(pslld, regs, regd)
+#define pslld(vars, vard) mmx_m2m(pslld, vars, vard)
+
+#define psllw_i2r(imm, reg) mmx_i2r(psllw, imm, reg)
+#define psllw_m2r(var, reg) mmx_m2r(psllw, var, reg)
+#define psllw_r2r(regs, regd) mmx_r2r(psllw, regs, regd)
+#define psllw(vars, vard) mmx_m2m(psllw, vars, vard)
+
+
+/* 1x64, 2x32, and 4x16 Parallel Shift Right Logical
+*/
+#define psrlq_i2r(imm, reg) mmx_i2r(psrlq, imm, reg)
+#define psrlq_m2r(var, reg) mmx_m2r(psrlq, var, reg)
+#define psrlq_r2r(regs, regd) mmx_r2r(psrlq, regs, regd)
+#define psrlq(vars, vard) mmx_m2m(psrlq, vars, vard)
+
+#define psrld_i2r(imm, reg) mmx_i2r(psrld, imm, reg)
+#define psrld_m2r(var, reg) mmx_m2r(psrld, var, reg)
+#define psrld_r2r(regs, regd) mmx_r2r(psrld, regs, regd)
+#define psrld(vars, vard) mmx_m2m(psrld, vars, vard)
+
+#define psrlw_i2r(imm, reg) mmx_i2r(psrlw, imm, reg)
+#define psrlw_m2r(var, reg) mmx_m2r(psrlw, var, reg)
+#define psrlw_r2r(regs, regd) mmx_r2r(psrlw, regs, regd)
+#define psrlw(vars, vard) mmx_m2m(psrlw, vars, vard)
+
+
+/* 2x32 and 4x16 Parallel Shift Right Arithmetic
+*/
+#define psrad_i2r(imm, reg) mmx_i2r(psrad, imm, reg)
+#define psrad_m2r(var, reg) mmx_m2r(psrad, var, reg)
+#define psrad_r2r(regs, regd) mmx_r2r(psrad, regs, regd)
+#define psrad(vars, vard) mmx_m2m(psrad, vars, vard)
+
+#define psraw_i2r(imm, reg) mmx_i2r(psraw, imm, reg)
+#define psraw_m2r(var, reg) mmx_m2r(psraw, var, reg)
+#define psraw_r2r(regs, regd) mmx_r2r(psraw, regs, regd)
+#define psraw(vars, vard) mmx_m2m(psraw, vars, vard)
+
+
+/* 2x32->4x16 and 4x16->8x8 PACK and Signed Saturate
+ (packs source and dest fields into dest in that order)
+*/
+#define packssdw_m2r(var, reg) mmx_m2r(packssdw, var, reg)
+#define packssdw_r2r(regs, regd) mmx_r2r(packssdw, regs, regd)
+#define packssdw(vars, vard) mmx_m2m(packssdw, vars, vard)
+
+#define packsswb_m2r(var, reg) mmx_m2r(packsswb, var, reg)
+#define packsswb_r2r(regs, regd) mmx_r2r(packsswb, regs, regd)
+#define packsswb(vars, vard) mmx_m2m(packsswb, vars, vard)
+
+
+/* 4x16->8x8 PACK and Unsigned Saturate
+ (packs source and dest fields into dest in that order)
+*/
+#define packuswb_m2r(var, reg) mmx_m2r(packuswb, var, reg)
+#define packuswb_r2r(regs, regd) mmx_r2r(packuswb, regs, regd)
+#define packuswb(vars, vard) mmx_m2m(packuswb, vars, vard)
+
+
+/* 2x32->1x64, 4x16->2x32, and 8x8->4x16 UNPaCK Low
+ (interleaves low half of dest with low half of source
+ as padding in each result field)
+*/
+#define punpckldq_m2r(var, reg) mmx_m2r(punpckldq, var, reg)
+#define punpckldq_r2r(regs, regd) mmx_r2r(punpckldq, regs, regd)
+#define punpckldq(vars, vard) mmx_m2m(punpckldq, vars, vard)
+
+#define punpcklwd_m2r(var, reg) mmx_m2r(punpcklwd, var, reg)
+#define punpcklwd_r2r(regs, regd) mmx_r2r(punpcklwd, regs, regd)
+#define punpcklwd(vars, vard) mmx_m2m(punpcklwd, vars, vard)
+
+#define punpcklbw_m2r(var, reg) mmx_m2r(punpcklbw, var, reg)
+#define punpcklbw_r2r(regs, regd) mmx_r2r(punpcklbw, regs, regd)
+#define punpcklbw(vars, vard) mmx_m2m(punpcklbw, vars, vard)
+
+
+/* 2x32->1x64, 4x16->2x32, and 8x8->4x16 UNPaCK High
+ (interleaves high half of dest with high half of source
+ as padding in each result field)
+*/
+#define punpckhdq_m2r(var, reg) mmx_m2r(punpckhdq, var, reg)
+#define punpckhdq_r2r(regs, regd) mmx_r2r(punpckhdq, regs, regd)
+#define punpckhdq(vars, vard) mmx_m2m(punpckhdq, vars, vard)
+
+#define punpckhwd_m2r(var, reg) mmx_m2r(punpckhwd, var, reg)
+#define punpckhwd_r2r(regs, regd) mmx_r2r(punpckhwd, regs, regd)
+#define punpckhwd(vars, vard) mmx_m2m(punpckhwd, vars, vard)
+
+#define punpckhbw_m2r(var, reg) mmx_m2r(punpckhbw, var, reg)
+#define punpckhbw_r2r(regs, regd) mmx_r2r(punpckhbw, regs, regd)
+#define punpckhbw(vars, vard) mmx_m2m(punpckhbw, vars, vard)
+
+
+/* Empty MMx State
+ (used to clean-up when going from mmx to float use
+ of the registers that are shared by both; note that
+ there is no float-to-mmx operation needed, because
+ only the float tag word info is corruptible)
+*/
+#ifdef MMX_TRACE
+
+#define emms() \
+ { \
+ fprintf(stderr, "emms()\n"); \
+ __asm__ __volatile__ ("emms"); \
+ }
+
+#else
+
+#define emms() __asm__ __volatile__ ("emms")
+
+#endif
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/spantmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/spantmp.h
new file mode 100644
index 000000000..f726e8305
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/spantmp.h
@@ -0,0 +1,328 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * (C) Copyright IBM Corporation 2002, 2003
+ * 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
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Keith Whitwell <keithw@tungstengraphics.com>
+ * Gareth Hughes <gareth@nvidia.com>
+ */
+
+#include "spantmp_common.h"
+
+#ifndef DBG
+#define DBG 0
+#endif
+
+#ifndef HW_READ_CLIPLOOP
+#define HW_READ_CLIPLOOP() HW_CLIPLOOP()
+#endif
+
+#ifndef HW_WRITE_CLIPLOOP
+#define HW_WRITE_CLIPLOOP() HW_CLIPLOOP()
+#endif
+
+
+static void TAG(WriteRGBASpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *values, const GLubyte mask[] )
+{
+ HW_WRITE_LOCK()
+ {
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ GLint x1;
+ GLint n1;
+ LOCAL_VARS;
+
+ y = Y_FLIP(y);
+
+ HW_WRITE_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+
+ if (DBG) fprintf(stderr, "WriteRGBASpan %d..%d (x1 %d)\n",
+ (int)i, (int)n1, (int)x1);
+
+ if (mask)
+ {
+ for (;n1>0;i++,x1++,n1--)
+ if (mask[i])
+ WRITE_RGBA( x1, y,
+ rgba[i][0], rgba[i][1],
+ rgba[i][2], rgba[i][3] );
+ }
+ else
+ {
+ for (;n1>0;i++,x1++,n1--)
+ WRITE_RGBA( x1, y,
+ rgba[i][0], rgba[i][1],
+ rgba[i][2], rgba[i][3] );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_WRITE_UNLOCK();
+}
+
+static void TAG(WriteRGBSpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *values, const GLubyte mask[] )
+{
+ HW_WRITE_LOCK()
+ {
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ GLint x1;
+ GLint n1;
+ LOCAL_VARS;
+
+ y = Y_FLIP(y);
+
+ HW_WRITE_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+
+ if (DBG) fprintf(stderr, "WriteRGBSpan %d..%d (x1 %d)\n",
+ (int)i, (int)n1, (int)x1);
+
+ if (mask)
+ {
+ for (;n1>0;i++,x1++,n1--)
+ if (mask[i])
+ WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 255 );
+ }
+ else
+ {
+ for (;n1>0;i++,x1++,n1--)
+ WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 255 );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_WRITE_UNLOCK();
+}
+
+static void TAG(WriteRGBAPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ const void *values, const GLubyte mask[] )
+{
+ HW_WRITE_LOCK()
+ {
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ GLuint i;
+ LOCAL_VARS;
+
+ if (DBG) fprintf(stderr, "WriteRGBAPixels\n");
+
+ HW_WRITE_CLIPLOOP()
+ {
+ if (mask)
+ {
+ for (i=0;i<n;i++)
+ {
+ if (mask[i]) {
+ const int fy = Y_FLIP(y[i]);
+ if (CLIPPIXEL(x[i],fy))
+ WRITE_RGBA( x[i], fy,
+ rgba[i][0], rgba[i][1],
+ rgba[i][2], rgba[i][3] );
+ }
+ }
+ }
+ else
+ {
+ for (i=0;i<n;i++)
+ {
+ const int fy = Y_FLIP(y[i]);
+ if (CLIPPIXEL(x[i],fy))
+ WRITE_RGBA( x[i], fy,
+ rgba[i][0], rgba[i][1],
+ rgba[i][2], rgba[i][3] );
+ }
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_WRITE_UNLOCK();
+}
+
+
+static void TAG(WriteMonoRGBASpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *value,
+ const GLubyte mask[] )
+{
+ HW_WRITE_LOCK()
+ {
+ const GLubyte *color = (const GLubyte *) value;
+ GLint x1;
+ GLint n1;
+ LOCAL_VARS;
+ INIT_MONO_PIXEL(p, color);
+
+ y = Y_FLIP( y );
+
+ if (DBG) fprintf(stderr, "WriteMonoRGBASpan\n");
+
+ HW_WRITE_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+ if (mask)
+ {
+ for (;n1>0;i++,x1++,n1--)
+ if (mask[i])
+ WRITE_PIXEL( x1, y, p );
+ }
+ else
+ {
+ for (;n1>0;i++,x1++,n1--)
+ WRITE_PIXEL( x1, y, p );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_WRITE_UNLOCK();
+}
+
+
+static void TAG(WriteMonoRGBAPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ const void *value,
+ const GLubyte mask[] )
+{
+ HW_WRITE_LOCK()
+ {
+ const GLubyte *color = (const GLubyte *) value;
+ GLuint i;
+ LOCAL_VARS;
+ INIT_MONO_PIXEL(p, color);
+
+ if (DBG) fprintf(stderr, "WriteMonoRGBAPixels\n");
+
+ HW_WRITE_CLIPLOOP()
+ {
+ if (mask)
+ {
+ for (i=0;i<n;i++)
+ if (mask[i]) {
+ int fy = Y_FLIP(y[i]);
+ if (CLIPPIXEL( x[i], fy ))
+ WRITE_PIXEL( x[i], fy, p );
+ }
+ }
+ else
+ {
+ for (i=0;i<n;i++) {
+ int fy = Y_FLIP(y[i]);
+ if (CLIPPIXEL( x[i], fy ))
+ WRITE_PIXEL( x[i], fy, p );
+ }
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_WRITE_UNLOCK();
+}
+
+
+static void TAG(ReadRGBASpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ void *values)
+{
+ HW_READ_LOCK()
+ {
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
+ GLint x1,n1;
+ LOCAL_VARS;
+
+ y = Y_FLIP(y);
+
+ if (DBG) fprintf(stderr, "ReadRGBASpan\n");
+
+ HW_READ_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+ for (;n1>0;i++,x1++,n1--)
+ READ_RGBA( rgba[i], x1, y );
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_READ_UNLOCK();
+}
+
+
+static void TAG(ReadRGBAPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ void *values )
+{
+ HW_READ_LOCK()
+ {
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
+ const GLubyte *mask = NULL; /* remove someday */
+ GLuint i;
+ LOCAL_VARS;
+
+ if (DBG) fprintf(stderr, "ReadRGBAPixels\n");
+
+ HW_READ_CLIPLOOP()
+ {
+ if (mask)
+ {
+ for (i=0;i<n;i++)
+ if (mask[i]) {
+ int fy = Y_FLIP( y[i] );
+ if (CLIPPIXEL( x[i], fy ))
+ READ_RGBA( rgba[i], x[i], fy );
+ }
+ }
+ else
+ {
+ for (i=0;i<n;i++) {
+ int fy = Y_FLIP( y[i] );
+ if (CLIPPIXEL( x[i], fy ))
+ READ_RGBA( rgba[i], x[i], fy );
+ }
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_READ_UNLOCK();
+}
+
+
+
+
+#undef WRITE_PIXEL
+#undef WRITE_RGBA
+#undef READ_RGBA
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/spantmp2.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/spantmp2.h
new file mode 100644
index 000000000..1a20a4597
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/spantmp2.h
@@ -0,0 +1,609 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file spantmp2.h
+ *
+ * Template file of span read / write functions.
+ *
+ * \author Keith Whitwell <keithw@tungstengraphics.com>
+ * \author Gareth Hughes <gareth@nvidia.com>
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include "colormac.h"
+#include "spantmp_common.h"
+
+#ifndef DBG
+#define DBG 0
+#endif
+
+#ifndef HW_READ_CLIPLOOP
+#define HW_READ_CLIPLOOP() HW_CLIPLOOP()
+#endif
+
+#ifndef HW_WRITE_CLIPLOOP
+#define HW_WRITE_CLIPLOOP() HW_CLIPLOOP()
+#endif
+
+#if (SPANTMP_PIXEL_FMT == GL_RGB) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5)
+
+#ifndef GET_SRC_PTR
+#define GET_SRC_PTR(_x, _y) (read_buf + (_x) * 2 + (_y) * pitch)
+#endif
+
+#ifndef GET_DST_PTR
+#define GET_DST_PTR(_x, _y) ( buf + (_x) * 2 + (_y) * pitch)
+#endif
+
+#define INIT_MONO_PIXEL(p, color) \
+ p = PACK_COLOR_565( color[0], color[1], color[2] )
+
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ do { \
+ GLshort * _p = (GLshort *) GET_DST_PTR(_x, _y); \
+ _p[0] = ((((int)r & 0xf8) << 8) | (((int)g & 0xfc) << 3) | \
+ (((int)b & 0xf8) >> 3)); \
+ } while(0)
+
+#define WRITE_PIXEL( _x, _y, p ) \
+ do { \
+ GLushort * _p = (GLushort *) GET_DST_PTR(_x, _y); \
+ _p[0] = p; \
+ } while(0)
+
+#define READ_RGBA( rgba, _x, _y ) \
+ do { \
+ GLushort p = *(volatile GLshort *) GET_SRC_PTR(_x, _y); \
+ rgba[0] = ((p >> 8) & 0xf8) * 255 / 0xf8; \
+ rgba[1] = ((p >> 3) & 0xfc) * 255 / 0xfc; \
+ rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8; \
+ rgba[3] = 0xff; \
+ } while (0)
+
+#elif (SPANTMP_PIXEL_FMT == GL_BGRA) && (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
+
+#ifndef GET_SRC_PTR
+#define GET_SRC_PTR(_x, _y) (read_buf + (_x) * 4 + (_y) * pitch)
+#endif
+
+#ifndef GET_DST_PTR
+#define GET_DST_PTR(_x, _y) ( buf + (_x) * 4 + (_y) * pitch)
+#endif
+
+# define INIT_MONO_PIXEL(p, color) \
+ p = PACK_COLOR_8888(color[3], color[0], color[1], color[2])
+
+# define WRITE_RGBA(_x, _y, r, g, b, a) \
+ do { \
+ GLuint * _p = (GLuint *) GET_DST_PTR(_x, _y); \
+ _p[0] = ((r << 16) | (g << 8) | (b << 0) | (a << 24)); \
+ } while(0)
+
+#define WRITE_PIXEL(_x, _y, p) \
+ do { \
+ GLuint * _p = (GLuint *) GET_DST_PTR(_x, _y); \
+ _p[0] = p; \
+ } while(0)
+
+# if defined( USE_X86_ASM )
+# define READ_RGBA(rgba, _x, _y) \
+ do { \
+ GLuint p = *(volatile GLuint *) GET_SRC_PTR(_x, _y); \
+ __asm__ __volatile__( "bswap %0; rorl $8, %0" \
+ : "=r" (p) : "r" (p) ); \
+ ((GLuint *)rgba)[0] = p; \
+ } while (0)
+# elif defined( MESA_BIG_ENDIAN )
+ /* On PowerPC with GCC 3.4.2 the shift madness below becomes a single
+ * rotlwi instruction. It also produces good code on SPARC.
+ */
+# define READ_RGBA( rgba, _x, _y ) \
+ do { \
+ GLuint p = *(volatile GLuint *) GET_SRC_PTR(_x, _y); \
+ GLuint t = p; \
+ *((uint32_t *) rgba) = (t >> 24) | (p << 8); \
+ } while (0)
+# else
+# define READ_RGBA( rgba, _x, _y ) \
+ do { \
+ GLuint p = *(volatile GLuint *) GET_SRC_PTR(_x, _y); \
+ rgba[0] = (p >> 16) & 0xff; \
+ rgba[1] = (p >> 8) & 0xff; \
+ rgba[2] = (p >> 0) & 0xff; \
+ rgba[3] = (p >> 24) & 0xff; \
+ } while (0)
+# endif
+
+#else
+#error SPANTMP_PIXEL_FMT must be set to a valid value!
+#endif
+
+#if defined( USE_MMX_ASM ) || defined( USE_SSE_ASM )
+#include "x86/read_rgba_span_x86.h"
+#include "x86/common_x86_asm.h"
+#endif
+
+static void TAG(WriteRGBASpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *values, const GLubyte mask[] )
+{
+ HW_WRITE_LOCK()
+ {
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ GLint x1;
+ GLint n1;
+ LOCAL_VARS;
+
+ y = Y_FLIP(y);
+
+ HW_WRITE_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+
+ if (DBG) fprintf(stderr, "WriteRGBASpan %d..%d (x1 %d)\n",
+ (int)i, (int)n1, (int)x1);
+
+ if (mask)
+ {
+ for (;n1>0;i++,x1++,n1--)
+ if (mask[i])
+ WRITE_RGBA( x1, y,
+ rgba[i][0], rgba[i][1],
+ rgba[i][2], rgba[i][3] );
+ }
+ else
+ {
+ for (;n1>0;i++,x1++,n1--)
+ WRITE_RGBA( x1, y,
+ rgba[i][0], rgba[i][1],
+ rgba[i][2], rgba[i][3] );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_WRITE_UNLOCK();
+}
+
+static void TAG(WriteRGBSpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *values, const GLubyte mask[] )
+{
+ HW_WRITE_LOCK()
+ {
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ GLint x1;
+ GLint n1;
+ LOCAL_VARS;
+
+ y = Y_FLIP(y);
+
+ HW_WRITE_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+
+ if (DBG) fprintf(stderr, "WriteRGBSpan %d..%d (x1 %d)\n",
+ (int)i, (int)n1, (int)x1);
+
+ if (mask)
+ {
+ for (;n1>0;i++,x1++,n1--)
+ if (mask[i])
+ WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 255 );
+ }
+ else
+ {
+ for (;n1>0;i++,x1++,n1--)
+ WRITE_RGBA( x1, y, rgb[i][0], rgb[i][1], rgb[i][2], 255 );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_WRITE_UNLOCK();
+}
+
+static void TAG(WriteRGBAPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ const void *values, const GLubyte mask[] )
+{
+ HW_WRITE_LOCK()
+ {
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ GLint i;
+ LOCAL_VARS;
+
+ if (DBG) fprintf(stderr, "WriteRGBAPixels\n");
+
+ HW_WRITE_CLIPLOOP()
+ {
+ if (mask)
+ {
+ for (i=0;i<n;i++)
+ {
+ if (mask[i]) {
+ const int fy = Y_FLIP(y[i]);
+ if (CLIPPIXEL(x[i],fy))
+ WRITE_RGBA( x[i], fy,
+ rgba[i][0], rgba[i][1],
+ rgba[i][2], rgba[i][3] );
+ }
+ }
+ }
+ else
+ {
+ for (i=0;i<n;i++)
+ {
+ const int fy = Y_FLIP(y[i]);
+ if (CLIPPIXEL(x[i],fy))
+ WRITE_RGBA( x[i], fy,
+ rgba[i][0], rgba[i][1],
+ rgba[i][2], rgba[i][3] );
+ }
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_WRITE_UNLOCK();
+}
+
+
+static void TAG(WriteMonoRGBASpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *value, const GLubyte mask[] )
+{
+ HW_WRITE_LOCK()
+ {
+ const GLubyte *color = (const GLubyte *) value;
+ GLint x1;
+ GLint n1;
+ LOCAL_VARS;
+ INIT_MONO_PIXEL(p, color);
+
+ y = Y_FLIP( y );
+
+ if (DBG) fprintf(stderr, "WriteMonoRGBASpan\n");
+
+ HW_WRITE_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+ if (mask)
+ {
+ for (;n1>0;i++,x1++,n1--)
+ if (mask[i])
+ WRITE_PIXEL( x1, y, p );
+ }
+ else
+ {
+ for (;n1>0;i++,x1++,n1--)
+ WRITE_PIXEL( x1, y, p );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_WRITE_UNLOCK();
+}
+
+
+static void TAG(WriteMonoRGBAPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ const void *value,
+ const GLubyte mask[] )
+{
+ HW_WRITE_LOCK()
+ {
+ const GLubyte *color = (const GLubyte *) value;
+ GLint i;
+ LOCAL_VARS;
+ INIT_MONO_PIXEL(p, color);
+
+ if (DBG) fprintf(stderr, "WriteMonoRGBAPixels\n");
+
+ HW_WRITE_CLIPLOOP()
+ {
+ if (mask)
+ {
+ for (i=0;i<n;i++)
+ if (mask[i]) {
+ int fy = Y_FLIP(y[i]);
+ if (CLIPPIXEL( x[i], fy ))
+ WRITE_PIXEL( x[i], fy, p );
+ }
+ }
+ else
+ {
+ for (i=0;i<n;i++) {
+ int fy = Y_FLIP(y[i]);
+ if (CLIPPIXEL( x[i], fy ))
+ WRITE_PIXEL( x[i], fy, p );
+ }
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_WRITE_UNLOCK();
+}
+
+
+static void TAG(ReadRGBASpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, void *values)
+{
+ HW_READ_LOCK()
+ {
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
+ GLint x1,n1;
+ LOCAL_VARS;
+
+ y = Y_FLIP(y);
+
+ if (DBG) fprintf(stderr, "ReadRGBASpan\n");
+
+ HW_READ_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+ for (;n1>0;i++,x1++,n1--)
+ READ_RGBA( rgba[i], x1, y );
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_READ_UNLOCK();
+}
+
+
+#if defined(USE_MMX_ASM) && \
+ (((SPANTMP_PIXEL_FMT == GL_BGRA) && \
+ (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)) || \
+ ((SPANTMP_PIXEL_FMT == GL_RGB) && \
+ (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5)))
+static void TAG2(ReadRGBASpan,_MMX)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, void *values)
+{
+#ifndef USE_INNER_EMMS
+ /* The EMMS instruction is directly in-lined here because using GCC's
+ * built-in _mm_empty function was found to utterly destroy performance.
+ */
+ __asm__ __volatile__( "emms" );
+#endif
+
+ HW_READ_LOCK()
+ {
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
+ GLint x1,n1;
+ LOCAL_VARS;
+
+ y = Y_FLIP(y);
+
+ if (DBG) fprintf(stderr, "ReadRGBASpan\n");
+
+ HW_READ_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+
+ {
+ const char * src = GET_SRC_PTR( x1, y );
+#if (SPANTMP_PIXEL_FMT == GL_RGB) && \
+ (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5)
+ _generic_read_RGBA_span_RGB565_MMX( src, rgba[i], n1 );
+#else
+ _generic_read_RGBA_span_BGRA8888_REV_MMX( src, rgba[i], n1 );
+#endif
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_READ_UNLOCK();
+#ifndef USE_INNER_EMMS
+ __asm__ __volatile__( "emms" );
+#endif
+}
+#endif
+
+
+#if defined(USE_SSE_ASM) && \
+ (SPANTMP_PIXEL_FMT == GL_BGRA) && \
+ (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
+static void TAG2(ReadRGBASpan,_SSE2)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ void *values)
+{
+ HW_READ_LOCK()
+ {
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
+ GLint x1,n1;
+ LOCAL_VARS;
+
+ y = Y_FLIP(y);
+
+ if (DBG) fprintf(stderr, "ReadRGBASpan\n");
+
+ HW_READ_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+
+ {
+ const char * src = GET_SRC_PTR( x1, y );
+ _generic_read_RGBA_span_BGRA8888_REV_SSE2( src, rgba[i], n1 );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_READ_UNLOCK();
+}
+#endif
+
+#if defined(USE_SSE_ASM) && \
+ (SPANTMP_PIXEL_FMT == GL_BGRA) && \
+ (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
+static void TAG2(ReadRGBASpan,_SSE)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ void *values)
+{
+#ifndef USE_INNER_EMMS
+ /* The EMMS instruction is directly in-lined here because using GCC's
+ * built-in _mm_empty function was found to utterly destroy performance.
+ */
+ __asm__ __volatile__( "emms" );
+#endif
+
+ HW_READ_LOCK()
+ {
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
+ GLint x1,n1;
+ LOCAL_VARS;
+
+ y = Y_FLIP(y);
+
+ if (DBG) fprintf(stderr, "ReadRGBASpan\n");
+
+ HW_READ_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+
+ {
+ const char * src = GET_SRC_PTR( x1, y );
+ _generic_read_RGBA_span_BGRA8888_REV_SSE( src, rgba[i], n1 );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_READ_UNLOCK();
+#ifndef USE_INNER_EMMS
+ __asm__ __volatile__( "emms" );
+#endif
+}
+#endif
+
+
+static void TAG(ReadRGBAPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ void *values )
+{
+ HW_READ_LOCK()
+ {
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
+ GLubyte *mask = NULL; /* remove someday */
+ GLint i;
+ LOCAL_VARS;
+
+ if (DBG) fprintf(stderr, "ReadRGBAPixels\n");
+
+ HW_READ_CLIPLOOP()
+ {
+ if (mask)
+ {
+ for (i=0;i<n;i++)
+ if (mask[i]) {
+ int fy = Y_FLIP( y[i] );
+ if (CLIPPIXEL( x[i], fy ))
+ READ_RGBA( rgba[i], x[i], fy );
+ }
+ }
+ else
+ {
+ for (i=0;i<n;i++) {
+ int fy = Y_FLIP( y[i] );
+ if (CLIPPIXEL( x[i], fy ))
+ READ_RGBA( rgba[i], x[i], fy );
+ }
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_READ_UNLOCK();
+}
+
+static void TAG(InitPointers)(struct gl_renderbuffer *rb)
+{
+ rb->PutRow = TAG(WriteRGBASpan);
+ rb->PutRowRGB = TAG(WriteRGBSpan);
+ rb->PutMonoRow = TAG(WriteMonoRGBASpan);
+ rb->PutValues = TAG(WriteRGBAPixels);
+ rb->PutMonoValues = TAG(WriteMonoRGBAPixels);
+ rb->GetValues = TAG(ReadRGBAPixels);
+
+#if defined(USE_SSE_ASM) && \
+ (SPANTMP_PIXEL_FMT == GL_BGRA) && \
+ (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
+ if ( cpu_has_xmm2 ) {
+ if (DBG) fprintf( stderr, "Using %s version of GetRow\n", "SSE2" );
+ rb->GetRow = TAG2(ReadRGBASpan, _SSE2);
+ }
+ else
+#endif
+#if defined(USE_SSE_ASM) && \
+ (SPANTMP_PIXEL_FMT == GL_BGRA) && \
+ (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)
+ if ( cpu_has_xmm ) {
+ if (DBG) fprintf( stderr, "Using %s version of GetRow\n", "SSE" );
+ rb->GetRow = TAG2(ReadRGBASpan, _SSE);
+ }
+ else
+#endif
+#if defined(USE_MMX_ASM) && \
+ (((SPANTMP_PIXEL_FMT == GL_BGRA) && \
+ (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_INT_8_8_8_8_REV)) || \
+ ((SPANTMP_PIXEL_FMT == GL_RGB) && \
+ (SPANTMP_PIXEL_TYPE == GL_UNSIGNED_SHORT_5_6_5)))
+ if ( cpu_has_mmx ) {
+ if (DBG) fprintf( stderr, "Using %s version of GetRow\n", "MMX" );
+ rb->GetRow = TAG2(ReadRGBASpan, _MMX);
+ }
+ else
+#endif
+ {
+ if (DBG) fprintf( stderr, "Using %s version of GetRow\n", "C" );
+ rb->GetRow = TAG(ReadRGBASpan);
+ }
+
+}
+
+
+#undef INIT_MONO_PIXEL
+#undef WRITE_PIXEL
+#undef WRITE_RGBA
+#undef READ_RGBA
+#undef TAG
+#undef TAG2
+#undef GET_SRC_PTR
+#undef GET_DST_PTR
+#undef SPANTMP_PIXEL_FMT
+#undef SPANTMP_PIXEL_TYPE
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/spantmp_common.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/spantmp_common.h
new file mode 100644
index 000000000..a4509a569
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/spantmp_common.h
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file spantmp_common.h
+ *
+ * common macros for span read / write functions to be used in the depth,
+ * stencil and pixel span templates.
+ */
+
+#ifndef HW_WRITE_LOCK
+#define HW_WRITE_LOCK() HW_LOCK()
+#endif
+
+#ifndef HW_WRITE_UNLOCK
+#define HW_WRITE_UNLOCK() HW_UNLOCK()
+#endif
+
+#ifndef HW_READ_LOCK
+#define HW_READ_LOCK() HW_LOCK()
+#endif
+
+#ifndef HW_READ_UNLOCK
+#define HW_READ_UNLOCK() HW_UNLOCK()
+#endif
+
+#ifndef HW_CLIPLOOP
+#define HW_CLIPLOOP() \
+ do { \
+ 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;
+#endif
+
+#ifndef HW_ENDCLIPLOOP
+#define HW_ENDCLIPLOOP() \
+ } \
+ } while (0)
+#endif
+
+#ifndef CLIPPIXEL
+#define CLIPPIXEL( _x, _y ) \
+ ((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
+#endif
+
+#ifndef CLIPSPAN
+#define CLIPSPAN( _x, _y, _n, _x1, _n1, _i ) \
+ if ( _y < miny || _y >= maxy /*|| _x + n < minx || _x >=maxx*/ ) { \
+ _n1 = 0, _x1 = x; \
+ } else { \
+ _n1 = _n; \
+ _x1 = _x; \
+ if ( _x1 < minx ) _i += (minx-_x1), n1 -= (minx-_x1), _x1 = minx; \
+ if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx); \
+ }
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/stenciltmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/stenciltmp.h
new file mode 100644
index 000000000..dccab0660
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/stenciltmp.h
@@ -0,0 +1,182 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/common/stenciltmp.h,v 1.3 2001/03/21 16:14:20 dawes Exp $ */
+
+#include "spantmp_common.h"
+
+#ifndef DBG
+#define DBG 0
+#endif
+
+static void TAG(WriteStencilSpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *values, const GLubyte mask[] )
+{
+ HW_WRITE_LOCK()
+ {
+ const GLubyte *stencil = (const GLubyte *) values;
+ GLint x1;
+ GLint n1;
+ LOCAL_STENCIL_VARS;
+
+ y = Y_FLIP(y);
+
+ HW_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+
+ if (DBG) fprintf(stderr, "WriteStencilSpan %d..%d (x1 %d)\n",
+ (int)i, (int)n1, (int)x1);
+
+ if (mask)
+ {
+ for (;n1>0;i++,x1++,n1--)
+ if (mask[i])
+ WRITE_STENCIL( x1, y, stencil[i] );
+ }
+ else
+ {
+ for (;n1>0;i++,x1++,n1--)
+ WRITE_STENCIL( x1, y, stencil[i] );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_WRITE_UNLOCK();
+}
+
+
+static void TAG(WriteMonoStencilSpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *value,
+ const GLubyte mask[] )
+{
+ HW_WRITE_LOCK()
+ {
+ const GLubyte stencil = *((const GLubyte *) value);
+ GLint x1;
+ GLint n1;
+ LOCAL_STENCIL_VARS;
+
+ y = Y_FLIP(y);
+
+ HW_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+
+ if (DBG) fprintf(stderr, "WriteStencilSpan %d..%d (x1 %d)\n",
+ (int)i, (int)n1, (int)x1);
+
+ if (mask)
+ {
+ for (;n1>0;i++,x1++,n1--)
+ if (mask[i])
+ WRITE_STENCIL( x1, y, stencil );
+ }
+ else
+ {
+ for (;n1>0;i++,x1++,n1--)
+ WRITE_STENCIL( x1, y, stencil );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_WRITE_UNLOCK();
+}
+
+
+
+static void TAG(WriteStencilPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ const void *values, const GLubyte mask[] )
+{
+ HW_WRITE_LOCK()
+ {
+ const GLubyte *stencil = (const GLubyte *) values;
+ GLuint i;
+ LOCAL_STENCIL_VARS;
+
+ if (DBG) fprintf(stderr, "WriteStencilPixels\n");
+
+ HW_CLIPLOOP()
+ {
+ for (i=0;i<n;i++)
+ {
+ if (mask[i]) {
+ const int fy = Y_FLIP(y[i]);
+ if (CLIPPIXEL(x[i],fy))
+ WRITE_STENCIL( x[i], fy, stencil[i] );
+ }
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_WRITE_UNLOCK();
+}
+
+
+/* Read stencil spans and pixels
+ */
+static void TAG(ReadStencilSpan)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ void *values)
+{
+ HW_READ_LOCK()
+ {
+ GLubyte *stencil = (GLubyte *) values;
+ GLint x1,n1;
+ LOCAL_STENCIL_VARS;
+
+ y = Y_FLIP(y);
+
+ if (DBG) fprintf(stderr, "ReadStencilSpan\n");
+
+ HW_CLIPLOOP()
+ {
+ GLint i = 0;
+ CLIPSPAN(x,y,n,x1,n1,i);
+ for (;n1>0;i++,n1--)
+ READ_STENCIL( stencil[i], (x+i), y );
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_READ_UNLOCK();
+}
+
+static void TAG(ReadStencilPixels)( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ void *values )
+{
+ HW_READ_LOCK()
+ {
+ GLubyte *stencil = (GLubyte *) values;
+ GLuint i;
+ LOCAL_STENCIL_VARS;
+
+ if (DBG) fprintf(stderr, "ReadStencilPixels\n");
+
+ HW_CLIPLOOP()
+ {
+ for (i=0;i<n;i++) {
+ int fy = Y_FLIP( y[i] );
+ if (CLIPPIXEL( x[i], fy ))
+ READ_STENCIL( stencil[i], x[i], fy );
+ }
+ }
+ HW_ENDCLIPLOOP();
+ }
+ HW_READ_UNLOCK();
+}
+
+
+
+
+#undef WRITE_STENCIL
+#undef READ_STENCIL
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/texmem.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/texmem.c
new file mode 100644
index 000000000..acefce0f5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/texmem.c
@@ -0,0 +1,1339 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * (C) Copyright IBM Corporation 2002, 2003
+ * 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
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Ian Romanick <idr@us.ibm.com>
+ * Keith Whitwell <keithw@tungstengraphics.com>
+ * Kevin E. Martin <kem@users.sourceforge.net>
+ * Gareth Hughes <gareth@nvidia.com>
+ */
+/* $XFree86:$ */
+
+/** \file texmem.c
+ * Implements all of the device-independent texture memory management.
+ *
+ * Currently, only a simple LRU texture memory management policy is
+ * implemented. In the (hopefully very near) future, better policies will be
+ * implemented. The idea is that the DRI should be able to run in one of two
+ * modes. In the default mode the DRI will dynamically attempt to discover
+ * the best texture management policy for the running application. In the
+ * other mode, the user (via some sort of as yet TBD mechanism) will select
+ * a texture management policy that is known to work well with the
+ * application.
+ */
+
+#include "texmem.h"
+#include "simple_list.h"
+#include "imports.h"
+#include "macros.h"
+#include "texformat.h"
+
+#include <assert.h>
+
+
+
+static unsigned dummy_swap_counter;
+
+
+/**
+ * Calculate \f$\log_2\f$ of a value. This is a particularly poor
+ * implementation of this function. However, since system performance is in
+ * no way dependent on this function, the slowness of the implementation is
+ * irrelevent.
+ *
+ * \param n Value whose \f$\log_2\f$ is to be calculated
+ */
+
+static GLuint
+driLog2( GLuint n )
+{
+ GLuint log2;
+
+ for ( log2 = 1 ; n > 1 ; log2++ ) {
+ n >>= 1;
+ }
+
+ return log2;
+}
+
+
+
+
+/**
+ * Determine if a texture is resident in textureable memory. Depending on
+ * the driver, this may or may not be on-card memory. It could be AGP memory
+ * or anyother type of memory from which the hardware can directly read
+ * texels.
+ *
+ * This function is intended to be used as the \c IsTextureResident function
+ * in the device's \c dd_function_table.
+ *
+ * \param ctx GL context pointer (currently unused)
+ * \param texObj Texture object to be tested
+ */
+
+GLboolean
+driIsTextureResident( GLcontext * ctx,
+ struct gl_texture_object * texObj )
+{
+ driTextureObject * t;
+
+
+ t = (driTextureObject *) texObj->DriverData;
+ return( (t != NULL) && (t->memBlock != NULL) );
+}
+
+
+
+
+/**
+ * (Re)initialize the global circular LRU list. The last element
+ * in the array (\a heap->nrRegions) is the sentinal. Keeping it
+ * at the end of the array allows the other elements of the array
+ * to be addressed rationally when looking up objects at a particular
+ * location in texture memory.
+ *
+ * \param heap Texture heap to be reset
+ */
+
+static void resetGlobalLRU( driTexHeap * heap )
+{
+ drmTextureRegionPtr list = heap->global_regions;
+ unsigned sz = 1U << heap->logGranularity;
+ unsigned i;
+
+ for (i = 0 ; (i+1) * sz <= heap->size ; i++) {
+ list[i].prev = i-1;
+ list[i].next = i+1;
+ list[i].age = 0;
+ }
+
+ i--;
+ list[0].prev = heap->nrRegions;
+ list[i].prev = i-1;
+ list[i].next = heap->nrRegions;
+ list[heap->nrRegions].prev = i;
+ list[heap->nrRegions].next = 0;
+ heap->global_age[0] = 0;
+}
+
+/**
+ * Print out debugging information about the local texture LRU.
+ *
+ * \param heap Texture heap to be printed
+ * \param callername Name of calling function
+ */
+static void printLocalLRU( driTexHeap * heap, const char *callername )
+{
+ driTextureObject *t;
+ unsigned sz = 1U << heap->logGranularity;
+
+ fprintf( stderr, "%s in %s:\nLocal LRU, heap %d:\n",
+ __FUNCTION__, callername, heap->heapId );
+
+ foreach ( t, &heap->texture_objects ) {
+ if (!t->memBlock)
+ continue;
+ if (!t->tObj) {
+ fprintf( stderr, "Placeholder (%p) %d at 0x%x sz 0x%x\n",
+ (void *)t,
+ t->memBlock->ofs / sz,
+ t->memBlock->ofs,
+ t->memBlock->size );
+ } else {
+ fprintf( stderr, "Texture (%p) at 0x%x sz 0x%x\n",
+ (void *)t,
+ t->memBlock->ofs,
+ t->memBlock->size );
+ }
+ }
+ foreach ( t, heap->swapped_objects ) {
+ if (!t->tObj) {
+ fprintf( stderr, "Swapped Placeholder (%p)\n", (void *)t );
+ } else {
+ fprintf( stderr, "Swapped Texture (%p)\n", (void *)t );
+ }
+ }
+
+ fprintf( stderr, "\n" );
+}
+
+/**
+ * Print out debugging information about the global texture LRU.
+ *
+ * \param heap Texture heap to be printed
+ * \param callername Name of calling function
+ */
+static void printGlobalLRU( driTexHeap * heap, const char *callername )
+{
+ drmTextureRegionPtr list = heap->global_regions;
+ unsigned int i, j;
+
+ fprintf( stderr, "%s in %s:\nGlobal LRU, heap %d list %p:\n",
+ __FUNCTION__, callername, heap->heapId, (void *)list );
+
+ for ( i = 0, j = heap->nrRegions ; i < heap->nrRegions ; i++ ) {
+ fprintf( stderr, "list[%d] age %d next %d prev %d in_use %d\n",
+ j, list[j].age, list[j].next, list[j].prev, list[j].in_use );
+ j = list[j].next;
+ if ( j == heap->nrRegions ) break;
+ }
+
+ if ( j != heap->nrRegions ) {
+ fprintf( stderr, "Loop detected in global LRU\n" );
+ for ( i = 0 ; i < heap->nrRegions ; i++ ) {
+ fprintf( stderr, "list[%d] age %d next %d prev %d in_use %d\n",
+ i, list[i].age, list[i].next, list[i].prev, list[i].in_use );
+ }
+ }
+
+ fprintf( stderr, "\n" );
+}
+
+
+/**
+ * Called by the client whenever it touches a local texture.
+ *
+ * \param t Texture object that the client has accessed
+ */
+
+void driUpdateTextureLRU( driTextureObject * t )
+{
+ driTexHeap * heap;
+ drmTextureRegionPtr list;
+ unsigned shift;
+ unsigned start;
+ unsigned end;
+ unsigned i;
+
+
+ heap = t->heap;
+ if ( heap != NULL ) {
+ shift = heap->logGranularity;
+ start = t->memBlock->ofs >> shift;
+ end = (t->memBlock->ofs + t->memBlock->size - 1) >> shift;
+
+
+ heap->local_age = ++heap->global_age[0];
+ list = heap->global_regions;
+
+
+ /* Update the context's local LRU
+ */
+
+ move_to_head( & heap->texture_objects, t );
+
+
+ for (i = start ; i <= end ; i++) {
+ list[i].age = heap->local_age;
+
+ /* remove_from_list(i)
+ */
+ list[(unsigned)list[i].next].prev = list[i].prev;
+ list[(unsigned)list[i].prev].next = list[i].next;
+
+ /* insert_at_head(list, i)
+ */
+ list[i].prev = heap->nrRegions;
+ list[i].next = list[heap->nrRegions].next;
+ list[(unsigned)list[heap->nrRegions].next].prev = i;
+ list[heap->nrRegions].next = i;
+ }
+
+ if ( 0 ) {
+ printGlobalLRU( heap, __FUNCTION__ );
+ printLocalLRU( heap, __FUNCTION__ );
+ }
+ }
+}
+
+
+
+
+/**
+ * Keep track of swapped out texture objects.
+ *
+ * \param t Texture object to be "swapped" out of its texture heap
+ */
+
+void driSwapOutTextureObject( driTextureObject * t )
+{
+ unsigned face;
+
+
+ if ( t->memBlock != NULL ) {
+ assert( t->heap != NULL );
+ mmFreeMem( t->memBlock );
+ t->memBlock = NULL;
+
+ if (t->timestamp > t->heap->timestamp)
+ t->heap->timestamp = t->timestamp;
+
+ t->heap->texture_swaps[0]++;
+ move_to_tail( t->heap->swapped_objects, t );
+ t->heap = NULL;
+ }
+ else {
+ assert( t->heap == NULL );
+ }
+
+
+ for ( face = 0 ; face < 6 ; face++ ) {
+ t->dirty_images[face] = ~0;
+ }
+}
+
+
+
+
+/**
+ * Destroy hardware state associated with texture \a t. Calls the
+ * \a destroy_texture_object method associated with the heap from which
+ * \a t was allocated.
+ *
+ * \param t Texture object to be destroyed
+ */
+
+void driDestroyTextureObject( driTextureObject * t )
+{
+ driTexHeap * heap;
+
+
+ if ( 0 ) {
+ fprintf( stderr, "[%s:%d] freeing %p (tObj = %p, DriverData = %p)\n",
+ __FILE__, __LINE__,
+ (void *)t,
+ (void *)((t != NULL) ? t->tObj : NULL),
+ (void *)((t != NULL && t->tObj != NULL) ? t->tObj->DriverData : NULL ));
+ }
+
+ if ( t != NULL ) {
+ if ( t->memBlock ) {
+ heap = t->heap;
+ assert( heap != NULL );
+
+ heap->texture_swaps[0]++;
+
+ mmFreeMem( t->memBlock );
+ t->memBlock = NULL;
+
+ if (t->timestamp > t->heap->timestamp)
+ t->heap->timestamp = t->timestamp;
+
+ heap->destroy_texture_object( heap->driverContext, t );
+ t->heap = NULL;
+ }
+
+ if ( t->tObj != NULL ) {
+ assert( t->tObj->DriverData == t );
+ t->tObj->DriverData = NULL;
+ }
+
+ remove_from_list( t );
+ FREE( t );
+ }
+
+ if ( 0 ) {
+ fprintf( stderr, "[%s:%d] done freeing %p\n", __FILE__, __LINE__, (void *)t );
+ }
+}
+
+
+
+
+/**
+ * Update the local heap's representation of texture memory based on
+ * data in the SAREA. This is done each time it is detected that some other
+ * direct rendering client has 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 \a tObj being \a NULL.
+ *
+ * \param heap Heap whose state is to be updated
+ * \param offset Byte offset in the heap that has been stolen
+ * \param size Size, in bytes, of the stolen block
+ * \param in_use Non-zero if the block is pinned/reserved by the kernel
+ */
+
+static void driTexturesGone( driTexHeap * heap, int offset, int size,
+ int in_use )
+{
+ driTextureObject * t;
+ driTextureObject * tmp;
+
+
+ foreach_s ( t, tmp, & heap->texture_objects ) {
+ if ( (t->memBlock->ofs < (offset + size))
+ && ((t->memBlock->ofs + t->memBlock->size) > offset) ) {
+ /* It overlaps - kick it out. If the texture object is just a
+ * place holder, then destroy it all together. Otherwise, mark
+ * it as being swapped out.
+ */
+
+ if ( t->tObj != NULL ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ driDestroyTextureObject( t );
+ }
+ }
+ }
+
+
+ {
+ t = (driTextureObject *) CALLOC( heap->texture_object_size );
+ if ( t == NULL ) return;
+
+ t->memBlock = mmAllocMem( heap->memory_heap, size, 0, offset );
+ if ( t->memBlock == NULL ) {
+ fprintf( stderr, "Couldn't alloc placeholder: heap %u sz %x ofs %x\n", heap->heapId,
+ (int)size, (int)offset );
+ mmDumpMemInfo( heap->memory_heap );
+ return;
+ }
+ t->heap = heap;
+ if (in_use)
+ t->bound = 99;
+ insert_at_head( & heap->texture_objects, t );
+ }
+}
+
+
+
+
+/**
+ * Called by the client on lock contention to determine whether textures have
+ * been stolen. If another client has modified a region in which we have
+ * textures, then we need to figure out which of our textures have been
+ * removed and update our global LRU.
+ *
+ * \param heap Texture heap to be updated
+ */
+
+void driAgeTextures( driTexHeap * heap )
+{
+ drmTextureRegionPtr list = heap->global_regions;
+ unsigned sz = 1U << (heap->logGranularity);
+ unsigned i, nr = 0;
+
+
+ /* Have to go right round from the back to ensure stuff ends up
+ * LRU in the local list... Fix with a cursor pointer.
+ */
+
+ for (i = list[heap->nrRegions].prev ;
+ i != heap->nrRegions && nr < heap->nrRegions ;
+ i = list[i].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 ( (i * sz) > heap->size ) {
+ nr = heap->nrRegions;
+ break;
+ }
+
+ if (list[i].age > heap->local_age)
+ driTexturesGone( heap, i * sz, sz, list[i].in_use);
+ }
+
+ /* Loop or uninitialized heap detected. Reset.
+ */
+
+ if (nr == heap->nrRegions) {
+ driTexturesGone( heap, 0, heap->size, 0);
+ resetGlobalLRU( heap );
+ }
+
+ if ( 0 ) {
+ printGlobalLRU( heap, __FUNCTION__ );
+ printLocalLRU( heap, __FUNCTION__ );
+ }
+
+ heap->local_age = heap->global_age[0];
+}
+
+
+
+
+#define INDEX_ARRAY_SIZE 6 /* I'm not aware of driver with more than 2 heaps */
+
+/**
+ * Allocate memory from a texture heap to hold a texture object. This
+ * routine will attempt to allocate memory for the texture from the heaps
+ * specified by \c heap_array in order. That is, first it will try to
+ * allocate from \c heap_array[0], then \c heap_array[1], and so on.
+ *
+ * \param heap_array Array of pointers to texture heaps to use
+ * \param nr_heaps Number of heap pointer in \a heap_array
+ * \param t Texture object for which space is needed
+ * \return The ID of the heap from which memory was allocated, or -1 if
+ * memory could not be allocated.
+ *
+ * \bug The replacement policy implemented by this function is horrible.
+ */
+
+
+int
+driAllocateTexture( driTexHeap * const * heap_array, unsigned nr_heaps,
+ driTextureObject * t )
+{
+ driTexHeap * heap;
+ driTextureObject * temp;
+ driTextureObject * cursor;
+ unsigned id;
+
+
+ /* In case it already has texture space, initialize heap. This also
+ * prevents GCC from issuing a warning that heap might be used
+ * uninitialized.
+ */
+
+ heap = t->heap;
+
+
+ /* Run through each of the existing heaps and try to allocate a buffer
+ * to hold the texture.
+ */
+
+ for ( id = 0 ; (t->memBlock == NULL) && (id < nr_heaps) ; id++ ) {
+ heap = heap_array[ id ];
+ if ( heap != NULL ) {
+ t->memBlock = mmAllocMem( heap->memory_heap, t->totalSize,
+ heap->alignmentShift, 0 );
+ }
+ }
+
+
+ /* Kick textures out until the requested texture fits.
+ */
+
+ if ( t->memBlock == NULL ) {
+ unsigned index[INDEX_ARRAY_SIZE];
+ unsigned nrGoodHeaps = 0;
+
+ /* Trying to avoid dynamic memory allocation. If you have more
+ * heaps, increase INDEX_ARRAY_SIZE. I'm not aware of any
+ * drivers with more than 2 tex heaps. */
+ assert( nr_heaps < INDEX_ARRAY_SIZE );
+
+ /* Sort large enough heaps by duty. Insertion sort should be
+ * fast enough for such a short array. */
+ for ( id = 0 ; id < nr_heaps ; id++ ) {
+ heap = heap_array[ id ];
+
+ if ( heap != NULL && t->totalSize <= heap->size ) {
+ unsigned j;
+
+ for ( j = 0 ; j < nrGoodHeaps; j++ ) {
+ if ( heap->duty > heap_array[ index[ j ] ]->duty )
+ break;
+ }
+
+ if ( j < nrGoodHeaps ) {
+ memmove( &index[ j+1 ], &index[ j ],
+ sizeof(index[ 0 ]) * (nrGoodHeaps - j) );
+ }
+
+ index[ j ] = id;
+
+ nrGoodHeaps++;
+ }
+ }
+
+ for ( id = 0 ; (t->memBlock == NULL) && (id < nrGoodHeaps) ; id++ ) {
+ heap = heap_array[ index[ id ] ];
+
+ for ( cursor = heap->texture_objects.prev, temp = cursor->prev;
+ cursor != &heap->texture_objects ;
+ cursor = temp, temp = cursor->prev ) {
+
+ /* The the LRU element. If the texture is bound to one of
+ * the texture units, then we cannot kick it out.
+ */
+ if ( cursor->bound /* || cursor->reserved */ ) {
+ continue;
+ }
+
+ if ( cursor->memBlock )
+ heap->duty -= cursor->memBlock->size;
+
+ /* If this is a placeholder, there's no need to keep it */
+ if (cursor->tObj)
+ driSwapOutTextureObject( cursor );
+ else
+ driDestroyTextureObject( cursor );
+
+ t->memBlock = mmAllocMem( heap->memory_heap, t->totalSize,
+ heap->alignmentShift, 0 );
+
+ if (t->memBlock)
+ break;
+ }
+ }
+
+ /* Rebalance duties. If a heap kicked more data than its duty,
+ * then all other heaps get that amount multiplied with their
+ * relative weight added to their duty. The negative duty is
+ * reset to 0. In the end all heaps have a duty >= 0.
+ *
+ * CAUTION: we must not change the heap pointer here, because it
+ * is used below to update the texture object.
+ */
+ for ( id = 0 ; id < nr_heaps ; id++ )
+ if ( heap_array[ id ] != NULL && heap_array[ id ]->duty < 0) {
+ int duty = -heap_array[ id ]->duty;
+ double weight = heap_array[ id ]->weight;
+ unsigned j;
+
+ for ( j = 0 ; j < nr_heaps ; j++ )
+ if ( j != id && heap_array[ j ] != NULL ) {
+ heap_array[ j ]->duty += (double) duty *
+ heap_array[ j ]->weight / weight;
+ }
+
+ heap_array[ id ]->duty = 0;
+ }
+ }
+
+
+ if ( t->memBlock != NULL ) {
+ /* id and heap->heapId may or may not be the same value here.
+ */
+
+ assert( heap != NULL );
+ assert( (t->heap == NULL) || (t->heap == heap) );
+
+ t->heap = heap;
+ return heap->heapId;
+ }
+ else {
+ assert( t->heap == NULL );
+
+ fprintf( stderr, "[%s:%d] unable to allocate texture\n",
+ __FUNCTION__, __LINE__ );
+ return -1;
+ }
+}
+
+
+
+
+
+
+/**
+ * Set the location where the texture-swap counter is stored.
+ */
+
+void
+driSetTextureSwapCounterLocation( driTexHeap * heap, unsigned * counter )
+{
+ heap->texture_swaps = (counter == NULL) ? & dummy_swap_counter : counter;
+}
+
+
+
+
+/**
+ * Create a new heap for texture data.
+ *
+ * \param heap_id Device-dependent heap identifier. This value
+ * will returned by driAllocateTexture when memory
+ * is allocated from this heap.
+ * \param context Device-dependent driver context. This is
+ * supplied as the first parameter to the
+ * \c destroy_tex_obj function.
+ * \param size Size, in bytes, of the texture region
+ * \param alignmentShift Alignment requirement for textures. If textures
+ * must be allocated on a 4096 byte boundry, this
+ * would be 12.
+ * \param nr_regions Number of regions into which this texture space
+ * should be partitioned
+ * \param global_regions Array of \c drmTextureRegion structures in the SAREA
+ * \param global_age Pointer to the global texture age in the SAREA
+ * \param swapped_objects Pointer to the list of texture objects that are
+ * not in texture memory (i.e., have been swapped
+ * out).
+ * \param texture_object_size Size, in bytes, of a device-dependent texture
+ * object
+ * \param destroy_tex_obj Function used to destroy a device-dependent
+ * texture object
+ *
+ * \sa driDestroyTextureHeap
+ */
+
+driTexHeap *
+driCreateTextureHeap( unsigned heap_id, void * context, unsigned size,
+ unsigned alignmentShift, unsigned nr_regions,
+ drmTextureRegionPtr global_regions, unsigned * global_age,
+ driTextureObject * swapped_objects,
+ unsigned texture_object_size,
+ destroy_texture_object_t * destroy_tex_obj
+ )
+{
+ driTexHeap * heap;
+ unsigned l;
+
+
+ if ( 0 )
+ fprintf( stderr, "%s( %u, %p, %u, %u, %u )\n",
+ __FUNCTION__,
+ heap_id, (void *)context, size, alignmentShift, nr_regions );
+
+ heap = (driTexHeap *) CALLOC( sizeof( driTexHeap ) );
+ if ( heap != NULL ) {
+ l = driLog2( (size - 1) / nr_regions );
+ if ( l < alignmentShift )
+ {
+ l = alignmentShift;
+ }
+
+ heap->logGranularity = l;
+ heap->size = size & ~((1L << l) - 1);
+
+ heap->memory_heap = mmInit( 0, heap->size );
+ if ( heap->memory_heap != NULL ) {
+ heap->heapId = heap_id;
+ heap->driverContext = context;
+
+ heap->alignmentShift = alignmentShift;
+ heap->nrRegions = nr_regions;
+ heap->global_regions = global_regions;
+ heap->global_age = global_age;
+ heap->swapped_objects = swapped_objects;
+ heap->texture_object_size = texture_object_size;
+ heap->destroy_texture_object = destroy_tex_obj;
+
+ /* Force global heap init */
+ if (heap->global_age[0] == 0)
+ heap->local_age = ~0;
+ else
+ heap->local_age = 0;
+
+ make_empty_list( & heap->texture_objects );
+ driSetTextureSwapCounterLocation( heap, NULL );
+
+ heap->weight = heap->size;
+ heap->duty = 0;
+ }
+ else {
+ FREE( heap );
+ heap = NULL;
+ }
+ }
+
+
+ if ( 0 )
+ fprintf( stderr, "%s returning %p\n", __FUNCTION__, (void *)heap );
+
+ return heap;
+}
+
+
+
+
+/** Destroys a texture heap
+ *
+ * \param heap Texture heap to be destroyed
+ */
+
+void
+driDestroyTextureHeap( driTexHeap * heap )
+{
+ driTextureObject * t;
+ driTextureObject * temp;
+
+
+ if ( heap != NULL ) {
+ foreach_s( t, temp, & heap->texture_objects ) {
+ driDestroyTextureObject( t );
+ }
+ foreach_s( t, temp, heap->swapped_objects ) {
+ driDestroyTextureObject( t );
+ }
+
+ mmDestroy( heap->memory_heap );
+ FREE( heap );
+ }
+}
+
+
+
+
+/****************************************************************************/
+/**
+ * Determine how many texels (including all mipmap levels) would be required
+ * for a texture map of size \f$2^^\c base_size_log2\f$ would require.
+ *
+ * \param base_size_log2 \f$log_2\f$ of the size of a side of the texture
+ * \param dimensions Number of dimensions of the texture. Either 2 or 3.
+ * \param faces Number of faces of the texture. Either 1 or 6 (for cube maps).
+ * \return Number of texels
+ */
+
+static unsigned
+texels_this_map_size( int base_size_log2, unsigned dimensions, unsigned faces )
+{
+ unsigned texels;
+
+
+ assert( (faces == 1) || (faces == 6) );
+ assert( (dimensions == 2) || (dimensions == 3) );
+
+ texels = 0;
+ if ( base_size_log2 >= 0 ) {
+ texels = (1U << (dimensions * base_size_log2));
+
+ /* See http://www.mail-archive.com/dri-devel@lists.sourceforge.net/msg03636.html
+ * for the complete explaination of why this formulation is used.
+ * Basically, the smaller mipmap levels sum to 0.333 the size of the
+ * level 0 map. The total size is therefore the size of the map
+ * multipled by 1.333. The +2 is there to round up.
+ */
+
+ texels = (texels * 4 * faces + 2) / 3;
+ }
+
+ return texels;
+}
+
+
+
+
+struct maps_per_heap {
+ unsigned c[32];
+};
+
+static void
+fill_in_maximums( driTexHeap * const * heaps, unsigned nr_heaps,
+ unsigned max_bytes_per_texel, unsigned max_size,
+ unsigned mipmaps_at_once, unsigned dimensions,
+ unsigned faces, struct maps_per_heap * max_textures )
+{
+ unsigned heap;
+ unsigned log2_size;
+ unsigned mask;
+
+
+ /* Determine how many textures of each size can be stored in each
+ * texture heap.
+ */
+
+ for ( heap = 0 ; heap < nr_heaps ; heap++ ) {
+ if ( heaps[ heap ] == NULL ) {
+ (void) memset( max_textures[ heap ].c, 0,
+ sizeof( max_textures[ heap ].c ) );
+ continue;
+ }
+
+ mask = (1U << heaps[ heap ]->logGranularity) - 1;
+
+ if ( 0 ) {
+ fprintf( stderr, "[%s:%d] heap[%u] = %u bytes, mask = 0x%08x\n",
+ __FILE__, __LINE__,
+ heap, heaps[ heap ]->size, mask );
+ }
+
+ for ( log2_size = max_size ; log2_size > 0 ; log2_size-- ) {
+ unsigned total;
+
+
+ /* Determine the total number of bytes required by a texture of
+ * size log2_size.
+ */
+
+ total = texels_this_map_size( log2_size, dimensions, faces )
+ - texels_this_map_size( log2_size - mipmaps_at_once,
+ dimensions, faces );
+ total *= max_bytes_per_texel;
+ total = (total + mask) & ~mask;
+
+ /* The number of textures of a given size that will fit in a heap
+ * is equal to the size of the heap divided by the size of the
+ * texture.
+ */
+
+ max_textures[ heap ].c[ log2_size ] = heaps[ heap ]->size / total;
+
+ if ( 0 ) {
+ fprintf( stderr, "[%s:%d] max_textures[%u].c[%02u] "
+ "= 0x%08x / 0x%08x "
+ "= %u (%u)\n",
+ __FILE__, __LINE__,
+ heap, log2_size,
+ heaps[ heap ]->size, total,
+ heaps[ heap ]->size / total,
+ max_textures[ heap ].c[ log2_size ] );
+ }
+ }
+ }
+}
+
+
+static unsigned
+get_max_size( unsigned nr_heaps,
+ unsigned texture_units,
+ unsigned max_size,
+ int all_textures_one_heap,
+ struct maps_per_heap * max_textures )
+{
+ unsigned heap;
+ unsigned log2_size;
+
+
+ /* Determine the largest texture size such that a texture of that size
+ * can be bound to each texture unit at the same time. Some hardware
+ * may require that all textures be in the same texture heap for
+ * multitexturing.
+ */
+
+ for ( log2_size = max_size ; log2_size > 0 ; log2_size-- ) {
+ unsigned total = 0;
+
+ for ( heap = 0 ; heap < nr_heaps ; heap++ )
+ {
+ total += max_textures[ heap ].c[ log2_size ];
+
+ if ( 0 ) {
+ fprintf( stderr, "[%s:%d] max_textures[%u].c[%02u] = %u, "
+ "total = %u\n", __FILE__, __LINE__, heap, log2_size,
+ max_textures[ heap ].c[ log2_size ], total );
+ }
+
+ if ( (max_textures[ heap ].c[ log2_size ] >= texture_units)
+ || (!all_textures_one_heap && (total >= texture_units)) ) {
+ /* The number of mipmap levels is the log-base-2 of the
+ * maximum texture size plus 1. If the maximum texture size
+ * is 1x1, the log-base-2 is 0 and 1 mipmap level (the base
+ * level) is available.
+ */
+
+ return log2_size + 1;
+ }
+ }
+ }
+
+ /* This should NEVER happen. It should always be possible to have at
+ * *least* a 1x1 texture in memory!
+ */
+ assert( log2_size != 0 );
+ return 0;
+}
+
+#define SET_MAX(f,v) \
+ do { if ( max_sizes[v] != 0 ) { limits-> f = max_sizes[v]; } } while( 0 )
+
+#define SET_MAX_RECT(f,v) \
+ do { if ( max_sizes[v] != 0 ) { limits-> f = 1 << max_sizes[v]; } } while( 0 )
+
+
+/**
+ * Given the amount of texture memory, the number of texture units, and the
+ * maximum size of a texel, calculate the maximum texture size the driver can
+ * advertise.
+ *
+ * \param heaps Texture heaps for this card
+ * \param nr_heap Number of texture heaps
+ * \param limits OpenGL contants. MaxTextureUnits must be set.
+ * \param max_bytes_per_texel Maximum size of a single texel, in bytes
+ * \param max_2D_size \f$\log_2\f$ of the maximum 2D texture size (i.e.,
+ * 1024x1024 textures, this would be 10)
+ * \param max_3D_size \f$\log_2\f$ of the maximum 3D texture size (i.e.,
+ * 1024x1024x1024 textures, this would be 10)
+ * \param max_cube_size \f$\log_2\f$ of the maximum cube texture size (i.e.,
+ * 1024x1024 textures, this would be 10)
+ * \param max_rect_size \f$\log_2\f$ of the maximum texture rectangle size
+ * (i.e., 1024x1024 textures, this would be 10). This is a power-of-2
+ * even though texture rectangles need not be a power-of-2.
+ * \param mipmaps_at_once Total number of mipmaps that can be used
+ * at one time. For most hardware this will be \f$\c max_size + 1\f$.
+ * For hardware that does not support mipmapping, this will be 1.
+ * \param all_textures_one_heap True if the hardware requires that all
+ * textures be in a single texture heap for multitexturing.
+ */
+
+void
+driCalculateMaxTextureLevels( driTexHeap * const * heaps,
+ unsigned nr_heaps,
+ struct gl_constants * limits,
+ unsigned max_bytes_per_texel,
+ unsigned max_2D_size,
+ unsigned max_3D_size,
+ unsigned max_cube_size,
+ unsigned max_rect_size,
+ unsigned mipmaps_at_once,
+ int all_textures_one_heap )
+{
+ struct maps_per_heap max_textures[8];
+ unsigned i;
+ const unsigned dimensions[4] = { 2, 3, 2, 2 };
+ const unsigned faces[4] = { 1, 1, 6, 1 };
+ unsigned max_sizes[4];
+ unsigned mipmaps[4];
+
+
+ max_sizes[0] = max_2D_size;
+ max_sizes[1] = max_3D_size;
+ max_sizes[2] = max_cube_size;
+ max_sizes[3] = max_rect_size;
+
+ mipmaps[0] = mipmaps_at_once;
+ mipmaps[1] = mipmaps_at_once;
+ mipmaps[2] = 1;
+ mipmaps[3] = mipmaps_at_once;
+
+
+ /* Calculate the maximum number of texture levels in two passes. The
+ * first pass determines how many textures of each power-of-two size
+ * (including all mipmap levels for that size) can fit in each texture
+ * heap. The second pass finds the largest texture size that allows
+ * a texture of that size to be bound to every texture unit.
+ */
+
+ for ( i = 0 ; i < 4 ; i++ ) {
+ if ( max_sizes[ i ] != 0 ) {
+ fill_in_maximums( heaps, nr_heaps, max_bytes_per_texel,
+ max_sizes[ i ], mipmaps[ i ],
+ dimensions[ i ], faces[ i ],
+ max_textures );
+
+ max_sizes[ i ] = get_max_size( nr_heaps,
+ limits->MaxTextureUnits,
+ max_sizes[ i ],
+ all_textures_one_heap,
+ max_textures );
+ }
+ }
+
+ SET_MAX( MaxTextureLevels, 0 );
+ SET_MAX( Max3DTextureLevels, 1 );
+ SET_MAX( MaxCubeTextureLevels, 2 );
+ SET_MAX_RECT( MaxTextureRectSize, 3 );
+}
+
+
+
+
+/**
+ * Perform initial binding of default textures objects on a per unit, per
+ * texture target basis.
+ *
+ * \param ctx Current OpenGL context
+ * \param swapped List of swapped-out textures
+ * \param targets Bit-mask of value texture targets
+ */
+
+void driInitTextureObjects( GLcontext *ctx, driTextureObject * swapped,
+ GLuint targets )
+{
+ struct gl_texture_object *texObj;
+ GLuint tmp = ctx->Texture.CurrentUnit;
+ unsigned i;
+
+
+ for ( i = 0 ; i < ctx->Const.MaxTextureUnits ; i++ ) {
+ ctx->Texture.CurrentUnit = i;
+
+ if ( (targets & DRI_TEXMGR_DO_TEXTURE_1D) != 0 ) {
+ texObj = ctx->Texture.Unit[i].Current1D;
+ ctx->Driver.BindTexture( ctx, GL_TEXTURE_1D, texObj );
+ move_to_tail( swapped, (driTextureObject *) texObj->DriverData );
+ }
+
+ if ( (targets & DRI_TEXMGR_DO_TEXTURE_2D) != 0 ) {
+ texObj = ctx->Texture.Unit[i].Current2D;
+ ctx->Driver.BindTexture( ctx, GL_TEXTURE_2D, texObj );
+ move_to_tail( swapped, (driTextureObject *) texObj->DriverData );
+ }
+
+ if ( (targets & DRI_TEXMGR_DO_TEXTURE_3D) != 0 ) {
+ texObj = ctx->Texture.Unit[i].Current3D;
+ ctx->Driver.BindTexture( ctx, GL_TEXTURE_3D, texObj );
+ move_to_tail( swapped, (driTextureObject *) texObj->DriverData );
+ }
+
+ if ( (targets & DRI_TEXMGR_DO_TEXTURE_CUBE) != 0 ) {
+ texObj = ctx->Texture.Unit[i].CurrentCubeMap;
+ ctx->Driver.BindTexture( ctx, GL_TEXTURE_CUBE_MAP_ARB, texObj );
+ move_to_tail( swapped, (driTextureObject *) texObj->DriverData );
+ }
+
+ if ( (targets & DRI_TEXMGR_DO_TEXTURE_RECT) != 0 ) {
+ texObj = ctx->Texture.Unit[i].CurrentRect;
+ ctx->Driver.BindTexture( ctx, GL_TEXTURE_RECTANGLE_NV, texObj );
+ move_to_tail( swapped, (driTextureObject *) texObj->DriverData );
+ }
+ }
+
+ ctx->Texture.CurrentUnit = tmp;
+}
+
+
+
+
+/**
+ * Verify that the specified texture is in the specificed heap.
+ *
+ * \param tex Texture to be tested.
+ * \param heap Texture memory heap to be tested.
+ * \return True if the texture is in the heap, false otherwise.
+ */
+
+static GLboolean
+check_in_heap( const driTextureObject * tex, const driTexHeap * heap )
+{
+#if 1
+ return tex->heap == heap;
+#else
+ driTextureObject * curr;
+
+ foreach( curr, & heap->texture_objects ) {
+ if ( curr == tex ) {
+ break;
+ }
+ }
+
+ return curr == tex;
+#endif
+}
+
+
+
+/****************************************************************************/
+/**
+ * Validate the consistency of a set of texture heaps.
+ * Original version by Keith Whitwell in r200/r200_sanity.c.
+ */
+
+GLboolean
+driValidateTextureHeaps( driTexHeap * const * texture_heaps,
+ unsigned nr_heaps, const driTextureObject * swapped )
+{
+ driTextureObject *t;
+ unsigned i;
+
+ for ( i = 0 ; i < nr_heaps ; i++ ) {
+ int last_end = 0;
+ unsigned textures_in_heap = 0;
+ unsigned blocks_in_mempool = 0;
+ const driTexHeap * heap = texture_heaps[i];
+ const memHeap_t * p = heap->memory_heap;
+
+ /* Check each texture object has a MemBlock, and is linked into
+ * the correct heap.
+ *
+ * Check the texobj base address corresponds to the MemBlock
+ * range. Check the texobj size (recalculate?) fits within
+ * the MemBlock.
+ *
+ * Count the number of texobj's using this heap.
+ */
+
+ foreach ( t, &heap->texture_objects ) {
+ if ( !check_in_heap( t, heap ) ) {
+ fprintf( stderr, "%s memory block for texture object @ %p not "
+ "found in heap #%d\n",
+ __FUNCTION__, (void *)t, i );
+ return GL_FALSE;
+ }
+
+
+ if ( t->totalSize > t->memBlock->size ) {
+ fprintf( stderr, "%s: Memory block for texture object @ %p is "
+ "only %u bytes, but %u are required\n",
+ __FUNCTION__, (void *)t, t->totalSize, t->memBlock->size );
+ return GL_FALSE;
+ }
+
+ textures_in_heap++;
+ }
+
+ /* Validate the contents of the heap:
+ * - Ordering
+ * - Overlaps
+ * - Bounds
+ */
+
+ while ( p != NULL ) {
+ if (p->reserved) {
+ fprintf( stderr, "%s: Block (%08x,%x), is reserved?!\n",
+ __FUNCTION__, p->ofs, p->size );
+ return GL_FALSE;
+ }
+
+ if (p->ofs != last_end) {
+ fprintf( stderr, "%s: blocks_in_mempool = %d, last_end = %d, p->ofs = %d\n",
+ __FUNCTION__, blocks_in_mempool, last_end, p->ofs );
+ return GL_FALSE;
+ }
+
+ if (!p->reserved && !p->free) {
+ blocks_in_mempool++;
+ }
+
+ last_end = p->ofs + p->size;
+ p = p->next;
+ }
+
+ if (textures_in_heap != blocks_in_mempool) {
+ fprintf( stderr, "%s: Different number of textures objects (%u) and "
+ "inuse memory blocks (%u)\n",
+ __FUNCTION__, textures_in_heap, blocks_in_mempool );
+ return GL_FALSE;
+ }
+
+#if 0
+ fprintf( stderr, "%s: textures_in_heap = %u\n",
+ __FUNCTION__, textures_in_heap );
+#endif
+ }
+
+
+ /* Check swapped texobj's have zero memblocks
+ */
+ i = 0;
+ foreach ( t, swapped ) {
+ if ( t->memBlock != NULL ) {
+ fprintf( stderr, "%s: Swapped texobj %p has non-NULL memblock %p\n",
+ __FUNCTION__, (void *)t, (void *)t->memBlock );
+ return GL_FALSE;
+ }
+ i++;
+ }
+
+#if 0
+ fprintf( stderr, "%s: swapped texture count = %u\n", __FUNCTION__, i );
+#endif
+
+ return GL_TRUE;
+}
+
+
+
+
+/****************************************************************************/
+/**
+ * Compute which mipmap levels that really need to be sent to the hardware.
+ * This depends on the base image size, GL_TEXTURE_MIN_LOD,
+ * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
+ */
+
+void
+driCalculateTextureFirstLastLevel( driTextureObject * t )
+{
+ struct gl_texture_object * const tObj = t->tObj;
+ const struct gl_texture_image * const baseImage =
+ tObj->Image[0][tObj->BaseLevel];
+
+ /* These must be signed values. MinLod and MaxLod can be negative numbers,
+ * and having firstLevel and lastLevel as signed prevents the need for
+ * extra sign checks.
+ */
+ int firstLevel;
+ int lastLevel;
+
+ /* Yes, this looks overly complicated, but it's all needed.
+ */
+
+ switch (tObj->Target) {
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_CUBE_MAP:
+ if (tObj->MinFilter == GL_NEAREST || tObj->MinFilter == GL_LINEAR) {
+ /* GL_NEAREST and GL_LINEAR only care about GL_TEXTURE_BASE_LEVEL.
+ */
+
+ firstLevel = lastLevel = tObj->BaseLevel;
+ }
+ else {
+ firstLevel = tObj->BaseLevel + (GLint)(tObj->MinLod + 0.5);
+ firstLevel = MAX2(firstLevel, tObj->BaseLevel);
+ lastLevel = tObj->BaseLevel + (GLint)(tObj->MaxLod + 0.5);
+ lastLevel = MAX2(lastLevel, t->tObj->BaseLevel);
+ lastLevel = MIN2(lastLevel, t->tObj->BaseLevel + baseImage->MaxLog2);
+ lastLevel = MIN2(lastLevel, t->tObj->MaxLevel);
+ lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
+ }
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ case GL_TEXTURE_4D_SGIS:
+ firstLevel = lastLevel = 0;
+ break;
+ default:
+ return;
+ }
+
+ /* save these values */
+ t->firstLevel = firstLevel;
+ t->lastLevel = lastLevel;
+}
+
+
+
+
+/**
+ * \name DRI texture formats. Pointers initialized to either the big- or
+ * little-endian Mesa formats.
+ */
+/*@{*/
+const struct gl_texture_format *_dri_texformat_rgba8888 = NULL;
+const struct gl_texture_format *_dri_texformat_argb8888 = NULL;
+const struct gl_texture_format *_dri_texformat_rgb565 = NULL;
+const struct gl_texture_format *_dri_texformat_argb4444 = NULL;
+const struct gl_texture_format *_dri_texformat_argb1555 = NULL;
+const struct gl_texture_format *_dri_texformat_al88 = NULL;
+const struct gl_texture_format *_dri_texformat_a8 = &_mesa_texformat_a8;
+const struct gl_texture_format *_dri_texformat_ci8 = &_mesa_texformat_ci8;
+const struct gl_texture_format *_dri_texformat_i8 = &_mesa_texformat_i8;
+const struct gl_texture_format *_dri_texformat_l8 = &_mesa_texformat_l8;
+/*@}*/
+
+
+/**
+ * Initialize little endian target, host byte order independent texture formats
+ */
+void
+driInitTextureFormats(void)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ if (littleEndian) {
+ _dri_texformat_rgba8888 = &_mesa_texformat_rgba8888;
+ _dri_texformat_argb8888 = &_mesa_texformat_argb8888;
+ _dri_texformat_rgb565 = &_mesa_texformat_rgb565;
+ _dri_texformat_argb4444 = &_mesa_texformat_argb4444;
+ _dri_texformat_argb1555 = &_mesa_texformat_argb1555;
+ _dri_texformat_al88 = &_mesa_texformat_al88;
+ }
+ else {
+ _dri_texformat_rgba8888 = &_mesa_texformat_rgba8888_rev;
+ _dri_texformat_argb8888 = &_mesa_texformat_argb8888_rev;
+ _dri_texformat_rgb565 = &_mesa_texformat_rgb565_rev;
+ _dri_texformat_argb4444 = &_mesa_texformat_argb4444_rev;
+ _dri_texformat_argb1555 = &_mesa_texformat_argb1555_rev;
+ _dri_texformat_al88 = &_mesa_texformat_al88_rev;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/texmem.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/texmem.h
new file mode 100644
index 000000000..705cd4d34
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/texmem.h
@@ -0,0 +1,327 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * (c) Copyright IBM Corporation 2002
+ * 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
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Ian Romanick <idr@us.ibm.com>
+ * Keith Whitwell <keithw@tungstengraphics.com>
+ * Kevin E. Martin <kem@users.sourceforge.net>
+ * Gareth Hughes <gareth@nvidia.com>
+ */
+/* $XFree86:$ */
+
+/** \file texmem.h
+ * Public interface to the DRI texture memory management routines.
+ *
+ * \sa texmem.c
+ */
+
+#ifndef DRI_TEXMEM_H
+#define DRI_TEXMEM_H
+
+#include "mtypes.h"
+#include "mm.h"
+#include "xf86drm.h"
+
+struct dri_tex_heap;
+typedef struct dri_tex_heap driTexHeap;
+
+struct dri_texture_object;
+typedef struct dri_texture_object driTextureObject;
+
+
+/**
+ * Base texture object type. Each driver will extend this type with its own
+ * private data members.
+ */
+
+struct dri_texture_object {
+ struct dri_texture_object * next;
+ struct dri_texture_object * prev;
+
+ driTexHeap * heap; /**< Texture heap currently stored in */
+ struct gl_texture_object * tObj;/**< Pointer to Mesa texture object
+ * If NULL, this texture object is a
+ * "placeholder" object representing
+ * texture memory in use by another context.
+ * A placeholder should have a heap and a memBlock.
+ */
+ PMemBlock memBlock; /**< Memory block containing texture */
+ unsigned bound; /**< Texture unit currently bound to */
+
+ unsigned totalSize; /**< Total size of the texture,
+ * including all mipmap levels
+ */
+
+ unsigned dirty_images[6]; /**< Flags for whether or not images
+ * need to be uploaded to local or
+ * AGP texture space. One flag set
+ * for each cube face for cubic
+ * textures. Bit zero corresponds to
+ * the base-level, which may or may
+ * not be the level zero mipmap.
+ */
+
+ unsigned timestamp; /**< Timestamp used to
+ * synchronize with 3d engine
+ * in hardware where textures
+ * are uploaded directly to
+ * the framebuffer.
+ */
+
+ unsigned firstLevel; /**< Image in \c tObj->Image[0] that
+ * corresponds to the base-level of
+ * this texture object.
+ */
+
+ unsigned lastLevel; /**< Last image in \c tObj->Image[0]
+ * used by the
+ * current LOD settings of
+ * this texture object. This
+ * value must be greater than
+ * or equal to \c firstLevel.
+ */
+};
+
+
+typedef void (destroy_texture_object_t)( void * driverContext,
+ driTextureObject * t );
+
+/**
+ * Client-private representation of texture memory state.
+ *
+ * Clients will place one or more of these structs in their driver
+ * context struct to manage one or more global texture heaps.
+ */
+
+struct dri_tex_heap {
+
+ /** Client-supplied heap identifier
+ */
+ unsigned heapId;
+
+ /** Pointer to the client's private context
+ */
+ void *driverContext;
+
+ /** Total size of the heap, in bytes
+ */
+ unsigned size;
+
+ /** \brief \f$log_2\f$ of size of single heap region
+ *
+ * Each context takes memory from the global texture heap in
+ * \f$2^{logGranularity}\f$ byte blocks. The value of
+ * \a logGranularity is based on the amount of memory represented
+ * by the heap and the maximum number of regions in the SAREA. Given
+ * \a b bytes of texture memory an \a n regions in the SAREA,
+ * \a logGranularity will be \f$\lfloor\log_2( b / n )\rfloor\f$.
+ */
+ unsigned logGranularity;
+
+ /** \brief Required alignment of allocations in this heap
+ *
+ * The alignment shift is supplied to \a mmAllocMem when memory is
+ * allocated from this heap. The value of \a alignmentShift will
+ * typically reflect some require of the hardware. This value has
+ * \b no \b relation to \a logGranularity. \a alignmentShift is a
+ * per-context value.
+ *
+ * \sa mmAllocMem
+ */
+ unsigned alignmentShift;
+
+ /** Number of elements in global list (the SAREA).
+ */
+ unsigned nrRegions;
+
+ /** Pointer to SAREA \a driTexRegion array
+ */
+ drmTextureRegionPtr global_regions;
+
+ /** Pointer to the texture state age (generation number) in the SAREA
+ */
+ unsigned * global_age;
+
+ /** Local age (generation number) of texture state
+ */
+ unsigned local_age;
+
+ /** Memory heap used to manage texture memory represented by
+ * this texture heap.
+ */
+ memHeap_t * memory_heap;
+
+ /** List of objects that we currently believe to be in texture
+ * memory.
+ */
+ driTextureObject texture_objects;
+
+ /** Pointer to the list of texture objects that are not in
+ * texture memory.
+ */
+ driTextureObject * swapped_objects;
+
+ /** Size of the driver-speicific texture object.
+ */
+ unsigned texture_object_size;
+
+
+ /**
+ * \brief Function to destroy driver-specific texture object data.
+ *
+ * This function is supplied by the driver so that the texture manager
+ * can release all resources associated with a texture object. This
+ * function should only release driver-specific data. That is,
+ * \a driDestroyTextureObject will release the texture memory
+ * associated with the texture object, it will release the memory
+ * for the texture object itself, and it will unlink the texture
+ * object from the texture object lists.
+ *
+ * \param driverContext Pointer to the driver supplied context
+ * \param t Texture object that is to be destroyed
+ * \sa driDestroyTextureObject
+ */
+
+ destroy_texture_object_t * destroy_texture_object;
+
+
+ /**
+ */
+ unsigned * texture_swaps;
+
+ /**
+ * Timestamp used to synchronize with 3d engine in hardware
+ * where textures are uploaded directly to the
+ * framebuffer.
+ */
+ unsigned timestamp;
+
+ /** \brief Kick/upload weight
+ *
+ * When not enough free space is available this weight
+ * influences the choice of the heap from which textures are
+ * kicked. By default the weight is equal to the heap size.
+ */
+ double weight;
+
+ /** \brief Kick/upload duty
+ *
+ * The heap with the highest duty will be chosen for kicking
+ * textures if not enough free space is available. The duty is
+ * reduced by the amount of data kicked. Rebalancing of
+ * negative duties takes the weights into account.
+ */
+ int duty;
+};
+
+
+
+
+/**
+ * Called by the client on lock contention to determine whether textures have
+ * been stolen. If another client has modified a region in which we have
+ * textures, then we need to figure out which of our textures have been
+ * removed and update our global LRU.
+ *
+ * \param heap Texture heap to be updated
+ * \hideinitializer
+ */
+
+#define DRI_AGE_TEXTURES( heap ) \
+ do { \
+ if ( ((heap) != NULL) \
+ && ((heap)->local_age != (heap)->global_age[0]) ) \
+ driAgeTextures( heap ); \
+ } while( 0 )
+
+
+
+
+/* This should be called whenever there has been contention on the hardware
+ * lock. driAgeTextures should not be called directly. Instead, clients
+ * should use DRI_AGE_TEXTURES, above.
+ */
+
+void driAgeTextures( driTexHeap * heap );
+
+void driUpdateTextureLRU( driTextureObject * t );
+void driSwapOutTextureObject( driTextureObject * t );
+void driDestroyTextureObject( driTextureObject * t );
+int driAllocateTexture( driTexHeap * const * heap_array, unsigned nr_heaps,
+ driTextureObject * t );
+
+GLboolean driIsTextureResident( GLcontext * ctx,
+ struct gl_texture_object * texObj );
+
+driTexHeap * driCreateTextureHeap( unsigned heap_id, void * context,
+ unsigned size, unsigned alignmentShift, unsigned nr_regions,
+ drmTextureRegionPtr global_regions, unsigned * global_age,
+ driTextureObject * swapped_objects, unsigned texture_object_size,
+ destroy_texture_object_t * destroy_tex_obj );
+void driDestroyTextureHeap( driTexHeap * heap );
+
+void
+driCalculateMaxTextureLevels( driTexHeap * const * heaps,
+ unsigned nr_heaps,
+ struct gl_constants * limits,
+ unsigned max_bytes_per_texel,
+ unsigned max_2D_size,
+ unsigned max_3D_size,
+ unsigned max_cube_size,
+ unsigned max_rect_size,
+ unsigned mipmaps_at_once,
+ int all_textures_one_heap );
+
+void
+driSetTextureSwapCounterLocation( driTexHeap * heap, unsigned * counter );
+
+#define DRI_TEXMGR_DO_TEXTURE_1D 0x0001
+#define DRI_TEXMGR_DO_TEXTURE_2D 0x0002
+#define DRI_TEXMGR_DO_TEXTURE_3D 0x0004
+#define DRI_TEXMGR_DO_TEXTURE_CUBE 0x0008
+#define DRI_TEXMGR_DO_TEXTURE_RECT 0x0010
+
+void driInitTextureObjects( GLcontext *ctx, driTextureObject * swapped,
+ GLuint targets );
+
+GLboolean driValidateTextureHeaps( driTexHeap * const * texture_heaps,
+ unsigned nr_heaps, const driTextureObject * swapped );
+
+extern void driCalculateTextureFirstLastLevel( driTextureObject * t );
+
+
+extern const struct gl_texture_format *_dri_texformat_rgba8888;
+extern const struct gl_texture_format *_dri_texformat_argb8888;
+extern const struct gl_texture_format *_dri_texformat_rgb565;
+extern const struct gl_texture_format *_dri_texformat_argb4444;
+extern const struct gl_texture_format *_dri_texformat_argb1555;
+extern const struct gl_texture_format *_dri_texformat_al88;
+extern const struct gl_texture_format *_dri_texformat_a8;
+extern const struct gl_texture_format *_dri_texformat_ci8;
+extern const struct gl_texture_format *_dri_texformat_i8;
+extern const struct gl_texture_format *_dri_texformat_l8;
+
+extern void driInitTextureFormats( void );
+
+#endif /* DRI_TEXMEM_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/utils.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/utils.c
new file mode 100644
index 000000000..fbe1991fa
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/utils.c
@@ -0,0 +1,695 @@
+/*
+ * (C) Copyright IBM Corporation 2002, 2004
+ * 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
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file utils.c
+ * Utility functions for DRI drivers.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include <string.h>
+#include <stdlib.h>
+#include "mtypes.h"
+#include "extensions.h"
+#include "utils.h"
+#include "dispatch.h"
+
+int driDispatchRemapTable[ driDispatchRemapTable_size ];
+
+#if defined(USE_X86_ASM)
+#include "x86/common_x86_asm.h"
+#endif
+
+#if defined(USE_PPC_ASM)
+#include "ppc/common_ppc_features.h"
+#endif
+
+unsigned
+driParseDebugString( const char * debug,
+ const struct dri_debug_control * control )
+{
+ unsigned flag;
+
+
+ flag = 0;
+ if ( debug != NULL ) {
+ while( control->string != NULL ) {
+ if ( !strcmp( debug, "all" ) ||
+ strstr( debug, control->string ) != NULL ) {
+ flag |= control->flag;
+ }
+
+ control++;
+ }
+ }
+
+ return flag;
+}
+
+
+
+/**
+ * Create the \c GL_RENDERER string for DRI drivers.
+ *
+ * Almost all DRI drivers use a \c GL_RENDERER string of the form:
+ *
+ * "Mesa DRI <chip> <driver date> <AGP speed) <CPU information>"
+ *
+ * Using the supplied chip name, driver data, and AGP speed, this function
+ * creates the string.
+ *
+ * \param buffer Buffer to hold the \c GL_RENDERER string.
+ * \param hardware_name Name of the hardware.
+ * \param driver_date Driver date.
+ * \param agp_mode AGP mode (speed).
+ *
+ * \returns
+ * The length of the string stored in \c buffer. This does \b not include
+ * the terminating \c NUL character.
+ */
+unsigned
+driGetRendererString( char * buffer, const char * hardware_name,
+ const char * driver_date, GLuint agp_mode )
+{
+#define MAX_INFO 4
+ const char * cpu[MAX_INFO];
+ unsigned next = 0;
+ unsigned i;
+ unsigned offset;
+
+
+ offset = sprintf( buffer, "Mesa DRI %s %s", hardware_name, driver_date );
+
+ /* Append any AGP-specific information.
+ */
+ switch ( agp_mode ) {
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ offset += sprintf( & buffer[ offset ], " AGP %ux", agp_mode );
+ break;
+
+ default:
+ break;
+ }
+
+ /* Append any CPU-specific information.
+ */
+#ifdef USE_X86_ASM
+ if ( _mesa_x86_cpu_features ) {
+ cpu[next] = " x86";
+ next++;
+ }
+# ifdef USE_MMX_ASM
+ if ( cpu_has_mmx ) {
+ cpu[next] = (cpu_has_mmxext) ? "/MMX+" : "/MMX";
+ next++;
+ }
+# endif
+# ifdef USE_3DNOW_ASM
+ if ( cpu_has_3dnow ) {
+ cpu[next] = (cpu_has_3dnowext) ? "/3DNow!+" : "/3DNow!";
+ next++;
+ }
+# endif
+# ifdef USE_SSE_ASM
+ if ( cpu_has_xmm ) {
+ cpu[next] = (cpu_has_xmm2) ? "/SSE2" : "/SSE";
+ next++;
+ }
+# endif
+
+#elif defined(USE_SPARC_ASM)
+
+ cpu[0] = " SPARC";
+ next = 1;
+
+#elif defined(USE_PPC_ASM)
+ if ( _mesa_ppc_cpu_features ) {
+ cpu[next] = (cpu_has_64) ? " PowerPC 64" : " PowerPC";
+ next++;
+ }
+
+# ifdef USE_VMX_ASM
+ if ( cpu_has_vmx ) {
+ cpu[next] = "/Altivec";
+ next++;
+ }
+# endif
+
+ if ( ! cpu_has_fpu ) {
+ cpu[next] = "/No FPU";
+ next++;
+ }
+#endif
+
+ for ( i = 0 ; i < next ; i++ ) {
+ const size_t len = strlen( cpu[i] );
+
+ strncpy( & buffer[ offset ], cpu[i], len );
+ offset += len;
+ }
+
+ return offset;
+}
+
+
+
+
+#define need_GL_ARB_multisample
+#define need_GL_ARB_transpose_matrix
+#define need_GL_ARB_window_pos
+#define need_GL_EXT_compiled_vertex_array
+#define need_GL_EXT_polygon_offset
+#define need_GL_EXT_texture_object
+#define need_GL_EXT_vertex_array
+#define need_GL_MESA_window_pos
+
+/* These are needed in *all* drivers because Mesa internally implements
+ * certain functionality in terms of functions provided by these extensions.
+ * For example, glBlendFunc is implemented by calling glBlendFuncSeparateEXT.
+ */
+#define need_GL_EXT_blend_func_separate
+#define need_GL_NV_vertex_program
+
+#include "extension_helper.h"
+
+static const struct dri_extension all_mesa_extensions[] = {
+ { "GL_ARB_multisample", GL_ARB_multisample_functions },
+ { "GL_ARB_transpose_matrix", GL_ARB_transpose_matrix_functions },
+ { "GL_ARB_window_pos", GL_ARB_window_pos_functions },
+ { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions },
+ { "GL_EXT_compiled_vertex_array", GL_EXT_compiled_vertex_array_functions },
+ { "GL_EXT_polygon_offset", GL_EXT_polygon_offset_functions },
+ { "GL_EXT_texture_object", GL_EXT_texture_object_functions },
+ { "GL_EXT_vertex_array", GL_EXT_vertex_array_functions },
+ { "GL_MESA_window_pos", GL_MESA_window_pos_functions },
+ { "GL_NV_vertex_program", GL_NV_vertex_program_functions },
+ { NULL, NULL }
+};
+
+
+/**
+ * Enable extensions supported by the driver.
+ *
+ * \bug
+ * ARB_imaging isn't handled properly. In Mesa, enabling ARB_imaging also
+ * enables all the sub-extensions that are folded into it. This means that
+ * we need to add entry-points (via \c driInitSingleExtension) for those
+ * new functions here.
+ */
+void driInitExtensions( GLcontext * ctx,
+ const struct dri_extension * extensions_to_enable,
+ GLboolean enable_imaging )
+{
+ static int first_time = 1;
+ unsigned i;
+
+ if ( first_time ) {
+ for ( i = 0 ; i < driDispatchRemapTable_size ; i++ ) {
+ driDispatchRemapTable[i] = -1;
+ }
+
+ first_time = 0;
+ driInitExtensions( ctx, all_mesa_extensions, GL_FALSE );
+ }
+
+ if ( (ctx != NULL) && enable_imaging ) {
+ _mesa_enable_imaging_extensions( ctx );
+ }
+
+ for ( i = 0 ; extensions_to_enable[i].name != NULL ; i++ ) {
+ driInitSingleExtension( ctx, & extensions_to_enable[i] );
+ }
+}
+
+
+
+
+/**
+ * Enable and add dispatch functions for a single extension
+ *
+ * \param ctx Context where extension is to be enabled.
+ * \param ext Extension that is to be enabled.
+ *
+ * \sa driInitExtensions, _mesa_enable_extension, _glapi_add_entrypoint
+ *
+ * \todo
+ * Determine if it would be better to use \c strlen instead of the hardcoded
+ * for-loops.
+ */
+void driInitSingleExtension( GLcontext * ctx,
+ const struct dri_extension * ext )
+{
+ unsigned i;
+
+
+ if ( ext->functions != NULL ) {
+ for ( i = 0 ; ext->functions[i].strings != NULL ; i++ ) {
+ const char * functions[16];
+ const char * parameter_signature;
+ const char * str = ext->functions[i].strings;
+ unsigned j;
+ unsigned offset;
+
+
+ /* Separate the parameter signature from the rest of the string.
+ * If the parameter signature is empty (i.e., the string starts
+ * with a NUL character), then the function has a void parameter
+ * list.
+ */
+ parameter_signature = str;
+ while ( str[0] != '\0' ) {
+ str++;
+ }
+ str++;
+
+
+ /* Divide the string into the substrings that name each
+ * entry-point for the function.
+ */
+ for ( j = 0 ; j < 16 ; j++ ) {
+ if ( str[0] == '\0' ) {
+ functions[j] = NULL;
+ break;
+ }
+
+ functions[j] = str;
+
+ while ( str[0] != '\0' ) {
+ str++;
+ }
+ str++;
+ }
+
+
+ /* Add each entry-point to the dispatch table.
+ */
+ offset = _glapi_add_dispatch( functions, parameter_signature );
+ if ( ext->functions[i].remap_index != -1 ) {
+ driDispatchRemapTable[ ext->functions[i].remap_index ] = offset;
+ }
+
+ if ( (ext->functions[i].offset != -1)
+ && (ext->functions[i].offset != offset) ) {
+ fprintf(stderr, "DISPATCH ERROR! %s -> %u != %u\n", functions[0],
+ driDispatchRemapTable[ ext->functions[i].remap_index ],
+ ext->functions[i].offset);
+ }
+ }
+ }
+
+ if ( ctx != NULL ) {
+ _mesa_enable_extension( ctx, ext->name );
+ }
+}
+
+
+/**
+ * Utility function used by drivers to test the verions of other components.
+ *
+ * If one of the version requirements is not met, a message is logged using
+ * \c __driUtilMessage.
+ *
+ * \param driver_name Name of the driver. Used in error messages.
+ * \param driActual Actual DRI version supplied __driCreateNewScreen.
+ * \param driExpected Minimum DRI version required by the driver.
+ * \param ddxActual Actual DDX version supplied __driCreateNewScreen.
+ * \param ddxExpected Minimum DDX minor and range of DDX major version required by the driver.
+ * \param drmActual Actual DRM version supplied __driCreateNewScreen.
+ * \param drmExpected Minimum DRM version required by the driver.
+ *
+ * \returns \c GL_TRUE if all version requirements are met. Otherwise,
+ * \c GL_FALSE is returned.
+ *
+ * \sa __driCreateNewScreen, driCheckDriDdxDrmVersions2, __driUtilMessage
+ *
+ * \todo
+ * Now that the old \c driCheckDriDdxDrmVersions function is gone, this
+ * function and \c driCheckDriDdxDrmVersions2 should be renamed.
+ */
+GLboolean
+driCheckDriDdxDrmVersions3(const char * driver_name,
+ const __DRIversion * driActual,
+ const __DRIversion * driExpected,
+ const __DRIversion * ddxActual,
+ const __DRIutilversion2 * ddxExpected,
+ const __DRIversion * drmActual,
+ const __DRIversion * drmExpected)
+{
+ static const char format[] = "%s DRI driver expected %s version %d.%d.x "
+ "but got version %d.%d.%d";
+ static const char format2[] = "%s DRI driver expected %s version %d-%d.%d.x "
+ "but got version %d.%d.%d";
+
+
+ /* Check the DRI version */
+ if ( (driActual->major != driExpected->major)
+ || (driActual->minor < driExpected->minor) ) {
+ __driUtilMessage(format, driver_name, "DRI",
+ driExpected->major, driExpected->minor,
+ driActual->major, driActual->minor, driActual->patch);
+ return GL_FALSE;
+ }
+
+ /* Check that the DDX driver version is compatible */
+ if ( (ddxActual->major < ddxExpected->major_min)
+ || (ddxActual->major > ddxExpected->major_max)
+ || (ddxActual->minor < ddxExpected->minor) ) {
+ __driUtilMessage(format2, driver_name, "DDX",
+ ddxExpected->major_min, ddxExpected->major_max, ddxExpected->minor,
+ ddxActual->major, ddxActual->minor, ddxActual->patch);
+ return GL_FALSE;
+ }
+
+ /* Check that the DRM driver version is compatible */
+ if ( (drmActual->major != drmExpected->major)
+ || (drmActual->minor < drmExpected->minor) ) {
+ __driUtilMessage(format, driver_name, "DRM",
+ drmExpected->major, drmExpected->minor,
+ drmActual->major, drmActual->minor, drmActual->patch);
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+GLboolean
+driCheckDriDdxDrmVersions2(const char * driver_name,
+ const __DRIversion * driActual,
+ const __DRIversion * driExpected,
+ const __DRIversion * ddxActual,
+ const __DRIversion * ddxExpected,
+ const __DRIversion * drmActual,
+ const __DRIversion * drmExpected)
+{
+ __DRIutilversion2 ddx_expected;
+ ddx_expected.major_min = ddxExpected->major;
+ ddx_expected.major_max = ddxExpected->major;
+ ddx_expected.minor = ddxExpected->minor;
+ ddx_expected.patch = ddxExpected->patch;
+ return driCheckDriDdxDrmVersions3(driver_name, driActual,
+ driExpected, ddxActual, & ddx_expected,
+ drmActual, drmExpected);
+}
+
+
+
+GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer,
+ GLint *x, GLint *y,
+ GLsizei *width, GLsizei *height )
+{
+ /* left clipping */
+ if (*x < buffer->_Xmin) {
+ *width -= (buffer->_Xmin - *x);
+ *x = buffer->_Xmin;
+ }
+
+ /* right clipping */
+ if (*x + *width > buffer->_Xmax)
+ *width -= (*x + *width - buffer->_Xmax - 1);
+
+ if (*width <= 0)
+ return GL_FALSE;
+
+ /* bottom clipping */
+ if (*y < buffer->_Ymin) {
+ *height -= (buffer->_Ymin - *y);
+ *y = buffer->_Ymin;
+ }
+
+ /* top clipping */
+ if (*y + *height > buffer->_Ymax)
+ *height -= (*y + *height - buffer->_Ymax - 1);
+
+ if (*height <= 0)
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
+
+
+/**
+ * Creates a set of \c __GLcontextModes that a driver will expose.
+ *
+ * A set of \c __GLcontextModes will be created based on the supplied
+ * parameters. The number of modes processed will be 2 *
+ * \c num_depth_stencil_bits * \c num_db_modes.
+ *
+ * For the most part, data is just copied from \c depth_bits, \c stencil_bits,
+ * \c db_modes, and \c visType into each \c __GLcontextModes element.
+ * However, the meanings of \c fb_format and \c fb_type require further
+ * explanation. The \c fb_format specifies which color components are in
+ * each pixel and what the default order is. For example, \c GL_RGB specifies
+ * that red, green, blue are available and red is in the "most significant"
+ * position and blue is in the "least significant". The \c fb_type specifies
+ * the bit sizes of each component and the actual ordering. For example, if
+ * \c GL_UNSIGNED_SHORT_5_6_5_REV is specified with \c GL_RGB, bits [15:11]
+ * are the blue value, bits [10:5] are the green value, and bits [4:0] are
+ * the red value.
+ *
+ * One sublte issue is the combination of \c GL_RGB or \c GL_BGR and either
+ * of the \c GL_UNSIGNED_INT_8_8_8_8 modes. The resulting mask values in the
+ * \c __GLcontextModes structure is \b identical to the \c GL_RGBA or
+ * \c GL_BGRA case, except the \c alphaMask is zero. This means that, as
+ * far as this routine is concerned, \c GL_RGB with \c GL_UNSIGNED_INT_8_8_8_8
+ * still uses 32-bits.
+ *
+ * If in doubt, look at the tables used in the function.
+ *
+ * \param ptr_to_modes Pointer to a pointer to a linked list of
+ * \c __GLcontextModes. Upon completion, a pointer to
+ * the next element to be process will be stored here.
+ * If the function fails and returns \c GL_FALSE, this
+ * value will be unmodified, but some elements in the
+ * linked list may be modified.
+ * \param fb_format Format of the framebuffer. Currently only \c GL_RGB,
+ * \c GL_RGBA, \c GL_BGR, and \c GL_BGRA are supported.
+ * \param fb_type Type of the pixels in the framebuffer. Currently only
+ * \c GL_UNSIGNED_SHORT_5_6_5,
+ * \c GL_UNSIGNED_SHORT_5_6_5_REV,
+ * \c GL_UNSIGNED_INT_8_8_8_8, and
+ * \c GL_UNSIGNED_INT_8_8_8_8_REV are supported.
+ * \param depth_bits Array of depth buffer sizes to be exposed.
+ * \param stencil_bits Array of stencil buffer sizes to be exposed.
+ * \param num_depth_stencil_bits Number of entries in both \c depth_bits and
+ * \c stencil_bits.
+ * \param db_modes Array of buffer swap modes. If an element has a
+ * value of \c GLX_NONE, then it represents a
+ * single-buffered mode. Other valid values are
+ * \c GLX_SWAP_EXCHANGE_OML, \c GLX_SWAP_COPY_OML, and
+ * \c GLX_SWAP_UNDEFINED_OML. See the
+ * GLX_OML_swap_method extension spec for more details.
+ * \param num_db_modes Number of entries in \c db_modes.
+ * \param visType GLX visual type. Usually either \c GLX_TRUE_COLOR or
+ * \c GLX_DIRECT_COLOR.
+ *
+ * \returns
+ * \c GL_TRUE on success or \c GL_FALSE on failure. Currently the only
+ * cause of failure is a bad parameter (i.e., unsupported \c fb_format or
+ * \c fb_type).
+ *
+ * \todo
+ * There is currently no way to support packed RGB modes (i.e., modes with
+ * exactly 3 bytes per pixel) or floating-point modes. This could probably
+ * be done by creating some new, private enums with clever names likes
+ * \c GL_UNSIGNED_3BYTE_8_8_8, \c GL_4FLOAT_32_32_32_32,
+ * \c GL_4HALF_16_16_16_16, etc. We can cross that bridge when we come to it.
+ */
+GLboolean
+driFillInModes( __GLcontextModes ** ptr_to_modes,
+ GLenum fb_format, GLenum fb_type,
+ const u_int8_t * depth_bits, const u_int8_t * stencil_bits,
+ unsigned num_depth_stencil_bits,
+ const GLenum * db_modes, unsigned num_db_modes,
+ int visType )
+{
+ static const u_int8_t bits_table[3][4] = {
+ /* R G B A */
+ { 5, 6, 5, 0 }, /* Any GL_UNSIGNED_SHORT_5_6_5 */
+ { 8, 8, 8, 0 }, /* Any RGB with any GL_UNSIGNED_INT_8_8_8_8 */
+ { 8, 8, 8, 8 } /* Any RGBA with any GL_UNSIGNED_INT_8_8_8_8 */
+ };
+
+ /* The following arrays are all indexed by the fb_type masked with 0x07.
+ * Given the four supported fb_type values, this results in valid array
+ * indices of 3, 4, 5, and 7.
+ */
+ static const u_int32_t masks_table_rgb[8][4] = {
+ { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+ { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+ { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+ { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, /* 5_6_5 */
+ { 0x0000001F, 0x000007E0, 0x0000F800, 0x00000000 }, /* 5_6_5_REV */
+ { 0xFF000000, 0x00FF0000, 0x0000FF00, 0x00000000 }, /* 8_8_8_8 */
+ { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+ { 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000 } /* 8_8_8_8_REV */
+ };
+
+ static const u_int32_t masks_table_rgba[8][4] = {
+ { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+ { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+ { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+ { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, /* 5_6_5 */
+ { 0x0000001F, 0x000007E0, 0x0000F800, 0x00000000 }, /* 5_6_5_REV */
+ { 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF }, /* 8_8_8_8 */
+ { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+ { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 }, /* 8_8_8_8_REV */
+ };
+
+ static const u_int32_t masks_table_bgr[8][4] = {
+ { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+ { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+ { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+ { 0x0000001F, 0x000007E0, 0x0000F800, 0x00000000 }, /* 5_6_5 */
+ { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, /* 5_6_5_REV */
+ { 0x0000FF00, 0x00FF0000, 0xFF000000, 0x00000000 }, /* 8_8_8_8 */
+ { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+ { 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 }, /* 8_8_8_8_REV */
+ };
+
+ static const u_int32_t masks_table_bgra[8][4] = {
+ { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+ { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+ { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+ { 0x0000001F, 0x000007E0, 0x0000F800, 0x00000000 }, /* 5_6_5 */
+ { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }, /* 5_6_5_REV */
+ { 0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF }, /* 8_8_8_8 */
+ { 0x00000000, 0x00000000, 0x00000000, 0x00000000 },
+ { 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 }, /* 8_8_8_8_REV */
+ };
+
+ static const u_int8_t bytes_per_pixel[8] = {
+ 0, 0, 0, 2, 2, 4, 0, 4
+ };
+
+ const u_int8_t * bits;
+ const u_int32_t * masks;
+ const int index = fb_type & 0x07;
+ __GLcontextModes * modes = *ptr_to_modes;
+ unsigned i;
+ unsigned j;
+ unsigned k;
+
+
+ if ( bytes_per_pixel[ index ] == 0 ) {
+ fprintf( stderr, "[%s:%u] Framebuffer type 0x%04x has 0 bytes per pixel.\n",
+ __FUNCTION__, __LINE__, fb_type );
+ return GL_FALSE;
+ }
+
+
+ /* Valid types are GL_UNSIGNED_SHORT_5_6_5 and GL_UNSIGNED_INT_8_8_8_8 and
+ * the _REV versions.
+ *
+ * Valid formats are GL_RGBA, GL_RGB, and GL_BGRA.
+ */
+
+ switch ( fb_format ) {
+ case GL_RGB:
+ bits = (bytes_per_pixel[ index ] == 2)
+ ? bits_table[0] : bits_table[1];
+ masks = masks_table_rgb[ index ];
+ break;
+
+ case GL_RGBA:
+ bits = (bytes_per_pixel[ index ] == 2)
+ ? bits_table[0] : bits_table[2];
+ masks = masks_table_rgba[ index ];
+ break;
+
+ case GL_BGR:
+ bits = (bytes_per_pixel[ index ] == 2)
+ ? bits_table[0] : bits_table[1];
+ masks = masks_table_bgr[ index ];
+ break;
+
+ case GL_BGRA:
+ bits = (bytes_per_pixel[ index ] == 2)
+ ? bits_table[0] : bits_table[2];
+ masks = masks_table_bgra[ index ];
+ break;
+
+ default:
+ fprintf( stderr, "[%s:%u] Framebuffer format 0x%04x is not GL_RGB, GL_RGBA, GL_BGR, or GL_BGRA.\n",
+ __FUNCTION__, __LINE__, fb_format );
+ return GL_FALSE;
+ }
+
+
+ for ( k = 0 ; k < num_depth_stencil_bits ; k++ ) {
+ for ( i = 0 ; i < num_db_modes ; i++ ) {
+ for ( j = 0 ; j < 2 ; j++ ) {
+
+ modes->redBits = bits[0];
+ modes->greenBits = bits[1];
+ modes->blueBits = bits[2];
+ modes->alphaBits = bits[3];
+ modes->redMask = masks[0];
+ modes->greenMask = masks[1];
+ modes->blueMask = masks[2];
+ modes->alphaMask = masks[3];
+ modes->rgbBits = modes->redBits + modes->greenBits
+ + modes->blueBits + modes->alphaBits;
+
+ modes->accumRedBits = 16 * j;
+ modes->accumGreenBits = 16 * j;
+ modes->accumBlueBits = 16 * j;
+ modes->accumAlphaBits = (masks[3] != 0) ? 16 * j : 0;
+ modes->visualRating = (j == 0) ? GLX_NONE : GLX_SLOW_CONFIG;
+
+ modes->stencilBits = stencil_bits[k];
+ modes->depthBits = depth_bits[k];
+
+ modes->visualType = visType;
+ modes->renderType = GLX_RGBA_BIT;
+ modes->drawableType = GLX_WINDOW_BIT;
+ modes->rgbMode = GL_TRUE;
+
+ if ( db_modes[i] == GLX_NONE ) {
+ modes->doubleBufferMode = GL_FALSE;
+ }
+ else {
+ modes->doubleBufferMode = GL_TRUE;
+ modes->swapMethod = db_modes[i];
+ }
+
+ modes->haveAccumBuffer = ((modes->accumRedBits +
+ modes->accumGreenBits +
+ modes->accumBlueBits +
+ modes->accumAlphaBits) > 0);
+ modes->haveDepthBuffer = (modes->depthBits > 0);
+ modes->haveStencilBuffer = (modes->stencilBits > 0);
+
+ modes = modes->next;
+ }
+ }
+ }
+
+ *ptr_to_modes = modes;
+ return GL_TRUE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/utils.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/utils.h
new file mode 100644
index 000000000..26d178f74
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/utils.h
@@ -0,0 +1,119 @@
+/*
+ * (C) Copyright IBM Corporation 2002, 2004
+ * 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
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Ian Romanick <idr@us.ibm.com>
+ */
+/* $XFree86:$ */
+
+#ifndef DRI_DEBUG_H
+#define DRI_DEBUG_H
+
+#include "context.h"
+#include "dri_util.h"
+
+struct dri_debug_control {
+ const char * string;
+ unsigned flag;
+};
+
+/**
+ * Description of the entry-points and parameters for an OpenGL function.
+ */
+struct dri_extension_function {
+ /**
+ * \brief
+ * Packed string describing the parameter signature and the entry-point
+ * names.
+ *
+ * The parameter signature and the names of the entry-points for this
+ * function are packed into a single string. The substrings are
+ * separated by NUL characters. The whole string is terminated by
+ * two consecutive NUL characters.
+ */
+ const char * strings;
+
+
+ /**
+ * Location in the remap table where the dispatch offset should be
+ * stored.
+ */
+ int remap_index;
+
+ /**
+ * Offset of the function in the dispatch table.
+ */
+ int offset;
+};
+
+/**
+ * Description of the API for an extension to OpenGL.
+ */
+struct dri_extension {
+ /**
+ * Name of the extension.
+ */
+ const char * name;
+
+
+ /**
+ * Pointer to a list of \c dri_extension_function structures. The list
+ * is terminated by a structure with a \c NULL
+ * \c dri_extension_function::strings pointer.
+ */
+ const struct dri_extension_function * functions;
+};
+
+extern unsigned driParseDebugString( const char * debug,
+ const struct dri_debug_control * control );
+
+extern unsigned driGetRendererString( char * buffer,
+ const char * hardware_name, const char * driver_date, GLuint agp_mode );
+
+extern void driInitExtensions( GLcontext * ctx,
+ const struct dri_extension * card_extensions, GLboolean enable_imaging );
+
+extern void driInitSingleExtension( GLcontext * ctx,
+ const struct dri_extension * ext );
+
+extern GLboolean driCheckDriDdxDrmVersions2(const char * driver_name,
+ const __DRIversion * driActual, const __DRIversion * driExpected,
+ const __DRIversion * ddxActual, const __DRIversion * ddxExpected,
+ const __DRIversion * drmActual, const __DRIversion * drmExpected);
+
+extern GLboolean driCheckDriDdxDrmVersions3(const char * driver_name,
+ const __DRIversion * driActual, const __DRIversion * driExpected,
+ const __DRIversion * ddxActual, const __DRIutilversion2 * ddxExpected,
+ const __DRIversion * drmActual, const __DRIversion * drmExpected);
+
+extern GLboolean driClipRectToFramebuffer( const GLframebuffer *buffer,
+ GLint *x, GLint *y,
+ GLsizei *width, GLsizei *height );
+
+extern GLboolean driFillInModes( __GLcontextModes ** modes,
+ GLenum fb_format, GLenum fb_type,
+ const u_int8_t * depth_bits, const u_int8_t * stencil_bits,
+ unsigned num_depth_stencil_bits,
+ const GLenum * db_modes, unsigned num_db_modes, int visType );
+
+#endif /* DRI_DEBUG_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/vblank.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/vblank.c
new file mode 100644
index 000000000..eebe42d96
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/vblank.c
@@ -0,0 +1,347 @@
+/* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * (c) Copyright IBM Corporation 2002
+ * 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
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Ian Romanick <idr@us.ibm.com>
+ */
+/* $XFree86:$ */
+
+#include "glheader.h"
+#include "xf86drm.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "dd.h"
+#include "vblank.h"
+#include "xmlpool.h"
+
+
+/****************************************************************************/
+/**
+ * Get the current MSC refresh counter.
+ *
+ * Stores the 64-bit count of vertical refreshes since some (arbitrary)
+ * point in time in \c count. Unless the value wraps around, which it
+ * may, it will never decrease.
+ *
+ * \warning This function is called from \c glXGetVideoSyncSGI, which expects
+ * a \c count of type \c unsigned (32-bit), and \c glXGetSyncValuesOML, which
+ * expects a \c count of type \c int64_t (signed 64-bit). The kernel ioctl
+ * currently always returns a \c sequence of type \c unsigned.
+ *
+ * \param priv Pointer to the DRI screen private struct.
+ * \param count Storage to hold MSC counter.
+ * \return Zero is returned on success. A negative errno value
+ * is returned on failure.
+ */
+int driGetMSC32( __DRIscreenPrivate * priv, int64_t * count )
+{
+ drmVBlank vbl;
+ int ret;
+
+ /* Don't wait for anything. Just get the current refresh count. */
+
+ vbl.request.type = DRM_VBLANK_RELATIVE;
+ vbl.request.sequence = 0;
+
+ ret = drmWaitVBlank( priv->fd, &vbl );
+ *count = (int64_t)vbl.reply.sequence;
+
+ return ret;
+}
+
+
+/****************************************************************************/
+/**
+ * Wait for a specified refresh count. This implements most of the
+ * functionality of \c glXWaitForMscOML from the GLX_OML_sync_control spec.
+ * Waits for the \c target_msc refresh. If that has already passed, it
+ * waits until \f$(MSC \bmod divisor)\f$ is equal to \c remainder. If
+ * \c target_msc is 0, use the behavior of glXWaitVideoSyncSGI(), which
+ * omits the initial check against a target MSC value.
+ *
+ * This function is actually something of a hack. The problem is that, at
+ * the time of this writing, none of the existing DRM modules support an
+ * ioctl that returns a 64-bit count (at least not on 32-bit platforms).
+ * However, this function exists to support a GLX function that requires
+ * the use of 64-bit counts. As such, there is a little bit of ugly
+ * hackery at the end of this function to make the 32-bit count act like
+ * a 64-bit count. There are still some cases where this will break, but
+ * I believe it catches the most common cases.
+ *
+ * The real solution is to provide an ioctl that uses a 64-bit count.
+ *
+ * \param dpy Pointer to the \c Display.
+ * \param priv Pointer to the DRI drawable private.
+ * \param target_msc Desired refresh count to wait for. A value of 0
+ * means to use the glXWaitVideoSyncSGI() behavior.
+ * \param divisor MSC divisor if \c target_msc is already reached.
+ * \param remainder Desired MSC remainder if \c target_msc is already
+ * reached.
+ * \param msc Buffer to hold MSC when done waiting.
+ *
+ * \return Zero on success or \c GLX_BAD_CONTEXT on failure.
+ */
+
+int driWaitForMSC32( __DRIdrawablePrivate *priv,
+ int64_t target_msc, int64_t divisor, int64_t remainder,
+ int64_t * msc )
+{
+ drmVBlank vbl;
+
+
+ if ( divisor != 0 ) {
+ unsigned int target = (unsigned int)target_msc;
+ unsigned int next = target;
+ unsigned int r;
+ int dont_wait = (target_msc == 0);
+
+ do {
+ /* dont_wait means we're using the glXWaitVideoSyncSGI() behavior.
+ * The first time around, just get the current count and proceed
+ * to the test for (MSC % divisor) == remainder.
+ */
+ vbl.request.type = dont_wait ? DRM_VBLANK_RELATIVE :
+ DRM_VBLANK_ABSOLUTE;
+ vbl.request.sequence = next;
+
+ if ( drmWaitVBlank( priv->driScreenPriv->fd, &vbl ) != 0 ) {
+ /* FIXME: This doesn't seem like the right thing to return here.
+ */
+ return GLX_BAD_CONTEXT;
+ }
+
+ dont_wait = 0;
+ if (target_msc != 0 && vbl.reply.sequence == target)
+ break;
+
+ /* Assuming the wait-done test fails, the next refresh to wait for
+ * will be one that satisfies (MSC % divisor) == remainder. The
+ * value (MSC - (MSC % divisor) + remainder) is the refresh value
+ * closest to the current value that would satisfy the equation.
+ * If this refresh has already happened, we add divisor to obtain
+ * the next refresh after the current one that will satisfy it.
+ */
+ r = (vbl.reply.sequence % (unsigned int)divisor);
+ next = (vbl.reply.sequence - r + (unsigned int)remainder);
+ if (next <= vbl.reply.sequence) next += (unsigned int)divisor;
+
+ } while ( r != (unsigned int)remainder );
+ }
+ else {
+ /* If the \c divisor is zero, just wait until the MSC is greater
+ * than or equal to \c target_msc.
+ */
+
+ vbl.request.type = DRM_VBLANK_ABSOLUTE;
+ vbl.request.sequence = target_msc;
+
+ if ( drmWaitVBlank( priv->driScreenPriv->fd, &vbl ) != 0 ) {
+ /* FIXME: This doesn't seem like the right thing to return here.
+ */
+ return GLX_BAD_CONTEXT;
+ }
+ }
+
+ *msc = (target_msc & 0xffffffff00000000LL);
+ *msc |= vbl.reply.sequence;
+ if ( *msc < target_msc ) {
+ *msc += 0x0000000100000000LL;
+ }
+
+ return 0;
+}
+
+
+/****************************************************************************/
+/**
+ * Gets a set of default vertical-blank-wait flags based on the internal GLX
+ * API version and several configuration options.
+ */
+
+GLuint driGetDefaultVBlankFlags( const driOptionCache *optionCache )
+{
+ GLuint flags = VBLANK_FLAG_INTERVAL;
+ int vblank_mode;
+
+
+ if ( driCheckOption( optionCache, "vblank_mode", DRI_ENUM ) )
+ vblank_mode = driQueryOptioni( optionCache, "vblank_mode" );
+ else
+ vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
+
+ switch (vblank_mode) {
+ case DRI_CONF_VBLANK_NEVER:
+ flags = 0;
+ break;
+ case DRI_CONF_VBLANK_DEF_INTERVAL_0:
+ break;
+ case DRI_CONF_VBLANK_DEF_INTERVAL_1:
+ flags |= VBLANK_FLAG_THROTTLE;
+ break;
+ case DRI_CONF_VBLANK_ALWAYS_SYNC:
+ flags |= VBLANK_FLAG_SYNC;
+ break;
+ }
+
+ return flags;
+}
+
+
+/****************************************************************************/
+/**
+ * Sets the default swap interval when the drawable is first bound to a
+ * direct rendering context.
+ */
+
+void driDrawableInitVBlank( __DRIdrawablePrivate *priv, GLuint flags )
+{
+ if ( priv->pdraw->swap_interval == (unsigned)-1 ) {
+ priv->pdraw->swap_interval = (flags & VBLANK_FLAG_THROTTLE) != 0 ? 1 : 0;
+ }
+}
+
+
+/****************************************************************************/
+/**
+ * Wrapper to call \c drmWaitVBlank. The main purpose of this function is to
+ * wrap the error message logging. The error message should only be logged
+ * the first time the \c drmWaitVBlank fails. If \c drmWaitVBlank is
+ * successful, \c vbl_seq will be set the sequence value in the reply.
+ *
+ * \param vbl Pointer to drmVBlank packet desribing how to wait.
+ * \param vbl_seq Location to store the current refresh counter.
+ * \param fd File descriptor use to call into the DRM.
+ * \return Zero on success or -1 on failure.
+ */
+
+static int do_wait( drmVBlank * vbl, GLuint * vbl_seq, int fd )
+{
+ int ret;
+
+
+ ret = drmWaitVBlank( fd, vbl );
+ if ( ret != 0 ) {
+ static GLboolean first_time = GL_TRUE;
+
+ if ( first_time ) {
+ fprintf(stderr,
+ "%s: drmWaitVBlank returned %d, IRQs don't seem to be"
+ " working correctly.\nTry running with LIBGL_THROTTLE_REFRESH"
+ " and LIBL_SYNC_REFRESH unset.\n", __FUNCTION__, ret);
+ first_time = GL_FALSE;
+ }
+
+ return -1;
+ }
+
+ *vbl_seq = vbl->reply.sequence;
+ return 0;
+}
+
+
+/****************************************************************************/
+/**
+ * Waits for the vertical blank for use with glXSwapBuffers.
+ *
+ * \param vbl_seq Vertical blank sequence number (MSC) after the last buffer
+ * swap. Updated after this wait.
+ * \param flags \c VBLANK_FLAG bits that control how long to wait.
+ * \param missed_deadline Set to \c GL_TRUE if the MSC after waiting is later
+ * than the "target" based on \c flags. The idea is that if
+ * \c missed_deadline is set, then the application is not
+ * achieving its desired framerate.
+ * \return Zero on success, -1 on error.
+ */
+
+int
+driWaitForVBlank( const __DRIdrawablePrivate *priv, GLuint * vbl_seq,
+ GLuint flags, GLboolean * missed_deadline )
+{
+ drmVBlank vbl;
+ unsigned original_seq;
+ unsigned deadline;
+ unsigned interval;
+
+
+ *missed_deadline = GL_FALSE;
+ if ( (flags & (VBLANK_FLAG_INTERVAL |
+ VBLANK_FLAG_THROTTLE |
+ VBLANK_FLAG_SYNC)) == 0 ||
+ (flags & VBLANK_FLAG_NO_IRQ) != 0 ) {
+ return 0;
+ }
+
+
+ /* VBLANK_FLAG_SYNC means to wait for at least one vertical blank. If
+ * that flag is not set, do a fake wait for zero vertical blanking
+ * periods so that we can get the current MSC.
+ *
+ * VBLANK_FLAG_INTERVAL and VBLANK_FLAG_THROTTLE mean to wait for at
+ * least one vertical blank since the last wait. Since do_wait modifies
+ * vbl_seq, we have to save the original value of vbl_seq for the
+ * VBLANK_FLAG_INTERVAL / VBLANK_FLAG_THROTTLE calculation later.
+ */
+
+ original_seq = *vbl_seq;
+
+ vbl.request.sequence = ((flags & VBLANK_FLAG_SYNC) != 0) ? 1 : 0;
+ vbl.request.type = DRM_VBLANK_RELATIVE;
+
+ if ( do_wait( & vbl, vbl_seq, priv->driScreenPriv->fd ) != 0 ) {
+ return -1;
+ }
+
+
+ vbl.request.type = DRM_VBLANK_ABSOLUTE;
+
+ if ( (flags & VBLANK_FLAG_INTERVAL) != 0 ) {
+ interval = priv->pdraw->swap_interval;
+ /* this must have been initialized when the drawable was first bound
+ * to a direct rendering context. */
+ assert ( interval != (unsigned)-1 );
+ }
+ else if ( (flags & VBLANK_FLAG_THROTTLE) != 0 ) {
+ interval = 1;
+ }
+ else {
+ interval = 0;
+ }
+
+
+ /* Wait until the next vertical blank. If the interval is zero, then
+ * the deadline is one vertical blank after the previous wait.
+ */
+
+ vbl.request.sequence = original_seq + interval;
+ if ( *vbl_seq < vbl.request.sequence ) {
+ if ( do_wait( & vbl, vbl_seq, priv->driScreenPriv->fd ) != 0 ) {
+ return -1;
+ }
+ }
+
+ deadline = original_seq + ((interval == 0) ? 1 : interval);
+ *missed_deadline = ( *vbl_seq > deadline );
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/vblank.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/vblank.h
new file mode 100644
index 000000000..3dc965def
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/vblank.h
@@ -0,0 +1,69 @@
+/* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * (c) Copyright IBM Corporation 2002
+ * 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
+ * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Ian Romanick <idr@us.ibm.com>
+ */
+/* $XFree86:$ */
+
+#ifndef DRI_VBLANK_H
+#define DRI_VBLANK_H
+
+#include "context.h"
+#include "dri_util.h"
+#include "xmlconfig.h"
+
+#define VBLANK_FLAG_INTERVAL (1U << 0) /* Respect the swap_interval setting
+ */
+#define VBLANK_FLAG_THROTTLE (1U << 1) /* Wait 1 refresh since last call.
+ */
+#define VBLANK_FLAG_SYNC (1U << 2) /* Sync to the next refresh.
+ */
+#define VBLANK_FLAG_NO_IRQ (1U << 7) /* DRM has no IRQ to wait on.
+ */
+
+extern int driGetMSC32( __DRIscreenPrivate * priv, int64_t * count );
+extern int driWaitForMSC32( __DRIdrawablePrivate *priv,
+ int64_t target_msc, int64_t divisor, int64_t remainder, int64_t * msc );
+extern GLuint driGetDefaultVBlankFlags( const driOptionCache *optionCache );
+extern void driDrawableInitVBlank ( __DRIdrawablePrivate *priv, GLuint flags );
+extern int driWaitForVBlank( const __DRIdrawablePrivate *priv,
+ GLuint * vbl_seq, GLuint flags, GLboolean * missed_deadline );
+
+#undef usleep
+#include <unistd.h> /* for usleep() */
+#include <sched.h> /* for sched_yield() */
+
+#ifdef linux
+#include <sched.h> /* for sched_yield() */
+#endif
+
+#define DO_USLEEP(nr) \
+ do { \
+ if (0) fprintf(stderr, "%s: usleep for %u\n", __FUNCTION__, nr ); \
+ if (1) usleep( nr ); \
+ sched_yield(); \
+ } while( 0 )
+
+#endif /* DRI_VBLANK_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlconfig.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlconfig.c
new file mode 100644
index 000000000..b635894fe
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlconfig.c
@@ -0,0 +1,1002 @@
+/*
+ * XML DRI client-side driver configuration
+ * Copyright (C) 2003 Felix Kuehling
+ *
+ * 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
+ * FELIX KUEHLING, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+/**
+ * \file xmlconfig.c
+ * \brief Driver-independent client-side part of the XML configuration
+ * \author Felix Kuehling
+ */
+
+#include "glheader.h"
+
+#include <string.h>
+#include <assert.h>
+#include <expat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include "imports.h"
+#include "dri_util.h"
+#include "xmlconfig.h"
+
+/*
+ * OS dependent ways of getting the name of the running program
+ */
+#if (defined(__unix__) || defined(unix)) && !defined(USG)
+#include <sys/param.h>
+#endif
+
+#undef GET_PROGRAM_NAME
+
+#if (defined(__GNU_LIBRARY__) || defined(__GLIBC__)) && !defined(__UCLIBC__)
+# if !defined(__GLIBC__) || (__GLIBC__ < 2)
+/* These aren't declared in any libc5 header */
+extern char *program_invocation_name, *program_invocation_short_name;
+# endif
+# define GET_PROGRAM_NAME() program_invocation_short_name
+#elif defined(__FreeBSD__) && (__FreeBSD__ >= 2)
+# include <osreldate.h>
+# if (__FreeBSD_version >= 440000)
+# include <stdlib.h>
+# define GET_PROGRAM_NAME() getprogname()
+# endif
+#elif defined(__NetBSD__) && defined(__NetBSD_Version) && (__NetBSD_Version >= 106000100)
+# include <stdlib.h>
+# define GET_PROGRAM_NAME() getprogname()
+#endif
+
+#if !defined(GET_PROGRAM_NAME)
+# if defined(OpenBSD) || defined(NetBSD) || defined(__UCLIBC__)
+/* This is a hack. It's said to work on OpenBSD, NetBSD and GNU.
+ * Rogelio M.Serrano Jr. reported it's also working with UCLIBC. It's
+ * used as a last resort, if there is no documented facility available. */
+static const char *__getProgramName () {
+ extern const char *__progname;
+ char * arg = strrchr(__progname, '/');
+ if (arg)
+ return arg+1;
+ else
+ return __progname;
+}
+# define GET_PROGRAM_NAME() __getProgramName()
+# else
+# define GET_PROGRAM_NAME() ""
+# warning "Per application configuration won't work with your OS version."
+# endif
+#endif
+
+/** \brief Find an option in an option cache with the name as key */
+static GLuint findOption (const driOptionCache *cache, const char *name) {
+ GLuint len = strlen (name);
+ GLuint size = 1 << cache->tableSize, mask = size - 1;
+ GLuint hash = 0;
+ GLuint i, shift;
+
+ /* compute a hash from the variable length name */
+ for (i = 0, shift = 0; i < len; ++i, shift = (shift+8) & 31)
+ hash += (GLuint)name[i] << shift;
+ hash *= hash;
+ hash = (hash >> (16-cache->tableSize/2)) & mask;
+
+ /* this is just the starting point of the linear search for the option */
+ for (i = 0; i < size; ++i, hash = (hash+1) & mask) {
+ /* if we hit an empty entry then the option is not defined (yet) */
+ if (cache->info[hash].name == 0)
+ break;
+ else if (!strcmp (name, cache->info[hash].name))
+ break;
+ }
+ /* this assertion fails if the hash table is full */
+ assert (i < size);
+
+ return hash;
+}
+
+/** \brief Count the real number of options in an option cache */
+static GLuint countOptions (const driOptionCache *cache) {
+ GLuint size = 1 << cache->tableSize;
+ GLuint i, count = 0;
+ for (i = 0; i < size; ++i)
+ if (cache->info[i].name)
+ count++;
+ return count;
+}
+
+/** \brief Like strdup but using MALLOC and with error checking. */
+#define XSTRDUP(dest,source) do { \
+ GLuint len = strlen (source); \
+ if (!(dest = MALLOC (len+1))) { \
+ fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__); \
+ abort(); \
+ } \
+ memcpy (dest, source, len+1); \
+} while (0)
+
+static int compare (const void *a, const void *b) {
+ return strcmp (*(char *const*)a, *(char *const*)b);
+}
+/** \brief Binary search in a string array. */
+static GLuint bsearchStr (const XML_Char *name,
+ const XML_Char *elems[], GLuint count) {
+ const XML_Char **found;
+ found = bsearch (&name, elems, count, sizeof (XML_Char *), compare);
+ if (found)
+ return found - elems;
+ else
+ return count;
+}
+
+/** \brief Locale-independent integer parser.
+ *
+ * Works similar to strtol. Leading space is NOT skipped. The input
+ * number may have an optional sign. Radix is specified by base. If
+ * base is 0 then decimal is assumed unless the input number is
+ * prefixed by 0x or 0X for hexadecimal or 0 for octal. After
+ * returning tail points to the first character that is not part of
+ * the integer number. If no number was found then tail points to the
+ * start of the input string. */
+static GLint strToI (const XML_Char *string, const XML_Char **tail, int base) {
+ GLint radix = base == 0 ? 10 : base;
+ GLint result = 0;
+ GLint sign = 1;
+ GLboolean numberFound = GL_FALSE;
+ const XML_Char *start = string;
+
+ assert (radix >= 2 && radix <= 36);
+
+ if (*string == '-') {
+ sign = -1;
+ string++;
+ } else if (*string == '+')
+ string++;
+ if (base == 0 && *string == '0') {
+ numberFound = GL_TRUE;
+ if (*(string+1) == 'x' || *(string+1) == 'X') {
+ radix = 16;
+ string += 2;
+ } else {
+ radix = 8;
+ string++;
+ }
+ }
+ do {
+ GLint digit = -1;
+ if (radix <= 10) {
+ if (*string >= '0' && *string < '0' + radix)
+ digit = *string - '0';
+ } else {
+ if (*string >= '0' && *string <= '9')
+ digit = *string - '0';
+ else if (*string >= 'a' && *string < 'a' + radix - 10)
+ digit = *string - 'a' + 10;
+ else if (*string >= 'A' && *string < 'A' + radix - 10)
+ digit = *string - 'A' + 10;
+ }
+ if (digit != -1) {
+ numberFound = GL_TRUE;
+ result = radix*result + digit;
+ string++;
+ } else
+ break;
+ } while (GL_TRUE);
+ *tail = numberFound ? string : start;
+ return sign * result;
+}
+
+/** \brief Locale-independent floating-point parser.
+ *
+ * Works similar to strtod. Leading space is NOT skipped. The input
+ * number may have an optional sign. '.' is interpreted as decimal
+ * point and may occor at most once. Optionally the number may end in
+ * [eE]<exponent>, where <exponent> is an integer as recognized by
+ * strToI. In that case the result is number * 10^exponent. After
+ * returning tail points to the first character that is not part of
+ * the floating point number. If no number was found then tail points
+ * to the start of the input string.
+ *
+ * Uses two passes for maximum accuracy. */
+static GLfloat strToF (const XML_Char *string, const XML_Char **tail) {
+ GLint nDigits = 0, pointPos, exponent;
+ GLfloat sign = 1.0f, result = 0.0f, scale;
+ const XML_Char *start = string, *numStart;
+
+ /* sign */
+ if (*string == '-') {
+ sign = -1.0f;
+ string++;
+ } else if (*string == '+')
+ string++;
+
+ /* first pass: determine position of decimal point, number of
+ * digits, exponent and the end of the number. */
+ numStart = string;
+ while (*string >= '0' && *string <= '9') {
+ string++;
+ nDigits++;
+ }
+ pointPos = nDigits;
+ if (*string == '.') {
+ string++;
+ while (*string >= '0' && *string <= '9') {
+ string++;
+ nDigits++;
+ }
+ }
+ if (nDigits == 0) {
+ /* no digits, no number */
+ *tail = start;
+ return 0.0f;
+ }
+ *tail = string;
+ if (*string == 'e' || *string == 'E') {
+ const XML_Char *expTail;
+ exponent = strToI (string+1, &expTail, 10);
+ if (expTail == string+1)
+ exponent = 0;
+ else
+ *tail = expTail;
+ } else
+ exponent = 0;
+ string = numStart;
+
+ /* scale of the first digit */
+ scale = sign * (GLfloat)pow (10.0, (GLdouble)(pointPos-1 + exponent));
+
+ /* second pass: parse digits */
+ do {
+ if (*string != '.') {
+ assert (*string >= '0' && *string <= '9');
+ result += scale * (GLfloat)(*string - '0');
+ scale *= 0.1f;
+ nDigits--;
+ }
+ string++;
+ } while (nDigits > 0);
+
+ return result;
+}
+
+/** \brief Parse a value of a given type. */
+static GLboolean parseValue (driOptionValue *v, driOptionType type,
+ const XML_Char *string) {
+ const XML_Char *tail;
+ /* skip leading white-space */
+ string += strspn (string, " \f\n\r\t\v");
+ switch (type) {
+ case DRI_BOOL:
+ if (!strcmp (string, "false")) {
+ v->_bool = GL_FALSE;
+ tail = string + 5;
+ } else if (!strcmp (string, "true")) {
+ v->_bool = GL_TRUE;
+ tail = string + 4;
+ }
+ else
+ return GL_FALSE;
+ break;
+ case DRI_ENUM: /* enum is just a special integer */
+ case DRI_INT:
+ v->_int = strToI (string, &tail, 0);
+ break;
+ case DRI_FLOAT:
+ v->_float = strToF (string, &tail);
+ break;
+ }
+
+ if (tail == string)
+ return GL_FALSE; /* empty string (or containing only white-space) */
+ /* skip trailing white space */
+ if (*tail)
+ tail += strspn (tail, " \f\n\r\t\v");
+ if (*tail)
+ return GL_FALSE; /* something left over that is not part of value */
+
+ return GL_TRUE;
+}
+
+/** \brief Parse a list of ranges of type info->type. */
+static GLboolean parseRanges (driOptionInfo *info, const XML_Char *string) {
+ XML_Char *cp, *range;
+ GLuint nRanges, i;
+ driOptionRange *ranges;
+
+ XSTRDUP (cp, string);
+ /* pass 1: determine the number of ranges (number of commas + 1) */
+ range = cp;
+ for (nRanges = 1; *range; ++range)
+ if (*range == ',')
+ ++nRanges;
+
+ if ((ranges = MALLOC (nRanges*sizeof(driOptionRange))) == NULL) {
+ fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__);
+ abort();
+ }
+
+ /* pass 2: parse all ranges into preallocated array */
+ range = cp;
+ for (i = 0; i < nRanges; ++i) {
+ XML_Char *end, *sep;
+ assert (range);
+ end = strchr (range, ',');
+ if (end)
+ *end = '\0';
+ sep = strchr (range, ':');
+ if (sep) { /* non-empty interval */
+ *sep = '\0';
+ if (!parseValue (&ranges[i].start, info->type, range) ||
+ !parseValue (&ranges[i].end, info->type, sep+1))
+ break;
+ if (info->type == DRI_INT &&
+ ranges[i].start._int > ranges[i].end._int)
+ break;
+ if (info->type == DRI_FLOAT &&
+ ranges[i].start._float > ranges[i].end._float)
+ break;
+ } else { /* empty interval */
+ if (!parseValue (&ranges[i].start, info->type, range))
+ break;
+ ranges[i].end = ranges[i].start;
+ }
+ if (end)
+ range = end+1;
+ else
+ range = NULL;
+ }
+ FREE (cp);
+ if (i < nRanges) {
+ FREE (ranges);
+ return GL_FALSE;
+ } else
+ assert (range == NULL);
+
+ info->nRanges = nRanges;
+ info->ranges = ranges;
+ return GL_TRUE;
+}
+
+/** \brief Check if a value is in one of info->ranges. */
+static GLboolean checkValue (const driOptionValue *v, const driOptionInfo *info) {
+ GLuint i;
+ assert (info->type != DRI_BOOL); /* should be caught by the parser */
+ if (info->nRanges == 0)
+ return GL_TRUE;
+ switch (info->type) {
+ case DRI_ENUM: /* enum is just a special integer */
+ case DRI_INT:
+ for (i = 0; i < info->nRanges; ++i)
+ if (v->_int >= info->ranges[i].start._int &&
+ v->_int <= info->ranges[i].end._int)
+ return GL_TRUE;
+ break;
+ case DRI_FLOAT:
+ for (i = 0; i < info->nRanges; ++i)
+ if (v->_float >= info->ranges[i].start._float &&
+ v->_float <= info->ranges[i].end._float)
+ return GL_TRUE;
+ break;
+ default:
+ assert (0); /* should never happen */
+ }
+ return GL_FALSE;
+}
+
+/** \brief Output a warning message. */
+#define XML_WARNING1(msg) do {\
+ __driUtilMessage ("Warning in %s line %d, column %d: "msg, data->name, \
+ XML_GetCurrentLineNumber(data->parser), \
+ XML_GetCurrentColumnNumber(data->parser)); \
+} while (0)
+#define XML_WARNING(msg,args...) do { \
+ __driUtilMessage ("Warning in %s line %d, column %d: "msg, data->name, \
+ XML_GetCurrentLineNumber(data->parser), \
+ XML_GetCurrentColumnNumber(data->parser), \
+ args); \
+} while (0)
+/** \brief Output an error message. */
+#define XML_ERROR1(msg) do { \
+ __driUtilMessage ("Error in %s line %d, column %d: "msg, data->name, \
+ XML_GetCurrentLineNumber(data->parser), \
+ XML_GetCurrentColumnNumber(data->parser)); \
+} while (0)
+#define XML_ERROR(msg,args...) do { \
+ __driUtilMessage ("Error in %s line %d, column %d: "msg, data->name, \
+ XML_GetCurrentLineNumber(data->parser), \
+ XML_GetCurrentColumnNumber(data->parser), \
+ args); \
+} while (0)
+/** \brief Output a fatal error message and abort. */
+#define XML_FATAL1(msg) do { \
+ fprintf (stderr, "Fatal error in %s line %d, column %d: "msg"\n", \
+ data->name, \
+ XML_GetCurrentLineNumber(data->parser), \
+ XML_GetCurrentColumnNumber(data->parser)); \
+ abort();\
+} while (0)
+#define XML_FATAL(msg,args...) do { \
+ fprintf (stderr, "Fatal error in %s line %d, column %d: "msg"\n", \
+ data->name, \
+ XML_GetCurrentLineNumber(data->parser), \
+ XML_GetCurrentColumnNumber(data->parser), \
+ args); \
+ abort();\
+} while (0)
+
+/** \brief Parser context for __driConfigOptions. */
+struct OptInfoData {
+ const char *name;
+ XML_Parser parser;
+ driOptionCache *cache;
+ GLboolean inDriInfo;
+ GLboolean inSection;
+ GLboolean inDesc;
+ GLboolean inOption;
+ GLboolean inEnum;
+ int curOption;
+};
+
+/** \brief Elements in __driConfigOptions. */
+enum OptInfoElem {
+ OI_DESCRIPTION = 0, OI_DRIINFO, OI_ENUM, OI_OPTION, OI_SECTION, OI_COUNT
+};
+static const XML_Char *OptInfoElems[] = {
+ "description", "driinfo", "enum", "option", "section"
+};
+
+/** \brief Parse attributes of an enum element.
+ *
+ * We're not actually interested in the data. Just make sure this is ok
+ * for external configuration tools.
+ */
+static void parseEnumAttr (struct OptInfoData *data, const XML_Char **attr) {
+ GLuint i;
+ const XML_Char *value = NULL, *text = NULL;
+ driOptionValue v;
+ GLuint opt = data->curOption;
+ for (i = 0; attr[i]; i += 2) {
+ if (!strcmp (attr[i], "value")) value = attr[i+1];
+ else if (!strcmp (attr[i], "text")) text = attr[i+1];
+ else XML_FATAL("illegal enum attribute: %s.", attr[i]);
+ }
+ if (!value) XML_FATAL1 ("value attribute missing in enum.");
+ if (!text) XML_FATAL1 ("text attribute missing in enum.");
+ if (!parseValue (&v, data->cache->info[opt].type, value))
+ XML_FATAL ("illegal enum value: %s.", value);
+ if (!checkValue (&v, &data->cache->info[opt]))
+ XML_FATAL ("enum value out of valid range: %s.", value);
+}
+
+/** \brief Parse attributes of a description element.
+ *
+ * We're not actually interested in the data. Just make sure this is ok
+ * for external configuration tools.
+ */
+static void parseDescAttr (struct OptInfoData *data, const XML_Char **attr) {
+ GLuint i;
+ const XML_Char *lang = NULL, *text = NULL;
+ for (i = 0; attr[i]; i += 2) {
+ if (!strcmp (attr[i], "lang")) lang = attr[i+1];
+ else if (!strcmp (attr[i], "text")) text = attr[i+1];
+ else XML_FATAL("illegal description attribute: %s.", attr[i]);
+ }
+ if (!lang) XML_FATAL1 ("lang attribute missing in description.");
+ if (!text) XML_FATAL1 ("text attribute missing in description.");
+}
+
+/** \brief Parse attributes of an option element. */
+static void parseOptInfoAttr (struct OptInfoData *data, const XML_Char **attr) {
+ enum OptAttr {OA_DEFAULT = 0, OA_NAME, OA_TYPE, OA_VALID, OA_COUNT};
+ static const XML_Char *optAttr[] = {"default", "name", "type", "valid"};
+ const XML_Char *attrVal[OA_COUNT] = {NULL, NULL, NULL, NULL};
+ const char *defaultVal;
+ driOptionCache *cache = data->cache;
+ GLuint opt, i;
+ for (i = 0; attr[i]; i += 2) {
+ GLuint attrName = bsearchStr (attr[i], optAttr, OA_COUNT);
+ if (attrName >= OA_COUNT)
+ XML_FATAL ("illegal option attribute: %s", attr[i]);
+ attrVal[attrName] = attr[i+1];
+ }
+ if (!attrVal[OA_NAME]) XML_FATAL1 ("name attribute missing in option.");
+ if (!attrVal[OA_TYPE]) XML_FATAL1 ("type attribute missing in option.");
+ if (!attrVal[OA_DEFAULT]) XML_FATAL1 ("default attribute missing in option.");
+
+ opt = findOption (cache, attrVal[OA_NAME]);
+ if (cache->info[opt].name)
+ XML_FATAL ("option %s redefined.", attrVal[OA_NAME]);
+ data->curOption = opt;
+
+ XSTRDUP (cache->info[opt].name, attrVal[OA_NAME]);
+
+ if (!strcmp (attrVal[OA_TYPE], "bool"))
+ cache->info[opt].type = DRI_BOOL;
+ else if (!strcmp (attrVal[OA_TYPE], "enum"))
+ cache->info[opt].type = DRI_ENUM;
+ else if (!strcmp (attrVal[OA_TYPE], "int"))
+ cache->info[opt].type = DRI_INT;
+ else if (!strcmp (attrVal[OA_TYPE], "float"))
+ cache->info[opt].type = DRI_FLOAT;
+ else
+ XML_FATAL ("illegal type in option: %s.", attrVal[OA_TYPE]);
+
+ defaultVal = getenv (cache->info[opt].name);
+ if (defaultVal != NULL) {
+ /* don't use XML_WARNING, we want the user to see this! */
+ fprintf (stderr,
+ "ATTENTION: default value of option %s overridden by environment.\n",
+ cache->info[opt].name);
+ } else
+ defaultVal = attrVal[OA_DEFAULT];
+ if (!parseValue (&cache->values[opt], cache->info[opt].type, defaultVal))
+ XML_FATAL ("illegal default value: %s.", defaultVal);
+
+ if (attrVal[OA_VALID]) {
+ if (cache->info[opt].type == DRI_BOOL)
+ XML_FATAL1 ("boolean option with valid attribute.");
+ if (!parseRanges (&cache->info[opt], attrVal[OA_VALID]))
+ XML_FATAL ("illegal valid attribute: %s.", attrVal[OA_VALID]);
+ if (!checkValue (&cache->values[opt], &cache->info[opt]))
+ XML_FATAL ("default value out of valid range '%s': %s.",
+ attrVal[OA_VALID], defaultVal);
+ } else if (cache->info[opt].type == DRI_ENUM) {
+ XML_FATAL1 ("valid attribute missing in option (mandatory for enums).");
+ } else {
+ cache->info[opt].nRanges = 0;
+ cache->info[opt].ranges = NULL;
+ }
+}
+
+/** \brief Handler for start element events. */
+static void optInfoStartElem (void *userData, const XML_Char *name,
+ const XML_Char **attr) {
+ struct OptInfoData *data = (struct OptInfoData *)userData;
+ enum OptInfoElem elem = bsearchStr (name, OptInfoElems, OI_COUNT);
+ switch (elem) {
+ case OI_DRIINFO:
+ if (data->inDriInfo)
+ XML_FATAL1 ("nested <driinfo> elements.");
+ if (attr[0])
+ XML_FATAL1 ("attributes specified on <driinfo> element.");
+ data->inDriInfo = GL_TRUE;
+ break;
+ case OI_SECTION:
+ if (!data->inDriInfo)
+ XML_FATAL1 ("<section> must be inside <driinfo>.");
+ if (data->inSection)
+ XML_FATAL1 ("nested <section> elements.");
+ if (attr[0])
+ XML_FATAL1 ("attributes specified on <section> element.");
+ data->inSection = GL_TRUE;
+ break;
+ case OI_DESCRIPTION:
+ if (!data->inSection && !data->inOption)
+ XML_FATAL1 ("<description> must be inside <description> or <option.");
+ if (data->inDesc)
+ XML_FATAL1 ("nested <description> elements.");
+ data->inDesc = GL_TRUE;
+ parseDescAttr (data, attr);
+ break;
+ case OI_OPTION:
+ if (!data->inSection)
+ XML_FATAL1 ("<option> must be inside <section>.");
+ if (data->inDesc)
+ XML_FATAL1 ("<option> nested in <description> element.");
+ if (data->inOption)
+ XML_FATAL1 ("nested <option> elements.");
+ data->inOption = GL_TRUE;
+ parseOptInfoAttr (data, attr);
+ break;
+ case OI_ENUM:
+ if (!(data->inOption && data->inDesc))
+ XML_FATAL1 ("<enum> must be inside <option> and <description>.");
+ if (data->inEnum)
+ XML_FATAL1 ("nested <enum> elements.");
+ data->inEnum = GL_TRUE;
+ parseEnumAttr (data, attr);
+ break;
+ default:
+ XML_FATAL ("unknown element: %s.", name);
+ }
+}
+
+/** \brief Handler for end element events. */
+static void optInfoEndElem (void *userData, const XML_Char *name) {
+ struct OptInfoData *data = (struct OptInfoData *)userData;
+ enum OptInfoElem elem = bsearchStr (name, OptInfoElems, OI_COUNT);
+ switch (elem) {
+ case OI_DRIINFO:
+ data->inDriInfo = GL_FALSE;
+ break;
+ case OI_SECTION:
+ data->inSection = GL_FALSE;
+ break;
+ case OI_DESCRIPTION:
+ data->inDesc = GL_FALSE;
+ break;
+ case OI_OPTION:
+ data->inOption = GL_FALSE;
+ break;
+ case OI_ENUM:
+ data->inEnum = GL_FALSE;
+ break;
+ default:
+ assert (0); /* should have been caught by StartElem */
+ }
+}
+
+void driParseOptionInfo (driOptionCache *info,
+ const char *configOptions, GLuint nConfigOptions) {
+ XML_Parser p;
+ int status;
+ struct OptInfoData userData;
+ struct OptInfoData *data = &userData;
+ GLuint realNoptions;
+
+ /* determine hash table size and allocate memory:
+ * 3/2 of the number of options, rounded up, so there remains always
+ * at least one free entry. This is needed for detecting undefined
+ * options in configuration files without getting a hash table overflow.
+ * Round this up to a power of two. */
+ GLuint minSize = (nConfigOptions*3 + 1) / 2;
+ GLuint size, log2size;
+ for (size = 1, log2size = 0; size < minSize; size <<= 1, ++log2size);
+ info->tableSize = log2size;
+ info->info = CALLOC (size * sizeof (driOptionInfo));
+ info->values = CALLOC (size * sizeof (driOptionValue));
+ if (info->info == NULL || info->values == NULL) {
+ fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__);
+ abort();
+ }
+
+ p = XML_ParserCreate ("UTF-8"); /* always UTF-8 */
+ XML_SetElementHandler (p, optInfoStartElem, optInfoEndElem);
+ XML_SetUserData (p, data);
+
+ userData.name = "__driConfigOptions";
+ userData.parser = p;
+ userData.cache = info;
+ userData.inDriInfo = GL_FALSE;
+ userData.inSection = GL_FALSE;
+ userData.inDesc = GL_FALSE;
+ userData.inOption = GL_FALSE;
+ userData.inEnum = GL_FALSE;
+ userData.curOption = -1;
+
+ status = XML_Parse (p, configOptions, strlen (configOptions), 1);
+ if (!status)
+ XML_FATAL ("%s.", XML_ErrorString(XML_GetErrorCode(p)));
+
+ XML_ParserFree (p);
+
+ /* Check if the actual number of options matches nConfigOptions.
+ * A mismatch is not fatal (a hash table overflow would be) but we
+ * want the driver developer's attention anyway. */
+ realNoptions = countOptions (info);
+ if (realNoptions != nConfigOptions) {
+ fprintf (stderr,
+ "Error: nConfigOptions (%u) does not match the actual number of options in\n"
+ " __driConfigOptions (%u).\n",
+ nConfigOptions, realNoptions);
+ }
+}
+
+/** \brief Parser context for configuration files. */
+struct OptConfData {
+ const char *name;
+ XML_Parser parser;
+ driOptionCache *cache;
+ GLint screenNum;
+ const char *driverName, *execName;
+ GLuint ignoringDevice;
+ GLuint ignoringApp;
+ GLuint inDriConf;
+ GLuint inDevice;
+ GLuint inApp;
+ GLuint inOption;
+};
+
+/** \brief Elements in configuration files. */
+enum OptConfElem {
+ OC_APPLICATION = 0, OC_DEVICE, OC_DRICONF, OC_OPTION, OC_COUNT
+};
+static const XML_Char *OptConfElems[] = {
+ "application", "device", "driconf", "option"
+};
+
+/** \brief Parse attributes of a device element. */
+static void parseDeviceAttr (struct OptConfData *data, const XML_Char **attr) {
+ GLuint i;
+ const XML_Char *driver = NULL, *screen = NULL;
+ for (i = 0; attr[i]; i += 2) {
+ if (!strcmp (attr[i], "driver")) driver = attr[i+1];
+ else if (!strcmp (attr[i], "screen")) screen = attr[i+1];
+ else XML_WARNING("unkown device attribute: %s.", attr[i]);
+ }
+ if (driver && strcmp (driver, data->driverName))
+ data->ignoringDevice = data->inDevice;
+ else if (screen) {
+ driOptionValue screenNum;
+ if (!parseValue (&screenNum, DRI_INT, screen))
+ XML_WARNING("illegal screen number: %s.", screen);
+ else if (screenNum._int != data->screenNum)
+ data->ignoringDevice = data->inDevice;
+ }
+}
+
+/** \brief Parse attributes of an application element. */
+static void parseAppAttr (struct OptConfData *data, const XML_Char **attr) {
+ GLuint i;
+ const XML_Char *name = NULL, *exec = NULL;
+ for (i = 0; attr[i]; i += 2) {
+ if (!strcmp (attr[i], "name")) name = attr[i+1];
+ else if (!strcmp (attr[i], "executable")) exec = attr[i+1];
+ else XML_WARNING("unkown application attribute: %s.", attr[i]);
+ }
+ if (exec && strcmp (exec, data->execName))
+ data->ignoringApp = data->inApp;
+}
+
+/** \brief Parse attributes of an option element. */
+static void parseOptConfAttr (struct OptConfData *data, const XML_Char **attr) {
+ GLuint i;
+ const XML_Char *name = NULL, *value = NULL;
+ for (i = 0; attr[i]; i += 2) {
+ if (!strcmp (attr[i], "name")) name = attr[i+1];
+ else if (!strcmp (attr[i], "value")) value = attr[i+1];
+ else XML_WARNING("unkown option attribute: %s.", attr[i]);
+ }
+ if (!name) XML_WARNING1 ("name attribute missing in option.");
+ if (!value) XML_WARNING1 ("value attribute missing in option.");
+ if (name && value) {
+ driOptionCache *cache = data->cache;
+ GLuint opt = findOption (cache, name);
+ if (cache->info[opt].name == NULL)
+ XML_WARNING ("undefined option: %s.", name);
+ else if (getenv (cache->info[opt].name))
+ /* don't use XML_WARNING, we want the user to see this! */
+ fprintf (stderr, "ATTENTION: option value of option %s ignored.\n",
+ cache->info[opt].name);
+ else if (!parseValue (&cache->values[opt], cache->info[opt].type, value))
+ XML_WARNING ("illegal option value: %s.", value);
+ }
+}
+
+/** \brief Handler for start element events. */
+static void optConfStartElem (void *userData, const XML_Char *name,
+ const XML_Char **attr) {
+ struct OptConfData *data = (struct OptConfData *)userData;
+ enum OptConfElem elem = bsearchStr (name, OptConfElems, OC_COUNT);
+ switch (elem) {
+ case OC_DRICONF:
+ if (data->inDriConf)
+ XML_WARNING1 ("nested <driconf> elements.");
+ if (attr[0])
+ XML_WARNING1 ("attributes specified on <driconf> element.");
+ data->inDriConf++;
+ break;
+ case OC_DEVICE:
+ if (!data->inDriConf)
+ XML_WARNING1 ("<device> should be inside <driconf>.");
+ if (data->inDevice)
+ XML_WARNING1 ("nested <device> elements.");
+ data->inDevice++;
+ if (!data->ignoringDevice && !data->ignoringApp)
+ parseDeviceAttr (data, attr);
+ break;
+ case OC_APPLICATION:
+ if (!data->inDevice)
+ XML_WARNING1 ("<application> should be inside <device>.");
+ if (data->inApp)
+ XML_WARNING1 ("nested <application> elements.");
+ data->inApp++;
+ if (!data->ignoringDevice && !data->ignoringApp)
+ parseAppAttr (data, attr);
+ break;
+ case OC_OPTION:
+ if (!data->inApp)
+ XML_WARNING1 ("<option> should be inside <application>.");
+ if (data->inOption)
+ XML_WARNING1 ("nested <option> elements.");
+ data->inOption++;
+ if (!data->ignoringDevice && !data->ignoringApp)
+ parseOptConfAttr (data, attr);
+ break;
+ default:
+ XML_WARNING ("unknown element: %s.", name);
+ }
+}
+
+/** \brief Handler for end element events. */
+static void optConfEndElem (void *userData, const XML_Char *name) {
+ struct OptConfData *data = (struct OptConfData *)userData;
+ enum OptConfElem elem = bsearchStr (name, OptConfElems, OC_COUNT);
+ switch (elem) {
+ case OC_DRICONF:
+ data->inDriConf--;
+ break;
+ case OC_DEVICE:
+ if (data->inDevice-- == data->ignoringDevice)
+ data->ignoringDevice = 0;
+ break;
+ case OC_APPLICATION:
+ if (data->inApp-- == data->ignoringApp)
+ data->ignoringApp = 0;
+ break;
+ case OC_OPTION:
+ data->inOption--;
+ break;
+ default:
+ /* unknown element, warning was produced on start tag */;
+ }
+}
+
+/** \brief Initialize an option cache based on info */
+static void initOptionCache (driOptionCache *cache, const driOptionCache *info) {
+ cache->info = info->info;
+ cache->tableSize = info->tableSize;
+ cache->values = MALLOC ((1<<info->tableSize) * sizeof (driOptionValue));
+ if (cache->values == NULL) {
+ fprintf (stderr, "%s: %d: out of memory.\n", __FILE__, __LINE__);
+ abort();
+ }
+ memcpy (cache->values, info->values,
+ (1<<info->tableSize) * sizeof (driOptionValue));
+}
+
+/** \brief Parse the named configuration file */
+static void parseOneConfigFile (XML_Parser p) {
+#define BUF_SIZE 0x1000
+ struct OptConfData *data = (struct OptConfData *)XML_GetUserData (p);
+ int status;
+ int fd;
+
+ if ((fd = open (data->name, O_RDONLY)) == -1) {
+ __driUtilMessage ("Can't open configuration file %s: %s.",
+ data->name, strerror (errno));
+ return;
+ }
+
+ while (1) {
+ int bytesRead;
+ void *buffer = XML_GetBuffer (p, BUF_SIZE);
+ if (!buffer) {
+ __driUtilMessage ("Can't allocate parser buffer.");
+ break;
+ }
+ bytesRead = read (fd, buffer, BUF_SIZE);
+ if (bytesRead == -1) {
+ __driUtilMessage ("Error reading from configuration file %s: %s.",
+ data->name, strerror (errno));
+ break;
+ }
+ status = XML_ParseBuffer (p, bytesRead, bytesRead == 0);
+ if (!status) {
+ XML_ERROR ("%s.", XML_ErrorString(XML_GetErrorCode(p)));
+ break;
+ }
+ if (bytesRead == 0)
+ break;
+ }
+
+ close (fd);
+#undef BUF_SIZE
+}
+
+void driParseConfigFiles (driOptionCache *cache, const driOptionCache *info,
+ GLint screenNum, const char *driverName) {
+ char *filenames[2] = {"/etc/drirc", NULL};
+ char *home;
+ GLuint i;
+ struct OptConfData userData;
+
+ initOptionCache (cache, info);
+
+ userData.cache = cache;
+ userData.screenNum = screenNum;
+ userData.driverName = driverName;
+ userData.execName = GET_PROGRAM_NAME();
+
+ if ((home = getenv ("HOME"))) {
+ GLuint len = strlen (home);
+ filenames[1] = MALLOC (len + 7+1);
+ if (filenames[1] == NULL)
+ __driUtilMessage ("Can't allocate memory for %s/.drirc.", home);
+ else {
+ memcpy (filenames[1], home, len);
+ memcpy (filenames[1] + len, "/.drirc", 7+1);
+ }
+ }
+
+ for (i = 0; i < 2; ++i) {
+ XML_Parser p;
+ if (filenames[i] == NULL)
+ continue;
+
+ p = XML_ParserCreate (NULL); /* use encoding specified by file */
+ XML_SetElementHandler (p, optConfStartElem, optConfEndElem);
+ XML_SetUserData (p, &userData);
+ userData.parser = p;
+ userData.name = filenames[i];
+ userData.ignoringDevice = 0;
+ userData.ignoringApp = 0;
+ userData.inDriConf = 0;
+ userData.inDevice = 0;
+ userData.inApp = 0;
+ userData.inOption = 0;
+
+ parseOneConfigFile (p);
+ XML_ParserFree (p);
+ }
+
+ if (filenames[1])
+ FREE (filenames[1]);
+}
+
+void driDestroyOptionInfo (driOptionCache *info) {
+ driDestroyOptionCache (info);
+ if (info->info) {
+ GLuint i, size = 1 << info->tableSize;
+ for (i = 0; i < size; ++i) {
+ if (info->info[i].name) {
+ FREE (info->info[i].name);
+ if (info->info[i].ranges)
+ FREE (info->info[i].ranges);
+ }
+ }
+ FREE (info->info);
+ }
+}
+
+void driDestroyOptionCache (driOptionCache *cache) {
+ if (cache->values)
+ FREE (cache->values);
+}
+
+GLboolean driCheckOption (const driOptionCache *cache, const char *name,
+ driOptionType type) {
+ GLuint i = findOption (cache, name);
+ return cache->info[i].name != NULL && cache->info[i].type == type;
+}
+
+GLboolean driQueryOptionb (const driOptionCache *cache, const char *name) {
+ GLuint i = findOption (cache, name);
+ /* make sure the option is defined and has the correct type */
+ assert (cache->info[i].name != NULL);
+ assert (cache->info[i].type == DRI_BOOL);
+ return cache->values[i]._bool;
+}
+
+GLint driQueryOptioni (const driOptionCache *cache, const char *name) {
+ GLuint i = findOption (cache, name);
+ /* make sure the option is defined and has the correct type */
+ assert (cache->info[i].name != NULL);
+ assert (cache->info[i].type == DRI_INT || cache->info[i].type == DRI_ENUM);
+ return cache->values[i]._int;
+}
+
+GLfloat driQueryOptionf (const driOptionCache *cache, const char *name) {
+ GLuint i = findOption (cache, name);
+ /* make sure the option is defined and has the correct type */
+ assert (cache->info[i].name != NULL);
+ assert (cache->info[i].type == DRI_FLOAT);
+ return cache->values[i]._float;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlconfig.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlconfig.h
new file mode 100644
index 000000000..c363af764
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlconfig.h
@@ -0,0 +1,124 @@
+/*
+ * XML DRI client-side driver configuration
+ * Copyright (C) 2003 Felix Kuehling
+ *
+ * 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
+ * FELIX KUEHLING, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+/**
+ * \file xmlconfig.h
+ * \brief Driver-independent client-side part of the XML configuration
+ * \author Felix Kuehling
+ */
+
+#ifndef __XMLCONFIG_H
+#define __XMLCONFIG_H
+
+/** \brief Option data types */
+typedef enum driOptionType {
+ DRI_BOOL, DRI_ENUM, DRI_INT, DRI_FLOAT
+} driOptionType;
+
+/** \brief Option value */
+typedef union driOptionValue {
+ GLboolean _bool; /**< \brief Boolean */
+ GLint _int; /**< \brief Integer or Enum */
+ GLfloat _float; /**< \brief Floating-point */
+} driOptionValue;
+
+/** \brief Single range of valid values
+ *
+ * For empty ranges (a single value) start == end */
+typedef struct driOptionRange {
+ driOptionValue start; /**< \brief Start */
+ driOptionValue end; /**< \brief End */
+} driOptionRange;
+
+/** \brief Information about an option */
+typedef struct driOptionInfo {
+ char *name; /**< \brief Name */
+ driOptionType type; /**< \brief Type */
+ driOptionRange *ranges; /**< \brief Array of ranges */
+ GLuint nRanges; /**< \brief Number of ranges */
+} driOptionInfo;
+
+/** \brief Option cache
+ *
+ * \li One in <driver>Screen caching option info and the default values
+ * \li One in each <driver>Context with the actual values for that context */
+typedef struct driOptionCache {
+ driOptionInfo *info;
+ /**< \brief Array of option infos
+ *
+ * Points to the same array in the screen and all contexts */
+ driOptionValue *values;
+ /**< \brief Array of option values
+ *
+ * \li Default values in screen
+ * \li Actual values in contexts
+ */
+ GLuint tableSize;
+ /**< \brief Size of the arrays
+ *
+ * Depending on the hash function this may differ from __driNConfigOptions.
+ * In the current implementation it's not actually a size but log2(size).
+ * The value is the same in the screen and all contexts. */
+} driOptionCache;
+
+/** \brief Parse XML option info from configOptions
+ *
+ * To be called in <driver>CreateScreen
+ *
+ * \param info pointer to a driOptionCache that will store the option info
+ * \param configOptions XML document describing available configuration opts
+ * \param nConfigOptions number of options, used to choose a hash table size
+ *
+ * For the option information to be available to external configuration tools
+ * it must be a public symbol __driConfigOptions. It is also passed as a
+ * parameter to driParseOptionInfo in order to avoid driver-independent code
+ * depending on symbols in driver-specific code. */
+void driParseOptionInfo (driOptionCache *info,
+ const char *configOptions, GLuint nConfigOptions);
+/** \brief Initialize option cache from info and parse configuration files
+ *
+ * To be called in <driver>CreateContext. screenNum and driverName select
+ * device sections. */
+void driParseConfigFiles (driOptionCache *cache, const driOptionCache *info,
+ GLint screenNum, const char *driverName);
+/** \brief Destroy option info
+ *
+ * To be called in <driver>DestroyScreen */
+void driDestroyOptionInfo (driOptionCache *info);
+/** \brief Destroy option cache
+ *
+ * To be called in <driver>DestroyContext */
+void driDestroyOptionCache (driOptionCache *cache);
+
+/** \brief Check if there exists a certain option */
+GLboolean driCheckOption (const driOptionCache *cache, const char *name,
+ driOptionType type);
+
+/** \brief Query a boolean option value */
+GLboolean driQueryOptionb (const driOptionCache *cache, const char *name);
+/** \brief Query an integer option value */
+GLint driQueryOptioni (const driOptionCache *cache, const char *name);
+/** \brief Query a floating-point option value */
+GLfloat driQueryOptionf (const driOptionCache *cache, const char *name);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool.h
new file mode 100644
index 000000000..7fbc6e800
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool.h
@@ -0,0 +1,94 @@
+/*
+ * XML DRI client-side driver configuration
+ * Copyright (C) 2003 Felix Kuehling
+ *
+ * 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
+ * FELIX KUEHLING, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+/**
+ * \file xmlpool.h
+ * \brief Pool of common options
+ * \author Felix Kuehling
+ *
+ * This file defines macros that can be used to construct
+ * driConfigOptions in the drivers. Common options are defined in
+ * xmlpool/t_options.h from which xmlpool/options.h is generated with
+ * translations. This file defines generic helper macros and includes
+ * xmlpool/options.h.
+ */
+
+#ifndef __XMLPOOL_H
+#define __XMLPOOL_H
+
+/*
+ * generic macros
+ */
+
+/** \brief Begin __driConfigOptions */
+#define DRI_CONF_BEGIN \
+"<driinfo>\n"
+
+/** \brief End __driConfigOptions */
+#define DRI_CONF_END \
+"</driinfo>\n"
+
+/** \brief Begin a section of related options */
+#define DRI_CONF_SECTION_BEGIN \
+"<section>\n"
+
+/** \brief End a section of related options */
+#define DRI_CONF_SECTION_END \
+"</section>\n"
+
+/** \brief Begin an option definition */
+#define DRI_CONF_OPT_BEGIN(name,type,def) \
+"<option name=\""#name"\" type=\""#type"\" default=\""#def"\">\n"
+
+/** \brief Begin an option definition with restrictions on valid values */
+#define DRI_CONF_OPT_BEGIN_V(name,type,def,valid) \
+"<option name=\""#name"\" type=\""#type"\" default=\""#def"\" valid=\""valid"\">\n"
+
+/** \brief End an option description */
+#define DRI_CONF_OPT_END \
+"</option>\n"
+
+/** \brief A verbal description in a specified language (empty version) */
+#define DRI_CONF_DESC(lang,text) \
+"<description lang=\""#lang"\" text=\""text"\"/>\n"
+
+/** \brief A verbal description in a specified language */
+#define DRI_CONF_DESC_BEGIN(lang,text) \
+"<description lang=\""#lang"\" text=\""text"\">\n"
+
+/** \brief End a description */
+#define DRI_CONF_DESC_END \
+"</description>\n"
+
+/** \brief A verbal description of an enum value */
+#define DRI_CONF_ENUM(value,text) \
+"<enum value=\""#value"\" text=\""text"\"/>\n"
+
+
+/*
+ * Predefined option sections and options with multi-lingual descriptions
+ * are now automatically generated.
+ */
+#include "xmlpool/options.h"
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/Makefile
new file mode 100644
index 000000000..ef94541c3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/Makefile
@@ -0,0 +1,96 @@
+# Convenient makefile for managing translations.
+
+# Prerequisites:
+# - GNU gettext
+# - Python
+
+# Adding new translations
+# -----------------------
+
+# To start working on a new translation edit the POS=... line
+# below. If you want to add for example a french translation, add
+# fr.po.
+
+# Then run "make po" to generate a fresh .po file from translatable
+# strings in t_options.h. Now you can edit the new .po file (fr.po in
+# the example above) to translate the strings. Please make sure that
+# your editor encodes the file in UTF-8.
+
+# Updating existing translations
+# ------------------------------
+
+# Run "make po" to update .po files with new translatable strings from
+# t_options.h. Now you can edit the .po files you're interested
+# in. Please make sure that your editor encodes the file in UTF-8.
+
+# Updating options.h
+# ------------------
+
+# Finally run "make" to generate options.h from t_options.h with all
+# translations. Now you can rebuild the drivers. Any common options
+# used by the drivers will have option descriptions with the latest
+# translations.
+
+# Publishing translations
+# -----------------------
+
+# To get your translation(s) into Mesa CVS, please send me your
+# <lang>.po file.
+
+# More information:
+# - info gettext
+
+# The set of supported languages. Add languages as needed.
+POS=de.po es.po nl.po fr.po
+
+#
+# Don't change anything below, unless you know what you're doing.
+#
+LANGS=$(POS:%.po=%)
+MOS=$(POS:%.po=%/LC_MESSAGES/options.mo)
+POT=xmlpool.pot
+
+.PHONY: all clean pot po mo
+
+all: options.h
+
+# Only intermediate files are cleaned up. options.h is not deleted because
+# it's in CVS.
+clean:
+ rm -f $(POT) *~
+ rm -rf $(LANGS)
+
+# Default target options.h
+options.h: t_options.h mo
+ python gen_xmlpool.py $(LANGS) > options.h
+
+# Update .mo files from the corresponding .po files.
+mo:
+ @for mo in $(MOS); do \
+ lang=$${mo%%/*}; \
+ echo "Updating $$mo from $$lang.po."; \
+ mkdir -p $${mo%/*}; \
+ msgfmt -o $$mo $$lang.po; \
+ done
+
+# Use this target to create or update .po files with new messages in
+# driconf.py.
+po: $(POS)
+
+pot: $(POT)
+
+# Extract message catalog from driconf.py.
+$(POT): t_options.h
+ xgettext -L C --from-code utf-8 -o $(POT) t_options.h
+
+# Create or update a .po file for a specific language.
+%.po: $(POT)
+ @if [ -f $@ ]; then \
+ echo "Merging new strings from $(POT) into $@."; \
+ mv $@ $@~; \
+ msgmerge -o $@ $@~ $(POT); \
+ else \
+ echo "Initializing $@ from $(POT)."; \
+ msginit -i $(POT) -o $@~ --locale=$*; \
+ sed -e 's/charset=.*\\n/charset=UTF-8\\n/' $@~ > $@; \
+ fi
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/de.po b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/de.po
new file mode 100644
index 000000000..e287d0fe7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/de.po
@@ -0,0 +1,231 @@
+# German translations for DRI driver options.
+# Copyright (C) 2005 Felix Kuehling
+# This file is distributed under the same license as the Mesa package.
+# Felix Kuehling <fxkuehl@gmx.de>, 2005.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Mesa 6.3\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2005-04-11 23:19+0200\n"
+"PO-Revision-Date: 2005-04-11 01:34+0200\n"
+"Last-Translator: Felix Kuehling <fxkuehl@gmx.de>\n"
+"Language-Team: German <de@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: t_options.h:53
+msgid "Debugging"
+msgstr "Fehlersuche"
+
+#: t_options.h:57
+msgid "Disable 3D acceleration"
+msgstr "3D-Beschleunigung abschalten"
+
+#: t_options.h:62
+msgid "Show performance boxes"
+msgstr "Zeige Performanceboxen"
+
+#: t_options.h:69
+msgid "Image Quality"
+msgstr "Bildqualität"
+
+#: t_options.h:77
+msgid "Texture color depth"
+msgstr "Texturfarbtiefe"
+
+#: t_options.h:78
+msgid "Prefer frame buffer color depth"
+msgstr "Bevorzuge Farbtiefe des Framebuffers"
+
+#: t_options.h:79
+msgid "Prefer 32 bits per texel"
+msgstr "Bevorzuge 32 bits pro Texel"
+
+#: t_options.h:80
+msgid "Prefer 16 bits per texel"
+msgstr "Bevorzuge 16 bits pro Texel"
+
+#: t_options.h:81
+msgid "Force 16 bits per texel"
+msgstr "Erzwinge 16 bits pro Texel"
+
+#: t_options.h:87
+msgid "Initial maximum value for anisotropic texture filtering"
+msgstr "Initialer Maximalwert für anisotropische Texturfilterung"
+
+#: t_options.h:92
+msgid "Forbid negative texture LOD bias"
+msgstr "Verbiete negative Textur-Detailgradverschiebung"
+
+#: t_options.h:97
+msgid ""
+"Enable S3TC texture compression even if software support is not available"
+msgstr ""
+"Aktiviere S3TC Texturkomprimierung auch wenn die nötige "
+"Softwareunterstützung fehlt"
+
+#: t_options.h:104
+msgid "Initial color reduction method"
+msgstr "Initiale Farbreduktionsmethode"
+
+#: t_options.h:105
+msgid "Round colors"
+msgstr "Farben runden"
+
+#: t_options.h:106
+msgid "Dither colors"
+msgstr "Farben rastern"
+
+#: t_options.h:114
+msgid "Color rounding method"
+msgstr "Farbrundungsmethode"
+
+#: t_options.h:115
+msgid "Round color components downward"
+msgstr "Farbkomponenten abrunden"
+
+#: t_options.h:116
+msgid "Round to nearest color"
+msgstr "Zur ähnlichsten Farbe runden"
+
+#: t_options.h:125
+msgid "Color dithering method"
+msgstr "Farbrasterungsmethode"
+
+#: t_options.h:126
+msgid "Horizontal error diffusion"
+msgstr "Horizontale Fehlerstreuung"
+
+#: t_options.h:127
+msgid "Horizontal error diffusion, reset error at line start"
+msgstr "Horizontale Fehlerstreuung, Fehler am Zeilenanfang zurücksetzen"
+
+#: t_options.h:128
+msgid "Ordered 2D color dithering"
+msgstr "Geordnete 2D Farbrasterung"
+
+#: t_options.h:134
+msgid "Floating point depth buffer"
+msgstr "Fließkomma z-Puffer"
+
+#: t_options.h:140
+msgid "Performance"
+msgstr "Leistung"
+
+#: t_options.h:148
+msgid "TCL mode (Transformation, Clipping, Lighting)"
+msgstr "TCL-Modus (Transformation, Clipping, Licht)"
+
+#: t_options.h:149
+msgid "Use software TCL pipeline"
+msgstr "Benutze die Software-TCL-Pipeline"
+
+#: t_options.h:150
+msgid "Use hardware TCL as first TCL pipeline stage"
+msgstr "Benutze Hardware TCL als erste Stufe der TCL-Pipeline"
+
+#: t_options.h:151
+msgid "Bypass the TCL pipeline"
+msgstr "Umgehe die TCL-Pipeline"
+
+#: t_options.h:152
+msgid ""
+"Bypass the TCL pipeline with state-based machine code generated on-the-fly"
+msgstr ""
+"Umgehe die TCL-Pipeline mit zur Laufzeit erzeugtem, zustandsbasiertem "
+"Maschinencode"
+
+#: t_options.h:161
+msgid "Method to limit rendering latency"
+msgstr "Methode zur Begrenzung der Bildverzögerung"
+
+#: t_options.h:162
+msgid "Busy waiting for the graphics hardware"
+msgstr "Aktives Warten auf die Grafikhardware"
+
+#: t_options.h:163
+msgid "Sleep for brief intervals while waiting for the graphics hardware"
+msgstr "Kurze Schlafintervalle beim Warten auf die Grafikhardware"
+
+#: t_options.h:164
+msgid "Let the graphics hardware emit a software interrupt and sleep"
+msgstr ""
+"Die Grafikhardware eine Softwareunterbrechnung erzeugen lassen und schlafen"
+
+#: t_options.h:174
+msgid "Synchronization with vertical refresh (swap intervals)"
+msgstr "Synchronisation mit der vertikalen Bildwiederholung"
+
+#: t_options.h:175
+msgid "Never synchronize with vertical refresh, ignore application's choice"
+msgstr ""
+"Niemals mit der Bildwiederholung synchronisieren, Anweisungen der Anwendung "
+"ignorieren"
+
+#: t_options.h:176
+msgid "Initial swap interval 0, obey application's choice"
+msgstr "Initiales Bildinterval 0, Anweisungen der Anwendung gehorchen"
+
+#: t_options.h:177
+msgid "Initial swap interval 1, obey application's choice"
+msgstr "Initiales Bildinterval 1, Anweisungen der Anwendung gehorchen"
+
+#: t_options.h:178
+msgid ""
+"Always synchronize with vertical refresh, application chooses the minimum "
+"swap interval"
+msgstr ""
+"Immer mit der Bildwiederholung synchronisieren, Anwendung wählt das minmale "
+"Bildinterval"
+
+#: t_options.h:186
+msgid "Use HyperZ to boost performance"
+msgstr "HyperZ zur Leistungssteigerung verwenden"
+
+#: t_options.h:191
+msgid "Number of texture units used"
+msgstr "Anzahl der benutzten Textureinheiten"
+
+#: t_options.h:196
+msgid ""
+"Enable hack to allow larger textures with texture compression on radeon/r200"
+msgstr ""
+"Hack aktivieren, der mit Texturkompression auf radeon/r200 größere Texturen "
+"erlaubt"
+
+#: t_options.h:201
+msgid "Texture filtering quality vs. speed, AKA “brilinear†texture filtering"
+msgstr ""
+"Texturfilterqualität versus -geschwindigkeit, auch bekannt als „brilineare“ "
+"Texturfilterung"
+
+#: t_options.h:209
+msgid "Used types of texture memory"
+msgstr "Benutzte Arten von Texturspeicher"
+
+#: t_options.h:210
+msgid "All available memory"
+msgstr "Aller verfügbarer Speicher"
+
+#: t_options.h:211
+msgid "Only card memory (if available)"
+msgstr "Nur Grafikspeicher (falls verfügbar)"
+
+#: t_options.h:212
+msgid "Only GART (AGP/PCIE) memory (if available)"
+msgstr "Nur GART-Speicher (AGP/PCIE) (falls verfügbar)"
+
+#: t_options.h:220
+msgid "Features that are not hardware-accelerated"
+msgstr "Funktionalität, die nicht hardwarebeschleunigt ist"
+
+#: t_options.h:224
+msgid "Enable extension GL_ARB_vertex_program"
+msgstr "Erweiterung GL_ARB_vertex_program aktivieren"
+
+#: t_options.h:229
+msgid "Enable extension GL_NV_vertex_program"
+msgstr "Erweiterung GL_NV_vertex_program aktivieren"
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/es.po b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/es.po
new file mode 100644
index 000000000..82ad177cb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/es.po
@@ -0,0 +1,219 @@
+# translation of es.po to Spanish
+# Spanish translations for PACKAGE package.
+# Copyright (C) 2005 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# David <deifo@ono.com>, 2005.
+# David Rubio Miguélez <deifo@ono.com>, 2005.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: es\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2005-04-12 12:18+0200\n"
+"PO-Revision-Date: 2005-04-12 20:26+0200\n"
+"Last-Translator: David Rubio Miguélez <deifo@ono.com>\n"
+"Language-Team: Spanish <es@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+"X-Generator: KBabel 1.10\n"
+
+#: t_options.h:53
+msgid "Debugging"
+msgstr "Depurando"
+
+#: t_options.h:57
+msgid "Disable 3D acceleration"
+msgstr "Desactivar aceleración 3D"
+
+#: t_options.h:62
+msgid "Show performance boxes"
+msgstr "Mostrar cajas de rendimiento"
+
+#: t_options.h:69
+msgid "Image Quality"
+msgstr "Calidad de imagen"
+
+#: t_options.h:77
+msgid "Texture color depth"
+msgstr "Profundidad de color de textura"
+
+#: t_options.h:78
+msgid "Prefer frame buffer color depth"
+msgstr "Preferir profundidad de color del \"framebuffer\""
+
+#: t_options.h:79
+msgid "Prefer 32 bits per texel"
+msgstr "Preferir 32 bits por texel"
+
+#: t_options.h:80
+msgid "Prefer 16 bits per texel"
+msgstr "Preferir 16 bits por texel"
+
+#: t_options.h:81
+msgid "Force 16 bits per texel"
+msgstr "Forzar a 16 bits por texel"
+
+#: t_options.h:87
+msgid "Initial maximum value for anisotropic texture filtering"
+msgstr "Valor máximo inicial para filtrado anisotrópico de textura"
+
+#: t_options.h:92
+msgid "Forbid negative texture LOD bias"
+msgstr "Prohibir valores negativos de Nivel De Detalle (LOD) de texturas"
+
+#: t_options.h:97
+msgid "Enable S3TC texture compression even if software support is not available"
+msgstr "Activar la compresión de texturas S3TC incluso si el soporte por software no está disponible"
+
+#: t_options.h:104
+msgid "Initial color reduction method"
+msgstr "Método inicial de reducción de color"
+
+#: t_options.h:105
+msgid "Round colors"
+msgstr "Colores redondeados"
+
+#: t_options.h:106
+msgid "Dither colors"
+msgstr "Colores suavizados"
+
+#: t_options.h:114
+msgid "Color rounding method"
+msgstr "Método de redondeo de colores"
+
+#: t_options.h:115
+msgid "Round color components downward"
+msgstr "Redondear hacia abajo los componentes de color"
+
+#: t_options.h:116
+msgid "Round to nearest color"
+msgstr "Redondear al color más cercano"
+
+#: t_options.h:125
+msgid "Color dithering method"
+msgstr "Método de suavizado de color"
+
+#: t_options.h:126
+msgid "Horizontal error diffusion"
+msgstr "Difusión de error horizontal"
+
+#: t_options.h:127
+msgid "Horizontal error diffusion, reset error at line start"
+msgstr "Difusión de error horizontal, reiniciar error al comienzo de línea"
+
+#: t_options.h:128
+msgid "Ordered 2D color dithering"
+msgstr "Suavizado de color 2D ordenado"
+
+#: t_options.h:134
+msgid "Floating point depth buffer"
+msgstr "Búfer de profundidad en coma flotante"
+
+#: t_options.h:140
+msgid "Performance"
+msgstr "Rendimiento"
+
+#: t_options.h:148
+msgid "TCL mode (Transformation, Clipping, Lighting)"
+msgstr "Modo TCL (Transformación, Recorte, Iluminación)"
+
+#: t_options.h:149
+msgid "Use software TCL pipeline"
+msgstr "Usar tubería TCL por software"
+
+#: t_options.h:150
+msgid "Use hardware TCL as first TCL pipeline stage"
+msgstr "Usar TCL por hardware en la primera fase de la tubería TCL"
+
+#: t_options.h:151
+msgid "Bypass the TCL pipeline"
+msgstr "Pasar por alto la tubería TCL"
+
+#: t_options.h:152
+msgid "Bypass the TCL pipeline with state-based machine code generated on-the-fly"
+msgstr "Pasar por alto la tubería TCL con código máquina basado en estados generado al vuelo"
+
+#: t_options.h:161
+msgid "Method to limit rendering latency"
+msgstr "Método para limitar la latencia de rénder"
+
+#: t_options.h:162
+msgid "Busy waiting for the graphics hardware"
+msgstr "Esperar activamente al hardware gráfico"
+
+#: t_options.h:163
+msgid "Sleep for brief intervals while waiting for the graphics hardware"
+msgstr "Dormir en intervalos cortos mientras se espera al hardware gráfico"
+
+#: t_options.h:164
+msgid "Let the graphics hardware emit a software interrupt and sleep"
+msgstr "Permitir que el hardware gráfico emita una interrupción de software y duerma"
+
+#: t_options.h:174
+msgid "Synchronization with vertical refresh (swap intervals)"
+msgstr "Sincronización con el refresco vertical (intervalos de intercambio)"
+
+#: t_options.h:175
+msgid "Never synchronize with vertical refresh, ignore application's choice"
+msgstr "No sincronizar nunca con el refresco vertical, ignorar la elección de la aplicación"
+
+#: t_options.h:176
+msgid "Initial swap interval 0, obey application's choice"
+msgstr "Intervalo de intercambio inicial 0, obedecer la elección de la aplicación"
+
+#: t_options.h:177
+msgid "Initial swap interval 1, obey application's choice"
+msgstr "Intervalo de intercambio inicial 1, obedecer la elección de la aplicación"
+
+#: t_options.h:178
+msgid ""
+"Always synchronize with vertical refresh, application chooses the minimum "
+"swap interval"
+msgstr "Sincronizar siempre con el refresco vertical, la aplicación elige el intervalo de intercambio mínimo"
+
+#: t_options.h:186
+msgid "Use HyperZ to boost performance"
+msgstr "Usar HyperZ para potenciar rendimiento"
+
+#: t_options.h:191
+msgid "Number of texture units used"
+msgstr "Número de unidades de textura usadas"
+
+#: t_options.h:196
+msgid "Enable hack to allow larger textures with texture compression on radeon/r200"
+msgstr "Activar \"hack\" para permitir texturas más grandes con compresión de textura activada en la Radeon/r200"
+
+#: t_options.h:201
+msgid "Texture filtering quality vs. speed, AKA “brilinear†texture filtering"
+msgstr "Calidad de filtrado de textura vs. velocidad, alias filtrado \"brilinear\" de textura"
+
+#: t_options.h:209
+msgid "Used types of texture memory"
+msgstr "Tipos de memoria de textura usados"
+
+#: t_options.h:210
+msgid "All available memory"
+msgstr "Toda la memoria disponible"
+
+#: t_options.h:211
+msgid "Only card memory (if available)"
+msgstr "Sólo la memoria de la tarjeta (si disponible)"
+
+#: t_options.h:212
+msgid "Only GART (AGP/PCIE) memory (if available)"
+msgstr "Sólo memoria GART (AGP/PCIE) (si disponible)"
+
+#: t_options.h:220
+msgid "Features that are not hardware-accelerated"
+msgstr "Características no aceleradas por hardware"
+
+#: t_options.h:224
+msgid "Enable extension GL_ARB_vertex_program"
+msgstr "Activar la extensión GL_ARB_vertex_program"
+
+#: t_options.h:229
+msgid "Enable extension GL_NV_vertex_program"
+msgstr "Activar extensión GL_NV_vertex_program"
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/fr.po b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/fr.po
new file mode 100644
index 000000000..19f3b4a4e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/fr.po
@@ -0,0 +1,225 @@
+# French translations for DRI driver options.
+# Copyright (C) 2005 Stephane Marchesin
+# This file is distributed under the same license as the Mesa package.
+# Stephane Marchesin <marchesin@icps.u-strasbg.fr>, 2005.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Mesa 6.3\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2005-04-11 23:19+0200\n"
+"PO-Revision-Date: 2005-04-11 01:34+0200\n"
+"Last-Translator: Stephane Marchesin <marchesin@icps.u-strasbg.fr>\n"
+"Language-Team: French <fr@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: t_options.h:53
+msgid "Debugging"
+msgstr "Debogage"
+
+#: t_options.h:57
+msgid "Disable 3D acceleration"
+msgstr "Désactiver l'accélération 3D"
+
+#: t_options.h:62
+msgid "Show performance boxes"
+msgstr "Afficher les boîtes de performance"
+
+#: t_options.h:69
+msgid "Image Quality"
+msgstr "Qualité d'image"
+
+#: t_options.h:77
+msgid "Texture color depth"
+msgstr "Profondeur de texture"
+
+#: t_options.h:78
+msgid "Prefer frame buffer color depth"
+msgstr "Profondeur de couleur"
+
+#: t_options.h:79
+msgid "Prefer 32 bits per texel"
+msgstr "Préférer 32 bits par texel"
+
+#: t_options.h:80
+msgid "Prefer 16 bits per texel"
+msgstr "Prérérer 16 bits par texel"
+
+#: t_options.h:81
+msgid "Force 16 bits per texel"
+msgstr "Forcer 16 bits par texel"
+
+#: t_options.h:87
+msgid "Initial maximum value for anisotropic texture filtering"
+msgstr "Valeur maximale initiale pour le filtrage anisotropique de texture"
+
+#: t_options.h:92
+msgid "Forbid negative texture LOD bias"
+msgstr "Interdire le LOD bias negatif"
+
+#: t_options.h:97
+msgid ""
+"Enable S3TC texture compression even if software support is not available"
+msgstr ""
+"Activer la compression de texture S3TC même si le support logiciel est absent"
+
+#: t_options.h:104
+msgid "Initial color reduction method"
+msgstr "Technique de réduction de couleurs"
+
+#: t_options.h:105
+msgid "Round colors"
+msgstr "Arrondir les valeurs de couleur"
+
+#: t_options.h:106
+msgid "Dither colors"
+msgstr "Tramer les couleurs"
+
+#: t_options.h:114
+msgid "Color rounding method"
+msgstr "Méthode d'arrondi des couleurs"
+
+#: t_options.h:115
+msgid "Round color components downward"
+msgstr "Arrondi à l'inférieur"
+
+#: t_options.h:116
+msgid "Round to nearest color"
+msgstr "Arrondi au plus proche"
+
+#: t_options.h:125
+msgid "Color dithering method"
+msgstr "Méthode de tramage"
+
+#: t_options.h:126
+msgid "Horizontal error diffusion"
+msgstr "Diffusion d'erreur horizontale"
+
+#: t_options.h:127
+msgid "Horizontal error diffusion, reset error at line start"
+msgstr "Diffusion d'erreur horizontale, réinitialisé pour chaque ligne"
+
+#: t_options.h:128
+msgid "Ordered 2D color dithering"
+msgstr "Tramage ordonné des couleurs"
+
+#: t_options.h:134
+msgid "Floating point depth buffer"
+msgstr "Z-buffer en virgule flottante"
+
+#: t_options.h:140
+msgid "Performance"
+msgstr "Performance"
+
+#: t_options.h:148
+msgid "TCL mode (Transformation, Clipping, Lighting)"
+msgstr "Mode de TCL (Transformation, Clipping, Eclairage)"
+
+#: t_options.h:149
+msgid "Use software TCL pipeline"
+msgstr "Utiliser un pipeline TCL logiciel"
+
+#: t_options.h:150
+msgid "Use hardware TCL as first TCL pipeline stage"
+msgstr "Utiliser le TCL matériel pour le premier niveau de pipeline"
+
+#: t_options.h:151
+msgid "Bypass the TCL pipeline"
+msgstr "Court-circuiter le pipeline TCL"
+
+#: t_options.h:152
+msgid ""
+"Bypass the TCL pipeline with state-based machine code generated on-the-fly"
+msgstr ""
+"Court-circuiter le pipeline TCL par une machine à états qui génère le code"
+"de TCL à la volée"
+
+#: t_options.h:161
+msgid "Method to limit rendering latency"
+msgstr "Méthode d'attente de la carte graphique"
+
+#: t_options.h:162
+msgid "Busy waiting for the graphics hardware"
+msgstr "Attente active de la carte graphique"
+
+#: t_options.h:163
+msgid "Sleep for brief intervals while waiting for the graphics hardware"
+msgstr "Attente utilisant usleep()"
+
+#: t_options.h:164
+msgid "Let the graphics hardware emit a software interrupt and sleep"
+msgstr "Utiliser les interruptions"
+
+#: t_options.h:174
+msgid "Synchronization with vertical refresh (swap intervals)"
+msgstr "Synchronisation de l'affichage avec le balayage vertical"
+
+#: t_options.h:175
+msgid "Never synchronize with vertical refresh, ignore application's choice"
+msgstr "Ne jamais synchroniser avec le balayage vertical, ignorer le choix de l'application"
+
+#: t_options.h:176
+msgid "Initial swap interval 0, obey application's choice"
+msgstr "Ne pas synchroniser avec le balayage vertical par défaut, mais obéir au choix de l'application"
+
+#: t_options.h:177
+msgid "Initial swap interval 1, obey application's choice"
+msgstr "Synchroniser avec le balayage vertical par défaut, mais obéir au choix de l'application"
+
+#: t_options.h:178
+msgid ""
+"Always synchronize with vertical refresh, application chooses the minimum "
+"swap interval"
+msgstr ""
+"Toujours synchroniser avec le balayage vertical, l'application choisit l'intervalle minimal"
+
+#: t_options.h:186
+msgid "Use HyperZ to boost performance"
+msgstr "Utiliser le HyperZ pour améliorer les performances"
+
+#: t_options.h:191
+msgid "Number of texture units used"
+msgstr "Nombre d'unités de texture"
+
+#: t_options.h:196
+msgid ""
+"Enable hack to allow larger textures with texture compression on radeon/r200"
+msgstr ""
+"Activer le hack permettant l'utilisation de textures de grande taille avec la "
+"compression de textures sur radeon/r200"
+
+#: t_options.h:201
+msgid "Texture filtering quality vs. speed, AKA “brilinear†texture filtering"
+msgstr ""
+"Qualité/performance du filtrage trilinéaire de texture (filtrage brilinéaire)"
+
+#: t_options.h:209
+msgid "Used types of texture memory"
+msgstr "Types de mémoire de texture"
+
+#: t_options.h:210
+msgid "All available memory"
+msgstr "Utiliser toute la mémoire disponible"
+
+#: t_options.h:211
+msgid "Only card memory (if available)"
+msgstr "Utiliser uniquement la mémoire graphique (si disponible)"
+
+#: t_options.h:212
+msgid "Only GART (AGP/PCIE) memory (if available)"
+msgstr "Utiliser uniquement la mémoire GART (AGP/PCIE) (si disponible)"
+
+#: t_options.h:220
+msgid "Features that are not hardware-accelerated"
+msgstr "Fonctionnalités ne bénéficiant pas d'une accélération matérielle"
+
+#: t_options.h:224
+msgid "Enable extension GL_ARB_vertex_program"
+msgstr "Activer l'extension GL_ARB_vertex_program"
+
+#: t_options.h:229
+msgid "Enable extension GL_NV_vertex_program"
+msgstr "Activer l'extension GL_NV_vertex_program"
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/gen_xmlpool.py b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/gen_xmlpool.py
new file mode 100644
index 000000000..7398c4cd0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/gen_xmlpool.py
@@ -0,0 +1,191 @@
+#!/usr/bin/python
+
+import sys
+import gettext
+import re
+
+# List of supported languages
+languages = sys.argv[1:]
+
+# Escape special characters in C strings
+def escapeCString (s):
+ escapeSeqs = {'\a' : '\\a', '\b' : '\\b', '\f' : '\\f', '\n' : '\\n',
+ '\r' : '\\r', '\t' : '\\t', '\v' : '\\v', '\\' : '\\\\'}
+ # " -> '' is a hack. Quotes (") aren't possible in XML attributes.
+ # Better use Unicode characters for typographic quotes in option
+ # descriptions and translations.
+ i = 0
+ r = ''
+ while i < len(s):
+ # Special case: escape double quote with \u201c or \u201d, depending
+ # on whether it's an open or close quote. This is needed because plain
+ # double quotes are not possible in XML attributes.
+ if s[i] == '"':
+ if i == len(s)-1 or s[i+1].isspace():
+ # close quote
+ q = u'\u201c'
+ else:
+ # open quote
+ q = u'\u201d'
+ r = r + q
+ elif escapeSeqs.has_key(s[i]):
+ r = r + escapeSeqs[s[i]]
+ else:
+ r = r + s[i]
+ i = i + 1
+ return r
+
+# Expand escape sequences in C strings (needed for gettext lookup)
+def expandCString (s):
+ escapeSeqs = {'a' : '\a', 'b' : '\b', 'f' : '\f', 'n' : '\n',
+ 'r' : '\r', 't' : '\t', 'v' : '\v',
+ '"' : '"', '\\' : '\\'}
+ i = 0
+ escape = False
+ hexa = False
+ octa = False
+ num = 0
+ digits = 0
+ r = ''
+ while i < len(s):
+ if not escape:
+ if s[i] == '\\':
+ escape = True
+ else:
+ r = r + s[i]
+ elif hexa:
+ if (s[i] >= '0' and s[i] <= '9') or \
+ (s[i] >= 'a' and s[i] <= 'f') or \
+ (s[i] >= 'A' and s[i] <= 'F'):
+ num = num * 16 + int(s[i],16)
+ digits = digits + 1
+ else:
+ digits = 2
+ if digits >= 2:
+ hexa = False
+ escape = False
+ r = r + chr(num)
+ elif octa:
+ if s[i] >= '0' and s[i] <= '7':
+ num = num * 8 + int(s[i],8)
+ digits = digits + 1
+ else:
+ digits = 3
+ if digits >= 3:
+ octa = False
+ escape = False
+ r = r + chr(num)
+ else:
+ if escapeSeqs.has_key(s[i]):
+ r = r + escapeSeqs[s[i]]
+ escape = False
+ elif s[i] >= '0' and s[i] <= '7':
+ octa = True
+ num = int(s[i],8)
+ if num <= 3:
+ digits = 1
+ else:
+ digits = 2
+ elif s[i] == 'x' or s[i] == 'X':
+ hexa = True
+ num = 0
+ digits = 0
+ else:
+ r = r + s[i]
+ escape = False
+ i = i + 1
+ return r
+
+# Expand matches. The first match is always a DESC or DESC_BEGIN match.
+# Subsequent matches are ENUM matches.
+#
+# DESC, DESC_BEGIN format: \1 \2=<lang> \3 \4=gettext(" \5=<text> \6=") \7
+# ENUM format: \1 \2=gettext(" \3=<text> \4=") \5
+def expandMatches (matches, translations, end=None):
+ assert len(matches) > 0
+ nTranslations = len(translations)
+ i = 0
+ # Expand the description+enums for all translations
+ for lang,trans in translations:
+ i = i + 1
+ # Make sure that all but the last line of a simple description
+ # are extended with a backslash.
+ suffix = ''
+ if len(matches) == 1 and i < len(translations) and \
+ not matches[0].expand (r'\7').endswith('\\'):
+ suffix = ' \\'
+ # Expand the description line. Need to use ugettext in order to allow
+ # non-ascii unicode chars in the original English descriptions.
+ text = escapeCString (trans.ugettext (unicode (expandCString (
+ matches[0].expand (r'\5')), "utf-8"))).encode("utf-8")
+ print matches[0].expand (r'\1' + lang + r'\3"' + text + r'"\7') + suffix
+ # Expand any subsequent enum lines
+ for match in matches[1:]:
+ text = escapeCString (trans.ugettext (unicode (expandCString (
+ match.expand (r'\3')), "utf-8"))).encode("utf-8")
+ print match.expand (r'\1"' + text + r'"\5')
+
+ # Expand description end
+ if end:
+ print end,
+
+# Compile a list of translation classes to all supported languages.
+# The first translation is always a NullTranslations.
+translations = [("en", gettext.NullTranslations())]
+for lang in languages:
+ try:
+ trans = gettext.translation ("options", ".", [lang])
+ except IOError:
+ sys.stderr.write ("Warning: language '%s' not found.\n" % lang)
+ continue
+ translations.append ((lang, trans))
+
+# Regular expressions:
+reLibintl_h = re.compile (r'#\s*include\s*<libintl.h>')
+reDESC = re.compile (r'(\s*DRI_CONF_DESC\s*\(\s*)([a-z]+)(\s*,\s*)(gettext\s*\(\s*")(.*)("\s*\))(\s*\)[ \t]*\\?)$')
+reDESC_BEGIN = re.compile (r'(\s*DRI_CONF_DESC_BEGIN\s*\(\s*)([a-z]+)(\s*,\s*)(gettext\s*\(\s*")(.*)("\s*\))(\s*\)[ \t]*\\?)$')
+reENUM = re.compile (r'(\s*DRI_CONF_ENUM\s*\([^,]+,\s*)(gettext\s*\(\s*")(.*)("\s*\))(\s*\)[ \t]*\\?)$')
+reDESC_END = re.compile (r'\s*DRI_CONF_DESC_END')
+
+# Print a header
+print \
+"/***********************************************************************\n" \
+" *** THIS FILE IS GENERATED AUTOMATICALLY. DON'T EDIT! ***\n" \
+" ***********************************************************************/"
+
+# Process the options template and generate options.h with all
+# translations.
+template = file ("t_options.h", "r")
+descMatches = []
+for line in template:
+ if len(descMatches) > 0:
+ matchENUM = reENUM .match (line)
+ matchDESC_END = reDESC_END.match (line)
+ if matchENUM:
+ descMatches.append (matchENUM)
+ elif matchDESC_END:
+ expandMatches (descMatches, translations, line)
+ descMatches = []
+ else:
+ sys.stderr.write (
+ "Warning: unexpected line inside description dropped:\n%s\n" \
+ % line)
+ continue
+ if reLibintl_h.search (line):
+ # Ignore (comment out) #include <libintl.h>
+ print "/* %s * commented out by gen_xmlpool.py */" % line
+ continue
+ matchDESC = reDESC .match (line)
+ matchDESC_BEGIN = reDESC_BEGIN.match (line)
+ if matchDESC:
+ assert len(descMatches) == 0
+ expandMatches ([matchDESC], translations)
+ elif matchDESC_BEGIN:
+ assert len(descMatches) == 0
+ descMatches = [matchDESC_BEGIN]
+ else:
+ print line,
+
+if len(descMatches) > 0:
+ sys.stderr.write ("Warning: unterminated description at end of file.\n")
+ expandMatches (descMatches, translations)
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/nl.po b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/nl.po
new file mode 100644
index 000000000..1e4cf167b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/nl.po
@@ -0,0 +1,230 @@
+# Dutch translations for PACKAGE package.
+# Copyright (C) 2005 THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# <manfred.stienstra@dwerg.net>, 2005.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2005-04-12 20:09+0200\n"
+"PO-Revision-Date: 2005-04-12 20:09+0200\n"
+"Last-Translator: Manfred Stienstra <manfred.stienstra@dwerg.net>\n"
+"Language-Team: Dutch <vertaling@nl.linux.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#: t_options.h:53
+msgid "Debugging"
+msgstr "Debuggen"
+
+#: t_options.h:57
+msgid "Disable 3D acceleration"
+msgstr "3D versnelling uitschakelen"
+
+#: t_options.h:62
+msgid "Show performance boxes"
+msgstr "Laat prestatie boxjes zien"
+
+#: t_options.h:69
+msgid "Image Quality"
+msgstr "Beeldkwaliteit"
+
+#: t_options.h:77
+msgid "Texture color depth"
+msgstr "Textuurkleurendiepte"
+
+#: t_options.h:78
+msgid "Prefer frame buffer color depth"
+msgstr "Prefereer kaderbufferkleurdiepte"
+
+#: t_options.h:79
+msgid "Prefer 32 bits per texel"
+msgstr "Prefereer 32 bits per texel"
+
+#: t_options.h:80
+msgid "Prefer 16 bits per texel"
+msgstr "Prefereer 16 bits per texel"
+
+#: t_options.h:81
+msgid "Force 16 bits per texel"
+msgstr "Dwing 16 bits per texel af"
+
+#: t_options.h:87
+msgid "Initial maximum value for anisotropic texture filtering"
+msgstr "Initïele maximum waarde voor anisotrophische textuur filtering"
+
+#: t_options.h:92
+msgid "Forbid negative texture LOD bias"
+msgstr "Verbied negatief niveau detailonderscheid (LOD) van texturen"
+
+#: t_options.h:97
+msgid ""
+"Enable S3TC texture compression even if software support is not available"
+msgstr ""
+"Schakel S3TC textuurcompressie in, zelfs als softwareondersteuning niet "
+"aanwezig is"
+
+#: t_options.h:104
+msgid "Initial color reduction method"
+msgstr "Initïele kleurreductie methode"
+
+#: t_options.h:105
+msgid "Round colors"
+msgstr "Rond kleuren af"
+
+#: t_options.h:106
+msgid "Dither colors"
+msgstr "Rasteriseer kleuren"
+
+#: t_options.h:114
+msgid "Color rounding method"
+msgstr "Kleurafrondingmethode"
+
+#: t_options.h:115
+msgid "Round color components downward"
+msgstr "Rond kleurencomponenten af naar beneden"
+
+#: t_options.h:116
+msgid "Round to nearest color"
+msgstr "Rond af naar dichtsbijzijnde kleur"
+
+#: t_options.h:125
+msgid "Color dithering method"
+msgstr "Kleurrasteriseringsmethode"
+
+#: t_options.h:126
+msgid "Horizontal error diffusion"
+msgstr "Horizontale foutdiffusie"
+
+#: t_options.h:127
+msgid "Horizontal error diffusion, reset error at line start"
+msgstr "Horizontale foutdiffusie, zet fout bij lijnbegin terug"
+
+#: t_options.h:128
+msgid "Ordered 2D color dithering"
+msgstr "Geordende 2D kleurrasterisering"
+
+#: t_options.h:134
+msgid "Floating point depth buffer"
+msgstr "Dieptebuffer als commagetal"
+
+#: t_options.h:140
+msgid "Performance"
+msgstr "Prestatie"
+
+#: t_options.h:148
+msgid "TCL mode (Transformation, Clipping, Lighting)"
+msgstr "TCL-modus (Transformatie, Clipping, Licht)"
+
+#: t_options.h:149
+msgid "Use software TCL pipeline"
+msgstr "Gebruik software TCL pijpleiding"
+
+#: t_options.h:150
+msgid "Use hardware TCL as first TCL pipeline stage"
+msgstr "Gebruik hardware TCL as eerste TCL pijpleiding trap"
+
+#: t_options.h:151
+msgid "Bypass the TCL pipeline"
+msgstr "Omzeil de TCL pijpleiding"
+
+#: t_options.h:152
+msgid ""
+"Bypass the TCL pipeline with state-based machine code generated on-the-fly"
+msgstr ""
+"Omzeil de TCL pijpleiding met staatgebaseerde machinecode die tijdens "
+"executie gegenereerd wordt"
+
+#: t_options.h:161
+msgid "Method to limit rendering latency"
+msgstr "Methode om beeldopbouwvertraging te onderdrukken"
+
+#: t_options.h:162
+msgid "Busy waiting for the graphics hardware"
+msgstr "Actief wachten voor de grafische hardware"
+
+#: t_options.h:163
+msgid "Sleep for brief intervals while waiting for the graphics hardware"
+msgstr "Slaap voor korte intervallen tijdens het wachten op de grafische "
+"hardware"
+
+#: t_options.h:164
+msgid "Let the graphics hardware emit a software interrupt and sleep"
+msgstr "Laat de grafische hardware een software onderbreking uitzenden en in "
+"slaap vallen"
+
+#: t_options.h:174
+msgid "Synchronization with vertical refresh (swap intervals)"
+msgstr "Synchronisatie met verticale verversing (interval omwisselen)"
+
+#: t_options.h:175
+msgid "Never synchronize with vertical refresh, ignore application's choice"
+msgstr "Nooit synchroniseren met verticale verversing, negeer de keuze van de "
+"applicatie"
+
+#: t_options.h:176
+msgid "Initial swap interval 0, obey application's choice"
+msgstr "Initïeel omwisselingsinterval 0, honoreer de keuze van de applicatie"
+
+#: t_options.h:177
+msgid "Initial swap interval 1, obey application's choice"
+msgstr "Initïeel omwisselingsinterval 1, honoreer de keuze van de applicatie"
+
+#: t_options.h:178
+msgid ""
+"Always synchronize with vertical refresh, application chooses the minimum "
+"swap interval"
+msgstr ""
+"Synchroniseer altijd met verticale verversing, de applicatie kiest het "
+"minimum omwisselingsinterval"
+
+#: t_options.h:186
+msgid "Use HyperZ to boost performance"
+msgstr "Gebruik HyperZ om de prestaties te verbeteren"
+
+#: t_options.h:191
+msgid "Number of texture units used"
+msgstr "Aantal textuureenheden in gebruik"
+
+#: t_options.h:196
+msgid ""
+"Enable hack to allow larger textures with texture compression on radeon/r200"
+msgstr ""
+"Schakel hack in om met textuurcompressie grotere texturen toe te staan op "
+"een radeon/r200"
+
+#: t_options.h:201
+msgid "Texture filtering quality vs. speed, AKA “brilinear†texture filtering"
+msgstr "Textuurfilterkwaliteit versus -snelheid, ookwel bekend als "
+"“brilineaire†textuurfiltering"
+
+#: t_options.h:209
+msgid "Used types of texture memory"
+msgstr "Gebruikte soorten textuurgeheugen"
+
+#: t_options.h:210
+msgid "All available memory"
+msgstr "Al het beschikbaar geheugen"
+
+#: t_options.h:211
+msgid "Only card memory (if available)"
+msgstr "Alleen geheugen op de kaart (als het aanwezig is)"
+
+#: t_options.h:212
+msgid "Only GART (AGP/PCIE) memory (if available)"
+msgstr "Alleen GART (AGP/PCIE) geheugen (als het aanwezig is)"
+
+#: t_options.h:220
+msgid "Features that are not hardware-accelerated"
+msgstr "Eigenschappen die niet hardwareversneld zijn"
+
+#: t_options.h:224
+msgid "Enable extension GL_ARB_vertex_program"
+msgstr "Zet uitbreiding GL_ARB_vertex_program aan"
+
+#: t_options.h:229
+msgid "Enable extension GL_NV_vertex_program"
+msgstr "Zet uitbreiding GL_NV_vertex_program aan"
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/options.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/options.h
new file mode 100644
index 000000000..86d17d024
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/options.h
@@ -0,0 +1,462 @@
+/***********************************************************************
+ *** THIS FILE IS GENERATED AUTOMATICALLY. DON'T EDIT! ***
+ ***********************************************************************/
+/*
+ * XML DRI client-side driver configuration
+ * Copyright (C) 2003 Felix Kuehling
+ *
+ * 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
+ * FELIX KUEHLING, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+/**
+ * \file t_options.h
+ * \brief Templates of common options
+ * \author Felix Kuehling
+ *
+ * This file defines macros for common options that can be used to
+ * construct driConfigOptions in the drivers. This file is only a
+ * template containing English descriptions for options wrapped in
+ * gettext(). xgettext can be used to extract translatable
+ * strings. These strings can then be translated by anyone familiar
+ * with GNU gettext. gen_xmlpool.py takes this template and fills in
+ * all the translations. The result (options.h) is included by
+ * xmlpool.h which in turn can be included by drivers.
+ *
+ * The macros used to describe otions in this file are defined in
+ * ../xmlpool.h.
+ */
+
+/* This is needed for xgettext to extract translatable strings.
+ * gen_xmlpool.py will discard this line. */
+/* #include <libintl.h>
+ * commented out by gen_xmlpool.py */
+
+/*
+ * predefined option sections and options with multi-lingual descriptions
+ */
+
+/** \brief Debugging options */
+#define DRI_CONF_SECTION_DEBUG \
+DRI_CONF_SECTION_BEGIN \
+ DRI_CONF_DESC(en,"Debugging") \
+ DRI_CONF_DESC(de,"Fehlersuche") \
+ DRI_CONF_DESC(es,"Depurando") \
+ DRI_CONF_DESC(nl,"Debuggen") \
+ DRI_CONF_DESC(fr,"Debogage")
+
+#define DRI_CONF_NO_RAST(def) \
+DRI_CONF_OPT_BEGIN(no_rast,bool,def) \
+ DRI_CONF_DESC(en,"Disable 3D acceleration") \
+ DRI_CONF_DESC(de,"3D-Beschleunigung abschalten") \
+ DRI_CONF_DESC(es,"Desactivar aceleración 3D") \
+ DRI_CONF_DESC(nl,"3D versnelling uitschakelen") \
+ DRI_CONF_DESC(fr,"Désactiver l'accélération 3D") \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_PERFORMANCE_BOXES(def) \
+DRI_CONF_OPT_BEGIN(performance_boxes,bool,def) \
+ DRI_CONF_DESC(en,"Show performance boxes") \
+ DRI_CONF_DESC(de,"Zeige Performanceboxen") \
+ DRI_CONF_DESC(es,"Mostrar cajas de rendimiento") \
+ DRI_CONF_DESC(nl,"Laat prestatie boxjes zien") \
+ DRI_CONF_DESC(fr,"Afficher les boîtes de performance") \
+DRI_CONF_OPT_END
+
+
+/** \brief Texture-related options */
+#define DRI_CONF_SECTION_QUALITY \
+DRI_CONF_SECTION_BEGIN \
+ DRI_CONF_DESC(en,"Image Quality") \
+ DRI_CONF_DESC(de,"Bildqualität") \
+ DRI_CONF_DESC(es,"Calidad de imagen") \
+ DRI_CONF_DESC(nl,"Beeldkwaliteit") \
+ DRI_CONF_DESC(fr,"Qualité d'image")
+
+#define DRI_CONF_TEXTURE_DEPTH_FB 0
+#define DRI_CONF_TEXTURE_DEPTH_32 1
+#define DRI_CONF_TEXTURE_DEPTH_16 2
+#define DRI_CONF_TEXTURE_DEPTH_FORCE_16 3
+#define DRI_CONF_TEXTURE_DEPTH(def) \
+DRI_CONF_OPT_BEGIN_V(texture_depth,enum,def,"0:3") \
+ DRI_CONF_DESC_BEGIN(en,"Texture color depth") \
+ DRI_CONF_ENUM(0,"Prefer frame buffer color depth") \
+ DRI_CONF_ENUM(1,"Prefer 32 bits per texel") \
+ DRI_CONF_ENUM(2,"Prefer 16 bits per texel") \
+ DRI_CONF_ENUM(3,"Force 16 bits per texel") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(de,"Texturfarbtiefe") \
+ DRI_CONF_ENUM(0,"Bevorzuge Farbtiefe des Framebuffers") \
+ DRI_CONF_ENUM(1,"Bevorzuge 32 bits pro Texel") \
+ DRI_CONF_ENUM(2,"Bevorzuge 16 bits pro Texel") \
+ DRI_CONF_ENUM(3,"Erzwinge 16 bits pro Texel") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(es,"Profundidad de color de textura") \
+ DRI_CONF_ENUM(0,"Preferir profundidad de color del â€framebuffer“") \
+ DRI_CONF_ENUM(1,"Preferir 32 bits por texel") \
+ DRI_CONF_ENUM(2,"Preferir 16 bits por texel") \
+ DRI_CONF_ENUM(3,"Forzar a 16 bits por texel") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(nl,"Textuurkleurendiepte") \
+ DRI_CONF_ENUM(0,"Prefereer kaderbufferkleurdiepte") \
+ DRI_CONF_ENUM(1,"Prefereer 32 bits per texel") \
+ DRI_CONF_ENUM(2,"Prefereer 16 bits per texel") \
+ DRI_CONF_ENUM(3,"Dwing 16 bits per texel af") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(fr,"Profondeur de texture") \
+ DRI_CONF_ENUM(0,"Profondeur de couleur") \
+ DRI_CONF_ENUM(1,"Préférer 32 bits par texel") \
+ DRI_CONF_ENUM(2,"Prérérer 16 bits par texel") \
+ DRI_CONF_ENUM(3,"Forcer 16 bits par texel") \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_DEF_MAX_ANISOTROPY(def,range) \
+DRI_CONF_OPT_BEGIN_V(def_max_anisotropy,float,def,range) \
+ DRI_CONF_DESC(en,"Initial maximum value for anisotropic texture filtering") \
+ DRI_CONF_DESC(de,"Initialer Maximalwert für anisotropische Texturfilterung") \
+ DRI_CONF_DESC(es,"Valor máximo inicial para filtrado anisotrópico de textura") \
+ DRI_CONF_DESC(nl,"Initïele maximum waarde voor anisotrophische textuur filtering") \
+ DRI_CONF_DESC(fr,"Valeur maximale initiale pour le filtrage anisotropique de texture") \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_NO_NEG_LOD_BIAS(def) \
+DRI_CONF_OPT_BEGIN(no_neg_lod_bias,bool,def) \
+ DRI_CONF_DESC(en,"Forbid negative texture LOD bias") \
+ DRI_CONF_DESC(de,"Verbiete negative Textur-Detailgradverschiebung") \
+ DRI_CONF_DESC(es,"Prohibir valores negativos de Nivel De Detalle (LOD) de texturas") \
+ DRI_CONF_DESC(nl,"Verbied negatief niveau detailonderscheid (LOD) van texturen") \
+ DRI_CONF_DESC(fr,"Interdire le LOD bias negatif") \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_FORCE_S3TC_ENABLE(def) \
+DRI_CONF_OPT_BEGIN(force_s3tc_enable,bool,def) \
+ DRI_CONF_DESC(en,"Enable S3TC texture compression even if software support is not available") \
+ DRI_CONF_DESC(de,"Aktiviere S3TC Texturkomprimierung auch wenn die nötige Softwareunterstützung fehlt") \
+ DRI_CONF_DESC(es,"Activar la compresión de texturas S3TC incluso si el soporte por software no está disponible") \
+ DRI_CONF_DESC(nl,"Schakel S3TC textuurcompressie in, zelfs als softwareondersteuning niet aanwezig is") \
+ DRI_CONF_DESC(fr,"Activer la compression de texture S3TC même si le support logiciel est absent") \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_COLOR_REDUCTION_ROUND 0
+#define DRI_CONF_COLOR_REDUCTION_DITHER 1
+#define DRI_CONF_COLOR_REDUCTION(def) \
+DRI_CONF_OPT_BEGIN_V(color_reduction,enum,def,"0:1") \
+ DRI_CONF_DESC_BEGIN(en,"Initial color reduction method") \
+ DRI_CONF_ENUM(0,"Round colors") \
+ DRI_CONF_ENUM(1,"Dither colors") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(de,"Initiale Farbreduktionsmethode") \
+ DRI_CONF_ENUM(0,"Farben runden") \
+ DRI_CONF_ENUM(1,"Farben rastern") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(es,"Método inicial de reducción de color") \
+ DRI_CONF_ENUM(0,"Colores redondeados") \
+ DRI_CONF_ENUM(1,"Colores suavizados") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(nl,"Initïele kleurreductie methode") \
+ DRI_CONF_ENUM(0,"Rond kleuren af") \
+ DRI_CONF_ENUM(1,"Rasteriseer kleuren") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(fr,"Technique de réduction de couleurs") \
+ DRI_CONF_ENUM(0,"Arrondir les valeurs de couleur") \
+ DRI_CONF_ENUM(1,"Tramer les couleurs") \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_ROUND_TRUNC 0
+#define DRI_CONF_ROUND_ROUND 1
+#define DRI_CONF_ROUND_MODE(def) \
+DRI_CONF_OPT_BEGIN_V(round_mode,enum,def,"0:1") \
+ DRI_CONF_DESC_BEGIN(en,"Color rounding method") \
+ DRI_CONF_ENUM(0,"Round color components downward") \
+ DRI_CONF_ENUM(1,"Round to nearest color") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(de,"Farbrundungsmethode") \
+ DRI_CONF_ENUM(0,"Farbkomponenten abrunden") \
+ DRI_CONF_ENUM(1,"Zur ähnlichsten Farbe runden") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(es,"Método de redondeo de colores") \
+ DRI_CONF_ENUM(0,"Redondear hacia abajo los componentes de color") \
+ DRI_CONF_ENUM(1,"Redondear al color más cercano") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(nl,"Kleurafrondingmethode") \
+ DRI_CONF_ENUM(0,"Rond kleurencomponenten af naar beneden") \
+ DRI_CONF_ENUM(1,"Rond af naar dichtsbijzijnde kleur") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(fr,"Méthode d'arrondi des couleurs") \
+ DRI_CONF_ENUM(0,"Arrondi à l'inférieur") \
+ DRI_CONF_ENUM(1,"Arrondi au plus proche") \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_DITHER_XERRORDIFF 0
+#define DRI_CONF_DITHER_XERRORDIFFRESET 1
+#define DRI_CONF_DITHER_ORDERED 2
+#define DRI_CONF_DITHER_MODE(def) \
+DRI_CONF_OPT_BEGIN_V(dither_mode,enum,def,"0:2") \
+ DRI_CONF_DESC_BEGIN(en,"Color dithering method") \
+ DRI_CONF_ENUM(0,"Horizontal error diffusion") \
+ DRI_CONF_ENUM(1,"Horizontal error diffusion, reset error at line start") \
+ DRI_CONF_ENUM(2,"Ordered 2D color dithering") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(de,"Farbrasterungsmethode") \
+ DRI_CONF_ENUM(0,"Horizontale Fehlerstreuung") \
+ DRI_CONF_ENUM(1,"Horizontale Fehlerstreuung, Fehler am Zeilenanfang zurücksetzen") \
+ DRI_CONF_ENUM(2,"Geordnete 2D Farbrasterung") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(es,"Método de suavizado de color") \
+ DRI_CONF_ENUM(0,"Difusión de error horizontal") \
+ DRI_CONF_ENUM(1,"Difusión de error horizontal, reiniciar error al comienzo de línea") \
+ DRI_CONF_ENUM(2,"Suavizado de color 2D ordenado") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(nl,"Kleurrasteriseringsmethode") \
+ DRI_CONF_ENUM(0,"Horizontale foutdiffusie") \
+ DRI_CONF_ENUM(1,"Horizontale foutdiffusie, zet fout bij lijnbegin terug") \
+ DRI_CONF_ENUM(2,"Geordende 2D kleurrasterisering") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(fr,"Méthode de tramage") \
+ DRI_CONF_ENUM(0,"Diffusion d'erreur horizontale") \
+ DRI_CONF_ENUM(1,"Diffusion d'erreur horizontale, réinitialisé pour chaque ligne") \
+ DRI_CONF_ENUM(2,"Tramage ordonné des couleurs") \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_FLOAT_DEPTH(def) \
+DRI_CONF_OPT_BEGIN(float_depth,bool,def) \
+ DRI_CONF_DESC(en,"Floating point depth buffer") \
+ DRI_CONF_DESC(de,"Fließkomma z-Puffer") \
+ DRI_CONF_DESC(es,"Búfer de profundidad en coma flotante") \
+ DRI_CONF_DESC(nl,"Dieptebuffer als commagetal") \
+ DRI_CONF_DESC(fr,"Z-buffer en virgule flottante") \
+DRI_CONF_OPT_END
+
+/** \brief Performance-related options */
+#define DRI_CONF_SECTION_PERFORMANCE \
+DRI_CONF_SECTION_BEGIN \
+ DRI_CONF_DESC(en,"Performance") \
+ DRI_CONF_DESC(de,"Leistung") \
+ DRI_CONF_DESC(es,"Rendimiento") \
+ DRI_CONF_DESC(nl,"Prestatie") \
+ DRI_CONF_DESC(fr,"Performance")
+
+#define DRI_CONF_TCL_SW 0
+#define DRI_CONF_TCL_PIPELINED 1
+#define DRI_CONF_TCL_VTXFMT 2
+#define DRI_CONF_TCL_CODEGEN 3
+#define DRI_CONF_TCL_MODE(def) \
+DRI_CONF_OPT_BEGIN_V(tcl_mode,enum,def,"0:3") \
+ DRI_CONF_DESC_BEGIN(en,"TCL mode (Transformation, Clipping, Lighting)") \
+ DRI_CONF_ENUM(0,"Use software TCL pipeline") \
+ DRI_CONF_ENUM(1,"Use hardware TCL as first TCL pipeline stage") \
+ DRI_CONF_ENUM(2,"Bypass the TCL pipeline") \
+ DRI_CONF_ENUM(3,"Bypass the TCL pipeline with state-based machine code generated on-the-fly") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(de,"TCL-Modus (Transformation, Clipping, Licht)") \
+ DRI_CONF_ENUM(0,"Benutze die Software-TCL-Pipeline") \
+ DRI_CONF_ENUM(1,"Benutze Hardware TCL als erste Stufe der TCL-Pipeline") \
+ DRI_CONF_ENUM(2,"Umgehe die TCL-Pipeline") \
+ DRI_CONF_ENUM(3,"Umgehe die TCL-Pipeline mit zur Laufzeit erzeugtem, zustandsbasiertem Maschinencode") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(es,"Modo TCL (Transformación, Recorte, Iluminación)") \
+ DRI_CONF_ENUM(0,"Usar tubería TCL por software") \
+ DRI_CONF_ENUM(1,"Usar TCL por hardware en la primera fase de la tubería TCL") \
+ DRI_CONF_ENUM(2,"Pasar por alto la tubería TCL") \
+ DRI_CONF_ENUM(3,"Pasar por alto la tubería TCL con código máquina basado en estados generado al vuelo") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(nl,"TCL-modus (Transformatie, Clipping, Licht)") \
+ DRI_CONF_ENUM(0,"Gebruik software TCL pijpleiding") \
+ DRI_CONF_ENUM(1,"Gebruik hardware TCL as eerste TCL pijpleiding trap") \
+ DRI_CONF_ENUM(2,"Omzeil de TCL pijpleiding") \
+ DRI_CONF_ENUM(3,"Omzeil de TCL pijpleiding met staatgebaseerde machinecode die tijdens executie gegenereerd wordt") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(fr,"Mode de TCL (Transformation, Clipping, Eclairage)") \
+ DRI_CONF_ENUM(0,"Utiliser un pipeline TCL logiciel") \
+ DRI_CONF_ENUM(1,"Utiliser le TCL matériel pour le premier niveau de pipeline") \
+ DRI_CONF_ENUM(2,"Court-circuiter le pipeline TCL") \
+ DRI_CONF_ENUM(3,"Court-circuiter le pipeline TCL par une machine à états qui génère le codede TCL à la volée") \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_FTHROTTLE_BUSY 0
+#define DRI_CONF_FTHROTTLE_USLEEPS 1
+#define DRI_CONF_FTHROTTLE_IRQS 2
+#define DRI_CONF_FTHROTTLE_MODE(def) \
+DRI_CONF_OPT_BEGIN_V(fthrottle_mode,enum,def,"0:2") \
+ DRI_CONF_DESC_BEGIN(en,"Method to limit rendering latency") \
+ DRI_CONF_ENUM(0,"Busy waiting for the graphics hardware") \
+ DRI_CONF_ENUM(1,"Sleep for brief intervals while waiting for the graphics hardware") \
+ DRI_CONF_ENUM(2,"Let the graphics hardware emit a software interrupt and sleep") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(de,"Methode zur Begrenzung der Bildverzögerung") \
+ DRI_CONF_ENUM(0,"Aktives Warten auf die Grafikhardware") \
+ DRI_CONF_ENUM(1,"Kurze Schlafintervalle beim Warten auf die Grafikhardware") \
+ DRI_CONF_ENUM(2,"Die Grafikhardware eine Softwareunterbrechnung erzeugen lassen und schlafen") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(es,"Método para limitar la latencia de rénder") \
+ DRI_CONF_ENUM(0,"Esperar activamente al hardware gráfico") \
+ DRI_CONF_ENUM(1,"Dormir en intervalos cortos mientras se espera al hardware gráfico") \
+ DRI_CONF_ENUM(2,"Permitir que el hardware gráfico emita una interrupción de software y duerma") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(nl,"Methode om beeldopbouwvertraging te onderdrukken") \
+ DRI_CONF_ENUM(0,"Actief wachten voor de grafische hardware") \
+ DRI_CONF_ENUM(1,"Slaap voor korte intervallen tijdens het wachten op de grafische hardware") \
+ DRI_CONF_ENUM(2,"Laat de grafische hardware een software onderbreking uitzenden en in slaap vallen") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(fr,"Méthode d'attente de la carte graphique") \
+ DRI_CONF_ENUM(0,"Attente active de la carte graphique") \
+ DRI_CONF_ENUM(1,"Attente utilisant usleep()") \
+ DRI_CONF_ENUM(2,"Utiliser les interruptions") \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_VBLANK_NEVER 0
+#define DRI_CONF_VBLANK_DEF_INTERVAL_0 1
+#define DRI_CONF_VBLANK_DEF_INTERVAL_1 2
+#define DRI_CONF_VBLANK_ALWAYS_SYNC 3
+#define DRI_CONF_VBLANK_MODE(def) \
+DRI_CONF_OPT_BEGIN_V(vblank_mode,enum,def,"0:3") \
+ DRI_CONF_DESC_BEGIN(en,"Synchronization with vertical refresh (swap intervals)") \
+ DRI_CONF_ENUM(0,"Never synchronize with vertical refresh, ignore application's choice") \
+ DRI_CONF_ENUM(1,"Initial swap interval 0, obey application's choice") \
+ DRI_CONF_ENUM(2,"Initial swap interval 1, obey application's choice") \
+ DRI_CONF_ENUM(3,"Always synchronize with vertical refresh, application chooses the minimum swap interval") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(de,"Synchronisation mit der vertikalen Bildwiederholung") \
+ DRI_CONF_ENUM(0,"Niemals mit der Bildwiederholung synchronisieren, Anweisungen der Anwendung ignorieren") \
+ DRI_CONF_ENUM(1,"Initiales Bildinterval 0, Anweisungen der Anwendung gehorchen") \
+ DRI_CONF_ENUM(2,"Initiales Bildinterval 1, Anweisungen der Anwendung gehorchen") \
+ DRI_CONF_ENUM(3,"Immer mit der Bildwiederholung synchronisieren, Anwendung wählt das minmale Bildinterval") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(es,"Sincronización con el refresco vertical (intervalos de intercambio)") \
+ DRI_CONF_ENUM(0,"No sincronizar nunca con el refresco vertical, ignorar la elección de la aplicación") \
+ DRI_CONF_ENUM(1,"Intervalo de intercambio inicial 0, obedecer la elección de la aplicación") \
+ DRI_CONF_ENUM(2,"Intervalo de intercambio inicial 1, obedecer la elección de la aplicación") \
+ DRI_CONF_ENUM(3,"Sincronizar siempre con el refresco vertical, la aplicación elige el intervalo de intercambio mínimo") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(nl,"Synchronisatie met verticale verversing (interval omwisselen)") \
+ DRI_CONF_ENUM(0,"Nooit synchroniseren met verticale verversing, negeer de keuze van de applicatie") \
+ DRI_CONF_ENUM(1,"Initïeel omwisselingsinterval 0, honoreer de keuze van de applicatie") \
+ DRI_CONF_ENUM(2,"Initïeel omwisselingsinterval 1, honoreer de keuze van de applicatie") \
+ DRI_CONF_ENUM(3,"Synchroniseer altijd met verticale verversing, de applicatie kiest het minimum omwisselingsinterval") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(fr,"Synchronisation de l'affichage avec le balayage vertical") \
+ DRI_CONF_ENUM(0,"Ne jamais synchroniser avec le balayage vertical, ignorer le choix de l'application") \
+ DRI_CONF_ENUM(1,"Ne pas synchroniser avec le balayage vertical par défaut, mais obéir au choix de l'application") \
+ DRI_CONF_ENUM(2,"Synchroniser avec le balayage vertical par défaut, mais obéir au choix de l'application") \
+ DRI_CONF_ENUM(3,"Toujours synchroniser avec le balayage vertical, l'application choisit l'intervalle minimal") \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_HYPERZ_DISABLED 0
+#define DRI_CONF_HYPERZ_ENABLED 1
+#define DRI_CONF_HYPERZ(def) \
+DRI_CONF_OPT_BEGIN(hyperz,bool,def) \
+ DRI_CONF_DESC(en,"Use HyperZ to boost performance") \
+ DRI_CONF_DESC(de,"HyperZ zur Leistungssteigerung verwenden") \
+ DRI_CONF_DESC(es,"Usar HyperZ para potenciar rendimiento") \
+ DRI_CONF_DESC(nl,"Gebruik HyperZ om de prestaties te verbeteren") \
+ DRI_CONF_DESC(fr,"Utiliser le HyperZ pour améliorer les performances") \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_MAX_TEXTURE_UNITS(def,min,max) \
+DRI_CONF_OPT_BEGIN_V(texture_units,int,def, # min ":" # max ) \
+ DRI_CONF_DESC(en,"Number of texture units used") \
+ DRI_CONF_DESC(de,"Anzahl der benutzten Textureinheiten") \
+ DRI_CONF_DESC(es,"Número de unidades de textura usadas") \
+ DRI_CONF_DESC(nl,"Aantal textuureenheden in gebruik") \
+ DRI_CONF_DESC(fr,"Nombre d'unités de texture") \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_TEXTURE_LEVEL_HACK(def) \
+DRI_CONF_OPT_BEGIN(texture_level_hack,bool,def) \
+ DRI_CONF_DESC(en,"Enable hack to allow larger textures with texture compression on radeon/r200") \
+ DRI_CONF_DESC(de,"Hack aktivieren, der mit Texturkompression auf radeon/r200 größere Texturen erlaubt") \
+ DRI_CONF_DESC(es,"Activar â€hack“ para permitir texturas más grandes con compresión de textura activada en la Radeon/r200") \
+ DRI_CONF_DESC(nl,"Schakel hack in om met textuurcompressie grotere texturen toe te staan op een radeon/r200") \
+ DRI_CONF_DESC(fr,"Activer le hack permettant l'utilisation de textures de grande taille avec la compression de textures sur radeon/r200") \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_TEXTURE_BLEND_QUALITY(def,range) \
+DRI_CONF_OPT_BEGIN_V(texture_blend_quality,float,def,range) \
+ DRI_CONF_DESC(en,"Texture filtering quality vs. speed, AKA “brilinear†texture filtering") \
+ DRI_CONF_DESC(de,"Texturfilterqualität versus -geschwindigkeit, auch bekannt als „brilineare“ Texturfilterung") \
+ DRI_CONF_DESC(es,"Calidad de filtrado de textura vs. velocidad, alias filtrado â€brilinear“ de textura") \
+ DRI_CONF_DESC(nl,"Textuurfilterkwaliteit versus -snelheid, ookwel bekend als “brilineaire†textuurfiltering") \
+ DRI_CONF_DESC(fr,"Qualité/performance du filtrage trilinéaire de texture (filtrage brilinéaire)") \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_TEXTURE_HEAPS_ALL 0
+#define DRI_CONF_TEXTURE_HEAPS_CARD 1
+#define DRI_CONF_TEXTURE_HEAPS_GART 2
+#define DRI_CONF_TEXTURE_HEAPS(def) \
+DRI_CONF_OPT_BEGIN_V(texture_heaps,enum,def,"0:2") \
+ DRI_CONF_DESC_BEGIN(en,"Used types of texture memory") \
+ DRI_CONF_ENUM(0,"All available memory") \
+ DRI_CONF_ENUM(1,"Only card memory (if available)") \
+ DRI_CONF_ENUM(2,"Only GART (AGP/PCIE) memory (if available)") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(de,"Benutzte Arten von Texturspeicher") \
+ DRI_CONF_ENUM(0,"Aller verfügbarer Speicher") \
+ DRI_CONF_ENUM(1,"Nur Grafikspeicher (falls verfügbar)") \
+ DRI_CONF_ENUM(2,"Nur GART-Speicher (AGP/PCIE) (falls verfügbar)") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(es,"Tipos de memoria de textura usados") \
+ DRI_CONF_ENUM(0,"Toda la memoria disponible") \
+ DRI_CONF_ENUM(1,"Sólo la memoria de la tarjeta (si disponible)") \
+ DRI_CONF_ENUM(2,"Sólo memoria GART (AGP/PCIE) (si disponible)") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(nl,"Gebruikte soorten textuurgeheugen") \
+ DRI_CONF_ENUM(0,"Al het beschikbaar geheugen") \
+ DRI_CONF_ENUM(1,"Alleen geheugen op de kaart (als het aanwezig is)") \
+ DRI_CONF_ENUM(2,"Alleen GART (AGP/PCIE) geheugen (als het aanwezig is)") \
+ DRI_CONF_DESC_END \
+ DRI_CONF_DESC_BEGIN(fr,"Types de mémoire de texture") \
+ DRI_CONF_ENUM(0,"Utiliser toute la mémoire disponible") \
+ DRI_CONF_ENUM(1,"Utiliser uniquement la mémoire graphique (si disponible)") \
+ DRI_CONF_ENUM(2,"Utiliser uniquement la mémoire GART (AGP/PCIE) (si disponible)") \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+/* Options for features that are not done in hardware by the driver (like GL_ARB_vertex_program
+ On cards where there is no documentation (r200) or on rasterization-only hardware). */
+#define DRI_CONF_SECTION_SOFTWARE \
+DRI_CONF_SECTION_BEGIN \
+ DRI_CONF_DESC(en,"Features that are not hardware-accelerated") \
+ DRI_CONF_DESC(de,"Funktionalität, die nicht hardwarebeschleunigt ist") \
+ DRI_CONF_DESC(es,"Características no aceleradas por hardware") \
+ DRI_CONF_DESC(nl,"Eigenschappen die niet hardwareversneld zijn") \
+ DRI_CONF_DESC(fr,"Fonctionnalités ne bénéficiant pas d'une accélération matérielle")
+
+#define DRI_CONF_ARB_VERTEX_PROGRAM(def) \
+DRI_CONF_OPT_BEGIN(arb_vertex_program,bool,def) \
+ DRI_CONF_DESC(en,"Enable extension GL_ARB_vertex_program") \
+ DRI_CONF_DESC(de,"Erweiterung GL_ARB_vertex_program aktivieren") \
+ DRI_CONF_DESC(es,"Activar la extensión GL_ARB_vertex_program") \
+ DRI_CONF_DESC(nl,"Zet uitbreiding GL_ARB_vertex_program aan") \
+ DRI_CONF_DESC(fr,"Activer l'extension GL_ARB_vertex_program") \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_NV_VERTEX_PROGRAM(def) \
+DRI_CONF_OPT_BEGIN(nv_vertex_program,bool,def) \
+ DRI_CONF_DESC(en,"Enable extension GL_NV_vertex_program") \
+ DRI_CONF_DESC(de,"Erweiterung GL_NV_vertex_program aktivieren") \
+ DRI_CONF_DESC(es,"Activar extensión GL_NV_vertex_program") \
+ DRI_CONF_DESC(nl,"Zet uitbreiding GL_NV_vertex_program aan") \
+ DRI_CONF_DESC(fr,"Activer l'extension GL_NV_vertex_program") \
+DRI_CONF_OPT_END
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/t_options.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/t_options.h
new file mode 100644
index 000000000..ab9245ee2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/common/xmlpool/t_options.h
@@ -0,0 +1,230 @@
+/*
+ * XML DRI client-side driver configuration
+ * Copyright (C) 2003 Felix Kuehling
+ *
+ * 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
+ * FELIX KUEHLING, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+/**
+ * \file t_options.h
+ * \brief Templates of common options
+ * \author Felix Kuehling
+ *
+ * This file defines macros for common options that can be used to
+ * construct driConfigOptions in the drivers. This file is only a
+ * template containing English descriptions for options wrapped in
+ * gettext(). xgettext can be used to extract translatable
+ * strings. These strings can then be translated by anyone familiar
+ * with GNU gettext. gen_xmlpool.py takes this template and fills in
+ * all the translations. The result (options.h) is included by
+ * xmlpool.h which in turn can be included by drivers.
+ *
+ * The macros used to describe otions in this file are defined in
+ * ../xmlpool.h.
+ */
+
+/* This is needed for xgettext to extract translatable strings.
+ * gen_xmlpool.py will discard this line. */
+#include <libintl.h>
+
+/*
+ * predefined option sections and options with multi-lingual descriptions
+ */
+
+/** \brief Debugging options */
+#define DRI_CONF_SECTION_DEBUG \
+DRI_CONF_SECTION_BEGIN \
+ DRI_CONF_DESC(en,gettext("Debugging"))
+
+#define DRI_CONF_NO_RAST(def) \
+DRI_CONF_OPT_BEGIN(no_rast,bool,def) \
+ DRI_CONF_DESC(en,gettext("Disable 3D acceleration")) \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_PERFORMANCE_BOXES(def) \
+DRI_CONF_OPT_BEGIN(performance_boxes,bool,def) \
+ DRI_CONF_DESC(en,gettext("Show performance boxes")) \
+DRI_CONF_OPT_END
+
+
+/** \brief Texture-related options */
+#define DRI_CONF_SECTION_QUALITY \
+DRI_CONF_SECTION_BEGIN \
+ DRI_CONF_DESC(en,gettext("Image Quality"))
+
+#define DRI_CONF_TEXTURE_DEPTH_FB 0
+#define DRI_CONF_TEXTURE_DEPTH_32 1
+#define DRI_CONF_TEXTURE_DEPTH_16 2
+#define DRI_CONF_TEXTURE_DEPTH_FORCE_16 3
+#define DRI_CONF_TEXTURE_DEPTH(def) \
+DRI_CONF_OPT_BEGIN_V(texture_depth,enum,def,"0:3") \
+ DRI_CONF_DESC_BEGIN(en,gettext("Texture color depth")) \
+ DRI_CONF_ENUM(0,gettext("Prefer frame buffer color depth")) \
+ DRI_CONF_ENUM(1,gettext("Prefer 32 bits per texel")) \
+ DRI_CONF_ENUM(2,gettext("Prefer 16 bits per texel")) \
+ DRI_CONF_ENUM(3,gettext("Force 16 bits per texel")) \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_DEF_MAX_ANISOTROPY(def,range) \
+DRI_CONF_OPT_BEGIN_V(def_max_anisotropy,float,def,range) \
+ DRI_CONF_DESC(en,gettext("Initial maximum value for anisotropic texture filtering")) \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_NO_NEG_LOD_BIAS(def) \
+DRI_CONF_OPT_BEGIN(no_neg_lod_bias,bool,def) \
+ DRI_CONF_DESC(en,gettext("Forbid negative texture LOD bias")) \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_FORCE_S3TC_ENABLE(def) \
+DRI_CONF_OPT_BEGIN(force_s3tc_enable,bool,def) \
+ DRI_CONF_DESC(en,gettext("Enable S3TC texture compression even if software support is not available")) \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_COLOR_REDUCTION_ROUND 0
+#define DRI_CONF_COLOR_REDUCTION_DITHER 1
+#define DRI_CONF_COLOR_REDUCTION(def) \
+DRI_CONF_OPT_BEGIN_V(color_reduction,enum,def,"0:1") \
+ DRI_CONF_DESC_BEGIN(en,gettext("Initial color reduction method")) \
+ DRI_CONF_ENUM(0,gettext("Round colors")) \
+ DRI_CONF_ENUM(1,gettext("Dither colors")) \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_ROUND_TRUNC 0
+#define DRI_CONF_ROUND_ROUND 1
+#define DRI_CONF_ROUND_MODE(def) \
+DRI_CONF_OPT_BEGIN_V(round_mode,enum,def,"0:1") \
+ DRI_CONF_DESC_BEGIN(en,gettext("Color rounding method")) \
+ DRI_CONF_ENUM(0,gettext("Round color components downward")) \
+ DRI_CONF_ENUM(1,gettext("Round to nearest color")) \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_DITHER_XERRORDIFF 0
+#define DRI_CONF_DITHER_XERRORDIFFRESET 1
+#define DRI_CONF_DITHER_ORDERED 2
+#define DRI_CONF_DITHER_MODE(def) \
+DRI_CONF_OPT_BEGIN_V(dither_mode,enum,def,"0:2") \
+ DRI_CONF_DESC_BEGIN(en,gettext("Color dithering method")) \
+ DRI_CONF_ENUM(0,gettext("Horizontal error diffusion")) \
+ DRI_CONF_ENUM(1,gettext("Horizontal error diffusion, reset error at line start")) \
+ DRI_CONF_ENUM(2,gettext("Ordered 2D color dithering")) \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_FLOAT_DEPTH(def) \
+DRI_CONF_OPT_BEGIN(float_depth,bool,def) \
+ DRI_CONF_DESC(en,gettext("Floating point depth buffer")) \
+DRI_CONF_OPT_END
+
+/** \brief Performance-related options */
+#define DRI_CONF_SECTION_PERFORMANCE \
+DRI_CONF_SECTION_BEGIN \
+ DRI_CONF_DESC(en,gettext("Performance"))
+
+#define DRI_CONF_TCL_SW 0
+#define DRI_CONF_TCL_PIPELINED 1
+#define DRI_CONF_TCL_VTXFMT 2
+#define DRI_CONF_TCL_CODEGEN 3
+#define DRI_CONF_TCL_MODE(def) \
+DRI_CONF_OPT_BEGIN_V(tcl_mode,enum,def,"0:3") \
+ DRI_CONF_DESC_BEGIN(en,gettext("TCL mode (Transformation, Clipping, Lighting)")) \
+ DRI_CONF_ENUM(0,gettext("Use software TCL pipeline")) \
+ DRI_CONF_ENUM(1,gettext("Use hardware TCL as first TCL pipeline stage")) \
+ DRI_CONF_ENUM(2,gettext("Bypass the TCL pipeline")) \
+ DRI_CONF_ENUM(3,gettext("Bypass the TCL pipeline with state-based machine code generated on-the-fly")) \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_FTHROTTLE_BUSY 0
+#define DRI_CONF_FTHROTTLE_USLEEPS 1
+#define DRI_CONF_FTHROTTLE_IRQS 2
+#define DRI_CONF_FTHROTTLE_MODE(def) \
+DRI_CONF_OPT_BEGIN_V(fthrottle_mode,enum,def,"0:2") \
+ DRI_CONF_DESC_BEGIN(en,gettext("Method to limit rendering latency")) \
+ DRI_CONF_ENUM(0,gettext("Busy waiting for the graphics hardware")) \
+ DRI_CONF_ENUM(1,gettext("Sleep for brief intervals while waiting for the graphics hardware")) \
+ DRI_CONF_ENUM(2,gettext("Let the graphics hardware emit a software interrupt and sleep")) \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_VBLANK_NEVER 0
+#define DRI_CONF_VBLANK_DEF_INTERVAL_0 1
+#define DRI_CONF_VBLANK_DEF_INTERVAL_1 2
+#define DRI_CONF_VBLANK_ALWAYS_SYNC 3
+#define DRI_CONF_VBLANK_MODE(def) \
+DRI_CONF_OPT_BEGIN_V(vblank_mode,enum,def,"0:3") \
+ DRI_CONF_DESC_BEGIN(en,gettext("Synchronization with vertical refresh (swap intervals)")) \
+ DRI_CONF_ENUM(0,gettext("Never synchronize with vertical refresh, ignore application's choice")) \
+ DRI_CONF_ENUM(1,gettext("Initial swap interval 0, obey application's choice")) \
+ DRI_CONF_ENUM(2,gettext("Initial swap interval 1, obey application's choice")) \
+ DRI_CONF_ENUM(3,gettext("Always synchronize with vertical refresh, application chooses the minimum swap interval")) \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_HYPERZ_DISABLED 0
+#define DRI_CONF_HYPERZ_ENABLED 1
+#define DRI_CONF_HYPERZ(def) \
+DRI_CONF_OPT_BEGIN(hyperz,bool,def) \
+ DRI_CONF_DESC(en,gettext("Use HyperZ to boost performance")) \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_MAX_TEXTURE_UNITS(def,min,max) \
+DRI_CONF_OPT_BEGIN_V(texture_units,int,def, # min ":" # max ) \
+ DRI_CONF_DESC(en,gettext("Number of texture units used")) \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_TEXTURE_LEVEL_HACK(def) \
+DRI_CONF_OPT_BEGIN(texture_level_hack,bool,def) \
+ DRI_CONF_DESC(en,gettext("Enable hack to allow larger textures with texture compression on radeon/r200")) \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_TEXTURE_BLEND_QUALITY(def,range) \
+DRI_CONF_OPT_BEGIN_V(texture_blend_quality,float,def,range) \
+ DRI_CONF_DESC(en,gettext("Texture filtering quality vs. speed, AKA “brilinear†texture filtering")) \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_TEXTURE_HEAPS_ALL 0
+#define DRI_CONF_TEXTURE_HEAPS_CARD 1
+#define DRI_CONF_TEXTURE_HEAPS_GART 2
+#define DRI_CONF_TEXTURE_HEAPS(def) \
+DRI_CONF_OPT_BEGIN_V(texture_heaps,enum,def,"0:2") \
+ DRI_CONF_DESC_BEGIN(en,gettext("Used types of texture memory")) \
+ DRI_CONF_ENUM(0,gettext("All available memory")) \
+ DRI_CONF_ENUM(1,gettext("Only card memory (if available)")) \
+ DRI_CONF_ENUM(2,gettext("Only GART (AGP/PCIE) memory (if available)")) \
+ DRI_CONF_DESC_END \
+DRI_CONF_OPT_END
+
+/* Options for features that are not done in hardware by the driver (like GL_ARB_vertex_program
+ On cards where there is no documentation (r200) or on rasterization-only hardware). */
+#define DRI_CONF_SECTION_SOFTWARE \
+DRI_CONF_SECTION_BEGIN \
+ DRI_CONF_DESC(en,gettext("Features that are not hardware-accelerated"))
+
+#define DRI_CONF_ARB_VERTEX_PROGRAM(def) \
+DRI_CONF_OPT_BEGIN(arb_vertex_program,bool,def) \
+ DRI_CONF_DESC(en,gettext("Enable extension GL_ARB_vertex_program")) \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_NV_VERTEX_PROGRAM(def) \
+DRI_CONF_OPT_BEGIN(nv_vertex_program,bool,def) \
+ DRI_CONF_DESC(en,gettext("Enable extension GL_NV_vertex_program")) \
+DRI_CONF_OPT_END
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/fb/Doxyfile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/fb/Doxyfile
new file mode 100644
index 000000000..31256db83
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/fb/Doxyfile
@@ -0,0 +1,232 @@
+# Doxyfile 1.3.2-Gideon
+
+#---------------------------------------------------------------------------
+# General configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME = fb
+PROJECT_NUMBER = $VERSION$
+OUTPUT_DIRECTORY =
+OUTPUT_LANGUAGE = English
+USE_WINDOWS_ENCODING = NO
+EXTRACT_ALL = NO
+EXTRACT_PRIVATE = NO
+EXTRACT_STATIC = NO
+EXTRACT_LOCAL_CLASSES = YES
+HIDE_UNDOC_MEMBERS = NO
+HIDE_UNDOC_CLASSES = NO
+HIDE_FRIEND_COMPOUNDS = NO
+HIDE_IN_BODY_DOCS = NO
+BRIEF_MEMBER_DESC = YES
+REPEAT_BRIEF = YES
+ALWAYS_DETAILED_SEC = NO
+INLINE_INHERITED_MEMB = NO
+FULL_PATH_NAMES = NO
+STRIP_FROM_PATH =
+INTERNAL_DOCS = NO
+CASE_SENSE_NAMES = YES
+SHORT_NAMES = NO
+HIDE_SCOPE_NAMES = NO
+SHOW_INCLUDE_FILES = YES
+JAVADOC_AUTOBRIEF = NO
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP = NO
+INHERIT_DOCS = YES
+INLINE_INFO = YES
+SORT_MEMBER_DOCS = YES
+DISTRIBUTE_GROUP_DOC = NO
+TAB_SIZE = 8
+GENERATE_TODOLIST = YES
+GENERATE_TESTLIST = YES
+GENERATE_BUGLIST = YES
+GENERATE_DEPRECATEDLIST= YES
+ALIASES =
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 30
+OPTIMIZE_OUTPUT_FOR_C = NO
+OPTIMIZE_OUTPUT_JAVA = NO
+SHOW_USED_FILES = YES
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET = NO
+WARNINGS = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_IF_DOC_ERROR = YES
+WARN_FORMAT = "$file:$line: $text"
+WARN_LOGFILE =
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT = /home/temp/Mesa/src/drv/fb
+FILE_PATTERNS = *.c \
+ *.cc \
+ *.cxx \
+ *.cpp \
+ *.c++ \
+ *.java \
+ *.ii \
+ *.ixx \
+ *.ipp \
+ *.i++ \
+ *.inl \
+ *.h \
+ *.hh \
+ *.hxx \
+ *.hpp \
+ *.h++ \
+ *.idl \
+ *.odl \
+ *.cs \
+ *.C \
+ *.H \
+ *.tlh \
+ *.diff \
+ *.patch \
+ *.moc \
+ *.xpm
+RECURSIVE = yes
+EXCLUDE =
+EXCLUDE_SYMLINKS = NO
+EXCLUDE_PATTERNS =
+EXAMPLE_PATH =
+EXAMPLE_PATTERNS = *
+EXAMPLE_RECURSIVE = NO
+IMAGE_PATH =
+INPUT_FILTER =
+FILTER_SOURCE_FILES = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER = NO
+INLINE_SOURCES = NO
+STRIP_CODE_COMMENTS = YES
+REFERENCED_BY_RELATION = YES
+REFERENCES_RELATION = YES
+VERBATIM_HEADERS = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX = NO
+COLS_IN_ALPHA_INDEX = 5
+IGNORE_PREFIX =
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML = YES
+HTML_OUTPUT = html
+HTML_FILE_EXTENSION = .html
+HTML_HEADER =
+HTML_FOOTER =
+HTML_STYLESHEET =
+HTML_ALIGN_MEMBERS = YES
+GENERATE_HTMLHELP = NO
+CHM_FILE =
+HHC_LOCATION =
+GENERATE_CHI = NO
+BINARY_TOC = NO
+TOC_EXPAND = NO
+DISABLE_INDEX = NO
+ENUM_VALUES_PER_LINE = 4
+GENERATE_TREEVIEW = NO
+TREEVIEW_WIDTH = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX = YES
+LATEX_OUTPUT = latex
+LATEX_CMD_NAME = latex
+MAKEINDEX_CMD_NAME = makeindex
+COMPACT_LATEX = NO
+PAPER_TYPE = a4wide
+EXTRA_PACKAGES =
+LATEX_HEADER =
+PDF_HYPERLINKS = NO
+USE_PDFLATEX = NO
+LATEX_BATCHMODE = NO
+LATEX_HIDE_INDICES = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF = NO
+RTF_OUTPUT = rtf
+COMPACT_RTF = NO
+RTF_HYPERLINKS = NO
+RTF_STYLESHEET_FILE =
+RTF_EXTENSIONS_FILE =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN = NO
+MAN_OUTPUT = man
+MAN_EXTENSION = .3
+MAN_LINKS = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML = yes
+XML_OUTPUT = xml
+XML_SCHEMA =
+XML_DTD =
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD = NO
+PERLMOD_LATEX = NO
+PERLMOD_PRETTY = YES
+PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = NO
+EXPAND_ONLY_PREDEF = NO
+SEARCH_INCLUDES = YES
+INCLUDE_PATH =
+INCLUDE_FILE_PATTERNS =
+PREDEFINED =
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = YES
+#---------------------------------------------------------------------------
+# Configuration::addtions related to external references
+#---------------------------------------------------------------------------
+TAGFILES =
+GENERATE_TAGFILE =
+ALLEXTERNALS = NO
+EXTERNAL_GROUPS = YES
+PERL_PATH = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS = YES
+HIDE_UNDOC_RELATIONS = YES
+HAVE_DOT = NO
+CLASS_GRAPH = YES
+COLLABORATION_GRAPH = YES
+UML_LOOK = NO
+TEMPLATE_RELATIONS = NO
+INCLUDE_GRAPH = YES
+INCLUDED_BY_GRAPH = YES
+CALL_GRAPH = NO
+GRAPHICAL_HIERARCHY = YES
+DOT_IMAGE_FORMAT = png
+DOT_PATH =
+DOTFILE_DIRS =
+MAX_DOT_GRAPH_WIDTH = 1024
+MAX_DOT_GRAPH_HEIGHT = 1024
+MAX_DOT_GRAPH_DEPTH = 1000
+GENERATE_LEGEND = YES
+DOT_CLEANUP = YES
+#---------------------------------------------------------------------------
+# Configuration::addtions related to the search engine
+#---------------------------------------------------------------------------
+SEARCHENGINE = NO
+CGI_NAME = search.cgi
+CGI_URL =
+DOC_URL =
+DOC_ABSPATH =
+BIN_ABSPATH = /usr/local/bin/
+EXT_DOC_PATHS =
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/fb/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/fb/Makefile
new file mode 100644
index 000000000..12465c9f4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/fb/Makefile
@@ -0,0 +1,21 @@
+# src/mesa/drivers/dri/fb/Makefile
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = fb_dri.so
+
+DRIVER_SOURCES = \
+ fb_dri.c \
+ fb_egl.c
+
+C_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+include ../Makefile.template
+
+symlinks:
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/fb/fb_dri.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/fb/fb_dri.c
new file mode 100644
index 000000000..e2ba66d2e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/fb/fb_dri.c
@@ -0,0 +1,786 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/* Minimal swrast-based dri loadable driver.
+ *
+ * Todo:
+ * -- Use malloced (rather than framebuffer) memory for backbuffer
+ * -- 32bpp is hardwared -- fix
+ *
+ * NOTES:
+ * -- No mechanism for cliprects or resize notification --
+ * assumes this is a fullscreen device.
+ * -- No locking -- assumes this is the only driver accessing this
+ * device.
+ * -- Doesn't (yet) make use of any acceleration or other interfaces
+ * provided by fb. Would be entirely happy working against any
+ * fullscreen interface.
+ * -- HOWEVER: only a small number of pixelformats are supported, and
+ * the mechanism for choosing between them makes some assumptions
+ * that may not be valid everywhere.
+ */
+
+#include "driver.h"
+#include "drm.h"
+#include "utils.h"
+#include "drirenderbuffer.h"
+
+#include "buffers.h"
+#include "extensions.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+#include "array_cache/acache.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
+void fbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis);
+
+typedef struct {
+ GLcontext *glCtx; /* Mesa context */
+
+ struct {
+ __DRIcontextPrivate *context;
+ __DRIscreenPrivate *screen;
+ __DRIdrawablePrivate *drawable; /* drawable bound to this ctx */
+ } dri;
+
+} fbContext, *fbContextPtr;
+
+#define FB_CONTEXT(ctx) ((fbContextPtr)(ctx->DriverCtx))
+
+
+static const GLubyte *
+get_string(GLcontext *ctx, GLenum pname)
+{
+ (void) ctx;
+ switch (pname) {
+ case GL_RENDERER:
+ return (const GLubyte *) "Mesa dumb framebuffer";
+ default:
+ return NULL;
+ }
+}
+
+
+static void
+update_state( GLcontext *ctx, GLuint new_state )
+{
+ /* not much to do here - pass it on */
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+}
+
+
+/**
+ * Called by ctx->Driver.GetBufferSize from in core Mesa to query the
+ * current framebuffer size.
+ */
+static void
+get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ fbContextPtr fbmesa = FB_CONTEXT(ctx);
+
+ *width = fbmesa->dri.drawable->w;
+ *height = fbmesa->dri.drawable->h;
+}
+
+
+static void
+viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ _mesa_ResizeBuffersMESA();
+}
+
+
+static void
+init_core_functions( struct dd_function_table *functions )
+{
+ functions->GetString = get_string;
+ functions->UpdateState = update_state;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
+ functions->GetBufferSize = get_buffer_size;
+ functions->Viewport = viewport;
+
+ functions->Clear = _swrast_Clear; /* could accelerate with blits */
+}
+
+
+/*
+ * Generate code for span functions.
+ */
+
+/* 24-bit BGR */
+#define NAME(PREFIX) PREFIX##_B8G8R8
+#define FORMAT GL_RGBA8
+#define SPAN_VARS \
+ driRenderbuffer *drb = (driRenderbuffer *) rb;
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLubyte *P = (GLubyte *)drb->Base.Data + (drb->Base.Height - (Y)) * drb->pitch + (X) * 3;
+#define INC_PIXEL_PTR(P) P += 3
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = VALUE[BCOMP]; \
+ DST[1] = VALUE[GCOMP]; \
+ DST[2] = VALUE[RCOMP]
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = SRC[2]; \
+ DST[GCOMP] = SRC[1]; \
+ DST[BCOMP] = SRC[0]; \
+ DST[ACOMP] = 0xff
+
+#include "swrast/s_spantemp.h"
+
+
+/* 32-bit BGRA */
+#define NAME(PREFIX) PREFIX##_B8G8R8A8
+#define FORMAT GL_RGBA8
+#define SPAN_VARS \
+ driRenderbuffer *drb = (driRenderbuffer *) rb;
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLubyte *P = (GLubyte *)drb->Base.Data + (drb->Base.Height - (Y)) * drb->pitch + (X) * 4;
+#define INC_PIXEL_PTR(P) P += 4
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = VALUE[BCOMP]; \
+ DST[1] = VALUE[GCOMP]; \
+ DST[2] = VALUE[RCOMP]; \
+ DST[3] = VALUE[ACOMP]
+#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
+ DST[0] = VALUE[BCOMP]; \
+ DST[1] = VALUE[GCOMP]; \
+ DST[2] = VALUE[RCOMP]; \
+ DST[3] = 0xff
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = SRC[2]; \
+ DST[GCOMP] = SRC[1]; \
+ DST[BCOMP] = SRC[0]; \
+ DST[ACOMP] = SRC[3]
+
+#include "swrast/s_spantemp.h"
+
+
+/* 16-bit BGR (XXX implement dithering someday) */
+#define NAME(PREFIX) PREFIX##_B5G6R5
+#define FORMAT GL_RGBA8
+#define SPAN_VARS \
+ driRenderbuffer *drb = (driRenderbuffer *) rb;
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLushort *P = (GLushort *)drb->Base.Data + (drb->Base.Height - (Y)) * drb->pitch + (X) * 2;
+#define INC_PIXEL_PTR(P) P += 1
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = ( (((VALUE[RCOMP]) & 0xf8) << 8) | (((VALUE[GCOMP]) & 0xfc) << 3) | ((VALUE[BCOMP]) >> 3) )
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = ( (((SRC[0]) >> 8) & 0xf8) | (((SRC[0]) >> 11) & 0x7) ); \
+ DST[GCOMP] = ( (((SRC[0]) >> 3) & 0xfc) | (((SRC[0]) >> 5) & 0x3) ); \
+ DST[BCOMP] = ( (((SRC[0]) << 3) & 0xf8) | (((SRC[0]) ) & 0x7) ); \
+ DST[ACOMP] = 0xff
+
+#include "swrast/s_spantemp.h"
+
+
+/* 15-bit BGR (XXX implement dithering someday) */
+#define NAME(PREFIX) PREFIX##_B5G5R5
+#define FORMAT GL_RGBA8
+#define SPAN_VARS \
+ driRenderbuffer *drb = (driRenderbuffer *) rb;
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLushort *P = (GLushort *)drb->Base.Data + (drb->Base.Height - (Y)) * drb->pitch + (X) * 2;
+#define INC_PIXEL_PTR(P) P += 1
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = ( (((VALUE[RCOMP]) & 0xf8) << 7) | (((VALUE[GCOMP]) & 0xf8) << 2) | ((VALUE[BCOMP]) >> 3) )
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = ( (((SRC[0]) >> 7) & 0xf8) | (((SRC[0]) >> 10) & 0x7) ); \
+ DST[GCOMP] = ( (((SRC[0]) >> 2) & 0xf8) | (((SRC[0]) >> 5) & 0x7) ); \
+ DST[BCOMP] = ( (((SRC[0]) << 3) & 0xf8) | (((SRC[0]) ) & 0x7) ); \
+ DST[ACOMP] = 0xff
+
+#include "swrast/s_spantemp.h"
+
+
+/* 8-bit color index */
+#define NAME(PREFIX) PREFIX##_CI8
+#define FORMAT GL_COLOR_INDEX8_EXT
+#define SPAN_VARS \
+ driRenderbuffer *drb = (driRenderbuffer *) rb;
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLubyte *P = (GLubyte *)drb->Base.Data + (drb->Base.Height - (Y)) * drb->pitch + (X);
+#define INC_PIXEL_PTR(P) P += 1
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ *DST = VALUE[0]
+#define FETCH_PIXEL(DST, SRC) \
+ DST = SRC[0]
+
+#include "swrast/s_spantemp.h"
+
+
+
+void
+fbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ ASSERT(drb->Base.InternalFormat == GL_RGBA);
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ drb->Base.GetRow = get_row_B5G6R5;
+ drb->Base.GetValues = get_values_B5G6R5;
+ drb->Base.PutRow = put_row_B5G6R5;
+ drb->Base.PutMonoRow = put_mono_row_B5G6R5;
+ drb->Base.PutRowRGB = put_row_rgb_B5G6R5;
+ drb->Base.PutValues = put_values_B5G6R5;
+ drb->Base.PutMonoValues = put_mono_values_B5G6R5;
+ }
+ else if (vis->redBits == 5 && vis->greenBits == 5 && vis->blueBits == 5) {
+ drb->Base.GetRow = get_row_B5G5R5;
+ drb->Base.GetValues = get_values_B5G5R5;
+ drb->Base.PutRow = put_row_B5G5R5;
+ drb->Base.PutMonoRow = put_mono_row_B5G5R5;
+ drb->Base.PutRowRGB = put_row_rgb_B5G5R5;
+ drb->Base.PutValues = put_values_B5G5R5;
+ drb->Base.PutMonoValues = put_mono_values_B5G5R5;
+ }
+ else if (vis->redBits == 8 && vis->greenBits == 8 && vis->blueBits == 8
+ && vis->alphaBits == 8) {
+ drb->Base.GetRow = get_row_B8G8R8A8;
+ drb->Base.GetValues = get_values_B8G8R8A8;
+ drb->Base.PutRow = put_row_B8G8R8A8;
+ drb->Base.PutMonoRow = put_mono_row_B8G8R8A8;
+ drb->Base.PutRowRGB = put_row_rgb_B8G8R8A8;
+ drb->Base.PutValues = put_values_B8G8R8A8;
+ drb->Base.PutMonoValues = put_mono_values_B8G8R8A8;
+ }
+ else if (vis->redBits == 8 && vis->greenBits == 8 && vis->blueBits == 8
+ && vis->alphaBits == 0) {
+ drb->Base.GetRow = get_row_B8G8R8;
+ drb->Base.GetValues = get_values_B8G8R8;
+ drb->Base.PutRow = put_row_B8G8R8;
+ drb->Base.PutMonoRow = put_mono_row_B8G8R8;
+ drb->Base.PutRowRGB = put_row_rgb_B8G8R8;
+ drb->Base.PutValues = put_values_B8G8R8;
+ drb->Base.PutMonoValues = put_mono_values_B8G8R8;
+ }
+ else if (vis->indexBits == 8) {
+ drb->Base.GetRow = get_row_CI8;
+ drb->Base.GetValues = get_values_CI8;
+ drb->Base.PutRow = put_row_CI8;
+ drb->Base.PutMonoRow = put_mono_row_CI8;
+ drb->Base.PutValues = put_values_CI8;
+ drb->Base.PutMonoValues = put_mono_values_CI8;
+ }
+ }
+ else {
+ /* hardware z/stencil/etc someday */
+ }
+}
+
+
+
+/* Initialize the driver specific screen private data.
+ */
+static GLboolean
+fbInitDriver( __DRIscreenPrivate *sPriv )
+{
+ sPriv->private = NULL;
+ return GL_TRUE;
+}
+
+static void
+fbDestroyScreen( __DRIscreenPrivate *sPriv )
+{
+}
+
+void fbSetBuffer( GLcontext *ctx,
+ GLframebuffer *colorBuffer,
+ GLuint bufferBit )
+{
+ /* NOP until SetBuffer is fully removed */
+}
+
+/* Create the device specific context.
+ */
+static GLboolean
+fbCreateContext( const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate)
+{
+ fbContextPtr fbmesa;
+ GLcontext *ctx, *shareCtx;
+ struct dd_function_table functions;
+
+ assert(glVisual);
+ assert(driContextPriv);
+
+ /* Allocate the Fb context */
+ fbmesa = (fbContextPtr) _mesa_calloc( sizeof(*fbmesa) );
+ if ( !fbmesa )
+ return GL_FALSE;
+
+ /* Init default driver functions then plug in our FBdev-specific functions
+ */
+ _mesa_init_driver_functions(&functions);
+ init_core_functions(&functions);
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((fbContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+
+ ctx = fbmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
+ &functions, (void *) fbmesa);
+ if (!fbmesa->glCtx) {
+ _mesa_free(fbmesa);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = fbmesa;
+
+ /* Create module contexts */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+ _swsetup_Wakeup( ctx );
+
+
+ /* swrast init -- need to verify these tests - I just plucked the
+ * numbers out of the air. (KW)
+ */
+ {
+ struct swrast_device_driver *swdd;
+ swdd = _swrast_GetDeviceDriverReference( ctx );
+ swdd->SetBuffer = fbSetBuffer;
+ }
+
+ /* use default TCL pipeline */
+ {
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.RunPipeline = _tnl_run_pipeline;
+ }
+
+ _mesa_enable_sw_extensions(ctx);
+
+ return GL_TRUE;
+}
+
+
+static void
+fbDestroyContext( __DRIcontextPrivate *driContextPriv )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ fbContextPtr fbmesa = (fbContextPtr) driContextPriv->driverPrivate;
+ fbContextPtr current = ctx ? FB_CONTEXT(ctx) : NULL;
+
+ /* check if we're deleting the currently bound context */
+ if (fbmesa == current) {
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ /* Free fb context resources */
+ if ( fbmesa ) {
+ _swsetup_DestroyContext( fbmesa->glCtx );
+ _tnl_DestroyContext( fbmesa->glCtx );
+ _ac_DestroyContext( fbmesa->glCtx );
+ _swrast_DestroyContext( fbmesa->glCtx );
+
+ /* free the Mesa context */
+ fbmesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context( fbmesa->glCtx );
+
+ _mesa_free( fbmesa );
+ }
+}
+
+
+/* Create and initialize the Mesa and driver specific pixmap buffer
+ * data.
+ */
+static GLboolean
+fbCreateBuffer( __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ struct gl_framebuffer *mesa_framebuffer;
+
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+ const GLboolean swDepth = mesaVis->depthBits > 0;
+ const GLboolean swAlpha = mesaVis->alphaBits > 0;
+ const GLboolean swAccum = mesaVis->accumRedBits > 0;
+ const GLboolean swStencil = mesaVis->stencilBits > 0;
+
+ mesa_framebuffer = _mesa_create_framebuffer(mesaVis);
+ if (!mesa_framebuffer)
+ return 0;
+
+ /* XXX double-check these parameters (bpp vs cpp, etc) */
+ {
+ driRenderbuffer *drb = driNewRenderbuffer(GL_RGBA, driScrnPriv->fbBPP / 8,
+ driScrnPriv->fbOrigin,
+ driScrnPriv->fbStride);
+ fbSetSpanFunctions(drb, mesaVis);
+ drb->Base.Data = driScrnPriv->pFB;
+ _mesa_add_renderbuffer(mesa_framebuffer,
+ BUFFER_FRONT_LEFT, &drb->Base);
+ }
+ if (mesaVis->doubleBufferMode) {
+ /* XXX what are the correct origin/stride values? */
+ driRenderbuffer *drb = driNewRenderbuffer(GL_RGBA, driScrnPriv->fbBPP /8,
+ driScrnPriv->fbOrigin,
+ driScrnPriv->fbStride);
+ fbSetSpanFunctions(drb, mesaVis);
+ drb->Base.Data = _mesa_malloc(driScrnPriv->fbStride * driScrnPriv->fbHeight);
+ _mesa_add_renderbuffer(mesa_framebuffer,
+ BUFFER_BACK_LEFT, &drb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(mesa_framebuffer,
+ GL_FALSE, /* color */
+ swDepth,
+ swStencil,
+ swAccum,
+ 0,
+ GL_FALSE /* aux */);
+
+ driDrawPriv->driverPrivate = mesa_framebuffer;
+
+ return 1;
+ }
+}
+
+
+static void
+fbDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ struct gl_framebuffer *mesa_framebuffer = (struct gl_framebuffer *)driDrawPriv->driverPrivate;
+
+ _mesa_free(mesa_framebuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer->Data);
+ _mesa_destroy_framebuffer(mesa_framebuffer);
+ driDrawPriv->driverPrivate = NULL;
+}
+
+
+
+/* If the backbuffer is on a videocard, this is extraordinarily slow!
+ */
+static void
+fbSwapBuffers( __DRIdrawablePrivate *dPriv )
+{
+ struct gl_framebuffer *mesa_framebuffer = (struct gl_framebuffer *)dPriv->driverPrivate;
+ struct gl_renderbuffer * front_renderbuffer = mesa_framebuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
+ void *frontBuffer = front_renderbuffer->Data;
+ int currentPitch = ((driRenderbuffer *)front_renderbuffer)->pitch;
+ void *backBuffer = mesa_framebuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer->Data;
+
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ fbContextPtr fbmesa = (fbContextPtr) dPriv->driContextPriv->driverPrivate;
+ GLcontext *ctx = fbmesa->glCtx;
+
+ if (ctx->Visual.doubleBufferMode) {
+ int i;
+ int offset = 0;
+ char *tmp = _mesa_malloc(currentPitch);
+
+ _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
+
+ ASSERT(frontBuffer);
+ ASSERT(backBuffer);
+
+ for (i = 0; i < dPriv->h; i++) {
+ _mesa_memcpy(tmp, (char *) backBuffer + offset,
+ currentPitch);
+ _mesa_memcpy((char *) frontBuffer + offset, tmp,
+ currentPitch);
+ offset += currentPitch;
+ }
+
+ _mesa_free(tmp);
+ }
+ }
+ else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ _mesa_problem(NULL, "fbSwapBuffers: drawable has no context!\n");
+ }
+}
+
+
+/* Force the context `c' to be the current context and associate with it
+ * buffer `b'.
+ */
+static GLboolean
+fbMakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv )
+{
+ if ( driContextPriv ) {
+ fbContextPtr newFbCtx =
+ (fbContextPtr) driContextPriv->driverPrivate;
+
+ newFbCtx->dri.drawable = driDrawPriv;
+
+ _mesa_make_current( newFbCtx->glCtx,
+ driDrawPriv->driverPrivate,
+ driReadPriv->driverPrivate);
+ } else {
+ _mesa_make_current( NULL, NULL, NULL );
+ }
+
+ return GL_TRUE;
+}
+
+
+/* Force the context `c' to be unbound from its buffer.
+ */
+static GLboolean
+fbUnbindContext( __DRIcontextPrivate *driContextPriv )
+{
+ return GL_TRUE;
+}
+
+static struct __DriverAPIRec fbAPI = {
+ .InitDriver = fbInitDriver,
+ .DestroyScreen = fbDestroyScreen,
+ .CreateContext = fbCreateContext,
+ .DestroyContext = fbDestroyContext,
+ .CreateBuffer = fbCreateBuffer,
+ .DestroyBuffer = fbDestroyBuffer,
+ .SwapBuffers = fbSwapBuffers,
+ .MakeCurrent = fbMakeCurrent,
+ .UnbindContext = fbUnbindContext,
+};
+
+
+
+static int
+__driValidateMode(const DRIDriverContext *ctx )
+{
+ return 1;
+}
+
+static int
+__driInitFBDev( struct DRIDriverContextRec *ctx )
+{
+ /* Note that drmOpen will try to load the kernel module, if needed. */
+ /* we need a fbdev drm driver - it will only track maps */
+ ctx->drmFD = drmOpen("radeon", NULL );
+ if (ctx->drmFD < 0) {
+ fprintf(stderr, "[drm] drmOpen failed\n");
+ return 0;
+ }
+
+ ctx->shared.SAREASize = SAREA_MAX;
+
+ if (drmAddMap( ctx->drmFD,
+ 0,
+ ctx->shared.SAREASize,
+ DRM_SHM,
+ DRM_CONTAINS_LOCK,
+ &ctx->shared.hSAREA) < 0)
+ {
+ fprintf(stderr, "[drm] drmAddMap failed\n");
+ return 0;
+ }
+ fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n",
+ ctx->shared.SAREASize, ctx->shared.hSAREA);
+
+ if (drmMap( ctx->drmFD,
+ ctx->shared.hSAREA,
+ ctx->shared.SAREASize,
+ (drmAddressPtr)(&ctx->pSAREA)) < 0)
+ {
+ fprintf(stderr, "[drm] drmMap failed\n");
+ return 0;
+ }
+ memset(ctx->pSAREA, 0, ctx->shared.SAREASize);
+ fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n",
+ ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize);
+
+ /* Need to AddMap the framebuffer and mmio regions here:
+ */
+ if (drmAddMap( ctx->drmFD,
+ (drm_handle_t)ctx->FBStart,
+ ctx->FBSize,
+ DRM_FRAME_BUFFER,
+#ifndef _EMBEDDED
+ 0,
+#else
+ DRM_READ_ONLY,
+#endif
+ &ctx->shared.hFrameBuffer) < 0)
+ {
+ fprintf(stderr, "[drm] drmAddMap framebuffer failed\n");
+ return 0;
+ }
+
+ fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n",
+ ctx->shared.hFrameBuffer);
+
+ return 1;
+}
+
+static void
+__driHaltFBDev( struct DRIDriverContextRec *ctx )
+{
+}
+
+struct DRIDriverRec __driDriver = {
+ __driValidateMode,
+ __driValidateMode,
+ __driInitFBDev,
+ __driHaltFBDev
+};
+
+static __GLcontextModes *
+fbFillInModes( unsigned pixel_bits, unsigned depth_bits,
+ unsigned stencil_bits, GLboolean have_back_buffer )
+{
+ __GLcontextModes * modes;
+ __GLcontextModes * m;
+ unsigned num_modes;
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ GLenum fb_format;
+ GLenum fb_type;
+
+ /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
+ * enough to add support. Basically, if a context is created with an
+ * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
+ * will never be used.
+ */
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
+ };
+
+ u_int8_t depth_bits_array[2];
+ u_int8_t stencil_bits_array[2];
+
+
+ depth_bits_array[0] = depth_bits;
+ depth_bits_array[1] = depth_bits;
+
+ /* Just like with the accumulation buffer, always provide some modes
+ * with a stencil buffer. It will be a sw fallback, but some apps won't
+ * care about that.
+ */
+ stencil_bits_array[0] = 0;
+ stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
+
+ depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1;
+ back_buffer_factor = (have_back_buffer) ? 2 : 1;
+
+ num_modes = depth_buffer_factor * back_buffer_factor * 4;
+
+ if ( pixel_bits == 16 ) {
+ fb_format = GL_RGB;
+ fb_type = GL_UNSIGNED_SHORT_5_6_5;
+ }
+ else {
+ fb_format = GL_RGBA;
+ fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ }
+
+ modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
+ m = modes;
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_TRUE_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_DIRECT_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+
+ /* Mark the visual as slow if there are "fake" stencil bits.
+ */
+ for ( m = modes ; m != NULL ; m = m->next ) {
+ if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) {
+ m->visualRating = GLX_SLOW_CONFIG;
+ }
+ }
+
+ return modes;
+}
+
+
+/**
+ * This is the bootstrap function for the driver. libGL supplies all of the
+ * requisite information about the system, and the driver initializes itself.
+ * This routine also fills in the linked list pointed to by \c driver_modes
+ * with the \c __GLcontextModes that the driver can support for windows or
+ * pbuffers.
+ *
+ * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
+ * failure.
+ */
+PUBLIC
+void * __driCreateNewScreen( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
+ const __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drmAddress pSAREA, int fd,
+ int internal_api_version,
+ __GLcontextModes ** driver_modes )
+{
+ __DRIscreenPrivate *psp;
+ static const __DRIversion ddx_expected = { 4, 0, 0 };
+ static const __DRIversion dri_expected = { 4, 0, 0 };
+ static const __DRIversion drm_expected = { 1, 5, 0 };
+
+
+ if ( ! driCheckDriDdxDrmVersions2( "fb",
+ dri_version, & dri_expected,
+ ddx_version, & ddx_expected,
+ drm_version, & drm_expected ) ) {
+ return NULL;
+ }
+
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &fbAPI);
+ if ( psp != NULL ) {
+ *driver_modes = fbFillInModes( psp->fbBPP,
+ (psp->fbBPP == 16) ? 16 : 24,
+ (psp->fbBPP == 16) ? 0 : 8,
+ 1);
+ }
+
+ return (void *) psp;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/fb/fb_egl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/fb/fb_egl.c
new file mode 100644
index 000000000..2cea48808
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/fb/fb_egl.c
@@ -0,0 +1,881 @@
+/*
+ * Test egl driver for fb_dri.so
+ */
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <linux/fb.h>
+
+#include "utils.h"
+#include "buffers.h"
+#include "extensions.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+#include "array_cache/acache.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+#include "drirenderbuffer.h"
+
+#include "eglconfig.h"
+#include "eglcontext.h"
+#include "egldisplay.h"
+#include "egldriver.h"
+#include "eglglobals.h"
+#include "eglmode.h"
+#include "eglscreen.h"
+#include "eglsurface.h"
+
+extern void
+fbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis);
+extern void
+fbSetBuffer( GLcontext *ctx, GLframebuffer *colorBuffer, GLuint bufferBit);
+
+/**
+ * fb driver-specific driver class derived from _EGLDriver
+ */
+typedef struct fb_driver
+{
+ _EGLDriver Base; /* base class/object */
+ GLuint fbStuff;
+} fbDriver;
+
+/**
+ * fb display-specific driver class derived from _EGLDisplay
+ */
+typedef struct fb_display
+{
+ _EGLDisplay Base; /* base class/object */
+ void *pFB;
+} fbDisplay;
+
+/**
+ * fb driver-specific screen class derived from _EGLScreen
+ */
+typedef struct fb_screen
+{
+ _EGLScreen Base;
+ char fb[NAME_MAX];
+} fbScreen;
+
+
+/**
+ * fb driver-specific surface class derived from _EGLSurface
+ */
+typedef struct fb_surface
+{
+ _EGLSurface Base; /* base class/object */
+ struct gl_framebuffer *mesa_framebuffer;
+} fbSurface;
+
+
+/**
+ * fb driver-specific context class derived from _EGLContext
+ */
+typedef struct fb_context
+{
+ _EGLContext Base; /* base class/object */
+ GLcontext *glCtx;
+} fbContext;
+
+
+static EGLBoolean
+fbFillInConfigs(_EGLDisplay *disp, unsigned pixel_bits, unsigned depth_bits,
+ unsigned stencil_bits, GLboolean have_back_buffer) {
+ _EGLConfig *configs;
+ _EGLConfig *c;
+ unsigned int i, num_configs;
+ unsigned int depth_buffer_factor;
+ unsigned int back_buffer_factor;
+ GLenum fb_format;
+ GLenum fb_type;
+
+ /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
+ * enough to add support. Basically, if a context is created with an
+ * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
+ * will never be used.
+ */
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
+ };
+
+ u_int8_t depth_bits_array[2];
+ u_int8_t stencil_bits_array[2];
+
+ depth_bits_array[0] = 0;
+ depth_bits_array[1] = depth_bits;
+
+ /* Just like with the accumulation buffer, always provide some modes
+ * with a stencil buffer. It will be a sw fallback, but some apps won't
+ * care about that.
+ */
+ stencil_bits_array[0] = 0;
+ stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
+
+ depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1;
+ back_buffer_factor = (have_back_buffer) ? 2 : 1;
+
+ num_configs = depth_buffer_factor * back_buffer_factor * 2;
+
+ if (pixel_bits == 16) {
+ fb_format = GL_RGB;
+ fb_type = GL_UNSIGNED_SHORT_5_6_5;
+ } else {
+ fb_format = GL_RGBA;
+ fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ }
+
+ configs = calloc(sizeof(*configs), num_configs);
+ c = configs;
+ if (!_eglFillInConfigs(c, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_TRUE_COLOR)) {
+ fprintf(stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__);
+ return EGL_FALSE;
+ }
+
+ /* Mark the visual as slow if there are "fake" stencil bits.
+ */
+ for (i = 0, c = configs; i < num_configs; i++, c++) {
+ int stencil = GET_CONFIG_ATTRIB(c, EGL_STENCIL_SIZE);
+ if ((stencil != 0) && (stencil != stencil_bits)) {
+ SET_CONFIG_ATTRIB(c, EGL_CONFIG_CAVEAT, EGL_SLOW_CONFIG);
+ }
+ }
+
+ for (i = 0, c = configs; i < num_configs; i++, c++)
+ _eglAddConfig(disp, c);
+
+ free(configs);
+
+ return EGL_TRUE;
+}
+
+static EGLBoolean
+fbSetupFramebuffer(fbDisplay *disp, char *fbdev)
+{
+ int fd;
+ char dev[20];
+ struct fb_var_screeninfo varInfo;
+ struct fb_fix_screeninfo fixedInfo;
+
+ snprintf(dev, sizeof(dev), "/dev/%s", fbdev);
+
+ /* open the framebuffer device */
+ fd = open(dev, O_RDWR);
+ if (fd < 0) {
+ fprintf(stderr, "Error opening %s: %s\n", fbdev, strerror(errno));
+ return EGL_FALSE;
+ }
+
+ /* get the original variable screen info */
+ if (ioctl(fd, FBIOGET_VSCREENINFO, &varInfo)) {
+ fprintf(stderr, "error: ioctl(FBIOGET_VSCREENINFO) failed: %s\n",
+ strerror(errno));
+ return EGL_FALSE;
+ }
+
+ /* Turn off hw accels (otherwise mmap of mmio region will be
+ * refused)
+ */
+ if (varInfo.accel_flags) {
+ varInfo.accel_flags = 0;
+ if (ioctl(fd, FBIOPUT_VSCREENINFO, &varInfo)) {
+ fprintf(stderr, "error: ioctl(FBIOPUT_VSCREENINFO) failed: %s\n",
+ strerror(errno));
+ return EGL_FALSE;
+ }
+ }
+
+ /* Get the fixed screen info */
+ if (ioctl(fd, FBIOGET_FSCREENINFO, &fixedInfo)) {
+ fprintf(stderr, "error: ioctl(FBIOGET_FSCREENINFO) failed: %s\n",
+ strerror(errno));
+ return EGL_FALSE;
+ }
+
+ if (fixedInfo.visual == FB_VISUAL_DIRECTCOLOR) {
+ struct fb_cmap cmap;
+ unsigned short red[256], green[256], blue[256];
+ int rcols = 1 << varInfo.red.length;
+ int gcols = 1 << varInfo.green.length;
+ int bcols = 1 << varInfo.blue.length;
+ int i;
+
+ cmap.start = 0;
+ cmap.len = gcols;
+ cmap.red = red;
+ cmap.green = green;
+ cmap.blue = blue;
+ cmap.transp = NULL;
+
+ for (i = 0; i < rcols ; i++)
+ red[i] = (65536/(rcols-1)) * i;
+
+ for (i = 0; i < gcols ; i++)
+ green[i] = (65536/(gcols-1)) * i;
+
+ for (i = 0; i < bcols ; i++)
+ blue[i] = (65536/(bcols-1)) * i;
+
+ if (ioctl(fd, FBIOPUTCMAP, (void *) &cmap) < 0) {
+ fprintf(stderr, "ioctl(FBIOPUTCMAP) failed [%d]\n", i);
+ exit(1);
+ }
+ }
+
+ /* mmap the framebuffer into our address space */
+ if (!disp->pFB)
+ disp->pFB = (caddr_t)mmap(0, /* start */
+ fixedInfo.smem_len, /* bytes */
+ PROT_READ | PROT_WRITE, /* prot */
+ MAP_SHARED, /* flags */
+ fd, /* fd */
+ 0); /* offset */
+ if (disp->pFB == (caddr_t)-1) {
+ fprintf(stderr, "error: unable to mmap framebuffer: %s\n",
+ strerror(errno));
+ return EGL_FALSE;
+ }
+
+ return EGL_TRUE;
+}
+
+const char *sysfs = "/sys/class/graphics";
+
+static EGLBoolean
+fbInitialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor)
+{
+ _EGLDisplay *disp = _eglLookupDisplay(dpy);
+ fbDisplay *display;
+ fbScreen *s;
+ _EGLScreen *scrn;
+ char c;
+ unsigned int x, y, r;
+ DIR *dir;
+ FILE *file;
+ struct dirent *dirent;
+ char path[NAME_MAX];
+
+ /* Switch display structure to one with our private fields */
+ display = calloc(1, sizeof(*display));
+ display->Base = *disp;
+ _eglHashInsert(_eglGlobal.Displays, disp->Handle, display);
+ free(disp);
+
+ *major = 1;
+ *minor = 0;
+
+ dir = opendir(sysfs);
+ if (!dir) {
+ printf("EGL - %s framebuffer device not found.", sysfs);
+ return EGL_FALSE;
+ }
+
+ while ((dirent = readdir(dir))) { /* assignment! */
+
+ if (dirent->d_name[0] != 'f')
+ continue;
+ if (dirent->d_name[1] != 'b')
+ continue;
+
+ if (fbSetupFramebuffer(display, dirent->d_name) == EGL_FALSE)
+ continue;
+
+ /* Create a screen */
+ s = (fbScreen *) calloc(1, sizeof(fbScreen));
+ if (!s)
+ return EGL_FALSE;
+
+ strncpy(s->fb, dirent->d_name, NAME_MAX);
+ scrn = &s->Base;
+ _eglInitScreen(scrn);
+ _eglAddScreen(&display->Base, scrn);
+
+ snprintf(path, sizeof(path), "%s/%s/modes", sysfs, s->fb);
+ file = fopen(path, "r");
+ while (fgets(path, sizeof(path), file)) {
+ sscanf(path, "%c:%ux%u-%u", &c, &x, &y, &r);
+ _eglAddMode(scrn, x, y, r * 1000, path);
+ }
+ fclose(file);
+
+ fbFillInConfigs(&display->Base, 32, 24, 8, 1);
+
+ }
+ closedir(dir);
+
+ drv->Initialized = EGL_TRUE;
+ return EGL_TRUE;
+}
+
+
+static fbDisplay *
+Lookup_fbDisplay(EGLDisplay dpy)
+{
+ _EGLDisplay *d = _eglLookupDisplay(dpy);
+ return (fbDisplay *) d;
+}
+
+
+static fbScreen *
+Lookup_fbScreen(EGLDisplay dpy, EGLScreenMESA screen)
+{
+ _EGLScreen *s = _eglLookupScreen(dpy, screen);
+ return (fbScreen *) s;
+}
+
+
+static fbContext *
+Lookup_fbContext(EGLContext ctx)
+{
+ _EGLContext *c = _eglLookupContext(ctx);
+ return (fbContext *) c;
+}
+
+
+static fbSurface *
+Lookup_fbSurface(EGLSurface surf)
+{
+ _EGLSurface *s = _eglLookupSurface(surf);
+ return (fbSurface *) s;
+}
+
+
+static EGLBoolean
+fbTerminate(_EGLDriver *drv, EGLDisplay dpy)
+{
+ fbDisplay *display = Lookup_fbDisplay(dpy);
+ _eglCleanupDisplay(&display->Base);
+ free(display);
+ free(drv);
+ return EGL_TRUE;
+}
+
+
+static const GLubyte *
+get_string(GLcontext *ctx, GLenum pname)
+{
+ (void) ctx;
+ switch (pname) {
+ case GL_RENDERER:
+ return (const GLubyte *) "Mesa dumb framebuffer";
+ default:
+ return NULL;
+ }
+}
+
+
+static void
+update_state( GLcontext *ctx, GLuint new_state )
+{
+ /* not much to do here - pass it on */
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+}
+
+
+/**
+ * Called by ctx->Driver.GetBufferSize from in core Mesa to query the
+ * current framebuffer size.
+ */
+static void
+get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
+{
+ *width = buffer->Width;
+ *height = buffer->Height;
+}
+
+
+static void
+viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ _mesa_ResizeBuffersMESA();
+}
+
+
+static void
+init_core_functions( struct dd_function_table *functions )
+{
+ functions->GetString = get_string;
+ functions->UpdateState = update_state;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
+ functions->GetBufferSize = get_buffer_size;
+ functions->Viewport = viewport;
+
+ functions->Clear = _swrast_Clear; /* could accelerate with blits */
+}
+
+
+static EGLContext
+fbCreateContext(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, EGLContext share_list, const EGLint *attrib_list)
+{
+ GLcontext *ctx;
+ _EGLConfig *conf;
+ fbContext *c;
+ _EGLDisplay *disp = _eglLookupDisplay(dpy);
+ struct dd_function_table functions;
+ GLvisual vis;
+ int i;
+
+ conf = _eglLookupConfig(drv, dpy, config);
+ if (!conf) {
+ _eglError(EGL_BAD_CONFIG, "eglCreateContext");
+ return EGL_NO_CONTEXT;
+ }
+
+ for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) {
+ switch (attrib_list[i]) {
+ /* no attribs defined for now */
+ default:
+ _eglError(EGL_BAD_ATTRIBUTE, "eglCreateContext");
+ return EGL_NO_CONTEXT;
+ }
+ }
+
+ c = (fbContext *) calloc(1, sizeof(fbContext));
+ if (!c)
+ return EGL_NO_CONTEXT;
+
+ _eglInitContext(&c->Base);
+ c->Base.Display = disp;
+ c->Base.Config = conf;
+ c->Base.DrawSurface = EGL_NO_SURFACE;
+ c->Base.ReadSurface = EGL_NO_SURFACE;
+
+ /* generate handle and insert into hash table */
+ _eglSaveContext(&c->Base);
+ assert(c->Base.Handle);
+
+ /* Init default driver functions then plug in our FBdev-specific functions
+ */
+ _mesa_init_driver_functions(&functions);
+ init_core_functions(&functions);
+
+ _eglConfigToContextModesRec(conf, &vis);
+
+ ctx = c->glCtx = _mesa_create_context(&vis, NULL, &functions, (void *)c);
+ if (!c->glCtx) {
+ _mesa_free(c);
+ return GL_FALSE;
+ }
+
+ /* Create module contexts */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+ _swsetup_Wakeup( ctx );
+
+
+ /* swrast init -- need to verify these tests - I just plucked the
+ * numbers out of the air. (KW)
+ */
+ {
+ struct swrast_device_driver *swdd;
+ swdd = _swrast_GetDeviceDriverReference( ctx );
+ swdd->SetBuffer = fbSetBuffer;
+ }
+
+ /* use default TCL pipeline */
+ {
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.RunPipeline = _tnl_run_pipeline;
+ }
+
+ _mesa_enable_sw_extensions(ctx);
+
+ return c->Base.Handle;
+}
+
+
+static EGLSurface
+fbCreateWindowSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativeWindowType window, const EGLint *attrib_list)
+{
+ int i;
+ for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) {
+ switch (attrib_list[i]) {
+ /* no attribs at this time */
+ default:
+ _eglError(EGL_BAD_ATTRIBUTE, "eglCreateWindowSurface");
+ return EGL_NO_SURFACE;
+ }
+ }
+ printf("eglCreateWindowSurface()\n");
+ /* XXX unfinished */
+
+ return EGL_NO_SURFACE;
+}
+
+
+static EGLSurface
+fbCreatePixmapSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, NativePixmapType pixmap, const EGLint *attrib_list)
+{
+ _EGLConfig *conf;
+ EGLint i;
+
+ conf = _eglLookupConfig(drv, dpy, config);
+ if (!conf) {
+ _eglError(EGL_BAD_CONFIG, "eglCreatePixmapSurface");
+ return EGL_NO_SURFACE;
+ }
+
+ for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) {
+ switch (attrib_list[i]) {
+ /* no attribs at this time */
+ default:
+ _eglError(EGL_BAD_ATTRIBUTE, "eglCreatePixmapSurface");
+ return EGL_NO_SURFACE;
+ }
+ }
+
+ if (conf->Attrib[EGL_SURFACE_TYPE - FIRST_ATTRIB] == 0) {
+ _eglError(EGL_BAD_MATCH, "eglCreatePixmapSurface");
+ return EGL_NO_SURFACE;
+ }
+
+ printf("eglCreatePixmapSurface()\n");
+ return EGL_NO_SURFACE;
+}
+
+
+static EGLSurface
+fbCreatePbufferSurface(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
+{
+ fbSurface *surf;
+
+ surf = (fbSurface *) calloc(1, sizeof(fbSurface));
+ if (!surf) {
+ return EGL_NO_SURFACE;
+ }
+
+ if (_eglInitPbufferSurface(&surf->Base, drv, dpy, config, attrib_list) == EGL_NO_SURFACE) {
+ free(surf);
+ return EGL_NO_SURFACE;
+ }
+
+ /* create software-based pbuffer */
+ {
+ GLcontext *ctx = NULL; /* this _should_ be OK */
+ GLvisual vis;
+ _EGLConfig *conf = _eglLookupConfig(drv, dpy, config);
+ assert(conf); /* bad config should be caught earlier */
+ _eglConfigToContextModesRec(conf, &vis);
+
+ surf->mesa_framebuffer = _mesa_create_framebuffer(&vis);
+ _mesa_add_soft_renderbuffers(surf->mesa_framebuffer,
+ GL_TRUE, /* color bufs */
+ vis.haveDepthBuffer,
+ vis.haveStencilBuffer,
+ vis.haveAccumBuffer,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */ );
+
+ /* set pbuffer/framebuffer size */
+ _mesa_resize_framebuffer(ctx, surf->mesa_framebuffer,
+ surf->Base.Width, surf->Base.Height);
+ }
+
+ return surf->Base.Handle;
+}
+
+
+static EGLBoolean
+fbDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
+{
+ fbSurface *fs = Lookup_fbSurface(surface);
+ _eglRemoveSurface(&fs->Base);
+ if (fs->Base.IsBound) {
+ fs->Base.DeletePending = EGL_TRUE;
+ }
+ else {
+ free(fs);
+ }
+ return EGL_TRUE;
+}
+
+
+static EGLBoolean
+fbDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext context)
+{
+ fbContext *fc = Lookup_fbContext(context);
+ _eglRemoveContext(&fc->Base);
+ if (fc->Base.IsBound) {
+ fc->Base.DeletePending = EGL_TRUE;
+ }
+ else {
+ free(fc);
+ }
+ return EGL_TRUE;
+}
+
+
+static EGLBoolean
+fbMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext context)
+{
+ fbSurface *readSurf = Lookup_fbSurface(read);
+ fbSurface *drawSurf = Lookup_fbSurface(draw);
+ fbContext *ctx = Lookup_fbContext(context);
+ EGLBoolean b;
+
+ b = _eglMakeCurrent(drv, dpy, draw, read, context);
+ if (!b)
+ return EGL_FALSE;
+
+ if (ctx) {
+ _mesa_make_current( ctx->glCtx,
+ drawSurf->mesa_framebuffer,
+ readSurf->mesa_framebuffer);
+ } else
+ _mesa_make_current( NULL, NULL, NULL );
+
+ return EGL_TRUE;
+}
+
+
+/**
+ * Create a drawing surface which can be directly displayed on a screen.
+ */
+static EGLSurface
+fbCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig cfg,
+ const EGLint *attrib_list)
+{
+ _EGLConfig *config = _eglLookupConfig(drv, dpy, cfg);
+ fbDisplay *display = Lookup_fbDisplay(dpy);
+ fbSurface *surface;
+ EGLSurface surf;
+ GLvisual vis;
+ GLcontext *ctx = NULL; /* this should be OK */
+ int origin, bytesPerPixel;
+ int width, height, stride;
+
+ surface = (fbSurface *) malloc(sizeof(*surface));
+ if (!surface) {
+ return EGL_NO_SURFACE;
+ }
+
+ /* init base class, error check, etc. */
+ surf = _eglInitScreenSurface(&surface->Base, drv, dpy, cfg, attrib_list);
+ if (surf == EGL_NO_SURFACE) {
+ free(surface);
+ return EGL_NO_SURFACE;
+ }
+
+ /* convert EGLConfig to GLvisual */
+ _eglConfigToContextModesRec(config, &vis);
+
+ /* create Mesa framebuffer */
+ surface->mesa_framebuffer = _mesa_create_framebuffer(&vis);
+ if (!surface->mesa_framebuffer) {
+ free(surface);
+ _eglRemoveSurface(&surface->Base);
+ return EGL_NO_SURFACE;
+ }
+
+ width = surface->Base.Width;
+ height = surface->Base.Height;
+ bytesPerPixel = vis.rgbBits / 8;
+ stride = width * bytesPerPixel;
+ origin = 0;
+
+ /* front color renderbuffer */
+ {
+ driRenderbuffer *drb = driNewRenderbuffer(GL_RGBA, bytesPerPixel,
+ origin, stride);
+ fbSetSpanFunctions(drb, &vis);
+ drb->Base.Data = display->pFB;
+ _mesa_add_renderbuffer(surface->mesa_framebuffer,
+ BUFFER_FRONT_LEFT, &drb->Base);
+ }
+
+ /* back color renderbuffer */
+ if (vis.doubleBufferMode) {
+ driRenderbuffer *drb = driNewRenderbuffer(GL_RGBA, bytesPerPixel,
+ origin, stride);
+ fbSetSpanFunctions(drb, &vis);
+ drb->Base.Data = _mesa_malloc(stride * height);
+ _mesa_add_renderbuffer(surface->mesa_framebuffer,
+ BUFFER_BACK_LEFT, &drb->Base);
+ }
+
+ /* other renderbuffers- software based */
+ _mesa_add_soft_renderbuffers(surface->mesa_framebuffer,
+ GL_FALSE, /* color */
+ vis.haveDepthBuffer,
+ vis.haveStencilBuffer,
+ vis.haveAccumBuffer,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+
+ _mesa_resize_framebuffer(ctx, surface->mesa_framebuffer, width, height);
+
+ return surf;
+}
+
+
+/**
+ * Show the given surface on the named screen.
+ * If surface is EGL_NO_SURFACE, disable the screen's output.
+ */
+static EGLBoolean
+fbShowSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
+ EGLSurface surface, EGLModeMESA m)
+{
+ fbDisplay *display = Lookup_fbDisplay(dpy);
+ fbScreen *scrn = Lookup_fbScreen(dpy, screen);
+ fbSurface *surf = Lookup_fbSurface(surface);
+ FILE *file;
+ char buffer[NAME_MAX];
+ _EGLMode *mode = _eglLookupMode(dpy, m);
+ int bits;
+
+ if (!_eglShowSurfaceMESA(drv, dpy, screen, surface, m))
+ return EGL_FALSE;
+
+ snprintf(buffer, sizeof(buffer), "%s/%s/blank", sysfs, scrn->fb);
+
+ file = fopen(buffer, "r+");
+ if (!file) {
+err:
+ printf("chown all fb sysfs attrib to allow write - %s\n", buffer);
+ return EGL_FALSE;
+ }
+ snprintf(buffer, sizeof(buffer), "%d", (m == EGL_NO_MODE_MESA ? VESA_POWERDOWN : VESA_VSYNC_SUSPEND));
+ fputs(buffer, file);
+ fclose(file);
+
+ if (m == EGL_NO_MODE_MESA)
+ return EGL_TRUE;
+
+ snprintf(buffer, sizeof(buffer), "%s/%s/mode", sysfs, scrn->fb);
+
+ file = fopen(buffer, "r+");
+ if (!file)
+ goto err;
+ fputs(mode->Name, file);
+ fclose(file);
+
+ snprintf(buffer, sizeof(buffer), "%s/%s/bits_per_pixel", sysfs, scrn->fb);
+
+ file = fopen(buffer, "r+");
+ if (!file)
+ goto err;
+ bits = GET_CONFIG_ATTRIB(surf->Base.Config, EGL_BUFFER_SIZE);
+ snprintf(buffer, sizeof(buffer), "%d", bits);
+ fputs(buffer, file);
+ fclose(file);
+
+ fbSetupFramebuffer(display, scrn->fb);
+
+ snprintf(buffer, sizeof(buffer), "%s/%s/blank", sysfs, scrn->fb);
+
+ file = fopen(buffer, "r+");
+ if (!file)
+ goto err;
+
+ snprintf(buffer, sizeof(buffer), "%d", VESA_NO_BLANKING);
+ fputs(buffer, file);
+ fclose(file);
+
+ return EGL_TRUE;
+}
+
+
+/* If the backbuffer is on a videocard, this is extraordinarily slow!
+ */
+static EGLBoolean
+fbSwapBuffers(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw)
+{
+ fbContext *context = (fbContext *)_eglGetCurrentContext();
+ fbSurface *fs = Lookup_fbSurface(draw);
+ struct gl_renderbuffer * front_renderbuffer = fs->mesa_framebuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
+ void *frontBuffer = front_renderbuffer->Data;
+ int currentPitch = ((driRenderbuffer *)front_renderbuffer)->pitch;
+ void *backBuffer = fs->mesa_framebuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer->Data;
+
+ if (!_eglSwapBuffers(drv, dpy, draw))
+ return EGL_FALSE;
+
+ if (context) {
+ GLcontext *ctx = context->glCtx;
+
+ if (ctx->Visual.doubleBufferMode) {
+ int i;
+ int offset = 0;
+ char *tmp = _mesa_malloc(currentPitch);
+
+ _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
+
+ ASSERT(frontBuffer);
+ ASSERT(backBuffer);
+
+ for (i = 0; i < fs->Base.Height; i++) {
+ _mesa_memcpy(tmp, (char *) backBuffer + offset,
+ currentPitch);
+ _mesa_memcpy((char *) frontBuffer + offset, tmp,
+ currentPitch);
+ offset += currentPitch;
+ }
+
+ _mesa_free(tmp);
+ }
+ }
+ else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ _mesa_problem(NULL, "fbSwapBuffers: drawable has no context!\n");
+ return EGL_FALSE;
+ }
+ return EGL_TRUE;
+}
+
+
+/**
+ * The bootstrap function. Return a new fbDriver object and
+ * plug in API functions.
+ */
+_EGLDriver *
+_eglMain(_EGLDisplay *dpy)
+{
+ fbDriver *fb;
+
+ fb = (fbDriver *) calloc(1, sizeof(fbDriver));
+ if (!fb) {
+ return NULL;
+ }
+
+ /* First fill in the dispatch table with defaults */
+ _eglInitDriverFallbacks(&fb->Base);
+
+ /* then plug in our fb-specific functions */
+ fb->Base.Initialize = fbInitialize;
+ fb->Base.Terminate = fbTerminate;
+ fb->Base.CreateContext = fbCreateContext;
+ fb->Base.MakeCurrent = fbMakeCurrent;
+ fb->Base.CreateWindowSurface = fbCreateWindowSurface;
+ fb->Base.CreatePixmapSurface = fbCreatePixmapSurface;
+ fb->Base.CreatePbufferSurface = fbCreatePbufferSurface;
+ fb->Base.DestroySurface = fbDestroySurface;
+ fb->Base.DestroyContext = fbDestroyContext;
+ fb->Base.CreateScreenSurfaceMESA = fbCreateScreenSurfaceMESA;
+ fb->Base.ShowSurfaceMESA = fbShowSurfaceMESA;
+ fb->Base.SwapBuffers = fbSwapBuffers;
+
+ /* enable supported extensions */
+ fb->Base.MESA_screen_surface = EGL_TRUE;
+ fb->Base.MESA_copy_context = EGL_TRUE;
+
+ return &fb->Base;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/Makefile
new file mode 100644
index 000000000..cb73238c0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/Makefile
@@ -0,0 +1,36 @@
+# src/mesa/drivers/dri/ffb/Makefile
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = ffb_dri.so
+
+# not yet
+# MINIGLX_SOURCES = server/ffb_dri.c
+
+DRIVER_SOURCES = \
+ ffb_bitmap.c \
+ ffb_clear.c \
+ ffb_dd.c \
+ ffb_depth.c \
+ ffb_fog.c \
+ ffb_lines.c \
+ ffb_points.c \
+ ffb_span.c \
+ ffb_state.c \
+ ffb_stencil.c \
+ ffb_tex.c \
+ ffb_tris.c \
+ ffb_vb.c \
+ ffb_xmesa.c
+
+C_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(DRIVER_SOURCES)
+
+
+ASM_SOURCES =
+
+include ../Makefile.template
+
+symlinks:
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_bitmap.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_bitmap.c
new file mode 100644
index 000000000..7263e8381
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_bitmap.c
@@ -0,0 +1,159 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_bitmap.c,v 1.1 2002/02/22 21:32:58 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2001 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "ffb_context.h"
+#include "ffb_state.h"
+#include "ffb_lock.h"
+#include "ffb_bitmap.h"
+#include "swrast/swrast.h"
+#include "image.h"
+#include "macros.h"
+
+/* Compute ceiling of integer quotient of A divided by B: */
+#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
+
+#undef FFB_BITMAP_TRACE
+
+static void
+ffb_bitmap(GLcontext *ctx, GLint px, GLint py,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ ffb_fbcPtr ffb = fmesa->regs;
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ unsigned int ppc, pixel;
+ GLint row, col, row_stride;
+ const GLubyte *src;
+ char *buf;
+
+ if (fmesa->bad_fragment_attrs != 0)
+ _swrast_Bitmap(ctx, px, py, width,
+ height, unpack, bitmap);
+
+ pixel = (((((GLuint)(ctx->Current.RasterColor[0] * 255.0f)) & 0xff) << 0) |
+ ((((GLuint)(ctx->Current.RasterColor[1] * 255.0f)) & 0xff) << 8) |
+ ((((GLuint)(ctx->Current.RasterColor[2] * 255.0f)) & 0xff) << 16) |
+ ((((GLuint)(ctx->Current.RasterColor[3] * 255.0f)) & 0xff) << 24));
+
+#ifdef FFB_BITMAP_TRACE
+ fprintf(stderr, "ffb_bitmap: ppc(%08x) fbc(%08x) cmp(%08x) pixel(%08x)\n",
+ fmesa->ppc, fmesa->fbc, fmesa->cmp, pixel);
+#endif
+
+ LOCK_HARDWARE(fmesa);
+ fmesa->hw_locked = 1;
+
+ if (fmesa->state_dirty)
+ ffbSyncHardware(fmesa);
+
+ ppc = fmesa->ppc;
+
+ FFBFifo(fmesa, 4);
+ ffb->ppc = ((ppc &
+ ~(FFB_PPC_TBE_MASK | FFB_PPC_ZS_MASK | FFB_PPC_CS_MASK | FFB_PPC_XS_MASK))
+ | (FFB_PPC_TBE_TRANSPARENT | FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST |
+ (ctx->Color.BlendEnabled ? FFB_PPC_XS_CONST : FFB_PPC_XS_WID)));
+ ffb->constz = ((GLuint) (ctx->Current.RasterPos[2] * 0x0fffffff));
+ ffb->fg = pixel;
+ ffb->fontinc = (0 << 16) | 32;
+
+ buf = (char *)(fmesa->sfb32 + (dPriv->x << 2) + (dPriv->y << 13));
+
+ row_stride = (unpack->Alignment * CEILING(width, 8 * unpack->Alignment));
+ src = (const GLubyte *) (bitmap +
+ (unpack->SkipRows * row_stride) +
+ (unpack->SkipPixels / 8));
+ if (unpack->LsbFirst == GL_TRUE) {
+ for (row = 0; row < height; row++, src += row_stride) {
+ const GLubyte *row_src = src;
+ GLuint base_x, base_y;
+
+ base_x = dPriv->x + px;
+ base_y = dPriv->y + (dPriv->h - (py + row));
+
+ FFBFifo(fmesa, 1);
+ ffb->fontxy = (base_y << 16) | base_x;
+
+ for (col = 0; col < width; col += 32, row_src += 4) {
+ GLint bitnum, font_w = (width - col);
+ GLuint font_data;
+
+ if (font_w > 32)
+ font_w = 32;
+ font_data = 0;
+ for (bitnum = 0; bitnum < 32; bitnum++) {
+ const GLubyte val = row_src[bitnum >> 3];
+
+ if (val & (1 << (bitnum & (8 - 1))))
+ font_data |= (1 << (31 - bitnum));
+ }
+
+ FFBFifo(fmesa, 2);
+ ffb->fontw = font_w;
+ ffb->font = font_data;
+ }
+ }
+ } else {
+ for (row = 0; row < height; row++, src += row_stride) {
+ const GLubyte *row_src = src;
+ GLuint base_x, base_y;
+
+ base_x = dPriv->x + px;
+ base_y = dPriv->y + (dPriv->h - (py + row));
+
+ FFBFifo(fmesa, 1);
+ ffb->fontxy = (base_y << 16) | base_x;
+
+ for (col = 0; col < width; col += 32, row_src += 4) {
+ GLint font_w = (width - col);
+
+ if (font_w > 32)
+ font_w = 32;
+ FFBFifo(fmesa, 2);
+ ffb->fontw = font_w;
+ ffb->font = (((unsigned int)row_src[0]) << 24 |
+ ((unsigned int)row_src[1]) << 16 |
+ ((unsigned int)row_src[2]) << 8 |
+ ((unsigned int)row_src[3]) << 0);
+ }
+ }
+ }
+
+ FFBFifo(fmesa, 1);
+ ffb->ppc = ppc;
+ fmesa->ffbScreen->rp_active = 1;
+
+ UNLOCK_HARDWARE(fmesa);
+ fmesa->hw_locked = 0;
+}
+
+void ffbDDInitBitmapFuncs(GLcontext *ctx)
+{
+ ctx->Driver.Bitmap = ffb_bitmap;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_bitmap.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_bitmap.h
new file mode 100644
index 000000000..4f8d2ea2a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_bitmap.h
@@ -0,0 +1,8 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_bitmap.h,v 1.1 2002/02/22 21:32:58 dawes Exp $ */
+
+#ifndef _FFB_BITMAP_H
+#define _FFB_BITMAP_H
+
+extern void ffbDDInitBitmapFuncs(GLcontext *);
+
+#endif /* !(_FFB_BITMAP_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_clear.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_clear.c
new file mode 100644
index 000000000..c63179149
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_clear.c
@@ -0,0 +1,354 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_clear.c,v 1.2 2002/02/22 21:32:58 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "mtypes.h"
+#include "extensions.h"
+
+#include "mm.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_depth.h"
+#include "ffb_context.h"
+#include "ffb_vb.h"
+#include "ffb_tris.h"
+#include "ffb_clear.h"
+#include "ffb_lock.h"
+
+#undef CLEAR_TRACE
+
+#define BOX_AREA(__w, __h) ((int)(__w) * (int)(__h))
+
+/* Compute the page aligned box for a page mode fast fill.
+ * In 'ework' this returns greater than zero if there are some odd
+ * edges to take care of which are outside of the page aligned area.
+ * It will place less than zero there if the box is too small,
+ * indicating that a different method must be used to fill it.
+ */
+#define CreatorPageFillParms(ffp, x, y, w, h, px, py, pw, ph, ework) \
+do { int xdiff, ydiff; \
+ int pf_bh = ffp->pagefill_height; \
+ int pf_bw = ffp->pagefill_width; \
+ py = ((y + (pf_bh - 1)) & ~(pf_bh - 1)); \
+ ydiff = py - y; \
+ px = ffp->Pf_AlignTab[x + (pf_bw - 1)]; \
+ xdiff = px - x; \
+ ph = ((h - ydiff) & ~(pf_bh - 1)); \
+ if(ph <= 0) \
+ ework = -1; \
+ else { \
+ pw = ffp->Pf_AlignTab[w - xdiff]; \
+ if(pw <= 0) { \
+ ework = -1; \
+ } else { \
+ ework = (((xdiff > 0) || \
+ (ydiff > 0) || \
+ ((w - pw) > 0) || \
+ ((h - ph) > 0))) ? 1 : 0; \
+ } \
+ } \
+} while(0);
+
+struct ff_fixups {
+ int x, y, width, height;
+};
+
+/* Compute fixups of non-page aligned areas after a page fill.
+ * Return the number of fixups needed.
+ */
+static __inline__ int
+CreatorComputePageFillFixups(struct ff_fixups *fixups,
+ int x, int y, int w, int h,
+ int paligned_x, int paligned_y,
+ int paligned_w, int paligned_h)
+{
+ int nfixups = 0;
+
+ /* FastFill Left */
+ if(paligned_x != x) {
+ fixups[nfixups].x = x;
+ fixups[nfixups].y = paligned_y;
+ fixups[nfixups].width = paligned_x - x;
+ fixups[nfixups].height = paligned_h;
+ nfixups++;
+ }
+ /* FastFill Top */
+ if(paligned_y != y) {
+ fixups[nfixups].x = x;
+ fixups[nfixups].y = y;
+ fixups[nfixups].width = w;
+ fixups[nfixups].height = paligned_y - y;
+ nfixups++;
+ }
+ /* FastFill Right */
+ if((x+w) != (paligned_x+paligned_w)) {
+ fixups[nfixups].x = (paligned_x+paligned_w);
+ fixups[nfixups].y = paligned_y;
+ fixups[nfixups].width = (x+w) - fixups[nfixups].x;
+ fixups[nfixups].height = paligned_h;
+ nfixups++;
+ }
+ /* FastFill Bottom */
+ if((y+h) != (paligned_y+paligned_h)) {
+ fixups[nfixups].x = x;
+ fixups[nfixups].y = (paligned_y+paligned_h);
+ fixups[nfixups].width = w;
+ fixups[nfixups].height = (y+h) - fixups[nfixups].y;
+ nfixups++;
+ }
+ return nfixups;
+}
+
+static void
+ffb_do_clear(ffbContextPtr fmesa, __DRIdrawablePrivate *dPriv,
+ GLboolean all, GLint cx, GLint cy, GLint cwidth,
+ GLint cheight)
+{
+ FFBDRIPtr gDRIPriv = (FFBDRIPtr) fmesa->driScreen->pDevPriv;
+ ffb_fbcPtr ffb = fmesa->regs;
+ drm_clip_rect_t *box = dPriv->pClipRects;
+ int nc = dPriv->numClipRects;
+
+ cy = dPriv->h - cy - cheight;
+ cx += dPriv->x;
+ cy += dPriv->y;
+
+ while (nc--) {
+ GLint x = box[nc].x1;
+ GLint y = box[nc].y1;
+ GLint width = box[nc].x2 - x;
+ GLint height = box[nc].y2 - y;
+ int paligned_y, paligned_x;
+ int paligned_h, paligned_w = 0;
+ int extra_work;
+
+ if (!all) {
+ if (x < cx) {
+ width -= cx - x;
+ x = cx;
+ }
+ if (y < cy) {
+ height -= cy - y;
+ y = cy;
+ }
+ if (x + width > cx + cwidth)
+ width = cx + cwidth - x;
+ if (y + height > cy + cheight)
+ height = cy + cheight - y;
+ if (width <= 0)
+ continue;
+ if (height <= 0)
+ continue;
+ }
+
+ if (BOX_AREA(width, height) < gDRIPriv->fastfill_small_area) {
+ FFBFifo(fmesa, 5);
+ ffb->drawop = FFB_DRAWOP_RECTANGLE;
+ ffb->by = y;
+ ffb->bx = x;
+ ffb->bh = height;
+ ffb->bw = width;
+ continue;
+ }
+
+ FFBFifo(fmesa, 1);
+ ffb->drawop = FFB_DRAWOP_FASTFILL;
+
+ if (gDRIPriv->disable_pagefill ||
+ (width < (gDRIPriv->pagefill_width<<1)) ||
+ (height < (gDRIPriv->pagefill_height<<1)))
+ goto do_fastfill;
+
+ CreatorPageFillParms(gDRIPriv,
+ x, y, width, height,
+ paligned_x, paligned_y,
+ paligned_w, paligned_h, extra_work);
+
+ if (extra_work < 0 ||
+ BOX_AREA(paligned_w, paligned_h) < gDRIPriv->pagefill_small_area) {
+ do_fastfill:
+ FFBFifo(fmesa, 10);
+ ffb->by = FFB_FASTFILL_COLOR_BLK;
+ ffb->dy = 0;
+ ffb->dx = 0;
+ ffb->bh = gDRIPriv->fastfill_height;
+ ffb->bw = (gDRIPriv->fastfill_width * 4);
+ ffb->by = FFB_FASTFILL_BLOCK;
+ ffb->dy = y;
+ ffb->dx = x;
+ ffb->bh = (height + (y & (gDRIPriv->fastfill_height - 1)));
+ ffb->bx = (width + (x & (gDRIPriv->fastfill_width - 1)));
+ continue;
+ }
+
+ /* Ok, page fill is possible and worth it. */
+ FFBFifo(fmesa, 15);
+ ffb->by = FFB_FASTFILL_COLOR_BLK;
+ ffb->dy = 0;
+ ffb->dx = 0;
+ ffb->bh = gDRIPriv->fastfill_height;
+ ffb->bw = gDRIPriv->fastfill_width * 4;
+ ffb->by = FFB_FASTFILL_BLOCK_X;
+ ffb->dy = 0;
+ ffb->dx = 0;
+ ffb->bh = gDRIPriv->pagefill_height;
+ ffb->bw = gDRIPriv->pagefill_width * 4;
+ ffb->by = FFB_FASTFILL_PAGE;
+ ffb->dy = paligned_y;
+ ffb->dx = paligned_x;
+ ffb->bh = paligned_h;
+ ffb->bx = paligned_w;
+
+ if (extra_work) {
+ struct ff_fixups local_fixups[4];
+ int nfixups;
+
+ nfixups = CreatorComputePageFillFixups(local_fixups,
+ x, y, width, height,
+ paligned_x, paligned_y,
+ paligned_w, paligned_h);
+ FFBFifo(fmesa, 5 + (nfixups * 5));
+ ffb->by = FFB_FASTFILL_COLOR_BLK;
+ ffb->dy = 0;
+ ffb->dx = 0;
+ ffb->bh = gDRIPriv->fastfill_height;
+ ffb->bw = gDRIPriv->fastfill_width * 4;
+
+ while (--nfixups >= 0) {
+ int xx, yy, ww, hh;
+
+ xx = local_fixups[nfixups].x;
+ yy = local_fixups[nfixups].y;
+ ffb->dy = yy;
+ ffb->dx = xx;
+ ww = (local_fixups[nfixups].width +
+ (xx & (gDRIPriv->fastfill_width - 1)));
+ hh = (local_fixups[nfixups].height +
+ (yy & (gDRIPriv->fastfill_height - 1)));
+ if (nfixups != 0) {
+ ffb->by = FFB_FASTFILL_BLOCK;
+ ffb->bh = hh;
+ ffb->bw = ww;
+ } else {
+ ffb->bh = hh;
+ ffb->by = FFB_FASTFILL_BLOCK;
+ ffb->bx = ww;
+ }
+ }
+ }
+ }
+}
+
+void ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cwidth, GLint cheight)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ unsigned int stcmask = BUFFER_BIT_STENCIL;
+
+#ifdef CLEAR_TRACE
+ fprintf(stderr, "ffbDDClear: mask(%08x) all(%d) "
+ "[x(%x)y(%x)w(%x)h(%x)]\n",
+ mask, (int) all, cx, cy, cwidth, cheight);
+#endif
+ if (!(fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS))
+ stcmask = 0;
+
+ if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT | BUFFER_BIT_DEPTH | stcmask)) {
+ ffb_fbcPtr ffb = fmesa->regs;
+ unsigned int fbc, ppc;
+
+ fbc = (FFB_FBC_XE_ON);
+ ppc = (FFB_PPC_ACE_DISABLE | FFB_PPC_DCE_DISABLE |
+ FFB_PPC_ABE_DISABLE | FFB_PPC_VCE_DISABLE |
+ FFB_PPC_APE_DISABLE | FFB_PPC_XS_WID |
+ FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST);
+
+ /* Y/X enables must be both on or both off. */
+ if (mask & (BUFFER_BIT_DEPTH | stcmask)) {
+ fbc |= (FFB_FBC_ZE_ON | FFB_FBC_YE_ON | FFB_FBC_WB_C);
+ } else
+ fbc |= FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF;
+
+ /* All RGB enables must be both on or both off. */
+ if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) {
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
+ if (fmesa->back_buffer == 0)
+ fbc |= FFB_FBC_WB_B;
+ else
+ fbc |= FFB_FBC_WB_A;
+ }
+ if (mask & BUFFER_BIT_BACK_LEFT) {
+ if (fmesa->back_buffer == 0)
+ fbc |= FFB_FBC_WB_A;
+ else
+ fbc |= FFB_FBC_WB_B;
+ }
+ fbc |= FFB_FBC_RGBE_ON;
+ } else
+ fbc |= FFB_FBC_RGBE_OFF;
+
+ LOCK_HARDWARE(fmesa);
+
+ if (dPriv->numClipRects) {
+ FFBFifo(fmesa, 8);
+ ffb->fbc = fbc;
+ ffb->ppc = ppc;
+ ffb->xclip = FFB_XCLIP_TEST_ALWAYS;
+ ffb->cmp = 0x80808080;
+ ffb->rop = FFB_ROP_NEW;
+
+ if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT))
+ ffb->fg = fmesa->clear_pixel;
+ if (mask & BUFFER_BIT_DEPTH)
+ ffb->constz = fmesa->clear_depth;
+ if (mask & stcmask)
+ ffb->consty = fmesa->clear_stencil;
+
+ ffb_do_clear(fmesa, dPriv, all, cx, cy, cwidth, cheight);
+
+ FFBFifo(fmesa, 6);
+ ffb->ppc = fmesa->ppc;
+ ffb->fbc = fmesa->fbc;
+ ffb->xclip = fmesa->xclip;
+ ffb->cmp = fmesa->cmp;
+ ffb->rop = fmesa->rop;
+ ffb->drawop = fmesa->drawop;
+ if (mask & stcmask)
+ ffb->consty = fmesa->consty;
+ fmesa->ffbScreen->rp_active = 1;
+ }
+
+ UNLOCK_HARDWARE(fmesa);
+
+ mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT |
+ BUFFER_BIT_DEPTH | stcmask);
+ }
+
+ if (mask)
+ _swrast_Clear(ctx, mask, all, cx, cy, cwidth, cheight);
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_clear.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_clear.h
new file mode 100644
index 000000000..4b707f19b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_clear.h
@@ -0,0 +1,9 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_clear.h,v 1.2 2002/02/22 21:32:58 dawes Exp $ */
+
+#ifndef _FFB_CLEAR_H
+#define _FFB_CLEAR_H
+
+extern void ffbDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cwidth, GLint cheight);
+
+#endif /* !(_FFB_CLEAR_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_context.h
new file mode 100644
index 000000000..33f6f7cff
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_context.h
@@ -0,0 +1,306 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_context.h,v 1.2 2002/02/22 21:32:58 dawes Exp $ */
+
+#ifndef _FFB_CONTEXT_H
+#define _FFB_CONTEXT_H
+
+#include "dri_util.h"
+#include "drm.h"
+
+#include "mtypes.h"
+
+#include "ffb_xmesa.h"
+
+typedef struct {
+ GLfloat alpha;
+ GLfloat red;
+ GLfloat green;
+ GLfloat blue;
+} ffb_color;
+
+#define FFB_GET_ALPHA(VTX) \
+ FFB_COLOR_FROM_FLOAT((VTX)->color[0].alpha)
+#define FFB_GET_RED(VTX) \
+ FFB_COLOR_FROM_FLOAT((VTX)->color[0].red)
+#define FFB_GET_GREEN(VTX) \
+ FFB_COLOR_FROM_FLOAT((VTX)->color[0].green)
+#define FFB_GET_BLUE(VTX) \
+ FFB_COLOR_FROM_FLOAT((VTX)->color[0].blue)
+
+typedef struct {
+ GLfloat x, y, z;
+ ffb_color color[2];
+} ffb_vertex;
+
+#define FFB_DELAYED_VIEWPORT_VARS \
+ GLfloat VP_SX = fmesa->hw_viewport[MAT_SX]; \
+ GLfloat VP_TX = fmesa->hw_viewport[MAT_TX]; \
+ GLfloat VP_SY = fmesa->hw_viewport[MAT_SY]; \
+ GLfloat VP_TY = fmesa->hw_viewport[MAT_TY]; \
+ GLfloat VP_SZ = fmesa->hw_viewport[MAT_SZ]; \
+ GLfloat VP_TZ = fmesa->hw_viewport[MAT_TZ]; \
+ (void) VP_SX; (void) VP_SY; (void) VP_SZ; \
+ (void) VP_TX; (void) VP_TY; (void) VP_TZ
+
+#define FFB_GET_Z(VTX) \
+ FFB_Z_FROM_FLOAT(VP_SZ * (VTX)->z + VP_TZ)
+#define FFB_GET_Y(VTX) \
+ FFB_XY_FROM_FLOAT(VP_SY * (VTX)->y + VP_TY)
+#define FFB_GET_X(VTX) \
+ FFB_XY_FROM_FLOAT(VP_SX * (VTX)->x + VP_TX)
+
+typedef void (*ffb_point_func)(GLcontext *, ffb_vertex *);
+typedef void (*ffb_line_func)(GLcontext *, ffb_vertex *, ffb_vertex *);
+typedef void (*ffb_tri_func)(GLcontext *, ffb_vertex *, ffb_vertex *,
+ ffb_vertex *);
+typedef void (*ffb_quad_func)(GLcontext *, ffb_vertex *, ffb_vertex *,
+ ffb_vertex *, ffb_vertex *);
+
+/* Immediate mode fast-path support. */
+typedef struct {
+ GLfloat obj[4];
+ GLfloat normal[4];
+ GLfloat clip[4];
+ GLuint mask;
+ GLfloat color[4];
+ GLfloat win[4];
+ GLfloat eye[4];
+} ffbTnlVertex, *ffbTnlVertexPtr;
+
+typedef void (*ffb_interp_func)(GLfloat t,
+ ffbTnlVertex *O,
+ const ffbTnlVertex *I,
+ const ffbTnlVertex *J);
+
+struct ffb_current_state {
+ GLfloat color[4];
+ GLfloat normal[4];
+ GLfloat specular[4];
+};
+
+struct ffb_light_state {
+ GLfloat base_color[3];
+ GLfloat base_alpha;
+};
+
+struct ffb_vertex_state {
+ struct ffb_current_state current;
+ struct ffb_light_state light;
+};
+
+struct ffb_imm_vertex {
+ ffbTnlVertex vertices[8];
+ ffbTnlVertex *v0;
+ ffbTnlVertex *v1;
+ ffbTnlVertex *v2;
+ ffbTnlVertex *v3;
+
+ void (*save_vertex)(GLcontext *ctx, ffbTnlVertex *v);
+ void (*flush_vertex)(GLcontext *ctx, ffbTnlVertex *v);
+
+ ffb_interp_func interp;
+
+ GLuint prim, format;
+
+ GLvertexformat vtxfmt;
+};
+
+typedef struct ffb_context_t {
+ GLcontext *glCtx;
+ GLframebuffer *glBuffer;
+
+ ffb_fbcPtr regs;
+ volatile char *sfb32;
+
+ int hw_locked;
+
+ int back_buffer; /* 0 = bufferA, 1 = bufferB */
+
+ /* Viewport matrix. */
+ GLfloat hw_viewport[16];
+#define SUBPIXEL_X (-0.5F)
+#define SUBPIXEL_Y (-0.5F + 0.125)
+
+ /* Vertices in driver format. */
+ ffb_vertex *verts;
+
+ /* Rasterization functions. */
+ ffb_point_func draw_point;
+ ffb_line_func draw_line;
+ ffb_tri_func draw_tri;
+ ffb_quad_func draw_quad;
+
+ GLenum raster_primitive;
+ GLenum render_primitive;
+
+ GLfloat backface_sign;
+ GLfloat depth_scale;
+
+ GLfloat ffb_2_30_fixed_scale;
+ GLfloat ffb_one_over_2_30_fixed_scale;
+ GLfloat ffb_16_16_fixed_scale;
+ GLfloat ffb_one_over_16_16_fixed_scale;
+ GLfloat ffb_ubyte_color_scale;
+ GLfloat ffb_zero;
+
+ /* Immediate mode state. */
+ struct ffb_vertex_state vtx_state;
+ struct ffb_imm_vertex imm;
+
+ /* Debugging knobs. */
+ GLboolean debugFallbacks;
+
+ /* This records state bits when a per-fragment attribute has
+ * been set which prevents us from rendering in hardware.
+ *
+ * As attributes change, some of these bits may clear as
+ * we move back within the chips capabilities. If they
+ * all clear, we return to full hw rendering.
+ */
+ unsigned int bad_fragment_attrs;
+#define FFB_BADATTR_FOG 0x00000001 /* Bad fog possible only when < FFB2 */
+#define FFB_BADATTR_BLENDFUNC 0x00000002 /* Any non-const func based upon dst alpha */
+#define FFB_BADATTR_BLENDROP 0x00000004 /* Blend enabled and LogicOP != GL_COPY */
+#define FFB_BADATTR_BLENDEQN 0x00000008 /* Blend equation other than ADD */
+#define FFB_BADATTR_STENCIL 0x00000010 /* Stencil enabled when < FFB2+ */
+#define FFB_BADATTR_TEXTURE 0x00000020 /* Texture enabled */
+#define FFB_BADATTR_SWONLY 0x00000040 /* Environment var set */
+
+ unsigned int state_dirty;
+ unsigned int state_fifo_ents;
+#define FFB_STATE_FBC 0x00000001
+#define FFB_STATE_PPC 0x00000002
+#define FFB_STATE_DRAWOP 0x00000004
+#define FFB_STATE_ROP 0x00000008
+#define FFB_STATE_LPAT 0x00000010
+#define FFB_STATE_PMASK 0x00000020
+#define FFB_STATE_XPMASK 0x00000040
+#define FFB_STATE_YPMASK 0x00000080
+#define FFB_STATE_ZPMASK 0x00000100
+#define FFB_STATE_XCLIP 0x00000200
+#define FFB_STATE_CMP 0x00000400
+#define FFB_STATE_MATCHAB 0x00000800
+#define FFB_STATE_MAGNAB 0x00001000
+#define FFB_STATE_MATCHC 0x00002000
+#define FFB_STATE_MAGNC 0x00004000
+#define FFB_STATE_DCUE 0x00008000
+#define FFB_STATE_BLEND 0x00010000
+#define FFB_STATE_CLIP 0x00020000
+#define FFB_STATE_STENCIL 0x00040000
+#define FFB_STATE_APAT 0x00080000
+#define FFB_STATE_WID 0x00100000
+#define FFB_STATE_ALL 0x001fffff
+
+ unsigned int state_all_fifo_ents;
+
+#define FFB_MAKE_DIRTY(FMESA, STATE_MASK, FIFO_ENTS) \
+do { if ((STATE_MASK) & ~((FMESA)->state_dirty)) { \
+ (FMESA)->state_dirty |= (STATE_MASK); \
+ (FMESA)->state_fifo_ents += FIFO_ENTS; \
+ } \
+} while (0)
+
+ /* General hw reg state. */
+ unsigned int fbc;
+ unsigned int ppc;
+ unsigned int drawop;
+ unsigned int rop;
+
+ unsigned int lpat;
+#define FFB_LPAT_BAD 0xffffffff
+
+ unsigned int wid;
+ unsigned int pmask;
+ unsigned int xpmask;
+ unsigned int ypmask;
+ unsigned int zpmask;
+ unsigned int xclip;
+ unsigned int cmp;
+ unsigned int matchab;
+ unsigned int magnab;
+ unsigned int matchc;
+ unsigned int magnc;
+
+ /* Depth cue unit hw reg state. */
+ unsigned int dcss; /* All FFB */
+ unsigned int dcsf; /* All FFB */
+ unsigned int dcsb; /* All FFB */
+ unsigned int dczf; /* All FFB */
+ unsigned int dczb; /* All FFB */
+ unsigned int dcss1; /* >=FFB2 only */
+ unsigned int dcss2; /* >=FFB2 only */
+ unsigned int dcss3; /* >=FFB2 only */
+ unsigned int dcs2; /* >=FFB2 only */
+ unsigned int dcs3; /* >=FFB2 only */
+ unsigned int dcs4; /* >=FFB2 only */
+ unsigned int dcd2; /* >=FFB2 only */
+ unsigned int dcd3; /* >=FFB2 only */
+ unsigned int dcd4; /* >=FFB2 only */
+
+ /* Blend unit hw reg state. */
+ unsigned int blendc;
+ unsigned int blendc1;
+ unsigned int blendc2;
+
+ /* ViewPort clipping hw reg state. */
+ unsigned int vclipmin;
+ unsigned int vclipmax;
+ unsigned int vclipzmin;
+ unsigned int vclipzmax;
+ struct {
+ unsigned int min;
+ unsigned int max;
+ } aux_clips[4];
+
+ /* Stencil control hw reg state. >=FFB2+ only. */
+ unsigned int stencil;
+ unsigned int stencilctl;
+ unsigned int consty; /* Stencil Ref */
+
+ /* Area pattern (used for polygon stipples). */
+ unsigned int pattern[32];
+
+ /* Fog state. */
+ float Znear, Zfar;
+
+ drm_context_t hHWContext;
+ drm_hw_lock_t *driHwLock;
+ int driFd;
+
+ unsigned int clear_pixel;
+ unsigned int clear_depth;
+ unsigned int clear_stencil;
+
+ unsigned int setupindex;
+ unsigned int setupnewinputs;
+ unsigned int new_gl_state;
+
+ __DRIdrawablePrivate *driDrawable;
+ __DRIscreenPrivate *driScreen;
+ ffbScreenPrivate *ffbScreen;
+ ffb_dri_state_t *ffb_sarea;
+} ffbContextRec, *ffbContextPtr;
+
+#define FFB_CONTEXT(ctx) ((ffbContextPtr)((ctx)->DriverCtx))
+
+/* We want the depth values written during software rendering
+ * to match what the hardware is going to put there when we
+ * hw render.
+ *
+ * The Z buffer is 28 bits deep. Smooth shaded primitives
+ * specify a 2:30 signed fixed point Z value in the range 0.0
+ * to 1.0 inclusive.
+ *
+ * So for example, when hw rendering, the largest Z value of
+ * 1.0 would produce a value of 0x0fffffff in the actual Z
+ * buffer, which is the maximum value.
+ *
+ * Mesa's depth type is a 32-bit int, so we use the following macro
+ * to convert to/from FFB hw Z values. Note we also have to clear
+ * out the top bits as that is where the Y (stencil) buffer is stored
+ * and during hw Z buffer reads it is always there. (During writes
+ * we tell the hw to discard those top 4 bits).
+ */
+#define Z_TO_MESA(VAL) ((GLdepth)(((VAL) & 0x0fffffff) << (32 - 28)))
+#define Z_FROM_MESA(VAL) (((GLuint)((GLdouble)(VAL))) >> (32 - 28))
+
+#endif /* !(_FFB_CONTEXT_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_dd.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_dd.c
new file mode 100644
index 000000000..53423bbae
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_dd.c
@@ -0,0 +1,119 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_dd.c,v 1.4 2002/09/11 19:49:07 tsi Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000, 2001 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "mtypes.h"
+#include "mm.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_depth.h"
+#include "ffb_context.h"
+#include "ffb_vb.h"
+#include "ffb_tris.h"
+#include "ffb_clear.h"
+#include "ffb_lock.h"
+#include "extensions.h"
+
+#define FFB_DATE "20021125"
+
+PUBLIC const char __driConfigOptions[] = { 0 };
+const GLuint __driNConfigOptions = 0;
+
+/* Mesa's Driver Functions */
+
+static const GLubyte *ffbDDGetString(GLcontext *ctx, GLenum name)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ static char buffer[128];
+
+ switch (name) {
+ case GL_VENDOR:
+ return (GLubyte *) "David S. Miller";
+
+ case GL_RENDERER:
+ sprintf(buffer, "Mesa DRI FFB " FFB_DATE);
+
+ if (fmesa->ffb_sarea->flags & FFB_DRI_FFB2)
+ strncat(buffer, " FFB2", 5);
+ if (fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS)
+ strncat(buffer, " FFB2PLUS", 9);
+ if (fmesa->ffb_sarea->flags & FFB_DRI_PAC1)
+ strncat(buffer, " PAC1", 5);
+ if (fmesa->ffb_sarea->flags & FFB_DRI_PAC2)
+ strncat(buffer, " PAC2", 5);
+
+#ifdef USE_SPARC_ASM
+ strncat(buffer, " Sparc", 6);
+#endif
+
+ return (GLubyte *) buffer;
+
+ default:
+ return NULL;
+ };
+}
+
+
+static void ffbBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ LOCK_HARDWARE(fmesa);
+ *width = fmesa->driDrawable->w;
+ *height = fmesa->driDrawable->h;
+ UNLOCK_HARDWARE(fmesa);
+}
+
+void ffbDDExtensionsInit(GLcontext *ctx)
+{
+ /* Nothing for now until we start to add
+ * real acceleration. -DaveM
+ */
+
+ /* XXX Need to turn off GL_EXT_blend_func_separate for one.
+ * XXX Also BlendEquation should be turned off too, what
+ * XXX EXT is that assosciated with?
+ */
+}
+
+static void ffbDDFinish(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ LOCK_HARDWARE(fmesa);
+ FFBWait(fmesa, fmesa->regs);
+ UNLOCK_HARDWARE(fmesa);
+}
+
+void ffbDDInitDriverFuncs(GLcontext *ctx)
+{
+ ctx->Driver.GetBufferSize = ffbBufferSize;
+ ctx->Driver.GetString = ffbDDGetString;
+ ctx->Driver.Clear = ffbDDClear;
+
+ ctx->Driver.Finish = ffbDDFinish;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_dd.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_dd.h
new file mode 100644
index 000000000..4ffcbe666
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_dd.h
@@ -0,0 +1,36 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_dd.h,v 1.1 2000/06/20 05:08:38 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D.
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#ifndef _FFB_DD_H
+#define _FFB_DD_H
+
+#include "context.h"
+
+void ffbDDInitDriverFuncs(GLcontext *ctx);
+void ffbDDExtensionsInit(GLcontext *ctx);
+
+#endif /* !(_FFB_DD_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_depth.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_depth.c
new file mode 100644
index 000000000..68a2450eb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_depth.c
@@ -0,0 +1,245 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_depth.c,v 1.2 2002/02/22 21:32:58 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "mtypes.h"
+#include "swrast/swrast.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_context.h"
+#include "ffb_depth.h"
+#include "ffb_lock.h"
+
+#include "swrast/swrast.h"
+
+#undef DEPTH_TRACE
+
+static void FFBWriteDepthSpan( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *values,
+ const GLubyte mask[] )
+{
+ const GLuint *depth = (const GLuint *) values;
+#ifdef DEPTH_TRACE
+ fprintf(stderr, "FFBWriteDepthSpan: n(%d) x(%d) y(%d)\n",
+ (int) n, x, y);
+#endif
+ if (ctx->Depth.Mask) {
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ GLuint *zptr;
+ GLuint i;
+
+ if (!fmesa->hw_locked)
+ LOCK_HARDWARE(fmesa);
+ FFBFifo(fmesa, 2);
+ fmesa->regs->fbc = (FFB_FBC_WB_C | FFB_FBC_ZE_ON |
+ FFB_FBC_YE_OFF | FFB_FBC_RGBE_OFF);
+ fmesa->regs->ppc = FFB_PPC_ZS_VAR;
+ FFBWait(fmesa, fmesa->regs);
+
+ y = (dPriv->h - y);
+ zptr = (GLuint *)
+ ((char *)fmesa->sfb32 +
+ ((dPriv->x + x) << 2) +
+ ((dPriv->y + y) << 13));
+
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ *zptr = Z_FROM_MESA(depth[i]);
+ }
+ zptr++;
+ }
+
+ FFBFifo(fmesa, 2);
+ fmesa->regs->fbc = fmesa->fbc;
+ fmesa->regs->ppc = fmesa->ppc;
+ fmesa->ffbScreen->rp_active = 1;
+ if (!fmesa->hw_locked)
+ UNLOCK_HARDWARE(fmesa);
+ }
+}
+
+static void FFBWriteMonoDepthSpan( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *value, const GLubyte mask[] )
+{
+ const GLuint depthVal = *((GLuint *) value);
+ GLuint depths[MAX_WIDTH];
+ GLuint i;
+ for (i = 0; i < n; i++)
+ depths[i] = depthVal;
+ FFBWriteDepthSpan(ctx, rb, n, x, y, depths, mask);
+}
+
+static void FFBWriteDepthPixels( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n,
+ const GLint x[],
+ const GLint y[],
+ const void *values,
+ const GLubyte mask[] )
+{
+ const GLuint *depth = (const GLuint *) values;
+#ifdef DEPTH_TRACE
+ fprintf(stderr, "FFBWriteDepthPixels: n(%d)\n", (int) n);
+#endif
+ if (ctx->Depth.Mask) {
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ char *zbase;
+ GLuint i;
+
+ if (!fmesa->hw_locked)
+ LOCK_HARDWARE(fmesa);
+ FFBFifo(fmesa, 2);
+ fmesa->regs->fbc = (FFB_FBC_WB_C | FFB_FBC_ZE_ON |
+ FFB_FBC_YE_OFF | FFB_FBC_RGBE_OFF);
+ fmesa->regs->ppc = FFB_PPC_ZS_VAR;
+ fmesa->ffbScreen->rp_active = 1;
+ FFBWait(fmesa, fmesa->regs);
+
+ zbase = ((char *)fmesa->sfb32 +
+ (dPriv->x << 2) + (dPriv->y << 13));
+
+ for (i = 0; i < n; i++) {
+ GLint y1 = (dPriv->h - y[i]);
+ GLint x1 = x[i];
+ GLuint *zptr;
+
+ zptr = (GLuint *)
+ (zbase + (x1 << 2) + (y1 << 13));
+ if (mask[i])
+ *zptr = Z_FROM_MESA(depth[i]);
+ }
+
+ FFBFifo(fmesa, 2);
+ fmesa->regs->fbc = fmesa->fbc;
+ fmesa->regs->ppc = fmesa->ppc;
+ fmesa->ffbScreen->rp_active = 1;
+ if (!fmesa->hw_locked)
+ UNLOCK_HARDWARE(fmesa);
+ }
+}
+
+static void FFBReadDepthSpan( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ void *values )
+{
+ GLuint *depth = (GLuint *) values;
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ GLuint *zptr;
+ GLuint i;
+
+#ifdef DEPTH_TRACE
+ fprintf(stderr, "FFBReadDepthSpan: n(%d) x(%d) y(%d)\n",
+ (int) n, x, y);
+#endif
+ if (!fmesa->hw_locked)
+ LOCK_HARDWARE(fmesa);
+ FFBFifo(fmesa, 1);
+ fmesa->regs->fbc = FFB_FBC_RB_C;
+ fmesa->ffbScreen->rp_active = 1;
+ FFBWait(fmesa, fmesa->regs);
+
+ y = (dPriv->h - y);
+ zptr = (GLuint *)
+ ((char *)fmesa->sfb32 +
+ ((dPriv->x + x) << 2) +
+ ((dPriv->y + y) << 13));
+
+ for (i = 0; i < n; i++) {
+ depth[i] = Z_TO_MESA(*zptr);
+ zptr++;
+ }
+
+ FFBFifo(fmesa, 1);
+ fmesa->regs->fbc = fmesa->fbc;
+ fmesa->ffbScreen->rp_active = 1;
+ if (!fmesa->hw_locked)
+ UNLOCK_HARDWARE(fmesa);
+}
+
+static void FFBReadDepthPixels( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ void *values )
+{
+ GLuint *depth = (GLuint *) values;
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ char *zbase;
+ GLuint i;
+
+#ifdef DEPTH_TRACE
+ fprintf(stderr, "FFBReadDepthPixels: n(%d)\n", (int) n);
+#endif
+ if (!fmesa->hw_locked)
+ LOCK_HARDWARE(fmesa);
+ FFBFifo(fmesa, 1);
+ fmesa->regs->fbc = FFB_FBC_RB_C;
+ fmesa->ffbScreen->rp_active = 1;
+ FFBWait(fmesa, fmesa->regs);
+
+ zbase = ((char *)fmesa->sfb32 +
+ (dPriv->x << 2) + (dPriv->y << 13));
+
+ for (i = 0; i < n; i++) {
+ GLint y1 = (dPriv->h - y[i]);
+ GLint x1 = x[i];
+ GLuint *zptr;
+
+ zptr = (GLuint *)
+ (zbase + (x1 << 2) + (y1 << 13));
+ depth[i] = Z_TO_MESA(*zptr);
+ }
+
+ FFBFifo(fmesa, 1);
+ fmesa->regs->fbc = fmesa->fbc;
+ fmesa->ffbScreen->rp_active = 1;
+ if (!fmesa->hw_locked)
+ UNLOCK_HARDWARE(fmesa);
+}
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+ffbSetDepthFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ assert(drb->Base.InternalFormat == GL_DEPTH_COMPONENT16);
+ drb->Base.GetRow = FFBReadDepthSpan;
+ drb->Base.GetValues = FFBReadDepthPixels;
+ drb->Base.PutRow = FFBWriteDepthSpan;
+ drb->Base.PutMonoRow = FFBWriteMonoDepthSpan;
+ drb->Base.PutValues = FFBWriteDepthPixels;
+ drb->Base.PutMonoValues = NULL;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_depth.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_depth.h
new file mode 100644
index 000000000..db908e7a6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_depth.h
@@ -0,0 +1,8 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_depth.h,v 1.1 2000/06/20 05:08:38 dawes Exp $ */
+
+#ifndef _FFB_DEPTH_H
+#define _FFB_DEPTH_H
+
+void ffbSetDepthFunctions(driRenderbuffer *drb, const GLvisual *vis);
+
+#endif /* !(_FFB_DEPTH_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_fifo.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_fifo.h
new file mode 100644
index 000000000..886d71b76
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_fifo.h
@@ -0,0 +1,28 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_fifo.h,v 1.2 2002/02/22 21:32:58 dawes Exp $ */
+
+#ifndef _FFB_FIFO_H
+#define _FFB_FIFO_H
+
+#define FFBFifo(__fmesa, __n) \
+do { ffbScreenPrivate *__fScrn = (__fmesa)->ffbScreen; \
+ int __cur_slots = __fScrn->fifo_cache; \
+ if ((__cur_slots - (__n)) < 0) { \
+ ffb_fbcPtr __ffb = __fmesa->regs; \
+ do { __cur_slots = (((int)__ffb->ucsr & FFB_UCSR_FIFO_MASK) - 4); \
+ } while ((__cur_slots - (__n)) < 0); \
+ } (__fScrn)->fifo_cache = (__cur_slots - (__n)); \
+} while(0)
+
+#define FFBWait(__fmesa, __ffb) \
+do { ffbScreenPrivate *__fScrn = (__fmesa)->ffbScreen; \
+ if (__fScrn->rp_active) { \
+ unsigned int __regval = (__ffb)->ucsr; \
+ while((__regval & FFB_UCSR_ALL_BUSY) != 0) { \
+ __regval = (__ffb)->ucsr; \
+ } \
+ __fScrn->fifo_cache = ((int)(__regval & FFB_UCSR_FIFO_MASK)) - 4; \
+ __fScrn->rp_active = 0; \
+ } \
+} while(0)
+
+#endif /* !(_FFB_FIFO_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_fog.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_fog.c
new file mode 100644
index 000000000..e6eca2390
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_fog.c
@@ -0,0 +1,73 @@
+
+/* FFB fog support:
+ *
+ * There are two levels of support for FOG in the Creator3D series.
+ * Both involve a depth cue unit and 1 or 4 slope factors and scales
+ * for varying the pixel intensity.
+ *
+ * Chips prior to FFB2 only have a single set of such settings, FFB2
+ * and later have 4 settings.
+ *
+ * The basic depth cueing equation is:
+ *
+ * C_final = dcsf(z) * C_orig + (1 - dcsf(z)) * C_fog
+ *
+ * C_final -- The final color passed to blend unit or frame
+ * buffer (if blending is disabled).
+ *
+ * C_orig -- The color we start with, which comes either from
+ * the raster processor or cpu writes to the smart
+ * framebuffer aperture.
+ *
+ * C_fog -- This is the "fog" color, ie. the desired color
+ * at the deepest Z.
+ *
+ * dcsf(z) -- The depth cue scale as a function of Z.
+ *
+ * With pre-FFB2 chips there are four parameters to control the depth
+ * cue scaling. Here is a diagram:
+ *
+ * 1.0 -------------
+ * | | | |
+ * | | | |
+ * Sfront XXXXX---+---+
+ * | |X | |
+ * dcsf(z) | | X | |
+ * | | X| |
+ * Sback +---+---XXXXX
+ * | | | |
+ * 0.0 -------------
+ * 0.0 Zf Zb 1.0
+ *
+ * z
+ * Therefore:
+ *
+ * for Zf < z < Zb
+ *
+ * dcsf(z) = Sback + ((Sfront - Sback) / (Zf - Zb)) * (Zb - z)
+ *
+ * for z <= Zf
+ *
+ * dcsf(z) = Sfront
+ *
+ * for z >= Zb
+ *
+ * dcsf(z) = Sback
+ *
+ * With FFB2 and later, 3 more slope regions are provided, the first of
+ * them starts at the end of the region defined above and ends at a
+ * specified depth value, the next slop region starts there and ends
+ * at the next specified depth value, and so on. Each of the 3 slope
+ * regions also have scale and slope settings of their own.
+ *
+ * The C_fog color is programmed into the alpha blending unit color1
+ * and color2 registers as follows:
+ *
+ * color1: -(C_fog)
+ * color2: C_fog - bg
+ *
+ * If alpha blending is disabled, the bg factor is zero. Note that
+ * the alpha blending color registers specify each of the RGB values
+ * as 9 bit 1:8 signed numbers in the range -1.00 to 0.ff inclusive.
+ * (ie. 0x100 == -1.00 and 0x0ff == +0.ff)
+ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_lines.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_lines.c
new file mode 100644
index 000000000..da1de18f3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_lines.c
@@ -0,0 +1,111 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_lines.c,v 1.2 2002/02/22 21:32:58 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000, 2001 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "mtypes.h"
+#include "mm.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_depth.h"
+#include "ffb_context.h"
+#include "ffb_vb.h"
+#include "ffb_lines.h"
+#include "ffb_tris.h"
+#include "ffb_lock.h"
+#include "extensions.h"
+
+#undef FFB_LINE_TRACE
+
+#define FFB_LINE_FLAT_BIT 0x01
+#define FFB_LINE_ALPHA_BIT 0x02
+#define MAX_FFB_LINE_FUNCS 0x04
+
+static ffb_line_func ffb_line_tab[MAX_FFB_LINE_FUNCS];
+
+/* If the line is not wide, we can support all of the line
+ * patterning and smooth shading features of OpenGL fully.
+ */
+
+#define IND (0)
+#define TAG(x) x
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_flat
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT)
+#define TAG(x) x##_alpha
+#include "ffb_linetmp.h"
+
+#define IND (FFB_LINE_ALPHA_BIT|FFB_LINE_FLAT_BIT)
+#define TAG(x) x##_alpha_flat
+#include "ffb_linetmp.h"
+
+void ffbDDLinefuncInit(void)
+{
+ init();
+ init_flat();
+ init_alpha();
+ init_alpha_flat();
+}
+
+static void ffb_dd_line( GLcontext *ctx, GLuint e0, GLuint e1 )
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ ffb_vertex *v0 = &fmesa->verts[e0];
+ ffb_vertex *v1 = &fmesa->verts[e1];
+ fmesa->draw_line( ctx, v0, v1 );
+}
+
+void ffbChooseLineState(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint ind = 0;
+
+ tnl->Driver.Render.Line = ffb_dd_line;
+
+ if (flags & DD_FLATSHADE)
+ ind |= FFB_LINE_FLAT_BIT;
+
+ if ((flags & DD_LINE_STIPPLE) != 0 &&
+ fmesa->lpat == FFB_LPAT_BAD) {
+ fmesa->draw_line = ffb_fallback_line;
+ return;
+ }
+
+ /* If blending or the alpha test is enabled we need to
+ * provide alpha components to the chip, else we can
+ * do without it and thus feed vertex data to the chip
+ * more efficiently.
+ */
+ if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled)
+ ind |= FFB_LINE_ALPHA_BIT;
+
+ fmesa->draw_line = ffb_line_tab[ind];
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_lines.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_lines.h
new file mode 100644
index 000000000..d508c243e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_lines.h
@@ -0,0 +1,18 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_lines.h,v 1.2 2002/02/22 21:32:58 dawes Exp $ */
+
+#ifndef _FFB_LINES_H
+#define _FFB_LINES_H
+
+#include "ffb_context.h"
+
+#define _FFB_NEW_LINE (_DD_NEW_FLATSHADE | \
+ _DD_NEW_LINE_WIDTH | \
+ _DD_NEW_LINE_STIPPLE | \
+ _DD_NEW_LINE_SMOOTH | \
+ _NEW_COLOR)
+
+extern void ffbDDLinefuncInit(void);
+extern void ffbChooseLineState(GLcontext *);
+extern void ffb_fallback_line( GLcontext *ctx, ffb_vertex *v0, ffb_vertex *v1 );
+
+#endif /* !(_FFB_LINES_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_linetmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_linetmp.h
new file mode 100644
index 000000000..0951513ca
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_linetmp.h
@@ -0,0 +1,81 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_linetmp.h,v 1.2 2002/02/22 21:32:58 dawes Exp $ */
+
+static __inline void TAG(ffb_line)(GLcontext *ctx, ffb_vertex *v0,
+ ffb_vertex *v1 )
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ ffb_fbcPtr ffb = fmesa->regs;
+#if (IND & FFB_LINE_FLAT_BIT)
+ const GLuint const_fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( v1->color[0] );
+#endif
+ FFB_DELAYED_VIEWPORT_VARS;
+
+#ifdef FFB_LINE_TRACE
+ fprintf(stderr, "FFB: ffb_line ["
+#if (IND & FFB_LINE_FLAT_BIT)
+ " FLAT"
+#endif
+#if (IND & FFB_LINE_ALPHA_BIT)
+ " ALPHA"
+#endif
+ " ]\n");
+#endif
+
+#if (IND & FFB_LINE_FLAT_BIT)
+ FFBFifo(fmesa, 1);
+ ffb->fg = const_fg;
+#ifdef FFB_LINE_TRACE
+ fprintf(stderr, "FFB: ffb_line confg_fg[%08x]\n", const_fg);
+#endif
+#endif
+
+#if (IND & FFB_LINE_FLAT_BIT)
+ /* (2 * 3) + 1 */
+ FFBFifo(fmesa, 7);
+#else
+#if (IND & FFB_LINE_ALPHA_BIT)
+ /* (2 * 7) + 1 */
+ FFBFifo(fmesa, 15);
+#else
+ /* (2 * 6) + 1 */
+ FFBFifo(fmesa, 13);
+#endif
+#endif
+
+ /* Using DDLINE or AALINE, init the line pattern state. */
+ ffb->lpat = fmesa->lpat;
+
+#if !(IND & FFB_LINE_FLAT_BIT)
+#if (IND & FFB_LINE_ALPHA_BIT)
+ ffb->alpha = FFB_GET_ALPHA(v0);
+#endif
+ ffb->red = FFB_GET_RED(v0);
+ ffb->green = FFB_GET_GREEN(v0);
+ ffb->blue = FFB_GET_BLUE(v0);
+#endif
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+#if !(IND & FFB_LINE_FLAT_BIT)
+#if (IND & FFB_LINE_ALPHA_BIT)
+ ffb->alpha = FFB_GET_ALPHA(v1);
+#endif
+ ffb->red = FFB_GET_RED(v1);
+ ffb->green = FFB_GET_GREEN(v1);
+ ffb->blue = FFB_GET_BLUE(v1);
+#endif
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(init)(void)
+{
+ ffb_line_tab[IND] = TAG(ffb_line);
+}
+
+#undef IND
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_lock.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_lock.h
new file mode 100644
index 000000000..7c49f740f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_lock.h
@@ -0,0 +1,37 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_lock.h,v 1.2 2002/02/22 21:32:59 dawes Exp $ */
+
+#ifndef _FFB_LOCK_H
+#define _FFB_LOCK_H
+
+#include "ffb_context.h"
+
+extern void ffbXMesaUpdateState(ffbContextPtr fmesa);
+#define FFB_UPDATE_STATE(fmesa) ffbXMesaUpdateState(fmesa)
+
+/* Lock the hardware and validate our state. This hardware can only ever
+ * exist on SPARC platforms. Don't bother building the real LOCK_HARDWARE and
+ * UNLOCK_HARDWARE code on non-SPARC platforms. The only reason the driver
+ * gets built on non-SPARC is to catch build breakages earlier.
+ */
+#if !defined(__sparc__)
+#define LOCK_HARDWARE(fmesa)
+#define UNLOCK_HARDWARE(fmesa)
+#else
+#define LOCK_HARDWARE(fmesa) \
+ do { \
+ DRM_CAS_RESULT(__ret); \
+ DRM_CAS(fmesa->driHwLock, fmesa->hHWContext, \
+ (DRM_LOCK_HELD | fmesa->hHWContext), __ret);\
+ if (__ret) { \
+ drmGetLock(fmesa->driFd, fmesa->hHWContext, 0); \
+ FFB_UPDATE_STATE(fmesa); \
+ } \
+ } while (0)
+
+
+/* Unlock the hardware. */
+#define UNLOCK_HARDWARE(fmesa) \
+ DRM_UNLOCK(fmesa->driFd, fmesa->driHwLock, fmesa->hHWContext);
+#endif
+
+#endif /* !(_FFB_LOCK_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_points.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_points.c
new file mode 100644
index 000000000..a7496dd1d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_points.c
@@ -0,0 +1,93 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_points.c,v 1.2 2002/02/22 21:32:59 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000, 2001 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "mtypes.h"
+#include "ffb_dd.h"
+#include "ffb_context.h"
+#include "ffb_vb.h"
+#include "ffb_points.h"
+#include "ffb_tris.h"
+#include "ffb_lock.h"
+
+
+#undef FFB_POINT_TRACE
+
+#define FFB_POINT_AA_BIT 0x01
+
+static ffb_point_func ffb_point_tab[0x08];
+
+#define IND (0)
+#define TAG(x) x
+#include "ffb_pointtmp.h"
+
+#define IND (FFB_POINT_AA_BIT)
+#define TAG(x) x##_aa
+#include "ffb_pointtmp.h"
+
+void ffbDDPointfuncInit(void)
+{
+ init();
+ init_aa();
+}
+
+static void ffb_dd_points( GLcontext *ctx, GLuint first, GLuint last )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ ffb_vertex *fverts = fmesa->verts;
+ int i;
+
+ if (VB->Elts == 0) {
+ for ( i = first ; i < last ; i++ ) {
+ if ( VB->ClipMask[i] == 0 ) {
+ fmesa->draw_point( ctx, &fverts[i] );
+ }
+ }
+ } else {
+ for ( i = first ; i < last ; i++ ) {
+ GLuint e = VB->Elts[i];
+ if ( VB->ClipMask[e] == 0 ) {
+ fmesa->draw_point( ctx, &fverts[e] );
+ }
+ }
+ }
+}
+
+void ffbChoosePointState(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint ind = 0;
+
+ tnl->Driver.Render.Points = ffb_dd_points;
+
+ if (flags & DD_POINT_SMOOTH)
+ ind |= FFB_POINT_AA_BIT;
+
+ fmesa->draw_point = ffb_point_tab[ind];
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_points.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_points.h
new file mode 100644
index 000000000..7d5c1f8a0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_points.h
@@ -0,0 +1,15 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_points.h,v 1.2 2002/02/22 21:32:59 dawes Exp $ */
+
+#ifndef _FFB_POINTS_H
+#define _FFB_POINTS_H
+
+extern void ffbDDPointfuncInit(void);
+
+#define _FFB_NEW_POINT (_DD_NEW_POINT_SIZE | \
+ _DD_NEW_POINT_SMOOTH | \
+ _NEW_COLOR)
+
+extern void ffbChoosePointState(GLcontext *);
+extern void ffb_fallback_point( GLcontext *ctx, ffb_vertex *v0 );
+
+#endif /* !(_FFB_POINTS_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_pointtmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_pointtmp.h
new file mode 100644
index 000000000..310c95d89
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_pointtmp.h
@@ -0,0 +1,55 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_pointtmp.h,v 1.3 2002/02/22 21:32:59 dawes Exp $ */
+
+static __inline void TAG(ffb_draw_point)(GLcontext *ctx, ffb_vertex *tmp )
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ ffb_fbcPtr ffb = fmesa->regs;
+ FFB_DELAYED_VIEWPORT_VARS;
+
+#ifdef FFB_POINT_TRACE
+ fprintf(stderr, "FFB: ffb_point ["
+#if (IND & FFB_POINT_AA_BIT)
+ "AA"
+#endif
+ "] X(%f) Y(%f) Z(%f)\n",
+ tmp->x, tmp->y, tmp->z);
+#endif
+
+#if (IND & FFB_POINT_AA_BIT)
+ FFBFifo(fmesa, 4);
+
+ ffb->fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( tmp->color[0] );
+ ffb->z = FFB_GET_Z(tmp);
+ ffb->y = FFB_GET_Y(tmp) + 0x8000 /* FIX ME */;
+ ffb->x = FFB_GET_X(tmp) + 0x8000 /* FIX ME */;
+#else
+ {
+ unsigned int const_fg, const_z, h, w;
+
+ const_fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( tmp->color[0] );
+ const_z = Z_FROM_MESA(FFB_Z_TO_FLOAT(FFB_GET_Z(tmp)));
+ h = FFB_GET_Y(tmp) >> 16;
+ w = FFB_GET_X(tmp) >> 16;
+#ifdef FFB_POINT_TRACE
+ fprintf(stderr, "FFB: ffb_point fg(%08x) z(%08x) h(%08x) w(%08x)\n",
+ const_fg, const_z, h, w);
+#endif
+ FFBFifo(fmesa, 4);
+ ffb->fg = const_fg;
+ ffb->constz = const_z;
+ ffb->bh = h;
+ ffb->bw = w;
+ }
+#endif
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+
+static void TAG(init)(void)
+{
+ ffb_point_tab[IND] = TAG(ffb_draw_point);
+}
+
+#undef IND
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_rendertmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_rendertmp.h
new file mode 100644
index 000000000..26d991b08
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_rendertmp.h
@@ -0,0 +1,646 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_rendertmp.h,v 1.2 2003/01/29 23:00:40 dawes Exp $ */
+
+#define IMPL_LOCAL_VARS \
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx); \
+ ffb_fbcPtr ffb = fmesa->regs; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ FFB_DELAYED_VIEWPORT_VARS; \
+ (void) fmesa; (void) ffb; (void) elt
+
+#if (IND & FFB_FLAT_BIT)
+#define FFB_DECLARE_CACHED_COLOR(NAME) \
+ unsigned int NAME;
+#define FFB_COMPUTE_CACHED_COLOR(NAME, VTX) \
+ NAME = FFB_PACK_CONST_UBYTE_ARGB_COLOR((VTX)->color[0])
+#define FFB_CACHED_COLOR_SAME(NAME1, NAME2) \
+ ((NAME1) == (NAME2))
+#define FFB_CACHED_COLOR_SET(NAME) \
+ ffb->fg = (NAME)
+#define FFB_CACHED_COLOR_UPDATE(NAME1, NAME2) \
+ ffb->fg = (NAME1) = (NAME2)
+#define FFB_SET_PRIM_COLOR(COLOR_VERTEX) \
+ ffb->fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR((COLOR_VERTEX)->color[0])
+#define FFB_PRIM_COLOR_COST 1
+#define FFB_SET_VERTEX_COLOR(VTX) /**/
+#define FFB_VERTEX_COLOR_COST 0
+#else
+#define FFB_DECLARE_CACHED_COLOR(NAME) /**/
+#define FFB_COMPUTE_CACHED_COLOR(NAME, VTX) /**/
+#define FFB_CACHED_COLOR_SAME(NAME1, NAME2) 0
+#define FFB_CACHED_COLOR_SET(NAME1) /**/
+#define FFB_CACHED_COLOR_UPDATE(NAME1, NAME2) /**/
+#define FFB_SET_PRIM_COLOR(COLOR_VERTEX) /**/
+#define FFB_PRIM_COLOR_COST 0
+#if (IND & FFB_ALPHA_BIT)
+#define FFB_SET_VERTEX_COLOR(VTX) \
+ ffb->alpha = FFB_GET_ALPHA(VTX); \
+ ffb->red = FFB_GET_RED(VTX); \
+ ffb->green = FFB_GET_GREEN(VTX); \
+ ffb->blue = FFB_GET_BLUE(VTX)
+#define FFB_VERTEX_COLOR_COST 4
+#else
+#define FFB_SET_VERTEX_COLOR(VTX) \
+ ffb->red = FFB_GET_RED(VTX); \
+ ffb->green = FFB_GET_GREEN(VTX); \
+ ffb->blue = FFB_GET_BLUE(VTX)
+#define FFB_VERTEX_COLOR_COST 3
+#endif
+#endif
+
+#define RESET_STIPPLE ffb->lpat = fmesa->lpat;
+
+#if !(IND & (FFB_TRI_CULL_BIT))
+static void TAG(ffb_vb_points)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
+ __FUNCTION__, start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_POINTS);
+ if (ctx->_TriangleCaps & DD_POINT_SMOOTH) {
+ for (i = start; i < count; i++) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i)];
+
+ FFBFifo(fmesa, 4);
+ ffb->fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR(v0->color[0]);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->y = FFB_GET_Y(v0) + 0x8000 /* FIX ME */;
+ ffb->x = FFB_GET_X(v0) + 0x8000 /* FIX ME */;
+ }
+ } else {
+ for (i = start; i < count; i++) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i)];
+ FFBFifo(fmesa, 4);
+ ffb->fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR(v0->color[0]);
+ ffb->constz = Z_FROM_MESA(FFB_Z_TO_FLOAT(FFB_GET_Z(v0)));
+ ffb->bh = FFB_GET_Y(v0) >> 16;
+ ffb->bw = FFB_GET_X(v0) >> 16;
+ }
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(ffb_vb_lines)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
+ __FUNCTION__, start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_LINES);
+ for (i = start + 1; i < count; i += 2) {
+ ffb_vertex *v0 = &fmesa->verts[i - 1];
+ ffb_vertex *v1 = &fmesa->verts[i - 0];
+
+ FFBFifo(fmesa, (1 + FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 2) + 6));
+
+ RESET_STIPPLE;
+
+ FFB_SET_PRIM_COLOR(v1);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+ }
+}
+
+static void TAG(ffb_vb_line_loop)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
+ __FUNCTION__, start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_LINE_LOOP);
+ if ((flags & PRIM_BEGIN) != 0) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(start + 0)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(start + 1)];
+
+ FFBFifo(fmesa, (1 + FFB_PRIM_COLOR_COST +
+ ((FFB_VERTEX_COLOR_COST * 2) + (3 * 2))));
+
+ RESET_STIPPLE;
+
+ FFB_SET_PRIM_COLOR(v1);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+ }
+ for (i = start + 2; i < count; i++) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i)];
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST + 3)));
+
+ FFB_SET_PRIM_COLOR(v0);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->y = FFB_GET_Y(v0);
+ ffb->x = FFB_GET_X(v0);
+ }
+ if ((flags & PRIM_END) != 0) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(start)];
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST + 3)));
+
+ FFB_SET_PRIM_COLOR(v0);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->y = FFB_GET_Y(v0);
+ ffb->x = FFB_GET_X(v0);
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(ffb_vb_line_strip)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ FFB_DECLARE_CACHED_COLOR(cached_fg)
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
+ __FUNCTION__, start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_LINE_STRIP);
+ FFBFifo(fmesa, (1 + FFB_PRIM_COLOR_COST +
+ ((FFB_VERTEX_COLOR_COST * 2) + (3 * 2))));
+
+ RESET_STIPPLE;
+
+ {
+ ffb_vertex *v0 = &fmesa->verts[ELT(start + 0)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(start + 1)];
+
+ FFB_COMPUTE_CACHED_COLOR(cached_fg, v0);
+ FFB_CACHED_COLOR_SET(cached_fg);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+ }
+
+ for (i = start + 2; i < count; i++) {
+ ffb_vertex *v1 = &fmesa->verts[ELT(i - 0)];
+ FFB_DECLARE_CACHED_COLOR(new_fg)
+
+ FFB_COMPUTE_CACHED_COLOR(new_fg, v1);
+ if (FFB_CACHED_COLOR_SAME(cached_fg, new_fg)) {
+ FFBFifo(fmesa, ((FFB_VERTEX_COLOR_COST * 1) + (3 * 1)));
+ } else {
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 1) + (3 * 1)));
+ FFB_CACHED_COLOR_UPDATE(cached_fg, new_fg);
+ }
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+#endif /* !(IND & (FFB_TRI_CULL_BIT)) */
+
+/* OK, now things start getting fun :-) */
+#if (IND & (FFB_TRI_CULL_BIT))
+#define FFB_AREA_DECLARE GLfloat cc, ex, ey, fx, fy;
+#define FFB_COMPUTE_AREA_TRI(V0, V1, V2) \
+{ ex = (V1)->x - (V0)->x; \
+ ey = (V1)->y - (V0)->y; \
+ fx = (V2)->x - (V0)->x; \
+ fy = (V2)->y - (V0)->y; \
+ cc = ex*fy-ey*fx; \
+}
+#define FFB_COMPUTE_AREA_QUAD(V0, V1, V2, V3) \
+{ ex = (V2)->x - (V0)->x; \
+ ey = (V2)->y - (V0)->y; \
+ fx = (V3)->x - (V1)->x; \
+ fy = (V3)->y - (V1)->y; \
+ cc = ex*fy-ey*fx; \
+}
+#else
+#define FFB_AREA_DECLARE /**/
+#define FFB_COMPUTE_AREA_TRI(V0, V1, V2) do { } while(0)
+#define FFB_COMPUTE_AREA_QUAD(V0, V1, V2, V3) do { } while(0)
+#endif
+
+#if (IND & FFB_TRI_CULL_BIT)
+#define FFB_CULL_TRI(CULL_ACTION) \
+ if (cc * fmesa->backface_sign > fmesa->ffb_zero) { \
+ CULL_ACTION \
+ }
+#define FFB_CULL_QUAD(CULL_ACTION) \
+ if (cc * fmesa->backface_sign > fmesa->ffb_zero) { \
+ CULL_ACTION \
+ }
+#else
+#define FFB_CULL_TRI(CULL_ACTION) do { } while (0)
+#define FFB_CULL_QUAD(CULL_ACTION) do { } while (0)
+#endif
+
+static void TAG(ffb_vb_triangles)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
+ __FUNCTION__, start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_TRIANGLES);
+ for (i = start + 2; i < count; i += 3) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i - 2)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(i - 1)];
+ ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)];
+ FFB_AREA_DECLARE
+
+ FFB_COMPUTE_AREA_TRI(v0, v1, v2);
+ FFB_CULL_TRI(continue;);
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 3) + 9));
+ FFB_SET_PRIM_COLOR(v2);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+
+ FFB_SET_VERTEX_COLOR(v2);
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(ffb_vb_tri_strip)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ GLint parity = 0;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
+ __FUNCTION__, start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_TRIANGLE_STRIP);
+
+ i = start + 2;
+ goto something_clipped;
+
+ something_clipped:
+ for (; i < count; i++, parity ^= 1) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i - 2 + parity)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(i - 1 - parity)];
+ ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)];
+ FFB_AREA_DECLARE
+
+ FFB_COMPUTE_AREA_TRI(v0, v1, v2);
+ FFB_CULL_TRI(continue;);
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 3) + 9));
+ FFB_SET_PRIM_COLOR(v2);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+
+ FFB_SET_VERTEX_COLOR(v2);
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
+
+ i++;
+ parity ^= 1;
+ break;
+ }
+
+ for (; i < count; i++, parity ^= 1) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i - 2 + parity)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(i - 1 - parity)];
+ ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)];
+ FFB_AREA_DECLARE
+ (void) v0; (void) v1;
+
+ FFB_COMPUTE_AREA_TRI(v0, v1, v2);
+ FFB_CULL_TRI(i++; parity^=1; goto something_clipped;);
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 1) + 3));
+ FFB_SET_PRIM_COLOR(v2);
+
+ FFB_SET_VERTEX_COLOR(v2);
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(ffb_vb_tri_fan)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
+ __FUNCTION__, start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_TRIANGLE_FAN);
+
+ i = start + 2;
+ goto something_clipped;
+
+ something_clipped:
+ for ( ; i < count; i++) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(start)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(i - 1)];
+ ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)];
+ FFB_AREA_DECLARE
+
+ FFB_COMPUTE_AREA_TRI(v0, v1, v2);
+ FFB_CULL_TRI(continue;);
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 3) + 9));
+ FFB_SET_PRIM_COLOR(v2);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+
+ FFB_SET_VERTEX_COLOR(v2);
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
+
+ i++;
+ break;
+ }
+
+ for (; i < count; i++) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(start)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(i - 1)];
+ ffb_vertex *v2 = &fmesa->verts[ELT(i - 0)];
+ FFB_AREA_DECLARE
+ (void) v0; (void) v1;
+
+ FFB_COMPUTE_AREA_TRI(v0, v1, v2);
+ FFB_CULL_TRI(i++; goto something_clipped;);
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 1) + 3));
+ FFB_SET_PRIM_COLOR(v2);
+
+ FFB_SET_VERTEX_COLOR(v2);
+ ffb->z = FFB_GET_Z(v2);
+ ffb->dmyf = FFB_GET_Y(v2);
+ ffb->dmxf = FFB_GET_X(v2);
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(ffb_vb_poly)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
+ __FUNCTION__, start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_POLYGON);
+
+ /* XXX Optimize XXX */
+ for (i = start + 2; i < count; i++) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i - 1)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(i)];
+ ffb_vertex *v2 = &fmesa->verts[ELT(start)];
+ FFB_AREA_DECLARE
+
+ FFB_COMPUTE_AREA_TRI(v0, v1, v2);
+ FFB_CULL_TRI(continue;);
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 3) + 9));
+ FFB_SET_PRIM_COLOR(v2);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+
+ FFB_SET_VERTEX_COLOR(v2);
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(ffb_vb_quads)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
+ __FUNCTION__, start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_QUADS);
+
+ for (i = start + 3; i < count; i += 4) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i - 3)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(i - 2)];
+ ffb_vertex *v2 = &fmesa->verts[ELT(i - 1)];
+ ffb_vertex *v3 = &fmesa->verts[ELT(i - 0)];
+ FFB_AREA_DECLARE
+
+ FFB_COMPUTE_AREA_QUAD(v0, v1, v2, v3);
+ FFB_CULL_QUAD(continue;);
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 4) + 12));
+ FFB_SET_PRIM_COLOR(v3);
+
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+
+ FFB_SET_VERTEX_COLOR(v2);
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
+
+ FFB_SET_VERTEX_COLOR(v3);
+ ffb->z = FFB_GET_Z(v3);
+ ffb->dmyf = FFB_GET_Y(v3);
+ ffb->dmxf = FFB_GET_X(v3);
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(ffb_vb_quad_strip)(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ GLint i;
+ IMPL_LOCAL_VARS;
+
+#ifdef FFB_RENDER_TRACE
+ fprintf(stderr, "%s: start(%d) count(%d) flags(%x)\n",
+ __FUNCTION__, start, count, flags);
+#endif
+ ffbRenderPrimitive(ctx, GL_QUAD_STRIP);
+
+ /* XXX Optimize XXX */
+ for (i = start + 3; i < count; i += 2) {
+ ffb_vertex *v0 = &fmesa->verts[ELT(i - 1)];
+ ffb_vertex *v1 = &fmesa->verts[ELT(i - 3)];
+ ffb_vertex *v2 = &fmesa->verts[ELT(i - 2)];
+ ffb_vertex *v3 = &fmesa->verts[ELT(i - 0)];
+ FFB_AREA_DECLARE
+
+ FFB_COMPUTE_AREA_QUAD(v0, v1, v2, v3);
+ FFB_CULL_QUAD(continue;);
+
+ FFBFifo(fmesa, (FFB_PRIM_COLOR_COST +
+ (FFB_VERTEX_COLOR_COST * 4) + 12));
+ FFB_SET_PRIM_COLOR(v3);
+
+ FFB_DUMP_VERTEX(v0);
+ FFB_SET_VERTEX_COLOR(v0);
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_DUMP_VERTEX(v1);
+ FFB_SET_VERTEX_COLOR(v1);
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+
+ FFB_DUMP_VERTEX(v2);
+ FFB_SET_VERTEX_COLOR(v2);
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
+
+ FFB_DUMP_VERTEX(v3);
+ FFB_SET_VERTEX_COLOR(v3);
+ ffb->z = FFB_GET_Z(v3);
+ ffb->dmyf = FFB_GET_Y(v3);
+ ffb->dmxf = FFB_GET_X(v3);
+ }
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void (*TAG(render_tab)[GL_POLYGON + 2])(GLcontext *, GLuint, GLuint, GLuint) =
+{
+#if !(IND & (FFB_TRI_CULL_BIT))
+ TAG(ffb_vb_points),
+ TAG(ffb_vb_lines),
+ TAG(ffb_vb_line_loop),
+ TAG(ffb_vb_line_strip),
+#else
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+#endif
+ TAG(ffb_vb_triangles),
+ TAG(ffb_vb_tri_strip),
+ TAG(ffb_vb_tri_fan),
+ TAG(ffb_vb_quads),
+ TAG(ffb_vb_quad_strip),
+ TAG(ffb_vb_poly),
+ ffb_vb_noop,
+};
+
+#undef IND
+#undef TAG
+
+#undef IMPL_LOCAL_VARS
+#undef FFB_DECLARE_CACHED_COLOR
+#undef FFB_COMPUTE_CACHED_COLOR
+#undef FFB_CACHED_COLOR_SAME
+#undef FFB_CACHED_COLOR_SET
+#undef FFB_CACHED_COLOR_UPDATE
+#undef FFB_SET_PRIM_COLOR
+#undef FFB_PRIM_COLOR_COST
+#undef FFB_SET_VERTEX_COLOR
+#undef FFB_VERTEX_COLOR_COST
+#undef RESET_STIPPLE
+#undef FFB_AREA_DECLARE
+#undef FFB_COMPUTE_AREA_TRI
+#undef FFB_COMPUTE_AREA_QUAD
+#undef FFB_CULL_TRI
+#undef FFB_CULL_QUAD
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_span.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_span.c
new file mode 100644
index 000000000..f4698c64e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_span.c
@@ -0,0 +1,135 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_span.c,v 1.2 2002/02/22 21:32:59 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "mtypes.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_context.h"
+#include "ffb_lock.h"
+
+#include "swrast/swrast.h"
+
+#define DBG 0
+
+#define HW_LOCK() \
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx); \
+ if (!fmesa->hw_locked) \
+ LOCK_HARDWARE(fmesa);
+
+#define HW_UNLOCK() \
+ if (!fmesa->hw_locked) \
+ UNLOCK_HARDWARE(fmesa); \
+
+#define LOCAL_VARS \
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable; \
+ GLuint height = dPriv->h; \
+ GLuint p; \
+ char *buf; \
+ (void) p
+
+#define INIT_MONO_PIXEL(p, color) \
+ p = ((color[0] << 0) | \
+ (color[1] << 8) | \
+ (color[2] << 16))
+
+/* We use WID clipping, so this test always passes. */
+#define CLIPPIXEL(__x, __y) (1)
+
+/* And also, due to WID clipping, we need not do anything
+ * special here.
+ */
+#define CLIPSPAN(__x,__y,__n,__x1,__n1,__i) \
+ __n1 = __n; \
+ __x1 = __x; \
+
+#define HW_CLIPLOOP() \
+do { unsigned int fbc, ppc, cmp; \
+ FFBWait(fmesa, fmesa->regs); \
+ fbc = fmesa->regs->fbc; ppc = fmesa->regs->ppc; cmp = fmesa->regs->cmp; \
+ fmesa->regs->fbc = ((fbc & \
+ ~(FFB_FBC_WB_C | FFB_FBC_ZE_MASK | FFB_FBC_RGBE_MASK)) \
+ | (FFB_FBC_ZE_OFF | FFB_FBC_RGBE_MASK)); \
+ fmesa->regs->ppc = ((ppc & \
+ ~(FFB_PPC_XS_MASK | FFB_PPC_ABE_MASK | FFB_PPC_DCE_MASK | \
+ FFB_PPC_APE_MASK | FFB_PPC_CS_MASK)) \
+ | (FFB_PPC_XS_WID | FFB_PPC_ABE_DISABLE | \
+ FFB_PPC_DCE_DISABLE | FFB_PPC_APE_DISABLE | \
+ FFB_PPC_CS_VAR)); \
+ fmesa->regs->cmp = ((cmp & ~(0xff << 16)) | (0x80 << 16)); \
+ fmesa->ffbScreen->rp_active = 1; \
+ FFBWait(fmesa, fmesa->regs); \
+ buf = (char *)(fmesa->sfb32 + (dPriv->x << 2) + (dPriv->y << 13));\
+ if (dPriv->numClipRects) {
+
+#define HW_ENDCLIPLOOP() \
+ } \
+ fmesa->regs->fbc = fbc; \
+ fmesa->regs->ppc = ppc; \
+ fmesa->regs->cmp = cmp; \
+ fmesa->ffbScreen->rp_active = 1; \
+} while(0)
+
+#define Y_FLIP(__y) (height - __y)
+
+#define READ_RGBA(rgba,__x,__y) \
+do { GLuint p = *(GLuint *)(buf + ((__x)<<2) + ((__y)<<13)); \
+ rgba[0] = (p >> 0) & 0xff; \
+ rgba[1] = (p >> 8) & 0xff; \
+ rgba[2] = (p >> 16) & 0xff; \
+ rgba[3] = 0xff; \
+} while(0)
+
+#define WRITE_RGBA(__x, __y, __r, __g, __b, __a) \
+ *(GLuint *)(buf + ((__x)<<2) + ((__y)<<13)) = \
+ ((((__r) & 0xff) << 0) | \
+ (((__g) & 0xff) << 8) | \
+ (((__b) & 0xff) << 16))
+
+#define WRITE_PIXEL(__x, __y, __p) \
+ *(GLuint *)(buf + ((__x)<<2) + ((__y)<<13)) = (__p)
+
+#define TAG(x) ffb##x##_888
+
+#include <spantmp.h>
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+ffbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ assert(vis->redBits == 8);
+ assert(vis->greenBits == 8);
+ assert(vis->blueBits == 8);
+ drb->Base.GetRow = ffbReadRGBASpan_888;
+ drb->Base.GetValues = ffbReadRGBAPixels_888;
+ drb->Base.PutRow = ffbWriteRGBASpan_888;
+ drb->Base.PutRowRGB = ffbWriteRGBSpan_888;
+ drb->Base.PutMonoRow = ffbWriteMonoRGBASpan_888;
+ drb->Base.PutValues = ffbWriteRGBAPixels_888;
+ drb->Base.PutMonoValues = ffbWriteMonoRGBAPixels_888;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_span.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_span.h
new file mode 100644
index 000000000..5ae227910
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_span.h
@@ -0,0 +1,10 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_span.h,v 1.1 2000/06/20 05:08:39 dawes Exp $ */
+
+#ifndef _FFB_SPAN_H
+#define _FFB_SPAN_H
+
+#include "drirenderbuffer.h"
+
+void ffbSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis);
+
+#endif /* !(_FFB_SPAN_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_state.c
new file mode 100644
index 000000000..86df5b4bc
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_state.c
@@ -0,0 +1,1223 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_state.c,v 1.5 2002/10/30 12:51:27 alanh Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000, 2001 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "mtypes.h"
+#include "buffers.h"
+#include "colormac.h"
+#include "mm.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_depth.h"
+#include "ffb_context.h"
+#include "ffb_vb.h"
+#include "ffb_tris.h"
+#include "ffb_state.h"
+#include "ffb_lock.h"
+#include "extensions.h"
+#include "enums.h"
+
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "tnl/t_pipeline.h"
+
+#undef STATE_TRACE
+
+static unsigned int ffbComputeAlphaFunc(GLcontext *ctx)
+{
+ unsigned int xclip;
+ GLubyte alphaRef;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDAlphaFunc: func(%s) ref(%02x)\n",
+ _mesa_lookup_enum_by_nr(ctx->Color.AlphaFunc),
+ ctx->Color.AlphaRef & 0xff);
+#endif
+
+ switch (ctx->Color.AlphaFunc) {
+ case GL_NEVER: xclip = FFB_XCLIP_TEST_NEVER; break;
+ case GL_LESS: xclip = FFB_XCLIP_TEST_LT; break;
+ case GL_EQUAL: xclip = FFB_XCLIP_TEST_EQ; break;
+ case GL_LEQUAL: xclip = FFB_XCLIP_TEST_LE; break;
+ case GL_GREATER: xclip = FFB_XCLIP_TEST_GT; break;
+ case GL_NOTEQUAL: xclip = FFB_XCLIP_TEST_NE; break;
+ case GL_GEQUAL: xclip = FFB_XCLIP_TEST_GE; break;
+ case GL_ALWAYS: xclip = FFB_XCLIP_TEST_ALWAYS; break;
+
+ default:
+ return FFB_XCLIP_TEST_ALWAYS | 0x00;
+ }
+
+ CLAMPED_FLOAT_TO_UBYTE(alphaRef, ctx->Color.AlphaRef);
+ xclip |= (alphaRef & 0xff);
+
+ return xclip;
+}
+
+static void ffbDDAlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ if (ctx->Color.AlphaEnabled) {
+ unsigned int xclip = ffbComputeAlphaFunc(ctx);
+
+ if (fmesa->xclip != xclip) {
+ fmesa->xclip = xclip;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_XCLIP, 1);
+ }
+ }
+}
+
+static void ffbDDBlendEquationSeparate(GLcontext *ctx,
+ GLenum modeRGB, GLenum modeA)
+{
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDBlendEquation: mode(%s)\n",
+ _mesa_lookup_enum_by_nr(modeRGB));
+#endif
+ assert( modeRGB == modeA );
+ FALLBACK( ctx, (modeRGB != GL_FUNC_ADD), FFB_BADATTR_BLENDEQN);
+}
+
+static void ffbDDBlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB,
+ GLenum dfactorRGB, GLenum sfactorA,
+ GLenum dfactorA)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ unsigned int blendc = 1 << 4;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDBlendFuncSeparate: sRGB(%s) dRGB(%s) sA(%s) dA(%s)\n",
+ _mesa_lookup_enum_by_nr(sfactorRGB),
+ _mesa_lookup_enum_by_nr(dfactorRGB),
+ _mesa_lookup_enum_by_nr(sfactorA),
+ _mesa_lookup_enum_by_nr(dfactorA));
+#endif
+ switch (ctx->Color.BlendSrcRGB) {
+ case GL_ZERO:
+ blendc |= (0 << 0);
+ break;
+
+ case GL_ONE:
+ blendc |= (1 << 0);
+ break;
+
+ case GL_ONE_MINUS_SRC_ALPHA:
+ blendc |= (2 << 0);
+ break;
+
+ case GL_SRC_ALPHA:
+ blendc |= (3 << 0);
+ break;
+
+ default:
+ if (ctx->Color.BlendEnabled)
+ FALLBACK( ctx, FFB_BADATTR_BLENDFUNC, GL_TRUE );
+ return;
+ };
+
+ switch (ctx->Color.BlendDstRGB) {
+ case GL_ZERO:
+ blendc |= (0 << 2);
+ break;
+
+ case GL_ONE:
+ blendc |= (1 << 2);
+ break;
+
+ case GL_ONE_MINUS_SRC_ALPHA:
+ blendc |= (2 << 2);
+ break;
+
+ case GL_SRC_ALPHA:
+ blendc |= (3 << 2);
+ break;
+
+ default:
+ if (ctx->Color.BlendEnabled)
+ FALLBACK( ctx, FFB_BADATTR_BLENDFUNC, GL_TRUE );
+ return;
+ };
+
+ if (ctx->Color.BlendEnabled &&
+ ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY) {
+ /* We could avoid this if sfactor is GL_ONE and
+ * dfactor is GL_ZERO. I do not think that is even
+ * worthwhile to check because if someone is using
+ * blending they use more interesting settings and
+ * also it would add more state tracking to a lot
+ * of the code in this file.
+ */
+ FALLBACK(ctx, FFB_BADATTR_BLENDROP, GL_TRUE);
+ return;
+ }
+
+ FALLBACK( ctx, (FFB_BADATTR_BLENDFUNC|FFB_BADATTR_BLENDROP), GL_FALSE );
+
+ if (blendc != fmesa->blendc) {
+ fmesa->blendc = blendc;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_BLEND, 1);
+ }
+}
+
+static void ffbDDDepthFunc(GLcontext *ctx, GLenum func)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLuint cmp;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDDepthFunc: func(%s)\n",
+ _mesa_lookup_enum_by_nr(func));
+#endif
+
+ switch (func) {
+ case GL_NEVER:
+ cmp = FFB_CMP_MAGN_NEVER;
+ break;
+ case GL_ALWAYS:
+ cmp = FFB_CMP_MAGN_ALWAYS;
+ break;
+ case GL_LESS:
+ cmp = FFB_CMP_MAGN_LT;
+ break;
+ case GL_LEQUAL:
+ cmp = FFB_CMP_MAGN_LE;
+ break;
+ case GL_EQUAL:
+ cmp = FFB_CMP_MAGN_EQ;
+ break;
+ case GL_GREATER:
+ cmp = FFB_CMP_MAGN_GT;
+ break;
+ case GL_GEQUAL:
+ cmp = FFB_CMP_MAGN_GE;
+ break;
+ case GL_NOTEQUAL:
+ cmp = FFB_CMP_MAGN_NE;
+ break;
+ default:
+ return;
+ };
+
+ if (! ctx->Depth.Test)
+ cmp = FFB_CMP_MAGN_ALWAYS;
+
+ cmp <<= 16;
+ cmp = (fmesa->cmp & ~(0xff<<16)) | cmp;
+ if (cmp != fmesa->cmp) {
+ fmesa->cmp = cmp;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_CMP, 1);
+ }
+}
+
+static void ffbDDDepthMask(GLcontext *ctx, GLboolean flag)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLuint fbc = fmesa->fbc;
+ GLboolean enabled_now;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDDepthMask: flag(%d)\n", flag);
+#endif
+
+ if ((fbc & FFB_FBC_ZE_MASK) == FFB_FBC_ZE_OFF)
+ enabled_now = GL_FALSE;
+ else
+ enabled_now = GL_TRUE;
+
+ if (flag != enabled_now) {
+ fbc &= ~FFB_FBC_ZE_MASK;
+ if (flag) {
+ fbc |= FFB_FBC_WB_C | FFB_FBC_ZE_ON;
+ } else {
+ fbc |= FFB_FBC_ZE_OFF;
+ fbc &= ~FFB_FBC_WB_C;
+ }
+ fmesa->fbc = fbc;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_FBC, 1);
+ }
+}
+
+static void ffbDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref, GLuint mask)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ unsigned int stencil, stencilctl, consty;
+
+ /* We will properly update sw/hw state when stenciling is
+ * enabled.
+ */
+ if (! ctx->Stencil.Enabled)
+ return;
+
+ stencilctl = fmesa->stencilctl;
+ stencilctl &= ~(7 << 16);
+
+ switch (func) {
+ case GL_ALWAYS: stencilctl |= (0 << 16); break;
+ case GL_GREATER: stencilctl |= (1 << 16); break;
+ case GL_EQUAL: stencilctl |= (2 << 16); break;
+ case GL_GEQUAL: stencilctl |= (3 << 16); break;
+ case GL_NEVER: stencilctl |= (4 << 16); break;
+ case GL_LEQUAL: stencilctl |= (5 << 16); break;
+ case GL_NOTEQUAL: stencilctl |= (6 << 16); break;
+ case GL_LESS: stencilctl |= (7 << 16); break;
+
+ default:
+ return;
+ };
+
+ consty = ref & 0xf;
+
+ stencil = fmesa->stencil;
+ stencil &= ~(0xf << 20);
+ stencil |= (mask & 0xf) << 20;
+
+ if (fmesa->stencil != stencil ||
+ fmesa->stencilctl != stencilctl ||
+ fmesa->consty != consty) {
+ fmesa->stencil = stencil;
+ fmesa->stencilctl = stencilctl;
+ fmesa->consty = consty;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_STENCIL, 6);
+ }
+}
+
+static void ffbDDStencilMask(GLcontext *ctx, GLuint mask)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ mask &= 0xf;
+ if (fmesa->ypmask != mask) {
+ fmesa->ypmask = mask;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_YPMASK, 1);
+ }
+}
+
+static void ffbDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ unsigned int stencilctl;
+
+ /* We will properly update sw/hw state when stenciling is
+ * enabled.
+ */
+ if (! ctx->Stencil.Enabled)
+ return;
+
+ stencilctl = fmesa->stencilctl;
+ stencilctl &= ~(0xfff00000);
+
+ switch (fail) {
+ case GL_ZERO: stencilctl |= (0 << 28); break;
+ case GL_KEEP: stencilctl |= (1 << 28); break;
+ case GL_INVERT: stencilctl |= (2 << 28); break;
+ case GL_REPLACE: stencilctl |= (3 << 28); break;
+ case GL_INCR: stencilctl |= (4 << 28); break;
+ case GL_DECR: stencilctl |= (5 << 28); break;
+
+ default:
+ return;
+ };
+
+ switch (zfail) {
+ case GL_ZERO: stencilctl |= (0 << 24); break;
+ case GL_KEEP: stencilctl |= (1 << 24); break;
+ case GL_INVERT: stencilctl |= (2 << 24); break;
+ case GL_REPLACE: stencilctl |= (3 << 24); break;
+ case GL_INCR: stencilctl |= (4 << 24); break;
+ case GL_DECR: stencilctl |= (5 << 24); break;
+
+ default:
+ return;
+ };
+
+ switch (zpass) {
+ case GL_ZERO: stencilctl |= (0 << 20); break;
+ case GL_KEEP: stencilctl |= (1 << 20); break;
+ case GL_INVERT: stencilctl |= (2 << 20); break;
+ case GL_REPLACE: stencilctl |= (3 << 20); break;
+ case GL_INCR: stencilctl |= (4 << 20); break;
+ case GL_DECR: stencilctl |= (5 << 20); break;
+
+ default:
+ return;
+ };
+
+ if (fmesa->stencilctl != stencilctl) {
+ fmesa->stencilctl = stencilctl;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_STENCIL, 6);
+ }
+}
+
+static void ffbCalcViewportRegs(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ GLuint xmin, xmax, ymin, ymax, zmin, zmax;
+ unsigned int vcmin, vcmax;
+
+ xmin = ctx->Viewport.X + dPriv->x;
+ xmax = xmin + ctx->Viewport.Width;
+ ymax = dPriv->y + dPriv->h - ctx->Viewport.Y;
+ ymin = ymax - ctx->Viewport.Height;
+ if (ctx->Scissor.Enabled) {
+ GLuint sc_xmin, sc_xmax, sc_ymin, sc_ymax;
+
+ sc_xmin = ctx->Viewport.X + dPriv->x;
+ sc_xmax = sc_xmin + ctx->Viewport.Width;
+ sc_ymax = dPriv->y + dPriv->h - ctx->Viewport.Y;
+ sc_ymin = sc_ymax - ctx->Viewport.Height;
+ if (sc_xmin > xmin)
+ xmin = sc_xmin;
+ if (sc_xmax < xmax)
+ xmax = sc_xmax;
+ if (sc_ymin > ymin)
+ ymin = sc_ymin;
+ if (sc_ymax < ymax)
+ ymax = sc_ymax;
+ }
+ zmin = ((GLdouble)ctx->Viewport.Near * 0x0fffffff);
+ zmax = ((GLdouble)ctx->Viewport.Far * 0x0fffffff);
+
+ vcmin = ((ymin & 0xffff) << 16) | (xmin & 0xffff);
+ vcmax = ((ymax & 0xffff) << 16) | (xmax & 0xffff);
+ if (fmesa->vclipmin != vcmin ||
+ fmesa->vclipmax != vcmax ||
+ fmesa->vclipzmin != zmin ||
+ fmesa->vclipzmax != zmax) {
+ fmesa->vclipmin = vcmin;
+ fmesa->vclipmax = vcmax;
+ fmesa->vclipzmin = zmin;
+ fmesa->vclipzmax = zmax;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_CLIP, (4 + (4 * 2)));
+ }
+}
+
+void ffbCalcViewport(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat *m = fmesa->hw_viewport;
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+
+ m[MAT_SX] = v[MAT_SX];
+ m[MAT_TX] = v[MAT_TX] + dPriv->x + SUBPIXEL_X;
+ m[MAT_SY] = - v[MAT_SY];
+ m[MAT_TY] = - v[MAT_TY] + dPriv->h + dPriv->y + SUBPIXEL_Y;
+ m[MAT_SZ] = v[MAT_SZ] * ((GLdouble)1.0 / (GLdouble)0x0fffffff);
+ m[MAT_TZ] = v[MAT_TZ] * ((GLdouble)1.0 / (GLdouble)0x0fffffff);
+
+ fmesa->depth_scale = ((GLdouble)1.0 / (GLdouble)0x0fffffff);
+
+ ffbCalcViewportRegs(ctx);
+
+ fmesa->setupnewinputs |= VERT_BIT_POS;
+}
+
+static void ffbDDViewport(GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height)
+{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
+ ffbCalcViewport(ctx);
+}
+
+static void ffbDDDepthRange(GLcontext *ctx, GLclampd nearval, GLclampd farval)
+{
+ ffbCalcViewport(ctx);
+}
+
+static void ffbDDScissor(GLcontext *ctx, GLint cx, GLint cy,
+ GLsizei cw, GLsizei ch)
+{
+ ffbCalcViewport(ctx);
+}
+
+static void ffbDDDrawBuffer(GLcontext *ctx, GLenum buffer)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ unsigned int fbc = fmesa->fbc;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDDrawBuffer: mode(%s)\n",
+ _mesa_lookup_enum_by_nr(buffer));
+#endif
+ fbc &= ~(FFB_FBC_WB_AB | FFB_FBC_RB_MASK);
+ switch (buffer) {
+ case GL_FRONT:
+ if (fmesa->back_buffer == 0)
+ fbc |= FFB_FBC_WB_B | FFB_FBC_RB_B;
+ else
+ fbc |= FFB_FBC_WB_A | FFB_FBC_RB_A;
+ break;
+
+ case GL_BACK:
+ if (fmesa->back_buffer == 0)
+ fbc |= FFB_FBC_WB_A | FFB_FBC_RB_A;
+ else
+ fbc |= FFB_FBC_WB_B | FFB_FBC_RB_B;
+ break;
+
+ case GL_FRONT_AND_BACK:
+ fbc |= FFB_FBC_WB_AB;
+ break;
+
+ default:
+ return;
+ };
+
+ if (fbc != fmesa->fbc) {
+ fmesa->fbc = fbc;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_FBC, 1);
+ }
+}
+
+
+static void ffbDDReadBuffer(GLcontext *ctx, GLenum buffer)
+{
+ /* no-op, unless you implement h/w glRead/CopyPixels */
+}
+
+
+/*
+ * Specifies buffer for sw fallbacks (spans)
+ */
+static void ffbDDSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
+ GLuint bufferBit)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ unsigned int fbc = fmesa->fbc;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDSetReadBuffer: mode(%s)\n",
+ _mesa_lookup_enum_by_nr(buffer));
+#endif
+ fbc &= ~(FFB_FBC_RB_MASK);
+ switch (bufferBit) {
+ case BUFFER_BIT_FRONT_LEFT:
+ if (fmesa->back_buffer == 0)
+ fbc |= FFB_FBC_RB_B;
+ else
+ fbc |= FFB_FBC_RB_A;
+ break;
+
+ case BUFFER_BIT_BACK_LEFT:
+ if (fmesa->back_buffer == 0)
+ fbc |= FFB_FBC_RB_A;
+ else
+ fbc |= FFB_FBC_RB_B;
+ break;
+
+ default:
+ _mesa_problem(ctx, "Unexpected buffer in ffbDDSetBuffer()");
+ return;
+ };
+
+ if (fbc != fmesa->fbc) {
+ fmesa->fbc = fbc;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_FBC, 1);
+ }
+}
+
+static void ffbDDClearColor(GLcontext *ctx, const GLfloat color[4])
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLubyte c[4];
+ CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
+
+ fmesa->clear_pixel = ((c[0] << 0) |
+ (c[1] << 8) |
+ (c[2] << 16));
+}
+
+static void ffbDDClearDepth(GLcontext *ctx, GLclampd depth)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ fmesa->clear_depth = Z_FROM_MESA(depth * 4294967295.0f);
+}
+
+static void ffbDDClearStencil(GLcontext *ctx, GLint stencil)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ fmesa->clear_stencil = stencil & 0xf;
+}
+
+/* XXX Actually, should I be using FBC controls for this? -DaveM */
+static void ffbDDColorMask(GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ unsigned int new_pmask = 0x0;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDColorMask: r(%d) g(%d) b(%d) a(%d)\n",
+ r, g, b, a);
+#endif
+ if (r)
+ new_pmask |= 0x000000ff;
+ if (g)
+ new_pmask |= 0x0000ff00;
+ if (b)
+ new_pmask |= 0x00ff0000;
+ if (a)
+ new_pmask |= 0xff000000;
+
+ if (fmesa->pmask != new_pmask) {
+ fmesa->pmask = new_pmask;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_PMASK, 1);
+ }
+}
+
+static void ffbDDLogicOp(GLcontext *ctx, GLenum op)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ unsigned int rop;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDLogicOp: op(%s)\n",
+ _mesa_lookup_enum_by_nr(op));
+#endif
+ switch (op) {
+ case GL_CLEAR: rop = FFB_ROP_ZERO; break;
+ case GL_SET: rop = FFB_ROP_ONES; break;
+ case GL_COPY: rop = FFB_ROP_NEW; break;
+ case GL_AND: rop = FFB_ROP_NEW_AND_OLD; break;
+ case GL_NAND: rop = FFB_ROP_NEW_AND_NOLD; break;
+ case GL_OR: rop = FFB_ROP_NEW_OR_OLD; break;
+ case GL_NOR: rop = FFB_ROP_NEW_OR_NOLD; break;
+ case GL_XOR: rop = FFB_ROP_NEW_XOR_OLD; break;
+ case GL_NOOP: rop = FFB_ROP_OLD; break;
+ case GL_COPY_INVERTED: rop = FFB_ROP_NNEW; break;
+ case GL_INVERT: rop = FFB_ROP_NOLD; break;
+ case GL_EQUIV: rop = FFB_ROP_NNEW_XOR_NOLD; break;
+ case GL_AND_REVERSE: rop = FFB_ROP_NEW_AND_NOLD; break;
+ case GL_AND_INVERTED: rop = FFB_ROP_NNEW_AND_OLD; break;
+ case GL_OR_REVERSE: rop = FFB_ROP_NEW_OR_NOLD; break;
+ case GL_OR_INVERTED: rop = FFB_ROP_NNEW_OR_OLD; break;
+
+ default:
+ return;
+ };
+
+ rop |= fmesa->rop & ~0xff;
+ if (rop != fmesa->rop) {
+ fmesa->rop = rop;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_ROP, 1);
+
+ if (op == GL_COPY)
+ FALLBACK( ctx, FFB_BADATTR_BLENDROP, GL_FALSE );
+ }
+}
+
+#if 0
+/* XXX Also need to track near/far just like 3dfx driver.
+ * XXX
+ * XXX Actually, that won't work, because the 3dfx chip works by
+ * XXX having 1/w coordinates fed to it for each primitive, and
+ * XXX it uses this to index it's 64 entry fog table.
+ */
+static void ffb_fog_linear(GLcontext *ctx, ffbContextPtr fmesa)
+{
+ GLfloat c = ctx->ProjectionMatrix.m[10];
+ GLfloat d = ctx->ProjectionMatrix.m[14];
+ GLfloat tz = ctx->Viewport.WindowMap.m[MAT_TZ];
+ GLfloat szInv = 1.0F / ctx->Viewport.WindowMap.m[MAT_SZ];
+ GLfloat fogEnd = ctx->Fog.End;
+ GLfloat fogScale = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
+ GLfloat ndcz;
+ GLfloat eyez;
+ GLfloat Zzero, Zone;
+ unsigned int zb, zf;
+
+ /* Compute the Z at which f reaches 0.0, this is the full
+ * saturation point.
+ *
+ * Thus compute Z (as seen by the chip during rendering),
+ * such that:
+ *
+ * 0.0 = (fogEnd - eyez) * fogScale
+ *
+ * fogScale is usually not zero, thus we are looking for:
+ *
+ * fogEnd = eyez
+ *
+ * fogEnd = -d / (c + ((Z - tz) * szInv))
+ * fogEnd * (c + ((Z - tz) * szInv)) = -d
+ * (c + ((Z - tz) * szInv)) = -d / fogEnd
+ * (Z - tz) * szInv = (-d / fogEnd) - c
+ * (Z - tz) = ((-d / fogEnd) - c) / szInv
+ * Z = (((-d / fogEnd) - c) / szInv) + tz
+ */
+ Zzero = (((-d / fogEnd) - c) / szInv) + tz;
+
+ /* Compute the Z at which f reaches 1.0, this is where
+ * the incoming frag's full intensity is shown. This
+ * equation is:
+ *
+ * 1.0 = (fogEnd - eyez)
+ *
+ * We are looking for:
+ *
+ * 1.0 + eyez = fogEnd
+ *
+ * 1.0 + (-d / (c + ((Z - tz) * szInv))) = fogEnd
+ * -d / (c + ((Z - tz) * szInv)) = fogEnd - 1.0
+ * -d / (FogEnd - 1.0) = (c + ((Z - tz) * szInv))
+ * (-d / (fogEnd - 1.0)) - c = ((Z - tz) * szInv)
+ * ((-d / (fogEnd - 1.0)) - c) / szInv = (Z - tz)
+ * (((-d / (fogEnd - 1.0)) - c) / szInv) + tz = Z
+ */
+ Zone = (((-d / (fogEnd - 1.0)) - c) / szInv) + tz;
+
+ /* FFB's Zfront must be less than Zback, thus we may have
+ * to invert Sf/Sb to satisfy this constraint.
+ */
+ if (Zzero < Zone) {
+ sf = 0.0;
+ sb = 1.0;
+ zf = Z_FROM_MESA(Zzero);
+ zb = Z_FROM_MESA(Zone);
+ } else {
+ sf = 1.0;
+ sb = 0.0;
+ zf = Z_FROM_MESA(Zone);
+ zb = Z_FROM_MESA(Zzero);
+ }
+}
+#endif
+
+static void ffbDDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
+{
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDFogfv: pname(%s)\n", _mesa_lookup_enum_by_nr(pname));
+#endif
+}
+
+static void ffbDDLineStipple(GLcontext *ctx, GLint factor, GLushort pattern)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDLineStipple: factor(%d) pattern(%04x)\n",
+ factor, pattern);
+#endif
+ if (ctx->Line.StippleFlag) {
+ factor = ctx->Line.StippleFactor;
+ pattern = ctx->Line.StipplePattern;
+ if ((GLuint) factor > 15) {
+ fmesa->lpat = FFB_LPAT_BAD;
+ } else {
+ fmesa->lpat = ((factor << FFB_LPAT_SCALEVAL_SHIFT) |
+ (0 << FFB_LPAT_PATLEN_SHIFT) |
+ ((pattern & 0xffff) << FFB_LPAT_PATTERN_SHIFT));
+ }
+ } else {
+ fmesa->lpat = 0;
+ }
+}
+
+void ffbXformAreaPattern(ffbContextPtr fmesa, const GLubyte *mask)
+{
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ int i, lines, xoff;
+
+ lines = 0;
+ i = (dPriv->y + dPriv->h) & (32 - 1);
+ xoff = dPriv->x & (32 - 1);
+ while (lines++ < 32) {
+ GLuint raw =
+ (((GLuint)mask[0] << 24) |
+ ((GLuint)mask[1] << 16) |
+ ((GLuint)mask[2] << 8) |
+ ((GLuint)mask[3] << 0));
+
+ fmesa->pattern[i] =
+ (raw << xoff) | (raw >> (32 - xoff));
+ i = (i - 1) & (32 - 1);
+ mask += 4;
+ }
+
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_APAT, 32);
+}
+
+static void ffbDDPolygonStipple(GLcontext *ctx, const GLubyte *mask)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDPolygonStipple: state(%d)\n",
+ ctx->Polygon.StippleFlag);
+#endif
+ ffbXformAreaPattern(fmesa, mask);
+}
+
+static void ffbDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ unsigned int tmp;
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDEnable: %s state(%d)\n",
+ _mesa_lookup_enum_by_nr(cap), state);
+#endif
+ switch (cap) {
+ case GL_ALPHA_TEST:
+ if (state)
+ tmp = ffbComputeAlphaFunc(ctx);
+ else
+ tmp = FFB_XCLIP_TEST_ALWAYS;
+
+ if (tmp != fmesa->xclip) {
+ fmesa->xclip = tmp;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_XCLIP, 1);
+ }
+ break;
+
+ case GL_BLEND:
+ tmp = (fmesa->ppc & ~FFB_PPC_ABE_MASK);
+ if (state) {
+ tmp |= FFB_PPC_ABE_ENABLE;
+ } else {
+ tmp |= FFB_PPC_ABE_DISABLE;
+ }
+ if (fmesa->ppc != tmp) {
+ fmesa->ppc = tmp;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_PPC, 1);
+ ffbDDBlendFuncSeparate(ctx, 0, 0, 0, 0 );
+ }
+ break;
+
+ case GL_DEPTH_TEST:
+ if (state)
+ tmp = 0x0fffffff;
+ else
+ tmp = 0x00000000;
+ if (tmp != fmesa->magnc) {
+ unsigned int fbc = fmesa->fbc;
+ fbc &= ~FFB_FBC_ZE_MASK;
+ if (state)
+ fbc |= FFB_FBC_ZE_ON;
+ else
+ fbc |= FFB_FBC_ZE_OFF;
+ fmesa->fbc = fbc;
+ ffbDDDepthFunc(ctx, ctx->Depth.Func);
+ fmesa->magnc = tmp;
+ FFB_MAKE_DIRTY(fmesa, (FFB_STATE_MAGNC | FFB_STATE_FBC), 2);
+ }
+ break;
+
+ case GL_SCISSOR_TEST:
+ ffbDDScissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
+ ctx->Scissor.Width, ctx->Scissor.Height);
+ break;
+
+ case GL_STENCIL_TEST:
+ if (!(fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS)) {
+ FALLBACK( ctx, FFB_BADATTR_STENCIL, state );
+ }
+
+ tmp = fmesa->fbc & ~FFB_FBC_YE_MASK;
+ if (state) {
+ ffbDDStencilFunc(ctx,
+ ctx->Stencil.Function[0],
+ ctx->Stencil.Ref[0],
+ ctx->Stencil.ValueMask[0]);
+ ffbDDStencilMask(ctx, ctx->Stencil.WriteMask[0]);
+ ffbDDStencilOp(ctx,
+ ctx->Stencil.FailFunc[0],
+ ctx->Stencil.ZFailFunc[0],
+ ctx->Stencil.ZPassFunc[0]);
+ tmp |= FFB_FBC_YE_MASK;
+ } else {
+ fmesa->stencil = 0xf0000000;
+ fmesa->stencilctl = 0x33300000;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_STENCIL, 6);
+ tmp |= FFB_FBC_YE_OFF;
+ }
+ if (tmp != fmesa->fbc) {
+ fmesa->fbc = tmp;
+ FFB_MAKE_DIRTY(fmesa, FFB_STATE_FBC, 1);
+ }
+ break;
+
+ case GL_FOG:
+ /* Until I implement the fog support... */
+ FALLBACK( ctx, FFB_BADATTR_FOG, state );
+ break;
+
+ case GL_LINE_STIPPLE:
+ if (! state)
+ fmesa->lpat = 0;
+ else
+ ffbDDLineStipple(ctx,
+ ctx->Line.StippleFactor,
+ ctx->Line.StipplePattern);
+ break;
+
+ case GL_POLYGON_STIPPLE:
+ /* Do nothing, we interrogate the state during
+ * reduced primitive changes. Since our caller
+ * will set NEW_POLYGON in the ctx NewState this
+ * will cause the driver rasterization functions
+ * to be reevaluated, which will cause us to force
+ * a reduced primitive change next rendering pass
+ * and it all works out.
+ */
+ break;
+
+ default:
+ break;
+ };
+}
+
+void ffbSyncHardware(ffbContextPtr fmesa)
+{
+ ffb_fbcPtr ffb = fmesa->regs;
+ unsigned int dirty;
+ int i;
+
+ FFBFifo(fmesa, fmesa->state_fifo_ents);
+
+ dirty = fmesa->state_dirty;
+ if (dirty & (FFB_STATE_FBC | FFB_STATE_PPC | FFB_STATE_DRAWOP |
+ FFB_STATE_ROP | FFB_STATE_LPAT | FFB_STATE_WID)) {
+ if (dirty & FFB_STATE_FBC)
+ ffb->fbc = fmesa->fbc;
+ if (dirty & FFB_STATE_PPC)
+ ffb->ppc = fmesa->ppc;
+ if (dirty & FFB_STATE_DRAWOP)
+ ffb->drawop = fmesa->drawop;
+ if (dirty & FFB_STATE_ROP)
+ ffb->rop = fmesa->rop;
+ if (dirty & FFB_STATE_LPAT)
+ ffb->rop = fmesa->lpat;
+ if (dirty & FFB_STATE_WID)
+ ffb->wid = fmesa->wid;
+ }
+ if (dirty & (FFB_STATE_PMASK | FFB_STATE_XPMASK | FFB_STATE_YPMASK |
+ FFB_STATE_ZPMASK | FFB_STATE_XCLIP | FFB_STATE_CMP |
+ FFB_STATE_MATCHAB | FFB_STATE_MAGNAB | FFB_STATE_MATCHC |
+ FFB_STATE_MAGNC)) {
+ if (dirty & FFB_STATE_PMASK)
+ ffb->pmask = fmesa->pmask;
+ if (dirty & FFB_STATE_XPMASK)
+ ffb->xpmask = fmesa->xpmask;
+ if (dirty & FFB_STATE_YPMASK)
+ ffb->ypmask = fmesa->ypmask;
+ if (dirty & FFB_STATE_ZPMASK)
+ ffb->zpmask = fmesa->zpmask;
+ if (dirty & FFB_STATE_XCLIP)
+ ffb->xclip = fmesa->xclip;
+ if (dirty & FFB_STATE_CMP)
+ ffb->cmp = fmesa->cmp;
+ if (dirty & FFB_STATE_MATCHAB)
+ ffb->matchab = fmesa->matchab;
+ if (dirty & FFB_STATE_MAGNAB)
+ ffb->magnab = fmesa->magnab;
+ if (dirty & FFB_STATE_MATCHC)
+ ffb->matchc = fmesa->matchc;
+ if (dirty & FFB_STATE_MAGNC)
+ ffb->magnc = fmesa->magnc;
+ }
+
+ if (dirty & FFB_STATE_DCUE) {
+ ffb->dcss = fmesa->dcss;
+ ffb->dcsf = fmesa->dcsf;
+ ffb->dcsb = fmesa->dcsb;
+ ffb->dczf = fmesa->dczf;
+ ffb->dczb = fmesa->dczb;
+ if (fmesa->ffb_sarea->flags & (FFB_DRI_FFB2 | FFB_DRI_FFB2PLUS)) {
+ ffb->dcss1 = fmesa->dcss1;
+ ffb->dcss2 = fmesa->dcss2;
+ ffb->dcss3 = fmesa->dcss3;
+ ffb->dcs2 = fmesa->dcs2;
+ ffb->dcs3 = fmesa->dcs3;
+ ffb->dcs4 = fmesa->dcs4;
+ ffb->dcd2 = fmesa->dcd2;
+ ffb->dcd3 = fmesa->dcd3;
+ ffb->dcd4 = fmesa->dcd4;
+ }
+ }
+
+ if (dirty & FFB_STATE_BLEND) {
+ ffb->blendc = fmesa->blendc;
+ ffb->blendc1 = fmesa->blendc1;
+ ffb->blendc2 = fmesa->blendc2;
+ }
+
+ if (dirty & FFB_STATE_CLIP) {
+ ffb->vclipmin = fmesa->vclipmin;
+ ffb->vclipmax = fmesa->vclipmax;
+ ffb->vclipzmin = fmesa->vclipzmin;
+ ffb->vclipzmax = fmesa->vclipzmax;
+ for (i = 0; i < 4; i++) {
+ ffb->auxclip[i].min = fmesa->aux_clips[i].min;
+ ffb->auxclip[i].max = fmesa->aux_clips[i].max;
+ }
+ }
+
+ if ((dirty & FFB_STATE_STENCIL) &&
+ (fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS)) {
+ ffb->stencil = fmesa->stencil;
+ ffb->stencilctl = fmesa->stencilctl;
+ ffb->fbc = FFB_FBC_WB_C;
+ ffb->rawstencilctl = (fmesa->stencilctl | (1 << 19));
+ ffb->fbc = fmesa->fbc;
+ ffb->consty = fmesa->consty;
+ }
+
+ if (dirty & FFB_STATE_APAT) {
+ for (i = 0; i < 32; i++)
+ ffb->pattern[i] = fmesa->pattern[i];
+ }
+
+ fmesa->state_dirty = 0;
+ fmesa->state_fifo_ents = 0;
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void ffbDDUpdateState(GLcontext *ctx, GLuint newstate)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ /* When we are hw rendering, changing certain kinds of
+ * state does not require flushing all of our context.
+ */
+ if (fmesa->bad_fragment_attrs == 0 &&
+ (newstate & ~_NEW_COLOR) == 0)
+ return;
+
+ _swrast_InvalidateState( ctx, newstate );
+ _swsetup_InvalidateState( ctx, newstate );
+ _ac_InvalidateState( ctx, newstate );
+ _tnl_InvalidateState( ctx, newstate );
+
+ if (newstate & _NEW_TEXTURE)
+ FALLBACK( ctx, FFB_BADATTR_TEXTURE,
+ (ctx->Texture._EnabledUnits != 0));
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "ffbDDUpdateState: newstate(%08x)\n", newstate);
+#endif
+
+ fmesa->new_gl_state |= newstate;
+
+ /* Force a reduced primitive change next rendering
+ * pass.
+ */
+ fmesa->raster_primitive = GL_POLYGON + 1;
+
+#if 0
+ /* When the modelview matrix changes, this changes what
+ * the eye coordinates will be so we have to recompute
+ * the depth cueing parameters.
+ *
+ * XXX DD_HAVE_HARDWARE_FOG.
+ */
+ if (ctx->Fog.Enabled && (newstate & _NEW_MODELVIEW))
+ ffb_update_fog();
+#endif
+}
+
+
+void ffbDDInitStateFuncs(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ ctx->Driver.UpdateState = ffbDDUpdateState;
+
+ ctx->Driver.Enable = ffbDDEnable;
+ ctx->Driver.AlphaFunc = ffbDDAlphaFunc;
+ ctx->Driver.BlendEquationSeparate = ffbDDBlendEquationSeparate;
+ ctx->Driver.BlendFuncSeparate = ffbDDBlendFuncSeparate;
+ ctx->Driver.DepthFunc = ffbDDDepthFunc;
+ ctx->Driver.DepthMask = ffbDDDepthMask;
+ ctx->Driver.Fogfv = ffbDDFogfv;
+ ctx->Driver.LineStipple = ffbDDLineStipple;
+ ctx->Driver.PolygonStipple = ffbDDPolygonStipple;
+ ctx->Driver.Scissor = ffbDDScissor;
+ ctx->Driver.ColorMask = ffbDDColorMask;
+ ctx->Driver.LogicOpcode = ffbDDLogicOp;
+ ctx->Driver.Viewport = ffbDDViewport;
+ ctx->Driver.DepthRange = ffbDDDepthRange;
+
+ if (fmesa->ffb_sarea->flags & FFB_DRI_FFB2PLUS) {
+ ctx->Driver.StencilFunc = ffbDDStencilFunc;
+ ctx->Driver.StencilMask = ffbDDStencilMask;
+ ctx->Driver.StencilOp = ffbDDStencilOp;
+ }
+
+ ctx->Driver.DrawBuffer = ffbDDDrawBuffer;
+ ctx->Driver.ReadBuffer = ffbDDReadBuffer;
+ ctx->Driver.ClearColor = ffbDDClearColor;
+ ctx->Driver.ClearDepth = ffbDDClearDepth;
+ ctx->Driver.ClearStencil = ffbDDClearStencil;
+
+ /* We will support color index modes later... -DaveM */
+ /*
+ ctx->Driver.ClearIndex = 0;
+ ctx->Driver.IndexMask = 0;
+ */
+
+ {
+ struct swrast_device_driver *swdd =
+ _swrast_GetDeviceDriverReference(ctx);
+ swdd->SetBuffer = ffbDDSetBuffer;
+ }
+
+
+}
+
+void ffbDDInitContextHwState(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ int fifo_count = 0;
+ int i;
+
+ fmesa->hw_locked = 0;
+
+ fmesa->bad_fragment_attrs = 0;
+ fmesa->state_dirty = FFB_STATE_ALL;
+ fmesa->new_gl_state = ~0;
+
+ fifo_count = 1;
+ fmesa->fbc = (FFB_FBC_WE_FORCEON | FFB_FBC_WM_COMBINED |
+ FFB_FBC_SB_BOTH | FFB_FBC_ZE_MASK |
+ FFB_FBC_YE_OFF | FFB_FBC_XE_OFF |
+ FFB_FBC_RGBE_MASK);
+ if (ctx->Visual.doubleBufferMode) {
+ /* Buffer B is the initial back buffer. */
+ fmesa->back_buffer = 1;
+ fmesa->fbc |= FFB_FBC_WB_BC | FFB_FBC_RB_B;
+ } else {
+ fmesa->back_buffer = 0;
+ fmesa->fbc |= FFB_FBC_WB_A | FFB_FBC_RB_A;
+ }
+
+ fifo_count += 1;
+ fmesa->ppc = (FFB_PPC_ACE_DISABLE | FFB_PPC_DCE_DISABLE |
+ FFB_PPC_ABE_DISABLE | FFB_PPC_VCE_3D |
+ FFB_PPC_APE_DISABLE | FFB_PPC_TBE_OPAQUE |
+ FFB_PPC_ZS_CONST | FFB_PPC_YS_CONST |
+ FFB_PPC_XS_WID | FFB_PPC_CS_VAR);
+
+ fifo_count += 3;
+ fmesa->drawop = FFB_DRAWOP_RECTANGLE;
+
+ /* GL_COPY is the default LogicOp. */
+ fmesa->rop = (FFB_ROP_NEW << 16) | (FFB_ROP_NEW << 8) | FFB_ROP_NEW;
+
+ /* No line patterning enabled. */
+ fmesa->lpat = 0x00000000;
+
+ /* We do not know the WID value until the first context switch. */
+ fifo_count += 1;
+ fmesa->wid = ~0;
+
+ fifo_count += 5;
+
+ /* ColorMask, all enabled. */
+ fmesa->pmask = 0xffffffff;
+
+ fmesa->xpmask = 0x000000ff;
+ fmesa->ypmask = 0x0000000f;
+ fmesa->zpmask = 0x0fffffff;
+
+ /* AlphaFunc GL_ALWAYS, AlphaRef 0 */
+ fmesa->xclip = FFB_XCLIP_TEST_ALWAYS | 0x00;
+
+ /* This sets us up to use WID clipping (so the DRI clipping
+ * rectangle is unneeded by us). All other match and magnitude
+ * tests are set to pass.
+ */
+ fifo_count += 5;
+ fmesa->cmp = ((FFB_CMP_MATCH_ALWAYS << 24) | /* MATCH C */
+ (FFB_CMP_MAGN_ALWAYS << 16) | /* MAGN C */
+ (FFB_CMP_MATCH_EQ << 8) | /* MATCH AB */
+ (FFB_CMP_MAGN_ALWAYS << 0)); /* MAGN AB */
+ fmesa->matchab = 0xff000000;
+ fmesa->magnab = 0x00000000;
+ fmesa->matchc = 0x00000000;
+ fmesa->magnc = 0x00000000;
+
+ /* Depth cue parameters, all zeros to start. */
+ fifo_count += 14;
+ fmesa->dcss = 0x00000000;
+ fmesa->dcsf = 0x00000000;
+ fmesa->dcsb = 0x00000000;
+ fmesa->dczf = 0x00000000;
+ fmesa->dczb = 0x00000000;
+ fmesa->dcss1 = 0x00000000;
+ fmesa->dcss2 = 0x00000000;
+ fmesa->dcss3 = 0x00000000;
+ fmesa->dcs2 = 0x00000000;
+ fmesa->dcs3 = 0x00000000;
+ fmesa->dcs4 = 0x00000000;
+ fmesa->dcd2 = 0x00000000;
+ fmesa->dcd3 = 0x00000000;
+ fmesa->dcd4 = 0x00000000;
+
+ /* Alpha blending unit state. */
+ fifo_count += 3;
+ fmesa->blendc = (1 << 0) | (0 << 2); /* src(GL_ONE) | dst(GL_ZERO) */
+ fmesa->blendc1 = 0x00000000;
+ fmesa->blendc2 = 0x00000000;
+
+ /* ViewPort clip state. */
+ fifo_count += 4 + (4 * 2);
+ fmesa->vclipmin = 0x00000000;
+ fmesa->vclipmax = 0xffffffff;
+ fmesa->vclipzmin = 0x00000000;
+ fmesa->vclipzmax = 0x0fffffff;
+ for (i = 0; i < 4; i++) {
+ fmesa->aux_clips[0].min = 0x00000000;
+ fmesa->aux_clips[0].max = 0x00000000;
+ }
+
+ /* Stenciling state. */
+ fifo_count += 6;
+ fmesa->stencil = 0xf0000000; /* Stencil MASK, Y plane */
+ fmesa->stencilctl = 0x33300000; /* All stencil tests disabled */
+ fmesa->consty = 0x0;
+
+ /* Area pattern, used for polygon stipples. */
+ fifo_count += 32;
+ for (i = 0; i < 32; i++)
+ fmesa->pattern[i] = 0x00000000;
+
+ fmesa->state_fifo_ents = fifo_count;
+ fmesa->state_all_fifo_ents = fifo_count;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_state.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_state.h
new file mode 100644
index 000000000..17b6fa20a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_state.h
@@ -0,0 +1,13 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_state.h,v 1.2 2002/02/22 21:32:59 dawes Exp $ */
+
+#ifndef _FFB_STATE_H
+#define _FFB_STATE_H
+
+extern void ffbDDInitStateFuncs(GLcontext *);
+extern void ffbDDInitContextHwState(GLcontext *);
+
+extern void ffbCalcViewport(GLcontext *);
+extern void ffbXformAreaPattern(ffbContextPtr, const GLubyte *);
+extern void ffbSyncHardware(ffbContextPtr fmesa);
+
+#endif /* !(_FFB_STATE_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_stencil.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_stencil.c
new file mode 100644
index 000000000..2f13ee921
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_stencil.c
@@ -0,0 +1,226 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_stencil.c,v 1.2 2002/02/22 21:32:59 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "mtypes.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_context.h"
+#include "ffb_stencil.h"
+#include "ffb_lock.h"
+
+#include "swrast/swrast.h"
+
+#undef STENCIL_TRACE
+
+static void FFBWriteStencilSpan( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *values, const GLubyte mask[] )
+{
+ const GLubyte *stencil = (const GLubyte *) values;
+#ifdef STENCIL_TRACE
+ fprintf(stderr, "FFBWriteStencilSpan: n(%d) x(%d) y(%d)\n",
+ (int) n, x, y);
+#endif
+ if (ctx->Depth.Mask) {
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ GLuint *zptr;
+ GLuint i;
+
+ if (!fmesa->hw_locked)
+ LOCK_HARDWARE(fmesa);
+ FFBFifo(fmesa, 2);
+ fmesa->regs->fbc = (FFB_FBC_WB_C | FFB_FBC_ZE_OFF |
+ FFB_FBC_YE_ON | FFB_FBC_RGBE_OFF);
+ fmesa->regs->ppc = FFB_PPC_YS_VAR;
+ FFBWait(fmesa, fmesa->regs);
+
+ y = (dPriv->h - y);
+ zptr = (GLuint *)
+ ((char *)fmesa->sfb32 +
+ ((dPriv->x + x) << 2) +
+ ((dPriv->y + y) << 13));
+
+ for (i = 0; i < n; i++) {
+ if (mask[i])
+ *zptr = (stencil[i] & 0xf) << 28;
+ zptr++;
+ }
+
+ FFBFifo(fmesa, 2);
+ fmesa->regs->fbc = fmesa->fbc;
+ fmesa->regs->ppc = fmesa->ppc;
+ fmesa->ffbScreen->rp_active = 1;
+ if (!fmesa->hw_locked)
+ UNLOCK_HARDWARE(fmesa);
+ }
+}
+
+static void FFBWriteStencilPixels( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n,
+ const GLint x[], const GLint y[],
+ const void *values, const GLubyte mask[] )
+{
+ const GLubyte *stencil = (const GLubyte *) values;
+#ifdef STENCIL_TRACE
+ fprintf(stderr, "FFBWriteStencilPixels: n(%d)\n", (int) n);
+#endif
+ if (ctx->Depth.Mask) {
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ char *zbase;
+ GLuint i;
+
+ if (!fmesa->hw_locked)
+ LOCK_HARDWARE(fmesa);
+ FFBFifo(fmesa, 2);
+ fmesa->regs->fbc = (FFB_FBC_WB_C | FFB_FBC_ZE_OFF |
+ FFB_FBC_YE_ON | FFB_FBC_RGBE_OFF);
+ fmesa->regs->ppc = FFB_PPC_YS_VAR;
+ fmesa->ffbScreen->rp_active = 1;
+ FFBWait(fmesa, fmesa->regs);
+
+ zbase = ((char *)fmesa->sfb32 +
+ (dPriv->x << 2) + (dPriv->y << 13));
+
+ for (i = 0; i < n; i++) {
+ GLint y1 = (dPriv->h - y[i]);
+ GLint x1 = x[i];
+ GLuint *zptr;
+
+ zptr = (GLuint *)
+ (zbase + (x1 << 2) + (y1 << 13));
+ if (mask[i])
+ *zptr = (stencil[i] & 0xf) << 28;
+ }
+
+ FFBFifo(fmesa, 2);
+ fmesa->regs->fbc = fmesa->fbc;
+ fmesa->regs->ppc = fmesa->ppc;
+ fmesa->ffbScreen->rp_active = 1;
+ if (!fmesa->hw_locked)
+ UNLOCK_HARDWARE(fmesa);
+ }
+}
+
+static void FFBReadStencilSpan( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ void *values)
+{
+ GLubyte *stencil = (GLubyte *) values;
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ GLuint *zptr;
+ GLuint i;
+
+#ifdef STENCIL_TRACE
+ fprintf(stderr, "FFBReadStencilSpan: n(%d) x(%d) y(%d)\n",
+ (int) n, x, y);
+#endif
+ if (!fmesa->hw_locked)
+ LOCK_HARDWARE(fmesa);
+ FFBFifo(fmesa, 1);
+ fmesa->regs->fbc = FFB_FBC_RB_C;
+ fmesa->ffbScreen->rp_active = 1;
+ FFBWait(fmesa, fmesa->regs);
+
+ y = (dPriv->h - y);
+ zptr = (GLuint *)
+ ((char *)fmesa->sfb32 +
+ ((dPriv->x + x) << 2) +
+ ((dPriv->y + y) << 13));
+
+ for (i = 0; i < n; i++) {
+ stencil[i] = (*zptr >> 28) & 0xf;
+ zptr++;
+ }
+
+ FFBFifo(fmesa, 1);
+ fmesa->regs->fbc = fmesa->fbc;
+ fmesa->ffbScreen->rp_active = 1;
+ if (!fmesa->hw_locked)
+ UNLOCK_HARDWARE(fmesa);
+}
+
+static void FFBReadStencilPixels( GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ void *values )
+{
+ GLubyte *stencil = (GLubyte *) values;
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ char *zbase;
+ GLuint i;
+
+#ifdef STENCIL_TRACE
+ fprintf(stderr, "FFBReadStencilPixels: n(%d)\n", (int) n);
+#endif
+ if (!fmesa->hw_locked)
+ LOCK_HARDWARE(fmesa);
+ FFBFifo(fmesa, 1);
+ fmesa->regs->fbc = FFB_FBC_RB_C;
+ fmesa->ffbScreen->rp_active = 1;
+ FFBWait(fmesa, fmesa->regs);
+
+ zbase = ((char *)fmesa->sfb32 +
+ (dPriv->x << 2) + (dPriv->y << 13));
+
+ for (i = 0; i < n; i++) {
+ GLint y1 = (dPriv->h - y[i]);
+ GLint x1 = x[i];
+ GLuint *zptr;
+
+ zptr = (GLuint *)
+ (zbase + (x1 << 2) + (y1 << 13));
+ stencil[i] = (*zptr >> 28) & 0xf;
+ }
+
+ FFBFifo(fmesa, 1);
+ fmesa->regs->fbc = fmesa->fbc;
+ fmesa->ffbScreen->rp_active = 1;
+ if (!fmesa->hw_locked)
+ UNLOCK_HARDWARE(fmesa);
+}
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+ffbSetStencilFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ assert(drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT);
+ drb->Base.GetRow = FFBReadStencilSpan;
+ drb->Base.GetValues = FFBReadStencilPixels;
+ drb->Base.PutRow = FFBWriteStencilSpan;
+ /*drb->Base.PutMonoRow = FFBWriteMonoStencilSpan;*/
+ drb->Base.PutValues = FFBWriteStencilPixels;
+ drb->Base.PutMonoValues = NULL;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_stencil.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_stencil.h
new file mode 100644
index 000000000..c7da1ca68
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_stencil.h
@@ -0,0 +1,8 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_stencil.h,v 1.1 2000/06/20 05:08:39 dawes Exp $ */
+
+#ifndef _FFB_STENCIL_H
+#define _FFB_STENCIL_H
+
+void ffbSetStencilFunctions(driRenderbuffer *drb, const GLvisual *vis);
+
+#endif /* !(_FFB_STENCIL_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tex.c
new file mode 100644
index 000000000..d6763b7cd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tex.c
@@ -0,0 +1,53 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_tex.c,v 1.1 2002/02/22 21:32:59 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2001 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "ffb_tex.h"
+
+/* No texture unit, all software. */
+/* XXX this function isn't needed since _mesa_init_driver_functions()
+ * will make all these assignments.
+ */
+void ffbDDInitTexFuncs(GLcontext *ctx)
+{
+ /*
+ ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
+ ctx->Driver.TexImage1D = _mesa_store_teximage1d;
+ ctx->Driver.TexImage2D = _mesa_store_teximage2d;
+ ctx->Driver.TexImage3D = _mesa_store_teximage3d;
+ ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
+ ctx->Driver.TexSubImage2D = _mesa_store_texsubimage2d;
+ ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
+ ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
+ ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
+ ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
+ ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
+ ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
+ ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
+ */
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tex.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tex.h
new file mode 100644
index 000000000..dba0e08af
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tex.h
@@ -0,0 +1,34 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_tex.h,v 1.1 2002/02/22 21:32:59 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D.
+ * Copyright (C) 2001 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#ifndef _FFB_TEX_H
+#define _FFB_TEX_H
+
+extern void ffbDDInitTexFuncs(GLcontext *ctx);
+
+#endif /* !(_FFB_DD_H) */
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tris.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tris.c
new file mode 100644
index 000000000..ca0e514dc
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tris.c
@@ -0,0 +1,945 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_tris.c,v 1.3 2002/10/30 12:51:28 alanh Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000, 2001 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "swrast/s_context.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
+#include "ffb_context.h"
+#include "ffb_tris.h"
+#include "ffb_lines.h"
+#include "ffb_lock.h"
+#include "ffb_points.h"
+#include "ffb_state.h"
+#include "ffb_vb.h"
+
+#undef TRI_DEBUG
+#undef FFB_RENDER_TRACE
+#undef STATE_TRACE
+
+#ifdef TRI_DEBUG
+static void ffb_print_vertex(const ffb_vertex *v)
+{
+ fprintf(stderr, "Vertex @(%p): "
+ "X[%f] Y[%f] Z[%f]\n",
+ v, v->x, v->y, v->z);
+ fprintf(stderr, "Vertex @(%p): "
+ "A[%f] R[%f] G[%f] B[%f]\n",
+ v,
+ v->color[0].alpha,
+ v->color[0].red,
+ v->color[0].green,
+ v->color[0].blue);
+}
+#define FFB_DUMP_VERTEX(V) ffb_print_vertex(V)
+#else
+#define FFB_DUMP_VERTEX(V) do { } while(0)
+#endif
+
+#define FFB_ALPHA_BIT 0x01
+#define FFB_FLAT_BIT 0x02
+#define FFB_TRI_CULL_BIT 0x04
+#define MAX_FFB_RENDER_FUNCS 0x08
+
+/***********************************************************************
+ * Build low-level triangle/quad rasterize functions *
+ ***********************************************************************/
+
+#define FFB_TRI_FLAT_BIT 0x01
+#define FFB_TRI_ALPHA_BIT 0x02
+/*#define FFB_TRI_CULL_BIT 0x04*/
+
+static ffb_tri_func ffb_tri_tab[0x8];
+static ffb_quad_func ffb_quad_tab[0x8];
+
+#define IND (0)
+#define TAG(x) x
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_CULL_BIT)
+#define TAG(x) x##_cull
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_CULL_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_cull_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT)
+#define TAG(x) x##_alpha
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_alpha_flat
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT)
+#define TAG(x) x##_alpha_cull
+#include "ffb_tritmp.h"
+
+#define IND (FFB_TRI_ALPHA_BIT|FFB_TRI_CULL_BIT|FFB_TRI_FLAT_BIT)
+#define TAG(x) x##_alpha_cull_flat
+#include "ffb_tritmp.h"
+
+static void init_tri_tab(void)
+{
+ ffb_init();
+ ffb_init_flat();
+ ffb_init_cull();
+ ffb_init_cull_flat();
+ ffb_init_alpha();
+ ffb_init_alpha_flat();
+ ffb_init_alpha_cull();
+ ffb_init_alpha_cull_flat();
+}
+
+/* Build a SWvertex from a hardware vertex. */
+static void ffb_translate_vertex(GLcontext *ctx, const ffb_vertex *src,
+ SWvertex *dst)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLfloat *m = ctx->Viewport._WindowMap.m;
+ const GLfloat sx = m[0];
+ const GLfloat sy = m[5];
+ const GLfloat sz = m[10];
+ const GLfloat tx = m[12];
+ const GLfloat ty = m[13];
+ const GLfloat tz = m[14];
+
+ dst->win[0] = sx * src->x + tx;
+ dst->win[1] = sy * src->y + ty;
+ dst->win[2] = sz * src->z + tz;
+ dst->win[3] = 1.0;
+
+ dst->color[0] = FFB_UBYTE_FROM_COLOR(src->color[0].red);
+ dst->color[1] = FFB_UBYTE_FROM_COLOR(src->color[0].green);
+ dst->color[2] = FFB_UBYTE_FROM_COLOR(src->color[0].blue);
+ dst->color[3] = FFB_UBYTE_FROM_COLOR(src->color[0].alpha);
+}
+
+/***********************************************************************
+ * Build fallback triangle/quad rasterize functions *
+ ***********************************************************************/
+
+static void ffb_fallback_triangle(GLcontext *ctx, ffb_vertex *v0,
+ ffb_vertex *v1, ffb_vertex *v2)
+{
+ SWvertex v[3];
+
+ ffb_translate_vertex(ctx, v0, &v[0]);
+ ffb_translate_vertex(ctx, v1, &v[1]);
+ ffb_translate_vertex(ctx, v2, &v[2]);
+
+ _swrast_Triangle(ctx, &v[0], &v[1], &v[2]);
+}
+
+static void ffb_fallback_quad(GLcontext *ctx,
+ ffb_vertex *v0, ffb_vertex *v1,
+ ffb_vertex *v2, ffb_vertex *v3)
+{
+ SWvertex v[4];
+
+ ffb_translate_vertex(ctx, v0, &v[0]);
+ ffb_translate_vertex(ctx, v1, &v[1]);
+ ffb_translate_vertex(ctx, v2, &v[2]);
+ ffb_translate_vertex(ctx, v3, &v[3]);
+
+ _swrast_Quad(ctx, &v[0], &v[1], &v[2], &v[3]);
+}
+
+void ffb_fallback_line(GLcontext *ctx, ffb_vertex *v0, ffb_vertex *v1)
+{
+ SWvertex v[2];
+
+ ffb_translate_vertex(ctx, v0, &v[0]);
+ ffb_translate_vertex(ctx, v1, &v[1]);
+
+ _swrast_Line(ctx, &v[0], &v[1]);
+}
+
+void ffb_fallback_point(GLcontext *ctx, ffb_vertex *v0)
+{
+ SWvertex v[1];
+
+ ffb_translate_vertex(ctx, v0, &v[0]);
+
+ _swrast_Point(ctx, &v[0]);
+}
+
+/***********************************************************************
+ * Rasterization functions for culled tris/quads *
+ ***********************************************************************/
+
+static void ffb_nodraw_triangle(GLcontext *ctx, ffb_vertex *v0,
+ ffb_vertex *v1, ffb_vertex *v2)
+{
+ (void) (ctx && v0 && v1 && v2);
+}
+
+static void ffb_nodraw_quad(GLcontext *ctx,
+ ffb_vertex *v0, ffb_vertex *v1,
+ ffb_vertex *v2, ffb_vertex *v3)
+{
+ (void) (ctx && v0 && v1 && v2 && v3);
+}
+
+static void ffb_update_cullsign(GLcontext *ctx)
+{
+ GLfloat backface_sign = 1;
+
+ switch (ctx->Polygon.CullFaceMode) {
+ case GL_BACK:
+ if (ctx->Polygon.FrontFace==GL_CCW)
+ backface_sign = -1;
+ break;
+
+ case GL_FRONT:
+ if (ctx->Polygon.FrontFace!=GL_CCW)
+ backface_sign = -1;
+ break;
+
+ default:
+ break;
+ };
+
+ FFB_CONTEXT(ctx)->backface_sign = backface_sign;
+}
+
+/***********************************************************************
+ * Choose triangle/quad rasterize functions *
+ ***********************************************************************/
+
+void ffbChooseTriangleState(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint ind = 0;
+
+ if (flags & DD_TRI_SMOOTH) {
+ fmesa->draw_tri = ffb_fallback_triangle;
+ fmesa->draw_quad = ffb_fallback_quad;
+ return;
+ }
+
+ if (flags & DD_FLATSHADE)
+ ind |= FFB_TRI_FLAT_BIT;
+
+ if (ctx->Polygon.CullFlag) {
+ if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) {
+ fmesa->draw_tri = ffb_nodraw_triangle;
+ fmesa->draw_quad = ffb_nodraw_quad;
+ return;
+ }
+
+ ind |= FFB_TRI_CULL_BIT;
+ ffb_update_cullsign(ctx);
+ } else
+ FFB_CONTEXT(ctx)->backface_sign = 0;
+
+ /* If blending or the alpha test is enabled we need to
+ * provide alpha components to the chip, else we can
+ * do without it and thus feed vertex data to the chip
+ * more efficiently.
+ */
+ if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled)
+ ind |= FFB_TRI_ALPHA_BIT;
+
+ fmesa->draw_tri = ffb_tri_tab[ind];
+ fmesa->draw_quad = ffb_quad_tab[ind];
+}
+
+static const GLenum reduced_prim[GL_POLYGON+1] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES
+};
+
+static void ffbRenderPrimitive(GLcontext *ctx, GLenum prim);
+static void ffbRasterPrimitive(GLcontext *ctx, GLenum rprim);
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define FFB_OFFSET_BIT 0x01
+#define FFB_TWOSIDE_BIT 0x02
+#define FFB_UNFILLED_BIT 0x04
+#define FFB_MAX_TRIFUNC 0x08
+
+static struct {
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
+} rast_tab[FFB_MAX_TRIFUNC];
+
+#define DO_OFFSET (IND & FFB_OFFSET_BIT)
+#define DO_UNFILLED (IND & FFB_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & FFB_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_QUAD 1
+#define DO_FULL_QUAD 1
+#define DO_TRI 1
+#define DO_LINE 0
+#define DO_POINTS 0
+
+#define QUAD( a, b, c, d ) fmesa->draw_quad( ctx, a, b, c, d )
+#define TRI( a, b, c ) fmesa->draw_tri( ctx, a, b, c )
+#define LINE( a, b ) fmesa->draw_line( ctx, a, b )
+#define POINT( a ) fmesa->draw_point( ctx, a )
+
+#define HAVE_BACK_COLORS 1
+#define HAVE_RGBA 1
+#define HAVE_SPEC 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX ffb_vertex
+#define TAB rast_tab
+
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define DEPTH_SCALE (fmesa->depth_scale)
+#define VERT_X(_v) (_v->x)
+#define VERT_Y(_v) (_v->y)
+#define VERT_Z(_v) (_v->z)
+#define AREA_IS_CCW( a ) (a < fmesa->ffb_zero)
+#define GET_VERTEX(e) (&fmesa->verts[e])
+#define INSANE_VERTICES
+#define VERT_SET_Z(v,val) ((v)->z = (val))
+#define VERT_Z_ADD(v,val) ((v)->z += (val))
+
+#define VERT_COPY_RGBA1( _v ) _v->color[0] = _v->color[1]
+#define VERT_COPY_RGBA( v0, v1 ) v0->color[0] = v1->color[0]
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->color[0]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->color[0] = color[idx]
+
+#define LOCAL_VARS(n) \
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable; \
+ ffb_color color[n]; \
+ (void) color; (void) dPriv;
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+#define RASTERIZE(x) if (fmesa->raster_primitive != reduced_prim[x]) \
+ ffbRasterPrimitive( ctx, reduced_prim[x] )
+#define RENDER_PRIMITIVE fmesa->render_primitive
+#define TAG(x) x
+#include "tnl_dd/t_dd_unfilled.h"
+
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FFB_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FFB_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FFB_TWOSIDE_BIT|FFB_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FFB_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FFB_OFFSET_BIT|FFB_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FFB_TWOSIDE_BIT|FFB_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FFB_TWOSIDE_BIT|FFB_OFFSET_BIT|FFB_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+static void init_rast_tab( void )
+{
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+}
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+static void ffbRenderClippedPolygon(GLcontext *ctx, const GLuint *elts, GLuint n)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint prim = fmesa->render_primitive;
+
+ /* Render the new vertices as an unclipped polygon. */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON](ctx, 0, n, PRIM_BEGIN|PRIM_END);
+ VB->Elts = tmp;
+ }
+
+ /* Restore the render primitive. */
+ if (prim != GL_POLYGON)
+ tnl->Driver.Render.PrimitiveNotify(ctx, prim);
+}
+
+static void ffbRenderClippedLine(GLcontext *ctx, GLuint ii, GLuint jj)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Line(ctx, ii, jj);
+}
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+static void ffb_vb_noop(GLcontext *ctx, GLuint start, GLuint count, GLuint flags)
+{
+ (void)(ctx && start && count && flags);
+}
+
+#define ELT(x) x
+
+#define IND 0
+#define TAG(x) x
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_FLAT_BIT)
+#define TAG(x) x##_flat
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_ALPHA_BIT)
+#define TAG(x) x##_alpha
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_FLAT_BIT | FFB_ALPHA_BIT)
+#define TAG(x) x##_flat_alpha
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_TRI_CULL_BIT)
+#define TAG(x) x##_tricull
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_FLAT_BIT | FFB_TRI_CULL_BIT)
+#define TAG(x) x##_flat_tricull
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_ALPHA_BIT | FFB_TRI_CULL_BIT)
+#define TAG(x) x##_alpha_tricull
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_FLAT_BIT | FFB_ALPHA_BIT | FFB_TRI_CULL_BIT)
+#define TAG(x) x##_flat_alpha_tricull
+#include "ffb_rendertmp.h"
+
+#undef ELT
+#define ELT(x) elt[x]
+
+#define IND 0
+#define TAG(x) x##_elt
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_FLAT_BIT)
+#define TAG(x) x##_flat_elt
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_ALPHA_BIT)
+#define TAG(x) x##_alpha_elt
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_FLAT_BIT | FFB_ALPHA_BIT)
+#define TAG(x) x##_flat_alpha_elt
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_TRI_CULL_BIT)
+#define TAG(x) x##_tricull_elt
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_FLAT_BIT | FFB_TRI_CULL_BIT)
+#define TAG(x) x##_flat_tricull_elt
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_ALPHA_BIT | FFB_TRI_CULL_BIT)
+#define TAG(x) x##_alpha_tricull_elt
+#include "ffb_rendertmp.h"
+
+#define IND (FFB_FLAT_BIT | FFB_ALPHA_BIT | FFB_TRI_CULL_BIT)
+#define TAG(x) x##_flat_alpha_tricull_elt
+#include "ffb_rendertmp.h"
+
+static void *render_tabs[MAX_FFB_RENDER_FUNCS];
+static void *render_tabs_elt[MAX_FFB_RENDER_FUNCS];
+
+static void init_render_tab(void)
+{
+ int i;
+
+ render_tabs[0] = render_tab;
+ render_tabs[FFB_FLAT_BIT] = render_tab_flat;
+ render_tabs[FFB_ALPHA_BIT] = render_tab_alpha;
+ render_tabs[FFB_FLAT_BIT|FFB_ALPHA_BIT] = render_tab_flat_alpha;
+ render_tabs[FFB_TRI_CULL_BIT] = render_tab_tricull;
+ render_tabs[FFB_FLAT_BIT|FFB_TRI_CULL_BIT] = render_tab_flat_tricull;
+ render_tabs[FFB_ALPHA_BIT|FFB_TRI_CULL_BIT] = render_tab_alpha_tricull;
+ render_tabs[FFB_FLAT_BIT|FFB_ALPHA_BIT|FFB_TRI_CULL_BIT] =
+ render_tab_flat_alpha_tricull;
+
+ render_tabs_elt[0] = render_tab_elt;
+ render_tabs_elt[FFB_FLAT_BIT] = render_tab_flat_elt;
+ render_tabs_elt[FFB_ALPHA_BIT] = render_tab_alpha_elt;
+ render_tabs_elt[FFB_FLAT_BIT|FFB_ALPHA_BIT] = render_tab_flat_alpha_elt;
+ render_tabs_elt[FFB_TRI_CULL_BIT] = render_tab_tricull_elt;
+ render_tabs_elt[FFB_FLAT_BIT|FFB_TRI_CULL_BIT] = render_tab_flat_tricull_elt;
+ render_tabs_elt[FFB_ALPHA_BIT|FFB_TRI_CULL_BIT] = render_tab_alpha_tricull_elt;
+ render_tabs_elt[FFB_FLAT_BIT|FFB_ALPHA_BIT|FFB_TRI_CULL_BIT] =
+ render_tab_flat_alpha_tricull_elt;
+
+ for (i = 0; i < MAX_FFB_RENDER_FUNCS; i++) {
+ tnl_render_func *rf = render_tabs[i];
+ tnl_render_func *rfe = render_tabs_elt[i];
+
+ if (i & FFB_TRI_CULL_BIT) {
+ int from_idx = (i & ~FFB_TRI_CULL_BIT);
+ tnl_render_func *rf_from = render_tabs[from_idx];
+ tnl_render_func *rfe_from = render_tabs_elt[from_idx];
+ int j;
+
+ for (j = GL_POINTS; j < GL_TRIANGLES; j++) {
+ rf[j] = rf_from[j];
+ rfe[j] = rfe_from[j];
+ }
+ }
+ }
+}
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+#ifdef FFB_RENDER_TRACE
+static void ffbPrintRenderFlags(GLuint index, GLuint render_index)
+{
+ fprintf(stderr,
+ "ffbChooseRenderState: "
+ "index(%s%s%s) "
+ "render_index(%s%s%s)\n",
+ ((index & FFB_TWOSIDE_BIT) ? "twoside " : ""),
+ ((index & FFB_OFFSET_BIT) ? "offset " : ""),
+ ((index & FFB_UNFILLED_BIT) ? "unfilled " : ""),
+ ((render_index & FFB_FLAT_BIT) ? "flat " : ""),
+ ((render_index & FFB_ALPHA_BIT) ? "alpha " : ""),
+ ((render_index & FFB_TRI_CULL_BIT) ? "tricull " : ""));
+}
+#endif
+
+void ffbChooseRenderState(GLcontext *ctx)
+{
+ GLuint flags = ctx->_TriangleCaps;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint index = 0;
+
+ /* Per-primitive fallbacks and the selection of fmesa->draw_* are
+ * handled elsewhere.
+ */
+ if (flags & DD_TRI_LIGHT_TWOSIDE)
+ index |= FFB_TWOSIDE_BIT;
+
+ if (flags & DD_TRI_OFFSET)
+ index |= FFB_OFFSET_BIT;
+
+ if (flags & DD_TRI_UNFILLED)
+ index |= FFB_UNFILLED_BIT;
+
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ GLuint render_index = 0;
+
+ if (flags & DD_FLATSHADE)
+ render_index |= FFB_FLAT_BIT;
+
+ if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled)
+ render_index |= FFB_ALPHA_BIT;
+
+ if (ctx->Polygon.CullFlag)
+ render_index |= FFB_TRI_CULL_BIT;
+
+#ifdef FFB_RENDER_TRACE
+ ffbPrintRenderFlags(index, render_index);
+#endif
+ tnl->Driver.Render.PrimTabVerts = render_tabs[render_index];
+ tnl->Driver.Render.PrimTabElts = render_tabs_elt[render_index];
+ } else {
+#ifdef FFB_RENDER_TRACE
+ ffbPrintRenderFlags(index, 0);
+#endif
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ }
+
+ tnl->Driver.Render.ClippedPolygon = ffbRenderClippedPolygon;
+ tnl->Driver.Render.ClippedLine = ffbRenderClippedLine;
+}
+
+static void ffbRunPipeline(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ if (fmesa->bad_fragment_attrs == 0 &&
+ fmesa->new_gl_state) {
+ if (fmesa->new_gl_state & _FFB_NEW_TRIANGLE)
+ ffbChooseTriangleState(ctx);
+ if (fmesa->new_gl_state & _FFB_NEW_LINE)
+ ffbChooseLineState(ctx);
+ if (fmesa->new_gl_state & _FFB_NEW_POINT)
+ ffbChoosePointState(ctx);
+ if (fmesa->new_gl_state & _FFB_NEW_RENDER)
+ ffbChooseRenderState(ctx);
+ if (fmesa->new_gl_state & _FFB_NEW_VERTEX)
+ ffbChooseVertexState(ctx);
+
+ fmesa->new_gl_state = 0;
+ }
+
+ _tnl_run_pipeline(ctx);
+}
+
+static void ffbRenderStart(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ LOCK_HARDWARE(fmesa);
+ fmesa->hw_locked = 1;
+
+ if (fmesa->state_dirty != 0)
+ ffbSyncHardware(fmesa);
+}
+
+static void ffbRenderFinish(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ UNLOCK_HARDWARE(fmesa);
+ fmesa->hw_locked = 0;
+}
+
+/* Even when doing full software rendering we need to
+ * wrap render{start,finish} so that the hardware is kept
+ * in sync (because multipass rendering changes the write
+ * buffer etc.)
+ */
+static void ffbSWRenderStart(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ LOCK_HARDWARE(fmesa);
+ fmesa->hw_locked = 1;
+
+ if (fmesa->state_dirty != 0)
+ ffbSyncHardware(fmesa);
+}
+
+static void ffbSWRenderFinish(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ UNLOCK_HARDWARE(fmesa);
+ fmesa->hw_locked = 0;
+}
+
+static void ffbRasterPrimitive(GLcontext *ctx, GLenum rprim)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLuint drawop, fbc, ppc;
+ int do_sw = 0;
+
+ fmesa->raster_primitive = rprim;
+
+ drawop = fmesa->drawop;
+ fbc = fmesa->fbc;
+ ppc = fmesa->ppc & ~(FFB_PPC_ZS_MASK | FFB_PPC_CS_MASK);
+
+#ifdef STATE_TRACE
+ fprintf(stderr,
+ "ffbReducedPrimitiveChange: rprim(%d) ", rprim);
+#endif
+ switch(rprim) {
+ case GL_POINTS:
+#ifdef STATE_TRACE
+ fprintf(stderr, "GL_POINTS ");
+#endif
+ if (fmesa->draw_point == ffb_fallback_point) {
+ do_sw = 1;
+ break;
+ }
+
+ if (ctx->Point.SmoothFlag) {
+ ppc |= (FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST);
+ drawop = FFB_DRAWOP_AADOT;
+ } else {
+ ppc |= (FFB_PPC_ZS_CONST | FFB_PPC_CS_CONST);
+ drawop = FFB_DRAWOP_DOT;
+ }
+ break;
+
+ case GL_LINES:
+#ifdef STATE_TRACE
+ fprintf(stderr, "GL_LINES ");
+#endif
+ if (fmesa->draw_line == ffb_fallback_line) {
+ do_sw = 1;
+ break;
+ }
+
+ if (ctx->_TriangleCaps & DD_FLATSHADE) {
+ ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST;
+ } else {
+ ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR;
+ }
+ if (ctx->Line.SmoothFlag)
+ drawop = FFB_DRAWOP_AALINE;
+ else
+ drawop = FFB_DRAWOP_DDLINE;
+ break;
+
+ case GL_TRIANGLES:
+#ifdef STATE_TRACE
+ fprintf(stderr, "GL_POLYGON ");
+#endif
+ if (fmesa->draw_tri == ffb_fallback_triangle) {
+ do_sw = 1;
+ break;
+ }
+
+ ppc &= ~FFB_PPC_APE_MASK;
+ if (ctx->Polygon.StippleFlag)
+ ppc |= FFB_PPC_APE_ENABLE;
+ else
+ ppc |= FFB_PPC_APE_DISABLE;
+
+ if (ctx->_TriangleCaps & DD_FLATSHADE) {
+ ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_CONST;
+ } else {
+ ppc |= FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR;
+ }
+ drawop = FFB_DRAWOP_TRIANGLE;
+ break;
+
+ default:
+#ifdef STATE_TRACE
+ fprintf(stderr, "unknown %d!\n", rprim);
+#endif
+ return;
+ };
+
+#ifdef STATE_TRACE
+ fprintf(stderr, "do_sw(%d) ", do_sw);
+#endif
+ if (do_sw != 0) {
+ fbc &= ~(FFB_FBC_WB_C);
+ fbc &= ~(FFB_FBC_ZE_MASK | FFB_FBC_RGBE_MASK);
+ fbc |= FFB_FBC_ZE_OFF | FFB_FBC_RGBE_MASK;
+ ppc &= ~(FFB_PPC_XS_MASK | FFB_PPC_ABE_MASK |
+ FFB_PPC_DCE_MASK | FFB_PPC_APE_MASK);
+ ppc |= (FFB_PPC_ZS_VAR | FFB_PPC_CS_VAR | FFB_PPC_XS_WID |
+ FFB_PPC_ABE_DISABLE | FFB_PPC_DCE_DISABLE |
+ FFB_PPC_APE_DISABLE);
+ } else {
+ fbc |= FFB_FBC_WB_C;
+ fbc &= ~(FFB_FBC_RGBE_MASK);
+ fbc |= FFB_FBC_RGBE_MASK;
+ ppc &= ~(FFB_PPC_ABE_MASK | FFB_PPC_XS_MASK);
+ if (ctx->Color.BlendEnabled) {
+ if ((rprim == GL_POINTS && !ctx->Point.SmoothFlag) ||
+ (rprim != GL_POINTS && ctx->_TriangleCaps & DD_FLATSHADE))
+ ppc |= FFB_PPC_ABE_ENABLE | FFB_PPC_XS_CONST;
+ else
+ ppc |= FFB_PPC_ABE_ENABLE | FFB_PPC_XS_VAR;
+ } else {
+ ppc |= FFB_PPC_ABE_DISABLE | FFB_PPC_XS_WID;
+ }
+ }
+#ifdef STATE_TRACE
+ fprintf(stderr, "fbc(%08x) ppc(%08x)\n", fbc, ppc);
+#endif
+
+ FFBFifo(fmesa, 4);
+ if (fmesa->drawop != drawop)
+ fmesa->regs->drawop = fmesa->drawop = drawop;
+ if (fmesa->fbc != fbc)
+ fmesa->regs->fbc = fmesa->fbc = fbc;
+ if (fmesa->ppc != ppc)
+ fmesa->regs->ppc = fmesa->ppc = ppc;
+ if (do_sw != 0) {
+ fmesa->regs->cmp =
+ (fmesa->cmp & ~(0xff<<16)) | (0x80 << 16);
+ } else
+ fmesa->regs->cmp = fmesa->cmp;
+}
+
+static void ffbRenderPrimitive(GLcontext *ctx, GLenum prim)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLuint rprim = reduced_prim[prim];
+
+ fmesa->render_primitive = prim;
+
+ if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ return;
+
+ if (fmesa->raster_primitive != rprim) {
+ ffbRasterPrimitive( ctx, rprim );
+ }
+}
+
+
+
+
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+
+static char *fallbackStrings[] = {
+ "Fog enabled",
+ "Blend function",
+ "Blend ROP",
+ "Blend equation",
+ "Stencil",
+ "Texture",
+ "LIBGL_SOFTWARE_RENDERING"
+};
+
+static char *getFallbackString(GLuint bit)
+{
+ int i = 0;
+
+ while (bit > 1) {
+ i++;
+ bit >>= 1;
+ }
+ return fallbackStrings[i];
+}
+
+void ffbFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldfallback = fmesa->bad_fragment_attrs;
+
+ if (mode) {
+ fmesa->bad_fragment_attrs |= bit;
+ if (oldfallback == 0) {
+/* FFB_FIREVERTICES(fmesa); */
+ _swsetup_Wakeup( ctx );
+ if (fmesa->debugFallbacks)
+ fprintf(stderr, "FFB begin software fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ } else {
+ fmesa->bad_fragment_attrs &= ~bit;
+ if (oldfallback == bit) {
+ _swrast_flush( ctx );
+
+ tnl->Driver.Render.Start = ffbRenderStart;
+ tnl->Driver.Render.PrimitiveNotify = ffbRenderPrimitive;
+ tnl->Driver.Render.Finish = ffbRenderFinish;
+ fmesa->new_gl_state = ~0;
+
+ /* Just re-choose everything:
+ */
+ ffbChooseVertexState(ctx);
+ ffbChooseRenderState(ctx);
+ ffbChooseTriangleState(ctx);
+ ffbChooseLineState(ctx);
+ ffbChoosePointState(ctx);
+
+ if (fmesa->debugFallbacks)
+ fprintf(stderr, "FFB end software fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ }
+}
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+void ffbDDInitRenderFuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ init_tri_tab();
+ init_render_tab();
+ firsttime = 0;
+ }
+
+ tnl->Driver.RunPipeline = ffbRunPipeline;
+ tnl->Driver.Render.Start = ffbRenderStart;
+ tnl->Driver.Render.Finish = ffbRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = ffbRenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+
+ swrast->Driver.SpanRenderStart = ffbSWRenderStart;
+ swrast->Driver.SpanRenderFinish = ffbSWRenderFinish;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tris.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tris.h
new file mode 100644
index 000000000..a803174b3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tris.h
@@ -0,0 +1,26 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_tris.h,v 1.2 2002/02/22 21:32:59 dawes Exp $ */
+
+#ifndef _FFB_TRIS_H
+#define _FFB_TRIS_H
+
+extern void ffbDDInitRenderFuncs( GLcontext *ctx );
+
+
+#define _FFB_NEW_RENDER (_DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET | \
+ _DD_NEW_TRI_UNFILLED)
+
+extern void ffbChooseRenderState(GLcontext *ctx);
+
+
+#define _FFB_NEW_TRIANGLE (_DD_NEW_TRI_SMOOTH | \
+ _DD_NEW_FLATSHADE | \
+ _NEW_POLYGON | \
+ _NEW_COLOR)
+
+extern void ffbChooseTriangleState(GLcontext *ctx);
+
+extern void ffbFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
+#define FALLBACK( ctx, bit, mode ) ffbFallback( ctx, bit, mode )
+
+#endif /* !(_FFB_TRIS_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tritmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tritmp.h
new file mode 100644
index 000000000..612ef2433
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_tritmp.h
@@ -0,0 +1,239 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_tritmp.h,v 1.2 2002/02/22 21:32:59 dawes Exp $ */
+
+static void TAG(ffb_triangle)( GLcontext *ctx,
+ ffb_vertex *v0,
+ ffb_vertex *v1,
+ ffb_vertex *v2 )
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ ffb_fbcPtr ffb = fmesa->regs;
+#if (IND & FFB_TRI_FLAT_BIT)
+ GLuint const_fg;
+#endif
+ FFB_DELAYED_VIEWPORT_VARS;
+
+#ifdef TRI_DEBUG
+ fprintf(stderr, "FFB: ffb_triangle ["
+#if (IND & FFB_TRI_CULL_BIT)
+ " CULL"
+#endif
+#if (IND & FFB_TRI_FLAT_BIT)
+ " FLAT"
+#endif
+#if (IND & FFB_TRI_ALPHA_BIT)
+ " ALPHA"
+#endif
+ " ]\n");
+#endif
+
+#if (IND & FFB_TRI_CULL_BIT)
+ { /* NOTE: These are not viewport transformed yet. */
+ GLfloat ex = v1->x - v0->x;
+ GLfloat ey = v1->y - v0->y;
+ GLfloat fx = v2->x - v0->x;
+ GLfloat fy = v2->y - v0->y;
+ GLfloat c = ex*fy-ey*fx;
+
+ /* Culled... */
+ if (c * fmesa->backface_sign > fmesa->ffb_zero)
+ return;
+ }
+#endif
+
+#if (IND & FFB_TRI_FLAT_BIT)
+ const_fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( v2->color[0] );
+#ifdef TRI_DEBUG
+ fprintf(stderr, "FFB_tri: const_fg %08x (B[%f] G[%f] R[%f])\n",
+ const_fg,
+ FFB_2_30_FIXED_TO_FLOAT(v2->color[0].blue),
+ FFB_2_30_FIXED_TO_FLOAT(v2->color[0].green),
+ FFB_2_30_FIXED_TO_FLOAT(v2->color[0].red));
+#endif
+#endif
+
+
+#if (IND & FFB_TRI_FLAT_BIT)
+ FFBFifo(fmesa, 1);
+ ffb->fg = const_fg;
+#endif
+
+#if (IND & FFB_TRI_FLAT_BIT)
+ FFBFifo(fmesa, 9);
+#else
+#if (IND & FFB_TRI_ALPHA_BIT)
+ FFBFifo(fmesa, 21);
+#else
+ FFBFifo(fmesa, 18);
+#endif
+#endif
+
+ FFB_DUMP_VERTEX(v0);
+#if !(IND & FFB_TRI_FLAT_BIT)
+#if (IND & FFB_TRI_ALPHA_BIT)
+ ffb->alpha = FFB_GET_ALPHA(v0);
+#endif
+ ffb->red = FFB_GET_RED(v0);
+ ffb->green = FFB_GET_GREEN(v0);
+ ffb->blue = FFB_GET_BLUE(v0);
+#endif
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_DUMP_VERTEX(v1);
+#if !(IND & FFB_TRI_FLAT_BIT)
+#if (IND & FFB_TRI_ALPHA_BIT)
+ ffb->alpha = FFB_GET_ALPHA(v1);
+#endif
+ ffb->red = FFB_GET_RED(v1);
+ ffb->green = FFB_GET_GREEN(v1);
+ ffb->blue = FFB_GET_BLUE(v1);
+#endif
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+
+ FFB_DUMP_VERTEX(v2);
+#if !(IND & FFB_TRI_FLAT_BIT)
+#if (IND & FFB_TRI_ALPHA_BIT)
+ ffb->alpha = FFB_GET_ALPHA(v2);
+#endif
+ ffb->red = FFB_GET_RED(v2);
+ ffb->green = FFB_GET_GREEN(v2);
+ ffb->blue = FFB_GET_BLUE(v2);
+#endif
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+
+static void TAG(ffb_quad)(GLcontext *ctx,
+ ffb_vertex *v0,
+ ffb_vertex *v1,
+ ffb_vertex *v2,
+ ffb_vertex *v3 )
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ ffb_fbcPtr ffb = fmesa->regs;
+#if (IND & FFB_TRI_FLAT_BIT)
+ GLuint const_fg;
+#endif
+ FFB_DELAYED_VIEWPORT_VARS;
+
+#ifdef TRI_DEBUG
+ fprintf(stderr, "FFB: ffb_quad ["
+#if (IND & FFB_TRI_CULL_BIT)
+ " CULL"
+#endif
+#if (IND & FFB_TRI_FLAT_BIT)
+ " FLAT"
+#endif
+#if (IND & FFB_TRI_ALPHA_BIT)
+ " ALPHA"
+#endif
+ " ]\n");
+#endif /* TRI_DEBUG */
+
+#if (IND & FFB_TRI_CULL_BIT)
+ { /* NOTE: These are not viewport transformed yet. */
+ GLfloat ex = v2->x - v0->x;
+ GLfloat ey = v2->y - v0->y;
+ GLfloat fx = v3->x - v1->x;
+ GLfloat fy = v3->y - v1->y;
+ GLfloat c = ex*fy-ey*fx;
+
+ /* Culled... */
+ if (c * fmesa->backface_sign > fmesa->ffb_zero)
+ return;
+ }
+#endif
+
+#if (IND & FFB_TRI_FLAT_BIT)
+ const_fg = FFB_PACK_CONST_UBYTE_ARGB_COLOR( v3->color[0] );
+#ifdef TRI_DEBUG
+ fprintf(stderr, "FFB_quad: const_fg %08x (B[%f] G[%f] R[%f])\n",
+ const_fg,
+ FFB_2_30_FIXED_TO_FLOAT(v3->color[0].blue),
+ FFB_2_30_FIXED_TO_FLOAT(v3->color[0].green),
+ FFB_2_30_FIXED_TO_FLOAT(v3->color[0].red));
+#endif
+#endif
+
+
+#if (IND & FFB_TRI_FLAT_BIT)
+ FFBFifo(fmesa, 13);
+ ffb->fg = const_fg;
+#else
+#if (IND & FFB_TRI_ALPHA_BIT)
+ FFBFifo(fmesa, 28);
+#else
+ FFBFifo(fmesa, 24);
+#endif
+#endif
+
+ FFB_DUMP_VERTEX(v0);
+#if !(IND & FFB_TRI_FLAT_BIT)
+#if (IND & FFB_TRI_ALPHA_BIT)
+ ffb->alpha = FFB_GET_ALPHA(v0);
+#endif
+ ffb->red = FFB_GET_RED(v0);
+ ffb->green = FFB_GET_GREEN(v0);
+ ffb->blue = FFB_GET_BLUE(v0);
+#endif
+ ffb->z = FFB_GET_Z(v0);
+ ffb->ryf = FFB_GET_Y(v0);
+ ffb->rxf = FFB_GET_X(v0);
+
+ FFB_DUMP_VERTEX(v1);
+#if !(IND & FFB_TRI_FLAT_BIT)
+#if (IND & FFB_TRI_ALPHA_BIT)
+ ffb->alpha = FFB_GET_ALPHA(v1);
+#endif
+ ffb->red = FFB_GET_RED(v1);
+ ffb->green = FFB_GET_GREEN(v1);
+ ffb->blue = FFB_GET_BLUE(v1);
+#endif
+ ffb->z = FFB_GET_Z(v1);
+ ffb->y = FFB_GET_Y(v1);
+ ffb->x = FFB_GET_X(v1);
+
+ FFB_DUMP_VERTEX(v2);
+#if !(IND & FFB_TRI_FLAT_BIT)
+#if (IND & FFB_TRI_ALPHA_BIT)
+ ffb->alpha = FFB_GET_ALPHA(v2);
+#endif
+ ffb->red = FFB_GET_RED(v2);
+ ffb->green = FFB_GET_GREEN(v2);
+ ffb->blue = FFB_GET_BLUE(v2);
+#endif
+ ffb->z = FFB_GET_Z(v2);
+ ffb->y = FFB_GET_Y(v2);
+ ffb->x = FFB_GET_X(v2);
+
+ FFB_DUMP_VERTEX(v3);
+#if !(IND & FFB_TRI_FLAT_BIT)
+#if (IND & FFB_TRI_ALPHA_BIT)
+ ffb->alpha = FFB_GET_ALPHA(v3);
+#endif
+ ffb->red = FFB_GET_RED(v3);
+ ffb->green = FFB_GET_GREEN(v3);
+ ffb->blue = FFB_GET_BLUE(v3);
+#endif
+ ffb->z = FFB_GET_Z(v3);
+ ffb->dmyf = FFB_GET_Y(v3);
+ ffb->dmxf = FFB_GET_X(v3);
+
+ fmesa->ffbScreen->rp_active = 1;
+}
+
+static void TAG(ffb_init)(void)
+{
+ ffb_tri_tab[IND] = TAG(ffb_triangle);
+ ffb_quad_tab[IND] = TAG(ffb_quad);
+}
+
+#undef IND
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vb.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vb.c
new file mode 100644
index 000000000..6ba1eabbf
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vb.c
@@ -0,0 +1,209 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_vb.c,v 1.4 2002/02/22 21:32:59 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000, 2001 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "ffb_xmesa.h"
+#include "ffb_context.h"
+#include "ffb_vb.h"
+#include "imports.h"
+#include "tnl/t_context.h"
+#include "swrast_setup/swrast_setup.h"
+#include "math/m_translate.h"
+
+#undef VB_DEBUG
+
+static void ffb_copy_pv_oneside(GLcontext *ctx, GLuint edst, GLuint esrc)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ ffb_vertex *dst = &fmesa->verts[edst];
+ ffb_vertex *src = &fmesa->verts[esrc];
+
+#ifdef VB_DEBUG
+ fprintf(stderr, "ffb_copy_pv_oneside: edst(%d) esrc(%d)\n", edst, esrc);
+#endif
+ dst->color[0].alpha = src->color[0].alpha;
+ dst->color[0].red = src->color[0].red;
+ dst->color[0].green = src->color[0].green;
+ dst->color[0].blue = src->color[0].blue;
+}
+
+static void ffb_copy_pv_twoside(GLcontext *ctx, GLuint edst, GLuint esrc)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ ffb_vertex *dst = &fmesa->verts[edst];
+ ffb_vertex *src = &fmesa->verts[esrc];
+
+#ifdef VB_DEBUG
+ fprintf(stderr, "ffb_copy_pv_twoside: edst(%d) esrc(%d)\n", edst, esrc);
+#endif
+ dst->color[0].alpha = src->color[0].alpha;
+ dst->color[0].red = src->color[0].red;
+ dst->color[0].green = src->color[0].green;
+ dst->color[0].blue = src->color[0].blue;
+ dst->color[1].alpha = src->color[1].alpha;
+ dst->color[1].red = src->color[1].red;
+ dst->color[1].green = src->color[1].green;
+ dst->color[1].blue = src->color[1].blue;
+}
+
+#define FFB_VB_RGBA_BIT 0x01
+#define FFB_VB_XYZ_BIT 0x02
+#define FFB_VB_TWOSIDE_BIT 0x04
+#define FFB_VB_MAX 0x08
+
+typedef void (*ffb_emit_func)(GLcontext *, GLuint, GLuint);
+
+static struct {
+ ffb_emit_func emit;
+ tnl_interp_func interp;
+} setup_tab[FFB_VB_MAX];
+
+
+#define IND (FFB_VB_XYZ_BIT)
+#define TAG(x) x##_w
+#include "ffb_vbtmp.h"
+
+#define IND (FFB_VB_RGBA_BIT)
+#define TAG(x) x##_g
+#include "ffb_vbtmp.h"
+
+#define IND (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT)
+#define TAG(x) x##_wg
+#include "ffb_vbtmp.h"
+
+#define IND (FFB_VB_TWOSIDE_BIT)
+#define TAG(x) x##_t
+#include "ffb_vbtmp.h"
+
+#define IND (FFB_VB_XYZ_BIT | FFB_VB_TWOSIDE_BIT)
+#define TAG(x) x##_wt
+#include "ffb_vbtmp.h"
+
+#define IND (FFB_VB_RGBA_BIT | FFB_VB_TWOSIDE_BIT)
+#define TAG(x) x##_gt
+#include "ffb_vbtmp.h"
+
+#define IND (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT | FFB_VB_TWOSIDE_BIT)
+#define TAG(x) x##_wgt
+#include "ffb_vbtmp.h"
+
+static void init_setup_tab( void )
+{
+ init_w();
+ init_g();
+ init_wg();
+ init_t();
+ init_wt();
+ init_gt();
+ init_wgt();
+}
+
+#ifdef VB_DEBUG
+static void ffbPrintSetupFlags(char *msg, GLuint flags)
+{
+ fprintf(stderr, "%s(%x): %s%s%s\n",
+ msg,
+ (int)flags,
+ (flags & FFB_VB_XYZ_BIT) ? " xyz," : "",
+ (flags & FFB_VB_RGBA_BIT) ? " rgba," : "",
+ (flags & FFB_VB_TWOSIDE_BIT) ? " twoside," : "");
+}
+#endif
+
+static void ffbDDBuildVertices(GLcontext *ctx, GLuint start, GLuint count,
+ GLuint newinputs)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ newinputs |= fmesa->setupnewinputs;
+ fmesa->setupnewinputs = 0;
+
+ if (!newinputs)
+ return;
+
+ if (newinputs & VERT_BIT_POS) {
+ setup_tab[fmesa->setupindex].emit(ctx, start, count);
+ } else {
+ GLuint ind = 0;
+
+ if (newinputs & VERT_BIT_COLOR0)
+ ind |= (FFB_VB_RGBA_BIT | FFB_VB_TWOSIDE_BIT);
+
+ ind &= fmesa->setupindex;
+
+ if (ind)
+ setup_tab[ind].emit(ctx, start, count);
+ }
+}
+
+void ffbChooseVertexState( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ int ind = FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT;
+
+ if (ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE)
+ ind |= FFB_VB_TWOSIDE_BIT;
+
+#ifdef VB_DEBUG
+ ffbPrintSetupFlags("ffb: full setup function", ind);
+#endif
+
+ fmesa->setupindex = ind;
+
+ tnl->Driver.Render.BuildVertices = ffbDDBuildVertices;
+ tnl->Driver.Render.Interp = setup_tab[ind].interp;
+ if (ind & FFB_VB_TWOSIDE_BIT)
+ tnl->Driver.Render.CopyPV = ffb_copy_pv_twoside;
+ else
+ tnl->Driver.Render.CopyPV = ffb_copy_pv_oneside;
+}
+
+void ffbInitVB( GLcontext *ctx )
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLuint size = TNL_CONTEXT(ctx)->vb.Size;
+
+ fmesa->verts = (ffb_vertex *)ALIGN_MALLOC(size * sizeof(ffb_vertex), 32);
+
+ {
+ static int firsttime = 1;
+ if (firsttime) {
+ init_setup_tab();
+ firsttime = 0;
+ }
+ }
+}
+
+
+void ffbFreeVB( GLcontext *ctx )
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ if (fmesa->verts) {
+ ALIGN_FREE(fmesa->verts);
+ fmesa->verts = 0;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vb.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vb.h
new file mode 100644
index 000000000..9eb6759f6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vb.h
@@ -0,0 +1,45 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_vb.h,v 1.2 2002/02/22 21:32:59 dawes Exp $ */
+
+#ifndef _FFB_VB_H
+#define _FFB_VB_H
+
+#include "mtypes.h"
+#include "macros.h"
+#include "tnl/t_context.h"
+#include "swrast/swrast.h"
+
+#define __FFB_2_30_FIXED_SCALE 1073741824.0f
+#define FFB_2_30_FLOAT_TO_FIXED(X) \
+ (IROUND((X) * fmesa->ffb_2_30_fixed_scale))
+#define FFB_2_30_FIXED_TO_FLOAT(X) \
+ (((GLfloat)(X)) * fmesa->ffb_one_over_2_30_fixed_scale)
+
+#define __FFB_16_16_FIXED_SCALE 65536.0f
+#define FFB_16_16_FLOAT_TO_FIXED(X) \
+ (IROUND((X) * fmesa->ffb_16_16_fixed_scale))
+#define FFB_16_16_FIXED_TO_FLOAT(X) \
+ (((GLfloat)(X)) * fmesa->ffb_one_over_16_16_fixed_scale)
+
+#define FFB_Z_FROM_FLOAT(VAL) FFB_2_30_FLOAT_TO_FIXED(VAL)
+#define FFB_Z_TO_FLOAT(VAL) FFB_2_30_FIXED_TO_FLOAT(VAL)
+#define FFB_XY_FROM_FLOAT(VAL) FFB_16_16_FLOAT_TO_FIXED(VAL)
+#define FFB_XY_TO_FLOAT(VAL) FFB_16_16_FIXED_TO_FLOAT(VAL)
+
+#define FFB_UBYTE_FROM_COLOR(VAL) ((IROUND((VAL) * fmesa->ffb_ubyte_color_scale)))
+
+#define FFB_PACK_CONST_UBYTE_ARGB_COLOR(C) \
+ ((FFB_UBYTE_FROM_COLOR(C.alpha) << 24) | \
+ (FFB_UBYTE_FROM_COLOR(C.blue) << 16) | \
+ (FFB_UBYTE_FROM_COLOR(C.green) << 8) | \
+ (FFB_UBYTE_FROM_COLOR(C.red) << 0))
+
+#define FFB_COLOR_FROM_FLOAT(VAL) FFB_2_30_FLOAT_TO_FIXED(VAL)
+
+#define _FFB_NEW_VERTEX (_DD_NEW_TRI_LIGHT_TWOSIDE)
+
+extern void ffbDDSetupInit(void);
+extern void ffbChooseVertexState(GLcontext *);
+extern void ffbInitVB( GLcontext *ctx );
+extern void ffbFreeVB( GLcontext *ctx );
+
+#endif /* !(_FFB_VB_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vbtmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vbtmp.h
new file mode 100644
index 000000000..a1d1254d9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vbtmp.h
@@ -0,0 +1,151 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_vbtmp.h,v 1.1 2002/02/22 21:32:59 dawes Exp $ */
+
+static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+#if defined(VB_DEBUG) || (IND & (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT))
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+#endif
+#if (IND & (FFB_VB_RGBA_BIT))
+ GLfloat (*col0)[4];
+ GLuint col0_stride;
+#if (IND & (FFB_VB_TWOSIDE_BIT))
+ GLfloat (*col1)[4];
+ GLuint col1_stride;
+#endif
+#endif
+#if (IND & FFB_VB_XYZ_BIT)
+ GLfloat (*proj)[4] = VB->NdcPtr->data;
+ GLuint proj_stride = VB->NdcPtr->stride;
+ const GLubyte *mask = VB->ClipMask;
+#endif
+ ffb_vertex *v = &fmesa->verts[start];
+ int i;
+
+#ifdef VB_DEBUG
+ fprintf(stderr, "FFB: ffb_emit ["
+#if (IND & (FFB_VB_XYZ_BIT))
+ " XYZ"
+#endif
+#if (IND & (FFB_VB_RGBA_BIT))
+ " RGBA"
+#endif
+#if (IND & (FFB_VB_TWOSIDE_BIT))
+ " TWOSIDE"
+#endif
+ "] start(%d) end(%d) import(%d)\n",
+ start, end,
+ VB->importable_data);
+#endif
+
+#if (IND & (FFB_VB_RGBA_BIT))
+ col0 = VB->ColorPtr[0]->data;
+ col0_stride = VB->ColorPtr[0]->stride;
+#if (IND & (FFB_VB_TWOSIDE_BIT))
+ col1 = VB->ColorPtr[1]->data;
+ col1_stride = VB->ColorPtr[1]->stride;
+#endif
+#endif
+
+ {
+ if (start) {
+#if (IND & (FFB_VB_XYZ_BIT))
+ proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_stride);
+#endif
+#if (IND & (FFB_VB_RGBA_BIT))
+ col0 = (GLfloat (*)[4])((GLubyte *)col0 + start * col0_stride);
+#if (IND & (FFB_VB_TWOSIDE_BIT))
+ col1 = (GLfloat (*)[4])((GLubyte *)col1 + start * col1_stride);
+#endif
+#endif
+ }
+ for (i = start; i < end; i++, v++) {
+#if (IND & (FFB_VB_XYZ_BIT))
+ if (mask[i] == 0) {
+ v->x = proj[0][0];
+ v->y = proj[0][1];
+ v->z = proj[0][2];
+ }
+ proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride);
+#endif
+#if (IND & (FFB_VB_RGBA_BIT))
+ v->color[0].alpha = CLAMP(col0[0][3], 0.0f, 1.0f);
+ v->color[0].red = CLAMP(col0[0][0], 0.0f, 1.0f);
+ v->color[0].green = CLAMP(col0[0][1], 0.0f, 1.0f);
+ v->color[0].blue = CLAMP(col0[0][2], 0.0f, 1.0f);
+ col0 = (GLfloat (*)[4])((GLubyte *)col0 + col0_stride);
+#if (IND & (FFB_VB_TWOSIDE_BIT))
+ v->color[1].alpha = CLAMP(col1[0][3], 0.0f, 1.0f);
+ v->color[1].red = CLAMP(col1[0][0], 0.0f, 1.0f);
+ v->color[1].green = CLAMP(col1[0][1], 0.0f, 1.0f);
+ v->color[1].blue = CLAMP(col1[0][2], 0.0f, 1.0f);
+ col1 = (GLfloat (*)[4])((GLubyte *)col1 + col1_stride);
+#endif
+#endif
+ }
+ }
+}
+
+static void TAG(interp)(GLcontext *ctx, GLfloat t,
+ GLuint edst, GLuint eout, GLuint ein,
+ GLboolean force_boundary)
+{
+#if (IND & (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT))
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+#endif
+#if (IND & (FFB_VB_XYZ_BIT))
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ const GLfloat *dstclip = VB->ClipPtr->data[edst];
+ GLfloat oow = 1.0 / dstclip[3];
+#endif
+#if (IND & (FFB_VB_XYZ_BIT | FFB_VB_RGBA_BIT))
+ ffb_vertex *dst = &fmesa->verts[edst];
+#endif
+#if (IND & (FFB_VB_RGBA_BIT))
+ ffb_vertex *in = &fmesa->verts[eout];
+ ffb_vertex *out = &fmesa->verts[ein];
+#endif
+
+#ifdef VB_DEBUG
+ fprintf(stderr, "FFB: ffb_interp ["
+#if (IND & (FFB_VB_XYZ_BIT))
+ " XYZ"
+#endif
+#if (IND & (FFB_VB_RGBA_BIT))
+ " RGBA"
+#endif
+#if (IND & (FFB_VB_TWOSIDE_BIT))
+ " TWOSIDE"
+#endif
+ "] edst(%d) eout(%d) ein(%d)\n",
+ edst, eout, ein);
+#endif
+
+#if (IND & (FFB_VB_XYZ_BIT))
+ dst->x = dstclip[0] * oow;
+ dst->y = dstclip[1] * oow;
+ dst->z = dstclip[2] * oow;
+#endif
+
+#if (IND & (FFB_VB_RGBA_BIT))
+ INTERP_F(t, dst->color[0].alpha, out->color[0].alpha, in->color[0].alpha);
+ INTERP_F(t, dst->color[0].red, out->color[0].red, in->color[0].red);
+ INTERP_F(t, dst->color[0].green, out->color[0].green, in->color[0].green);
+ INTERP_F(t, dst->color[0].blue, out->color[0].blue, in->color[0].blue);
+#if (IND & (FFB_VB_TWOSIDE_BIT))
+ INTERP_F(t, dst->color[1].alpha, out->color[1].alpha, in->color[1].alpha);
+ INTERP_F(t, dst->color[1].red, out->color[1].red, in->color[1].red);
+ INTERP_F(t, dst->color[1].green, out->color[1].green, in->color[1].green);
+ INTERP_F(t, dst->color[1].blue, out->color[1].blue, in->color[1].blue);
+#endif
+#endif
+}
+
+static void TAG(init)(void)
+{
+ setup_tab[IND].emit = TAG(emit);
+ setup_tab[IND].interp = TAG(interp);
+}
+
+#undef IND
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vtxfmt.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vtxfmt.c
new file mode 100644
index 000000000..d6a61d98e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vtxfmt.c
@@ -0,0 +1,427 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_vtxfmt.c,v 1.1 2002/02/22 21:32:59 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2001 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "glheader.h"
+#include "api_noop.h"
+#include "context.h"
+#include "light.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "vtxfmt.h"
+#include "ffb_xmesa.h"
+#include "ffb_context.h"
+#include "ffb_vb.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+
+#include "ffb_vtxfmt.h"
+
+#ifndef __GNUC__
+#define __inline /**/
+#endif
+
+#define TNL_VERTEX ffbTnlVertex
+
+#define INTERP_RGBA(t, out, a, b) \
+do { \
+ GLint i; \
+ for ( i = 0 ; i < 4 ; i++ ) { \
+ GLfloat fa = a[i]; \
+ GLfloat fb = b[i]; \
+ out[i] = LINTERP( t, fa, fb ); \
+ } \
+} while (0)
+
+/* Color functions: */
+
+static __inline void ffb_recalc_base_color(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ struct gl_light *light;
+
+ COPY_3V(fmesa->vtx_state.light.base_color, ctx->Light._BaseColor[0]);
+ foreach (light, &ctx->Light.EnabledList) {
+ ACC_3V(fmesa->vtx_state.light.base_color,
+ light->_MatAmbient[0]);
+ }
+
+ fmesa->vtx_state.light.base_alpha = ctx->Light._BaseAlpha[0];
+}
+
+#define GET_CURRENT \
+ GET_CURRENT_CONTEXT(ctx); \
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx)
+
+#define CURRENT_COLOR(COMP) fmesa->vtx_state.current.color[COMP]
+#define CURRENT_SPECULAR(COMP) fmesa->vtx_state.current.specular[COMP]
+#define COLOR_IS_FLOAT
+#define RECALC_BASE_COLOR(ctx) ffb_recalc_base_color(ctx)
+
+#define TAG(x) ffb_##x
+#include "tnl_dd/t_dd_imm_capi.h"
+
+/* Normal functions: */
+
+struct ffb_norm_tab {
+ void (*normal3f_multi)(GLfloat x, GLfloat y, GLfloat z);
+ void (*normal3fv_multi)(const GLfloat *v);
+ void (*normal3f_single)(GLfloat x, GLfloat y, GLfloat z);
+ void (*normal3fv_single)(const GLfloat *v);
+};
+
+static struct ffb_norm_tab norm_tab[0x4];
+
+#define HAVE_HW_LIGHTING 0
+#define GET_CURRENT_VERTEX \
+ GET_CURRENT_CONTEXT(ctx); \
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx); \
+ ffbTnlVertexPtr v = fmesa->imm.v0
+
+#define CURRENT_NORMAL fmesa->vtx_state.current.normal
+#define BASE_COLOR fmesa->vtx_state.light.base_color
+#define BASE_ALPHA fmesa->vtx_state.light.base_alpha
+#define VERT_COLOR( COMP ) v->color[COMP]
+#define VERT_COLOR_IS_FLOAT
+
+#define IND (0)
+#define TAG(x) ffb_##x
+#define PRESERVE_NORMAL_DEFS
+#include "tnl_dd/t_dd_imm_napi.h"
+
+#define IND (NORM_RESCALE)
+#define TAG(x) ffb_##x##_rescale
+#define PRESERVE_NORMAL_DEFS
+#include "tnl_dd/t_dd_imm_napi.h"
+
+#define IND (NORM_NORMALIZE)
+#define TAG(x) ffb_##x##_normalize
+#include "tnl_dd/t_dd_imm_napi.h"
+
+static void ffb_init_norm_funcs(void)
+{
+ ffb_init_norm();
+ ffb_init_norm_rescale();
+ ffb_init_norm_normalize();
+}
+
+static void choose_normals(void)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint index;
+
+ if (ctx->Light.Enabled) {
+ if (ctx->Transform.Normalize) {
+ index = NORM_NORMALIZE;
+ } else if (!ctx->Transform.RescaleNormals &&
+ ctx->_ModelViewInvScale != 1.0) {
+ index = NORM_RESCALE;
+ } else {
+ index = 0;
+ }
+
+ if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev) {
+ SET_Normal3f(ctx->Exec, norm_tab[index].normal3f_single);
+ SET_Normal3fv(ctx->Exec, norm_tab[index].normal3fv_single);
+ } else {
+ SET_Normal3f(ctx->Exec, norm_tab[index].normal3f_multi);
+ SET_Normal3fv(ctx->Exec, norm_tab[index].normal3fv_multi);
+ }
+ } else {
+ SET_Normal3f(ctx->Exec, _mesa_noop_Normal3f);
+ SET_Normal3fv(ctx->Exec, _mesa_noop_Normal3fv);
+ }
+}
+
+static void ffb_choose_Normal3f(GLfloat x, GLfloat y, GLfloat z)
+{
+ choose_normals();
+ CALL_Normal3f(GET_DISPATCH(), (x, y, z));
+}
+
+static void ffb_choose_Normal3fv(const GLfloat *v)
+{
+ choose_normals();
+ CALL_Normal3fv(GET_DISPATCH(), (v));
+}
+
+/* Vertex functions: */
+
+#define GET_CURRENT_VERTEX \
+ GET_CURRENT_CONTEXT(ctx); \
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx); \
+ ffbTnlVertexPtr v = fmesa->imm.v0
+
+#define CURRENT_VERTEX v->obj
+#define SAVE_VERTEX fmesa->imm.save_vertex(ctx, v)
+
+#define TAG(x) ffb_##x
+#include "tnl_dd/t_dd_imm_vapi.h"
+
+struct ffb_vert_tab {
+ void (*save_vertex)(GLcontext *ctx, ffbTnlVertexPtr v);
+ void (*interpolate_vertex)(GLfloat t,
+ ffbTnlVertex *O,
+ const ffbTnlVertex *I,
+ const ffbTnlVertex *J);
+};
+
+static struct ffb_vert_tab vert_tab[0xf];
+
+#define VTX_NORMAL 0x0
+#define VTX_RGBA 0x1
+
+#define LOCAL_VARS \
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx)
+
+#define CURRENT_COLOR fmesa->vtx_state.current.color
+#define COLOR_IS_FLOAT
+#define FLUSH_VERTEX fmesa->imm.flush_vertex( ctx, v );
+
+#define IND (VTX_NORMAL)
+#define TAG(x) ffb_##x##_NORMAL
+#define PRESERVE_VERTEX_DEFS
+#include "tnl_dd/t_dd_imm_vertex.h"
+
+#define IND (VTX_RGBA)
+#define TAG(x) ffb_##x##_RGBA
+#include "tnl_dd/t_dd_imm_vertex.h"
+
+static void ffb_init_vert_funcs( void )
+{
+ ffb_init_vert_NORMAL();
+ ffb_init_vert_RGBA();
+}
+
+#define LOCAL_VARS \
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx)
+
+#define GET_INTERP_FUNC \
+ ffb_interp_func interp = fmesa->imm.interp
+
+#define FLUSH_VERTEX fmesa->imm.flush_vertex
+#define IMM_VERTEX( V ) fmesa->imm.V
+#define IMM_VERTICES( n ) fmesa->imm.vertices[n]
+
+#define EMIT_VERTEX_USES_HWREGS
+
+/* XXX Implement me XXX */
+#define EMIT_VERTEX_TRI(VTX0, VTX1, VTX2) \
+ do { } while (0)
+#define EMIT_VERTEX_LINE(VTX0, VTX1) \
+ do { } while (0)
+#define EMIT_VERTEX_POINT(VTX0) \
+ do { } while (0)
+
+#define TAG(x) ffb_##x
+#include "tnl_dd/t_dd_imm_primtmp.h"
+
+/* Bzzt: Material changes are lost on fallback. */
+static void ffb_Materialfv(GLenum face, GLenum pname,
+ const GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ _mesa_noop_Materialfv( face, pname, params );
+ ffb_recalc_base_color( ctx );
+}
+
+/* Fallback functions: */
+
+static void ffb_do_fallback(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ struct ffb_current_state *current = &fmesa->vtx_state.current;
+
+ /* Tell tnl to restore its exec vtxfmt, rehook its driver callbacks
+ * and revive internal state that depended on those callbacks:
+ */
+ _tnl_wakeup_exec(ctx);
+
+ /* Replay enough vertices that the current primitive is continued
+ * correctly:
+ */
+ if (fmesa->imm.prim != PRIM_OUTSIDE_BEGIN_END )
+ CALL_Begin(GET_DISPATCH(), (fmesa->imm.prim));
+
+ if (ctx->Light.Enabled) {
+ /* Catch ColorMaterial */
+ CALL_Color4fv(GET_DISPATCH(), (ctx->Current.Color));
+ CALL_Normal3fv(GET_DISPATCH(), (current->normal));
+ } else {
+ CALL_Color4fv(GET_DISPATCH(), (current->color));
+ }
+}
+
+#define PRE_LOOPBACK( FUNC ) do { \
+ GET_CURRENT_CONTEXT(ctx); \
+ ffb_do_fallback( ctx ); \
+} while (0)
+
+#define TAG(x) ffb_fallback_##x
+#include "vtxfmt_tmp.h"
+
+static void ffb_Begin(GLenum prim)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ if (prim > GL_POLYGON) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBegin" );
+ return;
+ }
+
+ if (fmesa->imm.prim != PRIM_OUTSIDE_BEGIN_END) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glBegin" );
+ return;
+ }
+
+ ctx->Driver.NeedFlush |= (FLUSH_STORED_VERTICES |
+ FLUSH_UPDATE_CURRENT);
+
+ fmesa->imm.prim = prim;
+ fmesa->imm.v0 = &fmesa->imm.vertices[0];
+ fmesa->imm.save_vertex = ffb_save_vertex_RGBA;
+ fmesa->imm.flush_vertex = ffb_flush_tab[prim];
+
+ /* XXX Lock hardware, update FBC, PPC, DRAWOP, etc. XXX */
+}
+
+static void ffb_End(void)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+
+ if (fmesa->imm.prim == PRIM_OUTSIDE_BEGIN_END) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd" );
+ return;
+ }
+
+ fmesa->imm.prim = PRIM_OUTSIDE_BEGIN_END;
+
+ ctx->Driver.NeedFlush &= ~(FLUSH_STORED_VERTICES |
+ FLUSH_UPDATE_CURRENT);
+
+ /* XXX Unlock hardware, etc. */
+}
+
+void ffbInitTnlModule(GLcontext *ctx)
+{
+ ffbContextPtr fmesa = FFB_CONTEXT(ctx);
+ GLvertexformat *vfmt = &(fmesa->imm.vtxfmt);
+
+ /* Work in progress... */
+ return;
+
+ ffb_init_norm_funcs();
+ ffb_init_vert_funcs();
+
+ MEMSET(vfmt, 0, sizeof(GLvertexformat));
+
+ /* Handled fully in supported states: */
+ vfmt->ArrayElement = NULL; /* FIXME: ... */
+ vfmt->Color3f = ffb_choose_Color3f;
+ vfmt->Color3fv = ffb_choose_Color3fv;
+ vfmt->Color3ub = ffb_choose_Color3ub;
+ vfmt->Color3ubv = ffb_choose_Color3ubv;
+ vfmt->Color4f = ffb_choose_Color4f;
+ vfmt->Color4fv = ffb_choose_Color4fv;
+ vfmt->Color4ub = ffb_choose_Color4ub;
+ vfmt->Color4ubv = ffb_choose_Color4ubv;
+ vfmt->FogCoordfvEXT = ffb_FogCoordfvEXT;
+ vfmt->FogCoordfEXT = ffb_FogCoordfEXT;
+ vfmt->Materialfv = ffb_Materialfv;
+ vfmt->MultiTexCoord1fARB = ffb_fallback_MultiTexCoord1fARB;
+ vfmt->MultiTexCoord1fvARB = ffb_fallback_MultiTexCoord1fvARB;
+ vfmt->MultiTexCoord2fARB = ffb_fallback_MultiTexCoord2fARB;
+ vfmt->MultiTexCoord2fvARB = ffb_fallback_MultiTexCoord2fvARB;
+ vfmt->MultiTexCoord3fARB = ffb_fallback_MultiTexCoord3fARB;
+ vfmt->MultiTexCoord3fvARB = ffb_fallback_MultiTexCoord3fvARB;
+ vfmt->MultiTexCoord4fARB = ffb_fallback_MultiTexCoord4fARB;
+ vfmt->MultiTexCoord4fvARB = ffb_fallback_MultiTexCoord4fvARB;
+ vfmt->Normal3f = ffb_choose_Normal3f;
+ vfmt->Normal3fv = ffb_choose_Normal3fv;
+ vfmt->SecondaryColor3ubEXT = ffb_SecondaryColor3ubEXT;
+ vfmt->SecondaryColor3ubvEXT = ffb_SecondaryColor3ubvEXT;
+ vfmt->SecondaryColor3fEXT = ffb_SecondaryColor3fEXT;
+ vfmt->SecondaryColor3fvEXT = ffb_SecondaryColor3fvEXT;
+ vfmt->TexCoord1f = ffb_fallback_TexCoord1f;
+ vfmt->TexCoord1fv = ffb_fallback_TexCoord1fv;
+ vfmt->TexCoord2f = ffb_fallback_TexCoord2f;
+ vfmt->TexCoord2fv = ffb_fallback_TexCoord2fv;
+ vfmt->TexCoord3f = ffb_fallback_TexCoord3f;
+ vfmt->TexCoord3fv = ffb_fallback_TexCoord3fv;
+ vfmt->TexCoord4f = ffb_fallback_TexCoord4f;
+ vfmt->TexCoord4fv = ffb_fallback_TexCoord4fv;
+
+ vfmt->Vertex2f = ffb_Vertex2f;
+ vfmt->Vertex2fv = ffb_Vertex2fv;
+ vfmt->Vertex3f = ffb_Vertex3f;
+ vfmt->Vertex3fv = ffb_Vertex3fv;
+ vfmt->Vertex4f = ffb_Vertex4f;
+ vfmt->Vertex4fv = ffb_Vertex4fv;
+
+ vfmt->Begin = ffb_Begin;
+ vfmt->End = ffb_End;
+
+ vfmt->Rectf = _mesa_noop_Rectf; /* generic helper */
+
+ vfmt->DrawArrays = NULL;
+ vfmt->DrawElements = NULL;
+ vfmt->DrawRangeElements = _mesa_noop_DrawRangeElements; /* discard range */
+
+
+ /* Not active in supported states; just keep ctx->Current uptodate: */
+ vfmt->EdgeFlag = _mesa_noop_EdgeFlag;
+ vfmt->EdgeFlagv = _mesa_noop_EdgeFlagv;
+ vfmt->Indexi = _mesa_noop_Indexi;
+ vfmt->Indexiv = _mesa_noop_Indexiv;
+
+ /* Active but unsupported -- fallback if we receive these:
+ *
+ * All of these fallbacks can be fixed with additional code, except
+ * CallList, unless we build a play_immediate_noop() command which
+ * turns an immediate back into glBegin/glEnd commands...
+ */
+ vfmt->CallList = ffb_fallback_CallList;
+ vfmt->EvalCoord1f = ffb_fallback_EvalCoord1f;
+ vfmt->EvalCoord1fv = ffb_fallback_EvalCoord1fv;
+ vfmt->EvalCoord2f = ffb_fallback_EvalCoord2f;
+ vfmt->EvalCoord2fv = ffb_fallback_EvalCoord2fv;
+ vfmt->EvalMesh1 = ffb_fallback_EvalMesh1;
+ vfmt->EvalMesh2 = ffb_fallback_EvalMesh2;
+ vfmt->EvalPoint1 = ffb_fallback_EvalPoint1;
+ vfmt->EvalPoint2 = ffb_fallback_EvalPoint2;
+
+ vfmt->prefer_float_colors = GL_TRUE;
+
+ fmesa->imm.prim = PRIM_OUTSIDE_BEGIN_END;
+
+ /* THIS IS A HACK! */
+ _mesa_install_exec_vtxfmt( ctx, vfmt );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vtxfmt.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vtxfmt.h
new file mode 100644
index 000000000..063bb4923
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_vtxfmt.h
@@ -0,0 +1,8 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_vtxfmt.h,v 1.1 2002/02/22 21:32:59 dawes Exp $ */
+
+#ifndef _FFB_VTXFMT_H
+#define _FFB_VTXFMT_H
+
+extern void ffbInitTnlModule(GLcontext *);
+
+#endif /* !(_FFB_VTXFMT_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_xmesa.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_xmesa.c
new file mode 100644
index 000000000..530c5373a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_xmesa.c
@@ -0,0 +1,753 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.c,v 1.4 2002/02/22 21:32:59 dawes Exp $
+ *
+ * GLX Hardware Device Driver for Sun Creator/Creator3D
+ * Copyright (C) 2000, 2001 David S. Miller
+ *
+ * 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
+ * DAVID MILLER, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ * David S. Miller <davem@redhat.com>
+ */
+
+#include "ffb_xmesa.h"
+#include "context.h"
+#include "framebuffer.h"
+#include "matrix.h"
+#include "renderbuffer.h"
+#include "simple_list.h"
+#include "imports.h"
+#include "utils.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+#include "array_cache/acache.h"
+#include "drivers/common/driverfuncs.h"
+
+#include "ffb_context.h"
+#include "ffb_dd.h"
+#include "ffb_span.h"
+#include "ffb_depth.h"
+#include "ffb_stencil.h"
+#include "ffb_clear.h"
+#include "ffb_vb.h"
+#include "ffb_tris.h"
+#include "ffb_lines.h"
+#include "ffb_points.h"
+#include "ffb_state.h"
+#include "ffb_tex.h"
+#include "ffb_lock.h"
+#include "ffb_vtxfmt.h"
+#include "ffb_bitmap.h"
+
+#include "drm_sarea.h"
+
+static GLboolean
+ffbInitDriver(__DRIscreenPrivate *sPriv)
+{
+ ffbScreenPrivate *ffbScreen;
+ FFBDRIPtr gDRIPriv = (FFBDRIPtr) sPriv->pDevPriv;
+ drmAddress map;
+
+ if (getenv("LIBGL_FORCE_XSERVER"))
+ return GL_FALSE;
+
+
+ if (sPriv->devPrivSize != sizeof(FFBDRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(FFBDRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
+
+ /* Allocate the private area. */
+ ffbScreen = (ffbScreenPrivate *) MALLOC(sizeof(ffbScreenPrivate));
+ if (!ffbScreen)
+ return GL_FALSE;
+
+ /* Map FBC registers. */
+ if (drmMap(sPriv->fd,
+ gDRIPriv->hFbcRegs,
+ gDRIPriv->sFbcRegs,
+ &map)) {
+ FREE(ffbScreen);
+ return GL_FALSE;
+ }
+ ffbScreen->regs = (ffb_fbcPtr) map;
+
+ /* Map ramdac registers. */
+ if (drmMap(sPriv->fd,
+ gDRIPriv->hDacRegs,
+ gDRIPriv->sDacRegs,
+ &map)) {
+ drmUnmap((drmAddress)ffbScreen->regs, gDRIPriv->sFbcRegs);
+ FREE(ffbScreen);
+ return GL_FALSE;
+ }
+ ffbScreen->dac = (ffb_dacPtr) map;
+
+ /* Map "Smart" framebuffer views. */
+ if (drmMap(sPriv->fd,
+ gDRIPriv->hSfb8r,
+ gDRIPriv->sSfb8r,
+ &map)) {
+ drmUnmap((drmAddress)ffbScreen->regs, gDRIPriv->sFbcRegs);
+ drmUnmap((drmAddress)ffbScreen->dac, gDRIPriv->sDacRegs);
+ FREE(ffbScreen);
+ return GL_FALSE;
+ }
+ ffbScreen->sfb8r = (volatile char *) map;
+
+ if (drmMap(sPriv->fd,
+ gDRIPriv->hSfb32,
+ gDRIPriv->sSfb32,
+ &map)) {
+ drmUnmap((drmAddress)ffbScreen->regs, gDRIPriv->sFbcRegs);
+ drmUnmap((drmAddress)ffbScreen->dac, gDRIPriv->sDacRegs);
+ drmUnmap((drmAddress)ffbScreen->sfb8r, gDRIPriv->sSfb8r);
+ FREE(ffbScreen);
+ return GL_FALSE;
+ }
+ ffbScreen->sfb32 = (volatile char *) map;
+
+ if (drmMap(sPriv->fd,
+ gDRIPriv->hSfb64,
+ gDRIPriv->sSfb64,
+ &map)) {
+ drmUnmap((drmAddress)ffbScreen->regs, gDRIPriv->sFbcRegs);
+ drmUnmap((drmAddress)ffbScreen->dac, gDRIPriv->sDacRegs);
+ drmUnmap((drmAddress)ffbScreen->sfb8r, gDRIPriv->sSfb8r);
+ drmUnmap((drmAddress)ffbScreen->sfb32, gDRIPriv->sSfb32);
+ FREE(ffbScreen);
+ return GL_FALSE;
+ }
+ ffbScreen->sfb64 = (volatile char *) map;
+
+ ffbScreen->fifo_cache = 0;
+ ffbScreen->rp_active = 0;
+
+ ffbScreen->sPriv = sPriv;
+ sPriv->private = (void *) ffbScreen;
+
+ ffbDDLinefuncInit();
+ ffbDDPointfuncInit();
+
+ return GL_TRUE;
+}
+
+
+static void
+ffbDestroyScreen(__DRIscreenPrivate *sPriv)
+{
+ ffbScreenPrivate *ffbScreen = sPriv->private;
+ FFBDRIPtr gDRIPriv = (FFBDRIPtr) sPriv->pDevPriv;
+
+ drmUnmap((drmAddress)ffbScreen->regs, gDRIPriv->sFbcRegs);
+ drmUnmap((drmAddress)ffbScreen->dac, gDRIPriv->sDacRegs);
+ drmUnmap((drmAddress)ffbScreen->sfb8r, gDRIPriv->sSfb8r);
+ drmUnmap((drmAddress)ffbScreen->sfb32, gDRIPriv->sSfb32);
+ drmUnmap((drmAddress)ffbScreen->sfb64, gDRIPriv->sSfb64);
+
+ FREE(ffbScreen);
+}
+
+static const struct tnl_pipeline_stage *ffb_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ /* REMOVE: fog coord stage */
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ /* REMOVE: point attenuation stage */
+ &_tnl_render_stage,
+ 0,
+};
+
+/* Create and initialize the Mesa and driver specific context data */
+static GLboolean
+ffbCreateContext(const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate)
+{
+ ffbContextPtr fmesa;
+ GLcontext *ctx, *shareCtx;
+ __DRIscreenPrivate *sPriv;
+ ffbScreenPrivate *ffbScreen;
+ char *debug;
+ struct dd_function_table functions;
+
+ /* Allocate ffb context */
+ fmesa = (ffbContextPtr) CALLOC(sizeof(ffbContextRec));
+ if (!fmesa)
+ return GL_FALSE;
+
+ _mesa_init_driver_functions(&functions);
+
+ /* Allocate Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((ffbContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ fmesa->glCtx = _mesa_create_context(mesaVis, shareCtx,
+ &functions, fmesa);
+ if (!fmesa->glCtx) {
+ FREE(fmesa);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = fmesa;
+ ctx = fmesa->glCtx;
+
+ sPriv = driContextPriv->driScreenPriv;
+ ffbScreen = (ffbScreenPrivate *) sPriv->private;
+
+ /* Dri stuff. */
+ fmesa->hHWContext = driContextPriv->hHWContext;
+ fmesa->driFd = sPriv->fd;
+ fmesa->driHwLock = &sPriv->pSAREA->lock;
+
+ fmesa->ffbScreen = ffbScreen;
+ fmesa->driScreen = sPriv;
+ fmesa->ffb_sarea = FFB_DRISHARE(sPriv->pSAREA);
+
+ /* Register and framebuffer hw pointers. */
+ fmesa->regs = ffbScreen->regs;
+ fmesa->sfb32 = ffbScreen->sfb32;
+
+ ffbDDInitContextHwState(ctx);
+
+ /* Default clear and depth colors. */
+ {
+ 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);
+
+ fmesa->clear_pixel = ((r << 0) |
+ (g << 8) |
+ (b << 16));
+ }
+ fmesa->clear_depth = Z_FROM_MESA(ctx->Depth.Clear * 4294967295.0f);
+ fmesa->clear_stencil = ctx->Stencil.Clear & 0xf;
+
+ /* No wide points. */
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = 1.0;
+ ctx->Const.MaxPointSizeAA = 1.0;
+
+ /* Disable wide lines as we can't antialias them correctly in
+ * hardware.
+ */
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 1.0;
+ ctx->Const.MaxLineWidthAA = 1.0;
+ ctx->Const.LineWidthGranularity = 1.0;
+
+ /* Instead of having GCC emit these constants a zillion times
+ * everywhere in the driver, put them here.
+ */
+ fmesa->ffb_2_30_fixed_scale = __FFB_2_30_FIXED_SCALE;
+ fmesa->ffb_one_over_2_30_fixed_scale = (1.0 / __FFB_2_30_FIXED_SCALE);
+ fmesa->ffb_16_16_fixed_scale = __FFB_16_16_FIXED_SCALE;
+ fmesa->ffb_one_over_16_16_fixed_scale = (1.0 / __FFB_16_16_FIXED_SCALE);
+ fmesa->ffb_ubyte_color_scale = 255.0f;
+ fmesa->ffb_zero = 0.0f;
+
+ fmesa->debugFallbacks = GL_FALSE;
+ debug = getenv("LIBGL_DEBUG");
+ if (debug && strstr(debug, "fallbacks"))
+ fmesa->debugFallbacks = GL_TRUE;
+
+ /* Initialize the software rasterizer and helper modules. */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+
+ /* All of this need only be done once for a new context. */
+ /* XXX these should be moved right after the
+ * _mesa_init_driver_functions() call above.
+ */
+ ffbDDExtensionsInit(ctx);
+ ffbDDInitDriverFuncs(ctx);
+ ffbDDInitStateFuncs(ctx);
+ ffbDDInitRenderFuncs(ctx);
+ /*ffbDDInitTexFuncs(ctx); not needed */
+ ffbDDInitBitmapFuncs(ctx);
+ ffbInitVB(ctx);
+
+#if 0
+ ffbInitTnlModule(ctx);
+#endif
+
+ _tnl_destroy_pipeline(ctx);
+ _tnl_install_pipeline(ctx, ffb_pipeline);
+
+ return GL_TRUE;
+}
+
+static void
+ffbDestroyContext(__DRIcontextPrivate *driContextPriv)
+{
+ ffbContextPtr fmesa = (ffbContextPtr) driContextPriv->driverPrivate;
+
+ if (fmesa) {
+ ffbFreeVB(fmesa->glCtx);
+
+ _swsetup_DestroyContext( fmesa->glCtx );
+ _tnl_DestroyContext( fmesa->glCtx );
+ _ac_DestroyContext( fmesa->glCtx );
+ _swrast_DestroyContext( fmesa->glCtx );
+
+ /* free the Mesa context */
+ fmesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(fmesa->glCtx);
+
+ FREE(fmesa);
+ }
+}
+
+/* Create and initialize the Mesa and driver specific pixmap buffer data */
+static GLboolean
+ffbCreateBuffer(__DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ /* Mesa checks for pitch > 0, but ffb doesn't use pitches */
+ int bogusPitch = 1;
+ int bpp = 4; /* we've always got a 32bpp framebuffer */
+ int offset = 0; /* always at 0 for offset */
+
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ } else {
+ GLboolean swStencil = (mesaVis->stencilBits > 0 &&
+ mesaVis->depthBits != 24);
+#if 0
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ mesaVis->alphaBits > 0);
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, bpp, offset, bogusPitch);
+ ffbSetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, bpp, offset, bogusPitch);
+ ffbSetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, bpp, offset, bogusPitch);
+ ffbSetDepthFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, bpp, offset,bogusPitch);
+ ffbSetStencilFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+
+static void
+ffbDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+
+#define USE_FAST_SWAP
+
+static void
+ffbSwapBuffers( __DRIdrawablePrivate *dPriv )
+{
+ ffbContextPtr fmesa = (ffbContextPtr) dPriv->driContextPriv->driverPrivate;
+ unsigned int fbc, wid, wid_reg_val, dac_db_bit;
+ unsigned int shadow_dac_addr, active_dac_addr;
+ ffb_fbcPtr ffb;
+ ffb_dacPtr dac;
+
+ if (fmesa == NULL ||
+ fmesa->glCtx->Visual.doubleBufferMode == 0)
+ return;
+
+ /* Flush pending rendering commands */
+ _mesa_notifySwapBuffers(fmesa->glCtx);
+
+ ffb = fmesa->regs;
+ dac = fmesa->ffbScreen->dac;
+
+ fbc = fmesa->fbc;
+ wid = fmesa->wid;
+
+ /* Swap the buffer we render into and read pixels from. */
+ fmesa->back_buffer ^= 1;
+
+ /* If we are writing into both buffers, don't mess with
+ * the WB setting.
+ */
+ if ((fbc & FFB_FBC_WB_AB) != FFB_FBC_WB_AB) {
+ if ((fbc & FFB_FBC_WB_A) != 0)
+ fbc = (fbc & ~FFB_FBC_WB_A) | FFB_FBC_WB_B;
+ else
+ fbc = (fbc & ~FFB_FBC_WB_B) | FFB_FBC_WB_A;
+ }
+
+ /* But either way, we must flip the read buffer setting. */
+ if ((fbc & FFB_FBC_RB_A) != 0)
+ fbc = (fbc & ~FFB_FBC_RB_A) | FFB_FBC_RB_B;
+ else
+ fbc = (fbc & ~FFB_FBC_RB_B) | FFB_FBC_RB_A;
+
+ LOCK_HARDWARE(fmesa);
+
+ if (fmesa->fbc != fbc) {
+ FFBFifo(fmesa, 1);
+ ffb->fbc = fmesa->fbc = fbc;
+ fmesa->ffbScreen->rp_active = 1;
+ }
+
+ /* And swap the buffer displayed in the WID. */
+ if (fmesa->ffb_sarea->flags & FFB_DRI_PAC1) {
+ shadow_dac_addr = FFBDAC_PAC1_SPWLUT(wid);
+ active_dac_addr = FFBDAC_PAC1_APWLUT(wid);
+ dac_db_bit = FFBDAC_PAC1_WLUT_DB;
+ } else {
+ shadow_dac_addr = FFBDAC_PAC2_SPWLUT(wid);
+ active_dac_addr = FFBDAC_PAC2_APWLUT(wid);
+ dac_db_bit = FFBDAC_PAC2_WLUT_DB;
+ }
+
+ FFBWait(fmesa, ffb);
+
+ wid_reg_val = DACCFG_READ(dac, active_dac_addr);
+ if (fmesa->back_buffer == 0)
+ wid_reg_val |= dac_db_bit;
+ else
+ wid_reg_val &= ~dac_db_bit;
+#ifdef USE_FAST_SWAP
+ DACCFG_WRITE(dac, active_dac_addr, wid_reg_val);
+#else
+ DACCFG_WRITE(dac, shadow_dac_addr, wid_reg_val);
+
+ /* Schedule the window transfer. */
+ DACCFG_WRITE(dac, FFBDAC_CFG_WTCTRL,
+ (FFBDAC_CFG_WTCTRL_TCMD | FFBDAC_CFG_WTCTRL_TE));
+
+ {
+ int limit = 1000000;
+ while (limit--) {
+ unsigned int wtctrl = DACCFG_READ(dac, FFBDAC_CFG_WTCTRL);
+
+ if ((wtctrl & FFBDAC_CFG_WTCTRL_DS) == 0)
+ break;
+ }
+ }
+#endif
+
+ UNLOCK_HARDWARE(fmesa);
+}
+
+static void ffb_init_wid(ffbContextPtr fmesa, unsigned int wid)
+{
+ ffb_dacPtr dac = fmesa->ffbScreen->dac;
+ unsigned int wid_reg_val, dac_db_bit, active_dac_addr;
+ unsigned int shadow_dac_addr;
+
+ if (fmesa->ffb_sarea->flags & FFB_DRI_PAC1) {
+ shadow_dac_addr = FFBDAC_PAC1_SPWLUT(wid);
+ active_dac_addr = FFBDAC_PAC1_APWLUT(wid);
+ dac_db_bit = FFBDAC_PAC1_WLUT_DB;
+ } else {
+ shadow_dac_addr = FFBDAC_PAC2_SPWLUT(wid);
+ active_dac_addr = FFBDAC_PAC2_APWLUT(wid);
+ dac_db_bit = FFBDAC_PAC2_WLUT_DB;
+ }
+
+ wid_reg_val = DACCFG_READ(dac, active_dac_addr);
+ wid_reg_val &= ~dac_db_bit;
+#ifdef USE_FAST_SWAP
+ DACCFG_WRITE(dac, active_dac_addr, wid_reg_val);
+#else
+ DACCFG_WRITE(dac, shadow_dac_addr, wid_reg_val);
+
+ /* Schedule the window transfer. */
+ DACCFG_WRITE(dac, FFBDAC_CFG_WTCTRL,
+ (FFBDAC_CFG_WTCTRL_TCMD | FFBDAC_CFG_WTCTRL_TE));
+
+ {
+ int limit = 1000000;
+ while (limit--) {
+ unsigned int wtctrl = DACCFG_READ(dac, FFBDAC_CFG_WTCTRL);
+
+ if ((wtctrl & FFBDAC_CFG_WTCTRL_DS) == 0)
+ break;
+ }
+ }
+#endif
+}
+
+/* Force the context `c' to be the current context and associate with it
+ buffer `b' */
+static GLboolean
+ffbMakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
+{
+ if (driContextPriv) {
+ ffbContextPtr fmesa = (ffbContextPtr) driContextPriv->driverPrivate;
+ int first_time;
+
+ fmesa->driDrawable = driDrawPriv;
+
+ _mesa_make_current(fmesa->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate);
+
+ first_time = 0;
+ if (fmesa->wid == ~0) {
+ first_time = 1;
+ if (getenv("LIBGL_SOFTWARE_RENDERING"))
+ FALLBACK( fmesa->glCtx, FFB_BADATTR_SWONLY, GL_TRUE );
+ }
+
+ LOCK_HARDWARE(fmesa);
+ if (first_time) {
+ fmesa->wid = fmesa->ffb_sarea->wid_table[driDrawPriv->index];
+ ffb_init_wid(fmesa, fmesa->wid);
+ }
+
+ fmesa->state_dirty |= FFB_STATE_ALL;
+ fmesa->state_fifo_ents = fmesa->state_all_fifo_ents;
+ ffbSyncHardware(fmesa);
+ UNLOCK_HARDWARE(fmesa);
+
+ if (first_time) {
+ /* Also, at the first switch to a new context,
+ * we need to clear all the hw buffers.
+ */
+ ffbDDClear(fmesa->glCtx,
+ (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT |
+ BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL),
+ 1, 0, 0, 0, 0);
+ }
+ } else {
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ return GL_TRUE;
+}
+
+/* Force the context `c' to be unbound from its buffer */
+static GLboolean
+ffbUnbindContext(__DRIcontextPrivate *driContextPriv)
+{
+ return GL_TRUE;
+}
+
+void ffbXMesaUpdateState(ffbContextPtr fmesa)
+{
+ __DRIdrawablePrivate *dPriv = fmesa->driDrawable;
+ __DRIscreenPrivate *sPriv = fmesa->driScreen;
+ int stamp = dPriv->lastStamp;
+
+ DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
+
+ if (dPriv->lastStamp != stamp) {
+ GLcontext *ctx = fmesa->glCtx;
+
+ ffbCalcViewport(ctx);
+ if (ctx->Polygon.StippleFlag)
+ ffbXformAreaPattern(fmesa,
+ (const GLubyte *)ctx->PolygonStipple);
+ }
+}
+
+static const struct __DriverAPIRec ffbAPI = {
+ .InitDriver = ffbInitDriver,
+ .DestroyScreen = ffbDestroyScreen,
+ .CreateContext = ffbCreateContext,
+ .DestroyContext = ffbDestroyContext,
+ .CreateBuffer = ffbCreateBuffer,
+ .DestroyBuffer = ffbDestroyBuffer,
+ .SwapBuffers = ffbSwapBuffers,
+ .MakeCurrent = ffbMakeCurrent,
+ .UnbindContext = ffbUnbindContext,
+ .GetSwapInfo = NULL,
+ .GetMSC = NULL,
+ .WaitForMSC = NULL,
+ .WaitForSBC = NULL,
+ .SwapBuffersMSC = NULL
+};
+
+
+static __GLcontextModes *
+ffbFillInModes( unsigned pixel_bits, unsigned depth_bits,
+ unsigned stencil_bits, GLboolean have_back_buffer )
+{
+ __GLcontextModes * modes;
+ __GLcontextModes * m;
+ unsigned num_modes;
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ GLenum fb_format;
+ GLenum fb_type;
+
+ /* GLX_SWAP_COPY_OML is only supported because the FFB driver doesn't
+ * support pageflipping at all.
+ */
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
+ };
+
+ u_int8_t depth_bits_array[3];
+ u_int8_t stencil_bits_array[3];
+
+
+ depth_bits_array[0] = 0;
+ depth_bits_array[1] = depth_bits;
+ depth_bits_array[2] = depth_bits;
+
+ /* Just like with the accumulation buffer, always provide some modes
+ * with a stencil buffer. It will be a sw fallback, but some apps won't
+ * care about that.
+ */
+ stencil_bits_array[0] = 0;
+ stencil_bits_array[1] = 0;
+ stencil_bits_array[2] = (stencil_bits == 0) ? 8 : stencil_bits;
+
+ depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1;
+ back_buffer_factor = (have_back_buffer) ? 3 : 1;
+
+ num_modes = depth_buffer_factor * back_buffer_factor * 4;
+
+ if ( pixel_bits == 16 ) {
+ fb_format = GL_RGB;
+ fb_type = GL_UNSIGNED_SHORT_5_6_5;
+ }
+ else {
+ fb_format = GL_BGRA;
+ fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ }
+
+ modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
+ m = modes;
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_TRUE_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_DIRECT_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+
+
+ /* Mark the visual as slow if there are "fake" stencil bits.
+ */
+ for ( m = modes ; m != NULL ; m = m->next ) {
+ if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) {
+ m->visualRating = GLX_SLOW_CONFIG;
+ }
+ }
+
+ return modes;
+}
+
+
+/**
+ * This is the bootstrap function for the driver. libGL supplies all of the
+ * requisite information about the system, and the driver initializes itself.
+ * This routine also fills in the linked list pointed to by \c driver_modes
+ * with the \c __GLcontextModes that the driver can support for windows or
+ * pbuffers.
+ *
+ * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
+ * failure.
+ */
+PUBLIC
+void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
+ const __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drmAddress pSAREA, int fd,
+ int internal_api_version,
+ const __DRIinterfaceMethods * interface,
+ __GLcontextModes ** driver_modes )
+
+{
+ __DRIscreenPrivate *psp;
+ static const __DRIversion ddx_expected = { 0, 1, 1 };
+ static const __DRIversion dri_expected = { 4, 0, 0 };
+ static const __DRIversion drm_expected = { 0, 0, 1 };
+
+ dri_interface = interface;
+
+ if ( ! driCheckDriDdxDrmVersions2( "ffb",
+ dri_version, & dri_expected,
+ ddx_version, & ddx_expected,
+ drm_version, & drm_expected ) ) {
+ return NULL;
+ }
+
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &ffbAPI);
+ if ( psp != NULL ) {
+ *driver_modes = ffbFillInModes( 32, 16, 0, GL_TRUE );
+ }
+
+ return (void *) psp;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_xmesa.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_xmesa.h
new file mode 100644
index 000000000..b7580780a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/ffb_xmesa.h
@@ -0,0 +1,26 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/ffb/ffb_xmesa.h,v 1.2 2002/02/22 21:32:59 dawes Exp $ */
+
+#ifndef _FFB_XMESA_H_
+#define _FFB_XMESA_H_
+
+#include <sys/time.h>
+#include "dri_util.h"
+#include "mtypes.h"
+#include "ffb_drishare.h"
+#include "ffb_regs.h"
+#include "ffb_dac.h"
+#include "ffb_fifo.h"
+
+typedef struct {
+ __DRIscreenPrivate *sPriv;
+ ffb_fbcPtr regs;
+ ffb_dacPtr dac;
+ volatile char *sfb8r;
+ volatile char *sfb32;
+ volatile char *sfb64;
+
+ int fifo_cache;
+ int rp_active;
+} ffbScreenPrivate;
+
+#endif /* !(_FFB_XMESA_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/server/ffb_dac.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/server/ffb_dac.h
new file mode 100644
index 000000000..08114282e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/server/ffb_dac.h
@@ -0,0 +1,367 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - DAC register layout.
+ *
+ * Copyright (C) 2000 David S. Miller (davem@redhat.com)
+ *
+ * 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
+ * DAVID MILLER 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.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dac.h,v 1.2 2001/04/05 17:42:33 dawes Exp $ */
+
+#ifndef _FFB_DAC_H
+#define _FFB_DAC_H
+
+#define Bool int
+
+/* FFB utilizes two different ramdac chips:
+ *
+ * 1) BT9068 "Pacifica1", used in all FFB1 and
+ * FFB2 boards.
+ *
+ * 2) BT498(a) "Pacifica2", used in FFB2+ and
+ * AFB boards.
+ *
+ * They are mostly equivalent, except in a few key areas:
+ *
+ * 1) WID register layout
+ * 2) Number of CLUT tables
+ * 3) Presence of Window Address Mask register
+ * 4) Method of GAMMA correction support
+ */
+
+/* NOTE: All addresses described in this file are DAC
+ * indirect addresses.
+ */
+
+/* DAC color values are in the following format. */
+#define FFBDAC_COLOR_BLUE 0x00ff0000
+#define FFBDAC_COLOR_BLUE_SHFT 16
+#define FFBDAC_COLOR_GREEN 0x0000ff00
+#define FFBDAC_COLOR_GREEN_SHFT 8
+#define FFBDAC_COLOR_RED 0x000000ff
+#define FFBDAC_COLOR_RED_SHFT 0
+
+/* Cursor DAC register addresses. */
+#define FFBDAC_CUR_BITMAP_P0 0x000 /* Plane 0 cursor bitmap */
+#define FFBDAC_CUR_BITMAP_P1 0x080 /* Plane 1 cursor bitmap */
+#define FFBDAC_CUR_CTRL 0x100 /* Cursor control */
+#define FFBDAC_CUR_COLOR0 0x101 /* Cursor Color 0 */
+#define FFBDAC_CUR_COLOR1 0x102 /* Cursor Color 1 (bg) */
+#define FFBDAC_CUR_COLOR2 0x103 /* Cursor Color 2 (fg) */
+#define FFBDAC_CUR_POS 0x104 /* Active cursor position */
+
+/* Cursor control register.
+ * WARNING: Be careful, reverse logic on these bits.
+ */
+#define FFBDAC_CUR_CTRL_P0 0x00000001 /* Plane0 display disable */
+#define FFBDAC_CUR_CTRL_P1 0x00000002 /* Plane1 display disable */
+
+/* Active cursor position register */
+#define FFBDAC_CUR_POS_Y_SIGN 0x80000000 /* Sign of Y position */
+#define FFBDAC_CUR_POS_Y 0x0fff0000 /* Y position */
+#define FFBDAC_CUR_POS_X_SIGN 0x00008000 /* Sign of X position */
+#define FFBDAC_CUR_POS_X 0x00000fff /* X position */
+
+/* Configuration and Palette DAC register addresses. */
+#define FFBDAC_CFG_PPLLCTRL 0x0000 /* Pixel PLL Control */
+#define FFBDAC_CFG_GPLLCTRL 0x0001 /* General Purpose PLL Control */
+#define FFBDAC_CFG_PFCTRL 0x1000 /* Pixel Format Control */
+#define FFBDAC_CFG_UCTRL 0x1001 /* User Control */
+#define FFBDAC_CFG_CLUP_BASE 0x2000 /* Color Lookup Palette */
+#define FFBDAC_CFG_CLUP(entry) (FFBDAC_CFG_CLUP_BASE + ((entry) * 0x100))
+#define FFBDAC_PAC2_SOVWLUT0 0x3100 /* Shadow Overlay Window Lookup 0*/
+#define FFBDAC_PAC2_SOVWLUT1 0x3101 /* Shadow Overlay Window Lookup 1*/
+#define FFBDAC_PAC2_SOVWLUT2 0x3102 /* Shadow Overlay Window Lookup 2*/
+#define FFBDAC_PAC2_SOVWLUT3 0x3103 /* Shadow Overlay Window Lookup 3*/
+#define FFBDAC_PAC2_AOVWLUT0 0x3210 /* Active Overlay Window Lookup 0*/
+#define FFBDAC_PAC2_AOVWLUT1 0x3211 /* Active Overlay Window Lookup 1*/
+#define FFBDAC_PAC2_AOVWLUT2 0x3212 /* Active Overlay Window Lookup 2*/
+#define FFBDAC_PAC2_AOVWLUT3 0x3213 /* Active Overlay Window Lookup 3*/
+#define FFBDAC_CFG_WTCTRL 0x3150 /* Window Transfer Control */
+#define FFBDAC_CFG_TMCTRL 0x3151 /* Transparent Mask Control */
+#define FFBDAC_CFG_TCOLORKEY 0x3152 /* Transparent Color Key */
+#define FFBDAC_CFG_WAMASK 0x3153 /* Window Address Mask (PAC2 only) */
+#define FFBDAC_PAC1_SPWLUT_BASE 0x3100 /* Shadow Primary Window Lookups */
+#define FFBDAC_PAC1_SPWLUT(entry) (FFBDAC_PAC1_SPWLUT_BASE + (entry))
+#define FFBDAC_PAC1_APWLUT_BASE 0x3120 /* Active Primary Window Lookups */
+#define FFBDAC_PAC1_APWLUT(entry) (FFBDAC_PAC1_APWLUT_BASE + (entry))
+#define FFBDAC_PAC2_SPWLUT_BASE 0x3200 /* Shadow Primary Window Lookups */
+#define FFBDAC_PAC2_SPWLUT(entry) (FFBDAC_PAC2_SPWLUT_BASE + (entry))
+#define FFBDAC_PAC2_APWLUT_BASE 0x3240 /* Active Primary Window Lookups */
+#define FFBDAC_PAC2_APWLUT(entry) (FFBDAC_PAC2_APWLUT_BASE + (entry))
+#define FFBDAC_CFG_SANAL 0x5000 /* Signature Analysis Control */
+#define FFBDAC_CFG_DACCTRL 0x5001 /* DAC Control */
+#define FFBDAC_CFG_TGEN 0x6000 /* Timing Generator Control */
+#define FFBDAC_CFG_VBNP 0x6001 /* Vertical Blank Negation Point */
+#define FFBDAC_CFG_VBAP 0x6002 /* Vertical Blank Assertion Point*/
+#define FFBDAC_CFG_VSNP 0x6003 /* Vertical Sync Negation Point */
+#define FFBDAC_CFG_VSAP 0x6004 /* Vertical Sync Assertion Point */
+#define FFBDAC_CFG_HSNP 0x6005 /* Horz Serration Negation Point */
+#define FFBDAC_CFG_HBNP 0x6006 /* Horz Blank Negation Point */
+#define FFBDAC_CFG_HBAP 0x6007 /* Horz Blank Assertion Point */
+#define FFBDAC_CFG_HSYNCNP 0x6008 /* Horz Sync Negation Point */
+#define FFBDAC_CFG_HSYNCAP 0x6009 /* Horz Sync Assertion Point */
+#define FFBDAC_CFG_HSCENNP 0x600A /* Horz SCEN Negation Point */
+#define FFBDAC_CFG_HSCENAP 0x600B /* Horz SCEN Assertion Point */
+#define FFBDAC_CFG_EPNP 0x600C /* Eql'zing Pulse Negation Point */
+#define FFBDAC_CFG_EINP 0x600D /* Eql'zing Intvl Negation Point */
+#define FFBDAC_CFG_EIAP 0x600E /* Eql'zing Intvl Assertion Point*/
+#define FFBDAC_CFG_TGVC 0x600F /* Timing Generator Vert Counter */
+#define FFBDAC_CFG_TGHC 0x6010 /* Timing Generator Horz Counter */
+#define FFBDAC_CFG_DID 0x8000 /* Device Identification */
+#define FFBDAC_CFG_MPDATA 0x8001 /* Monitor Port Data */
+#define FFBDAC_CFG_MPSENSE 0x8002 /* Monitor Port Sense */
+
+/* Pixel PLL Control Register */
+#define FFBDAC_CFG_PPLLCTRL_M 0x0000007f /* PLL VCO Multiplicand */
+#define FFBDAC_CFG_PPLLCTRL_D 0x00000780 /* PLL VCO Divisor */
+#define FFBDAC_CFG_PPLLCTRL_PFD 0x00001800 /* Post VCO Frequency Divider */
+#define FFBDAC_CFG_PPLLCTRL_EN 0x00004000 /* Enable PLL as pixel clock src */
+
+/* General Purpose PLL Control Register */
+#define FFBDAC_CFG_GPLLCTRL_M 0x0000007f /* PLL VCO Multiplicand */
+#define FFBDAC_CFG_GPLLCTRL_D 0x00000780 /* PLL VCO Divisor */
+#define FFBDAC_CFG_GPLLCTRL_PFD 0x00001800 /* Post VCO Frequency Divider */
+#define FFBDAC_CFG_GPLLCTRL_EN 0x00004000 /* Enable PLL as Gen. Purpose clk*/
+
+/* Pixel Format Control Register */
+#define FFBDAC_CFG_PFCTRL_2_1 0x00000000 /* 2:1 pixel interleave format */
+#define FFBDAC_CFG_PFCTRL_4_1 0x00000001 /* 4:1 pixel interleave format */
+#define FFBDAC_CFG_PFCTRL_42_1 0x00000002 /* 4/2:1 pixel interleave format */
+#define FFBDAC_CFG_PFCTRL_82_1 0x00000003 /* 8/2:1 pixel interleave format */
+
+/* User Control Register */
+#define FFBDAC_UCTRL_IPDISAB 0x00000001 /* Disable input pullup resistors*/
+#define FFBDAC_UCTRL_ABLANK 0x00000002 /* Asynchronous Blank */
+#define FFBDAC_UCTRL_DBENAB 0x00000004 /* Double-Buffer Enable */
+#define FFBDAC_UCTRL_OVENAB 0x00000008 /* Overlay Enable */
+#define FFBDAC_UCTRL_WMODE 0x00000030 /* Window Mode */
+#define FFBDAC_UCTRL_WM_COMB 0x00000000 /* Window Mode = Combined */
+#define FFBDAC_UCTRL_WM_S4 0x00000010 /* Window Mode = Seperate_4 */
+#define FFBDAC_UCTRL_WM_S8 0x00000020 /* Window Mode = Seperate_8 */
+#define FFBDAC_UCTRL_WM_RESV 0x00000030 /* Window Mode = reserved */
+#define FFBDAC_UCTRL_MANREV 0x00000f00 /* 4-bit Manufacturing Revision */
+
+/* Overlay Window Lookup Registers (PAC2 only) */
+#define FFBDAC_CFG_OVWLUT_PSEL 0x0000000f /* Palette Section, Seperate_4 */
+#define FFBDAC_CFG_OVWLUT_PTBL 0x00000030 /* Palette Table */
+#define FFBDAC_CFG_OVWLUT_LKUP 0x00000100 /* 1 = Use palette, 0 = Bypass */
+#define FFBDAC_CFG_OVWLUT_OTYP 0x00000c00 /* Overlay Type */
+#define FFBDAC_CFG_OVWLUT_O_N 0x00000000 /* Overlay Type - None */
+#define FFBDAC_CFG_OVWLUT_O_T 0x00000400 /* Overlay Type - Transparent */
+#define FFBDAC_CFG_OVWLUT_O_O 0x00000800 /* Overlay Type - Opaque */
+#define FFBDAC_CFG_OVWLUT_O_R 0x00000c00 /* Overlay Type - Reserved */
+#define FFBDAC_CFG_OVWLUT_PCS 0x00003000 /* Psuedocolor Src */
+#define FFBDAC_CFG_OVWLUT_P_XO 0x00000000 /* Psuedocolor Src - XO[7:0] */
+#define FFBDAC_CFG_OVWLUT_P_R 0x00001000 /* Psuedocolor Src - R[7:0] */
+#define FFBDAC_CFG_OVWLUT_P_G 0x00002000 /* Psuedocolor Src - G[7:0] */
+#define FFBDAC_CFG_OVWLUT_P_B 0x00003000 /* Psuedocolor Src - B[7:0] */
+
+/* Window Transfer Control Register */
+#define FFBDAC_CFG_WTCTRL_DS 0x00000001 /* Device Status, 1 = Busy */
+#define FFBDAC_CFG_WTCTRL_TCMD 0x00000002 /* Transfer Command
+ * 1 = Transfer, 0 = No Action
+ */
+#define FFBDAC_CFG_WTCTRL_TE 0x00000004 /* Transfer Event
+ * 1 = Next Frame, 0 = Next Field
+ */
+#define FFBDAC_CFG_WTCTRL_DRD 0x00000008 /* Drawing Data
+ * 1 = Local Drawing Active
+ * 0 = Local Drawing Idle
+ */
+#define FFBDAC_CFG_WTCTRL_DRS 0x00000010 /* Drawing Status
+ * 1 = Network Drawing Active
+ * 0 = Network Drawing Idle
+ */
+
+/* Transparent Mask Control Register */
+#define FFBDAC_CFG_TMCTRL_OMSK 0x000000ff /* Overlay Mask */
+
+/* Transparent Color Key Register */
+#define FFBDAC_CFG_TCOLORKEY_K 0x000000ff /* Overlay Color Key */
+
+/* Window Address Mask Register (PAC2 only) */
+#define FFBDAC_CFG_WAMASK_PMSK 0x0000003f /* PWLUT select PMASK */
+#define FFBDAC_CFG_WAMASK_OMSK 0x00000300 /* OWLUT control OMASK */
+
+/* (non-Overlay) Window Lookup Table Registers, PAC1 format */
+#define FFBDAC_PAC1_WLUT_DB 0x00000020 /* 0 = Buffer A, 1 = Buffer B */
+#define FFBDAC_PAC1_WLUT_C 0x0000001c /* C: Color Model Selection */
+#define FFBDAC_PAC1_WLUT_C_8P 0x00000000 /* C: 8bpp Pseudocolor */
+#define FFBDAC_PAC1_WLUT_C_8LG 0x00000004 /* C: 8bpp Linear Grey */
+#define FFBDAC_PAC1_WLUT_C_8NG 0x00000008 /* C: 8bpp Non-Linear Grey */
+#define FFBDAC_PAC1_WLUT_C_24D 0x00000010 /* C: 24bpp Directcolor */
+#define FFBDAC_PAC1_WLUT_C_24LT 0x00000014 /* C: 24bpp Linear Truecolor */
+#define FFBDAC_PAC1_WLUT_C_24NT 0x00000018 /* C: 24bpp Non-Linear Truecolor */
+#define FFBDAC_PAC1_WLUT_PCS 0x00000003 /* Pseudocolor Src */
+#define FFBDAC_PAC1_WLUT_P_XO 0x00000000 /* Pseudocolor Src - XO[7:0] */
+#define FFBDAC_PAC1_WLUT_P_R 0x00000001 /* Pseudocolor Src - R[7:0] */
+#define FFBDAC_PAC1_WLUT_P_G 0x00000002 /* Pseudocolor Src - G[7:0] */
+#define FFBDAC_PAC1_WLUT_P_B 0x00000003 /* Pseudocolor Src - B[7:0] */
+
+/* (non-Overlay) Window Lookup Table Registers, PAC2 format */
+#define FFBDAC_PAC2_WLUT_PTBL 0x00000030 /* Palette Table Entry */
+#define FFBDAC_PAC2_WLUT_LKUP 0x00000100 /* 1 = Use palette, 0 = Bypass */
+#define FFBDAC_PAC2_WLUT_PCS 0x00003000 /* Pseudocolor Src */
+#define FFBDAC_PAC2_WLUT_P_XO 0x00000000 /* Pseudocolor Src - XO[7:0] */
+#define FFBDAC_PAC2_WLUT_P_R 0x00001000 /* Pseudocolor Src - R[7:0] */
+#define FFBDAC_PAC2_WLUT_P_G 0x00002000 /* Pseudocolor Src - G[7:0] */
+#define FFBDAC_PAC2_WLUT_P_B 0x00003000 /* Pseudocolor Src - B[7:0] */
+#define FFBDAC_PAC2_WLUT_DEPTH 0x00004000 /* 0 = Pseudocolor, 1 = Truecolor*/
+#define FFBDAC_PAC2_WLUT_DB 0x00008000 /* 0 = Buffer A, 1 = Buffer B */
+
+/* Signature Analysis Control Register */
+#define FFBDAC_CFG_SANAL_SRR 0x000000ff /* DAC Seed/Result for Red */
+#define FFBDAC_CFG_SANAL_SRG 0x0000ff00 /* DAC Seed/Result for Green */
+#define FFBDAC_CFG_SANAL_SRB 0x00ff0000 /* DAC Seed/Result for Blue */
+#define FFBDAC_CFG_SANAL_RQST 0x01000000 /* Signature Capture Request */
+#define FFBDAC_CFG_SANAL_BSY 0x02000000 /* Signature Analysis Busy */
+#define FFBDAC_CFG_SANAL_DSM 0x04000000 /* Data Strobe Mode
+ * 0 = Signature Analysis Mode
+ * 1 = Data Strobe Mode
+ */
+
+/* DAC Control Register */
+#define FFBDAC_CFG_DACCTRL_O2 0x00000003 /* Operand 2 Select
+ * 00 = Normal Operation
+ * 01 = Select 145mv Reference
+ * 10 = Select Blue DAC Output
+ * 11 = Reserved
+ */
+#define FFBDAC_CFG_DACCTRL_O1 0x0000000c /* Operand 1 Select
+ * 00 = Normal Operation
+ * 01 = Select Green DAC Output
+ * 10 = Select Red DAC Output
+ * 11 = Reserved
+ */
+#define FFBDAC_CFG_DACCTRL_CR 0x00000010 /* Comparator Result
+ * 0 = operand1 < operand2
+ * 1 = operand1 > operand2
+ */
+#define FFBDAC_CFG_DACCTRL_SGE 0x00000020 /* Sync-on-Green Enable */
+#define FFBDAC_CFG_DACCTRL_PE 0x00000040 /* Pedestal Enable */
+#define FFBDAC_CFG_DACCTRL_VPD 0x00000080 /* VSYNC* Pin Disable */
+#define FFBDAC_CFG_DACCTRL_SPB 0x00000100 /* Sync Polarity Bit
+ * 0 = VSYNC* and CSYNC* active low
+ * 1 = VSYNC* and CSYNC* active high
+ */
+
+/* Timing Generator Control Register */
+#define FFBDAC_CFG_TGEN_VIDE 0x00000001 /* Video Enable */
+#define FFBDAC_CFG_TGEN_TGE 0x00000002 /* Timing Generator Enable */
+#define FFBDAC_CFG_TGEN_HSD 0x00000004 /* HSYNC* Disabled */
+#define FFBDAC_CFG_TGEN_VSD 0x00000008 /* VSYNC* Disabled */
+#define FFBDAC_CFG_TGEN_EQD 0x00000010 /* Equalization Disabled */
+#define FFBDAC_CFG_TGEN_MM 0x00000020 /* 0 = Slave, 1 = Master */
+#define FFBDAC_CFG_TGEN_IM 0x00000040 /* 1 = Interlaced Mode */
+
+/* Device Identification Register, should be 0xA236E1AD for FFB bt497/bt498 */
+#define FFBDAC_CFG_DID_ONE 0x00000001 /* Always set */
+#define FFBDAC_CFG_DID_MANUF 0x00000ffe /* Manufacturer ID */
+#define FFBDAC_CFG_DID_PNUM 0x0ffff000 /* Device Part Number */
+#define FFBDAC_CFG_DID_REV 0xf0000000 /* Device Revision */
+
+/* Monitor Port Data Register */
+#define FFBDAC_CFG_MPDATA_SCL 0x00000001 /* SCL Data */
+#define FFBDAC_CFG_MPDATA_SDA 0x00000002 /* SDA Data */
+
+/* Monitor Port Sense Register */
+#define FFBDAC_CFG_MPSENSE_SCL 0x00000001 /* SCL Sense */
+#define FFBDAC_CFG_MPSENSE_SDA 0x00000002 /* SDA Sense */
+
+/* DAC register access shorthands. */
+#define DACCUR_READ(DAC, ADDR) ((DAC)->cur = (ADDR), (DAC)->curdata)
+#define DACCUR_WRITE(DAC, ADDR, VAL) ((DAC)->cur = (ADDR), (DAC)->curdata = (VAL))
+#define DACCFG_READ(DAC, ADDR) ((DAC)->cfg = (ADDR), (DAC)->cfgdata)
+#define DACCFG_WRITE(DAC, ADDR, VAL) ((DAC)->cfg = (ADDR), (DAC)->cfgdata = (VAL))
+
+typedef struct ffb_dac_hwstate {
+ unsigned int ppllctrl;
+ unsigned int gpllctrl;
+ unsigned int pfctrl;
+ unsigned int uctrl;
+ unsigned int clut[256 * 4]; /* One 256 entry clut on PAC1, 4 on PAC2 */
+ unsigned int ovluts[4]; /* Overlay WLUTS, PAC2 only */
+ unsigned int wtctrl;
+ unsigned int tmctrl;
+ unsigned int tcolorkey;
+ unsigned int wamask;
+ unsigned int pwluts[64];
+ unsigned int dacctrl;
+ unsigned int tgen;
+ unsigned int vbnp;
+ unsigned int vbap;
+ unsigned int vsnp;
+ unsigned int vsap;
+ unsigned int hsnp;
+ unsigned int hbnp;
+ unsigned int hbap;
+ unsigned int hsyncnp;
+ unsigned int hsyncap;
+ unsigned int hscennp;
+ unsigned int hscenap;
+ unsigned int epnp;
+ unsigned int einp;
+ unsigned int eiap;
+} ffb_dac_hwstate_t;
+
+typedef struct {
+ Bool InUse;
+
+ /* The following fields are undefined unless InUse is TRUE. */
+ int refcount;
+ Bool canshare;
+ unsigned int wlut_regval;
+ int buffer; /* 0 = Buffer A, 1 = Buffer B */
+ int depth; /* 8 or 32 bpp */
+ int greyscale; /* 1 = greyscale, 0 = color */
+ int linear; /* 1 = linear, 0 = non-linear */
+ int direct; /* 1 = 24bpp directcolor */
+ int channel; /* 0 = X, 1 = R, 2 = G, 3 = B */
+ int palette; /* Only PAC2 has multiple CLUTs */
+} ffb_wid_info_t;
+
+#define FFB_MAX_PWIDS 64
+typedef struct {
+ int num_wids;
+ int wid_shift; /* To get X channel value */
+ ffb_wid_info_t wid_pool[FFB_MAX_PWIDS];
+} ffb_wid_pool_t;
+
+typedef struct ffb_dac_info {
+ unsigned int flags;
+#define FFB_DAC_PAC1 0x00000001 /* Pacifica1 DAC, BT9068 */
+#define FFB_DAC_PAC2 0x00000002 /* Pacifica2 DAC, BT498 */
+#define FFB_DAC_ICURCTL 0x00000004 /* Inverted CUR_CTRL bits */
+
+ unsigned int kernel_wid;
+
+ /* These registers need to be modified when changing DAC
+ * timing state, so at init time we capture their values.
+ */
+ unsigned int ffbcfg0;
+ unsigned int ffbcfg2;
+ unsigned int ffb_passin_ctrl; /* FFB2+/AFB only */
+
+ ffb_dac_hwstate_t kern_dac_state;
+ ffb_dac_hwstate_t x_dac_state;
+
+ ffb_wid_pool_t wid_table;
+} ffb_dac_info_t;
+
+#endif /* _FFB_DAC_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/server/ffb_drishare.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/server/ffb_drishare.h
new file mode 100644
index 000000000..baf2f0d0a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/server/ffb_drishare.h
@@ -0,0 +1,48 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_drishare.h,v 1.2 2000/06/21 00:47:37 dawes Exp $ */
+
+#ifndef _FFB_DRISHARE_H
+#define _FFB_DRISHARE_H
+
+typedef struct ffb_dri_state {
+ int flags;
+#define FFB_DRI_FFB2 0x00000001
+#define FFB_DRI_FFB2PLUS 0x00000002
+#define FFB_DRI_PAC1 0x00000004
+#define FFB_DRI_PAC2 0x00000008
+
+ /* Indexed by DRI drawable id. */
+#define FFB_DRI_NWIDS 64
+ unsigned int wid_table[FFB_DRI_NWIDS];
+} ffb_dri_state_t;
+
+#define FFB_DRISHARE(SAREA) \
+ ((ffb_dri_state_t *) (((char *)(SAREA)) + sizeof(drm_sarea_t)))
+
+typedef struct {
+ drm_handle_t hFbcRegs;
+ drmSize sFbcRegs;
+
+ drm_handle_t hDacRegs;
+ drmSize sDacRegs;
+
+ drm_handle_t hSfb8r;
+ drmSize sSfb8r;
+
+ drm_handle_t hSfb32;
+ drmSize sSfb32;
+
+ drm_handle_t hSfb64;
+ drmSize sSfb64;
+
+ /* Fastfill/Pagefill parameters. */
+ unsigned char disable_pagefill;
+ int fastfill_small_area;
+ int pagefill_small_area;
+ int fastfill_height;
+ int fastfill_width;
+ int pagefill_height;
+ int pagefill_width;
+ short Pf_AlignTab[0x800];
+} FFBDRIRec, *FFBDRIPtr;
+
+#endif /* !(_FFB_DRISHARE_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/server/ffb_regs.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/server/ffb_regs.h
new file mode 100644
index 000000000..7f383d38d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/ffb/server/ffb_regs.h
@@ -0,0 +1,509 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - register layout.
+ *
+ * Copyright (C) 1998,1999,2000 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1998 Michal Rehacek (majkl@iname.com)
+ * Copyright (C) 1999 David S. Miller (davem@redhat.com)
+ *
+ * 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
+ * JAKUB JELINEK, MICHAL REHACEK, OR DAVID MILLER 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.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_regs.h,v 1.1 2000/05/18 23:21:37 dawes Exp $ */
+
+#ifndef FFBREGS_H
+#define FFBREGS_H
+
+/* Auxilliary clips. */
+typedef struct {
+ volatile unsigned int min;
+ volatile unsigned int max;
+} ffb_auxclip, *ffb_auxclipPtr;
+
+/* FFB register set. */
+typedef struct _ffb_fbc {
+ /* Next vertex registers, on the right we list which drawops
+ * use said register and the logical name the register has in
+ * that context.
+ */ /* DESCRIPTION DRAWOP(NAME) */
+/*0x00*/unsigned int pad1[3]; /* Reserved */
+/*0x0c*/volatile unsigned int alpha; /* ALPHA Transparency */
+/*0x10*/volatile unsigned int red; /* RED */
+/*0x14*/volatile unsigned int green; /* GREEN */
+/*0x18*/volatile unsigned int blue; /* BLUE */
+/*0x1c*/volatile unsigned int z; /* DEPTH */
+/*0x20*/volatile unsigned int y; /* Y triangle(DOYF) */
+ /* aadot(DYF) */
+ /* ddline(DYF) */
+ /* aaline(DYF) */
+/*0x24*/volatile unsigned int x; /* X triangle(DOXF) */
+ /* aadot(DXF) */
+ /* ddline(DXF) */
+ /* aaline(DXF) */
+/*0x28*/unsigned int pad2[2]; /* Reserved */
+/*0x30*/volatile unsigned int ryf; /* Y (alias to DOYF) ddline(RYF) */
+ /* aaline(RYF) */
+ /* triangle(RYF) */
+/*0x34*/volatile unsigned int rxf; /* X ddline(RXF) */
+ /* aaline(RXF) */
+ /* triangle(RXF) */
+/*0x38*/unsigned int pad3[2]; /* Reserved */
+/*0x40*/volatile unsigned int dmyf; /* Y (alias to DOYF) triangle(DMYF) */
+/*0x44*/volatile unsigned int dmxf; /* X triangle(DMXF) */
+/*0x48*/unsigned int pad4[2]; /* Reserved */
+/*0x50*/volatile unsigned int ebyi; /* Y (alias to RYI) polygon(EBYI) */
+/*0x54*/volatile unsigned int ebxi; /* X polygon(EBXI) */
+/*0x58*/unsigned int pad5[2]; /* Reserved */
+/*0x60*/volatile unsigned int by; /* Y brline(RYI) */
+ /* fastfill(OP) */
+ /* polygon(YI) */
+ /* rectangle(YI) */
+ /* bcopy(SRCY) */
+ /* vscroll(SRCY) */
+/*0x64*/volatile unsigned int bx; /* X brline(RXI) */
+ /* polygon(XI) */
+ /* rectangle(XI) */
+ /* bcopy(SRCX) */
+ /* vscroll(SRCX) */
+ /* fastfill(GO) */
+/*0x68*/volatile unsigned int dy; /* destination Y fastfill(DSTY) */
+ /* bcopy(DSRY) */
+ /* vscroll(DSRY) */
+/*0x6c*/volatile unsigned int dx; /* destination X fastfill(DSTX) */
+ /* bcopy(DSTX) */
+ /* vscroll(DSTX) */
+/*0x70*/volatile unsigned int bh; /* Y (alias to RYI) brline(DYI) */
+ /* dot(DYI) */
+ /* polygon(ETYI) */
+ /* Height fastfill(H) */
+ /* bcopy(H) */
+ /* vscroll(H) */
+ /* Y count fastfill(NY) */
+/*0x74*/volatile unsigned int bw; /* X dot(DXI) */
+ /* brline(DXI) */
+ /* polygon(ETXI) */
+ /* fastfill(W) */
+ /* bcopy(W) */
+ /* vscroll(W) */
+ /* fastfill(NX) */
+/*0x78*/unsigned int pad6[2]; /* Reserved */
+/*0x80*/unsigned int pad7[32]; /* Reserved */
+
+ /* Setup Unit's vertex state register */
+/*100*/ volatile unsigned int suvtx;
+/*104*/ unsigned int pad8[63]; /* Reserved */
+
+ /* Frame Buffer Control Registers */
+/*200*/ volatile unsigned int ppc; /* Pixel Processor Control */
+/*204*/ volatile unsigned int wid; /* Current WID */
+/*208*/ volatile unsigned int fg; /* FG data */
+/*20c*/ volatile unsigned int bg; /* BG data */
+/*210*/ volatile unsigned int consty; /* Constant Y */
+/*214*/ volatile unsigned int constz; /* Constant Z */
+/*218*/ volatile unsigned int xclip; /* X Clip */
+/*21c*/ volatile unsigned int dcss; /* Depth Cue Scale Slope */
+/*220*/ volatile unsigned int vclipmin; /* Viewclip XY Min Bounds */
+/*224*/ volatile unsigned int vclipmax; /* Viewclip XY Max Bounds */
+/*228*/ volatile unsigned int vclipzmin; /* Viewclip Z Min Bounds */
+/*22c*/ volatile unsigned int vclipzmax; /* Viewclip Z Max Bounds */
+/*230*/ volatile unsigned int dcsf; /* Depth Cue Scale Front Bound */
+/*234*/ volatile unsigned int dcsb; /* Depth Cue Scale Back Bound */
+/*238*/ volatile unsigned int dczf; /* Depth Cue Z Front */
+/*23c*/ volatile unsigned int dczb; /* Depth Cue Z Back */
+/*240*/ unsigned int pad9; /* Reserved */
+/*244*/ volatile unsigned int blendc; /* Alpha Blend Control */
+/*248*/ volatile unsigned int blendc1; /* Alpha Blend Color 1 */
+/*24c*/ volatile unsigned int blendc2; /* Alpha Blend Color 2 */
+/*250*/ volatile unsigned int fbramitc; /* FB RAM Interleave Test Control */
+/*254*/ volatile unsigned int fbc; /* Frame Buffer Control */
+/*258*/ volatile unsigned int rop; /* Raster OPeration */
+/*25c*/ volatile unsigned int cmp; /* Frame Buffer Compare */
+/*260*/ volatile unsigned int matchab; /* Buffer AB Match Mask */
+/*264*/ volatile unsigned int matchc; /* Buffer C(YZ) Match Mask */
+/*268*/ volatile unsigned int magnab; /* Buffer AB Magnitude Mask */
+/*26c*/ volatile unsigned int magnc; /* Buffer C(YZ) Magnitude Mask */
+/*270*/ volatile unsigned int fbcfg0; /* Frame Buffer Config 0 */
+/*274*/ volatile unsigned int fbcfg1; /* Frame Buffer Config 1 */
+/*278*/ volatile unsigned int fbcfg2; /* Frame Buffer Config 2 */
+/*27c*/ volatile unsigned int fbcfg3; /* Frame Buffer Config 3 */
+/*280*/ volatile unsigned int ppcfg; /* Pixel Processor Config */
+/*284*/ volatile unsigned int pick; /* Picking Control */
+/*288*/ volatile unsigned int fillmode; /* FillMode */
+/*28c*/ volatile unsigned int fbramwac; /* FB RAM Write Address Control */
+/*290*/ volatile unsigned int pmask; /* RGB PlaneMask */
+/*294*/ volatile unsigned int xpmask; /* X PlaneMask */
+/*298*/ volatile unsigned int ypmask; /* Y PlaneMask */
+/*29c*/ volatile unsigned int zpmask; /* Z PlaneMask */
+/*2a0*/ ffb_auxclip auxclip[4]; /* Auxilliary Viewport Clip */
+
+ /* New 3dRAM III support regs */
+/*2c0*/ volatile unsigned int rawblend2;
+/*2c4*/ volatile unsigned int rawpreblend;
+/*2c8*/ volatile unsigned int rawstencil;
+/*2cc*/ volatile unsigned int rawstencilctl;
+/*2d0*/ volatile unsigned int threedram1;
+/*2d4*/ volatile unsigned int threedram2;
+/*2d8*/ volatile unsigned int passin;
+/*2dc*/ volatile unsigned int rawclrdepth;
+/*2e0*/ volatile unsigned int rawpmask;
+/*2e4*/ volatile unsigned int rawcsrc;
+/*2e8*/ volatile unsigned int rawmatch;
+/*2ec*/ volatile unsigned int rawmagn;
+/*2f0*/ volatile unsigned int rawropblend;
+/*2f4*/ volatile unsigned int rawcmp;
+/*2f8*/ volatile unsigned int rawwac;
+/*2fc*/ volatile unsigned int fbramid;
+
+/*300*/ volatile unsigned int drawop; /* Draw OPeration */
+/*304*/ unsigned int pad10[2]; /* Reserved */
+/*30c*/ volatile unsigned int lpat; /* Line Pattern control */
+/*310*/ unsigned int pad11; /* Reserved */
+/*314*/ volatile unsigned int fontxy; /* XY Font coordinate */
+/*318*/ volatile unsigned int fontw; /* Font Width */
+/*31c*/ volatile unsigned int fontinc; /* Font Increment */
+/*320*/ volatile unsigned int font; /* Font bits */
+/*324*/ unsigned int pad12[3]; /* Reserved */
+/*330*/ volatile unsigned int blend2;
+/*334*/ volatile unsigned int preblend;
+/*338*/ volatile unsigned int stencil;
+/*33c*/ volatile unsigned int stencilctl;
+
+/*340*/ unsigned int pad13[4]; /* Reserved */
+/*350*/ volatile unsigned int dcss1; /* Depth Cue Scale Slope 1 */
+/*354*/ volatile unsigned int dcss2; /* Depth Cue Scale Slope 2 */
+/*358*/ volatile unsigned int dcss3; /* Depth Cue Scale Slope 3 */
+/*35c*/ volatile unsigned int widpmask;
+/*360*/ volatile unsigned int dcs2;
+/*364*/ volatile unsigned int dcs3;
+/*368*/ volatile unsigned int dcs4;
+/*36c*/ unsigned int pad14; /* Reserved */
+/*370*/ volatile unsigned int dcd2;
+/*374*/ volatile unsigned int dcd3;
+/*378*/ volatile unsigned int dcd4;
+/*37c*/ unsigned int pad15; /* Reserved */
+/*380*/ volatile unsigned int pattern[32]; /* area Pattern */
+/*400*/ unsigned int pad16[8]; /* Reserved */
+/*420*/ volatile unsigned int reset; /* chip RESET */
+/*424*/ unsigned int pad17[247]; /* Reserved */
+/*800*/ volatile unsigned int devid; /* Device ID */
+/*804*/ unsigned int pad18[63]; /* Reserved */
+/*900*/ volatile unsigned int ucsr; /* User Control & Status Register */
+/*904*/ unsigned int pad19[31]; /* Reserved */
+/*980*/ volatile unsigned int mer; /* Mode Enable Register */
+/*984*/ unsigned int pad20[1439]; /* Reserved */
+} ffb_fbc, *ffb_fbcPtr;
+
+/* Draw operations */
+#define FFB_DRAWOP_DOT 0x00
+#define FFB_DRAWOP_AADOT 0x01
+#define FFB_DRAWOP_BRLINECAP 0x02
+#define FFB_DRAWOP_BRLINEOPEN 0x03
+#define FFB_DRAWOP_DDLINE 0x04
+#define FFB_DRAWOP_AALINE 0x05
+#define FFB_DRAWOP_TRIANGLE 0x06
+#define FFB_DRAWOP_POLYGON 0x07
+#define FFB_DRAWOP_RECTANGLE 0x08
+#define FFB_DRAWOP_FASTFILL 0x09
+#define FFB_DRAWOP_BCOPY 0x0a /* Not implemented in any FFB, VIS is faster */
+#define FFB_DRAWOP_VSCROLL 0x0b /* Up to 12x faster than BCOPY, 3-4x faster than VIS */
+
+/* FastFill operation codes. */
+#define FFB_FASTFILL_PAGE 0x01
+#define FFB_FASTFILL_BLOCK 0x02
+#define FFB_FASTFILL_COLOR_BLK 0x03
+#define FFB_FASTFILL_BLOCK_X 0x04
+
+/* Spanfill Unit Line Pattern */
+#define FFB_LPAT_SCALEPTR 0xf0000000
+#define FFB_LPAT_SCALEPTR_SHIFT 28
+#define FFB_LPAT_PATPTR 0x0f000000
+#define FFB_LPAT_PATPTR_SHIFT 24
+#define FFB_LPAT_SCALEVAL 0x00f00000
+#define FFB_LPAT_SCALEVAL_SHIFT 20
+#define FFB_LPAT_PATLEN 0x000f0000
+#define FFB_LPAT_PATLEN_SHIFT 16
+#define FFB_LPAT_PATTERN 0x0000ffff
+#define FFB_LPAT_PATTERN_SHIFT 0
+
+/* Pixel processor control */
+/* Force WID */
+#define FFB_PPC_FW_DISABLE 0x800000
+#define FFB_PPC_FW_ENABLE 0xc00000
+#define FFB_PPC_FW_MASK 0xc00000
+/* Auxiliary clip */
+#define FFB_PPC_ACE_DISABLE 0x040000
+#define FFB_PPC_ACE_AUX_SUB 0x080000
+#define FFB_PPC_ACE_AUX_ADD 0x0c0000
+#define FFB_PPC_ACE_MASK 0x0c0000
+/* Depth cue */
+#define FFB_PPC_DCE_DISABLE 0x020000
+#define FFB_PPC_DCE_ENABLE 0x030000
+#define FFB_PPC_DCE_MASK 0x030000
+/* Alpha blend */
+#define FFB_PPC_ABE_DISABLE 0x008000
+#define FFB_PPC_ABE_ENABLE 0x00c000
+#define FFB_PPC_ABE_MASK 0x00c000
+/* View clip */
+#define FFB_PPC_VCE_DISABLE 0x001000
+#define FFB_PPC_VCE_2D 0x002000
+#define FFB_PPC_VCE_3D 0x003000
+#define FFB_PPC_VCE_MASK 0x003000
+/* Area pattern */
+#define FFB_PPC_APE_DISABLE 0x000800
+#define FFB_PPC_APE_ENABLE 0x000c00
+#define FFB_PPC_APE_MASK 0x000c00
+/* Transparent background */
+#define FFB_PPC_TBE_OPAQUE 0x000200
+#define FFB_PPC_TBE_TRANSPARENT 0x000300
+#define FFB_PPC_TBE_MASK 0x000300
+/* Z source */
+#define FFB_PPC_ZS_VAR 0x000080
+#define FFB_PPC_ZS_CONST 0x0000c0
+#define FFB_PPC_ZS_MASK 0x0000c0
+/* Y source */
+#define FFB_PPC_YS_VAR 0x000020
+#define FFB_PPC_YS_CONST 0x000030
+#define FFB_PPC_YS_MASK 0x000030
+/* X source */
+#define FFB_PPC_XS_WID 0x000004
+#define FFB_PPC_XS_VAR 0x000008
+#define FFB_PPC_XS_CONST 0x00000c
+#define FFB_PPC_XS_MASK 0x00000c
+/* Color (BGR) source */
+#define FFB_PPC_CS_VAR 0x000002
+#define FFB_PPC_CS_CONST 0x000003
+#define FFB_PPC_CS_MASK 0x000003
+
+/* X Clip */
+#define FFB_XCLIP_XREF 0x000000ff
+#define FFB_XCLIP_TEST_MASK 0x00070000
+#define FFB_XCLIP_TEST_ALWAYS 0x00000000
+#define FFB_XCLIP_TEST_GT 0x00010000
+#define FFB_XCLIP_TEST_EQ 0x00020000
+#define FFB_XCLIP_TEST_GE 0x00030000
+#define FFB_XCLIP_TEST_NEVER 0x00040000
+#define FFB_XCLIP_TEST_LE 0x00050000
+#define FFB_XCLIP_TEST_NE 0x00060000
+#define FFB_XCLIP_TEST_LT 0x00070000
+
+/* FB Control register */
+/* Write buffer dest */
+#define FFB_FBC_WB_A 0x20000000
+#define FFB_FBC_WB_B 0x40000000
+#define FFB_FBC_WB_AB 0x60000000
+#define FFB_FBC_WB_C 0x80000000
+#define FFB_FBC_WB_AC 0xa0000000
+#define FFB_FBC_WB_BC 0xc0000000
+#define FFB_FBC_WB_ABC 0xe0000000
+#define FFB_FBC_WB_MASK 0xe0000000
+/* Write enable */
+#define FFB_FBC_WE_FORCEOFF 0x00100000
+#define FFB_FBC_WE_FORCEON 0x00200000
+#define FFB_FBC_WE_USE_WMASK 0x00300000
+#define FFB_FBC_WE_MASK 0x00300000
+/* Write group mode */
+#define FFB_FBC_WM_RSVD 0x00040000
+#define FFB_FBC_WM_COMBINED 0x00080000
+#define FFB_FBC_WM_SEPARATE 0x000c0000
+#define FFB_FBC_WM_MASK 0x000c0000
+/* Read buffer src */
+#define FFB_FBC_RB_A 0x00004000
+#define FFB_FBC_RB_B 0x00008000
+#define FFB_FBC_RB_C 0x0000c000
+#define FFB_FBC_RB_MASK 0x0000c000
+/* Stereo buf dest */
+#define FFB_FBC_SB_LEFT 0x00001000
+#define FFB_FBC_SB_RIGHT 0x00002000
+#define FFB_FBC_SB_BOTH 0x00003000
+#define FFB_FBC_SB_MASK 0x00003000
+/* Z plane group enable */
+#define FFB_FBC_ZE_OFF 0x00000400
+#define FFB_FBC_ZE_ON 0x00000800
+#define FFB_FBC_ZE_MASK 0x00000c00
+/* Y plane group enable */
+#define FFB_FBC_YE_OFF 0x00000100
+#define FFB_FBC_YE_ON 0x00000200
+#define FFB_FBC_YE_MASK 0x00000300
+/* X plane group enable */
+#define FFB_FBC_XE_OFF 0x00000040
+#define FFB_FBC_XE_ON 0x00000080
+#define FFB_FBC_XE_MASK 0x000000c0
+/* B plane group enable */
+#define FFB_FBC_BE_OFF 0x00000010
+#define FFB_FBC_BE_ON 0x00000020
+#define FFB_FBC_BE_MASK 0x00000030
+/* G plane group enable */
+#define FFB_FBC_GE_OFF 0x00000004
+#define FFB_FBC_GE_ON 0x00000008
+#define FFB_FBC_GE_MASK 0x0000000c
+/* R plane group enable */
+#define FFB_FBC_RE_OFF 0x00000001
+#define FFB_FBC_RE_ON 0x00000002
+#define FFB_FBC_RE_MASK 0x00000003
+/* Combined */
+#define FFB_FBC_RGBE_OFF 0x00000015
+#define FFB_FBC_RGBE_ON 0x0000002a
+#define FFB_FBC_RGBE_MASK 0x0000003f
+
+/* Raster OP */
+#define FFB_ROP_YZ_MASK 0x008f0000
+#define FFB_ROP_X_MASK 0x00008f00
+#define FFB_ROP_RGB_MASK 0x0000008f
+
+/* Now the rops themselves which get shifted into the
+ * above fields.
+ */
+#define FFB_ROP_EDIT_BIT 0x80
+#define FFB_ROP_ZERO 0x80
+#define FFB_ROP_NEW_AND_OLD 0x81
+#define FFB_ROP_NEW_AND_NOLD 0x82
+#define FFB_ROP_NEW 0x83
+#define FFB_ROP_NNEW_AND_OLD 0x84
+#define FFB_ROP_OLD 0x85
+#define FFB_ROP_NEW_XOR_OLD 0x86
+#define FFB_ROP_NEW_OR_OLD 0x87
+#define FFB_ROP_NNEW_AND_NOLD 0x88
+#define FFB_ROP_NNEW_XOR_NOLD 0x89
+#define FFB_ROP_NOLD 0x8a
+#define FFB_ROP_NEW_OR_NOLD 0x8b
+#define FFB_ROP_NNEW 0x8c
+#define FFB_ROP_NNEW_OR_OLD 0x8d
+#define FFB_ROP_NNEW_OR_NOLD 0x8e
+#define FFB_ROP_ONES 0x8f
+
+/* FB Compare */
+#define FFB_CMP_MATCHC_MASK 0x8f000000
+#define FFB_CMP_MAGNC_MASK 0x00870000
+#define FFB_CMP_MATCHAB_MASK 0x0000ff00
+#define FFB_CMP_MAGNAB_MASK 0x000000ff
+
+/* Compare Match codes */
+#define FFB_CMP_MATCH_EDIT_BIT 0x80
+#define FFB_CMP_MATCH_ALWAYS 0x80
+#define FFB_CMP_MATCH_NEVER 0x81
+#define FFB_CMP_MATCH_EQ 0x82
+#define FFB_CMP_MATCH_NE 0x83
+#define FFB_CMP_MATCH_A_ALWAYS 0xc0
+#define FFB_CMP_MATCH_B_ALWAYS 0xa0
+
+/* Compare Magnitude codes */
+#define FFB_CMP_MAGN_EDIT_BIT 0x80
+#define FFB_CMP_MAGN_ALWAYS 0x80
+#define FFB_CMP_MAGN_GT 0x81
+#define FFB_CMP_MAGN_EQ 0x82
+#define FFB_CMP_MAGN_GE 0x83
+#define FFB_CMP_MAGN_NEVER 0x84
+#define FFB_CMP_MAGN_LE 0x85
+#define FFB_CMP_MAGN_NE 0x86
+#define FFB_CMP_MAGN_LT 0x87
+#define FFB_CMP_MAGN_A_ALWAYS 0xc0
+#define FFB_CMP_MAGN_B_ALWAYS 0xa0
+
+/* User Control and Status */
+#define FFB_UCSR_FIFO_MASK 0x00000fff
+#define FFB_UCSR_PICK_NO_HIT 0x00020000
+#define FFB_UCSR_PICK_HIT 0x00030000
+#define FFB_UCSR_PICK_DISABLE 0x00080000
+#define FFB_UCSR_PICK_ENABLE 0x000c0000
+#define FFB_UCSR_FB_BUSY 0x01000000
+#define FFB_UCSR_RP_BUSY 0x02000000
+#define FFB_UCSR_ALL_BUSY (FFB_UCSR_RP_BUSY|FFB_UCSR_FB_BUSY)
+#define FFB_UCSR_READ_ERR 0x40000000
+#define FFB_UCSR_FIFO_OVFL 0x80000000
+#define FFB_UCSR_ALL_ERRORS (FFB_UCSR_READ_ERR|FFB_UCSR_FIFO_OVFL)
+
+/* Mode Enable Register */
+#define FFB_MER_EIRA 0x00000080 /* Enable read-ahead, increasing */
+#define FFB_MER_EDRA 0x000000c0 /* Enable read-ahead, decreasing */
+#define FFB_MER_DRA 0x00000040 /* No read-ahead */
+
+/* FBram Config 0 */
+#define FFB_FBCFG0_RFTIME 0xff800000
+#define FFB_FBCFG0_XMAX 0x007c0000
+#define FFB_FBCFG0_YMAX 0x0003ffc0
+#define FFB_FBCFG0_RES_MASK 0x00000030
+#define FFB_FBCFG0_RES_HIGH 0x00000030 /* 1920x1360 */
+#define FFB_FBCFG0_RES_STD 0x00000020 /* 1280x1024 */
+#define FFB_FBCFG0_RES_STEREO 0x00000010 /* 960x580 */
+#define FFB_FBCFG0_RES_PRTRAIT 0x00000000 /* 1280x2048 */
+#define FFB_FBCFG0_ITRLACE 0x00000000
+#define FFB_FBCFG0_SEQUENTIAL 0x00000008
+#define FFB_FBCFG0_DRENA 0x00000004
+#define FFB_FBCFG0_BPMODE 0x00000002
+#define FFB_FBCFG0_RFRSH_RST 0x00000001
+
+typedef struct _ffb_dac {
+ volatile unsigned int cfg;
+ volatile unsigned int cfgdata;
+ volatile unsigned int cur;
+ volatile unsigned int curdata;
+} ffb_dac, *ffb_dacPtr;
+
+/* Writing 2 32-bit registers at a time using 64-bit stores. -DaveM */
+#if defined(__GNUC__) && defined(USE_VIS)
+/* 64-bit register writing support.
+ * Note: "lo" means "low address".
+ */
+#define FFB_WRITE64_COMMON(__regp, __lo32, __hi32, REG0, REG1) \
+do { __extension__ register unsigned int __r0 __asm__(""#REG0); \
+ __extension__ register unsigned int __r1 __asm__(""#REG1); \
+ __r0 = (__lo32); \
+ __r1 = (__hi32); \
+ __asm__ __volatile__ ("sllx\t%0, 32, %%g1\n\t" \
+ "srl\t%1, 0, %1\n\t" \
+ "or\t%%g1, %1, %%g1\n\t" \
+ "stx\t%%g1, %2" \
+ : : "r" (__r0), "r" (__r1), "m" (*(__regp)) : "g1"); \
+} while(0)
+
+#define FFB_WRITE64P(__regp, __srcp) \
+do { __asm__ __volatile__ ("ldx\t%0, %%g2;" \
+ "stx\t%%g2, %1" \
+ : : "m" (*(__srcp)), "m" (*(__regp)) \
+ : "g2"); \
+} while(0)
+
+#define FFB_WRITE64(__regp, __lo32, __hi32) \
+ FFB_WRITE64_COMMON(__regp, __lo32, __hi32, g2, g3)
+#define FFB_WRITE64_2(__regp, __lo32, __hi32) \
+ FFB_WRITE64_COMMON(__regp, __lo32, __hi32, g4, g5)
+#define FFB_WRITE64_3(__regp, __lo32, __hi32) \
+ FFB_WRITE64_COMMON(__regp, __lo32, __hi32, o4, o5)
+
+#else /* Do not use 64-bit writes. */
+
+#define FFB_WRITE64(__regp, __lo32, __hi32) \
+do { volatile unsigned int *__p = (__regp); \
+ *__p = (__lo32); \
+ *(__p + 1) = (__hi32); \
+} while(0)
+
+#define FFB_WRITE64P(__regp, __srcp) \
+do { volatile unsigned int *__p = (__regp); \
+ unsigned int *__q = (__srcp); \
+ *__p = *__q; \
+ *(__p + 1) = *(__q + 1); \
+} while(0)
+
+#define FFB_WRITE64_2(__regp, __lo32, __hi32) \
+ FFB_WRITE64(__regp, __lo32, __hi32)
+#define FFB_WRITE64_3(__regp, __lo32, __hi32) \
+ FFB_WRITE64(__regp, __lo32, __hi32)
+#endif
+
+#endif /* FFBREGS_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/Makefile
new file mode 100644
index 000000000..250d3ac08
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/Makefile
@@ -0,0 +1,35 @@
+# src/mesa/drivers/dri/gamma/Makefile
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = gamma_dri.so
+
+# Not yet
+# MINIGLX_SOURCES = server/gamma_dri.c
+
+DRIVER_SOURCES = \
+ gamma_context.c \
+ gamma_dd.c \
+ gamma_inithw.c \
+ gamma_lock.c \
+ gamma_render.c \
+ gamma_screen.c \
+ gamma_span.c \
+ gamma_state.c \
+ gamma_tex.c \
+ gamma_texmem.c \
+ gamma_texstate.c \
+ gamma_tris.c \
+ gamma_vb.c \
+ gamma_xmesa.c
+
+C_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+include ../Makefile.template
+
+symlinks:
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_client.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_client.h
new file mode 100644
index 000000000..1c1a22ebc
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_client.h
@@ -0,0 +1,6185 @@
+/* Automaticallly generated -- do not edit */
+#ifndef _GLINT_CLIENT_H_
+#define _GLINT_CLIENT_H_
+/* **********************************************************************/
+/* START OF glint_extra.h INCLUSION */
+/* **********************************************************************/
+
+/* glint_extra.h
+ * Created: Fri Apr 2 23:32:05 1999 by faith@precisioninsight.com
+ * Revised: Fri Apr 2 23:33:00 1999 by faith@precisioninsight.com
+ *
+ * Copyright 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, 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.
+ *
+ * $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_client.h,v 1.3 2002/02/22 21:33:00 dawes Exp $
+ *
+ */
+
+#define AreaStippleEnable 0x00001
+#define LineStippleEnable 0x00002
+#define GResetLineStipple 0x00004
+#define FastFillEnable 0x00008
+#define PrimitiveLine 0x00000
+#define PrimitiveTrapezoid 0x00040
+#define PrimitivePoint 0x00080
+#define PrimitiveRectangle 0x000C0
+#define AntialiasEnable 0x00100
+#define AntialiasingQuality 0x00200
+#define UsePointTable 0x00400
+#define SyncOnBitMask 0x00800
+#define SyncOnHostData 0x01000
+#define TextureEnable 0x02000
+#define FogEnable 0x04000
+#define CoverageEnable 0x08000
+#define SubPixelCorrectionEnable 0x10000
+#define SpanOperation 0x40000
+
+
+/* **********************************************************************/
+/* END OF glint_extra.h INCLUSION */
+/* **********************************************************************/
+
+
+#define GlintResetStatus 0x0000
+#define GlintResetStatusReg 0
+#define GlintResetStatusOff 0x0000
+#define GlintResetStatusSec 0x0000
+#define GlintResetStatusSecReg 2
+#define GlintResetStatusSecOff 0x0000
+
+#define GlintIntEnable 0x0008
+#define GlintIntEnableReg 0
+#define GlintIntEnableOff 0x0008
+#define GlintIntEnableSec 0x0008
+#define GlintIntEnableSecReg 2
+#define GlintIntEnableSecOff 0x0008
+
+#define GlintIntFlags 0x0010
+#define GlintIntFlagsReg 0
+#define GlintIntFlagsOff 0x0010
+#define GlintIntFlagsSec 0x0010
+#define GlintIntFlagsSecReg 2
+#define GlintIntFlagsSecOff 0x0010
+
+#define GlintInFIFOSpace 0x0018
+#define GlintInFIFOSpaceReg 0
+#define GlintInFIFOSpaceOff 0x0018
+#define GlintInFIFOSpaceSec 0x0018
+#define GlintInFIFOSpaceSecReg 2
+#define GlintInFIFOSpaceSecOff 0x0018
+
+#define GlintOutFIFOWords 0x0020
+#define GlintOutFIFOWordsReg 0
+#define GlintOutFIFOWordsOff 0x0020
+#define GlintOutFIFOWordsSec 0x0020
+#define GlintOutFIFOWordsSecReg 2
+#define GlintOutFIFOWordsSecOff 0x0020
+
+#define GlintDMAAddress 0x0028
+#define GlintDMAAddressReg 0
+#define GlintDMAAddressOff 0x0028
+#define GlintDMAAddressSec 0x0028
+#define GlintDMAAddressSecReg 2
+#define GlintDMAAddressSecOff 0x0028
+
+#define GlintDMACount 0x0030
+#define GlintDMACountReg 0
+#define GlintDMACountOff 0x0030
+#define GlintDMACountSec 0x0030
+#define GlintDMACountSecReg 2
+#define GlintDMACountSecOff 0x0030
+
+#define GlintErrorFlags 0x0038
+#define GlintErrorFlagsReg 0
+#define GlintErrorFlagsOff 0x0038
+#define GlintErrorFlagsSec 0x0038
+#define GlintErrorFlagsSecReg 2
+#define GlintErrorFlagsSecOff 0x0038
+
+#define GlintVClkCtl 0x0040
+#define GlintVClkCtlReg 0
+#define GlintVClkCtlOff 0x0040
+#define GlintVClkCtlSec 0x0040
+#define GlintVClkCtlSecReg 2
+#define GlintVClkCtlSecOff 0x0040
+
+#define GlintTestRegister 0x0048
+#define GlintTestRegisterReg 0
+#define GlintTestRegisterOff 0x0048
+#define GlintTestRegisterSec 0x0048
+#define GlintTestRegisterSecReg 2
+#define GlintTestRegisterSecOff 0x0048
+
+#define GlintAperture0 0x0050
+#define GlintAperture0Reg 0
+#define GlintAperture0Off 0x0050
+#define GlintAperture0Sec 0x0050
+#define GlintAperture0SecReg 2
+#define GlintAperture0SecOff 0x0050
+
+#define GlintAperture1 0x0058
+#define GlintAperture1Reg 0
+#define GlintAperture1Off 0x0058
+#define GlintAperture1Sec 0x0058
+#define GlintAperture1SecReg 2
+#define GlintAperture1SecOff 0x0058
+
+#define GlintDMAControl 0x0060
+#define GlintDMAControlReg 0
+#define GlintDMAControlOff 0x0060
+#define GlintDMAControlSec 0x0060
+#define GlintDMAControlSecReg 2
+#define GlintDMAControlSecOff 0x0060
+
+#define GlintFIFODis 0x0068
+#define GlintFIFODisReg 0
+#define GlintFIFODisOff 0x0068
+#define GlintFIFODisSec 0x0068
+#define GlintFIFODisSecReg 2
+#define GlintFIFODisSecOff 0x0068
+
+#define GlintLBMemoryCtl 0x1000
+#define GlintLBMemoryCtlReg 1
+#define GlintLBMemoryCtlOff 0x0000
+#define GlintLBMemoryCtlSec 0x1000
+#define GlintLBMemoryCtlSecReg 3
+#define GlintLBMemoryCtlSecOff 0x0000
+
+#define GlintLBMemoryEDO 0x1008
+#define GlintLBMemoryEDOReg 1
+#define GlintLBMemoryEDOOff 0x0008
+#define GlintLBMemoryEDOSec 0x1008
+#define GlintLBMemoryEDOSecReg 3
+#define GlintLBMemoryEDOSecOff 0x0008
+
+#define GlintFBMemoryCtl 0x1800
+#define GlintFBMemoryCtlReg 1
+#define GlintFBMemoryCtlOff 0x0800
+#define GlintFBMemoryCtlSec 0x1800
+#define GlintFBMemoryCtlSecReg 3
+#define GlintFBMemoryCtlSecOff 0x0800
+
+#define GlintFBModeSel 0x1808
+#define GlintFBModeSelReg 1
+#define GlintFBModeSelOff 0x0808
+#define GlintFBModeSelSec 0x1808
+#define GlintFBModeSelSecReg 3
+#define GlintFBModeSelSecOff 0x0808
+
+#define GlintFBGCWrMask 0x1810
+#define GlintFBGCWrMaskReg 1
+#define GlintFBGCWrMaskOff 0x0810
+#define GlintFBGCWrMaskSec 0x1810
+#define GlintFBGCWrMaskSecReg 3
+#define GlintFBGCWrMaskSecOff 0x0810
+
+#define GlintFBGCColorLower 0x1818
+#define GlintFBGCColorLowerReg 1
+#define GlintFBGCColorLowerOff 0x0818
+#define GlintFBGCColorLowerSec 0x1818
+#define GlintFBGCColorLowerSecReg 3
+#define GlintFBGCColorLowerSecOff 0x0818
+
+#define GlintFBTXMemCtl 0x1820
+#define GlintFBTXMemCtlReg 1
+#define GlintFBTXMemCtlOff 0x0820
+#define GlintFBTXMemCtlSec 0x1820
+#define GlintFBTXMemCtlSecReg 3
+#define GlintFBTXMemCtlSecOff 0x0820
+
+#define GlintFBWrMask 0x1830
+#define GlintFBWrMaskReg 1
+#define GlintFBWrMaskOff 0x0830
+#define GlintFBWrMaskSec 0x1830
+#define GlintFBWrMaskSecReg 3
+#define GlintFBWrMaskSecOff 0x0830
+
+#define GlintFBGCColorUpper 0x1838
+#define GlintFBGCColorUpperReg 1
+#define GlintFBGCColorUpperOff 0x0838
+#define GlintFBGCColorUpperSec 0x1838
+#define GlintFBGCColorUpperSecReg 3
+#define GlintFBGCColorUpperSecOff 0x0838
+
+#define GlintVTGHLimit 0x3000
+#define GlintVTGHLimitReg 1
+#define GlintVTGHLimitOff 0x2000
+#define GlintVTGHLimitSec 0x3000
+#define GlintVTGHLimitSecReg 3
+#define GlintVTGHLimitSecOff 0x2000
+
+#define GlintVTGHSyncStart 0x3008
+#define GlintVTGHSyncStartReg 1
+#define GlintVTGHSyncStartOff 0x2008
+#define GlintVTGHSyncStartSec 0x3008
+#define GlintVTGHSyncStartSecReg 3
+#define GlintVTGHSyncStartSecOff 0x2008
+
+#define GlintVTGHSyncEnd 0x3010
+#define GlintVTGHSyncEndReg 1
+#define GlintVTGHSyncEndOff 0x2010
+#define GlintVTGHSyncEndSec 0x3010
+#define GlintVTGHSyncEndSecReg 3
+#define GlintVTGHSyncEndSecOff 0x2010
+
+#define GlintVTGHBlankEnd 0x3018
+#define GlintVTGHBlankEndReg 1
+#define GlintVTGHBlankEndOff 0x2018
+#define GlintVTGHBlankEndSec 0x3018
+#define GlintVTGHBlankEndSecReg 3
+#define GlintVTGHBlankEndSecOff 0x2018
+
+#define GlintVTGVLimit 0x3020
+#define GlintVTGVLimitReg 1
+#define GlintVTGVLimitOff 0x2020
+#define GlintVTGVLimitSec 0x3020
+#define GlintVTGVLimitSecReg 3
+#define GlintVTGVLimitSecOff 0x2020
+
+#define GlintVTGVSyncStart 0x3028
+#define GlintVTGVSyncStartReg 1
+#define GlintVTGVSyncStartOff 0x2028
+#define GlintVTGVSyncStartSec 0x3028
+#define GlintVTGVSyncStartSecReg 3
+#define GlintVTGVSyncStartSecOff 0x2028
+
+#define GlintVTGVSyncEnd 0x3030
+#define GlintVTGVSyncEndReg 1
+#define GlintVTGVSyncEndOff 0x2030
+#define GlintVTGVSyncEndSec 0x3030
+#define GlintVTGVSyncEndSecReg 3
+#define GlintVTGVSyncEndSecOff 0x2030
+
+#define GlintVTGVBlankEnd 0x3038
+#define GlintVTGVBlankEndReg 1
+#define GlintVTGVBlankEndOff 0x2038
+#define GlintVTGVBlankEndSec 0x3038
+#define GlintVTGVBlankEndSecReg 3
+#define GlintVTGVBlankEndSecOff 0x2038
+
+#define GlintVTGHGateStart 0x3040
+#define GlintVTGHGateStartReg 1
+#define GlintVTGHGateStartOff 0x2040
+#define GlintVTGHGateStartSec 0x3040
+#define GlintVTGHGateStartSecReg 3
+#define GlintVTGHGateStartSecOff 0x2040
+
+#define GlintVTGHGateEnd 0x3048
+#define GlintVTGHGateEndReg 1
+#define GlintVTGHGateEndOff 0x2048
+#define GlintVTGHGateEndSec 0x3048
+#define GlintVTGHGateEndSecReg 3
+#define GlintVTGHGateEndSecOff 0x2048
+
+#define GlintVTGVGateStart 0x3050
+#define GlintVTGVGateStartReg 1
+#define GlintVTGVGateStartOff 0x2050
+#define GlintVTGVGateStartSec 0x3050
+#define GlintVTGVGateStartSecReg 3
+#define GlintVTGVGateStartSecOff 0x2050
+
+#define GlintVTGVGateEnd 0x3058
+#define GlintVTGVGateEndReg 1
+#define GlintVTGVGateEndOff 0x2058
+#define GlintVTGVGateEndSec 0x3058
+#define GlintVTGVGateEndSecReg 3
+#define GlintVTGVGateEndSecOff 0x2058
+
+#define GlintVTGPolarity 0x3060
+#define GlintVTGPolarityReg 1
+#define GlintVTGPolarityOff 0x2060
+#define GlintVTGPolaritySec 0x3060
+#define GlintVTGPolaritySecReg 3
+#define GlintVTGPolaritySecOff 0x2060
+
+#define GlintVTGFrameRowAddr 0x3068
+#define GlintVTGFrameRowAddrReg 1
+#define GlintVTGFrameRowAddrOff 0x2068
+#define GlintVTGFrameRowAddrSec 0x3068
+#define GlintVTGFrameRowAddrSecReg 3
+#define GlintVTGFrameRowAddrSecOff 0x2068
+
+#define GlintVTGVLineNumber 0x3070
+#define GlintVTGVLineNumberReg 1
+#define GlintVTGVLineNumberOff 0x2070
+#define GlintVTGVLineNumberSec 0x3070
+#define GlintVTGVLineNumberSecReg 3
+#define GlintVTGVLineNumberSecOff 0x2070
+
+#define GlintVTGSerialClk 0x3078
+#define GlintVTGSerialClkReg 1
+#define GlintVTGSerialClkOff 0x2078
+#define GlintVTGSerialClkSec 0x3078
+#define GlintVTGSerialClkSecReg 3
+#define GlintVTGSerialClkSecOff 0x2078
+
+#define GlintVTGModeCtl 0x3080
+#define GlintVTGModeCtlReg 1
+#define GlintVTGModeCtlOff 0x2080
+#define GlintVTGModeCtlSec 0x3080
+#define GlintVTGModeCtlSecReg 3
+#define GlintVTGModeCtlSecOff 0x2080
+
+#define GlintOutputFIFO 0x2000
+#define GlintOutputFIFOReg 1
+#define GlintOutputFIFOOff 0x1000
+#define GlintOutputFIFOSec 0x2000
+#define GlintOutputFIFOSecReg 3
+#define GlintOutputFIFOSecOff 0x1000
+
+#define GlintGInFIFOSpace 0x0018
+#define GlintGInFIFOSpaceReg 0
+#define GlintGInFIFOSpaceOff 0x0018
+
+#define GlintGDMAAddress 0x0028
+#define GlintGDMAAddressReg 0
+#define GlintGDMAAddressOff 0x0028
+
+#define GlintGDMACount 0x0030
+#define GlintGDMACountReg 0
+#define GlintGDMACountOff 0x0030
+
+#define GlintGDMAControl 0x0060
+#define GlintGDMAControlReg 0
+#define GlintGDMAControlOff 0x0060
+
+#define GlintGOutDMA 0x0080
+#define GlintGOutDMAReg 0
+#define GlintGOutDMAOff 0x0080
+
+#define GlintGOutDMACount 0x0088
+#define GlintGOutDMACountReg 0
+#define GlintGOutDMACountOff 0x0088
+
+#define GlintGResetStatus 0x0800
+#define GlintGResetStatusReg 0
+#define GlintGResetStatusOff 0x0800
+
+#define GlintGIntEnable 0x0808
+#define GlintGIntEnableReg 0
+#define GlintGIntEnableOff 0x0808
+
+#define GlintGIntFlags 0x0810
+#define GlintGIntFlagsReg 0
+#define GlintGIntFlagsOff 0x0810
+
+#define GlintGErrorFlags 0x0838
+#define GlintGErrorFlagsReg 0
+#define GlintGErrorFlagsOff 0x0838
+
+#define GlintGTestRegister 0x0848
+#define GlintGTestRegisterReg 0
+#define GlintGTestRegisterOff 0x0848
+
+#define GlintGFIFODis 0x0868
+#define GlintGFIFODisReg 0
+#define GlintGFIFODisOff 0x0868
+
+#define GlintGChipConfig 0x0870
+#define GlintGChipConfigReg 0
+#define GlintGChipConfigOff 0x0870
+
+#define GlintGCSRAperture 0x0878
+#define GlintGCSRApertureReg 0
+#define GlintGCSRApertureOff 0x0878
+
+#define GlintGPageTableAddr 0x0c00
+#define GlintGPageTableAddrReg 0
+#define GlintGPageTableAddrOff 0x0c00
+
+#define GlintGPageTableLength 0x0c08
+#define GlintGPageTableLengthReg 0
+#define GlintGPageTableLengthOff 0x0c08
+
+#define GlintGDelayTimer 0x0c38
+#define GlintGDelayTimerReg 0
+#define GlintGDelayTimerOff 0x0c38
+
+#define GlintGCommandMode 0x0c40
+#define GlintGCommandModeReg 0
+#define GlintGCommandModeOff 0x0c40
+
+#define GlintGCommandIntEnable 0x0c48
+#define GlintGCommandIntEnableReg 0
+#define GlintGCommandIntEnableOff 0x0c48
+
+#define GlintGCommandIntFlags 0x0c50
+#define GlintGCommandIntFlagsReg 0
+#define GlintGCommandIntFlagsOff 0x0c50
+
+#define GlintGCommandErrorFlags 0x0c58
+#define GlintGCommandErrorFlagsReg 0
+#define GlintGCommandErrorFlagsOff 0x0c58
+
+#define GlintGCommandStatus 0x0c60
+#define GlintGCommandStatusReg 0
+#define GlintGCommandStatusOff 0x0c60
+
+#define GlintGCommandFaultingAddr 0x0c68
+#define GlintGCommandFaultingAddrReg 0
+#define GlintGCommandFaultingAddrOff 0x0c68
+
+#define GlintGVertexFaultingAddr 0x0c70
+#define GlintGVertexFaultingAddrReg 0
+#define GlintGVertexFaultingAddrOff 0x0c70
+
+#define GlintGWriteFaultingAddr 0x0c88
+#define GlintGWriteFaultingAddrReg 0
+#define GlintGWriteFaultingAddrOff 0x0c88
+
+#define GlintGFeedbackSelectCount 0x0c98
+#define GlintGFeedbackSelectCountReg 0
+#define GlintGFeedbackSelectCountOff 0x0c98
+
+#define GlintGGammaProcessorMode 0x0cb8
+#define GlintGGammaProcessorModeReg 0
+#define GlintGGammaProcessorModeOff 0x0cb8
+
+#define GlintGVGAShadow 0x0d00
+#define GlintGVGAShadowReg 0
+#define GlintGVGAShadowOff 0x0d00
+
+#define GlintGMultGLINTAperture 0x0d08
+#define GlintGMultGLINTApertureReg 0
+#define GlintGMultGLINTApertureOff 0x0d08
+
+#define GlintGMultGLINT1 0x0d10
+#define GlintGMultGLINT1Reg 0
+#define GlintGMultGLINT1Off 0x0d10
+
+#define GlintGMultGLINT2 0x0d18
+#define GlintGMultGLINT2Reg 0
+#define GlintGMultGLINT2Off 0x0d18
+
+#define GlintStartXDom 0x8000
+#define GlintStartXDomTag 0x0000
+#define GlintStartXDomReg 1
+#define GlintStartXDomOff 0x7000
+#define GlintStartXDomSec 0x8000
+#define GlintStartXDomSecReg 3
+#define GlintStartXDomSecOff 0x7000
+
+#define GlintdXDom 0x8008
+#define GlintdXDomTag 0x0001
+#define GlintdXDomReg 1
+#define GlintdXDomOff 0x7008
+#define GlintdXDomSec 0x8008
+#define GlintdXDomSecReg 3
+#define GlintdXDomSecOff 0x7008
+
+#define GlintStartXSub 0x8010
+#define GlintStartXSubTag 0x0002
+#define GlintStartXSubReg 1
+#define GlintStartXSubOff 0x7010
+#define GlintStartXSubSec 0x8010
+#define GlintStartXSubSecReg 3
+#define GlintStartXSubSecOff 0x7010
+
+#define GlintdXSub 0x8018
+#define GlintdXSubTag 0x0003
+#define GlintdXSubReg 1
+#define GlintdXSubOff 0x7018
+#define GlintdXSubSec 0x8018
+#define GlintdXSubSecReg 3
+#define GlintdXSubSecOff 0x7018
+
+#define GlintStartY 0x8020
+#define GlintStartYTag 0x0004
+#define GlintStartYReg 1
+#define GlintStartYOff 0x7020
+#define GlintStartYSec 0x8020
+#define GlintStartYSecReg 3
+#define GlintStartYSecOff 0x7020
+
+#define GlintdY 0x8028
+#define GlintdYTag 0x0005
+#define GlintdYReg 1
+#define GlintdYOff 0x7028
+#define GlintdYSec 0x8028
+#define GlintdYSecReg 3
+#define GlintdYSecOff 0x7028
+
+#define GlintGLINTCount 0x8030
+#define GlintGLINTCountTag 0x0006
+#define GlintGLINTCountReg 1
+#define GlintGLINTCountOff 0x7030
+#define GlintGLINTCountSec 0x8030
+#define GlintGLINTCountSecReg 3
+#define GlintGLINTCountSecOff 0x7030
+
+#define GlintRender 0x8038
+#define GlintRenderTag 0x0007
+#define GlintRenderReg 1
+#define GlintRenderOff 0x7038
+#define GlintRenderSec 0x8038
+#define GlintRenderSecReg 3
+#define GlintRenderSecOff 0x7038
+
+#define GlintContinueNewLine 0x8040
+#define GlintContinueNewLineTag 0x0008
+#define GlintContinueNewLineReg 1
+#define GlintContinueNewLineOff 0x7040
+#define GlintContinueNewLineSec 0x8040
+#define GlintContinueNewLineSecReg 3
+#define GlintContinueNewLineSecOff 0x7040
+
+#define GlintContinueNewDom 0x8048
+#define GlintContinueNewDomTag 0x0009
+#define GlintContinueNewDomReg 1
+#define GlintContinueNewDomOff 0x7048
+#define GlintContinueNewDomSec 0x8048
+#define GlintContinueNewDomSecReg 3
+#define GlintContinueNewDomSecOff 0x7048
+
+#define GlintContinueNewSub 0x8050
+#define GlintContinueNewSubTag 0x000a
+#define GlintContinueNewSubReg 1
+#define GlintContinueNewSubOff 0x7050
+#define GlintContinueNewSubSec 0x8050
+#define GlintContinueNewSubSecReg 3
+#define GlintContinueNewSubSecOff 0x7050
+
+#define GlintContinue 0x8058
+#define GlintContinueTag 0x000b
+#define GlintContinueReg 1
+#define GlintContinueOff 0x7058
+#define GlintContinueSec 0x8058
+#define GlintContinueSecReg 3
+#define GlintContinueSecOff 0x7058
+
+#define GlintFlushSpan 0x8060
+#define GlintFlushSpanTag 0x000c
+#define GlintFlushSpanReg 1
+#define GlintFlushSpanOff 0x7060
+#define GlintFlushSpanSec 0x8060
+#define GlintFlushSpanSecReg 3
+#define GlintFlushSpanSecOff 0x7060
+
+#define GlintBitMaskPattern 0x8068
+#define GlintBitMaskPatternTag 0x000d
+#define GlintBitMaskPatternReg 1
+#define GlintBitMaskPatternOff 0x7068
+#define GlintBitMaskPatternSec 0x8068
+#define GlintBitMaskPatternSecReg 3
+#define GlintBitMaskPatternSecOff 0x7068
+
+#define GlintPointTable0 0x8080
+#define GlintPointTable0Tag 0x0010
+#define GlintPointTable0Reg 1
+#define GlintPointTable0Off 0x7080
+#define GlintPointTable0Sec 0x8080
+#define GlintPointTable0SecReg 3
+#define GlintPointTable0SecOff 0x7080
+
+#define GlintPointTable1 0x8088
+#define GlintPointTable1Tag 0x0011
+#define GlintPointTable1Reg 1
+#define GlintPointTable1Off 0x7088
+#define GlintPointTable1Sec 0x8088
+#define GlintPointTable1SecReg 3
+#define GlintPointTable1SecOff 0x7088
+
+#define GlintPointTable2 0x8090
+#define GlintPointTable2Tag 0x0012
+#define GlintPointTable2Reg 1
+#define GlintPointTable2Off 0x7090
+#define GlintPointTable2Sec 0x8090
+#define GlintPointTable2SecReg 3
+#define GlintPointTable2SecOff 0x7090
+
+#define GlintPointTable3 0x8098
+#define GlintPointTable3Tag 0x0013
+#define GlintPointTable3Reg 1
+#define GlintPointTable3Off 0x7098
+#define GlintPointTable3Sec 0x8098
+#define GlintPointTable3SecReg 3
+#define GlintPointTable3SecOff 0x7098
+
+#define GlintRasterizerMode 0x80a0
+#define GlintRasterizerModeTag 0x0014
+#define GlintRasterizerModeReg 1
+#define GlintRasterizerModeOff 0x70a0
+#define GlintRasterizerModeSec 0x80a0
+#define GlintRasterizerModeSecReg 3
+#define GlintRasterizerModeSecOff 0x70a0
+
+#define GlintYLimits 0x80a8
+#define GlintYLimitsTag 0x0015
+#define GlintYLimitsReg 1
+#define GlintYLimitsOff 0x70a8
+#define GlintYLimitsSec 0x80a8
+#define GlintYLimitsSecReg 3
+#define GlintYLimitsSecOff 0x70a8
+
+#define GlintScanLineOwnership 0x80b0
+#define GlintScanLineOwnershipTag 0x0016
+#define GlintScanLineOwnershipReg 1
+#define GlintScanLineOwnershipOff 0x70b0
+#define GlintScanLineOwnershipSec 0x80b0
+#define GlintScanLineOwnershipSecReg 3
+#define GlintScanLineOwnershipSecOff 0x70b0
+
+#define GlintWaitForCompletion 0x80b8
+#define GlintWaitForCompletionTag 0x0017
+#define GlintWaitForCompletionReg 1
+#define GlintWaitForCompletionOff 0x70b8
+#define GlintWaitForCompletionSec 0x80b8
+#define GlintWaitForCompletionSecReg 3
+#define GlintWaitForCompletionSecOff 0x70b8
+
+#define GlintPixelSize 0x80c0
+#define GlintPixelSizeTag 0x0018
+#define GlintPixelSizeReg 1
+#define GlintPixelSizeOff 0x70c0
+#define GlintPixelSizeSec 0x80c0
+#define GlintPixelSizeSecReg 3
+#define GlintPixelSizeSecOff 0x70c0
+
+#define GlintScissorMode 0x8180
+#define GlintScissorModeTag 0x0030
+#define GlintScissorModeReg 1
+#define GlintScissorModeOff 0x7180
+#define GlintScissorModeSec 0x8180
+#define GlintScissorModeSecReg 3
+#define GlintScissorModeSecOff 0x7180
+
+#define GlintScissorMinXY 0x8188
+#define GlintScissorMinXYTag 0x0031
+#define GlintScissorMinXYReg 1
+#define GlintScissorMinXYOff 0x7188
+#define GlintScissorMinXYSec 0x8188
+#define GlintScissorMinXYSecReg 3
+#define GlintScissorMinXYSecOff 0x7188
+
+#define GlintScissorMaxXY 0x8190
+#define GlintScissorMaxXYTag 0x0032
+#define GlintScissorMaxXYReg 1
+#define GlintScissorMaxXYOff 0x7190
+#define GlintScissorMaxXYSec 0x8190
+#define GlintScissorMaxXYSecReg 3
+#define GlintScissorMaxXYSecOff 0x7190
+
+#define GlintScreenSize 0x8198
+#define GlintScreenSizeTag 0x0033
+#define GlintScreenSizeReg 1
+#define GlintScreenSizeOff 0x7198
+#define GlintScreenSizeSec 0x8198
+#define GlintScreenSizeSecReg 3
+#define GlintScreenSizeSecOff 0x7198
+
+#define GlintAreaStippleMode 0x81a0
+#define GlintAreaStippleModeTag 0x0034
+#define GlintAreaStippleModeReg 1
+#define GlintAreaStippleModeOff 0x71a0
+#define GlintAreaStippleModeSec 0x81a0
+#define GlintAreaStippleModeSecReg 3
+#define GlintAreaStippleModeSecOff 0x71a0
+
+#define GlintLineStippleMode 0x81a8
+#define GlintLineStippleModeTag 0x0035
+#define GlintLineStippleModeReg 1
+#define GlintLineStippleModeOff 0x71a8
+#define GlintLineStippleModeSec 0x81a8
+#define GlintLineStippleModeSecReg 3
+#define GlintLineStippleModeSecOff 0x71a8
+
+#define GlintLoadLineStippleCounters 0x81b0
+#define GlintLoadLineStippleCountersTag 0x0036
+#define GlintLoadLineStippleCountersReg 1
+#define GlintLoadLineStippleCountersOff 0x71b0
+#define GlintLoadLineStippleCountersSec 0x81b0
+#define GlintLoadLineStippleCountersSecReg 3
+#define GlintLoadLineStippleCountersSecOff 0x71b0
+
+#define GlintUpdateLineStippleCounters 0x81b8
+#define GlintUpdateLineStippleCountersTag 0x0037
+#define GlintUpdateLineStippleCountersReg 1
+#define GlintUpdateLineStippleCountersOff 0x71b8
+#define GlintUpdateLineStippleCountersSec 0x81b8
+#define GlintUpdateLineStippleCountersSecReg 3
+#define GlintUpdateLineStippleCountersSecOff 0x71b8
+
+#define GlintSaveLineStippleState 0x81c0
+#define GlintSaveLineStippleStateTag 0x0038
+#define GlintSaveLineStippleStateReg 1
+#define GlintSaveLineStippleStateOff 0x71c0
+#define GlintSaveLineStippleStateSec 0x81c0
+#define GlintSaveLineStippleStateSecReg 3
+#define GlintSaveLineStippleStateSecOff 0x71c0
+
+#define GlintWindowOrigin 0x81c8
+#define GlintWindowOriginTag 0x0039
+#define GlintWindowOriginReg 1
+#define GlintWindowOriginOff 0x71c8
+#define GlintWindowOriginSec 0x81c8
+#define GlintWindowOriginSecReg 3
+#define GlintWindowOriginSecOff 0x71c8
+
+#define GlintAreaStipplePattern0 0x8200
+#define GlintAreaStipplePattern0Tag 0x0040
+#define GlintAreaStipplePattern0Reg 1
+#define GlintAreaStipplePattern0Off 0x7200
+#define GlintAreaStipplePattern0Sec 0x8200
+#define GlintAreaStipplePattern0SecReg 3
+#define GlintAreaStipplePattern0SecOff 0x7200
+
+#define GlintAreaStipplePattern1 0x8208
+#define GlintAreaStipplePattern1Tag 0x0041
+#define GlintAreaStipplePattern1Reg 1
+#define GlintAreaStipplePattern1Off 0x7208
+#define GlintAreaStipplePattern1Sec 0x8208
+#define GlintAreaStipplePattern1SecReg 3
+#define GlintAreaStipplePattern1SecOff 0x7208
+
+#define GlintAreaStipplePattern2 0x8210
+#define GlintAreaStipplePattern2Tag 0x0042
+#define GlintAreaStipplePattern2Reg 1
+#define GlintAreaStipplePattern2Off 0x7210
+#define GlintAreaStipplePattern2Sec 0x8210
+#define GlintAreaStipplePattern2SecReg 3
+#define GlintAreaStipplePattern2SecOff 0x7210
+
+#define GlintAreaStipplePattern3 0x8218
+#define GlintAreaStipplePattern3Tag 0x0043
+#define GlintAreaStipplePattern3Reg 1
+#define GlintAreaStipplePattern3Off 0x7218
+#define GlintAreaStipplePattern3Sec 0x8218
+#define GlintAreaStipplePattern3SecReg 3
+#define GlintAreaStipplePattern3SecOff 0x7218
+
+#define GlintAreaStipplePattern4 0x8220
+#define GlintAreaStipplePattern4Tag 0x0044
+#define GlintAreaStipplePattern4Reg 1
+#define GlintAreaStipplePattern4Off 0x7220
+#define GlintAreaStipplePattern4Sec 0x8220
+#define GlintAreaStipplePattern4SecReg 3
+#define GlintAreaStipplePattern4SecOff 0x7220
+
+#define GlintAreaStipplePattern5 0x8228
+#define GlintAreaStipplePattern5Tag 0x0045
+#define GlintAreaStipplePattern5Reg 1
+#define GlintAreaStipplePattern5Off 0x7228
+#define GlintAreaStipplePattern5Sec 0x8228
+#define GlintAreaStipplePattern5SecReg 3
+#define GlintAreaStipplePattern5SecOff 0x7228
+
+#define GlintAreaStipplePattern6 0x8230
+#define GlintAreaStipplePattern6Tag 0x0046
+#define GlintAreaStipplePattern6Reg 1
+#define GlintAreaStipplePattern6Off 0x7230
+#define GlintAreaStipplePattern6Sec 0x8230
+#define GlintAreaStipplePattern6SecReg 3
+#define GlintAreaStipplePattern6SecOff 0x7230
+
+#define GlintAreaStipplePattern7 0x8238
+#define GlintAreaStipplePattern7Tag 0x0047
+#define GlintAreaStipplePattern7Reg 1
+#define GlintAreaStipplePattern7Off 0x7238
+#define GlintAreaStipplePattern7Sec 0x8238
+#define GlintAreaStipplePattern7SecReg 3
+#define GlintAreaStipplePattern7SecOff 0x7238
+
+#define GlintAreaStipplePattern8 0x8240
+#define GlintAreaStipplePattern8Tag 0x0048
+#define GlintAreaStipplePattern8Reg 1
+#define GlintAreaStipplePattern8Off 0x7240
+#define GlintAreaStipplePattern8Sec 0x8240
+#define GlintAreaStipplePattern8SecReg 3
+#define GlintAreaStipplePattern8SecOff 0x7240
+
+#define GlintAreaStipplePattern9 0x8248
+#define GlintAreaStipplePattern9Tag 0x0049
+#define GlintAreaStipplePattern9Reg 1
+#define GlintAreaStipplePattern9Off 0x7248
+#define GlintAreaStipplePattern9Sec 0x8248
+#define GlintAreaStipplePattern9SecReg 3
+#define GlintAreaStipplePattern9SecOff 0x7248
+
+#define GlintAreaStipplePattern10 0x8250
+#define GlintAreaStipplePattern10Tag 0x004a
+#define GlintAreaStipplePattern10Reg 1
+#define GlintAreaStipplePattern10Off 0x7250
+#define GlintAreaStipplePattern10Sec 0x8250
+#define GlintAreaStipplePattern10SecReg 3
+#define GlintAreaStipplePattern10SecOff 0x7250
+
+#define GlintAreaStipplePattern11 0x8258
+#define GlintAreaStipplePattern11Tag 0x004b
+#define GlintAreaStipplePattern11Reg 1
+#define GlintAreaStipplePattern11Off 0x7258
+#define GlintAreaStipplePattern11Sec 0x8258
+#define GlintAreaStipplePattern11SecReg 3
+#define GlintAreaStipplePattern11SecOff 0x7258
+
+#define GlintAreaStipplePattern12 0x8260
+#define GlintAreaStipplePattern12Tag 0x004c
+#define GlintAreaStipplePattern12Reg 1
+#define GlintAreaStipplePattern12Off 0x7260
+#define GlintAreaStipplePattern12Sec 0x8260
+#define GlintAreaStipplePattern12SecReg 3
+#define GlintAreaStipplePattern12SecOff 0x7260
+
+#define GlintAreaStipplePattern13 0x8268
+#define GlintAreaStipplePattern13Tag 0x004d
+#define GlintAreaStipplePattern13Reg 1
+#define GlintAreaStipplePattern13Off 0x7268
+#define GlintAreaStipplePattern13Sec 0x8268
+#define GlintAreaStipplePattern13SecReg 3
+#define GlintAreaStipplePattern13SecOff 0x7268
+
+#define GlintAreaStipplePattern14 0x8270
+#define GlintAreaStipplePattern14Tag 0x004e
+#define GlintAreaStipplePattern14Reg 1
+#define GlintAreaStipplePattern14Off 0x7270
+#define GlintAreaStipplePattern14Sec 0x8270
+#define GlintAreaStipplePattern14SecReg 3
+#define GlintAreaStipplePattern14SecOff 0x7270
+
+#define GlintAreaStipplePattern15 0x8278
+#define GlintAreaStipplePattern15Tag 0x004f
+#define GlintAreaStipplePattern15Reg 1
+#define GlintAreaStipplePattern15Off 0x7278
+#define GlintAreaStipplePattern15Sec 0x8278
+#define GlintAreaStipplePattern15SecReg 3
+#define GlintAreaStipplePattern15SecOff 0x7278
+
+#define GlintAreaStipplePattern16 0x8280
+#define GlintAreaStipplePattern16Tag 0x0050
+#define GlintAreaStipplePattern16Reg 1
+#define GlintAreaStipplePattern16Off 0x7280
+#define GlintAreaStipplePattern16Sec 0x8280
+#define GlintAreaStipplePattern16SecReg 3
+#define GlintAreaStipplePattern16SecOff 0x7280
+
+#define GlintAreaStipplePattern17 0x8288
+#define GlintAreaStipplePattern17Tag 0x0051
+#define GlintAreaStipplePattern17Reg 1
+#define GlintAreaStipplePattern17Off 0x7288
+#define GlintAreaStipplePattern17Sec 0x8288
+#define GlintAreaStipplePattern17SecReg 3
+#define GlintAreaStipplePattern17SecOff 0x7288
+
+#define GlintAreaStipplePattern18 0x8290
+#define GlintAreaStipplePattern18Tag 0x0052
+#define GlintAreaStipplePattern18Reg 1
+#define GlintAreaStipplePattern18Off 0x7290
+#define GlintAreaStipplePattern18Sec 0x8290
+#define GlintAreaStipplePattern18SecReg 3
+#define GlintAreaStipplePattern18SecOff 0x7290
+
+#define GlintAreaStipplePattern19 0x8298
+#define GlintAreaStipplePattern19Tag 0x0053
+#define GlintAreaStipplePattern19Reg 1
+#define GlintAreaStipplePattern19Off 0x7298
+#define GlintAreaStipplePattern19Sec 0x8298
+#define GlintAreaStipplePattern19SecReg 3
+#define GlintAreaStipplePattern19SecOff 0x7298
+
+#define GlintAreaStipplePattern20 0x82a0
+#define GlintAreaStipplePattern20Tag 0x0054
+#define GlintAreaStipplePattern20Reg 1
+#define GlintAreaStipplePattern20Off 0x72a0
+#define GlintAreaStipplePattern20Sec 0x82a0
+#define GlintAreaStipplePattern20SecReg 3
+#define GlintAreaStipplePattern20SecOff 0x72a0
+
+#define GlintAreaStipplePattern21 0x82a8
+#define GlintAreaStipplePattern21Tag 0x0055
+#define GlintAreaStipplePattern21Reg 1
+#define GlintAreaStipplePattern21Off 0x72a8
+#define GlintAreaStipplePattern21Sec 0x82a8
+#define GlintAreaStipplePattern21SecReg 3
+#define GlintAreaStipplePattern21SecOff 0x72a8
+
+#define GlintAreaStipplePattern22 0x82b0
+#define GlintAreaStipplePattern22Tag 0x0056
+#define GlintAreaStipplePattern22Reg 1
+#define GlintAreaStipplePattern22Off 0x72b0
+#define GlintAreaStipplePattern22Sec 0x82b0
+#define GlintAreaStipplePattern22SecReg 3
+#define GlintAreaStipplePattern22SecOff 0x72b0
+
+#define GlintAreaStipplePattern23 0x82b8
+#define GlintAreaStipplePattern23Tag 0x0057
+#define GlintAreaStipplePattern23Reg 1
+#define GlintAreaStipplePattern23Off 0x72b8
+#define GlintAreaStipplePattern23Sec 0x82b8
+#define GlintAreaStipplePattern23SecReg 3
+#define GlintAreaStipplePattern23SecOff 0x72b8
+
+#define GlintAreaStipplePattern24 0x82c0
+#define GlintAreaStipplePattern24Tag 0x0058
+#define GlintAreaStipplePattern24Reg 1
+#define GlintAreaStipplePattern24Off 0x72c0
+#define GlintAreaStipplePattern24Sec 0x82c0
+#define GlintAreaStipplePattern24SecReg 3
+#define GlintAreaStipplePattern24SecOff 0x72c0
+
+#define GlintAreaStipplePattern25 0x82c8
+#define GlintAreaStipplePattern25Tag 0x0059
+#define GlintAreaStipplePattern25Reg 1
+#define GlintAreaStipplePattern25Off 0x72c8
+#define GlintAreaStipplePattern25Sec 0x82c8
+#define GlintAreaStipplePattern25SecReg 3
+#define GlintAreaStipplePattern25SecOff 0x72c8
+
+#define GlintAreaStipplePattern26 0x82d0
+#define GlintAreaStipplePattern26Tag 0x005a
+#define GlintAreaStipplePattern26Reg 1
+#define GlintAreaStipplePattern26Off 0x72d0
+#define GlintAreaStipplePattern26Sec 0x82d0
+#define GlintAreaStipplePattern26SecReg 3
+#define GlintAreaStipplePattern26SecOff 0x72d0
+
+#define GlintAreaStipplePattern27 0x82d8
+#define GlintAreaStipplePattern27Tag 0x005b
+#define GlintAreaStipplePattern27Reg 1
+#define GlintAreaStipplePattern27Off 0x72d8
+#define GlintAreaStipplePattern27Sec 0x82d8
+#define GlintAreaStipplePattern27SecReg 3
+#define GlintAreaStipplePattern27SecOff 0x72d8
+
+#define GlintAreaStipplePattern28 0x82e0
+#define GlintAreaStipplePattern28Tag 0x005c
+#define GlintAreaStipplePattern28Reg 1
+#define GlintAreaStipplePattern28Off 0x72e0
+#define GlintAreaStipplePattern28Sec 0x82e0
+#define GlintAreaStipplePattern28SecReg 3
+#define GlintAreaStipplePattern28SecOff 0x72e0
+
+#define GlintAreaStipplePattern29 0x82e8
+#define GlintAreaStipplePattern29Tag 0x005d
+#define GlintAreaStipplePattern29Reg 1
+#define GlintAreaStipplePattern29Off 0x72e8
+#define GlintAreaStipplePattern29Sec 0x82e8
+#define GlintAreaStipplePattern29SecReg 3
+#define GlintAreaStipplePattern29SecOff 0x72e8
+
+#define GlintAreaStipplePattern30 0x82f0
+#define GlintAreaStipplePattern30Tag 0x005e
+#define GlintAreaStipplePattern30Reg 1
+#define GlintAreaStipplePattern30Off 0x72f0
+#define GlintAreaStipplePattern30Sec 0x82f0
+#define GlintAreaStipplePattern30SecReg 3
+#define GlintAreaStipplePattern30SecOff 0x72f0
+
+#define GlintAreaStipplePattern31 0x82f8
+#define GlintAreaStipplePattern31Tag 0x005f
+#define GlintAreaStipplePattern31Reg 1
+#define GlintAreaStipplePattern31Off 0x72f8
+#define GlintAreaStipplePattern31Sec 0x82f8
+#define GlintAreaStipplePattern31SecReg 3
+#define GlintAreaStipplePattern31SecOff 0x72f8
+
+#define GlintRouterMode 0x8840
+#define GlintRouterModeTag 0x0108
+#define GlintRouterModeReg 1
+#define GlintRouterModeOff 0x7840
+#define GlintRouterModeSec 0x8840
+#define GlintRouterModeSecReg 3
+#define GlintRouterModeSecOff 0x7840
+
+#define GlintTextureAddressMode 0x8380
+#define GlintTextureAddressModeTag 0x0070
+#define GlintTextureAddressModeReg 1
+#define GlintTextureAddressModeOff 0x7380
+#define GlintTextureAddressModeSec 0x8380
+#define GlintTextureAddressModeSecReg 3
+#define GlintTextureAddressModeSecOff 0x7380
+
+#define GlintSStart 0x8388
+#define GlintSStartTag 0x0071
+#define GlintSStartReg 1
+#define GlintSStartOff 0x7388
+#define GlintSStartSec 0x8388
+#define GlintSStartSecReg 3
+#define GlintSStartSecOff 0x7388
+
+#define GlintdSdx 0x8390
+#define GlintdSdxTag 0x0072
+#define GlintdSdxReg 1
+#define GlintdSdxOff 0x7390
+#define GlintdSdxSec 0x8390
+#define GlintdSdxSecReg 3
+#define GlintdSdxSecOff 0x7390
+
+#define GlintdSdyDom 0x8398
+#define GlintdSdyDomTag 0x0073
+#define GlintdSdyDomReg 1
+#define GlintdSdyDomOff 0x7398
+#define GlintdSdyDomSec 0x8398
+#define GlintdSdyDomSecReg 3
+#define GlintdSdyDomSecOff 0x7398
+
+#define GlintTStart 0x83a0
+#define GlintTStartTag 0x0074
+#define GlintTStartReg 1
+#define GlintTStartOff 0x73a0
+#define GlintTStartSec 0x83a0
+#define GlintTStartSecReg 3
+#define GlintTStartSecOff 0x73a0
+
+#define GlintdTdx 0x83a8
+#define GlintdTdxTag 0x0075
+#define GlintdTdxReg 1
+#define GlintdTdxOff 0x73a8
+#define GlintdTdxSec 0x83a8
+#define GlintdTdxSecReg 3
+#define GlintdTdxSecOff 0x73a8
+
+#define GlintdTdyDom 0x83b0
+#define GlintdTdyDomTag 0x0076
+#define GlintdTdyDomReg 1
+#define GlintdTdyDomOff 0x73b0
+#define GlintdTdyDomSec 0x83b0
+#define GlintdTdyDomSecReg 3
+#define GlintdTdyDomSecOff 0x73b0
+
+#define GlintQStart 0x83b8
+#define GlintQStartTag 0x0077
+#define GlintQStartReg 1
+#define GlintQStartOff 0x73b8
+#define GlintQStartSec 0x83b8
+#define GlintQStartSecReg 3
+#define GlintQStartSecOff 0x73b8
+
+#define GlintdQdx 0x83c0
+#define GlintdQdxTag 0x0078
+#define GlintdQdxReg 1
+#define GlintdQdxOff 0x73c0
+#define GlintdQdxSec 0x83c0
+#define GlintdQdxSecReg 3
+#define GlintdQdxSecOff 0x73c0
+
+#define GlintdQdyDom 0x83c8
+#define GlintdQdyDomTag 0x0079
+#define GlintdQdyDomReg 1
+#define GlintdQdyDomOff 0x73c8
+#define GlintdQdyDomSec 0x83c8
+#define GlintdQdyDomSecReg 3
+#define GlintdQdyDomSecOff 0x73c8
+
+#define GlintLOD 0x83d0
+#define GlintLODTag 0x007a
+#define GlintLODReg 1
+#define GlintLODOff 0x73d0
+#define GlintLODSec 0x83d0
+#define GlintLODSecReg 3
+#define GlintLODSecOff 0x73d0
+
+#define GlintdSdy 0x83d8
+#define GlintdSdyTag 0x007b
+#define GlintdSdyReg 1
+#define GlintdSdyOff 0x73d8
+#define GlintdSdySec 0x83d8
+#define GlintdSdySecReg 3
+#define GlintdSdySecOff 0x73d8
+
+#define GlintdTdy 0x83e0
+#define GlintdTdyTag 0x007c
+#define GlintdTdyReg 1
+#define GlintdTdyOff 0x73e0
+#define GlintdTdySec 0x83e0
+#define GlintdTdySecReg 3
+#define GlintdTdySecOff 0x73e0
+
+#define GlintdQdy 0x83e8
+#define GlintdQdyTag 0x007d
+#define GlintdQdyReg 1
+#define GlintdQdyOff 0x73e8
+#define GlintdQdySec 0x83e8
+#define GlintdQdySecReg 3
+#define GlintdQdySecOff 0x73e8
+
+#define GlintTextureReadMode 0x8480
+#define GlintTextureReadModeTag 0x0090
+#define GlintTextureReadModeReg 1
+#define GlintTextureReadModeOff 0x7480
+#define GlintTextureReadModeSec 0x8480
+#define GlintTextureReadModeSecReg 3
+#define GlintTextureReadModeSecOff 0x7480
+
+#define GlintTextureFormat 0x8488
+#define GlintTextureFormatTag 0x0091
+#define GlintTextureFormatReg 1
+#define GlintTextureFormatOff 0x7488
+#define GlintTextureFormatSec 0x8488
+#define GlintTextureFormatSecReg 3
+#define GlintTextureFormatSecOff 0x7488
+
+#define GlintTextureCacheControl 0x8490
+#define GlintTextureCacheControlTag 0x0092
+#define GlintTextureCacheControlReg 1
+#define GlintTextureCacheControlOff 0x7490
+#define GlintTextureCacheControlSec 0x8490
+#define GlintTextureCacheControlSecReg 3
+#define GlintTextureCacheControlSecOff 0x7490
+
+#define GlintGLINTBorderColor 0x84a8
+#define GlintGLINTBorderColorTag 0x0095
+#define GlintGLINTBorderColorReg 1
+#define GlintGLINTBorderColorOff 0x74a8
+#define GlintGLINTBorderColorSec 0x84a8
+#define GlintGLINTBorderColorSecReg 3
+#define GlintGLINTBorderColorSecOff 0x74a8
+
+#define GlintTexelLUTIndex 0x84c0
+#define GlintTexelLUTIndexTag 0x0098
+#define GlintTexelLUTIndexReg 1
+#define GlintTexelLUTIndexOff 0x74c0
+#define GlintTexelLUTIndexSec 0x84c0
+#define GlintTexelLUTIndexSecReg 3
+#define GlintTexelLUTIndexSecOff 0x74c0
+
+#define GlintTexelLUTData 0x84c8
+#define GlintTexelLUTDataTag 0x0099
+#define GlintTexelLUTDataReg 1
+#define GlintTexelLUTDataOff 0x74c8
+#define GlintTexelLUTDataSec 0x84c8
+#define GlintTexelLUTDataSecReg 3
+#define GlintTexelLUTDataSecOff 0x74c8
+
+#define GlintTexelLUTAddress 0x84d0
+#define GlintTexelLUTAddressTag 0x009a
+#define GlintTexelLUTAddressReg 1
+#define GlintTexelLUTAddressOff 0x74d0
+#define GlintTexelLUTAddressSec 0x84d0
+#define GlintTexelLUTAddressSecReg 3
+#define GlintTexelLUTAddressSecOff 0x74d0
+
+#define GlintTexelLUTTransfer 0x84d8
+#define GlintTexelLUTTransferTag 0x009b
+#define GlintTexelLUTTransferReg 1
+#define GlintTexelLUTTransferOff 0x74d8
+#define GlintTexelLUTTransferSec 0x84d8
+#define GlintTexelLUTTransferSecReg 3
+#define GlintTexelLUTTransferSecOff 0x74d8
+
+#define GlintTextureFilterMode 0x84e0
+#define GlintTextureFilterModeTag 0x009c
+#define GlintTextureFilterModeReg 1
+#define GlintTextureFilterModeOff 0x74e0
+#define GlintTextureFilterModeSec 0x84e0
+#define GlintTextureFilterModeSecReg 3
+#define GlintTextureFilterModeSecOff 0x74e0
+
+#define GlintTextureChromaUpper 0x84e8
+#define GlintTextureChromaUpperTag 0x009d
+#define GlintTextureChromaUpperReg 1
+#define GlintTextureChromaUpperOff 0x74e8
+#define GlintTextureChromaUpperSec 0x84e8
+#define GlintTextureChromaUpperSecReg 3
+#define GlintTextureChromaUpperSecOff 0x74e8
+
+#define GlintTextureChromaLower 0x84f0
+#define GlintTextureChromaLowerTag 0x009e
+#define GlintTextureChromaLowerReg 1
+#define GlintTextureChromaLowerOff 0x74f0
+#define GlintTextureChromaLowerSec 0x84f0
+#define GlintTextureChromaLowerSecReg 3
+#define GlintTextureChromaLowerSecOff 0x74f0
+
+#define GlintTxBaseAddr0 0x8500
+#define GlintTxBaseAddr0Tag 0x00a0
+#define GlintTxBaseAddr0Reg 1
+#define GlintTxBaseAddr0Off 0x7500
+#define GlintTxBaseAddr0Sec 0x8500
+#define GlintTxBaseAddr0SecReg 3
+#define GlintTxBaseAddr0SecOff 0x7500
+
+#define GlintTxBaseAddr1 0x8508
+#define GlintTxBaseAddr1Tag 0x00a1
+#define GlintTxBaseAddr1Reg 1
+#define GlintTxBaseAddr1Off 0x7508
+#define GlintTxBaseAddr1Sec 0x8508
+#define GlintTxBaseAddr1SecReg 3
+#define GlintTxBaseAddr1SecOff 0x7508
+
+#define GlintTxBaseAddr2 0x8510
+#define GlintTxBaseAddr2Tag 0x00a2
+#define GlintTxBaseAddr2Reg 1
+#define GlintTxBaseAddr2Off 0x7510
+#define GlintTxBaseAddr2Sec 0x8510
+#define GlintTxBaseAddr2SecReg 3
+#define GlintTxBaseAddr2SecOff 0x7510
+
+#define GlintTxBaseAddr3 0x8518
+#define GlintTxBaseAddr3Tag 0x00a3
+#define GlintTxBaseAddr3Reg 1
+#define GlintTxBaseAddr3Off 0x7518
+#define GlintTxBaseAddr3Sec 0x8518
+#define GlintTxBaseAddr3SecReg 3
+#define GlintTxBaseAddr3SecOff 0x7518
+
+#define GlintTxBaseAddr4 0x8520
+#define GlintTxBaseAddr4Tag 0x00a4
+#define GlintTxBaseAddr4Reg 1
+#define GlintTxBaseAddr4Off 0x7520
+#define GlintTxBaseAddr4Sec 0x8520
+#define GlintTxBaseAddr4SecReg 3
+#define GlintTxBaseAddr4SecOff 0x7520
+
+#define GlintTxBaseAddr5 0x8528
+#define GlintTxBaseAddr5Tag 0x00a5
+#define GlintTxBaseAddr5Reg 1
+#define GlintTxBaseAddr5Off 0x7528
+#define GlintTxBaseAddr5Sec 0x8528
+#define GlintTxBaseAddr5SecReg 3
+#define GlintTxBaseAddr5SecOff 0x7528
+
+#define GlintTxBaseAddr6 0x8530
+#define GlintTxBaseAddr6Tag 0x00a6
+#define GlintTxBaseAddr6Reg 1
+#define GlintTxBaseAddr6Off 0x7530
+#define GlintTxBaseAddr6Sec 0x8530
+#define GlintTxBaseAddr6SecReg 3
+#define GlintTxBaseAddr6SecOff 0x7530
+
+#define GlintTxBaseAddr7 0x8538
+#define GlintTxBaseAddr7Tag 0x00a7
+#define GlintTxBaseAddr7Reg 1
+#define GlintTxBaseAddr7Off 0x7538
+#define GlintTxBaseAddr7Sec 0x8538
+#define GlintTxBaseAddr7SecReg 3
+#define GlintTxBaseAddr7SecOff 0x7538
+
+#define GlintTxBaseAddr8 0x8540
+#define GlintTxBaseAddr8Tag 0x00a8
+#define GlintTxBaseAddr8Reg 1
+#define GlintTxBaseAddr8Off 0x7540
+#define GlintTxBaseAddr8Sec 0x8540
+#define GlintTxBaseAddr8SecReg 3
+#define GlintTxBaseAddr8SecOff 0x7540
+
+#define GlintTxBaseAddr9 0x8548
+#define GlintTxBaseAddr9Tag 0x00a9
+#define GlintTxBaseAddr9Reg 1
+#define GlintTxBaseAddr9Off 0x7548
+#define GlintTxBaseAddr9Sec 0x8548
+#define GlintTxBaseAddr9SecReg 3
+#define GlintTxBaseAddr9SecOff 0x7548
+
+#define GlintTxBaseAddr10 0x8550
+#define GlintTxBaseAddr10Tag 0x00aa
+#define GlintTxBaseAddr10Reg 1
+#define GlintTxBaseAddr10Off 0x7550
+#define GlintTxBaseAddr10Sec 0x8550
+#define GlintTxBaseAddr10SecReg 3
+#define GlintTxBaseAddr10SecOff 0x7550
+
+#define GlintTxBaseAddr11 0x8558
+#define GlintTxBaseAddr11Tag 0x00ab
+#define GlintTxBaseAddr11Reg 1
+#define GlintTxBaseAddr11Off 0x7558
+#define GlintTxBaseAddr11Sec 0x8558
+#define GlintTxBaseAddr11SecReg 3
+#define GlintTxBaseAddr11SecOff 0x7558
+
+#define GlintTxBaseAddr12 0x8560
+#define GlintTxBaseAddr12Tag 0x00ac
+#define GlintTxBaseAddr12Reg 1
+#define GlintTxBaseAddr12Off 0x7560
+#define GlintTxBaseAddr12Sec 0x8560
+#define GlintTxBaseAddr12SecReg 3
+#define GlintTxBaseAddr12SecOff 0x7560
+
+#define GlintTexelLUT0 0x8e80
+#define GlintTexelLUT0Tag 0x01d0
+#define GlintTexelLUT0Reg 1
+#define GlintTexelLUT0Off 0x7e80
+#define GlintTexelLUT0Sec 0x8e80
+#define GlintTexelLUT0SecReg 3
+#define GlintTexelLUT0SecOff 0x7e80
+
+#define GlintTexelLUT1 0x8e88
+#define GlintTexelLUT1Tag 0x01d1
+#define GlintTexelLUT1Reg 1
+#define GlintTexelLUT1Off 0x7e88
+#define GlintTexelLUT1Sec 0x8e88
+#define GlintTexelLUT1SecReg 3
+#define GlintTexelLUT1SecOff 0x7e88
+
+#define GlintTexelLUT2 0x8e90
+#define GlintTexelLUT2Tag 0x01d2
+#define GlintTexelLUT2Reg 1
+#define GlintTexelLUT2Off 0x7e90
+#define GlintTexelLUT2Sec 0x8e90
+#define GlintTexelLUT2SecReg 3
+#define GlintTexelLUT2SecOff 0x7e90
+
+#define GlintTexelLUT3 0x8e98
+#define GlintTexelLUT3Tag 0x01d3
+#define GlintTexelLUT3Reg 1
+#define GlintTexelLUT3Off 0x7e98
+#define GlintTexelLUT3Sec 0x8e98
+#define GlintTexelLUT3SecReg 3
+#define GlintTexelLUT3SecOff 0x7e98
+
+#define GlintTexelLUT4 0x8ea0
+#define GlintTexelLUT4Tag 0x01d4
+#define GlintTexelLUT4Reg 1
+#define GlintTexelLUT4Off 0x7ea0
+#define GlintTexelLUT4Sec 0x8ea0
+#define GlintTexelLUT4SecReg 3
+#define GlintTexelLUT4SecOff 0x7ea0
+
+#define GlintTexelLUT5 0x8ea8
+#define GlintTexelLUT5Tag 0x01d5
+#define GlintTexelLUT5Reg 1
+#define GlintTexelLUT5Off 0x7ea8
+#define GlintTexelLUT5Sec 0x8ea8
+#define GlintTexelLUT5SecReg 3
+#define GlintTexelLUT5SecOff 0x7ea8
+
+#define GlintTexelLUT6 0x8eb0
+#define GlintTexelLUT6Tag 0x01d6
+#define GlintTexelLUT6Reg 1
+#define GlintTexelLUT6Off 0x7eb0
+#define GlintTexelLUT6Sec 0x8eb0
+#define GlintTexelLUT6SecReg 3
+#define GlintTexelLUT6SecOff 0x7eb0
+
+#define GlintTexelLUT7 0x8eb8
+#define GlintTexelLUT7Tag 0x01d7
+#define GlintTexelLUT7Reg 1
+#define GlintTexelLUT7Off 0x7eb8
+#define GlintTexelLUT7Sec 0x8eb8
+#define GlintTexelLUT7SecReg 3
+#define GlintTexelLUT7SecOff 0x7eb8
+
+#define GlintTexelLUT8 0x8ec0
+#define GlintTexelLUT8Tag 0x01d8
+#define GlintTexelLUT8Reg 1
+#define GlintTexelLUT8Off 0x7ec0
+#define GlintTexelLUT8Sec 0x8ec0
+#define GlintTexelLUT8SecReg 3
+#define GlintTexelLUT8SecOff 0x7ec0
+
+#define GlintTexelLUT9 0x8ec8
+#define GlintTexelLUT9Tag 0x01d9
+#define GlintTexelLUT9Reg 1
+#define GlintTexelLUT9Off 0x7ec8
+#define GlintTexelLUT9Sec 0x8ec8
+#define GlintTexelLUT9SecReg 3
+#define GlintTexelLUT9SecOff 0x7ec8
+
+#define GlintTexelLUT10 0x8ed0
+#define GlintTexelLUT10Tag 0x01da
+#define GlintTexelLUT10Reg 1
+#define GlintTexelLUT10Off 0x7ed0
+#define GlintTexelLUT10Sec 0x8ed0
+#define GlintTexelLUT10SecReg 3
+#define GlintTexelLUT10SecOff 0x7ed0
+
+#define GlintTexelLUT11 0x8ed8
+#define GlintTexelLUT11Tag 0x01db
+#define GlintTexelLUT11Reg 1
+#define GlintTexelLUT11Off 0x7ed8
+#define GlintTexelLUT11Sec 0x8ed8
+#define GlintTexelLUT11SecReg 3
+#define GlintTexelLUT11SecOff 0x7ed8
+
+#define GlintTexelLUT12 0x8ee0
+#define GlintTexelLUT12Tag 0x01dc
+#define GlintTexelLUT12Reg 1
+#define GlintTexelLUT12Off 0x7ee0
+#define GlintTexelLUT12Sec 0x8ee0
+#define GlintTexelLUT12SecReg 3
+#define GlintTexelLUT12SecOff 0x7ee0
+
+#define GlintTexelLUT13 0x8ee8
+#define GlintTexelLUT13Tag 0x01dd
+#define GlintTexelLUT13Reg 1
+#define GlintTexelLUT13Off 0x7ee8
+#define GlintTexelLUT13Sec 0x8ee8
+#define GlintTexelLUT13SecReg 3
+#define GlintTexelLUT13SecOff 0x7ee8
+
+#define GlintTexelLUT14 0x8ef0
+#define GlintTexelLUT14Tag 0x01de
+#define GlintTexelLUT14Reg 1
+#define GlintTexelLUT14Off 0x7ef0
+#define GlintTexelLUT14Sec 0x8ef0
+#define GlintTexelLUT14SecReg 3
+#define GlintTexelLUT14SecOff 0x7ef0
+
+#define GlintTexelLUT15 0x8ef8
+#define GlintTexelLUT15Tag 0x01df
+#define GlintTexelLUT15Reg 1
+#define GlintTexelLUT15Off 0x7ef8
+#define GlintTexelLUT15Sec 0x8ef8
+#define GlintTexelLUT15SecReg 3
+#define GlintTexelLUT15SecOff 0x7ef8
+
+#define GlintTexel0 0x8600
+#define GlintTexel0Tag 0x00c0
+#define GlintTexel0Reg 1
+#define GlintTexel0Off 0x7600
+#define GlintTexel0Sec 0x8600
+#define GlintTexel0SecReg 3
+#define GlintTexel0SecOff 0x7600
+
+#define GlintTexel1 0x8608
+#define GlintTexel1Tag 0x00c1
+#define GlintTexel1Reg 1
+#define GlintTexel1Off 0x7608
+#define GlintTexel1Sec 0x8608
+#define GlintTexel1SecReg 3
+#define GlintTexel1SecOff 0x7608
+
+#define GlintTexel2 0x8610
+#define GlintTexel2Tag 0x00c2
+#define GlintTexel2Reg 1
+#define GlintTexel2Off 0x7610
+#define GlintTexel2Sec 0x8610
+#define GlintTexel2SecReg 3
+#define GlintTexel2SecOff 0x7610
+
+#define GlintTexel3 0x8618
+#define GlintTexel3Tag 0x00c3
+#define GlintTexel3Reg 1
+#define GlintTexel3Off 0x7618
+#define GlintTexel3Sec 0x8618
+#define GlintTexel3SecReg 3
+#define GlintTexel3SecOff 0x7618
+
+#define GlintTexel4 0x8620
+#define GlintTexel4Tag 0x00c4
+#define GlintTexel4Reg 1
+#define GlintTexel4Off 0x7620
+#define GlintTexel4Sec 0x8620
+#define GlintTexel4SecReg 3
+#define GlintTexel4SecOff 0x7620
+
+#define GlintTexel5 0x8628
+#define GlintTexel5Tag 0x00c5
+#define GlintTexel5Reg 1
+#define GlintTexel5Off 0x7628
+#define GlintTexel5Sec 0x8628
+#define GlintTexel5SecReg 3
+#define GlintTexel5SecOff 0x7628
+
+#define GlintTexel6 0x8630
+#define GlintTexel6Tag 0x00c6
+#define GlintTexel6Reg 1
+#define GlintTexel6Off 0x7630
+#define GlintTexel6Sec 0x8630
+#define GlintTexel6SecReg 3
+#define GlintTexel6SecOff 0x7630
+
+#define GlintTexel7 0x8638
+#define GlintTexel7Tag 0x00c7
+#define GlintTexel7Reg 1
+#define GlintTexel7Off 0x7638
+#define GlintTexel7Sec 0x8638
+#define GlintTexel7SecReg 3
+#define GlintTexel7SecOff 0x7638
+
+#define GlintInterp0 0x8640
+#define GlintInterp0Tag 0x00c8
+#define GlintInterp0Reg 1
+#define GlintInterp0Off 0x7640
+#define GlintInterp0Sec 0x8640
+#define GlintInterp0SecReg 3
+#define GlintInterp0SecOff 0x7640
+
+#define GlintInterp1 0x8648
+#define GlintInterp1Tag 0x00c9
+#define GlintInterp1Reg 1
+#define GlintInterp1Off 0x7648
+#define GlintInterp1Sec 0x8648
+#define GlintInterp1SecReg 3
+#define GlintInterp1SecOff 0x7648
+
+#define GlintInterp2 0x8650
+#define GlintInterp2Tag 0x00ca
+#define GlintInterp2Reg 1
+#define GlintInterp2Off 0x7650
+#define GlintInterp2Sec 0x8650
+#define GlintInterp2SecReg 3
+#define GlintInterp2SecOff 0x7650
+
+#define GlintInterp3 0x8658
+#define GlintInterp3Tag 0x00cb
+#define GlintInterp3Reg 1
+#define GlintInterp3Off 0x7658
+#define GlintInterp3Sec 0x8658
+#define GlintInterp3SecReg 3
+#define GlintInterp3SecOff 0x7658
+
+#define GlintInterp4 0x8660
+#define GlintInterp4Tag 0x00cc
+#define GlintInterp4Reg 1
+#define GlintInterp4Off 0x7660
+#define GlintInterp4Sec 0x8660
+#define GlintInterp4SecReg 3
+#define GlintInterp4SecOff 0x7660
+
+#define GlintTextureFilter 0x8668
+#define GlintTextureFilterTag 0x00cd
+#define GlintTextureFilterReg 1
+#define GlintTextureFilterOff 0x7668
+#define GlintTextureFilterSec 0x8668
+#define GlintTextureFilterSecReg 3
+#define GlintTextureFilterSecOff 0x7668
+
+#define GlintTextureColorMode 0x8680
+#define GlintTextureColorModeTag 0x00d0
+#define GlintTextureColorModeReg 1
+#define GlintTextureColorModeOff 0x7680
+#define GlintTextureColorModeSec 0x8680
+#define GlintTextureColorModeSecReg 3
+#define GlintTextureColorModeSecOff 0x7680
+
+#define GlintTextureEnvColor 0x8688
+#define GlintTextureEnvColorTag 0x00d1
+#define GlintTextureEnvColorReg 1
+#define GlintTextureEnvColorOff 0x7688
+#define GlintTextureEnvColorSec 0x8688
+#define GlintTextureEnvColorSecReg 3
+#define GlintTextureEnvColorSecOff 0x7688
+
+#define GlintFogMode 0x8690
+#define GlintFogModeTag 0x00d2
+#define GlintFogModeReg 1
+#define GlintFogModeOff 0x7690
+#define GlintFogModeSec 0x8690
+#define GlintFogModeSecReg 3
+#define GlintFogModeSecOff 0x7690
+
+#define GlintFogColor 0x8698
+#define GlintFogColorTag 0x00d3
+#define GlintFogColorReg 1
+#define GlintFogColorOff 0x7698
+#define GlintFogColorSec 0x8698
+#define GlintFogColorSecReg 3
+#define GlintFogColorSecOff 0x7698
+
+#define GlintFStart 0x86a0
+#define GlintFStartTag 0x00d4
+#define GlintFStartReg 1
+#define GlintFStartOff 0x76a0
+#define GlintFStartSec 0x86a0
+#define GlintFStartSecReg 3
+#define GlintFStartSecOff 0x76a0
+
+#define GlintdFdx 0x86a8
+#define GlintdFdxTag 0x00d5
+#define GlintdFdxReg 1
+#define GlintdFdxOff 0x76a8
+#define GlintdFdxSec 0x86a8
+#define GlintdFdxSecReg 3
+#define GlintdFdxSecOff 0x76a8
+
+#define GlintdFdyDom 0x86b0
+#define GlintdFdyDomTag 0x00d6
+#define GlintdFdyDomReg 1
+#define GlintdFdyDomOff 0x76b0
+#define GlintdFdyDomSec 0x86b0
+#define GlintdFdyDomSecReg 3
+#define GlintdFdyDomSecOff 0x76b0
+
+#define GlintKsStart 0x86c8
+#define GlintKsStartTag 0x00d9
+#define GlintKsStartReg 1
+#define GlintKsStartOff 0x76c8
+#define GlintKsStartSec 0x86c8
+#define GlintKsStartSecReg 3
+#define GlintKsStartSecOff 0x76c8
+
+#define GlintdKsdx 0x86d0
+#define GlintdKsdxTag 0x00da
+#define GlintdKsdxReg 1
+#define GlintdKsdxOff 0x76d0
+#define GlintdKsdxSec 0x86d0
+#define GlintdKsdxSecReg 3
+#define GlintdKsdxSecOff 0x76d0
+
+#define GlintdKsdyDom 0x86d8
+#define GlintdKsdyDomTag 0x00db
+#define GlintdKsdyDomReg 1
+#define GlintdKsdyDomOff 0x76d8
+#define GlintdKsdyDomSec 0x86d8
+#define GlintdKsdyDomSecReg 3
+#define GlintdKsdyDomSecOff 0x76d8
+
+#define GlintKdStart 0x86e0
+#define GlintKdStartTag 0x00dc
+#define GlintKdStartReg 1
+#define GlintKdStartOff 0x76e0
+#define GlintKdStartSec 0x86e0
+#define GlintKdStartSecReg 3
+#define GlintKdStartSecOff 0x76e0
+
+#define GlintdKdStart 0x86e8
+#define GlintdKdStartTag 0x00dd
+#define GlintdKdStartReg 1
+#define GlintdKdStartOff 0x76e8
+#define GlintdKdStartSec 0x86e8
+#define GlintdKdStartSecReg 3
+#define GlintdKdStartSecOff 0x76e8
+
+#define GlintdKddyDom 0x86f0
+#define GlintdKddyDomTag 0x00de
+#define GlintdKddyDomReg 1
+#define GlintdKddyDomOff 0x76f0
+#define GlintdKddyDomSec 0x86f0
+#define GlintdKddyDomSecReg 3
+#define GlintdKddyDomSecOff 0x76f0
+
+#define GlintRStart 0x8780
+#define GlintRStartTag 0x00f0
+#define GlintRStartReg 1
+#define GlintRStartOff 0x7780
+#define GlintRStartSec 0x8780
+#define GlintRStartSecReg 3
+#define GlintRStartSecOff 0x7780
+
+#define GlintdRdx 0x8788
+#define GlintdRdxTag 0x00f1
+#define GlintdRdxReg 1
+#define GlintdRdxOff 0x7788
+#define GlintdRdxSec 0x8788
+#define GlintdRdxSecReg 3
+#define GlintdRdxSecOff 0x7788
+
+#define GlintdRdyDom 0x8790
+#define GlintdRdyDomTag 0x00f2
+#define GlintdRdyDomReg 1
+#define GlintdRdyDomOff 0x7790
+#define GlintdRdyDomSec 0x8790
+#define GlintdRdyDomSecReg 3
+#define GlintdRdyDomSecOff 0x7790
+
+#define GlintGStart 0x8798
+#define GlintGStartTag 0x00f3
+#define GlintGStartReg 1
+#define GlintGStartOff 0x7798
+#define GlintGStartSec 0x8798
+#define GlintGStartSecReg 3
+#define GlintGStartSecOff 0x7798
+
+#define GlintdGdx 0x87a0
+#define GlintdGdxTag 0x00f4
+#define GlintdGdxReg 1
+#define GlintdGdxOff 0x77a0
+#define GlintdGdxSec 0x87a0
+#define GlintdGdxSecReg 3
+#define GlintdGdxSecOff 0x77a0
+
+#define GlintdGdyDom 0x87a8
+#define GlintdGdyDomTag 0x00f5
+#define GlintdGdyDomReg 1
+#define GlintdGdyDomOff 0x77a8
+#define GlintdGdyDomSec 0x87a8
+#define GlintdGdyDomSecReg 3
+#define GlintdGdyDomSecOff 0x77a8
+
+#define GlintBStart 0x87b0
+#define GlintBStartTag 0x00f6
+#define GlintBStartReg 1
+#define GlintBStartOff 0x77b0
+#define GlintBStartSec 0x87b0
+#define GlintBStartSecReg 3
+#define GlintBStartSecOff 0x77b0
+
+#define GlintdBdx 0x87b8
+#define GlintdBdxTag 0x00f7
+#define GlintdBdxReg 1
+#define GlintdBdxOff 0x77b8
+#define GlintdBdxSec 0x87b8
+#define GlintdBdxSecReg 3
+#define GlintdBdxSecOff 0x77b8
+
+#define GlintdBdyDom 0x87c0
+#define GlintdBdyDomTag 0x00f8
+#define GlintdBdyDomReg 1
+#define GlintdBdyDomOff 0x77c0
+#define GlintdBdyDomSec 0x87c0
+#define GlintdBdyDomSecReg 3
+#define GlintdBdyDomSecOff 0x77c0
+
+#define GlintAStart 0x87c8
+#define GlintAStartTag 0x00f9
+#define GlintAStartReg 1
+#define GlintAStartOff 0x77c8
+#define GlintAStartSec 0x87c8
+#define GlintAStartSecReg 3
+#define GlintAStartSecOff 0x77c8
+
+#define GlintdAdx 0x87d0
+#define GlintdAdxTag 0x00fa
+#define GlintdAdxReg 1
+#define GlintdAdxOff 0x77d0
+#define GlintdAdxSec 0x87d0
+#define GlintdAdxSecReg 3
+#define GlintdAdxSecOff 0x77d0
+
+#define GlintdAdyDom 0x87d8
+#define GlintdAdyDomTag 0x00fb
+#define GlintdAdyDomReg 1
+#define GlintdAdyDomOff 0x77d8
+#define GlintdAdyDomSec 0x87d8
+#define GlintdAdyDomSecReg 3
+#define GlintdAdyDomSecOff 0x77d8
+
+#define GlintColorDDAMode 0x87e0
+#define GlintColorDDAModeTag 0x00fc
+#define GlintColorDDAModeReg 1
+#define GlintColorDDAModeOff 0x77e0
+#define GlintColorDDAModeSec 0x87e0
+#define GlintColorDDAModeSecReg 3
+#define GlintColorDDAModeSecOff 0x77e0
+
+#define GlintConstantColor 0x87e8
+#define GlintConstantColorTag 0x00fd
+#define GlintConstantColorReg 1
+#define GlintConstantColorOff 0x77e8
+#define GlintConstantColorSec 0x87e8
+#define GlintConstantColorSecReg 3
+#define GlintConstantColorSecOff 0x77e8
+
+#define GlintGLINTColor 0x87f0
+#define GlintGLINTColorTag 0x00fe
+#define GlintGLINTColorReg 1
+#define GlintGLINTColorOff 0x77f0
+#define GlintGLINTColorSec 0x87f0
+#define GlintGLINTColorSecReg 3
+#define GlintGLINTColorSecOff 0x77f0
+
+#define GlintAlphaTestMode 0x8800
+#define GlintAlphaTestModeTag 0x0100
+#define GlintAlphaTestModeReg 1
+#define GlintAlphaTestModeOff 0x7800
+#define GlintAlphaTestModeSec 0x8800
+#define GlintAlphaTestModeSecReg 3
+#define GlintAlphaTestModeSecOff 0x7800
+
+#define GlintAntialiasMode 0x8808
+#define GlintAntialiasModeTag 0x0101
+#define GlintAntialiasModeReg 1
+#define GlintAntialiasModeOff 0x7808
+#define GlintAntialiasModeSec 0x8808
+#define GlintAntialiasModeSecReg 3
+#define GlintAntialiasModeSecOff 0x7808
+
+#define GlintAlphaBlendMode 0x8810
+#define GlintAlphaBlendModeTag 0x0102
+#define GlintAlphaBlendModeReg 1
+#define GlintAlphaBlendModeOff 0x7810
+#define GlintAlphaBlendModeSec 0x8810
+#define GlintAlphaBlendModeSecReg 3
+#define GlintAlphaBlendModeSecOff 0x7810
+
+#define GlintChromaUpper 0x8f08
+#define GlintChromaUpperTag 0x01e1
+#define GlintChromaUpperReg 1
+#define GlintChromaUpperOff 0x7f08
+#define GlintChromaUpperSec 0x8f08
+#define GlintChromaUpperSecReg 3
+#define GlintChromaUpperSecOff 0x7f08
+
+#define GlintChromaLower 0x8f10
+#define GlintChromaLowerTag 0x01e2
+#define GlintChromaLowerReg 1
+#define GlintChromaLowerOff 0x7f10
+#define GlintChromaLowerSec 0x8f10
+#define GlintChromaLowerSecReg 3
+#define GlintChromaLowerSecOff 0x7f10
+
+#define GlintChromaTestMode 0x8f18
+#define GlintChromaTestModeTag 0x01e3
+#define GlintChromaTestModeReg 1
+#define GlintChromaTestModeOff 0x7f18
+#define GlintChromaTestModeSec 0x8f18
+#define GlintChromaTestModeSecReg 3
+#define GlintChromaTestModeSecOff 0x7f18
+
+#define GlintDitherMode 0x8818
+#define GlintDitherModeTag 0x0103
+#define GlintDitherModeReg 1
+#define GlintDitherModeOff 0x7818
+#define GlintDitherModeSec 0x8818
+#define GlintDitherModeSecReg 3
+#define GlintDitherModeSecOff 0x7818
+
+#define GlintFBSoftwareWriteMask 0x8820
+#define GlintFBSoftwareWriteMaskTag 0x0104
+#define GlintFBSoftwareWriteMaskReg 1
+#define GlintFBSoftwareWriteMaskOff 0x7820
+#define GlintFBSoftwareWriteMaskSec 0x8820
+#define GlintFBSoftwareWriteMaskSecReg 3
+#define GlintFBSoftwareWriteMaskSecOff 0x7820
+
+#define GlintLogicalOpMode 0x8828
+#define GlintLogicalOpModeTag 0x0105
+#define GlintLogicalOpModeReg 1
+#define GlintLogicalOpModeOff 0x7828
+#define GlintLogicalOpModeSec 0x8828
+#define GlintLogicalOpModeSecReg 3
+#define GlintLogicalOpModeSecOff 0x7828
+
+#define GlintFBWriteData 0x8830
+#define GlintFBWriteDataTag 0x0106
+#define GlintFBWriteDataReg 1
+#define GlintFBWriteDataOff 0x7830
+#define GlintFBWriteDataSec 0x8830
+#define GlintFBWriteDataSecReg 3
+#define GlintFBWriteDataSecOff 0x7830
+
+#define GlintLBReadMode 0x8880
+#define GlintLBReadModeTag 0x0110
+#define GlintLBReadModeReg 1
+#define GlintLBReadModeOff 0x7880
+#define GlintLBReadModeSec 0x8880
+#define GlintLBReadModeSecReg 3
+#define GlintLBReadModeSecOff 0x7880
+
+#define GlintLBReadFormat 0x8888
+#define GlintLBReadFormatTag 0x0111
+#define GlintLBReadFormatReg 1
+#define GlintLBReadFormatOff 0x7888
+#define GlintLBReadFormatSec 0x8888
+#define GlintLBReadFormatSecReg 3
+#define GlintLBReadFormatSecOff 0x7888
+
+#define GlintLBSourceOffset 0x8890
+#define GlintLBSourceOffsetTag 0x0112
+#define GlintLBSourceOffsetReg 1
+#define GlintLBSourceOffsetOff 0x7890
+#define GlintLBSourceOffsetSec 0x8890
+#define GlintLBSourceOffsetSecReg 3
+#define GlintLBSourceOffsetSecOff 0x7890
+
+#define GlintLBStencil 0x88a8
+#define GlintLBStencilTag 0x0115
+#define GlintLBStencilReg 1
+#define GlintLBStencilOff 0x78a8
+#define GlintLBStencilSec 0x88a8
+#define GlintLBStencilSecReg 3
+#define GlintLBStencilSecOff 0x78a8
+
+#define GlintLBDepth 0x88b0
+#define GlintLBDepthTag 0x0116
+#define GlintLBDepthReg 1
+#define GlintLBDepthOff 0x78b0
+#define GlintLBDepthSec 0x88b0
+#define GlintLBDepthSecReg 3
+#define GlintLBDepthSecOff 0x78b0
+
+#define GlintLBWindowBase 0x88b8
+#define GlintLBWindowBaseTag 0x0117
+#define GlintLBWindowBaseReg 1
+#define GlintLBWindowBaseOff 0x78b8
+#define GlintLBWindowBaseSec 0x88b8
+#define GlintLBWindowBaseSecReg 3
+#define GlintLBWindowBaseSecOff 0x78b8
+
+#define GlintLBWriteMode 0x88c0
+#define GlintLBWriteModeTag 0x0118
+#define GlintLBWriteModeReg 1
+#define GlintLBWriteModeOff 0x78c0
+#define GlintLBWriteModeSec 0x88c0
+#define GlintLBWriteModeSecReg 3
+#define GlintLBWriteModeSecOff 0x78c0
+
+#define GlintLBWriteFormat 0x88c8
+#define GlintLBWriteFormatTag 0x0119
+#define GlintLBWriteFormatReg 1
+#define GlintLBWriteFormatOff 0x78c8
+#define GlintLBWriteFormatSec 0x88c8
+#define GlintLBWriteFormatSecReg 3
+#define GlintLBWriteFormatSecOff 0x78c8
+
+#define GlintTextureData 0x88e8
+#define GlintTextureDataTag 0x011d
+#define GlintTextureDataReg 1
+#define GlintTextureDataOff 0x78e8
+#define GlintTextureDataSec 0x88e8
+#define GlintTextureDataSecReg 3
+#define GlintTextureDataSecOff 0x78e8
+
+#define GlintTextureDownloadOffset 0x88f0
+#define GlintTextureDownloadOffsetTag 0x011e
+#define GlintTextureDownloadOffsetReg 1
+#define GlintTextureDownloadOffsetOff 0x78f0
+#define GlintTextureDownloadOffsetSec 0x88f0
+#define GlintTextureDownloadOffsetSecReg 3
+#define GlintTextureDownloadOffsetSecOff 0x78f0
+
+#define GlintLBWindowOffset 0x88f8
+#define GlintLBWindowOffsetTag 0x011f
+#define GlintLBWindowOffsetReg 1
+#define GlintLBWindowOffsetOff 0x78f8
+#define GlintLBWindowOffsetSec 0x88f8
+#define GlintLBWindowOffsetSecReg 3
+#define GlintLBWindowOffsetSecOff 0x78f8
+
+#define GlintGLINTWindow 0x8980
+#define GlintGLINTWindowTag 0x0130
+#define GlintGLINTWindowReg 1
+#define GlintGLINTWindowOff 0x7980
+#define GlintGLINTWindowSec 0x8980
+#define GlintGLINTWindowSecReg 3
+#define GlintGLINTWindowSecOff 0x7980
+
+#define GlintStencilMode 0x8988
+#define GlintStencilModeTag 0x0131
+#define GlintStencilModeReg 1
+#define GlintStencilModeOff 0x7988
+#define GlintStencilModeSec 0x8988
+#define GlintStencilModeSecReg 3
+#define GlintStencilModeSecOff 0x7988
+
+#define GlintStencilData 0x8990
+#define GlintStencilDataTag 0x0132
+#define GlintStencilDataReg 1
+#define GlintStencilDataOff 0x7990
+#define GlintStencilDataSec 0x8990
+#define GlintStencilDataSecReg 3
+#define GlintStencilDataSecOff 0x7990
+
+#define GlintGLINTStencil 0x8998
+#define GlintGLINTStencilTag 0x0133
+#define GlintGLINTStencilReg 1
+#define GlintGLINTStencilOff 0x7998
+#define GlintGLINTStencilSec 0x8998
+#define GlintGLINTStencilSecReg 3
+#define GlintGLINTStencilSecOff 0x7998
+
+#define GlintDepthMode 0x89a0
+#define GlintDepthModeTag 0x0134
+#define GlintDepthModeReg 1
+#define GlintDepthModeOff 0x79a0
+#define GlintDepthModeSec 0x89a0
+#define GlintDepthModeSecReg 3
+#define GlintDepthModeSecOff 0x79a0
+
+#define GlintGLINTDepth 0x89a8
+#define GlintGLINTDepthTag 0x0135
+#define GlintGLINTDepthReg 1
+#define GlintGLINTDepthOff 0x79a8
+#define GlintGLINTDepthSec 0x89a8
+#define GlintGLINTDepthSecReg 3
+#define GlintGLINTDepthSecOff 0x79a8
+
+#define GlintZStartU 0x89b0
+#define GlintZStartUTag 0x0136
+#define GlintZStartUReg 1
+#define GlintZStartUOff 0x79b0
+#define GlintZStartUSec 0x89b0
+#define GlintZStartUSecReg 3
+#define GlintZStartUSecOff 0x79b0
+
+#define GlintZStartL 0x89b8
+#define GlintZStartLTag 0x0137
+#define GlintZStartLReg 1
+#define GlintZStartLOff 0x79b8
+#define GlintZStartLSec 0x89b8
+#define GlintZStartLSecReg 3
+#define GlintZStartLSecOff 0x79b8
+
+#define GlintdZdxU 0x89c0
+#define GlintdZdxUTag 0x0138
+#define GlintdZdxUReg 1
+#define GlintdZdxUOff 0x79c0
+#define GlintdZdxUSec 0x89c0
+#define GlintdZdxUSecReg 3
+#define GlintdZdxUSecOff 0x79c0
+
+#define GlintdZdxL 0x89c8
+#define GlintdZdxLTag 0x0139
+#define GlintdZdxLReg 1
+#define GlintdZdxLOff 0x79c8
+#define GlintdZdxLSec 0x89c8
+#define GlintdZdxLSecReg 3
+#define GlintdZdxLSecOff 0x79c8
+
+#define GlintdZdyDomU 0x89d0
+#define GlintdZdyDomUTag 0x013a
+#define GlintdZdyDomUReg 1
+#define GlintdZdyDomUOff 0x79d0
+#define GlintdZdyDomUSec 0x89d0
+#define GlintdZdyDomUSecReg 3
+#define GlintdZdyDomUSecOff 0x79d0
+
+#define GlintdZdyDomL 0x89d8
+#define GlintdZdyDomLTag 0x013b
+#define GlintdZdyDomLReg 1
+#define GlintdZdyDomLOff 0x79d8
+#define GlintdZdyDomLSec 0x89d8
+#define GlintdZdyDomLSecReg 3
+#define GlintdZdyDomLSecOff 0x79d8
+
+#define GlintFastClearDepth 0x89e0
+#define GlintFastClearDepthTag 0x013c
+#define GlintFastClearDepthReg 1
+#define GlintFastClearDepthOff 0x79e0
+#define GlintFastClearDepthSec 0x89e0
+#define GlintFastClearDepthSecReg 3
+#define GlintFastClearDepthSecOff 0x79e0
+
+#define GlintFBReadMode 0x8a80
+#define GlintFBReadModeTag 0x0150
+#define GlintFBReadModeReg 1
+#define GlintFBReadModeOff 0x7a80
+#define GlintFBReadModeSec 0x8a80
+#define GlintFBReadModeSecReg 3
+#define GlintFBReadModeSecOff 0x7a80
+
+#define GlintFBSourceOffset 0x8a88
+#define GlintFBSourceOffsetTag 0x0151
+#define GlintFBSourceOffsetReg 1
+#define GlintFBSourceOffsetOff 0x7a88
+#define GlintFBSourceOffsetSec 0x8a88
+#define GlintFBSourceOffsetSecReg 3
+#define GlintFBSourceOffsetSecOff 0x7a88
+
+#define GlintFBPixelOffset 0x8a90
+#define GlintFBPixelOffsetTag 0x0152
+#define GlintFBPixelOffsetReg 1
+#define GlintFBPixelOffsetOff 0x7a90
+#define GlintFBPixelOffsetSec 0x8a90
+#define GlintFBPixelOffsetSecReg 3
+#define GlintFBPixelOffsetSecOff 0x7a90
+
+#define GlintFBColor 0x8a98
+#define GlintFBColorTag 0x0153
+#define GlintFBColorReg 1
+#define GlintFBColorOff 0x7a98
+#define GlintFBColorSec 0x8a98
+#define GlintFBColorSecReg 3
+#define GlintFBColorSecOff 0x7a98
+
+#define GlintFBData 0x8aa0
+#define GlintFBDataTag 0x0154
+#define GlintFBDataReg 1
+#define GlintFBDataOff 0x7aa0
+#define GlintFBDataSec 0x8aa0
+#define GlintFBDataSecReg 3
+#define GlintFBDataSecOff 0x7aa0
+
+#define GlintFBSourceData 0x8aa8
+#define GlintFBSourceDataTag 0x0155
+#define GlintFBSourceDataReg 1
+#define GlintFBSourceDataOff 0x7aa8
+#define GlintFBSourceDataSec 0x8aa8
+#define GlintFBSourceDataSecReg 3
+#define GlintFBSourceDataSecOff 0x7aa8
+
+#define GlintFBWindowBase 0x8ab0
+#define GlintFBWindowBaseTag 0x0156
+#define GlintFBWindowBaseReg 1
+#define GlintFBWindowBaseOff 0x7ab0
+#define GlintFBWindowBaseSec 0x8ab0
+#define GlintFBWindowBaseSecReg 3
+#define GlintFBWindowBaseSecOff 0x7ab0
+
+#define GlintFBWriteMode 0x8ab8
+#define GlintFBWriteModeTag 0x0157
+#define GlintFBWriteModeReg 1
+#define GlintFBWriteModeOff 0x7ab8
+#define GlintFBWriteModeSec 0x8ab8
+#define GlintFBWriteModeSecReg 3
+#define GlintFBWriteModeSecOff 0x7ab8
+
+#define GlintFBHardwareWriteMask 0x8ac0
+#define GlintFBHardwareWriteMaskTag 0x0158
+#define GlintFBHardwareWriteMaskReg 1
+#define GlintFBHardwareWriteMaskOff 0x7ac0
+#define GlintFBHardwareWriteMaskSec 0x8ac0
+#define GlintFBHardwareWriteMaskSecReg 3
+#define GlintFBHardwareWriteMaskSecOff 0x7ac0
+
+#define GlintFBBlockColor 0x8ac8
+#define GlintFBBlockColorTag 0x0159
+#define GlintFBBlockColorReg 1
+#define GlintFBBlockColorOff 0x7ac8
+#define GlintFBBlockColorSec 0x8ac8
+#define GlintFBBlockColorSecReg 3
+#define GlintFBBlockColorSecOff 0x7ac8
+
+#define GlintPatternRamMode 0x8af8
+#define GlintPatternRamModeTag 0x015f
+#define GlintPatternRamModeReg 1
+#define GlintPatternRamModeOff 0x7af8
+#define GlintPatternRamModeSec 0x8af8
+#define GlintPatternRamModeSecReg 3
+#define GlintPatternRamModeSecOff 0x7af8
+
+#define GlintPatternRamData0 0x8b00
+#define GlintPatternRamData0Tag 0x0160
+#define GlintPatternRamData0Reg 1
+#define GlintPatternRamData0Off 0x7b00
+#define GlintPatternRamData0Sec 0x8b00
+#define GlintPatternRamData0SecReg 3
+#define GlintPatternRamData0SecOff 0x7b00
+
+#define GlintPatternRamData1 0x8b08
+#define GlintPatternRamData1Tag 0x0161
+#define GlintPatternRamData1Reg 1
+#define GlintPatternRamData1Off 0x7b08
+#define GlintPatternRamData1Sec 0x8b08
+#define GlintPatternRamData1SecReg 3
+#define GlintPatternRamData1SecOff 0x7b08
+
+#define GlintPatternRamData2 0x8b10
+#define GlintPatternRamData2Tag 0x0162
+#define GlintPatternRamData2Reg 1
+#define GlintPatternRamData2Off 0x7b10
+#define GlintPatternRamData2Sec 0x8b10
+#define GlintPatternRamData2SecReg 3
+#define GlintPatternRamData2SecOff 0x7b10
+
+#define GlintPatternRamData3 0x8b18
+#define GlintPatternRamData3Tag 0x0163
+#define GlintPatternRamData3Reg 1
+#define GlintPatternRamData3Off 0x7b18
+#define GlintPatternRamData3Sec 0x8b18
+#define GlintPatternRamData3SecReg 3
+#define GlintPatternRamData3SecOff 0x7b18
+
+#define GlintPatternRamData4 0x8b20
+#define GlintPatternRamData4Tag 0x0164
+#define GlintPatternRamData4Reg 1
+#define GlintPatternRamData4Off 0x7b20
+#define GlintPatternRamData4Sec 0x8b20
+#define GlintPatternRamData4SecReg 3
+#define GlintPatternRamData4SecOff 0x7b20
+
+#define GlintPatternRamData5 0x8b28
+#define GlintPatternRamData5Tag 0x0165
+#define GlintPatternRamData5Reg 1
+#define GlintPatternRamData5Off 0x7b28
+#define GlintPatternRamData5Sec 0x8b28
+#define GlintPatternRamData5SecReg 3
+#define GlintPatternRamData5SecOff 0x7b28
+
+#define GlintPatternRamData6 0x8b30
+#define GlintPatternRamData6Tag 0x0166
+#define GlintPatternRamData6Reg 1
+#define GlintPatternRamData6Off 0x7b30
+#define GlintPatternRamData6Sec 0x8b30
+#define GlintPatternRamData6SecReg 3
+#define GlintPatternRamData6SecOff 0x7b30
+
+#define GlintPatternRamData7 0x8b38
+#define GlintPatternRamData7Tag 0x0167
+#define GlintPatternRamData7Reg 1
+#define GlintPatternRamData7Off 0x7b38
+#define GlintPatternRamData7Sec 0x8b38
+#define GlintPatternRamData7SecReg 3
+#define GlintPatternRamData7SecOff 0x7b38
+
+#define GlintPatternRamData8 0x8b40
+#define GlintPatternRamData8Tag 0x0168
+#define GlintPatternRamData8Reg 1
+#define GlintPatternRamData8Off 0x7b40
+#define GlintPatternRamData8Sec 0x8b40
+#define GlintPatternRamData8SecReg 3
+#define GlintPatternRamData8SecOff 0x7b40
+
+#define GlintPatternRamData9 0x8b48
+#define GlintPatternRamData9Tag 0x0169
+#define GlintPatternRamData9Reg 1
+#define GlintPatternRamData9Off 0x7b48
+#define GlintPatternRamData9Sec 0x8b48
+#define GlintPatternRamData9SecReg 3
+#define GlintPatternRamData9SecOff 0x7b48
+
+#define GlintPatternRamData10 0x8b50
+#define GlintPatternRamData10Tag 0x016a
+#define GlintPatternRamData10Reg 1
+#define GlintPatternRamData10Off 0x7b50
+#define GlintPatternRamData10Sec 0x8b50
+#define GlintPatternRamData10SecReg 3
+#define GlintPatternRamData10SecOff 0x7b50
+
+#define GlintPatternRamData11 0x8b58
+#define GlintPatternRamData11Tag 0x016b
+#define GlintPatternRamData11Reg 1
+#define GlintPatternRamData11Off 0x7b58
+#define GlintPatternRamData11Sec 0x8b58
+#define GlintPatternRamData11SecReg 3
+#define GlintPatternRamData11SecOff 0x7b58
+
+#define GlintPatternRamData12 0x8b60
+#define GlintPatternRamData12Tag 0x016c
+#define GlintPatternRamData12Reg 1
+#define GlintPatternRamData12Off 0x7b60
+#define GlintPatternRamData12Sec 0x8b60
+#define GlintPatternRamData12SecReg 3
+#define GlintPatternRamData12SecOff 0x7b60
+
+#define GlintPatternRamData13 0x8b68
+#define GlintPatternRamData13Tag 0x016d
+#define GlintPatternRamData13Reg 1
+#define GlintPatternRamData13Off 0x7b68
+#define GlintPatternRamData13Sec 0x8b68
+#define GlintPatternRamData13SecReg 3
+#define GlintPatternRamData13SecOff 0x7b68
+
+#define GlintPatternRamData14 0x8b70
+#define GlintPatternRamData14Tag 0x016e
+#define GlintPatternRamData14Reg 1
+#define GlintPatternRamData14Off 0x7b70
+#define GlintPatternRamData14Sec 0x8b70
+#define GlintPatternRamData14SecReg 3
+#define GlintPatternRamData14SecOff 0x7b70
+
+#define GlintPatternRamData15 0x8b78
+#define GlintPatternRamData15Tag 0x016f
+#define GlintPatternRamData15Reg 1
+#define GlintPatternRamData15Off 0x7b78
+#define GlintPatternRamData15Sec 0x8b78
+#define GlintPatternRamData15SecReg 3
+#define GlintPatternRamData15SecOff 0x7b78
+
+#define GlintPatternRamData16 0x8b80
+#define GlintPatternRamData16Tag 0x0170
+#define GlintPatternRamData16Reg 1
+#define GlintPatternRamData16Off 0x7b80
+#define GlintPatternRamData16Sec 0x8b80
+#define GlintPatternRamData16SecReg 3
+#define GlintPatternRamData16SecOff 0x7b80
+
+#define GlintPatternRamData17 0x8b88
+#define GlintPatternRamData17Tag 0x0171
+#define GlintPatternRamData17Reg 1
+#define GlintPatternRamData17Off 0x7b88
+#define GlintPatternRamData17Sec 0x8b88
+#define GlintPatternRamData17SecReg 3
+#define GlintPatternRamData17SecOff 0x7b88
+
+#define GlintPatternRamData18 0x8b90
+#define GlintPatternRamData18Tag 0x0172
+#define GlintPatternRamData18Reg 1
+#define GlintPatternRamData18Off 0x7b90
+#define GlintPatternRamData18Sec 0x8b90
+#define GlintPatternRamData18SecReg 3
+#define GlintPatternRamData18SecOff 0x7b90
+
+#define GlintPatternRamData19 0x8b98
+#define GlintPatternRamData19Tag 0x0173
+#define GlintPatternRamData19Reg 1
+#define GlintPatternRamData19Off 0x7b98
+#define GlintPatternRamData19Sec 0x8b98
+#define GlintPatternRamData19SecReg 3
+#define GlintPatternRamData19SecOff 0x7b98
+
+#define GlintPatternRamData20 0x8ba0
+#define GlintPatternRamData20Tag 0x0174
+#define GlintPatternRamData20Reg 1
+#define GlintPatternRamData20Off 0x7ba0
+#define GlintPatternRamData20Sec 0x8ba0
+#define GlintPatternRamData20SecReg 3
+#define GlintPatternRamData20SecOff 0x7ba0
+
+#define GlintPatternRamData21 0x8ba8
+#define GlintPatternRamData21Tag 0x0175
+#define GlintPatternRamData21Reg 1
+#define GlintPatternRamData21Off 0x7ba8
+#define GlintPatternRamData21Sec 0x8ba8
+#define GlintPatternRamData21SecReg 3
+#define GlintPatternRamData21SecOff 0x7ba8
+
+#define GlintPatternRamData22 0x8bb0
+#define GlintPatternRamData22Tag 0x0176
+#define GlintPatternRamData22Reg 1
+#define GlintPatternRamData22Off 0x7bb0
+#define GlintPatternRamData22Sec 0x8bb0
+#define GlintPatternRamData22SecReg 3
+#define GlintPatternRamData22SecOff 0x7bb0
+
+#define GlintPatternRamData23 0x8bb8
+#define GlintPatternRamData23Tag 0x0177
+#define GlintPatternRamData23Reg 1
+#define GlintPatternRamData23Off 0x7bb8
+#define GlintPatternRamData23Sec 0x8bb8
+#define GlintPatternRamData23SecReg 3
+#define GlintPatternRamData23SecOff 0x7bb8
+
+#define GlintPatternRamData24 0x8bc0
+#define GlintPatternRamData24Tag 0x0178
+#define GlintPatternRamData24Reg 1
+#define GlintPatternRamData24Off 0x7bc0
+#define GlintPatternRamData24Sec 0x8bc0
+#define GlintPatternRamData24SecReg 3
+#define GlintPatternRamData24SecOff 0x7bc0
+
+#define GlintPatternRamData25 0x8bc8
+#define GlintPatternRamData25Tag 0x0179
+#define GlintPatternRamData25Reg 1
+#define GlintPatternRamData25Off 0x7bc8
+#define GlintPatternRamData25Sec 0x8bc8
+#define GlintPatternRamData25SecReg 3
+#define GlintPatternRamData25SecOff 0x7bc8
+
+#define GlintPatternRamData26 0x8bd0
+#define GlintPatternRamData26Tag 0x017a
+#define GlintPatternRamData26Reg 1
+#define GlintPatternRamData26Off 0x7bd0
+#define GlintPatternRamData26Sec 0x8bd0
+#define GlintPatternRamData26SecReg 3
+#define GlintPatternRamData26SecOff 0x7bd0
+
+#define GlintPatternRamData27 0x8bd8
+#define GlintPatternRamData27Tag 0x017b
+#define GlintPatternRamData27Reg 1
+#define GlintPatternRamData27Off 0x7bd8
+#define GlintPatternRamData27Sec 0x8bd8
+#define GlintPatternRamData27SecReg 3
+#define GlintPatternRamData27SecOff 0x7bd8
+
+#define GlintPatternRamData28 0x8be0
+#define GlintPatternRamData28Tag 0x017c
+#define GlintPatternRamData28Reg 1
+#define GlintPatternRamData28Off 0x7be0
+#define GlintPatternRamData28Sec 0x8be0
+#define GlintPatternRamData28SecReg 3
+#define GlintPatternRamData28SecOff 0x7be0
+
+#define GlintPatternRamData29 0x8be8
+#define GlintPatternRamData29Tag 0x017d
+#define GlintPatternRamData29Reg 1
+#define GlintPatternRamData29Off 0x7be8
+#define GlintPatternRamData29Sec 0x8be8
+#define GlintPatternRamData29SecReg 3
+#define GlintPatternRamData29SecOff 0x7be8
+
+#define GlintPatternRamData30 0x8bf0
+#define GlintPatternRamData30Tag 0x017e
+#define GlintPatternRamData30Reg 1
+#define GlintPatternRamData30Off 0x7bf0
+#define GlintPatternRamData30Sec 0x8bf0
+#define GlintPatternRamData30SecReg 3
+#define GlintPatternRamData30SecOff 0x7bf0
+
+#define GlintPatternRamData31 0x8bf8
+#define GlintPatternRamData31Tag 0x017f
+#define GlintPatternRamData31Reg 1
+#define GlintPatternRamData31Off 0x7bf8
+#define GlintPatternRamData31Sec 0x8bf8
+#define GlintPatternRamData31SecReg 3
+#define GlintPatternRamData31SecOff 0x7bf8
+
+#define GlintFBBlockColorU 0x8c68
+#define GlintFBBlockColorUTag 0x018d
+#define GlintFBBlockColorUReg 1
+#define GlintFBBlockColorUOff 0x7c68
+#define GlintFBBlockColorUSec 0x8c68
+#define GlintFBBlockColorUSecReg 3
+#define GlintFBBlockColorUSecOff 0x7c68
+
+#define GlintFBBlockColorL 0x8c70
+#define GlintFBBlockColorLTag 0x018e
+#define GlintFBBlockColorLReg 1
+#define GlintFBBlockColorLOff 0x7c70
+#define GlintFBBlockColorLSec 0x8c70
+#define GlintFBBlockColorLSecReg 3
+#define GlintFBBlockColorLSecOff 0x7c70
+
+#define GlintSuspendUntilFrameBlank 0x8c78
+#define GlintSuspendUntilFrameBlankTag 0x018f
+#define GlintSuspendUntilFrameBlankReg 1
+#define GlintSuspendUntilFrameBlankOff 0x7c78
+#define GlintSuspendUntilFrameBlankSec 0x8c78
+#define GlintSuspendUntilFrameBlankSecReg 3
+#define GlintSuspendUntilFrameBlankSecOff 0x7c78
+
+#define GlintFilterMode 0x8c00
+#define GlintFilterModeTag 0x0180
+#define GlintFilterModeReg 1
+#define GlintFilterModeOff 0x7c00
+#define GlintFilterModeSec 0x8c00
+#define GlintFilterModeSecReg 3
+#define GlintFilterModeSecOff 0x7c00
+
+#define GlintStatisticMode 0x8c08
+#define GlintStatisticModeTag 0x0181
+#define GlintStatisticModeReg 1
+#define GlintStatisticModeOff 0x7c08
+#define GlintStatisticModeSec 0x8c08
+#define GlintStatisticModeSecReg 3
+#define GlintStatisticModeSecOff 0x7c08
+
+#define GlintMinRegion 0x8c10
+#define GlintMinRegionTag 0x0182
+#define GlintMinRegionReg 1
+#define GlintMinRegionOff 0x7c10
+#define GlintMinRegionSec 0x8c10
+#define GlintMinRegionSecReg 3
+#define GlintMinRegionSecOff 0x7c10
+
+#define GlintMaxRegion 0x8c18
+#define GlintMaxRegionTag 0x0183
+#define GlintMaxRegionReg 1
+#define GlintMaxRegionOff 0x7c18
+#define GlintMaxRegionSec 0x8c18
+#define GlintMaxRegionSecReg 3
+#define GlintMaxRegionSecOff 0x7c18
+
+#define GlintResetPickResult 0x8c20
+#define GlintResetPickResultTag 0x0184
+#define GlintResetPickResultReg 1
+#define GlintResetPickResultOff 0x7c20
+#define GlintResetPickResultSec 0x8c20
+#define GlintResetPickResultSecReg 3
+#define GlintResetPickResultSecOff 0x7c20
+
+#define GlintMitHitRegion 0x8c28
+#define GlintMitHitRegionTag 0x0185
+#define GlintMitHitRegionReg 1
+#define GlintMitHitRegionOff 0x7c28
+#define GlintMitHitRegionSec 0x8c28
+#define GlintMitHitRegionSecReg 3
+#define GlintMitHitRegionSecOff 0x7c28
+
+#define GlintMaxHitRegion 0x8c30
+#define GlintMaxHitRegionTag 0x0186
+#define GlintMaxHitRegionReg 1
+#define GlintMaxHitRegionOff 0x7c30
+#define GlintMaxHitRegionSec 0x8c30
+#define GlintMaxHitRegionSecReg 3
+#define GlintMaxHitRegionSecOff 0x7c30
+
+#define GlintPickResult 0x8c38
+#define GlintPickResultTag 0x0187
+#define GlintPickResultReg 1
+#define GlintPickResultOff 0x7c38
+#define GlintPickResultSec 0x8c38
+#define GlintPickResultSecReg 3
+#define GlintPickResultSecOff 0x7c38
+
+#define GlintGLINTSync 0x8c40
+#define GlintGLINTSyncTag 0x0188
+#define GlintGLINTSyncReg 1
+#define GlintGLINTSyncOff 0x7c40
+#define GlintGLINTSyncSec 0x8c40
+#define GlintGLINTSyncSecReg 3
+#define GlintGLINTSyncSecOff 0x7c40
+
+#define GlintKsRStart 0x8c80
+#define GlintKsRStartTag 0x0190
+#define GlintKsRStartReg 1
+#define GlintKsRStartOff 0x7c80
+#define GlintKsRStartSec 0x8c80
+#define GlintKsRStartSecReg 3
+#define GlintKsRStartSecOff 0x7c80
+
+#define GlintdKsRdx 0x8c88
+#define GlintdKsRdxTag 0x0191
+#define GlintdKsRdxReg 1
+#define GlintdKsRdxOff 0x7c88
+#define GlintdKsRdxSec 0x8c88
+#define GlintdKsRdxSecReg 3
+#define GlintdKsRdxSecOff 0x7c88
+
+#define GlintdKsRdyDom 0x8c90
+#define GlintdKsRdyDomTag 0x0192
+#define GlintdKsRdyDomReg 1
+#define GlintdKsRdyDomOff 0x7c90
+#define GlintdKsRdyDomSec 0x8c90
+#define GlintdKsRdyDomSecReg 3
+#define GlintdKsRdyDomSecOff 0x7c90
+
+#define GlintKsGStart 0x8c98
+#define GlintKsGStartTag 0x0193
+#define GlintKsGStartReg 1
+#define GlintKsGStartOff 0x7c98
+#define GlintKsGStartSec 0x8c98
+#define GlintKsGStartSecReg 3
+#define GlintKsGStartSecOff 0x7c98
+
+#define GlintdKsGdx 0x8ca0
+#define GlintdKsGdxTag 0x0194
+#define GlintdKsGdxReg 1
+#define GlintdKsGdxOff 0x7ca0
+#define GlintdKsGdxSec 0x8ca0
+#define GlintdKsGdxSecReg 3
+#define GlintdKsGdxSecOff 0x7ca0
+
+#define GlintdKsGdyDom 0x8ca8
+#define GlintdKsGdyDomTag 0x0195
+#define GlintdKsGdyDomReg 1
+#define GlintdKsGdyDomOff 0x7ca8
+#define GlintdKsGdyDomSec 0x8ca8
+#define GlintdKsGdyDomSecReg 3
+#define GlintdKsGdyDomSecOff 0x7ca8
+
+#define GlintKsBStart 0x8cb0
+#define GlintKsBStartTag 0x0196
+#define GlintKsBStartReg 1
+#define GlintKsBStartOff 0x7cb0
+#define GlintKsBStartSec 0x8cb0
+#define GlintKsBStartSecReg 3
+#define GlintKsBStartSecOff 0x7cb0
+
+#define GlintdKsBdx 0x8cb8
+#define GlintdKsBdxTag 0x0197
+#define GlintdKsBdxReg 1
+#define GlintdKsBdxOff 0x7cb8
+#define GlintdKsBdxSec 0x8cb8
+#define GlintdKsBdxSecReg 3
+#define GlintdKsBdxSecOff 0x7cb8
+
+#define GlintdKsBdyDom 0x8cc0
+#define GlintdKsBdyDomTag 0x0198
+#define GlintdKsBdyDomReg 1
+#define GlintdKsBdyDomOff 0x7cc0
+#define GlintdKsBdyDomSec 0x8cc0
+#define GlintdKsBdyDomSecReg 3
+#define GlintdKsBdyDomSecOff 0x7cc0
+
+#define GlintKdRStart 0x8d00
+#define GlintKdRStartTag 0x01a0
+#define GlintKdRStartReg 1
+#define GlintKdRStartOff 0x7d00
+#define GlintKdRStartSec 0x8d00
+#define GlintKdRStartSecReg 3
+#define GlintKdRStartSecOff 0x7d00
+
+#define GlintdKdRdx 0x8d08
+#define GlintdKdRdxTag 0x01a1
+#define GlintdKdRdxReg 1
+#define GlintdKdRdxOff 0x7d08
+#define GlintdKdRdxSec 0x8d08
+#define GlintdKdRdxSecReg 3
+#define GlintdKdRdxSecOff 0x7d08
+
+#define GlintdKdRdyDom 0x8d10
+#define GlintdKdRdyDomTag 0x01a2
+#define GlintdKdRdyDomReg 1
+#define GlintdKdRdyDomOff 0x7d10
+#define GlintdKdRdyDomSec 0x8d10
+#define GlintdKdRdyDomSecReg 3
+#define GlintdKdRdyDomSecOff 0x7d10
+
+#define GlintKdGStart 0x8d18
+#define GlintKdGStartTag 0x01a3
+#define GlintKdGStartReg 1
+#define GlintKdGStartOff 0x7d18
+#define GlintKdGStartSec 0x8d18
+#define GlintKdGStartSecReg 3
+#define GlintKdGStartSecOff 0x7d18
+
+#define GlintdKdGdx 0x8d20
+#define GlintdKdGdxTag 0x01a4
+#define GlintdKdGdxReg 1
+#define GlintdKdGdxOff 0x7d20
+#define GlintdKdGdxSec 0x8d20
+#define GlintdKdGdxSecReg 3
+#define GlintdKdGdxSecOff 0x7d20
+
+#define GlintdKdGdyDom 0x8d28
+#define GlintdKdGdyDomTag 0x01a5
+#define GlintdKdGdyDomReg 1
+#define GlintdKdGdyDomOff 0x7d28
+#define GlintdKdGdyDomSec 0x8d28
+#define GlintdKdGdyDomSecReg 3
+#define GlintdKdGdyDomSecOff 0x7d28
+
+#define GlintKdBStart 0x8d30
+#define GlintKdBStartTag 0x01a6
+#define GlintKdBStartReg 1
+#define GlintKdBStartOff 0x7d30
+#define GlintKdBStartSec 0x8d30
+#define GlintKdBStartSecReg 3
+#define GlintKdBStartSecOff 0x7d30
+
+#define GlintdKdBdx 0x8d38
+#define GlintdKdBdxTag 0x01a7
+#define GlintdKdBdxReg 1
+#define GlintdKdBdxOff 0x7d38
+#define GlintdKdBdxSec 0x8d38
+#define GlintdKdBdxSecReg 3
+#define GlintdKdBdxSecOff 0x7d38
+
+#define GlintdKdBdyDom 0x8d40
+#define GlintdKdBdyDomTag 0x01a8
+#define GlintdKdBdyDomReg 1
+#define GlintdKdBdyDomOff 0x7d40
+#define GlintdKdBdyDomSec 0x8d40
+#define GlintdKdBdyDomSecReg 3
+#define GlintdKdBdyDomSecOff 0x7d40
+
+#define GlintContextDump 0x8dc0
+#define GlintContextDumpTag 0x01b8
+#define GlintContextDumpReg 1
+#define GlintContextDumpOff 0x7dc0
+
+#define GlintContextRestore 0x8dc8
+#define GlintContextRestoreTag 0x01b9
+#define GlintContextRestoreReg 1
+#define GlintContextRestoreOff 0x7dc8
+
+#define GlintContextData 0x8dd0
+#define GlintContextDataTag 0x01ba
+#define GlintContextDataReg 1
+#define GlintContextDataOff 0x7dd0
+
+#define GlintFeedbackToken 0x8f80
+#define GlintFeedbackTokenTag 0x01f0
+#define GlintFeedbackTokenReg 1
+#define GlintFeedbackTokenOff 0x7f80
+
+#define GlintFeedbackX 0x8f88
+#define GlintFeedbackXTag 0x01f1
+#define GlintFeedbackXReg 1
+#define GlintFeedbackXOff 0x7f88
+
+#define GlintFeedbackY 0x8f90
+#define GlintFeedbackYTag 0x01f2
+#define GlintFeedbackYReg 1
+#define GlintFeedbackYOff 0x7f90
+
+#define GlintFeedbackZ 0x8f98
+#define GlintFeedbackZTag 0x01f3
+#define GlintFeedbackZReg 1
+#define GlintFeedbackZOff 0x7f98
+
+#define GlintFeedbackW 0x8fa0
+#define GlintFeedbackWTag 0x01f4
+#define GlintFeedbackWReg 1
+#define GlintFeedbackWOff 0x7fa0
+
+#define GlintFeedbackRed 0x8fa8
+#define GlintFeedbackRedTag 0x01f5
+#define GlintFeedbackRedReg 1
+#define GlintFeedbackRedOff 0x7fa8
+
+#define GlintFeedbackGreen 0x8fb0
+#define GlintFeedbackGreenTag 0x01f6
+#define GlintFeedbackGreenReg 1
+#define GlintFeedbackGreenOff 0x7fb0
+
+#define GlintFeedbackBlue 0x8fb8
+#define GlintFeedbackBlueTag 0x01f7
+#define GlintFeedbackBlueReg 1
+#define GlintFeedbackBlueOff 0x7fb8
+
+#define GlintFeedbackAlpha 0x8fc0
+#define GlintFeedbackAlphaTag 0x01f8
+#define GlintFeedbackAlphaReg 1
+#define GlintFeedbackAlphaOff 0x7fc0
+
+#define GlintFeedbackS 0x8fc8
+#define GlintFeedbackSTag 0x01f9
+#define GlintFeedbackSReg 1
+#define GlintFeedbackSOff 0x7fc8
+
+#define GlintFeedbackT 0x8fd0
+#define GlintFeedbackTTag 0x01fa
+#define GlintFeedbackTReg 1
+#define GlintFeedbackTOff 0x7fd0
+
+#define GlintFeedbackR 0x8fd8
+#define GlintFeedbackRTag 0x01fb
+#define GlintFeedbackRReg 1
+#define GlintFeedbackROff 0x7fd8
+
+#define GlintFeedbackQ 0x8fe0
+#define GlintFeedbackQTag 0x01fc
+#define GlintFeedbackQReg 1
+#define GlintFeedbackQOff 0x7fe0
+
+#define GlintSelectRecord 0x8fe8
+#define GlintSelectRecordTag 0x01fd
+#define GlintSelectRecordReg 1
+#define GlintSelectRecordOff 0x7fe8
+
+#define GlintPassThrough 0x8ff0
+#define GlintPassThroughTag 0x01fe
+#define GlintPassThroughReg 1
+#define GlintPassThroughOff 0x7ff0
+
+#define GlintEndOfFeedback 0x8ff8
+#define GlintEndOfFeedbackTag 0x01ff
+#define GlintEndOfFeedbackReg 1
+#define GlintEndOfFeedbackOff 0x7ff8
+
+#define GlintV0FixedS 0x9000
+#define GlintV0FixedSTag 0x0200
+#define GlintV0FixedSReg 1
+#define GlintV0FixedSOff 0x8000
+
+#define GlintV0FixedT 0x9008
+#define GlintV0FixedTTag 0x0201
+#define GlintV0FixedTReg 1
+#define GlintV0FixedTOff 0x8008
+
+#define GlintV0FixedQ 0x9010
+#define GlintV0FixedQTag 0x0202
+#define GlintV0FixedQReg 1
+#define GlintV0FixedQOff 0x8010
+
+#define GlintV0FixedKs 0x9018
+#define GlintV0FixedKsTag 0x0203
+#define GlintV0FixedKsReg 1
+#define GlintV0FixedKsOff 0x8018
+
+#define GlintV0FixedKd 0x9020
+#define GlintV0FixedKdTag 0x0204
+#define GlintV0FixedKdReg 1
+#define GlintV0FixedKdOff 0x8020
+
+#define GlintV0FixedR 0x9028
+#define GlintV0FixedRTag 0x0205
+#define GlintV0FixedRReg 1
+#define GlintV0FixedROff 0x8028
+
+#define GlintV0FixedG 0x9030
+#define GlintV0FixedGTag 0x0206
+#define GlintV0FixedGReg 1
+#define GlintV0FixedGOff 0x8030
+
+#define GlintV0FixedB 0x9038
+#define GlintV0FixedBTag 0x0207
+#define GlintV0FixedBReg 1
+#define GlintV0FixedBOff 0x8038
+
+#define GlintV0FixedA 0x9040
+#define GlintV0FixedATag 0x0208
+#define GlintV0FixedAReg 1
+#define GlintV0FixedAOff 0x8040
+
+#define GlintV0FixedF 0x9048
+#define GlintV0FixedFTag 0x0209
+#define GlintV0FixedFReg 1
+#define GlintV0FixedFOff 0x8048
+
+#define GlintV0FixedX 0x9050
+#define GlintV0FixedXTag 0x020a
+#define GlintV0FixedXReg 1
+#define GlintV0FixedXOff 0x8050
+
+#define GlintV0FixedY 0x9058
+#define GlintV0FixedYTag 0x020b
+#define GlintV0FixedYReg 1
+#define GlintV0FixedYOff 0x8058
+
+#define GlintV0FixedZ 0x9060
+#define GlintV0FixedZTag 0x020c
+#define GlintV0FixedZReg 1
+#define GlintV0FixedZOff 0x8060
+
+#define GlintV1FixedS 0x9080
+#define GlintV1FixedSTag 0x0210
+#define GlintV1FixedSReg 1
+#define GlintV1FixedSOff 0x8080
+
+#define GlintV1FixedT 0x9088
+#define GlintV1FixedTTag 0x0211
+#define GlintV1FixedTReg 1
+#define GlintV1FixedTOff 0x8088
+
+#define GlintV1FixedQ 0x9090
+#define GlintV1FixedQTag 0x0212
+#define GlintV1FixedQReg 1
+#define GlintV1FixedQOff 0x8090
+
+#define GlintV1FixedKs 0x9098
+#define GlintV1FixedKsTag 0x0213
+#define GlintV1FixedKsReg 1
+#define GlintV1FixedKsOff 0x8098
+
+#define GlintV1FixedKd 0x90a0
+#define GlintV1FixedKdTag 0x0214
+#define GlintV1FixedKdReg 1
+#define GlintV1FixedKdOff 0x80a0
+
+#define GlintV1FixedR 0x90a8
+#define GlintV1FixedRTag 0x0215
+#define GlintV1FixedRReg 1
+#define GlintV1FixedROff 0x80a8
+
+#define GlintV1FixedG 0x90b0
+#define GlintV1FixedGTag 0x0216
+#define GlintV1FixedGReg 1
+#define GlintV1FixedGOff 0x80b0
+
+#define GlintV1FixedB 0x90b8
+#define GlintV1FixedBTag 0x0217
+#define GlintV1FixedBReg 1
+#define GlintV1FixedBOff 0x80b8
+
+#define GlintV1FixedA 0x90c0
+#define GlintV1FixedATag 0x0218
+#define GlintV1FixedAReg 1
+#define GlintV1FixedAOff 0x80c0
+
+#define GlintV1FixedF 0x90c8
+#define GlintV1FixedFTag 0x0219
+#define GlintV1FixedFReg 1
+#define GlintV1FixedFOff 0x80c8
+
+#define GlintV1FixedX 0x90d0
+#define GlintV1FixedXTag 0x021a
+#define GlintV1FixedXReg 1
+#define GlintV1FixedXOff 0x80d0
+
+#define GlintV1FixedY 0x90d8
+#define GlintV1FixedYTag 0x021b
+#define GlintV1FixedYReg 1
+#define GlintV1FixedYOff 0x80d8
+
+#define GlintV1FixedZ 0x90e0
+#define GlintV1FixedZTag 0x021c
+#define GlintV1FixedZReg 1
+#define GlintV1FixedZOff 0x80e0
+
+#define GlintV2FixedS 0x9100
+#define GlintV2FixedSTag 0x0220
+#define GlintV2FixedSReg 1
+#define GlintV2FixedSOff 0x8100
+
+#define GlintV2FixedT 0x9108
+#define GlintV2FixedTTag 0x0221
+#define GlintV2FixedTReg 1
+#define GlintV2FixedTOff 0x8108
+
+#define GlintV2FixedQ 0x9110
+#define GlintV2FixedQTag 0x0222
+#define GlintV2FixedQReg 1
+#define GlintV2FixedQOff 0x8110
+
+#define GlintV2FixedKs 0x9118
+#define GlintV2FixedKsTag 0x0223
+#define GlintV2FixedKsReg 1
+#define GlintV2FixedKsOff 0x8118
+
+#define GlintV2FixedKd 0x9120
+#define GlintV2FixedKdTag 0x0224
+#define GlintV2FixedKdReg 1
+#define GlintV2FixedKdOff 0x8120
+
+#define GlintV2FixedR 0x9128
+#define GlintV2FixedRTag 0x0225
+#define GlintV2FixedRReg 1
+#define GlintV2FixedROff 0x8128
+
+#define GlintV2FixedG 0x9130
+#define GlintV2FixedGTag 0x0226
+#define GlintV2FixedGReg 1
+#define GlintV2FixedGOff 0x8130
+
+#define GlintV2FixedB 0x9138
+#define GlintV2FixedBTag 0x0227
+#define GlintV2FixedBReg 1
+#define GlintV2FixedBOff 0x8138
+
+#define GlintV2FixedA 0x9140
+#define GlintV2FixedATag 0x0228
+#define GlintV2FixedAReg 1
+#define GlintV2FixedAOff 0x8140
+
+#define GlintV2FixedF 0x9148
+#define GlintV2FixedFTag 0x0229
+#define GlintV2FixedFReg 1
+#define GlintV2FixedFOff 0x8148
+
+#define GlintV2FixedX 0x9150
+#define GlintV2FixedXTag 0x022a
+#define GlintV2FixedXReg 1
+#define GlintV2FixedXOff 0x8150
+
+#define GlintV2FixedY 0x9158
+#define GlintV2FixedYTag 0x022b
+#define GlintV2FixedYReg 1
+#define GlintV2FixedYOff 0x8158
+
+#define GlintV2FixedZ 0x9160
+#define GlintV2FixedZTag 0x022c
+#define GlintV2FixedZReg 1
+#define GlintV2FixedZOff 0x8160
+
+#define GlintV0FloatS 0x9180
+#define GlintV0FloatSTag 0x0230
+#define GlintV0FloatSReg 1
+#define GlintV0FloatSOff 0x8180
+
+#define GlintV0FloatT 0x9188
+#define GlintV0FloatTTag 0x0231
+#define GlintV0FloatTReg 1
+#define GlintV0FloatTOff 0x8188
+
+#define GlintV0FloatQ 0x9190
+#define GlintV0FloatQTag 0x0232
+#define GlintV0FloatQReg 1
+#define GlintV0FloatQOff 0x8190
+
+#define GlintV0FloatKs 0x9198
+#define GlintV0FloatKsTag 0x0233
+#define GlintV0FloatKsReg 1
+#define GlintV0FloatKsOff 0x8198
+
+#define GlintV0FloatKd 0x91a0
+#define GlintV0FloatKdTag 0x0234
+#define GlintV0FloatKdReg 1
+#define GlintV0FloatKdOff 0x81a0
+
+#define GlintV0FloatR 0x91a8
+#define GlintV0FloatRTag 0x0235
+#define GlintV0FloatRReg 1
+#define GlintV0FloatROff 0x81a8
+
+#define GlintV0FloatG 0x91b0
+#define GlintV0FloatGTag 0x0236
+#define GlintV0FloatGReg 1
+#define GlintV0FloatGOff 0x81b0
+
+#define GlintV0FloatB 0x91b8
+#define GlintV0FloatBTag 0x0237
+#define GlintV0FloatBReg 1
+#define GlintV0FloatBOff 0x81b8
+
+#define GlintV0FloatA 0x91c0
+#define GlintV0FloatATag 0x0238
+#define GlintV0FloatAReg 1
+#define GlintV0FloatAOff 0x81c0
+
+#define GlintV0FloatF 0x91c8
+#define GlintV0FloatFTag 0x0239
+#define GlintV0FloatFReg 1
+#define GlintV0FloatFOff 0x81c8
+
+#define GlintV0FloatX 0x91d0
+#define GlintV0FloatXTag 0x023a
+#define GlintV0FloatXReg 1
+#define GlintV0FloatXOff 0x81d0
+
+#define GlintV0FloatY 0x91d8
+#define GlintV0FloatYTag 0x023b
+#define GlintV0FloatYReg 1
+#define GlintV0FloatYOff 0x81d8
+
+#define GlintV0FloatZ 0x91e0
+#define GlintV0FloatZTag 0x023c
+#define GlintV0FloatZReg 1
+#define GlintV0FloatZOff 0x81e0
+
+#define GlintV1FloatS 0x9200
+#define GlintV1FloatSTag 0x0240
+#define GlintV1FloatSReg 1
+#define GlintV1FloatSOff 0x8200
+
+#define GlintV1FloatT 0x9208
+#define GlintV1FloatTTag 0x0241
+#define GlintV1FloatTReg 1
+#define GlintV1FloatTOff 0x8208
+
+#define GlintV1FloatQ 0x9210
+#define GlintV1FloatQTag 0x0242
+#define GlintV1FloatQReg 1
+#define GlintV1FloatQOff 0x8210
+
+#define GlintV1FloatKs 0x9218
+#define GlintV1FloatKsTag 0x0243
+#define GlintV1FloatKsReg 1
+#define GlintV1FloatKsOff 0x8218
+
+#define GlintV1FloatKd 0x9220
+#define GlintV1FloatKdTag 0x0244
+#define GlintV1FloatKdReg 1
+#define GlintV1FloatKdOff 0x8220
+
+#define GlintV1FloatR 0x9228
+#define GlintV1FloatRTag 0x0245
+#define GlintV1FloatRReg 1
+#define GlintV1FloatROff 0x8228
+
+#define GlintV1FloatG 0x9230
+#define GlintV1FloatGTag 0x0246
+#define GlintV1FloatGReg 1
+#define GlintV1FloatGOff 0x8230
+
+#define GlintV1FloatB 0x9238
+#define GlintV1FloatBTag 0x0247
+#define GlintV1FloatBReg 1
+#define GlintV1FloatBOff 0x8238
+
+#define GlintV1FloatA 0x9240
+#define GlintV1FloatATag 0x0248
+#define GlintV1FloatAReg 1
+#define GlintV1FloatAOff 0x8240
+
+#define GlintV1FloatF 0x9248
+#define GlintV1FloatFTag 0x0249
+#define GlintV1FloatFReg 1
+#define GlintV1FloatFOff 0x8248
+
+#define GlintV1FloatX 0x9250
+#define GlintV1FloatXTag 0x024a
+#define GlintV1FloatXReg 1
+#define GlintV1FloatXOff 0x8250
+
+#define GlintV1FloatY 0x9258
+#define GlintV1FloatYTag 0x024b
+#define GlintV1FloatYReg 1
+#define GlintV1FloatYOff 0x8258
+
+#define GlintV1FloatZ 0x9260
+#define GlintV1FloatZTag 0x024c
+#define GlintV1FloatZReg 1
+#define GlintV1FloatZOff 0x8260
+
+#define GlintV2FloatS 0x9280
+#define GlintV2FloatSTag 0x0250
+#define GlintV2FloatSReg 1
+#define GlintV2FloatSOff 0x8280
+
+#define GlintV2FloatT 0x9288
+#define GlintV2FloatTTag 0x0251
+#define GlintV2FloatTReg 1
+#define GlintV2FloatTOff 0x8288
+
+#define GlintV2FloatQ 0x9290
+#define GlintV2FloatQTag 0x0252
+#define GlintV2FloatQReg 1
+#define GlintV2FloatQOff 0x8290
+
+#define GlintV2FloatKs 0x9298
+#define GlintV2FloatKsTag 0x0253
+#define GlintV2FloatKsReg 1
+#define GlintV2FloatKsOff 0x8298
+
+#define GlintV2FloatKd 0x92a0
+#define GlintV2FloatKdTag 0x0254
+#define GlintV2FloatKdReg 1
+#define GlintV2FloatKdOff 0x82a0
+
+#define GlintV2FloatR 0x92a8
+#define GlintV2FloatRTag 0x0255
+#define GlintV2FloatRReg 1
+#define GlintV2FloatROff 0x82a8
+
+#define GlintV2FloatG 0x92b0
+#define GlintV2FloatGTag 0x0256
+#define GlintV2FloatGReg 1
+#define GlintV2FloatGOff 0x82b0
+
+#define GlintV2FloatB 0x92b8
+#define GlintV2FloatBTag 0x0257
+#define GlintV2FloatBReg 1
+#define GlintV2FloatBOff 0x82b8
+
+#define GlintV2FloatA 0x92c0
+#define GlintV2FloatATag 0x0258
+#define GlintV2FloatAReg 1
+#define GlintV2FloatAOff 0x82c0
+
+#define GlintV2FloatF 0x92c8
+#define GlintV2FloatFTag 0x0259
+#define GlintV2FloatFReg 1
+#define GlintV2FloatFOff 0x82c8
+
+#define GlintV2FloatX 0x92d0
+#define GlintV2FloatXTag 0x025a
+#define GlintV2FloatXReg 1
+#define GlintV2FloatXOff 0x82d0
+
+#define GlintV2FloatY 0x92d8
+#define GlintV2FloatYTag 0x025b
+#define GlintV2FloatYReg 1
+#define GlintV2FloatYOff 0x82d8
+
+#define GlintV2FloatZ 0x92e0
+#define GlintV2FloatZTag 0x025c
+#define GlintV2FloatZReg 1
+#define GlintV2FloatZOff 0x82e0
+
+#define GlintDeltaMode 0x9300
+#define GlintDeltaModeTag 0x0260
+#define GlintDeltaModeReg 1
+#define GlintDeltaModeOff 0x8300
+
+#define GlintDrawTriangle 0x9308
+#define GlintDrawTriangleTag 0x0261
+#define GlintDrawTriangleReg 1
+#define GlintDrawTriangleOff 0x8308
+
+#define GlintRepeatTriangle 0x9310
+#define GlintRepeatTriangleTag 0x0262
+#define GlintRepeatTriangleReg 1
+#define GlintRepeatTriangleOff 0x8310
+
+#define GlintDrawLine01 0x9318
+#define GlintDrawLine01Tag 0x0263
+#define GlintDrawLine01Reg 1
+#define GlintDrawLine01Off 0x8318
+
+#define GlintDrawLine10 0x9320
+#define GlintDrawLine10Tag 0x0264
+#define GlintDrawLine10Reg 1
+#define GlintDrawLine10Off 0x8320
+
+#define GlintRepeatLine 0x9328
+#define GlintRepeatLineTag 0x0265
+#define GlintRepeatLineReg 1
+#define GlintRepeatLineOff 0x8328
+
+#define GlintEpilogueTag 0x9368
+#define GlintEpilogueTagTag 0x026d
+#define GlintEpilogueTagReg 1
+#define GlintEpilogueTagOff 0x8368
+
+#define GlintEpilogueData 0x9370
+#define GlintEpilogueDataTag 0x026e
+#define GlintEpilogueDataReg 1
+#define GlintEpilogueDataOff 0x8370
+
+#define GlintBroadcastMask 0x9378
+#define GlintBroadcastMaskTag 0x026f
+#define GlintBroadcastMaskReg 1
+#define GlintBroadcastMaskOff 0x8378
+
+#define GlintXBias 0x9480
+#define GlintXBiasTag 0x0290
+#define GlintXBiasReg 1
+#define GlintXBiasOff 0x8480
+
+#define GlintYBias 0x9488
+#define GlintYBiasTag 0x0291
+#define GlintYBiasReg 1
+#define GlintYBiasOff 0x8488
+
+#define GlintPointMode 0x9490
+#define GlintPointModeTag 0x0292
+#define GlintPointModeReg 1
+#define GlintPointModeOff 0x8490
+
+#define GlintPointSize 0x9498
+#define GlintPointSizeTag 0x0293
+#define GlintPointSizeReg 1
+#define GlintPointSizeOff 0x8498
+
+#define GlintAApointSize 0x94a0
+#define GlintAApointSizeTag 0x0294
+#define GlintAApointSizeReg 1
+#define GlintAApointSizeOff 0x84a0
+
+#define GlintLineMode 0x94a8
+#define GlintLineModeTag 0x0295
+#define GlintLineModeReg 1
+#define GlintLineModeOff 0x84a8
+
+#define GlintLineWidth 0x94b0
+#define GlintLineWidthTag 0x0296
+#define GlintLineWidthReg 1
+#define GlintLineWidthOff 0x84b0
+
+#define GlintLineWidthOffset 0x94b8
+#define GlintLineWidthOffsetTag 0x0297
+#define GlintLineWidthOffsetReg 1
+#define GlintLineWidthOffsetOff 0x84b8
+
+#define GlintAAlineWidth 0x94c0
+#define GlintAAlineWidthTag 0x0298
+#define GlintAAlineWidthReg 1
+#define GlintAAlineWidthOff 0x84c0
+
+#define GlintTriangleMode 0x94c8
+#define GlintTriangleModeTag 0x0299
+#define GlintTriangleModeReg 1
+#define GlintTriangleModeOff 0x84c8
+
+#define GlintRectangleMode 0x94d0
+#define GlintRectangleModeTag 0x029a
+#define GlintRectangleModeReg 1
+#define GlintRectangleModeOff 0x84d0
+
+#define GlintRectangleWidth 0x94d8
+#define GlintRectangleWidthTag 0x029b
+#define GlintRectangleWidthReg 1
+#define GlintRectangleWidthOff 0x84d8
+
+#define GlintRectangleHeight 0x94e0
+#define GlintRectangleHeightTag 0x029c
+#define GlintRectangleHeightReg 1
+#define GlintRectangleHeightOff 0x84e0
+
+#define GlintRectangle2DMode 0x94e8
+#define GlintRectangle2DModeTag 0x029d
+#define GlintRectangle2DModeReg 1
+#define GlintRectangle2DModeOff 0x84e8
+
+#define GlintRectangle2DControl 0x94f0
+#define GlintRectangle2DControlTag 0x029e
+#define GlintRectangle2DControlReg 1
+#define GlintRectangle2DControlOff 0x84f0
+
+#define GlintTransformMode 0x9508
+#define GlintTransformModeTag 0x02a1
+#define GlintTransformModeReg 1
+#define GlintTransformModeOff 0x8508
+
+#define GlintGeometryMode 0x9510
+#define GlintGeometryModeTag 0x02a2
+#define GlintGeometryModeReg 1
+#define GlintGeometryModeOff 0x8510
+
+#define GlintNormalizeMode 0x9518
+#define GlintNormalizeModeTag 0x02a3
+#define GlintNormalizeModeReg 1
+#define GlintNormalizeModeOff 0x8518
+
+#define GlintLightingMode 0x9520
+#define GlintLightingModeTag 0x02a4
+#define GlintLightingModeReg 1
+#define GlintLightingModeOff 0x8520
+
+#define GlintColorMaterialMode 0x9528
+#define GlintColorMaterialModeTag 0x02a5
+#define GlintColorMaterialModeReg 1
+#define GlintColorMaterialModeOff 0x8528
+
+#define GlintMaterialMode 0x9530
+#define GlintMaterialModeTag 0x02a6
+#define GlintMaterialModeReg 1
+#define GlintMaterialModeOff 0x8530
+
+#define GlintSelectResult 0x9580
+#define GlintSelectResultTag 0x02b0
+#define GlintSelectResultReg 1
+#define GlintSelectResultOff 0x8580
+
+#define GlintBegin 0x9590
+#define GlintBeginTag 0x02b2
+#define GlintBeginReg 1
+#define GlintBeginOff 0x8590
+
+#define GlintEnd 0x9598
+#define GlintEndTag 0x02b3
+#define GlintEndReg 1
+#define GlintEndOff 0x8598
+
+#define GlintEdgeFlag 0x95a0
+#define GlintEdgeFlagTag 0x02b4
+#define GlintEdgeFlagReg 1
+#define GlintEdgeFlagOff 0x85a0
+
+#define GlintObjectIDvalue 0x95a8
+#define GlintObjectIDvalueTag 0x02b5
+#define GlintObjectIDvalueReg 1
+#define GlintObjectIDvalueOff 0x85a8
+
+#define GlintIncrementObjectID 0x95b0
+#define GlintIncrementObjectIDTag 0x02b6
+#define GlintIncrementObjectIDReg 1
+#define GlintIncrementObjectIDOff 0x85b0
+
+#define GlintTransformCurrent 0x95b8
+#define GlintTransformCurrentTag 0x02b7
+#define GlintTransformCurrentReg 1
+#define GlintTransformCurrentOff 0x85b8
+
+#define GlintSaveCurrent 0x95c8
+#define GlintSaveCurrentTag 0x02b9
+#define GlintSaveCurrentReg 1
+#define GlintSaveCurrentOff 0x85c8
+
+#define GlintRestoreCurrent 0x95d0
+#define GlintRestoreCurrentTag 0x02ba
+#define GlintRestoreCurrentReg 1
+#define GlintRestoreCurrentOff 0x85d0
+
+#define GlintInitNames 0x95d8
+#define GlintInitNamesTag 0x02bb
+#define GlintInitNamesReg 1
+#define GlintInitNamesOff 0x85d8
+
+#define GlintPushName 0x95e0
+#define GlintPushNameTag 0x02bc
+#define GlintPushNameReg 1
+#define GlintPushNameOff 0x85e0
+
+#define GlintPopName 0x95e8
+#define GlintPopNameTag 0x02bd
+#define GlintPopNameReg 1
+#define GlintPopNameOff 0x85e8
+
+#define GlintLoadName 0x95f0
+#define GlintLoadNameTag 0x02be
+#define GlintLoadNameReg 1
+#define GlintLoadNameOff 0x85f0
+
+#define GlintGeomRectangle 0x96a0
+#define GlintGeomRectangleTag 0x02d4
+#define GlintGeomRectangleReg 1
+#define GlintGeomRectangleOff 0x86a0
+
+#define GlintDrawRectangle2D 0x97a0
+#define GlintDrawRectangle2DTag 0x02f4
+#define GlintDrawRectangle2DReg 1
+#define GlintDrawRectangle2DOff 0x87a0
+
+#define GlintNz 0x9800
+#define GlintNzTag 0x0300
+#define GlintNzReg 1
+#define GlintNzOff 0x8800
+
+#define GlintNy 0x9808
+#define GlintNyTag 0x0301
+#define GlintNyReg 1
+#define GlintNyOff 0x8808
+
+#define GlintNx 0x9810
+#define GlintNxTag 0x0302
+#define GlintNxReg 1
+#define GlintNxOff 0x8810
+
+#define GlintCa 0x9818
+#define GlintCaTag 0x0303
+#define GlintCaReg 1
+#define GlintCaOff 0x8818
+
+#define GlintCb 0x9820
+#define GlintCbTag 0x0304
+#define GlintCbReg 1
+#define GlintCbOff 0x8820
+
+#define GlintCg 0x9828
+#define GlintCgTag 0x0305
+#define GlintCgReg 1
+#define GlintCgOff 0x8828
+
+#define GlintCr3 0x9830
+#define GlintCr3Tag 0x0306
+#define GlintCr3Reg 1
+#define GlintCr3Off 0x8830
+
+#define GlintCr4 0x9838
+#define GlintCr4Tag 0x0307
+#define GlintCr4Reg 1
+#define GlintCr4Off 0x8838
+
+#define GlintTt2 0x9840
+#define GlintTt2Tag 0x0308
+#define GlintTt2Reg 1
+#define GlintTt2Off 0x8840
+
+#define GlintTs2 0x9848
+#define GlintTs2Tag 0x0309
+#define GlintTs2Reg 1
+#define GlintTs2Off 0x8848
+
+#define GlintVw 0x9850
+#define GlintVwTag 0x030a
+#define GlintVwReg 1
+#define GlintVwOff 0x8850
+
+#define GlintVz 0x9858
+#define GlintVzTag 0x030b
+#define GlintVzReg 1
+#define GlintVzOff 0x8858
+
+#define GlintVy 0x9860
+#define GlintVyTag 0x030c
+#define GlintVyReg 1
+#define GlintVyOff 0x8860
+
+#define GlintVx2 0x9868
+#define GlintVx2Tag 0x030d
+#define GlintVx2Reg 1
+#define GlintVx2Off 0x8868
+
+#define GlintVx3 0x9870
+#define GlintVx3Tag 0x030e
+#define GlintVx3Reg 1
+#define GlintVx3Off 0x8870
+
+#define GlintVx4 0x9878
+#define GlintVx4Tag 0x030f
+#define GlintVx4Reg 1
+#define GlintVx4Off 0x8878
+
+#define GlintFNz 0x9880
+#define GlintFNzTag 0x0310
+#define GlintFNzReg 1
+#define GlintFNzOff 0x8880
+
+#define GlintFNy 0x9888
+#define GlintFNyTag 0x0311
+#define GlintFNyReg 1
+#define GlintFNyOff 0x8888
+
+#define GlintFNx 0x9890
+#define GlintFNxTag 0x0312
+#define GlintFNxReg 1
+#define GlintFNxOff 0x8890
+
+#define GlintPackedColor3 0x9898
+#define GlintPackedColor3Tag 0x0313
+#define GlintPackedColor3Reg 1
+#define GlintPackedColor3Off 0x8898
+
+#define GlintPackedColor4 0x98a0
+#define GlintPackedColor4Tag 0x0314
+#define GlintPackedColor4Reg 1
+#define GlintPackedColor4Off 0x88a0
+
+#define GlintTq4 0x98a8
+#define GlintTq4Tag 0x0315
+#define GlintTq4Reg 1
+#define GlintTq4Off 0x88a8
+
+#define GlintTr4 0x98b0
+#define GlintTr4Tag 0x0316
+#define GlintTr4Reg 1
+#define GlintTr4Off 0x88b0
+
+#define GlintTt4 0x98b8
+#define GlintTt4Tag 0x0317
+#define GlintTt4Reg 1
+#define GlintTt4Off 0x88b8
+
+#define GlintTs4 0x98c0
+#define GlintTs4Tag 0x0318
+#define GlintTs4Reg 1
+#define GlintTs4Off 0x88c0
+
+#define GlintRPw 0x98c8
+#define GlintRPwTag 0x0319
+#define GlintRPwReg 1
+#define GlintRPwOff 0x88c8
+
+#define GlintRPz 0x98d0
+#define GlintRPzTag 0x031a
+#define GlintRPzReg 1
+#define GlintRPzOff 0x88d0
+
+#define GlintRPy 0x98d8
+#define GlintRPyTag 0x031b
+#define GlintRPyReg 1
+#define GlintRPyOff 0x88d8
+
+#define GlintRPx2 0x98e0
+#define GlintRPx2Tag 0x031c
+#define GlintRPx2Reg 1
+#define GlintRPx2Off 0x88e0
+
+#define GlintRPx3 0x98e8
+#define GlintRPx3Tag 0x031d
+#define GlintRPx3Reg 1
+#define GlintRPx3Off 0x88e8
+
+#define GlintRPx4 0x98f0
+#define GlintRPx4Tag 0x031e
+#define GlintRPx4Reg 1
+#define GlintRPx4Off 0x88f0
+
+#define GlintTs1 0x98f8
+#define GlintTs1Tag 0x031f
+#define GlintTs1Reg 1
+#define GlintTs1Off 0x88f8
+
+#define GlintModelViewMatrix0 0x9900
+#define GlintModelViewMatrix0Tag 0x0320
+#define GlintModelViewMatrix0Reg 1
+#define GlintModelViewMatrix0Off 0x8900
+
+#define GlintModelViewMatrix1 0x9908
+#define GlintModelViewMatrix1Tag 0x0321
+#define GlintModelViewMatrix1Reg 1
+#define GlintModelViewMatrix1Off 0x8908
+
+#define GlintModelViewMatrix2 0x9910
+#define GlintModelViewMatrix2Tag 0x0322
+#define GlintModelViewMatrix2Reg 1
+#define GlintModelViewMatrix2Off 0x8910
+
+#define GlintModelViewMatrix3 0x9918
+#define GlintModelViewMatrix3Tag 0x0323
+#define GlintModelViewMatrix3Reg 1
+#define GlintModelViewMatrix3Off 0x8918
+
+#define GlintModelViewMatrix4 0x9920
+#define GlintModelViewMatrix4Tag 0x0324
+#define GlintModelViewMatrix4Reg 1
+#define GlintModelViewMatrix4Off 0x8920
+
+#define GlintModelViewMatrix5 0x9928
+#define GlintModelViewMatrix5Tag 0x0325
+#define GlintModelViewMatrix5Reg 1
+#define GlintModelViewMatrix5Off 0x8928
+
+#define GlintModelViewMatrix6 0x9930
+#define GlintModelViewMatrix6Tag 0x0326
+#define GlintModelViewMatrix6Reg 1
+#define GlintModelViewMatrix6Off 0x8930
+
+#define GlintModelViewMatrix7 0x9938
+#define GlintModelViewMatrix7Tag 0x0327
+#define GlintModelViewMatrix7Reg 1
+#define GlintModelViewMatrix7Off 0x8938
+
+#define GlintModelViewMatrix8 0x9940
+#define GlintModelViewMatrix8Tag 0x0328
+#define GlintModelViewMatrix8Reg 1
+#define GlintModelViewMatrix8Off 0x8940
+
+#define GlintModelViewMatrix9 0x9948
+#define GlintModelViewMatrix9Tag 0x0329
+#define GlintModelViewMatrix9Reg 1
+#define GlintModelViewMatrix9Off 0x8948
+
+#define GlintModelViewMatrix10 0x9950
+#define GlintModelViewMatrix10Tag 0x032a
+#define GlintModelViewMatrix10Reg 1
+#define GlintModelViewMatrix10Off 0x8950
+
+#define GlintModelViewMatrix11 0x9958
+#define GlintModelViewMatrix11Tag 0x032b
+#define GlintModelViewMatrix11Reg 1
+#define GlintModelViewMatrix11Off 0x8958
+
+#define GlintModelViewMatrix12 0x9960
+#define GlintModelViewMatrix12Tag 0x032c
+#define GlintModelViewMatrix12Reg 1
+#define GlintModelViewMatrix12Off 0x8960
+
+#define GlintModelViewMatrix13 0x9968
+#define GlintModelViewMatrix13Tag 0x032d
+#define GlintModelViewMatrix13Reg 1
+#define GlintModelViewMatrix13Off 0x8968
+
+#define GlintModelViewMatrix14 0x9970
+#define GlintModelViewMatrix14Tag 0x032e
+#define GlintModelViewMatrix14Reg 1
+#define GlintModelViewMatrix14Off 0x8970
+
+#define GlintModelViewMatrix15 0x9978
+#define GlintModelViewMatrix15Tag 0x032f
+#define GlintModelViewMatrix15Reg 1
+#define GlintModelViewMatrix15Off 0x8978
+
+#define GlintModelViewProjectionMatrix0 0x9980
+#define GlintModelViewProjectionMatrix0Tag 0x0330
+#define GlintModelViewProjectionMatrix0Reg 1
+#define GlintModelViewProjectionMatrix0Off 0x8980
+
+#define GlintModelViewProjectionMatrix1 0x9988
+#define GlintModelViewProjectionMatrix1Tag 0x0331
+#define GlintModelViewProjectionMatrix1Reg 1
+#define GlintModelViewProjectionMatrix1Off 0x8988
+
+#define GlintModelViewProjectionMatrix2 0x9990
+#define GlintModelViewProjectionMatrix2Tag 0x0332
+#define GlintModelViewProjectionMatrix2Reg 1
+#define GlintModelViewProjectionMatrix2Off 0x8990
+
+#define GlintModelViewProjectionMatrix3 0x9998
+#define GlintModelViewProjectionMatrix3Tag 0x0333
+#define GlintModelViewProjectionMatrix3Reg 1
+#define GlintModelViewProjectionMatrix3Off 0x8998
+
+#define GlintModelViewProjectionMatrix4 0x99a0
+#define GlintModelViewProjectionMatrix4Tag 0x0334
+#define GlintModelViewProjectionMatrix4Reg 1
+#define GlintModelViewProjectionMatrix4Off 0x89a0
+
+#define GlintModelViewProjectionMatrix5 0x99a8
+#define GlintModelViewProjectionMatrix5Tag 0x0335
+#define GlintModelViewProjectionMatrix5Reg 1
+#define GlintModelViewProjectionMatrix5Off 0x89a8
+
+#define GlintModelViewProjectionMatrix6 0x99b0
+#define GlintModelViewProjectionMatrix6Tag 0x0336
+#define GlintModelViewProjectionMatrix6Reg 1
+#define GlintModelViewProjectionMatrix6Off 0x89b0
+
+#define GlintModelViewProjectionMatrix7 0x99b8
+#define GlintModelViewProjectionMatrix7Tag 0x0337
+#define GlintModelViewProjectionMatrix7Reg 1
+#define GlintModelViewProjectionMatrix7Off 0x89b8
+
+#define GlintModelViewProjectionMatrix8 0x99c0
+#define GlintModelViewProjectionMatrix8Tag 0x0338
+#define GlintModelViewProjectionMatrix8Reg 1
+#define GlintModelViewProjectionMatrix8Off 0x89c0
+
+#define GlintModelViewProjectionMatrix9 0x99c8
+#define GlintModelViewProjectionMatrix9Tag 0x0339
+#define GlintModelViewProjectionMatrix9Reg 1
+#define GlintModelViewProjectionMatrix9Off 0x89c8
+
+#define GlintModelViewProjectionMatrix10 0x99d0
+#define GlintModelViewProjectionMatrix10Tag 0x033a
+#define GlintModelViewProjectionMatrix10Reg 1
+#define GlintModelViewProjectionMatrix10Off 0x89d0
+
+#define GlintModelViewProjectionMatrix11 0x99d8
+#define GlintModelViewProjectionMatrix11Tag 0x033b
+#define GlintModelViewProjectionMatrix11Reg 1
+#define GlintModelViewProjectionMatrix11Off 0x89d8
+
+#define GlintModelViewProjectionMatrix12 0x99e0
+#define GlintModelViewProjectionMatrix12Tag 0x033c
+#define GlintModelViewProjectionMatrix12Reg 1
+#define GlintModelViewProjectionMatrix12Off 0x89e0
+
+#define GlintModelViewProjectionMatrix13 0x99e8
+#define GlintModelViewProjectionMatrix13Tag 0x033d
+#define GlintModelViewProjectionMatrix13Reg 1
+#define GlintModelViewProjectionMatrix13Off 0x89e8
+
+#define GlintModelViewProjectionMatrix14 0x99f0
+#define GlintModelViewProjectionMatrix14Tag 0x033e
+#define GlintModelViewProjectionMatrix14Reg 1
+#define GlintModelViewProjectionMatrix14Off 0x89f0
+
+#define GlintModelViewProjectionMatrix15 0x99f8
+#define GlintModelViewProjectionMatrix15Tag 0x033f
+#define GlintModelViewProjectionMatrix15Reg 1
+#define GlintModelViewProjectionMatrix15Off 0x89f8
+
+#define GlintNormalMatrix0 0x9a00
+#define GlintNormalMatrix0Tag 0x0340
+#define GlintNormalMatrix0Reg 1
+#define GlintNormalMatrix0Off 0x8a00
+
+#define GlintNormalMatrix1 0x9a08
+#define GlintNormalMatrix1Tag 0x0341
+#define GlintNormalMatrix1Reg 1
+#define GlintNormalMatrix1Off 0x8a08
+
+#define GlintNormalMatrix2 0x9a10
+#define GlintNormalMatrix2Tag 0x0342
+#define GlintNormalMatrix2Reg 1
+#define GlintNormalMatrix2Off 0x8a10
+
+#define GlintNormalMatrix3 0x9a18
+#define GlintNormalMatrix3Tag 0x0343
+#define GlintNormalMatrix3Reg 1
+#define GlintNormalMatrix3Off 0x8a18
+
+#define GlintNormalMatrix4 0x9a20
+#define GlintNormalMatrix4Tag 0x0344
+#define GlintNormalMatrix4Reg 1
+#define GlintNormalMatrix4Off 0x8a20
+
+#define GlintNormalMatrix5 0x9a28
+#define GlintNormalMatrix5Tag 0x0345
+#define GlintNormalMatrix5Reg 1
+#define GlintNormalMatrix5Off 0x8a28
+
+#define GlintNormalMatrix6 0x9a30
+#define GlintNormalMatrix6Tag 0x0346
+#define GlintNormalMatrix6Reg 1
+#define GlintNormalMatrix6Off 0x8a30
+
+#define GlintNormalMatrix7 0x9a38
+#define GlintNormalMatrix7Tag 0x0347
+#define GlintNormalMatrix7Reg 1
+#define GlintNormalMatrix7Off 0x8a38
+
+#define GlintNormalMatrix8 0x9a40
+#define GlintNormalMatrix8Tag 0x0348
+#define GlintNormalMatrix8Reg 1
+#define GlintNormalMatrix8Off 0x8a40
+
+#define GlintTextureMatrix0 0x9a80
+#define GlintTextureMatrix0Tag 0x0350
+#define GlintTextureMatrix0Reg 1
+#define GlintTextureMatrix0Off 0x8a80
+
+#define GlintTextureMatrix1 0x9a88
+#define GlintTextureMatrix1Tag 0x0351
+#define GlintTextureMatrix1Reg 1
+#define GlintTextureMatrix1Off 0x8a88
+
+#define GlintTextureMatrix2 0x9a90
+#define GlintTextureMatrix2Tag 0x0352
+#define GlintTextureMatrix2Reg 1
+#define GlintTextureMatrix2Off 0x8a90
+
+#define GlintTextureMatrix3 0x9a98
+#define GlintTextureMatrix3Tag 0x0353
+#define GlintTextureMatrix3Reg 1
+#define GlintTextureMatrix3Off 0x8a98
+
+#define GlintTextureMatrix4 0x9aa0
+#define GlintTextureMatrix4Tag 0x0354
+#define GlintTextureMatrix4Reg 1
+#define GlintTextureMatrix4Off 0x8aa0
+
+#define GlintTextureMatrix5 0x9aa8
+#define GlintTextureMatrix5Tag 0x0355
+#define GlintTextureMatrix5Reg 1
+#define GlintTextureMatrix5Off 0x8aa8
+
+#define GlintTextureMatrix6 0x9ab0
+#define GlintTextureMatrix6Tag 0x0356
+#define GlintTextureMatrix6Reg 1
+#define GlintTextureMatrix6Off 0x8ab0
+
+#define GlintTextureMatrix7 0x9ab8
+#define GlintTextureMatrix7Tag 0x0357
+#define GlintTextureMatrix7Reg 1
+#define GlintTextureMatrix7Off 0x8ab8
+
+#define GlintTextureMatrix8 0x9ac0
+#define GlintTextureMatrix8Tag 0x0358
+#define GlintTextureMatrix8Reg 1
+#define GlintTextureMatrix8Off 0x8ac0
+
+#define GlintTextureMatrix9 0x9ac8
+#define GlintTextureMatrix9Tag 0x0359
+#define GlintTextureMatrix9Reg 1
+#define GlintTextureMatrix9Off 0x8ac8
+
+#define GlintTextureMatrix10 0x9ad0
+#define GlintTextureMatrix10Tag 0x035a
+#define GlintTextureMatrix10Reg 1
+#define GlintTextureMatrix10Off 0x8ad0
+
+#define GlintTextureMatrix11 0x9ad8
+#define GlintTextureMatrix11Tag 0x035b
+#define GlintTextureMatrix11Reg 1
+#define GlintTextureMatrix11Off 0x8ad8
+
+#define GlintTextureMatrix12 0x9ae0
+#define GlintTextureMatrix12Tag 0x035c
+#define GlintTextureMatrix12Reg 1
+#define GlintTextureMatrix12Off 0x8ae0
+
+#define GlintTextureMatrix13 0x9ae8
+#define GlintTextureMatrix13Tag 0x035d
+#define GlintTextureMatrix13Reg 1
+#define GlintTextureMatrix13Off 0x8ae8
+
+#define GlintTextureMatrix14 0x9af0
+#define GlintTextureMatrix14Tag 0x035e
+#define GlintTextureMatrix14Reg 1
+#define GlintTextureMatrix14Off 0x8af0
+
+#define GlintTextureMatrix15 0x9af8
+#define GlintTextureMatrix15Tag 0x035f
+#define GlintTextureMatrix15Reg 1
+#define GlintTextureMatrix15Off 0x8af8
+
+#define GlintTexGen0 0x9b00
+#define GlintTexGen0Tag 0x0360
+#define GlintTexGen0Reg 1
+#define GlintTexGen0Off 0x8b00
+
+#define GlintTexGen1 0x9b08
+#define GlintTexGen1Tag 0x0361
+#define GlintTexGen1Reg 1
+#define GlintTexGen1Off 0x8b08
+
+#define GlintTexGen2 0x9b10
+#define GlintTexGen2Tag 0x0362
+#define GlintTexGen2Reg 1
+#define GlintTexGen2Off 0x8b10
+
+#define GlintTexGen3 0x9b18
+#define GlintTexGen3Tag 0x0363
+#define GlintTexGen3Reg 1
+#define GlintTexGen3Off 0x8b18
+
+#define GlintTexGen4 0x9b20
+#define GlintTexGen4Tag 0x0364
+#define GlintTexGen4Reg 1
+#define GlintTexGen4Off 0x8b20
+
+#define GlintTexGen5 0x9b28
+#define GlintTexGen5Tag 0x0365
+#define GlintTexGen5Reg 1
+#define GlintTexGen5Off 0x8b28
+
+#define GlintTexGen6 0x9b30
+#define GlintTexGen6Tag 0x0366
+#define GlintTexGen6Reg 1
+#define GlintTexGen6Off 0x8b30
+
+#define GlintTexGen7 0x9b38
+#define GlintTexGen7Tag 0x0367
+#define GlintTexGen7Reg 1
+#define GlintTexGen7Off 0x8b38
+
+#define GlintTexGen8 0x9b40
+#define GlintTexGen8Tag 0x0368
+#define GlintTexGen8Reg 1
+#define GlintTexGen8Off 0x8b40
+
+#define GlintTexGen9 0x9b48
+#define GlintTexGen9Tag 0x0369
+#define GlintTexGen9Reg 1
+#define GlintTexGen9Off 0x8b48
+
+#define GlintTexGen10 0x9b50
+#define GlintTexGen10Tag 0x036a
+#define GlintTexGen10Reg 1
+#define GlintTexGen10Off 0x8b50
+
+#define GlintTexGen11 0x9b58
+#define GlintTexGen11Tag 0x036b
+#define GlintTexGen11Reg 1
+#define GlintTexGen11Off 0x8b58
+
+#define GlintTexGen12 0x9b60
+#define GlintTexGen12Tag 0x036c
+#define GlintTexGen12Reg 1
+#define GlintTexGen12Off 0x8b60
+
+#define GlintTexGen13 0x9b68
+#define GlintTexGen13Tag 0x036d
+#define GlintTexGen13Reg 1
+#define GlintTexGen13Off 0x8b68
+
+#define GlintTexGen14 0x9b70
+#define GlintTexGen14Tag 0x036e
+#define GlintTexGen14Reg 1
+#define GlintTexGen14Off 0x8b70
+
+#define GlintTexGen15 0x9b78
+#define GlintTexGen15Tag 0x036f
+#define GlintTexGen15Reg 1
+#define GlintTexGen15Off 0x8b78
+
+#define GlintViewPortScaleX 0x9b80
+#define GlintViewPortScaleXTag 0x0370
+#define GlintViewPortScaleXReg 1
+#define GlintViewPortScaleXOff 0x8b80
+
+#define GlintViewPortScaleY 0x9b88
+#define GlintViewPortScaleYTag 0x0371
+#define GlintViewPortScaleYReg 1
+#define GlintViewPortScaleYOff 0x8b88
+
+#define GlintViewPortScaleZ 0x9b90
+#define GlintViewPortScaleZTag 0x0372
+#define GlintViewPortScaleZReg 1
+#define GlintViewPortScaleZOff 0x8b90
+
+#define GlintViewPortOffsetX 0x9b98
+#define GlintViewPortOffsetXTag 0x0373
+#define GlintViewPortOffsetXReg 1
+#define GlintViewPortOffsetXOff 0x8b98
+
+#define GlintViewPortOffsetY 0x9ba0
+#define GlintViewPortOffsetYTag 0x0374
+#define GlintViewPortOffsetYReg 1
+#define GlintViewPortOffsetYOff 0x8ba0
+
+#define GlintViewPortOffsetZ 0x9ba8
+#define GlintViewPortOffsetZTag 0x0375
+#define GlintViewPortOffsetZReg 1
+#define GlintViewPortOffsetZOff 0x8ba8
+
+#define GlintFogDensity 0x9bb0
+#define GlintFogDensityTag 0x0376
+#define GlintFogDensityReg 1
+#define GlintFogDensityOff 0x8bb0
+
+#define GlintFogScale 0x9bb8
+#define GlintFogScaleTag 0x0377
+#define GlintFogScaleReg 1
+#define GlintFogScaleOff 0x8bb8
+
+#define GlintFogEnd 0x9bc0
+#define GlintFogEndTag 0x0378
+#define GlintFogEndReg 1
+#define GlintFogEndOff 0x8bc0
+
+#define GlintPolygonOffsetFactor 0x9bc8
+#define GlintPolygonOffsetFactorTag 0x0379
+#define GlintPolygonOffsetFactorReg 1
+#define GlintPolygonOffsetFactorOff 0x8bc8
+
+#define GlintPolygonOffsetBias 0x9bd0
+#define GlintPolygonOffsetBiasTag 0x037a
+#define GlintPolygonOffsetBiasReg 1
+#define GlintPolygonOffsetBiasOff 0x8bd0
+
+#define GlintLineClipLengthThreshold 0x9bd8
+#define GlintLineClipLengthThresholdTag 0x037b
+#define GlintLineClipLengthThresholdReg 1
+#define GlintLineClipLengthThresholdOff 0x8bd8
+
+#define GlintTriangleClipAreaThreshold 0x9be0
+#define GlintTriangleClipAreaThresholdTag 0x037c
+#define GlintTriangleClipAreaThresholdReg 1
+#define GlintTriangleClipAreaThresholdOff 0x8be0
+
+#define GlintRasterPosXIncrement 0x9be8
+#define GlintRasterPosXIncrementTag 0x037d
+#define GlintRasterPosXIncrementReg 1
+#define GlintRasterPosXIncrementOff 0x8be8
+
+#define GlintRasterPosYIncrement 0x9bf0
+#define GlintRasterPosYIncrementTag 0x037e
+#define GlintRasterPosYIncrementReg 1
+#define GlintRasterPosYIncrementOff 0x8bf0
+
+#define GlintUserClip0X 0x9c00
+#define GlintUserClip0XTag 0x0380
+#define GlintUserClip0XReg 1
+#define GlintUserClip0XOff 0x8c00
+
+#define GlintUserClip0Y 0x9c08
+#define GlintUserClip0YTag 0x0381
+#define GlintUserClip0YReg 1
+#define GlintUserClip0YOff 0x8c08
+
+#define GlintUserClip0Z 0x9c10
+#define GlintUserClip0ZTag 0x0382
+#define GlintUserClip0ZReg 1
+#define GlintUserClip0ZOff 0x8c10
+
+#define GlintUserClip0W 0x9c18
+#define GlintUserClip0WTag 0x0383
+#define GlintUserClip0WReg 1
+#define GlintUserClip0WOff 0x8c18
+
+#define GlintUserClip1X 0x9c20
+#define GlintUserClip1XTag 0x0384
+#define GlintUserClip1XReg 1
+#define GlintUserClip1XOff 0x8c20
+
+#define GlintUserClip1Y 0x9c28
+#define GlintUserClip1YTag 0x0385
+#define GlintUserClip1YReg 1
+#define GlintUserClip1YOff 0x8c28
+
+#define GlintUserClip1Z 0x9c30
+#define GlintUserClip1ZTag 0x0386
+#define GlintUserClip1ZReg 1
+#define GlintUserClip1ZOff 0x8c30
+
+#define GlintUserClip1W 0x9c38
+#define GlintUserClip1WTag 0x0387
+#define GlintUserClip1WReg 1
+#define GlintUserClip1WOff 0x8c38
+
+#define GlintUserClip2X 0x9c40
+#define GlintUserClip2XTag 0x0388
+#define GlintUserClip2XReg 1
+#define GlintUserClip2XOff 0x8c40
+
+#define GlintUserClip2Y 0x9c48
+#define GlintUserClip2YTag 0x0389
+#define GlintUserClip2YReg 1
+#define GlintUserClip2YOff 0x8c48
+
+#define GlintUserClip2Z 0x9c50
+#define GlintUserClip2ZTag 0x038a
+#define GlintUserClip2ZReg 1
+#define GlintUserClip2ZOff 0x8c50
+
+#define GlintUserClip2W 0x9c58
+#define GlintUserClip2WTag 0x038b
+#define GlintUserClip2WReg 1
+#define GlintUserClip2WOff 0x8c58
+
+#define GlintUserClip3X 0x9c60
+#define GlintUserClip3XTag 0x038c
+#define GlintUserClip3XReg 1
+#define GlintUserClip3XOff 0x8c60
+
+#define GlintUserClip3Y 0x9c68
+#define GlintUserClip3YTag 0x038d
+#define GlintUserClip3YReg 1
+#define GlintUserClip3YOff 0x8c68
+
+#define GlintUserClip3Z 0x9c70
+#define GlintUserClip3ZTag 0x038e
+#define GlintUserClip3ZReg 1
+#define GlintUserClip3ZOff 0x8c70
+
+#define GlintUserClip3W 0x9c78
+#define GlintUserClip3WTag 0x038f
+#define GlintUserClip3WReg 1
+#define GlintUserClip3WOff 0x8c78
+
+#define GlintUserClip4X 0x9c80
+#define GlintUserClip4XTag 0x0390
+#define GlintUserClip4XReg 1
+#define GlintUserClip4XOff 0x8c80
+
+#define GlintUserClip4Y 0x9c88
+#define GlintUserClip4YTag 0x0391
+#define GlintUserClip4YReg 1
+#define GlintUserClip4YOff 0x8c88
+
+#define GlintUserClip4Z 0x9c90
+#define GlintUserClip4ZTag 0x0392
+#define GlintUserClip4ZReg 1
+#define GlintUserClip4ZOff 0x8c90
+
+#define GlintUserClip4W 0x9c98
+#define GlintUserClip4WTag 0x0393
+#define GlintUserClip4WReg 1
+#define GlintUserClip4WOff 0x8c98
+
+#define GlintUserClip5X 0x9ca0
+#define GlintUserClip5XTag 0x0394
+#define GlintUserClip5XReg 1
+#define GlintUserClip5XOff 0x8ca0
+
+#define GlintUserClip5Y 0x9ca8
+#define GlintUserClip5YTag 0x0395
+#define GlintUserClip5YReg 1
+#define GlintUserClip5YOff 0x8ca8
+
+#define GlintUserClip5Z 0x9cb0
+#define GlintUserClip5ZTag 0x0396
+#define GlintUserClip5ZReg 1
+#define GlintUserClip5ZOff 0x8cb0
+
+#define GlintUserClip5W 0x9cb8
+#define GlintUserClip5WTag 0x0397
+#define GlintUserClip5WReg 1
+#define GlintUserClip5WOff 0x8cb8
+
+#define GlintRasterPosXOffset 0x9ce8
+#define GlintRasterPosXOffsetTag 0x039d
+#define GlintRasterPosXOffsetReg 1
+#define GlintRasterPosXOffsetOff 0x8ce8
+
+#define GlintRasterPosYOffset 0x9cf0
+#define GlintRasterPosYOffsetTag 0x039e
+#define GlintRasterPosYOffsetReg 1
+#define GlintRasterPosYOffsetOff 0x8cf0
+
+#define GlintAttenuationCutOff 0x9cf8
+#define GlintAttenuationCutOffTag 0x039f
+#define GlintAttenuationCutOffReg 1
+#define GlintAttenuationCutOffOff 0x8cf8
+
+#define GlintLight0Mode 0x9d00
+#define GlintLight0ModeTag 0x03a0
+#define GlintLight0ModeReg 1
+#define GlintLight0ModeOff 0x8d00
+
+#define GlintLight0AmbientIntensityRed 0x9d08
+#define GlintLight0AmbientIntensityRedTag 0x03a1
+#define GlintLight0AmbientIntensityRedReg 1
+#define GlintLight0AmbientIntensityRedOff 0x8d08
+
+#define GlintLight0AmbientIntensityGreen 0x9d10
+#define GlintLight0AmbientIntensityGreenTag 0x03a2
+#define GlintLight0AmbientIntensityGreenReg 1
+#define GlintLight0AmbientIntensityGreenOff 0x8d10
+
+#define GlintLight0AmbientIntensityBlue 0x9d18
+#define GlintLight0AmbientIntensityBlueTag 0x03a3
+#define GlintLight0AmbientIntensityBlueReg 1
+#define GlintLight0AmbientIntensityBlueOff 0x8d18
+
+#define GlintLight0DiffuseIntensityRed 0x9d20
+#define GlintLight0DiffuseIntensityRedTag 0x03a4
+#define GlintLight0DiffuseIntensityRedReg 1
+#define GlintLight0DiffuseIntensityRedOff 0x8d20
+
+#define GlintLight0DiffuseIntensityGreen 0x9d28
+#define GlintLight0DiffuseIntensityGreenTag 0x03a5
+#define GlintLight0DiffuseIntensityGreenReg 1
+#define GlintLight0DiffuseIntensityGreenOff 0x8d28
+
+#define GlintLight0DiffuseIntensityBlue 0x9d30
+#define GlintLight0DiffuseIntensityBlueTag 0x03a6
+#define GlintLight0DiffuseIntensityBlueReg 1
+#define GlintLight0DiffuseIntensityBlueOff 0x8d30
+
+#define GlintLight0SpecularIntensityRed 0x9d38
+#define GlintLight0SpecularIntensityRedTag 0x03a7
+#define GlintLight0SpecularIntensityRedReg 1
+#define GlintLight0SpecularIntensityRedOff 0x8d38
+
+#define GlintLight0SpecularIntensityGreen 0x9d40
+#define GlintLight0SpecularIntensityGreenTag 0x03a8
+#define GlintLight0SpecularIntensityGreenReg 1
+#define GlintLight0SpecularIntensityGreenOff 0x8d40
+
+#define GlintLight0SpecularIntensityBlue 0x9d48
+#define GlintLight0SpecularIntensityBlueTag 0x03a9
+#define GlintLight0SpecularIntensityBlueReg 1
+#define GlintLight0SpecularIntensityBlueOff 0x8d48
+
+#define GlintLight0PositionX 0x9d50
+#define GlintLight0PositionXTag 0x03aa
+#define GlintLight0PositionXReg 1
+#define GlintLight0PositionXOff 0x8d50
+
+#define GlintLight0PositionY 0x9d58
+#define GlintLight0PositionYTag 0x03ab
+#define GlintLight0PositionYReg 1
+#define GlintLight0PositionYOff 0x8d58
+
+#define GlintLight0PositionZ 0x9d60
+#define GlintLight0PositionZTag 0x03ac
+#define GlintLight0PositionZReg 1
+#define GlintLight0PositionZOff 0x8d60
+
+#define GlintLight0PositionW 0x9d68
+#define GlintLight0PositionWTag 0x03ad
+#define GlintLight0PositionWReg 1
+#define GlintLight0PositionWOff 0x8d68
+
+#define GlintLight0SpotlightDirectionX 0x9d70
+#define GlintLight0SpotlightDirectionXTag 0x03ae
+#define GlintLight0SpotlightDirectionXReg 1
+#define GlintLight0SpotlightDirectionXOff 0x8d70
+
+#define GlintLight0SpotlightDirectionY 0x9d78
+#define GlintLight0SpotlightDirectionYTag 0x03af
+#define GlintLight0SpotlightDirectionYReg 1
+#define GlintLight0SpotlightDirectionYOff 0x8d78
+
+#define GlintLight0SpotlightDirectionZ 0x9d80
+#define GlintLight0SpotlightDirectionZTag 0x03b0
+#define GlintLight0SpotlightDirectionZReg 1
+#define GlintLight0SpotlightDirectionZOff 0x8d80
+
+#define GlintLight0SpotlightExponent 0x9d88
+#define GlintLight0SpotlightExponentTag 0x03b1
+#define GlintLight0SpotlightExponentReg 1
+#define GlintLight0SpotlightExponentOff 0x8d88
+
+#define GlintLight0CosSpotlightCutoffAngle 0x9d90
+#define GlintLight0CosSpotlightCutoffAngleTag 0x03b2
+#define GlintLight0CosSpotlightCutoffAngleReg 1
+#define GlintLight0CosSpotlightCutoffAngleOff 0x8d90
+
+#define GlintLight0ConstantAttenuation 0x9d98
+#define GlintLight0ConstantAttenuationTag 0x03b3
+#define GlintLight0ConstantAttenuationReg 1
+#define GlintLight0ConstantAttenuationOff 0x8d98
+
+#define GlintLight0LinearAttenuation 0x9da0
+#define GlintLight0LinearAttenuationTag 0x03b4
+#define GlintLight0LinearAttenuationReg 1
+#define GlintLight0LinearAttenuationOff 0x8da0
+
+#define GlintLight0QuadraticAttenuation 0x9da8
+#define GlintLight0QuadraticAttenuationTag 0x03b5
+#define GlintLight0QuadraticAttenuationReg 1
+#define GlintLight0QuadraticAttenuationOff 0x8da8
+
+#define GlintLight1Mode 0x9db0
+#define GlintLight1ModeTag 0x03b6
+#define GlintLight1ModeReg 1
+#define GlintLight1ModeOff 0x8db0
+
+#define GlintLight1AmbientIntensityRed 0x9db8
+#define GlintLight1AmbientIntensityRedTag 0x03b7
+#define GlintLight1AmbientIntensityRedReg 1
+#define GlintLight1AmbientIntensityRedOff 0x8db8
+
+#define GlintLight1AmbientIntensityGreen 0x9dc0
+#define GlintLight1AmbientIntensityGreenTag 0x03b8
+#define GlintLight1AmbientIntensityGreenReg 1
+#define GlintLight1AmbientIntensityGreenOff 0x8dc0
+
+#define GlintLight1AmbientIntensityBlue 0x9dc8
+#define GlintLight1AmbientIntensityBlueTag 0x03b9
+#define GlintLight1AmbientIntensityBlueReg 1
+#define GlintLight1AmbientIntensityBlueOff 0x8dc8
+
+#define GlintLight1DiffuseIntensityRed 0x9dd0
+#define GlintLight1DiffuseIntensityRedTag 0x03ba
+#define GlintLight1DiffuseIntensityRedReg 1
+#define GlintLight1DiffuseIntensityRedOff 0x8dd0
+
+#define GlintLight1DiffuseIntensityGreen 0x9dd8
+#define GlintLight1DiffuseIntensityGreenTag 0x03bb
+#define GlintLight1DiffuseIntensityGreenReg 1
+#define GlintLight1DiffuseIntensityGreenOff 0x8dd8
+
+#define GlintLight1DiffuseIntensityBlue 0x9de0
+#define GlintLight1DiffuseIntensityBlueTag 0x03bc
+#define GlintLight1DiffuseIntensityBlueReg 1
+#define GlintLight1DiffuseIntensityBlueOff 0x8de0
+
+#define GlintLight1SpecularIntensityRed 0x9de8
+#define GlintLight1SpecularIntensityRedTag 0x03bd
+#define GlintLight1SpecularIntensityRedReg 1
+#define GlintLight1SpecularIntensityRedOff 0x8de8
+
+#define GlintLight1SpecularIntensityGreen 0x9df0
+#define GlintLight1SpecularIntensityGreenTag 0x03be
+#define GlintLight1SpecularIntensityGreenReg 1
+#define GlintLight1SpecularIntensityGreenOff 0x8df0
+
+#define GlintLight1SpecularIntensityBlue 0x9df8
+#define GlintLight1SpecularIntensityBlueTag 0x03bf
+#define GlintLight1SpecularIntensityBlueReg 1
+#define GlintLight1SpecularIntensityBlueOff 0x8df8
+
+#define GlintLight1PositionX 0x9e00
+#define GlintLight1PositionXTag 0x03c0
+#define GlintLight1PositionXReg 1
+#define GlintLight1PositionXOff 0x8e00
+
+#define GlintLight1PositionY 0x9e08
+#define GlintLight1PositionYTag 0x03c1
+#define GlintLight1PositionYReg 1
+#define GlintLight1PositionYOff 0x8e08
+
+#define GlintLight1PositionZ 0x9e10
+#define GlintLight1PositionZTag 0x03c2
+#define GlintLight1PositionZReg 1
+#define GlintLight1PositionZOff 0x8e10
+
+#define GlintLight1PositionW 0x9e18
+#define GlintLight1PositionWTag 0x03c3
+#define GlintLight1PositionWReg 1
+#define GlintLight1PositionWOff 0x8e18
+
+#define GlintLight1SpotlightDirectionX 0x9e20
+#define GlintLight1SpotlightDirectionXTag 0x03c4
+#define GlintLight1SpotlightDirectionXReg 1
+#define GlintLight1SpotlightDirectionXOff 0x8e20
+
+#define GlintLight1SpotlightDirectionY 0x9e28
+#define GlintLight1SpotlightDirectionYTag 0x03c5
+#define GlintLight1SpotlightDirectionYReg 1
+#define GlintLight1SpotlightDirectionYOff 0x8e28
+
+#define GlintLight1SpotlightDirectionZ 0x9e30
+#define GlintLight1SpotlightDirectionZTag 0x03c6
+#define GlintLight1SpotlightDirectionZReg 1
+#define GlintLight1SpotlightDirectionZOff 0x8e30
+
+#define GlintLight1SpotlightExponent 0x9e38
+#define GlintLight1SpotlightExponentTag 0x03c7
+#define GlintLight1SpotlightExponentReg 1
+#define GlintLight1SpotlightExponentOff 0x8e38
+
+#define GlintLight1CosSpotlightCutoffAngle 0x9e40
+#define GlintLight1CosSpotlightCutoffAngleTag 0x03c8
+#define GlintLight1CosSpotlightCutoffAngleReg 1
+#define GlintLight1CosSpotlightCutoffAngleOff 0x8e40
+
+#define GlintLight1ConstantAttenuation 0x9e48
+#define GlintLight1ConstantAttenuationTag 0x03c9
+#define GlintLight1ConstantAttenuationReg 1
+#define GlintLight1ConstantAttenuationOff 0x8e48
+
+#define GlintLight1LinearAttenuation 0x9e50
+#define GlintLight1LinearAttenuationTag 0x03ca
+#define GlintLight1LinearAttenuationReg 1
+#define GlintLight1LinearAttenuationOff 0x8e50
+
+#define GlintLight1QuadraticAttenuation 0x9e58
+#define GlintLight1QuadraticAttenuationTag 0x03cb
+#define GlintLight1QuadraticAttenuationReg 1
+#define GlintLight1QuadraticAttenuationOff 0x8e58
+
+#define GlintLight2Mode 0x9e60
+#define GlintLight2ModeTag 0x03cc
+#define GlintLight2ModeReg 1
+#define GlintLight2ModeOff 0x8e60
+
+#define GlintLight2AmbientIntensityRed 0x9e68
+#define GlintLight2AmbientIntensityRedTag 0x03cd
+#define GlintLight2AmbientIntensityRedReg 1
+#define GlintLight2AmbientIntensityRedOff 0x8e68
+
+#define GlintLight2AmbientIntensityGreen 0x9e70
+#define GlintLight2AmbientIntensityGreenTag 0x03ce
+#define GlintLight2AmbientIntensityGreenReg 1
+#define GlintLight2AmbientIntensityGreenOff 0x8e70
+
+#define GlintLight2AmbientIntensityBlue 0x9e78
+#define GlintLight2AmbientIntensityBlueTag 0x03cf
+#define GlintLight2AmbientIntensityBlueReg 1
+#define GlintLight2AmbientIntensityBlueOff 0x8e78
+
+#define GlintLight2DiffuseIntensityRed 0x9e80
+#define GlintLight2DiffuseIntensityRedTag 0x03d0
+#define GlintLight2DiffuseIntensityRedReg 1
+#define GlintLight2DiffuseIntensityRedOff 0x8e80
+
+#define GlintLight2DiffuseIntensityGreen 0x9e88
+#define GlintLight2DiffuseIntensityGreenTag 0x03d1
+#define GlintLight2DiffuseIntensityGreenReg 1
+#define GlintLight2DiffuseIntensityGreenOff 0x8e88
+
+#define GlintLight2DiffuseIntensityBlue 0x9e90
+#define GlintLight2DiffuseIntensityBlueTag 0x03d2
+#define GlintLight2DiffuseIntensityBlueReg 1
+#define GlintLight2DiffuseIntensityBlueOff 0x8e90
+
+#define GlintLight2SpecularIntensityRed 0x9e98
+#define GlintLight2SpecularIntensityRedTag 0x03d3
+#define GlintLight2SpecularIntensityRedReg 1
+#define GlintLight2SpecularIntensityRedOff 0x8e98
+
+#define GlintLight2SpecularIntensityGreen 0x9ea0
+#define GlintLight2SpecularIntensityGreenTag 0x03d4
+#define GlintLight2SpecularIntensityGreenReg 1
+#define GlintLight2SpecularIntensityGreenOff 0x8ea0
+
+#define GlintLight2SpecularIntensityBlue 0x9ea8
+#define GlintLight2SpecularIntensityBlueTag 0x03d5
+#define GlintLight2SpecularIntensityBlueReg 1
+#define GlintLight2SpecularIntensityBlueOff 0x8ea8
+
+#define GlintLight2PositionX 0x9eb0
+#define GlintLight2PositionXTag 0x03d6
+#define GlintLight2PositionXReg 1
+#define GlintLight2PositionXOff 0x8eb0
+
+#define GlintLight2PositionY 0x9eb8
+#define GlintLight2PositionYTag 0x03d7
+#define GlintLight2PositionYReg 1
+#define GlintLight2PositionYOff 0x8eb8
+
+#define GlintLight2PositionZ 0x9ec0
+#define GlintLight2PositionZTag 0x03d8
+#define GlintLight2PositionZReg 1
+#define GlintLight2PositionZOff 0x8ec0
+
+#define GlintLight2PositionW 0x9ec8
+#define GlintLight2PositionWTag 0x03d9
+#define GlintLight2PositionWReg 1
+#define GlintLight2PositionWOff 0x8ec8
+
+#define GlintLight2SpotlightDirectionX 0x9ed0
+#define GlintLight2SpotlightDirectionXTag 0x03da
+#define GlintLight2SpotlightDirectionXReg 1
+#define GlintLight2SpotlightDirectionXOff 0x8ed0
+
+#define GlintLight2SpotlightDirectionY 0x9ed8
+#define GlintLight2SpotlightDirectionYTag 0x03db
+#define GlintLight2SpotlightDirectionYReg 1
+#define GlintLight2SpotlightDirectionYOff 0x8ed8
+
+#define GlintLight2SpotlightDirectionZ 0x9ee0
+#define GlintLight2SpotlightDirectionZTag 0x03dc
+#define GlintLight2SpotlightDirectionZReg 1
+#define GlintLight2SpotlightDirectionZOff 0x8ee0
+
+#define GlintLight2SpotlightExponent 0x9ee8
+#define GlintLight2SpotlightExponentTag 0x03dd
+#define GlintLight2SpotlightExponentReg 1
+#define GlintLight2SpotlightExponentOff 0x8ee8
+
+#define GlintLight2CosSpotlightCutoffAngle 0x9ef0
+#define GlintLight2CosSpotlightCutoffAngleTag 0x03de
+#define GlintLight2CosSpotlightCutoffAngleReg 1
+#define GlintLight2CosSpotlightCutoffAngleOff 0x8ef0
+
+#define GlintLight2ConstantAttenuation 0x9ef8
+#define GlintLight2ConstantAttenuationTag 0x03df
+#define GlintLight2ConstantAttenuationReg 1
+#define GlintLight2ConstantAttenuationOff 0x8ef8
+
+#define GlintLight2LinearAttenuation 0x9f00
+#define GlintLight2LinearAttenuationTag 0x03e0
+#define GlintLight2LinearAttenuationReg 1
+#define GlintLight2LinearAttenuationOff 0x8f00
+
+#define GlintLight2QuadraticAttenuation 0x9f08
+#define GlintLight2QuadraticAttenuationTag 0x03e1
+#define GlintLight2QuadraticAttenuationReg 1
+#define GlintLight2QuadraticAttenuationOff 0x8f08
+
+#define GlintLight3Mode 0x9f10
+#define GlintLight3ModeTag 0x03e2
+#define GlintLight3ModeReg 1
+#define GlintLight3ModeOff 0x8f10
+
+#define GlintLight3AmbientIntensityRed 0x9f18
+#define GlintLight3AmbientIntensityRedTag 0x03e3
+#define GlintLight3AmbientIntensityRedReg 1
+#define GlintLight3AmbientIntensityRedOff 0x8f18
+
+#define GlintLight3AmbientIntensityGreen 0x9f20
+#define GlintLight3AmbientIntensityGreenTag 0x03e4
+#define GlintLight3AmbientIntensityGreenReg 1
+#define GlintLight3AmbientIntensityGreenOff 0x8f20
+
+#define GlintLight3AmbientIntensityBlue 0x9f28
+#define GlintLight3AmbientIntensityBlueTag 0x03e5
+#define GlintLight3AmbientIntensityBlueReg 1
+#define GlintLight3AmbientIntensityBlueOff 0x8f28
+
+#define GlintLight3DiffuseIntensityRed 0x9f30
+#define GlintLight3DiffuseIntensityRedTag 0x03e6
+#define GlintLight3DiffuseIntensityRedReg 1
+#define GlintLight3DiffuseIntensityRedOff 0x8f30
+
+#define GlintLight3DiffuseIntensityGreen 0x9f38
+#define GlintLight3DiffuseIntensityGreenTag 0x03e7
+#define GlintLight3DiffuseIntensityGreenReg 1
+#define GlintLight3DiffuseIntensityGreenOff 0x8f38
+
+#define GlintLight3DiffuseIntensityBlue 0x9f40
+#define GlintLight3DiffuseIntensityBlueTag 0x03e8
+#define GlintLight3DiffuseIntensityBlueReg 1
+#define GlintLight3DiffuseIntensityBlueOff 0x8f40
+
+#define GlintLight3SpecularIntensityRed 0x9f48
+#define GlintLight3SpecularIntensityRedTag 0x03e9
+#define GlintLight3SpecularIntensityRedReg 1
+#define GlintLight3SpecularIntensityRedOff 0x8f48
+
+#define GlintLight3SpecularIntensityGreen 0x9f50
+#define GlintLight3SpecularIntensityGreenTag 0x03ea
+#define GlintLight3SpecularIntensityGreenReg 1
+#define GlintLight3SpecularIntensityGreenOff 0x8f50
+
+#define GlintLight3SpecularIntensityBlue 0x9f58
+#define GlintLight3SpecularIntensityBlueTag 0x03eb
+#define GlintLight3SpecularIntensityBlueReg 1
+#define GlintLight3SpecularIntensityBlueOff 0x8f58
+
+#define GlintLight3PositionX 0x9f60
+#define GlintLight3PositionXTag 0x03ec
+#define GlintLight3PositionXReg 1
+#define GlintLight3PositionXOff 0x8f60
+
+#define GlintLight3PositionY 0x9f68
+#define GlintLight3PositionYTag 0x03ed
+#define GlintLight3PositionYReg 1
+#define GlintLight3PositionYOff 0x8f68
+
+#define GlintLight3PositionZ 0x9f70
+#define GlintLight3PositionZTag 0x03ee
+#define GlintLight3PositionZReg 1
+#define GlintLight3PositionZOff 0x8f70
+
+#define GlintLight3PositionW 0x9f78
+#define GlintLight3PositionWTag 0x03ef
+#define GlintLight3PositionWReg 1
+#define GlintLight3PositionWOff 0x8f78
+
+#define GlintLight3SpotlightDirectionX 0x9f80
+#define GlintLight3SpotlightDirectionXTag 0x03f0
+#define GlintLight3SpotlightDirectionXReg 1
+#define GlintLight3SpotlightDirectionXOff 0x8f80
+
+#define GlintLight3SpotlightDirectionY 0x9f88
+#define GlintLight3SpotlightDirectionYTag 0x03f1
+#define GlintLight3SpotlightDirectionYReg 1
+#define GlintLight3SpotlightDirectionYOff 0x8f88
+
+#define GlintLight3SpotlightDirectionZ 0x9f90
+#define GlintLight3SpotlightDirectionZTag 0x03f2
+#define GlintLight3SpotlightDirectionZReg 1
+#define GlintLight3SpotlightDirectionZOff 0x8f90
+
+#define GlintLight3SpotlightExponent 0x9f98
+#define GlintLight3SpotlightExponentTag 0x03f3
+#define GlintLight3SpotlightExponentReg 1
+#define GlintLight3SpotlightExponentOff 0x8f98
+
+#define GlintLight3CosSpotlightCutoffAngle 0x9fa0
+#define GlintLight3CosSpotlightCutoffAngleTag 0x03f4
+#define GlintLight3CosSpotlightCutoffAngleReg 1
+#define GlintLight3CosSpotlightCutoffAngleOff 0x8fa0
+
+#define GlintLight3ConstantAttenuation 0x9fa8
+#define GlintLight3ConstantAttenuationTag 0x03f5
+#define GlintLight3ConstantAttenuationReg 1
+#define GlintLight3ConstantAttenuationOff 0x8fa8
+
+#define GlintLight3LinearAttenuation 0x9fb0
+#define GlintLight3LinearAttenuationTag 0x03f6
+#define GlintLight3LinearAttenuationReg 1
+#define GlintLight3LinearAttenuationOff 0x8fb0
+
+#define GlintLight3QuadraticAttenuation 0x9fb8
+#define GlintLight3QuadraticAttenuationTag 0x03f7
+#define GlintLight3QuadraticAttenuationReg 1
+#define GlintLight3QuadraticAttenuationOff 0x8fb8
+
+#define GlintLight4Mode 0x9fc0
+#define GlintLight4ModeTag 0x03f8
+#define GlintLight4ModeReg 1
+#define GlintLight4ModeOff 0x8fc0
+
+#define GlintLight4AmbientIntensityRed 0x9fc8
+#define GlintLight4AmbientIntensityRedTag 0x03f9
+#define GlintLight4AmbientIntensityRedReg 1
+#define GlintLight4AmbientIntensityRedOff 0x8fc8
+
+#define GlintLight4AmbientIntensityGreen 0x9fd0
+#define GlintLight4AmbientIntensityGreenTag 0x03fa
+#define GlintLight4AmbientIntensityGreenReg 1
+#define GlintLight4AmbientIntensityGreenOff 0x8fd0
+
+#define GlintLight4AmbientIntensityBlue 0x9fd8
+#define GlintLight4AmbientIntensityBlueTag 0x03fb
+#define GlintLight4AmbientIntensityBlueReg 1
+#define GlintLight4AmbientIntensityBlueOff 0x8fd8
+
+#define GlintLight4DiffuseIntensityRed 0x9fe0
+#define GlintLight4DiffuseIntensityRedTag 0x03fc
+#define GlintLight4DiffuseIntensityRedReg 1
+#define GlintLight4DiffuseIntensityRedOff 0x8fe0
+
+#define GlintLight4DiffuseIntensityGreen 0x9fe8
+#define GlintLight4DiffuseIntensityGreenTag 0x03fd
+#define GlintLight4DiffuseIntensityGreenReg 1
+#define GlintLight4DiffuseIntensityGreenOff 0x8fe8
+
+#define GlintLight4DiffuseIntensityBlue 0x9ff0
+#define GlintLight4DiffuseIntensityBlueTag 0x03fe
+#define GlintLight4DiffuseIntensityBlueReg 1
+#define GlintLight4DiffuseIntensityBlueOff 0x8ff0
+
+#define GlintLight4SpecularIntensityRed 0x9ff8
+#define GlintLight4SpecularIntensityRedTag 0x03ff
+#define GlintLight4SpecularIntensityRedReg 1
+#define GlintLight4SpecularIntensityRedOff 0x8ff8
+
+#define GlintLight4SpecularIntensityGreen 0xa000
+#define GlintLight4SpecularIntensityGreenTag 0x0400
+#define GlintLight4SpecularIntensityGreenReg 1
+#define GlintLight4SpecularIntensityGreenOff 0x9000
+
+#define GlintLight4SpecularIntensityBlue 0xa008
+#define GlintLight4SpecularIntensityBlueTag 0x0401
+#define GlintLight4SpecularIntensityBlueReg 1
+#define GlintLight4SpecularIntensityBlueOff 0x9008
+
+#define GlintLight4PositionX 0xa010
+#define GlintLight4PositionXTag 0x0402
+#define GlintLight4PositionXReg 1
+#define GlintLight4PositionXOff 0x9010
+
+#define GlintLight4PositionY 0xa018
+#define GlintLight4PositionYTag 0x0403
+#define GlintLight4PositionYReg 1
+#define GlintLight4PositionYOff 0x9018
+
+#define GlintLight4PositionZ 0xa020
+#define GlintLight4PositionZTag 0x0404
+#define GlintLight4PositionZReg 1
+#define GlintLight4PositionZOff 0x9020
+
+#define GlintLight4PositionW 0xa028
+#define GlintLight4PositionWTag 0x0405
+#define GlintLight4PositionWReg 1
+#define GlintLight4PositionWOff 0x9028
+
+#define GlintLight4SpotlightDirectionX 0xa030
+#define GlintLight4SpotlightDirectionXTag 0x0406
+#define GlintLight4SpotlightDirectionXReg 1
+#define GlintLight4SpotlightDirectionXOff 0x9030
+
+#define GlintLight4SpotlightDirectionY 0xa038
+#define GlintLight4SpotlightDirectionYTag 0x0407
+#define GlintLight4SpotlightDirectionYReg 1
+#define GlintLight4SpotlightDirectionYOff 0x9038
+
+#define GlintLight4SpotlightDirectionZ 0xa040
+#define GlintLight4SpotlightDirectionZTag 0x0408
+#define GlintLight4SpotlightDirectionZReg 1
+#define GlintLight4SpotlightDirectionZOff 0x9040
+
+#define GlintLight4SpotlightExponent 0xa048
+#define GlintLight4SpotlightExponentTag 0x0409
+#define GlintLight4SpotlightExponentReg 1
+#define GlintLight4SpotlightExponentOff 0x9048
+
+#define GlintLight4CosSpotlightCutoffAngle 0xa050
+#define GlintLight4CosSpotlightCutoffAngleTag 0x040a
+#define GlintLight4CosSpotlightCutoffAngleReg 1
+#define GlintLight4CosSpotlightCutoffAngleOff 0x9050
+
+#define GlintLight4ConstantAttenuation 0xa058
+#define GlintLight4ConstantAttenuationTag 0x040b
+#define GlintLight4ConstantAttenuationReg 1
+#define GlintLight4ConstantAttenuationOff 0x9058
+
+#define GlintLight4LinearAttenuation 0xa060
+#define GlintLight4LinearAttenuationTag 0x040c
+#define GlintLight4LinearAttenuationReg 1
+#define GlintLight4LinearAttenuationOff 0x9060
+
+#define GlintLight4QuadraticAttenuation 0xa068
+#define GlintLight4QuadraticAttenuationTag 0x040d
+#define GlintLight4QuadraticAttenuationReg 1
+#define GlintLight4QuadraticAttenuationOff 0x9068
+
+#define GlintLight5Mode 0xa070
+#define GlintLight5ModeTag 0x040e
+#define GlintLight5ModeReg 1
+#define GlintLight5ModeOff 0x9070
+
+#define GlintLight5AmbientIntensityRed 0xa078
+#define GlintLight5AmbientIntensityRedTag 0x040f
+#define GlintLight5AmbientIntensityRedReg 1
+#define GlintLight5AmbientIntensityRedOff 0x9078
+
+#define GlintLight5AmbientIntensityGreen 0xa080
+#define GlintLight5AmbientIntensityGreenTag 0x0410
+#define GlintLight5AmbientIntensityGreenReg 1
+#define GlintLight5AmbientIntensityGreenOff 0x9080
+
+#define GlintLight5AmbientIntensityBlue 0xa088
+#define GlintLight5AmbientIntensityBlueTag 0x0411
+#define GlintLight5AmbientIntensityBlueReg 1
+#define GlintLight5AmbientIntensityBlueOff 0x9088
+
+#define GlintLight5DiffuseIntensityRed 0xa090
+#define GlintLight5DiffuseIntensityRedTag 0x0412
+#define GlintLight5DiffuseIntensityRedReg 1
+#define GlintLight5DiffuseIntensityRedOff 0x9090
+
+#define GlintLight5DiffuseIntensityGreen 0xa098
+#define GlintLight5DiffuseIntensityGreenTag 0x0413
+#define GlintLight5DiffuseIntensityGreenReg 1
+#define GlintLight5DiffuseIntensityGreenOff 0x9098
+
+#define GlintLight5DiffuseIntensityBlue 0xa0a0
+#define GlintLight5DiffuseIntensityBlueTag 0x0414
+#define GlintLight5DiffuseIntensityBlueReg 1
+#define GlintLight5DiffuseIntensityBlueOff 0x90a0
+
+#define GlintLight5SpecularIntensityRed 0xa0a8
+#define GlintLight5SpecularIntensityRedTag 0x0415
+#define GlintLight5SpecularIntensityRedReg 1
+#define GlintLight5SpecularIntensityRedOff 0x90a8
+
+#define GlintLight5SpecularIntensityGreen 0xa0b0
+#define GlintLight5SpecularIntensityGreenTag 0x0416
+#define GlintLight5SpecularIntensityGreenReg 1
+#define GlintLight5SpecularIntensityGreenOff 0x90b0
+
+#define GlintLight5SpecularIntensityBlue 0xa0b8
+#define GlintLight5SpecularIntensityBlueTag 0x0417
+#define GlintLight5SpecularIntensityBlueReg 1
+#define GlintLight5SpecularIntensityBlueOff 0x90b8
+
+#define GlintLight5PositionX 0xa0c0
+#define GlintLight5PositionXTag 0x0418
+#define GlintLight5PositionXReg 1
+#define GlintLight5PositionXOff 0x90c0
+
+#define GlintLight5PositionY 0xa0c8
+#define GlintLight5PositionYTag 0x0419
+#define GlintLight5PositionYReg 1
+#define GlintLight5PositionYOff 0x90c8
+
+#define GlintLight5PositionZ 0xa0d0
+#define GlintLight5PositionZTag 0x041a
+#define GlintLight5PositionZReg 1
+#define GlintLight5PositionZOff 0x90d0
+
+#define GlintLight5PositionW 0xa0d8
+#define GlintLight5PositionWTag 0x041b
+#define GlintLight5PositionWReg 1
+#define GlintLight5PositionWOff 0x90d8
+
+#define GlintLight5SpotlightDirectionX 0xa0e0
+#define GlintLight5SpotlightDirectionXTag 0x041c
+#define GlintLight5SpotlightDirectionXReg 1
+#define GlintLight5SpotlightDirectionXOff 0x90e0
+
+#define GlintLight5SpotlightDirectionY 0xa0e8
+#define GlintLight5SpotlightDirectionYTag 0x041d
+#define GlintLight5SpotlightDirectionYReg 1
+#define GlintLight5SpotlightDirectionYOff 0x90e8
+
+#define GlintLight5SpotlightDirectionZ 0xa0f0
+#define GlintLight5SpotlightDirectionZTag 0x041e
+#define GlintLight5SpotlightDirectionZReg 1
+#define GlintLight5SpotlightDirectionZOff 0x90f0
+
+#define GlintLight5SpotlightExponent 0xa0f8
+#define GlintLight5SpotlightExponentTag 0x041f
+#define GlintLight5SpotlightExponentReg 1
+#define GlintLight5SpotlightExponentOff 0x90f8
+
+#define GlintLight5CosSpotlightCutoffAngle 0xa100
+#define GlintLight5CosSpotlightCutoffAngleTag 0x0420
+#define GlintLight5CosSpotlightCutoffAngleReg 1
+#define GlintLight5CosSpotlightCutoffAngleOff 0x9100
+
+#define GlintLight5ConstantAttenuation 0xa108
+#define GlintLight5ConstantAttenuationTag 0x0421
+#define GlintLight5ConstantAttenuationReg 1
+#define GlintLight5ConstantAttenuationOff 0x9108
+
+#define GlintLight5LinearAttenuation 0xa110
+#define GlintLight5LinearAttenuationTag 0x0422
+#define GlintLight5LinearAttenuationReg 1
+#define GlintLight5LinearAttenuationOff 0x9110
+
+#define GlintLight5QuadraticAttenuation 0xa118
+#define GlintLight5QuadraticAttenuationTag 0x0423
+#define GlintLight5QuadraticAttenuationReg 1
+#define GlintLight5QuadraticAttenuationOff 0x9118
+
+#define GlintLight6Mode 0xa120
+#define GlintLight6ModeTag 0x0424
+#define GlintLight6ModeReg 1
+#define GlintLight6ModeOff 0x9120
+
+#define GlintLight6AmbientIntensityRed 0xa128
+#define GlintLight6AmbientIntensityRedTag 0x0425
+#define GlintLight6AmbientIntensityRedReg 1
+#define GlintLight6AmbientIntensityRedOff 0x9128
+
+#define GlintLight6AmbientIntensityGreen 0xa130
+#define GlintLight6AmbientIntensityGreenTag 0x0426
+#define GlintLight6AmbientIntensityGreenReg 1
+#define GlintLight6AmbientIntensityGreenOff 0x9130
+
+#define GlintLight6AmbientIntensityBlue 0xa138
+#define GlintLight6AmbientIntensityBlueTag 0x0427
+#define GlintLight6AmbientIntensityBlueReg 1
+#define GlintLight6AmbientIntensityBlueOff 0x9138
+
+#define GlintLight6DiffuseIntensityRed 0xa140
+#define GlintLight6DiffuseIntensityRedTag 0x0428
+#define GlintLight6DiffuseIntensityRedReg 1
+#define GlintLight6DiffuseIntensityRedOff 0x9140
+
+#define GlintLight6DiffuseIntensityGreen 0xa148
+#define GlintLight6DiffuseIntensityGreenTag 0x0429
+#define GlintLight6DiffuseIntensityGreenReg 1
+#define GlintLight6DiffuseIntensityGreenOff 0x9148
+
+#define GlintLight6DiffuseIntensityBlue 0xa150
+#define GlintLight6DiffuseIntensityBlueTag 0x042a
+#define GlintLight6DiffuseIntensityBlueReg 1
+#define GlintLight6DiffuseIntensityBlueOff 0x9150
+
+#define GlintLight6SpecularIntensityRed 0xa158
+#define GlintLight6SpecularIntensityRedTag 0x042b
+#define GlintLight6SpecularIntensityRedReg 1
+#define GlintLight6SpecularIntensityRedOff 0x9158
+
+#define GlintLight6SpecularIntensityGreen 0xa160
+#define GlintLight6SpecularIntensityGreenTag 0x042c
+#define GlintLight6SpecularIntensityGreenReg 1
+#define GlintLight6SpecularIntensityGreenOff 0x9160
+
+#define GlintLight6SpecularIntensityBlue 0xa168
+#define GlintLight6SpecularIntensityBlueTag 0x042d
+#define GlintLight6SpecularIntensityBlueReg 1
+#define GlintLight6SpecularIntensityBlueOff 0x9168
+
+#define GlintLight6PositionX 0xa170
+#define GlintLight6PositionXTag 0x042e
+#define GlintLight6PositionXReg 1
+#define GlintLight6PositionXOff 0x9170
+
+#define GlintLight6PositionY 0xa178
+#define GlintLight6PositionYTag 0x042f
+#define GlintLight6PositionYReg 1
+#define GlintLight6PositionYOff 0x9178
+
+#define GlintLight6PositionZ 0xa180
+#define GlintLight6PositionZTag 0x0430
+#define GlintLight6PositionZReg 1
+#define GlintLight6PositionZOff 0x9180
+
+#define GlintLight6PositionW 0xa188
+#define GlintLight6PositionWTag 0x0431
+#define GlintLight6PositionWReg 1
+#define GlintLight6PositionWOff 0x9188
+
+#define GlintLight6SpotlightDirectionX 0xa190
+#define GlintLight6SpotlightDirectionXTag 0x0432
+#define GlintLight6SpotlightDirectionXReg 1
+#define GlintLight6SpotlightDirectionXOff 0x9190
+
+#define GlintLight6SpotlightDirectionY 0xa198
+#define GlintLight6SpotlightDirectionYTag 0x0433
+#define GlintLight6SpotlightDirectionYReg 1
+#define GlintLight6SpotlightDirectionYOff 0x9198
+
+#define GlintLight6SpotlightDirectionZ 0xa1a0
+#define GlintLight6SpotlightDirectionZTag 0x0434
+#define GlintLight6SpotlightDirectionZReg 1
+#define GlintLight6SpotlightDirectionZOff 0x91a0
+
+#define GlintLight6SpotlightExponent 0xa1a8
+#define GlintLight6SpotlightExponentTag 0x0435
+#define GlintLight6SpotlightExponentReg 1
+#define GlintLight6SpotlightExponentOff 0x91a8
+
+#define GlintLight6CosSpotlightCutoffAngle 0xa1b0
+#define GlintLight6CosSpotlightCutoffAngleTag 0x0436
+#define GlintLight6CosSpotlightCutoffAngleReg 1
+#define GlintLight6CosSpotlightCutoffAngleOff 0x91b0
+
+#define GlintLight6ConstantAttenuation 0xa1b8
+#define GlintLight6ConstantAttenuationTag 0x0437
+#define GlintLight6ConstantAttenuationReg 1
+#define GlintLight6ConstantAttenuationOff 0x91b8
+
+#define GlintLight6LinearAttenuation 0xa1c0
+#define GlintLight6LinearAttenuationTag 0x0438
+#define GlintLight6LinearAttenuationReg 1
+#define GlintLight6LinearAttenuationOff 0x91c0
+
+#define GlintLight6QuadraticAttenuation 0xa1c8
+#define GlintLight6QuadraticAttenuationTag 0x0439
+#define GlintLight6QuadraticAttenuationReg 1
+#define GlintLight6QuadraticAttenuationOff 0x91c8
+
+#define GlintLight7Mode 0xa1d0
+#define GlintLight7ModeTag 0x043a
+#define GlintLight7ModeReg 1
+#define GlintLight7ModeOff 0x91d0
+
+#define GlintLight7AmbientIntensityRed 0xa1d8
+#define GlintLight7AmbientIntensityRedTag 0x043b
+#define GlintLight7AmbientIntensityRedReg 1
+#define GlintLight7AmbientIntensityRedOff 0x91d8
+
+#define GlintLight7AmbientIntensityGreen 0xa1e0
+#define GlintLight7AmbientIntensityGreenTag 0x043c
+#define GlintLight7AmbientIntensityGreenReg 1
+#define GlintLight7AmbientIntensityGreenOff 0x91e0
+
+#define GlintLight7AmbientIntensityBlue 0xa1e8
+#define GlintLight7AmbientIntensityBlueTag 0x043d
+#define GlintLight7AmbientIntensityBlueReg 1
+#define GlintLight7AmbientIntensityBlueOff 0x91e8
+
+#define GlintLight7DiffuseIntensityRed 0xa1f0
+#define GlintLight7DiffuseIntensityRedTag 0x043e
+#define GlintLight7DiffuseIntensityRedReg 1
+#define GlintLight7DiffuseIntensityRedOff 0x91f0
+
+#define GlintLight7DiffuseIntensityGreen 0xa1f8
+#define GlintLight7DiffuseIntensityGreenTag 0x043f
+#define GlintLight7DiffuseIntensityGreenReg 1
+#define GlintLight7DiffuseIntensityGreenOff 0x91f8
+
+#define GlintLight7DiffuseIntensityBlue 0xa200
+#define GlintLight7DiffuseIntensityBlueTag 0x0440
+#define GlintLight7DiffuseIntensityBlueReg 1
+#define GlintLight7DiffuseIntensityBlueOff 0x9200
+
+#define GlintLight7SpecularIntensityRed 0xa208
+#define GlintLight7SpecularIntensityRedTag 0x0441
+#define GlintLight7SpecularIntensityRedReg 1
+#define GlintLight7SpecularIntensityRedOff 0x9208
+
+#define GlintLight7SpecularIntensityGreen 0xa210
+#define GlintLight7SpecularIntensityGreenTag 0x0442
+#define GlintLight7SpecularIntensityGreenReg 1
+#define GlintLight7SpecularIntensityGreenOff 0x9210
+
+#define GlintLight7SpecularIntensityBlue 0xa218
+#define GlintLight7SpecularIntensityBlueTag 0x0443
+#define GlintLight7SpecularIntensityBlueReg 1
+#define GlintLight7SpecularIntensityBlueOff 0x9218
+
+#define GlintLight7PositionX 0xa220
+#define GlintLight7PositionXTag 0x0444
+#define GlintLight7PositionXReg 1
+#define GlintLight7PositionXOff 0x9220
+
+#define GlintLight7PositionY 0xa228
+#define GlintLight7PositionYTag 0x0445
+#define GlintLight7PositionYReg 1
+#define GlintLight7PositionYOff 0x9228
+
+#define GlintLight7PositionZ 0xa230
+#define GlintLight7PositionZTag 0x0446
+#define GlintLight7PositionZReg 1
+#define GlintLight7PositionZOff 0x9230
+
+#define GlintLight7PositionW 0xa238
+#define GlintLight7PositionWTag 0x0447
+#define GlintLight7PositionWReg 1
+#define GlintLight7PositionWOff 0x9238
+
+#define GlintLight7SpotlightDirectionX 0xa240
+#define GlintLight7SpotlightDirectionXTag 0x0448
+#define GlintLight7SpotlightDirectionXReg 1
+#define GlintLight7SpotlightDirectionXOff 0x9240
+
+#define GlintLight7SpotlightDirectionY 0xa248
+#define GlintLight7SpotlightDirectionYTag 0x0449
+#define GlintLight7SpotlightDirectionYReg 1
+#define GlintLight7SpotlightDirectionYOff 0x9248
+
+#define GlintLight7SpotlightDirectionZ 0xa250
+#define GlintLight7SpotlightDirectionZTag 0x044a
+#define GlintLight7SpotlightDirectionZReg 1
+#define GlintLight7SpotlightDirectionZOff 0x9250
+
+#define GlintLight7SpotlightExponent 0xa258
+#define GlintLight7SpotlightExponentTag 0x044b
+#define GlintLight7SpotlightExponentReg 1
+#define GlintLight7SpotlightExponentOff 0x9258
+
+#define GlintLight7CosSpotlightCutoffAngle 0xa260
+#define GlintLight7CosSpotlightCutoffAngleTag 0x044c
+#define GlintLight7CosSpotlightCutoffAngleReg 1
+#define GlintLight7CosSpotlightCutoffAngleOff 0x9260
+
+#define GlintLight7ConstantAttenuation 0xa268
+#define GlintLight7ConstantAttenuationTag 0x044d
+#define GlintLight7ConstantAttenuationReg 1
+#define GlintLight7ConstantAttenuationOff 0x9268
+
+#define GlintLight7LinearAttenuation 0xa270
+#define GlintLight7LinearAttenuationTag 0x044e
+#define GlintLight7LinearAttenuationReg 1
+#define GlintLight7LinearAttenuationOff 0x9270
+
+#define GlintLight7QuadraticAttenuation 0xa278
+#define GlintLight7QuadraticAttenuationTag 0x044f
+#define GlintLight7QuadraticAttenuationReg 1
+#define GlintLight7QuadraticAttenuationOff 0x9278
+
+#define GlintLight8Mode 0xa280
+#define GlintLight8ModeTag 0x0450
+#define GlintLight8ModeReg 1
+#define GlintLight8ModeOff 0x9280
+
+#define GlintLight8AmbientIntensityRed 0xa288
+#define GlintLight8AmbientIntensityRedTag 0x0451
+#define GlintLight8AmbientIntensityRedReg 1
+#define GlintLight8AmbientIntensityRedOff 0x9288
+
+#define GlintLight8AmbientIntensityGreen 0xa290
+#define GlintLight8AmbientIntensityGreenTag 0x0452
+#define GlintLight8AmbientIntensityGreenReg 1
+#define GlintLight8AmbientIntensityGreenOff 0x9290
+
+#define GlintLight8AmbientIntensityBlue 0xa298
+#define GlintLight8AmbientIntensityBlueTag 0x0453
+#define GlintLight8AmbientIntensityBlueReg 1
+#define GlintLight8AmbientIntensityBlueOff 0x9298
+
+#define GlintLight8DiffuseIntensityRed 0xa2a0
+#define GlintLight8DiffuseIntensityRedTag 0x0454
+#define GlintLight8DiffuseIntensityRedReg 1
+#define GlintLight8DiffuseIntensityRedOff 0x92a0
+
+#define GlintLight8DiffuseIntensityGreen 0xa2a8
+#define GlintLight8DiffuseIntensityGreenTag 0x0455
+#define GlintLight8DiffuseIntensityGreenReg 1
+#define GlintLight8DiffuseIntensityGreenOff 0x92a8
+
+#define GlintLight8DiffuseIntensityBlue 0xa2b0
+#define GlintLight8DiffuseIntensityBlueTag 0x0456
+#define GlintLight8DiffuseIntensityBlueReg 1
+#define GlintLight8DiffuseIntensityBlueOff 0x92b0
+
+#define GlintLight8SpecularIntensityRed 0xa2b8
+#define GlintLight8SpecularIntensityRedTag 0x0457
+#define GlintLight8SpecularIntensityRedReg 1
+#define GlintLight8SpecularIntensityRedOff 0x92b8
+
+#define GlintLight8SpecularIntensityGreen 0xa2c0
+#define GlintLight8SpecularIntensityGreenTag 0x0458
+#define GlintLight8SpecularIntensityGreenReg 1
+#define GlintLight8SpecularIntensityGreenOff 0x92c0
+
+#define GlintLight8SpecularIntensityBlue 0xa2c8
+#define GlintLight8SpecularIntensityBlueTag 0x0459
+#define GlintLight8SpecularIntensityBlueReg 1
+#define GlintLight8SpecularIntensityBlueOff 0x92c8
+
+#define GlintLight8PositionX 0xa2d0
+#define GlintLight8PositionXTag 0x045a
+#define GlintLight8PositionXReg 1
+#define GlintLight8PositionXOff 0x92d0
+
+#define GlintLight8PositionY 0xa2d8
+#define GlintLight8PositionYTag 0x045b
+#define GlintLight8PositionYReg 1
+#define GlintLight8PositionYOff 0x92d8
+
+#define GlintLight8PositionZ 0xa2e0
+#define GlintLight8PositionZTag 0x045c
+#define GlintLight8PositionZReg 1
+#define GlintLight8PositionZOff 0x92e0
+
+#define GlintLight8PositionW 0xa2e8
+#define GlintLight8PositionWTag 0x045d
+#define GlintLight8PositionWReg 1
+#define GlintLight8PositionWOff 0x92e8
+
+#define GlintLight8SpotlightDirectionX 0xa2f0
+#define GlintLight8SpotlightDirectionXTag 0x045e
+#define GlintLight8SpotlightDirectionXReg 1
+#define GlintLight8SpotlightDirectionXOff 0x92f0
+
+#define GlintLight8SpotlightDirectionY 0xa2f8
+#define GlintLight8SpotlightDirectionYTag 0x045f
+#define GlintLight8SpotlightDirectionYReg 1
+#define GlintLight8SpotlightDirectionYOff 0x92f8
+
+#define GlintLight8SpotlightDirectionZ 0xa300
+#define GlintLight8SpotlightDirectionZTag 0x0460
+#define GlintLight8SpotlightDirectionZReg 1
+#define GlintLight8SpotlightDirectionZOff 0x9300
+
+#define GlintLight8SpotlightExponent 0xa308
+#define GlintLight8SpotlightExponentTag 0x0461
+#define GlintLight8SpotlightExponentReg 1
+#define GlintLight8SpotlightExponentOff 0x9308
+
+#define GlintLight8CosSpotlightCutoffAngle 0xa310
+#define GlintLight8CosSpotlightCutoffAngleTag 0x0462
+#define GlintLight8CosSpotlightCutoffAngleReg 1
+#define GlintLight8CosSpotlightCutoffAngleOff 0x9310
+
+#define GlintLight8ConstantAttenuation 0xa318
+#define GlintLight8ConstantAttenuationTag 0x0463
+#define GlintLight8ConstantAttenuationReg 1
+#define GlintLight8ConstantAttenuationOff 0x9318
+
+#define GlintLight8LinearAttenuation 0xa320
+#define GlintLight8LinearAttenuationTag 0x0464
+#define GlintLight8LinearAttenuationReg 1
+#define GlintLight8LinearAttenuationOff 0x9320
+
+#define GlintLight8QuadraticAttenuation 0xa328
+#define GlintLight8QuadraticAttenuationTag 0x0465
+#define GlintLight8QuadraticAttenuationReg 1
+#define GlintLight8QuadraticAttenuationOff 0x9328
+
+#define GlintLight9Mode 0xa330
+#define GlintLight9ModeTag 0x0466
+#define GlintLight9ModeReg 1
+#define GlintLight9ModeOff 0x9330
+
+#define GlintLight9AmbientIntensityRed 0xa338
+#define GlintLight9AmbientIntensityRedTag 0x0467
+#define GlintLight9AmbientIntensityRedReg 1
+#define GlintLight9AmbientIntensityRedOff 0x9338
+
+#define GlintLight9AmbientIntensityGreen 0xa340
+#define GlintLight9AmbientIntensityGreenTag 0x0468
+#define GlintLight9AmbientIntensityGreenReg 1
+#define GlintLight9AmbientIntensityGreenOff 0x9340
+
+#define GlintLight9AmbientIntensityBlue 0xa348
+#define GlintLight9AmbientIntensityBlueTag 0x0469
+#define GlintLight9AmbientIntensityBlueReg 1
+#define GlintLight9AmbientIntensityBlueOff 0x9348
+
+#define GlintLight9DiffuseIntensityRed 0xa350
+#define GlintLight9DiffuseIntensityRedTag 0x046a
+#define GlintLight9DiffuseIntensityRedReg 1
+#define GlintLight9DiffuseIntensityRedOff 0x9350
+
+#define GlintLight9DiffuseIntensityGreen 0xa358
+#define GlintLight9DiffuseIntensityGreenTag 0x046b
+#define GlintLight9DiffuseIntensityGreenReg 1
+#define GlintLight9DiffuseIntensityGreenOff 0x9358
+
+#define GlintLight9DiffuseIntensityBlue 0xa360
+#define GlintLight9DiffuseIntensityBlueTag 0x046c
+#define GlintLight9DiffuseIntensityBlueReg 1
+#define GlintLight9DiffuseIntensityBlueOff 0x9360
+
+#define GlintLight9SpecularIntensityRed 0xa368
+#define GlintLight9SpecularIntensityRedTag 0x046d
+#define GlintLight9SpecularIntensityRedReg 1
+#define GlintLight9SpecularIntensityRedOff 0x9368
+
+#define GlintLight9SpecularIntensityGreen 0xa370
+#define GlintLight9SpecularIntensityGreenTag 0x046e
+#define GlintLight9SpecularIntensityGreenReg 1
+#define GlintLight9SpecularIntensityGreenOff 0x9370
+
+#define GlintLight9SpecularIntensityBlue 0xa378
+#define GlintLight9SpecularIntensityBlueTag 0x046f
+#define GlintLight9SpecularIntensityBlueReg 1
+#define GlintLight9SpecularIntensityBlueOff 0x9378
+
+#define GlintLight9PositionX 0xa380
+#define GlintLight9PositionXTag 0x0470
+#define GlintLight9PositionXReg 1
+#define GlintLight9PositionXOff 0x9380
+
+#define GlintLight9PositionY 0xa388
+#define GlintLight9PositionYTag 0x0471
+#define GlintLight9PositionYReg 1
+#define GlintLight9PositionYOff 0x9388
+
+#define GlintLight9PositionZ 0xa390
+#define GlintLight9PositionZTag 0x0472
+#define GlintLight9PositionZReg 1
+#define GlintLight9PositionZOff 0x9390
+
+#define GlintLight9PositionW 0xa398
+#define GlintLight9PositionWTag 0x0473
+#define GlintLight9PositionWReg 1
+#define GlintLight9PositionWOff 0x9398
+
+#define GlintLight9SpotlightDirectionX 0xa3a0
+#define GlintLight9SpotlightDirectionXTag 0x0474
+#define GlintLight9SpotlightDirectionXReg 1
+#define GlintLight9SpotlightDirectionXOff 0x93a0
+
+#define GlintLight9SpotlightDirectionY 0xa3a8
+#define GlintLight9SpotlightDirectionYTag 0x0475
+#define GlintLight9SpotlightDirectionYReg 1
+#define GlintLight9SpotlightDirectionYOff 0x93a8
+
+#define GlintLight9SpotlightDirectionZ 0xa3b0
+#define GlintLight9SpotlightDirectionZTag 0x0476
+#define GlintLight9SpotlightDirectionZReg 1
+#define GlintLight9SpotlightDirectionZOff 0x93b0
+
+#define GlintLight9SpotlightExponent 0xa3b8
+#define GlintLight9SpotlightExponentTag 0x0477
+#define GlintLight9SpotlightExponentReg 1
+#define GlintLight9SpotlightExponentOff 0x93b8
+
+#define GlintLight9CosSpotlightCutoffAngle 0xa3c0
+#define GlintLight9CosSpotlightCutoffAngleTag 0x0478
+#define GlintLight9CosSpotlightCutoffAngleReg 1
+#define GlintLight9CosSpotlightCutoffAngleOff 0x93c0
+
+#define GlintLight9ConstantAttenuation 0xa3c8
+#define GlintLight9ConstantAttenuationTag 0x0479
+#define GlintLight9ConstantAttenuationReg 1
+#define GlintLight9ConstantAttenuationOff 0x93c8
+
+#define GlintLight9LinearAttenuation 0xa3d0
+#define GlintLight9LinearAttenuationTag 0x047a
+#define GlintLight9LinearAttenuationReg 1
+#define GlintLight9LinearAttenuationOff 0x93d0
+
+#define GlintLight9QuadraticAttenuation 0xa3d8
+#define GlintLight9QuadraticAttenuationTag 0x047b
+#define GlintLight9QuadraticAttenuationReg 1
+#define GlintLight9QuadraticAttenuationOff 0x93d8
+
+#define GlintLight10Mode 0xa3e0
+#define GlintLight10ModeTag 0x047c
+#define GlintLight10ModeReg 1
+#define GlintLight10ModeOff 0x93e0
+
+#define GlintLight10AmbientIntensityRed 0xa3e8
+#define GlintLight10AmbientIntensityRedTag 0x047d
+#define GlintLight10AmbientIntensityRedReg 1
+#define GlintLight10AmbientIntensityRedOff 0x93e8
+
+#define GlintLight10AmbientIntensityGreen 0xa3f0
+#define GlintLight10AmbientIntensityGreenTag 0x047e
+#define GlintLight10AmbientIntensityGreenReg 1
+#define GlintLight10AmbientIntensityGreenOff 0x93f0
+
+#define GlintLight10AmbientIntensityBlue 0xa3f8
+#define GlintLight10AmbientIntensityBlueTag 0x047f
+#define GlintLight10AmbientIntensityBlueReg 1
+#define GlintLight10AmbientIntensityBlueOff 0x93f8
+
+#define GlintLight10DiffuseIntensityRed 0xa400
+#define GlintLight10DiffuseIntensityRedTag 0x0480
+#define GlintLight10DiffuseIntensityRedReg 1
+#define GlintLight10DiffuseIntensityRedOff 0x9400
+
+#define GlintLight10DiffuseIntensityGreen 0xa408
+#define GlintLight10DiffuseIntensityGreenTag 0x0481
+#define GlintLight10DiffuseIntensityGreenReg 1
+#define GlintLight10DiffuseIntensityGreenOff 0x9408
+
+#define GlintLight10DiffuseIntensityBlue 0xa410
+#define GlintLight10DiffuseIntensityBlueTag 0x0482
+#define GlintLight10DiffuseIntensityBlueReg 1
+#define GlintLight10DiffuseIntensityBlueOff 0x9410
+
+#define GlintLight10SpecularIntensityRed 0xa418
+#define GlintLight10SpecularIntensityRedTag 0x0483
+#define GlintLight10SpecularIntensityRedReg 1
+#define GlintLight10SpecularIntensityRedOff 0x9418
+
+#define GlintLight10SpecularIntensityGreen 0xa420
+#define GlintLight10SpecularIntensityGreenTag 0x0484
+#define GlintLight10SpecularIntensityGreenReg 1
+#define GlintLight10SpecularIntensityGreenOff 0x9420
+
+#define GlintLight10SpecularIntensityBlue 0xa428
+#define GlintLight10SpecularIntensityBlueTag 0x0485
+#define GlintLight10SpecularIntensityBlueReg 1
+#define GlintLight10SpecularIntensityBlueOff 0x9428
+
+#define GlintLight10PositionX 0xa430
+#define GlintLight10PositionXTag 0x0486
+#define GlintLight10PositionXReg 1
+#define GlintLight10PositionXOff 0x9430
+
+#define GlintLight10PositionY 0xa438
+#define GlintLight10PositionYTag 0x0487
+#define GlintLight10PositionYReg 1
+#define GlintLight10PositionYOff 0x9438
+
+#define GlintLight10PositionZ 0xa440
+#define GlintLight10PositionZTag 0x0488
+#define GlintLight10PositionZReg 1
+#define GlintLight10PositionZOff 0x9440
+
+#define GlintLight10PositionW 0xa448
+#define GlintLight10PositionWTag 0x0489
+#define GlintLight10PositionWReg 1
+#define GlintLight10PositionWOff 0x9448
+
+#define GlintLight10SpotlightDirectionX 0xa450
+#define GlintLight10SpotlightDirectionXTag 0x048a
+#define GlintLight10SpotlightDirectionXReg 1
+#define GlintLight10SpotlightDirectionXOff 0x9450
+
+#define GlintLight10SpotlightDirectionY 0xa458
+#define GlintLight10SpotlightDirectionYTag 0x048b
+#define GlintLight10SpotlightDirectionYReg 1
+#define GlintLight10SpotlightDirectionYOff 0x9458
+
+#define GlintLight10SpotlightDirectionZ 0xa460
+#define GlintLight10SpotlightDirectionZTag 0x048c
+#define GlintLight10SpotlightDirectionZReg 1
+#define GlintLight10SpotlightDirectionZOff 0x9460
+
+#define GlintLight10SpotlightExponent 0xa468
+#define GlintLight10SpotlightExponentTag 0x048d
+#define GlintLight10SpotlightExponentReg 1
+#define GlintLight10SpotlightExponentOff 0x9468
+
+#define GlintLight10CosSpotlightCutoffAngle 0xa470
+#define GlintLight10CosSpotlightCutoffAngleTag 0x048e
+#define GlintLight10CosSpotlightCutoffAngleReg 1
+#define GlintLight10CosSpotlightCutoffAngleOff 0x9470
+
+#define GlintLight10ConstantAttenuation 0xa478
+#define GlintLight10ConstantAttenuationTag 0x048f
+#define GlintLight10ConstantAttenuationReg 1
+#define GlintLight10ConstantAttenuationOff 0x9478
+
+#define GlintLight10LinearAttenuation 0xa480
+#define GlintLight10LinearAttenuationTag 0x0490
+#define GlintLight10LinearAttenuationReg 1
+#define GlintLight10LinearAttenuationOff 0x9480
+
+#define GlintLight10QuadraticAttenuation 0xa488
+#define GlintLight10QuadraticAttenuationTag 0x0491
+#define GlintLight10QuadraticAttenuationReg 1
+#define GlintLight10QuadraticAttenuationOff 0x9488
+
+#define GlintLight11Mode 0xa490
+#define GlintLight11ModeTag 0x0492
+#define GlintLight11ModeReg 1
+#define GlintLight11ModeOff 0x9490
+
+#define GlintLight11AmbientIntensiveRed 0xa498
+#define GlintLight11AmbientIntensiveRedTag 0x0493
+#define GlintLight11AmbientIntensiveRedReg 1
+#define GlintLight11AmbientIntensiveRedOff 0x9498
+
+#define GlintLight11AmbientIntensityGreen 0xa4a0
+#define GlintLight11AmbientIntensityGreenTag 0x0494
+#define GlintLight11AmbientIntensityGreenReg 1
+#define GlintLight11AmbientIntensityGreenOff 0x94a0
+
+#define GlintLight11AmbientIntensityBlue 0xa4a8
+#define GlintLight11AmbientIntensityBlueTag 0x0495
+#define GlintLight11AmbientIntensityBlueReg 1
+#define GlintLight11AmbientIntensityBlueOff 0x94a8
+
+#define GlintLight11DiffuseIntensityRed 0xa4b0
+#define GlintLight11DiffuseIntensityRedTag 0x0496
+#define GlintLight11DiffuseIntensityRedReg 1
+#define GlintLight11DiffuseIntensityRedOff 0x94b0
+
+#define GlintLight11DiffuseIntensityGreen 0xa4b8
+#define GlintLight11DiffuseIntensityGreenTag 0x0497
+#define GlintLight11DiffuseIntensityGreenReg 1
+#define GlintLight11DiffuseIntensityGreenOff 0x94b8
+
+#define GlintLight11DiffuseIntensityBlue 0xa4c0
+#define GlintLight11DiffuseIntensityBlueTag 0x0498
+#define GlintLight11DiffuseIntensityBlueReg 1
+#define GlintLight11DiffuseIntensityBlueOff 0x94c0
+
+#define GlintLight11SpecularIntensityRed 0xa4c8
+#define GlintLight11SpecularIntensityRedTag 0x0499
+#define GlintLight11SpecularIntensityRedReg 1
+#define GlintLight11SpecularIntensityRedOff 0x94c8
+
+#define GlintLight11SpecularIntensityGreen 0xa4d0
+#define GlintLight11SpecularIntensityGreenTag 0x049a
+#define GlintLight11SpecularIntensityGreenReg 1
+#define GlintLight11SpecularIntensityGreenOff 0x94d0
+
+#define GlintLight11SpecularIntensityBlue 0xa4d8
+#define GlintLight11SpecularIntensityBlueTag 0x049b
+#define GlintLight11SpecularIntensityBlueReg 1
+#define GlintLight11SpecularIntensityBlueOff 0x94d8
+
+#define GlintLight11PositionX 0xa4e0
+#define GlintLight11PositionXTag 0x049c
+#define GlintLight11PositionXReg 1
+#define GlintLight11PositionXOff 0x94e0
+
+#define GlintLight11PositionY 0xa4e8
+#define GlintLight11PositionYTag 0x049d
+#define GlintLight11PositionYReg 1
+#define GlintLight11PositionYOff 0x94e8
+
+#define GlintLight11PositionZ 0xa4f0
+#define GlintLight11PositionZTag 0x049e
+#define GlintLight11PositionZReg 1
+#define GlintLight11PositionZOff 0x94f0
+
+#define GlintLight11PositionW 0xa4f8
+#define GlintLight11PositionWTag 0x049f
+#define GlintLight11PositionWReg 1
+#define GlintLight11PositionWOff 0x94f8
+
+#define GlintLight11SpotlightDirectionX 0xa500
+#define GlintLight11SpotlightDirectionXTag 0x04a0
+#define GlintLight11SpotlightDirectionXReg 1
+#define GlintLight11SpotlightDirectionXOff 0x9500
+
+#define GlintLight11SpotlightDirectionY 0xa508
+#define GlintLight11SpotlightDirectionYTag 0x04a1
+#define GlintLight11SpotlightDirectionYReg 1
+#define GlintLight11SpotlightDirectionYOff 0x9508
+
+#define GlintLight11SpotlightDirectionZ 0xa510
+#define GlintLight11SpotlightDirectionZTag 0x04a2
+#define GlintLight11SpotlightDirectionZReg 1
+#define GlintLight11SpotlightDirectionZOff 0x9510
+
+#define GlintLight11SpotlightExponent 0xa518
+#define GlintLight11SpotlightExponentTag 0x04a3
+#define GlintLight11SpotlightExponentReg 1
+#define GlintLight11SpotlightExponentOff 0x9518
+
+#define GlintLight11CosSpotlightCutoffAngle 0xa520
+#define GlintLight11CosSpotlightCutoffAngleTag 0x04a4
+#define GlintLight11CosSpotlightCutoffAngleReg 1
+#define GlintLight11CosSpotlightCutoffAngleOff 0x9520
+
+#define GlintLight11ConstantAttenuation 0xa528
+#define GlintLight11ConstantAttenuationTag 0x04a5
+#define GlintLight11ConstantAttenuationReg 1
+#define GlintLight11ConstantAttenuationOff 0x9528
+
+#define GlintLight11LinearAttenuation 0xa530
+#define GlintLight11LinearAttenuationTag 0x04a6
+#define GlintLight11LinearAttenuationReg 1
+#define GlintLight11LinearAttenuationOff 0x9530
+
+#define GlintLight11QuadraticAttenuation 0xa538
+#define GlintLight11QuadraticAttenuationTag 0x04a7
+#define GlintLight11QuadraticAttenuationReg 1
+#define GlintLight11QuadraticAttenuationOff 0x9538
+
+#define GlintLight12Mode 0xa540
+#define GlintLight12ModeTag 0x04a8
+#define GlintLight12ModeReg 1
+#define GlintLight12ModeOff 0x9540
+
+#define GlintLight12AmbientIntensityRed 0xa548
+#define GlintLight12AmbientIntensityRedTag 0x04a9
+#define GlintLight12AmbientIntensityRedReg 1
+#define GlintLight12AmbientIntensityRedOff 0x9548
+
+#define GlintLight12AmbientIntensityGreen 0xa550
+#define GlintLight12AmbientIntensityGreenTag 0x04aa
+#define GlintLight12AmbientIntensityGreenReg 1
+#define GlintLight12AmbientIntensityGreenOff 0x9550
+
+#define GlintLight12AmbientIntensityBlue 0xa558
+#define GlintLight12AmbientIntensityBlueTag 0x04ab
+#define GlintLight12AmbientIntensityBlueReg 1
+#define GlintLight12AmbientIntensityBlueOff 0x9558
+
+#define GlintLight12DiffuseIntensityRed 0xa560
+#define GlintLight12DiffuseIntensityRedTag 0x04ac
+#define GlintLight12DiffuseIntensityRedReg 1
+#define GlintLight12DiffuseIntensityRedOff 0x9560
+
+#define GlintLight12DiffuseIntensityGreen 0xa568
+#define GlintLight12DiffuseIntensityGreenTag 0x04ad
+#define GlintLight12DiffuseIntensityGreenReg 1
+#define GlintLight12DiffuseIntensityGreenOff 0x9568
+
+#define GlintLight12DiffuseIntensityBlue 0xa570
+#define GlintLight12DiffuseIntensityBlueTag 0x04ae
+#define GlintLight12DiffuseIntensityBlueReg 1
+#define GlintLight12DiffuseIntensityBlueOff 0x9570
+
+#define GlintLight12SpecularIntensityRed 0xa578
+#define GlintLight12SpecularIntensityRedTag 0x04af
+#define GlintLight12SpecularIntensityRedReg 1
+#define GlintLight12SpecularIntensityRedOff 0x9578
+
+#define GlintLight12SpecularIntensityGreen 0xa580
+#define GlintLight12SpecularIntensityGreenTag 0x04b0
+#define GlintLight12SpecularIntensityGreenReg 1
+#define GlintLight12SpecularIntensityGreenOff 0x9580
+
+#define GlintLight12SpecularIntensityBlue 0xa588
+#define GlintLight12SpecularIntensityBlueTag 0x04b1
+#define GlintLight12SpecularIntensityBlueReg 1
+#define GlintLight12SpecularIntensityBlueOff 0x9588
+
+#define GlintLight12PositionX 0xa590
+#define GlintLight12PositionXTag 0x04b2
+#define GlintLight12PositionXReg 1
+#define GlintLight12PositionXOff 0x9590
+
+#define GlintLight12PositionY 0xa598
+#define GlintLight12PositionYTag 0x04b3
+#define GlintLight12PositionYReg 1
+#define GlintLight12PositionYOff 0x9598
+
+#define GlintLight12PositionZ 0xa5a0
+#define GlintLight12PositionZTag 0x04b4
+#define GlintLight12PositionZReg 1
+#define GlintLight12PositionZOff 0x95a0
+
+#define GlintLight12PositionW 0xa5a8
+#define GlintLight12PositionWTag 0x04b5
+#define GlintLight12PositionWReg 1
+#define GlintLight12PositionWOff 0x95a8
+
+#define GlintLight12SpotlightDirectionX 0xa5b0
+#define GlintLight12SpotlightDirectionXTag 0x04b6
+#define GlintLight12SpotlightDirectionXReg 1
+#define GlintLight12SpotlightDirectionXOff 0x95b0
+
+#define GlintLight12SpotlightDirectionY 0xa5b8
+#define GlintLight12SpotlightDirectionYTag 0x04b7
+#define GlintLight12SpotlightDirectionYReg 1
+#define GlintLight12SpotlightDirectionYOff 0x95b8
+
+#define GlintLight12SpotlightDirectionZ 0xa5c0
+#define GlintLight12SpotlightDirectionZTag 0x04b8
+#define GlintLight12SpotlightDirectionZReg 1
+#define GlintLight12SpotlightDirectionZOff 0x95c0
+
+#define GlintLight12SpotlightExponent 0xa5c8
+#define GlintLight12SpotlightExponentTag 0x04b9
+#define GlintLight12SpotlightExponentReg 1
+#define GlintLight12SpotlightExponentOff 0x95c8
+
+#define GlintLight12CosSpotlightCutoffAngle 0xa5d0
+#define GlintLight12CosSpotlightCutoffAngleTag 0x04ba
+#define GlintLight12CosSpotlightCutoffAngleReg 1
+#define GlintLight12CosSpotlightCutoffAngleOff 0x95d0
+
+#define GlintLight12ConstantAttenuation 0xa5d8
+#define GlintLight12ConstantAttenuationTag 0x04bb
+#define GlintLight12ConstantAttenuationReg 1
+#define GlintLight12ConstantAttenuationOff 0x95d8
+
+#define GlintLight12LinearAttenuation 0xa5e0
+#define GlintLight12LinearAttenuationTag 0x04bc
+#define GlintLight12LinearAttenuationReg 1
+#define GlintLight12LinearAttenuationOff 0x95e0
+
+#define GlintLight12QuadraticAttenuation 0xa5e8
+#define GlintLight12QuadraticAttenuationTag 0x04bd
+#define GlintLight12QuadraticAttenuationReg 1
+#define GlintLight12QuadraticAttenuationOff 0x95e8
+
+#define GlintLight13Mode 0xa5f0
+#define GlintLight13ModeTag 0x04be
+#define GlintLight13ModeReg 1
+#define GlintLight13ModeOff 0x95f0
+
+#define GlintLight13AmbientIntensityRed 0xa5f8
+#define GlintLight13AmbientIntensityRedTag 0x04bf
+#define GlintLight13AmbientIntensityRedReg 1
+#define GlintLight13AmbientIntensityRedOff 0x95f8
+
+#define GlintLight13AmbientIntensityGreen 0xa600
+#define GlintLight13AmbientIntensityGreenTag 0x04c0
+#define GlintLight13AmbientIntensityGreenReg 1
+#define GlintLight13AmbientIntensityGreenOff 0x9600
+
+#define GlintLight13AmbientIntensityBlue 0xa608
+#define GlintLight13AmbientIntensityBlueTag 0x04c1
+#define GlintLight13AmbientIntensityBlueReg 1
+#define GlintLight13AmbientIntensityBlueOff 0x9608
+
+#define GlintLight13DiffuseIntensityRed 0xa610
+#define GlintLight13DiffuseIntensityRedTag 0x04c2
+#define GlintLight13DiffuseIntensityRedReg 1
+#define GlintLight13DiffuseIntensityRedOff 0x9610
+
+#define GlintLight13DiffuseIntensityGreen 0xa618
+#define GlintLight13DiffuseIntensityGreenTag 0x04c3
+#define GlintLight13DiffuseIntensityGreenReg 1
+#define GlintLight13DiffuseIntensityGreenOff 0x9618
+
+#define GlintLight13DiffuseIntensityBlue 0xa620
+#define GlintLight13DiffuseIntensityBlueTag 0x04c4
+#define GlintLight13DiffuseIntensityBlueReg 1
+#define GlintLight13DiffuseIntensityBlueOff 0x9620
+
+#define GlintLight13SpecularIntensityRed 0xa628
+#define GlintLight13SpecularIntensityRedTag 0x04c5
+#define GlintLight13SpecularIntensityRedReg 1
+#define GlintLight13SpecularIntensityRedOff 0x9628
+
+#define GlintLight13SpecularIntensityGreen 0xa630
+#define GlintLight13SpecularIntensityGreenTag 0x04c6
+#define GlintLight13SpecularIntensityGreenReg 1
+#define GlintLight13SpecularIntensityGreenOff 0x9630
+
+#define GlintLight13SpecularIntensityBlue 0xa638
+#define GlintLight13SpecularIntensityBlueTag 0x04c7
+#define GlintLight13SpecularIntensityBlueReg 1
+#define GlintLight13SpecularIntensityBlueOff 0x9638
+
+#define GlintLight13PositionX 0xa640
+#define GlintLight13PositionXTag 0x04c8
+#define GlintLight13PositionXReg 1
+#define GlintLight13PositionXOff 0x9640
+
+#define GlintLight13PositionY 0xa648
+#define GlintLight13PositionYTag 0x04c9
+#define GlintLight13PositionYReg 1
+#define GlintLight13PositionYOff 0x9648
+
+#define GlintLight13PositionZ 0xa650
+#define GlintLight13PositionZTag 0x04ca
+#define GlintLight13PositionZReg 1
+#define GlintLight13PositionZOff 0x9650
+
+#define GlintLight13PositionW 0xa658
+#define GlintLight13PositionWTag 0x04cb
+#define GlintLight13PositionWReg 1
+#define GlintLight13PositionWOff 0x9658
+
+#define GlintLight13SpotlightDirectionX 0xa660
+#define GlintLight13SpotlightDirectionXTag 0x04cc
+#define GlintLight13SpotlightDirectionXReg 1
+#define GlintLight13SpotlightDirectionXOff 0x9660
+
+#define GlintLight13SpotlightDirectionY 0xa668
+#define GlintLight13SpotlightDirectionYTag 0x04cd
+#define GlintLight13SpotlightDirectionYReg 1
+#define GlintLight13SpotlightDirectionYOff 0x9668
+
+#define GlintLight13SpotlightDirectionZ 0xa670
+#define GlintLight13SpotlightDirectionZTag 0x04ce
+#define GlintLight13SpotlightDirectionZReg 1
+#define GlintLight13SpotlightDirectionZOff 0x9670
+
+#define GlintLight13SpotlightExponent 0xa678
+#define GlintLight13SpotlightExponentTag 0x04cf
+#define GlintLight13SpotlightExponentReg 1
+#define GlintLight13SpotlightExponentOff 0x9678
+
+#define GlintLight13CosSpotlightCutoffAngle 0xa680
+#define GlintLight13CosSpotlightCutoffAngleTag 0x04d0
+#define GlintLight13CosSpotlightCutoffAngleReg 1
+#define GlintLight13CosSpotlightCutoffAngleOff 0x9680
+
+#define GlintLight13ConstantAttenuation 0xa688
+#define GlintLight13ConstantAttenuationTag 0x04d1
+#define GlintLight13ConstantAttenuationReg 1
+#define GlintLight13ConstantAttenuationOff 0x9688
+
+#define GlintLight13LinearAttenuation 0xa690
+#define GlintLight13LinearAttenuationTag 0x04d2
+#define GlintLight13LinearAttenuationReg 1
+#define GlintLight13LinearAttenuationOff 0x9690
+
+#define GlintLight13QuadraticAttenuation 0xa698
+#define GlintLight13QuadraticAttenuationTag 0x04d3
+#define GlintLight13QuadraticAttenuationReg 1
+#define GlintLight13QuadraticAttenuationOff 0x9698
+
+#define GlintLight14Mode 0xa6a0
+#define GlintLight14ModeTag 0x04d4
+#define GlintLight14ModeReg 1
+#define GlintLight14ModeOff 0x96a0
+
+#define GlintLight14AmbientIntensityRed 0xa6a8
+#define GlintLight14AmbientIntensityRedTag 0x04d5
+#define GlintLight14AmbientIntensityRedReg 1
+#define GlintLight14AmbientIntensityRedOff 0x96a8
+
+#define GlintLight14AmbientIntensityGreen 0xa6b0
+#define GlintLight14AmbientIntensityGreenTag 0x04d6
+#define GlintLight14AmbientIntensityGreenReg 1
+#define GlintLight14AmbientIntensityGreenOff 0x96b0
+
+#define GlintLight14AmbientIntensityBlue 0xa6b8
+#define GlintLight14AmbientIntensityBlueTag 0x04d7
+#define GlintLight14AmbientIntensityBlueReg 1
+#define GlintLight14AmbientIntensityBlueOff 0x96b8
+
+#define GlintLight14DiffuseIntensityRed 0xa6c0
+#define GlintLight14DiffuseIntensityRedTag 0x04d8
+#define GlintLight14DiffuseIntensityRedReg 1
+#define GlintLight14DiffuseIntensityRedOff 0x96c0
+
+#define GlintLight14DiffuseIntensityGreen 0xa6c8
+#define GlintLight14DiffuseIntensityGreenTag 0x04d9
+#define GlintLight14DiffuseIntensityGreenReg 1
+#define GlintLight14DiffuseIntensityGreenOff 0x96c8
+
+#define GlintLight14DiffuseIntensityBlue 0xa6d0
+#define GlintLight14DiffuseIntensityBlueTag 0x04da
+#define GlintLight14DiffuseIntensityBlueReg 1
+#define GlintLight14DiffuseIntensityBlueOff 0x96d0
+
+#define GlintLight14SpecularIntensityRed 0xa6d8
+#define GlintLight14SpecularIntensityRedTag 0x04db
+#define GlintLight14SpecularIntensityRedReg 1
+#define GlintLight14SpecularIntensityRedOff 0x96d8
+
+#define GlintLight14SpecularIntensityGreen 0xa6e0
+#define GlintLight14SpecularIntensityGreenTag 0x04dc
+#define GlintLight14SpecularIntensityGreenReg 1
+#define GlintLight14SpecularIntensityGreenOff 0x96e0
+
+#define GlintLight14SpecularIntensityBlue 0xa6e8
+#define GlintLight14SpecularIntensityBlueTag 0x04dd
+#define GlintLight14SpecularIntensityBlueReg 1
+#define GlintLight14SpecularIntensityBlueOff 0x96e8
+
+#define GlintLight14PositionX 0xa6f0
+#define GlintLight14PositionXTag 0x04de
+#define GlintLight14PositionXReg 1
+#define GlintLight14PositionXOff 0x96f0
+
+#define GlintLight14PositionY 0xa6f8
+#define GlintLight14PositionYTag 0x04df
+#define GlintLight14PositionYReg 1
+#define GlintLight14PositionYOff 0x96f8
+
+#define GlintLight14PositionZ 0xa700
+#define GlintLight14PositionZTag 0x04e0
+#define GlintLight14PositionZReg 1
+#define GlintLight14PositionZOff 0x9700
+
+#define GlintLight14PositionW 0xa708
+#define GlintLight14PositionWTag 0x04e1
+#define GlintLight14PositionWReg 1
+#define GlintLight14PositionWOff 0x9708
+
+#define GlintLight14SpotlightDirectionX 0xa710
+#define GlintLight14SpotlightDirectionXTag 0x04e2
+#define GlintLight14SpotlightDirectionXReg 1
+#define GlintLight14SpotlightDirectionXOff 0x9710
+
+#define GlintLight14SpotlightDirectionY 0xa718
+#define GlintLight14SpotlightDirectionYTag 0x04e3
+#define GlintLight14SpotlightDirectionYReg 1
+#define GlintLight14SpotlightDirectionYOff 0x9718
+
+#define GlintLight14SpotlightDirectionZ 0xa720
+#define GlintLight14SpotlightDirectionZTag 0x04e4
+#define GlintLight14SpotlightDirectionZReg 1
+#define GlintLight14SpotlightDirectionZOff 0x9720
+
+#define GlintLight14SpotlightExponent 0xa728
+#define GlintLight14SpotlightExponentTag 0x04e5
+#define GlintLight14SpotlightExponentReg 1
+#define GlintLight14SpotlightExponentOff 0x9728
+
+#define GlintLight14CosSpotlightCutoffAngle 0xa730
+#define GlintLight14CosSpotlightCutoffAngleTag 0x04e6
+#define GlintLight14CosSpotlightCutoffAngleReg 1
+#define GlintLight14CosSpotlightCutoffAngleOff 0x9730
+
+#define GlintLight14ConstantAttenuation 0xa738
+#define GlintLight14ConstantAttenuationTag 0x04e7
+#define GlintLight14ConstantAttenuationReg 1
+#define GlintLight14ConstantAttenuationOff 0x9738
+
+#define GlintLight14LinearAttenuation 0xa740
+#define GlintLight14LinearAttenuationTag 0x04e8
+#define GlintLight14LinearAttenuationReg 1
+#define GlintLight14LinearAttenuationOff 0x9740
+
+#define GlintLight14QuadraticAttenuation 0xa748
+#define GlintLight14QuadraticAttenuationTag 0x04e9
+#define GlintLight14QuadraticAttenuationReg 1
+#define GlintLight14QuadraticAttenuationOff 0x9748
+
+#define GlintLight15Mode 0xa750
+#define GlintLight15ModeTag 0x04ea
+#define GlintLight15ModeReg 1
+#define GlintLight15ModeOff 0x9750
+
+#define GlintLight15AmbientIntensityRed 0xa758
+#define GlintLight15AmbientIntensityRedTag 0x04eb
+#define GlintLight15AmbientIntensityRedReg 1
+#define GlintLight15AmbientIntensityRedOff 0x9758
+
+#define GlintLight15AmbientIntensityGreen 0xa760
+#define GlintLight15AmbientIntensityGreenTag 0x04ec
+#define GlintLight15AmbientIntensityGreenReg 1
+#define GlintLight15AmbientIntensityGreenOff 0x9760
+
+#define GlintLight15AmbientIntensityBlue 0xa768
+#define GlintLight15AmbientIntensityBlueTag 0x04ed
+#define GlintLight15AmbientIntensityBlueReg 1
+#define GlintLight15AmbientIntensityBlueOff 0x9768
+
+#define GlintLight15DiffuseIntensityRed 0xa770
+#define GlintLight15DiffuseIntensityRedTag 0x04ee
+#define GlintLight15DiffuseIntensityRedReg 1
+#define GlintLight15DiffuseIntensityRedOff 0x9770
+
+#define GlintLight15DiffuseIntensityGreen 0xa778
+#define GlintLight15DiffuseIntensityGreenTag 0x04ef
+#define GlintLight15DiffuseIntensityGreenReg 1
+#define GlintLight15DiffuseIntensityGreenOff 0x9778
+
+#define GlintLight15DiffuseIntensityBlue 0xa780
+#define GlintLight15DiffuseIntensityBlueTag 0x04f0
+#define GlintLight15DiffuseIntensityBlueReg 1
+#define GlintLight15DiffuseIntensityBlueOff 0x9780
+
+#define GlintLight15SpecularIntensityRed 0xa788
+#define GlintLight15SpecularIntensityRedTag 0x04f1
+#define GlintLight15SpecularIntensityRedReg 1
+#define GlintLight15SpecularIntensityRedOff 0x9788
+
+#define GlintLight15SpecularIntensityGreen 0xa790
+#define GlintLight15SpecularIntensityGreenTag 0x04f2
+#define GlintLight15SpecularIntensityGreenReg 1
+#define GlintLight15SpecularIntensityGreenOff 0x9790
+
+#define GlintLight15SpecularIntensityBlue 0xa798
+#define GlintLight15SpecularIntensityBlueTag 0x04f3
+#define GlintLight15SpecularIntensityBlueReg 1
+#define GlintLight15SpecularIntensityBlueOff 0x9798
+
+#define GlintLight15PositionX 0xa7a0
+#define GlintLight15PositionXTag 0x04f4
+#define GlintLight15PositionXReg 1
+#define GlintLight15PositionXOff 0x97a0
+
+#define GlintLight15PositionY 0xa7a8
+#define GlintLight15PositionYTag 0x04f5
+#define GlintLight15PositionYReg 1
+#define GlintLight15PositionYOff 0x97a8
+
+#define GlintLight15PositionZ 0xa7b0
+#define GlintLight15PositionZTag 0x04f6
+#define GlintLight15PositionZReg 1
+#define GlintLight15PositionZOff 0x97b0
+
+#define GlintLight15PositionW 0xa7b8
+#define GlintLight15PositionWTag 0x04f7
+#define GlintLight15PositionWReg 1
+#define GlintLight15PositionWOff 0x97b8
+
+#define GlintLight15SpotlightDirectionX 0xa7c0
+#define GlintLight15SpotlightDirectionXTag 0x04f8
+#define GlintLight15SpotlightDirectionXReg 1
+#define GlintLight15SpotlightDirectionXOff 0x97c0
+
+#define GlintLight15SpotlightDirectionY 0xa7c8
+#define GlintLight15SpotlightDirectionYTag 0x04f9
+#define GlintLight15SpotlightDirectionYReg 1
+#define GlintLight15SpotlightDirectionYOff 0x97c8
+
+#define GlintLight15SpotlightDirectionZ 0xa7d0
+#define GlintLight15SpotlightDirectionZTag 0x04fa
+#define GlintLight15SpotlightDirectionZReg 1
+#define GlintLight15SpotlightDirectionZOff 0x97d0
+
+#define GlintLight15SpotlightExponent 0xa7d8
+#define GlintLight15SpotlightExponentTag 0x04fb
+#define GlintLight15SpotlightExponentReg 1
+#define GlintLight15SpotlightExponentOff 0x97d8
+
+#define GlintLight15CosSpotlightCutoffAngle 0xa7e0
+#define GlintLight15CosSpotlightCutoffAngleTag 0x04fc
+#define GlintLight15CosSpotlightCutoffAngleReg 1
+#define GlintLight15CosSpotlightCutoffAngleOff 0x97e0
+
+#define GlintLight15ConstantAttenuation 0xa7e8
+#define GlintLight15ConstantAttenuationTag 0x04fd
+#define GlintLight15ConstantAttenuationReg 1
+#define GlintLight15ConstantAttenuationOff 0x97e8
+
+#define GlintLight15LinearAttenuation 0xa7f0
+#define GlintLight15LinearAttenuationTag 0x04fe
+#define GlintLight15LinearAttenuationReg 1
+#define GlintLight15LinearAttenuationOff 0x97f0
+
+#define GlintLight15QuadraticAttenuation 0xa7f8
+#define GlintLight15QuadraticAttenuationTag 0x04ff
+#define GlintLight15QuadraticAttenuationReg 1
+#define GlintLight15QuadraticAttenuationOff 0x97f8
+
+#define GlintSceneAmbientColorRed 0xa800
+#define GlintSceneAmbientColorRedTag 0x0500
+#define GlintSceneAmbientColorRedReg 1
+#define GlintSceneAmbientColorRedOff 0x9800
+
+#define GlintSceneAmbientColorGreen 0xa808
+#define GlintSceneAmbientColorGreenTag 0x0501
+#define GlintSceneAmbientColorGreenReg 1
+#define GlintSceneAmbientColorGreenOff 0x9808
+
+#define GlintSceneAmbientColorBlue 0xa810
+#define GlintSceneAmbientColorBlueTag 0x0502
+#define GlintSceneAmbientColorBlueReg 1
+#define GlintSceneAmbientColorBlueOff 0x9810
+
+#define GlintFrontAmbientColorRed 0xa880
+#define GlintFrontAmbientColorRedTag 0x0510
+#define GlintFrontAmbientColorRedReg 1
+#define GlintFrontAmbientColorRedOff 0x9880
+
+#define GlintFrontAmbientColorGreen 0xa888
+#define GlintFrontAmbientColorGreenTag 0x0511
+#define GlintFrontAmbientColorGreenReg 1
+#define GlintFrontAmbientColorGreenOff 0x9888
+
+#define GlintFrontAmbientColorBlue 0xa890
+#define GlintFrontAmbientColorBlueTag 0x0512
+#define GlintFrontAmbientColorBlueReg 1
+#define GlintFrontAmbientColorBlueOff 0x9890
+
+#define GlintFrontDiffuseColorRed 0xa898
+#define GlintFrontDiffuseColorRedTag 0x0513
+#define GlintFrontDiffuseColorRedReg 1
+#define GlintFrontDiffuseColorRedOff 0x9898
+
+#define GlintFrontDiffuseColorGreen 0xa8a0
+#define GlintFrontDiffuseColorGreenTag 0x0514
+#define GlintFrontDiffuseColorGreenReg 1
+#define GlintFrontDiffuseColorGreenOff 0x98a0
+
+#define GlintFrontDiffuseColorBlue 0xa8a8
+#define GlintFrontDiffuseColorBlueTag 0x0515
+#define GlintFrontDiffuseColorBlueReg 1
+#define GlintFrontDiffuseColorBlueOff 0x98a8
+
+#define GlintFrontAlpha 0xa8b0
+#define GlintFrontAlphaTag 0x0516
+#define GlintFrontAlphaReg 1
+#define GlintFrontAlphaOff 0x98b0
+
+#define GlintFrontSpecularColorRed 0xa8b8
+#define GlintFrontSpecularColorRedTag 0x0517
+#define GlintFrontSpecularColorRedReg 1
+#define GlintFrontSpecularColorRedOff 0x98b8
+
+#define GlintFrontSpecularColorGreen 0xa8c0
+#define GlintFrontSpecularColorGreenTag 0x0518
+#define GlintFrontSpecularColorGreenReg 1
+#define GlintFrontSpecularColorGreenOff 0x98c0
+
+#define GlintFrontSpecularColorBlue 0xa8c8
+#define GlintFrontSpecularColorBlueTag 0x0519
+#define GlintFrontSpecularColorBlueReg 1
+#define GlintFrontSpecularColorBlueOff 0x98c8
+
+#define GlintFrontEmissiveColorRed 0xa8d0
+#define GlintFrontEmissiveColorRedTag 0x051a
+#define GlintFrontEmissiveColorRedReg 1
+#define GlintFrontEmissiveColorRedOff 0x98d0
+
+#define GlintFrontEmissiveColorGreen 0xa8d8
+#define GlintFrontEmissiveColorGreenTag 0x051b
+#define GlintFrontEmissiveColorGreenReg 1
+#define GlintFrontEmissiveColorGreenOff 0x98d8
+
+#define GlintFrontEmissiveColorBlue 0xa8e0
+#define GlintFrontEmissiveColorBlueTag 0x051c
+#define GlintFrontEmissiveColorBlueReg 1
+#define GlintFrontEmissiveColorBlueOff 0x98e0
+
+#define GlintFrontSpecularExponent 0xa8e8
+#define GlintFrontSpecularExponentTag 0x051d
+#define GlintFrontSpecularExponentReg 1
+#define GlintFrontSpecularExponentOff 0x98e8
+
+#define GlintBackAmbientColorRed 0xa900
+#define GlintBackAmbientColorRedTag 0x0520
+#define GlintBackAmbientColorRedReg 1
+#define GlintBackAmbientColorRedOff 0x9900
+
+#define GlintBackAmbientColorGreen 0xa908
+#define GlintBackAmbientColorGreenTag 0x0521
+#define GlintBackAmbientColorGreenReg 1
+#define GlintBackAmbientColorGreenOff 0x9908
+
+#define GlintBackAmbientColorBlue 0xa910
+#define GlintBackAmbientColorBlueTag 0x0522
+#define GlintBackAmbientColorBlueReg 1
+#define GlintBackAmbientColorBlueOff 0x9910
+
+#define GlintBackDiffuseColorRed 0xa918
+#define GlintBackDiffuseColorRedTag 0x0523
+#define GlintBackDiffuseColorRedReg 1
+#define GlintBackDiffuseColorRedOff 0x9918
+
+#define GlintBackDiffuseColorGreen 0xa920
+#define GlintBackDiffuseColorGreenTag 0x0524
+#define GlintBackDiffuseColorGreenReg 1
+#define GlintBackDiffuseColorGreenOff 0x9920
+
+#define GlintBackDiffuseColorBlue 0xa928
+#define GlintBackDiffuseColorBlueTag 0x0525
+#define GlintBackDiffuseColorBlueReg 1
+#define GlintBackDiffuseColorBlueOff 0x9928
+
+#define GlintBackAlpha 0xa930
+#define GlintBackAlphaTag 0x0526
+#define GlintBackAlphaReg 1
+#define GlintBackAlphaOff 0x9930
+
+#define GlintBackSpecularColorRed 0xa938
+#define GlintBackSpecularColorRedTag 0x0527
+#define GlintBackSpecularColorRedReg 1
+#define GlintBackSpecularColorRedOff 0x9938
+
+#define GlintBackSpecularColorGreen 0xa940
+#define GlintBackSpecularColorGreenTag 0x0528
+#define GlintBackSpecularColorGreenReg 1
+#define GlintBackSpecularColorGreenOff 0x9940
+
+#define GlintBackSpecularColorBlue 0xa948
+#define GlintBackSpecularColorBlueTag 0x0529
+#define GlintBackSpecularColorBlueReg 1
+#define GlintBackSpecularColorBlueOff 0x9948
+
+#define GlintBackEmissiveColorRed 0xa950
+#define GlintBackEmissiveColorRedTag 0x052a
+#define GlintBackEmissiveColorRedReg 1
+#define GlintBackEmissiveColorRedOff 0x9950
+
+#define GlintBackEmissiveColorGreen 0xa958
+#define GlintBackEmissiveColorGreenTag 0x052b
+#define GlintBackEmissiveColorGreenReg 1
+#define GlintBackEmissiveColorGreenOff 0x9958
+
+#define GlintBackEmissiveColorBlue 0xa960
+#define GlintBackEmissiveColorBlueTag 0x052c
+#define GlintBackEmissiveColorBlueReg 1
+#define GlintBackEmissiveColorBlueOff 0x9960
+
+#define GlintBackSpecularExponent 0xa968
+#define GlintBackSpecularExponentTag 0x052d
+#define GlintBackSpecularExponentReg 1
+#define GlintBackSpecularExponentOff 0x9968
+
+#define GlintDMAAddr 0xa980
+#define GlintDMAAddrTag 0x0530
+#define GlintDMAAddrReg 1
+#define GlintDMAAddrOff 0x9980
+
+#define GlintGammaDMACount 0xa988
+#define GlintGammaDMACountTag 0x0531
+#define GlintGammaDMACountReg 1
+#define GlintGammaDMACountOff 0x9988
+
+#define GlintCommandInterrupt 0xa990
+#define GlintCommandInterruptTag 0x0532
+#define GlintCommandInterruptReg 1
+#define GlintCommandInterruptOff 0x9990
+
+#define GlintDMACall 0xa998
+#define GlintDMACallTag 0x0533
+#define GlintDMACallReg 1
+#define GlintDMACallOff 0x9998
+
+#define GlintDMAReturn 0xa9a0
+#define GlintDMAReturnTag 0x0534
+#define GlintDMAReturnReg 1
+#define GlintDMAReturnOff 0x99a0
+
+#define GlintDMARectangularRead 0xa9a8
+#define GlintDMARectangularReadTag 0x0535
+#define GlintDMARectangularReadReg 1
+#define GlintDMARectangularReadOff 0x99a8
+
+#define GlintDMARectangleReadAddress 0xa9b0
+#define GlintDMARectangleReadAddressTag 0x0536
+#define GlintDMARectangleReadAddressReg 1
+#define GlintDMARectangleReadAddressOff 0x99b0
+
+#define GlintDMARectangleReadLinePitch 0xa9b8
+#define GlintDMARectangleReadLinePitchTag 0x0537
+#define GlintDMARectangleReadLinePitchReg 1
+#define GlintDMARectangleReadLinePitchOff 0x99b8
+
+#define GlintDMARectangleReadTarget 0xa9c0
+#define GlintDMARectangleReadTargetTag 0x0538
+#define GlintDMARectangleReadTargetReg 1
+#define GlintDMARectangleReadTargetOff 0x99c0
+
+#define GlintDMARectangleWrite 0xa9c8
+#define GlintDMARectangleWriteTag 0x0539
+#define GlintDMARectangleWriteReg 1
+#define GlintDMARectangleWriteOff 0x99c8
+
+#define GlintDMARectangleWriteAddress 0xa9d0
+#define GlintDMARectangleWriteAddressTag 0x053a
+#define GlintDMARectangleWriteAddressReg 1
+#define GlintDMARectangleWriteAddressOff 0x99d0
+
+#define GlintDMARectangleWriteLinePitch 0xa9d8
+#define GlintDMARectangleWriteLinePitchTag 0x053b
+#define GlintDMARectangleWriteLinePitchReg 1
+#define GlintDMARectangleWriteLinePitchOff 0x99d8
+
+#define GlintDMAOutputAddress 0xa9e0
+#define GlintDMAOutputAddressTag 0x053c
+#define GlintDMAOutputAddressReg 1
+#define GlintDMAOutputAddressOff 0x99e0
+
+#define GlintDMAOutputCount 0xa9e8
+#define GlintDMAOutputCountTag 0x053d
+#define GlintDMAOutputCountReg 1
+#define GlintDMAOutputCountOff 0x99e8
+
+#define GlintDMAReadGLINTSource 0xa9f0
+#define GlintDMAReadGLINTSourceTag 0x053e
+#define GlintDMAReadGLINTSourceReg 1
+#define GlintDMAReadGLINTSourceOff 0x99f0
+
+#define GlintDMAFeedback 0xaa10
+#define GlintDMAFeedbackTag 0x0542
+#define GlintDMAFeedbackReg 1
+#define GlintDMAFeedbackOff 0x9a10
+
+#define GlintTransformModeAnd 0xaa80
+#define GlintTransformModeAndTag 0x0550
+#define GlintTransformModeAndReg 1
+#define GlintTransformModeAndOff 0x9a80
+
+#define GlintTransformModeOr 0xaa88
+#define GlintTransformModeOrTag 0x0551
+#define GlintTransformModeOrReg 1
+#define GlintTransformModeOrOff 0x9a88
+
+#define GlintGeometryModeAnd 0xaa90
+#define GlintGeometryModeAndTag 0x0552
+#define GlintGeometryModeAndReg 1
+#define GlintGeometryModeAndOff 0x9a90
+
+#define GlintGeometryModeOr 0xaa98
+#define GlintGeometryModeOrTag 0x0553
+#define GlintGeometryModeOrReg 1
+#define GlintGeometryModeOrOff 0x9a98
+
+#define GlintNormalizeModeAnd 0xaaa0
+#define GlintNormalizeModeAndTag 0x0554
+#define GlintNormalizeModeAndReg 1
+#define GlintNormalizeModeAndOff 0x9aa0
+
+#define GlintNormalizeModeOr 0xaaa8
+#define GlintNormalizeModeOrTag 0x0555
+#define GlintNormalizeModeOrReg 1
+#define GlintNormalizeModeOrOff 0x9aa8
+
+#define GlintLightingModeAnd 0xaab0
+#define GlintLightingModeAndTag 0x0556
+#define GlintLightingModeAndReg 1
+#define GlintLightingModeAndOff 0x9ab0
+
+#define GlintLightingModeOr 0xaab8
+#define GlintLightingModeOrTag 0x0557
+#define GlintLightingModeOrReg 1
+#define GlintLightingModeOrOff 0x9ab8
+
+#define GlintColorMaterialModeAnd 0xaac0
+#define GlintColorMaterialModeAndTag 0x0558
+#define GlintColorMaterialModeAndReg 1
+#define GlintColorMaterialModeAndOff 0x9ac0
+
+#define GlintColorMaterialModeOr 0xaac8
+#define GlintColorMaterialModeOrTag 0x0559
+#define GlintColorMaterialModeOrReg 1
+#define GlintColorMaterialModeOrOff 0x9ac8
+
+#define GlintDeltaModeAnd 0xaad0
+#define GlintDeltaModeAndTag 0x055a
+#define GlintDeltaModeAndReg 1
+#define GlintDeltaModeAndOff 0x9ad0
+
+#define GlintDeltaModeOr 0xaad8
+#define GlintDeltaModeOrTag 0x055b
+#define GlintDeltaModeOrReg 1
+#define GlintDeltaModeOrOff 0x9ad8
+
+#define GlintPointModeAnd 0xaae0
+#define GlintPointModeAndTag 0x055c
+#define GlintPointModeAndReg 1
+#define GlintPointModeAndOff 0x9ae0
+
+#define GlintPointModeOr 0xaae8
+#define GlintPointModeOrTag 0x055d
+#define GlintPointModeOrReg 1
+#define GlintPointModeOrOff 0x9ae8
+
+#define GlintLineModeAnd 0xaaf0
+#define GlintLineModeAndTag 0x055e
+#define GlintLineModeAndReg 1
+#define GlintLineModeAndOff 0x9af0
+
+#define GlintLineModeOr 0xaaf8
+#define GlintLineModeOrTag 0x055f
+#define GlintLineModeOrReg 1
+#define GlintLineModeOrOff 0x9af8
+
+#define GlintTriangleModeAnd 0xab00
+#define GlintTriangleModeAndTag 0x0560
+#define GlintTriangleModeAndReg 1
+#define GlintTriangleModeAndOff 0x9b00
+
+#define GlintTriangleModeOr 0xab08
+#define GlintTriangleModeOrTag 0x0561
+#define GlintTriangleModeOrReg 1
+#define GlintTriangleModeOrOff 0x9b08
+
+#define GlintMaterialModeAnd 0xab10
+#define GlintMaterialModeAndTag 0x0562
+#define GlintMaterialModeAndReg 1
+#define GlintMaterialModeAndOff 0x9b10
+
+#define GlintMaterialModeOr 0xab18
+#define GlintMaterialModeOrTag 0x0563
+#define GlintMaterialModeOrReg 1
+#define GlintMaterialModeOrOff 0x9b18
+
+#define GlintWindowAnd 0xab80
+#define GlintWindowAndTag 0x0570
+#define GlintWindowAndReg 1
+#define GlintWindowAndOff 0x9b80
+
+#define GlintWindowOr 0xab88
+#define GlintWindowOrTag 0x0571
+#define GlintWindowOrReg 1
+#define GlintWindowOrOff 0x9b88
+
+#define GlintLBReadModeAnd 0xab90
+#define GlintLBReadModeAndTag 0x0572
+#define GlintLBReadModeAndReg 1
+#define GlintLBReadModeAndOff 0x9b90
+
+#define GlintLBReadModeOr 0xab98
+#define GlintLBReadModeOrTag 0x0573
+#define GlintLBReadModeOrReg 1
+#define GlintLBReadModeOrOff 0x9b98
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_context.c
new file mode 100644
index 000000000..ffaf45459
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_context.c
@@ -0,0 +1,226 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * 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@tungstengraphics.com>
+ *
+ * 3DLabs Gamma driver.
+ *
+ */
+#include "gamma_context.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+
+#include "drivers/common/driverfuncs.h"
+
+#include "context.h"
+#include "simple_list.h"
+#include "imports.h"
+#include "matrix.h"
+#include "extensions.h"
+#if defined(USE_X86_ASM)
+#include "x86/common_x86_asm.h"
+#endif
+#include "simple_list.h"
+#include "mm.h"
+
+
+#include "gamma_vb.h"
+#include "gamma_tris.h"
+
+extern const struct tnl_pipeline_stage _gamma_render_stage;
+
+static const struct tnl_pipeline_stage *gamma_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ /* REMOVE: point attenuation stage */
+#if 1
+ &_gamma_render_stage, /* ADD: unclipped rastersetup-to-dma */
+#endif
+ &_tnl_render_stage,
+ 0,
+};
+
+GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate)
+{
+ GLcontext *ctx, *shareCtx;
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ gammaContextPtr gmesa;
+ gammaScreenPtr gammascrn;
+ GLINTSAREADRIPtr saPriv=(GLINTSAREADRIPtr)(((char*)sPriv->pSAREA)+
+ sizeof(drm_sarea_t));
+ struct dd_function_table functions;
+
+ gmesa = (gammaContextPtr) CALLOC( sizeof(*gmesa) );
+ if (!gmesa)
+ return GL_FALSE;
+
+ /* Init default driver functions then plug in our gamma-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions( &functions );
+ gammaDDInitTextureFuncs( &functions );
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((gammaContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+
+ gmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
+ &functions, (void *) gmesa);
+ if (!gmesa->glCtx) {
+ FREE(gmesa);
+ return GL_FALSE;
+ }
+
+ gmesa->driContext = driContextPriv;
+ gmesa->driScreen = sPriv;
+ gmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */
+
+ gmesa->hHWContext = driContextPriv->hHWContext;
+ gmesa->driHwLock = &sPriv->pSAREA->lock;
+ gmesa->driFd = sPriv->fd;
+ gmesa->sarea = saPriv;
+
+ gammascrn = gmesa->gammaScreen = (gammaScreenPtr)(sPriv->private);
+
+ ctx = gmesa->glCtx;
+
+ ctx->Const.MaxTextureLevels = GAMMA_TEX_MAXLEVELS;
+ ctx->Const.MaxTextureUnits = 1; /* Permedia 3 */
+ ctx->Const.MaxTextureImageUnits = 1;
+ ctx->Const.MaxTextureCoordUnits = 1;
+
+ ctx->Const.MinLineWidth = 0.0;
+ ctx->Const.MaxLineWidth = 255.0;
+
+ ctx->Const.MinLineWidthAA = 0.0;
+ ctx->Const.MaxLineWidthAA = 65536.0;
+
+ ctx->Const.MinPointSize = 0.0;
+ ctx->Const.MaxPointSize = 255.0;
+
+ ctx->Const.MinPointSizeAA = 0.5; /* 4x4 quality mode */
+ ctx->Const.MaxPointSizeAA = 16.0;
+ ctx->Const.PointSizeGranularity = 0.25;
+
+ gmesa->texHeap = mmInit( 0, gmesa->gammaScreen->textureSize );
+
+ make_empty_list(&gmesa->TexObjList);
+ make_empty_list(&gmesa->SwappedOut);
+
+ gmesa->CurrentTexObj[0] = 0;
+ gmesa->CurrentTexObj[1] = 0; /* Permedia 3, second texture */
+
+ gmesa->RenderIndex = ~0;
+
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+
+ /* Install the customized pipeline:
+ */
+ _tnl_destroy_pipeline( ctx );
+ _tnl_install_pipeline( ctx, gamma_pipeline );
+
+ /* Configure swrast & TNL to match hardware characteristics:
+ */
+ _swrast_allow_pixel_fog( ctx, GL_FALSE );
+ _swrast_allow_vertex_fog( ctx, GL_TRUE );
+ _tnl_allow_pixel_fog( ctx, GL_FALSE );
+ _tnl_allow_vertex_fog( ctx, GL_TRUE );
+
+ gammaInitVB( ctx );
+ gammaDDInitExtensions( ctx );
+ /* XXX these should really go right after _mesa_init_driver_functions() */
+ gammaDDInitDriverFuncs( ctx );
+ gammaDDInitStateFuncs( ctx );
+ gammaDDInitSpanFuncs( ctx );
+ gammaDDInitTriFuncs( ctx );
+ gammaDDInitState( gmesa );
+
+ gammaInitTextureObjects( ctx );
+
+ driContextPriv->driverPrivate = (void *)gmesa;
+
+ GET_FIRST_DMA(gmesa->driFd, gmesa->hHWContext,
+ 1, &gmesa->bufIndex, &gmesa->bufSize,
+ &gmesa->buf, &gmesa->bufCount, gammascrn);
+
+#ifdef DO_VALIDATE
+ GET_FIRST_DMA(gmesa->driFd, gmesa->hHWContext,
+ 1, &gmesa->WCbufIndex, &gmesa->WCbufSize,
+ &gmesa->WCbuf, &gmesa->WCbufCount, gammascrn);
+#endif
+
+ switch (glVisual->depthBits) {
+ case 16:
+ gmesa->DeltaMode = DM_Depth16;
+ gmesa->depth_scale = 1.0f / 0xffff;
+ break;
+ case 24:
+ gmesa->DeltaMode = DM_Depth24;
+ gmesa->depth_scale = 1.0f / 0xffffff;
+ break;
+ case 32:
+ gmesa->DeltaMode = DM_Depth32;
+ gmesa->depth_scale = 1.0f / 0xffffffff;
+ break;
+ default:
+ break;
+ }
+
+ gmesa->DepthSize = glVisual->depthBits;
+ gmesa->Flags = GAMMA_FRONT_BUFFER;
+ gmesa->Flags |= (glVisual->doubleBufferMode ? GAMMA_BACK_BUFFER : 0);
+ gmesa->Flags |= (gmesa->DepthSize > 0 ? GAMMA_DEPTH_BUFFER : 0);
+
+ gmesa->EnabledFlags = GAMMA_FRONT_BUFFER;
+ gmesa->EnabledFlags |= (glVisual->doubleBufferMode ? GAMMA_BACK_BUFFER : 0);
+
+
+ if (gmesa->Flags & GAMMA_BACK_BUFFER) {
+ gmesa->readOffset = gmesa->drawOffset = gmesa->driScreen->fbHeight * gmesa->driScreen->fbWidth * gmesa->gammaScreen->cpp;
+ } else {
+ gmesa->readOffset = gmesa->drawOffset = 0;
+ }
+
+ gammaInitHW( gmesa );
+
+ driContextPriv->driverPrivate = (void *)gmesa;
+
+ return GL_TRUE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_context.h
new file mode 100644
index 000000000..7745f4c3c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_context.h
@@ -0,0 +1,403 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_context.h,v 1.6 2002/12/16 16:18:50 dawes Exp $ */
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * 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@tungstengraphics.com>
+ *
+ */
+
+#ifndef _GAMMA_CONTEXT_H_
+#define _GAMMA_CONTEXT_H_
+
+#include "dri_util.h"
+#include "drm.h"
+#include "drm_sarea.h"
+#include "colormac.h"
+#include "gamma_regs.h"
+#include "gamma_macros.h"
+#include "gamma_screen.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "glint_dri.h"
+#include "mm.h"
+
+typedef union {
+ unsigned int i;
+ float f;
+} dmaBufRec, *dmaBuf;
+
+/* Flags for context */
+#define GAMMA_FRONT_BUFFER 0x00000001
+#define GAMMA_BACK_BUFFER 0x00000002
+#define GAMMA_DEPTH_BUFFER 0x00000004
+#define GAMMA_STENCIL_BUFFER 0x00000008
+#define GAMMA_ACCUM_BUFFER 0x00000010
+
+#define GAMMA_MAX_TEXTURE_SIZE 2048
+
+/* These are the minimum requirements and should probably be increased */
+#define MAX_MODELVIEW_STACK 16
+#define MAX_PROJECTION_STACK 2
+#define MAX_TEXTURE_STACK 2
+
+extern void gammaDDUpdateHWState(GLcontext *ctx);
+extern gammaScreenPtr gammaCreateScreen(__DRIscreenPrivate *sPriv);
+extern void gammaDestroyScreen(__DRIscreenPrivate *sPriv);
+extern GLboolean gammaCreateContext( const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate);
+
+#define GAMMA_UPLOAD_ALL 0xffffffff
+#define GAMMA_UPLOAD_CLIPRECTS 0x00000002
+#define GAMMA_UPLOAD_ALPHA 0x00000004
+#define GAMMA_UPLOAD_BLEND 0x00000008
+#define GAMMA_UPLOAD_DEPTH 0x00000010
+#define GAMMA_UPLOAD_VIEWPORT 0x00000020
+#define GAMMA_UPLOAD_SHADE 0x00000040
+#define GAMMA_UPLOAD_CLIP 0x00000080
+#define GAMMA_UPLOAD_MASKS 0x00000100
+#define GAMMA_UPLOAD_WINDOW 0x00000200 /* defunct */
+#define GAMMA_UPLOAD_GEOMETRY 0x00000400
+#define GAMMA_UPLOAD_POLYGON 0x00000800
+#define GAMMA_UPLOAD_DITHER 0x00001000
+#define GAMMA_UPLOAD_LOGICOP 0x00002000
+#define GAMMA_UPLOAD_FOG 0x00004000
+#define GAMMA_UPLOAD_LIGHT 0x00008000
+#define GAMMA_UPLOAD_CONTEXT 0x00010000
+#define GAMMA_UPLOAD_TEX0 0x00020000
+#define GAMMA_UPLOAD_STIPPLE 0x00040000
+#define GAMMA_UPLOAD_TRANSFORM 0x00080000
+#define GAMMA_UPLOAD_LINEMODE 0x00100000
+#define GAMMA_UPLOAD_POINTMODE 0x00200000
+#define GAMMA_UPLOAD_TRIMODE 0x00400000
+
+#define GAMMA_NEW_CLIP 0x00000001
+#define GAMMA_NEW_WINDOW 0x00000002
+#define GAMMA_NEW_CONTEXT 0x00000004
+#define GAMMA_NEW_TEXTURE 0x00000008 /* defunct */
+#define GAMMA_NEW_ALPHA 0x00000010
+#define GAMMA_NEW_DEPTH 0x00000020
+#define GAMMA_NEW_MASKS 0x00000040
+#define GAMMA_NEW_POLYGON 0x00000080
+#define GAMMA_NEW_CULL 0x00000100
+#define GAMMA_NEW_LOGICOP 0x00000200
+#define GAMMA_NEW_FOG 0x00000400
+#define GAMMA_NEW_LIGHT 0x00000800
+#define GAMMA_NEW_STIPPLE 0x00001000
+#define GAMMA_NEW_ALL 0xffffffff
+
+#define GAMMA_FALLBACK_TRI 0x00000001
+#define GAMMA_FALLBACK_TEXTURE 0x00000002
+
+#define FLUSH_BATCH(gmesa) do { \
+ /*FLUSH_DMA_BUFFER(gmesa);*/ \
+} while(0)
+
+struct gamma_context;
+typedef struct gamma_context gammaContextRec;
+typedef struct gamma_context *gammaContextPtr;
+typedef struct gamma_texture_object_t *gammaTextureObjectPtr;
+
+#define VALID_GAMMA_TEXTURE_OBJECT(tobj) (tobj)
+
+#define GAMMA_TEX_MAXLEVELS 12 /* 2K x 2K */
+
+/* For shared texture space managment, these texture objects may also
+ * be used as proxies for regions of texture memory containing other
+ * client's textures. Such proxy textures (not to be confused with GL
+ * proxy textures) are subject to the same LRU aging we use for our
+ * own private textures, and thus we have a mechanism where we can
+ * fairly decide between kicking out our own textures and those of
+ * other clients.
+ *
+ * Non-local texture objects have a valid MemBlock to describe the
+ * region managed by the other client, and can be identified by
+ * 't->globj == 0'
+ */
+struct gamma_texture_object_t {
+ struct gamma_texture_object_t *next, *prev;
+
+ GLuint age;
+ struct gl_texture_object *globj;
+
+ int Pitch;
+ int Height;
+ int texelBytes;
+ int totalSize;
+ int bound;
+
+ PMemBlock MemBlock;
+ char * BufAddr;
+
+ GLuint min_level;
+ GLuint max_level;
+ GLuint dirty_images;
+
+ GLint firstLevel, lastLevel; /* upload tObj->Image[0][first .. lastLevel] */
+
+ struct {
+ const struct gl_texture_image *image;
+ int offset; /* into BufAddr */
+ int height;
+ int internalFormat;
+ } image[GAMMA_TEX_MAXLEVELS];
+
+ u_int32_t TextureBaseAddr[GAMMA_TEX_MAXLEVELS];
+ u_int32_t TextureAddressMode;
+ u_int32_t TextureColorMode;
+ u_int32_t TextureFilterMode;
+ u_int32_t TextureFormat;
+ u_int32_t TextureReadMode;
+ u_int32_t TextureBorderColor;
+};
+
+#define GAMMA_NO_PALETTE 0x0
+#define GAMMA_USE_PALETTE 0x1
+#define GAMMA_UPDATE_PALETTE 0x2
+#define GAMMA_FALLBACK_PALETTE 0x4
+
+void gammaUpdateTextureState( GLcontext *ctx );
+
+void gammaDestroyTexObj( gammaContextPtr gmesa, gammaTextureObjectPtr t );
+void gammaSwapOutTexObj( gammaContextPtr gmesa, gammaTextureObjectPtr t );
+void gammaUploadTexImages( gammaContextPtr gmesa, gammaTextureObjectPtr t );
+
+void gammaResetGlobalLRU( gammaContextPtr gmesa );
+void gammaUpdateTexLRU( gammaContextPtr gmesa, gammaTextureObjectPtr t );
+void gammaTexturesGone( gammaContextPtr gmesa,
+ GLuint start, GLuint end,
+ GLuint in_use );
+
+void gammaEmitHwState( gammaContextPtr gmesa );
+void gammaDDInitExtensions( GLcontext *ctx );
+void gammaDDInitDriverFuncs( GLcontext *ctx );
+void gammaDDInitSpanFuncs( GLcontext *ctx );
+void gammaDDInitState( gammaContextPtr gmesa );
+void gammaInitHW( gammaContextPtr gmesa );
+void gammaDDInitStateFuncs( GLcontext *ctx );
+void gammaDDInitTextureFuncs( struct dd_function_table *table );
+void gammaInitTextureObjects( GLcontext *ctx );
+void gammaDDInitTriFuncs( GLcontext *ctx );
+
+void gammaUpdateWindow( GLcontext *ctx );
+void gammaUpdateViewportOffset( GLcontext *ctx );
+
+void gammaPrintLocalLRU( gammaContextPtr gmesa );
+void gammaPrintGlobalLRU( gammaContextPtr gmesa );
+
+extern void gammaFallback( gammaContextPtr gmesa, GLuint bit, GLboolean mode );
+#define FALLBACK( imesa, bit, mode ) gammaFallback( imesa, bit, mode )
+
+/* Use the templated vertex formats. Only one of these is used in gamma.
+ */
+#define TAG(x) gamma##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+typedef void (*gamma_quad_func)( gammaContextPtr,
+ const gammaVertex *,
+ const gammaVertex *,
+ const gammaVertex *,
+ const gammaVertex * );
+typedef void (*gamma_tri_func)( gammaContextPtr,
+ const gammaVertex *,
+ const gammaVertex *,
+ const gammaVertex * );
+typedef void (*gamma_line_func)( gammaContextPtr,
+ const gammaVertex *,
+ const gammaVertex * );
+typedef void (*gamma_point_func)( gammaContextPtr,
+ const gammaVertex * );
+
+
+struct gamma_context {
+ GLcontext *glCtx; /* Mesa context */
+
+ __DRIcontextPrivate *driContext;
+ __DRIscreenPrivate *driScreen;
+ __DRIdrawablePrivate *driDrawable;
+
+ GLuint new_gl_state;
+ GLuint new_state;
+ GLuint dirty;
+
+ GLINTSAREADRIPtr sarea;
+
+ /* Mirrors of some DRI state
+ */
+ drm_context_t hHWContext;
+ drm_hw_lock_t *driHwLock;
+ int driFd;
+
+ GLuint numClipRects; /* Cliprects for the draw buffer */
+ drm_clip_rect_t *pClipRects;
+
+ dmaBuf buf; /* DMA buffer for regular cmds */
+ int bufIndex;
+ int bufSize;
+ int bufCount;
+
+ dmaBuf WCbuf; /* DMA buffer for window changed cmds */
+ int WCbufIndex;
+ int WCbufSize;
+ int WCbufCount;
+
+ gammaScreenPtr gammaScreen; /* Screen private DRI data */
+
+ int drawOffset;
+ int readOffset;
+
+ gamma_point_func draw_point;
+ gamma_line_func draw_line;
+ gamma_tri_func draw_tri;
+ gamma_quad_func draw_quad;
+
+ GLuint Fallback;
+ GLuint RenderIndex;
+ GLuint SetupNewInputs;
+ GLuint SetupIndex;
+
+ GLuint vertex_format;
+ GLuint vertex_size;
+ GLuint vertex_stride_shift;
+ GLubyte *verts;
+
+ GLfloat hw_viewport[16];
+ GLuint hw_primitive;
+ GLenum render_primitive;
+
+ GLfloat depth_scale;
+
+ gammaTextureObjectPtr CurrentTexObj[2];
+ struct gamma_texture_object_t TexObjList;
+ struct gamma_texture_object_t SwappedOut;
+ GLenum TexEnvImageFmt[2];
+
+ memHeap_t *texHeap;
+
+ unsigned int lastSwap;
+ int texAge;
+ int ctxAge;
+ int dirtyAge;
+ unsigned int lastStamp;
+
+
+ u_int32_t ClearColor;
+ u_int32_t Color;
+ u_int32_t DitherMode;
+ u_int32_t ClearDepth;
+ u_int32_t FogMode;
+ u_int32_t AreaStippleMode;
+ u_int32_t LBReadFormat;
+ u_int32_t LBWriteFormat;
+ u_int32_t LineMode;
+ u_int32_t PointMode;
+ u_int32_t TriangleMode;
+ u_int32_t AntialiasMode;
+ GLfloat ViewportScaleX;
+ GLfloat ViewportScaleY;
+ GLfloat ViewportScaleZ;
+ GLfloat ViewportOffsetX;
+ GLfloat ViewportOffsetY;
+ GLfloat ViewportOffsetZ;
+ int MatrixMode;
+ int DepthMode;
+ int TransformMode;
+ int LBReadMode;
+ int FBReadMode;
+ int FBWindowBase;
+ int LBWindowBase;
+ int ColorDDAMode;
+ int GeometryMode;
+ int AlphaTestMode;
+ int AlphaBlendMode;
+ int AB_FBReadMode;
+ int AB_FBReadMode_Save;
+ int DeltaMode;
+ int ColorMaterialMode;
+ int FBHardwareWriteMask;
+ int MaterialMode;
+ int NormalizeMode;
+ int LightingMode;
+ int Light0Mode;
+ int Light1Mode;
+ int Light2Mode;
+ int Light3Mode;
+ int Light4Mode;
+ int Light5Mode;
+ int Light6Mode;
+ int Light7Mode;
+ int Light8Mode;
+ int Light9Mode;
+ int Light10Mode;
+ int Light11Mode;
+ int Light12Mode;
+ int Light13Mode;
+ int Light14Mode;
+ int Light15Mode;
+ int LogicalOpMode;
+ int ScissorMode;
+ int ScissorMaxXY;
+ int ScissorMinXY;
+ int Window; /* GID part probably should be in draw priv */
+ int WindowOrigin;
+ int x, y, w, h; /* Probably should be in drawable priv */
+ int FrameCount; /* Probably should be in drawable priv */
+ int NotClipped; /* Probably should be in drawable priv */
+ int WindowChanged; /* Probably should be in drawabl... */
+ int Flags;
+ int EnabledFlags;
+ int DepthSize;
+ int Begin;
+ GLenum ErrorValue;
+ int Texture1DEnabled;
+ int Texture2DEnabled;
+
+ float ModelView[16];
+ float Proj[16];
+ float ModelViewProj[16];
+ float Texture[16];
+
+ float ModelViewStack[(MAX_MODELVIEW_STACK-1)*16];
+ int ModelViewCount;
+ float ProjStack[(MAX_PROJECTION_STACK-1)*16];
+ int ProjCount;
+ float TextureStack[(MAX_TEXTURE_STACK-1)*16];
+ int TextureCount;
+};
+
+static __inline GLuint gammaPackColor( GLuint cpp,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a )
+{
+ switch ( cpp ) {
+ case 2:
+ return PACK_COLOR_565( r, g, b );
+ case 4:
+ return PACK_COLOR_8888( a, r, g, b );
+ default:
+ return 0;
+ }
+}
+
+#define GAMMA_CONTEXT(ctx) ((gammaContextPtr)(ctx->DriverCtx))
+
+#endif /* _GAMMA_CONTEXT_H_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_dd.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_dd.c
new file mode 100644
index 000000000..cca382d89
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_dd.c
@@ -0,0 +1,128 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * 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@tungstengraphics.com>
+ *
+ */
+
+#include "gamma_context.h"
+#include "gamma_vb.h"
+#include "gamma_lock.h"
+#if defined(USE_X86_ASM)
+#include "x86/common_x86_asm.h"
+#endif
+
+#include "context.h"
+#include "swrast/swrast.h"
+
+#define GAMMA_DATE "20021125"
+
+
+/* Return the width and height of the current color buffer.
+ */
+static void gammaDDGetBufferSize( GLframebuffer *buffer,
+ GLuint *width, GLuint *height )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ GAMMAHW_LOCK( gmesa );
+ *width = gmesa->driDrawable->w;
+ *height = gmesa->driDrawable->h;
+ GAMMAHW_UNLOCK( gmesa );
+}
+
+
+/* Return various strings for glGetString().
+ */
+static const GLubyte *gammaDDGetString( GLcontext *ctx, GLenum name )
+{
+ static char buffer[128];
+
+ switch ( name ) {
+ case GL_VENDOR:
+ return (GLubyte *)"VA Linux Systems, Inc.";
+
+ case GL_RENDERER:
+ sprintf( buffer, "Mesa DRI Gamma " GAMMA_DATE );
+
+ /* Append any CPU-specific information.
+ */
+#ifdef USE_X86_ASM
+ if ( _mesa_x86_cpu_features ) {
+ strncat( buffer, " x86", 4 );
+ }
+#ifdef USE_MMX_ASM
+ if ( cpu_has_mmx ) {
+ strncat( buffer, "/MMX", 4 );
+ }
+#endif
+#ifdef USE_3DNOW_ASM
+ if ( cpu_has_3dnow ) {
+ strncat( buffer, "/3DNow!", 7 );
+ }
+#endif
+#ifdef USE_SSE_ASM
+ if ( cpu_has_xmm ) {
+ strncat( buffer, "/SSE", 4 );
+ }
+#endif
+#endif
+ return (GLubyte *)buffer;
+
+ default:
+ return NULL;
+ }
+}
+
+/* Enable the extensions supported by this driver.
+ */
+void gammaDDInitExtensions( GLcontext *ctx )
+{
+ /* None... */
+}
+
+/* Initialize the driver's misc functions.
+ */
+void gammaDDInitDriverFuncs( GLcontext *ctx )
+{
+ ctx->Driver.GetBufferSize = gammaDDGetBufferSize;
+ ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
+ ctx->Driver.GetString = gammaDDGetString;
+
+ ctx->Driver.Error = NULL;
+
+ /* Pixel path fallbacks
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.ResizeBuffers = _swrast_alloc_buffers;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_inithw.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_inithw.c
new file mode 100644
index 000000000..47eb802b4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_inithw.c
@@ -0,0 +1,551 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * 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@tungstengraphics.com>
+ * Kevin E. Martin <martin@valinux.com>
+ *
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c,v 1.9 2002/10/30 12:51:29 alanh Exp $ */
+
+#include "gamma_context.h"
+#include "glint_dri.h"
+
+void gammaInitHW( gammaContextPtr gmesa )
+{
+ GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)gmesa->driScreen->pDevPriv;
+ int i;
+
+ if (gDRIPriv->numMultiDevices == 2) {
+ /* Set up each MX's ScanLineOwnership for OpenGL */
+ CHECK_DMA_BUFFER(gmesa, 5);
+ WRITE(gmesa->buf, BroadcastMask, 1);
+ WRITE(gmesa->buf, ScanLineOwnership, 5); /* Use bottom left as [0,0] */
+ WRITE(gmesa->buf, BroadcastMask, 2);
+ WRITE(gmesa->buf, ScanLineOwnership, 1); /* Use bottom left as [0,0] */
+ /* Broadcast to both MX's */
+ WRITE(gmesa->buf, BroadcastMask, 3);
+ FLUSH_DMA_BUFFER(gmesa);
+ }
+
+ gmesa->AlphaBlendMode = (AlphaBlendModeDisable |
+ AB_Src_One |
+ AB_Dst_Zero |
+ AB_NoAlphaBufferPresent |
+ AB_ColorFmt_8888 |
+ AB_ColorOrder_RGB |
+ AB_OpenGLType |
+ AB_AlphaDst_FBData |
+ AB_ColorConversionScale |
+ AB_AlphaConversionScale);
+
+ gmesa->DitherMode = DitherModeEnable | DM_ColorOrder_RGB;
+
+ switch (gmesa->gammaScreen->cpp) {
+ case 2:
+ gmesa->DitherMode |= DM_ColorFmt_5555;
+ gmesa->AlphaBlendMode |= AB_ColorFmt_5555;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PixelSize, 1);
+ break;
+ case 4:
+ gmesa->DitherMode |= DM_ColorFmt_8888;
+ gmesa->AlphaBlendMode |= AB_ColorFmt_8888;
+ WRITE(gmesa->buf, PixelSize, 0);
+ break;
+ }
+
+ /* FIXME for stencil, gid, etc */
+ switch (gmesa->DepthSize) {
+ case 16:
+ gmesa->LBReadFormat =
+ (LBRF_DepthWidth16 |
+ LBRF_StencilWidth8 |
+ LBRF_StencilPos16 |
+ LBRF_FrameCount8 |
+ LBRF_FrameCountPos24 |
+ LBRF_GIDWidth4 |
+ LBRF_GIDPos32 );
+ gmesa->LBWriteFormat =
+ (LBRF_DepthWidth16 |
+ LBRF_StencilWidth8 |
+ LBRF_StencilPos16 |
+ LBRF_FrameCount8 |
+ LBRF_FrameCountPos24 |
+ LBRF_GIDWidth4 |
+ LBRF_GIDPos32 );
+ break;
+ case 24:
+ gmesa->LBReadFormat =
+ (LBRF_DepthWidth24 |
+ LBRF_StencilWidth8 |
+ LBRF_StencilPos24 |
+ LBRF_FrameCount8 |
+ LBRF_FrameCountPos32 |
+ LBRF_GIDWidth4 |
+ LBRF_GIDPos36 );
+ gmesa->LBWriteFormat =
+ (LBRF_DepthWidth24 |
+ LBRF_StencilWidth8 |
+ LBRF_StencilPos24 |
+ LBRF_FrameCount8 |
+ LBRF_FrameCountPos32 |
+ LBRF_GIDWidth4 |
+ LBRF_GIDPos36 );
+ break;
+ case 32:
+ gmesa->LBReadFormat =
+ (LBRF_DepthWidth32 |
+ LBRF_StencilWidth8 |
+ LBRF_StencilPos32 |
+ LBRF_FrameCount8 |
+ LBRF_FrameCountPos40 |
+ LBRF_GIDWidth4 |
+ LBRF_GIDPos44 );
+ gmesa->LBWriteFormat =
+ (LBRF_DepthWidth32 |
+ LBRF_StencilWidth8 |
+ LBRF_StencilPos32 |
+ LBRF_FrameCount8 |
+ LBRF_FrameCountPos40 |
+ LBRF_GIDWidth4 |
+ LBRF_GIDPos44 );
+ break;
+ }
+
+ gmesa->FBHardwareWriteMask = 0xffffffff;
+ gmesa->FogMode = FogModeDisable;
+ gmesa->ClearDepth = 0xffffffff;
+ gmesa->AreaStippleMode = AreaStippleModeDisable;
+ gmesa->x = 0;
+ gmesa->y = 0;
+ gmesa->w = 0;
+ gmesa->h = 0;
+ gmesa->FrameCount = 0;
+ gmesa->MatrixMode = GL_MODELVIEW;
+ gmesa->ModelViewCount = 0;
+ gmesa->ProjCount = 0;
+ gmesa->TextureCount = 0;
+ gmesa->PointMode = PM_AntialiasQuality_4x4;
+ gmesa->LineMode = LM_AntialiasQuality_4x4;
+ gmesa->TriangleMode = TM_AntialiasQuality_4x4;
+ gmesa->AntialiasMode = AntialiasModeDisable;
+
+ for (i = 0; i < 16; i++)
+ if (i % 5 == 0)
+ gmesa->ModelView[i] =
+ gmesa->Proj[i] =
+ gmesa->ModelViewProj[i] =
+ gmesa->Texture[i] = 1.0;
+ else
+ gmesa->ModelView[i] =
+ gmesa->Proj[i] =
+ gmesa->ModelViewProj[i] =
+ gmesa->Texture[i] = 0.0;
+
+ gmesa->LBReadMode = (LBReadSrcDisable |
+ LBReadDstDisable |
+ LBDataTypeDefault |
+ LBWindowOriginBot |
+ gDRIPriv->pprod);
+ gmesa->FBReadMode = (FBReadSrcDisable |
+ FBReadDstDisable |
+ FBDataTypeDefault |
+ FBWindowOriginBot |
+ gDRIPriv->pprod);
+
+ if (gDRIPriv->numMultiDevices == 2) {
+ gmesa->LBReadMode |= LBScanLineInt2;
+ gmesa->FBReadMode |= FBScanLineInt2;
+ gmesa->LBWindowBase = gmesa->driScreen->fbWidth *
+ (gmesa->driScreen->fbHeight/2 - 1);
+ gmesa->FBWindowBase = gmesa->driScreen->fbWidth *
+ (gmesa->driScreen->fbHeight/2 - 1);
+ } else {
+ gmesa->LBWindowBase = gmesa->driScreen->fbWidth *
+ (gmesa->driScreen->fbHeight - 1);
+ gmesa->FBWindowBase = gmesa->driScreen->fbWidth *
+ (gmesa->driScreen->fbHeight - 1);
+ }
+
+ gmesa->Begin = (B_AreaStippleDisable |
+ B_LineStippleDisable |
+ B_AntiAliasDisable |
+ B_TextureDisable |
+ B_FogDisable |
+ B_SubPixelCorrectEnable |
+ B_PrimType_Null);
+
+ gmesa->ColorDDAMode = (ColorDDAEnable |
+ ColorDDAGouraud);
+
+ gmesa->GeometryMode = (GM_TextureDisable |
+ GM_FogDisable |
+ GM_FogExp |
+ GM_FrontPolyFill |
+ GM_BackPolyFill |
+ GM_FrontFaceCCW |
+ GM_PolyCullDisable |
+ GM_PolyCullBack |
+ GM_ClipShortLinesDisable |
+ GM_ClipSmallTrisDisable |
+ GM_RenderMode |
+ GM_Feedback2D |
+ GM_CullFaceNormDisable |
+ GM_AutoFaceNormDisable |
+ GM_GouraudShading |
+ GM_UserClipNone |
+ GM_PolyOffsetPointDisable |
+ GM_PolyOffsetLineDisable |
+ GM_PolyOffsetFillDisable |
+ GM_InvertFaceNormCullDisable);
+
+ gmesa->AlphaTestMode = (AlphaTestModeDisable |
+ AT_Always);
+
+ gmesa->AB_FBReadMode_Save = gmesa->AB_FBReadMode = 0;
+
+ gmesa->Window = (WindowEnable | /* For GID testing */
+ W_PassIfEqual |
+ (0 << 5)); /* GID part is set from draw priv (below) */
+
+ gmesa->NotClipped = GL_FALSE;
+ gmesa->WindowChanged = GL_TRUE;
+
+ gmesa->Texture1DEnabled = GL_FALSE;
+ gmesa->Texture2DEnabled = GL_FALSE;
+
+ gmesa->DepthMode |= (DepthModeDisable |
+ DM_WriteMask |
+ DM_Less);
+
+ gmesa->DeltaMode |= (DM_SubPixlCorrectionEnable |
+ DM_SmoothShadingEnable |
+ DM_Target500TXMX);
+
+ gmesa->LightingMode = LightingModeDisable | LightingModeSpecularEnable;
+ gmesa->Light0Mode = LNM_Off;
+ gmesa->Light1Mode = LNM_Off;
+ gmesa->Light2Mode = LNM_Off;
+ gmesa->Light3Mode = LNM_Off;
+ gmesa->Light4Mode = LNM_Off;
+ gmesa->Light5Mode = LNM_Off;
+ gmesa->Light6Mode = LNM_Off;
+ gmesa->Light7Mode = LNM_Off;
+ gmesa->Light8Mode = LNM_Off;
+ gmesa->Light9Mode = LNM_Off;
+ gmesa->Light10Mode = LNM_Off;
+ gmesa->Light11Mode = LNM_Off;
+ gmesa->Light12Mode = LNM_Off;
+ gmesa->Light13Mode = LNM_Off;
+ gmesa->Light14Mode = LNM_Off;
+ gmesa->Light15Mode = LNM_Off;
+
+ gmesa->LogicalOpMode = LogicalOpModeDisable;
+
+ gmesa->MaterialMode = MaterialModeDisable;
+
+ gmesa->ScissorMode = UserScissorDisable | ScreenScissorDisable;
+
+ gmesa->TransformMode = XM_UseModelViewProjMatrix |
+ XM_TexGenModeS_None |
+ XM_TexGenModeT_None |
+ XM_TexGenModeR_None |
+ XM_TexGenModeQ_None;
+
+ CHECK_DMA_BUFFER(gmesa, 20);
+ WRITE(gmesa->buf, LineStippleMode, 0);
+ WRITE(gmesa->buf, RouterMode, 0);
+ WRITE(gmesa->buf, TextureAddressMode, 0);
+ WRITE(gmesa->buf, TextureReadMode, 0);
+ WRITE(gmesa->buf, TextureFilterMode, 0);
+ WRITE(gmesa->buf, TextureColorMode, 0);
+ WRITE(gmesa->buf, StencilMode, 0);
+ WRITE(gmesa->buf, PatternRamMode, 0);
+ WRITE(gmesa->buf, ChromaTestMode, 0);
+ WRITE(gmesa->buf, StatisticMode, 0);
+ WRITE(gmesa->buf, AreaStippleMode, gmesa->AreaStippleMode);
+ WRITE(gmesa->buf, ScissorMode, gmesa->ScissorMode);
+ WRITE(gmesa->buf, FogMode, gmesa->FogMode);
+ WRITE(gmesa->buf, AntialiasMode, gmesa->AntialiasMode);
+ WRITE(gmesa->buf, LogicalOpMode, gmesa->LogicalOpMode);
+ WRITE(gmesa->buf, TriangleMode, gmesa->TriangleMode);
+ WRITE(gmesa->buf, PointMode, gmesa->PointMode);
+ WRITE(gmesa->buf, LineMode, gmesa->LineMode);
+ WRITE(gmesa->buf, LBWriteFormat, gmesa->LBWriteFormat);
+ WRITE(gmesa->buf, LBReadFormat, gmesa->LBReadFormat);
+
+ /* Framebuffer initialization */
+ CHECK_DMA_BUFFER(gmesa, 10);
+ WRITE(gmesa->buf, FBSourceData, 0);
+ WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode);
+ if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER) {
+ if (gDRIPriv->numMultiDevices == 2) {
+ WRITE(gmesa->buf, FBPixelOffset,
+ (gmesa->driScreen->fbHeight/2)*gmesa->driScreen->fbWidth);
+ } else {
+ WRITE(gmesa->buf, FBPixelOffset,
+ gmesa->driScreen->fbHeight*gmesa->driScreen->fbWidth);
+ }
+ } else
+ WRITE(gmesa->buf, FBPixelOffset, 0);
+ WRITE(gmesa->buf, FBSourceOffset, 0);
+ WRITE(gmesa->buf, FBHardwareWriteMask, 0xffffffff);
+ WRITE(gmesa->buf, FBSoftwareWriteMask, 0xffffffff);
+ WRITE(gmesa->buf, FBWriteMode, FBWriteModeEnable);
+ WRITE(gmesa->buf, FBWindowBase, gmesa->FBWindowBase);
+ WRITE(gmesa->buf, ScreenSize, ((gmesa->driScreen->fbHeight << 16) |
+ (gmesa->driScreen->fbWidth)));
+ WRITE(gmesa->buf, WindowOrigin, 0x00000000);
+
+ /* Localbuffer initialization */
+ CHECK_DMA_BUFFER(gmesa, 5);
+ WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode);
+ WRITE(gmesa->buf, LBSourceOffset, 0);
+ WRITE(gmesa->buf, LBWriteMode, LBWriteModeEnable);
+ WRITE(gmesa->buf, LBWindowOffset, 0);
+ WRITE(gmesa->buf, LBWindowBase, gmesa->LBWindowBase);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Rectangle2DControl, 1);
+
+ CHECK_DMA_BUFFER(gmesa, 11);
+ WRITE(gmesa->buf, DepthMode, gmesa->DepthMode);
+ WRITE(gmesa->buf, ColorDDAMode, gmesa->ColorDDAMode);
+ WRITE(gmesa->buf, FBBlockColor, 0x00000000);
+ WRITE(gmesa->buf, ConstantColor, 0x00000000);
+ WRITE(gmesa->buf, AlphaTestMode, gmesa->AlphaTestMode);
+ WRITE(gmesa->buf, AlphaBlendMode, gmesa->AlphaBlendMode);
+ WRITE(gmesa->buf, DitherMode, gmesa->DitherMode);
+ if (gDRIPriv->numMultiDevices == 2)
+ WRITE(gmesa->buf, RasterizerMode, RM_MultiGLINT | RM_BiasCoordNearHalf);
+ else
+ WRITE(gmesa->buf, RasterizerMode, RM_BiasCoordNearHalf);
+ WRITE(gmesa->buf, GLINTWindow, gmesa->Window);
+ WRITE(gmesa->buf, FastClearDepth, gmesa->ClearDepth);
+ WRITE(gmesa->buf, GLINTDepth, gmesa->ClearDepth);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, EdgeFlag, EdgeFlagEnable);
+
+ CHECK_DMA_BUFFER(gmesa, 16);
+ WRITEF(gmesa->buf, ModelViewMatrix0, 1.0);
+ WRITEF(gmesa->buf, ModelViewMatrix1, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix2, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix3, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix4, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix5, 1.0);
+ WRITEF(gmesa->buf, ModelViewMatrix6, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix7, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix8, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix9, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix10, 1.0);
+ WRITEF(gmesa->buf, ModelViewMatrix11, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix12, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix13, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix14, 0.0);
+ WRITEF(gmesa->buf, ModelViewMatrix15, 1.0);
+
+ CHECK_DMA_BUFFER(gmesa, 16);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix0, 1.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix1, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix2, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix3, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix4, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix5, 1.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix6, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix7, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix8, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix9, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix10, 1.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix11, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix12, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix13, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix14, 0.0);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix15, 1.0);
+
+ CHECK_DMA_BUFFER(gmesa, 16);
+ WRITEF(gmesa->buf, TextureMatrix0, 1.0);
+ WRITEF(gmesa->buf, TextureMatrix1, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix2, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix3, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix4, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix5, 1.0);
+ WRITEF(gmesa->buf, TextureMatrix6, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix7, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix8, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix9, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix10, 1.0);
+ WRITEF(gmesa->buf, TextureMatrix11, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix12, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix13, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix14, 0.0);
+ WRITEF(gmesa->buf, TextureMatrix15, 1.0);
+
+ CHECK_DMA_BUFFER(gmesa, 16);
+ WRITEF(gmesa->buf, TexGen0, 0.0);
+ WRITEF(gmesa->buf, TexGen1, 0.0);
+ WRITEF(gmesa->buf, TexGen2, 0.0);
+ WRITEF(gmesa->buf, TexGen3, 0.0);
+ WRITEF(gmesa->buf, TexGen4, 0.0);
+ WRITEF(gmesa->buf, TexGen5, 0.0);
+ WRITEF(gmesa->buf, TexGen6, 0.0);
+ WRITEF(gmesa->buf, TexGen7, 0.0);
+ WRITEF(gmesa->buf, TexGen8, 0.0);
+ WRITEF(gmesa->buf, TexGen9, 0.0);
+ WRITEF(gmesa->buf, TexGen10, 0.0);
+ WRITEF(gmesa->buf, TexGen11, 0.0);
+ WRITEF(gmesa->buf, TexGen12, 0.0);
+ WRITEF(gmesa->buf, TexGen13, 0.0);
+ WRITEF(gmesa->buf, TexGen14, 0.0);
+ WRITEF(gmesa->buf, TexGen15, 0.0);
+
+ CHECK_DMA_BUFFER(gmesa, 9);
+ WRITEF(gmesa->buf, NormalMatrix0, 1.0);
+ WRITEF(gmesa->buf, NormalMatrix1, 0.0);
+ WRITEF(gmesa->buf, NormalMatrix2, 0.0);
+ WRITEF(gmesa->buf, NormalMatrix3, 0.0);
+ WRITEF(gmesa->buf, NormalMatrix4, 1.0);
+ WRITEF(gmesa->buf, NormalMatrix5, 0.0);
+ WRITEF(gmesa->buf, NormalMatrix6, 0.0);
+ WRITEF(gmesa->buf, NormalMatrix7, 0.0);
+ WRITEF(gmesa->buf, NormalMatrix8, 1.0);
+
+ CHECK_DMA_BUFFER(gmesa, 3);
+ WRITEF(gmesa->buf, FogDensity, 0.0);
+ WRITEF(gmesa->buf, FogEnd, 0.0);
+ WRITEF(gmesa->buf, FogScale, 0.0);
+
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITEF(gmesa->buf, LineClipLengthThreshold, 0.0);
+ WRITEF(gmesa->buf, TriangleClipAreaThreshold, 0.0);
+
+ CHECK_DMA_BUFFER(gmesa, 5);
+ WRITE(gmesa->buf, GeometryMode, gmesa->GeometryMode);
+ WRITE(gmesa->buf, NormalizeMode, NormalizeModeDisable);
+ WRITE(gmesa->buf, LightingMode, gmesa->LightingMode);
+ WRITE(gmesa->buf, ColorMaterialMode, ColorMaterialModeDisable);
+ WRITE(gmesa->buf, MaterialMode, MaterialModeDisable);
+
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, FrontSpecularExponent, 0); /* fixed point */
+ WRITE(gmesa->buf, BackSpecularExponent, 0); /* fixed point */
+
+ CHECK_DMA_BUFFER(gmesa, 29);
+ WRITEF(gmesa->buf, FrontAmbientColorRed, 0.2);
+ WRITEF(gmesa->buf, FrontAmbientColorGreen, 0.2);
+ WRITEF(gmesa->buf, FrontAmbientColorBlue, 0.2);
+ WRITEF(gmesa->buf, BackAmbientColorRed, 0.2);
+ WRITEF(gmesa->buf, BackAmbientColorGreen, 0.2);
+ WRITEF(gmesa->buf, BackAmbientColorBlue, 0.2);
+ WRITEF(gmesa->buf, FrontDiffuseColorRed, 0.8);
+ WRITEF(gmesa->buf, FrontDiffuseColorGreen, 0.8);
+ WRITEF(gmesa->buf, FrontDiffuseColorBlue, 0.8);
+ WRITEF(gmesa->buf, BackDiffuseColorRed, 0.8);
+ WRITEF(gmesa->buf, BackDiffuseColorGreen, 0.8);
+ WRITEF(gmesa->buf, BackDiffuseColorBlue, 0.8);
+ WRITEF(gmesa->buf, FrontSpecularColorRed, 0.0);
+ WRITEF(gmesa->buf, FrontSpecularColorGreen, 0.0);
+ WRITEF(gmesa->buf, FrontSpecularColorBlue, 0.0);
+ WRITEF(gmesa->buf, BackSpecularColorRed, 0.0);
+ WRITEF(gmesa->buf, BackSpecularColorGreen, 0.0);
+ WRITEF(gmesa->buf, BackSpecularColorBlue, 0.0);
+ WRITEF(gmesa->buf, FrontEmissiveColorRed, 0.0);
+ WRITEF(gmesa->buf, FrontEmissiveColorGreen, 0.0);
+ WRITEF(gmesa->buf, FrontEmissiveColorBlue, 0.0);
+ WRITEF(gmesa->buf, BackEmissiveColorRed, 0.0);
+ WRITEF(gmesa->buf, BackEmissiveColorGreen, 0.0);
+ WRITEF(gmesa->buf, BackEmissiveColorBlue, 0.0);
+ WRITEF(gmesa->buf, SceneAmbientColorRed, 0.2);
+ WRITEF(gmesa->buf, SceneAmbientColorGreen, 0.2);
+ WRITEF(gmesa->buf, SceneAmbientColorBlue, 0.2);
+ WRITEF(gmesa->buf, FrontAlpha, 1.0);
+ WRITEF(gmesa->buf, BackAlpha, 1.0);
+
+ CHECK_DMA_BUFFER(gmesa, 7);
+ WRITE(gmesa->buf, PointSize, 1);
+ WRITEF(gmesa->buf, AApointSize, 1.0);
+ WRITE(gmesa->buf, LineWidth, 1);
+ WRITEF(gmesa->buf, AAlineWidth, 1.0);
+ WRITE(gmesa->buf, LineWidthOffset, 0);
+ WRITE(gmesa->buf, TransformMode, gmesa->TransformMode);
+ WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode);
+
+ CHECK_DMA_BUFFER(gmesa, 16);
+ WRITE(gmesa->buf, Light0Mode, LNM_Off);
+ WRITE(gmesa->buf, Light1Mode, LNM_Off);
+ WRITE(gmesa->buf, Light2Mode, LNM_Off);
+ WRITE(gmesa->buf, Light3Mode, LNM_Off);
+ WRITE(gmesa->buf, Light4Mode, LNM_Off);
+ WRITE(gmesa->buf, Light5Mode, LNM_Off);
+ WRITE(gmesa->buf, Light6Mode, LNM_Off);
+ WRITE(gmesa->buf, Light7Mode, LNM_Off);
+ WRITE(gmesa->buf, Light8Mode, LNM_Off);
+ WRITE(gmesa->buf, Light9Mode, LNM_Off);
+ WRITE(gmesa->buf, Light10Mode, LNM_Off);
+ WRITE(gmesa->buf, Light11Mode, LNM_Off);
+ WRITE(gmesa->buf, Light12Mode, LNM_Off);
+ WRITE(gmesa->buf, Light13Mode, LNM_Off);
+ WRITE(gmesa->buf, Light14Mode, LNM_Off);
+ WRITE(gmesa->buf, Light15Mode, LNM_Off);
+
+ CHECK_DMA_BUFFER(gmesa, 22);
+ WRITEF(gmesa->buf, Light0AmbientIntensityBlue, 0.0);
+ WRITEF(gmesa->buf, Light0AmbientIntensityGreen, 0.0);
+ WRITEF(gmesa->buf, Light0AmbientIntensityRed, 0.0);
+ WRITEF(gmesa->buf, Light0DiffuseIntensityBlue, 1.0);
+ WRITEF(gmesa->buf, Light0DiffuseIntensityGreen, 1.0);
+ WRITEF(gmesa->buf, Light0DiffuseIntensityRed, 1.0);
+ WRITEF(gmesa->buf, Light0SpecularIntensityBlue, 1.0);
+ WRITEF(gmesa->buf, Light0SpecularIntensityGreen, 1.0);
+ WRITEF(gmesa->buf, Light0SpecularIntensityRed, 1.0);
+ WRITEF(gmesa->buf, Light0SpotlightDirectionZ, 0.0);
+ WRITEF(gmesa->buf, Light0SpotlightDirectionY, 0.0);
+ WRITEF(gmesa->buf, Light0SpotlightDirectionX, -1.0);
+ WRITEF(gmesa->buf, Light0SpotlightExponent, 0.0);
+ WRITEF(gmesa->buf, Light0PositionZ, 0.0);
+ WRITEF(gmesa->buf, Light0PositionY, 0.0);
+ WRITEF(gmesa->buf, Light0PositionX, 1.0);
+ WRITEF(gmesa->buf, Light0PositionW, 0.0);
+ WRITEF(gmesa->buf, Light0CosSpotlightCutoffAngle, -1.0);
+ WRITEF(gmesa->buf, Light0ConstantAttenuation, 1.0);
+ WRITEF(gmesa->buf, Light0LinearAttenuation, 0.0);
+ WRITEF(gmesa->buf, Light0QuadraticAttenuation,0.0);
+
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITEF(gmesa->buf, XBias, 0.0);
+ WRITEF(gmesa->buf, YBias, 0.0);
+
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, ViewPortScaleX, gmesa->driScreen->fbWidth/4);
+ WRITEF(gmesa->buf, ViewPortScaleY, gmesa->driScreen->fbHeight/4);
+ WRITEF(gmesa->buf, ViewPortScaleZ, 1.0f);
+ WRITEF(gmesa->buf, ViewPortOffsetX, gmesa->x);
+ WRITEF(gmesa->buf, ViewPortOffsetY, gmesa->y);
+ WRITEF(gmesa->buf, ViewPortOffsetZ, 0.0f);
+
+ CHECK_DMA_BUFFER(gmesa, 3);
+ WRITEF(gmesa->buf, Nz, 1.0);
+ WRITEF(gmesa->buf, Ny, 0.0);
+ WRITEF(gmesa->buf, Nx, 0.0);
+
+ /* Send the initialization commands to the HW */
+ FLUSH_DMA_BUFFER(gmesa);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_lock.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_lock.c
new file mode 100644
index 000000000..4c0970f09
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_lock.c
@@ -0,0 +1,59 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_lock.c,v 1.4 2002/11/05 17:46:07 tsi Exp $ */
+
+#include "gamma_context.h"
+#include "gamma_lock.h"
+
+#ifdef DEBUG_LOCKING
+char *prevLockFile = NULL;
+int prevLockLine = 0;
+#endif
+
+
+/* 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.
+ */
+void gammaGetLock( gammaContextPtr gmesa, GLuint flags )
+{
+ __DRIdrawablePrivate *dPriv = gmesa->driDrawable;
+ __DRIscreenPrivate *sPriv = gmesa->driScreen;
+
+ drmGetLock( gmesa->driFd, gmesa->hHWContext, flags );
+
+ /* 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.
+ */
+ DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
+
+ if ( gmesa->lastStamp != dPriv->lastStamp ) {
+ gmesa->lastStamp = dPriv->lastStamp;
+ gmesa->new_state |= GAMMA_NEW_WINDOW | GAMMA_NEW_CLIP;
+ }
+
+ gmesa->numClipRects = dPriv->numClipRects;
+ gmesa->pClipRects = dPriv->pClipRects;
+
+#if 0
+ gmesa->dirty = ~0;
+
+ if ( sarea->ctxOwner != gmesa->hHWContext ) {
+ sarea->ctxOwner = gmesa->hHWContext;
+ gmesa->dirty = GAMMA_UPLOAD_ALL;
+ }
+
+ for ( i = 0 ; i < gmesa->lastTexHeap ; i++ ) {
+ if ( sarea->texAge[i] != gmesa->lastTexAge[i] ) {
+ gammaAgeTextures( gmesa, i );
+ }
+ }
+#endif
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_lock.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_lock.h
new file mode 100644
index 000000000..2d117320d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_lock.h
@@ -0,0 +1,84 @@
+#ifndef __GAMMA_LOCK_H__
+#define __GAMMA_LOCK_H__
+
+extern void gammaGetLock( gammaContextPtr gmesa, GLuint flags );
+
+/* Turn DEBUG_LOCKING on to find locking conflicts.
+ */
+#define DEBUG_LOCKING 0
+
+#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 and validate our state.
+ */
+#define LOCK_HARDWARE( gmesa ) \
+ do { \
+ char __ret = 0; \
+ DEBUG_CHECK_LOCK(); \
+ DRM_CAS( gmesa->driHwLock, gmesa->hHWContext, \
+ (DRM_LOCK_HELD | gmesa->hHWContext), __ret ); \
+ if ( __ret ) \
+ gammaGetLock( gmesa, 0 ); \
+ DEBUG_LOCK(); \
+ } while (0)
+
+/* Unlock the hardware.
+ */
+#define UNLOCK_HARDWARE( gmesa ) \
+ do { \
+ DRM_UNLOCK( gmesa->driFd, \
+ gmesa->driHwLock, \
+ gmesa->hHWContext ); \
+ DEBUG_RESET(); \
+ } while (0)
+
+#define GAMMAHW_LOCK( gmesa ) \
+ DRM_UNLOCK(gmesa->driFd, gmesa->driHwLock, gmesa->hHWContext); \
+ DRM_SPINLOCK(&gmesa->driScreen->pSAREA->drawable_lock, \
+ gmesa->driScreen->drawLockID); \
+ VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa);
+
+#define GAMMAHW_UNLOCK( gmesa ) \
+ DRM_SPINUNLOCK(&gmesa->driScreen->pSAREA->drawable_lock, \
+ gmesa->driScreen->drawLockID); \
+ VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa);
+
+#endif /* __GAMMA_LOCK_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_macros.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_macros.h
new file mode 100644
index 000000000..974fe569d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_macros.h
@@ -0,0 +1,324 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_macros.h,v 1.5 2002/02/22 21:33:02 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:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _GAMMA_MACROS_H_
+#define _GAMMA_MACROS_H_
+
+#define DEBUG_DRMDMA
+#define DEBUG_ERRORS
+#define DEBUG_COMMANDS_NOT
+#define DEBUG_VERBOSE_NOT
+#define DEBUG_VERBOSE_EXTRA_NOT
+
+#define RANDOMIZE_COLORS_NOT
+#define TURN_OFF_CLEARS_NOT
+#define CULL_ALL_PRIMS_NOT
+#define TURN_OFF_DEPTH_NOT
+#define TURN_OFF_BLEND_NOT
+#define FAST_CLEAR_4_NOT
+#define FORCE_DEPTH32_NOT
+#define DONT_SEND_DMA_NOT
+#define TURN_OFF_FCP_NOT
+#define TURN_OFF_TEXTURES_NOT
+#define DO_VALIDATE
+
+#define GAMMA_DMA_BUFFER_SIZE 4096
+
+#if 0
+#define GAMMA_DMA_SEND_FLAGS DRM_DMA_PRIORITY
+#define GAMMA_DMA_SEND_FLAGS DRM_DMA_BLOCK
+#else
+/* MUST use non-blocking dma flags for drawable lock routines */
+#define GAMMA_DMA_SEND_FLAGS 0
+#endif
+
+#if 0
+#define GAMMA_DMA_GET_FLAGS \
+ (DRM_DMA_SMALLER_OK | DRM_DMA_LARGER_OK | DRM_DMA_WAIT)
+#else
+#define GAMMA_DMA_GET_FLAGS DRM_DMA_WAIT
+#endif
+
+#if defined(DEBUG_DRMDMA) || defined(DEBUG_COMMANDS) || defined(DEBUG_VERBOSE)
+#include <stdio.h>
+#endif
+
+/* Note: The argument to DEBUG_GLCMDS() _must_ be enclosed in parenthesis */
+#ifdef DEBUG_VERBOSE
+#define DEBUG_GLCMDS(s) printf s
+#else
+#define DEBUG_GLCMDS(s)
+#endif
+
+/* Note: The argument to DEBUG_DMACMDS() _must_ be enclosed in parenthesis */
+#ifdef DEBUG_DRMDMA
+#define DEBUG_DMACMDS(s) printf s
+#else
+#define DEBUG_DMACMDS(s)
+#endif
+
+/* Note: The argument to DEBUG_WRITE() _must_ be enclosed in parenthesis */
+#ifdef DEBUG_COMMANDS
+#define DEBUG_WRITE(s) printf s
+#else
+#define DEBUG_WRITE(s)
+#endif
+
+/* Note: The argument to DEBUG_ERROR() _must_ be enclosed in parenthesis */
+#ifdef DEBUG_ERRORS
+#define DEBUG_ERROR(s) printf s
+#else
+#define DEBUG_ERROR(s)
+#endif
+
+#define WRITEV(buf,val1,val2,val3,val4) \
+do { \
+ buf++->i = 0x9C008300; \
+ buf++->f = val1; \
+ buf++->f = val2; \
+ buf++->f = val3; \
+ buf++->f = val4; \
+} while (0)
+
+#define WRITE(buf,reg,val) \
+do { \
+ buf++->i = Glint##reg##Tag; \
+ buf++->i = val; \
+ DEBUG_WRITE(("WRITE(buf, %s, 0x%08x);\n", #reg, (int)val)); \
+} while (0)
+
+#define WRITEF(buf,reg,val) \
+do { \
+ buf++->i = Glint##reg##Tag; \
+ buf++->f = val; \
+ DEBUG_WRITE(("WRITEF(buf, %s, %f);\n", #reg, (float)val)); \
+} while (0)
+
+#define CHECK_WC_DMA_BUFFER(gcp,n) \
+do { \
+ (gcp)->WCbufCount += (n<<1); \
+} while (0)
+
+#define CHECK_DMA_BUFFER(gcp,n) \
+do { \
+ if ((gcp)->bufCount+(n<<1) >= (gcp)->bufSize) \
+ PROCESS_DMA_BUFFER(gcp); \
+ (gcp)->bufCount += (n<<1); \
+} while (0)
+
+#define CHECK_DMA_BUFFER2(gcp,n) \
+do { \
+ if ((gcp)->bufCount+n >= (gcp)->bufSize) \
+ PROCESS_DMA_BUFFER(gcp); \
+ (gcp)->bufCount += n; \
+} while (0)
+
+#define FLUSH_DMA_BUFFER(gcp) \
+do { \
+ if (gcp->bufCount) \
+ PROCESS_DMA_BUFFER(gcp); \
+} while (0)
+
+#ifdef DONT_SEND_DMA
+#define GET_DMA(fd, hHWCtx, n, idx, size)
+#define SEND_DMA(fd, hHWCtx,n, idx, cnt)
+#else
+#define GET_DMA(fd, hHWCtx, n, idx, size) \
+do { \
+ drmDMAReq dma; \
+ int retcode, i; \
+ \
+ dma.context = (hHWCtx); \
+ dma.send_count = 0; \
+ dma.send_list = NULL; \
+ dma.send_sizes = NULL; \
+ dma.flags = GAMMA_DMA_GET_FLAGS; \
+ dma.request_count = (n); \
+ dma.request_size = GAMMA_DMA_BUFFER_SIZE; \
+ dma.request_list = (idx); \
+ dma.request_sizes = (size); \
+ \
+ do { \
+ if ((retcode = drmDMA((fd), &dma))) { \
+ DEBUG_DMACMDS(("drmDMA returned %d\n", retcode)); \
+ } \
+ } while (!(dma).granted_count); \
+ \
+ for (i = 0; i < (n); i++) { \
+ (size)[i] >>= 2; /* Convert from bytes to words */ \
+ } \
+} while (0)
+
+#define SEND_DMA(fd, hHWCtx, n, idx, cnt) \
+do { \
+ drmDMAReq dma; \
+ int retcode, i; \
+ \
+ for (i = 0; i < (n); i++) { \
+ (cnt)[i] <<= 2; /* Convert from words to bytes */ \
+ } \
+ \
+ dma.context = (hHWCtx); \
+ dma.send_count = 1; \
+ dma.send_list = (idx); \
+ dma.send_sizes = (cnt); \
+ dma.flags = GAMMA_DMA_SEND_FLAGS; \
+ dma.request_count = 0; \
+ dma.request_size = 0; \
+ dma.request_list = NULL; \
+ dma.request_sizes = NULL; \
+ \
+ if ((retcode = drmDMA((fd), &dma))) { \
+ DEBUG_DMACMDS(("drmDMA returned %d\n", retcode)); \
+ } \
+ \
+ for (i = 0; i < (n); i++) { \
+ (cnt)[i] = 0; \
+ } \
+} while (0)
+#endif
+
+#define GET_FIRST_DMA(fd, hHWCtx, n, idx, size, buf, cnt, gPriv) \
+do { \
+ int i; \
+ \
+ GET_DMA(fd, hHWCtx, n, idx, size); \
+ \
+ for (i = 0; i < (n); i++) { \
+ (buf)[i] = (dmaBuf)(gPriv)->bufs->list[(idx)[i]].address; \
+ (cnt)[i] = 0; \
+ } \
+} while (0)
+
+#define PROCESS_DMA_BUFFER_TOP_HALF(gcp) \
+do { \
+ SEND_DMA((gcp)->driFd, \
+ (gcp)->hHWContext, 1, &(gcp)->bufIndex, &(gcp)->bufCount); \
+} while (0)
+
+#define PROCESS_DMA_BUFFER_BOTTOM_HALF(gcp) \
+do { \
+ GET_DMA((gcp)->driFd, \
+ (gcp)->hHWContext, 1, &(gcp)->bufIndex, &(gcp)->bufSize); \
+ \
+ (gcp)->buf = \
+ (dmaBuf)(gcp)->gammaScreen->bufs->list[(gcp)->bufIndex].address; \
+} while (0)
+
+#define PROCESS_DMA_BUFFER(gcp) \
+do { \
+ VALIDATE_DRAWABLE_INFO(gcp); \
+ PROCESS_DMA_BUFFER_TOP_HALF(gcp); \
+ PROCESS_DMA_BUFFER_BOTTOM_HALF(gcp); \
+} while (0)
+
+#ifdef DO_VALIDATE
+#define VALIDATE_DRAWABLE_INFO_NO_LOCK(gcp) \
+do { \
+ /*__DRIscreenPrivate *psp = gcp->driScreen;*/ \
+ __DRIdrawablePrivate *pdp = gcp->driDrawable; \
+ \
+ if (*(pdp->pStamp) != pdp->lastStamp) { \
+ int old_index = pdp->index; \
+ while (*(pdp->pStamp) != pdp->lastStamp) { \
+ DRI_VALIDATE_DRAWABLE_INFO_ONCE(pdp); \
+ } \
+ if (pdp->index != old_index) { \
+ gcp->Window &= ~W_GIDMask; \
+ gcp->Window |= (pdp->index << 5); \
+ CHECK_WC_DMA_BUFFER(gcp, 1); \
+ WRITE(gcp->WCbuf, GLINTWindow, gcp->Window|(gcp->FrameCount<<9));\
+ } \
+ \
+ gammaUpdateViewportOffset( gcp->glCtx); \
+ \
+ if (pdp->numClipRects == 1 && \
+ pdp->pClipRects->x1 == pdp->x && \
+ pdp->pClipRects->x2 == (pdp->x+pdp->w) && \
+ pdp->pClipRects->y1 == pdp->y && \
+ pdp->pClipRects->y2 == (pdp->y+pdp->h)) { \
+ CHECK_WC_DMA_BUFFER(gcp, 1); \
+ WRITE(gcp->WCbuf, Rectangle2DControl, 0); \
+ gcp->NotClipped = GL_TRUE; \
+ } else { \
+ CHECK_WC_DMA_BUFFER(gcp, 1); \
+ WRITE(gcp->WCbuf, Rectangle2DControl, 1); \
+ gcp->NotClipped = GL_FALSE; \
+ } \
+ gcp->WindowChanged = GL_TRUE; \
+ \
+ if (gcp->WCbufCount) { \
+ SEND_DMA((gcp)->gammaScreen->driScreen->fd, \
+ (gcp)->hHWContext, 1, &(gcp)->WCbufIndex, \
+ &(gcp)->WCbufCount); \
+ (gcp)->WCbufIndex = -1; \
+ } \
+ } \
+} while (0)
+
+#define VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gcp) \
+do { \
+ if ((gcp)->WCbufIndex < 0) { \
+ GET_DMA((gcp)->gammaScreen->driScreen->fd, \
+ (gcp)->hHWContext, 1, &(gcp)->WCbufIndex, \
+ &(gcp)->WCbufSize); \
+ \
+ (gcp)->WCbuf = \
+ (dmaBuf)(gcp)->gammaScreen->bufs-> \
+ list[(gcp)->WCbufIndex].address; \
+ } \
+} while (0)
+
+#define VALIDATE_DRAWABLE_INFO(gcp) \
+do { \
+ __DRIscreenPrivate *psp = gcp->driScreen; \
+if (gcp->driDrawable) { \
+ DRM_SPINLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
+ VALIDATE_DRAWABLE_INFO_NO_LOCK(gcp); \
+ DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); \
+ VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gcp); \
+} \
+} while (0)
+#else
+#define VALIDATE_DRAWABLE_INFO(gcp)
+#endif
+
+#define CALC_LOG2(l2,s) \
+do { \
+ int __s = s; \
+ l2 = 0; \
+ while (__s > 1) { ++l2; __s >>= 1; } \
+} while (0)
+
+#endif /* _GAMMA_MACROS_H_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_regs.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_regs.h
new file mode 100644
index 000000000..2edda0722
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_regs.h
@@ -0,0 +1,659 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_regs.h,v 1.5 2002/02/22 21:33:02 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:
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _GAMMA_REGS_H_
+#define _GAMMA_REGS_H_
+
+#include "gamma_client.h"
+
+/**************** MX FLAGS ****************/
+/* FBReadMode */
+#define FBReadSrcDisable 0x00000000
+#define FBReadSrcEnable 0x00000200
+#define FBReadDstDisable 0x00000000
+#define FBReadDstEnable 0x00000400
+#define FBDataTypeDefault 0x00000000
+#define FBDataTypeColor 0x00008000
+#define FBWindowOriginTop 0x00000000
+#define FBWindowOriginBot 0x00010000
+#define FBScanLineInt1 0x00000000
+#define FBScanLineInt2 0x00800000
+#define FBScanLineInt4 0x01000000
+#define FBScanLineInt8 0x01800000
+#define FBSrcAddrConst 0x00000000
+#define FBSrcAddrIndex 0x10000000
+#define FBSrcAddrCoord 0x20000000
+
+/* LBReadMode */
+#define LBPartialProdMask 0x000001ff
+#define LBReadSrcDisable 0x00000000
+#define LBReadSrcEnable 0x00000200
+#define LBReadDstDisable 0x00000000
+#define LBReadDstEnable 0x00000400
+#define LBDataTypeDefault 0x00000000
+#define LBDataTypeStencil 0x00010000
+#define LBDataTypeDepth 0x00020000
+#define LBWindowOriginTop 0x00000000
+#define LBWindowOriginBot 0x00040000
+#define LBScanLineInt1 0x00000000
+#define LBScanLineInt2 0x00100000
+#define LBScanLineInt4 0x00200000
+#define LBScanLineInt8 0x00300000
+
+/* ColorDDAMode */
+#define ColorDDADisable 0x00000000
+#define ColorDDAEnable 0x00000001
+#define ColorDDAFlat 0x00000000
+#define ColorDDAGouraud 0x00000002
+#define ColorDDAShadingMask 0x00000002
+
+/* AlphaTestMode */
+#define AlphaTestModeDisable 0x00000000
+#define AlphaTestModeEnable 0x00000001
+#define AT_Never 0x00000000
+#define AT_Less 0x00000002
+#define AT_Equal 0x00000004
+#define AT_LessEqual 0x00000006
+#define AT_Greater 0x00000008
+#define AT_NotEqual 0x0000000a
+#define AT_GreaterEqual 0x0000000c
+#define AT_Always 0x0000000e
+#define AT_CompareMask 0x0000000e
+#define AT_RefValueMask 0x00000ff0
+
+/* AlphaBlendMode */
+#define AlphaBlendModeDisable 0x00000000
+#define AlphaBlendModeEnable 0x00000001
+#define AB_Src_Zero 0x00000000
+#define AB_Src_One 0x00000002
+#define AB_Src_DstColor 0x00000004
+#define AB_Src_OneMinusDstColor 0x00000006
+#define AB_Src_SrcAlpha 0x00000008
+#define AB_Src_OneMinusSrcAlpha 0x0000000a
+#define AB_Src_DstAlpha 0x0000000c
+#define AB_Src_OneMinusDstAlpha 0x0000000e
+#define AB_Src_SrcAlphaSaturate 0x00000010
+#define AB_SrcBlendMask 0x0000001e
+#define AB_Dst_Zero 0x00000000
+#define AB_Dst_One 0x00000020
+#define AB_Dst_SrcColor 0x00000040
+#define AB_Dst_OneMinusSrcColor 0x00000060
+#define AB_Dst_SrcAlpha 0x00000080
+#define AB_Dst_OneMinusSrcAlpha 0x000000a0
+#define AB_Dst_DstAlpha 0x000000c0
+#define AB_Dst_OneMinusDstAlpha 0x000000e0
+#define AB_DstBlendMask 0x000000e0
+#define AB_ColorFmt_8888 0x00000000
+#define AB_ColorFmt_5555 0x00000100
+#define AB_ColorFmt_4444 0x00000200
+#define AB_ColorFmt_4444Front 0x00000300
+#define AB_ColorFmt_4444Back 0x00000400
+#define AB_ColorFmt_332Front 0x00000500
+#define AB_ColorFmt_332Back 0x00000600
+#define AB_ColorFmt_121Front 0x00000700
+#define AB_ColorFmt_121Back 0x00000800
+#define AB_ColorFmt_555Back 0x00000d00
+#define AB_ColorFmt_CI8 0x00000e00
+#define AB_ColorFmt_CI4 0x00000f00
+#define AB_AlphaBufferPresent 0x00000000
+#define AB_NoAlphaBufferPresent 0x00001000
+#define AB_ColorOrder_BGR 0x00000000
+#define AB_ColorOrder_RGB 0x00002000
+#define AB_OpenGLType 0x00000000
+#define AB_QuickDraw3DType 0x00004000
+#define AB_AlphaDst_FBData 0x00000000
+#define AB_AlphaDst_FBSourceData 0x00008000
+#define AB_ColorConversionScale 0x00000000
+#define AB_ColorConversionShift 0x00010000
+#define AB_AlphaConversionScale 0x00000000
+#define AB_AlphaConversionShift 0x00020000
+
+/* AntialiasMode */
+#define AntialiasModeDisable 0x00000000
+#define AntialiasModeEnable 0x00000001
+
+/* AreaStippleMode */
+#define AreaStippleModeDisable 0x00000000
+#define AreaStippleModeEnable 0x00000001
+#define ASM_X32 0x00000008
+#define ASM_Y32 0x00000040
+
+/* DepthMode */
+#define DepthModeDisable 0x00000000
+#define DepthModeEnable 0x00000001
+#define DM_WriteMask 0x00000002
+#define DM_SourceFragment 0x00000000
+#define DM_SourceLBData 0x00000004
+#define DM_SourceDepthRegister 0x00000008
+#define DM_SourceLBSourceData 0x0000000c
+#define DM_SourceMask 0x0000000c
+#define DM_Never 0x00000000
+#define DM_Less 0x00000010
+#define DM_Equal 0x00000020
+#define DM_LessEqual 0x00000030
+#define DM_Greater 0x00000040
+#define DM_NotEqual 0x00000050
+#define DM_GreaterEqual 0x00000060
+#define DM_Always 0x00000070
+#define DM_CompareMask 0x00000070
+
+/* FBWriteMode */
+#define FBWriteModeDisable 0x00000000
+#define FBWriteModeEnable 0x00000001
+#define FBW_UploadColorData 0x00000008
+
+/* FogMode */
+#define FogModeDisable 0x00000000
+#define FogModeEnable 0x00000001
+
+/* LBWriteMode */
+#define LBWriteModeDisable 0x00000000
+#define LBWriteModeEnable 0x00000001
+#define LBW_UploadNone 0x00000000
+#define LBW_UploadDepth 0x00000002
+#define LBW_UploadStencil 0x00000004
+
+/* LBRead/Write Format */
+#define LBRF_DepthWidth15 0x03 /* only permedia */
+#define LBRF_DepthWidth16 0x00
+#define LBRF_DepthWidth24 0x01
+#define LBRF_DepthWidth32 0x02
+#define LBRF_StencilWidth0 (0 << 2)
+#define LBRF_StencilWidth4 (1 << 2)
+#define LBRF_StencilWidth8 (2 << 2)
+#define LBRF_StencilPos16 (0 << 4)
+#define LBRF_StencilPos20 (1 << 4)
+#define LBRF_StencilPos24 (2 << 4)
+#define LBRF_StencilPos28 (3 << 4)
+#define LBRF_StencilPos32 (4 << 4)
+#define LBRF_FrameCount0 (0 << 7)
+#define LBRF_FrameCount4 (1 << 7)
+#define LBRF_FrameCount8 (2 << 7)
+#define LBRF_FrameCountPos16 (0 << 9)
+#define LBRF_FrameCountPos20 (1 << 9)
+#define LBRF_FrameCountPos24 (2 << 9)
+#define LBRF_FrameCountPos28 (3 << 9)
+#define LBRF_FrameCountPos32 (4 << 9)
+#define LBRF_FrameCountPos36 (5 << 9)
+#define LBRF_FrameCountPos40 (6 << 9)
+#define LBRF_GIDWidth0 (0 << 12)
+#define LBRF_GIDWidth4 (1 << 12)
+#define LBRF_GIDPos16 (0 << 13)
+#define LBRF_GIDPos20 (1 << 13)
+#define LBRF_GIDPos24 (2 << 13)
+#define LBRF_GIDPos28 (3 << 13)
+#define LBRF_GIDPos32 (4 << 13)
+#define LBRF_GIDPos36 (5 << 13)
+#define LBRF_GIDPos40 (6 << 13)
+#define LBRF_GIDPos44 (7 << 13)
+#define LBRF_GIDPos48 (8 << 13)
+#define LBRF_Compact32 (1 << 17)
+
+/* StencilMode */
+#define StencilDisable 0x00000000
+#define StencilEnable 0x00000001
+
+/* RouterMode */
+#define R_Order_TextureDepth 0x00000000
+#define R_Order_DepthTexture 0x00000001
+
+/* ScissorMode */
+#define UserScissorDisable 0x00000000
+#define UserScissorEnable 0x00000001
+#define ScreenScissorDisable 0x00000000
+#define ScreenScissorEnable 0x00000002
+
+/* DitherMode */
+#define DitherModeDisable 0x00000000
+#define DitherModeEnable 0x00000001
+#define DM_DitherDisable 0x00000000
+#define DM_DitherEnable 0x00000002
+#define DM_ColorFmt_8888 0x00000000
+#define DM_ColorFmt_5555 0x00000004
+#define DM_ColorFmt_4444 0x00000008
+#define DM_ColorFmt_4444Front 0x0000000c
+#define DM_ColorFmt_4444Back 0x00000010
+#define DM_ColorFmt_332Front 0x00000014
+#define DM_ColorFmt_332Back 0x00000018
+#define DM_ColorFmt_121Front 0x0000001c
+#define DM_ColorFmt_121Back 0x00000020
+#define DM_ColorFmt_555Back 0x00000024
+#define DM_ColorFmt_CI8 0x00000028
+#define DM_ColorFmt_CI4 0x0000002c
+#define DM_XOffsetMask 0x000000c0
+#define DM_YOffsetMask 0x00000300
+#define DM_ColorOrder_BGR 0x00000000
+#define DM_ColorOrder_RGB 0x00000400
+#define DM_AlphaDitherDefault 0x00000000
+#define DM_AlphaDitherNone 0x00004000
+#define DM_Truncate 0x00000000
+#define DM_Round 0x00008000
+
+/* RasterizerMode */
+#define RM_MirrorBitMask 0x00000001
+#define RM_InvertBitMask 0x00000002
+#define RM_FractionAdjNo 0x00000000
+#define RM_FractionAdjZero 0x00000004
+#define RM_FractionAdjHalf 0x00000008
+#define RM_FractionAdjNearHalf 0x0000000c
+#define RM_BiasCoordZero 0x00000000
+#define RM_BiasCoordHalf 0x00000010
+#define RM_BiasCoordNearHalf 0x00000020
+#define RM_BitMaskByteSwap_ABCD 0x00000000
+#define RM_BitMaskByteSwap_BADC 0x00000080
+#define RM_BitMaskByteSwap_CDAB 0x00000100
+#define RM_BitMaskByteSwap_DCBA 0x00000180
+#define RM_BitMaskPacked 0x00000000
+#define RM_BitMaskEveryScanline 0x00000200
+#define RM_BitMaskOffsetMask 0x00007c00
+#define RM_HostDataByteSwap_ABCD 0x00000000
+#define RM_HostDataByteSwap_BADC 0x00008000
+#define RM_HostDataByteSwap_CDAB 0x00010000
+#define RM_HostDataByteSwap_DCBA 0x00018000
+#define RM_SingleGLINT 0x00000000
+#define RM_MultiGLINT 0x00020000
+#define RM_YLimitsEnable 0x00040000
+
+/* Window */
+#define WindowDisable 0x00000000
+#define WindowEnable 0x00000001
+#define W_AlwaysPass 0x00000000
+#define W_NeverPass 0x00000002
+#define W_PassIfEqual 0x00000004
+#define W_PassIfNotEqual 0x00000006
+#define W_CompareMask 0x00000006
+#define W_ForceLBUpdate 0x00000008
+#define W_LBUpdateFromSource 0x00000000
+#define W_LBUpdateFromRegisters 0x00000010
+#define W_GIDMask 0x000001e0
+#define W_FrameCountMask 0x0001fe00
+#define W_StencilFCP 0x00020000
+#define W_DepthFCP 0x00040000
+#define W_OverrideWriteFiltering 0x00080000
+
+/* TextureAddressMode */
+#define TextureAddressModeDisable 0x00000000
+#define TextureAddressModeEnable 0x00000001
+#define TAM_SWrap_Clamp 0x00000000
+#define TAM_SWrap_Repeat 0x00000002
+#define TAM_SWrap_Mirror 0x00000004
+#define TAM_SWrap_Mask 0x00000006
+#define TAM_TWrap_Clamp 0x00000000
+#define TAM_TWrap_Repeat 0x00000008
+#define TAM_TWrap_Mirror 0x00000010
+#define TAM_TWrap_Mask 0x00000018
+#define TAM_Operation_2D 0x00000000
+#define TAM_Operation_3D 0x00000020
+#define TAM_InhibitDDAInit 0x00000040
+#define TAM_LODDisable 0x00000000
+#define TAM_LODEnable 0x00000080
+#define TAM_DY_Disable 0x00000000
+#define TAM_DY_Enable 0x00000100
+#define TAM_WidthMask 0x00001e00
+#define TAM_HeightMask 0x0001e000
+#define TAM_TexMapType_1D 0x00000000
+#define TAM_TexMapType_2D 0x00020000
+#define TAM_TexMapType_Mask 0x00020000
+
+/* TextureReadMode */
+#define TextureReadModeDisable 0x00000000
+#define TextureReadModeEnable 0x00000001
+#define TRM_WidthMask 0x0000001e
+#define TRM_HeightMask 0x000001e0
+#define TRM_Depth1 0x00000000
+#define TRM_Depth2 0x00000200
+#define TRM_Depth4 0x00000400
+#define TRM_Depth8 0x00000600
+#define TRM_Depth16 0x00000800
+#define TRM_Depth32 0x00000a00
+#define TRM_DepthMask 0x00000e00
+#define TRM_Border 0x00001000
+#define TRM_Patch 0x00002000
+#define TRM_Mag_Nearest 0x00000000
+#define TRM_Mag_Linear 0x00004000
+#define TRM_Mag_Mask 0x00004000
+#define TRM_Min_Nearest 0x00000000
+#define TRM_Min_Linear 0x00008000
+#define TRM_Min_NearestMMNearest 0x00010000
+#define TRM_Min_NearestMMLinear 0x00018000
+#define TRM_Min_LinearMMNearest 0x00020000
+#define TRM_Min_LinearMMLinear 0x00028000
+#define TRM_Min_Mask 0x00038000
+#define TRM_UWrap_Clamp 0x00000000
+#define TRM_UWrap_Repeat 0x00040000
+#define TRM_UWrap_Mirror 0x00080000
+#define TRM_UWrap_Mask 0x000c0000
+#define TRM_VWrap_Clamp 0x00000000
+#define TRM_VWrap_Repeat 0x00100000
+#define TRM_VWrap_Mirror 0x00200000
+#define TRM_VWrap_Mask 0x00300000
+#define TRM_TexMapType_1D 0x00000000
+#define TRM_TexMapType_2D 0x00400000
+#define TRM_TexMapType_Mask 0x00400000
+#define TRM_MipMapDisable 0x00000000
+#define TRM_MipMapEnable 0x00800000
+#define TRM_PrimaryCacheDisable 0x00000000
+#define TRM_PrimaryCacheEnable 0x01000000
+#define TRM_FBSourceAddr_None 0x00000000
+#define TRM_FBSourceAddr_Index 0x02000000
+#define TRM_FBSourceAddr_Coord 0x04000000
+#define TRM_BorderClamp 0x08000000
+
+/* TextureColorMode */
+#define TextureColorModeDisable 0x00000000
+#define TextureColorModeEnable 0x00000001
+#define TCM_Modulate 0x00000000
+#define TCM_Decal 0x00000002
+#define TCM_Blend 0x00000004
+#define TCM_Replace 0x00000006
+#define TCM_ApplicationMask 0x0000000e
+#define TCM_OpenGLType 0x00000000
+#define TCM_QuickDraw3DType 0x00000010
+#define TCM_KdDDA_Disable 0x00000000
+#define TCM_KdDDA_Enable 0x00000020
+#define TCM_KsDDA_Disable 0x00000000
+#define TCM_KsDDA_Enable 0x00000040
+#define TCM_BaseFormat_Alpha 0x00000000
+#define TCM_BaseFormat_Lum 0x00000080
+#define TCM_BaseFormat_LumAlpha 0x00000100
+#define TCM_BaseFormat_Intensity 0x00000180
+#define TCM_BaseFormat_RGB 0x00000200
+#define TCM_BaseFormat_RGBA 0x00000280
+#define TCM_BaseFormatMask 0x00000380
+#define TCM_LoadMode_None 0x00000000
+#define TCM_LoadMode_Ks 0x00000400
+#define TCM_LoadMode_Kd 0x00000800
+
+/* TextureCacheControl */
+#define TCC_Invalidate 0x00000001
+#define TCC_Disable 0x00000000
+#define TCC_Enable 0x00000002
+
+/* TextureFilterMode */
+#define TextureFilterModeDisable 0x00000000
+#define TextureFilterModeEnable 0x00000001
+#define TFM_AlphaMapEnable 0x00000002
+#define TFM_AlphaMapSense 0x00000004
+
+/* TextureFormat */
+#define TF_LittleEndian 0x00000000
+#define TF_BigEndian 0x00000001
+#define TF_16Bit_565 0x00000000
+#define TF_16Bit_555 0x00000002
+#define TF_ColorOrder_BGR 0x00000000
+#define TF_ColorOrder_RGB 0x00000004
+#define TF_Compnents_1 0x00000000
+#define TF_Compnents_2 0x00000008
+#define TF_Compnents_3 0x00000010
+#define TF_Compnents_4 0x00000018
+#define TF_CompnentsMask 0x00000018
+#define TF_OutputFmt_Texel 0x00000000
+#define TF_OutputFmt_Color 0x00000020
+#define TF_OutputFmt_BitMask 0x00000040
+#define TF_OutputFmtMask 0x00000060
+#define TF_MirrorEnable 0x00000080
+#define TF_InvertEnable 0x00000100
+#define TF_ByteSwapEnable 0x00000200
+#define TF_LUTOffsetMask 0x0003fc00
+#define TF_OneCompFmt_Lum 0x00000000
+#define TF_OneCompFmt_Alpha 0x00040000
+#define TF_OneCompFmt_Intensity 0x00080000
+#define TF_OneCompFmt_Mask 0x000c0000
+/**************** MX FLAGS ****************/
+
+/************** GAMMA FLAGS ***************/
+/* GeometryMode */
+#define GM_TextureDisable 0x00000000
+#define GM_TextureEnable 0x00000001
+#define GM_FogDisable 0x00000000
+#define GM_FogEnable 0x00000002
+#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
+#define GM_PolyCullBack 0x00000400
+#define GM_PolyCullBoth 0x00000800
+#define GM_PolyCullMask 0x00000c00
+#define GM_ClipShortLinesDisable 0x00000000
+#define GM_ClipShortLinesEnable 0x00001000
+#define GM_ClipSmallTrisDisable 0x00000000
+#define GM_ClipSmallTrisEnable 0x00002000
+#define GM_RenderMode 0x00000000
+#define GM_SelectMode 0x00004000
+#define GM_FeedbackMode 0x00008000
+#define GM_Feedback2D 0x00000000
+#define GM_Feedback3D 0x00010000
+#define GM_Feedback3DColor 0x00020000
+#define GM_Feedback3DColorTexture 0x00030000
+#define GM_Feedback4DColorTexture 0x00040000
+#define GM_CullFaceNormDisable 0x00000000
+#define GM_CullFaceNormEnable 0x00080000
+#define GM_AutoFaceNormDisable 0x00000000
+#define GM_AutoFaceNormEnable 0x00100000
+#define GM_GouraudShading 0x00000000
+#define GM_FlatShading 0x00200000
+#define GM_ShadingMask 0x00200000
+#define GM_UserClipNone 0x00000000
+#define GM_UserClip0 0x00400000
+#define GM_UserClip1 0x00800000
+#define GM_UserClip2 0x01000000
+#define GM_UserClip3 0x02000000
+#define GM_UserClip4 0x04000000
+#define GM_UserClip5 0x08000000
+#define GM_PolyOffsetPointDisable 0x00000000
+#define GM_PolyOffsetPointEnable 0x10000000
+#define GM_PolyOffsetLineDisable 0x00000000
+#define GM_PolyOffsetLineEnable 0x20000000
+#define GM_PolyOffsetFillDisable 0x00000000
+#define GM_PolyOffsetFillEnable 0x40000000
+#define GM_InvertFaceNormCullDisable 0x00000000
+#define GM_InvertFaceNormCullEnable 0x80000000
+
+/* Begin */
+#define B_AreaStippleDisable 0x00000000
+#define B_AreaStippleEnable 0x00000001
+#define B_LineStippleDisable 0x00000000
+#define B_LineStippleEnable 0x00000002
+#define B_AntiAliasDisable 0x00000000
+#define B_AntiAliasEnable 0x00000100
+#define B_TextureDisable 0x00000000
+#define B_TextureEnable 0x00002000
+#define B_FogDisable 0x00000000
+#define B_FogEnable 0x00004000
+#define B_SubPixelCorrectDisable 0x00000000
+#define B_SubPixelCorrectEnable 0x00010000
+#define B_PrimType_Null 0x00000000
+#define B_PrimType_Points 0x10000000
+#define B_PrimType_Lines 0x20000000
+#define B_PrimType_LineLoop 0x30000000
+#define B_PrimType_LineStrip 0x40000000
+#define B_PrimType_Triangles 0x50000000
+#define B_PrimType_TriangleStrip 0x60000000
+#define B_PrimType_TriangleFan 0x70000000
+#define B_PrimType_Quads 0x80000000
+#define B_PrimType_QuadStrip 0x90000000
+#define B_PrimType_Polygon 0xa0000000
+#define B_PrimType_Mask 0xf0000000
+
+/* EdgeFlag */
+#define EdgeFlagDisable 0x00000000
+#define EdgeFlagEnable 0x00000001
+
+/* NormalizeMode */
+#define NormalizeModeDisable 0x00000000
+#define NormalizeModeEnable 0x00000001
+#define FaceNormalDisable 0x00000000
+#define FaceNormalEnable 0x00000002
+#define InvertAutoFaceNormal 0x00000004
+
+/* LightingMode */
+#define LightingModeDisable 0x00000000
+#define LightingModeEnable 0x00000001
+#define LightingModeTwoSides 0x00000004
+#define LightingModeLocalViewer 0x00000008
+#define LightingModeSpecularEnable 0x00008000
+
+/* 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_Target500TXMX 0x00000001
+#define DM_Depth16 0x00000004
+#define DM_Depth24 0x00000008
+#define DM_Depth32 0x0000000c
+#define DM_FogEnable 0x00000010
+#define DM_TextureEnable 0x00000020
+#define DM_SmoothShadingEnable 0x00000040
+#define DM_DepthEnable 0x00000080
+#define DM_SpecularEnable 0x00000100
+#define DM_DiffuseEnable 0x00000200
+#define DM_SubPixlCorrectionEnable 0x00000400
+#define DM_DiamondExit 0x00000800
+#define DM_NoDraw 0x00001000
+#define DM_ClampEnable 0x00002000
+#define DM_TextureParameterAsGiven 0x00000000
+#define DM_TextureParameterClamped 0x00004000
+#define DM_TextureParameterNormalized 0x00008000
+#define DM_BiasCoords 0x00080000
+#define DM_ColorDiffuse 0x00100000
+#define DM_ColorSpecular 0x00200000
+#define DM_FlatShadingMethod 0x00400000
+
+/* PointMode */
+#define PM_AntialiasDisable 0x00000000
+#define PM_AntialiasEnable 0x00000001
+#define PM_AntialiasQuality_4x4 0x00000000
+#define PM_AntialiasQuality_8x8 0x00000002
+
+/* LogicalOpMode */
+#define LogicalOpModeDisable 0x00000000
+#define LogicalOpModeEnable 0x00000001
+#define LogicalOpModeMask 0x0000001e
+
+/* LineMode */
+#define LM_StippleDisable 0x00000000
+#define LM_StippleEnable 0x00000001
+#define LM_RepeatFactorMask 0x000003fe
+#define LM_StippleMask 0x03fffc00
+#define LM_MirrorDisable 0x00000000
+#define LM_MirrorEnable 0x04000000
+#define LM_AntialiasDisable 0x00000000
+#define LM_AntialiasEnable 0x08000000
+#define LM_AntialiasQuality_4x4 0x00000000
+#define LM_AntialiasQuality_8x8 0x10000000
+
+/* TriangleMode */
+#define TM_AntialiasDisable 0x00000000
+#define TM_AntialiasEnable 0x00000001
+#define TM_AntialiasQuality_4x4 0x00000000
+#define TM_AntialiasQuality_8x8 0x00000002
+#define TM_UseTriPacketInterface 0x00000004
+
+/* TransformMode */
+#define XM_UseModelViewMatrix 0x00000001
+#define XM_UseModelViewProjMatrix 0x00000002
+#define XM_XformNormals 0x00000004
+#define XM_XformFaceNormals 0x00000008
+#define XM_XformTexture 0x00000010
+#define XM_XMask 0x00000013
+#define XM_TexGenModeS_None 0x00000000
+#define XM_TexGenModeS_ObjLinear 0x00000020
+#define XM_TexGenModeS_EyeLinear 0x00000040
+#define XM_TexGenModeS_SphereMap 0x00000060
+#define XM_TexGenModeT_None 0x00000000
+#define XM_TexGenModeT_ObjLinear 0x00000080
+#define XM_TexGenModeT_EyeLinear 0x00000100
+#define XM_TexGenModeT_SphereMap 0x00000180
+#define XM_TexGenModeR_None 0x00000000
+#define XM_TexGenModeR_ObjLinear 0x00000200
+#define XM_TexGenModeR_EyeLinear 0x00000400
+#define XM_TexGenModeR_SphereMap 0x00000600
+#define XM_TexGenModeQ_None 0x00000000
+#define XM_TexGenModeQ_ObjLinear 0x00000800
+#define XM_TexGenModeQ_EyeLinear 0x00001000
+#define XM_TexGenModeQQSphereMap 0x00001800
+#define XM_TexGenS 0x00002000
+#define XM_TexGenT 0x00004000
+#define XM_TexGenR 0x00008000
+#define XM_TexGenQ 0x00010000
+
+/* LightNMode */
+#define LNM_Off 0x00000000
+#define LNM_On 0x00000001
+/************** GAMMA FLAGS ***************/
+
+#endif /* _GAMMA_REGS_H_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_render.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_render.c
new file mode 100644
index 000000000..4b462f225
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_render.c
@@ -0,0 +1,220 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * 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@tungstengraphics.com>
+ *
+ * 3DLabs Gamma driver.
+ *
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+
+#include "tnl/t_context.h"
+
+#include "gamma_context.h"
+#include "gamma_tris.h"
+#include "gamma_vb.h"
+
+
+/* !! Should template this eventually !! */
+
+static void gamma_emit( GLcontext *ctx, GLuint start, GLuint end)
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLfloat (*coord)[4];
+ GLuint coord_stride;
+ GLfloat (*col)[4];
+ GLuint col_stride;
+ int i;
+ GLuint tc0_stride = 0;
+ GLfloat (*tc0)[4] = 0;
+ GLuint tc0_size = 0;
+
+ col = VB->ColorPtr[0]->data;
+ col_stride = VB->ColorPtr[0]->stride;
+
+ if (ctx->Texture.Unit[0]._ReallyEnabled) {
+ tc0_stride = VB->TexCoordPtr[0]->stride;
+ tc0 = VB->TexCoordPtr[0]->data;
+ tc0_size = VB->TexCoordPtr[0]->size;
+ coord = VB->ClipPtr->data;
+ coord_stride = VB->ClipPtr->stride;
+ } else {
+ coord = VB->NdcPtr->data;
+ coord_stride = VB->NdcPtr->stride;
+ }
+
+ if (ctx->Texture.Unit[0]._ReallyEnabled && tc0_size == 4) {
+ for (i=start; i < end; i++) {
+ CHECK_DMA_BUFFER(gmesa, 9);
+ WRITEF(gmesa->buf, Tq4, tc0[i][3]);
+ WRITEF(gmesa->buf, Tr4, tc0[i][2]);
+ WRITEF(gmesa->buf, Tt4, tc0[i][0]);
+ WRITEF(gmesa->buf, Ts4, tc0[i][1]);
+ WRITE(gmesa->buf, PackedColor4, *(u_int32_t*)col[i]);
+ WRITEF(gmesa->buf, Vw, coord[i][3]);
+ WRITEF(gmesa->buf, Vz, coord[i][2]);
+ WRITEF(gmesa->buf, Vy, coord[i][1]);
+ WRITEF(gmesa->buf, Vx4, coord[i][0]);
+ }
+ } else if (ctx->Texture.Unit[0]._ReallyEnabled && tc0_size == 2) {
+ for (i=start; i < end; i++) {
+ CHECK_DMA_BUFFER(gmesa, 7);
+ WRITEF(gmesa->buf, Tt2, tc0[i][0]);
+ WRITEF(gmesa->buf, Ts2, tc0[i][1]);
+ WRITE(gmesa->buf, PackedColor4, *(u_int32_t*)col[i]);
+ WRITEF(gmesa->buf, Vw, coord[i][3]);
+ WRITEF(gmesa->buf, Vz, coord[i][2]);
+ WRITEF(gmesa->buf, Vy, coord[i][1]);
+ WRITEF(gmesa->buf, Vx4, coord[i][0]);
+ }
+ } else {
+ for (i=start; i < end; i++) {
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITE(gmesa->buf, PackedColor4, *(u_int32_t*)col[i]);
+ WRITEF(gmesa->buf, Vz, coord[i][2]);
+ WRITEF(gmesa->buf, Vy, coord[i][1]);
+ WRITEF(gmesa->buf, Vx3, coord[i][0]);
+ }
+ }
+}
+
+#define HAVE_POINTS 1
+#define HAVE_LINES 1
+#define HAVE_LINE_STRIPS 1
+#define HAVE_TRIANGLES 1
+#define HAVE_TRI_STRIPS 1
+#define HAVE_TRI_STRIP_1 0
+#define HAVE_TRI_FANS 1
+#define HAVE_QUADS 1
+#define HAVE_QUAD_STRIPS 1
+#define HAVE_POLYGONS 1
+
+#define HAVE_ELTS 0
+
+
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ B_PrimType_Points,
+ B_PrimType_Lines,
+ B_PrimType_LineLoop,
+ B_PrimType_LineStrip,
+ B_PrimType_Triangles,
+ B_PrimType_TriangleStrip,
+ B_PrimType_TriangleFan,
+ B_PrimType_Quads,
+ B_PrimType_QuadStrip,
+ B_PrimType_Polygon
+};
+
+static __inline void gammaStartPrimitive( gammaContextPtr gmesa, GLenum prim )
+{
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Begin, gmesa->Begin | hw_prim[prim]);
+}
+
+static __inline void gammaEndPrimitive( gammaContextPtr gmesa )
+{
+ GLcontext *ctx = gmesa->glCtx;
+
+ if ( ctx->Line.SmoothFlag ||
+ ctx->Polygon.SmoothFlag ||
+ ctx->Point.SmoothFlag ) {
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, FlushSpan, 0);
+ }
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, End, 0);
+}
+
+#define LOCAL_VARS gammaContextPtr gmesa = GAMMA_CONTEXT(ctx)
+#define INIT( prim ) gammaStartPrimitive( gmesa, prim )
+#define FLUSH() gammaEndPrimitive( gmesa )
+#define GET_CURRENT_VB_MAX_VERTS() \
+ (gmesa->bufSize - gmesa->bufCount) / 2
+#define GET_SUBSEQUENT_VB_MAX_VERTS() \
+ GAMMA_DMA_BUFFER_SIZE / 2
+
+#define ALLOC_VERTS( nr ) (void *)0 /* todo: explicit alloc */
+#define EMIT_VERTS( ctx, j, nr, buf ) (gamma_emit(ctx, j, (j)+(nr)), (void *)0)
+
+#define TAG(x) gamma_##x
+#include "tnl_dd/t_dd_dmatmp.h"
+
+
+/**********************************************************************/
+/* Render pipeline stage */
+/**********************************************************************/
+
+
+static GLboolean gamma_run_render( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i;
+ tnl_render_func *tab;
+
+ /* GH: THIS IS A HACK!!! */
+ if (VB->ClipOrMask || gmesa->RenderIndex != 0)
+ return GL_TRUE; /* don't handle clipping here */
+
+ /* We don't do elts */
+ if (VB->Elts || !gamma_validate_render( ctx, VB ))
+ return GL_TRUE;
+
+ tab = TAG(render_tab_verts);
+
+ tnl->Driver.Render.Start( ctx );
+
+ for (i = 0 ; i < VB->PrimitiveCount ; i++)
+ {
+ GLuint prim = VB->Primitive[i].mode;
+ GLuint start = VB->Primitive[i].start;
+ GLuint length = VB->Primitive[i].count;
+
+ if (!length)
+ continue;
+
+ tab[prim & PRIM_MODE_MASK]( ctx, start, start + length, prim);
+ }
+
+ tnl->Driver.Render.Finish( ctx );
+
+ return GL_FALSE; /* finished the pipe */
+}
+
+
+const struct tnl_pipeline_stage _gamma_render_stage =
+{
+ "gamma render",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ gamma_run_render /* run */
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_screen.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_screen.c
new file mode 100644
index 000000000..0b91d059e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_screen.c
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * 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@tungstengraphics.com>
+ *
+ */
+
+#include "gamma_context.h"
+#include "gamma_vb.h"
+#include "glint_dri.h"
+
+#include "imports.h"
+
+gammaScreenPtr gammaCreateScreen( __DRIscreenPrivate *sPriv )
+{
+ gammaScreenPtr gammaScreen;
+ GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)sPriv->pDevPriv;
+ int i;
+
+ if (sPriv->devPrivSize != sizeof(GLINTDRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(GLINTDRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
+
+#if 0
+ /* Check the DRI externsion version */
+ if ( sPriv->driMajor != 3 || sPriv->driMinor != 1 ) {
+ __driUtilMessage( "Gamma DRI driver expected DRI version 4.0.x "
+ "but got version %d.%d.%d",
+ sPriv->driMajor, sPriv->driMinor, sPriv->driPatch );
+ return NULL;
+ }
+
+ /* Check that the DDX driver version is compatible */
+ if ( sPriv->ddxMajor != 4 ||
+ sPriv->ddxMinor != 0 ||
+ sPriv->ddxPatch < 0 ) {
+ __driUtilMessage( "r128 DRI driver expected DDX driver version 4.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch );
+ return GL_FALSE;
+ }
+
+ /* Check that the DRM driver version is compatible */
+ if ( sPriv->drmMajor != 2 ||
+ sPriv->drmMinor != 1 ||
+ sPriv->drmPatch < 0 ) {
+ __driUtilMessage( "r128 DRI driver expected DRM driver version 2.1.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch );
+ return GL_FALSE;
+ }
+#endif
+
+ /* Allocate the private area */
+ gammaScreen = (gammaScreenPtr) CALLOC( sizeof(*gammaScreen) );
+ if ( !gammaScreen ) return NULL;
+
+ gammaScreen->regionCount = 4; /* Magic number. Can we fix this? */
+
+ gammaScreen->regions = CALLOC(gammaScreen->regionCount *
+ sizeof(gammaRegion));
+
+ gammaScreen->regions[0].handle = gDRIPriv->registers0.handle;
+ gammaScreen->regions[0].size = gDRIPriv->registers0.size;
+ gammaScreen->regions[1].handle = gDRIPriv->registers1.handle;
+ gammaScreen->regions[1].size = gDRIPriv->registers1.size;
+ gammaScreen->regions[2].handle = gDRIPriv->registers2.handle;
+ gammaScreen->regions[2].size = gDRIPriv->registers2.size;
+ gammaScreen->regions[3].handle = gDRIPriv->registers3.handle;
+ gammaScreen->regions[3].size = gDRIPriv->registers3.size;
+
+ /* Next, map all the regions */
+ for (i = 0; i < gammaScreen->regionCount; i++) {
+ if (drmMap(sPriv->fd,
+ gammaScreen->regions[i].handle,
+ gammaScreen->regions[i].size,
+ &gammaScreen->regions[i].map)) {
+ while (--i > 0) {
+ (void)drmUnmap(gammaScreen->regions[i].map,
+ gammaScreen->regions[i].size);
+ }
+ return GL_FALSE;
+ }
+ }
+
+ /* Get the list of dma buffers */
+ gammaScreen->bufs = drmMapBufs(sPriv->fd);
+
+ if (!gammaScreen->bufs) {
+ while (gammaScreen->regionCount > 0) {
+ (void)drmUnmap(gammaScreen->regions[gammaScreen->regionCount].map,
+ gammaScreen->regions[gammaScreen->regionCount].size);
+ gammaScreen->regionCount--;
+ }
+ return GL_FALSE;
+ }
+
+ gammaScreen->textureSize = gDRIPriv->textureSize;
+ gammaScreen->logTextureGranularity = gDRIPriv->logTextureGranularity;
+ gammaScreen->cpp = gDRIPriv->cpp;
+ gammaScreen->frontOffset = gDRIPriv->frontOffset;
+ gammaScreen->frontPitch = gDRIPriv->frontPitch;
+ gammaScreen->backOffset = gDRIPriv->backOffset;
+ gammaScreen->backPitch = gDRIPriv->backPitch;
+ gammaScreen->backX = gDRIPriv->backX;
+ gammaScreen->backY = gDRIPriv->backY;
+ gammaScreen->depthOffset = gDRIPriv->depthOffset;
+ gammaScreen->depthPitch = gDRIPriv->depthPitch;
+
+ gammaScreen->driScreen = sPriv;
+
+ return gammaScreen;
+}
+
+/* Destroy the device specific screen private data struct.
+ */
+void gammaDestroyScreen( __DRIscreenPrivate *sPriv )
+{
+ gammaScreenPtr gammaScreen = (gammaScreenPtr)sPriv->private;
+
+ /* First, unmap the dma buffers */
+ drmUnmapBufs( gammaScreen->bufs );
+
+ /* Next, unmap all the regions */
+ while (gammaScreen->regionCount > 0) {
+ (void)drmUnmap(gammaScreen->regions[gammaScreen->regionCount].map,
+ gammaScreen->regions[gammaScreen->regionCount].size);
+ gammaScreen->regionCount--;
+ }
+ FREE(gammaScreen->regions);
+ FREE(gammaScreen);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_screen.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_screen.h
new file mode 100644
index 000000000..7f0ed6f80
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_screen.h
@@ -0,0 +1,30 @@
+typedef struct _gammaRegion {
+ drm_handle_t handle;
+ drmSize size;
+ drmAddress map;
+} gammaRegion, *gammaRegionPtr;
+
+typedef struct {
+
+ int regionCount; /* Count of register regions */
+ gammaRegion *regions; /* Vector of mapped region info */
+
+ drmBufMapPtr bufs; /* Map of DMA buffers */
+
+ __DRIscreenPrivate *driScreen; /* Back pointer to DRI screen */
+
+ int cpp;
+ int frontPitch;
+ int frontOffset;
+
+ int backPitch;
+ int backOffset;
+ int backX;
+ int backY;
+
+ int depthOffset;
+ int depthPitch;
+
+ int textureSize;
+ int logTextureGranularity;
+} gammaScreenRec, *gammaScreenPtr;
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_span.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_span.c
new file mode 100644
index 000000000..66cc961c6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_span.c
@@ -0,0 +1,313 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_span.c,v 1.4 2002/11/05 17:46:07 tsi Exp $ */
+
+#include "gamma_context.h"
+#include "gamma_lock.h"
+#include "colormac.h"
+
+#include "swrast/swrast.h"
+
+#define DBG 0
+
+#define LOCAL_VARS \
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \
+ gammaScreenPtr gammascrn = gmesa->gammaScreen; \
+ __DRIscreenPrivate *sPriv = gmesa->driScreen; \
+ __DRIdrawablePrivate *dPriv = gmesa->driDrawable; \
+ GLuint pitch = sPriv->fbWidth * gammascrn->cpp; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(sPriv->pFB + \
+ gmesa->drawOffset + \
+ (dPriv->x * gammascrn->cpp) + \
+ (dPriv->y * pitch)); \
+ char *read_buf = (char *)(sPriv->pFB + \
+ gmesa->readOffset + \
+ (dPriv->x * gammascrn->cpp) + \
+ (dPriv->y * pitch)); \
+ GLuint p; \
+ (void) read_buf; (void) buf; (void) p
+
+/* FIXME! Depth/Stencil read/writes don't work ! */
+#define LOCAL_DEPTH_VARS \
+ gammaScreenPtr gammascrn = gmesa->gammaScreen; \
+ __DRIdrawablePrivate *dPriv = gmesa->driDrawable; \
+ __DRIscreenPrivate *sPriv = gmesa->driScreen; \
+ GLuint pitch = gammascrn->depthPitch; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(sPriv->pFB + \
+ gammascrn->depthOffset + \
+ dPriv->x * gammascrn->cpp + \
+ dPriv->y * pitch)
+
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
+
+#define Y_FLIP( _y ) (height - _y - 1)
+
+#define HW_LOCK() \
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \
+ FLUSH_DMA_BUFFER(gmesa); \
+ gammaGetLock( gmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT ); \
+ GAMMAHW_LOCK( gmesa );
+
+#define HW_UNLOCK() GAMMAHW_UNLOCK( gmesa )
+
+
+
+/* ================================================================
+ * Color buffer
+ */
+
+/* 16 bit, RGB565 color spanline and pixel functions
+ */
+#define INIT_MONO_PIXEL(p, color) \
+ p = PACK_COLOR_565( color[0], color[1], color[2] )
+
+#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; \
+ if ( rgba[0] & 0x08 ) rgba[0] |= 0x07; \
+ if ( rgba[1] & 0x04 ) rgba[1] |= 0x03; \
+ if ( rgba[2] & 0x08 ) rgba[2] |= 0x07; \
+ } while (0)
+
+#define TAG(x) gamma##x##_RGB565
+#include "spantmp.h"
+
+
+/* 32 bit, ARGB8888 color spanline and pixel functions
+ */
+
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = PACK_COLOR_8888( color[3], color[0], color[1], color[2] )
+
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = ((b << 0) | \
+ (g << 8) | \
+ (r << 16) | \
+ (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) gamma##x##_ARGB8888
+#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) gamma##x##_16
+#include "depthtmp.h"
+
+
+#if 0 /* Unused */
+/* 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) gamma##x##_32
+#include "depthtmp.h"
+#endif
+
+
+/* 24/8 bit interleaved depth/stencil functions
+ */
+#define WRITE_DEPTH( _x, _y, d ) { \
+ GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*pitch); \
+ tmp &= 0xff; \
+ tmp |= (d) & 0xffffff00; \
+ *(GLuint *)(buf + (_x)*4 + (_y)*pitch) = tmp; \
+}
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLuint *)(buf + (_x)*4 + (_y)*pitch) & ~0xff;
+
+
+#define TAG(x) gamma##x##_24_8
+#include "depthtmp.h"
+
+#if 0
+#define WRITE_STENCIL( _x, _y, d ) { \
+ GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \
+ tmp &= 0xffffff00; \
+ tmp |= d & 0xff; \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \
+}
+
+#define READ_STENCIL( d, _x, _y ) \
+ d = *(GLuint *)(buf + _x*4 + _y*pitch) & 0xff;
+
+#define TAG(x) gamma##x##_24_8
+#include "stenciltmp.h"
+
+static void gammaReadRGBASpan8888( const GLcontext *ctx,
+ GLuint n, GLint x, GLint y,
+ GLubyte rgba[][4])
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ gammaScreenPtr gammascrn = gmesa->gammaScreen;
+ u_int32_t dwords1, dwords2, i = 0;
+ char *src = (char *)rgba[0];
+ GLuint read = n * gammascrn->cpp; /* Number of bytes we are expecting */
+ u_int32_t data;
+
+ FLUSH_DMA_BUFFER(gmesa);
+ CHECK_DMA_BUFFER(gmesa, 16);
+ WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode & ~(LBReadSrcEnable | LBReadDstEnable));
+ WRITE(gmesa->buf, ColorDDAMode, ColorDDAEnable);
+ WRITE(gmesa->buf, LBWriteMode, LBWriteModeDisable);
+ WRITE(gmesa->buf, FBReadMode, (gmesa->FBReadMode & ~FBReadSrcEnable) | FBReadDstEnable | FBDataTypeColor);
+ WRITE(gmesa->buf, FilterMode, 0x200); /* Pass FBColorData */
+ WRITE(gmesa->buf, FBWriteMode, FBW_UploadColorData | FBWriteModeDisable);
+ WRITE(gmesa->buf, StartXSub, (x+n)<<16);
+ WRITE(gmesa->buf, StartXDom, x<<16);
+ WRITE(gmesa->buf, StartY, y<<16);
+ WRITE(gmesa->buf, GLINTCount, 1);
+ WRITE(gmesa->buf, dXDom, 0<<16);
+ WRITE(gmesa->buf, dXSub, 0<<16);
+ WRITE(gmesa->buf, dY, 1<<16);
+ WRITE(gmesa->buf, Render, PrimitiveTrapezoid);
+ FLUSH_DMA_BUFFER(gmesa);
+
+moredata:
+
+ dwords1 = *(volatile u_int32_t*)(void *)(((u_int8_t*)gammascrn->regions[0].map) + (GlintOutFIFOWords));
+ dwords2 = *(volatile u_int32_t*)(void *)(((u_int8_t*)gammascrn->regions[2].map) + (GlintOutFIFOWords));
+
+ if (dwords1) {
+ memcpy(src, (char*)gammascrn->regions[1].map + 0x1000, dwords1 << 2);
+ src += dwords1 << 2;
+ read -= dwords1 << 2;
+ }
+ if (dwords2) {
+ memcpy(src, (char*)gammascrn->regions[3].map + 0x1000, dwords2 << 2);
+ src += dwords2 << 2;
+ read -= dwords2 << 2;
+ }
+
+ if (read)
+ goto moredata;
+
+done:
+
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITE(gmesa->buf, ColorDDAMode, gmesa->ColorDDAMode);
+ WRITE(gmesa->buf, LBWriteMode, LBWriteModeEnable);
+ WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode);
+ WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode);
+ WRITE(gmesa->buf, FBWriteMode, FBWriteModeEnable);
+ WRITE(gmesa->buf, FilterMode, 0x400);
+}
+#endif
+
+static void gammaSetBuffer( GLcontext *ctx,
+ GLframebuffer *colorBuffer,
+ GLuint bufferBit )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ switch ( bufferBit ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ gmesa->readOffset = 0;
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ gmesa->readOffset = gmesa->driScreen->fbHeight * gmesa->driScreen->fbWidth * gmesa->gammaScreen->cpp;
+ break;
+ default:
+ _mesa_problem(ctx, "Unexpected buffer 0x%x in gammaSetBuffer()", bufferBit);
+ }
+}
+
+
+void gammaDDInitSpanFuncs( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetBuffer = gammaSetBuffer;
+
+ switch ( gmesa->gammaScreen->cpp ) {
+ case 2:
+ swdd->WriteRGBASpan = gammaWriteRGBASpan_RGB565;
+ swdd->WriteRGBSpan = gammaWriteRGBSpan_RGB565;
+ swdd->WriteMonoRGBASpan = gammaWriteMonoRGBASpan_RGB565;
+ swdd->WriteRGBAPixels = gammaWriteRGBAPixels_RGB565;
+ swdd->WriteMonoRGBAPixels = gammaWriteMonoRGBAPixels_RGB565;
+ swdd->ReadRGBASpan = gammaReadRGBASpan_RGB565;
+ swdd->ReadRGBAPixels = gammaReadRGBAPixels_RGB565;
+ break;
+
+ case 4:
+ swdd->WriteRGBASpan = gammaWriteRGBASpan_ARGB8888;
+ swdd->WriteRGBSpan = gammaWriteRGBSpan_ARGB8888;
+ swdd->WriteMonoRGBASpan = gammaWriteMonoRGBASpan_ARGB8888;
+ swdd->WriteRGBAPixels = gammaWriteRGBAPixels_ARGB8888;
+ swdd->WriteMonoRGBAPixels = gammaWriteMonoRGBAPixels_ARGB8888;
+#if 1
+ swdd->ReadRGBASpan = gammaReadRGBASpan_ARGB8888;
+#else
+ swdd->ReadRGBASpan = gammaReadRGBASpan8888;
+#endif
+ swdd->ReadRGBAPixels = gammaReadRGBAPixels_ARGB8888;
+ break;
+
+ default:
+ break;
+ }
+
+ switch ( gmesa->glCtx->Visual.depthBits ) {
+ case 16:
+ swdd->ReadDepthSpan = gammaReadDepthSpan_16;
+ swdd->WriteDepthSpan = gammaWriteDepthSpan_16;
+ swdd->ReadDepthPixels = gammaReadDepthPixels_16;
+ swdd->WriteDepthPixels = gammaWriteDepthPixels_16;
+ break;
+
+ case 24:
+ swdd->ReadDepthSpan = gammaReadDepthSpan_24_8;
+ swdd->WriteDepthSpan = gammaWriteDepthSpan_24_8;
+ swdd->ReadDepthPixels = gammaReadDepthPixels_24_8;
+ swdd->WriteDepthPixels = gammaWriteDepthPixels_24_8;
+
+#if 0
+ swdd->ReadStencilSpan = gammaReadStencilSpan_24_8;
+ swdd->WriteStencilSpan = gammaWriteStencilSpan_24_8;
+ swdd->ReadStencilPixels = gammaReadStencilPixels_24_8;
+ swdd->WriteStencilPixels = gammaWriteStencilPixels_24_8;
+#endif
+ break;
+
+ default:
+ break;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_state.c
new file mode 100644
index 000000000..194313dc9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_state.c
@@ -0,0 +1,1730 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_state.c,v 1.5 2002/11/05 17:46:07 tsi Exp $ */
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * 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@tungstengraphics.com>
+ *
+ * 3DLabs Gamma driver
+ */
+
+#include "gamma_context.h"
+#include "gamma_macros.h"
+#include "buffers.h"
+#include "macros.h"
+#include "glint_dri.h"
+#include "colormac.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+
+#define ENABLELIGHTING 0
+
+/* =============================================================
+ * Alpha blending
+ */
+
+static void gammaUpdateAlphaMode( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ u_int32_t a = gmesa->AlphaTestMode;
+ u_int32_t b = gmesa->AlphaBlendMode;
+ u_int32_t f = gmesa->AB_FBReadMode_Save = 0;
+ GLubyte refByte = (GLint) (ctx->Color.AlphaRef * 255.0);
+
+ a &= ~(AT_CompareMask | AT_RefValueMask);
+ b &= ~(AB_SrcBlendMask | AB_DstBlendMask);
+
+ a |= refByte << 4;
+
+ switch ( ctx->Color.AlphaFunc ) {
+ case GL_NEVER:
+ a |= AT_Never;
+ break;
+ case GL_LESS:
+ a |= AT_Less;
+ break;
+ case GL_EQUAL:
+ a |= AT_Equal;
+ break;
+ case GL_LEQUAL:
+ a |= AT_LessEqual;
+ break;
+ case GL_GEQUAL:
+ a |= AT_GreaterEqual;
+ break;
+ case GL_GREATER:
+ a |= AT_Greater;
+ break;
+ case GL_NOTEQUAL:
+ a |= AT_NotEqual;
+ break;
+ case GL_ALWAYS:
+ a |= AT_Always;
+ break;
+ }
+
+ if ( ctx->Color.AlphaEnabled ) {
+ f |= FBReadDstEnable;
+ a |= AlphaTestModeEnable;
+ } else {
+ a &= ~AlphaTestModeEnable;
+ }
+
+ switch ( ctx->Color.BlendSrcRGB ) {
+ case GL_ZERO:
+ b |= AB_Src_Zero;
+ break;
+ case GL_ONE:
+ b |= AB_Src_One;
+ break;
+ case GL_DST_COLOR:
+ b |= AB_Src_DstColor;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ b |= AB_Src_OneMinusDstColor;
+ break;
+ case GL_SRC_ALPHA:
+ b |= AB_Src_SrcAlpha;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ b |= AB_Src_OneMinusSrcAlpha;
+ break;
+ case GL_DST_ALPHA:
+ b |= AB_Src_DstAlpha;
+ f |= FBReadSrcEnable;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ b |= AB_Src_OneMinusDstAlpha;
+ f |= FBReadSrcEnable;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ b |= AB_Src_SrcAlphaSaturate;
+ break;
+ }
+
+ switch ( ctx->Color.BlendDstRGB ) {
+ case GL_ZERO:
+ b |= AB_Dst_Zero;
+ break;
+ case GL_ONE:
+ b |= AB_Dst_One;
+ break;
+ case GL_SRC_COLOR:
+ b |= AB_Dst_SrcColor;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ b |= AB_Dst_OneMinusSrcColor;
+ break;
+ case GL_SRC_ALPHA:
+ b |= AB_Dst_SrcAlpha;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ b |= AB_Dst_OneMinusSrcAlpha;
+ break;
+ case GL_DST_ALPHA:
+ b |= AB_Dst_DstAlpha;
+ f |= FBReadSrcEnable;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ b |= AB_Dst_OneMinusDstAlpha;
+ f |= FBReadSrcEnable;
+ break;
+ }
+
+ if ( ctx->Color.BlendEnabled ) {
+ f |= FBReadDstEnable;
+ b |= AlphaBlendModeEnable;
+ } else {
+ b &= ~AlphaBlendModeEnable;
+ }
+
+ if ( gmesa->AlphaTestMode != a ) {
+ gmesa->AlphaTestMode = a;
+ gmesa->dirty |= GAMMA_UPLOAD_ALPHA;
+ }
+ if ( gmesa->AlphaBlendMode != b) {
+ gmesa->AlphaBlendMode = b;
+ gmesa->dirty |= GAMMA_UPLOAD_BLEND;
+ }
+ gmesa->AB_FBReadMode_Save = f;
+}
+
+static void gammaDDAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ (void) ref;
+
+ FLUSH_BATCH( gmesa );
+
+ gmesa->new_state |= GAMMA_NEW_ALPHA;
+}
+
+static void gammaDDBlendEquationSeparate( GLcontext *ctx,
+ GLenum modeRGB, GLenum modeA )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ assert( modeRGB == modeA );
+ FLUSH_BATCH( gmesa );
+
+ gmesa->new_state |= GAMMA_NEW_ALPHA;
+}
+
+static void gammaDDBlendFuncSeparate( GLcontext *ctx,
+ GLenum sfactorRGB, GLenum dfactorRGB,
+ GLenum sfactorA, GLenum dfactorA )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+
+ gmesa->new_state |= GAMMA_NEW_ALPHA;
+}
+
+
+/* ================================================================
+ * Buffer clear
+ */
+
+static void gammaDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)gmesa->driScreen->pDevPriv;
+ GLuint temp = 0;
+
+ FLUSH_BATCH( gmesa );
+
+ /* Update and emit any new state. We need to do this here to catch
+ * changes to the masks.
+ * FIXME: Just update the masks?
+ */
+ if ( gmesa->new_state )
+ gammaDDUpdateHWState( ctx );
+
+#ifdef DO_VALIDATE
+ /* Flush any partially filled buffers */
+ FLUSH_DMA_BUFFER(gmesa);
+
+ DRM_SPINLOCK(&gmesa->driScreen->pSAREA->drawable_lock,
+ gmesa->driScreen->drawLockID);
+ VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa);
+#endif
+
+ if (mask & BUFFER_BIT_DEPTH) {
+ /* Turn off writes the FB */
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, FBWriteMode, FBWriteModeDisable);
+
+ mask &= ~BUFFER_BIT_DEPTH;
+
+ /*
+ * Turn Rectangle2DControl off when the window is not clipped
+ * (i.e., the GID tests are not necessary). This dramatically
+ * increases the performance of the depth clears.
+ */
+ if (!gmesa->NotClipped) {
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Rectangle2DControl, 1);
+ }
+
+ temp = (gmesa->LBReadMode & LBPartialProdMask) | LBWindowOriginBot;
+ if (gDRIPriv->numMultiDevices == 2) temp |= LBScanLineInt2;
+
+ CHECK_DMA_BUFFER(gmesa, 5);
+ WRITE(gmesa->buf, LBReadMode, temp);
+ WRITE(gmesa->buf, DeltaMode, DM_DepthEnable);
+ WRITE(gmesa->buf, DepthMode, (DepthModeEnable |
+ DM_Always |
+ DM_SourceDepthRegister |
+ DM_WriteMask));
+ WRITE(gmesa->buf, GLINTDepth, gmesa->ClearDepth);
+
+ /* Increment the frame count */
+ gmesa->FrameCount++;
+#ifdef FAST_CLEAR_4
+ gmesa->FrameCount &= 0x0f;
+#else
+ gmesa->FrameCount &= 0xff;
+#endif
+
+ /* Force FCP to be written */
+ WRITE(gmesa->buf, GLINTWindow, (WindowEnable |
+ W_PassIfEqual |
+ (gmesa->Window & W_GIDMask) |
+ W_DepthFCP |
+ W_LBUpdateFromRegisters |
+ W_OverrideWriteFiltering |
+ (gmesa->FrameCount << 9)));
+
+ /* Clear part of the depth and FCP buffers */
+ {
+ int y = gmesa->driScreen->fbHeight - gmesa->driDrawable->y - gmesa->driDrawable->h;
+ int x = gmesa->driDrawable->x;
+ int w = gmesa->driDrawable->w;
+ int h = gmesa->driDrawable->h;
+#ifndef TURN_OFF_FCP
+ float hsub = h;
+
+ if (gmesa->WindowChanged) {
+ gmesa->WindowChanged = GL_FALSE;
+ } else {
+#ifdef FAST_CLEAR_4
+ hsub /= 16;
+#else
+ hsub /= 256;
+#endif
+
+ /* Handle the case where the height < # of FCPs */
+ if (hsub < 1.0) {
+ if (gmesa->FrameCount > h)
+ gmesa->FrameCount = 0;
+ h = 1;
+ y += gmesa->FrameCount;
+ } else {
+ h = (gmesa->FrameCount+1)*hsub;
+ h -= (int)(gmesa->FrameCount*hsub);
+ y += gmesa->FrameCount*hsub;
+ }
+ }
+#endif
+ if (h && w) {
+#if 0
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, Rectangle2DMode, ((h & 0xfff)<<12) |
+ (w & 0xfff) );
+ WRITE(gmesa->buf, DrawRectangle2D, ((y & 0xffff)<<16) |
+ (x & 0xffff) );
+#else
+ CHECK_DMA_BUFFER(gmesa, 8);
+ WRITE(gmesa->buf, StartXDom, x<<16);
+ WRITE(gmesa->buf, StartY, y<<16);
+ WRITE(gmesa->buf, StartXSub, (x+w)<<16);
+ WRITE(gmesa->buf, GLINTCount, h);
+ WRITE(gmesa->buf, dY, 1<<16);
+ WRITE(gmesa->buf, dXDom, 0<<16);
+ WRITE(gmesa->buf, dXSub, 0<<16);
+ WRITE(gmesa->buf, Render, 0x00000040); /* NOT_DONE */
+#endif
+ }
+ }
+
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITE(gmesa->buf, DepthMode, gmesa->DepthMode);
+ WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode);
+ WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode);
+ WRITE(gmesa->buf, GLINTWindow, gmesa->Window);
+ WRITE(gmesa->buf, FastClearDepth, gmesa->ClearDepth);
+ WRITE(gmesa->buf, FBWriteMode, FBWriteModeEnable);
+
+ /* Turn on Depth FCP */
+ if (gmesa->Window & W_DepthFCP) {
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, WindowOr, (gmesa->FrameCount << 9));
+ }
+
+ /* Turn off GID clipping if window is not clipped */
+ if (gmesa->NotClipped) {
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Rectangle2DControl, 0);
+ }
+ }
+
+ if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) {
+ int y = gmesa->driScreen->fbHeight - gmesa->driDrawable->y - gmesa->driDrawable->h;
+ int x = gmesa->driDrawable->x;
+ int w = gmesa->driDrawable->w;
+ int h = gmesa->driDrawable->h;
+
+ mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT);
+
+ if (x < 0) { w -= -x; x = 0; }
+
+ /* Turn on GID clipping if window is clipped */
+ if (!gmesa->NotClipped) {
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Rectangle2DControl, 1);
+ }
+
+ CHECK_DMA_BUFFER(gmesa, 18);
+ WRITE(gmesa->buf, FBBlockColor, gmesa->ClearColor);
+ WRITE(gmesa->buf, ColorDDAMode, ColorDDADisable);
+ WRITE(gmesa->buf, FBWriteMode, FBWriteModeEnable);
+ WRITE(gmesa->buf, DepthMode, 0);
+ WRITE(gmesa->buf, DeltaMode, 0);
+ WRITE(gmesa->buf, AlphaBlendMode, 0);
+#if 1
+ WRITE(gmesa->buf, dY, 1<<16);
+ WRITE(gmesa->buf, dXDom, 0<<16);
+ WRITE(gmesa->buf, dXSub, 0<<16);
+ WRITE(gmesa->buf, StartXSub, (x+w)<<16);
+ WRITE(gmesa->buf, GLINTCount, h);
+ WRITE(gmesa->buf, StartXDom, x<<16);
+ WRITE(gmesa->buf, StartY, y<<16);
+ WRITE(gmesa->buf, Render, 0x00000048); /* NOT_DONE */
+#else
+ WRITE(gmesa->buf, Rectangle2DMode, (((h & 0xfff)<<12) |
+ (w & 0xfff)));
+ WRITE(gmesa->buf, DrawRectangle2D, (((y & 0xffff)<<16) |
+ (x & 0xffff)));
+#endif
+ WRITE(gmesa->buf, DepthMode, gmesa->DepthMode);
+ WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode);
+ WRITE(gmesa->buf, AlphaBlendMode, gmesa->AlphaBlendMode);
+ WRITE(gmesa->buf, ColorDDAMode, gmesa->ColorDDAMode);
+
+ /* Turn off GID clipping if window is clipped */
+ if (gmesa->NotClipped) {
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Rectangle2DControl, 0);
+ }
+ }
+
+#ifdef DO_VALIDATE
+ PROCESS_DMA_BUFFER_TOP_HALF(gmesa);
+
+ DRM_SPINUNLOCK(&gmesa->driScreen->pSAREA->drawable_lock,
+ gmesa->driScreen->drawLockID);
+ VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa);
+
+ PROCESS_DMA_BUFFER_BOTTOM_HALF(gmesa);
+#endif
+
+ if ( mask )
+ _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
+}
+
+/* =============================================================
+ * Depth testing
+ */
+
+static void gammaUpdateZMode( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ u_int32_t z = gmesa->DepthMode;
+ u_int32_t delta = gmesa->DeltaMode;
+ u_int32_t window = gmesa->Window;
+ u_int32_t lbread = gmesa->LBReadMode;
+
+ z &= ~DM_CompareMask;
+
+ switch ( ctx->Depth.Func ) {
+ case GL_NEVER:
+ z |= DM_Never;
+ break;
+ case GL_ALWAYS:
+ z |= DM_Always;
+ break;
+ case GL_LESS:
+ z |= DM_Less;
+ break;
+ case GL_LEQUAL:
+ z |= DM_LessEqual;
+ break;
+ case GL_EQUAL:
+ z |= DM_Equal;
+ break;
+ case GL_GEQUAL:
+ z |= DM_GreaterEqual;
+ break;
+ case GL_GREATER:
+ z |= DM_Greater;
+ break;
+ case GL_NOTEQUAL:
+ z |= DM_NotEqual;
+ break;
+ }
+
+ if ( ctx->Depth.Test ) {
+ z |= DepthModeEnable;
+ delta |= DM_DepthEnable;
+ window |= W_DepthFCP;
+ lbread |= LBReadDstEnable;
+ } else {
+ z &= ~DepthModeEnable;
+ delta &= ~DM_DepthEnable;
+ window &= ~W_DepthFCP;
+ lbread &= ~LBReadDstEnable;
+ }
+
+ if ( ctx->Depth.Mask ) {
+ z |= DM_WriteMask;
+ } else {
+ z &= ~DM_WriteMask;
+ }
+
+#if 0
+ if ( gmesa->DepthMode != z ){
+#endif
+ gmesa->DepthMode = z;
+ gmesa->DeltaMode = delta;
+ gmesa->Window = window;
+ gmesa->LBReadMode = lbread;
+ gmesa->dirty |= GAMMA_UPLOAD_DEPTH;
+#if 0
+ }
+#endif
+}
+
+static void gammaDDDepthFunc( GLcontext *ctx, GLenum func )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_DEPTH;
+}
+
+static void gammaDDDepthMask( GLcontext *ctx, GLboolean flag )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_DEPTH;
+}
+
+static void gammaDDClearDepth( GLcontext *ctx, GLclampd d )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ switch ( gmesa->DepthSize ) {
+ case 16:
+ gmesa->ClearDepth = d * 0x0000ffff;
+ break;
+ case 24:
+ gmesa->ClearDepth = d * 0x00ffffff;
+ break;
+ case 32:
+ gmesa->ClearDepth = d * 0xffffffff;
+ break;
+ }
+}
+
+static void gammaDDFinish( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_DMA_BUFFER(gmesa);
+}
+
+static void gammaDDFlush( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_DMA_BUFFER(gmesa);
+}
+
+/* =============================================================
+ * Fog
+ */
+
+static void gammaUpdateFogAttrib( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ u_int32_t f = gmesa->FogMode;
+ u_int32_t g = gmesa->GeometryMode;
+ u_int32_t d = gmesa->DeltaMode;
+
+ if (ctx->Fog.Enabled) {
+ f |= FogModeEnable;
+ g |= GM_FogEnable;
+ d |= DM_FogEnable;
+ } else {
+ f &= ~FogModeEnable;
+ g &= ~GM_FogEnable;
+ d &= ~DM_FogEnable;
+ }
+
+ g &= ~GM_FogMask;
+
+ switch (ctx->Fog.Mode) {
+ case GL_LINEAR:
+ g |= GM_FogLinear;
+ break;
+ case GL_EXP:
+ g |= GM_FogExp;
+ break;
+ case GL_EXP2:
+ g |= GM_FogExpSquared;
+ break;
+ }
+
+ if ( gmesa->FogMode != f ) {
+ gmesa->FogMode = f;
+ gmesa->dirty |= GAMMA_UPLOAD_FOG;
+ }
+
+ if ( gmesa->GeometryMode != g ) {
+ gmesa->GeometryMode = g;
+ gmesa->dirty |= GAMMA_UPLOAD_GEOMETRY;
+ }
+
+ if ( gmesa->DeltaMode != d ) {
+ gmesa->DeltaMode = d;
+ gmesa->dirty |= GAMMA_UPLOAD_DEPTH;
+ }
+}
+
+#if 0
+static void gammaDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_FOG;
+}
+#endif
+
+/* =============================================================
+ * Lines
+ */
+static void gammaDDLineWidth( GLcontext *ctx, GLfloat width )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ CHECK_DMA_BUFFER(gmesa, 3);
+ WRITE(gmesa->buf, LineWidth, (GLuint)width);
+ WRITEF(gmesa->buf, AAlineWidth, width);
+ WRITE(gmesa->buf, LineWidthOffset, (GLuint)(width-1)/2);
+}
+
+static void gammaDDLineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ gmesa->LineMode &= ~(LM_StippleMask | LM_RepeatFactorMask);
+ gmesa->LineMode |= ((GLuint)(factor - 1) << 1) | ((GLuint)pattern << 10);
+
+ gmesa->dirty |= GAMMA_UPLOAD_LINEMODE;
+}
+
+
+
+/* =============================================================
+ * Points
+ */
+static void gammaDDPointSize( GLcontext *ctx, GLfloat size )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, PointSize, (GLuint)size);
+ WRITEF(gmesa->buf, AApointSize, size);
+}
+
+/* =============================================================
+ * Polygon
+ */
+
+static void gammaUpdatePolygon( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ u_int32_t g = gmesa->GeometryMode;
+
+ g &= ~(GM_PolyOffsetFillEnable | GM_PolyOffsetPointEnable |
+ GM_PolyOffsetLineEnable);
+
+ if (ctx->Polygon.OffsetFill) g |= GM_PolyOffsetFillEnable;
+ if (ctx->Polygon.OffsetPoint) g |= GM_PolyOffsetPointEnable;
+ if (ctx->Polygon.OffsetLine) g |= GM_PolyOffsetLineEnable;
+
+ g &= ~GM_FB_PolyMask;
+
+ switch (ctx->Polygon.FrontMode) {
+ case GL_FILL:
+ g |= GM_FrontPolyFill;
+ break;
+ case GL_LINE:
+ g |= GM_FrontPolyLine;
+ break;
+ case GL_POINT:
+ g |= GM_FrontPolyPoint;
+ break;
+ }
+
+ switch (ctx->Polygon.BackMode) {
+ case GL_FILL:
+ g |= GM_BackPolyFill;
+ break;
+ case GL_LINE:
+ g |= GM_BackPolyLine;
+ break;
+ case GL_POINT:
+ g |= GM_BackPolyPoint;
+ break;
+ }
+
+ if ( gmesa->GeometryMode != g ) {
+ gmesa->GeometryMode = g;
+ gmesa->dirty |= GAMMA_UPLOAD_GEOMETRY;
+ }
+
+ gmesa->dirty |= GAMMA_UPLOAD_POLYGON;
+}
+
+static void gammaDDPolygonMode( GLcontext *ctx, GLenum face, GLenum mode)
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+
+ gmesa->new_state |= GAMMA_NEW_POLYGON;
+}
+
+static void gammaUpdateStipple( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+
+ if (ctx->Polygon.StippleFlag) {
+ gmesa->AreaStippleMode |= AreaStippleModeEnable/* | ASM_X32 | ASM_Y32*/;
+ } else {
+ gmesa->AreaStippleMode &= ~AreaStippleModeEnable;
+ }
+
+ gmesa->dirty |= GAMMA_UPLOAD_STIPPLE;
+}
+
+static void gammaDDPolygonStipple( GLcontext *ctx, const GLubyte *mask)
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_STIPPLE;
+}
+
+/* =============================================================
+ * Clipping
+ */
+
+static void gammaUpdateClipping( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ GLint x1, y1, x2, y2;
+
+ if ( gmesa->driDrawable ) {
+ x1 = gmesa->driDrawable->x + ctx->Scissor.X;
+ y1 = gmesa->driScreen->fbHeight -
+ (gmesa->driDrawable->y +
+ gmesa->driDrawable->h) + ctx->Scissor.Y;
+ x2 = x1 + ctx->Scissor.Width;
+ y2 = y1 + ctx->Scissor.Height;
+
+ gmesa->ScissorMinXY = x1 | (y1 << 16);
+ gmesa->ScissorMaxXY = x2 | (y2 << 16);
+ if (ctx->Scissor.Enabled)
+ gmesa->ScissorMode |= UserScissorEnable;
+ else
+ gmesa->ScissorMode &= ~UserScissorEnable;
+
+ gmesa->dirty |= GAMMA_UPLOAD_CLIP;
+ }
+}
+
+static void gammaDDScissor( GLcontext *ctx,
+ GLint x, GLint y, GLsizei w, GLsizei h )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_CLIP;
+}
+
+/* =============================================================
+ * Culling
+ */
+
+static void gammaUpdateCull( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ u_int32_t g = gmesa->GeometryMode;
+
+ g &= ~(GM_PolyCullMask | GM_FFMask);
+
+ if (ctx->Polygon.FrontFace == GL_CCW) {
+ g |= GM_FrontFaceCCW;
+ } else {
+ g |= GM_FrontFaceCW;
+ }
+
+ switch ( ctx->Polygon.CullFaceMode ) {
+ case GL_FRONT:
+ g |= GM_PolyCullFront;
+ break;
+ case GL_BACK:
+ g |= GM_PolyCullBack;
+ break;
+ case GL_FRONT_AND_BACK:
+ g |= GM_PolyCullBoth;
+ break;
+ }
+
+ if ( ctx->Polygon.CullFlag ) {
+ g |= GM_PolyCullEnable;
+ } else {
+ g &= ~GM_PolyCullEnable;
+ }
+
+ if ( gmesa->GeometryMode != g ) {
+ gmesa->GeometryMode = g;
+ gmesa->dirty |= GAMMA_UPLOAD_GEOMETRY;
+ }
+}
+
+static void gammaDDCullFace( GLcontext *ctx, GLenum mode )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_CULL;
+}
+
+static void gammaDDFrontFace( GLcontext *ctx, GLenum mode )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_CULL;
+}
+
+/* =============================================================
+ * Masks
+ */
+
+static void gammaUpdateMasks( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+
+ GLuint mask = gammaPackColor( gmesa->gammaScreen->cpp,
+ ctx->Color.ColorMask[RCOMP],
+ ctx->Color.ColorMask[GCOMP],
+ ctx->Color.ColorMask[BCOMP],
+ ctx->Color.ColorMask[ACOMP] );
+
+ if (gmesa->gammaScreen->cpp == 2) mask |= mask << 16;
+
+ if ( gmesa->FBHardwareWriteMask != mask ) {
+ gmesa->FBHardwareWriteMask = mask;
+ gmesa->dirty |= GAMMA_UPLOAD_MASKS;
+ }
+}
+
+static void gammaDDColorMask( GLcontext *ctx, GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a)
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_MASKS;
+}
+
+/* =============================================================
+ * Rendering attributes
+ *
+ * We really don't want to recalculate all this every time we bind a
+ * texture. These things shouldn't change all that often, so it makes
+ * sense to break them out of the core texture state update routines.
+ */
+
+#if ENABLELIGHTING
+static void gammaDDLightfv(GLcontext *ctx, GLenum light, GLenum pname,
+ const GLfloat *params, GLint nParams)
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ GLfloat l,x,y,z,w;
+
+ switch(light) {
+ case GL_LIGHT0:
+ switch (pname) {
+ case GL_AMBIENT:
+ CHECK_DMA_BUFFER(gmesa, 3);
+ /* We don't do alpha */
+ WRITEF(gmesa->buf, Light0AmbientIntensityBlue, params[2]);
+ WRITEF(gmesa->buf, Light0AmbientIntensityGreen, params[1]);
+ WRITEF(gmesa->buf, Light0AmbientIntensityRed, params[0]);
+ break;
+ case GL_DIFFUSE:
+ CHECK_DMA_BUFFER(gmesa, 3);
+ /* We don't do alpha */
+ WRITEF(gmesa->buf, Light0DiffuseIntensityBlue, params[2]);
+ WRITEF(gmesa->buf, Light0DiffuseIntensityGreen, params[1]);
+ WRITEF(gmesa->buf, Light0DiffuseIntensityRed, params[0]);
+ break;
+ case GL_SPECULAR:
+ CHECK_DMA_BUFFER(gmesa, 3);
+ /* We don't do alpha */
+ WRITEF(gmesa->buf, Light0SpecularIntensityBlue, params[2]);
+ WRITEF(gmesa->buf, Light0SpecularIntensityGreen, params[1]);
+ WRITEF(gmesa->buf, Light0SpecularIntensityRed, params[0]);
+ break;
+ case GL_POSITION:
+ /* Normalize <x,y,z> */
+ x = params[0]; y = params[1]; z = params[2]; w = params[3];
+ l = sqrt(x*x + y*y + z*z + w*w);
+ w /= l;
+ x /= l;
+ y /= l;
+ z /= l;
+ if (params[3] != 0.0) {
+ gmesa->Light0Mode |= Light0ModeAttenuation;
+ gmesa->Light0Mode |= Light0ModeLocal;
+ } else {
+ gmesa->Light0Mode &= ~Light0ModeAttenuation;
+ gmesa->Light0Mode &= ~Light0ModeLocal;
+ }
+ CHECK_DMA_BUFFER(gmesa, 5);
+ WRITE(gmesa->buf, Light0Mode, gmesa->Light0Mode);
+ WRITEF(gmesa->buf, Light0PositionW, w);
+ WRITEF(gmesa->buf, Light0PositionZ, z);
+ WRITEF(gmesa->buf, Light0PositionY, y);
+ WRITEF(gmesa->buf, Light0PositionX, x);
+ break;
+ case GL_SPOT_DIRECTION:
+ CHECK_DMA_BUFFER(gmesa, 3);
+ /* WRITEF(gmesa->buf, Light0SpotlightDirectionW, params[3]); */
+ WRITEF(gmesa->buf, Light0SpotlightDirectionZ, params[2]);
+ WRITEF(gmesa->buf, Light0SpotlightDirectionY, params[1]);
+ WRITEF(gmesa->buf, Light0SpotlightDirectionX, params[0]);
+ break;
+ case GL_SPOT_EXPONENT:
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITEF(gmesa->buf, Light0SpotlightExponent, params[0]);
+ break;
+ case GL_SPOT_CUTOFF:
+ if (params[0] != 180.0)
+ gmesa->Light0Mode |= Light0ModeSpotLight;
+ else
+ gmesa->Light0Mode &= ~Light0ModeSpotLight;
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, Light0Mode, gmesa->Light0Mode);
+ WRITEF(gmesa->buf, Light0CosSpotlightCutoffAngle, cos(params[0]*DEG2RAD));
+ break;
+ case GL_CONSTANT_ATTENUATION:
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITEF(gmesa->buf, Light0ConstantAttenuation, params[0]);
+ break;
+ case GL_LINEAR_ATTENUATION:
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITEF(gmesa->buf, Light0LinearAttenuation, params[0]);
+ break;
+ case GL_QUADRATIC_ATTENUATION:
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITEF(gmesa->buf, Light0QuadraticAttenuation, params[0]);
+ break;
+ }
+ break;
+ }
+}
+
+static void gammaDDLightModelfv( GLcontext *ctx, GLenum pname,
+ const GLfloat *params )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ switch (pname) {
+ case GL_LIGHT_MODEL_AMBIENT:
+ CHECK_DMA_BUFFER(gmesa, 3);
+ /* We don't do alpha */
+ WRITEF(gmesa->buf, SceneAmbientColorBlue, params[2]);
+ WRITEF(gmesa->buf, SceneAmbientColorGreen, params[1]);
+ WRITEF(gmesa->buf, SceneAmbientColorRed, params[0]);
+ break;
+ case GL_LIGHT_MODEL_LOCAL_VIEWER:
+ if (params[0] != 0.0)
+ gmesa->LightingMode |= LightingModeLocalViewer;
+ else
+ gmesa->LightingMode &= ~LightingModeLocalViewer;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, LightingMode, gmesa->LightingMode);
+ break;
+ case GL_LIGHT_MODEL_TWO_SIDE:
+ if (params[0] == 1.0f) {
+ gmesa->LightingMode |= LightingModeTwoSides;
+ gmesa->MaterialMode |= MaterialModeTwoSides;
+ } else {
+ gmesa->LightingMode &= ~LightingModeTwoSides;
+ gmesa->MaterialMode &= ~MaterialModeTwoSides;
+ }
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, LightingMode, gmesa->LightingMode);
+ WRITE(gmesa->buf, MaterialMode, gmesa->MaterialMode);
+ break;
+ }
+}
+#endif
+
+static void gammaDDShadeModel( GLcontext *ctx, GLenum mode )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ u_int32_t g = gmesa->GeometryMode;
+ u_int32_t c = gmesa->ColorDDAMode;
+
+ g &= ~GM_ShadingMask;
+ c &= ~ColorDDAShadingMask;
+
+ switch ( mode ) {
+ case GL_FLAT:
+ g |= GM_FlatShading;
+ c |= ColorDDAFlat;
+ break;
+ case GL_SMOOTH:
+ g |= GM_GouraudShading;
+ c |= ColorDDAGouraud;
+ break;
+ default:
+ return;
+ }
+
+ if ( gmesa->ColorDDAMode != c ) {
+ FLUSH_BATCH( gmesa );
+ gmesa->ColorDDAMode = c;
+
+ gmesa->dirty |= GAMMA_UPLOAD_SHADE;
+ }
+
+ if ( gmesa->GeometryMode != g ) {
+ FLUSH_BATCH( gmesa );
+ gmesa->GeometryMode = g;
+
+ gmesa->dirty |= GAMMA_UPLOAD_GEOMETRY;
+ }
+}
+
+/* =============================================================
+ * Miscellaneous
+ */
+
+static void gammaDDClearColor( GLcontext *ctx, const GLfloat color[4])
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ GLubyte c[4];
+ UNCLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
+ UNCLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
+
+ gmesa->ClearColor = gammaPackColor( gmesa->gammaScreen->cpp,
+ c[0], c[1], c[2], c[3] );
+
+ if (gmesa->gammaScreen->cpp == 2) gmesa->ClearColor |= gmesa->ClearColor<<16;
+}
+
+
+static void gammaDDLogicalOpcode( GLcontext *ctx, GLenum opcode )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+
+ if ( ctx->Color.ColorLogicOpEnabled ) {
+ gmesa->LogicalOpMode = opcode << 1 | LogicalOpModeEnable;
+ } else {
+ gmesa->LogicalOpMode = LogicalOpModeDisable;
+ }
+
+ gmesa->dirty |= GAMMA_UPLOAD_LOGICOP;
+}
+
+static void gammaDDDrawBuffer( GLcontext *ctx, GLenum mode )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ FLUSH_BATCH( gmesa );
+
+ switch ( mode ) {
+ case GL_FRONT_LEFT:
+ gmesa->drawOffset = gmesa->readOffset = 0;
+ break;
+ case GL_BACK_LEFT:
+ gmesa->drawOffset = gmesa->readOffset = gmesa->driScreen->fbHeight * gmesa->driScreen->fbWidth * gmesa->gammaScreen->cpp;
+ break;
+ }
+}
+
+static void gammaDDReadBuffer( GLcontext *ctx, GLenum mode )
+{
+ /* XXX anything? */
+}
+
+/* =============================================================
+ * Window position and viewport transformation
+ */
+
+void gammaUpdateWindow( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = gmesa->driDrawable;
+ GLfloat xoffset = (GLfloat)dPriv->x;
+ GLfloat yoffset = gmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h;
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+
+ GLfloat sx = v[MAT_SX];
+ GLfloat tx = v[MAT_TX] + xoffset;
+ GLfloat sy = v[MAT_SY];
+ GLfloat ty = v[MAT_TY] + yoffset;
+ GLfloat sz = v[MAT_SZ] * gmesa->depth_scale;
+ GLfloat tz = v[MAT_TZ] * gmesa->depth_scale;
+
+ gmesa->dirty |= GAMMA_UPLOAD_VIEWPORT;
+
+ gmesa->ViewportScaleX = sx;
+ gmesa->ViewportScaleY = sy;
+ gmesa->ViewportScaleZ = sz;
+ gmesa->ViewportOffsetX = tx;
+ gmesa->ViewportOffsetY = ty;
+ gmesa->ViewportOffsetZ = tz;
+}
+
+
+
+static void gammaDDViewport( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
+ gammaUpdateWindow( ctx );
+}
+
+static void gammaDDDepthRange( GLcontext *ctx, GLclampd nearval,
+ GLclampd farval )
+{
+ gammaUpdateWindow( ctx );
+}
+
+void gammaUpdateViewportOffset( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = gmesa->driDrawable;
+ GLfloat xoffset = (GLfloat)dPriv->x;
+ GLfloat yoffset = gmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h;
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+
+ GLfloat tx = v[MAT_TX] + xoffset;
+ GLfloat ty = v[MAT_TY] + yoffset;
+
+ if ( gmesa->ViewportOffsetX != tx ||
+ gmesa->ViewportOffsetY != ty )
+ {
+ gmesa->ViewportOffsetX = tx;
+ gmesa->ViewportOffsetY = ty;
+
+ gmesa->new_state |= GAMMA_NEW_WINDOW;
+ }
+
+ gmesa->new_state |= GAMMA_NEW_CLIP;
+}
+
+#if 0
+/*
+ * Matrix
+ */
+
+static void gammaLoadHWMatrix(GLcontext *ctx)
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ const GLfloat *m;
+
+ gmesa->TransformMode &= ~XM_XformTexture;
+
+ switch (ctx->Transform.MatrixMode) {
+ case GL_MODELVIEW:
+ gmesa->TransformMode |= XM_UseModelViewMatrix;
+ m = ctx->ModelviewMatrixStack.Top->m;
+ CHECK_DMA_BUFFER(gmesa, 16);
+ WRITEF(gmesa->buf, ModelViewMatrix0, m[0]);
+ WRITEF(gmesa->buf, ModelViewMatrix1, m[1]);
+ WRITEF(gmesa->buf, ModelViewMatrix2, m[2]);
+ WRITEF(gmesa->buf, ModelViewMatrix3, m[3]);
+ WRITEF(gmesa->buf, ModelViewMatrix4, m[4]);
+ WRITEF(gmesa->buf, ModelViewMatrix5, m[5]);
+ WRITEF(gmesa->buf, ModelViewMatrix6, m[6]);
+ WRITEF(gmesa->buf, ModelViewMatrix7, m[7]);
+ WRITEF(gmesa->buf, ModelViewMatrix8, m[8]);
+ WRITEF(gmesa->buf, ModelViewMatrix9, m[9]);
+ WRITEF(gmesa->buf, ModelViewMatrix10, m[10]);
+ WRITEF(gmesa->buf, ModelViewMatrix11, m[11]);
+ WRITEF(gmesa->buf, ModelViewMatrix12, m[12]);
+ WRITEF(gmesa->buf, ModelViewMatrix13, m[13]);
+ WRITEF(gmesa->buf, ModelViewMatrix14, m[14]);
+ WRITEF(gmesa->buf, ModelViewMatrix15, m[15]);
+ break;
+ case GL_PROJECTION:
+ m = ctx->ProjectionMatrixStack.Top->m;
+ CHECK_DMA_BUFFER(gmesa, 16);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix0, m[0]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix1, m[1]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix2, m[2]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix3, m[3]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix4, m[4]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix5, m[5]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix6, m[6]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix7, m[7]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix8, m[8]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix9, m[9]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix10, m[10]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix11, m[11]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix12, m[12]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix13, m[13]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix14, m[14]);
+ WRITEF(gmesa->buf, ModelViewProjectionMatrix15, m[15]);
+ break;
+ case GL_TEXTURE:
+ m = ctx->TextureMatrixStack[0].Top->m;
+ CHECK_DMA_BUFFER(gmesa, 16);
+ gmesa->TransformMode |= XM_XformTexture;
+ WRITEF(gmesa->buf, TextureMatrix0, m[0]);
+ WRITEF(gmesa->buf, TextureMatrix1, m[1]);
+ WRITEF(gmesa->buf, TextureMatrix2, m[2]);
+ WRITEF(gmesa->buf, TextureMatrix3, m[3]);
+ WRITEF(gmesa->buf, TextureMatrix4, m[4]);
+ WRITEF(gmesa->buf, TextureMatrix5, m[5]);
+ WRITEF(gmesa->buf, TextureMatrix6, m[6]);
+ WRITEF(gmesa->buf, TextureMatrix7, m[7]);
+ WRITEF(gmesa->buf, TextureMatrix8, m[8]);
+ WRITEF(gmesa->buf, TextureMatrix9, m[9]);
+ WRITEF(gmesa->buf, TextureMatrix10, m[10]);
+ WRITEF(gmesa->buf, TextureMatrix11, m[11]);
+ WRITEF(gmesa->buf, TextureMatrix12, m[12]);
+ WRITEF(gmesa->buf, TextureMatrix13, m[13]);
+ WRITEF(gmesa->buf, TextureMatrix14, m[14]);
+ WRITEF(gmesa->buf, TextureMatrix15, m[15]);
+ break;
+
+ default:
+ /* ERROR!!! -- how did this happen? */
+ break;
+ }
+
+ gmesa->dirty |= GAMMA_UPLOAD_TRANSFORM;
+}
+#endif
+
+/* =============================================================
+ * State enable/disable
+ */
+
+static void gammaDDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ switch ( cap ) {
+ case GL_ALPHA_TEST:
+ case GL_BLEND:
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_ALPHA;
+ break;
+
+ case GL_CULL_FACE:
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_CULL;
+ break;
+
+ case GL_DEPTH_TEST:
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_DEPTH;
+ break;
+
+ case GL_DITHER:
+ do {
+ u_int32_t d = gmesa->DitherMode;
+ FLUSH_BATCH( gmesa );
+
+ if ( state ) {
+ d |= DM_DitherEnable;
+ } else {
+ d &= ~DM_DitherEnable;
+ }
+
+ if ( gmesa->DitherMode != d ) {
+ gmesa->DitherMode = d;
+ gmesa->dirty |= GAMMA_UPLOAD_DITHER;
+ }
+ } while (0);
+ break;
+
+#if 0
+ case GL_FOG:
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_FOG;
+ break;
+#endif
+
+ case GL_INDEX_LOGIC_OP:
+ case GL_COLOR_LOGIC_OP:
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_LOGICOP;
+ break;
+
+#if ENABLELIGHTING
+ case GL_LIGHTING:
+ do {
+ u_int32_t l = gmesa->LightingMode;
+ FLUSH_BATCH( gmesa );
+
+ if ( state ) {
+ l |= LightingModeEnable;
+ } else {
+ l &= ~LightingModeEnable;
+ }
+
+ if ( gmesa->LightingMode != l ) {
+ gmesa->LightingMode = l;
+ gmesa->dirty |= GAMMA_UPLOAD_LIGHT;
+ }
+ } while (0);
+ break;
+
+ case GL_COLOR_MATERIAL:
+ do {
+ u_int32_t m = gmesa->MaterialMode;
+ FLUSH_BATCH( gmesa );
+
+ if ( state ) {
+ m |= MaterialModeEnable;
+ } else {
+ m &= ~MaterialModeEnable;
+ }
+
+ if ( gmesa->MaterialMode != m ) {
+ gmesa->MaterialMode = m;
+ gmesa->dirty |= GAMMA_UPLOAD_LIGHT;
+ }
+ } while (0);
+ break;
+#endif
+
+ case GL_LINE_SMOOTH:
+ FLUSH_BATCH( gmesa );
+ if ( state ) {
+ gmesa->AntialiasMode |= AntialiasModeEnable;
+ gmesa->LineMode |= LM_AntialiasEnable;
+ } else {
+ gmesa->AntialiasMode &= ~AntialiasModeEnable;
+ gmesa->LineMode &= ~LM_AntialiasEnable;
+ }
+ gmesa->dirty |= GAMMA_UPLOAD_LINEMODE;
+ break;
+
+ case GL_POINT_SMOOTH:
+ FLUSH_BATCH( gmesa );
+ if ( state ) {
+ gmesa->AntialiasMode |= AntialiasModeEnable;
+ gmesa->PointMode |= PM_AntialiasEnable;
+ } else {
+ gmesa->AntialiasMode &= ~AntialiasModeEnable;
+ gmesa->PointMode &= ~PM_AntialiasEnable;
+ }
+ gmesa->dirty |= GAMMA_UPLOAD_POINTMODE;
+ break;
+
+ case GL_POLYGON_SMOOTH:
+ FLUSH_BATCH( gmesa );
+ if ( state ) {
+ gmesa->AntialiasMode |= AntialiasModeEnable;
+ gmesa->TriangleMode |= TM_AntialiasEnable;
+ } else {
+ gmesa->AntialiasMode &= ~AntialiasModeEnable;
+ gmesa->TriangleMode &= ~TM_AntialiasEnable;
+ }
+ gmesa->dirty |= GAMMA_UPLOAD_TRIMODE;
+ break;
+
+ case GL_SCISSOR_TEST:
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_CLIP;
+ break;
+
+ case GL_POLYGON_OFFSET_FILL:
+ case GL_POLYGON_OFFSET_POINT:
+ case GL_POLYGON_OFFSET_LINE:
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_POLYGON;
+ break;
+
+ case GL_LINE_STIPPLE:
+ FLUSH_BATCH( gmesa );
+ if ( state )
+ gmesa->LineMode |= LM_StippleEnable;
+ else
+ gmesa->LineMode &= ~LM_StippleEnable;
+ gmesa->dirty |= GAMMA_UPLOAD_LINEMODE;
+ break;
+
+ case GL_POLYGON_STIPPLE:
+ FLUSH_BATCH( gmesa );
+ gmesa->new_state |= GAMMA_NEW_STIPPLE;
+ break;
+
+ default:
+ return;
+ }
+}
+
+/* =============================================================
+ * State initialization, management
+ */
+
+
+/*
+ * Load the current context's state into the hardware.
+ *
+ * NOTE: Be VERY careful about ensuring the context state is marked for
+ * upload, the only place it shouldn't be uploaded is when the setup
+ * state has changed in ReducedPrimitiveChange as this comes right after
+ * a state update.
+ *
+ * Blits of any type should always upload the context and masks after
+ * they are done.
+ */
+void gammaEmitHwState( gammaContextPtr gmesa )
+{
+ if (!gmesa->driDrawable) return;
+
+ if (!gmesa->dirty) return;
+
+#ifdef DO_VALIDATE
+ /* Flush any partially filled buffers */
+ FLUSH_DMA_BUFFER(gmesa);
+
+ DRM_SPINLOCK(&gmesa->driScreen->pSAREA->drawable_lock,
+ gmesa->driScreen->drawLockID);
+ VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa);
+#endif
+
+ if (gmesa->dirty & GAMMA_UPLOAD_VIEWPORT) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_VIEWPORT;
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, ViewPortOffsetX, gmesa->ViewportOffsetX);
+ WRITEF(gmesa->buf, ViewPortOffsetY, gmesa->ViewportOffsetY);
+ WRITEF(gmesa->buf, ViewPortOffsetZ, gmesa->ViewportOffsetZ);
+ WRITEF(gmesa->buf, ViewPortScaleX, gmesa->ViewportScaleX);
+ WRITEF(gmesa->buf, ViewPortScaleY, gmesa->ViewportScaleY);
+ WRITEF(gmesa->buf, ViewPortScaleZ, gmesa->ViewportScaleZ);
+ }
+ if ( (gmesa->dirty & GAMMA_UPLOAD_POINTMODE) ||
+ (gmesa->dirty & GAMMA_UPLOAD_LINEMODE) ||
+ (gmesa->dirty & GAMMA_UPLOAD_TRIMODE) ) {
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, AntialiasMode, gmesa->AntialiasMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_POINTMODE) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_POINTMODE;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PointMode, gmesa->PointMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_LINEMODE) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_LINEMODE;
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, LineMode, gmesa->LineMode);
+ WRITE(gmesa->buf, LineStippleMode, gmesa->LineMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_TRIMODE) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_TRIMODE;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TriangleMode, gmesa->TriangleMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_FOG) {
+ GLchan c[3], col;
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( c, gmesa->glCtx->Fog.Color );
+ col = gammaPackColor(4, c[0], c[1], c[2], 0);
+ gmesa->dirty &= ~GAMMA_UPLOAD_FOG;
+ CHECK_DMA_BUFFER(gmesa, 5);
+#if 0
+ WRITE(gmesa->buf, FogMode, gmesa->FogMode);
+ WRITE(gmesa->buf, FogColor, col);
+ WRITEF(gmesa->buf, FStart, gmesa->glCtx->Fog.Start);
+#endif
+ WRITEF(gmesa->buf, FogEnd, gmesa->glCtx->Fog.End);
+ WRITEF(gmesa->buf, FogDensity, gmesa->glCtx->Fog.Density);
+ WRITEF(gmesa->buf, FogScale,
+ 1.0f/(gmesa->glCtx->Fog.End - gmesa->glCtx->Fog.Start));
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_DITHER) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_DITHER;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, DitherMode, gmesa->DitherMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_LOGICOP) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_LOGICOP;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, LogicalOpMode, gmesa->LogicalOpMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_CLIP) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_CLIP;
+ CHECK_DMA_BUFFER(gmesa, 3);
+ WRITE(gmesa->buf, ScissorMinXY, gmesa->ScissorMinXY);
+ WRITE(gmesa->buf, ScissorMaxXY, gmesa->ScissorMaxXY);
+ WRITE(gmesa->buf, ScissorMode, gmesa->ScissorMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_MASKS) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_MASKS;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, FBHardwareWriteMask, gmesa->FBHardwareWriteMask);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_ALPHA) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_ALPHA;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, AlphaTestMode, gmesa->AlphaTestMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_BLEND) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_BLEND;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, AlphaBlendMode, gmesa->AlphaBlendMode);
+ }
+ CHECK_DMA_BUFFER(gmesa, 1);
+ if (gmesa->glCtx->Color.BlendEnabled || gmesa->glCtx->Color.AlphaEnabled) {
+ WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode | gmesa->AB_FBReadMode_Save);
+ } else {
+ WRITE(gmesa->buf, FBReadMode, gmesa->FBReadMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_LIGHT) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_LIGHT;
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, LightingMode, gmesa->LightingMode);
+ WRITE(gmesa->buf, MaterialMode, gmesa->MaterialMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_SHADE) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_SHADE;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, ColorDDAMode, gmesa->ColorDDAMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_POLYGON) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_POLYGON;
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITEF(gmesa->buf, PolygonOffsetBias, gmesa->glCtx->Polygon.OffsetUnits);
+ WRITEF(gmesa->buf, PolygonOffsetFactor, gmesa->glCtx->Polygon.OffsetFactor);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_STIPPLE) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_STIPPLE;
+ CHECK_DMA_BUFFER(gmesa, 33);
+ WRITE(gmesa->buf, AreaStippleMode, gmesa->AreaStippleMode);
+ WRITE(gmesa->buf, AreaStipplePattern0, gmesa->glCtx->PolygonStipple[0]);
+ WRITE(gmesa->buf, AreaStipplePattern1, gmesa->glCtx->PolygonStipple[1]);
+ WRITE(gmesa->buf, AreaStipplePattern2, gmesa->glCtx->PolygonStipple[2]);
+ WRITE(gmesa->buf, AreaStipplePattern3, gmesa->glCtx->PolygonStipple[3]);
+ WRITE(gmesa->buf, AreaStipplePattern4, gmesa->glCtx->PolygonStipple[4]);
+ WRITE(gmesa->buf, AreaStipplePattern5, gmesa->glCtx->PolygonStipple[5]);
+ WRITE(gmesa->buf, AreaStipplePattern6, gmesa->glCtx->PolygonStipple[6]);
+ WRITE(gmesa->buf, AreaStipplePattern7, gmesa->glCtx->PolygonStipple[7]);
+ WRITE(gmesa->buf, AreaStipplePattern8, gmesa->glCtx->PolygonStipple[8]);
+ WRITE(gmesa->buf, AreaStipplePattern9, gmesa->glCtx->PolygonStipple[9]);
+ WRITE(gmesa->buf, AreaStipplePattern10, gmesa->glCtx->PolygonStipple[10]);
+ WRITE(gmesa->buf, AreaStipplePattern11, gmesa->glCtx->PolygonStipple[11]);
+ WRITE(gmesa->buf, AreaStipplePattern12, gmesa->glCtx->PolygonStipple[12]);
+ WRITE(gmesa->buf, AreaStipplePattern13, gmesa->glCtx->PolygonStipple[13]);
+ WRITE(gmesa->buf, AreaStipplePattern14, gmesa->glCtx->PolygonStipple[14]);
+ WRITE(gmesa->buf, AreaStipplePattern15, gmesa->glCtx->PolygonStipple[15]);
+ WRITE(gmesa->buf, AreaStipplePattern16, gmesa->glCtx->PolygonStipple[16]);
+ WRITE(gmesa->buf, AreaStipplePattern17, gmesa->glCtx->PolygonStipple[17]);
+ WRITE(gmesa->buf, AreaStipplePattern18, gmesa->glCtx->PolygonStipple[18]);
+ WRITE(gmesa->buf, AreaStipplePattern19, gmesa->glCtx->PolygonStipple[19]);
+ WRITE(gmesa->buf, AreaStipplePattern20, gmesa->glCtx->PolygonStipple[20]);
+ WRITE(gmesa->buf, AreaStipplePattern21, gmesa->glCtx->PolygonStipple[21]);
+ WRITE(gmesa->buf, AreaStipplePattern22, gmesa->glCtx->PolygonStipple[22]);
+ WRITE(gmesa->buf, AreaStipplePattern23, gmesa->glCtx->PolygonStipple[23]);
+ WRITE(gmesa->buf, AreaStipplePattern24, gmesa->glCtx->PolygonStipple[24]);
+ WRITE(gmesa->buf, AreaStipplePattern25, gmesa->glCtx->PolygonStipple[25]);
+ WRITE(gmesa->buf, AreaStipplePattern26, gmesa->glCtx->PolygonStipple[26]);
+ WRITE(gmesa->buf, AreaStipplePattern27, gmesa->glCtx->PolygonStipple[27]);
+ WRITE(gmesa->buf, AreaStipplePattern28, gmesa->glCtx->PolygonStipple[28]);
+ WRITE(gmesa->buf, AreaStipplePattern29, gmesa->glCtx->PolygonStipple[29]);
+ WRITE(gmesa->buf, AreaStipplePattern30, gmesa->glCtx->PolygonStipple[30]);
+ WRITE(gmesa->buf, AreaStipplePattern31, gmesa->glCtx->PolygonStipple[31]);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_DEPTH) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_DEPTH;
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITE(gmesa->buf, DepthMode, gmesa->DepthMode);
+ WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode);
+ WRITE(gmesa->buf, GLINTWindow,gmesa->Window | (gmesa->FrameCount << 9));
+ WRITE(gmesa->buf, LBReadMode, gmesa->LBReadMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_GEOMETRY) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_GEOMETRY;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, GeometryMode, gmesa->GeometryMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_TRANSFORM) {
+ gmesa->dirty &= ~GAMMA_UPLOAD_TRANSFORM;
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TransformMode, gmesa->TransformMode);
+ }
+ if (gmesa->dirty & GAMMA_UPLOAD_TEX0) {
+ gammaTextureObjectPtr curTex = gmesa->CurrentTexObj[0];
+ gmesa->dirty &= ~GAMMA_UPLOAD_TEX0;
+ if (curTex) {
+ CHECK_DMA_BUFFER(gmesa, 21);
+ WRITE(gmesa->buf, GeometryMode, gmesa->GeometryMode | GM_TextureEnable);
+ WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode | DM_TextureEnable);
+ WRITE(gmesa->buf, TextureAddressMode, curTex->TextureAddressMode);
+ WRITE(gmesa->buf, TextureReadMode, curTex->TextureReadMode);
+ WRITE(gmesa->buf, TextureColorMode, curTex->TextureColorMode);
+ WRITE(gmesa->buf, TextureFilterMode, curTex->TextureFilterMode);
+ WRITE(gmesa->buf, TextureFormat, curTex->TextureFormat);
+ WRITE(gmesa->buf, GLINTBorderColor, curTex->TextureBorderColor);
+ WRITE(gmesa->buf, TxBaseAddr0, curTex->TextureBaseAddr[0]);
+ WRITE(gmesa->buf, TxBaseAddr1, curTex->TextureBaseAddr[1]);
+ WRITE(gmesa->buf, TxBaseAddr2, curTex->TextureBaseAddr[2]);
+ WRITE(gmesa->buf, TxBaseAddr3, curTex->TextureBaseAddr[3]);
+ WRITE(gmesa->buf, TxBaseAddr4, curTex->TextureBaseAddr[4]);
+ WRITE(gmesa->buf, TxBaseAddr5, curTex->TextureBaseAddr[5]);
+ WRITE(gmesa->buf, TxBaseAddr6, curTex->TextureBaseAddr[6]);
+ WRITE(gmesa->buf, TxBaseAddr7, curTex->TextureBaseAddr[7]);
+ WRITE(gmesa->buf, TxBaseAddr8, curTex->TextureBaseAddr[8]);
+ WRITE(gmesa->buf, TxBaseAddr9, curTex->TextureBaseAddr[9]);
+ WRITE(gmesa->buf, TxBaseAddr10, curTex->TextureBaseAddr[10]);
+ WRITE(gmesa->buf, TxBaseAddr11, curTex->TextureBaseAddr[11]);
+ WRITE(gmesa->buf, TextureCacheControl, (TCC_Enable | TCC_Invalidate));
+ } else {
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITE(gmesa->buf, GeometryMode, gmesa->GeometryMode);
+ WRITE(gmesa->buf, DeltaMode, gmesa->DeltaMode);
+ WRITE(gmesa->buf, TextureAddressMode, TextureAddressModeDisable);
+ WRITE(gmesa->buf, TextureReadMode, TextureReadModeDisable);
+ WRITE(gmesa->buf, TextureFilterMode, TextureFilterModeDisable);
+ WRITE(gmesa->buf, TextureColorMode, TextureColorModeDisable);
+ }
+ }
+#ifdef DO_VALIDATE
+ PROCESS_DMA_BUFFER_TOP_HALF(gmesa);
+
+ DRM_SPINUNLOCK(&gmesa->driScreen->pSAREA->drawable_lock,
+ gmesa->driScreen->drawLockID);
+ VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa);
+
+ PROCESS_DMA_BUFFER_BOTTOM_HALF(gmesa);
+#endif
+}
+
+void gammaDDUpdateHWState( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ int new_state = gmesa->new_state;
+
+ if ( new_state )
+ {
+ FLUSH_BATCH( gmesa );
+
+ gmesa->new_state = 0;
+
+ /* Update the various parts of the context's state.
+ */
+ if ( new_state & GAMMA_NEW_ALPHA )
+ gammaUpdateAlphaMode( ctx );
+
+ if ( new_state & GAMMA_NEW_DEPTH )
+ gammaUpdateZMode( ctx );
+
+ if ( new_state & GAMMA_NEW_FOG )
+ gammaUpdateFogAttrib( ctx );
+
+ if ( new_state & GAMMA_NEW_CLIP )
+ gammaUpdateClipping( ctx );
+
+ if ( new_state & GAMMA_NEW_POLYGON )
+ gammaUpdatePolygon( ctx );
+
+ if ( new_state & GAMMA_NEW_CULL )
+ gammaUpdateCull( ctx );
+
+ if ( new_state & GAMMA_NEW_MASKS )
+ gammaUpdateMasks( ctx );
+
+ if ( new_state & GAMMA_NEW_WINDOW )
+ gammaUpdateWindow( ctx );
+
+ if ( new_state & GAMMA_NEW_STIPPLE )
+ gammaUpdateStipple( ctx );
+ }
+
+ /* HACK ! */
+
+ gammaEmitHwState( gmesa );
+}
+
+
+static void gammaDDUpdateState( GLcontext *ctx, GLuint new_state )
+{
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ GAMMA_CONTEXT(ctx)->new_gl_state |= new_state;
+}
+
+
+/* Initialize the context's hardware state.
+ */
+void gammaDDInitState( gammaContextPtr gmesa )
+{
+ gmesa->new_state = 0;
+}
+
+/* Initialize the driver's state functions.
+ */
+void gammaDDInitStateFuncs( GLcontext *ctx )
+{
+ ctx->Driver.UpdateState = gammaDDUpdateState;
+
+ ctx->Driver.Clear = gammaDDClear;
+ ctx->Driver.ClearIndex = NULL;
+ ctx->Driver.ClearColor = gammaDDClearColor;
+ ctx->Driver.DrawBuffer = gammaDDDrawBuffer;
+ ctx->Driver.ReadBuffer = gammaDDReadBuffer;
+
+ ctx->Driver.IndexMask = NULL;
+ ctx->Driver.ColorMask = gammaDDColorMask;
+
+ ctx->Driver.AlphaFunc = gammaDDAlphaFunc;
+ ctx->Driver.BlendEquationSeparate = gammaDDBlendEquationSeparate;
+ ctx->Driver.BlendFuncSeparate = gammaDDBlendFuncSeparate;
+ ctx->Driver.ClearDepth = gammaDDClearDepth;
+ ctx->Driver.CullFace = gammaDDCullFace;
+ ctx->Driver.FrontFace = gammaDDFrontFace;
+ ctx->Driver.DepthFunc = gammaDDDepthFunc;
+ ctx->Driver.DepthMask = gammaDDDepthMask;
+ ctx->Driver.DepthRange = gammaDDDepthRange;
+ ctx->Driver.Enable = gammaDDEnable;
+ ctx->Driver.Finish = gammaDDFinish;
+ ctx->Driver.Flush = gammaDDFlush;
+#if 0
+ ctx->Driver.Fogfv = gammaDDFogfv;
+#endif
+ ctx->Driver.Hint = NULL;
+ ctx->Driver.LineWidth = gammaDDLineWidth;
+ ctx->Driver.LineStipple = gammaDDLineStipple;
+#if ENABLELIGHTING
+ ctx->Driver.Lightfv = gammaDDLightfv;
+ ctx->Driver.LightModelfv = gammaDDLightModelfv;
+#endif
+ ctx->Driver.LogicOpcode = gammaDDLogicalOpcode;
+ ctx->Driver.PointSize = gammaDDPointSize;
+ ctx->Driver.PolygonMode = gammaDDPolygonMode;
+ ctx->Driver.PolygonStipple = gammaDDPolygonStipple;
+ ctx->Driver.Scissor = gammaDDScissor;
+ ctx->Driver.ShadeModel = gammaDDShadeModel;
+ ctx->Driver.ClearStencil = NULL;
+ ctx->Driver.StencilFunc = NULL;
+ ctx->Driver.StencilMask = NULL;
+ ctx->Driver.StencilOp = NULL;
+ ctx->Driver.Viewport = gammaDDViewport;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_tex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_tex.c
new file mode 100644
index 000000000..d4fc93f86
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_tex.c
@@ -0,0 +1,433 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_tex.c,v 1.4 2002/11/05 17:46:07 tsi Exp $ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "imports.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "texstore.h"
+#include "teximage.h"
+#include "texformat.h"
+#include "texobj.h"
+#include "swrast/swrast.h"
+
+#include "mm.h"
+#include "gamma_context.h"
+#include "colormac.h"
+
+
+/*
+ * Compute the 'S2.4' lod bias factor from the floating point OpenGL bias.
+ */
+#if 0
+static GLuint gammaComputeLodBias(GLfloat bias)
+{
+ return bias;
+}
+#endif
+
+static void gammaSetTexWrapping(gammaTextureObjectPtr t,
+ GLenum wraps, GLenum wrapt)
+{
+ u_int32_t t1 = t->TextureAddressMode;
+ u_int32_t t2 = t->TextureReadMode;
+
+ t1 &= ~(TAM_SWrap_Mask | TAM_TWrap_Mask);
+ t2 &= ~(TRM_UWrap_Mask | TRM_VWrap_Mask);
+
+ if (wraps != GL_CLAMP) {
+ t1 |= TAM_SWrap_Repeat;
+ t2 |= TRM_UWrap_Repeat;
+ }
+
+ if (wrapt != GL_CLAMP) {
+ t1 |= TAM_TWrap_Repeat;
+ t2 |= TRM_VWrap_Repeat;
+ }
+
+ t->TextureAddressMode = t1;
+ t->TextureReadMode = t2;
+}
+
+
+static void gammaSetTexFilter(gammaContextPtr gmesa,
+ gammaTextureObjectPtr t,
+ GLenum minf, GLenum magf,
+ GLfloat bias)
+{
+ u_int32_t t1 = t->TextureAddressMode;
+ u_int32_t t2 = t->TextureReadMode;
+
+ t2 &= ~(TRM_Mag_Mask | TRM_Min_Mask);
+
+ switch (minf) {
+ case GL_NEAREST:
+ t1 &= ~TAM_LODEnable;
+ t2 &= ~TRM_MipMapEnable;
+ t2 |= TRM_Min_Nearest;
+ break;
+ case GL_LINEAR:
+ t1 &= ~TAM_LODEnable;
+ t2 &= ~TRM_MipMapEnable;
+ t2 |= TRM_Min_Linear;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ t2 |= TRM_Min_NearestMMNearest;
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ t2 |= TRM_Min_LinearMMNearest;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ t2 |= TRM_Min_NearestMMLinear;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ t2 |= TRM_Min_LinearMMLinear;
+ break;
+ default:
+ break;
+ }
+
+ switch (magf) {
+ case GL_NEAREST:
+ t2 |= TRM_Mag_Nearest;
+ break;
+ case GL_LINEAR:
+ t2 |= TRM_Mag_Linear;
+ break;
+ default:
+ break;
+ }
+
+ t->TextureAddressMode = t1;
+ t->TextureReadMode = t2;
+}
+
+
+static void gammaSetTexBorderColor(gammaContextPtr gmesa,
+ gammaTextureObjectPtr t,
+ GLubyte color[4])
+{
+ t->TextureBorderColor = PACK_COLOR_8888(color[0], color[1], color[2], color[3]);
+}
+
+
+static void gammaTexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat *params )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData;
+ if (!t)
+ return;
+
+ /* Can't do the update now as we don't know whether to flush
+ * vertices or not. Setting gmesa->new_state means that
+ * gammaUpdateTextureState() will be called before any triangles are
+ * rendered. If a statechange has occurred, it will be detected at
+ * that point, and buffered vertices flushed.
+ */
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ {
+ GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias;
+ gammaSetTexFilter( gmesa, t, tObj->MinFilter, tObj->MagFilter, bias );
+ }
+ break;
+
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ gammaSetTexWrapping( t, tObj->WrapS, tObj->WrapT );
+ break;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ gammaSetTexBorderColor( gmesa, t, tObj->_BorderChan );
+ break;
+
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ /* This isn't the most efficient solution but there doesn't appear to
+ * be a nice alternative for Radeon. Since there's no LOD clamping,
+ * we just have to rely on loading the right subset of mipmap levels
+ * to simulate a clamped LOD.
+ */
+ gammaSwapOutTexObj( gmesa, t );
+ break;
+
+ default:
+ return;
+ }
+
+ if (t == gmesa->CurrentTexObj[0])
+ gmesa->dirty |= GAMMA_UPLOAD_TEX0;
+
+#if 0
+ if (t == gmesa->CurrentTexObj[1]) {
+ gmesa->dirty |= GAMMA_UPLOAD_TEX1;
+ }
+#endif
+}
+
+
+static void gammaTexEnv( GLcontext *ctx, GLenum target,
+ GLenum pname, const GLfloat *param )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
+ GLuint unit = ctx->Texture.CurrentUnit;
+
+ /* Only one env color. Need a fallback if env colors are different
+ * and texture setup references env color in both units.
+ */
+ switch (pname) {
+ case GL_TEXTURE_ENV_COLOR: {
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ GLfloat *fc = texUnit->EnvColor;
+ GLuint r, g, b, a, col;
+ CLAMPED_FLOAT_TO_UBYTE(r, fc[0]);
+ CLAMPED_FLOAT_TO_UBYTE(g, fc[1]);
+ CLAMPED_FLOAT_TO_UBYTE(b, fc[2]);
+ CLAMPED_FLOAT_TO_UBYTE(a, fc[3]);
+
+ col = ((a << 24) |
+ (r << 16) |
+ (g << 8) |
+ (b << 0));
+
+ break;
+ }
+ case GL_TEXTURE_ENV_MODE:
+ gmesa->TexEnvImageFmt[unit] = 0; /* force recalc of env state */
+ break;
+
+ case GL_TEXTURE_LOD_BIAS_EXT:
+#if 0 /* ?!?!?! */
+ {
+ struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData;
+ (void) t;
+ /* XXX Looks like there's something missing here */
+ }
+#endif
+ break;
+
+ default:
+ break;
+ }
+}
+
+#if 0
+static void gammaTexImage1D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *pack,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData;
+ if (t) {
+ gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t );
+ }
+ _mesa_store_teximage1d( ctx, target, level, internalFormat,
+ width, border, format, type,
+ pixels, pack, texObj, texImage );
+}
+#endif
+
+#if 0
+static void gammaTexSubImage1D( GLcontext *ctx,
+ GLenum target,
+ GLint level,
+ GLint xoffset,
+ GLsizei width,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *pack,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData;
+ if (t) {
+ gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t );
+ }
+ _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
+ format, type, pixels, pack, texObj,
+ texImage);
+}
+#endif
+
+static void gammaTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData;
+ if (t) {
+ gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t );
+ }
+ _mesa_store_teximage2d( ctx, target, level, internalFormat,
+ width, height, border, format, type,
+ pixels, packing, texObj, texImage );
+}
+
+static void gammaTexSubImage2D( 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 )
+{
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr) texObj->DriverData;
+ if (t) {
+ gammaSwapOutTexObj( GAMMA_CONTEXT(ctx), t );
+ }
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
+}
+
+static void gammaBindTexture( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData;
+
+ if (!t) {
+ GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias;
+ t = CALLOC_STRUCT(gamma_texture_object_t);
+
+ /* Initialize non-image-dependent parts of the state:
+ */
+ t->globj = tObj;
+
+ t->TextureAddressMode = TextureAddressModeEnable | TAM_Operation_3D |
+ TAM_DY_Enable | TAM_LODEnable;
+ t->TextureReadMode = TextureReadModeEnable | TRM_PrimaryCacheEnable |
+ TRM_MipMapEnable | TRM_BorderClamp | TRM_Border;
+ t->TextureColorMode = TextureColorModeEnable;
+ t->TextureFilterMode = TextureFilterModeEnable;
+
+ if (target == GL_TEXTURE_2D) {
+ t->TextureAddressMode |= TAM_TexMapType_2D;
+ t->TextureReadMode |= TRM_TexMapType_2D;
+ }
+ else if (target == GL_TEXTURE_1D) {
+ t->TextureAddressMode |= TAM_TexMapType_1D;
+ t->TextureReadMode |= TRM_TexMapType_1D;
+ }
+
+ t->TextureColorMode = TextureColorModeEnable;
+
+ t->TextureFilterMode = TextureFilterModeEnable;
+
+#ifdef MESA_LITTLE_ENDIAN
+ t->TextureFormat = (TF_LittleEndian |
+#else
+ t->TextureFormat = (TF_BigEndian |
+#endif
+ TF_ColorOrder_RGB |
+ TF_OutputFmt_Texel);
+
+ t->dirty_images = ~0;
+
+ tObj->DriverData = t;
+ make_empty_list( t );
+
+ gammaSetTexWrapping( t, tObj->WrapS, tObj->WrapT );
+ gammaSetTexFilter( gmesa, t, tObj->MinFilter, tObj->MagFilter, bias );
+ gammaSetTexBorderColor( gmesa, t, tObj->_BorderChan );
+ }
+}
+
+static void gammaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
+{
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData;
+
+ if (t) {
+ gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
+#if 0
+ if (gmesa)
+ GAMMA_FIREVERTICES( gmesa );
+#endif
+ gammaDestroyTexObj( gmesa, t );
+ tObj->DriverData = 0;
+ }
+ /* Free mipmap images and the texture object itself */
+ _mesa_delete_texture_object(ctx, tObj);
+}
+
+static GLboolean gammaIsTextureResident( GLcontext *ctx,
+ struct gl_texture_object *tObj )
+{
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData;
+ return t && t->MemBlock;
+}
+
+#ifdef UNUSED
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
+ * Note: this function will be called during context creation to
+ * allocate the default texture objects.
+ * Note: we could use containment here to 'derive' the driver-specific
+ * texture object from the core mesa gl_texture_object. Not done at this time.
+ */
+static struct gl_texture_object *
+gammaNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+{
+ struct gl_texture_object *obj;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ return obj;
+}
+#endif
+
+void gammaInitTextureObjects( GLcontext *ctx )
+{
+ struct gl_texture_object *texObj;
+ GLuint tmp = ctx->Texture.CurrentUnit;
+
+ ctx->Texture.CurrentUnit = 0;
+
+ texObj = ctx->Texture.Unit[0].Current1D;
+ gammaBindTexture( ctx, GL_TEXTURE_1D, texObj );
+
+ texObj = ctx->Texture.Unit[0].Current2D;
+ gammaBindTexture( ctx, GL_TEXTURE_2D, texObj );
+
+#if 0
+ ctx->Texture.CurrentUnit = 1;
+
+ texObj = ctx->Texture.Unit[1].Current1D;
+ gammaBindTexture( ctx, GL_TEXTURE_1D, texObj );
+
+ texObj = ctx->Texture.Unit[1].Current2D;
+ gammaBindTexture( ctx, GL_TEXTURE_2D, texObj );
+#endif
+
+ ctx->Texture.CurrentUnit = tmp;
+}
+
+
+void gammaDDInitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->TexEnv = gammaTexEnv;
+ functions->TexImage2D = gammaTexImage2D;
+ functions->TexSubImage2D = gammaTexSubImage2D;
+ functions->BindTexture = gammaBindTexture;
+ functions->DeleteTexture = gammaDeleteTexture;
+ functions->TexParameter = gammaTexParameter;
+ functions->IsTextureResident = gammaIsTextureResident;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_texmem.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_texmem.c
new file mode 100644
index 000000000..506b5c4c8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_texmem.c
@@ -0,0 +1,535 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_texmem.c,v 1.5 2002/11/05 17:46:07 tsi Exp $ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "glheader.h"
+#include "colormac.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "enums.h"
+
+#include "mm.h"
+#include "glint_dri.h"
+#include "gamma_context.h"
+#include "gamma_lock.h"
+
+void gammaDestroyTexObj(gammaContextPtr gmesa, gammaTextureObjectPtr t)
+{
+ if (!t) return;
+
+ /* This is sad - need to sync *in case* we upload a texture
+ * to this newly free memory...
+ */
+ if (t->MemBlock) {
+ mmFreeMem(t->MemBlock);
+ t->MemBlock = 0;
+
+ if (gmesa && t->age > gmesa->dirtyAge)
+ gmesa->dirtyAge = t->age;
+ }
+
+ if (t->globj)
+ t->globj->DriverData = 0;
+
+ if (gmesa) {
+ if (gmesa->CurrentTexObj[0] == t) {
+ gmesa->CurrentTexObj[0] = 0;
+ gmesa->dirty &= ~GAMMA_UPLOAD_TEX0;
+ }
+
+#if 0
+ if (gmesa->CurrentTexObj[1] == t) {
+ gmesa->CurrentTexObj[1] = 0;
+ gmesa->dirty &= ~GAMMA_UPLOAD_TEX1;
+ }
+#endif
+ }
+
+ remove_from_list(t);
+ free(t);
+}
+
+
+void gammaSwapOutTexObj(gammaContextPtr gmesa, gammaTextureObjectPtr t)
+{
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ if (t->MemBlock) {
+ mmFreeMem(t->MemBlock);
+ t->MemBlock = 0;
+
+ if (t->age > gmesa->dirtyAge)
+ gmesa->dirtyAge = t->age;
+ }
+
+ t->dirty_images = ~0;
+ move_to_tail(&(gmesa->SwappedOut), t);
+}
+
+
+
+/* Upload an image from mesa's internal copy.
+ */
+static void gammaUploadTexLevel( gammaContextPtr gmesa, gammaTextureObjectPtr t, int level )
+{
+ const struct gl_texture_image *image = t->image[level].image;
+ int i,j;
+ int l2d;
+#if 0
+ int offset = 0;
+#endif
+ int words, depthLog2;
+
+ /* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ l2d = 5; /* 32bits per texel == 1<<5 */
+
+ if (level == 0) {
+ t->TextureAddressMode &= ~(TAM_WidthMask | TAM_HeightMask);
+ t->TextureAddressMode |= (image->WidthLog2 << 9) |
+ (image->HeightLog2 << 13);
+ t->TextureReadMode &= ~(TRM_WidthMask | TRM_HeightMask |
+ TRM_DepthMask | TRM_Border |
+ TRM_Patch);
+ t->TextureReadMode |= (image->WidthLog2 << 1) |
+ (image->HeightLog2 << 5) |
+ (l2d << 9);
+ t->TextureFormat &= ~(TF_CompnentsMask | TF_OneCompFmt_Mask);
+ }
+
+ t->TextureBaseAddr[level] = /* ??? */
+ (unsigned long)(t->image[level].offset + t->BufAddr) << 5;
+
+ CALC_LOG2(depthLog2, 1<<l2d);
+ words = (image->Width * image->Height) >> (5-depthLog2);
+
+ CHECK_DMA_BUFFER(gmesa, 3);
+ WRITE(gmesa->buf, LBWindowBase, t->TextureBaseAddr[level] >> 5);
+ WRITE(gmesa->buf, TextureCacheControl, (TCC_Enable | TCC_Invalidate));
+ WRITE(gmesa->buf, WaitForCompletion, 0);
+ FLUSH_DMA_BUFFER(gmesa);
+
+ switch (t->image[level].internalFormat) {
+ case GL_RGB:
+ case 3:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ if (level == 0)
+ t->TextureFormat |= TF_Compnents_3;
+
+#if 0 /* This is the texture download code we SHOULD be using */
+ /* In the routines below, but this causes an DMA overrun - WHY ? */
+ while (offset < words) {
+ int count = gmesa->bufSize;
+ int i;
+ count -= 3;
+ if (count > words-offset) count = words-offset;
+
+ gmesa->buf->i = GlintTextureDownloadOffsetTag;
+ gmesa->buf++;
+ gmesa->buf->i = offset;
+ gmesa->buf++;
+ gmesa->buf->i = (GlintTextureDataTag | ((count-1) << 16));
+ gmesa->buf++;
+
+ for (i = 0; i < count; i++) {
+ gmesa->buf->i = PACK_COLOR_565(src[0],src[1],src[2]);
+ gmesa->buf++;
+ src += 3;
+ }
+
+ gmesa->bufCount = count+3; /* texture data + 3 values */
+ offset += count;
+
+ FLUSH_DMA_BUFFER(gmesa);
+ }
+#else
+ /* The UGLY way, and SLOW !, but the above sometimes causes
+ * a DMA overrun error ??? FIXME ! */
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureDownloadOffset, 0);
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+ data = PACK_COLOR_565(src[0],src[1],src[2]);
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureData, data);
+ src += 3;
+ }
+ FLUSH_DMA_BUFFER(gmesa);
+#endif
+ }
+ break;
+
+ case GL_RGBA:
+ case 4:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ if (level == 0)
+ t->TextureFormat |= TF_Compnents_4;
+
+ /* The UGLY way, and SLOW !, but the above sometimes causes
+ * a DMA overrun error ??? FIXME ! */
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureDownloadOffset, 0);
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+ data = PACK_COLOR_8888(src[0],src[1],src[2],src[3]);
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureData, data);
+ src += 4;
+ }
+ FLUSH_DMA_BUFFER(gmesa);
+ }
+ break;
+
+ case GL_LUMINANCE:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ if (level == 0)
+ t->TextureFormat |= TF_Compnents_1 | TF_OneCompFmt_Lum;
+
+ /* The UGLY way, and SLOW !, but the above sometimes causes
+ * a DMA overrun error ??? FIXME ! */
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureDownloadOffset, 0);
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+ data = PACK_COLOR_888(src[0],src[0],src[0]);
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureData, data);
+ src ++;
+ }
+ FLUSH_DMA_BUFFER(gmesa);
+ }
+ break;
+
+ case GL_INTENSITY:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ if (level == 0)
+ t->TextureFormat |= TF_Compnents_1 | TF_OneCompFmt_Intensity;
+
+ /* The UGLY way, and SLOW !, but the above sometimes causes
+ * a DMA overrun error ??? FIXME ! */
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureDownloadOffset, 0);
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+ data = PACK_COLOR_8888(src[0],src[0],src[0],src[0]);
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureData, data);
+ src ++;
+ }
+ FLUSH_DMA_BUFFER(gmesa);
+ }
+ break;
+
+ case GL_LUMINANCE_ALPHA:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ if (level == 0)
+ t->TextureFormat |= TF_Compnents_2;
+
+ /* The UGLY way, and SLOW !, but the above sometimes causes
+ * a DMA overrun error ??? FIXME ! */
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureDownloadOffset, 0);
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+ data = PACK_COLOR_8888(src[0],src[0],src[0],src[1]);
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureData, data);
+ src += 2;
+ }
+ FLUSH_DMA_BUFFER(gmesa);
+ }
+ break;
+
+ case GL_ALPHA:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ if (level == 0)
+ t->TextureFormat |= TF_Compnents_1 | TF_OneCompFmt_Alpha;
+
+ /* The UGLY way, and SLOW !, but the above sometimes causes
+ * a DMA overrun error ??? FIXME ! */
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureDownloadOffset, 0);
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+ data = PACK_COLOR_8888(255,255,255,src[0]);
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, TextureData, data);
+ src += 1;
+ }
+ FLUSH_DMA_BUFFER(gmesa);
+ }
+ break;
+
+ /* TODO: Translate color indices *now*:
+ */
+ case GL_COLOR_INDEX:
+ {
+ GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[level].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) {
+ for (i = 0 ; i < image->Width ; i++) {
+ dst[i] = src[0];
+ src += 1;
+ }
+ }
+ }
+ break;
+
+ default:
+ fprintf(stderr, "Not supported texture format %s\n",
+ _mesa_lookup_enum_by_nr(image->Format));
+ }
+
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, WaitForCompletion, 0);
+ WRITE(gmesa->buf, LBWindowBase, gmesa->LBWindowBase);
+}
+
+void gammaPrintLocalLRU( gammaContextPtr gmesa )
+{
+ gammaTextureObjectPtr t;
+ int sz = 1 << (gmesa->gammaScreen->logTextureGranularity);
+
+ foreach( t, &gmesa->TexObjList ) {
+ if (!t->globj)
+ fprintf(stderr, "Placeholder %d at %x sz %x\n",
+ t->MemBlock->ofs / sz,
+ t->MemBlock->ofs,
+ t->MemBlock->size);
+ else
+ fprintf(stderr, "Texture at %x sz %x\n",
+ t->MemBlock->ofs,
+ t->MemBlock->size);
+
+ }
+}
+
+void gammaPrintGlobalLRU( gammaContextPtr gmesa )
+{
+ int i, j;
+ GAMMATextureRegionPtr list = gmesa->sarea->texList;
+
+ for (i = 0, j = GAMMA_NR_TEX_REGIONS ; i < GAMMA_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 == GAMMA_NR_TEX_REGIONS) break;
+ }
+
+ if (j != GAMMA_NR_TEX_REGIONS)
+ fprintf(stderr, "Loop detected in global LRU\n");
+}
+
+
+void gammaResetGlobalLRU( gammaContextPtr gmesa )
+{
+ GAMMATextureRegionPtr list = gmesa->sarea->texList;
+ int sz = 1 << gmesa->gammaScreen->logTextureGranularity;
+ int i;
+
+ /* (Re)initialize the global circular LRU list. The last element
+ * in the array (GAMMA_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) * sz <= gmesa->gammaScreen->textureSize ; i++) {
+ list[i].prev = i-1;
+ list[i].next = i+1;
+ list[i].age = 0;
+ }
+
+ i--;
+ list[0].prev = GAMMA_NR_TEX_REGIONS;
+ list[i].prev = i-1;
+ list[i].next = GAMMA_NR_TEX_REGIONS;
+ list[GAMMA_NR_TEX_REGIONS].prev = i;
+ list[GAMMA_NR_TEX_REGIONS].next = 0;
+ gmesa->sarea->texAge = 0;
+}
+
+
+void gammaUpdateTexLRU( gammaContextPtr gmesa, gammaTextureObjectPtr t )
+{
+ int i;
+ int logsz = gmesa->gammaScreen->logTextureGranularity;
+ int start = t->MemBlock->ofs >> logsz;
+ int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz;
+ GAMMATextureRegionPtr list = gmesa->sarea->texList;
+
+ gmesa->texAge = ++gmesa->sarea->texAge;
+
+ /* Update our local LRU
+ */
+ move_to_head( &(gmesa->TexObjList), t );
+
+ /* Update the global LRU
+ */
+ for (i = start ; i <= end ; i++) {
+
+ list[i].in_use = 1;
+ list[i].age = gmesa->texAge;
+
+ /* remove_from_list(i)
+ */
+ list[(unsigned)list[i].next].prev = list[i].prev;
+ list[(unsigned)list[i].prev].next = list[i].next;
+
+ /* insert_at_head(list, i)
+ */
+ list[i].prev = GAMMA_NR_TEX_REGIONS;
+ list[i].next = list[GAMMA_NR_TEX_REGIONS].next;
+ list[(unsigned)list[GAMMA_NR_TEX_REGIONS].next].prev = i;
+ list[GAMMA_NR_TEX_REGIONS].next = i;
+ }
+}
+
+
+/* Called for every shared texture region which has increased in age
+ * since we last held the lock.
+ *
+ * Figures out which of our textures have been ejected by other clients,
+ * and pushes a placeholder texture onto the LRU list to represent
+ * the other client's textures.
+ */
+void gammaTexturesGone( gammaContextPtr gmesa,
+ GLuint offset,
+ GLuint size,
+ GLuint in_use )
+{
+ gammaTextureObjectPtr t, tmp;
+
+ foreach_s ( t, tmp, &gmesa->TexObjList ) {
+
+ if (t->MemBlock->ofs >= offset + size ||
+ t->MemBlock->ofs + t->MemBlock->size <= offset)
+ continue;
+
+ /* It overlaps - kick it off. Need to hold onto the currently bound
+ * objects, however.
+ */
+ gammaSwapOutTexObj( gmesa, t );
+ }
+
+ if (in_use) {
+ t = (gammaTextureObjectPtr) calloc(1,sizeof(*t));
+ if (!t) return;
+
+ t->MemBlock = mmAllocMem( gmesa->texHeap, size, 0, offset);
+ insert_at_head( &gmesa->TexObjList, t );
+ }
+
+ /* Reload any lost textures referenced by current vertex buffer.
+ */
+#if 0
+ if (gmesa->vertex_buffer) {
+ int i, j;
+
+ fprintf(stderr, "\n\nreload tex\n");
+
+ for (i = 0 ; i < gmesa->statenr ; i++) {
+ for (j = 0 ; j < 2 ; j++) {
+ gammaTextureObjectPtr t = gmesa->state_tex[j][i];
+ if (t) {
+ if (t->MemBlock == 0)
+ gammaUploadTexImages( gmesa, t );
+ }
+ }
+ }
+
+ /* Hard to do this with the lock held:
+ */
+/* GAMMA_FIREVERTICES( gmesa ); */
+ }
+#endif
+}
+
+
+
+
+
+/* This is called with the lock held. May have to eject our own and/or
+ * other client's texture objects to make room for the upload.
+ */
+void gammaUploadTexImages( gammaContextPtr gmesa, gammaTextureObjectPtr t )
+{
+ int i;
+ int ofs;
+ int numLevels;
+
+ /* /fprintf(stderr, "%s\n", __FUNCTION__); */
+#if 0
+ LOCK_HARDWARE( gmesa );
+#endif
+
+ /* Do we need to eject LRU texture objects?
+ */
+ if (!t->MemBlock) {
+ while (1)
+ {
+ t->MemBlock = mmAllocMem( gmesa->texHeap, t->totalSize, 12, 0 );
+ if (t->MemBlock)
+ break;
+
+ if (gmesa->TexObjList.prev == gmesa->CurrentTexObj[0] ||
+ gmesa->TexObjList.prev == gmesa->CurrentTexObj[1]) {
+ fprintf(stderr, "Hit bound texture in upload\n");
+ gammaPrintLocalLRU( gmesa );
+ return;
+ }
+
+ if (gmesa->TexObjList.prev == &(gmesa->TexObjList)) {
+ fprintf(stderr, "Failed to upload texture, sz %d\n", t->totalSize);
+ mmDumpMemInfo( gmesa->texHeap );
+ return;
+ }
+
+ gammaSwapOutTexObj( gmesa, gmesa->TexObjList.prev );
+ }
+
+ ofs = t->MemBlock->ofs;
+ t->BufAddr = (char *)(unsigned long)(gmesa->LBWindowBase + ofs); /* ??? */
+
+ if (t == gmesa->CurrentTexObj[0])
+ gmesa->dirty |= GAMMA_UPLOAD_TEX0;
+
+#if 0
+ if (t == gmesa->CurrentTexObj[1])
+ gmesa->dirty |= GAMMA_UPLOAD_TEX1;
+#endif
+
+ gammaUpdateTexLRU( gmesa, t );
+ }
+
+#if 0
+ if (gmesa->dirtyAge >= GET_DISPATCH_AGE(gmesa))
+ gammaWaitAgeLocked( gmesa, gmesa->dirtyAge );
+#endif
+
+ numLevels = t->lastLevel - t->firstLevel + 1;
+ for (i = 0 ; i < numLevels ; i++)
+ if (t->dirty_images & (1<<i))
+ gammaUploadTexLevel( gmesa, t, i );
+
+ t->dirty_images = 0;
+
+#if 0
+ UNLOCK_HARDWARE( gmesa );
+#endif
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_texstate.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_texstate.c
new file mode 100644
index 000000000..a8d1b253c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_texstate.c
@@ -0,0 +1,216 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_texstate.c,v 1.5 2002/11/05 17:46:07 tsi Exp $ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "enums.h"
+
+#include "mm.h"
+#include "gamma_context.h"
+
+static void gammaSetTexImages( gammaContextPtr gmesa,
+ struct gl_texture_object *tObj )
+{
+ GLuint height, width, pitch, i, log_pitch;
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr) tObj->DriverData;
+ const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
+ GLint firstLevel, lastLevel, numLevels;
+ GLint log2Width, log2Height;
+
+ /* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ t->texelBytes = 2;
+
+ /* Compute which mipmap levels we really want to send to the hardware.
+ * This depends on the base image size, GL_TEXTURE_MIN_LOD,
+ * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
+ * Yes, this looks overly complicated, but it's all needed.
+ */
+ if (tObj->MinFilter == GL_LINEAR || tObj->MinFilter == GL_NEAREST) {
+ firstLevel = lastLevel = tObj->BaseLevel;
+ }
+ else {
+ firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
+ firstLevel = MAX2(firstLevel, tObj->BaseLevel);
+ lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
+ lastLevel = MAX2(lastLevel, tObj->BaseLevel);
+ lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
+ lastLevel = MIN2(lastLevel, tObj->MaxLevel);
+ lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
+ }
+
+ /* save these values */
+ t->firstLevel = firstLevel;
+ t->lastLevel = lastLevel;
+
+ numLevels = lastLevel - firstLevel + 1;
+
+ log2Width = tObj->Image[0][firstLevel]->WidthLog2;
+ log2Height = tObj->Image[0][firstLevel]->HeightLog2;
+
+
+ /* Figure out the amount of memory required to hold all the mipmap
+ * levels. Choose the smallest pitch to accomodate the largest
+ * mipmap:
+ */
+ width = tObj->Image[0][firstLevel]->Width * t->texelBytes;
+ for (pitch = 32, log_pitch=2 ; pitch < width ; pitch *= 2 )
+ log_pitch++;
+
+ /* All images must be loaded at this pitch. Count the number of
+ * lines required:
+ */
+ for ( height = i = 0 ; i < numLevels ; i++ ) {
+ t->image[i].image = tObj->Image[0][firstLevel + i];
+ t->image[i].offset = height * pitch;
+ t->image[i].internalFormat = baseImage->Format;
+ height += t->image[i].image->Height;
+ t->TextureBaseAddr[i] = /* ??? */
+ (unsigned long)(t->image[i].offset + t->BufAddr) << 5;
+
+ }
+
+ t->Pitch = pitch;
+ t->totalSize = height*pitch;
+ t->max_level = i-1;
+ gmesa->dirty |= GAMMA_UPLOAD_TEX0 /* | GAMMA_UPLOAD_TEX1*/;
+
+ gammaUploadTexImages( gmesa, t );
+}
+
+static void gammaUpdateTexEnv( GLcontext *ctx, GLuint unit )
+{
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ const struct gl_texture_object *tObj = texUnit->_Current;
+ const GLuint format = tObj->Image[0][tObj->BaseLevel]->Format;
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData;
+ GLuint tc;
+
+ /* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ tc = t->TextureColorMode & ~(TCM_BaseFormatMask | TCM_ApplicationMask);
+
+ switch (format) {
+ case GL_RGB:
+ tc |= TCM_BaseFormat_RGB;
+ break;
+ case GL_LUMINANCE:
+ tc |= TCM_BaseFormat_Lum;
+ break;
+ case GL_ALPHA:
+ tc |= TCM_BaseFormat_Alpha;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ tc |= TCM_BaseFormat_LumAlpha;
+ break;
+ case GL_INTENSITY:
+ tc |= TCM_BaseFormat_Intensity;
+ break;
+ case GL_RGBA:
+ tc |= TCM_BaseFormat_RGBA;
+ break;
+ case GL_COLOR_INDEX:
+ break;
+ }
+
+ switch (texUnit->EnvMode) {
+ case GL_REPLACE:
+ tc |= TCM_Replace;
+ break;
+ case GL_MODULATE:
+ tc |= TCM_Modulate;
+ break;
+ case GL_ADD:
+ /* do nothing ???*/
+ break;
+ case GL_DECAL:
+ tc |= TCM_Decal;
+ break;
+ case GL_BLEND:
+ tc |= TCM_Blend;
+ break;
+ default:
+ fprintf(stderr, "unknown tex env mode");
+ return;
+ }
+
+ t->TextureColorMode = tc;
+}
+
+
+
+
+static void gammaUpdateTexUnit( GLcontext *ctx, GLuint unit )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+ /* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ if (texUnit->_ReallyEnabled == TEXTURE_2D_BIT)
+ {
+ struct gl_texture_object *tObj = texUnit->_Current;
+ gammaTextureObjectPtr t = (gammaTextureObjectPtr)tObj->DriverData;
+
+ /* Upload teximages (not pipelined)
+ */
+ if (t->dirty_images) {
+ gammaSetTexImages( gmesa, tObj );
+ if (!t->MemBlock) {
+ FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_TRUE );
+ return;
+ }
+ }
+
+#if 0
+ if (tObj->Image[0][tObj->BaseLevel]->Border > 0) {
+ FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_TRUE );
+ return;
+ }
+#endif
+
+ /* Update state if this is a different texture object to last
+ * time.
+ */
+ if (gmesa->CurrentTexObj[unit] != t) {
+ gmesa->dirty |= GAMMA_UPLOAD_TEX0 /* << unit */;
+ gmesa->CurrentTexObj[unit] = t;
+ gammaUpdateTexLRU( gmesa, t ); /* done too often */
+ }
+
+ /* Update texture environment if texture object image format or
+ * texture environment state has changed.
+ */
+ if (tObj->Image[0][tObj->BaseLevel]->Format != gmesa->TexEnvImageFmt[unit]) {
+ gmesa->TexEnvImageFmt[unit] = tObj->Image[0][tObj->BaseLevel]->Format;
+ gammaUpdateTexEnv( ctx, unit );
+ }
+ }
+ else if (texUnit->_ReallyEnabled) {
+ FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_TRUE );
+ }
+ else /*if (gmesa->CurrentTexObj[unit])*/ {
+ gmesa->CurrentTexObj[unit] = 0;
+ gmesa->TexEnvImageFmt[unit] = 0;
+ gmesa->dirty &= ~(GAMMA_UPLOAD_TEX0<<unit);
+ }
+}
+
+
+void gammaUpdateTextureState( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ /* fprintf(stderr, "%s\n", __FUNCTION__); */
+ FALLBACK( gmesa, GAMMA_FALLBACK_TEXTURE, GL_FALSE );
+ gammaUpdateTexUnit( ctx, 0 );
+#if 0
+ gammaUpdateTexUnit( ctx, 1 );
+#endif
+}
+
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_tris.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_tris.c
new file mode 100644
index 000000000..83bf56a14
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_tris.c
@@ -0,0 +1,659 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * 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@tungstengraphics.com>
+ * Keith Whitwell, <keith@tungstengraphics.com>
+ *
+ * 3DLabs Gamma driver.
+ */
+
+#include "gamma_context.h"
+#include "gamma_vb.h"
+#include "gamma_tris.h"
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "colormac.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
+
+/***********************************************************************
+ * Build hardware rasterization functions *
+ ***********************************************************************/
+
+#define GAMMA_RAST_ALPHA_BIT 0x01
+#define GAMMA_RAST_TEX_BIT 0x02
+#define GAMMA_RAST_FLAT_BIT 0x04
+
+static gamma_point_func gamma_point_tab[0x8];
+static gamma_line_func gamma_line_tab[0x8];
+static gamma_tri_func gamma_tri_tab[0x8];
+static gamma_quad_func gamma_quad_tab[0x8];
+
+#define IND (0)
+#define TAG(x) x
+#include "gamma_tritmp.h"
+
+#define IND (GAMMA_RAST_ALPHA_BIT)
+#define TAG(x) x##_alpha
+#include "gamma_tritmp.h"
+
+#define IND (GAMMA_RAST_TEX_BIT)
+#define TAG(x) x##_tex
+#include "gamma_tritmp.h"
+
+#define IND (GAMMA_RAST_ALPHA_BIT|GAMMA_RAST_TEX_BIT)
+#define TAG(x) x##_alpha_tex
+#include "gamma_tritmp.h"
+
+#define IND (GAMMA_RAST_FLAT_BIT)
+#define TAG(x) x##_flat
+#include "gamma_tritmp.h"
+
+#define IND (GAMMA_RAST_ALPHA_BIT|GAMMA_RAST_FLAT_BIT)
+#define TAG(x) x##_alpha_flat
+#include "gamma_tritmp.h"
+
+#define IND (GAMMA_RAST_TEX_BIT|GAMMA_RAST_FLAT_BIT)
+#define TAG(x) x##_tex_flat
+#include "gamma_tritmp.h"
+
+#define IND (GAMMA_RAST_ALPHA_BIT|GAMMA_RAST_TEX_BIT|GAMMA_RAST_FLAT_BIT)
+#define TAG(x) x##_alpha_tex_flat
+#include "gamma_tritmp.h"
+
+
+static void init_rast_tab( void )
+{
+ gamma_init();
+ gamma_init_alpha();
+ gamma_init_tex();
+ gamma_init_alpha_tex();
+ gamma_init_flat();
+ gamma_init_alpha_flat();
+ gamma_init_tex_flat();
+ gamma_init_alpha_tex_flat();
+}
+
+/***********************************************************************
+ * Rasterization fallback helpers *
+ ***********************************************************************/
+
+
+/* This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+static void
+gamma_fallback_quad( gammaContextPtr gmesa,
+ const gammaVertex *v0,
+ const gammaVertex *v1,
+ const gammaVertex *v2,
+ const gammaVertex *v3 )
+{
+ GLcontext *ctx = gmesa->glCtx;
+ SWvertex v[4];
+ gamma_translate_vertex( ctx, v0, &v[0] );
+ gamma_translate_vertex( ctx, v1, &v[1] );
+ gamma_translate_vertex( ctx, v2, &v[2] );
+ gamma_translate_vertex( ctx, v3, &v[3] );
+ _swrast_Quad( ctx, &v[0], &v[1], &v[2], &v[3] );
+}
+
+static void
+gamma_fallback_tri( gammaContextPtr gmesa,
+ const gammaVertex *v0,
+ const gammaVertex *v1,
+ const gammaVertex *v2 )
+{
+ GLcontext *ctx = gmesa->glCtx;
+ SWvertex v[3];
+ gamma_translate_vertex( ctx, v0, &v[0] );
+ gamma_translate_vertex( ctx, v1, &v[1] );
+ gamma_translate_vertex( ctx, v2, &v[2] );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+}
+
+static void
+gamma_fallback_line( gammaContextPtr gmesa,
+ const gammaVertex *v0,
+ const gammaVertex *v1 )
+{
+ GLcontext *ctx = gmesa->glCtx;
+ SWvertex v[2];
+ gamma_translate_vertex( ctx, v0, &v[0] );
+ gamma_translate_vertex( ctx, v1, &v[1] );
+ _swrast_Line( ctx, &v[0], &v[1] );
+}
+
+
+#if 0
+static void
+gamma_fallback_point( gammaContextPtr gmesa,
+ const gammaVertex *v0 )
+{
+ GLcontext *ctx = gmesa->glCtx;
+ SWvertex v[1];
+ gamma_translate_vertex( ctx, v0, &v[0] );
+ _swrast_Point( ctx, &v[0] );
+}
+#endif
+
+
+/***********************************************************************
+ * Choose rasterization functions *
+ ***********************************************************************/
+
+#define _GAMMA_NEW_RASTER_STATE (_NEW_FOG | \
+ _NEW_TEXTURE | \
+ _DD_NEW_TRI_SMOOTH | \
+ _DD_NEW_LINE_SMOOTH | \
+ _DD_NEW_POINT_SMOOTH | \
+ _DD_NEW_TRI_STIPPLE | \
+ _DD_NEW_LINE_STIPPLE)
+
+#define LINE_FALLBACK (0)
+#define TRI_FALLBACK (0)
+
+static void gammaChooseRasterState(GLcontext *ctx)
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint ind = 0;
+
+ if ( ctx->Line.SmoothFlag ||
+ ctx->Polygon.SmoothFlag ||
+ ctx->Point.SmoothFlag )
+ gmesa->Begin |= B_AntiAliasEnable;
+ else
+ gmesa->Begin &= ~B_AntiAliasEnable;
+
+ if ( ctx->Texture.Unit[0]._ReallyEnabled ) {
+ ind |= GAMMA_RAST_TEX_BIT;
+ gmesa->Begin |= B_TextureEnable;
+ } else
+ gmesa->Begin &= ~B_TextureEnable;
+
+ if (flags & DD_LINE_STIPPLE)
+ gmesa->Begin |= B_LineStippleEnable;
+ else
+ gmesa->Begin &= ~B_LineStippleEnable;
+
+ if (flags & DD_TRI_STIPPLE)
+ gmesa->Begin |= B_AreaStippleEnable;
+ else
+ gmesa->Begin &= ~B_AreaStippleEnable;
+
+ if (ctx->Fog.Enabled)
+ gmesa->Begin |= B_FogEnable;
+ else
+ gmesa->Begin &= ~B_FogEnable;
+
+ if (ctx->Color.BlendEnabled || ctx->Color.AlphaEnabled)
+ ind |= GAMMA_RAST_ALPHA_BIT;
+
+ if ( flags & DD_FLATSHADE )
+ ind |= GAMMA_RAST_FLAT_BIT;
+
+ gmesa->draw_line = gamma_line_tab[ind];
+ gmesa->draw_tri = gamma_tri_tab[ind];
+ gmesa->draw_quad = gamma_quad_tab[ind];
+ gmesa->draw_point = gamma_point_tab[ind];
+
+ /* Hook in fallbacks for specific primitives. CURRENTLY DISABLED
+ */
+ if (flags & LINE_FALLBACK)
+ gmesa->draw_line = gamma_fallback_line;
+
+ if (flags & TRI_FALLBACK) {
+ gmesa->draw_tri = gamma_fallback_tri;
+ gmesa->draw_quad = gamma_fallback_quad;
+ }
+}
+
+
+
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ gmesa->draw_tri( gmesa, a, b, c ); \
+} while (0)
+
+#define QUAD( a, b, c, d ) \
+do { \
+ gmesa->draw_quad( gmesa, a, b, c, d ); \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ gmesa->draw_line( gmesa, v0, v1 ); \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ gmesa->draw_point( gmesa, v0 ); \
+} while (0)
+
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define GAMMA_OFFSET_BIT 0x01
+#define GAMMA_TWOSIDE_BIT 0x02
+#define GAMMA_UNFILLED_BIT 0x04
+#define GAMMA_FALLBACK_BIT 0x08
+#define GAMMA_MAX_TRIFUNC 0x10
+
+
+static struct {
+ tnl_points_func points;
+ tnl_line_func line;
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
+} rast_tab[GAMMA_MAX_TRIFUNC];
+
+
+#define DO_FALLBACK (IND & GAMMA_FALLBACK_BIT)
+#define DO_OFFSET 0 /* (IND & GAMMA_OFFSET_BIT) */
+#define DO_UNFILLED 0 /* (IND & GAMMA_UNFILLED_BIT) */
+#define DO_TWOSIDE (IND & GAMMA_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 0
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX gammaVertex
+#define TAB rast_tab
+
+#define DEPTH_SCALE 1.0
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a > 0)
+#define GET_VERTEX(e) (gmesa->verts + (e * gmesa->vertex_size * sizeof(int)))
+
+#define VERT_SET_RGBA( v, c ) \
+do { \
+ UNCLAMPED_FLOAT_TO_UBYTE(v->ub4[4][0], (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(v->ub4[4][1], (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(v->ub4[4][2], (c)[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(v->ub4[4][3], (c)[3]); \
+} while (0)
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4]
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[4]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx]
+
+#define LOCAL_VARS(n) \
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \
+ GLuint color[n]; \
+ (void) color;
+
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ B_PrimType_Points,
+ B_PrimType_Lines,
+ B_PrimType_Lines,
+ B_PrimType_Lines,
+ B_PrimType_Triangles,
+ B_PrimType_Triangles,
+ B_PrimType_Triangles,
+ B_PrimType_Triangles,
+ B_PrimType_Triangles,
+ B_PrimType_Triangles
+};
+
+static void gammaResetLineStipple( GLcontext *ctx );
+static void gammaRasterPrimitive( GLcontext *ctx, GLuint hwprim );
+static void gammaRenderPrimitive( GLcontext *ctx, GLenum prim );
+
+#define RASTERIZE(x) if (gmesa->hw_primitive != hw_prim[x]) \
+ gammaRasterPrimitive( ctx, hw_prim[x] )
+#define RENDER_PRIMITIVE gmesa->render_primitive
+#define TAG(x) x
+#define IND GAMMA_FALLBACK_BIT
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (GAMMA_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (GAMMA_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (GAMMA_TWOSIDE_BIT|GAMMA_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (GAMMA_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (GAMMA_OFFSET_BIT|GAMMA_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (GAMMA_TWOSIDE_BIT|GAMMA_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (GAMMA_TWOSIDE_BIT|GAMMA_OFFSET_BIT|GAMMA_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+
+static void init_render_tab( void )
+{
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+}
+
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+#define VERT(x) (gammaVertex *)(gammaverts + (x * size * sizeof(int)))
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ gmesa->draw_point( gmesa, VERT(start) )
+#define RENDER_LINE( v0, v1 ) \
+ gmesa->draw_line( gmesa, VERT(v0), VERT(v1) )
+#define RENDER_TRI( v0, v1, v2 ) \
+ gmesa->draw_tri( gmesa, VERT(v0), VERT(v1), VERT(v2) )
+#define RENDER_QUAD( v0, v1, v2, v3 ) \
+ gmesa->draw_quad( gmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
+#define INIT(x) gammaRenderPrimitive( ctx, x );
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx); \
+ const GLuint size = gmesa->vertex_size; \
+ const char *gammaverts = (char *)gmesa->verts; \
+ const GLboolean stipple = ctx->Line.StippleFlag; \
+ (void) stipple;
+#define RESET_STIPPLE if ( stipple ) gammaResetLineStipple( ctx );
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) (x)
+#define TAG(x) gamma_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+static void gammaRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint prim = gmesa->render_primitive;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+ }
+
+ /* Restore the render primitive
+ */
+ if (prim != GL_POLYGON)
+ tnl->Driver.Render.PrimitiveNotify( ctx, prim );
+}
+
+static void gammaRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Line( ctx, ii, jj );
+}
+
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+
+
+#define _GAMMA_NEW_RENDERSTATE (_DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET)
+
+#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
+
+static void gammaChooseRenderState(GLcontext *ctx)
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= GAMMA_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= GAMMA_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= GAMMA_UNFILLED_BIT;
+ }
+
+ if (gmesa->RenderIndex != index) {
+ gmesa->RenderIndex = index;
+
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (gmesa->RenderIndex == 0)
+ tnl->Driver.Render.PrimTabVerts = gamma_render_tab_verts;
+ else
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = gammaRenderClippedLine;
+ tnl->Driver.Render.ClippedPolygon = gammaRenderClippedPoly;
+ }
+}
+
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+
+
+/* Determine the rasterized primitive when not drawing unfilled
+ * polygons.
+ *
+ * Used only for the default render stage which always decomposes
+ * primitives to trianges/lines/points. For the accelerated stage,
+ * which renders strips as strips, the equivalent calculations are
+ * performed in gammarender.c.
+ */
+
+static void gammaRasterPrimitive( GLcontext *ctx, GLuint hwprim )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ if (gmesa->hw_primitive != hwprim)
+ gmesa->hw_primitive = hwprim;
+}
+
+static void gammaRenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ gmesa->render_primitive = prim;
+}
+
+static void gammaRunPipeline( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ if ( gmesa->new_state )
+ gammaDDUpdateHWState( ctx );
+
+ if (gmesa->new_gl_state) {
+ if (gmesa->new_gl_state & _NEW_TEXTURE)
+ gammaUpdateTextureState( ctx );
+
+ if (!gmesa->Fallback) {
+ if (gmesa->new_gl_state & _GAMMA_NEW_VERTEX)
+ gammaChooseVertexState( ctx );
+
+ if (gmesa->new_gl_state & _GAMMA_NEW_RASTER_STATE)
+ gammaChooseRasterState( ctx );
+
+ if (gmesa->new_gl_state & _GAMMA_NEW_RENDERSTATE)
+ gammaChooseRenderState( ctx );
+ }
+
+ gmesa->new_gl_state = 0;
+ }
+
+ _tnl_run_pipeline( ctx );
+}
+
+static void gammaRenderStart( GLcontext *ctx )
+{
+ /* Check for projective texturing. Make sure all texcoord
+ * pointers point to something. (fix in mesa?)
+ */
+ gammaCheckTexSizes( ctx );
+}
+
+static void gammaRenderFinish( GLcontext *ctx )
+{
+ if (0)
+ _swrast_flush( ctx ); /* never needed */
+}
+
+static void gammaResetLineStipple( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+
+ /* Reset the hardware stipple counter.
+ */
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, UpdateLineStippleCounters, 0);
+}
+
+
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+
+
+void gammaFallback( gammaContextPtr gmesa, GLuint bit, GLboolean mode )
+{
+ GLcontext *ctx = gmesa->glCtx;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldfallback = gmesa->Fallback;
+
+ if (mode) {
+ gmesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ _swsetup_Wakeup( ctx );
+ _tnl_need_projected_coords( ctx, GL_TRUE );
+ gmesa->RenderIndex = ~0;
+ }
+ }
+ else {
+ gmesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = gammaRenderStart;
+ tnl->Driver.Render.PrimitiveNotify = gammaRenderPrimitive;
+ tnl->Driver.Render.Finish = gammaRenderFinish;
+ tnl->Driver.Render.BuildVertices = gammaBuildVertices;
+ tnl->Driver.Render.ResetLineStipple = gammaResetLineStipple;
+ gmesa->new_gl_state |= (_GAMMA_NEW_RENDERSTATE|
+ _GAMMA_NEW_RASTER_STATE|
+ _GAMMA_NEW_VERTEX);
+ }
+ }
+}
+
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+
+void gammaDDInitTriFuncs( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ init_render_tab();
+ firsttime = 0;
+ }
+
+ gmesa->RenderIndex = ~0;
+
+ tnl->Driver.RunPipeline = gammaRunPipeline;
+ tnl->Driver.Render.Start = gammaRenderStart;
+ tnl->Driver.Render.Finish = gammaRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = gammaRenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = gammaResetLineStipple;
+ tnl->Driver.Render.BuildVertices = gammaBuildVertices;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_tris.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_tris.h
new file mode 100644
index 000000000..02bec2869
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_tris.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * 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@tungstengraphics.com>
+ * Keith Whitwell, <keith@tungstengraphics.com>
+ *
+ * 3DLabs Gamma driver.
+ */
+
+#ifndef _GAMMA_TRIS_H
+#define _GAMMA_TRIS_H
+
+extern void gammaDDTrifuncInit(void);
+extern void gammaDDChooseTriRenderState(GLcontext *);
+
+
+
+#endif /* !(_GAMMA_TRIS_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_tritmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_tritmp.h
new file mode 100644
index 000000000..23459ff15
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_tritmp.h
@@ -0,0 +1,497 @@
+/* $XFree86: xc/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_tritmp.h,v 1.2 2004/12/13 22:40:49 tsi Exp $ */
+
+static void TAG(gamma_point)( gammaContextPtr gmesa,
+ const gammaVertex *v0 )
+{
+ u_int32_t vColor;
+ u_int32_t vBegin;
+
+ vBegin = gmesa->Begin | B_PrimType_Points;
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Begin, vBegin);
+
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v0->v.color.alpha << 24) |
+ (v0->v.color.blue << 16) |
+ (v0->v.color.green << 8) |
+ (v0->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v0->v.color.blue << 16) |
+ (v0->v.color.green << 8) |
+ (v0->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v0->v.u0);
+ WRITEF(gmesa->buf, Ts2, v0->v.v0);
+ WRITEF(gmesa->buf, Vw, v0->v.w);
+ WRITEF(gmesa->buf, Vz, v0->v.z);
+ WRITEF(gmesa->buf, Vy, v0->v.y);
+ WRITEF(gmesa->buf, Vx4, v0->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v0->v.w);
+ WRITEF(gmesa->buf, Vz, v0->v.z);
+ WRITEF(gmesa->buf, Vy, v0->v.y);
+ WRITEF(gmesa->buf, Vx4, v0->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, FlushSpan, 0);
+#endif
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, End, 0);
+}
+
+static void TAG(gamma_line)( gammaContextPtr gmesa,
+ const gammaVertex *v0,
+ const gammaVertex *v1 )
+{
+ u_int32_t vColor;
+ u_int32_t vBegin;
+
+ vBegin = gmesa->Begin | B_PrimType_Lines;
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Begin, vBegin);
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v0->v.color.alpha << 24) |
+ (v0->v.color.blue << 16) |
+ (v0->v.color.green << 8) |
+ (v0->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v0->v.color.blue << 16) |
+ (v0->v.color.green << 8) |
+ (v0->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#else
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v1->v.color.alpha << 24) |
+ (v1->v.color.blue << 16) |
+ (v1->v.color.green << 8) |
+ (v1->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v1->v.color.blue << 16) |
+ (v1->v.color.green << 8) |
+ (v1->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v0->v.u0);
+ WRITEF(gmesa->buf, Ts2, v0->v.v0);
+ WRITEF(gmesa->buf, Vw, v0->v.w);
+ WRITEF(gmesa->buf, Vz, v0->v.z);
+ WRITEF(gmesa->buf, Vy, v0->v.y);
+ WRITEF(gmesa->buf, Vx4, v0->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v0->v.w);
+ WRITEF(gmesa->buf, Vz, v0->v.z);
+ WRITEF(gmesa->buf, Vy, v0->v.y);
+ WRITEF(gmesa->buf, Vx4, v0->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v1->v.color.alpha << 24) |
+ (v1->v.color.blue << 16) |
+ (v1->v.color.green << 8) |
+ (v1->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v1->v.color.blue << 16) |
+ (v1->v.color.green << 8) |
+ (v1->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v1->v.u0);
+ WRITEF(gmesa->buf, Ts2, v1->v.v0);
+ WRITEF(gmesa->buf, Vw, v1->v.w);
+ WRITEF(gmesa->buf, Vz, v1->v.z);
+ WRITEF(gmesa->buf, Vy, v1->v.y);
+ WRITEF(gmesa->buf, Vx4, v1->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v1->v.w);
+ WRITEF(gmesa->buf, Vz, v1->v.z);
+ WRITEF(gmesa->buf, Vy, v1->v.y);
+ WRITEF(gmesa->buf, Vx4, v1->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, FlushSpan, 0);
+#endif
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, End, 0);
+}
+
+static void TAG(gamma_triangle)( gammaContextPtr gmesa,
+ const gammaVertex *v0,
+ const gammaVertex *v1,
+ const gammaVertex *v2 )
+{
+ u_int32_t vColor;
+ u_int32_t vBegin;
+
+ vBegin = gmesa->Begin | B_PrimType_Triangles;
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Begin, vBegin);
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v0->v.color.alpha << 24) |
+ (v0->v.color.blue << 16) |
+ (v0->v.color.green << 8) |
+ (v0->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v0->v.color.blue << 16) |
+ (v0->v.color.green << 8) |
+ (v0->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#else
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v2->v.color.alpha << 24) |
+ (v2->v.color.blue << 16) |
+ (v2->v.color.green << 8) |
+ (v2->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v2->v.color.blue << 16) |
+ (v2->v.color.green << 8) |
+ (v2->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v0->v.u0);
+ WRITEF(gmesa->buf, Ts2, v0->v.v0);
+ WRITEF(gmesa->buf, Vw, v0->v.w);
+ WRITEF(gmesa->buf, Vz, v0->v.z);
+ WRITEF(gmesa->buf, Vy, v0->v.y);
+ WRITEF(gmesa->buf, Vx4, v0->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v0->v.w);
+ WRITEF(gmesa->buf, Vz, v0->v.z);
+ WRITEF(gmesa->buf, Vy, v0->v.y);
+ WRITEF(gmesa->buf, Vx4, v0->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v1->v.color.alpha << 24) |
+ (v1->v.color.blue << 16) |
+ (v1->v.color.green << 8) |
+ (v1->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v1->v.color.blue << 16) |
+ (v1->v.color.green << 8) |
+ (v1->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v1->v.u0);
+ WRITEF(gmesa->buf, Ts2, v1->v.v0);
+ WRITEF(gmesa->buf, Vw, v1->v.w);
+ WRITEF(gmesa->buf, Vz, v1->v.z);
+ WRITEF(gmesa->buf, Vy, v1->v.y);
+ WRITEF(gmesa->buf, Vx4, v1->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v1->v.w);
+ WRITEF(gmesa->buf, Vz, v1->v.z);
+ WRITEF(gmesa->buf, Vy, v1->v.y);
+ WRITEF(gmesa->buf, Vx4, v1->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v2->v.color.alpha << 24) |
+ (v2->v.color.blue << 16) |
+ (v2->v.color.green << 8) |
+ (v2->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v2->v.color.blue << 16) |
+ (v2->v.color.green << 8) |
+ (v2->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v2->v.u0);
+ WRITEF(gmesa->buf, Ts2, v2->v.v0);
+ WRITEF(gmesa->buf, Vw, v2->v.w);
+ WRITEF(gmesa->buf, Vz, v2->v.z);
+ WRITEF(gmesa->buf, Vy, v2->v.y);
+ WRITEF(gmesa->buf, Vx4, v2->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v2->v.w);
+ WRITEF(gmesa->buf, Vz, v2->v.z);
+ WRITEF(gmesa->buf, Vy, v2->v.y);
+ WRITEF(gmesa->buf, Vx4, v2->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, FlushSpan, 0);
+#endif
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, End, 0);
+}
+
+static void TAG(gamma_quad)( gammaContextPtr gmesa,
+ const gammaVertex *v0,
+ const gammaVertex *v1,
+ const gammaVertex *v2,
+ const gammaVertex *v3 )
+{
+ u_int32_t vColor;
+ u_int32_t vBegin;
+
+ vBegin = gmesa->Begin | B_PrimType_Quads;
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, Begin, vBegin);
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v0->v.color.alpha << 24) |
+ (v0->v.color.blue << 16) |
+ (v0->v.color.green << 8) |
+ (v0->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v0->v.color.blue << 16) |
+ (v0->v.color.green << 8) |
+ (v0->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#else
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v3->v.color.alpha << 24) |
+ (v3->v.color.blue << 16) |
+ (v3->v.color.green << 8) |
+ (v3->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v3->v.color.blue << 16) |
+ (v3->v.color.green << 8) |
+ (v3->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v0->v.u0);
+ WRITEF(gmesa->buf, Ts2, v0->v.v0);
+ WRITEF(gmesa->buf, Vw, v0->v.w);
+ WRITEF(gmesa->buf, Vz, v0->v.z);
+ WRITEF(gmesa->buf, Vy, v0->v.y);
+ WRITEF(gmesa->buf, Vx4, v0->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v0->v.w);
+ WRITEF(gmesa->buf, Vz, v0->v.z);
+ WRITEF(gmesa->buf, Vy, v0->v.y);
+ WRITEF(gmesa->buf, Vx4, v0->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v1->v.color.alpha << 24) |
+ (v1->v.color.blue << 16) |
+ (v1->v.color.green << 8) |
+ (v1->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v1->v.color.blue << 16) |
+ (v1->v.color.green << 8) |
+ (v1->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v1->v.u0);
+ WRITEF(gmesa->buf, Ts2, v1->v.v0);
+ WRITEF(gmesa->buf, Vw, v1->v.w);
+ WRITEF(gmesa->buf, Vz, v1->v.z);
+ WRITEF(gmesa->buf, Vy, v1->v.y);
+ WRITEF(gmesa->buf, Vx4, v1->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v1->v.w);
+ WRITEF(gmesa->buf, Vz, v1->v.z);
+ WRITEF(gmesa->buf, Vy, v1->v.y);
+ WRITEF(gmesa->buf, Vx4, v1->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v2->v.color.alpha << 24) |
+ (v2->v.color.blue << 16) |
+ (v2->v.color.green << 8) |
+ (v2->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v2->v.color.blue << 16) |
+ (v2->v.color.green << 8) |
+ (v2->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v2->v.u0);
+ WRITEF(gmesa->buf, Ts2, v2->v.v0);
+ WRITEF(gmesa->buf, Vw, v2->v.w);
+ WRITEF(gmesa->buf, Vz, v2->v.z);
+ WRITEF(gmesa->buf, Vy, v2->v.y);
+ WRITEF(gmesa->buf, Vx4, v2->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v2->v.w);
+ WRITEF(gmesa->buf, Vz, v2->v.z);
+ WRITEF(gmesa->buf, Vy, v2->v.y);
+ WRITEF(gmesa->buf, Vx4, v2->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+#if (IND & GAMMA_RAST_ALPHA_BIT)
+ vColor = (v3->v.color.alpha << 24) |
+ (v3->v.color.blue << 16) |
+ (v3->v.color.green << 8) |
+ (v3->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor4, vColor);
+#else
+ vColor = (v3->v.color.blue << 16) |
+ (v3->v.color.green << 8) |
+ (v3->v.color.red << 0);
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, PackedColor3, vColor);
+#endif
+#endif
+
+#if (IND & GAMMA_RAST_TEX_BIT)
+ CHECK_DMA_BUFFER(gmesa, 6);
+ WRITEF(gmesa->buf, Tt2, v3->v.u0);
+ WRITEF(gmesa->buf, Ts2, v3->v.v0);
+ WRITEF(gmesa->buf, Vw, v3->v.w);
+ WRITEF(gmesa->buf, Vz, v3->v.z);
+ WRITEF(gmesa->buf, Vy, v3->v.y);
+ WRITEF(gmesa->buf, Vx4, v3->v.x);
+#else
+ CHECK_DMA_BUFFER(gmesa, 4);
+ WRITEF(gmesa->buf, Vw, v3->v.w);
+ WRITEF(gmesa->buf, Vz, v3->v.z);
+ WRITEF(gmesa->buf, Vy, v3->v.y);
+ WRITEF(gmesa->buf, Vx4, v3->v.x);
+#endif
+
+#if !(IND & GAMMA_RAST_FLAT_BIT)
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, FlushSpan, 0);
+#endif
+
+ CHECK_DMA_BUFFER(gmesa, 1);
+ WRITE(gmesa->buf, End, 0);
+}
+
+static void TAG(gamma_init)(void)
+{
+ gamma_point_tab[IND] = TAG(gamma_point);
+ gamma_line_tab[IND] = TAG(gamma_line);
+ gamma_tri_tab[IND] = TAG(gamma_triangle);
+ gamma_quad_tab[IND] = TAG(gamma_quad);
+}
+
+#undef IND
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_vb.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_vb.c
new file mode 100644
index 000000000..80d35cba9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_vb.c
@@ -0,0 +1,362 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_vb.c,v 1.4 2003/03/26 20:43:48 tsi Exp $ */
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * 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@tungstengraphics.com>
+ * Keith Whitwell, <keith@tungstengraphics.com>
+ *
+ * 3DLabs Gamma driver.
+ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "imports.h"
+#include "macros.h"
+#include "colormac.h"
+
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/t_context.h"
+#include "tnl/tnl.h"
+
+#include "gamma_context.h"
+#include "gamma_vb.h"
+#include "gamma_tris.h"
+
+
+#define GAMMA_TEX0_BIT 0x1
+#define GAMMA_RGBA_BIT 0x2
+#define GAMMA_XYZW_BIT 0x4
+#define GAMMA_PTEX_BIT 0x8
+#define GAMMA_FOG_BIT 0x10
+#define GAMMA_SPEC_BIT 0x20
+#define GAMMA_MAX_SETUP 0x40
+
+static struct {
+ void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
+ tnl_interp_func interp;
+ tnl_copy_pv_func copy_pv;
+ GLboolean (*check_tex_sizes)( GLcontext *ctx );
+ GLuint vertex_size;
+ GLuint vertex_format;
+} setup_tab[GAMMA_MAX_SETUP];
+
+#define TINY_VERTEX_FORMAT 1
+#define NOTEX_VERTEX_FORMAT 2
+#define TEX0_VERTEX_FORMAT 3
+#define TEX1_VERTEX_FORMAT 0
+#define PROJ_TEX1_VERTEX_FORMAT 0
+#define TEX2_VERTEX_FORMAT 0
+#define TEX3_VERTEX_FORMAT 0
+#define PROJ_TEX3_VERTEX_FORMAT 0
+
+#define DO_XYZW (IND & GAMMA_XYZW_BIT)
+#define DO_RGBA (IND & GAMMA_RGBA_BIT)
+#define DO_SPEC (IND & GAMMA_SPEC_BIT)
+#define DO_FOG (IND & GAMMA_FOG_BIT)
+#define DO_TEX0 (IND & GAMMA_TEX0_BIT)
+#define DO_TEX1 0
+#define DO_TEX2 0
+#define DO_TEX3 0
+#define DO_PTEX (IND & GAMMA_PTEX_BIT)
+
+#define VERTEX gammaVertex
+#define VERTEX_COLOR gamma_color_t
+#define GET_VIEWPORT_MAT() 0
+#define GET_TEXSOURCE(n) n
+#define GET_VERTEX_FORMAT() GAMMA_CONTEXT(ctx)->vertex_format
+#define GET_VERTEX_STORE() GAMMA_CONTEXT(ctx)->verts
+#define GET_VERTEX_SIZE() GAMMA_CONTEXT(ctx)->vertex_size * sizeof(GLuint)
+#define INVALIDATE_STORED_VERTICES()
+
+#define HAVE_HW_VIEWPORT 1
+#define HAVE_HW_DIVIDE 1
+#define HAVE_RGBA_COLOR 0 /* we're BGRA */
+#define HAVE_TINY_VERTICES 1
+#define HAVE_NOTEX_VERTICES 1
+#define HAVE_TEX0_VERTICES 1
+#define HAVE_TEX1_VERTICES 0
+#define HAVE_TEX2_VERTICES 0
+#define HAVE_TEX3_VERTICES 0
+#define HAVE_PTEX_VERTICES 1
+
+#define PTEX_FALLBACK() /* never needed */
+
+#define INTERP_VERTEX setup_tab[GAMMA_CONTEXT(ctx)->SetupIndex].interp
+#define COPY_PV_VERTEX setup_tab[GAMMA_CONTEXT(ctx)->SetupIndex].copy_pv
+
+
+
+/***********************************************************************
+ * Generate pv-copying and translation functions *
+ ***********************************************************************/
+
+#define TAG(x) gamma_##x
+#include "tnl_dd/t_dd_vb.c"
+
+/***********************************************************************
+ * Generate vertex emit and interp functions *
+ ***********************************************************************/
+
+#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT)
+#define TAG(x) x##_wg
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_SPEC_BIT)
+#define TAG(x) x##_wgs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_TEX0_BIT)
+#define TAG(x) x##_wgt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_TEX0_BIT|GAMMA_PTEX_BIT)
+#define TAG(x) x##_wgpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_SPEC_BIT|GAMMA_TEX0_BIT)
+#define TAG(x) x##_wgst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_SPEC_BIT|GAMMA_TEX0_BIT|\
+ GAMMA_PTEX_BIT)
+#define TAG(x) x##_wgspt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT)
+#define TAG(x) x##_wgf
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT)
+#define TAG(x) x##_wgfs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_TEX0_BIT)
+#define TAG(x) x##_wgft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_TEX0_BIT|\
+ GAMMA_PTEX_BIT)
+#define TAG(x) x##_wgfpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT|\
+ GAMMA_TEX0_BIT)
+#define TAG(x) x##_wgfst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_XYZW_BIT|GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT|\
+ GAMMA_TEX0_BIT|GAMMA_PTEX_BIT)
+#define TAG(x) x##_wgfspt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_TEX0_BIT)
+#define TAG(x) x##_t0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_FOG_BIT)
+#define TAG(x) x##_f
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_FOG_BIT|GAMMA_TEX0_BIT)
+#define TAG(x) x##_ft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_RGBA_BIT)
+#define TAG(x) x##_g
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_RGBA_BIT|GAMMA_SPEC_BIT)
+#define TAG(x) x##_gs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_RGBA_BIT|GAMMA_TEX0_BIT)
+#define TAG(x) x##_gt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_RGBA_BIT|GAMMA_SPEC_BIT|GAMMA_TEX0_BIT)
+#define TAG(x) x##_gst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_RGBA_BIT|GAMMA_FOG_BIT)
+#define TAG(x) x##_gf
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT)
+#define TAG(x) x##_gfs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_TEX0_BIT)
+#define TAG(x) x##_gft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (GAMMA_RGBA_BIT|GAMMA_FOG_BIT|GAMMA_SPEC_BIT|GAMMA_TEX0_BIT)
+#define TAG(x) x##_gfst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+static void init_setup_tab( void )
+{
+ init_wg();
+ init_wgs();
+ init_wgt0();
+ init_wgpt0();
+ init_wgst0();
+ init_wgspt0();
+ init_wgf();
+ init_wgfs();
+ init_wgft0();
+ init_wgfpt0();
+ init_wgfst0();
+ init_wgfspt0();
+ init_t0();
+ init_f();
+ init_ft0();
+ init_g();
+ init_gs();
+ init_gt0();
+ init_gst0();
+ init_gf();
+ init_gfs();
+ init_gft0();
+ init_gfst0();
+}
+
+void gammaCheckTexSizes( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
+
+ if (!setup_tab[gmesa->SetupIndex].check_tex_sizes(ctx)) {
+ /* Invalidate stored verts
+ */
+ gmesa->SetupNewInputs = ~0;
+ gmesa->SetupIndex |= GAMMA_PTEX_BIT;
+
+ if (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ tnl->Driver.Render.Interp = setup_tab[gmesa->SetupIndex].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[gmesa->SetupIndex].copy_pv;
+ }
+ }
+}
+
+void gammaBuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
+ GLuint stride = gmesa->vertex_size * sizeof(int);
+ GLubyte *v = ((GLubyte *)gmesa->verts + (start * stride));
+
+ newinputs |= gmesa->SetupNewInputs;
+ gmesa->SetupNewInputs = 0;
+
+ if (!newinputs)
+ return;
+
+ if (newinputs & VERT_BIT_POS) {
+ setup_tab[gmesa->SetupIndex].emit( ctx, start, count, v, stride );
+ } else {
+ GLuint ind = 0;
+
+ if (newinputs & VERT_BIT_COLOR0)
+ ind |= GAMMA_RGBA_BIT;
+
+ if (newinputs & VERT_BIT_COLOR1)
+ ind |= GAMMA_SPEC_BIT;
+
+ if (newinputs & VERT_BIT_TEX0)
+ ind |= GAMMA_TEX0_BIT;
+
+ if (newinputs & VERT_BIT_FOG)
+ ind |= GAMMA_FOG_BIT;
+
+ if (gmesa->SetupIndex & GAMMA_PTEX_BIT)
+ ind = ~0;
+
+ ind &= gmesa->SetupIndex;
+
+ if (ind) {
+ setup_tab[ind].emit( ctx, start, count, v, stride );
+ }
+ }
+}
+
+void gammaChooseVertexState( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint ind = GAMMA_XYZW_BIT|GAMMA_RGBA_BIT;
+
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ ind |= GAMMA_SPEC_BIT;
+
+ if (ctx->Fog.Enabled)
+ ind |= GAMMA_FOG_BIT;
+
+ if (ctx->Texture.Unit[0]._ReallyEnabled) {
+ _tnl_need_projected_coords( ctx, GL_FALSE );
+ ind |= GAMMA_TEX0_BIT;
+ } else
+ _tnl_need_projected_coords( ctx, GL_FALSE );
+
+ gmesa->SetupIndex = ind;
+
+ if (setup_tab[ind].vertex_format != gmesa->vertex_format) {
+ gmesa->vertex_format = setup_tab[ind].vertex_format;
+ gmesa->vertex_size = setup_tab[ind].vertex_size;
+ }
+
+ if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
+ tnl->Driver.Render.Interp = gamma_interp_extras;
+ tnl->Driver.Render.CopyPV = gamma_copy_pv_extras;
+ } else {
+ tnl->Driver.Render.Interp = setup_tab[ind].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
+ }
+}
+
+
+void gammaInitVB( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ GLuint size = TNL_CONTEXT(ctx)->vb.Size;
+
+ gmesa->verts = (GLubyte *)ALIGN_MALLOC(size * 4 * 16, 32);
+
+ {
+ static int firsttime = 1;
+ if (firsttime) {
+ init_setup_tab();
+ firsttime = 0;
+ gmesa->vertex_size = 16; /* FIXME - only one vertex setup */
+ }
+ }
+}
+
+
+void gammaFreeVB( GLcontext *ctx )
+{
+ gammaContextPtr gmesa = GAMMA_CONTEXT(ctx);
+ if (gmesa->verts) {
+ ALIGN_FREE(gmesa->verts);
+ gmesa->verts = 0;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_vb.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_vb.h
new file mode 100644
index 000000000..feda25c4c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_vb.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * 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@tungstengraphics.com>
+ * Keith Whitwell, <keith@tungstengraphics.com>
+ *
+ * 3DLabs Gamma driver.
+ */
+
+#ifndef GAMMAVB_INC
+#define GAMMAVB_INC
+
+#include "mtypes.h"
+#include "swrast/swrast.h"
+
+#define _GAMMA_NEW_VERTEX (_NEW_TEXTURE | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE)
+
+
+extern void gammaChooseVertexState( GLcontext *ctx );
+extern void gammaCheckTexSizes( GLcontext *ctx );
+extern void gammaBuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs );
+
+
+extern void gamma_import_float_colors( GLcontext *ctx );
+extern void gamma_import_float_spec_colors( GLcontext *ctx );
+
+extern void gamma_translate_vertex( GLcontext *ctx,
+ const gammaVertex *src,
+ SWvertex *dst );
+
+extern void gammaInitVB( GLcontext *ctx );
+extern void gammaFreeVB( GLcontext *ctx );
+
+extern void gamma_print_vertex( GLcontext *ctx, const gammaVertex *v );
+extern void gammaPrintSetupFlags(char *msg, GLuint flags );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_xmesa.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_xmesa.c
new file mode 100644
index 000000000..00f6aa32a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/gamma_xmesa.c
@@ -0,0 +1,266 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c,v 1.14 2002/10/30 12:51:30 alanh Exp $ */
+/*
+ * Copyright 2001 by Alan Hourihane.
+ *
+ * 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@tungstengraphics.com>
+ *
+ * 3DLabs Gamma driver
+ */
+
+#include "gamma_context.h"
+#include "gamma_vb.h"
+#include "context.h"
+#include "matrix.h"
+#include "glint_dri.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "array_cache/acache.h"
+
+static GLboolean
+gammaInitDriver(__DRIscreenPrivate *sPriv)
+{
+ sPriv->private = (void *) gammaCreateScreen( sPriv );
+
+ if (!sPriv->private) {
+ gammaDestroyScreen( sPriv );
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+static void
+gammaDestroyContext(__DRIcontextPrivate *driContextPriv)
+{
+ gammaContextPtr gmesa = (gammaContextPtr)driContextPriv->driverPrivate;
+
+ if (gmesa) {
+ _swsetup_DestroyContext( gmesa->glCtx );
+ _tnl_DestroyContext( gmesa->glCtx );
+ _ac_DestroyContext( gmesa->glCtx );
+ _swrast_DestroyContext( gmesa->glCtx );
+
+ gammaFreeVB( gmesa->glCtx );
+
+ /* free the Mesa context */
+ gmesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(gmesa->glCtx);
+
+ FREE(gmesa);
+ driContextPriv->driverPrivate = NULL;
+ }
+}
+
+
+static GLboolean
+gammaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ mesaVis->alphaBits > 0
+ );
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+
+static void
+gammaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+static void
+gammaSwapBuffers( __DRIdrawablePrivate *dPriv )
+{
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ gammaContextPtr gmesa;
+ __DRIscreenPrivate *driScrnPriv;
+ GLcontext *ctx;
+
+ gmesa = (gammaContextPtr) dPriv->driContextPriv->driverPrivate;
+ ctx = gmesa->glCtx;
+ driScrnPriv = gmesa->driScreen;
+
+ _mesa_notifySwapBuffers(ctx);
+
+ VALIDATE_DRAWABLE_INFO(gmesa);
+
+ /* Flush any partially filled buffers */
+ FLUSH_DMA_BUFFER(gmesa);
+
+ DRM_SPINLOCK(&driScrnPriv->pSAREA->drawable_lock,
+ driScrnPriv->drawLockID);
+ VALIDATE_DRAWABLE_INFO_NO_LOCK(gmesa);
+
+ if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER) {
+ int src, dst, x0, y0, x1, h;
+ int i;
+ int nRect = dPriv->numClipRects;
+ drm_clip_rect_t *pRect = dPriv->pClipRects;
+ __DRIscreenPrivate *driScrnPriv = gmesa->driScreen;
+ GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)driScrnPriv->pDevPriv;
+
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, FBReadMode, (gmesa->FBReadMode |
+ FBReadSrcEnable));
+ WRITE(gmesa->buf, LBWriteMode, LBWriteModeDisable);
+
+ for (i = 0; i < nRect; i++, pRect++) {
+ x0 = pRect->x1;
+ x1 = pRect->x2;
+ h = pRect->y2 - pRect->y1;
+
+ y0 = driScrnPriv->fbHeight - (pRect->y1+h);
+ if (gDRIPriv->numMultiDevices == 2)
+ src = (y0/2)*driScrnPriv->fbWidth+x0;
+ else
+ src = y0*driScrnPriv->fbWidth+x0;
+
+ y0 += driScrnPriv->fbHeight;
+ if (gDRIPriv->numMultiDevices == 2)
+ dst = (y0/2)*driScrnPriv->fbWidth+x0;
+ else
+ dst = y0*driScrnPriv->fbWidth+x0;
+
+ CHECK_DMA_BUFFER(gmesa, 9);
+ WRITE(gmesa->buf, StartXDom, x0<<16); /* X0dest */
+ WRITE(gmesa->buf, StartY, y0<<16); /* Y0dest */
+ WRITE(gmesa->buf, StartXSub, x1<<16); /* X1dest */
+ WRITE(gmesa->buf, GLINTCount, h); /* H */
+ WRITE(gmesa->buf, dY, 1<<16); /* ydir */
+ WRITE(gmesa->buf, dXDom, 0<<16);
+ WRITE(gmesa->buf, dXSub, 0<<16);
+ WRITE(gmesa->buf, FBSourceOffset, (dst-src));
+ WRITE(gmesa->buf, Render, 0x00040048); /* NOT_DONE */
+ }
+
+ /*
+ ** NOTE: FBSourceOffset (above) is backwards from what is
+ ** described in the manual (i.e., dst-src instead of src-dst)
+ ** due to our using the bottom-left window origin instead of the
+ ** top-left window origin.
+ */
+
+ /* Restore FBReadMode */
+ CHECK_DMA_BUFFER(gmesa, 2);
+ WRITE(gmesa->buf, FBReadMode, (gmesa->FBReadMode |
+ gmesa->AB_FBReadMode));
+ WRITE(gmesa->buf, LBWriteMode, LBWriteModeEnable);
+ }
+
+ if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER)
+ PROCESS_DMA_BUFFER_TOP_HALF(gmesa);
+
+ DRM_SPINUNLOCK(&driScrnPriv->pSAREA->drawable_lock,
+ driScrnPriv->drawLockID);
+ VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(gmesa);
+
+ if (gmesa->EnabledFlags & GAMMA_BACK_BUFFER)
+ PROCESS_DMA_BUFFER_BOTTOM_HALF(gmesa);
+ } else {
+ _mesa_problem(NULL, "gammaSwapBuffers: drawable has no context!\n");
+ }
+}
+
+static GLboolean
+gammaMakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
+{
+ if (driContextPriv) {
+ GET_CURRENT_CONTEXT(ctx);
+ gammaContextPtr oldGammaCtx = ctx ? GAMMA_CONTEXT(ctx) : NULL;
+ gammaContextPtr newGammaCtx = (gammaContextPtr) driContextPriv->driverPrivate;
+
+ if ( newGammaCtx != oldGammaCtx ) {
+ newGammaCtx->dirty = ~0;
+ }
+
+ if (newGammaCtx->driDrawable != driDrawPriv) {
+ newGammaCtx->driDrawable = driDrawPriv;
+ gammaUpdateWindow ( newGammaCtx->glCtx );
+ gammaUpdateViewportOffset( newGammaCtx->glCtx );
+ }
+
+#if 0
+ newGammaCtx->Window &= ~W_GIDMask;
+ newGammaCtx->Window |= (driDrawPriv->index << 5);
+ CHECK_DMA_BUFFER(newGammaCtx,1);
+ WRITE(newGammaCtx->buf, GLINTWindow, newGammaCtx->Window);
+#endif
+
+newGammaCtx->new_state |= GAMMA_NEW_WINDOW; /* FIXME */
+
+ _mesa_make_current2( newGammaCtx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
+ } else {
+ _mesa_make_current( 0, 0 );
+ }
+ return GL_TRUE;
+}
+
+
+static GLboolean
+gammaUnbindContext( __DRIcontextPrivate *driContextPriv )
+{
+ return GL_TRUE;
+}
+
+static struct __DriverAPIRec gammaAPI = {
+ gammaInitDriver,
+ gammaDestroyScreen,
+ gammaCreateContext,
+ gammaDestroyContext,
+ gammaCreateBuffer,
+ gammaDestroyBuffer,
+ gammaSwapBuffers,
+ gammaMakeCurrent,
+ gammaUnbindContext
+};
+
+
+
+/*
+ * This is the bootstrap function for the driver.
+ * The __driCreateScreen name is the symbol that libGL.so fetches.
+ * Return: pointer to a __DRIscreenPrivate.
+ */
+void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config)
+{
+ __DRIscreenPrivate *psp;
+ psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &gammaAPI);
+ return (void *) psp;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/server/glint_common.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/server/glint_common.h
new file mode 100644
index 000000000..ec601f942
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/server/glint_common.h
@@ -0,0 +1,64 @@
+/* glint_common.h -- common header definitions for Gamma 2D/3D/DRM suite
+ *
+ * Copyright 2002 Tungsten Graphics, 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.
+ *
+ * Converted to common header format:
+ * Jens Owen <jens@tungstengraphics.com>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_common.h,v 1.2 2003/04/03 16:52:18 dawes Exp $
+ *
+ */
+
+#ifndef _GLINT_COMMON_H_
+#define _GLINT_COMMON_H_
+
+/*
+ * WARNING: If you change any of these defines, make sure to change
+ * the kernel include file as well (gamma_drm.h)
+ */
+
+/* Driver specific DRM command indices
+ * NOTE: these are not OS specific, but they are driver specific
+ */
+#define DRM_GAMMA_INIT 0x00
+#define DRM_GAMMA_COPY 0x01
+
+typedef struct {
+ enum {
+ GAMMA_INIT_DMA = 0x01,
+ GAMMA_CLEANUP_DMA = 0x02
+ } func;
+ int sarea_priv_offset;
+ int pcimode;
+ unsigned int mmio0;
+ unsigned int mmio1;
+ unsigned int mmio2;
+ unsigned int mmio3;
+ unsigned int buffers_offset;
+ int num_rast;
+} drmGAMMAInit;
+
+extern int drmGAMMAInitDMA( int fd, drmGAMMAInit *info );
+extern int drmGAMMACleanupDMA( int fd );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/server/glint_dri.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/server/glint_dri.h
new file mode 100644
index 000000000..3952759f8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/gamma/server/glint_dri.h
@@ -0,0 +1,123 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h,v 1.7 2002/10/30 12:52:16 alanh 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.
+
+**************************************************************************/
+
+/*
+ * Author:
+ * Jens Owen <jens@tungstengraphics.com>
+ *
+ */
+
+#ifndef _GLINT_DRI_H_
+#define _GLINT_DRI_H_
+
+#include "xf86drm.h"
+#include "glint_common.h"
+
+typedef struct {
+ unsigned int GDeltaMode;
+ unsigned int GDepthMode;
+ unsigned int GGeometryMode;
+ unsigned int GTransformMode;
+} GAMMAContextRegionRec, *GAMMAContextRegionPtr;
+
+typedef struct {
+ unsigned char next, prev; /* indices to form a circular LRU */
+ unsigned char in_use; /* owned by a client, or free? */
+ int age; /* tracked by clients to update local LRU's */
+} GAMMATextureRegionRec, *GAMMATextureRegionPtr;
+
+typedef struct {
+ GAMMAContextRegionRec context_state;
+
+ unsigned int dirty;
+
+ /* Maintain an LRU of contiguous regions of texture space. If
+ * you think you own a region of texture memory, and it has an
+ * age different to the one you set, then you are mistaken and
+ * it has been stolen by another client. If global texAge
+ * hasn't changed, there is no need to walk the list.
+ *
+ * These regions can be used as a proxy for the fine-grained
+ * texture information of other clients - by maintaining them
+ * in the same lru which is used to age their own textures,
+ * clients have an approximate lru for the whole of global
+ * texture space, and can make informed decisions as to which
+ * areas to kick out. There is no need to choose whether to
+ * kick out your own texture or someone else's - simply eject
+ * them all in LRU order.
+ */
+
+#define GAMMA_NR_TEX_REGIONS 64
+ GAMMATextureRegionRec texList[GAMMA_NR_TEX_REGIONS+1];
+ /* Last elt is sentinal */
+ int texAge; /* last time texture was uploaded */
+ int last_enqueue; /* last time a buffer was enqueued */
+ int last_dispatch; /* age of the most recently dispatched buffer */
+ int last_quiescent; /* */
+ int ctxOwner; /* last context to upload state */
+
+ int vertex_prim;
+} GLINTSAREADRIRec, *GLINTSAREADRIPtr;
+
+/*
+ * Glint specific record passed back to client driver
+ * via DRIGetDeviceInfo request
+ */
+typedef struct {
+ drmRegion registers0;
+ drmRegion registers1;
+ drmRegion registers2;
+ drmRegion registers3;
+ int numMultiDevices;
+ int pprod;
+ int cpp;
+ int frontOffset;
+ int frontPitch;
+ int backOffset;
+ int backPitch;
+ int backX;
+ int backY;
+ int depthOffset;
+ int depthPitch;
+ int textureSize;
+ int logTextureGranularity;
+} GLINTDRIRec, *GLINTDRIPtr;
+
+#define GLINT_DRI_BUF_COUNT 256
+#define GLINT_DRI_BUF_SIZE 4096
+
+#define GAMMA_NR_TEX_REGIONS 64
+
+#define DMA_WRITE(val,reg) \
+do { \
+ pGlint->buf2D++ = Glint##reg##Tag; \
+ pGlint->buf2D++ = val; \
+} while (0)
+
+#endif /* _GLINT_DRI_H_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/Makefile
new file mode 100644
index 000000000..a7825b49b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/Makefile
@@ -0,0 +1,32 @@
+# src/mesa/drivers/dri/i810/Makefile
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = i810_dri.so
+
+# Not yet
+# MINIGLX_SOURCES = server/i810_dri.c
+
+DRIVER_SOURCES = \
+ i810context.c \
+ i810ioctl.c \
+ i810render.c \
+ i810screen.c \
+ i810span.c \
+ i810state.c \
+ i810tex.c \
+ i810texmem.c \
+ i810texstate.c \
+ i810tris.c \
+ i810vb.c
+
+C_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+include ../Makefile.template
+
+symlinks:
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810_3d_reg.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810_3d_reg.h
new file mode 100644
index 000000000..dade1a826
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810_3d_reg.h
@@ -0,0 +1,636 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810_3d_reg.h,v 1.7 2002/02/22 21:33:03 dawes Exp $ */
+
+#ifndef I810_3D_REG_H
+#define I810_3D_REG_H
+
+#include "i810_reg.h"
+
+/* Registers not used in the X server
+ */
+
+#define I810_NOP_ID 0x2094
+#define I810_NOP_ID_MASK ((1<<22)-1)
+
+
+/* 3D instructions
+ */
+
+
+/* GFXRENDERSTATE_PV_PIXELIZATION_RULE, p149
+ *
+ * Format:
+ * 0: GFX_OP_PV_RULE | PV_*
+ *
+ */
+#define GFX_OP_PV_RULE ((0x3<<29)|(0x7<<24))
+#define PV_SMALL_TRI_FILTER_ENABLE (0x1<<11)
+#define PV_UPDATE_PIXRULE (0x1<<10)
+#define PV_PIXRULE_ENABLE (0x1<<9)
+#define PV_UPDATE_LINELIST (0x1<<8)
+#define PV_LINELIST_MASK (0x3<<6)
+#define PV_LINELIST_PV0 (0x0<<6)
+#define PV_LINELIST_PV1 (0x1<<6)
+#define PV_UPDATE_TRIFAN (0x1<<5)
+#define PV_TRIFAN_MASK (0x3<<3)
+#define PV_TRIFAN_PV0 (0x0<<3)
+#define PV_TRIFAN_PV1 (0x1<<3)
+#define PV_TRIFAN_PV2 (0x2<<3)
+#define PV_UPDATE_TRISTRIP (0x1<<2)
+#define PV_TRISTRIP_MASK (0x3<<0)
+#define PV_TRISTRIP_PV0 (0x0<<0)
+#define PV_TRISTRIP_PV1 (0x1<<0)
+#define PV_TRISTRIP_PV2 (0x2<<0)
+
+
+/* GFXRENDERSTATE_SCISSOR_ENABLE, p146
+ *
+ * Format:
+ * 0: GFX_OP_SCISSOR | SC_*
+ */
+#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)
+
+/* GFXRENDERSTATE_SCISSOR_INFO, p147
+ *
+ * Format:
+ * 0: GFX_OP_SCISSOR_INFO
+ * 1: SCI_MIN_*
+ * 2: SCI_MAX_*
+ */
+#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)
+
+/* GFXRENDERSTATE_DRAWING_RECT_INFO, p144
+ *
+ * Format:
+ * 0: GFX_OP_DRAWRECT_INFO
+ * 1: DR1_*
+ * 2: DR2_*
+ * 3: DR3_*
+ * 4: DR4_*
+ */
+#define GFX_OP_DRAWRECT_INFO ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3))
+#define DR1_RECT_CLIP_ENABLE (0x0<<31)
+#define DR1_RECT_CLIP_DISABLE (0x1<<31)
+#define DR1_X_DITHER_BIAS_MASK (0x3<<26)
+#define DR1_X_DITHER_BIAS_SHIFT 26
+#define DR1_Y_DITHER_BIAS_MASK (0x3<<24)
+#define DR1_Y_DITHER_BIAS_SHIFT 24
+#define DR2_YMIN_MASK (0xffff<<16)
+#define DR2_XMIN_MASK (0xffff<<0)
+#define DR3_YMAX_MASK (0xffff<<16)
+#define DR3_XMAX_MASK (0xffff<<0)
+#define DR4_YORG_MASK (0x3ff<<16)
+#define DR4_XORG_MASK (0x7ff<<0)
+
+
+/* GFXRENDERSTATE_LINEWIDTH_CULL_SHADE_MODE, p140
+ *
+ * Format:
+ * 0: GFX_OP_LINEWIDTH_CULL_SHADE_MODE | LCS_*
+ */
+#define GFX_OP_LINEWIDTH_CULL_SHADE_MODE ((0x3<<29)|(0x2<<24))
+#define LCS_UPDATE_ZMODE (0x1<<20)
+#define LCS_Z_MASK (0xf<<16)
+#define LCS_Z_NEVER (0x1<<16)
+#define LCS_Z_LESS (0x2<<16)
+#define LCS_Z_EQUAL (0x3<<16)
+#define LCS_Z_LEQUAL (0x4<<16)
+#define LCS_Z_GREATER (0x5<<16)
+#define LCS_Z_NOTEQUAL (0x6<<16)
+#define LCS_Z_GEQUAL (0x7<<16)
+#define LCS_Z_ALWAYS (0x8<<16)
+#define LCS_UPDATE_LINEWIDTH (0x1<<15)
+#define LCS_LINEWIDTH_MASK (0x7<<12)
+#define LCS_LINEWIDTH_SHIFT 12
+#define LCS_LINEWIDTH_0_5 (0x1<<12)
+#define LCS_LINEWIDTH_1_0 (0x2<<12)
+#define LCS_LINEWIDTH_2_0 (0x4<<12)
+#define LCS_LINEWIDTH_3_0 (0x6<<12)
+#define LCS_UPDATE_ALPHA_INTERP (0x1<<11)
+#define LCS_ALPHA_FLAT (0x1<<10)
+#define LCS_ALPHA_INTERP (0x0<<10)
+#define LCS_UPDATE_FOG_INTERP (0x1<<9)
+#define LCS_FOG_INTERP (0x0<<8)
+#define LCS_FOG_FLAT (0x1<<8)
+#define LCS_UPDATE_SPEC_INTERP (0x1<<7)
+#define LCS_SPEC_INTERP (0x0<<6)
+#define LCS_SPEC_FLAT (0x1<<6)
+#define LCS_UPDATE_RGB_INTERP (0x1<<5)
+#define LCS_RGB_INTERP (0x0<<4)
+#define LCS_RGB_FLAT (0x1<<4)
+#define LCS_UPDATE_CULL_MODE (0x1<<3)
+#define LCS_CULL_MASK (0x7<<0)
+#define LCS_CULL_DISABLE (0x1<<0)
+#define LCS_CULL_CW (0x2<<0)
+#define LCS_CULL_CCW (0x3<<0)
+#define LCS_CULL_BOTH (0x4<<0)
+
+#define LCS_INTERP_FLAT (LCS_ALPHA_FLAT|LCS_RGB_FLAT|LCS_SPEC_FLAT)
+#define LCS_UPDATE_INTERP (LCS_UPDATE_ALPHA_INTERP| \
+ LCS_UPDATE_RGB_INTERP| \
+ LCS_UPDATE_SPEC_INTERP)
+
+
+/* GFXRENDERSTATE_BOOLEAN_ENA_1, p142
+ *
+ */
+#define GFX_OP_BOOL_1 ((0x3<<29)|(0x3<<24))
+#define B1_UPDATE_SPEC_SETUP_ENABLE (1<<19)
+#define B1_SPEC_SETUP_ENABLE (1<<18)
+#define B1_UPDATE_ALPHA_SETUP_ENABLE (1<<17)
+#define B1_ALPHA_SETUP_ENABLE (1<<16)
+#define B1_UPDATE_CI_KEY_ENABLE (1<<15)
+#define B1_CI_KEY_ENABLE (1<<14)
+#define B1_UPDATE_CHROMAKEY_ENABLE (1<<13)
+#define B1_CHROMAKEY_ENABLE (1<<12)
+#define B1_UPDATE_Z_BIAS_ENABLE (1<<11)
+#define B1_Z_BIAS_ENABLE (1<<10)
+#define B1_UPDATE_SPEC_ENABLE (1<<9)
+#define B1_SPEC_ENABLE (1<<8)
+#define B1_UPDATE_FOG_ENABLE (1<<7)
+#define B1_FOG_ENABLE (1<<6)
+#define B1_UPDATE_ALPHA_TEST_ENABLE (1<<5)
+#define B1_ALPHA_TEST_ENABLE (1<<4)
+#define B1_UPDATE_BLEND_ENABLE (1<<3)
+#define B1_BLEND_ENABLE (1<<2)
+#define B1_UPDATE_Z_TEST_ENABLE (1<<1)
+#define B1_Z_TEST_ENABLE (1<<0)
+
+/* GFXRENDERSTATE_BOOLEAN_ENA_2, p143
+ *
+ */
+#define GFX_OP_BOOL_2 ((0x3<<29)|(0x4<<24))
+#define B2_UPDATE_MAP_CACHE_ENABLE (1<<17)
+#define B2_MAP_CACHE_ENABLE (1<<16)
+#define B2_UPDATE_ALPHA_DITHER_ENABLE (1<<15)
+#define B2_ALPHA_DITHER_ENABLE (1<<14)
+#define B2_UPDATE_FOG_DITHER_ENABLE (1<<13)
+#define B2_FOG_DITHER_ENABLE (1<<12)
+#define B2_UPDATE_SPEC_DITHER_ENABLE (1<<11)
+#define B2_SPEC_DITHER_ENABLE (1<<10)
+#define B2_UPDATE_RGB_DITHER_ENABLE (1<<9)
+#define B2_RGB_DITHER_ENABLE (1<<8)
+#define B2_UPDATE_FB_WRITE_ENABLE (1<<3)
+#define B2_FB_WRITE_ENABLE (1<<2)
+#define B2_UPDATE_ZB_WRITE_ENABLE (1<<1)
+#define B2_ZB_WRITE_ENABLE (1<<0)
+
+
+/* GFXRENDERSTATE_FOG_COLOR, p144
+ */
+#define GFX_OP_FOG_COLOR ((0x3<<29)|(0x15<<24))
+#define FOG_RED_SHIFT 16
+#define FOG_GREEN_SHIFT 8
+#define FOG_BLUE_SHIFT 0
+#define FOG_RESERVED_MASK ((0x7<<16)|(0x3<<8)|(0x3))
+
+
+/* GFXRENDERSTATE_Z_BIAS_ALPHA_FUNC_REF, p139
+ */
+#define GFX_OP_ZBIAS_ALPHAFUNC ((0x3<<29)|(0x14<<24))
+#define ZA_UPDATE_ZBIAS (1<<22)
+#define ZA_ZBIAS_SHIFT 14
+#define ZA_ZBIAS_MASK (0xff<<14)
+#define ZA_UPDATE_ALPHAFUNC (1<<13)
+#define ZA_ALPHA_MASK (0xf<<9)
+#define ZA_ALPHA_NEVER (1<<9)
+#define ZA_ALPHA_LESS (2<<9)
+#define ZA_ALPHA_EQUAL (3<<9)
+#define ZA_ALPHA_LEQUAL (4<<9)
+#define ZA_ALPHA_GREATER (5<<9)
+#define ZA_ALPHA_NOTEQUAL (6<<9)
+#define ZA_ALPHA_GEQUAL (7<<9)
+#define ZA_ALPHA_ALWAYS (8<<9)
+#define ZA_UPDATE_ALPHAREF (1<<8)
+#define ZA_ALPHAREF_MASK (0xff<<0)
+#define ZA_ALPHAREF_SHIFT 0
+#define ZA_ALPHAREF_RESERVED (0x7<<0)
+
+
+/* GFXRENDERSTATE_SRC_DST_BLEND_MONO, p136
+ */
+#define GFX_OP_SRC_DEST_MONO ((0x3<<29)|(0x8<<24))
+#define SDM_UPDATE_MONO_ENABLE (1<<13)
+#define SDM_MONO_ENABLE (1<<12)
+#define SDM_UPDATE_SRC_BLEND (1<<11)
+#define SDM_SRC_MASK (0xf<<6)
+#define SDM_SRC_ZERO (0x1<<6)
+#define SDM_SRC_ONE (0x2<<6)
+#define SDM_SRC_SRC_COLOR (0x3<<6)
+#define SDM_SRC_INV_SRC_COLOR (0x4<<6)
+#define SDM_SRC_SRC_ALPHA (0x5<<6)
+#define SDM_SRC_INV_SRC_ALPHA (0x6<<6)
+#define SDM_SRC_DST_COLOR (0x9<<6)
+#define SDM_SRC_INV_DST_COLOR (0xa<<6)
+#define SDM_SRC_BOTH_SRC_ALPHA (0xc<<6)
+#define SDM_SRC_BOTH_INV_SRC_ALPHA (0xd<<6)
+#define SDM_UPDATE_DST_BLEND (1<<5)
+#define SDM_DST_MASK (0xf<<0)
+#define SDM_DST_ZERO (0x1<<0)
+#define SDM_DST_ONE (0x2<<0)
+#define SDM_DST_SRC_COLOR (0x3<<0)
+#define SDM_DST_INV_SRC_COLOR (0x4<<0)
+#define SDM_DST_SRC_ALPHA (0x5<<0)
+#define SDM_DST_INV_SRC_ALPHA (0x6<<0)
+#define SDM_DST_DST_COLOR (0x9<<0)
+#define SDM_DST_INV_DST_COLOR (0xa<<0)
+#define SDM_DST_BOTH_SRC_ALPHA (0xc<<0)
+#define SDM_DST_BOTH_INV_SRC_ALPHA (0xd<<0)
+
+
+/* GFXRENDERSTATE_COLOR_FACTOR, p134
+ *
+ * Format:
+ * 0: GFX_OP_COLOR_FACTOR
+ * 1: ARGB8888 color factor
+ */
+#define GFX_OP_COLOR_FACTOR ((0x3<<29)|(0x1d<<24)|(0x1<<16)|0x0)
+
+/* GFXRENDERSTATE_MAP_ALPHA_BLEND_STAGES, p132
+ */
+#define GFX_OP_MAP_ALPHA_STAGES ((0x3<<29)|(0x1<<24))
+#define MA_STAGE_SHIFT 20
+#define MA_STAGE_0 (0<<20)
+#define MA_STAGE_1 (1<<20)
+#define MA_STAGE_2 (2<<20)
+#define MA_UPDATE_ARG1 (1<<18)
+#define MA_ARG1_MASK ((0x7<<15)|(0x1<<13))
+#define MA_ARG1_ALPHA_FACTOR (0x1<<15)
+#define MA_ARG1_ITERATED_ALPHA (0x3<<15)
+#define MA_ARG1_CURRENT_ALPHA (0x5<<15)
+#define MA_ARG1_TEX0_ALPHA (0x6<<15)
+#define MA_ARG1_TEX1_ALPHA (0x7<<15)
+#define MA_ARG1_INVERT (0x1<<13)
+#define MA_ARG1_DONT_INVERT (0x0<<13)
+#define MA_UPDATE_ARG2 (1<<12)
+#define MA_ARG2_MASK ((0x7<<8)|(0x1<<6))
+#define MA_ARG2_ALPHA_FACTOR (0x1<<8)
+#define MA_ARG2_ITERATED_ALPHA (0x3<<8)
+#define MA_ARG2_CURRENT_ALPHA (0x5<<8)
+#define MA_ARG2_TEX0_ALPHA (0x6<<8)
+#define MA_ARG2_TEX1_ALPHA (0x7<<8)
+#define MA_ARG2_INVERT (0x1<<6)
+#define MA_ARG2_DONT_INVERT (0x0<<6)
+#define MA_UPDATE_OP (1<<5)
+#define MA_OP_MASK (0xf)
+#define MA_OP_ARG1 (0x1)
+#define MA_OP_ARG2 (0x2)
+#define MA_OP_MODULATE (0x3)
+#define MA_OP_MODULATE_X2 (0x4)
+#define MA_OP_MODULATE_X4 (0x5)
+#define MA_OP_ADD (0x6)
+#define MA_OP_ADD_SIGNED (0x7)
+#define MA_OP_LIN_BLEND_ITER_ALPHA (0x8)
+#define MA_OP_LIN_BLEND_ALPHA_FACTOR (0xa)
+#define MA_OP_LIN_BLEND_TEX0_ALPHA (0x10)
+#define MA_OP_LIN_BLEND_TEX1_ALPHA (0x11)
+
+
+/* GFXRENDERSTATE_MAP_COLOR_BLEND_STAGES, p129
+ */
+#define GFX_OP_MAP_COLOR_STAGES ((0x3<<29)|(0x0<<24))
+#define MC_STAGE_SHIFT 20
+#define MC_STAGE_0 (0<<20)
+#define MC_STAGE_1 (1<<20)
+#define MC_STAGE_2 (2<<20)
+#define MC_UPDATE_DEST (1<<19)
+#define MC_DEST_MASK (1<<18)
+#define MC_DEST_CURRENT (0<<18)
+#define MC_DEST_ACCUMULATOR (1<<18)
+#define MC_UPDATE_ARG1 (1<<17)
+#define MC_ARG1_MASK ((0x7<<14)|(0x1<<13)|(0x1<<12))
+#define MC_ARG1_ONE (0x0<<14)
+#define MC_ARG1_COLOR_FACTOR (0x1<<14)
+#define MC_ARG1_ACCUMULATOR (0x2<<14)
+#define MC_ARG1_ITERATED_COLOR (0x3<<14)
+#define MC_ARG1_SPECULAR_COLOR (0x4<<14)
+#define MC_ARG1_CURRENT_COLOR (0x5<<14)
+#define MC_ARG1_TEX0_COLOR (0x6<<14)
+#define MC_ARG1_TEX1_COLOR (0x7<<14)
+#define MC_ARG1_DONT_REPLICATE_ALPHA (0x0<<13)
+#define MC_ARG1_REPLICATE_ALPHA (0x1<<13)
+#define MC_ARG1_DONT_INVERT (0x0<<12)
+#define MC_ARG1_INVERT (0x1<<12)
+#define MC_UPDATE_ARG2 (1<<11)
+#define MC_ARG2_MASK ((0x7<<8)|(0x1<<7)|(0x1<<6))
+#define MC_ARG2_ONE (0x0<<8)
+#define MC_ARG2_COLOR_FACTOR (0x1<<8)
+#define MC_ARG2_ACCUMULATOR (0x2<<8)
+#define MC_ARG2_ITERATED_COLOR (0x3<<8)
+#define MC_ARG2_SPECULAR_COLOR (0x4<<8)
+#define MC_ARG2_CURRENT_COLOR (0x5<<8)
+#define MC_ARG2_TEX0_COLOR (0x6<<8)
+#define MC_ARG2_TEX1_COLOR (0x7<<8)
+#define MC_ARG2_DONT_REPLICATE_ALPHA (0x0<<7)
+#define MC_ARG2_REPLICATE_ALPHA (0x1<<7)
+#define MC_ARG2_DONT_INVERT (0x0<<6)
+#define MC_ARG2_INVERT (0x1<<6)
+#define MC_UPDATE_OP (1<<5)
+#define MC_OP_MASK (0xf)
+#define MC_OP_DISABLE (0x0)
+#define MC_OP_ARG1 (0x1)
+#define MC_OP_ARG2 (0x2)
+#define MC_OP_MODULATE (0x3)
+#define MC_OP_MODULATE_X2 (0x4)
+#define MC_OP_MODULATE_X4 (0x5)
+#define MC_OP_ADD (0x6)
+#define MC_OP_ADD_SIGNED (0x7)
+#define MC_OP_LIN_BLEND_ITER_ALPHA (0x8)
+#define MC_OP_LIN_BLEND_ALPHA_FACTOR (0xa)
+#define MC_OP_LIN_BLEND_TEX0_ALPHA (0x10)
+#define MC_OP_LIN_BLEND_TEX1_ALPHA (0x11)
+#define MC_OP_LIN_BLEND_TEX0_COLOR (0x12)
+#define MC_OP_LIN_BLEND_TEX1_COLOR (0x13)
+#define MC_OP_SUBTRACT (0x14)
+
+/* GFXRENDERSTATE_MAP_PALETTE_LOAD, p128
+ *
+ * Format:
+ * 0: GFX_OP_MAP_PALETTE_LOAD
+ * 1: 16bpp color[0]
+ * ...
+ * 256: 16bpp color[255]
+ */
+#define GFX_OP_MAP_PALETTE_LOAD ((0x3<<29)|(0x1d<<24)|(0x82<<16)|0xff)
+
+/* GFXRENDERSTATE_MAP_LOD_CONTROL, p127
+ */
+#define GFX_OP_MAP_LOD_CTL ((0x3<<29)|(0x1c<<24)|(0x4<<19))
+#define MLC_MAP_ID_SHIFT 16
+#define MLC_MAP_0 (0<<16)
+#define MLC_MAP_1 (1<<16)
+#define MLC_UPDATE_DITHER_WEIGHT (1<<10)
+#define MLC_DITHER_WEIGHT_MASK (0x3<<8)
+#define MLC_DITHER_WEIGHT_FULL (0x0<<8)
+#define MLC_DITHER_WEIGHT_50 (0x1<<8)
+#define MLC_DITHER_WEIGHT_25 (0x2<<8)
+#define MLC_DITHER_WEIGHT_12 (0x3<<8)
+#define MLC_UPDATE_LOD_BIAS (1<<7)
+#define MLC_LOD_BIAS_MASK ((1<<7)-1)
+
+/* GFXRENDERSTATE_MAP_LOD_LIMITS, p126
+ */
+#define GFX_OP_MAP_LOD_LIMITS ((0x3<<29)|(0x1c<<24)|(0x3<<19))
+#define MLL_MAP_ID_SHIFT 16
+#define MLL_MAP_0 (0<<16)
+#define MLL_MAP_1 (1<<16)
+#define MLL_UPDATE_MAX_MIP (1<<13)
+#define MLL_MAX_MIP_SHIFT 5
+#define MLL_MAX_MIP_MASK (0xff<<5)
+#define MLL_MAX_MIP_ONE (0x10<<5)
+#define MLL_UPDATE_MIN_MIP (1<<4)
+#define MLL_MIN_MIP_SHIFT 0
+#define MLL_MIN_MIP_MASK (0xf<<0)
+
+/* GFXRENDERSTATE_MAP_FILTER, p124
+ */
+#define GFX_OP_MAP_FILTER ((0x3<<29)|(0x1c<<24)|(0x2<<19))
+#define MF_MAP_ID_SHIFT 16
+#define MF_MAP_0 (0<<16)
+#define MF_MAP_1 (1<<16)
+#define MF_UPDATE_ANISOTROPIC (1<<12)
+#define MF_ANISOTROPIC_MASK (1<<10)
+#define MF_ANISOTROPIC_ENABLE (1<<10)
+#define MF_UPDATE_MIP_FILTER (1<<9)
+#define MF_MIP_MASK (0x3<<6)
+#define MF_MIP_NONE (0x0<<6)
+#define MF_MIP_NEAREST (0x1<<6)
+#define MF_MIP_DITHER (0x2<<6)
+#define MF_MIP_LINEAR (0x3<<6)
+#define MF_UPDATE_MAG_FILTER (1<<5)
+#define MF_MAG_MASK (1<<3)
+#define MF_MAG_LINEAR (1<<3)
+#define MF_MAG_NEAREST (0<<3)
+#define MF_UPDATE_MIN_FILTER (1<<2)
+#define MF_MIN_MASK (1<<0)
+#define MF_MIN_LINEAR (1<<0)
+#define MF_MIN_NEAREST (0<<0)
+
+/* GFXRENDERSTATE_MAP_INFO, p118
+ */
+#define GFX_OP_MAP_INFO ((0x3<<29)|(0x1d<<24)|0x2)
+#define MI1_MAP_ID_SHIFT 28
+#define MI1_MAP_0 (0<<28)
+#define MI1_MAP_1 (1<<28)
+#define MI1_FMT_MASK (0x7<<24)
+#define MI1_FMT_8CI (0x0<<24)
+#define MI1_FMT_8BPP (0x1<<24)
+#define MI1_FMT_16BPP (0x2<<24)
+#define MI1_FMT_422 (0x5<<24)
+#define MI1_PF_MASK (0x3<<21)
+#define MI1_PF_8CI_RGB565 (0x0<<21)
+#define MI1_PF_8CI_ARGB1555 (0x1<<21)
+#define MI1_PF_8CI_ARGB4444 (0x2<<21)
+#define MI1_PF_8CI_AY88 (0x3<<21)
+#define MI1_PF_16BPP_RGB565 (0x0<<21)
+#define MI1_PF_16BPP_ARGB1555 (0x1<<21)
+#define MI1_PF_16BPP_ARGB4444 (0x2<<21)
+#define MI1_PF_16BPP_AY88 (0x3<<21)
+#define MI1_PF_422_YCRCB_SWAP_Y (0x0<<21)
+#define MI1_PF_422_YCRCB (0x1<<21)
+#define MI1_PF_422_YCRCB_SWAP_UV (0x2<<21)
+#define MI1_PF_422_YCRCB_SWAP_YUV (0x3<<21)
+#define MI1_OUTPUT_CHANNEL_MASK (0x3<<19)
+#define MI1_COLOR_CONV_ENABLE (1<<18)
+#define MI1_VERT_STRIDE_MASK (1<<17)
+#define MI1_VERT_STRIDE_1 (1<<17)
+#define MI1_VERT_OFFSET_MASK (1<<16)
+#define MI1_VERT_OFFSET_1 (1<<16)
+#define MI1_ENABLE_FENCE_REGS (1<<10)
+#define MI1_TILED_SURFACE (1<<9)
+#define MI1_TILE_WALK_X (0<<8)
+#define MI1_TILE_WALK_Y (1<<8)
+#define MI1_PITCH_MASK (0xf<<0)
+#define MI2_DIMENSIONS_ARE_LOG2 (1<<31)
+#define MI2_DIMENSIONS_ARE_EXACT (0<<31)
+#define MI2_HEIGHT_SHIFT 16
+#define MI2_HEIGHT_MASK (0x1ff<<16)
+#define MI2_WIDTH_SHIFT 0
+#define MI2_WIDTH_MASK (0x1ff<<0)
+#define MI3_BASE_ADDR_MASK (~0xf)
+
+/* GFXRENDERSTATE_MAP_COORD_SETS, p116
+ */
+#define GFX_OP_MAP_COORD_SETS ((0x3<<29)|(0x1c<<24)|(0x1<<19))
+#define MCS_COORD_ID_SHIFT 16
+#define MCS_COORD_0 (0<<16)
+#define MCS_COORD_1 (1<<16)
+#define MCS_UPDATE_NORMALIZED (1<<15)
+#define MCS_NORMALIZED_COORDS_MASK (1<<14)
+#define MCS_NORMALIZED_COORDS (1<<14)
+#define MCS_UPDATE_V_STATE (1<<7)
+#define MCS_V_STATE_MASK (0x3<<4)
+#define MCS_V_WRAP (0x0<<4)
+#define MCS_V_MIRROR (0x1<<4)
+#define MCS_V_CLAMP (0x2<<4)
+#define MCS_V_WRAP_SHORTEST (0x3<<4)
+#define MCS_UPDATE_U_STATE (1<<3)
+#define MCS_U_STATE_MASK (0x3<<0)
+#define MCS_U_WRAP (0x0<<0)
+#define MCS_U_MIRROR (0x1<<0)
+#define MCS_U_CLAMP (0x2<<0)
+#define MCS_U_WRAP_SHORTEST (0x3<<0)
+
+/* GFXRENDERSTATE_MAP_TEXELS, p115
+ */
+#define GFX_OP_MAP_TEXELS ((0x3<<29)|(0x1c<<24)|(0x0<<19))
+#define MT_UPDATE_TEXEL1_STATE (1<<15)
+#define MT_TEXEL1_DISABLE (0<<14)
+#define MT_TEXEL1_ENABLE (1<<14)
+#define MT_TEXEL1_COORD0 (0<<11)
+#define MT_TEXEL1_COORD1 (1<<11)
+#define MT_TEXEL1_MAP0 (0<<8)
+#define MT_TEXEL1_MAP1 (1<<8)
+#define MT_UPDATE_TEXEL0_STATE (1<<7)
+#define MT_TEXEL0_DISABLE (0<<6)
+#define MT_TEXEL0_ENABLE (1<<6)
+#define MT_TEXEL0_COORD0 (0<<3)
+#define MT_TEXEL0_COORD1 (1<<3)
+#define MT_TEXEL0_MAP0 (0<<0)
+#define MT_TEXEL0_MAP1 (1<<0)
+
+/* GFXRENDERSTATE_VERTEX_FORMAT, p110
+ */
+#define GFX_OP_VERTEX_FMT ((0x3<<29)|(0x5<<24))
+#define VF_TEXCOORD_COUNT_SHIFT 8
+#define VF_TEXCOORD_COUNT_0 (0<<8)
+#define VF_TEXCOORD_COUNT_1 (1<<8)
+#define VF_TEXCOORD_COUNT_2 (2<<8)
+#define VF_SPEC_FOG_ENABLE (1<<7)
+#define VF_RGBA_ENABLE (1<<6)
+#define VF_Z_OFFSET_ENABLE (1<<5)
+#define VF_XYZ (0x1<<1)
+#define VF_XYZW (0x2<<1)
+#define VF_XY (0x3<<1)
+#define VF_XYW (0x4<<1)
+
+
+#define VERT_X_MASK (~0xf)
+#define VERT_X_EDGE_V2V0 (1<<2)
+#define VERT_X_EDGE_V1V2 (1<<1)
+#define VERT_X_EDGE_V0V1 (1<<0)
+
+/* Not enabled fields should not be sent to hardware:
+ */
+typedef struct {
+ union {
+ float x;
+ unsigned int edge_flags;
+ } x;
+ float y;
+ float z;
+ float z_bias;
+ float oow;
+ unsigned int argb;
+ unsigned int fog_spec_rgb; /* spec g and r ignored. */
+ float tu0;
+ float tv0;
+ float tu1;
+ float tv1;
+} i810_full_vertex;
+
+
+
+/* GFXCMDPARSER_BATCH_BUFFER, p105
+ *
+ * Not clear whether start address must be shifted or not. Not clear
+ * whether address is physical system memory, or subject to GTT
+ * translation. Because the address appears to be 32 bits long,
+ * perhaps it refers to physical system memory...
+ */
+#define CMD_OP_BATCH_BUFFER ((0x0<<29)|(0x30<<23)|0x1)
+#define BB1_START_ADDR_MASK (~0x7)
+#define BB1_PROTECTED (1<<0)
+#define BB1_UNPROTECTED (0<<0)
+#define BB2_END_ADDR_MASK (~0x7)
+
+/* Hardware seems to barf on buffers larger than this (in strange ways)...
+ */
+#define MAX_BATCH (512*1024)
+
+
+/* GFXCMDPARSER_Z_BUFFER_INFO, p98
+ *
+ * Base address is in GTT space, and must be 4K aligned
+ */
+#define CMD_OP_Z_BUFFER_INFO ((0x0<<29)|(0x16<<23))
+#define ZB_BASE_ADDR_SHIFT 0
+#define ZB_BASE_ADDR_MASK (~((1<<12)-1))
+#define ZB_PITCH_512B (0x0<<0)
+#define ZB_PITCH_1K (0x1<<0)
+#define ZB_PITCH_2K (0x2<<0)
+#define ZB_PITCH_4K (0x3<<0)
+
+/* GFXCMDPARSER_FRONT_BUFFER_INFO, p97
+ *
+ * Format:
+ * 0: CMD_OP_FRONT_BUFFER_INFO | (pitch<<FB0_PITCH_SHIFT) | FB0_*
+ * 1: FB1_*
+ */
+#define CMD_OP_FRONT_BUFFER_INFO ((0x0<<29)|(0x14<<23))
+#define FB0_PITCH_SHIFT 8
+#define FB0_FLIP_SYNC (0<<6)
+#define FB0_FLIP_ASYNC (1<<6)
+#define FB0_BASE_ADDR_SHIFT 0
+#define FB0_BASE_ADDR_MASK 0x03FFFFF8
+
+/* GFXCMDPARSER_DEST_BUFFER_INFO, p96
+ *
+ * Format:
+ */
+#define CMD_OP_DESTBUFFER_INFO ((0x0<<29)|(0x15<<23))
+#define DB1_BASE_ADDR_SHIFT 0
+#define DB1_BASE_ADDR_MASK 0x03FFF000
+#define DB1_PITCH_512B (0x0<<0)
+#define DB1_PITCH_1K (0x1<<0)
+#define DB1_PITCH_2K (0x2<<0)
+#define DB1_PITCH_4K (0x4<<0)
+
+
+/* GFXRENDERSTATE_DEST_BUFFER_VARIABLES, p152
+ *
+ * Format:
+ * 0: GFX_OP_DESTBUFFER_VARS
+ * 1: DEST_*
+ */
+#define GFX_OP_DESTBUFFER_VARS ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0)
+#define DV_HORG_BIAS_MASK (0xf<<20)
+#define DV_HORG_BIAS_OGL (0x0<<20)
+#define DV_VORG_BIAS_MASK (0xf<<16)
+#define DV_VORG_BIAS_OGL (0x0<<16)
+#define DV_PF_MASK (0x7<<8)
+#define DV_PF_INDEX (0x0<<8)
+#define DV_PF_555 (0x1<<8)
+#define DV_PF_565 (0x2<<8)
+
+#define GFX_OP_ANTIALIAS ((0x3<<29)|(0x6<<24))
+#define AA_UPDATE_EDGEFLAG (1<<13)
+#define AA_ENABLE_EDGEFLAG (1<<12)
+#define AA_UPDATE_POLYWIDTH (1<<11)
+#define AA_POLYWIDTH_05 (1<<9)
+#define AA_POLYWIDTH_10 (2<<9)
+#define AA_POLYWIDTH_20 (3<<9)
+#define AA_POLYWIDTH_40 (4<<9)
+#define AA_UPDATE_LINEWIDTH (1<<8)
+#define AA_LINEWIDTH_05 (1<<6)
+#define AA_LINEWIDTH_10 (2<<6)
+#define AA_LINEWIDTH_20 (3<<6)
+#define AA_LINEWIDTH_40 (4<<6)
+#define AA_UPDATE_BB_EXPANSION (1<<5)
+#define AA_BB_EXPANSION_SHIFT 2
+#define AA_UPDATE_AA_ENABLE (1<<1)
+#define AA_ENABLE (1<<0)
+
+#define GFX_OP_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16))
+#define ST1_ENABLE (1<<16)
+#define ST1_MASK (0xffff)
+
+#define I810_SET_FIELD( var, mask, value ) (var &= ~(mask), var |= value)
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810context.c
new file mode 100644
index 000000000..47c41c5db
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810context.c
@@ -0,0 +1,572 @@
+/**************************************************************************
+
+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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810context.c,v 1.3 2002/10/30 12:51:33 alanh Exp $ */
+
+/*
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ *
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "matrix.h"
+#include "simple_list.h"
+#include "extensions.h"
+#include "framebuffer.h"
+#include "imports.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "array_cache/acache.h"
+
+#include "tnl/t_pipeline.h"
+
+#include "drivers/common/driverfuncs.h"
+
+#include "i810screen.h"
+#include "i810_dri.h"
+
+#include "i810state.h"
+#include "i810tex.h"
+#include "i810span.h"
+#include "i810tris.h"
+#include "i810vb.h"
+#include "i810ioctl.h"
+
+#include "utils.h"
+
+#define need_GL_ARB_multisample
+#define need_GL_ARB_texture_compression
+#include "extension_helper.h"
+
+#ifndef I810_DEBUG
+int I810_DEBUG = (0);
+#endif
+
+PUBLIC const char __driConfigOptions[] = { 0 };
+const GLuint __driNConfigOptions = 0;
+
+#define DRIVER_DATE "20050818"
+
+static const GLubyte *i810GetString( GLcontext *ctx, GLenum name )
+{
+ static char buffer[128];
+
+ switch (name) {
+ case GL_VENDOR:
+ return (GLubyte *)"Keith Whitwell";
+ case GL_RENDERER: {
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ const char * chipset;
+
+ switch (imesa->i810Screen->deviceID) {
+ case PCI_CHIP_I810: chipset = "i810"; break;
+ case PCI_CHIP_I810_DC100: chipset = "i810 DC-100"; break;
+ case PCI_CHIP_I810_E: chipset = "i810E"; break;
+ case PCI_CHIP_I815: chipset = "i815"; break;
+ default: chipset = "Unknown i810-class Chipset"; break;
+ }
+
+ (void) driGetRendererString( buffer, chipset, DRIVER_DATE, 0 );
+ return (GLubyte *) buffer;
+ }
+ default:
+ return 0;
+ }
+}
+
+static void i810BufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+
+ /* Need to lock to make sure the driDrawable is uptodate. This
+ * information is used to resize Mesa's software buffers, so it has
+ * to be correct.
+ */
+ LOCK_HARDWARE(imesa);
+ *width = imesa->driDrawable->w;
+ *height = imesa->driDrawable->h;
+ UNLOCK_HARDWARE(imesa);
+}
+
+/* Extension strings exported by the i810 driver.
+ */
+const struct dri_extension card_extensions[] =
+{
+ { "GL_ARB_multisample", GL_ARB_multisample_functions },
+ { "GL_ARB_multitexture", NULL },
+ { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions },
+ { "GL_ARB_texture_env_add", NULL },
+ { "GL_ARB_texture_mirrored_repeat", NULL },
+ { "GL_EXT_stencil_wrap", NULL },
+ { "GL_EXT_texture_edge_clamp", NULL },
+ { "GL_EXT_texture_lod_bias", NULL },
+ { "GL_MESA_ycbcr_texture", NULL },
+ { "GL_NV_blend_square", NULL },
+ { "GL_SGIS_generate_mipmap", NULL },
+ { NULL, NULL }
+};
+
+extern const struct tnl_pipeline_stage _i810_render_stage;
+
+static const struct tnl_pipeline_stage *i810_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ /* REMOVE: point attenuation stage */
+#if 1
+ &_i810_render_stage, /* ADD: unclipped rastersetup-to-dma */
+#endif
+ &_tnl_render_stage,
+ 0,
+};
+
+static const struct dri_debug_control debug_control[] =
+{
+ { "fall", DEBUG_FALLBACKS },
+ { "tex", DEBUG_TEXTURE },
+ { "ioctl", DEBUG_IOCTL },
+ { "prim", DEBUG_PRIMS },
+ { "vert", DEBUG_VERTS },
+ { "state", DEBUG_STATE },
+ { "verb", DEBUG_VERBOSE },
+ { "dri", DEBUG_DRI },
+ { "dma", DEBUG_DMA },
+ { "san", DEBUG_SANITY },
+ { "sync", DEBUG_SYNC },
+ { "sleep", DEBUG_SLEEP },
+ { NULL, 0 }
+};
+
+GLboolean
+i810CreateContext( const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate )
+{
+ GLcontext *ctx, *shareCtx;
+ i810ContextPtr imesa;
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ i810ScreenPrivate *i810Screen = (i810ScreenPrivate *)sPriv->private;
+ I810SAREAPtr saPriv = (I810SAREAPtr)
+ (((GLubyte *)sPriv->pSAREA) + i810Screen->sarea_priv_offset);
+ struct dd_function_table functions;
+
+ /* Allocate i810 context */
+ imesa = (i810ContextPtr) CALLOC_STRUCT(i810_context_t);
+ if (!imesa) {
+ return GL_FALSE;
+ }
+
+ driContextPriv->driverPrivate = imesa;
+
+ imesa->i810Screen = i810Screen;
+ imesa->driScreen = sPriv;
+ imesa->sarea = saPriv;
+ imesa->glBuffer = NULL;
+
+ /* Init default driver functions then plug in our I810-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions( &functions );
+ i810InitIoctlFuncs( &functions );
+ i810InitTextureFuncs( &functions );
+
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((i810ContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ imesa->glCtx = _mesa_create_context(mesaVis, shareCtx,
+ &functions, (void*) imesa);
+ if (!imesa->glCtx) {
+ FREE(imesa);
+ return GL_FALSE;
+ }
+
+ (void) memset( imesa->texture_heaps, 0, sizeof( imesa->texture_heaps ) );
+ make_empty_list( & imesa->swapped );
+
+ imesa->nr_heaps = 1;
+ imesa->texture_heaps[0] = driCreateTextureHeap( 0, imesa,
+ i810Screen->textureSize,
+ 12,
+ I810_NR_TEX_REGIONS,
+ imesa->sarea->texList,
+ (unsigned *) & imesa->sarea->texAge, /* XXX we shouldn't cast! */
+ & imesa->swapped,
+ sizeof( struct i810_texture_object_t ),
+ (destroy_texture_object_t *) i810DestroyTexObj );
+
+
+
+ /* 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.
+ */
+
+
+
+ ctx = imesa->glCtx;
+ ctx->Const.MaxTextureUnits = 2;
+ ctx->Const.MaxTextureImageUnits = 2;
+ ctx->Const.MaxTextureCoordUnits = 2;
+
+
+ /* FIXME: driCalcualteMaxTextureLevels assumes that mipmaps are tightly
+ * FIXME: packed, but they're not in Intel graphics hardware.
+ */
+ driCalculateMaxTextureLevels( imesa->texture_heaps,
+ imesa->nr_heaps,
+ & ctx->Const,
+ 4,
+ 11, /* max 2D texture size is 2048x2048 */
+ 0, /* 3D textures unsupported */
+ 0, /* cube textures unsupported. */
+ 0, /* texture rectangles unsupported. */
+ 12,
+ GL_FALSE );
+
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 3.0;
+ ctx->Const.MaxLineWidthAA = 3.0;
+ ctx->Const.LineWidthGranularity = 1.0;
+
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = 3.0;
+ ctx->Const.MaxPointSizeAA = 3.0;
+ ctx->Const.PointSizeGranularity = 1.0;
+
+ ctx->Driver.GetBufferSize = i810BufferSize;
+ ctx->Driver.ResizeBuffers = _mesa_resize_framebuffer;
+ ctx->Driver.GetString = i810GetString;
+
+ /* Who owns who?
+ */
+ ctx->DriverCtx = (void *) imesa;
+ imesa->glCtx = ctx;
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+
+ /* Install the customized pipeline:
+ */
+ _tnl_destroy_pipeline( ctx );
+ _tnl_install_pipeline( ctx, i810_pipeline );
+
+ /* Configure swrast and T&L to match hardware characteristics:
+ */
+ _swrast_allow_pixel_fog( ctx, GL_FALSE );
+ _swrast_allow_vertex_fog( ctx, GL_TRUE );
+ _tnl_allow_pixel_fog( ctx, GL_FALSE );
+ _tnl_allow_vertex_fog( ctx, GL_TRUE );
+
+ /* Dri stuff
+ */
+ imesa->hHWContext = driContextPriv->hHWContext;
+ imesa->driFd = sPriv->fd;
+ imesa->driHwLock = &sPriv->pSAREA->lock;
+
+ imesa->stipple_in_hw = 1;
+ imesa->RenderIndex = ~0;
+ imesa->dirty = I810_UPLOAD_CTX|I810_UPLOAD_BUFFERS;
+ imesa->upload_cliprects = GL_TRUE;
+
+ imesa->CurrentTexObj[0] = 0;
+ imesa->CurrentTexObj[1] = 0;
+
+ _math_matrix_ctr( &imesa->ViewportMatrix );
+
+ driInitExtensions( ctx, card_extensions, GL_TRUE );
+ /* XXX these should really go right after _mesa_init_driver_functions() */
+ i810InitStateFuncs( ctx );
+ i810InitTriFuncs( ctx );
+ i810InitSpanFuncs( ctx );
+ i810InitVB( ctx );
+ i810InitState( ctx );
+
+#if DO_DEBUG
+ I810_DEBUG = driParseDebugString( getenv( "I810_DEBUG" ),
+ debug_control );
+ I810_DEBUG |= driParseDebugString( getenv( "INTEL_DEBUG" ),
+ debug_control );
+#endif
+
+ return GL_TRUE;
+}
+
+void
+i810DestroyContext(__DRIcontextPrivate *driContextPriv)
+{
+ i810ContextPtr imesa = (i810ContextPtr) driContextPriv->driverPrivate;
+
+ assert(imesa); /* should never be null */
+ if (imesa) {
+ GLboolean release_texture_heaps;
+
+
+ release_texture_heaps = (imesa->glCtx->Shared->RefCount == 1);
+ _swsetup_DestroyContext( imesa->glCtx );
+ _tnl_DestroyContext( imesa->glCtx );
+ _ac_DestroyContext( imesa->glCtx );
+ _swrast_DestroyContext( imesa->glCtx );
+
+ i810FreeVB( imesa->glCtx );
+
+ /* free the Mesa context */
+ imesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(imesa->glCtx);
+ if ( release_texture_heaps ) {
+ /* This share group is about to go away, free our private
+ * texture object data.
+ */
+ unsigned int i;
+
+ for ( i = 0 ; i < imesa->nr_heaps ; i++ ) {
+ driDestroyTextureHeap( imesa->texture_heaps[ i ] );
+ imesa->texture_heaps[ i ] = NULL;
+ }
+
+ assert( is_empty_list( & imesa->swapped ) );
+ }
+
+ FREE(imesa);
+ }
+}
+
+
+void i810XMesaSetFrontClipRects( i810ContextPtr imesa )
+{
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+
+ imesa->numClipRects = dPriv->numClipRects;
+ imesa->pClipRects = dPriv->pClipRects;
+ imesa->drawX = dPriv->x;
+ imesa->drawY = dPriv->y;
+
+ i810EmitDrawingRectangle( imesa );
+ imesa->upload_cliprects = GL_TRUE;
+}
+
+
+void i810XMesaSetBackClipRects( i810ContextPtr imesa )
+{
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+
+ if (imesa->sarea->pf_enabled == 0 && dPriv->numBackClipRects == 0)
+ {
+ imesa->numClipRects = dPriv->numClipRects;
+ imesa->pClipRects = dPriv->pClipRects;
+ imesa->drawX = dPriv->x;
+ imesa->drawY = dPriv->y;
+ } else {
+ imesa->numClipRects = dPriv->numBackClipRects;
+ imesa->pClipRects = dPriv->pBackClipRects;
+ imesa->drawX = dPriv->backX;
+ imesa->drawY = dPriv->backY;
+ }
+
+ i810EmitDrawingRectangle( imesa );
+ imesa->upload_cliprects = GL_TRUE;
+}
+
+
+static void i810XMesaWindowMoved( i810ContextPtr imesa )
+{
+ /* Determine current color drawing buffer */
+ switch (imesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) {
+ case BUFFER_BIT_FRONT_LEFT:
+ i810XMesaSetFrontClipRects( imesa );
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ i810XMesaSetBackClipRects( imesa );
+ break;
+ default:
+ /* glDrawBuffer(GL_NONE or GL_FRONT_AND_BACK): software fallback */
+ i810XMesaSetFrontClipRects( imesa );
+ }
+}
+
+
+GLboolean
+i810UnbindContext(__DRIcontextPrivate *driContextPriv)
+{
+ i810ContextPtr imesa = (i810ContextPtr) driContextPriv->driverPrivate;
+ if (imesa) {
+ imesa->dirty = I810_UPLOAD_CTX|I810_UPLOAD_BUFFERS;
+ if (imesa->CurrentTexObj[0]) imesa->dirty |= I810_UPLOAD_TEX0;
+ if (imesa->CurrentTexObj[1]) imesa->dirty |= I810_UPLOAD_TEX1;
+ }
+
+ return GL_TRUE;
+}
+
+
+GLboolean
+i810MakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
+{
+ if (driContextPriv) {
+ i810ContextPtr imesa = (i810ContextPtr) driContextPriv->driverPrivate;
+
+ /* Shouldn't the readbuffer be stored also?
+ */
+ imesa->driDrawable = driDrawPriv;
+
+ _mesa_make_current(imesa->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate);
+
+ /* Are these necessary?
+ */
+ i810XMesaWindowMoved( imesa );
+ }
+ else {
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ return GL_TRUE;
+}
+
+static void
+i810UpdatePageFlipping( i810ContextPtr imesa )
+{
+ GLcontext *ctx = imesa->glCtx;
+ int front = 0;
+
+ /* Determine current color drawing buffer */
+ switch (ctx->DrawBuffer->_ColorDrawBufferMask[0]) {
+ case BUFFER_BIT_FRONT_LEFT:
+ front = 1;
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ front = 0;
+ break;
+ default:
+ return;
+ }
+
+ if ( imesa->sarea->pf_current_page == 1 )
+ front ^= 1;
+
+ if (front) {
+ imesa->BufferSetup[I810_DESTREG_DI1] = imesa->i810Screen->fbOffset | imesa->i810Screen->backPitchBits;
+ imesa->drawMap = (char *)imesa->driScreen->pFB;
+ imesa->readMap = (char *)imesa->driScreen->pFB;
+ } else {
+ imesa->BufferSetup[I810_DESTREG_DI1] = imesa->i810Screen->backOffset | imesa->i810Screen->backPitchBits;
+ imesa->drawMap = imesa->i810Screen->back.map;
+ imesa->readMap = imesa->i810Screen->back.map;
+ }
+
+ imesa->dirty |= I810_UPLOAD_BUFFERS;
+}
+
+void i810GetLock( i810ContextPtr imesa, GLuint flags )
+{
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+ __DRIscreenPrivate *sPriv = imesa->driScreen;
+ I810SAREAPtr sarea = imesa->sarea;
+ int me = imesa->hHWContext;
+ unsigned i;
+
+ drmGetLock(imesa->driFd, imesa->hHWContext, flags);
+
+ /* 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:
+ */
+ DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
+
+
+ /* 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) {
+ imesa->upload_cliprects = GL_TRUE;
+ imesa->dirty = I810_UPLOAD_CTX|I810_UPLOAD_BUFFERS;
+ if (imesa->CurrentTexObj[0]) imesa->dirty |= I810_UPLOAD_TEX0;
+ if (imesa->CurrentTexObj[1]) imesa->dirty |= I810_UPLOAD_TEX1;
+ sarea->ctxOwner = me;
+ }
+
+ /* Shared texture managment - if another client has played with
+ * texture space, figure out which if any of our textures have been
+ * ejected, and update our global LRU.
+ */
+ for ( i = 0 ; i < imesa->nr_heaps ; i++ ) {
+ DRI_AGE_TEXTURES( imesa->texture_heaps[ i ] );
+ }
+
+ if (imesa->lastStamp != dPriv->lastStamp) {
+ i810UpdatePageFlipping( imesa );
+ i810XMesaWindowMoved( imesa );
+ imesa->lastStamp = dPriv->lastStamp;
+ }
+}
+
+
+void
+i810SwapBuffers( __DRIdrawablePrivate *dPriv )
+{
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ i810ContextPtr imesa;
+ GLcontext *ctx;
+ imesa = (i810ContextPtr) dPriv->driContextPriv->driverPrivate;
+ ctx = imesa->glCtx;
+ if (ctx->Visual.doubleBufferMode) {
+ _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
+ if ( imesa->sarea->pf_active ) {
+ i810PageFlip( dPriv );
+ } else {
+ i810CopyBuffer( dPriv );
+ }
+ }
+ }
+ else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ _mesa_problem(NULL, "i810SwapBuffers: drawable has no context!\n");
+ }
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810context.h
new file mode 100644
index 000000000..a2202e148
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810context.h
@@ -0,0 +1,252 @@
+/*
+ * GLX Hardware Device Driver for Intel i810
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * 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
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810context.h,v 1.9 2002/12/16 16:18:51 dawes Exp $ */
+
+#ifndef I810CONTEXT_INC
+#define I810CONTEXT_INC
+
+typedef struct i810_context_t i810Context;
+typedef struct i810_context_t *i810ContextPtr;
+typedef struct i810_texture_object_t *i810TextureObjectPtr;
+
+#include "drm.h"
+#include "mtypes.h"
+#include "mm.h"
+
+#include "i810screen.h"
+#include "i810tex.h"
+
+
+/* Reasons to disable hardware rasterization.
+ */
+#define I810_FALLBACK_TEXTURE 0x1
+#define I810_FALLBACK_DRAW_BUFFER 0x2
+#define I810_FALLBACK_READ_BUFFER 0x4
+#define I810_FALLBACK_COLORMASK 0x8
+#define I810_FALLBACK_SPECULAR 0x20
+#define I810_FALLBACK_LOGICOP 0x40
+#define I810_FALLBACK_RENDERMODE 0x80
+#define I810_FALLBACK_STENCIL 0x100
+#define I810_FALLBACK_BLEND_EQ 0x200
+#define I810_FALLBACK_BLEND_FUNC 0x400
+
+
+#ifndef PCI_CHIP_I810
+#define PCI_CHIP_I810 0x7121
+#define PCI_CHIP_I810_DC100 0x7123
+#define PCI_CHIP_I810_E 0x7125
+#define PCI_CHIP_I815 0x1132
+#endif
+
+#define IS_I810(imesa) (imesa->i810Screen->deviceID == PCI_CHIP_I810 || \
+ imesa->i810Screen->deviceID == PCI_CHIP_I810_DC100 || \
+ imesa->i810Screen->deviceID == PCI_CHIP_I810_E)
+#define IS_I815(imesa) (imesa->i810Screen->deviceID == PCI_CHIP_I815)
+
+
+#define I810_UPLOAD_TEX(i) (I810_UPLOAD_TEX0<<(i))
+
+/* Use the templated vertex formats:
+ */
+#define TAG(x) i810##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+typedef void (*i810_tri_func)( i810ContextPtr, i810Vertex *, i810Vertex *,
+ i810Vertex * );
+typedef void (*i810_line_func)( i810ContextPtr, i810Vertex *, i810Vertex * );
+typedef void (*i810_point_func)( i810ContextPtr, i810Vertex * );
+
+struct i810_context_t {
+ GLint refcount;
+ GLcontext *glCtx;
+
+ /* Texture object bookkeeping
+ */
+ unsigned nr_heaps;
+ driTexHeap * texture_heaps[1];
+ driTextureObject swapped;
+
+ struct i810_texture_object_t *CurrentTexObj[2];
+
+
+ /* Bit flag to keep track of fallbacks.
+ */
+ GLuint Fallback;
+
+ /* State for i810vb.c and i810tris.c.
+ */
+ GLuint new_state; /* _NEW_* flags */
+ GLuint SetupNewInputs;
+ GLuint SetupIndex;
+ GLuint RenderIndex;
+ GLmatrix ViewportMatrix;
+ GLenum render_primitive;
+ GLenum reduced_primitive;
+ GLuint hw_primitive;
+ GLubyte *verts;
+
+ drmBufPtr vertex_buffer;
+ char *vertex_addr;
+ GLuint vertex_low;
+ GLuint vertex_high;
+ GLuint vertex_last_prim;
+
+ GLboolean upload_cliprects;
+
+
+ /* Fallback rasterization functions
+ */
+ i810_point_func draw_point;
+ i810_line_func draw_line;
+ i810_tri_func draw_tri;
+
+ /* Hardware state
+ */
+ GLuint dirty; /* I810_UPLOAD_* */
+ GLuint Setup[I810_CTX_SETUP_SIZE];
+ GLuint BufferSetup[I810_DEST_SETUP_SIZE];
+ int vertex_size;
+ int vertex_stride_shift;
+ unsigned int lastStamp;
+ GLboolean stipple_in_hw;
+
+ GLenum TexEnvImageFmt[2];
+
+ /* State which can't be computed completely on the fly:
+ */
+ GLuint LcsCullMode;
+ GLuint LcsLineWidth;
+ GLuint LcsPointSize;
+
+ /* Funny mesa mirrors
+ */
+ GLushort ClearColor;
+
+ /* DRI stuff
+ */
+ GLuint needClip;
+ GLframebuffer *glBuffer;
+ GLboolean doPageFlip;
+
+ /* These refer to the current draw (front vs. back) buffer:
+ */
+ char *drawMap; /* draw buffer address in virtual mem */
+ char *readMap;
+ int drawX; /* origin of drawable in draw buffer */
+ int drawY;
+ GLuint numClipRects; /* cliprects for that buffer */
+ drm_clip_rect_t *pClipRects;
+
+ int lastSwap;
+ int texAge;
+ int ctxAge;
+ int dirtyAge;
+
+
+ GLboolean scissor;
+ drm_clip_rect_t draw_rect;
+ drm_clip_rect_t scissor_rect;
+
+ drm_context_t hHWContext;
+ drm_hw_lock_t *driHwLock;
+ int driFd;
+
+ __DRIdrawablePrivate *driDrawable;
+ __DRIscreenPrivate *driScreen;
+ i810ScreenPrivate *i810Screen;
+ I810SAREAPtr sarea;
+};
+
+
+#define I810_CONTEXT(ctx) ((i810ContextPtr)(ctx->DriverCtx))
+
+#define GET_DISPATCH_AGE( imesa ) imesa->sarea->last_dispatch
+#define GET_ENQUEUE_AGE( imesa ) imesa->sarea->last_enqueue
+
+
+/* Lock the hardware and validate our state.
+ */
+#define LOCK_HARDWARE( imesa ) \
+ do { \
+ char __ret=0; \
+ DRM_CAS(imesa->driHwLock, imesa->hHWContext, \
+ (DRM_LOCK_HELD|imesa->hHWContext), __ret); \
+ if (__ret) \
+ i810GetLock( imesa, 0 ); \
+ } while (0)
+
+
+
+/* Release the kernel lock.
+ */
+#define UNLOCK_HARDWARE(imesa) \
+ DRM_UNLOCK(imesa->driFd, imesa->driHwLock, imesa->hHWContext);
+
+
+/* This is the wrong way to do it, I'm sure. Otherwise the drm
+ * bitches that I've already got the heavyweight lock. At worst,
+ * this is 3 ioctls. The best solution probably only gets me down
+ * to 2 ioctls in the worst case.
+ */
+#define LOCK_HARDWARE_QUIESCENT( imesa ) do { \
+ LOCK_HARDWARE( imesa ); \
+ i810RegetLockQuiescent( imesa ); \
+} while(0)
+
+
+extern void i810GetLock( i810ContextPtr imesa, GLuint flags );
+extern void i810EmitHwStateLocked( i810ContextPtr imesa );
+extern void i810EmitScissorValues( i810ContextPtr imesa, int box_nr, int emit );
+extern void i810EmitDrawingRectangle( i810ContextPtr imesa );
+extern void i810XMesaSetBackClipRects( i810ContextPtr imesa );
+extern void i810XMesaSetFrontClipRects( i810ContextPtr imesa );
+
+#define SUBPIXEL_X -.5
+#define SUBPIXEL_Y -.5
+
+/* ================================================================
+ * Debugging:
+ */
+#define DO_DEBUG 1
+#if DO_DEBUG
+extern int I810_DEBUG;
+#else
+#define I810_DEBUG 0
+#endif
+
+#define DEBUG_TEXTURE 0x1
+#define DEBUG_STATE 0x2
+#define DEBUG_IOCTL 0x4
+#define DEBUG_PRIMS 0x8
+#define DEBUG_VERTS 0x10
+#define DEBUG_FALLBACKS 0x20
+#define DEBUG_VERBOSE 0x40
+#define DEBUG_DRI 0x80
+#define DEBUG_DMA 0x100
+#define DEBUG_SANITY 0x200
+#define DEBUG_SYNC 0x400
+#define DEBUG_SLEEP 0x800
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810ioctl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810ioctl.c
new file mode 100644
index 000000000..ba651555a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810ioctl.c
@@ -0,0 +1,511 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810ioctl.c,v 1.7 2002/10/30 12:51:33 alanh Exp $ */
+
+#include <unistd.h> /* for usleep() */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "dd.h"
+#include "swrast/swrast.h"
+#include "mm.h"
+
+#include "i810screen.h"
+#include "i810_dri.h"
+
+#include "i810context.h"
+#include "i810ioctl.h"
+#include "i810state.h"
+
+static drmBufPtr i810_get_buffer_ioctl( i810ContextPtr imesa )
+{
+ drmI810DMA dma;
+ drmBufPtr buf;
+ int retcode, i = 0;
+
+ while (1) {
+ retcode = drmCommandWriteRead(imesa->driFd, DRM_I810_GETBUF,
+ &dma, sizeof(drmI810DMA));
+
+ if (dma.granted == 1 && retcode == 0)
+ break;
+
+ if (++i > 1000) {
+ drmCommandNone(imesa->driFd, DRM_I810_FLUSH);
+ i = 0;
+ }
+ }
+
+ buf = &(imesa->i810Screen->bufs->list[dma.request_idx]);
+ buf->idx = dma.request_idx;
+ buf->used = 0;
+ buf->total = dma.request_size;
+ buf->address = (drmAddress)dma.virtual;
+
+ return buf;
+}
+
+
+
+#define DEPTH_SCALE ((1<<16)-1)
+
+static void i810Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+ const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
+ drmI810Clear clear;
+ unsigned int i;
+
+ clear.flags = 0;
+ clear.clear_color = imesa->ClearColor;
+ clear.clear_depth = (GLuint) (ctx->Depth.Clear * DEPTH_SCALE);
+
+ I810_FIREVERTICES( imesa );
+
+ if ((mask & BUFFER_BIT_FRONT_LEFT) && colorMask == ~0U) {
+ clear.flags |= I810_FRONT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
+ }
+
+ if ((mask & BUFFER_BIT_BACK_LEFT) && colorMask == ~0U) {
+ clear.flags |= I810_BACK;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
+ }
+
+ if (mask & BUFFER_BIT_DEPTH) {
+ if (ctx->Depth.Mask)
+ clear.flags |= I810_DEPTH;
+ mask &= ~BUFFER_BIT_DEPTH;
+ }
+
+ if (clear.flags) {
+ LOCK_HARDWARE( imesa );
+
+ /* flip top to bottom */
+ cy = dPriv->h-cy-ch;
+ cx += imesa->drawX;
+ cy += imesa->drawY;
+
+ for (i = 0 ; i < imesa->numClipRects ; )
+ {
+ unsigned int nr = MIN2(i + I810_NR_SAREA_CLIPRECTS, imesa->numClipRects);
+ drm_clip_rect_t *box = imesa->pClipRects;
+ drm_clip_rect_t *b = (drm_clip_rect_t *)imesa->sarea->boxes;
+ int n = 0;
+
+ if (!all) {
+ for ( ; i < nr ; i++) {
+ GLint x = box[i].x1;
+ GLint y = box[i].y1;
+ GLint w = box[i].x2 - x;
+ GLint h = box[i].y2 - y;
+
+ 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) continue;
+ if (h <= 0) continue;
+
+ b->x1 = x;
+ b->y1 = y;
+ b->x2 = x + w;
+ b->y2 = y + h;
+ b++;
+ n++;
+ }
+ } else {
+ for ( ; i < nr ; i++) {
+ *b++ = box[i];
+ n++;
+ }
+ }
+
+ imesa->sarea->nbox = n;
+ drmCommandWrite(imesa->driFd, DRM_I810_CLEAR,
+ &clear, sizeof(drmI810Clear));
+ }
+
+ UNLOCK_HARDWARE( imesa );
+ imesa->upload_cliprects = GL_TRUE;
+ }
+
+ if (mask)
+ _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
+}
+
+
+
+
+/*
+ * Copy the back buffer to the front buffer.
+ */
+void i810CopyBuffer( const __DRIdrawablePrivate *dPriv )
+{
+ i810ContextPtr imesa;
+ drm_clip_rect_t *pbox;
+ int nbox, i, tmp;
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ imesa = (i810ContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ I810_FIREVERTICES( imesa );
+ LOCK_HARDWARE( imesa );
+
+ pbox = (drm_clip_rect_t *)dPriv->pClipRects;
+ nbox = dPriv->numClipRects;
+
+ for (i = 0 ; i < nbox ; )
+ {
+ int nr = MIN2(i + I810_NR_SAREA_CLIPRECTS, dPriv->numClipRects);
+ drm_clip_rect_t *b = (drm_clip_rect_t *)imesa->sarea->boxes;
+
+ imesa->sarea->nbox = nr - i;
+
+ for ( ; i < nr ; i++)
+ *b++ = pbox[i];
+
+ drmCommandNone(imesa->driFd, DRM_I810_SWAP);
+ }
+
+ tmp = GET_ENQUEUE_AGE(imesa);
+ UNLOCK_HARDWARE( imesa );
+
+ /* multiarb will suck the life out of the server without this throttle:
+ */
+ if (GET_DISPATCH_AGE(imesa) < imesa->lastSwap) {
+ i810WaitAge(imesa, imesa->lastSwap);
+ }
+
+ imesa->lastSwap = tmp;
+ imesa->upload_cliprects = GL_TRUE;
+}
+
+
+/*
+ * XXX implement when full-screen extension is done.
+ */
+void i810PageFlip( const __DRIdrawablePrivate *dPriv )
+{
+ i810ContextPtr imesa;
+ int tmp, ret;
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ imesa = (i810ContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ I810_FIREVERTICES( imesa );
+ LOCK_HARDWARE( imesa );
+
+ if (dPriv->pClipRects) {
+ memcpy(&(imesa->sarea->boxes[0]), &(dPriv->pClipRects[0]),
+ sizeof(drm_clip_rect_t));
+ imesa->sarea->nbox = 1;
+ }
+ ret = drmCommandNone(imesa->driFd, DRM_I810_FLIP);
+ if (ret) {
+ fprintf(stderr, "%s: %d\n", __FUNCTION__, ret);
+ UNLOCK_HARDWARE( imesa );
+ exit(1);
+ }
+
+ tmp = GET_ENQUEUE_AGE(imesa);
+ UNLOCK_HARDWARE( imesa );
+
+ /* multiarb will suck the life out of the server without this throttle:
+ */
+ if (GET_DISPATCH_AGE(imesa) < imesa->lastSwap) {
+ i810WaitAge(imesa, imesa->lastSwap);
+ }
+
+ /* i810SetDrawBuffer( imesa->glCtx, imesa->glCtx->Color.DriverDrawBuffer );*/
+ i810DrawBuffer( imesa->glCtx, imesa->glCtx->Color.DrawBuffer[0] );
+ imesa->upload_cliprects = GL_TRUE;
+ imesa->lastSwap = tmp;
+ return;
+}
+
+
+/* This waits for *everybody* to finish rendering -- overkill.
+ */
+void i810DmaFinish( i810ContextPtr imesa )
+{
+ I810_FIREVERTICES( imesa );
+
+ LOCK_HARDWARE( imesa );
+ i810RegetLockQuiescent( imesa );
+ UNLOCK_HARDWARE( imesa );
+}
+
+
+void i810RegetLockQuiescent( i810ContextPtr imesa )
+{
+ drmUnlock(imesa->driFd, imesa->hHWContext);
+ i810GetLock( imesa, DRM_LOCK_QUIESCENT );
+}
+
+void i810WaitAgeLocked( i810ContextPtr imesa, int age )
+{
+ int i = 0, j;
+
+ while (++i < 5000) {
+ drmCommandNone(imesa->driFd, DRM_I810_GETAGE);
+ if (GET_DISPATCH_AGE(imesa) >= age)
+ return;
+ for (j = 0 ; j < 1000 ; j++)
+ ;
+ }
+
+ drmCommandNone(imesa->driFd, DRM_I810_FLUSH);
+}
+
+
+void i810WaitAge( i810ContextPtr imesa, int age )
+{
+ int i = 0, j;
+
+ while (++i < 5000) {
+ drmCommandNone(imesa->driFd, DRM_I810_GETAGE);
+ if (GET_DISPATCH_AGE(imesa) >= age)
+ return;
+ for (j = 0 ; j < 1000 ; j++)
+ ;
+ }
+
+ i = 0;
+ while (++i < 1000) {
+ drmCommandNone(imesa->driFd, DRM_I810_GETAGE);
+ if (GET_DISPATCH_AGE(imesa) >= age)
+ return;
+ usleep(1000);
+ }
+
+ LOCK_HARDWARE(imesa);
+ drmCommandNone(imesa->driFd, DRM_I810_FLUSH);
+ UNLOCK_HARDWARE(imesa);
+}
+
+
+
+
+static int intersect_rect( drm_clip_rect_t *out,
+ drm_clip_rect_t *a,
+ drm_clip_rect_t *b )
+{
+ *out = *a;
+ if (b->x1 > out->x1) out->x1 = b->x1;
+ if (b->x2 < out->x2) out->x2 = b->x2;
+ if (out->x1 >= out->x2) return 0;
+
+ if (b->y1 > out->y1) out->y1 = b->y1;
+ if (b->y2 < out->y2) out->y2 = b->y2;
+ if (out->y1 >= out->y2) return 0;
+ return 1;
+}
+
+
+static void emit_state( i810ContextPtr imesa )
+{
+ GLuint dirty = imesa->dirty;
+ I810SAREAPtr sarea = imesa->sarea;
+
+ if (dirty & I810_UPLOAD_BUFFERS) {
+ memcpy( sarea->BufferState, imesa->BufferSetup,
+ sizeof(imesa->BufferSetup) );
+ }
+
+ if (dirty & I810_UPLOAD_CTX) {
+ memcpy( sarea->ContextState, imesa->Setup,
+ sizeof(imesa->Setup) );
+ }
+
+ if (dirty & I810_UPLOAD_TEX0) {
+ memcpy(sarea->TexState[0],
+ imesa->CurrentTexObj[0]->Setup,
+ sizeof(imesa->CurrentTexObj[0]->Setup));
+ }
+
+ if (dirty & I810_UPLOAD_TEX1) {
+ GLuint *setup = sarea->TexState[1];
+
+ memcpy( setup,
+ imesa->CurrentTexObj[1]->Setup,
+ sizeof(imesa->CurrentTexObj[1]->Setup));
+
+ /* Need this for the case where both units are bound to the same
+ * texobj.
+ */
+ setup[I810_TEXREG_MI1] ^= (MI1_MAP_0 ^ MI1_MAP_1);
+ setup[I810_TEXREG_MLC] ^= (MLC_MAP_0 ^ MLC_MAP_1);
+ setup[I810_TEXREG_MLL] ^= (MLL_MAP_0 ^ MLL_MAP_1);
+ setup[I810_TEXREG_MCS] ^= (MCS_COORD_0 ^ MCS_COORD_1);
+ setup[I810_TEXREG_MF] ^= (MF_MAP_0 ^ MF_MAP_1);
+ }
+
+ sarea->dirty = dirty;
+ imesa->dirty = 0;
+}
+
+
+static void age_imesa( i810ContextPtr imesa, int age )
+{
+ if (imesa->CurrentTexObj[0]) imesa->CurrentTexObj[0]->base.timestamp = age;
+ if (imesa->CurrentTexObj[1]) imesa->CurrentTexObj[1]->base.timestamp = age;
+}
+
+
+void i810FlushPrimsLocked( i810ContextPtr imesa )
+{
+ drm_clip_rect_t *pbox = imesa->pClipRects;
+ int nbox = imesa->numClipRects;
+ drmBufPtr buffer = imesa->vertex_buffer;
+ I810SAREAPtr sarea = imesa->sarea;
+ drmI810Vertex vertex;
+ int i;
+
+ if (I810_DEBUG & DEBUG_STATE)
+ i810PrintDirty( __FUNCTION__, imesa->dirty );
+
+ if (imesa->dirty)
+ emit_state( imesa );
+
+ vertex.idx = buffer->idx;
+ vertex.used = imesa->vertex_low;
+ vertex.discard = 0;
+ sarea->vertex_prim = imesa->hw_primitive;
+
+ if (!nbox) {
+ vertex.used = 0;
+ }
+ else if (nbox > I810_NR_SAREA_CLIPRECTS) {
+ imesa->upload_cliprects = GL_TRUE;
+ }
+
+ if (!nbox || !imesa->upload_cliprects)
+ {
+ if (nbox == 1)
+ sarea->nbox = 0;
+ else
+ sarea->nbox = nbox;
+
+ vertex.discard = 1;
+ drmCommandWrite(imesa->driFd, DRM_I810_VERTEX,
+ &vertex, sizeof(drmI810Vertex));
+ age_imesa(imesa, sarea->last_enqueue);
+ }
+ else
+ {
+ for (i = 0 ; i < nbox ; )
+ {
+ int nr = MIN2(i + I810_NR_SAREA_CLIPRECTS, nbox);
+ drm_clip_rect_t *b = (drm_clip_rect_t *)sarea->boxes;
+
+ if (imesa->scissor) {
+ sarea->nbox = 0;
+
+ for ( ; i < nr ; i++) {
+ b->x1 = pbox[i].x1 - imesa->drawX;
+ b->y1 = pbox[i].y1 - imesa->drawY;
+ b->x2 = pbox[i].x2 - imesa->drawX;
+ b->y2 = pbox[i].y2 - imesa->drawY;
+
+ if (intersect_rect(b, b, &imesa->scissor_rect)) {
+ sarea->nbox++;
+ b++;
+ }
+ }
+
+ /* Culled?
+ */
+ if (!sarea->nbox) {
+ if (nr < nbox) continue;
+ vertex.used = 0;
+ }
+ } else {
+ sarea->nbox = nr - i;
+ for ( ; i < nr ; i++, b++) {
+ b->x1 = pbox[i].x1 - imesa->drawX;
+ b->y1 = pbox[i].y1 - imesa->drawY;
+ b->x2 = pbox[i].x2 - imesa->drawX;
+ b->y2 = pbox[i].y2 - imesa->drawY;
+ }
+ }
+
+ /* Finished with the buffer?
+ */
+ if (nr == nbox)
+ vertex.discard = 1;
+
+ drmCommandWrite(imesa->driFd, DRM_I810_VERTEX,
+ &vertex, sizeof(drmI810Vertex));
+ age_imesa(imesa, imesa->sarea->last_enqueue);
+ }
+ }
+
+ /* Reset imesa vars:
+ */
+ imesa->vertex_buffer = 0;
+ imesa->vertex_addr = 0;
+ imesa->vertex_low = 0;
+ imesa->vertex_high = 0;
+ imesa->vertex_last_prim = 0;
+ imesa->dirty = 0;
+ imesa->upload_cliprects = GL_FALSE;
+}
+
+void i810FlushPrimsGetBuffer( i810ContextPtr imesa )
+{
+ LOCK_HARDWARE(imesa);
+
+ if (imesa->vertex_buffer)
+ i810FlushPrimsLocked( imesa );
+
+ imesa->vertex_buffer = i810_get_buffer_ioctl( imesa );
+ imesa->vertex_high = imesa->vertex_buffer->total;
+ imesa->vertex_addr = (char *)imesa->vertex_buffer->address;
+ imesa->vertex_low = 4; /* leave room for instruction header */
+ imesa->vertex_last_prim = imesa->vertex_low;
+ UNLOCK_HARDWARE(imesa);
+}
+
+
+void i810FlushPrims( i810ContextPtr imesa )
+{
+ if (imesa->vertex_buffer) {
+ LOCK_HARDWARE( imesa );
+ i810FlushPrimsLocked( imesa );
+ UNLOCK_HARDWARE( imesa );
+ }
+}
+
+
+
+int i810_check_copy(int fd)
+{
+ return(drmCommandNone(fd, DRM_I810_DOCOPY));
+}
+
+static void i810Flush( GLcontext *ctx )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ I810_FIREVERTICES( imesa );
+}
+
+static void i810Finish( GLcontext *ctx )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ i810DmaFinish( imesa );
+}
+
+void i810InitIoctlFuncs( struct dd_function_table *functions )
+{
+ functions->Flush = i810Flush;
+ functions->Clear = i810Clear;
+ functions->Finish = i810Finish;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810ioctl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810ioctl.h
new file mode 100644
index 000000000..61399ee7b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810ioctl.h
@@ -0,0 +1,49 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810ioctl.h,v 1.7 2002/10/30 12:51:33 alanh Exp $ */
+
+#ifndef I810_IOCTL_H
+#define I810_IOCTL_H
+
+#include "i810context.h"
+
+void i810EmitPrim( i810ContextPtr imesa );
+void i810FlushPrims( i810ContextPtr mmesa );
+void i810FlushPrimsLocked( i810ContextPtr mmesa );
+void i810FlushPrimsGetBuffer( i810ContextPtr imesa );
+
+void i810WaitAgeLocked( i810ContextPtr imesa, int age );
+void i810WaitAge( i810ContextPtr imesa, int age );
+void i810DmaFinish( i810ContextPtr imesa );
+void i810RegetLockQuiescent( i810ContextPtr imesa );
+void i810InitIoctlFuncs( struct dd_function_table *functions );
+void i810CopyBuffer( const __DRIdrawablePrivate *dpriv );
+void i810PageFlip( const __DRIdrawablePrivate *dpriv );
+int i810_check_copy(int fd);
+
+#define I810_STATECHANGE(imesa, flag) \
+do { \
+ if (imesa->vertex_low != imesa->vertex_last_prim) \
+ i810FlushPrims(imesa); \
+ imesa->dirty |= flag; \
+} while (0) \
+
+
+#define I810_FIREVERTICES(imesa) \
+do { \
+ if (imesa->vertex_buffer) { \
+ i810FlushPrims(imesa); \
+ } \
+} while (0)
+
+static __inline GLuint *i810AllocDmaLow( i810ContextPtr imesa, int bytes )
+{
+ if (imesa->vertex_low + bytes > imesa->vertex_high)
+ i810FlushPrimsGetBuffer( imesa );
+
+ {
+ GLuint *start = (GLuint *)(imesa->vertex_addr + imesa->vertex_low);
+ imesa->vertex_low += bytes;
+ return start;
+ }
+}
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810render.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810render.c
new file mode 100644
index 000000000..a31d54236
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810render.c
@@ -0,0 +1,173 @@
+/*
+ * Intel i810 DRI driver for Mesa 3.5
+ *
+ * Copyright (C) 1999-2000 Keith Whitwell 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 KEITH WHITWELL 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * dma buffers. Use strip/fan hardware acceleration where possible.
+ *
+ */
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+
+#include "tnl/t_context.h"
+
+#include "i810screen.h"
+#include "i810_dri.h"
+
+#include "i810context.h"
+#include "i810tris.h"
+#include "i810state.h"
+#include "i810vb.h"
+#include "i810ioctl.h"
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * dma buffers. Use strip/fan hardware primitives where possible.
+ * Try to simulate missing primitives with indexed vertices.
+ */
+#define HAVE_POINTS 0
+#define HAVE_LINES 1
+#define HAVE_LINE_STRIPS 1
+#define HAVE_TRIANGLES 1
+#define HAVE_TRI_STRIPS 1
+#define HAVE_TRI_STRIP_1 0 /* has it, template can't use it yet */
+#define HAVE_TRI_FANS 1
+#define HAVE_POLYGONS 1
+#define HAVE_QUADS 0
+#define HAVE_QUAD_STRIPS 0
+
+#define HAVE_ELTS 0
+
+
+static GLuint hw_prim[GL_POLYGON+1] = {
+ 0,
+ PR_LINES,
+ 0,
+ PR_LINESTRIP,
+ PR_TRIANGLES,
+ PR_TRISTRIP_0,
+ PR_TRIFAN,
+ 0,
+ 0,
+ PR_POLYGON
+};
+
+static const GLenum reduced_prim[GL_POLYGON+1] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES
+};
+
+
+
+
+#define LOCAL_VARS i810ContextPtr imesa = I810_CONTEXT(ctx)
+#define INIT( prim ) do { \
+ I810_STATECHANGE(imesa, 0); \
+ i810RasterPrimitive( ctx, reduced_prim[prim], hw_prim[prim] ); \
+} while (0)
+#define GET_CURRENT_VB_MAX_VERTS() \
+ (((int)imesa->vertex_high - (int)imesa->vertex_low) / (imesa->vertex_size*4))
+#define GET_SUBSEQUENT_VB_MAX_VERTS() \
+ (I810_DMA_BUF_SZ-4) / (imesa->vertex_size * 4)
+
+#define ALLOC_VERTS( nr ) \
+ i810AllocDmaLow( imesa, (nr) * imesa->vertex_size * 4)
+#define EMIT_VERTS( ctx, j, nr, buf ) \
+ i810_emit_contiguous_verts(ctx, j, (j)+(nr), buf)
+
+#define FLUSH() I810_FIREVERTICES( imesa )
+
+
+#define TAG(x) i810_##x
+#include "tnl_dd/t_dd_dmatmp.h"
+
+
+/**********************************************************************/
+/* Render pipeline stage */
+/**********************************************************************/
+
+
+static GLboolean i810_run_render( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i;
+
+ /* Don't handle clipping or indexed vertices.
+ */
+ if (imesa->RenderIndex != 0 ||
+ !i810_validate_render( ctx, VB )) {
+ return GL_TRUE;
+ }
+
+ imesa->SetupNewInputs = VERT_BIT_POS;
+
+ tnl->Driver.Render.Start( ctx );
+
+ for (i = 0 ; i < VB->PrimitiveCount ; i++)
+ {
+ GLuint prim = VB->Primitive[i].mode;
+ GLuint start = VB->Primitive[i].start;
+ GLuint length = VB->Primitive[i].count;
+
+ if (!length)
+ continue;
+
+ i810_render_tab_verts[prim & PRIM_MODE_MASK]( ctx, start, start + length,
+ prim );
+ }
+
+ tnl->Driver.Render.Finish( ctx );
+
+ return GL_FALSE; /* finished the pipe */
+}
+
+
+
+const struct tnl_pipeline_stage _i810_render_stage =
+{
+ "i810 render",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ i810_run_render /* run */
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810screen.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810screen.c
new file mode 100644
index 000000000..991c7cb23
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810screen.c
@@ -0,0 +1,471 @@
+/**************************************************************************
+
+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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810screen.c,v 1.2 2002/10/30 12:51:33 alanh Exp $ */
+
+/*
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ *
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "framebuffer.h"
+#include "fbobject.h"
+#include "matrix.h"
+#include "renderbuffer.h"
+#include "simple_list.h"
+#include "utils.h"
+
+#include "i810screen.h"
+#include "i810_dri.h"
+
+#include "i810state.h"
+#include "i810tex.h"
+#include "i810span.h"
+#include "i810tris.h"
+#include "i810ioctl.h"
+
+#include "GL/internal/dri_interface.h"
+
+extern const struct dri_extension card_extensions[];
+
+static __GLcontextModes *fill_in_modes( __GLcontextModes *modes,
+ unsigned pixel_bits,
+ unsigned depth_bits,
+ unsigned stencil_bits,
+ const GLenum * db_modes,
+ unsigned num_db_modes,
+ int visType )
+{
+ static const u_int8_t bits[1][4] = {
+ { 5, 6, 5, 0 }
+ };
+
+ static const u_int32_t masks[1][4] = {
+ { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 }
+ };
+
+ unsigned i;
+ unsigned j;
+ const unsigned index = 0;
+
+ for ( i = 0 ; i < num_db_modes ; i++ ) {
+ for ( j = 0 ; j < 2 ; j++ ) {
+
+ modes->redBits = bits[index][0];
+ modes->greenBits = bits[index][1];
+ modes->blueBits = bits[index][2];
+ modes->alphaBits = bits[index][3];
+ modes->redMask = masks[index][0];
+ modes->greenMask = masks[index][1];
+ modes->blueMask = masks[index][2];
+ modes->alphaMask = masks[index][3];
+ modes->rgbBits = modes->redBits + modes->greenBits
+ + modes->blueBits + modes->alphaBits;
+
+ modes->accumRedBits = 16 * j;
+ modes->accumGreenBits = 16 * j;
+ modes->accumBlueBits = 16 * j;
+ modes->accumAlphaBits = (masks[index][3] != 0) ? 16 * j : 0;
+ modes->visualRating = (j == 0) ? GLX_NONE : GLX_SLOW_CONFIG;
+
+ modes->stencilBits = stencil_bits;
+ modes->depthBits = depth_bits;
+
+ modes->visualType = visType;
+ modes->renderType = GLX_RGBA_BIT;
+ modes->drawableType = GLX_WINDOW_BIT;
+ modes->rgbMode = GL_TRUE;
+
+ if ( db_modes[i] == GLX_NONE ) {
+ modes->doubleBufferMode = GL_FALSE;
+ }
+ else {
+ modes->doubleBufferMode = GL_TRUE;
+ modes->swapMethod = db_modes[i];
+ }
+
+ modes = modes->next;
+ }
+ }
+
+ return modes;
+
+}
+
+
+static __GLcontextModes *
+i810FillInModes( unsigned pixel_bits, unsigned depth_bits,
+ unsigned stencil_bits, GLboolean have_back_buffer )
+{ __GLcontextModes * modes;
+ __GLcontextModes * m;
+ unsigned num_modes;
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ unsigned i;
+
+ /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
+ * enough to add support. Basically, if a context is created with an
+ * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
+ * will never be used.
+ */
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
+ };
+
+ int depth_buffer_modes[2][2];
+
+
+ depth_buffer_modes[0][0] = depth_bits;
+ depth_buffer_modes[1][0] = depth_bits;
+
+ /* Just like with the accumulation buffer, always provide some modes
+ * with a stencil buffer. It will be a sw fallback, but some apps won't
+ * care about that.
+ */
+ depth_buffer_modes[0][1] = 0;
+ depth_buffer_modes[1][1] = (stencil_bits == 0) ? 8 : stencil_bits;
+
+ depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1;
+ back_buffer_factor = (have_back_buffer) ? 2 : 1;
+
+ num_modes = depth_buffer_factor * back_buffer_factor * 4;
+
+ modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
+ m = modes;
+ for ( i = 0 ; i < depth_buffer_factor ; i++ ) {
+ m = fill_in_modes( m, pixel_bits,
+ depth_buffer_modes[i][0], depth_buffer_modes[i][1],
+ back_buffer_modes, back_buffer_factor,
+ GLX_TRUE_COLOR );
+ }
+
+ for ( i = 0 ; i < depth_buffer_factor ; i++ ) {
+ m = fill_in_modes( m, pixel_bits,
+ depth_buffer_modes[i][0], depth_buffer_modes[i][1],
+ back_buffer_modes, back_buffer_factor,
+ GLX_DIRECT_COLOR );
+ }
+
+ /* Mark the visual as slow if there are "fake" stencil bits.
+ */
+ for ( m = modes ; m != NULL ; m = m->next ) {
+ if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) {
+ m->visualRating = GLX_SLOW_CONFIG;
+ }
+ }
+
+ return modes;
+
+}
+
+
+/* static int i810_malloc_proxy_buf(drmBufMapPtr buffers) */
+/* { */
+/* char *buffer; */
+/* drmBufPtr buf; */
+/* int i; */
+
+/* buffer = CALLOC(I810_DMA_BUF_SZ); */
+/* if(buffer == NULL) return -1; */
+/* for(i = 0; i < I810_DMA_BUF_NR; i++) { */
+/* buf = &(buffers->list[i]); */
+/* buf->address = (drmAddress)buffer; */
+/* } */
+/* return 0; */
+/* } */
+
+static drmBufMapPtr i810_create_empty_buffers(void)
+{
+ drmBufMapPtr retval;
+
+ retval = (drmBufMapPtr)ALIGN_MALLOC(sizeof(drmBufMap), 32);
+ if(retval == NULL) return NULL;
+ memset(retval, 0, sizeof(drmBufMap));
+ retval->list = (drmBufPtr)ALIGN_MALLOC(sizeof(drmBuf) * I810_DMA_BUF_NR, 32);
+ if(retval->list == NULL) {
+ ALIGN_FREE(retval);
+ return NULL;
+ }
+ memset(retval->list, 0, sizeof(drmBuf) * I810_DMA_BUF_NR);
+ return retval;
+}
+
+
+static GLboolean
+i810InitDriver(__DRIscreenPrivate *sPriv)
+{
+ i810ScreenPrivate *i810Screen;
+ I810DRIPtr gDRIPriv = (I810DRIPtr)sPriv->pDevPriv;
+
+ if (sPriv->devPrivSize != sizeof(I810DRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(I810DRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
+
+ /* Allocate the private area */
+ i810Screen = (i810ScreenPrivate *)CALLOC(sizeof(i810ScreenPrivate));
+ if (!i810Screen) {
+ __driUtilMessage("i810InitDriver: alloc i810ScreenPrivate struct failed");
+ return GL_FALSE;
+ }
+
+ i810Screen->driScrnPriv = sPriv;
+ sPriv->private = (void *)i810Screen;
+
+ i810Screen->deviceID=gDRIPriv->deviceID;
+ i810Screen->width=gDRIPriv->width;
+ i810Screen->height=gDRIPriv->height;
+ i810Screen->mem=gDRIPriv->mem;
+ i810Screen->cpp=gDRIPriv->cpp;
+ i810Screen->fbStride=gDRIPriv->fbStride;
+ i810Screen->fbOffset=gDRIPriv->fbOffset;
+
+ if (gDRIPriv->bitsPerPixel == 15)
+ i810Screen->fbFormat = DV_PF_555;
+ else
+ i810Screen->fbFormat = DV_PF_565;
+
+ i810Screen->backOffset=gDRIPriv->backOffset;
+ i810Screen->depthOffset=gDRIPriv->depthOffset;
+ i810Screen->backPitch = gDRIPriv->auxPitch;
+ i810Screen->backPitchBits = gDRIPriv->auxPitchBits;
+ i810Screen->textureOffset=gDRIPriv->textureOffset;
+ i810Screen->textureSize=gDRIPriv->textureSize;
+ i810Screen->logTextureGranularity = gDRIPriv->logTextureGranularity;
+
+ i810Screen->bufs = i810_create_empty_buffers();
+ if (i810Screen->bufs == NULL) {
+ __driUtilMessage("i810InitDriver: i810_create_empty_buffers() failed");
+ FREE(i810Screen);
+ return GL_FALSE;
+ }
+
+ i810Screen->back.handle = gDRIPriv->backbuffer;
+ i810Screen->back.size = gDRIPriv->backbufferSize;
+
+ if (drmMap(sPriv->fd,
+ i810Screen->back.handle,
+ i810Screen->back.size,
+ (drmAddress *)&i810Screen->back.map) != 0) {
+ FREE(i810Screen);
+ sPriv->private = NULL;
+ __driUtilMessage("i810InitDriver: drmMap failed");
+ return GL_FALSE;
+ }
+
+ 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) {
+ FREE(i810Screen);
+ drmUnmap(i810Screen->back.map, i810Screen->back.size);
+ sPriv->private = NULL;
+ __driUtilMessage("i810InitDriver: drmMap (2) failed");
+ 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) {
+ FREE(i810Screen);
+ drmUnmap(i810Screen->back.map, i810Screen->back.size);
+ drmUnmap(i810Screen->depth.map, i810Screen->depth.size);
+ sPriv->private = NULL;
+ __driUtilMessage("i810InitDriver: drmMap (3) failed");
+ return GL_FALSE;
+ }
+
+ i810Screen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
+
+ return GL_TRUE;
+}
+
+static void
+i810DestroyScreen(__DRIscreenPrivate *sPriv)
+{
+ i810ScreenPrivate *i810Screen = (i810ScreenPrivate *)sPriv->private;
+
+ /* 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);
+
+ FREE(i810Screen);
+ sPriv->private = NULL;
+}
+
+
+/**
+ * Create a buffer which corresponds to the window.
+ */
+static GLboolean
+i810CreateBuffer( __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ i810ScreenPrivate *screen = (i810ScreenPrivate *) driScrnPriv->private;
+
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+#if 0
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE /* s/w alpha planes */);
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ /*screen->frontOffset*/0, screen->backPitch);
+ i810SetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ i810SetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->backPitch);
+ i810SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+
+static void
+i810DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+
+static const struct __DriverAPIRec i810API = {
+ .InitDriver = i810InitDriver,
+ .DestroyScreen = i810DestroyScreen,
+ .CreateContext = i810CreateContext,
+ .DestroyContext = i810DestroyContext,
+ .CreateBuffer = i810CreateBuffer,
+ .DestroyBuffer = i810DestroyBuffer,
+ .SwapBuffers = i810SwapBuffers,
+ .MakeCurrent = i810MakeCurrent,
+ .UnbindContext = i810UnbindContext,
+ .GetSwapInfo = NULL,
+ .GetMSC = NULL,
+ .WaitForMSC = NULL,
+ .WaitForSBC = NULL,
+ .SwapBuffersMSC = NULL
+};
+
+
+/**
+ * This is the bootstrap function for the driver. libGL supplies all of the
+ * requisite information about the system, and the driver initializes itself.
+ * This routine also fills in the linked list pointed to by \c driver_modes
+ * with the \c __GLcontextModes that the driver can support for windows or
+ * pbuffers.
+ *
+ * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
+ * failure.
+ */
+PUBLIC
+void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
+ const __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drmAddress pSAREA, int fd,
+ int internal_api_version,
+ const __DRIinterfaceMethods * interface,
+ __GLcontextModes ** driver_modes )
+
+{
+ __DRIscreenPrivate *psp;
+ static const __DRIversion ddx_expected = { 1, 0, 0 };
+ static const __DRIversion dri_expected = { 4, 0, 0 };
+ static const __DRIversion drm_expected = { 1, 2, 0 };
+
+ dri_interface = interface;
+
+ if ( ! driCheckDriDdxDrmVersions2( "i810",
+ dri_version, & dri_expected,
+ ddx_version, & ddx_expected,
+ drm_version, & drm_expected ) ) {
+ return NULL;
+ }
+
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &i810API);
+ if ( psp != NULL ) {
+ *driver_modes = i810FillInModes( 16,
+ 16, 0,
+ 1);
+ driInitExtensions( NULL, card_extensions, GL_TRUE );
+ }
+
+ return (void *) psp;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810screen.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810screen.h
new file mode 100644
index 000000000..b29937665
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810screen.h
@@ -0,0 +1,99 @@
+/**************************************************************************
+
+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 <keith@tungstengraphics.com>
+ *
+ */
+
+#ifndef _I810_INIT_H_
+#define _I810_INIT_H_
+
+#include <sys/time.h>
+#include "dri_util.h"
+
+typedef struct {
+ drm_handle_t handle;
+ drmSize size;
+ char *map;
+} i810Region, *i810RegionPtr;
+
+typedef struct {
+ i810Region front;
+ i810Region back;
+ i810Region depth;
+ i810Region tex;
+
+ int deviceID;
+ int width;
+ int height;
+ int mem;
+
+ int cpp; /* for front and back buffers */
+ int bitsPerPixel;
+
+ int fbFormat;
+ int fbOffset;
+ int fbStride;
+
+ int backOffset;
+ int depthOffset;
+
+ int backPitch;
+ int backPitchBits;
+
+ int textureOffset;
+ int textureSize;
+ int logTextureGranularity;
+
+ __DRIscreenPrivate *driScrnPriv;
+ drmBufMapPtr bufs;
+ unsigned int sarea_priv_offset;
+} i810ScreenPrivate;
+
+
+extern GLboolean
+i810CreateContext( const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate );
+
+extern void
+i810DestroyContext(__DRIcontextPrivate *driContextPriv);
+
+extern GLboolean
+i810UnbindContext(__DRIcontextPrivate *driContextPriv);
+
+extern GLboolean
+i810MakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv);
+
+extern void
+i810SwapBuffers(__DRIdrawablePrivate *driDrawPriv);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810span.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810span.c
new file mode 100644
index 000000000..1a976048c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810span.c
@@ -0,0 +1,201 @@
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "colormac.h"
+
+#include "i810screen.h"
+#include "i810_dri.h"
+
+#include "i810span.h"
+#include "i810ioctl.h"
+#include "swrast/swrast.h"
+
+
+#define DBG 0
+
+#define LOCAL_VARS \
+ i810ContextPtr imesa = I810_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable; \
+ i810ScreenPrivate *i810Screen = imesa->i810Screen; \
+ GLuint pitch = i810Screen->backPitch; \
+ GLuint height = dPriv->h; \
+ GLushort p; \
+ char *buf = (char *)(imesa->drawMap + \
+ dPriv->x * 2 + \
+ dPriv->y * pitch); \
+ char *read_buf = (char *)(imesa->readMap + \
+ dPriv->x * 2 + \
+ dPriv->y * pitch); \
+ (void) read_buf; (void) buf; (void) p
+
+#define LOCAL_DEPTH_VARS \
+ i810ContextPtr imesa = I810_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable; \
+ i810ScreenPrivate *i810Screen = imesa->i810Screen; \
+ GLuint pitch = i810Screen->backPitch; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(i810Screen->depth.map + \
+ dPriv->x * 2 + \
+ dPriv->y * pitch)
+
+#define INIT_MONO_PIXEL(p, color) \
+ p = PACK_COLOR_565( color[0], color[1], color[2] )
+
+#define Y_FLIP(_y) (height - _y - 1)
+
+#define HW_LOCK()
+
+#define HW_UNLOCK()
+
+/* 16 bit, 565 rgb 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) * 255 / 0xf8; \
+ rgba[1] = ((p >> 3) & 0xfc) * 255 / 0xfc; \
+ rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8; \
+ rgba[3] = 255; \
+} while(0)
+
+#define TAG(x) i810##x##_565
+#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) i810##x##_16
+#include "depthtmp.h"
+
+
+/*
+ * This function is called to specify which buffer to read and write
+ * for software rasterization (swrast) fallbacks. This doesn't necessarily
+ * correspond to glDrawBuffer() or glReadBuffer() calls.
+ */
+static void i810SetBuffer(GLcontext *ctx, GLframebuffer *buffer,
+ GLuint bufferBit )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ (void) buffer;
+
+ switch(bufferBit) {
+ case BUFFER_BIT_FRONT_LEFT:
+ if ( imesa->sarea->pf_current_page == 1)
+ imesa->readMap = imesa->i810Screen->back.map;
+ else
+ imesa->readMap = (char*)imesa->driScreen->pFB;
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ if ( imesa->sarea->pf_current_page == 1)
+ imesa->readMap = (char*)imesa->driScreen->pFB;
+ else
+ imesa->readMap = imesa->i810Screen->back.map;
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+ imesa->drawMap = imesa->readMap;
+}
+
+/* Move locking out to get reasonable span performance.
+ */
+void i810SpanRenderStart( GLcontext *ctx )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ I810_FIREVERTICES(imesa);
+ LOCK_HARDWARE(imesa);
+ i810RegetLockQuiescent( imesa );
+}
+
+void i810SpanRenderFinish( GLcontext *ctx )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ _swrast_flush( ctx );
+ UNLOCK_HARDWARE( imesa );
+}
+
+void i810InitSpanFuncs( GLcontext *ctx )
+{
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetBuffer = i810SetBuffer;
+
+#if 0
+ swdd->WriteRGBASpan = i810WriteRGBASpan_565;
+ swdd->WriteRGBSpan = i810WriteRGBSpan_565;
+ swdd->WriteMonoRGBASpan = i810WriteMonoRGBASpan_565;
+ swdd->WriteRGBAPixels = i810WriteRGBAPixels_565;
+ swdd->WriteMonoRGBAPixels = i810WriteMonoRGBAPixels_565;
+ swdd->ReadRGBASpan = i810ReadRGBASpan_565;
+ swdd->ReadRGBAPixels = i810ReadRGBAPixels_565;
+#endif
+
+#if 0
+ swdd->ReadDepthSpan = i810ReadDepthSpan_16;
+ swdd->WriteDepthSpan = i810WriteDepthSpan_16;
+ swdd->ReadDepthPixels = i810ReadDepthPixels_16;
+ swdd->WriteDepthPixels = i810WriteDepthPixels_16;
+#endif
+
+ swdd->SpanRenderStart = i810SpanRenderStart;
+ swdd->SpanRenderFinish = i810SpanRenderFinish;
+}
+
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+i810SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ /* always 565 RGB */
+ drb->Base.GetRow = i810ReadRGBASpan_565;
+ drb->Base.GetValues = i810ReadRGBAPixels_565;
+ drb->Base.PutRow = i810WriteRGBASpan_565;
+ drb->Base.PutRowRGB = i810WriteRGBSpan_565;
+ drb->Base.PutMonoRow = i810WriteMonoRGBASpan_565;
+ drb->Base.PutValues = i810WriteRGBAPixels_565;
+ drb->Base.PutMonoValues = i810WriteMonoRGBAPixels_565;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = i810ReadDepthSpan_16;
+ drb->Base.GetValues = i810ReadDepthPixels_16;
+ drb->Base.PutRow = i810WriteDepthSpan_16;
+ drb->Base.PutMonoRow = i810WriteMonoDepthSpan_16;
+ drb->Base.PutValues = i810WriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ /* should never get here */
+ drb->Base.GetRow = NULL;
+ drb->Base.GetValues = NULL;
+ drb->Base.PutRow = NULL;
+ drb->Base.PutMonoRow = NULL;
+ drb->Base.PutValues = NULL;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = NULL;
+ drb->Base.GetValues = NULL;
+ drb->Base.PutRow = NULL;
+ drb->Base.PutMonoRow = NULL;
+ drb->Base.PutValues = NULL;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810span.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810span.h
new file mode 100644
index 000000000..9aed253bd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810span.h
@@ -0,0 +1,14 @@
+#ifndef _I810_SPAN_H
+#define _I810_SPAN_H
+
+#include "drirenderbuffer.h"
+
+extern void i810InitSpanFuncs( GLcontext *ctx );
+
+extern void i810SpanRenderFinish( GLcontext *ctx );
+extern void i810SpanRenderStart( GLcontext *ctx );
+
+extern void
+i810SetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810state.c
new file mode 100644
index 000000000..62dc819b3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810state.c
@@ -0,0 +1,1025 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810state.c,v 1.9 2002/10/30 12:51:33 alanh Exp $ */
+
+#include <stdio.h>
+
+#include "glheader.h"
+#include "buffers.h"
+#include "context.h"
+#include "macros.h"
+#include "enums.h"
+#include "dd.h"
+#include "colormac.h"
+
+#include "texmem.h"
+
+#include "i810screen.h"
+#include "i810_dri.h"
+
+#include "i810context.h"
+#include "i810state.h"
+#include "i810tex.h"
+#include "i810vb.h"
+#include "i810tris.h"
+#include "i810ioctl.h"
+
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "tnl/t_pipeline.h"
+
+static __inline__ GLuint i810PackColor(GLuint format,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a)
+{
+
+ if (I810_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ switch (format) {
+ case DV_PF_555:
+ return PACK_COLOR_1555( a, r, g, b );
+ case DV_PF_565:
+ return PACK_COLOR_565( r, g, b );
+ default:
+ fprintf(stderr, "unknown format %d\n", (int)format);
+ return 0;
+ }
+}
+
+
+static void i810AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ GLuint a = (ZA_UPDATE_ALPHAFUNC|ZA_UPDATE_ALPHAREF);
+ GLubyte refByte;
+
+ CLAMPED_FLOAT_TO_UBYTE(refByte, ref);
+
+ switch (ctx->Color.AlphaFunc) {
+ case GL_NEVER: a |= ZA_ALPHA_NEVER; break;
+ case GL_LESS: a |= ZA_ALPHA_LESS; break;
+ case GL_GEQUAL: a |= ZA_ALPHA_GEQUAL; break;
+ case GL_LEQUAL: a |= ZA_ALPHA_LEQUAL; break;
+ case GL_GREATER: a |= ZA_ALPHA_GREATER; break;
+ case GL_NOTEQUAL: a |= ZA_ALPHA_NOTEQUAL; break;
+ case GL_EQUAL: a |= ZA_ALPHA_EQUAL; break;
+ case GL_ALWAYS: a |= ZA_ALPHA_ALWAYS; break;
+ default: return;
+ }
+
+ a |= ((refByte & 0xfc) << ZA_ALPHAREF_SHIFT);
+
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_ZA] &= ~(ZA_ALPHA_MASK|ZA_ALPHAREF_MASK);
+ imesa->Setup[I810_CTXREG_ZA] |= a;
+}
+
+static void i810BlendEquationSeparate(GLcontext *ctx,
+ GLenum modeRGB, GLenum modeA)
+{
+ assert( modeRGB == modeA );
+
+ /* Can only do GL_ADD equation in hardware */
+ FALLBACK( I810_CONTEXT(ctx), I810_FALLBACK_BLEND_EQ,
+ modeRGB != GL_FUNC_ADD);
+
+ /* BlendEquation sets ColorLogicOpEnabled in an unexpected
+ * manner.
+ */
+ FALLBACK( I810_CONTEXT(ctx), I810_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
+}
+
+static void i810BlendFuncSeparate( GLcontext *ctx, GLenum sfactorRGB,
+ GLenum dfactorRGB, GLenum sfactorA,
+ GLenum dfactorA )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ GLuint a = SDM_UPDATE_SRC_BLEND | SDM_UPDATE_DST_BLEND;
+ GLboolean fallback = GL_FALSE;
+
+ switch (ctx->Color.BlendSrcRGB) {
+ case GL_ZERO: a |= SDM_SRC_ZERO; break;
+ case GL_ONE: a |= SDM_SRC_ONE; break;
+ case GL_SRC_COLOR: a |= SDM_SRC_SRC_COLOR; break;
+ case GL_ONE_MINUS_SRC_COLOR: a |= SDM_SRC_INV_SRC_COLOR; break;
+ case GL_SRC_ALPHA: a |= SDM_SRC_SRC_ALPHA; break;
+ case GL_ONE_MINUS_SRC_ALPHA: a |= SDM_SRC_INV_SRC_ALPHA; break;
+ case GL_DST_ALPHA: a |= SDM_SRC_ONE; break;
+ case GL_ONE_MINUS_DST_ALPHA: a |= SDM_SRC_ZERO; break;
+ case GL_DST_COLOR: a |= SDM_SRC_DST_COLOR; break;
+ case GL_ONE_MINUS_DST_COLOR: a |= SDM_SRC_INV_DST_COLOR; break;
+
+ /* (f, f, f, 1), f = min(As, 1 - Ad) = min(As, 1 - 1) = 0
+ * So (f, f, f, 1) = (0, 0, 0, 1). Since there is no destination alpha and
+ * the only supported alpha operation is GL_FUNC_ADD, the result modulating
+ * the source alpha with the alpha factor is largely irrelevant.
+ */
+ case GL_SRC_ALPHA_SATURATE: a |= SDM_SRC_ZERO; break;
+
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ fallback = GL_TRUE;
+ break;
+ default:
+ return;
+ }
+
+ switch (ctx->Color.BlendDstRGB) {
+ case GL_ZERO: a |= SDM_DST_ZERO; break;
+ case GL_ONE: a |= SDM_DST_ONE; break;
+ case GL_SRC_COLOR: a |= SDM_DST_SRC_COLOR; break;
+ case GL_ONE_MINUS_SRC_COLOR: a |= SDM_DST_INV_SRC_COLOR; break;
+ case GL_SRC_ALPHA: a |= SDM_DST_SRC_ALPHA; break;
+ case GL_ONE_MINUS_SRC_ALPHA: a |= SDM_DST_INV_SRC_ALPHA; break;
+ case GL_DST_ALPHA: a |= SDM_DST_ONE; break;
+ case GL_ONE_MINUS_DST_ALPHA: a |= SDM_DST_ZERO; break;
+ case GL_DST_COLOR: a |= SDM_DST_DST_COLOR; break;
+ case GL_ONE_MINUS_DST_COLOR: a |= SDM_DST_INV_DST_COLOR; break;
+
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ fallback = GL_TRUE;
+ break;
+ default:
+ return;
+ }
+
+ FALLBACK( imesa, I810_FALLBACK_BLEND_FUNC, fallback);
+ if (!fallback) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_SDM] &= ~(SDM_SRC_MASK|SDM_DST_MASK);
+ imesa->Setup[I810_CTXREG_SDM] |= a;
+ }
+}
+
+
+
+static void i810DepthFunc(GLcontext *ctx, GLenum func)
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ int zmode;
+
+ switch(func) {
+ case GL_NEVER: zmode = LCS_Z_NEVER; break;
+ case GL_ALWAYS: zmode = LCS_Z_ALWAYS; break;
+ case GL_LESS: zmode = LCS_Z_LESS; break;
+ case GL_LEQUAL: zmode = LCS_Z_LEQUAL; break;
+ case GL_EQUAL: zmode = LCS_Z_EQUAL; break;
+ case GL_GREATER: zmode = LCS_Z_GREATER; break;
+ case GL_GEQUAL: zmode = LCS_Z_GEQUAL; break;
+ case GL_NOTEQUAL: zmode = LCS_Z_NOTEQUAL; break;
+ default: return;
+ }
+
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_LCS] &= ~LCS_Z_MASK;
+ imesa->Setup[I810_CTXREG_LCS] |= zmode;
+}
+
+static void i810DepthMask(GLcontext *ctx, GLboolean flag)
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+
+ if (flag)
+ imesa->Setup[I810_CTXREG_B2] |= B2_ZB_WRITE_ENABLE;
+ else
+ imesa->Setup[I810_CTXREG_B2] &= ~B2_ZB_WRITE_ENABLE;
+}
+
+
+/* =============================================================
+ * Polygon stipple
+ *
+ * The i810 supports a 4x4 stipple natively, GL wants 32x32.
+ * Fortunately stipple is usually a repeating pattern.
+ */
+static void i810PolygonStipple( GLcontext *ctx, const GLubyte *mask )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ const GLubyte *m = mask;
+ GLubyte p[4];
+ int i,j,k;
+ int active = (ctx->Polygon.StippleFlag &&
+ imesa->reduced_primitive == GL_TRIANGLES);
+ GLuint newMask;
+
+ if (active) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_ST1] &= ~ST1_ENABLE;
+ }
+
+ p[0] = mask[12] & 0xf; p[0] |= p[0] << 4;
+ p[1] = mask[8] & 0xf; p[1] |= p[1] << 4;
+ p[2] = mask[4] & 0xf; p[2] |= p[2] << 4;
+ p[3] = mask[0] & 0xf; p[3] |= p[3] << 4;
+
+ for (k = 0 ; k < 8 ; k++)
+ for (j = 0 ; j < 4; j++)
+ for (i = 0 ; i < 4 ; i++)
+ if (*m++ != p[j]) {
+ imesa->stipple_in_hw = 0;
+ return;
+ }
+
+ newMask = ((p[0] & 0xf) << 0) |
+ ((p[1] & 0xf) << 4) |
+ ((p[2] & 0xf) << 8) |
+ ((p[3] & 0xf) << 12);
+
+ if (newMask == 0xffff) {
+ /* this is needed to make conform pass */
+ imesa->stipple_in_hw = 0;
+ return;
+ }
+
+ imesa->Setup[I810_CTXREG_ST1] &= ~0xffff;
+ imesa->Setup[I810_CTXREG_ST1] |= newMask;
+ imesa->stipple_in_hw = 1;
+
+ if (active)
+ imesa->Setup[I810_CTXREG_ST1] |= ST1_ENABLE;
+}
+
+
+
+/* =============================================================
+ * Hardware clipping
+ */
+
+
+static void i810Scissor( GLcontext *ctx, GLint x, GLint y,
+ GLsizei w, GLsizei h )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+
+ if (ctx->Scissor.Enabled) {
+ I810_FIREVERTICES(imesa); /* don't pipeline cliprect changes */
+ imesa->upload_cliprects = GL_TRUE;
+ }
+
+ imesa->scissor_rect.x1 = x;
+ imesa->scissor_rect.y1 = imesa->driDrawable->h - (y + h);
+ imesa->scissor_rect.x2 = x + w;
+ imesa->scissor_rect.y2 = imesa->driDrawable->h - y;
+}
+
+
+static void i810LogicOp( GLcontext *ctx, GLenum opcode )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ FALLBACK( imesa, I810_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled && opcode != GL_COPY) );
+}
+
+/* Fallback to swrast for select and feedback.
+ */
+static void i810RenderMode( GLcontext *ctx, GLenum mode )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ FALLBACK( imesa, I810_FALLBACK_RENDERMODE, (mode != GL_RENDER) );
+}
+
+
+void i810DrawBuffer(GLcontext *ctx, GLenum mode )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ int front = 0;
+
+ /*
+ * _DrawDestMask is easier to cope with than <mode>.
+ */
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0]) {
+ case BUFFER_BIT_FRONT_LEFT:
+ front = 1;
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ front = 0;
+ break;
+ default:
+ /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
+ FALLBACK( imesa, I810_FALLBACK_DRAW_BUFFER, GL_TRUE );
+ return;
+ }
+
+ if ( imesa->sarea->pf_current_page == 1 )
+ front ^= 1;
+
+ FALLBACK( imesa, I810_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ I810_FIREVERTICES(imesa);
+ I810_STATECHANGE(imesa, I810_UPLOAD_BUFFERS);
+
+ if (front)
+ {
+ imesa->BufferSetup[I810_DESTREG_DI1] = (imesa->i810Screen->fbOffset |
+ imesa->i810Screen->backPitchBits);
+ i810XMesaSetFrontClipRects( imesa );
+ }
+ else
+ {
+ imesa->BufferSetup[I810_DESTREG_DI1] = (imesa->i810Screen->backOffset |
+ imesa->i810Screen->backPitchBits);
+ i810XMesaSetBackClipRects( imesa );
+ }
+
+ /* We want to update the s/w rast state too so that r200SetBuffer()
+ * gets called.
+ */
+ _swrast_DrawBuffer(ctx, mode);
+}
+
+
+static void i810ReadBuffer(GLcontext *ctx, GLenum mode )
+{
+ /* XXX anything? */
+}
+
+
+static void i810ClearColor(GLcontext *ctx, const GLfloat color[4] )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ GLubyte c[4];
+ CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
+ imesa->ClearColor = i810PackColor( imesa->i810Screen->fbFormat,
+ c[0], c[1], c[2], c[3] );
+}
+
+
+/* =============================================================
+ * Culling - the i810 isn't quite as clean here as the rest of
+ * its interfaces, but it's not bad.
+ */
+static void i810CullFaceFrontFace(GLcontext *ctx, GLenum unused)
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ GLuint mode = LCS_CULL_BOTH;
+
+ if (ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK) {
+ mode = LCS_CULL_CW;
+ if (ctx->Polygon.CullFaceMode == GL_FRONT)
+ mode ^= (LCS_CULL_CW ^ LCS_CULL_CCW);
+ if (ctx->Polygon.FrontFace != GL_CCW)
+ mode ^= (LCS_CULL_CW ^ LCS_CULL_CCW);
+ }
+
+ imesa->LcsCullMode = mode;
+
+ if (ctx->Polygon.CullFlag)
+ {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_LCS] &= ~LCS_CULL_MASK;
+ imesa->Setup[I810_CTXREG_LCS] |= mode;
+ }
+}
+
+
+static void i810LineWidth( GLcontext *ctx, GLfloat widthf )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ int width = (int)ctx->Line._Width;
+
+ imesa->LcsLineWidth = 0;
+ if (width & 1) imesa->LcsLineWidth |= LCS_LINEWIDTH_1_0;
+ if (width & 2) imesa->LcsLineWidth |= LCS_LINEWIDTH_2_0;
+
+ if (imesa->reduced_primitive == GL_LINES) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_LCS] &= ~LCS_LINEWIDTH_3_0;
+ imesa->Setup[I810_CTXREG_LCS] |= imesa->LcsLineWidth;
+ }
+}
+
+static void i810PointSize( GLcontext *ctx, GLfloat sz )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ int size = (int)ctx->Point._Size;
+
+ imesa->LcsPointSize = 0;
+ if (size & 1) imesa->LcsPointSize |= LCS_LINEWIDTH_1_0;
+ if (size & 2) imesa->LcsPointSize |= LCS_LINEWIDTH_2_0;
+
+ if (imesa->reduced_primitive == GL_POINTS) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_LCS] &= ~LCS_LINEWIDTH_3_0;
+ imesa->Setup[I810_CTXREG_LCS] |= imesa->LcsPointSize;
+ }
+}
+
+/* =============================================================
+ * Color masks
+ */
+
+static void i810ColorMask(GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ GLuint tmp = 0;
+
+ if (r && g && b) {
+ tmp = imesa->Setup[I810_CTXREG_B2] | B2_FB_WRITE_ENABLE;
+ FALLBACK( imesa, I810_FALLBACK_COLORMASK, GL_FALSE );
+ } else if (!r && !g && !b) {
+ tmp = imesa->Setup[I810_CTXREG_B2] & ~B2_FB_WRITE_ENABLE;
+ FALLBACK( imesa, I810_FALLBACK_COLORMASK, GL_FALSE );
+ } else {
+ FALLBACK( imesa, I810_FALLBACK_COLORMASK, GL_TRUE );
+ return;
+ }
+
+ if (tmp != imesa->Setup[I810_CTXREG_B2]) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_B2] = tmp;
+ imesa->dirty |= I810_UPLOAD_CTX;
+ }
+}
+
+/* Seperate specular not fully implemented on the i810.
+ */
+static void i810LightModelfv(GLcontext *ctx, GLenum pname,
+ const GLfloat *param)
+{
+ if (pname == GL_LIGHT_MODEL_COLOR_CONTROL)
+ {
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ FALLBACK( imesa, I810_FALLBACK_SPECULAR,
+ (ctx->Light.Enabled &&
+ ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR));
+ }
+}
+
+/* But the 815 has it...
+ */
+static void i810LightModelfv_i815(GLcontext *ctx, GLenum pname,
+ const GLfloat *param)
+{
+ if (pname == GL_LIGHT_MODEL_COLOR_CONTROL)
+ {
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
+ imesa->Setup[I810_CTXREG_B1] |= B1_SPEC_ENABLE;
+ else
+ imesa->Setup[I810_CTXREG_B1] &= ~B1_SPEC_ENABLE;
+ }
+}
+
+/* In Mesa 3.5 we can reliably do native flatshading.
+ */
+static void i810ShadeModel(GLcontext *ctx, GLenum mode)
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ if (mode == GL_FLAT)
+ imesa->Setup[I810_CTXREG_LCS] |= LCS_INTERP_FLAT;
+ else
+ imesa->Setup[I810_CTXREG_LCS] &= ~LCS_INTERP_FLAT;
+}
+
+
+
+/* =============================================================
+ * Fog
+ */
+static void i810Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+
+ if (pname == GL_FOG_COLOR) {
+ GLuint color = (((GLubyte)(ctx->Fog.Color[0]*255.0F) << 16) |
+ ((GLubyte)(ctx->Fog.Color[1]*255.0F) << 8) |
+ ((GLubyte)(ctx->Fog.Color[2]*255.0F) << 0));
+
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_FOG] = ((GFX_OP_FOG_COLOR | color) &
+ ~FOG_RESERVED_MASK);
+ }
+}
+
+
+/* =============================================================
+ */
+static void i810Enable(GLcontext *ctx, GLenum cap, GLboolean state)
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+
+ switch(cap) {
+ case GL_ALPHA_TEST:
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_B1] &= ~B1_ALPHA_TEST_ENABLE;
+ if (state)
+ imesa->Setup[I810_CTXREG_B1] |= B1_ALPHA_TEST_ENABLE;
+ break;
+ case GL_BLEND:
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_B1] &= ~B1_BLEND_ENABLE;
+ if (state)
+ imesa->Setup[I810_CTXREG_B1] |= B1_BLEND_ENABLE;
+
+ /* For some reason enable(GL_BLEND) affects ColorLogicOpEnabled.
+ */
+ FALLBACK( imesa, I810_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
+ break;
+ case GL_DEPTH_TEST:
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_B1] &= ~B1_Z_TEST_ENABLE;
+ if (state)
+ imesa->Setup[I810_CTXREG_B1] |= B1_Z_TEST_ENABLE;
+ break;
+ case GL_SCISSOR_TEST:
+ /* XXX without these next two lines, conform's scissor test fails */
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ I810_STATECHANGE(imesa, I810_UPLOAD_BUFFERS);
+ I810_FIREVERTICES(imesa); /* don't pipeline cliprect changes */
+ imesa->upload_cliprects = GL_TRUE;
+ imesa->scissor = state;
+ break;
+ case GL_POLYGON_STIPPLE:
+ if (imesa->stipple_in_hw && imesa->reduced_primitive == GL_TRIANGLES)
+ {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_ST1] &= ~ST1_ENABLE;
+ if (state)
+ imesa->Setup[I810_CTXREG_ST1] |= ST1_ENABLE;
+ }
+ break;
+ case GL_LINE_SMOOTH:
+ /* Need to fatten the lines by .5, or they disappear...
+ */
+ if (imesa->reduced_primitive == GL_LINES) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_AA] &= ~AA_ENABLE;
+ imesa->Setup[I810_CTXREG_LCS] &= ~LCS_LINEWIDTH_0_5;
+ if (state) {
+ imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE;
+ imesa->Setup[I810_CTXREG_LCS] |= LCS_LINEWIDTH_0_5;
+ }
+ }
+ break;
+ case GL_POINT_SMOOTH:
+ if (imesa->reduced_primitive == GL_POINTS) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_AA] &= ~AA_ENABLE;
+ imesa->Setup[I810_CTXREG_LCS] &= ~LCS_LINEWIDTH_0_5;
+ if (state) {
+ imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE;
+ imesa->Setup[I810_CTXREG_LCS] |= LCS_LINEWIDTH_0_5;
+ }
+ }
+ break;
+ case GL_POLYGON_SMOOTH:
+ if (imesa->reduced_primitive == GL_TRIANGLES) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_AA] &= ~AA_ENABLE;
+ if (state)
+ imesa->Setup[I810_CTXREG_AA] |= AA_ENABLE;
+ }
+ break;
+ case GL_FOG:
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_B1] &= ~B1_FOG_ENABLE;
+ if (state)
+ imesa->Setup[I810_CTXREG_B1] |= B1_FOG_ENABLE;
+ break;
+ case GL_CULL_FACE:
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_LCS] &= ~LCS_CULL_MASK;
+ if (state)
+ imesa->Setup[I810_CTXREG_LCS] |= imesa->LcsCullMode;
+ else
+ imesa->Setup[I810_CTXREG_LCS] |= LCS_CULL_DISABLE;
+ break;
+ case GL_TEXTURE_2D:
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ if (ctx->Texture.CurrentUnit == 0) {
+ imesa->Setup[I810_CTXREG_MT] &= ~MT_TEXEL0_ENABLE;
+ if (state)
+ imesa->Setup[I810_CTXREG_MT] |= MT_TEXEL0_ENABLE;
+ } else {
+ imesa->Setup[I810_CTXREG_MT] &= ~MT_TEXEL1_ENABLE;
+ if (state)
+ imesa->Setup[I810_CTXREG_MT] |= MT_TEXEL1_ENABLE;
+ }
+ break;
+ case GL_COLOR_LOGIC_OP:
+ FALLBACK( imesa, I810_FALLBACK_LOGICOP,
+ (state && ctx->Color.LogicOp != GL_COPY));
+ break;
+ case GL_STENCIL_TEST:
+ FALLBACK( imesa, I810_FALLBACK_STENCIL, state );
+ break;
+ default:
+ ;
+ }
+}
+
+
+
+
+
+
+
+/* =============================================================
+ */
+
+
+
+
+void i810EmitDrawingRectangle( i810ContextPtr imesa )
+{
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+ i810ScreenPrivate *i810Screen = imesa->i810Screen;
+ int x0 = imesa->drawX;
+ int y0 = imesa->drawY;
+ int x1 = x0 + dPriv->w;
+ int y1 = y0 + dPriv->h;
+ GLuint dr2, dr3, dr4;
+
+
+ /* Coordinate origin of the window - may be offscreen.
+ */
+ dr4 = imesa->BufferSetup[I810_DESTREG_DR4] = ((y0<<16) |
+ (((unsigned)x0)&0xFFFF));
+
+ /* Clip to screen.
+ */
+ if (x0 < 0) x0 = 0;
+ if (y0 < 0) y0 = 0;
+ if (x1 > i810Screen->width-1) x1 = i810Screen->width-1;
+ if (y1 > i810Screen->height-1) y1 = i810Screen->height-1;
+
+
+ /* Onscreen drawing rectangle.
+ */
+ dr2 = imesa->BufferSetup[I810_DESTREG_DR2] = ((y0<<16) | x0);
+ dr3 = imesa->BufferSetup[I810_DESTREG_DR3] = (((y1+1)<<16) | (x1+1));
+
+
+ imesa->dirty |= I810_UPLOAD_BUFFERS;
+}
+
+
+
+static void i810CalcViewport( GLcontext *ctx )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat *m = imesa->ViewportMatrix.m;
+
+ /* See also i810_translate_vertex. SUBPIXEL adjustments can be done
+ * via state vars, too.
+ */
+ m[MAT_SX] = v[MAT_SX];
+ m[MAT_TX] = v[MAT_TX] + SUBPIXEL_X;
+ m[MAT_SY] = - v[MAT_SY];
+ m[MAT_TY] = - v[MAT_TY] + imesa->driDrawable->h + SUBPIXEL_Y;
+ m[MAT_SZ] = v[MAT_SZ] * (1.0 / 0xffff);
+ m[MAT_TZ] = v[MAT_TZ] * (1.0 / 0xffff);
+}
+
+static void i810Viewport( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
+ i810CalcViewport( ctx );
+}
+
+static void i810DepthRange( GLcontext *ctx,
+ GLclampd nearval, GLclampd farval )
+{
+ i810CalcViewport( ctx );
+}
+
+
+
+void i810PrintDirty( const char *msg, GLuint state )
+{
+ fprintf(stderr, "%s (0x%x): %s%s%s%s\n",
+ msg,
+ (unsigned int) state,
+ (state & I810_UPLOAD_TEX0) ? "upload-tex0, " : "",
+ (state & I810_UPLOAD_TEX1) ? "upload-tex1, " : "",
+ (state & I810_UPLOAD_CTX) ? "upload-ctx, " : "",
+ (state & I810_UPLOAD_BUFFERS) ? "upload-bufs, " : ""
+ );
+}
+
+
+
+void i810InitState( GLcontext *ctx )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ i810ScreenPrivate *i810Screen = imesa->i810Screen;
+
+ memset(imesa->Setup, 0, sizeof(imesa->Setup));
+
+ imesa->Setup[I810_CTXREG_VF] = 0;
+
+ imesa->Setup[I810_CTXREG_MT] = (GFX_OP_MAP_TEXELS |
+ MT_UPDATE_TEXEL1_STATE |
+ MT_TEXEL1_COORD1 |
+ MT_TEXEL1_MAP1 |
+ MT_TEXEL1_DISABLE |
+ MT_UPDATE_TEXEL0_STATE |
+ MT_TEXEL0_COORD0 |
+ MT_TEXEL0_MAP0 |
+ MT_TEXEL0_DISABLE);
+
+ imesa->Setup[I810_CTXREG_MC0] = ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_ITERATED_COLOR |
+ MC_ARG1_DONT_REPLICATE_ALPHA |
+ MC_ARG1_DONT_INVERT |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ONE |
+ MC_ARG2_DONT_REPLICATE_ALPHA |
+ MC_ARG2_DONT_INVERT |
+ MC_UPDATE_OP |
+ MC_OP_ARG1 );
+
+ imesa->Setup[I810_CTXREG_MC1] = ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_ONE |
+ MC_ARG1_DONT_REPLICATE_ALPHA |
+ MC_ARG1_DONT_INVERT |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ONE |
+ MC_ARG2_DONT_REPLICATE_ALPHA |
+ MC_ARG2_DONT_INVERT |
+ MC_UPDATE_OP |
+ MC_OP_DISABLE );
+
+
+ imesa->Setup[I810_CTXREG_MC2] = ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_2 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_CURRENT_COLOR |
+ MC_ARG1_REPLICATE_ALPHA |
+ MC_ARG1_DONT_INVERT |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ONE |
+ MC_ARG2_DONT_REPLICATE_ALPHA |
+ MC_ARG2_DONT_INVERT |
+ MC_UPDATE_OP |
+ MC_OP_DISABLE );
+
+
+ imesa->Setup[I810_CTXREG_MA0] = ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ITERATED_ALPHA |
+ MA_ARG1_DONT_INVERT |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_CURRENT_ALPHA |
+ MA_ARG2_DONT_INVERT |
+ MA_UPDATE_OP |
+ MA_OP_ARG1 );
+
+
+ imesa->Setup[I810_CTXREG_MA1] = ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_CURRENT_ALPHA |
+ MA_ARG1_DONT_INVERT |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_CURRENT_ALPHA |
+ MA_ARG2_DONT_INVERT |
+ MA_UPDATE_OP |
+ MA_OP_ARG1 );
+
+
+ imesa->Setup[I810_CTXREG_MA2] = ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_2 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_CURRENT_ALPHA |
+ MA_ARG1_DONT_INVERT |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_CURRENT_ALPHA |
+ MA_ARG2_DONT_INVERT |
+ MA_UPDATE_OP |
+ MA_OP_ARG1 );
+
+
+ imesa->Setup[I810_CTXREG_SDM] = ( GFX_OP_SRC_DEST_MONO |
+ SDM_UPDATE_MONO_ENABLE |
+ 0 |
+ SDM_UPDATE_SRC_BLEND |
+ SDM_SRC_ONE |
+ SDM_UPDATE_DST_BLEND |
+ SDM_DST_ZERO );
+
+ /* Use for colormask:
+ */
+ imesa->Setup[I810_CTXREG_CF0] = GFX_OP_COLOR_FACTOR;
+ imesa->Setup[I810_CTXREG_CF1] = 0xffffffff;
+
+ imesa->Setup[I810_CTXREG_ZA] = (GFX_OP_ZBIAS_ALPHAFUNC |
+ ZA_UPDATE_ALPHAFUNC |
+ ZA_ALPHA_ALWAYS |
+ ZA_UPDATE_ZBIAS |
+ 0 |
+ ZA_UPDATE_ALPHAREF |
+ 0x0);
+
+ imesa->Setup[I810_CTXREG_FOG] = (GFX_OP_FOG_COLOR |
+ (0xffffff & ~FOG_RESERVED_MASK));
+
+ /* Choose a pipe
+ */
+ imesa->Setup[I810_CTXREG_B1] = ( GFX_OP_BOOL_1 |
+ B1_UPDATE_SPEC_SETUP_ENABLE |
+ 0 |
+ B1_UPDATE_ALPHA_SETUP_ENABLE |
+ B1_ALPHA_SETUP_ENABLE |
+ B1_UPDATE_CI_KEY_ENABLE |
+ 0 |
+ B1_UPDATE_CHROMAKEY_ENABLE |
+ 0 |
+ B1_UPDATE_Z_BIAS_ENABLE |
+ 0 |
+ B1_UPDATE_SPEC_ENABLE |
+ 0 |
+ B1_UPDATE_FOG_ENABLE |
+ 0 |
+ B1_UPDATE_ALPHA_TEST_ENABLE |
+ 0 |
+ B1_UPDATE_BLEND_ENABLE |
+ 0 |
+ B1_UPDATE_Z_TEST_ENABLE |
+ 0 );
+
+ imesa->Setup[I810_CTXREG_B2] = ( GFX_OP_BOOL_2 |
+ B2_UPDATE_MAP_CACHE_ENABLE |
+ B2_MAP_CACHE_ENABLE |
+ B2_UPDATE_ALPHA_DITHER_ENABLE |
+ 0 |
+ B2_UPDATE_FOG_DITHER_ENABLE |
+ 0 |
+ B2_UPDATE_SPEC_DITHER_ENABLE |
+ 0 |
+ B2_UPDATE_RGB_DITHER_ENABLE |
+ B2_RGB_DITHER_ENABLE |
+ B2_UPDATE_FB_WRITE_ENABLE |
+ B2_FB_WRITE_ENABLE |
+ B2_UPDATE_ZB_WRITE_ENABLE |
+ B2_ZB_WRITE_ENABLE );
+
+ imesa->Setup[I810_CTXREG_LCS] = ( GFX_OP_LINEWIDTH_CULL_SHADE_MODE |
+ LCS_UPDATE_ZMODE |
+ LCS_Z_LESS |
+ LCS_UPDATE_LINEWIDTH |
+ LCS_LINEWIDTH_1_0 |
+ LCS_UPDATE_ALPHA_INTERP |
+ LCS_ALPHA_INTERP |
+ LCS_UPDATE_FOG_INTERP |
+ 0 |
+ LCS_UPDATE_SPEC_INTERP |
+ 0 |
+ LCS_UPDATE_RGB_INTERP |
+ LCS_RGB_INTERP |
+ LCS_UPDATE_CULL_MODE |
+ LCS_CULL_DISABLE);
+
+ imesa->LcsCullMode = LCS_CULL_CW;
+ imesa->LcsLineWidth = LCS_LINEWIDTH_1_0;
+ imesa->LcsPointSize = LCS_LINEWIDTH_1_0;
+
+ imesa->Setup[I810_CTXREG_PV] = ( GFX_OP_PV_RULE |
+ PV_UPDATE_PIXRULE |
+ PV_PIXRULE_ENABLE |
+ PV_UPDATE_LINELIST |
+ PV_LINELIST_PV1 |
+ PV_UPDATE_TRIFAN |
+ PV_TRIFAN_PV2 |
+ PV_UPDATE_TRISTRIP |
+ PV_TRISTRIP_PV2 );
+
+
+ imesa->Setup[I810_CTXREG_ST0] = GFX_OP_STIPPLE;
+ imesa->Setup[I810_CTXREG_ST1] = 0;
+
+ imesa->Setup[I810_CTXREG_AA] = ( GFX_OP_ANTIALIAS |
+ AA_UPDATE_EDGEFLAG |
+ 0 |
+ AA_UPDATE_POLYWIDTH |
+ AA_POLYWIDTH_05 |
+ AA_UPDATE_LINEWIDTH |
+ AA_LINEWIDTH_05 |
+ AA_UPDATE_BB_EXPANSION |
+ 0 |
+ AA_UPDATE_AA_ENABLE |
+ 0 );
+
+ memset(imesa->BufferSetup, 0, sizeof(imesa->BufferSetup));
+ imesa->BufferSetup[I810_DESTREG_DI0] = CMD_OP_DESTBUFFER_INFO;
+
+ if (imesa->glCtx->Visual.doubleBufferMode && imesa->sarea->pf_current_page == 0) {
+ /* use back buffer by default */
+ imesa->drawMap = i810Screen->back.map;
+ imesa->readMap = i810Screen->back.map;
+ imesa->BufferSetup[I810_DESTREG_DI1] = (i810Screen->backOffset |
+ i810Screen->backPitchBits);
+ } else {
+ /* use front buffer by default */
+ imesa->drawMap = (char *)imesa->driScreen->pFB;
+ imesa->readMap = (char *)imesa->driScreen->pFB;
+ imesa->BufferSetup[I810_DESTREG_DI1] = (i810Screen->fbOffset |
+ i810Screen->backPitchBits);
+ }
+
+ imesa->BufferSetup[I810_DESTREG_DV0] = GFX_OP_DESTBUFFER_VARS;
+ imesa->BufferSetup[I810_DESTREG_DV1] = (DV_HORG_BIAS_OGL |
+ DV_VORG_BIAS_OGL |
+ i810Screen->fbFormat);
+
+ imesa->BufferSetup[I810_DESTREG_DR0] = GFX_OP_DRAWRECT_INFO;
+ imesa->BufferSetup[I810_DESTREG_DR1] = DR1_RECT_CLIP_ENABLE;
+}
+
+
+static void i810InvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ I810_CONTEXT(ctx)->new_state |= new_state;
+}
+
+
+void i810InitStateFuncs(GLcontext *ctx)
+{
+ /* Callbacks for internal Mesa events.
+ */
+ ctx->Driver.UpdateState = i810InvalidateState;
+
+ /* API callbacks
+ */
+ ctx->Driver.AlphaFunc = i810AlphaFunc;
+ ctx->Driver.BlendEquationSeparate = i810BlendEquationSeparate;
+ ctx->Driver.BlendFuncSeparate = i810BlendFuncSeparate;
+ ctx->Driver.ClearColor = i810ClearColor;
+ ctx->Driver.ColorMask = i810ColorMask;
+ ctx->Driver.CullFace = i810CullFaceFrontFace;
+ ctx->Driver.DepthFunc = i810DepthFunc;
+ ctx->Driver.DepthMask = i810DepthMask;
+ ctx->Driver.Enable = i810Enable;
+ ctx->Driver.Fogfv = i810Fogfv;
+ ctx->Driver.FrontFace = i810CullFaceFrontFace;
+ ctx->Driver.LineWidth = i810LineWidth;
+ ctx->Driver.LogicOpcode = i810LogicOp;
+ ctx->Driver.PolygonStipple = i810PolygonStipple;
+ ctx->Driver.RenderMode = i810RenderMode;
+ ctx->Driver.Scissor = i810Scissor;
+ ctx->Driver.DrawBuffer = i810DrawBuffer;
+ ctx->Driver.ReadBuffer = i810ReadBuffer;
+ ctx->Driver.ShadeModel = i810ShadeModel;
+ ctx->Driver.DepthRange = i810DepthRange;
+ ctx->Driver.Viewport = i810Viewport;
+ ctx->Driver.PointSize = i810PointSize;
+
+ if (IS_I815(I810_CONTEXT(ctx))) {
+ ctx->Driver.LightModelfv = i810LightModelfv_i815;
+ } else {
+ ctx->Driver.LightModelfv = i810LightModelfv;
+ }
+
+ /* Pixel path fallbacks.
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810state.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810state.h
new file mode 100644
index 000000000..118b07549
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810state.h
@@ -0,0 +1,15 @@
+#ifndef _I810_STATE_H
+#define _I810_STATE_H
+
+#include "i810context.h"
+
+extern void i810InitState( GLcontext *ctx );
+extern void i810InitStateFuncs( GLcontext *ctx );
+extern void i810PrintDirty( const char *msg, GLuint state );
+extern void i810DrawBuffer(GLcontext *ctx, GLenum mode );
+
+extern void i810Fallback( i810ContextPtr imesa, GLuint bit, GLboolean mode );
+#define FALLBACK( imesa, bit, mode ) i810Fallback( imesa, bit, mode )
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810tex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810tex.c
new file mode 100644
index 000000000..0aba8e8aa
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810tex.c
@@ -0,0 +1,564 @@
+/*
+ * GLX Hardware Device Driver for Intel i810
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * 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
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810tex.c,v 1.9 2002/10/30 12:51:33 alanh Exp $ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "imports.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "texstore.h"
+#include "texformat.h"
+#include "teximage.h"
+#include "texmem.h"
+#include "texobj.h"
+#include "swrast/swrast.h"
+#include "colormac.h"
+#include "texobj.h"
+#include "mm.h"
+
+#include "i810screen.h"
+#include "i810_dri.h"
+
+#include "i810context.h"
+#include "i810tex.h"
+#include "i810state.h"
+#include "i810ioctl.h"
+
+
+/*
+ * Compute the 'S2.4' lod bias factor from the floating point OpenGL bias.
+ */
+static GLuint i810ComputeLodBias(GLfloat bias)
+{
+ int b = (int) (bias * 16.0) + 12;
+ if (b > 63)
+ b = 63;
+ else if (b < -64)
+ b = -64;
+ return (GLuint) (b & MLC_LOD_BIAS_MASK);
+}
+
+
+static void i810SetTexWrapping(i810TextureObjectPtr tex,
+ GLenum swrap, GLenum twrap)
+{
+ tex->Setup[I810_TEXREG_MCS] &= ~(MCS_U_STATE_MASK| MCS_V_STATE_MASK);
+
+ switch( swrap ) {
+ case GL_REPEAT:
+ tex->Setup[I810_TEXREG_MCS] |= MCS_U_WRAP;
+ break;
+ case GL_CLAMP:
+ case GL_CLAMP_TO_EDGE:
+ tex->Setup[I810_TEXREG_MCS] |= MCS_U_CLAMP;
+ break;
+ case GL_MIRRORED_REPEAT:
+ tex->Setup[I810_TEXREG_MCS] |= MCS_U_MIRROR;
+ break;
+ default:
+ _mesa_problem(NULL, "bad S wrap mode in %s", __FUNCTION__);
+ }
+
+ switch( twrap ) {
+ case GL_REPEAT:
+ tex->Setup[I810_TEXREG_MCS] |= MCS_V_WRAP;
+ break;
+ case GL_CLAMP:
+ case GL_CLAMP_TO_EDGE:
+ tex->Setup[I810_TEXREG_MCS] |= MCS_V_CLAMP;
+ break;
+ case GL_MIRRORED_REPEAT:
+ tex->Setup[I810_TEXREG_MCS] |= MCS_V_MIRROR;
+ break;
+ default:
+ _mesa_problem(NULL, "bad T wrap mode in %s", __FUNCTION__);
+ }
+}
+
+
+static void i810SetTexFilter(i810ContextPtr imesa,
+ i810TextureObjectPtr t,
+ GLenum minf, GLenum magf,
+ GLfloat bias)
+{
+ t->Setup[I810_TEXREG_MF] &= ~(MF_MIN_MASK|
+ MF_MAG_MASK|
+ MF_MIP_MASK);
+ t->Setup[I810_TEXREG_MLC] &= ~(MLC_LOD_BIAS_MASK);
+
+ switch (minf) {
+ case GL_NEAREST:
+ t->Setup[I810_TEXREG_MF] |= MF_MIN_NEAREST | MF_MIP_NONE;
+ break;
+ case GL_LINEAR:
+ t->Setup[I810_TEXREG_MF] |= MF_MIN_LINEAR | MF_MIP_NONE;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ t->Setup[I810_TEXREG_MF] |= MF_MIN_NEAREST | MF_MIP_NEAREST;
+ if (magf == GL_LINEAR) {
+ /*bias -= 0.5;*/ /* this doesn't work too good */
+ }
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ t->Setup[I810_TEXREG_MF] |= MF_MIN_LINEAR | MF_MIP_NEAREST;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ if (IS_I815(imesa))
+ t->Setup[I810_TEXREG_MF] |= MF_MIN_NEAREST | MF_MIP_LINEAR;
+ else
+ t->Setup[I810_TEXREG_MF] |= MF_MIN_NEAREST | MF_MIP_DITHER;
+ /*
+ if (magf == GL_LINEAR) {
+ bias -= 0.5;
+ }
+ */
+ bias -= 0.5; /* always biasing here looks better */
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ if (IS_I815(imesa))
+ t->Setup[I810_TEXREG_MF] |= MF_MIN_LINEAR | MF_MIP_LINEAR;
+ else
+ t->Setup[I810_TEXREG_MF] |= MF_MIN_LINEAR | MF_MIP_DITHER;
+ break;
+ default:
+ return;
+ }
+
+ switch (magf) {
+ case GL_NEAREST:
+ t->Setup[I810_TEXREG_MF] |= MF_MAG_NEAREST;
+ break;
+ case GL_LINEAR:
+ t->Setup[I810_TEXREG_MF] |= MF_MAG_LINEAR;
+ break;
+ default:
+ return;
+ }
+
+ t->Setup[I810_TEXREG_MLC] |= i810ComputeLodBias(bias);
+}
+
+
+static void
+i810SetTexBorderColor( i810TextureObjectPtr t, GLubyte color[4] )
+{
+ /* Need a fallback.
+ */
+}
+
+
+static i810TextureObjectPtr
+i810AllocTexObj( GLcontext *ctx, struct gl_texture_object *texObj )
+{
+ i810TextureObjectPtr t;
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+
+ t = CALLOC_STRUCT( i810_texture_object_t );
+ texObj->DriverData = t;
+ if ( t != NULL ) {
+ GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias;
+ /* Initialize non-image-dependent parts of the state:
+ */
+ t->base.tObj = texObj;
+ t->Setup[I810_TEXREG_MI0] = GFX_OP_MAP_INFO;
+ t->Setup[I810_TEXREG_MI1] = MI1_MAP_0;
+ t->Setup[I810_TEXREG_MI2] = MI2_DIMENSIONS_ARE_LOG2;
+ t->Setup[I810_TEXREG_MLC] = (GFX_OP_MAP_LOD_CTL |
+ MLC_MAP_0 |
+ /*MLC_DITHER_WEIGHT_FULL |*/
+ MLC_DITHER_WEIGHT_12 |
+ MLC_UPDATE_LOD_BIAS |
+ 0x0);
+ t->Setup[I810_TEXREG_MCS] = (GFX_OP_MAP_COORD_SETS |
+ MCS_COORD_0 |
+ MCS_UPDATE_NORMALIZED |
+ MCS_NORMALIZED_COORDS |
+ MCS_UPDATE_V_STATE |
+ MCS_V_WRAP |
+ MCS_UPDATE_U_STATE |
+ MCS_U_WRAP);
+ t->Setup[I810_TEXREG_MF] = (GFX_OP_MAP_FILTER |
+ MF_MAP_0 |
+ MF_UPDATE_ANISOTROPIC |
+ MF_UPDATE_MIP_FILTER |
+ MF_UPDATE_MAG_FILTER |
+ MF_UPDATE_MIN_FILTER);
+
+ make_empty_list( & t->base );
+
+ i810SetTexWrapping( t, texObj->WrapS, texObj->WrapT );
+ /*i830SetTexMaxAnisotropy( t, texObj->MaxAnisotropy );*/
+ i810SetTexFilter( imesa, t, texObj->MinFilter, texObj->MagFilter, bias );
+ i810SetTexBorderColor( t, texObj->_BorderChan );
+ }
+
+ return t;
+}
+
+
+static void i810TexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat *params )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData;
+
+ if (!t)
+ return;
+
+ if ( target != GL_TEXTURE_2D )
+ return;
+
+ /* Can't do the update now as we don't know whether to flush
+ * vertices or not. Setting imesa->new_state means that
+ * i810UpdateTextureState() will be called before any triangles are
+ * rendered. If a statechange has occurred, it will be detected at
+ * that point, and buffered vertices flushed.
+ */
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ {
+ GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias;
+ i810SetTexFilter( imesa, t, tObj->MinFilter, tObj->MagFilter, bias );
+ }
+ break;
+
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ i810SetTexWrapping( t, tObj->WrapS, tObj->WrapT );
+ break;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ i810SetTexBorderColor( t, tObj->_BorderChan );
+ break;
+
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ /* This isn't the most efficient solution but there doesn't appear to
+ * be a nice alternative for Radeon. Since there's no LOD clamping,
+ * we just have to rely on loading the right subset of mipmap levels
+ * to simulate a clamped LOD.
+ */
+ I810_FIREVERTICES( I810_CONTEXT(ctx) );
+ driSwapOutTextureObject( (driTextureObject *) t );
+ break;
+
+ default:
+ return;
+ }
+
+ if (t == imesa->CurrentTexObj[0]) {
+ I810_STATECHANGE( imesa, I810_UPLOAD_TEX0 );
+ }
+
+ if (t == imesa->CurrentTexObj[1]) {
+ I810_STATECHANGE( imesa, I810_UPLOAD_TEX1 );
+ }
+}
+
+
+/**
+ * Setup hardware bits for new texture environment settings.
+ *
+ * \todo
+ * Determine whether or not \c param can be used instead of
+ * \c texUnit->EnvColor in the \c GL_TEXTURE_ENV_COLOR case.
+ */
+static void i810TexEnv( GLcontext *ctx, GLenum target,
+ GLenum pname, const GLfloat *param )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ const GLuint unit = ctx->Texture.CurrentUnit;
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+ /* Only one env color. Need a fallback if env colors are different
+ * and texture setup references env color in both units.
+ */
+ switch (pname) {
+ case GL_TEXTURE_ENV_COLOR: {
+ GLubyte c[4];
+ GLuint envColor;
+
+ UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor );
+ envColor = PACK_COLOR_8888( c[3], c[0], c[1], c[2] );
+
+ if (imesa->Setup[I810_CTXREG_CF1] != envColor) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_CF1] = envColor;
+ }
+ break;
+ }
+
+ case GL_TEXTURE_ENV_MODE:
+ imesa->TexEnvImageFmt[unit] = 0; /* force recalc of env state */
+ break;
+
+ case GL_TEXTURE_LOD_BIAS: {
+ if ( texUnit->_Current != NULL ) {
+ const struct gl_texture_object *tObj = texUnit->_Current;
+ i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData;
+
+ t->Setup[I810_TEXREG_MLC] &= ~(MLC_LOD_BIAS_MASK);
+ t->Setup[I810_TEXREG_MLC] |= i810ComputeLodBias(*param);
+ }
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+
+
+#if 0
+static void i810TexImage1D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *pack,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ i810TextureObjectPtr t = (i810TextureObjectPtr) texObj->DriverData;
+ if (t) {
+ i810SwapOutTexObj( imesa, t );
+ }
+}
+
+static void i810TexSubImage1D( GLcontext *ctx,
+ GLenum target,
+ GLint level,
+ GLint xoffset,
+ GLsizei width,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *pack,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+}
+#endif
+
+
+static void i810TexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject *t = (driTextureObject *) texObj->DriverData;
+ if (t) {
+ I810_FIREVERTICES( I810_CONTEXT(ctx) );
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) i810AllocTexObj( ctx, texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ }
+ _mesa_store_teximage2d( ctx, target, level, internalFormat,
+ width, height, border, format, type,
+ pixels, packing, texObj, texImage );
+}
+
+static void i810TexSubImage2D( 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 )
+{
+ driTextureObject *t = (driTextureObject *)texObj->DriverData;
+ if (t) {
+ I810_FIREVERTICES( I810_CONTEXT(ctx) );
+ driSwapOutTextureObject( t );
+ }
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
+}
+
+
+static void i810BindTexture( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj )
+{
+ assert( (target != GL_TEXTURE_2D) || (tObj->DriverData != NULL) );
+}
+
+
+static void i810DeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
+{
+ driTextureObject * t = (driTextureObject *) tObj->DriverData;
+ if (t) {
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ if (imesa)
+ I810_FIREVERTICES( imesa );
+ driDestroyTextureObject( t );
+ }
+ /* Free mipmap images and the texture object itself */
+ _mesa_delete_texture_object(ctx, tObj);
+}
+
+/**
+ * Choose a Mesa texture format to match the requested format.
+ *
+ * \todo
+ * Determine why \c _mesa_texformat_al88 doesn't work right for
+ * \c GL_LUMINANCE_ALPHA textures. It seems to work fine for \c GL_INTENSITY,
+ * but \c GL_LUMINANCE_ALPHA gets some red bands in progs/demos/texenv.
+ */
+static const struct gl_texture_format *
+i810ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type )
+{
+ switch ( internalFormat ) {
+ case 4:
+ case GL_RGBA:
+ case GL_COMPRESSED_RGBA:
+ if ( format == GL_BGRA ) {
+ if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
+ return &_mesa_texformat_argb1555;
+ }
+ }
+ return &_mesa_texformat_argb4444;
+
+ case 3:
+ case GL_RGB:
+ case GL_COMPRESSED_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 &_mesa_texformat_rgb565;
+
+ case GL_RGBA2:
+ case GL_RGBA4:
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return &_mesa_texformat_argb4444;
+
+ case GL_RGB5_A1:
+ return &_mesa_texformat_argb1555;
+
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ case GL_COMPRESSED_ALPHA:
+ return &_mesa_texformat_al88;
+
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ case GL_COMPRESSED_LUMINANCE:
+ return &_mesa_texformat_rgb565;
+
+ 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_COMPRESSED_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case GL_COMPRESSED_INTENSITY:
+#if 0
+ return &_mesa_texformat_al88;
+#else
+ return &_mesa_texformat_argb4444;
+#endif
+
+ case GL_YCBCR_MESA:
+ if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
+ type == GL_UNSIGNED_BYTE)
+ return &_mesa_texformat_ycbcr;
+ else
+ return &_mesa_texformat_ycbcr_rev;
+
+ default:
+ fprintf(stderr, "unexpected texture format in %s\n", __FUNCTION__);
+ return NULL;
+ }
+
+ return NULL; /* never get here */
+}
+
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
+ * Note: this function will be called during context creation to
+ * allocate the default texture objects.
+ * Note: we could use containment here to 'derive' the driver-specific
+ * texture object from the core mesa gl_texture_object. Not done at this time.
+ */
+static struct gl_texture_object *
+i810NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+{
+ struct gl_texture_object *obj;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ i810AllocTexObj( ctx, obj );
+ return obj;
+}
+
+void i810InitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->ChooseTextureFormat = i810ChooseTextureFormat;
+ functions->TexImage2D = i810TexImage2D;
+ functions->TexSubImage2D = i810TexSubImage2D;
+ functions->BindTexture = i810BindTexture;
+ functions->NewTextureObject = i810NewTextureObject;
+ functions->DeleteTexture = i810DeleteTexture;
+ functions->TexParameter = i810TexParameter;
+ functions->TexEnv = i810TexEnv;
+ functions->IsTextureResident = driIsTextureResident;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810tex.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810tex.h
new file mode 100644
index 000000000..c6ab4c8e6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810tex.h
@@ -0,0 +1,78 @@
+/*
+ * GLX Hardware Device Driver for Intel i810
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * 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
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
+ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *
+ */
+
+#ifndef I810TEX_INC
+#define I810TEX_INC
+
+#include "mtypes.h"
+#include "mm.h"
+
+#include "i810context.h"
+#include "i810_3d_reg.h"
+#include "texmem.h"
+
+#define I810_TEX_MAXLEVELS 11
+
+/* For shared texture space managment, these texture objects may also
+ * be used as proxies for regions of texture memory containing other
+ * client's textures. Such proxy textures (not to be confused with GL
+ * proxy textures) are subject to the same LRU aging we use for our
+ * own private textures, and thus we have a mechanism where we can
+ * fairly decide between kicking out our own textures and those of
+ * other clients.
+ *
+ * Non-local texture objects have a valid MemBlock to describe the
+ * region managed by the other client, and can be identified by
+ * 't->globj == 0'
+ */
+struct i810_texture_object_t {
+ driTextureObject base;
+
+ int Pitch;
+ int Height;
+ int texelBytes;
+ char *BufAddr;
+
+ GLuint max_level;
+
+ struct {
+ const struct gl_texture_image *image;
+ int offset; /* into BufAddr */
+ int height;
+ int internalFormat;
+ } image[I810_TEX_MAXLEVELS];
+
+ GLuint Setup[I810_TEX_SETUP_SIZE];
+ GLuint dirty;
+
+};
+
+void i810UpdateTextureState( GLcontext *ctx );
+void i810InitTextureFuncs( struct dd_function_table *functions );
+
+void i810DestroyTexObj( i810ContextPtr imesa, i810TextureObjectPtr t );
+int i810UploadTexImagesLocked( i810ContextPtr imesa, i810TextureObjectPtr t );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810texmem.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810texmem.c
new file mode 100644
index 000000000..08900cc67
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810texmem.c
@@ -0,0 +1,183 @@
+/*
+ * GLX Hardware Device Driver for Intel i810
+ * Copyright (C) 1999 Keith Whitwell
+ * Texmem interface changes (C) 2003 Dave Airlie
+ *
+ * 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
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ */
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "colormac.h"
+#include "mm.h"
+#include "texformat.h"
+
+#include "i810screen.h"
+#include "i810_dri.h"
+
+#include "i810context.h"
+#include "i810tex.h"
+#include "i810state.h"
+#include "i810ioctl.h"
+
+
+void i810DestroyTexObj(i810ContextPtr imesa, i810TextureObjectPtr t)
+{
+ /* See if it was the driver's current object.
+ */
+ if ( imesa != NULL ) {
+ if (imesa->CurrentTexObj[0] == t) {
+ imesa->CurrentTexObj[0] = 0;
+ imesa->dirty &= ~I810_UPLOAD_TEX0;
+ }
+
+ if (imesa->CurrentTexObj[1] == t) {
+ imesa->CurrentTexObj[1] = 0;
+ imesa->dirty &= ~I810_UPLOAD_TEX1;
+ }
+ }
+}
+
+
+
+#if defined(i386) || defined(__i386__)
+/* From linux kernel i386 header files, copes with odd sizes better
+ * than COPY_DWORDS would:
+ */
+static __inline__ void * __memcpy(void * to, const void * from, size_t n)
+{
+int d0, d1, d2;
+__asm__ __volatile__(
+ "rep ; movsl\n\t"
+ "testb $2,%b4\n\t"
+ "je 1f\n\t"
+ "movsw\n"
+ "1:\ttestb $1,%b4\n\t"
+ "je 2f\n\t"
+ "movsb\n"
+ "2:"
+ : "=&c" (d0), "=&D" (d1), "=&S" (d2)
+ :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
+ : "memory");
+return (to);
+}
+#else
+/* Allow compilation on other architectures */
+#define __memcpy memcpy
+#endif
+
+/* Upload an image from mesa's internal copy.
+ */
+static void i810UploadTexLevel( i810ContextPtr imesa,
+ i810TextureObjectPtr t, int hwlevel )
+{
+ const struct gl_texture_image *image = t->image[hwlevel].image;
+ int j;
+
+ if (!image || !image->Data)
+ return;
+
+ if (image->Width * image->TexFormat->TexelBytes == t->Pitch) {
+ GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[hwlevel].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ memcpy( dst, src, t->Pitch * image->Height );
+ }
+ else switch (image->TexFormat->TexelBytes) {
+ case 1:
+ {
+ GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[hwlevel].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) {
+ __memcpy(dst, src, image->Width );
+ src += image->Width;
+ }
+ }
+ break;
+
+ case 2:
+ {
+ GLushort *dst = (GLushort *)(t->BufAddr + t->image[hwlevel].offset);
+ GLushort *src = (GLushort *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
+ __memcpy(dst, src, image->Width * 2 );
+ src += image->Width;
+ }
+ }
+ break;
+
+ default:
+ fprintf(stderr, "%s: Not supported texel size %d\n",
+ __FUNCTION__, image->TexFormat->TexelBytes);
+ }
+}
+
+/* This is called with the lock held. May have to eject our own and/or
+ * other client's texture objects to make room for the upload.
+ */
+int i810UploadTexImagesLocked( i810ContextPtr imesa, i810TextureObjectPtr t )
+{
+ int i;
+ int ofs;
+ int numLevels;
+
+ /* Do we need to eject LRU texture objects?
+ */
+ if (!t->base.memBlock) {
+ int heap;
+
+ heap = driAllocateTexture( imesa->texture_heaps, imesa->nr_heaps,
+ (driTextureObject *) t);
+
+ if ( heap == -1 ) {
+ return -1;
+ }
+
+ ofs = t->base.memBlock->ofs;
+ t->BufAddr = imesa->i810Screen->tex.map + ofs;
+ t->Setup[I810_TEXREG_MI3] = imesa->i810Screen->textureOffset + ofs;
+
+ if (t == imesa->CurrentTexObj[0])
+ I810_STATECHANGE(imesa, I810_UPLOAD_TEX0);
+
+ if (t == imesa->CurrentTexObj[1])
+ I810_STATECHANGE(imesa, I810_UPLOAD_TEX1);
+
+ /* i810UpdateTexLRU( imesa, t );*/
+ }
+ driUpdateTextureLRU( (driTextureObject *) t );
+
+ if (imesa->texture_heaps[0]->timestamp >= GET_DISPATCH_AGE(imesa))
+ i810WaitAgeLocked( imesa, imesa->texture_heaps[0]->timestamp );
+
+ numLevels = t->base.lastLevel - t->base.firstLevel + 1;
+ for (i = 0 ; i < numLevels ; i++)
+ if (t->base.dirty_images[0] & (1<<i))
+ i810UploadTexLevel( imesa, t, i );
+
+ t->base.dirty_images[0] = 0;
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810texstate.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810texstate.c
new file mode 100644
index 000000000..e100c565c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810texstate.c
@@ -0,0 +1,746 @@
+/*
+ * GLX Hardware Device Driver for Intel i810
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * 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
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ */
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "enums.h"
+
+#include "mm.h"
+
+#include "i810screen.h"
+#include "i810_dri.h"
+
+#include "i810context.h"
+#include "i810tex.h"
+#include "i810state.h"
+#include "i810ioctl.h"
+
+
+
+
+static void i810SetTexImages( i810ContextPtr imesa,
+ struct gl_texture_object *tObj )
+{
+ GLuint height, width, pitch, i, textureFormat, log_pitch;
+ i810TextureObjectPtr t = (i810TextureObjectPtr) tObj->DriverData;
+ const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
+ GLint numLevels;
+ GLint log2Width, log2Height;
+
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ switch (baseImage->Format) {
+ case GL_RGB:
+ case GL_LUMINANCE:
+ t->texelBytes = 2;
+ textureFormat = MI1_FMT_16BPP | MI1_PF_16BPP_RGB565;
+ break;
+ case GL_ALPHA:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ case GL_RGBA:
+ t->texelBytes = 2;
+ textureFormat = MI1_FMT_16BPP | MI1_PF_16BPP_ARGB4444;
+ break;
+ case GL_COLOR_INDEX:
+ textureFormat = MI1_FMT_8CI | MI1_PF_8CI_ARGB4444;
+ t->texelBytes = 1;
+ break;
+ case GL_YCBCR_MESA:
+ t->texelBytes = 2;
+ textureFormat = MI1_FMT_422 | MI1_PF_422_YCRCB_SWAP_Y
+ | MI1_COLOR_CONV_ENABLE;
+ break;
+
+ default:
+ fprintf(stderr, "i810SetTexImages: bad image->Format\n" );
+ return;
+ }
+
+ driCalculateTextureFirstLastLevel( (driTextureObject *) t );
+
+ numLevels = t->base.lastLevel - t->base.firstLevel + 1;
+
+ log2Width = tObj->Image[0][t->base.firstLevel]->WidthLog2;
+ log2Height = tObj->Image[0][t->base.firstLevel]->HeightLog2;
+
+ /* Figure out the amount of memory required to hold all the mipmap
+ * levels. Choose the smallest pitch to accomodate the largest
+ * mipmap:
+ */
+ width = tObj->Image[0][t->base.firstLevel]->Width * t->texelBytes;
+ for (pitch = 32, log_pitch=2 ; pitch < width ; pitch *= 2 )
+ log_pitch++;
+
+ /* All images must be loaded at this pitch. Count the number of
+ * lines required:
+ */
+ for ( height = i = 0 ; i < numLevels ; i++ ) {
+ t->image[i].image = tObj->Image[0][t->base.firstLevel + i];
+ t->image[i].offset = height * pitch;
+ t->image[i].internalFormat = baseImage->Format;
+ height += t->image[i].image->Height;
+ }
+
+ t->Pitch = pitch;
+ t->base.totalSize = height*pitch;
+ t->max_level = i-1;
+ t->dirty = I810_UPLOAD_TEX0 | I810_UPLOAD_TEX1;
+ t->Setup[I810_TEXREG_MI1] = (MI1_MAP_0 | textureFormat | log_pitch);
+ t->Setup[I810_TEXREG_MI2] = (MI2_DIMENSIONS_ARE_LOG2 |
+ (log2Height << 16) | log2Width);
+ t->Setup[I810_TEXREG_MLL] = (GFX_OP_MAP_LOD_LIMITS |
+ MLL_MAP_0 |
+ MLL_UPDATE_MAX_MIP |
+ MLL_UPDATE_MIN_MIP |
+ ((numLevels - 1) << MLL_MIN_MIP_SHIFT));
+
+ LOCK_HARDWARE( imesa );
+ i810UploadTexImagesLocked( imesa, t );
+ UNLOCK_HARDWARE( imesa );
+}
+
+/* ================================================================
+ * Texture combine functions
+ */
+
+#define I810_DISABLE 0
+#define I810_PASSTHRU 1
+#define I810_REPLACE 2
+#define I810_MODULATE 3
+#define I810_DECAL 4
+#define I810_BLEND 5
+#define I810_ALPHA_BLEND 6
+#define I810_ADD 7
+#define I810_MAX_COMBFUNC 8
+
+
+static GLuint i810_color_combine[][I810_MAX_COMBFUNC] =
+{
+ /* Unit 0:
+ */
+ {
+ /* Disable combiner stage
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_ITERATED_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ONE |
+ MC_UPDATE_OP |
+ MC_OP_ARG1 ), /* actually passthru */
+
+ /* Passthru
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_ITERATED_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ONE |
+ MC_UPDATE_OP |
+ MC_OP_ARG1 ),
+
+ /* GL_REPLACE
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_TEX0_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ONE |
+ MC_UPDATE_OP |
+ MC_OP_ARG1 ),
+
+ /* GL_MODULATE
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_TEX0_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ITERATED_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_MODULATE ),
+
+ /* GL_DECAL
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_COLOR_FACTOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_TEX0_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_LIN_BLEND_TEX0_ALPHA ),
+
+ /* GL_BLEND
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_COLOR_FACTOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ITERATED_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_LIN_BLEND_TEX0_COLOR ),
+
+ /* GL_BLEND according to alpha
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_TEX0_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ITERATED_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_LIN_BLEND_TEX0_ALPHA ),
+
+ /* GL_ADD
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_0 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_TEX0_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ITERATED_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_ADD ),
+ },
+
+ /* Unit 1:
+ */
+ {
+ /* Disable combiner stage (Note: disables all subsequent stages)
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_ONE |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ONE |
+ MC_UPDATE_OP |
+ MC_OP_DISABLE ),
+
+
+ /* Passthru
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_CURRENT_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ONE |
+ MC_UPDATE_OP |
+ MC_OP_ARG1 ),
+
+ /* GL_REPLACE
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_TEX1_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_ONE |
+ MC_UPDATE_OP |
+ MC_OP_ARG1 ),
+
+ /* GL_MODULATE
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_TEX1_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_CURRENT_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_MODULATE ),
+
+ /* GL_DECAL
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_COLOR_FACTOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_TEX1_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_LIN_BLEND_TEX1_ALPHA ),
+
+ /* GL_BLEND
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_COLOR_FACTOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_CURRENT_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_LIN_BLEND_TEX1_COLOR ),
+
+ /* GL_BLEND according to alpha
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_TEX1_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_CURRENT_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_LIN_BLEND_TEX1_ALPHA ),
+
+ /* GL_ADD
+ */
+ ( GFX_OP_MAP_COLOR_STAGES |
+ MC_STAGE_1 |
+ MC_UPDATE_DEST |
+ MC_DEST_CURRENT |
+ MC_UPDATE_ARG1 |
+ MC_ARG1_TEX1_COLOR |
+ MC_UPDATE_ARG2 |
+ MC_ARG2_CURRENT_COLOR |
+ MC_UPDATE_OP |
+ MC_OP_ADD ),
+ }
+};
+
+static GLuint i810_alpha_combine[][I810_MAX_COMBFUNC] =
+{
+ /* Unit 0:
+ */
+ {
+ /* Disable combiner stage
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ITERATED_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_TEX0_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_ARG1 ),
+
+ /* Passthru
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ITERATED_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_TEX0_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_ARG1 ),
+
+ /* GL_REPLACE
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ITERATED_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_TEX0_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_ARG2 ),
+
+ /* GL_MODULATE
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ITERATED_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_TEX0_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_MODULATE ),
+
+ /* GL_DECAL
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ALPHA_FACTOR |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_ALPHA_FACTOR |
+ MA_UPDATE_OP |
+ MA_OP_ARG1 ),
+
+ /* GL_BLEND
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ALPHA_FACTOR |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_ITERATED_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_LIN_BLEND_TEX0_ALPHA ),
+
+ /* GL_BLEND according to alpha (same as above)
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ALPHA_FACTOR |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_ITERATED_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_LIN_BLEND_TEX0_ALPHA ),
+
+ /* GL_ADD
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_0 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ITERATED_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_TEX0_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_ADD ),
+ },
+
+ /* Unit 1:
+ */
+ {
+ /* Disable combiner stage
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_CURRENT_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_CURRENT_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_ARG1 ),
+
+ /* Passthru
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_CURRENT_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_CURRENT_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_ARG1 ),
+
+ /* GL_REPLACE
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_CURRENT_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_TEX1_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_ARG2 ),
+
+ /* GL_MODULATE
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_CURRENT_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_TEX1_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_MODULATE ),
+
+ /* GL_DECAL
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ALPHA_FACTOR |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_ALPHA_FACTOR |
+ MA_UPDATE_OP |
+ MA_OP_ARG1 ),
+
+ /* GL_BLEND
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ALPHA_FACTOR |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_ITERATED_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_LIN_BLEND_TEX1_ALPHA ),
+
+ /* GL_BLEND according to alpha (same as above)
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_ALPHA_FACTOR |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_ITERATED_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_LIN_BLEND_TEX1_ALPHA ),
+
+ /* GL_ADD
+ */
+ ( GFX_OP_MAP_ALPHA_STAGES |
+ MA_STAGE_1 |
+ MA_UPDATE_ARG1 |
+ MA_ARG1_CURRENT_ALPHA |
+ MA_UPDATE_ARG2 |
+ MA_ARG2_TEX1_ALPHA |
+ MA_UPDATE_OP |
+ MA_OP_ADD ),
+ }
+
+};
+
+
+
+static void i810UpdateTexEnv( GLcontext *ctx, GLuint unit )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ const struct gl_texture_object *tObj = texUnit->_Current;
+ const GLuint format = tObj->Image[0][tObj->BaseLevel]->Format;
+ GLuint color_combine, alpha_combine;
+
+ switch (texUnit->EnvMode) {
+ case GL_REPLACE:
+ if (format == GL_ALPHA) {
+ color_combine = i810_color_combine[unit][I810_PASSTHRU];
+ alpha_combine = i810_alpha_combine[unit][I810_REPLACE];
+ } else if (format == GL_LUMINANCE || format == GL_RGB) {
+ color_combine = i810_color_combine[unit][I810_REPLACE];
+ alpha_combine = i810_alpha_combine[unit][I810_PASSTHRU];
+ } else {
+ color_combine = i810_color_combine[unit][I810_REPLACE];
+ alpha_combine = i810_alpha_combine[unit][I810_REPLACE];
+ }
+ break;
+
+ case GL_MODULATE:
+ if (format == GL_ALPHA) {
+ color_combine = i810_color_combine[unit][I810_PASSTHRU];
+ alpha_combine = i810_alpha_combine[unit][I810_MODULATE];
+ } else {
+ color_combine = i810_color_combine[unit][I810_MODULATE];
+ alpha_combine = i810_alpha_combine[unit][I810_MODULATE];
+ }
+ break;
+
+ case GL_DECAL:
+ switch (format) {
+ case GL_RGBA:
+ color_combine = i810_color_combine[unit][I810_ALPHA_BLEND];
+ alpha_combine = i810_alpha_combine[unit][I810_PASSTHRU];
+ break;
+ case GL_RGB:
+ color_combine = i810_color_combine[unit][I810_REPLACE];
+ alpha_combine = i810_alpha_combine[unit][I810_PASSTHRU];
+ break;
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ color_combine = i810_color_combine[unit][I810_PASSTHRU];
+ alpha_combine = i810_alpha_combine[unit][I810_PASSTHRU];
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ case GL_BLEND:
+ switch (format) {
+ case GL_RGB:
+ case GL_LUMINANCE:
+ color_combine = i810_color_combine[unit][I810_BLEND];
+ alpha_combine = i810_alpha_combine[unit][I810_PASSTHRU];
+ break;
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ color_combine = i810_color_combine[unit][I810_BLEND];
+ alpha_combine = i810_alpha_combine[unit][I810_MODULATE];
+ break;
+ case GL_ALPHA:
+ color_combine = i810_color_combine[unit][I810_PASSTHRU];
+ alpha_combine = i810_alpha_combine[unit][I810_MODULATE];
+ break;
+ case GL_INTENSITY:
+ color_combine = i810_color_combine[unit][I810_BLEND];
+ alpha_combine = i810_alpha_combine[unit][I810_BLEND];
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ case GL_ADD:
+ switch (format) {
+ case GL_RGB:
+ case GL_LUMINANCE:
+ color_combine = i810_color_combine[unit][I810_ADD];
+ alpha_combine = i810_alpha_combine[unit][I810_PASSTHRU];
+ break;
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ color_combine = i810_color_combine[unit][I810_ADD];
+ alpha_combine = i810_alpha_combine[unit][I810_MODULATE];
+ break;
+ case GL_ALPHA:
+ color_combine = i810_color_combine[unit][I810_PASSTHRU];
+ alpha_combine = i810_alpha_combine[unit][I810_MODULATE];
+ break;
+ case GL_INTENSITY:
+ color_combine = i810_color_combine[unit][I810_ADD];
+ alpha_combine = i810_alpha_combine[unit][I810_ADD];
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return;
+ }
+ break;
+
+ default:
+ return;
+ }
+
+ if (alpha_combine != imesa->Setup[I810_CTXREG_MA0 + unit] ||
+ color_combine != imesa->Setup[I810_CTXREG_MC0 + unit])
+ {
+ I810_STATECHANGE( imesa, I810_UPLOAD_CTX );
+ imesa->Setup[I810_CTXREG_MA0 + unit] = alpha_combine;
+ imesa->Setup[I810_CTXREG_MC0 + unit] = color_combine;
+ }
+}
+
+
+
+
+static void i810UpdateTexUnit( GLcontext *ctx, GLuint unit )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+ if (texUnit->_ReallyEnabled == TEXTURE_2D_BIT)
+ {
+ struct gl_texture_object *tObj = texUnit->_Current;
+ i810TextureObjectPtr t = (i810TextureObjectPtr)tObj->DriverData;
+
+ /* Upload teximages (not pipelined)
+ */
+ if (t->base.dirty_images[0]) {
+ I810_FIREVERTICES(imesa);
+ i810SetTexImages( imesa, tObj );
+ if (!t->base.memBlock) {
+ FALLBACK( imesa, I810_FALLBACK_TEXTURE, GL_TRUE );
+ return;
+ }
+ }
+
+ if (tObj->Image[0][tObj->BaseLevel]->Border > 0) {
+ FALLBACK( imesa, I810_FALLBACK_TEXTURE, GL_TRUE );
+ return;
+ }
+
+ /* Update state if this is a different texture object to last
+ * time.
+ */
+ if (imesa->CurrentTexObj[unit] != t) {
+ I810_STATECHANGE(imesa, (I810_UPLOAD_TEX0<<unit));
+ imesa->CurrentTexObj[unit] = t;
+ t->base.bound |= (1U << unit);
+
+ driUpdateTextureLRU( (driTextureObject *) t ); /* XXX: should be locked */
+
+ }
+
+ /* Update texture environment if texture object image format or
+ * texture environment state has changed.
+ */
+ if (tObj->Image[0][tObj->BaseLevel]->Format != imesa->TexEnvImageFmt[unit]) {
+ imesa->TexEnvImageFmt[unit] = tObj->Image[0][tObj->BaseLevel]->Format;
+ i810UpdateTexEnv( ctx, unit );
+ }
+ }
+ else if (texUnit->_ReallyEnabled) {
+ FALLBACK( imesa, I810_FALLBACK_TEXTURE, GL_TRUE );
+ }
+ else /*if (imesa->CurrentTexObj[unit])*/ {
+ imesa->CurrentTexObj[unit] = 0;
+ imesa->TexEnvImageFmt[unit] = 0;
+ imesa->dirty &= ~(I810_UPLOAD_TEX0<<unit);
+ imesa->Setup[I810_CTXREG_MA0 + unit] =
+ i810_alpha_combine[unit][I810_DISABLE];
+ imesa->Setup[I810_CTXREG_MC0 + unit] =
+ i810_color_combine[unit][I810_DISABLE];
+ I810_STATECHANGE( imesa, I810_UPLOAD_CTX );
+ }
+}
+
+
+void i810UpdateTextureState( GLcontext *ctx )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ /* fprintf(stderr, "%s\n", __FUNCTION__); */
+ FALLBACK( imesa, I810_FALLBACK_TEXTURE, GL_FALSE );
+ i810UpdateTexUnit( ctx, 0 );
+ i810UpdateTexUnit( ctx, 1 );
+}
+
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810tris.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810tris.c
new file mode 100644
index 000000000..3e09427bb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810tris.c
@@ -0,0 +1,871 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810tris.c,v 1.7 2002/10/30 12:51:33 alanh Exp $ */
+/**************************************************************************
+
+Copyright 2001 VA Linux Systems Inc., Fremont, 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
+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, VA LINUX SYSTEMS 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "enums.h"
+#include "colormac.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
+#include "i810screen.h"
+#include "i810_dri.h"
+
+#include "i810tris.h"
+#include "i810state.h"
+#include "i810vb.h"
+#include "i810ioctl.h"
+
+static void i810RenderPrimitive( GLcontext *ctx, GLenum prim );
+
+/***********************************************************************
+ * Emit primitives as inline vertices *
+ ***********************************************************************/
+
+#if defined(USE_X86_ASM)
+#define COPY_DWORDS( j, vb, vertsize, v ) \
+do { \
+ int __tmp; \
+ __asm__ __volatile__( "rep ; movsl" \
+ : "=%c" (j), "=D" (vb), "=S" (__tmp) \
+ : "0" (vertsize), \
+ "D" ((long)vb), \
+ "S" ((long)v) ); \
+} while (0)
+#else
+#define COPY_DWORDS( j, vb, vertsize, v ) \
+do { \
+ for ( j = 0 ; j < vertsize ; j++ ) \
+ vb[j] = ((GLuint *)v)[j]; \
+ vb += vertsize; \
+} while (0)
+#endif
+
+static __inline__ void i810_draw_triangle( i810ContextPtr imesa,
+ i810VertexPtr v0,
+ i810VertexPtr v1,
+ i810VertexPtr v2 )
+{
+ GLuint vertsize = imesa->vertex_size;
+ GLuint *vb = i810AllocDmaLow( imesa, 3 * 4 * vertsize );
+ int j;
+
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v2 );
+}
+
+
+static __inline__ void i810_draw_quad( i810ContextPtr imesa,
+ i810VertexPtr v0,
+ i810VertexPtr v1,
+ i810VertexPtr v2,
+ i810VertexPtr v3 )
+{
+ GLuint vertsize = imesa->vertex_size;
+ GLuint *vb = i810AllocDmaLow( imesa, 6 * 4 * vertsize );
+ int j;
+
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v3 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v2 );
+ COPY_DWORDS( j, vb, vertsize, v3 );
+}
+
+
+static __inline__ void i810_draw_point( i810ContextPtr imesa,
+ i810VertexPtr tmp )
+{
+ GLfloat sz = imesa->glCtx->Point._Size * .5;
+ int vertsize = imesa->vertex_size;
+ GLuint *vb = i810AllocDmaLow( imesa, 2 * 4 * vertsize );
+ int j;
+
+ /* Draw a point as a horizontal line.
+ */
+ *(float *)&vb[0] = tmp->v.x - sz + 0.125;
+ for (j = 1 ; j < vertsize ; j++)
+ vb[j] = tmp->ui[j];
+ vb += vertsize;
+
+ *(float *)&vb[0] = tmp->v.x + sz + 0.125;
+ for (j = 1 ; j < vertsize ; j++)
+ vb[j] = tmp->ui[j];
+ vb += vertsize;
+}
+
+
+static __inline__ void i810_draw_line( i810ContextPtr imesa,
+ i810VertexPtr v0,
+ i810VertexPtr v1 )
+{
+ GLuint vertsize = imesa->vertex_size;
+ GLuint *vb = i810AllocDmaLow( imesa, 2 * 4 * vertsize );
+ int j;
+
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+}
+
+
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ if (0) fprintf(stderr, "hw TRI\n"); \
+ if (DO_FALLBACK) \
+ imesa->draw_tri( imesa, a, b, c ); \
+ else \
+ i810_draw_triangle( imesa, a, b, c ); \
+} while (0)
+
+#define QUAD( a, b, c, d ) \
+do { \
+ if (0) fprintf(stderr, "hw QUAD\n"); \
+ if (DO_FALLBACK) { \
+ imesa->draw_tri( imesa, a, b, d ); \
+ imesa->draw_tri( imesa, b, c, d ); \
+ } else \
+ i810_draw_quad( imesa, a, b, c, d ); \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ if (0) fprintf(stderr, "hw LINE\n"); \
+ if (DO_FALLBACK) \
+ imesa->draw_line( imesa, v0, v1 ); \
+ else \
+ i810_draw_line( imesa, v0, v1 ); \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ if (0) fprintf(stderr, "hw POINT\n"); \
+ if (DO_FALLBACK) \
+ imesa->draw_point( imesa, v0 ); \
+ else \
+ i810_draw_point( imesa, v0 ); \
+} while (0)
+
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define I810_OFFSET_BIT 0x01
+#define I810_TWOSIDE_BIT 0x02
+#define I810_UNFILLED_BIT 0x04
+#define I810_FALLBACK_BIT 0x08
+#define I810_MAX_TRIFUNC 0x10
+
+
+static struct {
+ tnl_points_func points;
+ tnl_line_func line;
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
+} rast_tab[I810_MAX_TRIFUNC];
+
+
+#define DO_FALLBACK (IND & I810_FALLBACK_BIT)
+#define DO_OFFSET (IND & I810_OFFSET_BIT)
+#define DO_UNFILLED (IND & I810_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & I810_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 1
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX i810Vertex
+#define TAB rast_tab
+
+
+#define DEPTH_SCALE (1.0/0xffff)
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a > 0)
+#define GET_VERTEX(e) (imesa->verts + (e * imesa->vertex_size * sizeof(int)))
+
+#define VERT_SET_RGBA( v, c ) \
+do { \
+ i810_color_t *color = (i810_color_t *)&((v)->ui[coloroffset]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \
+} while (0)
+
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+
+#define VERT_SET_SPEC( v0, c ) \
+do { \
+ if (havespec) { \
+ UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.blue, (c)[2]); \
+ } \
+} while (0)
+#define VERT_COPY_SPEC( v0, v1 ) \
+do { \
+ if (havespec) { \
+ v0->v.specular.red = v1->v.specular.red; \
+ v0->v.specular.green = v1->v.specular.green; \
+ v0->v.specular.blue = v1->v.specular.blue; \
+ } \
+} while (0)
+
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
+#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[5]
+#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx]
+
+#define LOCAL_VARS(n) \
+ i810ContextPtr imesa = I810_CONTEXT(ctx); \
+ GLuint color[n], spec[n]; \
+ GLuint coloroffset = (imesa->vertex_size == 4 ? 3 : 4); \
+ GLboolean havespec = (imesa->vertex_size > 4); \
+ (void) color; (void) spec; (void) coloroffset; (void) havespec;
+
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ PR_LINES,
+ PR_LINES,
+ PR_LINES,
+ PR_LINES,
+ PR_TRIANGLES,
+ PR_TRIANGLES,
+ PR_TRIANGLES,
+ PR_TRIANGLES,
+ PR_TRIANGLES,
+ PR_TRIANGLES
+};
+
+#define RASTERIZE(x) if (imesa->hw_primitive != hw_prim[x]) \
+ i810RasterPrimitive( ctx, x, hw_prim[x] )
+#define RENDER_PRIMITIVE imesa->render_primitive
+#define TAG(x) x
+#define IND I810_FALLBACK_BIT
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_OFFSET_BIT|I810_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_TWOSIDE_BIT|I810_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT|I810_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_FALLBACK_BIT)
+#define TAG(x) x##_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_OFFSET_BIT|I810_FALLBACK_BIT)
+#define TAG(x) x##_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_TWOSIDE_BIT|I810_FALLBACK_BIT)
+#define TAG(x) x##_twoside_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT|I810_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_UNFILLED_BIT|I810_FALLBACK_BIT)
+#define TAG(x) x##_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_OFFSET_BIT|I810_UNFILLED_BIT|I810_FALLBACK_BIT)
+#define TAG(x) x##_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_TWOSIDE_BIT|I810_UNFILLED_BIT|I810_FALLBACK_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT|I810_UNFILLED_BIT| \
+ I810_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+static void init_rast_tab( void )
+{
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+ init_fallback();
+ init_offset_fallback();
+ init_twoside_fallback();
+ init_twoside_offset_fallback();
+ init_unfilled_fallback();
+ init_offset_unfilled_fallback();
+ init_twoside_unfilled_fallback();
+ init_twoside_offset_unfilled_fallback();
+}
+
+
+/***********************************************************************
+ * Rasterization fallback helpers *
+ ***********************************************************************/
+
+
+/* This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+static void
+i810_fallback_tri( i810ContextPtr imesa,
+ i810Vertex *v0,
+ i810Vertex *v1,
+ i810Vertex *v2 )
+{
+ GLcontext *ctx = imesa->glCtx;
+ SWvertex v[3];
+ i810_translate_vertex( ctx, v0, &v[0] );
+ i810_translate_vertex( ctx, v1, &v[1] );
+ i810_translate_vertex( ctx, v2, &v[2] );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+}
+
+
+static void
+i810_fallback_line( i810ContextPtr imesa,
+ i810Vertex *v0,
+ i810Vertex *v1 )
+{
+ GLcontext *ctx = imesa->glCtx;
+ SWvertex v[2];
+ i810_translate_vertex( ctx, v0, &v[0] );
+ i810_translate_vertex( ctx, v1, &v[1] );
+ _swrast_Line( ctx, &v[0], &v[1] );
+}
+
+
+static void
+i810_fallback_point( i810ContextPtr imesa,
+ i810Vertex *v0 )
+{
+ GLcontext *ctx = imesa->glCtx;
+ SWvertex v[1];
+ i810_translate_vertex( ctx, v0, &v[0] );
+ _swrast_Point( ctx, &v[0] );
+}
+
+
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+#define IND 0
+#define V(x) (i810Vertex *)(vertptr + ((x)*vertsize*sizeof(int)))
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) POINT( V(ELT(start)) );
+#define RENDER_LINE( v0, v1 ) LINE( V(v0), V(v1) )
+#define RENDER_TRI( v0, v1, v2 ) TRI( V(v0), V(v1), V(v2) )
+#define RENDER_QUAD( v0, v1, v2, v3 ) QUAD( V(v0), V(v1), V(v2), V(v3) )
+#define INIT(x) i810RenderPrimitive( ctx, x )
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ i810ContextPtr imesa = I810_CONTEXT(ctx); \
+ GLubyte *vertptr = (GLubyte *)imesa->verts; \
+ const GLuint vertsize = imesa->vertex_size; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ (void) elt;
+#define RESET_STIPPLE
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) x
+#define TAG(x) i810_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+#undef ELT
+#undef TAG
+#define TAG(x) i810_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl/t_vb_rendertmp.h"
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+
+
+static void i810RenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLuint prim = imesa->render_primitive;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n,
+ PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+ }
+
+ /* Restore the render primitive
+ */
+ if (prim != GL_POLYGON)
+ tnl->Driver.Render.PrimitiveNotify( ctx, prim );
+}
+
+static void i810RenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Line( ctx, ii, jj );
+}
+
+static void i810FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ GLuint vertsize = imesa->vertex_size;
+ GLuint *vb = i810AllocDmaLow( imesa, (n-2) * 3 * 4 * vertsize );
+ GLubyte *vertptr = (GLubyte *)imesa->verts;
+ const GLuint *start = (const GLuint *)V(elts[0]);
+ int i,j;
+
+ for (i = 2 ; i < n ; i++) {
+ COPY_DWORDS( j, vb, vertsize, V(elts[i-1]) );
+ COPY_DWORDS( j, vb, vertsize, V(elts[i]) );
+ COPY_DWORDS( j, vb, vertsize, start );
+ }
+}
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+/***********************************************************************
+ * Rasterization fallback helpers *
+ ***********************************************************************/
+
+
+
+#define _I810_NEW_RENDERSTATE (_DD_NEW_LINE_STIPPLE | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET | \
+ _DD_NEW_TRI_STIPPLE | \
+ _NEW_POLYGONSTIPPLE)
+
+#define POINT_FALLBACK (0)
+#define LINE_FALLBACK (DD_LINE_STIPPLE)
+#define TRI_FALLBACK (0)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK|\
+ DD_TRI_STIPPLE)
+#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
+
+static void i810ChooseRenderState(GLcontext *ctx)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ if (I810_DEBUG & DEBUG_STATE)
+ fprintf(stderr,"\n%s\n",__FUNCTION__);
+
+ if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) {
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= I810_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= I810_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= I810_UNFILLED_BIT;
+ }
+
+ imesa->draw_point = i810_draw_point;
+ imesa->draw_line = i810_draw_line;
+ imesa->draw_tri = i810_draw_triangle;
+
+ /* Hook in fallbacks for specific primitives.
+ */
+ if (flags & ANY_FALLBACK_FLAGS)
+ {
+ if (flags & POINT_FALLBACK)
+ imesa->draw_point = i810_fallback_point;
+
+ if (flags & LINE_FALLBACK)
+ imesa->draw_line = i810_fallback_line;
+
+ if (flags & TRI_FALLBACK)
+ imesa->draw_tri = i810_fallback_tri;
+
+ if ((flags & DD_TRI_STIPPLE) && !imesa->stipple_in_hw)
+ imesa->draw_tri = i810_fallback_tri;
+
+ index |= I810_FALLBACK_BIT;
+ }
+ }
+
+ if (imesa->RenderIndex != index) {
+ imesa->RenderIndex = index;
+
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = i810_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = i810_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */
+ tnl->Driver.Render.ClippedPolygon = i810FastRenderClippedPoly;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = i810RenderClippedLine;
+ tnl->Driver.Render.ClippedPolygon = i810RenderClippedPoly;
+ }
+ }
+}
+
+static const GLenum reduced_prim[GL_POLYGON+1] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES
+};
+
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+
+
+/* Determine the rasterized primitive when not drawing unfilled
+ * polygons.
+ *
+ * Used only for the default render stage which always decomposes
+ * primitives to trianges/lines/points. For the accelerated stage,
+ * which renders strips as strips, the equivalent calculations are
+ * performed in i810render.c.
+ */
+static void i810RenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ GLuint rprim = reduced_prim[prim];
+
+ imesa->render_primitive = prim;
+
+ if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ return;
+
+ if (imesa->reduced_primitive != rprim ||
+ hw_prim[prim] != imesa->hw_primitive) {
+ i810RasterPrimitive( ctx, rprim, hw_prim[prim] );
+ }
+}
+
+static void i810RunPipeline( GLcontext *ctx )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+
+ if (imesa->new_state) {
+ if (imesa->new_state & _NEW_TEXTURE)
+ i810UpdateTextureState( ctx ); /* may modify imesa->new_state */
+
+ if (!imesa->Fallback) {
+ if (imesa->new_state & _I810_NEW_VERTEX)
+ i810ChooseVertexState( ctx );
+
+ if (imesa->new_state & _I810_NEW_RENDERSTATE)
+ i810ChooseRenderState( ctx );
+ }
+
+ imesa->new_state = 0;
+ }
+
+ _tnl_run_pipeline( ctx );
+}
+
+static void i810RenderStart( GLcontext *ctx )
+{
+ /* Check for projective textureing. Make sure all texcoord
+ * pointers point to something. (fix in mesa?)
+ */
+ i810CheckTexSizes( ctx );
+}
+
+static void i810RenderFinish( GLcontext *ctx )
+{
+ if (I810_CONTEXT(ctx)->RenderIndex & I810_FALLBACK_BIT)
+ _swrast_flush( ctx );
+}
+
+
+
+
+/* System to flush dma and emit state changes based on the rasterized
+ * primitive.
+ */
+void i810RasterPrimitive( GLcontext *ctx,
+ GLenum rprim,
+ GLuint hwprim )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ GLuint st1 = imesa->Setup[I810_CTXREG_ST1];
+ GLuint aa = imesa->Setup[I810_CTXREG_AA];
+ GLuint lcs = imesa->Setup[I810_CTXREG_LCS];
+
+ st1 &= ~ST1_ENABLE;
+ aa &= ~AA_ENABLE;
+
+ if (I810_DEBUG & DEBUG_PRIMS) {
+ /* Prints reduced prim, and hw prim */
+ char *prim_name = "Unknown";
+
+ switch(hwprim) {
+ case PR_LINES:
+ prim_name = "Lines";
+ break;
+ case PR_LINESTRIP:
+ prim_name = "LineStrip";
+ break;
+ case PR_TRIANGLES:
+ prim_name = "Triangles";
+ break;
+ case PR_TRISTRIP_0:
+ prim_name = "TriStrip_0";
+ break;
+ case PR_TRIFAN:
+ prim_name = "TriFan";
+ break;
+ case PR_POLYGON:
+ prim_name = "Polygons";
+ break;
+ default:
+ break;
+ }
+
+ fprintf(stderr, "%s : rprim(%s), hwprim(%s)\n",
+ __FUNCTION__,
+ _mesa_lookup_enum_by_nr(rprim),
+ prim_name);
+ }
+
+ switch (rprim) {
+ case GL_TRIANGLES:
+ if (ctx->Polygon.StippleFlag)
+ st1 |= ST1_ENABLE;
+ if (ctx->Polygon.SmoothFlag)
+ aa |= AA_ENABLE;
+ break;
+ case GL_LINES:
+ lcs &= ~(LCS_LINEWIDTH_3_0|LCS_LINEWIDTH_0_5);
+ lcs |= imesa->LcsLineWidth;
+ if (ctx->Line.SmoothFlag) {
+ aa |= AA_ENABLE;
+ lcs |= LCS_LINEWIDTH_0_5;
+ }
+ break;
+ case GL_POINTS:
+ lcs &= ~(LCS_LINEWIDTH_3_0|LCS_LINEWIDTH_0_5);
+ lcs |= imesa->LcsPointSize;
+ if (ctx->Point.SmoothFlag) {
+ aa |= AA_ENABLE;
+ lcs |= LCS_LINEWIDTH_0_5;
+ }
+ break;
+ default:
+ return;
+ }
+
+ imesa->reduced_primitive = rprim;
+
+ if (st1 != imesa->Setup[I810_CTXREG_ST1] ||
+ aa != imesa->Setup[I810_CTXREG_AA] ||
+ lcs != imesa->Setup[I810_CTXREG_LCS])
+ {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->hw_primitive = hwprim;
+ imesa->Setup[I810_CTXREG_LCS] = lcs;
+ imesa->Setup[I810_CTXREG_ST1] = st1;
+ imesa->Setup[I810_CTXREG_AA] = aa;
+ }
+ else if (hwprim != imesa->hw_primitive) {
+ I810_STATECHANGE(imesa, 0);
+ imesa->hw_primitive = hwprim;
+ }
+}
+
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+static char *fallbackStrings[] = {
+ "Texture",
+ "Draw buffer",
+ "Read buffer",
+ "Color mask",
+ "Render mode",
+ "Stencil",
+ "Stipple",
+ "User disable"
+};
+
+
+static char *getFallbackString(GLuint bit)
+{
+ int i = 0;
+ while (bit > 1) {
+ i++;
+ bit >>= 1;
+ }
+ return fallbackStrings[i];
+}
+
+void i810Fallback( i810ContextPtr imesa, GLuint bit, GLboolean mode )
+{
+ GLcontext *ctx = imesa->glCtx;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldfallback = imesa->Fallback;
+
+ if (0) fprintf(stderr, "%s old %x bit %x mode %d\n", __FUNCTION__,
+ imesa->Fallback, bit, mode );
+
+ if (mode) {
+ imesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ I810_FIREVERTICES(imesa);
+ if (I810_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "ENTER FALLBACK %s\n", getFallbackString( bit ));
+ _swsetup_Wakeup( ctx );
+ imesa->RenderIndex = ~0;
+ }
+ }
+ else {
+ imesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ _swrast_flush( ctx );
+ if (I810_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "LEAVE FALLBACK %s\n", getFallbackString( bit ));
+ tnl->Driver.Render.Start = i810RenderStart;
+ tnl->Driver.Render.PrimitiveNotify = i810RenderPrimitive;
+ tnl->Driver.Render.Finish = i810RenderFinish;
+ tnl->Driver.Render.BuildVertices = i810BuildVertices;
+ imesa->new_state |= (_I810_NEW_RENDERSTATE|_I810_NEW_VERTEX);
+ }
+ }
+}
+
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+
+void i810InitTriFuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+ }
+
+ tnl->Driver.RunPipeline = i810RunPipeline;
+ tnl->Driver.Render.Start = i810RenderStart;
+ tnl->Driver.Render.Finish = i810RenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = i810RenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = i810BuildVertices;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810tris.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810tris.h
new file mode 100644
index 000000000..06c8b3fcd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810tris.h
@@ -0,0 +1,36 @@
+/*
+ * GLX Hardware Device Driver for Intel i810
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * 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
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810tris.h,v 1.10 2002/02/22 21:33:04 dawes Exp $ */
+
+#ifndef I810TRIS_INC
+#define I810TRIS_INC
+
+#include "mtypes.h"
+
+extern void i810PrintRenderState( const char *msg, GLuint state );
+extern void i810InitTriFuncs( GLcontext *ctx );
+extern void i810RasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810vb.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810vb.c
new file mode 100644
index 000000000..5ce98a991
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810vb.c
@@ -0,0 +1,489 @@
+/*
+ * GLX Hardware Device Driver for Intel i810
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * 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
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810vb.c,v 1.13 2003/03/26 20:43:48 tsi Exp $ */
+
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "imports.h"
+#include "macros.h"
+#include "colormac.h"
+
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/t_context.h"
+
+#include "i810screen.h"
+#include "i810_dri.h"
+
+#include "i810context.h"
+#include "i810vb.h"
+#include "i810ioctl.h"
+#include "i810tris.h"
+#include "i810state.h"
+
+
+#define I810_TEX1_BIT 0x1
+#define I810_TEX0_BIT 0x2
+#define I810_RGBA_BIT 0x4
+#define I810_SPEC_BIT 0x8
+#define I810_FOG_BIT 0x10
+#define I810_XYZW_BIT 0x20
+#define I810_PTEX_BIT 0x40
+#define I810_MAX_SETUP 0x80
+
+static struct {
+ void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
+ tnl_interp_func interp;
+ tnl_copy_pv_func copy_pv;
+ GLboolean (*check_tex_sizes)( GLcontext *ctx );
+ GLuint vertex_size;
+ GLuint vertex_format;
+} setup_tab[I810_MAX_SETUP];
+
+#define TINY_VERTEX_FORMAT (GFX_OP_VERTEX_FMT | \
+ VF_TEXCOORD_COUNT_0 | \
+ VF_RGBA_ENABLE | \
+ VF_XYZ)
+
+#define NOTEX_VERTEX_FORMAT (GFX_OP_VERTEX_FMT | \
+ VF_TEXCOORD_COUNT_0 | \
+ VF_SPEC_FOG_ENABLE | \
+ VF_RGBA_ENABLE | \
+ VF_XYZW)
+
+#define TEX0_VERTEX_FORMAT (GFX_OP_VERTEX_FMT | \
+ VF_TEXCOORD_COUNT_1 | \
+ VF_SPEC_FOG_ENABLE | \
+ VF_RGBA_ENABLE | \
+ VF_XYZW)
+
+#define TEX1_VERTEX_FORMAT (GFX_OP_VERTEX_FMT | \
+ VF_TEXCOORD_COUNT_2 | \
+ VF_SPEC_FOG_ENABLE | \
+ VF_RGBA_ENABLE | \
+ VF_XYZW)
+
+#define PROJ_TEX1_VERTEX_FORMAT 0
+#define TEX2_VERTEX_FORMAT 0
+#define TEX3_VERTEX_FORMAT 0
+#define PROJ_TEX3_VERTEX_FORMAT 0
+
+#define DO_XYZW (IND & I810_XYZW_BIT)
+#define DO_RGBA (IND & I810_RGBA_BIT)
+#define DO_SPEC (IND & I810_SPEC_BIT)
+#define DO_FOG (IND & I810_FOG_BIT)
+#define DO_TEX0 (IND & I810_TEX0_BIT)
+#define DO_TEX1 (IND & I810_TEX1_BIT)
+#define DO_TEX2 0
+#define DO_TEX3 0
+#define DO_PTEX (IND & I810_PTEX_BIT)
+
+#define VERTEX i810Vertex
+#define VERTEX_COLOR i810_color_t
+#define GET_VIEWPORT_MAT() I810_CONTEXT(ctx)->ViewportMatrix.m
+#define GET_TEXSOURCE(n) n
+#define GET_VERTEX_FORMAT() I810_CONTEXT(ctx)->Setup[I810_CTXREG_VF]
+#define GET_VERTEX_STORE() I810_CONTEXT(ctx)->verts
+#define GET_VERTEX_SIZE() I810_CONTEXT(ctx)->vertex_size * sizeof(GLuint)
+#define INVALIDATE_STORED_VERTICES()
+
+#define HAVE_HW_VIEWPORT 0
+#define HAVE_HW_DIVIDE 0
+#define HAVE_RGBA_COLOR 0
+#define HAVE_TINY_VERTICES 1
+#define HAVE_NOTEX_VERTICES 1
+#define HAVE_TEX0_VERTICES 1
+#define HAVE_TEX1_VERTICES 1
+#define HAVE_TEX2_VERTICES 0
+#define HAVE_TEX3_VERTICES 0
+#define HAVE_PTEX_VERTICES 0
+
+#define UNVIEWPORT_VARS GLfloat h = I810_CONTEXT(ctx)->driDrawable->h
+#define UNVIEWPORT_X(x) x - SUBPIXEL_X
+#define UNVIEWPORT_Y(y) - y + h + SUBPIXEL_Y
+#define UNVIEWPORT_Z(z) z * (float)0xffff
+
+#define PTEX_FALLBACK() FALLBACK(I810_CONTEXT(ctx), I810_FALLBACK_TEXTURE, 1)
+
+#define INTERP_VERTEX setup_tab[I810_CONTEXT(ctx)->SetupIndex].interp
+#define COPY_PV_VERTEX setup_tab[I810_CONTEXT(ctx)->SetupIndex].copy_pv
+
+
+/***********************************************************************
+ * Generate pv-copying and translation functions *
+ ***********************************************************************/
+
+#define TAG(x) i810_##x
+#include "tnl_dd/t_dd_vb.c"
+
+/***********************************************************************
+ * Generate vertex emit and interp functions *
+ ***********************************************************************/
+
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT)
+#define TAG(x) x##_wg
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_SPEC_BIT)
+#define TAG(x) x##_wgs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_TEX0_BIT)
+#define TAG(x) x##_wgt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_TEX0_BIT|I810_TEX1_BIT)
+#define TAG(x) x##_wgt0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_TEX0_BIT|I810_PTEX_BIT)
+#define TAG(x) x##_wgpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT)
+#define TAG(x) x##_wgst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT|\
+ I810_TEX1_BIT)
+#define TAG(x) x##_wgst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT|\
+ I810_PTEX_BIT)
+#define TAG(x) x##_wgspt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_FOG_BIT)
+#define TAG(x) x##_wgf
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT)
+#define TAG(x) x##_wgfs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT)
+#define TAG(x) x##_wgft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT|\
+ I810_TEX1_BIT)
+#define TAG(x) x##_wgft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT|\
+ I810_PTEX_BIT)
+#define TAG(x) x##_wgfpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT|\
+ I810_TEX0_BIT)
+#define TAG(x) x##_wgfst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT|\
+ I810_TEX0_BIT|I810_TEX1_BIT)
+#define TAG(x) x##_wgfst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_XYZW_BIT|I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT|\
+ I810_TEX0_BIT|I810_PTEX_BIT)
+#define TAG(x) x##_wgfspt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_TEX0_BIT)
+#define TAG(x) x##_t0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_TEX0_BIT|I810_TEX1_BIT)
+#define TAG(x) x##_t0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_FOG_BIT)
+#define TAG(x) x##_f
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_FOG_BIT|I810_TEX0_BIT)
+#define TAG(x) x##_ft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_FOG_BIT|I810_TEX0_BIT|I810_TEX1_BIT)
+#define TAG(x) x##_ft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT)
+#define TAG(x) x##_g
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_SPEC_BIT)
+#define TAG(x) x##_gs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_TEX0_BIT)
+#define TAG(x) x##_gt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_TEX0_BIT|I810_TEX1_BIT)
+#define TAG(x) x##_gt0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT)
+#define TAG(x) x##_gst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_SPEC_BIT|I810_TEX0_BIT|I810_TEX1_BIT)
+#define TAG(x) x##_gst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_FOG_BIT)
+#define TAG(x) x##_gf
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT)
+#define TAG(x) x##_gfs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT)
+#define TAG(x) x##_gft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_FOG_BIT|I810_TEX0_BIT|I810_TEX1_BIT)
+#define TAG(x) x##_gft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT|I810_TEX0_BIT)
+#define TAG(x) x##_gfst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (I810_RGBA_BIT|I810_FOG_BIT|I810_SPEC_BIT|I810_TEX0_BIT|\
+ I810_TEX1_BIT)
+#define TAG(x) x##_gfst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+
+static void init_setup_tab( void )
+{
+ init_wg();
+ init_wgs();
+ init_wgt0();
+ init_wgt0t1();
+ init_wgpt0();
+ init_wgst0();
+ init_wgst0t1();
+ init_wgspt0();
+ init_wgf();
+ init_wgfs();
+ init_wgft0();
+ init_wgft0t1();
+ init_wgfpt0();
+ init_wgfst0();
+ init_wgfst0t1();
+ init_wgfspt0();
+ init_t0();
+ init_t0t1();
+ init_f();
+ init_ft0();
+ init_ft0t1();
+ init_g();
+ init_gs();
+ init_gt0();
+ init_gt0t1();
+ init_gst0();
+ init_gst0t1();
+ init_gf();
+ init_gfs();
+ init_gft0();
+ init_gft0t1();
+ init_gfst0();
+ init_gfst0t1();
+}
+
+
+
+static void i810PrintSetupFlags(const char *msg, GLuint flags )
+{
+ fprintf(stderr, "%s(%x): %s%s%s%s%s%s\n",
+ msg,
+ (int)flags,
+ (flags & I810_XYZW_BIT) ? " xyzw," : "",
+ (flags & I810_RGBA_BIT) ? " rgba," : "",
+ (flags & I810_SPEC_BIT) ? " spec," : "",
+ (flags & I810_FOG_BIT) ? " fog," : "",
+ (flags & I810_TEX0_BIT) ? " tex-0," : "",
+ (flags & I810_TEX1_BIT) ? " tex-1," : "");
+}
+
+
+
+void i810CheckTexSizes( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+
+ if (!setup_tab[imesa->SetupIndex].check_tex_sizes(ctx)) {
+ /* Invalidate stored verts
+ */
+ imesa->SetupNewInputs = ~0;
+ imesa->SetupIndex |= I810_PTEX_BIT;
+
+ if (!imesa->Fallback &&
+ !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ tnl->Driver.Render.Interp = setup_tab[imesa->SetupIndex].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[imesa->SetupIndex].copy_pv;
+ }
+ if (imesa->Fallback) {
+ tnl->Driver.Render.Start(ctx);
+ }
+ }
+}
+
+void i810BuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ GLuint stride = imesa->vertex_size * sizeof(int);
+ GLubyte *v = ((GLubyte *)imesa->verts + (start * stride));
+
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+
+ newinputs |= imesa->SetupNewInputs;
+ imesa->SetupNewInputs = 0;
+
+ if (!newinputs)
+ return;
+
+ if (newinputs & VERT_BIT_POS) {
+ setup_tab[imesa->SetupIndex].emit( ctx, start, count, v, stride );
+ } else {
+ GLuint ind = 0;
+
+ if (newinputs & VERT_BIT_COLOR0)
+ ind |= I810_RGBA_BIT;
+
+ if (newinputs & VERT_BIT_COLOR1)
+ ind |= I810_SPEC_BIT;
+
+ if (newinputs & VERT_BIT_TEX0)
+ ind |= I810_TEX0_BIT;
+
+ if (newinputs & VERT_BIT_TEX1)
+ ind |= I810_TEX1_BIT;
+
+ if (newinputs & VERT_BIT_FOG)
+ ind |= I810_FOG_BIT;
+
+ if (imesa->SetupIndex & I810_PTEX_BIT)
+ ind = ~0;
+
+ ind &= imesa->SetupIndex;
+
+ if (ind) {
+ setup_tab[ind].emit( ctx, start, count, v, stride );
+ }
+ }
+}
+
+void i810ChooseVertexState( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ GLuint ind = I810_XYZW_BIT|I810_RGBA_BIT;
+
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ ind |= I810_SPEC_BIT;
+
+ if (ctx->Fog.Enabled)
+ ind |= I810_FOG_BIT;
+
+ if (ctx->Texture._EnabledUnits & 0x2)
+ /* unit 1 enabled */
+ ind |= I810_TEX1_BIT|I810_TEX0_BIT;
+ else if (ctx->Texture._EnabledUnits & 0x1)
+ /* unit 0 enabled */
+ ind |= I810_TEX0_BIT;
+
+ imesa->SetupIndex = ind;
+
+ if (I810_DEBUG & (DEBUG_VERTS|DEBUG_STATE))
+ i810PrintSetupFlags( __FUNCTION__, ind );
+
+ if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
+ tnl->Driver.Render.Interp = i810_interp_extras;
+ tnl->Driver.Render.CopyPV = i810_copy_pv_extras;
+ } else {
+ tnl->Driver.Render.Interp = setup_tab[ind].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
+ }
+
+ if (setup_tab[ind].vertex_format != imesa->Setup[I810_CTXREG_VF]) {
+ I810_STATECHANGE(imesa, I810_UPLOAD_CTX);
+ imesa->Setup[I810_CTXREG_VF] = setup_tab[ind].vertex_format;
+ imesa->vertex_size = setup_tab[ind].vertex_size;
+ }
+}
+
+
+
+void *i810_emit_contiguous_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ void *dest )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ GLuint stride = imesa->vertex_size * 4;
+ setup_tab[imesa->SetupIndex].emit( ctx, start, count, dest, stride );
+ return (void *)((char *)dest + stride * (count - start));
+}
+
+
+
+void i810InitVB( GLcontext *ctx )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ GLuint size = TNL_CONTEXT(ctx)->vb.Size;
+
+ imesa->verts = (GLubyte *)ALIGN_MALLOC(size * 4 * 16, 32);
+
+ {
+ static int firsttime = 1;
+ if (firsttime) {
+ init_setup_tab();
+ firsttime = 0;
+ }
+ }
+}
+
+
+void i810FreeVB( GLcontext *ctx )
+{
+ i810ContextPtr imesa = I810_CONTEXT(ctx);
+ if (imesa->verts) {
+ ALIGN_FREE(imesa->verts);
+ imesa->verts = 0;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810vb.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810vb.h
new file mode 100644
index 000000000..1cced86ab
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/i810vb.h
@@ -0,0 +1,60 @@
+/*
+ * GLX Hardware Device Driver for Intel i810
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * 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
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i810/i810vb.h,v 1.4 2002/02/22 21:33:04 dawes Exp $ */
+
+#ifndef I810VB_INC
+#define I810VB_INC
+
+#include "mtypes.h"
+#include "swrast/swrast.h"
+
+#define _I810_NEW_VERTEX (_NEW_TEXTURE | \
+ _DD_NEW_SEPARATE_SPECULAR | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _NEW_FOG)
+
+
+extern void i810ChooseVertexState( GLcontext *ctx );
+extern void i810CheckTexSizes( GLcontext *ctx );
+extern void i810BuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs );
+
+
+extern void *i810_emit_contiguous_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ void *dest );
+
+extern void i810_translate_vertex( GLcontext *ctx,
+ const i810Vertex *src,
+ SWvertex *dst );
+
+extern void i810InitVB( GLcontext *ctx );
+extern void i810FreeVB( GLcontext *ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/server/i810_common.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/server/i810_common.h
new file mode 100644
index 000000000..02e548be0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/server/i810_common.h
@@ -0,0 +1,192 @@
+/* i810_common.h -- common header definitions for I810 2D/3D/DRM suite
+ *
+ * Copyright 2002 Tungsten Graphics, 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.
+ *
+ * Converted to common header format:
+ * Jens Owen <jens@tungstengraphics.com>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_common.h,v 1.1 2002/09/11 00:29:31 dawes Exp $
+ *
+ */
+
+/* WARNING: If you change any of these defines, make sure to change
+ * the kernel include file as well (i810_drm.h)
+ */
+
+#ifndef _I810_COMMON_H_
+#define _I810_COMMON_H_
+
+#ifndef _I810_DEFINES_
+#define _I810_DEFINES_
+#define I810_USE_BATCH 1
+
+#define I810_DMA_BUF_ORDER 12
+#define I810_DMA_BUF_SZ (1<<I810_DMA_BUF_ORDER)
+#define I810_DMA_BUF_NR 256
+
+#define I810_NR_SAREA_CLIPRECTS 8
+
+/* Each region is a minimum of 64k, and there are at most 64 of them.
+ */
+#define I810_NR_TEX_REGIONS 64
+#define I810_LOG_MIN_TEX_REGION_SIZE 16
+
+/* Destbuffer state
+ * - backbuffer linear offset and pitch -- invarient in the current dri
+ * - zbuffer linear offset and pitch -- also invarient
+ * - drawing origin in back and depth buffers.
+ *
+ * Keep the depth/back buffer state here to acommodate private buffers
+ * in the future.
+ */
+#define I810_DESTREG_DI0 0 /* CMD_OP_DESTBUFFER_INFO (2 dwords) */
+#define I810_DESTREG_DI1 1
+#define I810_DESTREG_DV0 2 /* GFX_OP_DESTBUFFER_VARS (2 dwords) */
+#define I810_DESTREG_DV1 3
+#define I810_DESTREG_DR0 4 /* GFX_OP_DRAWRECT_INFO (4 dwords) */
+#define I810_DESTREG_DR1 5
+#define I810_DESTREG_DR2 6
+#define I810_DESTREG_DR3 7
+#define I810_DESTREG_DR4 8
+#define I810_DEST_SETUP_SIZE 10
+
+/* Context state
+ */
+#define I810_CTXREG_CF0 0 /* GFX_OP_COLOR_FACTOR */
+#define I810_CTXREG_CF1 1
+#define I810_CTXREG_ST0 2 /* GFX_OP_STIPPLE */
+#define I810_CTXREG_ST1 3
+#define I810_CTXREG_VF 4 /* GFX_OP_VERTEX_FMT */
+#define I810_CTXREG_MT 5 /* GFX_OP_MAP_TEXELS */
+#define I810_CTXREG_MC0 6 /* GFX_OP_MAP_COLOR_STAGES - stage 0 */
+#define I810_CTXREG_MC1 7 /* GFX_OP_MAP_COLOR_STAGES - stage 1 */
+#define I810_CTXREG_MC2 8 /* GFX_OP_MAP_COLOR_STAGES - stage 2 */
+#define I810_CTXREG_MA0 9 /* GFX_OP_MAP_ALPHA_STAGES - stage 0 */
+#define I810_CTXREG_MA1 10 /* GFX_OP_MAP_ALPHA_STAGES - stage 1 */
+#define I810_CTXREG_MA2 11 /* GFX_OP_MAP_ALPHA_STAGES - stage 2 */
+#define I810_CTXREG_SDM 12 /* GFX_OP_SRC_DEST_MONO */
+#define I810_CTXREG_FOG 13 /* GFX_OP_FOG_COLOR */
+#define I810_CTXREG_B1 14 /* GFX_OP_BOOL_1 */
+#define I810_CTXREG_B2 15 /* GFX_OP_BOOL_2 */
+#define I810_CTXREG_LCS 16 /* GFX_OP_LINEWIDTH_CULL_SHADE_MODE */
+#define I810_CTXREG_PV 17 /* GFX_OP_PV_RULE -- Invarient! */
+#define I810_CTXREG_ZA 18 /* GFX_OP_ZBIAS_ALPHAFUNC */
+#define I810_CTXREG_AA 19 /* GFX_OP_ANTIALIAS */
+#define I810_CTX_SETUP_SIZE 20
+
+/* Texture state (per tex unit)
+ */
+#define I810_TEXREG_MI0 0 /* GFX_OP_MAP_INFO (4 dwords) */
+#define I810_TEXREG_MI1 1
+#define I810_TEXREG_MI2 2
+#define I810_TEXREG_MI3 3
+#define I810_TEXREG_MF 4 /* GFX_OP_MAP_FILTER */
+#define I810_TEXREG_MLC 5 /* GFX_OP_MAP_LOD_CTL */
+#define I810_TEXREG_MLL 6 /* GFX_OP_MAP_LOD_LIMITS */
+#define I810_TEXREG_MCS 7 /* GFX_OP_MAP_COORD_SETS ??? */
+#define I810_TEX_SETUP_SIZE 8
+
+/* Driver specific DRM command indices
+ * NOTE: these are not OS specific, but they are driver specific
+ */
+#define DRM_I810_INIT 0x00
+#define DRM_I810_VERTEX 0x01
+#define DRM_I810_CLEAR 0x02
+#define DRM_I810_FLUSH 0x03
+#define DRM_I810_GETAGE 0x04
+#define DRM_I810_GETBUF 0x05
+#define DRM_I810_SWAP 0x06
+#define DRM_I810_COPY 0x07
+#define DRM_I810_DOCOPY 0x08
+#define DRM_I810_OV0INFO 0x09
+#define DRM_I810_FSTATUS 0x0a
+#define DRM_I810_OV0FLIP 0x0b
+#define DRM_I810_MC 0x0c
+#define DRM_I810_RSTATUS 0x0d
+#define DRM_I810_FLIP 0x0e
+
+#endif
+
+typedef enum _drmI810Initfunc {
+ I810_INIT_DMA = 0x01,
+ I810_CLEANUP_DMA = 0x02,
+ I810_INIT_DMA_1_4 = 0x03
+} drmI810Initfunc;
+
+typedef struct {
+ drmI810Initfunc func;
+ unsigned int mmio_offset;
+ unsigned int buffers_offset;
+ int sarea_priv_offset;
+ unsigned int ring_start;
+ unsigned int ring_end;
+ unsigned int ring_size;
+ unsigned int front_offset;
+ unsigned int back_offset;
+ unsigned int depth_offset;
+ unsigned int overlay_offset;
+ unsigned int overlay_physical;
+ unsigned int w;
+ unsigned int h;
+ unsigned int pitch;
+ unsigned int pitch_bits;
+} drmI810Init;
+
+typedef struct {
+ void *virtual;
+ int request_idx;
+ int request_size;
+ int granted;
+} drmI810DMA;
+
+/* Flags for clear ioctl
+ */
+#define I810_FRONT 0x1
+#define I810_BACK 0x2
+#define I810_DEPTH 0x4
+
+typedef struct {
+ int clear_color;
+ int clear_depth;
+ int flags;
+} drmI810Clear;
+
+typedef struct {
+ int idx; /* buffer index */
+ int used; /* nr bytes in use */
+ int discard; /* client is finished with the buffer? */
+} drmI810Vertex;
+
+/* Flags for vertex ioctl
+ */
+#define PR_TRIANGLES (0x0<<18)
+#define PR_TRISTRIP_0 (0x1<<18)
+#define PR_TRISTRIP_1 (0x2<<18)
+#define PR_TRIFAN (0x3<<18)
+#define PR_POLYGON (0x4<<18)
+#define PR_LINES (0x5<<18)
+#define PR_LINESTRIP (0x6<<18)
+#define PR_RECTS (0x7<<18)
+#define PR_MASK (0x7<<18)
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/server/i810_dri.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/server/i810_dri.c
new file mode 100644
index 000000000..f52797c5e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/server/i810_dri.c
@@ -0,0 +1,975 @@
+/**
+ * \file server/i810_dri.c
+ * \brief File to perform the device-specific initialization tasks typically
+ * done in the X server.
+ *
+ * Here they are converted to run in the client (or perhaps a standalone
+ * process), and to work with the frame buffer device rather than the X
+ * server infrastructure.
+ *
+ * Copyright (C) 2004 Dave Airlie (airlied@linux.ie)
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include "driver.h"
+#include "drm.h"
+
+#include "i810.h"
+#include "i810_dri.h"
+#include "i810_reg.h"
+
+
+static int i810_pitches[] = {
+ 512,
+ 1024,
+ 2048,
+ 4096,
+ 0
+};
+
+static int i810_pitch_flags[] = {
+ 0x0,
+ 0x1,
+ 0x2,
+ 0x3,
+ 0
+};
+
+static unsigned int i810_drm_version = 0;
+
+static int
+I810AllocLow(I810MemRange * result, I810MemRange * pool, int size)
+{
+ if (size > pool->Size)
+ return 0;
+
+ pool->Size -= size;
+ result->Size = size;
+ result->Start = pool->Start;
+ result->End = pool->Start += size;
+
+ return 1;
+}
+
+static int
+I810AllocHigh(I810MemRange * result, I810MemRange * pool, int size)
+{
+ if (size > pool->Size)
+ return 0;
+
+ pool->Size -= size;
+ result->Size = size;
+ result->End = pool->End;
+ result->Start = pool->End -= size;
+
+ return 1;
+}
+
+
+/**
+ * \brief Wait for free FIFO entries.
+ *
+ * \param ctx display handle.
+ * \param entries number of free entries to wait.
+ *
+ * It polls the free entries from the chip until it reaches the requested value
+ * or a timeout (3000 tries) occurs. Aborts the program if the FIFO times out.
+ */
+static void I810WaitForFifo( const DRIDriverContext *ctx,
+ int entries )
+{
+}
+
+/**
+ * \brief Reset graphics card to known state.
+ *
+ * \param ctx display handle.
+ *
+ * Resets the values of several I810 registers.
+ */
+static void I810EngineReset( const DRIDriverContext *ctx )
+{
+ unsigned char *I810MMIO = ctx->MMIOAddress;
+}
+
+/**
+ * \brief Restore the drawing engine.
+ *
+ * \param ctx display handle
+ *
+ * Resets the graphics card and sets initial values for several registers of
+ * the card's drawing engine.
+ *
+ * Turns on the i810 command processor engine (i.e., the ringbuffer).
+ */
+static int I810EngineRestore( const DRIDriverContext *ctx )
+{
+ I810Ptr info = ctx->driverPrivate;
+ unsigned char *I810MMIO = ctx->MMIOAddress;
+
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ return 1;
+}
+
+
+/**
+ * \brief Shutdown the drawing engine.
+ *
+ * \param ctx display handle
+ *
+ * Turns off the command processor engine & restores the graphics card
+ * to a state that fbdev understands.
+ */
+static int I810EngineShutdown( const DRIDriverContext *ctx )
+{
+ drmI810Init info;
+ int ret;
+
+ memset(&info, 0, sizeof(drmI810Init));
+ info.func = I810_CLEANUP_DMA;
+
+ ret = drmCommandWrite(ctx->drmFD, DRM_I810_INIT, &info, sizeof(drmI810Init));
+ if (ret>0)
+ {
+ fprintf(stderr,"[dri] I810 DMA Cleanup failed\n");
+ return -errno;
+ }
+ return 0;
+}
+
+/**
+ * \brief Compute base 2 logarithm.
+ *
+ * \param val value.
+ *
+ * \return base 2 logarithm of \p val.
+ */
+static int I810MinBits(int val)
+{
+ int bits;
+
+ if (!val) return 1;
+ for (bits = 0; val; val >>= 1, ++bits);
+ return bits;
+}
+
+static int I810DRIAgpPreInit( const DRIDriverContext *ctx, I810Ptr info)
+{
+
+ if (drmAgpAcquire(ctx->drmFD) < 0) {
+ fprintf(stderr, "[gart] AGP not available\n");
+ return 0;
+ }
+
+
+ if (drmAgpEnable(ctx->drmFD, 0) < 0) {
+ fprintf(stderr, "[gart] AGP not enabled\n");
+ drmAgpRelease(ctx->drmFD);
+ return 0;
+ }
+}
+
+/**
+ * \brief Initialize the AGP state
+ *
+ * \param ctx display handle.
+ * \param info driver private data.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Acquires and enables the AGP device. Reserves memory in the AGP space for
+ * the ring buffer, vertex buffers and textures. Initialize the I810
+ * registers to point to that memory and add client mappings.
+ */
+static int I810DRIAgpInit( const DRIDriverContext *ctx, I810Ptr info)
+{
+ unsigned char *I810MMIO = ctx->MMIOAddress;
+ int ret;
+ int s, l;
+ unsigned long dcacheHandle;
+ unsigned long agpHandle;
+ int pitch_idx = 0;
+ int back_size = 0;
+ int sysmem_size = 0;
+ int width = ctx->shared.virtualWidth * ctx->cpp;
+
+
+ info->backHandle = DRM_AGP_NO_HANDLE;
+ info->zHandle = DRM_AGP_NO_HANDLE;
+ info->sysmemHandle = DRM_AGP_NO_HANDLE;
+ info->dcacheHandle = DRM_AGP_NO_HANDLE;
+
+ memset(&info->DcacheMem, 0, sizeof(I810MemRange));
+ memset(&info->BackBuffer, 0, sizeof(I810MemRange));
+ memset(&info->DepthBuffer, 0, sizeof(I810MemRange));
+
+ drmAgpAlloc(ctx->drmFD, 4096 * 1024, 1, NULL, &dcacheHandle);
+ info->dcacheHandle = dcacheHandle;
+
+ fprintf(stderr, "[agp] dcacheHandle : 0x%x\n", dcacheHandle);
+
+#define Elements(x) sizeof(x)/sizeof(*x)
+ for (pitch_idx = 0; pitch_idx < Elements(i810_pitches); pitch_idx++)
+ if (width <= i810_pitches[pitch_idx])
+ break;
+
+ if (pitch_idx == Elements(i810_pitches)) {
+ fprintf(stderr,"[dri] Couldn't find depth/back buffer pitch\n");
+ exit(-1);
+ }
+ else
+ {
+ int lines = (ctx->shared.virtualWidth + 15) / 16 * 16;
+ back_size = i810_pitches[pitch_idx] * lines;
+ back_size = ((back_size + 4096 - 1) / 4096) * 4096;
+ }
+
+ sysmem_size = ctx->shared.fbSize;
+ fprintf(stderr,"sysmem_size is %lu back_size is %lu\n", sysmem_size, back_size);
+ if (dcacheHandle != DRM_AGP_NO_HANDLE) {
+ if (back_size > 4 * 1024 * 1024) {
+ fprintf(stderr,"[dri] Backsize is larger then 4 meg\n");
+ sysmem_size = sysmem_size - 2 * back_size;
+ drmAgpFree(ctx->drmFD, dcacheHandle);
+ info->dcacheHandle = dcacheHandle = DRM_AGP_NO_HANDLE;
+ } else {
+ sysmem_size = sysmem_size - back_size;
+ }
+ } else {
+ sysmem_size = sysmem_size - 2 * back_size;
+ }
+
+ info->SysMem.Start=0;
+ info->SysMem.Size = sysmem_size;
+ info->SysMem.End = sysmem_size;
+
+ if (dcacheHandle != DRM_AGP_NO_HANDLE) {
+ if (drmAgpBind(ctx->drmFD, dcacheHandle, info->DepthOffset) == 0) {
+ memset(&info->DcacheMem, 0, sizeof(I810MemRange));
+ fprintf(stderr,"[agp] GART: Found 4096K Z buffer memory\n");
+ info->DcacheMem.Start = info->DepthOffset;
+ info->DcacheMem.Size = 1024 * 4096;
+ info->DcacheMem.End = info->DcacheMem.Start + info->DcacheMem.Size;
+ } else {
+ fprintf(stderr, "[agp] GART: dcache bind failed\n");
+ drmAgpFree(ctx->drmFD, dcacheHandle);
+ info->dcacheHandle = dcacheHandle = DRM_AGP_NO_HANDLE;
+ }
+ } else {
+ fprintf(stderr, "[agp] GART: no dcache memory found\n");
+ }
+
+ drmAgpAlloc(ctx->drmFD, back_size, 0, NULL, &agpHandle);
+ info->backHandle = agpHandle;
+
+ if (agpHandle != DRM_AGP_NO_HANDLE) {
+ if (drmAgpBind(ctx->drmFD, agpHandle, info->BackOffset) == 0) {
+ fprintf(stderr, "[agp] Bound backbuffer memory\n");
+
+ info->BackBuffer.Start = info->BackOffset;
+ info->BackBuffer.Size = back_size;
+ info->BackBuffer.End = (info->BackBuffer.Start +
+ info->BackBuffer.Size);
+ } else {
+ fprintf(stderr,"[agp] Unable to bind backbuffer. Disabling DRI.\n");
+ return 0;
+ }
+ } else {
+ fprintf(stderr, "[dri] Unable to allocate backbuffer memory. Disabling DRI.\n");
+ return 0;
+ }
+
+ if (dcacheHandle == DRM_AGP_NO_HANDLE) {
+ drmAgpAlloc(ctx->drmFD, back_size, 0, NULL, &agpHandle);
+
+ info->zHandle = agpHandle;
+
+ if (agpHandle != DRM_AGP_NO_HANDLE) {
+ if (drmAgpBind(ctx->drmFD, agpHandle, info->DepthOffset) == 0) {
+ fprintf(stderr,"[agp] Bound depthbuffer memory\n");
+ info->DepthBuffer.Start = info->DepthOffset;
+ info->DepthBuffer.Size = back_size;
+ info->DepthBuffer.End = (info->DepthBuffer.Start +
+ info->DepthBuffer.Size);
+ } else {
+ fprintf(stderr,"[agp] Unable to bind depthbuffer. Disabling DRI.\n");
+ return 0;
+ }
+ } else {
+ fprintf(stderr,"[agp] Unable to allocate depthbuffer memory. Disabling DRI.\n");
+ return 0;
+ }
+ }
+
+ /* Now allocate and bind the agp space. This memory will include the
+ * regular framebuffer as well as texture memory.
+ */
+ drmAgpAlloc(ctx->drmFD, sysmem_size, 0, NULL, &agpHandle);
+ info->sysmemHandle = agpHandle;
+
+ if (agpHandle != DRM_AGP_NO_HANDLE) {
+ if (drmAgpBind(ctx->drmFD, agpHandle, 0) == 0) {
+ fprintf(stderr, "[agp] Bound System Texture Memory\n");
+ } else {
+ fprintf(stderr, "[agp] Unable to bind system texture memory. Disabling DRI.\n");
+ return 0;
+ }
+ } else {
+ fprintf(stderr, "[agp] Unable to allocate system texture memory. Disabling DRI.\n");
+ return 0;
+ }
+
+ info->auxPitch = i810_pitches[pitch_idx];
+ info->auxPitchBits = i810_pitch_flags[pitch_idx];
+
+ return 1;
+}
+
+
+/**
+ * \brief Initialize the kernel data structures and enable the CP engine.
+ *
+ * \param ctx display handle.
+ * \param info driver private data.
+ *
+ * \return non-zero on success, or zero on failure.
+ *
+ * This function is a wrapper around the DRM_I810_CP_INIT command, passing
+ * all the parameters in a drmI810Init structure.
+ */
+static int I810DRIKernelInit( const DRIDriverContext *ctx,
+ I810Ptr info)
+{
+ int cpp = ctx->bpp / 8;
+ drmI810Init drmInfo;
+ int ret;
+ I810RingBuffer *ring = &(info->LpRing);
+
+ /* This is the struct passed to the kernel module for its initialization */
+ memset(&drmInfo, 0, sizeof(drmI810Init));
+
+ /* make sure we have at least 1.4 */
+ drmInfo.func = I810_INIT_DMA_1_4;
+
+ drmInfo.ring_start = ring->mem.Start;
+ drmInfo.ring_end = ring->mem.End;
+ drmInfo.ring_size = ring->mem.Size;
+
+ drmInfo.mmio_offset = (unsigned int)info->regs;
+ drmInfo.buffers_offset = (unsigned int)info->buffer_map;
+ drmInfo.sarea_priv_offset = sizeof(drm_sarea_t);
+
+ drmInfo.front_offset = 0;
+ drmInfo.back_offset = info->BackBuffer.Start;
+ drmInfo.depth_offset = info->DepthBuffer.Start;
+
+ drmInfo.w = ctx->shared.virtualWidth;
+ drmInfo.h = ctx->shared.virtualHeight;
+ drmInfo.pitch = info->auxPitch;
+ drmInfo.pitch_bits = info->auxPitchBits;
+
+
+ ret = drmCommandWrite(ctx->drmFD, DRM_I810_INIT, &drmInfo,
+ sizeof(drmI810Init));
+
+ return ret >= 0;
+}
+
+
+/**
+ * \brief Add a map for the vertex buffers that will be accessed by any
+ * DRI-based clients.
+ *
+ * \param ctx display handle.
+ * \param info driver private data.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Calls drmAddBufs() with the previously allocated vertex buffers.
+ */
+static int I810DRIBufInit( const DRIDriverContext *ctx, I810Ptr info )
+{
+ /* Initialize vertex buffers */
+ info->bufNumBufs = drmAddBufs(ctx->drmFD,
+ I810_DMA_BUF_NR,
+ I810_DMA_BUF_SZ,
+ DRM_AGP_BUFFER,
+ info->BufferMem.Start);
+
+ if (info->bufNumBufs <= 0) {
+ fprintf(stderr,
+ "[drm] Could not create vertex/indirect buffers list\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[drm] Added %d %d byte vertex/indirect buffers\n",
+ info->bufNumBufs, I810_DMA_BUF_SZ);
+
+ return 1;
+}
+
+/**
+ * \brief Install an IRQ handler.
+ *
+ * \param ctx display handle.
+ * \param info driver private data.
+ *
+ * Attempts to install an IRQ handler via drmCtlInstHandler(), falling back to
+ * IRQ-free operation on failure.
+ */
+static void I810DRIIrqInit(const DRIDriverContext *ctx,
+ I810Ptr info)
+{
+ if (!info->irq) {
+ info->irq = drmGetInterruptFromBusID(ctx->drmFD,
+ ctx->pciBus,
+ ctx->pciDevice,
+ ctx->pciFunc);
+
+ if ((drmCtlInstHandler(ctx->drmFD, info->irq)) != 0) {
+ fprintf(stderr,
+ "[drm] failure adding irq handler, "
+ "there is a device already using that irq\n"
+ "[drm] falling back to irq-free operation\n");
+ info->irq = 0;
+ }
+ }
+
+ if (info->irq)
+ fprintf(stderr,
+ "[drm] dma control initialized, using IRQ %d\n",
+ info->irq);
+}
+
+static int I810CheckDRMVersion( const DRIDriverContext *ctx,
+ I810Ptr info )
+{
+ drmVersionPtr version;
+
+ version = drmGetVersion(ctx->drmFD);
+ if (version) {
+ int req_minor, req_patch;
+
+ req_minor = 4;
+ req_patch = 0;
+
+ i810_drm_version = (version->version_major<<16) | version->version_minor;
+ if (version->version_major != 1 ||
+ version->version_minor < req_minor ||
+ (version->version_minor == req_minor &&
+ version->version_patchlevel < req_patch)) {
+ /* Incompatible drm version */
+ fprintf(stderr,
+ "[dri] I810DRIScreenInit failed because of a version "
+ "mismatch.\n"
+ "[dri] i810.o kernel module version is %d.%d.%d "
+ "but version 1.%d.%d or newer is needed.\n"
+ "[dri] Disabling DRI.\n",
+ version->version_major,
+ version->version_minor,
+ version->version_patchlevel,
+ req_minor,
+ req_patch);
+ drmFreeVersion(version);
+ return 0;
+ }
+
+ info->drmMinor = version->version_minor;
+ drmFreeVersion(version);
+ }
+
+ return 1;
+}
+
+static int I810MemoryInit( const DRIDriverContext *ctx, I810Ptr info )
+{
+ int width_bytes = ctx->shared.virtualWidth * ctx->cpp;
+ int cpp = ctx->cpp;
+ int bufferSize = (ctx->shared.virtualHeight * width_bytes);
+ int depthSize = (((ctx->shared.virtualHeight+15) & ~15) * width_bytes);
+ int l;
+
+ if (drmAddMap(ctx->drmFD, (drm_handle_t) info->BackBuffer.Start,
+ info->BackBuffer.Size, DRM_AGP, 0,
+ &info->backbuffer) < 0) {
+ fprintf(stderr, "[drm] drmAddMap(backbuffer) failed. Disabling DRI\n");
+ return 0;
+ }
+
+ if (drmAddMap(ctx->drmFD, (drm_handle_t) info->DepthBuffer.Start,
+ info->DepthBuffer.Size, DRM_AGP, 0,
+ &info->depthbuffer) < 0) {
+ fprintf(stderr, "[drm] drmAddMap(depthbuffer) failed. Disabling DRI.\n");
+ return 0;
+ }
+
+ if (!I810AllocLow(&(info->FrontBuffer), &(info->SysMem), (((ctx->shared.virtualHeight * width_bytes) + 4095) & ~4095)))
+ {
+ fprintf(stderr,"Framebuffer allocation failed\n");
+ return 0;
+ }
+ else
+ fprintf(stderr,"Frame buffer at 0x%.8x (%luk, %lu bytes)\n",
+ info->FrontBuffer.Start,
+ info->FrontBuffer.Size / 1024, info->FrontBuffer.Size);
+
+ memset(&(info->LpRing), 0, sizeof(I810RingBuffer));
+ if (I810AllocLow(&(info->LpRing.mem), &(info->SysMem), 16 * 4096)) {
+ fprintf(stderr,
+ "Ring buffer at 0x%.8x (%luk, %lu bytes)\n",
+ info->LpRing.mem.Start,
+ info->LpRing.mem.Size / 1024, info->LpRing.mem.Size);
+
+ info->LpRing.tail_mask = info->LpRing.mem.Size - 1;
+ info->LpRing.virtual_start = info->LpRing.mem.Start;
+ info->LpRing.head = 0;
+ info->LpRing.tail = 0;
+ info->LpRing.space = 0;
+ } else {
+ fprintf(stderr, "Ring buffer allocation failed\n");
+ return (0);
+ }
+
+ /* Allocate buffer memory */
+ I810AllocHigh(&(info->BufferMem), &(info->SysMem),
+ I810_DMA_BUF_NR * I810_DMA_BUF_SZ);
+
+
+ fprintf(stderr, "[dri] Buffer map : %lx\n",
+ info->BufferMem.Start);
+
+ if (info->BufferMem.Start == 0 ||
+ info->BufferMem.End - info->BufferMem.Start >
+ I810_DMA_BUF_NR * I810_DMA_BUF_SZ) {
+ fprintf(stderr,"[dri] Not enough memory for dma buffers. Disabling DRI.\n");
+ return 0;
+ }
+
+ if (drmAddMap(ctx->drmFD, (drm_handle_t) info->BufferMem.Start,
+ info->BufferMem.Size, DRM_AGP, 0, &info->buffer_map) < 0) {
+ fprintf(stderr, "[drm] drmAddMap(buffer_map) failed. Disabling DRI.\n");
+ return 0;
+ }
+
+ if (drmAddMap(ctx->drmFD, (drm_handle_t) info->LpRing.mem.Start,
+ info->LpRing.mem.Size, DRM_AGP, 0, &info->ring_map) < 0) {
+ fprintf(stderr, "[drm] drmAddMap(ring_map) failed. Disabling DRI. \n");
+ return 0;
+ }
+
+ /* Front, back and depth buffers - everything else texture??
+ */
+ info->textureSize = info->SysMem.Size;
+
+ if (info->textureSize < 0)
+ return 0;
+
+
+ l = I810MinBits((info->textureSize-1) / I810_NR_TEX_REGIONS);
+ if (l < I810_LOG_MIN_TEX_REGION_SIZE) l = I810_LOG_MIN_TEX_REGION_SIZE;
+
+ /* Round the texture size up to the nearest whole number of
+ * texture regions. Again, be greedy about this, don't
+ * round down.
+ */
+ info->logTextureGranularity = l;
+ info->textureSize = (info->textureSize >> l) << l;
+
+ /* Set a minimum usable local texture heap size. This will fit
+ * two 256x256x32bpp textures.
+ */
+ if (info->textureSize < 512 * 1024) {
+ info->textureOffset = 0;
+ info->textureSize = 0;
+ }
+
+ I810AllocLow(&(info->TexMem), &(info->SysMem), info->textureSize);
+
+ if (drmAddMap(ctx->drmFD, (drm_handle_t) info->TexMem.Start,
+ info->TexMem.Size, DRM_AGP, 0, &info->textures) < 0) {
+ fprintf(stderr,
+ "[drm] drmAddMap(textures) failed. Disabling DRI.\n");
+ return 0;
+ }
+
+ /* Reserve space for textures */
+ fprintf(stderr,
+ "Will use back buffer at offset 0x%x\n",
+ info->BackOffset);
+ fprintf(stderr,
+ "Will use depth buffer at offset 0x%x\n",
+ info->DepthOffset);
+ fprintf(stderr,
+ "Will use %d kb for textures at offset 0x%x\n",
+ info->TexMem.Size/1024, info->TexMem.Start);
+
+ return 1;
+}
+
+
+
+/**
+ * Called at the start of each server generation.
+ *
+ * \param ctx display handle.
+ * \param info driver private data.
+ *
+ * \return non-zero on success, or zero on failure.
+ *
+ * Performs static frame buffer allocation. Opens the DRM device and add maps
+ * to the SAREA, framebuffer and MMIO regions. Fills in \p info with more
+ * information. Creates a \e server context to grab the lock for the
+ * initialization ioctls and calls the other initilization functions in this
+ * file. Starts the CP engine via the DRM_I810_CP_START command.
+ *
+ * Setups a I810DRIRec structure to be passed to i810_dri.so for its
+ * initialization.
+ */
+static int I810ScreenInit( DRIDriverContext *ctx, I810Ptr info )
+{
+ I810DRIPtr pI810DRI;
+ int err;
+
+ usleep(100);
+ /*assert(!ctx->IsClient);*/
+
+ /* from XFree86 driver */
+ info->DepthOffset = 0x3000000;
+ info->BackOffset = 0x3800000;
+ {
+ int width_bytes = (ctx->shared.virtualWidth * ctx->cpp);
+ int maxy = ctx->shared.fbSize / width_bytes;
+
+
+ if (maxy <= ctx->shared.virtualHeight * 3) {
+ fprintf(stderr,
+ "Static buffer allocation failed -- "
+ "need at least %d kB video memory (have %d kB)\n",
+ (ctx->shared.virtualWidth * ctx->shared.virtualHeight *
+ ctx->cpp * 3 + 1023) / 1024,
+ ctx->shared.fbSize / 1024);
+ return 0;
+ }
+ }
+
+
+ info->regsSize = ctx->MMIOSize;
+ ctx->shared.SAREASize = 0x2000;
+
+ /* Note that drmOpen will try to load the kernel module, if needed. */
+ ctx->drmFD = drmOpen("i810", NULL );
+ if (ctx->drmFD < 0) {
+ fprintf(stderr, "[drm] drmOpen failed\n");
+ return 0;
+ }
+
+ if ((err = drmSetBusid(ctx->drmFD, ctx->pciBusID)) < 0) {
+ fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n",
+ ctx->drmFD, ctx->pciBusID, strerror(-err));
+ return 0;
+ }
+
+ if (drmAddMap( ctx->drmFD,
+ 0,
+ ctx->shared.SAREASize,
+ DRM_SHM,
+ DRM_CONTAINS_LOCK,
+ &ctx->shared.hSAREA) < 0)
+ {
+ fprintf(stderr, "[drm] drmAddMap failed\n");
+ return 0;
+ }
+ fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n",
+ ctx->shared.SAREASize, ctx->shared.hSAREA);
+
+ if (drmMap( ctx->drmFD,
+ ctx->shared.hSAREA,
+ ctx->shared.SAREASize,
+ (drmAddressPtr)(&ctx->pSAREA)) < 0)
+ {
+ fprintf(stderr, "[drm] drmMap failed\n");
+ return 0;
+ }
+ memset(ctx->pSAREA, 0, ctx->shared.SAREASize);
+ fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n",
+ ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize);
+
+ if (drmAddMap(ctx->drmFD,
+ ctx->MMIOStart,
+ ctx->MMIOSize,
+ DRM_REGISTERS,
+ DRM_READ_ONLY,
+ &info->regs) < 0) {
+ fprintf(stderr, "[drm] drmAddMap mmio failed\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[drm] register handle = 0x%08x\n", info->regs);
+
+ I810DRIAgpPreInit(ctx, info);
+ /* Need to AddMap the framebuffer and mmio regions here:
+ */
+ if (drmAddMap( ctx->drmFD,
+ (drm_handle_t)ctx->FBStart,
+ ctx->FBSize,
+ DRM_FRAME_BUFFER,
+#ifndef _EMBEDDED
+ 0,
+#else
+ DRM_READ_ONLY,
+#endif
+ &ctx->shared.hFrameBuffer) < 0)
+ {
+ fprintf(stderr, "[drm] drmAddMap framebuffer failed\n");
+ return 0;
+ }
+
+ fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n",
+ ctx->shared.hFrameBuffer);
+
+ /* Check the i810 DRM version */
+ if (!I810CheckDRMVersion(ctx, info)) {
+ return 0;
+ }
+
+ /* Initialize AGP */
+ if (!I810DRIAgpInit(ctx, info)) {
+ return 0;
+ }
+
+
+ /* Memory manager setup */
+ if (!I810MemoryInit(ctx, info)) {
+ return 0;
+ }
+
+ /* Initialize the SAREA private data structure */
+ {
+ I810SAREAPtr pSAREAPriv;
+ pSAREAPriv = (I810SAREAPtr)(((char*)ctx->pSAREA) +
+ sizeof(drm_sarea_t));
+ memset(pSAREAPriv, 0, sizeof(*pSAREAPriv));
+ // pSAREAPriv->pf_enabled=1;
+ }
+
+
+ /* Create a 'server' context so we can grab the lock for
+ * initialization ioctls.
+ */
+ if ((err = drmCreateContext(ctx->drmFD, &ctx->serverContext)) != 0) {
+ fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err);
+ return 0;
+ }
+
+ DRM_LOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext, 0);
+
+ /* Initialize the vertex buffers list */
+ if (!I810DRIBufInit(ctx, info)) {
+ fprintf(stderr, "I810DRIBufInit failed\n");
+ DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext);
+ return 0;
+ }
+
+ /* Initialize the kernel data structures */
+ if (!I810DRIKernelInit(ctx, info)) {
+ fprintf(stderr, "I810DRIKernelInit failed\n");
+ DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext);
+ return 0;
+ }
+
+ /* Initialize IRQ */
+ I810DRIIrqInit(ctx, info);
+
+ /* Quick hack to clear the front & back buffers. Could also use
+ * the clear ioctl to do this, but would need to setup hw state
+ * first.
+ */
+#if 0
+ memset((char *)ctx->FBAddress,
+ 0,
+ info->auxPitch * ctx->cpp * ctx->shared.virtualHeight );
+
+ memset((char *)info->backbuffer,
+ 0,
+ info->auxPitch * ctx->cpp * ctx->shared.virtualHeight );
+#endif
+
+ /* This is the struct passed to i810_dri.so for its initialization */
+ ctx->driverClientMsg = malloc(sizeof(I810DRIRec));
+ ctx->driverClientMsgSize = sizeof(I810DRIRec);
+ pI810DRI = (I810DRIPtr)ctx->driverClientMsg;
+
+ pI810DRI->regs = info->regs;
+ pI810DRI->regsSize = info->regsSize;
+ // regsMap is unused
+
+ pI810DRI->backbufferSize = info->BackBuffer.Size;
+ pI810DRI->backbuffer = info->backbuffer;
+
+ pI810DRI->depthbufferSize = info->DepthBuffer.Size;
+ pI810DRI->depthbuffer = info->depthbuffer;
+
+ pI810DRI->textures = info->textures;
+ pI810DRI->textureSize = info->textureSize;
+
+ pI810DRI->agp_buffers = info->buffer_map;
+ pI810DRI->agp_buf_size = info->BufferMem.Size;
+
+ pI810DRI->deviceID = info->Chipset;
+ pI810DRI->width = ctx->shared.virtualWidth;
+ pI810DRI->height = ctx->shared.virtualHeight;
+ pI810DRI->mem = ctx->shared.fbSize;
+ pI810DRI->cpp = ctx->bpp / 8;
+ pI810DRI->bitsPerPixel = ctx->bpp;
+ pI810DRI->fbOffset = info->FrontBuffer.Start;
+ pI810DRI->fbStride = info->auxPitch;
+
+ pI810DRI->backOffset = info->BackBuffer.Start;
+ pI810DRI->depthOffset = info->DepthBuffer.Start;
+
+ pI810DRI->auxPitch = info->auxPitch;
+ pI810DRI->auxPitchBits = info->auxPitchBits;
+
+ pI810DRI->logTextureGranularity = info->logTextureGranularity;
+ pI810DRI->textureOffset = info->TexMem.Start;
+
+ pI810DRI->ringOffset = info->LpRing.mem.Start;
+ pI810DRI->ringSize = info->LpRing.mem.Size;
+
+ // drmBufs looks unused
+ pI810DRI->irq = info->irq;
+ pI810DRI->sarea_priv_offset = sizeof(drm_sarea_t);
+
+ /* Don't release the lock now - let the VT switch handler do it. */
+ return 1;
+}
+
+
+/**
+ * \brief Validate the fbdev mode.
+ *
+ * \param ctx display handle.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Saves some registers and returns 1.
+ *
+ * \sa i810ValidateMode().
+ */
+static int i810ValidateMode( const DRIDriverContext *ctx )
+{
+ unsigned char *I810MMIO = ctx->MMIOAddress;
+ I810Ptr info = ctx->driverPrivate;
+
+ return 1;
+}
+
+
+/**
+ * \brief Examine mode returned by fbdev.
+ *
+ * \param ctx display handle.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Restores registers that fbdev has clobbered and returns 1.
+ *
+ * \sa i810ValidateMode().
+ */
+static int i810PostValidateMode( const DRIDriverContext *ctx )
+{
+ unsigned char *I810MMIO = ctx->MMIOAddress;
+ I810Ptr info = ctx->driverPrivate;
+
+ return 1;
+}
+
+
+/**
+ * \brief Initialize the framebuffer device mode
+ *
+ * \param ctx display handle.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Fills in \p info with some default values and some information from \p ctx
+ * and then calls I810ScreenInit() for the screen initialization.
+ *
+ * Before exiting clears the framebuffer memory accessing it directly.
+ */
+static int i810InitFBDev( DRIDriverContext *ctx )
+{
+ I810Ptr info = calloc(1, sizeof(*info));
+
+ {
+ int dummy = ctx->shared.virtualWidth;
+
+ switch (ctx->bpp / 8) {
+ case 1: dummy = (ctx->shared.virtualWidth + 127) & ~127; break;
+ case 2: dummy = (ctx->shared.virtualWidth + 31) & ~31; break;
+ case 3:
+ case 4: dummy = (ctx->shared.virtualWidth + 15) & ~15; break;
+ }
+
+ ctx->shared.virtualWidth = dummy;
+ }
+
+ ctx->driverPrivate = (void *)info;
+
+ info->Chipset = ctx->chipset;
+
+ if (!I810ScreenInit( ctx, info ))
+ return 0;
+
+
+ return 1;
+}
+
+
+/**
+ * \brief The screen is being closed, so clean up any state and free any
+ * resources used by the DRI.
+ *
+ * \param ctx display handle.
+ *
+ * Unmaps the SAREA, closes the DRM device file descriptor and frees the driver
+ * private data.
+ */
+static void i810HaltFBDev( DRIDriverContext *ctx )
+{
+ drmUnmap( ctx->pSAREA, ctx->shared.SAREASize );
+ drmClose(ctx->drmFD);
+
+ if (ctx->driverPrivate) {
+ free(ctx->driverPrivate);
+ ctx->driverPrivate = 0;
+ }
+}
+
+
+extern void i810NotifyFocus( int );
+
+/**
+ * \brief Exported driver interface for Mini GLX.
+ *
+ * \sa DRIDriverRec.
+ */
+const struct DRIDriverRec __driDriver = {
+ i810ValidateMode,
+ i810PostValidateMode,
+ i810InitFBDev,
+ i810HaltFBDev,
+ I810EngineShutdown,
+ I810EngineRestore,
+#ifndef _EMBEDDED
+ 0,
+#else
+ i810NotifyFocus,
+#endif
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/server/i810_dri.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/server/i810_dri.h
new file mode 100644
index 000000000..408a4ebb4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/server/i810_dri.h
@@ -0,0 +1,128 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.h,v 1.10 2002/12/10 01:27:04 dawes Exp $ */
+
+#ifndef _I810_DRI_
+#define _I810_DRI_
+
+#include "xf86drm.h"
+#include "i810_common.h"
+
+#define I810_MAX_DRAWABLES 256
+
+typedef struct {
+ drm_handle_t regs;
+ drmSize regsSize;
+
+ drmSize backbufferSize;
+ drm_handle_t backbuffer;
+
+ drmSize depthbufferSize;
+ drm_handle_t depthbuffer;
+
+ drm_handle_t textures;
+ int textureSize;
+
+ drm_handle_t agp_buffers;
+ drmSize agp_buf_size;
+
+ int deviceID;
+ int width;
+ int height;
+ int mem;
+ int cpp;
+ int bitsPerPixel;
+ int fbOffset;
+ int fbStride;
+
+ int backOffset;
+ int depthOffset;
+
+ int auxPitch;
+ int auxPitchBits;
+
+ int logTextureGranularity;
+ int textureOffset;
+
+ /* For non-dma direct rendering.
+ */
+ int ringOffset;
+ int ringSize;
+
+ drmBufMapPtr drmBufs;
+ int irq;
+ unsigned int sarea_priv_offset;
+
+} I810DRIRec, *I810DRIPtr;
+
+/* WARNING: Do not change the SAREA structure without changing the kernel
+ * as well */
+
+#define I810_UPLOAD_TEX0IMAGE 0x1 /* handled clientside */
+#define I810_UPLOAD_TEX1IMAGE 0x2 /* handled clientside */
+#define I810_UPLOAD_CTX 0x4
+#define I810_UPLOAD_BUFFERS 0x8
+#define I810_UPLOAD_TEX0 0x10
+#define I810_UPLOAD_TEX1 0x20
+#define I810_UPLOAD_CLIPRECTS 0x40
+
+typedef struct {
+ unsigned char next, prev; /* indices to form a circular LRU */
+ unsigned char in_use; /* owned by a client, or free? */
+ int age; /* tracked by clients to update local LRU's */
+} I810TexRegionRec, *I810TexRegionPtr;
+
+typedef struct {
+ unsigned int ContextState[I810_CTX_SETUP_SIZE];
+ unsigned int BufferState[I810_DEST_SETUP_SIZE];
+ unsigned int TexState[2][I810_TEX_SETUP_SIZE];
+ unsigned int dirty;
+
+ unsigned int nbox;
+ drm_clip_rect_t boxes[I810_NR_SAREA_CLIPRECTS];
+
+ /* Maintain an LRU of contiguous regions of texture space. If
+ * you think you own a region of texture memory, and it has an
+ * age different to the one you set, then you are mistaken and
+ * it has been stolen by another client. If global texAge
+ * hasn't changed, there is no need to walk the list.
+ *
+ * These regions can be used as a proxy for the fine-grained
+ * texture information of other clients - by maintaining them
+ * in the same lru which is used to age their own textures,
+ * clients have an approximate lru for the whole of global
+ * texture space, and can make informed decisions as to which
+ * areas to kick out. There is no need to choose whether to
+ * kick out your own texture or someone else's - simply eject
+ * them all in LRU order.
+ */
+
+ drmTextureRegion texList[I810_NR_TEX_REGIONS + 1];
+
+ /* Last elt is sentinal */
+ int texAge; /* last time texture was uploaded */
+
+ int last_enqueue; /* last time a buffer was enqueued */
+ int last_dispatch; /* age of the most recently dispatched buffer */
+ int last_quiescent; /* */
+
+ int ctxOwner; /* last context to upload state */
+
+ int vertex_prim;
+
+ int pf_enabled; /* is pageflipping allowed? */
+ int pf_active; /* is pageflipping active right now? */
+ int pf_current_page; /* which buffer is being displayed? */
+
+
+} I810SAREARec, *I810SAREAPtr;
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} I810ConfigPrivRec, *I810ConfigPrivPtr;
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} I810DRIContextRec, *I810DRIContextPtr;
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/server/i810_reg.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/server/i810_reg.h
new file mode 100644
index 000000000..c935982a7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i810/server/i810_reg.h
@@ -0,0 +1,992 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_reg.h,v 1.13 2003/02/06 04:18:04 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 <keith@tungstengraphics.com>
+ *
+ * based on the i740 driver by
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ *
+ */
+
+#ifndef _I810_REG_H
+#define _I810_REG_H
+
+/* I/O register offsets
+ */
+#define SRX 0x3C4 /* p208 */
+#define GRX 0x3CE /* p213 */
+#define ARX 0x3C0 /* p224 */
+
+/* VGA Color Palette Registers */
+#define DACMASK 0x3C6 /* p232 */
+#define DACSTATE 0x3C7 /* p232 */
+#define DACRX 0x3C7 /* p233 */
+#define DACWX 0x3C8 /* p233 */
+#define DACDATA 0x3C9 /* p233 */
+
+/* CRT Controller Registers (CRX) */
+#define START_ADDR_HI 0x0C /* p246 */
+#define START_ADDR_LO 0x0D /* p247 */
+#define VERT_SYNC_END 0x11 /* p249 */
+#define EXT_VERT_TOTAL 0x30 /* p257 */
+#define EXT_VERT_DISPLAY 0x31 /* p258 */
+#define EXT_VERT_SYNC_START 0x32 /* p259 */
+#define EXT_VERT_BLANK_START 0x33 /* p260 */
+#define EXT_HORIZ_TOTAL 0x35 /* p261 */
+#define EXT_HORIZ_BLANK 0x39 /* p261 */
+#define EXT_START_ADDR 0x40 /* p262 */
+#define EXT_START_ADDR_ENABLE 0x80
+#define EXT_OFFSET 0x41 /* p263 */
+#define EXT_START_ADDR_HI 0x42 /* p263 */
+#define INTERLACE_CNTL 0x70 /* p264 */
+#define INTERLACE_ENABLE 0x80
+#define INTERLACE_DISABLE 0x00
+
+/* Miscellaneous Output Register
+ */
+#define MSR_R 0x3CC /* p207 */
+#define MSR_W 0x3C2 /* p207 */
+#define IO_ADDR_SELECT 0x01
+
+#define MDA_BASE 0x3B0 /* p207 */
+#define CGA_BASE 0x3D0 /* p207 */
+
+/* CR80 - IO Control, p264
+ */
+#define IO_CTNL 0x80
+#define EXTENDED_ATTR_CNTL 0x02
+#define EXTENDED_CRTC_CNTL 0x01
+
+/* GR10 - Address mapping, p221
+ */
+#define ADDRESS_MAPPING 0x10
+#define PAGE_TO_LOCAL_MEM_ENABLE 0x10
+#define GTT_MEM_MAP_ENABLE 0x08
+#define PACKED_MODE_ENABLE 0x04
+#define LINEAR_MODE_ENABLE 0x02
+#define PAGE_MAPPING_ENABLE 0x01
+
+/* Blitter control, p378
+ */
+#define BITBLT_CNTL 0x7000c
+#define COLEXP_MODE 0x30
+#define COLEXP_8BPP 0x00
+#define COLEXP_16BPP 0x10
+#define COLEXP_24BPP 0x20
+#define COLEXP_RESERVED 0x30
+#define BITBLT_STATUS 0x01
+
+/* p375.
+ */
+#define DISPLAY_CNTL 0x70008
+#define VGA_WRAP_MODE 0x02
+#define VGA_WRAP_AT_256KB 0x00
+#define VGA_NO_WRAP 0x02
+#define GUI_MODE 0x01
+#define STANDARD_VGA_MODE 0x00
+#define HIRES_MODE 0x01
+
+/* p375
+ */
+#define PIXPIPE_CONFIG_0 0x70009
+#define DAC_8_BIT 0x80
+#define DAC_6_BIT 0x00
+#define HW_CURSOR_ENABLE 0x10
+#define EXTENDED_PALETTE 0x01
+
+/* p375
+ */
+#define PIXPIPE_CONFIG_1 0x7000a
+#define DISPLAY_COLOR_MODE 0x0F
+#define DISPLAY_VGA_MODE 0x00
+#define DISPLAY_8BPP_MODE 0x02
+#define DISPLAY_15BPP_MODE 0x04
+#define DISPLAY_16BPP_MODE 0x05
+#define DISPLAY_24BPP_MODE 0x06
+#define DISPLAY_32BPP_MODE 0x07
+
+/* p375
+ */
+#define PIXPIPE_CONFIG_2 0x7000b
+#define DISPLAY_GAMMA_ENABLE 0x08
+#define DISPLAY_GAMMA_DISABLE 0x00
+#define OVERLAY_GAMMA_ENABLE 0x04
+#define OVERLAY_GAMMA_DISABLE 0x00
+
+
+/* p380
+ */
+#define DISPLAY_BASE 0x70020
+#define DISPLAY_BASE_MASK 0x03fffffc
+
+
+/* Cursor control registers, pp383-384
+ */
+/* Desktop (845G, 865G) */
+#define CURSOR_CONTROL 0x70080
+#define CURSOR_ENABLE 0x80000000
+#define CURSOR_GAMMA_ENABLE 0x40000000
+#define CURSOR_STRIDE_MASK 0x30000000
+#define CURSOR_FORMAT_SHIFT 24
+#define CURSOR_FORMAT_MASK (0x07 << CURSOR_FORMAT_SHIFT)
+#define CURSOR_FORMAT_2C (0x00 << CURSOR_FORMAT_SHIFT)
+#define CURSOR_FORMAT_3C (0x01 << CURSOR_FORMAT_SHIFT)
+#define CURSOR_FORMAT_4C (0x02 << CURSOR_FORMAT_SHIFT)
+#define CURSOR_FORMAT_ARGB (0x04 << CURSOR_FORMAT_SHIFT)
+#define CURSOR_FORMAT_XRGB (0x05 << CURSOR_FORMAT_SHIFT)
+
+/* Mobile and i810 */
+#define CURSOR_A_CONTROL CURSOR_CONTROL
+#define CURSOR_ORIGIN_SCREEN 0x00 /* i810 only */
+#define CURSOR_ORIGIN_DISPLAY 0x1 /* i810 only */
+#define CURSOR_MODE 0x27
+#define CURSOR_MODE_DISABLE 0x00
+#define CURSOR_MODE_32_4C_AX 0x01 /* i810 only */
+#define CURSOR_MODE_64_3C 0x04
+#define CURSOR_MODE_64_4C_AX 0x05
+#define CURSOR_MODE_64_4C 0x06
+#define CURSOR_MODE_64_32B_AX 0x07
+#define CURSOR_MODE_64_ARGB_AX (0x20 | CURSOR_MODE_64_32B_AX)
+#define MCURSOR_PIPE_SELECT (1 << 28)
+#define MCURSOR_PIPE_A 0x00
+#define MCURSOR_PIPE_B (1 << 28)
+#define MCURSOR_GAMMA_ENABLE (1 << 26)
+#define MCURSOR_MEM_TYPE_LOCAL (1 << 25)
+
+
+#define CURSOR_BASEADDR 0x70084
+#define CURSOR_A_BASE CURSOR_BASEADDR
+#define CURSOR_BASEADDR_MASK 0x1FFFFF00
+#define CURSOR_A_POSITION 0x70088
+#define CURSOR_POS_SIGN 0x8000
+#define CURSOR_POS_MASK 0x007FF
+#define CURSOR_X_SHIFT 0
+#define CURSOR_Y_SHIFT 16
+#define CURSOR_X_LO 0x70088
+#define CURSOR_X_HI 0x70089
+#define CURSOR_X_POS 0x00
+#define CURSOR_X_NEG 0x80
+#define CURSOR_Y_LO 0x7008A
+#define CURSOR_Y_HI 0x7008B
+#define CURSOR_Y_POS 0x00
+#define CURSOR_Y_NEG 0x80
+
+#define CURSOR_A_PALETTE0 0x70090
+#define CURSOR_A_PALETTE1 0x70094
+#define CURSOR_A_PALETTE2 0x70098
+#define CURSOR_A_PALETTE3 0x7009C
+
+#define CURSOR_SIZE 0x700A0
+#define CURSOR_SIZE_MASK 0x3FF
+#define CURSOR_SIZE_HSHIFT 0
+#define CURSOR_SIZE_VSHIFT 12
+
+
+/* Similar registers exist in Device 0 on the i810 (pp55-65), but I'm
+ * not sure they refer to local (graphics) memory.
+ *
+ * These details are for the local memory control registers,
+ * (pp301-310). The test machines are not equiped with local memory,
+ * so nothing is tested. Only a single row seems to be supported.
+ */
+#define DRAM_ROW_TYPE 0x3000
+#define DRAM_ROW_0 0x01
+#define DRAM_ROW_0_SDRAM 0x01
+#define DRAM_ROW_0_EMPTY 0x00
+#define DRAM_ROW_CNTL_LO 0x3001
+#define DRAM_PAGE_MODE_CTRL 0x10
+#define DRAM_RAS_TO_CAS_OVRIDE 0x08
+#define DRAM_CAS_LATENCY 0x04
+#define DRAM_RAS_TIMING 0x02
+#define DRAM_RAS_PRECHARGE 0x01
+#define DRAM_ROW_CNTL_HI 0x3002
+#define DRAM_REFRESH_RATE 0x18
+#define DRAM_REFRESH_DISABLE 0x00
+#define DRAM_REFRESH_60HZ 0x08
+#define DRAM_REFRESH_FAST_TEST 0x10
+#define DRAM_REFRESH_RESERVED 0x18
+#define DRAM_SMS 0x07
+#define DRAM_SMS_NORMAL 0x00
+#define DRAM_SMS_NOP_ENABLE 0x01
+#define DRAM_SMS_ABPCE 0x02
+#define DRAM_SMS_MRCE 0x03
+#define DRAM_SMS_CBRCE 0x04
+
+/* p307
+ */
+#define DPMS_SYNC_SELECT 0x5002
+#define VSYNC_CNTL 0x08
+#define VSYNC_ON 0x00
+#define VSYNC_OFF 0x08
+#define HSYNC_CNTL 0x02
+#define HSYNC_ON 0x00
+#define HSYNC_OFF 0x02
+
+
+
+/* p317, 319
+ */
+#define VCLK2_VCO_M 0x6008 /* treat as 16 bit? (includes msbs) */
+#define VCLK2_VCO_N 0x600a
+#define VCLK2_VCO_DIV_SEL 0x6012
+
+#define VCLK_DIVISOR_VGA0 0x6000
+#define VCLK_DIVISOR_VGA1 0x6004
+#define VCLK_POST_DIV 0x6010
+
+#define POST_DIV_SELECT 0x70
+#define POST_DIV_1 0x00
+#define POST_DIV_2 0x10
+#define POST_DIV_4 0x20
+#define POST_DIV_8 0x30
+#define POST_DIV_16 0x40
+#define POST_DIV_32 0x50
+#define VCO_LOOP_DIV_BY_4M 0x00
+#define VCO_LOOP_DIV_BY_16M 0x04
+
+
+/* Instruction Parser Mode Register
+ * - p281
+ * - 2 new bits.
+ */
+#define INST_PM 0x20c0
+#define AGP_SYNC_PACKET_FLUSH_ENABLE 0x20 /* reserved */
+#define SYNC_PACKET_FLUSH_ENABLE 0x10
+#define TWO_D_INST_DISABLE 0x08
+#define THREE_D_INST_DISABLE 0x04
+#define STATE_VAR_UPDATE_DISABLE 0x02
+#define PAL_STIP_DISABLE 0x01
+
+#define INST_DONE 0x2090
+#define INST_PS 0x20c4
+
+#define MEMMODE 0x20dc
+
+
+/* Instruction parser error register. p279
+ */
+#define IPEIR 0x2088
+#define IPEHR 0x208C
+
+
+/* General error reporting regs, p296
+ */
+#define EIR 0x20B0
+#define EMR 0x20B4
+#define ESR 0x20B8
+#define IP_ERR 0x0001
+#define ERROR_RESERVED 0xffc6
+
+
+/* Interrupt Control Registers
+ * - new bits for i810
+ * - new register hwstam (mask)
+ */
+#define HWSTAM 0x2098 /* p290 */
+#define IER 0x20a0 /* p291 */
+#define IIR 0x20a4 /* p292 */
+#define IMR 0x20a8 /* p293 */
+#define ISR 0x20ac /* p294 */
+#define HW_ERROR 0x8000
+#define SYNC_STATUS_TOGGLE 0x1000
+#define DPY_0_FLIP_PENDING 0x0800
+#define DPY_1_FLIP_PENDING 0x0400 /* not implemented on i810 */
+#define OVL_0_FLIP_PENDING 0x0200
+#define OVL_1_FLIP_PENDING 0x0100 /* not implemented on i810 */
+#define DPY_0_VBLANK 0x0080
+#define DPY_0_EVENT 0x0040
+#define DPY_1_VBLANK 0x0020 /* not implemented on i810 */
+#define DPY_1_EVENT 0x0010 /* not implemented on i810 */
+#define HOST_PORT_EVENT 0x0008 /* */
+#define CAPTURE_EVENT 0x0004 /* */
+#define USER_DEFINED 0x0002
+#define BREAKPOINT 0x0001
+
+
+#define INTR_RESERVED (0x6000 | \
+ DPY_1_FLIP_PENDING | \
+ OVL_1_FLIP_PENDING | \
+ DPY_1_VBLANK | \
+ DPY_1_EVENT | \
+ HOST_PORT_EVENT | \
+ CAPTURE_EVENT )
+
+/* FIFO Watermark and Burst Length Control Register
+ *
+ * - different offset and contents on i810 (p299) (fewer bits per field)
+ * - some overlay fields added
+ * - what does it all mean?
+ */
+#define FWATER_BLC 0x20d8
+#define FWATER_BLC2 0x20dc
+#define MM_BURST_LENGTH 0x00700000
+#define MM_FIFO_WATERMARK 0x0001F000
+#define LM_BURST_LENGTH 0x00000700
+#define LM_FIFO_WATERMARK 0x0000001F
+
+
+/* Fence/Tiling ranges [0..7]
+ */
+#define FENCE 0x2000
+#define FENCE_NR 8
+
+#define I830_FENCE_START_MASK 0x07f80000
+
+#define FENCE_START_MASK 0x03F80000
+#define FENCE_X_MAJOR 0x00000000
+#define FENCE_Y_MAJOR 0x00001000
+#define FENCE_SIZE_MASK 0x00000700
+#define FENCE_SIZE_512K 0x00000000
+#define FENCE_SIZE_1M 0x00000100
+#define FENCE_SIZE_2M 0x00000200
+#define FENCE_SIZE_4M 0x00000300
+#define FENCE_SIZE_8M 0x00000400
+#define FENCE_SIZE_16M 0x00000500
+#define FENCE_SIZE_32M 0x00000600
+#define FENCE_SIZE_64M 0x00000700
+#define FENCE_PITCH_MASK 0x00000070
+#define FENCE_PITCH_1 0x00000000
+#define FENCE_PITCH_2 0x00000010
+#define FENCE_PITCH_4 0x00000020
+#define FENCE_PITCH_8 0x00000030
+#define FENCE_PITCH_16 0x00000040
+#define FENCE_PITCH_32 0x00000050
+#define FENCE_PITCH_64 0x00000060
+#define FENCE_VALID 0x00000001
+
+
+/* Registers to control page table, p274
+ */
+#define PGETBL_CTL 0x2020
+#define PGETBL_ADDR_MASK 0xFFFFF000
+#define PGETBL_ENABLE_MASK 0x00000001
+#define PGETBL_ENABLED 0x00000001
+
+/* Register containing pge table error results, p276
+ */
+#define PGE_ERR 0x2024
+#define PGE_ERR_ADDR_MASK 0xFFFFF000
+#define PGE_ERR_ID_MASK 0x00000038
+#define PGE_ERR_CAPTURE 0x00000000
+#define PGE_ERR_OVERLAY 0x00000008
+#define PGE_ERR_DISPLAY 0x00000010
+#define PGE_ERR_HOST 0x00000018
+#define PGE_ERR_RENDER 0x00000020
+#define PGE_ERR_BLITTER 0x00000028
+#define PGE_ERR_MAPPING 0x00000030
+#define PGE_ERR_CMD_PARSER 0x00000038
+#define PGE_ERR_TYPE_MASK 0x00000007
+#define PGE_ERR_INV_TABLE 0x00000000
+#define PGE_ERR_INV_PTE 0x00000001
+#define PGE_ERR_MIXED_TYPES 0x00000002
+#define PGE_ERR_PAGE_MISS 0x00000003
+#define PGE_ERR_ILLEGAL_TRX 0x00000004
+#define PGE_ERR_LOCAL_MEM 0x00000005
+#define PGE_ERR_TILED 0x00000006
+
+
+
+/* Page table entries loaded via mmio region, p323
+ */
+#define PTE_BASE 0x10000
+#define PTE_ADDR_MASK 0x3FFFF000
+#define PTE_TYPE_MASK 0x00000006
+#define PTE_LOCAL 0x00000002
+#define PTE_MAIN_UNCACHED 0x00000000
+#define PTE_MAIN_CACHED 0x00000006
+#define PTE_VALID_MASK 0x00000001
+#define PTE_VALID 0x00000001
+
+
+/* Ring buffer registers, p277, overview p19
+ */
+#define LP_RING 0x2030
+#define HP_RING 0x2040
+
+#define RING_TAIL 0x00
+#define TAIL_ADDR 0x000FFFF8
+#define I830_TAIL_MASK 0x001FFFF8
+
+#define RING_HEAD 0x04
+#define HEAD_WRAP_COUNT 0xFFE00000
+#define HEAD_WRAP_ONE 0x00200000
+#define HEAD_ADDR 0x001FFFFC
+#define I830_HEAD_MASK 0x001FFFFC
+
+#define RING_START 0x08
+#define START_ADDR 0x00FFFFF8
+#define I830_RING_START_MASK 0xFFFFF000
+
+#define RING_LEN 0x0C
+#define RING_NR_PAGES 0x000FF000
+#define I830_RING_NR_PAGES 0x001FF000
+#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
+
+
+
+/* BitBlt Instructions
+ *
+ * There are many more masks & ranges yet to add.
+ */
+#define BR00_BITBLT_CLIENT 0x40000000
+#define BR00_OP_COLOR_BLT 0x10000000
+#define BR00_OP_SRC_COPY_BLT 0x10C00000
+#define BR00_OP_FULL_BLT 0x11400000
+#define BR00_OP_MONO_SRC_BLT 0x11800000
+#define BR00_OP_MONO_SRC_COPY_BLT 0x11000000
+#define BR00_OP_MONO_PAT_BLT 0x11C00000
+#define BR00_OP_MONO_SRC_COPY_IMMEDIATE_BLT (0x61 << 22)
+#define BR00_OP_TEXT_IMMEDIATE_BLT 0xc000000
+
+
+#define BR00_TPCY_DISABLE 0x00000000
+#define BR00_TPCY_ENABLE 0x00000010
+
+#define BR00_TPCY_ROP 0x00000000
+#define BR00_TPCY_NO_ROP 0x00000020
+#define BR00_TPCY_EQ 0x00000000
+#define BR00_TPCY_NOT_EQ 0x00000040
+
+#define BR00_PAT_MSB_FIRST 0x00000000 /* ? */
+
+#define BR00_PAT_VERT_ALIGN 0x000000e0
+
+#define BR00_LENGTH 0x0000000F
+
+#define BR09_DEST_ADDR 0x03FFFFFF
+
+#define BR11_SOURCE_PITCH 0x00003FFF
+
+#define BR12_SOURCE_ADDR 0x03FFFFFF
+
+#define BR13_SOLID_PATTERN 0x80000000
+#define BR13_RIGHT_TO_LEFT 0x40000000
+#define BR13_LEFT_TO_RIGHT 0x00000000
+#define BR13_MONO_TRANSPCY 0x20000000
+#define BR13_USE_DYN_DEPTH 0x04000000
+#define BR13_DYN_8BPP 0x00000000
+#define BR13_DYN_16BPP 0x01000000
+#define BR13_DYN_24BPP 0x02000000
+#define BR13_ROP_MASK 0x00FF0000
+#define BR13_DEST_PITCH 0x0000FFFF
+#define BR13_PITCH_SIGN_BIT 0x00008000
+
+#define BR14_DEST_HEIGHT 0xFFFF0000
+#define BR14_DEST_WIDTH 0x0000FFFF
+
+#define BR15_PATTERN_ADDR 0x03FFFFFF
+
+#define BR16_SOLID_PAT_COLOR 0x00FFFFFF
+#define BR16_BACKGND_PAT_CLR 0x00FFFFFF
+
+#define BR17_FGND_PAT_CLR 0x00FFFFFF
+
+#define BR18_SRC_BGND_CLR 0x00FFFFFF
+#define BR19_SRC_FGND_CLR 0x00FFFFFF
+
+
+/* Instruction parser instructions
+ */
+
+#define INST_PARSER_CLIENT 0x00000000
+#define INST_OP_FLUSH 0x02000000
+#define INST_FLUSH_MAP_CACHE 0x00000001
+
+
+#define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23))
+
+
+/* Registers in the i810 host-pci bridge pci config space which affect
+ * the i810 graphics operations.
+ */
+#define SMRAM_MISCC 0x70
+#define GMS 0x000000c0
+#define GMS_DISABLE 0x00000000
+#define GMS_ENABLE_BARE 0x00000040
+#define GMS_ENABLE_512K 0x00000080
+#define GMS_ENABLE_1M 0x000000c0
+#define USMM 0x00000030
+#define USMM_DISABLE 0x00000000
+#define USMM_TSEG_ZERO 0x00000010
+#define USMM_TSEG_512K 0x00000020
+#define USMM_TSEG_1M 0x00000030
+#define GFX_MEM_WIN_SIZE 0x00010000
+#define GFX_MEM_WIN_32M 0x00010000
+#define GFX_MEM_WIN_64M 0x00000000
+
+/* Overkill? I don't know. Need to figure out top of mem to make the
+ * SMRAM calculations come out. Linux seems to have problems
+ * detecting it all on its own, so this seems a reasonable double
+ * check to any user supplied 'mem=...' boot param.
+ *
+ * ... unfortunately this reg doesn't work according to spec on the
+ * test hardware.
+ */
+#define WHTCFG_PAMR_DRP 0x50
+#define SYS_DRAM_ROW_0_SHIFT 16
+#define SYS_DRAM_ROW_1_SHIFT 20
+#define DRAM_MASK 0x0f
+#define DRAM_VALUE_0 0
+#define DRAM_VALUE_1 8
+/* No 2 value defined */
+#define DRAM_VALUE_3 16
+#define DRAM_VALUE_4 16
+#define DRAM_VALUE_5 24
+#define DRAM_VALUE_6 32
+#define DRAM_VALUE_7 32
+#define DRAM_VALUE_8 48
+#define DRAM_VALUE_9 64
+#define DRAM_VALUE_A 64
+#define DRAM_VALUE_B 96
+#define DRAM_VALUE_C 128
+#define DRAM_VALUE_D 128
+#define DRAM_VALUE_E 192
+#define DRAM_VALUE_F 256 /* nice one, geezer */
+#define LM_FREQ_MASK 0x10
+#define LM_FREQ_133 0x10
+#define LM_FREQ_100 0x00
+
+
+
+
+/* These are 3d state registers, but the state is invarient, so we let
+ * the X server handle it:
+ */
+
+
+
+/* GFXRENDERSTATE_COLOR_CHROMA_KEY, p135
+ */
+#define GFX_OP_COLOR_CHROMA_KEY ((0x3<<29)|(0x1d<<24)|(0x2<<16)|0x1)
+#define CC1_UPDATE_KILL_WRITE (1<<28)
+#define CC1_ENABLE_KILL_WRITE (1<<27)
+#define CC1_DISABLE_KILL_WRITE 0
+#define CC1_UPDATE_COLOR_IDX (1<<26)
+#define CC1_UPDATE_CHROMA_LOW (1<<25)
+#define CC1_UPDATE_CHROMA_HI (1<<24)
+#define CC1_CHROMA_LOW_MASK ((1<<24)-1)
+#define CC2_COLOR_IDX_SHIFT 24
+#define CC2_COLOR_IDX_MASK (0xff<<24)
+#define CC2_CHROMA_HI_MASK ((1<<24)-1)
+
+
+#define GFX_CMD_CONTEXT_SEL ((0<<29)|(0x5<<23))
+#define CS_UPDATE_LOAD (1<<17)
+#define CS_UPDATE_USE (1<<16)
+#define CS_UPDATE_LOAD (1<<17)
+#define CS_LOAD_CTX0 0
+#define CS_LOAD_CTX1 (1<<8)
+#define CS_USE_CTX0 0
+#define CS_USE_CTX1 (1<<0)
+
+/* I810 LCD/TV registers */
+#define LCD_TV_HTOTAL 0x60000
+#define LCD_TV_C 0x60018
+#define LCD_TV_OVRACT 0x6001C
+
+#define LCD_TV_ENABLE (1 << 31)
+#define LCD_TV_VGAMOD (1 << 28)
+
+/* I830 CRTC registers */
+#define HTOTAL_A 0x60000
+#define HBLANK_A 0x60004
+#define HSYNC_A 0x60008
+#define VTOTAL_A 0x6000c
+#define VBLANK_A 0x60010
+#define VSYNC_A 0x60014
+#define PIPEASRC 0x6001c
+#define BCLRPAT_A 0x60020
+
+#define HTOTAL_B 0x61000
+#define HBLANK_B 0x61004
+#define HSYNC_B 0x61008
+#define VTOTAL_B 0x6100c
+#define VBLANK_B 0x61010
+#define VSYNC_B 0x61014
+#define PIPEBSRC 0x6101c
+#define BCLRPAT_B 0x61020
+
+#define DPLL_A 0x06014
+#define DPLL_B 0x06018
+#define FPA0 0x06040
+#define FPA1 0x06044
+
+#define I830_HTOTAL_MASK 0xfff0000
+#define I830_HACTIVE_MASK 0x7ff
+
+#define I830_HBLANKEND_MASK 0xfff0000
+#define I830_HBLANKSTART_MASK 0xfff
+
+#define I830_HSYNCEND_MASK 0xfff0000
+#define I830_HSYNCSTART_MASK 0xfff
+
+#define I830_VTOTAL_MASK 0xfff0000
+#define I830_VACTIVE_MASK 0x7ff
+
+#define I830_VBLANKEND_MASK 0xfff0000
+#define I830_VBLANKSTART_MASK 0xfff
+
+#define I830_VSYNCEND_MASK 0xfff0000
+#define I830_VSYNCSTART_MASK 0xfff
+
+#define I830_PIPEA_HORZ_MASK 0x7ff0000
+#define I830_PIPEA_VERT_MASK 0x7ff
+
+#define ADPA 0x61100
+#define ADPA_DAC_ENABLE (1<<31)
+#define ADPA_DAC_DISABLE 0
+#define ADPA_PIPE_SELECT_MASK (1<<30)
+#define ADPA_PIPE_A_SELECT 0
+#define ADPA_PIPE_B_SELECT (1<<30)
+#define ADPA_USE_VGA_HVPOLARITY (1<<15)
+#define ADPA_SETS_HVPOLARITY 0
+#define ADPA_VSYNC_CNTL_DISABLE (1<<11)
+#define ADPA_VSYNC_CNTL_ENABLE 0
+#define ADPA_HSYNC_CNTL_DISABLE (1<<10)
+#define ADPA_HSYNC_CNTL_ENABLE 0
+#define ADPA_VSYNC_ACTIVE_HIGH (1<<4)
+#define ADPA_VSYNC_ACTIVE_LOW 0
+#define ADPA_HSYNC_ACTIVE_HIGH (1<<3)
+#define ADPA_HSYNC_ACTIVE_LOW 0
+
+
+#define DVOA 0x61120
+#define DVOB 0x61140
+#define DVOC 0x61160
+#define DVO_ENABLE (1<<31)
+
+#define DVOA_SRCDIM 0x61124
+#define DVOB_SRCDIM 0x61144
+#define DVOC_SRCDIM 0x61164
+
+#define LVDS 0x61180
+
+#define PIPEACONF 0x70008
+#define PIPEACONF_ENABLE (1<<31)
+#define PIPEACONF_DISABLE 0
+#define PIPEACONF_DOUBLE_WIDE (1<<30)
+#define PIPEACONF_SINGLE_WIDE 0
+#define PIPEACONF_PIPE_UNLOCKED 0
+#define PIPEACONF_PIPE_LOCKED (1<<25)
+#define PIPEACONF_PALETTE 0
+#define PIPEACONF_GAMMA (1<<24)
+
+#define PIPEBCONF 0x71008
+#define PIPEBCONF_ENABLE (1<<31)
+#define PIPEBCONF_DISABLE 0
+#define PIPEBCONF_GAMMA (1<<24)
+#define PIPEBCONF_PALETTE 0
+
+#define DSPACNTR 0x70180
+#define DSPBCNTR 0x71180
+#define DISPLAY_PLANE_ENABLE (1<<31)
+#define DISPLAY_PLANE_DISABLE 0
+#define DISPPLANE_GAMMA_ENABLE (1<<30)
+#define DISPPLANE_GAMMA_DISABLE 0
+#define DISPPLANE_PIXFORMAT_MASK (0xf<<26)
+#define DISPPLANE_8BPP (0x2<<26)
+#define DISPPLANE_15_16BPP (0x4<<26)
+#define DISPPLANE_16BPP (0x5<<26)
+#define DISPPLANE_32BPP_NO_ALPHA (0x6<<26)
+#define DISPPLANE_32BPP (0x7<<26)
+#define DISPPLANE_STEREO_ENABLE (1<<25)
+#define DISPPLANE_STEREO_DISABLE 0
+#define DISPPLANE_SEL_PIPE_MASK (1<<24)
+#define DISPPLANE_SEL_PIPE_A 0
+#define DISPPLANE_SEL_PIPE_B (1<<24)
+#define DISPPLANE_SRC_KEY_ENABLE (1<<22)
+#define DISPPLANE_SRC_KEY_DISABLE 0
+#define DISPPLANE_LINE_DOUBLE (1<<20)
+#define DISPPLANE_NO_LINE_DOUBLE 0
+#define DISPPLANE_STEREO_POLARITY_FIRST 0
+#define DISPPLANE_STEREO_POLARITY_SECOND (1<<18)
+/* plane B only */
+#define DISPPLANE_ALPHA_TRANS_ENABLE (1<<15)
+#define DISPPLANE_ALPHA_TRANS_DISABLE 0
+#define DISPPLANE_SPRITE_ABOVE_DISPLAYA 0
+#define DISPPLANE_SPRITE_ABOVE_OVERLAY (1)
+
+#define DSPABASE 0x70184
+#define DSPASTRIDE 0x70188
+
+#define DSPBBASE 0x71184
+#define DSPBADDR DSPBBASE
+#define DSPBSTRIDE 0x71188
+
+/* Various masks for reserved bits, etc. */
+#define I830_FWATER1_MASK (~((1<<11)|(1<<10)|(1<<9)| \
+ (1<<8)|(1<<26)|(1<<25)|(1<<24)|(1<<5)|(1<<4)|(1<<3)| \
+ (1<<2)|(1<<1)|1|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16)))
+#define I830_FWATER2_MASK ~(0)
+
+#define DV0A_RESERVED ((1<<26)|(1<<25)|(1<<24)|(1<<23)|(1<<22)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<16)|(1<<5)|(1<<1)|1)
+#define DV0B_RESERVED ((1<<27)|(1<<26)|(1<<25)|(1<<24)|(1<<23)|(1<<22)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<16)|(1<<5)|(1<<1)|1)
+#define VGA0_N_DIVISOR_MASK ((1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16))
+#define VGA0_M1_DIVISOR_MASK ((1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9)|(1<<8))
+#define VGA0_M2_DIVISOR_MASK ((1<<5)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|1)
+#define VGA0_M1M2N_RESERVED ~(VGA0_N_DIVISOR_MASK|VGA0_M1_DIVISOR_MASK|VGA0_M2_DIVISOR_MASK)
+#define VGA0_POSTDIV_MASK ((1<<7)|(1<<5)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|1)
+#define VGA1_POSTDIV_MASK ((1<<15)|(1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9)|(1<<8))
+#define VGA_POSTDIV_RESERVED ~(VGA0_POSTDIV_MASK|VGA1_POSTDIV_MASK|(1<<7)|(1<<15))
+#define DPLLA_POSTDIV_MASK ((1<<23)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16))
+#define DPLLA_RESERVED ((1<<27)|(1<<26)|(1<<25)|(1<<24)|(1<<22)|(1<<15)|(1<<12)|(1<<11)|(1<<10)|(1<<9)|(1<<8)|(1<<7)|(1<<6)|(1<<5)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|1)
+#define ADPA_RESERVED ((1<<2)|(1<<1)|1|(1<<9)|(1<<8)|(1<<7)|(1<<6)|(1<<5)|(1<<30)|(1<<29)|(1<<28)|(1<<27)|(1<<26)|(1<<25)|(1<<24)|(1<<23)|(1<<22)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16))
+#define SUPER_WORD 32
+#define BURST_A_MASK ((1<<11)|(1<<10)|(1<<9)|(1<<8))
+#define BURST_B_MASK ((1<<26)|(1<<25)|(1<<24))
+#define WATER_A_MASK ((1<<5)|(1<<4)|(1<<3)|(1<<2)|(1<<1)|1)
+#define WATER_B_MASK ((1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16))
+#define WATER_RESERVED ((1<<31)|(1<<30)|(1<<29)|(1<<28)|(1<<27)|(1<<23)|(1<<22)|(1<<21)|(1<<15)|(1<<14)|(1<<13)|(1<<12)|(1<<7)|(1<<6))
+#define PIPEACONF_RESERVED ((1<<29)|(1<<28)|(1<<27)|(1<<23)|(1<<22)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16)|0xffff)
+#define PIPEBCONF_RESERVED ((1<<30)|(1<<29)|(1<<28)|(1<<27)|(1<<26)|(1<<25)|(1<<23)|(1<<22)|(1<<21)|(1<<20)|(1<<19)|(1<<18)|(1<<17)|(1<<16)|0xffff)
+#define DSPACNTR_RESERVED ((1<<23)|(1<<19)|(1<<17)|(1<<16)|0xffff)
+#define DSPBCNTR_RESERVED ((1<<23)|(1<<19)|(1<<17)|(1<<16)|0x7ffe)
+
+#define I830_GMCH_CTRL 0x52
+
+#define I830_GMCH_ENABLED 0x4
+#define I830_GMCH_MEM_MASK 0x1
+#define I830_GMCH_MEM_64M 0x1
+#define I830_GMCH_MEM_128M 0
+
+#define I830_GMCH_GMS_MASK 0x70
+#define I830_GMCH_GMS_DISABLED 0x00
+#define I830_GMCH_GMS_LOCAL 0x10
+#define I830_GMCH_GMS_STOLEN_512 0x20
+#define I830_GMCH_GMS_STOLEN_1024 0x30
+#define I830_GMCH_GMS_STOLEN_8192 0x40
+
+#define I830_RDRAM_CHANNEL_TYPE 0x03010
+#define I830_RDRAM_ND(x) (((x) & 0x20) >> 5)
+#define I830_RDRAM_DDT(x) (((x) & 0x18) >> 3)
+
+#define I855_GMCH_GMS_MASK (0x7 << 4)
+#define I855_GMCH_GMS_DISABLED 0x00
+#define I855_GMCH_GMS_STOLEN_1M (0x1 << 4)
+#define I855_GMCH_GMS_STOLEN_4M (0x2 << 4)
+#define I855_GMCH_GMS_STOLEN_8M (0x3 << 4)
+#define I855_GMCH_GMS_STOLEN_16M (0x4 << 4)
+#define I855_GMCH_GMS_STOLEN_32M (0x5 << 4)
+
+#define I85X_CAPID 0x44
+#define I85X_VARIANT_MASK 0x7
+#define I85X_VARIANT_SHIFT 5
+#define I855_GME 0x0
+#define I855_GM 0x4
+#define I852_GME 0x2
+#define I852_GM 0x5
+
+/* BLT commands */
+#define COLOR_BLT_CMD ((2<<29)|(0x40<<22)|(0x3))
+#define COLOR_BLT_WRITE_ALPHA (1<<21)
+#define COLOR_BLT_WRITE_RGB (1<<20)
+
+#define XY_COLOR_BLT_CMD ((2<<29)|(0x50<<22)|(0x4))
+#define XY_COLOR_BLT_WRITE_ALPHA (1<<21)
+#define XY_COLOR_BLT_WRITE_RGB (1<<20)
+
+#define XY_SETUP_CLIP_BLT_CMD ((2<<29)|(3<<22)|1)
+
+#define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6)
+#define XY_SRC_COPY_BLT_WRITE_ALPHA (1<<21)
+#define XY_SRC_COPY_BLT_WRITE_RGB (1<<20)
+
+#define SRC_COPY_BLT_CMD ((2<<29)|(0x43<<22)|0x4)
+#define SRC_COPY_BLT_WRITE_ALPHA (1<<21)
+#define SRC_COPY_BLT_WRITE_RGB (1<<20)
+
+#define XY_MONO_PAT_BLT_CMD ((0x2<<29)|(0x52<<22)|0x7)
+#define XY_MONO_PAT_VERT_SEED ((1<<10)|(1<<9)|(1<<8))
+#define XY_MONO_PAT_HORT_SEED ((1<<14)|(1<<13)|(1<<12))
+#define XY_MONO_PAT_BLT_WRITE_ALPHA (1<<21)
+#define XY_MONO_PAT_BLT_WRITE_RGB (1<<20)
+
+#define XY_MONO_SRC_BLT_CMD ((0x2<<29)|(0x54<<22)|(0x6))
+#define XY_MONO_SRC_BLT_WRITE_ALPHA (1<<21)
+#define XY_MONO_SRC_BLT_WRITE_RGB (1<<20)
+
+/* 3d state */
+#define STATE3D_FOG_MODE ((3<<29)|(0x1d<<24)|(0x89<<16)|2)
+#define FOG_MODE_VERTEX (1<<31)
+#define STATE3D_MAP_COORD_TRANSFORM ((3<<29)|(0x1d<<24)|(0x8c<<16))
+#define DISABLE_TEX_TRANSFORM (1<<28)
+#define TEXTURE_SET(x) (x<<29)
+#define STATE3D_RASTERIZATION_RULES ((3<<29)|(0x07<<24))
+#define POINT_RASTER_ENABLE (1<<15)
+#define POINT_RASTER_OGL (1<<13)
+#define STATE3D_VERTEX_TRANSFORM ((3<<29)|(0x1d<<24)|(0x8b<<16))
+#define DISABLE_VIEWPORT_TRANSFORM (1<<31)
+#define DISABLE_PERSPECTIVE_DIVIDE (1<<29)
+
+#define MI_SET_CONTEXT (0x18<<23)
+#define CTXT_NO_RESTORE (1)
+#define CTXT_PALETTE_SAVE_DISABLE (1<<3)
+#define CTXT_PALETTE_RESTORE_DISABLE (1<<2)
+
+/* Dword 0 */
+#define MI_VERTEX_BUFFER (0x17<<23)
+#define MI_VERTEX_BUFFER_IDX(x) (x<<20)
+#define MI_VERTEX_BUFFER_PITCH(x) (x<<13)
+#define MI_VERTEX_BUFFER_WIDTH(x) (x<<6)
+/* Dword 1 */
+#define MI_VERTEX_BUFFER_DISABLE (1)
+
+/* Overlay Flip */
+#define MI_OVERLAY_FLIP (0x11<<23)
+#define MI_OVERLAY_FLIP_CONTINUE (0<<21)
+#define MI_OVERLAY_FLIP_ON (1<<21)
+#define MI_OVERLAY_FLIP_OFF (2<<21)
+
+/* Wait for Events */
+#define MI_WAIT_FOR_EVENT (0x03<<23)
+#define MI_WAIT_FOR_OVERLAY_FLIP (1<<16)
+
+/* Flush */
+#define MI_FLUSH (0x04<<23)
+#define MI_WRITE_DIRTY_STATE (1<<4)
+#define MI_END_SCENE (1<<3)
+#define MI_INHIBIT_RENDER_CACHE_FLUSH (1<<2)
+#define MI_INVALIDATE_MAP_CACHE (1<<0)
+
+/* Noop */
+#define MI_NOOP 0x00
+#define MI_NOOP_WRITE_ID (1<<22)
+#define MI_NOOP_ID_MASK (1<<22 - 1)
+
+#define STATE3D_COLOR_FACTOR ((0x3<<29)|(0x1d<<24)|(0x01<<16))
+
+/* STATE3D_FOG_MODE stuff */
+#define ENABLE_FOG_SOURCE (1<<27)
+#define ENABLE_FOG_CONST (1<<24)
+#define ENABLE_FOG_DENSITY (1<<23)
+
+
+#define MAX_DISPLAY_PIPES 2
+
+typedef enum {
+ CrtIndex = 0,
+ TvIndex,
+ DfpIndex,
+ LfpIndex,
+ Tv2Index,
+ Dfp2Index,
+ UnknownIndex,
+ Unknown2Index,
+ NumDisplayTypes,
+ NumKnownDisplayTypes = UnknownIndex
+} DisplayType;
+
+/* What's connected to the pipes (as reported by the BIOS) */
+#define PIPE_ACTIVE_MASK 0xff
+#define PIPE_CRT_ACTIVE (1 << CrtIndex)
+#define PIPE_TV_ACTIVE (1 << TvIndex)
+#define PIPE_DFP_ACTIVE (1 << DfpIndex)
+#define PIPE_LCD_ACTIVE (1 << LfpIndex)
+#define PIPE_TV2_ACTIVE (1 << Tv2Index)
+#define PIPE_DFP2_ACTIVE (1 << Dfp2Index)
+#define PIPE_UNKNOWN_ACTIVE ((1 << UnknownIndex) | \
+ (1 << Unknown2Index))
+
+#define PIPE_SIZED_DISP_MASK (PIPE_DFP_ACTIVE | \
+ PIPE_LCD_ACTIVE | \
+ PIPE_DFP2_ACTIVE)
+
+#define PIPE_A_SHIFT 0
+#define PIPE_B_SHIFT 8
+#define PIPE_SHIFT(n) ((n) == 0 ? \
+ PIPE_A_SHIFT : PIPE_B_SHIFT)
+
+/*
+ * Some BIOS scratch area registers. The 845 (and 830?) store the amount
+ * of video memory available to the BIOS in SWF1.
+ */
+
+#define SWF0 0x71410
+#define SWF1 0x71414
+#define SWF2 0x71418
+#define SWF3 0x7141c
+#define SWF4 0x71420
+#define SWF5 0x71424
+#define SWF6 0x71428
+
+/*
+ * 855 scratch registers.
+ */
+#define SWF00 0x70410
+#define SWF01 0x70414
+#define SWF02 0x70418
+#define SWF03 0x7041c
+#define SWF04 0x70420
+#define SWF05 0x70424
+#define SWF06 0x70428
+
+#define SWF10 SWF0
+#define SWF11 SWF1
+#define SWF12 SWF2
+#define SWF13 SWF3
+#define SWF14 SWF4
+#define SWF15 SWF5
+#define SWF16 SWF6
+
+#define SWF30 0x72414
+#define SWF31 0x72418
+#define SWF32 0x7241c
+
+/*
+ * Overlay registers. These are overlay registers accessed via MMIO.
+ * Those loaded via the overlay register page are defined in i830_video.c.
+ */
+#define OVADD 0x30000
+
+#define DOVSTA 0x30008
+#define OC_BUF (0x3<<20)
+
+#define OGAMC5 0x30010
+#define OGAMC4 0x30014
+#define OGAMC3 0x30018
+#define OGAMC2 0x3001c
+#define OGAMC1 0x30020
+#define OGAMC0 0x30024
+
+
+/*
+ * Palette registers
+ */
+#define PALETTE_A 0x0a000
+#define PALETTE_B 0x0a800
+
+#endif /* _I810_REG_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/Makefile
new file mode 100644
index 000000000..3276d396e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/Makefile
@@ -0,0 +1,31 @@
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = i830_dri.so
+
+DRIVER_SOURCES = \
+ i830_context.c \
+ i830_debug.c \
+ i830_ioctl.c \
+ i830_render.c \
+ i830_screen.c \
+ i830_span.c \
+ i830_state.c \
+ i830_tex.c \
+ i830_texmem.c \
+ i830_texstate.c \
+ i830_tris.c
+
+C_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(MINIGLX_SOURCES) \
+ $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+
+
+include ../Makefile.template
+
+symlinks:
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_3d_reg.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_3d_reg.h
new file mode 100644
index 000000000..fa6f407ef
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_3d_reg.h
@@ -0,0 +1,677 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_3d_reg.h,v 1.4 2002/12/10 01:26:53 dawes Exp $ */
+#define I830_SET_FIELD( var, mask, value ) (var &= ~(mask), var |= value)
+
+#define CMD_3D (0x3<<29)
+
+/* 3DPRIMITIVE, p104 */
+#define PRIM3D_INLINE (CMD_3D | (0x1f<<24))
+#define PRIM3D_INDIRECT_SEQ ((1<<23) | PRIM3D_INLINE)
+#define PRIM3D_INDICES ((1<<23) | PRIM3D_INLINE | (1<<17))
+
+#define PRIM3D_INLINE_CNT(used) ((used / 4) - 2)
+#define PRIM3D_INDICES_CNT(num_indices) ((num_indices + 1) / 2)
+#define PRIM3D_INDIRECT_CNT(verts) (verts)
+
+#define PRIM3D_TRILIST 0
+#define PRIM3D_TRISTRIP (0x1<<18)
+#define PRIM3D_TRISTRIP_RVRSE (0x2<<18)
+#define PRIM3D_TRIFAN (0x3<<18)
+#define PRIM3D_POLY (0x4<<18)
+#define PRIM3D_LINELIST (0x5<<18)
+#define PRIM3D_LINESTRIP (0x6<<18)
+#define PRIM3D_RECTLIST (0x7<<18)
+#define PRIM3D_POINTLIST (0x8<<18)
+#define PRIM3D_DIB (0x9<<18)
+
+/* STATE3D_ANTI_ALIASING, p 123 */
+#define STATE3D_AA_CMD (CMD_3D | (0x06<<24))
+
+#define AA_LINE_ECAAR_WIDTH_ENABLE (1<<16)
+#define AA_LINE_ECAAR_WIDTH_0_5 0
+#define AA_LINE_ECAAR_WIDTH_1_0 (1<<14)
+#define AA_LINE_ECAAR_WIDTH_2_0 (2<<14)
+#define AA_LINE_ECAAR_WIDTH_4_0 (3<<14)
+
+#define AA_LINE_REGION_WIDTH_ENABLE (1<<8)
+#define AA_LINE_REGION_WIDTH_0_5 0
+#define AA_LINE_REGION_WIDTH_1_0 (1<<6)
+#define AA_LINE_REGION_WIDTH_2_0 (2<<6)
+#define AA_LINE_REGION_WIDTH_4_0 (3<<6)
+
+#define AA_LINE_ENABLE ((1<<1) | 1)
+#define AA_LINE_DISABLE (1<<1)
+
+/* STATE3D_BUFFER_INFO, p 124 */
+#define STATE3D_BUF_INFO_CMD (CMD_3D | (0x1d<<24) | (0x8e<<16) | 1)
+/* Dword 1 */
+#define BUF_3D_ID_COLOR_BACK (0x3<<24)
+#define BUF_3D_ID_DEPTH (0x7<<24)
+#define BUF_3D_USE_FENCE (1<<23)
+#define BUF_3D_TILED_SURFACE (1<<22)
+#define BUF_3D_TILE_WALK_X 0
+#define BUF_3D_TILE_WALK_Y (1<<21)
+#define BUF_3D_PITCH(x) ((x)<<2)
+/* Dword 2 */
+#define BUF_3D_ADDR(x) ((x) & ~0x3)
+
+/* STATE3D_COLOR_FACTOR_0, p127 */
+#define STATE3D_COLOR_FACTOR_CMD(stage) (CMD_3D | (0x1d<<24) | ((0x90 + (stage))<<16))
+
+/* STATE3D_CONSTANT_BLEND_COLOR, p128 */
+#define STATE3D_CONST_BLEND_COLOR_CMD (CMD_3D | (0x1d<<24) | (0x88<<16))
+
+/* STATE3D_DEFAULT_DIFFUSE, p128 */
+#define STATE3D_DFLT_DIFFUSE_CMD (CMD_3D | (0x1d<<24) | (0x99<<16))
+
+/* STATE3D_DEFAULT_SPECULAR, p129 */
+#define STATE3D_DFLT_SPEC_CMD (CMD_3D | (0x1d<<24) | (0x9a<<16))
+
+/* STATE3D_DEFAULT_Z, p129 */
+#define STATE3D_DFLT_Z_CMD (CMD_3D | (0x1d<<24) | (0x98<<16))
+
+/* STATE3D_DEST_BUFFER_VARIABLES, p130 */
+#define STATE3D_DST_BUF_VARS_CMD (CMD_3D | (0x1d<<24) | (0x85<<16))
+/* Dword 1 */
+#define DSTORG_HORT_BIAS(x) ((x)<<20)
+#define DSTORG_VERT_BIAS(x) ((x)<<16)
+#define COLOR_4_2_2_CHNL_WRT_ALL 0
+#define COLOR_4_2_2_CHNL_WRT_Y (1<<12)
+#define COLOR_4_2_2_CHNL_WRT_CR (2<<12)
+#define COLOR_4_2_2_CHNL_WRT_CB (3<<12)
+#define COLOR_4_2_2_CHNL_WRT_CRCB (4<<12)
+#define COLR_BUF_8BIT 0
+#define COLR_BUF_RGB555 (1<<8)
+#define COLR_BUF_RGB565 (2<<8)
+#define COLR_BUF_ARGB8888 (3<<8)
+#define DEPTH_IS_Z 0
+#define DEPTH_IS_W (1<<6)
+#define DEPTH_FRMT_16_FIXED 0
+#define DEPTH_FRMT_16_FLOAT (1<<2)
+#define DEPTH_FRMT_24_FIXED_8_OTHER (2<<2)
+#define DEPTH_FRMT_24_FLOAT_8_OTHER (3<<2)
+#define VERT_LINE_STRIDE_1 (1<<1)
+#define VERT_LINE_STRIDE_0 0
+#define VERT_LINE_STRIDE_OFS_1 1
+#define VERT_LINE_STRIDE_OFS_0 0
+
+/* STATE3D_DRAWING_RECTANGLE, p133 */
+#define STATE3D_DRAW_RECT_CMD (CMD_3D|(0x1d<<24)|(0x80<<16)|3)
+/* Dword 1 */
+#define DRAW_RECT_DIS_DEPTH_OFS (1<<30)
+#define DRAW_DITHER_OFS_X(x) ((x)<<26)
+#define DRAW_DITHER_OFS_Y(x) ((x)<<24)
+/* Dword 2 */
+#define DRAW_YMIN(x) ((x)<<16)
+#define DRAW_XMIN(x) (x)
+/* Dword 3 */
+#define DRAW_YMAX(x) ((x)<<16)
+#define DRAW_XMAX(x) (x)
+/* Dword 4 */
+#define DRAW_YORG(x) ((x)<<16)
+#define DRAW_XORG(x) (x)
+
+/* STATE3D_ENABLES_1, p136 */
+#define STATE3D_ENABLES_1_CMD (CMD_3D|(0x3<<24))
+#define ENABLE_LOGIC_OP_MASK ((1<<23)|(1<<22))
+#define ENABLE_LOGIC_OP ((1<<23)|(1<<22))
+#define DISABLE_LOGIC_OP (1<<23)
+#define ENABLE_STENCIL_TEST ((1<<21)|(1<<20))
+#define DISABLE_STENCIL_TEST (1<<21)
+#define ENABLE_DEPTH_BIAS ((1<<11)|(1<<10))
+#define DISABLE_DEPTH_BIAS (1<<11)
+#define ENABLE_SPEC_ADD_MASK ((1<<9)|(1<<8))
+#define ENABLE_SPEC_ADD ((1<<9)|(1<<8))
+#define DISABLE_SPEC_ADD (1<<9)
+#define ENABLE_DIS_FOG_MASK ((1<<7)|(1<<6))
+ /* prefixed I830 because ENABLE_FOG defined elsewhere */
+#define I830_ENABLE_FOG ((1<<7)|(1<<6))
+#define I830_DISABLE_FOG (1<<7)
+#define ENABLE_DIS_ALPHA_TEST_MASK ((1<<5)|(1<<4))
+#define ENABLE_ALPHA_TEST ((1<<5)|(1<<4))
+#define DISABLE_ALPHA_TEST (1<<5)
+#define ENABLE_DIS_CBLEND_MASK ((1<<3)|(1<<2))
+#define ENABLE_COLOR_BLEND ((1<<3)|(1<<2))
+#define DISABLE_COLOR_BLEND (1<<3)
+#define ENABLE_DIS_DEPTH_TEST_MASK ((1<<1)|1)
+#define ENABLE_DEPTH_TEST ((1<<1)|1)
+#define DISABLE_DEPTH_TEST (1<<1)
+
+/* STATE3D_ENABLES_2, p138 */
+#define STATE3D_ENABLES_2_CMD (CMD_3D|(0x4<<24))
+#define ENABLE_STENCIL_WRITE ((1<<21)|(1<<20))
+#define DISABLE_STENCIL_WRITE (1<<21)
+#define ENABLE_TEX_CACHE ((1<<17)|(1<<16))
+#define DISABLE_TEX_CACHE (1<<17)
+#define ENABLE_DITHER ((1<<9)|(1<<8))
+#define DISABLE_DITHER (1<<9)
+#define ENABLE_COLOR_MASK (1<<10)
+#define WRITEMASK_ALPHA (1<<7)
+#define WRITEMASK_ALPHA_SHIFT 7
+#define WRITEMASK_RED (1<<6)
+#define WRITEMASK_RED_SHIFT 6
+#define WRITEMASK_GREEN (1<<5)
+#define WRITEMASK_GREEN_SHIFT 5
+#define WRITEMASK_BLUE (1<<4)
+#define WRITEMASK_BLUE_SHIFT 4
+#define WRITEMASK_MASK ((1<<4)|(1<<5)|(1<<6)|(1<<7))
+#define ENABLE_COLOR_WRITE ((1<<3)|(1<<2))
+#define DISABLE_COLOR_WRITE (1<<3)
+#define ENABLE_DIS_DEPTH_WRITE_MASK 0x3
+#define ENABLE_DEPTH_WRITE ((1<<1)|1)
+#define DISABLE_DEPTH_WRITE (1<<1)
+
+/* STATE3D_FOG_COLOR, p139 */
+#define STATE3D_FOG_COLOR_CMD (CMD_3D|(0x15<<24))
+#define FOG_COLOR_RED(x) ((x)<<16)
+#define FOG_COLOR_GREEN(x) ((x)<<8)
+#define FOG_COLOR_BLUE(x) (x)
+
+/* STATE3D_FOG_MODE, p140 */
+#define STATE3D_FOG_MODE_CMD (CMD_3D|(0x1d<<24)|(0x89<<16)|2)
+/* Dword 1 */
+#define FOGFUNC_ENABLE (1<<31)
+#define FOGFUNC_VERTEX 0
+#define FOGFUNC_PIXEL_EXP (1<<28)
+#define FOGFUNC_PIXEL_EXP2 (2<<28)
+#define FOGFUNC_PIXEL_LINEAR (3<<28)
+#define FOGSRC_INDEX_Z (1<<27)
+#define FOGSRC_INDEX_W ((1<<27)|(1<<25))
+#define FOG_LINEAR_CONST (1<<24)
+#define FOG_CONST_1(x) ((x)<<4)
+#define ENABLE_FOG_DENSITY (1<<23)
+/* Dword 2 */
+#define FOG_CONST_2(x) (x)
+/* Dword 3 */
+#define FOG_DENSITY(x) (x)
+
+/* STATE3D_INDEPENDENT_ALPHA_BLEND, p142 */
+#define STATE3D_INDPT_ALPHA_BLEND_CMD (CMD_3D|(0x0b<<24))
+#define ENABLE_INDPT_ALPHA_BLEND ((1<<23)|(1<<22))
+#define DISABLE_INDPT_ALPHA_BLEND (1<<23)
+#define ALPHA_BLENDFUNC_MASK 0x3f0000
+#define ENABLE_ALPHA_BLENDFUNC (1<<21)
+#define ABLENDFUNC_ADD 0
+#define ABLENDFUNC_SUB (1<<16)
+#define ABLENDFUNC_RVSE_SUB (2<<16)
+#define ABLENDFUNC_MIN (3<<16)
+#define ABLENDFUNC_MAX (4<<16)
+#define SRC_DST_ABLEND_MASK 0xfff
+#define ENABLE_SRC_ABLEND_FACTOR (1<<11)
+#define SRC_ABLEND_FACT(x) ((x)<<6)
+#define ENABLE_DST_ABLEND_FACTOR (1<<5)
+#define DST_ABLEND_FACT(x) (x)
+
+#define BLEND_STATE_MASK (ALPHA_BLENDFUNC_MASK | SRC_DST_ABLEND_MASK)
+
+#define BLENDFACT_ZERO 0x01
+#define BLENDFACT_ONE 0x02
+#define BLENDFACT_SRC_COLR 0x03
+#define BLENDFACT_INV_SRC_COLR 0x04
+#define BLENDFACT_SRC_ALPHA 0x05
+#define BLENDFACT_INV_SRC_ALPHA 0x06
+#define BLENDFACT_DST_ALPHA 0x07
+#define BLENDFACT_INV_DST_ALPHA 0x08
+#define BLENDFACT_DST_COLR 0x09
+#define BLENDFACT_INV_DST_COLR 0x0a
+#define BLENDFACT_SRC_ALPHA_SATURATE 0x0b
+#define BLENDFACT_CONST_COLOR 0x0c
+#define BLENDFACT_INV_CONST_COLOR 0x0d
+#define BLENDFACT_CONST_ALPHA 0x0e
+#define BLENDFACT_INV_CONST_ALPHA 0x0f
+
+/* STATE3D_MAP_BLEND_ARG, p152 */
+#define STATE3D_MAP_BLEND_ARG_CMD(stage) (CMD_3D|(0x0e<<24)|((stage)<<20))
+
+#define TEXPIPE_COLOR 0
+#define TEXPIPE_ALPHA (1<<18)
+#define TEXPIPE_KILL (2<<18)
+#define TEXBLEND_ARG0 0
+#define TEXBLEND_ARG1 (1<<15)
+#define TEXBLEND_ARG2 (2<<15)
+#define TEXBLEND_ARG3 (3<<15)
+#define TEXBLENDARG_MODIFY_PARMS (1<<6)
+#define TEXBLENDARG_REPLICATE_ALPHA (1<<5)
+#define TEXBLENDARG_INV_ARG (1<<4)
+#define TEXBLENDARG_ONE 0
+#define TEXBLENDARG_FACTOR 0x01
+#define TEXBLENDARG_ACCUM 0x02
+#define TEXBLENDARG_DIFFUSE 0x03
+#define TEXBLENDARG_SPEC 0x04
+#define TEXBLENDARG_CURRENT 0x05
+#define TEXBLENDARG_TEXEL0 0x06
+#define TEXBLENDARG_TEXEL1 0x07
+#define TEXBLENDARG_TEXEL2 0x08
+#define TEXBLENDARG_TEXEL3 0x09
+#define TEXBLENDARG_FACTOR_N 0x0e
+
+/* STATE3D_MAP_BLEND_OP, p155 */
+#define STATE3D_MAP_BLEND_OP_CMD(stage) (CMD_3D|(0x0d<<24)|((stage)<<20))
+#if 0
+#define TEXPIPE_COLOR 0
+#define TEXPIPE_ALPHA (1<<18)
+#define TEXPIPE_KILL (2<<18)
+#endif
+#define ENABLE_TEXOUTPUT_WRT_SEL (1<<17)
+#define TEXOP_OUTPUT_CURRENT 0
+#define TEXOP_OUTPUT_ACCUM (1<<15)
+#define ENABLE_TEX_CNTRL_STAGE ((1<<12)|(1<<11))
+#define DISABLE_TEX_CNTRL_STAGE (1<<12)
+#define TEXOP_SCALE_SHIFT 9
+#define TEXOP_SCALE_1X (0 << TEXOP_SCALE_SHIFT)
+#define TEXOP_SCALE_2X (1 << TEXOP_SCALE_SHIFT)
+#define TEXOP_SCALE_4X (2 << TEXOP_SCALE_SHIFT)
+#define TEXOP_MODIFY_PARMS (1<<8)
+#define TEXOP_LAST_STAGE (1<<7)
+#define TEXBLENDOP_KILLPIXEL 0x02
+#define TEXBLENDOP_ARG1 0x01
+#define TEXBLENDOP_ARG2 0x02
+#define TEXBLENDOP_MODULATE 0x03
+#define TEXBLENDOP_ADD 0x06
+#define TEXBLENDOP_ADDSIGNED 0x07
+#define TEXBLENDOP_BLEND 0x08
+#define TEXBLENDOP_BLEND_AND_ADD 0x09
+#define TEXBLENDOP_SUBTRACT 0x0a
+#define TEXBLENDOP_DOT3 0x0b
+#define TEXBLENDOP_DOT4 0x0c
+#define TEXBLENDOP_MODULATE_AND_ADD 0x0d
+#define TEXBLENDOP_MODULATE_2X_AND_ADD 0x0e
+#define TEXBLENDOP_MODULATE_4X_AND_ADD 0x0f
+
+/* STATE3D_MAP_BUMP_TABLE, p160 TODO */
+/* STATE3D_MAP_COLOR_CHROMA_KEY, p161 TODO */
+
+/* STATE3D_MAP_COORD_SET_BINDINGS, p162 */
+#define STATE3D_MAP_COORD_SETBIND_CMD (CMD_3D|(0x1d<<24)|(0x02<<16))
+#define TEXBIND_MASK3 ((1<<15)|(1<<14)|(1<<13)|(1<<12))
+#define TEXBIND_MASK2 ((1<<11)|(1<<10)|(1<<9)|(1<<8))
+#define TEXBIND_MASK1 ((1<<7)|(1<<6)|(1<<5)|(1<<4))
+#define TEXBIND_MASK0 ((1<<3)|(1<<2)|(1<<1)|1)
+
+#define TEXBIND_SET3(x) ((x)<<12)
+#define TEXBIND_SET2(x) ((x)<<8)
+#define TEXBIND_SET1(x) ((x)<<4)
+#define TEXBIND_SET0(x) (x)
+
+#define TEXCOORDSRC_KEEP 0
+#define TEXCOORDSRC_DEFAULT 0x01
+#define TEXCOORDSRC_VTXSET_0 0x08
+#define TEXCOORDSRC_VTXSET_1 0x09
+#define TEXCOORDSRC_VTXSET_2 0x0a
+#define TEXCOORDSRC_VTXSET_3 0x0b
+#define TEXCOORDSRC_VTXSET_4 0x0c
+#define TEXCOORDSRC_VTXSET_5 0x0d
+#define TEXCOORDSRC_VTXSET_6 0x0e
+#define TEXCOORDSRC_VTXSET_7 0x0f
+
+#define MAP_UNIT(unit) ((unit)<<16)
+#define MAP_UNIT_MASK (3<<16)
+
+/* STATE3D_MAP_COORD_SETS, p164 */
+#define STATE3D_MAP_COORD_SET_CMD (CMD_3D|(0x1c<<24)|(0x01<<19))
+#define ENABLE_TEXCOORD_PARAMS (1<<15)
+#define TEXCOORDS_ARE_NORMAL (1<<14)
+#define TEXCOORDS_ARE_IN_TEXELUNITS 0
+#define TEXCOORDTYPE_CARTESIAN 0
+#define TEXCOORDTYPE_HOMOGENEOUS (1<<11)
+#define TEXCOORDTYPE_VECTOR (2<<11)
+#define ENABLE_ADDR_V_CNTL (1<<7)
+#define ENABLE_ADDR_U_CNTL (1<<3)
+#define TEXCOORD_ADDR_V_MODE(x) ((x)<<4)
+#define TEXCOORD_ADDR_U_MODE(x) (x)
+#define TEXCOORDMODE_WRAP 0
+#define TEXCOORDMODE_MIRROR 1
+#define TEXCOORDMODE_CLAMP 2
+#define TEXCOORDMODE_WRAP_SHORTEST 3
+#define TEXCOORDMODE_CLAMP_BORDER 4
+#define TEXCOORD_ADDR_V_MASK 0x70
+#define TEXCOORD_ADDR_U_MASK 0x7
+
+/* STATE3D_MAP_CUBE, p168 TODO */
+#define STATE3D_MAP_CUBE (CMD_3D|(0x1c<<24)|(0x0a<<19))
+#define CUBE_NEGX_ENABLE (1<<5)
+#define CUBE_POSX_ENABLE (1<<4)
+#define CUBE_NEGY_ENABLE (1<<3)
+#define CUBE_POSY_ENABLE (1<<2)
+#define CUBE_NEGZ_ENABLE (1<<1)
+#define CUBE_POSZ_ENABLE (1<<0)
+
+
+/* STATE3D_MODES_1, p190 */
+#define STATE3D_MODES_1_CMD (CMD_3D|(0x08<<24))
+#define BLENDFUNC_MASK 0x3f0000
+#define ENABLE_COLR_BLND_FUNC (1<<21)
+#define BLENDFUNC_ADD 0
+#define BLENDFUNC_SUB (1<<16)
+#define BLENDFUNC_RVRSE_SUB (2<<16)
+#define BLENDFUNC_MIN (3<<16)
+#define BLENDFUNC_MAX (4<<16)
+#define SRC_DST_BLND_MASK 0xfff
+#define ENABLE_SRC_BLND_FACTOR (1<<11)
+#define ENABLE_DST_BLND_FACTOR (1<<5)
+#define SRC_BLND_FACT(x) ((x)<<6)
+#define DST_BLND_FACT(x) (x)
+
+/* Use the blendfact defines for BLND_FACTOR macros */
+#if 0
+#define BLENDFACT_ZERO 0x01
+#define BLENDFACT_ONE 0x02
+#define BLENDFACT_SRC_COLR 0x03
+#define BLENDFACT_INV_SRC_COLR 0x04
+#define BLENDFACT_SRC_ALPHA 0x05
+#define BLENDFACT_INV_SRC_ALPHA 0x06
+#define BLENDFACT_DST_ALPHA 0x07
+#define BLENDFACT_INV_DST_ALPHA 0x08
+#define BLENDFACT_CONST_ALPHA 0x0e
+#define BLENDFACT_INV_CONST_ALPHA 0x0f
+#endif
+
+/* STATE3D_MODES_2, p192 */
+#define STATE3D_MODES_2_CMD (CMD_3D|(0x0f<<24))
+#define ENABLE_GLOBAL_DEPTH_BIAS (1<<22)
+#define GLOBAL_DEPTH_BIAS(x) ((x)<<14)
+#define ENABLE_ALPHA_TEST_FUNC (1<<13)
+#define ENABLE_ALPHA_REF_VALUE (1<<8)
+#define ALPHA_TEST_FUNC(x) ((x)<<9)
+#define ALPHA_REF_VALUE(x) (x)
+
+#define ALPHA_TEST_REF_MASK 0x3fff
+#define COMPAREFUNC_ALWAYS 0
+#define COMPAREFUNC_NEVER 0x1
+#define COMPAREFUNC_LESS 0x2
+#define COMPAREFUNC_EQUAL 0x3
+#define COMPAREFUNC_LEQUAL 0x4
+#define COMPAREFUNC_GREATER 0x5
+#define COMPAREFUNC_NOTEQUAL 0x6
+#define COMPAREFUNC_GEQUAL 0x7
+
+/* STATE3D_MODES_3, p193 */
+#define STATE3D_MODES_3_CMD (CMD_3D|(0x02<<24))
+#define DEPTH_TEST_FUNC_MASK 0x1f0000
+#define ENABLE_DEPTH_TEST_FUNC (1<<20)
+/* Uses COMPAREFUNC */
+#define DEPTH_TEST_FUNC(x) ((x)<<16)
+#define ENABLE_ALPHA_SHADE_MODE (1<<11)
+#define ENABLE_FOG_SHADE_MODE (1<<9)
+#define ENABLE_SPEC_SHADE_MODE (1<<7)
+#define ENABLE_COLOR_SHADE_MODE (1<<5)
+#define ALPHA_SHADE_MODE(x) ((x)<<10)
+#define FOG_SHADE_MODE(x) ((x)<<8)
+#define SPEC_SHADE_MODE(x) ((x)<<6)
+#define COLOR_SHADE_MODE(x) ((x)<<4)
+#define CULLMODE_MASK 0xf
+#define ENABLE_CULL_MODE (1<<3)
+#define CULLMODE_BOTH 0
+#define CULLMODE_NONE 1
+#define CULLMODE_CW 2
+#define CULLMODE_CCW 3
+
+#define SHADE_MODE_LINEAR 0
+#define SHADE_MODE_FLAT 0x1
+
+/* STATE3D_MODES_4, p195 */
+#define STATE3D_MODES_4_CMD (CMD_3D|(0x16<<24))
+#define ENABLE_LOGIC_OP_FUNC (1<<23)
+#define LOGIC_OP_FUNC(x) ((x)<<18)
+#define LOGICOP_MASK ((1<<18)|(1<<19)|(1<<20)|(1<<21))
+#define LOGICOP_CLEAR 0
+#define LOGICOP_NOR 0x1
+#define LOGICOP_AND_INV 0x2
+#define LOGICOP_COPY_INV 0x3
+#define LOGICOP_AND_RVRSE 0x4
+#define LOGICOP_INV 0x5
+#define LOGICOP_XOR 0x6
+#define LOGICOP_NAND 0x7
+#define LOGICOP_AND 0x8
+#define LOGICOP_EQUIV 0x9
+#define LOGICOP_NOOP 0xa
+#define LOGICOP_OR_INV 0xb
+#define LOGICOP_COPY 0xc
+#define LOGICOP_OR_RVRSE 0xd
+#define LOGICOP_OR 0xe
+#define LOGICOP_SET 0xf
+#define MODE4_ENABLE_STENCIL_TEST_MASK ((1<<17)|(0xff00))
+#define ENABLE_STENCIL_TEST_MASK (1<<17)
+#define STENCIL_TEST_MASK(x) ((x)<<8)
+#define MODE4_ENABLE_STENCIL_WRITE_MASK ((1<<16)|(0x00ff))
+#define ENABLE_STENCIL_WRITE_MASK (1<<16)
+#define STENCIL_WRITE_MASK(x) (x)
+
+/* STATE3D_MODES_5, p196 */
+#define STATE3D_MODES_5_CMD (CMD_3D|(0x0c<<24))
+#define ENABLE_SPRITE_POINT_TEX (1<<23)
+#define SPRITE_POINT_TEX_ON (1<<22)
+#define SPRITE_POINT_TEX_OFF 0
+#define FLUSH_RENDER_CACHE (1<<18)
+#define FLUSH_TEXTURE_CACHE (1<<16)
+#define FIXED_LINE_WIDTH_MASK 0xfc00
+#define ENABLE_FIXED_LINE_WIDTH (1<<15)
+#define FIXED_LINE_WIDTH(x) ((x)<<10)
+#define FIXED_POINT_WIDTH_MASK 0x3ff
+#define ENABLE_FIXED_POINT_WIDTH (1<<9)
+#define FIXED_POINT_WIDTH(x) (x)
+
+/* STATE3D_RASTERIZATION_RULES, p198 */
+#define STATE3D_RASTER_RULES_CMD (CMD_3D|(0x07<<24))
+#define ENABLE_POINT_RASTER_RULE (1<<15)
+#define OGL_POINT_RASTER_RULE (1<<13)
+#define ENABLE_LINE_STRIP_PROVOKE_VRTX (1<<8)
+#define ENABLE_TRI_FAN_PROVOKE_VRTX (1<<5)
+#define ENABLE_TRI_STRIP_PROVOKE_VRTX (1<<2)
+#define LINE_STRIP_PROVOKE_VRTX(x) ((x)<<6)
+#define TRI_FAN_PROVOKE_VRTX(x) ((x)<<3)
+#define TRI_STRIP_PROVOKE_VRTX(x) (x)
+
+/* STATE3D_SCISSOR_ENABLE, p200 */
+#define STATE3D_SCISSOR_ENABLE_CMD (CMD_3D|(0x1c<<24)|(0x10<<19))
+#define ENABLE_SCISSOR_RECT ((1<<1) | 1)
+#define DISABLE_SCISSOR_RECT (1<<1)
+
+/* STATE3D_SCISSOR_RECTANGLE_0, p201 */
+#define STATE3D_SCISSOR_RECT_0_CMD (CMD_3D|(0x1d<<24)|(0x81<<16)|1)
+/* Dword 1 */
+#define SCISSOR_RECT_0_YMIN(x) ((x)<<16)
+#define SCISSOR_RECT_0_XMIN(x) (x)
+/* Dword 2 */
+#define SCISSOR_RECT_0_YMAX(x) ((x)<<16)
+#define SCISSOR_RECT_0_XMAX(x) (x)
+
+/* STATE3D_STENCIL_TEST, p202 */
+#define STATE3D_STENCIL_TEST_CMD (CMD_3D|(0x09<<24))
+#define ENABLE_STENCIL_PARMS (1<<23)
+#define STENCIL_OPS_MASK (0xffc000)
+#define STENCIL_FAIL_OP(x) ((x)<<20)
+#define STENCIL_PASS_DEPTH_FAIL_OP(x) ((x)<<17)
+#define STENCIL_PASS_DEPTH_PASS_OP(x) ((x)<<14)
+
+#define STENCILOP_KEEP 0
+#define STENCILOP_ZERO 0x1
+#define STENCILOP_REPLACE 0x2
+#define STENCILOP_INCRSAT 0x3
+#define STENCILOP_DECRSAT 0x4
+#define STENCILOP_INCR 0x5
+#define STENCILOP_DECR 0x6
+#define STENCILOP_INVERT 0x7
+
+#define ENABLE_STENCIL_TEST_FUNC_MASK ((1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9))
+#define ENABLE_STENCIL_TEST_FUNC (1<<13)
+/* Uses COMPAREFUNC */
+#define STENCIL_TEST_FUNC(x) ((x)<<9)
+#define STENCIL_REF_VALUE_MASK ((1<<8)|0xff)
+#define ENABLE_STENCIL_REF_VALUE (1<<8)
+#define STENCIL_REF_VALUE(x) (x)
+
+/* STATE3D_VERTEX_FORMAT, p204 */
+#define STATE3D_VERTEX_FORMAT_CMD (CMD_3D|(0x05<<24))
+#define VRTX_HAS_POINT_WIDTH (1<<12)
+#define VRTX_TEX_COORD_COUNT(x) ((x)<<8)
+#define VRTX_HAS_SPEC (1<<7)
+#define VRTX_HAS_DIFFUSE (1<<6)
+#define VRTX_HAS_DEPTH_OFS (1<<5)
+#define VRTX_HAS_XYZ (1<<1)
+#define VRTX_HAS_XYZW (2<<1)
+#define VRTX_HAS_XY (3<<1)
+#define VRTX_HAS_XYW (4<<1)
+
+/* STATE3D_VERTEX_FORMAT_2, p206 */
+#define STATE3D_VERTEX_FORMAT_2_CMD (CMD_3D|(0x0a<<24))
+#define VRTX_TEX_SET_7_FMT(x) ((x)<<14)
+#define VRTX_TEX_SET_6_FMT(x) ((x)<<12)
+#define VRTX_TEX_SET_5_FMT(x) ((x)<<10)
+#define VRTX_TEX_SET_4_FMT(x) ((x)<<8)
+#define VRTX_TEX_SET_3_FMT(x) ((x)<<6)
+#define VRTX_TEX_SET_2_FMT(x) ((x)<<4)
+#define VRTX_TEX_SET_1_FMT(x) ((x)<<2)
+#define VRTX_TEX_SET_0_FMT(x) (x)
+
+#define TEXCOORDFMT_2D 0
+#define TEXCOORDFMT_3D 1
+#define TEXCOORDFMT_4D 2
+#define TEXCOORDFMT_1D 3
+
+/*New stuff picked up along the way */
+
+#define MLC_LOD_BIAS_MASK ((1<<7)-1)
+
+
+/* STATE3D_VERTEX_TRANSFORM, p207 */
+#define STATE3D_VERTEX_TRANS_CMD (CMD_3D|(0x1d<<24)|(0x8b<<16)|0)
+#define STATE3D_VERTEX_TRANS_MTX_CMD (CMD_3D|(0x1d<<24)|(0x8b<<16)|6)
+/* Dword 1 */
+#define ENABLE_VIEWPORT_TRANSFORM ((1<<31)|(1<<30))
+#define DISABLE_VIEWPORT_TRANSFORM (1<<31)
+#define ENABLE_PERSP_DIVIDE ((1<<29)|(1<<28))
+#define DISABLE_PERSP_DIVIDE (1<<29)
+#define VRTX_TRANS_LOAD_MATRICES 0x7421
+#define VRTX_TRANS_NO_LOAD_MATRICES 0x0000
+/* Dword 2 -> 7 are matrix elements */
+
+/* STATE3D_W_STATE, p209 */
+#define STATE3D_W_STATE_CMD (CMD_3D|(0x1d<<24)|(0x8d<<16)|1)
+/* Dword 1 */
+#define MAGIC_W_STATE_DWORD1 0x00000008
+/* Dword 2 */
+#define WFAR_VALUE(x) (x)
+
+/* if defining I830_ENABLE_4_TEXTURES, do it in i830_drm.h, too */
+
+#define I830PACKCOLOR4444(r,g,b,a) \
+ ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
+
+#define I830PACKCOLOR1555(r,g,b,a) \
+ ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
+ ((a) ? 0x8000 : 0))
+
+#define I830PACKCOLOR565(r,g,b) \
+ ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
+
+#define I830PACKCOLOR8888(r,g,b,a) \
+ ((a<<24) | (r<<16) | (g<<8) | b)
+
+
+/* Stipple command, carried over from the i810, apparently:
+ */
+#define GFX_OP_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16))
+#define ST1_ENABLE (1<<16)
+#define ST1_MASK (0xffff)
+
+
+
+#define STATE3D_LOAD_STATE_IMMEDIATE_2 ((0x3<<29)|(0x1d<<24)|(0x03<<16))
+#define LOAD_TEXTURE_MAP0 (1<<11)
+
+#define TM0S0_ADDRESS_MASK 0xfffffffc
+#define TM0S0_USE_FENCE (1<<1)
+
+#define TM0S1_HEIGHT_SHIFT 21
+#define TM0S1_WIDTH_SHIFT 10
+#define TM0S1_PALETTE_SELECT (1<<9)
+#define TM0S1_MAPSURF_FORMAT_MASK (0x7 << 6)
+#define TM0S1_MAPSURF_FORMAT_SHIFT 6
+#define MAPSURF_8BIT_INDEXED (0<<6)
+#define MAPSURF_8BIT (1<<6)
+#define MAPSURF_16BIT (2<<6)
+#define MAPSURF_32BIT (3<<6)
+#define MAPSURF_411 (4<<6)
+#define MAPSURF_422 (5<<6)
+#define MAPSURF_COMPRESSED (6<<6)
+#define MAPSURF_4BIT_INDEXED (7<<6)
+#define TM0S1_MT_FORMAT_MASK (0x7 << 3)
+#define TM0S1_MT_FORMAT_SHIFT 3
+#define MT_4BIT_IDX_ARGB8888 (7<<3) /* SURFACE_4BIT_INDEXED */
+#define MT_8BIT_IDX_RGB565 (0<<3) /* SURFACE_8BIT_INDEXED */
+#define MT_8BIT_IDX_ARGB1555 (1<<3)
+#define MT_8BIT_IDX_ARGB4444 (2<<3)
+#define MT_8BIT_IDX_AY88 (3<<3)
+#define MT_8BIT_IDX_ABGR8888 (4<<3)
+#define MT_8BIT_IDX_BUMP_88DVDU (5<<3)
+#define MT_8BIT_IDX_BUMP_655LDVDU (6<<3)
+#define MT_8BIT_IDX_ARGB8888 (7<<3)
+#define MT_8BIT_I8 (0<<3) /* SURFACE_8BIT */
+#define MT_8BIT_L8 (1<<3)
+#define MT_16BIT_RGB565 (0<<3) /* SURFACE_16BIT */
+#define MT_16BIT_ARGB1555 (1<<3)
+#define MT_16BIT_ARGB4444 (2<<3)
+#define MT_16BIT_AY88 (3<<3)
+#define MT_16BIT_DIB_ARGB1555_8888 (4<<3)
+#define MT_16BIT_BUMP_88DVDU (5<<3)
+#define MT_16BIT_BUMP_655LDVDU (6<<3)
+#define MT_16BIT_DIB_RGB565_8888 (7<<3)
+#define MT_32BIT_ARGB8888 (0<<3) /* SURFACE_32BIT */
+#define MT_32BIT_ABGR8888 (1<<3)
+#define MT_32BIT_BUMP_XLDVDU_8888 (6<<3)
+#define MT_32BIT_DIB_8888 (7<<3)
+#define MT_411_YUV411 (0<<3) /* SURFACE_411 */
+#define MT_422_YCRCB_SWAPY (0<<3) /* SURFACE_422 */
+#define MT_422_YCRCB_NORMAL (1<<3)
+#define MT_422_YCRCB_SWAPUV (2<<3)
+#define MT_422_YCRCB_SWAPUVY (3<<3)
+#define MT_COMPRESS_DXT1 (0<<3) /* SURFACE_COMPRESSED */
+#define MT_COMPRESS_DXT2_3 (1<<3)
+#define MT_COMPRESS_DXT4_5 (2<<3)
+#define MT_COMPRESS_FXT1 (3<<3)
+#define TM0S1_COLORSPACE_CONVERSION (1 << 2)
+#define TM0S1_TILED_SURFACE (1 << 1)
+#define TM0S1_TILE_WALK (1 << 0)
+
+#define TM0S2_PITCH_SHIFT 21
+#define TM0S2_CUBE_FACE_ENA_SHIFT 15
+#define TM0S2_MAP_FORMAT (1<<14)
+#define TM0S2_VERTICAL_LINE_STRIDE (1<<13)
+#define TM0S2_VERITCAL_LINE_STRIDE_OFF (1<<12)
+#define TM0S2_OUTPUT_CHAN_SHIFT 10
+#define TM0S2_OUTPUT_CHAN_MASK (3<<10)
+
+#define TM0S3_MIP_FILTER_MASK (0x3<<30)
+#define TM0S3_MIP_FILTER_SHIFT 30
+#define MIPFILTER_NONE 0
+#define MIPFILTER_NEAREST 1
+#define MIPFILTER_LINEAR 3
+#define TM0S3_MAG_FILTER_MASK (0x3<<28)
+#define TM0S3_MAG_FILTER_SHIFT 28
+#define TM0S3_MIN_FILTER_MASK (0x3<<26)
+#define TM0S3_MIN_FILTER_SHIFT 26
+#define FILTER_NEAREST 0
+#define FILTER_LINEAR 1
+#define FILTER_ANISOTROPIC 2
+
+#define TM0S3_LOD_BIAS_SHIFT 17
+#define TM0S3_LOD_BIAS_MASK (0x1ff<<17)
+#define TM0S3_MAX_MIP_SHIFT 9
+#define TM0S3_MAX_MIP_MASK (0xff<<9)
+#define TM0S3_MIN_MIP_SHIFT 3
+#define TM0S3_MIN_MIP_MASK (0x3f<<3)
+#define TM0S3_KILL_PIXEL (1<<2)
+#define TM0S3_KEYED_FILTER (1<<1)
+#define TM0S3_CHROMA_KEY (1<<0)
+
+
+/* STATE3D_MAP_TEXEL_STREAM, p188 */
+#define STATE3D_MAP_TEX_STREAM_CMD (CMD_3D|(0x1c<<24)|(0x05<<19))
+#define DISABLE_TEX_STREAM_BUMP (1<<12)
+#define ENABLE_TEX_STREAM_BUMP ((1<<12)|(1<<11))
+#define TEX_MODIFY_UNIT_0 0
+#define TEX_MODIFY_UNIT_1 (1<<8)
+#define ENABLE_TEX_STREAM_COORD_SET (1<<7)
+#define TEX_STREAM_COORD_SET(x) ((x)<<4)
+#define ENABLE_TEX_STREAM_MAP_IDX (1<<3)
+#define TEX_STREAM_MAP_IDX(x) (x)
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_context.c
new file mode 100644
index 000000000..45fcbd2e3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_context.c
@@ -0,0 +1,626 @@
+/**************************************************************************
+ *
+ * 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.
+ *
+ * **************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_context.c,v 1.9 2003/02/06 04:18:00 dawes Exp $ */
+
+/**
+ * \file i830_context.c
+ *
+ * Heavily Based on I810 driver written by Keith Whitwell.
+ *
+ * \author Jeff Hartmann <jhartmann@2d3d.com>
+ * \author Graeme Fisher <graeme@2d3d.co.za>
+ * \author Abraham vd Merwe <abraham@2d3d.co.za>
+ * \author Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "matrix.h"
+#include "simple_list.h"
+#include "extensions.h"
+#include "framebuffer.h"
+#include "imports.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "array_cache/acache.h"
+
+#include "tnl/t_pipeline.h"
+
+#include "drivers/common/driverfuncs.h"
+
+#include "i830_screen.h"
+#include "i830_dri.h"
+
+#include "i830_state.h"
+#include "i830_tex.h"
+#include "i830_span.h"
+#include "i830_tris.h"
+#include "i830_ioctl.h"
+
+
+#include "utils.h"
+
+#define need_GL_ARB_multisample
+#define need_GL_ARB_texture_compression
+#define need_GL_EXT_blend_color
+#define need_GL_EXT_blend_equation_separate
+#define need_GL_EXT_blend_func_separate
+#define need_GL_EXT_blend_minmax
+#define need_GL_EXT_fog_coord
+#define need_GL_EXT_secondary_color
+#include "extension_helper.h"
+
+#include "xmlpool.h" /* for symbolic values of enum-type options */
+#ifndef I830_DEBUG
+int I830_DEBUG = (0);
+#endif
+
+/***************************************
+ * Mesa's Driver Functions
+ ***************************************/
+
+#define DRIVER_DATE "20041007"
+
+
+static const GLubyte *i830DDGetString( GLcontext *ctx, GLenum name )
+{
+ const char * chipset;
+ static char buffer[128];
+
+ switch (name) {
+ case GL_VENDOR:
+ switch (I830_CONTEXT(ctx)->i830Screen->deviceID) {
+ case PCI_CHIP_845_G:
+ return (GLubyte *)"2d3D, Inc";
+
+ case PCI_CHIP_I830_M:
+ return (GLubyte *)"VA Linux, Inc";
+
+ case PCI_CHIP_I855_GM:
+ case PCI_CHIP_I865_G:
+ default:
+ return (GLubyte *)"Tungsten Graphics, Inc";
+ }
+ break;
+
+ case GL_RENDERER:
+ switch (I830_CONTEXT(ctx)->i830Screen->deviceID) {
+ case PCI_CHIP_845_G:
+ chipset = "Intel(R) 845G"; break;
+ case PCI_CHIP_I830_M:
+ chipset = "Intel(R) 830M"; break;
+ case PCI_CHIP_I855_GM:
+ chipset = "Intel(R) 852GM/855GM"; break;
+ case PCI_CHIP_I865_G:
+ chipset = "Intel(R) 865G"; break;
+ default:
+ chipset = "Unknown Intel Chipset"; break;
+ }
+
+ (void) driGetRendererString( buffer, chipset, DRIVER_DATE, 0 );
+ return (GLubyte *) buffer;
+
+ default:
+ return NULL;
+ }
+}
+
+static void i830BufferSize(GLframebuffer *buffer,
+ GLuint *width, GLuint *height)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ /* Need to lock to make sure the driDrawable is uptodate. This
+ * information is used to resize Mesa's software buffers, so it has
+ * to be correct.
+ */
+ LOCK_HARDWARE(imesa);
+ *width = imesa->driDrawable->w;
+ *height = imesa->driDrawable->h;
+ UNLOCK_HARDWARE(imesa);
+}
+
+
+/* Extension strings exported by the i830 driver.
+ */
+const struct dri_extension card_extensions[] =
+{
+ { "GL_ARB_multisample", GL_ARB_multisample_functions },
+ { "GL_ARB_multitexture", NULL },
+ { "GL_ARB_texture_border_clamp", NULL },
+ { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions },
+ { "GL_ARB_texture_env_add", NULL },
+ { "GL_ARB_texture_env_combine", NULL },
+ { "GL_ARB_texture_env_crossbar", NULL },
+ { "GL_ARB_texture_env_dot3", NULL },
+ { "GL_ARB_texture_mirrored_repeat", NULL },
+ { "GL_EXT_blend_color", GL_EXT_blend_color_functions },
+ { "GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions },
+ { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions },
+ { "GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions },
+ { "GL_EXT_blend_subtract", NULL },
+ { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions },
+ { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions },
+ { "GL_EXT_stencil_wrap", NULL },
+ { "GL_EXT_texture_edge_clamp", NULL },
+ { "GL_EXT_texture_env_combine", NULL },
+ { "GL_EXT_texture_env_dot3", NULL },
+ { "GL_EXT_texture_filter_anisotropic", NULL },
+ { "GL_EXT_texture_lod_bias", NULL },
+ { "GL_EXT_texture_rectangle", NULL },
+ { "GL_MESA_ycbcr_texture", NULL },
+ { "GL_NV_blend_square", NULL },
+ { "GL_SGIS_generate_mipmap", NULL },
+ { NULL, NULL }
+};
+
+
+extern const struct tnl_pipeline_stage _i830_render_stage;
+
+static const struct tnl_pipeline_stage *i830_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ /* REMOVE: point attenuation stage */
+#if 1
+ &_i830_render_stage, /* ADD: unclipped rastersetup-to-dma */
+#endif
+ &_tnl_render_stage,
+ 0,
+};
+
+
+static const struct dri_debug_control debug_control[] =
+{
+ { "fall", DEBUG_FALLBACKS },
+ { "tex", DEBUG_TEXTURE },
+ { "ioctl", DEBUG_IOCTL },
+ { "prim", DEBUG_PRIMS },
+ { "vert", DEBUG_VERTS },
+ { "state", DEBUG_STATE },
+ { "verb", DEBUG_VERBOSE },
+ { "dri", DEBUG_DRI },
+ { "dma", DEBUG_DMA },
+ { "san", DEBUG_SANITY },
+ { "sync", DEBUG_SYNC },
+ { "sleep", DEBUG_SLEEP },
+ { NULL, 0 }
+};
+
+
+GLboolean i830CreateContext( const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate)
+{
+ GLcontext *ctx , *shareCtx;
+ i830ContextPtr imesa;
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ i830ScreenPrivate *screen = (i830ScreenPrivate *)sPriv->private;
+ I830SAREAPtr saPriv=(I830SAREAPtr)
+ (((GLubyte *)sPriv->pSAREA)+screen->sarea_priv_offset);
+ struct dd_function_table functions;
+
+ /* Allocate i830 context */
+ imesa = (i830ContextPtr) CALLOC_STRUCT(i830_context_t);
+ if (!imesa)
+ return GL_FALSE;
+
+ /* Init default driver functions then plug in our I830-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions(&functions);
+ i830InitIoctlFuncs(&functions);
+ i830InitTextureFuncs(&functions);
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((i830ContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ imesa->glCtx = _mesa_create_context(mesaVis, shareCtx,
+ &functions, (void*) imesa);
+ if (!imesa->glCtx) {
+ FREE(imesa);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = imesa;
+
+
+ imesa->i830Screen = screen;
+ imesa->driScreen = sPriv;
+ imesa->sarea = saPriv;
+ imesa->glBuffer = NULL;
+
+ driParseConfigFiles (&imesa->optionCache, &screen->optionCache,
+ screen->driScrnPriv->myNum, "i830");
+
+ (void) memset( imesa->texture_heaps, 0, sizeof( imesa->texture_heaps ) );
+ make_empty_list( & imesa->swapped );
+
+ imesa->nr_heaps = 1;
+ imesa->texture_heaps[0] = driCreateTextureHeap( 0, imesa,
+ screen->textureSize,
+ 12,
+ I830_NR_TEX_REGIONS,
+ imesa->sarea->texList,
+ (unsigned *) & imesa->sarea->texAge, /* XXX shouldn't need cast! */
+ & imesa->swapped,
+ sizeof( struct i830_texture_object_t ),
+ (destroy_texture_object_t *) i830DestroyTexObj );
+
+ /* Set the maximum texture size small enough that we can guarantee
+ * that every texture unit can bind a maximal texture and have them
+ * in memory at once.
+ */
+
+ ctx = imesa->glCtx;
+ ctx->Const.MaxTextureUnits = driQueryOptioni(&imesa->optionCache,
+ "texture_units");
+ ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;
+ ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;
+
+ /* FIXME: driCalculateMaxTextureLevels assumes that mipmaps are tightly
+ * FIXME: packed, but they're not in Intel graphics hardware.
+ */
+ driCalculateMaxTextureLevels( imesa->texture_heaps,
+ imesa->nr_heaps,
+ & ctx->Const,
+ 4,
+ 11, /* max 2D texture size is 2048x2048 */
+ 0, /* 3D textures unsupported */
+ 0, /* cube textures unsupported. */
+ 0, /* texture rectangles unsupported. */
+ 12,
+ GL_FALSE );
+
+ ctx->Const.MaxTextureMaxAnisotropy = 2.0;
+
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 3.0;
+ ctx->Const.MaxLineWidthAA = 3.0;
+ ctx->Const.LineWidthGranularity = 1.0;
+
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = 255.0;
+ ctx->Const.MaxPointSizeAA = 3.0;
+ ctx->Const.PointSizeGranularity = 1.0;
+
+ ctx->Driver.GetBufferSize = i830BufferSize;
+ ctx->Driver.ResizeBuffers = _mesa_resize_framebuffer;
+ ctx->Driver.GetString = i830DDGetString;
+
+ /* Who owns who? */
+ ctx->DriverCtx = (void *) imesa;
+ imesa->glCtx = ctx;
+
+ /* Initialize the software rasterizer and helper modules. */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+
+ /* Install the customized pipeline: */
+ _tnl_destroy_pipeline( ctx );
+ _tnl_install_pipeline( ctx, i830_pipeline );
+
+ /* Configure swrast and T&L to match hardware characteristics: */
+ _swrast_allow_pixel_fog( ctx, GL_FALSE );
+ _swrast_allow_vertex_fog( ctx, GL_TRUE );
+ _tnl_allow_pixel_fog( ctx, GL_FALSE );
+ _tnl_allow_vertex_fog( ctx, GL_TRUE );
+
+ /* Dri stuff */
+ imesa->hHWContext = driContextPriv->hHWContext;
+ imesa->driFd = sPriv->fd;
+ /* drmLock ptr = &drm_hw_lock_t */
+ imesa->driHwLock = (drmLock *) &sPriv->pSAREA->lock;
+ imesa->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;
+
+ switch(mesaVis->depthBits) {
+ case 16:
+ imesa->depth_scale = 1.0/0xffff;
+ imesa->depth_clear_mask = ~0;
+ imesa->ClearDepth = 0xffff;
+ break;
+ case 24:
+ imesa->depth_scale = 1.0/0xffffff;
+ imesa->depth_clear_mask = 0x00ffffff;
+ imesa->stencil_clear_mask = 0xff000000;
+ imesa->ClearDepth = 0x00ffffff;
+ break;
+ case 32: /* Not supported */
+ default:
+ break;
+ }
+ /* Completely disable stenciling for now, there are some serious issues
+ * with stencil.
+ */
+#if 0
+ imesa->hw_stencil = 0;
+#endif
+
+ imesa->RenderIndex = ~0;
+ imesa->dirty = ~0;
+ imesa->upload_cliprects = GL_TRUE;
+
+ imesa->CurrentTexObj[0] = 0;
+ imesa->CurrentTexObj[1] = 0;
+
+ imesa->do_irqs = (imesa->i830Screen->irq_active &&
+ !getenv("I830_NO_IRQS"));
+
+ _math_matrix_ctr (&imesa->ViewportMatrix);
+
+ driInitExtensions( ctx, card_extensions, GL_TRUE );
+
+ if (imesa->glCtx->Mesa_DXTn) {
+ _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
+ _mesa_enable_extension( ctx, "GL_S3_s3tc" );
+ }
+ else if (driQueryOptionb (&imesa->optionCache, "force_s3tc_enable")) {
+ _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
+ }
+
+ _mesa_enable_extension( ctx, "GL_3DFX_texture_compression_FXT1" );
+
+ /* XXX these should really go right after _mesa_init_driver_functions() */
+ i830DDInitStateFuncs( ctx );
+ i830InitTriFuncs (ctx);
+ i830DDInitSpanFuncs( ctx );
+ i830DDInitState (ctx);
+
+#if DO_DEBUG
+ I830_DEBUG = driParseDebugString( getenv( "I830_DEBUG" ),
+ debug_control );
+ I830_DEBUG |= driParseDebugString( getenv( "INTEL_DEBUG" ),
+ debug_control );
+#endif
+
+ if (getenv("I830_NO_RAST") ||
+ getenv("INTEL_NO_RAST")) {
+ fprintf(stderr, "disabling 3D rasterization\n");
+ FALLBACK(imesa, I830_FALLBACK_USER, 1);
+ }
+
+ return GL_TRUE;
+}
+
+void i830DestroyContext(__DRIcontextPrivate *driContextPriv)
+{
+ i830ContextPtr imesa = (i830ContextPtr) driContextPriv->driverPrivate;
+
+ assert(imesa); /* should never be null */
+ if (imesa) {
+ GLboolean release_texture_heaps;
+
+
+ release_texture_heaps = (imesa->glCtx->Shared->RefCount == 1);
+ _swsetup_DestroyContext (imesa->glCtx);
+ _tnl_DestroyContext (imesa->glCtx);
+ _ac_DestroyContext (imesa->glCtx);
+ _swrast_DestroyContext (imesa->glCtx);
+
+ /* free the Mesa context */
+ imesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(imesa->glCtx);
+
+ if ( release_texture_heaps ) {
+ /* This share group is about to go away, free our private
+ * texture object data.
+ */
+ int i;
+
+ for ( i = 0 ; i < imesa->nr_heaps ; i++ ) {
+ driDestroyTextureHeap( imesa->texture_heaps[ i ] );
+ imesa->texture_heaps[ i ] = NULL;
+ }
+
+ assert( is_empty_list( & imesa->swapped ) );
+ }
+
+ FREE(imesa);
+ }
+}
+
+void i830XMesaSetFrontClipRects( i830ContextPtr imesa )
+{
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+
+ imesa->numClipRects = dPriv->numClipRects;
+ imesa->pClipRects = dPriv->pClipRects;
+ imesa->drawX = dPriv->x;
+ imesa->drawY = dPriv->y;
+
+ i830EmitDrawingRectangle( imesa );
+ imesa->upload_cliprects = GL_TRUE;
+}
+
+void i830XMesaSetBackClipRects( i830ContextPtr imesa )
+{
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+
+ if (imesa->sarea->pf_enabled == 0 && dPriv->numBackClipRects == 0) {
+ imesa->numClipRects = dPriv->numClipRects;
+ imesa->pClipRects = dPriv->pClipRects;
+ imesa->drawX = dPriv->x;
+ imesa->drawY = dPriv->y;
+ } else {
+ imesa->numClipRects = dPriv->numBackClipRects;
+ imesa->pClipRects = dPriv->pBackClipRects;
+ imesa->drawX = dPriv->backX;
+ imesa->drawY = dPriv->backY;
+ }
+
+ i830EmitDrawingRectangle( imesa );
+ imesa->upload_cliprects = GL_TRUE;
+}
+
+static void i830XMesaWindowMoved( i830ContextPtr imesa )
+{
+ switch (imesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) {
+ case BUFFER_BIT_FRONT_LEFT:
+ i830XMesaSetFrontClipRects( imesa );
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ i830XMesaSetBackClipRects( imesa );
+ break;
+ default:
+ /* glDrawBuffer(GL_NONE or GL_FRONT_AND_BACK): software fallback */
+ i830XMesaSetFrontClipRects( imesa );
+ }
+}
+
+GLboolean i830UnbindContext(__DRIcontextPrivate *driContextPriv)
+{
+ i830ContextPtr imesa = (i830ContextPtr) driContextPriv->driverPrivate;
+ unsigned i;
+
+ if (imesa) {
+ /* Might want to change this so texblend isn't always updated */
+ imesa->dirty |= (I830_UPLOAD_CTX |
+ I830_UPLOAD_BUFFERS |
+ I830_UPLOAD_STIPPLE |
+ I830_UPLOAD_TEXBLEND0 |
+ I830_UPLOAD_TEXBLEND1 |
+ I830_UPLOAD_TEXBLEND2 |
+ I830_UPLOAD_TEXBLEND3);
+
+ for ( i = 0 ; i < imesa->glCtx->Const.MaxTextureUnits ; i++ ) {
+ if (imesa->CurrentTexObj[i]) imesa->dirty |= I830_UPLOAD_TEX_N( i );
+ }
+ }
+ return GL_TRUE;
+}
+
+GLboolean i830MakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
+{
+
+ if (driContextPriv) {
+ i830ContextPtr imesa = (i830ContextPtr) driContextPriv->driverPrivate;
+
+ if ( imesa->driDrawable != driDrawPriv ) {
+ imesa->driDrawable = driDrawPriv;
+ i830XMesaWindowMoved( imesa );
+ imesa->mesa_drawable = driDrawPriv;
+ }
+
+ imesa->driReadable = driReadPriv;
+
+ _mesa_make_current(imesa->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate);
+ } else {
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ return GL_TRUE;
+}
+
+void i830GetLock( i830ContextPtr imesa, GLuint flags )
+{
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+ __DRIscreenPrivate *sPriv = imesa->driScreen;
+ I830SAREAPtr sarea = imesa->sarea;
+ int me = imesa->hHWContext;
+ unsigned i;
+
+ drmGetLock(imesa->driFd, imesa->hHWContext, flags);
+
+ /* 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:
+ */
+ DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv);
+
+ /* 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) {
+ imesa->upload_cliprects = GL_TRUE;
+ imesa->dirty |= (I830_UPLOAD_CTX |
+ I830_UPLOAD_BUFFERS |
+ I830_UPLOAD_STIPPLE);
+
+ for ( i = 0 ; i < imesa->glCtx->Const.MaxTextureUnits ; i++ ) {
+ if(imesa->CurrentTexObj[i]) imesa->dirty |= I830_UPLOAD_TEX_N( i );
+ if(imesa->TexBlendWordsUsed[i]) imesa->dirty |= I830_UPLOAD_TEXBLEND_N( i );
+ }
+
+ sarea->perf_boxes = imesa->perf_boxes | I830_BOX_LOST_CONTEXT;
+ sarea->ctxOwner = me;
+ }
+
+ /* Shared texture managment - if another client has played with
+ * texture space, figure out which if any of our textures have been
+ * ejected, and update our global LRU.
+ */
+
+ for ( i = 0 ; i < imesa->nr_heaps ; i++ ) {
+ DRI_AGE_TEXTURES( imesa->texture_heaps[ i ] );
+ }
+
+ if (imesa->lastStamp != dPriv->lastStamp) {
+ i830XMesaWindowMoved( imesa );
+ imesa->lastStamp = dPriv->lastStamp;
+ }
+
+ sarea->last_quiescent = -1; /* just kill it for now */
+}
+
+void i830SwapBuffers( __DRIdrawablePrivate *dPriv )
+{
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ i830ContextPtr imesa;
+ GLcontext *ctx;
+ imesa = (i830ContextPtr) dPriv->driContextPriv->driverPrivate;
+ ctx = imesa->glCtx;
+ if (ctx->Visual.doubleBufferMode) {
+ _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
+ if ( 0 /*imesa->doPageFlip*/ ) { /* doPageFlip is never set !!! */
+ i830PageFlip( dPriv );
+ } else {
+ i830CopyBuffer( dPriv );
+ }
+ }
+ } else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ _mesa_problem(NULL, "%s: drawable has no context!\n", __FUNCTION__);
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_context.h
new file mode 100644
index 000000000..de141bd4a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_context.h
@@ -0,0 +1,327 @@
+/*
+ * GLX Hardware Device Driver for Intel i830
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * 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
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ */
+
+/* Adapted for use in the I830M driver:
+ * Jeff Hartmann <jhartmann@2d3d.com>
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_context.h,v 1.7 2003/02/06 04:18:01 dawes Exp $ */
+
+#ifndef I830CONTEXT_INC
+#define I830CONTEXT_INC
+
+typedef struct i830_context_t i830Context;
+typedef struct i830_context_t *i830ContextPtr;
+typedef struct i830_texture_object_t *i830TextureObjectPtr;
+
+
+#include "mtypes.h"
+#include "drm.h"
+#include "mm.h"
+#include "tnl/t_vertex.h"
+
+#include "i830_screen.h"
+#include "i830_tex.h"
+
+#define TAG(x) i830##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+#define DV_PF_555 (1<<8)
+#define DV_PF_565 (2<<8)
+#define DV_PF_8888 (3<<8)
+
+#define I830_TEX_MAXLEVELS 10
+
+#define I830_CONTEXT(ctx) ((i830ContextPtr)(ctx->DriverCtx))
+#define GET_DISPATCH_AGE(imesa) imesa->sarea->last_dispatch
+#define GET_ENQUEUE_AGE(imesa) imesa->sarea->last_enqueue
+
+
+typedef void (*i830_tri_func)(i830ContextPtr, i830Vertex *, i830Vertex *,
+ i830Vertex *);
+typedef void (*i830_line_func)(i830ContextPtr, i830Vertex *, i830Vertex *);
+typedef void (*i830_point_func)(i830ContextPtr, i830Vertex *);
+
+#define I830_MAX_TEXTURE_UNITS 4
+
+#define I830_FALLBACK_TEXTURE 0x1
+#define I830_FALLBACK_DRAW_BUFFER 0x2
+#define I830_FALLBACK_READ_BUFFER 0x4
+#define I830_FALLBACK_COLORMASK 0x8
+#define I830_FALLBACK_RENDERMODE 0x10
+#define I830_FALLBACK_STENCIL 0x20
+#define I830_FALLBACK_STIPPLE 0x40
+#define I830_FALLBACK_USER 0x80
+
+struct i830_context_t
+{
+ GLint refcount;
+ GLcontext *glCtx;
+
+ /*From I830 stuff*/
+ int TextureMode;
+ GLuint renderindex;
+ GLuint TexBlendWordsUsed[I830_MAX_TEXTURE_UNITS];
+ GLuint TexBlend[I830_MAX_TEXTURE_UNITS][I830_TEXBLEND_SIZE];
+ GLuint Init_TexBlend[I830_MAX_TEXTURE_UNITS][I830_TEXBLEND_SIZE];
+ GLuint Init_TexBlendWordsUsed[I830_MAX_TEXTURE_UNITS];
+ GLuint Init_BufferSetup[I830_DEST_SETUP_SIZE];
+ GLuint LodBias[I830_MAX_TEXTURE_UNITS];
+
+ GLenum palette_format;
+ GLuint palette[256];
+
+
+ GLuint Init_Setup[I830_CTX_SETUP_SIZE];
+ GLuint vertex_prim;
+ drmBufPtr vertex_dma_buffer;
+
+ GLboolean mask_red;
+ GLboolean mask_green;
+ GLboolean mask_blue;
+ GLboolean mask_alpha;
+
+ GLubyte clear_red;
+ GLubyte clear_green;
+ GLubyte clear_blue;
+ GLubyte clear_alpha;
+
+ GLfloat depth_scale;
+ int depth_clear_mask;
+ int stencil_clear_mask;
+ int ClearDepth;
+ int hw_stencil;
+
+ GLuint MonoColor;
+
+ GLuint LastTexEnabled;
+ GLuint TexEnabledMask;
+
+ /* Texture object bookkeeping
+ */
+ unsigned nr_heaps;
+ driTexHeap * texture_heaps[1];
+ driTextureObject swapped;
+
+ struct i830_texture_object_t *CurrentTexObj[I830_MAX_TEXTURE_UNITS];
+
+ /* Rasterization and vertex state:
+ */
+ GLuint Fallback;
+ GLuint NewGLState;
+
+ /* Vertex state
+ */
+ GLuint vertex_size;
+ struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
+ GLuint vertex_attr_count;
+ char *verts; /* points to tnl->clipspace.vertex_buf */
+
+
+ /* State for i830tris.c.
+ */
+ GLuint RenderIndex;
+ GLmatrix ViewportMatrix;
+ GLenum render_primitive;
+ GLenum reduced_primitive;
+ GLuint hw_primitive;
+
+ drmBufPtr vertex_buffer;
+ char *vertex_addr;
+ GLuint vertex_low;
+ GLuint vertex_high;
+ GLuint vertex_last_prim;
+
+ GLboolean upload_cliprects;
+
+
+ /* Fallback rasterization functions
+ */
+ i830_point_func draw_point;
+ i830_line_func draw_line;
+ i830_tri_func draw_tri;
+
+ /* Hardware state
+ */
+ GLuint dirty; /* I810_UPLOAD_* */
+ GLuint Setup[I830_CTX_SETUP_SIZE];
+ GLuint BufferSetup[I830_DEST_SETUP_SIZE];
+ GLuint StippleSetup[I830_STP_SETUP_SIZE];
+ unsigned int lastStamp;
+ GLboolean hw_stipple;
+
+ GLenum TexEnvImageFmt[2];
+
+ /* State which can't be computed completely on the fly:
+ */
+ GLuint LcsCullMode;
+ GLuint LcsLineWidth;
+ GLuint LcsPointSize;
+
+ /* Funny mesa mirrors
+ */
+ GLuint ClearColor;
+
+ /* DRI stuff
+ */
+ GLuint needClip;
+ GLframebuffer *glBuffer;
+
+ /* These refer to the current draw (front vs. back) buffer:
+ */
+ char *drawMap; /* draw buffer address in virtual mem */
+ char *readMap;
+ int drawX; /* origin of drawable in draw buffer */
+ int drawY;
+ GLuint numClipRects; /* cliprects for that buffer */
+ drm_clip_rect_t *pClipRects;
+
+ int lastSwap;
+ int texAge;
+ int ctxAge;
+ int dirtyAge;
+ int perf_boxes;
+
+ int do_irqs;
+
+ GLboolean scissor;
+ drm_clip_rect_t draw_rect;
+ drm_clip_rect_t scissor_rect;
+
+ drm_context_t hHWContext;
+ drmLock *driHwLock;
+ int driFd;
+
+ __DRIdrawablePrivate *driDrawable; /**< DRI drawable bound to this
+ * context for drawing.
+ */
+ __DRIdrawablePrivate *driReadable; /**< DRI drawable bound to this
+ * context for reading.
+ */
+
+ /**
+ * Drawable used by Mesa for software fallbacks for reading and
+ * writing. It is set by Mesa's \c SetBuffer callback, and will always be
+ * either \c i830_context_t::driDrawable or \c i830_context_t::driReadable.
+ */
+
+ __DRIdrawablePrivate * mesa_drawable;
+
+ __DRIscreenPrivate *driScreen;
+ i830ScreenPrivate *i830Screen;
+ I830SAREAPtr sarea;
+
+ /**
+ * Configuration cache
+ */
+ driOptionCache optionCache;
+};
+
+
+#define I830_TEX_UNIT_ENABLED(unit) (1<<unit)
+#define VALID_I830_TEXTURE_OBJECT(tobj) (tobj)
+
+#define I830_CONTEXT(ctx) ((i830ContextPtr)(ctx->DriverCtx))
+#define I830_DRIVER_DATA(vb) ((i830VertexBufferPtr)((vb)->driver_data))
+#define GET_DISPATCH_AGE(imesa) imesa->sarea->last_dispatch
+#define GET_ENQUEUE_AGE(imesa) imesa->sarea->last_enqueue
+
+
+/* Lock the hardware and validate our state.
+ */
+#define LOCK_HARDWARE( imesa ) \
+do { \
+ char __ret=0; \
+ DRM_CAS(imesa->driHwLock, imesa->hHWContext, \
+ (DRM_LOCK_HELD|imesa->hHWContext), __ret); \
+ if (__ret) \
+ i830GetLock( imesa, 0 ); \
+}while (0)
+
+
+ /* Unlock the hardware using the global current context
+ */
+#define UNLOCK_HARDWARE(imesa) \
+do { \
+ imesa->perf_boxes |= imesa->sarea->perf_boxes; \
+ DRM_UNLOCK(imesa->driFd, imesa->driHwLock, imesa->hHWContext); \
+} while (0)
+
+ /* This is the wrong way to do it, I'm sure. Otherwise the drm
+ * bitches that I've already got the heavyweight lock. At worst,
+ * this is 3 ioctls. The best solution probably only gets me down
+ * to 2 ioctls in the worst case.
+ */
+#define LOCK_HARDWARE_QUIESCENT( imesa ) do { \
+ LOCK_HARDWARE( imesa ); \
+ i830RegetLockQuiescent( imesa ); \
+} while(0)
+
+
+
+extern void i830GetLock(i830ContextPtr imesa, GLuint flags);
+extern void i830EmitHwStateLocked(i830ContextPtr imesa);
+extern void i830EmitDrawingRectangle(i830ContextPtr imesa);
+extern void i830XMesaSetBackClipRects(i830ContextPtr imesa);
+extern void i830XMesaSetFrontClipRects(i830ContextPtr imesa);
+extern void i830DDExtensionsInit(GLcontext *ctx);
+extern void i830DDInitDriverFuncs(GLcontext *ctx);
+extern void i830DDUpdateHwState(GLcontext *ctx);
+
+#define SUBPIXEL_X 0.125
+#define SUBPIXEL_Y 0.125
+
+
+/* ================================================================
+ * Debugging:
+ */
+#define DO_DEBUG 1
+#if DO_DEBUG
+extern int I830_DEBUG;
+#else
+#define I830_DEBUG 0
+#endif
+
+#define DEBUG_TEXTURE 0x1
+#define DEBUG_STATE 0x2
+#define DEBUG_IOCTL 0x4
+#define DEBUG_PRIMS 0x8
+#define DEBUG_VERTS 0x10
+#define DEBUG_FALLBACKS 0x20
+#define DEBUG_VERBOSE 0x40
+#define DEBUG_DRI 0x80
+#define DEBUG_DMA 0x100
+#define DEBUG_SANITY 0x200
+#define DEBUG_SYNC 0x400
+#define DEBUG_SLEEP 0x800
+
+
+#define PCI_CHIP_845_G 0x2562
+#define PCI_CHIP_I830_M 0x3577
+#define PCI_CHIP_I855_GM 0x3582
+#define PCI_CHIP_I865_G 0x2572
+
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_debug.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_debug.c
new file mode 100644
index 000000000..eee48f1c1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_debug.c
@@ -0,0 +1,415 @@
+/**************************************************************************
+
+Copyright 2001 2d3d Inc., Delray Beach, FL
+
+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, VA LINUX SYSTEMS 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.
+
+**************************************************************************/
+
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_debug.c,v 1.3 2002/12/10 01:26:53 dawes Exp $ */
+
+/*
+ * Author:
+ * Jeff Hartmann <jhartmann@2d3d.com>
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "enums.h"
+#include "dd.h"
+
+#include "mm.h"
+
+#include "i830_screen.h"
+#include "i830_dri.h"
+
+#include "i830_context.h"
+#include "i830_state.h"
+#include "i830_tex.h"
+#include "i830_tris.h"
+#include "i830_ioctl.h"
+#include "i830_debug.h"
+
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "tnl/t_pipeline.h"
+
+
+#define TINY_VERTEX_FORMAT (STATE3D_VERTEX_FORMAT_CMD | \
+ VRTX_TEX_COORD_COUNT(0) | \
+ VRTX_HAS_DIFFUSE | \
+ VRTX_HAS_XYZ)
+
+#define NOTEX_VERTEX_FORMAT (STATE3D_VERTEX_FORMAT_CMD | \
+ VRTX_TEX_COORD_COUNT(0) | \
+ VRTX_HAS_DIFFUSE | \
+ VRTX_HAS_SPEC | \
+ VRTX_HAS_XYZW)
+
+#define TEX0_VERTEX_FORMAT (STATE3D_VERTEX_FORMAT_CMD | \
+ VRTX_TEX_COORD_COUNT(1) | \
+ VRTX_HAS_DIFFUSE | \
+ VRTX_HAS_SPEC | \
+ VRTX_HAS_XYZW)
+
+#define TEX1_VERTEX_FORMAT (STATE3D_VERTEX_FORMAT_CMD | \
+ VRTX_TEX_COORD_COUNT(2) | \
+ VRTX_HAS_DIFFUSE | \
+ VRTX_HAS_SPEC | \
+ VRTX_HAS_XYZW)
+
+#define PROJ_VF2 (STATE3D_VERTEX_FORMAT_2_CMD | \
+ VRTX_TEX_SET_0_FMT(TEXCOORDFMT_3D) | \
+ VRTX_TEX_SET_1_FMT(TEXCOORDFMT_3D) | \
+ VRTX_TEX_SET_2_FMT(TEXCOORDFMT_3D) | \
+ VRTX_TEX_SET_3_FMT(TEXCOORDFMT_3D))
+
+#define NON_PROJ_VF2 (STATE3D_VERTEX_FORMAT_2_CMD | \
+ VRTX_TEX_SET_0_FMT(TEXCOORDFMT_2D) | \
+ VRTX_TEX_SET_1_FMT(TEXCOORDFMT_2D) | \
+ VRTX_TEX_SET_2_FMT(TEXCOORDFMT_2D) | \
+ VRTX_TEX_SET_3_FMT(TEXCOORDFMT_2D))
+
+void i830DumpContextState( i830ContextPtr imesa )
+{
+ GLuint *Context = imesa->Setup;
+
+ fprintf(stderr, "%s\n", __FUNCTION__);
+ fprintf(stderr, "STATE1 : 0x%08x\n", Context[I830_CTXREG_STATE1]);
+ fprintf(stderr, "STATE2 : 0x%08x\n", Context[I830_CTXREG_STATE2]);
+ fprintf(stderr, "STATE3 : 0x%08x\n", Context[I830_CTXREG_STATE3]);
+ fprintf(stderr, "STATE4 : 0x%08x\n", Context[I830_CTXREG_STATE4]);
+ fprintf(stderr, "STATE5 : 0x%08x\n", Context[I830_CTXREG_STATE5]);
+ fprintf(stderr, "IALPHAB : 0x%08x\n", Context[I830_CTXREG_IALPHAB]);
+ fprintf(stderr, "STENCILTST : 0x%08x\n", Context[I830_CTXREG_STENCILTST]);
+ fprintf(stderr, "ENABLES_1 : 0x%08x\n", Context[I830_CTXREG_ENABLES_1]);
+ fprintf(stderr, "ENABLES_2 : 0x%08x\n", Context[I830_CTXREG_ENABLES_2]);
+ fprintf(stderr, "AA : 0x%08x\n", Context[I830_CTXREG_AA]);
+ fprintf(stderr, "FOGCOLOR : 0x%08x\n", Context[I830_CTXREG_FOGCOLOR]);
+ fprintf(stderr, "BCOLOR0 : 0x%08x\n", Context[I830_CTXREG_BLENDCOLR0]);
+ fprintf(stderr, "BCOLOR : 0x%08x\n", Context[I830_CTXREG_BLENDCOLR]);
+ fprintf(stderr, "VF : 0x%08x\n", Context[I830_CTXREG_VF]);
+ fprintf(stderr, "VF2 : 0x%08x\n", Context[I830_CTXREG_VF2]);
+ fprintf(stderr, "MCSB0 : 0x%08x\n", Context[I830_CTXREG_MCSB0]);
+ fprintf(stderr, "MCSB1 : 0x%08x\n", Context[I830_CTXREG_MCSB1]);
+}
+
+void i830DumpBufferState( i830ContextPtr imesa )
+{
+ GLuint *Buffer = imesa->BufferSetup;
+
+ fprintf(stderr, "%s\n", __FUNCTION__);
+ fprintf(stderr, "CBUFADDR : 0x%08x\n", Buffer[I830_DESTREG_CBUFADDR]);
+ fprintf(stderr, "DBUFADDR : 0x%08x\n", Buffer[I830_DESTREG_DBUFADDR]);
+ fprintf(stderr, "DV0 : 0x%08x\n", Buffer[I830_DESTREG_DV0]);
+ fprintf(stderr, "DV1 : 0x%08x\n", Buffer[I830_DESTREG_DV1]);
+ fprintf(stderr, "SENABLE : 0x%08x\n", Buffer[I830_DESTREG_SENABLE]);
+ fprintf(stderr, "SR0 : 0x%08x\n", Buffer[I830_DESTREG_SR0]);
+ fprintf(stderr, "SR1 : 0x%08x\n", Buffer[I830_DESTREG_SR1]);
+ fprintf(stderr, "SR2 : 0x%08x\n", Buffer[I830_DESTREG_SR2]);
+ fprintf(stderr, "DR0 : 0x%08x\n", Buffer[I830_DESTREG_DR0]);
+ fprintf(stderr, "DR1 : 0x%08x\n", Buffer[I830_DESTREG_DR1]);
+ fprintf(stderr, "DR2 : 0x%08x\n", Buffer[I830_DESTREG_DR2]);
+ fprintf(stderr, "DR3 : 0x%08x\n", Buffer[I830_DESTREG_DR3]);
+ fprintf(stderr, "DR4 : 0x%08x\n", Buffer[I830_DESTREG_DR4]);
+}
+
+void i830DumpStippleState( i830ContextPtr imesa )
+{
+ GLuint *Buffer = imesa->BufferSetup;
+
+ fprintf(stderr, "%s\n", __FUNCTION__);
+ fprintf(stderr, "ST1 : 0x%08x\n", Buffer[I830_STPREG_ST1]);
+}
+
+void i830DumpTextureState( i830ContextPtr imesa, int unit )
+{
+ i830TextureObjectPtr t = imesa->CurrentTexObj[unit];
+
+ if(t) {
+ fprintf(stderr, "%s : unit %d\n", __FUNCTION__, unit);
+ fprintf(stderr, "TM0LI : 0x%08x\n", t->Setup[I830_TEXREG_TM0LI]);
+ fprintf(stderr, "TM0S0 : 0x%08x\n", t->Setup[I830_TEXREG_TM0S0]);
+ fprintf(stderr, "TM0S1 : 0x%08x\n", t->Setup[I830_TEXREG_TM0S1]);
+ fprintf(stderr, "TM0S2 : 0x%08x\n", t->Setup[I830_TEXREG_TM0S2]);
+ fprintf(stderr, "TM0S3 : 0x%08x\n", t->Setup[I830_TEXREG_TM0S3]);
+ fprintf(stderr, "TM0S4 : 0x%08x\n", t->Setup[I830_TEXREG_TM0S4]);
+ fprintf(stderr, "NOP0 : 0x%08x\n", t->Setup[I830_TEXREG_NOP0]);
+ fprintf(stderr, "NOP1 : 0x%08x\n", t->Setup[I830_TEXREG_NOP1]);
+ fprintf(stderr, "NOP2 : 0x%08x\n", t->Setup[I830_TEXREG_NOP2]);
+ fprintf(stderr, "MCS : 0x%08x\n", t->Setup[I830_TEXREG_MCS]);
+ }
+}
+
+void i830DumpTextureBlendState( i830ContextPtr imesa, int unit )
+{
+ GLuint *TexBlend = imesa->TexBlend[unit];
+ GLuint length = imesa->TexBlendWordsUsed[unit];
+ int i;
+
+ fprintf(stderr, "%s : unit %d : length %d\n", __FUNCTION__, unit, length);
+ for(i = 0; i < length; i++) {
+ fprintf(stderr, "[%d] : 0x%08x\n", i, TexBlend[i]);
+ }
+}
+
+void i830VertexSanity( i830ContextPtr imesa, drmI830Vertex vertex )
+{
+ I830SAREAPtr sarea = imesa->sarea;
+ char *prim_name;
+ int size = 0;
+ int vfmt_size = 0;
+ int hw_nr_vertex = 0;
+ int hw_start_vertex = 0;
+
+ /* Do a bunch of sanity checks on the vertices sent to the hardware */
+
+ size = vertex.used - 4;
+ if(imesa->vertex_size && (size % imesa->vertex_size) != 0) {
+ fprintf(stderr, "\n\nVertex size does not match imesa "
+ "internal state\n");
+ fprintf(stderr, "Buffer size : %d\n", size);
+ fprintf(stderr, "Vertex size : %d\n", imesa->vertex_size);
+ }
+
+ /* Check to see if the vertex format is good, and get its size */
+ if (sarea->ContextState[I830_CTXREG_VF] == TINY_VERTEX_FORMAT) {
+ vfmt_size = 16; /* 4 dwords */
+ } else if (sarea->ContextState[I830_CTXREG_VF] ==
+ NOTEX_VERTEX_FORMAT) {
+ vfmt_size = 24; /* 6 dwords */
+ } else if (sarea->ContextState[I830_CTXREG_VF] ==
+ TEX0_VERTEX_FORMAT) {
+ vfmt_size = 32; /* 8 dwords */
+ if (sarea->ContextState[I830_CTXREG_VF2] != NON_PROJ_VF2) {
+ fprintf(stderr, "\n\nTex 0 vertex format, but proj "
+ "texturing\n");
+ }
+ } else if(sarea->ContextState[I830_CTXREG_VF] ==
+ TEX1_VERTEX_FORMAT) {
+ if (sarea->ContextState[I830_CTXREG_VF2] == NON_PROJ_VF2)
+ vfmt_size = 40; /* 10 dwords */
+ else
+ vfmt_size = 48; /* 12 dwords */
+ } else {
+ fprintf(stderr, "\n\nUnknown vertex format : vf : %08x "
+ "vf2 : %08x\n",
+ sarea->ContextState[I830_CTXREG_VF],
+ sarea->ContextState[I830_CTXREG_VF2]);
+ }
+
+ if(vfmt_size && (size % vfmt_size) != 0) {
+ fprintf(stderr, "\n\nVertex size does not match hardware "
+ "internal state\n");
+ fprintf(stderr, "Buffer size : %d\n", size);
+ fprintf(stderr, "Vertex size : %d\n", vfmt_size);
+ }
+
+ switch(sarea->vertex_prim) {
+ case PRIM3D_POINTLIST:
+ hw_start_vertex = 0;
+ hw_nr_vertex = 1;
+ prim_name = "PointList";
+ break;
+
+ case PRIM3D_LINELIST:
+ hw_start_vertex = 0;
+ hw_nr_vertex = 2;
+ prim_name = "LineList";
+ break;
+
+ case PRIM3D_LINESTRIP:
+ hw_start_vertex = 2;
+ hw_nr_vertex = 1;
+ prim_name = "LineStrip";
+ break;
+
+ case PRIM3D_TRILIST:
+ hw_start_vertex = 0;
+ hw_nr_vertex = 3;
+ prim_name = "TriList";
+ break;
+
+ case PRIM3D_TRISTRIP:
+ hw_start_vertex = 3;
+ hw_nr_vertex = 1;
+ prim_name = "TriStrip";
+ break;
+
+ case PRIM3D_TRIFAN:
+ hw_start_vertex = 3;
+ hw_nr_vertex = 1;
+ prim_name = "TriFan";
+ break;
+
+ case PRIM3D_POLY:
+ hw_start_vertex = 3;
+ hw_nr_vertex = 1;
+ prim_name = "Polygons";
+ break;
+ default:
+ prim_name = "Unknown";
+ fprintf(stderr, "\n\nUnknown primitive type : %08x\n",
+ sarea->vertex_prim);
+ }
+
+ if (hw_nr_vertex && vfmt_size) {
+ int temp_size = size - (hw_start_vertex * vfmt_size);
+ int remaining = (temp_size % (hw_nr_vertex * vfmt_size));
+
+ if (remaining != 0) {
+ fprintf(stderr, "\n\nThis buffer contains an improper"
+ " multiple of vertices for this primitive : %s\n",
+ prim_name);
+ fprintf(stderr, "Number of vertices in buffer : %d\n",
+ size / vfmt_size);
+ fprintf(stderr, "temp_size : %d\n", temp_size);
+ fprintf(stderr, "remaining vertices : %d",
+ remaining / vfmt_size);
+ }
+ }
+ if (vfmt_size) {
+ fprintf(stderr, "\n\nPrim name (%s), vertices (%d)\n",
+ prim_name,
+ size / vfmt_size);
+ }
+}
+
+void i830EmitHwStateLockedDebug( i830ContextPtr imesa )
+{
+ int i;
+
+ if ((imesa->dirty & I830_UPLOAD_TEX0_IMAGE) && imesa->CurrentTexObj[0]) {
+ i830UploadTexImagesLocked(imesa, imesa->CurrentTexObj[0]);
+ }
+
+ if ((imesa->dirty & I830_UPLOAD_TEX1_IMAGE) && imesa->CurrentTexObj[1]) {
+ i830UploadTexImagesLocked(imesa, imesa->CurrentTexObj[1]);
+ }
+
+ if (imesa->dirty & I830_UPLOAD_CTX) {
+ memcpy( imesa->sarea->ContextState,
+ imesa->Setup, sizeof(imesa->Setup) );
+ i830DumpContextState(imesa);
+ }
+
+ for(i = 0; i < I830_TEXTURE_COUNT; i++) {
+ if ((imesa->dirty & I830_UPLOAD_TEX_N(i)) && imesa->CurrentTexObj[i]) {
+ unsigned * TexState;
+
+ imesa->sarea->dirty |= I830_UPLOAD_TEX_N(i);
+
+ switch( i ) {
+ case 0:
+ case 1:
+ TexState = imesa->sarea->TexState[i];
+ break;
+
+ case 2:
+ TexState = imesa->sarea->TexState2;
+ break;
+
+ case 3:
+ TexState = imesa->sarea->TexState3;
+ break;
+ }
+
+ memcpy(TexState, imesa->CurrentTexObj[i]->Setup,
+ sizeof(imesa->sarea->TexState[i]));
+ i830DumpTextureState(imesa, i);
+ }
+ }
+ /* Need to figure out if texturing state, or enable changed. */
+
+ for(i = 0; i < I830_TEXBLEND_COUNT; i++) {
+ if (imesa->dirty & I830_UPLOAD_TEXBLEND_N(i)) {
+ unsigned * TexBlendState;
+ unsigned * words_used;
+
+ imesa->sarea->dirty |= I830_UPLOAD_TEXBLEND_N(i);
+
+ switch( i ) {
+ case 0:
+ case 1:
+ TexBlendState = imesa->sarea->TexBlendState[i];
+ words_used = & imesa->sarea->TexBlendStateWordsUsed[i];
+ break;
+
+ case 2:
+ TexBlendState = imesa->sarea->TexBlendState2;
+ words_used = & imesa->sarea->TexBlendStateWordsUsed2;
+ break;
+
+ case 3:
+ TexBlendState = imesa->sarea->TexBlendState3;
+ words_used = & imesa->sarea->TexBlendStateWordsUsed3;
+ break;
+ }
+
+ memcpy(TexBlendState, imesa->TexBlend[i],
+ imesa->TexBlendWordsUsed[i] * 4);
+ *words_used = imesa->TexBlendWordsUsed[i];
+
+ i830DumpTextureBlendState(imesa, i);
+ }
+ }
+
+ if (imesa->dirty & I830_UPLOAD_BUFFERS) {
+ memcpy( imesa->sarea->BufferState,imesa->BufferSetup,
+ sizeof(imesa->BufferSetup) );
+ i830DumpBufferState(imesa);
+ }
+
+ if (imesa->dirty & I830_UPLOAD_STIPPLE) {
+ fprintf(stderr, "UPLOAD_STIPPLE\n");
+ memcpy( imesa->sarea->StippleState,imesa->StippleSetup,
+ sizeof(imesa->StippleSetup) );
+ i830DumpStippleState(imesa);
+ }
+
+ if (imesa->dirty & I830_UPLOAD_TEX_PALETTE_SHARED) {
+ memcpy( imesa->sarea->Palette[0],imesa->palette,
+ sizeof(imesa->sarea->Palette[0]));
+ } else {
+ i830TextureObjectPtr p;
+ if (imesa->dirty & I830_UPLOAD_TEX_PALETTE_N(0)) {
+ p = imesa->CurrentTexObj[0];
+ memcpy( imesa->sarea->Palette[0],p->palette,
+ sizeof(imesa->sarea->Palette[0]));
+ }
+ if (imesa->dirty & I830_UPLOAD_TEX_PALETTE_N(1)) {
+ p = imesa->CurrentTexObj[1];
+ memcpy( imesa->sarea->Palette[1],
+ p->palette,
+ sizeof(imesa->sarea->Palette[1]));
+ }
+ }
+ imesa->sarea->dirty |= (imesa->dirty & ~(I830_UPLOAD_TEX_MASK |
+ I830_UPLOAD_TEXBLEND_MASK));
+
+ imesa->upload_cliprects = GL_TRUE;
+ imesa->dirty = 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_debug.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_debug.h
new file mode 100644
index 000000000..deb84f7b0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_debug.h
@@ -0,0 +1,48 @@
+/**************************************************************************
+
+Copyright 2001 2d3d Inc., Delray Beach, FL
+
+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, VA LINUX SYSTEMS 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.
+
+**************************************************************************/
+
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_debug.h,v 1.3 2002/12/10 01:26:53 dawes Exp $ */
+
+/*
+ * Author:
+ * Jeff Hartmann <jhartmann@2d3d.com>
+ */
+
+/* Defines for sanity checking and debug output */
+#ifndef I830DEBUG_INC
+#define I830DEBUG_INC
+
+
+void i830DumpContextState( i830ContextPtr imesa );
+void i830DumpStippleState( i830ContextPtr imesa );
+void i830DumpBufferState( i830ContextPtr imesa );
+void i830DumpTextureState( i830ContextPtr imesa, int unit );
+void i830DumpTextureBlendState( i830ContextPtr imesa, int unit );
+void i830VertexSanity( i830ContextPtr imesa, drmI830Vertex vertex );
+void i830EmitHwStateLockedDebug( i830ContextPtr imesa );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_ioctl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_ioctl.c
new file mode 100644
index 000000000..cd0c143df
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_ioctl.c
@@ -0,0 +1,841 @@
+
+/**************************************************************************
+
+Copyright 2001 VA Linux Systems Inc., Fremont, 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
+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, VA LINUX SYSTEMS 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.
+
+**************************************************************************/
+
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_ioctl.c,v 1.5 2002/12/10 01:26:53 dawes Exp $ */
+
+/*
+ * Author:
+ * Jeff Hartmann <jhartmann@2d3d.com>
+ * Graeme Fisher <graeme@2d3d.co.za>
+ * Abraham vd Merwe <abraham@2d3d.co.za>
+ *
+ * Heavily based on the I810 driver, which was written by:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "dd.h"
+#include "swrast/swrast.h"
+
+#include "mm.h"
+
+#include "i830_screen.h"
+#include "i830_dri.h"
+
+#include "i830_context.h"
+#include "i830_ioctl.h"
+#include "i830_state.h"
+#include "i830_debug.h"
+
+#include "drm.h"
+
+static drmBufPtr i830_get_buffer_ioctl( i830ContextPtr imesa )
+{
+ drmI830DMA dma;
+ drmBufPtr buf;
+ int retcode,i = 0;
+ while (1) {
+ retcode = drmCommandWriteRead(imesa->driFd,
+ DRM_I830_GETBUF,
+ &dma,
+ sizeof(drmI830DMA));
+ if (dma.granted == 1 && retcode == 0)
+ break;
+
+ if (++i > 1000) {
+ imesa->sarea->perf_boxes |= I830_BOX_WAIT;
+ retcode = drmCommandNone(imesa->driFd, DRM_I830_FLUSH);
+ i = 0;
+ }
+ }
+
+ buf = &(imesa->i830Screen->bufs->list[dma.request_idx]);
+ buf->idx = dma.request_idx;
+ buf->used = 0;
+ buf->total = dma.request_size;
+ buf->address = (drmAddress)dma.virtual;
+
+ return buf;
+}
+
+static void i830ClearDrawQuad(i830ContextPtr imesa, float left,
+ float right,
+ float bottom, float top, GLubyte red,
+ GLubyte green, GLubyte blue, GLubyte alpha)
+{
+ GLuint *vb = i830AllocDmaLowLocked( imesa, 128 );
+ i830Vertex tmp;
+ int i;
+
+ /* PRIM3D_TRIFAN */
+
+ /* initial vertex, left bottom */
+ tmp.v.x = left;
+ tmp.v.y = bottom;
+ tmp.v.z = 1.0;
+ tmp.v.w = 1.0;
+ tmp.v.color.red = red;
+ tmp.v.color.green = green;
+ tmp.v.color.blue = blue;
+ tmp.v.color.alpha = alpha;
+ tmp.v.specular.red = 0;
+ tmp.v.specular.green = 0;
+ tmp.v.specular.blue = 0;
+ tmp.v.specular.alpha = 0;
+ tmp.v.u0 = 0.0f;
+ tmp.v.v0 = 0.0f;
+ for (i = 0 ; i < 8 ; i++)
+ vb[i] = tmp.ui[i];
+
+ /* right bottom */
+ vb += 8;
+ tmp.v.x = right;
+ for (i = 0 ; i < 8 ; i++)
+ vb[i] = tmp.ui[i];
+
+ /* right top */
+ vb += 8;
+ tmp.v.y = top;
+ for (i = 0 ; i < 8 ; i++)
+ vb[i] = tmp.ui[i];
+
+ /* left top */
+ vb += 8;
+ tmp.v.x = left;
+ for (i = 0 ; i < 8 ; i++)
+ vb[i] = tmp.ui[i];
+}
+
+static void i830ClearWithTris(GLcontext *ctx, GLbitfield mask,
+ GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch)
+{
+ i830ContextPtr imesa = I830_CONTEXT( ctx );
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+ i830ScreenPrivate *i830Screen = imesa->i830Screen;
+ I830SAREAPtr sarea = imesa->sarea;
+ GLuint old_vertex_prim;
+ GLuint old_dirty;
+ int x0, y0, x1, y1;
+
+ if (I830_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "Clearing with triangles\n");
+
+ old_dirty = imesa->dirty & ~I830_UPLOAD_CLIPRECTS;
+ /* Discard all the dirty flags except the cliprect one, reset later */
+ imesa->dirty &= I830_UPLOAD_CLIPRECTS;
+
+ if(!all) {
+ x0 = cx;
+ y0 = cy;
+ x1 = x0 + cw;
+ y1 = y0 + ch;
+ } else {
+ x0 = 0;
+ y0 = 0;
+ x1 = x0 + dPriv->w;
+ y1 = y0 + dPriv->h;
+ }
+
+ /* Clip to Screen */
+ if (x0 < 0) x0 = 0;
+ if (y0 < 0) y0 = 0;
+ if (x1 > i830Screen->width-1) x1 = i830Screen->width-1;
+ if (y1 > i830Screen->height-1) y1 = i830Screen->height-1;
+
+ LOCK_HARDWARE(imesa);
+ memcpy(sarea->ContextState,
+ imesa->Init_Setup,
+ sizeof(imesa->Setup) );
+ memcpy(sarea->BufferState,
+ imesa->BufferSetup,
+ sizeof(imesa->BufferSetup) );
+ sarea->StippleState[I830_STPREG_ST1] = 0;
+
+ old_vertex_prim = imesa->hw_primitive;
+ imesa->hw_primitive = PRIM3D_TRIFAN;
+
+ if(mask & BUFFER_BIT_FRONT_LEFT) {
+ GLuint tmp = sarea->ContextState[I830_CTXREG_ENABLES_2];
+
+ sarea->dirty |= (I830_UPLOAD_CTX | I830_UPLOAD_BUFFERS |
+ I830_UPLOAD_TEXBLEND0);
+
+ sarea->TexBlendState[0][0] = (STATE3D_MAP_BLEND_OP_CMD(0) |
+ TEXPIPE_COLOR |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ DISABLE_TEX_CNTRL_STAGE |
+ TEXOP_SCALE_1X |
+ TEXOP_MODIFY_PARMS |
+ TEXOP_LAST_STAGE |
+ TEXBLENDOP_ARG1);
+ sarea->TexBlendState[0][1] = (STATE3D_MAP_BLEND_OP_CMD(0) |
+ TEXPIPE_ALPHA |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ TEXOP_SCALE_1X |
+ TEXOP_MODIFY_PARMS |
+ TEXBLENDOP_ARG1);
+ sarea->TexBlendState[0][2] = (STATE3D_MAP_BLEND_ARG_CMD(0) |
+ TEXPIPE_COLOR |
+ TEXBLEND_ARG1 |
+ TEXBLENDARG_MODIFY_PARMS |
+ TEXBLENDARG_CURRENT);
+ sarea->TexBlendState[0][3] = (STATE3D_MAP_BLEND_ARG_CMD(0) |
+ TEXPIPE_ALPHA |
+ TEXBLEND_ARG1 |
+ TEXBLENDARG_MODIFY_PARMS |
+ TEXBLENDARG_CURRENT);
+ sarea->TexBlendStateWordsUsed[0] = 4;
+
+ tmp &= ~(ENABLE_STENCIL_WRITE | ENABLE_DEPTH_WRITE);
+ tmp |= (DISABLE_STENCIL_WRITE |
+ DISABLE_DEPTH_WRITE |
+ (imesa->mask_red << WRITEMASK_RED_SHIFT) |
+ (imesa->mask_green << WRITEMASK_GREEN_SHIFT) |
+ (imesa->mask_blue << WRITEMASK_BLUE_SHIFT) |
+ (imesa->mask_alpha << WRITEMASK_ALPHA_SHIFT));
+ sarea->ContextState[I830_CTXREG_ENABLES_2] = tmp;
+
+ if(0)
+ fprintf(stderr, "fcdq : r_mask(%d) g_mask(%d) b_mask(%d) a_mask(%d)\n",
+ imesa->mask_red, imesa->mask_green, imesa->mask_blue,
+ imesa->mask_alpha);
+
+ sarea->BufferState[I830_DESTREG_CBUFADDR] = i830Screen->fbOffset;
+
+ if(0)
+ fprintf(stderr, "fcdq : x0(%d) x1(%d) y0(%d) y1(%d)\n"
+ "r(0x%x) g(0x%x) b(0x%x) a(0x%x)\n",
+ x0, x1, y0, y1, imesa->clear_red, imesa->clear_green,
+ imesa->clear_blue, imesa->clear_alpha);
+
+ i830ClearDrawQuad(imesa, (float)x0, (float)x1, (float)y0, (float)y1,
+ imesa->clear_red, imesa->clear_green,
+ imesa->clear_blue, imesa->clear_alpha);
+ i830FlushPrimsLocked( imesa );
+ }
+
+ if(mask & BUFFER_BIT_BACK_LEFT) {
+ GLuint tmp = sarea->ContextState[I830_CTXREG_ENABLES_2];
+
+ sarea->dirty |= (I830_UPLOAD_CTX | I830_UPLOAD_BUFFERS |
+ I830_UPLOAD_TEXBLEND0);
+
+ sarea->TexBlendState[0][0] = (STATE3D_MAP_BLEND_OP_CMD(0) |
+ TEXPIPE_COLOR |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ DISABLE_TEX_CNTRL_STAGE |
+ TEXOP_SCALE_1X |
+ TEXOP_MODIFY_PARMS |
+ TEXOP_LAST_STAGE |
+ TEXBLENDOP_ARG1);
+ sarea->TexBlendState[0][1] = (STATE3D_MAP_BLEND_OP_CMD(0) |
+ TEXPIPE_ALPHA |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ TEXOP_SCALE_1X |
+ TEXOP_MODIFY_PARMS |
+ TEXBLENDOP_ARG1);
+ sarea->TexBlendState[0][2] = (STATE3D_MAP_BLEND_ARG_CMD(0) |
+ TEXPIPE_COLOR |
+ TEXBLEND_ARG1 |
+ TEXBLENDARG_MODIFY_PARMS |
+ TEXBLENDARG_CURRENT);
+ sarea->TexBlendState[0][3] = (STATE3D_MAP_BLEND_ARG_CMD(0) |
+ TEXPIPE_ALPHA |
+ TEXBLEND_ARG2 |
+ TEXBLENDARG_MODIFY_PARMS |
+ TEXBLENDARG_CURRENT);
+ sarea->TexBlendStateWordsUsed[0] = 4;
+
+ tmp &= ~(ENABLE_STENCIL_WRITE | ENABLE_DEPTH_WRITE);
+ tmp |= (DISABLE_STENCIL_WRITE |
+ DISABLE_DEPTH_WRITE |
+ (imesa->mask_red << WRITEMASK_RED_SHIFT) |
+ (imesa->mask_green << WRITEMASK_GREEN_SHIFT) |
+ (imesa->mask_blue << WRITEMASK_BLUE_SHIFT) |
+ (imesa->mask_alpha << WRITEMASK_ALPHA_SHIFT));
+
+ if(0)
+ fprintf(stderr, "bcdq : r_mask(%d) g_mask(%d) b_mask(%d) a_mask(%d)\n",
+ imesa->mask_red, imesa->mask_green, imesa->mask_blue,
+ imesa->mask_alpha);
+
+ sarea->ContextState[I830_CTXREG_ENABLES_2] = tmp;
+
+ sarea->BufferState[I830_DESTREG_CBUFADDR] = i830Screen->backOffset;
+
+ if(0)
+ fprintf(stderr, "bcdq : x0(%d) x1(%d) y0(%d) y1(%d)\n"
+ "r(0x%x) g(0x%x) b(0x%x) a(0x%x)\n",
+ x0, x1, y0, y1, imesa->clear_red, imesa->clear_green,
+ imesa->clear_blue, imesa->clear_alpha);
+
+ i830ClearDrawQuad(imesa, (float)x0, (float)x1, (float)y0, (float)y1,
+ imesa->clear_red, imesa->clear_green,
+ imesa->clear_blue, imesa->clear_alpha);
+ i830FlushPrimsLocked( imesa );
+ }
+
+ if(mask & BUFFER_BIT_STENCIL) {
+ GLuint s_mask = ctx->Stencil.WriteMask[0];
+
+ sarea->dirty |= (I830_UPLOAD_CTX | I830_UPLOAD_BUFFERS |
+ I830_UPLOAD_TEXBLEND0);
+
+ sarea->TexBlendState[0][0] = (STATE3D_MAP_BLEND_OP_CMD(0) |
+ TEXPIPE_COLOR |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ DISABLE_TEX_CNTRL_STAGE |
+ TEXOP_SCALE_1X |
+ TEXOP_MODIFY_PARMS |
+ TEXOP_LAST_STAGE |
+ TEXBLENDOP_ARG1);
+ sarea->TexBlendState[0][1] = (STATE3D_MAP_BLEND_OP_CMD(0) |
+ TEXPIPE_ALPHA |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ TEXOP_SCALE_1X |
+ TEXOP_MODIFY_PARMS |
+ TEXBLENDOP_ARG1);
+ sarea->TexBlendState[0][2] = (STATE3D_MAP_BLEND_ARG_CMD(0) |
+ TEXPIPE_COLOR |
+ TEXBLEND_ARG1 |
+ TEXBLENDARG_MODIFY_PARMS |
+ TEXBLENDARG_CURRENT);
+ sarea->TexBlendState[0][3] = (STATE3D_MAP_BLEND_ARG_CMD(0) |
+ TEXPIPE_ALPHA |
+ TEXBLEND_ARG2 |
+ TEXBLENDARG_MODIFY_PARMS |
+ TEXBLENDARG_CURRENT);
+ sarea->TexBlendStateWordsUsed[0] = 4;
+
+ sarea->ContextState[I830_CTXREG_ENABLES_1] |= (ENABLE_STENCIL_TEST |
+ ENABLE_DEPTH_TEST);
+
+ sarea->ContextState[I830_CTXREG_ENABLES_2] &= ~(ENABLE_STENCIL_WRITE |
+ ENABLE_DEPTH_WRITE |
+ ENABLE_COLOR_WRITE);
+
+ sarea->ContextState[I830_CTXREG_ENABLES_2] |=
+ (ENABLE_STENCIL_WRITE |
+ DISABLE_DEPTH_WRITE |
+ (1 << WRITEMASK_RED_SHIFT) |
+ (1 << WRITEMASK_GREEN_SHIFT) |
+ (1 << WRITEMASK_BLUE_SHIFT) |
+ (1 << WRITEMASK_ALPHA_SHIFT) |
+ ENABLE_COLOR_WRITE);
+
+ sarea->ContextState[I830_CTXREG_STATE4] &=
+ ~MODE4_ENABLE_STENCIL_WRITE_MASK;
+
+ sarea->ContextState[I830_CTXREG_STATE4] |=
+ (ENABLE_STENCIL_WRITE_MASK |
+ STENCIL_WRITE_MASK(s_mask));
+
+ sarea->ContextState[I830_CTXREG_STENCILTST] &=
+ ~(STENCIL_OPS_MASK |
+ STENCIL_REF_VALUE_MASK |
+ ENABLE_STENCIL_TEST_FUNC_MASK);
+
+ sarea->ContextState[I830_CTXREG_STENCILTST] |=
+ (ENABLE_STENCIL_PARMS |
+ ENABLE_STENCIL_REF_VALUE |
+ ENABLE_STENCIL_TEST_FUNC |
+ STENCIL_FAIL_OP(STENCILOP_REPLACE) |
+ STENCIL_PASS_DEPTH_FAIL_OP(STENCILOP_REPLACE) |
+ STENCIL_PASS_DEPTH_PASS_OP(STENCILOP_REPLACE) |
+ STENCIL_REF_VALUE((ctx->Stencil.Clear & 0xff)) |
+ STENCIL_TEST_FUNC(COMPAREFUNC_ALWAYS));
+
+ if(0)
+ fprintf(stderr, "Enables_1 (0x%x) Enables_2 (0x%x) StenTst (0x%x)\n"
+ "Modes_4 (0x%x)\n",
+ sarea->ContextState[I830_CTXREG_ENABLES_1],
+ sarea->ContextState[I830_CTXREG_ENABLES_2],
+ sarea->ContextState[I830_CTXREG_STENCILTST],
+ sarea->ContextState[I830_CTXREG_STATE4]);
+
+ sarea->BufferState[I830_DESTREG_CBUFADDR] = i830Screen->fbOffset;
+
+ i830ClearDrawQuad(imesa, (float)x0, (float)x1, (float)y0, (float)y1,
+ 255, 255, 255, 255);
+ i830FlushPrimsLocked( imesa );
+ }
+
+ UNLOCK_HARDWARE(imesa);
+ imesa->dirty = old_dirty;
+ imesa->dirty |= (I830_UPLOAD_CTX |
+ I830_UPLOAD_BUFFERS |
+ I830_UPLOAD_TEXBLEND0);
+
+ imesa->hw_primitive = old_vertex_prim;
+}
+
+static void i830Clear(GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx1, GLint cy1, GLint cw, GLint ch)
+{
+ i830ContextPtr imesa = I830_CONTEXT( ctx );
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+ const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
+ drmI830Clear clear;
+ GLbitfield tri_mask = 0;
+ int i;
+ GLint cx, cy;
+
+ /* flip top to bottom */
+ cy = dPriv->h-cy1-ch;
+ cx = cx1 + imesa->drawX;
+ cy += imesa->drawY;
+
+ if(0) fprintf(stderr, "\nClearColor : 0x%08x\n", imesa->ClearColor);
+
+ clear.flags = 0;
+ clear.clear_color = imesa->ClearColor;
+ clear.clear_depth = 0;
+ clear.clear_colormask = 0;
+ clear.clear_depthmask = 0;
+
+ I830_FIREVERTICES( imesa );
+
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
+ if(colorMask == ~0) {
+ clear.flags |= I830_FRONT;
+ } else {
+ tri_mask |= BUFFER_BIT_FRONT_LEFT;
+ }
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
+ }
+
+ if (mask & BUFFER_BIT_BACK_LEFT) {
+ if(colorMask == ~0) {
+ clear.flags |= I830_BACK;
+ } else {
+ tri_mask |= BUFFER_BIT_BACK_LEFT;
+ }
+ mask &= ~BUFFER_BIT_BACK_LEFT;
+ }
+
+ if (mask & BUFFER_BIT_DEPTH) {
+ clear.flags |= I830_DEPTH;
+ clear.clear_depthmask = imesa->depth_clear_mask;
+ clear.clear_depth = (GLuint)(ctx->Depth.Clear * imesa->ClearDepth);
+ mask &= ~BUFFER_BIT_DEPTH;
+ }
+
+ if((mask & BUFFER_BIT_STENCIL) && imesa->hw_stencil) {
+ if (ctx->Stencil.WriteMask[0] != 0xff) {
+ tri_mask |= BUFFER_BIT_STENCIL;
+ } else {
+ clear.flags |= I830_DEPTH;
+ clear.clear_depthmask |= imesa->stencil_clear_mask;
+ clear.clear_depth |= (ctx->Stencil.Clear & 0xff) << 24;
+ }
+ mask &= ~BUFFER_BIT_STENCIL;
+ }
+
+ /* First check for clears that need to happen with triangles */
+ if(tri_mask) {
+ i830ClearWithTris(ctx, tri_mask, all, cx, cy, cw, ch);
+ }
+
+ if (clear.flags) {
+ LOCK_HARDWARE( imesa );
+
+ for (i = 0 ; i < imesa->numClipRects ; )
+ {
+ int nr = MIN2(i + I830_NR_SAREA_CLIPRECTS, imesa->numClipRects);
+ drm_clip_rect_t *box = imesa->pClipRects;
+ drm_clip_rect_t *b = (drm_clip_rect_t *)imesa->sarea->boxes;
+ int n = 0;
+
+ if (!all) {
+ for ( ; i < nr ; i++) {
+ GLint x = box[i].x1;
+ GLint y = box[i].y1;
+ GLint w = box[i].x2 - x;
+ GLint h = box[i].y2 - y;
+
+ 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) continue;
+ if (h <= 0) continue;
+
+ b->x1 = x;
+ b->y1 = y;
+ b->x2 = x + w;
+ b->y2 = y + h;
+ b++;
+ n++;
+ }
+ } else {
+ for ( ; i < nr ; i++) {
+ *b++ = *(drm_clip_rect_t *)&box[i];
+ n++;
+ }
+ }
+
+ imesa->sarea->nbox = n;
+ drmCommandWrite(imesa->driFd, DRM_I830_CLEAR,
+ &clear, sizeof(drmI830Clear));
+ }
+
+ UNLOCK_HARDWARE( imesa );
+ imesa->upload_cliprects = GL_TRUE;
+ }
+
+ if (mask)
+ _swrast_Clear( ctx, mask, all, cx1, cy1, cw, ch );
+}
+
+
+
+/*
+ * Copy the back buffer to the front buffer.
+ */
+void i830CopyBuffer( const __DRIdrawablePrivate *dPriv )
+{
+ i830ContextPtr imesa;
+ drm_clip_rect_t *pbox;
+ int nbox, i, tmp;
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ imesa = (i830ContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ I830_FIREVERTICES( imesa );
+ LOCK_HARDWARE( imesa );
+
+ imesa->sarea->perf_boxes |= imesa->perf_boxes;
+ imesa->perf_boxes = 0;
+
+ pbox = dPriv->pClipRects;
+ nbox = dPriv->numClipRects;
+
+ for (i = 0 ; i < nbox ; )
+ {
+ int nr = MIN2(i + I830_NR_SAREA_CLIPRECTS, dPriv->numClipRects);
+ drm_clip_rect_t *b = (drm_clip_rect_t *)imesa->sarea->boxes;
+
+ imesa->sarea->nbox = nr - i;
+
+ for ( ; i < nr ; i++)
+ *b++ = pbox[i];
+ drmCommandNone(imesa->driFd, DRM_I830_SWAP);
+ }
+
+ tmp = GET_ENQUEUE_AGE(imesa);
+ UNLOCK_HARDWARE( imesa );
+
+ /* multiarb will suck the life out of the server without this throttle:
+ */
+ if (GET_DISPATCH_AGE(imesa) < imesa->lastSwap) {
+ i830WaitAge(imesa, imesa->lastSwap);
+ }
+
+ imesa->lastSwap = tmp;
+ imesa->upload_cliprects = GL_TRUE;
+}
+
+/* Flip the front & back buffes
+ */
+void i830PageFlip( const __DRIdrawablePrivate *dPriv )
+{
+#if 0
+ i830ContextPtr imesa;
+ int tmp, ret;
+
+ if (I830_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ imesa = (i830ContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ I830_FIREVERTICES( imesa );
+ LOCK_HARDWARE( imesa );
+
+ imesa->sarea->perf_boxes |= imesa->perf_boxes;
+ imesa->perf_boxes = 0;
+
+ if (dPriv->pClipRects) {
+ *(drm_clip_rect_t *)imesa->sarea->boxes = dPriv->pClipRects[0];
+ imesa->sarea->nbox = 1;
+ }
+
+ ret = drmCommandNone(imesa->driFd, DRM_I830_FLIP);
+ if (ret) {
+ fprintf(stderr, "%s: %d\n", __FUNCTION__, ret);
+ UNLOCK_HARDWARE( imesa );
+ exit(1);
+ }
+
+ tmp = GET_ENQUEUE_AGE(imesa);
+ UNLOCK_HARDWARE( imesa );
+
+ /* multiarb will suck the life out of the server without this throttle:
+ */
+ if (GET_DISPATCH_AGE(imesa) < imesa->lastSwap) {
+ i830WaitAge(imesa, imesa->lastSwap);
+ }
+
+ i830SetDrawBuffer( imesa->glCtx, imesa->glCtx->Color.DriverDrawBuffer );
+ imesa->upload_cliprects = GL_TRUE;
+ imesa->lastSwap = tmp;
+#endif
+}
+
+/* This waits for *everybody* to finish rendering -- overkill.
+ */
+void i830DmaFinish( i830ContextPtr imesa )
+{
+ I830_FIREVERTICES( imesa );
+ LOCK_HARDWARE_QUIESCENT( imesa );
+ UNLOCK_HARDWARE( imesa );
+}
+
+void i830RegetLockQuiescent( i830ContextPtr imesa )
+{
+ drmUnlock(imesa->driFd, imesa->hHWContext);
+ i830GetLock( imesa, DRM_LOCK_QUIESCENT );
+}
+
+void i830WaitAgeLocked( i830ContextPtr imesa, int age )
+{
+ int i = 0;
+ while (++i < 5000) {
+ drmCommandNone(imesa->driFd, DRM_I830_GETAGE);
+ if (GET_DISPATCH_AGE(imesa) >= age) return;
+ imesa->sarea->perf_boxes |= I830_BOX_WAIT;
+ UNLOCK_HARDWARE( imesa );
+ if (I830_DEBUG & DEBUG_SLEEP) fprintf(stderr, ".");
+ usleep(1);
+ LOCK_HARDWARE( imesa );
+ }
+ /* If that didn't work, just do a flush:
+ */
+ drmCommandNone(imesa->driFd, DRM_I830_FLUSH);
+}
+
+void i830WaitAge( i830ContextPtr imesa, int age )
+{
+ int i = 0;
+ if (GET_DISPATCH_AGE(imesa) >= age) return;
+
+ while (1) {
+ drmCommandNone(imesa->driFd, DRM_I830_GETAGE);
+ if (GET_DISPATCH_AGE(imesa) >= age) return;
+ imesa->perf_boxes |= I830_BOX_WAIT;
+
+ if (imesa->do_irqs) {
+ drmI830IrqEmit ie;
+ drmI830IrqWait iw;
+ int ret;
+
+ ie.irq_seq = &iw.irq_seq;
+
+ LOCK_HARDWARE( imesa );
+ ret = drmCommandWriteRead( imesa->driFd, DRM_I830_IRQ_EMIT, &ie, sizeof(ie) );
+ if ( ret ) {
+ fprintf( stderr, "%s: drmI830IrqEmit: %d\n", __FUNCTION__, ret );
+ exit(1);
+ }
+ UNLOCK_HARDWARE(imesa);
+
+ ret = drmCommandWrite( imesa->driFd, DRM_I830_IRQ_WAIT, &iw, sizeof(iw) );
+ if ( ret ) {
+ fprintf( stderr, "%s: drmI830IrqWait: %d\n", __FUNCTION__, ret );
+ exit(1);
+ }
+ } else {
+ if (++i > 5000) usleep(1);
+ }
+ }
+}
+
+static void age_imesa( i830ContextPtr imesa, int age )
+{
+ if (imesa->CurrentTexObj[0]) imesa->CurrentTexObj[0]->base.timestamp = age;
+ if (imesa->CurrentTexObj[1]) imesa->CurrentTexObj[1]->base.timestamp = age;
+}
+
+void i830FlushPrimsLocked( i830ContextPtr imesa )
+{
+ drm_clip_rect_t *pbox = imesa->pClipRects;
+ int nbox = imesa->numClipRects;
+ drmBufPtr buffer = imesa->vertex_buffer;
+ I830SAREAPtr sarea = imesa->sarea;
+ drmI830Vertex vertex;
+ int i, nr;
+
+ if (I830_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s dirty: %08x\n", __FUNCTION__, imesa->dirty);
+
+
+ vertex.idx = buffer->idx;
+ vertex.used = imesa->vertex_low;
+ vertex.discard = 0;
+ sarea->vertex_prim = imesa->hw_primitive;
+
+ /* Reset imesa vars:
+ */
+ imesa->vertex_buffer = 0;
+ imesa->vertex_addr = 0;
+ imesa->vertex_low = 0;
+ imesa->vertex_high = 0;
+ imesa->vertex_last_prim = 0;
+
+ if (imesa->dirty) {
+ if (I830_DEBUG & DEBUG_SANITY)
+ i830EmitHwStateLockedDebug(imesa);
+ else
+ i830EmitHwStateLocked(imesa);
+ }
+
+ if (I830_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr,"%s: Vertex idx %d used %d discard %d\n",
+ __FUNCTION__, vertex.idx, vertex.used, vertex.discard);
+
+ if (!nbox) {
+ vertex.used = 0;
+ vertex.discard = 1;
+ if (drmCommandWrite (imesa->driFd, DRM_I830_VERTEX,
+ &vertex, sizeof(drmI830Vertex))) {
+ fprintf(stderr, "DRM_I830_VERTEX: %d\n", -errno);
+ UNLOCK_HARDWARE(imesa);
+ exit(1);
+ }
+ return;
+ }
+
+ for (i = 0 ; i < nbox ; i = nr ) {
+ drm_clip_rect_t *b = sarea->boxes;
+ int j;
+
+ nr = MIN2(i + I830_NR_SAREA_CLIPRECTS, nbox);
+ sarea->nbox = nr - i;
+
+ for ( j = i ; j < nr ; j++) {
+ b[j-i] = pbox[j];
+ }
+
+ /* Finished with the buffer?
+ */
+ if (nr == nbox)
+ vertex.discard = 1;
+
+ /* Do a bunch of sanity checks on the vertices sent to the hardware */
+ if (I830_DEBUG & DEBUG_SANITY) {
+ i830VertexSanity(imesa, vertex);
+
+ for ( j = 0 ; j < sarea->nbox ; j++) {
+ fprintf(stderr, "box %d/%d %d,%d %d,%d\n",
+ j, sarea->nbox, b[j].x1, b[j].y1, b[j].x2, b[j].y2);
+ }
+ }
+
+ drmCommandWrite (imesa->driFd, DRM_I830_VERTEX,
+ &vertex, sizeof(drmI830Vertex));
+ age_imesa(imesa, imesa->sarea->last_enqueue);
+ }
+
+ imesa->dirty = 0;
+ imesa->upload_cliprects = GL_FALSE;
+}
+
+void i830FlushPrimsGetBufferLocked( i830ContextPtr imesa )
+{
+ if (imesa->vertex_buffer)
+ i830FlushPrimsLocked( imesa );
+ imesa->vertex_buffer = i830_get_buffer_ioctl( imesa );
+ imesa->vertex_addr = (char *)imesa->vertex_buffer->address;
+
+ /* leave room for instruction header & footer:
+ */
+ imesa->vertex_high = imesa->vertex_buffer->total - 4;
+ imesa->vertex_low = 4;
+ imesa->vertex_last_prim = imesa->vertex_low;
+}
+
+void i830FlushPrimsGetBuffer( i830ContextPtr imesa )
+{
+ LOCK_HARDWARE(imesa);
+ i830FlushPrimsGetBufferLocked( imesa );
+ UNLOCK_HARDWARE(imesa);
+}
+
+
+void i830FlushPrims( i830ContextPtr imesa )
+{
+ if (imesa->vertex_buffer) {
+ LOCK_HARDWARE( imesa );
+ i830FlushPrimsLocked( imesa );
+ UNLOCK_HARDWARE( imesa );
+ }
+}
+
+int i830_check_copy(int fd)
+{
+ return drmCommandNone(fd, DRM_I830_DOCOPY);
+}
+
+static void i830Flush( GLcontext *ctx )
+{
+ i830ContextPtr imesa = I830_CONTEXT( ctx );
+ I830_FIREVERTICES( imesa );
+}
+
+static void i830Finish( GLcontext *ctx )
+{
+ i830ContextPtr imesa = I830_CONTEXT( ctx );
+ i830DmaFinish( imesa );
+}
+
+void i830InitIoctlFuncs( struct dd_function_table *functions )
+{
+ functions->Flush = i830Flush;
+ functions->Clear = i830Clear;
+ functions->Finish = i830Finish;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_ioctl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_ioctl.h
new file mode 100644
index 000000000..f92ff44ea
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_ioctl.h
@@ -0,0 +1,105 @@
+
+/**************************************************************************
+
+Copyright 2001 VA Linux Systems Inc., Fremont, 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
+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, VA LINUX SYSTEMS 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.
+
+**************************************************************************/
+
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_ioctl.h,v 1.3 2002/10/30 12:51:35 alanh Exp $ */
+
+/*
+ * Author:
+ * Jeff Hartmann <jhartmann@2d3d.com>
+ * Graeme Fisher <graeme@2d3d.co.za>
+ * Abraham vd Merwe <abraham@2d3d.co.za>
+ *
+ * Heavily based on the I810 driver, which was written by:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef I830_IOCTL_H
+#define I830_IOCTL_H
+
+#include "i830_context.h"
+
+GLuint *i830AllocDwords (i830ContextPtr imesa, int dwords);
+void i830EmitPrim( i830ContextPtr imesa );
+void i830FlushPrims( i830ContextPtr mmesa );
+void i830FlushPrimsLocked( i830ContextPtr mmesa );
+void i830FlushPrimsGetBuffer( i830ContextPtr imesa );
+void i830FlushPrimsGetBufferLocked( i830ContextPtr imesa );
+void i830WaitAgeLocked( i830ContextPtr imesa, int age );
+void i830WaitAge( i830ContextPtr imesa, int age );
+void i830DmaFinish( i830ContextPtr imesa );
+void i830RegetLockQuiescent( i830ContextPtr imesa );
+void i830InitIoctlFuncs( struct dd_function_table *functions );
+void i830CopyBuffer( const __DRIdrawablePrivate *dpriv );
+void i830PageFlip( const __DRIdrawablePrivate *dpriv );
+int i830_check_copy(int fd);
+
+#define I830_STATECHANGE(imesa, flag) \
+do { \
+ if (imesa->vertex_low != imesa->vertex_last_prim) \
+ i830FlushPrims(imesa); \
+ imesa->dirty |= flag; \
+} while (0)
+
+
+#define I830_FIREVERTICES(imesa) \
+do { \
+ if (imesa->vertex_buffer) { \
+ i830FlushPrims(imesa); \
+} \
+} while (0)
+
+
+static __inline GLuint *i830AllocDmaLow( i830ContextPtr imesa, int bytes )
+{
+ if (imesa->vertex_low + bytes > imesa->vertex_high) {
+ i830FlushPrimsGetBuffer( imesa );
+ }
+
+ {
+ GLuint *start = (GLuint *)(imesa->vertex_addr + imesa->vertex_low);
+ imesa->vertex_low += bytes;
+ return start;
+ }
+}
+
+static __inline GLuint *i830AllocDmaLowLocked( i830ContextPtr imesa,
+ int bytes )
+{
+ if (imesa->vertex_low + bytes > imesa->vertex_high) {
+ i830FlushPrimsGetBufferLocked( imesa );
+ }
+
+ {
+ GLuint *start = (GLuint *)(imesa->vertex_addr + imesa->vertex_low);
+ imesa->vertex_low += bytes;
+ return start;
+ }
+}
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_render.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_render.c
new file mode 100644
index 000000000..b0592e9cd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_render.c
@@ -0,0 +1,226 @@
+/*
+ * Intel i810 DRI driver for Mesa 3.5
+ *
+ * Copyright (C) 1999-2000 Keith Whitwell 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 KEITH WHITWELL 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Adapted for use on the I830:
+ * Jeff Hartmann <jhartmann@2d3d.com>
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_render.c,v 1.2 2002/12/10 01:26:53 dawes Exp $ */
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * dma buffers. Use strip/fan hardware acceleration where possible.
+ *
+ */
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "enums.h"
+
+#include "tnl/t_context.h"
+
+#include "i830_screen.h"
+#include "i830_dri.h"
+
+#include "i830_context.h"
+#include "i830_tris.h"
+#include "i830_state.h"
+#include "i830_ioctl.h"
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * dma buffers. Use strip/fan hardware primitives where possible.
+ * Try to simulate missing primitives with indexed vertices.
+ */
+#define HAVE_POINTS 0 /* Has it, but can't use because subpixel has to
+ * be adjusted for points on the I830/I845G
+ */
+#define HAVE_LINES 1
+#define HAVE_LINE_STRIPS 1
+#define HAVE_TRIANGLES 1
+#define HAVE_TRI_STRIPS 1
+#define HAVE_TRI_STRIP_1 0 /* has it, template can't use it yet */
+#define HAVE_TRI_FANS 1
+#define HAVE_POLYGONS 1
+#define HAVE_QUADS 0
+#define HAVE_QUAD_STRIPS 0
+
+#define HAVE_ELTS 0
+
+static GLuint hw_prim[GL_POLYGON+1] = {
+ 0,
+ PRIM3D_LINELIST,
+ PRIM3D_LINESTRIP,
+ PRIM3D_LINESTRIP,
+ PRIM3D_TRILIST,
+ PRIM3D_TRISTRIP,
+ PRIM3D_TRIFAN,
+ 0,
+ 0,
+ PRIM3D_POLY
+};
+
+static const GLenum reduced_prim[GL_POLYGON+1] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES
+};
+
+static const int scale_prim[GL_POLYGON+1] = {
+ 0, /* fallback case */
+ 1,
+ 2,
+ 2,
+ 1,
+ 3,
+ 3,
+ 0, /* fallback case */
+ 0, /* fallback case */
+ 3
+};
+
+
+#define LOCAL_VARS i830ContextPtr imesa = I830_CONTEXT(ctx)
+#define INIT( prim ) do { \
+ I830_STATECHANGE(imesa, 0); \
+ i830RasterPrimitive( ctx, reduced_prim[prim], hw_prim[prim] ); \
+} while (0)
+
+#define FLUSH() I830_FIREVERTICES( imesa )
+#define GET_CURRENT_VB_MAX_VERTS() \
+ (((int)imesa->vertex_high - (int)imesa->vertex_low) / (imesa->vertex_size*4))
+#define GET_SUBSEQUENT_VB_MAX_VERTS() \
+ (I830_DMA_BUF_SZ-8) / (imesa->vertex_size * 4)
+
+
+#define ALLOC_VERTS( nr ) \
+ i830AllocDmaLow( imesa, (nr) * imesa->vertex_size * 4)
+#define EMIT_VERTS( ctx, j, nr, buf ) \
+ _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf)
+
+#define TAG(x) i830_##x
+#include "tnl_dd/t_dd_dmatmp.h"
+
+
+/**********************************************************************/
+/* Render pipeline stage */
+/**********************************************************************/
+
+/* Heuristic for i830, which can only emit a single primitive per dma
+ * buffer, and has only a small number of dma buffers.
+ */
+static GLboolean choose_render( struct vertex_buffer *VB, int bufsz )
+{
+ int nr_prims = 0;
+ int nr_rprims = 0;
+ int nr_rverts = 0;
+ int rprim = 0;
+ int i;
+
+
+ for (i = 0 ; i < VB->PrimitiveCount ; i++)
+ {
+ GLuint prim = VB->Primitive[i].mode;
+ GLuint length = VB->Primitive[i].count;
+
+ if (!length)
+ continue;
+
+ if (!hw_prim[prim & PRIM_MODE_MASK])
+ return GL_FALSE;
+
+ nr_prims++;
+ nr_rverts += length * scale_prim[prim & PRIM_MODE_MASK];
+
+ if (reduced_prim[prim&PRIM_MODE_MASK] != rprim) {
+ nr_rprims++;
+ rprim = reduced_prim[prim&PRIM_MODE_MASK];
+ }
+ }
+
+ nr_prims += i / bufsz;
+ nr_rprims += nr_rverts / bufsz;
+
+ if ((nr_prims > nr_rprims * 2) ||
+ (nr_prims > nr_rprims + 3))
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
+
+static GLboolean i830_run_render( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i;
+ /* Don't handle clipping or indexed vertices.
+ */
+ if (imesa->RenderIndex != 0 ||
+ !i830_validate_render( ctx, VB ) ||
+ !choose_render( VB, 200 )) { /* 200 is estimate of nr verts/buf */
+ return GL_TRUE;
+ }
+
+ tnl->Driver.Render.Start( ctx );
+
+ for (i = 0 ; i < VB->PrimitiveCount ; i++)
+ {
+ GLuint prim = VB->Primitive[i].mode;
+ GLuint start = VB->Primitive[i].start;
+ GLuint length = VB->Primitive[i].count;
+
+ if (!length)
+ continue;
+
+ i830_render_tab_verts[prim & PRIM_MODE_MASK]( ctx, start, start + length,
+ prim );
+ }
+
+ tnl->Driver.Render.Finish( ctx );
+
+ return GL_FALSE; /* finished the pipe */
+}
+
+
+const struct tnl_pipeline_stage _i830_render_stage =
+{
+ "i830 render",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ i830_run_render /* run */
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_screen.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_screen.c
new file mode 100644
index 000000000..25def0b6f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_screen.c
@@ -0,0 +1,557 @@
+/**************************************************************************
+ *
+ * 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.
+ *
+ * **************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_screen.c,v 1.3 2002/12/10 01:26:53 dawes Exp $ */
+
+/**
+ * \file i830_screen.c
+ *
+ * Adapted for use on the I830M by Jeff Hartmann.
+ *
+ * \author Keith Whitwell <keith@tungstengraphics.com>
+ * \author Jeff Hartmann <jhartmann@2d3d.com>
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "matrix.h"
+#include "simple_list.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+
+#include "i830_screen.h"
+#include "i830_dri.h"
+
+#include "i830_state.h"
+#include "i830_tex.h"
+#include "i830_span.h"
+#include "i830_tris.h"
+#include "i830_ioctl.h"
+
+#include "i830_dri.h"
+
+#include "utils.h"
+#include "xmlpool.h"
+#include "drirenderbuffer.h"
+
+PUBLIC const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_MAX_TEXTURE_UNITS(4,2,4)
+ DRI_CONF_FORCE_S3TC_ENABLE(false)
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+const GLuint __driNConfigOptions = 2;
+
+extern const struct dri_extension card_extensions[];
+
+static int i830_malloc_proxy_buf(drmBufMapPtr buffers)
+{
+ char *buffer;
+ drmBufPtr buf;
+ int i;
+
+ buffer = ALIGN_MALLOC(I830_DMA_BUF_SZ, 32);
+ if(buffer == NULL) return -1;
+ for(i = 0; i < I830_DMA_BUF_NR; i++) {
+ buf = &(buffers->list[i]);
+ buf->address = (drmAddress)buffer;
+ }
+
+ return 0;
+}
+
+static drmBufMapPtr i830_create_empty_buffers(void)
+{
+ drmBufMapPtr retval;
+
+ retval = (drmBufMapPtr)ALIGN_MALLOC(sizeof(drmBufMap), 32);
+ if(retval == NULL) return NULL;
+ memset(retval, 0, sizeof(drmBufMap));
+ retval->list = (drmBufPtr)ALIGN_MALLOC(sizeof(drmBuf) * I830_DMA_BUF_NR, 32);
+ if(retval->list == NULL) {
+ FREE(retval);
+ return NULL;
+ }
+
+ memset(retval->list, 0, sizeof(drmBuf) * I830_DMA_BUF_NR);
+ return retval;
+}
+
+static void i830PrintDRIInfo(i830ScreenPrivate *i830Screen,
+ __DRIscreenPrivate *sPriv,
+ I830DRIPtr gDRIPriv)
+{
+ GLuint size = (gDRIPriv->ringSize +
+ i830Screen->textureSize +
+ i830Screen->depth.size +
+ i830Screen->back.size +
+ sPriv->fbSize +
+ I830_DMA_BUF_NR * I830_DMA_BUF_SZ +
+ 32768 /* Context Memory */ +
+ 16*4096 /* Ring buffer */ +
+ 64*1024 /* Scratch buffer */ +
+ 4096 /* Cursor */);
+ GLuint size_low = (gDRIPriv->ringSize +
+ i830Screen->textureSize +
+ sPriv->fbSize +
+ I830_DMA_BUF_NR * I830_DMA_BUF_SZ +
+ 32768 /* Context Memory */ +
+ 16*4096 /* Ring buffer */ +
+ 64*1024 /* Scratch buffer */);
+
+ fprintf(stderr, "\nFront size : 0x%x\n", sPriv->fbSize);
+ fprintf(stderr, "Front offset : 0x%x\n", i830Screen->fbOffset);
+ fprintf(stderr, "Back size : 0x%x\n", i830Screen->back.size);
+ fprintf(stderr, "Back offset : 0x%x\n", i830Screen->backOffset);
+ fprintf(stderr, "Depth size : 0x%x\n", i830Screen->depth.size);
+ fprintf(stderr, "Depth offset : 0x%x\n", i830Screen->depthOffset);
+ fprintf(stderr, "Texture size : 0x%x\n", i830Screen->textureSize);
+ fprintf(stderr, "Texture offset : 0x%x\n", i830Screen->textureOffset);
+ fprintf(stderr, "Ring offset : 0x%x\n", gDRIPriv->ringOffset);
+ fprintf(stderr, "Ring size : 0x%x\n", gDRIPriv->ringSize);
+ fprintf(stderr, "Memory : 0x%x\n", gDRIPriv->mem);
+ fprintf(stderr, "Used Memory : low(0x%x) high(0x%x)\n", size_low, size);
+}
+
+static GLboolean i830InitDriver(__DRIscreenPrivate *sPriv)
+{
+ i830ScreenPrivate *i830Screen;
+ I830DRIPtr gDRIPriv = (I830DRIPtr)sPriv->pDevPriv;
+ PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
+ (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
+ void * const psc = sPriv->psc->screenConfigs;
+
+ if (sPriv->devPrivSize != sizeof(I830DRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
+
+ /* Allocate the private area */
+ i830Screen = (i830ScreenPrivate *)CALLOC(sizeof(i830ScreenPrivate));
+ if (!i830Screen) {
+ fprintf(stderr,"\nERROR! Allocating private area failed\n");
+ return GL_FALSE;
+ }
+
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo (&i830Screen->optionCache,
+ __driConfigOptions, __driNConfigOptions);
+
+
+ i830Screen->driScrnPriv = sPriv;
+ sPriv->private = (void *)i830Screen;
+
+ i830Screen->deviceID = gDRIPriv->deviceID;
+ i830Screen->width = gDRIPriv->width;
+ i830Screen->height = gDRIPriv->height;
+ i830Screen->mem = gDRIPriv->mem;
+ i830Screen->cpp = gDRIPriv->cpp;
+ i830Screen->fbStride = gDRIPriv->fbStride;
+ i830Screen->fbOffset = gDRIPriv->fbOffset;
+
+ switch (gDRIPriv->bitsPerPixel) {
+ case 15: i830Screen->fbFormat = DV_PF_555; break;
+ case 16: i830Screen->fbFormat = DV_PF_565; break;
+ case 32: i830Screen->fbFormat = DV_PF_8888; break;
+ }
+
+ i830Screen->backOffset = gDRIPriv->backOffset;
+ i830Screen->depthOffset = gDRIPriv->depthOffset;
+ i830Screen->backPitch = gDRIPriv->auxPitch;
+ i830Screen->backPitchBits = gDRIPriv->auxPitchBits;
+ i830Screen->textureOffset = gDRIPriv->textureOffset;
+ i830Screen->textureSize = gDRIPriv->textureSize;
+ i830Screen->logTextureGranularity = gDRIPriv->logTextureGranularity;
+
+
+ i830Screen->bufs = i830_create_empty_buffers();
+ if(i830Screen->bufs == NULL) {
+ fprintf(stderr,"\nERROR: Failed to create empty buffers in %s \n",
+ __FUNCTION__);
+ FREE(i830Screen);
+ return GL_FALSE;
+ }
+
+ /* Check if you need to create a fake buffer */
+ if(i830_check_copy(sPriv->fd) == 1) {
+ i830_malloc_proxy_buf(i830Screen->bufs);
+ i830Screen->use_copy_buf = 1;
+ } else {
+ i830Screen->use_copy_buf = 0;
+ }
+
+ i830Screen->back.handle = gDRIPriv->backbuffer;
+ i830Screen->back.size = gDRIPriv->backbufferSize;
+
+ if (drmMap(sPriv->fd,
+ i830Screen->back.handle,
+ i830Screen->back.size,
+ (drmAddress *)&i830Screen->back.map) != 0) {
+ fprintf(stderr, "\nERROR: line %d, Function %s, File %s\n",
+ __LINE__, __FUNCTION__, __FILE__);
+ FREE(i830Screen);
+ sPriv->private = NULL;
+ return GL_FALSE;
+ }
+
+ i830Screen->depth.handle = gDRIPriv->depthbuffer;
+ i830Screen->depth.size = gDRIPriv->depthbufferSize;
+
+ if (drmMap(sPriv->fd,
+ i830Screen->depth.handle,
+ i830Screen->depth.size,
+ (drmAddress *)&i830Screen->depth.map) != 0) {
+ fprintf(stderr, "\nERROR: line %d, Function %s, File %s\n",
+ __LINE__, __FUNCTION__, __FILE__);
+ FREE(i830Screen);
+ drmUnmap(i830Screen->back.map, i830Screen->back.size);
+ sPriv->private = NULL;
+ return GL_FALSE;
+ }
+
+ i830Screen->tex.handle = gDRIPriv->textures;
+ i830Screen->tex.size = gDRIPriv->textureSize;
+
+ if (drmMap(sPriv->fd,
+ i830Screen->tex.handle,
+ i830Screen->tex.size,
+ (drmAddress *)&i830Screen->tex.map) != 0) {
+ fprintf(stderr, "\nERROR: line %d, Function %s, File %s\n",
+ __LINE__, __FUNCTION__, __FILE__);
+ FREE(i830Screen);
+ drmUnmap(i830Screen->back.map, i830Screen->back.size);
+ drmUnmap(i830Screen->depth.map, i830Screen->depth.size);
+ sPriv->private = NULL;
+ return GL_FALSE;
+ }
+
+ i830Screen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
+
+ if (0) i830PrintDRIInfo(i830Screen, sPriv, gDRIPriv);
+
+ i830Screen->drmMinor = sPriv->drmMinor;
+
+ if (sPriv->drmMinor >= 3) {
+ int ret;
+ drmI830GetParam gp;
+
+ gp.param = I830_PARAM_IRQ_ACTIVE;
+ gp.value = &i830Screen->irq_active;
+
+ ret = drmCommandWriteRead( sPriv->fd, DRM_I830_GETPARAM,
+ &gp, sizeof(gp));
+ if (ret) {
+ fprintf(stderr, "drmI830GetParam: %d\n", ret);
+ return GL_FALSE;
+ }
+ }
+
+#if 0
+ if (sPriv->drmMinor >= 3) {
+ int ret;
+ drmI830SetParam sp;
+
+ sp.param = I830_SETPARAM_PERF_BOXES;
+ sp.value = (getenv("I830_DO_BOXES") != 0);
+
+ ret = drmCommandWrite( sPriv->fd, DRM_I830_SETPARAM,
+ &sp, sizeof(sp));
+ if (ret)
+ fprintf(stderr, "Couldn't set perfboxes: %d\n", ret);
+ }
+#endif
+
+ if ( glx_enable_extension != NULL ) {
+ (*glx_enable_extension)( psc, "GLX_SGI_make_current_read" );
+ }
+
+ return GL_TRUE;
+}
+
+
+static void i830DestroyScreen(__DRIscreenPrivate *sPriv)
+{
+ i830ScreenPrivate *i830Screen = (i830ScreenPrivate *)sPriv->private;
+
+ /* Need to unmap all the bufs and maps here:
+ */
+ drmUnmap(i830Screen->back.map, i830Screen->back.size);
+ drmUnmap(i830Screen->depth.map, i830Screen->depth.size);
+ drmUnmap(i830Screen->tex.map, i830Screen->tex.size);
+ FREE(i830Screen);
+ sPriv->private = NULL;
+}
+
+
+static GLboolean i830CreateBuffer(__DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ i830ScreenPrivate *screen = (i830ScreenPrivate *) driScrnPriv->private;
+
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+#if 0
+ GLboolean swStencil = (mesaVis->stencilBits > 0 &&
+ mesaVis->depthBits != 24);
+#else
+ GLboolean swStencil = mesaVis->stencilBits > 0;
+#endif
+
+#if 0
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE /* s/w alpha planes */);
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ /*screen->frontOffset*/0, screen->backPitch);
+ i830SetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ i830SetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->backPitch);
+ i830SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ if (mesaVis->stencilBits == 8) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->backPitch);
+ i830SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else {
+ /* not really 32-bit Z, but use GL_DEPTH_COMPONENT32 anyway */
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT32, screen->cpp,
+ screen->depthOffset, screen->backPitch);
+ i830SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ }
+
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+ screen->depthOffset, screen->backPitch);
+ i830SetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+static void i830DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+static const struct __DriverAPIRec i830API = {
+ .InitDriver = i830InitDriver,
+ .DestroyScreen = i830DestroyScreen,
+ .CreateContext = i830CreateContext,
+ .DestroyContext = i830DestroyContext,
+ .CreateBuffer = i830CreateBuffer,
+ .DestroyBuffer = i830DestroyBuffer,
+ .SwapBuffers = i830SwapBuffers,
+ .MakeCurrent = i830MakeCurrent,
+ .UnbindContext = i830UnbindContext,
+ .GetSwapInfo = NULL,
+ .GetMSC = NULL,
+ .WaitForMSC = NULL,
+ .WaitForSBC = NULL,
+ .SwapBuffersMSC = NULL
+};
+
+
+static __GLcontextModes *
+i830FillInModes( unsigned pixel_bits, unsigned depth_bits,
+ unsigned stencil_bits, GLboolean have_back_buffer )
+{
+ __GLcontextModes * modes;
+ __GLcontextModes * m;
+ unsigned num_modes;
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ GLenum fb_format;
+ GLenum fb_type;
+
+ /* GLX_SWAP_COPY_OML is only supported because the MGA driver doesn't
+ * support pageflipping at all.
+ */
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
+ };
+
+ u_int8_t depth_bits_array[2];
+ u_int8_t stencil_bits_array[2];
+
+
+ depth_bits_array[0] = 0;
+ depth_bits_array[1] = depth_bits;
+
+ /* Just like with the accumulation buffer, always provide some modes
+ * with a stencil buffer. It will be a sw fallback, but some apps won't
+ * care about that.
+ */
+ stencil_bits_array[0] = 0;
+ stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
+
+ depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1;
+ back_buffer_factor = (have_back_buffer) ? 3 : 1;
+
+ num_modes = depth_buffer_factor * back_buffer_factor * 4;
+
+ if ( pixel_bits == 16 ) {
+ fb_format = GL_RGB;
+ fb_type = GL_UNSIGNED_SHORT_5_6_5;
+ }
+ else {
+ fb_format = GL_BGRA;
+ fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ }
+
+ modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
+ m = modes;
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_TRUE_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+
+ /* There's no direct color modes on i830? */
+
+ /* Mark the visual as slow if there are "fake" stencil bits.
+ */
+ for ( m = modes ; m != NULL ; m = m->next ) {
+ if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) {
+ m->visualRating = GLX_SLOW_CONFIG;
+ }
+ }
+
+ return modes;
+}
+
+
+/**
+ * This is the bootstrap function for the driver. libGL supplies all of the
+ * requisite information about the system, and the driver initializes itself.
+ * This routine also fills in the linked list pointed to by \c driver_modes
+ * with the \c __GLcontextModes that the driver can support for windows or
+ * pbuffers.
+ *
+ * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
+ * failure.
+ */
+PUBLIC
+void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
+ const __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drmAddress pSAREA, int fd,
+ int internal_api_version,
+ const __DRIinterfaceMethods * interface,
+ __GLcontextModes ** driver_modes )
+
+{
+ __DRIscreenPrivate *psp;
+ static const __DRIversion ddx_expected = { 1, 0, 0 };
+ static const __DRIversion dri_expected = { 4, 0, 0 };
+ static const __DRIversion drm_expected = { 1, 3, 0 };
+
+ dri_interface = interface;
+
+ if ( ! driCheckDriDdxDrmVersions2( "i830",
+ dri_version, & dri_expected,
+ ddx_version, & ddx_expected,
+ drm_version, & drm_expected ) ) {
+ return NULL;
+ }
+
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &i830API);
+ if ( psp != NULL ) {
+ I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
+ *driver_modes = i830FillInModes( dri_priv->cpp * 8,
+ (dri_priv->cpp == 2) ? 16 : 24,
+ (dri_priv->cpp == 2) ? 0 : 8,
+ (dri_priv->backOffset != dri_priv->depthOffset) );
+
+ /* Calling driInitExtensions here, with a NULL context pointer, does not actually
+ * enable the extensions. It just makes sure that all the dispatch offsets for all
+ * the extensions that *might* be enables are known. This is needed because the
+ * dispatch offsets need to be known when _mesa_context_create is called, but we can't
+ * enable the extensions until we have a context pointer.
+ *
+ * Hello chicken. Hello egg. How are you two today?
+ */
+ driInitExtensions( NULL, card_extensions, GL_FALSE );
+ }
+
+ return (void *) psp;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_screen.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_screen.h
new file mode 100644
index 000000000..edbe719e0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_screen.h
@@ -0,0 +1,113 @@
+/**************************************************************************
+
+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 <keith@tungstengraphics.com>
+ * Adapted for use on the I830M:
+ * Jeff Hartmann <jhartmann@2d3d.com>
+ */
+
+#ifndef _I830_INIT_H_
+#define _I830_INIT_H_
+
+#include <sys/time.h>
+#include "dri_util.h"
+#include "xmlconfig.h"
+
+
+typedef struct {
+ drm_handle_t handle;
+ drmSize size;
+ char *map;
+} i830Region, *i830RegionPtr;
+
+typedef struct
+{
+
+ i830Region front;
+ i830Region back;
+ i830Region depth;
+ i830Region tex;
+
+ int deviceID;
+ int width;
+ int height;
+ int mem;
+
+ int cpp; /* for front and back buffers */
+ int bitsPerPixel;
+
+ int fbFormat;
+ int fbOffset;
+ int fbStride;
+
+ int backOffset;
+ int depthOffset;
+
+ int backPitch;
+ int backPitchBits;
+
+ int textureOffset;
+ int textureSize;
+ int logTextureGranularity;
+
+ __DRIscreenPrivate *driScrnPriv;
+ drmBufMapPtr bufs;
+ int use_copy_buf;
+ unsigned int sarea_priv_offset;
+
+ int drmMinor;
+ int irq_active;
+
+ /**
+ * Configuration cache with default values for all contexts
+ */
+ driOptionCache optionCache;
+}i830ScreenPrivate;
+
+
+extern GLboolean
+i830CreateContext( const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate );
+
+extern void
+i830DestroyContext(__DRIcontextPrivate *driContextPriv);
+
+extern GLboolean
+i830UnbindContext(__DRIcontextPrivate *driContextPriv);
+
+extern GLboolean
+i830MakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv);
+
+extern void
+i830SwapBuffers(__DRIdrawablePrivate *driDrawPriv);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_span.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_span.c
new file mode 100644
index 000000000..4a86784e8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_span.c
@@ -0,0 +1,427 @@
+/**************************************************************************
+
+Copyright 2001 VA Linux Systems Inc., Fremont, 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
+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, VA LINUX SYSTEMS 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.
+
+**************************************************************************/
+
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_span.c,v 1.4 2002/12/10 01:26:53 dawes Exp $ */
+
+/**
+ * \file i830_span.c
+ *
+ * Heavily based on the I810 driver, which was written by Keith Whitwell.
+ *
+ * \author Jeff Hartmann <jhartmann@2d3d.com>
+ * \author Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "colormac.h"
+
+#include "i830_screen.h"
+#include "i830_dri.h"
+
+#include "i830_span.h"
+#include "i830_ioctl.h"
+#include "swrast/swrast.h"
+
+
+#define DBG 0
+
+#define LOCAL_VARS \
+ i830ContextPtr imesa = I830_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = imesa->mesa_drawable; \
+ i830ScreenPrivate *i830Screen = imesa->i830Screen; \
+ GLuint pitch = i830Screen->backPitch * i830Screen->cpp; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(imesa->drawMap + \
+ dPriv->x * i830Screen->cpp + \
+ dPriv->y * pitch); \
+ char *read_buf = (char *)(imesa->readMap + \
+ dPriv->x * i830Screen->cpp + \
+ dPriv->y * pitch); \
+ GLushort p; \
+ (void) read_buf; (void) buf; (void) p
+
+#define LOCAL_DEPTH_VARS \
+ i830ContextPtr imesa = I830_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = imesa->mesa_drawable; \
+ i830ScreenPrivate *i830Screen = imesa->i830Screen; \
+ GLuint pitch = i830Screen->backPitch * i830Screen->cpp; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(i830Screen->depth.map + \
+ dPriv->x * i830Screen->cpp + \
+ dPriv->y * pitch)
+
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
+
+#define INIT_MONO_PIXEL(p,color)\
+ p = PACK_COLOR_565(color[0],color[1],color[2])
+
+#define Y_FLIP(_y) (height - _y - 1)
+
+#define HW_LOCK()
+
+#define HW_UNLOCK()
+
+/* 16 bit, 565 rgb 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 >> 11) & 0x1f) * 255) / 31; \
+ rgba[1] = (((p >> 5) & 0x3f) * 255) / 63; \
+ rgba[2] = (((p >> 0) & 0x1f) * 255) / 31; \
+ rgba[3] = 255; \
+} while(0)
+
+#define TAG(x) i830##x##_565
+#include "spantmp.h"
+
+/* 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 *)(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) i830##x##_555
+#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) i830##x##_16
+#include "depthtmp.h"
+
+
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ i830ContextPtr imesa = I830_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable; \
+ i830ScreenPrivate *i830Screen = imesa->i830Screen; \
+ GLuint pitch = i830Screen->backPitch * i830Screen->cpp; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(imesa->drawMap + \
+ dPriv->x * i830Screen->cpp + \
+ dPriv->y * pitch); \
+ char *read_buf = (char *)(imesa->readMap + \
+ dPriv->x * i830Screen->cpp + \
+ dPriv->y * pitch); \
+ GLuint p = I830_CONTEXT( ctx )->MonoColor; \
+ (void) read_buf; (void) buf; (void) p
+
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p,color)\
+ p = PACK_COLOR_888(color[0],color[1],color[2])
+
+/* 32 bit, 8888 argb 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) i830##x##_8888
+#include "spantmp.h"
+
+/* 24 bit depthbuffer functions.
+ */
+#define WRITE_DEPTH( _x, _y, d ) \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = 0xffffff & d;
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLuint *)(buf + _x*4 + _y*pitch) & 0xffffff;
+
+#define TAG(x) i830##x##_24
+#include "depthtmp.h"
+
+/* 24/8 bit interleaved depth/stencil functions
+ */
+#define WRITE_DEPTH( _x, _y, d ) { \
+ GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \
+ tmp &= 0xff000000; \
+ tmp |= (d) & 0xffffff; \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \
+}
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLuint *)(buf + _x*4 + _y*pitch) & 0xffffff;
+
+
+#define TAG(x) i830##x##_24_8
+#include "depthtmp.h"
+
+#define WRITE_STENCIL( _x, _y, d ) { \
+ GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \
+ tmp &= 0xffffff; \
+ tmp |= (d<<24); \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \
+}
+
+#define READ_STENCIL( d, _x, _y ) \
+ d = *(GLuint *)(buf + _x*4 + _y*pitch) >> 24;
+
+#define TAG(x) i830##x##_24_8
+#include "stenciltmp.h"
+
+/*
+ * This function is called to specify which buffer to read and write
+ * for software rasterization (swrast) fallbacks. This doesn't necessarily
+ * correspond to glDrawBuffer() or glReadBuffer() calls.
+ */
+static void i830SetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
+ GLuint bufferBit)
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+
+ assert( (colorBuffer == imesa->driDrawable->driverPrivate)
+ || (colorBuffer == imesa->driReadable->driverPrivate) );
+
+ imesa->mesa_drawable = (colorBuffer == imesa->driDrawable->driverPrivate)
+ ? imesa->driDrawable : imesa->driReadable;
+
+ if (bufferBit == BUFFER_BIT_FRONT_LEFT) {
+ imesa->drawMap = (char *)imesa->driScreen->pFB;
+ imesa->readMap = (char *)imesa->driScreen->pFB;
+ } else if (bufferBit == BUFFER_BIT_BACK_LEFT) {
+ imesa->drawMap = imesa->i830Screen->back.map;
+ imesa->readMap = imesa->i830Screen->back.map;
+ } else {
+ ASSERT(0);
+ }
+}
+
+
+
+/* Move locking out to get reasonable span performance.
+ */
+void i830SpanRenderStart( GLcontext *ctx )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ I830_FIREVERTICES(imesa);
+ LOCK_HARDWARE(imesa);
+ i830RegetLockQuiescent( imesa );
+}
+
+void i830SpanRenderFinish( GLcontext *ctx )
+{
+ i830ContextPtr imesa = I830_CONTEXT( ctx );
+ _swrast_flush( ctx );
+ UNLOCK_HARDWARE( imesa );
+}
+
+void i830DDInitSpanFuncs( GLcontext *ctx )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ i830ScreenPrivate *i830Screen = imesa->i830Screen;
+
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetBuffer = i830SetBuffer;
+
+ switch (i830Screen->fbFormat) {
+ case DV_PF_555:
+#if 0
+ swdd->WriteRGBASpan = i830WriteRGBASpan_555;
+ swdd->WriteRGBSpan = i830WriteRGBSpan_555;
+ swdd->WriteMonoRGBASpan = i830WriteMonoRGBASpan_555;
+ swdd->WriteRGBAPixels = i830WriteRGBAPixels_555;
+ swdd->WriteMonoRGBAPixels = i830WriteMonoRGBAPixels_555;
+ swdd->ReadRGBASpan = i830ReadRGBASpan_555;
+ swdd->ReadRGBAPixels = i830ReadRGBAPixels_555;
+ swdd->ReadDepthSpan = i830ReadDepthSpan_16;
+ swdd->WriteDepthSpan = i830WriteDepthSpan_16;
+ swdd->ReadDepthPixels = i830ReadDepthPixels_16;
+ swdd->WriteDepthPixels = i830WriteDepthPixels_16;
+#endif
+ break;
+
+ case DV_PF_565:
+#if 0
+ swdd->WriteRGBASpan = i830WriteRGBASpan_565;
+ swdd->WriteRGBSpan = i830WriteRGBSpan_565;
+ swdd->WriteMonoRGBASpan = i830WriteMonoRGBASpan_565;
+ swdd->WriteRGBAPixels = i830WriteRGBAPixels_565;
+ swdd->WriteMonoRGBAPixels = i830WriteMonoRGBAPixels_565;
+ swdd->ReadRGBASpan = i830ReadRGBASpan_565;
+ swdd->ReadRGBAPixels = i830ReadRGBAPixels_565;
+ swdd->ReadDepthSpan = i830ReadDepthSpan_16;
+ swdd->WriteDepthSpan = i830WriteDepthSpan_16;
+ swdd->ReadDepthPixels = i830ReadDepthPixels_16;
+ swdd->WriteDepthPixels = i830WriteDepthPixels_16;
+#endif
+ break;
+
+ case DV_PF_8888:
+#if 0
+ swdd->WriteRGBASpan = i830WriteRGBASpan_8888;
+ swdd->WriteRGBSpan = i830WriteRGBSpan_8888;
+ swdd->WriteMonoRGBASpan = i830WriteMonoRGBASpan_8888;
+ swdd->WriteRGBAPixels = i830WriteRGBAPixels_8888;
+ swdd->WriteMonoRGBAPixels = i830WriteMonoRGBAPixels_8888;
+ swdd->ReadRGBASpan = i830ReadRGBASpan_8888;
+ swdd->ReadRGBAPixels = i830ReadRGBAPixels_8888;
+#endif
+
+ if(imesa->hw_stencil) {
+#if 0
+ swdd->ReadDepthSpan = i830ReadDepthSpan_24_8;
+ swdd->WriteDepthSpan = i830WriteDepthSpan_24_8;
+ swdd->ReadDepthPixels = i830ReadDepthPixels_24_8;
+ swdd->WriteDepthPixels = i830WriteDepthPixels_24_8;
+ swdd->WriteStencilSpan = i830WriteStencilSpan_24_8;
+ swdd->ReadStencilSpan = i830ReadStencilSpan_24_8;
+ swdd->WriteStencilPixels = i830WriteStencilPixels_24_8;
+ swdd->ReadStencilPixels = i830ReadStencilPixels_24_8;
+#endif
+ } else {
+#if 0
+ swdd->ReadDepthSpan = i830ReadDepthSpan_24;
+ swdd->WriteDepthSpan = i830WriteDepthSpan_24;
+ swdd->ReadDepthPixels = i830ReadDepthPixels_24;
+ swdd->WriteDepthPixels = i830WriteDepthPixels_24;
+#endif
+ }
+ break;
+ }
+
+ swdd->SpanRenderStart = i830SpanRenderStart;
+ swdd->SpanRenderFinish = i830SpanRenderFinish;
+}
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+i830SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 5 && vis->blueBits == 5) {
+ drb->Base.GetRow = i830ReadRGBASpan_555;
+ drb->Base.GetValues = i830ReadRGBAPixels_555;
+ drb->Base.PutRow = i830WriteRGBASpan_555;
+ drb->Base.PutRowRGB = i830WriteRGBSpan_555;
+ drb->Base.PutMonoRow = i830WriteMonoRGBASpan_555;
+ drb->Base.PutValues = i830WriteRGBAPixels_555;
+ drb->Base.PutMonoValues = i830WriteMonoRGBAPixels_555;
+ }
+ else if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ drb->Base.GetRow = i830ReadRGBASpan_565;
+ drb->Base.GetValues = i830ReadRGBAPixels_565;
+ drb->Base.PutRow = i830WriteRGBASpan_565;
+ drb->Base.PutRowRGB = i830WriteRGBSpan_565;
+ drb->Base.PutMonoRow = i830WriteMonoRGBASpan_565;
+ drb->Base.PutValues = i830WriteRGBAPixels_565;
+ drb->Base.PutMonoValues = i830WriteMonoRGBAPixels_565;
+ }
+ else {
+ assert(vis->redBits == 8);
+ assert(vis->greenBits == 8);
+ assert(vis->blueBits == 8);
+ drb->Base.GetRow = i830ReadRGBASpan_8888;
+ drb->Base.GetValues = i830ReadRGBAPixels_8888;
+ drb->Base.PutRow = i830WriteRGBASpan_8888;
+ drb->Base.PutRowRGB = i830WriteRGBSpan_8888;
+ drb->Base.PutMonoRow = i830WriteMonoRGBASpan_8888;
+ drb->Base.PutValues = i830WriteRGBAPixels_8888;
+ drb->Base.PutMonoValues = i830WriteMonoRGBAPixels_8888;
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = i830ReadDepthSpan_16;
+ drb->Base.GetValues = i830ReadDepthPixels_16;
+ drb->Base.PutRow = i830WriteDepthSpan_16;
+ drb->Base.PutMonoRow = i830WriteMonoDepthSpan_16;
+ drb->Base.PutValues = i830WriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = i830ReadDepthSpan_24_8;
+ drb->Base.GetValues = i830ReadDepthPixels_24_8;
+ drb->Base.PutRow = i830WriteDepthSpan_24_8;
+ drb->Base.PutMonoRow = i830WriteMonoDepthSpan_24_8;
+ drb->Base.PutValues = i830WriteDepthPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
+ /* not _really_ 32-bit Z */
+ drb->Base.GetRow = i830ReadDepthSpan_24;
+ drb->Base.GetValues = i830ReadDepthPixels_24;
+ drb->Base.PutRow = i830WriteDepthSpan_24;
+ drb->Base.PutMonoRow = i830WriteMonoDepthSpan_24;
+ drb->Base.PutValues = i830WriteDepthPixels_24;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = i830ReadStencilSpan_24_8;
+ drb->Base.GetValues = i830ReadStencilPixels_24_8;
+ drb->Base.PutRow = i830WriteStencilSpan_24_8;
+ drb->Base.PutMonoRow = i830WriteMonoStencilSpan_24_8;
+ drb->Base.PutValues = i830WriteStencilPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_span.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_span.h
new file mode 100644
index 000000000..4b8341971
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_span.h
@@ -0,0 +1,51 @@
+/**************************************************************************
+
+Copyright 2001 VA Linux Systems Inc., Fremont, 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
+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, VA LINUX SYSTEMS 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.
+
+**************************************************************************/
+
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_span.h,v 1.2 2002/09/11 00:29:26 dawes Exp $ */
+
+/*
+ * Author:
+ * Jeff Hartmann <jhartmann@2d3d.com>
+ *
+ * Heavily based on the I810 driver, which was written by:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef _I830_SPAN_H
+#define _I830_SPAN_H
+
+#include "drirenderbuffer.h"
+
+extern void i830DDInitSpanFuncs( GLcontext *ctx );
+
+extern void i830SpanRenderFinish( GLcontext *ctx );
+extern void i830SpanRenderStart( GLcontext *ctx );
+
+extern void
+i830SetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_state.c
new file mode 100644
index 000000000..615348544
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_state.c
@@ -0,0 +1,1707 @@
+/**************************************************************************
+
+Copyright 2001 2d3d Inc., Delray Beach, FL
+
+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, VA LINUX SYSTEMS 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.
+
+**************************************************************************/
+
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_state.c,v 1.6 2003/01/28 22:47:06 dawes Exp $ */
+
+/*
+ * Author:
+ * Jeff Hartmann <jhartmann@2d3d.com>
+ *
+ * Heavily based on the I810 driver, which was written by:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "buffers.h"
+#include "context.h"
+#include "macros.h"
+#include "enums.h"
+#include "dd.h"
+
+#include "texmem.h"
+
+#include "i830_screen.h"
+#include "i830_dri.h"
+
+#include "i830_context.h"
+#include "i830_state.h"
+#include "i830_tex.h"
+#include "i830_tris.h"
+#include "i830_ioctl.h"
+
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "tnl/t_pipeline.h"
+
+static __inline__ GLuint i830PackColor(GLuint format,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a)
+{
+
+ if (I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ switch (format) {
+ case DV_PF_555:
+ return I830PACKCOLOR1555(r,g,b,a);
+ case DV_PF_565:
+ return I830PACKCOLOR565(r,g,b);
+ case DV_PF_8888:
+ return I830PACKCOLOR8888(r,g,b,a);
+ default:
+ fprintf(stderr, "unknown format %d\n", (int)format);
+ return 0;
+ }
+}
+
+static void i830StencilFunc(GLcontext *ctx, GLenum func, GLint ref,
+ GLuint mask)
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ int test = 0;
+
+ mask = mask & 0xff;
+
+ if (I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s : func: %s, ref : 0x%x, mask: 0x%x\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(func), ref, mask);
+
+ switch(func) {
+ case GL_NEVER:
+ test = COMPAREFUNC_NEVER;
+ break;
+ case GL_LESS:
+ test = COMPAREFUNC_LESS;
+ break;
+ case GL_LEQUAL:
+ test = COMPAREFUNC_LEQUAL;
+ break;
+ case GL_GREATER:
+ test = COMPAREFUNC_GREATER;
+ break;
+ case GL_GEQUAL:
+ test = COMPAREFUNC_GEQUAL;
+ break;
+ case GL_NOTEQUAL:
+ test = COMPAREFUNC_NOTEQUAL;
+ break;
+ case GL_EQUAL:
+ test = COMPAREFUNC_EQUAL;
+ break;
+ case GL_ALWAYS:
+ test = COMPAREFUNC_ALWAYS;
+ break;
+ default:
+ return;
+ }
+
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_TEST_MASK;
+ imesa->Setup[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_TEST_MASK |
+ STENCIL_TEST_MASK(mask));
+ imesa->Setup[I830_CTXREG_STENCILTST] &= ~(STENCIL_REF_VALUE_MASK |
+ ENABLE_STENCIL_TEST_FUNC_MASK);
+ imesa->Setup[I830_CTXREG_STENCILTST] |= (ENABLE_STENCIL_REF_VALUE |
+ ENABLE_STENCIL_TEST_FUNC |
+ STENCIL_REF_VALUE(ref) |
+ STENCIL_TEST_FUNC(test));
+}
+
+static void i830StencilMask(GLcontext *ctx, GLuint mask)
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+
+ if (I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s : mask 0x%x\n", __FUNCTION__, mask);
+
+ mask = mask & 0xff;
+
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_WRITE_MASK;
+ imesa->Setup[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_WRITE_MASK |
+ STENCIL_WRITE_MASK(mask));
+}
+
+static void i830StencilOp(GLcontext *ctx, GLenum fail, GLenum zfail,
+ GLenum zpass)
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ int fop, dfop, dpop;
+
+ if (I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s: fail : %s, zfail: %s, zpass : %s\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(fail),
+ _mesa_lookup_enum_by_nr(zfail),
+ _mesa_lookup_enum_by_nr(zpass));
+
+ fop = 0; dfop = 0; dpop = 0;
+
+ switch(fail) {
+ case GL_KEEP:
+ fop = STENCILOP_KEEP;
+ break;
+ case GL_ZERO:
+ fop = STENCILOP_ZERO;
+ break;
+ case GL_REPLACE:
+ fop = STENCILOP_REPLACE;
+ break;
+ case GL_INCR:
+ fop = STENCILOP_INCRSAT;
+ break;
+ case GL_DECR:
+ fop = STENCILOP_DECRSAT;
+ break;
+ case GL_INCR_WRAP:
+ fop = STENCILOP_INCR;
+ break;
+ case GL_DECR_WRAP:
+ fop = STENCILOP_DECR;
+ break;
+ case GL_INVERT:
+ fop = STENCILOP_INVERT;
+ break;
+ default:
+ break;
+ }
+ switch(zfail) {
+ case GL_KEEP:
+ dfop = STENCILOP_KEEP;
+ break;
+ case GL_ZERO:
+ dfop = STENCILOP_ZERO;
+ break;
+ case GL_REPLACE:
+ dfop = STENCILOP_REPLACE;
+ break;
+ case GL_INCR:
+ dfop = STENCILOP_INCRSAT;
+ break;
+ case GL_DECR:
+ dfop = STENCILOP_DECRSAT;
+ break;
+ case GL_INCR_WRAP:
+ dfop = STENCILOP_INCR;
+ break;
+ case GL_DECR_WRAP:
+ dfop = STENCILOP_DECR;
+ break;
+ case GL_INVERT:
+ dfop = STENCILOP_INVERT;
+ break;
+ default:
+ break;
+ }
+ switch(zpass) {
+ case GL_KEEP:
+ dpop = STENCILOP_KEEP;
+ break;
+ case GL_ZERO:
+ dpop = STENCILOP_ZERO;
+ break;
+ case GL_REPLACE:
+ dpop = STENCILOP_REPLACE;
+ break;
+ case GL_INCR:
+ dpop = STENCILOP_INCRSAT;
+ break;
+ case GL_DECR:
+ dpop = STENCILOP_DECRSAT;
+ break;
+ case GL_INCR_WRAP:
+ dpop = STENCILOP_INCR;
+ break;
+ case GL_DECR_WRAP:
+ dpop = STENCILOP_DECR;
+ break;
+ case GL_INVERT:
+ dpop = STENCILOP_INVERT;
+ break;
+ default:
+ break;
+ }
+
+
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_STENCILTST] &= ~(STENCIL_OPS_MASK);
+ imesa->Setup[I830_CTXREG_STENCILTST] |= (ENABLE_STENCIL_PARMS |
+ STENCIL_FAIL_OP(fop) |
+ STENCIL_PASS_DEPTH_FAIL_OP(dfop) |
+ STENCIL_PASS_DEPTH_PASS_OP(dpop));
+}
+
+static void i830AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ int test = 0;
+ GLuint refByte = (GLint) (ref * 255.0);
+
+ switch(func) {
+ case GL_NEVER:
+ test = COMPAREFUNC_NEVER;
+ break;
+ case GL_LESS:
+ test = COMPAREFUNC_LESS;
+ break;
+ case GL_LEQUAL:
+ test = COMPAREFUNC_LEQUAL;
+ break;
+ case GL_GREATER:
+ test = COMPAREFUNC_GREATER;
+ break;
+ case GL_GEQUAL:
+ test = COMPAREFUNC_GEQUAL;
+ break;
+ case GL_NOTEQUAL:
+ test = COMPAREFUNC_NOTEQUAL;
+ break;
+ case GL_EQUAL:
+ test = COMPAREFUNC_EQUAL;
+ break;
+ case GL_ALWAYS:
+ test = COMPAREFUNC_ALWAYS;
+ break;
+ default:
+ return;
+ }
+
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_STATE2] &= ~ALPHA_TEST_REF_MASK;
+ imesa->Setup[I830_CTXREG_STATE2] |= (ENABLE_ALPHA_TEST_FUNC |
+ ENABLE_ALPHA_REF_VALUE |
+ ALPHA_TEST_FUNC(test) |
+ ALPHA_REF_VALUE(refByte));
+}
+
+/* This function makes sure that the proper enables are
+ * set for LogicOp, Independant Alpha Blend, and Blending.
+ * It needs to be called from numerous places where we
+ * could change the LogicOp or Independant Alpha Blend without subsequent
+ * calls to glEnable.
+ */
+static void i830EvalLogicOpBlendState(GLcontext *ctx)
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+
+ imesa->Setup[I830_CTXREG_ENABLES_1] &= ~(ENABLE_COLOR_BLEND |
+ ENABLE_LOGIC_OP_MASK);
+ imesa->Setup[I830_CTXREG_IALPHAB] &= ~ENABLE_INDPT_ALPHA_BLEND;
+
+ if (ctx->Color.ColorLogicOpEnabled) {
+ imesa->Setup[I830_CTXREG_ENABLES_1] |= (DISABLE_COLOR_BLEND |
+ ENABLE_LOGIC_OP);
+ imesa->Setup[I830_CTXREG_IALPHAB] |= DISABLE_INDPT_ALPHA_BLEND;
+ } else if (ctx->Color.BlendEnabled) {
+ imesa->Setup[I830_CTXREG_ENABLES_1] |= (ENABLE_COLOR_BLEND |
+ DISABLE_LOGIC_OP);
+
+ /* If the alpha blend state does not match the color blend state,
+ * enable independent alpha blending. Otherwise, leave it disabled
+ * and the hardware will use the color blend state for both.
+ */
+
+ if ( 0 && (imesa->Setup[I830_CTXREG_IALPHAB] & BLEND_STATE_MASK)
+ != (imesa->Setup[I830_CTXREG_STATE1] & BLEND_STATE_MASK) ) {
+ imesa->Setup[I830_CTXREG_IALPHAB] |= ENABLE_INDPT_ALPHA_BLEND;
+ } else {
+ imesa->Setup[I830_CTXREG_IALPHAB] |= DISABLE_INDPT_ALPHA_BLEND;
+ }
+ } else {
+ imesa->Setup[I830_CTXREG_ENABLES_1] |= (DISABLE_COLOR_BLEND |
+ DISABLE_LOGIC_OP);
+ imesa->Setup[I830_CTXREG_IALPHAB] |= DISABLE_INDPT_ALPHA_BLEND;
+ }
+}
+
+static void i830BlendColor(GLcontext *ctx, const GLfloat color[4])
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ GLubyte r, g, b, a;
+
+ if (I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ FLOAT_COLOR_TO_UBYTE_COLOR(r, color[RCOMP]);
+ FLOAT_COLOR_TO_UBYTE_COLOR(g, color[GCOMP]);
+ FLOAT_COLOR_TO_UBYTE_COLOR(b, color[BCOMP]);
+ FLOAT_COLOR_TO_UBYTE_COLOR(a, color[ACOMP]);
+
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_BLENDCOLR] = ((a << 24) |
+ (r << 16) |
+ (g << 8) |
+ b);
+}
+
+/**
+ * Calculate the hardware blend factor setting. This same function is used
+ * for source and destination of both alpha and RGB.
+ *
+ * \returns
+ * The hardware register value for the specified blend factor. This value
+ * will need to be shifted into the correct position for either source or
+ * destination factor.
+ *
+ * \todo
+ * Since the two cases where source and destination are handled differently
+ * are essentially error cases, they should never happen. Determine if these
+ * cases can be removed.
+ */
+static int blend_factor( GLenum factor, GLboolean is_src )
+{
+ int func;
+
+ switch( factor ) {
+ case GL_ZERO:
+ func = BLENDFACT_ZERO;
+ break;
+ case GL_ONE:
+ func = BLENDFACT_ONE;
+ break;
+ case GL_SRC_COLOR:
+ func = BLENDFACT_SRC_COLR;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ func = BLENDFACT_INV_SRC_COLR;
+ break;
+ case GL_SRC_ALPHA:
+ func = BLENDFACT_SRC_ALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ func = BLENDFACT_INV_SRC_ALPHA;
+ break;
+ case GL_DST_ALPHA:
+ func = BLENDFACT_DST_ALPHA;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ func = BLENDFACT_INV_DST_ALPHA;
+ break;
+ case GL_DST_COLOR:
+ func = BLENDFACT_DST_COLR;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ func = BLENDFACT_INV_DST_COLR;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ func = (is_src) ? BLENDFACT_SRC_ALPHA_SATURATE : BLENDFACT_ZERO;
+ break;
+ case GL_CONSTANT_COLOR:
+ func = BLENDFACT_CONST_COLOR;
+ break;
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ func = BLENDFACT_INV_CONST_COLOR;
+ break;
+ case GL_CONSTANT_ALPHA:
+ func = BLENDFACT_CONST_ALPHA;
+ break;
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ func = BLENDFACT_INV_CONST_ALPHA;
+ break;
+ default:
+ func = (is_src) ? BLENDFACT_ONE : BLENDFACT_ZERO;
+ }
+
+ return func;
+}
+
+
+/**
+ * Sets both the blend equation (called "function" in i830 docs) and the
+ * blend function (called "factor" in i830 docs). This is done in a single
+ * function because some blend equations (i.e., \c GL_MIN and \c GL_MAX)
+ * change the interpretation of the blend function.
+ */
+
+static void i830_set_blend_state( GLcontext * ctx )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ int funcA;
+ int funcRGB;
+ int eqnA;
+ int eqnRGB;
+
+
+ funcRGB = SRC_BLND_FACT( blend_factor( ctx->Color.BlendSrcRGB, GL_TRUE ) )
+ | DST_BLND_FACT( blend_factor( ctx->Color.BlendDstRGB, GL_FALSE ) );
+
+ switch(ctx->Color.BlendEquationRGB) {
+ case GL_FUNC_ADD:
+ eqnRGB = BLENDFUNC_ADD;
+ break;
+ case GL_MIN:
+ eqnRGB = BLENDFUNC_MIN;
+ funcRGB = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE);
+ break;
+ case GL_MAX:
+ eqnRGB = BLENDFUNC_MAX;
+ funcRGB = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE);
+ break;
+ case GL_FUNC_SUBTRACT:
+ eqnRGB = BLENDFUNC_SUB;
+ break;
+ case GL_FUNC_REVERSE_SUBTRACT:
+ eqnRGB = BLENDFUNC_RVRSE_SUB;
+ break;
+ default:
+ fprintf( stderr, "[%s:%u] Invalid RGB blend equation (0x%04x).\n",
+ __func__, __LINE__, ctx->Color.BlendEquationRGB );
+ return;
+ }
+
+
+ funcA = SRC_ABLEND_FACT( blend_factor( ctx->Color.BlendSrcA, GL_TRUE ) )
+ | DST_ABLEND_FACT( blend_factor( ctx->Color.BlendDstA, GL_FALSE ) );
+
+ switch(ctx->Color.BlendEquationA) {
+ case GL_FUNC_ADD:
+ eqnA = BLENDFUNC_ADD;
+ break;
+ case GL_MIN:
+ eqnA = BLENDFUNC_MIN;
+ funcA = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE);
+ break;
+ case GL_MAX:
+ eqnA = BLENDFUNC_MAX;
+ funcA = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE);
+ break;
+ case GL_FUNC_SUBTRACT:
+ eqnA = BLENDFUNC_SUB;
+ break;
+ case GL_FUNC_REVERSE_SUBTRACT:
+ eqnA = BLENDFUNC_RVRSE_SUB;
+ break;
+ default:
+ fprintf( stderr, "[%s:%u] Invalid alpha blend equation (0x%04x).\n",
+ __func__, __LINE__, ctx->Color.BlendEquationA );
+ return;
+ }
+
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+
+ imesa->Setup[I830_CTXREG_STATE1] = eqnRGB | funcRGB
+ | STATE3D_MODES_1_CMD
+ | ENABLE_SRC_BLND_FACTOR | ENABLE_DST_BLND_FACTOR
+ | ENABLE_COLR_BLND_FUNC;
+
+ imesa->Setup[I830_CTXREG_IALPHAB] = eqnA | funcA
+ | STATE3D_INDPT_ALPHA_BLEND_CMD
+ | ENABLE_SRC_ABLEND_FACTOR | ENABLE_DST_ABLEND_FACTOR
+ | ENABLE_ALPHA_BLENDFUNC;
+
+
+ /* This will catch a logicop blend equation. It will also ensure
+ * independant alpha blend is really in the correct state (either enabled
+ * or disabled) if blending is already enabled.
+ */
+
+ i830EvalLogicOpBlendState(ctx);
+
+ if (0) {
+ fprintf(stderr, "[%s:%u] STATE1: 0x%08x IALPHAB: 0x%08x blend is %sabled\n",
+ __func__, __LINE__,
+ imesa->Setup[I830_CTXREG_STATE1],
+ imesa->Setup[I830_CTXREG_IALPHAB],
+ (ctx->Color.BlendEnabled) ? "en" : "dis");
+ }
+}
+
+static void i830BlendEquationSeparate(GLcontext *ctx,
+ GLenum modeRGB, GLenum modeA)
+{
+ if (I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s -> %s, %s\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(modeRGB),
+ _mesa_lookup_enum_by_nr(modeA));
+
+ (void) modeRGB;
+ (void) modeA;
+ i830_set_blend_state( ctx );
+}
+
+
+
+static void i830BlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB,
+ GLenum dfactorRGB, GLenum sfactorA,
+ GLenum dfactorA )
+{
+ if (I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s -> RGB(%s, %s) A(%s, %s)\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(sfactorRGB),
+ _mesa_lookup_enum_by_nr(dfactorRGB),
+ _mesa_lookup_enum_by_nr(sfactorA),
+ _mesa_lookup_enum_by_nr(dfactorA));
+
+ (void) sfactorRGB;
+ (void) dfactorRGB;
+ (void) sfactorA;
+ (void) dfactorA;
+ i830_set_blend_state( ctx );
+}
+
+static void i830DepthFunc(GLcontext *ctx, GLenum func)
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ int test = 0;
+
+ if (I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ switch(func) {
+ case GL_NEVER:
+ test = COMPAREFUNC_NEVER;
+ break;
+ case GL_LESS:
+ test = COMPAREFUNC_LESS;
+ break;
+ case GL_LEQUAL:
+ test = COMPAREFUNC_LEQUAL;
+ break;
+ case GL_GREATER:
+ test = COMPAREFUNC_GREATER;
+ break;
+ case GL_GEQUAL:
+ test = COMPAREFUNC_GEQUAL;
+ break;
+ case GL_NOTEQUAL:
+ test = COMPAREFUNC_NOTEQUAL;
+ break;
+ case GL_EQUAL:
+ test = COMPAREFUNC_EQUAL;
+ break;
+ case GL_ALWAYS:
+ test = COMPAREFUNC_ALWAYS;
+ break;
+ default: return;
+ }
+
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_STATE3] &= ~DEPTH_TEST_FUNC_MASK;
+ imesa->Setup[I830_CTXREG_STATE3] |= (ENABLE_DEPTH_TEST_FUNC |
+ DEPTH_TEST_FUNC(test));
+}
+
+static void i830DepthMask(GLcontext *ctx, GLboolean flag)
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+
+ if (I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s flag (%d)\n", __FUNCTION__, flag);
+
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+
+ imesa->Setup[I830_CTXREG_ENABLES_2] &= ~ENABLE_DIS_DEPTH_WRITE_MASK;
+
+ if (flag && ctx->Depth.Test)
+ imesa->Setup[I830_CTXREG_ENABLES_2] |= ENABLE_DEPTH_WRITE;
+ else
+ imesa->Setup[I830_CTXREG_ENABLES_2] |= DISABLE_DEPTH_WRITE;
+}
+
+/* =============================================================
+ * Polygon stipple
+ *
+ * The i830 supports a 4x4 stipple natively, GL wants 32x32.
+ * Fortunately stipple is usually a repeating pattern.
+ */
+static void i830PolygonStipple( GLcontext *ctx, const GLubyte *mask )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ const GLubyte *m = mask;
+ GLubyte p[4];
+ int i,j,k;
+ int active = (ctx->Polygon.StippleFlag &&
+ imesa->reduced_primitive == GL_TRIANGLES);
+ GLuint newMask;
+
+ if (active) {
+ I830_STATECHANGE(imesa, I830_UPLOAD_STIPPLE);
+ imesa->StippleSetup[I830_STPREG_ST1] &= ~ST1_ENABLE;
+ }
+
+ p[0] = mask[12] & 0xf; p[0] |= p[0] << 4;
+ p[1] = mask[8] & 0xf; p[1] |= p[1] << 4;
+ p[2] = mask[4] & 0xf; p[2] |= p[2] << 4;
+ p[3] = mask[0] & 0xf; p[3] |= p[3] << 4;
+
+ for (k = 0 ; k < 8 ; k++)
+ for (j = 3 ; j >= 0; j--)
+ for (i = 0 ; i < 4 ; i++, m++)
+ if (*m != p[j]) {
+ imesa->hw_stipple = 0;
+ return;
+ }
+
+ newMask = (((p[0] & 0xf) << 0) |
+ ((p[1] & 0xf) << 4) |
+ ((p[2] & 0xf) << 8) |
+ ((p[3] & 0xf) << 12));
+
+
+ if (newMask == 0xffff || newMask == 0x0) {
+ /* this is needed to make conform pass */
+ imesa->hw_stipple = 0;
+ return;
+ }
+
+ imesa->StippleSetup[I830_STPREG_ST1] &= ~0xffff;
+ imesa->StippleSetup[I830_STPREG_ST1] |= newMask;
+ imesa->hw_stipple = 1;
+
+ if (active)
+ imesa->StippleSetup[I830_STPREG_ST1] |= ST1_ENABLE;
+}
+
+static void i830PolygonStippleFallback( GLcontext *ctx, const GLubyte *mask )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ imesa->hw_stipple = 0;
+ (void) i830PolygonStipple;
+}
+
+/* =============================================================
+ * Hardware clipping
+ */
+static void i830Scissor(GLcontext *ctx, GLint x, GLint y,
+ GLsizei w, GLsizei h)
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ int x1 = x;
+ int y1 = imesa->driDrawable->h - (y + h);
+ int x2 = x + w - 1;
+ int y2 = y1 + h - 1;
+
+ if (I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "[%s] x(%d) y(%d) w(%d) h(%d)\n", __FUNCTION__,
+ x, y, w, h);
+
+ if (x1 < 0) x1 = 0;
+ if (y1 < 0) y1 = 0;
+ if (x2 < 0) x2 = 0;
+ if (y2 < 0) y2 = 0;
+
+ if (x2 >= imesa->i830Screen->width) x2 = imesa->i830Screen->width-1;
+ if (y2 >= imesa->i830Screen->height) y2 = imesa->i830Screen->height-1;
+ if (x1 >= imesa->i830Screen->width) x1 = imesa->i830Screen->width-1;
+ if (y1 >= imesa->i830Screen->height) y1 = imesa->i830Screen->height-1;
+
+
+ I830_STATECHANGE(imesa, I830_UPLOAD_BUFFERS);
+ imesa->BufferSetup[I830_DESTREG_SR1] = (y1 << 16) | (x1 & 0xffff);
+ imesa->BufferSetup[I830_DESTREG_SR2] = (y2 << 16) | (x2 & 0xffff);
+}
+
+static void i830LogicOp(GLcontext *ctx, GLenum opcode)
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ int tmp = 0;
+
+ if (I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ /* FIXME: This should be a look-up table, like the r200 driver. */
+ switch(opcode) {
+ case GL_CLEAR:
+ tmp = LOGICOP_CLEAR;
+ break;
+ case GL_AND:
+ tmp = LOGICOP_AND;
+ break;
+ case GL_AND_REVERSE:
+ tmp = LOGICOP_AND_RVRSE;
+ break;
+ case GL_COPY:
+ tmp = LOGICOP_COPY;
+ break;
+ case GL_COPY_INVERTED:
+ tmp = LOGICOP_COPY_INV;
+ break;
+ case GL_AND_INVERTED:
+ tmp = LOGICOP_AND_INV;
+ break;
+ case GL_NOOP:
+ tmp = LOGICOP_NOOP;
+ break;
+ case GL_XOR:
+ tmp = LOGICOP_XOR;
+ break;
+ case GL_OR:
+ tmp = LOGICOP_OR;
+ break;
+ case GL_OR_INVERTED:
+ tmp = LOGICOP_OR_INV;
+ break;
+ case GL_NOR:
+ tmp = LOGICOP_NOR;
+ break;
+ case GL_EQUIV:
+ tmp = LOGICOP_EQUIV;
+ break;
+ case GL_INVERT:
+ tmp = LOGICOP_INV;
+ break;
+ case GL_OR_REVERSE:
+ tmp = LOGICOP_OR_RVRSE;
+ break;
+ case GL_NAND:
+ tmp = LOGICOP_NAND;
+ break;
+ case GL_SET:
+ tmp = LOGICOP_SET;
+ break;
+ default:
+ return;
+ }
+
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_STATE4] &= ~LOGICOP_MASK;
+ imesa->Setup[I830_CTXREG_STATE4] |= LOGIC_OP_FUNC(tmp);
+
+ /* Make sure all the enables are correct */
+ i830EvalLogicOpBlendState(ctx);
+}
+
+/* Fallback to swrast for select and feedback.
+ */
+static void i830RenderMode( GLcontext *ctx, GLenum mode )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ FALLBACK( imesa, I830_FALLBACK_RENDERMODE, (mode != GL_RENDER) );
+}
+
+static void i830DrawBuffer(GLcontext *ctx, GLenum mode )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+
+ /*
+ * _ColorDrawBufferMask is easier to cope with than <mode>.
+ */
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ I830_FIREVERTICES(imesa);
+ I830_STATECHANGE(imesa, I830_UPLOAD_BUFFERS);
+ imesa->BufferSetup[I830_DESTREG_CBUFADDR] = imesa->i830Screen->fbOffset;
+ i830XMesaSetFrontClipRects( imesa );
+ FALLBACK( imesa, I830_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ I830_FIREVERTICES(imesa);
+ I830_STATECHANGE(imesa, I830_UPLOAD_BUFFERS);
+ imesa->BufferSetup[I830_DESTREG_CBUFADDR] =
+ imesa->i830Screen->backOffset;
+ i830XMesaSetBackClipRects( imesa );
+ FALLBACK( imesa, I830_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ break;
+ default:
+ /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
+ FALLBACK( imesa, I830_FALLBACK_DRAW_BUFFER, GL_TRUE );
+ return;
+ }
+
+ /* We want to update the s/w rast state too so that i830SetBuffer()
+ * gets called.
+ */
+ _swrast_DrawBuffer(ctx, mode);
+}
+
+static void i830ReadBuffer(GLcontext *ctx, GLenum mode )
+{
+ /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
+}
+
+static void i830ClearColor(GLcontext *ctx, const GLfloat color[4])
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+
+ CLAMPED_FLOAT_TO_UBYTE(imesa->clear_red, color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(imesa->clear_green, color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(imesa->clear_blue, color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(imesa->clear_alpha, color[3]);
+
+ imesa->ClearColor = i830PackColor(imesa->i830Screen->fbFormat,
+ imesa->clear_red,
+ imesa->clear_green,
+ imesa->clear_blue,
+ imesa->clear_alpha);
+}
+
+static void i830CullFaceFrontFace(GLcontext *ctx, GLenum unused)
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ GLuint mode = CULLMODE_BOTH;
+
+ if (I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK) {
+ mode = CULLMODE_CW;
+
+ if (ctx->Polygon.CullFaceMode == GL_FRONT)
+ mode ^= (CULLMODE_CW ^ CULLMODE_CCW);
+ if (ctx->Polygon.FrontFace != GL_CCW)
+ mode ^= (CULLMODE_CW ^ CULLMODE_CCW);
+ }
+
+ imesa->LcsCullMode = mode;
+
+ if (ctx->Polygon.CullFlag) {
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_STATE3] &= ~CULLMODE_MASK;
+ imesa->Setup[I830_CTXREG_STATE3] |= ENABLE_CULL_MODE | mode;
+ }
+}
+
+static void i830LineWidth( GLcontext *ctx, GLfloat widthf )
+{
+ i830ContextPtr imesa = I830_CONTEXT( ctx );
+ int width;
+
+ if (I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ width = FloatToInt(widthf * 2);
+ CLAMP_SELF(width, 1, 15);
+
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_STATE5] &= ~FIXED_LINE_WIDTH_MASK;
+ imesa->Setup[I830_CTXREG_STATE5] |= (ENABLE_FIXED_LINE_WIDTH |
+ FIXED_LINE_WIDTH(width));
+}
+
+static void i830PointSize(GLcontext *ctx, GLfloat size)
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ GLint point_size = FloatToInt(size);
+
+ if (I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ CLAMP_SELF(point_size, 1, 256);
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_STATE5] &= ~FIXED_POINT_WIDTH_MASK;
+ imesa->Setup[I830_CTXREG_STATE5] |= (ENABLE_FIXED_POINT_WIDTH |
+ FIXED_POINT_WIDTH(point_size));
+}
+
+
+/* =============================================================
+ * Color masks
+ */
+
+static void i830ColorMask(GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a)
+{
+ i830ContextPtr imesa = I830_CONTEXT( ctx );
+ GLuint tmp = 0;
+
+ if (I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s r(%d) g(%d) b(%d) a(%d)\n", __FUNCTION__, r, g, b, a);
+
+ imesa->mask_red = !r;
+ imesa->mask_green = !g;
+ imesa->mask_blue = !b;
+ imesa->mask_alpha = !a;
+
+ tmp = (imesa->Setup[I830_CTXREG_ENABLES_2] & ~WRITEMASK_MASK) |
+ ENABLE_COLOR_MASK |
+ ENABLE_COLOR_WRITE |
+ ((!r) << WRITEMASK_RED_SHIFT) |
+ ((!g) << WRITEMASK_GREEN_SHIFT) |
+ ((!b) << WRITEMASK_BLUE_SHIFT) |
+ ((!a) << WRITEMASK_ALPHA_SHIFT);
+
+ if (tmp != imesa->Setup[I830_CTXREG_ENABLES_2]) {
+ I830_FIREVERTICES(imesa);
+ imesa->dirty |= I830_UPLOAD_CTX;
+ imesa->Setup[I830_CTXREG_ENABLES_2] = tmp;
+ }
+}
+
+static void update_specular( GLcontext *ctx )
+{
+ i830ContextPtr imesa = I830_CONTEXT( ctx );
+
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_ENABLES_1] &= ~ENABLE_SPEC_ADD_MASK;
+
+ if (NEED_SECONDARY_COLOR(ctx))
+ imesa->Setup[I830_CTXREG_ENABLES_1] |= ENABLE_SPEC_ADD;
+ else
+ imesa->Setup[I830_CTXREG_ENABLES_1] |= DISABLE_SPEC_ADD;
+}
+
+static void i830LightModelfv(GLcontext *ctx, GLenum pname,
+ const GLfloat *param)
+{
+ if (I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) {
+ update_specular( ctx );
+ }
+}
+
+/* In Mesa 3.5 we can reliably do native flatshading.
+ */
+static void i830ShadeModel(GLcontext *ctx, GLenum mode)
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+
+
+#define SHADE_MODE_MASK ((1<<10)|(1<<8)|(1<<6)|(1<<4))
+
+ imesa->Setup[I830_CTXREG_STATE3] &= ~SHADE_MODE_MASK;
+
+ if (mode == GL_FLAT) {
+ imesa->Setup[I830_CTXREG_STATE3] |= (ALPHA_SHADE_MODE(SHADE_MODE_FLAT) |
+ FOG_SHADE_MODE(SHADE_MODE_FLAT) |
+ SPEC_SHADE_MODE(SHADE_MODE_FLAT) |
+ COLOR_SHADE_MODE(SHADE_MODE_FLAT));
+ } else {
+ imesa->Setup[I830_CTXREG_STATE3] |= (ALPHA_SHADE_MODE(SHADE_MODE_LINEAR) |
+ FOG_SHADE_MODE(SHADE_MODE_LINEAR) |
+ SPEC_SHADE_MODE(SHADE_MODE_LINEAR) |
+ COLOR_SHADE_MODE(SHADE_MODE_LINEAR));
+ }
+}
+
+/* =============================================================
+ * Fog
+ */
+static void i830Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+
+ if (I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (pname == GL_FOG_COLOR) {
+ GLuint color = (((GLubyte)(ctx->Fog.Color[0]*255.0F) << 16) |
+ ((GLubyte)(ctx->Fog.Color[1]*255.0F) << 8) |
+ ((GLubyte)(ctx->Fog.Color[2]*255.0F) << 0));
+
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_FOGCOLOR] = (STATE3D_FOG_COLOR_CMD | color);
+ }
+}
+
+/* =============================================================
+ */
+
+static void i830Enable(GLcontext *ctx, GLenum cap, GLboolean state)
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+
+ switch(cap) {
+ case GL_LIGHTING:
+ case GL_COLOR_SUM_EXT:
+ update_specular( ctx );
+ break;
+
+ case GL_ALPHA_TEST:
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_ALPHA_TEST_MASK;
+ if (state)
+ imesa->Setup[I830_CTXREG_ENABLES_1] |= ENABLE_ALPHA_TEST;
+ else
+ imesa->Setup[I830_CTXREG_ENABLES_1] |= DISABLE_ALPHA_TEST;
+
+ break;
+
+ case GL_BLEND:
+ case GL_COLOR_LOGIC_OP:
+ case GL_INDEX_LOGIC_OP:
+ i830EvalLogicOpBlendState(ctx);
+ break;
+
+ case GL_DITHER:
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_ENABLES_2] &= ~ENABLE_DITHER;
+
+ if (state)
+ imesa->Setup[I830_CTXREG_ENABLES_2] |= ENABLE_DITHER;
+ else
+ imesa->Setup[I830_CTXREG_ENABLES_2] |= DISABLE_DITHER;
+ break;
+
+ case GL_DEPTH_TEST:
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_DEPTH_TEST_MASK;
+
+ if (state)
+ imesa->Setup[I830_CTXREG_ENABLES_1] |= ENABLE_DEPTH_TEST;
+ else
+ imesa->Setup[I830_CTXREG_ENABLES_1] |= DISABLE_DEPTH_TEST;
+
+ /* Also turn off depth writes when GL_DEPTH_TEST is disabled:
+ */
+ i830DepthMask( ctx, state );
+ break;
+
+ case GL_SCISSOR_TEST:
+ I830_STATECHANGE(imesa, I830_UPLOAD_BUFFERS);
+
+ if (state)
+ imesa->BufferSetup[I830_DESTREG_SENABLE] =
+ (STATE3D_SCISSOR_ENABLE_CMD |
+ ENABLE_SCISSOR_RECT);
+ else
+ imesa->BufferSetup[I830_DESTREG_SENABLE] =
+ (STATE3D_SCISSOR_ENABLE_CMD |
+ DISABLE_SCISSOR_RECT);
+
+ imesa->upload_cliprects = GL_TRUE;
+ break;
+
+ case GL_LINE_SMOOTH:
+ if (imesa->reduced_primitive == GL_LINES) {
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+
+ imesa->Setup[I830_CTXREG_AA] &= ~AA_LINE_ENABLE;
+ if (state)
+ imesa->Setup[I830_CTXREG_AA] |= AA_LINE_ENABLE;
+ else
+ imesa->Setup[I830_CTXREG_AA] |= AA_LINE_DISABLE;
+ }
+ break;
+
+ case GL_FOG:
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_FOG_MASK;
+ if (state)
+ imesa->Setup[I830_CTXREG_ENABLES_1] |= I830_ENABLE_FOG;
+ else
+ imesa->Setup[I830_CTXREG_ENABLES_1] |= I830_DISABLE_FOG;
+ break;
+
+ case GL_CULL_FACE:
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_STATE3] &= ~CULLMODE_MASK;
+ if (state)
+ imesa->Setup[I830_CTXREG_STATE3] |= (ENABLE_CULL_MODE |
+ imesa->LcsCullMode);
+ else
+ imesa->Setup[I830_CTXREG_STATE3] |= (ENABLE_CULL_MODE |
+ CULLMODE_NONE);
+ break;
+
+ case GL_TEXTURE_2D:
+/* I830_STATECHANGE(imesa, I830_UPLOAD_CTX); */
+/* imesa->Setup[I830_CTXREG_ENABLES_1] &= ~ENABLE_SPEC_ADD_MASK; */
+ break;
+
+ case GL_STENCIL_TEST:
+ if (imesa->hw_stencil) {
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_ENABLES_1] &= ~ENABLE_STENCIL_TEST;
+ imesa->Setup[I830_CTXREG_ENABLES_2] &= ~ENABLE_STENCIL_WRITE;
+
+ if (state) {
+ imesa->Setup[I830_CTXREG_ENABLES_1] |= ENABLE_STENCIL_TEST;
+ imesa->Setup[I830_CTXREG_ENABLES_2] |= ENABLE_STENCIL_WRITE;
+ } else {
+ imesa->Setup[I830_CTXREG_ENABLES_1] |= DISABLE_STENCIL_TEST;
+ imesa->Setup[I830_CTXREG_ENABLES_2] |= DISABLE_STENCIL_WRITE;
+ }
+ } else {
+ FALLBACK( imesa, I830_FALLBACK_STENCIL, state );
+ }
+ break;
+
+ case GL_POLYGON_STIPPLE:
+#if 0
+ /* The stipple command worked on my 855GM box, but not my 845G.
+ * I'll do more testing later to find out exactly which hardware
+ * supports it. Disabled for now.
+ */
+ if (imesa->hw_stipple && imesa->reduced_primitive == GL_TRIANGLES)
+ {
+ I830_STATECHANGE(imesa, I830_UPLOAD_STIPPLE);
+ imesa->StippleSetup[I830_STPREG_ST1] &= ~ST1_ENABLE;
+ if (state)
+ imesa->StippleSetup[I830_STPREG_ST1] |= ST1_ENABLE;
+ }
+#endif
+ break;
+
+ default:
+ ;
+ }
+}
+
+
+void i830EmitDrawingRectangle( i830ContextPtr imesa )
+{
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+ i830ScreenPrivate *i830Screen = imesa->i830Screen;
+ int x0 = imesa->drawX;
+ int y0 = imesa->drawY;
+ int x1 = x0 + dPriv->w;
+ int y1 = y0 + dPriv->h;
+
+ /* Don't set drawing rectangle */
+ if (I830_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s x0(%d) x1(%d) y0(%d) y1(%d)\n", __FUNCTION__,
+ x0, x1, y0, y1);
+
+ /* Coordinate origin of the window - may be offscreen.
+ */
+ imesa->BufferSetup[I830_DESTREG_DR4] = ((y0<<16) |
+ (((unsigned)x0)&0xFFFF));
+
+ /* Clip to screen.
+ */
+ if (x0 < 0) x0 = 0;
+ if (y0 < 0) y0 = 0;
+ if (x1 > i830Screen->width-1) x1 = i830Screen->width-1;
+ if (y1 > i830Screen->height-1) y1 = i830Screen->height-1;
+
+
+ /* Onscreen drawing rectangle.
+ */
+ imesa->BufferSetup[I830_DESTREG_DR2] = ((y0<<16) | x0);
+ imesa->BufferSetup[I830_DESTREG_DR3] = (((y1+1)<<16) | (x1+1));
+
+
+ /* Just add in our dirty flag, since we might be called when locked */
+ /* Might want to modify how this is done. */
+ imesa->dirty |= I830_UPLOAD_BUFFERS;
+
+ if (0)
+ fprintf(stderr, "[%s] DR2(0x%08x) DR3(0x%08x) DR4(0x%08x)\n",
+ __FUNCTION__,
+ imesa->BufferSetup[I830_DESTREG_DR2],
+ imesa->BufferSetup[I830_DESTREG_DR3],
+ imesa->BufferSetup[I830_DESTREG_DR4]);
+}
+
+/* This could be done in hardware, will do once I have the driver
+ * up and running.
+ */
+static void i830CalcViewport( GLcontext *ctx )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat *m = imesa->ViewportMatrix.m;
+
+ /* See also i830_translate_vertex. SUBPIXEL adjustments can be done
+ * via state vars, too.
+ */
+ m[MAT_SX] = v[MAT_SX];
+ m[MAT_TX] = v[MAT_TX] + SUBPIXEL_X;
+ m[MAT_SY] = - v[MAT_SY];
+ m[MAT_TY] = - v[MAT_TY] + imesa->driDrawable->h + SUBPIXEL_Y;
+ m[MAT_SZ] = v[MAT_SZ] * imesa->depth_scale;
+ m[MAT_TZ] = v[MAT_TZ] * imesa->depth_scale;
+}
+
+static void i830Viewport( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
+ i830CalcViewport( ctx );
+}
+
+static void i830DepthRange( GLcontext *ctx,
+ GLclampd nearval, GLclampd farval )
+{
+ i830CalcViewport( ctx );
+}
+
+void i830PrintDirty( const char *msg, GLuint state )
+{
+ fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s%s%s%s%s%s\n",
+ msg,
+ (unsigned int) state,
+ (state & I830_UPLOAD_TEX0) ? "upload-tex0, " : "",
+ (state & I830_UPLOAD_TEX1) ? "upload-tex1, " : "",
+ (state & I830_UPLOAD_TEX2) ? "upload-tex2, " : "",
+ (state & I830_UPLOAD_TEX3) ? "upload-tex3, " : "",
+ (state & I830_UPLOAD_CTX) ? "upload-ctx, " : "",
+ (state & I830_UPLOAD_BUFFERS) ? "upload-bufs, " : "",
+ (state & I830_UPLOAD_TEXBLEND0) ? "upload-blend0, " : "",
+ (state & I830_UPLOAD_TEXBLEND1) ? "upload-blend1, " : "",
+ (state & I830_UPLOAD_TEXBLEND2) ? "upload-blend2, " : "",
+ (state & I830_UPLOAD_TEXBLEND3) ? "upload-blend3, " : "",
+ (state & I830_UPLOAD_STIPPLE) ? "stipple, " : ""
+ );
+}
+
+/* Push the state into the sarea and/or texture memory.
+ */
+void i830EmitHwStateLocked( i830ContextPtr imesa )
+{
+ int i;
+
+ if (I830_DEBUG & DEBUG_STATE)
+ i830PrintDirty( __FUNCTION__, imesa->dirty );
+
+ for ( i = 0 ; i < imesa->glCtx->Const.MaxTextureUnits ; i++ ) {
+ if ( ((imesa->dirty & I830_UPLOAD_TEX_N_IMAGE( i )) != 0)
+ && (imesa->CurrentTexObj[i] != NULL) ) {
+ i830UploadTexImagesLocked(imesa, imesa->CurrentTexObj[i]);
+ }
+ }
+
+ if (imesa->dirty & I830_UPLOAD_CTX) {
+ memcpy( imesa->sarea->ContextState,
+ imesa->Setup, sizeof(imesa->Setup) );
+ }
+
+ for ( i = 0 ; i < imesa->glCtx->Const.MaxTextureUnits ; i++ ) {
+ if ((imesa->dirty & I830_UPLOAD_TEX_N(i)) && imesa->CurrentTexObj[i]) {
+ unsigned * TexState;
+
+ imesa->sarea->dirty |= I830_UPLOAD_TEX_N(i);
+
+ switch( i ) {
+ case 0:
+ case 1:
+ TexState = imesa->sarea->TexState[i];
+ break;
+
+ case 2:
+ TexState = imesa->sarea->TexState2;
+ break;
+
+ case 3:
+ TexState = imesa->sarea->TexState3;
+ break;
+ }
+
+ memcpy(TexState, imesa->CurrentTexObj[i]->Setup,
+ sizeof(imesa->sarea->TexState[i]));
+
+ TexState[I830_TEXREG_TM0S3] &= ~TM0S3_LOD_BIAS_MASK;
+ TexState[I830_TEXREG_TM0S3] |= imesa->LodBias[i];
+
+ /* Update the LRU usage */
+ if (imesa->CurrentTexObj[i]->base.memBlock)
+ driUpdateTextureLRU( (driTextureObject *)
+ imesa->CurrentTexObj[i] );
+ }
+ }
+ /* Need to figure out if texturing state, or enable changed. */
+
+ for ( i = 0 ; i < imesa->glCtx->Const.MaxTextureUnits ; i++ ) {
+ if (imesa->dirty & I830_UPLOAD_TEXBLEND_N(i)) {
+ unsigned * TexBlendState;
+ unsigned * words_used;
+
+ imesa->sarea->dirty |= I830_UPLOAD_TEXBLEND_N(i);
+
+ switch( i ) {
+ case 0:
+ case 1:
+ TexBlendState = imesa->sarea->TexBlendState[i];
+ words_used = & imesa->sarea->TexBlendStateWordsUsed[i];
+ break;
+
+ case 2:
+ TexBlendState = imesa->sarea->TexBlendState2;
+ words_used = & imesa->sarea->TexBlendStateWordsUsed2;
+ break;
+
+ case 3:
+ TexBlendState = imesa->sarea->TexBlendState3;
+ words_used = & imesa->sarea->TexBlendStateWordsUsed3;
+ break;
+ }
+
+ memcpy(TexBlendState, imesa->TexBlend[i],
+ imesa->TexBlendWordsUsed[i] * 4);
+ *words_used = imesa->TexBlendWordsUsed[i];
+ }
+ }
+
+ if (imesa->dirty & I830_UPLOAD_BUFFERS) {
+ memcpy( imesa->sarea->BufferState,imesa->BufferSetup,
+ sizeof(imesa->BufferSetup) );
+ }
+
+ if (imesa->dirty & I830_UPLOAD_STIPPLE) {
+ memcpy( imesa->sarea->StippleState,imesa->StippleSetup,
+ sizeof(imesa->StippleSetup) );
+ }
+
+ if (imesa->dirty & I830_UPLOAD_TEX_PALETTE_SHARED) {
+ memcpy( imesa->sarea->Palette[0],imesa->palette,
+ sizeof(imesa->sarea->Palette[0]));
+ } else {
+ i830TextureObjectPtr p;
+ if (imesa->dirty & I830_UPLOAD_TEX_PALETTE_N(0)) {
+ p = imesa->CurrentTexObj[0];
+ memcpy( imesa->sarea->Palette[0],p->palette,
+ sizeof(imesa->sarea->Palette[0]));
+ }
+ if (imesa->dirty & I830_UPLOAD_TEX_PALETTE_N(1)) {
+ p = imesa->CurrentTexObj[1];
+ memcpy( imesa->sarea->Palette[1],
+ p->palette,
+ sizeof(imesa->sarea->Palette[1]));
+ }
+ }
+
+ imesa->sarea->dirty |= (imesa->dirty & ~(I830_UPLOAD_TEX_MASK |
+ I830_UPLOAD_TEXBLEND_MASK));
+
+ imesa->upload_cliprects = GL_TRUE;
+ imesa->dirty = 0;
+}
+
+
+void i830DDInitState( GLcontext *ctx )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ i830ScreenPrivate *i830Screen = imesa->i830Screen;
+ int i;
+
+ imesa->clear_red = 0;
+ imesa->clear_green = 0;
+ imesa->clear_blue = 0;
+ imesa->clear_alpha = 0;
+
+ imesa->mask_red = GL_FALSE;
+ imesa->mask_green = GL_FALSE;
+ imesa->mask_blue = GL_FALSE;
+ imesa->mask_alpha = GL_FALSE;
+
+ /* Zero all texture state */
+ for (i = 0; i < I830_MAX_TEXTURE_UNITS; i++) {
+ (void) memset( imesa->TexBlend[i], 0, sizeof( imesa->TexBlend[i] ) );
+ (void) memset( imesa->Init_TexBlend[i], 0, sizeof( imesa->Init_TexBlend[i] ) );
+
+ imesa->TexBlendWordsUsed[i] = 0;
+ imesa->Init_TexBlendWordsUsed[i] = 0;
+ }
+
+ /* Set default blend state */
+ imesa->TexBlend[0][0] = (STATE3D_MAP_BLEND_OP_CMD(0) |
+ TEXPIPE_COLOR |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ DISABLE_TEX_CNTRL_STAGE |
+ TEXOP_SCALE_1X |
+ TEXOP_MODIFY_PARMS |
+ TEXOP_LAST_STAGE |
+ TEXBLENDOP_ARG1);
+ imesa->TexBlend[0][1] = (STATE3D_MAP_BLEND_OP_CMD(0) |
+ TEXPIPE_ALPHA |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ TEXOP_SCALE_1X |
+ TEXOP_MODIFY_PARMS |
+ TEXBLENDOP_ARG1);
+ imesa->TexBlend[0][2] = (STATE3D_MAP_BLEND_ARG_CMD(0) |
+ TEXPIPE_COLOR |
+ TEXBLEND_ARG1 |
+ TEXBLENDARG_MODIFY_PARMS |
+ TEXBLENDARG_DIFFUSE);
+ imesa->TexBlend[0][3] = (STATE3D_MAP_BLEND_ARG_CMD(0) |
+ TEXPIPE_ALPHA |
+ TEXBLEND_ARG1 |
+ TEXBLENDARG_MODIFY_PARMS |
+ TEXBLENDARG_DIFFUSE);
+
+ imesa->TexBlendWordsUsed[0] = 4;
+
+ imesa->Init_TexBlend[0][0] = (STATE3D_MAP_BLEND_OP_CMD(0) |
+ TEXPIPE_COLOR |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ DISABLE_TEX_CNTRL_STAGE |
+ TEXOP_SCALE_1X |
+ TEXOP_MODIFY_PARMS |
+ TEXOP_LAST_STAGE |
+ TEXBLENDOP_ARG1);
+ imesa->Init_TexBlend[0][1] = (STATE3D_MAP_BLEND_OP_CMD(0) |
+ TEXPIPE_ALPHA |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ TEXOP_SCALE_1X |
+ TEXOP_MODIFY_PARMS |
+ TEXBLENDOP_ARG1);
+ imesa->Init_TexBlend[0][2] = (STATE3D_MAP_BLEND_ARG_CMD(0) |
+ TEXPIPE_COLOR |
+ TEXBLEND_ARG1 |
+ TEXBLENDARG_MODIFY_PARMS |
+ TEXBLENDARG_CURRENT);
+ imesa->Init_TexBlend[0][3] = (STATE3D_MAP_BLEND_ARG_CMD(0) |
+ TEXPIPE_ALPHA |
+ TEXBLEND_ARG1 |
+ TEXBLENDARG_MODIFY_PARMS |
+ TEXBLENDARG_CURRENT);
+ imesa->Init_TexBlendWordsUsed[0] = 4;
+
+ memset(imesa->Setup, 0, sizeof(imesa->Setup));
+
+ imesa->Setup[I830_CTXREG_VF] = 0;
+ imesa->Setup[I830_CTXREG_VF2] = 0;
+
+ imesa->Setup[I830_CTXREG_AA] = (STATE3D_AA_CMD |
+ AA_LINE_ECAAR_WIDTH_ENABLE |
+ AA_LINE_ECAAR_WIDTH_1_0 |
+ AA_LINE_REGION_WIDTH_ENABLE |
+ AA_LINE_REGION_WIDTH_1_0 |
+ AA_LINE_DISABLE);
+
+ imesa->Setup[I830_CTXREG_ENABLES_1] = (STATE3D_ENABLES_1_CMD |
+ DISABLE_LOGIC_OP |
+ DISABLE_STENCIL_TEST |
+ DISABLE_DEPTH_BIAS |
+ DISABLE_SPEC_ADD |
+ I830_DISABLE_FOG |
+ DISABLE_ALPHA_TEST |
+ DISABLE_COLOR_BLEND |
+ DISABLE_DEPTH_TEST);
+
+ if (imesa->hw_stencil) {
+ imesa->Setup[I830_CTXREG_ENABLES_2] = (STATE3D_ENABLES_2_CMD |
+ ENABLE_STENCIL_WRITE |
+ ENABLE_TEX_CACHE |
+ ENABLE_DITHER |
+ ENABLE_COLOR_MASK |
+ /* set no color comps disabled */
+ ENABLE_COLOR_WRITE |
+ ENABLE_DEPTH_WRITE);
+ } else {
+ imesa->Setup[I830_CTXREG_ENABLES_2] = (STATE3D_ENABLES_2_CMD |
+ DISABLE_STENCIL_WRITE |
+ ENABLE_TEX_CACHE |
+ ENABLE_DITHER |
+ ENABLE_COLOR_MASK |
+ /* set no color comps disabled */
+ ENABLE_COLOR_WRITE |
+ ENABLE_DEPTH_WRITE);
+ }
+
+ imesa->Setup[I830_CTXREG_STATE1] = (STATE3D_MODES_1_CMD |
+ ENABLE_COLR_BLND_FUNC |
+ BLENDFUNC_ADD |
+ ENABLE_SRC_BLND_FACTOR |
+ SRC_BLND_FACT(BLENDFACT_ONE) |
+ ENABLE_DST_BLND_FACTOR |
+ DST_BLND_FACT(BLENDFACT_ZERO) );
+
+ imesa->Setup[I830_CTXREG_STATE2] = (STATE3D_MODES_2_CMD |
+ ENABLE_GLOBAL_DEPTH_BIAS |
+ GLOBAL_DEPTH_BIAS(0) |
+ ENABLE_ALPHA_TEST_FUNC |
+ ALPHA_TEST_FUNC(COMPAREFUNC_ALWAYS) |
+ ALPHA_REF_VALUE(0) );
+
+ imesa->Setup[I830_CTXREG_STATE3] = (STATE3D_MODES_3_CMD |
+ ENABLE_DEPTH_TEST_FUNC |
+ DEPTH_TEST_FUNC(COMPAREFUNC_LESS) |
+ ENABLE_ALPHA_SHADE_MODE |
+ ALPHA_SHADE_MODE(SHADE_MODE_LINEAR) |
+ ENABLE_FOG_SHADE_MODE |
+ FOG_SHADE_MODE(SHADE_MODE_LINEAR) |
+ ENABLE_SPEC_SHADE_MODE |
+ SPEC_SHADE_MODE(SHADE_MODE_LINEAR) |
+ ENABLE_COLOR_SHADE_MODE |
+ COLOR_SHADE_MODE(SHADE_MODE_LINEAR) |
+ ENABLE_CULL_MODE |
+ CULLMODE_NONE);
+
+ imesa->Setup[I830_CTXREG_STATE4] = (STATE3D_MODES_4_CMD |
+ ENABLE_LOGIC_OP_FUNC |
+ LOGIC_OP_FUNC(LOGICOP_COPY) |
+ ENABLE_STENCIL_TEST_MASK |
+ STENCIL_TEST_MASK(0xff) |
+ ENABLE_STENCIL_WRITE_MASK |
+ STENCIL_WRITE_MASK(0xff));
+
+ imesa->Setup[I830_CTXREG_STENCILTST] = (STATE3D_STENCIL_TEST_CMD |
+ ENABLE_STENCIL_PARMS |
+ STENCIL_FAIL_OP(STENCILOP_KEEP) |
+ STENCIL_PASS_DEPTH_FAIL_OP(STENCILOP_KEEP) |
+ STENCIL_PASS_DEPTH_PASS_OP(STENCILOP_KEEP) |
+ ENABLE_STENCIL_TEST_FUNC |
+ STENCIL_TEST_FUNC(COMPAREFUNC_ALWAYS) |
+ ENABLE_STENCIL_REF_VALUE |
+ STENCIL_REF_VALUE(0) );
+
+ imesa->Setup[I830_CTXREG_STATE5] = (STATE3D_MODES_5_CMD |
+ FLUSH_TEXTURE_CACHE |
+ ENABLE_SPRITE_POINT_TEX |
+ SPRITE_POINT_TEX_OFF |
+ ENABLE_FIXED_LINE_WIDTH |
+ FIXED_LINE_WIDTH(0x2) | /* 1.0 */
+ ENABLE_FIXED_POINT_WIDTH |
+ FIXED_POINT_WIDTH(1) );
+
+ imesa->Setup[I830_CTXREG_IALPHAB] = (STATE3D_INDPT_ALPHA_BLEND_CMD |
+ DISABLE_INDPT_ALPHA_BLEND |
+ ENABLE_ALPHA_BLENDFUNC |
+ ABLENDFUNC_ADD);
+
+ imesa->Setup[I830_CTXREG_FOGCOLOR] = (STATE3D_FOG_COLOR_CMD |
+ FOG_COLOR_RED(0) |
+ FOG_COLOR_GREEN(0) |
+ FOG_COLOR_BLUE(0));
+
+ imesa->Setup[I830_CTXREG_BLENDCOLR0] = (STATE3D_CONST_BLEND_COLOR_CMD);
+
+ imesa->Setup[I830_CTXREG_BLENDCOLR] = 0;
+
+ imesa->Setup[I830_CTXREG_MCSB0] = STATE3D_MAP_COORD_SETBIND_CMD;
+ imesa->Setup[I830_CTXREG_MCSB1] = (TEXBIND_SET3(TEXCOORDSRC_VTXSET_3) |
+ TEXBIND_SET2(TEXCOORDSRC_VTXSET_2) |
+ TEXBIND_SET1(TEXCOORDSRC_VTXSET_1) |
+ TEXBIND_SET0(TEXCOORDSRC_VTXSET_0));
+
+ imesa->LcsCullMode = CULLMODE_CW; /* GL default */
+
+ memset(imesa->BufferSetup, 0, sizeof(imesa->BufferSetup));
+ memset(imesa->StippleSetup, 0, sizeof(imesa->StippleSetup));
+
+
+ if (imesa->glCtx->Visual.doubleBufferMode &&
+ imesa->sarea->pf_current_page == 0) {
+ imesa->drawMap = i830Screen->back.map;
+ imesa->readMap = i830Screen->back.map;
+ imesa->BufferSetup[I830_DESTREG_CBUFADDR] = i830Screen->backOffset;
+ imesa->BufferSetup[I830_DESTREG_DBUFADDR] = 0;
+ } else {
+ /* use front buffer by default */
+ imesa->drawMap = (char *)imesa->driScreen->pFB;
+ imesa->readMap = (char *)imesa->driScreen->pFB;
+ imesa->BufferSetup[I830_DESTREG_CBUFADDR] = i830Screen->fbOffset;
+ imesa->BufferSetup[I830_DESTREG_DBUFADDR] = 0;
+ }
+
+ imesa->BufferSetup[I830_DESTREG_DV0] = STATE3D_DST_BUF_VARS_CMD;
+
+ switch (i830Screen->fbFormat) {
+ case DV_PF_555:
+ case DV_PF_565:
+ imesa->BufferSetup[I830_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */
+ DSTORG_VERT_BIAS(0x8) | /* .5 */
+ i830Screen->fbFormat |
+ DEPTH_IS_Z |
+ DEPTH_FRMT_16_FIXED);
+ break;
+ case DV_PF_8888:
+ imesa->BufferSetup[I830_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */
+ DSTORG_VERT_BIAS(0x8) | /* .5 */
+ i830Screen->fbFormat |
+ DEPTH_IS_Z |
+ DEPTH_FRMT_24_FIXED_8_OTHER);
+ break;
+ }
+ imesa->BufferSetup[I830_DESTREG_SENABLE] = (STATE3D_SCISSOR_ENABLE_CMD |
+ DISABLE_SCISSOR_RECT);
+ imesa->BufferSetup[I830_DESTREG_SR0] = STATE3D_SCISSOR_RECT_0_CMD;
+ imesa->BufferSetup[I830_DESTREG_SR1] = 0;
+ imesa->BufferSetup[I830_DESTREG_SR2] = 0;
+
+ imesa->BufferSetup[I830_DESTREG_DR0] = STATE3D_DRAW_RECT_CMD;
+ imesa->BufferSetup[I830_DESTREG_DR1] = 0;
+ imesa->BufferSetup[I830_DESTREG_DR2] = 0;
+ imesa->BufferSetup[I830_DESTREG_DR3] = (((i830Screen->height)<<16) |
+ (i830Screen->width));
+ imesa->BufferSetup[I830_DESTREG_DR4] = 0;
+
+ memcpy( imesa->Init_Setup,
+ imesa->Setup,
+ sizeof(imesa->Setup) );
+ memcpy( imesa->Init_BufferSetup,
+ imesa->BufferSetup,
+ sizeof(imesa->BufferSetup) );
+
+}
+
+static void i830InvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ I830_CONTEXT(ctx)->NewGLState |= new_state;
+}
+
+void i830DDInitStateFuncs(GLcontext *ctx)
+{
+ /* Callbacks for internal Mesa events.
+ */
+ ctx->Driver.UpdateState = i830InvalidateState;
+
+ /* API callbacks
+ */
+ ctx->Driver.AlphaFunc = i830AlphaFunc;
+ ctx->Driver.BlendEquationSeparate = i830BlendEquationSeparate;
+ ctx->Driver.BlendFuncSeparate = i830BlendFuncSeparate;
+ ctx->Driver.BlendColor = i830BlendColor;
+ ctx->Driver.ClearColor = i830ClearColor;
+ ctx->Driver.ColorMask = i830ColorMask;
+ ctx->Driver.CullFace = i830CullFaceFrontFace;
+ ctx->Driver.DepthFunc = i830DepthFunc;
+ ctx->Driver.DepthMask = i830DepthMask;
+ ctx->Driver.Enable = i830Enable;
+ ctx->Driver.Fogfv = i830Fogfv;
+ ctx->Driver.FrontFace = i830CullFaceFrontFace;
+ ctx->Driver.LineWidth = i830LineWidth;
+ ctx->Driver.PointSize = i830PointSize;
+ ctx->Driver.LogicOpcode = i830LogicOp;
+ ctx->Driver.PolygonStipple = i830PolygonStippleFallback;
+ ctx->Driver.RenderMode = i830RenderMode;
+ ctx->Driver.Scissor = i830Scissor;
+ ctx->Driver.DrawBuffer = i830DrawBuffer;
+ ctx->Driver.ReadBuffer = i830ReadBuffer;
+ ctx->Driver.ShadeModel = i830ShadeModel;
+ ctx->Driver.DepthRange = i830DepthRange;
+ ctx->Driver.Viewport = i830Viewport;
+ ctx->Driver.LightModelfv = i830LightModelfv;
+
+ ctx->Driver.StencilFunc = i830StencilFunc;
+ ctx->Driver.StencilMask = i830StencilMask;
+ ctx->Driver.StencilOp = i830StencilOp;
+
+ /* Pixel path fallbacks.
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_state.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_state.h
new file mode 100644
index 000000000..b65165124
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_state.h
@@ -0,0 +1,68 @@
+/**************************************************************************
+
+Copyright 2001 VA Linux Systems Inc., Fremont, 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
+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, VA LINUX SYSTEMS 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.
+
+**************************************************************************/
+
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_state.h,v 1.3 2002/12/10 01:26:53 dawes Exp $ */
+
+/*
+ * Author:
+ * Jeff Hartmann <jhartmann@2d3d.com>
+ *
+ * Heavily based on the I810 driver, which was written by:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+#ifndef _I830_STATE_H
+#define _I830_STATE_H
+
+#include "i830_context.h"
+#include "colormac.h"
+#define FloatToInt(F) ((int)(F))
+
+/*
+ * * This function/macro is sensitive to precision. Test carefully
+ * * if you change it.
+ * */
+#define FLOAT_COLOR_TO_UBYTE_COLOR(b, f) \
+ do { \
+ union {GLfloat r; GLuint i; } tmp; \
+ tmp.r = f; \
+ b = ((tmp.i >= IEEE_ONE) \
+ ? ((GLint)tmp.i < 0) ? (GLubyte)0 : (GLubyte)255 \
+ : (tmp.r = tmp.r*(255.0F/256.0F) + 32768.0F, \
+ (GLubyte)tmp.i)); \
+ } while (0)
+
+
+
+extern void i830DDInitState( GLcontext *ctx );
+extern void i830DDInitStateFuncs( GLcontext *ctx );
+
+extern void i830PrintDirty( const char *msg, GLuint state );
+extern void i830SetDrawBuffer(GLcontext *ctx, GLenum mode );
+
+extern void i830Fallback( i830ContextPtr imesa, GLuint bit, GLboolean mode );
+#define FALLBACK( imesa, bit, mode ) i830Fallback( imesa, bit, mode )
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_tex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_tex.c
new file mode 100644
index 000000000..41b5d9293
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_tex.c
@@ -0,0 +1,700 @@
+/**************************************************************************
+
+Copyright 2001 2d3d Inc., Delray Beach, FL
+
+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, VA LINUX SYSTEMS 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.
+
+**************************************************************************/
+
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_tex.c,v 1.5 2003/05/07 21:56:31 dawes Exp $ */
+
+/*
+ * Author:
+ * Jeff Hartmann <jhartmann@2d3d.com>
+ *
+ * Heavily based on the I810 driver, which was written by:
+ * Keith Whitwell <keithw@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "imports.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "texstore.h"
+#include "teximage.h"
+#include "texformat.h"
+#include "texmem.h"
+#include "texobj.h"
+#include "swrast/swrast.h"
+#include "texobj.h"
+#include "mm.h"
+
+#include "i830_screen.h"
+#include "i830_dri.h"
+#include "i830_context.h"
+#include "i830_tex.h"
+#include "i830_state.h"
+#include "i830_ioctl.h"
+
+/*
+ * Compute the 'S2.4' lod bias factor from the floating point OpenGL bias.
+ */
+static void i830ComputeLodBias( i830ContextPtr imesa, unsigned unit,
+ GLfloat bias )
+{
+ int b;
+
+ b = (int) (bias * 16.0);
+ if(b > 63) b = 63;
+ else if (b < -64) b = -64;
+ imesa->LodBias[ unit ] = ((b << TM0S3_LOD_BIAS_SHIFT) &
+ TM0S3_LOD_BIAS_MASK);
+}
+
+
+/**
+ * Set the texture wrap modes.
+ *
+ * The i830M (and related graphics cores) do not support GL_CLAMP. The Intel
+ * drivers for "other operating systems" implement GL_CLAMP as
+ * GL_CLAMP_TO_EDGE, so the same is done here.
+ *
+ * \param t Texture object whose wrap modes are to be set
+ * \param swrap Wrap mode for the \a s texture coordinate
+ * \param twrap Wrap mode for the \a t texture coordinate
+ */
+
+static void i830SetTexWrapping(i830TextureObjectPtr tex,
+ GLenum swrap, GLenum twrap)
+{
+ tex->Setup[I830_TEXREG_MCS] &= ~(TEXCOORD_ADDR_U_MASK|TEXCOORD_ADDR_V_MASK);
+
+ switch( swrap ) {
+ case GL_REPEAT:
+ tex->Setup[I830_TEXREG_MCS] |= TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_WRAP);
+ break;
+ case GL_CLAMP:
+ case GL_CLAMP_TO_EDGE:
+ tex->Setup[I830_TEXREG_MCS] |= TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_CLAMP);
+ break;
+ case GL_CLAMP_TO_BORDER:
+ tex->Setup[I830_TEXREG_MCS] |=
+ TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_CLAMP_BORDER);
+ break;
+ case GL_MIRRORED_REPEAT:
+ tex->Setup[I830_TEXREG_MCS] |=
+ TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_MIRROR);
+ break;
+ default:
+ _mesa_problem(NULL, "bad S wrap mode in %s", __FUNCTION__);
+ }
+
+ switch( twrap ) {
+ case GL_REPEAT:
+ tex->Setup[I830_TEXREG_MCS] |= TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_WRAP);
+ break;
+ case GL_CLAMP:
+ case GL_CLAMP_TO_EDGE:
+ tex->Setup[I830_TEXREG_MCS] |= TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_CLAMP);
+ break;
+ case GL_CLAMP_TO_BORDER:
+ tex->Setup[I830_TEXREG_MCS] |=
+ TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_CLAMP_BORDER);
+ break;
+ case GL_MIRRORED_REPEAT:
+ tex->Setup[I830_TEXREG_MCS] |=
+ TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_MIRROR);
+ break;
+ default:
+ _mesa_problem(NULL, "bad T wrap mode in %s", __FUNCTION__);
+ }
+}
+
+static void i830SetTexMaxAnisotropy( i830TextureObjectPtr t, GLfloat max )
+{
+ t->max_anisotropy = max;
+}
+
+
+/**
+ * Set the texture magnification and minification modes.
+ *
+ * \param t Texture whose filter modes are to be set
+ * \param minf Texture minification mode
+ * \param magf Texture magnification mode
+ * \param bias LOD bias for this texture unit.
+ */
+
+static void i830SetTexFilter( i830TextureObjectPtr t,
+ GLenum minf, GLenum magf )
+{
+ int minFilt = 0, mipFilt = 0, magFilt = 0;
+
+ if(I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if ( t->max_anisotropy > 1.0 ) {
+ minFilt = FILTER_ANISOTROPIC;
+ magFilt = FILTER_ANISOTROPIC;
+ }
+ else {
+ switch (minf) {
+ case GL_NEAREST:
+ minFilt = FILTER_NEAREST;
+ mipFilt = MIPFILTER_NONE;
+ break;
+ case GL_LINEAR:
+ minFilt = FILTER_LINEAR;
+ mipFilt = MIPFILTER_NONE;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ minFilt = FILTER_NEAREST;
+ mipFilt = MIPFILTER_NEAREST;
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ minFilt = FILTER_LINEAR;
+ mipFilt = MIPFILTER_NEAREST;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ minFilt = FILTER_NEAREST;
+ mipFilt = MIPFILTER_LINEAR;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ minFilt = FILTER_LINEAR;
+ mipFilt = MIPFILTER_LINEAR;
+ break;
+ default:
+ _mesa_problem(NULL, "%s: Unsupported min. filter %d", __FUNCTION__,
+ (int) minf );
+ break;
+ }
+
+ switch (magf) {
+ case GL_NEAREST:
+ magFilt = FILTER_NEAREST;
+ break;
+ case GL_LINEAR:
+ magFilt = FILTER_LINEAR;
+ break;
+ default:
+ _mesa_problem(NULL, "%s: Unsupported mag. filter %d", __FUNCTION__,
+ (int) magf );
+ break;
+ }
+ }
+
+ t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MIN_FILTER_MASK;
+ t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MIP_FILTER_MASK;
+ t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MAG_FILTER_MASK;
+ t->Setup[I830_TEXREG_TM0S3] |= ((minFilt << TM0S3_MIN_FILTER_SHIFT) |
+ (mipFilt << TM0S3_MIP_FILTER_SHIFT) |
+ (magFilt << TM0S3_MAG_FILTER_SHIFT));
+}
+
+static void i830SetTexBorderColor(i830TextureObjectPtr t, GLubyte color[4])
+{
+ if(I830_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ t->Setup[I830_TEXREG_TM0S4] =
+ I830PACKCOLOR8888(color[0],color[1],color[2],color[3]);
+}
+
+
+/**
+ * Allocate space for and load the mesa images into the texture memory block.
+ * This will happen before drawing with a new texture, or drawing with a
+ * texture after it was swapped out or teximaged again.
+ */
+
+static i830TextureObjectPtr i830AllocTexObj( struct gl_texture_object *texObj )
+{
+ i830TextureObjectPtr t;
+
+ t = CALLOC_STRUCT( i830_texture_object_t );
+ texObj->DriverData = t;
+ if ( t != NULL ) {
+ /* Initialize non-image-dependent parts of the state:
+ */
+ t->base.tObj = texObj;
+
+ t->Setup[I830_TEXREG_TM0LI] = STATE3D_LOAD_STATE_IMMEDIATE_2;
+ t->Setup[I830_TEXREG_TM0S0] = TM0S0_USE_FENCE;
+ t->Setup[I830_TEXREG_TM0S1] = 0;
+ t->Setup[I830_TEXREG_TM0S2] = 0;
+ t->Setup[I830_TEXREG_TM0S3] = 0;
+
+ t->Setup[I830_TEXREG_NOP0] = 0;
+ t->Setup[I830_TEXREG_NOP1] = 0;
+ t->Setup[I830_TEXREG_NOP2] = 0;
+
+ t->Setup[I830_TEXREG_MCS] = (STATE3D_MAP_COORD_SET_CMD |
+ MAP_UNIT(0) |
+ ENABLE_TEXCOORD_PARAMS |
+ TEXCOORDS_ARE_NORMAL |
+ TEXCOORDTYPE_CARTESIAN |
+ ENABLE_ADDR_V_CNTL |
+ TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_WRAP) |
+ ENABLE_ADDR_U_CNTL |
+ TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_WRAP));
+
+ make_empty_list( & t->base );
+
+ i830SetTexWrapping( t, texObj->WrapS, texObj->WrapT );
+ i830SetTexMaxAnisotropy( t, texObj->MaxAnisotropy );
+ i830SetTexFilter( t, texObj->MinFilter, texObj->MagFilter );
+ i830SetTexBorderColor( t, texObj->_BorderChan );
+ }
+
+ return t;
+}
+
+
+static void i830TexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat *params )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ i830TextureObjectPtr t = (i830TextureObjectPtr) tObj->DriverData;
+ GLuint unit = ctx->Texture.CurrentUnit;
+
+ if (!t)
+ return;
+
+ if ( target != GL_TEXTURE_2D && target != GL_TEXTURE_RECTANGLE_NV )
+ return;
+
+ /* Can't do the update now as we don't know whether to flush
+ * vertices or not. Setting imesa->NewGLState means that
+ * i830UpdateTextureState() will be called before any triangles are
+ * rendered. If a statechange has occurred, it will be detected at
+ * that point, and buffered vertices flushed.
+ */
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+ i830SetTexMaxAnisotropy( t, tObj->MaxAnisotropy );
+ i830SetTexFilter( t, tObj->MinFilter, tObj->MagFilter );
+ break;
+
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ i830SetTexWrapping( t, tObj->WrapS, tObj->WrapT );
+ break;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ i830SetTexBorderColor( t, tObj->_BorderChan );
+ break;
+
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ /* The i830 and its successors can do a lot of this without
+ * reloading the textures. A project for someone?
+ */
+ I830_FIREVERTICES( I830_CONTEXT(ctx) );
+ driSwapOutTextureObject( (driTextureObject *) t );
+ break;
+
+ default:
+ return;
+ }
+
+ if (t == imesa->CurrentTexObj[unit]) {
+ I830_STATECHANGE( imesa, I830_UPLOAD_TEX0 );
+ }
+}
+
+
+static void i830TexEnv( GLcontext *ctx, GLenum target,
+ GLenum pname, const GLfloat *param )
+{
+ i830ContextPtr imesa = I830_CONTEXT( ctx );
+ GLuint unit = ctx->Texture.CurrentUnit;
+
+ /* Only one env color. Need a fallback if env colors are different
+ * and texture setup references env color in both units.
+ */
+ switch (pname) {
+ case GL_TEXTURE_ENV_COLOR:
+ case GL_TEXTURE_ENV_MODE:
+ case GL_COMBINE_RGB_EXT:
+ case GL_COMBINE_ALPHA_EXT:
+ case GL_SOURCE0_RGB_EXT:
+ case GL_SOURCE1_RGB_EXT:
+ case GL_SOURCE2_RGB_EXT:
+ case GL_SOURCE0_ALPHA_EXT:
+ case GL_SOURCE1_ALPHA_EXT:
+ case GL_SOURCE2_ALPHA_EXT:
+ case GL_OPERAND0_RGB_EXT:
+ case GL_OPERAND1_RGB_EXT:
+ case GL_OPERAND2_RGB_EXT:
+ case GL_OPERAND0_ALPHA_EXT:
+ case GL_OPERAND1_ALPHA_EXT:
+ case GL_OPERAND2_ALPHA_EXT:
+ case GL_RGB_SCALE_EXT:
+ case GL_ALPHA_SCALE:
+ imesa->TexEnvImageFmt[unit] = 0; /* force recalc of env state */
+ break;
+
+ case GL_TEXTURE_LOD_BIAS_EXT:
+ i830ComputeLodBias( imesa, unit, *param );
+ I830_STATECHANGE( imesa, I830_UPLOAD_TEX_N(unit) );
+ break;
+
+ default:
+ break;
+ }
+}
+
+static void i830TexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ if (t) {
+ I830_FIREVERTICES( I830_CONTEXT(ctx) );
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) i830AllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ }
+
+ _mesa_store_teximage2d( ctx, target, level, internalFormat,
+ width, height, border, format, type,
+ pixels, packing, texObj, texImage );
+}
+
+static void i830TexSubImage2D( 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 )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ if (t) {
+ I830_FIREVERTICES( I830_CONTEXT(ctx) );
+ driSwapOutTextureObject( t );
+ }
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
+
+}
+
+
+
+static void i830CompressedTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ if ( t != NULL ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) i830AllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
+ return;
+ }
+ }
+
+ texImage->IsClientData = GL_FALSE;
+
+ if (I830_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: Using normal storage\n", __FUNCTION__);
+
+ _mesa_store_compressed_teximage2d(ctx, target, level, internalFormat, width,
+ height, border, imageSize, data, texObj, texImage);
+
+ t->dirty_images[face] |= (1 << level);
+}
+
+
+static void i830CompressedTexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ assert( t ); /* this _should_ be true */
+ if ( t ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) i830AllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2D");
+ return;
+ }
+ }
+
+ _mesa_store_compressed_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, imageSize, data, texObj, texImage);
+
+ t->dirty_images[face] |= (1 << level);
+}
+
+
+static void i830BindTexture( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj )
+{
+ assert( (target != GL_TEXTURE_2D && target != GL_TEXTURE_RECTANGLE_NV) ||
+ (tObj->DriverData != NULL) );
+}
+
+
+static void i830DeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
+{
+ driTextureObject * t = (driTextureObject *) tObj->DriverData;
+ if ( t != NULL ) {
+ i830ContextPtr imesa = I830_CONTEXT( ctx );
+
+ if ( imesa ) {
+ I830_FIREVERTICES( imesa );
+ }
+
+ driDestroyTextureObject( t );
+ }
+ /* Free mipmap images and the texture object itself */
+ _mesa_delete_texture_object(ctx, tObj);
+}
+
+
+static const struct gl_texture_format *
+i830ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type )
+{
+ i830ContextPtr imesa = I830_CONTEXT( ctx );
+ const GLboolean do32bpt = ( imesa->i830Screen->cpp == 4 &&
+ imesa->i830Screen->textureSize > 4*1024*1024);
+
+ switch ( internalFormat ) {
+ case 4:
+ case GL_RGBA:
+ case GL_COMPRESSED_RGBA:
+ if ( format == GL_BGRA ) {
+ if ( type == GL_UNSIGNED_INT_8_8_8_8_REV ) {
+ return &_mesa_texformat_argb8888;
+ }
+ else if ( type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
+ return &_mesa_texformat_argb4444;
+ }
+ else if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
+ return &_mesa_texformat_argb1555;
+ }
+ }
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+
+ case 3:
+ case GL_RGB:
+ case GL_COMPRESSED_RGB:
+ if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
+ return &_mesa_texformat_rgb565;
+ }
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+
+ case GL_RGBA4:
+ case GL_RGBA2:
+ return &_mesa_texformat_argb4444;
+
+ case GL_RGB5_A1:
+ return &_mesa_texformat_argb1555;
+
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+
+ case GL_RGB5:
+ case GL_RGB4:
+ case GL_R3_G3_B2:
+ return &_mesa_texformat_rgb565;
+
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ case GL_COMPRESSED_ALPHA:
+ return &_mesa_texformat_al88;
+
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ case GL_COMPRESSED_LUMINANCE:
+ return &_mesa_texformat_l8;
+
+ 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_COMPRESSED_LUMINANCE_ALPHA:
+ return &_mesa_texformat_al88;
+
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case GL_COMPRESSED_INTENSITY:
+ return &_mesa_texformat_i8;
+
+ case GL_YCBCR_MESA:
+ if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
+ type == GL_UNSIGNED_BYTE)
+ return &_mesa_texformat_ycbcr;
+ else
+ return &_mesa_texformat_ycbcr_rev;
+
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ return &_mesa_texformat_rgb_fxt1;
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ return &_mesa_texformat_rgba_fxt1;
+
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgb_dxt1;
+
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgba_dxt1;
+
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ return &_mesa_texformat_rgba_dxt3;
+
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ return &_mesa_texformat_rgba_dxt5;
+
+ default:
+ fprintf(stderr, "unexpected texture format in %s\n", __FUNCTION__);
+ return NULL;
+ }
+
+ return NULL; /* never get here */
+}
+
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
+ * Note: this function will be called during context creation to
+ * allocate the default texture objects.
+ * Note: we could use containment here to 'derive' the driver-specific
+ * texture object from the core mesa gl_texture_object. Not done at this time.
+ */
+static struct gl_texture_object *
+i830NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+{
+ struct gl_texture_object *obj;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ i830AllocTexObj( obj );
+ return obj;
+}
+
+void i830InitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->NewTextureObject = i830NewTextureObject;
+ functions->DeleteTexture = i830DeleteTexture;
+ functions->ChooseTextureFormat = i830ChooseTextureFormat;
+ functions->TexImage2D = i830TexImage2D;
+ functions->TexSubImage2D = i830TexSubImage2D;
+ functions->BindTexture = i830BindTexture;
+ functions->TexParameter = i830TexParameter;
+ functions->TexEnv = i830TexEnv;
+ functions->IsTextureResident = driIsTextureResident;
+ functions->CompressedTexImage2D = i830CompressedTexImage2D;
+ functions->CompressedTexSubImage2D = i830CompressedTexSubImage2D;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_tex.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_tex.h
new file mode 100644
index 000000000..68c18b105
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_tex.h
@@ -0,0 +1,70 @@
+/*
+ * GLX Hardware Device Driver for Intel i810
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * 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
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ * Adapted for use in the I830M driver:
+ * Jeff Hartmann <jhartmann@2d3d.com>
+ */
+
+#ifndef I830TEX_INC
+#define I830TEX_INC
+
+#include "mtypes.h"
+#include "i830_context.h"
+#include "i830_3d_reg.h"
+#include "texmem.h"
+
+#define I830_TEX_MAXLEVELS 10
+
+struct i830_texture_object_t
+{
+ driTextureObject base;
+
+ int texelBytes;
+ int Pitch;
+ int Height;
+ char *BufAddr;
+ GLenum palette_format;
+ GLuint palette[256];
+ struct {
+ const struct gl_texture_image *image;
+ int offset; /* into BufAddr */
+ int height;
+ int internalFormat;
+ } image[6][I830_TEX_MAXLEVELS];
+
+ /* Support for multitexture.
+ */
+
+ GLuint current_unit;
+ GLuint Setup[I830_TEX_SETUP_SIZE];
+ GLuint dirty;
+
+ GLfloat max_anisotropy;
+};
+
+void i830UpdateTextureState( GLcontext *ctx );
+void i830InitTextureFuncs( struct dd_function_table *functions );
+
+void i830DestroyTexObj( i830ContextPtr imesa, i830TextureObjectPtr t );
+int i830UploadTexImagesLocked( i830ContextPtr imesa, i830TextureObjectPtr t );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_texmem.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_texmem.c
new file mode 100644
index 000000000..7faf90874
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_texmem.c
@@ -0,0 +1,237 @@
+/**************************************************************************
+
+Copyright 2001 2d3d Inc., Delray Beach, FL
+
+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, VA LINUX SYSTEMS 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.
+
+**************************************************************************/
+
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_texmem.c,v 1.3 2002/12/10 01:26:53 dawes Exp $ */
+
+/*
+ * Author:
+ * Jeff Hartmann <jhartmann@2d3d.com>
+ *
+ * Heavily based on the I810 driver, which was written by:
+ * Keith Whitwell <keithw@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "texformat.h"
+
+#include "i830_screen.h"
+#include "i830_dri.h"
+
+#include "i830_context.h"
+#include "i830_tex.h"
+#include "i830_state.h"
+#include "i830_ioctl.h"
+
+
+void i830DestroyTexObj(i830ContextPtr imesa, i830TextureObjectPtr t)
+{
+ unsigned i;
+
+
+ /* See if it was the driver's current object.
+ */
+ if ( imesa != NULL ) {
+ for ( i = 0 ; i < imesa->glCtx->Const.MaxTextureUnits ; i++ ) {
+ if ( t == imesa->CurrentTexObj[ i ] ) {
+ imesa->CurrentTexObj[ i ] = NULL;
+ imesa->dirty &= ~I830_UPLOAD_TEX_N( i );
+ }
+ }
+ }
+}
+
+#if defined(i386) || defined(__i386__)
+/* From linux kernel i386 header files, copes with odd sizes better
+ * than COPY_DWORDS would:
+ */
+static __inline__ void * __memcpy(void * to, const void * from, size_t n)
+{
+int d0, d1, d2;
+__asm__ __volatile__(
+ "rep ; movsl\n\t"
+ "testb $2,%b4\n\t"
+ "je 1f\n\t"
+ "movsw\n"
+ "1:\ttestb $1,%b4\n\t"
+ "je 2f\n\t"
+ "movsb\n"
+ "2:"
+ : "=&c" (d0), "=&D" (d1), "=&S" (d2)
+ :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
+ : "memory");
+return (to);
+}
+#else
+/* Allow compilation on other architectures */
+#define __memcpy memcpy
+#endif
+
+/* Upload an image from mesa's internal copy.
+ */
+static void i830UploadTexLevel( i830ContextPtr imesa,
+ i830TextureObjectPtr t, int hwlevel )
+{
+ const struct gl_texture_image *image = t->image[0][hwlevel].image;
+ int j;
+
+ if (!image || !image->Data)
+ return;
+
+ if (image->IsCompressed) {
+ GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[0][hwlevel].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ if ((t->Setup[I830_TEXREG_TM0S1] & TM0S1_MT_FORMAT_MASK)==MT_COMPRESS_FXT1)
+ {
+ for (j = 0 ; j < image->Height/4 ; j++, dst += (t->Pitch)) {
+ __memcpy(dst, src, (image->Width*2) );
+ src += image->Width*2;
+ }
+ }
+ else if ((t->Setup[I830_TEXREG_TM0S1] & TM0S1_MT_FORMAT_MASK)==MT_COMPRESS_DXT1)
+ {
+ for (j = 0 ; j < image->Height/4 ; j++, dst += (t->Pitch)) {
+ __memcpy(dst, src, (image->Width*2) );
+ src += image->Width*2;
+ }
+ }
+ else if (((t->Setup[I830_TEXREG_TM0S1] & TM0S1_MT_FORMAT_MASK)==MT_COMPRESS_DXT2_3) || ((t->Setup[I830_TEXREG_TM0S1] & TM0S1_MT_FORMAT_MASK)==MT_COMPRESS_DXT4_5))
+ {
+ for (j = 0 ; j < image->Height/4 ; j++, dst += (t->Pitch)) {
+ __memcpy(dst, src, (image->Width*4) );
+ src += image->Width*4;
+ }
+ }
+ }
+ else if (image->Width * image->TexFormat->TexelBytes == t->Pitch) {
+ GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[0][hwlevel].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ memcpy( dst, src, t->Pitch * image->Height );
+ }
+ else switch (image->TexFormat->TexelBytes) {
+ case 1:
+ {
+ GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[0][hwlevel].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) {
+ __memcpy(dst, src, image->Width );
+ src += image->Width;
+ }
+ }
+ break;
+
+ case 2:
+ {
+ GLushort *dst = (GLushort *)(t->BufAddr + t->image[0][hwlevel].offset);
+ GLushort *src = (GLushort *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/2)) {
+ __memcpy(dst, src, image->Width * 2 );
+ src += image->Width;
+ }
+ }
+ break;
+
+ case 4:
+ {
+ GLuint *dst = (GLuint *)(t->BufAddr + t->image[0][hwlevel].offset);
+ GLuint *src = (GLuint *)image->Data;
+
+ for (j = 0 ; j < image->Height ; j++, dst += (t->Pitch/4)) {
+ __memcpy(dst, src, image->Width * 4 );
+ src += image->Width;
+ }
+ }
+ break;
+
+ default:
+ fprintf(stderr, "%s: Not supported texel size %d\n",
+ __FUNCTION__, image->TexFormat->TexelBytes);
+ }
+}
+
+
+/* This is called with the lock held. May have to eject our own and/or
+ * other client's texture objects to make room for the upload.
+ */
+
+int i830UploadTexImagesLocked( i830ContextPtr imesa, i830TextureObjectPtr t )
+{
+ int ofs;
+ int i;
+
+ if ( t->base.memBlock == NULL ) {
+ int heap;
+
+ heap = driAllocateTexture( imesa->texture_heaps, imesa->nr_heaps,
+ (driTextureObject *) t );
+ if ( heap == -1 ) {
+ return -1;
+ }
+
+ /* Set the base offset of the texture image */
+ ofs = t->base.memBlock->ofs;
+ t->BufAddr = imesa->i830Screen->tex.map + ofs;
+ t->Setup[I830_TEXREG_TM0S0] = (TM0S0_USE_FENCE |
+ (imesa->i830Screen->textureOffset + ofs));
+
+ for ( i = 0 ; i < imesa->glCtx->Const.MaxTextureUnits ; i++ ) {
+ if (t == imesa->CurrentTexObj[i]) {
+ imesa->dirty |= I830_UPLOAD_TEX_N( i );
+ }
+ }
+ }
+
+
+ /* Let the world know we've used this memory recently.
+ */
+ driUpdateTextureLRU( (driTextureObject *) t );
+
+ if (imesa->texture_heaps[0]->timestamp >= GET_DISPATCH_AGE(imesa))
+ i830WaitAgeLocked( imesa, imesa->texture_heaps[0]->timestamp );
+
+ /* Upload any images that are new */
+ if (t->base.dirty_images[0]) {
+ const int numLevels = t->base.lastLevel - t->base.firstLevel + 1;
+
+ for (i = 0 ; i < numLevels ; i++) {
+ if ( (t->base.dirty_images[0] & (1 << (i+t->base.firstLevel))) != 0 ) {
+ i830UploadTexLevel( imesa, t, i );
+ }
+ }
+ t->base.dirty_images[0] = 0;
+ imesa->sarea->perf_boxes |= I830_BOX_TEXTURE_LOAD;
+ }
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_texstate.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_texstate.c
new file mode 100644
index 000000000..358c554f3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_texstate.c
@@ -0,0 +1,716 @@
+/**************************************************************************
+
+Copyright 2001 2d3d Inc., Delray Beach, FL
+
+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, VA LINUX SYSTEMS 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.
+
+**************************************************************************/
+
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_texstate.c,v 1.3 2002/12/10 01:26:53 dawes Exp $ */
+
+/**
+ * \file i830_texstate.c
+ *
+ * Heavily based on the I810 driver, which was written by Keith Whitwell.
+ *
+ * \author Jeff Hartmann <jhartmann@2d3d.com>
+ * \author Keith Whitwell <keithw@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "texformat.h"
+#include "texstore.h"
+
+#include "mm.h"
+
+#include "i830_screen.h"
+#include "i830_dri.h"
+
+#include "i830_context.h"
+#include "i830_tex.h"
+#include "i830_state.h"
+#include "i830_ioctl.h"
+
+#define I830_TEX_UNIT_ENABLED(unit) (1<<unit)
+
+static void i830SetTexImages( i830ContextPtr imesa,
+ struct gl_texture_object *tObj )
+{
+ GLuint total_height, pitch, i, textureFormat;
+ i830TextureObjectPtr t = (i830TextureObjectPtr) tObj->DriverData;
+ const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
+ GLint numLevels;
+
+ switch( baseImage->TexFormat->MesaFormat ) {
+ case MESA_FORMAT_L8:
+ t->texelBytes = 1;
+ textureFormat = MAPSURF_8BIT | MT_8BIT_L8;
+ break;
+
+ case MESA_FORMAT_I8:
+ t->texelBytes = 1;
+ textureFormat = MAPSURF_8BIT | MT_8BIT_I8;
+ break;
+
+ case MESA_FORMAT_AL88:
+ t->texelBytes = 2;
+ textureFormat = MAPSURF_16BIT | MT_16BIT_AY88;
+ break;
+
+ case MESA_FORMAT_RGB565:
+ t->texelBytes = 2;
+ textureFormat = MAPSURF_16BIT | MT_16BIT_RGB565;
+ break;
+
+ case MESA_FORMAT_ARGB1555:
+ t->texelBytes = 2;
+ textureFormat = MAPSURF_16BIT | MT_16BIT_ARGB1555;
+ break;
+
+ case MESA_FORMAT_ARGB4444:
+ t->texelBytes = 2;
+ textureFormat = MAPSURF_16BIT | MT_16BIT_ARGB4444;
+ break;
+
+ case MESA_FORMAT_ARGB8888:
+ t->texelBytes = 4;
+ textureFormat = MAPSURF_32BIT | MT_32BIT_ARGB8888;
+ break;
+
+ case MESA_FORMAT_YCBCR_REV:
+ t->texelBytes = 2;
+ textureFormat = (MAPSURF_422 | MT_422_YCRCB_NORMAL |
+ TM0S1_COLORSPACE_CONVERSION);
+ break;
+
+ case MESA_FORMAT_YCBCR:
+ t->texelBytes = 2;
+ textureFormat = (MAPSURF_422 | MT_422_YCRCB_SWAPY | /* ??? */
+ TM0S1_COLORSPACE_CONVERSION);
+ break;
+
+ case MESA_FORMAT_RGB_FXT1:
+ case MESA_FORMAT_RGBA_FXT1:
+ t->texelBytes = 2;
+ textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_FXT1);
+ break;
+ case MESA_FORMAT_RGBA_DXT1:
+ case MESA_FORMAT_RGB_DXT1:
+ /*
+ * DXTn pitches are Width/4 * blocksize in bytes
+ * for DXT1: blocksize=8 so Width/4*8 = Width * 2
+ * for DXT3/5: blocksize=16 so Width/4*16 = Width * 4
+ */
+ t->texelBytes = 2;
+ textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT1);
+ break;
+ case MESA_FORMAT_RGBA_DXT3:
+ t->texelBytes = 4;
+ textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT2_3);
+ break;
+ case MESA_FORMAT_RGBA_DXT5:
+ t->texelBytes = 4;
+ textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
+ break;
+ default:
+ fprintf(stderr, "%s: bad image format\n", __FUNCTION__);
+ free( t );
+ return;
+ }
+
+ /* Compute which mipmap levels we really want to send to the hardware.
+ */
+
+ driCalculateTextureFirstLastLevel( (driTextureObject *) t );
+
+
+ /* Figure out the amount of memory required to hold all the mipmap
+ * levels. Choose the smallest pitch to accomodate the largest
+ * mipmap:
+ */
+ numLevels = t->base.lastLevel - t->base.firstLevel + 1;
+
+ /* Pitch would be subject to additional rules if texture memory were
+ * tiled. Currently it isn't.
+ */
+ if (0) {
+ pitch = 128;
+ while (pitch < tObj->Image[0][t->base.firstLevel]->Width * t->texelBytes)
+ pitch *= 2;
+ }
+ else {
+ pitch = tObj->Image[0][t->base.firstLevel]->Width * t->texelBytes;
+ pitch = (pitch + 3) & ~3;
+ }
+
+
+ /* All images must be loaded at this pitch. Count the number of
+ * lines required:
+ */
+ for ( total_height = i = 0 ; i < numLevels ; i++ ) {
+ t->image[0][i].image = tObj->Image[0][t->base.firstLevel + i];
+ if (!t->image[0][i].image)
+ break;
+
+ t->image[0][i].offset = total_height * pitch;
+ if (t->image[0][i].image->IsCompressed)
+ {
+ if (t->image[0][i].image->Height > 4)
+ total_height += t->image[0][i].image->Height/4;
+ else
+ total_height += 1;
+ }
+ else
+ total_height += t->image[0][i].image->Height;
+ t->image[0][i].internalFormat = baseImage->Format;
+ }
+
+ t->Pitch = pitch;
+ t->base.totalSize = total_height*pitch;
+ t->Setup[I830_TEXREG_TM0S1] =
+ (((tObj->Image[0][t->base.firstLevel]->Height - 1) << TM0S1_HEIGHT_SHIFT) |
+ ((tObj->Image[0][t->base.firstLevel]->Width - 1) << TM0S1_WIDTH_SHIFT) |
+ textureFormat);
+ t->Setup[I830_TEXREG_TM0S2] =
+ ((((pitch / 4) - 1) << TM0S2_PITCH_SHIFT));
+ t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MAX_MIP_MASK;
+ t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MIN_MIP_MASK;
+ t->Setup[I830_TEXREG_TM0S3] |= ((numLevels - 1)*4) << TM0S3_MIN_MIP_SHIFT;
+ t->dirty = I830_UPLOAD_TEX0 | I830_UPLOAD_TEX1
+ | I830_UPLOAD_TEX2 | I830_UPLOAD_TEX3;
+
+ LOCK_HARDWARE( imesa );
+ i830UploadTexImagesLocked( imesa, t );
+ UNLOCK_HARDWARE( imesa );
+}
+
+/* ================================================================
+ * Texture combine functions
+ */
+
+
+/**
+ * Calculate the hardware instuctions to setup the current texture enviromnemt
+ * settings. Since \c gl_texture_unit::_CurrentCombine is used, both
+ * "classic" texture enviroments and GL_ARB_texture_env_combine type texture
+ * environments are treated identically.
+ *
+ * \todo
+ * This function should return \c GLboolean. When \c GL_FALSE is returned,
+ * it means that an environment is selected that the hardware cannot do. This
+ * is the way the Radeon and R200 drivers work.
+ *
+ * \todo
+ * Looking at i830_3d_regs.h, it seems the i830 can do part of
+ * GL_ATI_texture_env_combine3. It can handle using \c GL_ONE and
+ * \c GL_ZERO as combine inputs (which the code already supports). It can
+ * also handle the \c GL_MODULATE_ADD_ATI mode. Is it worth investigating
+ * partial support for the extension?
+ *
+ * \todo
+ * Some thought needs to be put into the way combiners work. The driver
+ * treats the hardware as if there's a specific combine unit tied to each
+ * texture unit. That's why there's the special case for a disabled texture
+ * unit. That's not the way the hardware works. In reality, there are 4
+ * texture units and four general instruction slots. Each instruction slot
+ * can use any texture as an input. There's no need for this wierd "no-op"
+ * stuff. If texture units 0 and 3 are enabled, the instructions to combine
+ * them should be in slots 0 and 1, not 0 and 3 with two no-ops inbetween.
+ */
+
+static void i830UpdateTexEnv( GLcontext *ctx, GLuint unit )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ const GLuint numColorArgs = texUnit->_CurrentCombine->_NumArgsRGB;
+ const GLuint numAlphaArgs = texUnit->_CurrentCombine->_NumArgsA;
+
+ GLboolean need_constant_color = GL_FALSE;
+ GLuint blendop;
+ GLuint ablendop;
+ GLuint args_RGB[3];
+ GLuint args_A[3];
+ GLuint rgb_shift = texUnit->Combine.ScaleShiftRGB;
+ GLuint alpha_shift = texUnit->Combine.ScaleShiftA;
+ int i;
+ unsigned used;
+ static const GLuint tex_blend_rgb[3] = {
+ TEXPIPE_COLOR | TEXBLEND_ARG1 | TEXBLENDARG_MODIFY_PARMS,
+ TEXPIPE_COLOR | TEXBLEND_ARG2 | TEXBLENDARG_MODIFY_PARMS,
+ TEXPIPE_COLOR | TEXBLEND_ARG0 | TEXBLENDARG_MODIFY_PARMS,
+ };
+ static const GLuint tex_blend_a[3] = {
+ TEXPIPE_ALPHA | TEXBLEND_ARG1 | TEXBLENDARG_MODIFY_PARMS,
+ TEXPIPE_ALPHA | TEXBLEND_ARG2 | TEXBLENDARG_MODIFY_PARMS,
+ TEXPIPE_ALPHA | TEXBLEND_ARG0 | TEXBLENDARG_MODIFY_PARMS,
+ };
+ static const GLuint op_rgb[4] = {
+ 0,
+ TEXBLENDARG_INV_ARG,
+ TEXBLENDARG_REPLICATE_ALPHA,
+ TEXBLENDARG_REPLICATE_ALPHA | TEXBLENDARG_INV_ARG,
+ };
+
+
+
+ imesa->TexBlendWordsUsed[unit] = 0;
+
+ if(I830_DEBUG&DEBUG_TEXTURE)
+ fprintf(stderr, "[%s:%u] env. mode = %s\n", __FUNCTION__, __LINE__,
+ _mesa_lookup_enum_by_nr(texUnit->EnvMode));
+
+
+ if ( !texUnit->_ReallyEnabled ) {
+ imesa->TexBlend[unit][0] = (STATE3D_MAP_BLEND_OP_CMD(unit) |
+ TEXPIPE_COLOR |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ DISABLE_TEX_CNTRL_STAGE |
+ TEXOP_SCALE_1X |
+ TEXOP_MODIFY_PARMS |
+ TEXBLENDOP_ARG1);
+ imesa->TexBlend[unit][1] = (STATE3D_MAP_BLEND_OP_CMD(unit) |
+ TEXPIPE_ALPHA |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ TEXOP_SCALE_1X |
+ TEXOP_MODIFY_PARMS |
+ TEXBLENDOP_ARG1);
+ imesa->TexBlend[unit][2] = (STATE3D_MAP_BLEND_ARG_CMD(unit) |
+ TEXPIPE_COLOR |
+ TEXBLEND_ARG1 |
+ TEXBLENDARG_MODIFY_PARMS |
+ TEXBLENDARG_CURRENT);
+ imesa->TexBlend[unit][3] = (STATE3D_MAP_BLEND_ARG_CMD(unit) |
+ TEXPIPE_ALPHA |
+ TEXBLEND_ARG1 |
+ TEXBLENDARG_MODIFY_PARMS |
+ TEXBLENDARG_CURRENT);
+ imesa->TexBlendWordsUsed[unit] = 4;
+ }
+ else {
+ switch(texUnit->_CurrentCombine->ModeRGB) {
+ case GL_REPLACE:
+ blendop = TEXBLENDOP_ARG1;
+ break;
+ case GL_MODULATE:
+ blendop = TEXBLENDOP_MODULATE;
+ break;
+ case GL_ADD:
+ blendop = TEXBLENDOP_ADD;
+ break;
+ case GL_ADD_SIGNED:
+ blendop = TEXBLENDOP_ADDSIGNED;
+ break;
+ case GL_INTERPOLATE:
+ blendop = TEXBLENDOP_BLEND;
+ break;
+ case GL_SUBTRACT:
+ blendop = TEXBLENDOP_SUBTRACT;
+ break;
+ case GL_DOT3_RGB_EXT:
+ case GL_DOT3_RGBA_EXT:
+ /* The EXT version of the DOT3 extension does not support the
+ * scale factor, but the ARB version (and the version in OpenGL
+ * 1.3) does.
+ */
+ rgb_shift = 0;
+ alpha_shift = 0;
+ /* FALLTHROUGH */
+
+ case GL_DOT3_RGB:
+ case GL_DOT3_RGBA:
+ blendop = TEXBLENDOP_DOT3;
+ break;
+ default:
+ return;
+ }
+
+ blendop |= (rgb_shift << TEXOP_SCALE_SHIFT);
+
+ switch(texUnit->_CurrentCombine->ModeA) {
+ case GL_REPLACE:
+ ablendop = TEXBLENDOP_ARG1;
+ break;
+ case GL_MODULATE:
+ ablendop = TEXBLENDOP_MODULATE;
+ break;
+ case GL_ADD:
+ ablendop = TEXBLENDOP_ADD;
+ break;
+ case GL_ADD_SIGNED:
+ ablendop = TEXBLENDOP_ADDSIGNED;
+ break;
+ case GL_INTERPOLATE:
+ ablendop = TEXBLENDOP_BLEND;
+ break;
+ case GL_SUBTRACT:
+ ablendop = TEXBLENDOP_SUBTRACT;
+ break;
+ default:
+ return;
+ }
+
+ if ( (texUnit->_CurrentCombine->ModeRGB == GL_DOT3_RGBA_EXT)
+ || (texUnit->_CurrentCombine->ModeRGB == GL_DOT3_RGBA) ) {
+ ablendop = TEXBLENDOP_DOT3;
+ }
+
+ ablendop |= (alpha_shift << TEXOP_SCALE_SHIFT);
+
+ /* Handle RGB args */
+ for( i = 0 ; i < numColorArgs ; i++ ) {
+ const int op = texUnit->_CurrentCombine->OperandRGB[i] - GL_SRC_COLOR;
+
+ assert( (op >= 0) && (op <= 3) );
+ switch(texUnit->_CurrentCombine->SourceRGB[i]) {
+ case GL_TEXTURE:
+ args_RGB[i] = TEXBLENDARG_TEXEL0 + unit;
+ break;
+ case GL_TEXTURE0:
+ case GL_TEXTURE1:
+ case GL_TEXTURE2:
+ case GL_TEXTURE3:
+ args_RGB[i] = TEXBLENDARG_TEXEL0
+ + (texUnit->_CurrentCombine->SourceRGB[i] & 0x03);
+ break;
+ case GL_CONSTANT:
+ args_RGB[i] = TEXBLENDARG_FACTOR_N;
+ need_constant_color = GL_TRUE;
+ break;
+ case GL_PRIMARY_COLOR:
+ args_RGB[i] = TEXBLENDARG_DIFFUSE;
+ break;
+ case GL_PREVIOUS:
+ args_RGB[i] = TEXBLENDARG_CURRENT;
+ break;
+ case GL_ONE:
+ args_RGB[i] = TEXBLENDARG_ONE;
+ break;
+ case GL_ZERO:
+ args_RGB[i] = TEXBLENDARG_ONE | TEXBLENDARG_INV_ARG;
+ break;
+ default:
+ return;
+ }
+
+ /* Xor is used so that GL_ONE_MINUS_SRC_COLOR with GL_ZERO
+ * works correctly.
+ */
+ args_RGB[i] ^= op_rgb[op];
+ }
+
+ /* Handle A args */
+ for( i = 0 ; i < numAlphaArgs ; i++ ) {
+ const int op = texUnit->_CurrentCombine->OperandA[i] - GL_SRC_ALPHA;
+
+ assert( (op >= 0) && (op <= 1) );
+ switch(texUnit->_CurrentCombine->SourceA[i]) {
+ case GL_TEXTURE:
+ args_A[i] = TEXBLENDARG_TEXEL0 + unit;
+ break;
+ case GL_TEXTURE0:
+ case GL_TEXTURE1:
+ case GL_TEXTURE2:
+ case GL_TEXTURE3:
+ args_A[i] = TEXBLENDARG_TEXEL0
+ + (texUnit->_CurrentCombine->SourceA[i] & 0x03);
+ break;
+ case GL_CONSTANT:
+ args_A[i] = TEXBLENDARG_FACTOR_N;
+ need_constant_color = GL_TRUE;
+ break;
+ case GL_PRIMARY_COLOR:
+ args_A[i] = TEXBLENDARG_DIFFUSE;
+ break;
+ case GL_PREVIOUS:
+ args_A[i] = TEXBLENDARG_CURRENT;
+ break;
+ case GL_ONE:
+ args_A[i] = TEXBLENDARG_ONE;
+ break;
+ case GL_ZERO:
+ args_A[i] = TEXBLENDARG_ONE | TEXBLENDARG_INV_ARG;
+ break;
+ default:
+ return;
+ }
+
+ /* We cheat. :) The register values for this are the same as for
+ * RGB. Xor is used so that GL_ONE_MINUS_SRC_ALPHA with GL_ZERO
+ * works correctly.
+ */
+ args_A[i] ^= op_rgb[op];
+ }
+
+ /* Native Arg1 == Arg0 in GL_EXT_texture_env_combine spec */
+ /* Native Arg2 == Arg1 in GL_EXT_texture_env_combine spec */
+ /* Native Arg0 == Arg2 in GL_EXT_texture_env_combine spec */
+
+ /* Build color pipeline */
+
+ used = 0;
+ imesa->TexBlend[unit][used++] = (STATE3D_MAP_BLEND_OP_CMD(unit) |
+ TEXPIPE_COLOR |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ DISABLE_TEX_CNTRL_STAGE |
+ TEXOP_MODIFY_PARMS |
+ blendop);
+
+ imesa->TexBlend[unit][used++] = (STATE3D_MAP_BLEND_OP_CMD(unit) |
+ TEXPIPE_ALPHA |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ TEXOP_MODIFY_PARMS |
+ ablendop);
+
+ for ( i = 0 ; i < numColorArgs ; i++ ) {
+ imesa->TexBlend[unit][used++] = (STATE3D_MAP_BLEND_ARG_CMD(unit) |
+ tex_blend_rgb[i] |
+ args_RGB[i]);
+ }
+
+ for ( i = 0 ; i < numAlphaArgs ; i++ ) {
+ imesa->TexBlend[unit][used++] = (STATE3D_MAP_BLEND_ARG_CMD(unit) |
+ tex_blend_a[i] |
+ args_A[i]);
+ }
+
+
+ if ( need_constant_color ) {
+ GLubyte r, g, b, a;
+ const GLfloat * const fc = texUnit->EnvColor;
+
+ FLOAT_COLOR_TO_UBYTE_COLOR(r, fc[RCOMP]);
+ FLOAT_COLOR_TO_UBYTE_COLOR(g, fc[GCOMP]);
+ FLOAT_COLOR_TO_UBYTE_COLOR(b, fc[BCOMP]);
+ FLOAT_COLOR_TO_UBYTE_COLOR(a, fc[ACOMP]);
+
+ imesa->TexBlend[unit][used++] = STATE3D_COLOR_FACTOR_CMD(unit);
+ imesa->TexBlend[unit][used++] = ((a << 24) | (r << 16) | (g << 8) | b);
+ }
+
+ imesa->TexBlendWordsUsed[unit] = used;
+ }
+
+ I830_STATECHANGE( imesa, I830_UPLOAD_TEXBLEND_N(unit) );
+}
+
+
+/* This is bogus -- can't load the same texture object on two units.
+ */
+static void i830TexSetUnit( i830TextureObjectPtr t, GLuint unit )
+{
+ if(I830_DEBUG&DEBUG_TEXTURE)
+ fprintf(stderr, "%s unit(%d)\n", __FUNCTION__, unit);
+
+ t->Setup[I830_TEXREG_TM0LI] = (STATE3D_LOAD_STATE_IMMEDIATE_2 |
+ (LOAD_TEXTURE_MAP0 << unit) | 4);
+
+ I830_SET_FIELD(t->Setup[I830_TEXREG_MCS], MAP_UNIT_MASK, MAP_UNIT(unit));
+
+ t->current_unit = unit;
+ t->base.bound |= (1U << unit);
+}
+
+#define TEXCOORDTYPE_MASK (~((1<<13)|(1<<12)|(1<<11)))
+
+
+static GLboolean enable_tex_common( GLcontext *ctx, GLuint unit )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ i830TextureObjectPtr t = (i830TextureObjectPtr)tObj->DriverData;
+
+ /* Fallback if there's a texture border */
+ if ( tObj->Image[0][tObj->BaseLevel]->Border > 0 ) {
+ return GL_FALSE;
+ }
+
+ /* Upload teximages (not pipelined)
+ */
+ if (t->base.dirty_images[0]) {
+ i830SetTexImages( imesa, tObj );
+ if (!t->base.memBlock) {
+ return GL_FALSE;
+ }
+ }
+
+ /* Update state if this is a different texture object to last
+ * time.
+ */
+ if (imesa->CurrentTexObj[unit] != t) {
+
+ if ( imesa->CurrentTexObj[unit] != NULL ) {
+ /* The old texture is no longer bound to this texture unit.
+ * Mark it as such.
+ */
+
+ imesa->CurrentTexObj[unit]->base.bound &= ~(1U << unit);
+ }
+
+ I830_STATECHANGE( imesa, I830_UPLOAD_TEX_N(unit) );
+ imesa->CurrentTexObj[unit] = t;
+ i830TexSetUnit(t, unit);
+ }
+
+ /* Update texture environment if texture object image format or
+ * texture environment state has changed.
+ *
+ * KW: doesn't work -- change from tex0 only to tex0+tex1 gets
+ * missed (need to update last stage flag?). Call
+ * i830UpdateTexEnv always.
+ */
+ if (tObj->Image[0][tObj->BaseLevel]->Format !=
+ imesa->TexEnvImageFmt[unit]) {
+ imesa->TexEnvImageFmt[unit] = tObj->Image[0][tObj->BaseLevel]->Format;
+ }
+ i830UpdateTexEnv( ctx, unit );
+ imesa->TexEnabledMask |= I830_TEX_UNIT_ENABLED(unit);
+
+ return GL_TRUE;
+}
+
+static GLboolean enable_tex_rect( GLcontext *ctx, GLuint unit )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ i830TextureObjectPtr t = (i830TextureObjectPtr)tObj->DriverData;
+ GLuint mcs = t->Setup[I830_TEXREG_MCS];
+
+ mcs &= ~TEXCOORDS_ARE_NORMAL;
+ mcs |= TEXCOORDS_ARE_IN_TEXELUNITS;
+
+ if (mcs != t->Setup[I830_TEXREG_MCS]) {
+ I830_STATECHANGE( imesa, I830_UPLOAD_TEX_N(unit) );
+ t->Setup[I830_TEXREG_MCS] = mcs;
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLboolean enable_tex_2d( GLcontext *ctx, GLuint unit )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ i830TextureObjectPtr t = (i830TextureObjectPtr)tObj->DriverData;
+ GLuint mcs = t->Setup[I830_TEXREG_MCS];
+
+ mcs &= ~TEXCOORDS_ARE_IN_TEXELUNITS;
+ mcs |= TEXCOORDS_ARE_NORMAL;
+
+ if (mcs != t->Setup[I830_TEXREG_MCS]) {
+ I830_STATECHANGE( imesa, I830_UPLOAD_TEX_N(unit) );
+ t->Setup[I830_TEXREG_MCS] = mcs;
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLboolean disable_tex( GLcontext *ctx, int unit )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+
+ /* This is happening too often. I need to conditionally send diffuse
+ * state to the card. Perhaps a diffuse dirty flag of some kind.
+ * Will need to change this logic if more than 2 texture units are
+ * used. We need to only do this up to the last unit enabled, or unit
+ * one if nothing is enabled.
+ */
+
+ if ( imesa->CurrentTexObj[unit] != NULL ) {
+ /* The old texture is no longer bound to this texture unit.
+ * Mark it as such.
+ */
+
+ imesa->CurrentTexObj[unit]->base.bound &= ~(1U << unit);
+ imesa->CurrentTexObj[unit] = NULL;
+ }
+
+ imesa->TexEnvImageFmt[unit] = 0;
+ imesa->dirty &= ~(I830_UPLOAD_TEX_N(unit));
+
+ i830UpdateTexEnv( ctx, unit );
+
+ return GL_TRUE;
+}
+
+static GLboolean i830UpdateTexUnit( GLcontext *ctx, GLuint unit )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+ imesa->TexEnabledMask &= ~(I830_TEX_UNIT_ENABLED(unit));
+
+ if (texUnit->_ReallyEnabled == TEXTURE_2D_BIT) {
+ return (enable_tex_common( ctx, unit ) &&
+ enable_tex_2d( ctx, unit ));
+ }
+ else if (texUnit->_ReallyEnabled == TEXTURE_RECT_BIT) {
+ return (enable_tex_common( ctx, unit ) &&
+ enable_tex_rect( ctx, unit ));
+ }
+ else if (texUnit->_ReallyEnabled) {
+ return GL_FALSE;
+ }
+ else {
+ return disable_tex( ctx, unit );
+ }
+}
+
+
+
+void i830UpdateTextureState( GLcontext *ctx )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ int i;
+ int last_stage = 0;
+ GLboolean ok;
+
+ for ( i = 0 ; i < ctx->Const.MaxTextureUnits ; i++ ) {
+ if ( (ctx->Texture.Unit[i]._ReallyEnabled == TEXTURE_2D_BIT)
+ || (ctx->Texture.Unit[i]._ReallyEnabled == TEXTURE_RECT_BIT) ) {
+ last_stage = i;
+ }
+ }
+
+ ok = GL_TRUE;
+ for ( i = 0 ; i <= last_stage ; i++ ) {
+ ok = ok && i830UpdateTexUnit( ctx, i );
+ }
+
+ FALLBACK( imesa, I830_FALLBACK_TEXTURE, !ok );
+
+
+ /* Make sure last stage is set correctly */
+ imesa->TexBlend[last_stage][0] |= TEXOP_LAST_STAGE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_tris.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_tris.c
new file mode 100644
index 000000000..e0907202d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_tris.c
@@ -0,0 +1,1056 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_tris.c,v 1.4 2002/12/10 01:26:54 dawes Exp $ */
+/**************************************************************************
+
+Copyright 2001 VA Linux Systems Inc., Fremont, 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
+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, VA LINUX SYSTEMS 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.
+
+**************************************************************************/
+
+/*
+ * Original Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Adapted for use on the I830M:
+ * Jeff Hartmann <jhartmann@2d3d.com>
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "enums.h"
+#include "dd.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
+#include "i830_screen.h"
+#include "i830_dri.h"
+
+#include "i830_tris.h"
+#include "i830_state.h"
+#include "i830_ioctl.h"
+#include "i830_span.h"
+
+static void i830RenderPrimitive( GLcontext *ctx, GLenum prim );
+
+/***********************************************************************
+ * Emit primitives as inline vertices *
+ ***********************************************************************/
+
+#if defined(USE_X86_ASM)
+#define COPY_DWORDS( j, vb, vertsize, v ) \
+do { \
+ int __tmp; \
+ __asm__ __volatile__( "rep ; movsl" \
+ : "=%c" (j), "=D" (vb), "=S" (__tmp) \
+ : "0" (vertsize), \
+ "D" ((long)vb), \
+ "S" ((long)v) ); \
+} while (0)
+#else
+#define COPY_DWORDS( j, vb, vertsize, v ) \
+do { \
+ for ( j = 0 ; j < vertsize ; j++ ) \
+ vb[j] = ((GLuint *)v)[j]; \
+ vb += vertsize; \
+} while (0)
+#endif
+
+static void __inline__ i830_draw_triangle( i830ContextPtr imesa,
+ i830VertexPtr v0,
+ i830VertexPtr v1,
+ i830VertexPtr v2 )
+{
+ GLuint vertsize = imesa->vertex_size;
+ GLuint *vb = i830AllocDmaLow( imesa, 3 * 4 * vertsize );
+ int j;
+
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v2 );
+}
+
+
+static void __inline__ i830_draw_quad( i830ContextPtr imesa,
+ i830VertexPtr v0,
+ i830VertexPtr v1,
+ i830VertexPtr v2,
+ i830VertexPtr v3 )
+{
+ GLuint vertsize = imesa->vertex_size;
+ GLuint *vb = i830AllocDmaLow( imesa, 6 * 4 * vertsize );
+ int j;
+
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v3 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v2 );
+ COPY_DWORDS( j, vb, vertsize, v3 );
+}
+
+
+static __inline__ void i830_draw_point( i830ContextPtr imesa,
+ i830VertexPtr tmp )
+{
+ GLuint vertsize = imesa->vertex_size;
+ GLuint *vb = i830AllocDmaLow( imesa, 4 * vertsize );
+ int j;
+
+ /* Adjust for sub pixel position */
+ *(float *)&vb[0] = tmp->v.x - 0.125;
+ *(float *)&vb[1] = tmp->v.y - 0.125;
+ for (j = 2 ; j < vertsize ; j++)
+ vb[j] = tmp->ui[j];
+}
+
+
+static __inline__ void i830_draw_line( i830ContextPtr imesa,
+ i830VertexPtr v0,
+ i830VertexPtr v1 )
+{
+ GLuint vertsize = imesa->vertex_size;
+ GLuint *vb = i830AllocDmaLow( imesa, 2 * 4 * vertsize );
+ int j;
+
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+}
+
+
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ if (DO_FALLBACK) \
+ imesa->draw_tri( imesa, a, b, c ); \
+ else \
+ i830_draw_triangle( imesa, a, b, c ); \
+} while (0)
+
+#define QUAD( a, b, c, d ) \
+do { \
+ if (DO_FALLBACK) { \
+ imesa->draw_tri( imesa, a, b, d ); \
+ imesa->draw_tri( imesa, b, c, d ); \
+ } else \
+ i830_draw_quad( imesa, a, b, c, d ); \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ if (DO_FALLBACK) \
+ imesa->draw_line( imesa, v0, v1 ); \
+ else \
+ i830_draw_line( imesa, v0, v1 ); \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ if (DO_FALLBACK) \
+ imesa->draw_point( imesa, v0 ); \
+ else \
+ i830_draw_point( imesa, v0 ); \
+} while (0)
+
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define I830_OFFSET_BIT 0x01
+#define I830_TWOSIDE_BIT 0x02
+#define I830_UNFILLED_BIT 0x04
+#define I830_FALLBACK_BIT 0x08
+#define I830_MAX_TRIFUNC 0x10
+
+
+static struct {
+ tnl_points_func points;
+ tnl_line_func line;
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
+} rast_tab[I830_MAX_TRIFUNC];
+
+
+#define DO_FALLBACK (IND & I830_FALLBACK_BIT)
+#define DO_OFFSET (IND & I830_OFFSET_BIT)
+#define DO_UNFILLED (IND & I830_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & I830_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 1
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX i830Vertex
+#define TAB rast_tab
+
+#define DEPTH_SCALE (imesa->depth_scale)
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a > 0)
+#define GET_VERTEX(e) (imesa->verts + (e * imesa->vertex_size * sizeof(int)))
+
+#define VERT_SET_RGBA( v, c ) \
+do { \
+ i830_color_t *color = (i830_color_t *)&((v)->ui[coloroffset]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \
+} while (0)
+
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+
+#define VERT_SET_SPEC( v0, c ) \
+do { \
+ if (havespec) { \
+ UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.blue, (c)[2]); \
+ } \
+} while (0)
+#define VERT_COPY_SPEC( v0, v1 ) \
+do { \
+ if (havespec) { \
+ v0->v.specular.red = v1->v.specular.red; \
+ v0->v.specular.green = v1->v.specular.green; \
+ v0->v.specular.blue = v1->v.specular.blue; \
+ } \
+} while (0)
+
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
+#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[5]
+#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx]
+
+#define LOCAL_VARS(n) \
+ i830ContextPtr imesa = I830_CONTEXT(ctx); \
+ GLuint color[n], spec[n]; \
+ GLuint coloroffset = (imesa->vertex_size == 4 ? 3 : 4); \
+ GLboolean havespec = (imesa->vertex_size > 4); \
+ (void) color; (void) spec; (void) coloroffset; (void) havespec;
+
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ PRIM3D_POINTLIST,
+ PRIM3D_LINELIST,
+ PRIM3D_LINELIST,
+ PRIM3D_LINELIST,
+ PRIM3D_TRILIST,
+ PRIM3D_TRILIST,
+ PRIM3D_TRILIST,
+ PRIM3D_TRILIST,
+ PRIM3D_TRILIST,
+ PRIM3D_TRILIST
+};
+
+#define RASTERIZE(x) if (imesa->hw_primitive != hw_prim[x]) \
+ i830RasterPrimitive( ctx, x, hw_prim[x] )
+#define RENDER_PRIMITIVE imesa->render_primitive
+#define TAG(x) x
+#define IND I830_FALLBACK_BIT
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I830_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I830_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I830_TWOSIDE_BIT|I830_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I830_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I830_OFFSET_BIT|I830_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I830_TWOSIDE_BIT|I830_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I830_TWOSIDE_BIT|I830_OFFSET_BIT|I830_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I830_FALLBACK_BIT)
+#define TAG(x) x##_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I830_OFFSET_BIT|I830_FALLBACK_BIT)
+#define TAG(x) x##_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I830_TWOSIDE_BIT|I830_FALLBACK_BIT)
+#define TAG(x) x##_twoside_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I830_TWOSIDE_BIT|I830_OFFSET_BIT|I830_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I830_UNFILLED_BIT|I830_FALLBACK_BIT)
+#define TAG(x) x##_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I830_OFFSET_BIT|I830_UNFILLED_BIT|I830_FALLBACK_BIT)
+#define TAG(x) x##_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I830_TWOSIDE_BIT|I830_UNFILLED_BIT|I830_FALLBACK_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (I830_TWOSIDE_BIT|I830_OFFSET_BIT|I830_UNFILLED_BIT| \
+ I830_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+static void init_rast_tab( void )
+{
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+ init_fallback();
+ init_offset_fallback();
+ init_twoside_fallback();
+ init_twoside_offset_fallback();
+ init_unfilled_fallback();
+ init_offset_unfilled_fallback();
+ init_twoside_unfilled_fallback();
+ init_twoside_offset_unfilled_fallback();
+}
+
+
+/***********************************************************************
+ * Rasterization fallback helpers *
+ ***********************************************************************/
+
+
+/* This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+static void
+i830_fallback_tri( i830ContextPtr imesa,
+ i830Vertex *v0,
+ i830Vertex *v1,
+ i830Vertex *v2 )
+{
+ GLcontext *ctx = imesa->glCtx;
+ SWvertex v[3];
+
+ if (0)
+ fprintf(stderr, "\n%s\n", __FUNCTION__);
+
+ _swsetup_Translate( ctx, v0, &v[0] );
+ _swsetup_Translate( ctx, v1, &v[1] );
+ _swsetup_Translate( ctx, v2, &v[2] );
+ i830SpanRenderStart( ctx );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+ i830SpanRenderFinish( ctx );
+}
+
+
+static void
+i830_fallback_line( i830ContextPtr imesa,
+ i830Vertex *v0,
+ i830Vertex *v1 )
+{
+ GLcontext *ctx = imesa->glCtx;
+ SWvertex v[2];
+
+ if (0)
+ fprintf(stderr, "\n%s\n", __FUNCTION__);
+
+ _swsetup_Translate( ctx, v0, &v[0] );
+ _swsetup_Translate( ctx, v1, &v[1] );
+ i830SpanRenderStart( ctx );
+ _swrast_Line( ctx, &v[0], &v[1] );
+ i830SpanRenderFinish( ctx );
+}
+
+
+static void
+i830_fallback_point( i830ContextPtr imesa,
+ i830Vertex *v0 )
+{
+ GLcontext *ctx = imesa->glCtx;
+ SWvertex v[1];
+
+ if (0)
+ fprintf(stderr, "\n%s\n", __FUNCTION__);
+
+ _swsetup_Translate( ctx, v0, &v[0] );
+ i830SpanRenderStart( ctx );
+ _swrast_Point( ctx, &v[0] );
+ i830SpanRenderFinish( ctx );
+}
+
+
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+#define IND 0
+#define V(x) (i830Vertex *)(vertptr + ((x) * vertsize * sizeof(int)))
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) POINT( V(ELT(start)) );
+#define RENDER_LINE( v0, v1 ) LINE( V(v0), V(v1) )
+#define RENDER_TRI( v0, v1, v2 ) TRI( V(v0), V(v1), V(v2) )
+#define RENDER_QUAD( v0, v1, v2, v3 ) QUAD( V(v0), V(v1), V(v2), V(v3) )
+#define INIT(x) i830RenderPrimitive( ctx, x )
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ i830ContextPtr imesa = I830_CONTEXT(ctx); \
+ GLubyte *vertptr = (GLubyte *)imesa->verts; \
+ const GLuint vertsize = imesa->vertex_size; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ (void) elt;
+#define RESET_STIPPLE
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) x
+#define TAG(x) i830_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+#undef ELT
+#undef TAG
+#define TAG(x) i830_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl/t_vb_rendertmp.h"
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+
+
+static void i830RenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLuint prim = imesa->render_primitive;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n,
+ PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+ }
+
+ /* Restore the render primitive
+ */
+ if (prim != GL_POLYGON)
+ tnl->Driver.Render.PrimitiveNotify( ctx, prim );
+}
+
+static void i830RenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ tnl->Driver.Render.Line( ctx, ii, jj );
+}
+
+static void i830FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ i830ContextPtr imesa = I830_CONTEXT( ctx );
+ GLuint vertsize = imesa->vertex_size;
+ GLuint *vb = i830AllocDmaLow( imesa, (n-2) * 3 * 4 * vertsize );
+ GLubyte *vertptr = (GLubyte *)imesa->verts;
+ const GLuint *start = (const GLuint *)V(elts[0]);
+ int i,j;
+
+ for (i = 2 ; i < n ; i++) {
+ COPY_DWORDS( j, vb, vertsize, V(elts[i-1]) );
+ COPY_DWORDS( j, vb, vertsize, V(elts[i]) );
+ COPY_DWORDS( j, vb, vertsize, start );
+ }
+}
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+
+
+#define _I830_NEW_RENDERSTATE (_DD_NEW_LINE_STIPPLE | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET | \
+ _DD_NEW_TRI_STIPPLE | \
+ _NEW_POLYGONSTIPPLE)
+
+#define POINT_FALLBACK (0)
+#define LINE_FALLBACK (DD_LINE_STIPPLE)
+#define TRI_FALLBACK (0)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK|\
+ DD_TRI_STIPPLE)
+#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
+
+static void i830ChooseRenderState(GLcontext *ctx)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ if (I830_DEBUG & DEBUG_STATE)
+ fprintf(stderr,"\n%s\n",__FUNCTION__);
+
+ if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) {
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= I830_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= I830_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= I830_UNFILLED_BIT;
+ }
+
+ imesa->draw_point = i830_draw_point;
+ imesa->draw_line = i830_draw_line;
+ imesa->draw_tri = i830_draw_triangle;
+
+ /* Hook in fallbacks for specific primitives.
+ */
+ if (flags & ANY_FALLBACK_FLAGS)
+ {
+ if (flags & POINT_FALLBACK)
+ imesa->draw_point = i830_fallback_point;
+
+ if (flags & LINE_FALLBACK)
+ imesa->draw_line = i830_fallback_line;
+
+ if (flags & TRI_FALLBACK)
+ imesa->draw_tri = i830_fallback_tri;
+
+ if ((flags & DD_TRI_STIPPLE) && !imesa->hw_stipple) {
+ imesa->draw_tri = i830_fallback_tri;
+ }
+
+ index |= I830_FALLBACK_BIT;
+ }
+ }
+
+ if (imesa->RenderIndex != index) {
+ imesa->RenderIndex = index;
+
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = i830_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = i830_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */
+ tnl->Driver.Render.ClippedPolygon = i830FastRenderClippedPoly;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = i830RenderClippedLine;
+ tnl->Driver.Render.ClippedPolygon = i830RenderClippedPoly;
+ }
+ }
+}
+
+static const GLenum reduced_prim[GL_POLYGON+1] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES
+};
+
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+
+
+/* Determine the rasterized primitive when not drawing unfilled
+ * polygons.
+ *
+ * Used only for the default render stage which always decomposes
+ * primitives to trianges/lines/points. For the accelerated stage,
+ * which renders strips as strips, the equivalent calculations are
+ * performed in i810render.c.
+ */
+static void i830RenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ GLuint rprim = reduced_prim[prim];
+
+ imesa->render_primitive = prim;
+
+ if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ return;
+
+ if (imesa->reduced_primitive != rprim ||
+ hw_prim[prim] != imesa->hw_primitive) {
+ i830RasterPrimitive( ctx, rprim, hw_prim[prim] );
+ }
+}
+
+static void i830RunPipeline( GLcontext *ctx )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+
+ if (imesa->NewGLState) {
+ if (imesa->NewGLState & _NEW_TEXTURE) {
+ I830_FIREVERTICES( imesa );
+ i830UpdateTextureState( ctx ); /* may modify imesa->NewGLState */
+ }
+
+ if (!imesa->Fallback) {
+ if (imesa->NewGLState & _I830_NEW_RENDERSTATE)
+ i830ChooseRenderState( ctx );
+ }
+
+ imesa->NewGLState = 0;
+ }
+
+ _tnl_run_pipeline( ctx );
+}
+
+
+#define TEXCOORDTYPE_MASK (3<<11)
+
+
+
+static void set_projective_texturing( i830ContextPtr imesa,
+ GLuint i,
+ GLuint mcs)
+{
+ mcs |= (imesa->CurrentTexObj[i]->Setup[I830_TEXREG_MCS] &
+ ~TEXCOORDTYPE_MASK);
+
+ if (mcs != imesa->CurrentTexObj[i]->Setup[I830_TEXREG_MCS]) {
+ I830_STATECHANGE(imesa, I830_UPLOAD_TEX_N(i));
+ imesa->CurrentTexObj[i]->Setup[I830_TEXREG_MCS] = mcs;
+ }
+}
+
+
+#define SZ_TO_HW(sz) ((sz-2)&0x3)
+#define EMIT_SZ(sz) (EMIT_1F + (sz) - 1)
+#define EMIT_ATTR( ATTR, STYLE, V0 ) \
+do { \
+ imesa->vertex_attrs[imesa->vertex_attr_count].attrib = (ATTR); \
+ imesa->vertex_attrs[imesa->vertex_attr_count].format = (STYLE); \
+ imesa->vertex_attr_count++; \
+ v0 |= V0; \
+} while (0)
+
+#define EMIT_PAD( N ) \
+do { \
+ imesa->vertex_attrs[imesa->vertex_attr_count].attrib = 0; \
+ imesa->vertex_attrs[imesa->vertex_attr_count].format = EMIT_PAD; \
+ imesa->vertex_attrs[imesa->vertex_attr_count].offset = (N); \
+ imesa->vertex_attr_count++; \
+} while (0)
+
+#define VRTX_TEX_SET_FMT(n, x) ((x)<<((n)*2))
+
+/* Make sure hardware vertex format is appropriate for VB state.
+ */
+static void i830RenderStart( GLcontext *ctx )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint index = tnl->render_inputs;
+ GLuint v0 = STATE3D_VERTEX_FORMAT_CMD;
+ GLuint v2 = STATE3D_VERTEX_FORMAT_2_CMD;
+ GLuint force_emit = 0;
+
+ /* Important:
+ */
+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
+ imesa->vertex_attr_count = 0;
+
+ /* EMIT_ATTR's must be in order as they tell t_vertex.c how to
+ * build up a hardware vertex.
+ */
+ if (index & _TNL_BITS_TEX_ANY) {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, VRTX_HAS_XYZW );
+ }
+ else {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, VRTX_HAS_XYZ );
+ }
+
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, VRTX_HAS_DIFFUSE );
+
+ if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) {
+
+ if (index & _TNL_BIT_COLOR1)
+ {
+ if (imesa->vertex_attrs[imesa->vertex_attr_count].format != EMIT_3UB_3F_BGR)
+ force_emit=1;
+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, VRTX_HAS_SPEC );
+ }
+ else
+ {
+ if (imesa->vertex_attrs[imesa->vertex_attr_count].format != EMIT_PAD)
+ force_emit=1;
+ EMIT_PAD( 3 );
+ }
+ if (index & _TNL_BIT_FOG)
+ {
+ if (imesa->vertex_attrs[imesa->vertex_attr_count].format != EMIT_1UB_1F)
+ force_emit=1;
+ EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, VRTX_HAS_SPEC );
+ }
+ else
+ {
+ if (imesa->vertex_attrs[imesa->vertex_attr_count].format != EMIT_PAD)
+ force_emit=1;
+ EMIT_PAD( 1 );
+ }
+ }
+
+ if (index & _TNL_BITS_TEX_ANY) {
+ int i, last_stage = 0;
+
+ for (i = 0; i < ctx->Const.MaxTextureUnits ; i++)
+ if (index & _TNL_BIT_TEX(i))
+ last_stage = i+1;
+
+
+ for (i = 0; i < last_stage; i++) {
+ GLuint sz = VB->TexCoordPtr[i]->size;
+ GLuint emit;
+ GLuint mcs;
+
+ /* i830 doesn't like 1D or 4D texcoords:
+ */
+ switch (sz) {
+ case 1:
+ case 2:
+ case 3: /* no attempt at cube texturing so far */
+ emit = EMIT_2F;
+ sz = 2;
+ mcs = TEXCOORDTYPE_CARTESIAN;
+ break;
+ case 4:
+ emit = EMIT_3F_XYW;
+ sz = 3;
+ mcs = TEXCOORDTYPE_HOMOGENEOUS;
+ break;
+ default:
+ continue;
+ };
+
+ v2 |= VRTX_TEX_SET_FMT(i, SZ_TO_HW(sz));
+ EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_SZ(sz), 0 );
+
+ if (imesa->CurrentTexObj[i])
+ set_projective_texturing( imesa, i, mcs );
+ }
+
+ v0 |= VRTX_TEX_COORD_COUNT(last_stage);
+ }
+
+ /* Only need to change the vertex emit code if there has been a
+ * statechange to a new hardware vertex format:
+ */
+ if (v0 != imesa->Setup[I830_CTXREG_VF] ||
+ v2 != imesa->Setup[I830_CTXREG_VF2] ||
+ force_emit == 1) {
+
+ I830_STATECHANGE( imesa, I830_UPLOAD_CTX );
+
+ /* Must do this *after* statechange, so as not to affect
+ * buffered vertices reliant on the old state:
+ */
+ imesa->vertex_size =
+ _tnl_install_attrs( ctx,
+ imesa->vertex_attrs,
+ imesa->vertex_attr_count,
+ imesa->ViewportMatrix.m, 0 );
+
+ imesa->vertex_size >>= 2;
+
+ imesa->Setup[I830_CTXREG_VF] = v0;
+ imesa->Setup[I830_CTXREG_VF2] = v2;
+ }
+}
+
+
+static void i830RenderFinish( GLcontext *ctx )
+{
+ if (I830_CONTEXT(ctx)->RenderIndex & I830_FALLBACK_BIT)
+ _swrast_flush( ctx );
+}
+
+
+
+
+/* System to flush dma and emit state changes based on the rasterized
+ * primitive.
+ */
+void i830RasterPrimitive( GLcontext *ctx,
+ GLenum rprim,
+ GLuint hwprim )
+{
+ i830ContextPtr imesa = I830_CONTEXT(ctx);
+ GLuint aa = imesa->Setup[I830_CTXREG_AA];
+ GLuint st1 = imesa->StippleSetup[I830_STPREG_ST1];
+
+ aa &= ~AA_LINE_ENABLE;
+
+ if (I830_DEBUG & DEBUG_PRIMS) {
+ /* Prints reduced prim, and hw prim */
+ char *prim_name = "Unknown";
+
+ switch(hwprim) {
+ case PRIM3D_POINTLIST:
+ prim_name = "PointList";
+ break;
+ case PRIM3D_LINELIST:
+ prim_name = "LineList";
+ break;
+ case PRIM3D_LINESTRIP:
+ prim_name = "LineStrip";
+ break;
+ case PRIM3D_TRILIST:
+ prim_name = "TriList";
+ break;
+ case PRIM3D_TRISTRIP:
+ prim_name = "TriStrip";
+ break;
+ case PRIM3D_TRIFAN:
+ prim_name = "TriFan";
+ break;
+ case PRIM3D_POLY:
+ prim_name = "Polygons";
+ break;
+ default:
+ break;
+ }
+
+ fprintf(stderr, "%s : rprim(%s), hwprim(%s)\n",
+ __FUNCTION__,
+ _mesa_lookup_enum_by_nr(rprim),
+ prim_name);
+ }
+
+ switch (rprim) {
+ case GL_TRIANGLES:
+ aa |= AA_LINE_DISABLE;
+ if (ctx->Polygon.StippleFlag)
+ st1 |= ST1_ENABLE;
+ else
+ st1 &= ~ST1_ENABLE;
+ break;
+ case GL_LINES:
+ st1 &= ~ST1_ENABLE;
+ if (ctx->Line.SmoothFlag) {
+ aa |= AA_LINE_ENABLE;
+ } else {
+ aa |= AA_LINE_DISABLE;
+ }
+ break;
+ case GL_POINTS:
+ st1 &= ~ST1_ENABLE;
+ aa |= AA_LINE_DISABLE;
+ break;
+ default:
+ return;
+ }
+
+ imesa->reduced_primitive = rprim;
+
+ if (aa != imesa->Setup[I830_CTXREG_AA]) {
+ I830_STATECHANGE(imesa, I830_UPLOAD_CTX);
+ imesa->Setup[I830_CTXREG_AA] = aa;
+ }
+
+#if 0
+ if (st1 != imesa->StippleSetup[I830_STPREG_ST1]) {
+ I830_STATECHANGE(imesa, I830_UPLOAD_STIPPLE);
+ imesa->StippleSetup[I830_STPREG_ST1] = st1;
+ }
+#endif
+
+ if (hwprim != imesa->hw_primitive) {
+ I830_STATECHANGE(imesa, 0);
+ imesa->hw_primitive = hwprim;
+ }
+}
+
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+
+static char *fallbackStrings[] = {
+ "Texture",
+ "Draw buffer",
+ "Read buffer",
+ "Color mask",
+ "Render mode",
+ "Stencil",
+ "Stipple",
+ "User disable"
+};
+
+
+static char *getFallbackString(GLuint bit)
+{
+ int i = 0;
+ while (bit > 1) {
+ i++;
+ bit >>= 1;
+ }
+ return fallbackStrings[i];
+}
+
+
+
+void i830Fallback( i830ContextPtr imesa, GLuint bit, GLboolean mode )
+{
+ GLcontext *ctx = imesa->glCtx;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldfallback = imesa->Fallback;
+
+ if (mode) {
+ imesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ I830_FIREVERTICES(imesa);
+ if (I830_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "ENTER FALLBACK %s\n", getFallbackString( bit ));
+ _swsetup_Wakeup( ctx );
+ imesa->RenderIndex = ~0;
+ }
+ }
+ else {
+ imesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ _swrast_flush( ctx );
+ if (I830_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "LEAVE FALLBACK %s\n", getFallbackString( bit ));
+ tnl->Driver.Render.Start = i830RenderStart;
+ tnl->Driver.Render.PrimitiveNotify = i830RenderPrimitive;
+ tnl->Driver.Render.Finish = i830RenderFinish;
+
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+
+ _tnl_invalidate_vertex_state( ctx, ~0 );
+ _tnl_invalidate_vertices( ctx, ~0 );
+ _tnl_install_attrs( ctx,
+ imesa->vertex_attrs,
+ imesa->vertex_attr_count,
+ imesa->ViewportMatrix.m, 0 );
+
+ imesa->NewGLState |= _I830_NEW_RENDERSTATE;
+ }
+ }
+}
+
+
+
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+/**
+ * \bug
+ * How are the magic numbers 12 and 26 in the call to \c _tnl_init_vertices
+ * derived?
+ */
+void i830InitTriFuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+ }
+
+ tnl->Driver.RunPipeline = i830RunPipeline;
+ tnl->Driver.Render.Start = i830RenderStart;
+ tnl->Driver.Render.Finish = i830RenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = i830RenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+
+ _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
+ 26 * sizeof(GLfloat) );
+
+ I830_CONTEXT(ctx)->verts = (char *)tnl->clipspace.vertex_buf;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_tris.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_tris.h
new file mode 100644
index 000000000..ae4f0a5df
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/i830_tris.h
@@ -0,0 +1,37 @@
+/*
+ * GLX Hardware Device Driver for Intel i810
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * 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
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ * Adapted for use in the I830M:
+ * Jeff Hartmann <jhartmann@2d3d.com>
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/i830/i830_tris.h,v 1.3 2002/09/09 19:18:48 dawes Exp $ */
+
+#ifndef I830TRIS_INC
+#define I830TRIS_INC
+
+#include "mtypes.h"
+
+extern void i830PrintRenderState( const char *msg, GLuint state );
+extern void i830InitTriFuncs( GLcontext *ctx );
+extern void i830RasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/server/i830_common.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/server/i830_common.h
new file mode 100644
index 000000000..3367bfc16
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/server/i830_common.h
@@ -0,0 +1,288 @@
+/**************************************************************************
+
+Copyright 2001 VA Linux Systems Inc., Fremont, California.
+Copyright 2002 Tungsten Graphics 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, VA LINUX SYSTEMS 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.
+
+**************************************************************************/
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_common.h,v 1.2 2002/12/10 01:27:05 dawes Exp $ */
+
+/* Author: Jeff Hartmann <jhartmann@valinux.com>
+
+ Converted to common header format:
+ Jens Owen <jens@tungstengraphics.com>
+ */
+
+#ifndef _I830_COMMON_H_
+#define _I830_COMMON_H_
+
+/* WARNING: These defines must be the same as what the Xserver uses.
+ * if you change them, you must change the defines in the Xserver.
+ */
+
+#ifndef _I830_DEFINES_
+#define _I830_DEFINES_
+
+#define I830_DMA_BUF_ORDER 12
+#define I830_DMA_BUF_SZ (1<<I830_DMA_BUF_ORDER)
+#define I830_DMA_BUF_NR 256
+#define I830_NR_SAREA_CLIPRECTS 8
+
+/* Each region is a minimum of 64k, and there are at most 64 of them.
+ */
+#define I830_NR_TEX_REGIONS 64
+#define I830_LOG_MIN_TEX_REGION_SIZE 16
+
+/* if defining I830_ENABLE_4_TEXTURES, do it in i830_3d_reg.h, too */
+#if !defined(I830_ENABLE_4_TEXTURES)
+#define I830_TEXTURE_COUNT 2
+#define I830_TEXBLEND_COUNT 2 /* always same as TEXTURE_COUNT? */
+#else /* defined(I830_ENABLE_4_TEXTURES) */
+#define I830_TEXTURE_COUNT 4
+#define I830_TEXBLEND_COUNT 4 /* always same as TEXTURE_COUNT? */
+#endif /* I830_ENABLE_4_TEXTURES */
+
+#define I830_TEXBLEND_SIZE 12 /* (4 args + op) * 2 + COLOR_FACTOR */
+
+#define I830_UPLOAD_CTX 0x1
+#define I830_UPLOAD_BUFFERS 0x2
+#define I830_UPLOAD_CLIPRECTS 0x4
+#define I830_UPLOAD_TEX0_IMAGE 0x100 /* handled clientside */
+#define I830_UPLOAD_TEX0_CUBE 0x200 /* handled clientside */
+#define I830_UPLOAD_TEX1_IMAGE 0x400 /* handled clientside */
+#define I830_UPLOAD_TEX1_CUBE 0x800 /* handled clientside */
+#define I830_UPLOAD_TEX2_IMAGE 0x1000 /* handled clientside */
+#define I830_UPLOAD_TEX2_CUBE 0x2000 /* handled clientside */
+#define I830_UPLOAD_TEX3_IMAGE 0x4000 /* handled clientside */
+#define I830_UPLOAD_TEX3_CUBE 0x8000 /* handled clientside */
+#define I830_UPLOAD_TEX_N_IMAGE(n) (0x100 << (n * 2))
+#define I830_UPLOAD_TEX_N_CUBE(n) (0x200 << (n * 2))
+#define I830_UPLOAD_TEXIMAGE_MASK 0xff00
+#define I830_UPLOAD_TEX0 0x10000
+#define I830_UPLOAD_TEX1 0x20000
+#define I830_UPLOAD_TEX2 0x40000
+#define I830_UPLOAD_TEX3 0x80000
+#define I830_UPLOAD_TEX_N(n) (0x10000 << (n))
+#define I830_UPLOAD_TEX_MASK 0xf0000
+#define I830_UPLOAD_TEXBLEND0 0x100000
+#define I830_UPLOAD_TEXBLEND1 0x200000
+#define I830_UPLOAD_TEXBLEND2 0x400000
+#define I830_UPLOAD_TEXBLEND3 0x800000
+#define I830_UPLOAD_TEXBLEND_N(n) (0x100000 << (n))
+#define I830_UPLOAD_TEXBLEND_MASK 0xf00000
+#define I830_UPLOAD_TEX_PALETTE_N(n) (0x1000000 << (n))
+#define I830_UPLOAD_TEX_PALETTE_SHARED 0x4000000
+#define I830_UPLOAD_STIPPLE 0x8000000
+
+/* Indices into buf.Setup where various bits of state are mirrored per
+ * context and per buffer. These can be fired at the card as a unit,
+ * or in a piecewise fashion as required.
+ */
+
+/* Destbuffer state
+ * - backbuffer linear offset and pitch -- invarient in the current dri
+ * - zbuffer linear offset and pitch -- also invarient
+ * - drawing origin in back and depth buffers.
+ *
+ * Keep the depth/back buffer state here to acommodate private buffers
+ * in the future.
+ */
+
+#define I830_DESTREG_CBUFADDR 0
+/* Invarient */
+#define I830_DESTREG_DBUFADDR 1
+#define I830_DESTREG_DV0 2
+#define I830_DESTREG_DV1 3
+#define I830_DESTREG_SENABLE 4
+#define I830_DESTREG_SR0 5
+#define I830_DESTREG_SR1 6
+#define I830_DESTREG_SR2 7
+#define I830_DESTREG_DR0 8
+#define I830_DESTREG_DR1 9
+#define I830_DESTREG_DR2 10
+#define I830_DESTREG_DR3 11
+#define I830_DESTREG_DR4 12
+#define I830_DEST_SETUP_SIZE 13
+
+/* Context state
+ */
+#define I830_CTXREG_STATE1 0
+#define I830_CTXREG_STATE2 1
+#define I830_CTXREG_STATE3 2
+#define I830_CTXREG_STATE4 3
+#define I830_CTXREG_STATE5 4
+#define I830_CTXREG_IALPHAB 5
+#define I830_CTXREG_STENCILTST 6
+#define I830_CTXREG_ENABLES_1 7
+#define I830_CTXREG_ENABLES_2 8
+#define I830_CTXREG_AA 9
+#define I830_CTXREG_FOGCOLOR 10
+#define I830_CTXREG_BLENDCOLR0 11
+#define I830_CTXREG_BLENDCOLR 12 /* Dword 1 of 2 dword command */
+#define I830_CTXREG_VF 13
+#define I830_CTXREG_VF2 14
+#define I830_CTXREG_MCSB0 15
+#define I830_CTXREG_MCSB1 16
+#define I830_CTX_SETUP_SIZE 17
+
+/* 1.3: Stipple state
+ */
+#define I830_STPREG_ST0 0
+#define I830_STPREG_ST1 1
+#define I830_STP_SETUP_SIZE 2
+
+/* Texture state (per tex unit)
+ */
+#define I830_TEXREG_MI0 0 /* GFX_OP_MAP_INFO (6 dwords) */
+#define I830_TEXREG_MI1 1
+#define I830_TEXREG_MI2 2
+#define I830_TEXREG_MI3 3
+#define I830_TEXREG_MI4 4
+#define I830_TEXREG_MI5 5
+#define I830_TEXREG_MF 6 /* GFX_OP_MAP_FILTER */
+#define I830_TEXREG_MLC 7 /* GFX_OP_MAP_LOD_CTL */
+#define I830_TEXREG_MLL 8 /* GFX_OP_MAP_LOD_LIMITS */
+#define I830_TEXREG_MCS 9 /* GFX_OP_MAP_COORD_SETS */
+#define I830_TEX_SETUP_SIZE 10
+
+/* New version. Kernel auto-detects.
+ */
+#define I830_TEXREG_TM0LI 0 /* load immediate 2 texture map n */
+#define I830_TEXREG_TM0S0 1
+#define I830_TEXREG_TM0S1 2
+#define I830_TEXREG_TM0S2 3
+#define I830_TEXREG_TM0S3 4
+#define I830_TEXREG_TM0S4 5
+#define I830_TEXREG_NOP0 6 /* noop */
+#define I830_TEXREG_NOP1 7 /* noop */
+#define I830_TEXREG_NOP2 8 /* noop */
+#define __I830_TEXREG_MCS 9 /* GFX_OP_MAP_COORD_SETS -- shared */
+#define __I830_TEX_SETUP_SIZE 10
+
+
+#define I830_FRONT 0x1
+#define I830_BACK 0x2
+#define I830_DEPTH 0x4
+
+/* Driver specific DRM command indices
+ * NOTE: these are not OS specific, but they are driver specific
+ */
+#define DRM_I830_INIT 0x00
+#define DRM_I830_VERTEX 0x01
+#define DRM_I830_CLEAR 0x02
+#define DRM_I830_FLUSH 0x03
+#define DRM_I830_GETAGE 0x04
+#define DRM_I830_GETBUF 0x05
+#define DRM_I830_SWAP 0x06
+#define DRM_I830_COPY 0x07
+#define DRM_I830_DOCOPY 0x08
+#define DRM_I830_FLIP 0x09
+#define DRM_I830_IRQ_EMIT 0x0a
+#define DRM_I830_IRQ_WAIT 0x0b
+#define DRM_I830_GETPARAM 0x0c
+#define DRM_I830_SETPARAM 0x0d
+
+#endif /* _I830_DEFINES_ */
+
+typedef struct {
+ enum {
+ I830_INIT_DMA = 0x01,
+ I830_CLEANUP_DMA = 0x02
+ } func;
+ unsigned int mmio_offset;
+ unsigned int buffers_offset;
+ int sarea_priv_offset;
+ unsigned int ring_start;
+ unsigned int ring_end;
+ unsigned int ring_size;
+ unsigned int front_offset;
+ unsigned int back_offset;
+ unsigned int depth_offset;
+ unsigned int w;
+ unsigned int h;
+ unsigned int pitch;
+ unsigned int pitch_bits;
+ unsigned int back_pitch;
+ unsigned int depth_pitch;
+ unsigned int cpp;
+} drmI830Init;
+
+typedef struct {
+ int clear_color;
+ int clear_depth;
+ int flags;
+ unsigned int clear_colormask;
+ unsigned int clear_depthmask;
+} drmI830Clear;
+
+/* These may be placeholders if we have more cliprects than
+ * I830_NR_SAREA_CLIPRECTS. In that case, the client sets discard to
+ * false, indicating that the buffer will be dispatched again with a
+ * new set of cliprects.
+ */
+typedef struct {
+ int idx; /* buffer index */
+ int used; /* nr bytes in use */
+ int discard; /* client is finished with the buffer? */
+} drmI830Vertex;
+
+typedef struct {
+ int idx; /* buffer index */
+ int used; /* nr bytes in use */
+ void *address; /* Address to copy from */
+} drmI830Copy;
+
+typedef struct {
+ void *virtual;
+ int request_idx;
+ int request_size;
+ int granted;
+} drmI830DMA;
+
+typedef struct drm_i830_irq_emit {
+ int *irq_seq;
+} drmI830IrqEmit;
+
+typedef struct drm_i830_irq_wait {
+ int irq_seq;
+} drmI830IrqWait;
+
+typedef struct drm_i830_getparam {
+ int param;
+ int *value;
+} drmI830GetParam;
+
+#define I830_PARAM_IRQ_ACTIVE 1
+
+
+typedef struct drm_i830_setparam {
+ int param;
+ int value;
+} drmI830SetParam;
+
+#define I830_SETPARAM_USE_MI_BATCHBUFFER_START 1
+
+
+
+#endif /* _I830_DRM_H_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/server/i830_dri.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/server/i830_dri.h
new file mode 100644
index 000000000..e4b36cc16
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i830/server/i830_dri.h
@@ -0,0 +1,140 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_dri.h,v 1.5 2002/12/10 01:27:05 dawes Exp $ */
+
+#ifndef _I830_DRI_H
+#define _I830_DRI_H
+
+#include "drm.h" /* HACK!!! why doesn't xf86drm.h work??? */
+/* #include "xf86drm.h" */
+#include "i830_common.h"
+
+#define I830_MAX_DRAWABLES 256
+
+#define I830_MAJOR_VERSION 1
+#define I830_MINOR_VERSION 3
+#define I830_PATCHLEVEL 0
+
+#define I830_REG_SIZE 0x80000
+
+typedef struct _I830DRIRec {
+ drm_handle_t regs;
+ drmSize regsSize;
+
+ drmSize backbufferSize;
+ drm_handle_t backbuffer;
+
+ drmSize depthbufferSize;
+ drm_handle_t depthbuffer;
+
+ drm_handle_t textures;
+ int textureSize;
+
+ drm_handle_t agp_buffers;
+ drmSize agp_buf_size;
+
+ int deviceID;
+ int width;
+ int height;
+ int mem;
+ int cpp;
+ int bitsPerPixel;
+ int fbOffset;
+ int fbStride;
+
+ int backOffset;
+ int depthOffset;
+
+ int auxPitch;
+ int auxPitchBits;
+
+ int logTextureGranularity;
+ int textureOffset;
+
+ /* For non-dma direct rendering.
+ */
+ int ringOffset;
+ int ringSize;
+
+ drmBufMapPtr drmBufs;
+ int irq;
+ int sarea_priv_offset;
+} I830DRIRec, *I830DRIPtr;
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} I830ConfigPrivRec, *I830ConfigPrivPtr;
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} I830DRIContextRec, *I830DRIContextPtr;
+
+/* Warning: If you change the SAREA structure you must change the kernel
+ * structure as well */
+
+typedef struct _I830SAREA {
+ unsigned int ContextState[I830_CTX_SETUP_SIZE];
+ unsigned int BufferState[I830_DEST_SETUP_SIZE];
+ unsigned int TexState[I830_TEXTURE_COUNT][I830_TEX_SETUP_SIZE];
+ unsigned int TexBlendState[I830_TEXBLEND_COUNT][I830_TEXBLEND_SIZE];
+ unsigned int TexBlendStateWordsUsed[I830_TEXBLEND_COUNT];
+ unsigned int Palette[2][256];
+ unsigned int dirty;
+
+ unsigned int nbox;
+ drm_clip_rect_t boxes[I830_NR_SAREA_CLIPRECTS];
+
+ /* Maintain an LRU of contiguous regions of texture space. If
+ * you think you own a region of texture memory, and it has an
+ * age different to the one you set, then you are mistaken and
+ * it has been stolen by another client. If global texAge
+ * hasn't changed, there is no need to walk the list.
+ *
+ * These regions can be used as a proxy for the fine-grained
+ * texture information of other clients - by maintaining them
+ * in the same lru which is used to age their own textures,
+ * clients have an approximate lru for the whole of global
+ * texture space, and can make informed decisions as to which
+ * areas to kick out. There is no need to choose whether to
+ * kick out your own texture or someone else's - simply eject
+ * them all in LRU order.
+ */
+
+ drmTextureRegion texList[I830_NR_TEX_REGIONS + 1];
+ /* Last elt is sentinal */
+ int texAge; /* last time texture was uploaded */
+ int last_enqueue; /* last time a buffer was enqueued */
+ int last_dispatch; /* age of the most recently dispatched buffer */
+ int last_quiescent; /* */
+ int ctxOwner; /* last context to upload state */
+
+ int vertex_prim;
+
+ int pf_enabled; /* is pageflipping allowed? */
+ int pf_active; /* is pageflipping active right now? */
+ int pf_current_page; /* which buffer is being displayed? */
+
+ int perf_boxes; /* performance boxes to be displayed */
+
+ /* Here's the state for texunits 2,3:
+ */
+ unsigned int TexState2[I830_TEX_SETUP_SIZE];
+ unsigned int TexBlendState2[I830_TEXBLEND_SIZE];
+ unsigned int TexBlendStateWordsUsed2;
+
+ unsigned int TexState3[I830_TEX_SETUP_SIZE];
+ unsigned int TexBlendState3[I830_TEXBLEND_SIZE];
+ unsigned int TexBlendStateWordsUsed3;
+
+ unsigned int StippleState[I830_STP_SETUP_SIZE];
+} I830SAREARec, *I830SAREAPtr;
+
+/* Flags for perf_boxes
+ */
+#define I830_BOX_RING_EMPTY 0x1 /* populated by kernel */
+#define I830_BOX_FLIP 0x2 /* populated by kernel */
+#define I830_BOX_WAIT 0x4 /* populated by kernel & client */
+#define I830_BOX_TEXTURE_LOAD 0x8 /* populated by kernel */
+#define I830_BOX_LOST_CONTEXT 0x10 /* populated by client */
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/Makefile
new file mode 100644
index 000000000..c269fb129
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/Makefile
@@ -0,0 +1,47 @@
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = i915_dri.so
+
+DRIVER_SOURCES = \
+ i915_context.c \
+ i915_debug.c \
+ i915_fragprog.c \
+ i915_metaops.c \
+ i915_program.c \
+ i915_state.c \
+ i915_tex.c \
+ i915_texprog.c \
+ i915_texstate.c \
+ i915_vtbl.c \
+ i830_context.c \
+ i830_metaops.c \
+ i830_state.c \
+ i830_texblend.c \
+ i830_tex.c \
+ i830_texstate.c \
+ i830_vtbl.c \
+ intel_batchbuffer.c \
+ intel_context.c \
+ intel_ioctl.c \
+ intel_pixel.c \
+ intel_render.c \
+ intel_screen.c \
+ intel_span.c \
+ intel_state.c \
+ intel_tex.c \
+ intel_tris.c
+
+C_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(MINIGLX_SOURCES) \
+ $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+
+
+include ../Makefile.template
+
+symlinks:
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_context.c
new file mode 100644
index 000000000..6088db67e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_context.c
@@ -0,0 +1,122 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include "i830_context.h"
+#include "imports.h"
+#include "texmem.h"
+#include "intel_tex.h"
+#include "tnl/tnl.h"
+#include "tnl/t_vertex.h"
+#include "tnl/t_context.h"
+#include "utils.h"
+
+/***************************************
+ * Mesa's Driver Functions
+ ***************************************/
+
+static const struct dri_extension i830_extensions[] =
+{
+ { "GL_ARB_texture_env_crossbar", NULL },
+ { NULL, NULL }
+};
+
+
+static void i830InitDriverFunctions( struct dd_function_table *functions )
+{
+ intelInitDriverFunctions( functions );
+ i830InitStateFuncs( functions );
+ i830InitTextureFuncs( functions );
+}
+
+
+GLboolean i830CreateContext( const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate)
+{
+ struct dd_function_table functions;
+ i830ContextPtr i830 = (i830ContextPtr) CALLOC_STRUCT(i830_context);
+ intelContextPtr intel = &i830->intel;
+ GLcontext *ctx = &intel->ctx;
+ if (!i830) return GL_FALSE;
+
+ i830InitVtbl( i830 );
+ i830InitDriverFunctions( &functions );
+
+ if (!intelInitContext( intel, mesaVis, driContextPriv,
+ sharedContextPrivate, &functions )) {
+ FREE(i830);
+ return GL_FALSE;
+ }
+
+ intel->ctx.Const.MaxTextureUnits = I830_TEX_UNITS;
+ intel->ctx.Const.MaxTextureImageUnits = I830_TEX_UNITS;
+ intel->ctx.Const.MaxTextureCoordUnits = I830_TEX_UNITS;
+
+ intel->nr_heaps = 1;
+ intel->texture_heaps[0] =
+ driCreateTextureHeap( 0, intel,
+ intel->intelScreen->textureSize,
+ 12,
+ I830_NR_TEX_REGIONS,
+ intel->sarea->texList,
+ & intel->sarea->texAge,
+ & intel->swapped,
+ sizeof( struct i830_texture_object ),
+ (destroy_texture_object_t *)intelDestroyTexObj );
+
+ /* FIXME: driCalculateMaxTextureLevels assumes that mipmaps are tightly
+ * FIXME: packed, but they're not in Intel graphics hardware.
+ */
+ intel->ctx.Const.MaxTextureUnits = 1;
+ driCalculateMaxTextureLevels( intel->texture_heaps,
+ intel->nr_heaps,
+ &intel->ctx.Const,
+ 4,
+ 11, /* max 2D texture size is 2048x2048 */
+ 8, /* max 3D texture size is 256^3 */
+ 10, /* max CUBE texture size is 1024x1024 */
+ 11, /* max RECT. supported */
+ 12,
+ GL_FALSE );
+ intel->ctx.Const.MaxTextureUnits = I830_TEX_UNITS;
+
+ _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
+ 18 * sizeof(GLfloat) );
+
+ intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf;
+
+ driInitExtensions( ctx, i830_extensions, GL_FALSE );
+
+ i830InitState( i830 );
+
+
+ _tnl_allow_vertex_fog( ctx, 1 );
+ _tnl_allow_pixel_fog( ctx, 0 );
+
+ return GL_TRUE;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_context.h
new file mode 100644
index 000000000..62e20d0a0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_context.h
@@ -0,0 +1,215 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#ifndef I830CONTEXT_INC
+#define I830CONTEXT_INC
+
+#include "intel_context.h"
+
+#define I830_FALLBACK_TEXTURE 0x1000
+#define I830_FALLBACK_COLORMASK 0x2000
+#define I830_FALLBACK_STENCIL 0x4000
+#define I830_FALLBACK_STIPPLE 0x8000
+#define I830_FALLBACK_LOGICOP 0x10000
+
+#define I830_UPLOAD_CTX 0x1
+#define I830_UPLOAD_BUFFERS 0x2
+#define I830_UPLOAD_STIPPLE 0x4
+#define I830_UPLOAD_TEX(i) (0x10<<(i))
+#define I830_UPLOAD_TEXBLEND(i) (0x100<<(i))
+#define I830_UPLOAD_TEX_ALL (0x0f0)
+#define I830_UPLOAD_TEXBLEND_ALL (0xf00)
+
+/* State structure offsets - these will probably disappear.
+ */
+#define I830_DESTREG_CBUFADDR0 0
+#define I830_DESTREG_CBUFADDR1 1
+#define I830_DESTREG_CBUFADDR2 2
+#define I830_DESTREG_DBUFADDR0 3
+#define I830_DESTREG_DBUFADDR1 4
+#define I830_DESTREG_DBUFADDR2 5
+#define I830_DESTREG_DV0 6
+#define I830_DESTREG_DV1 7
+#define I830_DESTREG_SENABLE 8
+#define I830_DESTREG_SR0 9
+#define I830_DESTREG_SR1 10
+#define I830_DESTREG_SR2 11
+#define I830_DEST_SETUP_SIZE 12
+
+#define I830_CTXREG_STATE1 0
+#define I830_CTXREG_STATE2 1
+#define I830_CTXREG_STATE3 2
+#define I830_CTXREG_STATE4 3
+#define I830_CTXREG_STATE5 4
+#define I830_CTXREG_IALPHAB 5
+#define I830_CTXREG_STENCILTST 6
+#define I830_CTXREG_ENABLES_1 7
+#define I830_CTXREG_ENABLES_2 8
+#define I830_CTXREG_AA 9
+#define I830_CTXREG_FOGCOLOR 10
+#define I830_CTXREG_BLENDCOLOR0 11
+#define I830_CTXREG_BLENDCOLOR1 12
+#define I830_CTXREG_VF 13
+#define I830_CTXREG_VF2 14
+#define I830_CTXREG_MCSB0 15
+#define I830_CTXREG_MCSB1 16
+#define I830_CTX_SETUP_SIZE 17
+
+#define I830_STPREG_ST0 0
+#define I830_STPREG_ST1 1
+#define I830_STP_SETUP_SIZE 2
+
+#define I830_TEXREG_TM0LI 0 /* load immediate 2 texture map n */
+#define I830_TEXREG_TM0S0 1
+#define I830_TEXREG_TM0S1 2
+#define I830_TEXREG_TM0S2 3
+#define I830_TEXREG_TM0S3 4
+#define I830_TEXREG_TM0S4 5
+#define I830_TEXREG_MCS 6 /* _3DSTATE_MAP_COORD_SETS */
+#define I830_TEXREG_CUBE 7 /* _3DSTATE_MAP_SUBE */
+#define I830_TEX_SETUP_SIZE 8
+
+#define I830_TEXBLEND_SIZE 12 /* (4 args + op) * 2 + COLOR_FACTOR */
+
+struct i830_texture_object
+{
+ struct intel_texture_object intel;
+ GLuint Setup[I830_TEX_SETUP_SIZE];
+};
+
+#define I830_TEX_UNITS 4
+
+struct i830_hw_state {
+ GLuint Ctx[I830_CTX_SETUP_SIZE];
+ GLuint Buffer[I830_DEST_SETUP_SIZE];
+ GLuint Stipple[I830_STP_SETUP_SIZE];
+ GLuint Tex[I830_TEX_UNITS][I830_TEX_SETUP_SIZE];
+ GLuint TexBlend[I830_TEX_UNITS][I830_TEXBLEND_SIZE];
+ GLuint TexBlendWordsUsed[I830_TEX_UNITS];
+ GLuint emitted; /* I810_UPLOAD_* */
+ GLuint active;
+};
+
+struct i830_context
+{
+ struct intel_context intel;
+
+ GLuint last_index;
+
+ struct i830_hw_state meta, initial, state, *current;
+};
+
+typedef struct i830_context *i830ContextPtr;
+typedef struct i830_texture_object *i830TextureObjectPtr;
+
+#define I830_CONTEXT(ctx) ((i830ContextPtr)(ctx))
+
+
+
+#define I830_STATECHANGE(i830, flag) \
+do { \
+ INTEL_FIREVERTICES( &i830->intel ); \
+ i830->state.emitted &= ~flag; \
+} while (0)
+
+#define I830_ACTIVESTATE(i830, flag, mode) \
+do { \
+ INTEL_FIREVERTICES( &i830->intel ); \
+ if (mode) \
+ i830->state.active |= flag; \
+ else \
+ i830->state.active &= ~flag; \
+} while (0)
+
+/* i830_vtbl.c
+ */
+extern void
+i830InitVtbl( i830ContextPtr i830 );
+
+/* i830_context.c
+ */
+extern GLboolean
+i830CreateContext( const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate);
+
+/* i830_tex.c, i830_texstate.c
+ */
+extern void
+i830UpdateTextureState( intelContextPtr intel );
+
+extern void
+i830InitTextureFuncs( struct dd_function_table *functions );
+
+extern intelTextureObjectPtr
+i830AllocTexObj( struct gl_texture_object *tObj );
+
+/* i830_texblend.c
+ */
+extern GLuint i830SetTexEnvCombine(i830ContextPtr i830,
+ const struct gl_tex_env_combine_state * combine, GLint blendUnit,
+ GLuint texel_op, GLuint *state, const GLfloat *factor );
+
+extern void
+i830EmitTextureBlend( i830ContextPtr i830 );
+
+
+/* i830_state.c
+ */
+extern void
+i830InitStateFuncs( struct dd_function_table *functions );
+
+extern void
+i830EmitState( i830ContextPtr i830 );
+
+extern void
+i830InitState( i830ContextPtr i830 );
+
+/* i830_metaops.c
+ */
+extern GLboolean
+i830TryTextureReadPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack,
+ GLvoid *pixels );
+
+extern GLboolean
+i830TryTextureDrawPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels );
+
+extern void
+i830ClearWithTris( intelContextPtr intel, GLbitfield mask,
+ GLboolean all, GLint cx, GLint cy, GLint cw, GLint ch);
+
+
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_metaops.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_metaops.c
new file mode 100644
index 000000000..dd238378b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_metaops.c
@@ -0,0 +1,733 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include "glheader.h"
+#include "enums.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "utils.h"
+
+#include "intel_screen.h"
+#include "intel_batchbuffer.h"
+#include "intel_ioctl.h"
+
+#include "i830_context.h"
+#include "i830_reg.h"
+
+/* A large amount of state doesn't need to be uploaded.
+ */
+#define ACTIVE (I830_UPLOAD_TEXBLEND(0) | \
+ I830_UPLOAD_STIPPLE | \
+ I830_UPLOAD_CTX | \
+ I830_UPLOAD_BUFFERS | \
+ I830_UPLOAD_TEX(0))
+
+
+#define SET_STATE( i830, STATE ) \
+do { \
+ i830->current->emitted &= ~ACTIVE; \
+ i830->current = &i830->STATE; \
+ i830->current->emitted &= ~ACTIVE; \
+} while (0)
+
+/* Operations where the 3D engine is decoupled temporarily from the
+ * current GL state and used for other purposes than simply rendering
+ * incoming triangles.
+ */
+static void set_initial_state( i830ContextPtr i830 )
+{
+ memcpy(&i830->meta, &i830->initial, sizeof(i830->meta) );
+ i830->meta.active = ACTIVE;
+ i830->meta.emitted = 0;
+}
+
+
+static void set_no_depth_stencil_write( i830ContextPtr i830 )
+{
+ /* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_FALSE )
+ */
+ i830->meta.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_STENCIL_TEST;
+ i830->meta.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_STENCIL_WRITE;
+ i830->meta.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_STENCIL_TEST;
+ i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_STENCIL_WRITE;
+
+
+ /* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE )
+ */
+ i830->meta.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_DEPTH_TEST_MASK;
+ i830->meta.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_DIS_DEPTH_WRITE_MASK;
+ i830->meta.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_DEPTH_TEST;
+ i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_DEPTH_WRITE;
+
+ i830->meta.emitted &= ~I830_UPLOAD_CTX;
+}
+
+/* Set stencil unit to replace always with the reference value.
+ */
+static void set_stencil_replace( i830ContextPtr i830,
+ GLuint s_mask,
+ GLuint s_clear)
+{
+ /* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_TRUE )
+ */
+ i830->meta.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_STENCIL_TEST;
+ i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_STENCIL_WRITE;
+
+
+ /* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE )
+ */
+ i830->meta.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_DEPTH_TEST_MASK;
+ i830->meta.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_DIS_DEPTH_WRITE_MASK;
+ i830->meta.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_DEPTH_TEST;
+ i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_DEPTH_WRITE;
+
+ /* ctx->Driver.StencilMask( ctx, s_mask )
+ */
+ i830->meta.Ctx[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_WRITE_MASK;
+ i830->meta.Ctx[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_WRITE_MASK |
+ STENCIL_WRITE_MASK((s_mask&0xff)));
+
+ /* ctx->Driver.StencilOp( ctx, GL_REPLACE, GL_REPLACE, GL_REPLACE )
+ */
+ i830->meta.Ctx[I830_CTXREG_STENCILTST] &= ~(STENCIL_OPS_MASK);
+ i830->meta.Ctx[I830_CTXREG_STENCILTST] |=
+ (ENABLE_STENCIL_PARMS |
+ STENCIL_FAIL_OP(STENCILOP_REPLACE) |
+ STENCIL_PASS_DEPTH_FAIL_OP(STENCILOP_REPLACE) |
+ STENCIL_PASS_DEPTH_PASS_OP(STENCILOP_REPLACE));
+
+ /* ctx->Driver.StencilFunc( ctx, GL_ALWAYS, s_clear, ~0 )
+ */
+ i830->meta.Ctx[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_TEST_MASK;
+ i830->meta.Ctx[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_TEST_MASK |
+ STENCIL_TEST_MASK(0xff));
+
+ i830->meta.Ctx[I830_CTXREG_STENCILTST] &= ~(STENCIL_REF_VALUE_MASK |
+ ENABLE_STENCIL_TEST_FUNC_MASK);
+ i830->meta.Ctx[I830_CTXREG_STENCILTST] |=
+ (ENABLE_STENCIL_REF_VALUE |
+ ENABLE_STENCIL_TEST_FUNC |
+ STENCIL_REF_VALUE((s_clear&0xff)) |
+ STENCIL_TEST_FUNC(COMPAREFUNC_ALWAYS));
+
+
+
+ i830->meta.emitted &= ~I830_UPLOAD_CTX;
+}
+
+
+static void set_color_mask( i830ContextPtr i830, GLboolean state )
+{
+ const GLuint mask = ((1 << WRITEMASK_RED_SHIFT) |
+ (1 << WRITEMASK_GREEN_SHIFT) |
+ (1 << WRITEMASK_BLUE_SHIFT) |
+ (1 << WRITEMASK_ALPHA_SHIFT));
+
+ if (state) {
+ i830->meta.Ctx[I830_CTXREG_ENABLES_2] &= ~mask;
+ i830->meta.Ctx[I830_CTXREG_ENABLES_2] |=
+ (i830->state.Ctx[I830_CTXREG_ENABLES_2] & mask);
+ }
+ else
+ i830->meta.Ctx[I830_CTXREG_ENABLES_2] |= mask;
+
+ i830->meta.emitted &= ~I830_UPLOAD_CTX;
+}
+
+/* Installs a one-stage passthrough texture blend pipeline. Is there
+ * more that can be done to turn off texturing?
+ */
+static void set_no_texture( i830ContextPtr i830 )
+{
+ static const struct gl_tex_env_combine_state comb = {
+ GL_NONE, GL_NONE,
+ { GL_TEXTURE, 0, 0, }, { GL_TEXTURE, 0, 0, },
+ { GL_SRC_COLOR, 0, 0 }, { GL_SRC_ALPHA, 0, 0 },
+ 0, 0, 0, 0
+ };
+
+ i830->meta.TexBlendWordsUsed[0] =
+ i830SetTexEnvCombine( i830, & comb, 0, TEXBLENDARG_TEXEL0,
+ i830->meta.TexBlend[0], NULL);
+
+ i830->meta.TexBlend[0][0] |= TEXOP_LAST_STAGE;
+ i830->meta.emitted &= ~I830_UPLOAD_TEXBLEND(0);
+}
+
+/* Set up a single element blend stage for 'replace' texturing with no
+ * funny ops.
+ */
+static void enable_texture_blend_replace( i830ContextPtr i830,
+ GLenum format )
+{
+ static const struct gl_tex_env_combine_state comb = {
+ GL_REPLACE, GL_REPLACE,
+ { GL_TEXTURE, 0, 0, }, { GL_TEXTURE, 0, 0, },
+ { GL_SRC_COLOR, 0, 0 }, { GL_SRC_ALPHA, 0, 0 },
+ 0, 0, 1, 1
+ };
+
+ i830->meta.TexBlendWordsUsed[0] =
+ i830SetTexEnvCombine( i830, & comb, 0, TEXBLENDARG_TEXEL0,
+ i830->meta.TexBlend[0], NULL);
+
+ i830->meta.TexBlend[0][0] |= TEXOP_LAST_STAGE;
+ i830->meta.emitted &= ~I830_UPLOAD_TEXBLEND(0);
+
+/* fprintf(stderr, "%s: TexBlendWordsUsed[0]: %d\n", */
+/* __FUNCTION__, i830->meta.TexBlendWordsUsed[0]); */
+}
+
+
+
+/* Set up an arbitary piece of memory as a rectangular texture
+ * (including the front or back buffer).
+ */
+static void set_tex_rect_source( i830ContextPtr i830,
+ GLuint offset,
+ GLuint width,
+ GLuint height,
+ GLuint pitch,
+ GLuint textureFormat )
+{
+ GLint numLevels = 1;
+ GLuint *setup = i830->meta.Tex[0];
+
+ pitch *= i830->intel.intelScreen->cpp;
+
+/* fprintf(stderr, "%s: offset: %x w: %d h: %d pitch %d format %x\n", */
+/* __FUNCTION__, offset, width, height, pitch, textureFormat ); */
+
+ setup[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
+ (LOAD_TEXTURE_MAP0 << 0) | 4);
+ setup[I830_TEXREG_TM0S0] = (TM0S0_USE_FENCE | offset);
+ setup[I830_TEXREG_TM0S1] = (((height - 1) << TM0S1_HEIGHT_SHIFT) |
+ ((width - 1) << TM0S1_WIDTH_SHIFT) |
+ textureFormat);
+ setup[I830_TEXREG_TM0S2] = ((((pitch / 4) - 1) << TM0S2_PITCH_SHIFT));
+ setup[I830_TEXREG_TM0S3] &= ~TM0S3_MAX_MIP_MASK;
+ setup[I830_TEXREG_TM0S3] &= ~TM0S3_MIN_MIP_MASK;
+ setup[I830_TEXREG_TM0S3] |= ((numLevels - 1)*4) << TM0S3_MIN_MIP_SHIFT;
+
+ setup[I830_TEXREG_MCS] = (_3DSTATE_MAP_COORD_SET_CMD |
+ MAP_UNIT(0) |
+ ENABLE_TEXCOORD_PARAMS |
+ TEXCOORDS_ARE_IN_TEXELUNITS |
+ TEXCOORDTYPE_CARTESIAN |
+ ENABLE_ADDR_V_CNTL |
+ TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_WRAP) |
+ ENABLE_ADDR_U_CNTL |
+ TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_WRAP));
+
+ i830->meta.emitted &= ~I830_UPLOAD_TEX(0);
+}
+
+
+/* Select between front and back draw buffers.
+ */
+static void set_draw_offset( i830ContextPtr i830,
+ GLuint offset )
+{
+ i830->meta.Buffer[I830_DESTREG_CBUFADDR2] = offset;
+ i830->meta.emitted &= ~I830_UPLOAD_BUFFERS;
+}
+
+/* Setup an arbitary draw format, useful for targeting
+ * texture or agp memory.
+ */
+static void set_draw_format( i830ContextPtr i830,
+ GLuint format,
+ GLuint depth_format)
+{
+ i830->meta.Buffer[I830_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */
+ DSTORG_VERT_BIAS(0x8) | /* .5 */
+ format |
+ DEPTH_IS_Z |
+ depth_format);
+}
+
+
+static void set_vertex_format( i830ContextPtr i830 )
+{
+ i830->meta.Ctx[I830_CTXREG_VF] = (_3DSTATE_VFT0_CMD |
+ VFT0_TEX_COUNT(1) |
+ VFT0_DIFFUSE |
+ VFT0_SPEC |
+ VFT0_XYZW);
+ i830->meta.Ctx[I830_CTXREG_VF2] = (_3DSTATE_VFT1_CMD |
+ VFT1_TEX0_FMT(TEXCOORDFMT_2D) |
+ VFT1_TEX1_FMT(TEXCOORDFMT_2D) |
+ VFT1_TEX2_FMT(TEXCOORDFMT_2D) |
+ VFT1_TEX3_FMT(TEXCOORDFMT_2D));
+ i830->meta.emitted &= ~I830_UPLOAD_CTX;
+}
+
+
+static void draw_quad(i830ContextPtr i830,
+ GLfloat x0, GLfloat x1,
+ GLfloat y0, GLfloat y1,
+ GLubyte red, GLubyte green,
+ GLubyte blue, GLubyte alpha,
+ GLfloat s0, GLfloat s1,
+ GLfloat t0, GLfloat t1 )
+{
+ GLuint vertex_size = 8;
+ GLuint *vb = intelEmitInlinePrimitiveLocked( &i830->intel,
+ PRIM3D_TRIFAN,
+ 4*vertex_size,
+ vertex_size );
+ intelVertex tmp;
+ int i;
+
+
+/* fprintf(stderr, "%s: %f,%f-%f,%f 0x%x%x%x%x %f,%f-%f,%f\n", */
+/* __FUNCTION__, */
+/* x0,y0,x1,y1,red,green,blue,alpha,s0,t0,s1,t1); */
+
+
+ /* initial vertex, left bottom */
+ tmp.v.x = x0;
+ tmp.v.y = y0;
+ tmp.v.z = 1.0;
+ tmp.v.w = 1.0;
+ tmp.v.color.red = red;
+ tmp.v.color.green = green;
+ tmp.v.color.blue = blue;
+ tmp.v.color.alpha = alpha;
+ tmp.v.specular.red = 0;
+ tmp.v.specular.green = 0;
+ tmp.v.specular.blue = 0;
+ tmp.v.specular.alpha = 0;
+ tmp.v.u0 = s0;
+ tmp.v.v0 = t0;
+ for (i = 0 ; i < 8 ; i++)
+ vb[i] = tmp.ui[i];
+
+ /* right bottom */
+ vb += 8;
+ tmp.v.x = x1;
+ tmp.v.u0 = s1;
+ for (i = 0 ; i < 8 ; i++)
+ vb[i] = tmp.ui[i];
+
+ /* right top */
+ vb += 8;
+ tmp.v.y = y1;
+ tmp.v.v0 = t1;
+ for (i = 0 ; i < 8 ; i++)
+ vb[i] = tmp.ui[i];
+
+ /* left top */
+ vb += 8;
+ tmp.v.x = x0;
+ tmp.v.u0 = s0;
+ for (i = 0 ; i < 8 ; i++)
+ vb[i] = tmp.ui[i];
+
+/* fprintf(stderr, "%s: DV1: %x\n", */
+/* __FUNCTION__, i830->meta.Buffer[I830_DESTREG_DV1]); */
+}
+
+void
+i830ClearWithTris(intelContextPtr intel, GLbitfield mask,
+ GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch)
+{
+ i830ContextPtr i830 = I830_CONTEXT( intel );
+ __DRIdrawablePrivate *dPriv = intel->driDrawable;
+ intelScreenPrivate *screen = intel->intelScreen;
+ int x0, y0, x1, y1;
+
+
+ SET_STATE( i830, meta );
+ set_initial_state( i830 );
+ set_no_texture( i830 );
+ set_vertex_format( i830 );
+
+ LOCK_HARDWARE(intel);
+
+ if(!all) {
+ x0 = cx;
+ y0 = cy;
+ x1 = x0 + cw;
+ y1 = y0 + ch;
+ } else {
+ x0 = 0;
+ y0 = 0;
+ x1 = x0 + dPriv->w;
+ y1 = y0 + dPriv->h;
+ }
+
+ /* Don't do any clipping to screen - these are window coordinates.
+ * The active cliprects will be applied as for any other geometry.
+ */
+
+ if(mask & BUFFER_BIT_FRONT_LEFT) {
+ set_no_depth_stencil_write( i830 );
+ set_color_mask( i830, GL_TRUE );
+ set_draw_offset( i830, screen->frontOffset );
+ draw_quad(i830, x0, x1, y0, y1,
+ intel->clear_red, intel->clear_green,
+ intel->clear_blue, intel->clear_alpha,
+ 0, 0, 0, 0);
+ }
+
+ if(mask & BUFFER_BIT_BACK_LEFT) {
+ set_no_depth_stencil_write( i830 );
+ set_color_mask( i830, GL_TRUE );
+ set_draw_offset( i830, screen->backOffset );
+
+ draw_quad(i830, x0, x1, y0, y1,
+ intel->clear_red, intel->clear_green,
+ intel->clear_blue, intel->clear_alpha,
+ 0, 0, 0, 0);
+ }
+
+ if(mask & BUFFER_BIT_STENCIL) {
+ set_stencil_replace( i830,
+ intel->ctx.Stencil.WriteMask[0],
+ intel->ctx.Stencil.Clear);
+
+ set_color_mask( i830, GL_FALSE );
+ set_draw_offset( i830, screen->frontOffset );
+ draw_quad( i830, x0, x1, y0, y1, 0, 0, 0, 0, 0, 0, 0, 0 );
+ }
+
+ UNLOCK_HARDWARE(intel);
+
+ SET_STATE( i830, state );
+}
+
+
+
+
+GLboolean
+i830TryTextureReadPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack,
+ GLvoid *pixels )
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+ intelScreenPrivate *screen = i830->intel.intelScreen;
+ GLint pitch = pack->RowLength ? pack->RowLength : width;
+ __DRIdrawablePrivate *dPriv = i830->intel.driDrawable;
+ int textureFormat;
+ GLenum glTextureFormat;
+ int src_offset = i830->meta.Buffer[I830_DESTREG_CBUFADDR2];
+ int destOffset = intelAgpOffsetFromVirtual( &i830->intel, pixels);
+ int destFormat, depthFormat, destPitch;
+ drm_clip_rect_t tmp;
+
+ if (INTEL_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+
+ if ( ctx->_ImageTransferState ||
+ pack->SwapBytes ||
+ pack->LsbFirst ||
+ !pack->Invert) {
+ fprintf(stderr, "%s: check_color failed\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+
+ switch (screen->fbFormat) {
+ case DV_PF_565:
+ textureFormat = MAPSURF_16BIT | MT_16BIT_RGB565;
+ glTextureFormat = GL_RGB;
+ break;
+ case DV_PF_555:
+ textureFormat = MAPSURF_16BIT | MT_16BIT_ARGB1555;
+ glTextureFormat = GL_RGBA;
+ break;
+ case DV_PF_8888:
+ textureFormat = MAPSURF_32BIT | MT_32BIT_ARGB8888;
+ glTextureFormat = GL_RGBA;
+ break;
+ default:
+ fprintf(stderr, "%s: textureFormat failed %x\n", __FUNCTION__,
+ screen->fbFormat);
+ return GL_FALSE;
+ }
+
+
+ switch (type) {
+ case GL_UNSIGNED_SHORT_5_6_5:
+ if (format != GL_RGB) return GL_FALSE;
+ destFormat = COLR_BUF_RGB565;
+ depthFormat = DEPTH_FRMT_16_FIXED;
+ destPitch = pitch * 2;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ if (format != GL_BGRA) return GL_FALSE;
+ destFormat = COLR_BUF_ARGB8888;
+ depthFormat = DEPTH_FRMT_24_FIXED_8_OTHER;
+ destPitch = pitch * 4;
+ break;
+ default:
+ fprintf(stderr, "%s: destFormat failed %s\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(type));
+ return GL_FALSE;
+ }
+
+ destFormat |= (0x02<<24);
+
+/* fprintf(stderr, "type: %s destFormat: %x\n", */
+/* _mesa_lookup_enum_by_nr(type), */
+/* destFormat); */
+
+ intelFlush( ctx );
+
+ SET_STATE( i830, meta );
+ set_initial_state( i830 );
+ set_no_depth_stencil_write( i830 );
+
+ LOCK_HARDWARE( intel );
+ {
+ intelWaitForIdle( intel ); /* required by GL */
+
+ if (!driClipRectToFramebuffer(ctx->ReadBuffer, &x, &y, &width, &height)) {
+ UNLOCK_HARDWARE( intel );
+ SET_STATE(i830, state);
+ fprintf(stderr, "%s: cliprect failed\n", __FUNCTION__);
+ return GL_TRUE;
+ }
+
+#if 0
+ /* FIXME -- Just emit the correct state
+ */
+ if (i830SetParam(i830->driFd, I830_SETPARAM_CBUFFER_PITCH,
+ destPitch) != 0) {
+ UNLOCK_HARDWARE( intel );
+ SET_STATE(i830, state);
+ fprintf(stderr, "%s: setparam failed\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+#endif
+
+
+ y = dPriv->h - y - height;
+ x += dPriv->x;
+ y += dPriv->y;
+
+
+ /* Set the frontbuffer up as a large rectangular texture.
+ */
+ set_tex_rect_source( i830,
+ src_offset,
+ screen->width,
+ screen->height,
+ screen->frontPitch,
+ textureFormat );
+
+
+ enable_texture_blend_replace( i830, glTextureFormat );
+
+
+ /* Set the 3d engine to draw into the agp memory
+ */
+
+ set_draw_offset( i830, destOffset );
+ set_draw_format( i830, destFormat, depthFormat );
+
+
+ /* Draw a single quad, no cliprects:
+ */
+ i830->intel.numClipRects = 1;
+ i830->intel.pClipRects = &tmp;
+ i830->intel.pClipRects[0].x1 = 0;
+ i830->intel.pClipRects[0].y1 = 0;
+ i830->intel.pClipRects[0].x2 = width;
+ i830->intel.pClipRects[0].y2 = height;
+
+ draw_quad( i830,
+ 0, width, 0, height,
+ 0, 255, 0, 0,
+ x, x+width, y, y+height );
+
+ intelWindowMoved( intel );
+ }
+ UNLOCK_HARDWARE( intel );
+ intelFinish( ctx ); /* required by GL */
+
+ SET_STATE( i830, state );
+ return GL_TRUE;
+}
+
+
+GLboolean
+i830TryTextureDrawPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels )
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ GLint pitch = unpack->RowLength ? unpack->RowLength : width;
+ __DRIdrawablePrivate *dPriv = intel->driDrawable;
+ int textureFormat;
+ GLenum glTextureFormat;
+ int dst_offset = i830->meta.Buffer[I830_DESTREG_CBUFADDR2];
+ int src_offset = intelAgpOffsetFromVirtual( intel, pixels );
+
+ if (INTEL_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ /* Todo -- upload images that aren't in agp space, then texture
+ * from them.
+ */
+
+ if ( !intelIsAgpMemory( intel, pixels, pitch*height ) ) {
+ fprintf(stderr, "%s: intelIsAgpMemory failed\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+
+ /* Todo -- don't want to clobber all the drawing state like we do
+ * for readpixels -- most of this state can be handled just fine.
+ */
+ if ( ctx->_ImageTransferState ||
+ unpack->SwapBytes ||
+ unpack->LsbFirst ||
+ ctx->Color.AlphaEnabled ||
+ ctx->Depth.Test ||
+ ctx->Fog.Enabled ||
+ ctx->Scissor.Enabled ||
+ ctx->Stencil.Enabled ||
+ !ctx->Color.ColorMask[0] ||
+ !ctx->Color.ColorMask[1] ||
+ !ctx->Color.ColorMask[2] ||
+ !ctx->Color.ColorMask[3] ||
+ ctx->Color.ColorLogicOpEnabled ||
+ ctx->Texture._EnabledUnits ||
+ ctx->Depth.OcclusionTest) {
+ fprintf(stderr, "%s: other tests failed\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+
+ /* Todo -- remove these restrictions:
+ */
+ if (ctx->Pixel.ZoomX != 1.0F ||
+ ctx->Pixel.ZoomY != -1.0F)
+ return GL_FALSE;
+
+
+
+ switch (type) {
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ if (format != GL_BGRA) return GL_FALSE;
+ textureFormat = MAPSURF_16BIT | MT_16BIT_ARGB1555;
+ glTextureFormat = GL_RGBA;
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ if (format != GL_RGB) return GL_FALSE;
+ textureFormat = MAPSURF_16BIT | MT_16BIT_RGB565;
+ glTextureFormat = GL_RGB;
+ break;
+ case GL_UNSIGNED_SHORT_8_8_MESA:
+ if (format != GL_YCBCR_MESA) return GL_FALSE;
+ textureFormat = (MAPSURF_422 | MT_422_YCRCB_SWAPY
+/* | TM0S1_COLORSPACE_CONVERSION */
+ );
+ glTextureFormat = GL_YCBCR_MESA;
+ break;
+ case GL_UNSIGNED_SHORT_8_8_REV_MESA:
+ if (format != GL_YCBCR_MESA) return GL_FALSE;
+ textureFormat = (MAPSURF_422 | MT_422_YCRCB_NORMAL
+/* | TM0S1_COLORSPACE_CONVERSION */
+ );
+ glTextureFormat = GL_YCBCR_MESA;
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ if (format != GL_BGRA) return GL_FALSE;
+ textureFormat = MAPSURF_32BIT | MT_32BIT_ARGB8888;
+ glTextureFormat = GL_RGBA;
+ break;
+ default:
+ fprintf(stderr, "%s: destFormat failed\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+
+ intelFlush( ctx );
+
+ SET_STATE( i830, meta );
+
+ LOCK_HARDWARE( intel );
+ {
+ intelWaitForIdle( intel ); /* required by GL */
+
+ y -= height; /* cope with pixel zoom */
+
+ if (!driClipRectToFramebuffer(ctx->ReadBuffer, &x, &y, &width, &height)) {
+ UNLOCK_HARDWARE( intel );
+ SET_STATE(i830, state);
+ fprintf(stderr, "%s: cliprect failed\n", __FUNCTION__);
+ return GL_TRUE;
+ }
+
+
+ y = dPriv->h - y - height;
+
+ set_initial_state( i830 );
+
+ /* Set the pixel image up as a rectangular texture.
+ */
+ set_tex_rect_source( i830,
+ src_offset,
+ width,
+ height,
+ pitch, /* XXXX!!!! -- /2 sometimes */
+ textureFormat );
+
+
+ enable_texture_blend_replace( i830, glTextureFormat );
+
+
+ /* Draw to the current draw buffer:
+ */
+ set_draw_offset( i830, dst_offset );
+
+ /* Draw a quad, use regular cliprects
+ */
+/* fprintf(stderr, "x: %d y: %d width %d height %d\n", x, y, width, height); */
+
+ draw_quad( i830,
+ x, x+width, y, y+height,
+ 0, 255, 0, 0,
+ 0, width, 0, height );
+
+ intelWindowMoved( intel );
+ }
+ UNLOCK_HARDWARE( intel );
+ intelFinish( ctx ); /* required by GL */
+
+ SET_STATE(i830, state);
+
+ return GL_TRUE;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_reg.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_reg.h
new file mode 100644
index 000000000..c45b88ca5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_reg.h
@@ -0,0 +1,641 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+
+#ifndef _I830_REG_H_
+#define _I830_REG_H_
+
+
+#include "intel_reg.h"
+
+#define I830_SET_FIELD( var, mask, value ) (var &= ~(mask), var |= value)
+
+#define _3DSTATE_AA_CMD (CMD_3D | (0x06<<24))
+#define AA_LINE_ECAAR_WIDTH_ENABLE (1<<16)
+#define AA_LINE_ECAAR_WIDTH_0_5 0
+#define AA_LINE_ECAAR_WIDTH_1_0 (1<<14)
+#define AA_LINE_ECAAR_WIDTH_2_0 (2<<14)
+#define AA_LINE_ECAAR_WIDTH_4_0 (3<<14)
+#define AA_LINE_REGION_WIDTH_ENABLE (1<<8)
+#define AA_LINE_REGION_WIDTH_0_5 0
+#define AA_LINE_REGION_WIDTH_1_0 (1<<6)
+#define AA_LINE_REGION_WIDTH_2_0 (2<<6)
+#define AA_LINE_REGION_WIDTH_4_0 (3<<6)
+#define AA_LINE_ENABLE ((1<<1) | 1)
+#define AA_LINE_DISABLE (1<<1)
+
+#define _3DSTATE_BUF_INFO_CMD (CMD_3D | (0x1d<<24) | (0x8e<<16) | 1)
+/* Dword 1 */
+#define BUF_3D_ID_COLOR_BACK (0x3<<24)
+#define BUF_3D_ID_DEPTH (0x7<<24)
+#define BUF_3D_USE_FENCE (1<<23)
+#define BUF_3D_TILED_SURFACE (1<<22)
+#define BUF_3D_TILE_WALK_X 0
+#define BUF_3D_TILE_WALK_Y (1<<21)
+#define BUF_3D_PITCH(x) (((x)/4)<<2)
+/* Dword 2 */
+#define BUF_3D_ADDR(x) ((x) & ~0x3)
+
+
+#define _3DSTATE_COLOR_FACTOR_CMD (CMD_3D | (0x1d<<24) | (0x1<<16))
+
+#define _3DSTATE_COLOR_FACTOR_N_CMD(stage) (CMD_3D | (0x1d<<24) | \
+ ((0x90+(stage))<<16))
+
+#define _3DSTATE_CONST_BLEND_COLOR_CMD (CMD_3D | (0x1d<<24) | (0x88<<16))
+
+#define _3DSTATE_DFLT_DIFFUSE_CMD (CMD_3D | (0x1d<<24) | (0x99<<16))
+
+#define _3DSTATE_DFLT_SPEC_CMD (CMD_3D | (0x1d<<24) | (0x9a<<16))
+
+#define _3DSTATE_DFLT_Z_CMD (CMD_3D | (0x1d<<24) | (0x98<<16))
+
+
+#define _3DSTATE_DST_BUF_VARS_CMD (CMD_3D | (0x1d<<24) | (0x85<<16))
+/* Dword 1 */
+#define DSTORG_HORT_BIAS(x) ((x)<<20)
+#define DSTORG_VERT_BIAS(x) ((x)<<16)
+#define COLOR_4_2_2_CHNL_WRT_ALL 0
+#define COLOR_4_2_2_CHNL_WRT_Y (1<<12)
+#define COLOR_4_2_2_CHNL_WRT_CR (2<<12)
+#define COLOR_4_2_2_CHNL_WRT_CB (3<<12)
+#define COLOR_4_2_2_CHNL_WRT_CRCB (4<<12)
+#define COLR_BUF_8BIT 0
+#define COLR_BUF_RGB555 (1<<8)
+#define COLR_BUF_RGB565 (2<<8)
+#define COLR_BUF_ARGB8888 (3<<8)
+#define DEPTH_IS_Z 0
+#define DEPTH_IS_W (1<<6)
+#define DEPTH_FRMT_16_FIXED 0
+#define DEPTH_FRMT_16_FLOAT (1<<2)
+#define DEPTH_FRMT_24_FIXED_8_OTHER (2<<2)
+#define DEPTH_FRMT_24_FLOAT_8_OTHER (3<<2)
+#define VERT_LINE_STRIDE_1 (1<<1)
+#define VERT_LINE_STRIDE_0 0
+#define VERT_LINE_STRIDE_OFS_1 1
+#define VERT_LINE_STRIDE_OFS_0 0
+
+
+#define _3DSTATE_DRAW_RECT_CMD (CMD_3D|(0x1d<<24)|(0x80<<16)|3)
+/* Dword 1 */
+#define DRAW_RECT_DIS_DEPTH_OFS (1<<30)
+#define DRAW_DITHER_OFS_X(x) ((x)<<26)
+#define DRAW_DITHER_OFS_Y(x) ((x)<<24)
+/* Dword 2 */
+#define DRAW_YMIN(x) ((x)<<16)
+#define DRAW_XMIN(x) (x)
+/* Dword 3 */
+#define DRAW_YMAX(x) ((x)<<16)
+#define DRAW_XMAX(x) (x)
+/* Dword 4 */
+#define DRAW_YORG(x) ((x)<<16)
+#define DRAW_XORG(x) (x)
+
+
+#define _3DSTATE_ENABLES_1_CMD (CMD_3D|(0x3<<24))
+#define ENABLE_LOGIC_OP_MASK ((1<<23)|(1<<22))
+#define ENABLE_LOGIC_OP ((1<<23)|(1<<22))
+#define DISABLE_LOGIC_OP (1<<23)
+#define ENABLE_STENCIL_TEST ((1<<21)|(1<<20))
+#define DISABLE_STENCIL_TEST (1<<21)
+#define ENABLE_DEPTH_BIAS ((1<<11)|(1<<10))
+#define DISABLE_DEPTH_BIAS (1<<11)
+#define ENABLE_SPEC_ADD_MASK ((1<<9)|(1<<8))
+#define ENABLE_SPEC_ADD ((1<<9)|(1<<8))
+#define DISABLE_SPEC_ADD (1<<9)
+#define ENABLE_DIS_FOG_MASK ((1<<7)|(1<<6))
+#define ENABLE_FOG ((1<<7)|(1<<6))
+#define DISABLE_FOG (1<<7)
+#define ENABLE_DIS_ALPHA_TEST_MASK ((1<<5)|(1<<4))
+#define ENABLE_ALPHA_TEST ((1<<5)|(1<<4))
+#define DISABLE_ALPHA_TEST (1<<5)
+#define ENABLE_DIS_CBLEND_MASK ((1<<3)|(1<<2))
+#define ENABLE_COLOR_BLEND ((1<<3)|(1<<2))
+#define DISABLE_COLOR_BLEND (1<<3)
+#define ENABLE_DIS_DEPTH_TEST_MASK ((1<<1)|1)
+#define ENABLE_DEPTH_TEST ((1<<1)|1)
+#define DISABLE_DEPTH_TEST (1<<1)
+
+/* _3DSTATE_ENABLES_2, p138 */
+#define _3DSTATE_ENABLES_2_CMD (CMD_3D|(0x4<<24))
+#define ENABLE_STENCIL_WRITE ((1<<21)|(1<<20))
+#define DISABLE_STENCIL_WRITE (1<<21)
+#define ENABLE_TEX_CACHE ((1<<17)|(1<<16))
+#define DISABLE_TEX_CACHE (1<<17)
+#define ENABLE_DITHER ((1<<9)|(1<<8))
+#define DISABLE_DITHER (1<<9)
+#define ENABLE_COLOR_MASK (1<<10)
+#define WRITEMASK_ALPHA (1<<7)
+#define WRITEMASK_ALPHA_SHIFT 7
+#define WRITEMASK_RED (1<<6)
+#define WRITEMASK_RED_SHIFT 6
+#define WRITEMASK_GREEN (1<<5)
+#define WRITEMASK_GREEN_SHIFT 5
+#define WRITEMASK_BLUE (1<<4)
+#define WRITEMASK_BLUE_SHIFT 4
+#define WRITEMASK_MASK ((1<<4)|(1<<5)|(1<<6)|(1<<7))
+#define ENABLE_COLOR_WRITE ((1<<3)|(1<<2))
+#define DISABLE_COLOR_WRITE (1<<3)
+#define ENABLE_DIS_DEPTH_WRITE_MASK 0x3
+#define ENABLE_DEPTH_WRITE ((1<<1)|1)
+#define DISABLE_DEPTH_WRITE (1<<1)
+
+/* _3DSTATE_FOG_COLOR, p139 */
+#define _3DSTATE_FOG_COLOR_CMD (CMD_3D|(0x15<<24))
+#define FOG_COLOR_RED(x) ((x)<<16)
+#define FOG_COLOR_GREEN(x) ((x)<<8)
+#define FOG_COLOR_BLUE(x) (x)
+
+/* _3DSTATE_FOG_MODE, p140 */
+#define _3DSTATE_FOG_MODE_CMD (CMD_3D|(0x1d<<24)|(0x89<<16)|2)
+/* Dword 1 */
+#define FOGFUNC_ENABLE (1<<31)
+#define FOGFUNC_VERTEX 0
+#define FOGFUNC_PIXEL_EXP (1<<28)
+#define FOGFUNC_PIXEL_EXP2 (2<<28)
+#define FOGFUNC_PIXEL_LINEAR (3<<28)
+#define FOGSRC_INDEX_Z (1<<27)
+#define FOGSRC_INDEX_W ((1<<27)|(1<<25))
+#define FOG_LINEAR_CONST (1<<24)
+#define FOG_CONST_1(x) ((x)<<4)
+#define ENABLE_FOG_DENSITY (1<<23)
+/* Dword 2 */
+#define FOG_CONST_2(x) (x)
+/* Dword 3 */
+#define FOG_DENSITY(x) (x)
+
+/* _3DSTATE_INDEPENDENT_ALPHA_BLEND, p142 */
+#define _3DSTATE_INDPT_ALPHA_BLEND_CMD (CMD_3D|(0x0b<<24))
+#define ENABLE_INDPT_ALPHA_BLEND ((1<<23)|(1<<22))
+#define DISABLE_INDPT_ALPHA_BLEND (1<<23)
+#define ALPHA_BLENDFUNC_MASK 0x3f0000
+#define ENABLE_ALPHA_BLENDFUNC (1<<21)
+#define ABLENDFUNC_ADD 0
+#define ABLENDFUNC_SUB (1<<16)
+#define ABLENDFUNC_RVSE_SUB (2<<16)
+#define ABLENDFUNC_MIN (3<<16)
+#define ABLENDFUNC_MAX (4<<16)
+#define SRC_DST_ABLEND_MASK 0xfff
+#define ENABLE_SRC_ABLEND_FACTOR (1<<11)
+#define SRC_ABLEND_FACT(x) ((x)<<6)
+#define ENABLE_DST_ABLEND_FACTOR (1<<5)
+#define DST_ABLEND_FACT(x) (x)
+
+
+/* _3DSTATE_MAP_BLEND_ARG, p152 */
+#define _3DSTATE_MAP_BLEND_ARG_CMD(stage) (CMD_3D|(0x0e<<24)|((stage)<<20))
+
+#define TEXPIPE_COLOR 0
+#define TEXPIPE_ALPHA (1<<18)
+#define TEXPIPE_KILL (2<<18)
+#define TEXBLEND_ARG0 0
+#define TEXBLEND_ARG1 (1<<15)
+#define TEXBLEND_ARG2 (2<<15)
+#define TEXBLEND_ARG3 (3<<15)
+#define TEXBLENDARG_MODIFY_PARMS (1<<6)
+#define TEXBLENDARG_REPLICATE_ALPHA (1<<5)
+#define TEXBLENDARG_INV_ARG (1<<4)
+#define TEXBLENDARG_ONE 0
+#define TEXBLENDARG_FACTOR 0x01
+#define TEXBLENDARG_ACCUM 0x02
+#define TEXBLENDARG_DIFFUSE 0x03
+#define TEXBLENDARG_SPEC 0x04
+#define TEXBLENDARG_CURRENT 0x05
+#define TEXBLENDARG_TEXEL0 0x06
+#define TEXBLENDARG_TEXEL1 0x07
+#define TEXBLENDARG_TEXEL2 0x08
+#define TEXBLENDARG_TEXEL3 0x09
+#define TEXBLENDARG_FACTOR_N 0x0e
+
+/* _3DSTATE_MAP_BLEND_OP, p155 */
+#define _3DSTATE_MAP_BLEND_OP_CMD(stage) (CMD_3D|(0x0d<<24)|((stage)<<20))
+#if 0
+# define TEXPIPE_COLOR 0
+# define TEXPIPE_ALPHA (1<<18)
+# define TEXPIPE_KILL (2<<18)
+#endif
+#define ENABLE_TEXOUTPUT_WRT_SEL (1<<17)
+#define TEXOP_OUTPUT_CURRENT 0
+#define TEXOP_OUTPUT_ACCUM (1<<15)
+#define ENABLE_TEX_CNTRL_STAGE ((1<<12)|(1<<11))
+#define DISABLE_TEX_CNTRL_STAGE (1<<12)
+#define TEXOP_SCALE_SHIFT 9
+#define TEXOP_SCALE_1X (0 << TEXOP_SCALE_SHIFT)
+#define TEXOP_SCALE_2X (1 << TEXOP_SCALE_SHIFT)
+#define TEXOP_SCALE_4X (2 << TEXOP_SCALE_SHIFT)
+#define TEXOP_MODIFY_PARMS (1<<8)
+#define TEXOP_LAST_STAGE (1<<7)
+#define TEXBLENDOP_KILLPIXEL 0x02
+#define TEXBLENDOP_ARG1 0x01
+#define TEXBLENDOP_ARG2 0x02
+#define TEXBLENDOP_MODULATE 0x03
+#define TEXBLENDOP_ADD 0x06
+#define TEXBLENDOP_ADDSIGNED 0x07
+#define TEXBLENDOP_BLEND 0x08
+#define TEXBLENDOP_BLEND_AND_ADD 0x09
+#define TEXBLENDOP_SUBTRACT 0x0a
+#define TEXBLENDOP_DOT3 0x0b
+#define TEXBLENDOP_DOT4 0x0c
+#define TEXBLENDOP_MODULATE_AND_ADD 0x0d
+#define TEXBLENDOP_MODULATE_2X_AND_ADD 0x0e
+#define TEXBLENDOP_MODULATE_4X_AND_ADD 0x0f
+
+/* _3DSTATE_MAP_BUMP_TABLE, p160 TODO */
+/* _3DSTATE_MAP_COLOR_CHROMA_KEY, p161 TODO */
+
+#define _3DSTATE_MAP_COORD_TRANSFORM ((3<<29)|(0x1d<<24)|(0x8c<<16))
+#define DISABLE_TEX_TRANSFORM (1<<28)
+#define TEXTURE_SET(x) (x<<29)
+
+#define _3DSTATE_VERTEX_TRANSFORM ((3<<29)|(0x1d<<24)|(0x8b<<16))
+#define DISABLE_VIEWPORT_TRANSFORM (1<<31)
+#define DISABLE_PERSPECTIVE_DIVIDE (1<<29)
+
+
+/* _3DSTATE_MAP_COORD_SET_BINDINGS, p162 */
+#define _3DSTATE_MAP_COORD_SETBIND_CMD (CMD_3D|(0x1d<<24)|(0x02<<16))
+#define TEXBIND_MASK3 ((1<<15)|(1<<14)|(1<<13)|(1<<12))
+#define TEXBIND_MASK2 ((1<<11)|(1<<10)|(1<<9)|(1<<8))
+#define TEXBIND_MASK1 ((1<<7)|(1<<6)|(1<<5)|(1<<4))
+#define TEXBIND_MASK0 ((1<<3)|(1<<2)|(1<<1)|1)
+
+#define TEXBIND_SET3(x) ((x)<<12)
+#define TEXBIND_SET2(x) ((x)<<8)
+#define TEXBIND_SET1(x) ((x)<<4)
+#define TEXBIND_SET0(x) (x)
+
+#define TEXCOORDSRC_KEEP 0
+#define TEXCOORDSRC_DEFAULT 0x01
+#define TEXCOORDSRC_VTXSET_0 0x08
+#define TEXCOORDSRC_VTXSET_1 0x09
+#define TEXCOORDSRC_VTXSET_2 0x0a
+#define TEXCOORDSRC_VTXSET_3 0x0b
+#define TEXCOORDSRC_VTXSET_4 0x0c
+#define TEXCOORDSRC_VTXSET_5 0x0d
+#define TEXCOORDSRC_VTXSET_6 0x0e
+#define TEXCOORDSRC_VTXSET_7 0x0f
+
+#define MAP_UNIT(unit) ((unit)<<16)
+#define MAP_UNIT_MASK (0x7<<16)
+
+/* _3DSTATE_MAP_COORD_SETS, p164 */
+#define _3DSTATE_MAP_COORD_SET_CMD (CMD_3D|(0x1c<<24)|(0x01<<19))
+#define ENABLE_TEXCOORD_PARAMS (1<<15)
+#define TEXCOORDS_ARE_NORMAL (1<<14)
+#define TEXCOORDS_ARE_IN_TEXELUNITS 0
+#define TEXCOORDTYPE_CARTESIAN 0
+#define TEXCOORDTYPE_HOMOGENEOUS (1<<11)
+#define TEXCOORDTYPE_VECTOR (2<<11)
+#define TEXCOORDTYPE_MASK (0x7<<11)
+#define ENABLE_ADDR_V_CNTL (1<<7)
+#define ENABLE_ADDR_U_CNTL (1<<3)
+#define TEXCOORD_ADDR_V_MODE(x) ((x)<<4)
+#define TEXCOORD_ADDR_U_MODE(x) (x)
+#define TEXCOORDMODE_WRAP 0
+#define TEXCOORDMODE_MIRROR 1
+#define TEXCOORDMODE_CLAMP 2
+#define TEXCOORDMODE_WRAP_SHORTEST 3
+#define TEXCOORDMODE_CLAMP_BORDER 4
+#define TEXCOORD_ADDR_V_MASK 0x70
+#define TEXCOORD_ADDR_U_MASK 0x7
+
+/* _3DSTATE_MAP_CUBE, p168 TODO */
+#define _3DSTATE_MAP_CUBE (CMD_3D|(0x1c<<24)|(0x0a<<19))
+#define CUBE_NEGX_ENABLE (1<<5)
+#define CUBE_POSX_ENABLE (1<<4)
+#define CUBE_NEGY_ENABLE (1<<3)
+#define CUBE_POSY_ENABLE (1<<2)
+#define CUBE_NEGZ_ENABLE (1<<1)
+#define CUBE_POSZ_ENABLE (1<<0)
+
+
+/* _3DSTATE_MODES_1, p190 */
+#define _3DSTATE_MODES_1_CMD (CMD_3D|(0x08<<24))
+#define BLENDFUNC_MASK 0x3f0000
+#define ENABLE_COLR_BLND_FUNC (1<<21)
+#define BLENDFUNC_ADD 0
+#define BLENDFUNC_SUB (1<<16)
+#define BLENDFUNC_RVRSE_SUB (2<<16)
+#define BLENDFUNC_MIN (3<<16)
+#define BLENDFUNC_MAX (4<<16)
+#define SRC_DST_BLND_MASK 0xfff
+#define ENABLE_SRC_BLND_FACTOR (1<<11)
+#define ENABLE_DST_BLND_FACTOR (1<<5)
+#define SRC_BLND_FACT(x) ((x)<<6)
+#define DST_BLND_FACT(x) (x)
+
+
+/* _3DSTATE_MODES_2, p192 */
+#define _3DSTATE_MODES_2_CMD (CMD_3D|(0x0f<<24))
+#define ENABLE_GLOBAL_DEPTH_BIAS (1<<22)
+#define GLOBAL_DEPTH_BIAS(x) ((x)<<14)
+#define ENABLE_ALPHA_TEST_FUNC (1<<13)
+#define ENABLE_ALPHA_REF_VALUE (1<<8)
+#define ALPHA_TEST_FUNC(x) ((x)<<9)
+#define ALPHA_REF_VALUE(x) (x)
+
+#define ALPHA_TEST_REF_MASK 0x3fff
+
+/* _3DSTATE_MODES_3, p193 */
+#define _3DSTATE_MODES_3_CMD (CMD_3D|(0x02<<24))
+#define DEPTH_TEST_FUNC_MASK 0x1f0000
+#define ENABLE_DEPTH_TEST_FUNC (1<<20)
+/* Uses COMPAREFUNC */
+#define DEPTH_TEST_FUNC(x) ((x)<<16)
+#define ENABLE_ALPHA_SHADE_MODE (1<<11)
+#define ENABLE_FOG_SHADE_MODE (1<<9)
+#define ENABLE_SPEC_SHADE_MODE (1<<7)
+#define ENABLE_COLOR_SHADE_MODE (1<<5)
+#define ALPHA_SHADE_MODE(x) ((x)<<10)
+#define FOG_SHADE_MODE(x) ((x)<<8)
+#define SPEC_SHADE_MODE(x) ((x)<<6)
+#define COLOR_SHADE_MODE(x) ((x)<<4)
+#define CULLMODE_MASK 0xf
+#define ENABLE_CULL_MODE (1<<3)
+#define CULLMODE_BOTH 0
+#define CULLMODE_NONE 1
+#define CULLMODE_CW 2
+#define CULLMODE_CCW 3
+
+#define SHADE_MODE_LINEAR 0
+#define SHADE_MODE_FLAT 0x1
+
+/* _3DSTATE_MODES_4, p195 */
+#define _3DSTATE_MODES_4_CMD (CMD_3D|(0x16<<24))
+#define ENABLE_LOGIC_OP_FUNC (1<<23)
+#define LOGIC_OP_FUNC(x) ((x)<<18)
+#define LOGICOP_MASK ((1<<18)|(1<<19)|(1<<20)|(1<<21))
+#define LOGICOP_CLEAR 0
+#define LOGICOP_NOR 0x1
+#define LOGICOP_AND_INV 0x2
+#define LOGICOP_COPY_INV 0x3
+#define LOGICOP_AND_RVRSE 0x4
+#define LOGICOP_INV 0x5
+#define LOGICOP_XOR 0x6
+#define LOGICOP_NAND 0x7
+#define LOGICOP_AND 0x8
+#define LOGICOP_EQUIV 0x9
+#define LOGICOP_NOOP 0xa
+#define LOGICOP_OR_INV 0xb
+#define LOGICOP_COPY 0xc
+#define LOGICOP_OR_RVRSE 0xd
+#define LOGICOP_OR 0xe
+#define LOGICOP_SET 0xf
+#define MODE4_ENABLE_STENCIL_TEST_MASK ((1<<17)|(0xff00))
+#define ENABLE_STENCIL_TEST_MASK (1<<17)
+#define STENCIL_TEST_MASK(x) ((x)<<8)
+#define MODE4_ENABLE_STENCIL_WRITE_MASK ((1<<16)|(0x00ff))
+#define ENABLE_STENCIL_WRITE_MASK (1<<16)
+#define STENCIL_WRITE_MASK(x) (x)
+
+/* _3DSTATE_MODES_5, p196 */
+#define _3DSTATE_MODES_5_CMD (CMD_3D|(0x0c<<24))
+#define ENABLE_SPRITE_POINT_TEX (1<<23)
+#define SPRITE_POINT_TEX_ON (1<<22)
+#define SPRITE_POINT_TEX_OFF 0
+#define FLUSH_RENDER_CACHE (1<<18)
+#define FLUSH_TEXTURE_CACHE (1<<16)
+#define FIXED_LINE_WIDTH_MASK 0xfc00
+#define ENABLE_FIXED_LINE_WIDTH (1<<15)
+#define FIXED_LINE_WIDTH(x) ((x)<<10)
+#define FIXED_POINT_WIDTH_MASK 0x3ff
+#define ENABLE_FIXED_POINT_WIDTH (1<<9)
+#define FIXED_POINT_WIDTH(x) (x)
+
+/* _3DSTATE_RASTERIZATION_RULES, p198 */
+#define _3DSTATE_RASTER_RULES_CMD (CMD_3D|(0x07<<24))
+#define ENABLE_POINT_RASTER_RULE (1<<15)
+#define OGL_POINT_RASTER_RULE (1<<13)
+#define ENABLE_LINE_STRIP_PROVOKE_VRTX (1<<8)
+#define ENABLE_TRI_FAN_PROVOKE_VRTX (1<<5)
+#define ENABLE_TRI_STRIP_PROVOKE_VRTX (1<<2)
+#define LINE_STRIP_PROVOKE_VRTX(x) ((x)<<6)
+#define TRI_FAN_PROVOKE_VRTX(x) ((x)<<3)
+#define TRI_STRIP_PROVOKE_VRTX(x) (x)
+
+/* _3DSTATE_SCISSOR_ENABLE, p200 */
+#define _3DSTATE_SCISSOR_ENABLE_CMD (CMD_3D|(0x1c<<24)|(0x10<<19))
+#define ENABLE_SCISSOR_RECT ((1<<1) | 1)
+#define DISABLE_SCISSOR_RECT (1<<1)
+
+/* _3DSTATE_SCISSOR_RECTANGLE_0, p201 */
+#define _3DSTATE_SCISSOR_RECT_0_CMD (CMD_3D|(0x1d<<24)|(0x81<<16)|1)
+/* Dword 1 */
+#define SCISSOR_RECT_0_YMIN(x) ((x)<<16)
+#define SCISSOR_RECT_0_XMIN(x) (x)
+/* Dword 2 */
+#define SCISSOR_RECT_0_YMAX(x) ((x)<<16)
+#define SCISSOR_RECT_0_XMAX(x) (x)
+
+/* _3DSTATE_STENCIL_TEST, p202 */
+#define _3DSTATE_STENCIL_TEST_CMD (CMD_3D|(0x09<<24))
+#define ENABLE_STENCIL_PARMS (1<<23)
+#define STENCIL_OPS_MASK (0xffc000)
+#define STENCIL_FAIL_OP(x) ((x)<<20)
+#define STENCIL_PASS_DEPTH_FAIL_OP(x) ((x)<<17)
+#define STENCIL_PASS_DEPTH_PASS_OP(x) ((x)<<14)
+
+#define ENABLE_STENCIL_TEST_FUNC_MASK ((1<<13)|(1<<12)|(1<<11)|(1<<10)|(1<<9))
+#define ENABLE_STENCIL_TEST_FUNC (1<<13)
+/* Uses COMPAREFUNC */
+#define STENCIL_TEST_FUNC(x) ((x)<<9)
+#define STENCIL_REF_VALUE_MASK ((1<<8)|0xff)
+#define ENABLE_STENCIL_REF_VALUE (1<<8)
+#define STENCIL_REF_VALUE(x) (x)
+
+/* _3DSTATE_VERTEX_FORMAT, p204 */
+#define _3DSTATE_VFT0_CMD (CMD_3D|(0x05<<24))
+#define VFT0_POINT_WIDTH (1<<12)
+#define VFT0_TEX_COUNT_MASK (7<<8)
+#define VFT0_TEX_COUNT_SHIFT 8
+#define VFT0_TEX_COUNT(x) ((x)<<8)
+#define VFT0_SPEC (1<<7)
+#define VFT0_DIFFUSE (1<<6)
+#define VFT0_DEPTH_OFFSET (1<<5)
+#define VFT0_XYZ (1<<1)
+#define VFT0_XYZW (2<<1)
+#define VFT0_XY (3<<1)
+#define VFT0_XYW (4<<1)
+#define VFT0_XYZW_MASK (7<<1)
+
+/* _3DSTATE_VERTEX_FORMAT_2, p206 */
+#define _3DSTATE_VFT1_CMD (CMD_3D|(0x0a<<24))
+#define VFT1_TEX7_FMT(x) ((x)<<14)
+#define VFT1_TEX6_FMT(x) ((x)<<12)
+#define VFT1_TEX5_FMT(x) ((x)<<10)
+#define VFT1_TEX4_FMT(x) ((x)<<8)
+#define VFT1_TEX3_FMT(x) ((x)<<6)
+#define VFT1_TEX2_FMT(x) ((x)<<4)
+#define VFT1_TEX1_FMT(x) ((x)<<2)
+#define VFT1_TEX0_FMT(x) (x)
+#define VFT1_TEX0_MASK 3
+#define VFT1_TEX1_SHIFT 2
+#define TEXCOORDFMT_2D 0
+#define TEXCOORDFMT_3D 1
+#define TEXCOORDFMT_4D 2
+#define TEXCOORDFMT_1D 3
+
+/*New stuff picked up along the way */
+
+#define MLC_LOD_BIAS_MASK ((1<<7)-1)
+
+
+/* _3DSTATE_VERTEX_TRANSFORM, p207 */
+#define _3DSTATE_VERTEX_TRANS_CMD (CMD_3D|(0x1d<<24)|(0x8b<<16)|0)
+#define _3DSTATE_VERTEX_TRANS_MTX_CMD (CMD_3D|(0x1d<<24)|(0x8b<<16)|6)
+/* Dword 1 */
+#define ENABLE_VIEWPORT_TRANSFORM ((1<<31)|(1<<30))
+#define DISABLE_VIEWPORT_TRANSFORM (1<<31)
+#define ENABLE_PERSP_DIVIDE ((1<<29)|(1<<28))
+#define DISABLE_PERSP_DIVIDE (1<<29)
+#define VRTX_TRANS_LOAD_MATRICES 0x7421
+#define VRTX_TRANS_NO_LOAD_MATRICES 0x0000
+/* Dword 2 -> 7 are matrix elements */
+
+/* _3DSTATE_W_STATE, p209 */
+#define _3DSTATE_W_STATE_CMD (CMD_3D|(0x1d<<24)|(0x8d<<16)|1)
+/* Dword 1 */
+#define MAGIC_W_STATE_DWORD1 0x00000008
+/* Dword 2 */
+#define WFAR_VALUE(x) (x)
+
+
+/* Stipple command, carried over from the i810, apparently:
+ */
+#define _3DSTATE_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16))
+#define ST1_ENABLE (1<<16)
+#define ST1_MASK (0xffff)
+
+
+
+#define _3DSTATE_LOAD_STATE_IMMEDIATE_2 ((0x3<<29)|(0x1d<<24)|(0x03<<16))
+#define LOAD_TEXTURE_MAP0 (1<<11)
+#define LOAD_GLOBAL_COLOR_FACTOR (1<<6)
+
+#define TM0S0_ADDRESS_MASK 0xfffffffc
+#define TM0S0_USE_FENCE (1<<1)
+
+#define TM0S1_HEIGHT_SHIFT 21
+#define TM0S1_WIDTH_SHIFT 10
+#define TM0S1_PALETTE_SELECT (1<<9)
+#define TM0S1_MAPSURF_FORMAT_MASK (0x7 << 6)
+#define TM0S1_MAPSURF_FORMAT_SHIFT 6
+#define MAPSURF_8BIT_INDEXED (0<<6)
+#define MAPSURF_8BIT (1<<6)
+#define MAPSURF_16BIT (2<<6)
+#define MAPSURF_32BIT (3<<6)
+#define MAPSURF_411 (4<<6)
+#define MAPSURF_422 (5<<6)
+#define MAPSURF_COMPRESSED (6<<6)
+#define MAPSURF_4BIT_INDEXED (7<<6)
+#define TM0S1_MT_FORMAT_MASK (0x7 << 3)
+#define TM0S1_MT_FORMAT_SHIFT 3
+#define MT_4BIT_IDX_ARGB8888 (7<<3) /* SURFACE_4BIT_INDEXED */
+#define MT_8BIT_IDX_RGB565 (0<<3) /* SURFACE_8BIT_INDEXED */
+#define MT_8BIT_IDX_ARGB1555 (1<<3)
+#define MT_8BIT_IDX_ARGB4444 (2<<3)
+#define MT_8BIT_IDX_AY88 (3<<3)
+#define MT_8BIT_IDX_ABGR8888 (4<<3)
+#define MT_8BIT_IDX_BUMP_88DVDU (5<<3)
+#define MT_8BIT_IDX_BUMP_655LDVDU (6<<3)
+#define MT_8BIT_IDX_ARGB8888 (7<<3)
+#define MT_8BIT_I8 (0<<3) /* SURFACE_8BIT */
+#define MT_8BIT_L8 (1<<3)
+#define MT_16BIT_RGB565 (0<<3) /* SURFACE_16BIT */
+#define MT_16BIT_ARGB1555 (1<<3)
+#define MT_16BIT_ARGB4444 (2<<3)
+#define MT_16BIT_AY88 (3<<3)
+#define MT_16BIT_DIB_ARGB1555_8888 (4<<3)
+#define MT_16BIT_BUMP_88DVDU (5<<3)
+#define MT_16BIT_BUMP_655LDVDU (6<<3)
+#define MT_16BIT_DIB_RGB565_8888 (7<<3)
+#define MT_32BIT_ARGB8888 (0<<3) /* SURFACE_32BIT */
+#define MT_32BIT_ABGR8888 (1<<3)
+#define MT_32BIT_BUMP_XLDVDU_8888 (6<<3)
+#define MT_32BIT_DIB_8888 (7<<3)
+#define MT_411_YUV411 (0<<3) /* SURFACE_411 */
+#define MT_422_YCRCB_SWAPY (0<<3) /* SURFACE_422 */
+#define MT_422_YCRCB_NORMAL (1<<3)
+#define MT_422_YCRCB_SWAPUV (2<<3)
+#define MT_422_YCRCB_SWAPUVY (3<<3)
+#define MT_COMPRESS_DXT1 (0<<3) /* SURFACE_COMPRESSED */
+#define MT_COMPRESS_DXT2_3 (1<<3)
+#define MT_COMPRESS_DXT4_5 (2<<3)
+#define MT_COMPRESS_FXT1 (3<<3)
+#define TM0S1_COLORSPACE_CONVERSION (1 << 2)
+#define TM0S1_TILED_SURFACE (1 << 1)
+#define TM0S1_TILE_WALK (1 << 0)
+
+#define TM0S2_PITCH_SHIFT 21
+#define TM0S2_CUBE_FACE_ENA_SHIFT 15
+#define TM0S2_CUBE_FACE_ENA_MASK (1<<15)
+#define TM0S2_MAP_FORMAT (1<<14)
+#define TM0S2_VERTICAL_LINE_STRIDE (1<<13)
+#define TM0S2_VERITCAL_LINE_STRIDE_OFF (1<<12)
+#define TM0S2_OUTPUT_CHAN_SHIFT 10
+#define TM0S2_OUTPUT_CHAN_MASK (3<<10)
+
+#define TM0S3_MIP_FILTER_MASK (0x3<<30)
+#define TM0S3_MIP_FILTER_SHIFT 30
+#define MIPFILTER_NONE 0
+#define MIPFILTER_NEAREST 1
+#define MIPFILTER_LINEAR 3
+#define TM0S3_MAG_FILTER_MASK (0x3<<28)
+#define TM0S3_MAG_FILTER_SHIFT 28
+#define TM0S3_MIN_FILTER_MASK (0x3<<26)
+#define TM0S3_MIN_FILTER_SHIFT 26
+#define FILTER_NEAREST 0
+#define FILTER_LINEAR 1
+#define FILTER_ANISOTROPIC 2
+
+#define TM0S3_LOD_BIAS_SHIFT 17
+#define TM0S3_LOD_BIAS_MASK (0x1ff<<17)
+#define TM0S3_MAX_MIP_SHIFT 9
+#define TM0S3_MAX_MIP_MASK (0xff<<9)
+#define TM0S3_MIN_MIP_SHIFT 3
+#define TM0S3_MIN_MIP_MASK (0x3f<<3)
+#define TM0S3_KILL_PIXEL (1<<2)
+#define TM0S3_KEYED_FILTER (1<<1)
+#define TM0S3_CHROMA_KEY (1<<0)
+
+
+/* _3DSTATE_MAP_TEXEL_STREAM, p188 */
+#define _3DSTATE_MAP_TEX_STREAM_CMD (CMD_3D|(0x1c<<24)|(0x05<<19))
+#define DISABLE_TEX_STREAM_BUMP (1<<12)
+#define ENABLE_TEX_STREAM_BUMP ((1<<12)|(1<<11))
+#define TEX_MODIFY_UNIT_0 0
+#define TEX_MODIFY_UNIT_1 (1<<8)
+#define ENABLE_TEX_STREAM_COORD_SET (1<<7)
+#define TEX_STREAM_COORD_SET(x) ((x)<<4)
+#define ENABLE_TEX_STREAM_MAP_IDX (1<<3)
+#define TEX_STREAM_MAP_IDX(x) (x)
+
+
+#define MI_FLUSH ((0<<29)|(4<<23))
+#define FLUSH_MAP_CACHE (1<<0)
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_state.c
new file mode 100644
index 000000000..ec19fe980
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_state.c
@@ -0,0 +1,1089 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "enums.h"
+#include "dd.h"
+
+#include "texmem.h"
+
+#include "intel_screen.h"
+#include "intel_batchbuffer.h"
+
+#include "i830_context.h"
+#include "i830_reg.h"
+
+static void i830StencilFunc(GLcontext *ctx, GLenum func, GLint ref,
+ GLuint mask)
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ int test = intel_translate_compare_func(func);
+
+ mask = mask & 0xff;
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s : func: %s, ref : 0x%x, mask: 0x%x\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(func), ref, mask);
+
+
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_TEST_MASK;
+ i830->state.Ctx[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_TEST_MASK |
+ STENCIL_TEST_MASK(mask));
+ i830->state.Ctx[I830_CTXREG_STENCILTST] &= ~(STENCIL_REF_VALUE_MASK |
+ ENABLE_STENCIL_TEST_FUNC_MASK);
+ i830->state.Ctx[I830_CTXREG_STENCILTST] |= (ENABLE_STENCIL_REF_VALUE |
+ ENABLE_STENCIL_TEST_FUNC |
+ STENCIL_REF_VALUE(ref) |
+ STENCIL_TEST_FUNC(test));
+}
+
+static void i830StencilMask(GLcontext *ctx, GLuint mask)
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s : mask 0x%x\n", __FUNCTION__, mask);
+
+ mask = mask & 0xff;
+
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_WRITE_MASK;
+ i830->state.Ctx[I830_CTXREG_STATE4] |= (ENABLE_STENCIL_WRITE_MASK |
+ STENCIL_WRITE_MASK(mask));
+}
+
+static void i830StencilOp(GLcontext *ctx, GLenum fail, GLenum zfail,
+ GLenum zpass)
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ int fop, dfop, dpop;
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s: fail : %s, zfail: %s, zpass : %s\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(fail),
+ _mesa_lookup_enum_by_nr(zfail),
+ _mesa_lookup_enum_by_nr(zpass));
+
+ fop = 0; dfop = 0; dpop = 0;
+
+ switch(fail) {
+ case GL_KEEP:
+ fop = STENCILOP_KEEP;
+ break;
+ case GL_ZERO:
+ fop = STENCILOP_ZERO;
+ break;
+ case GL_REPLACE:
+ fop = STENCILOP_REPLACE;
+ break;
+ case GL_INCR:
+ fop = STENCILOP_INCRSAT;
+ break;
+ case GL_DECR:
+ fop = STENCILOP_DECRSAT;
+ break;
+ case GL_INCR_WRAP:
+ fop = STENCILOP_INCR;
+ break;
+ case GL_DECR_WRAP:
+ fop = STENCILOP_DECR;
+ break;
+ case GL_INVERT:
+ fop = STENCILOP_INVERT;
+ break;
+ default:
+ break;
+ }
+ switch(zfail) {
+ case GL_KEEP:
+ dfop = STENCILOP_KEEP;
+ break;
+ case GL_ZERO:
+ dfop = STENCILOP_ZERO;
+ break;
+ case GL_REPLACE:
+ dfop = STENCILOP_REPLACE;
+ break;
+ case GL_INCR:
+ dfop = STENCILOP_INCRSAT;
+ break;
+ case GL_DECR:
+ dfop = STENCILOP_DECRSAT;
+ break;
+ case GL_INCR_WRAP:
+ dfop = STENCILOP_INCR;
+ break;
+ case GL_DECR_WRAP:
+ dfop = STENCILOP_DECR;
+ break;
+ case GL_INVERT:
+ dfop = STENCILOP_INVERT;
+ break;
+ default:
+ break;
+ }
+ switch(zpass) {
+ case GL_KEEP:
+ dpop = STENCILOP_KEEP;
+ break;
+ case GL_ZERO:
+ dpop = STENCILOP_ZERO;
+ break;
+ case GL_REPLACE:
+ dpop = STENCILOP_REPLACE;
+ break;
+ case GL_INCR:
+ dpop = STENCILOP_INCRSAT;
+ break;
+ case GL_DECR:
+ dpop = STENCILOP_DECRSAT;
+ break;
+ case GL_INCR_WRAP:
+ dpop = STENCILOP_INCR;
+ break;
+ case GL_DECR_WRAP:
+ dpop = STENCILOP_DECR;
+ break;
+ case GL_INVERT:
+ dpop = STENCILOP_INVERT;
+ break;
+ default:
+ break;
+ }
+
+
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_STENCILTST] &= ~(STENCIL_OPS_MASK);
+ i830->state.Ctx[I830_CTXREG_STENCILTST] |= (ENABLE_STENCIL_PARMS |
+ STENCIL_FAIL_OP(fop) |
+ STENCIL_PASS_DEPTH_FAIL_OP(dfop) |
+ STENCIL_PASS_DEPTH_PASS_OP(dpop));
+}
+
+static void i830AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ int test = intel_translate_compare_func(func);
+ GLubyte refByte;
+ GLuint refInt;
+
+ UNCLAMPED_FLOAT_TO_UBYTE(refByte, ref);
+ refInt = (GLuint)refByte;
+
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_STATE2] &= ~ALPHA_TEST_REF_MASK;
+ i830->state.Ctx[I830_CTXREG_STATE2] |= (ENABLE_ALPHA_TEST_FUNC |
+ ENABLE_ALPHA_REF_VALUE |
+ ALPHA_TEST_FUNC(test) |
+ ALPHA_REF_VALUE(refInt));
+}
+
+/**
+ * Makes sure that the proper enables are set for LogicOp, Independant Alpha
+ * Blend, and Blending. It needs to be called from numerous places where we
+ * could change the LogicOp or Independant Alpha Blend without subsequent
+ * calls to glEnable.
+ *
+ * \todo
+ * This function is substantially different from the old i830-specific driver.
+ * I'm not sure which is correct.
+ */
+static void i830EvalLogicOpBlendState(GLcontext *ctx)
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+
+ if (ctx->Color._LogicOpEnabled) {
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~(ENABLE_COLOR_BLEND |
+ ENABLE_LOGIC_OP_MASK);
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] |= (DISABLE_COLOR_BLEND |
+ ENABLE_LOGIC_OP);
+ } else if (ctx->Color.BlendEnabled) {
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~(ENABLE_COLOR_BLEND |
+ ENABLE_LOGIC_OP_MASK);
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] |= (ENABLE_COLOR_BLEND |
+ DISABLE_LOGIC_OP);
+ } else {
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~(ENABLE_COLOR_BLEND |
+ ENABLE_LOGIC_OP_MASK);
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] |= (DISABLE_COLOR_BLEND |
+ DISABLE_LOGIC_OP);
+ }
+}
+
+static void i830BlendColor(GLcontext *ctx, const GLfloat color[4])
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ GLubyte r, g, b, a;
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ UNCLAMPED_FLOAT_TO_UBYTE(r, color[RCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(g, color[GCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(b, color[BCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(a, color[ACOMP]);
+
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_BLENDCOLOR1] = (a<<24) | (r<<16) | (g<<8) | b;
+}
+
+/**
+ * Sets both the blend equation (called "function" in i830 docs) and the
+ * blend function (called "factor" in i830 docs). This is done in a single
+ * function because some blend equations (i.e., \c GL_MIN and \c GL_MAX)
+ * change the interpretation of the blend function.
+ */
+static void i830_set_blend_state( GLcontext * ctx )
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ int funcA;
+ int funcRGB;
+ int eqnA;
+ int eqnRGB;
+ int iab;
+ int s1;
+
+
+ funcRGB = SRC_BLND_FACT( intel_translate_blend_factor( ctx->Color.BlendSrcRGB ) )
+ | DST_BLND_FACT( intel_translate_blend_factor( ctx->Color.BlendDstRGB ) );
+
+ switch(ctx->Color.BlendEquationRGB) {
+ case GL_FUNC_ADD:
+ eqnRGB = BLENDFUNC_ADD;
+ break;
+ case GL_MIN:
+ eqnRGB = BLENDFUNC_MIN;
+ funcRGB = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE);
+ break;
+ case GL_MAX:
+ eqnRGB = BLENDFUNC_MAX;
+ funcRGB = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE);
+ break;
+ case GL_FUNC_SUBTRACT:
+ eqnRGB = BLENDFUNC_SUB;
+ break;
+ case GL_FUNC_REVERSE_SUBTRACT:
+ eqnRGB = BLENDFUNC_RVRSE_SUB;
+ break;
+ default:
+ fprintf( stderr, "[%s:%u] Invalid RGB blend equation (0x%04x).\n",
+ __FUNCTION__, __LINE__, ctx->Color.BlendEquationRGB );
+ return;
+ }
+
+
+ funcA = SRC_ABLEND_FACT( intel_translate_blend_factor( ctx->Color.BlendSrcA ) )
+ | DST_ABLEND_FACT( intel_translate_blend_factor( ctx->Color.BlendDstA ) );
+
+ switch(ctx->Color.BlendEquationA) {
+ case GL_FUNC_ADD:
+ eqnA = BLENDFUNC_ADD;
+ break;
+ case GL_MIN:
+ eqnA = BLENDFUNC_MIN;
+ funcA = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE);
+ break;
+ case GL_MAX:
+ eqnA = BLENDFUNC_MAX;
+ funcA = SRC_BLND_FACT(BLENDFACT_ONE) | DST_BLND_FACT(BLENDFACT_ONE);
+ break;
+ case GL_FUNC_SUBTRACT:
+ eqnA = BLENDFUNC_SUB;
+ break;
+ case GL_FUNC_REVERSE_SUBTRACT:
+ eqnA = BLENDFUNC_RVRSE_SUB;
+ break;
+ default:
+ fprintf( stderr, "[%s:%u] Invalid alpha blend equation (0x%04x).\n",
+ __FUNCTION__, __LINE__, ctx->Color.BlendEquationA );
+ return;
+ }
+
+ iab = eqnA | funcA
+ | _3DSTATE_INDPT_ALPHA_BLEND_CMD
+ | ENABLE_SRC_ABLEND_FACTOR | ENABLE_DST_ABLEND_FACTOR
+ | ENABLE_ALPHA_BLENDFUNC;
+ s1 = eqnRGB | funcRGB
+ | _3DSTATE_MODES_1_CMD
+ | ENABLE_SRC_BLND_FACTOR | ENABLE_DST_BLND_FACTOR
+ | ENABLE_COLR_BLND_FUNC;
+
+ if ( (eqnA | funcA) != (eqnRGB | funcRGB) )
+ iab |= ENABLE_INDPT_ALPHA_BLEND;
+ else
+ iab |= DISABLE_INDPT_ALPHA_BLEND;
+
+ if (iab != i830->state.Ctx[I830_CTXREG_IALPHAB] ||
+ s1 != i830->state.Ctx[I830_CTXREG_STATE1]) {
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_IALPHAB] = iab;
+ i830->state.Ctx[I830_CTXREG_STATE1] = s1;
+ }
+
+ /* This will catch a logicop blend equation. It will also ensure
+ * independant alpha blend is really in the correct state (either enabled
+ * or disabled) if blending is already enabled.
+ */
+
+ i830EvalLogicOpBlendState(ctx);
+
+ if (0) {
+ fprintf(stderr, "[%s:%u] STATE1: 0x%08x IALPHAB: 0x%08x blend is %sabled\n",
+ __FUNCTION__, __LINE__,
+ i830->state.Ctx[I830_CTXREG_STATE1],
+ i830->state.Ctx[I830_CTXREG_IALPHAB],
+ (ctx->Color.BlendEnabled) ? "en" : "dis");
+ }
+}
+
+
+static void i830BlendEquationSeparate(GLcontext *ctx, GLenum modeRGB,
+ GLenum modeA)
+{
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s -> %s, %s\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(modeRGB),
+ _mesa_lookup_enum_by_nr(modeA));
+
+ (void) modeRGB;
+ (void) modeA;
+ i830_set_blend_state( ctx );
+}
+
+
+static void i830BlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB,
+ GLenum dfactorRGB, GLenum sfactorA,
+ GLenum dfactorA )
+{
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s -> RGB(%s, %s) A(%s, %s)\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(sfactorRGB),
+ _mesa_lookup_enum_by_nr(dfactorRGB),
+ _mesa_lookup_enum_by_nr(sfactorA),
+ _mesa_lookup_enum_by_nr(dfactorA));
+
+ (void) sfactorRGB;
+ (void) dfactorRGB;
+ (void) sfactorA;
+ (void) dfactorA;
+ i830_set_blend_state( ctx );
+}
+
+
+
+static void i830DepthFunc(GLcontext *ctx, GLenum func)
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ int test = intel_translate_compare_func(func);
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_STATE3] &= ~DEPTH_TEST_FUNC_MASK;
+ i830->state.Ctx[I830_CTXREG_STATE3] |= (ENABLE_DEPTH_TEST_FUNC |
+ DEPTH_TEST_FUNC(test));
+}
+
+static void i830DepthMask(GLcontext *ctx, GLboolean flag)
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s flag (%d)\n", __FUNCTION__, flag);
+
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+
+ i830->state.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_DIS_DEPTH_WRITE_MASK;
+
+ if (flag && ctx->Depth.Test)
+ i830->state.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_DEPTH_WRITE;
+ else
+ i830->state.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_DEPTH_WRITE;
+}
+
+/* =============================================================
+ * Polygon stipple
+ *
+ * The i830 supports a 4x4 stipple natively, GL wants 32x32.
+ * Fortunately stipple is usually a repeating pattern.
+ */
+static void i830PolygonStipple( GLcontext *ctx, const GLubyte *mask )
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ const GLubyte *m = mask;
+ GLubyte p[4];
+ int i,j,k;
+ int active = (ctx->Polygon.StippleFlag &&
+ i830->intel.reduced_primitive == GL_TRIANGLES);
+ GLuint newMask;
+
+ if (active) {
+ I830_STATECHANGE(i830, I830_UPLOAD_STIPPLE);
+ i830->state.Stipple[I830_STPREG_ST1] &= ~ST1_ENABLE;
+ }
+
+ p[0] = mask[12] & 0xf; p[0] |= p[0] << 4;
+ p[1] = mask[8] & 0xf; p[1] |= p[1] << 4;
+ p[2] = mask[4] & 0xf; p[2] |= p[2] << 4;
+ p[3] = mask[0] & 0xf; p[3] |= p[3] << 4;
+
+ for (k = 0 ; k < 8 ; k++)
+ for (j = 3 ; j >= 0; j--)
+ for (i = 0 ; i < 4 ; i++, m++)
+ if (*m != p[j]) {
+ i830->intel.hw_stipple = 0;
+ return;
+ }
+
+ newMask = (((p[0] & 0xf) << 0) |
+ ((p[1] & 0xf) << 4) |
+ ((p[2] & 0xf) << 8) |
+ ((p[3] & 0xf) << 12));
+
+
+ if (newMask == 0xffff || newMask == 0x0) {
+ /* this is needed to make conform pass */
+ i830->intel.hw_stipple = 0;
+ return;
+ }
+
+ i830->state.Stipple[I830_STPREG_ST1] &= ~0xffff;
+ i830->state.Stipple[I830_STPREG_ST1] |= newMask;
+ i830->intel.hw_stipple = 1;
+
+ if (active)
+ i830->state.Stipple[I830_STPREG_ST1] |= ST1_ENABLE;
+}
+
+
+/* =============================================================
+ * Hardware clipping
+ */
+static void i830Scissor(GLcontext *ctx, GLint x, GLint y,
+ GLsizei w, GLsizei h)
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ intelScreenPrivate *screen = i830->intel.intelScreen;
+ int x1, y1, x2, y2;
+
+ if (!i830->intel.driDrawable)
+ return;
+
+ x1 = x;
+ y1 = i830->intel.driDrawable->h - (y + h);
+ x2 = x + w - 1;
+ y2 = y1 + h - 1;
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "[%s] x(%d) y(%d) w(%d) h(%d)\n", __FUNCTION__,
+ x, y, w, h);
+
+ if (x1 < 0) x1 = 0;
+ if (y1 < 0) y1 = 0;
+ if (x2 < 0) x2 = 0;
+ if (y2 < 0) y2 = 0;
+
+ if (x2 >= screen->width) x2 = screen->width-1;
+ if (y2 >= screen->height) y2 = screen->height-1;
+ if (x1 >= screen->width) x1 = screen->width-1;
+ if (y1 >= screen->height) y1 = screen->height-1;
+
+
+ I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS);
+ i830->state.Buffer[I830_DESTREG_SR1] = (y1 << 16) | (x1 & 0xffff);
+ i830->state.Buffer[I830_DESTREG_SR2] = (y2 << 16) | (x2 & 0xffff);
+}
+
+static void i830LogicOp(GLcontext *ctx, GLenum opcode)
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ int tmp = intel_translate_logic_op( opcode );
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_STATE4] &= ~LOGICOP_MASK;
+ i830->state.Ctx[I830_CTXREG_STATE4] |= LOGIC_OP_FUNC(tmp);
+}
+
+
+
+static void i830CullFaceFrontFace(GLcontext *ctx, GLenum unused)
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ GLuint mode;
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (!ctx->Polygon.CullFlag) {
+ mode = CULLMODE_NONE;
+ }
+ else if (ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK) {
+ mode = CULLMODE_CW;
+
+ if (ctx->Polygon.CullFaceMode == GL_FRONT)
+ mode ^= (CULLMODE_CW ^ CULLMODE_CCW);
+ if (ctx->Polygon.FrontFace != GL_CCW)
+ mode ^= (CULLMODE_CW ^ CULLMODE_CCW);
+ }
+ else {
+ mode = CULLMODE_BOTH;
+ }
+
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_STATE3] &= ~CULLMODE_MASK;
+ i830->state.Ctx[I830_CTXREG_STATE3] |= ENABLE_CULL_MODE | mode;
+}
+
+static void i830LineWidth( GLcontext *ctx, GLfloat widthf )
+{
+ i830ContextPtr i830 = I830_CONTEXT( ctx );
+ int width;
+ int state5;
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ width = (int)(widthf * 2);
+ CLAMP_SELF(width, 1, 15);
+
+ state5 = i830->state.Ctx[I830_CTXREG_STATE5] & ~FIXED_LINE_WIDTH_MASK;
+ state5 |= (ENABLE_FIXED_LINE_WIDTH | FIXED_LINE_WIDTH(width));
+
+ if (state5 != i830->state.Ctx[I830_CTXREG_STATE5]) {
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_STATE5] = state5;
+ }
+}
+
+static void i830PointSize(GLcontext *ctx, GLfloat size)
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ GLint point_size = (int)size;
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ CLAMP_SELF(point_size, 1, 256);
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_STATE5] &= ~FIXED_POINT_WIDTH_MASK;
+ i830->state.Ctx[I830_CTXREG_STATE5] |= (ENABLE_FIXED_POINT_WIDTH |
+ FIXED_POINT_WIDTH(point_size));
+}
+
+
+/* =============================================================
+ * Color masks
+ */
+
+static void i830ColorMask(GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a)
+{
+ i830ContextPtr i830 = I830_CONTEXT( ctx );
+ GLuint tmp = 0;
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s r(%d) g(%d) b(%d) a(%d)\n", __FUNCTION__, r, g, b, a);
+
+ tmp = ((i830->state.Ctx[I830_CTXREG_ENABLES_2] & ~WRITEMASK_MASK) |
+ ENABLE_COLOR_MASK |
+ ENABLE_COLOR_WRITE |
+ ((!r) << WRITEMASK_RED_SHIFT) |
+ ((!g) << WRITEMASK_GREEN_SHIFT) |
+ ((!b) << WRITEMASK_BLUE_SHIFT) |
+ ((!a) << WRITEMASK_ALPHA_SHIFT));
+
+ if (tmp != i830->state.Ctx[I830_CTXREG_ENABLES_2]) {
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_ENABLES_2] = tmp;
+ }
+}
+
+static void update_specular( GLcontext *ctx )
+{
+ i830ContextPtr i830 = I830_CONTEXT( ctx );
+
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_SPEC_ADD_MASK;
+
+ if (NEED_SECONDARY_COLOR(ctx))
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_SPEC_ADD;
+ else
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_SPEC_ADD;
+}
+
+static void i830LightModelfv(GLcontext *ctx, GLenum pname,
+ const GLfloat *param)
+{
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) {
+ update_specular( ctx );
+ }
+}
+
+/* In Mesa 3.5 we can reliably do native flatshading.
+ */
+static void i830ShadeModel(GLcontext *ctx, GLenum mode)
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+
+
+#define SHADE_MODE_MASK ((1<<10)|(1<<8)|(1<<6)|(1<<4))
+
+ i830->state.Ctx[I830_CTXREG_STATE3] &= ~SHADE_MODE_MASK;
+
+ if (mode == GL_FLAT) {
+ i830->state.Ctx[I830_CTXREG_STATE3] |= (ALPHA_SHADE_MODE(SHADE_MODE_FLAT) |
+ FOG_SHADE_MODE(SHADE_MODE_FLAT) |
+ SPEC_SHADE_MODE(SHADE_MODE_FLAT) |
+ COLOR_SHADE_MODE(SHADE_MODE_FLAT));
+ } else {
+ i830->state.Ctx[I830_CTXREG_STATE3] |= (ALPHA_SHADE_MODE(SHADE_MODE_LINEAR) |
+ FOG_SHADE_MODE(SHADE_MODE_LINEAR) |
+ SPEC_SHADE_MODE(SHADE_MODE_LINEAR) |
+ COLOR_SHADE_MODE(SHADE_MODE_LINEAR));
+ }
+}
+
+/* =============================================================
+ * Fog
+ */
+static void i830Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (pname == GL_FOG_COLOR) {
+ GLuint color = (((GLubyte)(ctx->Fog.Color[0]*255.0F) << 16) |
+ ((GLubyte)(ctx->Fog.Color[1]*255.0F) << 8) |
+ ((GLubyte)(ctx->Fog.Color[2]*255.0F) << 0));
+
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_FOGCOLOR] = (_3DSTATE_FOG_COLOR_CMD | color);
+ }
+}
+
+/* =============================================================
+ */
+
+static void i830Enable(GLcontext *ctx, GLenum cap, GLboolean state)
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+
+ switch(cap) {
+ case GL_LIGHTING:
+ case GL_COLOR_SUM:
+ update_specular( ctx );
+ break;
+
+ case GL_ALPHA_TEST:
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_ALPHA_TEST_MASK;
+ if (state)
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_ALPHA_TEST;
+ else
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_ALPHA_TEST;
+
+ break;
+
+ case GL_BLEND:
+ i830EvalLogicOpBlendState(ctx);
+ break;
+
+ case GL_COLOR_LOGIC_OP:
+ i830EvalLogicOpBlendState(ctx);
+
+ /* Logicop doesn't seem to work at 16bpp:
+ */
+ if (i830->intel.intelScreen->cpp == 2)
+ FALLBACK( &i830->intel, I830_FALLBACK_LOGICOP, state );
+ break;
+
+ case GL_DITHER:
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_DITHER;
+
+ if (state)
+ i830->state.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_DITHER;
+ else
+ i830->state.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_DITHER;
+ break;
+
+ case GL_DEPTH_TEST:
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_DEPTH_TEST_MASK;
+
+ if (state)
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_DEPTH_TEST;
+ else
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_DEPTH_TEST;
+
+ /* Also turn off depth writes when GL_DEPTH_TEST is disabled:
+ */
+ i830DepthMask( ctx, ctx->Depth.Mask );
+ break;
+
+ case GL_SCISSOR_TEST:
+ I830_STATECHANGE(i830, I830_UPLOAD_BUFFERS);
+
+ if (state)
+ i830->state.Buffer[I830_DESTREG_SENABLE] =
+ (_3DSTATE_SCISSOR_ENABLE_CMD |
+ ENABLE_SCISSOR_RECT);
+ else
+ i830->state.Buffer[I830_DESTREG_SENABLE] =
+ (_3DSTATE_SCISSOR_ENABLE_CMD |
+ DISABLE_SCISSOR_RECT);
+
+ break;
+
+ case GL_LINE_SMOOTH:
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+
+ i830->state.Ctx[I830_CTXREG_AA] &= ~AA_LINE_ENABLE;
+ if (state)
+ i830->state.Ctx[I830_CTXREG_AA] |= AA_LINE_ENABLE;
+ else
+ i830->state.Ctx[I830_CTXREG_AA] |= AA_LINE_DISABLE;
+ break;
+
+ case GL_FOG:
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_DIS_FOG_MASK;
+ if (state)
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_FOG;
+ else
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_FOG;
+ break;
+
+ case GL_CULL_FACE:
+ i830CullFaceFrontFace(ctx, 0);
+ break;
+
+ case GL_TEXTURE_2D:
+ break;
+
+ case GL_STENCIL_TEST:
+ if (i830->intel.hw_stencil) {
+ I830_STATECHANGE(i830, I830_UPLOAD_CTX);
+
+ if (state) {
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] |= ENABLE_STENCIL_TEST;
+ i830->state.Ctx[I830_CTXREG_ENABLES_2] |= ENABLE_STENCIL_WRITE;
+ } else {
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] &= ~ENABLE_STENCIL_TEST;
+ i830->state.Ctx[I830_CTXREG_ENABLES_2] &= ~ENABLE_STENCIL_WRITE;
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] |= DISABLE_STENCIL_TEST;
+ i830->state.Ctx[I830_CTXREG_ENABLES_2] |= DISABLE_STENCIL_WRITE;
+ }
+ } else {
+ FALLBACK( &i830->intel, I830_FALLBACK_STENCIL, state );
+ }
+ break;
+
+ case GL_POLYGON_STIPPLE:
+ /* The stipple command worked on my 855GM box, but not my 845G.
+ * I'll do more testing later to find out exactly which hardware
+ * supports it. Disabled for now.
+ */
+ if (i830->intel.hw_stipple &&
+ i830->intel.reduced_primitive == GL_TRIANGLES)
+ {
+ I830_STATECHANGE(i830, I830_UPLOAD_STIPPLE);
+ i830->state.Stipple[I830_STPREG_ST1] &= ~ST1_ENABLE;
+ if (state)
+ i830->state.Stipple[I830_STPREG_ST1] |= ST1_ENABLE;
+ }
+ break;
+
+ default:
+ ;
+ }
+}
+
+
+static void i830_init_packets( i830ContextPtr i830 )
+{
+ intelScreenPrivate *screen = i830->intel.intelScreen;
+
+ /* Zero all state */
+ memset(&i830->state, 0, sizeof(i830->state));
+
+ /* Set default blend state */
+ i830->state.TexBlend[0][0] = (_3DSTATE_MAP_BLEND_OP_CMD(0) |
+ TEXPIPE_COLOR |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ DISABLE_TEX_CNTRL_STAGE |
+ TEXOP_SCALE_1X |
+ TEXOP_MODIFY_PARMS |
+ TEXOP_LAST_STAGE |
+ TEXBLENDOP_ARG1);
+ i830->state.TexBlend[0][1] = (_3DSTATE_MAP_BLEND_OP_CMD(0) |
+ TEXPIPE_ALPHA |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ TEXOP_SCALE_1X |
+ TEXOP_MODIFY_PARMS |
+ TEXBLENDOP_ARG1);
+ i830->state.TexBlend[0][2] = (_3DSTATE_MAP_BLEND_ARG_CMD(0) |
+ TEXPIPE_COLOR |
+ TEXBLEND_ARG1 |
+ TEXBLENDARG_MODIFY_PARMS |
+ TEXBLENDARG_DIFFUSE);
+ i830->state.TexBlend[0][3] = (_3DSTATE_MAP_BLEND_ARG_CMD(0) |
+ TEXPIPE_ALPHA |
+ TEXBLEND_ARG1 |
+ TEXBLENDARG_MODIFY_PARMS |
+ TEXBLENDARG_DIFFUSE);
+
+ i830->state.TexBlendWordsUsed[0] = 4;
+
+
+ i830->state.Ctx[I830_CTXREG_VF] = 0;
+ i830->state.Ctx[I830_CTXREG_VF2] = 0;
+
+ i830->state.Ctx[I830_CTXREG_AA] = (_3DSTATE_AA_CMD |
+ AA_LINE_ECAAR_WIDTH_ENABLE |
+ AA_LINE_ECAAR_WIDTH_1_0 |
+ AA_LINE_REGION_WIDTH_ENABLE |
+ AA_LINE_REGION_WIDTH_1_0 |
+ AA_LINE_DISABLE);
+
+ i830->state.Ctx[I830_CTXREG_ENABLES_1] = (_3DSTATE_ENABLES_1_CMD |
+ DISABLE_LOGIC_OP |
+ DISABLE_STENCIL_TEST |
+ DISABLE_DEPTH_BIAS |
+ DISABLE_SPEC_ADD |
+ DISABLE_FOG |
+ DISABLE_ALPHA_TEST |
+ DISABLE_COLOR_BLEND |
+ DISABLE_DEPTH_TEST);
+
+ if (i830->intel.hw_stencil) {
+ i830->state.Ctx[I830_CTXREG_ENABLES_2] = (_3DSTATE_ENABLES_2_CMD |
+ ENABLE_STENCIL_WRITE |
+ ENABLE_TEX_CACHE |
+ ENABLE_DITHER |
+ ENABLE_COLOR_MASK |
+ /* set no color comps disabled */
+ ENABLE_COLOR_WRITE |
+ ENABLE_DEPTH_WRITE);
+ } else {
+ i830->state.Ctx[I830_CTXREG_ENABLES_2] = (_3DSTATE_ENABLES_2_CMD |
+ DISABLE_STENCIL_WRITE |
+ ENABLE_TEX_CACHE |
+ ENABLE_DITHER |
+ ENABLE_COLOR_MASK |
+ /* set no color comps disabled */
+ ENABLE_COLOR_WRITE |
+ ENABLE_DEPTH_WRITE);
+ }
+
+ i830->state.Ctx[I830_CTXREG_STATE1] = (_3DSTATE_MODES_1_CMD |
+ ENABLE_COLR_BLND_FUNC |
+ BLENDFUNC_ADD |
+ ENABLE_SRC_BLND_FACTOR |
+ SRC_BLND_FACT(BLENDFACT_ONE) |
+ ENABLE_DST_BLND_FACTOR |
+ DST_BLND_FACT(BLENDFACT_ZERO) );
+
+ i830->state.Ctx[I830_CTXREG_STATE2] = (_3DSTATE_MODES_2_CMD |
+ ENABLE_GLOBAL_DEPTH_BIAS |
+ GLOBAL_DEPTH_BIAS(0) |
+ ENABLE_ALPHA_TEST_FUNC |
+ ALPHA_TEST_FUNC(COMPAREFUNC_ALWAYS) |
+ ALPHA_REF_VALUE(0) );
+
+ i830->state.Ctx[I830_CTXREG_STATE3] = (_3DSTATE_MODES_3_CMD |
+ ENABLE_DEPTH_TEST_FUNC |
+ DEPTH_TEST_FUNC(COMPAREFUNC_LESS) |
+ ENABLE_ALPHA_SHADE_MODE |
+ ALPHA_SHADE_MODE(SHADE_MODE_LINEAR) |
+ ENABLE_FOG_SHADE_MODE |
+ FOG_SHADE_MODE(SHADE_MODE_LINEAR) |
+ ENABLE_SPEC_SHADE_MODE |
+ SPEC_SHADE_MODE(SHADE_MODE_LINEAR) |
+ ENABLE_COLOR_SHADE_MODE |
+ COLOR_SHADE_MODE(SHADE_MODE_LINEAR) |
+ ENABLE_CULL_MODE |
+ CULLMODE_NONE);
+
+ i830->state.Ctx[I830_CTXREG_STATE4] = (_3DSTATE_MODES_4_CMD |
+ ENABLE_LOGIC_OP_FUNC |
+ LOGIC_OP_FUNC(LOGICOP_COPY) |
+ ENABLE_STENCIL_TEST_MASK |
+ STENCIL_TEST_MASK(0xff) |
+ ENABLE_STENCIL_WRITE_MASK |
+ STENCIL_WRITE_MASK(0xff));
+
+ i830->state.Ctx[I830_CTXREG_STENCILTST] = (_3DSTATE_STENCIL_TEST_CMD |
+ ENABLE_STENCIL_PARMS |
+ STENCIL_FAIL_OP(STENCILOP_KEEP) |
+ STENCIL_PASS_DEPTH_FAIL_OP(STENCILOP_KEEP) |
+ STENCIL_PASS_DEPTH_PASS_OP(STENCILOP_KEEP) |
+ ENABLE_STENCIL_TEST_FUNC |
+ STENCIL_TEST_FUNC(COMPAREFUNC_ALWAYS) |
+ ENABLE_STENCIL_REF_VALUE |
+ STENCIL_REF_VALUE(0) );
+
+ i830->state.Ctx[I830_CTXREG_STATE5] = (_3DSTATE_MODES_5_CMD |
+ FLUSH_TEXTURE_CACHE |
+ ENABLE_SPRITE_POINT_TEX |
+ SPRITE_POINT_TEX_OFF |
+ ENABLE_FIXED_LINE_WIDTH |
+ FIXED_LINE_WIDTH(0x2) | /* 1.0 */
+ ENABLE_FIXED_POINT_WIDTH |
+ FIXED_POINT_WIDTH(1) );
+
+ i830->state.Ctx[I830_CTXREG_IALPHAB] = (_3DSTATE_INDPT_ALPHA_BLEND_CMD |
+ DISABLE_INDPT_ALPHA_BLEND |
+ ENABLE_ALPHA_BLENDFUNC |
+ ABLENDFUNC_ADD);
+
+ i830->state.Ctx[I830_CTXREG_FOGCOLOR] = (_3DSTATE_FOG_COLOR_CMD |
+ FOG_COLOR_RED(0) |
+ FOG_COLOR_GREEN(0) |
+ FOG_COLOR_BLUE(0));
+
+ i830->state.Ctx[I830_CTXREG_BLENDCOLOR0] = _3DSTATE_CONST_BLEND_COLOR_CMD;
+ i830->state.Ctx[I830_CTXREG_BLENDCOLOR1] = 0;
+
+ i830->state.Ctx[I830_CTXREG_MCSB0] = _3DSTATE_MAP_COORD_SETBIND_CMD;
+ i830->state.Ctx[I830_CTXREG_MCSB1] = (TEXBIND_SET3(TEXCOORDSRC_VTXSET_3) |
+ TEXBIND_SET2(TEXCOORDSRC_VTXSET_2) |
+ TEXBIND_SET1(TEXCOORDSRC_VTXSET_1) |
+ TEXBIND_SET0(TEXCOORDSRC_VTXSET_0));
+
+
+ i830->state.Stipple[I830_STPREG_ST0] = _3DSTATE_STIPPLE;
+
+ i830->state.Buffer[I830_DESTREG_CBUFADDR0] = _3DSTATE_BUF_INFO_CMD;
+ i830->state.Buffer[I830_DESTREG_CBUFADDR1] =
+ (BUF_3D_ID_COLOR_BACK |
+ BUF_3D_PITCH(screen->frontPitch * screen->cpp) |
+ BUF_3D_USE_FENCE);
+
+
+ i830->state.Buffer[I830_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD;
+ i830->state.Buffer[I830_DESTREG_DBUFADDR1] =
+ (BUF_3D_ID_DEPTH |
+ BUF_3D_PITCH(screen->depthPitch * screen->cpp) |
+ BUF_3D_USE_FENCE);
+ i830->state.Buffer[I830_DESTREG_DBUFADDR2] = screen->depthOffset;
+
+
+ i830->state.Buffer[I830_DESTREG_DV0] = _3DSTATE_DST_BUF_VARS_CMD;
+
+ switch (screen->fbFormat) {
+ case DV_PF_555:
+ case DV_PF_565:
+ i830->state.Buffer[I830_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */
+ DSTORG_VERT_BIAS(0x8) | /* .5 */
+ screen->fbFormat |
+ DEPTH_IS_Z |
+ DEPTH_FRMT_16_FIXED);
+ break;
+ case DV_PF_8888:
+ i830->state.Buffer[I830_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */
+ DSTORG_VERT_BIAS(0x8) | /* .5 */
+ screen->fbFormat |
+ DEPTH_IS_Z |
+ DEPTH_FRMT_24_FIXED_8_OTHER);
+ break;
+ }
+
+ i830->state.Buffer[I830_DESTREG_SENABLE] = (_3DSTATE_SCISSOR_ENABLE_CMD |
+ DISABLE_SCISSOR_RECT);
+ i830->state.Buffer[I830_DESTREG_SR0] = _3DSTATE_SCISSOR_RECT_0_CMD;
+ i830->state.Buffer[I830_DESTREG_SR1] = 0;
+ i830->state.Buffer[I830_DESTREG_SR2] = 0;
+}
+
+
+void i830InitStateFuncs( struct dd_function_table *functions )
+{
+ functions->AlphaFunc = i830AlphaFunc;
+ functions->BlendColor = i830BlendColor;
+ functions->BlendEquationSeparate = i830BlendEquationSeparate;
+ functions->BlendFuncSeparate = i830BlendFuncSeparate;
+ functions->ColorMask = i830ColorMask;
+ functions->CullFace = i830CullFaceFrontFace;
+ functions->DepthFunc = i830DepthFunc;
+ functions->DepthMask = i830DepthMask;
+ functions->Enable = i830Enable;
+ functions->Fogfv = i830Fogfv;
+ functions->FrontFace = i830CullFaceFrontFace;
+ functions->LightModelfv = i830LightModelfv;
+ functions->LineWidth = i830LineWidth;
+ functions->LogicOpcode = i830LogicOp;
+ functions->PointSize = i830PointSize;
+ functions->PolygonStipple = i830PolygonStipple;
+ functions->Scissor = i830Scissor;
+ functions->ShadeModel = i830ShadeModel;
+ functions->StencilFunc = i830StencilFunc;
+ functions->StencilMask = i830StencilMask;
+ functions->StencilOp = i830StencilOp;
+}
+
+void i830InitState( i830ContextPtr i830 )
+{
+ GLcontext *ctx = &i830->intel.ctx;
+
+ i830_init_packets( i830 );
+
+ intelInitState( ctx );
+
+ memcpy( &i830->initial, &i830->state, sizeof(i830->state) );
+
+ i830->current = &i830->state;
+ i830->state.emitted = 0;
+ i830->state.active = (I830_UPLOAD_TEXBLEND(0) |
+ I830_UPLOAD_STIPPLE |
+ I830_UPLOAD_CTX |
+ I830_UPLOAD_BUFFERS);
+}
+
+
+
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_tex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_tex.c
new file mode 100644
index 000000000..d56a4df8b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_tex.c
@@ -0,0 +1,345 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "imports.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "image.h"
+#include "texstore.h"
+#include "texformat.h"
+#include "texmem.h"
+#include "swrast/swrast.h"
+
+#include "mm.h"
+
+#include "intel_ioctl.h"
+
+#include "i830_context.h"
+#include "i830_reg.h"
+
+
+
+
+/**
+ * Set the texture wrap modes.
+ *
+ * The i830M (and related graphics cores) do not support GL_CLAMP. The Intel
+ * drivers for "other operating systems" implement GL_CLAMP as
+ * GL_CLAMP_TO_EDGE, so the same is done here.
+ *
+ * \param t Texture object whose wrap modes are to be set
+ * \param swrap Wrap mode for the \a s texture coordinate
+ * \param twrap Wrap mode for the \a t texture coordinate
+ */
+static void i830SetTexWrapping(i830TextureObjectPtr tex,
+ GLenum swrap,
+ GLenum twrap)
+{
+ tex->Setup[I830_TEXREG_MCS] &= ~(TEXCOORD_ADDR_U_MASK|TEXCOORD_ADDR_V_MASK);
+
+ switch( swrap ) {
+ case GL_REPEAT:
+ tex->Setup[I830_TEXREG_MCS] |= TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_WRAP);
+ break;
+ case GL_CLAMP:
+ case GL_CLAMP_TO_EDGE:
+ tex->Setup[I830_TEXREG_MCS] |= TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_CLAMP);
+ break;
+ case GL_CLAMP_TO_BORDER:
+ tex->Setup[I830_TEXREG_MCS] |=
+ TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_CLAMP_BORDER);
+ break;
+ case GL_MIRRORED_REPEAT:
+ tex->Setup[I830_TEXREG_MCS] |=
+ TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_MIRROR);
+ break;
+ default:
+ break;
+ }
+
+ switch( twrap ) {
+ case GL_REPEAT:
+ tex->Setup[I830_TEXREG_MCS] |= TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_WRAP);
+ break;
+ case GL_CLAMP:
+ case GL_CLAMP_TO_EDGE:
+ tex->Setup[I830_TEXREG_MCS] |= TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_CLAMP);
+ break;
+ case GL_CLAMP_TO_BORDER:
+ tex->Setup[I830_TEXREG_MCS] |=
+ TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_CLAMP_BORDER);
+ break;
+ case GL_MIRRORED_REPEAT:
+ tex->Setup[I830_TEXREG_MCS] |=
+ TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_MIRROR);
+ break;
+ default:
+ break;
+ }
+}
+
+
+/**
+ * Set the texture magnification and minification modes.
+ *
+ * \param t Texture whose filter modes are to be set
+ * \param minf Texture minification mode
+ * \param magf Texture magnification mode
+ * \param bias LOD bias for this texture unit.
+ */
+
+static void i830SetTexFilter( i830TextureObjectPtr t, GLenum minf, GLenum magf,
+ GLfloat maxanisotropy )
+{
+ int minFilt = 0, mipFilt = 0, magFilt = 0;
+
+ if(INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if ( maxanisotropy > 1.0 ) {
+ minFilt = FILTER_ANISOTROPIC;
+ magFilt = FILTER_ANISOTROPIC;
+ }
+ else {
+ switch (minf) {
+ case GL_NEAREST:
+ minFilt = FILTER_NEAREST;
+ mipFilt = MIPFILTER_NONE;
+ break;
+ case GL_LINEAR:
+ minFilt = FILTER_LINEAR;
+ mipFilt = MIPFILTER_NONE;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ minFilt = FILTER_NEAREST;
+ mipFilt = MIPFILTER_NEAREST;
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ minFilt = FILTER_LINEAR;
+ mipFilt = MIPFILTER_NEAREST;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ minFilt = FILTER_NEAREST;
+ mipFilt = MIPFILTER_LINEAR;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ minFilt = FILTER_LINEAR;
+ mipFilt = MIPFILTER_LINEAR;
+ break;
+ default:
+ break;
+ }
+
+ switch (magf) {
+ case GL_NEAREST:
+ magFilt = FILTER_NEAREST;
+ break;
+ case GL_LINEAR:
+ magFilt = FILTER_LINEAR;
+ break;
+ default:
+ break;
+ }
+ }
+
+ t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MIN_FILTER_MASK;
+ t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MIP_FILTER_MASK;
+ t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MAG_FILTER_MASK;
+ t->Setup[I830_TEXREG_TM0S3] |= ((minFilt << TM0S3_MIN_FILTER_SHIFT) |
+ (mipFilt << TM0S3_MIP_FILTER_SHIFT) |
+ (magFilt << TM0S3_MAG_FILTER_SHIFT));
+}
+
+static void i830SetTexBorderColor(i830TextureObjectPtr t, GLubyte color[4])
+{
+ if(INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ t->Setup[I830_TEXREG_TM0S4] =
+ INTEL_PACKCOLOR8888(color[0],color[1],color[2],color[3]);
+}
+
+
+/**
+ * Allocate space for and load the mesa images into the texture memory block.
+ * This will happen before drawing with a new texture, or drawing with a
+ * texture after it was swapped out or teximaged again.
+ */
+
+intelTextureObjectPtr i830AllocTexObj( struct gl_texture_object *texObj )
+{
+ i830TextureObjectPtr t = CALLOC_STRUCT( i830_texture_object );
+ if ( !t )
+ return NULL;
+
+ texObj->DriverData = t;
+ t->intel.base.tObj = texObj;
+ t->intel.dirty = I830_UPLOAD_TEX_ALL;
+ make_empty_list( &t->intel.base );
+
+ t->Setup[I830_TEXREG_TM0LI] = 0; /* not used */
+ t->Setup[I830_TEXREG_TM0S0] = 0;
+ t->Setup[I830_TEXREG_TM0S1] = 0;
+ t->Setup[I830_TEXREG_TM0S2] = 0;
+ t->Setup[I830_TEXREG_TM0S3] = 0;
+ t->Setup[I830_TEXREG_MCS] = (_3DSTATE_MAP_COORD_SET_CMD |
+ MAP_UNIT(0) |
+ ENABLE_TEXCOORD_PARAMS |
+ TEXCOORDS_ARE_NORMAL |
+ TEXCOORDTYPE_CARTESIAN |
+ ENABLE_ADDR_V_CNTL |
+ TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_WRAP) |
+ ENABLE_ADDR_U_CNTL |
+ TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_WRAP));
+
+
+ i830SetTexWrapping( t, texObj->WrapS, texObj->WrapT );
+ i830SetTexFilter( t, texObj->MinFilter, texObj->MagFilter,
+ texObj->MaxAnisotropy );
+ i830SetTexBorderColor( t, texObj->_BorderChan );
+
+ return &t->intel;
+}
+
+
+static void i830TexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat *params )
+{
+ i830TextureObjectPtr t = (i830TextureObjectPtr) tObj->DriverData;
+ if (!t)
+ return;
+
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+ i830SetTexFilter( t, tObj->MinFilter, tObj->MagFilter,
+ tObj->MaxAnisotropy);
+ break;
+
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ i830SetTexWrapping( t, tObj->WrapS, tObj->WrapT );
+ break;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ i830SetTexBorderColor( t, tObj->_BorderChan );
+ break;
+
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ /* The i830 and its successors can do a lot of this without
+ * reloading the textures. A project for someone?
+ */
+ intelFlush( ctx );
+ driSwapOutTextureObject( (driTextureObject *) t );
+ break;
+
+ default:
+ return;
+ }
+
+ t->intel.dirty = I830_UPLOAD_TEX_ALL;
+}
+
+
+static void i830TexEnv( GLcontext *ctx, GLenum target,
+ GLenum pname, const GLfloat *param )
+{
+ i830ContextPtr i830 = I830_CONTEXT( ctx );
+ GLuint unit = ctx->Texture.CurrentUnit;
+
+ switch (pname) {
+ case GL_TEXTURE_ENV_COLOR:
+#if 0
+ {
+ GLubyte r, g, b, a;
+ GLuint col;
+
+ UNCLAMPED_FLOAT_TO_UBYTE(r, param[RCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(g, param[GCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(b, param[BCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(a, param[ACOMP]);
+
+ col = ((a << 24) | (r << 16) | (g << 8) | b);
+
+ if (col != i830->state.TexEnv[unit][I830_TEXENVREG_COL1]) {
+ I830_STATECHANGE(i830, I830_UPLOAD_TEXENV);
+ i830->state.TexEnv[unit][I830_TEXENVREG_COL1] = col;
+ }
+
+ break;
+ }
+#endif
+ case GL_TEXTURE_ENV_MODE:
+ case GL_COMBINE_RGB:
+ case GL_COMBINE_ALPHA:
+ case GL_SOURCE0_RGB:
+ case GL_SOURCE1_RGB:
+ case GL_SOURCE2_RGB:
+ case GL_SOURCE0_ALPHA:
+ case GL_SOURCE1_ALPHA:
+ case GL_SOURCE2_ALPHA:
+ case GL_OPERAND0_RGB:
+ case GL_OPERAND1_RGB:
+ case GL_OPERAND2_RGB:
+ case GL_OPERAND0_ALPHA:
+ case GL_OPERAND1_ALPHA:
+ case GL_OPERAND2_ALPHA:
+ case GL_RGB_SCALE:
+ case GL_ALPHA_SCALE:
+ break;
+
+ case GL_TEXTURE_LOD_BIAS: {
+ int b = (int) ((*param) * 16.0);
+ if (b > 63) b = 63;
+ if (b < -64) b = -64;
+ I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit));
+ i830->state.Tex[unit][I830_TEXREG_TM0S3] &= ~TM0S3_LOD_BIAS_MASK;
+ i830->state.Tex[unit][I830_TEXREG_TM0S3] |=
+ ((b << TM0S3_LOD_BIAS_SHIFT) & TM0S3_LOD_BIAS_MASK);
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+
+
+
+void i830InitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->TexEnv = i830TexEnv;
+ functions->TexParameter = i830TexParameter;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_texblend.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_texblend.c
new file mode 100644
index 000000000..49e034764
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_texblend.c
@@ -0,0 +1,465 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "texformat.h"
+#include "texstore.h"
+
+#include "mm.h"
+
+#include "intel_screen.h"
+#include "intel_ioctl.h"
+#include "intel_tex.h"
+
+#include "i830_context.h"
+#include "i830_reg.h"
+
+
+/* ================================================================
+ * Texture combine functions
+ */
+static GLuint pass_through( GLuint *state, GLuint blendUnit )
+{
+ state[0] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
+ TEXPIPE_COLOR |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ DISABLE_TEX_CNTRL_STAGE |
+ TEXOP_SCALE_1X |
+ TEXOP_MODIFY_PARMS |
+ TEXBLENDOP_ARG1);
+ state[1] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
+ TEXPIPE_ALPHA |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ TEXOP_SCALE_1X |
+ TEXOP_MODIFY_PARMS |
+ TEXBLENDOP_ARG1);
+ state[2] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
+ TEXPIPE_COLOR |
+ TEXBLEND_ARG1 |
+ TEXBLENDARG_MODIFY_PARMS |
+ TEXBLENDARG_CURRENT);
+ state[3] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
+ TEXPIPE_ALPHA |
+ TEXBLEND_ARG1 |
+ TEXBLENDARG_MODIFY_PARMS |
+ TEXBLENDARG_CURRENT);
+
+ return 4;
+}
+
+static GLuint emit_factor( GLuint blendUnit, GLuint *state, GLuint count,
+ const GLfloat *factor )
+{
+ GLubyte r, g, b, a;
+ GLuint col;
+
+ if (0)
+ fprintf(stderr, "emit constant %d: %.2f %.2f %.2f %.2f\n",
+ blendUnit, factor[0], factor[1], factor[2], factor[3]);
+
+ UNCLAMPED_FLOAT_TO_UBYTE(r, factor[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(g, factor[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(b, factor[2]);
+ UNCLAMPED_FLOAT_TO_UBYTE(a, factor[3]);
+
+ col = ((a << 24) | (r << 16) | (g << 8) | b);
+
+ state[count++] = _3DSTATE_COLOR_FACTOR_N_CMD(blendUnit);
+ state[count++] = col;
+
+ return count;
+}
+
+
+static __inline__ GLuint GetTexelOp(GLint unit)
+{
+ switch(unit) {
+ case 0: return TEXBLENDARG_TEXEL0;
+ case 1: return TEXBLENDARG_TEXEL1;
+ case 2: return TEXBLENDARG_TEXEL2;
+ case 3: return TEXBLENDARG_TEXEL3;
+ default: return TEXBLENDARG_TEXEL0;
+ }
+}
+
+
+/**
+ * Calculate the hardware instuctions to setup the current texture enviromnemt
+ * settings. Since \c gl_texture_unit::_CurrentCombine is used, both
+ * "classic" texture enviroments and GL_ARB_texture_env_combine type texture
+ * environments are treated identically.
+ *
+ * \todo
+ * This function should return \c GLboolean. When \c GL_FALSE is returned,
+ * it means that an environment is selected that the hardware cannot do. This
+ * is the way the Radeon and R200 drivers work.
+ *
+ * \todo
+ * Looking at i830_3d_regs.h, it seems the i830 can do part of
+ * GL_ATI_texture_env_combine3. It can handle using \c GL_ONE and
+ * \c GL_ZERO as combine inputs (which the code already supports). It can
+ * also handle the \c GL_MODULATE_ADD_ATI mode. Is it worth investigating
+ * partial support for the extension?
+ */
+GLuint
+i830SetTexEnvCombine(i830ContextPtr i830,
+ const struct gl_tex_env_combine_state * combine,
+ GLint blendUnit,
+ GLuint texel_op,
+ GLuint *state,
+ const GLfloat *factor )
+{
+ const GLuint numColorArgs = combine->_NumArgsRGB;
+ const GLuint numAlphaArgs = combine->_NumArgsA;
+
+ GLuint blendop;
+ GLuint ablendop;
+ GLuint args_RGB[3];
+ GLuint args_A[3];
+ GLuint rgb_shift;
+ GLuint alpha_shift;
+ GLboolean need_factor = 0;
+ int i;
+ unsigned used;
+ static const GLuint tex_blend_rgb[3] = {
+ TEXPIPE_COLOR | TEXBLEND_ARG1 | TEXBLENDARG_MODIFY_PARMS,
+ TEXPIPE_COLOR | TEXBLEND_ARG2 | TEXBLENDARG_MODIFY_PARMS,
+ TEXPIPE_COLOR | TEXBLEND_ARG0 | TEXBLENDARG_MODIFY_PARMS,
+ };
+ static const GLuint tex_blend_a[3] = {
+ TEXPIPE_ALPHA | TEXBLEND_ARG1 | TEXBLENDARG_MODIFY_PARMS,
+ TEXPIPE_ALPHA | TEXBLEND_ARG2 | TEXBLENDARG_MODIFY_PARMS,
+ TEXPIPE_ALPHA | TEXBLEND_ARG0 | TEXBLENDARG_MODIFY_PARMS,
+ };
+
+ if(INTEL_DEBUG&DEBUG_TEXTURE)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+
+ /* The EXT version of the DOT3 extension does not support the
+ * scale factor, but the ARB version (and the version in OpenGL
+ * 1.3) does.
+ */
+ switch (combine->ModeRGB) {
+ case GL_DOT3_RGB_EXT:
+ alpha_shift = combine->ScaleShiftA;
+ rgb_shift = 0;
+ break;
+
+ case GL_DOT3_RGBA_EXT:
+ alpha_shift = 0;
+ rgb_shift = 0;
+ break;
+
+ default:
+ rgb_shift = combine->ScaleShiftRGB;
+ alpha_shift = combine->ScaleShiftA;
+ break;
+ }
+
+
+ switch(combine->ModeRGB) {
+ case GL_REPLACE:
+ blendop = TEXBLENDOP_ARG1;
+ break;
+ case GL_MODULATE:
+ blendop = TEXBLENDOP_MODULATE;
+ break;
+ case GL_ADD:
+ blendop = TEXBLENDOP_ADD;
+ break;
+ case GL_ADD_SIGNED:
+ blendop = TEXBLENDOP_ADDSIGNED;
+ break;
+ case GL_INTERPOLATE:
+ blendop = TEXBLENDOP_BLEND;
+ break;
+ case GL_SUBTRACT:
+ blendop = TEXBLENDOP_SUBTRACT;
+ break;
+ case GL_DOT3_RGB_EXT:
+ case GL_DOT3_RGB:
+ blendop = TEXBLENDOP_DOT3;
+ break;
+ case GL_DOT3_RGBA_EXT:
+ case GL_DOT3_RGBA:
+ blendop = TEXBLENDOP_DOT3;
+ break;
+ default:
+ return pass_through( state, blendUnit );
+ }
+
+ blendop |= (rgb_shift << TEXOP_SCALE_SHIFT);
+
+
+ /* Handle RGB args */
+ for(i = 0; i < 3; i++) {
+ switch(combine->SourceRGB[i]) {
+ case GL_TEXTURE:
+ args_RGB[i] = texel_op;
+ break;
+ case GL_TEXTURE0:
+ case GL_TEXTURE1:
+ case GL_TEXTURE2:
+ case GL_TEXTURE3:
+ args_RGB[i] = GetTexelOp( combine->SourceRGB[i] - GL_TEXTURE0 );
+ break;
+ case GL_CONSTANT:
+ args_RGB[i] = TEXBLENDARG_FACTOR_N;
+ need_factor = 1;
+ break;
+ case GL_PRIMARY_COLOR:
+ args_RGB[i] = TEXBLENDARG_DIFFUSE;
+ break;
+ case GL_PREVIOUS:
+ args_RGB[i] = TEXBLENDARG_CURRENT;
+ break;
+ default:
+ return pass_through( state, blendUnit );
+ }
+
+ switch(combine->OperandRGB[i]) {
+ case GL_SRC_COLOR:
+ args_RGB[i] |= 0;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ args_RGB[i] |= TEXBLENDARG_INV_ARG;
+ break;
+ case GL_SRC_ALPHA:
+ args_RGB[i] |= TEXBLENDARG_REPLICATE_ALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ args_RGB[i] |= (TEXBLENDARG_REPLICATE_ALPHA |
+ TEXBLENDARG_INV_ARG);
+ break;
+ default:
+ return pass_through( state, blendUnit );
+ }
+ }
+
+
+ /* Need to knobble the alpha calculations of TEXBLENDOP_DOT4 to
+ * match the spec. Can't use DOT3 as it won't propogate values
+ * into alpha as required:
+ *
+ * Note - the global factor is set up with alpha == .5, so
+ * the alpha part of the DOT4 calculation should be zero.
+ */
+ if ( combine->ModeRGB == GL_DOT3_RGBA_EXT ||
+ combine->ModeRGB == GL_DOT3_RGBA ) {
+ ablendop = TEXBLENDOP_DOT4;
+ args_A[0] = TEXBLENDARG_FACTOR; /* the global factor */
+ args_A[1] = TEXBLENDARG_FACTOR;
+ args_A[2] = TEXBLENDARG_FACTOR;
+ }
+ else {
+ switch(combine->ModeA) {
+ case GL_REPLACE:
+ ablendop = TEXBLENDOP_ARG1;
+ break;
+ case GL_MODULATE:
+ ablendop = TEXBLENDOP_MODULATE;
+ break;
+ case GL_ADD:
+ ablendop = TEXBLENDOP_ADD;
+ break;
+ case GL_ADD_SIGNED:
+ ablendop = TEXBLENDOP_ADDSIGNED;
+ break;
+ case GL_INTERPOLATE:
+ ablendop = TEXBLENDOP_BLEND;
+ break;
+ case GL_SUBTRACT:
+ ablendop = TEXBLENDOP_SUBTRACT;
+ break;
+ default:
+ return pass_through( state, blendUnit );
+ }
+
+
+ ablendop |= (alpha_shift << TEXOP_SCALE_SHIFT);
+
+ /* Handle A args */
+ for(i = 0; i < 3; i++) {
+ switch(combine->SourceA[i]) {
+ case GL_TEXTURE:
+ args_A[i] = texel_op;
+ break;
+ case GL_TEXTURE0:
+ case GL_TEXTURE1:
+ case GL_TEXTURE2:
+ case GL_TEXTURE3:
+ args_A[i] = GetTexelOp( combine->SourceA[i] - GL_TEXTURE0 );
+ break;
+ case GL_CONSTANT:
+ args_A[i] = TEXBLENDARG_FACTOR_N;
+ need_factor = 1;
+ break;
+ case GL_PRIMARY_COLOR:
+ args_A[i] = TEXBLENDARG_DIFFUSE;
+ break;
+ case GL_PREVIOUS:
+ args_A[i] = TEXBLENDARG_CURRENT;
+ break;
+ default:
+ return pass_through( state, blendUnit );
+ }
+
+ switch(combine->OperandA[i]) {
+ case GL_SRC_ALPHA:
+ args_A[i] |= 0;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ args_A[i] |= TEXBLENDARG_INV_ARG;
+ break;
+ default:
+ return pass_through( state, blendUnit );
+ }
+ }
+ }
+
+
+
+ /* Native Arg1 == Arg0 in GL_EXT_texture_env_combine spec */
+ /* Native Arg2 == Arg1 in GL_EXT_texture_env_combine spec */
+ /* Native Arg0 == Arg2 in GL_EXT_texture_env_combine spec */
+
+ /* When we render we need to figure out which is the last really enabled
+ * tex unit, and put last stage on it
+ */
+
+
+ /* Build color & alpha pipelines */
+
+ used = 0;
+ state[used++] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
+ TEXPIPE_COLOR |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ DISABLE_TEX_CNTRL_STAGE |
+ TEXOP_MODIFY_PARMS |
+ blendop);
+ state[used++] = (_3DSTATE_MAP_BLEND_OP_CMD(blendUnit) |
+ TEXPIPE_ALPHA |
+ ENABLE_TEXOUTPUT_WRT_SEL |
+ TEXOP_OUTPUT_CURRENT |
+ TEXOP_MODIFY_PARMS |
+ ablendop);
+
+ for ( i = 0 ; i < numColorArgs ; i++ ) {
+ state[used++] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
+ tex_blend_rgb[i] | args_RGB[i]);
+ }
+
+ for ( i = 0 ; i < numAlphaArgs ; i++ ) {
+ state[used++] = (_3DSTATE_MAP_BLEND_ARG_CMD(blendUnit) |
+ tex_blend_a[i] | args_A[i]);
+ }
+
+
+ if (need_factor)
+ return emit_factor( blendUnit, state, used, factor );
+ else
+ return used;
+}
+
+
+static void emit_texblend( i830ContextPtr i830, GLuint unit, GLuint blendUnit,
+ GLboolean last_stage )
+{
+ struct gl_texture_unit *texUnit = &i830->intel.ctx.Texture.Unit[unit];
+ GLuint tmp[I830_TEXBLEND_SIZE], tmp_sz;
+
+
+ if (0) fprintf(stderr, "%s unit %d\n", __FUNCTION__, unit);
+
+ /* Update i830->state.TexBlend
+ */
+ tmp_sz = i830SetTexEnvCombine(i830, texUnit->_CurrentCombine, blendUnit,
+ GetTexelOp(unit), tmp,
+ texUnit->EnvColor );
+
+ if (last_stage)
+ tmp[0] |= TEXOP_LAST_STAGE;
+
+ if (tmp_sz != i830->state.TexBlendWordsUsed[blendUnit] ||
+ memcmp( tmp, i830->state.TexBlend[blendUnit], tmp_sz * sizeof(GLuint))) {
+
+ I830_STATECHANGE( i830, I830_UPLOAD_TEXBLEND(blendUnit) );
+ memcpy( i830->state.TexBlend[blendUnit], tmp, tmp_sz * sizeof(GLuint));
+ i830->state.TexBlendWordsUsed[blendUnit] = tmp_sz;
+ }
+
+ I830_ACTIVESTATE(i830, I830_UPLOAD_TEXBLEND(blendUnit), GL_TRUE);
+}
+
+static void emit_passthrough( i830ContextPtr i830 )
+{
+ GLuint tmp[I830_TEXBLEND_SIZE], tmp_sz;
+ GLuint unit = 0;
+
+ tmp_sz = pass_through( tmp, unit );
+ tmp[0] |= TEXOP_LAST_STAGE;
+
+ if (tmp_sz != i830->state.TexBlendWordsUsed[unit] ||
+ memcmp( tmp, i830->state.TexBlend[unit], tmp_sz * sizeof(GLuint))) {
+
+ I830_STATECHANGE( i830, I830_UPLOAD_TEXBLEND(unit) );
+ memcpy( i830->state.TexBlend[unit], tmp, tmp_sz * sizeof(GLuint));
+ i830->state.TexBlendWordsUsed[unit] = tmp_sz;
+ }
+
+ I830_ACTIVESTATE(i830, I830_UPLOAD_TEXBLEND(unit), GL_TRUE);
+}
+
+void i830EmitTextureBlend( i830ContextPtr i830 )
+{
+ GLcontext *ctx = &i830->intel.ctx;
+ GLuint unit, last_stage = 0, blendunit = 0;
+
+ I830_ACTIVESTATE(i830, I830_UPLOAD_TEXBLEND_ALL, GL_FALSE);
+
+ if (ctx->Texture._EnabledUnits) {
+ for (unit = 0 ; unit < ctx->Const.MaxTextureUnits ; unit++)
+ if (ctx->Texture.Unit[unit]._ReallyEnabled)
+ last_stage = unit;
+
+ for (unit = 0 ; unit < ctx->Const.MaxTextureUnits ; unit++)
+ if (ctx->Texture.Unit[unit]._ReallyEnabled)
+ emit_texblend( i830, unit, blendunit++, last_stage == unit );
+ }
+ else {
+ emit_passthrough( i830 );
+ }
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_texstate.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_texstate.c
new file mode 100644
index 000000000..ba452279b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_texstate.c
@@ -0,0 +1,483 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "texformat.h"
+#include "texstore.h"
+
+#include "mm.h"
+
+#include "intel_screen.h"
+#include "intel_ioctl.h"
+#include "intel_tex.h"
+
+#include "i830_context.h"
+#include "i830_reg.h"
+
+static const GLint initial_offsets[6][2] = { {0,0},
+ {0,2},
+ {1,0},
+ {1,2},
+ {1,1},
+ {1,3} };
+
+static const GLint step_offsets[6][2] = { {0,2},
+ {0,2},
+ {-1,2},
+ {-1,2},
+ {-1,1},
+ {-1,1} };
+
+#define I830_TEX_UNIT_ENABLED(unit) (1<<unit)
+
+static GLboolean i830SetTexImages( i830ContextPtr i830,
+ struct gl_texture_object *tObj )
+{
+ GLuint total_height, pitch, i, textureFormat;
+ i830TextureObjectPtr t = (i830TextureObjectPtr) tObj->DriverData;
+ const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
+ GLint firstLevel, lastLevel, numLevels;
+
+ switch( baseImage->TexFormat->MesaFormat ) {
+ case MESA_FORMAT_L8:
+ t->intel.texelBytes = 1;
+ textureFormat = MAPSURF_8BIT | MT_8BIT_L8;
+ break;
+
+ case MESA_FORMAT_I8:
+ t->intel.texelBytes = 1;
+ textureFormat = MAPSURF_8BIT | MT_8BIT_I8;
+ break;
+
+ case MESA_FORMAT_A8:
+ t->intel.texelBytes = 1;
+ textureFormat = MAPSURF_8BIT | MT_8BIT_I8; /* Kludge -- check with conform, glean */
+ break;
+
+ case MESA_FORMAT_AL88:
+ t->intel.texelBytes = 2;
+ textureFormat = MAPSURF_16BIT | MT_16BIT_AY88;
+ break;
+
+ case MESA_FORMAT_RGB565:
+ t->intel.texelBytes = 2;
+ textureFormat = MAPSURF_16BIT | MT_16BIT_RGB565;
+ break;
+
+ case MESA_FORMAT_ARGB1555:
+ t->intel.texelBytes = 2;
+ textureFormat = MAPSURF_16BIT | MT_16BIT_ARGB1555;
+ break;
+
+ case MESA_FORMAT_ARGB4444:
+ t->intel.texelBytes = 2;
+ textureFormat = MAPSURF_16BIT | MT_16BIT_ARGB4444;
+ break;
+
+ case MESA_FORMAT_ARGB8888:
+ t->intel.texelBytes = 4;
+ textureFormat = MAPSURF_32BIT | MT_32BIT_ARGB8888;
+ break;
+
+ case MESA_FORMAT_YCBCR_REV:
+ t->intel.texelBytes = 2;
+ textureFormat = (MAPSURF_422 | MT_422_YCRCB_NORMAL |
+ TM0S1_COLORSPACE_CONVERSION);
+ break;
+
+ case MESA_FORMAT_YCBCR:
+ t->intel.texelBytes = 2;
+ textureFormat = (MAPSURF_422 | MT_422_YCRCB_SWAPY | /* ??? */
+ TM0S1_COLORSPACE_CONVERSION);
+ break;
+
+ case MESA_FORMAT_RGB_FXT1:
+ case MESA_FORMAT_RGBA_FXT1:
+ t->intel.texelBytes = 2;
+ textureFormat = MAPSURF_COMPRESSED | MT_COMPRESS_FXT1;
+ break;
+
+ case MESA_FORMAT_RGBA_DXT1:
+ case MESA_FORMAT_RGB_DXT1:
+ /*
+ * DXTn pitches are Width/4 * blocksize in bytes
+ * for DXT1: blocksize=8 so Width/4*8 = Width * 2
+ * for DXT3/5: blocksize=16 so Width/4*16 = Width * 4
+ */
+ t->intel.texelBytes = 2;
+ textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT1);
+ break;
+ case MESA_FORMAT_RGBA_DXT3:
+ t->intel.texelBytes = 4;
+ textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT2_3);
+ break;
+ case MESA_FORMAT_RGBA_DXT5:
+ t->intel.texelBytes = 4;
+ textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
+ break;
+
+ default:
+ fprintf(stderr, "%s: bad image format\n", __FUNCTION__);
+ abort();
+ }
+
+ /* Compute which mipmap levels we really want to send to the hardware.
+ * This depends on the base image size, GL_TEXTURE_MIN_LOD,
+ * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
+ * Yes, this looks overly complicated, but it's all needed.
+ */
+ driCalculateTextureFirstLastLevel( (driTextureObject *) t );
+
+
+ /* Figure out the amount of memory required to hold all the mipmap
+ * levels. Choose the smallest pitch to accomodate the largest
+ * mipmap:
+ */
+ firstLevel = t->intel.base.firstLevel;
+ lastLevel = t->intel.base.lastLevel;
+ numLevels = lastLevel - firstLevel + 1;
+
+
+ /* All images must be loaded at this pitch. Count the number of
+ * lines required:
+ */
+ switch (tObj->Target) {
+ case GL_TEXTURE_CUBE_MAP: {
+ const GLuint dim = tObj->Image[0][firstLevel]->Width;
+ GLuint face;
+
+ pitch = dim * t->intel.texelBytes;
+ pitch *= 2; /* double pitch for cube layouts */
+ pitch = (pitch + 3) & ~3;
+
+ total_height = dim * 4;
+
+ for ( face = 0 ; face < 6 ; face++) {
+ GLuint x = initial_offsets[face][0] * dim;
+ GLuint y = initial_offsets[face][1] * dim;
+ GLuint d = dim;
+
+ t->intel.base.dirty_images[face] = ~0;
+
+ assert(tObj->Image[face][firstLevel]->Width == dim);
+ assert(tObj->Image[face][firstLevel]->Height == dim);
+
+ for (i = 0; i < numLevels; i++) {
+ t->intel.image[face][i].image = tObj->Image[face][firstLevel + i];
+ if (!t->intel.image[face][i].image) {
+ fprintf(stderr, "no image %d %d\n", face, i);
+ break; /* can't happen */
+ }
+
+ t->intel.image[face][i].offset =
+ y * pitch + x * t->intel.texelBytes;
+ t->intel.image[face][i].internalFormat = baseImage->Format;
+
+ d >>= 1;
+ x += step_offsets[face][0] * d;
+ y += step_offsets[face][1] * d;
+ }
+ }
+ break;
+ }
+ default:
+ pitch = tObj->Image[0][firstLevel]->Width * t->intel.texelBytes;
+ pitch = (pitch + 3) & ~3;
+ t->intel.base.dirty_images[0] = ~0;
+
+ for ( total_height = i = 0 ; i < numLevels ; i++ ) {
+ t->intel.image[0][i].image = tObj->Image[0][firstLevel + i];
+ if (!t->intel.image[0][i].image)
+ break;
+
+ t->intel.image[0][i].offset = total_height * pitch;
+ t->intel.image[0][i].internalFormat = baseImage->Format;
+ if (t->intel.image[0][i].image->IsCompressed)
+ {
+ if (t->intel.image[0][i].image->Height > 4)
+ total_height += t->intel.image[0][i].image->Height/4;
+ else
+ total_height += 1;
+ }
+ else
+ total_height += MAX2(2, t->intel.image[0][i].image->Height);
+ }
+ break;
+ }
+
+ t->intel.Pitch = pitch;
+ t->intel.base.totalSize = total_height*pitch;
+ t->intel.max_level = i-1;
+ t->Setup[I830_TEXREG_TM0S1] =
+ (((tObj->Image[0][firstLevel]->Height - 1) << TM0S1_HEIGHT_SHIFT) |
+ ((tObj->Image[0][firstLevel]->Width - 1) << TM0S1_WIDTH_SHIFT) |
+ textureFormat);
+ t->Setup[I830_TEXREG_TM0S2] =
+ (((pitch / 4) - 1) << TM0S2_PITCH_SHIFT) |
+ TM0S2_CUBE_FACE_ENA_MASK;
+ t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MAX_MIP_MASK;
+ t->Setup[I830_TEXREG_TM0S3] &= ~TM0S3_MIN_MIP_MASK;
+ t->Setup[I830_TEXREG_TM0S3] |= ((numLevels - 1)*4) << TM0S3_MIN_MIP_SHIFT;
+ t->intel.dirty = I830_UPLOAD_TEX_ALL;
+
+ return intelUploadTexImages( &i830->intel, &t->intel, 0 );
+}
+
+
+static void i830_import_tex_unit( i830ContextPtr i830,
+ i830TextureObjectPtr t,
+ GLuint unit )
+{
+ if(INTEL_DEBUG&DEBUG_TEXTURE)
+ fprintf(stderr, "%s unit(%d)\n", __FUNCTION__, unit);
+
+ if (i830->intel.CurrentTexObj[unit])
+ i830->intel.CurrentTexObj[unit]->base.bound &= ~(1U << unit);
+
+ i830->intel.CurrentTexObj[unit] = (intelTextureObjectPtr)t;
+ t->intel.base.bound |= (1 << unit);
+
+ I830_STATECHANGE( i830, I830_UPLOAD_TEX(unit) );
+
+ i830->state.Tex[unit][I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
+ (LOAD_TEXTURE_MAP0 << unit) | 4);
+ i830->state.Tex[unit][I830_TEXREG_TM0S0] = (TM0S0_USE_FENCE |
+ t->intel.TextureOffset);
+
+ i830->state.Tex[unit][I830_TEXREG_TM0S1] = t->Setup[I830_TEXREG_TM0S1];
+ i830->state.Tex[unit][I830_TEXREG_TM0S2] = t->Setup[I830_TEXREG_TM0S2];
+
+ i830->state.Tex[unit][I830_TEXREG_TM0S3] &= TM0S3_LOD_BIAS_MASK;
+ i830->state.Tex[unit][I830_TEXREG_TM0S3] |= (t->Setup[I830_TEXREG_TM0S3] &
+ ~TM0S3_LOD_BIAS_MASK);
+
+ i830->state.Tex[unit][I830_TEXREG_TM0S4] = t->Setup[I830_TEXREG_TM0S4];
+ i830->state.Tex[unit][I830_TEXREG_MCS] = (t->Setup[I830_TEXREG_MCS] &
+ ~MAP_UNIT_MASK);
+ i830->state.Tex[unit][I830_TEXREG_CUBE] = t->Setup[I830_TEXREG_CUBE];
+ i830->state.Tex[unit][I830_TEXREG_MCS] |= MAP_UNIT(unit);
+
+ t->intel.dirty &= ~I830_UPLOAD_TEX(unit);
+}
+
+
+
+static GLboolean enable_tex_common( GLcontext *ctx, GLuint unit )
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ i830TextureObjectPtr t = (i830TextureObjectPtr)tObj->DriverData;
+
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+
+ /* Fallback if there's a texture border */
+ if ( tObj->Image[0][tObj->BaseLevel]->Border > 0 ) {
+ fprintf(stderr, "Texture border\n");
+ return GL_FALSE;
+ }
+
+ /* Upload teximages (not pipelined)
+ */
+ if (t->intel.base.dirty_images[0]) {
+ if (!i830SetTexImages( i830, tObj )) {
+ return GL_FALSE;
+ }
+ }
+
+ /* Update state if this is a different texture object to last
+ * time.
+ */
+ if (i830->intel.CurrentTexObj[unit] != &t->intel ||
+ (t->intel.dirty & I830_UPLOAD_TEX(unit))) {
+ i830_import_tex_unit( i830, t, unit);
+ }
+
+ I830_ACTIVESTATE(i830, I830_UPLOAD_TEX(unit), GL_TRUE);
+
+ return GL_TRUE;
+}
+
+static GLboolean enable_tex_rect( GLcontext *ctx, GLuint unit )
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ GLuint mcs = i830->state.Tex[unit][I830_TEXREG_MCS];
+
+ mcs &= ~TEXCOORDS_ARE_NORMAL;
+ mcs |= TEXCOORDS_ARE_IN_TEXELUNITS;
+
+ if ((mcs != i830->state.Tex[unit][I830_TEXREG_MCS])
+ || (0 != i830->state.Tex[unit][I830_TEXREG_CUBE])) {
+ I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit));
+ i830->state.Tex[unit][I830_TEXREG_MCS] = mcs;
+ i830->state.Tex[unit][I830_TEXREG_CUBE] = 0;
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLboolean enable_tex_2d( GLcontext *ctx, GLuint unit )
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ GLuint mcs = i830->state.Tex[unit][I830_TEXREG_MCS];
+
+ mcs &= ~TEXCOORDS_ARE_IN_TEXELUNITS;
+ mcs |= TEXCOORDS_ARE_NORMAL;
+
+ if ((mcs != i830->state.Tex[unit][I830_TEXREG_MCS])
+ || (0 != i830->state.Tex[unit][I830_TEXREG_CUBE])) {
+ I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit));
+ i830->state.Tex[unit][I830_TEXREG_MCS] = mcs;
+ i830->state.Tex[unit][I830_TEXREG_CUBE] = 0;
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLboolean enable_tex_cube( GLcontext *ctx, GLuint unit )
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ i830TextureObjectPtr t = (i830TextureObjectPtr)tObj->DriverData;
+ GLuint mcs = i830->state.Tex[unit][I830_TEXREG_MCS];
+ const GLuint cube = CUBE_NEGX_ENABLE | CUBE_POSX_ENABLE
+ | CUBE_NEGY_ENABLE | CUBE_POSY_ENABLE
+ | CUBE_NEGZ_ENABLE | CUBE_POSZ_ENABLE;
+ GLuint face;
+
+ mcs &= ~TEXCOORDS_ARE_IN_TEXELUNITS;
+ mcs |= TEXCOORDS_ARE_NORMAL;
+
+ if ((mcs != i830->state.Tex[unit][I830_TEXREG_MCS])
+ || (cube != i830->state.Tex[unit][I830_TEXREG_CUBE])) {
+ I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit));
+ i830->state.Tex[unit][I830_TEXREG_MCS] = mcs;
+ i830->state.Tex[unit][I830_TEXREG_CUBE] = cube;
+ }
+
+ /* Upload teximages (not pipelined)
+ */
+ if ( t->intel.base.dirty_images[0] || t->intel.base.dirty_images[1] ||
+ t->intel.base.dirty_images[2] || t->intel.base.dirty_images[3] ||
+ t->intel.base.dirty_images[4] || t->intel.base.dirty_images[5] ) {
+ i830SetTexImages( i830, tObj );
+ }
+
+ /* upload (per face) */
+ for (face = 0; face < 6; face++) {
+ if (t->intel.base.dirty_images[face]) {
+ if (!intelUploadTexImages( &i830->intel, &t->intel, face )) {
+ return GL_FALSE;
+ }
+ }
+ }
+
+
+ return GL_TRUE;
+}
+
+
+static GLboolean disable_tex( GLcontext *ctx, GLuint unit )
+{
+ i830ContextPtr i830 = I830_CONTEXT(ctx);
+
+ /* This is happening too often. I need to conditionally send diffuse
+ * state to the card. Perhaps a diffuse dirty flag of some kind.
+ * Will need to change this logic if more than 2 texture units are
+ * used. We need to only do this up to the last unit enabled, or unit
+ * one if nothing is enabled.
+ */
+
+ if ( i830->intel.CurrentTexObj[unit] != NULL ) {
+ /* The old texture is no longer bound to this texture unit.
+ * Mark it as such.
+ */
+
+ i830->intel.CurrentTexObj[unit]->base.bound &= ~(1U << 0);
+ i830->intel.CurrentTexObj[unit] = NULL;
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean i830UpdateTexUnit( GLcontext *ctx, GLuint unit )
+{
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+ if (texUnit->_ReallyEnabled &&
+ INTEL_CONTEXT(ctx)->intelScreen->textureSize < 2048 * 1024)
+ return GL_FALSE;
+
+ switch(texUnit->_ReallyEnabled) {
+ case TEXTURE_1D_BIT:
+ case TEXTURE_2D_BIT:
+ return (enable_tex_common( ctx, unit ) &&
+ enable_tex_2d( ctx, unit ));
+ case TEXTURE_RECT_BIT:
+ return (enable_tex_common( ctx, unit ) &&
+ enable_tex_rect( ctx, unit ));
+ case TEXTURE_CUBE_BIT:
+ return (enable_tex_common( ctx, unit ) &&
+ enable_tex_cube( ctx, unit ));
+ case 0:
+ return disable_tex( ctx, unit );
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+void i830UpdateTextureState( intelContextPtr intel )
+{
+ i830ContextPtr i830 = I830_CONTEXT(intel);
+ GLcontext *ctx = &intel->ctx;
+ GLboolean ok;
+
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+
+ I830_ACTIVESTATE(i830, I830_UPLOAD_TEX_ALL, GL_FALSE);
+
+ ok = (i830UpdateTexUnit( ctx, 0 ) &&
+ i830UpdateTexUnit( ctx, 1 ) &&
+ i830UpdateTexUnit( ctx, 2 ) &&
+ i830UpdateTexUnit( ctx, 3 ));
+
+ FALLBACK( intel, I830_FALLBACK_TEXTURE, !ok );
+
+ if (ok)
+ i830EmitTextureBlend( i830 );
+}
+
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_vtbl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_vtbl.c
new file mode 100644
index 000000000..22939e8e5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i830_vtbl.c
@@ -0,0 +1,456 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+
+#include "i830_context.h"
+#include "i830_reg.h"
+
+#include "intel_batchbuffer.h"
+
+#include "tnl/t_context.h"
+#include "tnl/t_vertex.h"
+
+static GLboolean i830_check_vertex_size( intelContextPtr intel,
+ GLuint expected );
+
+#define SZ_TO_HW(sz) ((sz-2)&0x3)
+#define EMIT_SZ(sz) (EMIT_1F + (sz) - 1)
+#define EMIT_ATTR( ATTR, STYLE, V0 ) \
+do { \
+ intel->vertex_attrs[intel->vertex_attr_count].attrib = (ATTR); \
+ intel->vertex_attrs[intel->vertex_attr_count].format = (STYLE); \
+ intel->vertex_attr_count++; \
+ v0 |= V0; \
+} while (0)
+
+#define EMIT_PAD( N ) \
+do { \
+ intel->vertex_attrs[intel->vertex_attr_count].attrib = 0; \
+ intel->vertex_attrs[intel->vertex_attr_count].format = EMIT_PAD; \
+ intel->vertex_attrs[intel->vertex_attr_count].offset = (N); \
+ intel->vertex_attr_count++; \
+} while (0)
+
+
+#define VRTX_TEX_SET_FMT(n, x) ((x)<<((n)*2))
+#define TEXBIND_SET(n, x) ((x)<<((n)*4))
+
+static void i830_render_start( intelContextPtr intel )
+{
+ GLcontext *ctx = &intel->ctx;
+ i830ContextPtr i830 = I830_CONTEXT(intel);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint index = tnl->render_inputs;
+ GLuint v0 = _3DSTATE_VFT0_CMD;
+ GLuint v2 = _3DSTATE_VFT1_CMD;
+ GLuint mcsb1 = 0;
+
+ /* Important:
+ */
+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
+ intel->vertex_attr_count = 0;
+
+ /* EMIT_ATTR's must be in order as they tell t_vertex.c how to
+ * build up a hardware vertex.
+ */
+ if (index & _TNL_BITS_TEX_ANY) {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, VFT0_XYZW );
+ intel->coloroffset = 4;
+ }
+ else {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, VFT0_XYZ );
+ intel->coloroffset = 3;
+ }
+
+ if (index & _TNL_BIT_POINTSIZE) {
+ EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, VFT0_POINT_WIDTH );
+ }
+
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, VFT0_DIFFUSE );
+
+ intel->specoffset = 0;
+ if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) {
+ if (index & _TNL_BIT_COLOR1) {
+ intel->specoffset = intel->coloroffset + 1;
+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, VFT0_SPEC );
+ }
+ else
+ EMIT_PAD( 3 );
+
+ if (index & _TNL_BIT_FOG)
+ EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, VFT0_SPEC );
+ else
+ EMIT_PAD( 1 );
+ }
+
+ if (index & _TNL_BITS_TEX_ANY) {
+ int i, count = 0;
+
+ for (i = 0; i < I830_TEX_UNITS; i++) {
+ if (index & _TNL_BIT_TEX(i)) {
+ GLuint sz = VB->TexCoordPtr[i]->size;
+ GLuint emit;
+ GLuint mcs = (i830->state.Tex[i][I830_TEXREG_MCS] &
+ ~TEXCOORDTYPE_MASK);
+
+ switch (sz) {
+ case 1:
+ case 2:
+ emit = EMIT_2F;
+ sz = 2;
+ mcs |= TEXCOORDTYPE_CARTESIAN;
+ break;
+ case 3:
+ emit = EMIT_3F;
+ sz = 3;
+ mcs |= TEXCOORDTYPE_VECTOR;
+ break;
+ case 4:
+ emit = EMIT_3F_XYW;
+ sz = 3;
+ mcs |= TEXCOORDTYPE_HOMOGENEOUS;
+ break;
+ default:
+ continue;
+ };
+
+
+ EMIT_ATTR( _TNL_ATTRIB_TEX0+i, emit, 0 );
+ v2 |= VRTX_TEX_SET_FMT(count, SZ_TO_HW(sz));
+ mcsb1 |= (count+8)<<(i*4);
+
+ if (mcs != i830->state.Tex[i][I830_TEXREG_MCS]) {
+ I830_STATECHANGE(i830, I830_UPLOAD_TEX(i));
+ i830->state.Tex[i][I830_TEXREG_MCS] = mcs;
+ }
+
+ count++;
+ }
+ }
+
+ v0 |= VFT0_TEX_COUNT(count);
+ }
+
+ /* Only need to change the vertex emit code if there has been a
+ * statechange to a new hardware vertex format:
+ */
+ if (v0 != i830->state.Ctx[I830_CTXREG_VF] ||
+ v2 != i830->state.Ctx[I830_CTXREG_VF2] ||
+ mcsb1 != i830->state.Ctx[I830_CTXREG_MCSB1] ||
+ index != i830->last_index) {
+
+ I830_STATECHANGE( i830, I830_UPLOAD_CTX );
+
+ /* Must do this *after* statechange, so as not to affect
+ * buffered vertices reliant on the old state:
+ */
+ intel->vertex_size =
+ _tnl_install_attrs( ctx,
+ intel->vertex_attrs,
+ intel->vertex_attr_count,
+ intel->ViewportMatrix.m, 0 );
+
+ intel->vertex_size >>= 2;
+
+ i830->state.Ctx[I830_CTXREG_VF] = v0;
+ i830->state.Ctx[I830_CTXREG_VF2] = v2;
+ i830->state.Ctx[I830_CTXREG_MCSB1] = mcsb1;
+ i830->last_index = index;
+
+ assert(i830_check_vertex_size( intel, intel->vertex_size ));
+ }
+}
+
+static void i830_reduced_primitive_state( intelContextPtr intel,
+ GLenum rprim )
+{
+ i830ContextPtr i830 = I830_CONTEXT(intel);
+ GLuint st1 = i830->state.Stipple[I830_STPREG_ST1];
+
+ st1 &= ~ST1_ENABLE;
+
+ switch (rprim) {
+ case GL_TRIANGLES:
+ if (intel->ctx.Polygon.StippleFlag &&
+ intel->hw_stipple)
+ st1 |= ST1_ENABLE;
+ break;
+ case GL_LINES:
+ case GL_POINTS:
+ default:
+ break;
+ }
+
+ i830->intel.reduced_primitive = rprim;
+
+ if (st1 != i830->state.Stipple[I830_STPREG_ST1]) {
+ I830_STATECHANGE(i830, I830_UPLOAD_STIPPLE);
+ i830->state.Stipple[I830_STPREG_ST1] = st1;
+ }
+}
+
+/* Pull apart the vertex format registers and figure out how large a
+ * vertex is supposed to be.
+ */
+static GLboolean i830_check_vertex_size( intelContextPtr intel,
+ GLuint expected )
+{
+ i830ContextPtr i830 = I830_CONTEXT(intel);
+ int vft0 = i830->current->Ctx[I830_CTXREG_VF];
+ int vft1 = i830->current->Ctx[I830_CTXREG_VF2];
+ int nrtex = (vft0 & VFT0_TEX_COUNT_MASK) >> VFT0_TEX_COUNT_SHIFT;
+ int i, sz = 0;
+
+ switch (vft0 & VFT0_XYZW_MASK) {
+ case VFT0_XY: sz = 2; break;
+ case VFT0_XYZ: sz = 3; break;
+ case VFT0_XYW: sz = 3; break;
+ case VFT0_XYZW: sz = 4; break;
+ default:
+ fprintf(stderr, "no xyzw specified\n");
+ return 0;
+ }
+
+ if (vft0 & VFT0_SPEC) sz++;
+ if (vft0 & VFT0_DIFFUSE) sz++;
+ if (vft0 & VFT0_DEPTH_OFFSET) sz++;
+ if (vft0 & VFT0_POINT_WIDTH) sz++;
+
+ for (i = 0 ; i < nrtex ; i++) {
+ switch (vft1 & VFT1_TEX0_MASK) {
+ case TEXCOORDFMT_2D: sz += 2; break;
+ case TEXCOORDFMT_3D: sz += 3; break;
+ case TEXCOORDFMT_4D: sz += 4; break;
+ case TEXCOORDFMT_1D: sz += 1; break;
+ }
+ vft1 >>= VFT1_TEX1_SHIFT;
+ }
+
+ if (sz != expected)
+ fprintf(stderr, "vertex size mismatch %d/%d\n", sz, expected);
+
+ return sz == expected;
+}
+
+static void i830_emit_invarient_state( intelContextPtr intel )
+{
+ BATCH_LOCALS;
+
+ BEGIN_BATCH( 200 );
+
+ OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(0));
+ OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(1));
+ OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(2));
+ OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(3));
+
+ OUT_BATCH(_3DSTATE_DFLT_DIFFUSE_CMD);
+ OUT_BATCH(0);
+
+ OUT_BATCH(_3DSTATE_DFLT_SPEC_CMD);
+ OUT_BATCH(0);
+
+ OUT_BATCH(_3DSTATE_DFLT_Z_CMD);
+ OUT_BATCH(0);
+
+ OUT_BATCH(_3DSTATE_FOG_MODE_CMD);
+ OUT_BATCH(FOGFUNC_ENABLE |
+ FOG_LINEAR_CONST |
+ FOGSRC_INDEX_Z |
+ ENABLE_FOG_DENSITY);
+ OUT_BATCH(0);
+ OUT_BATCH(0);
+
+
+ OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD |
+ MAP_UNIT(0) |
+ DISABLE_TEX_STREAM_BUMP |
+ ENABLE_TEX_STREAM_COORD_SET |
+ TEX_STREAM_COORD_SET(0) |
+ ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(0));
+ OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD |
+ MAP_UNIT(1) |
+ DISABLE_TEX_STREAM_BUMP |
+ ENABLE_TEX_STREAM_COORD_SET |
+ TEX_STREAM_COORD_SET(1) |
+ ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(1));
+ OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD |
+ MAP_UNIT(2) |
+ DISABLE_TEX_STREAM_BUMP |
+ ENABLE_TEX_STREAM_COORD_SET |
+ TEX_STREAM_COORD_SET(2) |
+ ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(2));
+ OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD |
+ MAP_UNIT(3) |
+ DISABLE_TEX_STREAM_BUMP |
+ ENABLE_TEX_STREAM_COORD_SET |
+ TEX_STREAM_COORD_SET(3) |
+ ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(3));
+
+ OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM);
+ OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(0));
+ OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM);
+ OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(1));
+ OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM);
+ OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(2));
+ OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM);
+ OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(3));
+
+ OUT_BATCH(_3DSTATE_RASTER_RULES_CMD |
+ ENABLE_POINT_RASTER_RULE |
+ OGL_POINT_RASTER_RULE |
+ ENABLE_LINE_STRIP_PROVOKE_VRTX |
+ ENABLE_TRI_FAN_PROVOKE_VRTX |
+ ENABLE_TRI_STRIP_PROVOKE_VRTX |
+ LINE_STRIP_PROVOKE_VRTX(1) |
+ TRI_FAN_PROVOKE_VRTX(2) |
+ TRI_STRIP_PROVOKE_VRTX(2));
+
+ OUT_BATCH(_3DSTATE_SCISSOR_ENABLE_CMD |
+ DISABLE_SCISSOR_RECT);
+
+ OUT_BATCH(_3DSTATE_SCISSOR_RECT_0_CMD);
+ OUT_BATCH(0);
+ OUT_BATCH(0);
+
+ OUT_BATCH(_3DSTATE_VERTEX_TRANSFORM);
+ OUT_BATCH(DISABLE_VIEWPORT_TRANSFORM | DISABLE_PERSPECTIVE_DIVIDE);
+
+ OUT_BATCH(_3DSTATE_W_STATE_CMD);
+ OUT_BATCH(MAGIC_W_STATE_DWORD1);
+ OUT_BATCH(0x3f800000 /* 1.0 in IEEE float */ );
+
+
+ OUT_BATCH(_3DSTATE_COLOR_FACTOR_CMD);
+ OUT_BATCH(0x80808080); /* .5 required in alpha for GL_DOT3_RGBA_EXT */
+
+ ADVANCE_BATCH();
+}
+
+
+#define emit( intel, state, size ) \
+do { \
+ int k; \
+ BEGIN_BATCH( size / sizeof(GLuint)); \
+ for (k = 0 ; k < size / sizeof(GLuint) ; k++) \
+ OUT_BATCH(state[k]); \
+ ADVANCE_BATCH(); \
+} while (0);
+
+
+/* Push the state into the sarea and/or texture memory.
+ */
+static void i830_emit_state( intelContextPtr intel )
+{
+ i830ContextPtr i830 = I830_CONTEXT(intel);
+ struct i830_hw_state *state = i830->current;
+ int i;
+ GLuint dirty;
+ BATCH_LOCALS;
+
+ dirty = state->active & ~state->emitted;
+
+ if (dirty & I830_UPLOAD_CTX) {
+ if (VERBOSE) fprintf(stderr, "I830_UPLOAD_CTX:\n");
+ emit( i830, state->Ctx, sizeof(state->Ctx) );
+ }
+
+ if (dirty & I830_UPLOAD_BUFFERS) {
+ if (VERBOSE) fprintf(stderr, "I830_UPLOAD_BUFFERS:\n");
+ emit( i830, state->Buffer, sizeof(state->Buffer) );
+ }
+
+ if (dirty & I830_UPLOAD_STIPPLE) {
+ if (VERBOSE) fprintf(stderr, "I830_UPLOAD_STIPPLE:\n");
+ emit( i830, state->Stipple, sizeof(state->Stipple) );
+ }
+
+ for (i = 0; i < I830_TEX_UNITS; i++) {
+ if ((dirty & I830_UPLOAD_TEX(i))) {
+ if (VERBOSE) fprintf(stderr, "I830_UPLOAD_TEX(%d):\n", i);
+ emit( i830, state->Tex[i], sizeof(state->Tex[i]));
+ }
+
+ if (dirty & I830_UPLOAD_TEXBLEND(i)) {
+ if (VERBOSE) fprintf(stderr, "I830_UPLOAD_TEXBLEND(%d):\n", i);
+ emit( i830, state->TexBlend[i],
+ state->TexBlendWordsUsed[i] * 4 );
+ }
+ }
+
+ state->emitted |= dirty;
+}
+
+static void i830_destroy_context( intelContextPtr intel )
+{
+ _tnl_free_vertices(&intel->ctx);
+}
+
+static void i830_set_draw_offset( intelContextPtr intel, int offset )
+{
+ i830ContextPtr i830 = I830_CONTEXT(intel);
+ I830_STATECHANGE( i830, I830_UPLOAD_BUFFERS );
+ i830->state.Buffer[I830_DESTREG_CBUFADDR2] = offset;
+}
+
+/* This isn't really handled at the moment.
+ */
+static void i830_lost_hardware( intelContextPtr intel )
+{
+ I830_CONTEXT(intel)->state.emitted = 0;
+}
+
+
+
+static void i830_emit_flush( intelContextPtr intel )
+{
+ BATCH_LOCALS;
+
+ BEGIN_BATCH(2);
+ OUT_BATCH( MI_FLUSH | FLUSH_MAP_CACHE );
+ OUT_BATCH( 0 );
+ ADVANCE_BATCH();
+}
+
+
+
+
+void i830InitVtbl( i830ContextPtr i830 )
+{
+ i830->intel.vtbl.alloc_tex_obj = i830AllocTexObj;
+ i830->intel.vtbl.check_vertex_size = i830_check_vertex_size;
+ i830->intel.vtbl.clear_with_tris = i830ClearWithTris;
+ i830->intel.vtbl.destroy = i830_destroy_context;
+ i830->intel.vtbl.emit_invarient_state = i830_emit_invarient_state;
+ i830->intel.vtbl.emit_state = i830_emit_state;
+ i830->intel.vtbl.lost_hardware = i830_lost_hardware;
+ i830->intel.vtbl.reduced_primitive_state = i830_reduced_primitive_state;
+ i830->intel.vtbl.set_draw_offset = i830_set_draw_offset;
+ i830->intel.vtbl.update_texture_state = i830UpdateTextureState;
+ i830->intel.vtbl.emit_flush = i830_emit_flush;
+ i830->intel.vtbl.render_start = i830_render_start;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_context.c
new file mode 100644
index 000000000..42f91241b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_context.c
@@ -0,0 +1,181 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include "i915_context.h"
+#include "imports.h"
+#include "intel_tex.h"
+#include "intel_tris.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+#include "tnl/t_vertex.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "array_cache/acache.h"
+
+#include "utils.h"
+#include "i915_reg.h"
+
+/***************************************
+ * Mesa's Driver Functions
+ ***************************************/
+
+static const struct dri_extension i915_extensions[] =
+{
+ { "GL_ARB_depth_texture", NULL },
+ { "GL_ARB_fragment_program", NULL },
+ { "GL_ARB_shadow", NULL },
+ { "GL_EXT_shadow_funcs", NULL },
+ /* ARB extn won't work if not enabled */
+ { "GL_SGIX_depth_texture", NULL },
+ { NULL, NULL }
+};
+
+/* Override intel default.
+ */
+static void i915InvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ _tnl_invalidate_vertex_state( ctx, new_state );
+ INTEL_CONTEXT(ctx)->NewGLState |= new_state;
+
+ /* Todo: gather state values under which tracked parameters become
+ * invalidated, add callbacks for things like
+ * ProgramLocalParameters, etc.
+ */
+ {
+ struct i915_fragment_program *p =
+ (struct i915_fragment_program *)ctx->FragmentProgram._Current;
+ if (p && p->nr_params)
+ p->params_uptodate = 0;
+ }
+
+ if (new_state & (_NEW_FOG|_NEW_HINT|_NEW_PROGRAM))
+ i915_update_fog(ctx);
+}
+
+
+static void i915InitDriverFunctions( struct dd_function_table *functions )
+{
+ intelInitDriverFunctions( functions );
+ i915InitStateFunctions( functions );
+ i915InitTextureFuncs( functions );
+ i915InitFragProgFuncs( functions );
+ functions->UpdateState = i915InvalidateState;
+}
+
+
+
+GLboolean i915CreateContext( const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate)
+{
+ struct dd_function_table functions;
+ i915ContextPtr i915 = (i915ContextPtr) CALLOC_STRUCT(i915_context);
+ intelContextPtr intel = &i915->intel;
+ GLcontext *ctx = &intel->ctx;
+
+ if (!i915) return GL_FALSE;
+
+ i915InitVtbl( i915 );
+
+ i915InitDriverFunctions( &functions );
+
+ if (!intelInitContext( intel, mesaVis, driContextPriv,
+ sharedContextPrivate, &functions )) {
+ FREE(i915);
+ return GL_FALSE;
+ }
+
+ ctx->Const.MaxTextureUnits = I915_TEX_UNITS;
+ ctx->Const.MaxTextureImageUnits = I915_TEX_UNITS;
+ ctx->Const.MaxTextureCoordUnits = I915_TEX_UNITS;
+
+ intel->nr_heaps = 1;
+ intel->texture_heaps[0] =
+ driCreateTextureHeap( 0, intel,
+ intel->intelScreen->textureSize,
+ 12,
+ I830_NR_TEX_REGIONS,
+ intel->sarea->texList,
+ & intel->sarea->texAge,
+ & intel->swapped,
+ sizeof( struct i915_texture_object ),
+ (destroy_texture_object_t *)intelDestroyTexObj );
+
+ /* FIXME: driCalculateMaxTextureLevels assumes that mipmaps are
+ * tightly packed, but they're not in Intel graphics
+ * hardware.
+ */
+ ctx->Const.MaxTextureUnits = 1;
+ driCalculateMaxTextureLevels( intel->texture_heaps,
+ intel->nr_heaps,
+ &intel->ctx.Const,
+ 4,
+ 11, /* max 2D texture size is 2048x2048 */
+ 8, /* 3D texture */
+ 11, /* cube texture. */
+ 11, /* rect texture */
+ 12,
+ GL_FALSE );
+ ctx->Const.MaxTextureUnits = I915_TEX_UNITS;
+
+ /* GL_ARB_fragment_program limits - don't think Mesa actually
+ * validates programs against these, and in any case one ARB
+ * instruction can translate to more than one HW instruction, so
+ * we'll still have to check and fallback each time.
+ */
+
+ ctx->Const.MaxFragmentProgramTemps = I915_MAX_TEMPORARY;
+ ctx->Const.MaxFragmentProgramAttribs = 11; /* 8 tex, 2 color, fog */
+ ctx->Const.MaxFragmentProgramLocalParams = I915_MAX_CONSTANT;
+ ctx->Const.MaxFragmentProgramEnvParams = I915_MAX_CONSTANT;
+ ctx->Const.MaxFragmentProgramAluInstructions = I915_MAX_ALU_INSN;
+ ctx->Const.MaxFragmentProgramTexInstructions = I915_MAX_TEX_INSN;
+ ctx->Const.MaxFragmentProgramInstructions = (I915_MAX_ALU_INSN +
+ I915_MAX_TEX_INSN);
+ ctx->Const.MaxFragmentProgramTexIndirections = I915_MAX_TEX_INDIRECT;
+ ctx->Const.MaxFragmentProgramAddressRegs = 0; /* I don't think we have one */
+
+
+ driInitExtensions( ctx, i915_extensions, GL_FALSE );
+
+
+ _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
+ 36 * sizeof(GLfloat) );
+
+ intel->verts = TNL_CONTEXT(ctx)->clipspace.vertex_buf;
+
+ i915InitState( i915 );
+
+ return GL_TRUE;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_context.h
new file mode 100644
index 000000000..804627764
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_context.h
@@ -0,0 +1,351 @@
+ /**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#ifndef I915CONTEXT_INC
+#define I915CONTEXT_INC
+
+#include "intel_context.h"
+
+#define I915_FALLBACK_TEXTURE 0x1000
+#define I915_FALLBACK_COLORMASK 0x2000
+#define I915_FALLBACK_STENCIL 0x4000
+#define I915_FALLBACK_STIPPLE 0x8000
+#define I915_FALLBACK_PROGRAM 0x10000
+#define I915_FALLBACK_LOGICOP 0x20000
+
+#define I915_UPLOAD_CTX 0x1
+#define I915_UPLOAD_BUFFERS 0x2
+#define I915_UPLOAD_STIPPLE 0x4
+#define I915_UPLOAD_PROGRAM 0x8
+#define I915_UPLOAD_CONSTANTS 0x10
+#define I915_UPLOAD_FOG 0x20
+#define I915_UPLOAD_TEX(i) (0x00010000<<(i))
+#define I915_UPLOAD_TEX_ALL (0x00ff0000)
+#define I915_UPLOAD_TEX_0_SHIFT 16
+
+
+/* State structure offsets - these will probably disappear.
+ */
+#define I915_DESTREG_CBUFADDR0 0
+#define I915_DESTREG_CBUFADDR1 1
+#define I915_DESTREG_CBUFADDR2 2
+#define I915_DESTREG_DBUFADDR0 3
+#define I915_DESTREG_DBUFADDR1 4
+#define I915_DESTREG_DBUFADDR2 5
+#define I915_DESTREG_DV0 6
+#define I915_DESTREG_DV1 7
+#define I915_DESTREG_SENABLE 8
+#define I915_DESTREG_SR0 9
+#define I915_DESTREG_SR1 10
+#define I915_DESTREG_SR2 11
+#define I915_DEST_SETUP_SIZE 12
+
+#define I915_CTXREG_STATE4 0
+#define I915_CTXREG_LI 1
+#define I915_CTXREG_LIS2 2
+#define I915_CTXREG_LIS4 3
+#define I915_CTXREG_LIS5 4
+#define I915_CTXREG_LIS6 5
+#define I915_CTXREG_IAB 6
+#define I915_CTXREG_BLENDCOLOR0 7
+#define I915_CTXREG_BLENDCOLOR1 8
+#define I915_CTX_SETUP_SIZE 9
+
+#define I915_FOGREG_COLOR 0
+#define I915_FOGREG_MODE0 1
+#define I915_FOGREG_MODE1 2
+#define I915_FOGREG_MODE2 3
+#define I915_FOGREG_MODE3 4
+#define I915_FOG_SETUP_SIZE 5
+
+#define I915_STPREG_ST0 0
+#define I915_STPREG_ST1 1
+#define I915_STP_SETUP_SIZE 2
+
+#define I915_TEXREG_MS2 0
+#define I915_TEXREG_MS3 1
+#define I915_TEXREG_MS4 2
+#define I915_TEXREG_SS2 3
+#define I915_TEXREG_SS3 4
+#define I915_TEXREG_SS4 5
+#define I915_TEX_SETUP_SIZE 6
+
+#define I915_MAX_CONSTANT 32
+#define I915_CONSTANT_SIZE (2+(4*I915_MAX_CONSTANT))
+
+
+#define I915_PROGRAM_SIZE 192
+
+
+/* Hardware version of a parsed fragment program. "Derived" from the
+ * mesa fragment_program struct.
+ */
+struct i915_fragment_program {
+ struct fragment_program FragProg;
+
+ GLboolean translated;
+ GLboolean params_uptodate;
+ GLboolean on_hardware;
+ GLboolean error; /* If program is malformed for any reason. */
+
+ GLuint nr_tex_indirect;
+ GLuint nr_tex_insn;
+ GLuint nr_alu_insn;
+ GLuint nr_decl_insn;
+
+
+
+
+ /* TODO: split between the stored representation of a program and
+ * the state used to build that representation.
+ */
+ GLcontext *ctx;
+
+ GLuint declarations[I915_PROGRAM_SIZE];
+ GLuint program[I915_PROGRAM_SIZE];
+
+ GLfloat constant[I915_MAX_CONSTANT][4];
+ GLuint constant_flags[I915_MAX_CONSTANT];
+ GLuint nr_constants;
+
+ GLuint *csr; /* Cursor, points into program.
+ */
+
+ GLuint *decl; /* Cursor, points into declarations.
+ */
+
+ GLuint decl_s; /* flags for which s regs need to be decl'd */
+ GLuint decl_t; /* flags for which t regs need to be decl'd */
+
+ GLuint temp_flag; /* Tracks temporary regs which are in
+ * use.
+ */
+
+ GLuint utemp_flag; /* Tracks TYPE_U temporary regs which are in
+ * use.
+ */
+
+
+
+ /* Helpers for i915_fragprog.c:
+ */
+ GLuint wpos_tex;
+ GLboolean depth_written;
+
+ struct {
+ GLuint reg; /* Hardware constant idx */
+ const GLfloat *values; /* Pointer to tracked values */
+ } param[I915_MAX_CONSTANT];
+ GLuint nr_params;
+
+
+
+
+ /* Helpers for i915_texprog.c:
+ */
+ GLuint src_texture; /* Reg containing sampled texture color,
+ * else UREG_BAD.
+ */
+
+ GLuint src_previous; /* Reg containing color from previous
+ * stage. May need to be decl'd.
+ */
+
+ GLuint last_tex_stage; /* Number of last enabled texture unit */
+
+ struct vertex_buffer *VB;
+};
+
+
+
+
+
+
+struct i915_texture_object
+{
+ struct intel_texture_object intel;
+ GLenum lastTarget;
+ GLboolean refs_border_color;
+ GLuint Setup[I915_TEX_SETUP_SIZE];
+};
+
+#define I915_TEX_UNITS 8
+
+
+struct i915_hw_state {
+ GLuint Ctx[I915_CTX_SETUP_SIZE];
+ GLuint Buffer[I915_DEST_SETUP_SIZE];
+ GLuint Stipple[I915_STP_SETUP_SIZE];
+ GLuint Fog[I915_FOG_SETUP_SIZE];
+ GLuint Tex[I915_TEX_UNITS][I915_TEX_SETUP_SIZE];
+ GLuint Constant[I915_CONSTANT_SIZE];
+ GLuint ConstantSize;
+ GLuint Program[I915_PROGRAM_SIZE];
+ GLuint ProgramSize;
+ GLuint active; /* I915_UPLOAD_* */
+ GLuint emitted; /* I915_UPLOAD_* */
+};
+
+#define I915_FOG_PIXEL 2
+#define I915_FOG_VERTEX 1
+#define I915_FOG_NONE 0
+
+struct i915_context
+{
+ struct intel_context intel;
+
+ GLuint last_ReallyEnabled;
+ GLuint vertex_fog;
+
+ struct i915_fragment_program tex_program;
+ struct i915_fragment_program *current_program;
+
+ struct i915_hw_state meta, initial, state, *current;
+};
+
+
+typedef struct i915_context *i915ContextPtr;
+typedef struct i915_texture_object *i915TextureObjectPtr;
+
+#define I915_CONTEXT(ctx) ((i915ContextPtr)(ctx))
+
+
+
+#define I915_STATECHANGE(i915, flag) \
+do { \
+ if (0) fprintf(stderr, "I915_STATECHANGE %x in %s\n", flag, __FUNCTION__); \
+ INTEL_FIREVERTICES( &(i915)->intel ); \
+ (i915)->state.emitted &= ~(flag); \
+} while (0)
+
+#define I915_ACTIVESTATE(i915, flag, mode) \
+do { \
+ if (0) fprintf(stderr, "I915_ACTIVESTATE %x %d in %s\n", \
+ flag, mode, __FUNCTION__); \
+ INTEL_FIREVERTICES( &(i915)->intel ); \
+ if (mode) \
+ (i915)->state.active |= (flag); \
+ else \
+ (i915)->state.active &= ~(flag); \
+} while (0)
+
+
+/*======================================================================
+ * i915_vtbl.c
+ */
+extern void i915InitVtbl( i915ContextPtr i915 );
+
+
+
+#define SZ_TO_HW(sz) ((sz-2)&0x3)
+#define EMIT_SZ(sz) (EMIT_1F + (sz) - 1)
+#define EMIT_ATTR( ATTR, STYLE, S4, SZ ) \
+do { \
+ intel->vertex_attrs[intel->vertex_attr_count].attrib = (ATTR); \
+ intel->vertex_attrs[intel->vertex_attr_count].format = (STYLE); \
+ s4 |= S4; \
+ intel->vertex_attr_count++; \
+ offset += (SZ); \
+} while (0)
+
+#define EMIT_PAD( N ) \
+do { \
+ intel->vertex_attrs[intel->vertex_attr_count].attrib = 0; \
+ intel->vertex_attrs[intel->vertex_attr_count].format = EMIT_PAD; \
+ intel->vertex_attrs[intel->vertex_attr_count].offset = (N); \
+ intel->vertex_attr_count++; \
+ offset += (N); \
+} while (0)
+
+
+
+/*======================================================================
+ * i915_context.c
+ */
+extern GLboolean i915CreateContext( const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate);
+
+
+/*======================================================================
+ * i915_texprog.c
+ */
+extern void i915ValidateTextureProgram( i915ContextPtr i915 );
+
+
+/*======================================================================
+ * i915_debug.c
+ */
+extern void i915_disassemble_program( const GLuint *program, GLuint sz );
+extern void i915_print_ureg( const char *msg, GLuint ureg );
+
+
+/*======================================================================
+ * i915_state.c
+ */
+extern void i915InitStateFunctions( struct dd_function_table *functions );
+extern void i915InitState( i915ContextPtr i915 );
+extern void i915_update_fog( GLcontext *ctx );
+
+
+/*======================================================================
+ * i915_tex.c
+ */
+extern void i915UpdateTextureState( intelContextPtr intel );
+extern void i915InitTextureFuncs( struct dd_function_table *functions );
+extern intelTextureObjectPtr i915AllocTexObj( struct gl_texture_object *texObj );
+
+/*======================================================================
+ * i915_metaops.c
+ */
+extern GLboolean
+i915TryTextureReadPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack,
+ GLvoid *pixels );
+
+extern GLboolean
+i915TryTextureDrawPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels );
+
+extern void
+i915ClearWithTris( intelContextPtr intel, GLbitfield mask,
+ GLboolean all, GLint cx, GLint cy, GLint cw, GLint ch);
+
+
+/*======================================================================
+ * i915_fragprog.c
+ */
+extern void i915ValidateFragmentProgram( i915ContextPtr i915 );
+extern void i915InitFragProgFuncs( struct dd_function_table *functions );
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_debug.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_debug.c
new file mode 100644
index 000000000..054b56160
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_debug.c
@@ -0,0 +1,299 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include "i915_reg.h"
+#include "i915_context.h"
+#include <stdio.h>
+
+
+static const char *opcodes[0x20] = {
+ "NOP",
+ "ADD",
+ "MOV",
+ "MUL",
+ "MAD",
+ "DP2ADD",
+ "DP3",
+ "DP4",
+ "FRC",
+ "RCP",
+ "RSQ",
+ "EXP",
+ "LOG",
+ "CMP",
+ "MIN",
+ "MAX",
+ "FLR",
+ "MOD",
+ "TRC",
+ "SGE",
+ "SLT",
+ "TEXLD",
+ "TEXLDP",
+ "TEXLDB",
+ "TEXKILL",
+ "DCL",
+ "0x1a",
+ "0x1b",
+ "0x1c",
+ "0x1d",
+ "0x1e",
+ "0x1f",
+};
+
+
+static const int args[0x20] = {
+ 0, /* 0 nop */
+ 2, /* 1 add */
+ 1, /* 2 mov */
+ 2, /* 3 m ul */
+ 3, /* 4 mad */
+ 3, /* 5 dp2add */
+ 2, /* 6 dp3 */
+ 2, /* 7 dp4 */
+ 1, /* 8 frc */
+ 1, /* 9 rcp */
+ 1, /* a rsq */
+ 1, /* b exp */
+ 1, /* c log */
+ 3, /* d cmp */
+ 2, /* e min */
+ 2, /* f max */
+ 1, /* 10 flr */
+ 1, /* 11 mod */
+ 1, /* 12 trc */
+ 2, /* 13 sge */
+ 2, /* 14 slt */
+ 1,
+ 1,
+ 1,
+ 1,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+
+static const char *regname[0x8] = {
+ "R",
+ "T",
+ "CONST",
+ "S",
+ "OC",
+ "OD",
+ "U",
+ "UNKNOWN",
+};
+
+static void print_reg_type_nr( GLuint type, GLuint nr )
+{
+ switch (type) {
+ case REG_TYPE_T:
+ switch (nr) {
+ case T_DIFFUSE: fprintf(stderr, "T_DIFFUSE"); return;
+ case T_SPECULAR: fprintf(stderr, "T_SPECULAR"); return;
+ case T_FOG_W: fprintf(stderr, "T_FOG_W"); return;
+ default: fprintf(stderr, "T_TEX%d", nr); return;
+ }
+ case REG_TYPE_OC:
+ if (nr == 0) {
+ fprintf(stderr, "oC");
+ return;
+ }
+ break;
+ case REG_TYPE_OD:
+ if (nr == 0) {
+ fprintf(stderr, "oD");
+ return;
+ }
+ break;
+ default:
+ break;
+ }
+
+ fprintf(stderr, "%s[%d]", regname[type], nr);
+}
+
+#define REG_SWIZZLE_MASK 0x7777
+#define REG_NEGATE_MASK 0x8888
+
+#define REG_SWIZZLE_XYZW ((SRC_X << A2_SRC2_CHANNEL_X_SHIFT) | \
+ (SRC_Y << A2_SRC2_CHANNEL_Y_SHIFT) | \
+ (SRC_Z << A2_SRC2_CHANNEL_Z_SHIFT) | \
+ (SRC_W << A2_SRC2_CHANNEL_W_SHIFT))
+
+
+static void print_reg_neg_swizzle( GLuint reg )
+{
+ int i;
+
+ if ((reg & REG_SWIZZLE_MASK) == REG_SWIZZLE_XYZW &&
+ (reg & REG_NEGATE_MASK) == 0)
+ return;
+
+ fprintf(stderr, ".");
+
+ for (i = 3 ; i >= 0; i--) {
+ if (reg & (1<<((i*4)+3)))
+ fprintf(stderr, "-");
+
+ switch ((reg>>(i*4)) & 0x7) {
+ case 0: fprintf(stderr, "x"); break;
+ case 1: fprintf(stderr, "y"); break;
+ case 2: fprintf(stderr, "z"); break;
+ case 3: fprintf(stderr, "w"); break;
+ case 4: fprintf(stderr, "0"); break;
+ case 5: fprintf(stderr, "1"); break;
+ default: fprintf(stderr, "?"); break;
+ }
+ }
+}
+
+
+static void print_src_reg( GLuint dword )
+{
+ GLuint nr = (dword >> A2_SRC2_NR_SHIFT) & REG_NR_MASK;
+ GLuint type = (dword >> A2_SRC2_TYPE_SHIFT) & REG_TYPE_MASK;
+ print_reg_type_nr( type, nr );
+ print_reg_neg_swizzle( dword );
+}
+
+void i915_print_ureg( const char *msg, GLuint ureg )
+{
+ fprintf(stderr, "%s: ", msg);
+ print_src_reg( ureg >> 8 );
+ fprintf(stderr, "\n");
+}
+
+static void print_dest_reg( GLuint dword )
+{
+ GLuint nr = (dword >> A0_DEST_NR_SHIFT) & REG_NR_MASK;
+ GLuint type = (dword >> A0_DEST_TYPE_SHIFT) & REG_TYPE_MASK;
+ print_reg_type_nr( type, nr );
+ if ((dword & A0_DEST_CHANNEL_ALL) == A0_DEST_CHANNEL_ALL)
+ return;
+ fprintf(stderr, ".");
+ if (dword & A0_DEST_CHANNEL_X) fprintf(stderr, "x");
+ if (dword & A0_DEST_CHANNEL_Y) fprintf(stderr, "y");
+ if (dword & A0_DEST_CHANNEL_Z) fprintf(stderr, "z");
+ if (dword & A0_DEST_CHANNEL_W) fprintf(stderr, "w");
+}
+
+
+#define GET_SRC0_REG(r0, r1) ((r0<<14)|(r1>>A1_SRC0_CHANNEL_W_SHIFT))
+#define GET_SRC1_REG(r0, r1) ((r0<<8)|(r1>>A2_SRC1_CHANNEL_W_SHIFT))
+#define GET_SRC2_REG(r) (r)
+
+
+static void print_arith_op( GLuint opcode, const GLuint *program )
+{
+ if (opcode != A0_NOP) {
+ print_dest_reg(program[0]);
+ if (program[0] & A0_DEST_SATURATE)
+ fprintf(stderr, " = SATURATE ");
+ else
+ fprintf(stderr, " = ");
+ }
+
+ fprintf(stderr, "%s ", opcodes[opcode]);
+
+ print_src_reg(GET_SRC0_REG(program[0], program[1]));
+ if (args[opcode] == 1) {
+ fprintf(stderr, "\n");
+ return;
+ }
+
+ fprintf(stderr, ", ");
+ print_src_reg(GET_SRC1_REG(program[1], program[2]));
+ if (args[opcode] == 2) {
+ fprintf(stderr, "\n");
+ return;
+ }
+
+ fprintf(stderr, ", ");
+ print_src_reg(GET_SRC2_REG(program[2]));
+ fprintf(stderr, "\n");
+ return;
+}
+
+
+static void print_tex_op( GLuint opcode, const GLuint *program )
+{
+ print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL);
+ fprintf(stderr, " = ");
+
+ fprintf(stderr, "%s ", opcodes[opcode]);
+
+ fprintf(stderr, "S[%d],",
+ program[0] & T0_SAMPLER_NR_MASK);
+
+ print_reg_type_nr( (program[1]>>T1_ADDRESS_REG_TYPE_SHIFT) & REG_TYPE_MASK,
+ (program[1]>>T1_ADDRESS_REG_NR_SHIFT) & REG_NR_MASK );
+ fprintf(stderr, "\n");
+}
+
+static void print_dcl_op( GLuint opcode, const GLuint *program )
+{
+ fprintf(stderr, "%s ", opcodes[opcode]);
+ print_dest_reg(program[0] | A0_DEST_CHANNEL_ALL);
+ fprintf(stderr, "\n");
+}
+
+
+void i915_disassemble_program( const GLuint *program, GLuint sz )
+{
+ GLuint size = program[0] & 0x1ff;
+ GLint i;
+
+ fprintf(stderr, "BEGIN\n");
+
+ if (size+2 != sz) {
+ fprintf(stderr, "%s: program size mismatch %d/%d\n", __FUNCTION__,
+ size+2, sz);
+ exit(1);
+ }
+
+ program ++;
+ for (i = 1 ; i < sz ; i+=3, program+=3) {
+ GLuint opcode = program[0] & (0x1f<<24);
+
+ if ((GLint) opcode >= A0_NOP && opcode <= A0_SLT)
+ print_arith_op(opcode >> 24, program);
+ else if (opcode >= T0_TEXLD && opcode <= T0_TEXKILL)
+ print_tex_op(opcode >> 24, program);
+ else if (opcode == D0_DCL)
+ print_dcl_op(opcode >> 24, program);
+ else
+ fprintf(stderr, "Unknown opcode 0x%x\n", opcode);
+ }
+
+ fprintf(stderr, "END\n\n");
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_fragprog.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_fragprog.c
new file mode 100644
index 000000000..b69252d2a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_fragprog.c
@@ -0,0 +1,1065 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include "glheader.h"
+#include "macros.h"
+#include "enums.h"
+
+#include "tnl/t_context.h"
+#include "intel_batchbuffer.h"
+
+#include "i915_reg.h"
+#include "i915_context.h"
+#include "i915_program.h"
+
+#include "nvfragprog.h"
+#include "program.h"
+#include "arbfragparse.h"
+
+
+
+#undef PI
+#define PI 3.141592
+
+
+/* 1, -1/3!, 1/5!, -1/7! */
+static const GLfloat sin_constants[4] = { 1.0,
+ -1.0/(3*2*1),
+ 1.0/(5*4*3*2*1),
+ -1.0/(7*6*5*4*3*2*1) };
+
+/* 1, -1/2!, 1/4!, -1/6! */
+static const GLfloat cos_constants[4] = { 1.0,
+ -1.0/(2*1),
+ 1.0/(4*3*2*1),
+ -1.0/(6*5*4*3*2*1) };
+
+/**
+ * Retrieve a ureg for the given source register. Will emit
+ * constants, apply swizzling and negation as needed.
+ */
+static GLuint src_vector( struct i915_fragment_program *p,
+ const struct fp_src_register *source,
+ const struct fragment_program *program )
+{
+ GLuint src;
+
+ switch (source->File) {
+
+ /* Registers:
+ */
+ case PROGRAM_TEMPORARY:
+ if (source->Index >= I915_MAX_TEMPORARY) {
+ i915_program_error( p, "Exceeded max temporary reg" );
+ return 0;
+ }
+ src = UREG( REG_TYPE_R, source->Index );
+ break;
+ case PROGRAM_INPUT:
+ switch (source->Index) {
+ case FRAG_ATTRIB_WPOS:
+ src = i915_emit_decl( p, REG_TYPE_T, p->wpos_tex, D0_CHANNEL_ALL );
+ break;
+ case FRAG_ATTRIB_COL0:
+ src = i915_emit_decl( p, REG_TYPE_T, T_DIFFUSE, D0_CHANNEL_ALL );
+ break;
+ case FRAG_ATTRIB_COL1:
+ src = i915_emit_decl( p, REG_TYPE_T, T_SPECULAR, D0_CHANNEL_XYZ );
+ src = swizzle( src, X, Y, Z, ONE );
+ break;
+ case FRAG_ATTRIB_FOGC:
+ src = i915_emit_decl( p, REG_TYPE_T, T_FOG_W, D0_CHANNEL_W );
+ src = swizzle( src, W, W, W, W );
+ break;
+ case FRAG_ATTRIB_TEX0:
+ case FRAG_ATTRIB_TEX1:
+ case FRAG_ATTRIB_TEX2:
+ case FRAG_ATTRIB_TEX3:
+ case FRAG_ATTRIB_TEX4:
+ case FRAG_ATTRIB_TEX5:
+ case FRAG_ATTRIB_TEX6:
+ case FRAG_ATTRIB_TEX7:
+ src = i915_emit_decl( p, REG_TYPE_T,
+ T_TEX0 + (source->Index - FRAG_ATTRIB_TEX0),
+ D0_CHANNEL_ALL );
+ break;
+
+ default:
+ i915_program_error( p, "Bad source->Index" );
+ return 0;
+ }
+ break;
+
+ /* Various paramters and env values. All emitted to
+ * hardware as program constants.
+ */
+ case PROGRAM_LOCAL_PARAM:
+ src = i915_emit_param4fv(
+ p, program->Base.LocalParams[source->Index]);
+ break;
+
+ case PROGRAM_ENV_PARAM:
+ src = i915_emit_param4fv(
+ p, p->ctx->FragmentProgram.Parameters[source->Index]);
+ break;
+
+ case PROGRAM_STATE_VAR:
+ case PROGRAM_NAMED_PARAM:
+ src = i915_emit_param4fv(
+ p, program->Parameters->ParameterValues[source->Index] );
+ break;
+
+ default:
+ i915_program_error( p, "Bad source->File" );
+ return 0;
+ }
+
+ src = swizzle(src,
+ GET_SWZ(source->Swizzle, 0),
+ GET_SWZ(source->Swizzle, 1),
+ GET_SWZ(source->Swizzle, 2),
+ GET_SWZ(source->Swizzle, 3));
+
+ if (source->NegateBase)
+ src = negate( src, 1,1,1,1 );
+
+ return src;
+}
+
+
+static GLuint get_result_vector( struct i915_fragment_program *p,
+ const struct fp_instruction *inst )
+{
+ switch (inst->DstReg.File) {
+ case PROGRAM_OUTPUT:
+ switch (inst->DstReg.Index) {
+ case FRAG_OUTPUT_COLR:
+ return UREG(REG_TYPE_OC, 0);
+ case FRAG_OUTPUT_DEPR:
+ p->depth_written = 1;
+ return UREG(REG_TYPE_OD, 0);
+ default:
+ i915_program_error( p, "Bad inst->DstReg.Index" );
+ return 0;
+ }
+ case PROGRAM_TEMPORARY:
+ return UREG(REG_TYPE_R, inst->DstReg.Index);
+ default:
+ i915_program_error( p, "Bad inst->DstReg.File" );
+ return 0;
+ }
+}
+
+static GLuint get_result_flags( const struct fp_instruction *inst )
+{
+ GLuint flags = 0;
+
+ if (inst->Saturate) flags |= A0_DEST_SATURATE;
+ if (inst->DstReg.WriteMask & WRITEMASK_X) flags |= A0_DEST_CHANNEL_X;
+ if (inst->DstReg.WriteMask & WRITEMASK_Y) flags |= A0_DEST_CHANNEL_Y;
+ if (inst->DstReg.WriteMask & WRITEMASK_Z) flags |= A0_DEST_CHANNEL_Z;
+ if (inst->DstReg.WriteMask & WRITEMASK_W) flags |= A0_DEST_CHANNEL_W;
+
+ return flags;
+}
+
+static GLuint translate_tex_src_idx( struct i915_fragment_program *p,
+ GLubyte bit )
+{
+ switch (bit) {
+ case TEXTURE_1D_INDEX: return D0_SAMPLE_TYPE_2D;
+ case TEXTURE_2D_INDEX: return D0_SAMPLE_TYPE_2D;
+ case TEXTURE_RECT_INDEX: return D0_SAMPLE_TYPE_2D;
+ case TEXTURE_3D_INDEX: return D0_SAMPLE_TYPE_VOLUME;
+ case TEXTURE_CUBE_INDEX: return D0_SAMPLE_TYPE_CUBE;
+ default: i915_program_error(p, "TexSrcBit"); return 0;
+ }
+}
+
+#define EMIT_TEX( OP ) \
+do { \
+ GLuint dim = translate_tex_src_idx( p, inst->TexSrcIdx ); \
+ GLuint sampler = i915_emit_decl(p, REG_TYPE_S, \
+ inst->TexSrcUnit, dim); \
+ GLuint coord = src_vector( p, &inst->SrcReg[0], program); \
+ /* Texel lookup */ \
+ \
+ i915_emit_texld( p, \
+ get_result_vector( p, inst ), \
+ get_result_flags( inst ), \
+ sampler, \
+ coord, \
+ OP); \
+} while (0)
+
+#define EMIT_ARITH( OP, N ) \
+do { \
+ i915_emit_arith( p, \
+ OP, \
+ get_result_vector( p, inst ), \
+ get_result_flags( inst ), 0, \
+ (N<1)?0:src_vector( p, &inst->SrcReg[0], program), \
+ (N<2)?0:src_vector( p, &inst->SrcReg[1], program), \
+ (N<3)?0:src_vector( p, &inst->SrcReg[2], program)); \
+} while (0)
+
+#define EMIT_1ARG_ARITH( OP ) EMIT_ARITH( OP, 1 )
+#define EMIT_2ARG_ARITH( OP ) EMIT_ARITH( OP, 2 )
+#define EMIT_3ARG_ARITH( OP ) EMIT_ARITH( OP, 3 )
+
+
+/* Possible concerns:
+ *
+ * SIN, COS -- could use another taylor step?
+ * LIT -- results seem a little different to sw mesa
+ * LOG -- different to mesa on negative numbers, but this is conformant.
+ *
+ * Parse failures -- Mesa doesn't currently give a good indication
+ * internally whether a particular program string parsed or not. This
+ * can lead to confusion -- hopefully we cope with it ok now.
+ *
+ */
+static void upload_program( struct i915_fragment_program *p )
+{
+ const struct fragment_program *program = p->ctx->FragmentProgram._Current;
+ const struct fp_instruction *inst = program->Instructions;
+
+/* _mesa_debug_fp_inst(program->Base.NumInstructions, inst); */
+
+ /* Is this a parse-failed program? Ensure a valid program is
+ * loaded, as the flagging of an error isn't sufficient to stop
+ * this being uploaded to hardware.
+ */
+ if (inst[0].Opcode == FP_OPCODE_END) {
+ GLuint tmp = i915_get_utemp( p );
+ i915_emit_arith( p,
+ A0_MOV,
+ UREG(REG_TYPE_OC, 0),
+ A0_DEST_CHANNEL_ALL, 0,
+ swizzle(tmp,ONE,ZERO,ONE,ONE), 0, 0);
+ return;
+ }
+
+ while (1) {
+ GLuint src0, src1, src2, flags;
+ GLuint tmp = 0;
+
+ switch (inst->Opcode) {
+ case FP_OPCODE_ABS:
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+ i915_emit_arith( p,
+ A0_MAX,
+ get_result_vector( p, inst ),
+ get_result_flags( inst ), 0,
+ src0, negate(src0, 1,1,1,1), 0);
+ break;
+
+ case FP_OPCODE_ADD:
+ EMIT_2ARG_ARITH( A0_ADD );
+ break;
+
+ case FP_OPCODE_CMP:
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+ src1 = src_vector( p, &inst->SrcReg[1], program);
+ src2 = src_vector( p, &inst->SrcReg[2], program);
+ i915_emit_arith( p,
+ A0_CMP,
+ get_result_vector( p, inst ),
+ get_result_flags( inst ), 0,
+ src0, src2, src1); /* NOTE: order of src2, src1 */
+ break;
+
+ case FP_OPCODE_COS:
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+ tmp = i915_get_utemp( p );
+
+ i915_emit_arith( p,
+ A0_MUL,
+ tmp, A0_DEST_CHANNEL_X, 0,
+ src0,
+ i915_emit_const1f(p, 1.0/(PI * 2)),
+ 0);
+
+ i915_emit_arith( p,
+ A0_MOD,
+ tmp, A0_DEST_CHANNEL_X, 0,
+ tmp,
+ 0, 0 );
+
+ /* By choosing different taylor constants, could get rid of this mul:
+ */
+ i915_emit_arith( p,
+ A0_MUL,
+ tmp, A0_DEST_CHANNEL_X, 0,
+ tmp,
+ i915_emit_const1f(p, (PI * 2)),
+ 0);
+
+ /*
+ * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1
+ * t0 = MUL t0.xyxy t0.xx11 ; x^4, x^3, x^2, 1
+ * t0 = MUL t0.xxz1 t0.z111 ; x^6 x^4 x^2 1
+ * result = DP4 t0, cos_constants
+ */
+ i915_emit_arith( p,
+ A0_MUL,
+ tmp, A0_DEST_CHANNEL_XY, 0,
+ swizzle(tmp, X,X,ONE,ONE),
+ swizzle(tmp, X,ONE,ONE,ONE), 0);
+
+ i915_emit_arith( p,
+ A0_MUL,
+ tmp, A0_DEST_CHANNEL_XYZ, 0,
+ swizzle(tmp, X,Y,X,ONE),
+ swizzle(tmp, X,X,ONE,ONE), 0);
+
+ i915_emit_arith( p,
+ A0_MUL,
+ tmp, A0_DEST_CHANNEL_XYZ, 0,
+ swizzle(tmp, X,X,Z,ONE),
+ swizzle(tmp, Z,ONE,ONE,ONE), 0);
+
+ i915_emit_arith( p,
+ A0_DP4,
+ get_result_vector( p, inst ),
+ get_result_flags( inst ), 0,
+ swizzle(tmp, ONE,Z,Y,X),
+ i915_emit_const4fv( p, cos_constants ), 0);
+
+ break;
+
+ case FP_OPCODE_DP3:
+ EMIT_2ARG_ARITH( A0_DP3 );
+ break;
+
+ case FP_OPCODE_DP4:
+ EMIT_2ARG_ARITH( A0_DP4 );
+ break;
+
+ case FP_OPCODE_DPH:
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+ src1 = src_vector( p, &inst->SrcReg[1], program);
+
+ i915_emit_arith( p,
+ A0_DP4,
+ get_result_vector( p, inst ),
+ get_result_flags( inst ), 0,
+ swizzle(src0, X,Y,Z,ONE), src1, 0);
+ break;
+
+ case FP_OPCODE_DST:
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+ src1 = src_vector( p, &inst->SrcReg[1], program);
+
+ /* result[0] = 1 * 1;
+ * result[1] = a[1] * b[1];
+ * result[2] = a[2] * 1;
+ * result[3] = 1 * b[3];
+ */
+ i915_emit_arith( p,
+ A0_MUL,
+ get_result_vector( p, inst ),
+ get_result_flags( inst ), 0,
+ swizzle(src0, ONE, Y, Z, ONE),
+ swizzle(src1, ONE, Y, ONE, W ),
+ 0);
+ break;
+
+ case FP_OPCODE_EX2:
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+
+ i915_emit_arith( p,
+ A0_EXP,
+ get_result_vector( p, inst ),
+ get_result_flags( inst ), 0,
+ swizzle(src0,X,X,X,X), 0, 0);
+ break;
+
+ case FP_OPCODE_FLR:
+ EMIT_1ARG_ARITH( A0_FLR );
+ break;
+
+ case FP_OPCODE_FRC:
+ EMIT_1ARG_ARITH( A0_FRC );
+ break;
+
+ case FP_OPCODE_KIL:
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+ tmp = i915_get_utemp( p );
+
+ i915_emit_texld( p,
+ tmp, A0_DEST_CHANNEL_ALL, /* use a dummy dest reg */
+ 0,
+ src0,
+ T0_TEXKILL );
+ break;
+
+ case FP_OPCODE_LG2:
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+
+ i915_emit_arith( p,
+ A0_LOG,
+ get_result_vector( p, inst ),
+ get_result_flags( inst ), 0,
+ swizzle(src0,X,X,X,X), 0, 0);
+ break;
+
+ case FP_OPCODE_LIT:
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+ tmp = i915_get_utemp( p );
+
+ /* tmp = max( a.xyzw, a.00zw )
+ * XXX: Clamp tmp.w to -128..128
+ * tmp.y = log(tmp.y)
+ * tmp.y = tmp.w * tmp.y
+ * tmp.y = exp(tmp.y)
+ * result = cmp (a.11-x1, a.1x01, a.1xy1 )
+ */
+ i915_emit_arith( p, A0_MAX, tmp, A0_DEST_CHANNEL_ALL, 0,
+ src0, swizzle(src0, ZERO, ZERO, Z, W), 0 );
+
+ i915_emit_arith( p, A0_LOG, tmp, A0_DEST_CHANNEL_Y, 0,
+ swizzle(tmp, Y, Y, Y, Y), 0, 0 );
+
+ i915_emit_arith( p, A0_MUL, tmp, A0_DEST_CHANNEL_Y, 0,
+ swizzle(tmp, ZERO, Y, ZERO, ZERO),
+ swizzle(tmp, ZERO, W, ZERO, ZERO), 0 );
+
+ i915_emit_arith( p, A0_EXP, tmp, A0_DEST_CHANNEL_Y, 0,
+ swizzle(tmp, Y, Y, Y, Y), 0, 0 );
+
+ i915_emit_arith( p, A0_CMP,
+ get_result_vector( p, inst ),
+ get_result_flags( inst ), 0,
+ negate(swizzle(tmp, ONE, ONE, X, ONE),0,0,1,0),
+ swizzle(tmp, ONE, X, ZERO, ONE),
+ swizzle(tmp, ONE, X, Y, ONE));
+
+ break;
+
+ case FP_OPCODE_LRP:
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+ src1 = src_vector( p, &inst->SrcReg[1], program);
+ src2 = src_vector( p, &inst->SrcReg[2], program);
+ flags = get_result_flags( inst );
+ tmp = i915_get_utemp( p );
+
+ /* b*a + c*(1-a)
+ *
+ * b*a + c - ca
+ *
+ * tmp = b*a + c,
+ * result = (-c)*a + tmp
+ */
+ i915_emit_arith( p, A0_MAD, tmp,
+ flags & A0_DEST_CHANNEL_ALL, 0,
+ src1, src0, src2 );
+
+ i915_emit_arith( p, A0_MAD,
+ get_result_vector( p, inst ),
+ flags, 0,
+ negate(src2, 1,1,1,1), src0, tmp );
+ break;
+
+ case FP_OPCODE_MAD:
+ EMIT_3ARG_ARITH( A0_MAD );
+ break;
+
+ case FP_OPCODE_MAX:
+ EMIT_2ARG_ARITH( A0_MAX );
+ break;
+
+ case FP_OPCODE_MIN:
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+ src1 = src_vector( p, &inst->SrcReg[1], program);
+ tmp = i915_get_utemp( p );
+ flags = get_result_flags( inst );
+
+ i915_emit_arith( p,
+ A0_MAX,
+ tmp, flags & A0_DEST_CHANNEL_ALL, 0,
+ negate(src0,1,1,1,1),
+ negate(src1,1,1,1,1), 0);
+
+ i915_emit_arith( p,
+ A0_MOV,
+ get_result_vector( p, inst ),
+ flags, 0,
+ negate(tmp, 1,1,1,1), 0, 0);
+ break;
+
+ case FP_OPCODE_MOV:
+ EMIT_1ARG_ARITH( A0_MOV );
+ break;
+
+ case FP_OPCODE_MUL:
+ EMIT_2ARG_ARITH( A0_MUL );
+ break;
+
+ case FP_OPCODE_POW:
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+ src1 = src_vector( p, &inst->SrcReg[1], program);
+ tmp = i915_get_utemp( p );
+ flags = get_result_flags( inst );
+
+ /* XXX: masking on intermediate values, here and elsewhere.
+ */
+ i915_emit_arith( p,
+ A0_LOG,
+ tmp, A0_DEST_CHANNEL_X, 0,
+ swizzle(src0,X,X,X,X), 0, 0);
+
+ i915_emit_arith( p,
+ A0_MUL,
+ tmp, A0_DEST_CHANNEL_X, 0,
+ tmp, src1, 0);
+
+
+ i915_emit_arith( p,
+ A0_EXP,
+ get_result_vector( p, inst ),
+ flags, 0,
+ swizzle(tmp,X,X,X,X), 0, 0);
+
+ break;
+
+ case FP_OPCODE_RCP:
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+
+ i915_emit_arith( p,
+ A0_RCP,
+ get_result_vector( p, inst ),
+ get_result_flags( inst ), 0,
+ swizzle(src0,X,X,X,X), 0, 0);
+ break;
+
+ case FP_OPCODE_RSQ:
+
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+
+ i915_emit_arith( p,
+ A0_RSQ,
+ get_result_vector( p, inst ),
+ get_result_flags( inst ), 0,
+ swizzle(src0,X,X,X,X), 0, 0);
+ break;
+
+ case FP_OPCODE_SCS:
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+ tmp = i915_get_utemp( p );
+
+ /*
+ * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1
+ * t0 = MUL t0.xyxy t0.xx11 ; x^4, x^3, x^2, x
+ * t1 = MUL t0.xyyw t0.yz11 ; x^7 x^5 x^3 x
+ * scs.x = DP4 t1, sin_constants
+ * t1 = MUL t0.xxz1 t0.z111 ; x^6 x^4 x^2 1
+ * scs.y = DP4 t1, cos_constants
+ */
+ i915_emit_arith( p,
+ A0_MUL,
+ tmp, A0_DEST_CHANNEL_XY, 0,
+ swizzle(src0, X,X,ONE,ONE),
+ swizzle(src0, X,ONE,ONE,ONE), 0);
+
+ i915_emit_arith( p,
+ A0_MUL,
+ tmp, A0_DEST_CHANNEL_ALL, 0,
+ swizzle(tmp, X,Y,X,Y),
+ swizzle(tmp, X,X,ONE,ONE), 0);
+
+ if (inst->DstReg.WriteMask & WRITEMASK_Y) {
+ GLuint tmp1;
+
+ if (inst->DstReg.WriteMask & WRITEMASK_X)
+ tmp1 = i915_get_utemp( p );
+ else
+ tmp1 = tmp;
+
+ i915_emit_arith( p,
+ A0_MUL,
+ tmp1, A0_DEST_CHANNEL_ALL, 0,
+ swizzle(tmp, X,Y,Y,W),
+ swizzle(tmp, X,Z,ONE,ONE), 0);
+
+ i915_emit_arith( p,
+ A0_DP4,
+ get_result_vector( p, inst ),
+ A0_DEST_CHANNEL_Y, 0,
+ swizzle(tmp1, W,Z,Y,X),
+ i915_emit_const4fv( p, sin_constants ), 0);
+ }
+
+ if (inst->DstReg.WriteMask & WRITEMASK_X) {
+ i915_emit_arith( p,
+ A0_MUL,
+ tmp, A0_DEST_CHANNEL_XYZ, 0,
+ swizzle(tmp, X,X,Z,ONE),
+ swizzle(tmp, Z,ONE,ONE,ONE), 0);
+
+ i915_emit_arith( p,
+ A0_DP4,
+ get_result_vector( p, inst ),
+ A0_DEST_CHANNEL_X, 0,
+ swizzle(tmp, ONE,Z,Y,X),
+ i915_emit_const4fv( p, cos_constants ), 0);
+ }
+ break;
+
+ case FP_OPCODE_SGE:
+ EMIT_2ARG_ARITH( A0_SGE );
+ break;
+
+ case FP_OPCODE_SIN:
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+ tmp = i915_get_utemp( p );
+
+ i915_emit_arith( p,
+ A0_MUL,
+ tmp, A0_DEST_CHANNEL_X, 0,
+ src0,
+ i915_emit_const1f(p, 1.0/(PI * 2)),
+ 0);
+
+ i915_emit_arith( p,
+ A0_MOD,
+ tmp, A0_DEST_CHANNEL_X, 0,
+ tmp,
+ 0, 0 );
+
+ /* By choosing different taylor constants, could get rid of this mul:
+ */
+ i915_emit_arith( p,
+ A0_MUL,
+ tmp, A0_DEST_CHANNEL_X, 0,
+ tmp,
+ i915_emit_const1f(p, (PI * 2)),
+ 0);
+
+ /*
+ * t0.xy = MUL x.xx11, x.x1111 ; x^2, x, 1, 1
+ * t0 = MUL t0.xyxy t0.xx11 ; x^4, x^3, x^2, x
+ * t1 = MUL t0.xyyw t0.yz11 ; x^7 x^5 x^3 x
+ * result = DP4 t1.wzyx, sin_constants
+ */
+ i915_emit_arith( p,
+ A0_MUL,
+ tmp, A0_DEST_CHANNEL_XY, 0,
+ swizzle(tmp, X,X,ONE,ONE),
+ swizzle(tmp, X,ONE,ONE,ONE), 0);
+
+ i915_emit_arith( p,
+ A0_MUL,
+ tmp, A0_DEST_CHANNEL_ALL, 0,
+ swizzle(tmp, X,Y,X,Y),
+ swizzle(tmp, X,X,ONE,ONE), 0);
+
+ i915_emit_arith( p,
+ A0_MUL,
+ tmp, A0_DEST_CHANNEL_ALL, 0,
+ swizzle(tmp, X,Y,Y,W),
+ swizzle(tmp, X,Z,ONE,ONE), 0);
+
+ i915_emit_arith( p,
+ A0_DP4,
+ get_result_vector( p, inst ),
+ get_result_flags( inst ), 0,
+ swizzle(tmp, W, Z, Y, X ),
+ i915_emit_const4fv( p, sin_constants ), 0);
+ break;
+
+ case FP_OPCODE_SLT:
+ EMIT_2ARG_ARITH( A0_SLT );
+ break;
+
+ case FP_OPCODE_SUB:
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+ src1 = src_vector( p, &inst->SrcReg[1], program);
+
+ i915_emit_arith( p,
+ A0_ADD,
+ get_result_vector( p, inst ),
+ get_result_flags( inst ), 0,
+ src0, negate(src1, 1,1,1,1), 0);
+ break;
+
+ case FP_OPCODE_SWZ:
+ EMIT_1ARG_ARITH( A0_MOV ); /* extended swizzle handled natively */
+ break;
+
+ case FP_OPCODE_TEX:
+ EMIT_TEX( T0_TEXLD );
+ break;
+
+ case FP_OPCODE_TXB:
+ EMIT_TEX( T0_TEXLDB );
+ break;
+
+ case FP_OPCODE_TXP:
+ EMIT_TEX( T0_TEXLDP );
+ break;
+
+ case FP_OPCODE_XPD:
+ /* Cross product:
+ * result.x = src0.y * src1.z - src0.z * src1.y;
+ * result.y = src0.z * src1.x - src0.x * src1.z;
+ * result.z = src0.x * src1.y - src0.y * src1.x;
+ * result.w = undef;
+ */
+ src0 = src_vector( p, &inst->SrcReg[0], program);
+ src1 = src_vector( p, &inst->SrcReg[1], program);
+ tmp = i915_get_utemp( p );
+
+ i915_emit_arith( p,
+ A0_MUL,
+ tmp, A0_DEST_CHANNEL_ALL, 0,
+ swizzle(src0,Z,X,Y,ONE),
+ swizzle(src1,Y,Z,X,ONE), 0);
+
+ i915_emit_arith( p,
+ A0_MAD,
+ get_result_vector( p, inst ),
+ get_result_flags( inst ), 0,
+ swizzle(src0,Y,Z,X,ONE),
+ swizzle(src1,Z,X,Y,ONE),
+ negate(tmp,1,1,1,0));
+ break;
+
+ case FP_OPCODE_END:
+ return;
+
+ default:
+ i915_program_error( p, "bad opcode" );
+ return;
+ }
+
+ inst++;
+ i915_release_utemps( p );
+ }
+}
+
+/* Rather than trying to intercept and jiggle depth writes during
+ * emit, just move the value into its correct position at the end of
+ * the program:
+ */
+static void fixup_depth_write( struct i915_fragment_program *p )
+{
+ if (p->depth_written) {
+ GLuint depth = UREG(REG_TYPE_OD, 0);
+
+ i915_emit_arith( p,
+ A0_MOV,
+ depth, A0_DEST_CHANNEL_W, 0,
+ swizzle(depth,X,Y,Z,Z),
+ 0, 0);
+ }
+}
+
+
+#define FRAG_BIT_TEX(n) (FRAG_BIT_TEX0 << (n))
+
+
+static void check_wpos( struct i915_fragment_program *p )
+{
+ GLuint inputs = p->FragProg.InputsRead;
+ GLint i;
+
+ p->wpos_tex = -1;
+
+ for (i = 0; i < p->ctx->Const.MaxTextureCoordUnits; i++) {
+ if (inputs & FRAG_BIT_TEX(i))
+ continue;
+ else if (inputs & FRAG_BIT_WPOS) {
+ p->wpos_tex = i;
+ inputs &= ~FRAG_BIT_WPOS;
+ }
+ }
+
+ if (inputs & FRAG_BIT_WPOS) {
+ i915_program_error(p, "No free texcoord for wpos value");
+ }
+}
+
+
+static void translate_program( struct i915_fragment_program *p )
+{
+ i915ContextPtr i915 = I915_CONTEXT(p->ctx);
+
+ i915_init_program( i915, p );
+ check_wpos( p );
+ upload_program( p );
+ fixup_depth_write( p );
+ i915_fini_program( p );
+
+ p->translated = 1;
+}
+
+
+static void track_params( struct i915_fragment_program *p )
+{
+ GLint i;
+
+ if (p->nr_params)
+ _mesa_load_state_parameters(p->ctx, p->FragProg.Parameters);
+
+ for (i = 0; i < p->nr_params; i++) {
+ GLint reg = p->param[i].reg;
+ COPY_4V( p->constant[reg], p->param[i].values );
+ }
+
+ p->params_uptodate = 1;
+ p->on_hardware = 0; /* overkill */
+}
+
+
+static void i915BindProgram( GLcontext *ctx,
+ GLenum target,
+ struct program *prog )
+{
+ if (target == GL_FRAGMENT_PROGRAM_ARB) {
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ struct i915_fragment_program *p = (struct i915_fragment_program *)prog;
+
+ if (i915->current_program == p)
+ return;
+
+ if (i915->current_program) {
+ i915->current_program->on_hardware = 0;
+ i915->current_program->params_uptodate = 0;
+ }
+
+ i915->current_program = p;
+
+ assert(p->on_hardware == 0);
+ assert(p->params_uptodate == 0);
+
+ /* Hack: make sure fog is correctly enabled according to this
+ * fragment program's fog options.
+ */
+ ctx->Driver.Enable( ctx, GL_FRAGMENT_PROGRAM_ARB,
+ ctx->FragmentProgram.Enabled );
+ }
+}
+
+static struct program *i915NewProgram( GLcontext *ctx,
+ GLenum target,
+ GLuint id )
+{
+ switch (target) {
+ case GL_VERTEX_PROGRAM_ARB:
+ return _mesa_init_vertex_program( ctx, CALLOC_STRUCT(vertex_program),
+ target, id );
+
+ case GL_FRAGMENT_PROGRAM_ARB: {
+ struct i915_fragment_program *prog = CALLOC_STRUCT(i915_fragment_program);
+ if (prog) {
+ i915_init_program( I915_CONTEXT(ctx), prog );
+
+ return _mesa_init_fragment_program( ctx, &prog->FragProg,
+ target, id );
+ }
+ else
+ return NULL;
+ }
+
+ default:
+ /* Just fallback:
+ */
+ return _mesa_new_program( ctx, target, id );
+ }
+}
+
+static void i915DeleteProgram( GLcontext *ctx,
+ struct program *prog )
+{
+ if (prog->Target == GL_FRAGMENT_PROGRAM_ARB) {
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ struct i915_fragment_program *p = (struct i915_fragment_program *)prog;
+
+ if (i915->current_program == p)
+ i915->current_program = 0;
+ }
+
+ _mesa_delete_program( ctx, prog );
+}
+
+
+static GLboolean i915IsProgramNative( GLcontext *ctx,
+ GLenum target,
+ struct program *prog )
+{
+ if (target == GL_FRAGMENT_PROGRAM_ARB) {
+ struct i915_fragment_program *p = (struct i915_fragment_program *)prog;
+
+ if (!p->translated)
+ translate_program( p );
+
+ return !p->error;
+ }
+ else
+ return GL_TRUE;
+}
+
+static void i915ProgramStringNotify( GLcontext *ctx,
+ GLenum target,
+ struct program *prog )
+{
+ if (target == GL_FRAGMENT_PROGRAM_ARB) {
+ struct i915_fragment_program *p = (struct i915_fragment_program *)prog;
+ p->translated = 0;
+
+ /* Hack: make sure fog is correctly enabled according to this
+ * fragment program's fog options.
+ */
+ ctx->Driver.Enable( ctx, GL_FRAGMENT_PROGRAM_ARB,
+ ctx->FragmentProgram.Enabled );
+ }
+}
+
+
+void i915ValidateFragmentProgram( i915ContextPtr i915 )
+{
+ GLcontext *ctx = &i915->intel.ctx;
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+
+ struct i915_fragment_program *p =
+ (struct i915_fragment_program *)ctx->FragmentProgram._Current;
+
+ GLuint inputsRead = p->FragProg.InputsRead;
+ GLuint s4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_VFMT_MASK;
+ GLuint s2 = S2_TEXCOORD_NONE;
+ int i, offset = 0;
+
+ /* Important:
+ */
+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
+
+ if (!p->translated)
+ translate_program( p );
+
+ intel->vertex_attr_count = 0;
+ intel->wpos_offset = 0;
+ intel->wpos_size = 0;
+ intel->coloroffset = 0;
+ intel->specoffset = 0;
+
+ if (inputsRead & FRAG_BITS_TEX_ANY) {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, S4_VFMT_XYZW, 16 );
+ }
+ else {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, S4_VFMT_XYZ, 12 );
+ }
+
+ if (inputsRead & FRAG_BIT_COL0) {
+ intel->coloroffset = offset / 4;
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, S4_VFMT_COLOR, 4 );
+ }
+
+ if ((inputsRead & (FRAG_BIT_COL1|FRAG_BIT_FOGC)) ||
+ i915->vertex_fog != I915_FOG_NONE) {
+
+ if (inputsRead & FRAG_BIT_COL1) {
+ intel->specoffset = offset / 4;
+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, S4_VFMT_SPEC_FOG, 3 );
+ }
+ else
+ EMIT_PAD(3);
+
+ if ((inputsRead & FRAG_BIT_FOGC) || i915->vertex_fog != I915_FOG_NONE)
+ EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, S4_VFMT_SPEC_FOG, 1 );
+ else
+ EMIT_PAD( 1 );
+ }
+
+#if 0
+ if ((inputsRead & FRAG_BIT_FOGC) || i915->vertex_fog != I915_FOG_NONE) {
+ EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1F, S4_VFMT_FOG_PARAM, 4 );
+ }
+#endif
+
+ for (i = 0; i < p->ctx->Const.MaxTextureCoordUnits; i++) {
+ if (inputsRead & FRAG_BIT_TEX(i)) {
+ int sz = VB->TexCoordPtr[i]->size;
+
+ s2 &= ~S2_TEXCOORD_FMT(i, S2_TEXCOORD_FMT0_MASK);
+ s2 |= S2_TEXCOORD_FMT(i, SZ_TO_HW(sz));
+
+ EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_SZ(sz), 0, sz * 4 );
+ }
+ else if (i == p->wpos_tex) {
+
+ /* If WPOS is required, duplicate the XYZ position data in an
+ * unused texture coordinate:
+ */
+ s2 &= ~S2_TEXCOORD_FMT(i, S2_TEXCOORD_FMT0_MASK);
+ s2 |= S2_TEXCOORD_FMT(i, SZ_TO_HW(3));
+
+ intel->wpos_offset = offset;
+ intel->wpos_size = 3 * sizeof(GLuint);
+
+ EMIT_PAD( intel->wpos_size );
+ }
+ }
+
+ if (s2 != i915->state.Ctx[I915_CTXREG_LIS2] ||
+ s4 != i915->state.Ctx[I915_CTXREG_LIS4]) {
+
+ I915_STATECHANGE( i915, I915_UPLOAD_CTX );
+
+ /* Must do this *after* statechange, so as not to affect
+ * buffered vertices reliant on the old state:
+ */
+ intel->vertex_size = _tnl_install_attrs( &intel->ctx,
+ intel->vertex_attrs,
+ intel->vertex_attr_count,
+ intel->ViewportMatrix.m, 0 );
+
+ intel->vertex_size >>= 2;
+
+ i915->state.Ctx[I915_CTXREG_LIS2] = s2;
+ i915->state.Ctx[I915_CTXREG_LIS4] = s4;
+
+ assert(intel->vtbl.check_vertex_size( intel, intel->vertex_size ));
+ }
+
+ if (!p->params_uptodate)
+ track_params( p );
+
+ if (!p->on_hardware)
+ i915_upload_program( i915, p );
+}
+
+void i915InitFragProgFuncs( struct dd_function_table *functions )
+{
+ functions->BindProgram = i915BindProgram;
+ functions->NewProgram = i915NewProgram;
+ functions->DeleteProgram = i915DeleteProgram;
+ functions->IsProgramNative = i915IsProgramNative;
+ functions->ProgramStringNotify = i915ProgramStringNotify;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_metaops.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_metaops.c
new file mode 100644
index 000000000..2e9063edf
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_metaops.c
@@ -0,0 +1,516 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include "glheader.h"
+#include "enums.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "utils.h"
+
+#include "intel_screen.h"
+#include "intel_batchbuffer.h"
+#include "intel_ioctl.h"
+
+#include "i915_context.h"
+#include "i915_reg.h"
+
+/* A large amount of state doesn't need to be uploaded.
+ */
+#define ACTIVE (I915_UPLOAD_PROGRAM | \
+ I915_UPLOAD_STIPPLE | \
+ I915_UPLOAD_CTX | \
+ I915_UPLOAD_BUFFERS | \
+ I915_UPLOAD_TEX(0))
+
+#define SET_STATE( i915, STATE ) \
+do { \
+ i915->current->emitted &= ~ACTIVE; \
+ i915->current = &i915->STATE; \
+ i915->current->emitted &= ~ACTIVE; \
+} while (0)
+
+/* Operations where the 3D engine is decoupled temporarily from the
+ * current GL state and used for other purposes than simply rendering
+ * incoming triangles.
+ */
+static void set_initial_state( i915ContextPtr i915 )
+{
+ memcpy(&i915->meta, &i915->initial, sizeof(i915->meta) );
+ i915->meta.active = ACTIVE;
+ i915->meta.emitted = 0;
+}
+
+
+static void set_no_depth_stencil_write( i915ContextPtr i915 )
+{
+ /* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_FALSE )
+ */
+ i915->meta.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_TEST_ENABLE |
+ S5_STENCIL_WRITE_ENABLE);
+
+ /* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE )
+ */
+ i915->meta.Ctx[I915_CTXREG_LIS6] &= ~(S6_DEPTH_TEST_ENABLE |
+ S6_DEPTH_WRITE_ENABLE);
+
+ i915->meta.emitted &= ~I915_UPLOAD_CTX;
+}
+
+/* Set stencil unit to replace always with the reference value.
+ */
+static void set_stencil_replace( i915ContextPtr i915,
+ GLuint s_mask,
+ GLuint s_clear)
+{
+ GLuint op = STENCILOP_REPLACE;
+ GLuint func = COMPAREFUNC_ALWAYS;
+
+ /* ctx->Driver.Enable( ctx, GL_STENCIL_TEST, GL_TRUE )
+ */
+ i915->meta.Ctx[I915_CTXREG_LIS5] |= (S5_STENCIL_TEST_ENABLE |
+ S5_STENCIL_WRITE_ENABLE);
+
+
+ /* ctx->Driver.Enable( ctx, GL_DEPTH_TEST, GL_FALSE )
+ */
+ i915->meta.Ctx[I915_CTXREG_LIS6] &= ~(S6_DEPTH_TEST_ENABLE |
+ S6_DEPTH_WRITE_ENABLE);
+
+
+ /* ctx->Driver.StencilMask( ctx, s_mask )
+ */
+ i915->meta.Ctx[I915_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_WRITE_MASK;
+
+ i915->meta.Ctx[I915_CTXREG_STATE4] |= (ENABLE_STENCIL_WRITE_MASK |
+ STENCIL_WRITE_MASK(s_mask));
+
+
+ /* ctx->Driver.StencilOp( ctx, GL_REPLACE, GL_REPLACE, GL_REPLACE )
+ */
+ i915->meta.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_FAIL_MASK |
+ S5_STENCIL_PASS_Z_FAIL_MASK |
+ S5_STENCIL_PASS_Z_PASS_MASK);
+
+ i915->meta.Ctx[I915_CTXREG_LIS5] |= ((op << S5_STENCIL_FAIL_SHIFT) |
+ (op << S5_STENCIL_PASS_Z_FAIL_SHIFT) |
+ (op << S5_STENCIL_PASS_Z_PASS_SHIFT));
+
+
+ /* ctx->Driver.StencilFunc( ctx, GL_ALWAYS, s_ref, ~0 )
+ */
+ i915->meta.Ctx[I915_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_TEST_MASK;
+ i915->meta.Ctx[I915_CTXREG_STATE4] |= (ENABLE_STENCIL_TEST_MASK |
+ STENCIL_TEST_MASK(0xff));
+
+ i915->meta.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_REF_MASK |
+ S5_STENCIL_TEST_FUNC_MASK);
+
+ i915->meta.Ctx[I915_CTXREG_LIS5] |= ((s_clear << S5_STENCIL_REF_SHIFT) |
+ (func << S5_STENCIL_TEST_FUNC_SHIFT));
+
+
+ i915->meta.emitted &= ~I915_UPLOAD_CTX;
+}
+
+
+static void set_color_mask( i915ContextPtr i915, GLboolean state )
+{
+ const GLuint mask = (S5_WRITEDISABLE_RED |
+ S5_WRITEDISABLE_GREEN |
+ S5_WRITEDISABLE_BLUE |
+ S5_WRITEDISABLE_ALPHA);
+
+ /* Copy colormask state from "regular" hw context.
+ */
+ if (state) {
+ i915->meta.Ctx[I915_CTXREG_LIS5] &= ~mask;
+ i915->meta.Ctx[I915_CTXREG_LIS5] |=
+ (i915->state.Ctx[I915_CTXREG_LIS5] & mask);
+ }
+ else
+ i915->meta.Ctx[I915_CTXREG_LIS5] |= mask;
+
+ i915->meta.emitted &= ~I915_UPLOAD_CTX;
+}
+
+
+
+
+#define REG( type, nr ) (((type)<<5)|(nr))
+
+#define REG_R(x) REG(REG_TYPE_R, x)
+#define REG_T(x) REG(REG_TYPE_T, x)
+#define REG_CONST(x) REG(REG_TYPE_CONST, x)
+#define REG_S(x) REG(REG_TYPE_S, x)
+#define REG_OC REG(REG_TYPE_OC, 0)
+#define REG_OD REG(REG_TYPE_OD, 0)
+#define REG_U(x) REG(REG_TYPE_U, x)
+
+#define REG_T_DIFFUSE REG(REG_TYPE_T, T_DIFFUSE)
+#define REG_T_SPECULAR REG(REG_TYPE_T, T_SPECULAR)
+#define REG_T_FOG_W REG(REG_TYPE_T, T_FOG_W)
+#define REG_T_TEX(x) REG(REG_TYPE_T, x)
+
+
+#define A0_DEST_REG( reg ) ( (reg) << A0_DEST_NR_SHIFT )
+#define A0_SRC0_REG( reg ) ( (reg) << A0_SRC0_NR_SHIFT )
+#define A1_SRC1_REG( reg ) ( (reg) << A1_SRC1_NR_SHIFT )
+#define A1_SRC2_REG( reg ) ( (reg) << A1_SRC2_NR_SHIFT )
+#define A2_SRC2_REG( reg ) ( (reg) << A2_SRC2_NR_SHIFT )
+#define D0_DECL_REG( reg ) ( (reg) << D0_NR_SHIFT )
+#define T0_DEST_REG( reg ) ( (reg) << T0_DEST_NR_SHIFT )
+
+#define T0_SAMPLER( unit ) ((unit)<<T0_SAMPLER_NR_SHIFT)
+
+#define T1_ADDRESS_REG( type, nr ) (((type)<<T1_ADDRESS_REG_TYPE_SHIFT)| \
+ ((nr)<<T1_ADDRESS_REG_NR_SHIFT))
+
+
+#define A1_SRC0_XYZW ((SRC_X << A1_SRC0_CHANNEL_X_SHIFT) | \
+ (SRC_Y << A1_SRC0_CHANNEL_Y_SHIFT) | \
+ (SRC_Z << A1_SRC0_CHANNEL_Z_SHIFT) | \
+ (SRC_W << A1_SRC0_CHANNEL_W_SHIFT))
+
+#define A1_SRC1_XY ((SRC_X << A1_SRC1_CHANNEL_X_SHIFT) | \
+ (SRC_Y << A1_SRC1_CHANNEL_Y_SHIFT))
+
+#define A2_SRC1_ZW ((SRC_Z << A2_SRC1_CHANNEL_Z_SHIFT) | \
+ (SRC_W << A2_SRC1_CHANNEL_W_SHIFT))
+
+#define A2_SRC2_XYZW ((SRC_X << A2_SRC2_CHANNEL_X_SHIFT) | \
+ (SRC_Y << A2_SRC2_CHANNEL_Y_SHIFT) | \
+ (SRC_Z << A2_SRC2_CHANNEL_Z_SHIFT) | \
+ (SRC_W << A2_SRC2_CHANNEL_W_SHIFT))
+
+
+
+
+
+static void set_no_texture( i915ContextPtr i915 )
+{
+ static const GLuint prog[] = {
+ _3DSTATE_PIXEL_SHADER_PROGRAM,
+
+ /* Declare incoming diffuse color:
+ */
+ (D0_DCL |
+ D0_DECL_REG( REG_T_DIFFUSE ) |
+ D0_CHANNEL_ALL),
+ D1_MBZ,
+ D2_MBZ,
+
+ /* output-color = mov(t_diffuse)
+ */
+ (A0_MOV |
+ A0_DEST_REG( REG_OC ) |
+ A0_DEST_CHANNEL_ALL |
+ A0_SRC0_REG( REG_T_DIFFUSE )),
+ (A1_SRC0_XYZW),
+ 0,
+ };
+
+
+ memcpy( i915->meta.Program, prog, sizeof(prog) );
+ i915->meta.ProgramSize = sizeof(prog) / sizeof(*prog);
+ i915->meta.Program[0] |= i915->meta.ProgramSize - 2;
+ i915->meta.emitted &= ~I915_UPLOAD_PROGRAM;
+}
+
+#if 0
+static void enable_texture_blend_replace( i915ContextPtr i915 )
+{
+ static const GLuint prog[] = {
+ _3DSTATE_PIXEL_SHADER_PROGRAM,
+
+ /* Declare the sampler:
+ */
+ (D0_DCL |
+ D0_DECL_REG( REG_S(0) ) |
+ D0_SAMPLE_TYPE_2D |
+ D0_CHANNEL_NONE),
+ D1_MBZ,
+ D2_MBZ,
+
+ /* Declare the interpolated texture coordinate:
+ */
+ (D0_DCL |
+ D0_DECL_REG( REG_T_TEX(0) ) |
+ D0_CHANNEL_ALL),
+ D1_MBZ,
+ D2_MBZ,
+
+ /* output-color = texld(sample0, texcoord0)
+ */
+ (T0_TEXLD |
+ T0_DEST_REG( REG_OC ) |
+ T0_SAMPLER( 0 )),
+ T1_ADDRESS_REG(REG_TYPE_T, 0),
+ T2_MBZ
+ };
+
+ memcpy( i915->meta.Program, prog, sizeof(prog) );
+ i915->meta.ProgramSize = sizeof(prog) / sizeof(*prog);
+ i915->meta.Program[0] |= i915->meta.ProgramSize - 2;
+ i915->meta.emitted &= ~I915_UPLOAD_PROGRAM;
+}
+
+
+
+
+
+/* Set up an arbitary piece of memory as a rectangular texture
+ * (including the front or back buffer).
+ */
+static void set_tex_rect_source( i915ContextPtr i915,
+ GLuint offset,
+ GLuint width,
+ GLuint height,
+ GLuint pitch,
+ GLuint textureFormat )
+{
+ GLuint unit = 0;
+ GLint numLevels = 1;
+ GLuint *state = i915->meta.Tex[0];
+
+ pitch *= i915->intel.intelScreen->cpp;
+
+/* fprintf(stderr, "%s: offset: %x w: %d h: %d pitch %d format %x\n", */
+/* __FUNCTION__, offset, width, height, pitch, textureFormat ); */
+
+ state[I915_TEXREG_MS2] = offset;
+ state[I915_TEXREG_MS3] = (((height - 1) << MS3_HEIGHT_SHIFT) |
+ ((width - 1) << MS3_WIDTH_SHIFT) |
+ textureFormat |
+ MS3_USE_FENCE_REGS);
+
+ state[I915_TEXREG_MS4] = ((((pitch / 4) - 1) << MS4_PITCH_SHIFT) |
+ MS4_CUBE_FACE_ENA_MASK |
+ ((((numLevels-1) * 4)) << MS4_MAX_LOD_SHIFT));
+
+ state[I915_TEXREG_SS2] = ((FILTER_NEAREST << SS2_MIN_FILTER_SHIFT) |
+ (MIPFILTER_NONE << SS2_MIP_FILTER_SHIFT) |
+ (FILTER_NEAREST << SS2_MAG_FILTER_SHIFT));
+ state[I915_TEXREG_SS3] = ((TEXCOORDMODE_WRAP << SS3_TCX_ADDR_MODE_SHIFT) |
+ (TEXCOORDMODE_WRAP << SS3_TCY_ADDR_MODE_SHIFT) |
+ (TEXCOORDMODE_WRAP << SS3_TCZ_ADDR_MODE_SHIFT) |
+ (unit<<SS3_TEXTUREMAP_INDEX_SHIFT));
+
+ state[I915_TEXREG_SS4] = 0;
+
+ i915->meta.emitted &= ~I915_UPLOAD_TEX(0);
+}
+#endif
+
+/* Select between front and back draw buffers.
+ */
+static void set_draw_offset( i915ContextPtr i915,
+ GLuint offset )
+{
+ i915->meta.Buffer[I915_DESTREG_CBUFADDR2] = offset;
+ i915->meta.emitted &= ~I915_UPLOAD_BUFFERS;
+}
+
+#if 0
+/* Setup an arbitary draw format, useful for targeting texture or agp
+ * memory.
+ */
+static void set_draw_format( i915ContextPtr i915,
+ GLuint format,
+ GLuint depth_format)
+{
+ i915->meta.Buffer[I915_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */
+ DSTORG_VERT_BIAS(0x8) | /* .5 */
+ format |
+ LOD_PRECLAMP_OGL |
+ TEX_DEFAULT_COLOR_OGL |
+ depth_format);
+
+ i915->meta.emitted &= ~I915_UPLOAD_BUFFERS;
+/* fprintf(stderr, "%s: DV1: %x\n", */
+/* __FUNCTION__, i915->meta.Buffer[I915_DESTREG_DV1]); */
+}
+#endif
+
+static void set_vertex_format( i915ContextPtr i915 )
+{
+ i915->meta.Ctx[I915_CTXREG_LIS2] =
+ (S2_TEXCOORD_FMT(0, TEXCOORDFMT_2D) |
+ S2_TEXCOORD_FMT(1, TEXCOORDFMT_NOT_PRESENT) |
+ S2_TEXCOORD_FMT(2, TEXCOORDFMT_NOT_PRESENT) |
+ S2_TEXCOORD_FMT(3, TEXCOORDFMT_NOT_PRESENT) |
+ S2_TEXCOORD_FMT(4, TEXCOORDFMT_NOT_PRESENT) |
+ S2_TEXCOORD_FMT(5, TEXCOORDFMT_NOT_PRESENT) |
+ S2_TEXCOORD_FMT(6, TEXCOORDFMT_NOT_PRESENT) |
+ S2_TEXCOORD_FMT(7, TEXCOORDFMT_NOT_PRESENT));
+
+ i915->meta.Ctx[I915_CTXREG_LIS4] &= ~S4_VFMT_MASK;
+
+ i915->meta.Ctx[I915_CTXREG_LIS4] |=
+ (S4_VFMT_COLOR |
+ S4_VFMT_SPEC_FOG |
+ S4_VFMT_XYZW);
+
+ i915->meta.emitted &= ~I915_UPLOAD_CTX;
+
+}
+
+
+static void draw_quad(i915ContextPtr i915,
+ GLfloat x0, GLfloat x1,
+ GLfloat y0, GLfloat y1,
+ GLubyte red, GLubyte green,
+ GLubyte blue, GLubyte alpha,
+ GLfloat s0, GLfloat s1,
+ GLfloat t0, GLfloat t1 )
+{
+ GLuint vertex_size = 8;
+ GLuint *vb = intelEmitInlinePrimitiveLocked( &i915->intel,
+ PRIM3D_TRIFAN,
+ 4 * vertex_size,
+ vertex_size );
+ intelVertex tmp;
+ int i;
+
+ if (0)
+ fprintf(stderr, "%s: %f,%f-%f,%f 0x%x%x%x%x %f,%f-%f,%f\n",
+ __FUNCTION__,
+ x0,y0,x1,y1,red,green,blue,alpha,s0,t0,s1,t1);
+
+
+ /* initial vertex, left bottom */
+ tmp.v.x = x0;
+ tmp.v.y = y0;
+ tmp.v.z = 1.0;
+ tmp.v.w = 1.0;
+ tmp.v.color.red = red;
+ tmp.v.color.green = green;
+ tmp.v.color.blue = blue;
+ tmp.v.color.alpha = alpha;
+ tmp.v.specular.red = 0;
+ tmp.v.specular.green = 0;
+ tmp.v.specular.blue = 0;
+ tmp.v.specular.alpha = 0;
+ tmp.v.u0 = s0;
+ tmp.v.v0 = t0;
+
+ for (i = 0 ; i < vertex_size ; i++)
+ vb[i] = tmp.ui[i];
+
+ /* right bottom */
+ vb += vertex_size;
+ tmp.v.x = x1;
+ tmp.v.u0 = s1;
+ for (i = 0 ; i < vertex_size ; i++)
+ vb[i] = tmp.ui[i];
+
+ /* right top */
+ vb += vertex_size;
+ tmp.v.y = y1;
+ tmp.v.v0 = t1;
+ for (i = 0 ; i < vertex_size ; i++)
+ vb[i] = tmp.ui[i];
+
+ /* left top */
+ vb += vertex_size;
+ tmp.v.x = x0;
+ tmp.v.u0 = s0;
+ for (i = 0 ; i < vertex_size ; i++)
+ vb[i] = tmp.ui[i];
+}
+
+void
+i915ClearWithTris(intelContextPtr intel, GLbitfield mask,
+ GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch)
+{
+ i915ContextPtr i915 = I915_CONTEXT( intel );
+ __DRIdrawablePrivate *dPriv = intel->driDrawable;
+ intelScreenPrivate *screen = intel->intelScreen;
+ int x0, y0, x1, y1;
+
+ SET_STATE( i915, meta );
+ set_initial_state( i915 );
+ set_no_texture( i915 );
+ set_vertex_format( i915 );
+
+ LOCK_HARDWARE(intel);
+
+ if(!all) {
+ x0 = cx;
+ y0 = cy;
+ x1 = x0 + cw;
+ y1 = y0 + ch;
+ } else {
+ x0 = 0;
+ y0 = 0;
+ x1 = x0 + dPriv->w;
+ y1 = y0 + dPriv->h;
+ }
+
+ /* Don't do any clipping to screen - these are window coordinates.
+ * The active cliprects will be applied as for any other geometry.
+ */
+
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
+ set_no_depth_stencil_write( i915 );
+ set_color_mask( i915, GL_TRUE );
+ set_draw_offset( i915, screen->frontOffset );
+
+ draw_quad(i915, x0, x1, y0, y1,
+ intel->clear_red, intel->clear_green,
+ intel->clear_blue, intel->clear_alpha,
+ 0, 0, 0, 0);
+ }
+
+ if (mask & BUFFER_BIT_BACK_LEFT) {
+ set_no_depth_stencil_write( i915 );
+ set_color_mask( i915, GL_TRUE );
+ set_draw_offset( i915, screen->backOffset );
+
+ draw_quad(i915, x0, x1, y0, y1,
+ intel->clear_red, intel->clear_green,
+ intel->clear_blue, intel->clear_alpha,
+ 0, 0, 0, 0);
+ }
+
+ if (mask & BUFFER_BIT_STENCIL) {
+ set_stencil_replace( i915,
+ intel->ctx.Stencil.WriteMask[0],
+ intel->ctx.Stencil.Clear);
+
+ set_color_mask( i915, GL_FALSE );
+ set_draw_offset( i915, screen->frontOffset ); /* could be either? */
+
+ draw_quad( i915, x0, x1, y0, y1, 0, 0, 0, 0, 0, 0, 0, 0 );
+ }
+
+ UNLOCK_HARDWARE(intel);
+
+ SET_STATE( i915, state );
+}
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_program.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_program.c
new file mode 100644
index 000000000..cf3ebc171
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_program.c
@@ -0,0 +1,466 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include <strings.h>
+
+#include "glheader.h"
+#include "macros.h"
+#include "enums.h"
+
+#include "tnl/t_context.h"
+#include "intel_batchbuffer.h"
+
+#include "i915_reg.h"
+#include "i915_context.h"
+#include "i915_program.h"
+
+
+#define A0_DEST( reg ) (((reg)&UREG_TYPE_NR_MASK)>>UREG_A0_DEST_SHIFT_LEFT)
+#define D0_DEST( reg ) (((reg)&UREG_TYPE_NR_MASK)>>UREG_A0_DEST_SHIFT_LEFT)
+#define T0_DEST( reg ) (((reg)&UREG_TYPE_NR_MASK)>>UREG_A0_DEST_SHIFT_LEFT)
+#define A0_SRC0( reg ) (((reg)&UREG_MASK)>>UREG_A0_SRC0_SHIFT_LEFT)
+#define A1_SRC0( reg ) (((reg)&UREG_MASK)<<UREG_A1_SRC0_SHIFT_RIGHT)
+#define A1_SRC1( reg ) (((reg)&UREG_MASK)>>UREG_A1_SRC1_SHIFT_LEFT)
+#define A2_SRC1( reg ) (((reg)&UREG_MASK)<<UREG_A2_SRC1_SHIFT_RIGHT)
+#define A2_SRC2( reg ) (((reg)&UREG_MASK)>>UREG_A2_SRC2_SHIFT_LEFT)
+
+/* These are special, and don't have swizzle/negate bits.
+ */
+#define T0_SAMPLER( reg ) (GET_UREG_NR(reg)<<T0_SAMPLER_NR_SHIFT)
+#define T1_ADDRESS_REG( reg ) ((GET_UREG_NR(reg)<<T1_ADDRESS_REG_NR_SHIFT) | \
+ (GET_UREG_TYPE(reg)<<T1_ADDRESS_REG_TYPE_SHIFT))
+
+
+/* Macros for translating UREG's into the various register fields used
+ * by the I915 programmable unit.
+ */
+#define UREG_A0_DEST_SHIFT_LEFT (UREG_TYPE_SHIFT - A0_DEST_TYPE_SHIFT)
+#define UREG_A0_SRC0_SHIFT_LEFT (UREG_TYPE_SHIFT - A0_SRC0_TYPE_SHIFT)
+#define UREG_A1_SRC0_SHIFT_RIGHT (A1_SRC0_CHANNEL_W_SHIFT - UREG_CHANNEL_W_SHIFT)
+#define UREG_A1_SRC1_SHIFT_LEFT (UREG_TYPE_SHIFT - A1_SRC1_TYPE_SHIFT)
+#define UREG_A2_SRC1_SHIFT_RIGHT (A2_SRC1_CHANNEL_W_SHIFT - UREG_CHANNEL_W_SHIFT)
+#define UREG_A2_SRC2_SHIFT_LEFT (UREG_TYPE_SHIFT - A2_SRC2_TYPE_SHIFT)
+
+#define UREG_MASK 0xffffff00
+#define UREG_TYPE_NR_MASK ((REG_TYPE_MASK << UREG_TYPE_SHIFT) | \
+ (REG_NR_MASK << UREG_NR_SHIFT))
+
+
+#define I915_CONSTFLAG_PARAM 0x1f
+
+GLuint i915_get_temp( struct i915_fragment_program *p )
+{
+ int bit = ffs( ~p->temp_flag );
+ if (!bit) {
+ fprintf(stderr, "%s: out of temporaries\n", __FILE__);
+ exit(1);
+ }
+
+ p->temp_flag |= 1<<(bit-1);
+ return UREG(REG_TYPE_R, (bit-1));
+}
+
+
+GLuint i915_get_utemp( struct i915_fragment_program *p )
+{
+ int bit = ffs( ~p->utemp_flag );
+ if (!bit) {
+ fprintf(stderr, "%s: out of temporaries\n", __FILE__);
+ exit(1);
+ }
+
+ p->utemp_flag |= 1<<(bit-1);
+ return UREG(REG_TYPE_U, (bit-1));
+}
+
+void i915_release_utemps( struct i915_fragment_program *p )
+{
+ p->utemp_flag = ~0x7;
+}
+
+
+GLuint i915_emit_decl( struct i915_fragment_program *p,
+ GLuint type, GLuint nr, GLuint d0_flags )
+{
+ GLuint reg = UREG(type, nr);
+
+ if (type == REG_TYPE_T) {
+ if (p->decl_t & (1<<nr))
+ return reg;
+
+ p->decl_t |= (1<<nr);
+ }
+ else if (type == REG_TYPE_S) {
+ if (p->decl_s & (1<<nr))
+ return reg;
+
+ p->decl_s |= (1<<nr);
+ }
+ else
+ return reg;
+
+ *(p->decl++) = (D0_DCL | D0_DEST( reg ) | d0_flags);
+ *(p->decl++) = D1_MBZ;
+ *(p->decl++) = D2_MBZ;
+
+ p->nr_decl_insn++;
+ return reg;
+}
+
+GLuint i915_emit_arith( struct i915_fragment_program *p,
+ GLuint op,
+ GLuint dest,
+ GLuint mask,
+ GLuint saturate,
+ GLuint src0,
+ GLuint src1,
+ GLuint src2 )
+{
+ GLuint c[3];
+ GLuint nr_const = 0;
+
+ assert(GET_UREG_TYPE(dest) != REG_TYPE_CONST);
+ assert(dest = UREG(GET_UREG_TYPE(dest), GET_UREG_NR(dest)));
+
+ if (GET_UREG_TYPE(src0) == REG_TYPE_CONST) c[nr_const++] = 0;
+ if (GET_UREG_TYPE(src1) == REG_TYPE_CONST) c[nr_const++] = 1;
+ if (GET_UREG_TYPE(src2) == REG_TYPE_CONST) c[nr_const++] = 2;
+
+ /* Recursively call this function to MOV additional const values
+ * into temporary registers. Use utemp registers for this -
+ * currently shouldn't be possible to run out, but keep an eye on
+ * this.
+ */
+ if (nr_const > 1) {
+ GLuint s[3], first, i, old_utemp_flag;
+
+ s[0] = src0;
+ s[1] = src1;
+ s[2] = src2;
+ old_utemp_flag = p->utemp_flag;
+
+ first = GET_UREG_NR(s[c[0]]);
+ for (i = 1 ; i < nr_const ; i++) {
+ if (GET_UREG_NR(s[c[i]]) != first) {
+ GLuint tmp = i915_get_utemp(p);
+
+ i915_emit_arith( p, A0_MOV, tmp, A0_DEST_CHANNEL_ALL, 0,
+ s[c[i]], 0, 0 );
+ s[c[i]] = tmp;
+ }
+ }
+
+ src0 = s[0];
+ src1 = s[1];
+ src2 = s[2];
+ p->utemp_flag = old_utemp_flag; /* restore */
+ }
+
+ *(p->csr++) = (op |
+ A0_DEST( dest ) |
+ mask |
+ saturate |
+ A0_SRC0( src0 ));
+ *(p->csr++) = (A1_SRC0( src0 ) |
+ A1_SRC1( src1 ));
+ *(p->csr++) = (A2_SRC1( src1 ) |
+ A2_SRC2( src2 ));
+
+ p->nr_alu_insn++;
+ return dest;
+}
+
+GLuint i915_emit_texld( struct i915_fragment_program *p,
+ GLuint dest,
+ GLuint destmask,
+ GLuint sampler,
+ GLuint coord,
+ GLuint op )
+{
+ assert(GET_UREG_TYPE(dest) != REG_TYPE_CONST);
+ assert(dest = UREG(GET_UREG_TYPE(dest), GET_UREG_NR(dest)));
+
+ if (GET_UREG_TYPE(coord) != REG_TYPE_T) {
+ p->nr_tex_indirect++;
+ }
+
+ *(p->csr++) = (op |
+ T0_DEST( dest ) |
+ destmask |
+ T0_SAMPLER( sampler ));
+
+ *(p->csr++) = T1_ADDRESS_REG( coord );
+ *(p->csr++) = T2_MBZ;
+
+ p->nr_tex_insn++;
+ return dest;
+}
+
+
+GLuint i915_emit_const1f( struct i915_fragment_program *p, GLfloat c0 )
+{
+ GLint reg, idx;
+
+ if (c0 == 0.0) return swizzle(UREG(REG_TYPE_R, 0), ZERO, ZERO, ZERO, ZERO);
+ if (c0 == 1.0) return swizzle(UREG(REG_TYPE_R, 0), ONE, ONE, ONE, ONE );
+
+ for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {
+ if (p->constant_flags[reg] == I915_CONSTFLAG_PARAM)
+ continue;
+ for (idx = 0; idx < 4; idx++) {
+ if (!(p->constant_flags[reg] & (1<<idx)) ||
+ p->constant[reg][idx] == c0) {
+ p->constant[reg][idx] = c0;
+ p->constant_flags[reg] |= 1<<idx;
+ if (reg+1 > p->nr_constants) p->nr_constants = reg+1;
+ return swizzle(UREG(REG_TYPE_CONST, reg),idx,ZERO,ZERO,ONE);
+ }
+ }
+ }
+
+ fprintf(stderr, "%s: out of constants\n", __FUNCTION__);
+ p->error = 1;
+ return 0;
+}
+
+GLuint i915_emit_const2f( struct i915_fragment_program *p,
+ GLfloat c0, GLfloat c1 )
+{
+ GLint reg, idx;
+
+ if (c0 == 0.0) return swizzle(i915_emit_const1f(p, c1), ZERO, X, Z, W);
+ if (c0 == 1.0) return swizzle(i915_emit_const1f(p, c1), ONE, X, Z, W);
+
+ if (c1 == 0.0) return swizzle(i915_emit_const1f(p, c0), X, ZERO, Z, W);
+ if (c1 == 1.0) return swizzle(i915_emit_const1f(p, c0), X, ONE, Z, W);
+
+ for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {
+ if (p->constant_flags[reg] == 0xf ||
+ p->constant_flags[reg] == I915_CONSTFLAG_PARAM)
+ continue;
+ for (idx = 0; idx < 3; idx++) {
+ if (!(p->constant_flags[reg] & (3<<idx))) {
+ p->constant[reg][idx] = c0;
+ p->constant[reg][idx+1] = c1;
+ p->constant_flags[reg] |= 3<<idx;
+ if (reg+1 > p->nr_constants) p->nr_constants = reg+1;
+ return swizzle(UREG(REG_TYPE_CONST, reg),idx,idx+1,ZERO,ONE);
+ }
+ }
+ }
+
+ fprintf(stderr, "%s: out of constants\n", __FUNCTION__);
+ p->error = 1;
+ return 0;
+}
+
+
+
+GLuint i915_emit_const4f( struct i915_fragment_program *p,
+ GLfloat c0, GLfloat c1, GLfloat c2, GLfloat c3 )
+{
+ GLint reg;
+
+ for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {
+ if (p->constant_flags[reg] == 0xf &&
+ p->constant[reg][0] == c0 &&
+ p->constant[reg][1] == c1 &&
+ p->constant[reg][2] == c2 &&
+ p->constant[reg][3] == c3) {
+ return UREG(REG_TYPE_CONST, reg);
+ }
+ else if (p->constant_flags[reg] == 0) {
+ p->constant[reg][0] = c0;
+ p->constant[reg][1] = c1;
+ p->constant[reg][2] = c2;
+ p->constant[reg][3] = c3;
+ p->constant_flags[reg] = 0xf;
+ if (reg+1 > p->nr_constants) p->nr_constants = reg+1;
+ return UREG(REG_TYPE_CONST, reg);
+ }
+ }
+
+ fprintf(stderr, "%s: out of constants\n", __FUNCTION__);
+ p->error = 1;
+ return 0;
+}
+
+
+GLuint i915_emit_const4fv( struct i915_fragment_program *p, const GLfloat *c )
+{
+ return i915_emit_const4f( p, c[0], c[1], c[2], c[3] );
+}
+
+
+GLuint i915_emit_param4fv( struct i915_fragment_program *p,
+ const GLfloat *values )
+{
+ GLint reg, i;
+
+ for (i = 0; i < p->nr_params; i++) {
+ if (p->param[i].values == values)
+ return UREG(REG_TYPE_CONST, p->param[i].reg);
+ }
+
+
+ for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {
+ if (p->constant_flags[reg] == 0) {
+ p->constant_flags[reg] = I915_CONSTFLAG_PARAM;
+ i = p->nr_params++;
+
+ p->param[i].values = values;
+ p->param[i].reg = reg;
+ p->params_uptodate = 0;
+
+ if (reg+1 > p->nr_constants) p->nr_constants = reg+1;
+ return UREG(REG_TYPE_CONST, reg);
+ }
+ }
+
+ fprintf(stderr, "%s: out of constants\n", __FUNCTION__);
+ p->error = 1;
+ return 0;
+}
+
+
+
+
+void i915_program_error( struct i915_fragment_program *p, const GLubyte *msg )
+{
+ fprintf(stderr, "%s\n", msg);
+ p->error = 1;
+}
+
+void i915_init_program( i915ContextPtr i915, struct i915_fragment_program *p )
+{
+ GLcontext *ctx = &i915->intel.ctx;
+ TNLcontext *tnl = TNL_CONTEXT( ctx );
+
+ p->translated = 0;
+ p->params_uptodate = 0;
+ p->on_hardware = 0;
+ p->error = 0;
+
+ p->nr_tex_indirect = 1; /* correct? */
+ p->nr_tex_insn = 0;
+ p->nr_alu_insn = 0;
+ p->nr_decl_insn = 0;
+
+ p->ctx = ctx;
+ memset( p->constant_flags, 0, sizeof(p->constant_flags) );
+
+ p->nr_constants = 0;
+ p->csr = p->program;
+ p->decl = p->declarations;
+ p->decl_s = 0;
+ p->decl_t = 0;
+ p->temp_flag = 0xffff000;
+ p->utemp_flag = ~0x7;
+ p->wpos_tex = -1;
+ p->depth_written = 0;
+ p->nr_params = 0;
+
+ p->src_texture = UREG_BAD;
+ p->src_previous = UREG(REG_TYPE_T, T_DIFFUSE);
+ p->last_tex_stage = 0;
+ p->VB = &tnl->vb;
+
+ *(p->decl++) = _3DSTATE_PIXEL_SHADER_PROGRAM;
+}
+
+
+void i915_fini_program( struct i915_fragment_program *p )
+{
+ GLuint program_size = p->csr - p->program;
+ GLuint decl_size = p->decl - p->declarations;
+
+ if (p->nr_tex_indirect > I915_MAX_TEX_INDIRECT)
+ i915_program_error(p, "Exceeded max nr indirect texture lookups");
+
+ if (p->nr_tex_insn > I915_MAX_TEX_INSN)
+ i915_program_error(p, "Exceeded max TEX instructions");
+
+ if (p->nr_alu_insn > I915_MAX_ALU_INSN)
+ i915_program_error(p, "Exceeded max ALU instructions");
+
+ if (p->nr_decl_insn > I915_MAX_DECL_INSN)
+ i915_program_error(p, "Exceeded max DECL instructions");
+
+ p->declarations[0] |= program_size + decl_size - 2;
+}
+
+void i915_upload_program( i915ContextPtr i915, struct i915_fragment_program *p )
+{
+ GLuint program_size = p->csr - p->program;
+ GLuint decl_size = p->decl - p->declarations;
+
+ FALLBACK( &i915->intel, I915_FALLBACK_PROGRAM, p->error );
+
+ /* Could just go straight to the batchbuffer from here:
+ */
+ if (i915->state.ProgramSize != (program_size + decl_size) ||
+ memcmp(i915->state.Program + decl_size, p->program,
+ program_size*sizeof(int)) != 0) {
+ I915_STATECHANGE( i915, I915_UPLOAD_PROGRAM );
+ memcpy(i915->state.Program, p->declarations, decl_size*sizeof(int));
+ memcpy(i915->state.Program + decl_size, p->program,
+ program_size*sizeof(int));
+ i915->state.ProgramSize = decl_size + program_size;
+ }
+
+ /* Always seemed to get a failure if I used memcmp() to
+ * shortcircuit this state upload. Needs further investigation?
+ */
+ if (p->nr_constants) {
+ GLuint nr = p->nr_constants;
+
+ I915_ACTIVESTATE( i915, I915_UPLOAD_CONSTANTS, 1 );
+ I915_STATECHANGE( i915, I915_UPLOAD_CONSTANTS );
+
+ i915->state.Constant[0] = _3DSTATE_PIXEL_SHADER_CONSTANTS | ((nr) * 4);
+ i915->state.Constant[1] = (1<<(nr-1)) | ((1<<(nr-1))-1);
+
+ memcpy(&i915->state.Constant[2], p->constant, 4*sizeof(int)*(nr));
+ i915->state.ConstantSize = 2 + (nr) * 4;
+
+ if (0) {
+ GLuint i;
+ for (i = 0; i < nr; i++) {
+ fprintf(stderr, "const[%d]: %f %f %f %f\n", i,
+ p->constant[i][0],
+ p->constant[i][1],
+ p->constant[i][2],
+ p->constant[i][3]);
+ }
+ }
+ }
+ else {
+ I915_ACTIVESTATE( i915, I915_UPLOAD_CONSTANTS, 0 );
+ }
+
+ p->on_hardware = 1;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_program.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_program.h
new file mode 100644
index 000000000..c53ebead6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_program.h
@@ -0,0 +1,163 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+
+#ifndef I915_PROGRAM_H
+#define I915_PROGRAM_H
+
+#include "i915_context.h"
+#include "i915_reg.h"
+
+
+
+/* Having zero and one in here makes the definition of swizzle a lot
+ * easier.
+ */
+#define UREG_TYPE_SHIFT 29
+#define UREG_NR_SHIFT 24
+#define UREG_CHANNEL_X_NEGATE_SHIFT 23
+#define UREG_CHANNEL_X_SHIFT 20
+#define UREG_CHANNEL_Y_NEGATE_SHIFT 19
+#define UREG_CHANNEL_Y_SHIFT 16
+#define UREG_CHANNEL_Z_NEGATE_SHIFT 15
+#define UREG_CHANNEL_Z_SHIFT 12
+#define UREG_CHANNEL_W_NEGATE_SHIFT 11
+#define UREG_CHANNEL_W_SHIFT 8
+#define UREG_CHANNEL_ZERO_NEGATE_MBZ 5
+#define UREG_CHANNEL_ZERO_SHIFT 4
+#define UREG_CHANNEL_ONE_NEGATE_MBZ 1
+#define UREG_CHANNEL_ONE_SHIFT 0
+
+#define UREG_BAD 0xffffffff /* not a valid ureg */
+
+#define X SRC_X
+#define Y SRC_Y
+#define Z SRC_Z
+#define W SRC_W
+#define ZERO SRC_ZERO
+#define ONE SRC_ONE
+
+/* Construct a ureg:
+ */
+#define UREG( type, nr ) (((type)<< UREG_TYPE_SHIFT) | \
+ ((nr) << UREG_NR_SHIFT) | \
+ (X << UREG_CHANNEL_X_SHIFT) | \
+ (Y << UREG_CHANNEL_Y_SHIFT) | \
+ (Z << UREG_CHANNEL_Z_SHIFT) | \
+ (W << UREG_CHANNEL_W_SHIFT) | \
+ (ZERO << UREG_CHANNEL_ZERO_SHIFT) | \
+ (ONE << UREG_CHANNEL_ONE_SHIFT))
+
+#define GET_CHANNEL_SRC( reg, channel ) ((reg<<(channel*4)) & (0xf<<20))
+#define CHANNEL_SRC( src, channel ) (src>>(channel*4))
+
+#define GET_UREG_TYPE(reg) (((reg)>>UREG_TYPE_SHIFT)&REG_TYPE_MASK)
+#define GET_UREG_NR(reg) (((reg)>>UREG_NR_SHIFT)&REG_NR_MASK)
+
+
+
+#define UREG_XYZW_CHANNEL_MASK 0x00ffff00
+
+/* One neat thing about the UREG representation:
+ */
+static __inline int swizzle( int reg, int x, int y, int z, int w )
+{
+ return ((reg & ~UREG_XYZW_CHANNEL_MASK) |
+ CHANNEL_SRC( GET_CHANNEL_SRC( reg, x ), 0 ) |
+ CHANNEL_SRC( GET_CHANNEL_SRC( reg, y ), 1 ) |
+ CHANNEL_SRC( GET_CHANNEL_SRC( reg, z ), 2 ) |
+ CHANNEL_SRC( GET_CHANNEL_SRC( reg, w ), 3 ));
+}
+
+/* Another neat thing about the UREG representation:
+ */
+static __inline int negate( int reg, int x, int y, int z, int w )
+{
+ return reg ^ (((x&1)<<UREG_CHANNEL_X_NEGATE_SHIFT)|
+ ((y&1)<<UREG_CHANNEL_Y_NEGATE_SHIFT)|
+ ((z&1)<<UREG_CHANNEL_Z_NEGATE_SHIFT)|
+ ((w&1)<<UREG_CHANNEL_W_NEGATE_SHIFT));
+}
+
+
+extern GLuint i915_get_temp( struct i915_fragment_program *p );
+extern GLuint i915_get_utemp( struct i915_fragment_program *p );
+extern void i915_release_utemps( struct i915_fragment_program *p );
+
+
+extern GLuint i915_emit_texld( struct i915_fragment_program *p,
+ GLuint dest,
+ GLuint destmask,
+ GLuint sampler,
+ GLuint coord,
+ GLuint op );
+
+extern GLuint i915_emit_arith( struct i915_fragment_program *p,
+ GLuint op,
+ GLuint dest,
+ GLuint mask,
+ GLuint saturate,
+ GLuint src0,
+ GLuint src1,
+ GLuint src2 );
+
+extern GLuint i915_emit_decl( struct i915_fragment_program *p,
+ GLuint type, GLuint nr, GLuint d0_flags );
+
+
+extern GLuint i915_emit_const1f( struct i915_fragment_program *p,
+ GLfloat c0 );
+
+extern GLuint i915_emit_const2f( struct i915_fragment_program *p,
+ GLfloat c0, GLfloat c1 );
+
+extern GLuint i915_emit_const4fv( struct i915_fragment_program *p,
+ const GLfloat *c );
+
+extern GLuint i915_emit_const4f( struct i915_fragment_program *p,
+ GLfloat c0, GLfloat c1,
+ GLfloat c2, GLfloat c3 );
+
+
+extern GLuint i915_emit_param4fv( struct i915_fragment_program *p,
+ const GLfloat *values );
+
+extern void i915_program_error( struct i915_fragment_program *p,
+ const GLubyte *msg );
+
+extern void i915_init_program( i915ContextPtr i915,
+ struct i915_fragment_program *p );
+
+extern void i915_upload_program( i915ContextPtr i915,
+ struct i915_fragment_program *p );
+
+extern void i915_fini_program( struct i915_fragment_program *p );
+
+
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_reg.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_reg.h
new file mode 100644
index 000000000..3241b36b6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_reg.h
@@ -0,0 +1,833 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+
+#ifndef _I915_REG_H_
+#define _I915_REG_H_
+
+
+#include "intel_reg.h"
+
+#define I915_SET_FIELD( var, mask, value ) (var &= ~(mask), var |= value)
+
+#define CMD_3D (0x3<<29)
+
+#define PRIM3D_INLINE (CMD_3D | (0x1f<<24))
+#define PRIM3D_TRILIST (0x0<<18)
+#define PRIM3D_TRISTRIP (0x1<<18)
+#define PRIM3D_TRISTRIP_RVRSE (0x2<<18)
+#define PRIM3D_TRIFAN (0x3<<18)
+#define PRIM3D_POLY (0x4<<18)
+#define PRIM3D_LINELIST (0x5<<18)
+#define PRIM3D_LINESTRIP (0x6<<18)
+#define PRIM3D_RECTLIST (0x7<<18)
+#define PRIM3D_POINTLIST (0x8<<18)
+#define PRIM3D_DIB (0x9<<18)
+#define PRIM3D_CLEAR_RECT (0xa<<18)
+#define PRIM3D_ZONE_INIT (0xd<<18)
+#define PRIM3D_MASK (0x1f<<18)
+
+/* p137 */
+#define _3DSTATE_AA_CMD (CMD_3D | (0x06<<24))
+#define AA_LINE_ECAAR_WIDTH_ENABLE (1<<16)
+#define AA_LINE_ECAAR_WIDTH_0_5 0
+#define AA_LINE_ECAAR_WIDTH_1_0 (1<<14)
+#define AA_LINE_ECAAR_WIDTH_2_0 (2<<14)
+#define AA_LINE_ECAAR_WIDTH_4_0 (3<<14)
+#define AA_LINE_REGION_WIDTH_ENABLE (1<<8)
+#define AA_LINE_REGION_WIDTH_0_5 0
+#define AA_LINE_REGION_WIDTH_1_0 (1<<6)
+#define AA_LINE_REGION_WIDTH_2_0 (2<<6)
+#define AA_LINE_REGION_WIDTH_4_0 (3<<6)
+
+/* 3DSTATE_BACKFACE_STENCIL_OPS, p138*/
+#define _3DSTATE_BACKFACE_STENCIL_OPS (CMD_3D | (0x8<<24))
+#define BFO_ENABLE_STENCIL_REF (1<<23)
+#define BFO_STENCIL_REF_SHIFT 15
+#define BFO_STENCIL_REF_MASK (0xff<<15)
+#define BFO_ENABLE_STENCIL_FUNCS (1<<14)
+#define BFO_STENCIL_TEST_SHIFT 11
+#define BFO_STENCIL_TEST_MASK (0x7<<11)
+#define BFO_STENCIL_FAIL_SHIFT 8
+#define BFO_STENCIL_FAIL_MASK (0x7<<8)
+#define BFO_STENCIL_PASS_Z_FAIL_SHIFT 5
+#define BFO_STENCIL_PASS_Z_FAIL_MASK (0x7<<5)
+#define BFO_STENCIL_PASS_Z_PASS_SHIFT 2
+#define BFO_STENCIL_PASS_Z_PASS_MASK (0x7<<2)
+#define BFO_ENABLE_STENCIL_TWO_SIDE (1<<1)
+#define BFO_STENCIL_TWO_SIDE (1<<0)
+
+
+/* 3DSTATE_BACKFACE_STENCIL_MASKS, p140 */
+#define _3DSTATE_BACKFACE_STENCIL_MASKS (CMD_3D | (0x9<<24))
+#define BFM_ENABLE_STENCIL_TEST_MASK (1<<17)
+#define BFM_ENABLE_STENCIL_WRITE_MASK (1<<16)
+#define BFM_STENCIL_TEST_MASK_SHIFT 8
+#define BFM_STENCIL_TEST_MASK_MASK (0xff<<8)
+#define BFM_STENCIL_WRITE_MASK_SHIFT 0
+#define BFM_STENCIL_WRITE_MASK_MASK (0xff<<0)
+
+
+
+/* 3DSTATE_BIN_CONTROL p141 */
+
+/* p143 */
+#define _3DSTATE_BUF_INFO_CMD (CMD_3D | (0x1d<<24) | (0x8e<<16) | 1)
+/* Dword 1 */
+#define BUF_3D_ID_COLOR_BACK (0x3<<24)
+#define BUF_3D_ID_DEPTH (0x7<<24)
+#define BUF_3D_USE_FENCE (1<<23)
+#define BUF_3D_TILED_SURFACE (1<<22)
+#define BUF_3D_TILE_WALK_X 0
+#define BUF_3D_TILE_WALK_Y (1<<21)
+#define BUF_3D_PITCH(x) (((x)/4)<<2)
+/* Dword 2 */
+#define BUF_3D_ADDR(x) ((x) & ~0x3)
+
+
+/* 3DSTATE_CHROMA_KEY */
+
+/* 3DSTATE_CLEAR_PARAMETERS, p150 */
+
+/* 3DSTATE_CONSTANT_BLEND_COLOR, p153 */
+#define _3DSTATE_CONST_BLEND_COLOR_CMD (CMD_3D | (0x1d<<24) | (0x88<<16))
+
+
+
+/* 3DSTATE_COORD_SET_BINDINGS, p154 */
+#define _3DSTATE_COORD_SET_BINDINGS (CMD_3D | (0x16<<24))
+#define CSB_TCB(iunit, eunit) ((eunit)<<(iunit*3))
+
+/* p156 */
+#define _3DSTATE_DFLT_DIFFUSE_CMD (CMD_3D | (0x1d<<24) | (0x99<<16))
+
+/* p157 */
+#define _3DSTATE_DFLT_SPEC_CMD (CMD_3D | (0x1d<<24) | (0x9a<<16))
+
+/* p158 */
+#define _3DSTATE_DFLT_Z_CMD (CMD_3D | (0x1d<<24) | (0x98<<16))
+
+
+/* 3DSTATE_DEPTH_OFFSET_SCALE, p159 */
+#define _3DSTATE_DEPTH_OFFSET_SCALE (CMD_3D | (0x1d<<24) | (0x97<<16))
+/* scale in dword 1 */
+
+
+/* 3DSTATE_DEPTH_SUBRECT_DISABLE, p160 */
+#define _3DSTATE_DEPTH_SUBRECT_DISABLE (CMD_3D | (0x1c<<24) | (0x11<19) | 0x2)
+
+/* p161 */
+#define _3DSTATE_DST_BUF_VARS_CMD (CMD_3D | (0x1d<<24) | (0x85<<16))
+/* Dword 1 */
+#define TEX_DEFAULT_COLOR_OGL (0<<30)
+#define TEX_DEFAULT_COLOR_D3D (1<<30)
+#define ZR_EARLY_DEPTH (1<<29)
+#define LOD_PRECLAMP_OGL (1<<28)
+#define LOD_PRECLAMP_D3D (0<<28)
+#define DITHER_FULL_ALWAYS (0<<26)
+#define DITHER_FULL_ON_FB_BLEND (1<<26)
+#define DITHER_CLAMPED_ALWAYS (2<<26)
+#define LINEAR_GAMMA_BLEND_32BPP (1<<25)
+#define DEBUG_DISABLE_ENH_DITHER (1<<24)
+#define DSTORG_HORT_BIAS(x) ((x)<<20)
+#define DSTORG_VERT_BIAS(x) ((x)<<16)
+#define COLOR_4_2_2_CHNL_WRT_ALL 0
+#define COLOR_4_2_2_CHNL_WRT_Y (1<<12)
+#define COLOR_4_2_2_CHNL_WRT_CR (2<<12)
+#define COLOR_4_2_2_CHNL_WRT_CB (3<<12)
+#define COLOR_4_2_2_CHNL_WRT_CRCB (4<<12)
+#define COLR_BUF_8BIT 0
+#define COLR_BUF_RGB555 (1<<8)
+#define COLR_BUF_RGB565 (2<<8)
+#define COLR_BUF_ARGB8888 (3<<8)
+#define DEPTH_FRMT_16_FIXED 0
+#define DEPTH_FRMT_16_FLOAT (1<<2)
+#define DEPTH_FRMT_24_FIXED_8_OTHER (2<<2)
+#define VERT_LINE_STRIDE_1 (1<<1)
+#define VERT_LINE_STRIDE_0 (0<<1)
+#define VERT_LINE_STRIDE_OFS_1 1
+#define VERT_LINE_STRIDE_OFS_0 0
+
+/* p166 */
+#define _3DSTATE_DRAW_RECT_CMD (CMD_3D|(0x1d<<24)|(0x80<<16)|3)
+/* Dword 1 */
+#define DRAW_RECT_DIS_DEPTH_OFS (1<<30)
+#define DRAW_DITHER_OFS_X(x) ((x)<<26)
+#define DRAW_DITHER_OFS_Y(x) ((x)<<24)
+/* Dword 2 */
+#define DRAW_YMIN(x) ((x)<<16)
+#define DRAW_XMIN(x) (x)
+/* Dword 3 */
+#define DRAW_YMAX(x) ((x)<<16)
+#define DRAW_XMAX(x) (x)
+/* Dword 4 */
+#define DRAW_YORG(x) ((x)<<16)
+#define DRAW_XORG(x) (x)
+
+
+/* 3DSTATE_FILTER_COEFFICIENTS_4X4, p170 */
+
+/* 3DSTATE_FILTER_COEFFICIENTS_6X5, p172 */
+
+
+/* _3DSTATE_FOG_COLOR, p173 */
+#define _3DSTATE_FOG_COLOR_CMD (CMD_3D|(0x15<<24))
+#define FOG_COLOR_RED(x) ((x)<<16)
+#define FOG_COLOR_GREEN(x) ((x)<<8)
+#define FOG_COLOR_BLUE(x) (x)
+
+/* _3DSTATE_FOG_MODE, p174 */
+#define _3DSTATE_FOG_MODE_CMD (CMD_3D|(0x1d<<24)|(0x89<<16)|2)
+/* Dword 1 */
+#define FMC1_FOGFUNC_MODIFY_ENABLE (1<<31)
+#define FMC1_FOGFUNC_VERTEX (0<<28)
+#define FMC1_FOGFUNC_PIXEL_EXP (1<<28)
+#define FMC1_FOGFUNC_PIXEL_EXP2 (2<<28)
+#define FMC1_FOGFUNC_PIXEL_LINEAR (3<<28)
+#define FMC1_FOGFUNC_MASK (3<<28)
+#define FMC1_FOGINDEX_MODIFY_ENABLE (1<<27)
+#define FMC1_FOGINDEX_Z (0<<25)
+#define FMC1_FOGINDEX_W (1<<25)
+#define FMC1_C1_C2_MODIFY_ENABLE (1<<24)
+#define FMC1_DENSITY_MODIFY_ENABLE (1<<23)
+#define FMC1_C1_ONE (1<<13)
+#define FMC1_C1_MASK (0xffff<<4)
+/* Dword 2 */
+#define FMC2_C2_ONE (1<<16)
+/* Dword 3 */
+#define FMC3_D_ONE (1<<16)
+
+
+
+/* _3DSTATE_INDEPENDENT_ALPHA_BLEND, p177 */
+#define _3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD (CMD_3D|(0x0b<<24))
+#define IAB_MODIFY_ENABLE (1<<23)
+#define IAB_ENABLE (1<<22)
+#define IAB_MODIFY_FUNC (1<<21)
+#define IAB_FUNC_SHIFT 16
+#define IAB_MODIFY_SRC_FACTOR (1<<11)
+#define IAB_SRC_FACTOR_SHIFT 6
+#define IAB_SRC_FACTOR_MASK (BLENDFACT_MASK<<6)
+#define IAB_MODIFY_DST_FACTOR (1<<5)
+#define IAB_DST_FACTOR_SHIFT 0
+#define IAB_DST_FACTOR_MASK (BLENDFACT_MASK<<0)
+
+
+#define BLENDFUNC_ADD 0x0
+#define BLENDFUNC_SUBTRACT 0x1
+#define BLENDFUNC_REVERSE_SUBTRACT 0x2
+#define BLENDFUNC_MIN 0x3
+#define BLENDFUNC_MAX 0x4
+#define BLENDFUNC_MASK 0x7
+
+/* 3DSTATE_LOAD_INDIRECT, p180 */
+
+#define _3DSTATE_LOAD_INDIRECT (CMD_3D|(0x1d<<24)|(0x7<<16))
+#define LI0_STATE_STATIC_INDIRECT (0x01<<8)
+#define LI0_STATE_DYNAMIC_INDIRECT (0x02<<8)
+#define LI0_STATE_SAMPLER (0x04<<8)
+#define LI0_STATE_MAP (0x08<<8)
+#define LI0_STATE_PROGRAM (0x10<<8)
+#define LI0_STATE_CONSTANTS (0x20<<8)
+
+#define SIS0_BUFFER_ADDRESS(x) ((x)&~0x3)
+#define SIS0_FORCE_LOAD (1<<1)
+#define SIS0_BUFFER_VALID (1<<0)
+#define SIS1_BUFFER_LENGTH(x) ((x)&0xff)
+
+#define DIS0_BUFFER_ADDRESS(x) ((x)&~0x3)
+#define DIS0_BUFFER_RESET (1<<1)
+#define DIS0_BUFFER_VALID (1<<0)
+
+#define SSB0_BUFFER_ADDRESS(x) ((x)&~0x3)
+#define SSB0_FORCE_LOAD (1<<1)
+#define SSB0_BUFFER_VALID (1<<0)
+#define SSB1_BUFFER_LENGTH(x) ((x)&0xff)
+
+#define MSB0_BUFFER_ADDRESS(x) ((x)&~0x3)
+#define MSB0_FORCE_LOAD (1<<1)
+#define MSB0_BUFFER_VALID (1<<0)
+#define MSB1_BUFFER_LENGTH(x) ((x)&0xff)
+
+#define PSP0_BUFFER_ADDRESS(x) ((x)&~0x3)
+#define PSP0_FORCE_LOAD (1<<1)
+#define PSP0_BUFFER_VALID (1<<0)
+#define PSP1_BUFFER_LENGTH(x) ((x)&0xff)
+
+#define PSC0_BUFFER_ADDRESS(x) ((x)&~0x3)
+#define PSC0_FORCE_LOAD (1<<1)
+#define PSC0_BUFFER_VALID (1<<0)
+#define PSC1_BUFFER_LENGTH(x) ((x)&0xff)
+
+
+
+
+
+/* _3DSTATE_RASTERIZATION_RULES */
+#define _3DSTATE_RASTER_RULES_CMD (CMD_3D|(0x07<<24))
+#define ENABLE_POINT_RASTER_RULE (1<<15)
+#define OGL_POINT_RASTER_RULE (1<<13)
+#define ENABLE_TEXKILL_3D_4D (1<<10)
+#define TEXKILL_3D (0<<9)
+#define TEXKILL_4D (1<<9)
+#define ENABLE_LINE_STRIP_PROVOKE_VRTX (1<<8)
+#define ENABLE_TRI_FAN_PROVOKE_VRTX (1<<5)
+#define LINE_STRIP_PROVOKE_VRTX(x) ((x)<<6)
+#define TRI_FAN_PROVOKE_VRTX(x) ((x)<<3)
+
+/* _3DSTATE_SCISSOR_ENABLE, p256 */
+#define _3DSTATE_SCISSOR_ENABLE_CMD (CMD_3D|(0x1c<<24)|(0x10<<19))
+#define ENABLE_SCISSOR_RECT ((1<<1) | 1)
+#define DISABLE_SCISSOR_RECT (1<<1)
+
+/* _3DSTATE_SCISSOR_RECTANGLE_0, p257 */
+#define _3DSTATE_SCISSOR_RECT_0_CMD (CMD_3D|(0x1d<<24)|(0x81<<16)|1)
+/* Dword 1 */
+#define SCISSOR_RECT_0_YMIN(x) ((x)<<16)
+#define SCISSOR_RECT_0_XMIN(x) (x)
+/* Dword 2 */
+#define SCISSOR_RECT_0_YMAX(x) ((x)<<16)
+#define SCISSOR_RECT_0_XMAX(x) (x)
+
+/* p189 */
+#define _3DSTATE_LOAD_STATE_IMMEDIATE_1 ((0x3<<29)|(0x1d<<24)|(0x04<<16))
+#define I1_LOAD_S(n) (1<<(4+n))
+
+#define S0_VB_OFFSET_MASK 0xffffffc
+#define S0_AUTO_CACHE_INV_DISABLE (1<<0)
+
+#define S1_VERTEX_WIDTH_SHIFT 24
+#define S1_VERTEX_WIDTH_MASK (0x3f<<24)
+#define S1_VERTEX_PITCH_SHIFT 16
+#define S1_VERTEX_PITCH_MASK (0x3f<<16)
+
+#define TEXCOORDFMT_2D 0x0
+#define TEXCOORDFMT_3D 0x1
+#define TEXCOORDFMT_4D 0x2
+#define TEXCOORDFMT_1D 0x3
+#define TEXCOORDFMT_2D_16 0x4
+#define TEXCOORDFMT_4D_16 0x5
+#define TEXCOORDFMT_NOT_PRESENT 0xf
+#define S2_TEXCOORD_FMT0_MASK 0xf
+#define S2_TEXCOORD_FMT1_SHIFT 4
+#define S2_TEXCOORD_FMT(unit, type) ((type)<<(unit*4))
+#define S2_TEXCOORD_NONE (~0)
+
+/* S3 not interesting */
+
+#define S4_POINT_WIDTH_SHIFT 23
+#define S4_POINT_WIDTH_MASK (0x1ff<<23)
+#define S4_LINE_WIDTH_SHIFT 19
+#define S4_LINE_WIDTH_ONE (0x2<<19)
+#define S4_LINE_WIDTH_MASK (0xf<<19)
+#define S4_FLATSHADE_ALPHA (1<<18)
+#define S4_FLATSHADE_FOG (1<<17)
+#define S4_FLATSHADE_SPECULAR (1<<16)
+#define S4_FLATSHADE_COLOR (1<<15)
+#define S4_CULLMODE_BOTH (0<<13)
+#define S4_CULLMODE_NONE (1<<13)
+#define S4_CULLMODE_CW (2<<13)
+#define S4_CULLMODE_CCW (3<<13)
+#define S4_CULLMODE_MASK (3<<13)
+#define S4_VFMT_POINT_WIDTH (1<<12)
+#define S4_VFMT_SPEC_FOG (1<<11)
+#define S4_VFMT_COLOR (1<<10)
+#define S4_VFMT_DEPTH_OFFSET (1<<9)
+#define S4_VFMT_XYZ (1<<6)
+#define S4_VFMT_XYZW (2<<6)
+#define S4_VFMT_XY (3<<6)
+#define S4_VFMT_XYW (4<<6)
+#define S4_VFMT_XYZW_MASK (7<<6)
+#define S4_FORCE_DEFAULT_DIFFUSE (1<<5)
+#define S4_FORCE_DEFAULT_SPECULAR (1<<4)
+#define S4_LOCAL_DEPTH_OFFSET_ENABLE (1<<3)
+#define S4_VFMT_FOG_PARAM (1<<2)
+#define S4_SPRITE_POINT_ENABLE (1<<1)
+#define S4_LINE_ANTIALIAS_ENABLE (1<<0)
+
+#define S4_VFMT_MASK (S4_VFMT_POINT_WIDTH | \
+ S4_VFMT_SPEC_FOG | \
+ S4_VFMT_COLOR | \
+ S4_VFMT_DEPTH_OFFSET | \
+ S4_VFMT_XYZW_MASK | \
+ S4_VFMT_FOG_PARAM)
+
+
+#define S5_WRITEDISABLE_ALPHA (1<<31)
+#define S5_WRITEDISABLE_RED (1<<30)
+#define S5_WRITEDISABLE_GREEN (1<<29)
+#define S5_WRITEDISABLE_BLUE (1<<28)
+#define S5_WRITEDISABLE_MASK (0xf<<28)
+#define S5_FORCE_DEFAULT_POINT_SIZE (1<<27)
+#define S5_LAST_PIXEL_ENABLE (1<<26)
+#define S5_GLOBAL_DEPTH_OFFSET_ENABLE (1<<25)
+#define S5_FOG_ENABLE (1<<24)
+#define S5_STENCIL_REF_SHIFT 16
+#define S5_STENCIL_REF_MASK (0xff<<16)
+#define S5_STENCIL_TEST_FUNC_SHIFT 13
+#define S5_STENCIL_TEST_FUNC_MASK (0x7<<13)
+#define S5_STENCIL_FAIL_SHIFT 10
+#define S5_STENCIL_FAIL_MASK (0x7<<10)
+#define S5_STENCIL_PASS_Z_FAIL_SHIFT 7
+#define S5_STENCIL_PASS_Z_FAIL_MASK (0x7<<7)
+#define S5_STENCIL_PASS_Z_PASS_SHIFT 4
+#define S5_STENCIL_PASS_Z_PASS_MASK (0x7<<4)
+#define S5_STENCIL_WRITE_ENABLE (1<<3)
+#define S5_STENCIL_TEST_ENABLE (1<<2)
+#define S5_COLOR_DITHER_ENABLE (1<<1)
+#define S5_LOGICOP_ENABLE (1<<0)
+
+
+#define S6_ALPHA_TEST_ENABLE (1<<31)
+#define S6_ALPHA_TEST_FUNC_SHIFT 28
+#define S6_ALPHA_TEST_FUNC_MASK (0x7<<28)
+#define S6_ALPHA_REF_SHIFT 20
+#define S6_ALPHA_REF_MASK (0xff<<20)
+#define S6_DEPTH_TEST_ENABLE (1<<19)
+#define S6_DEPTH_TEST_FUNC_SHIFT 16
+#define S6_DEPTH_TEST_FUNC_MASK (0x7<<16)
+#define S6_CBUF_BLEND_ENABLE (1<<15)
+#define S6_CBUF_BLEND_FUNC_SHIFT 12
+#define S6_CBUF_BLEND_FUNC_MASK (0x7<<12)
+#define S6_CBUF_SRC_BLEND_FACT_SHIFT 8
+#define S6_CBUF_SRC_BLEND_FACT_MASK (0xf<<8)
+#define S6_CBUF_DST_BLEND_FACT_SHIFT 4
+#define S6_CBUF_DST_BLEND_FACT_MASK (0xf<<4)
+#define S6_DEPTH_WRITE_ENABLE (1<<3)
+#define S6_COLOR_WRITE_ENABLE (1<<2)
+#define S6_TRISTRIP_PV_SHIFT 0
+#define S6_TRISTRIP_PV_MASK (0x3<<0)
+
+#define S7_DEPTH_OFFSET_CONST_MASK ~0
+
+/* 3DSTATE_MAP_DEINTERLACER_PARAMETERS */
+/* 3DSTATE_MAP_PALETTE_LOAD_32, p206 */
+
+
+/* _3DSTATE_MODES_4, p218 */
+#define _3DSTATE_MODES_4_CMD (CMD_3D|(0x0d<<24))
+#define ENABLE_LOGIC_OP_FUNC (1<<23)
+#define LOGIC_OP_FUNC(x) ((x)<<18)
+#define LOGICOP_MASK (0xf<<18)
+#define MODE4_ENABLE_STENCIL_TEST_MASK ((1<<17)|(0xff00))
+#define ENABLE_STENCIL_TEST_MASK (1<<17)
+#define STENCIL_TEST_MASK(x) ((x)<<8)
+#define MODE4_ENABLE_STENCIL_WRITE_MASK ((1<<16)|(0x00ff))
+#define ENABLE_STENCIL_WRITE_MASK (1<<16)
+#define STENCIL_WRITE_MASK(x) (x)
+
+/* _3DSTATE_MODES_5, p220 */
+#define _3DSTATE_MODES_5_CMD (CMD_3D|(0x0c<<24))
+#define PIPELINE_FLUSH_RENDER_CACHE (1<<18)
+#define PIPELINE_FLUSH_TEXTURE_CACHE (1<<16)
+
+
+/* p221 */
+#define _3DSTATE_PIXEL_SHADER_CONSTANTS (CMD_3D|(0x1d<<24)|(0x6<<16))
+#define PS1_REG(n) (1<<(n))
+#define PS2_CONST_X(n) (n)
+#define PS3_CONST_Y(n) (n)
+#define PS4_CONST_Z(n) (n)
+#define PS5_CONST_W(n) (n)
+
+/* p222 */
+
+
+#define I915_MAX_TEX_INDIRECT 4
+#define I915_MAX_TEX_INSN 32
+#define I915_MAX_ALU_INSN 64
+#define I915_MAX_DECL_INSN 27
+#define I915_MAX_TEMPORARY 16
+
+
+/* Each instruction is 3 dwords long, though most don't require all
+ * this space. Maximum of 123 instructions. Smaller maxes per insn
+ * type.
+ */
+#define _3DSTATE_PIXEL_SHADER_PROGRAM (CMD_3D|(0x1d<<24)|(0x5<<16))
+
+#define REG_TYPE_R 0 /* temporary regs, no need to
+ * dcl, must be written before
+ * read -- Preserved between
+ * phases.
+ */
+#define REG_TYPE_T 1 /* Interpolated values, must be
+ * dcl'ed before use.
+ *
+ * 0..7: texture coord,
+ * 8: diffuse spec,
+ * 9: specular color,
+ * 10: fog parameter in w.
+ */
+#define REG_TYPE_CONST 2 /* Restriction: only one const
+ * can be referenced per
+ * instruction, though it may be
+ * selected for multiple inputs.
+ * Constants not initialized
+ * default to zero.
+ */
+#define REG_TYPE_S 3 /* sampler */
+#define REG_TYPE_OC 4 /* output color (rgba) */
+#define REG_TYPE_OD 5 /* output depth (w), xyz are
+ * temporaries. If not written,
+ * interpolated depth is used?
+ */
+#define REG_TYPE_U 6 /* unpreserved temporaries */
+#define REG_TYPE_MASK 0x7
+#define REG_NR_MASK 0xf
+
+
+/* REG_TYPE_T:
+ */
+#define T_TEX0 0
+#define T_TEX1 1
+#define T_TEX2 2
+#define T_TEX3 3
+#define T_TEX4 4
+#define T_TEX5 5
+#define T_TEX6 6
+#define T_TEX7 7
+#define T_DIFFUSE 8
+#define T_SPECULAR 9
+#define T_FOG_W 10 /* interpolated fog is in W coord */
+
+/* Arithmetic instructions */
+
+/* .replicate_swizzle == selection and replication of a particular
+ * scalar channel, ie., .xxxx, .yyyy, .zzzz or .wwww
+ */
+#define A0_NOP (0x0<<24) /* no operation */
+#define A0_ADD (0x1<<24) /* dst = src0 + src1 */
+#define A0_MOV (0x2<<24) /* dst = src0 */
+#define A0_MUL (0x3<<24) /* dst = src0 * src1 */
+#define A0_MAD (0x4<<24) /* dst = src0 * src1 + src2 */
+#define A0_DP2ADD (0x5<<24) /* dst.xyzw = src0.xy dot src1.xy + src2.replicate_swizzle */
+#define A0_DP3 (0x6<<24) /* dst.xyzw = src0.xyz dot src1.xyz */
+#define A0_DP4 (0x7<<24) /* dst.xyzw = src0.xyzw dot src1.xyzw */
+#define A0_FRC (0x8<<24) /* dst = src0 - floor(src0) */
+#define A0_RCP (0x9<<24) /* dst.xyzw = 1/(src0.replicate_swizzle) */
+#define A0_RSQ (0xa<<24) /* dst.xyzw = 1/(sqrt(abs(src0.replicate_swizzle))) */
+#define A0_EXP (0xb<<24) /* dst.xyzw = exp2(src0.replicate_swizzle) */
+#define A0_LOG (0xc<<24) /* dst.xyzw = log2(abs(src0.replicate_swizzle)) */
+#define A0_CMP (0xd<<24) /* dst = (src0 >= 0.0) ? src1 : src2 */
+#define A0_MIN (0xe<<24) /* dst = (src0 < src1) ? src0 : src1 */
+#define A0_MAX (0xf<<24) /* dst = (src0 >= src1) ? src0 : src1 */
+#define A0_FLR (0x10<<24) /* dst = floor(src0) */
+#define A0_MOD (0x11<<24) /* dst = src0 fmod 1.0 */
+#define A0_TRC (0x12<<24) /* dst = int(src0) */
+#define A0_SGE (0x13<<24) /* dst = src0 >= src1 ? 1.0 : 0.0 */
+#define A0_SLT (0x14<<24) /* dst = src0 < src1 ? 1.0 : 0.0 */
+#define A0_DEST_SATURATE (1<<22)
+#define A0_DEST_TYPE_SHIFT 19
+/* Allow: R, OC, OD, U */
+#define A0_DEST_NR_SHIFT 14
+/* Allow R: 0..15, OC,OD: 0..0, U: 0..2 */
+#define A0_DEST_CHANNEL_X (1<<10)
+#define A0_DEST_CHANNEL_Y (2<<10)
+#define A0_DEST_CHANNEL_Z (4<<10)
+#define A0_DEST_CHANNEL_W (8<<10)
+#define A0_DEST_CHANNEL_ALL (0xf<<10)
+#define A0_DEST_CHANNEL_SHIFT 10
+#define A0_SRC0_TYPE_SHIFT 7
+#define A0_SRC0_NR_SHIFT 2
+
+#define A0_DEST_CHANNEL_XY (A0_DEST_CHANNEL_X|A0_DEST_CHANNEL_Y)
+#define A0_DEST_CHANNEL_XYZ (A0_DEST_CHANNEL_XY|A0_DEST_CHANNEL_Z)
+
+
+#define SRC_X 0
+#define SRC_Y 1
+#define SRC_Z 2
+#define SRC_W 3
+#define SRC_ZERO 4
+#define SRC_ONE 5
+
+#define A1_SRC0_CHANNEL_X_NEGATE (1<<31)
+#define A1_SRC0_CHANNEL_X_SHIFT 28
+#define A1_SRC0_CHANNEL_Y_NEGATE (1<<27)
+#define A1_SRC0_CHANNEL_Y_SHIFT 24
+#define A1_SRC0_CHANNEL_Z_NEGATE (1<<23)
+#define A1_SRC0_CHANNEL_Z_SHIFT 20
+#define A1_SRC0_CHANNEL_W_NEGATE (1<<19)
+#define A1_SRC0_CHANNEL_W_SHIFT 16
+#define A1_SRC1_TYPE_SHIFT 13
+#define A1_SRC1_NR_SHIFT 8
+#define A1_SRC1_CHANNEL_X_NEGATE (1<<7)
+#define A1_SRC1_CHANNEL_X_SHIFT 4
+#define A1_SRC1_CHANNEL_Y_NEGATE (1<<3)
+#define A1_SRC1_CHANNEL_Y_SHIFT 0
+
+#define A2_SRC1_CHANNEL_Z_NEGATE (1<<31)
+#define A2_SRC1_CHANNEL_Z_SHIFT 28
+#define A2_SRC1_CHANNEL_W_NEGATE (1<<27)
+#define A2_SRC1_CHANNEL_W_SHIFT 24
+#define A2_SRC2_TYPE_SHIFT 21
+#define A2_SRC2_NR_SHIFT 16
+#define A2_SRC2_CHANNEL_X_NEGATE (1<<15)
+#define A2_SRC2_CHANNEL_X_SHIFT 12
+#define A2_SRC2_CHANNEL_Y_NEGATE (1<<11)
+#define A2_SRC2_CHANNEL_Y_SHIFT 8
+#define A2_SRC2_CHANNEL_Z_NEGATE (1<<7)
+#define A2_SRC2_CHANNEL_Z_SHIFT 4
+#define A2_SRC2_CHANNEL_W_NEGATE (1<<3)
+#define A2_SRC2_CHANNEL_W_SHIFT 0
+
+
+
+/* Texture instructions */
+#define T0_TEXLD (0x15<<24) /* Sample texture using predeclared
+ * sampler and address, and output
+ * filtered texel data to destination
+ * register */
+#define T0_TEXLDP (0x16<<24) /* Same as texld but performs a
+ * perspective divide of the texture
+ * coordinate .xyz values by .w before
+ * sampling. */
+#define T0_TEXLDB (0x17<<24) /* Same as texld but biases the
+ * computed LOD by w. Only S4.6 two's
+ * comp is used. This implies that a
+ * float to fixed conversion is
+ * done. */
+#define T0_TEXKILL (0x18<<24) /* Does not perform a sampling
+ * operation. Simply kills the pixel
+ * if any channel of the address
+ * register is < 0.0. */
+#define T0_DEST_TYPE_SHIFT 19
+/* Allow: R, OC, OD, U */
+/* Note: U (unpreserved) regs do not retain their values between
+ * phases (cannot be used for feedback)
+ *
+ * Note: oC and OD registers can only be used as the destination of a
+ * texture instruction once per phase (this is an implementation
+ * restriction).
+ */
+#define T0_DEST_NR_SHIFT 14
+/* Allow R: 0..15, OC,OD: 0..0, U: 0..2 */
+#define T0_SAMPLER_NR_SHIFT 0 /* This field ignored for TEXKILL */
+#define T0_SAMPLER_NR_MASK (0xf<<0)
+
+#define T1_ADDRESS_REG_TYPE_SHIFT 24 /* Reg to use as texture coord */
+/* Allow R, T, OC, OD -- R, OC, OD are 'dependent' reads, new program phase */
+#define T1_ADDRESS_REG_NR_SHIFT 17
+#define T2_MBZ 0
+
+/* Declaration instructions */
+#define D0_DCL (0x19<<24) /* Declare a t (interpolated attrib)
+ * register or an s (sampler)
+ * register. */
+#define D0_SAMPLE_TYPE_SHIFT 22
+#define D0_SAMPLE_TYPE_2D (0x0<<22)
+#define D0_SAMPLE_TYPE_CUBE (0x1<<22)
+#define D0_SAMPLE_TYPE_VOLUME (0x2<<22)
+#define D0_SAMPLE_TYPE_MASK (0x3<<22)
+
+#define D0_TYPE_SHIFT 19
+/* Allow: T, S */
+#define D0_NR_SHIFT 14
+/* Allow T: 0..10, S: 0..15 */
+#define D0_CHANNEL_X (1<<10)
+#define D0_CHANNEL_Y (2<<10)
+#define D0_CHANNEL_Z (4<<10)
+#define D0_CHANNEL_W (8<<10)
+#define D0_CHANNEL_ALL (0xf<<10)
+#define D0_CHANNEL_NONE (0<<10)
+
+#define D0_CHANNEL_XY (D0_CHANNEL_X|D0_CHANNEL_Y)
+#define D0_CHANNEL_XYZ (D0_CHANNEL_XY|D0_CHANNEL_Z)
+
+/* I915 Errata: Do not allow (xz), (xw), (xzw) combinations for diffuse
+ * or specular declarations.
+ *
+ * For T dcls, only allow: (x), (xy), (xyz), (w), (xyzw)
+ *
+ * Must be zero for S (sampler) dcls
+ */
+#define D1_MBZ 0
+#define D2_MBZ 0
+
+
+
+/* p207 */
+#define _3DSTATE_MAP_STATE (CMD_3D|(0x1d<<24)|(0x0<<16))
+
+#define MS1_MAPMASK_SHIFT 0
+#define MS1_MAPMASK_MASK (0x8fff<<0)
+
+#define MS2_UNTRUSTED_SURFACE (1<<31)
+#define MS2_ADDRESS_MASK 0xfffffffc
+#define MS2_VERTICAL_LINE_STRIDE (1<<1)
+#define MS2_VERTICAL_OFFSET (1<<1)
+
+#define MS3_HEIGHT_SHIFT 21
+#define MS3_WIDTH_SHIFT 10
+#define MS3_PALETTE_SELECT (1<<9)
+#define MS3_MAPSURF_FORMAT_SHIFT 7
+#define MS3_MAPSURF_FORMAT_MASK (0x7<<7)
+#define MAPSURF_8BIT (1<<7)
+#define MAPSURF_16BIT (2<<7)
+#define MAPSURF_32BIT (3<<7)
+#define MAPSURF_422 (5<<7)
+#define MAPSURF_COMPRESSED (6<<7)
+#define MAPSURF_4BIT_INDEXED (7<<7)
+#define MS3_MT_FORMAT_MASK (0x7 << 3)
+#define MS3_MT_FORMAT_SHIFT 3
+#define MT_4BIT_IDX_ARGB8888 (7<<3) /* SURFACE_4BIT_INDEXED */
+#define MT_8BIT_I8 (0<<3) /* SURFACE_8BIT */
+#define MT_8BIT_L8 (1<<3)
+#define MT_8BIT_A8 (4<<3)
+#define MT_8BIT_MONO8 (5<<3)
+#define MT_16BIT_RGB565 (0<<3) /* SURFACE_16BIT */
+#define MT_16BIT_ARGB1555 (1<<3)
+#define MT_16BIT_ARGB4444 (2<<3)
+#define MT_16BIT_AY88 (3<<3)
+#define MT_16BIT_88DVDU (5<<3)
+#define MT_16BIT_BUMP_655LDVDU (6<<3)
+#define MT_16BIT_I16 (7<<3)
+#define MT_16BIT_L16 (8<<3)
+#define MT_16BIT_A16 (9<<3)
+#define MT_32BIT_ARGB8888 (0<<3) /* SURFACE_32BIT */
+#define MT_32BIT_ABGR8888 (1<<3)
+#define MT_32BIT_XRGB8888 (2<<3)
+#define MT_32BIT_XBGR8888 (3<<3)
+#define MT_32BIT_QWVU8888 (4<<3)
+#define MT_32BIT_AXVU8888 (5<<3)
+#define MT_32BIT_LXVU8888 (6<<3)
+#define MT_32BIT_XLVU8888 (7<<3)
+#define MT_32BIT_ARGB2101010 (8<<3)
+#define MT_32BIT_ABGR2101010 (9<<3)
+#define MT_32BIT_AWVU2101010 (0xA<<3)
+#define MT_32BIT_GR1616 (0xB<<3)
+#define MT_32BIT_VU1616 (0xC<<3)
+#define MT_32BIT_xI824 (0xD<<3)
+#define MT_32BIT_xA824 (0xE<<3)
+#define MT_32BIT_xL824 (0xF<<3)
+#define MT_422_YCRCB_SWAPY (0<<3) /* SURFACE_422 */
+#define MT_422_YCRCB_NORMAL (1<<3)
+#define MT_422_YCRCB_SWAPUV (2<<3)
+#define MT_422_YCRCB_SWAPUVY (3<<3)
+#define MT_COMPRESS_DXT1 (0<<3) /* SURFACE_COMPRESSED */
+#define MT_COMPRESS_DXT2_3 (1<<3)
+#define MT_COMPRESS_DXT4_5 (2<<3)
+#define MT_COMPRESS_FXT1 (3<<3)
+#define MT_COMPRESS_DXT1_RGB (4<<3)
+#define MS3_USE_FENCE_REGS (1<<2)
+#define MS3_TILED_SURFACE (1<<1)
+#define MS3_TILE_WALK (1<<0)
+
+#define MS4_PITCH_SHIFT 21
+#define MS4_CUBE_FACE_ENA_NEGX (1<<20)
+#define MS4_CUBE_FACE_ENA_POSX (1<<19)
+#define MS4_CUBE_FACE_ENA_NEGY (1<<18)
+#define MS4_CUBE_FACE_ENA_POSY (1<<17)
+#define MS4_CUBE_FACE_ENA_NEGZ (1<<16)
+#define MS4_CUBE_FACE_ENA_POSZ (1<<15)
+#define MS4_CUBE_FACE_ENA_MASK (0x3f<<15)
+#define MS4_MAX_LOD_SHIFT 9
+#define MS4_MAX_LOD_MASK (0x3f<<9)
+#define MS4_MIP_LAYOUT_LEGACY (0<<8)
+#define MS4_VOLUME_DEPTH_SHIFT 0
+#define MS4_VOLUME_DEPTH_MASK (0xff<<0)
+
+/* p244 */
+#define _3DSTATE_SAMPLER_STATE (CMD_3D|(0x1d<<24)|(0x1<<16))
+
+#define SS1_MAPMASK_SHIFT 0
+#define SS1_MAPMASK_MASK (0x8fff<<0)
+
+#define SS2_REVERSE_GAMMA_ENABLE (1<<31)
+#define SS2_PACKED_TO_PLANAR_ENABLE (1<<30)
+#define SS2_COLORSPACE_CONVERSION (1<<29)
+#define SS2_CHROMAKEY_SHIFT 27
+#define SS2_BASE_MIP_LEVEL_SHIFT 22
+#define SS2_BASE_MIP_LEVEL_MASK (0x1f<<22)
+#define SS2_MIP_FILTER_SHIFT 20
+#define SS2_MIP_FILTER_MASK (0x3<<20)
+#define MIPFILTER_NONE 0
+#define MIPFILTER_NEAREST 1
+#define MIPFILTER_LINEAR 3
+#define SS2_MAG_FILTER_SHIFT 17
+#define SS2_MAG_FILTER_MASK (0x7<<17)
+#define FILTER_NEAREST 0
+#define FILTER_LINEAR 1
+#define FILTER_ANISOTROPIC 2
+#define FILTER_4X4_1 3
+#define FILTER_4X4_2 4
+#define FILTER_4X4_FLAT 5
+#define FILTER_6X5_MONO 6 /* XXX - check */
+#define SS2_MIN_FILTER_SHIFT 14
+#define SS2_MIN_FILTER_MASK (0x7<<14)
+#define SS2_LOD_BIAS_SHIFT 5
+#define SS2_LOD_BIAS_ONE (0x10<<5)
+#define SS2_LOD_BIAS_MASK (0x1ff<<5)
+/* Shadow requires:
+ * MT_X8{I,L,A}24 or MT_{I,L,A}16 texture format
+ * FILTER_4X4_x MIN and MAG filters
+ */
+#define SS2_SHADOW_ENABLE (1<<4)
+#define SS2_MAX_ANISO_MASK (1<<3)
+#define SS2_MAX_ANISO_2 (0<<3)
+#define SS2_MAX_ANISO_4 (1<<3)
+#define SS2_SHADOW_FUNC_SHIFT 0
+#define SS2_SHADOW_FUNC_MASK (0x7<<0)
+/* SS2_SHADOW_FUNC values: see COMPAREFUNC_* */
+
+#define SS3_MIN_LOD_SHIFT 24
+#define SS3_MIN_LOD_ONE (0x10<<24)
+#define SS3_MIN_LOD_MASK (0xff<<24)
+#define SS3_KILL_PIXEL_ENABLE (1<<17)
+#define SS3_TCX_ADDR_MODE_SHIFT 12
+#define SS3_TCX_ADDR_MODE_MASK (0x7<<12)
+#define TEXCOORDMODE_WRAP 0
+#define TEXCOORDMODE_MIRROR 1
+#define TEXCOORDMODE_CLAMP_EDGE 2
+#define TEXCOORDMODE_CUBE 3
+#define TEXCOORDMODE_CLAMP_BORDER 4
+#define TEXCOORDMODE_MIRROR_ONCE 5
+#define SS3_TCY_ADDR_MODE_SHIFT 9
+#define SS3_TCY_ADDR_MODE_MASK (0x7<<9)
+#define SS3_TCZ_ADDR_MODE_SHIFT 6
+#define SS3_TCZ_ADDR_MODE_MASK (0x7<<6)
+#define SS3_NORMALIZED_COORDS (1<<5)
+#define SS3_TEXTUREMAP_INDEX_SHIFT 1
+#define SS3_TEXTUREMAP_INDEX_MASK (0xf<<1)
+#define SS3_DEINTERLACER_ENABLE (1<<0)
+
+#define SS4_BORDER_COLOR_MASK (~0)
+
+/* 3DSTATE_SPAN_STIPPLE, p258
+ */
+#define _3DSTATE_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16))
+#define ST1_ENABLE (1<<16)
+#define ST1_MASK (0xffff)
+
+
+#define MI_FLUSH ((0<<29)|(4<<23))
+#define FLUSH_MAP_CACHE (1<<0)
+#define FLUSH_RENDER_CACHE (1<<1)
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_state.c
new file mode 100644
index 000000000..adb17b218
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_state.c
@@ -0,0 +1,954 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "enums.h"
+#include "dd.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+
+#include "texmem.h"
+
+#include "intel_screen.h"
+#include "intel_batchbuffer.h"
+
+#include "i915_context.h"
+#include "i915_reg.h"
+
+
+
+static void i915StencilFunc(GLcontext *ctx, GLenum func, GLint ref,
+ GLuint mask)
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ int test = intel_translate_compare_func( func );
+
+ mask = mask & 0xff;
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s : func: %s, ref : 0x%x, mask: 0x%x\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(func), ref, mask);
+
+
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ i915->state.Ctx[I915_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_TEST_MASK;
+ i915->state.Ctx[I915_CTXREG_STATE4] |= (ENABLE_STENCIL_TEST_MASK |
+ STENCIL_TEST_MASK(mask));
+
+ i915->state.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_REF_MASK |
+ S5_STENCIL_TEST_FUNC_MASK);
+
+ i915->state.Ctx[I915_CTXREG_LIS5] |= ((ref << S5_STENCIL_REF_SHIFT) |
+ (test << S5_STENCIL_TEST_FUNC_SHIFT));
+}
+
+static void i915StencilMask(GLcontext *ctx, GLuint mask)
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s : mask 0x%x\n", __FUNCTION__, mask);
+
+ mask = mask & 0xff;
+
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ i915->state.Ctx[I915_CTXREG_STATE4] &= ~MODE4_ENABLE_STENCIL_WRITE_MASK;
+ i915->state.Ctx[I915_CTXREG_STATE4] |= (ENABLE_STENCIL_WRITE_MASK |
+ STENCIL_WRITE_MASK(mask));
+}
+
+
+static void i915StencilOp(GLcontext *ctx, GLenum fail, GLenum zfail,
+ GLenum zpass)
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ int fop = intel_translate_stencil_op(fail);
+ int dfop = intel_translate_stencil_op(zfail);
+ int dpop = intel_translate_stencil_op(zpass);
+
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s: fail : %s, zfail: %s, zpass : %s\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(fail),
+ _mesa_lookup_enum_by_nr(zfail),
+ _mesa_lookup_enum_by_nr(zpass));
+
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+
+ i915->state.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_FAIL_MASK |
+ S5_STENCIL_PASS_Z_FAIL_MASK |
+ S5_STENCIL_PASS_Z_PASS_MASK);
+
+ i915->state.Ctx[I915_CTXREG_LIS5] |= ((fop << S5_STENCIL_FAIL_SHIFT) |
+ (dfop << S5_STENCIL_PASS_Z_FAIL_SHIFT) |
+ (dpop << S5_STENCIL_PASS_Z_PASS_SHIFT));
+}
+
+static void i915AlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ int test = intel_translate_compare_func( func );
+ GLubyte refByte;
+
+ UNCLAMPED_FLOAT_TO_UBYTE(refByte, ref);
+
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ i915->state.Ctx[I915_CTXREG_LIS6] &= ~(S6_ALPHA_TEST_FUNC_MASK |
+ S6_ALPHA_REF_MASK);
+ i915->state.Ctx[I915_CTXREG_LIS6] |= ((test << S6_ALPHA_TEST_FUNC_SHIFT) |
+ (((GLuint)refByte) << S6_ALPHA_REF_SHIFT));
+}
+
+/* This function makes sure that the proper enables are
+ * set for LogicOp, Independant Alpha Blend, and Blending.
+ * It needs to be called from numerous places where we
+ * could change the LogicOp or Independant Alpha Blend without subsequent
+ * calls to glEnable.
+ */
+static void i915EvalLogicOpBlendState(GLcontext *ctx)
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+
+ if (ctx->Color._LogicOpEnabled) {
+ i915->state.Ctx[I915_CTXREG_LIS5] |= S5_LOGICOP_ENABLE;
+ i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_CBUF_BLEND_ENABLE;
+ } else {
+ i915->state.Ctx[I915_CTXREG_LIS5] &= ~S5_LOGICOP_ENABLE;
+
+ if (ctx->Color.BlendEnabled) {
+ i915->state.Ctx[I915_CTXREG_LIS6] |= S6_CBUF_BLEND_ENABLE;
+ } else {
+ i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_CBUF_BLEND_ENABLE;
+ }
+ }
+}
+
+static void i915BlendColor(GLcontext *ctx, const GLfloat color[4])
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ GLubyte r, g, b, a;
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ UNCLAMPED_FLOAT_TO_UBYTE(r, color[RCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(g, color[GCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(b, color[BCOMP]);
+ UNCLAMPED_FLOAT_TO_UBYTE(a, color[ACOMP]);
+
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ i915->state.Ctx[I915_CTXREG_BLENDCOLOR1] = (a<<24) | (r<<16) | (g<<8) | b;
+}
+
+
+#define DST_BLND_FACT(f) ((f)<<S6_CBUF_DST_BLEND_FACT_SHIFT)
+#define SRC_BLND_FACT(f) ((f)<<S6_CBUF_SRC_BLEND_FACT_SHIFT)
+#define DST_ABLND_FACT(f) ((f)<<IAB_DST_FACTOR_SHIFT)
+#define SRC_ABLND_FACT(f) ((f)<<IAB_SRC_FACTOR_SHIFT)
+
+
+
+static GLuint translate_blend_equation( GLenum mode )
+{
+ switch (mode) {
+ case GL_FUNC_ADD: return BLENDFUNC_ADD;
+ case GL_MIN: return BLENDFUNC_MIN;
+ case GL_MAX: return BLENDFUNC_MAX;
+ case GL_FUNC_SUBTRACT: return BLENDFUNC_SUBTRACT;
+ case GL_FUNC_REVERSE_SUBTRACT: return BLENDFUNC_REVERSE_SUBTRACT;
+ default: return 0;
+ }
+}
+
+static void i915UpdateBlendState( GLcontext *ctx )
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ GLuint iab = (i915->state.Ctx[I915_CTXREG_IAB] &
+ ~(IAB_SRC_FACTOR_MASK |
+ IAB_DST_FACTOR_MASK |
+ (BLENDFUNC_MASK << IAB_FUNC_SHIFT) |
+ IAB_ENABLE));
+
+ GLuint lis6 = (i915->state.Ctx[I915_CTXREG_LIS6] &
+ ~(S6_CBUF_SRC_BLEND_FACT_MASK |
+ S6_CBUF_DST_BLEND_FACT_MASK |
+ S6_CBUF_BLEND_FUNC_MASK));
+
+ GLuint eqRGB = ctx->Color.BlendEquationRGB;
+ GLuint eqA = ctx->Color.BlendEquationA;
+ GLuint srcRGB = ctx->Color.BlendSrcRGB;
+ GLuint dstRGB = ctx->Color.BlendDstRGB;
+ GLuint srcA = ctx->Color.BlendSrcA;
+ GLuint dstA = ctx->Color.BlendDstA;
+
+ if (eqRGB == GL_MIN || eqRGB == GL_MAX) {
+ srcRGB = dstRGB = GL_ONE;
+ }
+
+ if (eqA == GL_MIN || eqA == GL_MAX) {
+ srcA = dstA = GL_ONE;
+ }
+
+ lis6 |= SRC_BLND_FACT(intel_translate_blend_factor(srcRGB));
+ lis6 |= DST_BLND_FACT(intel_translate_blend_factor(dstRGB));
+ lis6 |= translate_blend_equation( eqRGB ) << S6_CBUF_BLEND_FUNC_SHIFT;
+
+ iab |= SRC_ABLND_FACT(intel_translate_blend_factor(srcA));
+ iab |= DST_ABLND_FACT(intel_translate_blend_factor(dstA));
+ iab |= translate_blend_equation( eqA ) << IAB_FUNC_SHIFT;
+
+ if (srcA != srcRGB || dstA != dstRGB || eqA != eqRGB)
+ iab |= IAB_ENABLE;
+
+ if (iab != i915->state.Ctx[I915_CTXREG_IAB] ||
+ lis6 != i915->state.Ctx[I915_CTXREG_LIS6]) {
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ i915->state.Ctx[I915_CTXREG_IAB] = iab;
+ i915->state.Ctx[I915_CTXREG_LIS6] = lis6;
+ }
+
+ /* This will catch a logicop blend equation */
+ i915EvalLogicOpBlendState(ctx);
+}
+
+
+static void i915BlendFuncSeparate(GLcontext *ctx, GLenum srcRGB,
+ GLenum dstRGB, GLenum srcA,
+ GLenum dstA )
+{
+ i915UpdateBlendState( ctx );
+}
+
+
+static void i915BlendEquationSeparate(GLcontext *ctx, GLenum eqRGB,
+ GLenum eqA)
+{
+ i915UpdateBlendState( ctx );
+}
+
+
+static void i915DepthFunc(GLcontext *ctx, GLenum func)
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ int test = intel_translate_compare_func( func );
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_DEPTH_TEST_FUNC_MASK;
+ i915->state.Ctx[I915_CTXREG_LIS6] |= test << S6_DEPTH_TEST_FUNC_SHIFT;
+}
+
+static void i915DepthMask(GLcontext *ctx, GLboolean flag)
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s flag (%d)\n", __FUNCTION__, flag);
+
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+
+ if (flag && ctx->Depth.Test)
+ i915->state.Ctx[I915_CTXREG_LIS6] |= S6_DEPTH_WRITE_ENABLE;
+ else
+ i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_DEPTH_WRITE_ENABLE;
+}
+
+/* =============================================================
+ * Polygon stipple
+ *
+ * The i915 supports a 4x4 stipple natively, GL wants 32x32.
+ * Fortunately stipple is usually a repeating pattern.
+ */
+static void i915PolygonStipple( GLcontext *ctx, const GLubyte *mask )
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ const GLubyte *m = mask;
+ GLubyte p[4];
+ int i,j,k;
+ int active = (ctx->Polygon.StippleFlag &&
+ i915->intel.reduced_primitive == GL_TRIANGLES);
+ GLuint newMask;
+
+ if (active) {
+ I915_STATECHANGE(i915, I915_UPLOAD_STIPPLE);
+ i915->state.Stipple[I915_STPREG_ST1] &= ~ST1_ENABLE;
+ }
+
+ p[0] = mask[12] & 0xf; p[0] |= p[0] << 4;
+ p[1] = mask[8] & 0xf; p[1] |= p[1] << 4;
+ p[2] = mask[4] & 0xf; p[2] |= p[2] << 4;
+ p[3] = mask[0] & 0xf; p[3] |= p[3] << 4;
+
+ for (k = 0 ; k < 8 ; k++)
+ for (j = 3 ; j >= 0; j--)
+ for (i = 0 ; i < 4 ; i++, m++)
+ if (*m != p[j]) {
+ i915->intel.hw_stipple = 0;
+ return;
+ }
+
+ newMask = (((p[0] & 0xf) << 0) |
+ ((p[1] & 0xf) << 4) |
+ ((p[2] & 0xf) << 8) |
+ ((p[3] & 0xf) << 12));
+
+
+ if (newMask == 0xffff || newMask == 0x0) {
+ /* this is needed to make conform pass */
+ i915->intel.hw_stipple = 0;
+ return;
+ }
+
+ i915->state.Stipple[I915_STPREG_ST1] &= ~0xffff;
+ i915->state.Stipple[I915_STPREG_ST1] |= newMask;
+ i915->intel.hw_stipple = 1;
+
+ if (active)
+ i915->state.Stipple[I915_STPREG_ST1] |= ST1_ENABLE;
+}
+
+
+/* =============================================================
+ * Hardware clipping
+ */
+static void i915Scissor(GLcontext *ctx, GLint x, GLint y,
+ GLsizei w, GLsizei h)
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ intelScreenPrivate *screen = i915->intel.intelScreen;
+ int x1, y1, x2, y2;
+
+ if (!i915->intel.driDrawable)
+ return;
+
+ x1 = x;
+ y1 = i915->intel.driDrawable->h - (y + h);
+ x2 = x + w - 1;
+ y2 = y1 + h - 1;
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "[%s] x(%d) y(%d) w(%d) h(%d)\n", __FUNCTION__,
+ x, y, w, h);
+
+ if (x1 < 0) x1 = 0;
+ if (y1 < 0) y1 = 0;
+ if (x2 < 0) x2 = 0;
+ if (y2 < 0) y2 = 0;
+
+ if (x2 >= screen->width) x2 = screen->width-1;
+ if (y2 >= screen->height) y2 = screen->height-1;
+ if (x1 >= screen->width) x1 = screen->width-1;
+ if (y1 >= screen->height) y1 = screen->height-1;
+
+
+ I915_STATECHANGE(i915, I915_UPLOAD_BUFFERS);
+ i915->state.Buffer[I915_DESTREG_SR1] = (y1 << 16) | (x1 & 0xffff);
+ i915->state.Buffer[I915_DESTREG_SR2] = (y2 << 16) | (x2 & 0xffff);
+}
+
+static void i915LogicOp(GLcontext *ctx, GLenum opcode)
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ int tmp = intel_translate_logic_op(opcode);
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ i915->state.Ctx[I915_CTXREG_STATE4] &= ~LOGICOP_MASK;
+ i915->state.Ctx[I915_CTXREG_STATE4] |= LOGIC_OP_FUNC(tmp);
+}
+
+
+
+static void i915CullFaceFrontFace(GLcontext *ctx, GLenum unused)
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ GLuint mode;
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (!ctx->Polygon.CullFlag) {
+ mode = S4_CULLMODE_NONE;
+ }
+ else if (ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK) {
+ mode = S4_CULLMODE_CW;
+
+ if (ctx->Polygon.CullFaceMode == GL_FRONT)
+ mode ^= (S4_CULLMODE_CW ^ S4_CULLMODE_CCW);
+ if (ctx->Polygon.FrontFace != GL_CCW)
+ mode ^= (S4_CULLMODE_CW ^ S4_CULLMODE_CCW);
+ }
+ else {
+ mode = S4_CULLMODE_BOTH;
+ }
+
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ i915->state.Ctx[I915_CTXREG_LIS4] &= ~S4_CULLMODE_MASK;
+ i915->state.Ctx[I915_CTXREG_LIS4] |= mode;
+}
+
+static void i915LineWidth( GLcontext *ctx, GLfloat widthf )
+{
+ i915ContextPtr i915 = I915_CONTEXT( ctx );
+ int lis4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_LINE_WIDTH_MASK;
+ int width;
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ width = (int)(widthf * 2);
+ CLAMP_SELF(width, 1, 0xf);
+ lis4 |= width << S4_LINE_WIDTH_SHIFT;
+
+ if (lis4 != i915->state.Ctx[I915_CTXREG_LIS4]) {
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ i915->state.Ctx[I915_CTXREG_LIS4] = lis4;
+ }
+}
+
+static void i915PointSize(GLcontext *ctx, GLfloat size)
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ int lis4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_POINT_WIDTH_MASK;
+ GLint point_size = (int)size;
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ CLAMP_SELF(point_size, 1, 255);
+ lis4 |= point_size << S4_POINT_WIDTH_SHIFT;
+
+ if (lis4 != i915->state.Ctx[I915_CTXREG_LIS4]) {
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ i915->state.Ctx[I915_CTXREG_LIS4] = lis4;
+ }
+}
+
+
+/* =============================================================
+ * Color masks
+ */
+
+static void i915ColorMask(GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a)
+{
+ i915ContextPtr i915 = I915_CONTEXT( ctx );
+ GLuint tmp = i915->state.Ctx[I915_CTXREG_LIS5] & ~S5_WRITEDISABLE_MASK;
+
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s r(%d) g(%d) b(%d) a(%d)\n", __FUNCTION__, r, g, b, a);
+
+ if (!r) tmp |= S5_WRITEDISABLE_RED;
+ if (!g) tmp |= S5_WRITEDISABLE_GREEN;
+ if (!b) tmp |= S5_WRITEDISABLE_BLUE;
+ if (!a) tmp |= S5_WRITEDISABLE_ALPHA;
+
+ if (tmp != i915->state.Ctx[I915_CTXREG_LIS5]) {
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ i915->state.Ctx[I915_CTXREG_LIS5] = tmp;
+ }
+}
+
+static void update_specular( GLcontext *ctx )
+{
+ /* A hack to trigger the rebuild of the fragment program.
+ */
+ INTEL_CONTEXT(ctx)->NewGLState |= _NEW_TEXTURE;
+ I915_CONTEXT(ctx)->tex_program.translated = 0;
+}
+
+static void i915LightModelfv(GLcontext *ctx, GLenum pname,
+ const GLfloat *param)
+{
+ if (INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) {
+ update_specular( ctx );
+ }
+}
+
+static void i915ShadeModel(GLcontext *ctx, GLenum mode)
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+
+ if (mode == GL_SMOOTH) {
+ i915->state.Ctx[I915_CTXREG_LIS4] &= ~(S4_FLATSHADE_ALPHA |
+ S4_FLATSHADE_COLOR |
+ S4_FLATSHADE_SPECULAR);
+ } else {
+ i915->state.Ctx[I915_CTXREG_LIS4] |= (S4_FLATSHADE_ALPHA |
+ S4_FLATSHADE_COLOR |
+ S4_FLATSHADE_SPECULAR);
+ }
+}
+
+/* =============================================================
+ * Fog
+ */
+void i915_update_fog( GLcontext *ctx )
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ GLenum mode;
+ GLboolean enabled;
+ GLboolean try_pixel_fog;
+
+ if (ctx->FragmentProgram._Active) {
+ /* Pull in static fog state from program */
+
+ mode = ctx->FragmentProgram._Current->FogOption;
+ enabled = (mode != GL_NONE);
+ try_pixel_fog = 0;
+ }
+ else {
+ enabled = ctx->Fog.Enabled;
+ mode = ctx->Fog.Mode;
+
+ try_pixel_fog = (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT &&
+ ctx->Hint.Fog == GL_NICEST &&
+ 0); /* XXX - DISABLE -- Need ortho fallback */
+ }
+
+ if (!enabled) {
+ i915->vertex_fog = I915_FOG_NONE;
+ }
+ else if (try_pixel_fog) {
+
+ I915_STATECHANGE(i915, I915_UPLOAD_FOG);
+ i915->state.Fog[I915_FOGREG_MODE1] &= ~FMC1_FOGFUNC_MASK;
+ i915->vertex_fog = I915_FOG_PIXEL;
+
+ switch (mode) {
+ case GL_LINEAR:
+ if (ctx->Fog.End <= ctx->Fog.Start) {
+ /* XXX - this won't work with fragment programs. Need to
+ * either fallback or append fog instructions to end of
+ * program in the case of linear fog.
+ */
+ i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_VERTEX;
+ i915->vertex_fog = I915_FOG_VERTEX;
+ }
+ else {
+ GLfloat c1 = ctx->Fog.End/(ctx->Fog.End-ctx->Fog.Start);
+ GLfloat c2 = 1.0/(ctx->Fog.End-ctx->Fog.Start);
+
+ i915->state.Fog[I915_FOGREG_MODE1] &= ~FMC1_C1_MASK;
+ i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_PIXEL_LINEAR;
+ i915->state.Fog[I915_FOGREG_MODE1] |=
+ ((GLuint)(c1 * FMC1_C1_ONE)) & FMC1_C1_MASK;
+
+ if (i915->state.Fog[I915_FOGREG_MODE1] & FMC1_FOGINDEX_Z) {
+ i915->state.Fog[I915_FOGREG_MODE2] = (GLuint)(c2 * FMC2_C2_ONE);
+ }
+ else {
+ union { float f; int i; } fi;
+ fi.f = c2;
+ i915->state.Fog[I915_FOGREG_MODE2] = fi.i;
+ }
+ }
+ break;
+ case GL_EXP:
+ i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_PIXEL_EXP;
+ break;
+ case GL_EXP2:
+ i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_PIXEL_EXP2;
+ break;
+ default:
+ break;
+ }
+ }
+ else /* if (i915->vertex_fog != I915_FOG_VERTEX) */ {
+ I915_STATECHANGE(i915, I915_UPLOAD_FOG);
+ i915->state.Fog[I915_FOGREG_MODE1] &= ~FMC1_FOGFUNC_MASK;
+ i915->state.Fog[I915_FOGREG_MODE1] |= FMC1_FOGFUNC_VERTEX;
+ i915->vertex_fog = I915_FOG_VERTEX;
+ }
+
+ {
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ I915_ACTIVESTATE(i915, I915_UPLOAD_FOG, enabled);
+ if (enabled)
+ i915->state.Ctx[I915_CTXREG_LIS5] |= S5_FOG_ENABLE;
+ else
+ i915->state.Ctx[I915_CTXREG_LIS5] &= ~S5_FOG_ENABLE;
+ }
+
+ if (enabled) {
+ _tnl_allow_vertex_fog( ctx, (i915->vertex_fog == I915_FOG_VERTEX) );
+ _tnl_allow_pixel_fog( ctx, (i915->vertex_fog != I915_FOG_VERTEX) );
+ }
+}
+
+static void i915Fogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+
+ switch (pname) {
+ case GL_FOG_COORDINATE_SOURCE_EXT:
+ case GL_FOG_MODE:
+ case GL_FOG_START:
+ case GL_FOG_END:
+ break;
+
+ case GL_FOG_DENSITY:
+ I915_STATECHANGE(i915, I915_UPLOAD_FOG);
+
+ if (i915->state.Fog[I915_FOGREG_MODE1] & FMC1_FOGINDEX_Z) {
+ i915->state.Fog[I915_FOGREG_MODE3] = (GLuint)(ctx->Fog.Density *
+ FMC3_D_ONE);
+ }
+ else {
+ union { float f; int i; } fi;
+ fi.f = ctx->Fog.Density;
+ i915->state.Fog[I915_FOGREG_MODE3] = fi.i;
+ }
+ break;
+
+ case GL_FOG_COLOR:
+ I915_STATECHANGE(i915, I915_UPLOAD_FOG);
+ i915->state.Fog[I915_FOGREG_COLOR] =
+ (_3DSTATE_FOG_COLOR_CMD |
+ ((GLubyte)(ctx->Fog.Color[0]*255.0F) << 16) |
+ ((GLubyte)(ctx->Fog.Color[1]*255.0F) << 8) |
+ ((GLubyte)(ctx->Fog.Color[2]*255.0F) << 0));
+ break;
+
+ default:
+ break;
+ }
+}
+
+static void i915Hint(GLcontext *ctx, GLenum target, GLenum state)
+{
+ switch (target) {
+ case GL_FOG_HINT:
+ break;
+ default:
+ break;
+ }
+}
+
+/* =============================================================
+ */
+
+static void i915Enable(GLcontext *ctx, GLenum cap, GLboolean state)
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+
+ switch(cap) {
+ case GL_TEXTURE_2D:
+ break;
+
+ case GL_LIGHTING:
+ case GL_COLOR_SUM:
+ update_specular( ctx );
+ break;
+
+ case GL_ALPHA_TEST:
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ if (state)
+ i915->state.Ctx[I915_CTXREG_LIS6] |= S6_ALPHA_TEST_ENABLE;
+ else
+ i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_ALPHA_TEST_ENABLE;
+ break;
+
+ case GL_BLEND:
+ i915EvalLogicOpBlendState(ctx);
+ break;
+
+ case GL_COLOR_LOGIC_OP:
+ i915EvalLogicOpBlendState(ctx);
+
+ /* Logicop doesn't seem to work at 16bpp:
+ */
+ if (i915->intel.intelScreen->cpp == 2)
+ FALLBACK( &i915->intel, I915_FALLBACK_LOGICOP, state );
+ break;
+
+ case GL_FRAGMENT_PROGRAM_ARB:
+ break;
+
+ case GL_DITHER:
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ if (state)
+ i915->state.Ctx[I915_CTXREG_LIS5] |= S5_COLOR_DITHER_ENABLE;
+ else
+ i915->state.Ctx[I915_CTXREG_LIS5] &= ~S5_COLOR_DITHER_ENABLE;
+ break;
+
+ case GL_DEPTH_TEST:
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ if (state)
+ i915->state.Ctx[I915_CTXREG_LIS6] |= S6_DEPTH_TEST_ENABLE;
+ else
+ i915->state.Ctx[I915_CTXREG_LIS6] &= ~S6_DEPTH_TEST_ENABLE;
+
+ i915DepthMask( ctx, ctx->Depth.Mask );
+ break;
+
+ case GL_SCISSOR_TEST:
+ I915_STATECHANGE(i915, I915_UPLOAD_BUFFERS);
+ if (state)
+ i915->state.Buffer[I915_DESTREG_SENABLE] = (_3DSTATE_SCISSOR_ENABLE_CMD |
+ ENABLE_SCISSOR_RECT);
+ else
+ i915->state.Buffer[I915_DESTREG_SENABLE] = (_3DSTATE_SCISSOR_ENABLE_CMD |
+ DISABLE_SCISSOR_RECT);
+ break;
+
+ case GL_LINE_SMOOTH:
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ if (state)
+ i915->state.Ctx[I915_CTXREG_LIS4] |= S4_LINE_ANTIALIAS_ENABLE;
+ else
+ i915->state.Ctx[I915_CTXREG_LIS4] &= ~S4_LINE_ANTIALIAS_ENABLE;
+ break;
+
+ case GL_FOG:
+ break;
+
+ case GL_CULL_FACE:
+ i915CullFaceFrontFace(ctx, 0);
+ break;
+
+ case GL_STENCIL_TEST:
+ if (i915->intel.hw_stencil) {
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ if (state)
+ i915->state.Ctx[I915_CTXREG_LIS5] |= (S5_STENCIL_TEST_ENABLE |
+ S5_STENCIL_WRITE_ENABLE);
+ else
+ i915->state.Ctx[I915_CTXREG_LIS5] &= ~(S5_STENCIL_TEST_ENABLE |
+ S5_STENCIL_WRITE_ENABLE);
+ } else {
+ FALLBACK( &i915->intel, I915_FALLBACK_STENCIL, state );
+ }
+ break;
+
+ case GL_POLYGON_STIPPLE:
+ /* The stipple command worked on my 855GM box, but not my 845G.
+ * I'll do more testing later to find out exactly which hardware
+ * supports it. Disabled for now.
+ */
+ if (i915->intel.hw_stipple &&
+ i915->intel.reduced_primitive == GL_TRIANGLES)
+ {
+ I915_STATECHANGE(i915, I915_UPLOAD_STIPPLE);
+ if (state)
+ i915->state.Stipple[I915_STPREG_ST1] |= ST1_ENABLE;
+ else
+ i915->state.Stipple[I915_STPREG_ST1] &= ~ST1_ENABLE;
+ }
+ break;
+
+ default:
+ ;
+ }
+}
+
+
+static void i915_init_packets( i915ContextPtr i915 )
+{
+ intelScreenPrivate *screen = i915->intel.intelScreen;
+
+ /* Zero all state */
+ memset(&i915->state, 0, sizeof(i915->state));
+
+
+ {
+ I915_STATECHANGE(i915, I915_UPLOAD_CTX);
+ /* Probably don't want to upload all this stuff every time one
+ * piece changes.
+ */
+ i915->state.Ctx[I915_CTXREG_LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
+ I1_LOAD_S(2) |
+ I1_LOAD_S(4) |
+ I1_LOAD_S(5) |
+ I1_LOAD_S(6) |
+ (4));
+ i915->state.Ctx[I915_CTXREG_LIS2] = 0;
+ i915->state.Ctx[I915_CTXREG_LIS4] = 0;
+ i915->state.Ctx[I915_CTXREG_LIS5] = 0;
+
+ if (screen->cpp == 2)
+ i915->state.Ctx[I915_CTXREG_LIS5] |= S5_COLOR_DITHER_ENABLE;
+
+
+ i915->state.Ctx[I915_CTXREG_LIS6] = (S6_COLOR_WRITE_ENABLE |
+ (2 << S6_TRISTRIP_PV_SHIFT));
+
+ i915->state.Ctx[I915_CTXREG_STATE4] = (_3DSTATE_MODES_4_CMD |
+ ENABLE_LOGIC_OP_FUNC |
+ LOGIC_OP_FUNC(LOGICOP_COPY) |
+ ENABLE_STENCIL_TEST_MASK |
+ STENCIL_TEST_MASK(0xff) |
+ ENABLE_STENCIL_WRITE_MASK |
+ STENCIL_WRITE_MASK(0xff));
+
+
+ i915->state.Ctx[I915_CTXREG_IAB] = (_3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD |
+ IAB_MODIFY_ENABLE |
+ IAB_MODIFY_FUNC |
+ IAB_MODIFY_SRC_FACTOR |
+ IAB_MODIFY_DST_FACTOR);
+
+ i915->state.Ctx[I915_CTXREG_BLENDCOLOR0] = _3DSTATE_CONST_BLEND_COLOR_CMD;
+ i915->state.Ctx[I915_CTXREG_BLENDCOLOR1] = 0;
+
+ }
+
+ {
+ I915_STATECHANGE(i915, I915_UPLOAD_STIPPLE);
+ i915->state.Stipple[I915_STPREG_ST0] = _3DSTATE_STIPPLE;
+ }
+
+
+ {
+ I915_STATECHANGE(i915, I915_UPLOAD_FOG);
+ i915->state.Fog[I915_FOGREG_MODE0] = _3DSTATE_FOG_MODE_CMD;
+ i915->state.Fog[I915_FOGREG_MODE1] = (FMC1_FOGFUNC_MODIFY_ENABLE |
+ FMC1_FOGFUNC_VERTEX |
+ FMC1_FOGINDEX_MODIFY_ENABLE |
+ FMC1_FOGINDEX_W |
+ FMC1_C1_C2_MODIFY_ENABLE |
+ FMC1_DENSITY_MODIFY_ENABLE);
+ i915->state.Fog[I915_FOGREG_COLOR] = _3DSTATE_FOG_COLOR_CMD;
+ }
+
+
+ {
+ I915_STATECHANGE(i915, I915_UPLOAD_BUFFERS);
+ i915->state.Buffer[I915_DESTREG_CBUFADDR0] = _3DSTATE_BUF_INFO_CMD;
+ i915->state.Buffer[I915_DESTREG_CBUFADDR1] =
+ (BUF_3D_ID_COLOR_BACK |
+ BUF_3D_PITCH(screen->frontPitch * screen->cpp) |
+ BUF_3D_USE_FENCE);
+
+
+ i915->state.Buffer[I915_DESTREG_DBUFADDR0] = _3DSTATE_BUF_INFO_CMD;
+ i915->state.Buffer[I915_DESTREG_DBUFADDR1] =
+ (BUF_3D_ID_DEPTH |
+ BUF_3D_PITCH(screen->depthPitch * screen->cpp) |
+ BUF_3D_USE_FENCE);
+ i915->state.Buffer[I915_DESTREG_DBUFADDR2] = screen->depthOffset;
+
+
+ i915->state.Buffer[I915_DESTREG_DV0] = _3DSTATE_DST_BUF_VARS_CMD;
+
+ switch (screen->fbFormat) {
+ case DV_PF_555:
+ case DV_PF_565:
+ i915->state.Buffer[I915_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */
+ DSTORG_VERT_BIAS(0x8) | /* .5 */
+ LOD_PRECLAMP_OGL |
+ TEX_DEFAULT_COLOR_OGL |
+ DITHER_FULL_ALWAYS |
+ screen->fbFormat |
+ DEPTH_FRMT_16_FIXED);
+ break;
+ case DV_PF_8888:
+ i915->state.Buffer[I915_DESTREG_DV1] = (DSTORG_HORT_BIAS(0x8) | /* .5 */
+ DSTORG_VERT_BIAS(0x8) | /* .5 */
+ LOD_PRECLAMP_OGL |
+ TEX_DEFAULT_COLOR_OGL |
+ screen->fbFormat |
+ DEPTH_FRMT_24_FIXED_8_OTHER);
+ break;
+ }
+ i915->state.Buffer[I915_DESTREG_SENABLE] = (_3DSTATE_SCISSOR_ENABLE_CMD |
+ DISABLE_SCISSOR_RECT);
+ i915->state.Buffer[I915_DESTREG_SR0] = _3DSTATE_SCISSOR_RECT_0_CMD;
+ i915->state.Buffer[I915_DESTREG_SR1] = 0;
+ i915->state.Buffer[I915_DESTREG_SR2] = 0;
+ }
+
+
+ /* These will be emitted every at the head of every buffer, unless
+ * we get hardware contexts working.
+ */
+ i915->state.active = (I915_UPLOAD_PROGRAM |
+ I915_UPLOAD_STIPPLE |
+ I915_UPLOAD_CTX |
+ I915_UPLOAD_BUFFERS);
+}
+
+void i915InitStateFunctions( struct dd_function_table *functions )
+{
+ functions->AlphaFunc = i915AlphaFunc;
+ functions->BlendColor = i915BlendColor;
+ functions->BlendEquationSeparate = i915BlendEquationSeparate;
+ functions->BlendFuncSeparate = i915BlendFuncSeparate;
+ functions->ColorMask = i915ColorMask;
+ functions->CullFace = i915CullFaceFrontFace;
+ functions->DepthFunc = i915DepthFunc;
+ functions->DepthMask = i915DepthMask;
+ functions->Enable = i915Enable;
+ functions->Fogfv = i915Fogfv;
+ functions->FrontFace = i915CullFaceFrontFace;
+ functions->Hint = i915Hint;
+ functions->LightModelfv = i915LightModelfv;
+ functions->LineWidth = i915LineWidth;
+ functions->LogicOpcode = i915LogicOp;
+ functions->PointSize = i915PointSize;
+ functions->PolygonStipple = i915PolygonStipple;
+ functions->Scissor = i915Scissor;
+ functions->ShadeModel = i915ShadeModel;
+ functions->StencilFunc = i915StencilFunc;
+ functions->StencilMask = i915StencilMask;
+ functions->StencilOp = i915StencilOp;
+}
+
+
+void i915InitState( i915ContextPtr i915 )
+{
+ GLcontext *ctx = &i915->intel.ctx;
+
+ i915_init_packets( i915 );
+
+ intelInitState( ctx );
+
+ memcpy( &i915->initial, &i915->state, sizeof(i915->state) );
+ i915->current = &i915->state;
+}
+
+
+
+
+
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_tex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_tex.c
new file mode 100644
index 000000000..4f77833e1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_tex.c
@@ -0,0 +1,182 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "imports.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "image.h"
+#include "texstore.h"
+#include "texformat.h"
+#include "texmem.h"
+#include "swrast/swrast.h"
+
+#include "mm.h"
+
+#include "intel_ioctl.h"
+
+#include "i915_context.h"
+#include "i915_reg.h"
+
+
+
+
+
+
+/**
+ * Allocate space for and load the mesa images into the texture memory block.
+ * This will happen before drawing with a new texture, or drawing with a
+ * texture after it was swapped out or teximaged again.
+ */
+
+intelTextureObjectPtr i915AllocTexObj( struct gl_texture_object *texObj )
+{
+ i915TextureObjectPtr t = CALLOC_STRUCT( i915_texture_object );
+ if ( !t )
+ return NULL;
+
+ texObj->DriverData = t;
+ t->intel.base.tObj = texObj;
+ t->intel.dirty = I915_UPLOAD_TEX_ALL;
+ make_empty_list( &t->intel.base );
+ return &t->intel;
+}
+
+
+static void i915TexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat *params )
+{
+ i915TextureObjectPtr t = (i915TextureObjectPtr) tObj->DriverData;
+
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ case GL_TEXTURE_WRAP_R:
+ case GL_TEXTURE_BORDER_COLOR:
+ t->intel.dirty = I915_UPLOAD_TEX_ALL;
+ break;
+
+ case GL_TEXTURE_COMPARE_MODE:
+ t->intel.dirty = I915_UPLOAD_TEX_ALL;
+ break;
+ case GL_TEXTURE_COMPARE_FUNC:
+ t->intel.dirty = I915_UPLOAD_TEX_ALL;
+ break;
+
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ /* The i915 and its successors can do a lot of this without
+ * reloading the textures. A project for someone?
+ */
+ intelFlush( ctx );
+ driSwapOutTextureObject( (driTextureObject *) t );
+ t->intel.dirty = I915_UPLOAD_TEX_ALL;
+ break;
+
+ default:
+ return;
+ }
+}
+
+
+static void i915TexEnv( GLcontext *ctx, GLenum target,
+ GLenum pname, const GLfloat *param )
+{
+ i915ContextPtr i915 = I915_CONTEXT( ctx );
+ GLuint unit = ctx->Texture.CurrentUnit;
+
+ switch (pname) {
+ case GL_TEXTURE_ENV_COLOR: /* Should be a tracked param */
+ case GL_TEXTURE_ENV_MODE:
+ case GL_COMBINE_RGB:
+ case GL_COMBINE_ALPHA:
+ case GL_SOURCE0_RGB:
+ case GL_SOURCE1_RGB:
+ case GL_SOURCE2_RGB:
+ case GL_SOURCE0_ALPHA:
+ case GL_SOURCE1_ALPHA:
+ case GL_SOURCE2_ALPHA:
+ case GL_OPERAND0_RGB:
+ case GL_OPERAND1_RGB:
+ case GL_OPERAND2_RGB:
+ case GL_OPERAND0_ALPHA:
+ case GL_OPERAND1_ALPHA:
+ case GL_OPERAND2_ALPHA:
+ case GL_RGB_SCALE:
+ case GL_ALPHA_SCALE:
+ i915->tex_program.translated = 0;
+ break;
+
+ case GL_TEXTURE_LOD_BIAS: {
+ int b = (int) ((*param) * 16.0);
+ if (b > 255) b = 255;
+ if (b < -256) b = -256;
+ I915_STATECHANGE(i915, I915_UPLOAD_TEX(unit));
+ i915->state.Tex[unit][I915_TEXREG_SS2] &= ~SS2_LOD_BIAS_MASK;
+ i915->state.Tex[unit][I915_TEXREG_SS2] |=
+ ((b << SS2_LOD_BIAS_SHIFT) & SS2_LOD_BIAS_MASK);
+ break;
+ }
+
+ default:
+ break;
+ }
+}
+
+
+static void i915BindTexture( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj )
+{
+ i915TextureObjectPtr tex = (i915TextureObjectPtr)texObj->DriverData;
+
+ if (tex->lastTarget != texObj->Target) {
+ tex->intel.dirty = I915_UPLOAD_TEX_ALL;
+ tex->lastTarget = texObj->Target;
+ }
+
+ /* Need this if image format changes between bound textures.
+ * Could try and shortcircuit by checking for differences in
+ * state between incoming and outgoing textures:
+ */
+ I915_CONTEXT(ctx)->tex_program.translated = 0;
+}
+
+
+
+void i915InitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->BindTexture = i915BindTexture;
+ functions->TexEnv = i915TexEnv;
+ functions->TexParameter = i915TexParameter;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_texprog.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_texprog.c
new file mode 100644
index 000000000..3eaf53d7d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_texprog.c
@@ -0,0 +1,668 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include <strings.h>
+
+#include "glheader.h"
+#include "macros.h"
+#include "enums.h"
+
+#include "tnl/t_context.h"
+#include "intel_batchbuffer.h"
+
+#include "i915_reg.h"
+#include "i915_context.h"
+#include "i915_program.h"
+
+static GLuint translate_tex_src_bit( struct i915_fragment_program *p,
+ GLubyte bit )
+{
+ switch (bit) {
+ case TEXTURE_1D_BIT: return D0_SAMPLE_TYPE_2D;
+ case TEXTURE_2D_BIT: return D0_SAMPLE_TYPE_2D;
+ case TEXTURE_RECT_BIT: return D0_SAMPLE_TYPE_2D;
+ case TEXTURE_3D_BIT: return D0_SAMPLE_TYPE_VOLUME;
+ case TEXTURE_CUBE_BIT: return D0_SAMPLE_TYPE_CUBE;
+ default: i915_program_error(p, "TexSrcBit"); return 0;
+ }
+}
+
+static GLuint get_source( struct i915_fragment_program *p,
+ GLenum src, GLuint unit )
+{
+ switch (src) {
+ case GL_TEXTURE:
+ if (p->src_texture == UREG_BAD) {
+
+ /* TODO: Use D0_CHANNEL_XY where possible.
+ */
+ GLuint dim = translate_tex_src_bit( p, p->ctx->Texture.Unit[unit]._ReallyEnabled);
+ GLuint sampler = i915_emit_decl(p, REG_TYPE_S, unit, dim);
+ GLuint texcoord = i915_emit_decl(p, REG_TYPE_T, unit, D0_CHANNEL_ALL);
+ GLuint tmp = i915_get_temp( p );
+ GLuint op = T0_TEXLD;
+
+ if (p->VB->TexCoordPtr[unit]->size == 4)
+ op = T0_TEXLDP;
+
+ p->src_texture = i915_emit_texld( p, tmp, A0_DEST_CHANNEL_ALL,
+ sampler, texcoord, op );
+ }
+
+ return p->src_texture;
+
+ /* Crossbar: */
+ case GL_TEXTURE0:
+ case GL_TEXTURE1:
+ case GL_TEXTURE2:
+ case GL_TEXTURE3:
+ case GL_TEXTURE4:
+ case GL_TEXTURE5:
+ case GL_TEXTURE6:
+ case GL_TEXTURE7: {
+ return UREG_BAD;
+ }
+
+ case GL_CONSTANT:
+ return i915_emit_const4fv( p, p->ctx->Texture.Unit[unit].EnvColor );
+ case GL_PRIMARY_COLOR:
+ return i915_emit_decl(p, REG_TYPE_T, T_DIFFUSE, D0_CHANNEL_ALL);
+ case GL_PREVIOUS:
+ default:
+ i915_emit_decl(p,
+ GET_UREG_TYPE(p->src_previous),
+ GET_UREG_NR(p->src_previous), D0_CHANNEL_ALL);
+ return p->src_previous;
+ }
+}
+
+
+static GLuint emit_combine_source( struct i915_fragment_program *p,
+ GLuint mask,
+ GLuint unit,
+ GLenum source,
+ GLenum operand )
+{
+ GLuint arg, src;
+
+ src = get_source(p, source, unit);
+
+ switch (operand) {
+ case GL_ONE_MINUS_SRC_COLOR:
+ /* Get unused tmp,
+ * Emit tmp = 1.0 + arg.-x-y-z-w
+ */
+ arg = i915_get_temp( p );
+ return i915_emit_arith( p, A0_ADD, arg, mask, 0,
+ swizzle(src, ONE, ONE, ONE, ONE ),
+ negate(src, 1,1,1,1), 0);
+
+ case GL_SRC_ALPHA:
+ if (mask == A0_DEST_CHANNEL_W)
+ return src;
+ else
+ return swizzle( src, W, W, W, W );
+ case GL_ONE_MINUS_SRC_ALPHA:
+ /* Get unused tmp,
+ * Emit tmp = 1.0 + arg.-w-w-w-w
+ */
+ arg = i915_get_temp( p );
+ return i915_emit_arith( p, A0_ADD, arg, mask, 0,
+ swizzle(src, ONE, ONE, ONE, ONE ),
+ negate( swizzle(src,W,W,W,W), 1,1,1,1), 0);
+ case GL_SRC_COLOR:
+ default:
+ return src;
+ }
+}
+
+
+
+static int nr_args( GLenum mode )
+{
+ switch (mode) {
+ case GL_REPLACE: return 1;
+ case GL_MODULATE: return 2;
+ case GL_ADD: return 2;
+ case GL_ADD_SIGNED: return 2;
+ case GL_INTERPOLATE: return 3;
+ case GL_SUBTRACT: return 2;
+ case GL_DOT3_RGB_EXT: return 2;
+ case GL_DOT3_RGBA_EXT: return 2;
+ case GL_DOT3_RGB: return 2;
+ case GL_DOT3_RGBA: return 2;
+ default: return 0;
+ }
+}
+
+
+static GLboolean args_match( struct gl_texture_unit *texUnit )
+{
+ int i, nr = nr_args(texUnit->Combine.ModeRGB);
+
+ for (i = 0 ; i < nr ; i++) {
+ if (texUnit->Combine.SourceA[i] != texUnit->Combine.SourceRGB[i])
+ return GL_FALSE;
+
+ switch(texUnit->Combine.OperandA[i]) {
+ case GL_SRC_ALPHA:
+ switch(texUnit->Combine.OperandRGB[i]) {
+ case GL_SRC_COLOR:
+ case GL_SRC_ALPHA:
+ break;
+ default:
+ return GL_FALSE;
+ }
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ switch(texUnit->Combine.OperandRGB[i]) {
+ case GL_ONE_MINUS_SRC_COLOR:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ break;
+ default:
+ return GL_FALSE;
+ }
+ break;
+ default:
+ return GL_FALSE; /* impossible */
+ }
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLuint emit_combine( struct i915_fragment_program *p,
+ GLuint dest,
+ GLuint mask,
+ GLuint saturate,
+ GLuint unit,
+ GLenum mode,
+ const GLenum *source,
+ const GLenum *operand)
+{
+ int tmp, src[3], nr = nr_args(mode);
+ int i;
+
+ for (i = 0; i < nr; i++)
+ src[i] = emit_combine_source( p, mask, unit, source[i], operand[i] );
+
+ switch (mode) {
+ case GL_REPLACE:
+ if (mask == A0_DEST_CHANNEL_ALL && !saturate)
+ return src[0];
+ else
+ return i915_emit_arith( p, A0_MOV, dest, mask, saturate, src[0], 0, 0 );
+ case GL_MODULATE:
+ return i915_emit_arith( p, A0_MUL, dest, mask, saturate,
+ src[0], src[1], 0 );
+ case GL_ADD:
+ return i915_emit_arith( p, A0_ADD, dest, mask, saturate,
+ src[0], src[1], 0 );
+ case GL_ADD_SIGNED:
+ /* tmp = arg0 + arg1
+ * result = tmp + -.5
+ */
+ tmp = i915_emit_const1f(p, .5);
+ tmp = negate(swizzle(tmp,X,X,X,X),1,1,1,1);
+ i915_emit_arith( p, A0_ADD, dest, mask, 0, src[0], src[1], 0 );
+ i915_emit_arith( p, A0_ADD, dest, mask, saturate, dest, tmp, 0 );
+ return dest;
+ case GL_INTERPOLATE: /* TWO INSTRUCTIONS */
+ /* Arg0 * (Arg2) + Arg1 * (1-Arg2)
+ *
+ * Arg0*Arg2 + Arg1 - Arg1Arg2
+ *
+ * tmp = Arg0*Arg2 + Arg1,
+ * result = (-Arg1)Arg2 + tmp
+ */
+ tmp = i915_get_temp( p );
+ i915_emit_arith( p, A0_MAD, tmp, mask, 0, src[0], src[2], src[1] );
+ i915_emit_arith( p, A0_MAD, dest, mask, saturate,
+ negate(src[1], 1,1,1,1), src[2], tmp );
+ return dest;
+ case GL_SUBTRACT:
+ /* negate src[1] */
+ return i915_emit_arith( p, A0_ADD, dest, mask, saturate, src[0],
+ negate(src[1],1,1,1,1), 0 );
+
+ case GL_DOT3_RGBA:
+ case GL_DOT3_RGBA_EXT:
+ case GL_DOT3_RGB_EXT:
+ case GL_DOT3_RGB: {
+ GLuint tmp0 = i915_get_temp( p );
+ GLuint tmp1 = i915_get_temp( p );
+ GLuint neg1 = negate(swizzle(i915_emit_const1f(p, 1),X,X,X,X), 1,1,1,1);
+ GLuint two = swizzle(i915_emit_const1f(p, 2),X,X,X,X);
+ i915_emit_arith( p, A0_MAD, tmp0, A0_DEST_CHANNEL_ALL, 0,
+ two, src[0], neg1);
+ if (src[0] == src[1])
+ tmp1 = tmp0;
+ else
+ i915_emit_arith( p, A0_MAD, tmp1, A0_DEST_CHANNEL_ALL, 0,
+ two, src[1], neg1);
+ i915_emit_arith( p, A0_DP3, dest, mask, saturate, tmp0, tmp1, 0);
+ return dest;
+ }
+
+ default:
+ return src[0];
+ }
+}
+
+static GLuint get_dest( struct i915_fragment_program *p, int unit )
+{
+ if (p->ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ return i915_get_temp( p );
+ else if (unit != p->last_tex_stage)
+ return i915_get_temp( p );
+ else
+ return UREG(REG_TYPE_OC, 0);
+}
+
+
+
+static GLuint emit_texenv( struct i915_fragment_program *p, int unit )
+{
+ struct gl_texture_unit *texUnit = &p->ctx->Texture.Unit[unit];
+ GLenum envMode = texUnit->EnvMode;
+ struct gl_texture_object *tObj = texUnit->_Current;
+ GLenum format = tObj->Image[0][tObj->BaseLevel]->Format;
+ GLuint saturate = unit < p->last_tex_stage ? A0_DEST_SATURATE : 0;
+
+ switch(envMode) {
+ case GL_BLEND: {
+ const int cf = get_source(p, GL_PREVIOUS, unit);
+ const int cc = get_source(p, GL_CONSTANT, unit);
+ const int cs = get_source(p, GL_TEXTURE, unit);
+ const int out = get_dest(p, unit);
+
+ if (format == GL_INTENSITY) {
+ /* cv = cf(1 - cs) + cc.cs
+ * cv = cf - cf.cs + cc.cs
+ */
+ /* u[2] = MAD( -cf * cs + cf )
+ * cv = MAD( cc * cs + u[2] )
+ */
+
+ i915_emit_arith( p, A0_MAD, out, A0_DEST_CHANNEL_ALL, 0,
+ negate(cf,1,1,1,1), cs, cf );
+
+ i915_emit_arith( p, A0_MAD, out, A0_DEST_CHANNEL_ALL, saturate,
+ cc, cs, out );
+
+ return out;
+ } else {
+ /* cv = cf(1 - cs) + cc.cs
+ * cv = cf - cf.cs + cc.cs
+ * av = af.as
+ */
+ /* u[2] = MAD( cf.-x-y-zw * cs.xyzw + cf.xyz0 )
+ * oC = MAD( cc.xyz0 * cs.xyz0 + u[2].xyzw )
+ */
+ i915_emit_arith( p, A0_MAD, out, A0_DEST_CHANNEL_ALL, 0,
+ negate(cf,1,1,1,0),
+ cs,
+ swizzle(cf,X,Y,Z,ZERO) );
+
+
+ i915_emit_arith( p, A0_MAD, out, A0_DEST_CHANNEL_ALL, saturate,
+ swizzle(cc,X,Y,Z,ZERO),
+ swizzle(cs,X,Y,Z,ZERO),
+ out );
+
+ return out;
+ }
+ }
+
+ case GL_DECAL: {
+ if (format == GL_RGB ||
+ format == GL_RGBA) {
+ int cf = get_source( p, GL_PREVIOUS, unit );
+ int cs = get_source( p, GL_TEXTURE, unit );
+ int out = get_dest(p, unit);
+
+ /* cv = cf(1-as) + cs.as
+ * cv = cf.(-as) + cf + cs.as
+ * av = af
+ */
+
+ /* u[2] = mad( cf.xyzw * cs.-w-w-w1 + cf.xyz0 )
+ * oc = mad( cs.xyz0 * cs.www0 + u[2].xyzw )
+ */
+ i915_emit_arith( p, A0_MAD, out, A0_DEST_CHANNEL_ALL, 0,
+ cf,
+ negate(swizzle(cs,W,W,W,ONE),1,1,1,0),
+ swizzle(cf,X,Y,Z,ZERO) );
+
+ i915_emit_arith( p, A0_MAD, out, A0_DEST_CHANNEL_ALL, saturate,
+ swizzle(cs,X,Y,Z,ZERO),
+ swizzle(cs,W,W,W,ZERO),
+ out );
+ return out;
+ }
+ else {
+ return get_source( p, GL_PREVIOUS, unit );
+ }
+ }
+
+ case GL_REPLACE: {
+ const int cs = get_source( p, GL_TEXTURE, unit ); /* saturated */
+ switch (format) {
+ case GL_ALPHA: {
+ const int cf = get_source( p, GL_PREVIOUS, unit ); /* saturated */
+ i915_emit_arith( p, A0_MOV, cs, A0_DEST_CHANNEL_XYZ, 0, cf, 0, 0 );
+ return cs;
+ }
+ case GL_RGB:
+ case GL_LUMINANCE: {
+ const int cf = get_source( p, GL_PREVIOUS, unit ); /* saturated */
+ i915_emit_arith( p, A0_MOV, cs, A0_DEST_CHANNEL_W, 0, cf, 0, 0 );
+ return cs;
+ }
+ default:
+ return cs;
+ }
+ }
+
+ case GL_MODULATE: {
+ const int cf = get_source( p, GL_PREVIOUS, unit );
+ const int cs = get_source( p, GL_TEXTURE, unit );
+ const int out = get_dest(p, unit);
+ switch (format) {
+ case GL_ALPHA:
+ i915_emit_arith( p, A0_MUL, out, A0_DEST_CHANNEL_ALL, saturate,
+ swizzle(cs, ONE, ONE, ONE, W), cf, 0 );
+ break;
+ default:
+ i915_emit_arith( p, A0_MUL, out, A0_DEST_CHANNEL_ALL, saturate,
+ cs, cf, 0 );
+ break;
+ }
+ return out;
+ }
+ case GL_ADD: {
+ int cf = get_source( p, GL_PREVIOUS, unit );
+ int cs = get_source( p, GL_TEXTURE, unit );
+ const int out = get_dest( p, unit );
+
+ if (format == GL_INTENSITY) {
+ /* output-color.rgba = add( incoming, u[1] )
+ */
+ i915_emit_arith( p, A0_ADD, out, A0_DEST_CHANNEL_ALL, saturate,
+ cs, cf, 0 );
+ return out;
+ }
+ else {
+ /* cv.xyz = cf.xyz + cs.xyz
+ * cv.w = cf.w * cs.w
+ *
+ * cv.xyzw = MAD( cf.111w * cs.xyzw + cf.xyz0 )
+ */
+ i915_emit_arith( p, A0_MAD, out, A0_DEST_CHANNEL_ALL, saturate,
+ swizzle(cf,ONE,ONE,ONE,W),
+ cs,
+ swizzle(cf,X,Y,Z,ZERO) );
+ return out;
+ }
+ break;
+ }
+ case GL_COMBINE: {
+ GLuint rgb_shift, alpha_shift, out, shift;
+ GLuint dest = get_dest(p, unit);
+
+ /* The EXT version of the DOT3 extension does not support the
+ * scale factor, but the ARB version (and the version in OpenGL
+ * 1.3) does.
+ */
+ switch (texUnit->Combine.ModeRGB) {
+ case GL_DOT3_RGB_EXT:
+ alpha_shift = texUnit->Combine.ScaleShiftA;
+ rgb_shift = 0;
+ break;
+
+ case GL_DOT3_RGBA_EXT:
+ alpha_shift = 0;
+ rgb_shift = 0;
+ break;
+
+ default:
+ rgb_shift = texUnit->Combine.ScaleShiftRGB;
+ alpha_shift = texUnit->Combine.ScaleShiftA;
+ break;
+ }
+
+
+ /* Emit the RGB and A combine ops
+ */
+ if (texUnit->Combine.ModeRGB == texUnit->Combine.ModeA &&
+ args_match( texUnit )) {
+ out = emit_combine( p, dest, A0_DEST_CHANNEL_ALL, saturate,
+ unit,
+ texUnit->Combine.ModeRGB,
+ texUnit->Combine.SourceRGB,
+ texUnit->Combine.OperandRGB );
+ }
+ else if (texUnit->Combine.ModeRGB == GL_DOT3_RGBA_EXT ||
+ texUnit->Combine.ModeRGB == GL_DOT3_RGBA) {
+
+ out = emit_combine( p, dest, A0_DEST_CHANNEL_ALL, saturate,
+ unit,
+ texUnit->Combine.ModeRGB,
+ texUnit->Combine.SourceRGB,
+ texUnit->Combine.OperandRGB );
+ }
+ else {
+ /* Need to do something to stop from re-emitting identical
+ * argument calculations here:
+ */
+ out = emit_combine( p, dest, A0_DEST_CHANNEL_XYZ, saturate,
+ unit,
+ texUnit->Combine.ModeRGB,
+ texUnit->Combine.SourceRGB,
+ texUnit->Combine.OperandRGB );
+ out = emit_combine( p, dest, A0_DEST_CHANNEL_W, saturate,
+ unit,
+ texUnit->Combine.ModeA,
+ texUnit->Combine.SourceA,
+ texUnit->Combine.OperandA );
+ }
+
+ /* Deal with the final shift:
+ */
+ if (alpha_shift || rgb_shift) {
+ if (rgb_shift == alpha_shift) {
+ shift = i915_emit_const1f(p, 1<<rgb_shift);
+ shift = swizzle(shift,X,X,X,X);
+ }
+ else {
+ shift = i915_emit_const2f(p, 1<<rgb_shift, 1<<alpha_shift);
+ shift = swizzle(shift,X,X,X,Y);
+ }
+ return i915_emit_arith( p, A0_MUL, dest, A0_DEST_CHANNEL_ALL,
+ saturate, out, shift, 0 );
+ }
+
+ return out;
+ }
+
+ default:
+ return get_source(p, GL_PREVIOUS, 0);
+ }
+}
+
+static void emit_program_fini( struct i915_fragment_program *p )
+{
+ int cf = get_source( p, GL_PREVIOUS, 0 );
+ int out = UREG( REG_TYPE_OC, 0 );
+
+ if (p->ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
+ /* Emit specular add.
+ */
+ GLuint s = i915_emit_decl(p, REG_TYPE_T, T_SPECULAR, D0_CHANNEL_ALL);
+ i915_emit_arith( p, A0_ADD, out, A0_DEST_CHANNEL_ALL, 0, cf,
+ swizzle(s, X,Y,Z,ZERO), 0 );
+ }
+ else if (cf != out) {
+ /* Will wind up in here if no texture enabled or a couple of
+ * other scenarios (GL_REPLACE for instance).
+ */
+ i915_emit_arith( p, A0_MOV, out, A0_DEST_CHANNEL_ALL, 0, cf, 0, 0 );
+ }
+}
+
+
+static void i915EmitTextureProgram( i915ContextPtr i915 )
+{
+ GLcontext *ctx = &i915->intel.ctx;
+ struct i915_fragment_program *p = &i915->tex_program;
+ GLuint unit;
+
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+
+ i915_init_program( i915, p );
+
+ if (ctx->Texture._EnabledUnits) {
+ for (unit = 0 ; unit < ctx->Const.MaxTextureUnits ; unit++)
+ if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+ p->last_tex_stage = unit;
+ }
+
+ for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++)
+ if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+ p->src_previous = emit_texenv( p, unit );
+ p->src_texture = UREG_BAD;
+ p->temp_flag = 0xffff000;
+ p->temp_flag |= 1 << GET_UREG_NR(p->src_previous);
+ }
+ }
+
+ emit_program_fini( p );
+
+ i915_fini_program( p );
+ i915_upload_program( i915, p );
+
+ p->translated = 1;
+}
+
+
+void i915ValidateTextureProgram( i915ContextPtr i915 )
+{
+ intelContextPtr intel = &i915->intel;
+ GLcontext *ctx = &intel->ctx;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint index = tnl->render_inputs;
+ int i, offset;
+ GLuint s4 = i915->state.Ctx[I915_CTXREG_LIS4] & ~S4_VFMT_MASK;
+ GLuint s2 = S2_TEXCOORD_NONE;
+
+ /* Important:
+ */
+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
+ intel->vertex_attr_count = 0;
+ intel->coloroffset = 0;
+ intel->specoffset = 0;
+ offset = 0;
+
+ if (i915->vertex_fog == I915_FOG_PIXEL) {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, S4_VFMT_XYZW, 16 );
+ index &= ~_TNL_BIT_FOG;
+ }
+ else if (index & _TNL_BITS_TEX_ANY) {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, S4_VFMT_XYZW, 16 );
+ }
+ else {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, S4_VFMT_XYZ, 12 );
+ }
+
+ /* How undefined is undefined? */
+ if (index & _TNL_BIT_POINTSIZE) {
+ EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, S4_VFMT_POINT_WIDTH, 4 );
+ }
+
+ intel->coloroffset = offset / 4;
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, S4_VFMT_COLOR, 4 );
+
+ if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) {
+ if (index & _TNL_BIT_COLOR1) {
+ intel->specoffset = offset / 4;
+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, S4_VFMT_SPEC_FOG, 3 );
+ } else
+ EMIT_PAD( 3 );
+
+ if (index & _TNL_BIT_FOG)
+ EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, S4_VFMT_SPEC_FOG, 1 );
+ else
+ EMIT_PAD( 1 );
+ }
+
+ if (index & _TNL_BITS_TEX_ANY) {
+ for (i = 0; i < 8; i++) {
+ if (index & _TNL_BIT_TEX(i)) {
+ int sz = VB->TexCoordPtr[i]->size;
+
+ s2 &= ~S2_TEXCOORD_FMT(i, S2_TEXCOORD_FMT0_MASK);
+ s2 |= S2_TEXCOORD_FMT(i, SZ_TO_HW(sz));
+
+ EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_SZ(sz), 0, sz * 4 );
+ }
+ }
+ }
+
+ /* Only need to change the vertex emit code if there has been a
+ * statechange to a new hardware vertex format:
+ */
+ if (s2 != i915->state.Ctx[I915_CTXREG_LIS2] ||
+ s4 != i915->state.Ctx[I915_CTXREG_LIS4]) {
+
+ I915_STATECHANGE( i915, I915_UPLOAD_CTX );
+
+ i915->tex_program.translated = 0;
+
+ /* Must do this *after* statechange, so as not to affect
+ * buffered vertices reliant on the old state:
+ */
+ intel->vertex_size = _tnl_install_attrs( ctx,
+ intel->vertex_attrs,
+ intel->vertex_attr_count,
+ intel->ViewportMatrix.m, 0 );
+
+ intel->vertex_size >>= 2;
+
+ i915->state.Ctx[I915_CTXREG_LIS2] = s2;
+ i915->state.Ctx[I915_CTXREG_LIS4] = s4;
+
+ assert(intel->vtbl.check_vertex_size( intel, intel->vertex_size ));
+ }
+
+ if (!i915->tex_program.translated ||
+ i915->last_ReallyEnabled != ctx->Texture._EnabledUnits) {
+ i915EmitTextureProgram( i915 );
+ i915->last_ReallyEnabled = ctx->Texture._EnabledUnits;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_texstate.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_texstate.c
new file mode 100644
index 000000000..7a274bb69
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_texstate.c
@@ -0,0 +1,922 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "texformat.h"
+#include "texstore.h"
+
+#include "mm.h"
+
+#include "intel_screen.h"
+#include "intel_ioctl.h"
+#include "intel_tex.h"
+
+#include "i915_context.h"
+#include "i915_reg.h"
+
+static GLint initial_offsets[6][2] = { {0,0},
+ {0,2},
+ {1,0},
+ {1,2},
+ {1,1},
+ {1,3} };
+
+
+static GLint step_offsets[6][2] = { {0,2},
+ {0,2},
+ {-1,2},
+ {-1,2},
+ {-1,1},
+ {-1,1} };
+
+
+#define I915_TEX_UNIT_ENABLED(unit) (1<<unit)
+
+static void i915LayoutTextureImages( i915ContextPtr i915,
+ struct gl_texture_object *tObj )
+{
+ const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
+ i915TextureObjectPtr t = (i915TextureObjectPtr) tObj->DriverData;
+ GLint firstLevel, lastLevel, numLevels;
+ GLint i, total_height, pitch;
+
+ /* Compute which mipmap levels we really want to send to the hardware.
+ */
+ driCalculateTextureFirstLastLevel( (driTextureObject *) t );
+
+ /* Figure out the amount of memory required to hold all the mipmap
+ * levels. Choose the smallest pitch to accomodate the largest
+ * mipmap:
+ */
+ firstLevel = t->intel.base.firstLevel;
+ lastLevel = t->intel.base.lastLevel;
+ numLevels = lastLevel - firstLevel + 1;
+
+
+
+ /* All images must be loaded at this pitch. Count the number of
+ * lines required:
+ */
+ switch (tObj->Target) {
+ case GL_TEXTURE_CUBE_MAP: {
+ const GLuint dim = tObj->Image[0][firstLevel]->Width;
+ GLuint face;
+
+ pitch = dim * t->intel.texelBytes;
+ pitch *= 2; /* double pitch for cube layouts */
+ pitch = (pitch + 3) & ~3;
+
+ total_height = dim * 4;
+
+ for ( face = 0 ; face < 6 ; face++) {
+ GLuint x = initial_offsets[face][0] * dim;
+ GLuint y = initial_offsets[face][1] * dim;
+ GLuint d = dim;
+
+ t->intel.base.dirty_images[face] = ~0;
+
+ assert(tObj->Image[face][firstLevel]->Width == dim);
+ assert(tObj->Image[face][firstLevel]->Height == dim);
+
+ for (i = 0; i < numLevels; i++) {
+ t->intel.image[face][i].image = tObj->Image[face][firstLevel + i];
+ if (!t->intel.image[face][i].image) {
+ fprintf(stderr, "no image %d %d\n", face, i);
+ break; /* can't happen */
+ }
+
+ t->intel.image[face][i].offset =
+ y * pitch + x * t->intel.texelBytes;
+ t->intel.image[face][i].internalFormat = baseImage->Format;
+
+ d >>= 1;
+ x += step_offsets[face][0] * d;
+ y += step_offsets[face][1] * d;
+ }
+ }
+ break;
+ }
+ case GL_TEXTURE_3D: {
+ GLuint virtual_height;
+ GLuint tmp_numLevels = numLevels;
+ pitch = tObj->Image[0][firstLevel]->Width * t->intel.texelBytes;
+ pitch = (pitch + 3) & ~3;
+ t->intel.base.dirty_images[0] = ~0;
+
+ /* Calculate the size of a single slice. Hardware demands a
+ * minimum of 8 mipmaps, some of which might ultimately not be
+ * used:
+ */
+ if (tmp_numLevels < 9)
+ tmp_numLevels = 9;
+
+ virtual_height = tObj->Image[0][firstLevel]->Height;
+
+ for ( total_height = i = 0 ; i < tmp_numLevels ; i++ ) {
+ t->intel.image[0][i].image = tObj->Image[0][firstLevel + i];
+ if (t->intel.image[0][i].image) {
+ t->intel.image[0][i].offset = total_height * pitch;
+ t->intel.image[0][i].internalFormat = baseImage->Format;
+ }
+
+ total_height += MAX2(2, virtual_height);
+ virtual_height >>= 1;
+ }
+
+ t->intel.depth_pitch = total_height * pitch;
+
+ /* Multiply slice size by texture depth for total size. It's
+ * remarkable how wasteful of memory all the i8x0 texture
+ * layouts are.
+ */
+ total_height *= t->intel.image[0][0].image->Depth;
+ break;
+ }
+ default:
+ pitch = tObj->Image[0][firstLevel]->Width * t->intel.texelBytes;
+ pitch = (pitch + 3) & ~3;
+ t->intel.base.dirty_images[0] = ~0;
+
+ for ( total_height = i = 0 ; i < numLevels ; i++ ) {
+ t->intel.image[0][i].image = tObj->Image[0][firstLevel + i];
+ if (!t->intel.image[0][i].image)
+ break;
+
+ t->intel.image[0][i].offset = total_height * pitch;
+ t->intel.image[0][i].internalFormat = baseImage->Format;
+ if (t->intel.image[0][i].image->IsCompressed)
+ {
+ if (t->intel.image[0][i].image->Height > 4)
+ total_height += t->intel.image[0][i].image->Height/4;
+ else
+ total_height += 1;
+ }
+ else
+ total_height += MAX2(2, t->intel.image[0][i].image->Height);
+ }
+ break;
+ }
+
+ t->intel.Pitch = pitch;
+ t->intel.base.totalSize = total_height*pitch;
+ t->intel.max_level = numLevels-1;
+}
+
+
+static void i945LayoutTextureImages( i915ContextPtr i915,
+ struct gl_texture_object *tObj )
+{
+ const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
+ i915TextureObjectPtr t = (i915TextureObjectPtr) tObj->DriverData;
+ GLint firstLevel, lastLevel, numLevels;
+ GLint i, total_height, pitch, sz, max_offset = 0, offset;
+
+
+ /* Compute which mipmap levels we really want to send to the hardware.
+ */
+ driCalculateTextureFirstLastLevel( (driTextureObject *) t );
+
+ /* Figure out the amount of memory required to hold all the mipmap
+ * levels. Choose the smallest pitch to accomodate the largest
+ * mipmap:
+ */
+ firstLevel = t->intel.base.firstLevel;
+ lastLevel = t->intel.base.lastLevel;
+ numLevels = lastLevel - firstLevel + 1;
+
+
+
+ /* All images must be loaded at this pitch. Count the number of
+ * lines required:
+ */
+ switch (tObj->Target) {
+ case GL_TEXTURE_CUBE_MAP: {
+ const GLuint dim = tObj->Image[0][firstLevel]->Width;
+ GLuint face;
+
+ /* Depending on the size of the largest images, pitch can be
+ * determined either by the old-style packing of cubemap faces,
+ * or the final row of 4x4, 2x2 and 1x1 faces below this.
+ */
+ if (dim > 32) {
+ pitch = dim * t->intel.texelBytes;
+ pitch *= 2; /* double pitch for cube layouts */
+ pitch = (pitch + 3) & ~3;
+ }
+ else {
+ pitch = 14 * 8 * t->intel.texelBytes; /* determined by row of
+ * little maps at
+ * bottom */
+ }
+
+ total_height = dim * 4 + 4;
+
+ for ( face = 0 ; face < 6 ; face++) {
+ GLuint x = initial_offsets[face][0] * dim;
+ GLuint y = initial_offsets[face][1] * dim;
+ GLuint d = dim;
+
+ if (dim == 4 && face >= 4) {
+ y = total_height - 4;
+ x = (face - 4) * 8;
+ }
+ else if (dim < 4) {
+ y = total_height - 4;
+ x = face * 8;
+ }
+
+ t->intel.base.dirty_images[face] = ~0;
+
+ assert(tObj->Image[face][firstLevel]->Width == dim);
+ assert(tObj->Image[face][firstLevel]->Height == dim);
+
+ for (i = 0; i < numLevels; i++) {
+
+
+ t->intel.image[face][i].image = tObj->Image[face][firstLevel + i];
+ assert(t->intel.image[face][i].image);
+
+ t->intel.image[face][i].offset =
+ y * pitch + x * t->intel.texelBytes;
+ t->intel.image[face][i].internalFormat = baseImage->Format;
+
+ d >>= 1;
+
+ switch (d) {
+ case 4:
+ switch (face) {
+ case FACE_POS_X:
+ case FACE_NEG_X:
+ x += step_offsets[face][0] * d;
+ y += step_offsets[face][1] * d;
+ break;
+ case FACE_POS_Y:
+ case FACE_NEG_Y:
+ y += 12;
+ x -= 8;
+ break;
+ case FACE_POS_Z:
+ case FACE_NEG_Z:
+ y = total_height - 4;
+ x = (face - 4) * 8;
+ break;
+ }
+
+ case 2:
+ y = total_height - 4;
+ x = 16 + face * 8;
+ break;
+
+ case 1:
+ x += 48;
+ break;
+
+ default:
+ x += step_offsets[face][0] * d;
+ y += step_offsets[face][1] * d;
+ break;
+ }
+ }
+ }
+ max_offset = total_height * pitch;
+ break;
+ }
+ case GL_TEXTURE_3D: {
+ GLuint depth_packing = 0, depth_pack_pitch;
+ GLuint tmp_numLevels = numLevels;
+ pitch = tObj->Image[0][firstLevel]->Width * t->intel.texelBytes;
+ pitch = (pitch + 3) & ~3;
+ depth_pack_pitch = pitch;
+
+ t->intel.base.dirty_images[0] = ~0;
+
+
+ for ( total_height = i = 0 ; i < tmp_numLevels ; i++ ) {
+ t->intel.image[0][i].image = tObj->Image[0][firstLevel + i];
+ if (!t->intel.image[0][i].image)
+ break;
+
+
+ t->intel.image[0][i].offset = total_height * pitch;
+ t->intel.image[0][i].internalFormat = baseImage->Format;
+
+
+
+ total_height += MAX2(2, t->intel.image[0][i].image->Height) *
+ MAX2((t->intel.image[0][i].image->Depth >> depth_packing), 1);
+
+ /* When alignment dominates, can't increase depth packing?
+ * Or does pitch grow??? What are the alignment constraints,
+ * anyway?
+ */
+ if (depth_pack_pitch > 4) {
+ depth_packing++;
+ depth_pack_pitch <<= 2;
+ }
+ }
+
+ max_offset = total_height * pitch;
+ break;
+ }
+ default:
+ pitch = tObj->Image[0][firstLevel]->Width * t->intel.texelBytes;
+ pitch = (pitch + 3) & ~3;
+ t->intel.base.dirty_images[0] = ~0;
+ max_offset = 0;
+
+ for ( offset = i = 0 ; i < numLevels ; i++ ) {
+ t->intel.image[0][i].image = tObj->Image[0][firstLevel + i];
+ if (!t->intel.image[0][i].image)
+ break;
+
+ t->intel.image[0][i].offset = offset;
+ t->intel.image[0][i].internalFormat = baseImage->Format;
+
+ if (t->intel.image[0][i].image->IsCompressed)
+ sz = MAX2(1, t->intel.image[0][i].image->Height/4) * pitch;
+ else
+ sz = MAX2(2, t->intel.image[0][i].image->Height) * pitch;
+
+ /* Because the images are packed better, the final offset
+ * might not be the maximal one:
+ */
+ max_offset = MAX2(max_offset, offset + sz);
+
+ /* LPT change: step right after second mipmap.
+ */
+ if (i == 1)
+ offset += pitch / 2;
+ else
+ offset += sz;
+
+ }
+ break;
+ }
+
+ t->intel.Pitch = pitch;
+ t->intel.base.totalSize = max_offset;
+ t->intel.max_level = numLevels-1;
+}
+
+
+
+
+static void i915SetTexImages( i915ContextPtr i915,
+ struct gl_texture_object *tObj )
+{
+ GLuint textureFormat;
+ i915TextureObjectPtr t = (i915TextureObjectPtr) tObj->DriverData;
+ const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
+ GLint ss2 = 0;
+
+ switch( baseImage->TexFormat->MesaFormat ) {
+ case MESA_FORMAT_L8:
+ t->intel.texelBytes = 1;
+ textureFormat = MAPSURF_8BIT | MT_8BIT_L8;
+ break;
+
+ case MESA_FORMAT_I8:
+ t->intel.texelBytes = 1;
+ textureFormat = MAPSURF_8BIT | MT_8BIT_I8;
+ break;
+
+ case MESA_FORMAT_A8:
+ t->intel.texelBytes = 1;
+ textureFormat = MAPSURF_8BIT | MT_8BIT_A8;
+ break;
+
+ case MESA_FORMAT_AL88:
+ t->intel.texelBytes = 2;
+ textureFormat = MAPSURF_16BIT | MT_16BIT_AY88;
+ break;
+
+ case MESA_FORMAT_RGB565:
+ t->intel.texelBytes = 2;
+ textureFormat = MAPSURF_16BIT | MT_16BIT_RGB565;
+ break;
+
+ case MESA_FORMAT_ARGB1555:
+ t->intel.texelBytes = 2;
+ textureFormat = MAPSURF_16BIT | MT_16BIT_ARGB1555;
+ break;
+
+ case MESA_FORMAT_ARGB4444:
+ t->intel.texelBytes = 2;
+ textureFormat = MAPSURF_16BIT | MT_16BIT_ARGB4444;
+ break;
+
+ case MESA_FORMAT_ARGB8888:
+ t->intel.texelBytes = 4;
+ textureFormat = MAPSURF_32BIT | MT_32BIT_ARGB8888;
+ break;
+
+ case MESA_FORMAT_YCBCR_REV:
+ t->intel.texelBytes = 2;
+ textureFormat = (MAPSURF_422 | MT_422_YCRCB_NORMAL);
+ ss2 |= SS2_COLORSPACE_CONVERSION;
+ break;
+
+ case MESA_FORMAT_YCBCR:
+ t->intel.texelBytes = 2;
+ textureFormat = (MAPSURF_422 | MT_422_YCRCB_SWAPY);
+ ss2 |= SS2_COLORSPACE_CONVERSION;
+ break;
+
+ case MESA_FORMAT_RGB_FXT1:
+ case MESA_FORMAT_RGBA_FXT1:
+ t->intel.texelBytes = 2;
+ textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_FXT1);
+ break;
+
+ case MESA_FORMAT_DEPTH_COMPONENT16:
+ t->intel.texelBytes = 2;
+ textureFormat = (MAPSURF_16BIT | MT_16BIT_L16);
+ break;
+
+ case MESA_FORMAT_RGBA_DXT1:
+ case MESA_FORMAT_RGB_DXT1:
+ /*
+ * DXTn pitches are Width/4 * blocksize in bytes
+ * for DXT1: blocksize=8 so Width/4*8 = Width * 2
+ * for DXT3/5: blocksize=16 so Width/4*16 = Width * 4
+ */
+ t->intel.texelBytes = 2;
+ textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT1);
+ break;
+
+ case MESA_FORMAT_RGBA_DXT3:
+ t->intel.texelBytes = 4;
+ textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT2_3);
+ break;
+
+ case MESA_FORMAT_RGBA_DXT5:
+ t->intel.texelBytes = 4;
+ textureFormat = (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
+ break;
+
+#if 0
+ case MESA_FORMAT_DEPTH_COMPONENT_X8Z24:
+ t->intel.texelBytes = 4;
+ textureFormat = (MAPSURF_32BIT | MT_32BIT_xL824);
+ break;
+#endif
+
+ default:
+ fprintf(stderr, "%s: bad image format %x\n", __FUNCTION__,
+ baseImage->TexFormat->MesaFormat);
+ abort();
+ }
+
+
+ if (i915->intel.intelScreen->deviceID == PCI_CHIP_I945_G)
+ i945LayoutTextureImages( i915, tObj );
+ else
+ i915LayoutTextureImages( i915, tObj );
+
+ t->Setup[I915_TEXREG_MS3] =
+ (((tObj->Image[0][t->intel.base.firstLevel]->Height - 1) << MS3_HEIGHT_SHIFT) |
+ ((tObj->Image[0][t->intel.base.firstLevel]->Width - 1) << MS3_WIDTH_SHIFT) |
+ textureFormat |
+ MS3_USE_FENCE_REGS);
+
+ t->Setup[I915_TEXREG_MS4] =
+ ((((t->intel.Pitch / 4) - 1) << MS4_PITCH_SHIFT) |
+ MS4_CUBE_FACE_ENA_MASK |
+ (((t->intel.max_level * 4)) << MS4_MAX_LOD_SHIFT) |
+ ((tObj->Image[0][t->intel.base.firstLevel]->Depth - 1) << MS4_VOLUME_DEPTH_SHIFT));
+
+ t->Setup[I915_TEXREG_SS2] &= ~(SS2_COLORSPACE_CONVERSION);
+ t->Setup[I915_TEXREG_SS2] |= ss2;
+
+ t->intel.dirty = I915_UPLOAD_TEX_ALL;
+
+}
+
+
+/* The i915 (and related graphics cores) do not support GL_CLAMP. The
+ * Intel drivers for "other operating systems" implement GL_CLAMP as
+ * GL_CLAMP_TO_EDGE, so the same is done here.
+ */
+static GLuint translate_wrap_mode( GLenum wrap )
+{
+ switch( wrap ) {
+ case GL_REPEAT: return TEXCOORDMODE_WRAP;
+ case GL_CLAMP: return TEXCOORDMODE_CLAMP_EDGE; /* not quite correct */
+ case GL_CLAMP_TO_EDGE: return TEXCOORDMODE_CLAMP_EDGE;
+ case GL_CLAMP_TO_BORDER: return TEXCOORDMODE_CLAMP_BORDER;
+ case GL_MIRRORED_REPEAT: return TEXCOORDMODE_MIRROR;
+ default: return TEXCOORDMODE_WRAP;
+ }
+}
+
+
+/**
+ */
+static void i915ImportTexObjState( struct gl_texture_object *texObj )
+{
+ i915TextureObjectPtr t = (i915TextureObjectPtr)texObj->DriverData;
+ int minFilt = 0, mipFilt = 0, magFilt = 0, shadow = 0;
+
+ if(INTEL_DEBUG&DEBUG_DRI)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ switch (texObj->MinFilter) {
+ case GL_NEAREST:
+ minFilt = FILTER_NEAREST;
+ mipFilt = MIPFILTER_NONE;
+ break;
+ case GL_LINEAR:
+ minFilt = FILTER_LINEAR;
+ mipFilt = MIPFILTER_NONE;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ minFilt = FILTER_NEAREST;
+ mipFilt = MIPFILTER_NEAREST;
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ minFilt = FILTER_LINEAR;
+ mipFilt = MIPFILTER_NEAREST;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ minFilt = FILTER_NEAREST;
+ mipFilt = MIPFILTER_LINEAR;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ minFilt = FILTER_LINEAR;
+ mipFilt = MIPFILTER_LINEAR;
+ break;
+ default:
+ break;
+ }
+
+ if ( texObj->MaxAnisotropy > 1.0 ) {
+ minFilt = FILTER_ANISOTROPIC;
+ magFilt = FILTER_ANISOTROPIC;
+ }
+ else {
+ switch (texObj->MagFilter) {
+ case GL_NEAREST:
+ magFilt = FILTER_NEAREST;
+ break;
+ case GL_LINEAR:
+ magFilt = FILTER_LINEAR;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (texObj->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB &&
+ texObj->Target != GL_TEXTURE_3D) {
+
+ shadow = SS2_SHADOW_ENABLE;
+ shadow |= intel_translate_compare_func( texObj->CompareFunc );
+
+ minFilt = FILTER_4X4_FLAT;
+ magFilt = FILTER_4X4_FLAT;
+ }
+
+
+ t->Setup[I915_TEXREG_SS2] &= ~(SS2_MIN_FILTER_MASK |
+ SS2_MIP_FILTER_MASK |
+ SS2_MAG_FILTER_MASK |
+ SS2_SHADOW_ENABLE |
+ SS2_SHADOW_FUNC_MASK);
+ t->Setup[I915_TEXREG_SS2] |= ((minFilt << SS2_MIN_FILTER_SHIFT) |
+ (mipFilt << SS2_MIP_FILTER_SHIFT) |
+ (magFilt << SS2_MAG_FILTER_SHIFT) |
+ shadow);
+
+ {
+ GLuint ss3 = t->Setup[I915_TEXREG_SS3] & ~(SS3_TCX_ADDR_MODE_MASK |
+ SS3_TCY_ADDR_MODE_MASK |
+ SS3_TCZ_ADDR_MODE_MASK);
+ GLenum ws = texObj->WrapS;
+ GLenum wt = texObj->WrapT;
+ GLenum wr = texObj->WrapR;
+
+ t->refs_border_color = 0;
+
+ if (texObj->Target == GL_TEXTURE_3D &&
+ (texObj->MinFilter != GL_NEAREST ||
+ texObj->MagFilter != GL_NEAREST)) {
+
+ /* Try to mimic GL_CLAMP functionality a little better -
+ * switch to CLAMP_TO_BORDER whenever a non-NEAREST filter is
+ * in use. Only do this for 3D textures at the moment --
+ * doing it universally would fix the conform texbc.c
+ * failure, though.
+ */
+ if (ws == GL_CLAMP) ws = GL_CLAMP_TO_BORDER;
+ if (wt == GL_CLAMP) wt = GL_CLAMP_TO_BORDER;
+ if (wr == GL_CLAMP) wr = GL_CLAMP_TO_BORDER;
+
+ /* 3D textures don't seem to respect the border color.
+ * Fallback if there's ever a danger that they might refer to
+ * it.
+ */
+ if (ws == GL_CLAMP_TO_BORDER) t->refs_border_color = 1;
+ if (wt == GL_CLAMP_TO_BORDER) t->refs_border_color = 1;
+ if (wr == GL_CLAMP_TO_BORDER) t->refs_border_color = 1;
+ }
+
+ ss3 |= translate_wrap_mode(ws) << SS3_TCX_ADDR_MODE_SHIFT;
+ ss3 |= translate_wrap_mode(wt) << SS3_TCY_ADDR_MODE_SHIFT;
+ ss3 |= translate_wrap_mode(wr) << SS3_TCZ_ADDR_MODE_SHIFT;
+
+ if (ss3 != t->Setup[I915_TEXREG_SS3]) {
+ t->intel.dirty = I915_UPLOAD_TEX_ALL;
+ t->Setup[I915_TEXREG_SS3] = ss3;
+ }
+ }
+
+ {
+ const GLubyte *color = texObj->_BorderChan;
+
+ t->Setup[I915_TEXREG_SS4] = INTEL_PACKCOLOR8888(color[0],color[1],
+ color[2],color[3]);
+ }
+}
+
+
+
+static void i915_import_tex_unit( i915ContextPtr i915,
+ i915TextureObjectPtr t,
+ GLuint unit )
+{
+ GLuint state[I915_TEX_SETUP_SIZE];
+
+ if(INTEL_DEBUG&DEBUG_TEXTURE)
+ fprintf(stderr, "%s unit(%d)\n", __FUNCTION__, unit);
+
+ if (i915->intel.CurrentTexObj[unit])
+ i915->intel.CurrentTexObj[unit]->base.bound &= ~(1U << unit);
+
+ i915->intel.CurrentTexObj[unit] = (intelTextureObjectPtr)t;
+ t->intel.base.bound |= (1 << unit);
+
+ if (t->intel.dirty & I915_UPLOAD_TEX(unit)) {
+ i915ImportTexObjState( t->intel.base.tObj );
+ t->intel.dirty &= ~I915_UPLOAD_TEX(unit);
+ }
+
+ state[I915_TEXREG_MS2] = t->intel.TextureOffset;
+ state[I915_TEXREG_MS3] = t->Setup[I915_TEXREG_MS3];
+ state[I915_TEXREG_MS4] = t->Setup[I915_TEXREG_MS4];
+
+ state[I915_TEXREG_SS2] = (i915->state.Tex[unit][I915_TEXREG_SS2] &
+ SS2_LOD_BIAS_MASK);
+ state[I915_TEXREG_SS2] |= (t->Setup[I915_TEXREG_SS2] & ~SS2_LOD_BIAS_MASK);
+
+ state[I915_TEXREG_SS3] = (i915->state.Tex[unit][I915_TEXREG_SS3] &
+ SS3_NORMALIZED_COORDS);
+ state[I915_TEXREG_SS3] |= (t->Setup[I915_TEXREG_SS3] &
+ ~(SS3_NORMALIZED_COORDS|
+ SS3_TEXTUREMAP_INDEX_MASK));
+
+ state[I915_TEXREG_SS3] |= (unit<<SS3_TEXTUREMAP_INDEX_SHIFT);
+
+ state[I915_TEXREG_SS4] = t->Setup[I915_TEXREG_SS4];
+
+
+ if (memcmp(state, i915->state.Tex[unit], sizeof(state)) != 0) {
+ I915_STATECHANGE( i915, I915_UPLOAD_TEX(unit) );
+ memcpy(i915->state.Tex[unit], state, sizeof(state));
+ }
+}
+
+
+
+static GLboolean enable_tex_common( GLcontext *ctx, GLuint unit )
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ i915TextureObjectPtr t = (i915TextureObjectPtr)tObj->DriverData;
+
+ if (0) fprintf(stderr, "%s %d\n", __FUNCTION__, unit);
+
+ if (!(i915->state.active & I915_UPLOAD_TEX(unit))) {
+ I915_ACTIVESTATE(i915, I915_UPLOAD_TEX(unit), GL_TRUE);
+ }
+
+ /* Fallback if there's a texture border */
+ if ( tObj->Image[0][tObj->BaseLevel]->Border > 0 ) {
+ return GL_FALSE;
+ }
+
+
+ /* Update state if this is a different texture object to last
+ * time.
+ */
+ if (i915->intel.CurrentTexObj[unit] != &t->intel ||
+ (t->intel.dirty & I915_UPLOAD_TEX(unit))) {
+ i915_import_tex_unit( i915, t, unit);
+ i915->tex_program.translated = 0;
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean enable_tex_rect( GLcontext *ctx, GLuint unit )
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ i915TextureObjectPtr t = (i915TextureObjectPtr)tObj->DriverData;
+ GLuint ss3 = i915->state.Tex[unit][I915_TEXREG_SS3];
+
+ ss3 &= ~SS3_NORMALIZED_COORDS;
+
+ if (ss3 != i915->state.Tex[unit][I915_TEXREG_SS3]) {
+ I915_STATECHANGE(i915, I915_UPLOAD_TEX(unit));
+ i915->state.Tex[unit][I915_TEXREG_SS3] = ss3;
+ }
+
+ /* Upload teximages (not pipelined)
+ */
+ if (t->intel.base.dirty_images[0]) {
+ i915SetTexImages( i915, tObj );
+ if (!intelUploadTexImages( &i915->intel, &t->intel, 0 )) {
+ return GL_FALSE;
+ }
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLboolean enable_tex_2d( GLcontext *ctx, GLuint unit )
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ i915TextureObjectPtr t = (i915TextureObjectPtr)tObj->DriverData;
+ GLuint ss3 = i915->state.Tex[unit][I915_TEXREG_SS3];
+
+ ss3 |= SS3_NORMALIZED_COORDS;
+
+ if (ss3 != i915->state.Tex[unit][I915_TEXREG_SS3]) {
+ I915_STATECHANGE(i915, I915_UPLOAD_TEX(unit));
+ i915->state.Tex[unit][I915_TEXREG_SS3] = ss3;
+ }
+
+ /* Upload teximages (not pipelined)
+ */
+ if (t->intel.base.dirty_images[0]) {
+ i915SetTexImages( i915, tObj );
+ if (!intelUploadTexImages( &i915->intel, &t->intel, 0 )) {
+ return GL_FALSE;
+ }
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean enable_tex_cube( GLcontext *ctx, GLuint unit )
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ i915TextureObjectPtr t = (i915TextureObjectPtr)tObj->DriverData;
+ GLuint ss3 = i915->state.Tex[unit][I915_TEXREG_SS3];
+ GLuint face;
+
+ ss3 |= SS3_NORMALIZED_COORDS;
+
+ if (ss3 != i915->state.Tex[unit][I915_TEXREG_SS3]) {
+ I915_STATECHANGE(i915, I915_UPLOAD_TEX(unit));
+ i915->state.Tex[unit][I915_TEXREG_SS3] = ss3;
+ }
+
+ /* Upload teximages (not pipelined)
+ */
+ if ( t->intel.base.dirty_images[0] || t->intel.base.dirty_images[1] ||
+ t->intel.base.dirty_images[2] || t->intel.base.dirty_images[3] ||
+ t->intel.base.dirty_images[4] || t->intel.base.dirty_images[5] ) {
+ i915SetTexImages( i915, tObj );
+ }
+
+ /* upload (per face) */
+ for (face = 0; face < 6; face++) {
+ if (t->intel.base.dirty_images[face]) {
+ if (!intelUploadTexImages( &i915->intel, &t->intel, face )) {
+ return GL_FALSE;
+ }
+ }
+ }
+
+
+ return GL_TRUE;
+}
+
+static GLboolean enable_tex_3d( GLcontext *ctx, GLuint unit )
+{
+ struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
+ i915TextureObjectPtr t = (i915TextureObjectPtr)tObj->DriverData;
+
+ /* 3D textures on I915 seem to get bogus border colors, hence this
+ * fallback:
+ */
+ if (t->refs_border_color)
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
+
+
+
+static GLboolean disable_tex( GLcontext *ctx, GLuint unit )
+{
+ i915ContextPtr i915 = I915_CONTEXT(ctx);
+
+ if (i915->state.active & I915_UPLOAD_TEX(unit)) {
+ I915_ACTIVESTATE(i915, I915_UPLOAD_TEX(unit), GL_FALSE);
+ }
+
+ /* The old texture is no longer bound to this texture unit.
+ * Mark it as such.
+ */
+ if ( i915->intel.CurrentTexObj[unit] != NULL ) {
+ i915->intel.CurrentTexObj[unit]->base.bound &= ~(1U << 0);
+ i915->intel.CurrentTexObj[unit] = NULL;
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean i915UpdateTexUnit( GLcontext *ctx, GLuint unit )
+{
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+ if (texUnit->_ReallyEnabled &&
+ INTEL_CONTEXT(ctx)->intelScreen->textureSize < 2048 * 1024)
+ return GL_FALSE;
+
+ switch (texUnit->_ReallyEnabled) {
+ case TEXTURE_1D_BIT:
+ case TEXTURE_2D_BIT:
+ return (enable_tex_2d( ctx, unit ) &&
+ enable_tex_common( ctx, unit ));
+ case TEXTURE_RECT_BIT:
+ return (enable_tex_rect( ctx, unit ) &&
+ enable_tex_common( ctx, unit ));
+ case TEXTURE_CUBE_BIT:
+ return (enable_tex_cube( ctx, unit ) &&
+ enable_tex_common( ctx, unit ));
+ case TEXTURE_3D_BIT:
+ return (enable_tex_2d( ctx, unit ) &&
+ enable_tex_common( ctx, unit ) &&
+ enable_tex_3d( ctx, unit));
+ case 0:
+ return disable_tex( ctx, unit );
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+void i915UpdateTextureState( intelContextPtr intel )
+{
+ GLcontext *ctx = &intel->ctx;
+ GLboolean ok = GL_TRUE;
+ GLuint i;
+
+ for (i = 0 ; i < I915_TEX_UNITS && ok ; i++) {
+ ok = i915UpdateTexUnit( ctx, i );
+ }
+
+ FALLBACK( intel, I915_FALLBACK_TEXTURE, !ok );
+}
+
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_vtbl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_vtbl.c
new file mode 100644
index 000000000..795286601
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/i915_vtbl.c
@@ -0,0 +1,353 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "imports.h"
+#include "macros.h"
+#include "colormac.h"
+
+#include "tnl/t_context.h"
+#include "tnl/t_vertex.h"
+
+#include "intel_batchbuffer.h"
+
+#include "i915_reg.h"
+#include "i915_context.h"
+
+static void i915_render_start( intelContextPtr intel )
+{
+ GLcontext *ctx = &intel->ctx;
+ i915ContextPtr i915 = I915_CONTEXT(intel);
+
+ if (ctx->FragmentProgram._Active)
+ i915ValidateFragmentProgram( i915 );
+ else
+ i915ValidateTextureProgram( i915 );
+}
+
+
+static void i915_reduced_primitive_state( intelContextPtr intel,
+ GLenum rprim )
+{
+ i915ContextPtr i915 = I915_CONTEXT(intel);
+ GLuint st1 = i915->state.Stipple[I915_STPREG_ST1];
+
+ st1 &= ~ST1_ENABLE;
+
+ switch (rprim) {
+ case GL_TRIANGLES:
+ if (intel->ctx.Polygon.StippleFlag &&
+ intel->hw_stipple)
+ st1 |= ST1_ENABLE;
+ break;
+ case GL_LINES:
+ case GL_POINTS:
+ default:
+ break;
+ }
+
+ i915->intel.reduced_primitive = rprim;
+
+ if (st1 != i915->state.Stipple[I915_STPREG_ST1]) {
+ I915_STATECHANGE(i915, I915_UPLOAD_STIPPLE);
+ i915->state.Stipple[I915_STPREG_ST1] = st1;
+ }
+}
+
+
+/* Pull apart the vertex format registers and figure out how large a
+ * vertex is supposed to be.
+ */
+static GLboolean i915_check_vertex_size( intelContextPtr intel,
+ GLuint expected )
+{
+ i915ContextPtr i915 = I915_CONTEXT(intel);
+ int lis2 = i915->current->Ctx[I915_CTXREG_LIS2];
+ int lis4 = i915->current->Ctx[I915_CTXREG_LIS4];
+ int i, sz = 0;
+
+ switch (lis4 & S4_VFMT_XYZW_MASK) {
+ case S4_VFMT_XY: sz = 2; break;
+ case S4_VFMT_XYZ: sz = 3; break;
+ case S4_VFMT_XYW: sz = 3; break;
+ case S4_VFMT_XYZW: sz = 4; break;
+ default:
+ fprintf(stderr, "no xyzw specified\n");
+ return 0;
+ }
+
+ if (lis4 & S4_VFMT_SPEC_FOG) sz++;
+ if (lis4 & S4_VFMT_COLOR) sz++;
+ if (lis4 & S4_VFMT_DEPTH_OFFSET) sz++;
+ if (lis4 & S4_VFMT_POINT_WIDTH) sz++;
+ if (lis4 & S4_VFMT_FOG_PARAM) sz++;
+
+ for (i = 0 ; i < 8 ; i++) {
+ switch (lis2 & S2_TEXCOORD_FMT0_MASK) {
+ case TEXCOORDFMT_2D: sz += 2; break;
+ case TEXCOORDFMT_3D: sz += 3; break;
+ case TEXCOORDFMT_4D: sz += 4; break;
+ case TEXCOORDFMT_1D: sz += 1; break;
+ case TEXCOORDFMT_2D_16: sz += 1; break;
+ case TEXCOORDFMT_4D_16: sz += 2; break;
+ case TEXCOORDFMT_NOT_PRESENT: break;
+ default:
+ fprintf(stderr, "bad texcoord fmt %d\n", i);
+ return GL_FALSE;
+ }
+ lis2 >>= S2_TEXCOORD_FMT1_SHIFT;
+ }
+
+ if (sz != expected)
+ fprintf(stderr, "vertex size mismatch %d/%d\n", sz, expected);
+
+ return sz == expected;
+}
+
+
+static void i915_emit_invarient_state( intelContextPtr intel )
+{
+ BATCH_LOCALS;
+
+ BEGIN_BATCH( 200 );
+
+ OUT_BATCH(_3DSTATE_AA_CMD |
+ AA_LINE_ECAAR_WIDTH_ENABLE |
+ AA_LINE_ECAAR_WIDTH_1_0 |
+ AA_LINE_REGION_WIDTH_ENABLE |
+ AA_LINE_REGION_WIDTH_1_0);
+
+ OUT_BATCH(_3DSTATE_DFLT_DIFFUSE_CMD);
+ OUT_BATCH(0);
+
+ OUT_BATCH(_3DSTATE_DFLT_SPEC_CMD);
+ OUT_BATCH(0);
+
+ OUT_BATCH(_3DSTATE_DFLT_Z_CMD);
+ OUT_BATCH(0);
+
+ /* Don't support texture crossbar yet */
+ OUT_BATCH(_3DSTATE_COORD_SET_BINDINGS |
+ CSB_TCB(0, 0) |
+ CSB_TCB(1, 1) |
+ CSB_TCB(2, 2) |
+ CSB_TCB(3, 3) |
+ CSB_TCB(4, 4) |
+ CSB_TCB(5, 5) |
+ CSB_TCB(6, 6) |
+ CSB_TCB(7, 7));
+
+ OUT_BATCH(_3DSTATE_RASTER_RULES_CMD |
+ ENABLE_POINT_RASTER_RULE |
+ OGL_POINT_RASTER_RULE |
+ ENABLE_LINE_STRIP_PROVOKE_VRTX |
+ ENABLE_TRI_FAN_PROVOKE_VRTX |
+ LINE_STRIP_PROVOKE_VRTX(1) |
+ TRI_FAN_PROVOKE_VRTX(2) |
+ ENABLE_TEXKILL_3D_4D |
+ TEXKILL_4D);
+
+ /* Need to initialize this to zero.
+ */
+ OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
+ I1_LOAD_S(3) |
+ (1));
+ OUT_BATCH(0);
+
+ /* XXX: Use this */
+ OUT_BATCH(_3DSTATE_SCISSOR_ENABLE_CMD |
+ DISABLE_SCISSOR_RECT);
+
+ OUT_BATCH(_3DSTATE_SCISSOR_RECT_0_CMD);
+ OUT_BATCH(0);
+ OUT_BATCH(0);
+
+ OUT_BATCH(_3DSTATE_DEPTH_SUBRECT_DISABLE);
+
+ OUT_BATCH(_3DSTATE_LOAD_INDIRECT | 0); /* disable indirect state */
+ OUT_BATCH(0);
+
+
+ /* Don't support twosided stencil yet */
+ OUT_BATCH(_3DSTATE_BACKFACE_STENCIL_OPS |
+ BFO_ENABLE_STENCIL_TWO_SIDE |
+ 0 );
+
+ ADVANCE_BATCH();
+}
+
+
+#define emit( intel, state, size ) \
+do { \
+ int k; \
+ BEGIN_BATCH( (size) / sizeof(GLuint)); \
+ for (k = 0 ; k < (size) / sizeof(GLuint) ; k++) \
+ OUT_BATCH((state)[k]); \
+ ADVANCE_BATCH(); \
+} while (0);
+
+
+/* Push the state into the sarea and/or texture memory.
+ */
+static void i915_emit_state( intelContextPtr intel )
+{
+ i915ContextPtr i915 = I915_CONTEXT(intel);
+ struct i915_hw_state *state = i915->current;
+ int i;
+ GLuint dirty;
+ BATCH_LOCALS;
+
+ /* More to workaround the multitex hang - if one texture unit state
+ * is modified, emit all texture units.
+ */
+ dirty = state->active & ~state->emitted;
+ if (dirty & I915_UPLOAD_TEX_ALL)
+ state->emitted &= ~I915_UPLOAD_TEX_ALL;
+ dirty = state->active & ~state->emitted;
+
+
+ if (VERBOSE)
+ fprintf(stderr, "%s dirty: %x\n", __FUNCTION__, dirty);
+
+ if (dirty & I915_UPLOAD_CTX) {
+ if (VERBOSE) fprintf(stderr, "I915_UPLOAD_CTX:\n");
+ emit( i915, state->Ctx, sizeof(state->Ctx) );
+ }
+
+ if (dirty & I915_UPLOAD_BUFFERS) {
+ if (VERBOSE) fprintf(stderr, "I915_UPLOAD_BUFFERS:\n");
+ emit( i915, state->Buffer, sizeof(state->Buffer) );
+ }
+
+ if (dirty & I915_UPLOAD_STIPPLE) {
+ if (VERBOSE) fprintf(stderr, "I915_UPLOAD_STIPPLE:\n");
+ emit( i915, state->Stipple, sizeof(state->Stipple) );
+ }
+
+ if (dirty & I915_UPLOAD_FOG) {
+ if (VERBOSE) fprintf(stderr, "I915_UPLOAD_FOG:\n");
+ emit( i915, state->Fog, sizeof(state->Fog) );
+ }
+
+ /* Combine all the dirty texture state into a single command to
+ * avoid lockups on I915 hardware.
+ */
+ if (dirty & I915_UPLOAD_TEX_ALL) {
+ int nr = 0;
+
+ for (i = 0; i < I915_TEX_UNITS; i++)
+ if (dirty & I915_UPLOAD_TEX(i))
+ nr++;
+
+ BEGIN_BATCH(2+nr*3);
+ OUT_BATCH(_3DSTATE_MAP_STATE | (3*nr));
+ OUT_BATCH((dirty & I915_UPLOAD_TEX_ALL) >> I915_UPLOAD_TEX_0_SHIFT);
+ for (i = 0 ; i < I915_TEX_UNITS ; i++)
+ if (dirty & I915_UPLOAD_TEX(i)) {
+ OUT_BATCH(state->Tex[i][I915_TEXREG_MS2]);
+ OUT_BATCH(state->Tex[i][I915_TEXREG_MS3]);
+ OUT_BATCH(state->Tex[i][I915_TEXREG_MS4]);
+ }
+ ADVANCE_BATCH();
+
+ BEGIN_BATCH(2+nr*3);
+ OUT_BATCH(_3DSTATE_SAMPLER_STATE | (3*nr));
+ OUT_BATCH((dirty & I915_UPLOAD_TEX_ALL) >> I915_UPLOAD_TEX_0_SHIFT);
+ for (i = 0 ; i < I915_TEX_UNITS ; i++)
+ if (dirty & I915_UPLOAD_TEX(i)) {
+ OUT_BATCH(state->Tex[i][I915_TEXREG_SS2]);
+ OUT_BATCH(state->Tex[i][I915_TEXREG_SS3]);
+ OUT_BATCH(state->Tex[i][I915_TEXREG_SS4]);
+ }
+ ADVANCE_BATCH();
+ }
+
+ if (dirty & I915_UPLOAD_CONSTANTS) {
+ if (VERBOSE) fprintf(stderr, "I915_UPLOAD_CONSTANTS:\n");
+ emit( i915, state->Constant, state->ConstantSize * sizeof(GLuint) );
+ }
+
+ if (dirty & I915_UPLOAD_PROGRAM) {
+ if (VERBOSE) fprintf(stderr, "I915_UPLOAD_PROGRAM:\n");
+
+ assert((state->Program[0] & 0x1ff)+2 == state->ProgramSize);
+
+ emit( i915, state->Program, state->ProgramSize * sizeof(GLuint) );
+ if (VERBOSE)
+ i915_disassemble_program( state->Program, state->ProgramSize );
+ }
+
+ state->emitted |= dirty;
+}
+
+static void i915_destroy_context( intelContextPtr intel )
+{
+ _tnl_free_vertices(&intel->ctx);
+}
+
+static void i915_set_draw_offset( intelContextPtr intel, int offset )
+{
+ i915ContextPtr i915 = I915_CONTEXT(intel);
+ I915_STATECHANGE( i915, I915_UPLOAD_BUFFERS );
+ i915->state.Buffer[I915_DESTREG_CBUFADDR2] = offset;
+}
+
+static void i915_lost_hardware( intelContextPtr intel )
+{
+ I915_CONTEXT(intel)->state.emitted = 0;
+}
+
+static void i915_emit_flush( intelContextPtr intel )
+{
+ BATCH_LOCALS;
+
+ BEGIN_BATCH(2);
+ OUT_BATCH( MI_FLUSH | FLUSH_MAP_CACHE | FLUSH_RENDER_CACHE );
+ OUT_BATCH( 0 );
+ ADVANCE_BATCH();
+}
+
+
+void i915InitVtbl( i915ContextPtr i915 )
+{
+ i915->intel.vtbl.alloc_tex_obj = i915AllocTexObj;
+ i915->intel.vtbl.check_vertex_size = i915_check_vertex_size;
+ i915->intel.vtbl.clear_with_tris = i915ClearWithTris;
+ i915->intel.vtbl.destroy = i915_destroy_context;
+ i915->intel.vtbl.emit_invarient_state = i915_emit_invarient_state;
+ i915->intel.vtbl.emit_state = i915_emit_state;
+ i915->intel.vtbl.lost_hardware = i915_lost_hardware;
+ i915->intel.vtbl.reduced_primitive_state = i915_reduced_primitive_state;
+ i915->intel.vtbl.render_start = i915_render_start;
+ i915->intel.vtbl.set_draw_offset = i915_set_draw_offset;
+ i915->intel.vtbl.update_texture_state = i915UpdateTextureState;
+ i915->intel.vtbl.emit_flush = i915_emit_flush;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_batchbuffer.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_batchbuffer.c
new file mode 100644
index 000000000..7c9ad87be
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_batchbuffer.c
@@ -0,0 +1,688 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+
+#include <stdio.h>
+#include <errno.h>
+
+#include "mtypes.h"
+#include "context.h"
+#include "enums.h"
+
+#include "intel_reg.h"
+#include "intel_batchbuffer.h"
+#include "intel_context.h"
+
+
+
+
+/* ================================================================
+ * Performance monitoring functions
+ */
+
+static void intel_fill_box( intelContextPtr intel,
+ GLshort x, GLshort y,
+ GLshort w, GLshort h,
+ GLubyte r, GLubyte g, GLubyte b )
+{
+ intelEmitFillBlitLocked( intel,
+ intel->intelScreen->cpp,
+ intel->intelScreen->backPitch,
+ intel->intelScreen->frontOffset,
+ x, y, w, h,
+ INTEL_PACKCOLOR(intel->intelScreen->fbFormat,
+ r,g,b,0xff));
+}
+
+static void intel_draw_performance_boxes( intelContextPtr intel )
+{
+ /* Purple box for page flipping
+ */
+ if ( intel->perf_boxes & I830_BOX_FLIP )
+ intel_fill_box( intel, 4, 4, 8, 8, 255, 0, 255 );
+
+ /* Red box if we have to wait for idle at any point
+ */
+ if ( intel->perf_boxes & I830_BOX_WAIT )
+ intel_fill_box( intel, 16, 4, 8, 8, 255, 0, 0 );
+
+ /* Blue box: lost context?
+ */
+ if ( intel->perf_boxes & I830_BOX_LOST_CONTEXT )
+ intel_fill_box( intel, 28, 4, 8, 8, 0, 0, 255 );
+
+ /* Yellow box for texture swaps
+ */
+ if ( intel->perf_boxes & I830_BOX_TEXTURE_LOAD )
+ intel_fill_box( intel, 40, 4, 8, 8, 255, 255, 0 );
+
+ /* Green box if hardware never idles (as far as we can tell)
+ */
+ if ( !(intel->perf_boxes & I830_BOX_RING_EMPTY) )
+ intel_fill_box( intel, 64, 4, 8, 8, 0, 255, 0 );
+
+
+ /* Draw bars indicating number of buffers allocated
+ * (not a great measure, easily confused)
+ */
+#if 0
+ if (intel->dma_used) {
+ int bar = intel->dma_used / 10240;
+ if (bar > 100) bar = 100;
+ if (bar < 1) bar = 1;
+ intel_fill_box( intel, 4, 16, bar, 4, 196, 128, 128 );
+ intel->dma_used = 0;
+ }
+#endif
+
+ intel->perf_boxes = 0;
+}
+
+
+
+
+
+
+static int bad_prim_vertex_nr( int primitive, int nr )
+{
+ switch (primitive & PRIM3D_MASK) {
+ case PRIM3D_POINTLIST:
+ return nr < 1;
+ case PRIM3D_LINELIST:
+ return (nr & 1) || nr == 0;
+ case PRIM3D_LINESTRIP:
+ return nr < 2;
+ case PRIM3D_TRILIST:
+ case PRIM3D_RECTLIST:
+ return nr % 3 || nr == 0;
+ case PRIM3D_POLY:
+ case PRIM3D_TRIFAN:
+ case PRIM3D_TRISTRIP:
+ case PRIM3D_TRISTRIP_RVRSE:
+ return nr < 3;
+ default:
+ return 1;
+ }
+}
+
+static void intel_flush_inline_primitive( GLcontext *ctx )
+{
+ intelContextPtr intel = INTEL_CONTEXT( ctx );
+ GLuint used = intel->batch.ptr - intel->prim.start_ptr;
+ GLuint vertcount;
+
+ assert(intel->prim.primitive != ~0);
+
+ if (1) {
+ /* Check vertex size against the vertex we're specifying to
+ * hardware. If it's wrong, ditch the primitive.
+ */
+ if (!intel->vtbl.check_vertex_size( intel, intel->vertex_size ))
+ goto do_discard;
+
+ vertcount = (used - 4)/ (intel->vertex_size * 4);
+
+ if (!vertcount)
+ goto do_discard;
+
+ if (vertcount * intel->vertex_size * 4 != used - 4) {
+ fprintf(stderr, "vertex size confusion %d %d\n", used,
+ intel->vertex_size * vertcount * 4);
+ goto do_discard;
+ }
+
+ if (bad_prim_vertex_nr( intel->prim.primitive, vertcount )) {
+ fprintf(stderr, "bad_prim_vertex_nr %x %d\n", intel->prim.primitive,
+ vertcount);
+ goto do_discard;
+ }
+ }
+
+ if (used < 8)
+ goto do_discard;
+
+ *(int *)intel->prim.start_ptr = (_3DPRIMITIVE |
+ intel->prim.primitive |
+ (used/4-2));
+
+ goto finished;
+
+ do_discard:
+ intel->batch.ptr -= used;
+ intel->batch.space += used;
+ assert(intel->batch.space >= 0);
+
+ finished:
+ intel->prim.primitive = ~0;
+ intel->prim.start_ptr = 0;
+ intel->prim.flush = 0;
+}
+
+
+/* Emit a primitive referencing vertices in a vertex buffer.
+ */
+void intelStartInlinePrimitive( intelContextPtr intel, GLuint prim )
+{
+ BATCH_LOCALS;
+
+ if (0)
+ fprintf(stderr, "%s %x\n", __FUNCTION__, prim);
+
+
+ /* Finish any in-progress primitive:
+ */
+ INTEL_FIREVERTICES( intel );
+
+ /* Emit outstanding state:
+ */
+ intel->vtbl.emit_state( intel );
+
+ /* Make sure there is some space in this buffer:
+ */
+ if (intel->vertex_size * 10 * sizeof(GLuint) >= intel->batch.space)
+ intelFlushBatch(intel, GL_TRUE);
+
+
+#if 1
+ if (((int)intel->batch.ptr) & 0x4) {
+ BEGIN_BATCH(1);
+ OUT_BATCH(0);
+ ADVANCE_BATCH();
+ }
+#endif
+
+ /* Emit a slot which will be filled with the inline primitive
+ * command later.
+ */
+ BEGIN_BATCH(2);
+ OUT_BATCH( 0 );
+
+ intel->prim.start_ptr = batch_ptr;
+ intel->prim.primitive = prim;
+ intel->prim.flush = intel_flush_inline_primitive;
+
+ OUT_BATCH( 0 );
+ ADVANCE_BATCH();
+}
+
+
+void intelRestartInlinePrimitive( intelContextPtr intel )
+{
+ GLuint prim = intel->prim.primitive;
+
+ intel_flush_inline_primitive( &intel->ctx );
+ if (1) intelFlushBatch(intel, GL_TRUE); /* GL_TRUE - is critical */
+ intelStartInlinePrimitive( intel, prim );
+}
+
+
+
+void intelWrapInlinePrimitive( intelContextPtr intel )
+{
+ GLuint prim = intel->prim.primitive;
+
+ if (0)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+ intel_flush_inline_primitive( &intel->ctx );
+ intelFlushBatch(intel, GL_TRUE);
+ intelStartInlinePrimitive( intel, prim );
+}
+
+
+/* Emit a primitive with space for inline vertices.
+ */
+GLuint *intelEmitInlinePrimitiveLocked(intelContextPtr intel,
+ int primitive,
+ int dwords,
+ int vertex_size )
+{
+ GLuint *tmp = 0;
+ BATCH_LOCALS;
+
+ if (0)
+ fprintf(stderr, "%s 0x%x %d\n", __FUNCTION__, primitive, dwords);
+
+ /* Emit outstanding state:
+ */
+ intel->vtbl.emit_state( intel );
+
+
+ if (1) {
+ int used = dwords * 4;
+ int vertcount;
+
+ /* Check vertex size against the vertex we're specifying to
+ * hardware. If it's wrong, ditch the primitive.
+ */
+ if (!intel->vtbl.check_vertex_size( intel, vertex_size ))
+ goto do_discard;
+
+ vertcount = dwords / vertex_size;
+
+ if (dwords % vertex_size) {
+ fprintf(stderr, "did not request a whole number of vertices\n");
+ goto do_discard;
+ }
+
+ if (bad_prim_vertex_nr( primitive, vertcount )) {
+ fprintf(stderr, "bad_prim_vertex_nr %x %d\n", primitive, vertcount);
+ goto do_discard;
+ }
+
+ if (used < 8)
+ goto do_discard;
+ }
+
+ /* Emit 3D_PRIMITIVE commands:
+ */
+ BEGIN_BATCH(1 + dwords);
+ OUT_BATCH( _3DPRIMITIVE |
+ primitive |
+ (dwords-1) );
+
+ tmp = (GLuint *)batch_ptr;
+ batch_ptr += dwords * 4;
+
+ ADVANCE_BATCH();
+
+ do_discard:
+ return tmp;
+}
+
+
+
+/*
+ * Copy the back buffer to the front buffer.
+ */
+void intelCopyBuffer( const __DRIdrawablePrivate *dPriv )
+{
+ intelContextPtr intel;
+
+ if (0)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ intel = (intelContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ intelFlush( &intel->ctx );
+ LOCK_HARDWARE( intel );
+ {
+ intelScreenPrivate *intelScreen = intel->intelScreen;
+ __DRIdrawablePrivate *dPriv = intel->driDrawable;
+ int nbox = dPriv->numClipRects;
+ drm_clip_rect_t *pbox = dPriv->pClipRects;
+ int pitch = intelScreen->frontPitch;
+ int cpp = intelScreen->cpp;
+ int i;
+ GLuint CMD, BR13;
+ BATCH_LOCALS;
+
+ switch(cpp) {
+ case 2:
+ BR13 = (pitch * cpp) | (0xCC << 16) | (1<<24);
+ CMD = XY_SRC_COPY_BLT_CMD;
+ break;
+ case 4:
+ BR13 = (pitch * cpp) | (0xCC << 16) | (1<<24) | (1<<25);
+ CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA |
+ XY_SRC_COPY_BLT_WRITE_RGB);
+ break;
+ default:
+ BR13 = (pitch * cpp) | (0xCC << 16) | (1<<24);
+ CMD = XY_SRC_COPY_BLT_CMD;
+ break;
+ }
+
+ if (0)
+ intel_draw_performance_boxes( intel );
+
+ for (i = 0 ; i < nbox; i++, pbox++)
+ {
+ if (pbox->x1 > pbox->x2 ||
+ pbox->y1 > pbox->y2 ||
+ pbox->x2 > intelScreen->width ||
+ pbox->y2 > intelScreen->height)
+ continue;
+
+ BEGIN_BATCH( 8);
+ OUT_BATCH( CMD );
+ OUT_BATCH( BR13 );
+ OUT_BATCH( (pbox->y1 << 16) | pbox->x1 );
+ OUT_BATCH( (pbox->y2 << 16) | pbox->x2 );
+
+ if (intel->sarea->pf_current_page == 0)
+ OUT_BATCH( intelScreen->frontOffset );
+ else
+ OUT_BATCH( intelScreen->backOffset );
+
+ OUT_BATCH( (pbox->y1 << 16) | pbox->x1 );
+ OUT_BATCH( BR13 & 0xffff );
+
+ if (intel->sarea->pf_current_page == 0)
+ OUT_BATCH( intelScreen->backOffset );
+ else
+ OUT_BATCH( intelScreen->frontOffset );
+
+ ADVANCE_BATCH();
+ }
+ }
+ intelFlushBatchLocked( intel, GL_TRUE, GL_TRUE, GL_TRUE );
+ UNLOCK_HARDWARE( intel );
+}
+
+
+
+
+void intelEmitFillBlitLocked( intelContextPtr intel,
+ GLuint cpp,
+ GLshort dst_pitch,
+ GLuint dst_offset,
+ GLshort x, GLshort y,
+ GLshort w, GLshort h,
+ GLuint color )
+{
+ GLuint BR13, CMD;
+ BATCH_LOCALS;
+
+ dst_pitch *= cpp;
+
+ switch(cpp) {
+ case 1:
+ case 2:
+ case 3:
+ BR13 = dst_pitch | (0xF0 << 16) | (1<<24);
+ CMD = XY_COLOR_BLT_CMD;
+ break;
+ case 4:
+ BR13 = dst_pitch | (0xF0 << 16) | (1<<24) | (1<<25);
+ CMD = (XY_COLOR_BLT_CMD | XY_COLOR_BLT_WRITE_ALPHA |
+ XY_COLOR_BLT_WRITE_RGB);
+ break;
+ default:
+ return;
+ }
+
+ BEGIN_BATCH( 6);
+ OUT_BATCH( CMD );
+ OUT_BATCH( BR13 );
+ OUT_BATCH( (y << 16) | x );
+ OUT_BATCH( ((y+h) << 16) | (x+w) );
+ OUT_BATCH( dst_offset );
+ OUT_BATCH( color );
+ ADVANCE_BATCH();
+}
+
+
+/* Copy BitBlt
+ */
+void intelEmitCopyBlitLocked( intelContextPtr intel,
+ GLuint cpp,
+ GLshort src_pitch,
+ GLuint src_offset,
+ GLshort dst_pitch,
+ GLuint dst_offset,
+ GLshort src_x, GLshort src_y,
+ GLshort dst_x, GLshort dst_y,
+ GLshort w, GLshort h )
+{
+ GLuint CMD, BR13;
+ int dst_y2 = dst_y + h;
+ int dst_x2 = dst_x + w;
+ BATCH_LOCALS;
+
+ src_pitch *= cpp;
+ dst_pitch *= cpp;
+
+ switch(cpp) {
+ case 1:
+ case 2:
+ case 3:
+ BR13 = dst_pitch | (0xCC << 16) | (1<<24);
+ CMD = XY_SRC_COPY_BLT_CMD;
+ break;
+ case 4:
+ BR13 = dst_pitch | (0xCC << 16) | (1<<24) | (1<<25);
+ CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA |
+ XY_SRC_COPY_BLT_WRITE_RGB);
+ break;
+ default:
+ return;
+ }
+
+ if (dst_y2 < dst_y ||
+ dst_x2 < dst_x) {
+ return;
+ }
+
+ BEGIN_BATCH( 12);
+ OUT_BATCH( CMD );
+ OUT_BATCH( BR13 );
+ OUT_BATCH( (dst_y << 16) | dst_x );
+ OUT_BATCH( (dst_y2 << 16) | dst_x2 );
+ OUT_BATCH( dst_offset );
+ OUT_BATCH( (src_y << 16) | src_x );
+ OUT_BATCH( src_pitch );
+ OUT_BATCH( src_offset );
+ ADVANCE_BATCH();
+}
+
+
+
+void intelClearWithBlit(GLcontext *ctx, GLbitfield flags, GLboolean all,
+ GLint cx1, GLint cy1, GLint cw, GLint ch)
+{
+ intelContextPtr intel = INTEL_CONTEXT( ctx );
+ intelScreenPrivate *intelScreen = intel->intelScreen;
+ GLuint clear_depth, clear_color;
+ GLint cx, cy;
+ GLint pitch = intelScreen->frontPitch;
+ GLint cpp = intelScreen->cpp;
+ GLint i;
+ GLuint BR13, CMD, D_CMD;
+ BATCH_LOCALS;
+
+
+ clear_color = intel->ClearColor;
+ clear_depth = 0;
+
+ if (flags & BUFFER_BIT_DEPTH) {
+ clear_depth = (GLuint)(ctx->Depth.Clear * intel->ClearDepth);
+ }
+
+ if (flags & BUFFER_BIT_STENCIL) {
+ clear_depth |= (ctx->Stencil.Clear & 0xff) << 24;
+ }
+
+ switch(cpp) {
+ case 2:
+ BR13 = (0xF0 << 16) | (pitch * cpp) | (1<<24);
+ D_CMD = CMD = XY_COLOR_BLT_CMD;
+ break;
+ case 4:
+ BR13 = (0xF0 << 16) | (pitch * cpp) | (1<<24) | (1<<25);
+ CMD = (XY_COLOR_BLT_CMD |
+ XY_COLOR_BLT_WRITE_ALPHA |
+ XY_COLOR_BLT_WRITE_RGB);
+ D_CMD = XY_COLOR_BLT_CMD;
+ if (flags & BUFFER_BIT_DEPTH) D_CMD |= XY_COLOR_BLT_WRITE_RGB;
+ if (flags & BUFFER_BIT_STENCIL) D_CMD |= XY_COLOR_BLT_WRITE_ALPHA;
+ break;
+ default:
+ BR13 = (0xF0 << 16) | (pitch * cpp) | (1<<24);
+ D_CMD = CMD = XY_COLOR_BLT_CMD;
+ break;
+ }
+
+ intelFlush( &intel->ctx );
+ LOCK_HARDWARE( intel );
+ {
+ /* flip top to bottom */
+ cy = intel->driDrawable->h-cy1-ch;
+ cx = cx1 + intel->drawX;
+ cy += intel->drawY;
+
+ /* adjust for page flipping */
+ if ( intel->sarea->pf_current_page == 1 ) {
+ GLuint tmp = flags;
+
+ flags &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT);
+ if ( tmp & BUFFER_BIT_FRONT_LEFT ) flags |= BUFFER_BIT_BACK_LEFT;
+ if ( tmp & BUFFER_BIT_BACK_LEFT ) flags |= BUFFER_BIT_FRONT_LEFT;
+ }
+
+ for (i = 0 ; i < intel->numClipRects ; i++)
+ {
+ drm_clip_rect_t *box = &intel->pClipRects[i];
+ drm_clip_rect_t b;
+
+ if (!all) {
+ GLint x = box[i].x1;
+ GLint y = box[i].y1;
+ GLint w = box[i].x2 - x;
+ GLint h = box[i].y2 - y;
+
+ 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) continue;
+ if (h <= 0) continue;
+
+ b.x1 = x;
+ b.y1 = y;
+ b.x2 = x + w;
+ b.y2 = y + h;
+ } else {
+ b = *box;
+ }
+
+
+ if (b.x1 > b.x2 ||
+ b.y1 > b.y2 ||
+ b.x2 > intelScreen->width ||
+ b.y2 > intelScreen->height)
+ continue;
+
+ if ( flags & BUFFER_BIT_FRONT_LEFT ) {
+ BEGIN_BATCH( 6);
+ OUT_BATCH( CMD );
+ OUT_BATCH( BR13 );
+ OUT_BATCH( (b.y1 << 16) | b.x1 );
+ OUT_BATCH( (b.y2 << 16) | b.x2 );
+ OUT_BATCH( intelScreen->frontOffset );
+ OUT_BATCH( clear_color );
+ ADVANCE_BATCH();
+ }
+
+ if ( flags & BUFFER_BIT_BACK_LEFT ) {
+ BEGIN_BATCH( 6);
+ OUT_BATCH( CMD );
+ OUT_BATCH( BR13 );
+ OUT_BATCH( (b.y1 << 16) | b.x1 );
+ OUT_BATCH( (b.y2 << 16) | b.x2 );
+ OUT_BATCH( intelScreen->backOffset );
+ OUT_BATCH( clear_color );
+ ADVANCE_BATCH();
+ }
+
+ if ( flags & (BUFFER_BIT_STENCIL | BUFFER_BIT_DEPTH) ) {
+ BEGIN_BATCH( 6);
+ OUT_BATCH( D_CMD );
+ OUT_BATCH( BR13 );
+ OUT_BATCH( (b.y1 << 16) | b.x1 );
+ OUT_BATCH( (b.y2 << 16) | b.x2 );
+ OUT_BATCH( intelScreen->depthOffset );
+ OUT_BATCH( clear_depth );
+ ADVANCE_BATCH();
+ }
+ }
+ }
+ intelFlushBatchLocked( intel, GL_TRUE, GL_FALSE, GL_TRUE );
+ UNLOCK_HARDWARE( intel );
+}
+
+
+
+
+void intelDestroyBatchBuffer( GLcontext *ctx )
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+
+ if (intel->alloc.ptr) {
+ intelFreeAGP( intel, intel->alloc.ptr );
+ intel->alloc.ptr = 0;
+ }
+}
+
+
+void intelInitBatchBuffer( GLcontext *ctx )
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+
+ if (!intel->intelScreen->allow_batchbuffer || getenv("INTEL_NO_BATCH")) {
+ intel->alloc.size = 8 * 1024;
+ intel->alloc.ptr = malloc( intel->alloc.size );
+ intel->alloc.offset = 0;
+ }
+ else {
+ switch (intel->intelScreen->deviceID) {
+ case PCI_CHIP_I865_G:
+ /* HW bug? Seems to crash if batchbuffer crosses 4k boundary.
+ */
+ intel->alloc.size = 8 * 1024;
+ break;
+ default:
+ /* This is the smallest amount of memory the kernel deals with.
+ * We'd ideally like to make this smaller.
+ */
+ intel->alloc.size = 1 << intel->intelScreen->logTextureGranularity;
+ break;
+ }
+
+ intel->alloc.ptr = intelAllocateAGP( intel, intel->alloc.size );
+ if (intel->alloc.ptr)
+ intel->alloc.offset =
+ intelAgpOffsetFromVirtual( intel, intel->alloc.ptr );
+ }
+
+ if (!intel->alloc.ptr) {
+ FALLBACK(intel, INTEL_FALLBACK_NO_BATCHBUFFER, 1);
+ }
+ else {
+ intel->prim.flush = 0;
+ intel->vtbl.emit_invarient_state( intel );
+
+ /* Make sure this gets to the hardware, even if we have no cliprects:
+ */
+ LOCK_HARDWARE( intel );
+ intelFlushBatchLocked( intel, GL_TRUE, GL_FALSE, GL_TRUE );
+ UNLOCK_HARDWARE( intel );
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_batchbuffer.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_batchbuffer.h
new file mode 100644
index 000000000..bd879af15
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_batchbuffer.h
@@ -0,0 +1,123 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#ifndef INTEL_BATCHBUFFER_H
+#define INTEL_BATCHBUFFER_H
+
+#include "intel_context.h"
+#include "intel_ioctl.h"
+
+
+#define BATCH_LOCALS GLubyte *batch_ptr;
+
+/* #define VERBOSE 0 */
+#ifndef VERBOSE
+extern int VERBOSE;
+#endif
+
+
+#define BEGIN_BATCH(n) \
+do { \
+ if (VERBOSE) fprintf(stderr, \
+ "BEGIN_BATCH(%d) in %s, %d dwords free\n", \
+ (n), __FUNCTION__, intel->batch.space/4); \
+ if (intel->batch.space < (n)*4) \
+ intelFlushBatch(intel, GL_TRUE); \
+ batch_ptr = intel->batch.ptr; \
+} while (0)
+
+#define OUT_BATCH(n) \
+do { \
+ *(GLuint *)batch_ptr = (n); \
+ if (VERBOSE) fprintf(stderr, " -- %08x at %s/%d\n", (n), __FILE__, __LINE__); \
+ batch_ptr += 4; \
+} while (0)
+
+#define ADVANCE_BATCH() \
+do { \
+ if (VERBOSE) fprintf(stderr, "ADVANCE_BATCH()\n"); \
+ intel->batch.space -= (batch_ptr - intel->batch.ptr); \
+ intel->batch.ptr = batch_ptr; \
+ assert(intel->batch.space >= 0); \
+} while(0)
+
+extern void intelInitBatchBuffer( GLcontext *ctx );
+extern void intelDestroyBatchBuffer( GLcontext *ctx );
+
+extern void intelStartInlinePrimitive( intelContextPtr intel, GLuint prim );
+extern void intelWrapInlinePrimitive( intelContextPtr intel );
+extern void intelRestartInlinePrimitive( intelContextPtr intel );
+extern GLuint *intelEmitInlinePrimitiveLocked(intelContextPtr intel,
+ int primitive, int dwords,
+ int vertex_size);
+extern void intelCopyBuffer( const __DRIdrawablePrivate *dpriv );
+extern void intelClearWithBlit(GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx1, GLint cy1, GLint cw, GLint ch);
+
+extern void intelEmitCopyBlitLocked( intelContextPtr intel,
+ GLuint cpp,
+ GLshort src_pitch,
+ GLuint src_offset,
+ GLshort dst_pitch,
+ GLuint dst_offset,
+ GLshort srcx, GLshort srcy,
+ GLshort dstx, GLshort dsty,
+ GLshort w, GLshort h );
+
+extern void intelEmitFillBlitLocked( intelContextPtr intel,
+ GLuint cpp,
+ GLshort dst_pitch,
+ GLuint dst_offset,
+ GLshort x, GLshort y,
+ GLshort w, GLshort h,
+ GLuint color );
+
+
+
+
+static __inline GLuint *intelExtendInlinePrimitive( intelContextPtr intel,
+ GLuint dwords )
+{
+ GLuint sz = dwords * sizeof(GLuint);
+ GLuint *ptr;
+
+ if (intel->batch.space < sz) {
+ intelWrapInlinePrimitive( intel );
+/* assert(intel->batch.space >= sz); */
+ }
+
+/* assert(intel->prim.primitive != ~0); */
+ ptr = (GLuint *)intel->batch.ptr;
+ intel->batch.ptr += sz;
+ intel->batch.space -= sz;
+
+ return ptr;
+}
+
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_context.c
new file mode 100644
index 000000000..bdf02c766
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_context.c
@@ -0,0 +1,712 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+
+#include "glheader.h"
+#include "context.h"
+#include "matrix.h"
+#include "simple_list.h"
+#include "extensions.h"
+#include "framebuffer.h"
+#include "imports.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "array_cache/acache.h"
+
+#include "tnl/t_pipeline.h"
+#include "tnl/t_vertex.h"
+
+#include "drivers/common/driverfuncs.h"
+
+#include "intel_screen.h"
+
+#include "i830_dri.h"
+#include "i830_common.h"
+
+#include "intel_tex.h"
+#include "intel_span.h"
+#include "intel_tris.h"
+#include "intel_ioctl.h"
+#include "intel_batchbuffer.h"
+
+#include "utils.h"
+#ifndef INTEL_DEBUG
+int INTEL_DEBUG = (0);
+#endif
+
+#define need_GL_ARB_multisample
+#define need_GL_ARB_point_parameters
+#define need_GL_ARB_texture_compression
+#define need_GL_ARB_vertex_buffer_object
+#define need_GL_ARB_vertex_program
+#define need_GL_ARB_window_pos
+#define need_GL_EXT_blend_color
+#define need_GL_EXT_blend_equation_separate
+#define need_GL_EXT_blend_func_separate
+#define need_GL_EXT_blend_minmax
+#define need_GL_EXT_cull_vertex
+#define need_GL_EXT_fog_coord
+#define need_GL_EXT_multi_draw_arrays
+#define need_GL_EXT_secondary_color
+#define need_GL_NV_vertex_program
+#include "extension_helper.h"
+
+#ifndef VERBOSE
+int VERBOSE = 0;
+#endif
+
+#if DEBUG_LOCKING
+char *prevLockFile;
+int prevLockLine;
+#endif
+
+/***************************************
+ * Mesa's Driver Functions
+ ***************************************/
+
+#define DRIVER_DATE "20050225"
+
+const GLubyte *intelGetString( GLcontext *ctx, GLenum name )
+{
+ const char * chipset;
+ static char buffer[128];
+
+ switch (name) {
+ case GL_VENDOR:
+ return (GLubyte *)"Tungsten Graphics, Inc";
+ break;
+
+ case GL_RENDERER:
+ switch (INTEL_CONTEXT(ctx)->intelScreen->deviceID) {
+ case PCI_CHIP_845_G:
+ chipset = "Intel(R) 845G"; break;
+ case PCI_CHIP_I830_M:
+ chipset = "Intel(R) 830M"; break;
+ case PCI_CHIP_I855_GM:
+ chipset = "Intel(R) 852GM/855GM"; break;
+ case PCI_CHIP_I865_G:
+ chipset = "Intel(R) 865G"; break;
+ case PCI_CHIP_I915_G:
+ chipset = "Intel(R) 915G"; break;
+ case PCI_CHIP_I915_GM:
+ chipset = "Intel(R) 915GM"; break;
+ case PCI_CHIP_I945_G:
+ chipset = "Intel(R) 945G"; break;
+ default:
+ chipset = "Unknown Intel Chipset"; break;
+ }
+
+ (void) driGetRendererString( buffer, chipset, DRIVER_DATE, 0 );
+ return (GLubyte *) buffer;
+
+ default:
+ return NULL;
+ }
+}
+
+static void intelBufferSize(GLframebuffer *buffer,
+ GLuint *width, GLuint *height)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+ /* Need to lock to make sure the driDrawable is uptodate. This
+ * information is used to resize Mesa's software buffers, so it has
+ * to be correct.
+ */
+ LOCK_HARDWARE(intel);
+ *width = intel->driDrawable->w;
+ *height = intel->driDrawable->h;
+ UNLOCK_HARDWARE(intel);
+}
+
+
+/**
+ * Extension strings exported by the intel driver.
+ *
+ * \note
+ * It appears that ARB_texture_env_crossbar has "disappeared" compared to the
+ * old i830-specific driver.
+ */
+const struct dri_extension card_extensions[] =
+{
+ { "GL_ARB_multisample", GL_ARB_multisample_functions },
+ { "GL_ARB_multitexture", NULL },
+ { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions },
+ { "GL_ARB_texture_border_clamp", NULL },
+ { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions },
+ { "GL_ARB_texture_cube_map", NULL },
+ { "GL_ARB_texture_env_add", NULL },
+ { "GL_ARB_texture_env_combine", NULL },
+ { "GL_ARB_texture_env_dot3", NULL },
+ { "GL_ARB_texture_mirrored_repeat", NULL },
+ { "GL_ARB_texture_rectangle", NULL },
+ { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions },
+ { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions },
+ { "GL_ARB_window_pos", GL_ARB_window_pos_functions },
+ { "GL_EXT_blend_color", GL_EXT_blend_color_functions },
+ { "GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions },
+ { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions },
+ { "GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions },
+ { "GL_EXT_blend_subtract", NULL },
+ { "GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions },
+ { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions },
+ { "GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions },
+ { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions },
+ { "GL_EXT_stencil_wrap", NULL },
+ { "GL_EXT_texture_edge_clamp", NULL },
+ { "GL_EXT_texture_env_combine", NULL },
+ { "GL_EXT_texture_env_dot3", NULL },
+ { "GL_EXT_texture_filter_anisotropic", NULL },
+ { "GL_EXT_texture_lod_bias", NULL },
+ { "GL_3DFX_texture_compression_FXT1", NULL },
+ { "GL_APPLE_client_storage", NULL },
+ { "GL_MESA_pack_invert", NULL },
+ { "GL_MESA_ycbcr_texture", NULL },
+ { "GL_NV_blend_square", NULL },
+ { "GL_NV_vertex_program", GL_NV_vertex_program_functions },
+ { "GL_NV_vertex_program1_1", NULL },
+ { "GL_SGIS_generate_mipmap", NULL },
+ { NULL, NULL }
+};
+
+extern const struct tnl_pipeline_stage _intel_render_stage;
+
+static const struct tnl_pipeline_stage *intel_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_vertex_cull_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ &_tnl_point_attenuation_stage,
+ &_tnl_arb_vertex_program_stage,
+ &_tnl_vertex_program_stage,
+#if 1
+ &_intel_render_stage, /* ADD: unclipped rastersetup-to-dma */
+#endif
+ &_tnl_render_stage,
+ 0,
+};
+
+
+static const struct dri_debug_control debug_control[] =
+{
+ { "fall", DEBUG_FALLBACKS },
+ { "tex", DEBUG_TEXTURE },
+ { "ioctl", DEBUG_IOCTL },
+ { "prim", DEBUG_PRIMS },
+ { "vert", DEBUG_VERTS },
+ { "state", DEBUG_STATE },
+ { "verb", DEBUG_VERBOSE },
+ { "dri", DEBUG_DRI },
+ { "dma", DEBUG_DMA },
+ { "san", DEBUG_SANITY },
+ { "sync", DEBUG_SYNC },
+ { "sleep", DEBUG_SLEEP },
+ { "pix", DEBUG_PIXEL },
+ { NULL, 0 }
+};
+
+
+static void intelInvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ _tnl_invalidate_vertex_state( ctx, new_state );
+ INTEL_CONTEXT(ctx)->NewGLState |= new_state;
+}
+
+
+void intelInitDriverFunctions( struct dd_function_table *functions )
+{
+ _mesa_init_driver_functions( functions );
+
+ functions->Flush = intelFlush;
+ functions->Clear = intelClear;
+ functions->Finish = intelFinish;
+ functions->GetBufferSize = intelBufferSize;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
+ functions->GetString = intelGetString;
+ functions->UpdateState = intelInvalidateState;
+ functions->CopyColorTable = _swrast_CopyColorTable;
+ functions->CopyColorSubTable = _swrast_CopyColorSubTable;
+ functions->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ functions->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+
+ intelInitTextureFuncs( functions );
+ intelInitPixelFuncs( functions );
+ intelInitStateFuncs( functions );
+}
+
+
+
+GLboolean intelInitContext( intelContextPtr intel,
+ const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate,
+ struct dd_function_table *functions )
+{
+ GLcontext *ctx = &intel->ctx;
+ GLcontext *shareCtx = (GLcontext *) sharedContextPrivate;
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ intelScreenPrivate *intelScreen = (intelScreenPrivate *)sPriv->private;
+ drmI830Sarea *saPriv = (drmI830Sarea *)
+ (((GLubyte *)sPriv->pSAREA)+intelScreen->sarea_priv_offset);
+
+ if (!_mesa_initialize_context(&intel->ctx,
+ mesaVis, shareCtx,
+ functions,
+ (void*) intel))
+ return GL_FALSE;
+
+ driContextPriv->driverPrivate = intel;
+ intel->intelScreen = intelScreen;
+ intel->driScreen = sPriv;
+ intel->sarea = saPriv;
+
+
+ (void) memset( intel->texture_heaps, 0, sizeof( intel->texture_heaps ) );
+ make_empty_list( & intel->swapped );
+
+ ctx->Const.MaxTextureMaxAnisotropy = 2.0;
+
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 3.0;
+ ctx->Const.MaxLineWidthAA = 3.0;
+ ctx->Const.LineWidthGranularity = 1.0;
+
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = 255.0;
+ ctx->Const.MaxPointSizeAA = 3.0;
+ ctx->Const.PointSizeGranularity = 1.0;
+
+ /* Initialize the software rasterizer and helper modules. */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+
+ /* Install the customized pipeline: */
+ _tnl_destroy_pipeline( ctx );
+ _tnl_install_pipeline( ctx, intel_pipeline );
+
+ /* Configure swrast to match hardware characteristics: */
+ _swrast_allow_pixel_fog( ctx, GL_FALSE );
+ _swrast_allow_vertex_fog( ctx, GL_TRUE );
+
+ /* Dri stuff */
+ intel->hHWContext = driContextPriv->hHWContext;
+ intel->driFd = sPriv->fd;
+ intel->driHwLock = (drmLock *) &sPriv->pSAREA->lock;
+
+ intel->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;
+ intel->hw_stipple = 1;
+
+ switch(mesaVis->depthBits) {
+ case 0: /* what to do in this case? */
+ case 16:
+ intel->depth_scale = 1.0/0xffff;
+ intel->polygon_offset_scale = 1.0/0xffff;
+ intel->depth_clear_mask = ~0;
+ intel->ClearDepth = 0xffff;
+ break;
+ case 24:
+ intel->depth_scale = 1.0/0xffffff;
+ intel->polygon_offset_scale = 2.0/0xffffff; /* req'd to pass glean */
+ intel->depth_clear_mask = 0x00ffffff;
+ intel->stencil_clear_mask = 0xff000000;
+ intel->ClearDepth = 0x00ffffff;
+ break;
+ default:
+ assert(0);
+ break;
+ }
+
+ /* Initialize swrast, tnl driver tables: */
+ intelInitSpanFuncs( ctx );
+ intelInitTriFuncs( ctx );
+
+
+ intel->RenderIndex = ~0;
+
+ intel->do_irqs = (intel->intelScreen->irq_active &&
+ !getenv("INTEL_NO_IRQS"));
+
+ _math_matrix_ctr (&intel->ViewportMatrix);
+
+ driInitExtensions( ctx, card_extensions, GL_TRUE );
+
+ if (intel->ctx.Mesa_DXTn) {
+ _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
+ _mesa_enable_extension( ctx, "GL_S3_s3tc" );
+ }
+ else if (driQueryOptionb (&intelScreen->optionCache, "force_s3tc_enable")) {
+ _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
+ }
+
+/* driInitTextureObjects( ctx, & intel->swapped, */
+/* DRI_TEXMGR_DO_TEXTURE_1D | */
+/* DRI_TEXMGR_DO_TEXTURE_2D | */
+/* DRI_TEXMGR_DO_TEXTURE_RECT ); */
+
+
+ intel->prim.flush = intelInitBatchBuffer;
+ intel->prim.primitive = ~0;
+
+
+#if DO_DEBUG
+ INTEL_DEBUG = driParseDebugString( getenv( "INTEL_DEBUG" ),
+ debug_control );
+ INTEL_DEBUG |= driParseDebugString( getenv( "INTEL_DEBUG" ),
+ debug_control );
+#endif
+
+#ifndef VERBOSE
+ if (getenv("INTEL_VERBOSE"))
+ VERBOSE=1;
+#endif
+
+ if (getenv("INTEL_NO_RAST") ||
+ getenv("INTEL_NO_RAST")) {
+ fprintf(stderr, "disabling 3D rasterization\n");
+ FALLBACK(intel, INTEL_FALLBACK_USER, 1);
+ }
+
+ return GL_TRUE;
+}
+
+void intelDestroyContext(__DRIcontextPrivate *driContextPriv)
+{
+ intelContextPtr intel = (intelContextPtr) driContextPriv->driverPrivate;
+
+ assert(intel); /* should never be null */
+ if (intel) {
+ GLboolean release_texture_heaps;
+
+
+ intel->vtbl.destroy( intel );
+
+ release_texture_heaps = (intel->ctx.Shared->RefCount == 1);
+ _swsetup_DestroyContext (&intel->ctx);
+ _tnl_DestroyContext (&intel->ctx);
+ _ac_DestroyContext (&intel->ctx);
+
+ _swrast_DestroyContext (&intel->ctx);
+ intel->Fallback = 0; /* don't call _swrast_Flush later */
+
+ intelDestroyBatchBuffer(&intel->ctx);
+
+
+ if ( release_texture_heaps ) {
+ /* This share group is about to go away, free our private
+ * texture object data.
+ */
+ int i;
+
+ for ( i = 0 ; i < intel->nr_heaps ; i++ ) {
+ driDestroyTextureHeap( intel->texture_heaps[ i ] );
+ intel->texture_heaps[ i ] = NULL;
+ }
+
+ assert( is_empty_list( & intel->swapped ) );
+ }
+
+ /* free the Mesa context */
+ _mesa_destroy_context(&intel->ctx);
+ }
+}
+
+void intelSetFrontClipRects( intelContextPtr intel )
+{
+ __DRIdrawablePrivate *dPriv = intel->driDrawable;
+
+ if (!dPriv) return;
+
+ intel->numClipRects = dPriv->numClipRects;
+ intel->pClipRects = dPriv->pClipRects;
+ intel->drawX = dPriv->x;
+ intel->drawY = dPriv->y;
+}
+
+
+void intelSetBackClipRects( intelContextPtr intel )
+{
+ __DRIdrawablePrivate *dPriv = intel->driDrawable;
+
+ if (!dPriv) return;
+
+ if (intel->sarea->pf_enabled == 0 && dPriv->numBackClipRects == 0) {
+ intel->numClipRects = dPriv->numClipRects;
+ intel->pClipRects = dPriv->pClipRects;
+ intel->drawX = dPriv->x;
+ intel->drawY = dPriv->y;
+ } else {
+ intel->numClipRects = dPriv->numBackClipRects;
+ intel->pClipRects = dPriv->pBackClipRects;
+ intel->drawX = dPriv->backX;
+ intel->drawY = dPriv->backY;
+
+ if (dPriv->numBackClipRects == 1 &&
+ dPriv->x == dPriv->backX &&
+ dPriv->y == dPriv->backY) {
+
+ /* Repeat the calculation of the back cliprect dimensions here
+ * as early versions of dri.a in the Xserver are incorrect. Try
+ * very hard not to restrict future versions of dri.a which
+ * might eg. allocate truly private back buffers.
+ */
+ int x1, y1;
+ int x2, y2;
+
+ x1 = dPriv->x;
+ y1 = dPriv->y;
+ x2 = dPriv->x + dPriv->w;
+ y2 = dPriv->y + dPriv->h;
+
+ if (x1 < 0) x1 = 0;
+ if (y1 < 0) y1 = 0;
+ if (x2 > intel->intelScreen->width) x2 = intel->intelScreen->width;
+ if (y2 > intel->intelScreen->height) y2 = intel->intelScreen->height;
+
+ if (x1 == dPriv->pBackClipRects[0].x1 &&
+ y1 == dPriv->pBackClipRects[0].y1) {
+
+ dPriv->pBackClipRects[0].x2 = x2;
+ dPriv->pBackClipRects[0].y2 = y2;
+ }
+ }
+ }
+}
+
+
+void intelWindowMoved( intelContextPtr intel )
+{
+ if (!intel->ctx.DrawBuffer) {
+ intelSetFrontClipRects( intel );
+ }
+ else {
+ switch (intel->ctx.DrawBuffer->_ColorDrawBufferMask[0]) {
+ case BUFFER_BIT_FRONT_LEFT:
+ intelSetFrontClipRects( intel );
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ intelSetBackClipRects( intel );
+ break;
+ default:
+ /* glDrawBuffer(GL_NONE or GL_FRONT_AND_BACK): software fallback */
+ intelSetFrontClipRects( intel );
+ }
+ }
+}
+
+GLboolean intelUnbindContext(__DRIcontextPrivate *driContextPriv)
+{
+ return GL_TRUE;
+}
+
+GLboolean intelMakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
+{
+
+ if (driContextPriv) {
+ intelContextPtr intel = (intelContextPtr) driContextPriv->driverPrivate;
+
+ if ( intel->driDrawable != driDrawPriv ) {
+ /* Shouldn't the readbuffer be stored also? */
+ intel->driDrawable = driDrawPriv;
+ intelWindowMoved( intel );
+ }
+
+ _mesa_make_current(&intel->ctx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate);
+
+ intel->ctx.Driver.DrawBuffer( &intel->ctx, intel->ctx.Color.DrawBuffer[0] );
+ } else {
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ return GL_TRUE;
+}
+
+void intelGetLock( intelContextPtr intel, GLuint flags )
+{
+ __DRIdrawablePrivate *dPriv = intel->driDrawable;
+ __DRIscreenPrivate *sPriv = intel->driScreen;
+ drmI830Sarea * sarea = intel->sarea;
+ int me = intel->hHWContext;
+ unsigned i;
+
+ drmGetLock(intel->driFd, intel->hHWContext, flags);
+
+ /* 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:
+ */
+ if (dPriv)
+ DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
+
+ /* 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) {
+ intel->perf_boxes |= I830_BOX_LOST_CONTEXT;
+ sarea->ctxOwner = me;
+ }
+
+ /* Shared texture managment - if another client has played with
+ * texture space, figure out which if any of our textures have been
+ * ejected, and update our global LRU.
+ */
+
+ for ( i = 0 ; i < intel->nr_heaps ; i++ ) {
+ DRI_AGE_TEXTURES( intel->texture_heaps[ i ] );
+ }
+
+ if (dPriv && intel->lastStamp != dPriv->lastStamp) {
+ intelWindowMoved( intel );
+ intel->lastStamp = dPriv->lastStamp;
+ }
+}
+
+void intelSwapBuffers( __DRIdrawablePrivate *dPriv )
+{
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ intelContextPtr intel;
+ GLcontext *ctx;
+ intel = (intelContextPtr) dPriv->driContextPriv->driverPrivate;
+ ctx = &intel->ctx;
+ if (ctx->Visual.doubleBufferMode) {
+ _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
+ if ( 0 /*intel->doPageFlip*/ ) { /* doPageFlip is never set !!! */
+ intelPageFlip( dPriv );
+ } else {
+ intelCopyBuffer( dPriv );
+ }
+ }
+ } else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ fprintf(stderr, "%s: drawable has no context!\n", __FUNCTION__);
+ }
+}
+
+
+void intelInitState( GLcontext *ctx )
+{
+ /* Mesa should do this for us:
+ */
+ ctx->Driver.AlphaFunc( ctx,
+ ctx->Color.AlphaFunc,
+ ctx->Color.AlphaRef);
+
+ ctx->Driver.BlendColor( ctx,
+ ctx->Color.BlendColor );
+
+ ctx->Driver.BlendEquationSeparate( ctx,
+ ctx->Color.BlendEquationRGB,
+ ctx->Color.BlendEquationA);
+
+ ctx->Driver.BlendFuncSeparate( ctx,
+ ctx->Color.BlendSrcRGB,
+ ctx->Color.BlendDstRGB,
+ ctx->Color.BlendSrcA,
+ ctx->Color.BlendDstA);
+
+ ctx->Driver.ColorMask( ctx,
+ ctx->Color.ColorMask[RCOMP],
+ ctx->Color.ColorMask[GCOMP],
+ ctx->Color.ColorMask[BCOMP],
+ ctx->Color.ColorMask[ACOMP]);
+
+ ctx->Driver.CullFace( ctx, ctx->Polygon.CullFaceMode );
+ ctx->Driver.DepthFunc( ctx, ctx->Depth.Func );
+ ctx->Driver.DepthMask( ctx, ctx->Depth.Mask );
+
+ ctx->Driver.Enable( ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled );
+ ctx->Driver.Enable( ctx, GL_BLEND, ctx->Color.BlendEnabled );
+ ctx->Driver.Enable( ctx, GL_COLOR_LOGIC_OP, ctx->Color.ColorLogicOpEnabled );
+ ctx->Driver.Enable( ctx, GL_COLOR_SUM, ctx->Fog.ColorSumEnabled );
+ ctx->Driver.Enable( ctx, GL_CULL_FACE, ctx->Polygon.CullFlag );
+ ctx->Driver.Enable( ctx, GL_DEPTH_TEST, ctx->Depth.Test );
+ ctx->Driver.Enable( ctx, GL_DITHER, ctx->Color.DitherFlag );
+ ctx->Driver.Enable( ctx, GL_FOG, ctx->Fog.Enabled );
+ ctx->Driver.Enable( ctx, GL_LIGHTING, ctx->Light.Enabled );
+ ctx->Driver.Enable( ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag );
+ ctx->Driver.Enable( ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag );
+ ctx->Driver.Enable( ctx, GL_SCISSOR_TEST, ctx->Scissor.Enabled );
+ ctx->Driver.Enable( ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled );
+ ctx->Driver.Enable( ctx, GL_TEXTURE_1D, GL_FALSE );
+ ctx->Driver.Enable( ctx, GL_TEXTURE_2D, GL_FALSE );
+ ctx->Driver.Enable( ctx, GL_TEXTURE_RECTANGLE_NV, GL_FALSE );
+ ctx->Driver.Enable( ctx, GL_TEXTURE_3D, GL_FALSE );
+ ctx->Driver.Enable( ctx, GL_TEXTURE_CUBE_MAP, GL_FALSE );
+
+ ctx->Driver.Fogfv( ctx, GL_FOG_COLOR, ctx->Fog.Color );
+ ctx->Driver.Fogfv( ctx, GL_FOG_MODE, 0 );
+ ctx->Driver.Fogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );
+ ctx->Driver.Fogfv( ctx, GL_FOG_START, &ctx->Fog.Start );
+ ctx->Driver.Fogfv( ctx, GL_FOG_END, &ctx->Fog.End );
+
+ ctx->Driver.FrontFace( ctx, ctx->Polygon.FrontFace );
+
+ {
+ GLfloat f = (GLfloat)ctx->Light.Model.ColorControl;
+ ctx->Driver.LightModelfv( ctx, GL_LIGHT_MODEL_COLOR_CONTROL, &f );
+ }
+
+ ctx->Driver.LineWidth( ctx, ctx->Line.Width );
+ ctx->Driver.LogicOpcode( ctx, ctx->Color.LogicOp );
+ ctx->Driver.PointSize( ctx, ctx->Point.Size );
+ ctx->Driver.PolygonStipple( ctx, (const GLubyte *)ctx->PolygonStipple );
+ ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y,
+ ctx->Scissor.Width, ctx->Scissor.Height );
+ ctx->Driver.ShadeModel( ctx, ctx->Light.ShadeModel );
+ ctx->Driver.StencilFunc( ctx,
+ ctx->Stencil.Function[0],
+ ctx->Stencil.Ref[0],
+ ctx->Stencil.ValueMask[0] );
+ ctx->Driver.StencilMask( ctx, ctx->Stencil.WriteMask[0] );
+ ctx->Driver.StencilOp( ctx,
+ ctx->Stencil.FailFunc[0],
+ ctx->Stencil.ZFailFunc[0],
+ ctx->Stencil.ZPassFunc[0]);
+
+
+ ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_context.h
new file mode 100644
index 000000000..da1ef701b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_context.h
@@ -0,0 +1,519 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#ifndef INTELCONTEXT_INC
+#define INTELCONTEXT_INC
+
+
+
+#include "mtypes.h"
+#include "drm.h"
+#include "mm.h"
+#include "texmem.h"
+
+#include "intel_screen.h"
+#include "i830_common.h"
+#include "tnl/t_vertex.h"
+
+#define TAG(x) intel##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+#define DV_PF_555 (1<<8)
+#define DV_PF_565 (2<<8)
+#define DV_PF_8888 (3<<8)
+
+#define INTEL_CONTEXT(ctx) ((intelContextPtr)(ctx))
+
+typedef struct intel_context intelContext;
+typedef struct intel_context *intelContextPtr;
+typedef struct intel_texture_object *intelTextureObjectPtr;
+
+typedef void (*intel_tri_func)(intelContextPtr, intelVertex *, intelVertex *,
+ intelVertex *);
+typedef void (*intel_line_func)(intelContextPtr, intelVertex *, intelVertex *);
+typedef void (*intel_point_func)(intelContextPtr, intelVertex *);
+
+#define INTEL_FALLBACK_DRAW_BUFFER 0x1
+#define INTEL_FALLBACK_READ_BUFFER 0x2
+#define INTEL_FALLBACK_USER 0x4
+#define INTEL_FALLBACK_NO_BATCHBUFFER 0x8
+#define INTEL_FALLBACK_NO_TEXMEM 0x10
+#define INTEL_FALLBACK_RENDERMODE 0x20
+
+extern void intelFallback( intelContextPtr intel, GLuint bit, GLboolean mode );
+#define FALLBACK( intel, bit, mode ) intelFallback( intel, bit, mode )
+
+
+#define INTEL_TEX_MAXLEVELS 10
+
+
+struct intel_texture_object
+{
+ driTextureObject base; /* the parent class */
+
+ GLuint texelBytes;
+ GLuint age;
+ GLuint Pitch;
+ GLuint Height;
+ GLuint TextureOffset;
+ GLubyte *BufAddr;
+
+ GLuint min_level;
+ GLuint max_level;
+ GLuint depth_pitch;
+
+ struct {
+ const struct gl_texture_image *image;
+ GLuint offset; /* into BufAddr */
+ GLuint height;
+ GLuint internalFormat;
+ } image[6][INTEL_TEX_MAXLEVELS];
+
+ GLuint dirty;
+ GLuint firstLevel,lastLevel;
+};
+
+
+struct intel_context
+{
+ GLcontext ctx; /* the parent class */
+
+ struct {
+ void (*destroy)( intelContextPtr intel );
+ void (*emit_state)( intelContextPtr intel );
+ void (*emit_invarient_state)( intelContextPtr intel );
+ void (*lost_hardware)( intelContextPtr intel );
+ void (*update_texture_state)( intelContextPtr intel );
+
+ void (*render_start)( intelContextPtr intel );
+ void (*set_draw_offset)( intelContextPtr intel, int offset );
+ void (*emit_flush)( intelContextPtr intel );
+
+ void (*reduced_primitive_state)( intelContextPtr intel, GLenum rprim );
+
+ GLboolean (*check_vertex_size)( intelContextPtr intel, GLuint expected );
+
+ void (*clear_with_tris)( intelContextPtr intel, GLbitfield mask,
+ GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch);
+
+ intelTextureObjectPtr (*alloc_tex_obj)( struct gl_texture_object *tObj );
+
+ } vtbl;
+
+ GLint refcount;
+ GLuint Fallback;
+ GLuint NewGLState;
+
+ struct {
+ GLuint start_offset;
+ GLint size;
+ GLint space;
+ GLubyte *ptr;
+ } batch;
+
+ struct {
+ void *ptr;
+ GLint size;
+ GLuint offset;
+ GLuint active_buf;
+ GLuint irq_emitted;
+ } alloc;
+
+ struct {
+ GLuint primitive;
+ GLubyte *start_ptr;
+ void (*flush)( GLcontext * );
+ } prim;
+
+ GLboolean locked;
+
+ GLubyte clear_red;
+ GLubyte clear_green;
+ GLubyte clear_blue;
+ GLubyte clear_alpha;
+ GLuint ClearColor;
+ GLuint ClearDepth;
+
+ GLuint coloroffset;
+ GLuint specoffset;
+
+ /* Support for duplicating XYZW as WPOS parameter (crutch for I915).
+ */
+ GLuint wpos_offset;
+ GLuint wpos_size;
+
+ struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
+ GLuint vertex_attr_count;
+
+ GLfloat depth_scale;
+ GLfloat polygon_offset_scale; /* dependent on depth_scale, bpp */
+ GLuint depth_clear_mask;
+ GLuint stencil_clear_mask;
+
+ GLboolean hw_stencil;
+ GLboolean hw_stipple;
+
+ /* Texture object bookkeeping
+ */
+ GLuint nr_heaps;
+ driTexHeap * texture_heaps[1];
+ driTextureObject swapped;
+ GLuint lastStamp;
+
+ struct intel_texture_object *CurrentTexObj[MAX_TEXTURE_UNITS];
+
+ /* State for intelvb.c and inteltris.c.
+ */
+ GLuint RenderIndex;
+ GLmatrix ViewportMatrix;
+ GLenum render_primitive;
+ GLenum reduced_primitive;
+ GLuint vertex_size;
+ char *verts; /* points to tnl->clipspace.vertex_buf */
+
+
+ /* Fallback rasterization functions
+ */
+ intel_point_func draw_point;
+ intel_line_func draw_line;
+ intel_tri_func draw_tri;
+
+ /* These refer to the current draw (front vs. back) buffer:
+ */
+ char *drawMap; /* draw buffer address in virtual mem */
+ char *readMap;
+ GLuint drawOffset; /* agp offset of drawbuffer */
+ int drawX; /* origin of drawable in draw buffer */
+ int drawY;
+ GLuint numClipRects; /* cliprects for that buffer */
+ drm_clip_rect_t *pClipRects;
+
+ int dirtyAge;
+ int perf_boxes;
+ int do_irqs;
+
+ GLboolean scissor;
+ drm_clip_rect_t draw_rect;
+ drm_clip_rect_t scissor_rect;
+
+ drm_context_t hHWContext;
+ drmLock *driHwLock;
+ int driFd;
+
+ __DRIdrawablePrivate *driDrawable;
+ __DRIscreenPrivate *driScreen;
+ intelScreenPrivate *intelScreen;
+ drmI830Sarea *sarea;
+
+ /**
+ * Configuration cache
+ */
+ driOptionCache optionCache;
+};
+
+
+#define DEBUG_LOCKING 1
+
+#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)
+
+/* Slightly less broken way of detecting recursive locking in a
+ * threaded environment. The right way to do this would be to make
+ * prevLockFile, prevLockLine thread-local.
+ *
+ * This technique instead checks to see if the same context is
+ * requesting the lock twice -- this will not catch application
+ * breakages where the same context is active in two different threads
+ * at once, but it will catch driver breakages (recursive locking) in
+ * threaded apps.
+ */
+#define DEBUG_CHECK_LOCK() \
+ do { \
+ if ( *((volatile int *)intel->driHwLock) == \
+ (DRM_LOCK_HELD | intel->hHWContext) ) { \
+ fprintf( stderr, \
+ "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \
+ prevLockFile, prevLockLine, __FILE__, __LINE__ ); \
+ abort(); \
+ } \
+ } while (0)
+
+#else
+
+#define DEBUG_LOCK()
+#define DEBUG_RESET()
+#define DEBUG_CHECK_LOCK()
+
+#endif
+
+
+
+
+/* Lock the hardware and validate our state.
+ */
+#define LOCK_HARDWARE( intel ) \
+do { \
+ char __ret=0; \
+ DEBUG_CHECK_LOCK(); \
+ assert(!(intel)->locked); \
+ DRM_CAS((intel)->driHwLock, (intel)->hHWContext, \
+ (DRM_LOCK_HELD|(intel)->hHWContext), __ret); \
+ if (__ret) \
+ intelGetLock( (intel), 0 ); \
+ DEBUG_LOCK(); \
+ (intel)->locked = 1; \
+}while (0)
+
+
+ /* Unlock the hardware using the global current context
+ */
+#define UNLOCK_HARDWARE(intel) \
+do { \
+ intel->locked = 0; \
+ if (0) { \
+ intel->perf_boxes |= intel->sarea->perf_boxes; \
+ intel->sarea->perf_boxes = 0; \
+ } \
+ DRM_UNLOCK((intel)->driFd, (intel)->driHwLock, (intel)->hHWContext); \
+ DEBUG_RESET(); \
+} while (0)
+
+
+#define SUBPIXEL_X 0.125
+#define SUBPIXEL_Y 0.125
+
+#define INTEL_FIREVERTICES(intel) \
+do { \
+ if ((intel)->prim.flush) \
+ (intel)->prim.flush(&(intel)->ctx); \
+} while (0)
+
+/* ================================================================
+ * Color packing:
+ */
+
+#define INTEL_PACKCOLOR4444(r,g,b,a) \
+ ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
+
+#define INTEL_PACKCOLOR1555(r,g,b,a) \
+ ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
+ ((a) ? 0x8000 : 0))
+
+#define INTEL_PACKCOLOR565(r,g,b) \
+ ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
+
+#define INTEL_PACKCOLOR8888(r,g,b,a) \
+ ((a<<24) | (r<<16) | (g<<8) | b)
+
+
+#define INTEL_PACKCOLOR(format, r, g, b, a) \
+(format == DV_PF_555 ? INTEL_PACKCOLOR1555(r,g,b,a) : \
+ (format == DV_PF_565 ? INTEL_PACKCOLOR565(r,g,b) : \
+ (format == DV_PF_8888 ? INTEL_PACKCOLOR8888(r,g,b,a) : \
+ 0)))
+
+
+
+/* ================================================================
+ * From linux kernel i386 header files, copes with odd sizes better
+ * than COPY_DWORDS would:
+ */
+#if defined(i386) || defined(__i386__)
+static __inline__ void * __memcpy(void * to, const void * from, size_t n)
+{
+ int d0, d1, d2;
+ __asm__ __volatile__(
+ "rep ; movsl\n\t"
+ "testb $2,%b4\n\t"
+ "je 1f\n\t"
+ "movsw\n"
+ "1:\ttestb $1,%b4\n\t"
+ "je 2f\n\t"
+ "movsb\n"
+ "2:"
+ : "=&c" (d0), "=&D" (d1), "=&S" (d2)
+ :"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
+ : "memory");
+ return (to);
+}
+#else
+#define __memcpy(a,b,c) memcpy(a,b,c)
+#endif
+
+
+
+/* ================================================================
+ * Debugging:
+ */
+#define DO_DEBUG 1
+#if DO_DEBUG
+extern int INTEL_DEBUG;
+#else
+#define INTEL_DEBUG 0
+#endif
+
+#define DEBUG_TEXTURE 0x1
+#define DEBUG_STATE 0x2
+#define DEBUG_IOCTL 0x4
+#define DEBUG_PRIMS 0x8
+#define DEBUG_VERTS 0x10
+#define DEBUG_FALLBACKS 0x20
+#define DEBUG_VERBOSE 0x40
+#define DEBUG_DRI 0x80
+#define DEBUG_DMA 0x100
+#define DEBUG_SANITY 0x200
+#define DEBUG_SYNC 0x400
+#define DEBUG_SLEEP 0x800
+#define DEBUG_PIXEL 0x1000
+
+
+#define PCI_CHIP_845_G 0x2562
+#define PCI_CHIP_I830_M 0x3577
+#define PCI_CHIP_I855_GM 0x3582
+#define PCI_CHIP_I865_G 0x2572
+#define PCI_CHIP_I915_G 0x2582
+#define PCI_CHIP_I915_GM 0x2592
+#define PCI_CHIP_I945_G 0x2772
+
+
+/* ================================================================
+ * intel_context.c:
+ */
+
+extern void intelInitDriverFunctions( struct dd_function_table *functions );
+
+extern GLboolean intelInitContext( intelContextPtr intel,
+ const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate,
+ struct dd_function_table *functions );
+
+extern void intelGetLock(intelContextPtr intel, GLuint flags);
+extern void intelSetBackClipRects(intelContextPtr intel);
+extern void intelSetFrontClipRects(intelContextPtr intel);
+extern void intelWindowMoved( intelContextPtr intel );
+
+extern void intelInitState( GLcontext *ctx );
+extern const GLubyte *intelGetString( GLcontext *ctx, GLenum name );
+
+
+/* ================================================================
+ * intel_state.c:
+ */
+extern void intelInitStateFuncs( struct dd_function_table *functions );
+
+#define COMPAREFUNC_ALWAYS 0
+#define COMPAREFUNC_NEVER 0x1
+#define COMPAREFUNC_LESS 0x2
+#define COMPAREFUNC_EQUAL 0x3
+#define COMPAREFUNC_LEQUAL 0x4
+#define COMPAREFUNC_GREATER 0x5
+#define COMPAREFUNC_NOTEQUAL 0x6
+#define COMPAREFUNC_GEQUAL 0x7
+
+#define STENCILOP_KEEP 0
+#define STENCILOP_ZERO 0x1
+#define STENCILOP_REPLACE 0x2
+#define STENCILOP_INCRSAT 0x3
+#define STENCILOP_DECRSAT 0x4
+#define STENCILOP_INCR 0x5
+#define STENCILOP_DECR 0x6
+#define STENCILOP_INVERT 0x7
+
+#define LOGICOP_CLEAR 0
+#define LOGICOP_NOR 0x1
+#define LOGICOP_AND_INV 0x2
+#define LOGICOP_COPY_INV 0x3
+#define LOGICOP_AND_RVRSE 0x4
+#define LOGICOP_INV 0x5
+#define LOGICOP_XOR 0x6
+#define LOGICOP_NAND 0x7
+#define LOGICOP_AND 0x8
+#define LOGICOP_EQUIV 0x9
+#define LOGICOP_NOOP 0xa
+#define LOGICOP_OR_INV 0xb
+#define LOGICOP_COPY 0xc
+#define LOGICOP_OR_RVRSE 0xd
+#define LOGICOP_OR 0xe
+#define LOGICOP_SET 0xf
+
+#define BLENDFACT_ZERO 0x01
+#define BLENDFACT_ONE 0x02
+#define BLENDFACT_SRC_COLR 0x03
+#define BLENDFACT_INV_SRC_COLR 0x04
+#define BLENDFACT_SRC_ALPHA 0x05
+#define BLENDFACT_INV_SRC_ALPHA 0x06
+#define BLENDFACT_DST_ALPHA 0x07
+#define BLENDFACT_INV_DST_ALPHA 0x08
+#define BLENDFACT_DST_COLR 0x09
+#define BLENDFACT_INV_DST_COLR 0x0a
+#define BLENDFACT_SRC_ALPHA_SATURATE 0x0b
+#define BLENDFACT_CONST_COLOR 0x0c
+#define BLENDFACT_INV_CONST_COLOR 0x0d
+#define BLENDFACT_CONST_ALPHA 0x0e
+#define BLENDFACT_INV_CONST_ALPHA 0x0f
+#define BLENDFACT_MASK 0x0f
+
+
+extern int intel_translate_compare_func( GLenum func );
+extern int intel_translate_stencil_op( GLenum op );
+extern int intel_translate_blend_factor( GLenum factor );
+extern int intel_translate_logic_op( GLenum opcode );
+
+
+/* ================================================================
+ * intel_ioctl.c:
+ */
+extern void intel_dump_batchbuffer( long offset,
+ int *ptr,
+ int count );
+
+
+/* ================================================================
+ * intel_pixel.c:
+ */
+extern void intelInitPixelFuncs( struct dd_function_table *functions );
+
+
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_ioctl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_ioctl.c
new file mode 100644
index 000000000..83bb77f38
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_ioctl.c
@@ -0,0 +1,607 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sched.h>
+
+#include "mtypes.h"
+#include "context.h"
+#include "swrast/swrast.h"
+
+#include "intel_context.h"
+#include "intel_ioctl.h"
+#include "intel_batchbuffer.h"
+#include "drm.h"
+
+
+
+static int intelEmitIrqLocked( intelContextPtr intel )
+{
+ drmI830IrqEmit ie;
+ int ret, seq = 0;
+
+ assert(((*(int *)intel->driHwLock) & ~DRM_LOCK_CONT) ==
+ (DRM_LOCK_HELD|intel->hHWContext));
+
+ ie.irq_seq = &seq;
+
+ ret = drmCommandWriteRead( intel->driFd, DRM_I830_IRQ_EMIT,
+ &ie, sizeof(ie) );
+ if ( ret ) {
+ fprintf( stderr, "%s: drmI830IrqEmit: %d\n", __FUNCTION__, ret );
+ exit(1);
+ }
+
+ if (0)
+ fprintf(stderr, "%s --> %d\n", __FUNCTION__, seq );
+
+ return seq;
+}
+
+static void intelWaitIrq( intelContextPtr intel, int seq )
+{
+ drmI830IrqWait iw;
+ int ret;
+
+ if (0)
+ fprintf(stderr, "%s %d\n", __FUNCTION__, seq );
+
+ iw.irq_seq = seq;
+
+ do {
+ ret = drmCommandWrite( intel->driFd, DRM_I830_IRQ_WAIT, &iw, sizeof(iw) );
+ } while (ret == -EAGAIN || ret == -EINTR);
+
+ if ( ret ) {
+ fprintf( stderr, "%s: drmI830IrqWait: %d\n", __FUNCTION__, ret );
+ if (0)
+ intel_dump_batchbuffer( intel->alloc.offset,
+ intel->alloc.ptr,
+ intel->alloc.size );
+ exit(1);
+ }
+}
+
+
+
+static void age_intel( intelContextPtr intel, int age )
+{
+ GLuint i;
+
+ for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++)
+ if (intel->CurrentTexObj[i])
+ intel->CurrentTexObj[i]->age = age;
+}
+
+void intel_dump_batchbuffer( long offset,
+ int *ptr,
+ int count )
+{
+ int i;
+ fprintf(stderr, "\n\n\nSTART BATCH (%d dwords):\n", count);
+ for (i = 0; i < count/4; i += 4)
+ fprintf(stderr, "\t0x%lx: 0x%08x 0x%08x 0x%08x 0x%08x\n",
+ (unsigned int)offset + i*4, ptr[i], ptr[i+1], ptr[i+2], ptr[i+3]);
+ fprintf(stderr, "END BATCH\n\n\n");
+}
+
+void intelRefillBatchLocked( intelContextPtr intel, GLboolean allow_unlock )
+{
+ GLuint last_irq = intel->alloc.irq_emitted;
+ GLuint half = intel->alloc.size / 2;
+ GLuint buf = (intel->alloc.active_buf ^= 1);
+
+ intel->alloc.irq_emitted = intelEmitIrqLocked( intel );
+
+ if (last_irq) {
+ if (allow_unlock) UNLOCK_HARDWARE( intel );
+ intelWaitIrq( intel, last_irq );
+ if (allow_unlock) LOCK_HARDWARE( intel );
+ }
+
+ if (0)
+ fprintf(stderr, "%s: now using half %d\n", __FUNCTION__, buf);
+
+ intel->batch.start_offset = intel->alloc.offset + buf * half;
+ intel->batch.ptr = (char *)intel->alloc.ptr + buf * half;
+ intel->batch.size = half - 8;
+ intel->batch.space = half - 8;
+ assert(intel->batch.space >= 0);
+}
+
+#define MI_BATCH_BUFFER_END (0xA<<23)
+
+
+void intelFlushBatchLocked( intelContextPtr intel,
+ GLboolean ignore_cliprects,
+ GLboolean refill,
+ GLboolean allow_unlock)
+{
+ drmI830BatchBuffer batch;
+
+ assert(intel->locked);
+
+ if (0)
+ fprintf(stderr, "%s used %d of %d offset %x..%x refill %d\n",
+ __FUNCTION__,
+ (intel->batch.size - intel->batch.space),
+ intel->batch.size,
+ intel->batch.start_offset,
+ intel->batch.start_offset +
+ (intel->batch.size - intel->batch.space),
+ refill);
+
+ /* Throw away non-effective packets. Won't work once we have
+ * hardware contexts which would preserve statechanges beyond a
+ * single buffer.
+ */
+ if (intel->numClipRects == 0 && !ignore_cliprects) {
+
+ /* Without this yeild, an application with no cliprects can hog
+ * the hardware. Without unlocking, the effect is much worse -
+ * effectively a lock-out of other contexts.
+ */
+ if (allow_unlock) {
+ UNLOCK_HARDWARE( intel );
+ sched_yield();
+ LOCK_HARDWARE( intel );
+ }
+
+ /* Note that any state thought to have been emitted actually
+ * hasn't:
+ */
+ intel->batch.ptr -= (intel->batch.size - intel->batch.space);
+ intel->batch.space = intel->batch.size;
+ intel->vtbl.lost_hardware( intel );
+ }
+
+ if (intel->batch.space != intel->batch.size) {
+ batch.start = intel->batch.start_offset;
+ batch.used = intel->batch.size - intel->batch.space;
+ batch.cliprects = intel->pClipRects;
+ batch.num_cliprects = ignore_cliprects ? 0 : intel->numClipRects;
+ batch.DR1 = 0;
+ batch.DR4 = ((((GLuint)intel->drawX) & 0xffff) |
+ (((GLuint)intel->drawY) << 16));
+
+ if (intel->alloc.offset) {
+ if ((batch.used & 0x4) == 0) {
+ ((int *)intel->batch.ptr)[0] = 0;
+ ((int *)intel->batch.ptr)[1] = MI_BATCH_BUFFER_END;
+ batch.used += 0x8;
+ intel->batch.ptr += 0x8;
+ }
+ else {
+ ((int *)intel->batch.ptr)[0] = MI_BATCH_BUFFER_END;
+ batch.used += 0x4;
+ intel->batch.ptr += 0x4;
+ }
+ }
+
+ if (0)
+ intel_dump_batchbuffer( batch.start,
+ (int *)(intel->batch.ptr - batch.used),
+ batch.used );
+
+ if (0)
+ fprintf(stderr, "%s: 0x%x..0x%x DR4: %x cliprects: %d\n",
+ __FUNCTION__,
+ batch.start,
+ batch.start + batch.used,
+ batch.DR4, batch.num_cliprects);
+
+ intel->batch.start_offset += batch.used;
+ intel->batch.size -= batch.used;
+
+ if (intel->batch.size < 8) {
+ refill = GL_TRUE;
+ intel->batch.space = intel->batch.size = 0;
+ }
+ else {
+ intel->batch.size -= 8;
+ intel->batch.space = intel->batch.size;
+ }
+
+
+ assert(intel->batch.space >= 0);
+ assert(batch.start >= intel->alloc.offset);
+ assert(batch.start < intel->alloc.offset + intel->alloc.size);
+ assert(batch.start + batch.used > intel->alloc.offset);
+ assert(batch.start + batch.used <=
+ intel->alloc.offset + intel->alloc.size);
+
+
+ if (intel->alloc.offset) {
+ if (drmCommandWrite (intel->driFd, DRM_I830_BATCHBUFFER, &batch,
+ sizeof(batch))) {
+ fprintf(stderr, "DRM_I830_BATCHBUFFER: %d\n", -errno);
+ UNLOCK_HARDWARE(intel);
+ exit(1);
+ }
+ } else {
+ drmI830CmdBuffer cmd;
+ cmd.buf = (GLubyte *)intel->alloc.ptr + batch.start;
+ cmd.sz = batch.used;
+ cmd.DR1 = batch.DR1;
+ cmd.DR4 = batch.DR4;
+ cmd.num_cliprects = batch.num_cliprects;
+ cmd.cliprects = batch.cliprects;
+
+ if (drmCommandWrite (intel->driFd, DRM_I830_CMDBUFFER, &cmd,
+ sizeof(cmd))) {
+ fprintf(stderr, "DRM_I830_CMDBUFFER: %d\n", -errno);
+ UNLOCK_HARDWARE(intel);
+ exit(1);
+ }
+ }
+
+
+ age_intel(intel, intel->sarea->last_enqueue);
+
+ /* FIXME: use hardware contexts to avoid 'losing' hardware after
+ * each buffer flush.
+ */
+ intel->vtbl.lost_hardware( intel );
+ }
+
+ if (refill)
+ intelRefillBatchLocked( intel, allow_unlock );
+}
+
+void intelFlushBatch( intelContextPtr intel, GLboolean refill )
+{
+ if (intel->locked) {
+ intelFlushBatchLocked( intel, GL_FALSE, refill, GL_FALSE );
+ }
+ else {
+ LOCK_HARDWARE(intel);
+ intelFlushBatchLocked( intel, GL_FALSE, refill, GL_TRUE );
+ UNLOCK_HARDWARE(intel);
+ }
+}
+
+
+
+
+
+
+
+void intelWaitForIdle( intelContextPtr intel )
+{
+ if (0)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ intel->vtbl.emit_flush( intel );
+ intelFlushBatch( intel, GL_TRUE );
+
+ /* Use an irq to wait for dma idle -- Need to track lost contexts
+ * to shortcircuit consecutive calls to this function:
+ */
+ intelWaitIrq( intel, intel->alloc.irq_emitted );
+ intel->alloc.irq_emitted = 0;
+}
+
+
+
+void intelFlush( GLcontext *ctx )
+{
+ intelContextPtr intel = INTEL_CONTEXT( ctx );
+
+ if (intel->Fallback)
+ _swrast_flush( ctx );
+
+ INTEL_FIREVERTICES( intel );
+
+ if (intel->batch.size != intel->batch.space)
+ intelFlushBatch( intel, GL_FALSE );
+}
+
+void intelFinish( GLcontext *ctx )
+{
+ intelContextPtr intel = INTEL_CONTEXT( ctx );
+ intelFlush( ctx );
+ intelWaitForIdle( intel );
+}
+
+
+void intelClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch)
+{
+ intelContextPtr intel = INTEL_CONTEXT( ctx );
+ const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
+ GLbitfield tri_mask = 0;
+ GLbitfield blit_mask = 0;
+ GLbitfield swrast_mask = 0;
+
+ if (0)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ /* Take care of cliprects, which are handled differently for
+ * clears, etc.
+ */
+ intelFlush( &intel->ctx );
+
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
+ if (colorMask == ~0) {
+ blit_mask |= BUFFER_BIT_FRONT_LEFT;
+ }
+ else {
+ tri_mask |= BUFFER_BIT_FRONT_LEFT;
+ }
+ }
+
+ if (mask & BUFFER_BIT_BACK_LEFT) {
+ if (colorMask == ~0) {
+ blit_mask |= BUFFER_BIT_BACK_LEFT;
+ }
+ else {
+ tri_mask |= BUFFER_BIT_BACK_LEFT;
+ }
+ }
+
+ if (mask & BUFFER_BIT_DEPTH) {
+ blit_mask |= BUFFER_BIT_DEPTH;
+ }
+
+ if (mask & BUFFER_BIT_STENCIL) {
+ if (!intel->hw_stencil) {
+ swrast_mask |= BUFFER_BIT_STENCIL;
+ }
+ else if (ctx->Stencil.WriteMask[0] != 0xff) {
+ tri_mask |= BUFFER_BIT_STENCIL;
+ }
+ else {
+ blit_mask |= BUFFER_BIT_STENCIL;
+ }
+ }
+
+ swrast_mask |= (mask & BUFFER_BIT_ACCUM);
+
+ if (blit_mask)
+ intelClearWithBlit( ctx, blit_mask, all, cx, cy, cw, ch );
+
+ if (tri_mask)
+ intel->vtbl.clear_with_tris( intel, tri_mask, all, cx, cy, cw, ch);
+
+ if (swrast_mask)
+ _swrast_Clear( ctx, swrast_mask, all, cx, cy, cw, ch );
+}
+
+
+
+void *intelAllocateAGP( intelContextPtr intel, GLsizei size )
+{
+ int region_offset = 0;
+ drmI830MemAlloc alloc;
+ int ret;
+
+ if (0)
+ fprintf(stderr, "%s: %d bytes\n", __FUNCTION__, size);
+
+ alloc.region = I830_MEM_REGION_AGP;
+ alloc.alignment = 0;
+ alloc.size = size;
+ alloc.region_offset = &region_offset;
+
+ LOCK_HARDWARE(intel);
+
+ /* Make sure the global heap is initialized
+ */
+ if (intel->texture_heaps[0])
+ driAgeTextures( intel->texture_heaps[0] );
+
+
+ ret = drmCommandWriteRead( intel->driFd,
+ DRM_I830_ALLOC,
+ &alloc, sizeof(alloc));
+
+ if (ret) {
+ fprintf(stderr, "%s: DRM_I830_ALLOC ret %d\n", __FUNCTION__, ret);
+ UNLOCK_HARDWARE(intel);
+ return NULL;
+ }
+
+ if (0)
+ fprintf(stderr, "%s: allocated %d bytes\n", __FUNCTION__, size);
+
+ /* Need to propogate this information (agp memory in use) to our
+ * local texture lru. The kernel has already updated the global
+ * lru. An alternative would have been to allocate memory the
+ * usual way and then notify the kernel to pin the allocation.
+ */
+ if (intel->texture_heaps[0])
+ driAgeTextures( intel->texture_heaps[0] );
+
+ UNLOCK_HARDWARE(intel);
+
+ return (void *)((char *)intel->intelScreen->tex.map + region_offset);
+}
+
+void intelFreeAGP( intelContextPtr intel, void *pointer )
+{
+ int region_offset;
+ drmI830MemFree memfree;
+ int ret;
+
+ region_offset = (char *)pointer - (char *)intel->intelScreen->tex.map;
+
+ if (region_offset < 0 ||
+ region_offset > intel->intelScreen->tex.size) {
+ fprintf(stderr, "offset %d outside range 0..%d\n", region_offset,
+ intel->intelScreen->tex.size);
+ return;
+ }
+
+ memfree.region = I830_MEM_REGION_AGP;
+ memfree.region_offset = region_offset;
+
+ ret = drmCommandWrite( intel->driFd,
+ DRM_I830_FREE,
+ &memfree, sizeof(memfree));
+
+ if (ret)
+ fprintf(stderr, "%s: DRM_I830_FREE ret %d\n", __FUNCTION__, ret);
+}
+
+/* This version of AllocateMemoryMESA allocates only agp memory, and
+ * only does so after the point at which the driver has been
+ * initialized.
+ *
+ * Theoretically a valid context isn't required. However, in this
+ * implementation, it is, as I'm using the hardware lock to protect
+ * the kernel data structures, and the current context to get the
+ * device fd.
+ */
+void *intelAllocateMemoryMESA(__DRInativeDisplay *dpy, int scrn,
+ GLsizei size, GLfloat readfreq,
+ GLfloat writefreq, GLfloat priority)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (INTEL_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s sz %d %f/%f/%f\n", __FUNCTION__, size, readfreq,
+ writefreq, priority);
+
+ if (getenv("INTEL_NO_ALLOC"))
+ return NULL;
+
+ if (!ctx || INTEL_CONTEXT(ctx) == 0)
+ return NULL;
+
+ return intelAllocateAGP( INTEL_CONTEXT(ctx), size );
+}
+
+
+/* Called via glXFreeMemoryMESA() */
+void intelFreeMemoryMESA(__DRInativeDisplay *dpy, int scrn, GLvoid *pointer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (INTEL_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s %p\n", __FUNCTION__, pointer);
+
+ if (!ctx || INTEL_CONTEXT(ctx) == 0) {
+ fprintf(stderr, "%s: no context\n", __FUNCTION__);
+ return;
+ }
+
+ intelFreeAGP( INTEL_CONTEXT(ctx), pointer );
+}
+
+/* Called via glXGetMemoryOffsetMESA()
+ *
+ * Returns offset of pointer from the start of agp aperture.
+ */
+GLuint intelGetMemoryOffsetMESA(__DRInativeDisplay *dpy, int scrn,
+ const GLvoid *pointer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ intelContextPtr intel;
+
+ if (!ctx || !(intel = INTEL_CONTEXT(ctx)) ) {
+ fprintf(stderr, "%s: no context\n", __FUNCTION__);
+ return ~0;
+ }
+
+ if (!intelIsAgpMemory( intel, pointer, 0 ))
+ return ~0;
+
+ return intelAgpOffsetFromVirtual( intel, pointer );
+}
+
+
+GLboolean intelIsAgpMemory( intelContextPtr intel, const GLvoid *pointer,
+ GLint size )
+{
+ int offset = (char *)pointer - (char *)intel->intelScreen->tex.map;
+ int valid = (size >= 0 &&
+ offset >= 0 &&
+ offset + size < intel->intelScreen->tex.size);
+
+ if (INTEL_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "intelIsAgpMemory( %p ) : %d\n", pointer, valid );
+
+ return valid;
+}
+
+
+GLuint intelAgpOffsetFromVirtual( intelContextPtr intel, const GLvoid *pointer )
+{
+ int offset = (char *)pointer - (char *)intel->intelScreen->tex.map;
+
+ if (offset < 0 || offset > intel->intelScreen->tex.size)
+ return ~0;
+ else
+ return intel->intelScreen->textureOffset + offset;
+}
+
+
+
+
+
+/* Flip the front & back buffes
+ */
+void intelPageFlip( const __DRIdrawablePrivate *dPriv )
+{
+#if 0
+ intelContextPtr intel;
+ int tmp, ret;
+
+ if (INTEL_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ intel = (intelContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ intelFlush( &intel->ctx );
+ LOCK_HARDWARE( intel );
+
+ if (dPriv->pClipRects) {
+ *(drm_clip_rect_t *)intel->sarea->boxes = dPriv->pClipRects[0];
+ intel->sarea->nbox = 1;
+ }
+
+ ret = drmCommandNone(intel->driFd, DRM_I830_FLIP);
+ if (ret) {
+ fprintf(stderr, "%s: %d\n", __FUNCTION__, ret);
+ UNLOCK_HARDWARE( intel );
+ exit(1);
+ }
+
+ tmp = intel->sarea->last_enqueue;
+ intelRefillBatchLocked( intel );
+ UNLOCK_HARDWARE( intel );
+
+
+ intelSetDrawBuffer( &intel->ctx, intel->ctx.Color.DriverDrawBuffer );
+#endif
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_ioctl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_ioctl.h
new file mode 100644
index 000000000..7e6295167
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_ioctl.h
@@ -0,0 +1,66 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#ifndef INTEL_IOCTL_H
+#define INTEL_IOCTL_H
+
+#include "intel_context.h"
+
+extern void intelWaitAgeLocked( intelContextPtr intel, int age, GLboolean unlock );
+
+extern void intelClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch);
+
+extern void intelPageFlip( const __DRIdrawablePrivate *dpriv );
+extern void intelWaitForIdle( intelContextPtr intel );
+extern void intelFlushBatch( intelContextPtr intel, GLboolean refill );
+extern void intelFlushBatchLocked( intelContextPtr intel,
+ GLboolean ignore_cliprects,
+ GLboolean refill,
+ GLboolean allow_unlock);
+extern void intelRefillBatchLocked( intelContextPtr intel, GLboolean allow_unlock );
+extern void intelFinish( GLcontext *ctx );
+extern void intelFlush( GLcontext *ctx );
+
+extern void *intelAllocateAGP( intelContextPtr intel, GLsizei size );
+extern void intelFreeAGP( intelContextPtr intel, void *pointer );
+
+extern void *intelAllocateMemoryMESA( __DRInativeDisplay *dpy, int scrn,
+ GLsizei size, GLfloat readfreq,
+ GLfloat writefreq, GLfloat priority );
+
+extern void intelFreeMemoryMESA( __DRInativeDisplay *dpy, int scrn,
+ GLvoid *pointer );
+
+extern GLuint intelGetMemoryOffsetMESA( __DRInativeDisplay *dpy, int scrn, const GLvoid *pointer );
+extern GLboolean intelIsAgpMemory( intelContextPtr intel, const GLvoid *pointer,
+ GLint size );
+
+extern GLuint intelAgpOffsetFromVirtual( intelContextPtr intel, const GLvoid *p );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_pixel.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_pixel.c
new file mode 100644
index 000000000..e56e46b4d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_pixel.c
@@ -0,0 +1,490 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include "glheader.h"
+#include "enums.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "swrast/swrast.h"
+
+#include "intel_screen.h"
+#include "intel_context.h"
+#include "intel_ioctl.h"
+#include "intel_batchbuffer.h"
+
+
+
+static GLboolean
+check_color( const GLcontext *ctx, GLenum type, GLenum format,
+ const struct gl_pixelstore_attrib *packing,
+ const void *pixels, GLint sz, GLint pitch )
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+ GLuint cpp = intel->intelScreen->cpp;
+
+ if (INTEL_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if ( (pitch & 63) ||
+ ctx->_ImageTransferState ||
+ packing->SwapBytes ||
+ packing->LsbFirst) {
+ if (INTEL_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s: failed 1\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+
+ if ( type == GL_UNSIGNED_INT_8_8_8_8_REV &&
+ cpp == 4 &&
+ format == GL_BGRA ) {
+ if (INTEL_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s: passed 2\n", __FUNCTION__);
+ return GL_TRUE;
+ }
+
+ if (INTEL_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s: failed\n", __FUNCTION__);
+
+ return GL_FALSE;
+}
+
+static GLboolean
+check_color_per_fragment_ops( const GLcontext *ctx )
+{
+ int result;
+ result = (!( ctx->Color.AlphaEnabled ||
+ ctx->Depth.Test ||
+ ctx->Fog.Enabled ||
+ ctx->Scissor.Enabled ||
+ ctx->Stencil.Enabled ||
+ !ctx->Color.ColorMask[0] ||
+ !ctx->Color.ColorMask[1] ||
+ !ctx->Color.ColorMask[2] ||
+ !ctx->Color.ColorMask[3] ||
+ ctx->Color.ColorLogicOpEnabled ||
+ ctx->Texture._EnabledUnits ||
+ ctx->Depth.OcclusionTest
+ ) &&
+ ctx->Current.RasterPosValid);
+
+ return result;
+}
+
+
+
+static GLboolean
+clip_pixelrect( const GLcontext *ctx,
+ const GLframebuffer *buffer,
+ GLint *x, GLint *y,
+ GLsizei *width, GLsizei *height,
+ GLint *size )
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+
+ /* left clipping */
+ if (*x < buffer->_Xmin) {
+ *width -= (buffer->_Xmin - *x);
+ *x = buffer->_Xmin;
+ }
+
+ /* right clipping */
+ if (*x + *width > buffer->_Xmax)
+ *width -= (*x + *width - buffer->_Xmax - 1);
+
+ if (*width <= 0)
+ return GL_FALSE;
+
+ /* bottom clipping */
+ if (*y < buffer->_Ymin) {
+ *height -= (buffer->_Ymin - *y);
+ *y = buffer->_Ymin;
+ }
+
+ /* top clipping */
+ if (*y + *height > buffer->_Ymax)
+ *height -= (*y + *height - buffer->_Ymax - 1);
+
+ if (*height <= 0)
+ return GL_FALSE;
+
+ *size = ((*y + *height - 1) * intel->intelScreen->frontPitch +
+ (*x + *width - 1) * intel->intelScreen->cpp);
+
+ return GL_TRUE;
+}
+
+static GLboolean
+intelTryReadPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack,
+ GLvoid *pixels )
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+ GLint size = 0;
+ GLint pitch = pack->RowLength ? pack->RowLength : width;
+
+ if (INTEL_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ /* Only accelerate reading to agp buffers.
+ */
+ if ( !intelIsAgpMemory(intel, pixels,
+ pitch * height * intel->intelScreen->cpp ) ) {
+ if (INTEL_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s: dest not agp\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+
+ /* Need GL_PACK_INVERT_MESA to cope with upsidedown results from
+ * blitter:
+ */
+ if (!pack->Invert) {
+ if (INTEL_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s: MESA_PACK_INVERT not set\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+
+ if (!check_color(ctx, type, format, pack, pixels, size, pitch))
+ return GL_FALSE;
+
+ switch ( intel->intelScreen->cpp ) {
+ case 4:
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+
+ /* Although the blits go on the command buffer, need to do this and
+ * fire with lock held to guarentee cliprects and drawOffset are
+ * correct.
+ *
+ * This is an unusual situation however, as the code which flushes
+ * a full command buffer expects to be called unlocked. As a
+ * workaround, immediately flush the buffer on aquiring the lock.
+ */
+ intelFlush( &intel->ctx );
+ LOCK_HARDWARE( intel );
+ {
+ __DRIdrawablePrivate *dPriv = intel->driDrawable;
+ int nbox = dPriv->numClipRects;
+ int src_offset = intel->drawOffset;
+ int src_pitch = intel->intelScreen->frontPitch;
+ int dst_offset = intelAgpOffsetFromVirtual( intel, pixels);
+ drm_clip_rect_t *box = dPriv->pClipRects;
+ int i;
+
+ if (!clip_pixelrect(ctx, ctx->ReadBuffer, &x, &y, &width, &height,
+ &size)) {
+ UNLOCK_HARDWARE( intel );
+ if (INTEL_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s totally clipped -- nothing to do\n",
+ __FUNCTION__);
+ return GL_TRUE;
+ }
+
+
+ y = dPriv->h - y - height;
+ x += dPriv->x;
+ y += dPriv->y;
+
+
+ if (INTEL_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "readpixel blit src_pitch %d dst_pitch %d\n",
+ src_pitch, pitch);
+
+ for (i = 0 ; i < nbox ; i++)
+ {
+ GLint bx = box[i].x1;
+ GLint by = box[i].y1;
+ GLint bw = box[i].x2 - bx;
+ GLint bh = box[i].y2 - by;
+
+ if (bx < x) bw -= x - bx, bx = x;
+ if (by < y) bh -= y - by, by = y;
+ if (bx + bw > x + width) bw = x + width - bx;
+ if (by + bh > y + height) bh = y + height - by;
+ if (bw <= 0) continue;
+ if (bh <= 0) continue;
+
+ intelEmitCopyBlitLocked( intel,
+ intel->intelScreen->cpp,
+ src_pitch, src_offset,
+ pitch, dst_offset,
+ bx, by,
+ bx - x, by - y,
+ bw, bh );
+ }
+ }
+ UNLOCK_HARDWARE( intel );
+ intelFinish( &intel->ctx );
+
+ return GL_TRUE;
+}
+
+static void
+intelReadPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack,
+ GLvoid *pixels )
+{
+ if (INTEL_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (!intelTryReadPixels( ctx, x, y, width, height, format, type, pack,
+ pixels))
+ _swrast_ReadPixels( ctx, x, y, width, height, format, type, pack,
+ pixels);
+}
+
+
+
+
+static void do_draw_pix( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLint pitch,
+ const void *pixels,
+ GLuint dest )
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = intel->driDrawable;
+ drm_clip_rect_t *box = dPriv->pClipRects;
+ int nbox = dPriv->numClipRects;
+ int i;
+ int size;
+ int src_offset = intelAgpOffsetFromVirtual( intel, pixels);
+ int src_pitch = pitch;
+
+ if (INTEL_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ intelFlush( &intel->ctx );
+ LOCK_HARDWARE( intel );
+ if (ctx->DrawBuffer)
+ {
+ y -= height; /* cope with pixel zoom */
+
+ if (!clip_pixelrect(ctx, ctx->DrawBuffer,
+ &x, &y, &width, &height,
+ &size)) {
+ UNLOCK_HARDWARE( intel );
+ return;
+ }
+
+ y = dPriv->h - y - height; /* convert from gl to hardware coords */
+ x += dPriv->x;
+ y += dPriv->y;
+
+
+ for (i = 0 ; i < nbox ; i++ )
+ {
+ GLint bx = box[i].x1;
+ GLint by = box[i].y1;
+ GLint bw = box[i].x2 - bx;
+ GLint bh = box[i].y2 - by;
+
+ if (bx < x) bw -= x - bx, bx = x;
+ if (by < y) bh -= y - by, by = y;
+ if (bx + bw > x + width) bw = x + width - bx;
+ if (by + bh > y + height) bh = y + height - by;
+ if (bw <= 0) continue;
+ if (bh <= 0) continue;
+
+ intelEmitCopyBlitLocked( intel,
+ intel->intelScreen->cpp,
+ src_pitch, src_offset,
+ intel->intelScreen->frontPitch,
+ intel->drawOffset,
+ bx - x, by - y,
+ bx, by,
+ bw, bh );
+ }
+ }
+ UNLOCK_HARDWARE( intel );
+ intelFinish( &intel->ctx );
+}
+
+
+
+
+static GLboolean
+intelTryDrawPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels )
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+ GLint pitch = unpack->RowLength ? unpack->RowLength : width;
+ GLuint dest;
+ GLuint cpp = intel->intelScreen->cpp;
+ GLint size = width * pitch * cpp;
+
+ if (INTEL_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ switch (format) {
+ case GL_RGB:
+ case GL_RGBA:
+ case GL_BGRA:
+ dest = intel->drawOffset;
+
+ /* Planemask doesn't have full support in blits.
+ */
+ if (!ctx->Color.ColorMask[RCOMP] ||
+ !ctx->Color.ColorMask[GCOMP] ||
+ !ctx->Color.ColorMask[BCOMP] ||
+ !ctx->Color.ColorMask[ACOMP]) {
+ if (INTEL_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s: planemask\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+
+ /* Can't do conversions on agp reads/draws.
+ */
+ if ( !intelIsAgpMemory( intel, pixels, size ) ) {
+ if (INTEL_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s: not agp memory\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+
+ if (!check_color(ctx, type, format, unpack, pixels, size, pitch)) {
+ return GL_FALSE;
+ }
+ if (!check_color_per_fragment_ops(ctx)) {
+ return GL_FALSE;
+ }
+
+ if (ctx->Pixel.ZoomX != 1.0F ||
+ ctx->Pixel.ZoomY != -1.0F)
+ return GL_FALSE;
+ break;
+
+ default:
+ return GL_FALSE;
+ }
+
+ if ( intelIsAgpMemory(intel, pixels, size) )
+ {
+ do_draw_pix( ctx, x, y, width, height, pitch, pixels,
+ dest );
+ return GL_TRUE;
+ }
+ else if (0)
+ {
+ /* Pixels is in regular memory -- get dma buffers and perform
+ * upload through them. No point doing this for regular uploads
+ * but once we remove some of the restrictions above (colormask,
+ * pixelformat conversion, zoom?, etc), this could be a win.
+ */
+ }
+ else
+ return GL_FALSE;
+}
+
+static void
+intelDrawPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels )
+{
+ if (INTEL_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (!intelTryDrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels ))
+ _swrast_DrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels );
+}
+
+
+
+
+/**
+ * Implement glCopyPixels for the front color buffer (or back buffer Pixmap)
+ * for the color buffer. Don't support zooming, pixel transfer, etc.
+ * We do support copying from one window to another, ala glXMakeCurrentRead.
+ */
+static void
+intelCopyPixels( GLcontext *ctx,
+ GLint srcx, GLint srcy, GLsizei width, GLsizei height,
+ GLint destx, GLint desty, GLenum type )
+{
+#if 0
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ const SWcontext *swrast = SWRAST_CONTEXT( ctx );
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ const XMesaDrawable drawBuffer = xmesa->xm_draw_buffer->buffer;
+ const XMesaDrawable readBuffer = xmesa->xm_read_buffer->buffer;
+ const XMesaGC gc = xmesa->xm_draw_buffer->gc;
+
+ ASSERT(dpy);
+ ASSERT(gc);
+
+ if (drawBuffer && /* buffer != 0 means it's a Window or Pixmap */
+ readBuffer &&
+ type == GL_COLOR &&
+ (swrast->_RasterMask & ~CLIP_BIT) == 0 && /* no blend, z-test, etc */
+ ctx->_ImageTransferState == 0 && /* no color tables, scale/bias, etc */
+ ctx->Pixel.ZoomX == 1.0 && /* no zooming */
+ ctx->Pixel.ZoomY == 1.0) {
+ /* Note: we don't do any special clipping work here. We could,
+ * but X will do it for us.
+ */
+ srcy = FLIP(xmesa->xm_read_buffer, srcy) - height + 1;
+ desty = FLIP(xmesa->xm_draw_buffer, desty) - height + 1;
+ XCopyArea(dpy, readBuffer, drawBuffer, gc,
+ srcx, srcy, width, height, destx, desty);
+ }
+#else
+ _swrast_CopyPixels(ctx, srcx, srcy, width, height, destx, desty, type );
+#endif
+}
+
+
+
+
+void intelInitPixelFuncs( struct dd_function_table *functions )
+{
+ /* Pixel path fallbacks.
+ */
+ functions->Accum = _swrast_Accum;
+ functions->Bitmap = _swrast_Bitmap;
+ functions->CopyPixels = intelCopyPixels;
+
+ if (!getenv("INTEL_NO_BLITS")) {
+ functions->ReadPixels = intelReadPixels;
+ functions->DrawPixels = intelDrawPixels;
+ }
+ else {
+ functions->ReadPixels = _swrast_ReadPixels;
+ functions->DrawPixels = _swrast_DrawPixels;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_reg.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_reg.h
new file mode 100644
index 000000000..1ec153266
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_reg.h
@@ -0,0 +1,84 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+
+#ifndef _INTEL_REG_H_
+#define _INTEL_REG_H_
+
+
+
+#define CMD_3D (0x3<<29)
+
+
+#define _3DPRIMITIVE ((0x3<<29)|(0x1f<<24))
+#define PRIM_INDIRECT (1<<23)
+#define PRIM_INLINE (0<<23)
+#define PRIM_INDIRECT_SEQUENTIAL (0<<17)
+#define PRIM_INDIRECT_ELTS (1<<17)
+
+#define PRIM3D_TRILIST (0x0<<18)
+#define PRIM3D_TRISTRIP (0x1<<18)
+#define PRIM3D_TRISTRIP_RVRSE (0x2<<18)
+#define PRIM3D_TRIFAN (0x3<<18)
+#define PRIM3D_POLY (0x4<<18)
+#define PRIM3D_LINELIST (0x5<<18)
+#define PRIM3D_LINESTRIP (0x6<<18)
+#define PRIM3D_RECTLIST (0x7<<18)
+#define PRIM3D_POINTLIST (0x8<<18)
+#define PRIM3D_DIB (0x9<<18)
+#define PRIM3D_MASK (0x1f<<18)
+
+#define I915PACKCOLOR4444(r,g,b,a) \
+ ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
+
+#define I915PACKCOLOR1555(r,g,b,a) \
+ ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
+ ((a) ? 0x8000 : 0))
+
+#define I915PACKCOLOR565(r,g,b) \
+ ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
+
+#define I915PACKCOLOR8888(r,g,b,a) \
+ ((a<<24) | (r<<16) | (g<<8) | b)
+
+
+
+
+#define BR00_BITBLT_CLIENT 0x40000000
+#define BR00_OP_COLOR_BLT 0x10000000
+#define BR00_OP_SRC_COPY_BLT 0x10C00000
+#define BR13_SOLID_PATTERN 0x80000000
+
+#define XY_COLOR_BLT_CMD ((2<<29)|(0x50<<22)|0x4)
+#define XY_COLOR_BLT_WRITE_ALPHA (1<<21)
+#define XY_COLOR_BLT_WRITE_RGB (1<<20)
+
+#define XY_SRC_COPY_BLT_CMD ((2<<29)|(0x53<<22)|6)
+#define XY_SRC_COPY_BLT_WRITE_ALPHA (1<<21)
+#define XY_SRC_COPY_BLT_WRITE_RGB (1<<20)
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_render.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_render.c
new file mode 100644
index 000000000..d9438ba0f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_render.c
@@ -0,0 +1,240 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * dma buffers. Use strip/fan hardware acceleration where possible.
+ *
+ */
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "enums.h"
+
+#include "tnl/t_context.h"
+#include "tnl/t_vertex.h"
+
+#include "intel_screen.h"
+#include "intel_context.h"
+#include "intel_tris.h"
+#include "intel_batchbuffer.h"
+#include "intel_reg.h"
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * dma buffers. Use strip/fan hardware primitives where possible.
+ * Try to simulate missing primitives with indexed vertices.
+ */
+#define HAVE_POINTS 0 /* Has it, but can't use because subpixel has to
+ * be adjusted for points on the INTEL/I845G
+ */
+#define HAVE_LINES 1
+#define HAVE_LINE_STRIPS 1
+#define HAVE_TRIANGLES 1
+#define HAVE_TRI_STRIPS 1
+#define HAVE_TRI_STRIP_1 0 /* has it, template can't use it yet */
+#define HAVE_TRI_FANS 1
+#define HAVE_POLYGONS 1
+#define HAVE_QUADS 0
+#define HAVE_QUAD_STRIPS 0
+
+#define HAVE_ELTS 0
+
+static GLuint hw_prim[GL_POLYGON+1] = {
+ 0,
+ PRIM3D_LINELIST,
+ PRIM3D_LINESTRIP,
+ PRIM3D_LINESTRIP,
+ PRIM3D_TRILIST,
+ PRIM3D_TRISTRIP,
+ PRIM3D_TRIFAN,
+ 0,
+ 0,
+ PRIM3D_POLY
+};
+
+static const GLenum reduced_prim[GL_POLYGON+1] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES
+};
+
+static const int scale_prim[GL_POLYGON+1] = {
+ 0, /* fallback case */
+ 1,
+ 2,
+ 2,
+ 1,
+ 3,
+ 3,
+ 0, /* fallback case */
+ 0, /* fallback case */
+ 3
+};
+
+
+static void intelDmaPrimitive( intelContextPtr intel, GLenum prim )
+{
+ if (0) fprintf(stderr, "%s %s\n", __FUNCTION__, _mesa_lookup_enum_by_nr(prim));
+ INTEL_FIREVERTICES(intel);
+ intel->vtbl.reduced_primitive_state( intel, reduced_prim[prim] );
+ intelStartInlinePrimitive( intel, hw_prim[prim] );
+}
+
+
+#define LOCAL_VARS intelContextPtr intel = INTEL_CONTEXT(ctx)
+#define INIT( prim ) \
+do { \
+ intelDmaPrimitive( intel, prim ); \
+} while (0)
+#define FLUSH() INTEL_FIREVERTICES( intel )
+
+#define GET_SUBSEQUENT_VB_MAX_VERTS() \
+ (((intel->alloc.size / 2) - 1500) / (intel->vertex_size*4))
+#define GET_CURRENT_VB_MAX_VERTS() GET_SUBSEQUENT_VB_MAX_VERTS()
+
+#define ALLOC_VERTS( nr ) \
+ intelExtendInlinePrimitive( intel, (nr) * intel->vertex_size )
+
+#define EMIT_VERTS( ctx, j, nr, buf ) \
+ _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf )
+
+#define TAG(x) intel_##x
+#include "tnl_dd/t_dd_dmatmp.h"
+
+
+/**********************************************************************/
+/* Render pipeline stage */
+/**********************************************************************/
+
+/* Heuristic to choose between the two render paths:
+ */
+static GLboolean choose_render( intelContextPtr intel,
+ struct vertex_buffer *VB )
+{
+ int vertsz = intel->vertex_size;
+ int cost_render = 0;
+ int cost_fallback = 0;
+ int nr_prims = 0;
+ int nr_rprims = 0;
+ int nr_rverts = 0;
+ int rprim = intel->reduced_primitive;
+ int i = 0;
+
+ for (i = 0 ; i < VB->PrimitiveCount ; i++) {
+ GLuint prim = VB->Primitive[i].mode;
+ GLuint length = VB->Primitive[i].count;
+
+ if (!length)
+ continue;
+
+ nr_prims++;
+ nr_rverts += length * scale_prim[prim & PRIM_MODE_MASK];
+
+ if (reduced_prim[prim & PRIM_MODE_MASK] != rprim) {
+ nr_rprims++;
+ rprim = reduced_prim[prim & PRIM_MODE_MASK];
+ }
+ }
+
+ /* One point for each generated primitive:
+ */
+ cost_render = nr_prims;
+ cost_fallback = nr_rprims;
+
+ /* One point for every 1024 dwords (4k) of dma:
+ */
+ cost_render += (vertsz * i) / 1024;
+ cost_fallback += (vertsz * nr_rverts) / 1024;
+
+ if (0)
+ fprintf(stderr, "cost render: %d fallback: %d\n",
+ cost_render, cost_fallback);
+
+ if (cost_render > cost_fallback)
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
+
+static GLboolean intel_run_render( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i;
+
+ /* Don't handle clipping or indexed vertices.
+ */
+ if (intel->RenderIndex != 0 ||
+ !intel_validate_render( ctx, VB ) ||
+ !choose_render( intel, VB )) {
+ return GL_TRUE;
+ }
+
+ tnl->clipspace.new_inputs |= VERT_BIT_POS;
+
+ tnl->Driver.Render.Start( ctx );
+
+ for (i = 0 ; i < VB->PrimitiveCount ; i++)
+ {
+ GLuint prim = VB->Primitive[i].mode;
+ GLuint start = VB->Primitive[i].start;
+ GLuint length = VB->Primitive[i].count;
+
+ if (!length)
+ continue;
+
+ intel_render_tab_verts[prim & PRIM_MODE_MASK]( ctx, start, start + length,
+ prim );
+ }
+
+ tnl->Driver.Render.Finish( ctx );
+
+ return GL_FALSE; /* finished the pipe */
+}
+
+const struct tnl_pipeline_stage _intel_render_stage =
+{
+ "intel render",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ intel_run_render /* run */
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_screen.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_screen.c
new file mode 100644
index 000000000..57c7504bf
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_screen.c
@@ -0,0 +1,511 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include "glheader.h"
+#include "context.h"
+#include "framebuffer.h"
+#include "matrix.h"
+#include "renderbuffer.h"
+#include "simple_list.h"
+#include "utils.h"
+#include "xmlpool.h"
+
+
+#include "intel_screen.h"
+
+#include "intel_tex.h"
+#include "intel_span.h"
+#include "intel_tris.h"
+#include "intel_ioctl.h"
+
+
+
+#include "i830_dri.h"
+
+PUBLIC const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_FORCE_S3TC_ENABLE(false)
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+const GLuint __driNConfigOptions = 1;
+
+extern const struct dri_extension card_extensions[];
+
+static void intelPrintDRIInfo(intelScreenPrivate *intelScreen,
+ __DRIscreenPrivate *sPriv,
+ I830DRIPtr gDRIPriv)
+{
+ fprintf(stderr, "Front size : 0x%x\n", sPriv->fbSize);
+ fprintf(stderr, "Front offset : 0x%x\n", intelScreen->frontOffset);
+ fprintf(stderr, "Back size : 0x%x\n", intelScreen->back.size);
+ fprintf(stderr, "Back offset : 0x%x\n", intelScreen->backOffset);
+ fprintf(stderr, "Depth size : 0x%x\n", intelScreen->depth.size);
+ fprintf(stderr, "Depth offset : 0x%x\n", intelScreen->depthOffset);
+ fprintf(stderr, "Texture size : 0x%x\n", intelScreen->textureSize);
+ fprintf(stderr, "Texture offset : 0x%x\n", intelScreen->textureOffset);
+ fprintf(stderr, "Memory : 0x%x\n", gDRIPriv->mem);
+}
+
+static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv)
+{
+ intelScreenPrivate *intelScreen;
+ I830DRIPtr gDRIPriv = (I830DRIPtr)sPriv->pDevPriv;
+ PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
+ (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
+ void * const psc = sPriv->psc->screenConfigs;
+
+ if (sPriv->devPrivSize != sizeof(I830DRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
+
+ /* Allocate the private area */
+ intelScreen = (intelScreenPrivate *)CALLOC(sizeof(intelScreenPrivate));
+ if (!intelScreen) {
+ fprintf(stderr,"\nERROR! Allocating private area failed\n");
+ return GL_FALSE;
+ }
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo (&intelScreen->optionCache,
+ __driConfigOptions, __driNConfigOptions);
+
+ intelScreen->driScrnPriv = sPriv;
+ sPriv->private = (void *)intelScreen;
+
+ intelScreen->deviceID = gDRIPriv->deviceID;
+ intelScreen->width = gDRIPriv->width;
+ intelScreen->height = gDRIPriv->height;
+ intelScreen->mem = gDRIPriv->mem;
+ intelScreen->cpp = gDRIPriv->cpp;
+ intelScreen->frontPitch = gDRIPriv->fbStride;
+ intelScreen->frontOffset = gDRIPriv->fbOffset;
+
+ switch (gDRIPriv->bitsPerPixel) {
+ case 15: intelScreen->fbFormat = DV_PF_555; break;
+ case 16: intelScreen->fbFormat = DV_PF_565; break;
+ case 32: intelScreen->fbFormat = DV_PF_8888; break;
+ }
+
+ intelScreen->backOffset = gDRIPriv->backOffset;
+ intelScreen->backPitch = gDRIPriv->backPitch;
+ intelScreen->depthOffset = gDRIPriv->depthOffset;
+ intelScreen->depthPitch = gDRIPriv->depthPitch;
+ intelScreen->textureOffset = gDRIPriv->textureOffset;
+ intelScreen->textureSize = gDRIPriv->textureSize;
+ intelScreen->logTextureGranularity = gDRIPriv->logTextureGranularity;
+ intelScreen->back.handle = gDRIPriv->backbuffer;
+ intelScreen->back.size = gDRIPriv->backbufferSize;
+
+ if (drmMap(sPriv->fd,
+ intelScreen->back.handle,
+ intelScreen->back.size,
+ (drmAddress *)&intelScreen->back.map) != 0) {
+ fprintf(stderr, "\nERROR: line %d, Function %s, File %s\n",
+ __LINE__, __FUNCTION__, __FILE__);
+ FREE(intelScreen);
+ sPriv->private = NULL;
+ return GL_FALSE;
+ }
+
+ intelScreen->depth.handle = gDRIPriv->depthbuffer;
+ intelScreen->depth.size = gDRIPriv->depthbufferSize;
+
+ if (drmMap(sPriv->fd,
+ intelScreen->depth.handle,
+ intelScreen->depth.size,
+ (drmAddress *)&intelScreen->depth.map) != 0) {
+ fprintf(stderr, "\nERROR: line %d, Function %s, File %s\n",
+ __LINE__, __FUNCTION__, __FILE__);
+ FREE(intelScreen);
+ drmUnmap(intelScreen->back.map, intelScreen->back.size);
+ sPriv->private = NULL;
+ return GL_FALSE;
+ }
+
+ intelScreen->tex.handle = gDRIPriv->textures;
+ intelScreen->tex.size = gDRIPriv->textureSize;
+
+ if (drmMap(sPriv->fd,
+ intelScreen->tex.handle,
+ intelScreen->tex.size,
+ (drmAddress *)&intelScreen->tex.map) != 0) {
+ fprintf(stderr, "\nERROR: line %d, Function %s, File %s\n",
+ __LINE__, __FUNCTION__, __FILE__);
+ FREE(intelScreen);
+ drmUnmap(intelScreen->back.map, intelScreen->back.size);
+ drmUnmap(intelScreen->depth.map, intelScreen->depth.size);
+ sPriv->private = NULL;
+ return GL_FALSE;
+ }
+
+ intelScreen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
+
+ if (0) intelPrintDRIInfo(intelScreen, sPriv, gDRIPriv);
+
+ intelScreen->drmMinor = sPriv->drmMinor;
+
+ {
+ int ret;
+ drmI830GetParam gp;
+
+ gp.param = I830_PARAM_IRQ_ACTIVE;
+ gp.value = &intelScreen->irq_active;
+
+ ret = drmCommandWriteRead( sPriv->fd, DRM_I830_GETPARAM,
+ &gp, sizeof(gp));
+ if (ret) {
+ fprintf(stderr, "drmI830GetParam: %d\n", ret);
+ return GL_FALSE;
+ }
+ }
+
+ {
+ int ret;
+ drmI830GetParam gp;
+
+ gp.param = I830_PARAM_ALLOW_BATCHBUFFER;
+ gp.value = &intelScreen->allow_batchbuffer;
+
+ ret = drmCommandWriteRead( sPriv->fd, DRM_I830_GETPARAM,
+ &gp, sizeof(gp));
+ if (ret) {
+ fprintf(stderr, "drmI830GetParam: (%d) %d\n", gp.param, ret);
+ return GL_FALSE;
+ }
+ }
+
+ if (glx_enable_extension != NULL) {
+ (*glx_enable_extension)( psc, "GLX_SGI_make_current_read" );
+ (*glx_enable_extension)( psc, "GLX_MESA_allocate_memory" );
+ }
+
+ sPriv->psc->allocateMemory = (void *) intelAllocateMemoryMESA;
+ sPriv->psc->freeMemory = (void *) intelFreeMemoryMESA;
+ sPriv->psc->memoryOffset = (void *) intelGetMemoryOffsetMESA;
+
+ return GL_TRUE;
+}
+
+
+static void intelDestroyScreen(__DRIscreenPrivate *sPriv)
+{
+ intelScreenPrivate *intelScreen = (intelScreenPrivate *)sPriv->private;
+
+ /* Need to unmap all the bufs and maps here:
+ */
+ drmUnmap(intelScreen->back.map, intelScreen->back.size);
+ drmUnmap(intelScreen->depth.map, intelScreen->depth.size);
+ drmUnmap(intelScreen->tex.map, intelScreen->tex.size);
+ FREE(intelScreen);
+ sPriv->private = NULL;
+}
+
+
+static GLboolean intelCreateBuffer( __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ intelScreenPrivate *screen = (intelScreenPrivate *) driScrnPriv->private;
+
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ } else {
+ GLboolean swStencil = (mesaVis->stencilBits > 0 &&
+ mesaVis->depthBits != 24);
+
+#if 0
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE /* s/w alpha planes */);
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->frontPitch);
+ intelSetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ intelSetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ intelSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ intelSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ intelSetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+static void intelDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+
+/* There are probably better ways to do this, such as an
+ * init-designated function to register chipids and createcontext
+ * functions.
+ */
+extern GLboolean i830CreateContext( const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate);
+
+extern GLboolean i915CreateContext( const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate);
+
+
+
+
+static GLboolean intelCreateContext( const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate)
+{
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ intelScreenPrivate *intelScreen = (intelScreenPrivate *)sPriv->private;
+
+ switch (intelScreen->deviceID) {
+ case PCI_CHIP_845_G:
+ case PCI_CHIP_I830_M:
+ case PCI_CHIP_I855_GM:
+ case PCI_CHIP_I865_G:
+ return i830CreateContext( mesaVis, driContextPriv,
+ sharedContextPrivate );
+
+ case PCI_CHIP_I915_G:
+ case PCI_CHIP_I915_GM:
+ case PCI_CHIP_I945_G:
+ return i915CreateContext( mesaVis, driContextPriv,
+ sharedContextPrivate );
+
+ default:
+ fprintf(stderr, "Unrecognized deviceID %x\n", intelScreen->deviceID);
+ return GL_FALSE;
+ }
+}
+
+
+static const struct __DriverAPIRec intelAPI = {
+ .InitDriver = intelInitDriver,
+ .DestroyScreen = intelDestroyScreen,
+ .CreateContext = intelCreateContext,
+ .DestroyContext = intelDestroyContext,
+ .CreateBuffer = intelCreateBuffer,
+ .DestroyBuffer = intelDestroyBuffer,
+ .SwapBuffers = intelSwapBuffers,
+ .MakeCurrent = intelMakeCurrent,
+ .UnbindContext = intelUnbindContext,
+ .GetSwapInfo = NULL,
+ .GetMSC = NULL,
+ .WaitForMSC = NULL,
+ .WaitForSBC = NULL,
+ .SwapBuffersMSC = NULL
+};
+
+
+static __GLcontextModes *
+intelFillInModes( unsigned pixel_bits, unsigned depth_bits,
+ unsigned stencil_bits, GLboolean have_back_buffer )
+{
+ __GLcontextModes * modes;
+ __GLcontextModes * m;
+ unsigned num_modes;
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ GLenum fb_format;
+ GLenum fb_type;
+
+ /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
+ * support pageflipping at all.
+ */
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
+ };
+
+ u_int8_t depth_bits_array[3];
+ u_int8_t stencil_bits_array[3];
+
+
+ depth_bits_array[0] = 0;
+ depth_bits_array[1] = depth_bits;
+ depth_bits_array[2] = depth_bits;
+
+ /* Just like with the accumulation buffer, always provide some modes
+ * with a stencil buffer. It will be a sw fallback, but some apps won't
+ * care about that.
+ */
+ stencil_bits_array[0] = 0;
+ stencil_bits_array[1] = 0;
+ stencil_bits_array[2] = (stencil_bits == 0) ? 8 : stencil_bits;
+
+ depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1;
+ back_buffer_factor = (have_back_buffer) ? 3 : 1;
+
+ num_modes = depth_buffer_factor * back_buffer_factor * 4;
+
+ if ( pixel_bits == 16 ) {
+ fb_format = GL_RGB;
+ fb_type = GL_UNSIGNED_SHORT_5_6_5;
+ }
+ else {
+ fb_format = GL_BGRA;
+ fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ }
+
+ modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
+ m = modes;
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_TRUE_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_DIRECT_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+
+ /* Mark the visual as slow if there are "fake" stencil bits.
+ */
+ for ( m = modes ; m != NULL ; m = m->next ) {
+ if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) {
+ m->visualRating = GLX_SLOW_CONFIG;
+ }
+ }
+
+ return modes;
+}
+
+
+/**
+ * This is the bootstrap function for the driver. libGL supplies all of the
+ * requisite information about the system, and the driver initializes itself.
+ * This routine also fills in the linked list pointed to by \c driver_modes
+ * with the \c __GLcontextModes that the driver can support for windows or
+ * pbuffers.
+ *
+ * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
+ * failure.
+ */
+PUBLIC
+void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
+ const __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drmAddress pSAREA, int fd,
+ int internal_api_version,
+ const __DRIinterfaceMethods * interface,
+ __GLcontextModes ** driver_modes )
+
+{
+ __DRIscreenPrivate *psp;
+ static const __DRIversion ddx_expected = { 1, 4, 0 };
+ static const __DRIversion dri_expected = { 4, 0, 0 };
+ static const __DRIversion drm_expected = { 1, 1, 0 };
+
+ dri_interface = interface;
+
+ if ( ! driCheckDriDdxDrmVersions2( "i915",
+ dri_version, & dri_expected,
+ ddx_version, & ddx_expected,
+ drm_version, & drm_expected ) ) {
+ return NULL;
+ }
+
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &intelAPI);
+ if ( psp != NULL ) {
+ I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
+ *driver_modes = intelFillInModes( dri_priv->cpp * 8,
+ (dri_priv->cpp == 2) ? 16 : 24,
+ (dri_priv->cpp == 2) ? 0 : 8,
+ (dri_priv->backOffset != dri_priv->depthOffset) );
+
+ /* Calling driInitExtensions here, with a NULL context pointer, does not actually
+ * enable the extensions. It just makes sure that all the dispatch offsets for all
+ * the extensions that *might* be enables are known. This is needed because the
+ * dispatch offsets need to be known when _mesa_context_create is called, but we can't
+ * enable the extensions until we have a context pointer.
+ *
+ * Hello chicken. Hello egg. How are you two today?
+ */
+ driInitExtensions( NULL, card_extensions, GL_FALSE );
+ }
+
+ return (void *) psp;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_screen.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_screen.h
new file mode 100644
index 000000000..f2fb1c6bc
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_screen.h
@@ -0,0 +1,101 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#ifndef _INTEL_INIT_H_
+#define _INTEL_INIT_H_
+
+#include <sys/time.h>
+#include "dri_util.h"
+#include "xmlconfig.h"
+
+typedef struct {
+ drm_handle_t handle;
+ drmSize size;
+ char *map;
+} intelRegion;
+
+typedef struct
+{
+ intelRegion front;
+ intelRegion back;
+ intelRegion depth;
+ intelRegion tex;
+
+ int deviceID;
+ int width;
+ int height;
+ int mem;
+
+ int cpp; /* for front and back buffers */
+ int bitsPerPixel;
+
+ int fbFormat;
+
+ int frontOffset;
+ int frontPitch;
+
+ int backOffset;
+ int backPitch;
+
+ int depthOffset;
+ int depthPitch;
+
+
+ int textureOffset;
+ int textureSize;
+ int logTextureGranularity;
+
+ __DRIscreenPrivate *driScrnPriv;
+ unsigned int sarea_priv_offset;
+
+ int drmMinor;
+
+ int irq_active;
+ int allow_batchbuffer;
+
+ /**
+ * Configuration cache with default values for all contexts
+ */
+ driOptionCache optionCache;
+} intelScreenPrivate;
+
+
+extern void
+intelDestroyContext(__DRIcontextPrivate *driContextPriv);
+
+extern GLboolean
+intelUnbindContext(__DRIcontextPrivate *driContextPriv);
+
+extern GLboolean
+intelMakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv);
+
+extern void
+intelSwapBuffers( __DRIdrawablePrivate *dPriv);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_span.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_span.c
new file mode 100644
index 000000000..3522f4f38
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_span.c
@@ -0,0 +1,379 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "colormac.h"
+
+#include "intel_screen.h"
+
+#include "intel_span.h"
+#include "intel_ioctl.h"
+#include "swrast/swrast.h"
+
+
+#define DBG 0
+
+#define LOCAL_VARS \
+ intelContextPtr intel = INTEL_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = intel->driDrawable; \
+ intelScreenPrivate *intelScreen = intel->intelScreen; \
+ GLuint pitch = intelScreen->backPitch * intelScreen->cpp; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(intel->drawMap + \
+ dPriv->x * intelScreen->cpp + \
+ dPriv->y * pitch); \
+ char *read_buf = (char *)(intel->readMap + \
+ dPriv->x * intelScreen->cpp + \
+ dPriv->y * pitch); \
+ GLushort p; \
+ (void) read_buf; (void) buf; (void) p
+
+#define LOCAL_DEPTH_VARS \
+ intelContextPtr intel = INTEL_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = intel->driDrawable; \
+ intelScreenPrivate *intelScreen = intel->intelScreen; \
+ GLuint pitch = intelScreen->backPitch * intelScreen->cpp; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(intelScreen->depth.map + \
+ dPriv->x * intelScreen->cpp + \
+ dPriv->y * pitch)
+
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
+
+#define INIT_MONO_PIXEL(p,color)\
+ p = INTEL_PACKCOLOR565(color[0],color[1],color[2])
+
+#define Y_FLIP(_y) (height - _y - 1)
+
+#define HW_LOCK()
+
+#define HW_UNLOCK()
+
+/* 16 bit, 565 rgb 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 >> 11) & 0x1f) * 255) / 31; \
+ rgba[1] = (((p >> 5) & 0x3f) * 255) / 63; \
+ rgba[2] = (((p >> 0) & 0x1f) * 255) / 31; \
+ rgba[3] = 255; \
+} while(0)
+
+#define TAG(x) intel##x##_565
+#include "spantmp.h"
+
+/* 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 *)(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) intel##x##_555
+#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) intel##x##_16
+#include "depthtmp.h"
+
+
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ intelContextPtr intel = INTEL_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = intel->driDrawable; \
+ intelScreenPrivate *intelScreen = intel->intelScreen; \
+ GLuint pitch = intelScreen->backPitch * intelScreen->cpp; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(intel->drawMap + \
+ dPriv->x * intelScreen->cpp + \
+ dPriv->y * pitch); \
+ char *read_buf = (char *)(intel->readMap + \
+ dPriv->x * intelScreen->cpp + \
+ dPriv->y * pitch); \
+ GLuint p; \
+ (void) read_buf; (void) buf; (void) p
+
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p,color)\
+ p = INTEL_PACKCOLOR8888(color[0],color[1],color[2],color[3])
+
+/* 32 bit, 8888 argb 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) intel##x##_8888
+#include "spantmp.h"
+
+
+/* 24/8 bit interleaved depth/stencil functions
+ */
+#define WRITE_DEPTH( _x, _y, d ) { \
+ GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*pitch); \
+ tmp &= 0xff000000; \
+ tmp |= (d) & 0xffffff; \
+ *(GLuint *)(buf + (_x)*4 + (_y)*pitch) = tmp; \
+}
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLuint *)(buf + (_x)*4 + (_y)*pitch) & 0xffffff;
+
+
+#define TAG(x) intel##x##_24_8
+#include "depthtmp.h"
+
+#define WRITE_STENCIL( _x, _y, d ) { \
+ GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*pitch); \
+ tmp &= 0xffffff; \
+ tmp |= ((d)<<24); \
+ *(GLuint *)(buf + (_x)*4 + (_y)*pitch) = tmp; \
+}
+
+#define READ_STENCIL( d, _x, _y ) \
+ d = *(GLuint *)(buf + (_x)*4 + (_y)*pitch) >> 24;
+
+#define TAG(x) intel##x##_24_8
+#include "stenciltmp.h"
+
+
+/*
+ * This function is called to specify which buffer to read and write
+ * for software rasterization (swrast) fallbacks. This doesn't necessarily
+ * correspond to glDrawBuffer() or glReadBuffer() calls.
+ */
+static void intelSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
+ GLuint bufferBit)
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+ if (bufferBit == BUFFER_BIT_FRONT_LEFT) {
+ intel->drawMap = (char *)intel->driScreen->pFB;
+ intel->readMap = (char *)intel->driScreen->pFB;
+ } else if (bufferBit == BUFFER_BIT_BACK_LEFT) {
+ intel->drawMap = intel->intelScreen->back.map;
+ intel->readMap = intel->intelScreen->back.map;
+ } else {
+ ASSERT(0);
+ }
+}
+
+
+/* Move locking out to get reasonable span performance.
+ */
+void intelSpanRenderStart( GLcontext *ctx )
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+
+ intelFlush(&intel->ctx);
+ LOCK_HARDWARE(intel);
+ intelWaitForIdle(intel);
+}
+
+void intelSpanRenderFinish( GLcontext *ctx )
+{
+ intelContextPtr intel = INTEL_CONTEXT( ctx );
+ _swrast_flush( ctx );
+ UNLOCK_HARDWARE( intel );
+}
+
+void intelInitSpanFuncs( GLcontext *ctx )
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+ intelScreenPrivate *intelScreen = intel->intelScreen;
+
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetBuffer = intelSetBuffer;
+
+ switch (intelScreen->fbFormat) {
+ case DV_PF_555:
+#if 0
+ swdd->WriteRGBASpan = intelWriteRGBASpan_555;
+ swdd->WriteRGBSpan = intelWriteRGBSpan_555;
+ swdd->WriteMonoRGBASpan = intelWriteMonoRGBASpan_555;
+ swdd->WriteRGBAPixels = intelWriteRGBAPixels_555;
+ swdd->WriteMonoRGBAPixels = intelWriteMonoRGBAPixels_555;
+ swdd->ReadRGBASpan = intelReadRGBASpan_555;
+ swdd->ReadRGBAPixels = intelReadRGBAPixels_555;
+ swdd->ReadDepthSpan = intelReadDepthSpan_16;
+ swdd->WriteDepthSpan = intelWriteDepthSpan_16;
+ swdd->ReadDepthPixels = intelReadDepthPixels_16;
+ swdd->WriteDepthPixels = intelWriteDepthPixels_16;
+#endif
+ break;
+
+ case DV_PF_565:
+#if 0
+ swdd->WriteRGBASpan = intelWriteRGBASpan_565;
+ swdd->WriteRGBSpan = intelWriteRGBSpan_565;
+ swdd->WriteMonoRGBASpan = intelWriteMonoRGBASpan_565;
+ swdd->WriteRGBAPixels = intelWriteRGBAPixels_565;
+ swdd->WriteMonoRGBAPixels = intelWriteMonoRGBAPixels_565;
+ swdd->ReadRGBASpan = intelReadRGBASpan_565;
+ swdd->ReadRGBAPixels = intelReadRGBAPixels_565;
+ swdd->ReadDepthSpan = intelReadDepthSpan_16;
+ swdd->WriteDepthSpan = intelWriteDepthSpan_16;
+ swdd->ReadDepthPixels = intelReadDepthPixels_16;
+ swdd->WriteDepthPixels = intelWriteDepthPixels_16;
+#endif
+ break;
+
+ case DV_PF_8888:
+#if 0
+ swdd->WriteRGBASpan = intelWriteRGBASpan_8888;
+ swdd->WriteRGBSpan = intelWriteRGBSpan_8888;
+ swdd->WriteMonoRGBASpan = intelWriteMonoRGBASpan_8888;
+ swdd->WriteRGBAPixels = intelWriteRGBAPixels_8888;
+ swdd->WriteMonoRGBAPixels = intelWriteMonoRGBAPixels_8888;
+ swdd->ReadRGBASpan = intelReadRGBASpan_8888;
+ swdd->ReadRGBAPixels = intelReadRGBAPixels_8888;
+ swdd->ReadDepthSpan = intelReadDepthSpan_24_8;
+ swdd->WriteDepthSpan = intelWriteDepthSpan_24_8;
+ swdd->ReadDepthPixels = intelReadDepthPixels_24_8;
+ swdd->WriteDepthPixels = intelWriteDepthPixels_24_8;
+
+ swdd->WriteStencilSpan = intelWriteStencilSpan_24_8;
+ swdd->ReadStencilSpan = intelReadStencilSpan_24_8;
+ swdd->WriteStencilPixels = intelWriteStencilPixels_24_8;
+ swdd->ReadStencilPixels = intelReadStencilPixels_24_8;
+#endif
+ break;
+ }
+
+ swdd->SpanRenderStart = intelSpanRenderStart;
+ swdd->SpanRenderFinish = intelSpanRenderFinish;
+}
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+intelSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 5 && vis->blueBits == 5) {
+ drb->Base.GetRow = intelReadRGBASpan_555;
+ drb->Base.GetValues = intelReadRGBAPixels_555;
+ drb->Base.PutRow = intelWriteRGBASpan_555;
+ drb->Base.PutRowRGB = intelWriteRGBSpan_555;
+ drb->Base.PutMonoRow = intelWriteMonoRGBASpan_555;
+ drb->Base.PutValues = intelWriteRGBAPixels_555;
+ drb->Base.PutMonoValues = intelWriteMonoRGBAPixels_555;
+ }
+ else if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ drb->Base.GetRow = intelReadRGBASpan_565;
+ drb->Base.GetValues = intelReadRGBAPixels_565;
+ drb->Base.PutRow = intelWriteRGBASpan_565;
+ drb->Base.PutRowRGB = intelWriteRGBSpan_565;
+ drb->Base.PutMonoRow = intelWriteMonoRGBASpan_565;
+ drb->Base.PutValues = intelWriteRGBAPixels_565;
+ drb->Base.PutMonoValues = intelWriteMonoRGBAPixels_565;
+ }
+ else {
+ assert(vis->redBits == 8);
+ assert(vis->greenBits == 8);
+ assert(vis->blueBits == 8);
+ drb->Base.GetRow = intelReadRGBASpan_8888;
+ drb->Base.GetValues = intelReadRGBAPixels_8888;
+ drb->Base.PutRow = intelWriteRGBASpan_8888;
+ drb->Base.PutRowRGB = intelWriteRGBSpan_8888;
+ drb->Base.PutMonoRow = intelWriteMonoRGBASpan_8888;
+ drb->Base.PutValues = intelWriteRGBAPixels_8888;
+ drb->Base.PutMonoValues = intelWriteMonoRGBAPixels_8888;
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = intelReadDepthSpan_16;
+ drb->Base.GetValues = intelReadDepthPixels_16;
+ drb->Base.PutRow = intelWriteDepthSpan_16;
+ drb->Base.PutMonoRow = intelWriteMonoDepthSpan_16;
+ drb->Base.PutValues = intelWriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = intelReadDepthSpan_24_8;
+ drb->Base.GetValues = intelReadDepthPixels_24_8;
+ drb->Base.PutRow = intelWriteDepthSpan_24_8;
+ drb->Base.PutMonoRow = intelWriteMonoDepthSpan_24_8;
+ drb->Base.PutValues = intelWriteDepthPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = intelReadStencilSpan_24_8;
+ drb->Base.GetValues = intelReadStencilPixels_24_8;
+ drb->Base.PutRow = intelWriteStencilSpan_24_8;
+ drb->Base.PutMonoRow = intelWriteMonoStencilSpan_24_8;
+ drb->Base.PutValues = intelWriteStencilPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_span.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_span.h
new file mode 100644
index 000000000..2d4f8589d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_span.h
@@ -0,0 +1,41 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#ifndef _INTEL_SPAN_H
+#define _INTEL_SPAN_H
+
+#include "drirenderbuffer.h"
+
+extern void intelInitSpanFuncs( GLcontext *ctx );
+
+extern void intelSpanRenderFinish( GLcontext *ctx );
+extern void intelSpanRenderStart( GLcontext *ctx );
+
+extern void
+intelSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_state.c
new file mode 100644
index 000000000..cf1f3c580
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_state.c
@@ -0,0 +1,285 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "enums.h"
+#include "dd.h"
+
+#include "intel_screen.h"
+#include "intel_context.h"
+#include "swrast/swrast.h"
+
+int intel_translate_compare_func( GLenum func )
+{
+ switch(func) {
+ case GL_NEVER:
+ return COMPAREFUNC_NEVER;
+ case GL_LESS:
+ return COMPAREFUNC_LESS;
+ case GL_LEQUAL:
+ return COMPAREFUNC_LEQUAL;
+ case GL_GREATER:
+ return COMPAREFUNC_GREATER;
+ case GL_GEQUAL:
+ return COMPAREFUNC_GEQUAL;
+ case GL_NOTEQUAL:
+ return COMPAREFUNC_NOTEQUAL;
+ case GL_EQUAL:
+ return COMPAREFUNC_EQUAL;
+ case GL_ALWAYS:
+ return COMPAREFUNC_ALWAYS;
+ }
+
+ fprintf(stderr, "Unknown value in %s: %x\n", __FUNCTION__, func);
+ return COMPAREFUNC_ALWAYS;
+}
+
+int intel_translate_stencil_op( GLenum op )
+{
+ switch(op) {
+ case GL_KEEP:
+ return STENCILOP_KEEP;
+ case GL_ZERO:
+ return STENCILOP_ZERO;
+ case GL_REPLACE:
+ return STENCILOP_REPLACE;
+ case GL_INCR:
+ return STENCILOP_INCRSAT;
+ case GL_DECR:
+ return STENCILOP_DECRSAT;
+ case GL_INCR_WRAP:
+ return STENCILOP_INCR;
+ case GL_DECR_WRAP:
+ return STENCILOP_DECR;
+ case GL_INVERT:
+ return STENCILOP_INVERT;
+ default:
+ return STENCILOP_ZERO;
+ }
+}
+
+int intel_translate_blend_factor( GLenum factor )
+{
+ switch(factor) {
+ case GL_ZERO:
+ return BLENDFACT_ZERO;
+ case GL_SRC_ALPHA:
+ return BLENDFACT_SRC_ALPHA;
+ case GL_ONE:
+ return BLENDFACT_ONE;
+ case GL_SRC_COLOR:
+ return BLENDFACT_SRC_COLR;
+ case GL_ONE_MINUS_SRC_COLOR:
+ return BLENDFACT_INV_SRC_COLR;
+ case GL_DST_COLOR:
+ return BLENDFACT_DST_COLR;
+ case GL_ONE_MINUS_DST_COLOR:
+ return BLENDFACT_INV_DST_COLR;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ return BLENDFACT_INV_SRC_ALPHA;
+ case GL_DST_ALPHA:
+ return BLENDFACT_DST_ALPHA;
+ case GL_ONE_MINUS_DST_ALPHA:
+ return BLENDFACT_INV_DST_ALPHA;
+ case GL_SRC_ALPHA_SATURATE:
+ return BLENDFACT_SRC_ALPHA_SATURATE;
+ case GL_CONSTANT_COLOR:
+ return BLENDFACT_CONST_COLOR;
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ return BLENDFACT_INV_CONST_COLOR;
+ case GL_CONSTANT_ALPHA:
+ return BLENDFACT_CONST_ALPHA;
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ return BLENDFACT_INV_CONST_ALPHA;
+ }
+
+ fprintf(stderr, "Unknown value in %s: %x\n", __FUNCTION__, factor);
+ return BLENDFACT_ZERO;
+}
+
+int intel_translate_logic_op( GLenum opcode )
+{
+ switch(opcode) {
+ case GL_CLEAR:
+ return LOGICOP_CLEAR;
+ case GL_AND:
+ return LOGICOP_AND;
+ case GL_AND_REVERSE:
+ return LOGICOP_AND_RVRSE;
+ case GL_COPY:
+ return LOGICOP_COPY;
+ case GL_COPY_INVERTED:
+ return LOGICOP_COPY_INV;
+ case GL_AND_INVERTED:
+ return LOGICOP_AND_INV;
+ case GL_NOOP:
+ return LOGICOP_NOOP;
+ case GL_XOR:
+ return LOGICOP_XOR;
+ case GL_OR:
+ return LOGICOP_OR;
+ case GL_OR_INVERTED:
+ return LOGICOP_OR_INV;
+ case GL_NOR:
+ return LOGICOP_NOR;
+ case GL_EQUIV:
+ return LOGICOP_EQUIV;
+ case GL_INVERT:
+ return LOGICOP_INV;
+ case GL_OR_REVERSE:
+ return LOGICOP_OR_RVRSE;
+ case GL_NAND:
+ return LOGICOP_NAND;
+ case GL_SET:
+ return LOGICOP_SET;
+ default:
+ return LOGICOP_SET;
+ }
+}
+
+static void intelDrawBuffer(GLcontext *ctx, GLenum mode )
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+ intelScreenPrivate *screen = intel->intelScreen;
+ int front = 0;
+
+ if (!ctx->DrawBuffer)
+ return;
+
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ front = 1;
+ FALLBACK( intel, INTEL_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ front = 0;
+ FALLBACK( intel, INTEL_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ break;
+ default:
+ FALLBACK( intel, INTEL_FALLBACK_DRAW_BUFFER, GL_TRUE );
+ return;
+ }
+
+ /* We want to update the s/w rast state too so that r200SetBuffer()
+ * gets called.
+ */
+ _swrast_DrawBuffer(ctx, mode);
+
+ if ( intel->sarea->pf_current_page == 1 )
+ front ^= 1;
+
+ intelSetFrontClipRects( intel );
+
+ if (front) {
+ intel->drawOffset = screen->frontOffset;
+ intel->drawMap = (char *)intel->driScreen->pFB;
+ intel->readMap = (char *)intel->driScreen->pFB;
+ } else {
+ intel->drawOffset = screen->backOffset;
+ intel->drawMap = screen->back.map;
+ intel->readMap = screen->back.map;
+ }
+
+ intel->vtbl.set_draw_offset( intel, intel->drawOffset );
+}
+
+static void intelReadBuffer( GLcontext *ctx, GLenum mode )
+{
+ /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
+}
+
+
+static void intelClearColor(GLcontext *ctx, const GLfloat color[4])
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+ intelScreenPrivate *screen = intel->intelScreen;
+
+ CLAMPED_FLOAT_TO_UBYTE(intel->clear_red, color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(intel->clear_green, color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(intel->clear_blue, color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(intel->clear_alpha, color[3]);
+
+ intel->ClearColor = INTEL_PACKCOLOR(screen->fbFormat,
+ intel->clear_red,
+ intel->clear_green,
+ intel->clear_blue,
+ intel->clear_alpha);
+}
+
+
+static void intelCalcViewport( GLcontext *ctx )
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat *m = intel->ViewportMatrix.m;
+
+ /* See also intel_translate_vertex. SUBPIXEL adjustments can be done
+ * via state vars, too.
+ */
+ m[MAT_SX] = v[MAT_SX];
+ m[MAT_TX] = v[MAT_TX] + SUBPIXEL_X;
+ m[MAT_SY] = - v[MAT_SY];
+ m[MAT_TY] = - v[MAT_TY] + intel->driDrawable->h + SUBPIXEL_Y;
+ m[MAT_SZ] = v[MAT_SZ] * intel->depth_scale;
+ m[MAT_TZ] = v[MAT_TZ] * intel->depth_scale;
+}
+
+static void intelViewport( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ intelCalcViewport( ctx );
+}
+
+static void intelDepthRange( GLcontext *ctx,
+ GLclampd nearval, GLclampd farval )
+{
+ intelCalcViewport( ctx );
+}
+
+/* Fallback to swrast for select and feedback.
+ */
+static void intelRenderMode( GLcontext *ctx, GLenum mode )
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+ FALLBACK( intel, INTEL_FALLBACK_RENDERMODE, (mode != GL_RENDER) );
+}
+
+
+void intelInitStateFuncs( struct dd_function_table *functions )
+{
+ functions->DrawBuffer = intelDrawBuffer;
+ functions->ReadBuffer = intelReadBuffer;
+ functions->RenderMode = intelRenderMode;
+ functions->Viewport = intelViewport;
+ functions->DepthRange = intelDepthRange;
+ functions->ClearColor = intelClearColor;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_tex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_tex.c
new file mode 100644
index 000000000..5fc904e60
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_tex.c
@@ -0,0 +1,831 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "imports.h"
+#include "macros.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "image.h"
+#include "texstore.h"
+#include "texformat.h"
+#include "teximage.h"
+#include "texmem.h"
+#include "texobj.h"
+#include "swrast/swrast.h"
+
+#include "mm.h"
+
+#include "intel_screen.h"
+#include "intel_batchbuffer.h"
+#include "intel_context.h"
+#include "intel_tex.h"
+#include "intel_ioctl.h"
+
+
+
+static GLboolean
+intelValidateClientStorage( intelContextPtr intel, GLenum target,
+ GLint internalFormat,
+ GLint srcWidth, GLint srcHeight,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+
+{
+ GLcontext *ctx = &intel->ctx;
+ int texelBytes;
+
+ if (0)
+ fprintf(stderr, "intformat %s format %s type %s\n",
+ _mesa_lookup_enum_by_nr( internalFormat ),
+ _mesa_lookup_enum_by_nr( format ),
+ _mesa_lookup_enum_by_nr( type ));
+
+ if (!ctx->Unpack.ClientStorage)
+ return 0;
+
+ if (ctx->_ImageTransferState ||
+ texImage->IsCompressed ||
+ texObj->GenerateMipmap)
+ return 0;
+
+
+ /* This list is incomplete
+ */
+ switch ( internalFormat ) {
+ case GL_RGBA:
+ if ( format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV ) {
+ texImage->TexFormat = &_mesa_texformat_argb8888;
+ texelBytes = 4;
+ }
+ else
+ return 0;
+ break;
+
+ case GL_RGB:
+ if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
+ texImage->TexFormat = &_mesa_texformat_rgb565;
+ texelBytes = 2;
+ }
+ else
+ return 0;
+ break;
+
+ case GL_YCBCR_MESA:
+ if ( format == GL_YCBCR_MESA &&
+ type == GL_UNSIGNED_SHORT_8_8_REV_APPLE ) {
+ texImage->TexFormat = &_mesa_texformat_ycbcr_rev;
+ texelBytes = 2;
+ }
+ else if ( format == GL_YCBCR_MESA &&
+ (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
+ type == GL_UNSIGNED_BYTE)) {
+ texImage->TexFormat = &_mesa_texformat_ycbcr;
+ texelBytes = 2;
+ }
+ else
+ return 0;
+ break;
+
+
+ default:
+ return 0;
+ }
+
+ /* Could deal with these packing issues, but currently don't:
+ */
+ if (packing->SkipPixels ||
+ packing->SkipRows ||
+ packing->SwapBytes ||
+ packing->LsbFirst) {
+ return 0;
+ }
+
+ {
+ GLint srcRowStride = _mesa_image_row_stride(packing, srcWidth,
+ format, type);
+
+
+ if (0)
+ fprintf(stderr, "%s: srcRowStride %d/%x\n",
+ __FUNCTION__, srcRowStride, srcRowStride);
+
+ /* Could check this later in upload, pitch restrictions could be
+ * relaxed, but would need to store the image pitch somewhere,
+ * as packing details might change before image is uploaded:
+ */
+ if (!intelIsAgpMemory( intel, pixels, srcHeight * srcRowStride ) ||
+ (srcRowStride & 63))
+ return 0;
+
+
+ /* Have validated that _mesa_transfer_teximage would be a straight
+ * memcpy at this point. NOTE: future calls to TexSubImage will
+ * overwrite the client data. This is explicitly mentioned in the
+ * extension spec.
+ */
+ texImage->Data = (void *)pixels;
+ texImage->IsClientData = GL_TRUE;
+ texImage->RowStride = srcRowStride / texelBytes;
+ return 1;
+ }
+}
+
+
+
+static void intelTexImage1D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+ assert(t);
+ intelFlush( ctx );
+ driSwapOutTextureObject( t );
+
+ texImage->IsClientData = GL_FALSE;
+
+ _mesa_store_teximage1d( ctx, target, level, internalFormat,
+ width, border, format, type,
+ pixels, packing, texObj, texImage );
+
+ t->dirty_images[0] |= (1 << level);
+}
+
+static void intelTexSubImage1D( 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 )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+ assert(t);
+ intelFlush( ctx );
+ driSwapOutTextureObject( t );
+
+ _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
+ format, type, pixels, packing, texObj,
+ texImage);
+}
+
+
+/* Handles 2D, CUBE, RECT:
+ */
+static void intelTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ assert(t);
+ intelFlush( ctx );
+ driSwapOutTextureObject( t );
+ texImage->IsClientData = GL_FALSE;
+
+ if (intelValidateClientStorage( INTEL_CONTEXT(ctx), target,
+ internalFormat,
+ width, height,
+ format, type, pixels,
+ packing, texObj, texImage)) {
+ if (INTEL_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: Using client storage\n", __FUNCTION__);
+ }
+ else {
+ _mesa_store_teximage2d( ctx, target, level, internalFormat,
+ width, height, border, format, type,
+ pixels, packing, texObj, texImage );
+
+ t->dirty_images[face] |= (1 << level);
+ }
+}
+
+static void intelTexSubImage2D( 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 )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ if (texImage->IsClientData &&
+ (char *)pixels == (char *)texImage->Data +
+ ((xoffset + yoffset * texImage->RowStride) *
+ texImage->TexFormat->TexelBytes)) {
+
+ /* Notification only - no upload required */
+ }
+ else {
+ assert( t ); /* this _should_ be true */
+ intelFlush( ctx );
+ driSwapOutTextureObject( t );
+
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
+
+ t->dirty_images[face] |= (1 << level);
+ }
+}
+
+static void intelCompressedTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ assert(t);
+ intelFlush( ctx );
+
+ driSwapOutTextureObject( t );
+ texImage->IsClientData = GL_FALSE;
+
+ if (INTEL_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: Using normal storage\n", __FUNCTION__);
+
+ _mesa_store_compressed_teximage2d(ctx, target, level, internalFormat, width,
+ height, border, imageSize, data, texObj, texImage);
+
+ t->dirty_images[face] |= (1 << level);
+}
+
+
+static void intelCompressedTexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ assert( t ); /* this _should_ be true */
+ intelFlush( ctx );
+ driSwapOutTextureObject( t );
+
+ _mesa_store_compressed_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, imageSize, data, texObj, texImage);
+
+ t->dirty_images[face] |= (1 << level);
+}
+
+
+static void intelTexImage3D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint depth,
+ GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+ assert(t);
+ driSwapOutTextureObject( t );
+ texImage->IsClientData = GL_FALSE;
+
+ _mesa_store_teximage3d(ctx, target, level, internalFormat,
+ width, height, depth, border,
+ format, type, pixels,
+ &ctx->Unpack, texObj, texImage);
+
+ t->dirty_images[0] |= (1 << level);
+}
+
+
+static void
+intelTexSubImage3D( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+ assert( t ); /* this _should_ be true */
+ driSwapOutTextureObject( t );
+
+ _mesa_store_texsubimage3d(ctx, target, level, xoffset, yoffset, zoffset,
+ width, height, depth,
+ format, type, pixels, packing, texObj, texImage);
+
+ t->dirty_images[0] |= (1 << level);
+}
+
+
+
+
+static void intelDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
+{
+ driTextureObject * t = (driTextureObject *) tObj->DriverData;
+
+ if ( t != NULL ) {
+ intelFlush( ctx );
+ driDestroyTextureObject( t );
+ }
+
+ /* Free mipmap images and the texture object itself */
+ _mesa_delete_texture_object(ctx, tObj);
+}
+
+
+static const struct gl_texture_format *
+intelChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type )
+{
+ intelContextPtr intel = INTEL_CONTEXT( ctx );
+ const GLboolean do32bpt = ( intel->intelScreen->cpp == 4 &&
+ intel->intelScreen->textureSize > 4*1024*1024);
+
+ switch ( internalFormat ) {
+ case 4:
+ case GL_RGBA:
+ case GL_COMPRESSED_RGBA:
+ if ( format == GL_BGRA ) {
+ if ( type == GL_UNSIGNED_INT_8_8_8_8_REV ) {
+ return &_mesa_texformat_argb8888;
+ }
+ else if ( type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
+ return &_mesa_texformat_argb4444;
+ }
+ else if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
+ return &_mesa_texformat_argb1555;
+ }
+ }
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+
+ case 3:
+ case GL_RGB:
+ case GL_COMPRESSED_RGB:
+ if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
+ return &_mesa_texformat_rgb565;
+ }
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+
+ case GL_RGBA4:
+ case GL_RGBA2:
+ return &_mesa_texformat_argb4444;
+
+ case GL_RGB5_A1:
+ return &_mesa_texformat_argb1555;
+
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+
+ case GL_RGB5:
+ case GL_RGB4:
+ case GL_R3_G3_B2:
+ return &_mesa_texformat_rgb565;
+
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ case GL_COMPRESSED_ALPHA:
+ return &_mesa_texformat_a8;
+
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ case GL_COMPRESSED_LUMINANCE:
+ return &_mesa_texformat_l8;
+
+ 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_COMPRESSED_LUMINANCE_ALPHA:
+ return &_mesa_texformat_al88;
+
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case GL_COMPRESSED_INTENSITY:
+ return &_mesa_texformat_i8;
+
+ case GL_YCBCR_MESA:
+ if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
+ type == GL_UNSIGNED_BYTE)
+ return &_mesa_texformat_ycbcr;
+ else
+ return &_mesa_texformat_ycbcr_rev;
+
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ return &_mesa_texformat_rgb_fxt1;
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ return &_mesa_texformat_rgba_fxt1;
+
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgb_dxt1;
+
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgba_dxt1;
+
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ return &_mesa_texformat_rgba_dxt3;
+
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ return &_mesa_texformat_rgba_dxt5;
+
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT16:
+ case GL_DEPTH_COMPONENT24:
+ case GL_DEPTH_COMPONENT32:
+ return &_mesa_texformat_depth_component16;
+
+ default:
+ fprintf(stderr, "unexpected texture format %s in %s\n",
+ _mesa_lookup_enum_by_nr(internalFormat),
+ __FUNCTION__);
+ return NULL;
+ }
+
+ return NULL; /* never get here */
+}
+
+
+
+void intelDestroyTexObj(intelContextPtr intel, intelTextureObjectPtr t)
+{
+ unsigned i;
+
+ if ( intel == NULL )
+ return;
+
+ if ( t->age > intel->dirtyAge )
+ intel->dirtyAge = t->age;
+
+ for ( i = 0 ; i < MAX_TEXTURE_UNITS ; i++ ) {
+ if ( t == intel->CurrentTexObj[ i ] )
+ intel->CurrentTexObj[ i ] = NULL;
+ }
+}
+
+
+
+/* Upload an image from mesa's internal copy. Image may be 1D, 2D or
+ * 3D. Cubemaps are expanded elsewhere.
+ */
+static void intelUploadTexImage( intelContextPtr intel,
+ intelTextureObjectPtr t,
+ const struct gl_texture_image *image,
+ const GLuint offset )
+{
+
+ if (!image || !image->Data)
+ return;
+
+ if (image->Depth == 1 && image->IsClientData) {
+ if (INTEL_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "Blit uploading\n");
+
+ /* Do it with a blit.
+ */
+ intelEmitCopyBlitLocked( intel,
+ image->TexFormat->TexelBytes,
+ image->RowStride, /* ? */
+ intelGetMemoryOffsetMESA( NULL, 0, image->Data ),
+ t->Pitch / image->TexFormat->TexelBytes,
+ intelGetMemoryOffsetMESA( NULL, 0, t->BufAddr + offset ),
+ 0, 0,
+ 0, 0,
+ image->Width,
+ image->Height);
+ }
+ else if (image->IsCompressed) {
+ GLuint row_len = image->Width * 2;
+ GLubyte *dst = (GLubyte *)(t->BufAddr + offset);
+ GLubyte *src = (GLubyte *)image->Data;
+ GLuint j;
+
+ if (INTEL_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr,
+ "Upload image %dx%dx%d offset %xm row_len %x "
+ "pitch %x depth_pitch %x\n",
+ image->Width, image->Height, image->Depth, offset,
+ row_len, t->Pitch, t->depth_pitch);
+
+ switch(image->IntFormat)
+ {
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ for (j = 0 ; j < image->Height/4 ; j++, dst += (t->Pitch)) {
+ __memcpy(dst, src, row_len );
+ src += row_len;
+ }
+ break;
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ for (j = 0 ; j < image->Height/4 ; j++, dst += (t->Pitch)) {
+ __memcpy(dst, src, (image->Width*4) );
+ src += image->Width*4;
+ }
+ break;
+ default:
+ fprintf(stderr,"Internal Compressed format not supported %d\n", image->IntFormat);
+ break;
+ }
+ }
+ else {
+ GLuint row_len = image->Width * image->TexFormat->TexelBytes;
+ GLubyte *dst = (GLubyte *)(t->BufAddr + offset);
+ GLubyte *src = (GLubyte *)image->Data;
+ GLuint d, j;
+
+ if (INTEL_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr,
+ "Upload image %dx%dx%d offset %xm row_len %x "
+ "pitch %x depth_pitch %x\n",
+ image->Width, image->Height, image->Depth, offset,
+ row_len, t->Pitch, t->depth_pitch);
+
+ if (row_len == t->Pitch) {
+ for (d = 0; d < image->Depth; d++) {
+ memcpy( dst, src, t->Pitch * image->Height );
+ dst += t->depth_pitch;
+ src += row_len * image->Height;
+ }
+ }
+ else {
+ for (d = 0 ; d < image->Depth ; d++) {
+ for (j = 0 ; j < image->Height ; j++) {
+ __memcpy(dst, src, row_len );
+ src += row_len;
+ dst += t->Pitch;
+ }
+
+ dst += t->depth_pitch - (t->Pitch * image->Height);
+ }
+ }
+ }
+}
+
+
+
+int intelUploadTexImages( intelContextPtr intel,
+ intelTextureObjectPtr t,
+ GLuint face)
+{
+ const int numLevels = t->base.lastLevel - t->base.firstLevel + 1;
+ const struct gl_texture_image *firstImage = t->image[face][t->base.firstLevel].image;
+ int pitch = firstImage->RowStride * firstImage->TexFormat->TexelBytes;
+
+ /* Can we texture out of the existing client data? */
+ if ( numLevels == 1 &&
+ firstImage->IsClientData &&
+ (pitch & 3) == 0) {
+
+ if (INTEL_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "AGP texturing from client memory\n");
+
+ t->TextureOffset = intelAgpOffsetFromVirtual( intel, firstImage->Data );
+ t->BufAddr = 0;
+ t->dirty = ~0;
+ return GL_TRUE;
+ }
+ else {
+ if (INTEL_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "Uploading client data to agp\n");
+
+ INTEL_FIREVERTICES( intel );
+ LOCK_HARDWARE( intel );
+
+ if ( t->base.memBlock == NULL ) {
+ int heap;
+
+ heap = driAllocateTexture( intel->texture_heaps, intel->nr_heaps,
+ (driTextureObject *) t );
+ if ( heap == -1 ) {
+ UNLOCK_HARDWARE( intel );
+ return GL_FALSE;
+ }
+
+ /* Set the base offset of the texture image */
+ t->BufAddr = intel->intelScreen->tex.map + t->base.memBlock->ofs;
+ t->TextureOffset = intel->intelScreen->textureOffset + t->base.memBlock->ofs;
+ t->dirty = ~0;
+ }
+
+
+ /* Let the world know we've used this memory recently.
+ */
+ driUpdateTextureLRU( (driTextureObject *) t );
+
+
+ /* Upload any images that are new */
+ if (t->base.dirty_images[face]) {
+ int i;
+
+ intelWaitForIdle( intel );
+
+ for (i = 0 ; i < numLevels ; i++) {
+ int level = i + t->base.firstLevel;
+
+ if (t->base.dirty_images[face] & (1<<level)) {
+
+ const struct gl_texture_image *image = t->image[face][i].image;
+ GLuint offset = t->image[face][i].offset;
+
+ if (INTEL_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "upload level %d, offset %x\n",
+ level, offset);
+
+ intelUploadTexImage( intel, t, image, offset );
+ }
+ }
+ t->base.dirty_images[face] = 0;
+ intel->perf_boxes |= I830_BOX_TEXTURE_LOAD;
+ }
+
+ UNLOCK_HARDWARE( intel );
+ return GL_TRUE;
+ }
+}
+
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
+ * Note: this function will be called during context creation to
+ * allocate the default texture objects.
+ * Note: we could use containment here to 'derive' the driver-specific
+ * texture object from the core mesa gl_texture_object. Not done at this time.
+ */
+static struct gl_texture_object *
+intelNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+{
+ struct gl_texture_object *obj = _mesa_new_texture_object(ctx, name, target);
+ INTEL_CONTEXT(ctx)->vtbl.alloc_tex_obj( obj );
+ return obj;
+}
+
+
+void intelInitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->NewTextureObject = intelNewTextureObject;
+ functions->ChooseTextureFormat = intelChooseTextureFormat;
+ functions->TexImage1D = intelTexImage1D;
+ functions->TexImage2D = intelTexImage2D;
+ functions->TexImage3D = intelTexImage3D;
+ functions->TexSubImage1D = intelTexSubImage1D;
+ functions->TexSubImage2D = intelTexSubImage2D;
+ functions->TexSubImage3D = intelTexSubImage3D;
+ functions->CopyTexImage1D = _swrast_copy_teximage1d;
+ functions->CopyTexImage2D = _swrast_copy_teximage2d;
+ functions->CopyTexSubImage1D = _swrast_copy_texsubimage1d;
+ functions->CopyTexSubImage2D = _swrast_copy_texsubimage2d;
+ functions->CopyTexSubImage3D = _swrast_copy_texsubimage3d;
+ functions->DeleteTexture = intelDeleteTexture;
+ functions->UpdateTexturePalette = NULL;
+ functions->IsTextureResident = driIsTextureResident;
+ functions->TestProxyTexImage = _mesa_test_proxy_teximage;
+ functions->DeleteTexture = intelDeleteTexture;
+ functions->CompressedTexImage2D = intelCompressedTexImage2D;
+ functions->CompressedTexSubImage2D = intelCompressedTexSubImage2D;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_tex.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_tex.h
new file mode 100644
index 000000000..0a1f697e9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_tex.h
@@ -0,0 +1,42 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#ifndef INTELTEX_INC
+#define INTELTEX_INC
+
+#include "mtypes.h"
+#include "intel_context.h"
+#include "texmem.h"
+
+
+void intelInitTextureFuncs( struct dd_function_table *functions );
+
+void intelDestroyTexObj( intelContextPtr intel, intelTextureObjectPtr t );
+int intelUploadTexImages( intelContextPtr intel, intelTextureObjectPtr t,
+ GLuint face );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_tris.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_tris.c
new file mode 100644
index 000000000..bb0a7713e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_tris.c
@@ -0,0 +1,920 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "enums.h"
+#include "dd.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+#include "tnl/t_vertex.h"
+
+#include "intel_screen.h"
+#include "intel_tris.h"
+#include "intel_batchbuffer.h"
+#include "intel_reg.h"
+#include "intel_span.h"
+
+static void intelRenderPrimitive( GLcontext *ctx, GLenum prim );
+static void intelRasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim );
+
+/***********************************************************************
+ * Emit primitives as inline vertices *
+ ***********************************************************************/
+
+#ifdef __i386__
+#define COPY_DWORDS( j, vb, vertsize, v ) \
+do { \
+ int __tmp; \
+ __asm__ __volatile__( "rep ; movsl" \
+ : "=%c" (j), "=D" (vb), "=S" (__tmp) \
+ : "0" (vertsize), \
+ "D" ((long)vb), \
+ "S" ((long)v) ); \
+} while (0)
+#else
+#define COPY_DWORDS( j, vb, vertsize, v ) \
+do { \
+ if (0) fprintf(stderr, "\n"); \
+ for ( j = 0 ; j < vertsize ; j++ ) { \
+ if (0) fprintf(stderr, " -- v(%d): %x/%f\n",j, \
+ ((GLuint *)v)[j], \
+ ((GLfloat *)v)[j]); \
+ vb[j] = ((GLuint *)v)[j]; \
+ } \
+ vb += vertsize; \
+} while (0)
+#endif
+
+static void __inline__ intel_draw_quad( intelContextPtr intel,
+ intelVertexPtr v0,
+ intelVertexPtr v1,
+ intelVertexPtr v2,
+ intelVertexPtr v3 )
+{
+ GLuint vertsize = intel->vertex_size;
+ GLuint *vb = intelExtendInlinePrimitive( intel, 6 * vertsize );
+ int j;
+
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v3 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v2 );
+ COPY_DWORDS( j, vb, vertsize, v3 );
+}
+
+static void __inline__ intel_draw_triangle( intelContextPtr intel,
+ intelVertexPtr v0,
+ intelVertexPtr v1,
+ intelVertexPtr v2 )
+{
+ GLuint vertsize = intel->vertex_size;
+ GLuint *vb = intelExtendInlinePrimitive( intel, 3 * vertsize );
+ int j;
+
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v2 );
+}
+
+
+static __inline__ void intel_draw_line( intelContextPtr intel,
+ intelVertexPtr v0,
+ intelVertexPtr v1 )
+{
+ GLuint vertsize = intel->vertex_size;
+ GLuint *vb = intelExtendInlinePrimitive( intel, 2 * vertsize );
+ int j;
+
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+}
+
+
+static __inline__ void intel_draw_point( intelContextPtr intel,
+ intelVertexPtr v0 )
+{
+ GLuint vertsize = intel->vertex_size;
+ GLuint *vb = intelExtendInlinePrimitive( intel, vertsize );
+ int j;
+
+ /* Adjust for sub pixel position -- still required for conform. */
+ *(float *)&vb[0] = v0->v.x - 0.125;
+ *(float *)&vb[1] = v0->v.y - 0.125;
+ for (j = 2 ; j < vertsize ; j++)
+ vb[j] = v0->ui[j];
+}
+
+
+
+/***********************************************************************
+ * Fixup for ARB_point_parameters *
+ ***********************************************************************/
+
+static void intel_atten_point( intelContextPtr intel, intelVertexPtr v0 )
+{
+ GLcontext *ctx = &intel->ctx;
+ GLfloat psz[4], col[4], restore_psz, restore_alpha;
+
+ _tnl_get_attr( ctx, v0, _TNL_ATTRIB_POINTSIZE, psz );
+ _tnl_get_attr( ctx, v0, _TNL_ATTRIB_COLOR0, col );
+
+ restore_psz = psz[0];
+ restore_alpha = col[3];
+
+ if (psz[0] >= ctx->Point.Threshold) {
+ psz[0] = MIN2(psz[0], ctx->Point.MaxSize);
+ }
+ else {
+ GLfloat dsize = psz[0] / ctx->Point.Threshold;
+ psz[0] = MAX2(ctx->Point.Threshold, ctx->Point.MinSize);
+ col[3] *= dsize * dsize;
+ }
+
+ if (psz[0] < 1.0)
+ psz[0] = 1.0;
+
+ if (restore_psz != psz[0] || restore_alpha != col[3]) {
+ _tnl_set_attr( ctx, v0, _TNL_ATTRIB_POINTSIZE, psz);
+ _tnl_set_attr( ctx, v0, _TNL_ATTRIB_COLOR0, col);
+
+ intel_draw_point( intel, v0 );
+
+ psz[0] = restore_psz;
+ col[3] = restore_alpha;
+
+ _tnl_set_attr( ctx, v0, _TNL_ATTRIB_POINTSIZE, psz);
+ _tnl_set_attr( ctx, v0, _TNL_ATTRIB_COLOR0, col);
+ }
+ else
+ intel_draw_point( intel, v0 );
+}
+
+
+
+
+
+/***********************************************************************
+ * Fixup for I915 WPOS texture coordinate *
+ ***********************************************************************/
+
+
+
+static void intel_wpos_triangle( intelContextPtr intel,
+ intelVertexPtr v0,
+ intelVertexPtr v1,
+ intelVertexPtr v2 )
+{
+ GLuint offset = intel->wpos_offset;
+ GLuint size = intel->wpos_size;
+
+ __memcpy( ((char *)v0) + offset, v0, size );
+ __memcpy( ((char *)v1) + offset, v1, size );
+ __memcpy( ((char *)v2) + offset, v2, size );
+
+ intel_draw_triangle( intel, v0, v1, v2 );
+}
+
+
+static void intel_wpos_line( intelContextPtr intel,
+ intelVertexPtr v0,
+ intelVertexPtr v1 )
+{
+ GLuint offset = intel->wpos_offset;
+ GLuint size = intel->wpos_size;
+
+ __memcpy( ((char *)v0) + offset, v0, size );
+ __memcpy( ((char *)v1) + offset, v1, size );
+
+ intel_draw_line( intel, v0, v1 );
+}
+
+
+static void intel_wpos_point( intelContextPtr intel,
+ intelVertexPtr v0 )
+{
+ GLuint offset = intel->wpos_offset;
+ GLuint size = intel->wpos_size;
+
+ __memcpy( ((char *)v0) + offset, v0, size );
+
+ intel_draw_point( intel, v0 );
+}
+
+
+
+
+
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ if (DO_FALLBACK) \
+ intel->draw_tri( intel, a, b, c ); \
+ else \
+ intel_draw_triangle( intel, a, b, c ); \
+} while (0)
+
+#define QUAD( a, b, c, d ) \
+do { \
+ if (DO_FALLBACK) { \
+ intel->draw_tri( intel, a, b, d ); \
+ intel->draw_tri( intel, b, c, d ); \
+ } else \
+ intel_draw_quad( intel, a, b, c, d ); \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ if (DO_FALLBACK) \
+ intel->draw_line( intel, v0, v1 ); \
+ else \
+ intel_draw_line( intel, v0, v1 ); \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ if (DO_FALLBACK) \
+ intel->draw_point( intel, v0 ); \
+ else \
+ intel_draw_point( intel, v0 ); \
+} while (0)
+
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define INTEL_OFFSET_BIT 0x01
+#define INTEL_TWOSIDE_BIT 0x02
+#define INTEL_UNFILLED_BIT 0x04
+#define INTEL_FALLBACK_BIT 0x08
+#define INTEL_MAX_TRIFUNC 0x10
+
+
+static struct {
+ tnl_points_func points;
+ tnl_line_func line;
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
+} rast_tab[INTEL_MAX_TRIFUNC];
+
+
+#define DO_FALLBACK (IND & INTEL_FALLBACK_BIT)
+#define DO_OFFSET (IND & INTEL_OFFSET_BIT)
+#define DO_UNFILLED (IND & INTEL_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & INTEL_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 1
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX intelVertex
+#define TAB rast_tab
+
+/* Only used to pull back colors into vertices (ie, we know color is
+ * floating point).
+ */
+#define INTEL_COLOR( dst, src ) \
+do { \
+ UNCLAMPED_FLOAT_TO_UBYTE((dst)[0], (src)[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE((dst)[1], (src)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE((dst)[2], (src)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE((dst)[3], (src)[3]); \
+} while (0)
+
+#define INTEL_SPEC( dst, src ) \
+do { \
+ UNCLAMPED_FLOAT_TO_UBYTE((dst)[0], (src)[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE((dst)[1], (src)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE((dst)[2], (src)[0]); \
+} while (0)
+
+
+#define DEPTH_SCALE intel->polygon_offset_scale
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a > 0)
+#define GET_VERTEX(e) (intel->verts + (e * intel->vertex_size * sizeof(GLuint)))
+
+#define VERT_SET_RGBA( v, c ) if (coloroffset) INTEL_COLOR( v->ub4[coloroffset], c )
+#define VERT_COPY_RGBA( v0, v1 ) if (coloroffset) v0->ui[coloroffset] = v1->ui[coloroffset]
+#define VERT_SAVE_RGBA( idx ) if (coloroffset) color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) if (coloroffset) v[idx]->ui[coloroffset] = color[idx]
+
+#define VERT_SET_SPEC( v, c ) if (specoffset) INTEL_SPEC( v->ub4[specoffset], c )
+#define VERT_COPY_SPEC( v0, v1 ) if (specoffset) COPY_3V(v0->ub4[specoffset], v1->ub4[specoffset])
+#define VERT_SAVE_SPEC( idx ) if (specoffset) spec[idx] = v[idx]->ui[specoffset]
+#define VERT_RESTORE_SPEC( idx ) if (specoffset) v[idx]->ui[specoffset] = spec[idx]
+
+#define LOCAL_VARS(n) \
+ intelContextPtr intel = INTEL_CONTEXT(ctx); \
+ GLuint color[n], spec[n]; \
+ GLuint coloroffset = intel->coloroffset; \
+ GLboolean specoffset = intel->specoffset; \
+ (void) color; (void) spec; (void) coloroffset; (void) specoffset;
+
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ PRIM3D_POINTLIST,
+ PRIM3D_LINELIST,
+ PRIM3D_LINELIST,
+ PRIM3D_LINELIST,
+ PRIM3D_TRILIST,
+ PRIM3D_TRILIST,
+ PRIM3D_TRILIST,
+ PRIM3D_TRILIST,
+ PRIM3D_TRILIST,
+ PRIM3D_TRILIST
+};
+
+#define RASTERIZE(x) intelRasterPrimitive( ctx, x, hw_prim[x] )
+#define RENDER_PRIMITIVE intel->render_primitive
+#define TAG(x) x
+#define IND INTEL_FALLBACK_BIT
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (INTEL_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (INTEL_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (INTEL_TWOSIDE_BIT|INTEL_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (INTEL_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (INTEL_OFFSET_BIT|INTEL_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (INTEL_TWOSIDE_BIT|INTEL_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (INTEL_TWOSIDE_BIT|INTEL_OFFSET_BIT|INTEL_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (INTEL_FALLBACK_BIT)
+#define TAG(x) x##_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (INTEL_OFFSET_BIT|INTEL_FALLBACK_BIT)
+#define TAG(x) x##_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (INTEL_TWOSIDE_BIT|INTEL_FALLBACK_BIT)
+#define TAG(x) x##_twoside_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (INTEL_TWOSIDE_BIT|INTEL_OFFSET_BIT|INTEL_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (INTEL_UNFILLED_BIT|INTEL_FALLBACK_BIT)
+#define TAG(x) x##_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (INTEL_OFFSET_BIT|INTEL_UNFILLED_BIT|INTEL_FALLBACK_BIT)
+#define TAG(x) x##_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (INTEL_TWOSIDE_BIT|INTEL_UNFILLED_BIT|INTEL_FALLBACK_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (INTEL_TWOSIDE_BIT|INTEL_OFFSET_BIT|INTEL_UNFILLED_BIT| \
+ INTEL_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+static void init_rast_tab( void )
+{
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+ init_fallback();
+ init_offset_fallback();
+ init_twoside_fallback();
+ init_twoside_offset_fallback();
+ init_unfilled_fallback();
+ init_offset_unfilled_fallback();
+ init_twoside_unfilled_fallback();
+ init_twoside_offset_unfilled_fallback();
+}
+
+
+/***********************************************************************
+ * Rasterization fallback helpers *
+ ***********************************************************************/
+
+
+/* This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+static void
+intel_fallback_tri( intelContextPtr intel,
+ intelVertex *v0,
+ intelVertex *v1,
+ intelVertex *v2 )
+{
+ GLcontext *ctx = &intel->ctx;
+ SWvertex v[3];
+
+ if (0)
+ fprintf(stderr, "\n%s\n", __FUNCTION__);
+
+ _swsetup_Translate( ctx, v0, &v[0] );
+ _swsetup_Translate( ctx, v1, &v[1] );
+ _swsetup_Translate( ctx, v2, &v[2] );
+ intelSpanRenderStart( ctx );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+ intelSpanRenderFinish( ctx );
+}
+
+
+static void
+intel_fallback_line( intelContextPtr intel,
+ intelVertex *v0,
+ intelVertex *v1 )
+{
+ GLcontext *ctx = &intel->ctx;
+ SWvertex v[2];
+
+ if (0)
+ fprintf(stderr, "\n%s\n", __FUNCTION__);
+
+ _swsetup_Translate( ctx, v0, &v[0] );
+ _swsetup_Translate( ctx, v1, &v[1] );
+ intelSpanRenderStart( ctx );
+ _swrast_Line( ctx, &v[0], &v[1] );
+ intelSpanRenderFinish( ctx );
+}
+
+
+static void
+intel_fallback_point( intelContextPtr intel,
+ intelVertex *v0 )
+{
+ GLcontext *ctx = &intel->ctx;
+ SWvertex v[1];
+
+ if (0)
+ fprintf(stderr, "\n%s\n", __FUNCTION__);
+
+ _swsetup_Translate( ctx, v0, &v[0] );
+ intelSpanRenderStart( ctx );
+ _swrast_Point( ctx, &v[0] );
+ intelSpanRenderFinish( ctx );
+}
+
+
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+#define IND 0
+#define V(x) (intelVertex *)(vertptr + ((x)*vertsize*sizeof(GLuint)))
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) POINT( V(ELT(start)) );
+#define RENDER_LINE( v0, v1 ) LINE( V(v0), V(v1) )
+#define RENDER_TRI( v0, v1, v2 ) TRI( V(v0), V(v1), V(v2) )
+#define RENDER_QUAD( v0, v1, v2, v3 ) QUAD( V(v0), V(v1), V(v2), V(v3) )
+#define INIT(x) intelRenderPrimitive( ctx, x )
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ intelContextPtr intel = INTEL_CONTEXT(ctx); \
+ GLubyte *vertptr = (GLubyte *)intel->verts; \
+ const GLuint vertsize = intel->vertex_size; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ (void) elt;
+#define RESET_STIPPLE
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) x
+#define TAG(x) intel_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+#undef ELT
+#undef TAG
+#define TAG(x) intel_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl/t_vb_rendertmp.h"
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+
+
+static void intelRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLuint prim = intel->render_primitive;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n,
+ PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+ }
+
+ /* Restore the render primitive
+ */
+ if (prim != GL_POLYGON)
+ tnl->Driver.Render.PrimitiveNotify( ctx, prim );
+}
+
+static void intelRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ tnl->Driver.Render.Line( ctx, ii, jj );
+}
+
+static void intelFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ intelContextPtr intel = INTEL_CONTEXT( ctx );
+ const GLuint vertsize = intel->vertex_size;
+ GLuint *vb = intelExtendInlinePrimitive( intel, (n-2) * 3 * vertsize );
+ GLubyte *vertptr = (GLubyte *)intel->verts;
+ const GLuint *start = (const GLuint *)V(elts[0]);
+ int i,j;
+
+ for (i = 2 ; i < n ; i++) {
+ COPY_DWORDS( j, vb, vertsize, V(elts[i-1]) );
+ COPY_DWORDS( j, vb, vertsize, V(elts[i]) );
+ COPY_DWORDS( j, vb, vertsize, start );
+ }
+}
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+
+
+
+#define POINT_FALLBACK (0)
+#define LINE_FALLBACK (DD_LINE_STIPPLE)
+#define TRI_FALLBACK (0)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK|\
+ DD_TRI_STIPPLE|DD_POINT_ATTEN)
+#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
+
+void intelChooseRenderState(GLcontext *ctx)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ struct fragment_program *program = ctx->FragmentProgram._Current;
+ GLboolean have_wpos = (program && (program->InputsRead & FRAG_BIT_WPOS));
+ GLuint index = 0;
+
+ if (INTEL_DEBUG & DEBUG_STATE)
+ fprintf(stderr,"\n%s\n",__FUNCTION__);
+
+ if ((flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) || have_wpos) {
+
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= INTEL_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= INTEL_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= INTEL_UNFILLED_BIT;
+ }
+
+ if (have_wpos) {
+ intel->draw_point = intel_wpos_point;
+ intel->draw_line = intel_wpos_line;
+ intel->draw_tri = intel_wpos_triangle;
+
+ /* Make sure these get called:
+ */
+ index |= INTEL_FALLBACK_BIT;
+ }
+ else {
+ intel->draw_point = intel_draw_point;
+ intel->draw_line = intel_draw_line;
+ intel->draw_tri = intel_draw_triangle;
+ }
+
+ /* Hook in fallbacks for specific primitives.
+ */
+ if (flags & ANY_FALLBACK_FLAGS)
+ {
+ if (flags & POINT_FALLBACK)
+ intel->draw_point = intel_fallback_point;
+
+ if (flags & LINE_FALLBACK)
+ intel->draw_line = intel_fallback_line;
+
+ if (flags & TRI_FALLBACK)
+ intel->draw_tri = intel_fallback_tri;
+
+ if ((flags & DD_TRI_STIPPLE) && !intel->hw_stipple)
+ intel->draw_tri = intel_fallback_tri;
+
+ if (flags & DD_POINT_ATTEN)
+ intel->draw_point = intel_atten_point;
+
+ index |= INTEL_FALLBACK_BIT;
+ }
+ }
+
+ if (intel->RenderIndex != index) {
+ intel->RenderIndex = index;
+
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = intel_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = intel_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */
+ tnl->Driver.Render.ClippedPolygon = intelFastRenderClippedPoly;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = intelRenderClippedLine;
+ tnl->Driver.Render.ClippedPolygon = intelRenderClippedPoly;
+ }
+ }
+}
+
+static const GLenum reduced_prim[GL_POLYGON+1] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES
+};
+
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+
+
+
+static void intelRunPipeline( GLcontext *ctx )
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+
+ if (intel->NewGLState) {
+ if (intel->NewGLState & _NEW_TEXTURE) {
+ intel->vtbl.update_texture_state( intel );
+ }
+
+ if (!intel->Fallback) {
+ if (intel->NewGLState & _INTEL_NEW_RENDERSTATE)
+ intelChooseRenderState( ctx );
+ }
+
+ intel->NewGLState = 0;
+ }
+
+ _tnl_run_pipeline( ctx );
+}
+
+static void intelRenderStart( GLcontext *ctx )
+{
+ INTEL_CONTEXT(ctx)->vtbl.render_start( INTEL_CONTEXT(ctx) );
+}
+
+static void intelRenderFinish( GLcontext *ctx )
+{
+ if (INTEL_CONTEXT(ctx)->RenderIndex & INTEL_FALLBACK_BIT)
+ _swrast_flush( ctx );
+}
+
+
+
+
+ /* System to flush dma and emit state changes based on the rasterized
+ * primitive.
+ */
+static void intelRasterPrimitive( GLcontext *ctx, GLenum rprim, GLuint hwprim )
+{
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+
+ if (0)
+ fprintf(stderr, "%s %s %x\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(rprim), hwprim);
+
+ intel->vtbl.reduced_primitive_state( intel, rprim );
+
+ /* Start a new primitive. Arrange to have it flushed later on.
+ */
+ if (hwprim != intel->prim.primitive)
+ intelStartInlinePrimitive( intel, hwprim );
+}
+
+
+ /*
+ */
+ static void intelRenderPrimitive( GLcontext *ctx, GLenum prim )
+ {
+ intelContextPtr intel = INTEL_CONTEXT(ctx);
+
+ if (0)
+ fprintf(stderr, "%s %s\n", __FUNCTION__, _mesa_lookup_enum_by_nr(prim));
+
+ /* Let some clipping routines know which primitive they're dealing
+ * with.
+ */
+ intel->render_primitive = prim;
+
+ /* Shortcircuit this when called from t_dd_rendertmp.h for unfilled
+ * triangles. The rasterized primitive will always be reset by
+ * lower level functions in that case, potentially pingponging the
+ * state:
+ */
+ if (reduced_prim[prim] == GL_TRIANGLES &&
+ (ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ return;
+
+ /* Set some primitive-dependent state and Start? a new primitive.
+ */
+ intelRasterPrimitive( ctx, reduced_prim[prim], hw_prim[prim] );
+ }
+
+
+ /**********************************************************************/
+ /* Transition to/from hardware rasterization. */
+ /**********************************************************************/
+
+ static char *fallbackStrings[] = {
+ "Texture",
+ "Draw buffer",
+ "Read buffer",
+ "Color mask",
+ "Render mode",
+ "Stencil",
+ "Stipple",
+ "User disable"
+ };
+
+
+ static char *getFallbackString(GLuint bit)
+ {
+ int i = 0;
+ while (bit > 1) {
+ i++;
+ bit >>= 1;
+ }
+ return fallbackStrings[i];
+ }
+
+
+
+ void intelFallback( intelContextPtr intel, GLuint bit, GLboolean mode )
+ {
+ GLcontext *ctx = &intel->ctx;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldfallback = intel->Fallback;
+
+ if (mode) {
+ intel->Fallback |= bit;
+ if (oldfallback == 0) {
+ intelFlush(ctx);
+ if (INTEL_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "ENTER FALLBACK %x: %s\n",
+ bit, getFallbackString( bit ));
+ _swsetup_Wakeup( ctx );
+ intel->RenderIndex = ~0;
+ }
+ }
+ else {
+ intel->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ _swrast_flush( ctx );
+ if (INTEL_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "LEAVE FALLBACK %s\n", getFallbackString( bit ));
+ tnl->Driver.Render.Start = intelRenderStart;
+ tnl->Driver.Render.PrimitiveNotify = intelRenderPrimitive;
+ tnl->Driver.Render.Finish = intelRenderFinish;
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+
+ _tnl_invalidate_vertex_state( ctx, ~0 );
+ _tnl_invalidate_vertices( ctx, ~0 );
+ _tnl_install_attrs( ctx,
+ intel->vertex_attrs,
+ intel->vertex_attr_count,
+ intel->ViewportMatrix.m, 0 );
+
+ intel->NewGLState |= _INTEL_NEW_RENDERSTATE;
+ }
+ }
+ }
+
+
+
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+
+void intelInitTriFuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+ }
+
+ tnl->Driver.RunPipeline = intelRunPipeline;
+ tnl->Driver.Render.Start = intelRenderStart;
+ tnl->Driver.Render.Finish = intelRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = intelRenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_tris.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_tris.h
new file mode 100644
index 000000000..d7e382fdb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/intel_tris.h
@@ -0,0 +1,46 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#ifndef INTELTRIS_INC
+#define INTELTRIS_INC
+
+#include "mtypes.h"
+
+#define _INTEL_NEW_RENDERSTATE (_DD_NEW_LINE_STIPPLE | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET | \
+ _DD_NEW_TRI_STIPPLE | \
+ _NEW_PROGRAM | \
+ _NEW_POLYGONSTIPPLE)
+
+extern void intelInitTriFuncs( GLcontext *ctx );
+
+extern void intelPrintRenderState( const char *msg, GLuint state );
+extern void intelChooseRenderState( GLcontext *ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/server/i830_common.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/server/i830_common.h
new file mode 100644
index 000000000..c03f74289
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/server/i830_common.h
@@ -0,0 +1,169 @@
+/**************************************************************************
+
+Copyright 2001 VA Linux Systems Inc., Fremont, California.
+Copyright 2002 Tungsten Graphics 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, VA LINUX SYSTEMS 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.
+
+**************************************************************************/
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_common.h,v 1.1 2002/09/11 00:29:32 dawes Exp $ */
+
+#ifndef _I830_COMMON_H_
+#define _I830_COMMON_H_
+
+
+#define I830_NR_TEX_REGIONS 255 /* maximum due to use of chars for next/prev */
+#define I830_LOG_MIN_TEX_REGION_SIZE 14
+
+
+/* Driver specific DRM command indices
+ * NOTE: these are not OS specific, but they are driver specific
+ */
+#define DRM_I830_INIT 0x00
+#define DRM_I830_FLUSH 0x01
+#define DRM_I830_FLIP 0x02
+#define DRM_I830_BATCHBUFFER 0x03
+#define DRM_I830_IRQ_EMIT 0x04
+#define DRM_I830_IRQ_WAIT 0x05
+#define DRM_I830_GETPARAM 0x06
+#define DRM_I830_SETPARAM 0x07
+#define DRM_I830_ALLOC 0x08
+#define DRM_I830_FREE 0x09
+#define DRM_I830_INIT_HEAP 0x0a
+#define DRM_I830_CMDBUFFER 0x0b
+
+typedef struct {
+ enum {
+ I830_INIT_DMA = 0x01,
+ I830_CLEANUP_DMA = 0x02,
+ I830_RESUME_DMA = 0x03
+ } func;
+ unsigned int mmio_offset;
+ int sarea_priv_offset;
+ unsigned int ring_start;
+ unsigned int ring_end;
+ unsigned int ring_size;
+ unsigned int front_offset;
+ unsigned int back_offset;
+ unsigned int depth_offset;
+ unsigned int w;
+ unsigned int h;
+ unsigned int pitch;
+ unsigned int pitch_bits;
+ unsigned int back_pitch;
+ unsigned int depth_pitch;
+ unsigned int cpp;
+ unsigned int chipset;
+} drmI830Init;
+
+typedef struct {
+ drmTextureRegion texList[I830_NR_TEX_REGIONS+1];
+ int last_upload; /* last time texture was uploaded */
+ int last_enqueue; /* last time a buffer was enqueued */
+ int last_dispatch; /* age of the most recently dispatched buffer */
+ int ctxOwner; /* last context to upload state */
+ int texAge;
+ int pf_enabled; /* is pageflipping allowed? */
+ int pf_active;
+ int pf_current_page; /* which buffer is being displayed? */
+ int perf_boxes; /* performance boxes to be displayed */
+} drmI830Sarea;
+
+/* Flags for perf_boxes
+ */
+#define I830_BOX_RING_EMPTY 0x1 /* populated by kernel */
+#define I830_BOX_FLIP 0x2 /* populated by kernel */
+#define I830_BOX_WAIT 0x4 /* populated by kernel & client */
+#define I830_BOX_TEXTURE_LOAD 0x8 /* populated by kernel */
+#define I830_BOX_LOST_CONTEXT 0x10 /* populated by client */
+
+
+typedef struct {
+ int start; /* agp offset */
+ int used; /* nr bytes in use */
+ int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
+ int DR4; /* window origin for GFX_OP_DRAWRECT_INFO*/
+ int num_cliprects; /* mulitpass with multiple cliprects? */
+ drm_clip_rect_t *cliprects; /* pointer to userspace cliprects */
+} drmI830BatchBuffer;
+
+typedef struct {
+ char *buf; /* agp offset */
+ int sz; /* nr bytes in use */
+ int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
+ int DR4; /* window origin for GFX_OP_DRAWRECT_INFO*/
+ int num_cliprects; /* mulitpass with multiple cliprects? */
+ drm_clip_rect_t *cliprects; /* pointer to userspace cliprects */
+} drmI830CmdBuffer;
+
+
+typedef struct {
+ int *irq_seq;
+} drmI830IrqEmit;
+
+typedef struct {
+ int irq_seq;
+} drmI830IrqWait;
+
+typedef struct {
+ int param;
+ int *value;
+} drmI830GetParam;
+
+#define I830_PARAM_IRQ_ACTIVE 1
+#define I830_PARAM_ALLOW_BATCHBUFFER 2
+
+typedef struct {
+ int param;
+ int value;
+} drmI830SetParam;
+
+#define I830_SETPARAM_USE_MI_BATCHBUFFER_START 1
+#define I830_SETPARAM_TEX_LRU_LOG_GRANULARITY 2
+#define I830_SETPARAM_ALLOW_BATCHBUFFER 3
+
+
+/* A memory manager for regions of shared memory:
+ */
+#define I830_MEM_REGION_AGP 1
+
+typedef struct {
+ int region;
+ int alignment;
+ int size;
+ int *region_offset; /* offset from start of fb or agp */
+} drmI830MemAlloc;
+
+typedef struct {
+ int region;
+ int region_offset;
+} drmI830MemFree;
+
+typedef struct {
+ int region;
+ int size;
+ int start;
+} drmI830MemInitHeap;
+
+
+#endif /* _I830_DRM_H_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/server/i830_dri.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/server/i830_dri.h
new file mode 100644
index 000000000..978f47a2b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/i915/server/i830_dri.h
@@ -0,0 +1,69 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i830_dri.h,v 1.4 2002/10/30 12:52:18 alanh Exp $ */
+
+#ifndef _I830_DRI_H
+#define _I830_DRI_H
+
+#include "xf86drm.h"
+#include "i830_common.h"
+
+#define I830_MAX_DRAWABLES 256
+
+#define I830_MAJOR_VERSION 1
+#define I830_MINOR_VERSION 3
+#define I830_PATCHLEVEL 0
+
+#define I830_REG_SIZE 0x80000
+
+/* Note: This structure has changed slightly from what is expected by
+ * the i830_drv.o driver. Maybe that should be reverted.
+ */
+typedef struct _I830DRIRec {
+ drm_handle_t regs;
+ drmSize regsSize;
+
+ drmSize backbufferSize;
+ drm_handle_t backbuffer;
+
+ drmSize depthbufferSize;
+ drm_handle_t depthbuffer;
+
+ drm_handle_t textures;
+ int textureSize;
+
+ drm_handle_t agp_buffers;
+ drmSize agp_buf_size;
+
+ int deviceID;
+ int width;
+ int height;
+ int mem;
+ int cpp;
+ int bitsPerPixel;
+ int fbOffset;
+ int fbStride;
+
+ int backOffset;
+ int backPitch;
+
+ int depthOffset;
+ int depthPitch;
+
+ int logTextureGranularity;
+ int textureOffset;
+
+ int irq;
+ int sarea_priv_offset;
+} I830DRIRec, *I830DRIPtr;
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} I830ConfigPrivRec, *I830ConfigPrivPtr;
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} I830DRIContextRec, *I830DRIContextPtr;
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/Makefile
new file mode 100644
index 000000000..7246d51f5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/Makefile
@@ -0,0 +1,33 @@
+# src/mesa/drivers/dri/mach64/Makefile
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = mach64_dri.so
+
+# Not yet
+# MINIGLX_SOURCES = server/mach64_dri.c
+
+DRIVER_SOURCES = \
+ mach64_context.c \
+ mach64_ioctl.c \
+ mach64_screen.c \
+ mach64_span.c \
+ mach64_state.c \
+ mach64_tex.c \
+ mach64_texmem.c \
+ mach64_texstate.c \
+ mach64_tris.c \
+ mach64_vb.c \
+ mach64_dd.c \
+ mach64_lock.c
+
+C_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+include ../Makefile.template
+
+symlinks:
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_context.c
new file mode 100644
index 000000000..717b9b9e8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_context.c
@@ -0,0 +1,338 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * Jos�Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "simple_list.h"
+#include "imports.h"
+#include "matrix.h"
+#include "extensions.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+
+#include "drivers/common/driverfuncs.h"
+
+#include "mach64_context.h"
+#include "mach64_ioctl.h"
+#include "mach64_dd.h"
+#include "mach64_span.h"
+#include "mach64_state.h"
+#include "mach64_tex.h"
+#include "mach64_tris.h"
+#include "mach64_vb.h"
+
+#include "utils.h"
+#include "vblank.h"
+
+#define need_GL_ARB_multisample
+#include "extension_helper.h"
+
+#ifndef MACH64_DEBUG
+int MACH64_DEBUG = (0);
+#endif
+
+static const struct dri_debug_control debug_control[] =
+{
+ { "sync", DEBUG_ALWAYS_SYNC },
+ { "api", DEBUG_VERBOSE_API },
+ { "msg", DEBUG_VERBOSE_MSG },
+ { "lru", DEBUG_VERBOSE_LRU },
+ { "dri", DEBUG_VERBOSE_DRI },
+ { "ioctl", DEBUG_VERBOSE_IOCTL },
+ { "prims", DEBUG_VERBOSE_PRIMS },
+ { "count", DEBUG_VERBOSE_COUNT },
+ { "nowait", DEBUG_NOWAIT },
+ { "fall", DEBUG_VERBOSE_FALLBACK },
+ { NULL, 0 }
+};
+
+const struct dri_extension card_extensions[] =
+{
+ { "GL_ARB_multisample", GL_ARB_multisample_functions },
+ { "GL_ARB_multitexture", NULL },
+ { "GL_EXT_texture_edge_clamp", NULL },
+ { "GL_MESA_ycbcr_texture", NULL },
+ { "GL_SGIS_generate_mipmap", NULL },
+ { NULL, NULL }
+};
+
+
+/* Create the device specific context.
+ */
+GLboolean mach64CreateContext( const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate )
+{
+ GLcontext *ctx, *shareCtx;
+ __DRIscreenPrivate *driScreen = driContextPriv->driScreenPriv;
+ struct dd_function_table functions;
+ mach64ContextPtr mmesa;
+ mach64ScreenPtr mach64Screen;
+ int i, heap;
+
+#if DO_DEBUG
+ MACH64_DEBUG = driParseDebugString(getenv("MACH64_DEBUG"), debug_control);
+#endif
+
+ /* Allocate the mach64 context */
+ mmesa = (mach64ContextPtr) CALLOC( sizeof(*mmesa) );
+ if ( !mmesa )
+ return GL_FALSE;
+
+ /* Init default driver functions then plug in our Mach64-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions( &functions );
+ mach64InitDriverFuncs( &functions );
+ mach64InitIoctlFuncs( &functions );
+ mach64InitTextureFuncs( &functions );
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((mach64ContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ mmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
+ &functions, (void *)mmesa);
+ if (!mmesa->glCtx) {
+ FREE(mmesa);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = mmesa;
+ ctx = mmesa->glCtx;
+
+ mmesa->driContext = driContextPriv;
+ mmesa->driScreen = driScreen;
+ mmesa->driDrawable = NULL;
+ mmesa->hHWContext = driContextPriv->hHWContext;
+ mmesa->driHwLock = &driScreen->pSAREA->lock;
+ mmesa->driFd = driScreen->fd;
+
+ mach64Screen = mmesa->mach64Screen = (mach64ScreenPtr)driScreen->private;
+
+ /* Parse configuration files */
+ driParseConfigFiles (&mmesa->optionCache, &mach64Screen->optionCache,
+ mach64Screen->driScreen->myNum, "mach64");
+
+ mmesa->sarea = (drm_mach64_sarea_t *)((char *)driScreen->pSAREA +
+ sizeof(drm_sarea_t));
+
+ mmesa->CurrentTexObj[0] = NULL;
+ mmesa->CurrentTexObj[1] = NULL;
+
+ make_empty_list( &mmesa->SwappedOut );
+
+ mmesa->firstTexHeap = mach64Screen->firstTexHeap;
+ mmesa->lastTexHeap = mach64Screen->firstTexHeap + mach64Screen->numTexHeaps;
+
+ for ( i = mmesa->firstTexHeap ; i < mmesa->lastTexHeap ; i++ ) {
+ make_empty_list( &mmesa->TexObjList[i] );
+ mmesa->texHeap[i] = mmInit( 0, mach64Screen->texSize[i] );
+ mmesa->lastTexAge[i] = -1;
+ }
+
+ mmesa->RenderIndex = -1; /* Impossible value */
+ mmesa->vert_buf = NULL;
+ mmesa->num_verts = 0;
+ mmesa->new_state = MACH64_NEW_ALL;
+ mmesa->dirty = MACH64_UPLOAD_ALL;
+
+ /* 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 memory (on-card or AGP) at once.
+ * Test for 2 textures * bytes/texel * size * size. There's no
+ * need to account for mipmaps since we only upload one level.
+ */
+ heap = mach64Screen->IsPCI ? MACH64_CARD_HEAP : MACH64_AGP_HEAP;
+
+ if ( mach64Screen->texSize[heap] >= 2 * mach64Screen->cpp * 1024*1024 ) {
+ ctx->Const.MaxTextureLevels = 11; /* 1024x1024 */
+ } else if ( mach64Screen->texSize[heap] >= 2 * mach64Screen->cpp * 512*512 ) {
+ ctx->Const.MaxTextureLevels = 10; /* 512x512 */
+ } else {
+ ctx->Const.MaxTextureLevels = 9; /* 256x256 */
+ }
+
+ ctx->Const.MaxTextureUnits = 2;
+
+#if ENABLE_PERF_BOXES
+ mmesa->boxes = ( getenv( "LIBGL_PERFORMANCE_BOXES" ) != NULL );
+#endif
+
+ /* Allocate the vertex buffer
+ */
+ mmesa->vert_buf = ALIGN_MALLOC(MACH64_BUFFER_SIZE, 32);
+ if ( !mmesa->vert_buf )
+ return GL_FALSE;
+ mmesa->vert_used = 0;
+ mmesa->vert_total = MACH64_BUFFER_SIZE;
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+
+ /* Install the customized pipeline:
+ */
+/* _tnl_destroy_pipeline( ctx ); */
+/* _tnl_install_pipeline( ctx, mach64_pipeline ); */
+
+ /* Configure swrast and T&L to match hardware characteristics:
+ */
+ _swrast_allow_pixel_fog( ctx, GL_FALSE );
+ _swrast_allow_vertex_fog( ctx, GL_TRUE );
+ _tnl_allow_pixel_fog( ctx, GL_FALSE );
+ _tnl_allow_vertex_fog( ctx, GL_TRUE );
+
+ driInitExtensions( ctx, card_extensions, GL_TRUE );
+
+ mach64InitVB( ctx );
+ mach64InitTriFuncs( ctx );
+ mach64DDInitStateFuncs( ctx );
+ mach64DDInitSpanFuncs( ctx );
+ mach64DDInitState( mmesa );
+
+ mmesa->do_irqs = (mmesa->mach64Screen->irq && !getenv("MACH64_NO_IRQS"));
+
+ mmesa->vblank_flags = (mmesa->do_irqs)
+ ? driGetDefaultVBlankFlags(&mmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
+
+ driContextPriv->driverPrivate = (void *)mmesa;
+
+ if (driQueryOptionb(&mmesa->optionCache, "no_rast")) {
+ fprintf(stderr, "disabling 3D acceleration\n");
+ FALLBACK(mmesa, MACH64_FALLBACK_DISABLE, 1);
+ }
+
+ return GL_TRUE;
+}
+
+/* Destroy the device specific context.
+ */
+void mach64DestroyContext( __DRIcontextPrivate *driContextPriv )
+{
+ mach64ContextPtr mmesa = (mach64ContextPtr) driContextPriv->driverPrivate;
+
+ assert(mmesa); /* should never be null */
+ if ( mmesa ) {
+ if (mmesa->glCtx->Shared->RefCount == 1) {
+ /* This share group is about to go away, free our private
+ * texture object data.
+ */
+ mach64TexObjPtr t, next_t;
+ int i;
+
+ for ( i = mmesa->firstTexHeap ; i < mmesa->lastTexHeap ; i++ ) {
+ foreach_s ( t, next_t, &mmesa->TexObjList[i] ) {
+ mach64DestroyTexObj( mmesa, t );
+ }
+ mmDestroy( mmesa->texHeap[i] );
+ mmesa->texHeap[i] = NULL;
+ }
+
+ foreach_s ( t, next_t, &mmesa->SwappedOut ) {
+ mach64DestroyTexObj( mmesa, t );
+ }
+ }
+
+ _swsetup_DestroyContext( mmesa->glCtx );
+ _tnl_DestroyContext( mmesa->glCtx );
+ _ac_DestroyContext( mmesa->glCtx );
+ _swrast_DestroyContext( mmesa->glCtx );
+
+ mach64FreeVB( mmesa->glCtx );
+
+ /* Free the vertex buffer */
+ if ( mmesa->vert_buf )
+ ALIGN_FREE( mmesa->vert_buf );
+
+ /* free the Mesa context */
+ mmesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(mmesa->glCtx);
+
+ FREE( mmesa );
+ }
+}
+
+/* Force the context `c' to be the current context and associate with it
+ * buffer `b'.
+ */
+GLboolean
+mach64MakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv )
+{
+ if ( driContextPriv ) {
+ GET_CURRENT_CONTEXT(ctx);
+ mach64ContextPtr oldMach64Ctx = ctx ? MACH64_CONTEXT(ctx) : NULL;
+ mach64ContextPtr newMach64Ctx = (mach64ContextPtr) driContextPriv->driverPrivate;
+
+ if ( newMach64Ctx != oldMach64Ctx ) {
+ newMach64Ctx->new_state |= MACH64_NEW_CONTEXT;
+ newMach64Ctx->dirty = MACH64_UPLOAD_ALL;
+ }
+
+
+ driDrawableInitVBlank( driDrawPriv, newMach64Ctx->vblank_flags );
+
+ if ( newMach64Ctx->driDrawable != driDrawPriv ) {
+ newMach64Ctx->driDrawable = driDrawPriv;
+ mach64CalcViewport( newMach64Ctx->glCtx );
+ }
+
+ _mesa_make_current( newMach64Ctx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
+
+
+ newMach64Ctx->new_state |= MACH64_NEW_CLIP;
+ } else {
+ _mesa_make_current( NULL, NULL, NULL );
+ }
+
+ return GL_TRUE;
+}
+
+
+/* Force the context `c' to be unbound from its buffer.
+ */
+GLboolean
+mach64UnbindContext( __DRIcontextPrivate *driContextPriv )
+{
+ return GL_TRUE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_context.h
new file mode 100644
index 000000000..c541f77ab
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_context.h
@@ -0,0 +1,405 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * Jos�Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#ifndef __MACH64_CONTEXT_H__
+#define __MACH64_CONTEXT_H__
+
+#include "dri_util.h"
+#include "drm.h"
+#include "mach64_drm.h"
+
+#include "mtypes.h"
+
+#include "mach64_reg.h"
+
+#include "texmem.h"
+
+struct mach64_context;
+typedef struct mach64_context mach64ContextRec;
+typedef struct mach64_context *mach64ContextPtr;
+
+#include "mach64_lock.h"
+#include "mach64_screen.h"
+
+/* Experimental driver options */
+#define MACH64_CLIENT_STATE_EMITS 0
+
+/* Performace monitoring */
+#define ENABLE_PERF_BOXES 1
+
+/* Native vertex format */
+#define MACH64_NATIVE_VTXFMT 1
+
+/* Flags for what context state needs to be updated:
+ */
+#define MACH64_NEW_ALPHA 0x0001
+#define MACH64_NEW_DEPTH 0x0002
+#define MACH64_NEW_FOG 0x0004
+#define MACH64_NEW_CLIP 0x0008
+#define MACH64_NEW_CULL 0x0010
+#define MACH64_NEW_MASKS 0x0020
+#define MACH64_NEW_RENDER_UNUSED 0x0040
+#define MACH64_NEW_WINDOW 0x0080
+#define MACH64_NEW_TEXTURE 0x0100
+#define MACH64_NEW_CONTEXT 0x0200
+#define MACH64_NEW_ALL 0x03ff
+
+/* Flags for software fallback cases:
+ */
+#define MACH64_FALLBACK_TEXTURE 0x0001
+#define MACH64_FALLBACK_DRAW_BUFFER 0x0002
+#define MACH64_FALLBACK_READ_BUFFER 0x0004
+#define MACH64_FALLBACK_STENCIL 0x0008
+#define MACH64_FALLBACK_RENDER_MODE 0x0010
+#define MACH64_FALLBACK_LOGICOP 0x0020
+#define MACH64_FALLBACK_SEP_SPECULAR 0x0040
+#define MACH64_FALLBACK_BLEND_EQ 0x0080
+#define MACH64_FALLBACK_BLEND_FUNC 0x0100
+#define MACH64_FALLBACK_DISABLE 0x0200
+
+#define CARD32 GLuint /* KW: For building in mesa tree */
+
+#if MACH64_NATIVE_VTXFMT
+
+/* The vertex structures.
+ */
+
+/* The size of this union is not of relevence:
+ */
+union mach64_vertex_t {
+ GLfloat f[16];
+ GLuint ui[16];
+ GLushort us2[16][2];
+ GLubyte ub4[16][4];
+};
+
+typedef union mach64_vertex_t mach64Vertex, *mach64VertexPtr;
+
+#else
+
+/* Use the templated vertex format:
+ */
+#define TAG(x) mach64##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+#endif /* MACH64_NATIVE_VTXFMT */
+
+/* Subpixel offsets for window coordinates:
+ * These are enough to fix most glean tests except polygonOffset.
+ * There are also still some gaps that show in e.g. the tunnel Mesa demo
+ * or the lament xscreensaver hack.
+ */
+#define SUBPIXEL_X (0.0125F)
+#define SUBPIXEL_Y (0.15F)
+
+
+typedef void (*mach64_tri_func)( mach64ContextPtr,
+ mach64Vertex *,
+ mach64Vertex *,
+ mach64Vertex * );
+
+typedef void (*mach64_line_func)( mach64ContextPtr,
+ mach64Vertex *,
+ mach64Vertex * );
+
+typedef void (*mach64_point_func)( mach64ContextPtr,
+ mach64Vertex * );
+
+#ifdef TEXMEM
+struct mach64_texture_object {
+ driTextureObject base;
+
+ GLuint offset;
+
+ GLuint dirty;
+ GLuint age;
+
+ GLint widthLog2;
+ GLint heightLog2;
+ GLint maxLog2;
+
+ GLint hasAlpha;
+ GLint textureFormat;
+
+ /* Have to keep these separate due to how they are programmed.
+ * FIXME: Why don't we just use the tObj values?
+ */
+ GLboolean BilinearMin;
+ GLboolean BilinearMag;
+ GLboolean ClampS;
+ GLboolean ClampT;
+};
+#else
+struct mach64_texture_object {
+ struct mach64_texture_object *next;
+ struct mach64_texture_object *prev;
+ struct gl_texture_object *tObj;
+
+ PMemBlock memBlock;
+ GLuint offset;
+ GLuint size;
+
+ GLuint dirty;
+ GLuint age;
+
+ GLint bound;
+ GLint heap;
+
+ GLint widthLog2;
+ GLint heightLog2;
+ GLint maxLog2;
+
+ GLint hasAlpha;
+ GLint textureFormat;
+
+ /* Have to keep these separate due to how they are programmed.
+ * FIXME: Why don't we just use the tObj values?
+ */
+ GLboolean BilinearMin;
+ GLboolean BilinearMag;
+ GLboolean ClampS;
+ GLboolean ClampT;
+};
+#endif
+
+typedef struct mach64_texture_object mach64TexObj, *mach64TexObjPtr;
+
+
+struct mach64_context {
+ GLcontext *glCtx;
+
+ /* Driver and hardware state management
+ */
+ GLuint new_state;
+ GLuint dirty; /* Hardware state to be updated */
+ drm_mach64_context_regs_t setup;
+
+ GLuint NewGLState;
+ GLuint Fallback;
+ GLuint SetupIndex;
+ GLuint SetupNewInputs;
+ GLuint RenderIndex;
+ GLfloat hw_viewport[16];
+ GLfloat depth_scale;
+ GLuint vertex_size;
+ GLuint vertex_stride_shift;
+ GLuint vertex_format;
+ GLuint num_verts;
+ GLubyte *verts;
+
+ CARD32 Color; /* Current draw color */
+ CARD32 ClearColor; /* Color used to clear color buffer */
+ CARD32 ClearDepth; /* Value used to clear depth buffer */
+
+ /* Map GL texture units onto hardware
+ */
+ GLint multitex;
+ GLint tmu_source[2];
+ GLint tex_dest[2];
+
+ /* Texture object bookkeeping
+ */
+ mach64TexObjPtr CurrentTexObj[2];
+#ifdef TEXMEM
+ unsigned nr_heaps;
+ driTexHeap * texture_heaps[ R128_NR_TEX_HEAPS ];
+ driTextureObject swapped;
+#else
+ mach64TexObj TexObjList[MACH64_NR_TEX_HEAPS];
+ mach64TexObj SwappedOut;
+ memHeap_t *texHeap[MACH64_NR_TEX_HEAPS];
+ GLuint lastTexAge[MACH64_NR_TEX_HEAPS];
+ GLint firstTexHeap, lastTexHeap;
+#endif
+
+ /* Fallback rasterization functions
+ */
+ mach64_point_func draw_point;
+ mach64_line_func draw_line;
+ mach64_tri_func draw_tri;
+
+ /* Culling */
+ GLfloat backface_sign;
+
+ /* DMA buffers
+ */
+ void *vert_buf;
+ size_t vert_total;
+ unsigned vert_used;
+
+ GLuint hw_primitive;
+ GLenum render_primitive;
+
+ /* Visual, drawable, cliprect and scissor information
+ */
+ GLint drawOffset, drawPitch;
+ GLint drawX, drawY; /* origin of drawable in draw buffer */
+ GLint readOffset, readPitch;
+
+ GLuint numClipRects; /* Cliprects for the draw buffer */
+ drm_clip_rect_t *pClipRects;
+
+ GLint scissor;
+ drm_clip_rect_t ScissorRect; /* Current software scissor */
+
+ /* Mirrors of some DRI state
+ */
+ __DRIcontextPrivate *driContext; /* DRI context */
+ __DRIscreenPrivate *driScreen; /* DRI screen */
+ __DRIdrawablePrivate *driDrawable; /* DRI drawable bound to this ctx */
+
+ unsigned int lastStamp; /* mirror driDrawable->lastStamp */
+
+ drm_context_t hHWContext;
+ drm_hw_lock_t *driHwLock;
+ int driFd;
+
+ mach64ScreenPtr mach64Screen; /* Screen private DRI data */
+ drm_mach64_sarea_t *sarea; /* Private SAREA data */
+
+ GLuint hardwareWentIdle;
+
+#if ENABLE_PERF_BOXES
+ /* Performance counters
+ */
+ GLuint boxes; /* Draw performance boxes */
+ GLuint c_clears;
+ GLuint c_drawWaits;
+ GLuint c_textureSwaps;
+ GLuint c_textureBytes;
+ GLuint c_agpTextureBytes;
+ GLuint c_texsrc_agp;
+ GLuint c_texsrc_card;
+ GLuint c_vertexBuffers;
+#endif
+
+ /* VBI
+ */
+ GLuint vbl_seq;
+ GLuint vblank_flags;
+ GLuint do_irqs;
+
+ /* Configuration cache
+ */
+ driOptionCache optionCache;
+};
+
+#define MACH64_CONTEXT(ctx) ((mach64ContextPtr)(ctx->DriverCtx))
+
+
+extern GLboolean mach64CreateContext( const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate );
+
+extern void mach64DestroyContext( __DRIcontextPrivate * );
+
+extern GLboolean mach64MakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv );
+
+extern GLboolean mach64UnbindContext( __DRIcontextPrivate *driContextPriv );
+
+/* ================================================================
+ * Byte ordering
+ */
+#if MESA_LITTLE_ENDIAN == 1
+#define LE32_IN( x ) ( *(GLuint *)(x) )
+#define LE32_IN_FLOAT( x ) ( *(GLfloat *)(x) )
+#define LE32_OUT( x, y ) do { *(GLuint *)(x) = (y); } while (0)
+#define LE32_OUT_FLOAT( x, y ) do { *(GLfloat *)(x) = (y); } while (0)
+#else
+#include <byteswap.h>
+#define LE32_IN( x ) bswap_32( *(GLuint *)(x) )
+#define LE32_IN_FLOAT( x ) \
+({ \
+ GLuint __tmp = bswap_32( *(GLuint *)(x) ); \
+ *(GLfloat *)&__tmp; \
+})
+#define LE32_OUT( x, y ) do { *(GLuint *)(x) = bswap_32( y ); } while (0)
+#define LE32_OUT_FLOAT( x, y ) \
+do { \
+ GLuint __tmp; \
+ *(GLfloat *)&__tmp = (y); \
+ *(GLuint *)(x) = bswap_32( __tmp ); \
+} while (0)
+#endif
+
+/* ================================================================
+ * DMA buffers
+ */
+
+#define DMALOCALS CARD32 *buf=NULL; int requested=0; int outcount=0
+
+/* called while locked for interleaved client-side state emits */
+#define DMAGETPTR( dwords ) \
+do { \
+ requested = (dwords); \
+ buf = (CARD32 *)mach64AllocDmaLocked( mmesa, ((dwords)*4) ); \
+ outcount = 0; \
+} while(0)
+
+#define DMAOUTREG( reg, val ) \
+do { \
+ LE32_OUT( &buf[outcount++], ADRINDEX( reg ) ); \
+ LE32_OUT( &buf[outcount++], ( val ) ); \
+} while(0)
+
+#define DMAADVANCE() \
+do { \
+ if (outcount < requested) { \
+ mmesa->vert_used -= (requested - outcount) * 4; \
+ } \
+} while(0)
+
+/* ================================================================
+ * Debugging:
+ */
+
+#define DO_DEBUG 1
+
+#if DO_DEBUG
+extern int MACH64_DEBUG;
+#else
+#define MACH64_DEBUG 0
+#endif
+
+#define DEBUG_ALWAYS_SYNC 0x001
+#define DEBUG_VERBOSE_API 0x002
+#define DEBUG_VERBOSE_MSG 0x004
+#define DEBUG_VERBOSE_LRU 0x008
+#define DEBUG_VERBOSE_DRI 0x010
+#define DEBUG_VERBOSE_IOCTL 0x020
+#define DEBUG_VERBOSE_PRIMS 0x040
+#define DEBUG_VERBOSE_COUNT 0x080
+#define DEBUG_NOWAIT 0x100
+#define DEBUG_VERBOSE_FALLBACK 0x200
+#endif /* __MACH64_CONTEXT_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_dd.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_dd.c
new file mode 100644
index 000000000..7c27c5856
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_dd.c
@@ -0,0 +1,135 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#include "mach64_context.h"
+#include "mach64_ioctl.h"
+#include "mach64_state.h"
+#include "mach64_vb.h"
+#include "mach64_dd.h"
+
+#include "context.h"
+#include "utils.h"
+#include "framebuffer.h"
+
+#define DRIVER_DATE "20051019"
+
+/* Return the current color buffer size.
+ */
+static void mach64DDGetBufferSize( GLframebuffer *buffer,
+ GLuint *width, GLuint *height )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ LOCK_HARDWARE( mmesa );
+ *width = mmesa->driDrawable->w;
+ *height = mmesa->driDrawable->h;
+ UNLOCK_HARDWARE( mmesa );
+}
+
+/* Return various strings for glGetString().
+ */
+static const GLubyte *mach64DDGetString( GLcontext *ctx, GLenum name )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ static char buffer[128];
+ unsigned offset;
+ const char * card_name = "Mach64 [Rage Pro]";
+ GLuint agp_mode = mmesa->mach64Screen->IsPCI ? 0 :
+ mmesa->mach64Screen->AGPMode;
+
+ switch ( name ) {
+ case GL_VENDOR:
+ return (GLubyte*)"Gareth Hughes, Leif Delgass, José Fonseca";
+
+ case GL_RENDERER:
+
+ offset = driGetRendererString( buffer, card_name, DRIVER_DATE,
+ agp_mode );
+ return (GLubyte *)buffer;
+
+ 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 mach64DDFlush( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ LOCK_HARDWARE( mmesa );
+ FLUSH_DMA_LOCKED( mmesa );
+ UNLOCK_HARDWARE( mmesa );
+
+#if ENABLE_PERF_BOXES
+ if ( mmesa->boxes ) {
+ LOCK_HARDWARE( mmesa );
+ mach64PerformanceBoxesLocked( mmesa );
+ UNLOCK_HARDWARE( mmesa );
+ }
+
+ /* Log the performance counters if necessary */
+ mach64PerformanceCounters( mmesa );
+#endif
+}
+
+/* Make sure all commands have been sent to the hardware and have
+ * completed processing.
+ */
+static void mach64DDFinish( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+#if ENABLE_PERF_BOXES
+ /* Bump the performance counter */
+ mmesa->c_drawWaits++;
+#endif
+
+ mach64DDFlush( ctx );
+ mach64WaitForIdle( mmesa );
+}
+
+/* Initialize the driver's misc functions.
+ */
+void mach64InitDriverFuncs( struct dd_function_table *functions )
+{
+ functions->GetBufferSize = mach64DDGetBufferSize;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
+ functions->GetString = mach64DDGetString;
+ functions->Finish = mach64DDFinish;
+ functions->Flush = mach64DDFlush;
+
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_dd.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_dd.h
new file mode 100644
index 000000000..74cf1d304
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_dd.h
@@ -0,0 +1,36 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ *
+ */
+
+#ifndef __MACH64_DD_H__
+#define __MACH64_DD_H__
+
+extern void mach64InitDriverFuncs( struct dd_function_table *functions );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_ioctl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_ioctl.c
new file mode 100644
index 000000000..1889dc2b9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_ioctl.c
@@ -0,0 +1,912 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * Jos�Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+#include <errno.h>
+
+#include "mach64_context.h"
+#include "mach64_state.h"
+#include "mach64_ioctl.h"
+#include "mach64_tex.h"
+
+#include "imports.h"
+#include "macros.h"
+
+#include "swrast/swrast.h"
+
+#include "vblank.h"
+
+#define MACH64_TIMEOUT 10 /* the DRM already has a timeout, so keep this small */
+
+
+/* =============================================================
+ * Hardware vertex buffer handling
+ */
+
+/* Get a new VB from the pool of vertex buffers in AGP space.
+ */
+drmBufPtr mach64GetBufferLocked( mach64ContextPtr mmesa )
+{
+ int fd = mmesa->mach64Screen->driScreen->fd;
+ int index = 0;
+ int size = 0;
+ drmDMAReq dma;
+ drmBufPtr buf = NULL;
+ int to = 0;
+ int ret;
+
+ dma.context = mmesa->hHWContext;
+ dma.send_count = 0;
+ dma.send_list = NULL;
+ dma.send_sizes = NULL;
+ dma.flags = 0;
+ dma.request_count = 1;
+ dma.request_size = MACH64_BUFFER_SIZE;
+ dma.request_list = &index;
+ dma.request_sizes = &size;
+ dma.granted_count = 0;
+
+ while ( !buf && ( to++ < MACH64_TIMEOUT ) ) {
+ ret = drmDMA( fd, &dma );
+
+ if ( ret == 0 ) {
+ buf = &mmesa->mach64Screen->buffers->list[index];
+ buf->used = 0;
+#if ENABLE_PERF_BOXES
+ /* Bump the performance counter */
+ mmesa->c_vertexBuffers++;
+#endif
+ return buf;
+ }
+ }
+
+ if ( !buf ) {
+ drmCommandNone( fd, DRM_MACH64_RESET );
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "Error: Could not get new VB... exiting\n" );
+ exit( -1 );
+ }
+
+ return buf;
+}
+
+void mach64FlushVerticesLocked( mach64ContextPtr mmesa )
+{
+ drm_clip_rect_t *pbox = mmesa->pClipRects;
+ int nbox = mmesa->numClipRects;
+ void *buffer = mmesa->vert_buf;
+ int count = mmesa->vert_used;
+ int prim = mmesa->hw_primitive;
+ int fd = mmesa->driScreen->fd;
+ drm_mach64_vertex_t vertex;
+ int i, ret;
+
+ mmesa->num_verts = 0;
+ mmesa->vert_used = 0;
+
+ if ( !count )
+ return;
+
+ if ( mmesa->dirty & ~MACH64_UPLOAD_CLIPRECTS )
+ mach64EmitHwStateLocked( mmesa );
+
+ if ( !nbox )
+ count = 0;
+
+ if ( nbox > MACH64_NR_SAREA_CLIPRECTS )
+ mmesa->dirty |= MACH64_UPLOAD_CLIPRECTS;
+
+ if ( !count || !(mmesa->dirty & MACH64_UPLOAD_CLIPRECTS) ) {
+ /* FIXME: Is this really necessary */
+ if ( nbox == 1 )
+ mmesa->sarea->nbox = 0;
+ else
+ mmesa->sarea->nbox = nbox;
+
+ vertex.prim = prim;
+ vertex.buf = buffer;
+ vertex.used = count;
+ vertex.discard = 1;
+ ret = drmCommandWrite( fd, DRM_MACH64_VERTEX, &vertex, sizeof(drm_mach64_vertex_t) );
+ if ( ret ) {
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "Error flushing vertex buffer: return = %d\n", ret );
+ exit( -1 );
+ }
+
+ } else {
+
+ for ( i = 0 ; i < nbox ; ) {
+ int nr = MIN2( i + MACH64_NR_SAREA_CLIPRECTS, nbox );
+ drm_clip_rect_t *b = mmesa->sarea->boxes;
+ int discard = 0;
+
+ mmesa->sarea->nbox = nr - i;
+ for ( ; i < nr ; i++ ) {
+ *b++ = pbox[i];
+ }
+
+ /* Finished with the buffer?
+ */
+ if ( nr == nbox ) {
+ discard = 1;
+ }
+
+ mmesa->sarea->dirty |= MACH64_UPLOAD_CLIPRECTS;
+
+ vertex.prim = prim;
+ vertex.buf = buffer;
+ vertex.used = count;
+ vertex.discard = discard;
+ ret = drmCommandWrite( fd, DRM_MACH64_VERTEX, &vertex, sizeof(drm_mach64_vertex_t) );
+ if ( ret ) {
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "Error flushing vertex buffer: return = %d\n", ret );
+ exit( -1 );
+ }
+ }
+ }
+
+ mmesa->dirty &= ~MACH64_UPLOAD_CLIPRECTS;
+}
+
+/* ================================================================
+ * Texture uploads
+ */
+
+void mach64FireBlitLocked( mach64ContextPtr mmesa, drmBufPtr buffer,
+ GLint offset, GLint pitch, GLint format,
+ GLint x, GLint y, GLint width, GLint height )
+{
+ drm_mach64_blit_t blit;
+ GLint ret;
+
+ blit.idx = buffer->idx;
+ blit.offset = offset;
+ blit.pitch = pitch;
+ blit.format = format;
+ blit.x = x;
+ blit.y = y;
+ blit.width = width;
+ blit.height = height;
+
+ ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_BLIT,
+ &blit, sizeof(drm_mach64_blit_t) );
+
+ if ( ret ) {
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "DRM_MACH64_BLIT: return = %d\n", ret );
+ exit( -1 );
+ }
+}
+
+
+/* ================================================================
+ * SwapBuffers with client-side throttling
+ */
+static void delay( void ) {
+/* Prevent an optimizing compiler from removing a spin loop */
+}
+
+/* Throttle the frame rate -- only allow MACH64_MAX_QUEUED_FRAMES
+ * pending swap buffers requests at a time.
+ *
+ * GH: We probably don't want a timeout here, as we can wait as
+ * long as we want for a frame to complete. If it never does, then
+ * the card has locked.
+ */
+static int mach64WaitForFrameCompletion( mach64ContextPtr mmesa )
+{
+ int fd = mmesa->driFd;
+ int i;
+ int wait = 0;
+ int frames;
+
+ while ( 1 ) {
+ drm_mach64_getparam_t gp;
+ int ret;
+
+ if ( mmesa->sarea->frames_queued < MACH64_MAX_QUEUED_FRAMES ) {
+ break;
+ }
+
+ if (MACH64_DEBUG & DEBUG_NOWAIT) {
+ return 1;
+ }
+
+ gp.param = MACH64_PARAM_FRAMES_QUEUED;
+ gp.value = &frames; /* also copied into sarea->frames_queued by DRM */
+
+ ret = drmCommandWriteRead( fd, DRM_MACH64_GETPARAM, &gp, sizeof(gp) );
+
+ if ( ret ) {
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "DRM_MACH64_GETPARAM: return = %d\n", ret );
+ exit( -1 );
+ }
+
+ /* Spin in place a bit so we aren't hammering the register */
+ wait++;
+
+ for ( i = 0 ; i < 1024 ; i++ ) {
+ delay();
+ }
+
+ }
+
+ return wait;
+}
+
+/* Copy the back color buffer to the front color buffer.
+ */
+void mach64CopyBuffer( const __DRIdrawablePrivate *dPriv )
+{
+ mach64ContextPtr mmesa;
+ GLint nbox, i, ret;
+ drm_clip_rect_t *pbox;
+ GLboolean missed_target;
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ mmesa = (mach64ContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "\n********************************\n" );
+ fprintf( stderr, "\n%s( %p )\n\n",
+ __FUNCTION__, mmesa->glCtx );
+ fflush( stderr );
+ }
+
+ /* Flush any outstanding vertex buffers */
+ FLUSH_BATCH( mmesa );
+
+ LOCK_HARDWARE( mmesa );
+
+ /* Throttle the frame rate -- only allow one pending swap buffers
+ * request at a time.
+ */
+ if ( !mach64WaitForFrameCompletion( mmesa ) ) {
+ mmesa->hardwareWentIdle = 1;
+ } else {
+ mmesa->hardwareWentIdle = 0;
+ }
+
+#if ENABLE_PERF_BOXES
+ if ( mmesa->boxes ) {
+ mach64PerformanceBoxesLocked( mmesa );
+ }
+#endif
+
+ UNLOCK_HARDWARE( mmesa );
+ driWaitForVBlank( dPriv, &mmesa->vbl_seq, mmesa->vblank_flags, &missed_target );
+ LOCK_HARDWARE( mmesa );
+
+ /* use front buffer cliprects */
+ nbox = dPriv->numClipRects;
+ pbox = dPriv->pClipRects;
+
+ for ( i = 0 ; i < nbox ; ) {
+ GLint nr = MIN2( i + MACH64_NR_SAREA_CLIPRECTS , nbox );
+ drm_clip_rect_t *b = mmesa->sarea->boxes;
+ GLint n = 0;
+
+ for ( ; i < nr ; i++ ) {
+ *b++ = pbox[i];
+ n++;
+ }
+ mmesa->sarea->nbox = n;
+
+ ret = drmCommandNone( mmesa->driFd, DRM_MACH64_SWAP );
+
+ if ( ret ) {
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "DRM_MACH64_SWAP: return = %d\n", ret );
+ exit( -1 );
+ }
+ }
+
+ if ( MACH64_DEBUG & DEBUG_ALWAYS_SYNC ) {
+ mach64WaitForIdleLocked( mmesa );
+ }
+
+ UNLOCK_HARDWARE( mmesa );
+
+ mmesa->dirty |= (MACH64_UPLOAD_CONTEXT |
+ MACH64_UPLOAD_MISC |
+ MACH64_UPLOAD_CLIPRECTS);
+
+#if ENABLE_PERF_BOXES
+ /* Log the performance counters if necessary */
+ mach64PerformanceCounters( mmesa );
+#endif
+}
+
+#if ENABLE_PERF_BOXES
+/* ================================================================
+ * Performance monitoring
+ */
+
+void mach64PerformanceCounters( mach64ContextPtr mmesa )
+{
+
+ if (MACH64_DEBUG & DEBUG_VERBOSE_COUNT) {
+ /* report performance counters */
+ fprintf( stderr, "mach64CopyBuffer: vertexBuffers:%i drawWaits:%i clears:%i\n",
+ mmesa->c_vertexBuffers, mmesa->c_drawWaits, mmesa->c_clears );
+ }
+
+ mmesa->c_vertexBuffers = 0;
+ mmesa->c_drawWaits = 0;
+ mmesa->c_clears = 0;
+
+ if ( mmesa->c_textureSwaps || mmesa->c_textureBytes || mmesa->c_agpTextureBytes ) {
+ if (MACH64_DEBUG & DEBUG_VERBOSE_COUNT) {
+ fprintf( stderr, " textureSwaps:%i textureBytes:%i agpTextureBytes:%i\n",
+ mmesa->c_textureSwaps, mmesa->c_textureBytes, mmesa->c_agpTextureBytes );
+ }
+ mmesa->c_textureSwaps = 0;
+ mmesa->c_textureBytes = 0;
+ mmesa->c_agpTextureBytes = 0;
+ }
+
+ mmesa->c_texsrc_agp = 0;
+ mmesa->c_texsrc_card = 0;
+
+ if (MACH64_DEBUG & DEBUG_VERBOSE_COUNT)
+ fprintf( stderr, "---------------------------------------------------------\n" );
+}
+
+
+void mach64PerformanceBoxesLocked( mach64ContextPtr mmesa )
+{
+ GLint ret;
+ drm_mach64_clear_t clear;
+ GLint x, y, w, h;
+ GLuint color;
+ GLint nbox;
+ GLint x1, y1, x2, y2;
+ drm_clip_rect_t *b = mmesa->sarea->boxes;
+
+ /* save cliprects */
+ nbox = mmesa->sarea->nbox;
+ x1 = b[0].x1;
+ y1 = b[0].y1;
+ x2 = b[0].x2;
+ y2 = b[0].y2;
+
+ /* setup a single cliprect and call the clear ioctl for each box */
+ mmesa->sarea->nbox = 1;
+
+ w = h = 8;
+ x = mmesa->drawX;
+ y = mmesa->drawY;
+ b[0].x1 = x;
+ b[0].x2 = x + w;
+ b[0].y1 = y;
+ b[0].y2 = y + h;
+
+ clear.flags = MACH64_BACK;
+ clear.clear_depth = 0;
+
+ /* Red box if DDFinish was called to wait for rendering to complete */
+ if ( mmesa->c_drawWaits ) {
+ color = mach64PackColor( mmesa->mach64Screen->cpp, 255, 0, 0, 0 );
+
+ clear.x = x;
+ clear.y = y;
+ clear.w = w;
+ clear.h = h;
+ clear.clear_color = color;
+
+ ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR,
+ &clear, sizeof(drm_mach64_clear_t) );
+
+ if (ret < 0) {
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret );
+ exit( -1 );
+ }
+
+ }
+
+ x += w;
+ b[0].x1 = x;
+ b[0].x2 = x + w;
+
+ /* draw a green box if we had to wait for previous frame(s) to complete */
+ if ( !mmesa->hardwareWentIdle ) {
+ color = mach64PackColor( mmesa->mach64Screen->cpp, 0, 255, 0, 0 );
+
+ clear.x = x;
+ clear.y = y;
+ clear.w = w;
+ clear.h = h;
+ clear.clear_color = color;
+
+ ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR,
+ &clear, sizeof(drm_mach64_clear_t) );
+
+ if (ret < 0) {
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret );
+ exit( -1 );
+ }
+
+ }
+
+ x += w;
+ w = 20;
+ b[0].x1 = x;
+
+ /* show approx. ratio of AGP/card textures used - Blue = AGP, Purple = Card */
+ if ( mmesa->c_texsrc_agp || mmesa->c_texsrc_card ) {
+ color = mach64PackColor( mmesa->mach64Screen->cpp, 0, 0, 255, 0 );
+ w = ((GLfloat)mmesa->c_texsrc_agp / (GLfloat)(mmesa->c_texsrc_agp + mmesa->c_texsrc_card))*20;
+ if (w > 1) {
+
+ b[0].x2 = x + w;
+
+ clear.x = x;
+ clear.y = y;
+ clear.w = w;
+ clear.h = h;
+ clear.clear_color = color;
+
+ ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR,
+ &clear, sizeof(drm_mach64_clear_t) );
+
+ if (ret < 0) {
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret );
+ exit( -1 );
+ }
+ }
+
+ x += w;
+ w = 20 - w;
+
+ if (w > 1) {
+ b[0].x1 = x;
+ b[0].x2 = x + w;
+
+ color = mach64PackColor( mmesa->mach64Screen->cpp, 255, 0, 255, 0 );
+
+ clear.x = x;
+ clear.y = y;
+ clear.w = w;
+ clear.h = h;
+ clear.clear_color = color;
+
+ ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR,
+ &clear, sizeof(drm_mach64_clear_t) );
+
+ if (ret < 0) {
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret );
+ exit( -1 );
+ }
+ }
+ }
+
+ x += w;
+ w = 8;
+ b[0].x1 = x;
+ b[0].x2 = x + w;
+
+ /* Yellow box if we swapped textures */
+ if ( mmesa->c_textureSwaps ) {
+ color = mach64PackColor( mmesa->mach64Screen->cpp, 255, 255, 0, 0 );
+
+ clear.x = x;
+ clear.y = y;
+ clear.w = w;
+ clear.h = h;
+ clear.clear_color = color;
+
+ ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR,
+ &clear, sizeof(drm_mach64_clear_t) );
+
+ if (ret < 0) {
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret );
+ exit( -1 );
+ }
+
+ }
+
+ h = 4;
+ x += 8;
+ b[0].x1 = x;
+ b[0].y2 = y + h;
+
+ /* Purple bar for card memory texture blits/uploads */
+ if ( mmesa->c_textureBytes ) {
+ color = mach64PackColor( mmesa->mach64Screen->cpp, 255, 0, 255, 0 );
+ w = mmesa->c_textureBytes / 16384;
+ if ( w <= 0 )
+ w = 1;
+ if (w > (mmesa->driDrawable->w - 44))
+ w = mmesa->driDrawable->w - 44;
+
+ b[0].x2 = x + w;
+
+ clear.x = x;
+ clear.y = y;
+ clear.w = w;
+ clear.h = h;
+ clear.clear_color = color;
+
+ ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR,
+ &clear, sizeof(drm_mach64_clear_t) );
+
+ if (ret < 0) {
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret );
+ exit( -1 );
+ }
+ }
+
+ /* Blue bar for AGP memory texture blits/uploads */
+ if ( mmesa->c_agpTextureBytes ) {
+ color = mach64PackColor( mmesa->mach64Screen->cpp, 0, 0, 255, 0 );
+ w = mmesa->c_agpTextureBytes / 16384;
+ if ( w <= 0 )
+ w = 1;
+ if (w > (mmesa->driDrawable->w - 44))
+ w = mmesa->driDrawable->w - 44;
+
+ y += 4;
+ b[0].x2 = x + w;
+ b[0].y1 = y;
+ b[0].y2 = y + h;
+
+ clear.x = x;
+ clear.y = y;
+ clear.w = w;
+ clear.h = h;
+ clear.clear_color = color;
+
+ ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR,
+ &clear, sizeof(drm_mach64_clear_t) );
+
+ if (ret < 0) {
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret );
+ exit( -1 );
+ }
+ }
+
+ /* Pink bar for number of vertex buffers used */
+ if ( mmesa->c_vertexBuffers ) {
+ color = mach64PackColor( mmesa->mach64Screen->cpp, 196, 128, 128, 0 );
+
+ w = mmesa->c_vertexBuffers;
+ if (w > (mmesa->driDrawable->w))
+ w = mmesa->driDrawable->w;
+
+ h = 8;
+ x = mmesa->drawX;
+ y = mmesa->drawY + 8;
+ b[0].x1 = x;
+ b[0].x2 = x + w;
+ b[0].y1 = y;
+ b[0].y2 = y + h;
+
+ clear.x = x;
+ clear.y = y;
+ clear.w = w;
+ clear.h = h;
+ clear.clear_color = color;
+
+ ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR,
+ &clear, sizeof(drm_mach64_clear_t) );
+
+ if (ret < 0) {
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret );
+ exit( -1 );
+ }
+ }
+
+ /* restore cliprects */
+ mmesa->sarea->nbox = nbox;
+ b[0].x1 = x1;
+ b[0].y1 = y1;
+ b[0].x2 = x2;
+ b[0].y2 = y2;
+
+}
+
+#endif
+
+/* ================================================================
+ * Buffer clear
+ */
+
+static void mach64DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT( ctx );
+ __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
+ drm_mach64_clear_t clear;
+ GLuint flags = 0;
+ GLint i;
+ GLint ret;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s: all=%d %d,%d %dx%d\n",
+ __FUNCTION__, all, cx, cy, cw, ch );
+ }
+
+#if ENABLE_PERF_BOXES
+ /* Bump the performance counter */
+ mmesa->c_clears++;
+#endif
+
+ FLUSH_BATCH( mmesa );
+
+ /* The only state changes we care about here are the RGBA colormask
+ * and scissor/clipping. We'll just update that state, if needed.
+ */
+ if ( mmesa->new_state & (MACH64_NEW_MASKS | MACH64_NEW_CLIP) ) {
+ const GLuint save_state = mmesa->new_state;
+ mmesa->new_state &= (MACH64_NEW_MASKS | MACH64_NEW_CLIP);
+ mach64DDUpdateHWState( ctx );
+ mmesa->new_state = save_state & ~(MACH64_NEW_MASKS | MACH64_NEW_CLIP);
+ }
+
+ if ( mask & BUFFER_BIT_FRONT_LEFT ) {
+ flags |= MACH64_FRONT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
+ }
+
+ if ( mask & BUFFER_BIT_BACK_LEFT ) {
+ flags |= MACH64_BACK;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
+ }
+
+ if ( ( mask & BUFFER_BIT_DEPTH ) && ctx->Depth.Mask ) {
+ flags |= MACH64_DEPTH;
+ mask &= ~BUFFER_BIT_DEPTH;
+ }
+
+ if ( mask )
+ _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
+
+ if ( !flags )
+ return;
+
+ LOCK_HARDWARE( mmesa );
+
+ /* This needs to be in the locked region, so updated drawable origin is used */
+ /* Flip top to bottom */
+ cx += mmesa->drawX;
+ cy = mmesa->drawY + dPriv->h - cy - ch;
+
+ /* HACK?
+ */
+ if ( mmesa->dirty & ~MACH64_UPLOAD_CLIPRECTS ) {
+ mach64EmitHwStateLocked( mmesa );
+ }
+
+ for ( i = 0 ; i < mmesa->numClipRects ; ) {
+ int nr = MIN2( i + MACH64_NR_SAREA_CLIPRECTS, mmesa->numClipRects );
+ drm_clip_rect_t *box = mmesa->pClipRects;
+ drm_clip_rect_t *b = mmesa->sarea->boxes;
+ GLint n = 0;
+
+ if ( !all ) {
+ for ( ; i < nr ; i++ ) {
+ GLint x = box[i].x1;
+ GLint y = box[i].y1;
+ GLint w = box[i].x2 - x;
+ GLint h = box[i].y2 - y;
+
+ 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 ) continue;
+ if ( h <= 0 ) continue;
+
+ b->x1 = x;
+ b->y1 = y;
+ b->x2 = x + w;
+ b->y2 = y + h;
+ b++;
+ n++;
+ }
+ } else {
+ for ( ; i < nr ; i++ ) {
+ *b++ = box[i];
+ n++;
+ }
+ }
+
+ mmesa->sarea->nbox = n;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_IOCTL ) {
+ fprintf( stderr,
+ "DRM_MACH64_CLEAR: flag 0x%x color %x depth %x nbox %d\n",
+ flags,
+ (GLuint)mmesa->ClearColor,
+ (GLuint)mmesa->ClearDepth,
+ mmesa->sarea->nbox );
+ }
+
+ clear.flags = flags;
+ clear.x = cx;
+ clear.y = cy;
+ clear.w = cw;
+ clear.h = ch;
+ clear.clear_color = mmesa->ClearColor;
+ clear.clear_depth = mmesa->ClearDepth;
+
+ ret = drmCommandWrite( mmesa->driFd, DRM_MACH64_CLEAR,
+ &clear, sizeof(drm_mach64_clear_t) );
+
+ if ( ret ) {
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "DRM_MACH64_CLEAR: return = %d\n", ret );
+ exit( -1 );
+ }
+ }
+
+ UNLOCK_HARDWARE( mmesa );
+
+ mmesa->dirty |= (MACH64_UPLOAD_CONTEXT |
+ MACH64_UPLOAD_MISC |
+ MACH64_UPLOAD_CLIPRECTS);
+
+}
+
+
+void mach64WaitForIdleLocked( mach64ContextPtr mmesa )
+{
+ int fd = mmesa->driFd;
+ int to = 0;
+ int ret;
+
+ do {
+ ret = drmCommandNone( fd, DRM_MACH64_IDLE );
+ } while ( ( ret == -EBUSY ) && ( to++ < MACH64_TIMEOUT ) );
+
+ if ( ret < 0 ) {
+ drmCommandNone( fd, DRM_MACH64_RESET );
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "Error: Mach64 timed out... exiting\n" );
+ exit( -1 );
+ }
+}
+
+/* Flush the DMA queue to the hardware */
+void mach64FlushDMALocked( mach64ContextPtr mmesa )
+{
+ int fd = mmesa->driFd;
+ int ret;
+
+ ret = drmCommandNone( fd, DRM_MACH64_FLUSH );
+
+ if ( ret < 0 ) {
+ drmCommandNone( fd, DRM_MACH64_RESET );
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "Error flushing DMA... exiting\n" );
+ exit( -1 );
+ }
+
+ mmesa->dirty |= (MACH64_UPLOAD_CONTEXT |
+ MACH64_UPLOAD_MISC |
+ MACH64_UPLOAD_CLIPRECTS);
+
+}
+
+/* For client-side state emits - currently unused */
+void mach64UploadHwStateLocked( mach64ContextPtr mmesa )
+{
+ drm_mach64_sarea_t *sarea = mmesa->sarea;
+
+ drm_mach64_context_regs_t *regs = &sarea->context_state;
+ unsigned int dirty = sarea->dirty;
+ CARD32 offset = ((regs->tex_size_pitch & 0xf0) >> 2);
+
+ DMALOCALS;
+
+ DMAGETPTR( 19*2 );
+
+ if ( dirty & MACH64_UPLOAD_MISC ) {
+ DMAOUTREG( MACH64_DP_MIX, regs->dp_mix );
+ DMAOUTREG( MACH64_DP_SRC, regs->dp_src );
+ DMAOUTREG( MACH64_CLR_CMP_CNTL, regs->clr_cmp_cntl );
+ DMAOUTREG( MACH64_GUI_TRAJ_CNTL, regs->gui_traj_cntl );
+ DMAOUTREG( MACH64_SC_LEFT_RIGHT, regs->sc_left_right );
+ DMAOUTREG( MACH64_SC_TOP_BOTTOM, regs->sc_top_bottom );
+ sarea->dirty &= ~MACH64_UPLOAD_MISC;
+ }
+
+ if ( dirty & MACH64_UPLOAD_DST_OFF_PITCH ) {
+ DMAOUTREG( MACH64_DST_OFF_PITCH, regs->dst_off_pitch );
+ sarea->dirty &= ~MACH64_UPLOAD_DST_OFF_PITCH;
+ }
+ if ( dirty & MACH64_UPLOAD_Z_OFF_PITCH ) {
+ DMAOUTREG( MACH64_Z_OFF_PITCH, regs->z_off_pitch );
+ sarea->dirty &= ~MACH64_UPLOAD_Z_OFF_PITCH;
+ }
+ if ( dirty & MACH64_UPLOAD_Z_ALPHA_CNTL ) {
+ DMAOUTREG( MACH64_Z_CNTL, regs->z_cntl );
+ DMAOUTREG( MACH64_ALPHA_TST_CNTL, regs->alpha_tst_cntl );
+ sarea->dirty &= ~MACH64_UPLOAD_Z_ALPHA_CNTL;
+ }
+ if ( dirty & MACH64_UPLOAD_SCALE_3D_CNTL ) {
+ DMAOUTREG( MACH64_SCALE_3D_CNTL, regs->scale_3d_cntl );
+ sarea->dirty &= ~MACH64_UPLOAD_SCALE_3D_CNTL;
+ }
+ if ( dirty & MACH64_UPLOAD_DP_FOG_CLR ) {
+ DMAOUTREG( MACH64_DP_FOG_CLR, regs->dp_fog_clr );
+ sarea->dirty &= ~MACH64_UPLOAD_DP_FOG_CLR;
+ }
+ if ( dirty & MACH64_UPLOAD_DP_WRITE_MASK ) {
+ DMAOUTREG( MACH64_DP_WRITE_MASK, regs->dp_write_mask );
+ sarea->dirty &= ~MACH64_UPLOAD_DP_WRITE_MASK;
+ }
+ if ( dirty & MACH64_UPLOAD_DP_PIX_WIDTH ) {
+ DMAOUTREG( MACH64_DP_PIX_WIDTH, regs->dp_pix_width );
+ sarea->dirty &= ~MACH64_UPLOAD_DP_PIX_WIDTH;
+ }
+ if ( dirty & MACH64_UPLOAD_SETUP_CNTL ) {
+ DMAOUTREG( MACH64_SETUP_CNTL, regs->setup_cntl );
+ sarea->dirty &= ~MACH64_UPLOAD_SETUP_CNTL;
+ }
+
+ if ( dirty & MACH64_UPLOAD_TEXTURE ) {
+ DMAOUTREG( MACH64_TEX_SIZE_PITCH, regs->tex_size_pitch );
+ DMAOUTREG( MACH64_TEX_CNTL, regs->tex_cntl );
+ DMAOUTREG( MACH64_SECONDARY_TEX_OFF, regs->secondary_tex_off );
+ DMAOUTREG( MACH64_TEX_0_OFF + offset, regs->tex_offset );
+ sarea->dirty &= ~MACH64_UPLOAD_TEXTURE;
+ }
+
+#if 0
+ if ( dirty & MACH64_UPLOAD_CLIPRECTS ) {
+ DMAOUTREG( MACH64_SC_LEFT_RIGHT, regs->sc_left_right );
+ DMAOUTREG( MACH64_SC_TOP_BOTTOM, regs->sc_top_bottom );
+ sarea->dirty &= ~MACH64_UPLOAD_CLIPRECTS;
+ }
+#endif
+
+ sarea->dirty = 0;
+
+ DMAADVANCE();
+}
+
+void mach64InitIoctlFuncs( struct dd_function_table *functions )
+{
+ functions->Clear = mach64DDClear;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_ioctl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_ioctl.h
new file mode 100644
index 000000000..8bd958531
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_ioctl.h
@@ -0,0 +1,148 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#ifndef __MACH64_IOCTL_H__
+#define __MACH64_IOCTL_H__
+
+#include "mach64_dri.h"
+#include "mach64_reg.h"
+#include "mach64_lock.h"
+
+#define MACH64_BUFFER_MAX_DWORDS (MACH64_BUFFER_SIZE / sizeof(CARD32))
+
+
+extern drmBufPtr mach64GetBufferLocked( mach64ContextPtr mmesa );
+extern void mach64FlushVerticesLocked( mach64ContextPtr mmesa );
+extern void mach64FlushDMALocked( mach64ContextPtr mmesa );
+extern void mach64UploadHwStateLocked( mach64ContextPtr mmesa );
+
+static __inline void *mach64AllocDmaLow( mach64ContextPtr mmesa, int bytes )
+{
+ CARD32 *head;
+
+ if ( mmesa->vert_used + bytes > mmesa->vert_total ) {
+ LOCK_HARDWARE( mmesa );
+ mach64FlushVerticesLocked( mmesa );
+ UNLOCK_HARDWARE( mmesa );
+ }
+
+ head = (CARD32 *)((char *)mmesa->vert_buf + mmesa->vert_used);
+ mmesa->vert_used += bytes;
+
+ return head;
+}
+
+static __inline void *mach64AllocDmaLocked( mach64ContextPtr mmesa, int bytes )
+{
+ CARD32 *head;
+
+ if ( mmesa->vert_used + bytes > mmesa->vert_total ) {
+ mach64FlushVerticesLocked( mmesa );
+ }
+
+ head = (CARD32 *)((char *)mmesa->vert_buf + mmesa->vert_used);
+ mmesa->vert_used += bytes;
+
+ return head;
+}
+
+extern void mach64FireBlitLocked( mach64ContextPtr mmesa, drmBufPtr buffer,
+ GLint offset, GLint pitch, GLint format,
+ GLint x, GLint y, GLint width, GLint height );
+
+extern void mach64CopyBuffer( const __DRIdrawablePrivate *dPriv );
+#if ENABLE_PERF_BOXES
+extern void mach64PerformanceCounters( mach64ContextPtr mmesa );
+extern void mach64PerformanceBoxesLocked( mach64ContextPtr mmesa );
+#endif
+extern void mach64WaitForIdleLocked( mach64ContextPtr mmesa );
+
+extern void mach64InitIoctlFuncs( struct dd_function_table *functions );
+
+/* ================================================================
+ * Helper macros:
+ */
+
+#define FLUSH_BATCH( mmesa ) \
+do { \
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_IOCTL ) \
+ fprintf( stderr, "FLUSH_BATCH in %s\n", __FUNCTION__ ); \
+ if ( mmesa->vert_used ) { \
+ mach64FlushVertices( mmesa ); \
+ } \
+} while (0)
+
+/* According to a comment in ATIMach64Sync (atimach64.c) in the DDX:
+ *
+ * "For VTB's and later, the first CPU read of the framebuffer will return
+ * zeroes [...] This appears to be due to some kind of engine
+ * caching of framebuffer data I haven't found any way of disabling, or
+ * otherwise circumventing."
+ */
+#define FINISH_DMA_LOCKED( mmesa ) \
+do { \
+ CARD32 _tmp; \
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_IOCTL ) \
+ fprintf( stderr, "FINISH_DMA_LOCKED in %s\n", __FUNCTION__ ); \
+ if ( mmesa->vert_used ) { \
+ mach64FlushVerticesLocked( mmesa ); \
+ } \
+ mach64WaitForIdleLocked( mmesa ); \
+ /* pre-read framebuffer to counter caching problem */ \
+ _tmp = *(volatile CARD32 *)mmesa->driScreen->pFB; \
+} while (0)
+
+#define FLUSH_DMA_LOCKED( mmesa ) \
+do { \
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_IOCTL ) \
+ fprintf( stderr, "FLUSH_DMA_LOCKED in %s\n", __FUNCTION__ ); \
+ if ( mmesa->vert_used ) { \
+ mach64FlushVerticesLocked( mmesa ); \
+ } \
+ mach64FlushDMALocked( mmesa ); \
+} while (0)
+
+#define mach64FlushVertices( mmesa ) \
+do { \
+ LOCK_HARDWARE( mmesa ); \
+ mach64FlushVerticesLocked( mmesa ); \
+ UNLOCK_HARDWARE( mmesa ); \
+} while (0)
+
+#define mach64WaitForIdle( mmesa ) \
+do { \
+ LOCK_HARDWARE( mmesa ); \
+ mach64WaitForIdleLocked( mmesa ); \
+ UNLOCK_HARDWARE( mmesa ); \
+} while (0)
+
+
+#endif /* __MACH64_IOCTL_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_lock.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_lock.c
new file mode 100644
index 000000000..3d41d71b3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_lock.c
@@ -0,0 +1,93 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#include "mach64_context.h"
+#include "mach64_state.h"
+#include "mach64_lock.h"
+#include "mach64_tex.h"
+
+#if DEBUG_LOCKING
+char *prevLockFile = NULL;
+int prevLockLine = 0;
+#endif
+
+
+/* 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.
+ */
+void mach64GetLock( mach64ContextPtr mmesa, GLuint flags )
+{
+ __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
+ __DRIscreenPrivate *sPriv = mmesa->driScreen;
+ drm_mach64_sarea_t *sarea = mmesa->sarea;
+ int i;
+
+ drmGetLock( mmesa->driFd, mmesa->hHWContext, flags );
+
+ /* 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.
+ */
+ DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
+
+ if ( mmesa->lastStamp != dPriv->lastStamp ) {
+ mmesa->lastStamp = dPriv->lastStamp;
+ if (mmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT)
+ mach64SetCliprects( mmesa->glCtx, GL_BACK_LEFT );
+ else
+ mach64SetCliprects( mmesa->glCtx, GL_FRONT_LEFT );
+ mach64CalcViewport( mmesa->glCtx );
+ }
+
+ mmesa->dirty |= (MACH64_UPLOAD_CONTEXT
+ | MACH64_UPLOAD_MISC
+ | MACH64_UPLOAD_CLIPRECTS);
+
+ if ( sarea->ctx_owner != mmesa->hHWContext ) {
+ sarea->ctx_owner = mmesa->hHWContext;
+ mmesa->dirty = MACH64_UPLOAD_ALL;
+ }
+
+ for ( i = mmesa->firstTexHeap ; i < mmesa->lastTexHeap ; i++ ) {
+ if ( mmesa->texHeap[i] && (sarea->tex_age[i] != mmesa->lastTexAge[i]) ) {
+ mach64AgeTextures( mmesa, i );
+ }
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_lock.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_lock.h
new file mode 100644
index 000000000..973880ee2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_lock.h
@@ -0,0 +1,104 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ *
+ */
+
+#ifndef __MACH64_LOCK_H__
+#define __MACH64_LOCK_H__
+
+extern void mach64GetLock( mach64ContextPtr mmesa, GLuint flags );
+
+
+/* Turn DEBUG_LOCKING on to find locking conflicts.
+ */
+#define DEBUG_LOCKING 1
+
+#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 and validate our state.
+ */
+#define LOCK_HARDWARE( mmesa ) \
+ do { \
+ char __ret = 0; \
+ DEBUG_CHECK_LOCK(); \
+ DRM_CAS( mmesa->driHwLock, mmesa->hHWContext, \
+ (DRM_LOCK_HELD | mmesa->hHWContext), __ret ); \
+ if ( __ret ) \
+ mach64GetLock( mmesa, 0 ); \
+ DEBUG_LOCK(); \
+ } while (0)
+
+/* Unlock the hardware.
+ */
+#define UNLOCK_HARDWARE( mmesa ) \
+ do { \
+ DRM_UNLOCK( mmesa->driFd, \
+ mmesa->driHwLock, \
+ mmesa->hHWContext ); \
+ DEBUG_RESET(); \
+ } while (0)
+
+#endif /* __MACH64_LOCK_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_native_vb.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_native_vb.c
new file mode 100644
index 000000000..7872c206f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_native_vb.c
@@ -0,0 +1,257 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Original authors:
+ * Keith Whitwell <keithw@valinux.com>
+ *
+ * Adapted to Mach64 by:
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#include "math/m_translate.h"
+
+#ifndef LOCALVARS
+#define LOCALVARS
+#endif
+
+void TAG(translate_vertex)(GLcontext *ctx,
+ const VERTEX *src,
+ SWvertex *dst)
+{
+ LOCALVARS
+ GLuint format = GET_VERTEX_FORMAT();
+ UNVIEWPORT_VARS;
+ CARD32 *p = (CARD32 *)src + 10 - mmesa->vertex_size;
+
+ dst->win[3] = 1.0;
+
+ switch ( format ) {
+ case TEX1_VERTEX_FORMAT:
+#ifdef MACH64_PREMULT_TEXCOORDS
+ {
+ float rhw = 1.0 / LE32_IN_FLOAT( p + 2 );
+
+ dst->texcoord[1][0] = rhw*LE32_IN_FLOAT( p++ );
+ dst->texcoord[1][1] = rhw*LE32_IN_FLOAT( p++ );
+ }
+#else
+ dst->texcoord[1][0] = LE32_IN_FLOAT( p++ );
+ dst->texcoord[1][1] = LE32_IN_FLOAT( p++ );
+#endif
+ dst->texcoord[1][3] = 1.0;
+ p++;
+
+ case TEX0_VERTEX_FORMAT:
+#ifdef MACH64_PREMULT_TEXCOORDS
+ {
+ float rhw = 1.0 / LE32_IN_FLOAT( p + 2 );
+
+ dst->texcoord[0][0] = rhw*LE32_IN_FLOAT( p++ );
+ dst->texcoord[0][1] = rhw*LE32_IN_FLOAT( p++ );
+ }
+#else
+ dst->texcoord[0][0] = LE32_IN_FLOAT( p++ );
+ dst->texcoord[0][1] = LE32_IN_FLOAT( p++ );
+#endif
+ dst->texcoord[0][3] = 1.0;
+ dst->win[3] = LE32_IN_FLOAT( p++ );
+
+ case NOTEX_VERTEX_FORMAT:
+ dst->specular[2] = ((GLubyte *)p)[0];
+ dst->specular[1] = ((GLubyte *)p)[1];
+ dst->specular[0] = ((GLubyte *)p)[2];
+ dst->fog = ((GLubyte *)p)[3];
+ p++;
+
+ case TINY_VERTEX_FORMAT:
+ dst->win[2] = UNVIEWPORT_Z( LE32_IN( p++ ) );
+
+ dst->color[2] = ((GLubyte *)p)[0];
+ dst->color[1] = ((GLubyte *)p)[1];
+ dst->color[0] = ((GLubyte *)p)[2];
+ dst->color[3] = ((GLubyte *)p)[3];
+ p++;
+
+ {
+ GLuint xy = LE32_IN( p );
+
+ dst->win[0] = UNVIEWPORT_X( (GLfloat)(GLshort)( xy >> 16 ) );
+ dst->win[1] = UNVIEWPORT_Y( (GLfloat)(GLshort)( xy & 0xffff ) );
+ }
+ }
+
+ assert( p + 1 - (CARD32 *)src == 10 );
+
+ dst->pointSize = ctx->Point._Size;
+}
+
+
+
+void TAG(print_vertex)( GLcontext *ctx, const VERTEX *v )
+{
+ LOCALVARS
+ GLuint format = GET_VERTEX_FORMAT();
+ CARD32 *p = (CARD32 *)v + 10 - mmesa->vertex_size;
+
+ switch ( format ) {
+ case TEX1_VERTEX_FORMAT:
+ {
+ GLfloat u, v, w;
+#ifdef MACH64_PREMULT_TEXCOORDS
+ float rhw = 1.0 / LE32_IN_FLOAT( p + 2 );
+
+ u = rhw*LE32_IN_FLOAT( p++ );
+ v = rhw*LE32_IN_FLOAT( p++ );
+#else
+ u = LE32_IN_FLOAT( p++ );
+ v = LE32_IN_FLOAT( p++ );
+#endif
+ w = LE32_IN_FLOAT( p++ );
+ fprintf( stderr, "u1 %f v1 %f w1 %f\n", u, v, w );
+ }
+
+ case TEX0_VERTEX_FORMAT:
+ {
+ GLfloat u, v, w;
+#ifdef MACH64_PREMULT_TEXCOORDS
+ float rhw = 1.0 / LE32_IN_FLOAT( p + 2 );
+
+ u = rhw*LE32_IN_FLOAT( p++ );
+ v = rhw*LE32_IN_FLOAT( p++ );
+#else
+ u = LE32_IN_FLOAT( p++ );
+ v = LE32_IN_FLOAT( p++ );
+#endif
+ w = LE32_IN_FLOAT( p++ );
+ fprintf( stderr, "u0 %f v0 %f w0 %f\n", u, v, w );
+ }
+
+ case NOTEX_VERTEX_FORMAT:
+ {
+ GLubyte r, g, b, a;
+
+ b = ((GLubyte *)p)[0];
+ g = ((GLubyte *)p)[1];
+ r = ((GLubyte *)p)[2];
+ a = ((GLubyte *)p)[3];
+ p++;
+ fprintf(stderr, "spec: r %d g %d b %d a %d\n", r, g, b, a);
+ }
+
+ case TINY_VERTEX_FORMAT:
+ {
+ GLuint xy;
+ GLfloat x, y, z;
+ GLubyte r, g, b, a;
+
+ z = LE32_IN( p++ ) / 65536.0;
+
+ b = ((GLubyte *)p)[0];
+ g = ((GLubyte *)p)[1];
+ r = ((GLubyte *)p)[2];
+ a = ((GLubyte *)p)[3];
+ p++;
+ xy = LE32_IN( p );
+ x = (GLfloat)(GLshort)( xy >> 16 ) / 4.0;
+ y = (GLfloat)(GLshort)( xy & 0xffff ) / 4.0;
+
+ fprintf(stderr, "x %f y %f z %f\n", x, y, z);
+ fprintf(stderr, "r %d g %d b %d a %d\n", r, g, b, a);
+ }
+ }
+
+ assert( p + 1 - (CARD32 *)v == 10 );
+
+ fprintf(stderr, "\n");
+}
+
+/* Interpolate the elements of the VB not included in typical hardware
+ * vertices.
+ *
+ * NOTE: All these arrays are guarenteed by tnl to be writeable and
+ * have good stride.
+ */
+#ifndef INTERP_QUALIFIER
+#define INTERP_QUALIFIER static
+#endif
+
+#define GET_COLOR(ptr, idx) ((ptr)->data[idx])
+
+
+INTERP_QUALIFIER void TAG(interp_extras)( GLcontext *ctx,
+ GLfloat t,
+ GLuint dst, GLuint out, GLuint in,
+ GLboolean force_boundary )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ if (VB->ColorPtr[1]) {
+ assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat));
+
+ INTERP_4F( t,
+ GET_COLOR(VB->ColorPtr[1], dst),
+ GET_COLOR(VB->ColorPtr[1], out),
+ GET_COLOR(VB->ColorPtr[1], in) );
+
+ if (VB->SecondaryColorPtr[1]) {
+ INTERP_3F( t,
+ GET_COLOR(VB->SecondaryColorPtr[1], dst),
+ GET_COLOR(VB->SecondaryColorPtr[1], out),
+ GET_COLOR(VB->SecondaryColorPtr[1], in) );
+ }
+ }
+
+ if (VB->EdgeFlag) {
+ VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
+ }
+
+ INTERP_VERTEX(ctx, t, dst, out, in, force_boundary);
+}
+
+INTERP_QUALIFIER void TAG(copy_pv_extras)( GLcontext *ctx,
+ GLuint dst, GLuint src )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ if (VB->ColorPtr[1]) {
+ COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst),
+ GET_COLOR(VB->ColorPtr[1], src) );
+
+ if (VB->SecondaryColorPtr[1]) {
+ COPY_4FV( GET_COLOR(VB->SecondaryColorPtr[1], dst),
+ GET_COLOR(VB->SecondaryColorPtr[1], src) );
+ }
+ }
+
+ COPY_PV_VERTEX(ctx, dst, src);
+}
+
+
+#undef INTERP_QUALIFIER
+#undef GET_COLOR
+
+#undef IND
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_native_vbtmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_native_vbtmp.h
new file mode 100644
index 000000000..f64b808ee
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_native_vbtmp.h
@@ -0,0 +1,562 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Original authors:
+ * Keith Whitwell <keithw@valinux.com>
+ *
+ * Adapted to Mach64 by:
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+
+/* DO_XYZW: Emit xyz and maybe w coordinates.
+ * DO_RGBA: Emit color.
+ * DO_SPEC: Emit specular color.
+ * DO_FOG: Emit fog coordinate in specular alpha.
+ * DO_TEX0: Emit tex0 u,v coordinates.
+ * DO_TEX1: Emit tex1 u,v coordinates.
+ * DO_PTEX: Emit tex0,1 q coordinates where possible.
+ *
+ * Additionally, this template assumes it is emitting *transformed*
+ * vertices; the modifications to emit untransformed vertices (ie. to
+ * t&l hardware) are probably too great to cooexist with the code
+ * already in this file.
+ */
+
+#define VIEWPORT_X(x) ((GLint) ((s[0] * (x) + s[12]) * 4.0))
+#define VIEWPORT_Y(y) ((GLint) ((s[5] * (y) + s[13]) * 4.0))
+#define VIEWPORT_Z(z) (((GLuint) (s[10] * (z) + s[14])) << 15)
+
+#ifndef LOCALVARS
+#define LOCALVARS
+#endif
+
+static void TAG(emit)( GLcontext *ctx,
+ GLuint start, GLuint end,
+ void *dest,
+ GLuint stride )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+#if DO_TEX1
+ GLfloat (*tc1)[4];
+ GLuint tc1_stride;
+#if DO_PTEX
+ GLuint tc1_size;
+#endif
+#endif
+#if DO_TEX0
+ GLfloat (*tc0)[4];
+ GLuint tc0_stride;
+#if DO_PTEX
+ GLuint tc0_size;
+#endif
+#endif
+#if DO_SPEC
+ GLfloat (*spec)[4];
+ GLuint spec_stride;
+#endif
+#if DO_FOG
+ GLfloat (*fog)[4];
+ GLuint fog_stride;
+#endif
+#if DO_RGBA
+ GLfloat (*col)[4];
+ GLuint col_stride;
+#endif
+ GLfloat (*coord)[4];
+ GLuint coord_stride;
+ VERTEX *v = (VERTEX *)dest;
+ const GLfloat *s = GET_VIEWPORT_MAT();
+#if DO_TEX1 || DO_TEX0 || DO_XYZW
+ const GLubyte *mask = VB->ClipMask;
+#endif
+ int i;
+
+#if !DO_XYZW
+ (void) s; /* Quiet compiler */
+#endif
+/* fprintf(stderr, "%s(big) importable %d %d..%d\n", */
+/* __FUNCTION__, VB->importable_data, start, end); */
+
+#if DO_TEX1
+ {
+ const GLuint t1 = GET_TEXSOURCE(1);
+ tc1 = VB->TexCoordPtr[t1]->data;
+ tc1_stride = VB->TexCoordPtr[t1]->stride;
+#if DO_PTEX
+ tc1_size = VB->TexCoordPtr[t1]->size;
+#endif
+ }
+#endif
+
+#if DO_TEX0
+ {
+ const GLuint t0 = GET_TEXSOURCE(0);
+ tc0 = VB->TexCoordPtr[t0]->data;
+ tc0_stride = VB->TexCoordPtr[t0]->stride;
+#if DO_PTEX
+ tc0_size = VB->TexCoordPtr[t0]->size;
+#endif
+ }
+#endif
+
+#if DO_SPEC
+ if (VB->SecondaryColorPtr[0]) {
+ spec = VB->SecondaryColorPtr[0]->data;
+ spec_stride = VB->SecondaryColorPtr[0]->stride;
+ } else {
+ spec = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
+ spec_stride = 0;
+ }
+#endif
+
+#if DO_FOG
+ if (VB->FogCoordPtr) {
+ fog = VB->FogCoordPtr->data;
+ fog_stride = VB->FogCoordPtr->stride;
+ } else {
+ static GLfloat tmp[4] = {0, 0, 0, 0};
+ fog = &tmp;
+ fog_stride = 0;
+ }
+#endif
+
+#if DO_RGBA
+ col = VB->ColorPtr[0]->data;
+ col_stride = VB->ColorPtr[0]->stride;
+#endif
+
+ coord = VB->NdcPtr->data;
+ coord_stride = VB->NdcPtr->stride;
+
+ if (start) {
+#if DO_TEX1
+ STRIDE_4F(tc1, start * tc1_stride);
+#endif
+#if DO_TEX0
+ STRIDE_4F(tc0, start * tc0_stride);
+#endif
+#if DO_SPEC
+ STRIDE_4F(spec, start * spec_stride);
+#endif
+#if DO_FOG
+ STRIDE_4F(fog, start * fog_stride);
+#endif
+#if DO_RGBA
+ STRIDE_4F(col, start * col_stride);
+#endif
+ STRIDE_4F(coord, start * coord_stride);
+ }
+
+ for (i=start; i < end; i++, v = (VERTEX *)((GLubyte *)v + stride)) {
+ CARD32 *p = (CARD32 *)v;
+#if DO_TEX1 || DO_TEX0
+ GLfloat w;
+
+ if (mask[i] == 0) {
+ /* unclipped */
+ w = coord[0][3];
+ } else {
+ /* clipped */
+ w = 1.0;
+ }
+#endif
+
+#if DO_TEX1
+#if DO_PTEX
+ if (tc1_size == 4) {
+#ifdef MACH64_PREMULT_TEXCOORDS
+ LE32_OUT_FLOAT( p++, w*tc1[0][0] ); /* VERTEX_?_SECONDARY_S */
+ LE32_OUT_FLOAT( p++, w*tc1[0][1] ); /* VERTEX_?_SECONDARY_T */
+ LE32_OUT_FLOAT( p++, w*tc1[0][3] ); /* VERTEX_?_SECONDARY_W */
+#else /* !MACH64_PREMULT_TEXCOORDS */
+ float rhw = 1.0 / tc1[0][3];
+ LE32_OUT_FLOAT( p++, rhw*tc1[0][0] ); /* VERTEX_?_SECONDARY_S */
+ LE32_OUT_FLOAT( p++, rhw*tc1[0][1] ); /* VERTEX_?_SECONDARY_T */
+ LE32_OUT_FLOAT( p++, w*tc1[0][3] ); /* VERTEX_?_SECONDARY_W */
+#endif /* !MACH64_PREMULT_TEXCOORDS */
+ } else {
+#endif /* DO_PTEX */
+#ifdef MACH64_PREMULT_TEXCOORDS
+ LE32_OUT_FLOAT( p++, w*tc1[0][0] ); /* VERTEX_?_SECONDARY_S */
+ LE32_OUT_FLOAT( p++, w*tc1[0][1] ); /* VERTEX_?_SECONDARY_T */
+ LE32_OUT_FLOAT( p++, w ); /* VERTEX_?_SECONDARY_W */
+#else /* !MACH64_PREMULT_TEXCOORDS */
+ LE32_OUT_FLOAT( p++, tc1[0][0] ); /* VERTEX_?_SECONDARY_S */
+ LE32_OUT_FLOAT( p++, tc1[0][1] ); /* VERTEX_?_SECONDARY_T */
+ LE32_OUT_FLOAT( p++, w ); /* VERTEX_?_SECONDARY_W */
+#endif /* !MACH64_PREMULT_TEXCOORDS */
+#if DO_PTEX
+ }
+#endif /* DO_PTEX */
+ STRIDE_4F(tc1, tc1_stride);
+#else /* !DO_TEX1 */
+ p += 3;
+#endif /* !DO_TEX1 */
+
+#if DO_TEX0
+#if DO_PTEX
+ if (tc0_size == 4) {
+#ifdef MACH64_PREMULT_TEXCOORDS
+ LE32_OUT_FLOAT( p++, w*tc0[0][0] ); /* VERTEX_?_S */
+ LE32_OUT_FLOAT( p++, w*tc0[0][1] ); /* VERTEX_?_T */
+ LE32_OUT_FLOAT( p++, w*tc0[0][3] ); /* VERTEX_?_W */
+#else /* !MACH64_PREMULT_TEXCOORDS */
+ float rhw = 1.0 / tc0[0][3];
+ LE32_OUT_FLOAT( p++, rhw*tc0[0][0] ); /* VERTEX_?_S */
+ LE32_OUT_FLOAT( p++, rhw*tc0[0][1] ); /* VERTEX_?_T */
+ LE32_OUT_FLOAT( p++, w*tc0[0][3] ); /* VERTEX_?_W */
+#endif /* !MACH64_PREMULT_TEXCOORDS */
+ } else {
+#endif /* DO_PTEX */
+#ifdef MACH64_PREMULT_TEXCOORDS
+ LE32_OUT_FLOAT( p++, w*tc0[0][0] ); /* VERTEX_?_S */
+ LE32_OUT_FLOAT( p++, w*tc0[0][1] ); /* VERTEX_?_T */
+ LE32_OUT_FLOAT( p++, w ); /* VERTEX_?_W */
+#else /* !MACH64_PREMULT_TEXCOORDS */
+ LE32_OUT_FLOAT( p++, tc0[0][0] ); /* VERTEX_?_S */
+ LE32_OUT_FLOAT( p++, tc0[0][1] ); /* VERTEX_?_T */
+ LE32_OUT_FLOAT( p++, w ); /* VERTEX_?_W */
+#endif /* !MACH64_PREMULT_TEXCOORDS */
+#if DO_PTEX
+ }
+#endif /* DO_PTEX */
+ STRIDE_4F(tc0, tc0_stride);
+#else /* !DO_TEX0 */
+ p += 3;
+#endif /* !DO_TEX0 */
+
+#if DO_SPEC
+ UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[0], spec[0][2]); /* VERTEX_?_SPEC_B */
+ UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[1], spec[0][1]); /* VERTEX_?_SPEC_G */
+ UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[2], spec[0][0]); /* VERTEX_?_SPEC_R */
+
+ STRIDE_4F(spec, spec_stride);
+#endif
+#if DO_FOG
+ UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[3], fog[0][0]); /* VERTEX_?_SPEC_A */
+ /* ((GLubyte *)p)[3] = fog[0][0] * 255.0; */
+ STRIDE_4F(fog, fog_stride);
+#endif
+ p++;
+
+#if DO_XYZW
+ if (mask[i] == 0) {
+ /* unclipped */
+ LE32_OUT( p++, VIEWPORT_Z( coord[0][2] ) ); /* VERTEX_?_Z */
+ } else {
+#endif
+ p++;
+#if DO_XYZW
+ }
+#endif
+
+#if DO_RGBA
+ UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[0], col[0][2]);
+ UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[1], col[0][1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[2], col[0][0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[3], col[0][3]);
+ p++;
+ STRIDE_4F(col, col_stride);
+#else
+ p++;
+#endif
+
+#if DO_XYZW
+ if (mask[i] == 0) {
+ /* unclipped */
+ LE32_OUT( p,
+ (VIEWPORT_X( coord[0][0] ) << 16) | /* VERTEX_?_X */
+ (VIEWPORT_Y( coord[0][1] ) & 0xffff) ); /* VERTEX_?_Y */
+
+ if (MACH64_DEBUG & DEBUG_VERBOSE_PRIMS) {
+ fprintf( stderr, "%s: vert %d: %.2f %.2f %.2f %x\n",
+ __FUNCTION__,
+ i,
+ (LE32_IN( p ) >> 16)/4.0,
+ (LE32_IN( p ) & 0xffff)/4.0,
+ LE32_IN( p - 2 )/65536.0,
+ *(GLuint *)(p - 1) );
+ }
+ }
+#endif
+#if DO_TEX1 || DO_TEX0 || DO_XYZW
+ STRIDE_4F(coord, coord_stride);
+#endif
+
+ assert( p + 1 - (CARD32 *)v == 10 );
+ }
+}
+
+#if DO_XYZW && DO_RGBA
+
+static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ /* Force 'missing' texcoords to something valid.
+ */
+ if (DO_TEX1 && VB->TexCoordPtr[0] == 0)
+ VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
+
+ if (DO_PTEX)
+ return GL_TRUE;
+
+ /* No hardware support for projective texture. Can fake it for
+ * TEX0 only.
+ */
+ if ((DO_TEX1 && VB->TexCoordPtr[GET_TEXSOURCE(1)]->size == 4)) {
+ PTEX_FALLBACK();
+ return GL_FALSE;
+ }
+
+ if (DO_TEX0 && VB->TexCoordPtr[GET_TEXSOURCE(0)]->size == 4) {
+ if (DO_TEX1) {
+ PTEX_FALLBACK();
+ }
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+static void TAG(interp)( GLcontext *ctx,
+ GLfloat t,
+ GLuint edst, GLuint eout, GLuint ein,
+ GLboolean force_boundary )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLubyte *ddverts = GET_VERTEX_STORE();
+ GLuint size = GET_VERTEX_SIZE();
+ const GLfloat *dstclip = VB->ClipPtr->data[edst];
+ GLfloat w;
+ const GLfloat *s = GET_VIEWPORT_MAT();
+
+ CARD32 *dst = (CARD32 *)(ddverts + (edst * size));
+ CARD32 *in = (CARD32 *)(ddverts + (ein * size));
+ CARD32 *out = (CARD32 *)(ddverts + (eout * size));
+
+ (void)s;
+
+ w = (dstclip[3] == 0.0F) ? 1.0 : (1.0 / dstclip[3]);
+
+#if DO_TEX1
+ {
+ GLfloat temp;
+#if DO_PTEX
+ GLfloat wout = VB->NdcPtr->data[eout][3];
+ GLfloat win = VB->NdcPtr->data[ein][3];
+ GLfloat qout = LE32_IN_FLOAT( out + 2 ) / wout;
+ GLfloat qin = LE32_IN_FLOAT( in + 2 ) / win;
+ GLfloat qdst, rqdst;
+
+ INTERP_F( t, qdst, qout, qin );
+ rqdst = 1.0 / qdst;
+
+ INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin );
+ LE32_OUT_FLOAT( dst, temp*rqdst ); /* VERTEX_?_SECONDARY_S */
+ dst++; out++; in++;
+
+ INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin );
+ LE32_OUT_FLOAT( dst, temp*rqdst ); /* VERTEX_?_SECONDARY_T */
+ dst++; out++; in++;
+
+ LE32_OUT_FLOAT( dst, w*rqdst ); /* VERTEX_?_SECONDARY_W */
+ dst++; out++; in++;
+#else /* !DO_PTEX */
+#ifdef MACH64_PREMULT_TEXCOORDS
+ GLfloat qout = w / LE32_IN_FLOAT( out + 2 );
+ GLfloat qin = w / LE32_IN_FLOAT( in + 2 );
+
+ INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin );
+ LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_SECONDARY_S */
+ dst++; out++; in++;
+
+ INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin );
+ LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_SECONDARY_T */
+ dst++; out++; in++;
+#else /* !MACH64_PREMULT_TEXCOORDS */
+ INTERP_F( t, temp, LE32_IN_FLOAT( out ), LE32_IN_FLOAT( in ) );
+ LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_SECONDARY_S */
+ dst++; out++; in++;
+
+ INTERP_F( t, temp, LE32_IN_FLOAT( out ), LE32_IN_FLOAT( in ) );
+ LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_SECONDARY_T */
+ dst++; out++; in++;
+#endif /* !MACH64_PREMULT_TEXCOORDS */
+ LE32_OUT_FLOAT( dst, w ); /* VERTEX_?_SECONDARY_W */
+ dst++; out++; in++;
+#endif /* !DO_PTEX */
+ }
+#else /* !DO_TEX1 */
+ dst += 3; out += 3; in += 3;
+#endif /* !DO_TEX1 */
+
+#if DO_TEX0
+ {
+ GLfloat temp;
+#if DO_PTEX
+ GLfloat wout = VB->NdcPtr->data[eout][3];
+ GLfloat win = VB->NdcPtr->data[ein][3];
+ GLfloat qout = LE32_IN_FLOAT( out + 2 ) / wout;
+ GLfloat qin = LE32_IN_FLOAT( in + 2 ) / win;
+ GLfloat qdst, rqdst;
+
+ INTERP_F( t, qdst, qout, qin );
+ rqdst = 1.0 / qdst;
+
+ INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin );
+ LE32_OUT_FLOAT( dst, temp*rqdst ); /* VERTEX_?_S */
+ dst++; out++; in++;
+
+ INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin );
+ LE32_OUT_FLOAT( dst, temp*rqdst ); /* VERTEX_?_T */
+ dst++; out++; in++;
+
+ LE32_OUT_FLOAT( dst, w*rqdst ); /* VERTEX_?_W */
+ dst++; out++; in++;
+#else /* !DO_PTEX */
+#ifdef MACH64_PREMULT_TEXCOORDS
+ GLfloat qout = w / LE32_IN_FLOAT( out + 2 );
+ GLfloat qin = w / LE32_IN_FLOAT( in + 2 );
+
+ INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin );
+ LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_S */
+ dst++; out++; in++;
+
+ INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin );
+ LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_T */
+ dst++; out++; in++;
+#else /* !MACH64_PREMULT_TEXCOORDS */
+ INTERP_F( t, temp, LE32_IN_FLOAT( out ), LE32_IN_FLOAT( in ) );
+ LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_S */
+ dst++; out++; in++;
+
+ INTERP_F( t, temp, LE32_IN_FLOAT( out ), LE32_IN_FLOAT( in ) );
+ LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_T */
+ dst++; out++; in++;
+#endif /* !MACH64_PREMULT_TEXCOORDS */
+ LE32_OUT_FLOAT( dst, w ); /* VERTEX_?_W */
+ dst++; out++; in++;
+#endif /* !DO_PTEX */
+ }
+#else /* !DO_TEX0 */
+ dst += 3; out += 3; in += 3;
+#endif /* !DO_TEX0 */
+
+#if DO_SPEC
+ INTERP_UB( t, ((GLubyte *)dst)[0], ((GLubyte *)out)[0], ((GLubyte *)in)[0] ); /* VERTEX_?_SPEC_B */
+ INTERP_UB( t, ((GLubyte *)dst)[1], ((GLubyte *)out)[1], ((GLubyte *)in)[1] ); /* VERTEX_?_SPEC_G */
+ INTERP_UB( t, ((GLubyte *)dst)[2], ((GLubyte *)out)[2], ((GLubyte *)in)[2] ); /* VERTEX_?_SPEC_R */
+#endif
+
+#if DO_FOG
+ INTERP_UB( t, ((GLubyte *)dst)[3], ((GLubyte *)out)[3], ((GLubyte *)in)[3] ); /* VERTEX_?_SPEC_A */
+#endif /* DO_FOG */
+
+ dst++; out++; in++;
+
+ LE32_OUT( dst, VIEWPORT_Z( dstclip[2] * w ) ); /* VERTEX_?_Z */
+ dst++; out++; in++;
+
+ INTERP_UB( t, ((GLubyte *)dst)[0], ((GLubyte *)out)[0], ((GLubyte *)in)[0] ); /* VERTEX_?_B */
+ INTERP_UB( t, ((GLubyte *)dst)[1], ((GLubyte *)out)[1], ((GLubyte *)in)[1] ); /* VERTEX_?_G */
+ INTERP_UB( t, ((GLubyte *)dst)[2], ((GLubyte *)out)[2], ((GLubyte *)in)[2] ); /* VERTEX_?_R */
+ INTERP_UB( t, ((GLubyte *)dst)[3], ((GLubyte *)out)[3], ((GLubyte *)in)[3] ); /* VERTEX_?_A */
+ dst++; /*out++; in++;*/
+
+ LE32_OUT( dst,
+ (VIEWPORT_X( dstclip[0] * w ) << 16) | /* VERTEX_?_X */
+ (VIEWPORT_Y( dstclip[1] * w ) & 0xffff) ); /* VERTEX_?_Y */
+
+ assert( dst + 1 - (CARD32 *)(ddverts + (edst * size)) == 10 );
+ assert( in + 2 - (CARD32 *)(ddverts + (ein * size)) == 10 );
+ assert( out + 2 - (CARD32 *)(ddverts + (eout * size)) == 10 );
+
+ if (MACH64_DEBUG & DEBUG_VERBOSE_PRIMS) {
+ fprintf( stderr, "%s: dst vert: %.2f %.2f %.2f %x\n",
+ __FUNCTION__,
+ (GLshort)(LE32_IN( dst ) >> 16)/4.0,
+ (GLshort)(LE32_IN( dst ) & 0xffff)/4.0,
+ LE32_IN( dst - 2 )/65536.0,
+ *(GLuint *)(dst - 1) );
+ }
+}
+
+#endif /* DO_RGBA && DO_XYZW */
+
+
+static void TAG(copy_pv)( GLcontext *ctx, GLuint edst, GLuint esrc )
+{
+#if DO_SPEC || DO_FOG || DO_RGBA
+ LOCALVARS
+ GLubyte *verts = GET_VERTEX_STORE();
+ GLuint size = GET_VERTEX_SIZE();
+ GLuint *dst = (GLuint *)(verts + (edst * size));
+ GLuint *src = (GLuint *)(verts + (esrc * size));
+#endif
+
+#if DO_SPEC || DO_FOG
+ dst[6] = src[6]; /* VERTEX_?_SPEC_ARGB */
+#endif
+
+#if DO_RGBA
+ dst[8] = src[8]; /* VERTEX_?_ARGB */
+#endif
+}
+
+static void TAG(init)( void )
+{
+ setup_tab[IND].emit = TAG(emit);
+
+#if DO_XYZW && DO_RGBA
+ setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes);
+ setup_tab[IND].interp = TAG(interp);
+#endif
+
+ setup_tab[IND].copy_pv = TAG(copy_pv);
+
+#if DO_TEX1
+ setup_tab[IND].vertex_format = TEX1_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 10;
+#elif DO_TEX0
+ setup_tab[IND].vertex_format = TEX0_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 7;
+#elif DO_SPEC || DO_FOG
+ setup_tab[IND].vertex_format = NOTEX_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 4;
+#else
+ setup_tab[IND].vertex_format = TINY_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 3;
+#endif
+
+}
+
+
+#undef IND
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_reg.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_reg.h
new file mode 100644
index 000000000..abbba295a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_reg.h
@@ -0,0 +1,406 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#ifndef __MACH64_REG_H__
+#define __MACH64_REG_H__
+
+/*
+ * Not sure how this compares with the G200, but the Rage Pro has two
+ * banks of registers, with bank 0 at (aperture base + memmap offset - 1KB)
+ * and bank 1 at (aperture base + memmap offset - 2KB). But, to send them
+ * via DMA, we need to encode them as memory map select rather than physical
+ * offsets.
+ */
+#define DWMREG0 0x0400
+#define DWMREG0_END 0x07ff
+#define DWMREG1 0x0000
+#define DWMREG1_END 0x03ff
+
+#define ISREG0(r) ( ( (r) >= DWMREG0 ) && ( (r) <= DWMREG0_END ) )
+#define ADRINDEX0(r) ( ((r) - DWMREG0) >> 2 )
+#define ADRINDEX1(r) ( ( ((r) - DWMREG1) >> 2 ) | 0x0100 )
+#define ADRINDEX(r) ( ISREG0(r) ? ADRINDEX0(r) : ADRINDEX1(r) )
+
+#define MMREG0 0x0000
+#define MMREG0_END 0x00ff
+
+#define ISMMREG0(r) ( ( (r) >= MMREG0 ) && ( (r) <= MMREG0_END ) )
+#define MMSELECT0(r) ( ((r)<<2) + DWMREG0 )
+#define MMSELECT1(r) ( ( (((r) & 0xff)<<2) + DWMREG1 ) )
+#define MMSELECT(r) ( ISMMREG0(r) ? MMSELECT0(r) : MMSELECT1(r) )
+
+/* FIXME: If register reads are necessary, we should account for endianess here */
+#define MACH64_BASE(reg) ((CARD32)(mmesa->mach64Screen->mmio.map))
+#define MACH64_ADDR(reg) (MACH64_BASE(reg) + reg)
+
+#define MACH64_DEREF(reg) *(__volatile__ CARD32 *)MACH64_ADDR(reg)
+#define MACH64_READ(reg) MACH64_DEREF(reg)
+
+
+/* ================================================================
+ * Registers
+ */
+
+#define MACH64_ALPHA_TST_CNTL 0x0550
+# define MACH64_ALPHA_TEST_EN (1 << 0)
+# define MACH64_ALPHA_TEST_MASK (7 << 4)
+# define MACH64_ALPHA_TEST_NEVER (0 << 4)
+# define MACH64_ALPHA_TEST_LESS (1 << 4)
+# define MACH64_ALPHA_TEST_LEQUAL (2 << 4)
+# define MACH64_ALPHA_TEST_EQUAL (3 << 4)
+# define MACH64_ALPHA_TEST_GEQUAL (4 << 4)
+# define MACH64_ALPHA_TEST_GREATER (5 << 4)
+# define MACH64_ALPHA_TEST_NOTEQUAL (6 << 4)
+# define MACH64_ALPHA_TEST_ALWAYS (7 << 4)
+# define MACH64_ALPHA_MOD_MSB (1 << 7)
+# define MACH64_ALPHA_DST_MASK (7 << 8)
+# define MACH64_ALPHA_DST_ZERO (0 << 8)
+# define MACH64_ALPHA_DST_ONE (1 << 8)
+# define MACH64_ALPHA_DST_SRCALPHA (4 << 8)
+# define MACH64_ALPHA_DST_INVSRCALPHA (5 << 8)
+# define MACH64_ALPHA_DST_DSTALPHA (6 << 8)
+# define MACH64_ALPHA_DST_INVDSTALPHA (7 << 8)
+# define MACH64_ALPHA_TST_SRC_TEXEL (0 << 12)
+# define MACH64_ALPHA_TST_SRC_SRCALPHA (1 << 12)
+# define MACH64_REF_ALPHA_MASK (0xff << 16)
+# define MACH64_REF_ALPHA_SHIFT 16
+# define MACH64_COMPOSITE_SHADOW (1 << 30)
+# define MACH64_SPECULAR_LIGHT_EN (1 << 31)
+
+#define MACH64_BUS_CNTL 0x04a0
+# define MACH64_BUS_MSTR_RESET (1 << 1)
+# define MACH64_BUS_FLUSH_BUF (1 << 2)
+# define MACH64_BUS_MASTER_DIS (1 << 6)
+# define MACH64_BUS_EXT_REG_EN (1 << 27)
+
+#define MACH64_COMPOSITE_SHADOW_ID 0x0798
+
+#define MACH64_CLR_CMP_CLR 0x0700
+#define MACH64_CLR_CMP_CNTL 0x0708
+#define MACH64_CLR_CMP_MASK 0x0704
+
+#define MACH64_DP_BKGD_CLR 0x06c0
+#define MACH64_DP_FOG_CLR 0x06c4
+#define MACH64_DP_FGRD_BKGD_CLR 0x06e0
+#define MACH64_DP_FRGD_CLR 0x06c4
+#define MACH64_DP_FGRD_CLR_MIX 0x06dc
+
+#define MACH64_DP_MIX 0x06d4
+# define BKGD_MIX_NOT_D (0 << 0)
+# define BKGD_MIX_ZERO (1 << 0)
+# define BKGD_MIX_ONE (2 << 0)
+# define MACH64_BKGD_MIX_D (3 << 0)
+# define BKGD_MIX_NOT_S (4 << 0)
+# define BKGD_MIX_D_XOR_S (5 << 0)
+# define BKGD_MIX_NOT_D_XOR_S (6 << 0)
+# define MACH64_BKGD_MIX_S (7 << 0)
+# define BKGD_MIX_NOT_D_OR_NOT_S (8 << 0)
+# define BKGD_MIX_D_OR_NOT_S (9 << 0)
+# define BKGD_MIX_NOT_D_OR_S (10 << 0)
+# define BKGD_MIX_D_OR_S (11 << 0)
+# define BKGD_MIX_D_AND_S (12 << 0)
+# define BKGD_MIX_NOT_D_AND_S (13 << 0)
+# define BKGD_MIX_D_AND_NOT_S (14 << 0)
+# define BKGD_MIX_NOT_D_AND_NOT_S (15 << 0)
+# define BKGD_MIX_D_PLUS_S_DIV2 (23 << 0)
+# define FRGD_MIX_NOT_D (0 << 16)
+# define FRGD_MIX_ZERO (1 << 16)
+# define FRGD_MIX_ONE (2 << 16)
+# define FRGD_MIX_D (3 << 16)
+# define FRGD_MIX_NOT_S (4 << 16)
+# define FRGD_MIX_D_XOR_S (5 << 16)
+# define FRGD_MIX_NOT_D_XOR_S (6 << 16)
+# define MACH64_FRGD_MIX_S (7 << 16)
+# define FRGD_MIX_NOT_D_OR_NOT_S (8 << 16)
+# define FRGD_MIX_D_OR_NOT_S (9 << 16)
+# define FRGD_MIX_NOT_D_OR_S (10 << 16)
+# define FRGD_MIX_D_OR_S (11 << 16)
+# define FRGD_MIX_D_AND_S (12 << 16)
+# define FRGD_MIX_NOT_D_AND_S (13 << 16)
+# define FRGD_MIX_D_AND_NOT_S (14 << 16)
+# define FRGD_MIX_NOT_D_AND_NOT_S (15 << 16)
+# define FRGD_MIX_D_PLUS_S_DIV2 (23 << 16)
+
+#define MACH64_DP_PIX_WIDTH 0x06d0
+# define MACH64_COMPOSITE_PIX_WIDTH_MASK (0xf << 4)
+# define MACH64_HOST_TRIPLE_ENABLE (1 << 13)
+# define MACH64_BYTE_ORDER_MSB_TO_LSB (0 << 24)
+# define MACH64_BYTE_ORDER_LSB_TO_MSB (1 << 24)
+# define MACH64_SCALE_PIX_WIDTH_MASK (0xf << 28)
+
+#define MACH64_DP_SRC 0x06d8
+# define MACH64_BKGD_SRC_BKGD_CLR (0 << 0)
+# define MACH64_BKGD_SRC_FRGD_CLR (1 << 0)
+# define MACH64_BKGD_SRC_HOST (2 << 0)
+# define MACH64_BKGD_SRC_BLIT (3 << 0)
+# define MACH64_BKGD_SRC_PATTERN (4 << 0)
+# define MACH64_BKGD_SRC_3D (5 << 0)
+# define MACH64_FRGD_SRC_BKGD_CLR (0 << 8)
+# define MACH64_FRGD_SRC_FRGD_CLR (1 << 8)
+# define MACH64_FRGD_SRC_HOST (2 << 8)
+# define MACH64_FRGD_SRC_BLIT (3 << 8)
+# define MACH64_FRGD_SRC_PATTERN (4 << 8)
+# define MACH64_FRGD_SRC_3D (5 << 8)
+# define MACH64_MONO_SRC_ONE (0 << 16)
+# define MACH64_MONO_SRC_PATTERN (1 << 16)
+# define MACH64_MONO_SRC_HOST (2 << 16)
+# define MACH64_MONO_SRC_BLIT (3 << 16)
+
+#define MACH64_DP_WRITE_MASK 0x06c8
+
+#define MACH64_DST_CNTL 0x0530
+# define MACH64_DST_X_RIGHT_TO_LEFT (0 << 0)
+# define MACH64_DST_X_LEFT_TO_RIGHT (1 << 0)
+# define MACH64_DST_Y_BOTTOM_TO_TOP (0 << 1)
+# define MACH64_DST_Y_TOP_TO_BOTTOM (1 << 1)
+# define MACH64_DST_X_MAJOR (0 << 2)
+# define MACH64_DST_Y_MAJOR (1 << 2)
+# define MACH64_DST_X_TILE (1 << 3)
+# define MACH64_DST_Y_TILE (1 << 4)
+# define MACH64_DST_LAST_PEL (1 << 5)
+# define MACH64_DST_POLYGON_ENABLE (1 << 6)
+# define MACH64_DST_24_ROTATION_ENABLE (1 << 7)
+
+#define MACH64_DST_HEIGHT_WIDTH 0x0518
+#define MACH64_DST_OFF_PITCH 0x0500
+#define MACH64_DST_WIDTH_HEIGHT 0x06ec
+#define MACH64_DST_X_Y 0x06e8
+#define MACH64_DST_Y_X 0x050c
+
+#define MACH64_FIFO_STAT 0x0710
+# define MACH64_FIFO_SLOT_MASK 0x0000ffff
+# define MACH64_FIFO_ERR (1 << 31)
+
+#define MACH64_GEN_TEST_CNTL 0x04d0
+#define MACH64_GUI_CMDFIFO_DEBUG 0x0170
+#define MACH64_GUI_CMDFIFO_DATA 0x0174
+#define MACH64_GUI_CNTL 0x0178
+#define MACH64_GUI_STAT 0x0738
+# define MACH64_GUI_ACTIVE (1 << 0)
+#define MACH64_GUI_TRAJ_CNTL 0x0730
+
+#define MACH64_HOST_CNTL 0x0640
+#define MACH64_HOST_DATA0 0x0600
+#define MACH64_HW_DEBUG 0x047c
+
+#define MACH64_ONE_OVER_AREA 0x029c
+#define MACH64_ONE_OVER_AREA_UC 0x0300
+
+#define MACH64_PAT_REG0 0x0680
+#define MACH64_PAT_REG1 0x0684
+
+#define MACH64_SC_LEFT_RIGHT 0x06a8
+#define MACH64_SC_TOP_BOTTOM 0x06b4
+#define MACH64_SCALE_3D_CNTL 0x05fc
+# define MACH64_SCALE_PIX_EXPAND_ZERO_EXTEND (0 << 0)
+# define MACH64_SCALE_PIX_EXPAND_DYNAMIC_RANGE (1 << 0)
+# define MACH64_SCALE_DITHER_ERROR_DIFFUSE (0 << 1)
+# define MACH64_SCALE_DITHER_2D_TABLE (1 << 1)
+# define MACH64_DITHER_EN (1 << 2)
+# define MACH64_DITHER_INIT_CURRENT (O << 3)
+# define MACH64_DITHER_INIT_RESET (1 << 3)
+# define MACH64_ROUND_EN (1 << 4)
+# define MACH64_TEX_CACHE_DIS (1 << 5)
+# define MACH64_SCALE_3D_FCN_MASK (3 << 6)
+# define MACH64_SCALE_3D_FCN_NOP (0 << 6)
+# define MACH64_SCALE_3D_FCN_SCALE (1 << 6)
+# define MACH64_SCALE_3D_FCN_TEXTURE (2 << 6)
+# define MACH64_SCALE_3D_FCN_SHADE (3 << 6)
+# define MACH64_TEXTURE_DISABLE (1 << 6)
+# define MACH64_EDGE_ANTI_ALIAS (1 << 8)
+# define MACH64_TEX_CACHE_SPLIT (1 << 9)
+# define MACH64_APPLE_YUV_MODE (1 << 10)
+# define MACH64_ALPHA_FOG_EN_MASK (3 << 11)
+# define MACH64_ALPHA_FOG_DIS (0 << 11)
+# define MACH64_ALPHA_FOG_EN_ALPHA (1 << 11)
+# define MACH64_ALPHA_FOG_EN_FOG (2 << 11)
+# define MACH64_ALPHA_BLEND_SAT (1 << 13)
+# define MACH64_RED_DITHER_MAX (1 << 14)
+# define MACH64_SIGNED_DST_CLAMP (1 << 15)
+# define MACH64_ALPHA_BLEND_SRC_MASK (7 << 16)
+# define MACH64_ALPHA_BLEND_SRC_ZERO (0 << 16)
+# define MACH64_ALPHA_BLEND_SRC_ONE (1 << 16)
+# define MACH64_ALPHA_BLEND_SRC_DSTCOLOR (2 << 16)
+# define MACH64_ALPHA_BLEND_SRC_INVDSTCOLOR (3 << 16)
+# define MACH64_ALPHA_BLEND_SRC_SRCALPHA (4 << 16)
+# define MACH64_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16)
+# define MACH64_ALPHA_BLEND_SRC_DSTALPHA (6 << 16)
+# define MACH64_ALPHA_BLEND_SRC_INVDSTALPHA (7 << 16)
+# define MACH64_ALPHA_BLEND_DST_MASK (7 << 19)
+# define MACH64_ALPHA_BLEND_DST_ZERO (0 << 19)
+# define MACH64_ALPHA_BLEND_DST_ONE (1 << 19)
+# define MACH64_ALPHA_BLEND_DST_SRCCOLOR (2 << 19)
+# define MACH64_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 19)
+# define MACH64_ALPHA_BLEND_DST_SRCALPHA (4 << 19)
+# define MACH64_ALPHA_BLEND_DST_INVSRCALPHA (5 << 19)
+# define MACH64_ALPHA_BLEND_DST_DSTALPHA (6 << 19)
+# define MACH64_ALPHA_BLEND_DST_INVDSTALPHA (7 << 19)
+# define MACH64_TEX_LIGHT_FCN_MASK (3 << 22)
+# define MACH64_TEX_LIGHT_FCN_REPLACE (0 << 22)
+# define MACH64_TEX_LIGHT_FCN_MODULATE (1 << 22)
+# define MACH64_TEX_LIGHT_FCN_ALPHA_DECAL (2 << 22)
+# define MACH64_MIP_MAP_DISABLE (1 << 24)
+# define MACH64_BILINEAR_TEX_EN (1 << 25)
+# define MACH64_TEX_BLEND_FCN_MASK (3 << 26)
+# define MACH64_TEX_BLEND_FCN_NEAREST (0 << 26)
+# define MACH64_TEX_BLEND_FCN_LINEAR (2 << 26)
+# define MACH64_TEX_BLEND_FCN_TRILINEAR (3 << 26)
+# define MACH64_TEX_AMASK_AEN (1 << 28)
+# define MACH64_TEX_AMASK_BLEND_EDGE (1 << 29)
+# define MACH64_TEX_MAP_AEN (1 << 30)
+# define MACH64_SRC_3D_HOST_FIFO (1 << 31)
+#define MACH64_SCRATCH_REG0 0x0480
+#define MACH64_SCRATCH_REG1 0x0484
+#define MACH64_SECONDARY_TEX_OFF 0x0778
+#define MACH64_SETUP_CNTL 0x0304
+# define MACH64_DONT_START_TRI (1 << 0)
+# define MACH64_DONT_START_ANY (1 << 2)
+# define MACH64_FLAT_SHADE_MASK (3 << 3)
+# define MACH64_FLAT_SHADE_OFF (0 << 3)
+# define MACH64_FLAT_SHADE_VERTEX_1 (1 << 3)
+# define MACH64_FLAT_SHADE_VERTEX_2 (2 << 3)
+# define MACH64_FLAT_SHADE_VERTEX_3 (3 << 3)
+# define MACH64_SOLID_MODE_OFF (0 << 5)
+# define MACH64_SOLID_MODE_ON (1 << 5)
+# define MACH64_LOG_MAX_INC_ADJ (1 << 6)
+# define MACH64_SET_UP_CONTINUE (1 << 31)
+#define MACH64_SRC_CNTL 0x05b4
+#define MACH64_SRC_HEIGHT1 0x0594
+#define MACH64_SRC_HEIGHT2 0x05ac
+#define MACH64_SRC_HEIGHT1_WIDTH1 0x0598
+#define MACH64_SRC_HEIGHT2_WIDTH2 0x05b0
+#define MACH64_SRC_OFF_PITCH 0x0580
+#define MACH64_SRC_WIDTH1 0x0590
+#define MACH64_SRC_Y_X 0x058c
+
+#define MACH64_TEX_0_OFF 0x05c0
+#define MACH64_TEX_CNTL 0x0774
+# define MACH64_LOD_BIAS_SHIFT 0
+# define MACH64_LOD_BIAS_MASK (0xf << 0)
+# define MACH64_COMP_FACTOR_SHIFT 4
+# define MACH64_COMP_FACTOR_MASK (0xf << 4)
+# define MACH64_TEXTURE_COMPOSITE (1 << 8)
+# define MACH64_COMP_COMBINE_BLEND (0 << 9)
+# define MACH64_COMP_COMBINE_MODULATE (1 << 9)
+# define MACH64_COMP_BLEND_NEAREST (0 << 11)
+# define MACH64_COMP_BLEND_BILINEAR (1 << 11)
+# define MACH64_COMP_FILTER_NEAREST (0 << 12)
+# define MACH64_COMP_FILTER_BILINEAR (1 << 12)
+# define MACH64_COMP_ALPHA (1 << 13)
+# define MACH64_TEXTURE_TILING (1 << 14)
+# define MACH64_COMPOSITE_TEX_TILING (1 << 15)
+# define MACH64_TEX_COLLISION_DISABLE (1 << 16)
+# define MACH64_TEXTURE_CLAMP_S (1 << 17)
+# define MACH64_TEXTURE_CLAMP_T (1 << 18)
+# define MACH64_TEX_ST_MULT_W (0 << 19)
+# define MACH64_TEX_ST_DIRECT (1 << 19)
+# define MACH64_TEX_SRC_LOCAL (0 << 20)
+# define MACH64_TEX_SRC_AGP (1 << 20)
+# define MACH64_TEX_UNCOMPRESSED (0 << 21)
+# define MACH64_TEX_VQ_COMPRESSED (1 << 21)
+# define MACH64_COMP_TEX_UNCOMPRESSED (0 << 22)
+# define MACH64_COMP_TEX_VQ_COMPRESSED (1 << 22)
+# define MACH64_TEX_CACHE_FLUSH (1 << 23)
+# define MACH64_SEC_TEX_CLAMP_S (1 << 24)
+# define MACH64_SEC_TEX_CLAMP_T (1 << 25)
+# define MACH64_TEX_WRAP_S (1 << 28)
+# define MACH64_TEX_WRAP_T (1 << 29)
+# define MACH64_TEX_CACHE_SIZE_4K (1 << 30)
+# define MACH64_TEX_CACHE_SIZE_2K (1 << 30)
+# define MACH64_SECONDARY_STW (1 << 31)
+#define MACH64_TEX_PALETTE 0x077c
+#define MACH64_TEX_PALETTE_INDEX 0x0740
+#define MACH64_TEX_SIZE_PITCH 0x0770
+
+#define MACH64_VERTEX_1_ARGB 0x0254
+#define MACH64_VERTEX_1_S 0x0240
+#define MACH64_VERTEX_1_SECONDARY_S 0x0328
+#define MACH64_VERTEX_1_SECONDARY_T 0x032c
+#define MACH64_VERTEX_1_SECONDARY_W 0x0330
+#define MACH64_VERTEX_1_SPEC_ARGB 0x024c
+#define MACH64_VERTEX_1_T 0x0244
+#define MACH64_VERTEX_1_W 0x0248
+#define MACH64_VERTEX_1_X_Y 0x0258
+#define MACH64_VERTEX_1_Z 0x0250
+#define MACH64_VERTEX_2_ARGB 0x0274
+#define MACH64_VERTEX_2_S 0x0260
+#define MACH64_VERTEX_2_SECONDARY_S 0x0334
+#define MACH64_VERTEX_2_SECONDARY_T 0x0338
+#define MACH64_VERTEX_2_SECONDARY_W 0x033c
+#define MACH64_VERTEX_2_SPEC_ARGB 0x026c
+#define MACH64_VERTEX_2_T 0x0264
+#define MACH64_VERTEX_2_W 0x0268
+#define MACH64_VERTEX_2_X_Y 0x0278
+#define MACH64_VERTEX_2_Z 0x0270
+#define MACH64_VERTEX_3_ARGB 0x0294
+#define MACH64_VERTEX_3_S 0x0280
+#define MACH64_VERTEX_3_SECONDARY_S 0x02a0
+#define MACH64_VERTEX_3_SECONDARY_T 0x02a4
+#define MACH64_VERTEX_3_SECONDARY_W 0x02a8
+#define MACH64_VERTEX_3_SPEC_ARGB 0x028c
+#define MACH64_VERTEX_3_T 0x0284
+#define MACH64_VERTEX_3_W 0x0288
+#define MACH64_VERTEX_3_X_Y 0x0298
+#define MACH64_VERTEX_3_Z 0x0290
+
+#define MACH64_Z_CNTL 0x054c
+# define MACH64_Z_EN (1 << 0)
+# define MACH64_Z_SRC_2D (1 << 1)
+# define MACH64_Z_TEST_MASK (7 << 4)
+# define MACH64_Z_TEST_NEVER (0 << 4)
+# define MACH64_Z_TEST_LESS (1 << 4)
+# define MACH64_Z_TEST_LEQUAL (2 << 4)
+# define MACH64_Z_TEST_EQUAL (3 << 4)
+# define MACH64_Z_TEST_GEQUAL (4 << 4)
+# define MACH64_Z_TEST_GREATER (5 << 4)
+# define MACH64_Z_TEST_NOTEQUAL (6 << 4)
+# define MACH64_Z_TEST_ALWAYS (7 << 4)
+# define MACH64_Z_MASK_EN (1 << 8)
+#define MACH64_Z_OFF_PITCH 0x0548
+
+
+
+#define MACH64_DATATYPE_CI8 2
+#define MACH64_DATATYPE_ARGB1555 3
+#define MACH64_DATATYPE_RGB565 4
+#define MACH64_DATATYPE_ARGB8888 6
+#define MACH64_DATATYPE_RGB332 7
+#define MACH64_DATATYPE_Y8 8
+#define MACH64_DATATYPE_RGB8 9
+#define MACH64_DATATYPE_VYUY422 11
+#define MACH64_DATATYPE_YVYU422 12
+#define MACH64_DATATYPE_AYUV444 14
+#define MACH64_DATATYPE_ARGB4444 15
+
+#define MACH64_LAST_FRAME_REG MACH64_PAT_REG0
+#define MACH64_LAST_DISPATCH_REG MACH64_PAT_REG1
+
+#endif /* __MACH64_REG_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_screen.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_screen.c
new file mode 100644
index 000000000..3403434a5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_screen.c
@@ -0,0 +1,553 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * Jos�Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#include "mach64_context.h"
+#include "mach64_ioctl.h"
+#include "mach64_tris.h"
+#include "mach64_vb.h"
+#include "mach64_span.h"
+
+#include "context.h"
+#include "imports.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+
+#include "utils.h"
+#include "vblank.h"
+
+#include "GL/internal/dri_interface.h"
+
+/* Mach64 configuration
+ */
+#include "xmlpool.h"
+
+PUBLIC const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_NO_RAST(false)
+#if ENABLE_PERF_BOXES
+ DRI_CONF_PERFORMANCE_BOXES(false)
+#endif
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+#if ENABLE_PERF_BOXES
+static const GLuint __driNConfigOptions = 3;
+#else
+static const GLuint __driNConfigOptions = 2;
+#endif
+
+extern const struct dri_extension card_extensions[];
+
+static __GLcontextModes * fill_in_modes( __GLcontextModes * modes,
+ unsigned pixel_bits,
+ unsigned depth_bits,
+ unsigned stencil_bits,
+ const GLenum * db_modes,
+ unsigned num_db_modes,
+ int visType )
+{
+ static const u_int8_t bits[2][4] = {
+ { 5, 6, 5, 0 },
+ { 8, 8, 8, 0 }
+ };
+
+ static const u_int32_t masks[2][4] = {
+ { 0x0000F800, 0x000007E0, 0x0000001F, 0x00000000 },
+ { 0x00FF0000, 0x0000FF00, 0x000000FF, 0x00000000 }
+ };
+
+ unsigned i;
+ unsigned j;
+ const unsigned index = ((pixel_bits + 15) / 16) - 1;
+
+ for ( i = 0 ; i < num_db_modes ; i++ ) {
+ for ( j = 0 ; j < 2 ; j++ ) {
+
+ modes->redBits = bits[index][0];
+ modes->greenBits = bits[index][1];
+ modes->blueBits = bits[index][2];
+ modes->alphaBits = bits[index][3];
+ modes->redMask = masks[index][0];
+ modes->greenMask = masks[index][1];
+ modes->blueMask = masks[index][2];
+ modes->alphaMask = masks[index][3];
+ modes->rgbBits = modes->redBits + modes->greenBits
+ + modes->blueBits + modes->alphaBits;
+
+ modes->accumRedBits = 16 * j;
+ modes->accumGreenBits = 16 * j;
+ modes->accumBlueBits = 16 * j;
+ modes->accumAlphaBits = 0;
+ modes->visualRating = (j == 0) ? GLX_NONE : GLX_SLOW_CONFIG;
+ modes->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
+ modes->stencilBits = stencil_bits;
+ modes->depthBits = depth_bits;
+
+ modes->visualType = visType;
+ modes->renderType = GLX_RGBA_BIT;
+ modes->rgbMode = GL_TRUE;
+
+ if ( db_modes[i] == GLX_NONE ) {
+
+ modes->doubleBufferMode = GL_FALSE;
+ }
+ else {
+ modes->doubleBufferMode = GL_TRUE;
+ modes->swapMethod = db_modes[i];
+ }
+
+ modes = modes->next;
+ }
+ }
+
+ return modes;
+}
+
+
+static __GLcontextModes *
+mach64FillInModes( unsigned pixel_bits, unsigned depth_bits,
+ unsigned stencil_bits, GLboolean have_back_buffer )
+{
+ __GLcontextModes * modes;
+ __GLcontextModes * m;
+ unsigned num_modes;
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ unsigned i;
+
+ /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
+ * enough to add support. Basically, if a context is created with an
+ * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
+ * will never be used.
+ */
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
+ };
+
+ int depth_buffer_modes[2][2];
+
+
+ depth_buffer_modes[0][0] = depth_bits;
+ depth_buffer_modes[1][0] = depth_bits;
+
+ /* Just like with the accumulation buffer, always provide some modes
+ * with a stencil buffer. It will be a sw fallback, but some apps won't
+ * care about that.
+ */
+ depth_buffer_modes[0][1] = 0;
+ depth_buffer_modes[1][1] = (stencil_bits == 0) ? 8 : stencil_bits;
+
+ depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1;
+ back_buffer_factor = (have_back_buffer) ? 2 : 1;
+
+ num_modes = depth_buffer_factor * back_buffer_factor * 4;
+
+ modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
+ m = modes;
+ for ( i = 0 ; i < depth_buffer_factor ; i++ ) {
+ m = fill_in_modes( m, pixel_bits,
+ depth_buffer_modes[i][0], depth_buffer_modes[i][1],
+ back_buffer_modes, back_buffer_factor,
+ GLX_TRUE_COLOR );
+ }
+
+ for ( i = 0 ; i < depth_buffer_factor ; i++ ) {
+ m = fill_in_modes( m, pixel_bits,
+ depth_buffer_modes[i][0], depth_buffer_modes[i][1],
+ back_buffer_modes, back_buffer_factor,
+ GLX_DIRECT_COLOR );
+ }
+
+ /* Mark the visual as slow if there are "fake" stencil bits.
+ */
+ for ( m = modes ; m != NULL ; m = m->next ) {
+ if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ){
+ m->visualRating = GLX_SLOW_CONFIG;
+ }
+ }
+
+ return modes;
+}
+
+
+/* Create the device specific screen private data struct.
+ */
+static mach64ScreenRec *
+mach64CreateScreen( __DRIscreenPrivate *sPriv )
+{
+ mach64ScreenPtr mach64Screen;
+ ATIDRIPtr serverInfo = (ATIDRIPtr)sPriv->pDevPriv;
+ PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
+ (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
+ void * const psc = sPriv->psc->screenConfigs;
+
+ if (sPriv->devPrivSize != sizeof(ATIDRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(ATIDRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_DRI )
+ fprintf( stderr, "%s\n", __FUNCTION__ );
+
+ /* Allocate the private area */
+ mach64Screen = (mach64ScreenPtr) CALLOC( sizeof(*mach64Screen) );
+ if ( !mach64Screen ) return NULL;
+
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo (&mach64Screen->optionCache,
+ __driConfigOptions, __driNConfigOptions);
+
+ mach64Screen->IsPCI = serverInfo->IsPCI;
+
+ {
+ drm_mach64_getparam_t gp;
+ int ret;
+
+ gp.param = MACH64_PARAM_IRQ_NR;
+ gp.value = (void *) &mach64Screen->irq;
+
+ ret = drmCommandWriteRead( sPriv->fd, DRM_MACH64_GETPARAM,
+ &gp, sizeof(gp));
+ if (ret) {
+ fprintf(stderr, "DRM_MACH64_GETPARAM (MACH64_PARAM_IRQ_NR): %d\n", ret);
+ FREE( mach64Screen );
+ return NULL;
+ }
+ }
+
+ mach64Screen->mmio.handle = serverInfo->regs;
+ mach64Screen->mmio.size = serverInfo->regsSize;
+ if ( drmMap( sPriv->fd,
+ mach64Screen->mmio.handle,
+ mach64Screen->mmio.size,
+ (drmAddressPtr)&mach64Screen->mmio.map ) != 0 ) {
+ FREE( mach64Screen );
+ return NULL;
+ }
+
+ mach64Screen->buffers = drmMapBufs( sPriv->fd );
+ if ( !mach64Screen->buffers ) {
+ drmUnmap( (drmAddress)mach64Screen->mmio.map,
+ mach64Screen->mmio.size );
+ FREE( mach64Screen );
+ return NULL;
+ }
+
+ if ( !mach64Screen->IsPCI ) {
+ mach64Screen->agpTextures.handle = serverInfo->agp;
+ mach64Screen->agpTextures.size = serverInfo->agpSize;
+ if ( drmMap( sPriv->fd,
+ mach64Screen->agpTextures.handle,
+ mach64Screen->agpTextures.size,
+ (drmAddressPtr)&mach64Screen->agpTextures.map ) ) {
+ drmUnmapBufs( mach64Screen->buffers );
+ drmUnmap( (drmAddress)mach64Screen->mmio.map, mach64Screen->mmio.size );
+ FREE( mach64Screen );
+ return NULL;
+ }
+ }
+
+ mach64Screen->AGPMode = serverInfo->AGPMode;
+
+ mach64Screen->chipset = serverInfo->chipset;
+ mach64Screen->width = serverInfo->width;
+ mach64Screen->height = serverInfo->height;
+ mach64Screen->mem = serverInfo->mem;
+ mach64Screen->cpp = serverInfo->cpp;
+
+ mach64Screen->frontOffset = serverInfo->frontOffset;
+ mach64Screen->frontPitch = serverInfo->frontPitch;
+ mach64Screen->backOffset = serverInfo->backOffset;
+ mach64Screen->backPitch = serverInfo->backPitch;
+ mach64Screen->depthOffset = serverInfo->depthOffset;
+ mach64Screen->depthPitch = serverInfo->depthPitch;
+
+ mach64Screen->texOffset[MACH64_CARD_HEAP] = serverInfo->textureOffset;
+ mach64Screen->texSize[MACH64_CARD_HEAP] = serverInfo->textureSize;
+ mach64Screen->logTexGranularity[MACH64_CARD_HEAP] =
+ serverInfo->logTextureGranularity;
+
+ if ( mach64Screen->IsPCI ) {
+ mach64Screen->numTexHeaps = MACH64_NR_TEX_HEAPS - 1;
+ mach64Screen->firstTexHeap = MACH64_CARD_HEAP;
+ mach64Screen->texOffset[MACH64_AGP_HEAP] = 0;
+ mach64Screen->texSize[MACH64_AGP_HEAP] = 0;
+ mach64Screen->logTexGranularity[MACH64_AGP_HEAP] = 0;
+ } else {
+ if (mach64Screen->texSize[MACH64_CARD_HEAP] > 0) {
+ mach64Screen->numTexHeaps = MACH64_NR_TEX_HEAPS;
+ mach64Screen->firstTexHeap = MACH64_CARD_HEAP;
+ } else {
+ mach64Screen->numTexHeaps = MACH64_NR_TEX_HEAPS - 1;
+ mach64Screen->firstTexHeap = MACH64_AGP_HEAP;
+ }
+ mach64Screen->texOffset[MACH64_AGP_HEAP] = serverInfo->agpTextureOffset;
+ mach64Screen->texSize[MACH64_AGP_HEAP] = serverInfo->agpSize;
+ mach64Screen->logTexGranularity[MACH64_AGP_HEAP] = serverInfo->logAgpTextureGranularity;
+ }
+
+ mach64Screen->driScreen = sPriv;
+
+ if ( glx_enable_extension != NULL ) {
+ if ( mach64Screen->irq != 0 ) {
+ (*glx_enable_extension)( psc, "GLX_SGI_swap_control" );
+ (*glx_enable_extension)( psc, "GLX_SGI_video_sync" );
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_control" );
+ }
+
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
+ }
+
+ return mach64Screen;
+}
+
+/* Destroy the device specific screen private data struct.
+ */
+static void
+mach64DestroyScreen( __DRIscreenPrivate *driScreen )
+{
+ mach64ScreenRec *mach64Screen = (mach64ScreenRec *) driScreen->private;
+
+ if ( !mach64Screen )
+ return;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_DRI )
+ fprintf( stderr, "%s\n", __FUNCTION__ );
+
+ if ( !mach64Screen->IsPCI ) {
+ drmUnmap( (drmAddress)mach64Screen->agpTextures.map,
+ mach64Screen->agpTextures.size );
+ }
+
+ drmUnmapBufs( mach64Screen->buffers );
+ drmUnmap( (drmAddress)mach64Screen->mmio.map, mach64Screen->mmio.size );
+
+ FREE( mach64Screen );
+ driScreen->private = NULL;
+}
+
+
+/* Create and initialize the Mesa and driver specific pixmap buffer
+ * data.
+ */
+static GLboolean
+mach64CreateBuffer( __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ mach64ScreenPtr screen = (mach64ScreenPtr) driScrnPriv->private;
+
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+#if 0
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer( mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ mesaVis->alphaBits > 0 );
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->frontPitch);
+ mach64SetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ mach64SetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ mach64SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ mach64SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+
+static void
+mach64DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+
+/* Copy the back color buffer to the front color buffer */
+static void
+mach64SwapBuffers(__DRIdrawablePrivate *dPriv)
+{
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ mach64ContextPtr mmesa;
+ GLcontext *ctx;
+ mmesa = (mach64ContextPtr) dPriv->driContextPriv->driverPrivate;
+ ctx = mmesa->glCtx;
+ if (ctx->Visual.doubleBufferMode) {
+ _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
+ mach64CopyBuffer( dPriv );
+ }
+ }
+ else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__);
+ }
+}
+
+
+/* Initialize the driver specific screen private data.
+ */
+static GLboolean
+mach64InitDriver( __DRIscreenPrivate *driScreen )
+{
+ driScreen->private = (void *) mach64CreateScreen( driScreen );
+
+ if ( !driScreen->private ) {
+ mach64DestroyScreen( driScreen );
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+static struct __DriverAPIRec mach64API = {
+ .InitDriver = mach64InitDriver,
+ .DestroyScreen = mach64DestroyScreen,
+ .CreateContext = mach64CreateContext,
+ .DestroyContext = mach64DestroyContext,
+ .CreateBuffer = mach64CreateBuffer,
+ .DestroyBuffer = mach64DestroyBuffer,
+ .SwapBuffers = mach64SwapBuffers,
+ .MakeCurrent = mach64MakeCurrent,
+ .UnbindContext = mach64UnbindContext,
+ .GetSwapInfo = NULL,
+ .GetMSC = driGetMSC32,
+ .WaitForMSC = driWaitForMSC32,
+ .WaitForSBC = NULL,
+ .SwapBuffersMSC = NULL
+};
+
+
+/**
+ * This is the bootstrap function for the driver. libGL supplies all of the
+ * requisite information about the system, and the driver initializes itself.
+ * This routine also fills in the linked list pointed to by \c driver_modes
+ * with the \c __GLcontextModes that the driver can support for windows or
+ * pbuffers.
+ *
+ * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
+ * failure.
+ */
+PUBLIC
+void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
+ const __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drmAddress pSAREA, int fd,
+ int internal_api_version,
+ const __DRIinterfaceMethods * interface,
+ __GLcontextModes ** driver_modes )
+
+{
+ __DRIscreenPrivate *psp;
+ static const __DRIversion ddx_expected = { 6, 4, 0 };
+ static const __DRIversion dri_expected = { 4, 0, 0 };
+ static const __DRIversion drm_expected = { 1, 0, 0 };
+
+ dri_interface = interface;
+
+ if ( ! driCheckDriDdxDrmVersions2( "Mach64",
+ dri_version, & dri_expected,
+ ddx_version, & ddx_expected,
+ drm_version, & drm_expected ) ) {
+ return NULL;
+ }
+
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &mach64API);
+ if ( psp != NULL ) {
+ ATIDRIPtr dri_priv = (ATIDRIPtr) psp->pDevPriv;
+ *driver_modes = mach64FillInModes( dri_priv->cpp * 8,
+ 16,
+ 0,
+ 1);
+
+ /* Calling driInitExtensions here, with a NULL context pointer, does not actually
+ * enable the extensions. It just makes sure that all the dispatch offsets for all
+ * the extensions that *might* be enables are known. This is needed because the
+ * dispatch offsets need to be known when _mesa_context_create is called, but we can't
+ * enable the extensions until we have a context pointer.
+ *
+ * Hello chicken. Hello egg. How are you two today?
+ */
+ driInitExtensions( NULL, card_extensions, GL_FALSE );
+ }
+
+ return (void *) psp;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_screen.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_screen.h
new file mode 100644
index 000000000..5305058e2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_screen.h
@@ -0,0 +1,78 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#ifndef __MACH64_SCREEN_H__
+#define __MACH64_SCREEN_H__
+
+#include "xmlconfig.h"
+
+typedef struct {
+ drm_handle_t handle; /* Handle to the DRM region */
+ drmSize size; /* Size of the DRM region */
+ drmAddress *map; /* Mapping of the DRM region */
+} mach64RegionRec, *mach64RegionPtr;
+
+typedef struct {
+ int chipset;
+ int width;
+ int height;
+ int mem;
+ int cpp;
+
+ unsigned int frontOffset;
+ unsigned int frontPitch;
+ unsigned int backOffset;
+ unsigned int backPitch;
+
+ unsigned int depthOffset;
+ unsigned int depthPitch;
+
+ int IsPCI;
+ int AGPMode;
+ unsigned int irq; /* IRQ number (0 means none) */
+
+ /* Shared Texture data */
+ int firstTexHeap, numTexHeaps;
+ int texOffset[MACH64_NR_TEX_HEAPS];
+ int texSize[MACH64_NR_TEX_HEAPS];
+ int logTexGranularity[MACH64_NR_TEX_HEAPS];
+
+ mach64RegionRec mmio;
+ mach64RegionRec agpTextures;
+
+ drmBufMapPtr buffers;
+
+ __DRIscreenPrivate *driScreen;
+
+ driOptionCache optionCache;
+} mach64ScreenRec, *mach64ScreenPtr;
+
+#endif /* __MACH64_SCREEN_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_span.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_span.c
new file mode 100644
index 000000000..0ac0eeaa6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_span.c
@@ -0,0 +1,231 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * Jos�Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#include "mach64_context.h"
+#include "mach64_ioctl.h"
+#include "mach64_state.h"
+#include "mach64_span.h"
+
+#include "swrast/swrast.h"
+
+#define DBG 0
+
+#define LOCAL_VARS \
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); \
+ mach64ScreenRec *mach64Screen = mmesa->mach64Screen; \
+ __DRIscreenPrivate *driScreen = mmesa->driScreen; \
+ __DRIdrawablePrivate *dPriv = mmesa->driDrawable; \
+ GLuint pitch = mmesa->drawPitch * mach64Screen->cpp; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(driScreen->pFB + \
+ mmesa->drawOffset + \
+ (dPriv->x * mach64Screen->cpp) + \
+ (dPriv->y * pitch)); \
+ char *read_buf = (char *)(driScreen->pFB + \
+ mmesa->readOffset + \
+ (dPriv->x * mach64Screen->cpp) + \
+ (dPriv->y * pitch)); \
+ GLushort p; \
+ (void) read_buf; (void) buf; (void) p
+
+#define LOCAL_DEPTH_VARS \
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); \
+ mach64ScreenRec *mach64Screen = mmesa->mach64Screen; \
+ __DRIdrawablePrivate *dPriv = mmesa->driDrawable; \
+ __DRIscreenPrivate *driScreen = mmesa->driScreen; \
+ GLuint pitch = mach64Screen->depthPitch * 2; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(driScreen->pFB + \
+ mach64Screen->depthOffset + \
+ dPriv->x * 2 + \
+ dPriv->y * pitch)
+
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
+
+#define Y_FLIP( _y ) (height - _y - 1)
+
+#define HW_LOCK()
+
+/* FIXME could/should we use dPriv->numClipRects like the other drivers? */
+#define HW_CLIPLOOP() \
+ do { \
+ int _nc = mmesa->numClipRects; \
+ \
+ 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 maxy = mmesa->pClipRects[_nc].y2 - mmesa->drawY;
+
+#define HW_ENDCLIPLOOP() \
+ } \
+ } while (0)
+
+#define HW_UNLOCK()
+
+
+
+/* ================================================================
+ * Color buffer
+ */
+
+/* 16 bit, RGB565 color spanline and pixel functions
+ */
+#define SPANTMP_PIXEL_FMT GL_RGB
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
+
+#define TAG(x) mach64##x##_RGB565
+#define TAG2(x,y) mach64##x##_RGB565##y
+#include "spantmp2.h"
+
+
+/* 32 bit, ARGB8888 color spanline and pixel functions
+ */
+/* FIXME the old code always read back alpha as 0xff, i.e. fully opaque.
+ Was there a reason to do so ? If so that'll won't work with that template... */
+#define SPANTMP_PIXEL_FMT GL_BGRA
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
+
+#define TAG(x) mach64##x##_ARGB8888
+#define TAG2(x,y) mach64##x##_ARGB8888##y
+#include "spantmp2.h"
+
+
+/* ================================================================
+ * Depth buffer
+ */
+
+/* 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) mach64##x##_16
+#include "depthtmp.h"
+
+
+/*
+ * This function is called to specify which buffer to read and write
+ * for software rasterization (swrast) fallbacks. This doesn't necessarily
+ * correspond to glDrawBuffer() or glReadBuffer() calls.
+ */
+static void mach64DDSetBuffer( GLcontext *ctx,
+ GLframebuffer *colorBuffer,
+ GLuint bufferBit )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ switch ( bufferBit ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ if (MACH64_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf(stderr,"%s: BUFFER_BIT_FRONT_LEFT\n", __FUNCTION__);
+ mmesa->drawOffset = mmesa->readOffset = mmesa->mach64Screen->frontOffset;
+ mmesa->drawPitch = mmesa->readPitch = mmesa->mach64Screen->frontPitch;
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ if (MACH64_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf(stderr,"%s: BUFFER_BIT_BACK_LEFT\n", __FUNCTION__);
+ mmesa->drawOffset = mmesa->readOffset = mmesa->mach64Screen->backOffset;
+ mmesa->drawPitch = mmesa->readPitch = mmesa->mach64Screen->backPitch;
+ break;
+ default:
+ break;
+ }
+}
+
+static void mach64SpanRenderStart( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ LOCK_HARDWARE( mmesa );
+ FINISH_DMA_LOCKED( mmesa );
+}
+
+static void mach64SpanRenderFinish( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ _swrast_flush( ctx );
+ UNLOCK_HARDWARE( mmesa );
+}
+
+void mach64DDInitSpanFuncs( GLcontext *ctx )
+{
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetBuffer = mach64DDSetBuffer;
+ swdd->SpanRenderStart = mach64SpanRenderStart;
+ swdd->SpanRenderFinish = mach64SpanRenderFinish;
+}
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+mach64SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ mach64InitPointers_RGB565(&drb->Base);
+ }
+ else {
+ mach64InitPointers_ARGB8888(&drb->Base);
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = mach64ReadDepthSpan_16;
+ drb->Base.GetValues = mach64ReadDepthPixels_16;
+ drb->Base.PutRow = mach64WriteDepthSpan_16;
+ drb->Base.PutMonoRow = mach64WriteMonoDepthSpan_16;
+ drb->Base.PutValues = mach64WriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ /* never */
+ drb->Base.GetRow = NULL;
+ drb->Base.GetValues = NULL;
+ drb->Base.PutRow = NULL;
+ drb->Base.PutMonoRow = NULL;
+ drb->Base.PutValues = NULL;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ /* never */
+ drb->Base.GetRow = NULL;
+ drb->Base.GetValues = NULL;
+ drb->Base.PutRow = NULL;
+ drb->Base.PutMonoRow = NULL;
+ drb->Base.PutValues = NULL;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_span.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_span.h
new file mode 100644
index 000000000..0f4c76647
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_span.h
@@ -0,0 +1,41 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ *
+ */
+
+#ifndef __MACH64_SPAN_H__
+#define __MACH64_SPAN_H__
+
+#include "drirenderbuffer.h"
+
+extern void mach64DDInitSpanFuncs( GLcontext *ctx );
+
+extern void
+mach64SetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_state.c
new file mode 100644
index 000000000..d9b5725a6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_state.c
@@ -0,0 +1,1216 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * Jos�Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#include "mach64_context.h"
+#include "mach64_state.h"
+#include "mach64_ioctl.h"
+#include "mach64_tris.h"
+#include "mach64_vb.h"
+#include "mach64_tex.h"
+
+#include "context.h"
+#include "buffers.h"
+#include "enums.h"
+#include "colormac.h"
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "tnl/t_pipeline.h"
+
+
+/* =============================================================
+ * Alpha blending
+ */
+
+static void mach64UpdateAlphaMode( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ GLuint a = mmesa->setup.alpha_tst_cntl;
+ GLuint s = mmesa->setup.scale_3d_cntl;
+ GLuint m = mmesa->setup.dp_write_mask;
+
+ if ( ctx->Color.AlphaEnabled ) {
+ GLubyte ref;
+
+ CLAMPED_FLOAT_TO_UBYTE(ref, ctx->Color.AlphaRef);
+
+ a &= ~(MACH64_ALPHA_TEST_MASK | MACH64_REF_ALPHA_MASK);
+
+ switch ( ctx->Color.AlphaFunc ) {
+ case GL_NEVER:
+ a |= MACH64_ALPHA_TEST_NEVER;
+ break;
+ case GL_LESS:
+ a |= MACH64_ALPHA_TEST_LESS;
+ break;
+ case GL_LEQUAL:
+ a |= MACH64_ALPHA_TEST_LEQUAL;
+ break;
+ case GL_EQUAL:
+ a |= MACH64_ALPHA_TEST_EQUAL;
+ break;
+ case GL_GEQUAL:
+ a |= MACH64_ALPHA_TEST_GEQUAL;
+ break;
+ case GL_GREATER:
+ a |= MACH64_ALPHA_TEST_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ a |= MACH64_ALPHA_TEST_NOTEQUAL;
+ break;
+ case GL_ALWAYS:
+ a |= MACH64_ALPHA_TEST_ALWAYS;
+ break;
+ }
+
+ a |= (ref << MACH64_REF_ALPHA_SHIFT);
+ a |= MACH64_ALPHA_TEST_EN;
+ } else {
+ a &= ~MACH64_ALPHA_TEST_EN;
+ }
+
+ FALLBACK( mmesa, MACH64_FALLBACK_BLEND_FUNC, GL_FALSE );
+
+ if ( ctx->Color.BlendEnabled ) {
+ s &= ~(MACH64_ALPHA_BLEND_SRC_MASK |
+ MACH64_ALPHA_BLEND_DST_MASK |
+ MACH64_ALPHA_BLEND_SAT);
+
+ switch ( ctx->Color.BlendSrcRGB ) {
+ case GL_ZERO:
+ s |= MACH64_ALPHA_BLEND_SRC_ZERO;
+ break;
+ case GL_ONE:
+ s |= MACH64_ALPHA_BLEND_SRC_ONE;
+ break;
+ case GL_DST_COLOR:
+ s |= MACH64_ALPHA_BLEND_SRC_DSTCOLOR;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ s |= MACH64_ALPHA_BLEND_SRC_INVDSTCOLOR;
+ break;
+ case GL_SRC_ALPHA:
+ s |= MACH64_ALPHA_BLEND_SRC_SRCALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ s |= MACH64_ALPHA_BLEND_SRC_INVSRCALPHA;
+ break;
+ case GL_DST_ALPHA:
+ s |= MACH64_ALPHA_BLEND_SRC_DSTALPHA;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ s |= MACH64_ALPHA_BLEND_SRC_INVDSTALPHA;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ s |= (MACH64_ALPHA_BLEND_SRC_SRCALPHA |
+ MACH64_ALPHA_BLEND_SAT);
+ break;
+ default:
+ FALLBACK( mmesa, MACH64_FALLBACK_BLEND_FUNC, GL_TRUE );
+ }
+
+ switch ( ctx->Color.BlendDstRGB ) {
+ case GL_ZERO:
+ s |= MACH64_ALPHA_BLEND_DST_ZERO;
+ break;
+ case GL_ONE:
+ s |= MACH64_ALPHA_BLEND_DST_ONE;
+ break;
+ case GL_SRC_COLOR:
+ s |= MACH64_ALPHA_BLEND_DST_SRCCOLOR;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ s |= MACH64_ALPHA_BLEND_DST_INVSRCCOLOR;
+ break;
+ case GL_SRC_ALPHA:
+ s |= MACH64_ALPHA_BLEND_DST_SRCALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ s |= MACH64_ALPHA_BLEND_DST_INVSRCALPHA;
+ break;
+ case GL_DST_ALPHA:
+ s |= MACH64_ALPHA_BLEND_DST_DSTALPHA;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ s |= MACH64_ALPHA_BLEND_DST_INVDSTALPHA;
+ break;
+ default:
+ FALLBACK( mmesa, MACH64_FALLBACK_BLEND_FUNC, GL_TRUE );
+ }
+
+ m = 0xffffffff; /* Can't color mask and blend at the same time */
+ s &= ~MACH64_ALPHA_FOG_EN_FOG; /* Can't fog and blend at the same time */
+ s |= MACH64_ALPHA_FOG_EN_ALPHA;
+ } else {
+ s &= ~MACH64_ALPHA_FOG_EN_ALPHA;
+ }
+
+ if ( mmesa->setup.alpha_tst_cntl != a ) {
+ mmesa->setup.alpha_tst_cntl = a;
+ mmesa->dirty |= MACH64_UPLOAD_Z_ALPHA_CNTL;
+ }
+ if ( mmesa->setup.scale_3d_cntl != s ) {
+ mmesa->setup.scale_3d_cntl = s;
+ mmesa->dirty |= MACH64_UPLOAD_SCALE_3D_CNTL;
+ }
+ if ( mmesa->setup.dp_write_mask != m ) {
+ mmesa->setup.dp_write_mask = m;
+ mmesa->dirty |= MACH64_UPLOAD_DP_WRITE_MASK;
+ }
+}
+
+static void mach64DDAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MACH64_NEW_ALPHA;
+}
+
+static void mach64DDBlendEquationSeparate( GLcontext *ctx,
+ GLenum modeRGB, GLenum modeA )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ assert( modeRGB == modeA );
+ FLUSH_BATCH( mmesa );
+
+ /* BlendEquation affects ColorLogicOpEnabled
+ */
+ FALLBACK( MACH64_CONTEXT(ctx), MACH64_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
+
+ /* Can only do blend addition, not min, max, subtract, etc. */
+ FALLBACK( MACH64_CONTEXT(ctx), MACH64_FALLBACK_BLEND_EQ,
+ modeRGB != GL_FUNC_ADD);
+
+ mmesa->new_state |= MACH64_NEW_ALPHA;
+}
+
+static void mach64DDBlendFuncSeparate( GLcontext *ctx,
+ GLenum sfactorRGB, GLenum dfactorRGB,
+ GLenum sfactorA, GLenum dfactorA )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MACH64_NEW_ALPHA;
+}
+
+
+/* =============================================================
+ * Depth testing
+ */
+
+static void mach64UpdateZMode( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ GLuint z = mmesa->setup.z_cntl;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_MSG ) {
+ fprintf( stderr, "%s:\n", __FUNCTION__ );
+ }
+
+ if ( ctx->Depth.Test ) {
+ z &= ~MACH64_Z_TEST_MASK;
+
+ switch ( ctx->Depth.Func ) {
+ case GL_NEVER:
+ z |= MACH64_Z_TEST_NEVER;
+ break;
+ case GL_ALWAYS:
+ z |= MACH64_Z_TEST_ALWAYS;
+ break;
+ case GL_LESS:
+ z |= MACH64_Z_TEST_LESS;
+ break;
+ case GL_LEQUAL:
+ z |= MACH64_Z_TEST_LEQUAL;
+ break;
+ case GL_EQUAL:
+ z |= MACH64_Z_TEST_EQUAL;
+ break;
+ case GL_GEQUAL:
+ z |= MACH64_Z_TEST_GEQUAL;
+ break;
+ case GL_GREATER:
+ z |= MACH64_Z_TEST_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ z |= MACH64_Z_TEST_NOTEQUAL;
+ break;
+ }
+
+ z |= MACH64_Z_EN;
+ } else {
+ z &= ~MACH64_Z_EN;
+ }
+
+ if ( ctx->Depth.Mask ) {
+ z |= MACH64_Z_MASK_EN;
+ } else {
+ z &= ~MACH64_Z_MASK_EN;
+ }
+
+ if ( mmesa->setup.z_cntl != z ) {
+ mmesa->setup.z_cntl = z;
+ mmesa->dirty |= MACH64_UPLOAD_Z_ALPHA_CNTL;
+ }
+}
+
+static void mach64DDDepthFunc( GLcontext *ctx, GLenum func )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MACH64_NEW_DEPTH;
+}
+
+static void mach64DDDepthMask( GLcontext *ctx, GLboolean flag )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MACH64_NEW_DEPTH;
+}
+
+static void mach64DDClearDepth( GLcontext *ctx, GLclampd d )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ /* Always have a 16-bit depth buffer.
+ */
+ mmesa->ClearDepth = d * 0xffff;
+}
+
+
+/* =============================================================
+ * Fog
+ */
+
+static void mach64UpdateFogAttrib( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ CARD32 s = mmesa->setup.scale_3d_cntl;
+ GLubyte c[4];
+ CARD32 col;
+
+ /* Can't fog if blending is on */
+ if ( ctx->Color.BlendEnabled )
+ return;
+
+ if ( ctx->Fog.Enabled ) {
+ s |= MACH64_ALPHA_FOG_EN_FOG;
+ s &= ~(MACH64_ALPHA_BLEND_SRC_MASK |
+ MACH64_ALPHA_BLEND_DST_MASK |
+ MACH64_ALPHA_BLEND_SAT);
+ /* From Utah-glx: "fog color is now dest and fog factor is alpha, so
+ * use GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA"
+ */
+ s |= (MACH64_ALPHA_BLEND_SRC_SRCALPHA |
+ MACH64_ALPHA_BLEND_DST_INVSRCALPHA);
+ /* From Utah-glx: "can't use texture alpha when fogging" */
+ s &= ~MACH64_TEX_MAP_AEN;
+ } else {
+ s &= ~(MACH64_ALPHA_BLEND_SRC_MASK |
+ MACH64_ALPHA_BLEND_DST_MASK |
+ MACH64_ALPHA_BLEND_SAT);
+ s |= (MACH64_ALPHA_BLEND_SRC_ONE |
+ MACH64_ALPHA_BLEND_DST_ZERO);
+ s &= ~MACH64_ALPHA_FOG_EN_FOG;
+ }
+
+ c[0] = FLOAT_TO_UBYTE( ctx->Fog.Color[0] );
+ c[1] = FLOAT_TO_UBYTE( ctx->Fog.Color[1] );
+ c[2] = FLOAT_TO_UBYTE( ctx->Fog.Color[2] );
+ c[3] = FLOAT_TO_UBYTE( ctx->Fog.Color[3] );
+
+ col = mach64PackColor( 4, c[0], c[1], c[2], c[3] );
+
+ if ( mmesa->setup.dp_fog_clr != col ) {
+ mmesa->setup.dp_fog_clr = col;
+ mmesa->dirty |= MACH64_UPLOAD_DP_FOG_CLR;
+ }
+ if ( mmesa->setup.scale_3d_cntl != s ) {
+ mmesa->setup.scale_3d_cntl = s;
+ mmesa->dirty |= MACH64_UPLOAD_SCALE_3D_CNTL;
+ }
+
+}
+
+static void mach64DDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MACH64_NEW_FOG;
+}
+
+
+/* =============================================================
+ * Clipping
+ */
+
+static void mach64UpdateClipping( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ mach64ScreenPtr mach64Screen = mmesa->mach64Screen;
+
+ if ( mmesa->driDrawable ) {
+ __DRIdrawablePrivate *drawable = mmesa->driDrawable;
+ int x1 = 0;
+ int y1 = 0;
+ int x2 = drawable->w - 1;
+ int y2 = drawable->h - 1;
+
+ if ( ctx->Scissor.Enabled ) {
+ if ( ctx->Scissor.X > x1 ) {
+ x1 = ctx->Scissor.X;
+ }
+ if ( drawable->h - ctx->Scissor.Y - ctx->Scissor.Height > y1 ) {
+ y1 = drawable->h - ctx->Scissor.Y - ctx->Scissor.Height;
+ }
+ if ( ctx->Scissor.X + ctx->Scissor.Width - 1 < x2 ) {
+ x2 = ctx->Scissor.X + ctx->Scissor.Width - 1;
+ }
+ if ( drawable->h - ctx->Scissor.Y - 1 < y2 ) {
+ y2 = drawable->h - ctx->Scissor.Y - 1;
+ }
+ }
+
+ x1 += drawable->x;
+ y1 += drawable->y;
+ x2 += drawable->x;
+ y2 += drawable->y;
+
+ /* clamp to screen borders */
+ if (x1 < 0) x1 = 0;
+ if (y1 < 0) y1 = 0;
+ if (x2 < 0) x2 = 0;
+ if (y2 < 0) y2 = 0;
+ if (x2 > mach64Screen->width-1) x2 = mach64Screen->width-1;
+ if (y2 > mach64Screen->height-1) y2 = mach64Screen->height-1;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_MSG ) {
+ fprintf( stderr, "%s: drawable %3d %3d %3d %3d\n",
+ __FUNCTION__,
+ drawable->x,
+ drawable->y,
+ drawable->w,
+ drawable->h );
+ fprintf( stderr, "%s: scissor %3d %3d %3d %3d\n",
+ __FUNCTION__,
+ ctx->Scissor.X,
+ ctx->Scissor.Y,
+ ctx->Scissor.Width,
+ ctx->Scissor.Height );
+ fprintf( stderr, "%s: final %3d %3d %3d %3d\n",
+ __FUNCTION__, x1, y1, x2, y2 );
+ fprintf( stderr, "\n" );
+ }
+
+ mmesa->setup.sc_top_bottom = ((y1 << 0) |
+ (y2 << 16));
+
+ mmesa->setup.sc_left_right = ((x1 << 0) |
+ (x2 << 16));
+
+ /* UPLOAD_MISC reduces the dirty state, we just need to
+ * emit the scissor to the SAREA. We need to dirty cliprects
+ * since the scissor and cliprects are intersected to update the
+ * single hardware scissor
+ */
+ mmesa->dirty |= MACH64_UPLOAD_MISC | MACH64_UPLOAD_CLIPRECTS;
+ }
+}
+
+static void mach64DDScissor( GLcontext *ctx,
+ GLint x, GLint y, GLsizei w, GLsizei h )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MACH64_NEW_CLIP;
+}
+
+
+/* =============================================================
+ * Culling
+ */
+
+static void mach64UpdateCull( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ GLfloat backface_sign = 1;
+
+ if ( ctx->Polygon.CullFlag /*&& ctx->PB->primitive == GL_POLYGON*/ ) {
+ backface_sign = 1;
+ switch ( ctx->Polygon.CullFaceMode ) {
+ case GL_BACK:
+ if ( ctx->Polygon.FrontFace == GL_CCW )
+ backface_sign = -1;
+ break;
+ case GL_FRONT:
+ if ( ctx->Polygon.FrontFace != GL_CCW )
+ backface_sign = -1;
+ break;
+ default:
+ case GL_FRONT_AND_BACK:
+ backface_sign = 0;
+ break;
+ }
+ } else {
+ backface_sign = 0;
+ }
+
+ mmesa->backface_sign = backface_sign;
+
+}
+
+static void mach64DDCullFace( GLcontext *ctx, GLenum mode )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MACH64_NEW_CULL;
+}
+
+static void mach64DDFrontFace( GLcontext *ctx, GLenum mode )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MACH64_NEW_CULL;
+}
+
+
+/* =============================================================
+ * Masks
+ */
+
+static void mach64UpdateMasks( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ GLuint mask = 0xffffffff;
+
+ /* mach64 can't color mask with alpha blending enabled */
+ if ( !ctx->Color.BlendEnabled ) {
+ mask = mach64PackColor( mmesa->mach64Screen->cpp,
+ ctx->Color.ColorMask[RCOMP],
+ ctx->Color.ColorMask[GCOMP],
+ ctx->Color.ColorMask[BCOMP],
+ ctx->Color.ColorMask[ACOMP] );
+ }
+
+ if ( mmesa->setup.dp_write_mask != mask ) {
+ mmesa->setup.dp_write_mask = mask;
+ mmesa->dirty |= MACH64_UPLOAD_DP_WRITE_MASK;
+ }
+}
+
+static void mach64DDColorMask( GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MACH64_NEW_MASKS;
+}
+
+
+/* =============================================================
+ * Rendering attributes
+ *
+ * We really don't want to recalculate all this every time we bind a
+ * texture. These things shouldn't change all that often, so it makes
+ * sense to break them out of the core texture state update routines.
+ */
+
+static void mach64UpdateSpecularLighting( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ GLuint a = mmesa->setup.alpha_tst_cntl;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_MSG ) {
+ fprintf( stderr, "%s:\n", __FUNCTION__ );
+ }
+
+ if ( ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR &&
+ ctx->Light.Enabled ) {
+ a |= MACH64_SPECULAR_LIGHT_EN;
+ } else {
+ a &= ~MACH64_SPECULAR_LIGHT_EN;
+ }
+
+ if ( mmesa->setup.alpha_tst_cntl != a ) {
+ mmesa->setup.alpha_tst_cntl = a;
+ mmesa->dirty |= MACH64_UPLOAD_Z_ALPHA_CNTL;
+ mmesa->new_state |= MACH64_NEW_CONTEXT;
+ }
+}
+
+static void mach64DDLightModelfv( GLcontext *ctx, GLenum pname,
+ const GLfloat *param )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ if ( pname == GL_LIGHT_MODEL_COLOR_CONTROL ) {
+ FLUSH_BATCH( mmesa );
+ mach64UpdateSpecularLighting(ctx);
+ }
+}
+
+static void mach64DDShadeModel( GLcontext *ctx, GLenum mode )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ GLuint s = mmesa->setup.setup_cntl;
+
+ s &= ~MACH64_FLAT_SHADE_MASK;
+
+ switch ( mode ) {
+ case GL_FLAT:
+ s |= MACH64_FLAT_SHADE_VERTEX_3;
+ break;
+ case GL_SMOOTH:
+ s |= MACH64_FLAT_SHADE_OFF;
+ break;
+ default:
+ return;
+ }
+
+ if ( mmesa->setup.setup_cntl != s ) {
+ FLUSH_BATCH( mmesa );
+ mmesa->setup.setup_cntl = s;
+
+ mmesa->dirty |= MACH64_UPLOAD_SETUP_CNTL;
+ }
+}
+
+
+/* =============================================================
+ * Viewport
+ */
+
+
+void mach64CalcViewport( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat *m = mmesa->hw_viewport;
+
+ /* See also mach64_translate_vertex.
+ */
+ m[MAT_SX] = v[MAT_SX];
+ m[MAT_TX] = v[MAT_TX] + (GLfloat)mmesa->drawX + SUBPIXEL_X;
+ m[MAT_SY] = - v[MAT_SY];
+ m[MAT_TY] = - v[MAT_TY] + mmesa->driDrawable->h + (GLfloat)mmesa->drawY + SUBPIXEL_Y;
+ m[MAT_SZ] = v[MAT_SZ] * mmesa->depth_scale;
+ m[MAT_TZ] = v[MAT_TZ] * mmesa->depth_scale;
+
+ mmesa->SetupNewInputs = ~0;
+}
+
+static void mach64Viewport( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
+ mach64CalcViewport( ctx );
+}
+
+static void mach64DepthRange( GLcontext *ctx,
+ GLclampd nearval, GLclampd farval )
+{
+ mach64CalcViewport( ctx );
+}
+
+
+/* =============================================================
+ * Miscellaneous
+ */
+
+static void mach64DDClearColor( GLcontext *ctx,
+ const GLfloat color[4] )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ GLubyte c[4];
+
+ CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
+
+ mmesa->ClearColor = mach64PackColor( mmesa->mach64Screen->cpp,
+ c[0], c[1], c[2], c[3] );
+}
+
+static void mach64DDLogicOpCode( GLcontext *ctx, GLenum opcode )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ if ( ctx->Color.ColorLogicOpEnabled ) {
+ FLUSH_BATCH( mmesa );
+
+ FALLBACK( mmesa, MACH64_FALLBACK_LOGICOP, opcode != GL_COPY);
+ }
+}
+
+void mach64SetCliprects( GLcontext *ctx, GLenum mode )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
+
+ switch ( mode ) {
+ case GL_FRONT_LEFT:
+ mmesa->numClipRects = dPriv->numClipRects;
+ mmesa->pClipRects = dPriv->pClipRects;
+ mmesa->drawX = dPriv->x;
+ mmesa->drawY = dPriv->y;
+ break;
+ case GL_BACK_LEFT:
+ if ( dPriv->numBackClipRects == 0 ) {
+ mmesa->numClipRects = dPriv->numClipRects;
+ mmesa->pClipRects = dPriv->pClipRects;
+ mmesa->drawX = dPriv->x;
+ mmesa->drawY = dPriv->y;
+ } else {
+ mmesa->numClipRects = dPriv->numBackClipRects;
+ mmesa->pClipRects = dPriv->pBackClipRects;
+ mmesa->drawX = dPriv->backX;
+ mmesa->drawY = dPriv->backY;
+ }
+ break;
+ default:
+ return;
+ }
+
+ mach64UpdateClipping( ctx );
+
+ mmesa->dirty |= MACH64_UPLOAD_CLIPRECTS;
+}
+
+static void mach64DDDrawBuffer( GLcontext *ctx, GLenum mode )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ FLUSH_BATCH( mmesa );
+
+ /*
+ * _DrawDestMask is easier to cope with than <mode>.
+ */
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ FALLBACK( mmesa, MACH64_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ mach64SetCliprects( ctx, GL_FRONT_LEFT );
+ if (MACH64_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf(stderr,"%s: BUFFER_BIT_FRONT_LEFT\n", __FUNCTION__);
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ FALLBACK( mmesa, MACH64_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ mach64SetCliprects( ctx, GL_BACK_LEFT );
+ if (MACH64_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf(stderr,"%s: BUFFER_BIT_BACK_LEFT\n", __FUNCTION__);
+ break;
+ default:
+ /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
+ FALLBACK( mmesa, MACH64_FALLBACK_DRAW_BUFFER, GL_TRUE );
+ if (MACH64_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf(stderr,"%s: fallback (mode=%d)\n", __FUNCTION__, mode);
+ break;
+ }
+
+ /* We want to update the s/w rast state too so that mach64SetBuffer()
+ * gets called.
+ */
+ _swrast_DrawBuffer(ctx, mode);
+
+ mmesa->setup.dst_off_pitch = (((mmesa->drawPitch/8) << 22) |
+ (mmesa->drawOffset >> 3));
+
+ mmesa->dirty |= MACH64_UPLOAD_DST_OFF_PITCH;
+}
+
+static void mach64DDReadBuffer( GLcontext *ctx, GLenum mode )
+{
+ /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
+}
+
+/* =============================================================
+ * State enable/disable
+ */
+
+static void mach64DDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %s = %s )\n",
+ __FUNCTION__, _mesa_lookup_enum_by_nr( cap ),
+ state ? "GL_TRUE" : "GL_FALSE" );
+ }
+
+ switch ( cap ) {
+ case GL_ALPHA_TEST:
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MACH64_NEW_ALPHA;
+ break;
+
+ case GL_BLEND:
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MACH64_NEW_ALPHA;
+
+ /* enable(GL_BLEND) affects ColorLogicOpEnabled.
+ */
+ FALLBACK( mmesa, MACH64_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
+ break;
+
+ case GL_CULL_FACE:
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MACH64_NEW_CULL;
+ break;
+
+ case GL_DEPTH_TEST:
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MACH64_NEW_DEPTH;
+ break;
+
+ case GL_DITHER:
+ do {
+ GLuint s = mmesa->setup.scale_3d_cntl;
+ FLUSH_BATCH( mmesa );
+
+ if ( ctx->Color.DitherFlag ) {
+ /* Dithering causes problems w/ 24bpp depth */
+ if ( mmesa->mach64Screen->cpp == 4 )
+ s |= MACH64_ROUND_EN;
+ else
+ s |= MACH64_DITHER_EN;
+ } else {
+ s &= ~MACH64_DITHER_EN;
+ s &= ~MACH64_ROUND_EN;
+ }
+
+ if ( mmesa->setup.scale_3d_cntl != s ) {
+ mmesa->setup.scale_3d_cntl = s;
+ mmesa->dirty |= ( MACH64_UPLOAD_SCALE_3D_CNTL );
+ }
+ } while (0);
+ break;
+
+ case GL_FOG:
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MACH64_NEW_FOG;
+ break;
+
+ case GL_INDEX_LOGIC_OP:
+ case GL_COLOR_LOGIC_OP:
+ FLUSH_BATCH( mmesa );
+ FALLBACK( mmesa, MACH64_FALLBACK_LOGICOP,
+ state && ctx->Color.LogicOp != GL_COPY );
+ break;
+
+ case GL_LIGHTING:
+ mach64UpdateSpecularLighting(ctx);
+ break;
+
+ case GL_SCISSOR_TEST:
+ FLUSH_BATCH( mmesa );
+ mmesa->scissor = state;
+ mmesa->new_state |= MACH64_NEW_CLIP;
+ break;
+
+ case GL_STENCIL_TEST:
+ FLUSH_BATCH( mmesa );
+ FALLBACK( mmesa, MACH64_FALLBACK_STENCIL, state );
+ break;
+
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MACH64_NEW_TEXTURE;
+ break;
+
+ default:
+ return;
+ }
+}
+
+/* =============================================================
+ * Render mode
+ */
+
+static void mach64DDRenderMode( GLcontext *ctx, GLenum mode )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ FALLBACK( mmesa, MACH64_FALLBACK_RENDER_MODE, (mode != GL_RENDER) );
+}
+
+/* =============================================================
+ * State initialization, management
+ */
+
+static void mach64DDPrintDirty( const char *msg, GLuint state )
+{
+ fprintf( stderr,
+ "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s\n",
+ msg,
+ state,
+ (state & MACH64_UPLOAD_DST_OFF_PITCH) ? "dst_off_pitch, " : "",
+ (state & MACH64_UPLOAD_Z_ALPHA_CNTL) ? "z_alpha_cntl, " : "",
+ (state & MACH64_UPLOAD_SCALE_3D_CNTL) ? "scale_3d_cntl, " : "",
+ (state & MACH64_UPLOAD_DP_FOG_CLR) ? "dp_fog_clr, " : "",
+ (state & MACH64_UPLOAD_DP_WRITE_MASK) ? "dp_write_mask, " : "",
+ (state & MACH64_UPLOAD_DP_PIX_WIDTH) ? "dp_pix_width, " : "",
+ (state & MACH64_UPLOAD_SETUP_CNTL) ? "setup_cntl, " : "",
+ (state & MACH64_UPLOAD_MISC) ? "misc, " : "",
+ (state & MACH64_UPLOAD_TEXTURE) ? "texture, " : "",
+ (state & MACH64_UPLOAD_TEX0IMAGE) ? "tex0 image, " : "",
+ (state & MACH64_UPLOAD_TEX1IMAGE) ? "tex1 image, " : "",
+ (state & MACH64_UPLOAD_CLIPRECTS) ? "cliprects, " : "" );
+}
+
+/*
+ * Load the current context's state into the hardware.
+ *
+ * NOTE: Be VERY careful about ensuring the context state is marked for
+ * upload, the only place it shouldn't be uploaded is when the setup
+ * state has changed in ReducedPrimitiveChange as this comes right after
+ * a state update.
+ *
+ * Blits of any type should always upload the context and masks after
+ * they are done.
+ */
+void mach64EmitHwStateLocked( mach64ContextPtr mmesa )
+{
+ drm_mach64_sarea_t *sarea = mmesa->sarea;
+ drm_mach64_context_regs_t *regs = &(mmesa->setup);
+ mach64TexObjPtr t0 = mmesa->CurrentTexObj[0];
+ mach64TexObjPtr t1 = mmesa->CurrentTexObj[1];
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_MSG ) {
+ mach64DDPrintDirty( __FUNCTION__, mmesa->dirty );
+ }
+
+ if ( t0 && t1 && mmesa->mach64Screen->numTexHeaps > 1 ) {
+ if (t0->heap != t1->heap ||
+ (mmesa->dirty & MACH64_UPLOAD_TEX0IMAGE) ||
+ (mmesa->dirty & MACH64_UPLOAD_TEX1IMAGE))
+ mach64UploadMultiTexImages( mmesa, t0, t1 );
+ } else {
+ if ( mmesa->dirty & MACH64_UPLOAD_TEX0IMAGE ) {
+ if ( t0 ) mach64UploadTexImages( mmesa, t0 );
+ }
+ if ( mmesa->dirty & MACH64_UPLOAD_TEX1IMAGE ) {
+ if ( t1 ) mach64UploadTexImages( mmesa, t1 );
+ }
+ }
+
+ if ( mmesa->dirty & (MACH64_UPLOAD_CONTEXT | MACH64_UPLOAD_MISC) ) {
+ memcpy( &sarea->context_state, regs,
+ MACH64_NR_CONTEXT_REGS * sizeof(GLuint) );
+ }
+
+ if ( mmesa->dirty & MACH64_UPLOAD_TEXTURE ) {
+ mach64EmitTexStateLocked( mmesa, t0, t1 );
+ }
+
+ sarea->vertsize = mmesa->vertex_size;
+
+ /* Turn off the texture cache flushing.
+ */
+ mmesa->setup.tex_cntl &= ~MACH64_TEX_CACHE_FLUSH;
+
+ sarea->dirty |= mmesa->dirty;
+
+ mmesa->dirty &= MACH64_UPLOAD_CLIPRECTS;
+}
+
+static void mach64DDPrintState( const char *msg, GLuint flags )
+{
+ fprintf( stderr,
+ "%s: (0x%x) %s%s%s%s%s%s%s%s%s\n",
+ msg,
+ flags,
+ (flags & MACH64_NEW_CONTEXT) ? "context, " : "",
+ (flags & MACH64_NEW_ALPHA) ? "alpha, " : "",
+ (flags & MACH64_NEW_DEPTH) ? "depth, " : "",
+ (flags & MACH64_NEW_FOG) ? "fog, " : "",
+ (flags & MACH64_NEW_CLIP) ? "clip, " : "",
+ (flags & MACH64_NEW_TEXTURE) ? "texture, " : "",
+ (flags & MACH64_NEW_CULL) ? "cull, " : "",
+ (flags & MACH64_NEW_MASKS) ? "masks, " : "",
+ (flags & MACH64_NEW_WINDOW) ? "window, " : "" );
+}
+
+/* Update the hardware state */
+void mach64DDUpdateHWState( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ int new_state = mmesa->new_state;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_MSG ) {
+ fprintf( stderr, "%s:\n", __FUNCTION__ );
+ }
+
+ if ( new_state )
+ {
+ FLUSH_BATCH( mmesa );
+
+ mmesa->new_state = 0;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_MSG )
+ mach64DDPrintState( __FUNCTION__, new_state );
+
+ /* Update the various parts of the context's state.
+ */
+ if ( new_state & MACH64_NEW_ALPHA )
+ mach64UpdateAlphaMode( ctx );
+
+ if ( new_state & MACH64_NEW_DEPTH )
+ mach64UpdateZMode( ctx );
+
+ if ( new_state & MACH64_NEW_FOG )
+ mach64UpdateFogAttrib( ctx );
+
+ if ( new_state & MACH64_NEW_CLIP )
+ mach64UpdateClipping( ctx );
+
+ if ( new_state & MACH64_NEW_WINDOW )
+ mach64CalcViewport( ctx );
+
+ if ( new_state & MACH64_NEW_CULL )
+ mach64UpdateCull( ctx );
+
+ if ( new_state & MACH64_NEW_MASKS )
+ mach64UpdateMasks( ctx );
+
+ if ( new_state & MACH64_NEW_TEXTURE )
+ mach64UpdateTextureState( ctx );
+ }
+}
+
+
+static void mach64DDInvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ MACH64_CONTEXT(ctx)->NewGLState |= new_state;
+}
+
+
+/* Initialize the context's hardware state */
+void mach64DDInitState( mach64ContextPtr mmesa )
+{
+ GLuint format;
+
+ switch ( mmesa->mach64Screen->cpp ) {
+ case 2:
+ format = MACH64_DATATYPE_RGB565;
+ break;
+ case 4:
+ format = MACH64_DATATYPE_ARGB8888;
+ break;
+ default:
+ fprintf( stderr, "Error: Unsupported pixel depth... exiting\n" );
+ exit( -1 );
+ }
+
+ /* Always have a 16-bit depth buffer
+ * but Z coordinates are specified in 16.1 format to the setup engine.
+ */
+ mmesa->depth_scale = 2.0;
+
+ mmesa->ClearColor = 0x00000000;
+ mmesa->ClearDepth = 0x0000ffff;
+
+ mmesa->Fallback = 0;
+
+ if ( mmesa->glCtx->Visual.doubleBufferMode ) {
+ mmesa->drawOffset = mmesa->readOffset = mmesa->mach64Screen->backOffset;
+ mmesa->drawPitch = mmesa->readPitch = mmesa->mach64Screen->backPitch;
+ } else {
+ mmesa->drawOffset = mmesa->readOffset = mmesa->mach64Screen->frontOffset;
+ mmesa->drawPitch = mmesa->readPitch = mmesa->mach64Screen->frontPitch;
+ }
+
+ /* Harware state:
+ */
+ mmesa->setup.dst_off_pitch = (((mmesa->drawPitch/8) << 22) |
+ (mmesa->drawOffset >> 3));
+
+ mmesa->setup.z_off_pitch = (((mmesa->mach64Screen->depthPitch/8) << 22) |
+ (mmesa->mach64Screen->depthOffset >> 3));
+
+ mmesa->setup.z_cntl = (MACH64_Z_TEST_LESS |
+ MACH64_Z_MASK_EN);
+
+ mmesa->setup.alpha_tst_cntl = (MACH64_ALPHA_TEST_ALWAYS |
+ MACH64_ALPHA_DST_SRCALPHA |
+ MACH64_ALPHA_TST_SRC_TEXEL |
+ (0 << MACH64_REF_ALPHA_SHIFT));
+
+ mmesa->setup.scale_3d_cntl = (MACH64_SCALE_PIX_EXPAND_DYNAMIC_RANGE |
+ /* MACH64_SCALE_DITHER_ERROR_DIFFUSE | */
+ MACH64_SCALE_DITHER_2D_TABLE |
+ /* MACH64_DITHER_INIT_CURRENT | */
+ MACH64_DITHER_INIT_RESET |
+ MACH64_SCALE_3D_FCN_SHADE |
+ MACH64_ALPHA_FOG_DIS |
+ MACH64_ALPHA_BLEND_SRC_ONE |
+ MACH64_ALPHA_BLEND_DST_ZERO |
+ MACH64_TEX_LIGHT_FCN_MODULATE |
+ MACH64_MIP_MAP_DISABLE |
+ MACH64_BILINEAR_TEX_EN |
+ MACH64_TEX_BLEND_FCN_LINEAR);
+
+ /* GL spec says dithering initially enabled, but dithering causes
+ * problems w/ 24bpp depth
+ */
+ if ( mmesa->mach64Screen->cpp == 4 )
+ mmesa->setup.scale_3d_cntl |= MACH64_ROUND_EN;
+ else
+ mmesa->setup.scale_3d_cntl |= MACH64_DITHER_EN;
+
+ mmesa->setup.sc_left_right = 0x1fff0000;
+ mmesa->setup.sc_top_bottom = 0x3fff0000;
+
+ mmesa->setup.dp_fog_clr = 0x00ffffff;
+ mmesa->setup.dp_write_mask = 0xffffffff;
+
+ mmesa->setup.dp_pix_width = ((format << 0) |
+ (format << 4) |
+ (format << 8) |
+ (format << 16) |
+ (format << 28));
+
+ mmesa->setup.dp_mix = (MACH64_BKGD_MIX_S |
+ MACH64_FRGD_MIX_S);
+ mmesa->setup.dp_src = (MACH64_BKGD_SRC_3D |
+ MACH64_FRGD_SRC_3D |
+ MACH64_MONO_SRC_ONE);
+
+ mmesa->setup.clr_cmp_cntl = 0x00000000;
+ mmesa->setup.gui_traj_cntl = (MACH64_DST_X_LEFT_TO_RIGHT |
+ MACH64_DST_Y_TOP_TO_BOTTOM);
+
+ mmesa->setup.setup_cntl = (MACH64_FLAT_SHADE_OFF |
+ MACH64_SOLID_MODE_OFF |
+ MACH64_LOG_MAX_INC_ADJ);
+ mmesa->setup.setup_cntl = 0;
+
+ mmesa->setup.tex_size_pitch = 0x00000000;
+
+ mmesa->setup.tex_cntl = ((0 << MACH64_LOD_BIAS_SHIFT) |
+ (0 << MACH64_COMP_FACTOR_SHIFT) |
+ MACH64_COMP_COMBINE_MODULATE |
+ MACH64_COMP_BLEND_NEAREST |
+ MACH64_COMP_FILTER_NEAREST |
+ /* MACH64_TEXTURE_TILING | */
+#ifdef MACH64_PREMULT_TEXCOORDS
+ MACH64_TEX_ST_DIRECT |
+#endif
+ MACH64_TEX_SRC_LOCAL |
+ MACH64_TEX_UNCOMPRESSED |
+ MACH64_TEX_CACHE_FLUSH |
+ MACH64_TEX_CACHE_SIZE_4K);
+
+ mmesa->setup.secondary_tex_off = 0x00000000;
+ mmesa->setup.tex_offset = 0x00000000;
+
+ mmesa->new_state = MACH64_NEW_ALL;
+}
+
+/* Initialize the driver's state functions.
+ */
+void mach64DDInitStateFuncs( GLcontext *ctx )
+{
+ ctx->Driver.UpdateState = mach64DDInvalidateState;
+
+ ctx->Driver.ClearIndex = NULL;
+ ctx->Driver.ClearColor = mach64DDClearColor;
+ ctx->Driver.DrawBuffer = mach64DDDrawBuffer;
+ ctx->Driver.ReadBuffer = mach64DDReadBuffer;
+
+ ctx->Driver.IndexMask = NULL;
+ ctx->Driver.ColorMask = mach64DDColorMask;
+ ctx->Driver.AlphaFunc = mach64DDAlphaFunc;
+ ctx->Driver.BlendEquationSeparate = mach64DDBlendEquationSeparate;
+ ctx->Driver.BlendFuncSeparate = mach64DDBlendFuncSeparate;
+ ctx->Driver.ClearDepth = mach64DDClearDepth;
+ ctx->Driver.CullFace = mach64DDCullFace;
+ ctx->Driver.FrontFace = mach64DDFrontFace;
+ ctx->Driver.DepthFunc = mach64DDDepthFunc;
+ ctx->Driver.DepthMask = mach64DDDepthMask;
+ ctx->Driver.Enable = mach64DDEnable;
+ ctx->Driver.Fogfv = mach64DDFogfv;
+ ctx->Driver.Hint = NULL;
+ ctx->Driver.Lightfv = NULL;
+ ctx->Driver.LightModelfv = mach64DDLightModelfv;
+ ctx->Driver.LogicOpcode = mach64DDLogicOpCode;
+ ctx->Driver.PolygonMode = NULL;
+ ctx->Driver.PolygonStipple = NULL;
+ ctx->Driver.RenderMode = mach64DDRenderMode;
+ ctx->Driver.Scissor = mach64DDScissor;
+ ctx->Driver.ShadeModel = mach64DDShadeModel;
+ ctx->Driver.ClearStencil = NULL;
+ ctx->Driver.StencilFunc = NULL;
+ ctx->Driver.StencilMask = NULL;
+ ctx->Driver.StencilOp = NULL;
+
+ ctx->Driver.DepthRange = mach64DepthRange;
+ ctx->Driver.Viewport = mach64Viewport;
+
+ /* Pixel path fallbacks.
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_state.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_state.h
new file mode 100644
index 000000000..95bcab365
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_state.h
@@ -0,0 +1,47 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ */
+
+#ifndef __MACH64_STATE_H__
+#define __MACH64_STATE_H__
+
+#include "mach64_context.h"
+
+extern void mach64DDInitState( mach64ContextPtr mmesa );
+extern void mach64DDInitStateFuncs( GLcontext *ctx );
+
+extern void mach64SetCliprects( GLcontext *ctx, GLenum mode );
+extern void mach64CalcViewport( GLcontext *ctx );
+
+extern void mach64DDUpdateState( GLcontext *ctx );
+extern void mach64DDUpdateHWState( GLcontext *ctx );
+
+extern void mach64EmitHwStateLocked( mach64ContextPtr mmesa );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_tex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_tex.c
new file mode 100644
index 000000000..6459deef7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_tex.c
@@ -0,0 +1,610 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#include "mach64_context.h"
+#include "mach64_ioctl.h"
+#include "mach64_state.h"
+#include "mach64_vb.h"
+#include "mach64_tris.h"
+#include "mach64_tex.h"
+
+#include "context.h"
+#include "macros.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "texstore.h"
+#include "texformat.h"
+#include "teximage.h"
+#include "texobj.h"
+#include "imports.h"
+
+
+static void mach64SetTexWrap( mach64TexObjPtr t,
+ GLenum swrap, GLenum twrap )
+{
+ switch ( swrap ) {
+ case GL_CLAMP:
+ case GL_CLAMP_TO_EDGE:
+ case GL_CLAMP_TO_BORDER:
+ t->ClampS = GL_TRUE;
+ break;
+ case GL_REPEAT:
+ t->ClampS = GL_FALSE;
+ break;
+ }
+
+ switch ( twrap ) {
+ case GL_CLAMP:
+ case GL_CLAMP_TO_EDGE:
+ case GL_CLAMP_TO_BORDER:
+ t->ClampT = GL_TRUE;
+ break;
+ case GL_REPEAT:
+ t->ClampT = GL_FALSE;
+ break;
+ }
+}
+
+static void mach64SetTexFilter( mach64TexObjPtr t,
+ GLenum minf, GLenum magf )
+{
+ switch ( minf ) {
+ case GL_NEAREST:
+ case GL_NEAREST_MIPMAP_NEAREST:
+ case GL_NEAREST_MIPMAP_LINEAR:
+ t->BilinearMin = GL_FALSE;
+ break;
+ case GL_LINEAR:
+ case GL_LINEAR_MIPMAP_NEAREST:
+ case GL_LINEAR_MIPMAP_LINEAR:
+ t->BilinearMin = GL_TRUE;
+ break;
+ }
+
+ switch ( magf ) {
+ case GL_NEAREST:
+ t->BilinearMag = GL_FALSE;
+ break;
+ case GL_LINEAR:
+ t->BilinearMag = GL_TRUE;
+ break;
+ }
+}
+
+static void mach64SetTexBorderColor( mach64TexObjPtr t, GLubyte c[4] )
+{
+#if 0
+ GLuint border = mach64PackColor( 4, c[0], c[1], c[2], c[3] );
+#endif
+}
+
+
+static mach64TexObjPtr
+mach64AllocTexObj( struct gl_texture_object *texObj )
+{
+ mach64TexObjPtr t;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_API )
+ fprintf( stderr, "%s( %p )\n", __FUNCTION__, texObj );
+
+ t = (mach64TexObjPtr) CALLOC_STRUCT( mach64_texture_object );
+ if ( !t )
+ return NULL;
+
+ /* Initialize non-image-dependent parts of the state:
+ */
+ t->tObj = texObj;
+
+ t->offset = 0;
+
+ t->dirty = 1;
+
+ make_empty_list( t );
+
+ mach64SetTexWrap( t, texObj->WrapS, texObj->WrapT );
+ /*mach64SetTexMaxAnisotropy( t, texObj->MaxAnisotropy );*/
+ mach64SetTexFilter( t, texObj->MinFilter, texObj->MagFilter );
+ mach64SetTexBorderColor( t, texObj->_BorderChan );
+
+ return t;
+}
+
+
+/* Called by the _mesa_store_teximage[123]d() functions. */
+static const struct gl_texture_format *
+mach64ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ (void) format;
+ (void) type;
+
+ switch ( internalFormat ) {
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ 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 4:
+ case GL_RGBA:
+ case GL_RGBA2:
+ if (mmesa->mach64Screen->cpp == 4)
+ return &_mesa_texformat_argb8888;
+ else
+ return &_mesa_texformat_argb4444;
+
+ case GL_RGB5_A1:
+ if (mmesa->mach64Screen->cpp == 4)
+ return &_mesa_texformat_argb8888;
+ else
+ return &_mesa_texformat_argb1555;
+
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ case GL_RGBA4:
+ if (mmesa->mach64Screen->cpp == 4)
+ return &_mesa_texformat_argb8888;
+ else
+ return &_mesa_texformat_argb4444;
+
+ 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 (mmesa->mach64Screen->cpp == 4)
+ return &_mesa_texformat_argb8888;
+ else
+ return &_mesa_texformat_rgb565;
+
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ if (mmesa->mach64Screen->cpp == 4)
+ return &_mesa_texformat_argb8888; /* inefficient but accurate */
+ else
+ return &_mesa_texformat_argb1555;
+
+ case GL_INTENSITY4:
+ case GL_INTENSITY:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ if (mmesa->mach64Screen->cpp == 4)
+ return &_mesa_texformat_argb8888; /* inefficient but accurate */
+ else
+ return &_mesa_texformat_argb4444;
+
+ 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:
+ return &_mesa_texformat_ci8;
+
+ case GL_YCBCR_MESA:
+ if (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
+ type == GL_UNSIGNED_BYTE)
+ return &_mesa_texformat_ycbcr;
+ else
+ return &_mesa_texformat_ycbcr_rev;
+
+ default:
+ _mesa_problem( ctx, "unexpected format in %s", __FUNCTION__ );
+ return NULL;
+ }
+}
+
+static void mach64TexImage1D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ mach64TexObjPtr t = (mach64TexObjPtr) texObj->DriverData;
+
+ if ( t ) {
+ mach64SwapOutTexObj( mmesa, t );
+ }
+ else {
+ t = mach64AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
+ return;
+ }
+ texObj->DriverData = t;
+ }
+
+ /* Note, this will call mach64ChooseTextureFormat */
+ _mesa_store_teximage1d( ctx, target, level, internalFormat,
+ width, border, format, type,
+ pixels, packing, texObj, texImage );
+
+ mmesa->new_state |= MACH64_NEW_TEXTURE;
+}
+
+static void mach64TexSubImage1D( 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 )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ mach64TexObjPtr t = (mach64TexObjPtr) texObj->DriverData;
+
+ assert( t ); /* this _should_ be true */
+ if ( t ) {
+ mach64SwapOutTexObj( mmesa, t );
+ }
+ else {
+ t = mach64AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
+ return;
+ }
+ texObj->DriverData = t;
+ }
+
+ _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
+ format, type, pixels, packing, texObj,
+ texImage);
+
+ mmesa->new_state |= MACH64_NEW_TEXTURE;
+}
+
+static void mach64TexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ mach64TexObjPtr t = (mach64TexObjPtr) texObj->DriverData;
+
+ if ( t ) {
+ mach64SwapOutTexObj( mmesa, t );
+ }
+ else {
+ t = mach64AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ texObj->DriverData = t;
+ }
+
+ /* Note, this will call mach64ChooseTextureFormat */
+ _mesa_store_teximage2d( ctx, target, level, internalFormat,
+ width, height, border, format, type, pixels,
+ &ctx->Unpack, texObj, texImage );
+
+ mmesa->new_state |= MACH64_NEW_TEXTURE;
+}
+
+static void mach64TexSubImage2D( 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 )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ mach64TexObjPtr t = (mach64TexObjPtr) texObj->DriverData;
+
+ assert( t ); /* this _should_ be true */
+ if ( t ) {
+ mach64SwapOutTexObj( mmesa, t );
+ }
+ else {
+ t = mach64AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
+ return;
+ }
+ texObj->DriverData = t;
+ }
+
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
+
+ mmesa->new_state |= MACH64_NEW_TEXTURE;
+}
+
+/* Due to the way we must program texture state into the Rage Pro,
+ * we must leave these calculations to the absolute last minute.
+ */
+void mach64EmitTexStateLocked( mach64ContextPtr mmesa,
+ mach64TexObjPtr t0,
+ mach64TexObjPtr t1 )
+{
+ drm_mach64_sarea_t *sarea = mmesa->sarea;
+ drm_mach64_context_regs_t *regs = &(mmesa->setup);
+
+ /* for multitex, both textures must be local or AGP */
+ if ( t0 && t1 )
+ assert(t0->heap == t1->heap);
+
+ if ( t0 ) {
+ if (t0->heap == MACH64_CARD_HEAP) {
+#if ENABLE_PERF_BOXES
+ mmesa->c_texsrc_card++;
+#endif
+ mmesa->setup.tex_cntl &= ~MACH64_TEX_SRC_AGP;
+ } else {
+#if ENABLE_PERF_BOXES
+ mmesa->c_texsrc_agp++;
+#endif
+ mmesa->setup.tex_cntl |= MACH64_TEX_SRC_AGP;
+ }
+ mmesa->setup.tex_offset = t0->offset;
+ }
+
+ if ( t1 ) {
+ mmesa->setup.secondary_tex_off = t1->offset;
+ }
+
+ memcpy( &sarea->context_state.tex_size_pitch, &regs->tex_size_pitch,
+ MACH64_NR_TEXTURE_REGS * sizeof(GLuint) );
+}
+
+
+/* ================================================================
+ * Device Driver API texture functions
+ */
+
+static void mach64DDTexEnv( GLcontext *ctx, GLenum target,
+ GLenum pname, const GLfloat *param )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+#if 0
+ struct gl_texture_unit *texUnit;
+ GLubyte c[4];
+#endif
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %s )\n",
+ __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) );
+ }
+
+ switch ( pname ) {
+ case GL_TEXTURE_ENV_MODE:
+ FLUSH_BATCH( mmesa );
+ mmesa->new_state |= MACH64_NEW_TEXTURE | MACH64_NEW_ALPHA;
+ break;
+
+#if 0
+ case GL_TEXTURE_ENV_COLOR:
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ CLAMPED_FLOAT_TO_UBYTE( c[0], texUnit->EnvColor[0] );
+ CLAMPED_FLOAT_TO_UBYTE( c[1], texUnit->EnvColor[1] );
+ CLAMPED_FLOAT_TO_UBYTE( c[2], texUnit->EnvColor[2] );
+ CLAMPED_FLOAT_TO_UBYTE( c[3], texUnit->EnvColor[3] );
+ mmesa->env_color = mach64PackColor( 32, c[0], c[1], c[2], c[3] );
+ if ( mmesa->setup.constant_color_c != mmesa->env_color ) {
+ FLUSH_BATCH( mmesa );
+ mmesa->setup.constant_color_c = mmesa->env_color;
+
+ mmesa->new_state |= MACH64_NEW_TEXTURE;
+
+ /* More complex multitexture/multipass fallbacks for GL_BLEND
+ * can be done later, but this allows a single pass GL_BLEND
+ * in some cases (ie. Performer town demo).
+ */
+ mmesa->blend_flags &= ~MACH64_BLEND_ENV_COLOR;
+ if ( mmesa->env_color != 0x00000000 &&
+ mmesa->env_color != 0xff000000 &&
+ mmesa->env_color != 0x00ffffff &&
+ mmesa->env_color != 0xffffffff )) {
+ mmesa->blend_flags |= MACH64_BLEND_ENV_COLOR;
+ }
+ }
+ break;
+#endif
+
+ default:
+ return;
+ }
+}
+
+static void mach64DDTexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat *params )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ mach64TexObjPtr t = (mach64TexObjPtr)tObj->DriverData;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %s )\n",
+ __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) );
+ }
+
+ if ( ( target != GL_TEXTURE_2D ) &&
+ ( target != GL_TEXTURE_1D ) ) {
+ return;
+ }
+
+ if (!t) {
+ t = mach64AllocTexObj(tObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexParameter");
+ return;
+ }
+ tObj->DriverData = t;
+ }
+
+ switch ( pname ) {
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ if ( t->bound ) FLUSH_BATCH( mmesa );
+ mach64SetTexFilter( t, tObj->MinFilter, tObj->MagFilter );
+ break;
+
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ if ( t->bound ) FLUSH_BATCH( mmesa );
+ mach64SetTexWrap( t, tObj->WrapS, tObj->WrapT );
+ break;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ if ( t->bound ) FLUSH_BATCH( mmesa );
+ mach64SetTexBorderColor( t, tObj->_BorderChan );
+ break;
+
+ case GL_TEXTURE_BASE_LEVEL:
+ /* From Radeon/Rage128:
+ * This isn't the most efficient solution but there doesn't appear to
+ * be a nice alternative. Since there's no LOD clamping,
+ * we just have to rely on loading the right subset of mipmap levels
+ * to simulate a clamped LOD.
+ *
+ * For mach64 we're only concerned with the base level
+ * since that's the only texture we upload.
+ */
+ if ( t->bound ) FLUSH_BATCH( mmesa );
+ mach64SwapOutTexObj( mmesa, t );
+ break;
+
+ default:
+ return;
+ }
+
+ mmesa->new_state |= MACH64_NEW_TEXTURE;
+}
+
+static void mach64DDBindTexture( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ GLint unit = ctx->Texture.CurrentUnit;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %p ) unit=%d\n",
+ __FUNCTION__, tObj, unit );
+ }
+
+ FLUSH_BATCH( mmesa );
+
+ if ( mmesa->CurrentTexObj[unit] ) {
+ mmesa->CurrentTexObj[unit]->bound &= ~(unit+1);
+ mmesa->CurrentTexObj[unit] = NULL;
+ }
+
+ mmesa->new_state |= MACH64_NEW_TEXTURE;
+}
+
+static void mach64DDDeleteTexture( GLcontext *ctx,
+ struct gl_texture_object *tObj )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ mach64TexObjPtr t = (mach64TexObjPtr)tObj->DriverData;
+
+ if ( t ) {
+ if ( t->bound && mmesa ) {
+ FLUSH_BATCH( mmesa );
+
+ mmesa->CurrentTexObj[t->bound-1] = 0;
+ mmesa->new_state |= MACH64_NEW_TEXTURE;
+ }
+
+ mach64DestroyTexObj( mmesa, t );
+ tObj->DriverData = NULL;
+ /* Free mipmap images and the texture object itself */
+ _mesa_delete_texture_object(ctx, tObj);
+
+ }
+}
+
+static GLboolean mach64DDIsTextureResident( GLcontext *ctx,
+ struct gl_texture_object *tObj )
+{
+ mach64TexObjPtr t = (mach64TexObjPtr)tObj->DriverData;
+
+ return ( t && t->memBlock );
+}
+
+
+void mach64InitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->TexEnv = mach64DDTexEnv;
+ functions->ChooseTextureFormat = mach64ChooseTextureFormat;
+ functions->TexImage1D = mach64TexImage1D;
+ functions->TexSubImage1D = mach64TexSubImage1D;
+ functions->TexImage2D = mach64TexImage2D;
+ functions->TexSubImage2D = mach64TexSubImage2D;
+ functions->TexImage3D = _mesa_store_teximage3d;
+ functions->TexSubImage3D = _mesa_store_texsubimage3d;
+ functions->CopyTexImage1D = _swrast_copy_teximage1d;
+ functions->CopyTexImage2D = _swrast_copy_teximage2d;
+ functions->CopyTexSubImage1D = _swrast_copy_texsubimage1d;
+ functions->CopyTexSubImage2D = _swrast_copy_texsubimage2d;
+ functions->CopyTexSubImage3D = _swrast_copy_texsubimage3d;
+ functions->TexParameter = mach64DDTexParameter;
+ functions->BindTexture = mach64DDBindTexture;
+ functions->DeleteTexture = mach64DDDeleteTexture;
+ functions->UpdateTexturePalette = NULL;
+ functions->ActiveTexture = NULL;
+ functions->IsTextureResident = mach64DDIsTextureResident;
+ functions->PrioritizeTexture = NULL;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_tex.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_tex.h
new file mode 100644
index 000000000..d950dd12b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_tex.h
@@ -0,0 +1,99 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#ifndef __MACH64_TEX_H__
+#define __MACH64_TEX_H__
+
+extern void mach64UpdateTextureState( GLcontext *ctx );
+
+extern void mach64SwapOutTexObj( mach64ContextPtr mach64ctx,
+ mach64TexObjPtr t );
+
+extern void mach64UploadTexImages( mach64ContextPtr mach64ctx,
+ mach64TexObjPtr t );
+
+extern void mach64UploadMultiTexImages( mach64ContextPtr mach64ctx,
+ mach64TexObjPtr t0, mach64TexObjPtr t1 );
+
+extern void mach64AgeTextures( mach64ContextPtr mach64ctx, int heap );
+extern void mach64DestroyTexObj( mach64ContextPtr mach64ctx,
+ mach64TexObjPtr t );
+
+extern void mach64UpdateTexLRU( mach64ContextPtr mach64ctx,
+ mach64TexObjPtr t );
+
+extern void mach64PrintLocalLRU( mach64ContextPtr mach64ctx, int heap );
+extern void mach64PrintGlobalLRU( mach64ContextPtr mach64ctx, int heap );
+
+extern void mach64EmitTexStateLocked( mach64ContextPtr mmesa,
+ mach64TexObjPtr t0,
+ mach64TexObjPtr t1 );
+
+extern void mach64InitTextureFuncs( struct dd_function_table *functions );
+
+/* ================================================================
+ * Color conversion macros:
+ */
+
+#define MACH64PACKCOLOR332(r, g, b) \
+ (((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))
+
+#define MACH64PACKCOLOR1555(r, g, b, a) \
+ ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
+ ((a) ? 0x8000 : 0))
+
+#define MACH64PACKCOLOR565(r, g, b) \
+ ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
+
+#define MACH64PACKCOLOR888(r, g, b) \
+ (((r) << 16) | ((g) << 8) | (b))
+
+#define MACH64PACKCOLOR8888(r, g, b, a) \
+ (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
+
+#define MACH64PACKCOLOR4444(r, g, b, a) \
+ ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
+
+static __inline__ GLuint mach64PackColor( GLuint cpp,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a )
+{
+ switch ( cpp ) {
+ case 2:
+ return MACH64PACKCOLOR565( r, g, b );
+ case 4:
+ return MACH64PACKCOLOR8888( r, g, b, a );
+ default:
+ return 0;
+ }
+}
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_texmem.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_texmem.c
new file mode 100644
index 000000000..f771818c8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_texmem.c
@@ -0,0 +1,867 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * Jose Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#include "mach64_context.h"
+#include "mach64_state.h"
+#include "mach64_ioctl.h"
+#include "mach64_vb.h"
+#include "mach64_tris.h"
+#include "mach64_tex.h"
+
+#include "context.h"
+#include "macros.h"
+#include "simple_list.h"
+#include "texformat.h"
+#include "imports.h"
+
+
+/* Destroy hardware state associated with texture `t'.
+ */
+void mach64DestroyTexObj( mach64ContextPtr mmesa, mach64TexObjPtr t )
+{
+#if ENABLE_PERF_BOXES
+ /* Bump the performace counter */
+ if (mmesa)
+ mmesa->c_textureSwaps++;
+#endif
+ if ( !t ) return;
+
+#if 0
+ if ( t->tObj && t->memBlock && mmesa ) {
+ /* not a placeholder, so release from global LRU if necessary */
+ int heap = t->heap;
+ drmTextureRegion *list = mmesa->sarea->tex_list[heap];
+ int log2sz = mmesa->mach64Screen->logTexGranularity[heap];
+ int start = t->memBlock->ofs >> log2sz;
+ int end = (t->memBlock->ofs + t->memBlock->size - 1) >> log2sz;
+ int i;
+
+ mmesa->lastTexAge[heap] = ++mmesa->sarea->tex_age[heap];
+
+ /* Update the global LRU */
+ for ( i = start ; i <= end ; i++ ) {
+ /* do we own this block? */
+ if (list[i].in_use == mmesa->hHWContext) {
+ list[i].in_use = 0;
+ list[i].age = mmesa->lastTexAge[heap];
+
+ /* remove_from_list(i) */
+ list[(GLuint)list[i].next].prev = list[i].prev;
+ list[(GLuint)list[i].prev].next = list[i].next;
+ }
+ }
+ }
+#endif
+
+ if ( t->memBlock ) {
+ mmFreeMem( t->memBlock );
+ t->memBlock = NULL;
+ }
+
+ if ( t->tObj ) {
+ t->tObj->DriverData = NULL;
+ }
+
+ if ( t->bound && mmesa )
+ mmesa->CurrentTexObj[t->bound-1] = NULL;
+
+ remove_from_list( t );
+ FREE( t );
+}
+
+/* Keep track of swapped out texture objects.
+ */
+void mach64SwapOutTexObj( mach64ContextPtr mmesa,
+ mach64TexObjPtr t )
+{
+#if ENABLE_PERF_BOXES
+ /* Bump the performace counter */
+ if (mmesa)
+ mmesa->c_textureSwaps++;
+#endif
+
+#if 0
+ if ( t->tObj && t->memBlock && mmesa ) {
+ /* not a placeholder, so release from global LRU if necessary */
+ int heap = t->heap;
+ drmTextureRegion *list = mmesa->sarea->tex_list[heap];
+ int log2sz = mmesa->mach64Screen->logTexGranularity[heap];
+ int start = t->memBlock->ofs >> log2sz;
+ int end = (t->memBlock->ofs + t->memBlock->size - 1) >> log2sz;
+ int i;
+
+ mmesa->lastTexAge[heap] = ++mmesa->sarea->tex_age[heap];
+
+ /* Update the global LRU */
+ for ( i = start ; i <= end ; i++ ) {
+ /* do we own this block? */
+ if (list[i].in_use == mmesa->hHWContext) {
+ list[i].in_use = 0;
+ list[i].age = mmesa->lastTexAge[heap];
+
+ /* remove_from_list(i) */
+ list[(GLuint)list[i].next].prev = list[i].prev;
+ list[(GLuint)list[i].prev].next = list[i].next;
+ }
+ }
+ }
+#endif
+
+ if ( t->memBlock ) {
+ mmFreeMem( t->memBlock );
+ t->memBlock = NULL;
+ }
+
+ t->dirty = ~0;
+ move_to_tail( &mmesa->SwappedOut, t );
+}
+
+/* Print out debugging information about texture LRU.
+ */
+void mach64PrintLocalLRU( mach64ContextPtr mmesa, int heap )
+{
+ mach64TexObjPtr t;
+ int sz = 1 << (mmesa->mach64Screen->logTexGranularity[heap]);
+
+ fprintf( stderr, "\nLocal LRU, heap %d:\n", heap );
+
+ foreach( t, &mmesa->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 );
+ }
+ }
+
+ fprintf( stderr, "\n" );
+}
+
+void mach64PrintGlobalLRU( mach64ContextPtr mmesa, int heap )
+{
+ drm_tex_region_t *list = mmesa->sarea->tex_list[heap];
+ int i, j;
+
+ fprintf( stderr, "\nGlobal LRU, heap %d list %p:\n", heap, list );
+
+ for ( i = 0, j = MACH64_NR_TEX_REGIONS ; i < MACH64_NR_TEX_REGIONS ; i++ ) {
+ fprintf( stderr, "list[%d] age %d in_use %d next %d prev %d\n",
+ j, list[j].age, list[j].in_use, list[j].next, list[j].prev );
+ j = list[j].next;
+ if ( j == MACH64_NR_TEX_REGIONS ) break;
+ }
+
+ if ( j != MACH64_NR_TEX_REGIONS ) {
+ fprintf( stderr, "Loop detected in global LRU\n" );
+ for ( i = 0 ; i < MACH64_NR_TEX_REGIONS ; i++ ) {
+ fprintf( stderr, "list[%d] age %d in_use %d next %d prev %d\n",
+ i, list[i].age, list[i].in_use, list[i].next, list[i].prev );
+ }
+ }
+
+ fprintf( stderr, "\n" );
+}
+
+/* Reset the global texture LRU.
+ */
+/* NOTE: This function is only called while holding the hardware lock */
+static void mach64ResetGlobalLRU( mach64ContextPtr mmesa, int heap )
+{
+ drm_tex_region_t *list = mmesa->sarea->tex_list[heap];
+ int sz = 1 << mmesa->mach64Screen->logTexGranularity[heap];
+ int i;
+
+ /* (Re)initialize the global circular LRU list. The last element in
+ * the array (MACH64_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) * sz <= mmesa->mach64Screen->texSize[heap] ; i++ ) {
+ list[i].prev = i-1;
+ list[i].next = i+1;
+ list[i].age = 0;
+ list[i].in_use = 0;
+ }
+
+ i--;
+ list[0].prev = MACH64_NR_TEX_REGIONS;
+ list[i].prev = i-1;
+ list[i].next = MACH64_NR_TEX_REGIONS;
+ list[MACH64_NR_TEX_REGIONS].prev = i;
+ list[MACH64_NR_TEX_REGIONS].next = 0;
+ mmesa->sarea->tex_age[heap] = 0;
+}
+
+/* Update the local and global texture LRUs.
+ */
+/* NOTE: This function is only called while holding the hardware lock */
+void mach64UpdateTexLRU( mach64ContextPtr mmesa,
+ mach64TexObjPtr t )
+{
+ int heap = t->heap;
+ drm_tex_region_t *list = mmesa->sarea->tex_list[heap];
+ int log2sz = mmesa->mach64Screen->logTexGranularity[heap];
+ int start = t->memBlock->ofs >> log2sz;
+ int end = (t->memBlock->ofs + t->memBlock->size - 1) >> log2sz;
+ int i;
+
+ mmesa->lastTexAge[heap] = ++mmesa->sarea->tex_age[heap];
+
+ if ( !t->memBlock ) {
+ fprintf( stderr, "no memblock\n\n" );
+ return;
+ }
+
+ /* Update our local LRU */
+ move_to_head( &mmesa->TexObjList[heap], t );
+
+ /* Update the global LRU */
+ for ( i = start ; i <= end ; i++ ) {
+ list[i].in_use = mmesa->hHWContext;
+ list[i].age = mmesa->lastTexAge[heap];
+
+#if 0
+ /* if this is the last region, it's not in the list */
+ if ( !(i*(1<<log2sz) > mmesa->mach64Screen->texSize[heap] ) ) {
+#endif
+ /* remove_from_list(i) */
+ list[(GLuint)list[i].next].prev = list[i].prev;
+ list[(GLuint)list[i].prev].next = list[i].next;
+#if 0
+ }
+#endif
+
+ /* insert_at_head(list, i) */
+ list[i].prev = MACH64_NR_TEX_REGIONS;
+ list[i].next = list[MACH64_NR_TEX_REGIONS].next;
+ list[(GLuint)list[MACH64_NR_TEX_REGIONS].next].prev = i;
+ list[MACH64_NR_TEX_REGIONS].next = i;
+ }
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_LRU ) {
+ mach64PrintGlobalLRU( mmesa, t->heap );
+ mach64PrintLocalLRU( mmesa, t->heap );
+ }
+}
+
+/* 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 mach64TexturesGone( mach64ContextPtr mmesa, int heap,
+ int offset, int size, int in_use )
+{
+ mach64TexObjPtr t, tmp;
+
+ foreach_s ( t, tmp, &mmesa->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 ) {
+ mach64SwapOutTexObj( mmesa, t );
+ } else {
+ mach64DestroyTexObj( mmesa, t );
+ }
+ }
+
+ if ( in_use > 0 && in_use != mmesa->hHWContext ) {
+ t = (mach64TexObjPtr) CALLOC( sizeof(*t) );
+ if (!t) return;
+
+ t->memBlock = mmAllocMem( mmesa->texHeap[heap], size, 0, offset );
+ if ( !t->memBlock ) {
+ fprintf( stderr, "Couldn't alloc placeholder sz %x ofs %x\n",
+ (int)size, (int)offset );
+ mmDumpMemInfo( mmesa->texHeap[heap] );
+ return;
+ }
+ insert_at_head( &mmesa->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 mach64AgeTextures( mach64ContextPtr mmesa, int heap )
+{
+ drm_mach64_sarea_t *sarea = mmesa->sarea;
+
+ if ( sarea->tex_age[heap] != mmesa->lastTexAge[heap] ) {
+ int sz = 1 << mmesa->mach64Screen->logTexGranularity[heap];
+ int nr = 0;
+ int idx;
+
+ /* Have to go right round from the back to ensure stuff ends up
+ * LRU in our local list... Fix with a cursor pointer.
+ */
+ for ( idx = sarea->tex_list[heap][MACH64_NR_TEX_REGIONS].prev ;
+ idx != MACH64_NR_TEX_REGIONS && nr < MACH64_NR_TEX_REGIONS ;
+ idx = sarea->tex_list[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 * sz > mmesa->mach64Screen->texSize[heap] ) {
+ nr = MACH64_NR_TEX_REGIONS;
+ break;
+ }
+
+ if ( sarea->tex_list[heap][idx].age > mmesa->lastTexAge[heap] ) {
+ mach64TexturesGone( mmesa, heap, idx * sz, sz,
+ sarea->tex_list[heap][idx].in_use );
+ }
+ }
+
+ /* If switching texturing schemes, then the SAREA might not
+ * have been properly cleared, so we need to reset the
+ * global texture LRU.
+ */
+ if ( nr == MACH64_NR_TEX_REGIONS ) {
+ mach64TexturesGone( mmesa, heap, 0,
+ mmesa->mach64Screen->texSize[heap], 0 );
+ mach64ResetGlobalLRU( mmesa, heap );
+ }
+
+ if ( 0 ) {
+ mach64PrintGlobalLRU( mmesa, heap );
+ mach64PrintLocalLRU( mmesa, heap );
+ }
+
+ mmesa->dirty |= (MACH64_UPLOAD_CONTEXT |
+ MACH64_UPLOAD_TEX0IMAGE |
+ MACH64_UPLOAD_TEX1IMAGE);
+ mmesa->lastTexAge[heap] = sarea->tex_age[heap];
+ }
+}
+
+/* Upload the texture image associated with texture `t' at level `level'
+ * at the address relative to `start'.
+ */
+static void mach64UploadAGPSubImage( mach64ContextPtr mmesa,
+ mach64TexObjPtr t, int level,
+ int x, int y, int width, int height )
+{
+ mach64ScreenRec *mach64Screen = mmesa->mach64Screen;
+ struct gl_texture_image *image;
+ int texelsPerDword = 0;
+ int dwords;
+
+ /* Ensure we have a valid texture to upload */
+ if ( ( level < 0 ) || ( level > mmesa->glCtx->Const.MaxTextureLevels ) )
+ return;
+
+ image = t->tObj->Image[0][level];
+ if ( !image )
+ return;
+
+ switch ( image->TexFormat->TexelBytes ) {
+ case 1: texelsPerDword = 4; break;
+ case 2: texelsPerDword = 2; break;
+ case 4: texelsPerDword = 1; break;
+ }
+
+#if 1
+ /* FIXME: The subimage index calcs are wrong... */
+ x = 0;
+ y = 0;
+ width = image->Width;
+ height = image->Height;
+#endif
+
+ dwords = width * height / texelsPerDword;
+
+#if ENABLE_PERF_BOXES
+ /* Bump the performance counter */
+ mmesa->c_agpTextureBytes += (dwords << 2);
+#endif
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "mach64UploadSubImage: %d,%d of %d,%d at %d,%d\n",
+ width, height, image->Width, image->Height, x, y );
+ fprintf( stderr, " blit ofs: 0x%07x pitch: 0x%x dwords: %d\n",
+ (GLuint)t->offset, (GLint)width, dwords );
+ mmDumpMemInfo( mmesa->texHeap[t->heap] );
+ }
+
+ assert(image->Data);
+
+ {
+ CARD32 *dst = (CARD32 *)((char *)mach64Screen->agpTextures.map + t->memBlock->ofs);
+ const GLubyte *src = (const GLubyte *) image->Data +
+ (y * image->Width + x) * image->TexFormat->TexelBytes;
+ const GLuint bytes = width * height * image->TexFormat->TexelBytes;
+ memcpy(dst, src, bytes);
+ }
+
+}
+
+/* Upload the texture image associated with texture `t' at level `level'
+ * at the address relative to `start'.
+ */
+static void mach64UploadLocalSubImage( mach64ContextPtr mmesa,
+ mach64TexObjPtr 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, dwords;
+ const int maxdwords = (MACH64_BUFFER_MAX_DWORDS - (MACH64_HOSTDATA_BLIT_OFFSET / 4));
+ CARD32 pitch, offset;
+ int i;
+
+ /* Ensure we have a valid texture to upload */
+ if ( ( level < 0 ) || ( level > mmesa->glCtx->Const.MaxTextureLevels ) )
+ return;
+
+ image = t->tObj->Image[0][level];
+ if ( !image )
+ return;
+
+ switch ( image->TexFormat->TexelBytes ) {
+ case 1: texelsPerDword = 4; break;
+ case 2: texelsPerDword = 2; break;
+ case 4: texelsPerDword = 1; break;
+ }
+
+#if 1
+ /* FIXME: The subimage index calcs are wrong... */
+ x = 0;
+ y = 0;
+ width = image->Width;
+ height = image->Height;
+#endif
+
+ imageWidth = image->Width;
+ imageHeight = image->Height;
+
+ format = t->textureFormat;
+
+ /* 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 64 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 >= 64 ) {
+ /* The texture walker and the blitter look identical */
+ pitch = imageWidth >> 3;
+ } else {
+ int factor;
+ int y2;
+ int start, end;
+
+ start = (y * imageWidth) & ~63;
+ end = (y + height) * imageWidth;
+
+ if ( end - start < 64 ) {
+ /* Handle the case where the total number of texels
+ * uploaded is < 64.
+ */
+ x = 0;
+ y = start / 64;
+ width = end - start;
+ height = 1;
+ } else {
+ /* Upload some number of full 64 texel blit rows */
+ factor = 64 / imageWidth;
+
+ y2 = y + height - 1;
+ y /= factor;
+ y2 /= factor;
+
+ x = 0;
+ width = 64;
+ height = y2 - y + 1;
+ }
+
+ /* Fixed pitch of 64 */
+ pitch = 8;
+ }
+
+ dwords = width * height / texelsPerDword;
+ offset = t->offset;
+
+#if ENABLE_PERF_BOXES
+ /* Bump the performance counter */
+ mmesa->c_textureBytes += (dwords << 2);
+#endif
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "mach64UploadSubImage: %d,%d of %d,%d at %d,%d\n",
+ width, height, image->Width, image->Height, x, y );
+ fprintf( stderr, " blit ofs: 0x%07x pitch: 0x%x dwords: %d\n",
+ (GLuint)offset, (GLint)width, dwords );
+ mmDumpMemInfo( mmesa->texHeap[t->heap] );
+ }
+
+ /* Subdivide the texture if required (account for the registers added by the drm) */
+ if ( dwords <= maxdwords ) {
+ rows = height;
+ } else {
+ rows = (maxdwords * texelsPerDword) / (2 * width);
+ }
+
+ for ( i = 0, remaining = height ;
+ remaining > 0 ;
+ remaining -= rows, y += rows, i++ )
+ {
+ drmBufPtr buffer;
+ CARD32 *dst;
+
+ height = MIN2(remaining, rows);
+
+ /* Grab the dma buffer for the texture blit */
+ buffer = mach64GetBufferLocked( mmesa );
+
+ dst = (CARD32 *)((char *)buffer->address + MACH64_HOSTDATA_BLIT_OFFSET);
+
+ assert(image->Data);
+
+ {
+ const GLubyte *src = (const GLubyte *) image->Data +
+ (y * image->Width + x) * image->TexFormat->TexelBytes;
+ const GLuint bytes = width * height * image->TexFormat->TexelBytes;
+ memcpy(dst, src, bytes);
+ }
+
+ mach64FireBlitLocked( mmesa, buffer, offset, pitch, format,
+ x, y, width, height );
+
+ }
+
+ mmesa->new_state |= MACH64_NEW_CONTEXT;
+ mmesa->dirty |= MACH64_UPLOAD_CONTEXT | MACH64_UPLOAD_MISC;
+}
+
+
+/* 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.
+ */
+void mach64UploadTexImages( mach64ContextPtr mmesa, mach64TexObjPtr t )
+{
+ GLint heap;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %p, %p )\n",
+ __FUNCTION__, mmesa->glCtx, t );
+ }
+
+ assert(t);
+ assert(t->tObj);
+
+ /* Choose the heap appropriately */
+ heap = MACH64_CARD_HEAP;
+
+ if ( !mmesa->mach64Screen->IsPCI &&
+ t->size > mmesa->mach64Screen->texSize[heap] ) {
+ heap = MACH64_AGP_HEAP;
+ }
+
+ /* Do we need to eject LRU texture objects? */
+ if ( !t->memBlock ) {
+ t->heap = heap;
+
+ /* Allocate a memory block on a 64-byte boundary */
+ t->memBlock = mmAllocMem( mmesa->texHeap[heap], t->size, 6, 0 );
+
+ /* Try AGP before kicking anything out of local mem */
+ if ( !mmesa->mach64Screen->IsPCI && !t->memBlock && heap == MACH64_CARD_HEAP ) {
+ t->memBlock = mmAllocMem( mmesa->texHeap[MACH64_AGP_HEAP],
+ t->size, 6, 0 );
+
+ if ( t->memBlock )
+ heap = t->heap = MACH64_AGP_HEAP;
+ }
+
+ /* Kick out textures until the requested texture fits */
+ while ( !t->memBlock ) {
+ if ( mmesa->TexObjList[heap].prev->bound ) {
+ fprintf( stderr,
+ "mach64UploadTexImages: ran into bound texture\n" );
+ return;
+ }
+ if ( mmesa->TexObjList[heap].prev == &mmesa->TexObjList[heap] ) {
+ if ( mmesa->mach64Screen->IsPCI ) {
+ fprintf( stderr, "%s: upload texture failure on "
+ "local texture heaps, sz=%d\n", __FUNCTION__,
+ t->size );
+ return;
+ } else if ( heap == MACH64_CARD_HEAP ) {
+ heap = t->heap = MACH64_AGP_HEAP;
+ continue;
+ } else {
+ int i;
+ fprintf( stderr, "%s: upload texture failure on "
+ "%sAGP texture heaps, sz=%d\n", __FUNCTION__,
+ mmesa->firstTexHeap == MACH64_CARD_HEAP ? "both local and " : "",
+ t->size );
+ for ( i = mmesa->firstTexHeap ; i < mmesa->lastTexHeap ; i++ ) {
+ mach64PrintLocalLRU( mmesa, i );
+ mmDumpMemInfo( mmesa->texHeap[i] );
+ }
+ exit(-1);
+ return;
+ }
+ }
+
+ mach64SwapOutTexObj( mmesa, mmesa->TexObjList[heap].prev );
+
+ t->memBlock = mmAllocMem( mmesa->texHeap[heap], t->size, 6, 0 );
+ }
+
+ /* Set the base offset of the texture image */
+ t->offset = mmesa->mach64Screen->texOffset[heap] + t->memBlock->ofs;
+
+ /* Force loading the new state into the hardware */
+ mmesa->dirty |= (MACH64_UPLOAD_SCALE_3D_CNTL |
+ MACH64_UPLOAD_TEXTURE);
+ }
+
+ /* Let the world know we've used this memory recently */
+ mach64UpdateTexLRU( mmesa, t );
+
+ /* Upload any images that are new */
+ if ( t->dirty ) {
+ if (t->heap == MACH64_AGP_HEAP) {
+ /* Need to make sure any vertex buffers in the queue complete */
+ mach64WaitForIdleLocked( mmesa );
+ mach64UploadAGPSubImage( mmesa, t, t->tObj->BaseLevel, 0, 0,
+ t->tObj->Image[0][t->tObj->BaseLevel]->Width,
+ t->tObj->Image[0][t->tObj->BaseLevel]->Height );
+ } else {
+ mach64UploadLocalSubImage( mmesa, t, t->tObj->BaseLevel, 0, 0,
+ t->tObj->Image[0][t->tObj->BaseLevel]->Width,
+ t->tObj->Image[0][t->tObj->BaseLevel]->Height );
+ }
+
+ mmesa->setup.tex_cntl |= MACH64_TEX_CACHE_FLUSH;
+ }
+
+ mmesa->dirty |= MACH64_UPLOAD_TEXTURE;
+
+ t->dirty = 0;
+}
+
+/* The mach64 needs to have both primary and secondary textures in either
+ * local or AGP memory, so we need a "buddy system" to make sure that allocation
+ * succeeds or fails for both textures.
+ * FIXME: This needs to be optimized better.
+ */
+void mach64UploadMultiTexImages( mach64ContextPtr mmesa,
+ mach64TexObjPtr t0,
+ mach64TexObjPtr t1 )
+{
+ GLint heap;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %p, %p %p )\n",
+ __FUNCTION__, mmesa->glCtx, t0, t1 );
+ }
+
+ assert(t0 && t1);
+ assert(t0->tObj && t1->tObj);
+
+ /* Choose the heap appropriately */
+ heap = MACH64_CARD_HEAP;
+
+ if ( !mmesa->mach64Screen->IsPCI &&
+ ((t0->size + t1->size) > mmesa->mach64Screen->texSize[heap]) ) {
+ heap = MACH64_AGP_HEAP;
+ }
+
+ /* Do we need to eject LRU texture objects? */
+ if ( !t0->memBlock || !t1->memBlock || t0->heap != t1->heap ) {
+ /* FIXME: starting from scratch for now to keep it simple */
+ if ( t0->memBlock ) {
+ mach64SwapOutTexObj( mmesa, t0 );
+ }
+ if ( t1->memBlock ) {
+ mach64SwapOutTexObj( mmesa, t1 );
+ }
+ t0->heap = t1->heap = heap;
+ /* Allocate a memory block on a 64-byte boundary */
+ t0->memBlock = mmAllocMem( mmesa->texHeap[heap], t0->size, 6, 0 );
+ if ( t0->memBlock ) {
+ t1->memBlock = mmAllocMem( mmesa->texHeap[heap], t1->size, 6, 0 );
+ if ( !t1->memBlock ) {
+ mmFreeMem( t0->memBlock );
+ t0->memBlock = NULL;
+ }
+ }
+ /* Try AGP before kicking anything out of local mem */
+ if ( (!t0->memBlock || !t1->memBlock) && heap == MACH64_CARD_HEAP ) {
+ t0->memBlock = mmAllocMem( mmesa->texHeap[MACH64_AGP_HEAP], t0->size, 6, 0 );
+ if ( t0->memBlock ) {
+ t1->memBlock = mmAllocMem( mmesa->texHeap[MACH64_AGP_HEAP], t1->size, 6, 0 );
+ if ( !t1->memBlock ) {
+ mmFreeMem( t0->memBlock );
+ t0->memBlock = NULL;
+ }
+ }
+
+ if ( t0->memBlock && t1->memBlock )
+ heap = t0->heap = t1->heap = MACH64_AGP_HEAP;
+ }
+
+ /* Kick out textures until the requested texture fits */
+ while ( !t0->memBlock || !t1->memBlock ) {
+ if ( mmesa->TexObjList[heap].prev->bound ) {
+ fprintf( stderr,
+ "%s: ran into bound texture\n", __FUNCTION__ );
+ return;
+ }
+ if ( mmesa->TexObjList[heap].prev == &mmesa->TexObjList[heap] ) {
+ if ( mmesa->mach64Screen->IsPCI ) {
+ fprintf( stderr, "%s: upload texture failure on local "
+ "texture heaps, tex0 sz=%d tex1 sz=%d\n", __FUNCTION__,
+ t0->size, t1->size );
+ return;
+ } else if ( heap == MACH64_CARD_HEAP ) {
+ /* If only one allocation succeeded, start over again in AGP */
+ if (t0->memBlock) {
+ mmFreeMem( t0->memBlock );
+ t0->memBlock = NULL;
+ }
+ if (t1->memBlock) {
+ mmFreeMem( t1->memBlock );
+ t1->memBlock = NULL;
+ }
+ heap = t0->heap = t1->heap = MACH64_AGP_HEAP;
+ continue;
+ } else {
+ int i;
+ fprintf( stderr, "%s: upload texture failure on %s"
+ "AGP texture heaps, tex0 sz=%d tex1 sz=%d\n", __FUNCTION__,
+ mmesa->firstTexHeap == MACH64_CARD_HEAP ? "both local and " : "",
+ t0->size, t1->size );
+ for ( i = mmesa->firstTexHeap ; i < mmesa->lastTexHeap ; i++ ) {
+ mach64PrintLocalLRU( mmesa, i );
+ mmDumpMemInfo( mmesa->texHeap[i] );
+ }
+ exit(-1);
+ return;
+ }
+ }
+
+ mach64SwapOutTexObj( mmesa, mmesa->TexObjList[heap].prev );
+
+ if (!t0->memBlock)
+ t0->memBlock = mmAllocMem( mmesa->texHeap[heap], t0->size, 6, 0 );
+ if (!t1->memBlock)
+ t1->memBlock = mmAllocMem( mmesa->texHeap[heap], t1->size, 6, 0 );
+ }
+
+ /* Set the base offset of the texture image */
+ t0->offset = mmesa->mach64Screen->texOffset[heap] + t0->memBlock->ofs;
+ t1->offset = mmesa->mach64Screen->texOffset[heap] + t1->memBlock->ofs;
+
+ /* Force loading the new state into the hardware */
+ mmesa->dirty |= (MACH64_UPLOAD_SCALE_3D_CNTL |
+ MACH64_UPLOAD_TEXTURE);
+ }
+
+ /* Let the world know we've used this memory recently */
+ mach64UpdateTexLRU( mmesa, t0 );
+ mach64UpdateTexLRU( mmesa, t1 );
+
+ /* Upload any images that are new */
+ if ( t0->dirty ) {
+ if (t0->heap == MACH64_AGP_HEAP) {
+ /* Need to make sure any vertex buffers in the queue complete */
+ mach64WaitForIdleLocked( mmesa );
+ mach64UploadAGPSubImage( mmesa, t0, t0->tObj->BaseLevel, 0, 0,
+ t0->tObj->Image[0][t0->tObj->BaseLevel]->Width,
+ t0->tObj->Image[0][t0->tObj->BaseLevel]->Height );
+ } else {
+ mach64UploadLocalSubImage( mmesa, t0, t0->tObj->BaseLevel, 0, 0,
+ t0->tObj->Image[0][t0->tObj->BaseLevel]->Width,
+ t0->tObj->Image[0][t0->tObj->BaseLevel]->Height );
+ }
+ mmesa->setup.tex_cntl |= MACH64_TEX_CACHE_FLUSH;
+ }
+ if ( t1->dirty ) {
+ if (t1->heap == MACH64_AGP_HEAP) {
+ /* Need to make sure any vertex buffers in the queue complete */
+ mach64WaitForIdleLocked( mmesa );
+ mach64UploadAGPSubImage( mmesa, t1, t1->tObj->BaseLevel, 0, 0,
+ t1->tObj->Image[0][t1->tObj->BaseLevel]->Width,
+ t1->tObj->Image[0][t1->tObj->BaseLevel]->Height );
+ } else {
+ mach64UploadLocalSubImage( mmesa, t1, t1->tObj->BaseLevel, 0, 0,
+ t1->tObj->Image[0][t1->tObj->BaseLevel]->Width,
+ t1->tObj->Image[0][t1->tObj->BaseLevel]->Height );
+ }
+
+ mmesa->setup.tex_cntl |= MACH64_TEX_CACHE_FLUSH;
+ }
+
+ mmesa->dirty |= MACH64_UPLOAD_TEXTURE;
+
+ t0->dirty = 0;
+ t1->dirty = 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_texstate.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_texstate.c
new file mode 100644
index 000000000..ada4b056f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_texstate.c
@@ -0,0 +1,558 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "macros.h"
+#include "texformat.h"
+
+#include "mach64_context.h"
+#include "mach64_ioctl.h"
+#include "mach64_state.h"
+#include "mach64_vb.h"
+#include "mach64_tris.h"
+#include "mach64_tex.h"
+
+static void mach64SetTexImages( mach64ContextPtr mmesa,
+ const struct gl_texture_object *tObj )
+{
+ mach64TexObjPtr t = (mach64TexObjPtr) tObj->DriverData;
+ struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
+#if 0
+ int log2Pitch, log2Height, log2Size, log2MinSize;
+ int i;
+ GLint firstLevel, lastLevel;
+#endif
+ int totalSize;
+
+ assert(t);
+ assert(baseImage);
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_API )
+ fprintf( stderr, "%s( %p )\n", __FUNCTION__, tObj );
+
+ switch (baseImage->TexFormat->MesaFormat) {
+ case MESA_FORMAT_ARGB8888:
+ t->textureFormat = MACH64_DATATYPE_ARGB8888;
+ break;
+ case MESA_FORMAT_ARGB4444:
+ t->textureFormat = MACH64_DATATYPE_ARGB4444;
+ break;
+ case MESA_FORMAT_RGB565:
+ t->textureFormat = MACH64_DATATYPE_RGB565;
+ break;
+ case MESA_FORMAT_ARGB1555:
+ t->textureFormat = MACH64_DATATYPE_ARGB1555;
+ break;
+ case MESA_FORMAT_RGB332:
+ t->textureFormat = MACH64_DATATYPE_RGB332;
+ break;
+ case MESA_FORMAT_RGB888:
+ t->textureFormat = MACH64_DATATYPE_RGB8;
+ break;
+ case MESA_FORMAT_CI8:
+ t->textureFormat = MACH64_DATATYPE_CI8;
+ break;
+ case MESA_FORMAT_YCBCR:
+ t->textureFormat = MACH64_DATATYPE_YVYU422;
+ break;
+ case MESA_FORMAT_YCBCR_REV:
+ t->textureFormat = MACH64_DATATYPE_VYUY422;
+ break;
+ default:
+ _mesa_problem(mmesa->glCtx, "Bad texture format in %s", __FUNCTION__);
+ };
+
+#if 0
+ /* Compute which mipmap levels we really want to send to the hardware.
+ * This depends on the base image size, GL_TEXTURE_MIN_LOD,
+ * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
+ * Yes, this looks overly complicated, but it's all needed.
+ */
+ firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
+ firstLevel = MAX2(firstLevel, tObj->BaseLevel);
+ lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
+ lastLevel = MAX2(lastLevel, tObj->BaseLevel);
+ lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
+ lastLevel = MIN2(lastLevel, tObj->MaxLevel);
+ lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
+
+ log2Pitch = tObj->Image[firstLevel]->WidthLog2;
+ log2Height = tObj->Image[firstLevel]->HeightLog2;
+ log2Size = MAX2(log2Pitch, log2Height);
+ log2MinSize = log2Size;
+
+ t->dirty = 0;
+ totalSize = 0;
+ for ( i = firstLevel; i <= lastLevel; i++ ) {
+ const struct gl_texture_image *texImage;
+
+ texImage = tObj->Image[i];
+ if ( !texImage || !texImage->Data ) {
+ lastLevel = i - 1;
+ break;
+ }
+
+ log2MinSize = texImage->MaxLog2;
+
+ t->image[i - firstLevel].offset = totalSize;
+ t->image[i - firstLevel].width = tObj->Image[i]->Width;
+ t->image[i - firstLevel].height = tObj->Image[i]->Height;
+
+ t->dirty |= (1 << i);
+
+ totalSize += (tObj->Image[i]->Height *
+ tObj->Image[i]->Width *
+ tObj->Image[i]->TexFormat->TexelBytes);
+
+ /* Offsets must be 32-byte aligned for host data blits and tiling */
+ totalSize = (totalSize + 31) & ~31;
+ }
+
+ t->totalSize = totalSize;
+ t->firstLevel = firstLevel;
+ t->lastLevel = lastLevel;
+
+ /* Set the texture format */
+ t->setup.tex_cntl &= ~(0xf << 16);
+ t->setup.tex_cntl |= t->textureFormat;
+
+ t->setup.tex_combine_cntl = 0x00000000; /* XXX is this right? */
+
+ t->setup.tex_size_pitch = ((log2Pitch << R128_TEX_PITCH_SHIFT) |
+ (log2Size << R128_TEX_SIZE_SHIFT) |
+ (log2Height << R128_TEX_HEIGHT_SHIFT) |
+ (log2MinSize << R128_TEX_MIN_SIZE_SHIFT));
+
+ for ( i = 0 ; i < R128_MAX_TEXTURE_LEVELS ; i++ ) {
+ t->setup.tex_offset[i] = 0x00000000;
+ }
+
+ if (firstLevel == lastLevel)
+ t->setup.tex_cntl |= R128_MIP_MAP_DISABLE;
+ else
+ t->setup.tex_cntl &= ~R128_MIP_MAP_DISABLE;
+
+#else
+ if ( ( baseImage->Format == GL_RGBA ) ||
+ ( baseImage->Format == GL_ALPHA ) ||
+ ( baseImage->Format == GL_LUMINANCE_ALPHA ) ) {
+ t->hasAlpha = 1;
+ } else {
+ t->hasAlpha = 0;
+ }
+
+ totalSize = ( baseImage->Width * baseImage->Height *
+ baseImage->TexFormat->TexelBytes );
+ totalSize = (totalSize + 31) & ~31;
+ t->size = totalSize;
+ t->widthLog2 = baseImage->WidthLog2;
+ t->heightLog2 = baseImage->HeightLog2;
+ t->maxLog2 = baseImage->MaxLog2;
+
+#endif
+}
+
+static void mach64UpdateTextureEnv( GLcontext *ctx, int unit )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ GLint source = mmesa->tmu_source[unit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
+ const struct gl_texture_object *tObj = texUnit->_Current;
+ const GLenum format = tObj->Image[0][tObj->BaseLevel]->Format;
+ GLuint s = mmesa->setup.scale_3d_cntl;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %p, %d )\n",
+ __FUNCTION__, ctx, unit );
+ }
+
+/* REPLACE MODULATE DECAL GL_BLEND
+ *
+ * ALPHA C = Cf C = Cf undef C = Cf
+ * A = At A = AfAt A = AfAt
+ *
+ * LUMINANCE C = Ct C = CfCt undef C = Cf(1-Ct)+CcCt
+ * A = Af A = Af A = Af
+ *
+ * LUMINANCE_ALPHA C = Ct C = CfCt undef C = Cf(1-Ct)+CcCt
+ * A = At A = AfAt A = AfAt
+ *
+ * INTENSITY C = Ct C = CfCt undef C = Cf(1-Ct)+CcCt
+ * A = At A = AfAt A = Af(1-At)+AcAt
+ *
+ * RGB C = Ct C = CfCt C = Ct C = Cf(1-Ct)+CcCt
+ * A = Af A = Af A = Af A = Af
+ *
+ * RGBA C = Ct C = CfCt C = Cf(1-At)+CtAt C = Cf(1-Ct)+CcCt
+ * A = At A = AfAt A = Af A = AfAt
+ */
+
+
+ if ( unit == 0 ) {
+ s &= ~MACH64_TEX_LIGHT_FCN_MASK;
+
+ /* Set the texture environment state
+ * Need to verify these are working correctly, but the
+ * texenv Mesa demo seems to work.
+ */
+ switch ( texUnit->EnvMode ) {
+ case GL_REPLACE:
+ switch ( format ) {
+ case GL_ALPHA:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ /* Not compliant - can't get At */
+ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE );
+ s |= MACH64_TEX_LIGHT_FCN_MODULATE;
+ break;
+ default:
+ s |= MACH64_TEX_LIGHT_FCN_REPLACE;
+ }
+ break;
+ case GL_MODULATE:
+ switch ( format ) {
+ case GL_ALPHA:
+ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE );
+ s |= MACH64_TEX_LIGHT_FCN_MODULATE;
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ /* These should be compliant */
+ s |= MACH64_TEX_LIGHT_FCN_MODULATE;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE );
+ s |= MACH64_TEX_LIGHT_FCN_MODULATE;
+ break;
+ case GL_RGBA:
+ /* Should fallback when blending enabled for complete compliance */
+ s |= MACH64_TEX_LIGHT_FCN_MODULATE;
+ break;
+ default:
+ s |= MACH64_TEX_LIGHT_FCN_MODULATE;
+ }
+ break;
+ case GL_DECAL:
+ switch ( format ) {
+ case GL_RGBA:
+ s |= MACH64_TEX_LIGHT_FCN_ALPHA_DECAL;
+ break;
+ case GL_RGB:
+ s |= MACH64_TEX_LIGHT_FCN_REPLACE;
+ break;
+ case GL_ALPHA:
+ case GL_LUMINANCE_ALPHA:
+ /* undefined - disable texturing, pass fragment unmodified */
+ /* Also, pass fragment alpha instead of texture alpha */
+ s &= ~MACH64_TEX_MAP_AEN;
+ s |= MACH64_TEXTURE_DISABLE;
+ s |= MACH64_TEX_LIGHT_FCN_MODULATE;
+ break;
+ case GL_LUMINANCE:
+ case GL_INTENSITY:
+ /* undefined - disable texturing, pass fragment unmodified */
+ s |= MACH64_TEXTURE_DISABLE;
+ s |= MACH64_TEX_LIGHT_FCN_MODULATE;
+ break;
+ default:
+ s |= MACH64_TEX_LIGHT_FCN_MODULATE;
+ }
+ break;
+ case GL_BLEND:
+ /* GL_BLEND not supported by RagePRO, use software */
+ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE );
+ s |= MACH64_TEX_LIGHT_FCN_MODULATE;
+ break;
+ case GL_ADD:
+ case GL_COMBINE:
+ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE );
+ s |= MACH64_TEX_LIGHT_FCN_MODULATE;
+ break;
+ default:
+ s |= MACH64_TEX_LIGHT_FCN_MODULATE;
+ }
+
+ if ( mmesa->setup.scale_3d_cntl != s ) {
+ mmesa->setup.scale_3d_cntl = s;
+ mmesa->dirty |= MACH64_UPLOAD_SCALE_3D_CNTL;
+ }
+
+ } else {
+ /* blend = 0, modulate = 1 - initialize to blend */
+ mmesa->setup.tex_cntl &= ~MACH64_COMP_COMBINE_MODULATE;
+ /* Set the texture composite function for multitexturing*/
+ switch ( texUnit->EnvMode ) {
+ case GL_BLEND:
+ /* GL_BLEND not supported by RagePRO, use software */
+ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE );
+ mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE;
+ break;
+ case GL_MODULATE:
+ /* Should fallback when blending enabled for complete compliance */
+ mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE;
+ break;
+ case GL_REPLACE:
+ switch ( format ) {
+ case GL_ALPHA:
+ mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE;
+ break;
+ default: /* not supported by RagePRO */
+ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE );
+ mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE;
+ }
+ break;
+ case GL_DECAL:
+ switch ( format ) {
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ /* undefined, disable compositing and pass fragment unmodified */
+ mmesa->setup.tex_cntl &= ~MACH64_TEXTURE_COMPOSITE;
+ break;
+ default: /* not supported by RagePRO */
+ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE );
+ mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE;
+ }
+ break;
+ case GL_ADD:
+ case GL_COMBINE:
+ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE );
+ mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE;
+ break;
+ default:
+ mmesa->setup.tex_cntl |= MACH64_COMP_COMBINE_MODULATE;
+ }
+ }
+}
+
+
+static void mach64UpdateTextureUnit( GLcontext *ctx, int unit )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ int source = mmesa->tmu_source[unit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
+ const struct gl_texture_object *tObj = ctx->Texture.Unit[source]._Current;
+ mach64TexObjPtr t = tObj->DriverData;
+ GLuint d = mmesa->setup.dp_pix_width;
+ GLuint s = mmesa->setup.scale_3d_cntl;
+
+ assert(unit == 0 || unit == 1); /* only two tex units */
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %p, %d ) enabled=0x%x 0x%x\n",
+ __FUNCTION__, ctx, unit, ctx->Texture.Unit[0]._ReallyEnabled,
+ ctx->Texture.Unit[1]._ReallyEnabled);
+ }
+
+ if (texUnit->_ReallyEnabled & (TEXTURE_1D_BIT | TEXTURE_2D_BIT)) {
+
+ assert(t); /* should have driver tex data by now */
+
+ /* Fallback if there's a texture border */
+ if ( tObj->Image[0][tObj->BaseLevel]->Border > 0 ) {
+ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE );
+ return;
+ }
+
+ /* Upload teximages */
+ if (t->dirty) {
+ mach64SetTexImages( mmesa, tObj );
+ mmesa->dirty |= (MACH64_UPLOAD_TEX0IMAGE << unit);
+ }
+
+ /* Bind to the given texture unit */
+ mmesa->CurrentTexObj[unit] = t;
+ t->bound |= (1 << unit);
+
+ if ( t->memBlock )
+ mach64UpdateTexLRU( mmesa, t );
+
+ /* register setup */
+ if ( unit == 0 ) {
+ d &= ~MACH64_SCALE_PIX_WIDTH_MASK;
+ d |= (t->textureFormat << 28);
+
+ s &= ~(MACH64_TEXTURE_DISABLE |
+ MACH64_TEX_CACHE_SPLIT |
+ MACH64_TEX_BLEND_FCN_MASK |
+ MACH64_TEX_MAP_AEN);
+
+ if ( mmesa->multitex ) {
+ s |= MACH64_TEX_BLEND_FCN_TRILINEAR | MACH64_TEX_CACHE_SPLIT;
+ } else if ( t->BilinearMin ) {
+ s |= MACH64_TEX_BLEND_FCN_LINEAR;
+ } else {
+ s |= MACH64_TEX_BLEND_FCN_NEAREST;
+ }
+ if ( t->BilinearMag ) {
+ s |= MACH64_BILINEAR_TEX_EN;
+ } else {
+ s &= ~MACH64_BILINEAR_TEX_EN;
+ }
+
+ if ( t->hasAlpha ) {
+ s |= MACH64_TEX_MAP_AEN;
+ }
+
+ mmesa->setup.tex_cntl &= ~(MACH64_TEXTURE_CLAMP_S |
+ MACH64_TEXTURE_CLAMP_T |
+ MACH64_SECONDARY_STW);
+
+ if ( t->ClampS ) {
+ mmesa->setup.tex_cntl |= MACH64_TEXTURE_CLAMP_S;
+ }
+ if ( t->ClampT ) {
+ mmesa->setup.tex_cntl |= MACH64_TEXTURE_CLAMP_T;
+ }
+
+ mmesa->setup.tex_size_pitch |= ((t->widthLog2 << 0) |
+ (t->maxLog2 << 4) |
+ (t->heightLog2 << 8));
+ } else {
+
+ /* Enable texture mapping mode */
+ s &= ~MACH64_TEXTURE_DISABLE;
+
+ d &= ~MACH64_COMPOSITE_PIX_WIDTH_MASK;
+ d |= (t->textureFormat << 4);
+
+ mmesa->setup.tex_cntl &= ~(MACH64_COMP_ALPHA |
+ MACH64_SEC_TEX_CLAMP_S |
+ MACH64_SEC_TEX_CLAMP_T);
+ mmesa->setup.tex_cntl |= (MACH64_TEXTURE_COMPOSITE |
+ MACH64_SECONDARY_STW);
+
+ if ( t->BilinearMin ) {
+ mmesa->setup.tex_cntl |= MACH64_COMP_BLEND_BILINEAR;
+ } else {
+ mmesa->setup.tex_cntl &= ~MACH64_COMP_BLEND_BILINEAR;
+ }
+ if ( t->BilinearMag ) {
+ mmesa->setup.tex_cntl |= MACH64_COMP_FILTER_BILINEAR;
+ } else {
+ mmesa->setup.tex_cntl &= ~MACH64_COMP_FILTER_BILINEAR;
+ }
+
+ if ( t->hasAlpha ) {
+ mmesa->setup.tex_cntl |= MACH64_COMP_ALPHA;
+ }
+ if ( t->ClampS ) {
+ mmesa->setup.tex_cntl |= MACH64_SEC_TEX_CLAMP_S;
+ }
+ if ( t->ClampT ) {
+ mmesa->setup.tex_cntl |= MACH64_SEC_TEX_CLAMP_T;
+ }
+
+ mmesa->setup.tex_size_pitch |= ((t->widthLog2 << 16) |
+ (t->maxLog2 << 20) |
+ (t->heightLog2 << 24));
+ }
+
+ if ( mmesa->setup.scale_3d_cntl != s ) {
+ mmesa->setup.scale_3d_cntl = s;
+ mmesa->dirty |= MACH64_UPLOAD_SCALE_3D_CNTL;
+ }
+
+ if ( mmesa->setup.dp_pix_width != d ) {
+ mmesa->setup.dp_pix_width = d;
+ mmesa->dirty |= MACH64_UPLOAD_DP_PIX_WIDTH;
+ }
+ }
+ else if (texUnit->_ReallyEnabled) {
+ /* 3D or cube map texture enabled - fallback */
+ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_TRUE );
+ }
+ else {
+ /* texture unit disabled */
+ }
+}
+
+
+/* Update the hardware texture state */
+void mach64UpdateTextureState( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %p ) en=0x%x 0x%x\n",
+ __FUNCTION__, ctx, ctx->Texture.Unit[0]._ReallyEnabled,
+ ctx->Texture.Unit[1]._ReallyEnabled);
+ }
+
+ /* Clear any texturing fallbacks */
+ FALLBACK( mmesa, MACH64_FALLBACK_TEXTURE, GL_FALSE );
+
+ /* Unbind any currently bound textures */
+ if ( mmesa->CurrentTexObj[0] ) mmesa->CurrentTexObj[0]->bound = 0;
+ if ( mmesa->CurrentTexObj[1] ) mmesa->CurrentTexObj[1]->bound = 0;
+ mmesa->CurrentTexObj[0] = NULL;
+ mmesa->CurrentTexObj[1] = NULL;
+
+ /* Disable all texturing until it is known to be good */
+ mmesa->setup.scale_3d_cntl |= MACH64_TEXTURE_DISABLE;
+ mmesa->setup.scale_3d_cntl &= ~MACH64_TEX_MAP_AEN;
+ mmesa->setup.tex_cntl &= ~MACH64_TEXTURE_COMPOSITE;
+
+ mmesa->setup.tex_size_pitch = 0x00000000;
+
+ mmesa->tmu_source[0] = 0;
+ mmesa->tmu_source[1] = 1;
+ mmesa->multitex = 0;
+
+ if (ctx->Texture._EnabledUnits & 0x2) {
+ /* unit 1 enabled */
+ if (ctx->Texture._EnabledUnits & 0x1) {
+ /* units 0 and 1 enabled */
+ mmesa->multitex = 1;
+ mach64UpdateTextureUnit( ctx, 0 );
+ mach64UpdateTextureEnv( ctx, 0 );
+ mach64UpdateTextureUnit( ctx, 1 );
+ mach64UpdateTextureEnv( ctx, 1 );
+ } else {
+ mmesa->tmu_source[0] = 1;
+ mmesa->tmu_source[1] = 0;
+ mach64UpdateTextureUnit( ctx, 0 );
+ mach64UpdateTextureEnv( ctx, 0 );
+ }
+ } else if (ctx->Texture._EnabledUnits & 0x1) {
+ /* only unit 0 enabled */
+ mach64UpdateTextureUnit( ctx, 0 );
+ mach64UpdateTextureEnv( ctx, 0 );
+ }
+
+ mmesa->dirty |= (MACH64_UPLOAD_SCALE_3D_CNTL |
+ MACH64_UPLOAD_TEXTURE);
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_tris.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_tris.c
new file mode 100644
index 000000000..4a0044be8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_tris.c
@@ -0,0 +1,1921 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "colormac.h"
+#include "macros.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
+#include "mach64_tris.h"
+#include "mach64_state.h"
+#include "mach64_context.h"
+#include "mach64_vb.h"
+#include "mach64_ioctl.h"
+
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ MACH64_PRIM_POINTS,
+ MACH64_PRIM_LINES,
+ MACH64_PRIM_LINE_LOOP,
+ MACH64_PRIM_LINE_STRIP,
+ MACH64_PRIM_TRIANGLES,
+ MACH64_PRIM_TRIANGLE_STRIP,
+ MACH64_PRIM_TRIANGLE_FAN,
+ MACH64_PRIM_QUADS,
+ MACH64_PRIM_QUAD_STRIP,
+ MACH64_PRIM_POLYGON,
+};
+
+static void mach64RasterPrimitive( GLcontext *ctx, GLuint hwprim );
+static void mach64RenderPrimitive( GLcontext *ctx, GLenum prim );
+
+
+/* FIXME: Remove this when native template is finished. */
+#define MACH64_PRINT_BUFFER 0
+
+/***********************************************************************
+ * Emit primitives as inline vertices *
+ ***********************************************************************/
+
+#if defined(USE_X86_ASM)
+#define DO_COPY_VERTEX( vb, vertsize, v, n, m ) \
+do { \
+ register const CARD32 *__p __asm__( "esi" ) = (CARD32 *)v + 10 - vertsize; \
+ register int __s __asm__( "ecx" ) = vertsize; \
+ if ( vertsize > 7 ) { \
+ *vb++ = (2 << 16) | ADRINDEX( MACH64_VERTEX_##n##_SECONDARY_S ); \
+ __asm__ __volatile__( "movsl ; movsl ; movsl" \
+ : "=D" (vb), "=S" (__p) \
+ : "0" (vb), "1" (__p) ); \
+ __s -= 3; \
+ } \
+ *vb++ = ((__s - 1 + m) << 16) | \
+ (ADRINDEX( MACH64_VERTEX_##n##_X_Y ) - (__s - 1) ); \
+ __asm__ __volatile__( "rep ; movsl" \
+ : "=%c" (__s), "=D" (vb), "=S" (__p) \
+ : "0" (__s), "1" (vb), "2" (__p) ); \
+} while (0)
+#else
+#define DO_COPY_VERTEX( vb, vertsize, v, n, m ) \
+do { \
+ CARD32 *__p = (CARD32 *)v + 10 - vertsize; \
+ int __s = vertsize; \
+ if ( vertsize > 7 ) { \
+ LE32_OUT( vb++, (2 << 16) | \
+ ADRINDEX( MACH64_VERTEX_##n##_SECONDARY_S ) ); \
+ *vb++ = *__p++; \
+ *vb++ = *__p++; \
+ *vb++ = *__p++; \
+ __s -= 3; \
+ } \
+ LE32_OUT( vb++, ((__s - 1 + m) << 16) | \
+ (ADRINDEX( MACH64_VERTEX_##n##_X_Y ) - (__s - 1)) ); \
+ while ( __s-- ) { \
+ *vb++ = *__p++; \
+ } \
+} while (0)
+#endif
+
+#define COPY_VERTEX( vb, vertsize, v, n ) DO_COPY_VERTEX( vb, vertsize, v, n, 0 )
+#define COPY_VERTEX_OOA( vb, vertsize, v, n ) DO_COPY_VERTEX( vb, vertsize, v, n, 1 )
+
+
+static __inline void mach64_draw_quad( mach64ContextPtr mmesa,
+ mach64VertexPtr v0,
+ mach64VertexPtr v1,
+ mach64VertexPtr v2,
+ mach64VertexPtr v3 )
+{
+#if MACH64_NATIVE_VTXFMT
+ GLcontext *ctx = mmesa->glCtx;
+ const GLuint vertsize = mmesa->vertex_size;
+ GLint a;
+ GLfloat ooa;
+ GLuint xy;
+ const GLuint xyoffset = 9;
+ GLint xx[3], yy[3]; /* 2 fractional bits for hardware */
+ unsigned vbsiz = (vertsize + (vertsize > 7 ? 2 : 1)) * 4 + 2;
+ CARD32 *vb, *vbchk;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) {
+ fprintf(stderr, "%s:\n", __FUNCTION__);
+ fprintf(stderr,"Vertex 1:\n");
+ mach64_print_vertex( ctx, v0 );
+ fprintf(stderr,"Vertex 2:\n");
+ mach64_print_vertex( ctx, v1 );
+ fprintf(stderr,"Vertex 3:\n");
+ mach64_print_vertex( ctx, v2 );
+ fprintf(stderr,"Vertex 4:\n");
+ mach64_print_vertex( ctx, v3 );
+ }
+
+ xy = LE32_IN( &v0->ui[xyoffset] );
+ xx[0] = (GLshort)( xy >> 16 );
+ yy[0] = (GLshort)( xy & 0xffff );
+
+ xy = LE32_IN( &v1->ui[xyoffset] );
+ xx[1] = (GLshort)( xy >> 16 );
+ yy[1] = (GLshort)( xy & 0xffff );
+
+ xy = LE32_IN( &v3->ui[xyoffset] );
+ xx[2] = (GLshort)( xy >> 16 );
+ yy[2] = (GLshort)( xy & 0xffff );
+
+ a = (xx[0] - xx[2]) * (yy[1] - yy[2]) -
+ (yy[0] - yy[2]) * (xx[1] - xx[2]);
+
+ if ( (mmesa->backface_sign &&
+ ((a < 0 && !signbit( mmesa->backface_sign )) ||
+ (a > 0 && signbit( mmesa->backface_sign )))) ) {
+ /* cull quad */
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS )
+ fprintf(stderr,"Quad culled\n");
+ return;
+ }
+
+ ooa = 16.0 / a;
+
+ vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * sizeof(CARD32) );
+ vbchk = vb + vbsiz;
+
+ COPY_VERTEX( vb, vertsize, v0, 1 );
+ COPY_VERTEX( vb, vertsize, v1, 2 );
+ COPY_VERTEX_OOA( vb, vertsize, v3, 3 );
+ LE32_OUT( vb++, *(CARD32 *)&ooa );
+
+ xy = LE32_IN( &v2->ui[xyoffset] );
+ xx[0] = (GLshort)( xy >> 16 );
+ yy[0] = (GLshort)( xy & 0xffff );
+
+ a = (xx[0] - xx[2]) * (yy[1] - yy[2]) -
+ (yy[0] - yy[2]) * (xx[1] - xx[2]);
+
+ ooa = 16.0 / a;
+
+ COPY_VERTEX_OOA( vb, vertsize, v2, 1 );
+ LE32_OUT( vb++, *(CARD32 *)&ooa );
+
+ assert( vb == vbchk );
+
+#if MACH64_PRINT_BUFFER
+ {
+ int i;
+ fprintf(stderr, "quad:\n");
+ for (i = 0; i < vbsiz; i++)
+ fprintf(stderr, " %08lx\n", *(vb - vbsiz + i));
+ fprintf(stderr, "\n");
+ }
+#endif
+#else
+ GLuint vertsize = mmesa->vertex_size;
+ GLint coloridx;
+ GLfloat ooa;
+ GLint xx[3], yy[3]; /* 2 fractional bits for hardware */
+ unsigned vbsiz =
+ ((
+ 1 +
+ (vertsize > 6 ? 2 : 0) +
+ (vertsize > 4 ? 2 : 0) +
+ 3 +
+ (mmesa->multitex ? 4 : 0)
+ ) * 4 + 4);
+ CARD32 *vb;
+ unsigned vbidx = 0;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) {
+ fprintf(stderr, "%s:\n", __FUNCTION__);
+ fprintf(stderr,"Vertex 1: x: %.2f, y: %.2f, z: %.2f, w: %f\n\ts0: %f, t0: %f\n\ts1: %f, t1: %f\n",
+ v0->v.x, v0->v.y, v0->v.z, v0->v.w, v0->v.u0, v0->v.v0, v0->v.u1, v0->v.v1);
+ fprintf(stderr,"Vertex 2: x: %.2f, y: %.2f, z: %.2f, w: %f\n\ts0: %f, t0: %f\n\ts1: %f, t1: %f\n",
+ v1->v.x, v1->v.y, v1->v.z, v1->v.w, v1->v.u0, v1->v.v0, v1->v.u1, v1->v.v1);
+ fprintf(stderr,"Vertex 3: x: %.2f, y: %.2f, z: %.2f, w: %f\n\ts0: %f, t0: %f\n\ts1: %f, t1: %f\n",
+ v2->v.x, v2->v.y, v2->v.z, v2->v.w, v2->v.u0, v2->v.v0, v2->v.u1, v2->v.v1);
+ fprintf(stderr,"Vertex 4: x: %.2f, y: %.2f, z: %.2f, w: %f\n\ts0: %f, t0: %f\n\ts1: %f, t1: %f\n",
+ v3->v.x, v3->v.y, v3->v.z, v3->v.w, v3->v.u0, v3->v.v0, v3->v.u1, v3->v.v1);
+ }
+
+#if MACH64_CLIENT_STATE_EMITS
+ /* Enable for interleaved client-side state emits */
+ LOCK_HARDWARE( mmesa );
+ if ( mmesa->dirty ) {
+ mach64EmitHwStateLocked( mmesa );
+ }
+ if ( mmesa->sarea->dirty ) {
+ mach64UploadHwStateLocked( mmesa );
+ }
+ UNLOCK_HARDWARE( mmesa );
+#endif
+
+ xx[0] = (GLint)(v0->v.x * 4);
+ yy[0] = (GLint)(v0->v.y * 4);
+
+ xx[1] = (GLint)(v1->v.x * 4);
+ yy[1] = (GLint)(v1->v.y * 4);
+
+ xx[2] = (GLint)(v3->v.x * 4);
+ yy[2] = (GLint)(v3->v.y * 4);
+
+ ooa = 0.25 * 0.25 * ((xx[0] - xx[2]) * (yy[1] - yy[2]) -
+ (yy[0] - yy[2]) * (xx[1] - xx[2]));
+
+ if ( ooa * mmesa->backface_sign < 0 ) {
+ /* cull quad */
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS )
+ fprintf(stderr,"Quad culled\n");
+ return;
+ }
+
+ vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * 4 );
+
+ ooa = 1.0 / ooa;
+
+ coloridx = (vertsize > 4) ? 4: 3;
+
+ /* setup for 3,5, or 7 sequential reg writes based on vertex format */
+ switch (vertsize) {
+ case 6:
+ LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_1_W) );
+ break;
+ case 4:
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_Z) );
+ break;
+ default: /* vertsize >= 8 */
+ LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_1_S) );
+ break;
+ }
+ if (vertsize > 6) {
+ LE32_OUT( &vb[vbidx++], v0->ui[6] ); /* MACH64_VERTEX_1_S */
+ LE32_OUT( &vb[vbidx++], v0->ui[7] ); /* MACH64_VERTEX_1_T */
+ }
+ if (vertsize > 4) {
+ LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_1_W */
+ LE32_OUT( &vb[vbidx++], v0->ui[5] ); /* MACH64_VERTEX_1_SPEC_ARGB */
+ }
+ LE32_OUT( &vb[vbidx++], ((GLint)(v0->v.z) << 15) ); /* MACH64_VERTEX_1_Z */
+ vb[vbidx++] = v0->ui[coloridx]; /* MACH64_VERTEX_1_ARGB */
+ LE32_OUT( &vb[vbidx++], (xx[0] << 16) | (yy[0] & 0xffff) ); /* MACH64_VERTEX_1_X_Y */
+
+ if (mmesa->multitex) {
+ /* setup for 3 sequential reg writes */
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_SECONDARY_S) );
+ LE32_OUT( &vb[vbidx++], v0->ui[8] ); /* MACH64_VERTEX_1_SECONDARY_S */
+ LE32_OUT( &vb[vbidx++], v0->ui[9] ); /* MACH64_VERTEX_1_SECONDARY_T */
+ LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_1_SECONDARY_W */
+ }
+
+ /* setup for 3,5, or 7 sequential reg writes based on vertex format */
+ switch (vertsize) {
+ case 6:
+ LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_2_W) );
+ break;
+ case 4:
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_2_Z) );
+ break;
+ default: /* vertsize >= 8 */
+ LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_2_S) );
+ break;
+ }
+ if (vertsize > 6) {
+ LE32_OUT( &vb[vbidx++], v1->ui[6] ); /* MACH64_VERTEX_2_S */
+ LE32_OUT( &vb[vbidx++], v1->ui[7] ); /* MACH64_VERTEX_2_T */
+ }
+ if (vertsize > 4) {
+ LE32_OUT( &vb[vbidx++], v1->ui[3] ); /* MACH64_VERTEX_2_W */
+ LE32_OUT( &vb[vbidx++], v1->ui[5] ); /* MACH64_VERTEX_2_SPEC_ARGB */
+ }
+ LE32_OUT( &vb[vbidx++], ((GLint)(v1->v.z) << 15) ); /* MACH64_VERTEX_2_Z */
+ vb[vbidx++] = v1->ui[coloridx]; /* MACH64_VERTEX_2_ARGB */
+ LE32_OUT( &vb[vbidx++], (xx[1] << 16) | (yy[1] & 0xffff) ); /* MACH64_VERTEX_2_X_Y */
+
+ if (mmesa->multitex) {
+ /* setup for 3 sequential reg writes */
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_2_SECONDARY_S) );
+ LE32_OUT( &vb[vbidx++], v1->ui[8] ); /* MACH64_VERTEX_2_SECONDARY_S */
+ LE32_OUT( &vb[vbidx++], v1->ui[9] ); /* MACH64_VERTEX_2_SECONDARY_T */
+ LE32_OUT( &vb[vbidx++], v1->ui[3] ); /* MACH64_VERTEX_2_SECONDARY_W */
+ }
+
+ /* setup for 3,5, or 7 sequential reg writes based on vertex format */
+ switch (vertsize) {
+ case 6:
+ LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_3_W) );
+ break;
+ case 4:
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_3_Z) );
+ break;
+ default: /* vertsize >= 8 */
+ LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_3_S) );
+ break;
+ }
+ if (vertsize > 6) {
+ LE32_OUT( &vb[vbidx++], v3->ui[6] ); /* MACH64_VERTEX_3_S */
+ LE32_OUT( &vb[vbidx++], v3->ui[7] ); /* MACH64_VERTEX_3_T */
+ }
+ if (vertsize > 4) {
+ LE32_OUT( &vb[vbidx++], v3->ui[3] ); /* MACH64_VERTEX_3_W */
+ LE32_OUT( &vb[vbidx++], v3->ui[5] ); /* MACH64_VERTEX_3_SPEC_ARGB */
+ }
+ LE32_OUT( &vb[vbidx++], ((GLint)(v3->v.z) << 15) ); /* MACH64_VERTEX_3_Z */
+ vb[vbidx++] = v3->ui[coloridx]; /* MACH64_VERTEX_3_ARGB */
+ LE32_OUT( &vb[vbidx++], (xx[2] << 16) | (yy[2] & 0xffff) ); /* MACH64_VERTEX_3_X_Y */
+
+ if (mmesa->multitex) {
+ /* setup for 3 sequential reg writes */
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_3_SECONDARY_S) );
+ LE32_OUT( &vb[vbidx++], v3->ui[8] ); /* MACH64_VERTEX_3_SECONDARY_S */
+ LE32_OUT( &vb[vbidx++], v3->ui[9] ); /* MACH64_VERTEX_3_SECONDARY_T */
+ LE32_OUT( &vb[vbidx++], v3->ui[3] ); /* MACH64_VERTEX_3_SECONDARY_W */
+ }
+
+ LE32_OUT( &vb[vbidx++], ADRINDEX(MACH64_ONE_OVER_AREA_UC) );
+ LE32_OUT( &vb[vbidx++], *(GLuint *)&ooa );
+
+ xx[0] = (GLint)(v2->v.x * 4);
+ yy[0] = (GLint)(v2->v.y * 4);
+
+ ooa = 0.25 * 0.25 * ((xx[0] - xx[2]) * (yy[1] - yy[2]) -
+ (yy[0] - yy[2]) * (xx[1] - xx[2]));
+ ooa = 1.0 / ooa;
+
+ /* setup for 3,5, or 7 sequential reg writes based on vertex format */
+ switch (vertsize) {
+ case 6:
+ LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_1_W) );
+ break;
+ case 4:
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_Z) );
+ break;
+ default: /* vertsize >= 8 */
+ LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_1_S) );
+ break;
+ }
+ if (vertsize > 6) {
+ LE32_OUT( &vb[vbidx++], v2->ui[6] ); /* MACH64_VERTEX_1_S */
+ LE32_OUT( &vb[vbidx++], v2->ui[7] ); /* MACH64_VERTEX_1_T */
+ }
+ if (vertsize > 4) {
+ LE32_OUT( &vb[vbidx++], v2->ui[3] ); /* MACH64_VERTEX_1_W */
+ LE32_OUT( &vb[vbidx++], v2->ui[5] ); /* MACH64_VERTEX_1_SPEC_ARGB */
+ }
+ LE32_OUT( &vb[vbidx++], ((GLint)(v2->v.z) << 15) ); /* MACH64_VERTEX_1_Z */
+ vb[vbidx++] = v2->ui[coloridx]; /* MACH64_VERTEX_1_ARGB */
+ LE32_OUT( &vb[vbidx++], (xx[0] << 16) | (yy[0] & 0xffff) ); /* MACH64_VERTEX_1_X_Y */
+
+ if (mmesa->multitex) {
+ /* setup for 3 sequential reg writes */
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_SECONDARY_S) );
+ LE32_OUT( &vb[vbidx++], v2->ui[8] ); /* MACH64_VERTEX_1_SECONDARY_S */
+ LE32_OUT( &vb[vbidx++], v2->ui[9] ); /* MACH64_VERTEX_1_SECONDARY_T */
+ LE32_OUT( &vb[vbidx++], v2->ui[3] ); /* MACH64_VERTEX_1_SECONDARY_W */
+ }
+
+ LE32_OUT( &vb[vbidx++], ADRINDEX(MACH64_ONE_OVER_AREA_UC) );
+ LE32_OUT( &vb[vbidx++], *(GLuint *)&ooa );
+
+ assert(vbsiz == vbidx);
+
+#if MACH64_PRINT_BUFFER
+ {
+ int i;
+ fprintf(stderr, "quad:\n");
+ for (i = 0; i < vbsiz; i++)
+ fprintf(stderr, " %08lx\n", *(vb + i));
+ fprintf(stderr, "\n");
+ }
+#endif
+#endif
+}
+
+static __inline void mach64_draw_triangle( mach64ContextPtr mmesa,
+ mach64VertexPtr v0,
+ mach64VertexPtr v1,
+ mach64VertexPtr v2 )
+{
+#if MACH64_NATIVE_VTXFMT
+ GLcontext *ctx = mmesa->glCtx;
+ GLuint vertsize = mmesa->vertex_size;
+ GLint a;
+ GLfloat ooa;
+ GLuint xy;
+ const GLuint xyoffset = 9;
+ GLint xx[3], yy[3]; /* 2 fractional bits for hardware */
+ unsigned vbsiz = (vertsize + (vertsize > 7 ? 2 : 1)) * 3 + 1;
+ CARD32 *vb, *vbchk;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) {
+ fprintf(stderr, "%s:\n", __FUNCTION__);
+ fprintf(stderr,"Vertex 1:\n");
+ mach64_print_vertex( ctx, v0 );
+ fprintf(stderr,"Vertex 2:\n");
+ mach64_print_vertex( ctx, v1 );
+ fprintf(stderr,"Vertex 3:\n");
+ mach64_print_vertex( ctx, v2 );
+ }
+
+ xy = LE32_IN( &v0->ui[xyoffset] );
+ xx[0] = (GLshort)( xy >> 16 );
+ yy[0] = (GLshort)( xy & 0xffff );
+
+ xy = LE32_IN( &v1->ui[xyoffset] );
+ xx[1] = (GLshort)( xy >> 16 );
+ yy[1] = (GLshort)( xy & 0xffff );
+
+ xy = LE32_IN( &v2->ui[xyoffset] );
+ xx[2] = (GLshort)( xy >> 16 );
+ yy[2] = (GLshort)( xy & 0xffff );
+
+ a = (xx[0] - xx[2]) * (yy[1] - yy[2]) -
+ (yy[0] - yy[2]) * (xx[1] - xx[2]);
+
+ if ( mmesa->backface_sign &&
+ ((a < 0 && !signbit( mmesa->backface_sign )) ||
+ (a > 0 && signbit( mmesa->backface_sign ))) ) {
+ /* cull triangle */
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS )
+ fprintf(stderr,"Triangle culled\n");
+ return;
+ }
+
+ ooa = 16.0 / a;
+
+ vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * sizeof(CARD32) );
+ vbchk = vb + vbsiz;
+
+ COPY_VERTEX( vb, vertsize, v0, 1 );
+ COPY_VERTEX( vb, vertsize, v1, 2 );
+ COPY_VERTEX_OOA( vb, vertsize, v2, 3 );
+ LE32_OUT( vb++, *(CARD32 *)&ooa );
+
+ assert( vb == vbchk );
+
+#if MACH64_PRINT_BUFFER
+ {
+ int i;
+ fprintf(stderr, "tri:\n");
+ for (i = 0; i < vbsiz; i++)
+ fprintf(stderr, " %08lx\n", *(vb - vbsiz + i));
+ fprintf(stderr, "\n");
+ }
+#endif
+#else
+ GLuint vertsize = mmesa->vertex_size;
+ GLint coloridx;
+ GLfloat ooa;
+ GLint xx[3], yy[3]; /* 2 fractional bits for hardware */
+ unsigned vbsiz =
+ ((
+ 1 +
+ (vertsize > 6 ? 2 : 0) +
+ (vertsize > 4 ? 2 : 0) +
+ 3 +
+ (mmesa->multitex ? 4 : 0)
+ ) * 3 + 2);
+ CARD32 *vb;
+ unsigned vbidx = 0;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) {
+ fprintf(stderr, "%s:\n", __FUNCTION__);
+ fprintf(stderr,"Vertex 1: x: %.2f, y: %.2f, z: %.2f, w: %f\n\ts0: %f, t0: %f\n\ts1: %f, t1: %f\n",
+ v0->v.x, v0->v.y, v0->v.z, v0->v.w, v0->v.u0, v0->v.v0, v0->v.u1, v0->v.v1);
+ fprintf(stderr,"Vertex 2: x: %.2f, y: %.2f, z: %.2f, w: %f\n\ts0: %f, t0: %f\n\ts1: %f, t1: %f\n",
+ v1->v.x, v1->v.y, v1->v.z, v1->v.w, v1->v.u0, v1->v.v0, v1->v.u1, v1->v.v1);
+ fprintf(stderr,"Vertex 3: x: %.2f, y: %.2f, z: %.2f, w: %f\n\ts0: %f, t0: %f\n\ts1: %f, t1: %f\n",
+ v2->v.x, v2->v.y, v2->v.z, v2->v.w, v2->v.u0, v2->v.v0, v2->v.u1, v2->v.v1);
+ }
+
+#if MACH64_CLIENT_STATE_EMITS
+ /* Enable for interleaved client-side state emits */
+ LOCK_HARDWARE( mmesa );
+ if ( mmesa->dirty ) {
+ mach64EmitHwStateLocked( mmesa );
+ }
+ if ( mmesa->sarea->dirty ) {
+ mach64UploadHwStateLocked( mmesa );
+ }
+ UNLOCK_HARDWARE( mmesa );
+#endif
+
+ xx[0] = (GLint)(v0->v.x * 4);
+ yy[0] = (GLint)(v0->v.y * 4);
+
+ xx[1] = (GLint)(v1->v.x * 4);
+ yy[1] = (GLint)(v1->v.y * 4);
+
+ xx[2] = (GLint)(v2->v.x * 4);
+ yy[2] = (GLint)(v2->v.y * 4);
+
+ ooa = 0.25 * 0.25 * ((xx[0] - xx[2]) * (yy[1] - yy[2]) -
+ (yy[0] - yy[2]) * (xx[1] - xx[2]));
+
+ if ( ooa * mmesa->backface_sign < 0 ) {
+ /* cull triangle */
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS )
+ fprintf(stderr,"Triangle culled\n");
+ return;
+ }
+
+ vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * 4 );
+
+ ooa = 1.0 / ooa;
+
+ coloridx = (vertsize > 4) ? 4: 3;
+
+ /* setup for 3,5, or 7 sequential reg writes based on vertex format */
+ switch (vertsize) {
+ case 6:
+ LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_1_W) );
+ break;
+ case 4:
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_Z) );
+ break;
+ default: /* vertsize >= 8 */
+ LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_1_S) );
+ break;
+ }
+ if (vertsize > 6) {
+ LE32_OUT( &vb[vbidx++], v0->ui[6] ); /* MACH64_VERTEX_1_S */
+ LE32_OUT( &vb[vbidx++], v0->ui[7] ); /* MACH64_VERTEX_1_T */
+ }
+ if (vertsize > 4) {
+ LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_1_W */
+ LE32_OUT( &vb[vbidx++], v0->ui[5] ); /* MACH64_VERTEX_1_SPEC_ARGB */
+ }
+ LE32_OUT( &vb[vbidx++], ((GLint)(v0->v.z) << 15) ); /* MACH64_VERTEX_1_Z */
+ vb[vbidx++] = v0->ui[coloridx]; /* MACH64_VERTEX_1_ARGB */
+ LE32_OUT( &vb[vbidx++], (xx[0] << 16) | (yy[0] & 0xffff) ); /* MACH64_VERTEX_1_X_Y */
+
+ if (mmesa->multitex) {
+ /* setup for 3 sequential reg writes */
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_SECONDARY_S) );
+ LE32_OUT( &vb[vbidx++], v0->ui[8] ); /* MACH64_VERTEX_1_SECONDARY_S */
+ LE32_OUT( &vb[vbidx++], v0->ui[9] ); /* MACH64_VERTEX_1_SECONDARY_T */
+ LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_1_SECONDARY_W */
+ }
+
+ /* setup for 3,5, or 7 sequential reg writes based on vertex format */
+ switch (vertsize) {
+ case 6:
+ LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_2_W) );
+ break;
+ case 4:
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_2_Z) );
+ break;
+ default: /* vertsize >= 8 */
+ LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_2_S) );
+ break;
+ }
+ if (vertsize > 6) {
+ LE32_OUT( &vb[vbidx++], v1->ui[6] ); /* MACH64_VERTEX_2_S */
+ LE32_OUT( &vb[vbidx++], v1->ui[7] ); /* MACH64_VERTEX_2_T */
+ }
+ if (vertsize > 4) {
+ LE32_OUT( &vb[vbidx++], v1->ui[3] ); /* MACH64_VERTEX_2_W */
+ LE32_OUT( &vb[vbidx++], v1->ui[5] ); /* MACH64_VERTEX_2_SPEC_ARGB */
+ }
+ LE32_OUT( &vb[vbidx++], ((GLint)(v1->v.z) << 15) ); /* MACH64_VERTEX_2_Z */
+ vb[vbidx++] = v1->ui[coloridx]; /* MACH64_VERTEX_2_ARGB */
+ LE32_OUT( &vb[vbidx++], (xx[1] << 16) | (yy[1] & 0xffff) ); /* MACH64_VERTEX_2_X_Y */
+
+ if (mmesa->multitex) {
+ /* setup for 3 sequential reg writes */
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_2_SECONDARY_S) );
+ LE32_OUT( &vb[vbidx++], v1->ui[8] ); /* MACH64_VERTEX_2_SECONDARY_S */
+ LE32_OUT( &vb[vbidx++], v1->ui[9] ); /* MACH64_VERTEX_2_SECONDARY_T */
+ LE32_OUT( &vb[vbidx++], v1->ui[3] ); /* MACH64_VERTEX_2_SECONDARY_W */
+ }
+
+ /* setup for 3,5, or 7 sequential reg writes based on vertex format */
+ switch (vertsize) {
+ case 6:
+ LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_3_W) );
+ break;
+ case 4:
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_3_Z) );
+ break;
+ default: /* vertsize >= 8 */
+ LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_3_S) );
+ break;
+ }
+ if (vertsize > 6) {
+ LE32_OUT( &vb[vbidx++], v2->ui[6] ); /* MACH64_VERTEX_3_S */
+ LE32_OUT( &vb[vbidx++], v2->ui[7] ); /* MACH64_VERTEX_3_T */
+ }
+ if (vertsize > 4) {
+ LE32_OUT( &vb[vbidx++], v2->ui[3] ); /* MACH64_VERTEX_3_W */
+ LE32_OUT( &vb[vbidx++], v2->ui[5] ); /* MACH64_VERTEX_3_SPEC_ARGB */
+ }
+ LE32_OUT( &vb[vbidx++], ((GLint)(v2->v.z) << 15) ); /* MACH64_VERTEX_3_Z */
+ vb[vbidx++] = v2->ui[coloridx]; /* MACH64_VERTEX_3_ARGB */
+ LE32_OUT( &vb[vbidx++], (xx[2] << 16) | (yy[2] & 0xffff) ); /* MACH64_VERTEX_3_X_Y */
+
+ if (mmesa->multitex) {
+ /* setup for 3 sequential reg writes */
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_3_SECONDARY_S) );
+ LE32_OUT( &vb[vbidx++], v2->ui[8] ); /* MACH64_VERTEX_3_SECONDARY_S */
+ LE32_OUT( &vb[vbidx++], v2->ui[9] ); /* MACH64_VERTEX_3_SECONDARY_T */
+ LE32_OUT( &vb[vbidx++], v2->ui[3] ); /* MACH64_VERTEX_3_SECONDARY_W */
+ }
+
+ LE32_OUT( &vb[vbidx++], ADRINDEX(MACH64_ONE_OVER_AREA_UC) );
+ LE32_OUT( &vb[vbidx++], *(GLuint *)&ooa );
+
+ assert(vbsiz == vbidx);
+
+#if MACH64_PRINT_BUFFER
+ {
+ int i;
+ fprintf(stderr, "tri:\n");
+ for (i = 0; i < vbsiz; ++i)
+ fprintf(stderr, " %08lx\n", *(vb + i));
+ fprintf(stderr, "\n");
+ }
+#endif
+#endif
+}
+
+static __inline void mach64_draw_line( mach64ContextPtr mmesa,
+ mach64VertexPtr v0,
+ mach64VertexPtr v1 )
+{
+#if MACH64_NATIVE_VTXFMT
+ GLcontext *ctx = mmesa->glCtx;
+ const GLuint vertsize = mmesa->vertex_size;
+ GLint width = (GLint)(mmesa->glCtx->Line._Width * 2.0); /* 2 fractional bits for hardware */
+ GLfloat ooa;
+ GLuint *pxy0, *pxy1;
+ GLuint xy0old, xy0, xy1old, xy1;
+ const GLuint xyoffset = 9;
+ GLint x0, y0, x1, y1;
+ GLint dx, dy, ix, iy;
+ unsigned vbsiz = (vertsize + (vertsize > 7 ? 2 : 1)) * 4 + 2;
+ CARD32 *vb, *vbchk;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) {
+ fprintf(stderr, "%s:\n", __FUNCTION__);
+ fprintf(stderr,"Vertex 1:\n");
+ mach64_print_vertex( ctx, v0 );
+ fprintf(stderr,"Vertex 2:\n");
+ mach64_print_vertex( ctx, v1 );
+ }
+
+ if( !width )
+ width = 1; /* round to the nearest supported width */
+
+ pxy0 = &v0->ui[xyoffset];
+ xy0old = *pxy0;
+ xy0 = LE32_IN( &xy0old );
+ x0 = (GLshort)( xy0 >> 16 );
+ y0 = (GLshort)( xy0 & 0xffff );
+
+ pxy1 = &v1->ui[xyoffset];
+ xy1old = *pxy1;
+ xy1 = LE32_IN( &xy1old );
+ x1 = (GLshort)( xy1 >> 16 );
+ y1 = (GLshort)( xy1 & 0xffff );
+
+ if ( (dx = x1 - x0) < 0 ) {
+ dx = -dx;
+ }
+ if ( (dy = y1 - y0) < 0 ) {
+ dy = -dy;
+ }
+
+ /* adjust vertices depending on line direction */
+ if ( dx > dy ) {
+ ix = 0;
+ iy = width;
+ ooa = 8.0 / ((x1 - x0) * width);
+ } else {
+ ix = width;
+ iy = 0;
+ ooa = 8.0 / ((y0 - y1) * width);
+ }
+
+ vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * sizeof(CARD32) );
+ vbchk = vb + vbsiz;
+
+ LE32_OUT( pxy0, (( x0 - ix ) << 16) | (( y0 - iy ) & 0xffff) );
+ COPY_VERTEX( vb, vertsize, v0, 1 );
+ LE32_OUT( pxy1, (( x1 - ix ) << 16) | (( y1 - iy ) & 0xffff) );
+ COPY_VERTEX( vb, vertsize, v1, 2 );
+ LE32_OUT( pxy0, (( x0 + ix ) << 16) | (( y0 + iy ) & 0xffff) );
+ COPY_VERTEX_OOA( vb, vertsize, v0, 3 );
+ LE32_OUT( vb++, *(CARD32 *)&ooa );
+
+ ooa = -ooa;
+
+ LE32_OUT( pxy1, (( x1 + ix ) << 16) | (( y1 + iy ) & 0xffff) );
+ COPY_VERTEX_OOA( vb, vertsize, v1, 1 );
+ LE32_OUT( vb++, *(CARD32 *)&ooa );
+
+ *pxy0 = xy0old;
+ *pxy1 = xy1old;
+#else /* !MACH64_NATIVE_VTXFMT */
+ GLuint vertsize = mmesa->vertex_size;
+ GLint coloridx;
+ float width = 1.0; /* Only support 1 pix lines now */
+ GLfloat ooa;
+ GLint xx[3], yy[3]; /* 2 fractional bits for hardware */
+ unsigned vbsiz =
+ ((
+ 1 +
+ (vertsize > 6 ? 2 : 0) +
+ (vertsize > 4 ? 2 : 0) +
+ 3 +
+ (mmesa->multitex ? 4 : 0)
+ ) * 4 + 4);
+ CARD32 *vb;
+ unsigned vbidx = 0;
+
+ GLfloat hw, dx, dy, ix, iy;
+ GLfloat x0 = v0->v.x;
+ GLfloat y0 = v0->v.y;
+ GLfloat x1 = v1->v.x;
+ GLfloat y1 = v1->v.y;
+
+#if MACH64_CLIENT_STATE_EMITS
+ /* Enable for interleaved client-side state emits */
+ LOCK_HARDWARE( mmesa );
+ if ( mmesa->dirty ) {
+ mach64EmitHwStateLocked( mmesa );
+ }
+ if ( mmesa->sarea->dirty ) {
+ mach64UploadHwStateLocked( mmesa );
+ }
+ UNLOCK_HARDWARE( mmesa );
+#endif
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) {
+ fprintf(stderr, "%s:\n", __FUNCTION__);
+ fprintf(stderr,"Vertex 1: x: %.2f, y: %.2f, z: %.2f, w: %f\n",
+ v0->v.x, v0->v.y, v0->v.z, v0->v.w);
+ fprintf(stderr,"Vertex 2: x: %.2f, y: %.2f, z: %.2f, w: %f\n",
+ v1->v.x, v1->v.y, v1->v.z, v1->v.w);
+ }
+
+ hw = 0.5F * width;
+ if (hw > 0.1F && hw < 0.5F) {
+ hw = 0.5F;
+ }
+
+ /* adjust vertices depending on line direction */
+ dx = v0->v.x - v1->v.x;
+ dy = v0->v.y - v1->v.y;
+ if (dx * dx > dy * dy) {
+ /* X-major line */
+ ix = 0.0F;
+ iy = hw;
+ if (x1 < x0) {
+ x0 += 0.5F;
+ x1 += 0.5F;
+ }
+ y0 -= 0.5F;
+ y1 -= 0.5F;
+ }
+ else {
+ /* Y-major line */
+ ix = hw;
+ iy = 0.0F;
+ if (y1 > y0) {
+ y0 -= 0.5F;
+ y1 -= 0.5F;
+ }
+ x0 += 0.5F;
+ x1 += 0.5F;
+ }
+
+ xx[0] = (GLint)((x0 - ix) * 4);
+ yy[0] = (GLint)((y0 - iy) * 4);
+
+ xx[1] = (GLint)((x1 - ix) * 4);
+ yy[1] = (GLint)((y1 - iy) * 4);
+
+ xx[2] = (GLint)((x0 + ix) * 4);
+ yy[2] = (GLint)((y0 + iy) * 4);
+
+ ooa = 0.25 * 0.25 * ((xx[0] - xx[2]) * (yy[1] - yy[2]) -
+ (yy[0] - yy[2]) * (xx[1] - xx[2]));
+
+ if ( ooa * mmesa->backface_sign < 0 ) {
+ /* cull line */
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS )
+ fprintf(stderr,"Line culled\n");
+ return;
+ }
+
+ vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * 4 );
+
+ ooa = 1.0 / ooa;
+
+ coloridx = (vertsize > 4) ? 4: 3;
+
+ /* setup for 3,5, or 7 sequential reg writes based on vertex format */
+ switch (vertsize) {
+ case 6:
+ LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_1_W) );
+ break;
+ case 4:
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_Z) );
+ break;
+ default: /* vertsize >= 8 */
+ LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_1_S) );
+ break;
+ }
+ if (vertsize > 6) {
+ LE32_OUT( &vb[vbidx++], v0->ui[6] ); /* MACH64_VERTEX_1_S */
+ LE32_OUT( &vb[vbidx++], v0->ui[7] ); /* MACH64_VERTEX_1_T */
+ }
+ if (vertsize > 4) {
+ LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_1_W */
+ LE32_OUT( &vb[vbidx++], v0->ui[5] ); /* MACH64_VERTEX_1_SPEC_ARGB */
+ }
+ LE32_OUT( &vb[vbidx++], ((GLint)(v0->v.z) << 15) ); /* MACH64_VERTEX_1_Z */
+ vb[vbidx++] = v0->ui[coloridx]; /* MACH64_VERTEX_1_ARGB */
+ LE32_OUT( &vb[vbidx++], (xx[0] << 16) | (yy[0] & 0xffff) ); /* MACH64_VERTEX_1_X_Y */
+
+ /* setup for 3,5, or 7 sequential reg writes based on vertex format */
+ switch (vertsize) {
+ case 6:
+ LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_2_W) );
+ break;
+ case 4:
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_2_Z) );
+ break;
+ default: /* vertsize >= 8 */
+ LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_2_S) );
+ break;
+ }
+ if (vertsize > 6) {
+ LE32_OUT( &vb[vbidx++], v1->ui[6] ); /* MACH64_VERTEX_2_S */
+ LE32_OUT( &vb[vbidx++], v1->ui[7] ); /* MACH64_VERTEX_2_T */
+ }
+ if (vertsize > 4) {
+ LE32_OUT( &vb[vbidx++], v1->ui[3] ); /* MACH64_VERTEX_2_W */
+ LE32_OUT( &vb[vbidx++], v1->ui[5] ); /* MACH64_VERTEX_2_SPEC_ARGB */
+ }
+ LE32_OUT( &vb[vbidx++], ((GLint)(v1->v.z) << 15) ); /* MACH64_VERTEX_2_Z */
+ vb[vbidx++] = v1->ui[coloridx]; /* MACH64_VERTEX_2_ARGB */
+ LE32_OUT( &vb[vbidx++], (xx[1] << 16) | (yy[1] & 0xffff) ); /* MACH64_VERTEX_2_X_Y */
+
+ /* setup for 3,5, or 7 sequential reg writes based on vertex format */
+ switch (vertsize) {
+ case 6:
+ LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_3_W) );
+ break;
+ case 4:
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_3_Z) );
+ break;
+ default: /* vertsize >= 8 */
+ LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_3_S) );
+ break;
+ }
+ if (vertsize > 6) {
+ LE32_OUT( &vb[vbidx++], v0->ui[6] ); /* MACH64_VERTEX_3_S */
+ LE32_OUT( &vb[vbidx++], v0->ui[7] ); /* MACH64_VERTEX_3_T */
+ }
+ if (vertsize > 4) {
+ LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_3_W */
+ LE32_OUT( &vb[vbidx++], v0->ui[5] ); /* MACH64_VERTEX_3_SPEC_ARGB */
+ }
+ LE32_OUT( &vb[vbidx++], ((GLint)(v0->v.z) << 15) ); /* MACH64_VERTEX_3_Z */
+ vb[vbidx++] = v0->ui[coloridx]; /* MACH64_VERTEX_3_ARGB */
+ LE32_OUT( &vb[vbidx++], (xx[2] << 16) | (yy[2] & 0xffff) ); /* MACH64_VERTEX_3_X_Y */
+
+ LE32_OUT( &vb[vbidx++], ADRINDEX(MACH64_ONE_OVER_AREA_UC) );
+ LE32_OUT( &vb[vbidx++], *(GLuint *)&ooa );
+
+ xx[0] = (GLint)((x1 + ix) * 4);
+ yy[0] = (GLint)((y1 + iy) * 4);
+
+ ooa = 0.25 * 0.25 * ((xx[0] - xx[2]) * (yy[1] - yy[2]) -
+ (yy[0] - yy[2]) * (xx[1] - xx[2]));
+ ooa = 1.0 / ooa;
+
+ /* setup for 3,5, or 7 sequential reg writes based on vertex format */
+ switch (vertsize) {
+ case 6:
+ LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_1_W) );
+ break;
+ case 4:
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_Z) );
+ break;
+ default: /* vertsize >= 8 */
+ LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_1_S) );
+ break;
+ }
+ if (vertsize > 6) {
+ LE32_OUT( &vb[vbidx++], v1->ui[6] ); /* MACH64_VERTEX_1_S */
+ LE32_OUT( &vb[vbidx++], v1->ui[7] ); /* MACH64_VERTEX_1_T */
+ }
+ if (vertsize > 4) {
+ LE32_OUT( &vb[vbidx++], v1->ui[3] ); /* MACH64_VERTEX_1_W */
+ LE32_OUT( &vb[vbidx++], v1->ui[5] ); /* MACH64_VERTEX_1_SPEC_ARGB */
+ }
+ LE32_OUT( &vb[vbidx++], ((GLint)(v1->v.z) << 15) ); /* MACH64_VERTEX_1_Z */
+ vb[vbidx++] = v1->ui[coloridx]; /* MACH64_VERTEX_1_ARGB */
+ LE32_OUT( &vb[vbidx++], (xx[0] << 16) | (yy[0] & 0xffff) ); /* MACH64_VERTEX_1_X_Y */
+
+ LE32_OUT( &vb[vbidx++], ADRINDEX(MACH64_ONE_OVER_AREA_UC) );
+ LE32_OUT( &vb[vbidx++], *(GLuint *)&ooa );
+
+ assert(vbsiz == vbidx);
+#endif
+}
+
+static __inline void mach64_draw_point( mach64ContextPtr mmesa,
+ mach64VertexPtr v0 )
+{
+#if MACH64_NATIVE_VTXFMT
+ GLcontext *ctx = mmesa->glCtx;
+ const GLuint vertsize = mmesa->vertex_size;
+ GLint sz = (GLint)(mmesa->glCtx->Point._Size * 2.0); /* 2 fractional bits for hardware */
+ GLfloat ooa;
+ GLuint *pxy;
+ GLuint xyold, xy;
+ const GLuint xyoffset = 9;
+ GLint x, y;
+ unsigned vbsiz = (vertsize + (vertsize > 7 ? 2 : 1)) * 4 + 2;
+ CARD32 *vb, *vbchk;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) {
+ fprintf(stderr, "%s:\n", __FUNCTION__);
+ fprintf(stderr,"Vertex 1:\n");
+ mach64_print_vertex( ctx, v0 );
+ }
+
+ if( !sz )
+ sz = 1; /* round to the nearest supported size */
+
+ pxy = &v0->ui[xyoffset];
+ xyold = *pxy;
+ xy = LE32_IN( &xyold );
+ x = (GLshort)( xy >> 16 );
+ y = (GLshort)( xy & 0xffff );
+
+ ooa = 4.0 / (sz * sz);
+
+ vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * sizeof(CARD32) );
+ vbchk = vb + vbsiz;
+
+ LE32_OUT( pxy, (( x - sz ) << 16) | (( y - sz ) & 0xffff) );
+ COPY_VERTEX( vb, vertsize, v0, 1 );
+ LE32_OUT( pxy, (( x + sz ) << 16) | (( y - sz ) & 0xffff) );
+ COPY_VERTEX( vb, vertsize, v0, 2 );
+ LE32_OUT( pxy, (( x - sz ) << 16) | (( y + sz ) & 0xffff) );
+ COPY_VERTEX_OOA( vb, vertsize, v0, 3 );
+ LE32_OUT( vb++, *(CARD32 *)&ooa );
+
+ ooa = -ooa;
+
+ LE32_OUT( pxy, (( x + sz ) << 16) | (( y + sz ) & 0xffff) );
+ COPY_VERTEX_OOA( vb, vertsize, v0, 1 );
+ LE32_OUT( vb++, *(CARD32 *)&ooa );
+
+ *pxy = xyold;
+#else /* !MACH64_NATIVE_VTXFMT */
+ GLuint vertsize = mmesa->vertex_size;
+ GLint coloridx;
+ float sz = 1.0; /* Only support 1 pix points now */
+ GLfloat ooa;
+ GLint xx[3], yy[3]; /* 2 fractional bits for hardware */
+ unsigned vbsiz =
+ ((
+ 1 +
+ (vertsize > 6 ? 2 : 0) +
+ (vertsize > 4 ? 2 : 0) +
+ 3 +
+ (mmesa->multitex ? 4 : 0)
+ ) * 4 + 4);
+ CARD32 *vb;
+ unsigned vbidx = 0;
+
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS ) {
+ fprintf(stderr, "%s:\n", __FUNCTION__);
+ fprintf(stderr,"Vertex 1: x: %.2f, y: %.2f, z: %.2f, w: %f\n",
+ v0->v.x, v0->v.y, v0->v.z, v0->v.w);
+ }
+
+#if MACH64_CLIENT_STATE_EMITS
+ /* Enable for interleaved client-side state emits */
+ LOCK_HARDWARE( mmesa );
+ if ( mmesa->dirty ) {
+ mach64EmitHwStateLocked( mmesa );
+ }
+ if ( mmesa->sarea->dirty ) {
+ mach64UploadHwStateLocked( mmesa );
+ }
+ UNLOCK_HARDWARE( mmesa );
+#endif
+
+ xx[0] = (GLint)((v0->v.x - sz) * 4);
+ yy[0] = (GLint)((v0->v.y - sz) * 4);
+
+ xx[1] = (GLint)((v0->v.x + sz) * 4);
+ yy[1] = (GLint)((v0->v.y - sz) * 4);
+
+ xx[2] = (GLint)((v0->v.x - sz) * 4);
+ yy[2] = (GLint)((v0->v.y + sz) * 4);
+
+ ooa = 0.25 * 0.25 * ((xx[0] - xx[2]) * (yy[1] - yy[2]) -
+ (yy[0] - yy[2]) * (xx[1] - xx[2]));
+
+ if ( ooa * mmesa->backface_sign < 0 ) {
+ /* cull quad */
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS )
+ fprintf(stderr,"Point culled\n");
+ return;
+ }
+
+ vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * 4 );
+
+ ooa = 1.0 / ooa;
+
+ coloridx = (vertsize > 4) ? 4: 3;
+
+ /* setup for 3,5, or 7 sequential reg writes based on vertex format */
+ switch (vertsize) {
+ case 6:
+ LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_1_W) );
+ break;
+ case 4:
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_Z) );
+ break;
+ default: /* vertsize >= 8 */
+ LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_1_S) );
+ break;
+ }
+ if (vertsize > 6) {
+ LE32_OUT( &vb[vbidx++], v0->ui[6] ); /* MACH64_VERTEX_1_S */
+ LE32_OUT( &vb[vbidx++], v0->ui[7] ); /* MACH64_VERTEX_1_T */
+ }
+ if (vertsize > 4) {
+ LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_1_W */
+ LE32_OUT( &vb[vbidx++], v0->ui[5] ); /* MACH64_VERTEX_1_SPEC_ARGB */
+ }
+ LE32_OUT( &vb[vbidx++], ((GLint)(v0->v.z) << 15) ); /* MACH64_VERTEX_1_Z */
+ vb[vbidx++] = v0->ui[coloridx]; /* MACH64_VERTEX_1_ARGB */
+ LE32_OUT( &vb[vbidx++], (xx[0] << 16) | (yy[0] & 0xffff) ); /* MACH64_VERTEX_1_X_Y */
+
+ /* setup for 3,5, or 7 sequential reg writes based on vertex format */
+ switch (vertsize) {
+ case 6:
+ LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_2_W) );
+ break;
+ case 4:
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_2_Z) );
+ break;
+ default: /* vertsize >= 8 */
+ LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_2_S) );
+ break;
+ }
+ if (vertsize > 6) {
+ LE32_OUT( &vb[vbidx++], v0->ui[6] ); /* MACH64_VERTEX_2_S */
+ LE32_OUT( &vb[vbidx++], v0->ui[7] ); /* MACH64_VERTEX_2_T */
+ }
+ if (vertsize > 4) {
+ LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_2_W */
+ LE32_OUT( &vb[vbidx++], v0->ui[5] ); /* MACH64_VERTEX_2_SPEC_ARGB */
+ }
+ LE32_OUT( &vb[vbidx++], ((GLint)(v0->v.z) << 15) ); /* MACH64_VERTEX_2_Z */
+ vb[vbidx++] = v0->ui[coloridx]; /* MACH64_VERTEX_2_ARGB */
+ LE32_OUT( &vb[vbidx++], (xx[1] << 16) | (yy[1] & 0xffff) ); /* MACH64_VERTEX_2_X_Y */
+
+ /* setup for 3,5, or 7 sequential reg writes based on vertex format */
+ switch (vertsize) {
+ case 6:
+ LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_3_W) );
+ break;
+ case 4:
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_3_Z) );
+ break;
+ default: /* vertsize >= 8 */
+ LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_3_S) );
+ break;
+ }
+ if (vertsize > 6) {
+ LE32_OUT( &vb[vbidx++], v0->ui[6] ); /* MACH64_VERTEX_3_S */
+ LE32_OUT( &vb[vbidx++], v0->ui[7] ); /* MACH64_VERTEX_3_T */
+ }
+ if (vertsize > 4) {
+ LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_3_W */
+ LE32_OUT( &vb[vbidx++], v0->ui[5] ); /* MACH64_VERTEX_3_SPEC_ARGB */
+ }
+ LE32_OUT( &vb[vbidx++], ((GLint)(v0->v.z) << 15) ); /* MACH64_VERTEX_3_Z */
+ vb[vbidx++] = v0->ui[coloridx]; /* MACH64_VERTEX_3_ARGB */
+ LE32_OUT( &vb[vbidx++], (xx[2] << 16) | (yy[2] & 0xffff) ); /* MACH64_VERTEX_3_X_Y */
+
+ LE32_OUT( &vb[vbidx++], ADRINDEX(MACH64_ONE_OVER_AREA_UC) );
+ LE32_OUT( &vb[vbidx++], *(GLuint *)&ooa );
+
+ xx[0] = (GLint)((v0->v.x + sz) * 4);
+ yy[0] = (GLint)((v0->v.y + sz) * 4);
+
+ ooa = 0.25 * 0.25 * ((xx[0] - xx[2]) * (yy[1] - yy[2]) -
+ (yy[0] - yy[2]) * (xx[1] - xx[2]));
+ ooa = 1.0 / ooa;
+
+ /* setup for 3,5, or 7 sequential reg writes based on vertex format */
+ switch (vertsize) {
+ case 6:
+ LE32_OUT( &vb[vbidx++], (4 << 16) | ADRINDEX(MACH64_VERTEX_1_W) );
+ break;
+ case 4:
+ LE32_OUT( &vb[vbidx++], (2 << 16) | ADRINDEX(MACH64_VERTEX_1_Z) );
+ break;
+ default: /* vertsize >= 8 */
+ LE32_OUT( &vb[vbidx++], (6 << 16) | ADRINDEX(MACH64_VERTEX_1_S) );
+ break;
+ }
+ if (vertsize > 6) {
+ LE32_OUT( &vb[vbidx++], v0->ui[6] ); /* MACH64_VERTEX_1_S */
+ LE32_OUT( &vb[vbidx++], v0->ui[7] ); /* MACH64_VERTEX_1_T */
+ }
+ if (vertsize > 4) {
+ LE32_OUT( &vb[vbidx++], v0->ui[3] ); /* MACH64_VERTEX_1_W */
+ LE32_OUT( &vb[vbidx++], v0->ui[5] ); /* MACH64_VERTEX_1_SPEC_ARGB */
+ }
+ LE32_OUT( &vb[vbidx++], ((GLint)(v0->v.z) << 15) ); /* MACH64_VERTEX_1_Z */
+ vb[vbidx++] = v0->ui[coloridx]; /* MACH64_VERTEX_1_ARGB */
+ LE32_OUT( &vb[vbidx++], (xx[0] << 16) | (yy[0] & 0xffff) ); /* MACH64_VERTEX_1_X_Y */
+
+ LE32_OUT( &vb[vbidx++], ADRINDEX(MACH64_ONE_OVER_AREA_UC) );
+ LE32_OUT( &vb[vbidx++], *(GLuint *)&ooa );
+
+ assert(vbsiz == vbidx);
+#endif
+}
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ if (DO_FALLBACK) \
+ mmesa->draw_tri( mmesa, a, b, c ); \
+ else \
+ mach64_draw_triangle( mmesa, a, b, c ); \
+} while (0)
+
+#define QUAD( a, b, c, d ) \
+do { \
+ if (DO_FALLBACK) { \
+ mmesa->draw_tri( mmesa, a, b, d ); \
+ mmesa->draw_tri( mmesa, b, c, d ); \
+ } else \
+ mach64_draw_quad( mmesa, a, b, c, d ); \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ if (DO_FALLBACK) \
+ mmesa->draw_line( mmesa, v0, v1 ); \
+ else \
+ mach64_draw_line( mmesa, v0, v1 ); \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ if (DO_FALLBACK) \
+ mmesa->draw_point( mmesa, v0 ); \
+ else \
+ mach64_draw_point( mmesa, v0 ); \
+} while (0)
+
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define MACH64_OFFSET_BIT 0x01
+#define MACH64_TWOSIDE_BIT 0x02
+#define MACH64_UNFILLED_BIT 0x04
+#define MACH64_FALLBACK_BIT 0x08
+#define MACH64_MAX_TRIFUNC 0x10
+
+static struct {
+ tnl_points_func points;
+ tnl_line_func line;
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
+} rast_tab[MACH64_MAX_TRIFUNC];
+
+
+#define DO_FALLBACK (IND & MACH64_FALLBACK_BIT)
+#define DO_OFFSET (IND & MACH64_OFFSET_BIT)
+#define DO_UNFILLED (IND & MACH64_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & MACH64_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 1
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX mach64Vertex
+#define TAB rast_tab
+
+#if MACH64_NATIVE_VTXFMT
+
+/* #define DEPTH_SCALE 65536.0 */
+#define DEPTH_SCALE 1
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) ((GLfloat)(GLshort)(LE32_IN( &(_v)->ui[xyoffset] ) & 0xffff) / 4.0)
+#define VERT_Y(_v) ((GLfloat)(GLshort)(LE32_IN( &(_v)->ui[xyoffset] ) >> 16) / 4.0)
+#define VERT_Z(_v) ((GLfloat) LE32_IN( &(_v)->ui[zoffset] ))
+#define INSANE_VERTICES
+#define VERT_SET_Z(_v,val) LE32_OUT( &(_v)->ui[zoffset], (GLuint)(val) )
+#define VERT_Z_ADD(_v,val) LE32_OUT( &(_v)->ui[zoffset], LE32_IN( &(_v)->ui[zoffset] ) + (GLuint)(val) )
+#define AREA_IS_CCW( a ) ((a) < 0)
+#define GET_VERTEX(e) (mmesa->verts + ((e) * mmesa->vertex_size * sizeof(int)))
+
+#define MACH64_COLOR( dst, src ) \
+do { \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[0], src[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[1], src[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[2], src[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[3], src[3]); \
+} while (0)
+
+#define MACH64_SPEC( dst, src ) \
+do { \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[0], src[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[1], src[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[2], src[0]); \
+} while (0)
+
+#define VERT_SET_RGBA( v, c ) MACH64_COLOR( v->ub4[coloroffset], c )
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
+
+#define VERT_SET_SPEC( v, c ) if (havespec) MACH64_SPEC( v->ub4[specoffset], c )
+#define VERT_COPY_SPEC( v0, v1 ) if (havespec) COPY_3V( v0->ub4[specoffset], v1->ub4[specoffset] )
+#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[specoffset]
+#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[specoffset] = spec[idx]
+
+#define LOCAL_VARS(n) \
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); \
+ GLuint color[n], spec[n]; \
+ GLuint vertex_size = mmesa->vertex_size; \
+ const GLuint xyoffset = 9; \
+ const GLuint coloroffset = 8; \
+ const GLuint zoffset = 7; \
+ const GLuint specoffset = 6; \
+ GLboolean havespec = vertex_size >= 4 ? 1 : 0; \
+ (void) color; (void) spec; (void) vertex_size; \
+ (void) xyoffset; (void) coloroffset; (void) zoffset; \
+ (void) specoffset; (void) havespec;
+
+#else
+
+#define DEPTH_SCALE 1.0
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a > 0)
+#define GET_VERTEX(e) (mmesa->verts + ((e) * mmesa->vertex_size * sizeof(int)))
+
+#define MACH64_COLOR( dst, src ) \
+do { \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[0], src[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[1], src[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[2], src[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[3], src[3]); \
+} while (0)
+
+#define MACH64_SPEC( dst, src ) \
+do { \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[0], src[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[1], src[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[2], src[0]); \
+} while (0)
+
+#define VERT_SET_RGBA( v, c ) MACH64_COLOR( v->ub4[coloroffset], c )
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
+
+#define VERT_SET_SPEC( v, c ) if (havespec) MACH64_SPEC( v->ub4[5], c )
+#define VERT_COPY_SPEC( v0, v1 ) if (havespec) COPY_3V(v0->ub4[5], v1->ub4[5])
+#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[5]
+#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx]
+
+#define LOCAL_VARS(n) \
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); \
+ GLuint color[n], spec[n]; \
+ GLuint coloroffset = (mmesa->vertex_size == 4 ? 3 : 4); \
+ GLboolean havespec = (mmesa->vertex_size == 4 ? 0 : 1); \
+ (void) color; (void) spec; (void) coloroffset; (void) havespec;
+
+#endif
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+#define RASTERIZE(x) if (mmesa->hw_primitive != hw_prim[x]) \
+ mach64RasterPrimitive( ctx, hw_prim[x] )
+#define RENDER_PRIMITIVE mmesa->render_primitive
+#define IND MACH64_FALLBACK_BIT
+#define TAG(x) x
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
+
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MACH64_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MACH64_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MACH64_TWOSIDE_BIT|MACH64_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MACH64_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MACH64_OFFSET_BIT|MACH64_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MACH64_TWOSIDE_BIT|MACH64_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MACH64_TWOSIDE_BIT|MACH64_OFFSET_BIT|MACH64_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MACH64_FALLBACK_BIT)
+#define TAG(x) x##_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MACH64_OFFSET_BIT|MACH64_FALLBACK_BIT)
+#define TAG(x) x##_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MACH64_TWOSIDE_BIT|MACH64_FALLBACK_BIT)
+#define TAG(x) x##_twoside_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MACH64_TWOSIDE_BIT|MACH64_OFFSET_BIT|MACH64_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MACH64_UNFILLED_BIT|MACH64_FALLBACK_BIT)
+#define TAG(x) x##_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MACH64_OFFSET_BIT|MACH64_UNFILLED_BIT|MACH64_FALLBACK_BIT)
+#define TAG(x) x##_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MACH64_TWOSIDE_BIT|MACH64_UNFILLED_BIT|MACH64_FALLBACK_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MACH64_TWOSIDE_BIT|MACH64_OFFSET_BIT|MACH64_UNFILLED_BIT| \
+ MACH64_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+static void init_rast_tab( void )
+{
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+ init_fallback();
+ init_offset_fallback();
+ init_twoside_fallback();
+ init_twoside_offset_fallback();
+ init_unfilled_fallback();
+ init_offset_unfilled_fallback();
+ init_twoside_unfilled_fallback();
+ init_twoside_offset_unfilled_fallback();
+}
+
+
+/***********************************************************************
+ * Rasterization fallback helpers *
+ ***********************************************************************/
+
+
+/* This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+static void
+mach64_fallback_tri( mach64ContextPtr mmesa,
+ mach64Vertex *v0,
+ mach64Vertex *v1,
+ mach64Vertex *v2 )
+{
+ GLcontext *ctx = mmesa->glCtx;
+ SWvertex v[3];
+ mach64_translate_vertex( ctx, v0, &v[0] );
+ mach64_translate_vertex( ctx, v1, &v[1] );
+ mach64_translate_vertex( ctx, v2, &v[2] );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+}
+
+
+static void
+mach64_fallback_line( mach64ContextPtr mmesa,
+ mach64Vertex *v0,
+ mach64Vertex *v1 )
+{
+ GLcontext *ctx = mmesa->glCtx;
+ SWvertex v[2];
+ mach64_translate_vertex( ctx, v0, &v[0] );
+ mach64_translate_vertex( ctx, v1, &v[1] );
+ _swrast_Line( ctx, &v[0], &v[1] );
+}
+
+
+static void
+mach64_fallback_point( mach64ContextPtr mmesa,
+ mach64Vertex *v0 )
+{
+ GLcontext *ctx = mmesa->glCtx;
+ SWvertex v[1];
+ mach64_translate_vertex( ctx, v0, &v[0] );
+ _swrast_Point( ctx, &v[0] );
+}
+
+
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+#define VERT(x) (mach64Vertex *)(mach64verts + ((x) * vertsize * sizeof(int)))
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ mach64_draw_point( mmesa, VERT(start) )
+#define RENDER_LINE( v0, v1 ) \
+ mach64_draw_line( mmesa, VERT(v0), VERT(v1) )
+#define RENDER_TRI( v0, v1, v2 ) \
+ mach64_draw_triangle( mmesa, VERT(v0), VERT(v1), VERT(v2) )
+#define RENDER_QUAD( v0, v1, v2, v3 ) \
+ mach64_draw_quad( mmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
+#define INIT(x) do { \
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__); \
+ mach64RenderPrimitive( ctx, x ); \
+} while (0)
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); \
+ const GLuint vertsize = mmesa->vertex_size; \
+ const char *mach64verts = (char *)mmesa->verts; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ (void) elt;
+#define RESET_STIPPLE
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) (x)
+#define TAG(x) mach64_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+#undef ELT
+#undef TAG
+#define TAG(x) mach64_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl/t_vb_rendertmp.h"
+
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+static void mach64RenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLuint prim = mmesa->render_primitive;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+ }
+
+ /* Restore the render primitive
+ */
+ if (prim != GL_POLYGON)
+ tnl->Driver.Render.PrimitiveNotify( ctx, prim );
+
+}
+
+static void mach64RenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Line( ctx, ii, jj );
+}
+
+#if MACH64_NATIVE_VTXFMT
+static void mach64FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT( ctx );
+ const GLuint vertsize = mmesa->vertex_size;
+ GLint a;
+ GLfloat ooa;
+ GLuint xy;
+ const GLuint xyoffset = 9;
+ GLint xx[3], yy[3]; /* 2 fractional bits for hardware */
+ unsigned vbsiz = (vertsize + (vertsize > 7 ? 2 : 1)) * n + (n-2);
+ CARD32 *vb, *vbchk;
+ GLubyte *mach64verts = (GLubyte *)mmesa->verts;
+ mach64VertexPtr v0, v1, v2;
+ int i;
+
+ v0 = (mach64VertexPtr)VERT(elts[1]);
+ v1 = (mach64VertexPtr)VERT(elts[2]);
+ v2 = (mach64VertexPtr)VERT(elts[0]);
+
+ xy = LE32_IN( &v0->ui[xyoffset] );
+ xx[0] = (GLshort)( xy >> 16 );
+ yy[0] = (GLshort)( xy & 0xffff );
+
+ xy = LE32_IN( &v1->ui[xyoffset] );
+ xx[1] = (GLshort)( xy >> 16 );
+ yy[1] = (GLshort)( xy & 0xffff );
+
+ xy = LE32_IN( &v2->ui[xyoffset] );
+ xx[2] = (GLshort)( xy >> 16 );
+ yy[2] = (GLshort)( xy & 0xffff );
+
+ a = (xx[0] - xx[2]) * (yy[1] - yy[2]) -
+ (yy[0] - yy[2]) * (xx[1] - xx[2]);
+
+ if ( (mmesa->backface_sign &&
+ ((a < 0 && !signbit( mmesa->backface_sign )) ||
+ (a > 0 && signbit( mmesa->backface_sign )))) ) {
+ /* cull polygon */
+ if ( MACH64_DEBUG & DEBUG_VERBOSE_PRIMS )
+ fprintf(stderr,"Polygon culled\n");
+ return;
+ }
+
+ ooa = 16.0 / a;
+
+ vb = (CARD32 *)mach64AllocDmaLow( mmesa, vbsiz * sizeof(CARD32) );
+ vbchk = vb + vbsiz;
+
+ COPY_VERTEX( vb, vertsize, v0, 1 );
+ COPY_VERTEX( vb, vertsize, v1, 2 );
+ COPY_VERTEX_OOA( vb, vertsize, v2, 3 );
+ LE32_OUT( vb++, *(CARD32 *)&ooa );
+
+ i = 3;
+ while (1) {
+ if (i >= n)
+ break;
+ v0 = (mach64VertexPtr)VERT(elts[i]);
+ i++;
+
+ xy = LE32_IN( &v0->ui[xyoffset] );
+ xx[0] = (GLshort)( xy >> 16 );
+ yy[0] = (GLshort)( xy & 0xffff );
+
+ a = (xx[0] - xx[2]) * (yy[1] - yy[2]) -
+ (yy[0] - yy[2]) * (xx[1] - xx[2]);
+ ooa = 16.0 / a;
+
+ COPY_VERTEX_OOA( vb, vertsize, v0, 1 );
+ LE32_OUT( vb++, *(CARD32 *)&ooa );
+
+ if (i >= n)
+ break;
+ v1 = (mach64VertexPtr)VERT(elts[i]);
+ i++;
+
+ xy = LE32_IN( &v1->ui[xyoffset] );
+ xx[1] = (GLshort)( xy >> 16 );
+ yy[1] = (GLshort)( xy & 0xffff );
+
+ a = (xx[0] - xx[2]) * (yy[1] - yy[2]) -
+ (yy[0] - yy[2]) * (xx[1] - xx[2]);
+ ooa = 16.0 / a;
+
+ COPY_VERTEX_OOA( vb, vertsize, v1, 2 );
+ LE32_OUT( vb++, *(CARD32 *)&ooa );
+ }
+
+ assert( vb == vbchk );
+}
+#else
+static void mach64FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT( ctx );
+ const GLuint vertsize = mmesa->vertex_size;
+ GLubyte *mach64verts = (GLubyte *)mmesa->verts;
+ const GLuint *start = (const GLuint *)VERT(elts[0]);
+ int i;
+
+ for (i = 2 ; i < n ; i++) {
+ mach64_draw_triangle( mmesa,
+ VERT(elts[i-1]),
+ VERT(elts[i]),
+ (mach64VertexPtr) start
+ );
+ }
+}
+#endif /* MACH64_NATIVE_VTXFMT */
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+#define _MACH64_NEW_RENDER_STATE (_DD_NEW_POINT_SMOOTH | \
+ _DD_NEW_LINE_SMOOTH | \
+ _DD_NEW_LINE_STIPPLE | \
+ _DD_NEW_TRI_SMOOTH | \
+ _DD_NEW_TRI_STIPPLE | \
+ _NEW_POLYGONSTIPPLE | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET) \
+
+#define POINT_FALLBACK (DD_POINT_SMOOTH)
+#define LINE_FALLBACK (DD_LINE_SMOOTH|DD_LINE_STIPPLE)
+#define TRI_FALLBACK (DD_TRI_SMOOTH|DD_TRI_STIPPLE)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)
+#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
+
+
+static void mach64ChooseRenderState(GLcontext *ctx)
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ if (flags & (ANY_RASTER_FLAGS|ANY_FALLBACK_FLAGS)) {
+ mmesa->draw_point = mach64_draw_point;
+ mmesa->draw_line = mach64_draw_line;
+ mmesa->draw_tri = mach64_draw_triangle;
+
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= MACH64_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= MACH64_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= MACH64_UNFILLED_BIT;
+ }
+
+ /* Hook in fallbacks for specific primitives.
+ */
+ if (flags & (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)) {
+ if (flags & POINT_FALLBACK) mmesa->draw_point = mach64_fallback_point;
+ if (flags & LINE_FALLBACK) mmesa->draw_line = mach64_fallback_line;
+ if (flags & TRI_FALLBACK) mmesa->draw_tri = mach64_fallback_tri;
+ index |= MACH64_FALLBACK_BIT;
+ }
+ }
+
+ if (index != mmesa->RenderIndex) {
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = mach64_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = mach64_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = rast_tab[index].line;
+ tnl->Driver.Render.ClippedPolygon = mach64FastRenderClippedPoly;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = mach64RenderClippedLine;
+ tnl->Driver.Render.ClippedPolygon = mach64RenderClippedPoly;
+ }
+
+ mmesa->RenderIndex = index;
+ }
+}
+
+/**********************************************************************/
+/* Validate state at pipeline start */
+/**********************************************************************/
+
+static void mach64RunPipeline( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ if (mmesa->new_state)
+ mach64DDUpdateHWState( ctx );
+
+ if (!mmesa->Fallback && mmesa->NewGLState) {
+ if (mmesa->NewGLState & _MACH64_NEW_VERTEX_STATE)
+ mach64ChooseVertexState( ctx );
+
+ if (mmesa->NewGLState & _MACH64_NEW_RENDER_STATE)
+ mach64ChooseRenderState( ctx );
+
+ mmesa->NewGLState = 0;
+ }
+
+ _tnl_run_pipeline( ctx );
+}
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+/* 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.
+ */
+
+static void mach64RasterPrimitive( GLcontext *ctx, GLuint hwprim )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+
+ mmesa->new_state |= MACH64_NEW_CONTEXT;
+ mmesa->dirty |= MACH64_UPLOAD_CONTEXT;
+
+ if (mmesa->hw_primitive != hwprim) {
+ FLUSH_BATCH( mmesa );
+ mmesa->hw_primitive = hwprim;
+ }
+}
+
+static void mach64RenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ GLuint hw = hw_prim[prim];
+
+ mmesa->render_primitive = prim;
+
+ if (prim >= GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ return;
+
+ mach64RasterPrimitive( ctx, hw );
+}
+
+
+static void mach64RenderStart( GLcontext *ctx )
+{
+ /* Check for projective texturing. Make sure all texcoord
+ * pointers point to something. (fix in mesa?)
+ */
+ mach64CheckTexSizes( ctx );
+}
+
+static void mach64RenderFinish( GLcontext *ctx )
+{
+ if (MACH64_CONTEXT(ctx)->RenderIndex & MACH64_FALLBACK_BIT)
+ _swrast_flush( ctx );
+}
+
+
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+
+static const char * const fallbackStrings[] = {
+ "Texture mode",
+ "glDrawBuffer(GL_FRONT_AND_BACK)",
+ "glReadBuffer",
+ "glEnable(GL_STENCIL) without hw stencil buffer",
+ "glRenderMode(selection or feedback)",
+ "glLogicOp (mode != GL_COPY)",
+ "GL_SEPARATE_SPECULAR_COLOR",
+ "glBlendEquation (mode != ADD)",
+ "glBlendFunc",
+ "Rasterization disable",
+};
+
+
+static const char *getFallbackString(GLuint bit)
+{
+ int i = 0;
+ while (bit > 1) {
+ i++;
+ bit >>= 1;
+ }
+ return fallbackStrings[i];
+}
+
+void mach64Fallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ GLuint oldfallback = mmesa->Fallback;
+
+ if (mode) {
+ mmesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ FLUSH_BATCH( mmesa );
+ _swsetup_Wakeup( ctx );
+ mmesa->RenderIndex = ~0;
+ if (MACH64_DEBUG & DEBUG_VERBOSE_FALLBACK) {
+ fprintf(stderr, "Mach64 begin rasterization fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ }
+ }
+ else {
+ mmesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = mach64RenderStart;
+ tnl->Driver.Render.PrimitiveNotify = mach64RenderPrimitive;
+ tnl->Driver.Render.Finish = mach64RenderFinish;
+ tnl->Driver.Render.BuildVertices = mach64BuildVertices;
+ mmesa->NewGLState |= (_MACH64_NEW_RENDER_STATE|
+ _MACH64_NEW_VERTEX_STATE);
+ if (MACH64_DEBUG & DEBUG_VERBOSE_FALLBACK) {
+ fprintf(stderr, "Mach64 end rasterization fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ }
+ }
+}
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+void mach64InitTriFuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+ }
+
+ tnl->Driver.RunPipeline = mach64RunPipeline;
+ tnl->Driver.Render.Start = mach64RenderStart;
+ tnl->Driver.Render.Finish = mach64RenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = mach64RenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = mach64BuildVertices;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_tris.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_tris.h
new file mode 100644
index 000000000..208703289
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_tris.h
@@ -0,0 +1,43 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#ifndef __MACH64_TRIS_H__
+#define __MACH64_TRIS_H__
+
+#include "mtypes.h"
+
+extern void mach64InitTriFuncs( GLcontext *ctx );
+
+
+extern void mach64Fallback( GLcontext *ctx, GLuint bit, GLboolean mode );
+#define FALLBACK( mmesa, bit, mode ) mach64Fallback( mmesa->glCtx, bit, mode )
+
+
+#endif /* __MACH64_TRIS_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_vb.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_vb.c
new file mode 100644
index 000000000..83a5f73e6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_vb.c
@@ -0,0 +1,642 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "imports.h"
+#include "macros.h"
+#include "colormac.h"
+
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/t_context.h"
+
+#include "mach64_context.h"
+#include "mach64_vb.h"
+#include "mach64_ioctl.h"
+#include "mach64_tris.h"
+#include "mach64_state.h"
+
+
+#define MACH64_TEX1_BIT 0x1
+#define MACH64_TEX0_BIT 0x2
+#define MACH64_RGBA_BIT 0x4
+#define MACH64_SPEC_BIT 0x8
+#define MACH64_FOG_BIT 0x10
+#define MACH64_XYZW_BIT 0x20
+#define MACH64_PTEX_BIT 0x40
+#define MACH64_MAX_SETUP 0x80
+
+static struct {
+ void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
+ tnl_interp_func interp;
+ tnl_copy_pv_func copy_pv;
+ GLboolean (*check_tex_sizes)( GLcontext *ctx );
+ GLuint vertex_size;
+ GLuint vertex_format;
+} setup_tab[MACH64_MAX_SETUP];
+
+#define TINY_VERTEX_FORMAT 1
+#define NOTEX_VERTEX_FORMAT 2
+#define TEX0_VERTEX_FORMAT 3
+#define TEX1_VERTEX_FORMAT 4
+#define PROJ_TEX1_VERTEX_FORMAT 0
+#define TEX2_VERTEX_FORMAT 0
+#define TEX3_VERTEX_FORMAT 0
+#define PROJ_TEX3_VERTEX_FORMAT 0
+
+#define DO_XYZW (IND & MACH64_XYZW_BIT)
+#define DO_RGBA (IND & MACH64_RGBA_BIT)
+#define DO_SPEC (IND & MACH64_SPEC_BIT)
+#define DO_FOG (IND & MACH64_FOG_BIT)
+#define DO_TEX0 (IND & MACH64_TEX0_BIT)
+#define DO_TEX1 (IND & MACH64_TEX1_BIT)
+#define DO_TEX2 0
+#define DO_TEX3 0
+#define DO_PTEX (IND & MACH64_PTEX_BIT)
+
+#define VERTEX mach64Vertex
+#define LOCALVARS mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+#define GET_VIEWPORT_MAT() mmesa->hw_viewport
+#define GET_TEXSOURCE(n) mmesa->tmu_source[n]
+#define GET_VERTEX_FORMAT() mmesa->vertex_format
+#define GET_VERTEX_STORE() mmesa->verts
+#define GET_VERTEX_SIZE() mmesa->vertex_size * sizeof(GLuint)
+
+#define HAVE_HW_VIEWPORT 0
+#define HAVE_HW_DIVIDE 0
+#define HAVE_RGBA_COLOR 0
+#define HAVE_TINY_VERTICES 1
+#define HAVE_NOTEX_VERTICES 1
+#define HAVE_TEX0_VERTICES 1
+#define HAVE_TEX1_VERTICES 1
+#define HAVE_TEX2_VERTICES 0
+#define HAVE_TEX3_VERTICES 0
+#define HAVE_PTEX_VERTICES 0
+
+#define UNVIEWPORT_VARS \
+ const GLfloat dx = - (GLfloat)mmesa->drawX - SUBPIXEL_X; \
+ const GLfloat dy = (mmesa->driDrawable->h + \
+ (GLfloat)mmesa->drawY + SUBPIXEL_Y); \
+ const GLfloat sz = 1.0 / mmesa->depth_scale
+
+#if MACH64_NATIVE_VTXFMT
+
+#define UNVIEWPORT_X(x) ((GLfloat)(x) / 4.0) + dx
+#define UNVIEWPORT_Y(y) - ((GLfloat)(y) / 4.0) + dy
+#define UNVIEWPORT_Z(z) (GLfloat)((z) >> 15) * sz
+
+#else
+
+#define UNVIEWPORT_X(x) x + dx;
+#define UNVIEWPORT_Y(y) - y + dy;
+#define UNVIEWPORT_Z(z) z * sz;
+
+#endif
+
+#define PTEX_FALLBACK() FALLBACK(MACH64_CONTEXT(ctx), MACH64_FALLBACK_TEXTURE, 1)
+
+#define IMPORT_FLOAT_COLORS mach64_import_float_colors
+#define IMPORT_FLOAT_SPEC_COLORS mach64_import_float_spec_colors
+
+#define INTERP_VERTEX setup_tab[mmesa->SetupIndex].interp
+#define COPY_PV_VERTEX setup_tab[mmesa->SetupIndex].copy_pv
+
+/***********************************************************************
+ * Generate pv-copying and translation functions *
+ ***********************************************************************/
+
+#if MACH64_NATIVE_VTXFMT
+
+#define TAG(x) mach64_##x
+#include "mach64_native_vb.c"
+
+#else
+
+#define TAG(x) mach64_##x
+#include "tnl_dd/t_dd_vb.c"
+
+#endif
+
+/***********************************************************************
+ * Generate vertex emit and interp functions *
+ ***********************************************************************/
+
+
+#if MACH64_NATIVE_VTXFMT
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT)
+#define TAG(x) x##_wg
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_SPEC_BIT)
+#define TAG(x) x##_wgs
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_TEX0_BIT)
+#define TAG(x) x##_wgt0
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT)
+#define TAG(x) x##_wgt0t1
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_TEX0_BIT|MACH64_PTEX_BIT)
+#define TAG(x) x##_wgpt0
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT)
+#define TAG(x) x##_wgst0
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT|\
+ MACH64_TEX1_BIT)
+#define TAG(x) x##_wgst0t1
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT|\
+ MACH64_PTEX_BIT)
+#define TAG(x) x##_wgspt0
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT)
+#define TAG(x) x##_wgf
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT)
+#define TAG(x) x##_wgfs
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT)
+#define TAG(x) x##_wgft0
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT|\
+ MACH64_TEX1_BIT)
+#define TAG(x) x##_wgft0t1
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT|\
+ MACH64_PTEX_BIT)
+#define TAG(x) x##_wgfpt0
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|\
+ MACH64_TEX0_BIT)
+#define TAG(x) x##_wgfst0
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|\
+ MACH64_TEX0_BIT|MACH64_TEX1_BIT)
+#define TAG(x) x##_wgfst0t1
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|\
+ MACH64_TEX0_BIT|MACH64_PTEX_BIT)
+#define TAG(x) x##_wgfspt0
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_TEX0_BIT)
+#define TAG(x) x##_t0
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_TEX0_BIT|MACH64_TEX1_BIT)
+#define TAG(x) x##_t0t1
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_FOG_BIT)
+#define TAG(x) x##_f
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_FOG_BIT|MACH64_TEX0_BIT)
+#define TAG(x) x##_ft0
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_FOG_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT)
+#define TAG(x) x##_ft0t1
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT)
+#define TAG(x) x##_g
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_SPEC_BIT)
+#define TAG(x) x##_gs
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_TEX0_BIT)
+#define TAG(x) x##_gt0
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT)
+#define TAG(x) x##_gt0t1
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT)
+#define TAG(x) x##_gst0
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT)
+#define TAG(x) x##_gst0t1
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT)
+#define TAG(x) x##_gf
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT)
+#define TAG(x) x##_gfs
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT)
+#define TAG(x) x##_gft0
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT)
+#define TAG(x) x##_gft0t1
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT)
+#define TAG(x) x##_gfst0
+#include "mach64_native_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT|\
+ MACH64_TEX1_BIT)
+#define TAG(x) x##_gfst0t1
+#include "mach64_native_vbtmp.h"
+
+#else
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT)
+#define TAG(x) x##_wg
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_SPEC_BIT)
+#define TAG(x) x##_wgs
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_TEX0_BIT)
+#define TAG(x) x##_wgt0
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT)
+#define TAG(x) x##_wgt0t1
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_TEX0_BIT|MACH64_PTEX_BIT)
+#define TAG(x) x##_wgpt0
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT)
+#define TAG(x) x##_wgst0
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT|\
+ MACH64_TEX1_BIT)
+#define TAG(x) x##_wgst0t1
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT|\
+ MACH64_PTEX_BIT)
+#define TAG(x) x##_wgspt0
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT)
+#define TAG(x) x##_wgf
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT)
+#define TAG(x) x##_wgfs
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT)
+#define TAG(x) x##_wgft0
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT|\
+ MACH64_TEX1_BIT)
+#define TAG(x) x##_wgft0t1
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT|\
+ MACH64_PTEX_BIT)
+#define TAG(x) x##_wgfpt0
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|\
+ MACH64_TEX0_BIT)
+#define TAG(x) x##_wgfst0
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|\
+ MACH64_TEX0_BIT|MACH64_TEX1_BIT)
+#define TAG(x) x##_wgfst0t1
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_XYZW_BIT|MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|\
+ MACH64_TEX0_BIT|MACH64_PTEX_BIT)
+#define TAG(x) x##_wgfspt0
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_TEX0_BIT)
+#define TAG(x) x##_t0
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_TEX0_BIT|MACH64_TEX1_BIT)
+#define TAG(x) x##_t0t1
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_FOG_BIT)
+#define TAG(x) x##_f
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_FOG_BIT|MACH64_TEX0_BIT)
+#define TAG(x) x##_ft0
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_FOG_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT)
+#define TAG(x) x##_ft0t1
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT)
+#define TAG(x) x##_g
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_SPEC_BIT)
+#define TAG(x) x##_gs
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_TEX0_BIT)
+#define TAG(x) x##_gt0
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT)
+#define TAG(x) x##_gt0t1
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT)
+#define TAG(x) x##_gst0
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT)
+#define TAG(x) x##_gst0t1
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT)
+#define TAG(x) x##_gf
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT)
+#define TAG(x) x##_gfs
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT)
+#define TAG(x) x##_gft0
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_TEX0_BIT|MACH64_TEX1_BIT)
+#define TAG(x) x##_gft0t1
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT)
+#define TAG(x) x##_gfst0
+#include "mach64_vbtmp.h"
+
+#define IND (MACH64_RGBA_BIT|MACH64_FOG_BIT|MACH64_SPEC_BIT|MACH64_TEX0_BIT|\
+ MACH64_TEX1_BIT)
+#define TAG(x) x##_gfst0t1
+#include "mach64_vbtmp.h"
+
+#endif
+
+static void init_setup_tab( void )
+{
+ init_wg();
+ init_wgs();
+ init_wgt0();
+ init_wgt0t1();
+ init_wgpt0();
+ init_wgst0();
+ init_wgst0t1();
+ init_wgspt0();
+ init_wgf();
+ init_wgfs();
+ init_wgft0();
+ init_wgft0t1();
+ init_wgfpt0();
+ init_wgfst0();
+ init_wgfst0t1();
+ init_wgfspt0();
+ init_t0();
+ init_t0t1();
+ init_f();
+ init_ft0();
+ init_ft0t1();
+ init_g();
+ init_gs();
+ init_gt0();
+ init_gt0t1();
+ init_gst0();
+ init_gst0t1();
+ init_gf();
+ init_gfs();
+ init_gft0();
+ init_gft0t1();
+ init_gfst0();
+ init_gfst0t1();
+}
+
+
+
+void mach64PrintSetupFlags( char *msg, GLuint flags )
+{
+ fprintf( stderr, "%s: %d %s%s%s%s%s%s%s\n",
+ msg,
+ (int)flags,
+ (flags & MACH64_XYZW_BIT) ? " xyzw," : "",
+ (flags & MACH64_RGBA_BIT) ? " rgba," : "",
+ (flags & MACH64_SPEC_BIT) ? " spec," : "",
+ (flags & MACH64_FOG_BIT) ? " fog," : "",
+ (flags & MACH64_TEX0_BIT) ? " tex-0," : "",
+ (flags & MACH64_TEX1_BIT) ? " tex-1," : "",
+ (flags & MACH64_PTEX_BIT) ? " ptex," : "");
+}
+
+
+
+
+void mach64CheckTexSizes( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT( ctx );
+
+ if (!setup_tab[mmesa->SetupIndex].check_tex_sizes(ctx)) {
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ /* Invalidate stored verts
+ */
+ mmesa->SetupNewInputs = ~0;
+ mmesa->SetupIndex |= MACH64_PTEX_BIT;
+
+ if (!mmesa->Fallback &&
+ !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ tnl->Driver.Render.Interp = setup_tab[mmesa->SetupIndex].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[mmesa->SetupIndex].copy_pv;
+ }
+ }
+}
+
+void mach64BuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT( ctx );
+ GLuint stride = mmesa->vertex_size * sizeof(int);
+ GLubyte *v = ((GLubyte *)mmesa->verts + (start * stride));
+
+ newinputs |= mmesa->SetupNewInputs;
+ mmesa->SetupNewInputs = 0;
+
+ if (!newinputs)
+ return;
+
+ if (newinputs & VERT_BIT_POS) {
+ setup_tab[mmesa->SetupIndex].emit( ctx, start, count, v, stride );
+ } else {
+ GLuint ind = 0;
+
+ if (newinputs & VERT_BIT_COLOR0)
+ ind |= MACH64_RGBA_BIT;
+
+ if (newinputs & VERT_BIT_COLOR1)
+ ind |= MACH64_SPEC_BIT;
+
+ if (newinputs & VERT_BIT_TEX0)
+ ind |= MACH64_TEX0_BIT;
+
+ if (newinputs & VERT_BIT_TEX1)
+ ind |= MACH64_TEX1_BIT;
+
+ if (newinputs & VERT_BIT_FOG)
+ ind |= MACH64_FOG_BIT;
+
+ if (mmesa->SetupIndex & MACH64_PTEX_BIT)
+ ind = ~0;
+
+ ind &= mmesa->SetupIndex;
+
+ if (ind) {
+ setup_tab[ind].emit( ctx, start, count, v, stride );
+ }
+ }
+}
+
+void mach64ChooseVertexState( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ mach64ContextPtr mmesa = MACH64_CONTEXT( ctx );
+ GLuint ind = MACH64_XYZW_BIT|MACH64_RGBA_BIT;
+
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ ind |= MACH64_SPEC_BIT;
+
+ if (ctx->Fog.Enabled)
+ ind |= MACH64_FOG_BIT;
+
+ if (ctx->Texture._EnabledUnits) {
+ ind |= MACH64_TEX0_BIT;
+ if (ctx->Texture.Unit[0]._ReallyEnabled &&
+ ctx->Texture.Unit[1]._ReallyEnabled) {
+ ind |= MACH64_TEX1_BIT;
+ }
+ }
+
+ mmesa->SetupIndex = ind;
+
+ if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
+ tnl->Driver.Render.Interp = mach64_interp_extras;
+ tnl->Driver.Render.CopyPV = mach64_copy_pv_extras;
+ } else {
+ tnl->Driver.Render.Interp = setup_tab[ind].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
+ }
+
+#if 0
+ if (MACH64_DEBUG & DEBUG_VERBOSE_MSG) {
+ mach64PrintSetupFlags( __FUNCTION__, ind );
+ }
+#endif
+
+ if (setup_tab[ind].vertex_format != mmesa->vertex_format) {
+ FLUSH_BATCH(mmesa);
+ mmesa->vertex_format = setup_tab[ind].vertex_format;
+ mmesa->vertex_size = setup_tab[ind].vertex_size;
+ }
+}
+
+
+#if 0
+void mach64_emit_contiguous_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ GLuint vertex_size = mmesa->vertex_size * 4;
+ GLuint *dest = mach64AllocDmaLow( mmesa, (count-start) * vertex_size);
+ setup_tab[mmesa->SetupIndex].emit( ctx, start, count, dest, vertex_size );
+}
+#endif
+
+
+void mach64InitVB( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ GLuint size = TNL_CONTEXT(ctx)->vb.Size;
+
+ mmesa->verts = (GLubyte *)ALIGN_MALLOC(size * 4 * 16, 32);
+
+ {
+ static int firsttime = 1;
+ if (firsttime) {
+ init_setup_tab();
+ firsttime = 0;
+ }
+ }
+}
+
+
+void mach64FreeVB( GLcontext *ctx )
+{
+ mach64ContextPtr mmesa = MACH64_CONTEXT(ctx);
+ if (mmesa->verts) {
+ ALIGN_FREE(mmesa->verts);
+ mmesa->verts = 0;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_vb.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_vb.h
new file mode 100644
index 000000000..bcc4759af
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_vb.h
@@ -0,0 +1,77 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+#ifndef __MACH64_VB_H__
+#define __MACH64_VB_H__
+
+#include "mtypes.h"
+#include "swrast/swrast.h"
+#include "mach64_context.h"
+
+/* premultiply texture coordinates by homogenous coordinate */
+#define MACH64_PREMULT_TEXCOORDS
+
+#define _MACH64_NEW_VERTEX_STATE (_DD_NEW_SEPARATE_SPECULAR | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_UNFILLED | \
+ _NEW_TEXTURE | \
+ _NEW_FOG)
+
+
+extern void mach64CheckTexSizes( GLcontext *ctx );
+extern void mach64ChooseVertexState( GLcontext *ctx );
+
+extern void mach64BuildVertices( GLcontext *ctx, GLuint start, GLuint count,
+ GLuint newinputs );
+
+extern void mach64PrintSetupFlags(char *msg, GLuint flags );
+
+extern void mach64InitVB( GLcontext *ctx );
+extern void mach64FreeVB( GLcontext *ctx );
+
+#if 0
+extern void mach64_emit_contiguous_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count );
+
+extern void mach64_emit_indexed_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count );
+#endif
+
+extern void mach64_translate_vertex( GLcontext *ctx,
+ const mach64Vertex *src,
+ SWvertex *dst );
+
+extern void mach64_print_vertex( GLcontext *ctx, const mach64Vertex *v );
+
+
+#endif /* __MACH64_VB_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_vbtmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_vbtmp.h
new file mode 100644
index 000000000..c1207cacd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/mach64_vbtmp.h
@@ -0,0 +1,770 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Keith Whitwell <keithw@valinux.com>
+ *
+ * Modified for mach64 by:
+ * Leif Delgass <ldelgass@retinalburn.net>
+ * José Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+
+/* Unlike the other templates here, this assumes quite a bit about the
+ * underlying hardware. Specifically it assumes a d3d-like vertex
+ * format, with a layout more or less constrained to look like the
+ * following:
+ *
+ * union {
+ * struct {
+ * float x, y, z, w;
+ * struct { char r, g, b, a; } color;
+ * struct { char r, g, b, fog; } spec;
+ * float u0, v0;
+ * float u1, v1;
+ * float u2, v2;
+ * float u3, v3;
+ * } v;
+ * struct {
+ * float x, y, z, w;
+ * struct { char r, g, b, a; } color;
+ * struct { char r, g, b, fog; } spec;
+ * float u0, v0, q0;
+ * float u1, v1, q1;
+ * float u2, v2, q2;
+ * float u3, v3, q3;
+ * } pv;
+ * struct {
+ * float x, y, z;
+ * struct { char r, g, b, a; } color;
+ * } tv;
+ * float f[16];
+ * unsigned int ui[16];
+ * unsigned char ub4[4][16];
+ * }
+ *
+
+ * DO_XYZW: Emit xyz and maybe w coordinates.
+ * DO_RGBA: Emit color.
+ * DO_SPEC: Emit specular color.
+ * DO_FOG: Emit fog coordinate in specular alpha.
+ * DO_TEX0: Emit tex0 u,v coordinates.
+ * DO_TEX1: Emit tex1 u,v coordinates.
+ * DO_TEX2: Emit tex2 u,v coordinates.
+ * DO_TEX3: Emit tex3 u,v coordinates.
+ * DO_PTEX: Emit tex0,1,2,3 q coordinates where possible.
+ *
+ * HAVE_RGBA_COLOR: Hardware takes color in rgba order (else bgra).
+ *
+ * HAVE_HW_VIEWPORT: Hardware performs viewport transform.
+ * HAVE_HW_DIVIDE: Hardware performs perspective divide.
+ *
+ * HAVE_TINY_VERTICES: Hardware understands v.tv format.
+ * HAVE_PTEX_VERTICES: Hardware understands v.pv format.
+ * HAVE_NOTEX_VERTICES: Hardware understands v.v format with texcount 0.
+ *
+ * Additionally, this template assumes it is emitting *transformed*
+ * vertices; the modifications to emit untransformed vertices (ie. to
+ * t&l hardware) are probably too great to cooexist with the code
+ * already in this file.
+ *
+ * NOTE: The PTEX vertex format always includes TEX0 and TEX1, even if
+ * only TEX0 is enabled, in order to maintain a vertex size which is
+ * an exact number of quadwords.
+ */
+
+#if (HAVE_HW_VIEWPORT)
+#define VIEWPORT_X(dst,x) dst = x
+#define VIEWPORT_Y(dst,y) dst = y
+#define VIEWPORT_Z(dst,z) dst = z
+#else
+#define VIEWPORT_X(dst,x) dst = s[0] * x + s[12]
+#define VIEWPORT_Y(dst,y) dst = s[5] * y + s[13]
+#define VIEWPORT_Z(dst,z) dst = s[10] * z + s[14]
+#endif
+
+#if (HAVE_HW_DIVIDE && !HAVE_PTEX_VERTICES)
+#error "can't cope with this combination"
+#endif
+
+#ifndef LOCALVARS
+#define LOCALVARS
+#endif
+
+#ifndef CHECK_HW_DIVIDE
+#define CHECK_HW_DIVIDE 1
+#endif
+
+#if (HAVE_HW_DIVIDE || DO_SPEC || DO_TEX0 || DO_FOG || !HAVE_TINY_VERTICES)
+
+static void TAG(emit)( GLcontext *ctx,
+ GLuint start, GLuint end,
+ void *dest,
+ GLuint stride )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLfloat (*tc0)[4], (*tc1)[4], (*fog)[4];
+ GLfloat (*tc2)[4], (*tc3)[4];
+ GLfloat (*spec)[4];
+ GLfloat (*col)[4];
+ GLuint col_stride;
+ GLuint tc0_stride, tc1_stride, spec_stride, fog_stride;
+ GLuint tc2_stride, tc3_stride;
+ GLuint tc0_size, tc1_size;
+ GLuint tc2_size, tc3_size;
+ GLfloat (*coord)[4];
+ GLuint coord_stride;
+ VERTEX *v = (VERTEX *)dest;
+ const GLfloat *s = GET_VIEWPORT_MAT();
+ const GLubyte *mask = VB->ClipMask;
+ int i;
+
+/* fprintf(stderr, "%s(big) importable %d %d..%d\n", */
+/* __FUNCTION__, VB->importable_data, start, end); */
+
+ if (HAVE_HW_VIEWPORT && HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) {
+ (void) s;
+ coord = VB->ClipPtr->data;
+ coord_stride = VB->ClipPtr->stride;
+ }
+ else {
+ coord = VB->NdcPtr->data;
+ coord_stride = VB->NdcPtr->stride;
+ }
+
+ if (DO_TEX3) {
+ const GLuint t3 = GET_TEXSOURCE(3);
+ tc3 = VB->TexCoordPtr[t3]->data;
+ tc3_stride = VB->TexCoordPtr[t3]->stride;
+ if (DO_PTEX)
+ tc3_size = VB->TexCoordPtr[t3]->size;
+ }
+
+ if (DO_TEX2) {
+ const GLuint t2 = GET_TEXSOURCE(2);
+ tc2 = VB->TexCoordPtr[t2]->data;
+ tc2_stride = VB->TexCoordPtr[t2]->stride;
+ if (DO_PTEX)
+ tc2_size = VB->TexCoordPtr[t2]->size;
+ }
+
+ if (DO_TEX1) {
+ const GLuint t1 = GET_TEXSOURCE(1);
+ tc1 = VB->TexCoordPtr[t1]->data;
+ tc1_stride = VB->TexCoordPtr[t1]->stride;
+ if (DO_PTEX)
+ tc1_size = VB->TexCoordPtr[t1]->size;
+ }
+
+ if (DO_TEX0) {
+ const GLuint t0 = GET_TEXSOURCE(0);
+ tc0_stride = VB->TexCoordPtr[t0]->stride;
+ tc0 = VB->TexCoordPtr[t0]->data;
+ if (DO_PTEX)
+ tc0_size = VB->TexCoordPtr[t0]->size;
+ }
+
+ if (DO_RGBA) {
+ col = VB->ColorPtr[0]->data;
+ col_stride = VB->ColorPtr[0]->stride;
+ }
+
+ if (DO_SPEC) {
+ spec = VB->SecondaryColorPtr[0]->data;
+ spec_stride = VB->SecondaryColorPtr[0]->stride;
+ } else {
+ spec = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
+ spec_stride = 0;
+ }
+
+ if (DO_FOG) {
+ if (VB->FogCoordPtr) {
+ fog = VB->FogCoordPtr->data;
+ fog_stride = VB->FogCoordPtr->stride;
+ } else {
+ static GLfloat tmp[4] = {0, 0, 0, 0};
+ fog = &tmp;
+ fog_stride = 0;
+ }
+ }
+
+ /* May have nonstandard strides:
+ */
+ if (start) {
+ coord = (GLfloat (*)[4])((GLubyte *)coord + start * coord_stride);
+ if (DO_TEX0)
+ tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + start * tc0_stride);
+ if (DO_TEX1)
+ tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride);
+ if (DO_TEX2)
+ tc2 = (GLfloat (*)[4])((GLubyte *)tc2 + start * tc2_stride);
+ if (DO_TEX3)
+ tc3 = (GLfloat (*)[4])((GLubyte *)tc3 + start * tc3_stride);
+ if (DO_RGBA)
+ STRIDE_4F(col, start * col_stride);
+ if (DO_SPEC)
+ STRIDE_4F(spec, start * spec_stride);
+ if (DO_FOG)
+ STRIDE_4F(fog, start * fog_stride);
+ // fog = (GLfloat (*)[4])((GLubyte *)fog + start * fog_stride);
+ /* STRIDE_F(fog, start * fog_stride); */
+ }
+
+ for (i=start; i < end; i++, v = (VERTEX *)((GLubyte *)v + stride)) {
+ if (DO_XYZW) {
+ if (HAVE_HW_VIEWPORT || mask[i] == 0) {
+ /* unclipped */
+ VIEWPORT_X(v->v.x, coord[0][0]);
+ VIEWPORT_Y(v->v.y, coord[0][1]);
+ VIEWPORT_Z(v->v.z, coord[0][2]);
+ v->v.w = coord[0][3];
+ } else {
+ /* clipped */
+ v->v.w = 1.0;
+ }
+ if (MACH64_DEBUG & DEBUG_VERBOSE_PRIMS) {
+ fprintf(stderr, "%s: vert (importable) %d: %.2f %.2f %.2f %f\n",
+ __FUNCTION__, i, v->v.x, v->v.y, v->v.z, v->v.w);
+ }
+ coord = (GLfloat (*)[4])((GLubyte *)coord + coord_stride);
+ }
+ if (DO_RGBA) {
+ if (HAVE_RGBA_COLOR) {
+ *(GLuint *)&v->v.color = *(GLuint *)&col[0];
+ STRIDE_4F(col, col_stride);
+ } else {
+ v->v.color.blue = col[0][2];
+ v->v.color.green = col[0][1];
+ v->v.color.red = col[0][0];
+ v->v.color.alpha = col[0][3];
+ STRIDE_4F(col, col_stride);
+ }
+ }
+ if (DO_SPEC) {
+ v->v.specular.red = spec[0][0];
+ v->v.specular.green = spec[0][1];
+ v->v.specular.blue = spec[0][2];
+ STRIDE_4F(spec, spec_stride);
+ }
+ if (DO_FOG) {
+ v->v.specular.alpha = fog[0][0] * 255.0;
+ /* STRIDE_F(fog, fog_stride); */
+ fog = (GLfloat (*)[4])((GLubyte *)fog + fog_stride);
+ }
+ if (DO_TEX0) {
+ v->v.u0 = tc0[0][0];
+ v->v.v0 = tc0[0][1];
+ if (MACH64_DEBUG & DEBUG_VERBOSE_PRIMS) {
+ fprintf(stderr, "%s: vert (importable) %d: u0: %.2f, v0: %.2f, w: %f\n",
+ __FUNCTION__, i, v->v.u0, v->v.v0, v->v.w);
+ }
+#ifdef MACH64_PREMULT_TEXCOORDS
+ v->v.u0 *= v->v.w;
+ v->v.v0 *= v->v.w;
+#endif
+ if (DO_PTEX) {
+ if (HAVE_PTEX_VERTICES) {
+ if (tc0_size == 4)
+ v->pv.q0 = tc0[0][3];
+ else
+ v->pv.q0 = 1.0;
+ }
+ else if (tc0_size == 4) {
+#ifdef MACH64_PREMULT_TEXCOORDS
+ v->v.w *= tc0[0][3];
+#else
+ float rhw = 1.0 / tc0[0][3];
+ v->v.w *= tc0[0][3];
+ v->v.u0 *= rhw;
+ v->v.v0 *= rhw;
+#endif
+ }
+ }
+ tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride);
+ }
+ if (DO_TEX1) {
+ if (DO_PTEX) {
+ v->pv.u1 = tc1[0][0];
+ v->pv.v1 = tc1[0][1];
+ if (tc1_size == 4)
+ v->pv.q1 = tc1[0][3];
+ else
+ v->pv.q1 = 1.0;
+ }
+ else {
+ v->v.u1 = tc1[0][0];
+ v->v.v1 = tc1[0][1];
+ }
+#ifdef MACH64_PREMULT_TEXCOORDS
+ v->v.u1 *= v->v.w;
+ v->v.v1 *= v->v.w;
+#endif
+ tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + tc1_stride);
+ }
+ else if (DO_PTEX) {
+ *(GLuint *)&v->pv.q1 = 0; /* avoid culling on radeon */
+ }
+ if (DO_TEX2) {
+ if (DO_PTEX) {
+ v->pv.u2 = tc2[0][0];
+ v->pv.v2 = tc2[0][1];
+ if (tc2_size == 4)
+ v->pv.q2 = tc2[0][3];
+ else
+ v->pv.q2 = 1.0;
+ }
+ else {
+ v->v.u2 = tc2[0][0];
+ v->v.v2 = tc2[0][1];
+ }
+ tc2 = (GLfloat (*)[4])((GLubyte *)tc2 + tc2_stride);
+ }
+ if (DO_TEX3) {
+ if (DO_PTEX) {
+ v->pv.u3 = tc3[0][0];
+ v->pv.v3 = tc3[0][1];
+ if (tc3_size == 4)
+ v->pv.q3 = tc3[0][3];
+ else
+ v->pv.q3 = 1.0;
+ }
+ else {
+ v->v.u3 = tc3[0][0];
+ v->v.v3 = tc3[0][1];
+ }
+ tc3 = (GLfloat (*)[4])((GLubyte *)tc3 + tc3_stride);
+ }
+ }
+}
+
+#else
+#if DO_XYZW
+
+#if HAVE_HW_DIVIDE
+#error "cannot use tiny vertices with hw perspective divide"
+#endif
+
+static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
+ void *dest, GLuint stride )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLfloat (*col)[4];
+ GLuint col_stride;
+ GLfloat (*coord)[4] = VB->NdcPtr->data;
+ GLuint coord_stride = VB->NdcPtr->stride;
+ GLfloat *v = (GLfloat *)dest;
+ const GLubyte *mask = VB->ClipMask;
+ const GLfloat *s = GET_VIEWPORT_MAT();
+ int i;
+
+ (void) s;
+
+ ASSERT(stride == 4);
+
+ col = VB->ColorPtr[0]->data;
+ col_stride = VB->ColorPtr[0]->stride;
+
+ /* Pack what's left into a 4-dword vertex. Color is in a different
+ * place, and there is no 'w' coordinate.
+ */
+ if (start) {
+ coord = (GLfloat (*)[4])((GLubyte *)coord + start * coord_stride);
+ STRIDE_4F(col, start * col_stride);
+ }
+
+ for (i=start; i < end; i++, v+=4) {
+ if (HAVE_HW_VIEWPORT || mask[i] == 0) {
+ VIEWPORT_X(v[0], coord[0][0]);
+ VIEWPORT_Y(v[1], coord[0][1]);
+ VIEWPORT_Z(v[2], coord[0][2]);
+ }
+ coord = (GLfloat (*)[4])((GLubyte *)coord + coord_stride);
+ if (DO_RGBA) {
+ if (HAVE_RGBA_COLOR) {
+ *(GLuint *)&v[3] = *(GLuint *)col;
+ }
+ else {
+ GLubyte *b = (GLubyte *)&v[3];
+ UNCLAMPED_FLOAT_TO_UBYTE(b[0], col[0][2]);
+ UNCLAMPED_FLOAT_TO_UBYTE(b[1], col[0][1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(b[2], col[0][0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(b[3], col[0][3]);
+ }
+ STRIDE_4F( col, col_stride );
+ }
+ if (MACH64_DEBUG & DEBUG_VERBOSE_PRIMS) {
+ fprintf(stderr, "vert (importable) %d: %.2f %.2f %.2f %x\n",
+ i, v[0], v[1], v[2], *(int *)&v[3]);
+ }
+ }
+}
+#else
+static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
+ void *dest, GLuint stride )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLfloat (*col)[4];
+ GLuint col_stride;
+ GLfloat *v = (GLfloat *)dest;
+ int i;
+
+ col = VB->ColorPtr[0]->data;
+ col_stride = VB->ColorPtr[0]->stride;
+
+ if (start)
+ STRIDE_4F(col, col_stride * start);
+
+ /* Need to figure out where color is:
+ */
+ if (GET_VERTEX_FORMAT() == TINY_VERTEX_FORMAT)
+ v += 3;
+ else
+ v += 4;
+
+ for (i=start; i < end; i++, STRIDE_F(v, stride)) {
+ if (HAVE_RGBA_COLOR) {
+ *(GLuint *)v = *(GLuint *)col[0];
+ }
+ else {
+ GLubyte *b = (GLubyte *)v;
+ UNCLAMPED_FLOAT_TO_UBYTE(b[0], col[0][2]);
+ UNCLAMPED_FLOAT_TO_UBYTE(b[1], col[0][1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(b[2], col[0][0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(b[3], col[0][3]);
+ }
+ STRIDE_4F( col, col_stride );
+ }
+}
+#endif /* emit */
+#endif /* emit */
+
+#if (DO_XYZW) && (DO_RGBA)
+
+
+#if (HAVE_PTEX_VERTICES)
+static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ /* Force 'missing' texcoords to something valid.
+ */
+ if (DO_TEX3 && VB->TexCoordPtr[2] == 0)
+ VB->TexCoordPtr[2] = VB->TexCoordPtr[3];
+
+ if (DO_TEX2 && VB->TexCoordPtr[1] == 0)
+ VB->TexCoordPtr[1] = VB->TexCoordPtr[2];
+
+ if (DO_TEX1 && VB->TexCoordPtr[0] == 0)
+ VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
+
+ if (DO_PTEX)
+ return GL_TRUE;
+
+ if ((DO_TEX3 && VB->TexCoordPtr[GET_TEXSOURCE(3)]->size == 4) ||
+ (DO_TEX2 && VB->TexCoordPtr[GET_TEXSOURCE(2)]->size == 4) ||
+ (DO_TEX1 && VB->TexCoordPtr[GET_TEXSOURCE(1)]->size == 4) ||
+ (DO_TEX0 && VB->TexCoordPtr[GET_TEXSOURCE(0)]->size == 4))
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+#else
+static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ /* Force 'missing' texcoords to something valid.
+ */
+ if (DO_TEX3 && VB->TexCoordPtr[2] == 0)
+ VB->TexCoordPtr[2] = VB->TexCoordPtr[3];
+
+ if (DO_TEX2 && VB->TexCoordPtr[1] == 0)
+ VB->TexCoordPtr[1] = VB->TexCoordPtr[2];
+
+ if (DO_TEX1 && VB->TexCoordPtr[0] == 0)
+ VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
+
+ if (DO_PTEX)
+ return GL_TRUE;
+
+ /* No hardware support for projective texture. Can fake it for
+ * TEX0 only.
+ */
+ if ((DO_TEX3 && VB->TexCoordPtr[GET_TEXSOURCE(3)]->size == 4) ||
+ (DO_TEX2 && VB->TexCoordPtr[GET_TEXSOURCE(2)]->size == 4) ||
+ (DO_TEX1 && VB->TexCoordPtr[GET_TEXSOURCE(1)]->size == 4)) {
+ PTEX_FALLBACK();
+ return GL_FALSE;
+ }
+
+ if (DO_TEX0 && VB->TexCoordPtr[GET_TEXSOURCE(0)]->size == 4) {
+ if (DO_TEX1 || DO_TEX2 || DO_TEX3) {
+ PTEX_FALLBACK();
+ }
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+#endif /* ptex */
+
+
+static void TAG(interp)( GLcontext *ctx,
+ GLfloat t,
+ GLuint edst, GLuint eout, GLuint ein,
+ GLboolean force_boundary )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLubyte *ddverts = GET_VERTEX_STORE();
+ GLuint size = GET_VERTEX_SIZE();
+ const GLfloat *dstclip = VB->ClipPtr->data[edst];
+ GLfloat w;
+ const GLfloat *s = GET_VIEWPORT_MAT();
+
+ VERTEX *dst = (VERTEX *)(ddverts + (edst * size));
+ VERTEX *in = (VERTEX *)(ddverts + (ein * size));
+ VERTEX *out = (VERTEX *)(ddverts + (eout * size));
+
+ (void)s;
+
+ if (HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) {
+ VIEWPORT_X( dst->v.x, dstclip[0] );
+ VIEWPORT_Y( dst->v.y, dstclip[1] );
+ VIEWPORT_Z( dst->v.z, dstclip[2] );
+ w = dstclip[3];
+ }
+ else {
+ w = (dstclip[3] == 0.0F) ? 1.0 : (1.0 / dstclip[3]);
+ VIEWPORT_X( dst->v.x, dstclip[0] * w );
+ VIEWPORT_Y( dst->v.y, dstclip[1] * w );
+ VIEWPORT_Z( dst->v.z, dstclip[2] * w );
+ }
+
+ if (MACH64_DEBUG & DEBUG_VERBOSE_PRIMS) {
+ fprintf( stderr, "%s: dst vert: %.2f %.2f %.2f %f\n",
+ __FUNCTION__,
+ dst->v.x,
+ dst->v.y,
+ dst->v.z,
+ w );
+ }
+
+ if ((HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) ||
+ DO_FOG || DO_SPEC || DO_TEX0 || DO_TEX1 ||
+ DO_TEX2 || DO_TEX3 || !HAVE_TINY_VERTICES) {
+
+ dst->v.w = w;
+
+ INTERP_UB( t, dst->ub4[4][0], out->ub4[4][0], in->ub4[4][0] );
+ INTERP_UB( t, dst->ub4[4][1], out->ub4[4][1], in->ub4[4][1] );
+ INTERP_UB( t, dst->ub4[4][2], out->ub4[4][2], in->ub4[4][2] );
+ INTERP_UB( t, dst->ub4[4][3], out->ub4[4][3], in->ub4[4][3] );
+
+ if (DO_SPEC) {
+ INTERP_UB( t, dst->ub4[5][0], out->ub4[5][0], in->ub4[5][0] );
+ INTERP_UB( t, dst->ub4[5][1], out->ub4[5][1], in->ub4[5][1] );
+ INTERP_UB( t, dst->ub4[5][2], out->ub4[5][2], in->ub4[5][2] );
+ }
+ if (DO_FOG) {
+ INTERP_UB( t, dst->ub4[5][3], out->ub4[5][3], in->ub4[5][3] );
+ }
+ if (DO_TEX0) {
+ if (DO_PTEX) {
+ if (HAVE_PTEX_VERTICES) {
+ INTERP_F( t, dst->pv.u0, out->pv.u0, in->pv.u0 );
+ INTERP_F( t, dst->pv.v0, out->pv.v0, in->pv.v0 );
+ INTERP_F( t, dst->pv.q0, out->pv.q0, in->pv.q0 );
+ } else {
+ GLfloat wout = VB->NdcPtr->data[eout][3];
+ GLfloat win = VB->NdcPtr->data[ein][3];
+ GLfloat qout = out->pv.w / wout;
+ GLfloat qin = in->pv.w / win;
+ GLfloat qdst, rqdst;
+
+ ASSERT( !HAVE_HW_DIVIDE );
+
+ INTERP_F( t, dst->v.u0, out->v.u0 * qout, in->v.u0 * qin );
+ INTERP_F( t, dst->v.v0, out->v.v0 * qout, in->v.v0 * qin );
+ INTERP_F( t, qdst, qout, qin );
+
+ rqdst = 1.0 / qdst;
+ dst->v.u0 *= rqdst;
+ dst->v.v0 *= rqdst;
+ dst->v.w *= rqdst;
+ }
+ }
+ else {
+#ifdef MACH64_PREMULT_TEXCOORDS
+ GLfloat qout = 1 / out->v.w;
+ GLfloat qin = 1 / in->v.w;
+
+ INTERP_F( t, dst->v.u0, out->v.u0 * qout, in->v.u0 * qin);
+ INTERP_F( t, dst->v.v0, out->v.v0 * qout, in->v.v0 * qin);
+
+ dst->v.u0 *= w;
+ dst->v.v0 *= w;
+#else
+ INTERP_F( t, dst->v.u0, out->v.u0, in->v.u0 );
+ INTERP_F( t, dst->v.v0, out->v.v0, in->v.v0 );
+#endif
+ }
+ }
+ if (DO_TEX1) {
+ if (DO_PTEX) {
+ INTERP_F( t, dst->pv.u1, out->pv.u1, in->pv.u1 );
+ INTERP_F( t, dst->pv.v1, out->pv.v1, in->pv.v1 );
+ INTERP_F( t, dst->pv.q1, out->pv.q1, in->pv.q1 );
+ } else {
+#ifdef MACH64_PREMULT_TEXCOORDS
+ GLfloat qout = 1 / out->v.w;
+ GLfloat qin = 1 / in->v.w;
+
+ INTERP_F( t, dst->v.u1, out->v.u1 * qout, in->v.u1 * qin );
+ INTERP_F( t, dst->v.v1, out->v.v1 * qout, in->v.v1 * qin );
+
+ dst->v.u1 *= w;
+ dst->v.v1 *= w;
+#else
+ INTERP_F( t, dst->v.u1, out->v.u1, in->v.u1 );
+ INTERP_F( t, dst->v.v1, out->v.v1, in->v.v1 );
+#endif
+ }
+ }
+ else if (DO_PTEX) {
+ dst->pv.q0 = 0.0; /* must be a valid float on radeon */
+ }
+ if (DO_TEX2) {
+ if (DO_PTEX) {
+ INTERP_F( t, dst->pv.u2, out->pv.u2, in->pv.u2 );
+ INTERP_F( t, dst->pv.v2, out->pv.v2, in->pv.v2 );
+ INTERP_F( t, dst->pv.q2, out->pv.q2, in->pv.q2 );
+ } else {
+ INTERP_F( t, dst->v.u2, out->v.u2, in->v.u2 );
+ INTERP_F( t, dst->v.v2, out->v.v2, in->v.v2 );
+ }
+ }
+ if (DO_TEX3) {
+ if (DO_PTEX) {
+ INTERP_F( t, dst->pv.u3, out->pv.u3, in->pv.u3 );
+ INTERP_F( t, dst->pv.v3, out->pv.v3, in->pv.v3 );
+ INTERP_F( t, dst->pv.q3, out->pv.q3, in->pv.q3 );
+ } else {
+ INTERP_F( t, dst->v.u3, out->v.u3, in->v.u3 );
+ INTERP_F( t, dst->v.v3, out->v.v3, in->v.v3 );
+ }
+ }
+ } else {
+ /* 4-dword vertex. Color is in v[3] and there is no oow coordinate.
+ */
+ INTERP_UB( t, dst->ub4[3][0], out->ub4[3][0], in->ub4[3][0] );
+ INTERP_UB( t, dst->ub4[3][1], out->ub4[3][1], in->ub4[3][1] );
+ INTERP_UB( t, dst->ub4[3][2], out->ub4[3][2], in->ub4[3][2] );
+ INTERP_UB( t, dst->ub4[3][3], out->ub4[3][3], in->ub4[3][3] );
+ }
+}
+
+#endif /* rgba && xyzw */
+
+
+static void TAG(init)( void )
+{
+ setup_tab[IND].emit = TAG(emit);
+
+#if (DO_XYZW && DO_RGBA)
+ setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes);
+ setup_tab[IND].interp = TAG(interp);
+#endif
+
+ if (DO_SPEC)
+ setup_tab[IND].copy_pv = copy_pv_rgba4_spec5;
+ else if (HAVE_HW_DIVIDE || DO_SPEC || DO_FOG || DO_TEX0 || DO_TEX1 ||
+ DO_TEX2 || DO_TEX3 || !HAVE_TINY_VERTICES)
+ setup_tab[IND].copy_pv = copy_pv_rgba4;
+ else
+ setup_tab[IND].copy_pv = copy_pv_rgba3;
+
+ if (DO_TEX3) {
+ if (DO_PTEX) {
+ ASSERT(HAVE_PTEX_VERTICES);
+ setup_tab[IND].vertex_format = PROJ_TEX3_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 18;
+ }
+ else {
+ setup_tab[IND].vertex_format = TEX3_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 14;
+ }
+ }
+ else if (DO_TEX2) {
+ if (DO_PTEX) {
+ ASSERT(HAVE_PTEX_VERTICES);
+ setup_tab[IND].vertex_format = PROJ_TEX3_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 18;
+ }
+ else {
+ setup_tab[IND].vertex_format = TEX2_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 12;
+ }
+ }
+ else if (DO_TEX1) {
+ if (DO_PTEX) {
+ ASSERT(HAVE_PTEX_VERTICES);
+ setup_tab[IND].vertex_format = PROJ_TEX1_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 12;
+ }
+ else {
+ setup_tab[IND].vertex_format = TEX1_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 10;
+ }
+ }
+ else if (DO_TEX0) {
+ if (DO_PTEX && HAVE_PTEX_VERTICES) {
+ setup_tab[IND].vertex_format = PROJ_TEX1_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 12;
+ } else {
+ setup_tab[IND].vertex_format = TEX0_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 8;
+ }
+ }
+ else if (!HAVE_HW_DIVIDE && !DO_SPEC && !DO_FOG && HAVE_TINY_VERTICES) {
+ setup_tab[IND].vertex_format = TINY_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 4;
+ } else if (HAVE_NOTEX_VERTICES) {
+ setup_tab[IND].vertex_format = NOTEX_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 6;
+ } else {
+ setup_tab[IND].vertex_format = TEX0_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 8;
+ }
+
+}
+
+
+#undef IND
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/server/mach64_dri.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/server/mach64_dri.h
new file mode 100644
index 000000000..139668e3f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mach64/server/mach64_dri.h
@@ -0,0 +1,126 @@
+/* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
+/*
+ * Copyright 2000 Gareth Hughes
+ * 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
+ * GARETH HUGHES 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@valinux.com>
+ * Leif Delgass <ldelgass@retinalburn.net>
+ */
+
+#ifndef __MACH64_DRI_H__
+#define __MACH64_DRI_H__ 1
+
+#include "xf86drm.h"
+
+typedef struct {
+ drm_handle_t fbHandle;
+
+ drm_handle_t regsHandle;
+ drmSize regsSize;
+
+ int IsPCI;
+
+ drm_handle_t agpHandle; /* Handle from drmAgpAlloc */
+ unsigned long agpOffset;
+ drmSize agpSize;
+ int agpMode;
+
+ /* DMA descriptor ring */
+ unsigned long ringStart; /* Offset into AGP space */
+ drm_handle_t ringHandle; /* Handle from drmAddMap */
+ drmSize ringMapSize; /* Size of map */
+ int ringSize; /* Size of ring (in kB) */
+ drmAddress ringMap; /* Map */
+
+ /* vertex buffer data */
+ unsigned long bufferStart; /* Offset into AGP space */
+ drm_handle_t bufferHandle; /* Handle from drmAddMap */
+ drmSize bufferMapSize; /* Size of map */
+ int bufferSize; /* Size of buffers (in MB) */
+ drmAddress bufferMap; /* Map */
+
+ drmBufMapPtr drmBuffers; /* Buffer map */
+ int numBuffers; /* Number of buffers */
+
+ /* AGP Texture data */
+ unsigned long agpTexStart; /* Offset into AGP space */
+ drm_handle_t agpTexHandle; /* Handle from drmAddMap */
+ drmSize agpTexMapSize; /* Size of map */
+ int agpTexSize; /* Size of AGP tex space (in MB) */
+ drmAddress agpTexMap; /* Map */
+ int log2AGPTexGran;
+
+ int fbX;
+ int fbY;
+ int backX;
+ int backY;
+ int depthX;
+ int depthY;
+
+ int frontOffset;
+ int frontPitch;
+ int backOffset;
+ int backPitch;
+ int depthOffset;
+ int depthPitch;
+
+ int textureOffset;
+ int textureSize;
+ int logTextureGranularity;
+} ATIDRIServerInfoRec, *ATIDRIServerInfoPtr;
+
+typedef struct {
+ int chipset;
+ int width;
+ int height;
+ int mem;
+ int cpp;
+
+ int IsPCI;
+ int AGPMode;
+
+ unsigned int frontOffset;
+ unsigned int frontPitch;
+
+ unsigned int backOffset;
+ unsigned int backPitch;
+
+ unsigned int depthOffset;
+ unsigned int depthPitch;
+
+ unsigned int textureOffset;
+ unsigned int textureSize;
+ int logTextureGranularity;
+
+ drm_handle_t regs;
+ drmSize regsSize;
+
+ drm_handle_t agp;
+ drmSize agpSize;
+ unsigned int agpTextureOffset;
+ unsigned int agpTextureSize;
+ int logAgpTextureGranularity;
+} ATIDRIRec, *ATIDRIPtr;
+
+#endif /* __MACH64_DRI_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/Doxyfile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/Doxyfile
new file mode 100644
index 000000000..0d0c134a7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/Doxyfile
@@ -0,0 +1,234 @@
+# Doxyfile 1.3.3-Gideon
+
+#---------------------------------------------------------------------------
+# General configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME = mga
+PROJECT_NUMBER = $VERSION$
+OUTPUT_DIRECTORY =
+OUTPUT_LANGUAGE = English
+USE_WINDOWS_ENCODING = NO
+EXTRACT_ALL = NO
+EXTRACT_PRIVATE = NO
+EXTRACT_STATIC = NO
+EXTRACT_LOCAL_CLASSES = YES
+HIDE_UNDOC_MEMBERS = NO
+HIDE_UNDOC_CLASSES = NO
+HIDE_FRIEND_COMPOUNDS = NO
+HIDE_IN_BODY_DOCS = NO
+BRIEF_MEMBER_DESC = YES
+REPEAT_BRIEF = YES
+ALWAYS_DETAILED_SEC = NO
+INLINE_INHERITED_MEMB = NO
+FULL_PATH_NAMES = NO
+STRIP_FROM_PATH =
+INTERNAL_DOCS = NO
+CASE_SENSE_NAMES = YES
+SHORT_NAMES = NO
+HIDE_SCOPE_NAMES = NO
+SHOW_INCLUDE_FILES = YES
+JAVADOC_AUTOBRIEF = NO
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP = NO
+INHERIT_DOCS = YES
+INLINE_INFO = YES
+SORT_MEMBER_DOCS = YES
+DISTRIBUTE_GROUP_DOC = NO
+TAB_SIZE = 8
+GENERATE_TODOLIST = YES
+GENERATE_TESTLIST = YES
+GENERATE_BUGLIST = YES
+GENERATE_DEPRECATEDLIST= YES
+ALIASES =
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 30
+OPTIMIZE_OUTPUT_FOR_C = NO
+OPTIMIZE_OUTPUT_JAVA = NO
+SHOW_USED_FILES = YES
+SUBGROUPING = YES
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET = NO
+WARNINGS = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_IF_DOC_ERROR = YES
+WARN_FORMAT = "$file:$line: $text"
+WARN_LOGFILE =
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT = /home/newtree/temp/src/mesa/drivers/dri/mga
+FILE_PATTERNS = *.c \
+ *.cc \
+ *.cxx \
+ *.cpp \
+ *.c++ \
+ *.java \
+ *.ii \
+ *.ixx \
+ *.ipp \
+ *.i++ \
+ *.inl \
+ *.h \
+ *.hh \
+ *.hxx \
+ *.hpp \
+ *.h++ \
+ *.idl \
+ *.odl \
+ *.cs \
+ *.C \
+ *.H \
+ *.tlh \
+ *.diff \
+ *.patch \
+ *.moc \
+ *.xpm \
+ *.dox
+RECURSIVE = yes
+EXCLUDE =
+EXCLUDE_SYMLINKS = NO
+EXCLUDE_PATTERNS =
+EXAMPLE_PATH =
+EXAMPLE_PATTERNS = *
+EXAMPLE_RECURSIVE = NO
+IMAGE_PATH =
+INPUT_FILTER =
+FILTER_SOURCE_FILES = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER = NO
+INLINE_SOURCES = NO
+STRIP_CODE_COMMENTS = YES
+REFERENCED_BY_RELATION = YES
+REFERENCES_RELATION = YES
+VERBATIM_HEADERS = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX = NO
+COLS_IN_ALPHA_INDEX = 5
+IGNORE_PREFIX =
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML = YES
+HTML_OUTPUT = html
+HTML_FILE_EXTENSION = .html
+HTML_HEADER =
+HTML_FOOTER =
+HTML_STYLESHEET =
+HTML_ALIGN_MEMBERS = YES
+GENERATE_HTMLHELP = NO
+CHM_FILE =
+HHC_LOCATION =
+GENERATE_CHI = NO
+BINARY_TOC = NO
+TOC_EXPAND = NO
+DISABLE_INDEX = NO
+ENUM_VALUES_PER_LINE = 4
+GENERATE_TREEVIEW = NO
+TREEVIEW_WIDTH = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX = YES
+LATEX_OUTPUT = latex
+LATEX_CMD_NAME = latex
+MAKEINDEX_CMD_NAME = makeindex
+COMPACT_LATEX = NO
+PAPER_TYPE = a4wide
+EXTRA_PACKAGES =
+LATEX_HEADER =
+PDF_HYPERLINKS = NO
+USE_PDFLATEX = NO
+LATEX_BATCHMODE = NO
+LATEX_HIDE_INDICES = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF = NO
+RTF_OUTPUT = rtf
+COMPACT_RTF = NO
+RTF_HYPERLINKS = NO
+RTF_STYLESHEET_FILE =
+RTF_EXTENSIONS_FILE =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN = NO
+MAN_OUTPUT = man
+MAN_EXTENSION = .3
+MAN_LINKS = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML = yes
+XML_OUTPUT = xml
+XML_SCHEMA =
+XML_DTD =
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD = NO
+PERLMOD_LATEX = NO
+PERLMOD_PRETTY = YES
+PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = NO
+EXPAND_ONLY_PREDEF = NO
+SEARCH_INCLUDES = YES
+INCLUDE_PATH =
+INCLUDE_FILE_PATTERNS =
+PREDEFINED =
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = YES
+#---------------------------------------------------------------------------
+# Configuration::addtions related to external references
+#---------------------------------------------------------------------------
+TAGFILES =
+GENERATE_TAGFILE =
+ALLEXTERNALS = NO
+EXTERNAL_GROUPS = YES
+PERL_PATH = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS = YES
+HIDE_UNDOC_RELATIONS = YES
+HAVE_DOT = NO
+CLASS_GRAPH = YES
+COLLABORATION_GRAPH = YES
+UML_LOOK = NO
+TEMPLATE_RELATIONS = NO
+INCLUDE_GRAPH = YES
+INCLUDED_BY_GRAPH = YES
+CALL_GRAPH = NO
+GRAPHICAL_HIERARCHY = YES
+DOT_IMAGE_FORMAT = png
+DOT_PATH =
+DOTFILE_DIRS =
+MAX_DOT_GRAPH_WIDTH = 1024
+MAX_DOT_GRAPH_HEIGHT = 1024
+MAX_DOT_GRAPH_DEPTH = 1000
+GENERATE_LEGEND = YES
+DOT_CLEANUP = YES
+#---------------------------------------------------------------------------
+# Configuration::addtions related to the search engine
+#---------------------------------------------------------------------------
+SEARCHENGINE = NO
+CGI_NAME = search.cgi
+CGI_URL =
+DOC_URL =
+DOC_ABSPATH =
+BIN_ABSPATH = /usr/local/bin/
+EXT_DOC_PATHS =
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/Makefile
new file mode 100644
index 000000000..a871064c6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/Makefile
@@ -0,0 +1,34 @@
+# src/mesa/drivers/dri/mga/Makefile
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = mga_dri.so
+
+MINIGLX_SOURCES = server/mga_dri.c
+
+DRIVER_SOURCES = \
+ mgadd.c \
+ mgaioctl.c \
+ mgarender.c \
+ mgastate.c \
+ mgatris.c \
+ mgapixel.c \
+ mgaspan.c \
+ mgatex.c \
+ mgatexmem.c \
+ mga_texstate.c \
+ mga_texcombine.c \
+ mgavb.c \
+ mga_xmesa.c
+
+C_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(DRIVER_SOURCES)
+
+
+ASM_SOURCES =
+
+include ../Makefile.template
+
+symlinks:
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/README b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/README
new file mode 100644
index 000000000..a7133fa66
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/README
@@ -0,0 +1,26 @@
+MGA DRI driver ported from XF86DRI to FBDRI
+by Denis Oliver Kropp <dok@directfb.org>
+
+
+INFO
+
+This driver has been ported from the head branch of XFree86 to
+the embedded-1-branch of Mesa.
+
+
+STATUS
+
+Already working very well as far as I've tested it (16/32 bit).
+glxgears runs at 935 fps (G550 32MB AGP 4x, Athlon 1.33) vs 744 fps with XFree.
+Other demos (terrain, fire, etc.) have been successfully tested as well.
+
+
+TODO
+
+- mgaEngineShutdown
+- mgaEngineRestore
+- SGRAM detection
+- remove some unused bits from server/*
+- subset driver support
+- mgaWaitForVBlank
+- deinitialization (from MGADRICloseScreen) a la radeonDestroyScreen
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mga_texcombine.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mga_texcombine.c
new file mode 100644
index 000000000..bbfa29be5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mga_texcombine.c
@@ -0,0 +1,672 @@
+/*
+ * Copyright (c) 2003 Ville Syrjala
+ *
+ * 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
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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:
+ * Ville Syrjala <syrjala@sci.fi>
+ */
+
+#include "glheader.h"
+
+#include "mgacontext.h"
+#include "mgatex.h"
+#include "mgaregs.h"
+
+/*
+ * GL_ARB_texture_env_combine
+ * GL_EXT_texture_env_combine
+ * GL_ARB_texture_env_crossbar
+ * GL_ATI_texture_env_combine3
+ */
+
+#define ARG_DISABLE 0xffffffff
+#define MGA_ARG1 0
+#define MGA_ARG2 1
+#define MGA_ALPHA 2
+
+GLboolean mgaUpdateTextureEnvCombine( GLcontext *ctx, int unit )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ const int source = mmesa->tmu_source[unit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
+ GLuint *reg = ((GLuint *)&mmesa->setup.tdualstage0 + unit);
+ GLuint numColorArgs = 0, numAlphaArgs = 0;
+ GLuint arg1[3], arg2[3], alpha[3];
+ int args[3];
+ int i;
+
+ switch (texUnit->Combine.ModeRGB) {
+ case GL_REPLACE:
+ numColorArgs = 1;
+ break;
+ case GL_MODULATE:
+ case GL_ADD:
+ case GL_ADD_SIGNED:
+ case GL_SUBTRACT:
+ numColorArgs = 2;
+ break;
+ case GL_INTERPOLATE:
+ case GL_MODULATE_ADD_ATI:
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ case GL_MODULATE_SUBTRACT_ATI:
+ numColorArgs = 3;
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+ switch (texUnit->Combine.ModeA) {
+ case GL_REPLACE:
+ numAlphaArgs = 1;
+ break;
+ case GL_MODULATE:
+ case GL_ADD:
+ case GL_ADD_SIGNED:
+ case GL_SUBTRACT:
+ numAlphaArgs = 2;
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+ /* Start fresh :) */
+ *reg = 0;
+
+ /* COLOR */
+ for (i = 0; i < 3; i++) {
+ arg1[i] = 0;
+ arg2[i] = 0;
+ alpha[i] = 0;
+ }
+
+ for (i = 0;i < numColorArgs; i++) {
+ switch (texUnit->Combine.SourceRGB[i]) {
+ case GL_TEXTURE:
+ arg1[i] |= 0;
+ arg2[i] |= ARG_DISABLE;
+ alpha[i] |= TD0_color_alpha_currtex;
+ break;
+ case GL_TEXTURE0:
+ if (source == 0) {
+ arg1[i] |= 0;
+ arg2[i] |= ARG_DISABLE;
+ alpha[i] |= TD0_color_alpha_currtex;
+ } else {
+ if (ctx->Texture._EnabledUnits != 0x03) {
+ /* disable texturing */
+ mmesa->setup.dwgctl &= DC_opcod_MASK;
+ mmesa->setup.dwgctl |= DC_opcod_trap;
+ mmesa->hw.alpha_sel = AC_alphasel_diffused;
+ /* return GL_TRUE since we don't need a fallback */
+ return GL_TRUE;
+ }
+ arg1[i] |= ARG_DISABLE;
+ arg2[i] |= ARG_DISABLE;
+ alpha[i] |= TD0_color_alpha_prevtex;
+ }
+ break;
+ case GL_TEXTURE1:
+ if (source == 0) {
+ if (ctx->Texture._EnabledUnits != 0x03) {
+ /* disable texturing */
+ mmesa->setup.dwgctl &= DC_opcod_MASK;
+ mmesa->setup.dwgctl |= DC_opcod_trap;
+ mmesa->hw.alpha_sel = AC_alphasel_diffused;
+ /* return GL_TRUE since we don't need a fallback */
+ return GL_TRUE;
+ }
+ arg1[i] |= ARG_DISABLE;
+ /* G400 specs (TDUALSTAGE0) */
+ arg2[i] |= TD0_color_arg2_prevstage;
+ alpha[i] |= TD0_color_alpha_prevstage;
+ } else {
+ arg1[i] |= 0;
+ arg2[i] |= ARG_DISABLE;
+ alpha[i] |= TD0_color_alpha_currtex;
+ }
+ break;
+ case GL_CONSTANT:
+ if (mmesa->fcol_used &&
+ mmesa->envcolor[source] != mmesa->envcolor[!source])
+ return GL_FALSE;
+
+ arg1[i] |= ARG_DISABLE;
+ arg2[i] |= TD0_color_arg2_fcol;
+ alpha[i] |= TD0_color_alpha_fcol;
+
+ mmesa->setup.fcol = mmesa->envcolor[source];
+ mmesa->fcol_used = GL_TRUE;
+ break;
+ case GL_PRIMARY_COLOR:
+ arg1[i] |= ARG_DISABLE;
+ /* G400 specs (TDUALSTAGE1) */
+ if (unit == 0 || (mmesa->setup.tdualstage0 &
+ ((TD0_color_sel_mul & TD0_color_sel_add) |
+ (TD0_alpha_sel_mul & TD0_alpha_sel_add)))) {
+ arg2[i] |= TD0_color_arg2_diffuse;
+ alpha[i] |= TD0_color_alpha_diffuse;
+ } else {
+ arg2[i] |= ARG_DISABLE;
+ alpha[i] |= ARG_DISABLE;
+ }
+ break;
+ case GL_PREVIOUS:
+ arg1[i] |= ARG_DISABLE;
+ if (unit == 0) {
+ arg2[i] |= TD0_color_arg2_diffuse;
+ alpha[i] |= TD0_color_alpha_diffuse;
+ } else {
+ arg2[i] |= TD0_color_arg2_prevstage;
+ alpha[i] |= TD0_color_alpha_prevstage;
+ }
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+ switch (texUnit->Combine.OperandRGB[i]) {
+ case GL_SRC_COLOR:
+ arg1[i] |= 0;
+ arg2[i] |= 0;
+ if (texUnit->Combine.SourceRGB[i] == GL_CONSTANT &&
+ RGBA_EQUAL( mmesa->envcolor[source] )) {
+ alpha[i] |= 0;
+ } else {
+ alpha[i] |= ARG_DISABLE;
+ }
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ arg1[i] |= TD0_color_arg1_inv_enable;
+ arg2[i] |= TD0_color_arg2_inv_enable;
+ if (texUnit->Combine.SourceRGB[i] == GL_CONSTANT &&
+ RGBA_EQUAL( mmesa->envcolor[source] )) {
+ alpha[i] |= (TD0_color_alpha1inv_enable |
+ TD0_color_alpha2inv_enable);
+ } else {
+ alpha[i] |= ARG_DISABLE;
+ }
+ break;
+ case GL_SRC_ALPHA:
+ arg1[i] |= TD0_color_arg1_replicatealpha_enable;
+ arg2[i] |= TD0_color_arg2_replicatealpha_enable;
+ alpha[i] |= 0;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ arg1[i] |= (TD0_color_arg1_replicatealpha_enable |
+ TD0_color_arg1_inv_enable);
+ arg2[i] |= (TD0_color_arg2_replicatealpha_enable |
+ TD0_color_arg2_inv_enable);
+ alpha[i] |= (TD0_color_alpha1inv_enable |
+ TD0_color_alpha2inv_enable);
+ break;
+ }
+ }
+
+ switch (texUnit->Combine.ModeRGB) {
+ case GL_MODULATE_ADD_ATI:
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ /* Special handling for ATI_texture_env_combine3.
+ * If Arg1 == Arg0 or Arg1 == Arg2 we can use arg1 or arg2 as input for
+ * both multiplier and adder.
+ */
+ /* Arg1 == arg1 */
+ if (arg1[1] == arg1[0]) {
+ if ((arg1[1] | arg2[2]) != ARG_DISABLE) {
+ *reg |= arg1[1] | arg2[2];
+ args[0] = MGA_ARG1; args[1] = MGA_ARG1; args[2] = MGA_ARG2;
+ break;
+ } else
+ if ((arg1[1] | alpha[2]) != ARG_DISABLE) {
+ *reg |= arg1[1] | alpha[2];
+ args[0] = MGA_ARG1; args[1] = MGA_ARG1; args[2] = MGA_ALPHA;
+ break;
+ }
+ }
+ if (arg1[1] == arg1[2]) {
+ if ((arg1[1] | arg2[0]) != ARG_DISABLE) {
+ *reg |= arg1[1] | arg2[0];
+ args[0] = MGA_ARG2; args[1] = MGA_ARG1; args[2] = MGA_ARG1;
+ break;
+ } else
+ if ((arg1[1] | alpha[0]) != ARG_DISABLE) {
+ *reg |= arg1[1] | alpha[0];
+ args[0] = MGA_ALPHA; args[1] = MGA_ARG1; args[2] = MGA_ARG1;
+ break;
+ }
+ }
+ /* fallthrough */
+ case GL_MODULATE_SUBTRACT_ATI:
+ /* Arg1 == arg2 */
+ if (arg2[1] == arg2[0]) {
+ if ((arg2[1] | arg1[2]) != ARG_DISABLE) {
+ *reg |= arg2[1] | arg1[2];
+ args[0] = MGA_ARG2; args[1] = MGA_ARG2; args[2] = MGA_ARG1;
+ break;
+ } else
+ if ((arg2[1] | alpha[2]) != ARG_DISABLE) {
+ *reg |= arg2[1] | alpha[2];
+ args[0] = MGA_ARG2; args[1] = MGA_ARG2; args[2] = MGA_ALPHA;
+ break;
+ }
+ }
+ if (arg2[1] == arg2[2]) {
+ if ((arg2[1] | arg1[0]) != ARG_DISABLE) {
+ *reg |= arg2[1] | arg1[0];
+ args[0] = MGA_ARG1; args[1] = MGA_ARG2; args[2] = MGA_ARG2;
+ break;
+ } else
+ if ((arg2[1] | alpha[0]) != ARG_DISABLE) {
+ *reg |= arg2[1] | alpha[0];
+ args[0] = MGA_ALPHA; args[1] = MGA_ARG2; args[2] = MGA_ARG2;
+ break;
+ }
+ }
+ /* fallthrough */
+ default:
+ /* Find working combo of arg1, arg2 and alpha.
+ *
+ * Keep the Arg0 != alpha cases first since there's
+ * no way to get alpha out by itself (GL_REPLACE).
+ *
+ * Keep the Arg2 == alpha cases first because only alpha has the
+ * capabilities to function as Arg2 (GL_INTERPOLATE). Also good for
+ * GL_ADD, GL_ADD_SIGNED, GL_SUBTRACT since we can't get alpha to the
+ * adder.
+ *
+ * Keep the Arg1 == alpha cases last for GL_MODULATE_ADD_ATI,
+ * GL_MODULATE_SIGNED_ADD_ATI. Again because we can't get alpha to the
+ * adder.
+ *
+ * GL_MODULATE_SUBTRACT_ATI needs special treatment since it requires
+ * that Arg1 == arg2. This requirement clashes with those of other modes.
+ */
+ if ((arg1[0] | arg2[1] | alpha[2]) != ARG_DISABLE) {
+ *reg |= arg1[0] | arg2[1] | alpha[2];
+ args[0] = MGA_ARG1; args[1] = MGA_ARG2; args[2] = MGA_ALPHA;
+ } else
+ if ((arg1[1] | arg2[0] | alpha[2]) != ARG_DISABLE &&
+ texUnit->Combine.ModeRGB != GL_MODULATE_SUBTRACT_ATI) {
+ *reg |= arg1[1] | arg2[0] | alpha[2];
+ args[0] = MGA_ARG2; args[1] = MGA_ARG1; args[2] = MGA_ALPHA;
+ } else
+ if ((arg1[1] | arg2[2] | alpha[0]) != ARG_DISABLE &&
+ texUnit->Combine.ModeRGB != GL_MODULATE_SUBTRACT_ATI) {
+ *reg |= arg1[1] | arg2[2] | alpha[0];
+ args[0] = MGA_ALPHA; args[1] = MGA_ARG1; args[2] = MGA_ARG2;
+ } else
+ if ((arg1[2] | arg2[1] | alpha[0]) != ARG_DISABLE) {
+ *reg |= arg1[2] | arg2[1] | alpha[0];
+ args[0] = MGA_ALPHA; args[1] = MGA_ARG2; args[2] = MGA_ARG1;
+ } else
+ if ((arg1[0] | arg2[2] | alpha[1]) != ARG_DISABLE) {
+ *reg |= arg1[0] | arg2[2] | alpha[1];
+ args[0] = MGA_ARG1; args[1] = MGA_ALPHA; args[2] = MGA_ARG2;
+ } else
+ if ((arg1[2] | arg2[0] | alpha[1]) != ARG_DISABLE) {
+ *reg |= arg1[2] | arg2[0] | alpha[1];
+ args[0] = MGA_ARG2; args[1] = MGA_ALPHA; args[2] = MGA_ARG1;
+ } else {
+ /* nothing suitable */
+ return GL_FALSE;
+ }
+ }
+
+ switch (texUnit->Combine.ModeRGB) {
+ case GL_REPLACE:
+ if (texUnit->Combine.ScaleShiftRGB) {
+ return GL_FALSE;
+ }
+
+ if (args[0] == MGA_ARG1) {
+ *reg |= TD0_color_sel_arg1;
+ } else if (args[0] == MGA_ARG2) {
+ *reg |= TD0_color_sel_arg2;
+ } else if (args[0] == MGA_ALPHA) {
+ /* Can't get alpha out by itself */
+ return GL_FALSE;
+ }
+ break;
+ case GL_MODULATE:
+ if (texUnit->Combine.ScaleShiftRGB == 1) {
+ *reg |= TD0_color_modbright_2x;
+ } else if (texUnit->Combine.ScaleShiftRGB == 2) {
+ *reg |= TD0_color_modbright_4x;
+ }
+
+ *reg |= TD0_color_sel_mul;
+
+ if (args[0] == MGA_ALPHA || args[1] == MGA_ALPHA) {
+ if (args[0] == MGA_ARG1 || args[1] == MGA_ARG1) {
+ *reg |= TD0_color_arg2mul_alpha2;
+ } else if (args[0] == MGA_ARG2 || args[1] == MGA_ARG2) {
+ *reg |= TD0_color_arg1mul_alpha1;
+ }
+ }
+ break;
+ case GL_ADD_SIGNED:
+ *reg |= TD0_color_addbias_enable;
+ /* fallthrough */
+ case GL_ADD:
+ if (args[0] == MGA_ALPHA || args[1] == MGA_ALPHA) {
+ /* Can't get alpha to the adder */
+ return GL_FALSE;
+ }
+ if (texUnit->Combine.ScaleShiftRGB == 1) {
+ *reg |= TD0_color_add2x_enable;
+ } else if (texUnit->Combine.ScaleShiftRGB == 2) {
+ return GL_FALSE;
+ }
+
+ *reg |= (TD0_color_add_add |
+ TD0_color_sel_add);
+ break;
+ case GL_INTERPOLATE:
+ if (args[2] != MGA_ALPHA) {
+ /* Only alpha can function as Arg2 */
+ return GL_FALSE;
+ }
+ if (texUnit->Combine.ScaleShiftRGB == 1) {
+ *reg |= TD0_color_add2x_enable;
+ } else if (texUnit->Combine.ScaleShiftRGB == 2) {
+ return GL_FALSE;
+ }
+
+ *reg |= (TD0_color_arg1mul_alpha1 |
+ TD0_color_blend_enable |
+ TD0_color_arg1add_mulout |
+ TD0_color_arg2add_mulout |
+ TD0_color_add_add |
+ TD0_color_sel_add);
+
+ /* Have to do this with xor since GL_ONE_MINUS_SRC_ALPHA may have
+ * already touched this bit.
+ */
+ *reg ^= TD0_color_alpha1inv_enable;
+
+ if (args[0] == MGA_ARG2) {
+ /* Swap arguments */
+ *reg ^= (TD0_color_arg1mul_alpha1 |
+ TD0_color_arg2mul_alpha2 |
+ TD0_color_alpha1inv_enable |
+ TD0_color_alpha2inv_enable);
+ }
+
+ if (ctx->Texture._EnabledUnits != 0x03) {
+ /* Linear blending mode needs dualtex enabled */
+ *(reg+1) = (TD0_color_arg2_prevstage |
+ TD0_color_sel_arg2 |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2);
+ mmesa->force_dualtex = GL_TRUE;
+ }
+ break;
+ case GL_SUBTRACT:
+ if (args[0] == MGA_ALPHA || args[1] == MGA_ALPHA) {
+ /* Can't get alpha to the adder */
+ return GL_FALSE;
+ }
+ if (texUnit->Combine.ScaleShiftRGB == 1) {
+ *reg |= TD0_color_add2x_enable;
+ } else if (texUnit->Combine.ScaleShiftRGB == 2) {
+ return GL_FALSE;
+ }
+
+ *reg |= (TD0_color_add_sub |
+ TD0_color_sel_add);
+
+ if (args[0] == MGA_ARG2) {
+ /* Swap arguments */
+ *reg ^= (TD0_color_arg1_inv_enable |
+ TD0_color_arg2_inv_enable);
+ }
+ break;
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ *reg |= TD0_color_addbias_enable;
+ /* fallthrough */
+ case GL_MODULATE_ADD_ATI:
+ if (args[1] == MGA_ALPHA) {
+ /* Can't get alpha to the adder */
+ return GL_FALSE;
+ }
+ if (texUnit->Combine.ScaleShiftRGB == 1) {
+ *reg |= TD0_color_add2x_enable;
+ } else if (texUnit->Combine.ScaleShiftRGB == 2) {
+ return GL_FALSE;
+ }
+
+ *reg |= (TD0_color_add_add |
+ TD0_color_sel_add);
+
+ if (args[1] == args[0] || args[1] == args[2]) {
+ *reg |= TD0_color_arg1add_mulout;
+ if (args[0] == MGA_ALPHA || args[2] == MGA_ALPHA)
+ *reg |= TD0_color_arg1mul_alpha1;
+
+ if (args[1] == MGA_ARG1) {
+ /* Swap adder arguments */
+ *reg ^= (TD0_color_arg1add_mulout |
+ TD0_color_arg2add_mulout);
+ if (args[0] == MGA_ALPHA || args[2] == MGA_ALPHA) {
+ /* Swap multiplier arguments */
+ *reg ^= (TD0_color_arg1mul_alpha1 |
+ TD0_color_arg2mul_alpha2);
+ }
+ }
+ } else {
+ *reg |= (TD0_color_arg2mul_alpha2 |
+ TD0_color_arg1add_mulout);
+
+ if (args[1] == MGA_ARG1) {
+ /* Swap arguments */
+ *reg ^= (TD0_color_arg1mul_alpha1 |
+ TD0_color_arg2mul_alpha2 |
+ TD0_color_arg1add_mulout |
+ TD0_color_arg2add_mulout);
+ }
+ }
+ break;
+ case GL_MODULATE_SUBTRACT_ATI:
+ if (args[1] != MGA_ARG2) {
+ /* Can't swap arguments */
+ return GL_FALSE;
+ }
+ if (texUnit->Combine.ScaleShiftRGB == 1) {
+ *reg |= TD0_color_add2x_enable;
+ } else if (texUnit->Combine.ScaleShiftRGB == 2) {
+ return GL_FALSE;
+ }
+
+ *reg |= (TD0_color_add_sub |
+ TD0_color_sel_add);
+
+ if (args[1] == args[0] || args[1] == args[2]) {
+ *reg |= TD0_color_arg1add_mulout;
+ if (args[0] == MGA_ALPHA || args[2] == MGA_ALPHA)
+ *reg |= TD0_color_arg1mul_alpha1;
+ } else {
+ *reg |= (TD0_color_arg2mul_alpha2 |
+ TD0_color_arg1add_mulout);
+ }
+ break;
+ }
+
+
+ /* ALPHA */
+ for (i = 0; i < 2; i++) {
+ arg1[i] = 0;
+ arg2[i] = 0;
+ }
+
+ for (i = 0; i < numAlphaArgs; i++) {
+ switch (texUnit->Combine.SourceA[i]) {
+ case GL_TEXTURE:
+ arg1[i] |= 0;
+ arg2[i] |= ARG_DISABLE;
+ break;
+ case GL_TEXTURE0:
+ if (source == 0) {
+ arg1[i] |= 0;
+ arg2[i] |= ARG_DISABLE;
+ } else {
+ if (ctx->Texture._EnabledUnits != 0x03) {
+ /* disable texturing */
+ mmesa->setup.dwgctl &= DC_opcod_MASK;
+ mmesa->setup.dwgctl |= DC_opcod_trap;
+ mmesa->hw.alpha_sel = AC_alphasel_diffused;
+ /* return GL_TRUE since we don't need a fallback */
+ return GL_TRUE;
+ }
+ arg1[i] |= ARG_DISABLE;
+ arg2[i] |= TD0_alpha_arg2_prevtex;
+ }
+ break;
+ case GL_TEXTURE1:
+ if (source == 0) {
+ if (ctx->Texture._EnabledUnits != 0x03) {
+ /* disable texturing */
+ mmesa->setup.dwgctl &= DC_opcod_MASK;
+ mmesa->setup.dwgctl |= DC_opcod_trap;
+ mmesa->hw.alpha_sel = AC_alphasel_diffused;
+ /* return GL_TRUE since we don't need a fallback */
+ return GL_TRUE;
+ }
+ arg1[i] |= ARG_DISABLE;
+ /* G400 specs (TDUALSTAGE0) */
+ arg2[i] |= TD0_alpha_arg2_prevstage;
+ } else {
+ arg1[i] |= 0;
+ arg2[i] |= ARG_DISABLE;
+ }
+ break;
+ case GL_CONSTANT:
+ if (mmesa->fcol_used &&
+ mmesa->envcolor[source] != mmesa->envcolor[!source])
+ return GL_FALSE;
+
+ arg1[i] |= ARG_DISABLE;
+ arg2[i] |= TD0_alpha_arg2_fcol;
+
+ mmesa->setup.fcol = mmesa->envcolor[source];
+ mmesa->fcol_used = GL_TRUE;
+ break;
+ case GL_PRIMARY_COLOR:
+ arg1[i] |= ARG_DISABLE;
+ /* G400 specs (TDUALSTAGE1) */
+ if (unit == 0 || (mmesa->setup.tdualstage0 &
+ ((TD0_color_sel_mul & TD0_color_sel_add) |
+ (TD0_alpha_sel_mul & TD0_alpha_sel_add)))) {
+ arg2[i] |= TD0_alpha_arg2_diffuse;
+ } else {
+ arg2[i] |= ARG_DISABLE;
+ }
+ break;
+ case GL_PREVIOUS:
+ arg1[i] |= ARG_DISABLE;
+ if (unit == 0) {
+ arg2[i] |= TD0_alpha_arg2_diffuse;
+ } else {
+ arg2[i] |= TD0_alpha_arg2_prevstage;
+ }
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+ switch (texUnit->Combine.OperandA[i]) {
+ case GL_SRC_ALPHA:
+ arg1[i] |= 0;
+ arg2[i] |= 0;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ arg1[i] |= TD0_alpha_arg1_inv_enable;
+ arg2[i] |= TD0_alpha_arg2_inv_enable;
+ break;
+ }
+ }
+
+ /* Find a working combo of arg1 and arg2 */
+ if ((arg1[0] | arg2[1]) != ARG_DISABLE) {
+ *reg |= arg1[0] | arg2[1];
+ args[0] = MGA_ARG1; args[1] = MGA_ARG2;
+ } else
+ if ((arg1[1] | arg2[0]) != ARG_DISABLE) {
+ *reg |= arg1[1] | arg2[0];
+ args[0] = MGA_ARG2; args[1] = MGA_ARG1;
+ } else {
+ /* nothing suitable */
+ return GL_FALSE;
+ }
+
+ switch (texUnit->Combine.ModeA) {
+ case GL_REPLACE:
+ if (texUnit->Combine.ScaleShiftA) {
+ return GL_FALSE;
+ }
+
+ if (args[0] == MGA_ARG1) {
+ *reg |= TD0_alpha_sel_arg1;
+ } else if (args[0] == MGA_ARG2) {
+ *reg |= TD0_alpha_sel_arg2;
+ }
+ break;
+ case GL_MODULATE:
+ if (texUnit->Combine.ScaleShiftA == 1) {
+ *reg |= TD0_alpha_modbright_2x;
+ } else if (texUnit->Combine.ScaleShiftA == 2) {
+ *reg |= TD0_alpha_modbright_4x;
+ }
+
+ *reg |= TD0_alpha_sel_mul;
+ break;
+ case GL_ADD_SIGNED:
+ *reg |= TD0_alpha_addbias_enable;
+ /* fallthrough */
+ case GL_ADD:
+ if (texUnit->Combine.ScaleShiftA == 1) {
+ *reg |= TD0_alpha_add2x_enable;
+ } else if (texUnit->Combine.ScaleShiftA == 2) {
+ return GL_FALSE;
+ }
+
+ *reg |= (TD0_alpha_add_enable |
+ TD0_alpha_sel_add);
+ break;
+ case GL_SUBTRACT:
+ if (texUnit->Combine.ScaleShiftA == 1) {
+ *reg |= TD0_alpha_add2x_enable;
+ } else if (texUnit->Combine.ScaleShiftA == 2) {
+ return GL_FALSE;
+ }
+
+ *reg |= (TD0_alpha_add_disable |
+ TD0_alpha_sel_add);
+
+ if (args[0] == MGA_ARG2) {
+ /* Swap arguments */
+ *reg ^= (TD0_alpha_arg1_inv_enable |
+ TD0_alpha_arg2_inv_enable);
+ }
+ break;
+ }
+
+ return GL_TRUE;
+}
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mga_texstate.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mga_texstate.c
new file mode 100644
index 000000000..8c28254cb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mga_texstate.c
@@ -0,0 +1,902 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * (c) Copyright IBM Corporation 2002
+ * 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
+ * VA LINUX SYSTEMS, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Ian Romanick <idr@us.ibm.com>
+ * Keith Whitwell <keithw@tungstengraphics.com>
+ */
+/* $XFree86:$ */
+
+#include <stdlib.h>
+#include "mm.h"
+#include "mgacontext.h"
+#include "mgatex.h"
+#include "mgaregs.h"
+#include "mgatris.h"
+#include "mgaioctl.h"
+
+#include "context.h"
+#include "enums.h"
+#include "macros.h"
+#include "imports.h"
+
+#include "simple_list.h"
+#include "texformat.h"
+
+#define MGA_USE_TABLE_FOR_FORMAT
+#ifdef MGA_USE_TABLE_FOR_FORMAT
+#define TMC_nr_tformat (MESA_FORMAT_YCBCR_REV + 1)
+static const unsigned TMC_tformat[ TMC_nr_tformat ] =
+{
+ [MESA_FORMAT_ARGB8888] = TMC_tformat_tw32,
+ [MESA_FORMAT_RGB565] = TMC_tformat_tw16,
+ [MESA_FORMAT_ARGB4444] = TMC_tformat_tw12,
+ [MESA_FORMAT_ARGB1555] = TMC_tformat_tw15,
+ [MESA_FORMAT_AL88] = TMC_tformat_tw8al,
+ [MESA_FORMAT_I8] = TMC_tformat_tw8a,
+ [MESA_FORMAT_CI8] = TMC_tformat_tw8 ,
+ [MESA_FORMAT_YCBCR] = TMC_tformat_tw422uyvy,
+ [MESA_FORMAT_YCBCR_REV] = TMC_tformat_tw422,
+};
+#endif
+
+static void
+mgaSetTexImages( mgaContextPtr mmesa,
+ const struct gl_texture_object * tObj )
+{
+ mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData;
+ struct gl_texture_image *baseImage = tObj->Image[0][ tObj->BaseLevel ];
+ GLint totalSize;
+ GLint width, height;
+ GLint i;
+ GLint numLevels;
+ GLint log2Width, log2Height;
+ GLuint txformat = 0;
+ GLint ofs;
+
+ /* Set the hardware texture format
+ */
+#ifndef MGA_USE_TABLE_FOR_FORMAT
+ switch (baseImage->TexFormat->MesaFormat) {
+
+ case MESA_FORMAT_ARGB8888: txformat = TMC_tformat_tw32; break;
+ case MESA_FORMAT_RGB565: txformat = TMC_tformat_tw16; break;
+ case MESA_FORMAT_ARGB4444: txformat = TMC_tformat_tw12; break;
+ case MESA_FORMAT_ARGB1555: txformat = TMC_tformat_tw15; break;
+ case MESA_FORMAT_AL88: txformat = TMC_tformat_tw8al; break;
+ case MESA_FORMAT_I8: txformat = TMC_tformat_tw8a; break;
+ case MESA_FORMAT_CI8: txformat = TMC_tformat_tw8; break;
+ case MESA_FORMAT_YCBCR: txformat = TMC_tformat_tw422uyvy; break;
+ case MESA_FORMAT_YCBCR_REV: txformat = TMC_tformat_tw422; break;
+
+ default:
+ _mesa_problem(NULL, "unexpected texture format in %s", __FUNCTION__);
+ return;
+ }
+#else
+ if ( (baseImage->TexFormat->MesaFormat >= TMC_nr_tformat)
+ || (TMC_tformat[ baseImage->TexFormat->MesaFormat ] == 0) )
+ {
+ _mesa_problem(NULL, "unexpected texture format in %s", __FUNCTION__);
+ return;
+ }
+
+ txformat = TMC_tformat[ baseImage->TexFormat->MesaFormat ];
+
+#endif /* MGA_USE_TABLE_FOR_FORMAT */
+
+ driCalculateTextureFirstLastLevel( (driTextureObject *) t );
+ if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
+ log2Width = 0;
+ log2Height = 0;
+ } else {
+ log2Width = tObj->Image[0][t->base.firstLevel]->WidthLog2;
+ log2Height = tObj->Image[0][t->base.firstLevel]->HeightLog2;
+ }
+
+ width = tObj->Image[0][t->base.firstLevel]->Width;
+ height = tObj->Image[0][t->base.firstLevel]->Height;
+
+ numLevels = MIN2( t->base.lastLevel - t->base.firstLevel + 1,
+ MGA_IS_G200(mmesa) ? G200_TEX_MAXLEVELS : G400_TEX_MAXLEVELS);
+
+
+ totalSize = 0;
+ for ( i = 0 ; i < numLevels ; i++ ) {
+ const struct gl_texture_image * const texImage =
+ tObj->Image[0][ i + t->base.firstLevel ];
+ int size;
+
+ if (texImage == NULL)
+ break;
+
+ size = texImage->Width * texImage->Height *
+ baseImage->TexFormat->TexelBytes;
+
+ t->offsets[i] = totalSize;
+ t->base.dirty_images[0] |= (1<<i);
+
+ /* All mipmaps must be 32-byte aligned */
+ totalSize += (size + 31) & ~31;
+
+ /* Since G400 calculates the offsets in hardware
+ * it can't handle more than one < 32 byte mipmap.
+ *
+ * Further testing has indicated that it can't
+ * handle any < 32 byte mipmaps.
+ */
+ if (MGA_IS_G400( mmesa ) && size <= 32) {
+ i++;
+ break;
+ }
+ }
+
+ /* save these values */
+ numLevels = i;
+ t->base.lastLevel = t->base.firstLevel + numLevels - 1;
+ t->base.totalSize = totalSize;
+
+ /* setup hardware register values */
+ t->setup.texctl &= (TMC_tformat_MASK & TMC_tpitch_MASK
+ & TMC_tpitchext_MASK);
+ t->setup.texctl |= txformat;
+
+
+ /* Set the texture width. In order to support non-power of 2 textures and
+ * textures larger than 1024 texels wide, "linear" pitch must be used. For
+ * the linear pitch, if the width is 2048, a value of zero is used.
+ */
+
+ t->setup.texctl |= TMC_tpitchlin_enable;
+ t->setup.texctl |= MGA_FIELD( TMC_tpitchext, width & (2048 - 1) );
+
+
+ /* G400 specifies the number of mip levels in a strange way. Since there
+ * are up to 11 levels, it requires 4 bits. Three of the bits are at the
+ * high end of TEXFILTER. The other bit is in the middle. Weird.
+ */
+ numLevels--;
+ t->setup.texfilter &= TF_mapnb_MASK & TF_mapnbhigh_MASK & TF_reserved_MASK;
+ t->setup.texfilter |= MGA_FIELD( TF_mapnb, numLevels & 0x7 );
+ t->setup.texfilter |= MGA_FIELD( TF_mapnbhigh, (numLevels >> 3) & 0x1 );
+
+ /* warp texture registers */
+ ofs = MGA_IS_G200(mmesa) ? 28 : 11;
+
+ t->setup.texwidth = (MGA_FIELD(TW_twmask, width - 1) |
+ MGA_FIELD(TW_rfw, (10 - log2Width - 8) & 63 ) |
+ MGA_FIELD(TW_tw, (log2Width + ofs ) | 0x40 ));
+
+ t->setup.texheight = (MGA_FIELD(TH_thmask, height - 1) |
+ MGA_FIELD(TH_rfh, (10 - log2Height - 8) & 63 ) |
+ MGA_FIELD(TH_th, (log2Height + ofs ) | 0x40 ));
+
+ mgaUploadTexImages( mmesa, t );
+}
+
+
+/* ================================================================
+ * Texture unit state management
+ */
+
+static void mgaUpdateTextureEnvG200( GLcontext *ctx, GLuint unit )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ struct gl_texture_object *tObj = ctx->Texture.Unit[0]._Current;
+ mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData;
+ GLenum format = tObj->Image[0][tObj->BaseLevel]->Format;
+
+ if (tObj != ctx->Texture.Unit[0].Current2D &&
+ tObj != ctx->Texture.Unit[0].CurrentRect)
+ return;
+
+
+ t->setup.texctl &= ~TMC_tmodulate_enable;
+ t->setup.texctl2 &= ~(TMC_decalblend_enable |
+ TMC_idecal_enable |
+ TMC_decaldis_enable);
+
+ switch (ctx->Texture.Unit[0].EnvMode) {
+ case GL_REPLACE:
+ if (format == GL_ALPHA)
+ t->setup.texctl2 |= TMC_idecal_enable;
+
+ if (format == GL_RGB || format == GL_LUMINANCE)
+ mmesa->hw.alpha_sel = AC_alphasel_diffused;
+ else
+ mmesa->hw.alpha_sel = AC_alphasel_fromtex;
+ break;
+
+ case GL_MODULATE:
+ t->setup.texctl |= TMC_tmodulate_enable;
+
+ if (format == GL_ALPHA)
+ t->setup.texctl2 |= (TMC_idecal_enable |
+ TMC_decaldis_enable);
+
+ if (format == GL_RGB || format == GL_LUMINANCE)
+ mmesa->hw.alpha_sel = AC_alphasel_diffused;
+ else
+ mmesa->hw.alpha_sel = AC_alphasel_modulated;
+ break;
+
+ case GL_DECAL:
+ if (format == GL_RGB || format == GL_RGBA)
+ t->setup.texctl2 |= TMC_decalblend_enable;
+ else
+ t->setup.texctl2 |= TMC_idecal_enable;
+
+ mmesa->hw.alpha_sel = AC_alphasel_diffused;
+ break;
+
+ case GL_BLEND:
+ if (format == GL_ALPHA) {
+ t->setup.texctl2 |= TMC_idecal_enable;
+ mmesa->hw.alpha_sel = AC_alphasel_modulated;
+ } else {
+ t->texenv_fallback = GL_TRUE;
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+#define MGA_REPLACE 0
+#define MGA_MODULATE 1
+#define MGA_DECAL 2
+#define MGA_ADD 3
+#define MGA_MAX_COMBFUNC 4
+
+static const GLuint g400_color_combine[][MGA_MAX_COMBFUNC] =
+{
+ /* Unit 0:
+ */
+ {
+ /* GL_REPLACE
+ * Cv = Cs
+ * Av = Af
+ */
+ (TD0_color_sel_arg1 |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_arg2),
+
+ /* GL_MODULATE
+ * Cv = Cf Cs
+ * Av = Af
+ */
+ (TD0_color_arg2_diffuse |
+ TD0_color_sel_mul |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_arg2),
+
+ /* GL_DECAL
+ * Cv = Cs
+ * Av = Af
+ */
+ (TD0_color_sel_arg1 |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_arg2),
+
+ /* GL_ADD
+ * Cv = Cf + Cs
+ * Av = Af
+ */
+ (TD0_color_arg2_diffuse |
+ TD0_color_add_add |
+ TD0_color_sel_add |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_arg2),
+ },
+
+ /* Unit 1:
+ */
+ {
+ /* GL_REPLACE
+ * Cv = Cs
+ * Av = Ap
+ */
+ (TD0_color_sel_arg1 |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2),
+
+ /* GL_MODULATE
+ * Cv = Cp Cs
+ * Av = Ap
+ */
+ (TD0_color_arg2_prevstage |
+ TD0_color_sel_mul |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2),
+
+ /* GL_DECAL
+ * Cv = Cs
+ * Av = Ap
+ */
+ (TD0_color_sel_arg1 |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2),
+
+ /* GL_ADD
+ * Cv = Cp + Cs
+ * Av = Ap
+ */
+ (TD0_color_arg2_prevstage |
+ TD0_color_add_add |
+ TD0_color_sel_add |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2),
+ },
+};
+
+static const GLuint g400_color_alpha_combine[][MGA_MAX_COMBFUNC] =
+{
+ /* Unit 0:
+ */
+ {
+ /* GL_REPLACE
+ * Cv = Cs
+ * Av = As
+ */
+ (TD0_color_sel_arg1 |
+ TD0_alpha_sel_arg1),
+
+ /* GL_MODULATE
+ * Cv = Cf Cs
+ * Av = Af As
+ */
+ (TD0_color_arg2_diffuse |
+ TD0_color_sel_mul |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_mul),
+
+ /* GL_DECAL
+ * tmp = Cf ( 1 - As )
+ * Cv = tmp + Cs As
+ * Av = Af
+ */
+ (TD0_color_arg2_diffuse |
+ TD0_color_alpha_currtex |
+ TD0_color_alpha1inv_enable |
+ TD0_color_arg1mul_alpha1 |
+ TD0_color_blend_enable |
+ TD0_color_arg1add_mulout |
+ TD0_color_arg2add_mulout |
+ TD0_color_add_add |
+ TD0_color_sel_add |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_arg2),
+
+ /* GL_ADD
+ * Cv = Cf + Cs
+ * Av = Af As
+ */
+ (TD0_color_arg2_diffuse |
+ TD0_color_add_add |
+ TD0_color_sel_add |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_mul),
+ },
+
+ /* Unit 1:
+ */
+ {
+ /* GL_REPLACE
+ * Cv = Cs
+ * Av = As
+ */
+ (TD0_color_sel_arg1 |
+ TD0_alpha_sel_arg1),
+
+ /* GL_MODULATE
+ * Cv = Cp Cs
+ * Av = Ap As
+ */
+ (TD0_color_arg2_prevstage |
+ TD0_color_sel_mul |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_mul),
+
+ /* GL_DECAL
+ * tmp = Cp ( 1 - As )
+ * Cv = tmp + Cs As
+ * Av = Ap
+ */
+ (TD0_color_arg2_prevstage |
+ TD0_color_alpha_currtex |
+ TD0_color_alpha1inv_enable |
+ TD0_color_arg1mul_alpha1 |
+ TD0_color_blend_enable |
+ TD0_color_arg1add_mulout |
+ TD0_color_arg2add_mulout |
+ TD0_color_add_add |
+ TD0_color_sel_add |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2),
+
+ /* GL_ADD
+ * Cv = Cp + Cs
+ * Av = Ap As
+ */
+ (TD0_color_arg2_prevstage |
+ TD0_color_add_add |
+ TD0_color_sel_add |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_mul),
+ },
+};
+
+static const GLuint g400_alpha_combine[][MGA_MAX_COMBFUNC] =
+{
+ /* Unit 0:
+ */
+ {
+ /* GL_REPLACE
+ * Cv = Cf
+ * Av = As
+ */
+ (TD0_color_arg2_diffuse |
+ TD0_color_sel_arg2 |
+ TD0_alpha_sel_arg1),
+
+ /* GL_MODULATE
+ * Cv = Cf
+ * Av = Af As
+ */
+ (TD0_color_arg2_diffuse |
+ TD0_color_sel_arg2 |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_mul),
+
+ /* GL_DECAL (undefined)
+ * Cv = Cf
+ * Av = Af
+ */
+ (TD0_color_arg2_diffuse |
+ TD0_color_sel_arg2 |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_arg2),
+
+ /* GL_ADD
+ * Cv = Cf
+ * Av = Af As
+ */
+ (TD0_color_arg2_diffuse |
+ TD0_color_sel_arg2 |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_mul),
+ },
+
+ /* Unit 1:
+ */
+ {
+ /* GL_REPLACE
+ * Cv = Cp
+ * Av = As
+ */
+ (TD0_color_arg2_prevstage |
+ TD0_color_sel_arg2 |
+ TD0_alpha_sel_arg1),
+
+ /* GL_MODULATE
+ * Cv = Cp
+ * Av = Ap As
+ */
+ (TD0_color_arg2_prevstage |
+ TD0_color_sel_arg2 |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_mul),
+
+ /* GL_DECAL (undefined)
+ * Cv = Cp
+ * Av = Ap
+ */
+ (TD0_color_arg2_prevstage |
+ TD0_color_sel_arg2 |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2),
+
+ /* GL_ADD
+ * Cv = Cp
+ * Av = Ap As
+ */
+ (TD0_color_arg2_prevstage |
+ TD0_color_sel_arg2 |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_mul),
+ },
+};
+
+static GLboolean mgaUpdateTextureEnvBlend( GLcontext *ctx, int unit )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ const int source = mmesa->tmu_source[unit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
+ const struct gl_texture_object *tObj = texUnit->_Current;
+ GLuint *reg = ((GLuint *)&mmesa->setup.tdualstage0 + unit);
+ GLenum format = tObj->Image[0][tObj->BaseLevel]->Format;
+
+ *reg = 0;
+
+ if (format == GL_ALPHA) {
+ /* Cv = Cf */
+ *reg |= (TD0_color_arg2_diffuse |
+ TD0_color_sel_arg2);
+ /* Av = Af As */
+ *reg |= (TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_mul);
+ return GL_TRUE;
+ }
+
+ /* C1 = Cf ( 1 - Cs ) */
+ *reg |= (TD0_color_arg1_inv_enable |
+ TD0_color_arg2_diffuse |
+ TD0_color_sel_mul);
+
+ if (format == GL_RGB || format == GL_LUMINANCE) {
+ /* A1 = Af */
+ *reg |= (TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_arg2);
+ } else
+ if (format == GL_RGBA || format == GL_LUMINANCE_ALPHA) {
+ /* A1 = Af As */
+ *reg |= (TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_mul);
+ } else
+ if (format == GL_INTENSITY) {
+ /* A1 = Af ( 1 - As ) */
+ *reg |= (TD0_alpha_arg1_inv_enable |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_sel_mul);
+ }
+
+ if (RGB_ZERO(mmesa->envcolor[source]) &&
+ (format != GL_INTENSITY || ALPHA_ZERO(mmesa->envcolor[source])))
+ return GL_TRUE; /* all done */
+
+ if (ctx->Texture._EnabledUnits == 0x03)
+ return GL_FALSE; /* need both units */
+
+ mmesa->force_dualtex = GL_TRUE;
+ reg = &mmesa->setup.tdualstage1;
+ *reg = 0;
+
+ if (RGB_ZERO(mmesa->envcolor[source])) {
+ /* Cv = C1 */
+ *reg |= (TD0_color_arg2_prevstage |
+ TD0_color_sel_arg2);
+ } else
+ if (RGB_ONE(mmesa->envcolor[source])) {
+ /* Cv = C1 + Cs */
+ *reg |= (TD0_color_arg2_prevstage |
+ TD0_color_add_add |
+ TD0_color_sel_add);
+ } else
+ if (RGBA_EQUAL(mmesa->envcolor[source])) {
+ /* Cv = C1 + Cc Cs */
+ *reg |= (TD0_color_arg2_prevstage |
+ TD0_color_alpha_fcol |
+ TD0_color_arg2mul_alpha2 |
+ TD0_color_arg1add_mulout |
+ TD0_color_add_add |
+ TD0_color_sel_add);
+
+ mmesa->setup.fcol = mmesa->envcolor[source];
+ } else {
+ return GL_FALSE;
+ }
+
+ if (format != GL_INTENSITY || ALPHA_ZERO(mmesa->envcolor[source])) {
+ /* Av = A1 */
+ *reg |= (TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2);
+ } else
+ if (ALPHA_ONE(mmesa->envcolor[source])) {
+ /* Av = A1 + As */
+ *reg |= (TD0_alpha_arg2_prevstage |
+ TD0_alpha_add_enable |
+ TD0_alpha_sel_add);
+ } else {
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+static void mgaUpdateTextureEnvG400( GLcontext *ctx, GLuint unit )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ const int source = mmesa->tmu_source[unit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
+ const struct gl_texture_object *tObj = texUnit->_Current;
+ GLuint *reg = ((GLuint *)&mmesa->setup.tdualstage0 + unit);
+ mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData;
+ GLenum format = tObj->Image[0][tObj->BaseLevel]->Format;
+
+ if (tObj != ctx->Texture.Unit[source].Current2D &&
+ tObj != ctx->Texture.Unit[source].CurrentRect)
+ return;
+
+ switch (ctx->Texture.Unit[source].EnvMode) {
+ case GL_REPLACE:
+ if (format == GL_ALPHA) {
+ *reg = g400_alpha_combine[unit][MGA_REPLACE];
+ } else if (format == GL_RGB || format == GL_LUMINANCE) {
+ *reg = g400_color_combine[unit][MGA_REPLACE];
+ } else {
+ *reg = g400_color_alpha_combine[unit][MGA_REPLACE];
+ }
+ break;
+
+ case GL_MODULATE:
+ if (format == GL_ALPHA) {
+ *reg = g400_alpha_combine[unit][MGA_MODULATE];
+ } else if (format == GL_RGB || format == GL_LUMINANCE) {
+ *reg = g400_color_combine[unit][MGA_MODULATE];
+ } else {
+ *reg = g400_color_alpha_combine[unit][MGA_MODULATE];
+ }
+ break;
+
+ case GL_DECAL:
+ if (format == GL_RGB) {
+ *reg = g400_color_combine[unit][MGA_DECAL];
+ } else if (format == GL_RGBA) {
+ *reg = g400_color_alpha_combine[unit][MGA_DECAL];
+ if (ctx->Texture._EnabledUnits != 0x03) {
+ /* Linear blending mode needs dual texturing enabled */
+ *(reg+1) = (TD0_color_arg2_prevstage |
+ TD0_color_sel_arg2 |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_sel_arg2);
+ mmesa->force_dualtex = GL_TRUE;
+ }
+ } else {
+ /* Undefined */
+ *reg = g400_alpha_combine[unit][MGA_DECAL];
+ }
+ break;
+
+ case GL_ADD:
+ if (format == GL_ALPHA) {
+ *reg = g400_alpha_combine[unit][MGA_ADD];
+ } else if (format == GL_RGB || format == GL_LUMINANCE) {
+ *reg = g400_color_combine[unit][MGA_ADD];
+ } else if (format == GL_RGBA || format == GL_LUMINANCE_ALPHA) {
+ *reg = g400_color_alpha_combine[unit][MGA_ADD];
+ } else if (format == GL_INTENSITY) {
+ /* Cv = Cf + Cs
+ * Av = Af + As
+ */
+ if (unit == 0) {
+ *reg = (TD0_color_arg2_diffuse |
+ TD0_color_add_add |
+ TD0_color_sel_add |
+ TD0_alpha_arg2_diffuse |
+ TD0_alpha_add_enable |
+ TD0_alpha_sel_add);
+ } else {
+ *reg = (TD0_color_arg2_prevstage |
+ TD0_color_add_add |
+ TD0_color_sel_add |
+ TD0_alpha_arg2_prevstage |
+ TD0_alpha_add_enable |
+ TD0_alpha_sel_add);
+ }
+ }
+ break;
+
+ case GL_BLEND:
+ if (!mgaUpdateTextureEnvBlend(ctx, unit))
+ t->texenv_fallback = GL_TRUE;
+ break;
+
+ case GL_COMBINE:
+ if (!mgaUpdateTextureEnvCombine(ctx, unit))
+ t->texenv_fallback = GL_TRUE;
+ break;
+ default:
+ break;
+ }
+}
+
+static void disable_tex( GLcontext *ctx, int unit )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+
+ /* Texture unit disabled */
+
+ if ( mmesa->CurrentTexObj[unit] != NULL ) {
+ /* The old texture is no longer bound to this texture unit.
+ * Mark it as such.
+ */
+
+ mmesa->CurrentTexObj[unit]->base.bound &= ~(1UL << unit);
+ mmesa->CurrentTexObj[unit] = NULL;
+ }
+
+ if ( unit != 0 && !mmesa->force_dualtex ) {
+ mmesa->setup.tdualstage1 = mmesa->setup.tdualstage0;
+ }
+
+ if ( ctx->Texture._EnabledUnits == 0 ) {
+ mmesa->setup.dwgctl &= DC_opcod_MASK;
+ mmesa->setup.dwgctl |= DC_opcod_trap;
+ mmesa->hw.alpha_sel = AC_alphasel_diffused;
+ }
+
+ mmesa->dirty |= MGA_UPLOAD_CONTEXT | (MGA_UPLOAD_TEX0 << unit);
+}
+
+static GLboolean enable_tex( GLcontext *ctx, int unit )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ const int source = mmesa->tmu_source[unit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
+ const struct gl_texture_object *tObj = texUnit->_Current;
+ mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData;
+
+ /* Upload teximages (not pipelined)
+ */
+ if (t->base.dirty_images[0]) {
+ FLUSH_BATCH( mmesa );
+ mgaSetTexImages( mmesa, tObj );
+ if ( t->base.memBlock == NULL ) {
+ return GL_FALSE;
+ }
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean update_tex_common( GLcontext *ctx, int unit )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ const int source = mmesa->tmu_source[unit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData;
+
+ /* Fallback if there's a texture border */
+ if ( tObj->Image[0][tObj->BaseLevel]->Border > 0 ) {
+ return GL_FALSE;
+ }
+
+
+ /* Update state if this is a different texture object to last
+ * time.
+ */
+ if ( mmesa->CurrentTexObj[unit] != t ) {
+ if ( mmesa->CurrentTexObj[unit] != NULL ) {
+ /* The old texture is no longer bound to this texture unit.
+ * Mark it as such.
+ */
+
+ mmesa->CurrentTexObj[unit]->base.bound &= ~(1UL << unit);
+ }
+
+ mmesa->CurrentTexObj[unit] = t;
+ t->base.bound |= (1UL << unit);
+
+ driUpdateTextureLRU( (driTextureObject *) t ); /* done too often */
+ }
+
+ /* register setup */
+ if ( unit == 1 ) {
+ mmesa->setup.tdualstage1 = mmesa->setup.tdualstage0;
+ }
+
+ t->texenv_fallback = GL_FALSE;
+
+ /* Set this before mgaUpdateTextureEnvG400() since
+ * GL_ARB_texture_env_crossbar may have to disable texturing.
+ */
+ mmesa->setup.dwgctl &= DC_opcod_MASK;
+ mmesa->setup.dwgctl |= DC_opcod_texture_trap;
+
+ /* FIXME: The Radeon has some cached state so that it can avoid calling
+ * FIXME: UpdateTextureEnv in some cases. Is that possible here?
+ */
+ if (MGA_IS_G400(mmesa)) {
+ /* G400: Regardless of texture env mode, we use the alpha from the
+ * texture unit (AC_alphasel_fromtex) since it will have already
+ * been modulated by the incoming fragment color, if needed.
+ * We don't want (AC_alphasel_modulate) since that'll effectively
+ * do the modulation twice.
+ */
+ mmesa->hw.alpha_sel = AC_alphasel_fromtex;
+
+ mgaUpdateTextureEnvG400( ctx, unit );
+ } else {
+ mgaUpdateTextureEnvG200( ctx, unit );
+ }
+
+ t->setup.texctl2 &= TMC_dualtex_MASK;
+ if (ctx->Texture._EnabledUnits == 0x03 || mmesa->force_dualtex) {
+ t->setup.texctl2 |= TMC_dualtex_enable;
+ }
+
+ mmesa->dirty |= MGA_UPLOAD_CONTEXT | (MGA_UPLOAD_TEX0 << unit);
+
+ FALLBACK( ctx, MGA_FALLBACK_BORDER_MODE, t->border_fallback );
+ return !t->border_fallback && !t->texenv_fallback;
+}
+
+
+static GLboolean updateTextureUnit( GLcontext *ctx, int unit )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ const int source = mmesa->tmu_source[unit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
+
+
+ if ( texUnit->_ReallyEnabled == TEXTURE_2D_BIT ||
+ texUnit->_ReallyEnabled == TEXTURE_RECT_BIT ) {
+ return(enable_tex( ctx, unit ) &&
+ update_tex_common( ctx, unit ));
+ }
+ else if ( texUnit->_ReallyEnabled ) {
+ return GL_FALSE;
+ }
+ else {
+ disable_tex( ctx, unit );
+ return GL_TRUE;
+ }
+}
+
+/* The G400 is now programmed quite differently wrt texture environment.
+ */
+void mgaUpdateTextureState( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ GLboolean ok;
+ unsigned i;
+
+ mmesa->force_dualtex = GL_FALSE;
+ mmesa->fcol_used = GL_FALSE;
+
+ /* This works around a quirk with the MGA hardware. If only OpenGL
+ * TEXTURE1 is enabled, then the hardware TEXTURE0 must be used. The
+ * hardware TEXTURE1 can ONLY be used when hardware TEXTURE0 is also used.
+ */
+
+ mmesa->tmu_source[0] = 0;
+ mmesa->tmu_source[1] = 1;
+
+ if ((ctx->Texture._EnabledUnits & 0x03) == 0x02) {
+ /* only texture 1 enabled */
+ mmesa->tmu_source[0] = 1;
+ mmesa->tmu_source[1] = 0;
+ }
+
+ for ( i = 0, ok = GL_TRUE
+ ; (i < ctx->Const.MaxTextureUnits) && ok
+ ; i++ ) {
+ ok = updateTextureUnit( ctx, i );
+ }
+
+ FALLBACK( ctx, MGA_FALLBACK_TEXTURE, !ok );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mga_xmesa.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mga_xmesa.c
new file mode 100644
index 000000000..d1d7799f9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mga_xmesa.c
@@ -0,0 +1,1020 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c,v 1.19 2003/03/26 20:43:49 tsi Exp $ */
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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.
+ */
+
+/**
+ * \file mga_xmesa.c
+ * MGA screen and context initialization / creation code.
+ *
+ * \author Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include <stdlib.h>
+#include <stdint.h>
+#include "drm.h"
+#include "mga_drm.h"
+#include "mga_xmesa.h"
+#include "context.h"
+#include "matrix.h"
+#include "simple_list.h"
+#include "imports.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "array_cache/acache.h"
+
+#include "tnl/t_pipeline.h"
+
+#include "drivers/common/driverfuncs.h"
+
+#include "mgadd.h"
+#include "mgastate.h"
+#include "mgatex.h"
+#include "mgaspan.h"
+#include "mgaioctl.h"
+#include "mgatris.h"
+#include "mgavb.h"
+#include "mgapixel.h"
+#include "mga_xmesa.h"
+#include "mga_dri.h"
+
+#include "utils.h"
+#include "vblank.h"
+
+#include "extensions.h"
+
+#include "GL/internal/dri_interface.h"
+
+#define need_GL_ARB_multisample
+#define need_GL_ARB_texture_compression
+#define need_GL_ARB_vertex_program
+#define need_GL_EXT_fog_coord
+#define need_GL_EXT_multi_draw_arrays
+#define need_GL_EXT_secondary_color
+#if 0
+#define need_GL_EXT_paletted_texture
+#endif
+#define need_GL_NV_vertex_program
+#include "extension_helper.h"
+
+/* MGA configuration
+ */
+#include "xmlpool.h"
+
+PUBLIC const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_QUALITY
+ DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
+ DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_SOFTWARE
+ DRI_CONF_ARB_VERTEX_PROGRAM(true)
+ DRI_CONF_NV_VERTEX_PROGRAM(true)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_NO_RAST(false)
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+static const GLuint __driNConfigOptions = 6;
+
+#ifndef MGA_DEBUG
+int MGA_DEBUG = 0;
+#endif
+
+static int getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo );
+
+static __GLcontextModes *
+mgaFillInModes( unsigned pixel_bits, unsigned depth_bits,
+ unsigned stencil_bits, GLboolean have_back_buffer )
+{
+ __GLcontextModes * modes;
+ __GLcontextModes * m;
+ unsigned num_modes;
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ GLenum fb_format;
+ GLenum fb_type;
+
+ /* GLX_SWAP_COPY_OML is only supported because the MGA driver doesn't
+ * support pageflipping at all.
+ */
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
+ };
+
+ u_int8_t depth_bits_array[3];
+ u_int8_t stencil_bits_array[3];
+
+
+ depth_bits_array[0] = 0;
+ depth_bits_array[1] = depth_bits;
+ depth_bits_array[2] = depth_bits;
+
+ /* Just like with the accumulation buffer, always provide some modes
+ * with a stencil buffer. It will be a sw fallback, but some apps won't
+ * care about that.
+ */
+ stencil_bits_array[0] = 0;
+ stencil_bits_array[1] = 0;
+ stencil_bits_array[2] = (stencil_bits == 0) ? 8 : stencil_bits;
+
+ depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1;
+ back_buffer_factor = (have_back_buffer) ? 2 : 1;
+
+ num_modes = depth_buffer_factor * back_buffer_factor * 4;
+
+ if ( pixel_bits == 16 ) {
+ fb_format = GL_RGB;
+ fb_type = GL_UNSIGNED_SHORT_5_6_5;
+ }
+ else {
+ fb_format = GL_BGR;
+ fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ }
+
+ modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
+ m = modes;
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_TRUE_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_DIRECT_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+
+ /* Mark the visual as slow if there are "fake" stencil bits.
+ */
+ for ( m = modes ; m != NULL ; m = m->next ) {
+ if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) {
+ m->visualRating = GLX_SLOW_CONFIG;
+ }
+ }
+
+ return modes;
+}
+
+
+static GLboolean
+mgaInitDriver(__DRIscreenPrivate *sPriv)
+{
+ mgaScreenPrivate *mgaScreen;
+ MGADRIPtr serverInfo = (MGADRIPtr)sPriv->pDevPriv;
+ PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
+ (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
+ void * const psc = sPriv->psc->screenConfigs;
+
+ if (sPriv->devPrivSize != sizeof(MGADRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(MGADRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
+
+ /* Allocate the private area */
+ mgaScreen = (mgaScreenPrivate *)MALLOC(sizeof(mgaScreenPrivate));
+ if (!mgaScreen) {
+ __driUtilMessage("Couldn't malloc screen struct");
+ return GL_FALSE;
+ }
+
+ mgaScreen->sPriv = sPriv;
+ sPriv->private = (void *)mgaScreen;
+
+ if (sPriv->drmMinor >= 1) {
+ int ret;
+ drm_mga_getparam_t gp;
+
+ gp.param = MGA_PARAM_IRQ_NR;
+ gp.value = &mgaScreen->irq;
+ mgaScreen->irq = 0;
+
+ ret = drmCommandWriteRead( sPriv->fd, DRM_MGA_GETPARAM,
+ &gp, sizeof(gp));
+ if (ret) {
+ fprintf(stderr, "drmMgaGetParam (MGA_PARAM_IRQ_NR): %d\n", ret);
+ FREE(mgaScreen);
+ sPriv->private = NULL;
+ return GL_FALSE;
+ }
+ }
+
+ if ( glx_enable_extension != NULL ) {
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_control" );
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
+ (*glx_enable_extension)( psc, "GLX_SGI_make_current_read" );
+ (*glx_enable_extension)( psc, "GLX_SGI_swap_control" );
+ (*glx_enable_extension)( psc, "GLX_SGI_video_sync" );
+ }
+
+ if (serverInfo->chipset != MGA_CARD_TYPE_G200 &&
+ serverInfo->chipset != MGA_CARD_TYPE_G400) {
+ FREE(mgaScreen);
+ sPriv->private = NULL;
+ __driUtilMessage("Unrecognized chipset");
+ return GL_FALSE;
+ }
+
+
+ mgaScreen->chipset = serverInfo->chipset;
+ mgaScreen->cpp = serverInfo->cpp;
+
+ mgaScreen->agpMode = serverInfo->agpMode;
+
+ mgaScreen->frontPitch = serverInfo->frontPitch;
+ mgaScreen->frontOffset = serverInfo->frontOffset;
+ mgaScreen->backOffset = serverInfo->backOffset;
+ mgaScreen->backPitch = serverInfo->backPitch;
+ mgaScreen->depthOffset = serverInfo->depthOffset;
+ mgaScreen->depthPitch = serverInfo->depthPitch;
+
+
+ /* The only reason that the MMIO region needs to be accessable and the
+ * primary DMA region base address needs to be known is so that the driver
+ * can busy wait for certain DMA operations to complete (see
+ * mgaWaitForFrameCompletion in mgaioctl.c).
+ *
+ * Starting with MGA DRM version 3.2, these are completely unneeded as
+ * there is a new, in-kernel mechanism for handling the wait.
+ */
+
+ if (mgaScreen->sPriv->drmMinor < 2) {
+ mgaScreen->mmio.handle = serverInfo->registers.handle;
+ mgaScreen->mmio.size = serverInfo->registers.size;
+ if ( drmMap( sPriv->fd,
+ mgaScreen->mmio.handle, mgaScreen->mmio.size,
+ &mgaScreen->mmio.map ) < 0 ) {
+ FREE( mgaScreen );
+ sPriv->private = NULL;
+ __driUtilMessage( "Couldn't map MMIO registers" );
+ return GL_FALSE;
+ }
+
+ mgaScreen->primary.handle = serverInfo->primary.handle;
+ mgaScreen->primary.size = serverInfo->primary.size;
+ }
+ else {
+ (void) memset( & mgaScreen->primary, 0, sizeof( mgaScreen->primary ) );
+ (void) memset( & mgaScreen->mmio, 0, sizeof( mgaScreen->mmio ) );
+ }
+
+ mgaScreen->textureOffset[MGA_CARD_HEAP] = serverInfo->textureOffset;
+ mgaScreen->textureOffset[MGA_AGP_HEAP] = (serverInfo->agpTextureOffset |
+ PDEA_pagpxfer_enable | 1);
+
+ mgaScreen->textureSize[MGA_CARD_HEAP] = serverInfo->textureSize;
+ mgaScreen->textureSize[MGA_AGP_HEAP] = serverInfo->agpTextureSize;
+
+
+ /* The texVirtual array stores the base addresses in the CPU's address
+ * space of the texture memory pools. The base address of the on-card
+ * memory pool is calculated as an offset of the base of video memory. The
+ * AGP texture pool has to be mapped into the processes address space by
+ * the DRM.
+ */
+
+ mgaScreen->texVirtual[MGA_CARD_HEAP] = (char *)(mgaScreen->sPriv->pFB +
+ serverInfo->textureOffset);
+
+ if ( serverInfo->agpTextureSize > 0 ) {
+ if (drmMap(sPriv->fd, serverInfo->agpTextureOffset,
+ serverInfo->agpTextureSize,
+ (drmAddress *)&mgaScreen->texVirtual[MGA_AGP_HEAP]) != 0) {
+ FREE(mgaScreen);
+ sPriv->private = NULL;
+ __driUtilMessage("Couldn't map agptexture region");
+ return GL_FALSE;
+ }
+ }
+
+
+ /* For calculating setupdma addresses.
+ */
+
+ mgaScreen->bufs = drmMapBufs(sPriv->fd);
+ if (!mgaScreen->bufs) {
+ FREE(mgaScreen);
+ sPriv->private = NULL;
+ __driUtilMessage("Couldn't map dma buffers");
+ return GL_FALSE;
+ }
+ mgaScreen->sarea_priv_offset = serverInfo->sarea_priv_offset;
+
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo (&mgaScreen->optionCache,
+ __driConfigOptions, __driNConfigOptions);
+
+ return GL_TRUE;
+}
+
+
+static void
+mgaDestroyScreen(__DRIscreenPrivate *sPriv)
+{
+ mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *) sPriv->private;
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
+ fprintf(stderr, "mgaDestroyScreen\n");
+
+ drmUnmapBufs(mgaScreen->bufs);
+
+
+ /* free all option information */
+ driDestroyOptionInfo (&mgaScreen->optionCache);
+
+ FREE(mgaScreen);
+ sPriv->private = NULL;
+}
+
+
+extern const struct tnl_pipeline_stage _mga_render_stage;
+
+static const struct tnl_pipeline_stage *mga_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ &_tnl_arb_vertex_program_stage,
+ &_tnl_vertex_program_stage,
+
+ /* REMOVE: point attenuation stage */
+#if 0
+ &_mga_render_stage, /* ADD: unclipped rastersetup-to-dma */
+ /* Need new ioctl for wacceptseq */
+#endif
+ &_tnl_render_stage,
+ 0,
+};
+
+
+static const struct dri_extension g400_extensions[] =
+{
+ { "GL_ARB_multitexture", NULL },
+ { "GL_ARB_texture_env_add", NULL },
+ { "GL_ARB_texture_env_combine", NULL },
+ { "GL_ARB_texture_env_crossbar", NULL },
+ { "GL_EXT_texture_env_combine", NULL },
+ { "GL_EXT_texture_edge_clamp", NULL },
+ { "GL_ATI_texture_env_combine3", NULL },
+ { NULL, NULL }
+};
+
+static const struct dri_extension card_extensions[] =
+{
+ { "GL_ARB_multisample", GL_ARB_multisample_functions },
+ { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions },
+ { "GL_ARB_texture_rectangle", NULL },
+ { "GL_EXT_blend_logic_op", NULL },
+ { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions },
+ { "GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions },
+ /* paletted_textures currently doesn't work, but we could fix them later */
+#if defined( need_GL_EXT_paletted_texture )
+ { "GL_EXT_shared_texture_palette", NULL },
+ { "GL_EXT_paletted_texture", GL_EXT_paletted_texture_functions },
+#endif
+ { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions },
+ { "GL_EXT_stencil_wrap", NULL },
+ { "GL_MESA_ycbcr_texture", NULL },
+ { "GL_SGIS_generate_mipmap", NULL },
+ { NULL, NULL }
+};
+
+static const struct dri_extension ARB_vp_extension[] = {
+ { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions },
+ { NULL, NULL }
+};
+
+static const struct dri_extension NV_vp_extensions[] = {
+ { "GL_NV_vertex_program", GL_NV_vertex_program_functions },
+ { "GL_NV_vertex_program1_1", NULL },
+ { NULL, NULL }
+};
+
+static const struct dri_debug_control debug_control[] =
+{
+ { "fall", DEBUG_VERBOSE_FALLBACK },
+ { "tex", DEBUG_VERBOSE_TEXTURE },
+ { "ioctl", DEBUG_VERBOSE_IOCTL },
+ { "verb", DEBUG_VERBOSE_MSG },
+ { "dri", DEBUG_VERBOSE_DRI },
+ { NULL, 0 }
+};
+
+
+static GLboolean
+mgaCreateContext( const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate )
+{
+ int i;
+ unsigned maxlevels;
+ GLcontext *ctx, *shareCtx;
+ mgaContextPtr mmesa;
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *)sPriv->private;
+ drm_mga_sarea_t *saPriv = (drm_mga_sarea_t *)(((char*)sPriv->pSAREA)+
+ mgaScreen->sarea_priv_offset);
+ struct dd_function_table functions;
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
+ fprintf(stderr, "mgaCreateContext\n");
+
+ /* allocate mga context */
+ mmesa = (mgaContextPtr) CALLOC(sizeof(mgaContext));
+ if (!mmesa) {
+ return GL_FALSE;
+ }
+
+ /* Init default driver functions then plug in our Radeon-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions( &functions );
+ mgaInitDriverFuncs( &functions );
+ mgaInitTextureFuncs( &functions );
+ mgaInitIoctlFuncs( &functions );
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((mgaContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ mmesa->glCtx = _mesa_create_context(mesaVis, shareCtx,
+ &functions, (void *) mmesa);
+ if (!mmesa->glCtx) {
+ FREE(mmesa);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = mmesa;
+
+ /* Init mga state */
+ mmesa->hHWContext = driContextPriv->hHWContext;
+ mmesa->driFd = sPriv->fd;
+ mmesa->driHwLock = &sPriv->pSAREA->lock;
+
+ mmesa->mgaScreen = mgaScreen;
+ mmesa->driScreen = sPriv;
+ mmesa->sarea = (void *)saPriv;
+
+ /* Parse configuration files */
+ driParseConfigFiles (&mmesa->optionCache, &mgaScreen->optionCache,
+ sPriv->myNum, "mga");
+
+ (void) memset( mmesa->texture_heaps, 0, sizeof( mmesa->texture_heaps ) );
+ make_empty_list( & mmesa->swapped );
+
+ mmesa->nr_heaps = mgaScreen->texVirtual[MGA_AGP_HEAP] ? 2 : 1;
+ for ( i = 0 ; i < mmesa->nr_heaps ; i++ ) {
+ mmesa->texture_heaps[i] = driCreateTextureHeap( i, mmesa,
+ mgaScreen->textureSize[i],
+ 6,
+ MGA_NR_TEX_REGIONS,
+ (drmTextureRegionPtr)mmesa->sarea->texList[i],
+ &mmesa->sarea->texAge[i],
+ &mmesa->swapped,
+ sizeof( mgaTextureObject_t ),
+ (destroy_texture_object_t *) mgaDestroyTexObj );
+ }
+
+ /* Set the maximum texture size small enough that we can guarentee
+ * that both texture units can bind a maximal texture and have them
+ * on the card at once.
+ */
+ ctx = mmesa->glCtx;
+ if ( mgaScreen->chipset == MGA_CARD_TYPE_G200 ) {
+ ctx->Const.MaxTextureUnits = 1;
+ ctx->Const.MaxTextureImageUnits = 1;
+ ctx->Const.MaxTextureCoordUnits = 1;
+ maxlevels = G200_TEX_MAXLEVELS;
+
+ }
+ else {
+ ctx->Const.MaxTextureUnits = 2;
+ ctx->Const.MaxTextureImageUnits = 2;
+ ctx->Const.MaxTextureCoordUnits = 2;
+ maxlevels = G400_TEX_MAXLEVELS;
+ }
+
+ driCalculateMaxTextureLevels( mmesa->texture_heaps,
+ mmesa->nr_heaps,
+ & ctx->Const,
+ 4,
+ 11, /* max 2D texture size is 2048x2048 */
+ 0, /* 3D textures unsupported. */
+ 0, /* cube textures unsupported. */
+ 11, /* max texture rect size is 2048x2048 */
+ maxlevels,
+ GL_FALSE );
+
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 10.0;
+ ctx->Const.MaxLineWidthAA = 10.0;
+ ctx->Const.LineWidthGranularity = 1.0;
+
+ mmesa->texture_depth = driQueryOptioni (&mmesa->optionCache,
+ "texture_depth");
+ if (mmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
+ mmesa->texture_depth = ( mesaVis->rgbBits >= 24 ) ?
+ DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
+ mmesa->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;
+
+ switch (mesaVis->depthBits) {
+ case 16:
+ mmesa->depth_scale = 1.0/(GLdouble)0xffff;
+ mmesa->depth_clear_mask = ~0;
+ mmesa->ClearDepth = 0xffff;
+ break;
+ case 24:
+ mmesa->depth_scale = 1.0/(GLdouble)0xffffff;
+ if (mmesa->hw_stencil) {
+ mmesa->depth_clear_mask = 0xffffff00;
+ mmesa->stencil_clear_mask = 0x000000ff;
+ } else
+ mmesa->depth_clear_mask = ~0;
+ mmesa->ClearDepth = 0xffffff00;
+ break;
+ case 32:
+ mmesa->depth_scale = 1.0/(GLdouble)0xffffffff;
+ mmesa->depth_clear_mask = ~0;
+ mmesa->ClearDepth = 0xffffffff;
+ break;
+ };
+
+ mmesa->haveHwStipple = GL_FALSE;
+ mmesa->RenderIndex = -1; /* impossible value */
+ mmesa->dirty = ~0;
+ mmesa->vertex_format = 0;
+ mmesa->CurrentTexObj[0] = 0;
+ mmesa->CurrentTexObj[1] = 0;
+ mmesa->tmu_source[0] = 0;
+ mmesa->tmu_source[1] = 1;
+
+ mmesa->texAge[0] = 0;
+ mmesa->texAge[1] = 0;
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+
+ _swsetup_CreateContext( ctx );
+
+ /* Install the customized pipeline:
+ */
+ _tnl_destroy_pipeline( ctx );
+ _tnl_install_pipeline( ctx, mga_pipeline );
+
+ /* Configure swrast and T&L to match hardware characteristics:
+ */
+ _swrast_allow_pixel_fog( ctx, GL_FALSE );
+ _swrast_allow_vertex_fog( ctx, GL_TRUE );
+ _tnl_allow_pixel_fog( ctx, GL_FALSE );
+ _tnl_allow_vertex_fog( ctx, GL_TRUE );
+
+ mmesa->primary_offset = mmesa->mgaScreen->primary.handle;
+
+ ctx->DriverCtx = (void *) mmesa;
+ mmesa->glCtx = ctx;
+
+ driInitExtensions( ctx, card_extensions, GL_FALSE );
+
+ if (MGA_IS_G400(MGA_CONTEXT(ctx))) {
+ driInitExtensions( ctx, g400_extensions, GL_FALSE );
+ }
+
+ if ( driQueryOptionb( &mmesa->optionCache, "arb_vertex_program" ) ) {
+ driInitSingleExtension( ctx, ARB_vp_extension );
+ }
+
+ if ( driQueryOptionb( &mmesa->optionCache, "nv_vertex_program" ) ) {
+ driInitExtensions( ctx, NV_vp_extensions, GL_FALSE );
+ }
+
+
+ /* XXX these should really go right after _mesa_init_driver_functions() */
+ mgaDDInitStateFuncs( ctx );
+ mgaDDInitSpanFuncs( ctx );
+ mgaDDInitPixelFuncs( ctx );
+ mgaDDInitTriFuncs( ctx );
+
+ mgaInitVB( ctx );
+ mgaInitState( mmesa );
+
+ driContextPriv->driverPrivate = (void *) mmesa;
+
+#if DO_DEBUG
+ MGA_DEBUG = driParseDebugString( getenv( "MGA_DEBUG" ),
+ debug_control );
+#endif
+
+ mmesa->vblank_flags = (mmesa->mgaScreen->irq == 0)
+ ? VBLANK_FLAG_NO_IRQ : driGetDefaultVBlankFlags(&mmesa->optionCache);
+
+ (*dri_interface->getUST)( & mmesa->swap_ust );
+
+ if (driQueryOptionb(&mmesa->optionCache, "no_rast")) {
+ fprintf(stderr, "disabling 3D acceleration\n");
+ FALLBACK(mmesa->glCtx, MGA_FALLBACK_DISABLE, 1);
+ }
+
+ return GL_TRUE;
+}
+
+static void
+mgaDestroyContext(__DRIcontextPrivate *driContextPriv)
+{
+ mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate;
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
+ fprintf( stderr, "[%s:%d] mgaDestroyContext start\n",
+ __FILE__, __LINE__ );
+
+ assert(mmesa); /* should never be null */
+ if (mmesa) {
+ GLboolean release_texture_heaps;
+
+
+ release_texture_heaps = (mmesa->glCtx->Shared->RefCount == 1);
+ _swsetup_DestroyContext( mmesa->glCtx );
+ _tnl_DestroyContext( mmesa->glCtx );
+ _ac_DestroyContext( mmesa->glCtx );
+ _swrast_DestroyContext( mmesa->glCtx );
+
+ mgaFreeVB( mmesa->glCtx );
+
+ /* free the Mesa context */
+ mmesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(mmesa->glCtx);
+
+ if ( release_texture_heaps ) {
+ /* This share group is about to go away, free our private
+ * texture object data.
+ */
+ int i;
+
+ for ( i = 0 ; i < mmesa->nr_heaps ; i++ ) {
+ driDestroyTextureHeap( mmesa->texture_heaps[ i ] );
+ mmesa->texture_heaps[ i ] = NULL;
+ }
+
+ assert( is_empty_list( & mmesa->swapped ) );
+ }
+
+ /* free the option cache */
+ driDestroyOptionCache (&mmesa->optionCache);
+
+ FREE(mmesa);
+ }
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_DRI)
+ fprintf( stderr, "[%s:%d] mgaDestroyContext done\n",
+ __FILE__, __LINE__ );
+}
+
+
+static GLboolean
+mgaCreateBuffer( __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ mgaScreenPrivate *screen = (mgaScreenPrivate *) driScrnPriv->private;
+
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+ GLboolean swStencil = (mesaVis->stencilBits > 0 &&
+ mesaVis->depthBits != 24);
+
+#if 0
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ mesaVis->alphaBits > 0 );
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->frontPitch);
+ mgaSetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ mgaSetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ mgaSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ /* XXX is this right? */
+ if (mesaVis->stencilBits) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ mgaSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT32, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ mgaSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ }
+ else if (mesaVis->depthBits == 32) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT32, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ mgaSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ mgaSetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+
+static void
+mgaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+static void
+mgaSwapBuffers(__DRIdrawablePrivate *dPriv)
+{
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ mgaContextPtr mmesa;
+ GLcontext *ctx;
+ mmesa = (mgaContextPtr) dPriv->driContextPriv->driverPrivate;
+ ctx = mmesa->glCtx;
+
+ if (ctx->Visual.doubleBufferMode) {
+ _mesa_notifySwapBuffers( ctx );
+ mgaCopyBuffer( dPriv );
+ }
+ } else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ _mesa_problem(NULL, "%s: drawable has no context!\n", __FUNCTION__);
+ }
+}
+
+static GLboolean
+mgaUnbindContext(__DRIcontextPrivate *driContextPriv)
+{
+ mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate;
+ if (mmesa)
+ mmesa->dirty = ~0;
+
+ return GL_TRUE;
+}
+
+/* This looks buggy to me - the 'b' variable isn't used anywhere...
+ * Hmm - It seems that the drawable is already hooked in to
+ * driDrawablePriv.
+ *
+ * But why are we doing context initialization here???
+ */
+static GLboolean
+mgaMakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
+{
+ if (driContextPriv) {
+ mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate;
+
+ if (mmesa->driDrawable != driDrawPriv) {
+ driDrawableInitVBlank( driDrawPriv, mmesa->vblank_flags );
+ mmesa->driDrawable = driDrawPriv;
+ mmesa->dirty = ~0;
+ mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK);
+ mmesa->mesa_drawable = driDrawPriv;
+ }
+
+ mmesa->driReadable = driReadPriv;
+
+ _mesa_make_current(mmesa->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate);
+ }
+ else {
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ return GL_TRUE;
+}
+
+
+void mgaGetLock( mgaContextPtr mmesa, GLuint flags )
+{
+ __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
+ drm_mga_sarea_t *sarea = mmesa->sarea;
+ int me = mmesa->hHWContext;
+ int i;
+
+ drmGetLock(mmesa->driFd, mmesa->hHWContext, flags);
+
+ if (*(dPriv->pStamp) != mmesa->lastStamp) {
+ mmesa->lastStamp = *(dPriv->pStamp);
+ mmesa->SetupNewInputs |= VERT_BIT_POS;
+ mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK);
+ mgaUpdateRects( mmesa, (MGA_FRONT|MGA_BACK) );
+ }
+
+ mmesa->dirty |= MGA_UPLOAD_CONTEXT | MGA_UPLOAD_CLIPRECTS;
+
+ mmesa->sarea->dirty |= MGA_UPLOAD_CONTEXT;
+
+ if (sarea->ctxOwner != me) {
+ mmesa->dirty |= (MGA_UPLOAD_CONTEXT | MGA_UPLOAD_TEX0 |
+ MGA_UPLOAD_TEX1 | MGA_UPLOAD_PIPE);
+ sarea->ctxOwner=me;
+ }
+
+ for ( i = 0 ; i < mmesa->nr_heaps ; i++ ) {
+ DRI_AGE_TEXTURES( mmesa->texture_heaps[ i ] );
+ }
+}
+
+
+static const struct __DriverAPIRec mgaAPI = {
+ .InitDriver = mgaInitDriver,
+ .DestroyScreen = mgaDestroyScreen,
+ .CreateContext = mgaCreateContext,
+ .DestroyContext = mgaDestroyContext,
+ .CreateBuffer = mgaCreateBuffer,
+ .DestroyBuffer = mgaDestroyBuffer,
+ .SwapBuffers = mgaSwapBuffers,
+ .MakeCurrent = mgaMakeCurrent,
+ .UnbindContext = mgaUnbindContext,
+ .GetSwapInfo = getSwapInfo,
+ .GetMSC = driGetMSC32,
+ .WaitForMSC = driWaitForMSC32,
+ .WaitForSBC = NULL,
+ .SwapBuffersMSC = NULL
+};
+
+
+/**
+ * This is the bootstrap function for the driver. libGL supplies all of the
+ * requisite information about the system, and the driver initializes itself.
+ * This routine also fills in the linked list pointed to by \c driver_modes
+ * with the \c __GLcontextModes that the driver can support for windows or
+ * pbuffers.
+ *
+ * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
+ * failure.
+ */
+PUBLIC
+void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
+ const __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drmAddress pSAREA, int fd,
+ int internal_api_version,
+ const __DRIinterfaceMethods * interface,
+ __GLcontextModes ** driver_modes )
+
+{
+ __DRIscreenPrivate *psp;
+ static const __DRIversion ddx_expected = { 1, 2, 0 };
+ static const __DRIversion dri_expected = { 4, 0, 0 };
+ static const __DRIversion drm_expected = { 3, 0, 0 };
+
+ dri_interface = interface;
+
+ if ( ! driCheckDriDdxDrmVersions2( "MGA",
+ dri_version, & dri_expected,
+ ddx_version, & ddx_expected,
+ drm_version, & drm_expected ) ) {
+ return NULL;
+ }
+
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &mgaAPI);
+ if ( psp != NULL ) {
+ MGADRIPtr dri_priv = (MGADRIPtr) psp->pDevPriv;
+ *driver_modes = mgaFillInModes( dri_priv->cpp * 8,
+ (dri_priv->cpp == 2) ? 16 : 24,
+ (dri_priv->cpp == 2) ? 0 : 8,
+ (dri_priv->backOffset != dri_priv->depthOffset) );
+
+ /* Calling driInitExtensions here, with a NULL context pointer, does not actually
+ * enable the extensions. It just makes sure that all the dispatch offsets for all
+ * the extensions that *might* be enables are known. This is needed because the
+ * dispatch offsets need to be known when _mesa_context_create is called, but we can't
+ * enable the extensions until we have a context pointer.
+ *
+ * Hello chicken. Hello egg. How are you two today?
+ */
+ driInitExtensions( NULL, card_extensions, GL_FALSE );
+ driInitExtensions( NULL, g400_extensions, GL_FALSE );
+ driInitSingleExtension( NULL, ARB_vp_extension );
+ driInitExtensions( NULL, NV_vp_extensions, GL_FALSE );
+
+ }
+
+ return (void *) psp;
+}
+
+
+/**
+ * Get information about previous buffer swaps.
+ */
+static int
+getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
+{
+ mgaContextPtr mmesa;
+
+ if ( (dPriv == NULL) || (dPriv->driContextPriv == NULL)
+ || (dPriv->driContextPriv->driverPrivate == NULL)
+ || (sInfo == NULL) ) {
+ return -1;
+ }
+
+ mmesa = (mgaContextPtr) dPriv->driContextPriv->driverPrivate;
+ sInfo->swap_count = mmesa->swap_count;
+ sInfo->swap_ust = mmesa->swap_ust;
+ sInfo->swap_missed_count = mmesa->swap_missed_count;
+
+ sInfo->swap_missed_usage = (sInfo->swap_missed_count != 0)
+ ? driCalculateSwapUsage( dPriv, 0, mmesa->swap_missed_ust )
+ : 0.0;
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mga_xmesa.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mga_xmesa.h
new file mode 100644
index 000000000..0ab0c63f7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mga_xmesa.h
@@ -0,0 +1,155 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mga_xmesa.h,v 1.12 2002/12/16 16:18:52 dawes Exp $ */
+
+#ifndef _MGA_INIT_H_
+#define _MGA_INIT_H_
+
+#include <sys/time.h>
+#include "dri_util.h"
+#include "mga_drm.h"
+#include "mtypes.h"
+#include "mgaregs.h"
+#include "xmlconfig.h"
+
+typedef struct mga_screen_private_s {
+ /**
+ * Chipset "family" of this card. Currently only \c MGA_CARD_TYPE_G200 and
+ * \c MGA_CARD_TYPE_G400 are possible.
+ */
+ int chipset;
+
+
+ /**
+ * Characters (bytes) per-pixel for both the front and back buffers.
+ *
+ * \note
+ * This is also implicitly the bytes per-pixel for the depth-buffer.
+ */
+ int cpp;
+
+ GLint agpMode;
+ unsigned int irq; /**< IRQ number (0 means none) */
+
+ unsigned int frontOffset;
+ unsigned int frontPitch;
+ unsigned int backOffset;
+ unsigned int backPitch;
+
+ unsigned int depthOffset;
+ unsigned int depthPitch;
+
+ unsigned int textureOffset[MGA_NR_TEX_HEAPS];
+ unsigned int textureSize[MGA_NR_TEX_HEAPS];
+ char *texVirtual[MGA_NR_TEX_HEAPS];
+
+
+ __DRIscreenPrivate *sPriv;
+ drmBufMapPtr bufs;
+
+ drmRegion mmio;
+ drmRegion primary;
+ unsigned int sarea_priv_offset;
+
+ /** Configuration cache with default values for all contexts */
+ driOptionCache optionCache;
+} mgaScreenPrivate;
+
+
+/**
+ * mgaRenderbuffer, derived from Mesa's gl_renderbuffer
+ */
+typedef struct {
+ struct gl_renderbuffer Base;
+ /* XXX per-window info should go here */
+ int foo, bar;
+} mgaRenderbuffer;
+
+
+
+#include "mgacontext.h"
+
+extern void mgaGetLock( mgaContextPtr mmesa, GLuint flags );
+extern void mgaEmitHwStateLocked( mgaContextPtr mmesa );
+extern void mgaEmitScissorValues( mgaContextPtr mmesa, int box_nr, int emit );
+
+#define GET_DISPATCH_AGE( mmesa ) mmesa->sarea->last_dispatch
+
+
+
+/* Lock the hardware and validate our state.
+ */
+#define LOCK_HARDWARE( mmesa ) \
+ do { \
+ char __ret=0; \
+ DRM_CAS(mmesa->driHwLock, mmesa->hHWContext, \
+ (DRM_LOCK_HELD|mmesa->hHWContext), __ret); \
+ if (__ret) \
+ mgaGetLock( mmesa, 0 ); \
+ } while (0)
+
+
+/*
+ */
+#define LOCK_HARDWARE_QUIESCENT( mmesa ) do { \
+ LOCK_HARDWARE( mmesa ); \
+ UPDATE_LOCK( mmesa, DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH ); \
+} while (0)
+
+
+/* Unlock the hardware using the global current context
+ */
+#define UNLOCK_HARDWARE(mmesa) \
+ DRM_UNLOCK(mmesa->driFd, mmesa->driHwLock, mmesa->hHWContext);
+
+
+/* Freshen our snapshot of the drawables
+ */
+#define REFRESH_DRAWABLE_INFO( mmesa ) \
+do { \
+ LOCK_HARDWARE( mmesa ); \
+ mmesa->lastX = mmesa->drawX; \
+ mmesa->lastY = mmesa->drawY; \
+ UNLOCK_HARDWARE( mmesa ); \
+} while (0)
+
+
+#define GET_DRAWABLE_LOCK( mmesa ) while(0)
+#define RELEASE_DRAWABLE_LOCK( mmesa ) while(0)
+
+
+/* The 2D driver macros are busted -- we can't use them here as they
+ * rely on the 2D driver data structures rather than taking an explicit
+ * base address.
+ */
+#define MGA_BASE( reg ) ((unsigned long)(mmesa->mgaScreen->mmio.map))
+#define MGA_ADDR( reg ) (MGA_BASE(reg) + reg)
+
+#define MGA_DEREF( reg ) *(volatile u_int32_t *)MGA_ADDR( reg )
+#define MGA_READ( reg ) MGA_DEREF( reg )
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgacontext.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgacontext.h
new file mode 100644
index 000000000..81348b6c7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgacontext.h
@@ -0,0 +1,372 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgacontext.h,v 1.7 2002/12/16 16:18:52 dawes Exp $*/
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef MGALIB_INC
+#define MGALIB_INC
+
+#include <stdint.h>
+#include "drm.h"
+#include "mga_drm.h"
+#include "dri_util.h"
+#include "mtypes.h"
+#include "xf86drm.h"
+#include "mm.h"
+#include "colormac.h"
+#include "texmem.h"
+#include "macros.h"
+#include "xmlconfig.h"
+
+#define MGA_SET_FIELD(reg,mask,val) reg = ((reg) & (mask)) | ((val) & ~(mask))
+#define MGA_FIELD(field,val) (((val) << (field ## _SHIFT)) & ~(field ## _MASK))
+#define MGA_GET_FIELD(field, val) ((val & ~(field ## _MASK)) >> (field ## _SHIFT))
+
+#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
+ * - texture env GL_BLEND -- can be fixed
+ * - 1D and 3D textures
+ * - incomplete textures
+ * - GL_DEPTH_FUNC == GL_NEVER not in h/w
+ */
+#define MGA_FALLBACK_TEXTURE 0x1
+#define MGA_FALLBACK_DRAW_BUFFER 0x2
+#define MGA_FALLBACK_READ_BUFFER 0x4
+#define MGA_FALLBACK_BLEND 0x8
+#define MGA_FALLBACK_RENDERMODE 0x10
+#define MGA_FALLBACK_STENCIL 0x20
+#define MGA_FALLBACK_DEPTH 0x40
+#define MGA_FALLBACK_BORDER_MODE 0x80
+#define MGA_FALLBACK_DISABLE 0x100
+
+
+/* Use the templated vertex formats:
+ */
+#define TAG(x) mga##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+typedef struct mga_context_t mgaContext;
+typedef struct mga_context_t *mgaContextPtr;
+
+typedef void (*mga_tri_func)( mgaContextPtr, mgaVertex *, mgaVertex *,
+ mgaVertex * );
+typedef void (*mga_line_func)( mgaContextPtr, mgaVertex *, mgaVertex * );
+typedef void (*mga_point_func)( mgaContextPtr, mgaVertex * );
+
+
+
+/* Texture environment color
+ */
+#define RGB_ZERO(c) (((c) & 0xffffff) == 0x000000)
+#define RGB_ONE(c) (((c) & 0xffffff) == 0xffffff)
+#define ALPHA_ZERO(c) (((c) >> 24) == 0x00)
+#define ALPHA_ONE(c) (((c) >> 24) == 0xff)
+#define RGBA_EQUAL(c) ((c) == PACK_COLOR_8888( (c) & 0xff, (c) & 0xff, \
+ (c) & 0xff, (c) & 0xff ))
+
+struct mga_texture_object_s;
+struct mga_screen_private_s;
+
+#define G200_TEX_MAXLEVELS 5
+#define G400_TEX_MAXLEVELS 11
+
+typedef struct mga_texture_object_s
+{
+ driTextureObject base;
+
+ /* The G200 only has the ability to use 5 mipmap levels (including the
+ * base level). The G400 does not have this restriction, but it still
+ * only has 5 offset pointers in the hardware. The trick on the G400 is
+ * upto the first 4 offset pointers point to mipmap levels. The last
+ * offset pointer tells how large the preceeding mipmap is. This value is
+ * then used to determine where the remaining mipmaps are.
+ *
+ * For example, if the first offsets[0] through offsets[2] are used as
+ * pointers, then offset[3] will be the size of the mipmap pointed to by
+ * offsets[2]. So mipmap level 3 will be at (offsets[2]+offsets[3]). For
+ * each successive mipmap level, offsets[3] is divided by 4 and added to
+ * the previous address. So mipmap level 4 will be at
+ * (offsets[2]+offsets[3]+(offsets[3] / 4)).
+ *
+ * The last pointer is selected by setting TO_texorgoffsetsel in its
+ * pointer. In the previous example, offset[2] would have
+ * TO_texorgoffsetsel or'ed in before writing it to the hardware.
+ *
+ * In the current driver all of the mipmaps are packed together linearly
+ * with mipmap level 0. Therefore offsets[0] points to the base of the
+ * texture (and has TO_texorgoffsetsel or'ed in), and offsets[1] is the
+ * size of the base texture.
+ *
+ * There is a possible optimization available here. At times the driver
+ * may not be able to allocate a single block of memory for the complete
+ * texture without ejecting some other textures from memory. It may be
+ * possible to put some of the lower mipmap levels (i.e., the larger
+ * mipmaps) in memory separate from the higher levels.
+ *
+ * The implementation should be fairly obvious, but getting "right" would
+ * likely be non-trivial. A first allocation for the entire texture would
+ * be attempted with a flag that says "don't eject other textures." If
+ * that failed, an additional allocation would be attmpted for just the
+ * base map. The process would repeat with the block of lower maps. The
+ * tricky parts would be in detecting when some of the levels had been
+ * ejected from texture memory by other textures and preventing the
+ * 4th allocation (for all the smallest mipmap levels) from kicking out
+ * any of the first three.
+ *
+ * This array holds G400_TEX_MAXLEVELS pointers to remove an if-statement
+ * in a loop in mgaSetTexImages. Values past G200_TEX_MAXLEVELS are not
+ * used.
+ */
+ GLuint offsets[G400_TEX_MAXLEVELS];
+
+ int texelBytes;
+ GLuint age;
+
+ drm_mga_texture_regs_t setup;
+
+ /* If one texture dimension wraps with GL_CLAMP and the other with
+ * GL_CLAMP_TO_EDGE, we have to fallback to software. We would also have
+ * to fallback for GL_CLAMP_TO_BORDER.
+ */
+ GLboolean border_fallback;
+ /* Depending on multitxturing and environment color
+ * GL_BLEND may have to be a software fallback.
+ */
+ GLboolean texenv_fallback;
+} mgaTextureObject_t;
+
+struct mga_hw_state {
+ GLuint specen;
+ GLuint cull;
+ GLuint cull_dualtex;
+ GLuint stencil;
+ GLuint stencilctl;
+ GLuint stencil_enable;
+ GLuint zmode;
+ GLuint rop;
+ GLuint alpha_func;
+ GLuint alpha_func_enable;
+ GLuint blend_func;
+ GLuint blend_func_enable;
+ GLuint alpha_sel;
+};
+
+struct mga_context_t {
+
+ GLcontext *glCtx;
+ unsigned int lastStamp; /* fullscreen breaks dpriv->laststamp,
+ * need to shadow it here. */
+
+ /* Hardware state management
+ */
+ struct mga_hw_state hw;
+
+ /* Bookkeeping for texturing
+ */
+ unsigned nr_heaps;
+ driTexHeap * texture_heaps[ MGA_NR_TEX_HEAPS ];
+ driTextureObject swapped;
+
+ struct mga_texture_object_s *CurrentTexObj[2];
+
+
+ /* Map GL texture units onto hardware.
+ */
+ GLuint tmu_source[2];
+
+ int texture_depth;
+
+ /* Manage fallbacks
+ */
+ GLuint Fallback;
+
+ /* Texture environment color.
+ */
+ unsigned int envcolor[2];
+ GLboolean fcol_used;
+ GLboolean force_dualtex;
+
+ /* Rasterization state
+ */
+ GLuint SetupNewInputs;
+ GLuint SetupIndex;
+ GLuint RenderIndex;
+
+ GLuint hw_primitive;
+ GLenum raster_primitive;
+ GLenum render_primitive;
+
+ GLubyte *verts;
+ GLint vertex_stride_shift;
+ GLuint vertex_format;
+ GLuint vertex_size;
+
+ /* Fallback rasterization functions
+ */
+ mga_point_func draw_point;
+ mga_line_func draw_line;
+ mga_tri_func draw_tri;
+
+
+ /* Manage driver and hardware state
+ */
+ GLuint NewGLState;
+ GLuint dirty;
+
+ drm_mga_context_regs_t setup;
+
+ GLuint ClearColor;
+ GLuint ClearDepth;
+ GLuint poly_stipple;
+ GLfloat depth_scale;
+
+ GLuint depth_clear_mask;
+ GLuint stencil_clear_mask;
+ GLuint hw_stencil;
+ GLuint haveHwStipple;
+ GLfloat hw_viewport[16];
+
+ /* Dma buffers
+ */
+ drmBufPtr vertex_dma_buffer;
+ drmBufPtr iload_buffer;
+
+ /* VBI
+ */
+ GLuint vbl_seq;
+ GLuint vblank_flags;
+
+ int64_t swap_ust;
+ int64_t swap_missed_ust;
+
+ GLuint swap_count;
+ GLuint swap_missed_count;
+
+ uint32_t last_frame_fence;
+
+ /* 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 readOffset;
+ int drawX, drawY; /* origin of drawable in draw buffer */
+ int lastX, lastY; /* detect DSTORG bug */
+ GLuint numClipRects; /* cliprects for the draw buffer */
+ drm_clip_rect_t *pClipRects;
+ drm_clip_rect_t draw_rect;
+ drm_clip_rect_t scissor_rect;
+ int scissor;
+
+ drm_clip_rect_t tmp_boxes[2][MGA_NR_SAREA_CLIPRECTS];
+
+
+ /* Texture aging and DMA based aging.
+ */
+ unsigned int texAge[MGA_NR_TEX_HEAPS];/* texture LRU age */
+ unsigned int dirtyAge; /* buffer age for synchronization */
+
+ GLuint primary_offset;
+
+ /* Mirrors of some DRI state.
+ */
+ drm_context_t hHWContext;
+ drm_hw_lock_t *driHwLock;
+ int driFd;
+ __DRIdrawablePrivate *driDrawable;
+ __DRIdrawablePrivate *driReadable;
+
+ /**
+ * Drawable used by Mesa for software fallbacks for reading and
+ * writing. It is set by Mesa's \c SetBuffer callback, and will always be
+ * either \c mga_context_t::driDrawable or \c mga_context_t::driReadable.
+ */
+ __DRIdrawablePrivate *mesa_drawable;
+
+ __DRIscreenPrivate *driScreen;
+ struct mga_screen_private_s *mgaScreen;
+ drm_mga_sarea_t *sarea;
+
+ /* Configuration cache
+ */
+ driOptionCache optionCache;
+};
+
+#define MGA_CONTEXT(ctx) ((mgaContextPtr)(ctx->DriverCtx))
+
+
+
+
+/* ================================================================
+ * Debugging:
+ */
+#define DO_DEBUG 1
+
+#if DO_DEBUG
+extern int MGA_DEBUG;
+#else
+#define MGA_DEBUG 0
+#endif
+
+#define DEBUG_VERBOSE_MSG 0x01
+#define DEBUG_VERBOSE_DRI 0x02
+#define DEBUG_VERBOSE_IOCTL 0x04
+#define DEBUG_VERBOSE_TEXTURE 0x08
+#define DEBUG_VERBOSE_FALLBACK 0x10
+
+static __inline__ GLuint mgaPackColor(GLuint cpp,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a)
+{
+ switch (cpp) {
+ case 2:
+ return PACK_COLOR_565( r, g, b );
+ case 4:
+ return PACK_COLOR_8888( a, r, g, b );
+ default:
+ return 0;
+ }
+}
+
+
+/*
+ * Subpixel offsets for window coordinates:
+ */
+#define SUBPIXEL_X (-0.5F)
+#define SUBPIXEL_Y (-0.5F + 0.125)
+
+
+#define MGA_WA_TRIANGLES 0x18000000
+#define MGA_WA_TRISTRIP_T0 0x02010200
+#define MGA_WA_TRIFAN_T0 0x01000408
+#define MGA_WA_TRISTRIP_T0T1 0x02010400
+#define MGA_WA_TRIFAN_T0T1 0x01000810
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgadd.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgadd.c
new file mode 100644
index 000000000..8532ea95f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgadd.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgadd.c,v 1.14 2002/10/30 12:51:35 alanh Exp $ */
+
+
+#include "mtypes.h"
+#include "framebuffer.h"
+
+#include "mm.h"
+#include "mgacontext.h"
+#include "mgadd.h"
+#include "mgastate.h"
+#include "mgaspan.h"
+#include "mgatex.h"
+#include "mgatris.h"
+#include "mgavb.h"
+#include "mga_xmesa.h"
+#include "utils.h"
+
+#define DRIVER_DATE "20050609"
+
+
+/***************************************
+ * Mesa's Driver Functions
+ ***************************************/
+
+
+static const GLubyte *mgaGetString( GLcontext *ctx, GLenum name )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ static char buffer[128];
+ unsigned offset;
+
+ switch ( name ) {
+ case GL_VENDOR:
+ return (GLubyte *) "VA Linux Systems Inc.";
+
+ case GL_RENDERER:
+ offset = driGetRendererString( buffer,
+ MGA_IS_G400(mmesa) ? "G400" :
+ MGA_IS_G200(mmesa) ? "G200" : "MGA",
+ DRIVER_DATE,
+ mmesa->mgaScreen->agpMode );
+
+ return (GLubyte *)buffer;
+
+ default:
+ return NULL;
+ }
+}
+
+
+static void mgaBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ /* Need to lock to make sure the driDrawable is uptodate. This
+ * information is used to resize Mesa's software buffers, so it has
+ * to be correct.
+ */
+ LOCK_HARDWARE( mmesa );
+ *width = mmesa->driDrawable->w;
+ *height = mmesa->driDrawable->h;
+ UNLOCK_HARDWARE( mmesa );
+}
+
+
+void mgaInitDriverFuncs( struct dd_function_table *functions )
+{
+ functions->GetBufferSize = mgaBufferSize;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
+ functions->GetString = mgaGetString;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgadd.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgadd.h
new file mode 100644
index 000000000..f98bfdc87
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgadd.h
@@ -0,0 +1,36 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgadd.h,v 1.3 2002/10/30 12:51:35 alanh Exp $ */
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef MGADD_INC
+#define MGADD_INC
+
+#include "context.h"
+
+extern void mgaInitDriverFuncs( struct dd_function_table *functions );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaioctl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaioctl.c
new file mode 100644
index 000000000..df253d159
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaioctl.c
@@ -0,0 +1,743 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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.
+ */
+
+/**
+ * \file mgaioctl.c
+ * MGA IOCTL related wrapper functions.
+ *
+ * \author Keith Whitwell <keith@tungstengraphics.com>
+ * \author Gareth Hughes <gareth@valinux.com>
+ */
+
+#include <errno.h>
+#include "mtypes.h"
+#include "macros.h"
+#include "dd.h"
+#include "swrast/swrast.h"
+
+#include "mm.h"
+#include "drm.h"
+#include "mga_drm.h"
+#include "mgacontext.h"
+#include "mgadd.h"
+#include "mgastate.h"
+#include "mgatex.h"
+#include "mgavb.h"
+#include "mgaioctl.h"
+#include "mgatris.h"
+
+#include "vblank.h"
+
+
+int
+mgaSetFence( mgaContextPtr mmesa, uint32_t * fence )
+{
+ int ret = ENOSYS;
+
+ if ( mmesa->driScreen->drmMinor >= 2 ) {
+ ret = drmCommandWriteRead( mmesa->driScreen->fd, DRM_MGA_SET_FENCE,
+ fence, sizeof( uint32_t ));
+ if (ret) {
+ fprintf(stderr, "drmMgaSetFence: %d\n", ret);
+ exit(1);
+ }
+ }
+
+ return ret;
+}
+
+
+int
+mgaWaitFence( mgaContextPtr mmesa, uint32_t fence, uint32_t * curr_fence )
+{
+ int ret = ENOSYS;
+
+ if ( mmesa->driScreen->drmMinor >= 2 ) {
+ uint32_t temp = fence;
+
+ ret = drmCommandWriteRead( mmesa->driScreen->fd,
+ DRM_MGA_WAIT_FENCE,
+ & temp, sizeof( uint32_t ));
+ if (ret) {
+ fprintf(stderr, "drmMgaSetFence: %d\n", ret);
+ exit(1);
+ }
+
+ if ( curr_fence ) {
+ *curr_fence = temp;
+ }
+ }
+
+ return ret;
+}
+
+
+static void mga_iload_dma_ioctl(mgaContextPtr mmesa,
+ unsigned long dest,
+ int length)
+{
+ drmBufPtr buf = mmesa->iload_buffer;
+ drm_mga_iload_t iload;
+ int ret, i;
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "DRM_IOCTL_MGA_ILOAD idx %d dst %x length %d\n",
+ buf->idx, (int) dest, length);
+
+ if ( (length & MGA_ILOAD_MASK) != 0 ) {
+ UNLOCK_HARDWARE( mmesa );
+ fprintf( stderr, "%s: Invalid ILOAD datasize (%d), must be "
+ "multiple of %u.\n", __FUNCTION__, length, MGA_ILOAD_ALIGN );
+ exit( 1 );
+ }
+
+ iload.idx = buf->idx;
+ iload.dstorg = dest;
+ iload.length = length;
+
+ i = 0;
+ do {
+ ret = drmCommandWrite( mmesa->driFd, DRM_MGA_ILOAD,
+ &iload, sizeof(iload) );
+ } while ( ret == -EBUSY && i++ < DRM_MGA_IDLE_RETRY );
+
+ if ( ret < 0 ) {
+ printf("send iload retcode = %d\n", ret);
+ exit(1);
+ }
+
+ mmesa->iload_buffer = 0;
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "finished iload dma put\n");
+
+}
+
+drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa )
+{
+ int idx = 0;
+ int size = 0;
+ drmDMAReq dma;
+ int retcode;
+ drmBufPtr buf;
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "Getting dma buffer\n");
+
+ dma.context = mmesa->hHWContext;
+ dma.send_count = 0;
+ dma.send_list = NULL;
+ dma.send_sizes = NULL;
+ dma.flags = 0;
+ dma.request_count = 1;
+ dma.request_size = MGA_BUFFER_SIZE;
+ dma.request_list = &idx;
+ dma.request_sizes = &size;
+ dma.granted_count = 0;
+
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "drmDMA (get) ctx %d count %d size 0x%x\n",
+ dma.context, dma.request_count,
+ dma.request_size);
+
+ while (1) {
+ retcode = drmDMA(mmesa->driFd, &dma);
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "retcode %d sz %d idx %d count %d\n",
+ retcode,
+ dma.request_sizes[0],
+ dma.request_list[0],
+ dma.granted_count);
+
+ if (retcode == 0 &&
+ dma.request_sizes[0] &&
+ dma.granted_count)
+ break;
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "\n\nflush");
+
+ UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT );
+ }
+
+ buf = &(mmesa->mgaScreen->bufs->list[idx]);
+ buf->used = 0;
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr,
+ "drmDMA (get) returns size[0] 0x%x idx[0] %d\n"
+ "dma_buffer now: buf idx: %d size: %d used: %d addr %p\n",
+ dma.request_sizes[0], dma.request_list[0],
+ buf->idx, buf->total,
+ buf->used, buf->address);
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "finished getbuffer\n");
+
+ return buf;
+}
+
+
+
+
+static void
+mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
+ GLuint flags = 0;
+ GLuint clear_color = mmesa->ClearColor;
+ GLuint clear_depth = 0;
+ GLuint color_mask = 0;
+ GLuint depth_mask = 0;
+ int ret;
+ int i;
+ static int nrclears;
+ drm_mga_clear_t clear;
+
+ FLUSH_BATCH( mmesa );
+
+ if ( mask & BUFFER_BIT_FRONT_LEFT ) {
+ flags |= MGA_FRONT;
+ color_mask = mmesa->setup.plnwt;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
+ }
+
+ if ( mask & BUFFER_BIT_BACK_LEFT ) {
+ flags |= MGA_BACK;
+ color_mask = mmesa->setup.plnwt;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
+ }
+
+ if ( (mask & BUFFER_BIT_DEPTH) && ctx->Depth.Mask ) {
+ flags |= MGA_DEPTH;
+ clear_depth = (mmesa->ClearDepth & mmesa->depth_clear_mask);
+ depth_mask |= mmesa->depth_clear_mask;
+ mask &= ~BUFFER_BIT_DEPTH;
+ }
+
+ if ( (mask & BUFFER_BIT_STENCIL) && mmesa->hw_stencil ) {
+ flags |= MGA_DEPTH;
+ clear_depth |= (ctx->Stencil.Clear & mmesa->stencil_clear_mask);
+ depth_mask |= mmesa->stencil_clear_mask;
+ mask &= ~BUFFER_BIT_STENCIL;
+ }
+
+ if ( flags ) {
+ LOCK_HARDWARE( mmesa );
+
+ if ( mmesa->dirty_cliprects )
+ mgaUpdateRects( mmesa, (MGA_FRONT | MGA_BACK) );
+
+ /* flip top to bottom */
+ cy = dPriv->h-cy-ch;
+ cx += mmesa->drawX;
+ cy += mmesa->drawY;
+
+ if ( MGA_DEBUG & DEBUG_VERBOSE_IOCTL )
+ fprintf( stderr, "Clear, bufs %x nbox %d\n",
+ (int)flags, (int)mmesa->numClipRects );
+
+ for (i = 0 ; i < mmesa->numClipRects ; )
+ {
+ int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, mmesa->numClipRects);
+ drm_clip_rect_t *box = mmesa->pClipRects;
+ drm_clip_rect_t *b = mmesa->sarea->boxes;
+ int n = 0;
+
+ if (!all) {
+ for ( ; i < nr ; i++) {
+ GLint x = box[i].x1;
+ GLint y = box[i].y1;
+ GLint w = box[i].x2 - x;
+ GLint h = box[i].y2 - y;
+
+ 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) continue;
+ if (h <= 0) continue;
+
+ b->x1 = x;
+ b->y1 = y;
+ b->x2 = x + w;
+ b->y2 = y + h;
+ b++;
+ n++;
+ }
+ } else {
+ for ( ; i < nr ; i++) {
+ *b++ = box[i];
+ n++;
+ }
+ }
+
+
+ if ( MGA_DEBUG & DEBUG_VERBOSE_IOCTL )
+ fprintf( stderr,
+ "DRM_IOCTL_MGA_CLEAR flag 0x%x color %x depth %x nbox %d\n",
+ flags, clear_color, clear_depth, mmesa->sarea->nbox );
+
+ mmesa->sarea->nbox = n;
+
+ clear.flags = flags;
+ clear.clear_color = clear_color;
+ clear.clear_depth = clear_depth;
+ clear.color_mask = color_mask;
+ clear.depth_mask = depth_mask;
+ ret = drmCommandWrite( mmesa->driFd, DRM_MGA_CLEAR,
+ &clear, sizeof(clear));
+ if ( ret ) {
+ fprintf( stderr, "send clear retcode = %d\n", ret );
+ exit( 1 );
+ }
+ if ( MGA_DEBUG & DEBUG_VERBOSE_IOCTL )
+ fprintf( stderr, "finished clear %d\n", ++nrclears );
+ }
+
+ UNLOCK_HARDWARE( mmesa );
+ mmesa->dirty |= MGA_UPLOAD_CLIPRECTS|MGA_UPLOAD_CONTEXT;
+ }
+
+ if (mask)
+ _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
+}
+
+
+/**
+ * Wait for the previous frame of rendering has completed.
+ *
+ * \param mmesa Hardware context pointer.
+ *
+ * \bug
+ * The loop in this function should have some sort of a timeout mechanism.
+ *
+ * \warning
+ * This routine used to assume that the hardware lock was held on entry. It
+ * now assumes that the lock is \b not held on entry.
+ */
+
+static void mgaWaitForFrameCompletion( mgaContextPtr mmesa )
+{
+ if ( mgaWaitFence( mmesa, mmesa->last_frame_fence, NULL ) == ENOSYS ) {
+ unsigned wait = 0;
+ GLuint last_frame;
+ GLuint last_wrap;
+
+
+ LOCK_HARDWARE( mmesa );
+ last_frame = mmesa->sarea->last_frame.head;
+ last_wrap = mmesa->sarea->last_frame.wrap;
+
+ /* The DMA routines in the kernel track a couple values in the SAREA
+ * that we use here. The number of times that the primary DMA buffer
+ * has "wrapped" around is tracked in last_wrap. In addition, the
+ * wrap count and the buffer position at the end of the last frame are
+ * stored in last_frame.wrap and last_frame.head.
+ *
+ * By comparing the wrap counts and the current DMA pointer value
+ * (read directly from the hardware) to last_frame.head, we can
+ * determine when the graphics processor has processed all of the
+ * commands for the last frame.
+ *
+ * In this case "last frame" means the frame of the *previous* swap-
+ * buffers call. This is done to prevent queuing a second buffer swap
+ * before the previous swap is executed.
+ */
+ while ( 1 ) {
+ if ( last_wrap < mmesa->sarea->last_wrap ||
+ ( last_wrap == mmesa->sarea->last_wrap &&
+ last_frame <= (MGA_READ( MGAREG_PRIMADDRESS ) -
+ mmesa->primary_offset) ) ) {
+ break;
+ }
+ if ( 0 ) {
+ wait++;
+ fprintf( stderr, " last: head=0x%06x wrap=%d\n",
+ last_frame, last_wrap );
+ fprintf( stderr, " head: head=0x%06lx wrap=%d\n",
+ (long)(MGA_READ( MGAREG_PRIMADDRESS ) - mmesa->primary_offset),
+ mmesa->sarea->last_wrap );
+ }
+ UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH );
+
+ UNLOCK_HARDWARE( mmesa );
+ DO_USLEEP( 1 );
+ LOCK_HARDWARE( mmesa );
+ }
+ if ( wait )
+ fprintf( stderr, "\n" );
+
+ UNLOCK_HARDWARE( mmesa );
+ }
+}
+
+
+/*
+ * Copy the back buffer to the front buffer.
+ */
+void mgaCopyBuffer( const __DRIdrawablePrivate *dPriv )
+{
+ mgaContextPtr mmesa;
+ drm_clip_rect_t *pbox;
+ GLint nbox;
+ GLint ret;
+ GLint i;
+ GLboolean missed_target;
+
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ mmesa = (mgaContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ FLUSH_BATCH( mmesa );
+
+ mgaWaitForFrameCompletion( mmesa );
+ driWaitForVBlank( dPriv, & mmesa->vbl_seq, mmesa->vblank_flags,
+ & missed_target );
+ if ( missed_target ) {
+ mmesa->swap_missed_count++;
+ (void) (*dri_interface->getUST)( & mmesa->swap_missed_ust );
+ }
+ LOCK_HARDWARE( mmesa );
+
+ /* Use the frontbuffer cliprects
+ */
+ if (mmesa->dirty_cliprects & MGA_FRONT)
+ mgaUpdateRects( mmesa, MGA_FRONT );
+
+
+ pbox = dPriv->pClipRects;
+ nbox = dPriv->numClipRects;
+
+ for (i = 0 ; i < nbox ; )
+ {
+ int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, dPriv->numClipRects);
+ drm_clip_rect_t *b = mmesa->sarea->boxes;
+
+ mmesa->sarea->nbox = nr - i;
+
+ for ( ; i < nr ; i++)
+ *b++ = pbox[i];
+
+ if (0)
+ fprintf(stderr, "DRM_IOCTL_MGA_SWAP\n");
+
+ ret = drmCommandNone( mmesa->driFd, DRM_MGA_SWAP );
+ if ( ret ) {
+ printf("send swap retcode = %d\n", ret);
+ exit(1);
+ }
+ }
+
+ (void) mgaSetFence( mmesa, & mmesa->last_frame_fence );
+ UNLOCK_HARDWARE( mmesa );
+
+ mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
+ mmesa->swap_count++;
+ (void) (*dri_interface->getUST)( & mmesa->swap_ust );
+}
+
+
+/**
+ * Implement the hardware-specific portion of \c glFinish.
+ *
+ * Flushes all pending commands to the hardware and wait for them to finish.
+ *
+ * \param ctx Context where the \c glFinish command was issued.
+ *
+ * \sa glFinish, mgaFlush, mgaFlushDMA
+ */
+static void mgaFinish( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ uint32_t fence;
+
+
+ LOCK_HARDWARE( mmesa );
+ if ( mmesa->vertex_dma_buffer != NULL ) {
+ mgaFlushVerticesLocked( mmesa );
+ }
+
+ if ( mgaSetFence( mmesa, & fence ) == 0 ) {
+ UNLOCK_HARDWARE( mmesa );
+ (void) mgaWaitFence( mmesa, fence, NULL );
+ }
+ else {
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) {
+ fprintf(stderr, "mgaRegetLockQuiescent\n");
+ }
+
+ UPDATE_LOCK( mmesa, DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH );
+ UNLOCK_HARDWARE( mmesa );
+ }
+}
+
+
+/**
+ * Flush all commands upto at least a certain point to the hardware.
+ *
+ * \note
+ * The term "wait" in the name of this function is misleading. It doesn't
+ * actually wait for anything. It just makes sure that the commands have
+ * been flushed to the hardware.
+ *
+ * \warning
+ * As the name implies, this function assumes that the hardware lock is
+ * held on entry.
+ */
+void mgaWaitAgeLocked( mgaContextPtr mmesa, int age )
+{
+ if (GET_DISPATCH_AGE(mmesa) < age) {
+ UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH );
+ }
+}
+
+
+static GLboolean intersect_rect( drm_clip_rect_t *out,
+ const drm_clip_rect_t *a,
+ const drm_clip_rect_t *b )
+{
+ *out = *a;
+ if (b->x1 > out->x1) out->x1 = b->x1;
+ if (b->y1 > out->y1) out->y1 = b->y1;
+ if (b->x2 < out->x2) out->x2 = b->x2;
+ if (b->y2 < out->y2) out->y2 = b->y2;
+
+ return ((out->x1 < out->x2) && (out->y1 < out->y2));
+}
+
+
+
+
+static void age_mmesa( mgaContextPtr mmesa, int age )
+{
+ if (mmesa->CurrentTexObj[0]) mmesa->CurrentTexObj[0]->age = age;
+ if (mmesa->CurrentTexObj[1]) mmesa->CurrentTexObj[1]->age = age;
+}
+
+
+void mgaFlushVerticesLocked( mgaContextPtr mmesa )
+{
+ drm_clip_rect_t *pbox = mmesa->pClipRects;
+ int nbox = mmesa->numClipRects;
+ drmBufPtr buffer = mmesa->vertex_dma_buffer;
+ drm_mga_vertex_t vertex;
+ int i;
+
+ mmesa->vertex_dma_buffer = 0;
+
+ if (!buffer)
+ return;
+
+ if (mmesa->dirty_cliprects & mmesa->draw_buffer)
+ mgaUpdateRects( mmesa, mmesa->draw_buffer );
+
+ if (mmesa->dirty & ~MGA_UPLOAD_CLIPRECTS)
+ mgaEmitHwStateLocked( mmesa );
+
+ /* FIXME: Workaround bug in kernel module.
+ */
+ mmesa->sarea->dirty |= MGA_UPLOAD_CONTEXT;
+
+ if (!nbox)
+ buffer->used = 0;
+
+ if (nbox >= MGA_NR_SAREA_CLIPRECTS)
+ mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
+
+#if 0
+ if (!buffer->used || !(mmesa->dirty & MGA_UPLOAD_CLIPRECTS))
+ {
+ if (nbox == 1)
+ mmesa->sarea->nbox = 0;
+ else
+ mmesa->sarea->nbox = nbox;
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "Firing vertex -- case a nbox %d\n", nbox);
+
+ vertex.idx = buffer->idx;
+ vertex.used = buffer->used;
+ vertex.discard = 1;
+ drmCommandWrite( mmesa->driFd, DRM_MGA_VERTEX,
+ &vertex, sizeof(drmMGAVertex) );
+
+ age_mmesa(mmesa, mmesa->sarea->last_enqueue);
+ }
+ else
+#endif
+ {
+ for (i = 0 ; i < nbox ; )
+ {
+ int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, nbox);
+ drm_clip_rect_t *b = mmesa->sarea->boxes;
+ int discard = 0;
+
+ if (mmesa->scissor) {
+ mmesa->sarea->nbox = 0;
+
+ for ( ; i < nr ; i++) {
+ *b = pbox[i];
+ if (intersect_rect(b, b, &mmesa->scissor_rect)) {
+ mmesa->sarea->nbox++;
+ b++;
+ }
+ }
+
+ /* Culled?
+ */
+ if (!mmesa->sarea->nbox) {
+ if (nr < nbox) continue;
+ buffer->used = 0;
+ }
+ } else {
+ mmesa->sarea->nbox = nr - i;
+ for ( ; i < nr ; i++)
+ *b++ = pbox[i];
+ }
+
+ /* Finished with the buffer?
+ */
+ if (nr == nbox)
+ discard = 1;
+
+ mmesa->sarea->dirty |= MGA_UPLOAD_CLIPRECTS;
+
+ vertex.idx = buffer->idx;
+ vertex.used = buffer->used;
+ vertex.discard = discard;
+ drmCommandWrite( mmesa->driFd, DRM_MGA_VERTEX,
+ &vertex, sizeof(vertex) );
+
+ age_mmesa(mmesa, mmesa->sarea->last_enqueue);
+ }
+ }
+
+ mmesa->dirty &= ~MGA_UPLOAD_CLIPRECTS;
+}
+
+void mgaFlushVertices( mgaContextPtr mmesa )
+{
+ LOCK_HARDWARE( mmesa );
+ mgaFlushVerticesLocked( mmesa );
+ UNLOCK_HARDWARE( mmesa );
+}
+
+
+void mgaFireILoadLocked( mgaContextPtr mmesa,
+ GLuint offset, GLuint length )
+{
+ if (!mmesa->iload_buffer) {
+ fprintf(stderr, "mgaFireILoad: no buffer\n");
+ return;
+ }
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "mgaFireILoad idx %d ofs 0x%x length %d\n",
+ mmesa->iload_buffer->idx, (int)offset, (int)length );
+
+ mga_iload_dma_ioctl( mmesa, offset, length );
+}
+
+void mgaGetILoadBufferLocked( mgaContextPtr mmesa )
+{
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL)
+ fprintf(stderr, "mgaGetIloadBuffer (buffer now %p)\n",
+ (void *) mmesa->iload_buffer);
+
+ mmesa->iload_buffer = mga_get_buffer_ioctl( mmesa );
+}
+
+
+/**
+ * Implement the hardware-specific portion of \c glFlush.
+ *
+ * \param ctx Context to be flushed.
+ *
+ * \sa glFlush, mgaFinish, mgaFlushDMA
+ */
+static void mgaFlush( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+
+
+ LOCK_HARDWARE( mmesa );
+ if ( mmesa->vertex_dma_buffer != NULL ) {
+ mgaFlushVerticesLocked( mmesa );
+ }
+
+ UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH );
+ UNLOCK_HARDWARE( mmesa );
+}
+
+
+int mgaFlushDMA( int fd, drmLockFlags flags )
+{
+ drm_lock_t lock;
+ int ret, i = 0;
+
+ memset( &lock, 0, sizeof(lock) );
+
+ lock.flags = flags & (DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH
+ | DRM_LOCK_FLUSH_ALL);
+
+ do {
+ ret = drmCommandWrite( fd, DRM_MGA_FLUSH, &lock, sizeof(lock) );
+ } while ( ret && errno == EBUSY && i++ < DRM_MGA_IDLE_RETRY );
+
+ if ( ret == 0 )
+ return 0;
+ if ( errno != EBUSY )
+ return -errno;
+
+ if ( lock.flags & DRM_LOCK_QUIESCENT ) {
+ /* Only keep trying if we need quiescence.
+ */
+ lock.flags &= ~(DRM_LOCK_FLUSH | DRM_LOCK_FLUSH_ALL);
+
+ do {
+ ret = drmCommandWrite( fd, DRM_MGA_FLUSH, &lock, sizeof(lock) );
+ } while ( ret && errno == EBUSY && i++ < DRM_MGA_IDLE_RETRY );
+ }
+
+ if ( ret == 0 ) {
+ return 0;
+ } else {
+ return -errno;
+ }
+}
+
+void mgaInitIoctlFuncs( struct dd_function_table *functions )
+{
+ functions->Clear = mgaClear;
+ functions->Flush = mgaFlush;
+ functions->Finish = mgaFinish;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaioctl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaioctl.h
new file mode 100644
index 000000000..f3ae749ca
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaioctl.h
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ * Gareth Hughes <gareth@valinux.com>
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaioctl.h,v 1.11 2002/10/30 12:51:36 alanh Exp $ */
+
+#ifndef MGA_IOCTL_H
+#define MGA_IOCTL_H
+
+#include "mgacontext.h"
+#include "mga_xmesa.h"
+
+void mgaCopyBuffer( const __DRIdrawablePrivate *dPriv );
+void mgaWaitForVBlank( mgaContextPtr mmesa );
+
+void mgaGetILoadBufferLocked( mgaContextPtr mmesa );
+void mgaFireILoadLocked( mgaContextPtr mmesa,
+ GLuint offset, GLuint length );
+
+void mgaWaitAgeLocked( mgaContextPtr mmesa, int age );
+
+void mgaFlushVertices( mgaContextPtr mmesa );
+void mgaFlushVerticesLocked( mgaContextPtr mmesa );
+int mgaFlushDMA( int fd, drmLockFlags flags );
+
+void mgaInitIoctlFuncs( struct dd_function_table *functions );
+
+#define FLUSH_BATCH(mmesa) do { \
+ if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) \
+ fprintf(stderr, "FLUSH_BATCH in %s\n", __FUNCTION__); \
+ if (mmesa->vertex_dma_buffer) mgaFlushVertices(mmesa); \
+} while (0)
+
+#define MGA_STATECHANGE(mmesa, flag) do { \
+ FLUSH_BATCH(mmesa); \
+ mmesa->dirty |= flag; \
+} while (0)
+
+
+extern drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa );
+
+static __inline
+GLuint *mgaAllocDmaLow( mgaContextPtr mmesa, int bytes )
+{
+ GLuint *head;
+
+ /* If there is no DMA buffer currently allocated or the currently
+ * allocated DMA buffer doesn't have enough room left for this request,
+ * a new buffer will need to be allocated.
+ */
+ if ( (mmesa->vertex_dma_buffer == NULL)
+ || ((mmesa->vertex_dma_buffer->used + bytes)
+ > mmesa->vertex_dma_buffer->total) ) {
+ LOCK_HARDWARE( mmesa );
+
+ /* In the case where the existing buffer does not have enough room,
+ * we need to flush it out to the hardware.
+ */
+ if ( mmesa->vertex_dma_buffer != NULL ) {
+ mgaFlushVerticesLocked( mmesa );
+ }
+
+ mmesa->vertex_dma_buffer = mga_get_buffer_ioctl( mmesa );
+ UNLOCK_HARDWARE( mmesa );
+ }
+
+ head = (GLuint *)((char *)mmesa->vertex_dma_buffer->address +
+ mmesa->vertex_dma_buffer->used);
+
+ mmesa->vertex_dma_buffer->used += bytes;
+ return head;
+}
+
+
+#define UPDATE_LOCK( mmesa, flags ) \
+do { \
+ GLint ret = mgaFlushDMA( mmesa->driFd, flags ); \
+ if ( ret < 0 ) { \
+ drmCommandNone( mmesa->driFd, DRM_MGA_RESET ); \
+ UNLOCK_HARDWARE( mmesa ); \
+ fprintf( stderr, "%s: flush return = %s (%d), flags = 0x%08x\n", \
+ __FUNCTION__, strerror( -ret ), -ret, \
+ (unsigned)(flags) ); \
+ exit( 1 ); \
+ } \
+} while (0)
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgapixel.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgapixel.c
new file mode 100644
index 000000000..952b8d563
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgapixel.c
@@ -0,0 +1,664 @@
+/*
+ * Copyright 2000 Compaq Computer Inc. and VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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.
+ */
+
+/**
+ * \file mgapixel.c
+ * Implement framebuffer pixel operations for MGA.
+ *
+ * \todo
+ * Someday the accelerated \c glReadPixels and \c glDrawPixels paths need to
+ * be resurrected. They are currently ifdef'ed out because they don't seem
+ * to work and they only get activated some very rare circumstances.
+ *
+ * \author Keith Whitwell <keith@tungstengraphics.com>
+ * \author Gareth Hughes <gareth@valinux.com>
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgapixel.c,v 1.9 2002/11/05 17:46:08 tsi Exp $ */
+
+#include "mtypes.h"
+#include "macros.h"
+#include "mgadd.h"
+#include "mgacontext.h"
+#include "mgaioctl.h"
+#include "mgapixel.h"
+#include "mgastate.h"
+
+#include "swrast/swrast.h"
+#include "imports.h"
+
+#if 0
+#define IS_AGP_MEM( mmesa, p ) \
+ ((unsigned long)mmesa->mgaScreen->buffers.map <= ((unsigned long)p) && \
+ (unsigned long)mmesa->mgaScreen->buffers.map + \
+ (unsigned long)mmesa->mgaScreen->buffers.size > ((unsigned long)p))
+#define AGP_OFFSET( mmesa, p ) \
+ (((unsigned long)p) - (unsigned long)mmesa->mgaScreen->buffers.map)
+
+
+#if defined(MESA_packed_depth_stencil)
+static GLboolean
+check_depth_stencil_24_8( const GLcontext *ctx, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ const void *pixels, GLint sz,
+ GLint pitch )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ return ( type == GL_UNSIGNED_INT_24_8_MESA &&
+ ctx->Visual->DepthBits == 24 &&
+ ctx->Visual->StencilBits == 8 &&
+ mmesa->mgaScreen->cpp == 4 &&
+ mmesa->hw_stencil &&
+ !ctx->Pixel.IndexShift &&
+ !ctx->Pixel.IndexOffset &&
+ !ctx->Pixel.MapStencilFlag &&
+ ctx->Pixel.DepthBias == 0.0 &&
+ ctx->Pixel.DepthScale == 1.0 &&
+ !packing->SwapBytes &&
+ pitch % 32 == 0 &&
+ pitch < 4096 );
+}
+#endif
+
+
+static GLboolean
+check_depth( const GLcontext *ctx, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ const void *pixels, GLint sz, GLint pitch )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ if ( IS_AGP_MEM( mmesa, pixels ) &&
+ !( ( type == GL_UNSIGNED_INT && mmesa->mgaScreen->cpp == 4 ) ||
+ ( type == GL_UNSIGNED_SHORT && mmesa->mgaScreen->cpp == 2 ) ) )
+ return GL_FALSE;
+
+ return ( ctx->Pixel.DepthBias == 0.0 &&
+ ctx->Pixel.DepthScale == 1.0 &&
+ !packing->SwapBytes &&
+ pitch % 32 == 0 &&
+ pitch < 4096 );
+}
+
+
+static GLboolean
+check_color( const GLcontext *ctx, GLenum type, GLenum format,
+ const struct gl_pixelstore_attrib *packing,
+ const void *pixels, GLint sz, GLint pitch )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLuint cpp = mmesa->mgaScreen->cpp;
+
+ /* Can't do conversions on agp reads/draws.
+ */
+ if ( IS_AGP_MEM( mmesa, pixels ) &&
+ !( pitch % 32 == 0 && pitch < 4096 &&
+ ( ( type == GL_UNSIGNED_BYTE &&
+ cpp == 4 && format == GL_BGRA ) ||
+ ( type == GL_UNSIGNED_INT_8_8_8_8 &&
+ cpp == 4 && format == GL_BGRA ) ||
+ ( type == GL_UNSIGNED_SHORT_5_6_5_REV &&
+ cpp == 2 && format == GL_RGB ) ) ) )
+ return GL_FALSE;
+
+ return (!ctx->_ImageTransferState &&
+ !packing->SwapBytes &&
+ !packing->LsbFirst);
+}
+
+static GLboolean
+check_color_per_fragment_ops( const GLcontext *ctx )
+{
+ return (!( ctx->Color.AlphaEnabled ||
+ ctx->Depth.Test ||
+ ctx->Fog.Enabled ||
+ ctx->Scissor.Enabled ||
+ ctx->Stencil.Enabled ||
+ !ctx->Color.ColorMask[0] ||
+ !ctx->Color.ColorMask[1] ||
+ !ctx->Color.ColorMask[2] ||
+ !ctx->Color.ColorMask[3] ||
+ ctx->Color.ColorLogicOpEnabled ||
+ ctx->Texture._EnabledUnits ||
+ ctx->Depth.OcclusionTest
+ ) &&
+ ctx->Current.RasterPosValid &&
+ ctx->Pixel.ZoomX == 1.0F &&
+ (ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F));
+}
+
+static GLboolean
+check_depth_per_fragment_ops( const GLcontext *ctx )
+{
+ return ( ctx->Current.RasterPosValid &&
+ ctx->Color.ColorMask[RCOMP] == 0 &&
+ ctx->Color.ColorMask[BCOMP] == 0 &&
+ ctx->Color.ColorMask[GCOMP] == 0 &&
+ ctx->Color.ColorMask[ACOMP] == 0 &&
+ ctx->Pixel.ZoomX == 1.0F &&
+ ( ctx->Pixel.ZoomY == 1.0F || ctx->Pixel.ZoomY == -1.0F ) );
+}
+
+/* In addition to the requirements for depth:
+ */
+#if defined(MESA_packed_depth_stencil)
+static GLboolean
+check_stencil_per_fragment_ops( const GLcontext *ctx )
+{
+ return ( !ctx->Pixel.IndexShift &&
+ !ctx->Pixel.IndexOffset );
+}
+#endif
+
+
+static GLboolean
+clip_pixelrect( const GLcontext *ctx,
+ const GLframebuffer *buffer,
+ GLint *x, GLint *y,
+ GLsizei *width, GLsizei *height,
+ GLint *skipPixels, GLint *skipRows,
+ GLint *size )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ *width = MIN2(*width, MAX_WIDTH); /* redundant? */
+
+ /* left clipping */
+ if (*x < buffer->_Xmin) {
+ *skipPixels += (buffer->_Xmin - *x);
+ *width -= (buffer->_Xmin - *x);
+ *x = buffer->_Xmin;
+ }
+
+ /* right clipping */
+ if (*x + *width > buffer->_Xmax)
+ *width -= (*x + *width - buffer->_Xmax - 1);
+
+ if (*width <= 0)
+ return GL_FALSE;
+
+ /* bottom clipping */
+ if (*y < buffer->_Ymin) {
+ *skipRows += (buffer->_Ymin - *y);
+ *height -= (buffer->_Ymin - *y);
+ *y = buffer->_Ymin;
+ }
+
+ /* top clipping */
+ if (*y + *height > buffer->_Ymax)
+ *height -= (*y + *height - buffer->_Ymax - 1);
+
+ if (*height <= 0)
+ return GL_FALSE;
+
+ *size = ((*y + *height - 1) * mmesa->mgaScreen->frontPitch +
+ (*x + *width - 1) * mmesa->mgaScreen->cpp);
+
+ return GL_TRUE;
+}
+
+static GLboolean
+mgaTryReadPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack,
+ GLvoid *pixels )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLint size, skipPixels, skipRows;
+ GLint pitch = pack->RowLength ? pack->RowLength : width;
+ GLboolean ok;
+
+ GLuint planemask;
+ GLuint source;
+#if 0
+ drmMGABlit blit;
+ GLuint dest;
+ GLint source_pitch, dest_pitch;
+ GLint delta_sx, delta_sy;
+ GLint delta_dx, delta_dy;
+ GLint blit_height, ydir;
+#endif
+
+ if (!clip_pixelrect(ctx, ctx->ReadBuffer,
+ &x, &y, &width, &height,
+ &skipPixels, &skipRows, &size)) {
+ return GL_TRUE;
+ }
+
+ /* Only accelerate reading to agp buffers.
+ */
+ if ( !IS_AGP_MEM(mmesa, (char *)pixels) ||
+ !IS_AGP_MEM(mmesa, (char *)pixels + size) )
+ return GL_FALSE;
+
+ switch (format) {
+#if defined(MESA_packed_depth_stencil)
+ case GL_DEPTH_STENCIL_MESA:
+ ok = check_depth_stencil_24_8(ctx, type, pack, pixels, size, pitch);
+ planemask = ~0;
+ source = mmesa->mgaScreen->depthOffset;
+ break;
+#endif
+
+ case GL_DEPTH_COMPONENT:
+ ok = check_depth(ctx, type, pack, pixels, size, pitch);
+
+ /* Can't accelerate at this depth -- planemask does the wrong
+ * thing; it doesn't clear the low order bits in the
+ * destination, instead it leaves them untouched.
+ *
+ * Could get the acclerator to solid fill the destination with
+ * zeros first... Or get the cpu to do it...
+ */
+ if (ctx->Visual.depthBits == 24)
+ return GL_FALSE;
+
+ planemask = ~0;
+ source = mmesa->mgaScreen->depthOffset;
+ break;
+
+ case GL_RGB:
+ case GL_BGRA:
+ ok = check_color(ctx, type, format, pack, pixels, size, pitch);
+ planemask = ~0;
+ source = (mmesa->draw_buffer == MGA_FRONT ?
+ mmesa->mgaScreen->frontOffset :
+ mmesa->mgaScreen->backOffset);
+ break;
+
+ default:
+ return GL_FALSE;
+ }
+
+ if (!ok) {
+ return GL_FALSE;
+ }
+
+
+ LOCK_HARDWARE( mmesa );
+
+#if 0
+ {
+ __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
+ int nbox, retcode, i;
+
+ UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT );
+
+ if (mmesa->dirty_cliprects & MGA_FRONT)
+ mgaUpdateRects( mmesa, MGA_FRONT );
+
+ nbox = dPriv->numClipRects;
+
+ y = dPriv->h - y - height;
+ x += mmesa->drawX;
+ y += mmesa->drawY;
+
+ dest = ((mmesa->mgaScreen->agp.handle + AGP_OFFSET(mmesa, pixels)) |
+ DO_dstmap_sys | DO_dstacc_agp);
+ source_pitch = mmesa->mgaScreen->frontPitch / mmesa->mgaScreen->cpp;
+ dest_pitch = pitch;
+ delta_sx = 0;
+ delta_sy = 0;
+ delta_dx = -x;
+ delta_dy = -y;
+ blit_height = 2*y + height;
+ ydir = -1;
+
+ if (0) fprintf(stderr, "XX doing readpixel blit src_pitch %d dst_pitch %d\n",
+ source_pitch, dest_pitch);
+
+
+
+ for (i = 0 ; i < nbox ; )
+ {
+ int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, dPriv->numClipRects);
+ drm_clip_rect_t *box = dPriv->pClipRects;
+ drm_clip_rect_t *b = mmesa->sarea->boxes;
+ int n = 0;
+
+ for ( ; i < nr ; i++) {
+ GLint bx = box[i].x1;
+ GLint by = box[i].y1;
+ GLint bw = box[i].x2 - bx;
+ GLint bh = box[i].y2 - by;
+
+ if (bx < x) bw -= x - bx, bx = x;
+ if (by < y) bh -= y - by, by = y;
+ if (bx + bw > x + width) bw = x + width - bx;
+ if (by + bh > y + height) bh = y + height - by;
+ if (bw <= 0) continue;
+ if (bh <= 0) continue;
+
+ b->x1 = bx;
+ b->y1 = by;
+ b->x2 = bx + bw;
+ b->y2 = by + bh;
+ b++;
+ n++;
+ }
+
+ mmesa->sarea->nbox = n;
+
+ if (n && (retcode = drmCommandWrite( mmesa->driFd, DRM_MGA_BLIT,
+ &blit, sizeof(drmMGABlit)))) {
+ fprintf(stderr, "blit ioctl failed, retcode = %d\n", retcode);
+ UNLOCK_HARDWARE( mmesa );
+ exit(1);
+ }
+ }
+
+ UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT );
+ }
+#endif
+
+ UNLOCK_HARDWARE( mmesa );
+
+ return GL_TRUE;
+}
+
+static void
+mgaDDReadPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack,
+ GLvoid *pixels )
+{
+ if (!mgaTryReadPixels( ctx, x, y, width, height, format, type, pack, pixels))
+ _swrast_ReadPixels( ctx, x, y, width, height, format, type, pack, pixels);
+}
+
+
+
+
+static void do_draw_pix( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLint pitch,
+ const void *pixels,
+ GLuint dest, GLuint planemask)
+{
+#if 0
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ drmMGABlit blit;
+ __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
+ drm_clip_rect_t pbox = dPriv->pClipRects;
+ int nbox = dPriv->numClipRects;
+ int retcode, i;
+
+ y = dPriv->h - y - height;
+ x += mmesa->drawX;
+ y += mmesa->drawY;
+
+ blit.dest = dest;
+ blit.planemask = planemask;
+ blit.source = ((mmesa->mgaScreen->agp.handle + AGP_OFFSET(mmesa, pixels))
+ | SO_srcmap_sys | SO_srcacc_agp);
+ blit.dest_pitch = mmesa->mgaScreen->frontPitch / mmesa->mgaScreen->cpp;
+ blit.source_pitch = pitch;
+ blit.delta_sx = -x;
+ blit.delta_sy = -y;
+ blit.delta_dx = 0;
+ blit.delta_dy = 0;
+ if (ctx->Pixel.ZoomY == -1) {
+ blit.height = height;
+ blit.ydir = 1;
+ } else {
+ blit.height = height;
+ blit.ydir = -1;
+ }
+
+ if (0) fprintf(stderr,
+ "doing drawpixel blit src_pitch %d dst_pitch %d\n",
+ blit.source_pitch, blit.dest_pitch);
+
+ for (i = 0 ; i < nbox ; )
+ {
+ int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, dPriv->numClipRects);
+ drm_clip_rect_t *box = mmesa->pClipRects;
+ drm_clip_rect_t *b = mmesa->sarea->boxes;
+ int n = 0;
+
+ for ( ; i < nr ; i++) {
+ GLint bx = box[i].x1;
+ GLint by = box[i].y1;
+ GLint bw = box[i].x2 - bx;
+ GLint bh = box[i].y2 - by;
+
+ if (bx < x) bw -= x - bx, bx = x;
+ if (by < y) bh -= y - by, by = y;
+ if (bx + bw > x + width) bw = x + width - bx;
+ if (by + bh > y + height) bh = y + height - by;
+ if (bw <= 0) continue;
+ if (bh <= 0) continue;
+
+ b->x1 = bx;
+ b->y1 = by;
+ b->x2 = bx + bw;
+ b->y2 = by + bh;
+ b++;
+ n++;
+ }
+
+ mmesa->sarea->nbox = n;
+
+ if (n && (retcode = drmCommandWrite( mmesa->driFd, DRM_MGA_BLIT,
+ &blit, sizeof(drmMGABlit)))) {
+ fprintf(stderr, "blit ioctl failed, retcode = %d\n", retcode);
+ UNLOCK_HARDWARE( mmesa );
+ exit(1);
+ }
+ }
+#endif
+}
+
+
+
+
+static GLboolean
+mgaTryDrawPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLint size, skipPixels, skipRows;
+ GLint pitch = unpack->RowLength ? unpack->RowLength : width;
+ GLuint dest, planemask;
+ GLuint cpp = mmesa->mgaScreen->cpp;
+
+ if (!clip_pixelrect(ctx, ctx->DrawBuffer,
+ &x, &y, &width, &height,
+ &skipPixels, &skipRows, &size)) {
+ return GL_TRUE;
+ }
+
+
+ switch (format) {
+#if defined(MESA_packed_depth_stencil)
+ case GL_DEPTH_STENCIL_MESA:
+ dest = mmesa->mgaScreen->depthOffset;
+ planemask = ~0;
+ if (!check_depth_stencil_24_8(ctx, type, unpack, pixels, size, pitch) ||
+ !check_depth_per_fragment_ops(ctx) ||
+ !check_stencil_per_fragment_ops(ctx))
+ return GL_FALSE;
+ break;
+#endif
+
+ case GL_DEPTH_COMPONENT:
+ dest = mmesa->mgaScreen->depthOffset;
+
+ if (ctx->Visual.depthBits == 24)
+ planemask = ~0xff;
+ else
+ planemask = ~0;
+
+ if (!check_depth(ctx, type, unpack, pixels, size, pitch) ||
+ !check_depth_per_fragment_ops(ctx))
+ return GL_FALSE;
+ break;
+
+ case GL_RGB:
+ case GL_BGRA:
+ dest = (mmesa->draw_buffer == MGA_FRONT ?
+ mmesa->mgaScreen->frontOffset :
+ mmesa->mgaScreen->backOffset);
+
+ planemask = mgaPackColor(cpp,
+ ctx->Color.ColorMask[RCOMP],
+ ctx->Color.ColorMask[GCOMP],
+ ctx->Color.ColorMask[BCOMP],
+ ctx->Color.ColorMask[ACOMP]);
+
+ if (cpp == 2)
+ planemask |= planemask << 16;
+
+ if (!check_color(ctx, type, format, unpack, pixels, size, pitch)) {
+ return GL_FALSE;
+ }
+ if (!check_color_per_fragment_ops(ctx)) {
+ return GL_FALSE;
+ }
+ break;
+
+ default:
+ return GL_FALSE;
+ }
+
+ LOCK_HARDWARE_QUIESCENT( mmesa );
+
+ if (mmesa->dirty_cliprects & MGA_FRONT)
+ mgaUpdateRects( mmesa, MGA_FRONT );
+
+ if ( IS_AGP_MEM(mmesa, (char *)pixels) &&
+ IS_AGP_MEM(mmesa, (char *)pixels + size) )
+ {
+ do_draw_pix( ctx, x, y, width, height, pitch, pixels,
+ dest, planemask );
+ UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT );
+ }
+ else
+ {
+ /* Pixels is in regular memory -- get dma buffers and perform
+ * upload through them.
+ */
+/* drmBufPtr buf = mgaGetBufferLocked(mmesa); */
+ GLuint bufferpitch = (width*cpp+31)&~31;
+
+ char *address = 0; /* mmesa->mgaScreen->agp.map; */
+
+ do {
+/* GLuint rows = MIN2( height, MGA_DMA_BUF_SZ / bufferpitch ); */
+ GLuint rows = height;
+
+
+ if (0) fprintf(stderr, "trying to upload %d rows (pitch %d)\n",
+ rows, bufferpitch);
+
+ /* The texture conversion code is so slow that there is only
+ * negligble speedup when the buffers/images don't exactly
+ * match:
+ */
+#if 0
+ if (cpp == 2) {
+ if (!_mesa_convert_texsubimage2d( MESA_FORMAT_RGB565,
+ 0, 0, width, rows,
+ bufferpitch, format, type,
+ unpack, pixels, address )) {
+/* mgaReleaseBufLocked( mmesa, buf ); */
+ UNLOCK_HARDWARE(mmesa);
+ return GL_FALSE;
+ }
+ } else {
+ if (!_mesa_convert_texsubimage2d( MESA_FORMAT_ARGB8888,
+ 0, 0, width, rows,
+ bufferpitch, format, type,
+ unpack, pixels, address )) {
+/* mgaReleaseBufLocked( mmesa, buf ); */
+ UNLOCK_HARDWARE(mmesa);
+ return GL_FALSE;
+ }
+ }
+#else
+ MEMCPY( address, pixels, rows*bufferpitch );
+#endif
+
+ do_draw_pix( ctx, x, y, width, rows,
+ bufferpitch/cpp, address, dest, planemask );
+
+ /* Fix me -- use multiple buffers to avoid flush.
+ */
+ UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT );
+
+ pixels = (void *)((char *) pixels + rows * pitch);
+ height -= rows;
+ y += rows;
+ } while (height);
+
+/* mgaReleaseBufLocked( mmesa, buf ); */
+ }
+
+ UNLOCK_HARDWARE( mmesa );
+ mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
+
+ return GL_TRUE;
+}
+
+static void
+mgaDDDrawPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels )
+{
+ if (!mgaTryDrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels ))
+ _swrast_DrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels );
+}
+#endif
+
+
+/* Stub functions - not a real allocator, always returns pointer to
+ * the same block of agp space which isn't used for anything else at
+ * present.
+ */
+void mgaDDInitPixelFuncs( GLcontext *ctx )
+{
+ /* Pixel path fallbacks.
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+
+#if 0
+ if (getenv("MGA_BLIT_PIXELS")) {
+ ctx->Driver.ReadPixels = mgaDDReadPixels; /* requires agp dest */
+ ctx->Driver.DrawPixels = mgaDDDrawPixels; /* works with agp/normal mem */
+ }
+#endif
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgapixel.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgapixel.h
new file mode 100644
index 000000000..c44fd769a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgapixel.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2000-2001 Compaq Computer Inc. VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgapixel.h,v 1.5 2002/10/30 12:51:36 alanh Exp $ */
+
+#ifndef MGA_PIXELS_H
+#define MGA_PIXELS_H
+
+#include "mtypes.h"
+
+extern void mgaDDInitPixelFuncs( GLcontext *ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaregs.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaregs.h
new file mode 100644
index 000000000..e1291ca01
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaregs.h
@@ -0,0 +1,1395 @@
+/* author: stephen crowley, crow@debian.org */
+
+/*
+ * 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
+ * STEPHEN CROWLEY, OR ANY OTHER CONTRIBUTORS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaregs.h,v 1.6 2003/01/12 03:55:46 tsi Exp $ */
+
+#ifndef _MGAREGS_H_
+#define _MGAREGS_H_
+
+/*************** (START) AUTOMATICLY GENERATED REGISTER FILE *****************/
+/*
+ * Generated on Wed Jan 26 13:44:46 MST 2000
+ */
+
+
+
+/*
+ * Power Graphic Mode Memory Space Registers
+ */
+
+#define MGAREG_MGA_EXEC 0x0100
+#define MGAREG_AGP_PLL 0x1e4c
+
+# define AGP_PLL_agp2xpllen_MASK 0xfffffffe /* bit 0 */
+# define AGP_PLL_agp2xpllen_disable 0x0
+# define AGP_PLL_agp2xpllen_enable 0x1
+
+#define MGAREG_CFG_OR 0x1e4c
+
+# define CFG_OR_comp_or_MASK 0xfffffff7 /* bit 3 */
+# define CFG_OR_comp_or_disable 0x0
+# define CFG_OR_comp_or_enable 0x8
+# define CFG_OR_compfreq_MASK 0xffffff0f /* bits 4-7 */
+# define CFG_OR_compfreq_SHIFT 4
+# define CFG_OR_comporup_MASK 0xfffff0ff /* bits 8-11 */
+# define CFG_OR_comporup_SHIFT 8
+# define CFG_OR_compordn_MASK 0xffff0fff /* bits 12-15 */
+# define CFG_OR_compordn_SHIFT 12
+# define CFG_OR_e2pq_MASK 0xfffeffff /* bit 16 */
+# define CFG_OR_e2pq_disable 0x0
+# define CFG_OR_e2pq_enable 0x10000
+# define CFG_OR_e2pqbypcsn_MASK 0xfffdffff /* bit 17 */
+# define CFG_OR_e2pqbypcsn_disable 0x0
+# define CFG_OR_e2pqbypcsn_enable 0x20000
+# define CFG_OR_e2pqbypd_MASK 0xfffbffff /* bit 18 */
+# define CFG_OR_e2pqbypd_disable 0x0
+# define CFG_OR_e2pqbypd_enable 0x40000
+# define CFG_OR_e2pbypclk_MASK 0xfff7ffff /* bit 19 */
+# define CFG_OR_e2pbypclk_disable 0x0
+# define CFG_OR_e2pbypclk_enable 0x80000
+# define CFG_OR_e2pbyp_MASK 0xffefffff /* bit 20 */
+# define CFG_OR_e2pbyp_disable 0x0
+# define CFG_OR_e2pbyp_enable 0x100000
+# define CFG_OR_rate_cap_or_MASK 0xff1fffff /* bits 21-23 */
+# define CFG_OR_rate_cap_or_SHIFT 21
+# define CFG_OR_rq_or_MASK 0xe0ffffff /* bits 24-28 */
+# define CFG_OR_rq_or_SHIFT 24
+
+#define MGAREG_ALPHACTRL 0x2c7c
+
+# define AC_src_MASK 0xfffffff0 /* bits 0-3 */
+# define AC_src_zero 0x0 /* val 0, shift 0 */
+# define AC_src_one 0x1 /* val 1, shift 0 */
+# define AC_src_dst_color 0x2 /* val 2, shift 0 */
+# define AC_src_om_dst_color 0x3 /* val 3, shift 0 */
+# define AC_src_src_alpha 0x4 /* val 4, shift 0 */
+# define AC_src_om_src_alpha 0x5 /* val 5, shift 0 */
+# define AC_src_dst_alpha 0x6 /* val 6, shift 0 */
+# define AC_src_om_dst_alpha 0x7 /* val 7, shift 0 */
+# define AC_src_src_alpha_sat 0x8 /* val 8, shift 0 */
+# define AC_dst_MASK 0xffffff0f /* bits 4-7 */
+# define AC_dst_zero 0x0 /* val 0, shift 4 */
+# define AC_dst_one 0x10 /* val 1, shift 4 */
+# define AC_dst_src_color 0x20 /* val 2, shift 4 */
+# define AC_dst_om_src_color 0x30 /* val 3, shift 4 */
+# define AC_dst_src_alpha 0x40 /* val 4, shift 4 */
+# define AC_dst_om_src_alpha 0x50 /* val 5, shift 4 */
+# define AC_dst_dst_alpha 0x60 /* val 6, shift 4 */
+# define AC_dst_om_dst_alpha 0x70 /* val 7, shift 4 */
+# define AC_amode_MASK 0xfffffcff /* bits 8-9 */
+# define AC_amode_FCOL 0x0 /* val 0, shift 8 */
+# define AC_amode_alpha_channel 0x100 /* val 1, shift 8 */
+# define AC_amode_video_alpha 0x200 /* val 2, shift 8 */
+# define AC_amode_RSVD 0x300 /* val 3, shift 8 */
+# define AC_astipple_MASK 0xfffff7ff /* bit 11 */
+# define AC_astipple_disable 0x0
+# define AC_astipple_enable 0x800
+# define AC_aten_MASK 0xffffefff /* bit 12 */
+# define AC_aten_disable 0x0
+# define AC_aten_enable 0x1000
+# define AC_atmode_MASK 0xffff1fff /* bits 13-15 */
+# define AC_atmode_noacmp 0x0 /* val 0, shift 13 */
+# define AC_atmode_ae 0x4000 /* val 2, shift 13 */
+# define AC_atmode_ane 0x6000 /* val 3, shift 13 */
+# define AC_atmode_alt 0x8000 /* val 4, shift 13 */
+# define AC_atmode_alte 0xa000 /* val 5, shift 13 */
+# define AC_atmode_agt 0xc000 /* val 6, shift 13 */
+# define AC_atmode_agte 0xe000 /* val 7, shift 13 */
+# define AC_atref_MASK 0xff00ffff /* bits 16-23 */
+# define AC_atref_SHIFT 16
+# define AC_alphasel_MASK 0xfcffffff /* bits 24-25 */
+# define AC_alphasel_fromtex 0x0 /* val 0, shift 24 */
+# define AC_alphasel_diffused 0x1000000 /* val 1, shift 24 */
+# define AC_alphasel_modulated 0x2000000 /* val 2, shift 24 */
+# define AC_alphasel_trans 0x3000000 /* val 3, shift 24 */
+
+#define MGAREG_ALPHASTART 0x2c70
+#define MGAREG_ALPHAXINC 0x2c74
+#define MGAREG_ALPHAYINC 0x2c78
+#define MGAREG_AR0 0x1c60
+
+# define AR0_ar0_MASK 0xfffc0000 /* bits 0-17 */
+# define AR0_ar0_SHIFT 0
+
+#define MGAREG_AR1 0x1c64
+
+# define AR1_ar1_MASK 0xff000000 /* bits 0-23 */
+# define AR1_ar1_SHIFT 0
+
+#define MGAREG_AR2 0x1c68
+
+# define AR2_ar2_MASK 0xfffc0000 /* bits 0-17 */
+# define AR2_ar2_SHIFT 0
+
+#define MGAREG_AR3 0x1c6c
+
+# define AR3_ar3_MASK 0xff000000 /* bits 0-23 */
+# define AR3_ar3_SHIFT 0
+# define AR3_spage_MASK 0xf8ffffff /* bits 24-26 */
+# define AR3_spage_SHIFT 24
+
+#define MGAREG_AR4 0x1c70
+
+# define AR4_ar4_MASK 0xfffc0000 /* bits 0-17 */
+# define AR4_ar4_SHIFT 0
+
+#define MGAREG_AR5 0x1c74
+
+# define AR5_ar5_MASK 0xfffc0000 /* bits 0-17 */
+# define AR5_ar5_SHIFT 0
+
+#define MGAREG_AR6 0x1c78
+
+# define AR6_ar6_MASK 0xfffc0000 /* bits 0-17 */
+# define AR6_ar6_SHIFT 0
+
+#define MGAREG_BCOL 0x1c20
+#define MGAREG_BESA1CORG 0x3d10
+#define MGAREG_BESA1ORG 0x3d00
+#define MGAREG_BESA2CORG 0x3d14
+#define MGAREG_BESA2ORG 0x3d04
+#define MGAREG_BESB1CORG 0x3d18
+#define MGAREG_BESB1ORG 0x3d08
+#define MGAREG_BESB2CORG 0x3d1c
+#define MGAREG_BESB2ORG 0x3d0c
+#define MGAREG_BESCTL 0x3d20
+
+# define BC_besen_MASK 0xfffffffe /* bit 0 */
+# define BC_besen_disable 0x0
+# define BC_besen_enable 0x1
+# define BC_besv1srcstp_MASK 0xffffffbf /* bit 6 */
+# define BC_besv1srcstp_even 0x0
+# define BC_besv1srcstp_odd 0x40
+# define BC_besv2srcstp_MASK 0xfffffeff /* bit 8 */
+# define BC_besv2srcstp_disable 0x0
+# define BC_besv2srcstp_enable 0x100
+# define BC_beshfen_MASK 0xfffffbff /* bit 10 */
+# define BC_beshfen_disable 0x0
+# define BC_beshfen_enable 0x400
+# define BC_besvfen_MASK 0xfffff7ff /* bit 11 */
+# define BC_besvfen_disable 0x0
+# define BC_besvfen_enable 0x800
+# define BC_beshfixc_MASK 0xffffefff /* bit 12 */
+# define BC_beshfixc_weight 0x0
+# define BC_beshfixc_coeff 0x1000
+# define BC_bescups_MASK 0xfffeffff /* bit 16 */
+# define BC_bescups_disable 0x0
+# define BC_bescups_enable 0x10000
+# define BC_bes420pl_MASK 0xfffdffff /* bit 17 */
+# define BC_bes420pl_422 0x0
+# define BC_bes420pl_420 0x20000
+# define BC_besdith_MASK 0xfffbffff /* bit 18 */
+# define BC_besdith_disable 0x0
+# define BC_besdith_enable 0x40000
+# define BC_beshmir_MASK 0xfff7ffff /* bit 19 */
+# define BC_beshmir_disable 0x0
+# define BC_beshmir_enable 0x80000
+# define BC_besbwen_MASK 0xffefffff /* bit 20 */
+# define BC_besbwen_color 0x0
+# define BC_besbwen_bw 0x100000
+# define BC_besblank_MASK 0xffdfffff /* bit 21 */
+# define BC_besblank_disable 0x0
+# define BC_besblank_enable 0x200000
+# define BC_besfselm_MASK 0xfeffffff /* bit 24 */
+# define BC_besfselm_soft 0x0
+# define BC_besfselm_hard 0x1000000
+# define BC_besfsel_MASK 0xf9ffffff /* bits 25-26 */
+# define BC_besfsel_a1 0x0 /* val 0, shift 25 */
+# define BC_besfsel_a2 0x2000000 /* val 1, shift 25 */
+# define BC_besfsel_b1 0x4000000 /* val 2, shift 25 */
+# define BC_besfsel_b2 0x6000000 /* val 3, shift 25 */
+
+#define MGAREG_BESGLOBCTL 0x3dc0
+
+# define BGC_beshzoom_MASK 0xfffffffe /* bit 0 */
+# define BGC_beshzoom_disable 0x0
+# define BGC_beshzoom_enable 0x1
+# define BGC_beshzoomf_MASK 0xfffffffd /* bit 1 */
+# define BGC_beshzoomf_disable 0x0
+# define BGC_beshzoomf_enable 0x2
+# define BGC_bescorder_MASK 0xfffffff7 /* bit 3 */
+# define BGC_bescorder_even 0x0
+# define BGC_bescorder_odd 0x8
+# define BGC_besreghup_MASK 0xffffffef /* bit 4 */
+# define BGC_besreghup_disable 0x0
+# define BGC_besreghup_enable 0x10
+# define BGC_besvcnt_MASK 0xf000ffff /* bits 16-27 */
+# define BGC_besvcnt_SHIFT 16
+
+#define MGAREG_BESHCOORD 0x3d28
+
+# define BHC_besright_MASK 0xfffff800 /* bits 0-10 */
+# define BHC_besright_SHIFT 0
+# define BHC_besleft_MASK 0xf800ffff /* bits 16-26 */
+# define BHC_besleft_SHIFT 16
+
+#define MGAREG_BESHISCAL 0x3d30
+
+# define BHISF_beshiscal_MASK 0xffe00003 /* bits 2-20 */
+# define BHISF_beshiscal_SHIFT 2
+
+#define MGAREG_BESHSRCEND 0x3d3c
+
+# define BHSE_beshsrcend_MASK 0xfc000003 /* bits 2-25 */
+# define BHSE_beshsrcend_SHIFT 2
+
+#define MGAREG_BESHSRCLST 0x3d50
+
+# define BHSL_beshsrclst_MASK 0xfc00ffff /* bits 16-25 */
+# define BHSL_beshsrclst_SHIFT 16
+
+#define MGAREG_BESHSRCST 0x3d38
+
+# define BHSS_beshsrcst_MASK 0xfc000003 /* bits 2-25 */
+# define BHSS_beshsrcst_SHIFT 2
+
+#define MGAREG_BESPITCH 0x3d24
+
+# define BP_bespitch_MASK 0xfffff000 /* bits 0-11 */
+# define BP_bespitch_SHIFT 0
+
+#define MGAREG_BESSTATUS 0x3dc4
+
+# define BS_besstat_MASK 0xfffffffc /* bits 0-1 */
+# define BS_besstat_a1 0x0 /* val 0, shift 0 */
+# define BS_besstat_a2 0x1 /* val 1, shift 0 */
+# define BS_besstat_b1 0x2 /* val 2, shift 0 */
+# define BS_besstat_b2 0x3 /* val 3, shift 0 */
+
+#define MGAREG_BESV1SRCLST 0x3d54
+
+# define BSF_besv1srclast_MASK 0xfffffc00 /* bits 0-9 */
+# define BSF_besv1srclast_SHIFT 0
+
+#define MGAREG_BESV2SRCLST 0x3d58
+
+# define BSF_besv2srclst_MASK 0xfffffc00 /* bits 0-9 */
+# define BSF_besv2srclst_SHIFT 0
+
+#define MGAREG_BESV1WGHT 0x3d48
+
+# define BSF_besv1wght_MASK 0xffff0003 /* bits 2-15 */
+# define BSF_besv1wght_SHIFT 2
+# define BSF_besv1wghts_MASK 0xfffeffff /* bit 16 */
+# define BSF_besv1wghts_disable 0x0
+# define BSF_besv1wghts_enable 0x10000
+
+#define MGAREG_BESV2WGHT 0x3d4c
+
+# define BSF_besv2wght_MASK 0xffff0003 /* bits 2-15 */
+# define BSF_besv2wght_SHIFT 2
+# define BSF_besv2wghts_MASK 0xfffeffff /* bit 16 */
+# define BSF_besv2wghts_disable 0x0
+# define BSF_besv2wghts_enable 0x10000
+
+#define MGAREG_BESVCOORD 0x3d2c
+
+# define BVC_besbot_MASK 0xfffff800 /* bits 0-10 */
+# define BVC_besbot_SHIFT 0
+# define BVC_bestop_MASK 0xf800ffff /* bits 16-26 */
+# define BVC_bestop_SHIFT 16
+
+#define MGAREG_BESVISCAL 0x3d34
+
+# define BVISF_besviscal_MASK 0xffe00003 /* bits 2-20 */
+# define BVISF_besviscal_SHIFT 2
+
+#define MGAREG_CODECADDR 0x3e44
+#define MGAREG_CODECCTL 0x3e40
+#define MGAREG_CODECHARDPTR 0x3e4c
+#define MGAREG_CODECHOSTPTR 0x3e48
+#define MGAREG_CODECLCODE 0x3e50
+#define MGAREG_CXBNDRY 0x1c80
+
+# define CXB_cxleft_MASK 0xfffff000 /* bits 0-11 */
+# define CXB_cxleft_SHIFT 0
+# define CXB_cxright_MASK 0xf000ffff /* bits 16-27 */
+# define CXB_cxright_SHIFT 16
+
+#define MGAREG_CXLEFT 0x1ca0
+#define MGAREG_CXRIGHT 0x1ca4
+#define MGAREG_DMAMAP30 0x1e30
+#define MGAREG_DMAMAP74 0x1e34
+#define MGAREG_DMAMAPB8 0x1e38
+#define MGAREG_DMAMAPFC 0x1e3c
+#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 DO_dstmap_MASK 0xfffffffe /* bit 0 */
+# define DO_dstmap_fb 0x0
+# define DO_dstmap_sys 0x1
+# define DO_dstacc_MASK 0xfffffffd /* bit 1 */
+# define DO_dstacc_pci 0x0
+# define DO_dstacc_agp 0x2
+# define DO_dstorg_MASK 0x7 /* bits 3-31 */
+# define DO_dstorg_SHIFT 3
+
+#define MGAREG_DWG_INDIR_WT 0x1e80
+#define MGAREG_DWGCTL 0x1c00
+
+# define DC_opcod_MASK 0xfffffff0 /* bits 0-3 */
+# define DC_opcod_line_open 0x0 /* val 0, shift 0 */
+# define DC_opcod_autoline_open 0x1 /* val 1, shift 0 */
+# define DC_opcod_line_close 0x2 /* val 2, shift 0 */
+# define DC_opcod_autoline_close 0x3 /* val 3, shift 0 */
+# define DC_opcod_trap 0x4 /* val 4, shift 0 */
+# define DC_opcod_texture_trap 0x6 /* val 6, shift 0 */
+# define DC_opcod_bitblt 0x8 /* val 8, shift 0 */
+# define DC_opcod_iload 0x9 /* val 9, shift 0 */
+# define DC_atype_MASK 0xffffff8f /* bits 4-6 */
+# define DC_atype_rpl 0x0 /* val 0, shift 4 */
+# define DC_atype_rstr 0x10 /* val 1, shift 4 */
+# define DC_atype_zi 0x30 /* val 3, shift 4 */
+# define DC_atype_blk 0x40 /* val 4, shift 4 */
+# define DC_atype_i 0x70 /* val 7, shift 4 */
+# define DC_linear_MASK 0xffffff7f /* bit 7 */
+# define DC_linear_xy 0x0
+# define DC_linear_linear 0x80
+# define DC_zmode_MASK 0xfffff8ff /* bits 8-10 */
+# define DC_zmode_nozcmp 0x0 /* val 0, shift 8 */
+# define DC_zmode_ze 0x200 /* val 2, shift 8 */
+# define DC_zmode_zne 0x300 /* val 3, shift 8 */
+# define DC_zmode_zlt 0x400 /* val 4, shift 8 */
+# define DC_zmode_zlte 0x500 /* val 5, shift 8 */
+# define DC_zmode_zgt 0x600 /* val 6, shift 8 */
+# define DC_zmode_zgte 0x700 /* val 7, shift 8 */
+# define DC_solid_MASK 0xfffff7ff /* bit 11 */
+# define DC_solid_disable 0x0
+# define DC_solid_enable 0x800
+# define DC_arzero_MASK 0xffffefff /* bit 12 */
+# define DC_arzero_disable 0x0
+# define DC_arzero_enable 0x1000
+# define DC_sgnzero_MASK 0xffffdfff /* bit 13 */
+# define DC_sgnzero_disable 0x0
+# define DC_sgnzero_enable 0x2000
+# define DC_shftzero_MASK 0xffffbfff /* bit 14 */
+# define DC_shftzero_disable 0x0
+# define DC_shftzero_enable 0x4000
+# define DC_bop_MASK 0xfff0ffff /* bits 16-19 */
+# define DC_bop_SHIFT 16
+# define DC_trans_MASK 0xff0fffff /* bits 20-23 */
+# define DC_trans_SHIFT 20
+# define DC_bltmod_MASK 0xe1ffffff /* bits 25-28 */
+# define DC_bltmod_bmonolef 0x0 /* val 0, shift 25 */
+# define DC_bltmod_bmonowf 0x8000000 /* val 4, shift 25 */
+# define DC_bltmod_bplan 0x2000000 /* val 1, shift 25 */
+# define DC_bltmod_bfcol 0x4000000 /* val 2, shift 25 */
+# define DC_bltmod_bu32bgr 0x6000000 /* val 3, shift 25 */
+# define DC_bltmod_bu32rgb 0xe000000 /* val 7, shift 25 */
+# define DC_bltmod_bu24bgr 0x16000000 /* val 11, shift 25 */
+# define DC_bltmod_bu24rgb 0x1e000000 /* val 15, shift 25 */
+# define DC_pattern_MASK 0xdfffffff /* bit 29 */
+# define DC_pattern_disable 0x0
+# define DC_pattern_enable 0x20000000
+# define DC_transc_MASK 0xbfffffff /* bit 30 */
+# define DC_transc_disable 0x0
+# define DC_transc_enable 0x40000000
+# define DC_clipdis_MASK 0x7fffffff /* bit 31 */
+# define DC_clipdis_disable 0x0
+# define DC_clipdis_enable 0x80000000
+
+#define MGAREG_DWGSYNC 0x2c4c
+
+# define DS_dwgsyncaddr_MASK 0x3 /* bits 2-31 */
+# define DS_dwgsyncaddr_SHIFT 2
+
+#define MGAREG_FCOL 0x1c24
+#define MGAREG_FIFOSTATUS 0x1e10
+
+# define FS_fifocount_MASK 0xffffff80 /* bits 0-6 */
+# define FS_fifocount_SHIFT 0
+# define FS_bfull_MASK 0xfffffeff /* bit 8 */
+# define FS_bfull_disable 0x0
+# define FS_bfull_enable 0x100
+# define FS_bempty_MASK 0xfffffdff /* bit 9 */
+# define FS_bempty_disable 0x0
+# define FS_bempty_enable 0x200
+
+#define MGAREG_FOGCOL 0x1cf4
+#define MGAREG_FOGSTART 0x1cc4
+#define MGAREG_FOGXINC 0x1cd4
+#define MGAREG_FOGYINC 0x1ce4
+#define MGAREG_FXBNDRY 0x1c84
+
+# define XA_fxleft_MASK 0xffff0000 /* bits 0-15 */
+# define XA_fxleft_SHIFT 0
+# define XA_fxright_MASK 0xffff /* bits 16-31 */
+# define XA_fxright_SHIFT 16
+
+#define MGAREG_FXLEFT 0x1ca8
+#define MGAREG_FXRIGHT 0x1cac
+#define MGAREG_ICLEAR 0x1e18
+
+# define IC_softrapiclr_MASK 0xfffffffe /* bit 0 */
+# define IC_softrapiclr_disable 0x0
+# define IC_softrapiclr_enable 0x1
+# define IC_pickiclr_MASK 0xfffffffb /* bit 2 */
+# define IC_pickiclr_disable 0x0
+# define IC_pickiclr_enable 0x4
+# define IC_vlineiclr_MASK 0xffffffdf /* bit 5 */
+# define IC_vlineiclr_disable 0x0
+# define IC_vlineiclr_enable 0x20
+# define IC_wiclr_MASK 0xffffff7f /* bit 7 */
+# define IC_wiclr_disable 0x0
+# define IC_wiclr_enable 0x80
+# define IC_wciclr_MASK 0xfffffeff /* bit 8 */
+# define IC_wciclr_disable 0x0
+# define IC_wciclr_enable 0x100
+
+#define MGAREG_IEN 0x1e1c
+
+# define IE_softrapien_MASK 0xfffffffe /* bit 0 */
+# define IE_softrapien_disable 0x0
+# define IE_softrapien_enable 0x1
+# define IE_pickien_MASK 0xfffffffb /* bit 2 */
+# define IE_pickien_disable 0x0
+# define IE_pickien_enable 0x4
+# define IE_vlineien_MASK 0xffffffdf /* bit 5 */
+# define IE_vlineien_disable 0x0
+# define IE_vlineien_enable 0x20
+# define IE_extien_MASK 0xffffffbf /* bit 6 */
+# define IE_extien_disable 0x0
+# define IE_extien_enable 0x40
+# define IE_wien_MASK 0xffffff7f /* bit 7 */
+# define IE_wien_disable 0x0
+# define IE_wien_enable 0x80
+# define IE_wcien_MASK 0xfffffeff /* bit 8 */
+# define IE_wcien_disable 0x0
+# define IE_wcien_enable 0x100
+
+#define MGAREG_LEN 0x1c5c
+#define MGAREG_MACCESS 0x1c04
+
+# define MA_pwidth_MASK 0xfffffffc /* bits 0-1 */
+# define MA_pwidth_8 0x0 /* val 0, shift 0 */
+# define MA_pwidth_16 0x1 /* val 1, shift 0 */
+# define MA_pwidth_32 0x2 /* val 2, shift 0 */
+# define MA_pwidth_24 0x3 /* val 3, shift 0 */
+# define MA_zwidth_MASK 0xffffffe7 /* bits 3-4 */
+# define MA_zwidth_16 0x0 /* val 0, shift 3 */
+# define MA_zwidth_32 0x8 /* val 1, shift 3 */
+# define MA_zwidth_15 0x10 /* val 2, shift 3 */
+# define MA_zwidth_24 0x18 /* val 3, shift 3 */
+# define MA_memreset_MASK 0xffff7fff /* bit 15 */
+# define MA_memreset_disable 0x0
+# define MA_memreset_enable 0x8000
+# define MA_fogen_MASK 0xfbffffff /* bit 26 */
+# define MA_fogen_disable 0x0
+# define MA_fogen_enable 0x4000000
+# define MA_tlutload_MASK 0xdfffffff /* bit 29 */
+# define MA_tlutload_disable 0x0
+# define MA_tlutload_enable 0x20000000
+# define MA_nodither_MASK 0xbfffffff /* bit 30 */
+# define MA_nodither_disable 0x0
+# define MA_nodither_enable 0x40000000
+# define MA_dit555_MASK 0x7fffffff /* bit 31 */
+# define MA_dit555_disable 0x0
+# define MA_dit555_enable 0x80000000
+
+#define MGAREG_MCTLWTST 0x1c08
+
+# define MCWS_casltncy_MASK 0xfffffff8 /* bits 0-2 */
+# define MCWS_casltncy_SHIFT 0
+# define MCWS_rrddelay_MASK 0xffffffcf /* bits 4-5 */
+# define MCWS_rcddelay_MASK 0xfffffe7f /* bits 7-8 */
+# define MCWS_rasmin_MASK 0xffffe3ff /* bits 10-12 */
+# define MCWS_rasmin_SHIFT 10
+# define MCWS_rpdelay_MASK 0xffff3fff /* bits 14-15 */
+# define MCWS_wrdelay_MASK 0xfff3ffff /* bits 18-19 */
+# define MCWS_rddelay_MASK 0xffdfffff /* bit 21 */
+# define MCWS_rddelay_disable 0x0
+# define MCWS_rddelay_enable 0x200000
+# define MCWS_smrdelay_MASK 0xfe7fffff /* bits 23-24 */
+# define MCWS_bwcdelay_MASK 0xf3ffffff /* bits 26-27 */
+# define MCWS_bpldelay_MASK 0x1fffffff /* bits 29-31 */
+# define MCWS_bpldelay_SHIFT 29
+
+#define MGAREG_MEMRDBK 0x1e44
+
+# define MRB_mclkbrd0_MASK 0xfffffff0 /* bits 0-3 */
+# define MRB_mclkbrd0_SHIFT 0
+# define MRB_mclkbrd1_MASK 0xfffffe1f /* bits 5-8 */
+# define MRB_mclkbrd1_SHIFT 5
+# define MRB_strmfctl_MASK 0xff3fffff /* bits 22-23 */
+# define MRB_mrsopcod_MASK 0xe1ffffff /* bits 25-28 */
+# define MRB_mrsopcod_SHIFT 25
+
+#define MGAREG_OPMODE 0x1e54
+
+# define OM_dmamod_MASK 0xfffffff3 /* bits 2-3 */
+# define OM_dmamod_general 0x0 /* val 0, shift 2 */
+# define OM_dmamod_blit 0x4 /* val 1, shift 2 */
+# define OM_dmamod_vector 0x8 /* val 2, shift 2 */
+# define OM_dmamod_vertex 0xc /* val 3, shift 2 */
+# define OM_dmadatasiz_MASK 0xfffffcff /* bits 8-9 */
+# define OM_dmadatasiz_8 0x0 /* val 0, shift 8 */
+# define OM_dmadatasiz_16 0x100 /* val 1, shift 8 */
+# define OM_dmadatasiz_32 0x200 /* val 2, shift 8 */
+# define OM_dirdatasiz_MASK 0xfffcffff /* bits 16-17 */
+# define OM_dirdatasiz_8 0x0 /* val 0, shift 16 */
+# define OM_dirdatasiz_16 0x10000 /* val 1, shift 16 */
+# define OM_dirdatasiz_32 0x20000 /* val 2, shift 16 */
+
+#define MGAREG_PAT0 0x1c10
+#define MGAREG_PAT1 0x1c14
+#define MGAREG_PITCH 0x1c8c
+
+# define P_iy_MASK 0xffffe000 /* bits 0-12 */
+# define P_iy_SHIFT 0
+# define P_ylin_MASK 0xffff7fff /* bit 15 */
+# define P_ylin_disable 0x0
+# define P_ylin_enable 0x8000
+
+#define MGAREG_PLNWT 0x1c1c
+#define MGAREG_PRIMADDRESS 0x1e58
+
+# define PDCA_primod_MASK 0xfffffffc /* bits 0-1 */
+# define PDCA_primod_general 0x0 /* val 0, shift 0 */
+# define PDCA_primod_blit 0x1 /* val 1, shift 0 */
+# define PDCA_primod_vector 0x2 /* val 2, shift 0 */
+# define PDCA_primod_vertex 0x3 /* val 3, shift 0 */
+# define PDCA_primaddress_MASK 0x3 /* bits 2-31 */
+# define PDCA_primaddress_SHIFT 2
+
+#define MGAREG_PRIMEND 0x1e5c
+
+# define PDEA_primnostart_MASK 0xfffffffe /* bit 0 */
+# define PDEA_primnostart_disable 0x0
+# define PDEA_primnostart_enable 0x1
+# define PDEA_pagpxfer_MASK 0xfffffffd /* bit 1 */
+# define PDEA_pagpxfer_disable 0x0
+# define PDEA_pagpxfer_enable 0x2
+# define PDEA_primend_MASK 0x3 /* bits 2-31 */
+# define PDEA_primend_SHIFT 2
+
+#define MGAREG_PRIMPTR 0x1e50
+
+# define PLS_primptren0_MASK 0xfffffffe /* bit 0 */
+# define PLS_primptren0_disable 0x0
+# define PLS_primptren0_enable 0x1
+# define PLS_primptren1_MASK 0xfffffffd /* bit 1 */
+# define PLS_primptren1_disable 0x0
+# define PLS_primptren1_enable 0x2
+# define PLS_primptr_MASK 0x7 /* bits 3-31 */
+# define PLS_primptr_SHIFT 3
+
+#define MGAREG_RST 0x1e40
+
+# define R_softreset_MASK 0xfffffffe /* bit 0 */
+# define R_softreset_disable 0x0
+# define R_softreset_enable 0x1
+# define R_softextrst_MASK 0xfffffffd /* bit 1 */
+# define R_softextrst_disable 0x0
+# define R_softextrst_enable 0x2
+
+#define MGAREG_SECADDRESS 0x2c40
+
+# define SDCA_secmod_MASK 0xfffffffc /* bits 0-1 */
+# define SDCA_secmod_general 0x0 /* val 0, shift 0 */
+# define SDCA_secmod_blit 0x1 /* val 1, shift 0 */
+# define SDCA_secmod_vector 0x2 /* val 2, shift 0 */
+# define SDCA_secmod_vertex 0x3 /* val 3, shift 0 */
+# define SDCA_secaddress_MASK 0x3 /* bits 2-31 */
+# define SDCA_secaddress_SHIFT 2
+
+#define MGAREG_SECEND 0x2c44
+
+# define SDEA_sagpxfer_MASK 0xfffffffd /* bit 1 */
+# define SDEA_sagpxfer_disable 0x0
+# define SDEA_sagpxfer_enable 0x2
+# define SDEA_secend_MASK 0x3 /* bits 2-31 */
+# define SDEA_secend_SHIFT 2
+
+#define MGAREG_SETUPADDRESS 0x2cd0
+
+# define SETADD_mode_MASK 0xfffffffc /* bits 0-1 */
+# define SETADD_mode_vertlist 0x0 /* val 0, shift 0 */
+# define SETADD_address_MASK 0x3 /* bits 2-31 */
+# define SETADD_address_SHIFT 2
+
+#define MGAREG_SETUPEND 0x2cd4
+
+# define SETEND_agpxfer_MASK 0xfffffffd /* bit 1 */
+# define SETEND_agpxfer_disable 0x0
+# define SETEND_agpxfer_enable 0x2
+# define SETEND_address_MASK 0x3 /* bits 2-31 */
+# define SETEND_address_SHIFT 2
+
+#define MGAREG_SGN 0x1c58
+
+# define S_sdydxl_MASK 0xfffffffe /* bit 0 */
+# define S_sdydxl_y 0x0
+# define S_sdydxl_x 0x1
+# define S_scanleft_MASK 0xfffffffe /* bit 0 */
+# define S_scanleft_disable 0x0
+# define S_scanleft_enable 0x1
+# define S_sdxl_MASK 0xfffffffd /* bit 1 */
+# define S_sdxl_pos 0x0
+# define S_sdxl_neg 0x2
+# define S_sdy_MASK 0xfffffffb /* bit 2 */
+# define S_sdy_pos 0x0
+# define S_sdy_neg 0x4
+# define S_sdxr_MASK 0xffffffdf /* bit 5 */
+# define S_sdxr_pos 0x0
+# define S_sdxr_neg 0x20
+# define S_brkleft_MASK 0xfffffeff /* bit 8 */
+# define S_brkleft_disable 0x0
+# define S_brkleft_enable 0x100
+# define S_errorinit_MASK 0x7fffffff /* bit 31 */
+# define S_errorinit_disable 0x0
+# define S_errorinit_enable 0x80000000
+
+#define MGAREG_SHIFT 0x1c50
+
+# define FSC_x_off_MASK 0xfffffff0 /* bits 0-3 */
+# define FSC_x_off_SHIFT 0
+# define FSC_funcnt_MASK 0xffffff80 /* bits 0-6 */
+# define FSC_funcnt_SHIFT 0
+# define FSC_y_off_MASK 0xffffff8f /* bits 4-6 */
+# define FSC_y_off_SHIFT 4
+# define FSC_funoff_MASK 0xffc0ffff /* bits 16-21 */
+# define FSC_funoff_SHIFT 16
+# define FSC_stylelen_MASK 0xffc0ffff /* bits 16-21 */
+# define FSC_stylelen_SHIFT 16
+
+#define MGAREG_SOFTRAP 0x2c48
+
+# define STH_softraphand_MASK 0x3 /* bits 2-31 */
+# define STH_softraphand_SHIFT 2
+
+#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 SO_srcmap_MASK 0xfffffffe /* bit 0 */
+# define SO_srcmap_fb 0x0
+# define SO_srcmap_sys 0x1
+# define SO_srcacc_MASK 0xfffffffd /* bit 1 */
+# define SO_srcacc_pci 0x0
+# define SO_srcacc_agp 0x2
+# define SO_srcorg_MASK 0x7 /* bits 3-31 */
+# define SO_srcorg_SHIFT 3
+
+#define MGAREG_STATUS 0x1e14
+
+# define STAT_softrapen_MASK 0xfffffffe /* bit 0 */
+# define STAT_softrapen_disable 0x0
+# define STAT_softrapen_enable 0x1
+# define STAT_pickpen_MASK 0xfffffffb /* bit 2 */
+# define STAT_pickpen_disable 0x0
+# define STAT_pickpen_enable 0x4
+# define STAT_vsyncsts_MASK 0xfffffff7 /* bit 3 */
+# define STAT_vsyncsts_disable 0x0
+# define STAT_vsyncsts_enable 0x8
+# define STAT_vsyncpen_MASK 0xffffffef /* bit 4 */
+# define STAT_vsyncpen_disable 0x0
+# define STAT_vsyncpen_enable 0x10
+# define STAT_vlinepen_MASK 0xffffffdf /* bit 5 */
+# define STAT_vlinepen_disable 0x0
+# define STAT_vlinepen_enable 0x20
+# define STAT_extpen_MASK 0xffffffbf /* bit 6 */
+# define STAT_extpen_disable 0x0
+# define STAT_extpen_enable 0x40
+# define STAT_wpen_MASK 0xffffff7f /* bit 7 */
+# define STAT_wpen_disable 0x0
+# define STAT_wpen_enable 0x80
+# define STAT_wcpen_MASK 0xfffffeff /* bit 8 */
+# define STAT_wcpen_disable 0x0
+# define STAT_wcpen_enable 0x100
+# define STAT_dwgengsts_MASK 0xfffeffff /* bit 16 */
+# define STAT_dwgengsts_disable 0x0
+# define STAT_dwgengsts_enable 0x10000
+# define STAT_endprdmasts_MASK 0xfffdffff /* bit 17 */
+# define STAT_endprdmasts_disable 0x0
+# define STAT_endprdmasts_enable 0x20000
+# define STAT_wbusy_MASK 0xfffbffff /* bit 18 */
+# define STAT_wbusy_disable 0x0
+# define STAT_wbusy_enable 0x40000
+# define STAT_swflag_MASK 0xfffffff /* bits 28-31 */
+# define STAT_swflag_SHIFT 28
+
+#define MGAREG_STENCIL 0x2cc8
+
+# define S_sref_MASK 0xffffff00 /* bits 0-7 */
+# define S_sref_SHIFT 0
+# define S_smsk_MASK 0xffff00ff /* bits 8-15 */
+# define S_smsk_SHIFT 8
+# define S_swtmsk_MASK 0xff00ffff /* bits 16-23 */
+# define S_swtmsk_SHIFT 16
+
+#define MGAREG_STENCILCTL 0x2ccc
+
+# define SC_smode_MASK 0xfffffff8 /* bits 0-2 */
+# define SC_smode_salways 0x0 /* val 0, shift 0 */
+# define SC_smode_snever 0x1 /* val 1, shift 0 */
+# define SC_smode_se 0x2 /* val 2, shift 0 */
+# define SC_smode_sne 0x3 /* val 3, shift 0 */
+# define SC_smode_slt 0x4 /* val 4, shift 0 */
+# define SC_smode_slte 0x5 /* val 5, shift 0 */
+# define SC_smode_sgt 0x6 /* val 6, shift 0 */
+# define SC_smode_sgte 0x7 /* val 7, shift 0 */
+# define SC_sfailop_MASK 0xffffffc7 /* bits 3-5 */
+# define SC_sfailop_keep 0x0 /* val 0, shift 3 */
+# define SC_sfailop_zero 0x8 /* val 1, shift 3 */
+# define SC_sfailop_replace 0x10 /* val 2, shift 3 */
+# define SC_sfailop_incrsat 0x18 /* val 3, shift 3 */
+# define SC_sfailop_decrsat 0x20 /* val 4, shift 3 */
+# define SC_sfailop_invert 0x28 /* val 5, shift 3 */
+# define SC_sfailop_incr 0x30 /* val 6, shift 3 */
+# define SC_sfailop_decr 0x38 /* val 7, shift 3 */
+# define SC_szfailop_MASK 0xfffffe3f /* bits 6-8 */
+# define SC_szfailop_keep 0x0 /* val 0, shift 6 */
+# define SC_szfailop_zero 0x40 /* val 1, shift 6 */
+# define SC_szfailop_replace 0x80 /* val 2, shift 6 */
+# define SC_szfailop_incrsat 0xc0 /* val 3, shift 6 */
+# define SC_szfailop_decrsat 0x100 /* val 4, shift 6 */
+# define SC_szfailop_invert 0x140 /* val 5, shift 6 */
+# define SC_szfailop_incr 0x180 /* val 6, shift 6 */
+# define SC_szfailop_decr 0x1c0 /* val 7, shift 6 */
+# define SC_szpassop_MASK 0xfffff1ff /* bits 9-11 */
+# define SC_szpassop_keep 0x0 /* val 0, shift 9 */
+# define SC_szpassop_zero 0x200 /* val 1, shift 9 */
+# define SC_szpassop_replace 0x400 /* val 2, shift 9 */
+# define SC_szpassop_incrsat 0x600 /* val 3, shift 9 */
+# define SC_szpassop_decrsat 0x800 /* val 4, shift 9 */
+# define SC_szpassop_invert 0xa00 /* val 5, shift 9 */
+# define SC_szpassop_incr 0xc00 /* val 6, shift 9 */
+# define SC_szpassop_decr 0xe00 /* val 7, shift 9 */
+
+#define MGAREG_TDUALSTAGE0 0x2cf8
+
+# define TD0_color_arg2_MASK 0xfffffffc /* bits 0-1 */
+# define TD0_color_arg2_diffuse 0x0 /* val 0, shift 0 */
+# define TD0_color_arg2_specular 0x1 /* val 1, shift 0 */
+# define TD0_color_arg2_fcol 0x2 /* val 2, shift 0 */
+# define TD0_color_arg2_prevstage 0x3 /* val 3, shift 0 */
+# define TD0_color_alpha_MASK 0xffffffe3 /* bits 2-4 */
+# define TD0_color_alpha_diffuse 0x0 /* val 0, shift 2 */
+# define TD0_color_alpha_fcol 0x4 /* val 1, shift 2 */
+# define TD0_color_alpha_currtex 0x8 /* val 2, shift 2 */
+# define TD0_color_alpha_prevtex 0xc /* val 3, shift 2 */
+# define TD0_color_alpha_prevstage 0x10 /* val 4, shift 2 */
+# define TD0_color_arg1_replicatealpha_MASK 0xffffffdf /* bit 5 */
+# define TD0_color_arg1_replicatealpha_disable 0x0
+# define TD0_color_arg1_replicatealpha_enable 0x20
+# define TD0_color_arg1_inv_MASK 0xffffffbf /* bit 6 */
+# define TD0_color_arg1_inv_disable 0x0
+# define TD0_color_arg1_inv_enable 0x40
+# define TD0_color_arg2_replicatealpha_MASK 0xffffff7f /* bit 7 */
+# define TD0_color_arg2_replicatealpha_disable 0x0
+# define TD0_color_arg2_replicatealpha_enable 0x80
+# define TD0_color_arg2_inv_MASK 0xfffffeff /* bit 8 */
+# define TD0_color_arg2_inv_disable 0x0
+# define TD0_color_arg2_inv_enable 0x100
+# define TD0_color_alpha1inv_MASK 0xfffffdff /* bit 9 */
+# define TD0_color_alpha1inv_disable 0x0
+# define TD0_color_alpha1inv_enable 0x200
+# define TD0_color_alpha2inv_MASK 0xfffffbff /* bit 10 */
+# define TD0_color_alpha2inv_disable 0x0
+# define TD0_color_alpha2inv_enable 0x400
+# define TD0_color_arg1mul_MASK 0xfffff7ff /* bit 11 */
+# define TD0_color_arg1mul_disable 0x0 /* val 0, shift 11 */
+# define TD0_color_arg1mul_alpha1 0x800 /* val 1, shift 11 */
+# define TD0_color_arg2mul_MASK 0xffffefff /* bit 12 */
+# define TD0_color_arg2mul_disable 0x0 /* val 0, shift 12 */
+# define TD0_color_arg2mul_alpha2 0x1000 /* val 1, shift 12 */
+# define TD0_color_arg1add_MASK 0xffffdfff /* bit 13 */
+# define TD0_color_arg1add_disable 0x0 /* val 0, shift 13 */
+# define TD0_color_arg1add_mulout 0x2000 /* val 1, shift 13 */
+# define TD0_color_arg2add_MASK 0xffffbfff /* bit 14 */
+# define TD0_color_arg2add_disable 0x0 /* val 0, shift 14 */
+# define TD0_color_arg2add_mulout 0x4000 /* val 1, shift 14 */
+# define TD0_color_modbright_MASK 0xfffe7fff /* bits 15-16 */
+# define TD0_color_modbright_disable 0x0 /* val 0, shift 15 */
+# define TD0_color_modbright_2x 0x8000 /* val 1, shift 15 */
+# define TD0_color_modbright_4x 0x10000 /* val 2, shift 15 */
+# define TD0_color_add_MASK 0xfffdffff /* bit 17 */
+# define TD0_color_add_sub 0x0 /* val 0, shift 17 */
+# define TD0_color_add_add 0x20000 /* val 1, shift 17 */
+# define TD0_color_add2x_MASK 0xfffbffff /* bit 18 */
+# define TD0_color_add2x_disable 0x0
+# define TD0_color_add2x_enable 0x40000
+# define TD0_color_addbias_MASK 0xfff7ffff /* bit 19 */
+# define TD0_color_addbias_disable 0x0
+# define TD0_color_addbias_enable 0x80000
+# define TD0_color_blend_MASK 0xffefffff /* bit 20 */
+# define TD0_color_blend_disable 0x0
+# define TD0_color_blend_enable 0x100000
+# define TD0_color_sel_MASK 0xff9fffff /* bits 21-22 */
+# define TD0_color_sel_arg1 0x0 /* val 0, shift 21 */
+# define TD0_color_sel_arg2 0x200000 /* val 1, shift 21 */
+# define TD0_color_sel_add 0x400000 /* val 2, shift 21 */
+# define TD0_color_sel_mul 0x600000 /* val 3, shift 21 */
+# define TD0_alpha_arg1_inv_MASK 0xff7fffff /* bit 23 */
+# define TD0_alpha_arg1_inv_disable 0x0
+# define TD0_alpha_arg1_inv_enable 0x800000
+# define TD0_alpha_arg2_MASK 0xfcffffff /* bits 24-25 */
+# define TD0_alpha_arg2_diffuse 0x0 /* val 0, shift 24 */
+# define TD0_alpha_arg2_fcol 0x1000000 /* val 1, shift 24 */
+# define TD0_alpha_arg2_prevtex 0x2000000 /* val 2, shift 24 */
+# define TD0_alpha_arg2_prevstage 0x3000000 /* val 3, shift 24 */
+# define TD0_alpha_arg2_inv_MASK 0xfbffffff /* bit 26 */
+# define TD0_alpha_arg2_inv_disable 0x0
+# define TD0_alpha_arg2_inv_enable 0x4000000
+# define TD0_alpha_add_MASK 0xf7ffffff /* bit 27 */
+# define TD0_alpha_add_disable 0x0
+# define TD0_alpha_add_enable 0x8000000
+# define TD0_alpha_addbias_MASK 0xefffffff /* bit 28 */
+# define TD0_alpha_addbias_disable 0x0
+# define TD0_alpha_addbias_enable 0x10000000
+# define TD0_alpha_add2x_MASK 0xdfffffff /* bit 29 */
+# define TD0_alpha_add2x_disable 0x0
+# define TD0_alpha_add2x_enable 0x20000000
+# define TD0_alpha_modbright_MASK 0xcfffffff /* bits 28-29 */
+# define TD0_alpha_modbright_disable 0x0 /* val 0, shift 28 */
+# define TD0_alpha_modbright_2x 0x10000000 /* val 1, shift 28 */
+# define TD0_alpha_modbright_4x 0x20000000 /* val 2, shift 28 */
+# define TD0_alpha_sel_MASK 0x3fffffff /* bits 30-31 */
+# define TD0_alpha_sel_arg1 0x0 /* val 0, shift 30 */
+# define TD0_alpha_sel_arg2 0x40000000 /* val 1, shift 30 */
+# define TD0_alpha_sel_add 0x80000000 /* val 2, shift 30 */
+# define TD0_alpha_sel_mul 0xc0000000 /* val 3, shift 30 */
+
+#define MGAREG_TDUALSTAGE1 0x2cfc
+
+# define TD1_color_arg2_MASK 0xfffffffc /* bits 0-1 */
+# define TD1_color_arg2_diffuse 0x0 /* val 0, shift 0 */
+# define TD1_color_arg2_specular 0x1 /* val 1, shift 0 */
+# define TD1_color_arg2_fcol 0x2 /* val 2, shift 0 */
+# define TD1_color_arg2_prevstage 0x3 /* val 3, shift 0 */
+# define TD1_color_alpha_MASK 0xffffffe3 /* bits 2-4 */
+# define TD1_color_alpha_diffuse 0x0 /* val 0, shift 2 */
+# define TD1_color_alpha_fcol 0x4 /* val 1, shift 2 */
+# define TD1_color_alpha_tex0 0x8 /* val 2, shift 2 */
+# define TD1_color_alpha_prevtex 0xc /* val 3, shift 2 */
+# define TD1_color_alpha_prevstage 0x10 /* val 4, shift 2 */
+# define TD1_color_arg1_replicatealpha_MASK 0xffffffdf /* bit 5 */
+# define TD1_color_arg1_replicatealpha_disable 0x0
+# define TD1_color_arg1_replicatealpha_enable 0x20
+# define TD1_color_arg1_inv_MASK 0xffffffbf /* bit 6 */
+# define TD1_color_arg1_inv_disable 0x0
+# define TD1_color_arg1_inv_enable 0x40
+# define TD1_color_arg2_replicatealpha_MASK 0xffffff7f /* bit 7 */
+# define TD1_color_arg2_replicatealpha_disable 0x0
+# define TD1_color_arg2_replicatealpha_enable 0x80
+# define TD1_color_arg2_inv_MASK 0xfffffeff /* bit 8 */
+# define TD1_color_arg2_inv_disable 0x0
+# define TD1_color_arg2_inv_enable 0x100
+# define TD1_color_alpha1inv_MASK 0xfffffdff /* bit 9 */
+# define TD1_color_alpha1inv_disable 0x0
+# define TD1_color_alpha1inv_enable 0x200
+# define TD1_color_alpha2inv_MASK 0xfffffbff /* bit 10 */
+# define TD1_color_alpha2inv_disable 0x0
+# define TD1_color_alpha2inv_enable 0x400
+# define TD1_color_arg1mul_MASK 0xfffff7ff /* bit 11 */
+# define TD1_color_arg1mul_disable 0x0 /* val 0, shift 11 */
+# define TD1_color_arg1mul_alpha1 0x800 /* val 1, shift 11 */
+# define TD1_color_arg2mul_MASK 0xffffefff /* bit 12 */
+# define TD1_color_arg2mul_disable 0x0 /* val 0, shift 12 */
+# define TD1_color_arg2mul_alpha2 0x1000 /* val 1, shift 12 */
+# define TD1_color_arg1add_MASK 0xffffdfff /* bit 13 */
+# define TD1_color_arg1add_disable 0x0 /* val 0, shift 13 */
+# define TD1_color_arg1add_mulout 0x2000 /* val 1, shift 13 */
+# define TD1_color_arg2add_MASK 0xffffbfff /* bit 14 */
+# define TD1_color_arg2add_disable 0x0 /* val 0, shift 14 */
+# define TD1_color_arg2add_mulout 0x4000 /* val 1, shift 14 */
+# define TD1_color_modbright_MASK 0xfffe7fff /* bits 15-16 */
+# define TD1_color_modbright_disable 0x0 /* val 0, shift 15 */
+# define TD1_color_modbright_2x 0x8000 /* val 1, shift 15 */
+# define TD1_color_modbright_4x 0x10000 /* val 2, shift 15 */
+# define TD1_color_add_MASK 0xfffdffff /* bit 17 */
+# define TD1_color_add_sub 0x0 /* val 0, shift 17 */
+# define TD1_color_add_add 0x20000 /* val 1, shift 17 */
+# define TD1_color_add2x_MASK 0xfffbffff /* bit 18 */
+# define TD1_color_add2x_disable 0x0
+# define TD1_color_add2x_enable 0x40000
+# define TD1_color_addbias_MASK 0xfff7ffff /* bit 19 */
+# define TD1_color_addbias_disable 0x0
+# define TD1_color_addbias_enable 0x80000
+# define TD1_color_blend_MASK 0xffefffff /* bit 20 */
+# define TD1_color_blend_disable 0x0
+# define TD1_color_blend_enable 0x100000
+# define TD1_color_sel_MASK 0xff9fffff /* bits 21-22 */
+# define TD1_color_sel_arg1 0x0 /* val 0, shift 21 */
+# define TD1_color_sel_arg2 0x200000 /* val 1, shift 21 */
+# define TD1_color_sel_add 0x400000 /* val 2, shift 21 */
+# define TD1_color_sel_mul 0x600000 /* val 3, shift 21 */
+# define TD1_alpha_arg1_inv_MASK 0xff7fffff /* bit 23 */
+# define TD1_alpha_arg1_inv_disable 0x0
+# define TD1_alpha_arg1_inv_enable 0x800000
+# define TD1_alpha_arg2_MASK 0xfcffffff /* bits 24-25 */
+# define TD1_alpha_arg2_diffuse 0x0 /* val 0, shift 24 */
+# define TD1_alpha_arg2_fcol 0x1000000 /* val 1, shift 24 */
+# define TD1_alpha_arg2_prevtex 0x2000000 /* val 2, shift 24 */
+# define TD1_alpha_arg2_prevstage 0x3000000 /* val 3, shift 24 */
+# define TD1_alpha_arg2_inv_MASK 0xfbffffff /* bit 26 */
+# define TD1_alpha_arg2_inv_disable 0x0
+# define TD1_alpha_arg2_inv_enable 0x4000000
+# define TD1_alpha_add_MASK 0xf7ffffff /* bit 27 */
+# define TD1_alpha_add_disable 0x0
+# define TD1_alpha_add_enable 0x8000000
+# define TD1_alpha_addbias_MASK 0xefffffff /* bit 28 */
+# define TD1_alpha_addbias_disable 0x0
+# define TD1_alpha_addbias_enable 0x10000000
+# define TD1_alpha_add2x_MASK 0xdfffffff /* bit 29 */
+# define TD1_alpha_add2x_disable 0x0
+# define TD1_alpha_add2x_enable 0x20000000
+# define TD1_alpha_modbright_MASK 0xcfffffff /* bits 28-29 */
+# define TD1_alpha_modbright_disable 0x0 /* val 0, shift 28 */
+# define TD1_alpha_modbright_2x 0x10000000 /* val 1, shift 28 */
+# define TD1_alpha_modbright_4x 0x20000000 /* val 2, shift 28 */
+# define TD1_alpha_sel_MASK 0x3fffffff /* bits 30-31 */
+# define TD1_alpha_sel_arg1 0x0 /* val 0, shift 30 */
+# define TD1_alpha_sel_arg2 0x40000000 /* val 1, shift 30 */
+# define TD1_alpha_sel_add 0x80000000 /* val 2, shift 30 */
+# define TD1_alpha_sel_mul 0xc0000000 /* val 3, shift 30 */
+
+#define MGAREG_TEST0 0x1e48
+
+# define TST_ramtsten_MASK 0xfffffffe /* bit 0 */
+# define TST_ramtsten_disable 0x0
+# define TST_ramtsten_enable 0x1
+# define TST_ramtstdone_MASK 0xfffffffd /* bit 1 */
+# define TST_ramtstdone_disable 0x0
+# define TST_ramtstdone_enable 0x2
+# define TST_wramtstpass_MASK 0xfffffffb /* bit 2 */
+# define TST_wramtstpass_disable 0x0
+# define TST_wramtstpass_enable 0x4
+# define TST_tcachetstpass_MASK 0xfffffff7 /* bit 3 */
+# define TST_tcachetstpass_disable 0x0
+# define TST_tcachetstpass_enable 0x8
+# define TST_tluttstpass_MASK 0xffffffef /* bit 4 */
+# define TST_tluttstpass_disable 0x0
+# define TST_tluttstpass_enable 0x10
+# define TST_luttstpass_MASK 0xffffffdf /* bit 5 */
+# define TST_luttstpass_disable 0x0
+# define TST_luttstpass_enable 0x20
+# define TST_besramtstpass_MASK 0xffffffbf /* bit 6 */
+# define TST_besramtstpass_disable 0x0
+# define TST_besramtstpass_enable 0x40
+# define TST_ringen_MASK 0xfffffeff /* bit 8 */
+# define TST_ringen_disable 0x0
+# define TST_ringen_enable 0x100
+# define TST_apllbyp_MASK 0xfffffdff /* bit 9 */
+# define TST_apllbyp_disable 0x0
+# define TST_apllbyp_enable 0x200
+# define TST_hiten_MASK 0xfffffbff /* bit 10 */
+# define TST_hiten_disable 0x0
+# define TST_hiten_enable 0x400
+# define TST_tmode_MASK 0xffffc7ff /* bits 11-13 */
+# define TST_tmode_SHIFT 11
+# define TST_tclksel_MASK 0xfffe3fff /* bits 14-16 */
+# define TST_tclksel_SHIFT 14
+# define TST_ringcnten_MASK 0xfffdffff /* bit 17 */
+# define TST_ringcnten_disable 0x0
+# define TST_ringcnten_enable 0x20000
+# define TST_ringcnt_MASK 0xc003ffff /* bits 18-29 */
+# define TST_ringcnt_SHIFT 18
+# define TST_ringcntclksl_MASK 0xbfffffff /* bit 30 */
+# define TST_ringcntclksl_disable 0x0
+# define TST_ringcntclksl_enable 0x40000000
+# define TST_biosboot_MASK 0x7fffffff /* bit 31 */
+# define TST_biosboot_disable 0x0
+# define TST_biosboot_enable 0x80000000
+
+#define MGAREG_TEXBORDERCOL 0x2c5c
+#define MGAREG_TEXCTL 0x2c30
+
+# define TMC_tformat_MASK 0xfffffff0 /* bits 0-3 */
+# define TMC_tformat_tw4 0x0 /* val 0, shift 0 */
+# define TMC_tformat_tw8 0x1 /* val 1, shift 0 */
+# define TMC_tformat_tw15 0x2 /* val 2, shift 0 */
+# define TMC_tformat_tw16 0x3 /* val 3, shift 0 */
+# define TMC_tformat_tw12 0x4 /* val 4, shift 0 */
+# define TMC_tformat_tw32 0x6 /* val 6, shift 0 */
+# define TMC_tformat_tw8a 0x7 /* val 7, shift 0 */
+# define TMC_tformat_tw8al 0x8 /* val 8, shift 0 */
+# define TMC_tformat_tw422 0xa /* val 10, shift 0 */
+# define TMC_tformat_tw422uyvy 0xb /* val 11, shift 0 */
+# define TMC_tpitchlin_MASK 0xfffffeff /* bit 8 */
+# define TMC_tpitchlin_disable 0x0
+# define TMC_tpitchlin_enable 0x100
+# define TMC_tpitchext_MASK 0xfff001ff /* bits 9-19 */
+# define TMC_tpitchext_SHIFT 9
+# define TMC_tpitch_MASK 0xfff8ffff /* bits 16-18 */
+# define TMC_tpitch_SHIFT 16
+# define TMC_owalpha_MASK 0xffbfffff /* bit 22 */
+# define TMC_owalpha_disable 0x0
+# define TMC_owalpha_enable 0x400000
+# define TMC_azeroextend_MASK 0xff7fffff /* bit 23 */
+# define TMC_azeroextend_disable 0x0
+# define TMC_azeroextend_enable 0x800000
+# define TMC_decalckey_MASK 0xfeffffff /* bit 24 */
+# define TMC_decalckey_disable 0x0
+# define TMC_decalckey_enable 0x1000000
+# define TMC_takey_MASK 0xfdffffff /* bit 25 */
+# define TMC_takey_0 0x0
+# define TMC_takey_1 0x2000000
+# define TMC_tamask_MASK 0xfbffffff /* bit 26 */
+# define TMC_tamask_0 0x0
+# define TMC_tamask_1 0x4000000
+# define TMC_clampv_MASK 0xf7ffffff /* bit 27 */
+# define TMC_clampv_disable 0x0
+# define TMC_clampv_enable 0x8000000
+# define TMC_clampu_MASK 0xefffffff /* bit 28 */
+# define TMC_clampu_disable 0x0
+# define TMC_clampu_enable 0x10000000
+# define TMC_tmodulate_MASK 0xdfffffff /* bit 29 */
+# define TMC_tmodulate_disable 0x0
+# define TMC_tmodulate_enable 0x20000000
+# define TMC_strans_MASK 0xbfffffff /* bit 30 */
+# define TMC_strans_disable 0x0
+# define TMC_strans_enable 0x40000000
+# define TMC_itrans_MASK 0x7fffffff /* bit 31 */
+# define TMC_itrans_disable 0x0
+# define TMC_itrans_enable 0x80000000
+
+#define MGAREG_TEXCTL2 0x2c3c
+
+# define TMC_decalblend_MASK 0xfffffffe /* bit 0 */
+# define TMC_decalblend_disable 0x0
+# define TMC_decalblend_enable 0x1
+# define TMC_idecal_MASK 0xfffffffd /* bit 1 */
+# define TMC_idecal_disable 0x0
+# define TMC_idecal_enable 0x2
+# define TMC_decaldis_MASK 0xfffffffb /* bit 2 */
+# define TMC_decaldis_disable 0x0
+# define TMC_decaldis_enable 0x4
+# define TMC_ckstransdis_MASK 0xffffffef /* bit 4 */
+# define TMC_ckstransdis_disable 0x0
+# define TMC_ckstransdis_enable 0x10
+# define TMC_borderen_MASK 0xffffffdf /* bit 5 */
+# define TMC_borderen_disable 0x0
+# define TMC_borderen_enable 0x20
+# define TMC_specen_MASK 0xffffffbf /* bit 6 */
+# define TMC_specen_disable 0x0
+# define TMC_specen_enable 0x40
+# define TMC_dualtex_MASK 0xffffff7f /* bit 7 */
+# define TMC_dualtex_disable 0x0
+# define TMC_dualtex_enable 0x80
+# define TMC_tablefog_MASK 0xfffffeff /* bit 8 */
+# define TMC_tablefog_disable 0x0
+# define TMC_tablefog_enable 0x100
+# define TMC_bumpmap_MASK 0xfffffdff /* bit 9 */
+# define TMC_bumpmap_disable 0x0
+# define TMC_bumpmap_enable 0x200
+# define TMC_map1_MASK 0x7fffffff /* bit 31 */
+# define TMC_map1_disable 0x0
+# define TMC_map1_enable 0x80000000
+
+#define MGAREG_TEXFILTER 0x2c58
+
+# define TF_minfilter_MASK 0xfffffff0 /* bits 0-3 */
+# define TF_minfilter_nrst 0x0 /* val 0, shift 0 */
+# define TF_minfilter_bilin 0x2 /* val 2, shift 0 */
+# define TF_minfilter_cnst 0x3 /* val 3, shift 0 */
+# define TF_minfilter_mm1s 0x8 /* val 8, shift 0 */
+# define TF_minfilter_mm2s 0x9 /* val 9, shift 0 */
+# define TF_minfilter_mm4s 0xa /* val 10, shift 0 */
+# define TF_minfilter_mm8s 0xc /* val 12, shift 0 */
+# define TF_magfilter_MASK 0xffffff0f /* bits 4-7 */
+# define TF_magfilter_nrst 0x0 /* val 0, shift 4 */
+# define TF_magfilter_bilin 0x20 /* val 2, shift 4 */
+# define TF_magfilter_cnst 0x30 /* val 3, shift 4 */
+# define TF_uvoffset_SHIFT 17
+# define TF_uvoffset_OGL (0U << TF_uvoffset_SHIFT)
+# define TF_uvoffset_D3D (1U << TF_uvoffset_SHIFT)
+# define TF_uvoffset_MASK (~(1U << TF_uvoffset_SHIFT))
+# define TF_reserved_MASK (~0x1ff00) /* bits 8-16 */
+# define TF_mapnbhigh_SHIFT 18
+# define TF_mapnbhigh_MASK (~(1U << TF_mapnbhigh_SHIFT))
+# define TF_avgstride_MASK 0xfff7ffff /* bit 19 */
+# define TF_avgstride_disable 0x0
+# define TF_avgstride_enable 0x80000
+# define TF_filteralpha_MASK 0xffefffff /* bit 20 */
+# define TF_filteralpha_disable 0x0
+# define TF_filteralpha_enable 0x100000
+# define TF_fthres_MASK 0xe01fffff /* bits 21-28 */
+# define TF_fthres_SHIFT 21
+# define TF_mapnb_MASK 0x1fffffff /* bits 29-31 */
+# define TF_mapnb_SHIFT 29
+
+#define MGAREG_TEXHEIGHT 0x2c2c
+
+# define TH_th_MASK 0xffffffc0 /* bits 0-5 */
+# define TH_th_SHIFT 0
+# define TH_rfh_MASK 0xffff81ff /* bits 9-14 */
+# define TH_rfh_SHIFT 9
+# define TH_thmask_MASK 0xe003ffff /* bits 18-28 */
+# define TH_thmask_SHIFT 18
+
+#define MGAREG_TEXORG 0x2c24
+
+# define TO_texorgmap_MASK 0xfffffffe /* bit 0 */
+# define TO_texorgmap_fb 0x0
+# define TO_texorgmap_sys 0x1
+# define TO_texorgacc_MASK 0xfffffffd /* bit 1 */
+# define TO_texorgacc_pci 0x0
+# define TO_texorgacc_agp 0x2
+# define TO_texorgoffsetsel 0x4
+# define TO_texorg_MASK 0x1f /* bits 5-31 */
+# define TO_texorg_SHIFT 5
+
+#define MGAREG_TEXORG1 0x2ca4
+#define MGAREG_TEXORG2 0x2ca8
+#define MGAREG_TEXORG3 0x2cac
+#define MGAREG_TEXORG4 0x2cb0
+#define MGAREG_TEXTRANS 0x2c34
+
+# define TT_tckey_MASK 0xffff0000 /* bits 0-15 */
+# define TT_tckey_SHIFT 0
+# define TT_tkmask_MASK 0xffff /* bits 16-31 */
+# define TT_tkmask_SHIFT 16
+
+#define MGAREG_TEXTRANSHIGH 0x2c38
+
+# define TT_tckeyh_MASK 0xffff0000 /* bits 0-15 */
+# define TT_tckeyh_SHIFT 0
+# define TT_tkmaskh_MASK 0xffff /* bits 16-31 */
+# define TT_tkmaskh_SHIFT 16
+
+#define MGAREG_TEXWIDTH 0x2c28
+
+# define TW_tw_MASK 0xffffffc0 /* bits 0-5 */
+# define TW_tw_SHIFT 0
+# define TW_rfw_MASK 0xffff81ff /* bits 9-14 */
+# define TW_rfw_SHIFT 9
+# define TW_twmask_MASK 0xe003ffff /* bits 18-28 */
+# define TW_twmask_SHIFT 18
+
+#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 WAS_seqdst0_MASK 0xffffffc0 /* bits 0-5 */
+# define WAS_seqdst0_SHIFT 0
+# define WAS_seqdst1_MASK 0xfffff03f /* bits 6-11 */
+# define WAS_seqdst1_SHIFT 6
+# define WAS_seqdst2_MASK 0xfffc0fff /* bits 12-17 */
+# define WAS_seqdst2_SHIFT 12
+# define WAS_seqdst3_MASK 0xff03ffff /* bits 18-23 */
+# define WAS_seqdst3_SHIFT 18
+# define WAS_seqlen_MASK 0xfcffffff /* bits 24-25 */
+# define WAS_wfirsttag_MASK 0xfbffffff /* bit 26 */
+# define WAS_wfirsttag_disable 0x0
+# define WAS_wfirsttag_enable 0x4000000
+# define WAS_wsametag_MASK 0xf7ffffff /* bit 27 */
+# define WAS_wsametag_disable 0x0
+# define WAS_wsametag_enable 0x8000000
+# define WAS_seqoff_MASK 0xefffffff /* bit 28 */
+# define WAS_seqoff_disable 0x0
+# define WAS_seqoff_enable 0x10000000
+
+#define MGAREG_WCODEADDR 0x1e6c
+
+# define WMA_wcodeaddr_MASK 0xff /* bits 8-31 */
+# define WMA_wcodeaddr_SHIFT 8
+
+#define MGAREG_WFLAG 0x1dc4
+
+# define WF_walustsflag_MASK 0xffffff00 /* bits 0-7 */
+# define WF_walustsflag_SHIFT 0
+# define WF_walucfgflag_MASK 0xffff00ff /* bits 8-15 */
+# define WF_walucfgflag_SHIFT 8
+# define WF_wprgflag_MASK 0xffff /* bits 16-31 */
+# define WF_wprgflag_SHIFT 16
+
+#define MGAREG_WFLAG1 0x1de0
+
+# define WF1_walustsflag1_MASK 0xffffff00 /* bits 0-7 */
+# define WF1_walustsflag1_SHIFT 0
+# define WF1_walucfgflag1_MASK 0xffff00ff /* bits 8-15 */
+# define WF1_walucfgflag1_SHIFT 8
+# define WF1_wprgflag1_MASK 0xffff /* bits 16-31 */
+# define WF1_wprgflag1_SHIFT 16
+
+#define MGAREG_WFLAGNB 0x1e64
+#define MGAREG_WFLAGNB1 0x1e08
+#define MGAREG_WGETMSB 0x1dc8
+
+# define WGV_wgetmsbmin_MASK 0xffffffe0 /* bits 0-4 */
+# define WGV_wgetmsbmin_SHIFT 0
+# define WGV_wgetmsbmax_MASK 0xffffe0ff /* bits 8-12 */
+# define WGV_wgetmsbmax_SHIFT 8
+# define WGV_wbrklefttop_MASK 0xfffeffff /* bit 16 */
+# define WGV_wbrklefttop_disable 0x0
+# define WGV_wbrklefttop_enable 0x10000
+# define WGV_wfastcrop_MASK 0xfffdffff /* bit 17 */
+# define WGV_wfastcrop_disable 0x0
+# define WGV_wfastcrop_enable 0x20000
+# define WGV_wcentersnap_MASK 0xfffbffff /* bit 18 */
+# define WGV_wcentersnap_disable 0x0
+# define WGV_wcentersnap_enable 0x40000
+# define WGV_wbrkrighttop_MASK 0xfff7ffff /* bit 19 */
+# define WGV_wbrkrighttop_disable 0x0
+# define WGV_wbrkrighttop_enable 0x80000
+
+#define MGAREG_WIADDR 0x1dc0
+
+# define WIA_wmode_MASK 0xfffffffc /* bits 0-1 */
+# define WIA_wmode_suspend 0x0 /* val 0, shift 0 */
+# define WIA_wmode_resume 0x1 /* val 1, shift 0 */
+# define WIA_wmode_jump 0x2 /* val 2, shift 0 */
+# define WIA_wmode_start 0x3 /* val 3, shift 0 */
+# define WIA_wagp_MASK 0xfffffffb /* bit 2 */
+# define WIA_wagp_pci 0x0
+# define WIA_wagp_agp 0x4
+# define WIA_wiaddr_MASK 0x7 /* bits 3-31 */
+# define WIA_wiaddr_SHIFT 3
+
+#define MGAREG_WIADDR2 0x1dd8
+
+# define WIA2_wmode_MASK 0xfffffffc /* bits 0-1 */
+# define WIA2_wmode_suspend 0x0 /* val 0, shift 0 */
+# define WIA2_wmode_resume 0x1 /* val 1, shift 0 */
+# define WIA2_wmode_jump 0x2 /* val 2, shift 0 */
+# define WIA2_wmode_start 0x3 /* val 3, shift 0 */
+# define WIA2_wagp_MASK 0xfffffffb /* bit 2 */
+# define WIA2_wagp_pci 0x0
+# define WIA2_wagp_agp 0x4
+# define WIA2_wiaddr_MASK 0x7 /* bits 3-31 */
+# define WIA2_wiaddr_SHIFT 3
+
+#define MGAREG_WIADDRNB 0x1e60
+#define MGAREG_WIADDRNB1 0x1e04
+#define MGAREG_WIADDRNB2 0x1e00
+#define MGAREG_WIMEMADDR 0x1e68
+
+# define WIMA_wimemaddr_MASK 0xffffff00 /* bits 0-7 */
+# define WIMA_wimemaddr_SHIFT 0
+
+#define MGAREG_WIMEMDATA 0x2000
+#define MGAREG_WIMEMDATA1 0x2100
+#define MGAREG_WMISC 0x1e70
+
+# define WM_wucodecache_MASK 0xfffffffe /* bit 0 */
+# define WM_wucodecache_disable 0x0
+# define WM_wucodecache_enable 0x1
+# define WM_wmaster_MASK 0xfffffffd /* bit 1 */
+# define WM_wmaster_disable 0x0
+# define WM_wmaster_enable 0x2
+# define WM_wcacheflush_MASK 0xfffffff7 /* bit 3 */
+# define WM_wcacheflush_disable 0x0
+# define WM_wcacheflush_enable 0x8
+
+#define MGAREG_WR 0x2d00
+#define MGAREG_WVRTXSZ 0x1dcc
+
+# define WVS_wvrtxsz_MASK 0xffffffc0 /* bits 0-5 */
+# define WVS_wvrtxsz_SHIFT 0
+# define WVS_primsz_MASK 0xffffc0ff /* bits 8-13 */
+# define WVS_primsz_SHIFT 8
+
+#define MGAREG_XDST 0x1cb0
+#define MGAREG_XYEND 0x1c44
+
+# define XYEA_x_end_MASK 0xffff0000 /* bits 0-15 */
+# define XYEA_x_end_SHIFT 0
+# define XYEA_y_end_MASK 0xffff /* bits 16-31 */
+# define XYEA_y_end_SHIFT 16
+
+#define MGAREG_XYSTRT 0x1c40
+
+# define XYSA_x_start_MASK 0xffff0000 /* bits 0-15 */
+# define XYSA_x_start_SHIFT 0
+# define XYSA_y_start_MASK 0xffff /* bits 16-31 */
+# define XYSA_y_start_SHIFT 16
+
+#define MGAREG_YBOT 0x1c9c
+#define MGAREG_YDST 0x1c90
+
+# define YA_ydst_MASK 0xff800000 /* bits 0-22 */
+# define YA_ydst_SHIFT 0
+# define YA_sellin_MASK 0x1fffffff /* bits 29-31 */
+# define YA_sellin_SHIFT 29
+
+#define MGAREG_YDSTLEN 0x1c88
+
+# define YDL_length_MASK 0xffff0000 /* bits 0-15 */
+# define YDL_length_SHIFT 0
+# define YDL_yval_MASK 0xffff /* bits 16-31 */
+# define YDL_yval_SHIFT 16
+
+#define MGAREG_YDSTORG 0x1c94
+#define MGAREG_YTOP 0x1c98
+#define MGAREG_ZORG 0x1c0c
+
+# define ZO_zorgmap_MASK 0xfffffffe /* bit 0 */
+# define ZO_zorgmap_fb 0x0
+# define ZO_zorgmap_sys 0x1
+# define ZO_zorgacc_MASK 0xfffffffd /* bit 1 */
+# define ZO_zorgacc_pci 0x0
+# define ZO_zorgacc_agp 0x2
+# define ZO_zorg_MASK 0x3 /* bits 2-31 */
+# define ZO_zorg_SHIFT 2
+
+
+
+
+/**************** (END) AUTOMATICLY GENERATED REGISTER FILE ******************/
+
+/* Copied from mga_drv.h kernel file.
+ */
+
+#define MGA_ILOAD_ALIGN 64
+#define MGA_ILOAD_MASK (MGA_ILOAD_ALIGN - 1)
+
+#endif /* _MGAREGS_H_ */
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgarender.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgarender.c
new file mode 100644
index 000000000..3080cea79
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgarender.c
@@ -0,0 +1,172 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgarender.c,v 1.4 2002/10/30 12:51:36 alanh Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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
+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, VA LINUX SYSTEMS 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ *
+ */
+
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * dma buffers. Use strip/fan hardware primitives where possible.
+ * Simulate missing primitives with indexed vertices.
+ */
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+
+#include "tnl/t_context.h"
+
+#include "mgacontext.h"
+#include "mgatris.h"
+#include "mgastate.h"
+#include "mgaioctl.h"
+#include "mgavb.h"
+
+#define HAVE_POINTS 0
+#define HAVE_LINES 0
+#define HAVE_LINE_STRIPS 0
+#define HAVE_TRIANGLES 1
+#define HAVE_TRI_STRIPS 1
+#define HAVE_TRI_STRIP_1 0
+#define HAVE_TRI_FANS 1
+#define HAVE_POLYGONS 0
+#define HAVE_QUADS 0
+#define HAVE_QUAD_STRIPS 0
+
+#define HAVE_ELTS 0 /* for now */
+
+static void mgaDmaPrimitive( GLcontext *ctx, GLenum prim )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLuint hwprim;
+
+ switch (prim) {
+ case GL_TRIANGLES:
+ hwprim = MGA_WA_TRIANGLES;
+ break;
+ case GL_TRIANGLE_STRIP:
+ if (mmesa->vertex_size == 8)
+ hwprim = MGA_WA_TRISTRIP_T0;
+ else
+ hwprim = MGA_WA_TRISTRIP_T0T1;
+ break;
+ case GL_TRIANGLE_FAN:
+ if (mmesa->vertex_size == 8)
+ hwprim = MGA_WA_TRIFAN_T0;
+ else
+ hwprim = MGA_WA_TRIFAN_T0T1;
+ break;
+ default:
+ return;
+ }
+
+ mgaRasterPrimitive( ctx, GL_TRIANGLES, hwprim );
+}
+
+
+#define LOCAL_VARS mgaContextPtr mmesa = MGA_CONTEXT(ctx)
+#define INIT( prim ) do { \
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__); \
+ FLUSH_BATCH(mmesa); \
+ mgaDmaPrimitive( ctx, prim ); \
+} while (0)
+#define FLUSH() FLUSH_BATCH( mmesa )
+#define GET_CURRENT_VB_MAX_VERTS() \
+ 0 /* fix me */
+#define GET_SUBSEQUENT_VB_MAX_VERTS() \
+ MGA_BUFFER_SIZE / (mmesa->vertex_size * 4)
+
+
+#define ALLOC_VERTS( nr ) \
+ mgaAllocDmaLow( mmesa, (nr) * mmesa->vertex_size * 4)
+#define EMIT_VERTS( ctx, j, nr, buf ) \
+ mga_emit_contiguous_verts(ctx, j, (j)+(nr), buf)
+
+
+#define TAG(x) mga_##x
+#include "tnl_dd/t_dd_dmatmp.h"
+
+
+
+/**********************************************************************/
+/* Render pipeline stage */
+/**********************************************************************/
+
+
+static GLboolean mga_run_render( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i;
+
+ /* Don't handle clipping or indexed vertices or vertex manipulations.
+ */
+ if (mmesa->RenderIndex != 0 ||
+ !mga_validate_render( ctx, VB )) {
+ return GL_TRUE;
+ }
+
+ tnl->Driver.Render.Start( ctx );
+ mmesa->SetupNewInputs = ~0;
+
+ for (i = 0 ; i < VB->PrimitiveCount ; i++)
+ {
+ GLuint prim = VB->Primitive[i].mode;
+ GLuint start = VB->Primitive[i].start;
+ GLuint length = VB->Primitive[i].count;
+
+ if (!length)
+ continue;
+
+ mga_render_tab_verts[prim & PRIM_MODE_MASK]( ctx, start, start + length,
+ prim);
+ }
+
+ tnl->Driver.Render.Finish( ctx );
+
+ return GL_FALSE; /* finished the pipe */
+}
+
+
+const struct tnl_pipeline_stage _mga_render_stage =
+{
+ "mga render",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ mga_run_render /* run */
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaspan.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaspan.c
new file mode 100644
index 000000000..c62b1c875
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaspan.c
@@ -0,0 +1,312 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaspan.c,v 1.11 2002/10/30 12:51:36 alanh Exp $ */
+
+#include "mtypes.h"
+#include "mgadd.h"
+#include "mgacontext.h"
+#include "mgaspan.h"
+#include "mgaioctl.h"
+#include "swrast/swrast.h"
+
+#define DBG 0
+
+#define LOCAL_VARS \
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = mmesa->mesa_drawable; \
+ mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \
+ __DRIscreenPrivate *sPriv = mmesa->driScreen; \
+ GLuint pitch = mgaScreen->frontPitch; \
+ GLuint height = dPriv->h; \
+ char *read_buf = (char *)(sPriv->pFB + \
+ mmesa->readOffset + \
+ dPriv->x * mgaScreen->cpp + \
+ dPriv->y * pitch); \
+ char *buf = (char *)(sPriv->pFB + \
+ mmesa->drawOffset + \
+ dPriv->x * mgaScreen->cpp + \
+ dPriv->y * pitch); \
+ GLuint p; \
+ (void) read_buf; (void) buf; (void) p
+
+
+
+#define LOCAL_DEPTH_VARS \
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = mmesa->mesa_drawable; \
+ 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 * mgaScreen->cpp + \
+ dPriv->y * pitch)
+
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
+
+#define HW_LOCK()
+
+/* FIXME could/should we use dPriv->numClipRects like the other drivers? */
+#define HW_CLIPLOOP() \
+ do { \
+ int _nc = mmesa->numClipRects; \
+ 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 maxy = mmesa->pClipRects[_nc].y2 - mmesa->drawY;
+
+#define HW_ENDCLIPLOOP() \
+ } \
+ } while (0)
+
+#define HW_UNLOCK()
+
+
+
+#define Y_FLIP(_y) (height - _y - 1)
+
+/* 16 bit, RGB565 color spanline and pixel functions
+ */
+#define SPANTMP_PIXEL_FMT GL_RGB
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
+
+#define TAG(x) mga##x##_565
+#define TAG2(x,y) mga##x##_565##y
+#include "spantmp2.h"
+
+/* 32 bit, ARGB8888 color spanline and pixel functions
+ */
+#define SPANTMP_PIXEL_FMT GL_BGRA
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
+
+#define TAG(x) mga##x##_8888
+#define TAG2(x,y) mga##x##_8888##y
+#include "spantmp2.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) mga##x##_16
+#include "depthtmp.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) mga##x##_32
+#include "depthtmp.h"
+
+
+
+/* 24/8 bit interleaved depth/stencil functions
+ */
+#define WRITE_DEPTH( _x, _y, d ) { \
+ GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*pitch); \
+ tmp &= 0xff; \
+ tmp |= (d) << 8; \
+ *(GLuint *)(buf + (_x)*4 + (_y)*pitch) = tmp; \
+}
+
+#define READ_DEPTH( d, _x, _y ) { \
+ d = (*(GLuint *)(buf + (_x)*4 + (_y)*pitch) & ~0xff) >> 8; \
+}
+
+#define TAG(x) mga##x##_24_8
+#include "depthtmp.h"
+
+#define WRITE_STENCIL( _x, _y, d ) { \
+ GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \
+ tmp &= 0xffffff00; \
+ tmp |= d & 0xff; \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \
+}
+
+#define READ_STENCIL( d, _x, _y ) \
+ d = *(GLuint *)(buf + _x*4 + _y*pitch) & 0xff;
+
+#define TAG(x) mga##x##_24_8
+#include "stenciltmp.h"
+
+
+
+/*
+ * This function is called to specify which buffer to read and write
+ * for software rasterization (swrast) fallbacks. This doesn't necessarily
+ * correspond to glDrawBuffer() or glReadBuffer() calls.
+ */
+static void mgaDDSetBuffer(GLcontext *ctx, GLframebuffer *buffer,
+ GLuint bufferBit)
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ unsigned int offset;
+
+ assert((bufferBit == BUFFER_BIT_FRONT_LEFT) || (bufferBit == BUFFER_BIT_BACK_LEFT));
+
+ offset = (bufferBit == BUFFER_BIT_FRONT_LEFT)
+ ? mmesa->mgaScreen->frontOffset
+ : mmesa->mgaScreen->backOffset;
+
+ mmesa->drawOffset = offset;
+ mmesa->readOffset = offset;
+
+ assert( (buffer == mmesa->driDrawable->driverPrivate)
+ || (buffer == mmesa->driReadable->driverPrivate) );
+
+ mmesa->mesa_drawable = (buffer == mmesa->driDrawable->driverPrivate)
+ ? mmesa->driDrawable : mmesa->driReadable;
+}
+
+void mgaSpanRenderStart( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ FLUSH_BATCH( mmesa );
+ LOCK_HARDWARE_QUIESCENT( mmesa );
+}
+
+void mgaSpanRenderFinish( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ _swrast_flush( ctx );
+ UNLOCK_HARDWARE( mmesa );
+}
+
+/**
+ * Initialize the driver callbacks for the read / write span functions.
+ *
+ * \bug
+ * To really support RGB888 and RGBA8888 visuals, we need separate read and
+ * write routines for 888 and 8888. We also need to determine whether or not
+ * the visual has destination alpha.
+ */
+void mgaDDInitSpanFuncs( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetBuffer = mgaDDSetBuffer;
+
+ switch (mmesa->mgaScreen->cpp) {
+ case 2:
+#if 0
+ mgaInitPointers_565( swdd );
+ swdd->ReadDepthSpan = mgaReadDepthSpan_16;
+ swdd->WriteDepthSpan = mgaWriteDepthSpan_16;
+ swdd->ReadDepthPixels = mgaReadDepthPixels_16;
+ swdd->WriteDepthPixels = mgaWriteDepthPixels_16;
+#endif
+ break;
+
+ case 4:
+#if 0
+ mgaInitPointers_8888( swdd );
+
+ if (!mmesa->hw_stencil) {
+ swdd->ReadDepthSpan = mgaReadDepthSpan_32;
+ swdd->WriteDepthSpan = mgaWriteDepthSpan_32;
+ swdd->ReadDepthPixels = mgaReadDepthPixels_32;
+ swdd->WriteDepthPixels = mgaWriteDepthPixels_32;
+ } else {
+ swdd->ReadDepthSpan = mgaReadDepthSpan_24_8;
+ swdd->WriteDepthSpan = mgaWriteDepthSpan_24_8;
+ swdd->ReadDepthPixels = mgaReadDepthPixels_24_8;
+ swdd->WriteDepthPixels = mgaWriteDepthPixels_24_8;
+
+ swdd->ReadStencilSpan = mgaReadStencilSpan_24_8;
+ swdd->WriteStencilSpan = mgaWriteStencilSpan_24_8;
+ swdd->ReadStencilPixels = mgaReadStencilPixels_24_8;
+ swdd->WriteStencilPixels = mgaWriteStencilPixels_24_8;
+ }
+#endif
+ break;
+ }
+ swdd->SpanRenderStart = mgaSpanRenderStart;
+ swdd->SpanRenderFinish = mgaSpanRenderFinish;
+}
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+mgaSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ mgaInitPointers_565(&drb->Base);
+ }
+ else {
+ mgaInitPointers_8888(&drb->Base);
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = mgaReadDepthSpan_16;
+ drb->Base.GetValues = mgaReadDepthPixels_16;
+ drb->Base.PutRow = mgaWriteDepthSpan_16;
+ drb->Base.PutMonoRow = mgaWriteMonoDepthSpan_16;
+ drb->Base.PutValues = mgaWriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = mgaReadDepthSpan_24_8;
+ drb->Base.GetValues = mgaReadDepthPixels_24_8;
+ drb->Base.PutRow = mgaWriteDepthSpan_24_8;
+ drb->Base.PutMonoRow = mgaWriteMonoDepthSpan_24_8;
+ drb->Base.PutValues = mgaWriteDepthPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
+ drb->Base.GetRow = mgaReadDepthSpan_32;
+ drb->Base.GetValues = mgaReadDepthPixels_32;
+ drb->Base.PutRow = mgaWriteDepthSpan_32;
+ drb->Base.PutMonoRow = mgaWriteMonoDepthSpan_32;
+ drb->Base.PutValues = mgaWriteDepthPixels_32;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = mgaReadStencilSpan_24_8;
+ drb->Base.GetValues = mgaReadStencilPixels_24_8;
+ drb->Base.PutRow = mgaWriteStencilSpan_24_8;
+ drb->Base.PutMonoRow = mgaWriteMonoStencilSpan_24_8;
+ drb->Base.PutValues = mgaWriteStencilPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaspan.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaspan.h
new file mode 100644
index 000000000..f133a51c0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgaspan.h
@@ -0,0 +1,40 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaspan.h,v 1.3 2002/10/30 12:51:36 alanh Exp $ */
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef _MGA_SPAN_H
+#define _MGA_SPAN_H
+
+#include "drirenderbuffer.h"
+
+extern void mgaDDInitSpanFuncs( GLcontext *ctx );
+
+extern void
+mgaSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgastate.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgastate.c
new file mode 100644
index 000000000..72d5c9fb0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgastate.c
@@ -0,0 +1,1237 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgastate.c,v 1.13 2002/10/30 12:51:36 alanh Exp $ */
+
+
+#include "mtypes.h"
+#include "buffers.h"
+#include "colormac.h"
+#include "dd.h"
+
+#include "mm.h"
+#include "mgacontext.h"
+#include "mgadd.h"
+#include "mgastate.h"
+#include "mgatex.h"
+#include "mgavb.h"
+#include "mgatris.h"
+#include "mgaioctl.h"
+#include "mgaregs.h"
+
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "xmlpool.h"
+
+static void updateSpecularLighting( GLcontext *ctx );
+
+static const GLuint mgarop_NoBLK[16] = {
+ DC_atype_rpl | 0x00000000, DC_atype_rstr | 0x00080000,
+ DC_atype_rstr | 0x00040000, DC_atype_rpl | 0x000c0000,
+ DC_atype_rstr | 0x00020000, DC_atype_rstr | 0x000a0000,
+ DC_atype_rstr | 0x00060000, DC_atype_rstr | 0x000e0000,
+ DC_atype_rstr | 0x00010000, DC_atype_rstr | 0x00090000,
+ DC_atype_rstr | 0x00050000, DC_atype_rstr | 0x000d0000,
+ DC_atype_rpl | 0x00030000, DC_atype_rstr | 0x000b0000,
+ DC_atype_rstr | 0x00070000, DC_atype_rpl | 0x000f0000
+};
+
+/* =============================================================
+ * Alpha blending
+ */
+
+static void mgaDDAlphaFunc(GLcontext *ctx, GLenum func, GLfloat ref)
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLubyte refByte;
+ GLuint a;
+
+ CLAMPED_FLOAT_TO_UBYTE(refByte, ref);
+
+ switch ( func ) {
+ case GL_NEVER:
+ a = AC_atmode_alt;
+ refByte = 0;
+ break;
+ case GL_LESS:
+ a = AC_atmode_alt;
+ break;
+ case GL_GEQUAL:
+ a = AC_atmode_agte;
+ break;
+ case GL_LEQUAL:
+ a = AC_atmode_alte;
+ break;
+ case GL_GREATER:
+ a = AC_atmode_agt;
+ break;
+ case GL_NOTEQUAL:
+ a = AC_atmode_ane;
+ break;
+ case GL_EQUAL:
+ a = AC_atmode_ae;
+ break;
+ case GL_ALWAYS:
+ a = AC_atmode_noacmp;
+ break;
+ default:
+ a = 0;
+ break;
+ }
+
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ mmesa->hw.alpha_func = a | MGA_FIELD( AC_atref, refByte );
+}
+
+static void updateBlendLogicOp(GLcontext *ctx)
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+
+ mmesa->hw.blend_func_enable =
+ (ctx->Color.BlendEnabled && !ctx->Color._LogicOpEnabled) ? ~0 : 0;
+
+ FALLBACK( ctx, MGA_FALLBACK_BLEND,
+ ctx->Color.BlendEnabled && !ctx->Color._LogicOpEnabled &&
+ mmesa->hw.blend_func == (AC_src_src_alpha_sat | AC_dst_zero) );
+}
+
+static void mgaDDBlendEquationSeparate(GLcontext *ctx,
+ GLenum modeRGB, GLenum modeA)
+{
+ assert( modeRGB == modeA );
+ updateBlendLogicOp( ctx );
+}
+
+static void mgaDDBlendFuncSeparate( GLcontext *ctx, GLenum sfactorRGB,
+ GLenum dfactorRGB, GLenum sfactorA,
+ GLenum dfactorA )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLuint src;
+ GLuint dst;
+
+ switch (ctx->Color.BlendSrcRGB) {
+ case GL_ZERO:
+ src = AC_src_zero; break;
+ case GL_SRC_ALPHA:
+ src = AC_src_src_alpha; break;
+ case GL_ONE:
+ default: /* never happens */
+ src = AC_src_one; break;
+ case GL_DST_COLOR:
+ src = AC_src_dst_color; break;
+ case GL_ONE_MINUS_DST_COLOR:
+ src = AC_src_om_dst_color; break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ src = AC_src_om_src_alpha; break;
+ case GL_DST_ALPHA:
+ src = (ctx->Visual.alphaBits > 0)
+ ? AC_src_dst_alpha : AC_src_one;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ src = (ctx->Visual.alphaBits > 0)
+ ? AC_src_om_dst_alpha : AC_src_zero;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ src = (ctx->Visual.alphaBits > 0)
+ ? AC_src_src_alpha_sat : AC_src_zero;
+ break;
+ }
+
+ switch (ctx->Color.BlendDstRGB) {
+ case GL_SRC_ALPHA:
+ dst = AC_dst_src_alpha; break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ dst = AC_dst_om_src_alpha; break;
+ default: /* never happens */
+ case GL_ZERO:
+ dst = AC_dst_zero; break;
+ case GL_ONE:
+ dst = AC_dst_one; break;
+ case GL_SRC_COLOR:
+ dst = AC_dst_src_color; break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ dst = AC_dst_om_src_color; break;
+ case GL_DST_ALPHA:
+ dst = (ctx->Visual.alphaBits > 0)
+ ? AC_dst_dst_alpha : AC_dst_one;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ dst = (ctx->Visual.alphaBits > 0)
+ ? AC_dst_om_dst_alpha : AC_dst_zero;
+ break;
+ }
+
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ mmesa->hw.blend_func = (src | dst);
+
+ FALLBACK( ctx, MGA_FALLBACK_BLEND,
+ ctx->Color.BlendEnabled && !ctx->Color._LogicOpEnabled &&
+ mmesa->hw.blend_func == (AC_src_src_alpha_sat | AC_dst_zero) );
+}
+
+/* =============================================================
+ * Depth testing
+ */
+
+static void mgaDDDepthFunc(GLcontext *ctx, GLenum func)
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ int zmode;
+
+ switch (func) {
+ case GL_NEVER:
+ /* can't do this in h/w, we'll use a s/w fallback */
+ FALLBACK (ctx, MGA_FALLBACK_DEPTH, ctx->Depth.Test);
+
+ /* FALLTHROUGH */
+ case GL_ALWAYS:
+ zmode = DC_zmode_nozcmp; break;
+ case GL_LESS:
+ zmode = DC_zmode_zlt; break;
+ case GL_LEQUAL:
+ zmode = DC_zmode_zlte; break;
+ case GL_EQUAL:
+ zmode = DC_zmode_ze; break;
+ case GL_GREATER:
+ zmode = DC_zmode_zgt; break;
+ case GL_GEQUAL:
+ zmode = DC_zmode_zgte; break;
+ case GL_NOTEQUAL:
+ zmode = DC_zmode_zne; break;
+ default:
+ zmode = 0; break;
+ }
+
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ mmesa->hw.zmode &= DC_zmode_MASK;
+ mmesa->hw.zmode |= zmode;
+}
+
+static void mgaDDDepthMask(GLcontext *ctx, GLboolean flag)
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+
+
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ mmesa->hw.zmode &= DC_atype_MASK;
+ mmesa->hw.zmode |= (flag) ? DC_atype_zi : DC_atype_i;
+}
+
+
+static void mgaDDClearDepth(GLcontext *ctx, GLclampd d)
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ /* Select the Z depth. The ~ is used because the _MASK values in the
+ * MGA driver are used to mask OFF the selected bits. In this case,
+ * we want to mask off everything except the MA_zwidth bits.
+ */
+ switch (mmesa->setup.maccess & ~MA_zwidth_MASK) {
+ case MA_zwidth_16: mmesa->ClearDepth = d * 0x0000ffff; break;
+ case MA_zwidth_24: mmesa->ClearDepth = d * 0xffffff00; break;
+ case MA_zwidth_32: mmesa->ClearDepth = d * 0xffffffff; break;
+ default: return;
+ }
+}
+
+
+/* =============================================================
+ * Fog
+ */
+
+
+static void mgaDDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ if (pname == GL_FOG_COLOR) {
+ GLuint color = PACK_COLOR_888((GLubyte)(ctx->Fog.Color[0]*255.0F),
+ (GLubyte)(ctx->Fog.Color[1]*255.0F),
+ (GLubyte)(ctx->Fog.Color[2]*255.0F));
+
+ MGA_STATECHANGE(mmesa, MGA_UPLOAD_CONTEXT);
+ mmesa->setup.fogcolor = color;
+ }
+}
+
+
+/* =============================================================
+ * Scissoring
+ */
+
+
+void mgaUpdateClipping(const GLcontext *ctx)
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ if (mmesa->driDrawable)
+ {
+ int x1 = mmesa->driDrawable->x + ctx->Scissor.X;
+ int y1 = mmesa->driDrawable->y + mmesa->driDrawable->h
+ - (ctx->Scissor.Y + ctx->Scissor.Height);
+ int x2 = x1 + ctx->Scissor.Width;
+ int y2 = y1 + ctx->Scissor.Height;
+
+ if (x1 < 0) x1 = 0;
+ if (y1 < 0) y1 = 0;
+ if (x2 < 0) x2 = 0;
+ if (y2 < 0) y2 = 0;
+
+ mmesa->scissor_rect.x1 = x1;
+ mmesa->scissor_rect.y1 = y1;
+ mmesa->scissor_rect.x2 = x2;
+ mmesa->scissor_rect.y2 = y2;
+
+ mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
+ }
+}
+
+
+static void mgaDDScissor( GLcontext *ctx, GLint x, GLint y,
+ GLsizei w, GLsizei h )
+{
+ if ( ctx->Scissor.Enabled ) {
+ FLUSH_BATCH( MGA_CONTEXT(ctx) ); /* don't pipeline cliprect changes */
+ mgaUpdateClipping( ctx );
+ }
+}
+
+
+/* =============================================================
+ * Culling
+ */
+
+
+#define _CULL_DISABLE 0
+#define _CULL_NEGATIVE ((1<<11)|(1<<5)|(1<<16))
+#define _CULL_POSITIVE (1<<11)
+
+static void mgaDDCullFaceFrontFace(GLcontext *ctx, GLenum unused)
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ if (ctx->Polygon.CullFlag &&
+ ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK)
+ {
+ mmesa->hw.cull = _CULL_NEGATIVE;
+
+ if (ctx->Polygon.CullFaceMode == GL_FRONT)
+ mmesa->hw.cull ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE);
+
+ if (ctx->Polygon.FrontFace != GL_CCW)
+ mmesa->hw.cull ^= (_CULL_POSITIVE ^ _CULL_NEGATIVE);
+
+ mmesa->hw.cull_dualtex = mmesa->hw.cull ^
+ (_CULL_POSITIVE ^ _CULL_NEGATIVE); /* warp bug? */
+ }
+ else {
+ mmesa->hw.cull = _CULL_DISABLE;
+ mmesa->hw.cull_dualtex = _CULL_DISABLE;
+ }
+}
+
+
+/* =============================================================
+ * Masks
+ */
+
+static void mgaDDColorMask(GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ mgaScreenPrivate *mgaScreen = mmesa->mgaScreen;
+
+
+ GLuint mask = mgaPackColor(mgaScreen->cpp,
+ ctx->Color.ColorMask[RCOMP],
+ ctx->Color.ColorMask[GCOMP],
+ ctx->Color.ColorMask[BCOMP],
+ ctx->Color.ColorMask[ACOMP]);
+
+ if (mgaScreen->cpp == 2)
+ mask = mask | (mask << 16);
+
+ if (mmesa->setup.plnwt != mask) {
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ mmesa->setup.plnwt = mask;
+ }
+}
+
+
+/* =============================================================
+ * Polygon state
+ */
+
+static int mgaStipples[16] = {
+ 0xffff,
+ 0xa5a5,
+ 0x5a5a,
+ 0xa0a0,
+ 0x5050,
+ 0x0a0a,
+ 0x0505,
+ 0x8020,
+ 0x0401,
+ 0x1040,
+ 0x0208,
+ 0x0802,
+ 0x4010,
+ 0x0104,
+ 0x2080,
+ 0x0000
+};
+
+/**
+ * The MGA supports a subset of possible 4x4 stipples natively, GL
+ * wants 32x32. Fortunately stipple is usually a repeating pattern.
+ *
+ * \param ctx GL rendering context to be affected
+ * \param mask Pointer to the 32x32 stipple mask
+ */
+
+static void mgaDDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ const GLubyte *m = mask;
+ GLubyte p[4];
+ int i,j,k;
+ int active = (ctx->Polygon.StippleFlag &&
+ mmesa->raster_primitive == GL_TRIANGLES);
+ GLuint stipple;
+
+ FLUSH_BATCH(mmesa);
+ mmesa->haveHwStipple = 0;
+
+ if (active) {
+ mmesa->dirty |= MGA_UPLOAD_CONTEXT;
+ mmesa->setup.dwgctl &= ~(0xf<<20);
+ }
+
+ p[0] = mask[0] & 0xf; p[0] |= p[0] << 4;
+ p[1] = mask[4] & 0xf; p[1] |= p[1] << 4;
+ p[2] = mask[8] & 0xf; p[2] |= p[2] << 4;
+ p[3] = mask[12] & 0xf; p[3] |= p[3] << 4;
+
+ for (k = 0 ; k < 8 ; k++)
+ for (j = 0 ; j < 4; j++)
+ for (i = 0 ; i < 4 ; i++)
+ if (*m++ != p[j]) {
+ return;
+ }
+
+ stipple = ( ((p[0] & 0xf) << 0) |
+ ((p[1] & 0xf) << 4) |
+ ((p[2] & 0xf) << 8) |
+ ((p[3] & 0xf) << 12) );
+
+ for (i = 0 ; i < 16 ; i++)
+ if (mgaStipples[i] == stipple) {
+ mmesa->poly_stipple = i<<20;
+ mmesa->haveHwStipple = 1;
+ break;
+ }
+
+ if (active) {
+ mmesa->setup.dwgctl &= ~(0xf<<20);
+ mmesa->setup.dwgctl |= mmesa->poly_stipple;
+ }
+}
+
+
+/* =============================================================
+ * Rendering attributes
+ *
+ * We really don't want to recalculate all this every time we bind a
+ * texture. These things shouldn't change all that often, so it makes
+ * sense to break them out of the core texture state update routines.
+ */
+
+static void updateSpecularLighting( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ unsigned int specen;
+
+ specen = NEED_SECONDARY_COLOR(ctx) ? TMC_specen_enable : 0;
+
+ if ( specen != mmesa->hw.specen ) {
+ mmesa->hw.specen = specen;
+ mmesa->dirty |= MGA_UPLOAD_TEX0 | MGA_UPLOAD_TEX1;
+ }
+}
+
+
+/* =============================================================
+ * Materials
+ */
+
+
+static void mgaDDLightModelfv(GLcontext *ctx, GLenum pname,
+ const GLfloat *param)
+{
+ if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) {
+ FLUSH_BATCH( MGA_CONTEXT(ctx) );
+ updateSpecularLighting( ctx );
+ }
+}
+
+
+/* =============================================================
+ * Stencil
+ */
+
+
+static void mgaDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref,
+ GLuint mask)
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLuint stencil;
+ GLuint stencilctl;
+
+ stencil = MGA_FIELD( S_sref, ref ) | MGA_FIELD( S_smsk, mask );
+ switch (func)
+ {
+ case GL_NEVER:
+ stencilctl = SC_smode_snever;
+ break;
+ case GL_LESS:
+ stencilctl = SC_smode_slt;
+ break;
+ case GL_LEQUAL:
+ stencilctl = SC_smode_slte;
+ break;
+ case GL_GREATER:
+ stencilctl = SC_smode_sgt;
+ break;
+ case GL_GEQUAL:
+ stencilctl = SC_smode_sgte;
+ break;
+ case GL_NOTEQUAL:
+ stencilctl = SC_smode_sne;
+ break;
+ case GL_EQUAL:
+ stencilctl = SC_smode_se;
+ break;
+ case GL_ALWAYS:
+ default:
+ stencilctl = SC_smode_salways;
+ break;
+ }
+
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ mmesa->hw.stencil &= (S_sref_MASK & S_smsk_MASK);
+ mmesa->hw.stencil |= stencil;
+ mmesa->hw.stencilctl &= SC_smode_MASK;
+ mmesa->hw.stencilctl |= stencilctl;
+}
+
+static void mgaDDStencilMask(GLcontext *ctx, GLuint mask)
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ mmesa->hw.stencil &= S_swtmsk_MASK;
+ mmesa->hw.stencil |= MGA_FIELD( S_swtmsk, mask );
+}
+
+static void mgaDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail,
+ GLenum zpass)
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLuint stencilctl;
+
+ stencilctl = 0;
+ switch (ctx->Stencil.FailFunc[0])
+ {
+ case GL_KEEP:
+ stencilctl |= SC_sfailop_keep;
+ break;
+ case GL_ZERO:
+ stencilctl |= SC_sfailop_zero;
+ break;
+ case GL_REPLACE:
+ stencilctl |= SC_sfailop_replace;
+ break;
+ case GL_INCR:
+ stencilctl |= SC_sfailop_incrsat;
+ break;
+ case GL_DECR:
+ stencilctl |= SC_sfailop_decrsat;
+ break;
+ case GL_INCR_WRAP:
+ stencilctl |= SC_sfailop_incr;
+ break;
+ case GL_DECR_WRAP:
+ stencilctl |= SC_sfailop_decr;
+ break;
+ case GL_INVERT:
+ stencilctl |= SC_sfailop_invert;
+ break;
+ default:
+ break;
+ }
+
+ switch (ctx->Stencil.ZFailFunc[0])
+ {
+ case GL_KEEP:
+ stencilctl |= SC_szfailop_keep;
+ break;
+ case GL_ZERO:
+ stencilctl |= SC_szfailop_zero;
+ break;
+ case GL_REPLACE:
+ stencilctl |= SC_szfailop_replace;
+ break;
+ case GL_INCR:
+ stencilctl |= SC_szfailop_incrsat;
+ break;
+ case GL_DECR:
+ stencilctl |= SC_szfailop_decrsat;
+ break;
+ case GL_INCR_WRAP:
+ stencilctl |= SC_szfailop_incr;
+ break;
+ case GL_DECR_WRAP:
+ stencilctl |= SC_szfailop_decr;
+ break;
+ case GL_INVERT:
+ stencilctl |= SC_szfailop_invert;
+ break;
+ default:
+ break;
+ }
+
+ switch (ctx->Stencil.ZPassFunc[0])
+ {
+ case GL_KEEP:
+ stencilctl |= SC_szpassop_keep;
+ break;
+ case GL_ZERO:
+ stencilctl |= SC_szpassop_zero;
+ break;
+ case GL_REPLACE:
+ stencilctl |= SC_szpassop_replace;
+ break;
+ case GL_INCR:
+ stencilctl |= SC_szpassop_incrsat;
+ break;
+ case GL_DECR:
+ stencilctl |= SC_szpassop_decrsat;
+ break;
+ case GL_INCR_WRAP:
+ stencilctl |= SC_szpassop_incr;
+ break;
+ case GL_DECR_WRAP:
+ stencilctl |= SC_szpassop_decr;
+ break;
+ case GL_INVERT:
+ stencilctl |= SC_szpassop_invert;
+ break;
+ default:
+ break;
+ }
+
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ mmesa->hw.stencilctl &= (SC_sfailop_MASK & SC_szfailop_MASK
+ & SC_szpassop_MASK);
+ mmesa->hw.stencilctl |= stencilctl;
+}
+
+
+/* =============================================================
+ * Window position and viewport transformation
+ */
+
+void mgaCalcViewport( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat *m = mmesa->hw_viewport;
+
+ /* See also mga_translate_vertex.
+ */
+ m[MAT_SX] = v[MAT_SX];
+ m[MAT_TX] = v[MAT_TX] + mmesa->drawX + SUBPIXEL_X;
+ m[MAT_SY] = - v[MAT_SY];
+ m[MAT_TY] = - v[MAT_TY] + mmesa->driDrawable->h + mmesa->drawY + SUBPIXEL_Y;
+ m[MAT_SZ] = v[MAT_SZ] * mmesa->depth_scale;
+ m[MAT_TZ] = v[MAT_TZ] * mmesa->depth_scale;
+
+ mmesa->SetupNewInputs = ~0;
+}
+
+static void mgaViewport( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
+ mgaCalcViewport( ctx );
+}
+
+static void mgaDepthRange( GLcontext *ctx,
+ GLclampd nearval, GLclampd farval )
+{
+ mgaCalcViewport( ctx );
+}
+
+
+/* =============================================================
+ * Miscellaneous
+ */
+
+static void mgaDDClearColor(GLcontext *ctx,
+ const GLfloat color[4] )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLubyte c[4];
+ CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
+
+ mmesa->ClearColor = mgaPackColor( mmesa->mgaScreen->cpp,
+ c[0], c[1], c[2], c[3]);
+}
+
+
+/* Fallback to swrast for select and feedback.
+ */
+static void mgaRenderMode( GLcontext *ctx, GLenum mode )
+{
+ FALLBACK( ctx, MGA_FALLBACK_RENDERMODE, (mode != GL_RENDER) );
+}
+
+
+static void mgaDDLogicOp( GLcontext *ctx, GLenum opcode )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ mmesa->hw.rop = mgarop_NoBLK[ opcode & 0x0f ];
+}
+
+
+static void mgaXMesaSetFrontClipRects( mgaContextPtr mmesa )
+{
+ __DRIdrawablePrivate *driDrawable = mmesa->driDrawable;
+
+ if (driDrawable->numClipRects == 0) {
+ static drm_clip_rect_t zeroareacliprect = {0,0,0,0};
+ mmesa->numClipRects = 1;
+ mmesa->pClipRects = &zeroareacliprect;
+ } else {
+ mmesa->numClipRects = driDrawable->numClipRects;
+ mmesa->pClipRects = driDrawable->pClipRects;
+ }
+ mmesa->drawX = driDrawable->x;
+ mmesa->drawY = driDrawable->y;
+
+ mmesa->setup.dstorg = mmesa->drawOffset;
+ mmesa->dirty |= MGA_UPLOAD_CONTEXT | MGA_UPLOAD_CLIPRECTS;
+}
+
+
+static void mgaXMesaSetBackClipRects( mgaContextPtr mmesa )
+{
+ __DRIdrawablePrivate *driDrawable = mmesa->driDrawable;
+
+ if (driDrawable->numBackClipRects == 0)
+ {
+ if (driDrawable->numClipRects == 0) {
+ static drm_clip_rect_t zeroareacliprect = {0,0,0,0};
+ mmesa->numClipRects = 1;
+ mmesa->pClipRects = &zeroareacliprect;
+ } else {
+ mmesa->numClipRects = driDrawable->numClipRects;
+ mmesa->pClipRects = driDrawable->pClipRects;
+ }
+ mmesa->drawX = driDrawable->x;
+ mmesa->drawY = driDrawable->y;
+ } else {
+ mmesa->numClipRects = driDrawable->numBackClipRects;
+ mmesa->pClipRects = driDrawable->pBackClipRects;
+ mmesa->drawX = driDrawable->backX;
+ mmesa->drawY = driDrawable->backY;
+ }
+
+ mmesa->setup.dstorg = mmesa->drawOffset;
+ mmesa->dirty |= MGA_UPLOAD_CONTEXT | MGA_UPLOAD_CLIPRECTS;
+}
+
+
+void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers )
+{
+ __DRIdrawablePrivate *driDrawable = mmesa->driDrawable;
+ drm_mga_sarea_t *sarea = mmesa->sarea;
+
+
+ DRI_VALIDATE_DRAWABLE_INFO(mmesa->driScreen, driDrawable);
+ mmesa->dirty_cliprects = 0;
+
+ if (mmesa->draw_buffer == MGA_FRONT)
+ mgaXMesaSetFrontClipRects( mmesa );
+ else
+ mgaXMesaSetBackClipRects( mmesa );
+
+ sarea->req_drawable = driDrawable->draw;
+ sarea->req_draw_buffer = mmesa->draw_buffer;
+
+ mgaUpdateClipping( mmesa->glCtx );
+ mgaCalcViewport( mmesa->glCtx );
+
+ mmesa->dirty |= MGA_UPLOAD_CLIPRECTS;
+}
+
+
+static void mgaDDDrawBuffer(GLcontext *ctx, GLenum mode )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ FLUSH_BATCH( mmesa );
+
+ /*
+ * _DrawDestMask is easier to cope with than <mode>.
+ */
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ mmesa->setup.dstorg = mmesa->mgaScreen->frontOffset;
+ mmesa->dirty |= MGA_UPLOAD_CONTEXT;
+ mmesa->draw_buffer = MGA_FRONT;
+ mgaXMesaSetFrontClipRects( mmesa );
+ FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ mmesa->setup.dstorg = mmesa->mgaScreen->backOffset;
+ mmesa->draw_buffer = MGA_BACK;
+ mmesa->dirty |= MGA_UPLOAD_CONTEXT;
+ mgaXMesaSetBackClipRects( mmesa );
+ FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ break;
+ default:
+ /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
+ FALLBACK( ctx, MGA_FALLBACK_DRAW_BUFFER, GL_TRUE );
+ return;
+ }
+
+ /* We want to update the s/w rast state too so that r200SetBuffer()
+ * gets called.
+ */
+ _swrast_DrawBuffer(ctx, mode);
+}
+
+
+static void mgaDDReadBuffer(GLcontext *ctx, GLenum mode )
+{
+ /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
+}
+
+
+/* =============================================================
+ * State enable/disable
+ */
+
+
+static void mgaDDEnable(GLcontext *ctx, GLenum cap, GLboolean state)
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+
+ switch(cap) {
+ case GL_DITHER:
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ if (!ctx->Color.DitherFlag)
+ mmesa->setup.maccess |= MA_nodither_enable;
+ else
+ mmesa->setup.maccess &= ~MA_nodither_enable;
+ break;
+ case GL_LIGHTING:
+ case GL_COLOR_SUM_EXT:
+ FLUSH_BATCH( mmesa );
+ updateSpecularLighting( ctx );
+ break;
+ case GL_ALPHA_TEST:
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ mmesa->hw.alpha_func_enable = (state) ? ~0 : 0;
+ break;
+ case GL_DEPTH_TEST:
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ FALLBACK (ctx, MGA_FALLBACK_DEPTH,
+ ctx->Depth.Func == GL_NEVER && ctx->Depth.Test);
+ break;
+
+ case GL_SCISSOR_TEST:
+ FLUSH_BATCH( mmesa );
+ mmesa->scissor = state;
+ mgaUpdateClipping( ctx );
+ break;
+
+ case GL_FOG:
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ if (ctx->Fog.Enabled)
+ mmesa->setup.maccess |= MA_fogen_enable;
+ else
+ mmesa->setup.maccess &= ~MA_fogen_enable;
+ break;
+ case GL_CULL_FACE:
+ mgaDDCullFaceFrontFace( ctx, 0 );
+ break;
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ break;
+ case GL_POLYGON_STIPPLE:
+ if (mmesa->haveHwStipple && mmesa->raster_primitive == GL_TRIANGLES) {
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ mmesa->setup.dwgctl &= ~(0xf<<20);
+ if (state)
+ mmesa->setup.dwgctl |= mmesa->poly_stipple;
+ }
+ break;
+
+ case GL_BLEND:
+ case GL_COLOR_LOGIC_OP:
+ updateBlendLogicOp( ctx );
+ break;
+
+ case GL_STENCIL_TEST:
+ MGA_STATECHANGE( mmesa, MGA_UPLOAD_CONTEXT );
+ if (mmesa->hw_stencil) {
+ mmesa->hw.stencil_enable = ( state ) ? ~0 : 0;
+ }
+ else {
+ FALLBACK( ctx, MGA_FALLBACK_STENCIL, state );
+ }
+ default:
+ break;
+ }
+}
+
+
+/* =============================================================
+ */
+
+static void mgaDDPrintDirty( const char *msg, GLuint state )
+{
+ fprintf(stderr, "%s (0x%03x): %s%s%s%s%s%s%s\n",
+ msg,
+ (unsigned int) state,
+ (state & MGA_WAIT_AGE) ? "wait-age " : "",
+ (state & MGA_UPLOAD_TEX0IMAGE) ? "upload-tex0-img " : "",
+ (state & MGA_UPLOAD_TEX1IMAGE) ? "upload-tex1-img " : "",
+ (state & MGA_UPLOAD_CONTEXT) ? "upload-ctx " : "",
+ (state & MGA_UPLOAD_TEX0) ? "upload-tex0 " : "",
+ (state & MGA_UPLOAD_TEX1) ? "upload-tex1 " : "",
+ (state & MGA_UPLOAD_PIPE) ? "upload-pipe " : ""
+ );
+}
+
+/* Push the state into the sarea and/or texture memory.
+ */
+void mgaEmitHwStateLocked( mgaContextPtr mmesa )
+{
+ drm_mga_sarea_t *sarea = mmesa->sarea;
+ GLcontext * ctx = mmesa->glCtx;
+
+ if (MGA_DEBUG & DEBUG_VERBOSE_MSG)
+ mgaDDPrintDirty( __FUNCTION__, mmesa->dirty );
+
+ if (mmesa->dirty & MGA_UPLOAD_CONTEXT) {
+ mmesa->setup.wflag = _CULL_DISABLE;
+ if (mmesa->raster_primitive == GL_TRIANGLES) {
+ if ((ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT &&
+ ctx->Texture.Unit[1]._ReallyEnabled == TEXTURE_2D_BIT)) {
+ mmesa->setup.wflag = mmesa->hw.cull_dualtex;
+ }
+ else {
+ mmesa->setup.wflag = mmesa->hw.cull;
+ }
+ }
+
+ mmesa->setup.stencil = mmesa->hw.stencil
+ & mmesa->hw.stencil_enable;
+ mmesa->setup.stencilctl = mmesa->hw.stencilctl
+ & mmesa->hw.stencil_enable;
+
+ /* If depth testing is not enabled, then use the no Z-compare / no
+ * Z-write mode. Otherwise, use whatever is set in hw.zmode.
+ */
+ mmesa->setup.dwgctl &= (DC_zmode_MASK & DC_atype_MASK);
+ mmesa->setup.dwgctl |= (ctx->Depth.Test)
+ ? mmesa->hw.zmode : (DC_zmode_nozcmp | DC_atype_i);
+
+ mmesa->setup.dwgctl &= DC_bop_MASK;
+ mmesa->setup.dwgctl |= (ctx->Color._LogicOpEnabled)
+ ? mmesa->hw.rop : mgarop_NoBLK[ GL_COPY & 0x0f ];
+
+ mmesa->setup.alphactrl &= AC_src_MASK & AC_dst_MASK & AC_atmode_MASK
+ & AC_atref_MASK & AC_alphasel_MASK;
+ mmesa->setup.alphactrl |=
+ (mmesa->hw.alpha_func & mmesa->hw.alpha_func_enable) |
+ (mmesa->hw.blend_func & mmesa->hw.blend_func_enable) |
+ ((AC_src_one | AC_dst_zero) & ~mmesa->hw.blend_func_enable) |
+ mmesa->hw.alpha_sel;
+
+ memcpy( &sarea->context_state, &mmesa->setup, sizeof(mmesa->setup));
+ }
+
+ if ((mmesa->dirty & MGA_UPLOAD_TEX0) && mmesa->CurrentTexObj[0]) {
+ memcpy(&sarea->tex_state[0],
+ &mmesa->CurrentTexObj[0]->setup,
+ sizeof(sarea->tex_state[0]));
+ }
+
+ if ((mmesa->dirty & MGA_UPLOAD_TEX1) && mmesa->CurrentTexObj[1]) {
+ memcpy(&sarea->tex_state[1],
+ &mmesa->CurrentTexObj[1]->setup,
+ sizeof(sarea->tex_state[1]));
+ }
+
+ if (mmesa->dirty & (MGA_UPLOAD_TEX0 | MGA_UPLOAD_TEX1)) {
+ sarea->tex_state[0].texctl2 &= ~TMC_specen_enable;
+ sarea->tex_state[1].texctl2 &= ~TMC_specen_enable;
+ sarea->tex_state[0].texctl2 |= mmesa->hw.specen;
+ sarea->tex_state[1].texctl2 |= mmesa->hw.specen;
+ }
+
+ if (mmesa->dirty & MGA_UPLOAD_PIPE) {
+/* mmesa->sarea->wacceptseq = mmesa->hw_primitive; */
+ mmesa->sarea->warp_pipe = mmesa->vertex_format;
+ mmesa->sarea->vertsize = mmesa->vertex_size;
+ }
+
+ mmesa->sarea->dirty |= mmesa->dirty;
+ mmesa->dirty &= MGA_UPLOAD_CLIPRECTS;
+}
+
+/* =============================================================
+ */
+
+
+static void mgaDDValidateState( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+
+ FLUSH_BATCH( mmesa );
+
+ if (mmesa->NewGLState & _NEW_TEXTURE) {
+ mgaUpdateTextureState(ctx);
+ }
+
+ if (!mmesa->Fallback) {
+ if (mmesa->NewGLState & _MGA_NEW_RASTERSETUP) {
+ mgaChooseVertexState( ctx );
+ }
+
+ if (mmesa->NewGLState & _MGA_NEW_RENDERSTATE) {
+ mgaChooseRenderState( ctx );
+ }
+ }
+
+ mmesa->NewGLState = 0;
+}
+
+
+static void mgaDDInvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ MGA_CONTEXT(ctx)->NewGLState |= new_state;
+}
+
+
+static void mgaRunPipeline( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ if (mmesa->NewGLState) {
+ mgaDDValidateState( ctx );
+ }
+
+ if (mmesa->dirty) {
+ mgaEmitHwStateLocked( mmesa );
+ }
+
+ _tnl_run_pipeline( ctx );
+}
+
+
+void mgaInitState( mgaContextPtr mmesa )
+{
+ mgaScreenPrivate *mgaScreen = mmesa->mgaScreen;
+ GLcontext *ctx = mmesa->glCtx;
+
+ if (ctx->Visual.doubleBufferMode) {
+ /* use back buffer by default */
+ mmesa->draw_buffer = MGA_BACK;
+ mmesa->drawOffset = mmesa->mgaScreen->backOffset;
+ mmesa->readOffset = mmesa->mgaScreen->backOffset;
+ mmesa->setup.dstorg = mgaScreen->backOffset;
+ } else {
+ /* use front buffer by default */
+ mmesa->draw_buffer = MGA_FRONT;
+ mmesa->drawOffset = mmesa->mgaScreen->frontOffset;
+ mmesa->readOffset = mmesa->mgaScreen->frontOffset;
+ mmesa->setup.dstorg = mgaScreen->frontOffset;
+ }
+
+ mmesa->setup.maccess = (MA_memreset_disable |
+ MA_fogen_disable |
+ MA_tlutload_disable |
+ MA_nodither_disable |
+ MA_dit555_disable);
+ if (driQueryOptioni (&mmesa->optionCache, "color_reduction") !=
+ DRI_CONF_COLOR_REDUCTION_DITHER)
+ mmesa->setup.maccess |= MA_nodither_enable;
+
+ switch (mmesa->mgaScreen->cpp) {
+ case 2:
+ mmesa->setup.maccess |= MA_pwidth_16;
+ break;
+ case 4:
+ mmesa->setup.maccess |= MA_pwidth_32;
+ break;
+ default:
+ fprintf( stderr, "Error: unknown cpp %d, exiting...\n",
+ mmesa->mgaScreen->cpp );
+ exit( 1 );
+ }
+
+ switch (mmesa->glCtx->Visual.depthBits) {
+ case 16:
+ mmesa->setup.maccess |= MA_zwidth_16;
+ break;
+ case 24:
+ mmesa->setup.maccess |= MA_zwidth_24;
+ break;
+ case 32:
+ mmesa->setup.maccess |= MA_zwidth_32;
+ break;
+ }
+
+ mmesa->hw.blend_func = AC_src_one | AC_dst_zero;
+ mmesa->hw.blend_func_enable = 0;
+ mmesa->hw.alpha_func = AC_atmode_noacmp | MGA_FIELD( AC_atref, 0x00 );
+ mmesa->hw.alpha_func_enable = 0;
+ mmesa->hw.rop = mgarop_NoBLK[ GL_COPY & 0x0f ];
+ mmesa->hw.zmode = DC_zmode_zlt | DC_atype_zi;
+ mmesa->hw.stencil = MGA_FIELD( S_sref, 0x00) | MGA_FIELD( S_smsk, 0xff ) |
+ MGA_FIELD( S_swtmsk, 0xff );
+ mmesa->hw.stencilctl = SC_smode_salways | SC_sfailop_keep
+ | SC_szfailop_keep | SC_szpassop_keep;
+ mmesa->hw.stencil_enable = 0;
+ mmesa->hw.cull = _CULL_DISABLE;
+ mmesa->hw.cull_dualtex = _CULL_DISABLE;
+ mmesa->hw.specen = 0;
+ mmesa->hw.alpha_sel = AC_alphasel_diffused;
+
+ mmesa->setup.dwgctl = (DC_opcod_trap |
+ DC_linear_xy |
+ DC_solid_disable |
+ DC_arzero_disable |
+ DC_sgnzero_disable |
+ DC_shftzero_enable |
+ MGA_FIELD( DC_bop, 0xC ) |
+ MGA_FIELD( DC_trans, 0x0 ) |
+ DC_bltmod_bmonolef |
+ DC_pattern_disable |
+ DC_transc_disable |
+ DC_clipdis_disable);
+
+ mmesa->setup.plnwt = ~0;
+ mmesa->setup.alphactrl = (AC_amode_alpha_channel |
+ AC_astipple_disable |
+ AC_aten_disable);
+
+ mmesa->setup.fogcolor = PACK_COLOR_888((GLubyte)(ctx->Fog.Color[0]*255.0F),
+ (GLubyte)(ctx->Fog.Color[1]*255.0F),
+ (GLubyte)(ctx->Fog.Color[2]*255.0F));
+
+ mmesa->setup.wflag = 0;
+ mmesa->setup.tdualstage0 = 0;
+ mmesa->setup.tdualstage1 = 0;
+ mmesa->setup.fcol = 0;
+ mmesa->dirty |= MGA_UPLOAD_CONTEXT;
+
+ mmesa->envcolor[0] = 0;
+ mmesa->envcolor[1] = 0;
+}
+
+
+void mgaDDInitStateFuncs( GLcontext *ctx )
+{
+ ctx->Driver.UpdateState = mgaDDInvalidateState;
+ ctx->Driver.Enable = mgaDDEnable;
+ ctx->Driver.LightModelfv = mgaDDLightModelfv;
+ ctx->Driver.AlphaFunc = mgaDDAlphaFunc;
+ ctx->Driver.BlendEquationSeparate = mgaDDBlendEquationSeparate;
+ ctx->Driver.BlendFuncSeparate = mgaDDBlendFuncSeparate;
+ ctx->Driver.DepthFunc = mgaDDDepthFunc;
+ ctx->Driver.DepthMask = mgaDDDepthMask;
+ ctx->Driver.Fogfv = mgaDDFogfv;
+ ctx->Driver.Scissor = mgaDDScissor;
+ ctx->Driver.CullFace = mgaDDCullFaceFrontFace;
+ ctx->Driver.FrontFace = mgaDDCullFaceFrontFace;
+ ctx->Driver.ColorMask = mgaDDColorMask;
+
+ ctx->Driver.DrawBuffer = mgaDDDrawBuffer;
+ ctx->Driver.ReadBuffer = mgaDDReadBuffer;
+ ctx->Driver.ClearColor = mgaDDClearColor;
+ ctx->Driver.ClearDepth = mgaDDClearDepth;
+ ctx->Driver.LogicOpcode = mgaDDLogicOp;
+
+ ctx->Driver.PolygonStipple = mgaDDPolygonStipple;
+
+ ctx->Driver.StencilFunc = mgaDDStencilFunc;
+ ctx->Driver.StencilMask = mgaDDStencilMask;
+ ctx->Driver.StencilOp = mgaDDStencilOp;
+
+ ctx->Driver.DepthRange = mgaDepthRange;
+ ctx->Driver.Viewport = mgaViewport;
+ ctx->Driver.RenderMode = mgaRenderMode;
+
+ ctx->Driver.ClearIndex = 0;
+ ctx->Driver.IndexMask = 0;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+
+ TNL_CONTEXT(ctx)->Driver.RunPipeline = mgaRunPipeline;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgastate.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgastate.h
new file mode 100644
index 000000000..afbe0aaf9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgastate.h
@@ -0,0 +1,39 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgastate.h,v 1.5 2002/10/30 12:51:36 alanh Exp $ */
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef _MGA_STATE_H
+#define _MGA_STATE_H
+
+extern void mgaInitState( mgaContextPtr mmesa );
+extern void mgaDDInitStateFuncs(GLcontext *ctx);
+extern void mgaUpdateClipping(const GLcontext *ctx);
+extern void mgaUpdateCull( GLcontext *ctx );
+extern void mgaCalcViewport( GLcontext *ctx );
+extern void mgaUpdateRects( mgaContextPtr mmesa, GLuint buffers );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatex.c
new file mode 100644
index 000000000..8caa1f858
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatex.c
@@ -0,0 +1,538 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatex.c,v 1.14 2002/10/30 12:51:36 alanh Exp $ */
+
+#include "glheader.h"
+#include "mm.h"
+#include "mgacontext.h"
+#include "mgatex.h"
+#include "mgaregs.h"
+#include "mgatris.h"
+#include "mgaioctl.h"
+
+#include "colormac.h"
+#include "context.h"
+#include "enums.h"
+#include "simple_list.h"
+#include "imports.h"
+#include "macros.h"
+#include "texformat.h"
+#include "texstore.h"
+#include "teximage.h"
+#include "texobj.h"
+
+#include "swrast/swrast.h"
+
+#include "xmlpool.h"
+
+/**
+ * Set the texture wrap modes.
+ * Currently \c GL_REPEAT, \c GL_CLAMP and \c GL_CLAMP_TO_EDGE are supported.
+ *
+ * \param t Texture object whose wrap modes are to be set
+ * \param swrap Wrap mode for the \a s texture coordinate
+ * \param twrap Wrap mode for the \a t texture coordinate
+ */
+
+static void
+mgaSetTexWrapping( mgaTextureObjectPtr t, GLenum swrap, GLenum twrap )
+{
+ GLboolean is_clamp = GL_FALSE;
+ GLboolean is_clamp_to_edge = GL_FALSE;
+
+ t->setup.texctl &= (TMC_clampu_MASK & TMC_clampv_MASK);
+ t->setup.texctl2 &= (TMC_borderen_MASK);
+
+ switch( swrap ) {
+ case GL_REPEAT:
+ break;
+ case GL_CLAMP:
+ t->setup.texctl |= TMC_clampu_enable;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_CLAMP_TO_EDGE:
+ t->setup.texctl |= TMC_clampu_enable;
+ is_clamp_to_edge = GL_TRUE;
+ break;
+ default:
+ _mesa_problem(NULL, "bad S wrap mode in %s", __FUNCTION__);
+ }
+
+ switch( twrap ) {
+ case GL_REPEAT:
+ break;
+ case GL_CLAMP:
+ t->setup.texctl |= TMC_clampv_enable;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_CLAMP_TO_EDGE:
+ t->setup.texctl |= TMC_clampv_enable;
+ is_clamp_to_edge = GL_TRUE;
+ break;
+ default:
+ _mesa_problem(NULL, "bad T wrap mode in %s", __FUNCTION__);
+ }
+
+ if ( is_clamp ) {
+ t->setup.texctl2 |= TMC_borderen_enable;
+ }
+
+ t->border_fallback = (is_clamp && is_clamp_to_edge);
+}
+
+
+/**
+ * Set the texture magnification and minification modes.
+ *
+ * \param t Texture whose filter modes are to be set
+ * \param minf Texture minification mode
+ * \param magf Texture magnification mode
+ */
+
+static void
+mgaSetTexFilter( mgaTextureObjectPtr t, GLenum minf, GLenum magf )
+{
+ GLuint val = 0;
+
+ switch (minf) {
+ case GL_NEAREST: val = TF_minfilter_nrst; break;
+ case GL_LINEAR: val = TF_minfilter_bilin; break;
+ case GL_NEAREST_MIPMAP_NEAREST: val = TF_minfilter_mm1s; break;
+ case GL_LINEAR_MIPMAP_NEAREST: val = TF_minfilter_mm4s; break;
+ case GL_NEAREST_MIPMAP_LINEAR: val = TF_minfilter_mm2s; break;
+ case GL_LINEAR_MIPMAP_LINEAR: val = TF_minfilter_mm8s; break;
+ default: val = TF_minfilter_nrst; break;
+ }
+
+ switch (magf) {
+ case GL_NEAREST: val |= TF_magfilter_nrst; break;
+ case GL_LINEAR: val |= TF_magfilter_bilin; break;
+ default: val |= TF_magfilter_nrst; break;
+ }
+
+ /* See OpenGL 1.2 specification */
+ if (magf == GL_LINEAR && (minf == GL_NEAREST_MIPMAP_NEAREST ||
+ minf == GL_NEAREST_MIPMAP_LINEAR)) {
+ val |= MGA_FIELD( TF_fthres, 0x20 ); /* c = 0.5 */
+ } else {
+ val |= MGA_FIELD( TF_fthres, 0x10 ); /* c = 0 */
+ }
+
+
+ /* Mask off the bits for the fields we are setting. Remember, the MGA mask
+ * defines have 0s for the bits in the named fields. This is the opposite
+ * of most of the other drivers.
+ */
+
+ t->setup.texfilter &= (TF_minfilter_MASK &
+ TF_magfilter_MASK &
+ TF_fthres_MASK);
+ t->setup.texfilter |= val;
+}
+
+static void mgaSetTexBorderColor(mgaTextureObjectPtr t, GLubyte color[4])
+{
+ t->setup.texbordercol = PACK_COLOR_8888(color[3], color[0],
+ color[1], color[2] );
+}
+
+
+static const struct gl_texture_format *
+mgaChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ const GLboolean do32bpt =
+ ( mmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32 );
+ const GLboolean force16bpt =
+ ( mmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16 );
+ (void) format;
+
+ switch ( internalFormat ) {
+ case 4:
+ case GL_RGBA:
+ case GL_COMPRESSED_RGBA:
+ switch ( type ) {
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return &_mesa_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return &_mesa_texformat_argb1555;
+ default:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+ }
+
+ case 3:
+ case GL_RGB:
+ case GL_COMPRESSED_RGB:
+ switch ( type ) {
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return &_mesa_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return &_mesa_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ return &_mesa_texformat_rgb565;
+ default:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+ }
+
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return !force16bpt ?
+ &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+
+ case GL_RGBA4:
+ case GL_RGBA2:
+ return &_mesa_texformat_argb4444;
+
+ case GL_RGB5_A1:
+ return &_mesa_texformat_argb1555;
+
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ return !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+
+ case GL_RGB5:
+ case GL_RGB4:
+ case GL_R3_G3_B2:
+ return &_mesa_texformat_rgb565;
+
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ case GL_COMPRESSED_ALPHA:
+ /* FIXME: This will report incorrect component sizes... */
+ return MGA_IS_G400(mmesa) ? &_mesa_texformat_al88 : &_mesa_texformat_argb4444;
+
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ case GL_COMPRESSED_LUMINANCE:
+ /* FIXME: This will report incorrect component sizes... */
+ return MGA_IS_G400(mmesa) ? &_mesa_texformat_al88 : &_mesa_texformat_rgb565;
+
+ 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_COMPRESSED_LUMINANCE_ALPHA:
+ /* FIXME: This will report incorrect component sizes... */
+ return MGA_IS_G400(mmesa) ? &_mesa_texformat_al88 : &_mesa_texformat_argb4444;
+
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case GL_COMPRESSED_INTENSITY:
+ /* FIXME: This will report incorrect component sizes... */
+ return MGA_IS_G400(mmesa) ? &_mesa_texformat_i8 : &_mesa_texformat_argb4444;
+
+ case GL_YCBCR_MESA:
+ if (MGA_IS_G400(mmesa) &&
+ (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
+ type == GL_UNSIGNED_BYTE))
+ return &_mesa_texformat_ycbcr;
+ else
+ return &_mesa_texformat_ycbcr_rev;
+
+ 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:
+ return &_mesa_texformat_ci8;
+
+ default:
+ _mesa_problem( ctx, "unexpected texture format in %s", __FUNCTION__ );
+ return NULL;
+ }
+
+ return NULL; /* never get here */
+}
+
+
+
+
+/**
+ * Allocate space for and load the mesa images into the texture memory block.
+ * This will happen before drawing with a new texture, or drawing with a
+ * texture after it was swapped out or teximaged again.
+ */
+
+static mgaTextureObjectPtr
+mgaAllocTexObj( struct gl_texture_object *tObj )
+{
+ mgaTextureObjectPtr t;
+
+
+ t = CALLOC( sizeof( *t ) );
+ tObj->DriverData = t;
+ if ( t != NULL ) {
+ /* Initialize non-image-dependent parts of the state:
+ */
+ t->base.tObj = tObj;
+
+ t->setup.texctl = TMC_takey_1 | TMC_tamask_0;
+ t->setup.texctl2 = TMC_ckstransdis_enable;
+ t->setup.texfilter = TF_filteralpha_enable | TF_uvoffset_OGL;
+
+ t->border_fallback = GL_FALSE;
+ t->texenv_fallback = GL_FALSE;
+
+ make_empty_list( & t->base );
+
+ mgaSetTexWrapping( t, tObj->WrapS, tObj->WrapT );
+ mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter );
+ mgaSetTexBorderColor( t, tObj->_BorderChan );
+ }
+
+ return( t );
+}
+
+
+static void mgaTexEnv( GLcontext *ctx, GLenum target,
+ GLenum pname, const GLfloat *param )
+{
+ GLuint unit = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+
+ switch( pname ) {
+ case GL_TEXTURE_ENV_COLOR: {
+ GLubyte c[4];
+
+ UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor );
+ mmesa->envcolor[unit] = PACK_COLOR_8888( c[3], c[0], c[1], c[2] );
+ break;
+ }
+ }
+}
+
+
+static void mgaTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+ if ( t != NULL ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) mgaAllocTexObj( texObj );
+ if ( t == NULL ) {
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glTexImage2D" );
+ return;
+ }
+ }
+
+ _mesa_store_teximage2d( ctx, target, level, internalFormat,
+ width, height, border, format, type,
+ pixels, packing, texObj, texImage );
+ level -= t->firstLevel;
+ if (level >= 0)
+ t->dirty_images[0] |= (1UL << level);
+}
+
+static void mgaTexSubImage2D( 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 )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+ assert( t ); /* this _should_ be true */
+ if ( t != NULL ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) mgaAllocTexObj( texObj );
+ if ( t == NULL ) {
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glTexImage2D" );
+ return;
+ }
+ }
+
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
+ level -= t->firstLevel;
+ if (level >= 0)
+ t->dirty_images[0] |= (1UL << level);
+}
+
+
+/**
+ * Changes variables and flags for a state update, which will happen at the
+ * next UpdateTextureState
+ */
+
+static void
+mgaTexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat *params )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ mgaTextureObjectPtr t = (mgaTextureObjectPtr) tObj->DriverData;
+
+ /* If we don't have a hardware texture, it will be automatically
+ * created with current state before it is used, so we don't have
+ * to do anything now
+ */
+ if ( (t == NULL) ||
+ (target != GL_TEXTURE_2D &&
+ target != GL_TEXTURE_RECTANGLE_NV) ) {
+ return;
+ }
+
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ driSwapOutTextureObject( (driTextureObject *) t );
+ /* FALLTHROUGH */
+ case GL_TEXTURE_MAG_FILTER:
+ FLUSH_BATCH(mmesa);
+ mgaSetTexFilter( t, tObj->MinFilter, tObj->MagFilter );
+ break;
+
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ FLUSH_BATCH(mmesa);
+ mgaSetTexWrapping(t,tObj->WrapS,tObj->WrapT);
+ break;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ FLUSH_BATCH(mmesa);
+ mgaSetTexBorderColor(t, tObj->_BorderChan);
+ break;
+
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ /* This isn't the most efficient solution but there doesn't appear to
+ * be a nice alternative. Since there's no LOD clamping,
+ * we just have to rely on loading the right subset of mipmap levels
+ * to simulate a clamped LOD.
+ */
+ driSwapOutTextureObject( (driTextureObject *) t );
+ break;
+
+ default:
+ return;
+ }
+}
+
+
+static void
+mgaBindTexture( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj )
+{
+ assert( (target != GL_TEXTURE_2D && target != GL_TEXTURE_RECTANGLE_NV) ||
+ (tObj->DriverData != NULL) );
+}
+
+
+static void
+mgaDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ driTextureObject * t = (driTextureObject *) tObj->DriverData;
+
+ if ( t ) {
+ if ( mmesa ) {
+ FLUSH_BATCH( mmesa );
+ }
+
+ driDestroyTextureObject( t );
+ }
+}
+
+
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
+ * Note: this function will be called during context creation to
+ * allocate the default texture objects.
+ * Note: we could use containment here to 'derive' the driver-specific
+ * texture object from the core mesa gl_texture_object. Not done at this time.
+ */
+static struct gl_texture_object *
+mgaNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+{
+ struct gl_texture_object *obj;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ mgaAllocTexObj( obj );
+ return obj;
+}
+
+
+void
+mgaInitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->ChooseTextureFormat = mgaChooseTextureFormat;
+ functions->TexImage2D = mgaTexImage2D;
+ functions->TexSubImage2D = mgaTexSubImage2D;
+ functions->BindTexture = mgaBindTexture;
+ functions->NewTextureObject = mgaNewTextureObject;
+ functions->DeleteTexture = mgaDeleteTexture;
+ functions->IsTextureResident = driIsTextureResident;
+ functions->TexEnv = mgaTexEnv;
+ functions->TexParameter = mgaTexParameter;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatex.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatex.h
new file mode 100644
index 000000000..fb7ffcff1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatex.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatex.h,v 1.7 2002/10/30 12:51:36 alanh Exp $ */
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef MGATEX_INC
+#define MGATEX_INC
+
+#include "mgacontext.h"
+
+typedef struct mga_texture_object_s *mgaTextureObjectPtr;
+
+
+/* Called before a primitive is rendered to make sure the texture
+ * state is properly setup. Texture residence is checked later
+ * when we grab the lock.
+ */
+void mgaUpdateTextureState( GLcontext *ctx );
+
+int mgaUploadTexImages( mgaContextPtr mmesa, mgaTextureObjectPtr t );
+
+void mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t );
+
+void mgaInitTextureFuncs( struct dd_function_table *functions );
+
+GLboolean mgaUpdateTextureEnvCombine( GLcontext *ctx, int unit );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatexmem.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatexmem.c
new file mode 100644
index 000000000..18743331c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatexmem.c
@@ -0,0 +1,278 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatexmem.c,v 1.7 2002/10/30 12:51:36 alanh Exp $ */
+
+#include "glheader.h"
+
+#include "mm.h"
+#include "mgacontext.h"
+#include "mgatex.h"
+#include "mgaregs.h"
+#include "mgaioctl.h"
+#include "mga_xmesa.h"
+
+#include "imports.h"
+#include "simple_list.h"
+
+/**
+ * Destroy any device-dependent state associated with the texture. This may
+ * include NULLing out hardware state that points to the texture.
+ */
+void
+mgaDestroyTexObj( mgaContextPtr mmesa, mgaTextureObjectPtr t )
+{
+ unsigned i;
+
+
+ /* See if it was the driver's current object.
+ */
+
+ if ( mmesa != NULL )
+ {
+ if ( t->age > mmesa->dirtyAge )
+ mmesa->dirtyAge = t->age;
+
+ for ( i = 0 ; i < mmesa->glCtx->Const.MaxTextureUnits ; i++ )
+ {
+ if ( t == mmesa->CurrentTexObj[ i ] ) {
+ mmesa->CurrentTexObj[ i ] = NULL;
+ }
+ }
+ }
+}
+
+
+/**
+ * Upload a texture image from system memory to either on-card or AGP
+ * memory. Uploads to on-card memory are performed using an ILOAD operation.
+ * This is used for both initial loading of the entire image, and texSubImage
+ * updates.
+ *
+ * Performed with the hardware lock held.
+ *
+ * Even though this function is named "upload subimage," the entire image
+ * is uploaded.
+ *
+ * \param mmesa Driver context.
+ * \param t Texture to be uploaded.
+ * \param hwlevel Mipmap level of the texture to be uploaded.
+ *
+ * \bug As mentioned above, this fuction actually copies the entier mipmap
+ * level. There should be a version of this function that performs
+ * sub-rectangle uploads. This will perform quite a bit better if only
+ * a small portion of a larger texture has been updated. Care would
+ * need to be take with such an implementation once glCopyTexImage has
+ * been hardware accelerated.
+ */
+static void mgaUploadSubImage( mgaContextPtr mmesa,
+ mgaTextureObjectPtr t, GLint hwlevel )
+{
+ struct gl_texture_image * texImage;
+ unsigned offset;
+ unsigned texelBytes;
+ unsigned length;
+ const int level = hwlevel + t->base.firstLevel;
+
+
+ if ( (hwlevel < 0)
+ || (hwlevel >= (MGA_IS_G200(mmesa)
+ ? G200_TEX_MAXLEVELS : G400_TEX_MAXLEVELS)) ) {
+ fprintf( stderr, "[%s:%d] level = %d\n", __FILE__, __LINE__, level );
+ return;
+ }
+
+ texImage = t->base.tObj->Image[0][level];
+ if ( texImage == NULL ) {
+ fprintf( stderr, "[%s:%d] Image[%d] = NULL\n", __FILE__, __LINE__,
+ level );
+ return;
+ }
+
+
+ if (texImage->Data == NULL) {
+ fprintf(stderr, "null texture image data tObj %p level %d\n",
+ (void *) t->base.tObj, level);
+ return;
+ }
+
+
+ /* find the proper destination offset for this level */
+ if ( MGA_IS_G200(mmesa) ) {
+ offset = (t->base.memBlock->ofs + t->offsets[hwlevel]);
+ }
+ else {
+ unsigned i;
+
+ offset = t->base.memBlock->ofs;
+ for ( i = 0 ; i < hwlevel ; i++ ) {
+ offset += (t->offsets[1] >> (i * 2));
+ }
+ }
+
+
+ /* Copy the texture from system memory to a memory space that can be
+ * directly used by the hardware for texturing.
+ */
+
+ texelBytes = texImage->TexFormat->TexelBytes;
+ length = texImage->Width * texImage->Height * texelBytes;
+ if ( t->base.heap->heapId == MGA_CARD_HEAP ) {
+ unsigned tex_offset = 0;
+ unsigned to_copy;
+
+
+ /* We may not be able to upload the entire texture in one batch due to
+ * register limits or dma buffer limits. Split the copy up into maximum
+ * sized chunks.
+ */
+
+ offset += mmesa->mgaScreen->textureOffset[ t->base.heap->heapId ];
+ while ( length != 0 ) {
+ mgaGetILoadBufferLocked( mmesa );
+
+ /* The kernel ILOAD ioctl requires that the lenght be an even multiple
+ * of MGA_ILOAD_ALIGN.
+ */
+ length = ((length) + MGA_ILOAD_MASK) & ~MGA_ILOAD_MASK;
+
+ to_copy = MIN2( length, MGA_BUFFER_SIZE );
+ (void) memcpy( mmesa->iload_buffer->address,
+ (GLubyte *) texImage->Data + tex_offset, to_copy );
+
+ if ( MGA_DEBUG & DEBUG_VERBOSE_TEXTURE )
+ fprintf(stderr, "[%s:%d] address/size = 0x%08lx/%d\n",
+ __FILE__, __LINE__,
+ (long) (offset + tex_offset),
+ to_copy );
+
+ mgaFireILoadLocked( mmesa, offset + tex_offset, to_copy );
+ tex_offset += to_copy;
+ length -= to_copy;
+ }
+ } else {
+ /* FIXME: the sync for direct copy reduces speed.. */
+ /* This works, is slower for uploads to card space and needs
+ * additional synchronization with the dma stream.
+ */
+
+ UPDATE_LOCK(mmesa, DRM_LOCK_FLUSH | DRM_LOCK_QUIESCENT);
+
+ memcpy( mmesa->mgaScreen->texVirtual[t->base.heap->heapId] + offset,
+ texImage->Data, length );
+
+ if ( MGA_DEBUG & DEBUG_VERBOSE_TEXTURE )
+ fprintf(stderr, "[%s:%d] address/size = 0x%08lx/%d\n",
+ __FILE__, __LINE__,
+ (long) (mmesa->mgaScreen->texVirtual[t->base.heap->heapId]
+ + offset),
+ length);
+ }
+}
+
+
+/**
+ * Upload the texture images associated with texture \a t. This might
+ * require the allocation of texture memory.
+ *
+ * \param mmesa Context pointer
+ * \param t Texture to be uploaded
+ */
+
+int mgaUploadTexImages( mgaContextPtr mmesa, mgaTextureObjectPtr t )
+{
+ int i;
+ int ofs;
+
+
+ if ( (t == NULL) || (t->base.totalSize == 0) )
+ return 0;
+
+ LOCK_HARDWARE( mmesa );
+
+ if (t->base.memBlock == NULL ) {
+ int heap;
+
+ heap = driAllocateTexture( mmesa->texture_heaps, mmesa->nr_heaps,
+ (driTextureObject *) t );
+ if ( heap == -1 ) {
+ UNLOCK_HARDWARE( mmesa );
+ return -1;
+ }
+
+ ofs = mmesa->mgaScreen->textureOffset[ heap ]
+ + t->base.memBlock->ofs;
+
+ if ( MGA_IS_G200(mmesa) ) {
+ t->setup.texorg = ofs;
+ t->setup.texorg1 = ofs + t->offsets[1];
+ t->setup.texorg2 = ofs + t->offsets[2];
+ t->setup.texorg3 = ofs + t->offsets[3];
+ t->setup.texorg4 = ofs + t->offsets[4];
+ }
+ else {
+ t->setup.texorg = ofs | TO_texorgoffsetsel;
+ t->setup.texorg1 = t->offsets[1];
+ t->setup.texorg2 = 0;
+ t->setup.texorg3 = 0;
+ t->setup.texorg4 = 0;
+ }
+
+ mmesa->dirty |= MGA_UPLOAD_CONTEXT;
+ }
+
+ /* Let the world know we've used this memory recently.
+ */
+ driUpdateTextureLRU( (driTextureObject *) t );
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_TEXTURE)
+ fprintf(stderr, "[%s:%d] dispatch age: %d age freed memory: %d\n",
+ __FILE__, __LINE__,
+ GET_DISPATCH_AGE(mmesa), mmesa->dirtyAge);
+
+ if (mmesa->dirtyAge >= GET_DISPATCH_AGE(mmesa))
+ mgaWaitAgeLocked( mmesa, mmesa->dirtyAge );
+
+ if (t->base.dirty_images[0]) {
+ const int numLevels = t->base.lastLevel - t->base.firstLevel + 1;
+
+ if (MGA_DEBUG&DEBUG_VERBOSE_TEXTURE)
+ fprintf(stderr, "[%s:%d] dirty_images[0] = 0x%04x\n",
+ __FILE__, __LINE__, t->base.dirty_images[0] );
+
+ for (i = 0 ; i < numLevels ; i++) {
+ if ( (t->base.dirty_images[0] & (1U << i)) != 0 ) {
+ mgaUploadSubImage( mmesa, t, i );
+ }
+ }
+ t->base.dirty_images[0] = 0;
+ }
+
+
+ UNLOCK_HARDWARE( mmesa );
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatris.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatris.c
new file mode 100644
index 000000000..2b7ea05b1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatris.c
@@ -0,0 +1,912 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatris.c,v 1.10 2002/10/30 12:51:36 alanh Exp $ */
+
+#include "mtypes.h"
+#include "macros.h"
+#include "colormac.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
+#include "mm.h"
+#include "mgacontext.h"
+#include "mgaioctl.h"
+#include "mgatris.h"
+#include "mgavb.h"
+#include "mgastate.h"
+
+
+static void mgaRenderPrimitive( GLcontext *ctx, GLenum prim );
+
+/***********************************************************************
+ * Functions to draw basic primitives *
+ ***********************************************************************/
+
+
+#if defined (USE_X86_ASM)
+#define EMIT_VERT( j, vb, vertex_size, v ) \
+do { int __tmp; \
+ __asm__ __volatile__( "rep ; movsl" \
+ : "=%c" (j), "=D" (vb), "=S" (__tmp) \
+ : "0" (vertex_size), \
+ "D" ((long)vb), \
+ "S" ((long)v)); \
+} while (0)
+#else
+#define EMIT_VERT( j, vb, vertex_size, v ) \
+do { \
+ for ( j = 0 ; j < vertex_size ; j++ ) \
+ vb[j] = (v)->ui[j]; \
+ vb += vertex_size; \
+} while (0)
+#endif
+
+static void __inline__ mga_draw_triangle( mgaContextPtr mmesa,
+ mgaVertexPtr v0,
+ mgaVertexPtr v1,
+ mgaVertexPtr v2 )
+{
+ GLuint vertex_size = mmesa->vertex_size;
+ GLuint *vb = mgaAllocDmaLow( mmesa, 3 * 4 * vertex_size );
+ int j;
+
+ EMIT_VERT( j, vb, vertex_size, v0 );
+ EMIT_VERT( j, vb, vertex_size, v1 );
+ EMIT_VERT( j, vb, vertex_size, v2 );
+}
+
+
+static void __inline__ mga_draw_quad( mgaContextPtr mmesa,
+ mgaVertexPtr v0,
+ mgaVertexPtr v1,
+ mgaVertexPtr v2,
+ mgaVertexPtr v3 )
+{
+ GLuint vertex_size = mmesa->vertex_size;
+ GLuint *vb = mgaAllocDmaLow( mmesa, 6 * 4 * vertex_size );
+ int j;
+
+ EMIT_VERT( j, vb, vertex_size, v0 );
+ EMIT_VERT( j, vb, vertex_size, v1 );
+ EMIT_VERT( j, vb, vertex_size, v3 );
+ EMIT_VERT( j, vb, vertex_size, v1 );
+ EMIT_VERT( j, vb, vertex_size, v2 );
+ EMIT_VERT( j, vb, vertex_size, v3 );
+}
+
+
+static __inline__ void mga_draw_point( mgaContextPtr mmesa,
+ mgaVertexPtr tmp )
+{
+ GLfloat sz = mmesa->glCtx->Point._Size * .5;
+ int vertex_size = mmesa->vertex_size;
+ GLuint *vb = mgaAllocDmaLow( mmesa, 6 * 4 * vertex_size );
+ int j;
+
+#if 0
+ v0->v.x += PNT_X_OFFSET - TRI_X_OFFSET;
+ v0->v.y += PNT_Y_OFFSET - TRI_Y_OFFSET;
+#endif
+
+ /* Draw a point as two triangles.
+ */
+ *(float *)&vb[0] = tmp->v.x - sz;
+ *(float *)&vb[1] = tmp->v.y - sz;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = tmp->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = tmp->v.x + sz;
+ *(float *)&vb[1] = tmp->v.y - sz;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = tmp->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = tmp->v.x + sz;
+ *(float *)&vb[1] = tmp->v.y + sz;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = tmp->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = tmp->v.x + sz;
+ *(float *)&vb[1] = tmp->v.y + sz;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = tmp->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = tmp->v.x - sz;
+ *(float *)&vb[1] = tmp->v.y + sz;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = tmp->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = tmp->v.x - sz;
+ *(float *)&vb[1] = tmp->v.y - sz;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = tmp->ui[j];
+
+#if 0
+ v0->v.x -= PNT_X_OFFSET - TRI_X_OFFSET;
+ v0->v.y -= PNT_Y_OFFSET - TRI_Y_OFFSET;
+#endif
+}
+
+
+static __inline__ void mga_draw_line( mgaContextPtr mmesa,
+ mgaVertexPtr v0,
+ mgaVertexPtr v1 )
+{
+ GLuint vertex_size = mmesa->vertex_size;
+ GLuint *vb = mgaAllocDmaLow( mmesa, 6 * 4 * vertex_size );
+ GLfloat dx, dy, ix, iy;
+ GLfloat width = mmesa->glCtx->Line._Width;
+ GLint j;
+
+#if 0
+ v0->v.x += LINE_X_OFFSET - TRI_X_OFFSET;
+ v0->v.y += LINE_Y_OFFSET - TRI_Y_OFFSET;
+ v1->v.x += LINE_X_OFFSET - TRI_X_OFFSET;
+ v1->v.y += LINE_Y_OFFSET - TRI_Y_OFFSET;
+#endif
+
+ dx = v0->v.x - v1->v.x;
+ dy = v0->v.y - v1->v.y;
+
+ ix = width * .5; iy = 0;
+ if (dx * dx > dy * dy) {
+ iy = ix; ix = 0;
+ }
+
+ *(float *)&vb[0] = v0->v.x - ix;
+ *(float *)&vb[1] = v0->v.y - iy;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = v0->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = v1->v.x + ix;
+ *(float *)&vb[1] = v1->v.y + iy;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = v1->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = v0->v.x + ix;
+ *(float *)&vb[1] = v0->v.y + iy;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = v0->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = v0->v.x - ix;
+ *(float *)&vb[1] = v0->v.y - iy;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = v0->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = v1->v.x - ix;
+ *(float *)&vb[1] = v1->v.y - iy;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = v1->ui[j];
+ vb += vertex_size;
+
+ *(float *)&vb[0] = v1->v.x + ix;
+ *(float *)&vb[1] = v1->v.y + iy;
+ for (j = 2 ; j < vertex_size ; j++)
+ vb[j] = v1->ui[j];
+ vb += vertex_size;
+
+#if 0
+ v0->v.x -= LINE_X_OFFSET - TRI_X_OFFSET;
+ v0->v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
+ v1->v.x -= LINE_X_OFFSET - TRI_X_OFFSET;
+ v1->v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
+#endif
+}
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ if (DO_FALLBACK) \
+ mmesa->draw_tri( mmesa, a, b, c ); \
+ else \
+ mga_draw_triangle( mmesa, a, b, c ); \
+} while (0)
+
+#define QUAD( a, b, c, d ) \
+do { \
+ if (DO_FALLBACK) { \
+ mmesa->draw_tri( mmesa, a, b, d ); \
+ mmesa->draw_tri( mmesa, b, c, d ); \
+ } else { \
+ mga_draw_quad( mmesa, a, b, c, d ); \
+ } \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ if (DO_FALLBACK) \
+ mmesa->draw_line( mmesa, v0, v1 ); \
+ else { \
+ mga_draw_line( mmesa, v0, v1 ); \
+ } \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ if (DO_FALLBACK) \
+ mmesa->draw_point( mmesa, v0 ); \
+ else { \
+ mga_draw_point( mmesa, v0 ); \
+ } \
+} while (0)
+
+
+/***********************************************************************
+ * Fallback to swrast for basic primitives *
+ ***********************************************************************/
+
+/* This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+
+static void
+mga_fallback_tri( mgaContextPtr mmesa,
+ mgaVertex *v0,
+ mgaVertex *v1,
+ mgaVertex *v2 )
+{
+ GLcontext *ctx = mmesa->glCtx;
+ SWvertex v[3];
+ mga_translate_vertex( ctx, v0, &v[0] );
+ mga_translate_vertex( ctx, v1, &v[1] );
+ mga_translate_vertex( ctx, v2, &v[2] );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+}
+
+
+static void
+mga_fallback_line( mgaContextPtr mmesa,
+ mgaVertex *v0,
+ mgaVertex *v1 )
+{
+ GLcontext *ctx = mmesa->glCtx;
+ SWvertex v[2];
+ mga_translate_vertex( ctx, v0, &v[0] );
+ mga_translate_vertex( ctx, v1, &v[1] );
+ _swrast_Line( ctx, &v[0], &v[1] );
+}
+
+
+static void
+mga_fallback_point( mgaContextPtr mmesa,
+ mgaVertex *v0 )
+{
+ GLcontext *ctx = mmesa->glCtx;
+ SWvertex v[1];
+ mga_translate_vertex( ctx, v0, &v[0] );
+ _swrast_Point( ctx, &v[0] );
+}
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+
+#define MGA_UNFILLED_BIT 0x1
+#define MGA_OFFSET_BIT 0x2
+#define MGA_TWOSIDE_BIT 0x4
+#define MGA_FLAT_BIT 0x8 /* mga can't flatshade? */
+#define MGA_FALLBACK_BIT 0x10
+#define MGA_MAX_TRIFUNC 0x20
+
+static struct {
+ tnl_points_func points;
+ tnl_line_func line;
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
+} rast_tab[MGA_MAX_TRIFUNC];
+
+#define DO_FALLBACK (IND & MGA_FALLBACK_BIT)
+#define DO_OFFSET (IND & MGA_OFFSET_BIT)
+#define DO_UNFILLED (IND & MGA_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & MGA_TWOSIDE_BIT)
+#define DO_FLAT (IND & MGA_FLAT_BIT)
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_BACK_COLORS 0
+#define HAVE_SPEC 1
+#define HAVE_HW_FLATSHADE 0
+#define VERTEX mgaVertex
+#define TAB rast_tab
+
+
+#define DEPTH_SCALE mmesa->depth_scale
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a > 0)
+#define GET_VERTEX(e) (mmesa->verts + (e * mmesa->vertex_size * sizeof(int)))
+
+#define VERT_SET_RGBA( v, c ) \
+do { \
+ mga_color_t *color = (mga_color_t *)&((v)->ui[4]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \
+} while (0)
+
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4]
+
+#define VERT_SET_SPEC( v0, c ) \
+do { \
+ UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.blue, (c)[2]); \
+} while (0)
+
+#define VERT_COPY_SPEC( v0, v1 ) \
+do { \
+ v0->v.specular.red = v1->v.specular.red; \
+ v0->v.specular.green = v1->v.specular.green; \
+ v0->v.specular.blue = v1->v.specular.blue; \
+} while (0)
+
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[4]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx]
+#define VERT_SAVE_SPEC( idx ) spec[idx] = v[idx]->ui[5]
+#define VERT_RESTORE_SPEC( idx ) v[idx]->ui[5] = spec[idx]
+
+#define LOCAL_VARS(n) \
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx); \
+ GLuint color[n], spec[n]; \
+ (void) color; (void) spec;
+
+
+
+/***********************************************************************
+ * Functions to draw basic unfilled primitives *
+ ***********************************************************************/
+
+#define RASTERIZE(x) if (mmesa->raster_primitive != x) \
+ mgaRasterPrimitive( ctx, x, MGA_WA_TRIANGLES )
+#define RENDER_PRIMITIVE mmesa->render_primitive
+#define IND MGA_FALLBACK_BIT
+#define TAG(x) x
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+/***********************************************************************
+ * Functions to draw GL primitives *
+ ***********************************************************************/
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_OFFSET_BIT|MGA_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT|MGA_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_FALLBACK_BIT)
+#define TAG(x) x##_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_OFFSET_BIT|MGA_FALLBACK_BIT)
+#define TAG(x) x##_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_FALLBACK_BIT)
+#define TAG(x) x##_twoside_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT|MGA_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_UNFILLED_BIT|MGA_FALLBACK_BIT)
+#define TAG(x) x##_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_OFFSET_BIT|MGA_UNFILLED_BIT|MGA_FALLBACK_BIT)
+#define TAG(x) x##_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_UNFILLED_BIT|MGA_FALLBACK_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT|MGA_UNFILLED_BIT| \
+ MGA_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+/* Mga doesn't support provoking-vertex flat-shading?
+ */
+#define IND (MGA_FLAT_BIT)
+#define TAG(x) x##_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_OFFSET_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_offset_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_twoside_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_UNFILLED_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_OFFSET_BIT|MGA_UNFILLED_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_offset_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_UNFILLED_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_twoside_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT|MGA_UNFILLED_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_FALLBACK_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_OFFSET_BIT|MGA_FALLBACK_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_offset_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_FALLBACK_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_twoside_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT|MGA_FALLBACK_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_UNFILLED_BIT|MGA_FALLBACK_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_OFFSET_BIT|MGA_UNFILLED_BIT|MGA_FALLBACK_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_offset_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_UNFILLED_BIT|MGA_FALLBACK_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (MGA_TWOSIDE_BIT|MGA_OFFSET_BIT|MGA_UNFILLED_BIT| \
+ MGA_FALLBACK_BIT|MGA_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+static void init_rast_tab( void )
+{
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+ init_fallback();
+ init_offset_fallback();
+ init_twoside_fallback();
+ init_twoside_offset_fallback();
+ init_unfilled_fallback();
+ init_offset_unfilled_fallback();
+ init_twoside_unfilled_fallback();
+ init_twoside_offset_unfilled_fallback();
+
+ init_flat();
+ init_offset_flat();
+ init_twoside_flat();
+ init_twoside_offset_flat();
+ init_unfilled_flat();
+ init_offset_unfilled_flat();
+ init_twoside_unfilled_flat();
+ init_twoside_offset_unfilled_flat();
+ init_fallback_flat();
+ init_offset_fallback_flat();
+ init_twoside_fallback_flat();
+ init_twoside_offset_fallback_flat();
+ init_unfilled_fallback_flat();
+ init_offset_unfilled_fallback_flat();
+ init_twoside_unfilled_fallback_flat();
+ init_twoside_offset_unfilled_fallback_flat();
+}
+
+/**********************************************************************/
+/* Render whole begin/end objects */
+/**********************************************************************/
+
+
+#define VERT(x) (mgaVertex *)(vertptr + ((x)*vertex_size*sizeof(int)))
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ mga_draw_point( mmesa, VERT(ELT(start)) );
+#define RENDER_LINE( v0, v1 ) \
+ mga_draw_line( mmesa, VERT(v0), VERT(v1) )
+#define RENDER_TRI( v0, v1, v2 ) \
+ mga_draw_triangle( mmesa, VERT(v0), VERT(v1), VERT(v2) )
+#define RENDER_QUAD( v0, v1, v2, v3 ) \
+ mga_draw_quad( mmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
+#define INIT(x) mgaRenderPrimitive( ctx, x )
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx); \
+ GLubyte *vertptr = (GLubyte *)mmesa->verts; \
+ const GLuint vertex_size = mmesa->vertex_size; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ (void) elt;
+#define RESET_STIPPLE
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) x
+#define TAG(x) mga_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+#undef ELT
+#undef TAG
+#define TAG(x) mga_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl/t_vb_rendertmp.h"
+
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+
+
+static void mgaRenderClippedPoly( GLcontext *ctx, const GLuint *elts, GLuint n )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint prim = mmesa->render_primitive;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+ }
+
+ /* Restore the render primitive
+ */
+ if (prim != GL_POLYGON)
+ tnl->Driver.Render.PrimitiveNotify( ctx, prim );
+}
+
+static void mgaRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Line( ctx, ii, jj );
+}
+
+static void mgaFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ GLuint vertex_size = mmesa->vertex_size;
+ GLuint *vb = mgaAllocDmaLow( mmesa, (n-2) * 3 * 4 * vertex_size );
+ GLubyte *vertptr = (GLubyte *)mmesa->verts;
+ const GLuint *start = (const GLuint *)VERT(elts[0]);
+ int i,j;
+
+ for (i = 2 ; i < n ; i++) {
+ EMIT_VERT( j, vb, vertex_size, (mgaVertexPtr) VERT(elts[i-1]) );
+ EMIT_VERT( j, vb, vertex_size, (mgaVertexPtr) VERT(elts[i]) );
+ EMIT_VERT( j, vb, vertex_size, (mgaVertexPtr) start );
+ }
+}
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+
+#define POINT_FALLBACK (DD_POINT_SMOOTH)
+#define LINE_FALLBACK (DD_LINE_SMOOTH | DD_LINE_STIPPLE)
+#define TRI_FALLBACK (DD_TRI_SMOOTH | DD_TRI_UNFILLED)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)
+#define ANY_RASTER_FLAGS (DD_FLATSHADE|DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET| \
+ DD_TRI_UNFILLED)
+
+void mgaChooseRenderState(GLcontext *ctx)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS|DD_TRI_STIPPLE)) {
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= MGA_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= MGA_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= MGA_UNFILLED_BIT;
+ if (flags & DD_FLATSHADE) index |= MGA_FLAT_BIT;
+ }
+
+ mmesa->draw_point = mga_draw_point;
+ mmesa->draw_line = mga_draw_line;
+ mmesa->draw_tri = mga_draw_triangle;
+
+ /* Hook in fallbacks for specific primitives.
+ */
+ if (flags & ANY_FALLBACK_FLAGS)
+ {
+ if (flags & POINT_FALLBACK)
+ mmesa->draw_point = mga_fallback_point;
+
+ if (flags & LINE_FALLBACK)
+ mmesa->draw_line = mga_fallback_line;
+
+ if (flags & TRI_FALLBACK)
+ mmesa->draw_tri = mga_fallback_tri;
+
+ index |= MGA_FALLBACK_BIT;
+ }
+
+ if ((flags & DD_TRI_STIPPLE) && !mmesa->haveHwStipple) {
+ mmesa->draw_tri = mga_fallback_tri;
+ index |= MGA_FALLBACK_BIT;
+ }
+ }
+
+ if (mmesa->RenderIndex != index) {
+ mmesa->RenderIndex = index;
+
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = mga_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = mga_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */
+ tnl->Driver.Render.ClippedPolygon = mgaFastRenderClippedPoly;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = mgaRenderClippedLine;
+ tnl->Driver.Render.ClippedPolygon = mgaRenderClippedPoly;
+ }
+ }
+}
+
+/**********************************************************************/
+/* Runtime render state and callbacks */
+/**********************************************************************/
+
+
+static GLenum reduced_prim[GL_POLYGON+1] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES
+};
+
+
+
+/* Always called between RenderStart and RenderFinish --> We already
+ * hold the lock.
+ */
+void mgaRasterPrimitive( GLcontext *ctx, GLenum prim, GLuint hwprim )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+
+ FLUSH_BATCH( mmesa );
+
+ /* Update culling */
+ if (mmesa->raster_primitive != prim)
+ mmesa->dirty |= MGA_UPLOAD_CONTEXT;
+
+ mmesa->raster_primitive = prim;
+/* mmesa->hw_primitive = hwprim; */
+ mmesa->hw_primitive = MGA_WA_TRIANGLES; /* disable mgarender.c for now */
+
+ if (ctx->Polygon.StippleFlag && mmesa->haveHwStipple)
+ {
+ mmesa->dirty |= MGA_UPLOAD_CONTEXT;
+ mmesa->setup.dwgctl &= ~(0xf<<20);
+ if (mmesa->raster_primitive == GL_TRIANGLES)
+ mmesa->setup.dwgctl |= mmesa->poly_stipple;
+ }
+}
+
+
+
+/* Determine the rasterized primitive when not drawing unfilled
+ * polygons.
+ *
+ * Used only for the default render stage which always decomposes
+ * primitives to trianges/lines/points. For the accelerated stage,
+ * which renders strips as strips, the equivalent calculations are
+ * performed in mgarender.c.
+ */
+static void mgaRenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLuint rprim = reduced_prim[prim];
+
+ mmesa->render_primitive = prim;
+
+ if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ return;
+
+ if (mmesa->raster_primitive != rprim) {
+ mgaRasterPrimitive( ctx, rprim, MGA_WA_TRIANGLES );
+ }
+}
+
+static void mgaRenderFinish( GLcontext *ctx )
+{
+ if (MGA_CONTEXT(ctx)->RenderIndex & MGA_FALLBACK_BIT)
+ _swrast_flush( ctx );
+}
+
+
+
+/**********************************************************************/
+/* Manage total rasterization fallbacks */
+/**********************************************************************/
+
+static const char * const fallbackStrings[] = {
+ "Texture mode",
+ "glDrawBuffer(GL_FRONT_AND_BACK)",
+ "read buffer",
+ "glBlendFunc(GL_SRC_ALPHA_SATURATE, GL_ZERO)",
+ "glRenderMode(selection or feedback)",
+ "No hardware stencil",
+ "glDepthFunc( GL_NEVER )",
+ "Mixing GL_CLAMP_TO_EDGE and GL_CLAMP",
+ "rasterization fallback option"
+};
+
+static const char *getFallbackString(GLuint bit)
+{
+ int i = 0;
+ while (bit > 1) {
+ i++;
+ bit >>= 1;
+ }
+ return fallbackStrings[i];
+}
+
+
+void mgaFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLuint oldfallback = mmesa->Fallback;
+
+ if (mode) {
+ mmesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ FLUSH_BATCH(mmesa);
+ _swsetup_Wakeup( ctx );
+ mmesa->RenderIndex = ~0;
+ if (MGA_DEBUG & DEBUG_VERBOSE_FALLBACK) {
+ fprintf(stderr, "MGA begin rasterization fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ }
+ }
+ else {
+ mmesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = mgaCheckTexSizes;
+ tnl->Driver.Render.PrimitiveNotify = mgaRenderPrimitive;
+ tnl->Driver.Render.Finish = mgaRenderFinish;
+ tnl->Driver.Render.BuildVertices = mgaBuildVertices;
+ mmesa->NewGLState |= (_MGA_NEW_RENDERSTATE |
+ _MGA_NEW_RASTERSETUP);
+ if (MGA_DEBUG & DEBUG_VERBOSE_FALLBACK) {
+ fprintf(stderr, "MGA end rasterization fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ }
+ }
+}
+
+
+void mgaDDInitTriFuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ static int firsttime = 1;
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+ }
+
+ mmesa->RenderIndex = ~0;
+
+ tnl->Driver.Render.Start = mgaCheckTexSizes;
+ tnl->Driver.Render.Finish = mgaRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = mgaRenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = mgaBuildVertices;
+ tnl->Driver.Render.Multipass = NULL;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatris.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatris.h
new file mode 100644
index 000000000..f3ece3a05
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgatris.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgatris.h,v 1.10 2002/10/30 12:51:36 alanh Exp $ */
+
+#ifndef MGATRIS_INC
+#define MGATRIS_INC
+
+#include "mtypes.h"
+
+extern void mgaDDInitTriFuncs( GLcontext *ctx );
+extern void mgaChooseRenderState( GLcontext *ctx );
+extern void mgaRasterPrimitive( GLcontext *ctx, GLenum prim, GLuint hwprim );
+
+extern void mgaFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
+#define FALLBACK( ctx, bit, mode ) mgaFallback( ctx, bit, mode )
+
+#define _MGA_NEW_RENDERSTATE (_DD_NEW_POINT_SMOOTH | \
+ _DD_NEW_LINE_SMOOTH | \
+ _DD_NEW_LINE_STIPPLE | \
+ _DD_NEW_TRI_SMOOTH | \
+ _DD_NEW_FLATSHADE | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_STIPPLE | \
+ _NEW_POLYGONSTIPPLE)
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgavb.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgavb.c
new file mode 100644
index 000000000..902d8bd1c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgavb.c
@@ -0,0 +1,480 @@
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgavb.c,v 1.15 2003/03/26 20:43:49 tsi Exp $ */
+
+#include <stdlib.h>
+#include "mgacontext.h"
+#include "mgavb.h"
+#include "mgatris.h"
+#include "mgaioctl.h"
+#include "mga_xmesa.h"
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "imports.h"
+#include "macros.h"
+#include "colormac.h"
+
+#include "tnl/t_context.h"
+#include "swrast_setup/swrast_setup.h"
+#include "swrast/swrast.h"
+
+
+#define MGA_TEX1_BIT 0x1
+#define MGA_TEX0_BIT 0x2
+#define MGA_RGBA_BIT 0x4
+#define MGA_SPEC_BIT 0x8
+#define MGA_FOG_BIT 0x10
+#define MGA_XYZW_BIT 0x20
+#define MGA_PTEX_BIT 0x40
+#define MGA_MAX_SETUP 0x80
+
+static struct {
+ void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
+ tnl_interp_func interp;
+ tnl_copy_pv_func copy_pv;
+ GLboolean (*check_tex_sizes)( GLcontext *ctx );
+ GLuint vertex_size;
+ GLuint vertex_format;
+} setup_tab[MGA_MAX_SETUP];
+
+
+#define TINY_VERTEX_FORMAT 0
+#define NOTEX_VERTEX_FORMAT 0
+#define TEX0_VERTEX_FORMAT (MGA_A|MGA_S|MGA_F)
+#define TEX1_VERTEX_FORMAT (MGA_A|MGA_S|MGA_F|MGA_T2)
+#define PROJ_TEX1_VERTEX_FORMAT 0
+#define TEX2_VERTEX_FORMAT 0
+#define TEX3_VERTEX_FORMAT 0
+#define PROJ_TEX3_VERTEX_FORMAT 0
+
+#define DO_XYZW (IND & MGA_XYZW_BIT)
+#define DO_RGBA (IND & MGA_RGBA_BIT)
+#define DO_SPEC (IND & MGA_SPEC_BIT)
+#define DO_FOG (IND & MGA_FOG_BIT)
+#define DO_TEX0 (IND & MGA_TEX0_BIT)
+#define DO_TEX1 (IND & MGA_TEX1_BIT)
+#define DO_TEX2 0
+#define DO_TEX3 0
+#define DO_PTEX (IND & MGA_PTEX_BIT)
+
+
+#define VERTEX mgaVertex
+#define VERTEX_COLOR mga_color_t
+#define LOCALVARS mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+#define GET_VIEWPORT_MAT() mmesa->hw_viewport
+#define GET_TEXSOURCE(n) mmesa->tmu_source[n]
+#define GET_VERTEX_FORMAT() mmesa->vertex_format
+#define GET_VERTEX_STORE() mmesa->verts
+#define GET_VERTEX_SIZE() mmesa->vertex_size * sizeof(GLuint)
+
+#define HAVE_HW_VIEWPORT 0
+#define HAVE_HW_DIVIDE 0
+#define HAVE_RGBA_COLOR 0
+#define HAVE_TINY_VERTICES 0
+#define HAVE_NOTEX_VERTICES 0
+#define HAVE_TEX0_VERTICES 1
+#define HAVE_TEX1_VERTICES 1
+#define HAVE_TEX2_VERTICES 0
+#define HAVE_TEX3_VERTICES 0
+#define HAVE_PTEX_VERTICES 0
+
+#define UNVIEWPORT_VARS \
+ const GLfloat dx = - mmesa->drawX - SUBPIXEL_X; \
+ const GLfloat dy = (mmesa->driDrawable->h + \
+ mmesa->drawY + SUBPIXEL_Y); \
+ const GLfloat sz = 1.0 / mmesa->depth_scale
+
+#define UNVIEWPORT_X(x) x + dx;
+#define UNVIEWPORT_Y(y) - y + dy;
+#define UNVIEWPORT_Z(z) z * sz;
+
+#define PTEX_FALLBACK() FALLBACK(ctx, MGA_FALLBACK_TEXTURE, 1)
+
+#define INTERP_VERTEX setup_tab[mmesa->SetupIndex].interp
+#define COPY_PV_VERTEX setup_tab[mmesa->SetupIndex].copy_pv
+
+
+/***********************************************************************
+ * Generate pv-copying and translation functions *
+ ***********************************************************************/
+
+#define TAG(x) mga_##x
+#include "tnl_dd/t_dd_vb.c"
+
+/***********************************************************************
+ * Generate vertex emit and interp functions *
+ ***********************************************************************/
+
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT)
+#define TAG(x) x##_wg
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_SPEC_BIT)
+#define TAG(x) x##_wgs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_wgt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_wgt0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_TEX0_BIT|MGA_PTEX_BIT)
+#define TAG(x) x##_wgpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_wgst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_wgst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT|MGA_PTEX_BIT)
+#define TAG(x) x##_wgspt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_FOG_BIT)
+#define TAG(x) x##_wgf
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT)
+#define TAG(x) x##_wgfs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_wgft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_wgft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_TEX0_BIT|MGA_PTEX_BIT)
+#define TAG(x) x##_wgfpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_wgfst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_wgfst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_XYZW_BIT|MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT|MGA_PTEX_BIT)
+#define TAG(x) x##_wgfspt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_TEX0_BIT)
+#define TAG(x) x##_t0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_t0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_FOG_BIT)
+#define TAG(x) x##_f
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_FOG_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_ft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_FOG_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_ft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_RGBA_BIT)
+#define TAG(x) x##_g
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_RGBA_BIT|MGA_SPEC_BIT)
+#define TAG(x) x##_gs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_RGBA_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_gt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_RGBA_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_gt0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_RGBA_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_gst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_RGBA_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_gst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_RGBA_BIT|MGA_FOG_BIT)
+#define TAG(x) x##_gf
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT)
+#define TAG(x) x##_gfs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_RGBA_BIT|MGA_FOG_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_gft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_RGBA_BIT|MGA_FOG_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_gft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT)
+#define TAG(x) x##_gfst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (MGA_RGBA_BIT|MGA_FOG_BIT|MGA_SPEC_BIT|MGA_TEX0_BIT|MGA_TEX1_BIT)
+#define TAG(x) x##_gfst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+
+static void init_setup_tab( void )
+{
+ init_wg();
+ init_wgs();
+ init_wgt0();
+ init_wgt0t1();
+ init_wgpt0();
+ init_wgst0();
+ init_wgst0t1();
+ init_wgspt0();
+ init_wgf();
+ init_wgfs();
+ init_wgft0();
+ init_wgft0t1();
+ init_wgfpt0();
+ init_wgfst0();
+ init_wgfst0t1();
+ init_wgfspt0();
+ init_t0();
+ init_t0t1();
+ init_f();
+ init_ft0();
+ init_ft0t1();
+ init_g();
+ init_gs();
+ init_gt0();
+ init_gt0t1();
+ init_gst0();
+ init_gst0t1();
+ init_gf();
+ init_gfs();
+ init_gft0();
+ init_gft0t1();
+ init_gfst0();
+ init_gfst0t1();
+}
+
+
+
+
+void mgaPrintSetupFlags(char *msg, GLuint flags )
+{
+ fprintf(stderr, "%s: %d %s%s%s%s%s%s\n",
+ msg,
+ (int)flags,
+ (flags & MGA_XYZW_BIT) ? " xyzw," : "",
+ (flags & MGA_RGBA_BIT) ? " rgba," : "",
+ (flags & MGA_SPEC_BIT) ? " spec," : "",
+ (flags & MGA_FOG_BIT) ? " fog," : "",
+ (flags & MGA_TEX0_BIT) ? " tex-0," : "",
+ (flags & MGA_TEX1_BIT) ? " tex-1," : "");
+}
+
+
+void mgaCheckTexSizes( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ /*fprintf(stderr, "%s\n", __FUNCTION__);*/
+
+ if (!setup_tab[mmesa->SetupIndex].check_tex_sizes(ctx)) {
+ mmesa->SetupIndex |= MGA_PTEX_BIT;
+ mmesa->SetupNewInputs = ~0;
+
+ if (!mmesa->Fallback &&
+ !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ tnl->Driver.Render.Interp = setup_tab[mmesa->SetupIndex].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[mmesa->SetupIndex].copy_pv;
+ }
+ if (mmesa->Fallback) {
+ tnl->Driver.Render.Start(ctx);
+ }
+ }
+}
+
+
+void mgaBuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ GLuint stride = mmesa->vertex_size * sizeof(int);
+ GLubyte *v = ((GLubyte *)mmesa->verts + (start * stride));
+
+ newinputs |= mmesa->SetupNewInputs;
+ mmesa->SetupNewInputs = 0;
+
+ if (!newinputs)
+ return;
+
+ if (newinputs & VERT_BIT_POS) {
+ setup_tab[mmesa->SetupIndex].emit( ctx, start, count, v, stride );
+ } else {
+ GLuint ind = 0;
+
+ if (newinputs & VERT_BIT_COLOR0)
+ ind |= MGA_RGBA_BIT;
+
+ if (newinputs & VERT_BIT_COLOR1)
+ ind |= MGA_SPEC_BIT;
+
+ if (newinputs & VERT_BIT_TEX0)
+ ind |= MGA_TEX0_BIT;
+
+ if (newinputs & VERT_BIT_TEX1)
+ ind |= MGA_TEX0_BIT|MGA_TEX1_BIT;
+
+ if (newinputs & VERT_BIT_FOG)
+ ind |= MGA_FOG_BIT;
+
+ if (mmesa->SetupIndex & MGA_PTEX_BIT)
+ ind = ~0;
+
+ ind &= mmesa->SetupIndex;
+
+ if (ind) {
+ setup_tab[ind].emit( ctx, start, count, v, stride );
+ }
+ }
+}
+
+
+void mgaChooseVertexState( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint ind = MGA_XYZW_BIT|MGA_RGBA_BIT;
+
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ ind |= MGA_SPEC_BIT;
+
+ if (ctx->Fog.Enabled)
+ ind |= MGA_FOG_BIT;
+
+ if (ctx->Texture._EnabledUnits & 0x2) {
+ /* unit 1 enabled */
+ if (ctx->Texture._EnabledUnits & 0x1) {
+ /* unit 0 enabled */
+ ind |= MGA_TEX1_BIT|MGA_TEX0_BIT;
+ }
+ else {
+ ind |= MGA_TEX0_BIT;
+ }
+ }
+ else if (ctx->Texture._EnabledUnits & 0x1) {
+ /* unit 0 enabled */
+ ind |= MGA_TEX0_BIT;
+ }
+
+ mmesa->SetupIndex = ind;
+
+ if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
+ tnl->Driver.Render.Interp = mga_interp_extras;
+ tnl->Driver.Render.CopyPV = mga_copy_pv_extras;
+ } else {
+ tnl->Driver.Render.Interp = setup_tab[ind].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
+ }
+
+ if (setup_tab[ind].vertex_format != mmesa->vertex_format) {
+ FLUSH_BATCH(mmesa);
+ mmesa->dirty |= MGA_UPLOAD_PIPE;
+ mmesa->vertex_format = setup_tab[ind].vertex_format;
+ mmesa->vertex_size = setup_tab[ind].vertex_size;
+ }
+}
+
+
+
+void *mga_emit_contiguous_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ void *dest)
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLuint stride = mmesa->vertex_size * 4;
+ setup_tab[mmesa->SetupIndex].emit( ctx, start, count, dest, stride );
+ return (void *)((char *)dest + stride * (count - start));
+}
+
+
+
+void mgaInitVB( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ GLuint size = TNL_CONTEXT(ctx)->vb.Size;
+
+ mmesa->verts = (GLubyte *)ALIGN_MALLOC(size * sizeof(mgaVertex), 32);
+
+ {
+ static int firsttime = 1;
+ if (firsttime) {
+ init_setup_tab();
+ firsttime = 0;
+ }
+ }
+
+ mmesa->dirty |= MGA_UPLOAD_PIPE;
+ mmesa->vertex_format = setup_tab[0].vertex_format;
+ mmesa->vertex_size = setup_tab[0].vertex_size;
+}
+
+
+void mgaFreeVB( GLcontext *ctx )
+{
+ mgaContextPtr mmesa = MGA_CONTEXT(ctx);
+ if (mmesa->verts) {
+ ALIGN_FREE(mmesa->verts);
+ mmesa->verts = 0;
+ }
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgavb.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgavb.h
new file mode 100644
index 000000000..5f6454aca
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/mgavb.h
@@ -0,0 +1,66 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgavb.h,v 1.8 2002/10/30 12:51:36 alanh Exp $ */
+/*
+ * Copyright 2000-2001 VA Linux Systems, Inc.
+ * 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef MGAVB_INC
+#define MGAVB_INC
+
+#include "mtypes.h"
+#include "mgacontext.h"
+#include "swrast/swrast.h"
+
+#define _MGA_NEW_RASTERSETUP (_NEW_TEXTURE | \
+ _DD_NEW_SEPARATE_SPECULAR | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _NEW_FOG)
+
+
+extern void mgaChooseVertexState( GLcontext *ctx );
+extern void mgaCheckTexSizes( GLcontext *ctx );
+extern void mgaBuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs );
+
+extern void mgaPrintSetupFlags(char *msg, GLuint flags );
+
+extern void mgaInitVB( GLcontext *ctx );
+extern void mgaFreeVB( GLcontext *ctx );
+
+extern void *mga_emit_contiguous_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ void *dest );
+
+extern void mga_translate_vertex(GLcontext *ctx,
+ const mgaVertex *src,
+ SWvertex *dst);
+
+extern void mga_print_vertex( GLcontext *ctx, const mgaVertex *v );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga.h
new file mode 100644
index 000000000..830d48d85
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga.h
@@ -0,0 +1,115 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h,v 1.85 2002/12/16 16:19:17 dawes Exp $ */
+/*
+ * MGA Millennium (MGA2064W) functions
+ *
+ * Copyright 1996 The XFree86 Project, Inc.
+ *
+ * Authors
+ * Dirk Hohndel
+ * hohndel@XFree86.Org
+ * David Dawes
+ * dawes@XFree86.Org
+ */
+
+#ifndef MGA_H
+#define MGA_H
+
+
+#include "xf86drm.h"
+#include "linux/types.h"
+
+
+#define PCI_CHIP_MGA2085 0x0518
+#define PCI_CHIP_MGA2064 0x0519
+#define PCI_CHIP_MGA1064 0x051A
+#define PCI_CHIP_MGA2164 0x051B
+#define PCI_CHIP_MGA2164_AGP 0x051F
+#define PCI_CHIP_MGAG200_PCI 0x0520
+#define PCI_CHIP_MGAG200 0x0521
+#define PCI_CHIP_MGAG400 0x0525
+#define PCI_CHIP_MGAG550 0x2527
+#define PCI_CHIP_MGAG100_PCI 0x1000
+#define PCI_CHIP_MGAG100 0x1001
+
+
+# define MMIO_IN8(base, offset) \
+ *(volatile unsigned char *)(((unsigned char*)(base)) + (offset))
+# define MMIO_IN16(base, offset) \
+ *(volatile unsigned short *)(void *)(((unsigned char*)(base)) + (offset))
+# define MMIO_IN32(base, offset) \
+ *(volatile unsigned int *)(void *)(((unsigned char*)(base)) + (offset))
+# define MMIO_OUT8(base, offset, val) \
+ *(volatile unsigned char *)(((unsigned char*)(base)) + (offset)) = (val)
+# define MMIO_OUT16(base, offset, val) \
+ *(volatile unsigned short *)(void *)(((unsigned char*)(base)) + (offset)) = (val)
+# define MMIO_OUT32(base, offset, val) \
+ *(volatile unsigned int *)(void *)(((unsigned char*)(base)) + (offset)) = (val)
+
+#define INREG8(addr) MMIO_IN8(pMga->IOBase, addr)
+#define INREG16(addr) MMIO_IN16(pMga->IOBase, addr)
+#define INREG(addr) MMIO_IN32(pMga->IOBase, addr)
+#define OUTREG8(addr, val) MMIO_OUT8(pMga->IOBase, addr, val)
+#define OUTREG16(addr, val) MMIO_OUT16(pMga->IOBase, addr, val)
+#define OUTREG(addr, val) MMIO_OUT32(pMga->IOBase, addr, val)
+
+#define MGAIOMAPSIZE 0x00004000
+
+
+typedef struct {
+ int Chipset; /**< \brief Chipset number */
+
+ int irq; /**< \brief IRQ number */
+
+
+ int frontOffset; /**< \brief Front color buffer offset */
+ int frontPitch; /**< \brief Front color buffer pitch */
+ int backOffset; /**< \brief Back color buffer offset */
+ int backPitch; /**< \brief Back color buffer pitch */
+ int depthOffset; /**< \brief Depth buffer offset */
+ int depthPitch; /**< \brief Depth buffer pitch */
+ int textureOffset; /**< \brief Texture area offset */
+ int textureSize; /**< \brief Texture area size */
+ int logTextureGranularity;
+
+ /**
+ * \name AGP
+ */
+ /*@{*/
+ drmSize agpSize; /**< \brief AGP map size */
+ int agpMode; /**< \brief AGP mode */
+ /*@}*/
+
+ drmRegion agp;
+
+ /* PCI mappings */
+ drmRegion registers;
+ drmRegion status;
+
+ /* AGP mappings */
+ drmRegion warp;
+ drmRegion primary;
+ drmRegion buffers;
+ drmRegion agpTextures;
+
+ drmBufMapPtr drmBuffers;
+
+ unsigned long IOAddress;
+ unsigned char *IOBase;
+ int HasSDRAM;
+
+ __u32 reg_ien;
+} MGARec, *MGAPtr;
+
+
+
+#define MGA_FRONT 0x1
+#define MGA_BACK 0x2
+#define MGA_DEPTH 0x4
+
+#define MGA_AGP_1X_MODE 0x01
+#define MGA_AGP_2X_MODE 0x02
+#define MGA_AGP_4X_MODE 0x04
+#define MGA_AGP_MODE_MASK 0x07
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_bios.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_bios.h
new file mode 100644
index 000000000..8fbf619e3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_bios.h
@@ -0,0 +1,143 @@
+/* $XConsortium: mga_bios.h /main/2 1996/10/28 04:48:23 kaleb $ */
+#ifndef MGA_BIOS_H
+#define MGA_BIOS_H
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_bios.h,v 1.3 1998/07/25 16:55:51 dawes Exp $ */
+
+/*
+ * MGABiosInfo - This struct describes the video BIOS info block.
+ *
+ * DESCRIPTION
+ * Do not mess with this, unless you know what you are doing.
+ * The data lengths and types are critical.
+ *
+ * HISTORY
+ * October 7, 1996 - [aem] Andrew E. Mileski
+ * This struct was shamelessly stolen from the MGA DDK.
+ * It has been reformatted, and the data types changed.
+ */
+typedef struct {
+ /* Length of this structure in bytes */
+ __u16 StructLen;
+
+ /*
+ * Unique number identifying the product type
+ * 0 : MGA-S1P20 (2MB base with 175MHz Ramdac)
+ * 1 : MGA-S1P21 (2MB base with 220MHz Ramdac)
+ * 2 : Reserved
+ * 3 : Reserved
+ * 4 : MGA-S1P40 (4MB base with 175MHz Ramdac)
+ * 5 : MGA-S1P41 (4MB base with 220MHz Ramdac)
+ */
+ __u16 ProductID;
+
+ /* Serial number of the board */
+ __u8 SerNo[ 10 ];
+
+ /*
+ * Manufacturing date of the board (at product test)
+ * Format: yyyy yyym mmmd dddd
+ */
+ __u16 ManufDate;
+
+ /* Identification of manufacturing site */
+ __u16 ManufId;
+
+ /*
+ * Number and revision level of the PCB
+ * Format: nnnn nnnn nnnr rrrr
+ * n = PCB number ex:576 (from 0->2047)
+ * r = PCB revision (from 0->31)
+ */
+ __u16 PCBInfo;
+
+ /* Identification of any PMBs */
+ __u16 PMBInfo;
+
+ /*
+ * Bit 0-7 : Ramdac speed (0=175MHz, 1=220MHz)
+ * Bit 8-15 : Ramdac type (0=TVP3026, 1=TVP3027)
+ */
+ __u16 RamdacType;
+
+ /* Maximum PCLK of the ramdac */
+ __u16 PclkMax;
+
+ /* Maximum LDCLK supported by the WRAM memory */
+ __u16 LclkMax;
+
+ /* Maximum MCLK of base board */
+ __u16 ClkBase;
+
+ /* Maximum MCLK of 4Mb board */
+ __u16 Clk4MB;
+
+ /* Maximum MCLK of 8Mb board */
+ __u16 Clk8MB;
+
+ /* Maximum MCLK of board with multimedia module */
+ __u16 ClkMod;
+
+ /* Diagnostic test pass frequency */
+ __u16 TestClk;
+
+ /* Default VGA mode1 pixel frequency */
+ __u16 VGAFreq1;
+
+ /* Default VGA mode2 pixel frequency */
+ __u16 VGAFreq2;
+
+ /* Date of last BIOS programming/update */
+ __u16 ProgramDate;
+
+ /* Number of times BIOS has been programmed */
+ __u16 ProgramCnt;
+
+ /* Support for up to 32 hardware/software options */
+ __u32 Options;
+
+ /* Support for up to 32 hardware/software features */
+ __u32 FeatFlag;
+
+ /* Definition of VGA mode MCLK */
+ __u16 VGAClk;
+
+ /* Indicate the revision level of this header struct */
+ __u16 StructRev;
+
+ __u16 Reserved[ 3 ];
+} MGABiosInfo;
+
+/* from the PINS structure, refer pins info from MGA */
+typedef struct tagParamMGA {
+ __u16 PinID; /* 0 */
+ __u8 StructLen; /* 2 */
+ __u8 Rsvd1; /* 3 */
+ __u16 StructRev; /* 4 */
+ __u16 ProgramDate; /* 6 */
+ __u16 ProgramCnt; /* 8 */
+ __u16 ProductID; /* 10 */
+ __u8 SerNo[16]; /* 12 */
+ __u8 PLInfo[6]; /* 28 */
+ __u16 PCBInfo; /* 34 */
+ __u32 FeatFlag; /* 36 */
+ __u8 RamdacType; /* 40 */
+ __u8 RamdacSpeed; /* 41 */
+ __u8 PclkMax; /* 42 */
+ __u8 ClkGE; /* 43 */
+ __u8 ClkMem; /* 44 */
+ __u8 Clk4MB; /* 45 */
+ __u8 Clk8MB; /* 46 */
+ __u8 ClkMod; /* 47 */
+ __u8 TestClk; /* 48 */
+ __u8 VGAFreq1; /* 49 */
+ __u8 VGAFreq2; /* 50 */
+ __u8 MCTLWTST; /* 51 */
+ __u8 VidCtrl; /* 52 */
+ __u8 Clk12MB; /* 53 */
+ __u8 Clk16MB; /* 54 */
+ __u8 Reserved[8]; /* 55-62 */
+ __u8 PinCheck; /* 63 */
+} MGABios2Info;
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_dri.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_dri.c
new file mode 100644
index 000000000..258ace83a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_dri.c
@@ -0,0 +1,1089 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c,v 1.28 2003/02/08 21:26:58 dawes Exp $ */
+
+/*
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ * Gareth Hughes <gareth@valinux.com>
+ */
+
+#include <errno.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <inttypes.h>
+
+#include "driver.h"
+#include "drm.h"
+#include "memops.h"
+
+#include "mga_reg.h"
+#include "mga.h"
+#include "mga_macros.h"
+#include "mga_dri.h"
+
+
+/* Quiescence, locking
+ */
+#define MGA_TIMEOUT 2048
+
+static void MGAWaitForIdleDMA( struct DRIDriverContextRec *ctx, MGAPtr pMga )
+{
+ drm_lock_t lock;
+ int ret;
+ int i = 0;
+
+ memset( &lock, 0, sizeof(lock) );
+
+ for (;;) {
+ do {
+ /* first ask for quiescent and flush */
+ lock.flags = DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH;
+ do {
+ ret = drmCommandWrite( ctx->drmFD, DRM_MGA_FLUSH,
+ &lock, sizeof( lock ) );
+ } while ( ret == -EBUSY && i++ < DRM_MGA_IDLE_RETRY );
+
+ /* if it's still busy just try quiescent */
+ if ( ret == -EBUSY ) {
+ lock.flags = DRM_LOCK_QUIESCENT;
+ do {
+ ret = drmCommandWrite( ctx->drmFD, DRM_MGA_FLUSH,
+ &lock, sizeof( lock ) );
+ } while ( ret == -EBUSY && i++ < DRM_MGA_IDLE_RETRY );
+ }
+ } while ( ( ret == -EBUSY ) && ( i++ < MGA_TIMEOUT ) );
+
+ if ( ret == 0 )
+ return;
+
+ fprintf( stderr,
+ "[dri] Idle timed out, resetting engine...\n" );
+
+ drmCommandNone( ctx->drmFD, DRM_MGA_RESET );
+ }
+}
+
+static unsigned int mylog2( unsigned int n )
+{
+ unsigned int log2 = 1;
+ while ( n > 1 ) n >>= 1, log2++;
+ return log2;
+}
+
+static int MGADRIAgpInit(struct DRIDriverContextRec *ctx, MGAPtr pMga)
+{
+ unsigned long mode;
+ unsigned int vendor, device;
+ int ret, count, i;
+
+ if(pMga->agpSize < 12)pMga->agpSize = 12;
+ if(pMga->agpSize > 64)pMga->agpSize = 64; /* cap */
+
+ /* FIXME: Make these configurable...
+ */
+ pMga->agp.size = pMga->agpSize * 1024 * 1024;
+
+ pMga->warp.offset = 0;
+ pMga->warp.size = MGA_WARP_UCODE_SIZE;
+
+ pMga->primary.offset = (pMga->warp.offset +
+ pMga->warp.size);
+ pMga->primary.size = 1024 * 1024;
+
+ pMga->buffers.offset = (pMga->primary.offset +
+ pMga->primary.size);
+ pMga->buffers.size = MGA_NUM_BUFFERS * MGA_BUFFER_SIZE;
+
+
+ pMga->agpTextures.offset = (pMga->buffers.offset +
+ pMga->buffers.size);
+
+ pMga->agpTextures.size = pMga->agp.size -
+ pMga->agpTextures.offset;
+
+ if ( drmAgpAcquire( ctx->drmFD ) < 0 ) {
+ fprintf( stderr, "[agp] AGP not available\n" );
+ return 0;
+ }
+
+ mode = drmAgpGetMode( ctx->drmFD ); /* Default mode */
+ vendor = drmAgpVendorId( ctx->drmFD );
+ device = drmAgpDeviceId( ctx->drmFD );
+
+ mode &= ~MGA_AGP_MODE_MASK;
+ switch ( pMga->agpMode ) {
+ case 4:
+ mode |= MGA_AGP_4X_MODE;
+ case 2:
+ mode |= MGA_AGP_2X_MODE;
+ case 1:
+ default:
+ mode |= MGA_AGP_1X_MODE;
+ }
+
+#if 0
+ fprintf( stderr,
+ "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n",
+ mode, vendor, device,
+ ctx->pciVendor,
+ ctx->pciChipType );
+#endif
+
+ if ( drmAgpEnable( ctx->drmFD, mode ) < 0 ) {
+ fprintf( stderr, "[agp] AGP not enabled\n" );
+ drmAgpRelease( ctx->drmFD );
+ return 0;
+ }
+
+ if ( pMga->Chipset == PCI_CHIP_MGAG200 ) {
+ switch ( pMga->agpMode ) {
+ case 2:
+ fprintf( stderr,
+ "[drm] Enabling AGP 2x PLL encoding\n" );
+ OUTREG( MGAREG_AGP_PLL, MGA_AGP2XPLL_ENABLE );
+ break;
+
+ case 1:
+ default:
+ fprintf( stderr,
+ "[drm] Disabling AGP 2x PLL encoding\n" );
+ OUTREG( MGAREG_AGP_PLL, MGA_AGP2XPLL_DISABLE );
+ pMga->agpMode = 1;
+ break;
+ }
+ }
+
+ ret = drmAgpAlloc( ctx->drmFD, pMga->agp.size,
+ 0, NULL, &pMga->agp.handle );
+ if ( ret < 0 ) {
+ fprintf( stderr, "[agp] Out of memory (%d)\n", ret );
+ drmAgpRelease( ctx->drmFD );
+ return 0;
+ }
+ fprintf( stderr,
+ "[agp] %d kB allocated with handle 0x%08x\n",
+ pMga->agp.size/1024, (unsigned int)pMga->agp.handle );
+
+ if ( drmAgpBind( ctx->drmFD, pMga->agp.handle, 0 ) < 0 ) {
+ fprintf( stderr, "[agp] Could not bind memory\n" );
+ drmAgpFree( ctx->drmFD, pMga->agp.handle );
+ drmAgpRelease( ctx->drmFD );
+ return 0;
+ }
+
+ /* WARP microcode space
+ */
+ if ( drmAddMap( ctx->drmFD,
+ pMga->warp.offset,
+ pMga->warp.size,
+ DRM_AGP, DRM_READ_ONLY,
+ &pMga->warp.handle ) < 0 ) {
+ fprintf( stderr,
+ "[agp] Could not add WARP microcode mapping\n" );
+ return 0;
+ }
+ fprintf( stderr,
+ "[agp] WARP microcode handle = 0x%08x\n",
+ pMga->warp.handle );
+
+ if ( drmMap( ctx->drmFD,
+ pMga->warp.handle,
+ pMga->warp.size,
+ &pMga->warp.map ) < 0 ) {
+ fprintf( stderr,
+ "[agp] Could not map WARP microcode\n" );
+ return 0;
+ }
+ fprintf( stderr,
+ "[agp] WARP microcode mapped at 0x%08lx\n",
+ (unsigned long)pMga->warp.map );
+
+ /* Primary DMA space
+ */
+ if ( drmAddMap( ctx->drmFD,
+ pMga->primary.offset,
+ pMga->primary.size,
+ DRM_AGP, DRM_READ_ONLY,
+ &pMga->primary.handle ) < 0 ) {
+ fprintf( stderr,
+ "[agp] Could not add primary DMA mapping\n" );
+ return 0;
+ }
+ fprintf( stderr,
+ "[agp] Primary DMA handle = 0x%08x\n",
+ pMga->primary.handle );
+
+ if ( drmMap( ctx->drmFD,
+ pMga->primary.handle,
+ pMga->primary.size,
+ &pMga->primary.map ) < 0 ) {
+ fprintf( stderr,
+ "[agp] Could not map primary DMA\n" );
+ return 0;
+ }
+ fprintf( stderr,
+ "[agp] Primary DMA mapped at 0x%08lx\n",
+ (unsigned long)pMga->primary.map );
+
+ /* DMA buffers
+ */
+ if ( drmAddMap( ctx->drmFD,
+ pMga->buffers.offset,
+ pMga->buffers.size,
+ DRM_AGP, 0,
+ &pMga->buffers.handle ) < 0 ) {
+ fprintf( stderr,
+ "[agp] Could not add DMA buffers mapping\n" );
+ return 0;
+ }
+ fprintf( stderr,
+ "[agp] DMA buffers handle = 0x%08x\n",
+ pMga->buffers.handle );
+
+ if ( drmMap( ctx->drmFD,
+ pMga->buffers.handle,
+ pMga->buffers.size,
+ &pMga->buffers.map ) < 0 ) {
+ fprintf( stderr,
+ "[agp] Could not map DMA buffers\n" );
+ return 0;
+ }
+ fprintf( stderr,
+ "[agp] DMA buffers mapped at 0x%08lx\n",
+ (unsigned long)pMga->buffers.map );
+
+ count = drmAddBufs( ctx->drmFD,
+ MGA_NUM_BUFFERS, MGA_BUFFER_SIZE,
+ DRM_AGP_BUFFER, pMga->buffers.offset );
+ if ( count <= 0 ) {
+ fprintf( stderr,
+ "[drm] failure adding %d %d byte DMA buffers\n",
+ MGA_NUM_BUFFERS, MGA_BUFFER_SIZE );
+ return 0;
+ }
+ fprintf( stderr,
+ "[drm] Added %d %d byte DMA buffers\n",
+ count, MGA_BUFFER_SIZE );
+
+ i = mylog2(pMga->agpTextures.size / MGA_NR_TEX_REGIONS);
+ if(i < MGA_LOG_MIN_TEX_REGION_SIZE)
+ i = MGA_LOG_MIN_TEX_REGION_SIZE;
+ pMga->agpTextures.size = (pMga->agpTextures.size >> i) << i;
+
+ if ( drmAddMap( ctx->drmFD,
+ pMga->agpTextures.offset,
+ pMga->agpTextures.size,
+ DRM_AGP, 0,
+ &pMga->agpTextures.handle ) < 0 ) {
+ fprintf( stderr,
+ "[agp] Could not add agpTexture mapping\n" );
+ return 0;
+ }
+/* should i map it ? */
+ fprintf( stderr,
+ "[agp] agpTexture handle = 0x%08x\n",
+ pMga->agpTextures.handle );
+ fprintf( stderr,
+ "[agp] agpTexture size: %d kb\n", pMga->agpTextures.size/1024 );
+
+ return 1;
+}
+
+static int MGADRIMapInit( struct DRIDriverContextRec *ctx, MGAPtr pMga )
+{
+ pMga->registers.size = MGAIOMAPSIZE;
+
+ if ( drmAddMap( ctx->drmFD,
+ (drm_handle_t)pMga->IOAddress,
+ pMga->registers.size,
+ DRM_REGISTERS, DRM_READ_ONLY,
+ &pMga->registers.handle ) < 0 ) {
+ fprintf( stderr,
+ "[drm] Could not add MMIO registers mapping\n" );
+ return 0;
+ }
+ fprintf( stderr,
+ "[drm] Registers handle = 0x%08lx\n",
+ pMga->registers.handle );
+
+ pMga->status.size = SAREA_MAX;
+
+ if ( drmAddMap( ctx->drmFD, 0, pMga->status.size,
+ DRM_SHM, DRM_READ_ONLY | DRM_LOCKED | DRM_KERNEL,
+ &pMga->status.handle ) < 0 ) {
+ fprintf( stderr,
+ "[drm] Could not add status page mapping\n" );
+ return 0;
+ }
+ fprintf( stderr,
+ "[drm] Status handle = 0x%08x\n",
+ pMga->status.handle );
+
+ if ( drmMap( ctx->drmFD,
+ pMga->status.handle,
+ pMga->status.size,
+ &pMga->status.map ) < 0 ) {
+ fprintf( stderr,
+ "[agp] Could not map status page\n" );
+ return 0;
+ }
+ fprintf( stderr,
+ "[agp] Status page mapped at 0x%08lx\n",
+ (unsigned long)pMga->status.map );
+
+ return 1;
+}
+
+static int MGADRIKernelInit( struct DRIDriverContextRec *ctx, MGAPtr pMga )
+{
+ drm_mga_init_t init;
+ int ret;
+
+ memset( &init, 0, sizeof(init) );
+
+ init.func = MGA_INIT_DMA;
+ init.sarea_priv_offset = sizeof(drm_sarea_t);
+
+ switch ( pMga->Chipset ) {
+ case PCI_CHIP_MGAG550:
+ case PCI_CHIP_MGAG400:
+ init.chipset = MGA_CARD_TYPE_G400;
+ break;
+ case PCI_CHIP_MGAG200:
+ case PCI_CHIP_MGAG200_PCI:
+ init.chipset = MGA_CARD_TYPE_G200;
+ break;
+ default:
+ return 0;
+ }
+
+ init.sgram = 0; /* FIXME !pMga->HasSDRAM; */
+
+
+ switch (ctx->bpp)
+ {
+ case 16:
+ init.maccess = MGA_MACCESS_PW16;
+ break;
+ case 32:
+ init.maccess = MGA_MACCESS_PW32;
+ break;
+ default:
+ fprintf( stderr, "[mga] invalid bpp (%d)\n", ctx->bpp );
+ return 0;
+ }
+
+
+ init.fb_cpp = ctx->bpp / 8;
+ init.front_offset = pMga->frontOffset;
+ init.front_pitch = pMga->frontPitch / init.fb_cpp;
+ init.back_offset = pMga->backOffset;
+ init.back_pitch = pMga->backPitch / init.fb_cpp;
+
+ init.depth_cpp = ctx->bpp / 8;
+ init.depth_offset = pMga->depthOffset;
+ init.depth_pitch = pMga->depthPitch / init.depth_cpp;
+
+ init.texture_offset[0] = pMga->textureOffset;
+ init.texture_size[0] = pMga->textureSize;
+
+ init.fb_offset = ctx->shared.hFrameBuffer;
+ init.mmio_offset = pMga->registers.handle;
+ init.status_offset = pMga->status.handle;
+
+ init.warp_offset = pMga->warp.handle;
+ init.primary_offset = pMga->primary.handle;
+ init.buffers_offset = pMga->buffers.handle;
+
+ init.texture_offset[1] = pMga->agpTextures.handle;
+ init.texture_size[1] = pMga->agpTextures.size;
+
+ ret = drmCommandWrite( ctx->drmFD, DRM_MGA_INIT, &init, sizeof(init));
+ if ( ret < 0 ) {
+ fprintf( stderr,
+ "[drm] Failed to initialize DMA! (%d)\n", ret );
+ return 0;
+ }
+
+ return 1;
+}
+
+static void MGADRIIrqInit(struct DRIDriverContextRec *ctx, MGAPtr pMga)
+{
+ if (!pMga->irq)
+ {
+ pMga->irq = drmGetInterruptFromBusID(ctx->drmFD,
+ ctx->pciBus,
+ ctx->pciDevice,
+ ctx->pciFunc);
+
+ fprintf(stderr, "[drm] got IRQ %d\n", pMga->irq);
+
+ if((drmCtlInstHandler(ctx->drmFD, pMga->irq)) != 0)
+ {
+ fprintf(stderr,
+ "[drm] failure adding irq handler, "
+ "there is a device already using that irq\n"
+ "[drm] falling back to irq-free operation\n");
+ pMga->irq = 0;
+ }
+ else
+ {
+ pMga->reg_ien = INREG( MGAREG_IEN );
+ }
+ }
+
+ if (pMga->irq)
+ fprintf(stderr,
+ "[drm] dma control initialized, using IRQ %d\n",
+ pMga->irq);
+}
+
+static int MGADRIBuffersInit( struct DRIDriverContextRec *ctx, MGAPtr pMga )
+{
+ pMga->drmBuffers = drmMapBufs( ctx->drmFD );
+ if ( !pMga->drmBuffers )
+ {
+ fprintf( stderr,
+ "[drm] Failed to map DMA buffers list\n" );
+ return 0;
+ }
+
+ fprintf( stderr,
+ "[drm] Mapped %d DMA buffers\n",
+ pMga->drmBuffers->count );
+
+ return 1;
+}
+
+static int MGAMemoryInit( struct DRIDriverContextRec *ctx, MGAPtr pMga )
+{
+ int width_bytes = ctx->shared.virtualWidth * ctx->cpp;
+ int bufferSize = ((ctx->shared.virtualHeight * width_bytes
+ + MGA_BUFFER_ALIGN)
+ & ~MGA_BUFFER_ALIGN);
+ int depthSize = ((((ctx->shared.virtualHeight+15) & ~15) * width_bytes
+ + MGA_BUFFER_ALIGN)
+ & ~MGA_BUFFER_ALIGN);
+ int l;
+
+ pMga->frontOffset = 0;
+ pMga->frontPitch = ctx->shared.virtualWidth * ctx->cpp;
+
+ fprintf(stderr,
+ "Using %d MB AGP aperture\n", pMga->agpSize);
+ fprintf(stderr,
+ "Using %d MB for vertex/indirect buffers\n", pMga->buffers.size>>20);
+ fprintf(stderr,
+ "Using %d MB for AGP textures\n", pMga->agpTextures.size>>20);
+
+ /* Front, back and depth buffers - everything else texture??
+ */
+ pMga->textureSize = ctx->shared.fbSize - 2 * bufferSize - depthSize;
+
+ if (pMga->textureSize < 0)
+ return 0;
+
+ l = mylog2( pMga->textureSize / MGA_NR_TEX_REGIONS );
+ if ( l < MGA_LOG_MIN_TEX_REGION_SIZE )
+ l = MGA_LOG_MIN_TEX_REGION_SIZE;
+
+ /* Round the texture size up to the nearest whole number of
+ * texture regions. Again, be greedy about this, don't
+ * round down.
+ */
+ pMga->logTextureGranularity = l;
+ pMga->textureSize = (pMga->textureSize >> l) << l;
+
+ /* Set a minimum usable local texture heap size. This will fit
+ * two 256x256x32bpp textures.
+ */
+ if (pMga->textureSize < 512 * 1024) {
+ pMga->textureOffset = 0;
+ pMga->textureSize = 0;
+ }
+
+ /* Reserve space for textures */
+ pMga->textureOffset = ((ctx->shared.fbSize - pMga->textureSize +
+ MGA_BUFFER_ALIGN) &
+ ~MGA_BUFFER_ALIGN);
+
+ /* Reserve space for the shared depth
+ * buffer.
+ */
+ pMga->depthOffset = ((pMga->textureOffset - depthSize +
+ MGA_BUFFER_ALIGN) &
+ ~MGA_BUFFER_ALIGN);
+ pMga->depthPitch = ctx->shared.virtualWidth * ctx->cpp;
+
+ pMga->backOffset = ((pMga->depthOffset - bufferSize +
+ MGA_BUFFER_ALIGN) &
+ ~MGA_BUFFER_ALIGN);
+ pMga->backPitch = ctx->shared.virtualWidth * ctx->cpp;
+
+
+ fprintf(stderr,
+ "Will use back buffer at offset 0x%x\n",
+ pMga->backOffset);
+ fprintf(stderr,
+ "Will use depth buffer at offset 0x%x\n",
+ pMga->depthOffset);
+ fprintf(stderr,
+ "Will use %d kb for textures at offset 0x%x\n",
+ pMga->textureSize/1024, pMga->textureOffset);
+
+ return 1;
+}
+
+static int MGACheckDRMVersion( struct DRIDriverContextRec *ctx, MGAPtr pMga )
+{
+ drmVersionPtr version;
+
+ /* Check the MGA DRM version */
+ version = drmGetVersion(ctx->drmFD);
+ if ( version ) {
+ if ( version->version_major != 3 ||
+ version->version_minor < 0 ) {
+ /* incompatible drm version */
+ fprintf( stderr,
+ "[dri] MGADRIScreenInit failed because of a version mismatch.\n"
+ "[dri] mga.o kernel module version is %d.%d.%d but version 3.0.x is needed.\n"
+ "[dri] Disabling DRI.\n",
+ version->version_major,
+ version->version_minor,
+ version->version_patchlevel );
+ drmFreeVersion( version );
+ return 0;
+ }
+ drmFreeVersion( version );
+ }
+
+ return 1;
+}
+
+static void print_client_msg( MGADRIPtr pMGADRI )
+{
+ fprintf( stderr, "chipset: %d\n", pMGADRI->chipset );
+
+ fprintf( stderr, "width: %d\n", pMGADRI->width );
+ fprintf( stderr, "height: %d\n", pMGADRI->height );
+ fprintf( stderr, "mem: %d\n", pMGADRI->mem );
+ fprintf( stderr, "cpp: %d\n", pMGADRI->cpp );
+
+ fprintf( stderr, "agpMode: %d\n", pMGADRI->agpMode );
+
+ fprintf( stderr, "frontOffset: %d\n", pMGADRI->frontOffset );
+ fprintf( stderr, "frontPitch: %d\n", pMGADRI->frontPitch );
+
+ fprintf( stderr, "backOffset: %d\n", pMGADRI->backOffset );
+ fprintf( stderr, "backPitch: %d\n", pMGADRI->backPitch );
+
+ fprintf( stderr, "depthOffset: %d\n", pMGADRI->depthOffset );
+ fprintf( stderr, "depthPitch: %d\n", pMGADRI->depthPitch );
+
+ fprintf( stderr, "textureOffset: %d\n", pMGADRI->textureOffset );
+ fprintf( stderr, "textureSize: %d\n", pMGADRI->textureSize );
+
+ fprintf( stderr, "logTextureGranularity: %d\n", pMGADRI->logTextureGranularity );
+ fprintf( stderr, "logAgpTextureGranularity: %d\n", pMGADRI->logAgpTextureGranularity );
+
+ fprintf( stderr, "agpTextureHandle: %u\n", (unsigned int)pMGADRI->agpTextureOffset );
+ fprintf( stderr, "agpTextureSize: %u\n", (unsigned int)pMGADRI->agpTextureSize );
+
+#if 0
+ pMGADRI->registers.handle = pMga->registers.handle;
+ pMGADRI->registers.size = pMga->registers.size;
+ pMGADRI->status.handle = pMga->status.handle;
+ pMGADRI->status.size = pMga->status.size;
+ pMGADRI->primary.handle = pMga->primary.handle;
+ pMGADRI->primary.size = pMga->primary.size;
+ pMGADRI->buffers.handle = pMga->buffers.handle;
+ pMGADRI->buffers.size = pMga->buffers.size;
+ pMGADRI->sarea_priv_offset = sizeof(drm_sarea_t);
+#endif
+}
+
+static int MGAScreenInit( struct DRIDriverContextRec *ctx, MGAPtr pMga )
+{
+ int i;
+ int err;
+ MGADRIPtr pMGADRI;
+
+ usleep(100);
+ /*assert(!ctx->IsClient);*/
+
+ {
+ int width_bytes = (ctx->shared.virtualWidth * ctx->cpp);
+ int maxy = ctx->shared.fbSize / width_bytes;
+
+
+ if (maxy <= ctx->shared.virtualHeight * 3) {
+ fprintf(stderr,
+ "Static buffer allocation failed -- "
+ "need at least %d kB video memory (have %d kB)\n",
+ (ctx->shared.virtualWidth * ctx->shared.virtualHeight *
+ ctx->cpp * 3 + 1023) / 1024,
+ ctx->shared.fbSize / 1024);
+ return 0;
+ }
+ }
+
+ switch(pMga->Chipset) {
+ case PCI_CHIP_MGAG550:
+ case PCI_CHIP_MGAG400:
+ case PCI_CHIP_MGAG200:
+#if 0
+ case PCI_CHIP_MGAG200_PCI:
+#endif
+ break;
+ default:
+ fprintf(stderr, "[drm] Direct rendering only supported with G200/G400/G550 AGP\n");
+ return 0;
+ }
+
+ fprintf( stderr,
+ "[drm] bpp: %d depth: %d\n",
+ ctx->bpp, ctx->bpp /* FIXME: depth */ );
+
+ if ( (ctx->bpp / 8) != 2 &&
+ (ctx->bpp / 8) != 4 ) {
+ fprintf( stderr,
+ "[dri] Direct rendering only supported in 16 and 32 bpp modes\n" );
+ return 0;
+ }
+
+ ctx->shared.SAREASize = SAREA_MAX;
+
+
+ /* Note that drmOpen will try to load the kernel module, if needed. */
+ ctx->drmFD = drmOpen("mga", NULL );
+ if (ctx->drmFD < 0) {
+ fprintf(stderr, "[drm] drmOpen failed\n");
+ return 0;
+ }
+
+ if ((err = drmSetBusid(ctx->drmFD, ctx->pciBusID)) < 0) {
+ fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n",
+ ctx->drmFD, ctx->pciBusID, strerror(-err));
+ return 0;
+ }
+
+
+ if (drmAddMap( ctx->drmFD,
+ 0,
+ ctx->shared.SAREASize,
+ DRM_SHM,
+ DRM_CONTAINS_LOCK,
+ &ctx->shared.hSAREA) < 0)
+ {
+ fprintf(stderr, "[drm] drmAddMap failed\n");
+ return 0;
+ }
+ fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n",
+ ctx->shared.SAREASize, ctx->shared.hSAREA);
+
+ if (drmMap( ctx->drmFD,
+ ctx->shared.hSAREA,
+ ctx->shared.SAREASize,
+ (drmAddressPtr)(&ctx->pSAREA)) < 0)
+ {
+ fprintf(stderr, "[drm] drmMap failed\n");
+ return 0;
+ }
+ memset(ctx->pSAREA, 0, ctx->shared.SAREASize);
+ fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n",
+ ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize);
+
+ /* Need to AddMap the framebuffer and mmio regions here:
+ */
+ if (drmAddMap( ctx->drmFD,
+ (drm_handle_t)ctx->FBStart,
+ ctx->FBSize,
+ DRM_FRAME_BUFFER,
+ 0,
+ &ctx->shared.hFrameBuffer) < 0)
+ {
+ fprintf(stderr, "[drm] drmAddMap framebuffer failed\n");
+ return 0;
+ }
+ fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n",
+ ctx->shared.hFrameBuffer);
+
+
+#if 0 /* will be done in MGADRIMapInit */
+ if (drmAddMap(ctx->drmFD,
+ ctx->FixedInfo.mmio_start,
+ ctx->FixedInfo.mmio_len,
+ DRM_REGISTERS,
+ DRM_READ_ONLY,
+ &pMga->registers.handle) < 0) {
+ fprintf(stderr, "[drm] drmAddMap mmio failed\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[drm] register handle = 0x%08lx\n", pMga->registers.handle);
+#endif
+
+
+ /* Check the mga DRM version */
+ if (!MGACheckDRMVersion(ctx, pMga)) {
+ return 0;
+ }
+
+ if ( !MGADRIAgpInit( ctx, pMga ) ) {
+ return 0;
+ }
+
+ if ( !MGADRIMapInit( ctx, pMga ) ) {
+ return 0;
+ }
+
+ /* Memory manager setup */
+ if (!MGAMemoryInit(ctx, pMga)) {
+ return 0;
+ }
+
+
+ /* Create a 'server' context so we can grab the lock for
+ * initialization ioctls.
+ */
+ if ((err = drmCreateContext(ctx->drmFD, &ctx->serverContext)) != 0) {
+ fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err);
+ return 0;
+ }
+
+ DRM_LOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext, 0);
+
+ /* Initialize the kernel data structures */
+ if (!MGADRIKernelInit(ctx, pMga)) {
+ fprintf(stderr, "MGADRIKernelInit failed\n");
+ DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext);
+ return 0;
+ }
+
+ /* Initialize the vertex buffers list */
+ if (!MGADRIBuffersInit(ctx, pMga)) {
+ fprintf(stderr, "MGADRIBuffersInit failed\n");
+ DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext);
+ return 0;
+ }
+
+ /* Initialize IRQ */
+ MGADRIIrqInit(ctx, pMga);
+
+
+ /* Initialize the SAREA private data structure */
+ {
+ drm_mga_sarea_t *pSAREAPriv;
+ pSAREAPriv = (drm_mga_sarea_t *)(((char*)ctx->pSAREA) +
+ sizeof(drm_sarea_t));
+ memset(pSAREAPriv, 0, sizeof(*pSAREAPriv));
+ }
+
+ /* Quick hack to clear the front & back buffers. Could also use
+ * the clear ioctl to do this, but would need to setup hw state
+ * first.
+ */
+ drimemsetio((char *)ctx->FBAddress + pMga->frontOffset,
+ 0,
+ pMga->frontPitch * ctx->shared.virtualHeight );
+
+ drimemsetio((char *)ctx->FBAddress + pMga->backOffset,
+ 0,
+ pMga->backPitch * ctx->shared.virtualHeight );
+
+ /* Can release the lock now */
+/* DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext);*/
+
+ /* This is the struct passed to radeon_dri.so for its initialization */
+ ctx->driverClientMsg = malloc(sizeof(MGADRIRec));
+ ctx->driverClientMsgSize = sizeof(MGADRIRec);
+
+ pMGADRI = (MGADRIPtr)ctx->driverClientMsg;
+
+
+ switch(pMga->Chipset) {
+ case PCI_CHIP_MGAG550:
+ case PCI_CHIP_MGAG400:
+ pMGADRI->chipset = MGA_CARD_TYPE_G400;
+ break;
+ case PCI_CHIP_MGAG200:
+ case PCI_CHIP_MGAG200_PCI:
+ pMGADRI->chipset = MGA_CARD_TYPE_G200;
+ break;
+ default:
+ return 0;
+ }
+ pMGADRI->width = ctx->shared.virtualWidth;
+ pMGADRI->height = ctx->shared.virtualHeight;
+ pMGADRI->mem = ctx->shared.fbSize;
+ pMGADRI->cpp = ctx->bpp / 8;
+
+ pMGADRI->agpMode = pMga->agpMode;
+
+ pMGADRI->frontOffset = pMga->frontOffset;
+ pMGADRI->frontPitch = pMga->frontPitch;
+ pMGADRI->backOffset = pMga->backOffset;
+ pMGADRI->backPitch = pMga->backPitch;
+ pMGADRI->depthOffset = pMga->depthOffset;
+ pMGADRI->depthPitch = pMga->depthPitch;
+ pMGADRI->textureOffset = pMga->textureOffset;
+ pMGADRI->textureSize = pMga->textureSize;
+ pMGADRI->logTextureGranularity = pMga->logTextureGranularity;
+
+ i = mylog2( pMga->agpTextures.size / MGA_NR_TEX_REGIONS );
+ if ( i < MGA_LOG_MIN_TEX_REGION_SIZE )
+ i = MGA_LOG_MIN_TEX_REGION_SIZE;
+
+ pMGADRI->logAgpTextureGranularity = i;
+ pMGADRI->agpTextureOffset = (unsigned int)pMga->agpTextures.handle;
+ pMGADRI->agpTextureSize = (unsigned int)pMga->agpTextures.size;
+
+ pMGADRI->registers.handle = pMga->registers.handle;
+ pMGADRI->registers.size = pMga->registers.size;
+ pMGADRI->status.handle = pMga->status.handle;
+ pMGADRI->status.size = pMga->status.size;
+ pMGADRI->primary.handle = pMga->primary.handle;
+ pMGADRI->primary.size = pMga->primary.size;
+ pMGADRI->buffers.handle = pMga->buffers.handle;
+ pMGADRI->buffers.size = pMga->buffers.size;
+ pMGADRI->sarea_priv_offset = sizeof(drm_sarea_t);
+
+ print_client_msg( pMGADRI );
+
+ return 1;
+}
+
+
+/**
+ * \brief Validate the fbdev mode.
+ *
+ * \param ctx display handle.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Saves some registers and returns 1.
+ *
+ * \sa mgaValidateMode().
+ */
+static int mgaValidateMode( const DRIDriverContext *ctx )
+{
+ return 1;
+}
+
+
+/**
+ * \brief Examine mode returned by fbdev.
+ *
+ * \param ctx display handle.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Restores registers that fbdev has clobbered and returns 1.
+ *
+ * \sa mgaValidateMode().
+ */
+static int mgaPostValidateMode( const DRIDriverContext *ctx )
+{
+ return 1;
+}
+
+
+/**
+ * \brief Initialize the framebuffer device mode
+ *
+ * \param ctx display handle.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Fills in \p info with some default values and some information from \p ctx
+ * and then calls MGAScreenInit() for the screen initialization.
+ *
+ * Before exiting clears the framebuffer memomry accessing it directly.
+ */
+static int mgaInitFBDev( struct DRIDriverContextRec *ctx )
+{
+ MGAPtr pMga = calloc(1, sizeof(*pMga));
+
+ {
+ int dummy = ctx->shared.virtualWidth;
+
+ switch (ctx->bpp / 8) {
+ case 1: dummy = (ctx->shared.virtualWidth + 127) & ~127; break;
+ case 2: dummy = (ctx->shared.virtualWidth + 31) & ~31; break;
+ case 3:
+ case 4: dummy = (ctx->shared.virtualWidth + 15) & ~15; break;
+ }
+
+ ctx->shared.virtualWidth = dummy;
+ }
+
+ ctx->driverPrivate = (void *)pMga;
+
+ pMga->agpMode = MGA_DEFAULT_AGP_MODE;
+ pMga->agpSize = MGA_DEFAULT_AGP_SIZE;
+
+ pMga->Chipset = ctx->chipset;
+
+ pMga->IOAddress = ctx->MMIOStart;
+ pMga->IOBase = ctx->MMIOAddress;
+
+ pMga->frontPitch = ctx->shared.virtualWidth * ctx->cpp;
+
+ if (!MGAScreenInit( ctx, pMga ))
+ return 0;
+
+ return 1;
+}
+
+
+/**
+ * \brief The screen is being closed, so clean up any state and free any
+ * resources used by the DRI.
+ *
+ * \param ctx display handle.
+ *
+ * Unmaps the SAREA, closes the DRM device file descriptor and frees the driver
+ * private data.
+ */
+static void mgaHaltFBDev( struct DRIDriverContextRec *ctx )
+{
+ drmUnmap( ctx->pSAREA, ctx->shared.SAREASize );
+ drmClose(ctx->drmFD);
+
+ if (ctx->driverPrivate) {
+ free(ctx->driverPrivate);
+ ctx->driverPrivate = NULL;
+ }
+}
+
+
+static int mgaEngineShutdown( const DRIDriverContext *ctx )
+{
+ fprintf(stderr, "%s() is not yet implemented!\n", __FUNCTION__);
+
+ return 1;
+}
+
+static int mgaEngineRestore( const DRIDriverContext *ctx )
+{
+ fprintf(stderr, "%s() is not yet implemented!\n", __FUNCTION__);
+
+ return 1;
+}
+
+/**
+ * \brief Exported driver interface for Mini GLX.
+ *
+ * \sa DRIDriverRec.
+ */
+struct DRIDriverRec __driDriver = {
+ mgaValidateMode,
+ mgaPostValidateMode,
+ mgaInitFBDev,
+ mgaHaltFBDev,
+ mgaEngineShutdown,
+ mgaEngineRestore,
+ 0
+};
+
+
+
+
+#if 0
+void MGADRICloseScreen( ScreenPtr pScreen )
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ MGAPtr pMga = MGAPTR(pScrn);
+ MGADRIServerPrivatePtr pMga = pMga->DRIServerInfo;
+ drmMGAInit init;
+
+ if ( pMga->drmBuffers ) {
+ drmUnmapBufs( pMga->drmBuffers );
+ pMga->drmBuffers = NULL;
+ }
+
+ if (pMga->irq) {
+ drmCtlUninstHandler(ctx->drmFD);
+ pMga->irq = 0;
+ }
+
+ /* Cleanup DMA */
+ memset( &init, 0, sizeof(drmMGAInit) );
+ init.func = MGA_CLEANUP_DMA;
+ drmCommandWrite( ctx->drmFD, DRM_MGA_INIT, &init, sizeof(drmMGAInit) );
+
+ if ( pMga->status.map ) {
+ drmUnmap( pMga->status.map, pMga->status.size );
+ pMga->status.map = NULL;
+ }
+ if ( pMga->buffers.map ) {
+ drmUnmap( pMga->buffers.map, pMga->buffers.size );
+ pMga->buffers.map = NULL;
+ }
+ if ( pMga->primary.map ) {
+ drmUnmap( pMga->primary.map, pMga->primary.size );
+ pMga->primary.map = NULL;
+ }
+ if ( pMga->warp.map ) {
+ drmUnmap( pMga->warp.map, pMga->warp.size );
+ pMga->warp.map = NULL;
+ }
+
+ if ( pMga->agpTextures.map ) {
+ drmUnmap( pMga->agpTextures.map, pMga->agpTextures.size );
+ pMga->agpTextures.map = NULL;
+ }
+
+ if ( pMga->agp.handle ) {
+ drmAgpUnbind( ctx->drmFD, pMga->agp.handle );
+ drmAgpFree( ctx->drmFD, pMga->agp.handle );
+ pMga->agp.handle = 0;
+ drmAgpRelease( ctx->drmFD );
+ }
+
+ DRICloseScreen( pScreen );
+
+ if ( pMga->pDRIInfo ) {
+ if ( pMga->pDRIpMga->devPrivate ) {
+ xfree( pMga->pDRIpMga->devPrivate );
+ pMga->pDRIpMga->devPrivate = 0;
+ }
+ DRIDestroyInfoRec( pMga->pDRIInfo );
+ pMga->pDRIInfo = 0;
+ }
+ if ( pMga->DRIServerInfo ) {
+ xfree( pMga->DRIServerInfo );
+ pMga->DRIServerInfo = 0;
+ }
+ if ( pMga->pVisualConfigs ) {
+ xfree( pMga->pVisualConfigs );
+ }
+ if ( pMga->pVisualConfigsPriv ) {
+ xfree( pMga->pVisualConfigsPriv );
+ }
+}
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_dri.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_dri.h
new file mode 100644
index 000000000..03b841460
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_dri.h
@@ -0,0 +1,113 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.h,v 1.8 2002/11/29 11:06:42 eich Exp $ */
+
+/*
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ * Gareth Hughes <gareth@valinux.com>
+ */
+
+#ifndef __MGA_DRI_H__
+#define __MGA_DRI_H__
+
+#include "xf86drm.h"
+#include "drm.h"
+#include "mga_drm.h"
+
+#define MGA_DEFAULT_AGP_SIZE 64
+#define MGA_DEFAULT_AGP_MODE 4
+#define MGA_MAX_AGP_MODE 4
+
+/* Buffer are aligned on 4096 byte boundaries.
+ */
+#define MGA_BUFFER_ALIGN 0x00000fff
+
+#ifdef __GNUC__
+# define DEPRECATED __attribute__ ((deprecated))
+#else
+# define DEPRECATED
+#endif
+
+#if 1
+typedef struct _mgaDrmRegion {
+ drm_handle_t handle;
+ unsigned int offset;
+ drmSize size;
+} mgaDrmRegion, *mgaDrmRegionPtr;
+#else
+#define mgaDrmRegion drmRegion
+#endif
+
+typedef struct {
+ int chipset;
+ int width DEPRECATED;
+ int height DEPRECATED;
+ int mem DEPRECATED;
+ int cpp;
+
+ int agpMode;
+
+ unsigned int frontOffset;
+ unsigned int frontPitch;
+
+ unsigned int backOffset;
+ unsigned int backPitch;
+
+ unsigned int depthOffset;
+ unsigned int depthPitch;
+
+ unsigned int textureOffset;
+ unsigned int textureSize;
+ int logTextureGranularity DEPRECATED;
+
+ /* Allow calculation of setup dma addresses.
+ */
+ unsigned int agpBufferOffset DEPRECATED;
+
+ unsigned int agpTextureOffset;
+ unsigned int agpTextureSize;
+ int logAgpTextureGranularity DEPRECATED;
+
+ unsigned int mAccess DEPRECATED;
+
+ /**
+ * \name DRM memory regions.
+ *
+ * \todo
+ * Several of these fields are no longer used (and will never be used
+ * again) on the client-side. None of them, except \c registers, are used
+ * on the server-side. At some point when it is safe to do so (probably
+ * for the X.org 6.9 / 7.0 release), these fields should be removed.
+ */
+ /*@{*/
+ mgaDrmRegion registers; /**< MMIO registers. */
+ mgaDrmRegion status DEPRECATED; /**< No longer used on the client-side. */
+ mgaDrmRegion primary; /**< Primary DMA region. */
+ mgaDrmRegion buffers DEPRECATED; /**< No longer used on the client-side. */
+ /*@}*/
+
+ unsigned int sarea_priv_offset;
+} MGADRIRec, *MGADRIPtr;
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_macros.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_macros.h
new file mode 100644
index 000000000..d985081ab
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_macros.h
@@ -0,0 +1,118 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h,v 1.22 2002/02/20 17:17:50 dawes Exp $ */
+
+#ifndef _MGA_MACROS_H_
+#define _MGA_MACROS_H_
+
+#ifndef PSZ
+#define PSZ 8
+#endif
+
+#if PSZ == 8
+#define REPLICATE(r) r &= 0xFF; r |= r << 8; r |= r << 16
+#elif PSZ == 16
+#define REPLICATE(r) r &= 0xFFFF; r |= r << 16
+#elif PSZ == 24
+#define REPLICATE(r) r &= 0xFFFFFF; r |= r << 24
+#else
+#define REPLICATE(r) /* */
+#endif
+
+#define RGBEQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff))
+
+#ifdef XF86DRI
+#define MGA_SYNC_XTAG 0x275f4200
+
+#define MGABUSYWAIT() do { \
+OUTREG(MGAREG_DWGSYNC, MGA_SYNC_XTAG); \
+while(INREG(MGAREG_DWGSYNC) != MGA_SYNC_XTAG) ; \
+}while(0);
+
+#endif
+
+#define MGAISBUSY() (INREG8(MGAREG_Status + 2) & 0x01)
+
+#define WAITFIFO(cnt) \
+ if(!pMga->UsePCIRetry) {\
+ register int n = cnt; \
+ if(n > pMga->FifoSize) n = pMga->FifoSize; \
+ while(pMga->fifoCount < (n))\
+ pMga->fifoCount = INREG8(MGAREG_FIFOSTATUS);\
+ pMga->fifoCount -= n;\
+ }
+
+#define XYADDRESS(x,y) \
+ ((y) * pMga->CurrentLayout.displayWidth + (x) + pMga->YDstOrg)
+
+#define MAKEDMAINDEX(index) ((((index) >> 2) & 0x7f) | (((index) >> 6) & 0x80))
+
+#define DMAINDICES(one,two,three,four) \
+ ( MAKEDMAINDEX(one) | \
+ (MAKEDMAINDEX(two) << 8) | \
+ (MAKEDMAINDEX(three) << 16) | \
+ (MAKEDMAINDEX(four) << 24) )
+
+#if PSZ == 24
+#define SET_PLANEMASK(p) /**/
+#else
+#define SET_PLANEMASK(p) \
+ if(!(pMga->AccelFlags & MGA_NO_PLANEMASK) && ((p) != pMga->PlaneMask)) { \
+ pMga->PlaneMask = (p); \
+ REPLICATE((p)); \
+ OUTREG(MGAREG_PLNWT,(p)); \
+ }
+#endif
+
+#define SET_FOREGROUND(c) \
+ if((c) != pMga->FgColor) { \
+ pMga->FgColor = (c); \
+ REPLICATE((c)); \
+ OUTREG(MGAREG_FCOL,(c)); \
+ }
+
+#define SET_BACKGROUND(c) \
+ if((c) != pMga->BgColor) { \
+ pMga->BgColor = (c); \
+ REPLICATE((c)); \
+ OUTREG(MGAREG_BCOL,(c)); \
+ }
+
+#define DISABLE_CLIP() { \
+ pMga->AccelFlags &= ~CLIPPER_ON; \
+ WAITFIFO(1); \
+ OUTREG(MGAREG_CXBNDRY, 0xFFFF0000); }
+
+#ifdef XF86DRI
+#define CHECK_DMA_QUIESCENT(pMGA, pScrn) { \
+ if (!pMGA->haveQuiescense) { \
+ pMGA->GetQuiescence( pScrn ); \
+ } \
+}
+#else
+#define CHECK_DMA_QUIESCENT(pMGA, pScrn)
+#endif
+
+#ifdef USEMGAHAL
+#define HAL_CHIPSETS ((pMga->Chipset == PCI_CHIP_MGAG200_PCI) || \
+ (pMga->Chipset == PCI_CHIP_MGAG200) || \
+ (pMga->Chipset == PCI_CHIP_MGAG400) || \
+ (pMga->Chipset == PCI_CHIP_MGAG550))
+
+#define MGA_HAL(x) { \
+ MGAPtr pMga = MGAPTR(pScrn); \
+ if (pMga->HALLoaded && HAL_CHIPSETS) { x; } \
+}
+#define MGA_NOT_HAL(x) { \
+ MGAPtr pMga = MGAPTR(pScrn); \
+ if (!pMga->HALLoaded || !HAL_CHIPSETS) { x; } \
+}
+#else
+#define MGA_NOT_HAL(x) { x; }
+#endif
+
+#define MGAISGx50(x) ( (((x)->Chipset == PCI_CHIP_MGAG400) && ((x)->ChipRev >= 0x80)) || \
+ ((x)->Chipset == PCI_CHIP_MGAG550) )
+
+#define MGA_DH_NEEDS_HAL(x) (((x)->Chipset == PCI_CHIP_MGAG400) && \
+ ((x)->ChipRev < 0x80))
+
+#endif /* _MGA_MACROS_H_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_reg.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_reg.h
new file mode 100644
index 000000000..b8e349923
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/mga/server/mga_reg.h
@@ -0,0 +1,484 @@
+/* $XConsortium: mgareg.h /main/2 1996/10/25 10:33:21 kaleb $ */
+
+
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h,v 1.18 2001/09/26 12:59:18 alanh Exp $ */
+
+
+
+/*
+ * MGA Millennium (MGA2064W) functions
+ * MGA Mystique (MGA1064SG) functions
+ *
+ * Copyright 1996 The XFree86 Project, Inc.
+ *
+ * Authors
+ * Dirk Hohndel
+ * hohndel@XFree86.Org
+ * David Dawes
+ * dawes@XFree86.Org
+ * Contributors:
+ * Guy DESBIEF, Aix-en-provence, France
+ * g.desbief@aix.pacwan.net
+ * MGA1064SG Mystique register file
+ */
+
+
+#ifndef _MGA_REG_H_
+#define _MGA_REG_H_
+
+#define MGAREG_DWGCTL 0x1c00
+#define MGAREG_MACCESS 0x1c04
+#define MGA_MACCESS_PW16 0x00000001
+#define MGA_MACCESS_PW32 0x00000002
+/* the following is a mystique only register */
+#define MGAREG_MCTLWTST 0x1c08
+#define MGAREG_ZORG 0x1c0c
+
+#define MGAREG_PAT0 0x1c10
+#define MGAREG_PAT1 0x1c14
+#define MGAREG_PLNWT 0x1c1c
+
+#define MGAREG_BCOL 0x1c20
+#define MGAREG_FCOL 0x1c24
+
+#define MGAREG_SRC0 0x1c30
+#define MGAREG_SRC1 0x1c34
+#define MGAREG_SRC2 0x1c38
+#define MGAREG_SRC3 0x1c3c
+
+#define MGAREG_XYSTRT 0x1c40
+#define MGAREG_XYEND 0x1c44
+
+#define MGAREG_SHIFT 0x1c50
+/* the following is a mystique only register */
+#define MGAREG_DMAPAD 0x1c54
+#define MGAREG_SGN 0x1c58
+#define MGAREG_LEN 0x1c5c
+
+#define MGAREG_AR0 0x1c60
+#define MGAREG_AR1 0x1c64
+#define MGAREG_AR2 0x1c68
+#define MGAREG_AR3 0x1c6c
+#define MGAREG_AR4 0x1c70
+#define MGAREG_AR5 0x1c74
+#define MGAREG_AR6 0x1c78
+
+#define MGAREG_CXBNDRY 0x1c80
+#define MGAREG_FXBNDRY 0x1c84
+#define MGAREG_YDSTLEN 0x1c88
+#define MGAREG_PITCH 0x1c8c
+
+#define MGAREG_YDST 0x1c90
+#define MGAREG_YDSTORG 0x1c94
+#define MGAREG_YTOP 0x1c98
+#define MGAREG_YBOT 0x1c9c
+
+#define MGAREG_CXLEFT 0x1ca0
+#define MGAREG_CXRIGHT 0x1ca4
+#define MGAREG_FXLEFT 0x1ca8
+#define MGAREG_FXRIGHT 0x1cac
+
+#define MGAREG_XDST 0x1cb0
+
+#define MGAREG_DR0 0x1cc0
+#define MGAREG_DR1 0x1cc4
+#define MGAREG_DR2 0x1cc8
+#define MGAREG_DR3 0x1ccc
+
+#define MGAREG_DR4 0x1cd0
+#define MGAREG_DR5 0x1cd4
+#define MGAREG_DR6 0x1cd8
+#define MGAREG_DR7 0x1cdc
+
+#define MGAREG_DR8 0x1ce0
+#define MGAREG_DR9 0x1ce4
+#define MGAREG_DR10 0x1ce8
+#define MGAREG_DR11 0x1cec
+
+#define MGAREG_DR12 0x1cf0
+#define MGAREG_DR13 0x1cf4
+#define MGAREG_DR14 0x1cf8
+#define MGAREG_DR15 0x1cfc
+
+#define MGAREG_SRCORG 0x2cb4
+#define MGAREG_DSTORG 0x2cb8
+
+/* add or or this to one of the previous "power registers" to start
+ the drawing engine */
+
+#define MGAREG_EXEC 0x0100
+
+#define MGAREG_FIFOSTATUS 0x1e10
+#define MGAREG_Status 0x1e14
+#define MGAREG_ICLEAR 0x1e18
+#define MGAREG_IEN 0x1e1c
+
+#define MGAREG_VCOUNT 0x1e20
+
+#define MGAREG_Reset 0x1e40
+
+#define MGAREG_OPMODE 0x1e54
+
+/* Warp Registers */
+#define MGAREG_WIADDR 0x1dc0
+#define MGAREG_WIADDR2 0x1dd8
+#define MGAREG_WGETMSB 0x1dc8
+#define MGAREG_WVRTXSZ 0x1dcc
+#define MGAREG_WACCEPTSEQ 0x1dd4
+#define MGAREG_WMISC 0x1e70
+
+/* OPMODE register additives */
+
+#define MGAOPM_DMA_GENERAL (0x00 << 2)
+#define MGAOPM_DMA_BLIT (0x01 << 2)
+#define MGAOPM_DMA_VECTOR (0x10 << 2)
+
+/* DWGCTL register additives */
+
+/* Lines */
+
+#define MGADWG_LINE_OPEN 0x00
+#define MGADWG_AUTOLINE_OPEN 0x01
+#define MGADWG_LINE_CLOSE 0x02
+#define MGADWG_AUTOLINE_CLOSE 0x03
+
+/* Trapezoids */
+#define MGADWG_TRAP 0x04
+#define MGADWG_TEXTURE_TRAP 0x05
+
+/* BitBlts */
+
+#define MGADWG_BITBLT 0x08
+#define MGADWG_FBITBLT 0x0c
+#define MGADWG_ILOAD 0x09
+#define MGADWG_ILOAD_SCALE 0x0d
+#define MGADWG_ILOAD_FILTER 0x0f
+#define MGADWG_ILOAD_HIQH 0x07
+#define MGADWG_ILOAD_HIQHV 0x0e
+#define MGADWG_IDUMP 0x0a
+
+/* atype access to WRAM */
+
+#define MGADWG_RPL ( 0x00 << 4 )
+#define MGADWG_RSTR ( 0x01 << 4 )
+#define MGADWG_ZI ( 0x03 << 4 )
+#define MGADWG_BLK ( 0x04 << 4 )
+#define MGADWG_I ( 0x07 << 4 )
+
+/* specifies whether bit blits are linear or xy */
+#define MGADWG_LINEAR ( 0x01 << 7 )
+
+/* z drawing mode. use MGADWG_NOZCMP for always */
+
+#define MGADWG_NOZCMP ( 0x00 << 8 )
+#define MGADWG_ZE ( 0x02 << 8 )
+#define MGADWG_ZNE ( 0x03 << 8 )
+#define MGADWG_ZLT ( 0x04 << 8 )
+#define MGADWG_ZLTE ( 0x05 << 8 )
+#define MGADWG_GT ( 0x06 << 8 )
+#define MGADWG_GTE ( 0x07 << 8 )
+
+/* use this to force colour expansion circuitry to do its stuff */
+
+#define MGADWG_SOLID ( 0x01 << 11 )
+
+/* ar register at zero */
+
+#define MGADWG_ARZERO ( 0x01 << 12 )
+
+#define MGADWG_SGNZERO ( 0x01 << 13 )
+
+#define MGADWG_SHIFTZERO ( 0x01 << 14 )
+
+/* See table on 4-43 for bop ALU operations */
+
+/* See table on 4-44 for translucidity masks */
+
+#define MGADWG_BMONOLEF ( 0x00 << 25 )
+#define MGADWG_BMONOWF ( 0x04 << 25 )
+#define MGADWG_BPLAN ( 0x01 << 25 )
+
+/* note that if bfcol is specified and you're doing a bitblt, it causes
+ a fbitblt to be performed, so check that you obey the fbitblt rules */
+
+#define MGADWG_BFCOL ( 0x02 << 25 )
+#define MGADWG_BUYUV ( 0x0e << 25 )
+#define MGADWG_BU32BGR ( 0x03 << 25 )
+#define MGADWG_BU32RGB ( 0x07 << 25 )
+#define MGADWG_BU24BGR ( 0x0b << 25 )
+#define MGADWG_BU24RGB ( 0x0f << 25 )
+
+#define MGADWG_PATTERN ( 0x01 << 29 )
+#define MGADWG_TRANSC ( 0x01 << 30 )
+#define MGAREG_MISC_WRITE 0x3c2
+#define MGAREG_MISC_READ 0x3cc
+#define MGAREG_MISC_IOADSEL (0x1 << 0)
+#define MGAREG_MISC_RAMMAPEN (0x1 << 1)
+#define MGAREG_MISC_CLK_SEL_VGA25 (0x0 << 2)
+#define MGAREG_MISC_CLK_SEL_VGA28 (0x1 << 2)
+#define MGAREG_MISC_CLK_SEL_MGA_PIX (0x2 << 2)
+#define MGAREG_MISC_CLK_SEL_MGA_MSK (0x3 << 2)
+#define MGAREG_MISC_VIDEO_DIS (0x1 << 4)
+#define MGAREG_MISC_HIGH_PG_SEL (0x1 << 5)
+
+/* MMIO VGA registers */
+#define MGAREG_SEQ_INDEX 0x1fc4
+#define MGAREG_SEQ_DATA 0x1fc5
+#define MGAREG_CRTC_INDEX 0x1fd4
+#define MGAREG_CRTC_DATA 0x1fd5
+#define MGAREG_CRTCEXT_INDEX 0x1fde
+#define MGAREG_CRTCEXT_DATA 0x1fdf
+
+
+
+/* MGA bits for registers PCI_OPTION_REG */
+#define MGA1064_OPT_SYS_CLK_PCI ( 0x00 << 0 )
+#define MGA1064_OPT_SYS_CLK_PLL ( 0x01 << 0 )
+#define MGA1064_OPT_SYS_CLK_EXT ( 0x02 << 0 )
+#define MGA1064_OPT_SYS_CLK_MSK ( 0x03 << 0 )
+
+#define MGA1064_OPT_SYS_CLK_DIS ( 0x01 << 2 )
+#define MGA1064_OPT_G_CLK_DIV_1 ( 0x01 << 3 )
+#define MGA1064_OPT_M_CLK_DIV_1 ( 0x01 << 4 )
+
+#define MGA1064_OPT_SYS_PLL_PDN ( 0x01 << 5 )
+#define MGA1064_OPT_VGA_ION ( 0x01 << 8 )
+
+/* MGA registers in PCI config space */
+#define PCI_MGA_INDEX 0x44
+#define PCI_MGA_DATA 0x48
+#define PCI_MGA_OPTION2 0x50
+#define PCI_MGA_OPTION3 0x54
+
+#define RAMDAC_OFFSET 0x3c00
+
+/* TVP3026 direct registers */
+
+#define TVP3026_INDEX 0x00
+#define TVP3026_WADR_PAL 0x00
+#define TVP3026_COL_PAL 0x01
+#define TVP3026_PIX_RD_MSK 0x02
+#define TVP3026_RADR_PAL 0x03
+#define TVP3026_CUR_COL_ADDR 0x04
+#define TVP3026_CUR_COL_DATA 0x05
+#define TVP3026_DATA 0x0a
+#define TVP3026_CUR_RAM 0x0b
+#define TVP3026_CUR_XLOW 0x0c
+#define TVP3026_CUR_XHI 0x0d
+#define TVP3026_CUR_YLOW 0x0e
+#define TVP3026_CUR_YHI 0x0f
+
+/* TVP3026 indirect registers */
+
+#define TVP3026_SILICON_REV 0x01
+#define TVP3026_CURSOR_CTL 0x06
+#define TVP3026_LATCH_CTL 0x0f
+#define TVP3026_TRUE_COLOR_CTL 0x18
+#define TVP3026_MUX_CTL 0x19
+#define TVP3026_CLK_SEL 0x1a
+#define TVP3026_PAL_PAGE 0x1c
+#define TVP3026_GEN_CTL 0x1d
+#define TVP3026_MISC_CTL 0x1e
+#define TVP3026_GEN_IO_CTL 0x2a
+#define TVP3026_GEN_IO_DATA 0x2b
+#define TVP3026_PLL_ADDR 0x2c
+#define TVP3026_PIX_CLK_DATA 0x2d
+#define TVP3026_MEM_CLK_DATA 0x2e
+#define TVP3026_LOAD_CLK_DATA 0x2f
+#define TVP3026_KEY_RED_LOW 0x32
+#define TVP3026_KEY_RED_HI 0x33
+#define TVP3026_KEY_GREEN_LOW 0x34
+#define TVP3026_KEY_GREEN_HI 0x35
+#define TVP3026_KEY_BLUE_LOW 0x36
+#define TVP3026_KEY_BLUE_HI 0x37
+#define TVP3026_KEY_CTL 0x38
+#define TVP3026_MCLK_CTL 0x39
+#define TVP3026_SENSE_TEST 0x3a
+#define TVP3026_TEST_DATA 0x3b
+#define TVP3026_CRC_LSB 0x3c
+#define TVP3026_CRC_MSB 0x3d
+#define TVP3026_CRC_CTL 0x3e
+#define TVP3026_ID 0x3f
+#define TVP3026_RESET 0xff
+
+
+/* MGA1064 DAC Register file */
+/* MGA1064 direct registers */
+
+#define MGA1064_INDEX 0x00
+#define MGA1064_WADR_PAL 0x00
+#define MGA1064_COL_PAL 0x01
+#define MGA1064_PIX_RD_MSK 0x02
+#define MGA1064_RADR_PAL 0x03
+#define MGA1064_DATA 0x0a
+
+#define MGA1064_CUR_XLOW 0x0c
+#define MGA1064_CUR_XHI 0x0d
+#define MGA1064_CUR_YLOW 0x0e
+#define MGA1064_CUR_YHI 0x0f
+
+/* MGA1064 indirect registers */
+#define MGA1064_DVI_PIPE_CTL 0x03
+#define MGA1064_CURSOR_BASE_ADR_LOW 0x04
+#define MGA1064_CURSOR_BASE_ADR_HI 0x05
+#define MGA1064_CURSOR_CTL 0x06
+#define MGA1064_CURSOR_COL0_RED 0x08
+#define MGA1064_CURSOR_COL0_GREEN 0x09
+#define MGA1064_CURSOR_COL0_BLUE 0x0a
+
+#define MGA1064_CURSOR_COL1_RED 0x0c
+#define MGA1064_CURSOR_COL1_GREEN 0x0d
+#define MGA1064_CURSOR_COL1_BLUE 0x0e
+
+#define MGA1064_CURSOR_COL2_RED 0x010
+#define MGA1064_CURSOR_COL2_GREEN 0x011
+#define MGA1064_CURSOR_COL2_BLUE 0x012
+
+#define MGA1064_VREF_CTL 0x018
+
+#define MGA1064_MUL_CTL 0x19
+#define MGA1064_MUL_CTL_8bits 0x0
+#define MGA1064_MUL_CTL_15bits 0x01
+#define MGA1064_MUL_CTL_16bits 0x02
+#define MGA1064_MUL_CTL_24bits 0x03
+#define MGA1064_MUL_CTL_32bits 0x04
+#define MGA1064_MUL_CTL_2G8V16bits 0x05
+#define MGA1064_MUL_CTL_G16V16bits 0x06
+#define MGA1064_MUL_CTL_32_24bits 0x07
+
+#define MGAGDAC_XVREFCTRL 0x18
+#define MGA1064_PIX_CLK_CTL 0x1a
+#define MGA1064_PIX_CLK_CTL_CLK_DIS ( 0x01 << 2 )
+#define MGA1064_PIX_CLK_CTL_CLK_POW_DOWN ( 0x01 << 3 )
+#define MGA1064_PIX_CLK_CTL_SEL_PCI ( 0x00 << 0 )
+#define MGA1064_PIX_CLK_CTL_SEL_PLL ( 0x01 << 0 )
+#define MGA1064_PIX_CLK_CTL_SEL_EXT ( 0x02 << 0 )
+#define MGA1064_PIX_CLK_CTL_SEL_MSK ( 0x03 << 0 )
+
+#define MGA1064_GEN_CTL 0x1d
+#define MGA1064_MISC_CTL 0x1e
+#define MGA1064_MISC_CTL_DAC_POW_DN ( 0x01 << 0 )
+#define MGA1064_MISC_CTL_VGA ( 0x01 << 1 )
+#define MGA1064_MISC_CTL_DIS_CON ( 0x03 << 1 )
+#define MGA1064_MISC_CTL_MAFC ( 0x02 << 1 )
+#define MGA1064_MISC_CTL_VGA8 ( 0x01 << 3 )
+#define MGA1064_MISC_CTL_DAC_RAM_CS ( 0x01 << 4 )
+
+#define MGA1064_GEN_IO_CTL 0x2a
+#define MGA1064_GEN_IO_DATA 0x2b
+#define MGA1064_SYS_PLL_M 0x2c
+#define MGA1064_SYS_PLL_N 0x2d
+#define MGA1064_SYS_PLL_P 0x2e
+#define MGA1064_SYS_PLL_STAT 0x2f
+#define MGA1064_ZOOM_CTL 0x38
+#define MGA1064_SENSE_TST 0x3a
+
+#define MGA1064_CRC_LSB 0x3c
+#define MGA1064_CRC_MSB 0x3d
+#define MGA1064_CRC_CTL 0x3e
+#define MGA1064_COL_KEY_MSK_LSB 0x40
+#define MGA1064_COL_KEY_MSK_MSB 0x41
+#define MGA1064_COL_KEY_LSB 0x42
+#define MGA1064_COL_KEY_MSB 0x43
+#define MGA1064_PIX_PLLA_M 0x44
+#define MGA1064_PIX_PLLA_N 0x45
+#define MGA1064_PIX_PLLA_P 0x46
+#define MGA1064_PIX_PLLB_M 0x48
+#define MGA1064_PIX_PLLB_N 0x49
+#define MGA1064_PIX_PLLB_P 0x4a
+#define MGA1064_PIX_PLLC_M 0x4c
+#define MGA1064_PIX_PLLC_N 0x4d
+#define MGA1064_PIX_PLLC_P 0x4e
+
+#define MGA1064_PIX_PLL_STAT 0x4f
+
+/*Added for G450 dual head*/
+/* Supported PLL*/
+#define __PIXEL_PLL 1
+#define __SYSTEM_PLL 2
+#define __VIDEO_PLL 3
+
+#define MGA1064_VID_PLL_P 0x8D
+#define MGA1064_VID_PLL_M 0x8E
+#define MGA1064_VID_PLL_N 0x8F
+
+#define MGA1064_DISP_CTL 0x8a
+#define MGA1064_SYNC_CTL 0x8b
+#define MGA1064_PWR_CTL 0xa0
+#define MGA1064_PAN_CTL 0xa2
+
+/* Using crtc2 */
+#define MGAREG2_C2CTL 0x10
+#define MGAREG2_C2HPARAM 0x14
+#define MGAREG2_C2HSYNC 0x18
+#define MGAREG2_C2VPARAM 0x1c
+#define MGAREG2_C2VSYNC 0x20
+#define MGAREG2_C2STARTADD0 0x28
+
+#define MGAREG2_C2OFFSET 0x40
+#define MGAREG2_C2DATACTL 0x4c
+
+#define MGAREG_C2CTL 0x3c10
+#define MGAREG_C2HPARAM 0x3c14
+#define MGAREG_C2HSYNC 0x3c18
+#define MGAREG_C2VPARAM 0x3c1c
+#define MGAREG_C2VSYNC 0x3c20
+#define MGAREG_C2STARTADD0 0x3c28
+
+#define MGAREG_C2OFFSET 0x3c40
+#define MGAREG_C2DATACTL 0x3c4c
+
+#define MGA1064_DISP_CTL 0x8a
+#define MGA1064_SYNC_CTL 0x8b
+#define MGA1064_PWR_CTL 0xa0
+
+/* video register */
+
+#define MGAREG_BESA1C3ORG 0x3d60
+#define MGAREG_BESA1CORG 0x3d10
+#define MGAREG_BESA1ORG 0x3d00
+#define MGAREG_BESCTL 0x3d20
+#define MGAREG_BESGLOBCTL 0x3dc0
+#define MGAREG_BESHCOORD 0x3d28
+#define MGAREG_BESHISCAL 0x3d30
+#define MGAREG_BESHSRCEND 0x3d3c
+#define MGAREG_BESHSRCLST 0x3d50
+#define MGAREG_BESHSRCST 0x3d38
+#define MGAREG_BESLUMACTL 0x3d40
+#define MGAREG_BESPITCH 0x3d24
+#define MGAREG_BESV1SRCLST 0x3d54
+#define MGAREG_BESV1WGHT 0x3d48
+#define MGAREG_BESVCOORD 0x3d2c
+#define MGAREG_BESVISCAL 0x3d34
+
+/* texture engine registers */
+
+#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_TEXORG 0x2c24
+#define MGAREG_TEXWIDTH 0x2c28
+#define MGAREG_TEXHEIGHT 0x2c2c
+#define MGAREG_TEXCTL 0x2c30
+#define MGAREG_TEXCTL2 0x2c3c
+#define MGAREG_TEXTRANS 0x2c34
+#define MGAREG_TEXTRANSHIGH 0x2c38
+#define MGAREG_TEXFILTER 0x2c58
+#define MGAREG_ALPHASTART 0x2c70
+#define MGAREG_ALPHAXINC 0x2c74
+#define MGAREG_ALPHAYINC 0x2c78
+#define MGAREG_ALPHACTRL 0x2c7c
+#define MGAREG_DWGSYNC 0x2c4c
+
+#define MGAREG_AGP_PLL 0x1e4c
+#define MGA_AGP2XPLL_ENABLE 0x1
+#define MGA_AGP2XPLL_DISABLE 0x0
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/Makefile
new file mode 100644
index 000000000..796dfbc51
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/Makefile
@@ -0,0 +1,32 @@
+# src/mesa/drivers/dri/r128/Makefile
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = r128_dri.so
+
+MINIGLX_SOURCES = server/r128_dri.c
+
+DRIVER_SOURCES = \
+ r128_context.c \
+ r128_lock.c \
+ r128_state.c \
+ r128_texstate.c \
+ r128_dd.c \
+ r128_screen.c \
+ r128_tex.c \
+ r128_tris.c \
+ r128_ioctl.c \
+ r128_span.c \
+ r128_texmem.c
+
+C_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+
+include ../Makefile.template
+
+symlinks:
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_context.c
new file mode 100644
index 000000000..f071bbecb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_context.c
@@ -0,0 +1,364 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_context.c,v 1.8 2002/10/30 12:51:38 alanh Exp $ */
+/**************************************************************************
+
+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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "simple_list.h"
+#include "imports.h"
+#include "matrix.h"
+#include "extensions.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+
+#include "drivers/common/driverfuncs.h"
+
+#include "r128_context.h"
+#include "r128_ioctl.h"
+#include "r128_dd.h"
+#include "r128_state.h"
+#include "r128_span.h"
+#include "r128_tex.h"
+#include "r128_tris.h"
+
+#include "vblank.h"
+#include "utils.h"
+#include "texmem.h"
+#include "xmlpool.h" /* for symbolic values of enum-type options */
+
+#ifndef R128_DEBUG
+int R128_DEBUG = 0;
+#endif
+
+#define need_GL_ARB_multisample
+#define need_GL_ARB_texture_compression
+#define need_GL_EXT_blend_minmax
+#include "extension_helper.h"
+
+const struct dri_extension card_extensions[] =
+{
+ { "GL_ARB_multisample", GL_ARB_multisample_functions },
+ { "GL_ARB_multitexture", NULL },
+ { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions },
+ { "GL_ARB_texture_env_add", NULL },
+ { "GL_ARB_texture_mirrored_repeat", NULL },
+ { "GL_EXT_blend_subtract", GL_EXT_blend_minmax_functions },
+ { "GL_EXT_texture_edge_clamp", NULL },
+ { "GL_MESA_ycbcr_texture", NULL },
+ { "GL_NV_blend_square", NULL },
+ { "GL_SGIS_generate_mipmap", NULL },
+ { NULL, NULL }
+};
+
+static const struct dri_debug_control debug_control[] =
+{
+ { "ioctl", DEBUG_VERBOSE_IOCTL },
+ { "verb", DEBUG_VERBOSE_MSG },
+ { "dri", DEBUG_VERBOSE_DRI },
+ { "2d", DEBUG_VERBOSE_2D },
+ { "sync", DEBUG_ALWAYS_SYNC },
+ { "api", DEBUG_VERBOSE_API },
+ { "fall", DEBUG_VERBOSE_FALL },
+ { NULL, 0 }
+};
+
+/* Create the device specific context.
+ */
+GLboolean r128CreateContext( const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate )
+{
+ GLcontext *ctx, *shareCtx;
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ struct dd_function_table functions;
+ r128ContextPtr rmesa;
+ r128ScreenPtr r128scrn;
+ int i;
+
+ /* Allocate the r128 context */
+ rmesa = (r128ContextPtr) CALLOC( sizeof(*rmesa) );
+ if ( !rmesa )
+ return GL_FALSE;
+
+ /* Init default driver functions then plug in our Radeon-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions( &functions );
+ r128InitDriverFuncs( &functions );
+ r128InitIoctlFuncs( &functions );
+ r128InitTextureFuncs( &functions );
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((r128ContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ rmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
+ &functions, (void *) rmesa);
+ if (!rmesa->glCtx) {
+ FREE(rmesa);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = rmesa;
+ ctx = rmesa->glCtx;
+
+ rmesa->driContext = driContextPriv;
+ rmesa->driScreen = sPriv;
+ rmesa->driDrawable = NULL;
+ rmesa->hHWContext = driContextPriv->hHWContext;
+ rmesa->driHwLock = &sPriv->pSAREA->lock;
+ rmesa->driFd = sPriv->fd;
+
+ r128scrn = rmesa->r128Screen = (r128ScreenPtr)(sPriv->private);
+
+ /* Parse configuration files */
+ driParseConfigFiles (&rmesa->optionCache, &r128scrn->optionCache,
+ r128scrn->driScreen->myNum, "r128");
+
+ rmesa->sarea = (drm_r128_sarea_t *)((char *)sPriv->pSAREA +
+ r128scrn->sarea_priv_offset);
+
+ rmesa->CurrentTexObj[0] = NULL;
+ rmesa->CurrentTexObj[1] = NULL;
+
+ (void) memset( rmesa->texture_heaps, 0, sizeof( rmesa->texture_heaps ) );
+ make_empty_list( & rmesa->swapped );
+
+ rmesa->nr_heaps = r128scrn->numTexHeaps;
+ for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
+ rmesa->texture_heaps[i] = driCreateTextureHeap( i, rmesa,
+ r128scrn->texSize[i],
+ 12,
+ R128_NR_TEX_REGIONS,
+ (drmTextureRegionPtr)rmesa->sarea->tex_list[i],
+ &rmesa->sarea->tex_age[i],
+ &rmesa->swapped,
+ sizeof( r128TexObj ),
+ (destroy_texture_object_t *) r128DestroyTexObj );
+
+ driSetTextureSwapCounterLocation( rmesa->texture_heaps[i],
+ & rmesa->c_textureSwaps );
+ }
+ rmesa->texture_depth = driQueryOptioni (&rmesa->optionCache,
+ "texture_depth");
+ if (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
+ rmesa->texture_depth = ( r128scrn->cpp == 4 ) ?
+ DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
+
+
+ rmesa->RenderIndex = -1; /* Impossible value */
+ rmesa->vert_buf = NULL;
+ rmesa->num_verts = 0;
+ rmesa->tnl_state = ~0;
+
+ /* Set the maximum texture size small enough that we can guarentee that
+ * all texture units can bind a maximal texture and have them both in
+ * texturable memory at once.
+ */
+
+ ctx->Const.MaxTextureUnits = 2;
+ ctx->Const.MaxTextureImageUnits = 2;
+ ctx->Const.MaxTextureCoordUnits = 2;
+
+ driCalculateMaxTextureLevels( rmesa->texture_heaps,
+ rmesa->nr_heaps,
+ & ctx->Const,
+ 4,
+ 10, /* max 2D texture size is 1024x1024 */
+ 0, /* 3D textures unsupported. */
+ 0, /* cube textures unsupported. */
+ 0, /* texture rectangles unsupported. */
+ 11,
+ GL_FALSE );
+
+ /* No wide points.
+ */
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = 1.0;
+ ctx->Const.MaxPointSizeAA = 1.0;
+
+ /* No wide lines.
+ */
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 1.0;
+ ctx->Const.MaxLineWidthAA = 1.0;
+ ctx->Const.LineWidthGranularity = 1.0;
+
+#if ENABLE_PERF_BOXES
+ rmesa->boxes = driQueryOptionb(&rmesa->optionCache, "performance_boxes");
+#endif
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+
+ /* Install the customized pipeline:
+ */
+/* _tnl_destroy_pipeline( ctx ); */
+/* _tnl_install_pipeline( ctx, r128_pipeline ); */
+
+ /* Configure swrast and T&L to match hardware characteristics:
+ */
+ _swrast_allow_pixel_fog( ctx, GL_FALSE );
+ _swrast_allow_vertex_fog( ctx, GL_TRUE );
+ _tnl_allow_pixel_fog( ctx, GL_FALSE );
+ _tnl_allow_vertex_fog( ctx, GL_TRUE );
+
+ driInitExtensions( ctx, card_extensions, GL_TRUE );
+ if (sPriv->drmMinor >= 4)
+ _mesa_enable_extension( ctx, "GL_MESA_ycbcr_texture" );
+
+ r128InitTriFuncs( ctx );
+ r128DDInitStateFuncs( ctx );
+ r128DDInitSpanFuncs( ctx );
+ r128DDInitState( rmesa );
+
+ rmesa->vblank_flags = (rmesa->r128Screen->irq != 0)
+ ? driGetDefaultVBlankFlags(&rmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
+
+ driContextPriv->driverPrivate = (void *)rmesa;
+
+#if DO_DEBUG
+ R128_DEBUG = driParseDebugString( getenv( "R128_DEBUG" ),
+ debug_control );
+#endif
+
+ if (driQueryOptionb(&rmesa->optionCache, "no_rast")) {
+ fprintf(stderr, "disabling 3D acceleration\n");
+ FALLBACK(rmesa, R128_FALLBACK_DISABLE, 1);
+ }
+
+ return GL_TRUE;
+}
+
+/* Destroy the device specific context.
+ */
+void r128DestroyContext( __DRIcontextPrivate *driContextPriv )
+{
+ r128ContextPtr rmesa = (r128ContextPtr) driContextPriv->driverPrivate;
+
+ assert(rmesa); /* should never be null */
+ if ( rmesa ) {
+ GLboolean release_texture_heaps;
+
+
+ release_texture_heaps = (rmesa->glCtx->Shared->RefCount == 1);
+
+ _swsetup_DestroyContext( rmesa->glCtx );
+ _tnl_DestroyContext( rmesa->glCtx );
+ _ac_DestroyContext( rmesa->glCtx );
+ _swrast_DestroyContext( rmesa->glCtx );
+
+ /* free the Mesa context */
+ rmesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(rmesa->glCtx);
+
+ if ( release_texture_heaps ) {
+ /* This share group is about to go away, free our private
+ * texture object data.
+ */
+ int i;
+
+ for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
+ driDestroyTextureHeap( rmesa->texture_heaps[ i ] );
+ rmesa->texture_heaps[ i ] = NULL;
+ }
+
+ assert( is_empty_list( & rmesa->swapped ) );
+ }
+
+ /* free the option cache */
+ driDestroyOptionCache (&rmesa->optionCache);
+
+ FREE( rmesa );
+ }
+
+#if 0
+ /* Use this to force shared object profiling. */
+ glx_fini_prof();
+#endif
+}
+
+
+/* Force the context `c' to be the current context and associate with it
+ * buffer `b'.
+ */
+GLboolean
+r128MakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv )
+{
+ if ( driContextPriv ) {
+ GET_CURRENT_CONTEXT(ctx);
+ r128ContextPtr oldR128Ctx = ctx ? R128_CONTEXT(ctx) : NULL;
+ r128ContextPtr newR128Ctx = (r128ContextPtr) driContextPriv->driverPrivate;
+
+ if ( newR128Ctx != oldR128Ctx ) {
+ newR128Ctx->new_state |= R128_NEW_CONTEXT;
+ newR128Ctx->dirty = R128_UPLOAD_ALL;
+ }
+
+ driDrawableInitVBlank( driDrawPriv, newR128Ctx->vblank_flags );
+ newR128Ctx->driDrawable = driDrawPriv;
+
+ _mesa_make_current( newR128Ctx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
+
+ newR128Ctx->new_state |= R128_NEW_WINDOW | R128_NEW_CLIP;
+ } else {
+ _mesa_make_current( NULL, NULL, NULL );
+ }
+
+ return GL_TRUE;
+}
+
+
+/* Force the context `c' to be unbound from its buffer.
+ */
+GLboolean
+r128UnbindContext( __DRIcontextPrivate *driContextPriv )
+{
+ return GL_TRUE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_context.h
new file mode 100644
index 000000000..e91257f7f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_context.h
@@ -0,0 +1,269 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_context.h,v 1.12 2002/12/16 16:18:52 dawes Exp $ */
+/**************************************************************************
+
+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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#ifndef __R128_CONTEXT_H__
+#define __R128_CONTEXT_H__
+
+#include "dri_util.h"
+#include "drm.h"
+#include "r128_drm.h"
+
+#include "mtypes.h"
+#include "tnl/t_vertex.h"
+
+#include "r128_reg.h"
+
+#include "texmem.h"
+
+struct r128_context;
+typedef struct r128_context r128ContextRec;
+typedef struct r128_context *r128ContextPtr;
+
+#include "r128_lock.h"
+#include "r128_texobj.h"
+#include "r128_screen.h"
+
+/* Flags for what context state needs to be updated:
+ */
+#define R128_NEW_ALPHA 0x0001
+#define R128_NEW_DEPTH 0x0002
+#define R128_NEW_FOG 0x0004
+#define R128_NEW_CLIP 0x0008
+#define R128_NEW_CULL 0x0010
+#define R128_NEW_MASKS 0x0020
+#define R128_NEW_RENDER_NOT 0x0040
+#define R128_NEW_WINDOW 0x0080
+#define R128_NEW_CONTEXT 0x0100
+#define R128_NEW_ALL 0x01ff
+
+/* 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_STENCIL 0x0008
+#define R128_FALLBACK_RENDER_MODE 0x0010
+#define R128_FALLBACK_LOGICOP 0x0020
+#define R128_FALLBACK_SEP_SPECULAR 0x0040
+#define R128_FALLBACK_BLEND_EQ 0x0080
+#define R128_FALLBACK_BLEND_FUNC 0x0100
+#define R128_FALLBACK_PROJTEX 0x0200
+#define R128_FALLBACK_DISABLE 0x0400
+
+
+/* Use the templated vertex format:
+ */
+#define TAG(x) r128##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+/* Reasons why the GL_BLEND fallback mightn't work:
+ */
+#define R128_BLEND_ENV_COLOR 0x1
+#define R128_BLEND_MULTITEX 0x2
+
+/* Subpixel offsets for window coordinates (triangles):
+ */
+#define SUBPIXEL_X (0.0F)
+#define SUBPIXEL_Y (0.125F)
+
+
+typedef void (*r128_tri_func)( r128ContextPtr,
+ r128Vertex *,
+ r128Vertex *,
+ r128Vertex * );
+
+typedef void (*r128_line_func)( r128ContextPtr,
+ r128Vertex *,
+ r128Vertex * );
+
+typedef void (*r128_point_func)( r128ContextPtr,
+ r128Vertex * );
+
+
+struct r128_context {
+ GLcontext *glCtx; /* Mesa context */
+
+ /* Driver and hardware state management
+ */
+ GLuint new_state;
+ GLuint dirty; /* Hardware state to be updated */
+ drm_r128_context_regs_t setup;
+
+ /* Vertex state */
+ GLuint vertex_size;
+ GLuint vertex_format;
+ struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
+ GLuint vertex_attr_count;
+ char *verts; /* points to tnl->clipspace.vertex_buf */
+ GLuint num_verts;
+ int coloroffset, specoffset;
+ int tnl_state; /* tnl->render_inputs for this _tnl_install_attrs */
+
+ GLuint NewGLState;
+ GLuint Fallback;
+ GLuint RenderIndex;
+ GLfloat hw_viewport[16];
+ GLfloat depth_scale;
+
+ u_int32_t ClearColor; /* Color used to clear color buffer */
+ u_int32_t ClearDepth; /* Value used to clear depth buffer */
+ u_int32_t ClearStencil; /* Value used to clear stencil */
+
+ /* Map GL texture units onto hardware
+ */
+ GLint multitex;
+ GLint tmu_source[2];
+ GLuint tex_combine[2];
+ GLuint blend_flags;
+ GLuint env_color;
+
+ /* Texture object bookkeeping
+ */
+ unsigned nr_heaps;
+ driTexHeap * texture_heaps[ R128_NR_TEX_HEAPS ];
+ driTextureObject swapped;
+
+ r128TexObjPtr CurrentTexObj[2];
+
+ int texture_depth;
+
+ /* Fallback rasterization functions
+ */
+ r128_point_func draw_point;
+ r128_line_func draw_line;
+ r128_tri_func draw_tri;
+
+ /* Vertex buffers
+ */
+ drmBufPtr vert_buf;
+
+ GLuint hw_primitive;
+ GLenum render_primitive;
+
+ /* Page flipping
+ */
+ GLuint doPageFlip;
+
+ /* Drawable, cliprect and scissor information
+ */
+ GLint drawOffset, drawPitch;
+ GLint readOffset, readPitch;
+
+ GLuint numClipRects; /* Cliprects for the draw buffer */
+ drm_clip_rect_t *pClipRects;
+
+ GLuint scissor;
+ drm_clip_rect_t ScissorRect; /* Current software scissor */
+
+ /* Mirrors of some DRI state
+ */
+ __DRIcontextPrivate *driContext; /* DRI context */
+ __DRIscreenPrivate *driScreen; /* DRI screen */
+ __DRIdrawablePrivate *driDrawable; /* DRI drawable bound to this ctx */
+
+ unsigned int lastStamp; /* mirror driDrawable->lastStamp */
+
+ drm_context_t hHWContext;
+ drm_hw_lock_t *driHwLock;
+ int driFd;
+
+ r128ScreenPtr r128Screen; /* Screen private DRI data */
+ drm_r128_sarea_t *sarea; /* Private SAREA data */
+
+ /* Performance counters
+ */
+ GLuint boxes; /* Draw performance boxes */
+ GLuint hardwareWentIdle;
+ GLuint c_clears;
+ GLuint c_drawWaits;
+ GLuint c_textureSwaps;
+ GLuint c_textureBytes;
+ GLuint c_vertexBuffers;
+
+ /* VBI
+ */
+ GLuint vbl_seq;
+ GLuint vblank_flags;
+
+ /* Configuration cache
+ */
+ driOptionCache optionCache;
+};
+
+#define R128_CONTEXT(ctx) ((r128ContextPtr)(ctx->DriverCtx))
+
+#define R128_IS_PLAIN( rmesa ) \
+ (rmesa->r128Screen->chipset == R128_CARD_TYPE_R128)
+#define R128_IS_PRO( rmesa ) \
+ (rmesa->r128Screen->chipset == R128_CARD_TYPE_R128_PRO)
+#define R128_IS_MOBILITY( rmesa ) \
+ (rmesa->r128Screen->chipset == R128_CARD_TYPE_R128_MOBILITY)
+
+
+extern GLboolean r128CreateContext( const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate );
+
+extern void r128DestroyContext( __DRIcontextPrivate * );
+
+extern GLboolean r128MakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv );
+
+extern GLboolean r128UnbindContext( __DRIcontextPrivate *driContextPriv );
+
+/* ================================================================
+ * Debugging:
+ */
+#define DO_DEBUG 1
+#define ENABLE_PERF_BOXES 0
+
+#if DO_DEBUG
+extern int R128_DEBUG;
+#else
+#define R128_DEBUG 0
+#endif
+
+#define DEBUG_ALWAYS_SYNC 0x01
+#define DEBUG_VERBOSE_API 0x02
+#define DEBUG_VERBOSE_MSG 0x04
+#define DEBUG_VERBOSE_LRU 0x08
+#define DEBUG_VERBOSE_DRI 0x10
+#define DEBUG_VERBOSE_IOCTL 0x20
+#define DEBUG_VERBOSE_2D 0x40
+#define DEBUG_VERBOSE_FALL 0x80
+
+#endif /* __R128_CONTEXT_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_dd.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_dd.c
new file mode 100644
index 000000000..59480b25d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_dd.c
@@ -0,0 +1,148 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_dd.c,v 1.15 2002/10/30 12:51:38 alanh Exp $ */
+/**************************************************************************
+
+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@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ *
+ */
+
+#include "r128_context.h"
+#include "r128_ioctl.h"
+#include "r128_state.h"
+#include "r128_dd.h"
+#include "swrast/swrast.h"
+
+#include "context.h"
+#include "framebuffer.h"
+
+#include "utils.h"
+
+#define DRIVER_DATE "20041026"
+
+
+/* Return the width and height of the current color buffer.
+ */
+static void r128GetBufferSize( GLframebuffer *buffer,
+ GLuint *width, GLuint *height )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ LOCK_HARDWARE( rmesa );
+ *width = rmesa->driDrawable->w;
+ *height = rmesa->driDrawable->h;
+ UNLOCK_HARDWARE( rmesa );
+}
+
+/* Return various strings for glGetString().
+ */
+static const GLubyte *r128GetString( GLcontext *ctx, GLenum name )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ static char buffer[128];
+ unsigned offset;
+ const char * card_name = "Rage 128";
+ GLuint agp_mode = rmesa->r128Screen->IsPCI ? 0 :
+ rmesa->r128Screen->AGPMode;
+
+ switch ( name ) {
+ case GL_VENDOR:
+ return (GLubyte *)"VA Linux Systems, Inc.";
+
+ case GL_RENDERER:
+ /* Select the spefic chipset.
+ */
+ if ( R128_IS_PRO( rmesa ) ) {
+ card_name = "Rage 128 Pro";
+ }
+ else if ( R128_IS_MOBILITY( rmesa ) ) {
+ card_name = "Rage 128 Mobility";
+ }
+
+ offset = driGetRendererString( buffer, card_name, DRIVER_DATE,
+ agp_mode );
+
+ return (GLubyte *)buffer;
+
+ 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 r128Flush( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ FLUSH_BATCH( rmesa );
+
+#if ENABLE_PERF_BOXES
+ if ( rmesa->boxes ) {
+ LOCK_HARDWARE( rmesa );
+ r128PerformanceBoxesLocked( rmesa );
+ UNLOCK_HARDWARE( rmesa );
+ }
+
+ /* Log the performance counters if necessary */
+ r128PerformanceCounters( rmesa );
+#endif
+}
+
+/* Make sure all commands have been sent to the hardware and have
+ * completed processing.
+ */
+static void r128Finish( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+#if ENABLE_PERF_BOXES
+ /* Bump the performance counter */
+ rmesa->c_drawWaits++;
+#endif
+
+ r128Flush( ctx );
+ r128WaitForIdle( rmesa );
+}
+
+
+/* Initialize the driver's misc functions.
+ */
+void r128InitDriverFuncs( struct dd_function_table *functions )
+{
+ functions->GetBufferSize = r128GetBufferSize;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
+ functions->GetString = r128GetString;
+ functions->Finish = r128Finish;
+ functions->Flush = r128Flush;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_dd.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_dd.h
new file mode 100644
index 000000000..7a0abb73f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_dd.h
@@ -0,0 +1,41 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_dd.h,v 1.3 2001/01/08 01:07:20 martin Exp $ */
+/**************************************************************************
+
+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@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ *
+ */
+
+#ifndef __R128_DD_H__
+#define __R128_DD_H__
+
+extern void r128InitDriverFuncs( struct dd_function_table *functions );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_ioctl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_ioctl.c
new file mode 100644
index 000000000..fc017329c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_ioctl.c
@@ -0,0 +1,813 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c,v 1.10 2002/12/16 16:18:53 dawes Exp $ */
+/**************************************************************************
+
+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@valinux.com>
+ *
+ */
+#include <errno.h>
+
+#define STANDALONE_MMIO
+#include "r128_context.h"
+#include "r128_state.h"
+#include "r128_ioctl.h"
+#include "imports.h"
+#include "macros.h"
+
+#include "swrast/swrast.h"
+
+#include "vblank.h"
+#include "mmio.h"
+
+#define R128_TIMEOUT 2048
+#define R128_IDLE_RETRY 32
+
+
+/* =============================================================
+ * Hardware vertex buffer handling
+ */
+
+/* Get a new VB from the pool of vertex buffers in AGP space.
+ */
+drmBufPtr r128GetBufferLocked( r128ContextPtr rmesa )
+{
+ int fd = rmesa->r128Screen->driScreen->fd;
+ int index = 0;
+ int size = 0;
+ drmDMAReq dma;
+ drmBufPtr buf = NULL;
+ int to = 0;
+ int ret;
+
+ dma.context = rmesa->hHWContext;
+ dma.send_count = 0;
+ dma.send_list = NULL;
+ dma.send_sizes = NULL;
+ dma.flags = 0;
+ dma.request_count = 1;
+ dma.request_size = R128_BUFFER_SIZE;
+ dma.request_list = &index;
+ dma.request_sizes = &size;
+ dma.granted_count = 0;
+
+ while ( !buf && ( to++ < R128_TIMEOUT ) ) {
+ ret = drmDMA( fd, &dma );
+
+ if ( ret == 0 ) {
+ buf = &rmesa->r128Screen->buffers->list[index];
+ buf->used = 0;
+#if ENABLE_PERF_BOXES
+ /* Bump the performance counter */
+ rmesa->c_vertexBuffers++;
+#endif
+ return buf;
+ }
+ }
+
+ if ( !buf ) {
+ drmCommandNone( fd, DRM_R128_CCE_RESET);
+ UNLOCK_HARDWARE( rmesa );
+ fprintf( stderr, "Error: Could not get new VB... exiting\n" );
+ exit( -1 );
+ }
+
+ return buf;
+}
+
+void r128FlushVerticesLocked( r128ContextPtr rmesa )
+{
+ drm_clip_rect_t *pbox = rmesa->pClipRects;
+ int nbox = rmesa->numClipRects;
+ drmBufPtr buffer = rmesa->vert_buf;
+ int count = rmesa->num_verts;
+ int prim = rmesa->hw_primitive;
+ int fd = rmesa->driScreen->fd;
+ drm_r128_vertex_t vertex;
+ int i;
+
+ rmesa->num_verts = 0;
+ rmesa->vert_buf = NULL;
+
+ if ( !buffer )
+ return;
+
+ if ( rmesa->dirty & ~R128_UPLOAD_CLIPRECTS )
+ r128EmitHwStateLocked( rmesa );
+
+ if ( !nbox )
+ count = 0;
+
+ if ( nbox >= R128_NR_SAREA_CLIPRECTS )
+ rmesa->dirty |= R128_UPLOAD_CLIPRECTS;
+
+ if ( !count || !(rmesa->dirty & R128_UPLOAD_CLIPRECTS) )
+ {
+ if ( nbox < 3 ) {
+ rmesa->sarea->nbox = 0;
+ } else {
+ rmesa->sarea->nbox = nbox;
+ }
+
+ vertex.prim = prim;
+ vertex.idx = buffer->idx;
+ vertex.count = count;
+ vertex.discard = 1;
+ drmCommandWrite( fd, DRM_R128_VERTEX, &vertex, sizeof(vertex) );
+ }
+ else
+ {
+ for ( i = 0 ; i < nbox ; ) {
+ int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
+ drm_clip_rect_t *b = rmesa->sarea->boxes;
+ int discard = 0;
+
+ rmesa->sarea->nbox = nr - i;
+ for ( ; i < nr ; i++ ) {
+ *b++ = pbox[i];
+ }
+
+ /* Finished with the buffer?
+ */
+ if ( nr == nbox ) {
+ discard = 1;
+ }
+
+ rmesa->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
+
+ vertex.prim = prim;
+ vertex.idx = buffer->idx;
+ vertex.count = count;
+ vertex.discard = discard;
+ drmCommandWrite( fd, DRM_R128_VERTEX, &vertex, sizeof(vertex) );
+ }
+ }
+
+ rmesa->dirty &= ~R128_UPLOAD_CLIPRECTS;
+}
+
+
+
+
+
+/* ================================================================
+ * Texture uploads
+ */
+
+void r128FireBlitLocked( r128ContextPtr rmesa, drmBufPtr buffer,
+ GLint offset, GLint pitch, GLint format,
+ GLint x, GLint y, GLint width, GLint height )
+{
+ drm_r128_blit_t blit;
+ GLint ret;
+
+ blit.idx = buffer->idx;
+ blit.offset = offset;
+ blit.pitch = pitch;
+ blit.format = format;
+ blit.x = x;
+ blit.y = y;
+ blit.width = width;
+ blit.height = height;
+
+ ret = drmCommandWrite( rmesa->driFd, DRM_R128_BLIT,
+ &blit, sizeof(blit) );
+
+ if ( ret ) {
+ UNLOCK_HARDWARE( rmesa );
+ fprintf( stderr, "DRM_R128_BLIT: return = %d\n", ret );
+ exit( 1 );
+ }
+}
+
+
+/* ================================================================
+ * SwapBuffers with client-side throttling
+ */
+
+static void delay( void ) {
+/* Prevent an optimizing compiler from removing a spin loop */
+}
+
+#define R128_MAX_OUTSTANDING 2
+
+
+/* Throttle the frame rate -- only allow one pending swap buffers
+ * request at a time.
+ * GH: We probably don't want a timeout here, as we can wait as
+ * long as we want for a frame to complete. If it never does, then
+ * the card has locked.
+ */
+static int r128WaitForFrameCompletion( r128ContextPtr rmesa )
+{
+ unsigned char *R128MMIO = rmesa->r128Screen->mmio.map;
+ int i;
+ int wait = 0;
+
+ while ( 1 ) {
+ u_int32_t frame = read_MMIO_LE32( R128MMIO, R128_LAST_FRAME_REG );
+
+ if ( rmesa->sarea->last_frame - frame <= R128_MAX_OUTSTANDING ) {
+ break;
+ }
+
+ /* Spin in place a bit so we aren't hammering the register */
+ wait++;
+ for ( i = 0 ; i < 1024 ; i++ ) {
+ delay();
+ }
+ }
+
+ return wait;
+}
+
+/* Copy the back color buffer to the front color buffer.
+ */
+void r128CopyBuffer( const __DRIdrawablePrivate *dPriv )
+{
+ r128ContextPtr rmesa;
+ GLint nbox, i, ret;
+ GLboolean missed_target;
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ rmesa = (r128ContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "\n********************************\n" );
+ fprintf( stderr, "\n%s( %p )\n\n",
+ __FUNCTION__, (void *)rmesa->glCtx );
+ fflush( stderr );
+ }
+
+ FLUSH_BATCH( rmesa );
+
+ LOCK_HARDWARE( rmesa );
+
+ /* Throttle the frame rate -- only allow one pending swap buffers
+ * request at a time.
+ */
+ if ( !r128WaitForFrameCompletion( rmesa ) ) {
+ rmesa->hardwareWentIdle = 1;
+ } else {
+ rmesa->hardwareWentIdle = 0;
+ }
+
+ UNLOCK_HARDWARE( rmesa );
+ driWaitForVBlank( dPriv, &rmesa->vbl_seq, rmesa->vblank_flags, &missed_target );
+ LOCK_HARDWARE( rmesa );
+
+ nbox = dPriv->numClipRects; /* must be in locked region */
+
+ for ( i = 0 ; i < nbox ; ) {
+ GLint nr = MIN2( i + R128_NR_SAREA_CLIPRECTS , nbox );
+ drm_clip_rect_t *box = dPriv->pClipRects;
+ drm_clip_rect_t *b = rmesa->sarea->boxes;
+ GLint n = 0;
+
+ for ( ; i < nr ; i++ ) {
+ *b++ = box[i];
+ n++;
+ }
+ rmesa->sarea->nbox = n;
+
+ ret = drmCommandNone( rmesa->driFd, DRM_R128_SWAP );
+
+ if ( ret ) {
+ UNLOCK_HARDWARE( rmesa );
+ fprintf( stderr, "DRM_R128_SWAP: return = %d\n", ret );
+ exit( 1 );
+ }
+ }
+
+ if ( R128_DEBUG & DEBUG_ALWAYS_SYNC ) {
+ i = 0;
+ do {
+ ret = drmCommandNone(rmesa->driFd, DRM_R128_CCE_IDLE);
+ } while ( ret && errno == EBUSY && i++ < R128_IDLE_RETRY );
+ }
+
+ UNLOCK_HARDWARE( rmesa );
+
+ rmesa->new_state |= R128_NEW_CONTEXT;
+ rmesa->dirty |= (R128_UPLOAD_CONTEXT |
+ R128_UPLOAD_MASKS |
+ R128_UPLOAD_CLIPRECTS);
+
+#if ENABLE_PERF_BOXES
+ /* Log the performance counters if necessary */
+ r128PerformanceCounters( rmesa );
+#endif
+}
+
+void r128PageFlip( const __DRIdrawablePrivate *dPriv )
+{
+ r128ContextPtr rmesa;
+ GLint ret;
+ GLboolean missed_target;
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ rmesa = (r128ContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "\n%s( %p ): page=%d\n\n",
+ __FUNCTION__, (void *)rmesa->glCtx, rmesa->sarea->pfCurrentPage );
+ }
+
+ FLUSH_BATCH( rmesa );
+
+ LOCK_HARDWARE( rmesa );
+
+ /* Throttle the frame rate -- only allow one pending swap buffers
+ * request at a time.
+ */
+ if ( !r128WaitForFrameCompletion( rmesa ) ) {
+ rmesa->hardwareWentIdle = 1;
+ } else {
+ rmesa->hardwareWentIdle = 0;
+ }
+
+ UNLOCK_HARDWARE( rmesa );
+ driWaitForVBlank( dPriv, &rmesa->vbl_seq, rmesa->vblank_flags, &missed_target );
+ LOCK_HARDWARE( rmesa );
+
+ /* The kernel will have been initialized to perform page flipping
+ * on a swapbuffers ioctl.
+ */
+ ret = drmCommandNone( rmesa->driFd, DRM_R128_FLIP );
+
+ UNLOCK_HARDWARE( rmesa );
+
+ if ( ret ) {
+ fprintf( stderr, "DRM_R128_FLIP: return = %d\n", ret );
+ exit( 1 );
+ }
+
+ if ( rmesa->sarea->pfCurrentPage == 1 ) {
+ rmesa->drawOffset = rmesa->r128Screen->frontOffset;
+ rmesa->drawPitch = rmesa->r128Screen->frontPitch;
+ } else {
+ rmesa->drawOffset = rmesa->r128Screen->backOffset;
+ rmesa->drawPitch = rmesa->r128Screen->backPitch;
+ }
+
+ rmesa->setup.dst_pitch_offset_c = (((rmesa->drawPitch/8) << 21) |
+ (rmesa->drawOffset >> 5));
+ rmesa->new_state |= R128_NEW_WINDOW;
+
+ /* FIXME: Do we need this anymore? */
+ rmesa->new_state |= R128_NEW_CONTEXT;
+ rmesa->dirty |= (R128_UPLOAD_CONTEXT |
+ R128_UPLOAD_MASKS |
+ R128_UPLOAD_CLIPRECTS);
+
+#if ENABLE_PERF_BOXES
+ /* Log the performance counters if necessary */
+ r128PerformanceCounters( rmesa );
+#endif
+}
+
+
+/* ================================================================
+ * Buffer clear
+ */
+
+static void r128Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = rmesa->driDrawable;
+ drm_r128_clear_t clear;
+ GLuint flags = 0;
+ GLint i;
+ GLint ret;
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s:\n", __FUNCTION__ );
+ }
+
+ FLUSH_BATCH( rmesa );
+
+ /* The only state change we care about here is the RGBA colormask
+ * We'll just update that state, if needed. If we do more then
+ * there's some strange side-effects that the conformance tests find.
+ */
+ if ( rmesa->new_state & R128_NEW_MASKS) {
+ const GLuint save_state = rmesa->new_state;
+ rmesa->new_state = R128_NEW_MASKS;
+ r128DDUpdateHWState( ctx );
+ rmesa->new_state = save_state & ~R128_NEW_MASKS;
+ }
+
+ if ( mask & BUFFER_BIT_FRONT_LEFT ) {
+ flags |= R128_FRONT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
+ }
+
+ if ( mask & BUFFER_BIT_BACK_LEFT ) {
+ flags |= R128_BACK;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
+ }
+
+ if ( ( mask & BUFFER_BIT_DEPTH ) && ctx->Depth.Mask ) {
+ flags |= R128_DEPTH;
+ mask &= ~BUFFER_BIT_DEPTH;
+ }
+#if 0
+ /* FIXME: Add stencil support */
+ if ( mask & BUFFER_BIT_STENCIL ) {
+ flags |= DRM_R128_DEPTH_BUFFER;
+ mask &= ~BUFFER_BIT_STENCIL;
+ }
+#endif
+
+ if ( flags ) {
+
+ /* Flip top to bottom */
+ cx += dPriv->x;
+ cy = dPriv->y + dPriv->h - cy - ch;
+
+ LOCK_HARDWARE( rmesa );
+
+ /* FIXME: Do we actually need this?
+ */
+ if ( rmesa->dirty & ~R128_UPLOAD_CLIPRECTS ) {
+ r128EmitHwStateLocked( rmesa );
+ }
+
+ for ( i = 0 ; i < rmesa->numClipRects ; ) {
+ GLint nr = MIN2( i + R128_NR_SAREA_CLIPRECTS , rmesa->numClipRects );
+ drm_clip_rect_t *box = rmesa->pClipRects;
+ drm_clip_rect_t *b = rmesa->sarea->boxes;
+ GLint n = 0;
+
+ if ( !all ) {
+ for ( ; i < nr ; i++ ) {
+ GLint x = box[i].x1;
+ GLint y = box[i].y1;
+ GLint w = box[i].x2 - x;
+ GLint h = box[i].y2 - y;
+
+ 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 ) continue;
+ if ( h <= 0 ) continue;
+
+ b->x1 = x;
+ b->y1 = y;
+ b->x2 = x + w;
+ b->y2 = y + h;
+ b++;
+ n++;
+ }
+ } else {
+ for ( ; i < nr ; i++ ) {
+ *b++ = box[i];
+ n++;
+ }
+ }
+
+ rmesa->sarea->nbox = n;
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_IOCTL ) {
+ fprintf( stderr,
+ "DRM_R128_CLEAR: flag 0x%x color %x depth %x nbox %d\n",
+ flags,
+ (GLuint)rmesa->ClearColor,
+ (GLuint)rmesa->ClearDepth,
+ rmesa->sarea->nbox );
+ }
+
+ clear.flags = flags;
+ clear.clear_color = rmesa->ClearColor;
+ clear.clear_depth = rmesa->ClearDepth;
+ clear.color_mask = rmesa->setup.plane_3d_mask_c;
+ clear.depth_mask = ~0;
+
+ ret = drmCommandWrite( rmesa->driFd, DRM_R128_CLEAR,
+ &clear, sizeof(clear) );
+
+ if ( ret ) {
+ UNLOCK_HARDWARE( rmesa );
+ fprintf( stderr, "DRM_R128_CLEAR: return = %d\n", ret );
+ exit( 1 );
+ }
+ }
+
+ UNLOCK_HARDWARE( rmesa );
+
+ rmesa->dirty |= R128_UPLOAD_CLIPRECTS;
+ }
+
+ if ( mask )
+ _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
+}
+
+
+/* ================================================================
+ * Depth spans, pixels
+ */
+
+void r128WriteDepthSpanLocked( r128ContextPtr rmesa,
+ GLuint n, GLint x, GLint y,
+ const GLdepth depth[],
+ const GLubyte mask[] )
+{
+ drm_clip_rect_t *pbox = rmesa->pClipRects;
+ drm_r128_depth_t d;
+ int nbox = rmesa->numClipRects;
+ int fd = rmesa->driScreen->fd;
+ int i;
+
+ if ( !nbox || !n ) {
+ return;
+ }
+ if ( nbox >= R128_NR_SAREA_CLIPRECTS ) {
+ rmesa->dirty |= R128_UPLOAD_CLIPRECTS;
+ }
+
+ if ( !(rmesa->dirty & R128_UPLOAD_CLIPRECTS) )
+ {
+ if ( nbox < 3 ) {
+ rmesa->sarea->nbox = 0;
+ } else {
+ rmesa->sarea->nbox = nbox;
+ }
+
+ d.func = R128_WRITE_SPAN;
+ d.n = n;
+ d.x = (int*)&x;
+ d.y = (int*)&y;
+ d.buffer = (unsigned int *)depth;
+ d.mask = (unsigned char *)mask;
+
+ drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d));
+
+ }
+ else
+ {
+ for (i = 0 ; i < nbox ; ) {
+ int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
+ drm_clip_rect_t *b = rmesa->sarea->boxes;
+
+ rmesa->sarea->nbox = nr - i;
+ for ( ; i < nr ; i++) {
+ *b++ = pbox[i];
+ }
+
+ rmesa->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
+
+ d.func = R128_WRITE_SPAN;
+ d.n = n;
+ d.x = (int*)&x;
+ d.y = (int*)&y;
+ d.buffer = (unsigned int *)depth;
+ d.mask = (unsigned char *)mask;
+
+ drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d));
+ }
+ }
+
+ rmesa->dirty &= ~R128_UPLOAD_CLIPRECTS;
+}
+
+void r128WriteDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
+ const GLint x[], const GLint y[],
+ const GLdepth depth[],
+ const GLubyte mask[] )
+{
+ drm_clip_rect_t *pbox = rmesa->pClipRects;
+ drm_r128_depth_t d;
+ int nbox = rmesa->numClipRects;
+ int fd = rmesa->driScreen->fd;
+ int i;
+
+ if ( !nbox || !n ) {
+ return;
+ }
+ if ( nbox >= R128_NR_SAREA_CLIPRECTS ) {
+ rmesa->dirty |= R128_UPLOAD_CLIPRECTS;
+ }
+
+ if ( !(rmesa->dirty & R128_UPLOAD_CLIPRECTS) )
+ {
+ if ( nbox < 3 ) {
+ rmesa->sarea->nbox = 0;
+ } else {
+ rmesa->sarea->nbox = nbox;
+ }
+
+ d.func = R128_WRITE_PIXELS;
+ d.n = n;
+ d.x = (int*)&x;
+ d.y = (int*)&y;
+ d.buffer = (unsigned int *)depth;
+ d.mask = (unsigned char *)mask;
+
+ drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d));
+ }
+ else
+ {
+ for (i = 0 ; i < nbox ; ) {
+ int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
+ drm_clip_rect_t *b = rmesa->sarea->boxes;
+
+ rmesa->sarea->nbox = nr - i;
+ for ( ; i < nr ; i++) {
+ *b++ = pbox[i];
+ }
+
+ rmesa->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
+
+ d.func = R128_WRITE_PIXELS;
+ d.n = n;
+ d.x = (int*)&x;
+ d.y = (int*)&y;
+ d.buffer = (unsigned int *)depth;
+ d.mask = (unsigned char *)mask;
+
+ drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d));
+ }
+ }
+
+ rmesa->dirty &= ~R128_UPLOAD_CLIPRECTS;
+}
+
+void r128ReadDepthSpanLocked( r128ContextPtr rmesa,
+ GLuint n, GLint x, GLint y )
+{
+ drm_clip_rect_t *pbox = rmesa->pClipRects;
+ drm_r128_depth_t d;
+ int nbox = rmesa->numClipRects;
+ int fd = rmesa->driScreen->fd;
+ int i;
+
+ if ( !nbox || !n ) {
+ return;
+ }
+ if ( nbox >= R128_NR_SAREA_CLIPRECTS ) {
+ rmesa->dirty |= R128_UPLOAD_CLIPRECTS;
+ }
+
+ if ( !(rmesa->dirty & R128_UPLOAD_CLIPRECTS) )
+ {
+ if ( nbox < 3 ) {
+ rmesa->sarea->nbox = 0;
+ } else {
+ rmesa->sarea->nbox = nbox;
+ }
+
+ d.func = R128_READ_SPAN;
+ d.n = n;
+ d.x = (int*)&x;
+ d.y = (int*)&y;
+ d.buffer = NULL;
+ d.mask = NULL;
+
+ drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d));
+ }
+ else
+ {
+ for (i = 0 ; i < nbox ; ) {
+ int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
+ drm_clip_rect_t *b = rmesa->sarea->boxes;
+
+ rmesa->sarea->nbox = nr - i;
+ for ( ; i < nr ; i++) {
+ *b++ = pbox[i];
+ }
+
+ rmesa->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
+
+ d.func = R128_READ_SPAN;
+ d.n = n;
+ d.x = (int*)&x;
+ d.y = (int*)&y;
+ d.buffer = NULL;
+ d.mask = NULL;
+
+ drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d));
+ }
+ }
+
+ rmesa->dirty &= ~R128_UPLOAD_CLIPRECTS;
+}
+
+void r128ReadDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
+ const GLint x[], const GLint y[] )
+{
+ drm_clip_rect_t *pbox = rmesa->pClipRects;
+ drm_r128_depth_t d;
+ int nbox = rmesa->numClipRects;
+ int fd = rmesa->driScreen->fd;
+ int i;
+
+ if ( !nbox || !n ) {
+ return;
+ }
+ if ( nbox >= R128_NR_SAREA_CLIPRECTS ) {
+ rmesa->dirty |= R128_UPLOAD_CLIPRECTS;
+ }
+
+ if ( !(rmesa->dirty & R128_UPLOAD_CLIPRECTS) )
+ {
+ if ( nbox < 3 ) {
+ rmesa->sarea->nbox = 0;
+ } else {
+ rmesa->sarea->nbox = nbox;
+ }
+
+ d.func = R128_READ_PIXELS;
+ d.n = n;
+ d.x = (int*)&x;
+ d.y = (int*)&y;
+ d.buffer = NULL;
+ d.mask = NULL;
+
+ drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d));
+ }
+ else
+ {
+ for (i = 0 ; i < nbox ; ) {
+ int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
+ drm_clip_rect_t *b = rmesa->sarea->boxes;
+
+ rmesa->sarea->nbox = nr - i;
+ for ( ; i < nr ; i++) {
+ *b++ = pbox[i];
+ }
+
+ rmesa->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
+
+ d.func = R128_READ_PIXELS;
+ d.n = n;
+ d.x = (int*)&x;
+ d.y = (int*)&y;
+ d.buffer = NULL;
+ d.mask = NULL;
+
+ drmCommandWrite( fd, DRM_R128_DEPTH, &d, sizeof(d));
+ }
+ }
+
+ rmesa->dirty &= ~R128_UPLOAD_CLIPRECTS;
+}
+
+
+void r128WaitForIdleLocked( r128ContextPtr rmesa )
+{
+ int fd = rmesa->r128Screen->driScreen->fd;
+ int to = 0;
+ int ret, i;
+
+ do {
+ i = 0;
+ do {
+ ret = drmCommandNone( fd, DRM_R128_CCE_IDLE);
+ } while ( ret && errno == EBUSY && i++ < R128_IDLE_RETRY );
+ } while ( ( ret == -EBUSY ) && ( to++ < R128_TIMEOUT ) );
+
+ if ( ret < 0 ) {
+ drmCommandNone( fd, DRM_R128_CCE_RESET);
+ UNLOCK_HARDWARE( rmesa );
+ fprintf( stderr, "Error: Rage 128 timed out... exiting\n" );
+ exit( -1 );
+ }
+}
+
+void r128InitIoctlFuncs( struct dd_function_table *functions )
+{
+ functions->Clear = r128Clear;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_ioctl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_ioctl.h
new file mode 100644
index 000000000..d2f2dded8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_ioctl.h
@@ -0,0 +1,144 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h,v 1.6 2002/12/16 16:18:53 dawes Exp $ */
+/**************************************************************************
+
+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@valinux.com>
+ *
+ */
+
+#ifndef __R128_IOCTL_H__
+#define __R128_IOCTL_H__
+
+#include "r128_dri.h"
+#include "r128_reg.h"
+#include "r128_lock.h"
+
+#define R128_BUFFER_MAX_DWORDS (R128_BUFFER_SIZE / sizeof(u_int32_t))
+
+
+extern drmBufPtr r128GetBufferLocked( r128ContextPtr rmesa );
+extern void r128FlushVerticesLocked( r128ContextPtr rmesa );
+
+static __inline void *r128AllocDmaLow( r128ContextPtr rmesa, int count,
+ int vert_size )
+{
+ u_int32_t *head;
+ int bytes = count * vert_size;
+
+ if ( !rmesa->vert_buf ) {
+ LOCK_HARDWARE( rmesa );
+ rmesa->vert_buf = r128GetBufferLocked( rmesa );
+ UNLOCK_HARDWARE( rmesa );
+ } else if ( rmesa->vert_buf->used + bytes > rmesa->vert_buf->total ) {
+ LOCK_HARDWARE( rmesa );
+ r128FlushVerticesLocked( rmesa );
+ rmesa->vert_buf = r128GetBufferLocked( rmesa );
+ UNLOCK_HARDWARE( rmesa );
+ }
+
+ head = (u_int32_t *)((char *)rmesa->vert_buf->address + rmesa->vert_buf->used);
+ rmesa->vert_buf->used += bytes;
+ rmesa->num_verts += count;
+
+ return head;
+}
+
+extern void r128FireBlitLocked( r128ContextPtr rmesa, drmBufPtr buffer,
+ GLint offset, GLint pitch, GLint format,
+ GLint x, GLint y, GLint width, GLint height );
+
+extern void r128WriteDepthSpanLocked( r128ContextPtr rmesa,
+ GLuint n, GLint x, GLint y,
+ const GLdepth depth[],
+ const GLubyte mask[] );
+extern void r128WriteDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
+ const GLint x[], const GLint y[],
+ const GLdepth depth[],
+ const GLubyte mask[] );
+extern void r128ReadDepthSpanLocked( r128ContextPtr rmesa,
+ GLuint n, GLint x, GLint y );
+extern void r128ReadDepthPixelsLocked( r128ContextPtr rmesa, GLuint n,
+ const GLint x[], const GLint y[] );
+
+extern void r128CopyBuffer( const __DRIdrawablePrivate *dPriv );
+extern void r128PageFlip( const __DRIdrawablePrivate *dPriv );
+void r128WaitForVBlank( r128ContextPtr rmesa );
+
+extern void r128WaitForIdleLocked( r128ContextPtr rmesa );
+
+
+extern void r128InitIoctlFuncs( struct dd_function_table *functions );
+
+
+/* ================================================================
+ * Helper macros:
+ */
+
+#define FLUSH_BATCH( rmesa ) \
+do { \
+ if ( R128_DEBUG & DEBUG_VERBOSE_IOCTL ) \
+ fprintf( stderr, "FLUSH_BATCH in %s\n", __FUNCTION__ ); \
+ if ( rmesa->vert_buf ) { \
+ r128FlushVertices( rmesa ); \
+ } \
+} while (0)
+
+/* 64-bit align the next element address, and then make room for the
+ * next indexed prim packet header.
+ */
+#define ALIGN_NEXT_ELT( rmesa ) \
+do { \
+ rmesa->next_elt = (GLushort *) \
+ (((GLuint)rmesa->next_elt + 7) & ~0x7); \
+ rmesa->next_elt = (GLushort *) \
+ ((GLubyte *)rmesa->next_elt + R128_INDEX_PRIM_OFFSET); \
+} while (0)
+
+#define r128FlushVertices( rmesa ) \
+do { \
+ LOCK_HARDWARE( rmesa ); \
+ r128FlushVerticesLocked( rmesa ); \
+ UNLOCK_HARDWARE( rmesa ); \
+} while (0)
+
+#define r128FlushElts( rmesa ) \
+do { \
+ LOCK_HARDWARE( rmesa ); \
+ r128FlushEltsLocked( rmesa ); \
+ UNLOCK_HARDWARE( rmesa ); \
+} while (0)
+
+#define r128WaitForIdle( rmesa ) \
+ do { \
+ LOCK_HARDWARE( rmesa ); \
+ r128WaitForIdleLocked( rmesa ); \
+ UNLOCK_HARDWARE( rmesa ); \
+ } while (0)
+
+#endif /* __R128_IOCTL_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_lock.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_lock.c
new file mode 100644
index 000000000..ea4ccfb2e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_lock.c
@@ -0,0 +1,123 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_lock.c,v 1.5 2002/10/30 12:51:38 alanh Exp $ */
+/**************************************************************************
+
+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@valinux.com>
+ *
+ */
+
+#include "r128_context.h"
+#include "r128_lock.h"
+#include "r128_tex.h"
+#include "r128_state.h"
+
+#if DEBUG_LOCKING
+char *prevLockFile = NULL;
+int prevLockLine = 0;
+#endif
+
+
+/* Turn on/off page flipping according to the flags in the sarea:
+ */
+static void
+r128UpdatePageFlipping( r128ContextPtr rmesa )
+{
+ int use_back;
+
+ rmesa->doPageFlip = rmesa->sarea->pfAllowPageFlip;
+
+ use_back = (rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT);
+ use_back ^= (rmesa->sarea->pfCurrentPage == 1);
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_API )
+ fprintf(stderr, "%s allow %d current %d\n", __FUNCTION__,
+ rmesa->doPageFlip,
+ rmesa->sarea->pfCurrentPage );
+
+ if ( use_back ) {
+ rmesa->drawOffset = rmesa->r128Screen->backOffset;
+ rmesa->drawPitch = rmesa->r128Screen->backPitch;
+ } else {
+ rmesa->drawOffset = rmesa->r128Screen->frontOffset;
+ rmesa->drawPitch = rmesa->r128Screen->frontPitch;
+ }
+
+ rmesa->setup.dst_pitch_offset_c = (((rmesa->drawPitch/8) << 21) |
+ (rmesa->drawOffset >> 5));
+ rmesa->new_state |= R128_NEW_WINDOW;
+}
+
+/* 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.
+ */
+void r128GetLock( r128ContextPtr rmesa, GLuint flags )
+{
+ __DRIdrawablePrivate *dPriv = rmesa->driDrawable;
+ __DRIscreenPrivate *sPriv = rmesa->driScreen;
+ drm_r128_sarea_t *sarea = rmesa->sarea;
+ int i;
+
+ drmGetLock( rmesa->driFd, rmesa->hHWContext, flags );
+
+ /* 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.
+ */
+ DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
+
+ if ( rmesa->lastStamp != dPriv->lastStamp ) {
+ r128UpdatePageFlipping( rmesa );
+ rmesa->lastStamp = dPriv->lastStamp;
+ rmesa->new_state |= R128_NEW_CLIP;
+ rmesa->tnl_state = ~0;
+ }
+
+ rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_CLIPRECTS;
+
+ rmesa->numClipRects = dPriv->numClipRects;
+ rmesa->pClipRects = dPriv->pClipRects;
+
+ if ( sarea->ctx_owner != rmesa->hHWContext ) {
+ sarea->ctx_owner = rmesa->hHWContext;
+ rmesa->dirty = R128_UPLOAD_ALL;
+ }
+
+ for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
+ DRI_AGE_TEXTURES( rmesa->texture_heaps[i] );
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_lock.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_lock.h
new file mode 100644
index 000000000..39bdde982
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_lock.h
@@ -0,0 +1,108 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_lock.h,v 1.4 2001/01/08 01:07:21 martin Exp $ */
+/**************************************************************************
+
+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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#ifndef __R128_LOCK_H__
+#define __R128_LOCK_H__
+
+extern void r128GetLock( r128ContextPtr rmesa, GLuint flags );
+
+/* Turn DEBUG_LOCKING on to find locking conflicts.
+ */
+#define DEBUG_LOCKING 0
+
+#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 and validate our state.
+ */
+#define LOCK_HARDWARE( rmesa ) \
+ do { \
+ char __ret = 0; \
+ DEBUG_CHECK_LOCK(); \
+ DRM_CAS( rmesa->driHwLock, rmesa->hHWContext, \
+ (DRM_LOCK_HELD | rmesa->hHWContext), __ret ); \
+ if ( __ret ) \
+ r128GetLock( rmesa, 0 ); \
+ DEBUG_LOCK(); \
+ } while (0)
+
+/* Unlock the hardware.
+ */
+#define UNLOCK_HARDWARE( rmesa ) \
+ do { \
+ DRM_UNLOCK( rmesa->driFd, \
+ rmesa->driHwLock, \
+ rmesa->hHWContext ); \
+ DEBUG_RESET(); \
+ } while (0)
+
+#endif /* __R128_LOCK_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_screen.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_screen.c
new file mode 100644
index 000000000..17cdd60b1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_screen.c
@@ -0,0 +1,547 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_screen.c,v 1.9 2003/03/26 20:43:49 tsi Exp $ */
+/**************************************************************************
+
+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@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ *
+ */
+
+#include "r128_dri.h"
+
+#include "r128_context.h"
+#include "r128_ioctl.h"
+#include "r128_span.h"
+#include "r128_tris.h"
+
+#include "context.h"
+#include "imports.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+
+#include "utils.h"
+#include "vblank.h"
+
+#include "GL/internal/dri_interface.h"
+
+/* R128 configuration
+ */
+#include "xmlpool.h"
+
+PUBLIC const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_QUALITY
+ DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_NO_RAST(false)
+#if ENABLE_PERF_BOXES
+ DRI_CONF_PERFORMANCE_BOXES(false)
+#endif
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+#if ENABLE_PERF_BOXES
+static const GLuint __driNConfigOptions = 4;
+#else
+static const GLuint __driNConfigOptions = 3;
+#endif
+
+extern const struct dri_extension card_extensions[];
+
+#if 1
+/* Including xf86PciInfo.h introduces a bunch of errors...
+ */
+#define PCI_CHIP_RAGE128LE 0x4C45
+#define PCI_CHIP_RAGE128LF 0x4C46
+#define PCI_CHIP_RAGE128PF 0x5046
+#define PCI_CHIP_RAGE128PR 0x5052
+#define PCI_CHIP_RAGE128RE 0x5245
+#define PCI_CHIP_RAGE128RF 0x5246
+#define PCI_CHIP_RAGE128RK 0x524B
+#define PCI_CHIP_RAGE128RL 0x524C
+#endif
+
+
+/* Create the device specific screen private data struct.
+ */
+static r128ScreenPtr
+r128CreateScreen( __DRIscreenPrivate *sPriv )
+{
+ r128ScreenPtr r128Screen;
+ R128DRIPtr r128DRIPriv = (R128DRIPtr)sPriv->pDevPriv;
+ PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
+ (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
+ void * const psc = sPriv->psc->screenConfigs;
+
+ if (sPriv->devPrivSize != sizeof(R128DRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(R128DRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
+
+ /* Allocate the private area */
+ r128Screen = (r128ScreenPtr) CALLOC( sizeof(*r128Screen) );
+ if ( !r128Screen ) return NULL;
+
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo (&r128Screen->optionCache,
+ __driConfigOptions, __driNConfigOptions);
+
+ /* This is first since which regions we map depends on whether or
+ * not we are using a PCI card.
+ */
+ r128Screen->IsPCI = r128DRIPriv->IsPCI;
+ r128Screen->sarea_priv_offset = r128DRIPriv->sarea_priv_offset;
+
+ if (sPriv->drmMinor >= 3) {
+ drm_r128_getparam_t gp;
+ int ret;
+
+ gp.param = R128_PARAM_IRQ_NR;
+ gp.value = &r128Screen->irq;
+
+ ret = drmCommandWriteRead( sPriv->fd, DRM_R128_GETPARAM,
+ &gp, sizeof(gp));
+ if (ret) {
+ fprintf(stderr, "drmR128GetParam (R128_PARAM_IRQ_NR): %d\n", ret);
+ FREE( r128Screen );
+ return NULL;
+ }
+ }
+
+ r128Screen->mmio.handle = r128DRIPriv->registerHandle;
+ r128Screen->mmio.size = r128DRIPriv->registerSize;
+ if ( drmMap( sPriv->fd,
+ r128Screen->mmio.handle,
+ r128Screen->mmio.size,
+ (drmAddressPtr)&r128Screen->mmio.map ) ) {
+ FREE( r128Screen );
+ return NULL;
+ }
+
+ r128Screen->buffers = drmMapBufs( sPriv->fd );
+ if ( !r128Screen->buffers ) {
+ drmUnmap( (drmAddress)r128Screen->mmio.map, r128Screen->mmio.size );
+ FREE( r128Screen );
+ return NULL;
+ }
+
+ if ( !r128Screen->IsPCI ) {
+ r128Screen->agpTextures.handle = r128DRIPriv->agpTexHandle;
+ r128Screen->agpTextures.size = r128DRIPriv->agpTexMapSize;
+ if ( drmMap( sPriv->fd,
+ r128Screen->agpTextures.handle,
+ r128Screen->agpTextures.size,
+ (drmAddressPtr)&r128Screen->agpTextures.map ) ) {
+ drmUnmapBufs( r128Screen->buffers );
+ drmUnmap( (drmAddress)r128Screen->mmio.map, r128Screen->mmio.size );
+ FREE( r128Screen );
+ return NULL;
+ }
+ }
+
+ switch ( r128DRIPriv->deviceID ) {
+ case PCI_CHIP_RAGE128RE:
+ case PCI_CHIP_RAGE128RF:
+ case PCI_CHIP_RAGE128RK:
+ case PCI_CHIP_RAGE128RL:
+ r128Screen->chipset = R128_CARD_TYPE_R128;
+ break;
+ case PCI_CHIP_RAGE128PF:
+ r128Screen->chipset = R128_CARD_TYPE_R128_PRO;
+ break;
+ case PCI_CHIP_RAGE128LE:
+ case PCI_CHIP_RAGE128LF:
+ r128Screen->chipset = R128_CARD_TYPE_R128_MOBILITY;
+ break;
+ default:
+ r128Screen->chipset = R128_CARD_TYPE_R128;
+ break;
+ }
+
+ r128Screen->cpp = r128DRIPriv->bpp / 8;
+ r128Screen->AGPMode = r128DRIPriv->AGPMode;
+
+ r128Screen->frontOffset = r128DRIPriv->frontOffset;
+ r128Screen->frontPitch = r128DRIPriv->frontPitch;
+ r128Screen->backOffset = r128DRIPriv->backOffset;
+ r128Screen->backPitch = r128DRIPriv->backPitch;
+ r128Screen->depthOffset = r128DRIPriv->depthOffset;
+ r128Screen->depthPitch = r128DRIPriv->depthPitch;
+ r128Screen->spanOffset = r128DRIPriv->spanOffset;
+
+ if ( r128DRIPriv->textureSize == 0 ) {
+ r128Screen->texOffset[R128_LOCAL_TEX_HEAP] =
+ r128DRIPriv->agpTexOffset + R128_AGP_TEX_OFFSET;
+ r128Screen->texSize[R128_LOCAL_TEX_HEAP] = r128DRIPriv->agpTexMapSize;
+ r128Screen->logTexGranularity[R128_LOCAL_TEX_HEAP] =
+ r128DRIPriv->log2AGPTexGran;
+ } else {
+ r128Screen->texOffset[R128_LOCAL_TEX_HEAP] = r128DRIPriv->textureOffset;
+ r128Screen->texSize[R128_LOCAL_TEX_HEAP] = r128DRIPriv->textureSize;
+ r128Screen->logTexGranularity[R128_LOCAL_TEX_HEAP] = r128DRIPriv->log2TexGran;
+ }
+
+ if ( !r128Screen->agpTextures.map || r128DRIPriv->textureSize == 0 ) {
+ r128Screen->numTexHeaps = R128_NR_TEX_HEAPS - 1;
+ r128Screen->texOffset[R128_AGP_TEX_HEAP] = 0;
+ r128Screen->texSize[R128_AGP_TEX_HEAP] = 0;
+ r128Screen->logTexGranularity[R128_AGP_TEX_HEAP] = 0;
+ } else {
+ r128Screen->numTexHeaps = R128_NR_TEX_HEAPS;
+ r128Screen->texOffset[R128_AGP_TEX_HEAP] =
+ r128DRIPriv->agpTexOffset + R128_AGP_TEX_OFFSET;
+ r128Screen->texSize[R128_AGP_TEX_HEAP] = r128DRIPriv->agpTexMapSize;
+ r128Screen->logTexGranularity[R128_AGP_TEX_HEAP] =
+ r128DRIPriv->log2AGPTexGran;
+ }
+
+ r128Screen->driScreen = sPriv;
+
+ if ( glx_enable_extension != NULL ) {
+ if ( r128Screen->irq != 0 ) {
+ (*glx_enable_extension)( psc, "GLX_SGI_swap_control" );
+ (*glx_enable_extension)( psc, "GLX_SGI_video_sync" );
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_control" );
+ }
+
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
+ }
+
+ return r128Screen;
+}
+
+/* Destroy the device specific screen private data struct.
+ */
+static void
+r128DestroyScreen( __DRIscreenPrivate *sPriv )
+{
+ r128ScreenPtr r128Screen = (r128ScreenPtr)sPriv->private;
+
+ if ( !r128Screen )
+ return;
+
+ if ( !r128Screen->IsPCI ) {
+ drmUnmap( (drmAddress)r128Screen->agpTextures.map,
+ r128Screen->agpTextures.size );
+ }
+ drmUnmapBufs( r128Screen->buffers );
+ drmUnmap( (drmAddress)r128Screen->mmio.map, r128Screen->mmio.size );
+
+ /* free all option information */
+ driDestroyOptionInfo (&r128Screen->optionCache);
+
+ FREE( r128Screen );
+ sPriv->private = NULL;
+}
+
+
+/* Create and initialize the Mesa and driver specific pixmap buffer
+ * data.
+ */
+static GLboolean
+r128CreateBuffer( __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ r128ScreenPtr screen = (r128ScreenPtr) driScrnPriv->private;
+
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+#if 0
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer( mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ mesaVis->alphaBits > 0 );
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->frontPitch);
+ r128SetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ r128SetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ r128SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ r128SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+
+static void
+r128DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+
+/* Copy the back color buffer to the front color buffer */
+static void
+r128SwapBuffers(__DRIdrawablePrivate *dPriv)
+{
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ r128ContextPtr rmesa;
+ GLcontext *ctx;
+ rmesa = (r128ContextPtr) dPriv->driContextPriv->driverPrivate;
+ ctx = rmesa->glCtx;
+ if (ctx->Visual.doubleBufferMode) {
+ _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
+ if ( rmesa->doPageFlip ) {
+ r128PageFlip( dPriv );
+ }
+ else {
+ r128CopyBuffer( dPriv );
+ }
+ }
+ }
+ else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__);
+ }
+}
+
+
+/* Initialize the driver specific screen private data.
+ */
+static GLboolean
+r128InitDriver( __DRIscreenPrivate *sPriv )
+{
+ sPriv->private = (void *) r128CreateScreen( sPriv );
+
+ if ( !sPriv->private ) {
+ r128DestroyScreen( sPriv );
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+static struct __DriverAPIRec r128API = {
+ .InitDriver = r128InitDriver,
+ .DestroyScreen = r128DestroyScreen,
+ .CreateContext = r128CreateContext,
+ .DestroyContext = r128DestroyContext,
+ .CreateBuffer = r128CreateBuffer,
+ .DestroyBuffer = r128DestroyBuffer,
+ .SwapBuffers = r128SwapBuffers,
+ .MakeCurrent = r128MakeCurrent,
+ .UnbindContext = r128UnbindContext,
+ .GetSwapInfo = NULL,
+ .GetMSC = driGetMSC32,
+ .WaitForMSC = driWaitForMSC32,
+ .WaitForSBC = NULL,
+ .SwapBuffersMSC = NULL
+
+};
+
+
+static __GLcontextModes *
+r128FillInModes( unsigned pixel_bits, unsigned depth_bits,
+ unsigned stencil_bits, GLboolean have_back_buffer )
+{
+ __GLcontextModes * modes;
+ __GLcontextModes * m;
+ unsigned num_modes;
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ GLenum fb_format;
+ GLenum fb_type;
+
+ /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
+ * enough to add support. Basically, if a context is created with an
+ * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
+ * will never be used.
+ */
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
+ };
+
+ u_int8_t depth_bits_array[2];
+ u_int8_t stencil_bits_array[2];
+
+
+ depth_bits_array[0] = depth_bits;
+ depth_bits_array[1] = depth_bits;
+
+ /* Just like with the accumulation buffer, always provide some modes
+ * with a stencil buffer. It will be a sw fallback, but some apps won't
+ * care about that.
+ */
+ stencil_bits_array[0] = 0;
+ stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
+
+ depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1;
+ back_buffer_factor = (have_back_buffer) ? 2 : 1;
+
+ num_modes = depth_buffer_factor * back_buffer_factor * 4;
+
+ if ( pixel_bits == 16 ) {
+ fb_format = GL_RGB;
+ fb_type = GL_UNSIGNED_SHORT_5_6_5;
+ }
+ else {
+ fb_format = GL_BGR;
+ fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ }
+
+ modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
+ m = modes;
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_TRUE_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_DIRECT_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+
+ /* Mark the visual as slow if there are "fake" stencil bits.
+ */
+ for ( m = modes ; m != NULL ; m = m->next ) {
+ if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) {
+ m->visualRating = GLX_SLOW_CONFIG;
+ }
+ }
+
+ return modes;
+}
+
+
+/**
+ * This is the bootstrap function for the driver. libGL supplies all of the
+ * requisite information about the system, and the driver initializes itself.
+ * This routine also fills in the linked list pointed to by \c driver_modes
+ * with the \c __GLcontextModes that the driver can support for windows or
+ * pbuffers.
+ *
+ * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
+ * failure.
+ */
+PUBLIC
+void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
+ const __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drmAddress pSAREA, int fd,
+ int internal_api_version,
+ const __DRIinterfaceMethods * interface,
+ __GLcontextModes ** driver_modes )
+
+{
+ __DRIscreenPrivate *psp;
+ static const __DRIversion ddx_expected = { 4, 0, 0 };
+ static const __DRIversion dri_expected = { 4, 0, 0 };
+ static const __DRIversion drm_expected = { 2, 2, 0 };
+
+
+ dri_interface = interface;
+
+ if ( ! driCheckDriDdxDrmVersions2( "Rage128",
+ dri_version, & dri_expected,
+ ddx_version, & ddx_expected,
+ drm_version, & drm_expected ) ) {
+ return NULL;
+ }
+
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &r128API);
+ if ( psp != NULL ) {
+ R128DRIPtr dri_priv = (R128DRIPtr) psp->pDevPriv;
+ *driver_modes = r128FillInModes( dri_priv->bpp,
+ (dri_priv->bpp == 16) ? 16 : 24,
+ (dri_priv->bpp == 16) ? 0 : 8,
+ (dri_priv->backOffset != dri_priv->depthOffset) );
+
+ /* Calling driInitExtensions here, with a NULL context pointer, does not actually
+ * enable the extensions. It just makes sure that all the dispatch offsets for all
+ * the extensions that *might* be enables are known. This is needed because the
+ * dispatch offsets need to be known when _mesa_context_create is called, but we can't
+ * enable the extensions until we have a context pointer.
+ *
+ * Hello chicken. Hello egg. How are you two today?
+ */
+ driInitExtensions( NULL, card_extensions, GL_FALSE );
+ }
+
+ return (void *) psp;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_screen.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_screen.h
new file mode 100644
index 000000000..8db8eea35
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_screen.h
@@ -0,0 +1,84 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_screen.h,v 1.7 2002/12/16 16:18:53 dawes Exp $ */
+/**************************************************************************
+
+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@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ *
+ */
+
+#ifndef __R128_SCREEN_H__
+#define __R128_SCREEN_H__
+
+#include "xmlconfig.h"
+
+typedef struct {
+ drm_handle_t handle; /* Handle to the DRM region */
+ drmSize size; /* Size of the DRM region */
+ unsigned char *map; /* Mapping of the DRM region */
+} r128RegionRec, *r128RegionPtr;
+
+typedef struct {
+
+ GLint chipset;
+ GLint cpp;
+ GLint IsPCI; /* Current card is a PCI card */
+ GLint AGPMode;
+ unsigned int irq; /* IRQ number (0 means none) */
+
+ GLuint frontOffset;
+ GLuint frontPitch;
+ GLuint backOffset;
+ GLuint backPitch;
+
+ GLuint depthOffset;
+ GLuint depthPitch;
+ GLuint spanOffset;
+
+ /* Shared texture data */
+ GLint numTexHeaps;
+ GLint texOffset[R128_NR_TEX_HEAPS];
+ GLint texSize[R128_NR_TEX_HEAPS];
+ GLint logTexGranularity[R128_NR_TEX_HEAPS];
+
+ r128RegionRec mmio;
+ r128RegionRec agpTextures;
+
+ drmBufMapPtr buffers;
+
+ __DRIscreenPrivate *driScreen;
+ unsigned int sarea_priv_offset;
+
+ /* Configuration cache with default values for all contexts */
+ driOptionCache optionCache;
+
+} r128ScreenRec, *r128ScreenPtr;
+
+
+#endif /* __R128_SCREEN_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_span.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_span.c
new file mode 100644
index 000000000..fd4722b3b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_span.c
@@ -0,0 +1,368 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_span.c,v 1.8 2002/10/30 12:51:39 alanh Exp $ */
+/**************************************************************************
+
+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@valinux.com>
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Kevin E. Martin <martin@valinux.com>
+ *
+ */
+
+#include "r128_context.h"
+#include "r128_ioctl.h"
+#include "r128_state.h"
+#include "r128_span.h"
+#include "r128_tex.h"
+
+#include "swrast/swrast.h"
+
+#define DBG 0
+
+#define HAVE_HW_DEPTH_SPANS 1
+#define HAVE_HW_DEPTH_PIXELS 1
+
+#define LOCAL_VARS \
+ r128ContextPtr rmesa = R128_CONTEXT(ctx); \
+ r128ScreenPtr r128scrn = rmesa->r128Screen; \
+ __DRIscreenPrivate *sPriv = rmesa->driScreen; \
+ __DRIdrawablePrivate *dPriv = rmesa->driDrawable; \
+ GLuint pitch = r128scrn->frontPitch * r128scrn->cpp; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(sPriv->pFB + \
+ rmesa->drawOffset + \
+ (dPriv->x * r128scrn->cpp) + \
+ (dPriv->y * pitch)); \
+ char *read_buf = (char *)(sPriv->pFB + \
+ rmesa->readOffset + \
+ (dPriv->x * r128scrn->cpp) + \
+ (dPriv->y * pitch)); \
+ GLuint p; \
+ (void) read_buf; (void) buf; (void) p
+
+#define LOCAL_DEPTH_VARS \
+ r128ContextPtr rmesa = R128_CONTEXT(ctx); \
+ r128ScreenPtr r128scrn = rmesa->r128Screen; \
+ __DRIscreenPrivate *sPriv = rmesa->driScreen; \
+ __DRIdrawablePrivate *dPriv = rmesa->driDrawable; \
+ GLuint height = dPriv->h; \
+ (void) r128scrn; (void) sPriv; (void) height
+
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
+
+#define Y_FLIP( _y ) (height - _y - 1)
+
+#define HW_LOCK()
+
+#define HW_UNLOCK()
+
+
+
+/* ================================================================
+ * Color buffer
+ */
+
+/* 16 bit, RGB565 color spanline and pixel functions
+ */
+#define SPANTMP_PIXEL_FMT GL_RGB
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
+
+#define TAG(x) r128##x##_RGB565
+#define TAG2(x,y) r128##x##_RGB565##y
+#include "spantmp2.h"
+
+
+/* 32 bit, ARGB8888 color spanline and pixel functions
+ */
+#define SPANTMP_PIXEL_FMT GL_BGRA
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
+
+#define TAG(x) r128##x##_ARGB8888
+#define TAG2(x,y) r128##x##_ARGB8888##y
+#include "spantmp2.h"
+
+
+/* ================================================================
+ * Depth buffer
+ */
+
+/* 16-bit depth buffer functions
+ */
+
+#define WRITE_DEPTH_SPAN() \
+ r128WriteDepthSpanLocked( rmesa, n, \
+ x + dPriv->x, \
+ y + dPriv->y, \
+ depth, mask );
+
+#define WRITE_DEPTH_PIXELS() \
+do { \
+ GLint ox[MAX_WIDTH]; \
+ GLint oy[MAX_WIDTH]; \
+ for ( i = 0 ; i < n ; i++ ) { \
+ ox[i] = x[i] + dPriv->x; \
+ oy[i] = Y_FLIP( y[i] ) + dPriv->y; \
+ } \
+ r128WriteDepthPixelsLocked( rmesa, n, ox, oy, depth, mask ); \
+} while (0)
+
+#define READ_DEPTH_SPAN() \
+do { \
+ GLushort *buf = (GLushort *)((GLubyte *)sPriv->pFB + \
+ r128scrn->spanOffset); \
+ GLint i; \
+ \
+ r128ReadDepthSpanLocked( rmesa, n, \
+ x + dPriv->x, \
+ y + dPriv->y ); \
+ r128WaitForIdleLocked( rmesa ); \
+ \
+ for ( i = 0 ; i < n ; i++ ) { \
+ depth[i] = buf[i]; \
+ } \
+} while (0)
+
+#define READ_DEPTH_PIXELS() \
+do { \
+ GLushort *buf = (GLushort *)((GLubyte *)sPriv->pFB + \
+ r128scrn->spanOffset); \
+ GLint i, remaining = n; \
+ \
+ while ( remaining > 0 ) { \
+ GLint ox[128]; \
+ GLint oy[128]; \
+ GLint count; \
+ \
+ if ( remaining <= 128 ) { \
+ count = remaining; \
+ } else { \
+ count = 128; \
+ } \
+ for ( i = 0 ; i < count ; i++ ) { \
+ ox[i] = x[i] + dPriv->x; \
+ oy[i] = Y_FLIP( y[i] ) + dPriv->y; \
+ } \
+ \
+ r128ReadDepthPixelsLocked( rmesa, count, ox, oy ); \
+ r128WaitForIdleLocked( rmesa ); \
+ \
+ for ( i = 0 ; i < count ; i++ ) { \
+ depth[i] = buf[i]; \
+ } \
+ depth += count; \
+ x += count; \
+ y += count; \
+ remaining -= count; \
+ } \
+} while (0)
+
+#define TAG(x) r128##x##_16
+#include "depthtmp.h"
+
+
+/* 24-bit depth, 8-bit stencil buffer functions
+ */
+#define WRITE_DEPTH_SPAN() \
+ r128WriteDepthSpanLocked( rmesa, n, \
+ x + dPriv->x, \
+ y + dPriv->y, \
+ depth, mask );
+
+#define WRITE_DEPTH_PIXELS() \
+do { \
+ GLint ox[MAX_WIDTH]; \
+ GLint oy[MAX_WIDTH]; \
+ for ( i = 0 ; i < n ; i++ ) { \
+ ox[i] = x[i] + dPriv->x; \
+ oy[i] = Y_FLIP( y[i] ) + dPriv->y; \
+ } \
+ r128WriteDepthPixelsLocked( rmesa, n, ox, oy, depth, mask ); \
+} while (0)
+
+#define READ_DEPTH_SPAN() \
+do { \
+ GLuint *buf = (GLuint *)((GLubyte *)sPriv->pFB + \
+ r128scrn->spanOffset); \
+ GLint i; \
+ \
+ r128ReadDepthSpanLocked( rmesa, n, \
+ x + dPriv->x, \
+ y + dPriv->y ); \
+ r128WaitForIdleLocked( rmesa ); \
+ \
+ for ( i = 0 ; i < n ; i++ ) { \
+ depth[i] = buf[i] & 0x00ffffff; \
+ } \
+} while (0)
+
+#define READ_DEPTH_PIXELS() \
+do { \
+ GLuint *buf = (GLuint *)((GLubyte *)sPriv->pFB + \
+ r128scrn->spanOffset); \
+ GLint i, remaining = n; \
+ \
+ while ( remaining > 0 ) { \
+ GLint ox[128]; \
+ GLint oy[128]; \
+ GLint count; \
+ \
+ if ( remaining <= 128 ) { \
+ count = remaining; \
+ } else { \
+ count = 128; \
+ } \
+ for ( i = 0 ; i < count ; i++ ) { \
+ ox[i] = x[i] + dPriv->x; \
+ oy[i] = Y_FLIP( y[i] ) + dPriv->y; \
+ } \
+ \
+ r128ReadDepthPixelsLocked( rmesa, count, ox, oy ); \
+ r128WaitForIdleLocked( rmesa ); \
+ \
+ for ( i = 0 ; i < count ; i++ ) { \
+ depth[i] = buf[i] & 0x00ffffff; \
+ } \
+ depth += count; \
+ x += count; \
+ y += count; \
+ remaining -= count; \
+ } \
+} while (0)
+
+#define TAG(x) r128##x##_24_8
+#include "depthtmp.h"
+
+
+
+/* ================================================================
+ * Stencil buffer
+ */
+
+/* FIXME: Add support for hardware stencil buffers.
+ */
+
+/*
+ * This function is called to specify which buffer to read and write
+ * for software rasterization (swrast) fallbacks. This doesn't necessarily
+ * correspond to glDrawBuffer() or glReadBuffer() calls.
+ */
+static void r128DDSetBuffer( GLcontext *ctx,
+ GLframebuffer *colorBuffer,
+ GLuint bufferBit )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ switch ( bufferBit ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ if ( rmesa->sarea->pfCurrentPage == 1 ) {
+ rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->backOffset;
+ rmesa->drawPitch = rmesa->readPitch = rmesa->r128Screen->backPitch;
+ } else {
+ rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->frontOffset;
+ rmesa->drawPitch = rmesa->readPitch = rmesa->r128Screen->frontPitch;
+ }
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ if ( rmesa->sarea->pfCurrentPage == 1 ) {
+ rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->frontOffset;
+ rmesa->drawPitch = rmesa->readPitch = rmesa->r128Screen->frontPitch;
+ } else {
+ rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->backOffset;
+ rmesa->drawPitch = rmesa->readPitch = rmesa->r128Screen->backPitch;
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void r128SpanRenderStart( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ FLUSH_BATCH(rmesa);
+ LOCK_HARDWARE(rmesa);
+ r128WaitForIdleLocked( rmesa );
+}
+
+void r128SpanRenderFinish( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ _swrast_flush( ctx );
+ UNLOCK_HARDWARE( rmesa );
+}
+
+void r128DDInitSpanFuncs( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetBuffer = r128DDSetBuffer;
+ swdd->SpanRenderStart = r128SpanRenderStart;
+ swdd->SpanRenderFinish = r128SpanRenderFinish;
+}
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+r128SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ r128InitPointers_RGB565(&drb->Base);
+ }
+ else {
+ r128InitPointers_ARGB8888(&drb->Base);
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = r128ReadDepthSpan_16;
+ drb->Base.GetValues = r128ReadDepthPixels_16;
+ drb->Base.PutRow = r128WriteDepthSpan_16;
+ drb->Base.PutMonoRow = r128WriteMonoDepthSpan_16;
+ drb->Base.PutValues = r128WriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = r128ReadDepthSpan_24_8;
+ drb->Base.GetValues = r128ReadDepthPixels_24_8;
+ drb->Base.PutRow = r128WriteDepthSpan_24_8;
+ drb->Base.PutMonoRow = r128WriteMonoDepthSpan_24_8;
+ drb->Base.PutValues = r128WriteDepthPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = NULL;
+ drb->Base.GetValues = NULL;
+ drb->Base.PutRow = NULL;
+ drb->Base.PutMonoRow = NULL;
+ drb->Base.PutValues = NULL;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_span.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_span.h
new file mode 100644
index 000000000..fd7c2d139
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_span.h
@@ -0,0 +1,46 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_span.h,v 1.3 2001/01/08 01:07:21 martin Exp $ */
+/**************************************************************************
+
+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@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ *
+ */
+
+#ifndef __R128_SPAN_H__
+#define __R128_SPAN_H__
+
+#include "drirenderbuffer.h"
+
+extern void r128DDInitSpanFuncs( GLcontext *ctx );
+
+extern void
+r128SetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_state.c
new file mode 100644
index 000000000..29f490da8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_state.c
@@ -0,0 +1,1261 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_state.c,v 1.11 2002/10/30 12:51:39 alanh Exp $ */
+/**************************************************************************
+
+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@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ * Keith Whitwell <keith@tungstengraphics.com>
+ *
+ */
+
+#include "r128_context.h"
+#include "r128_state.h"
+#include "r128_ioctl.h"
+#include "r128_tris.h"
+#include "r128_tex.h"
+
+#include "context.h"
+#include "buffers.h"
+#include "enums.h"
+#include "colormac.h"
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "tnl/t_pipeline.h"
+
+
+/* =============================================================
+ * Alpha blending
+ */
+
+
+/**
+ * Calculate the hardware blend factor setting. This same function is used
+ * for source and destination of both alpha and RGB.
+ *
+ * \returns
+ * The hardware register value for the specified blend factor. This value
+ * will need to be shifted into the correct position for either source or
+ * destination factor.
+ *
+ * \todo
+ * Since the two cases where source and destination are handled differently
+ * are essentially error cases, they should never happen. Determine if these
+ * cases can be removed.
+ */
+static int blend_factor( r128ContextPtr rmesa, GLenum factor, GLboolean is_src )
+{
+ int func;
+
+ switch ( factor ) {
+ case GL_ZERO:
+ func = R128_ALPHA_BLEND_ZERO;
+ break;
+ case GL_ONE:
+ func = R128_ALPHA_BLEND_ONE;
+ break;
+
+ case GL_SRC_COLOR:
+ func = R128_ALPHA_BLEND_SRCCOLOR;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ func = R128_ALPHA_BLEND_INVSRCCOLOR;
+ break;
+ case GL_SRC_ALPHA:
+ func = R128_ALPHA_BLEND_SRCALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ func = R128_ALPHA_BLEND_INVSRCALPHA;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ func = (is_src) ? R128_ALPHA_BLEND_SAT : R128_ALPHA_BLEND_ZERO;
+ break;
+
+ case GL_DST_COLOR:
+ func = R128_ALPHA_BLEND_DSTCOLOR;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ func = R128_ALPHA_BLEND_INVDSTCOLOR;
+ break;
+ case GL_DST_ALPHA:
+ func = R128_ALPHA_BLEND_DSTALPHA;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ func = R128_ALPHA_BLEND_INVDSTALPHA;
+ break;
+
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ default:
+ FALLBACK( rmesa, R128_FALLBACK_BLEND_FUNC, GL_TRUE );
+ func = (is_src) ? R128_ALPHA_BLEND_ONE : R128_ALPHA_BLEND_ZERO;
+ break;
+ }
+
+ return func;
+}
+
+
+static void r128UpdateAlphaMode( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLuint a = rmesa->setup.misc_3d_state_cntl_reg;
+ GLuint t = rmesa->setup.tex_cntl_c;
+
+ if ( ctx->Color.AlphaEnabled ) {
+ GLubyte ref;
+
+ CLAMPED_FLOAT_TO_UBYTE(ref, ctx->Color.AlphaRef);
+
+ a &= ~(R128_ALPHA_TEST_MASK | R128_REF_ALPHA_MASK);
+
+ switch ( ctx->Color.AlphaFunc ) {
+ 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;
+ }
+
+ a |= ref & R128_REF_ALPHA_MASK;
+ t |= R128_ALPHA_TEST_ENABLE;
+ } else {
+ t &= ~R128_ALPHA_TEST_ENABLE;
+ }
+
+ FALLBACK( rmesa, R128_FALLBACK_BLEND_FUNC, GL_FALSE );
+
+ if ( ctx->Color.BlendEnabled ) {
+ a &= ~((R128_ALPHA_BLEND_MASK << R128_ALPHA_BLEND_SRC_SHIFT) |
+ (R128_ALPHA_BLEND_MASK << R128_ALPHA_BLEND_DST_SHIFT)
+ | R128_ALPHA_COMB_FCN_MASK);
+
+ a |= blend_factor( rmesa, ctx->Color.BlendSrcRGB, GL_TRUE )
+ << R128_ALPHA_BLEND_SRC_SHIFT;
+ a |= blend_factor( rmesa, ctx->Color.BlendDstRGB, GL_FALSE )
+ << R128_ALPHA_BLEND_DST_SHIFT;
+
+ switch (ctx->Color.BlendEquationRGB) {
+ case GL_FUNC_ADD:
+ a |= R128_ALPHA_COMB_ADD_CLAMP;
+ break;
+ case GL_FUNC_SUBTRACT:
+ a |= R128_ALPHA_COMB_SUB_SRC_DST_CLAMP;
+ break;
+ default:
+ FALLBACK( rmesa, R128_FALLBACK_BLEND_EQ, GL_TRUE );
+ }
+
+ t |= R128_ALPHA_ENABLE;
+ } else {
+ t &= ~R128_ALPHA_ENABLE;
+ }
+
+ if ( rmesa->setup.misc_3d_state_cntl_reg != a ) {
+ rmesa->setup.misc_3d_state_cntl_reg = a;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS;
+ }
+ if ( rmesa->setup.tex_cntl_c != t ) {
+ rmesa->setup.tex_cntl_c = t;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS;
+ }
+}
+
+static void r128DDAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ FLUSH_BATCH( rmesa );
+ rmesa->new_state |= R128_NEW_ALPHA;
+}
+
+static void r128DDBlendEquationSeparate( GLcontext *ctx,
+ GLenum modeRGB, GLenum modeA )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ assert( modeRGB == modeA );
+ FLUSH_BATCH( rmesa );
+
+ /* BlendEquation sets ColorLogicOpEnabled in an unexpected
+ * manner.
+ */
+ FALLBACK( R128_CONTEXT(ctx), R128_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
+
+ /* Can only do blend addition, not min, max, subtract, etc. */
+ FALLBACK( R128_CONTEXT(ctx), R128_FALLBACK_BLEND_EQ,
+ (modeRGB != GL_FUNC_ADD) && (modeRGB != GL_FUNC_SUBTRACT));
+
+ rmesa->new_state |= R128_NEW_ALPHA;
+}
+
+static void r128DDBlendFuncSeparate( GLcontext *ctx,
+ GLenum sfactorRGB, GLenum dfactorRGB,
+ GLenum sfactorA, GLenum dfactorA )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ FLUSH_BATCH( rmesa );
+ rmesa->new_state |= R128_NEW_ALPHA;
+}
+
+
+/* =============================================================
+ * Depth testing
+ */
+
+static void r128UpdateZMode( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLuint z = rmesa->setup.z_sten_cntl_c;
+ GLuint t = rmesa->setup.tex_cntl_c;
+
+ if ( ctx->Depth.Test ) {
+ z &= ~R128_Z_TEST_MASK;
+
+ switch ( ctx->Depth.Func ) {
+ case GL_NEVER:
+ z |= R128_Z_TEST_NEVER;
+ break;
+ case GL_ALWAYS:
+ z |= R128_Z_TEST_ALWAYS;
+ 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;
+ }
+
+ t |= R128_Z_ENABLE;
+ } else {
+ t &= ~R128_Z_ENABLE;
+ }
+
+ if ( ctx->Depth.Mask ) {
+ t |= R128_Z_WRITE_ENABLE;
+ } else {
+ t &= ~R128_Z_WRITE_ENABLE;
+ }
+
+ if ( rmesa->setup.z_sten_cntl_c != z ) {
+ rmesa->setup.z_sten_cntl_c = z;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+ }
+ if ( rmesa->setup.tex_cntl_c != t ) {
+ rmesa->setup.tex_cntl_c = t;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+ }
+}
+
+static void r128DDDepthFunc( GLcontext *ctx, GLenum func )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ FLUSH_BATCH( rmesa );
+ rmesa->new_state |= R128_NEW_DEPTH;
+}
+
+static void r128DDDepthMask( GLcontext *ctx, GLboolean flag )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ FLUSH_BATCH( rmesa );
+ rmesa->new_state |= R128_NEW_DEPTH;
+}
+
+static void r128DDClearDepth( GLcontext *ctx, GLclampd d )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ switch ( rmesa->setup.z_sten_cntl_c & R128_Z_PIX_WIDTH_MASK ) {
+ case R128_Z_PIX_WIDTH_16:
+ rmesa->ClearDepth = d * 0x0000ffff;
+ break;
+ case R128_Z_PIX_WIDTH_24:
+ rmesa->ClearDepth = d * 0x00ffffff;
+ break;
+ case R128_Z_PIX_WIDTH_32:
+ rmesa->ClearDepth = d * 0xffffffff;
+ break;
+ }
+}
+
+
+/* =============================================================
+ * Fog
+ */
+
+static void r128UpdateFogAttrib( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLuint t = rmesa->setup.tex_cntl_c;
+ GLubyte c[4];
+ GLuint col;
+
+ if ( ctx->Fog.Enabled ) {
+ t |= R128_FOG_ENABLE;
+ } else {
+ t &= ~R128_FOG_ENABLE;
+ }
+
+ c[0] = FLOAT_TO_UBYTE( ctx->Fog.Color[0] );
+ c[1] = FLOAT_TO_UBYTE( ctx->Fog.Color[1] );
+ c[2] = FLOAT_TO_UBYTE( ctx->Fog.Color[2] );
+
+ col = r128PackColor( 4, c[0], c[1], c[2], 0 );
+
+ if ( rmesa->setup.fog_color_c != col ) {
+ rmesa->setup.fog_color_c = col;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+ }
+ if ( rmesa->setup.tex_cntl_c != t ) {
+ rmesa->setup.tex_cntl_c = t;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+ }
+}
+
+static void r128DDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ FLUSH_BATCH( rmesa );
+ rmesa->new_state |= R128_NEW_FOG;
+}
+
+
+/* =============================================================
+ * Clipping
+ */
+
+static void r128UpdateClipping( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ if ( rmesa->driDrawable ) {
+ __DRIdrawablePrivate *drawable = rmesa->driDrawable;
+ int x1 = 0;
+ int y1 = 0;
+ int x2 = drawable->w - 1;
+ int y2 = drawable->h - 1;
+
+ if ( ctx->Scissor.Enabled ) {
+ if ( ctx->Scissor.X > x1 ) {
+ x1 = ctx->Scissor.X;
+ }
+ if ( drawable->h - ctx->Scissor.Y - ctx->Scissor.Height > y1 ) {
+ y1 = drawable->h - ctx->Scissor.Y - ctx->Scissor.Height;
+ }
+ if ( ctx->Scissor.X + ctx->Scissor.Width - 1 < x2 ) {
+ x2 = ctx->Scissor.X + ctx->Scissor.Width - 1;
+ }
+ if ( drawable->h - ctx->Scissor.Y - 1 < y2 ) {
+ y2 = drawable->h - ctx->Scissor.Y - 1;
+ }
+ }
+
+ x1 += drawable->x;
+ y1 += drawable->y;
+ x2 += drawable->x;
+ y2 += drawable->y;
+
+ rmesa->setup.sc_top_left_c = ((y1 << 16) | x1);
+ rmesa->setup.sc_bottom_right_c = ((y2 << 16) | x2);
+
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+ }
+}
+
+static void r128DDScissor( GLcontext *ctx,
+ GLint x, GLint y, GLsizei w, GLsizei h )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ FLUSH_BATCH( rmesa );
+ rmesa->new_state |= R128_NEW_CLIP;
+}
+
+
+/* =============================================================
+ * Culling
+ */
+
+static void r128UpdateCull( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLuint f = rmesa->setup.pm4_vc_fpu_setup;
+
+ f &= ~R128_FRONT_DIR_MASK;
+
+ switch ( ctx->Polygon.FrontFace ) {
+ case GL_CW:
+ f |= R128_FRONT_DIR_CW;
+ break;
+ case GL_CCW:
+ f |= R128_FRONT_DIR_CCW;
+ break;
+ }
+
+ f |= R128_BACKFACE_SOLID | R128_FRONTFACE_SOLID;
+
+ if ( 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;
+ }
+ }
+
+ if ( 1 || rmesa->setup.pm4_vc_fpu_setup != f ) {
+ rmesa->setup.pm4_vc_fpu_setup = f;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_SETUP;
+ }
+}
+
+static void r128DDCullFace( GLcontext *ctx, GLenum mode )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ FLUSH_BATCH( rmesa );
+ rmesa->new_state |= R128_NEW_CULL;
+}
+
+static void r128DDFrontFace( GLcontext *ctx, GLenum mode )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ FLUSH_BATCH( rmesa );
+ rmesa->new_state |= R128_NEW_CULL;
+}
+
+
+/* =============================================================
+ * Masks
+ */
+
+static void r128UpdateMasks( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ GLuint mask = r128PackColor( rmesa->r128Screen->cpp,
+ ctx->Color.ColorMask[RCOMP],
+ ctx->Color.ColorMask[GCOMP],
+ ctx->Color.ColorMask[BCOMP],
+ ctx->Color.ColorMask[ACOMP] );
+
+ if ( rmesa->setup.plane_3d_mask_c != mask ) {
+ rmesa->setup.plane_3d_mask_c = mask;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS;
+ }
+}
+
+static void r128DDColorMask( GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ FLUSH_BATCH( rmesa );
+ rmesa->new_state |= R128_NEW_MASKS;
+}
+
+
+/* =============================================================
+ * Rendering attributes
+ *
+ * We really don't want to recalculate all this every time we bind a
+ * texture. These things shouldn't change all that often, so it makes
+ * sense to break them out of the core texture state update routines.
+ */
+
+static void updateSpecularLighting( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLuint t = rmesa->setup.tex_cntl_c;
+
+ if ( ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR &&
+ ctx->Light.Enabled) {
+ /* XXX separate specular color just doesn't seem to work as it should.
+ * For now, we fall back to s/w rendering whenever separate specular
+ * is enabled.
+ */
+#if 0
+ if (ctx->Light.ShadeModel == GL_FLAT) {
+ /* R128 can't do flat-shaded separate specular */
+ t &= ~R128_SPEC_LIGHT_ENABLE;
+ FALLBACK( rmesa, R128_FALLBACK_SEP_SPECULAR, GL_TRUE );
+ /*printf("%s fallback sep spec\n", __FUNCTION__);*/
+ }
+ else {
+ t |= R128_SPEC_LIGHT_ENABLE;
+ FALLBACK( rmesa, R128_FALLBACK_SEP_SPECULAR, GL_FALSE );
+ /*printf("%s enable sep spec\n", __FUNCTION__);*/
+ }
+#else
+ t &= ~R128_SPEC_LIGHT_ENABLE;
+ FALLBACK( rmesa, R128_FALLBACK_SEP_SPECULAR, GL_TRUE );
+ /*printf("%s fallback sep spec\n", __FUNCTION__);*/
+#endif
+ }
+ else {
+ t &= ~R128_SPEC_LIGHT_ENABLE;
+ FALLBACK( rmesa, R128_FALLBACK_SEP_SPECULAR, GL_FALSE );
+ /*printf("%s disable sep spec\n", __FUNCTION__);*/
+ }
+
+ if ( rmesa->setup.tex_cntl_c != t ) {
+ rmesa->setup.tex_cntl_c = t;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+ rmesa->dirty |= R128_UPLOAD_SETUP;
+ rmesa->new_state |= R128_NEW_CONTEXT;
+ }
+}
+
+
+static void r128DDLightModelfv( GLcontext *ctx, GLenum pname,
+ const GLfloat *param )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ if ( pname == GL_LIGHT_MODEL_COLOR_CONTROL ) {
+ FLUSH_BATCH( rmesa );
+ updateSpecularLighting(ctx);
+ }
+}
+
+static void r128DDShadeModel( GLcontext *ctx, GLenum mode )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLuint s = rmesa->setup.pm4_vc_fpu_setup;
+
+ s &= ~R128_FPU_COLOR_MASK;
+
+ switch ( mode ) {
+ case GL_FLAT:
+ s |= R128_FPU_COLOR_FLAT;
+ break;
+ case GL_SMOOTH:
+ s |= R128_FPU_COLOR_GOURAUD;
+ break;
+ default:
+ return;
+ }
+
+ updateSpecularLighting(ctx);
+
+ if ( rmesa->setup.pm4_vc_fpu_setup != s ) {
+ FLUSH_BATCH( rmesa );
+ rmesa->setup.pm4_vc_fpu_setup = s;
+
+ rmesa->new_state |= R128_NEW_CONTEXT;
+ rmesa->dirty |= R128_UPLOAD_SETUP;
+ }
+}
+
+
+/* =============================================================
+ * Window position
+ */
+
+void r128UpdateWindow( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ int x = rmesa->driDrawable->x;
+ int y = rmesa->driDrawable->y;
+
+ rmesa->setup.window_xy_offset = ((y << R128_WINDOW_Y_SHIFT) |
+ (x << R128_WINDOW_X_SHIFT));
+
+ rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_WINDOW;
+}
+
+/* =============================================================
+ * Viewport
+ */
+
+
+static void r128CalcViewport( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat *m = rmesa->hw_viewport;
+
+ /* See also r128_translate_vertex.
+ */
+ m[MAT_SX] = v[MAT_SX];
+ m[MAT_TX] = v[MAT_TX] + SUBPIXEL_X;
+ m[MAT_SY] = - v[MAT_SY];
+ m[MAT_TY] = - v[MAT_TY] + rmesa->driDrawable->h + SUBPIXEL_Y;
+ m[MAT_SZ] = v[MAT_SZ] * rmesa->depth_scale;
+ m[MAT_TZ] = v[MAT_TZ] * rmesa->depth_scale;
+}
+
+static void r128Viewport( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
+ r128CalcViewport( ctx );
+}
+
+static void r128DepthRange( GLcontext *ctx,
+ GLclampd nearval, GLclampd farval )
+{
+ r128CalcViewport( ctx );
+}
+
+
+/* =============================================================
+ * Miscellaneous
+ */
+
+static void r128DDClearColor( GLcontext *ctx,
+ const GLfloat color[4] )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLubyte c[4];
+
+ CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
+
+ rmesa->ClearColor = r128PackColor( rmesa->r128Screen->cpp,
+ c[0], c[1], c[2], c[3] );
+}
+
+static void r128DDLogicOpCode( GLcontext *ctx, GLenum opcode )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ if ( ctx->Color.ColorLogicOpEnabled ) {
+ FLUSH_BATCH( rmesa );
+
+ FALLBACK( rmesa, R128_FALLBACK_LOGICOP, opcode != GL_COPY );
+ }
+}
+
+static void r128DDDrawBuffer( GLcontext *ctx, GLenum mode )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ FLUSH_BATCH( rmesa );
+
+ /*
+ * _ColorDrawBufferMask is easier to cope with than <mode>.
+ */
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ break;
+ default:
+ /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
+ FALLBACK( rmesa, R128_FALLBACK_DRAW_BUFFER, GL_TRUE );
+ break;
+ }
+
+ /* We want to update the s/w rast state too so that r128DDSetBuffer()
+ * gets called.
+ */
+ _swrast_DrawBuffer(ctx, mode);
+
+ rmesa->setup.dst_pitch_offset_c = (((rmesa->drawPitch/8) << 21) |
+ (rmesa->drawOffset >> 5));
+ rmesa->new_state |= R128_NEW_WINDOW;
+}
+
+static void r128DDReadBuffer( GLcontext *ctx, GLenum mode )
+{
+ /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
+}
+
+
+/* =============================================================
+ * Polygon stipple
+ */
+
+static void r128DDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLuint stipple[32], i;
+ drm_r128_stipple_t stippleRec;
+
+ for (i = 0; i < 32; i++) {
+ stipple[31 - i] = ((mask[i*4+0] << 24) |
+ (mask[i*4+1] << 16) |
+ (mask[i*4+2] << 8) |
+ (mask[i*4+3]));
+ }
+
+ FLUSH_BATCH( rmesa );
+ LOCK_HARDWARE( rmesa );
+
+ stippleRec.mask = stipple;
+ drmCommandWrite( rmesa->driFd, DRM_R128_STIPPLE,
+ &stippleRec, sizeof(stippleRec) );
+
+ UNLOCK_HARDWARE( rmesa );
+
+ rmesa->new_state |= R128_NEW_CONTEXT;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+}
+
+
+/* =============================================================
+ * Render mode
+ */
+
+static void r128DDRenderMode( GLcontext *ctx, GLenum mode )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ FALLBACK( rmesa, R128_FALLBACK_RENDER_MODE, (mode != GL_RENDER) );
+}
+
+
+
+/* =============================================================
+ * State enable/disable
+ */
+
+static void r128DDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %s = %s )\n",
+ __FUNCTION__, _mesa_lookup_enum_by_nr( cap ),
+ state ? "GL_TRUE" : "GL_FALSE" );
+ }
+
+ switch ( cap ) {
+ case GL_ALPHA_TEST:
+ FLUSH_BATCH( rmesa );
+ rmesa->new_state |= R128_NEW_ALPHA;
+ break;
+
+ case GL_BLEND:
+ FLUSH_BATCH( rmesa );
+ rmesa->new_state |= R128_NEW_ALPHA;
+
+ /* For some reason enable(GL_BLEND) affects ColorLogicOpEnabled.
+ */
+ FALLBACK( rmesa, R128_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
+ break;
+
+ case GL_CULL_FACE:
+ FLUSH_BATCH( rmesa );
+ rmesa->new_state |= R128_NEW_CULL;
+ break;
+
+ case GL_DEPTH_TEST:
+ FLUSH_BATCH( rmesa );
+ rmesa->new_state |= R128_NEW_DEPTH;
+ break;
+
+ case GL_DITHER:
+ do {
+ GLuint t = rmesa->setup.tex_cntl_c;
+ FLUSH_BATCH( rmesa );
+
+ if ( ctx->Color.DitherFlag ) {
+ t |= R128_DITHER_ENABLE;
+ } else {
+ t &= ~R128_DITHER_ENABLE;
+ }
+
+ if ( rmesa->setup.tex_cntl_c != t ) {
+ rmesa->setup.tex_cntl_c = t;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+ }
+ } while (0);
+ break;
+
+ case GL_FOG:
+ FLUSH_BATCH( rmesa );
+ rmesa->new_state |= R128_NEW_FOG;
+ break;
+
+ case GL_COLOR_LOGIC_OP:
+ FLUSH_BATCH( rmesa );
+ FALLBACK( rmesa, R128_FALLBACK_LOGICOP,
+ state && ctx->Color.LogicOp != GL_COPY );
+ break;
+
+ case GL_LIGHTING:
+ updateSpecularLighting(ctx);
+ break;
+
+ case GL_SCISSOR_TEST:
+ FLUSH_BATCH( rmesa );
+ rmesa->scissor = state;
+ rmesa->new_state |= R128_NEW_CLIP;
+ break;
+
+ case GL_STENCIL_TEST:
+ FLUSH_BATCH( rmesa );
+ FALLBACK( rmesa, R128_FALLBACK_STENCIL, state );
+ break;
+
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ FLUSH_BATCH( rmesa );
+ break;
+
+ case GL_POLYGON_STIPPLE:
+ if ( rmesa->render_primitive == GL_TRIANGLES ) {
+ FLUSH_BATCH( rmesa );
+ rmesa->setup.dp_gui_master_cntl_c &= ~R128_GMC_BRUSH_NONE;
+ if ( state ) {
+ rmesa->setup.dp_gui_master_cntl_c |=
+ R128_GMC_BRUSH_32x32_MONO_FG_LA;
+ } else {
+ rmesa->setup.dp_gui_master_cntl_c |=
+ R128_GMC_BRUSH_SOLID_COLOR;
+ }
+ rmesa->new_state |= R128_NEW_CONTEXT;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+ }
+ break;
+
+ default:
+ return;
+ }
+}
+
+
+/* =============================================================
+ * State initialization, management
+ */
+
+static void r128DDPrintDirty( const char *msg, GLuint state )
+{
+ fprintf( stderr,
+ "%s: (0x%x) %s%s%s%s%s%s%s%s%s\n",
+ msg,
+ state,
+ (state & R128_UPLOAD_CORE) ? "core, " : "",
+ (state & R128_UPLOAD_CONTEXT) ? "context, " : "",
+ (state & R128_UPLOAD_SETUP) ? "setup, " : "",
+ (state & R128_UPLOAD_TEX0) ? "tex0, " : "",
+ (state & R128_UPLOAD_TEX1) ? "tex1, " : "",
+ (state & R128_UPLOAD_MASKS) ? "masks, " : "",
+ (state & R128_UPLOAD_WINDOW) ? "window, " : "",
+ (state & R128_UPLOAD_CLIPRECTS) ? "cliprects, " : "",
+ (state & R128_REQUIRE_QUIESCENCE) ? "quiescence, " : "" );
+}
+
+/*
+ * Load the current context's state into the hardware.
+ *
+ * NOTE: Be VERY careful about ensuring the context state is marked for
+ * upload, the only place it shouldn't be uploaded is when the setup
+ * state has changed in ReducedPrimitiveChange as this comes right after
+ * a state update.
+ *
+ * Blits of any type should always upload the context and masks after
+ * they are done.
+ */
+void r128EmitHwStateLocked( r128ContextPtr rmesa )
+{
+ drm_r128_sarea_t *sarea = rmesa->sarea;
+ drm_r128_context_regs_t *regs = &(rmesa->setup);
+ const r128TexObjPtr t0 = rmesa->CurrentTexObj[0];
+ const r128TexObjPtr t1 = rmesa->CurrentTexObj[1];
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_MSG ) {
+ r128DDPrintDirty( "r128EmitHwStateLocked", rmesa->dirty );
+ }
+
+ if ( rmesa->dirty & (R128_UPLOAD_CONTEXT |
+ R128_UPLOAD_SETUP |
+ R128_UPLOAD_MASKS |
+ R128_UPLOAD_WINDOW |
+ R128_UPLOAD_CORE) ) {
+ memcpy( &sarea->context_state, regs, sizeof(sarea->context_state) );
+ }
+
+ if ( (rmesa->dirty & R128_UPLOAD_TEX0) && t0 ) {
+ drm_r128_texture_regs_t *tex = &sarea->tex_state[0];
+
+ tex->tex_cntl = t0->setup.tex_cntl;
+ tex->tex_combine_cntl = rmesa->tex_combine[0];
+ tex->tex_size_pitch = t0->setup.tex_size_pitch;
+ memcpy( &tex->tex_offset[0], &t0->setup.tex_offset[0],
+ sizeof(tex->tex_offset ) );
+ tex->tex_border_color = t0->setup.tex_border_color;
+ }
+
+ if ( (rmesa->dirty & R128_UPLOAD_TEX1) && t1 ) {
+ drm_r128_texture_regs_t *tex = &sarea->tex_state[1];
+
+ tex->tex_cntl = t1->setup.tex_cntl;
+ tex->tex_combine_cntl = rmesa->tex_combine[1];
+ tex->tex_size_pitch = t1->setup.tex_size_pitch;
+ memcpy( &tex->tex_offset[0], &t1->setup.tex_offset[0],
+ sizeof(tex->tex_offset ) );
+ tex->tex_border_color = t1->setup.tex_border_color;
+ }
+
+ sarea->vertsize = rmesa->vertex_size;
+ sarea->vc_format = rmesa->vertex_format;
+
+ /* Turn off the texture cache flushing */
+ rmesa->setup.tex_cntl_c &= ~R128_TEX_CACHE_FLUSH;
+
+ sarea->dirty |= rmesa->dirty;
+ rmesa->dirty &= R128_UPLOAD_CLIPRECTS;
+}
+
+static void r128DDPrintState( const char *msg, GLuint flags )
+{
+ fprintf( stderr,
+ "%s: (0x%x) %s%s%s%s%s%s%s%s\n",
+ msg,
+ flags,
+ (flags & R128_NEW_CONTEXT) ? "context, " : "",
+ (flags & R128_NEW_ALPHA) ? "alpha, " : "",
+ (flags & R128_NEW_DEPTH) ? "depth, " : "",
+ (flags & R128_NEW_FOG) ? "fog, " : "",
+ (flags & R128_NEW_CLIP) ? "clip, " : "",
+ (flags & R128_NEW_CULL) ? "cull, " : "",
+ (flags & R128_NEW_MASKS) ? "masks, " : "",
+ (flags & R128_NEW_WINDOW) ? "window, " : "" );
+}
+
+void r128DDUpdateHWState( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ int new_state = rmesa->new_state;
+
+ if ( new_state || rmesa->NewGLState & _NEW_TEXTURE )
+ {
+ FLUSH_BATCH( rmesa );
+
+ rmesa->new_state = 0;
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_MSG )
+ r128DDPrintState( "r128UpdateHwState", new_state );
+
+ /* Update the various parts of the context's state.
+ */
+ if ( new_state & R128_NEW_ALPHA )
+ r128UpdateAlphaMode( ctx );
+
+ if ( new_state & R128_NEW_DEPTH )
+ r128UpdateZMode( ctx );
+
+ if ( new_state & R128_NEW_FOG )
+ r128UpdateFogAttrib( ctx );
+
+ if ( new_state & R128_NEW_CLIP )
+ r128UpdateClipping( ctx );
+
+ if ( new_state & R128_NEW_CULL )
+ r128UpdateCull( ctx );
+
+ if ( new_state & R128_NEW_MASKS )
+ r128UpdateMasks( ctx );
+
+ if ( new_state & R128_NEW_WINDOW )
+ r128UpdateWindow( ctx );
+
+ if ( rmesa->NewGLState & _NEW_TEXTURE ) {
+ r128UpdateTextureState( ctx );
+ }
+ }
+}
+
+
+static void r128DDInvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ R128_CONTEXT(ctx)->NewGLState |= new_state;
+}
+
+
+
+/* Initialize the context's hardware state.
+ */
+void r128DDInitState( r128ContextPtr rmesa )
+{
+ int dst_bpp, depth_bpp;
+
+ switch ( rmesa->r128Screen->cpp ) {
+ case 2:
+ dst_bpp = R128_GMC_DST_16BPP;
+ break;
+ case 4:
+ dst_bpp = R128_GMC_DST_32BPP;
+ break;
+ default:
+ fprintf( stderr, "Error: Unsupported pixel depth... exiting\n" );
+ exit( -1 );
+ }
+
+ rmesa->ClearColor = 0x00000000;
+
+ switch ( rmesa->glCtx->Visual.depthBits ) {
+ case 16:
+ rmesa->ClearDepth = 0x0000ffff;
+ depth_bpp = R128_Z_PIX_WIDTH_16;
+ rmesa->depth_scale = 1.0 / (GLfloat)0xffff;
+ break;
+ case 24:
+ rmesa->ClearDepth = 0x00ffffff;
+ depth_bpp = R128_Z_PIX_WIDTH_24;
+ rmesa->depth_scale = 1.0 / (GLfloat)0xffffff;
+ break;
+ default:
+ fprintf( stderr, "Error: Unsupported depth %d... exiting\n",
+ rmesa->glCtx->Visual.depthBits );
+ exit( -1 );
+ }
+
+ rmesa->Fallback = 0;
+
+ if ( rmesa->glCtx->Visual.doubleBufferMode && rmesa->sarea->pfCurrentPage == 0 ) {
+ rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->backOffset;
+ rmesa->drawPitch = rmesa->readPitch = rmesa->r128Screen->backPitch;
+ } else {
+ rmesa->drawOffset = rmesa->readOffset = rmesa->r128Screen->frontOffset;
+ rmesa->drawPitch = rmesa->readPitch = rmesa->r128Screen->frontPitch;
+ }
+
+ /* Harware state:
+ */
+ rmesa->setup.dst_pitch_offset_c = (((rmesa->drawPitch/8) << 21) |
+ (rmesa->drawOffset >> 5));
+
+ rmesa->setup.dp_gui_master_cntl_c = (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_GMC_AUX_CLIP_DIS |
+ R128_GMC_WR_MSK_DIS);
+
+ rmesa->setup.sc_top_left_c = 0x00000000;
+ rmesa->setup.sc_bottom_right_c = 0x1fff1fff;
+
+ rmesa->setup.z_offset_c = rmesa->r128Screen->depthOffset;
+ rmesa->setup.z_pitch_c = ((rmesa->r128Screen->depthPitch >> 3) |
+ R128_Z_TILE);
+
+ rmesa->setup.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);
+
+ rmesa->setup.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 |
+ (0x3f << R128_LOD_BIAS_SHIFT));
+
+ rmesa->setup.misc_3d_state_cntl_reg = (R128_MISC_SCALE_3D_TEXMAP_SHADE |
+ R128_MISC_SCALE_PIX_REPLICATE |
+ R128_ALPHA_COMB_ADD_CLAMP |
+ R128_FOG_VERTEX |
+ (R128_ALPHA_BLEND_ONE << R128_ALPHA_BLEND_SRC_SHIFT) |
+ (R128_ALPHA_BLEND_ZERO << R128_ALPHA_BLEND_DST_SHIFT) |
+ R128_ALPHA_TEST_ALWAYS);
+
+ rmesa->setup.texture_clr_cmp_clr_c = 0x00000000;
+ rmesa->setup.texture_clr_cmp_msk_c = 0xffffffff;
+
+ rmesa->setup.fog_color_c = 0x00000000;
+
+ rmesa->setup.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);
+
+ rmesa->setup.setup_cntl = (R128_COLOR_GOURAUD |
+ R128_PRIM_TYPE_TRI |
+ R128_TEXTURE_ST_MULT_W |
+ R128_STARTING_VERTEX_1 |
+ R128_ENDING_VERTEX_3 |
+ R128_SU_POLY_LINE_NOT_LAST |
+ R128_SUB_PIX_4BITS);
+
+ rmesa->setup.tex_size_pitch_c = 0x00000000;
+ rmesa->setup.constant_color_c = 0x00ffffff;
+
+ rmesa->setup.dp_write_mask = 0xffffffff;
+ rmesa->setup.sten_ref_mask_c = 0xffff0000;
+ rmesa->setup.plane_3d_mask_c = 0xffffffff;
+
+ rmesa->setup.window_xy_offset = 0x00000000;
+
+ rmesa->setup.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_ALPHA_COMB_ADD_CLAMP |
+ R128_FOG_VERTEX |
+ (R128_ALPHA_BLEND_ONE << R128_ALPHA_BLEND_SRC_SHIFT) |
+ (R128_ALPHA_BLEND_ZERO << R128_ALPHA_BLEND_DST_SHIFT) |
+ R128_ALPHA_TEST_ALWAYS |
+ R128_COMPOSITE_SHADOW_CMP_EQUAL |
+ R128_TEX_MAP_ALPHA_IN_TEXTURE |
+ R128_TEX_CACHE_LINE_SIZE_4QW);
+
+ rmesa->new_state = R128_NEW_ALL;
+}
+
+/* Initialize the driver's state functions.
+ */
+void r128DDInitStateFuncs( GLcontext *ctx )
+{
+ ctx->Driver.UpdateState = r128DDInvalidateState;
+
+ ctx->Driver.ClearIndex = NULL;
+ ctx->Driver.ClearColor = r128DDClearColor;
+ ctx->Driver.DrawBuffer = r128DDDrawBuffer;
+ ctx->Driver.ReadBuffer = r128DDReadBuffer;
+
+ ctx->Driver.IndexMask = NULL;
+ ctx->Driver.ColorMask = r128DDColorMask;
+ ctx->Driver.AlphaFunc = r128DDAlphaFunc;
+ ctx->Driver.BlendEquationSeparate = r128DDBlendEquationSeparate;
+ 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.Enable = r128DDEnable;
+ ctx->Driver.Fogfv = r128DDFogfv;
+ ctx->Driver.Hint = NULL;
+ ctx->Driver.Lightfv = NULL;
+ ctx->Driver.LightModelfv = r128DDLightModelfv;
+ ctx->Driver.LogicOpcode = r128DDLogicOpCode;
+ ctx->Driver.PolygonMode = NULL;
+ ctx->Driver.PolygonStipple = r128DDPolygonStipple;
+ ctx->Driver.RenderMode = r128DDRenderMode;
+ ctx->Driver.Scissor = r128DDScissor;
+ ctx->Driver.ShadeModel = r128DDShadeModel;
+ ctx->Driver.ClearStencil = NULL;
+ ctx->Driver.StencilFunc = NULL;
+ ctx->Driver.StencilMask = NULL;
+ ctx->Driver.StencilOp = NULL;
+
+ ctx->Driver.DepthRange = r128DepthRange;
+ ctx->Driver.Viewport = r128Viewport;
+
+ /* Pixel path fallbacks.
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_state.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_state.h
new file mode 100644
index 000000000..ac33853b1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_state.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_state.h,v 1.3 2001/01/08 01:07:21 martin Exp $ */
+/**************************************************************************
+
+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@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ *
+ */
+
+#ifndef __R128_STATE_H__
+#define __R128_STATE_H__
+
+#include "r128_context.h"
+
+extern void r128DDInitState( r128ContextPtr rmesa );
+extern void r128DDInitStateFuncs( GLcontext *ctx );
+
+extern void r128DDUpdateState( GLcontext *ctx );
+extern void r128DDUpdateHWState( GLcontext *ctx );
+
+extern void r128UpdateWindow( GLcontext *ctx );
+
+extern void r128EmitHwStateLocked( r128ContextPtr rmesa );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_tex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_tex.c
new file mode 100644
index 000000000..3b2d017c1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_tex.c
@@ -0,0 +1,617 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.c,v 1.14 2002/11/05 17:46:08 tsi Exp $ */
+/**************************************************************************
+
+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@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ */
+
+#include "r128_context.h"
+#include "r128_state.h"
+#include "r128_ioctl.h"
+#include "r128_tris.h"
+#include "r128_tex.h"
+#include "r128_texobj.h"
+
+#include "context.h"
+#include "macros.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "texstore.h"
+#include "texformat.h"
+#include "teximage.h"
+#include "texobj.h"
+#include "imports.h"
+#include "colormac.h"
+#include "texobj.h"
+
+#include "xmlpool.h"
+
+#define TEX_0 1
+#define TEX_1 2
+
+
+/**
+ * Set the texture wrap modes. Currently \c GL_REPEAT, \c GL_CLAMP,
+ * \c GL_CLAMP_TO_EDGE, and \c GL_MIRRORED_REPEAT are supported.
+ *
+ * \param t Texture object whose wrap modes are to be set
+ * \param swrap Wrap mode for the \a s texture coordinate
+ * \param twrap Wrap mode for the \a t texture coordinate
+ */
+static void r128SetTexWrap( r128TexObjPtr t, GLenum swrap, GLenum twrap )
+{
+ t->setup.tex_cntl &= ~(R128_TEX_CLAMP_S_MASK | R128_TEX_CLAMP_T_MASK);
+
+ switch ( swrap ) {
+ case GL_CLAMP:
+ t->setup.tex_cntl |= R128_TEX_CLAMP_S_BORDER_COLOR;
+ break;
+ case GL_CLAMP_TO_EDGE:
+ t->setup.tex_cntl |= R128_TEX_CLAMP_S_CLAMP;
+ break;
+ case GL_REPEAT:
+ t->setup.tex_cntl |= R128_TEX_CLAMP_S_WRAP;
+ break;
+ case GL_MIRRORED_REPEAT:
+ t->setup.tex_cntl |= R128_TEX_CLAMP_S_MIRROR;
+ break;
+ }
+
+ switch ( twrap ) {
+ case GL_CLAMP:
+ t->setup.tex_cntl |= R128_TEX_CLAMP_T_BORDER_COLOR;
+ break;
+ case GL_CLAMP_TO_EDGE:
+ t->setup.tex_cntl |= R128_TEX_CLAMP_T_CLAMP;
+ break;
+ case GL_REPEAT:
+ t->setup.tex_cntl |= R128_TEX_CLAMP_T_WRAP;
+ break;
+ case GL_MIRRORED_REPEAT:
+ t->setup.tex_cntl |= R128_TEX_CLAMP_T_MIRROR;
+ break;
+ }
+}
+
+static void r128SetTexFilter( r128TexObjPtr t, GLenum minf, GLenum magf )
+{
+ t->setup.tex_cntl &= ~(R128_MIN_BLEND_MASK | R128_MAG_BLEND_MASK);
+
+ switch ( minf ) {
+ case GL_NEAREST:
+ t->setup.tex_cntl |= R128_MIN_BLEND_NEAREST;
+ break;
+ case GL_LINEAR:
+ t->setup.tex_cntl |= R128_MIN_BLEND_LINEAR;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ t->setup.tex_cntl |= R128_MIN_BLEND_MIPNEAREST;
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ t->setup.tex_cntl |= R128_MIN_BLEND_MIPLINEAR;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ t->setup.tex_cntl |= R128_MIN_BLEND_LINEARMIPNEAREST;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ t->setup.tex_cntl |= R128_MIN_BLEND_LINEARMIPLINEAR;
+ break;
+ }
+
+ switch ( magf ) {
+ case GL_NEAREST:
+ t->setup.tex_cntl |= R128_MAG_BLEND_NEAREST;
+ break;
+ case GL_LINEAR:
+ t->setup.tex_cntl |= R128_MAG_BLEND_LINEAR;
+ break;
+ }
+}
+
+static void r128SetTexBorderColor( r128TexObjPtr t, GLubyte c[4] )
+{
+ t->setup.tex_border_color = r128PackColor( 4, c[0], c[1], c[2], c[3] );
+}
+
+
+static r128TexObjPtr r128AllocTexObj( struct gl_texture_object *texObj )
+{
+ r128TexObjPtr t;
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *) texObj );
+ }
+
+ t = (r128TexObjPtr) CALLOC_STRUCT( r128_tex_obj );
+ texObj->DriverData = t;
+ if ( t != NULL ) {
+
+ /* Initialize non-image-dependent parts of the state:
+ */
+ t->base.tObj = texObj;
+
+ /* FIXME Something here to set initial values for other parts of
+ * FIXME t->setup?
+ */
+
+ make_empty_list( (driTextureObject *) t );
+
+ r128SetTexWrap( t, texObj->WrapS, texObj->WrapT );
+ r128SetTexFilter( t, texObj->MinFilter, texObj->MagFilter );
+ r128SetTexBorderColor( t, texObj->_BorderChan );
+ }
+
+ return t;
+}
+
+
+/* Called by the _mesa_store_teximage[123]d() functions. */
+static const struct gl_texture_format *
+r128ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ const GLboolean do32bpt =
+ ( rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32 );
+ const GLboolean force16bpt =
+ ( rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16 );
+ (void) format;
+ (void) type;
+
+ switch ( internalFormat ) {
+ /* non-sized formats with alpha */
+ case GL_INTENSITY:
+ case GL_COMPRESSED_INTENSITY:
+ case GL_ALPHA:
+ case GL_COMPRESSED_ALPHA:
+ case 2:
+ case GL_LUMINANCE_ALPHA:
+ case GL_COMPRESSED_LUMINANCE_ALPHA:
+ case 4:
+ case GL_RGBA:
+ case GL_COMPRESSED_RGBA:
+ if (do32bpt)
+ return _dri_texformat_argb8888;
+ else
+ return _dri_texformat_argb4444;
+
+ /* 16-bit formats with alpha */
+ case GL_INTENSITY4:
+ case GL_ALPHA4:
+ case GL_LUMINANCE4_ALPHA4:
+ case GL_RGBA2:
+ case GL_RGBA4:
+ return _dri_texformat_argb4444;
+
+ /* 32-bit formats with alpha */
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ case GL_LUMINANCE6_ALPHA2:
+ case GL_LUMINANCE8_ALPHA8:
+ case GL_LUMINANCE12_ALPHA4:
+ case GL_LUMINANCE12_ALPHA12:
+ case GL_LUMINANCE16_ALPHA16:
+ case GL_RGB5_A1:
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ if (!force16bpt)
+ return _dri_texformat_argb8888;
+ else
+ return _dri_texformat_argb4444;
+
+ /* non-sized formats without alpha */
+ case 1:
+ case GL_LUMINANCE:
+ case GL_COMPRESSED_LUMINANCE:
+ case 3:
+ case GL_RGB:
+ case GL_COMPRESSED_RGB:
+ if (do32bpt)
+ return _dri_texformat_argb8888;
+ else
+ return _dri_texformat_rgb565;
+
+ /* 16-bit formats without alpha */
+ case GL_LUMINANCE4:
+ case GL_R3_G3_B2:
+ case GL_RGB4:
+ case GL_RGB5:
+ return _dri_texformat_rgb565;
+
+ /* 32-bit formats without alpha */
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ if (!force16bpt)
+ return _dri_texformat_argb8888;
+ else
+ return _dri_texformat_rgb565;
+
+ /* color-indexed formats */
+ 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:
+ return _dri_texformat_ci8;
+
+ case GL_YCBCR_MESA:
+ if (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
+ type == GL_UNSIGNED_BYTE)
+ return &_mesa_texformat_ycbcr;
+ else
+ return &_mesa_texformat_ycbcr_rev;
+
+ default:
+ _mesa_problem( ctx, "unexpected format in %s", __FUNCTION__ );
+ return NULL;
+ }
+}
+
+
+static void r128TexImage1D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+ if ( t ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) r128AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
+ return;
+ }
+ }
+
+ /* Note, this will call r128ChooseTextureFormat */
+ _mesa_store_teximage1d( ctx, target, level, internalFormat,
+ width, border, format, type,
+ pixels, packing, texObj, texImage );
+
+ t->dirty_images[0] |= (1 << level);
+}
+
+
+static void r128TexSubImage1D( 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 )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+ assert( t ); /* this _should_ be true */
+ if ( t ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) r128AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
+ return;
+ }
+ }
+
+ _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
+ format, type, pixels, packing, texObj,
+ texImage);
+
+ t->dirty_images[0] |= (1 << level);
+}
+
+
+static void r128TexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+ if ( t ) {
+ driSwapOutTextureObject( (driTextureObject *) t );
+ }
+ else {
+ t = (driTextureObject *) r128AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ }
+
+ /* Note, this will call r128ChooseTextureFormat */
+ _mesa_store_teximage2d(ctx, target, level, internalFormat,
+ width, height, border, format, type, pixels,
+ &ctx->Unpack, texObj, texImage);
+
+ t->dirty_images[0] |= (1 << level);
+}
+
+
+static void r128TexSubImage2D( 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 )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+ assert( t ); /* this _should_ be true */
+ if ( t ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) r128AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ }
+
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
+ t->dirty_images[0] |= (1 << level);
+}
+
+
+static void r128TexEnv( GLcontext *ctx, GLenum target,
+ GLenum pname, const GLfloat *param )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit;
+ GLubyte c[4];
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %s )\n",
+ __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) );
+ }
+
+ switch ( pname ) {
+ case GL_TEXTURE_ENV_MODE:
+ FLUSH_BATCH( rmesa );
+ rmesa->new_state |= R128_NEW_ALPHA;
+ break;
+
+ case GL_TEXTURE_ENV_COLOR:
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ CLAMPED_FLOAT_TO_UBYTE( c[0], texUnit->EnvColor[0] );
+ CLAMPED_FLOAT_TO_UBYTE( c[1], texUnit->EnvColor[1] );
+ CLAMPED_FLOAT_TO_UBYTE( c[2], texUnit->EnvColor[2] );
+ CLAMPED_FLOAT_TO_UBYTE( c[3], texUnit->EnvColor[3] );
+ rmesa->env_color = r128PackColor( 4, c[0], c[1], c[2], c[3] );
+ if ( rmesa->setup.constant_color_c != rmesa->env_color ) {
+ FLUSH_BATCH( rmesa );
+ rmesa->setup.constant_color_c = rmesa->env_color;
+
+ /* More complex multitexture/multipass fallbacks for GL_BLEND
+ * can be done later, but this allows a single pass GL_BLEND
+ * in some cases (ie. Performer town demo). This is only
+ * applicable to the regular Rage 128, as the Pro and M3 can
+ * handle true single-pass GL_BLEND texturing.
+ */
+ rmesa->blend_flags &= ~R128_BLEND_ENV_COLOR;
+ if ( R128_IS_PLAIN( rmesa ) &&
+ rmesa->env_color != 0x00000000 &&
+ rmesa->env_color != 0xff000000 &&
+ rmesa->env_color != 0x00ffffff &&
+ rmesa->env_color != 0xffffffff ) {
+ rmesa->blend_flags |= R128_BLEND_ENV_COLOR;
+ }
+ }
+ break;
+
+ case GL_TEXTURE_LOD_BIAS:
+ {
+ u_int32_t t = rmesa->setup.tex_cntl_c;
+ GLint bias;
+ u_int32_t b;
+
+ /* GTH: This isn't exactly correct, but gives good results up to a
+ * certain point. It is better than completely ignoring the LOD
+ * bias. Unfortunately there isn't much range in the bias, the
+ * spec mentions strides that vary between 0.5 and 2.0 but these
+ * numbers don't seem to relate the the GL LOD bias value at all.
+ */
+ if ( param[0] >= 1.0 ) {
+ bias = -128;
+ } else if ( param[0] >= 0.5 ) {
+ bias = -64;
+ } else if ( param[0] >= 0.25 ) {
+ bias = 0;
+ } else if ( param[0] >= 0.0 ) {
+ bias = 63;
+ } else {
+ bias = 127;
+ }
+
+ b = (u_int32_t)bias & 0xff;
+ t &= ~R128_LOD_BIAS_MASK;
+ t |= (b << R128_LOD_BIAS_SHIFT);
+
+ if ( rmesa->setup.tex_cntl_c != t ) {
+ FLUSH_BATCH( rmesa );
+ rmesa->setup.tex_cntl_c = t;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+ }
+ }
+ break;
+
+ default:
+ return;
+ }
+}
+
+
+static void r128TexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat *params )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ r128TexObjPtr t = (r128TexObjPtr)tObj->DriverData;
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %s )\n",
+ __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) );
+ }
+
+ if ( ( target != GL_TEXTURE_2D ) && ( target != GL_TEXTURE_1D ) )
+ return;
+
+ switch ( pname ) {
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ if ( t->base.bound ) FLUSH_BATCH( rmesa );
+ r128SetTexFilter( t, tObj->MinFilter, tObj->MagFilter );
+ break;
+
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ if ( t->base.bound ) FLUSH_BATCH( rmesa );
+ r128SetTexWrap( t, tObj->WrapS, tObj->WrapT );
+ break;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ if ( t->base.bound ) FLUSH_BATCH( rmesa );
+ r128SetTexBorderColor( t, tObj->_BorderChan );
+ break;
+
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ /* This isn't the most efficient solution but there doesn't appear to
+ * be a nice alternative for R128. Since there's no LOD clamping,
+ * we just have to rely on loading the right subset of mipmap levels
+ * to simulate a clamped LOD.
+ */
+ if ( t->base.bound ) FLUSH_BATCH( rmesa );
+ driSwapOutTextureObject( (driTextureObject *) t );
+ break;
+
+ default:
+ return;
+ }
+}
+
+static void r128BindTexture( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj )
+{
+ if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %p ) unit=%d\n", __FUNCTION__, (void *) tObj,
+ ctx->Texture.CurrentUnit );
+ }
+
+ assert( (target != GL_TEXTURE_2D && target != GL_TEXTURE_1D) ||
+ (tObj->DriverData != NULL) );
+}
+
+
+static void r128DeleteTexture( GLcontext *ctx,
+ struct gl_texture_object *tObj )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ driTextureObject * t = (driTextureObject *) tObj->DriverData;
+
+ if ( t ) {
+ if ( t->bound && rmesa ) {
+ FLUSH_BATCH( rmesa );
+ }
+
+ driDestroyTextureObject( t );
+ }
+ /* Free mipmap images and the texture object itself */
+ _mesa_delete_texture_object(ctx, tObj);
+}
+
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
+ * Note: we could use containment here to 'derive' the driver-specific
+ * texture object from the core mesa gl_texture_object. Not done at this time.
+ */
+static struct gl_texture_object *
+r128NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+{
+ struct gl_texture_object *obj;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ r128AllocTexObj( obj );
+ return obj;
+}
+
+void r128InitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->TexEnv = r128TexEnv;
+ functions->ChooseTextureFormat = r128ChooseTextureFormat;
+ functions->TexImage1D = r128TexImage1D;
+ functions->TexSubImage1D = r128TexSubImage1D;
+ functions->TexImage2D = r128TexImage2D;
+ functions->TexSubImage2D = r128TexSubImage2D;
+ functions->TexParameter = r128TexParameter;
+ functions->BindTexture = r128BindTexture;
+ functions->NewTextureObject = r128NewTextureObject;
+ functions->DeleteTexture = r128DeleteTexture;
+ functions->IsTextureResident = driIsTextureResident;
+
+ driInitTextureFormats();
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_tex.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_tex.h
new file mode 100644
index 000000000..54053b8b3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_tex.h
@@ -0,0 +1,85 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tex.h,v 1.7 2002/02/22 21:44:58 dawes Exp $ */
+/**************************************************************************
+
+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@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ *
+ */
+
+#ifndef __R128_TEX_H__
+#define __R128_TEX_H__
+
+extern void r128UpdateTextureState( GLcontext *ctx );
+
+extern void r128UploadTexImages( r128ContextPtr rmesa, r128TexObjPtr t );
+
+extern void r128DestroyTexObj( r128ContextPtr rmesa, r128TexObjPtr t );
+
+extern void r128InitTextureFuncs( struct dd_function_table *functions );
+
+
+/* ================================================================
+ * Color conversion macros:
+ */
+
+#define R128PACKCOLOR332( r, g, b ) \
+ (((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))
+
+#define R128PACKCOLOR1555( r, g, b, a ) \
+ ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
+ ((a) ? 0x8000 : 0))
+
+#define R128PACKCOLOR565( r, g, b ) \
+ ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
+
+#define R128PACKCOLOR888( r, g, b ) \
+ (((r) << 16) | ((g) << 8) | (b))
+
+#define R128PACKCOLOR8888( r, g, b, a ) \
+ (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
+
+#define R128PACKCOLOR4444( r, g, b, a ) \
+ ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
+
+static __inline__ u_int32_t r128PackColor( GLuint cpp,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a )
+{
+ switch ( cpp ) {
+ case 2:
+ return R128PACKCOLOR565( r, g, b );
+ case 4:
+ return R128PACKCOLOR8888( r, g, b, a );
+ default:
+ return 0;
+ }
+}
+
+#endif /* __R128_TEX_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_texmem.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_texmem.c
new file mode 100644
index 000000000..d011a7567
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_texmem.c
@@ -0,0 +1,301 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_texmem.c,v 1.1 2002/02/22 21:44:58 dawes Exp $ */
+/**************************************************************************
+
+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@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ */
+
+#include "r128_context.h"
+#include "r128_state.h"
+#include "r128_ioctl.h"
+#include "r128_tris.h"
+#include "r128_tex.h"
+
+#include "context.h"
+#include "macros.h"
+#include "simple_list.h"
+#include "texformat.h"
+#include "imports.h"
+
+#define TEX_0 1
+#define TEX_1 2
+
+
+/* Destroy hardware state associated with texture `t'.
+ */
+void r128DestroyTexObj( r128ContextPtr rmesa, r128TexObjPtr t )
+{
+ unsigned i;
+
+
+ /* See if it was the driver's current object.
+ */
+
+ if ( rmesa != NULL )
+ {
+ for ( i = 0 ; i < rmesa->glCtx->Const.MaxTextureUnits ; i++ )
+ {
+ if ( t == rmesa->CurrentTexObj[ i ] ) {
+ assert( t->base.bound & (1 << i) );
+ rmesa->CurrentTexObj[ i ] = NULL;
+ }
+ }
+ }
+}
+
+
+/**
+ * Upload the texture image associated with texture \a t at the specified
+ * level at the address relative to \a start.
+ */
+static void uploadSubImage( r128ContextPtr rmesa, r128TexObjPtr t,
+ GLint level,
+ GLint x, GLint y, GLint width, GLint height )
+{
+ struct gl_texture_image *image;
+ int texelsPerDword = 0;
+ int imageWidth, imageHeight;
+ int remaining, rows;
+ int format, dwords;
+ u_int32_t pitch, offset;
+ int i;
+
+ /* Ensure we have a valid texture to upload */
+ if ( ( level < 0 ) || ( level > R128_MAX_TEXTURE_LEVELS ) )
+ return;
+
+ image = t->base.tObj->Image[0][level];
+ if ( !image )
+ return;
+
+ switch ( image->TexFormat->TexelBytes ) {
+ case 1: texelsPerDword = 4; break;
+ case 2: texelsPerDword = 2; break;
+ case 4: texelsPerDword = 1; break;
+ }
+
+#if 1
+ /* FIXME: The subimage index calcs are wrong... */
+ x = 0;
+ y = 0;
+ width = image->Width;
+ height = image->Height;
+#endif
+
+ 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 = t->bufAddr + t->image[level - t->base.firstLevel].offset;
+
+#if ENABLE_PERF_BOXES
+ /* Bump the performace counter */
+ rmesa->c_textureBytes += (dwords << 2);
+#endif
+
+ if ( R128_DEBUG & 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%07x pitch: 0x%x dwords: %d "
+ "level: %d format: %x\n",
+ (GLuint)offset, (GLuint)pitch, dwords, level, format );
+ }
+
+ /* Subdivide the texture if required */
+ if ( dwords <= R128_BUFFER_MAX_DWORDS / 2 ) {
+ rows = height;
+ } else {
+ rows = (R128_BUFFER_MAX_DWORDS * texelsPerDword) / (2 * width);
+ }
+
+ for ( i = 0, remaining = height ;
+ remaining > 0 ;
+ remaining -= rows, y += rows, i++ )
+ {
+ u_int32_t *dst;
+ drmBufPtr buffer;
+
+ assert(image->Data);
+
+ height = MIN2(remaining, rows);
+
+ /* Grab the indirect buffer for the texture blit */
+ LOCK_HARDWARE( rmesa );
+ buffer = r128GetBufferLocked( rmesa );
+
+ dst = (u_int32_t *)((char *)buffer->address + R128_HOSTDATA_BLIT_OFFSET);
+
+ /* Copy the next chunck of the texture image into the blit buffer */
+ {
+ const GLubyte *src = (const GLubyte *) image->Data +
+ (y * image->Width + x) * image->TexFormat->TexelBytes;
+ const GLuint bytes = width * height * image->TexFormat->TexelBytes;
+ memcpy(dst, src, bytes);
+ }
+
+ r128FireBlitLocked( rmesa, buffer,
+ offset, pitch, format,
+ x, y, width, height );
+ UNLOCK_HARDWARE( rmesa );
+ }
+
+ rmesa->new_state |= R128_NEW_CONTEXT;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT | R128_UPLOAD_MASKS;
+}
+
+
+/* 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.
+ */
+void r128UploadTexImages( r128ContextPtr rmesa, r128TexObjPtr t )
+{
+ const GLint numLevels = t->base.lastLevel - t->base.firstLevel + 1;
+ GLint i;
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %p, %p )\n",
+ __FUNCTION__, (void *) rmesa->glCtx, (void *) t );
+ }
+
+ assert(t);
+
+ LOCK_HARDWARE( rmesa );
+
+ if ( !t->base.memBlock ) {
+ int heap;
+
+
+ heap = driAllocateTexture( rmesa->texture_heaps, rmesa->nr_heaps,
+ (driTextureObject *) t );
+ if ( heap == -1 ) {
+ UNLOCK_HARDWARE( rmesa );
+ return;
+ }
+
+ /* Set the base offset of the texture image */
+ t->bufAddr = rmesa->r128Screen->texOffset[heap]
+ + t->base.memBlock->ofs;
+
+ /* Set texture offsets for each mipmap level */
+ if ( t->setup.tex_cntl & R128_MIP_MAP_DISABLE ) {
+ for ( i = 0 ; i < R128_MAX_TEXTURE_LEVELS ; i++ ) {
+ t->setup.tex_offset[i] = t->bufAddr;
+ }
+ } else {
+ for ( i = 0; i < numLevels; i++ ) {
+ const int j = numLevels - i - 1;
+ t->setup.tex_offset[j] = t->bufAddr + t->image[i].offset;
+ }
+ }
+ }
+
+ /* Let the world know we've used this memory recently.
+ */
+ driUpdateTextureLRU( (driTextureObject *) t );
+ UNLOCK_HARDWARE( rmesa );
+
+ /* Upload any images that are new */
+ if ( t->base.dirty_images[0] ) {
+ for ( i = 0 ; i < numLevels; i++ ) {
+ const GLint j = t->base.firstLevel + i; /* the texObj's level */
+ if ( t->base.dirty_images[0] & (1 << j) ) {
+ uploadSubImage( rmesa, t, j, 0, 0,
+ t->image[i].width, t->image[i].height );
+ }
+ }
+
+ rmesa->setup.tex_cntl_c |= R128_TEX_CACHE_FLUSH;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+ t->base.dirty_images[0] = 0;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_texobj.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_texobj.h
new file mode 100644
index 000000000..282e88714
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_texobj.h
@@ -0,0 +1,68 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_texobj.h,v 1.5 2002/02/22 21:44:58 dawes Exp $ */
+/**************************************************************************
+
+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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#ifndef _R128_TEXOBJ_H_
+#define _R128_TEXOBJ_H_
+
+#include "mm.h"
+
+/* Individual texture image information.
+ */
+typedef struct {
+ GLuint offset; /* Relative to local texture space */
+ GLuint width;
+ GLuint height;
+} r128TexImage;
+
+typedef struct r128_tex_obj r128TexObj, *r128TexObjPtr;
+
+/* Texture object in locally shared texture space.
+ */
+struct r128_tex_obj {
+ driTextureObject base;
+
+ u_int32_t bufAddr; /* Offset to start of locally
+ shared texture block */
+
+ GLuint age;
+ r128TexImage image[R128_MAX_TEXTURE_LEVELS]; /* Image data for all
+ mipmap levels */
+
+ u_int32_t textureFormat; /* Actual hardware format */
+
+ drm_r128_texture_regs_t setup; /* Setup regs for texture */
+};
+
+#endif /* _R128_TEXOBJ_H_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_texstate.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_texstate.c
new file mode 100644
index 000000000..c22323b68
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_texstate.c
@@ -0,0 +1,648 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_texstate.c,v 1.1 2002/02/22 21:44:58 dawes Exp $ */
+/**************************************************************************
+
+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@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "macros.h"
+#include "texformat.h"
+
+#include "r128_context.h"
+#include "r128_state.h"
+#include "r128_ioctl.h"
+#include "r128_tris.h"
+#include "r128_tex.h"
+
+
+static void r128SetTexImages( r128ContextPtr rmesa,
+ const struct gl_texture_object *tObj )
+{
+ r128TexObjPtr t = (r128TexObjPtr) tObj->DriverData;
+ struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
+ int log2Pitch, log2Height, log2Size, log2MinSize;
+ int totalSize;
+ int i;
+ GLint firstLevel, lastLevel;
+
+ assert(t);
+ assert(baseImage);
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_API )
+ fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *) tObj );
+
+ switch (baseImage->TexFormat->MesaFormat) {
+ case MESA_FORMAT_ARGB8888:
+ case MESA_FORMAT_ARGB8888_REV:
+ t->textureFormat = R128_DATATYPE_ARGB8888;
+ break;
+ case MESA_FORMAT_ARGB4444:
+ case MESA_FORMAT_ARGB4444_REV:
+ t->textureFormat = R128_DATATYPE_ARGB4444;
+ break;
+ case MESA_FORMAT_RGB565:
+ case MESA_FORMAT_RGB565_REV:
+ t->textureFormat = R128_DATATYPE_RGB565;
+ break;
+ case MESA_FORMAT_RGB332:
+ t->textureFormat = R128_DATATYPE_RGB8;
+ break;
+ case MESA_FORMAT_CI8:
+ t->textureFormat = R128_DATATYPE_CI8;
+ break;
+ case MESA_FORMAT_YCBCR:
+ t->textureFormat = R128_DATATYPE_YVYU422;
+ break;
+ case MESA_FORMAT_YCBCR_REV:
+ t->textureFormat = R128_DATATYPE_VYUY422;
+ break;
+ default:
+ _mesa_problem(rmesa->glCtx, "Bad texture format in %s", __FUNCTION__);
+ };
+
+ /* Compute which mipmap levels we really want to send to the hardware.
+ */
+
+ driCalculateTextureFirstLastLevel( (driTextureObject *) t );
+ firstLevel = t->base.firstLevel;
+ lastLevel = t->base.lastLevel;
+
+ log2Pitch = tObj->Image[0][firstLevel]->WidthLog2;
+ log2Height = tObj->Image[0][firstLevel]->HeightLog2;
+ log2Size = MAX2(log2Pitch, log2Height);
+ log2MinSize = log2Size;
+
+ t->base.dirty_images[0] = 0;
+ totalSize = 0;
+ for ( i = firstLevel; i <= lastLevel; i++ ) {
+ const struct gl_texture_image *texImage;
+
+ texImage = tObj->Image[0][i];
+ if ( !texImage || !texImage->Data ) {
+ lastLevel = i - 1;
+ break;
+ }
+
+ log2MinSize = texImage->MaxLog2;
+
+ t->image[i - firstLevel].offset = totalSize;
+ t->image[i - firstLevel].width = tObj->Image[0][i]->Width;
+ t->image[i - firstLevel].height = tObj->Image[0][i]->Height;
+
+ t->base.dirty_images[0] |= (1 << i);
+
+ totalSize += (tObj->Image[0][i]->Height *
+ tObj->Image[0][i]->Width *
+ tObj->Image[0][i]->TexFormat->TexelBytes);
+
+ /* Offsets must be 32-byte aligned for host data blits and tiling */
+ totalSize = (totalSize + 31) & ~31;
+ }
+
+ t->base.totalSize = totalSize;
+ t->base.firstLevel = firstLevel;
+ t->base.lastLevel = lastLevel;
+
+ /* Set the texture format */
+ t->setup.tex_cntl &= ~(0xf << 16);
+ t->setup.tex_cntl |= t->textureFormat;
+
+ t->setup.tex_combine_cntl = 0x00000000; /* XXX is this right? */
+
+ t->setup.tex_size_pitch = ((log2Pitch << R128_TEX_PITCH_SHIFT) |
+ (log2Size << R128_TEX_SIZE_SHIFT) |
+ (log2Height << R128_TEX_HEIGHT_SHIFT) |
+ (log2MinSize << R128_TEX_MIN_SIZE_SHIFT));
+
+ for ( i = 0 ; i < R128_MAX_TEXTURE_LEVELS ; i++ ) {
+ t->setup.tex_offset[i] = 0x00000000;
+ }
+
+ if (firstLevel == lastLevel)
+ t->setup.tex_cntl |= R128_MIP_MAP_DISABLE;
+ else
+ t->setup.tex_cntl &= ~R128_MIP_MAP_DISABLE;
+
+ /* FYI: r128UploadTexImages( rmesa, t ); used to be called here */
+}
+
+
+/* ================================================================
+ * Texture combine functions
+ */
+
+#define COLOR_COMB_DISABLE (R128_COMB_DIS | \
+ R128_COLOR_FACTOR_TEX)
+#define COLOR_COMB_COPY_INPUT (R128_COMB_COPY_INP | \
+ R128_COLOR_FACTOR_TEX)
+#define COLOR_COMB_MODULATE (R128_COMB_MODULATE | \
+ R128_COLOR_FACTOR_TEX)
+#define COLOR_COMB_MODULATE_NTEX (R128_COMB_MODULATE | \
+ R128_COLOR_FACTOR_NTEX)
+#define COLOR_COMB_ADD (R128_COMB_ADD | \
+ R128_COLOR_FACTOR_TEX)
+#define COLOR_COMB_BLEND_TEX (R128_COMB_BLEND_TEXTURE | \
+ R128_COLOR_FACTOR_TEX)
+/* Rage 128 Pro/M3 only! */
+#define COLOR_COMB_BLEND_COLOR (R128_COMB_MODULATE2X | \
+ R128_COMB_FCN_MSB | \
+ R128_COLOR_FACTOR_CONST_COLOR)
+
+#define ALPHA_COMB_DISABLE (R128_COMB_ALPHA_DIS | \
+ R128_ALPHA_FACTOR_TEX_ALPHA)
+#define ALPHA_COMB_COPY_INPUT (R128_COMB_ALPHA_COPY_INP | \
+ R128_ALPHA_FACTOR_TEX_ALPHA)
+#define ALPHA_COMB_MODULATE (R128_COMB_ALPHA_MODULATE | \
+ R128_ALPHA_FACTOR_TEX_ALPHA)
+#define ALPHA_COMB_MODULATE_NTEX (R128_COMB_ALPHA_MODULATE | \
+ R128_ALPHA_FACTOR_NTEX_ALPHA)
+#define ALPHA_COMB_ADD (R128_COMB_ALPHA_ADD | \
+ R128_ALPHA_FACTOR_TEX_ALPHA)
+
+#define INPUT_INTERP (R128_INPUT_FACTOR_INT_COLOR | \
+ R128_INP_FACTOR_A_INT_ALPHA)
+#define INPUT_PREVIOUS (R128_INPUT_FACTOR_PREV_COLOR | \
+ R128_INP_FACTOR_A_PREV_ALPHA)
+
+static GLboolean r128UpdateTextureEnv( GLcontext *ctx, int unit )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLint source = rmesa->tmu_source[unit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
+ const struct gl_texture_object *tObj = texUnit->_Current;
+ const GLenum format = tObj->Image[0][tObj->BaseLevel]->Format;
+ GLuint combine;
+
+ if ( R128_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %p, %d )\n",
+ __FUNCTION__, (void *) ctx, unit );
+ }
+
+ if ( unit == 0 ) {
+ combine = INPUT_INTERP;
+ } else {
+ combine = INPUT_PREVIOUS;
+ }
+
+ /* Set the texture environment state */
+ switch ( texUnit->EnvMode ) {
+ case GL_REPLACE:
+ switch ( format ) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ combine |= (COLOR_COMB_DISABLE | /* C = Ct */
+ ALPHA_COMB_DISABLE); /* A = At */
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ combine |= (COLOR_COMB_DISABLE | /* C = Ct */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ break;
+ case GL_ALPHA:
+ combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
+ ALPHA_COMB_DISABLE); /* A = At */
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return GL_FALSE;
+ }
+ break;
+
+ case GL_MODULATE:
+ switch ( format ) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ combine |= (COLOR_COMB_MODULATE | /* C = CfCt */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ combine |= (COLOR_COMB_MODULATE | /* C = CfCt */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ break;
+ case GL_ALPHA:
+ combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return GL_FALSE;
+ }
+ break;
+
+ case GL_DECAL:
+ switch ( format ) {
+ case GL_RGBA:
+ combine |= (COLOR_COMB_BLEND_TEX | /* C = Cf(1-At)+CtAt */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ break;
+ case GL_RGB:
+ combine |= (COLOR_COMB_DISABLE | /* C = Ct */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ break;
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ /* Undefined behaviour - just copy the incoming fragment */
+ combine |= (COLOR_COMB_COPY_INPUT | /* C = undefined */
+ ALPHA_COMB_COPY_INPUT); /* A = undefined */
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return GL_FALSE;
+ }
+ break;
+
+ case GL_BLEND:
+ /* Rage 128 Pro and M3 can handle GL_BLEND texturing.
+ */
+ if ( !R128_IS_PLAIN( rmesa ) ) {
+ /* XXX this hasn't been fully tested, I don't have a Pro card. -BP */
+ switch ( format ) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ combine |= (COLOR_COMB_BLEND_COLOR | /* C = Cf(1-Ct)+CcCt */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ break;
+
+ case GL_RGB:
+ case GL_LUMINANCE:
+ combine |= (COLOR_COMB_BLEND_COLOR | /* C = Cf(1-Ct)+CcCt */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ break;
+
+ case GL_ALPHA:
+ combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ break;
+
+ case GL_INTENSITY:
+ /* GH: We could be smarter about this... */
+ switch ( rmesa->env_color & 0xff000000 ) {
+ case 0x00000000:
+ combine |= (COLOR_COMB_BLEND_COLOR | /* C = Cf(1-It)+CcIt */
+ ALPHA_COMB_MODULATE_NTEX); /* A = Af(1-It) */
+ default:
+ combine |= (COLOR_COMB_MODULATE | /* C = fallback */
+ ALPHA_COMB_MODULATE); /* A = fallback */
+ return GL_FALSE;
+ }
+ break;
+
+ case GL_COLOR_INDEX:
+ default:
+ return GL_FALSE;
+ }
+ break;
+ }
+
+ /* Rage 128 has to fake some cases of GL_BLEND, otherwise fallback
+ * to software rendering.
+ */
+ if ( rmesa->blend_flags ) {
+ return GL_FALSE;
+ }
+ switch ( format ) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ switch ( rmesa->env_color & 0x00ffffff ) {
+ case 0x00000000:
+ combine |= (COLOR_COMB_MODULATE_NTEX | /* C = Cf(1-Ct) */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ break;
+#if 0
+ /* This isn't right - BP */
+ case 0x00ffffff:
+ if ( unit == 0 ) {
+ combine |= (COLOR_COMB_MODULATE_NTEX | /* C = Cf(1-Ct) */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ } else {
+ combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ }
+ break;
+#endif
+ default:
+ combine |= (COLOR_COMB_MODULATE | /* C = fallback */
+ ALPHA_COMB_MODULATE); /* A = fallback */
+ return GL_FALSE;
+ }
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ switch ( rmesa->env_color & 0x00ffffff ) {
+ case 0x00000000:
+ combine |= (COLOR_COMB_MODULATE_NTEX | /* C = Cf(1-Ct) */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ break;
+#if 0
+ /* This isn't right - BP */
+ case 0x00ffffff:
+ if ( unit == 0 ) {
+ combine |= (COLOR_COMB_MODULATE_NTEX | /* C = Cf(1-Ct) */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ } else {
+ combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ }
+ break;
+#endif
+ default:
+ combine |= (COLOR_COMB_MODULATE | /* C = fallback */
+ ALPHA_COMB_COPY_INPUT); /* A = fallback */
+ return GL_FALSE;
+ }
+ break;
+ case GL_ALPHA:
+ if ( unit == 0 ) {
+ combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ } else {
+ combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ }
+ break;
+ case GL_INTENSITY:
+ switch ( rmesa->env_color & 0x00ffffff ) {
+ case 0x00000000:
+ combine |= COLOR_COMB_MODULATE_NTEX; /* C = Cf(1-It) */
+ break;
+#if 0
+ /* This isn't right - BP */
+ case 0x00ffffff:
+ if ( unit == 0 ) {
+ combine |= COLOR_COMB_MODULATE_NTEX; /* C = Cf(1-It) */
+ } else {
+ combine |= COLOR_COMB_ADD; /* C = Cf+It */
+ }
+ break;
+#endif
+ default:
+ combine |= (COLOR_COMB_MODULATE | /* C = fallback */
+ ALPHA_COMB_MODULATE); /* A = fallback */
+ return GL_FALSE;
+ }
+ switch ( rmesa->env_color & 0xff000000 ) {
+ case 0x00000000:
+ combine |= ALPHA_COMB_MODULATE_NTEX; /* A = Af(1-It) */
+ break;
+#if 0
+ /* This isn't right - BP */
+ case 0xff000000:
+ if ( unit == 0 ) {
+ combine |= ALPHA_COMB_MODULATE_NTEX; /* A = Af(1-It) */
+ } else {
+ combine |= ALPHA_COMB_ADD; /* A = Af+It */
+ }
+ break;
+#endif
+ default:
+ combine |= (COLOR_COMB_MODULATE | /* C = fallback */
+ ALPHA_COMB_MODULATE); /* A = fallback */
+ return GL_FALSE;
+ }
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return GL_FALSE;
+ }
+ break;
+
+ case GL_ADD:
+ switch ( format ) {
+ case GL_RGBA:
+ case GL_LUMINANCE_ALPHA:
+ combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */
+ ALPHA_COMB_COPY_INPUT); /* A = Af */
+ break;
+ case GL_ALPHA:
+ combine |= (COLOR_COMB_COPY_INPUT | /* C = Cf */
+ ALPHA_COMB_MODULATE); /* A = AfAt */
+ break;
+ case GL_INTENSITY:
+ combine |= (COLOR_COMB_ADD | /* C = Cf+Ct */
+ ALPHA_COMB_ADD); /* A = Af+At */
+ break;
+ case GL_COLOR_INDEX:
+ default:
+ return GL_FALSE;
+ }
+ break;
+
+ default:
+ return GL_FALSE;
+ }
+
+ if ( rmesa->tex_combine[unit] != combine ) {
+ rmesa->tex_combine[unit] = combine;
+ rmesa->dirty |= R128_UPLOAD_TEX0 << unit;
+ }
+ return GL_TRUE;
+}
+
+static void disable_tex( GLcontext *ctx, int unit )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ FLUSH_BATCH( rmesa );
+
+ if ( rmesa->CurrentTexObj[unit] ) {
+ rmesa->CurrentTexObj[unit]->base.bound &= ~(1 << unit);
+ rmesa->CurrentTexObj[unit] = NULL;
+ }
+
+ rmesa->setup.tex_cntl_c &= ~(R128_TEXMAP_ENABLE << unit);
+ rmesa->setup.tex_size_pitch_c &= ~(R128_TEX_SIZE_PITCH_MASK <<
+ (R128_SEC_TEX_SIZE_PITCH_SHIFT * unit));
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+
+ /* If either texture unit is disabled, then multitexturing is not
+ * happening.
+ */
+
+ rmesa->blend_flags &= ~R128_BLEND_MULTITEX;
+}
+
+static GLboolean enable_tex_2d( GLcontext *ctx, int unit )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ const int source = rmesa->tmu_source[unit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
+ const struct gl_texture_object *tObj = texUnit->_Current;
+ r128TexObjPtr t = (r128TexObjPtr) tObj->DriverData;
+
+ /* Need to load the 2d images associated with this unit.
+ */
+ if ( t->base.dirty_images[0] ) {
+ /* FIXME: For Radeon, RADEON_FIREVERTICES is called here. Should
+ * FIXME: something similar be done for R128?
+ */
+ /* FLUSH_BATCH( rmesa ); */
+
+ r128SetTexImages( rmesa, tObj );
+ r128UploadTexImages( rmesa, t );
+ if ( !t->base.memBlock )
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean update_tex_common( GLcontext *ctx, int unit )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ const int source = rmesa->tmu_source[unit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
+ const struct gl_texture_object *tObj = texUnit->_Current;
+ r128TexObjPtr t = (r128TexObjPtr) tObj->DriverData;
+
+
+ /* Fallback if there's a texture border */
+ if ( tObj->Image[0][tObj->BaseLevel]->Border > 0 ) {
+ return GL_FALSE;
+ }
+
+
+ /* Update state if this is a different texture object to last
+ * time.
+ */
+ if ( rmesa->CurrentTexObj[unit] != t ) {
+ if ( rmesa->CurrentTexObj[unit] != NULL ) {
+ /* The old texture is no longer bound to this texture unit.
+ * Mark it as such.
+ */
+
+ rmesa->CurrentTexObj[unit]->base.bound &=
+ ~(1UL << unit);
+ }
+
+ rmesa->CurrentTexObj[unit] = t;
+ t->base.bound |= (1UL << unit);
+ rmesa->dirty |= R128_UPLOAD_TEX0 << unit;
+
+ driUpdateTextureLRU( (driTextureObject *) t ); /* XXX: should be locked! */
+ }
+
+ /* FIXME: We need to update the texture unit if any texture parameters have
+ * changed, but this texture was already bound. This could be changed to
+ * work like the Radeon driver where the texture object has it's own
+ * dirty state flags
+ */
+ rmesa->dirty |= R128_UPLOAD_TEX0 << unit;
+
+ /* register setup */
+ rmesa->setup.tex_size_pitch_c &= ~(R128_TEX_SIZE_PITCH_MASK <<
+ (R128_SEC_TEX_SIZE_PITCH_SHIFT * unit));
+
+ if ( unit == 0 ) {
+ rmesa->setup.tex_cntl_c |= R128_TEXMAP_ENABLE;
+ rmesa->setup.tex_size_pitch_c |= t->setup.tex_size_pitch << 0;
+ rmesa->setup.scale_3d_cntl &= ~R128_TEX_CACHE_SPLIT;
+ t->setup.tex_cntl &= ~R128_SEC_SELECT_SEC_ST;
+ }
+ else {
+ rmesa->setup.tex_cntl_c |= R128_SEC_TEXMAP_ENABLE;
+ rmesa->setup.tex_size_pitch_c |= t->setup.tex_size_pitch << 16;
+ rmesa->setup.scale_3d_cntl |= R128_TEX_CACHE_SPLIT;
+ t->setup.tex_cntl |= R128_SEC_SELECT_SEC_ST;
+
+ /* If the second TMU is enabled, then multitexturing is happening.
+ */
+ if ( R128_IS_PLAIN( rmesa ) )
+ rmesa->blend_flags |= R128_BLEND_MULTITEX;
+ }
+
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+
+
+ /* FIXME: The Radeon has some cached state so that it can avoid calling
+ * FIXME: UpdateTextureEnv in some cases. Is that possible here?
+ */
+ return r128UpdateTextureEnv( ctx, unit );
+}
+
+static GLboolean updateTextureUnit( GLcontext *ctx, int unit )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ const int source = rmesa->tmu_source[unit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[source];
+
+
+ if (texUnit->_ReallyEnabled & (TEXTURE_1D_BIT | TEXTURE_2D_BIT)) {
+ return (enable_tex_2d( ctx, unit ) &&
+ update_tex_common( ctx, unit ));
+ }
+ else if ( texUnit->_ReallyEnabled ) {
+ return GL_FALSE;
+ }
+ else {
+ disable_tex( ctx, unit );
+ return GL_TRUE;
+ }
+}
+
+
+void r128UpdateTextureState( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLboolean ok;
+
+
+ /* This works around a quirk with the R128 hardware. If only OpenGL
+ * TEXTURE1 is enabled, then the hardware TEXTURE0 must be used. The
+ * hardware TEXTURE1 can ONLY be used when hardware TEXTURE0 is also used.
+ */
+
+ rmesa->tmu_source[0] = 0;
+ rmesa->tmu_source[1] = 1;
+
+ if ((ctx->Texture._EnabledUnits & 0x03) == 0x02) {
+ /* only texture 1 enabled */
+ rmesa->tmu_source[0] = 1;
+ rmesa->tmu_source[1] = 0;
+ }
+
+ ok = (updateTextureUnit( ctx, 0 ) &&
+ updateTextureUnit( ctx, 1 ));
+
+ FALLBACK( rmesa, R128_FALLBACK_TEXTURE, !ok );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_tris.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_tris.c
new file mode 100644
index 000000000..c12ad0ccb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_tris.c
@@ -0,0 +1,769 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tris.c,v 1.8 2002/10/30 12:51:43 alanh Exp $ */ /* -*- c-basic-offset: 3 -*- */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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
+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, VA LINUX SYSTEMS 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ *
+ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "colormac.h"
+#include "macros.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
+#include "r128_tris.h"
+#include "r128_state.h"
+#include "r128_tex.h"
+#include "r128_ioctl.h"
+
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ R128_CCE_VC_CNTL_PRIM_TYPE_POINT,
+ R128_CCE_VC_CNTL_PRIM_TYPE_LINE,
+ R128_CCE_VC_CNTL_PRIM_TYPE_LINE,
+ R128_CCE_VC_CNTL_PRIM_TYPE_LINE,
+ R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST,
+};
+
+static void r128RasterPrimitive( GLcontext *ctx, GLuint hwprim );
+static void r128RenderPrimitive( GLcontext *ctx, GLenum prim );
+
+
+/***********************************************************************
+ * Emit primitives as inline vertices *
+ ***********************************************************************/
+
+#define HAVE_QUADS 0
+#define HAVE_LINES 1
+#define HAVE_POINTS 1
+#define HAVE_LE32_VERTS 1
+#define CTX_ARG r128ContextPtr rmesa
+#define GET_VERTEX_DWORDS() rmesa->vertex_size
+#define ALLOC_VERTS( n, size ) r128AllocDmaLow( rmesa, (n), (size) * 4 )
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ r128ContextPtr rmesa = R128_CONTEXT(ctx); \
+ const char *vertptr = rmesa->verts;
+#define VERT(x) (r128Vertex *)(vertptr + ((x) * vertsize * 4))
+#define VERTEX r128Vertex
+#undef TAG
+#define TAG(x) r128_##x
+#include "tnl_dd/t_dd_triemit.h"
+#undef TAG
+#undef LOCAL_VARS
+
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ if (DO_FALLBACK) \
+ rmesa->draw_tri( rmesa, a, b, c ); \
+ else \
+ r128_triangle( rmesa, a, b, c ); \
+} while (0)
+
+#define QUAD( a, b, c, d ) \
+do { \
+ if (DO_FALLBACK) { \
+ rmesa->draw_tri( rmesa, a, b, d ); \
+ rmesa->draw_tri( rmesa, b, c, d ); \
+ } else \
+ r128_quad( rmesa, a, b, c, d ); \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ if (DO_FALLBACK) \
+ rmesa->draw_line( rmesa, v0, v1 ); \
+ else \
+ r128_line( rmesa, v0, v1 ); \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ if (DO_FALLBACK) \
+ rmesa->draw_point( rmesa, v0 ); \
+ else \
+ r128_point( rmesa, v0 ); \
+} while (0)
+
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define R128_OFFSET_BIT 0x01
+#define R128_TWOSIDE_BIT 0x02
+#define R128_UNFILLED_BIT 0x04
+#define R128_FALLBACK_BIT 0x08
+#define R128_MAX_TRIFUNC 0x10
+
+
+static struct {
+ tnl_points_func points;
+ tnl_line_func line;
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
+} rast_tab[R128_MAX_TRIFUNC];
+
+
+#define DO_FALLBACK (IND & R128_FALLBACK_BIT)
+#define DO_OFFSET (IND & R128_OFFSET_BIT)
+#define DO_UNFILLED (IND & R128_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & R128_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 1
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX r128Vertex
+#define TAB rast_tab
+
+#define DEPTH_SCALE rmesa->depth_scale
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a > 0)
+#define GET_VERTEX(e) (rmesa->verts + (e * rmesa->vertex_size * sizeof(int)))
+
+#define VERT_SET_RGBA( v, c ) \
+do { \
+ r128_color_t *color = (r128_color_t *)&((v)->ui[coloroffset]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \
+} while (0)
+
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+
+#define VERT_SET_SPEC( v0, c ) \
+do { \
+ if (havespec) { \
+ r128_color_t *spec = (r128_color_t *)&((v0)->ui[specoffset]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(spec->red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(spec->green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(spec->blue, (c)[2]); \
+ } \
+} while (0)
+#define VERT_COPY_SPEC( v0, v1 ) \
+do { \
+ if (havespec) { \
+ r128_color_t *spec0 = (r128_color_t *)&((v0)->ui[specoffset]); \
+ r128_color_t *spec1 = (r128_color_t *)&((v1)->ui[specoffset]); \
+ spec0->red = spec1->red; \
+ spec0->green = spec1->green; \
+ spec0->blue = spec1->blue; \
+ } \
+} while (0)
+
+/* These don't need LE32_TO_CPU() as they are used to save and restore
+ * colors which are already in the correct format.
+ */
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
+#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[specoffset]
+#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[specoffset] = spec[idx]
+
+
+#define LOCAL_VARS(n) \
+ r128ContextPtr rmesa = R128_CONTEXT(ctx); \
+ GLuint color[n], spec[n]; \
+ GLuint coloroffset = rmesa->coloroffset; \
+ GLuint specoffset = rmesa->specoffset; \
+ GLboolean havespec = (rmesa->specoffset != 0); \
+ (void) color; (void) spec; (void) specoffset; \
+ (void) coloroffset; (void) havespec;
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+#define RASTERIZE(x) if (rmesa->hw_primitive != hw_prim[x]) \
+ r128RasterPrimitive( ctx, hw_prim[x] )
+#define RENDER_PRIMITIVE rmesa->render_primitive
+#define IND R128_FALLBACK_BIT
+#define TAG(x) x
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
+
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_TWOSIDE_BIT|R128_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_OFFSET_BIT|R128_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_TWOSIDE_BIT|R128_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_TWOSIDE_BIT|R128_OFFSET_BIT|R128_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_FALLBACK_BIT)
+#define TAG(x) x##_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_OFFSET_BIT|R128_FALLBACK_BIT)
+#define TAG(x) x##_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_TWOSIDE_BIT|R128_FALLBACK_BIT)
+#define TAG(x) x##_twoside_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_TWOSIDE_BIT|R128_OFFSET_BIT|R128_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_UNFILLED_BIT|R128_FALLBACK_BIT)
+#define TAG(x) x##_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_OFFSET_BIT|R128_UNFILLED_BIT|R128_FALLBACK_BIT)
+#define TAG(x) x##_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_TWOSIDE_BIT|R128_UNFILLED_BIT|R128_FALLBACK_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R128_TWOSIDE_BIT|R128_OFFSET_BIT|R128_UNFILLED_BIT| \
+ R128_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+static void init_rast_tab( void )
+{
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+ init_fallback();
+ init_offset_fallback();
+ init_twoside_fallback();
+ init_twoside_offset_fallback();
+ init_unfilled_fallback();
+ init_offset_unfilled_fallback();
+ init_twoside_unfilled_fallback();
+ init_twoside_offset_unfilled_fallback();
+}
+
+
+
+/***********************************************************************
+ * Rasterization fallback helpers *
+ ***********************************************************************/
+
+
+/* This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+static void
+r128_fallback_tri( r128ContextPtr rmesa,
+ r128Vertex *v0,
+ r128Vertex *v1,
+ r128Vertex *v2 )
+{
+ GLcontext *ctx = rmesa->glCtx;
+ SWvertex v[3];
+ _swsetup_Translate( ctx, v0, &v[0] );
+ _swsetup_Translate( ctx, v1, &v[1] );
+ _swsetup_Translate( ctx, v2, &v[2] );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+}
+
+
+static void
+r128_fallback_line( r128ContextPtr rmesa,
+ r128Vertex *v0,
+ r128Vertex *v1 )
+{
+ GLcontext *ctx = rmesa->glCtx;
+ SWvertex v[2];
+ _swsetup_Translate( ctx, v0, &v[0] );
+ _swsetup_Translate( ctx, v1, &v[1] );
+ _swrast_Line( ctx, &v[0], &v[1] );
+}
+
+
+static void
+r128_fallback_point( r128ContextPtr rmesa,
+ r128Vertex *v0 )
+{
+ GLcontext *ctx = rmesa->glCtx;
+ SWvertex v[1];
+ _swsetup_Translate( ctx, v0, &v[0] );
+ _swrast_Point( ctx, &v[0] );
+}
+
+
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ r128_point( rmesa, VERT(start) )
+#define RENDER_LINE( v0, v1 ) \
+ r128_line( rmesa, VERT(v0), VERT(v1) )
+#define RENDER_TRI( v0, v1, v2 ) \
+ r128_triangle( rmesa, VERT(v0), VERT(v1), VERT(v2) )
+#define RENDER_QUAD( v0, v1, v2, v3 ) \
+ r128_quad( rmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
+#define INIT(x) do { \
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__); \
+ r128RenderPrimitive( ctx, x ); \
+} while (0)
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ r128ContextPtr rmesa = R128_CONTEXT(ctx); \
+ const GLuint vertsize = rmesa->vertex_size; \
+ const char *vertptr = (char *)rmesa->verts; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ (void) elt;
+#define RESET_STIPPLE
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) (x)
+#define TAG(x) r128_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+#undef ELT
+#undef TAG
+#define TAG(x) r128_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl/t_vb_rendertmp.h"
+
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+#define POINT_FALLBACK (DD_POINT_SMOOTH)
+#define LINE_FALLBACK (DD_LINE_STIPPLE|DD_LINE_SMOOTH)
+#define TRI_FALLBACK (DD_TRI_SMOOTH)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)
+#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
+#define _R128_NEW_RENDER_STATE (ANY_FALLBACK_FLAGS | ANY_RASTER_FLAGS)
+
+static void r128ChooseRenderState(GLcontext *ctx)
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ if (flags & (ANY_RASTER_FLAGS|ANY_FALLBACK_FLAGS)) {
+ rmesa->draw_point = r128_point;
+ rmesa->draw_line = r128_line;
+ rmesa->draw_tri = r128_triangle;
+
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R128_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= R128_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= R128_UNFILLED_BIT;
+ }
+
+ /* Hook in fallbacks for specific primitives.
+ */
+ if (flags & (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)) {
+ if (flags & POINT_FALLBACK) rmesa->draw_point = r128_fallback_point;
+ if (flags & LINE_FALLBACK) rmesa->draw_line = r128_fallback_line;
+ if (flags & TRI_FALLBACK) rmesa->draw_tri = r128_fallback_tri;
+ index |= R128_FALLBACK_BIT;
+ }
+ }
+
+ if (index != rmesa->RenderIndex) {
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.ClippedLine = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = r128_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = r128_render_tab_elts;
+ tnl->Driver.Render.ClippedPolygon = r128_fast_clipped_poly;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon;
+ }
+
+ rmesa->RenderIndex = index;
+ }
+}
+
+/**********************************************************************/
+/* Validate state at pipeline start */
+/**********************************************************************/
+
+static void r128RunPipeline( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ if (rmesa->new_state || rmesa->NewGLState & _NEW_TEXTURE)
+ r128DDUpdateHWState( ctx );
+
+ if (!rmesa->Fallback && rmesa->NewGLState) {
+ if (rmesa->NewGLState & _R128_NEW_RENDER_STATE)
+ r128ChooseRenderState( ctx );
+
+ rmesa->NewGLState = 0;
+ }
+
+ _tnl_run_pipeline( ctx );
+}
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+/* 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 r128RasterPrimitive( GLcontext *ctx, GLuint hwprim )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+
+ rmesa->setup.dp_gui_master_cntl_c &= ~R128_GMC_BRUSH_NONE;
+
+ if ( ctx->Polygon.StippleFlag && hwprim == GL_TRIANGLES ) {
+ rmesa->setup.dp_gui_master_cntl_c |= R128_GMC_BRUSH_32x32_MONO_FG_LA;
+ }
+ else {
+ rmesa->setup.dp_gui_master_cntl_c |= R128_GMC_BRUSH_SOLID_COLOR;
+ }
+
+ rmesa->new_state |= R128_NEW_CONTEXT;
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+
+ if (rmesa->hw_primitive != hwprim) {
+ FLUSH_BATCH( rmesa );
+ rmesa->hw_primitive = hwprim;
+ }
+}
+
+static void r128RenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLuint hw = hw_prim[prim];
+ rmesa->render_primitive = prim;
+ if (prim >= GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ return;
+ r128RasterPrimitive( ctx, hw );
+}
+
+#define EMIT_ATTR( ATTR, STYLE, VF, SIZE ) \
+do { \
+ rmesa->vertex_attrs[rmesa->vertex_attr_count].attrib = (ATTR); \
+ rmesa->vertex_attrs[rmesa->vertex_attr_count].format = (STYLE); \
+ rmesa->vertex_attr_count++; \
+ vc_frmt |= (VF); \
+ offset += (SIZE); \
+} while (0)
+
+#define EMIT_PAD( SIZE ) \
+do { \
+ rmesa->vertex_attrs[rmesa->vertex_attr_count].attrib = 0; \
+ rmesa->vertex_attrs[rmesa->vertex_attr_count].format = EMIT_PAD; \
+ rmesa->vertex_attrs[rmesa->vertex_attr_count].offset = (SIZE); \
+ rmesa->vertex_attr_count++; \
+ offset += (SIZE); \
+} while (0)
+
+static void r128RenderStart( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint index = tnl->render_inputs;
+ GLuint vc_frmt = 0;
+ GLboolean fallback_projtex = GL_FALSE;
+ GLuint offset = 0;
+
+ /* Important: */
+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
+ rmesa->vertex_attr_count = 0;
+ rmesa->specoffset = 0;
+
+ /* EMIT_ATTR's must be in order as they tell t_vertex.c how to
+ * build up a hardware vertex.
+ */
+ if ( index & _TNL_BITS_TEX_ANY )
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, R128_CCE_VC_FRMT_RHW, 16 );
+ else
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, 0, 12 );
+
+ rmesa->coloroffset = offset;
+#if MESA_LITTLE_ENDIAN
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA,
+ R128_CCE_VC_FRMT_DIFFUSE_ARGB, 4 );
+#else
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_ARGB,
+ R128_CCE_VC_FRMT_DIFFUSE_ARGB, 4 );
+#endif
+
+ if ( index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG) ) {
+#if MESA_LITTLE_ENDIAN
+ if ( index & _TNL_BIT_COLOR1) {
+ rmesa->specoffset = offset;
+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_RGB,
+ R128_CCE_VC_FRMT_SPEC_FRGB, 3 );
+ } else
+ EMIT_PAD( 3 );
+
+ if (index & _TNL_BIT_FOG)
+ EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, R128_CCE_VC_FRMT_SPEC_FRGB,
+ 1 );
+ else
+ EMIT_PAD( 1 );
+#else
+ if (index & _TNL_BIT_FOG)
+ EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, R128_CCE_VC_FRMT_SPEC_FRGB,
+ 1 );
+ else
+ EMIT_PAD( 1 );
+
+ if ( index & _TNL_BIT_COLOR1) {
+ rmesa->specoffset = offset;
+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_RGB,
+ R128_CCE_VC_FRMT_SPEC_FRGB, 3 );
+ } else
+ EMIT_PAD( 3 );
+#endif
+ }
+
+ if ( index & _TNL_BIT_TEX(rmesa->tmu_source[0]) ) {
+ if ( VB->TexCoordPtr[rmesa->tmu_source[0]]->size > 2 )
+ fallback_projtex = GL_TRUE;
+ EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F, R128_CCE_VC_FRMT_S_T, 8 );
+ }
+ if ( index & _TNL_BIT_TEX(rmesa->tmu_source[1]) ) {
+ if ( VB->TexCoordPtr[rmesa->tmu_source[1]]->size > 2 )
+ fallback_projtex = GL_TRUE;
+ EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_2F, R128_CCE_VC_FRMT_S2_T2, 8 );
+ }
+
+ /* projective textures are not supported by the hardware */
+ FALLBACK( rmesa, R128_FALLBACK_PROJTEX, fallback_projtex );
+
+ /* Only need to change the vertex emit code if there has been a
+ * statechange to a TNL index.
+ */
+ if ( index != rmesa->tnl_state ) {
+ FLUSH_BATCH( rmesa );
+ rmesa->dirty |= R128_UPLOAD_CONTEXT;
+
+ rmesa->vertex_size =
+ _tnl_install_attrs( ctx,
+ rmesa->vertex_attrs,
+ rmesa->vertex_attr_count,
+ rmesa->hw_viewport, 0 );
+ rmesa->vertex_size >>= 2;
+
+ rmesa->vertex_format = vc_frmt;
+ }
+}
+
+static void r128RenderFinish( GLcontext *ctx )
+{
+ if (R128_CONTEXT(ctx)->RenderIndex & R128_FALLBACK_BIT)
+ _swrast_flush( ctx );
+}
+
+
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+
+static const char * const fallbackStrings[] = {
+ "Texture mode",
+ "glDrawBuffer(GL_FRONT_AND_BACK)",
+ "glReadBuffer",
+ "glEnable(GL_STENCIL) without hw stencil buffer",
+ "glRenderMode(selection or feedback)",
+ "glLogicOp (mode != GL_COPY)",
+ "GL_SEPARATE_SPECULAR_COLOR",
+ "glBlendEquation(mode != ADD)",
+ "glBlendFunc",
+ "Projective texture",
+ "Rasterization disable",
+};
+
+
+static const char *getFallbackString(GLuint bit)
+{
+ int i = 0;
+ while (bit > 1) {
+ i++;
+ bit >>= 1;
+ }
+ return fallbackStrings[i];
+}
+
+void r128Fallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ GLuint oldfallback = rmesa->Fallback;
+
+ if (mode) {
+ rmesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ FLUSH_BATCH( rmesa );
+ _swsetup_Wakeup( ctx );
+ rmesa->RenderIndex = ~0;
+ if ( R128_DEBUG & DEBUG_VERBOSE_FALL ) {
+ fprintf(stderr, "R128 begin rasterization fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ }
+ }
+ else {
+ rmesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = r128RenderStart;
+ tnl->Driver.Render.PrimitiveNotify = r128RenderPrimitive;
+ tnl->Driver.Render.Finish = r128RenderFinish;
+
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+
+ _tnl_invalidate_vertex_state( ctx, ~0 );
+ _tnl_invalidate_vertices( ctx, ~0 );
+ _tnl_install_attrs( ctx,
+ rmesa->vertex_attrs,
+ rmesa->vertex_attr_count,
+ rmesa->hw_viewport, 0 );
+
+ rmesa->NewGLState |= _R128_NEW_RENDER_STATE;
+ if ( R128_DEBUG & DEBUG_VERBOSE_FALL ) {
+ fprintf(stderr, "R128 end rasterization fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ }
+ }
+}
+
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+void r128InitTriFuncs( GLcontext *ctx )
+{
+ r128ContextPtr rmesa = R128_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+ }
+
+ tnl->Driver.RunPipeline = r128RunPipeline;
+ tnl->Driver.Render.Start = r128RenderStart;
+ tnl->Driver.Render.Finish = r128RenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = r128RenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+
+ _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
+ (6 + 2 * ctx->Const.MaxTextureUnits) * sizeof(GLfloat) );
+ rmesa->verts = (char *)tnl->clipspace.vertex_buf;
+ rmesa->tnl_state = -1;
+
+ rmesa->NewGLState |= _R128_NEW_RENDER_STATE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_tris.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_tris.h
new file mode 100644
index 000000000..755d3320b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/r128_tris.h
@@ -0,0 +1,48 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tris.h,v 1.8 2002/10/30 12:51:43 alanh Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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
+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, VA LINUX SYSTEMS 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ *
+ */
+
+#ifndef __R128_TRIS_H__
+#define __R128_TRIS_H__
+
+#include "mtypes.h"
+
+extern void r128InitTriFuncs( GLcontext *ctx );
+
+
+extern void r128Fallback( GLcontext *ctx, GLuint bit, GLboolean mode );
+#define FALLBACK( rmesa, bit, mode ) r128Fallback( rmesa->glCtx, bit, mode )
+
+
+#endif /* __R128_TRIS_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/pci_ids.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/pci_ids.h
new file mode 100644
index 000000000..fe8b08787
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/pci_ids.h
@@ -0,0 +1,57 @@
+/* Rage128 M3 */
+#define PCI_DEVICE_ID_ATI_RAGE128_LE 0x4c45
+#define PCI_DEVICE_ID_ATI_RAGE128_LF 0x4c46
+/* Rage128 M4 */
+#define PCI_DEVICE_ID_ATI_RAGE128_MF 0x4d46
+#define PCI_DEVICE_ID_ATI_RAGE128_ML 0x4d4c
+/* Rage128 Pro GL */
+#define PCI_DEVICE_ID_ATI_RAGE128_PA 0x5041
+#define PCI_DEVICE_ID_ATI_RAGE128_PB 0x5042
+#define PCI_DEVICE_ID_ATI_RAGE128_PC 0x5043
+#define PCI_DEVICE_ID_ATI_RAGE128_PD 0x5044
+#define PCI_DEVICE_ID_ATI_RAGE128_PE 0x5045
+#define PCI_DEVICE_ID_ATI_RAGE128_PF 0x5046
+/* Rage128 Pro VR */
+#define PCI_DEVICE_ID_ATI_RAGE128_PG 0x5047
+#define PCI_DEVICE_ID_ATI_RAGE128_PH 0x5048
+#define PCI_DEVICE_ID_ATI_RAGE128_PI 0x5049
+#define PCI_DEVICE_ID_ATI_RAGE128_PJ 0x504A
+#define PCI_DEVICE_ID_ATI_RAGE128_PK 0x504B
+#define PCI_DEVICE_ID_ATI_RAGE128_PL 0x504C
+#define PCI_DEVICE_ID_ATI_RAGE128_PM 0x504D
+#define PCI_DEVICE_ID_ATI_RAGE128_PN 0x504E
+#define PCI_DEVICE_ID_ATI_RAGE128_PO 0x504F
+#define PCI_DEVICE_ID_ATI_RAGE128_PP 0x5050
+#define PCI_DEVICE_ID_ATI_RAGE128_PQ 0x5051
+#define PCI_DEVICE_ID_ATI_RAGE128_PR 0x5052
+#define PCI_DEVICE_ID_ATI_RAGE128_TR 0x5452
+#define PCI_DEVICE_ID_ATI_RAGE128_PS 0x5053
+#define PCI_DEVICE_ID_ATI_RAGE128_PT 0x5054
+#define PCI_DEVICE_ID_ATI_RAGE128_PU 0x5055
+#define PCI_DEVICE_ID_ATI_RAGE128_PV 0x5056
+#define PCI_DEVICE_ID_ATI_RAGE128_PW 0x5057
+#define PCI_DEVICE_ID_ATI_RAGE128_PX 0x5058
+/* Rage128 GL */
+#define PCI_DEVICE_ID_ATI_RAGE128_RE 0x5245
+#define PCI_DEVICE_ID_ATI_RAGE128_RF 0x5246
+/* Rage128 VR */
+#define PCI_DEVICE_ID_ATI_RAGE128_RE 0x5245
+#define PCI_DEVICE_ID_ATI_RAGE128_RF 0x5246
+#define PCI_DEVICE_ID_ATI_RAGE128_RG 0x5247
+#define PCI_DEVICE_ID_ATI_RAGE128_RK 0x524b
+#define PCI_DEVICE_ID_ATI_RAGE128_RL 0x524c
+#define PCI_DEVICE_ID_ATI_RAGE128_SE 0x5345
+#define PCI_DEVICE_ID_ATI_RAGE128_SF 0x5346
+#define PCI_DEVICE_ID_ATI_RAGE128_SG 0x5347
+#define PCI_DEVICE_ID_ATI_RAGE128_SH 0x5348
+#define PCI_DEVICE_ID_ATI_RAGE128_SK 0x534b
+#define PCI_DEVICE_ID_ATI_RAGE128_SL 0x534c
+#define PCI_DEVICE_ID_ATI_RAGE128_SM 0x534d
+#define PCI_DEVICE_ID_ATI_RAGE128_SN 0x534e
+/* Rage128 Pro Ultra */
+#define PCI_DEVICE_ID_ATI_RAGE128_TF 0x5446
+#define PCI_DEVICE_ID_ATI_RAGE128_TL 0x544C
+#define PCI_DEVICE_ID_ATI_RAGE128_TR 0x5452
+#define PCI_DEVICE_ID_ATI_RAGE128_TS 0x5453
+#define PCI_DEVICE_ID_ATI_RAGE128_TT 0x5454
+#define PCI_DEVICE_ID_ATI_RAGE128_TU 0x5455
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128.h
new file mode 100644
index 000000000..ce98b1b91
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128.h
@@ -0,0 +1,465 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h,v 1.24 2002/12/16 16:19:10 dawes Exp $ */
+/*
+ * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario,
+ * Precision Insight, Inc., Cedar Park, Texas, and
+ * VA Linux Systems Inc., Fremont, 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 on 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX
+ * SYSTEMS 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:
+ * Rickard E. Faith <faith@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ *
+ */
+
+#ifndef _R128_H_
+#define _R128_H_
+
+#include "dri_util.h"
+
+#define R128_DEBUG 0 /* Turn off debugging output */
+#define R128_IDLE_RETRY 32 /* Fall out of idle loops after this count */
+#define R128_TIMEOUT 2000000 /* Fall out of wait loops after this count */
+#define R128_MMIOSIZE 0x4000
+
+#define R128_VBIOS_SIZE 0x00010000
+
+#if R128_DEBUG
+#define R128TRACE(x) \
+ do { \
+ ErrorF("(**) %s(%d): ", R128_NAME, pScrn->scrnIndex); \
+ ErrorF x; \
+ } while (0);
+#else
+#define R128TRACE(x)
+#endif
+
+
+/* Other macros */
+#define R128_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
+#define R128_ALIGN(x,bytes) (((x) + ((bytes) - 1)) & ~((bytes) - 1))
+#define R128PTR(pScrn) ((R128InfoPtr)(pScrn)->driverPrivate)
+
+/**
+ * \brief Chip families.
+ */
+typedef enum {
+ CHIP_FAMILY_UNKNOWN,
+ CHIP_FAMILY_R128_PCI,
+ CHIP_FAMILY_R128_AGP,
+} R128ChipFamily;
+
+typedef struct { /* All values in XCLKS */
+ int ML; /* Memory Read Latency */
+ int MB; /* Memory Burst Length */
+ int Trcd; /* RAS to CAS delay */
+ int Trp; /* RAS percentage */
+ int Twr; /* Write Recovery */
+ int CL; /* CAS Latency */
+ int Tr2w; /* Read to Write Delay */
+ int Rloop; /* Loop Latency */
+ int Rloop_fudge; /* Add to ML to get Rloop */
+ char *name;
+} R128RAMRec, *R128RAMPtr;
+
+typedef struct {
+ /* Common registers */
+ u_int32_t ovr_clr;
+ u_int32_t ovr_wid_left_right;
+ u_int32_t ovr_wid_top_bottom;
+ u_int32_t ov0_scale_cntl;
+ u_int32_t mpp_tb_config;
+ u_int32_t mpp_gp_config;
+ u_int32_t subpic_cntl;
+ u_int32_t viph_control;
+ u_int32_t i2c_cntl_1;
+ u_int32_t gen_int_cntl;
+ u_int32_t cap0_trig_cntl;
+ u_int32_t cap1_trig_cntl;
+ u_int32_t bus_cntl;
+ u_int32_t config_cntl;
+
+ /* Other registers to save for VT switches */
+ u_int32_t dp_datatype;
+ u_int32_t gen_reset_cntl;
+ u_int32_t clock_cntl_index;
+ u_int32_t amcgpio_en_reg;
+ u_int32_t amcgpio_mask;
+
+ /* CRTC registers */
+ u_int32_t crtc_gen_cntl;
+ u_int32_t crtc_ext_cntl;
+ u_int32_t dac_cntl;
+ u_int32_t crtc_h_total_disp;
+ u_int32_t crtc_h_sync_strt_wid;
+ u_int32_t crtc_v_total_disp;
+ u_int32_t crtc_v_sync_strt_wid;
+ u_int32_t crtc_offset;
+ u_int32_t crtc_offset_cntl;
+ u_int32_t crtc_pitch;
+
+ /* CRTC2 registers */
+ u_int32_t crtc2_gen_cntl;
+
+ /* Flat panel registers */
+ u_int32_t fp_crtc_h_total_disp;
+ u_int32_t fp_crtc_v_total_disp;
+ u_int32_t fp_gen_cntl;
+ u_int32_t fp_h_sync_strt_wid;
+ u_int32_t fp_horz_stretch;
+ u_int32_t fp_panel_cntl;
+ u_int32_t fp_v_sync_strt_wid;
+ u_int32_t fp_vert_stretch;
+ u_int32_t lvds_gen_cntl;
+ u_int32_t tmds_crc;
+ u_int32_t tmds_transmitter_cntl;
+
+ /* Computed values for PLL */
+ u_int32_t dot_clock_freq;
+ u_int32_t pll_output_freq;
+ int feedback_div;
+ int post_div;
+
+ /* PLL registers */
+ u_int32_t ppll_ref_div;
+ u_int32_t ppll_div_3;
+ u_int32_t htotal_cntl;
+
+ /* DDA register */
+ u_int32_t dda_config;
+ u_int32_t dda_on_off;
+
+ /* Pallet */
+ GLboolean palette_valid;
+ u_int32_t palette[256];
+} R128SaveRec, *R128SavePtr;
+
+typedef struct {
+ int Chipset;
+ GLboolean Primary;
+
+ GLboolean FBDev;
+
+ unsigned long LinearAddr; /* Frame buffer physical address */
+ unsigned long BIOSAddr; /* BIOS physical address */
+
+ unsigned char *MMIO; /* Map of MMIO region */
+ unsigned char *FB; /* Map of frame buffer */
+
+ u_int32_t MemCntl;
+ u_int32_t BusCntl;
+ unsigned long FbMapSize; /* Size of frame buffer, in bytes */
+ int Flags; /* Saved copy of mode flags */
+
+ /* Computed values for FPs */
+ int PanelXRes;
+ int PanelYRes;
+ int HOverPlus;
+ int HSyncWidth;
+ int HBlank;
+ int VOverPlus;
+ int VSyncWidth;
+ int VBlank;
+ int PanelPwrDly;
+
+ unsigned long cursor_start;
+ unsigned long cursor_end;
+
+ /*
+ * XAAForceTransBlit is used to change the behavior of the XAA
+ * SetupForScreenToScreenCopy function, to make it DGA-friendly.
+ */
+ GLboolean XAAForceTransBlit;
+
+ int fifo_slots; /* Free slots in the FIFO (64 max) */
+ int pix24bpp; /* Depth of pixmap for 24bpp framebuffer */
+ GLboolean dac6bits; /* Use 6 bit DAC? */
+
+ /* Computed values for Rage 128 */
+ int pitch;
+ int datatype;
+ u_int32_t dp_gui_master_cntl;
+
+ /* Saved values for ScreenToScreenCopy */
+ int xdir;
+ int ydir;
+
+ /* ScanlineScreenToScreenColorExpand support */
+ unsigned char *scratch_buffer[1];
+ unsigned char *scratch_save;
+ int scanline_x;
+ int scanline_y;
+ int scanline_w;
+ int scanline_h;
+
+ int scanline_hpass;
+ int scanline_x1clip;
+ int scanline_x2clip;
+ int scanline_rop;
+ int scanline_fg;
+ int scanline_bg;
+
+ int scanline_words;
+ int scanline_direct;
+ int scanline_bpp; /* Only used for ImageWrite */
+
+ drm_context_t drmCtx;
+
+ drmSize registerSize;
+ drm_handle_t registerHandle;
+
+ GLboolean IsPCI; /* Current card is a PCI card */
+ drmSize pciSize;
+ drm_handle_t pciMemHandle;
+ unsigned char *PCI; /* Map */
+
+ GLboolean allowPageFlip; /* Enable 3d page flipping */
+ GLboolean have3DWindows; /* Are there any 3d clients? */
+ int drmMinor;
+
+ drmSize agpSize;
+ drm_handle_t agpMemHandle; /* Handle from drmAgpAlloc */
+ unsigned long agpOffset;
+ unsigned char *AGP; /* Map */
+ int agpMode;
+
+ GLboolean CCEInUse; /* CCE is currently active */
+ int CCEMode; /* CCE mode that server/clients use */
+ int CCEFifoSize; /* Size of the CCE command FIFO */
+ GLboolean CCESecure; /* CCE security enabled */
+ int CCEusecTimeout; /* CCE timeout in usecs */
+
+ /* CCE ring buffer data */
+ unsigned long ringStart; /* Offset into AGP space */
+ drm_handle_t 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 */
+ drm_handle_t ringReadPtrHandle; /* Handle from drmAddMap */
+ drmSize ringReadMapSize; /* Size of map */
+ unsigned char *ringReadPtr; /* Map */
+
+ /* CCE vertex/indirect buffer data */
+ unsigned long bufStart; /* Offset into AGP space */
+ drm_handle_t bufHandle; /* Handle from drmAddMap */
+ drmSize bufMapSize; /* Size of map */
+ int bufSize; /* Size of buffers (in MB) */
+ unsigned char *buf; /* Map */
+ int bufNumBufs; /* Number of buffers */
+ drmBufMapPtr buffers; /* Buffer map */
+
+ /* CCE AGP Texture data */
+ unsigned long agpTexStart; /* Offset into AGP space */
+ drm_handle_t agpTexHandle; /* Handle from drmAddMap */
+ drmSize agpTexMapSize; /* Size of map */
+ int agpTexSize; /* Size of AGP tex space (in MB) */
+ unsigned char *agpTex; /* Map */
+ int log2AGPTexGran;
+
+ /* CCE 2D accleration */
+ drmBufPtr indirectBuffer;
+ int indirectStart;
+
+ /* DRI screen private data */
+ int fbX;
+ int fbY;
+ int backX;
+ int backY;
+ int depthX;
+ int depthY;
+
+ int frontOffset;
+ int frontPitch;
+ int backOffset;
+ int backPitch;
+ int depthOffset;
+ int depthPitch;
+ int spanOffset;
+ int textureOffset;
+ int textureSize;
+ int log2TexGran;
+
+ /* Saved scissor values */
+ u_int32_t sc_left;
+ u_int32_t sc_right;
+ u_int32_t sc_top;
+ u_int32_t sc_bottom;
+
+ u_int32_t re_top_left;
+ u_int32_t re_width_height;
+
+ u_int32_t aux_sc_cntl;
+
+ int irq;
+ u_int32_t gen_int_cntl;
+
+ GLboolean DMAForXv;
+
+} R128InfoRec, *R128InfoPtr;
+
+#define R128WaitForFifo(pScrn, entries) \
+do { \
+ if (info->fifo_slots < entries) R128WaitForFifoFunction(pScrn, entries); \
+ info->fifo_slots -= entries; \
+} while (0)
+
+extern void r128WaitForFifoFunction(const DRIDriverContext *ctx, int entries);
+extern void r128WaitForIdle(const DRIDriverContext *ctx);
+
+extern void r128WaitForVerticalSync(const DRIDriverContext *ctx);
+
+extern GLboolean r128AccelInit(const DRIDriverContext *ctx);
+extern void r128EngineInit(const DRIDriverContext *ctx);
+extern GLboolean r128CursorInit(const DRIDriverContext *ctx);
+extern GLboolean r128DGAInit(const DRIDriverContext *ctx);
+
+extern void r128InitVideo(const DRIDriverContext *ctx);
+
+extern GLboolean r128DRIScreenInit(const DRIDriverContext *ctx);
+extern void r128DRICloseScreen(const DRIDriverContext *ctx);
+extern GLboolean r128DRIFinishScreenInit(const DRIDriverContext *ctx);
+
+#define R128CCE_START(ctx, info) \
+do { \
+ int _ret = drmCommandNone(ctx->drmFD, DRM_R128_CCE_START); \
+ if (_ret) { \
+ fprintf(stderr, \
+ "%s: CCE start %d\n", __FUNCTION__, _ret); \
+ } \
+} while (0)
+
+#define R128CCE_STOP(ctx, info) \
+do { \
+ int _ret = R128CCEStop(ctx); \
+ if (_ret) { \
+ fprintf(stderr, \
+ "%s: CCE stop %d\n", __FUNCTION__, _ret); \
+ } \
+} while (0)
+
+#define R128CCE_RESET(ctx, info) \
+do { \
+ if (info->directRenderingEnabled \
+ && R128CCE_USE_RING_BUFFER(info->CCEMode)) { \
+ int _ret = drmCommandNone(info->drmFD, DRM_R128_CCE_RESET); \
+ if (_ret) { \
+ fprintf(stderr, \
+ "%s: CCE reset %d\n", __FUNCTION__, _ret); \
+ } \
+ } \
+} while (0)
+
+
+#define CCE_PACKET0( reg, n ) \
+ (R128_CCE_PACKET0 | ((n) << 16) | ((reg) >> 2))
+#define CCE_PACKET1( reg0, reg1 ) \
+ (R128_CCE_PACKET1 | (((reg1) >> 2) << 11) | ((reg0) >> 2))
+#define CCE_PACKET2() \
+ (R128_CCE_PACKET2)
+#define CCE_PACKET3( pkt, n ) \
+ (R128_CCE_PACKET3 | (pkt) | ((n) << 16))
+
+
+#define R128_VERBOSE 0
+
+#define RING_LOCALS u_int32_t *__head; int __count;
+
+#define R128CCE_REFRESH(pScrn, info) \
+do { \
+ if ( R128_VERBOSE ) { \
+ fprintf(stderr, "REFRESH( %d ) in %s\n", \
+ !info->CCEInUse , __FUNCTION__ ); \
+ } \
+ if ( !info->CCEInUse ) { \
+ R128CCEWaitForIdle(pScrn); \
+ BEGIN_RING( 6 ); \
+ OUT_RING_REG( R128_RE_TOP_LEFT, info->re_top_left ); \
+ OUT_RING_REG( R128_RE_WIDTH_HEIGHT, info->re_width_height ); \
+ OUT_RING_REG( R128_AUX_SC_CNTL, info->aux_sc_cntl ); \
+ ADVANCE_RING(); \
+ info->CCEInUse = TRUE; \
+ } \
+} while (0)
+
+#define BEGIN_RING( n ) do { \
+ if ( R128_VERBOSE ) { \
+ fprintf(stderr, \
+ "BEGIN_RING( %d ) in %s\n", n, __FUNCTION__ ); \
+ } \
+ if ( !info->indirectBuffer ) { \
+ info->indirectBuffer = R128CCEGetBuffer( pScrn ); \
+ info->indirectStart = 0; \
+ } else if ( (info->indirectBuffer->used + 4*(n)) > \
+ info->indirectBuffer->total ) { \
+ R128CCEFlushIndirect( pScrn, 1 ); \
+ } \
+ __head = (pointer)((char *)info->indirectBuffer->address + \
+ info->indirectBuffer->used); \
+ __count = 0; \
+} while (0)
+
+#define ADVANCE_RING() do { \
+ if ( R128_VERBOSE ) { \
+ fprintf(stderr, \
+ "ADVANCE_RING() used: %d+%d=%d/%d\n", \
+ info->indirectBuffer->used - info->indirectStart, \
+ __count * sizeof(u_int32_t), \
+ info->indirectBuffer->used - info->indirectStart + \
+ __count * sizeof(u_int32_t), \
+ info->indirectBuffer->total - info->indirectStart ); \
+ } \
+ info->indirectBuffer->used += __count * (int)sizeof(u_int32_t); \
+} while (0)
+
+#define OUT_RING( x ) do { \
+ if ( R128_VERBOSE ) { \
+ fprintf(stderr, \
+ " OUT_RING( 0x%08x )\n", (unsigned int)(x) ); \
+ } \
+ MMIO_OUT32(&__head[__count++], 0, (x)); \
+} while (0)
+
+#define OUT_RING_REG( reg, val ) \
+do { \
+ OUT_RING( CCE_PACKET0( reg, 0 ) ); \
+ OUT_RING( val ); \
+} while (0)
+
+#define FLUSH_RING() \
+do { \
+ if ( R128_VERBOSE ) \
+ fprintf(stderr, \
+ "FLUSH_RING in %s\n", __FUNCTION__ ); \
+ if ( info->indirectBuffer ) { \
+ R128CCEFlushIndirect( pScrn, 0 ); \
+ } \
+} while (0)
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_dri.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_dri.c
new file mode 100644
index 000000000..5edf1e100
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_dri.c
@@ -0,0 +1,1113 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.c,v 1.28 2003/02/07 20:41:14 martin Exp $ */
+/*
+ * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario,
+ * Precision Insight, Inc., Cedar Park, Texas, and
+ * VA Linux Systems Inc., Fremont, 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 on 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX
+ * SYSTEMS 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 <martin@valinux.com>
+ * Rickard E. Faith <faith@valinux.com>
+ * Daryll Strauss <daryll@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+// Fix this to use kernel pci_ids.h when all of these IDs make it into the kernel
+#include "pci_ids.h"
+
+#include "driver.h"
+#include "drm.h"
+#include "memops.h"
+
+#include "r128.h"
+#include "r128_dri.h"
+#include "r128_macros.h"
+#include "r128_reg.h"
+#include "r128_version.h"
+#include "r128_drm.h"
+
+static size_t r128_drm_page_size;
+
+/* Compute log base 2 of val. */
+static int R128MinBits(int val)
+{
+ int bits;
+
+ if (!val) return 1;
+ for (bits = 0; val; val >>= 1, ++bits);
+ return bits;
+}
+
+/* Initialize the AGP state. Request memory for use in AGP space, and
+ initialize the Rage 128 registers to point to that memory. */
+static GLboolean R128DRIAgpInit(const DRIDriverContext *ctx)
+{
+ unsigned char *R128MMIO = ctx->MMIOAddress;
+ R128InfoPtr info = ctx->driverPrivate;
+ unsigned long mode;
+ unsigned int vendor, device;
+ int ret;
+ unsigned long cntl, chunk;
+ int s, l;
+ int flags;
+ unsigned long agpBase;
+
+ if (drmAgpAcquire(ctx->drmFD) < 0) {
+ fprintf(stderr, "[agp] AGP not available\n");
+ return GL_FALSE;
+ }
+
+ /* Modify the mode if the default mode is
+ not appropriate for this particular
+ combination of graphics card and AGP
+ chipset. */
+
+ mode = drmAgpGetMode(ctx->drmFD); /* Default mode */
+ vendor = drmAgpVendorId(ctx->drmFD);
+ device = drmAgpDeviceId(ctx->drmFD);
+
+ mode &= ~R128_AGP_MODE_MASK;
+ switch (info->agpMode) {
+ case 4: mode |= R128_AGP_4X_MODE;
+ case 2: mode |= R128_AGP_2X_MODE;
+ case 1: default: mode |= R128_AGP_1X_MODE;
+ }
+
+ fprintf(stderr,
+ "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n",
+ mode, vendor, device,
+ 0x1002,
+ info->Chipset);
+
+ if (drmAgpEnable(ctx->drmFD, mode) < 0) {
+ fprintf(stderr, "[agp] AGP not enabled\n");
+ drmAgpRelease(ctx->drmFD);
+ return GL_FALSE;
+ }
+
+ info->agpOffset = 0;
+
+ if ((ret = drmAgpAlloc(ctx->drmFD, info->agpSize*1024*1024, 0, NULL,
+ &info->agpMemHandle)) < 0) {
+ fprintf(stderr, "[agp] Out of memory (%d)\n", ret);
+ drmAgpRelease(ctx->drmFD);
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[agp] %d kB allocated with handle 0x%08x\n",
+ info->agpSize*1024, info->agpMemHandle);
+
+ if (drmAgpBind(ctx->drmFD, info->agpMemHandle, info->agpOffset) < 0) {
+ fprintf(stderr, "[agp] Could not bind\n");
+ drmAgpFree(ctx->drmFD, info->agpMemHandle);
+ drmAgpRelease(ctx->drmFD);
+ return GL_FALSE;
+ }
+
+ /* Initialize the CCE ring buffer data */
+ info->ringStart = info->agpOffset;
+ info->ringMapSize = info->ringSize*1024*1024 + r128_drm_page_size;
+ info->ringSizeLog2QW = R128MinBits(info->ringSize*1024*1024/8) - 1;
+
+ info->ringReadOffset = info->ringStart + info->ringMapSize;
+ info->ringReadMapSize = r128_drm_page_size;
+
+ /* Reserve space for vertex/indirect buffers */
+ info->bufStart = info->ringReadOffset + info->ringReadMapSize;
+ info->bufMapSize = info->bufSize*1024*1024;
+
+ /* Reserve the rest for AGP textures */
+ info->agpTexStart = info->bufStart + info->bufMapSize;
+ s = (info->agpSize*1024*1024 - info->agpTexStart);
+ l = R128MinBits((s-1) / R128_NR_TEX_REGIONS);
+ if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY;
+ info->agpTexMapSize = (s >> l) << l;
+ info->log2AGPTexGran = l;
+
+ if (info->CCESecure) flags = DRM_READ_ONLY;
+ else flags = 0;
+
+ if (drmAddMap(ctx->drmFD, info->ringStart, info->ringMapSize,
+ DRM_AGP, flags, &info->ringHandle) < 0) {
+ fprintf(stderr,
+ "[agp] Could not add ring mapping\n");
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[agp] ring handle = 0x%08x\n", info->ringHandle);
+
+ if (drmMap(ctx->drmFD, info->ringHandle, info->ringMapSize,
+ (drmAddressPtr)&info->ring) < 0) {
+ fprintf(stderr, "[agp] Could not map ring\n");
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[agp] Ring mapped at 0x%08lx\n",
+ (unsigned long)info->ring);
+
+ if (drmAddMap(ctx->drmFD, info->ringReadOffset, info->ringReadMapSize,
+ DRM_AGP, flags, &info->ringReadPtrHandle) < 0) {
+ fprintf(stderr,
+ "[agp] Could not add ring read ptr mapping\n");
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[agp] ring read ptr handle = 0x%08x\n",
+ info->ringReadPtrHandle);
+
+ if (drmMap(ctx->drmFD, info->ringReadPtrHandle, info->ringReadMapSize,
+ (drmAddressPtr)&info->ringReadPtr) < 0) {
+ fprintf(stderr,
+ "[agp] Could not map ring read ptr\n");
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[agp] Ring read ptr mapped at 0x%08lx\n",
+ (unsigned long)info->ringReadPtr);
+
+ if (drmAddMap(ctx->drmFD, info->bufStart, info->bufMapSize,
+ DRM_AGP, 0, &info->bufHandle) < 0) {
+ fprintf(stderr,
+ "[agp] Could not add vertex/indirect buffers mapping\n");
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[agp] vertex/indirect buffers handle = 0x%08lx\n",
+ info->bufHandle);
+
+ if (drmMap(ctx->drmFD, info->bufHandle, info->bufMapSize,
+ (drmAddressPtr)&info->buf) < 0) {
+ fprintf(stderr,
+ "[agp] Could not map vertex/indirect buffers\n");
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[agp] Vertex/indirect buffers mapped at 0x%08lx\n",
+ (unsigned long)info->buf);
+
+ if (drmAddMap(ctx->drmFD, info->agpTexStart, info->agpTexMapSize,
+ DRM_AGP, 0, &info->agpTexHandle) < 0) {
+ fprintf(stderr,
+ "[agp] Could not add AGP texture map mapping\n");
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[agp] AGP texture map handle = 0x%08lx\n",
+ info->agpTexHandle);
+
+ if (drmMap(ctx->drmFD, info->agpTexHandle, info->agpTexMapSize,
+ (drmAddressPtr)&info->agpTex) < 0) {
+ fprintf(stderr,
+ "[agp] Could not map AGP texture map\n");
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[agp] AGP Texture map mapped at 0x%08lx\n",
+ (unsigned long)info->agpTex);
+
+ /* Initialize Rage 128's AGP registers */
+ cntl = INREG(R128_AGP_CNTL);
+ cntl &= ~R128_AGP_APER_SIZE_MASK;
+ switch (info->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:
+ fprintf(stderr,
+ "[agp] Illegal aperture size %d kB\n",
+ info->agpSize*1024);
+ return GL_FALSE;
+ }
+ agpBase = drmAgpBase(ctx->drmFD);
+ OUTREG(R128_AGP_BASE, agpBase);
+ OUTREG(R128_AGP_CNTL, cntl);
+
+ /* Disable Rage 128's PCIGART registers */
+ chunk = INREG(R128_BM_CHUNK_0_VAL);
+ chunk &= ~(R128_BM_PTR_FORCE_TO_PCI |
+ R128_BM_PM4_RD_FORCE_TO_PCI |
+ R128_BM_GLOBAL_FORCE_TO_PCI);
+ OUTREG(R128_BM_CHUNK_0_VAL, chunk);
+
+ OUTREG(R128_PCI_GART_PAGE, 1); /* Ensure AGP GART is used (for now) */
+
+ return GL_TRUE;
+}
+
+static GLboolean R128DRIPciInit(const DRIDriverContext *ctx)
+{
+ R128InfoPtr info = ctx->driverPrivate;
+ unsigned char *R128MMIO = ctx->MMIOAddress;
+ u_int32_t chunk;
+ int ret;
+ int flags;
+
+ info->agpOffset = 0;
+
+ ret = drmScatterGatherAlloc(ctx->drmFD, info->agpSize*1024*1024,
+ &info->pciMemHandle);
+ if (ret < 0) {
+ fprintf(stderr, "[pci] Out of memory (%d)\n", ret);
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[pci] %d kB allocated with handle 0x%08x\n",
+ info->agpSize*1024, info->pciMemHandle);
+
+ /* Initialize the CCE ring buffer data */
+ info->ringStart = info->agpOffset;
+ info->ringMapSize = info->ringSize*1024*1024 + r128_drm_page_size;
+ info->ringSizeLog2QW = R128MinBits(info->ringSize*1024*1024/8) - 1;
+
+ info->ringReadOffset = info->ringStart + info->ringMapSize;
+ info->ringReadMapSize = r128_drm_page_size;
+
+ /* Reserve space for vertex/indirect buffers */
+ info->bufStart = info->ringReadOffset + info->ringReadMapSize;
+ info->bufMapSize = info->bufSize*1024*1024;
+
+ flags = DRM_READ_ONLY | DRM_LOCKED | DRM_KERNEL;
+
+ if (drmAddMap(ctx->drmFD, info->ringStart, info->ringMapSize,
+ DRM_SCATTER_GATHER, flags, &info->ringHandle) < 0) {
+ fprintf(stderr,
+ "[pci] Could not add ring mapping\n");
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[pci] ring handle = 0x%08lx\n", info->ringHandle);
+
+ if (drmMap(ctx->drmFD, info->ringHandle, info->ringMapSize,
+ (drmAddressPtr)&info->ring) < 0) {
+ fprintf(stderr, "[pci] Could not map ring\n");
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[pci] Ring mapped at 0x%08lx\n",
+ (unsigned long)info->ring);
+ fprintf(stderr,
+ "[pci] Ring contents 0x%08lx\n",
+ *(unsigned long *)info->ring);
+
+ if (drmAddMap(ctx->drmFD, info->ringReadOffset, info->ringReadMapSize,
+ DRM_SCATTER_GATHER, flags, &info->ringReadPtrHandle) < 0) {
+ fprintf(stderr,
+ "[pci] Could not add ring read ptr mapping\n");
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[pci] ring read ptr handle = 0x%08lx\n",
+ info->ringReadPtrHandle);
+
+ if (drmMap(ctx->drmFD, info->ringReadPtrHandle, info->ringReadMapSize,
+ (drmAddressPtr)&info->ringReadPtr) < 0) {
+ fprintf(stderr,
+ "[pci] Could not map ring read ptr\n");
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[pci] Ring read ptr mapped at 0x%08lx\n",
+ (unsigned long)info->ringReadPtr);
+ fprintf(stderr,
+ "[pci] Ring read ptr contents 0x%08lx\n",
+ *(unsigned long *)info->ringReadPtr);
+
+ if (drmAddMap(ctx->drmFD, info->bufStart, info->bufMapSize,
+ DRM_SCATTER_GATHER, 0, &info->bufHandle) < 0) {
+ fprintf(stderr,
+ "[pci] Could not add vertex/indirect buffers mapping\n");
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[pci] vertex/indirect buffers handle = 0x%08lx\n",
+ info->bufHandle);
+
+ if (drmMap(ctx->drmFD, info->bufHandle, info->bufMapSize,
+ (drmAddressPtr)&info->buf) < 0) {
+ fprintf(stderr,
+ "[pci] Could not map vertex/indirect buffers\n");
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[pci] Vertex/indirect buffers mapped at 0x%08lx\n",
+ (unsigned long)info->buf);
+ fprintf(stderr,
+ "[pci] Vertex/indirect buffers contents 0x%08lx\n",
+ *(unsigned long *)info->buf);
+
+ if (!info->IsPCI) {
+ /* This is really an AGP card, force PCI GART mode */
+ chunk = INREG(R128_BM_CHUNK_0_VAL);
+ chunk |= (R128_BM_PTR_FORCE_TO_PCI |
+ R128_BM_PM4_RD_FORCE_TO_PCI |
+ R128_BM_GLOBAL_FORCE_TO_PCI);
+ OUTREG(R128_BM_CHUNK_0_VAL, chunk);
+ OUTREG(R128_PCI_GART_PAGE, 0); /* Ensure PCI GART is used */
+ }
+
+ return GL_TRUE;
+}
+
+/* Add a map for the MMIO registers that will be accessed by any
+ DRI-based clients. */
+static GLboolean R128DRIMapInit(const DRIDriverContext *ctx)
+{
+ R128InfoPtr info = ctx->driverPrivate;
+ int flags;
+
+ if (info->CCESecure) flags = DRM_READ_ONLY;
+ else flags = 0;
+
+ /* Map registers */
+ if (drmAddMap(ctx->drmFD, ctx->MMIOStart, ctx->MMIOSize,
+ DRM_REGISTERS, flags, &info->registerHandle) < 0) {
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[drm] register handle = 0x%08x\n", info->registerHandle);
+
+ return GL_TRUE;
+}
+
+/* Initialize the kernel data structures. */
+static int R128DRIKernelInit(const DRIDriverContext *ctx)
+{
+ R128InfoPtr info = ctx->driverPrivate;
+ drm_r128_init_t drmInfo;
+
+ memset( &drmInfo, 0, sizeof(&drmInfo) );
+
+ drmInfo.func = R128_INIT_CCE;
+ drmInfo.sarea_priv_offset = sizeof(drm_sarea_t);
+ drmInfo.is_pci = info->IsPCI;
+ drmInfo.cce_mode = info->CCEMode;
+ drmInfo.cce_secure = info->CCESecure;
+ drmInfo.ring_size = info->ringSize*1024*1024;
+ drmInfo.usec_timeout = info->CCEusecTimeout;
+
+ drmInfo.fb_bpp = ctx->bpp;
+ drmInfo.depth_bpp = ctx->bpp;
+
+ drmInfo.front_offset = info->frontOffset;
+ drmInfo.front_pitch = info->frontPitch;
+
+ drmInfo.back_offset = info->backOffset;
+ drmInfo.back_pitch = info->backPitch;
+
+ drmInfo.depth_offset = info->depthOffset;
+ drmInfo.depth_pitch = info->depthPitch;
+ drmInfo.span_offset = info->spanOffset;
+
+ drmInfo.fb_offset = info->LinearAddr;
+ drmInfo.mmio_offset = info->registerHandle;
+ drmInfo.ring_offset = info->ringHandle;
+ drmInfo.ring_rptr_offset = info->ringReadPtrHandle;
+ drmInfo.buffers_offset = info->bufHandle;
+ drmInfo.agp_textures_offset = info->agpTexHandle;
+
+ if (drmCommandWrite(ctx->drmFD, DRM_R128_INIT,
+ &drmInfo, sizeof(drmInfo)) < 0)
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
+/* Add a map for the vertex buffers that will be accessed by any
+ DRI-based clients. */
+static GLboolean R128DRIBufInit(const DRIDriverContext *ctx)
+{
+ R128InfoPtr info = ctx->driverPrivate;
+ /* Initialize vertex buffers */
+ if (info->IsPCI) {
+ info->bufNumBufs = drmAddBufs(ctx->drmFD,
+ info->bufMapSize / R128_BUFFER_SIZE,
+ R128_BUFFER_SIZE,
+ DRM_SG_BUFFER,
+ info->bufStart);
+ } else {
+ info->bufNumBufs = drmAddBufs(ctx->drmFD,
+ info->bufMapSize / R128_BUFFER_SIZE,
+ R128_BUFFER_SIZE,
+ DRM_AGP_BUFFER,
+ info->bufStart);
+ }
+ if (info->bufNumBufs <= 0) {
+ fprintf(stderr,
+ "[drm] Could not create vertex/indirect buffers list\n");
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[drm] Added %d %d byte vertex/indirect buffers\n",
+ info->bufNumBufs, R128_BUFFER_SIZE);
+
+ if (!(info->buffers = drmMapBufs(ctx->drmFD))) {
+ fprintf(stderr,
+ "[drm] Failed to map vertex/indirect buffers list\n");
+ return GL_FALSE;
+ }
+ fprintf(stderr,
+ "[drm] Mapped %d vertex/indirect buffers\n",
+ info->buffers->count);
+
+ return GL_TRUE;
+}
+
+static void R128DRIIrqInit(const DRIDriverContext *ctx)
+{
+ R128InfoPtr info = ctx->driverPrivate;
+ unsigned char *R128MMIO = ctx->MMIOAddress;
+
+ if (!info->irq) {
+ info->irq = drmGetInterruptFromBusID(
+ ctx->drmFD,
+ ctx->pciBus,
+ ctx->pciDevice,
+ ctx->pciFunc);
+
+ if((drmCtlInstHandler(ctx->drmFD, info->irq)) != 0) {
+ fprintf(stderr,
+ "[drm] failure adding irq handler, "
+ "there is a device already using that irq\n"
+ "[drm] falling back to irq-free operation\n");
+ info->irq = 0;
+ } else {
+ info->gen_int_cntl = INREG( R128_GEN_INT_CNTL );
+ }
+ }
+
+ if (info->irq)
+ fprintf(stderr,
+ "[drm] dma control initialized, using IRQ %d\n",
+ info->irq);
+}
+
+static int R128CCEStop(const DRIDriverContext *ctx)
+{
+ R128InfoPtr info = ctx->driverPrivate;
+ drm_r128_cce_stop_t stop;
+ int ret, i;
+
+ stop.flush = 1;
+ stop.idle = 1;
+
+ ret = drmCommandWrite( ctx->drmFD, DRM_R128_CCE_STOP,
+ &stop, sizeof(stop) );
+
+ if ( ret == 0 ) {
+ return 0;
+ } else if ( errno != EBUSY ) {
+ return -errno;
+ }
+
+ stop.flush = 0;
+
+ i = 0;
+ do {
+ ret = drmCommandWrite( ctx->drmFD, DRM_R128_CCE_STOP,
+ &stop, sizeof(stop) );
+ } while ( ret && errno == EBUSY && i++ < R128_IDLE_RETRY );
+
+ if ( ret == 0 ) {
+ return 0;
+ } else if ( errno != EBUSY ) {
+ return -errno;
+ }
+
+ stop.idle = 0;
+
+ if ( drmCommandWrite( ctx->drmFD, DRM_R128_CCE_STOP,
+ &stop, sizeof(stop) )) {
+ return -errno;
+ } else {
+ return 0;
+ }
+}
+
+/* Initialize the CCE state, and start the CCE (if used by the X server) */
+static void R128DRICCEInit(const DRIDriverContext *ctx)
+{
+ R128InfoPtr info = ctx->driverPrivate;
+
+ /* Turn on bus mastering */
+ info->BusCntl &= ~R128_BUS_MASTER_DIS;
+
+ /* 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;
+ }
+
+ /* Make sure the CCE is on for the X server */
+ R128CCE_START(ctx, info);
+}
+
+
+static int R128MemoryInit(const DRIDriverContext *ctx)
+{
+ R128InfoPtr info = ctx->driverPrivate;
+ int width_bytes = ctx->shared.virtualWidth * ctx->cpp;
+ int cpp = ctx->cpp;
+ int bufferSize = ((ctx->shared.virtualHeight * width_bytes
+ + R128_BUFFER_ALIGN)
+ & ~R128_BUFFER_ALIGN);
+ int depthSize = ((((ctx->shared.virtualHeight+15) & ~15) * width_bytes
+ + R128_BUFFER_ALIGN)
+ & ~R128_BUFFER_ALIGN);
+ int l;
+
+ info->frontOffset = 0;
+ info->frontPitch = ctx->shared.virtualWidth;
+
+ fprintf(stderr,
+ "Using %d MB AGP aperture\n", info->agpSize);
+ fprintf(stderr,
+ "Using %d MB for the ring buffer\n", info->ringSize);
+ fprintf(stderr,
+ "Using %d MB for vertex/indirect buffers\n", info->bufSize);
+ fprintf(stderr,
+ "Using %d MB for AGP textures\n", info->agpTexSize);
+
+ /* Front, back and depth buffers - everything else texture??
+ */
+ info->textureSize = ctx->shared.fbSize - 2 * bufferSize - depthSize;
+
+ if (info->textureSize < 0)
+ return 0;
+
+ l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS);
+ if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY;
+
+ /* Round the texture size up to the nearest whole number of
+ * texture regions. Again, be greedy about this, don't
+ * round down.
+ */
+ info->log2TexGran = l;
+ info->textureSize = (info->textureSize >> l) << l;
+
+ /* Set a minimum usable local texture heap size. This will fit
+ * two 256x256x32bpp textures.
+ */
+ if (info->textureSize < 512 * 1024) {
+ info->textureOffset = 0;
+ info->textureSize = 0;
+ }
+
+ /* Reserve space for textures */
+ info->textureOffset = ((ctx->shared.fbSize - info->textureSize +
+ R128_BUFFER_ALIGN) &
+ ~R128_BUFFER_ALIGN);
+
+ /* Reserve space for the shared depth
+ * buffer.
+ */
+ info->depthOffset = ((info->textureOffset - depthSize +
+ R128_BUFFER_ALIGN) &
+ ~R128_BUFFER_ALIGN);
+ info->depthPitch = ctx->shared.virtualWidth;
+
+ info->backOffset = ((info->depthOffset - bufferSize +
+ R128_BUFFER_ALIGN) &
+ ~R128_BUFFER_ALIGN);
+ info->backPitch = ctx->shared.virtualWidth;
+
+
+ fprintf(stderr,
+ "Will use back buffer at offset 0x%x\n",
+ info->backOffset);
+ fprintf(stderr,
+ "Will use depth buffer at offset 0x%x\n",
+ info->depthOffset);
+ fprintf(stderr,
+ "Will use %d kb for textures at offset 0x%x\n",
+ info->textureSize/1024, info->textureOffset);
+
+ return 1;
+}
+
+
+/* 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. */
+static GLboolean R128DRIScreenInit(DRIDriverContext *ctx)
+{
+ R128InfoPtr info = ctx->driverPrivate;
+ R128DRIPtr pR128DRI;
+ int err, major, minor, patch;
+ drmVersionPtr version;
+ drm_r128_sarea_t *pSAREAPriv;
+
+ switch (ctx->bpp) {
+ case 8:
+ /* These modes are not supported (yet). */
+ case 15:
+ case 24:
+ fprintf(stderr,
+ "[dri] R128DRIScreenInit failed (depth %d not supported). "
+ "[dri] Disabling DRI.\n", ctx->bpp);
+ return GL_FALSE;
+
+ /* Only 16 and 32 color depths are supports currently. */
+ case 16:
+ case 32:
+ break;
+ }
+ r128_drm_page_size = getpagesize();
+
+ info->registerSize = ctx->MMIOSize;
+ ctx->shared.SAREASize = SAREA_MAX;
+
+ /* Note that drmOpen will try to load the kernel module, if needed. */
+ ctx->drmFD = drmOpen("r128", NULL );
+ if (ctx->drmFD < 0) {
+ fprintf(stderr, "[drm] drmOpen failed\n");
+ return 0;
+ }
+
+ /* Check the r128 DRM version */
+ version = drmGetVersion(ctx->drmFD);
+ if (version) {
+ if (version->version_major != 2 ||
+ version->version_minor < 2) {
+ /* incompatible drm version */
+ fprintf(stderr,
+ "[dri] R128DRIScreenInit failed because of a version mismatch.\n"
+ "[dri] r128.o kernel module version is %d.%d.%d but version 2.2 or greater is needed.\n"
+ "[dri] Disabling the DRI.\n",
+ version->version_major,
+ version->version_minor,
+ version->version_patchlevel);
+ drmFreeVersion(version);
+ return GL_FALSE;
+ }
+ info->drmMinor = version->version_minor;
+ drmFreeVersion(version);
+ }
+
+ if ((err = drmSetBusid(ctx->drmFD, ctx->pciBusID)) < 0) {
+ fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n",
+ ctx->drmFD, ctx->pciBusID, strerror(-err));
+ return 0;
+ }
+
+ if (drmAddMap( ctx->drmFD,
+ 0,
+ ctx->shared.SAREASize,
+ DRM_SHM,
+ DRM_CONTAINS_LOCK,
+ &ctx->shared.hSAREA) < 0)
+ {
+ fprintf(stderr, "[drm] drmAddMap failed\n");
+ return 0;
+ }
+ fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n",
+ ctx->shared.SAREASize, ctx->shared.hSAREA);
+
+ if (drmMap( ctx->drmFD,
+ ctx->shared.hSAREA,
+ ctx->shared.SAREASize,
+ (drmAddressPtr)(&ctx->pSAREA)) < 0)
+ {
+ fprintf(stderr, "[drm] drmMap failed\n");
+ return 0;
+ }
+ memset(ctx->pSAREA, 0, ctx->shared.SAREASize);
+ fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n",
+ ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize);
+
+ /* Need to AddMap the framebuffer and mmio regions here:
+ */
+ if (drmAddMap( ctx->drmFD,
+ (drm_handle_t)ctx->FBStart,
+ ctx->FBSize,
+ DRM_FRAME_BUFFER,
+ 0,
+ &ctx->shared.hFrameBuffer) < 0)
+ {
+ fprintf(stderr, "[drm] drmAddMap framebuffer failed\n");
+ return 0;
+ }
+
+ fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n",
+ ctx->shared.hFrameBuffer);
+
+ if (!R128MemoryInit(ctx))
+ return GL_FALSE;
+
+ /* Initialize AGP */
+ if (!info->IsPCI && !R128DRIAgpInit(ctx)) {
+ info->IsPCI = GL_TRUE;
+ fprintf(stderr,
+ "[agp] AGP failed to initialize -- falling back to PCI mode.\n");
+ fprintf(stderr,
+ "[agp] Make sure you have the agpgart kernel module loaded.\n");
+ }
+
+ /* Initialize PCIGART */
+ if (info->IsPCI && !R128DRIPciInit(ctx)) {
+ return GL_FALSE;
+ }
+
+ /* DRIScreenInit doesn't add all the
+ common mappings. Add additional
+ mappings here. */
+ if (!R128DRIMapInit(ctx)) {
+ return GL_FALSE;
+ }
+
+ /* Create a 'server' context so we can grab the lock for
+ * initialization ioctls.
+ */
+ if ((err = drmCreateContext(ctx->drmFD, &ctx->serverContext)) != 0) {
+ fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err);
+ return 0;
+ }
+
+ DRM_LOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext, 0);
+
+ /* Initialize the kernel data structures */
+ if (!R128DRIKernelInit(ctx)) {
+ return GL_FALSE;
+ }
+
+ /* Initialize the vertex buffers list */
+ if (!R128DRIBufInit(ctx)) {
+ return GL_FALSE;
+ }
+
+ /* Initialize IRQ */
+ R128DRIIrqInit(ctx);
+
+ /* Initialize and start the CCE if required */
+ R128DRICCEInit(ctx);
+
+ /* Quick hack to clear the front & back buffers. Could also use
+ * the clear ioctl to do this, but would need to setup hw state
+ * first.
+ */
+ drimemsetio((char *)ctx->FBAddress + info->frontOffset,
+ 0,
+ info->frontPitch * ctx->cpp * ctx->shared.virtualHeight );
+
+ drimemsetio((char *)ctx->FBAddress + info->backOffset,
+ 0,
+ info->backPitch * ctx->cpp * ctx->shared.virtualHeight );
+
+ pSAREAPriv = (drm_r128_sarea_t *)(((char*)ctx->pSAREA) +
+ sizeof(drm_sarea_t));
+ memset(pSAREAPriv, 0, sizeof(*pSAREAPriv));
+
+ /* This is the struct passed to radeon_dri.so for its initialization */
+ ctx->driverClientMsg = malloc(sizeof(R128DRIRec));
+ ctx->driverClientMsgSize = sizeof(R128DRIRec);
+
+ pR128DRI = (R128DRIPtr)ctx->driverClientMsg;
+ pR128DRI->deviceID = info->Chipset;
+ pR128DRI->width = ctx->shared.virtualWidth;
+ pR128DRI->height = ctx->shared.virtualHeight;
+ pR128DRI->depth = ctx->bpp;
+ pR128DRI->bpp = ctx->bpp;
+
+ pR128DRI->IsPCI = info->IsPCI;
+ pR128DRI->AGPMode = info->agpMode;
+
+ pR128DRI->frontOffset = info->frontOffset;
+ pR128DRI->frontPitch = info->frontPitch;
+ pR128DRI->backOffset = info->backOffset;
+ pR128DRI->backPitch = info->backPitch;
+ pR128DRI->depthOffset = info->depthOffset;
+ pR128DRI->depthPitch = info->depthPitch;
+ pR128DRI->spanOffset = info->spanOffset;
+ pR128DRI->textureOffset = info->textureOffset;
+ pR128DRI->textureSize = info->textureSize;
+ pR128DRI->log2TexGran = info->log2TexGran;
+
+ pR128DRI->registerHandle = info->registerHandle;
+ pR128DRI->registerSize = info->registerSize;
+
+ pR128DRI->agpTexHandle = info->agpTexHandle;
+ pR128DRI->agpTexMapSize = info->agpTexMapSize;
+ pR128DRI->log2AGPTexGran = info->log2AGPTexGran;
+ pR128DRI->agpTexOffset = info->agpTexStart;
+ pR128DRI->sarea_priv_offset = sizeof(drm_sarea_t);
+
+ return GL_TRUE;
+}
+
+/* The screen is being closed, so clean up any state and free any
+ resources used by the DRI. */
+void R128DRICloseScreen(const DRIDriverContext *ctx)
+{
+ R128InfoPtr info = ctx->driverPrivate;
+ drm_r128_init_t drmInfo;
+
+ /* Stop the CCE if it is still in use */
+ R128CCE_STOP(ctx, info);
+
+ if (info->irq) {
+ drmCtlUninstHandler(ctx->drmFD);
+ info->irq = 0;
+ }
+
+ /* De-allocate vertex buffers */
+ if (info->buffers) {
+ drmUnmapBufs(info->buffers);
+ info->buffers = NULL;
+ }
+
+ /* De-allocate all kernel resources */
+ memset(&drmInfo, 0, sizeof(drmInfo));
+ drmInfo.func = R128_CLEANUP_CCE;
+ drmCommandWrite(ctx->drmFD, DRM_R128_INIT,
+ &drmInfo, sizeof(drmInfo));
+
+ /* De-allocate all AGP resources */
+ if (info->agpTex) {
+ drmUnmap(info->agpTex, info->agpTexMapSize);
+ info->agpTex = NULL;
+ }
+ if (info->buf) {
+ drmUnmap(info->buf, info->bufMapSize);
+ info->buf = NULL;
+ }
+ if (info->ringReadPtr) {
+ drmUnmap(info->ringReadPtr, info->ringReadMapSize);
+ info->ringReadPtr = NULL;
+ }
+ if (info->ring) {
+ drmUnmap(info->ring, info->ringMapSize);
+ info->ring = NULL;
+ }
+ if (info->agpMemHandle != DRM_AGP_NO_HANDLE) {
+ drmAgpUnbind(ctx->drmFD, info->agpMemHandle);
+ drmAgpFree(ctx->drmFD, info->agpMemHandle);
+ info->agpMemHandle = 0;
+ drmAgpRelease(ctx->drmFD);
+ }
+ if (info->pciMemHandle) {
+ drmScatterGatherFree(ctx->drmFD, info->pciMemHandle);
+ info->pciMemHandle = 0;
+ }
+}
+
+static GLboolean R128PreInitDRI(const DRIDriverContext *ctx)
+{
+ R128InfoPtr info = ctx->driverPrivate;
+
+ /*info->CCEMode = R128_DEFAULT_CCE_PIO_MODE;*/
+ info->CCEMode = R128_DEFAULT_CCE_BM_MODE;
+ info->CCESecure = GL_TRUE;
+
+ info->agpMode = R128_DEFAULT_AGP_MODE;
+ info->agpSize = R128_DEFAULT_AGP_SIZE;
+ info->ringSize = R128_DEFAULT_RING_SIZE;
+ info->bufSize = R128_DEFAULT_BUFFER_SIZE;
+ info->agpTexSize = R128_DEFAULT_AGP_TEX_SIZE;
+
+ info->CCEusecTimeout = R128_DEFAULT_CCE_TIMEOUT;
+
+ return GL_TRUE;
+}
+
+/**
+ * \brief Initialize the framebuffer device mode
+ *
+ * \param ctx display handle.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Fills in \p info with some default values and some information from \p ctx
+ * and then calls R128ScreenInit() for the screen initialization.
+ *
+ * Before exiting clears the framebuffer memory accessing it directly.
+ */
+static int R128InitFBDev( DRIDriverContext *ctx )
+{
+ R128InfoPtr info = calloc(1, sizeof(*info));
+
+ {
+ int dummy = ctx->shared.virtualWidth;
+
+ switch (ctx->bpp / 8) {
+ case 1: dummy = (ctx->shared.virtualWidth + 127) & ~127; break;
+ case 2: dummy = (ctx->shared.virtualWidth + 31) & ~31; break;
+ case 3:
+ case 4: dummy = (ctx->shared.virtualWidth + 15) & ~15; break;
+ }
+
+ ctx->shared.virtualWidth = dummy;
+ }
+
+ ctx->driverPrivate = (void *)info;
+
+ info->Chipset = ctx->chipset;
+
+ switch (info->Chipset) {
+ case PCI_DEVICE_ID_ATI_RAGE128_LE:
+ case PCI_DEVICE_ID_ATI_RAGE128_RE:
+ case PCI_DEVICE_ID_ATI_RAGE128_RK:
+ case PCI_DEVICE_ID_ATI_RAGE128_PD:
+ case PCI_DEVICE_ID_ATI_RAGE128_PP:
+ case PCI_DEVICE_ID_ATI_RAGE128_PR:
+ /* This is a PCI card */
+ info->IsPCI = GL_TRUE;
+ break;
+ default:
+ /* This is an AGP card */
+ info->IsPCI = GL_FALSE;
+ break;
+ }
+
+ info->frontPitch = ctx->shared.virtualWidth;
+ info->LinearAddr = ctx->FBStart & 0xfc000000;
+
+ if (!R128PreInitDRI(ctx))
+ return 0;
+
+ if (!R128DRIScreenInit(ctx))
+ return 0;
+
+ return 1;
+}
+
+
+/**
+ * \brief The screen is being closed, so clean up any state and free any
+ * resources used by the DRI.
+ *
+ * \param ctx display handle.
+ *
+ * Unmaps the SAREA, closes the DRM device file descriptor and frees the driver
+ * private data.
+ */
+static void R128HaltFBDev( DRIDriverContext *ctx )
+{
+ drmUnmap( ctx->pSAREA, ctx->shared.SAREASize );
+ drmClose(ctx->drmFD);
+
+ if (ctx->driverPrivate) {
+ free(ctx->driverPrivate);
+ ctx->driverPrivate = 0;
+ }
+}
+
+
+/**
+ * \brief Validate the fbdev mode.
+ *
+ * \param ctx display handle.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Saves some registers and returns 1.
+ *
+ * \sa R128PostValidateMode().
+ */
+static int R128ValidateMode( const DRIDriverContext *ctx )
+{
+ return 1;
+}
+
+
+/**
+ * \brief Examine mode returned by fbdev.
+ *
+ * \param ctx display handle.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Restores registers that fbdev has clobbered and returns 1.
+ *
+ * \sa R128ValidateMode().
+ */
+static int R128PostValidateMode( const DRIDriverContext *ctx )
+{
+ return 1;
+}
+
+
+/**
+ * \brief Shutdown the drawing engine.
+ *
+ * \param ctx display handle
+ *
+ * Turns off the command processor engine & restores the graphics card
+ * to a state that fbdev understands.
+ */
+static int R128EngineShutdown( const DRIDriverContext *ctx )
+{
+ return 1;
+}
+
+/**
+ * \brief Restore the drawing engine.
+ *
+ * \param ctx display handle
+ *
+ * Resets the graphics card and sets initial values for several registers of
+ * the card's drawing engine.
+ *
+ * Turns on the R128 command processor engine (i.e., the ringbuffer).
+ */
+static int R128EngineRestore( const DRIDriverContext *ctx )
+{
+ return 1;
+}
+
+
+/**
+ * \brief Exported driver interface for Mini GLX.
+ *
+ * \sa DRIDriverRec.
+ */
+const struct DRIDriverRec __driDriver = {
+ R128ValidateMode,
+ R128PostValidateMode,
+ R128InitFBDev,
+ R128HaltFBDev,
+ R128EngineShutdown,
+ R128EngineRestore,
+ 0,
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_dri.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_dri.h
new file mode 100644
index 000000000..67ade70de
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_dri.h
@@ -0,0 +1,103 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.h,v 1.7 2002/10/30 12:52:12 alanh Exp $ */
+/*
+ * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario,
+ * Precision Insight, Inc., Cedar Park, Texas, and
+ * VA Linux Systems Inc., Fremont, 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 on 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX
+ * SYSTEMS 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 <martin@valinux.com>
+ * Rickard E. Faith <faith@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#ifndef _R128_DRI_
+#define _R128_DRI_
+
+#include "xf86drm.h"
+#include "drm.h"
+
+/* DRI Driver defaults */
+#define R128_DEFAULT_CCE_PIO_MODE R128_PM4_64PIO_64VCBM_64INDBM
+#define R128_DEFAULT_CCE_BM_MODE R128_PM4_64BM_64VCBM_64INDBM
+#define R128_DEFAULT_AGP_MODE 1
+#define R128_DEFAULT_AGP_SIZE 8 /* MB (must be a power of 2 and > 4MB) */
+#define R128_DEFAULT_RING_SIZE 1 /* MB (must be page aligned) */
+#define R128_DEFAULT_BUFFER_SIZE 2 /* MB (must be page aligned) */
+#define R128_DEFAULT_AGP_TEX_SIZE 1 /* MB (must be page aligned) */
+
+#define R128_DEFAULT_CCE_TIMEOUT 10000 /* usecs */
+
+#define R128_AGP_MAX_MODE 4
+#define R128_BUFFER_ALIGN 0x00000fff
+
+#define R128_CARD_TYPE_R128 1
+#define R128_CARD_TYPE_R128_PRO 2
+#define R128_CARD_TYPE_R128_MOBILITY 3
+
+#define R128CCE_USE_RING_BUFFER(m) \
+(((m) == R128_PM4_192BM) || \
+ ((m) == R128_PM4_128BM_64INDBM) || \
+ ((m) == R128_PM4_64BM_128INDBM) || \
+ ((m) == R128_PM4_64BM_64VCBM_64INDBM))
+
+typedef struct {
+ /* DRI screen private data */
+ int deviceID; /* PCI device ID */
+ int width; /* Width in pixels of display */
+ int height; /* Height in scanlines of display */
+ int depth; /* Depth of display (8, 15, 16, 24) */
+ int bpp; /* Bit depth of display (8, 16, 24, 32) */
+
+ int IsPCI; /* Current card is a PCI card */
+ int AGPMode;
+
+ int frontOffset; /* Start of front buffer */
+ int frontPitch;
+ int backOffset; /* Start of shared back buffer */
+ int backPitch;
+ int depthOffset; /* Start of shared depth buffer */
+ int depthPitch;
+ int spanOffset; /* Start of scratch spanline */
+ int textureOffset;/* Start of texture data in frame buffer */
+ int textureSize;
+ int log2TexGran;
+
+ /* MMIO register data */
+ drm_handle_t registerHandle;
+ drmSize registerSize;
+
+ /* CCE AGP Texture data */
+ drm_handle_t agpTexHandle;
+ drmSize agpTexMapSize;
+ int log2AGPTexGran;
+ int agpTexOffset;
+ unsigned int sarea_priv_offset;
+} R128DRIRec, *R128DRIPtr;
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_macros.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_macros.h
new file mode 100644
index 000000000..93b7feb02
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_macros.h
@@ -0,0 +1,135 @@
+/**
+ * \file server/R128_macros.h
+ * \brief Macros for R128 MMIO operation.
+ *
+ * \authors Kevin E. Martin <martin@xfree86.org>
+ * \authors Rickard E. Faith <faith@valinux.com>
+ * \authors Alan Hourihane <alanh@fairlite.demon.co.uk>
+ */
+
+/*
+ * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and
+ * VA Linux Systems Inc., Fremont, 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 on 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS 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.
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/R128_reg.h,v 1.20 2002/10/12 01:38:07 martin Exp $ */
+
+#ifndef _R128_MACROS_H_
+#define _R128_MACROS_H_
+
+
+
+# define MMIO_IN8(base, offset) \
+ *(volatile unsigned char *)(((unsigned char*)(base)) + (offset))
+# define MMIO_IN16(base, offset) \
+ *(volatile unsigned short *)(void *)(((unsigned char*)(base)) + (offset))
+# define MMIO_IN32(base, offset) \
+ *(volatile unsigned int *)(void *)(((unsigned char*)(base)) + (offset))
+# define MMIO_OUT8(base, offset, val) \
+ *(volatile unsigned char *)(((unsigned char*)(base)) + (offset)) = (val)
+# define MMIO_OUT16(base, offset, val) \
+ *(volatile unsigned short *)(void *)(((unsigned char*)(base)) + (offset)) = (val)
+# define MMIO_OUT32(base, offset, val) \
+ *(volatile unsigned int *)(void *)(((unsigned char*)(base)) + (offset)) = (val)
+
+
+ /* Memory mapped register access macros */
+#define INREG8(addr) MMIO_IN8(R128MMIO, addr)
+#define INREG16(addr) MMIO_IN16(R128MMIO, addr)
+#define INREG(addr) MMIO_IN32(R128MMIO, addr)
+#define OUTREG8(addr, val) MMIO_OUT8(R128MMIO, addr, val)
+#define OUTREG16(addr, val) MMIO_OUT16(R128MMIO, addr, val)
+#define OUTREG(addr, val) MMIO_OUT32(R128MMIO, addr, val)
+
+#define ADDRREG(addr) ((volatile GLuint *)(pointer)(R128MMIO + (addr)))
+
+
+#define OUTREGP(addr, val, mask) \
+do { \
+ GLuint tmp = INREG(addr); \
+ tmp &= (mask); \
+ tmp |= (val); \
+ OUTREG(addr, tmp); \
+} while (0)
+
+#define INPLL(dpy, addr) r128INPLL(dpy, addr)
+
+#define OUTPLL(addr, val) \
+do { \
+ OUTREG8(R128_CLOCK_CNTL_INDEX, (((addr) & 0x3f) | \
+ R128_PLL_WR_EN)); \
+ OUTREG(R128_CLOCK_CNTL_DATA, val); \
+} while (0)
+
+#define OUTPLLP(dpy, addr, val, mask) \
+do { \
+ GLuint tmp = INPLL(dpy, addr); \
+ tmp &= (mask); \
+ tmp |= (val); \
+ OUTPLL(addr, tmp); \
+} while (0)
+
+#define OUTPAL_START(idx) \
+do { \
+ OUTREG8(R128_PALETTE_INDEX, (idx)); \
+} while (0)
+
+#define OUTPAL_NEXT(r, g, b) \
+do { \
+ OUTREG(R128_PALETTE_DATA, ((r) << 16) | ((g) << 8) | (b)); \
+} while (0)
+
+#define OUTPAL_NEXT_CARD32(v) \
+do { \
+ OUTREG(R128_PALETTE_DATA, (v & 0x00ffffff)); \
+} while (0)
+
+#define OUTPAL(idx, r, g, b) \
+do { \
+ OUTPAL_START((idx)); \
+ OUTPAL_NEXT((r), (g), (b)); \
+} while (0)
+
+#define INPAL_START(idx) \
+do { \
+ OUTREG(R128_PALETTE_INDEX, (idx) << 16); \
+} while (0)
+
+#define INPAL_NEXT() INREG(R128_PALETTE_DATA)
+
+#define PAL_SELECT(idx) \
+do { \
+ if (!idx) { \
+ OUTREG(R128_DAC_CNTL2, INREG(R128_DAC_CNTL2) & \
+ (GLuint)~R128_DAC2_PALETTE_ACC_CTL); \
+ } else { \
+ OUTREG(R128_DAC_CNTL2, INREG(R128_DAC_CNTL2) | \
+ R128_DAC2_PALETTE_ACC_CTL); \
+ } \
+} while (0)
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_reg.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_reg.h
new file mode 100644
index 000000000..00f5041c1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_reg.h
@@ -0,0 +1,1394 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_reg.h,v 1.15 2002/12/16 16:19:11 dawes Exp $ */
+/*
+ * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario,
+ * Precision Insight, Inc., Cedar Park, Texas, and
+ * VA Linux Systems Inc., Fremont, 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 on 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX
+ * SYSTEMS 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:
+ * Rickard E. Faith <faith@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ * References:
+ *
+ * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical
+ * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April
+ * 1999.
+ *
+ * RAGE 128 Software Development Manual (Technical Reference Manual P/N
+ * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999.
+ *
+ */
+
+#ifndef _R128_REG_H_
+#define _R128_REG_H_
+
+#define R128_ADAPTER_ID 0x0f2c /* PCI */
+#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_CNTL_B 0x0b44
+#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_4X_MODE 0x04
+# define R128_AGP_MODE_MASK 0x07
+#define R128_AMCGPIO_A_REG 0x01a0
+#define R128_AMCGPIO_EN_REG 0x01a8
+#define R128_AMCGPIO_MASK 0x0194
+#define R128_AMCGPIO_Y_REG 0x01a4
+#define R128_ATTRDR 0x03c1 /* VGA */
+#define R128_ATTRDW 0x03c0 /* VGA */
+#define R128_ATTRX 0x03c0 /* VGA */
+#define R128_AUX_SC_CNTL 0x1660
+# 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_AUX1_SC_BOTTOM 0x1670
+#define R128_AUX1_SC_LEFT 0x1664
+#define R128_AUX1_SC_RIGHT 0x1668
+#define R128_AUX1_SC_TOP 0x166c
+#define R128_AUX2_SC_BOTTOM 0x1680
+#define R128_AUX2_SC_LEFT 0x1674
+#define R128_AUX2_SC_RIGHT 0x1678
+#define R128_AUX2_SC_TOP 0x167c
+#define R128_AUX3_SC_BOTTOM 0x1690
+#define R128_AUX3_SC_LEFT 0x1684
+#define R128_AUX3_SC_RIGHT 0x1688
+#define R128_AUX3_SC_TOP 0x168c
+#define R128_AUX_WINDOW_HORZ_CNTL 0x02d8
+#define R128_AUX_WINDOW_VERT_CNTL 0x02dc
+
+#define R128_BASE_CODE 0x0f0b
+#define R128_BIOS_0_SCRATCH 0x0010
+#define R128_BIOS_1_SCRATCH 0x0014
+#define R128_BIOS_2_SCRATCH 0x0018
+#define R128_BIOS_3_SCRATCH 0x001c
+#define R128_BIOS_4_SCRATCH 0x0020
+#define R128_BIOS_5_SCRATCH 0x0024
+# define R128_BIOS_DISPLAY_FP (1 << 0)
+# define R128_BIOS_DISPLAY_CRT (2 << 0)
+# define R128_BIOS_DISPLAY_FP_CRT (3 << 0)
+#define R128_BIOS_6_SCRATCH 0x0028
+#define R128_BIOS_7_SCRATCH 0x002c
+#define R128_BIOS_ROM 0x0f30 /* PCI */
+#define R128_BIST 0x0f0f /* PCI */
+#define R128_BM_CHUNK_0_VAL 0x0a18
+# define R128_BM_PTR_FORCE_TO_PCI (1 << 21)
+# define R128_BM_PM4_RD_FORCE_TO_PCI (1 << 22)
+# define R128_BM_GLOBAL_FORCE_TO_PCI (1 << 23)
+#define R128_BRUSH_DATA0 0x1480
+#define R128_BRUSH_DATA1 0x1484
+#define R128_BRUSH_DATA10 0x14a8
+#define R128_BRUSH_DATA11 0x14ac
+#define R128_BRUSH_DATA12 0x14b0
+#define R128_BRUSH_DATA13 0x14b4
+#define R128_BRUSH_DATA14 0x14b8
+#define R128_BRUSH_DATA15 0x14bc
+#define R128_BRUSH_DATA16 0x14c0
+#define R128_BRUSH_DATA17 0x14c4
+#define R128_BRUSH_DATA18 0x14c8
+#define R128_BRUSH_DATA19 0x14cc
+#define R128_BRUSH_DATA2 0x1488
+#define R128_BRUSH_DATA20 0x14d0
+#define R128_BRUSH_DATA21 0x14d4
+#define R128_BRUSH_DATA22 0x14d8
+#define R128_BRUSH_DATA23 0x14dc
+#define R128_BRUSH_DATA24 0x14e0
+#define R128_BRUSH_DATA25 0x14e4
+#define R128_BRUSH_DATA26 0x14e8
+#define R128_BRUSH_DATA27 0x14ec
+#define R128_BRUSH_DATA28 0x14f0
+#define R128_BRUSH_DATA29 0x14f4
+#define R128_BRUSH_DATA3 0x148c
+#define R128_BRUSH_DATA30 0x14f8
+#define R128_BRUSH_DATA31 0x14fc
+#define R128_BRUSH_DATA32 0x1500
+#define R128_BRUSH_DATA33 0x1504
+#define R128_BRUSH_DATA34 0x1508
+#define R128_BRUSH_DATA35 0x150c
+#define R128_BRUSH_DATA36 0x1510
+#define R128_BRUSH_DATA37 0x1514
+#define R128_BRUSH_DATA38 0x1518
+#define R128_BRUSH_DATA39 0x151c
+#define R128_BRUSH_DATA4 0x1490
+#define R128_BRUSH_DATA40 0x1520
+#define R128_BRUSH_DATA41 0x1524
+#define R128_BRUSH_DATA42 0x1528
+#define R128_BRUSH_DATA43 0x152c
+#define R128_BRUSH_DATA44 0x1530
+#define R128_BRUSH_DATA45 0x1534
+#define R128_BRUSH_DATA46 0x1538
+#define R128_BRUSH_DATA47 0x153c
+#define R128_BRUSH_DATA48 0x1540
+#define R128_BRUSH_DATA49 0x1544
+#define R128_BRUSH_DATA5 0x1494
+#define R128_BRUSH_DATA50 0x1548
+#define R128_BRUSH_DATA51 0x154c
+#define R128_BRUSH_DATA52 0x1550
+#define R128_BRUSH_DATA53 0x1554
+#define R128_BRUSH_DATA54 0x1558
+#define R128_BRUSH_DATA55 0x155c
+#define R128_BRUSH_DATA56 0x1560
+#define R128_BRUSH_DATA57 0x1564
+#define R128_BRUSH_DATA58 0x1568
+#define R128_BRUSH_DATA59 0x156c
+#define R128_BRUSH_DATA6 0x1498
+#define R128_BRUSH_DATA60 0x1570
+#define R128_BRUSH_DATA61 0x1574
+#define R128_BRUSH_DATA62 0x1578
+#define R128_BRUSH_DATA63 0x157c
+#define R128_BRUSH_DATA7 0x149c
+#define R128_BRUSH_DATA8 0x14a0
+#define R128_BRUSH_DATA9 0x14a4
+#define R128_BRUSH_SCALE 0x1470
+#define R128_BRUSH_Y_X 0x1474
+#define R128_BUS_CNTL 0x0030
+# 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_BUS_WAIT_ON_LOCK_EN (1 << 4)
+
+#define R128_CACHE_CNTL 0x1724
+#define R128_CACHE_LINE 0x0f0c /* PCI */
+#define R128_CAP0_TRIG_CNTL 0x0950 /* ? */
+#define R128_CAP1_TRIG_CNTL 0x09c0 /* ? */
+#define R128_CAPABILITIES_ID 0x0f50 /* PCI */
+#define R128_CAPABILITIES_PTR 0x0f34 /* PCI */
+#define R128_CLK_PIN_CNTL 0x0001 /* PLL */
+#define R128_CLOCK_CNTL_DATA 0x000c
+#define R128_CLOCK_CNTL_INDEX 0x0008
+# define R128_PLL_WR_EN (1 << 7)
+# define R128_PLL_DIV_SEL (3 << 8)
+#define R128_CLR_CMP_CLR_3D 0x1a24
+#define R128_CLR_CMP_CLR_DST 0x15c8
+#define R128_CLR_CMP_CLR_SRC 0x15c4
+#define R128_CLR_CMP_CNTL 0x15c0
+# define R128_SRC_CMP_EQ_COLOR (4 << 0)
+# define R128_SRC_CMP_NEQ_COLOR (5 << 0)
+# define R128_CLR_CMP_SRC_SOURCE (1 << 24)
+#define R128_CLR_CMP_MASK 0x15cc
+# define R128_CLR_CMP_MSK 0xffffffff
+#define R128_CLR_CMP_MASK_3D 0x1A28
+#define R128_COMMAND 0x0f04 /* PCI */
+#define R128_COMPOSITE_SHADOW_ID 0x1a0c
+#define R128_CONFIG_APER_0_BASE 0x0100
+#define R128_CONFIG_APER_1_BASE 0x0104
+#define R128_CONFIG_APER_SIZE 0x0108
+#define R128_CONFIG_BONDS 0x00e8
+#define R128_CONFIG_CNTL 0x00e0
+# define APER_0_BIG_ENDIAN_16BPP_SWAP (1 << 0)
+# define APER_0_BIG_ENDIAN_32BPP_SWAP (2 << 0)
+#define R128_CONFIG_MEMSIZE 0x00f8
+#define R128_CONFIG_MEMSIZE_EMBEDDED 0x0114
+#define R128_CONFIG_REG_1_BASE 0x010c
+#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
+#define R128_CRTC_DEBUG 0x021c
+#define R128_CRTC_EXT_CNTL 0x0054
+# define R128_CRTC_VGA_XOVERSCAN (1 << 0)
+# define R128_VGA_ATI_LINEAR (1 << 3)
+# define R128_XCRT_CNT_EN (1 << 6)
+# 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_FP_OUT_EN (1 << 22)
+# define R128_FP_ACTIVE (1 << 23)
+#define R128_CRTC_EXT_CNTL_DPMS_BYTE 0x0055
+# define R128_CRTC_HSYNC_DIS_BYTE (1 << 0)
+# define R128_CRTC_VSYNC_DIS_BYTE (1 << 1)
+# define R128_CRTC_DISPLAY_DIS_BYTE (1 << 2)
+#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_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_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
+#define R128_CUR_CLR1 0x0270
+#define R128_CUR_HORZ_VERT_OFF 0x0268
+#define R128_CUR_HORZ_VERT_POSN 0x0264
+#define R128_CUR_OFFSET 0x0260
+# define R128_CUR_LOCK (1 << 31)
+
+#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_PALETTE_ACC_CTL (1 << 5)
+# define R128_DAC_8BIT_EN (1 << 8)
+# define R128_DAC_VGA_ADR_EN (1 << 13)
+# define R128_DAC_MASK_ALL (0xff << 24)
+#define R128_DAC_CRC_SIG 0x02cc
+#define R128_DAC_DATA 0x03c9 /* VGA */
+#define R128_DAC_MASK 0x03c6 /* VGA */
+#define R128_DAC_R_INDEX 0x03c7 /* VGA */
+#define R128_DAC_W_INDEX 0x03c8 /* VGA */
+#define R128_DDA_CONFIG 0x02e0
+#define R128_DDA_ON_OFF 0x02e4
+#define R128_DEFAULT_OFFSET 0x16e0
+#define R128_DEFAULT_PITCH 0x16e4
+#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_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
+#define R128_DP_CNTL 0x16c0
+# define R128_DST_X_LEFT_TO_RIGHT (1 << 0)
+# define R128_DST_Y_TOP_TO_BOTTOM (1 << 1)
+#define R128_DP_CNTL_XDIR_YDIR_YMAJOR 0x16d0
+# define R128_DST_Y_MAJOR (1 << 2)
+# 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)
+# define R128_GMC_SRC_CLIPPING (1 << 2)
+# define R128_GMC_DST_CLIPPING (1 << 3)
+# define R128_GMC_BRUSH_DATATYPE_MASK (0x0f << 4)
+# define R128_GMC_BRUSH_8X8_MONO_FG_BG (0 << 4)
+# define R128_GMC_BRUSH_8X8_MONO_FG_LA (1 << 4)
+# define R128_GMC_BRUSH_1X8_MONO_FG_BG (4 << 4)
+# define R128_GMC_BRUSH_1X8_MONO_FG_LA (5 << 4)
+# define R128_GMC_BRUSH_32x1_MONO_FG_BG (6 << 4)
+# define R128_GMC_BRUSH_32x1_MONO_FG_LA (7 << 4)
+# define R128_GMC_BRUSH_32x32_MONO_FG_BG (8 << 4)
+# define R128_GMC_BRUSH_32x32_MONO_FG_LA (9 << 4)
+# 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)
+# define R128_GMC_SRC_DATATYPE_MONO_FG_BG (0 << 12)
+# 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)
+# define R128_DP_SRC_SOURCE_HOST_DATA (3 << 24)
+# define R128_GMC_3D_FCN_EN (1 << 27)
+# define R128_GMC_CLR_CMP_CNTL_DIS (1 << 28)
+# define R128_GMC_AUX_CLIP_DIS (1 << 29)
+# 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
+# define R128_ROP3_SDna 0x00440000
+# define R128_ROP3_S 0x00cc0000
+# define R128_ROP3_DSna 0x00220000
+# define R128_ROP3_D 0x00aa0000
+# define R128_ROP3_DSx 0x00660000
+# define R128_ROP3_DSo 0x00ee0000
+# define R128_ROP3_DSon 0x00110000
+# define R128_ROP3_DSxn 0x00990000
+# define R128_ROP3_Dn 0x00550000
+# define R128_ROP3_SDno 0x00dd0000
+# define R128_ROP3_Sn 0x00330000
+# define R128_ROP3_DSno 0x00bb0000
+# define R128_ROP3_DSan 0x00770000
+# define R128_ROP3_ONE 0x00ff0000
+# define R128_ROP3_DPa 0x00a00000
+# define R128_ROP3_PDna 0x00500000
+# define R128_ROP3_P 0x00f00000
+# define R128_ROP3_DPna 0x000a0000
+# define R128_ROP3_D 0x00aa0000
+# define R128_ROP3_DPx 0x005a0000
+# define R128_ROP3_DPo 0x00fa0000
+# define R128_ROP3_DPon 0x00050000
+# define R128_ROP3_PDxn 0x00a50000
+# define R128_ROP3_PDno 0x00f50000
+# define R128_ROP3_Pn 0x000f0000
+# define R128_ROP3_DPno 0x00af0000
+# define R128_ROP3_DPan 0x005f0000
+
+
+#define R128_DP_GUI_MASTER_CNTL_C 0x1c84
+#define R128_DP_MIX 0x16c8
+#define R128_DP_SRC_BKGD_CLR 0x15dc
+#define R128_DP_SRC_FRGD_CLR 0x15d8
+#define R128_DP_WRITE_MASK 0x16cc
+#define R128_DST_BRES_DEC 0x1630
+#define R128_DST_BRES_ERR 0x1628
+#define R128_DST_BRES_INC 0x162c
+#define R128_DST_BRES_LNTH 0x1634
+#define R128_DST_BRES_LNTH_SUB 0x1638
+#define R128_DST_HEIGHT 0x1410
+#define R128_DST_HEIGHT_WIDTH 0x143c
+#define R128_DST_HEIGHT_WIDTH_8 0x158c
+#define R128_DST_HEIGHT_WIDTH_BW 0x15b4
+#define R128_DST_HEIGHT_Y 0x15a0
+#define R128_DST_OFFSET 0x1404
+#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_TILE (1 << 31)
+#define R128_DST_WIDTH 0x140c
+#define R128_DST_WIDTH_HEIGHT 0x1598
+#define R128_DST_WIDTH_X 0x1588
+#define R128_DST_WIDTH_X_INCY 0x159c
+#define R128_DST_X 0x141c
+#define R128_DST_X_SUB 0x15a4
+#define R128_DST_X_Y 0x1594
+#define R128_DST_Y 0x1420
+#define R128_DST_Y_SUB 0x15a8
+#define R128_DST_Y_X 0x1438
+
+#define R128_EXT_MEM_CNTL 0x0144
+
+#define R128_FCP_CNTL 0x0012 /* PLL */
+#define R128_FLUSH_1 0x1704
+#define R128_FLUSH_2 0x1708
+#define R128_FLUSH_3 0x170c
+#define R128_FLUSH_4 0x1710
+#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_BLANK_DIS (1 << 1)
+# define R128_FP_TDMS_EN (1 << 2)
+# define R128_FP_DETECT_SENSE (1 << 8)
+# define R128_FP_SEL_CRTC2 (1 << 13)
+# define R128_FP_CRTC_DONT_SHADOW_VPAR (1 << 16)
+# define R128_FP_CRTC_DONT_SHADOW_HEND (1 << 17)
+# define R128_FP_CRTC_USE_SHADOW_VEND (1 << 18)
+# define R128_FP_CRTC_USE_SHADOW_ROWCUR (1 << 19)
+# define R128_FP_CRTC_HORZ_DIV2_EN (1 << 20)
+# define R128_FP_CRTC_HOR_CRT_DIV2_DIS (1 << 21)
+# define R128_FP_CRT_SYNC_SEL (1 << 23)
+# 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_AUTO_HORZ_RATIO (0 << 24)
+# 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 (1 << 30)
+# define R128_HORZ_AUTO_RATIO_FIX_EN (1 << 31)
+
+#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_AUTO_RATIO_EN (1 << 26)
+# define R128_VERT_STRETCH_RESERVED 0xf8e00000
+
+#define R128_GEN_INT_CNTL 0x0040
+#define R128_GEN_INT_STATUS 0x0044
+# define R128_VSYNC_INT_AK (1 << 2)
+# define R128_VSYNC_INT (1 << 2)
+#define R128_GEN_RESET_CNTL 0x00f0
+# define R128_SOFT_RESET_GUI (1 << 0)
+# define R128_SOFT_RESET_VCLK (1 << 8)
+# define R128_SOFT_RESET_PCLK (1 << 9)
+# define R128_SOFT_RESET_DISPENG_XCLK (1 << 11)
+# define R128_SOFT_RESET_MEMCTLR_XCLK (1 << 12)
+#define R128_GENENB 0x03c3 /* VGA */
+#define R128_GENFC_RD 0x03ca /* VGA */
+#define R128_GENFC_WT 0x03da /* VGA, 0x03ba */
+#define R128_GENMO_RD 0x03cc /* VGA */
+#define R128_GENMO_WT 0x03c2 /* VGA */
+#define R128_GENS0 0x03c2 /* VGA */
+#define R128_GENS1 0x03da /* VGA, 0x03ba */
+#define R128_GPIO_MONID 0x0068
+# define R128_GPIO_MONID_A_0 (1 << 0)
+# define R128_GPIO_MONID_A_1 (1 << 1)
+# define R128_GPIO_MONID_A_2 (1 << 2)
+# define R128_GPIO_MONID_A_3 (1 << 3)
+# define R128_GPIO_MONID_Y_0 (1 << 8)
+# define R128_GPIO_MONID_Y_1 (1 << 9)
+# define R128_GPIO_MONID_Y_2 (1 << 10)
+# define R128_GPIO_MONID_Y_3 (1 << 11)
+# define R128_GPIO_MONID_EN_0 (1 << 16)
+# define R128_GPIO_MONID_EN_1 (1 << 17)
+# define R128_GPIO_MONID_EN_2 (1 << 18)
+# define R128_GPIO_MONID_EN_3 (1 << 19)
+# define R128_GPIO_MONID_MASK_0 (1 << 24)
+# define R128_GPIO_MONID_MASK_1 (1 << 25)
+# define R128_GPIO_MONID_MASK_2 (1 << 26)
+# define R128_GPIO_MONID_MASK_3 (1 << 27)
+#define R128_GPIO_MONIDB 0x006c
+#define R128_GRPH8_DATA 0x03cf /* VGA */
+#define R128_GRPH8_IDX 0x03ce /* VGA */
+#define R128_GUI_DEBUG0 0x16a0
+#define R128_GUI_DEBUG1 0x16a4
+#define R128_GUI_DEBUG2 0x16a8
+#define R128_GUI_DEBUG3 0x16ac
+#define R128_GUI_DEBUG4 0x16b0
+#define R128_GUI_DEBUG5 0x16b4
+#define R128_GUI_DEBUG6 0x16b8
+#define R128_GUI_PROBE 0x16bc
+#define R128_GUI_SCRATCH_REG0 0x15e0
+#define R128_GUI_SCRATCH_REG1 0x15e4
+#define R128_GUI_SCRATCH_REG2 0x15e8
+#define R128_GUI_SCRATCH_REG3 0x15ec
+#define R128_GUI_SCRATCH_REG4 0x15f0
+#define R128_GUI_SCRATCH_REG5 0x15f4
+#define R128_GUI_STAT 0x1740
+# define R128_GUI_FIFOCNT_MASK 0x0fff
+# define R128_GUI_ACTIVE (1 << 31)
+
+#define R128_HEADER 0x0f0e /* PCI */
+#define R128_HOST_DATA0 0x17c0
+#define R128_HOST_DATA1 0x17c4
+#define R128_HOST_DATA2 0x17c8
+#define R128_HOST_DATA3 0x17cc
+#define R128_HOST_DATA4 0x17d0
+#define R128_HOST_DATA5 0x17d4
+#define R128_HOST_DATA6 0x17d8
+#define R128_HOST_DATA7 0x17dc
+#define R128_HOST_DATA_LAST 0x17e0
+#define R128_HOST_PATH_CNTL 0x0130
+#define R128_HTOTAL_CNTL 0x0009 /* PLL */
+#define R128_HW_DEBUG 0x0128
+#define R128_HW_DEBUG2 0x011c
+
+#define R128_I2C_CNTL_1 0x0094 /* ? */
+#define R128_INTERRUPT_LINE 0x0f3c /* PCI */
+#define R128_INTERRUPT_PIN 0x0f3d /* PCI */
+#define R128_IO_BASE 0x0f14 /* PCI */
+
+#define R128_LATENCY 0x0f0d /* PCI */
+#define R128_LEAD_BRES_DEC 0x1608
+#define R128_LEAD_BRES_ERR 0x1600
+#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_DISPLAY_DIS (1 << 1)
+# define R128_LVDS_EN (1 << 7)
+# define R128_LVDS_DIGON (1 << 18)
+# define R128_LVDS_BLON (1 << 19)
+# define R128_LVDS_SEL_CRTC2 (1 << 23)
+# define R128_HSYNC_DELAY_SHIFT 28
+# define R128_HSYNC_DELAY_MASK (0xf << 28)
+
+#define R128_MAX_LATENCY 0x0f3f /* PCI */
+#define R128_MCLK_CNTL 0x000f /* PLL */
+# define R128_FORCE_GCP (1 << 16)
+# define R128_FORCE_PIPE3D_CP (1 << 17)
+# define R128_FORCE_RCP (1 << 18)
+#define R128_MDGPIO_A_REG 0x01ac
+#define R128_MDGPIO_EN_REG 0x01b0
+#define R128_MDGPIO_MASK 0x0198
+#define R128_MDGPIO_Y_REG 0x01b4
+#define R128_MEM_ADDR_CONFIG 0x0148
+#define R128_MEM_BASE 0x0f10 /* PCI */
+#define R128_MEM_CNTL 0x0140
+#define R128_MEM_INIT_LAT_TIMER 0x0154
+#define R128_MEM_INTF_CNTL 0x014c
+#define R128_MEM_SDRAM_MODE_REG 0x0158
+#define R128_MEM_STR_CNTL 0x0150
+#define R128_MEM_VGA_RP_SEL 0x003c
+#define R128_MEM_VGA_WP_SEL 0x0038
+#define R128_MIN_GRANT 0x0f3e /* PCI */
+#define R128_MM_DATA 0x0004
+#define R128_MM_INDEX 0x0000
+#define R128_MPLL_CNTL 0x000e /* PLL */
+#define R128_MPP_TB_CONFIG 0x01c0 /* ? */
+#define R128_MPP_GP_CONFIG 0x01c8 /* ? */
+
+#define R128_N_VIF_COUNT 0x0248
+
+#define R128_OVR_CLR 0x0230
+#define R128_OVR_WID_LEFT_RIGHT 0x0234
+#define R128_OVR_WID_TOP_BOTTOM 0x0238
+
+/* first overlay unit (there is only one) */
+
+#define R128_OV0_Y_X_START 0x0400
+#define R128_OV0_Y_X_END 0x0404
+#define R128_OV0_EXCLUSIVE_HORZ 0x0408
+# define R128_EXCL_HORZ_START_MASK 0x000000ff
+# define R128_EXCL_HORZ_END_MASK 0x0000ff00
+# define R128_EXCL_HORZ_BACK_PORCH_MASK 0x00ff0000
+# define R128_EXCL_HORZ_EXCLUSIVE_EN 0x80000000
+#define R128_OV0_EXCLUSIVE_VERT 0x040C
+# define R128_EXCL_VERT_START_MASK 0x000003ff
+# define R128_EXCL_VERT_END_MASK 0x03ff0000
+#define R128_OV0_REG_LOAD_CNTL 0x0410
+# define R128_REG_LD_CTL_LOCK 0x00000001L
+# define R128_REG_LD_CTL_VBLANK_DURING_LOCK 0x00000002L
+# define R128_REG_LD_CTL_STALL_GUI_UNTIL_FLIP 0x00000004L
+# define R128_REG_LD_CTL_LOCK_READBACK 0x00000008L
+#define R128_OV0_SCALE_CNTL 0x0420
+# define R128_SCALER_PIX_EXPAND 0x00000001L
+# define R128_SCALER_Y2R_TEMP 0x00000002L
+# define R128_SCALER_HORZ_PICK_NEAREST 0x00000003L
+# define R128_SCALER_VERT_PICK_NEAREST 0x00000004L
+# define R128_SCALER_SIGNED_UV 0x00000010L
+# define R128_SCALER_GAMMA_SEL_MASK 0x00000060L
+# define R128_SCALER_GAMMA_SEL_BRIGHT 0x00000000L
+# define R128_SCALER_GAMMA_SEL_G22 0x00000020L
+# define R128_SCALER_GAMMA_SEL_G18 0x00000040L
+# define R128_SCALER_GAMMA_SEL_G14 0x00000060L
+# define R128_SCALER_COMCORE_SHIFT_UP_ONE 0x00000080L
+# define R128_SCALER_SURFAC_FORMAT 0x00000f00L
+# define R128_SCALER_SOURCE_15BPP 0x00000300L
+# define R128_SCALER_SOURCE_16BPP 0x00000400L
+# define R128_SCALER_SOURCE_32BPP 0x00000600L
+# define R128_SCALER_SOURCE_YUV9 0x00000900L
+# define R128_SCALER_SOURCE_YUV12 0x00000A00L
+# define R128_SCALER_SOURCE_VYUY422 0x00000B00L
+# define R128_SCALER_SOURCE_YVYU422 0x00000C00L
+# define R128_SCALER_SMART_SWITCH 0x00008000L
+# define R128_SCALER_BURST_PER_PLANE 0x00ff0000L
+# define R128_SCALER_DOUBLE_BUFFER 0x01000000L
+# define R128_SCALER_DIS_LIMIT 0x08000000L
+# define R128_SCALER_PRG_LOAD_START 0x10000000L
+# define R128_SCALER_INT_EMU 0x20000000L
+# define R128_SCALER_ENABLE 0x40000000L
+# define R128_SCALER_SOFT_RESET 0x80000000L
+#define R128_OV0_V_INC 0x0424
+#define R128_OV0_P1_V_ACCUM_INIT 0x0428
+# define R128_OV0_P1_MAX_LN_IN_PER_LN_OUT 0x00000003L
+# define R128_OV0_P1_V_ACCUM_INIT_MASK 0x01ff8000L
+#define R128_OV0_P23_V_ACCUM_INIT 0x042C
+#define R128_OV0_P1_BLANK_LINES_AT_TOP 0x0430
+# define R128_P1_BLNK_LN_AT_TOP_M1_MASK 0x00000fffL
+# define R128_P1_ACTIVE_LINES_M1 0x0fff0000L
+#define R128_OV0_P23_BLANK_LINES_AT_TOP 0x0434
+# define R128_P23_BLNK_LN_AT_TOP_M1_MASK 0x000007ffL
+# define R128_P23_ACTIVE_LINES_M1 0x07ff0000L
+#define R128_OV0_VID_BUF0_BASE_ADRS 0x0440
+# define R128_VIF_BUF0_PITCH_SEL 0x00000001L
+# define R128_VIF_BUF0_TILE_ADRS 0x00000002L
+# define R128_VIF_BUF0_BASE_ADRS_MASK 0x03fffff0L
+# define R128_VIF_BUF0_1ST_LINE_LSBS_MASK 0x48000000L
+#define R128_OV0_VID_BUF1_BASE_ADRS 0x0444
+# define R128_VIF_BUF1_PITCH_SEL 0x00000001L
+# define R128_VIF_BUF1_TILE_ADRS 0x00000002L
+# define R128_VIF_BUF1_BASE_ADRS_MASK 0x03fffff0L
+# define R128_VIF_BUF1_1ST_LINE_LSBS_MASK 0x48000000L
+#define R128_OV0_VID_BUF2_BASE_ADRS 0x0448
+# define R128_VIF_BUF2_PITCH_SEL 0x00000001L
+# define R128_VIF_BUF2_TILE_ADRS 0x00000002L
+# define R128_VIF_BUF2_BASE_ADRS_MASK 0x03fffff0L
+# define R128_VIF_BUF2_1ST_LINE_LSBS_MASK 0x48000000L
+#define R128_OV0_VID_BUF3_BASE_ADRS 0x044C
+#define R128_OV0_VID_BUF4_BASE_ADRS 0x0450
+#define R128_OV0_VID_BUF5_BASE_ADRS 0x0454
+#define R128_OV0_VID_BUF_PITCH0_VALUE 0x0460
+#define R128_OV0_VID_BUF_PITCH1_VALUE 0x0464
+#define R128_OV0_AUTO_FLIP_CNTL 0x0470
+#define R128_OV0_DEINTERLACE_PATTERN 0x0474
+#define R128_OV0_H_INC 0x0480
+#define R128_OV0_STEP_BY 0x0484
+#define R128_OV0_P1_H_ACCUM_INIT 0x0488
+#define R128_OV0_P23_H_ACCUM_INIT 0x048C
+#define R128_OV0_P1_X_START_END 0x0494
+#define R128_OV0_P2_X_START_END 0x0498
+#define R128_OV0_P3_X_START_END 0x049C
+#define R128_OV0_FILTER_CNTL 0x04A0
+#define R128_OV0_FOUR_TAP_COEF_0 0x04B0
+#define R128_OV0_FOUR_TAP_COEF_1 0x04B4
+#define R128_OV0_FOUR_TAP_COEF_2 0x04B8
+#define R128_OV0_FOUR_TAP_COEF_3 0x04BC
+#define R128_OV0_FOUR_TAP_COEF_4 0x04C0
+#define R128_OV0_COLOUR_CNTL 0x04E0
+#define R128_OV0_VIDEO_KEY_CLR 0x04E4
+#define R128_OV0_VIDEO_KEY_MSK 0x04E8
+#define R128_OV0_GRAPHICS_KEY_CLR 0x04EC
+#define R128_OV0_GRAPHICS_KEY_MSK 0x04F0
+#define R128_OV0_KEY_CNTL 0x04F4
+# define R128_VIDEO_KEY_FN_MASK 0x00000007L
+# define R128_VIDEO_KEY_FN_FALSE 0x00000000L
+# define R128_VIDEO_KEY_FN_TRUE 0x00000001L
+# define R128_VIDEO_KEY_FN_EQ 0x00000004L
+# define R128_VIDEO_KEY_FN_NE 0x00000005L
+# define R128_GRAPHIC_KEY_FN_MASK 0x00000070L
+# define R128_GRAPHIC_KEY_FN_FALSE 0x00000000L
+# define R128_GRAPHIC_KEY_FN_TRUE 0x00000010L
+# define R128_GRAPHIC_KEY_FN_EQ 0x00000040L
+# define R128_GRAPHIC_KEY_FN_NE 0x00000050L
+# define R128_CMP_MIX_MASK 0x00000100L
+# define R128_CMP_MIX_OR 0x00000000L
+# define R128_CMP_MIX_AND 0x00000100L
+#define R128_OV0_TEST 0x04F8
+
+
+#define R128_PALETTE_DATA 0x00b4
+#define R128_PALETTE_INDEX 0x00b0
+#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_MISC_CNTL 0x0188
+#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
+#define R128_PCI_GART_PAGE 0x017c
+#define R128_PLANE_3D_MASK_C 0x1d44
+#define R128_PLL_TEST_CNTL 0x0013 /* PLL */
+#define R128_PMI_CAP_ID 0x0f5c /* PCI */
+#define R128_PMI_DATA 0x0f63 /* PCI */
+#define R128_PMI_NXT_CAP_PTR 0x0f5d /* PCI */
+#define R128_PMI_PMC_REG 0x0f5e /* PCI */
+#define R128_PMI_PMCSR_REG 0x0f60 /* PCI */
+#define R128_PMI_REGISTER 0x0f5c /* PCI */
+#define R128_PPLL_CNTL 0x0002 /* PLL */
+# define R128_PPLL_RESET (1 << 0)
+# define R128_PPLL_SLEEP (1 << 1)
+# define R128_PPLL_ATOMIC_UPDATE_EN (1 << 16)
+# define R128_PPLL_VGA_ATOMIC_UPDATE_EN (1 << 17)
+#define R128_PPLL_DIV_0 0x0004 /* PLL */
+#define R128_PPLL_DIV_1 0x0005 /* PLL */
+#define R128_PPLL_DIV_2 0x0006 /* PLL */
+#define R128_PPLL_DIV_3 0x0007 /* PLL */
+# define R128_PPLL_FB3_DIV_MASK 0x07ff
+# define R128_PPLL_POST3_DIV_MASK 0x00070000
+#define R128_PPLL_REF_DIV 0x0003 /* PLL */
+# define R128_PPLL_REF_DIV_MASK 0x03ff
+# define R128_PPLL_ATOMIC_UPDATE_R (1 << 15) /* same as _W */
+# define R128_PPLL_ATOMIC_UPDATE_W (1 << 15) /* same as _R */
+#define R128_PWR_MNGMT_CNTL_STATUS 0x0f60 /* PCI */
+#define R128_REG_BASE 0x0f18 /* PCI */
+#define R128_REGPROG_INF 0x0f09 /* PCI */
+#define R128_REVISION_ID 0x0f08 /* PCI */
+
+#define R128_SC_BOTTOM 0x164c
+#define R128_SC_BOTTOM_RIGHT 0x16f0
+#define R128_SC_BOTTOM_RIGHT_C 0x1c8c
+#define R128_SC_LEFT 0x1640
+#define R128_SC_RIGHT 0x1644
+#define R128_SC_TOP 0x1648
+#define R128_SC_TOP_LEFT 0x16ec
+#define R128_SC_TOP_LEFT_C 0x1c88
+#define R128_SEQ8_DATA 0x03c5 /* VGA */
+#define R128_SEQ8_IDX 0x03c4 /* VGA */
+#define R128_SNAPSHOT_F_COUNT 0x0244
+#define R128_SNAPSHOT_VH_COUNTS 0x0240
+#define R128_SNAPSHOT_VIF_COUNT 0x024c
+#define R128_SRC_OFFSET 0x15ac
+#define R128_SRC_PITCH 0x15b0
+#define R128_SRC_PITCH_OFFSET 0x1428
+#define R128_SRC_SC_BOTTOM 0x165c
+#define R128_SRC_SC_BOTTOM_RIGHT 0x16f4
+#define R128_SRC_SC_RIGHT 0x1654
+#define R128_SRC_X 0x1414
+#define R128_SRC_X_Y 0x1590
+#define R128_SRC_Y 0x1418
+#define R128_SRC_Y_X 0x1434
+#define R128_STATUS 0x0f06 /* PCI */
+#define R128_SUBPIC_CNTL 0x0540 /* ? */
+#define R128_SUB_CLASS 0x0f0a /* PCI */
+#define R128_SURFACE_DELAY 0x0b00
+#define R128_SURFACE0_INFO 0x0b0c
+#define R128_SURFACE0_LOWER_BOUND 0x0b04
+#define R128_SURFACE0_UPPER_BOUND 0x0b08
+#define R128_SURFACE1_INFO 0x0b1c
+#define R128_SURFACE1_LOWER_BOUND 0x0b14
+#define R128_SURFACE1_UPPER_BOUND 0x0b18
+#define R128_SURFACE2_INFO 0x0b2c
+#define R128_SURFACE2_LOWER_BOUND 0x0b24
+#define R128_SURFACE2_UPPER_BOUND 0x0b28
+#define R128_SURFACE3_INFO 0x0b3c
+#define R128_SURFACE3_LOWER_BOUND 0x0b34
+#define R128_SURFACE3_UPPER_BOUND 0x0b38
+#define R128_SW_SEMAPHORE 0x013c
+
+#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_TMDS_TRANSMITTER_CNTL 0x02a4
+# define R128_TMDS_PLLEN (1 << 0)
+# define R128_TMDS_PLLRST (1 << 1)
+#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
+#define R128_VGA_DDA_ON_OFF 0x02ec
+#define R128_VID_BUFFER_CONTROL 0x0900
+#define R128_VIDEOMUX_CNTL 0x0190
+#define R128_VIPH_CONTROL 0x01D0 /* ? */
+
+#define R128_WAIT_UNTIL 0x1720
+
+#define R128_X_MPLL_REF_FB_DIV 0x000a /* PLL */
+#define R128_XCLK_CNTL 0x000d /* PLL */
+#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_BUFFER_DL_WPTR_DELAY 0x0718
+# define R128_PRE_WRITE_TIMER_SHIFT 0
+# define R128_PRE_WRITE_LIMIT_SHIFT 23
+#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_COLOR_MASK (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_VC_DEBUG_CONFIG 0x07a4
+#define R128_PM4_VC_STAT 0x07a8
+#define R128_PM4_VC_TIMESTAMP0 0x07b0
+#define R128_PM4_VC_TIMESTAMP1 0x07b4
+#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_SRC_DST_CLAMP (2 << 12)
+# define R128_ALPHA_COMB_SUB_SRC_DST_NCLAMP (3 << 12)
+# define R128_ALPHA_COMB_FCN_MASK (3 << 12)
+# define R128_FOG_VERTEX (0 << 14)
+# define R128_FOG_TABLE (1 << 14)
+# define R128_SIGNED_DST_CLAMP (1 << 15)
+
+# define R128_ALPHA_BLEND_ZERO (0 )
+# define R128_ALPHA_BLEND_ONE (1 )
+# define R128_ALPHA_BLEND_SRCCOLOR (2 )
+# define R128_ALPHA_BLEND_INVSRCCOLOR (3 )
+# define R128_ALPHA_BLEND_SRCALPHA (4 )
+# define R128_ALPHA_BLEND_INVSRCALPHA (5 )
+# define R128_ALPHA_BLEND_DSTALPHA (6 )
+# define R128_ALPHA_BLEND_INVDSTALPHA (7 )
+# define R128_ALPHA_BLEND_DSTCOLOR (8 )
+# define R128_ALPHA_BLEND_INVDSTCOLOR (9 )
+# define R128_ALPHA_BLEND_SAT (10) /* aka SRCALPHASAT */
+# define R128_ALPHA_BLEND_BLEND (11) /* aka BOTHSRCALPHA */
+# define R128_ALPHA_BLEND_INVBLEND (12) /* aka BOTHINVSRCALPHA */
+# define R128_ALPHA_BLEND_MASK (15)
+
+# define R128_ALPHA_BLEND_SRC_SHIFT (16)
+# define R128_ALPHA_BLEND_DST_SHIFT (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_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_SCALE_3D_DATATYPE 0x1a20
+
+#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_TILE (1 << 16)
+#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_LOD_BIAS_MASK (0xff << 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)
+/* Bits [14:12] are the same as R128_SCALE_3D_CNTL */
+/* Bit [15] is unknown */
+/* Bits [26:16] are the same as R128_SCALE_3D_CNTL */
+/* Bits [31:27] are unknown */
+
+#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_YVYU422 (11 << 16)
+# define R128_DATATYPE_VYUY422 (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_CONST_COLOR (0 << 4)
+# define R128_COLOR_FACTOR_NCONST_COLOR (1 << 4)
+# 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_PREV_COLOR (8 << 4)
+# define R128_COLOR_FACTOR_MASK (15 << 4)
+# define R128_COMB_FCN_MSB (1 << 8)
+# 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
+#define R128_TEX_CACHE_STAT_COUNT 0x1974
+
+
+ /* Constants */
+#define R128_AGP_TEX_OFFSET 0x02000000
+
+#define R128_LAST_FRAME_REG R128_GUI_SCRATCH_REG0
+
+ /* 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 0xC0000000
+#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 << 12)
+# 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
+
+/* hmm copyed blindly (no specs) from radeon.h ... */
+#define R128_RE_TOP_LEFT 0x26c0
+# define R128_RE_LEFT_SHIFT 0
+# define R128_RE_TOP_SHIFT 16
+#define R128_RE_WIDTH_HEIGHT 0x1c44
+# define R128_RE_WIDTH_SHIFT 0
+# define R128_RE_HEIGHT_SHIFT 16
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_version.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_version.h
new file mode 100644
index 000000000..589d8d40b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r128/server/r128_version.h
@@ -0,0 +1,60 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128_version.h,v 1.6 2003/01/01 19:16:35 tsi Exp $ */
+/*
+ * Copyright 2000 through 2003 by Marc Aurele La France (TSI @ UQV), tsi@xfree86.org
+ *
+ * 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 Marc Aurele La France not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. Marc Aurele La France makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as-is" without express or implied warranty.
+ *
+ * MARC AURELE LA FRANCE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
+ * EVENT SHALL MARC AURELE LA FRANCE 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.
+ */
+
+#ifndef _R128_VERSION_H_
+#define _R128_VERSION_H_ 1
+
+#undef R128_NAME
+#undef R128_DRIVER_NAME
+#undef R128_VERSION_MAJOR
+#undef R128_VERSION_MINOR
+#undef R128_VERSION_PATCH
+#undef R128_VERSION_CURRENT
+#undef R128_VERSION_EVALUATE
+#undef R128_VERSION_STRINGIFY
+#undef R128_VERSION_NAME
+
+#define R128_NAME "R128"
+#define R128_DRIVER_NAME "r128"
+
+#define R128_VERSION_MAJOR 4
+#define R128_VERSION_MINOR 0
+#define R128_VERSION_PATCH 1
+
+#ifndef R128_VERSION_EXTRA
+#define R128_VERSION_EXTRA ""
+#endif
+
+#define R128_VERSION_CURRENT \
+ ((R128_VERSION_MAJOR << 20) | \
+ (R128_VERSION_MINOR << 10) | \
+ (R128_VERSION_PATCH))
+
+#define R128_VERSION_EVALUATE(__x) #__x
+#define R128_VERSION_STRINGIFY(_x) R128_VERSION_EVALUATE(_x)
+#define R128_VERSION_NAME \
+ R128_VERSION_STRINGIFY(R128_VERSION_MAJOR) "." \
+ R128_VERSION_STRINGIFY(R128_VERSION_MINOR) "." \
+ R128_VERSION_STRINGIFY(R128_VERSION_MINOR) R128_VERSION_EXTRA
+
+#endif /* _R128_VERSION_H_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/Doxyfile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/Doxyfile
new file mode 100644
index 000000000..27b3d0371
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/Doxyfile
@@ -0,0 +1,232 @@
+# Doxyfile 1.3.2-Gideon
+
+#---------------------------------------------------------------------------
+# General configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME = r200
+PROJECT_NUMBER = $VERSION$
+OUTPUT_DIRECTORY =
+OUTPUT_LANGUAGE = English
+USE_WINDOWS_ENCODING = NO
+EXTRACT_ALL = NO
+EXTRACT_PRIVATE = NO
+EXTRACT_STATIC = NO
+EXTRACT_LOCAL_CLASSES = YES
+HIDE_UNDOC_MEMBERS = NO
+HIDE_UNDOC_CLASSES = NO
+HIDE_FRIEND_COMPOUNDS = NO
+HIDE_IN_BODY_DOCS = NO
+BRIEF_MEMBER_DESC = YES
+REPEAT_BRIEF = YES
+ALWAYS_DETAILED_SEC = NO
+INLINE_INHERITED_MEMB = NO
+FULL_PATH_NAMES = NO
+STRIP_FROM_PATH =
+INTERNAL_DOCS = NO
+CASE_SENSE_NAMES = YES
+SHORT_NAMES = NO
+HIDE_SCOPE_NAMES = NO
+SHOW_INCLUDE_FILES = YES
+JAVADOC_AUTOBRIEF = NO
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP = NO
+INHERIT_DOCS = YES
+INLINE_INFO = YES
+SORT_MEMBER_DOCS = YES
+DISTRIBUTE_GROUP_DOC = NO
+TAB_SIZE = 8
+GENERATE_TODOLIST = YES
+GENERATE_TESTLIST = YES
+GENERATE_BUGLIST = YES
+GENERATE_DEPRECATEDLIST= YES
+ALIASES =
+ENABLED_SECTIONS =
+MAX_INITIALIZER_LINES = 30
+OPTIMIZE_OUTPUT_FOR_C = NO
+OPTIMIZE_OUTPUT_JAVA = NO
+SHOW_USED_FILES = YES
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET = NO
+WARNINGS = YES
+WARN_IF_UNDOCUMENTED = YES
+WARN_IF_DOC_ERROR = YES
+WARN_FORMAT = "$file:$line: $text"
+WARN_LOGFILE =
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT = /home/temp/Mesa/src/drv/r200
+FILE_PATTERNS = *.c \
+ *.cc \
+ *.cxx \
+ *.cpp \
+ *.c++ \
+ *.java \
+ *.ii \
+ *.ixx \
+ *.ipp \
+ *.i++ \
+ *.inl \
+ *.h \
+ *.hh \
+ *.hxx \
+ *.hpp \
+ *.h++ \
+ *.idl \
+ *.odl \
+ *.cs \
+ *.C \
+ *.H \
+ *.tlh \
+ *.diff \
+ *.patch \
+ *.moc \
+ *.xpm
+RECURSIVE = yes
+EXCLUDE =
+EXCLUDE_SYMLINKS = NO
+EXCLUDE_PATTERNS =
+EXAMPLE_PATH =
+EXAMPLE_PATTERNS = *
+EXAMPLE_RECURSIVE = NO
+IMAGE_PATH =
+INPUT_FILTER =
+FILTER_SOURCE_FILES = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER = NO
+INLINE_SOURCES = NO
+STRIP_CODE_COMMENTS = YES
+REFERENCED_BY_RELATION = YES
+REFERENCES_RELATION = YES
+VERBATIM_HEADERS = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX = NO
+COLS_IN_ALPHA_INDEX = 5
+IGNORE_PREFIX =
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML = YES
+HTML_OUTPUT = html
+HTML_FILE_EXTENSION = .html
+HTML_HEADER =
+HTML_FOOTER =
+HTML_STYLESHEET =
+HTML_ALIGN_MEMBERS = YES
+GENERATE_HTMLHELP = NO
+CHM_FILE =
+HHC_LOCATION =
+GENERATE_CHI = NO
+BINARY_TOC = NO
+TOC_EXPAND = NO
+DISABLE_INDEX = NO
+ENUM_VALUES_PER_LINE = 4
+GENERATE_TREEVIEW = NO
+TREEVIEW_WIDTH = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX = YES
+LATEX_OUTPUT = latex
+LATEX_CMD_NAME = latex
+MAKEINDEX_CMD_NAME = makeindex
+COMPACT_LATEX = NO
+PAPER_TYPE = a4wide
+EXTRA_PACKAGES =
+LATEX_HEADER =
+PDF_HYPERLINKS = NO
+USE_PDFLATEX = NO
+LATEX_BATCHMODE = NO
+LATEX_HIDE_INDICES = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF = NO
+RTF_OUTPUT = rtf
+COMPACT_RTF = NO
+RTF_HYPERLINKS = NO
+RTF_STYLESHEET_FILE =
+RTF_EXTENSIONS_FILE =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN = NO
+MAN_OUTPUT = man
+MAN_EXTENSION = .3
+MAN_LINKS = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML = yes
+XML_OUTPUT = xml
+XML_SCHEMA =
+XML_DTD =
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD = NO
+PERLMOD_LATEX = NO
+PERLMOD_PRETTY = YES
+PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING = YES
+MACRO_EXPANSION = NO
+EXPAND_ONLY_PREDEF = NO
+SEARCH_INCLUDES = YES
+INCLUDE_PATH =
+INCLUDE_FILE_PATTERNS =
+PREDEFINED =
+EXPAND_AS_DEFINED =
+SKIP_FUNCTION_MACROS = YES
+#---------------------------------------------------------------------------
+# Configuration::addtions related to external references
+#---------------------------------------------------------------------------
+TAGFILES =
+GENERATE_TAGFILE =
+ALLEXTERNALS = NO
+EXTERNAL_GROUPS = YES
+PERL_PATH = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS = YES
+HIDE_UNDOC_RELATIONS = YES
+HAVE_DOT = NO
+CLASS_GRAPH = YES
+COLLABORATION_GRAPH = YES
+UML_LOOK = NO
+TEMPLATE_RELATIONS = NO
+INCLUDE_GRAPH = YES
+INCLUDED_BY_GRAPH = YES
+CALL_GRAPH = NO
+GRAPHICAL_HIERARCHY = YES
+DOT_IMAGE_FORMAT = png
+DOT_PATH =
+DOTFILE_DIRS =
+MAX_DOT_GRAPH_WIDTH = 1024
+MAX_DOT_GRAPH_HEIGHT = 1024
+MAX_DOT_GRAPH_DEPTH = 1000
+GENERATE_LEGEND = YES
+DOT_CLEANUP = YES
+#---------------------------------------------------------------------------
+# Configuration::addtions related to the search engine
+#---------------------------------------------------------------------------
+SEARCHENGINE = NO
+CGI_NAME = search.cgi
+CGI_URL =
+DOC_URL =
+DOC_ABSPATH =
+BIN_ABSPATH = /usr/local/bin/
+EXT_DOC_PATHS =
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/Makefile
new file mode 100644
index 000000000..e4fff5746
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/Makefile
@@ -0,0 +1,62 @@
+# src/mesa/drivers/dri/r200/Makefile
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = r200_dri.so
+
+MINIGLX_SOURCES = server/radeon_dri.c
+
+ifeq ($(USING_EGL), 1)
+EGL_SOURCES = server/radeon_egl.c
+endif
+
+DRIVER_SOURCES = r200_context.c \
+ r200_ioctl.c \
+ r200_lock.c \
+ r200_screen.c \
+ r200_state.c \
+ r200_state_init.c \
+ r200_cmdbuf.c \
+ r200_pixel.c \
+ r200_tex.c \
+ r200_texmem.c \
+ r200_texstate.c \
+ r200_tcl.c \
+ r200_swtcl.c \
+ r200_span.c \
+ r200_maos.c \
+ r200_sanity.c \
+ r200_vtxfmt.c \
+ r200_vtxfmt_c.c \
+ r200_vtxfmt_sse.c \
+ r200_vtxfmt_x86.c \
+ $(EGL_SOURCES)
+
+C_SOURCES = $(COMMON_SOURCES) $(DRIVER_SOURCES)
+
+X86_SOURCES = r200_vtxtmp_x86.S
+
+SYMLINKS = \
+ server/radeon_egl.c \
+ server/radeon_dri.c \
+ server/radeon_dri.h \
+ server/radeon.h \
+ server/radeon_macros.h \
+ server/radeon_reg.h
+
+##### TARGETS #####
+
+
+include ../Makefile.template
+
+#INCLUDES += -I../radeon/server
+
+server:
+ mkdir -p server
+
+$(SYMLINKS): server
+ @[ -e $@ ] || ln -sf ../../radeon/$@ server/
+
+symlinks: $(SYMLINKS)
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_cmdbuf.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_cmdbuf.c
new file mode 100644
index 000000000..2891054b0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_cmdbuf.c
@@ -0,0 +1,423 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_cmdbuf.c,v 1.1 2002/10/30 12:51:51 alanh Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "macros.h"
+#include "context.h"
+#include "swrast/swrast.h"
+#include "simple_list.h"
+
+#include "r200_context.h"
+#include "r200_state.h"
+#include "r200_ioctl.h"
+#include "r200_tcl.h"
+#include "r200_sanity.h"
+#include "radeon_reg.h"
+
+static void print_state_atom( struct r200_state_atom *state )
+{
+ int i;
+
+ fprintf(stderr, "emit %s/%d\n", state->name, state->cmd_size);
+
+ if (0 & R200_DEBUG & DEBUG_VERBOSE)
+ for (i = 0 ; i < state->cmd_size ; i++)
+ fprintf(stderr, "\t%s[%d]: %x\n", state->name, i, state->cmd[i]);
+
+}
+
+/* The state atoms will be emitted in the order they appear in the atom list,
+ * so this step is important.
+ */
+void r200SetUpAtomList( r200ContextPtr rmesa )
+{
+ int i, mtu;
+
+ mtu = rmesa->glCtx->Const.MaxTextureUnits;
+
+ make_empty_list(&rmesa->hw.atomlist);
+ rmesa->hw.atomlist.name = "atom-list";
+
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.ctx );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.set );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.lin );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.msk );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.vpt );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.vtx );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.vap );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.vte );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.msc );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.cst );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.zbs );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.tcl );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.msl );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.tcg );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.grd );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.fog );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.tam );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.tf );
+ for (i = 0; i < mtu; ++i)
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.tex[i] );
+ for (i = 0; i < mtu; ++i)
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.cube[i] );
+ for (i = 0; i < 6; ++i)
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.pix[i] );
+
+ for (i = 0; i < 8; ++i)
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.lit[i] );
+ for (i = 0; i < 3 + mtu; ++i)
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.mat[i] );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.eye );
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.glt );
+ for (i = 0; i < 2; ++i)
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.mtl[i] );
+ for (i = 0; i < 6; ++i)
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.ucp[i] );
+ /* FIXME: is this a good place to insert that atom ? */
+ insert_at_tail( &rmesa->hw.atomlist, &rmesa->hw.prf );
+}
+
+static void r200SaveHwState( r200ContextPtr rmesa )
+{
+ struct r200_state_atom *atom;
+ char * dest = rmesa->backup_store.cmd_buf;
+
+ if (R200_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ rmesa->backup_store.cmd_used = 0;
+
+ foreach( atom, &rmesa->hw.atomlist ) {
+ if ( atom->check( rmesa->glCtx, atom->idx ) ) {
+ int size = atom->cmd_size * 4;
+ memcpy( dest, atom->cmd, size);
+ dest += size;
+ rmesa->backup_store.cmd_used += size;
+ if (R200_DEBUG & DEBUG_STATE)
+ print_state_atom( atom );
+ }
+ }
+
+ assert( rmesa->backup_store.cmd_used <= R200_CMD_BUF_SZ );
+ if (R200_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "Returning to r200EmitState\n");
+}
+
+void r200EmitState( r200ContextPtr rmesa )
+{
+ char *dest;
+ int mtu;
+ struct r200_state_atom *atom;
+
+ if (R200_DEBUG & (DEBUG_STATE|DEBUG_PRIMS))
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (rmesa->save_on_next_emit) {
+ r200SaveHwState(rmesa);
+ rmesa->save_on_next_emit = GL_FALSE;
+ }
+
+ if (!rmesa->hw.is_dirty && !rmesa->hw.all_dirty)
+ return;
+
+ mtu = rmesa->glCtx->Const.MaxTextureUnits;
+
+ /* To avoid going across the entire set of states multiple times, just check
+ * for enough space for the case of emitting all state, and inline the
+ * r200AllocCmdBuf code here without all the checks.
+ */
+ r200EnsureCmdBufSpace( rmesa, rmesa->hw.max_state_size );
+
+ /* we need to calculate dest after EnsureCmdBufSpace
+ as we may flush the buffer - airlied */
+ dest = rmesa->store.cmd_buf + rmesa->store.cmd_used;
+ if (R200_DEBUG & DEBUG_STATE) {
+ foreach( atom, &rmesa->hw.atomlist ) {
+ if ( atom->dirty || rmesa->hw.all_dirty ) {
+ if ( atom->check( rmesa->glCtx, atom->idx ) )
+ print_state_atom( atom );
+ else
+ fprintf(stderr, "skip state %s\n", atom->name);
+ }
+ }
+ }
+
+ foreach( atom, &rmesa->hw.atomlist ) {
+ if ( rmesa->hw.all_dirty )
+ atom->dirty = GL_TRUE;
+ if ( atom->dirty ) {
+ if ( atom->check( rmesa->glCtx, atom->idx ) ) {
+ int size = atom->cmd_size * 4;
+ memcpy( dest, atom->cmd, size);
+ dest += size;
+ rmesa->store.cmd_used += size;
+ atom->dirty = GL_FALSE;
+ }
+ }
+ }
+
+ assert( rmesa->store.cmd_used <= R200_CMD_BUF_SZ );
+
+ rmesa->hw.is_dirty = GL_FALSE;
+ rmesa->hw.all_dirty = GL_FALSE;
+}
+
+/* Fire a section of the retained (indexed_verts) buffer as a regular
+ * primtive.
+ */
+void r200EmitVbufPrim( r200ContextPtr rmesa,
+ GLuint primitive,
+ GLuint vertex_nr )
+{
+ drm_radeon_cmd_header_t *cmd;
+
+ assert(!(primitive & R200_VF_PRIM_WALK_IND));
+
+ r200EmitState( rmesa );
+
+ if (R200_DEBUG & (DEBUG_IOCTL|DEBUG_PRIMS))
+ fprintf(stderr, "%s cmd_used/4: %d prim %x nr %d\n", __FUNCTION__,
+ rmesa->store.cmd_used/4, primitive, vertex_nr);
+
+ cmd = (drm_radeon_cmd_header_t *)r200AllocCmdBuf( rmesa, VBUF_BUFSZ,
+ __FUNCTION__ );
+ cmd[0].i = 0;
+ cmd[0].header.cmd_type = RADEON_CMD_PACKET3_CLIP;
+ cmd[1].i = R200_CP_CMD_3D_DRAW_VBUF_2;
+ cmd[2].i = (primitive |
+ R200_VF_PRIM_WALK_LIST |
+ R200_VF_COLOR_ORDER_RGBA |
+ (vertex_nr << R200_VF_VERTEX_NUMBER_SHIFT));
+}
+
+
+void r200FlushElts( r200ContextPtr rmesa )
+{
+ int *cmd = (int *)(rmesa->store.cmd_buf + rmesa->store.elts_start);
+ int dwords;
+ int nr = (rmesa->store.cmd_used - (rmesa->store.elts_start + 12)) / 2;
+
+ if (R200_DEBUG & (DEBUG_IOCTL|DEBUG_PRIMS))
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ assert( rmesa->dma.flush == r200FlushElts );
+ rmesa->dma.flush = NULL;
+
+ /* Cope with odd number of elts:
+ */
+ rmesa->store.cmd_used = (rmesa->store.cmd_used + 2) & ~2;
+ dwords = (rmesa->store.cmd_used - rmesa->store.elts_start) / 4;
+
+ cmd[1] |= (dwords - 3) << 16;
+ cmd[2] |= nr << R200_VF_VERTEX_NUMBER_SHIFT;
+
+ if (R200_DEBUG & DEBUG_SYNC) {
+ fprintf(stderr, "%s: Syncing\n", __FUNCTION__);
+ r200Finish( rmesa->glCtx );
+ }
+}
+
+
+GLushort *r200AllocEltsOpenEnded( r200ContextPtr rmesa,
+ GLuint primitive,
+ GLuint min_nr )
+{
+ drm_radeon_cmd_header_t *cmd;
+ GLushort *retval;
+
+ if (R200_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s %d prim %x\n", __FUNCTION__, min_nr, primitive);
+
+ assert((primitive & R200_VF_PRIM_WALK_IND));
+
+ r200EmitState( rmesa );
+
+ cmd = (drm_radeon_cmd_header_t *)r200AllocCmdBuf( rmesa, ELTS_BUFSZ(min_nr),
+ __FUNCTION__ );
+ cmd[0].i = 0;
+ cmd[0].header.cmd_type = RADEON_CMD_PACKET3_CLIP;
+ cmd[1].i = R200_CP_CMD_3D_DRAW_INDX_2;
+ cmd[2].i = (primitive |
+ R200_VF_PRIM_WALK_IND |
+ R200_VF_COLOR_ORDER_RGBA);
+
+
+ retval = (GLushort *)(cmd+3);
+
+ if (R200_DEBUG & DEBUG_PRIMS)
+ fprintf(stderr, "%s: header 0x%x prim %x \n",
+ __FUNCTION__,
+ cmd[1].i, primitive);
+
+ assert(!rmesa->dma.flush);
+ rmesa->glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
+ rmesa->dma.flush = r200FlushElts;
+
+ rmesa->store.elts_start = ((char *)cmd) - rmesa->store.cmd_buf;
+
+ return retval;
+}
+
+
+
+void r200EmitVertexAOS( r200ContextPtr rmesa,
+ GLuint vertex_size,
+ GLuint offset )
+{
+ drm_radeon_cmd_header_t *cmd;
+
+ if (R200_DEBUG & (DEBUG_PRIMS|DEBUG_IOCTL))
+ fprintf(stderr, "%s: vertex_size 0x%x offset 0x%x \n",
+ __FUNCTION__, vertex_size, offset);
+
+ cmd = (drm_radeon_cmd_header_t *)r200AllocCmdBuf( rmesa, VERT_AOS_BUFSZ,
+ __FUNCTION__ );
+
+ cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
+ cmd[1].i = R200_CP_CMD_3D_LOAD_VBPNTR | (2 << 16);
+ cmd[2].i = 1;
+ cmd[3].i = vertex_size | (vertex_size << 8);
+ cmd[4].i = offset;
+}
+
+
+void r200EmitAOS( r200ContextPtr rmesa,
+ struct r200_dma_region **component,
+ GLuint nr,
+ GLuint offset )
+{
+ drm_radeon_cmd_header_t *cmd;
+ int sz = AOS_BUFSZ(nr);
+ int i;
+ int *tmp;
+
+ if (R200_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s nr arrays: %d\n", __FUNCTION__, nr);
+
+ cmd = (drm_radeon_cmd_header_t *)r200AllocCmdBuf( rmesa, sz, __FUNCTION__ );
+ cmd[0].i = 0;
+ cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
+ cmd[1].i = R200_CP_CMD_3D_LOAD_VBPNTR | (((sz / sizeof(int)) - 3) << 16);
+ cmd[2].i = nr;
+ tmp = &cmd[0].i;
+ cmd += 3;
+
+ for (i = 0 ; i < nr ; i++) {
+ if (i & 1) {
+ cmd[0].i |= ((component[i]->aos_stride << 24) |
+ (component[i]->aos_size << 16));
+ cmd[2].i = (component[i]->aos_start +
+ offset * component[i]->aos_stride * 4);
+ cmd += 3;
+ }
+ else {
+ cmd[0].i = ((component[i]->aos_stride << 8) |
+ (component[i]->aos_size << 0));
+ cmd[1].i = (component[i]->aos_start +
+ offset * component[i]->aos_stride * 4);
+ }
+ }
+
+ if (R200_DEBUG & DEBUG_VERTS) {
+ fprintf(stderr, "%s:\n", __FUNCTION__);
+ for (i = 0 ; i < sz ; i++)
+ fprintf(stderr, " %d: %x\n", i, tmp[i]);
+ }
+}
+
+void r200EmitBlit( r200ContextPtr rmesa,
+ GLuint color_fmt,
+ GLuint src_pitch,
+ GLuint src_offset,
+ GLuint dst_pitch,
+ GLuint dst_offset,
+ GLint srcx, GLint srcy,
+ GLint dstx, GLint dsty,
+ GLuint w, GLuint h )
+{
+ drm_radeon_cmd_header_t *cmd;
+
+ if (R200_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s src %x/%x %d,%d dst: %x/%x %d,%d sz: %dx%d\n",
+ __FUNCTION__,
+ src_pitch, src_offset, srcx, srcy,
+ dst_pitch, dst_offset, dstx, dsty,
+ w, h);
+
+ assert( (src_pitch & 63) == 0 );
+ assert( (dst_pitch & 63) == 0 );
+ assert( (src_offset & 1023) == 0 );
+ assert( (dst_offset & 1023) == 0 );
+ assert( w < (1<<16) );
+ assert( h < (1<<16) );
+
+ cmd = (drm_radeon_cmd_header_t *)r200AllocCmdBuf( rmesa, 8 * sizeof(int),
+ __FUNCTION__ );
+
+
+ cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
+ cmd[1].i = R200_CP_CMD_BITBLT_MULTI | (5 << 16);
+ cmd[2].i = (RADEON_GMC_SRC_PITCH_OFFSET_CNTL |
+ RADEON_GMC_DST_PITCH_OFFSET_CNTL |
+ RADEON_GMC_BRUSH_NONE |
+ (color_fmt << 8) |
+ RADEON_GMC_SRC_DATATYPE_COLOR |
+ RADEON_ROP3_S |
+ RADEON_DP_SRC_SOURCE_MEMORY |
+ RADEON_GMC_CLR_CMP_CNTL_DIS |
+ RADEON_GMC_WR_MSK_DIS );
+
+ cmd[3].i = ((src_pitch/64)<<22) | (src_offset >> 10);
+ cmd[4].i = ((dst_pitch/64)<<22) | (dst_offset >> 10);
+ cmd[5].i = (srcx << 16) | srcy;
+ cmd[6].i = (dstx << 16) | dsty; /* dst */
+ cmd[7].i = (w << 16) | h;
+}
+
+
+void r200EmitWait( r200ContextPtr rmesa, GLuint flags )
+{
+ if (rmesa->dri.drmMinor >= 6) {
+ drm_radeon_cmd_header_t *cmd;
+
+ assert( !(flags & ~(RADEON_WAIT_2D|RADEON_WAIT_3D)) );
+
+ cmd = (drm_radeon_cmd_header_t *)r200AllocCmdBuf( rmesa, 1 * sizeof(int),
+ __FUNCTION__ );
+ cmd[0].i = 0;
+ cmd[0].wait.cmd_type = RADEON_CMD_WAIT;
+ cmd[0].wait.flags = flags;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_context.c
new file mode 100644
index 000000000..04dbc180c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_context.c
@@ -0,0 +1,694 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_context.c,v 1.3 2003/05/06 23:52:08 daenzer Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "api_arrayelt.h"
+#include "context.h"
+#include "simple_list.h"
+#include "imports.h"
+#include "matrix.h"
+#include "extensions.h"
+#include "framebuffer.h"
+#include "state.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+
+#include "drivers/common/driverfuncs.h"
+
+#include "r200_context.h"
+#include "r200_ioctl.h"
+#include "r200_state.h"
+#include "r200_span.h"
+#include "r200_pixel.h"
+#include "r200_tex.h"
+#include "r200_swtcl.h"
+#include "r200_tcl.h"
+#include "r200_vtxfmt.h"
+#include "r200_maos.h"
+
+#define need_GL_ARB_multisample
+#define need_GL_ARB_texture_compression
+#define need_GL_ARB_vertex_buffer_object
+#define need_GL_ARB_vertex_program
+#define need_GL_EXT_blend_minmax
+#define need_GL_EXT_fog_coord
+#define need_GL_EXT_secondary_color
+#define need_GL_EXT_blend_equation_separate
+#define need_GL_EXT_blend_func_separate
+#define need_GL_NV_vertex_program
+#include "extension_helper.h"
+
+#define DRIVER_DATE "20041207"
+
+#include "vblank.h"
+#include "utils.h"
+#include "xmlpool.h" /* for symbolic values of enum-type options */
+#ifndef R200_DEBUG
+int R200_DEBUG = (0);
+#endif
+
+
+/* Return the width and height of the given buffer.
+ */
+static void r200GetBufferSize( GLframebuffer *buffer,
+ GLuint *width, GLuint *height )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ LOCK_HARDWARE( rmesa );
+ *width = rmesa->dri.drawable->w;
+ *height = rmesa->dri.drawable->h;
+ UNLOCK_HARDWARE( rmesa );
+}
+
+/* Return various strings for glGetString().
+ */
+static const GLubyte *r200GetString( GLcontext *ctx, GLenum name )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ static char buffer[128];
+ unsigned offset;
+ GLuint agp_mode = rmesa->r200Screen->IsPCI ? 0 :
+ rmesa->r200Screen->AGPMode;
+
+ switch ( name ) {
+ case GL_VENDOR:
+ return (GLubyte *)"Tungsten Graphics, Inc.";
+
+ case GL_RENDERER:
+ offset = driGetRendererString( buffer, "R200", DRIVER_DATE,
+ agp_mode );
+
+ sprintf( & buffer[ offset ], " %sTCL",
+ !(rmesa->TclFallback & R200_TCL_FALLBACK_TCL_DISABLE)
+ ? "" : "NO-" );
+
+ return (GLubyte *)buffer;
+
+ default:
+ return NULL;
+ }
+}
+
+
+/* Extension strings exported by the R200 driver.
+ */
+const struct dri_extension card_extensions[] =
+{
+ { "GL_ARB_multisample", GL_ARB_multisample_functions },
+ { "GL_ARB_multitexture", NULL },
+ { "GL_ARB_texture_border_clamp", NULL },
+ { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions },
+ { "GL_ARB_texture_env_add", NULL },
+ { "GL_ARB_texture_env_combine", NULL },
+ { "GL_ARB_texture_env_dot3", NULL },
+ { "GL_ARB_texture_mirrored_repeat", NULL },
+ { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions },
+ { "GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions },
+ { "GL_EXT_blend_subtract", NULL },
+ { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions },
+ { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions },
+ { "GL_EXT_stencil_wrap", NULL },
+ { "GL_EXT_texture_edge_clamp", NULL },
+ { "GL_EXT_texture_env_combine", NULL },
+ { "GL_EXT_texture_env_dot3", NULL },
+ { "GL_EXT_texture_filter_anisotropic", NULL },
+ { "GL_EXT_texture_lod_bias", NULL },
+ { "GL_EXT_texture_mirror_clamp", NULL },
+ { "GL_EXT_texture_rectangle", NULL },
+ { "GL_ATI_texture_env_combine3", NULL },
+ { "GL_ATI_texture_mirror_once", NULL },
+ { "GL_MESA_pack_invert", NULL },
+ { "GL_NV_blend_square", NULL },
+ { "GL_SGIS_generate_mipmap", NULL },
+ { NULL, NULL }
+};
+
+const struct dri_extension blend_extensions[] = {
+ { "GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions },
+ { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions },
+ { NULL, NULL }
+};
+
+const struct dri_extension ARB_vp_extension[] = {
+ { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions }
+};
+
+const struct dri_extension NV_vp_extension[] = {
+ { "GL_NV_vertex_program", GL_NV_vertex_program_functions }
+};
+
+extern const struct tnl_pipeline_stage _r200_render_stage;
+extern const struct tnl_pipeline_stage _r200_tcl_stage;
+
+static const struct tnl_pipeline_stage *r200_pipeline[] = {
+
+ /* Try and go straight to t&l
+ */
+ &_r200_tcl_stage,
+
+ /* Catch any t&l fallbacks
+ */
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ &_tnl_arb_vertex_program_stage,
+ &_tnl_vertex_program_stage,
+
+ /* Try again to go to tcl?
+ * - no good for asymmetric-twoside (do with multipass)
+ * - no good for asymmetric-unfilled (do with multipass)
+ * - good for material
+ * - good for texgen
+ * - need to manipulate a bit of state
+ *
+ * - worth it/not worth it?
+ */
+
+ /* Else do them here.
+ */
+/* &_r200_render_stage, */ /* FIXME: bugs with ut2003 */
+ &_tnl_render_stage, /* FALLBACK: */
+ NULL,
+};
+
+
+
+/* Initialize the driver's misc functions.
+ */
+static void r200InitDriverFuncs( struct dd_function_table *functions )
+{
+ functions->GetBufferSize = r200GetBufferSize;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
+ functions->GetString = r200GetString;
+
+ functions->Error = NULL;
+ functions->DrawPixels = NULL;
+ functions->Bitmap = NULL;
+}
+
+static const struct dri_debug_control debug_control[] =
+{
+ { "fall", DEBUG_FALLBACKS },
+ { "tex", DEBUG_TEXTURE },
+ { "ioctl", DEBUG_IOCTL },
+ { "prim", DEBUG_PRIMS },
+ { "vert", DEBUG_VERTS },
+ { "state", DEBUG_STATE },
+ { "code", DEBUG_CODEGEN },
+ { "vfmt", DEBUG_VFMT },
+ { "vtxf", DEBUG_VFMT },
+ { "verb", DEBUG_VERBOSE },
+ { "dri", DEBUG_DRI },
+ { "dma", DEBUG_DMA },
+ { "san", DEBUG_SANITY },
+ { "sync", DEBUG_SYNC },
+ { "pix", DEBUG_PIXEL },
+ { "mem", DEBUG_MEMORY },
+ { NULL, 0 }
+};
+
+
+/* Create the device specific rendering context.
+ */
+GLboolean r200CreateContext( const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate)
+{
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ r200ScreenPtr screen = (r200ScreenPtr)(sPriv->private);
+ struct dd_function_table functions;
+ r200ContextPtr rmesa;
+ GLcontext *ctx, *shareCtx;
+ int i;
+ int tcl_mode, fthrottle_mode;
+
+ assert(glVisual);
+ assert(driContextPriv);
+ assert(screen);
+
+ /* Allocate the R200 context */
+ rmesa = (r200ContextPtr) CALLOC( sizeof(*rmesa) );
+ if ( !rmesa )
+ return GL_FALSE;
+
+ /* init exp fog table data */
+ r200InitStaticFogData();
+
+ /* Parse configuration files.
+ * Do this here so that initialMaxAnisotropy is set before we create
+ * the default textures.
+ */
+ driParseConfigFiles (&rmesa->optionCache, &screen->optionCache,
+ screen->driScreen->myNum, "r200");
+ rmesa->initialMaxAnisotropy = driQueryOptionf(&rmesa->optionCache,
+ "def_max_anisotropy");
+
+ if ( driQueryOptionb( &rmesa->optionCache, "hyperz" ) ) {
+ if ( sPriv->drmMinor < 13 )
+ fprintf( stderr, "DRM version 1.%d too old to support HyperZ, "
+ "disabling.\n",sPriv->drmMinor );
+ else
+ rmesa->using_hyperz = GL_TRUE;
+ }
+
+ if ( sPriv->drmMinor >= 15 )
+ rmesa->texmicrotile = GL_TRUE;
+
+ /* Init default driver functions then plug in our R200-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions(&functions);
+ r200InitDriverFuncs(&functions);
+ r200InitIoctlFuncs(&functions);
+ r200InitStateFuncs(&functions);
+ r200InitTextureFuncs(&functions);
+
+ /* Allocate and initialize the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((r200ContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ rmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
+ &functions, (void *) rmesa);
+ if (!rmesa->glCtx) {
+ FREE(rmesa);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = rmesa;
+
+ /* Init r200 context data */
+ rmesa->dri.context = driContextPriv;
+ rmesa->dri.screen = sPriv;
+ rmesa->dri.drawable = NULL; /* Set by XMesaMakeCurrent */
+ rmesa->dri.hwContext = driContextPriv->hHWContext;
+ rmesa->dri.hwLock = &sPriv->pSAREA->lock;
+ rmesa->dri.fd = sPriv->fd;
+ rmesa->dri.drmMinor = sPriv->drmMinor;
+
+ rmesa->r200Screen = screen;
+ rmesa->sarea = (drm_radeon_sarea_t *)((GLubyte *)sPriv->pSAREA +
+ screen->sarea_priv_offset);
+
+
+ rmesa->dma.buf0_address = rmesa->r200Screen->buffers->list[0].address;
+
+ (void) memset( rmesa->texture_heaps, 0, sizeof( rmesa->texture_heaps ) );
+ make_empty_list( & rmesa->swapped );
+
+ rmesa->nr_heaps = 1 /* screen->numTexHeaps */ ;
+ assert(rmesa->nr_heaps < R200_NR_TEX_HEAPS);
+ for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
+ rmesa->texture_heaps[i] = driCreateTextureHeap( i, rmesa,
+ screen->texSize[i],
+ 12,
+ RADEON_NR_TEX_REGIONS,
+ (drmTextureRegionPtr)rmesa->sarea->tex_list[i],
+ & rmesa->sarea->tex_age[i],
+ & rmesa->swapped,
+ sizeof( r200TexObj ),
+ (destroy_texture_object_t *) r200DestroyTexObj );
+ }
+ rmesa->texture_depth = driQueryOptioni (&rmesa->optionCache,
+ "texture_depth");
+ if (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
+ rmesa->texture_depth = ( screen->cpp == 4 ) ?
+ DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
+
+ rmesa->swtcl.RenderIndex = ~0;
+ rmesa->hw.all_dirty = 1;
+
+ /* Set the maximum texture size small enough that we can guarentee that
+ * all texture units can bind a maximal texture and have them both in
+ * texturable memory at once.
+ */
+
+ ctx = rmesa->glCtx;
+ ctx->Const.MaxTextureUnits = driQueryOptioni (&rmesa->optionCache,
+ "texture_units");
+ ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;
+ ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;
+
+ driCalculateMaxTextureLevels( rmesa->texture_heaps,
+ rmesa->nr_heaps,
+ & ctx->Const,
+ 4,
+ 11, /* max 2D texture size is 2048x2048 */
+#if ENABLE_HW_3D_TEXTURE
+ 8, /* max 3D texture size is 256^3 */
+#else
+ 0, /* 3D textures unsupported */
+#endif
+ 11, /* max cube texture size is 2048x2048 */
+ 11, /* max texture rectangle size is 2048x2048 */
+ 12,
+ GL_FALSE );
+
+ /* adjust max texture size a bit. Hack, but I really want to use larger textures
+ which will work just fine in 99.999999% of all cases, especially with texture compression... */
+ if (driQueryOptionb( &rmesa->optionCache, "texture_level_hack" ))
+ {
+ if (ctx->Const.MaxTextureLevels < 12) ctx->Const.MaxTextureLevels += 1;
+ }
+
+ ctx->Const.MaxTextureMaxAnisotropy = 16.0;
+
+ /* No wide points.
+ */
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = 1.0;
+ ctx->Const.MaxPointSizeAA = 1.0;
+
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 10.0;
+ ctx->Const.MaxLineWidthAA = 10.0;
+ ctx->Const.LineWidthGranularity = 0.0625;
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+ _ae_create_context( ctx );
+
+ /* Install the customized pipeline:
+ */
+ _tnl_destroy_pipeline( ctx );
+ _tnl_install_pipeline( ctx, r200_pipeline );
+ ctx->Driver.FlushVertices = r200FlushVertices;
+
+ /* Try and keep materials and vertices separate:
+ */
+ _tnl_isolate_materials( ctx, GL_TRUE );
+
+
+ /* Configure swrast and TNL to match hardware characteristics:
+ */
+ _swrast_allow_pixel_fog( ctx, GL_FALSE );
+ _swrast_allow_vertex_fog( ctx, GL_TRUE );
+ _tnl_allow_pixel_fog( ctx, GL_FALSE );
+ _tnl_allow_vertex_fog( ctx, GL_TRUE );
+
+
+ for ( i = 0 ; i < R200_MAX_TEXTURE_UNITS ; i++ ) {
+ _math_matrix_ctr( &rmesa->TexGenMatrix[i] );
+ _math_matrix_set_identity( &rmesa->TexGenMatrix[i] );
+ }
+ _math_matrix_ctr( &rmesa->tmpmat );
+ _math_matrix_set_identity( &rmesa->tmpmat );
+
+ driInitExtensions( ctx, card_extensions, GL_TRUE );
+ if (!(rmesa->r200Screen->chipset & R200_CHIPSET_YCBCR_BROKEN)) {
+ /* yuv textures don't work with some chips - R200 / rv280 okay so far
+ others get the bit ordering right but don't actually do YUV-RGB conversion */
+ _mesa_enable_extension( ctx, "GL_MESA_ycbcr_texture" );
+ }
+ if (rmesa->glCtx->Mesa_DXTn) {
+ _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
+ _mesa_enable_extension( ctx, "GL_S3_s3tc" );
+ }
+ else if (driQueryOptionb (&rmesa->optionCache, "force_s3tc_enable")) {
+ _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
+ }
+
+ if (rmesa->r200Screen->drmSupportsCubeMaps)
+ _mesa_enable_extension( ctx, "GL_ARB_texture_cube_map" );
+ if (rmesa->r200Screen->drmSupportsBlendColor) {
+ driInitExtensions( ctx, blend_extensions, GL_FALSE );
+ }
+ if(driQueryOptionb(&rmesa->optionCache, "arb_vertex_program"))
+ driInitSingleExtension( ctx, ARB_vp_extension );
+ if(driQueryOptionb(&rmesa->optionCache, "nv_vertex_program"))
+ driInitSingleExtension( ctx, NV_vp_extension );
+
+#if 0
+ r200InitDriverFuncs( ctx );
+ r200InitIoctlFuncs( ctx );
+ r200InitStateFuncs( ctx );
+ r200InitTextureFuncs( ctx );
+#endif
+ /* plug in a few more device driver functions */
+ /* XXX these should really go right after _mesa_init_driver_functions() */
+ r200InitPixelFuncs( ctx );
+ r200InitSpanFuncs( ctx );
+ r200InitTnlFuncs( ctx );
+ r200InitState( rmesa );
+ r200InitSwtcl( ctx );
+
+ fthrottle_mode = driQueryOptioni(&rmesa->optionCache, "fthrottle_mode");
+ rmesa->iw.irq_seq = -1;
+ rmesa->irqsEmitted = 0;
+ rmesa->do_irqs = (rmesa->dri.drmMinor >= 6 &&
+ fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS &&
+ rmesa->r200Screen->irq);
+
+ rmesa->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
+
+ if (!rmesa->do_irqs)
+ fprintf(stderr,
+ "IRQ's not enabled, falling back to %s: %d %d %d\n",
+ rmesa->do_usleeps ? "usleeps" : "busy waits",
+ rmesa->dri.drmMinor,
+ fthrottle_mode,
+ rmesa->r200Screen->irq);
+
+ rmesa->vblank_flags = (rmesa->r200Screen->irq != 0)
+ ? driGetDefaultVBlankFlags(&rmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
+
+ rmesa->prefer_gart_client_texturing =
+ (getenv("R200_GART_CLIENT_TEXTURES") != 0);
+
+ (*dri_interface->getUST)( & rmesa->swap_ust );
+
+
+#if DO_DEBUG
+ R200_DEBUG = driParseDebugString( getenv( "R200_DEBUG" ),
+ debug_control );
+ R200_DEBUG |= driParseDebugString( getenv( "RADEON_DEBUG" ),
+ debug_control );
+#endif
+
+ tcl_mode = driQueryOptioni(&rmesa->optionCache, "tcl_mode");
+ if (driQueryOptionb(&rmesa->optionCache, "no_rast")) {
+ fprintf(stderr, "disabling 3D acceleration\n");
+ FALLBACK(rmesa, R200_FALLBACK_DISABLE, 1);
+ }
+ else if (tcl_mode == DRI_CONF_TCL_SW || getenv("R200_NO_TCL") ||
+ !(rmesa->r200Screen->chipset & R200_CHIPSET_TCL)) {
+ if (rmesa->r200Screen->chipset & R200_CHIPSET_TCL) {
+ rmesa->r200Screen->chipset &= ~R200_CHIPSET_TCL;
+ fprintf(stderr, "Disabling HW TCL support\n");
+ }
+ TCL_FALLBACK(rmesa->glCtx, R200_TCL_FALLBACK_TCL_DISABLE, 1);
+ }
+
+ if (rmesa->r200Screen->chipset & R200_CHIPSET_TCL) {
+ if (tcl_mode >= DRI_CONF_TCL_VTXFMT)
+ r200VtxfmtInit( ctx, tcl_mode >= DRI_CONF_TCL_CODEGEN );
+
+ _tnl_need_dlist_norm_lengths( ctx, GL_FALSE );
+ }
+ return GL_TRUE;
+}
+
+
+/* Destroy the device specific context.
+ */
+/* Destroy the Mesa and driver specific context data.
+ */
+void r200DestroyContext( __DRIcontextPrivate *driContextPriv )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = (r200ContextPtr) driContextPriv->driverPrivate;
+ r200ContextPtr current = ctx ? R200_CONTEXT(ctx) : NULL;
+
+ /* check if we're deleting the currently bound context */
+ if (rmesa == current) {
+ R200_FIREVERTICES( rmesa );
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ /* Free r200 context resources */
+ assert(rmesa); /* should never be null */
+ if ( rmesa ) {
+ GLboolean release_texture_heaps;
+
+
+ release_texture_heaps = (rmesa->glCtx->Shared->RefCount == 1);
+ _swsetup_DestroyContext( rmesa->glCtx );
+ _tnl_DestroyContext( rmesa->glCtx );
+ _ac_DestroyContext( rmesa->glCtx );
+ _swrast_DestroyContext( rmesa->glCtx );
+
+ r200DestroySwtcl( rmesa->glCtx );
+ r200ReleaseArrays( rmesa->glCtx, ~0 );
+
+ if (rmesa->dma.current.buf) {
+ r200ReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );
+ r200FlushCmdBuf( rmesa, __FUNCTION__ );
+ }
+
+ if (!(rmesa->TclFallback & R200_TCL_FALLBACK_TCL_DISABLE)) {
+ int tcl_mode = driQueryOptioni(&rmesa->optionCache, "tcl_mode");
+ if (tcl_mode >= DRI_CONF_TCL_VTXFMT)
+ r200VtxfmtDestroy( rmesa->glCtx );
+ }
+
+ /* free the Mesa context */
+ rmesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context( rmesa->glCtx );
+
+ if (rmesa->state.scissor.pClipRects) {
+ FREE(rmesa->state.scissor.pClipRects);
+ rmesa->state.scissor.pClipRects = NULL;
+ }
+
+ if ( release_texture_heaps ) {
+ /* This share group is about to go away, free our private
+ * texture object data.
+ */
+ int i;
+
+ for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
+ driDestroyTextureHeap( rmesa->texture_heaps[ i ] );
+ rmesa->texture_heaps[ i ] = NULL;
+ }
+
+ assert( is_empty_list( & rmesa->swapped ) );
+ }
+
+ /* free the option cache */
+ driDestroyOptionCache (&rmesa->optionCache);
+
+ FREE( rmesa );
+ }
+}
+
+
+
+
+void
+r200SwapBuffers( __DRIdrawablePrivate *dPriv )
+{
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ r200ContextPtr rmesa;
+ GLcontext *ctx;
+ rmesa = (r200ContextPtr) dPriv->driContextPriv->driverPrivate;
+ ctx = rmesa->glCtx;
+ if (ctx->Visual.doubleBufferMode) {
+ _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
+ if ( rmesa->doPageFlip ) {
+ r200PageFlip( dPriv );
+ }
+ else {
+ r200CopyBuffer( dPriv );
+ }
+ }
+ }
+ else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__);
+ }
+}
+
+
+/* Force the context `c' to be the current context and associate with it
+ * buffer `b'.
+ */
+GLboolean
+r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv )
+{
+ if ( driContextPriv ) {
+ r200ContextPtr newCtx =
+ (r200ContextPtr) driContextPriv->driverPrivate;
+
+ if (R200_DEBUG & DEBUG_DRI)
+ fprintf(stderr, "%s ctx %p\n", __FUNCTION__, (void *)newCtx->glCtx);
+
+ if ( newCtx->dri.drawable != driDrawPriv ) {
+ driDrawableInitVBlank( driDrawPriv, newCtx->vblank_flags );
+ newCtx->dri.drawable = driDrawPriv;
+ r200UpdateWindow( newCtx->glCtx );
+ r200UpdateViewportOffset( newCtx->glCtx );
+ }
+
+ _mesa_make_current( newCtx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
+
+ if (newCtx->vb.enabled)
+ r200VtxfmtMakeCurrent( newCtx->glCtx );
+
+ _mesa_update_state( newCtx->glCtx );
+ r200ValidateState( newCtx->glCtx );
+
+ } else {
+ if (R200_DEBUG & DEBUG_DRI)
+ fprintf(stderr, "%s ctx is null\n", __FUNCTION__);
+ _mesa_make_current( NULL, NULL, NULL );
+ }
+
+ if (R200_DEBUG & DEBUG_DRI)
+ fprintf(stderr, "End %s\n", __FUNCTION__);
+ return GL_TRUE;
+}
+
+/* Force the context `c' to be unbound from its buffer.
+ */
+GLboolean
+r200UnbindContext( __DRIcontextPrivate *driContextPriv )
+{
+ r200ContextPtr rmesa = (r200ContextPtr) driContextPriv->driverPrivate;
+
+ if (R200_DEBUG & DEBUG_DRI)
+ fprintf(stderr, "%s ctx %p\n", __FUNCTION__, (void *)rmesa->glCtx);
+
+ r200VtxfmtUnbindContext( rmesa->glCtx );
+ return GL_TRUE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_context.h
new file mode 100644
index 000000000..8169af709
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_context.h
@@ -0,0 +1,995 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_context.h,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R200_CONTEXT_H__
+#define __R200_CONTEXT_H__
+
+#include "tnl/t_vertex.h"
+#include "drm.h"
+#include "radeon_drm.h"
+#include "dri_util.h"
+#include "texmem.h"
+
+#include "macros.h"
+#include "mtypes.h"
+#include "colormac.h"
+#include "r200_reg.h"
+
+#define ENABLE_HW_3D_TEXTURE 1 /* XXX this is temporary! */
+
+struct r200_context;
+typedef struct r200_context r200ContextRec;
+typedef struct r200_context *r200ContextPtr;
+
+#include "r200_lock.h"
+#include "r200_screen.h"
+#include "mm.h"
+
+/* Flags for software fallback cases */
+/* See correponding strings in r200_swtcl.c */
+#define R200_FALLBACK_TEXTURE 0x01
+#define R200_FALLBACK_DRAW_BUFFER 0x02
+#define R200_FALLBACK_STENCIL 0x04
+#define R200_FALLBACK_RENDER_MODE 0x08
+#define R200_FALLBACK_DISABLE 0x10
+#define R200_FALLBACK_BORDER_MODE 0x20
+
+/* The blit width for texture uploads
+ */
+#define BLIT_WIDTH_BYTES 1024
+
+/* Use the templated vertex format:
+ */
+#define COLOR_IS_RGBA
+#define TAG(x) r200##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+typedef void (*r200_tri_func)( r200ContextPtr,
+ r200Vertex *,
+ r200Vertex *,
+ r200Vertex * );
+
+typedef void (*r200_line_func)( r200ContextPtr,
+ r200Vertex *,
+ r200Vertex * );
+
+typedef void (*r200_point_func)( r200ContextPtr,
+ r200Vertex * );
+
+
+struct r200_colorbuffer_state {
+ GLuint clear;
+ GLint drawOffset, drawPitch;
+ int roundEnable;
+};
+
+
+struct r200_depthbuffer_state {
+ GLuint clear;
+ GLfloat scale;
+};
+
+struct r200_pixel_state {
+ GLint readOffset, readPitch;
+};
+
+struct r200_scissor_state {
+ drm_clip_rect_t rect;
+ GLboolean enabled;
+
+ GLuint numClipRects; /* Cliprects active */
+ GLuint numAllocedClipRects; /* Cliprects available */
+ drm_clip_rect_t *pClipRects;
+};
+
+struct r200_stencilbuffer_state {
+ GLboolean hwBuffer;
+ GLuint clear; /* rb3d_stencilrefmask value */
+};
+
+struct r200_stipple_state {
+ GLuint mask[32];
+};
+
+
+
+#define TEX_0 0x1
+#define TEX_1 0x2
+#define TEX_2 0x4
+#define TEX_3 0x8
+#define TEX_4 0x10
+#define TEX_5 0x20
+#define TEX_ALL 0x3f
+
+typedef struct r200_tex_obj r200TexObj, *r200TexObjPtr;
+
+/* Texture object in locally shared texture space.
+ */
+struct r200_tex_obj {
+ driTextureObject base;
+
+ GLuint bufAddr; /* Offset to start of locally
+ shared texture block */
+
+ GLuint dirty_state; /* Flags (1 per texunit) for
+ whether or not this texobj
+ has dirty hardware state
+ (pp_*) that needs to be
+ brought into the
+ texunit. */
+
+ drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
+ /* Six, for the cube faces */
+
+ GLuint pp_txfilter; /* hardware register values */
+ GLuint pp_txformat;
+ GLuint pp_txformat_x;
+ GLuint pp_txoffset; /* Image location in texmem.
+ All cube faces follow. */
+ GLuint pp_txsize; /* npot only */
+ GLuint pp_txpitch; /* npot only */
+ GLuint pp_border_color;
+ GLuint pp_cubic_faces; /* cube face 1,2,3,4 log2 sizes */
+
+ GLboolean border_fallback;
+
+ GLuint tile_bits; /* hw texture tile bits used on this texture */
+};
+
+
+struct r200_texture_env_state {
+ r200TexObjPtr texobj;
+ GLenum format;
+ GLenum envMode;
+};
+
+#define R200_MAX_TEXTURE_UNITS 6
+
+struct r200_texture_state {
+ struct r200_texture_env_state unit[R200_MAX_TEXTURE_UNITS];
+};
+
+
+struct r200_state_atom {
+ struct r200_state_atom *next, *prev;
+ const char *name; /* for debug */
+ int cmd_size; /* size in bytes */
+ GLuint idx;
+ int *cmd; /* one or more cmd's */
+ int *lastcmd; /* one or more cmd's */
+ GLboolean dirty;
+ GLboolean (*check)( GLcontext *, int ); /* is this state active? */
+};
+
+
+
+/* Trying to keep these relatively short as the variables are becoming
+ * extravagently long. Drop the driver name prefix off the front of
+ * everything - I think we know which driver we're in by now, and keep the
+ * prefix to 3 letters unless absolutely impossible.
+ */
+
+#define CTX_CMD_0 0
+#define CTX_PP_MISC 1
+#define CTX_PP_FOG_COLOR 2
+#define CTX_RE_SOLID_COLOR 3
+#define CTX_RB3D_BLENDCNTL 4
+#define CTX_RB3D_DEPTHOFFSET 5
+#define CTX_RB3D_DEPTHPITCH 6
+#define CTX_RB3D_ZSTENCILCNTL 7
+#define CTX_CMD_1 8
+#define CTX_PP_CNTL 9
+#define CTX_RB3D_CNTL 10
+#define CTX_RB3D_COLOROFFSET 11
+#define CTX_CMD_2 12 /* why */
+#define CTX_RB3D_COLORPITCH 13 /* why */
+#define CTX_STATE_SIZE_OLDDRM 14
+#define CTX_CMD_3 14
+#define CTX_RB3D_BLENDCOLOR 15
+#define CTX_RB3D_ABLENDCNTL 16
+#define CTX_RB3D_CBLENDCNTL 17
+#define CTX_STATE_SIZE_NEWDRM 18
+
+#define SET_CMD_0 0
+#define SET_SE_CNTL 1
+#define SET_RE_CNTL 2 /* replace se_coord_fmt */
+#define SET_STATE_SIZE 3
+
+#define VTE_CMD_0 0
+#define VTE_SE_VTE_CNTL 1
+#define VTE_STATE_SIZE 2
+
+#define LIN_CMD_0 0
+#define LIN_RE_LINE_PATTERN 1
+#define LIN_RE_LINE_STATE 2
+#define LIN_CMD_1 3
+#define LIN_SE_LINE_WIDTH 4
+#define LIN_STATE_SIZE 5
+
+#define MSK_CMD_0 0
+#define MSK_RB3D_STENCILREFMASK 1
+#define MSK_RB3D_ROPCNTL 2
+#define MSK_RB3D_PLANEMASK 3
+#define MSK_STATE_SIZE 4
+
+#define VPT_CMD_0 0
+#define VPT_SE_VPORT_XSCALE 1
+#define VPT_SE_VPORT_XOFFSET 2
+#define VPT_SE_VPORT_YSCALE 3
+#define VPT_SE_VPORT_YOFFSET 4
+#define VPT_SE_VPORT_ZSCALE 5
+#define VPT_SE_VPORT_ZOFFSET 6
+#define VPT_STATE_SIZE 7
+
+#define ZBS_CMD_0 0
+#define ZBS_SE_ZBIAS_FACTOR 1
+#define ZBS_SE_ZBIAS_CONSTANT 2
+#define ZBS_STATE_SIZE 3
+
+#define MSC_CMD_0 0
+#define MSC_RE_MISC 1
+#define MSC_STATE_SIZE 2
+
+#define TAM_CMD_0 0
+#define TAM_DEBUG3 1
+#define TAM_STATE_SIZE 2
+
+#define TEX_CMD_0 0
+#define TEX_PP_TXFILTER 1 /*2c00*/
+#define TEX_PP_TXFORMAT 2 /*2c04*/
+#define TEX_PP_TXFORMAT_X 3 /*2c08*/
+#define TEX_PP_TXSIZE 4 /*2c0c*/
+#define TEX_PP_TXPITCH 5 /*2c10*/
+#define TEX_PP_BORDER_COLOR 6 /*2c14*/
+#define TEX_CMD_1 7
+#define TEX_PP_TXOFFSET 8 /*2d00 */
+#define TEX_STATE_SIZE 9
+
+#define CUBE_CMD_0 0 /* 1 register follows */
+#define CUBE_PP_CUBIC_FACES 1 /* 0x2c18 */
+#define CUBE_CMD_1 2 /* 5 registers follow */
+#define CUBE_PP_CUBIC_OFFSET_F1 3 /* 0x2d04 */
+#define CUBE_PP_CUBIC_OFFSET_F2 4 /* 0x2d08 */
+#define CUBE_PP_CUBIC_OFFSET_F3 5 /* 0x2d0c */
+#define CUBE_PP_CUBIC_OFFSET_F4 6 /* 0x2d10 */
+#define CUBE_PP_CUBIC_OFFSET_F5 7 /* 0x2d14 */
+#define CUBE_STATE_SIZE 8
+
+#define PIX_CMD_0 0
+#define PIX_PP_TXCBLEND 1
+#define PIX_PP_TXCBLEND2 2
+#define PIX_PP_TXABLEND 3
+#define PIX_PP_TXABLEND2 4
+#define PIX_STATE_SIZE 5
+
+#define TF_CMD_0 0
+#define TF_TFACTOR_0 1
+#define TF_TFACTOR_1 2
+#define TF_TFACTOR_2 3
+#define TF_TFACTOR_3 4
+#define TF_TFACTOR_4 5
+#define TF_TFACTOR_5 6
+#define TF_STATE_SIZE 7
+
+#define TCL_CMD_0 0
+#define TCL_LIGHT_MODEL_CTL_0 1
+#define TCL_LIGHT_MODEL_CTL_1 2
+#define TCL_PER_LIGHT_CTL_0 3
+#define TCL_PER_LIGHT_CTL_1 4
+#define TCL_PER_LIGHT_CTL_2 5
+#define TCL_PER_LIGHT_CTL_3 6
+#define TCL_CMD_1 7
+#define TCL_UCP_VERT_BLEND_CTL 8
+#define TCL_STATE_SIZE 9
+
+#define MSL_CMD_0 0
+#define MSL_MATRIX_SELECT_0 1
+#define MSL_MATRIX_SELECT_1 2
+#define MSL_MATRIX_SELECT_2 3
+#define MSL_MATRIX_SELECT_3 4
+#define MSL_MATRIX_SELECT_4 5
+#define MSL_STATE_SIZE 6
+
+#define TCG_CMD_0 0
+#define TCG_TEX_PROC_CTL_2 1
+#define TCG_TEX_PROC_CTL_3 2
+#define TCG_TEX_PROC_CTL_0 3
+#define TCG_TEX_PROC_CTL_1 4
+#define TCG_TEX_CYL_WRAP_CTL 5
+#define TCG_STATE_SIZE 6
+
+#define MTL_CMD_0 0
+#define MTL_EMMISSIVE_RED 1
+#define MTL_EMMISSIVE_GREEN 2
+#define MTL_EMMISSIVE_BLUE 3
+#define MTL_EMMISSIVE_ALPHA 4
+#define MTL_AMBIENT_RED 5
+#define MTL_AMBIENT_GREEN 6
+#define MTL_AMBIENT_BLUE 7
+#define MTL_AMBIENT_ALPHA 8
+#define MTL_DIFFUSE_RED 9
+#define MTL_DIFFUSE_GREEN 10
+#define MTL_DIFFUSE_BLUE 11
+#define MTL_DIFFUSE_ALPHA 12
+#define MTL_SPECULAR_RED 13
+#define MTL_SPECULAR_GREEN 14
+#define MTL_SPECULAR_BLUE 15
+#define MTL_SPECULAR_ALPHA 16
+#define MTL_CMD_1 17
+#define MTL_SHININESS 18
+#define MTL_STATE_SIZE 19
+
+#define VAP_CMD_0 0
+#define VAP_SE_VAP_CNTL 1
+#define VAP_STATE_SIZE 2
+
+/* Replaces a lot of packet info from radeon
+ */
+#define VTX_CMD_0 0
+#define VTX_VTXFMT_0 1
+#define VTX_VTXFMT_1 2
+#define VTX_TCL_OUTPUT_VTXFMT_0 3
+#define VTX_TCL_OUTPUT_VTXFMT_1 4
+#define VTX_CMD_1 5
+#define VTX_TCL_OUTPUT_COMPSEL 6
+#define VTX_CMD_2 7
+#define VTX_STATE_CNTL 8
+#define VTX_STATE_SIZE 9
+
+
+#define VTX_COLOR(v,n) (((v)>>(R200_VTX_COLOR_0_SHIFT+(n)*2))&\
+ R200_VTX_COLOR_MASK)
+
+/**
+ * Given the \c R200_SE_VTX_FMT_1 for the current vertex state, determine
+ * how many components are in texture coordinate \c n.
+ */
+#define VTX_TEXn_COUNT(v,n) (((v) >> (3 * n)) & 0x07)
+
+#define MAT_CMD_0 0
+#define MAT_ELT_0 1
+#define MAT_STATE_SIZE 17
+
+#define GRD_CMD_0 0
+#define GRD_VERT_GUARD_CLIP_ADJ 1
+#define GRD_VERT_GUARD_DISCARD_ADJ 2
+#define GRD_HORZ_GUARD_CLIP_ADJ 3
+#define GRD_HORZ_GUARD_DISCARD_ADJ 4
+#define GRD_STATE_SIZE 5
+
+/* position changes frequently when lighting in modelpos - separate
+ * out to new state item?
+ */
+#define LIT_CMD_0 0
+#define LIT_AMBIENT_RED 1
+#define LIT_AMBIENT_GREEN 2
+#define LIT_AMBIENT_BLUE 3
+#define LIT_AMBIENT_ALPHA 4
+#define LIT_DIFFUSE_RED 5
+#define LIT_DIFFUSE_GREEN 6
+#define LIT_DIFFUSE_BLUE 7
+#define LIT_DIFFUSE_ALPHA 8
+#define LIT_SPECULAR_RED 9
+#define LIT_SPECULAR_GREEN 10
+#define LIT_SPECULAR_BLUE 11
+#define LIT_SPECULAR_ALPHA 12
+#define LIT_POSITION_X 13
+#define LIT_POSITION_Y 14
+#define LIT_POSITION_Z 15
+#define LIT_POSITION_W 16
+#define LIT_DIRECTION_X 17
+#define LIT_DIRECTION_Y 18
+#define LIT_DIRECTION_Z 19
+#define LIT_DIRECTION_W 20
+#define LIT_ATTEN_QUADRATIC 21
+#define LIT_ATTEN_LINEAR 22
+#define LIT_ATTEN_CONST 23
+#define LIT_ATTEN_XXX 24
+#define LIT_CMD_1 25
+#define LIT_SPOT_DCD 26
+#define LIT_SPOT_DCM 27
+#define LIT_SPOT_EXPONENT 28
+#define LIT_SPOT_CUTOFF 29
+#define LIT_SPECULAR_THRESH 30
+#define LIT_RANGE_CUTOFF 31 /* ? */
+#define LIT_ATTEN_CONST_INV 32
+#define LIT_STATE_SIZE 33
+
+/* Fog
+ */
+#define FOG_CMD_0 0
+#define FOG_R 1
+#define FOG_C 2
+#define FOG_D 3
+#define FOG_PAD 4
+#define FOG_STATE_SIZE 5
+
+/* UCP
+ */
+#define UCP_CMD_0 0
+#define UCP_X 1
+#define UCP_Y 2
+#define UCP_Z 3
+#define UCP_W 4
+#define UCP_STATE_SIZE 5
+
+/* GLT - Global ambient
+ */
+#define GLT_CMD_0 0
+#define GLT_RED 1
+#define GLT_GREEN 2
+#define GLT_BLUE 3
+#define GLT_ALPHA 4
+#define GLT_STATE_SIZE 5
+
+/* EYE
+ */
+#define EYE_CMD_0 0
+#define EYE_X 1
+#define EYE_Y 2
+#define EYE_Z 3
+#define EYE_RESCALE_FACTOR 4
+#define EYE_STATE_SIZE 5
+
+/* CST - constant state
+ */
+#define CST_CMD_0 0
+#define CST_PP_CNTL_X 1
+#define CST_CMD_1 2
+#define CST_RB3D_DEPTHXY_OFFSET 3
+#define CST_CMD_2 4
+#define CST_RE_AUX_SCISSOR_CNTL 5
+#define CST_CMD_3 6
+#define CST_RE_SCISSOR_TL_0 7
+#define CST_RE_SCISSOR_BR_0 8
+#define CST_CMD_4 9
+#define CST_SE_VAP_CNTL_STATUS 10
+#define CST_CMD_5 11
+#define CST_RE_POINTSIZE 12
+#define CST_CMD_6 13
+#define CST_SE_TCL_INPUT_VTX_0 14
+#define CST_SE_TCL_INPUT_VTX_1 15
+#define CST_SE_TCL_INPUT_VTX_2 16
+#define CST_SE_TCL_INPUT_VTX_3 17
+#define CST_STATE_SIZE 18
+
+#define PRF_CMD_0 0
+#define PRF_PP_TRI_PERF 1
+#define PRF_PP_PERF_CNTL 2
+#define PRF_STATE_SIZE 3
+
+
+struct r200_hw_state {
+ /* Head of the linked list of state atoms. */
+ struct r200_state_atom atomlist;
+
+ /* Hardware state, stored as cmdbuf commands:
+ * -- Need to doublebuffer for
+ * - reviving state after loss of context
+ * - eliding noop statechange loops? (except line stipple count)
+ */
+ struct r200_state_atom ctx;
+ struct r200_state_atom set;
+ struct r200_state_atom vte;
+ struct r200_state_atom lin;
+ struct r200_state_atom msk;
+ struct r200_state_atom vpt;
+ struct r200_state_atom vap;
+ struct r200_state_atom vtx;
+ struct r200_state_atom tcl;
+ struct r200_state_atom msl;
+ struct r200_state_atom tcg;
+ struct r200_state_atom msc;
+ struct r200_state_atom cst;
+ struct r200_state_atom tam;
+ struct r200_state_atom tf;
+ struct r200_state_atom tex[6];
+ struct r200_state_atom cube[6];
+ struct r200_state_atom zbs;
+ struct r200_state_atom mtl[2];
+ struct r200_state_atom mat[9];
+ struct r200_state_atom lit[8]; /* includes vec, scl commands */
+ struct r200_state_atom ucp[6];
+ struct r200_state_atom pix[6]; /* pixshader stages */
+ struct r200_state_atom eye; /* eye pos */
+ struct r200_state_atom grd; /* guard band clipping */
+ struct r200_state_atom fog;
+ struct r200_state_atom glt;
+ struct r200_state_atom prf;
+
+ int max_state_size; /* Number of bytes necessary for a full state emit. */
+ GLboolean is_dirty, all_dirty;
+};
+
+struct r200_state {
+ /* Derived state for internal purposes:
+ */
+ struct r200_colorbuffer_state color;
+ struct r200_depthbuffer_state depth;
+ struct r200_pixel_state pixel;
+ struct r200_scissor_state scissor;
+ struct r200_stencilbuffer_state stencil;
+ struct r200_stipple_state stipple;
+ struct r200_texture_state texture;
+};
+
+/* Need refcounting on dma buffers:
+ */
+struct r200_dma_buffer {
+ int refcount; /* the number of retained regions in buf */
+ drmBufPtr buf;
+};
+
+#define GET_START(rvb) (rmesa->r200Screen->gart_buffer_offset + \
+ (rvb)->address - rmesa->dma.buf0_address + \
+ (rvb)->start)
+
+/* A retained region, eg vertices for indexed vertices.
+ */
+struct r200_dma_region {
+ struct r200_dma_buffer *buf;
+ char *address; /* == buf->address */
+ int start, end, ptr; /* offsets from start of buf */
+ int aos_start;
+ int aos_stride;
+ int aos_size;
+};
+
+
+struct r200_dma {
+ /* Active dma region. Allocations for vertices and retained
+ * regions come from here. Also used for emitting random vertices,
+ * these may be flushed by calling flush_current();
+ */
+ struct r200_dma_region current;
+
+ void (*flush)( r200ContextPtr );
+
+ char *buf0_address; /* start of buf[0], for index calcs */
+ GLuint nr_released_bufs; /* flush after so many buffers released */
+};
+
+struct r200_dri_mirror {
+ __DRIcontextPrivate *context; /* DRI context */
+ __DRIscreenPrivate *screen; /* DRI screen */
+ __DRIdrawablePrivate *drawable; /* DRI drawable bound to this ctx */
+
+ drm_context_t hwContext;
+ drm_hw_lock_t *hwLock;
+ int fd;
+ int drmMinor;
+};
+
+
+#define R200_CMD_BUF_SZ (8*1024)
+
+struct r200_store {
+ GLuint statenr;
+ GLuint primnr;
+ char cmd_buf[R200_CMD_BUF_SZ];
+ int cmd_used;
+ int elts_start;
+};
+
+
+/* r200_tcl.c
+ */
+struct r200_tcl_info {
+ GLuint vertex_format;
+ GLint last_offset;
+ GLuint hw_primitive;
+
+ struct r200_dma_region *aos_components[8];
+ GLuint nr_aos_components;
+
+ GLuint *Elts;
+
+ struct r200_dma_region indexed_verts;
+ struct r200_dma_region obj;
+ struct r200_dma_region rgba;
+ struct r200_dma_region spec;
+ struct r200_dma_region fog;
+ struct r200_dma_region tex[R200_MAX_TEXTURE_UNITS];
+ struct r200_dma_region norm;
+};
+
+
+/* r200_swtcl.c
+ */
+struct r200_swtcl_info {
+ GLuint RenderIndex;
+
+ /**
+ * Size of a hardware vertex. This is calculated when \c ::vertex_attrs is
+ * installed in the Mesa state vector.
+ */
+ GLuint vertex_size;
+
+ /**
+ * Attributes instructing the Mesa TCL pipeline where / how to put vertex
+ * data in the hardware buffer.
+ */
+ struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
+
+ /**
+ * Number of elements of \c ::vertex_attrs that are actually used.
+ */
+ GLuint vertex_attr_count;
+
+ /**
+ * Cached pointer to the buffer where Mesa will store vertex data.
+ */
+ GLubyte *verts;
+
+ /* Fallback rasterization functions
+ */
+ r200_point_func draw_point;
+ r200_line_func draw_line;
+ r200_tri_func draw_tri;
+
+ GLuint hw_primitive;
+ GLenum render_primitive;
+ GLuint numverts;
+
+ /**
+ * Offset of the 4UB color data within a hardware (swtcl) vertex.
+ */
+ GLuint coloroffset;
+
+ /**
+ * Offset of the 3UB specular color data within a hardware (swtcl) vertex.
+ */
+ GLuint specoffset;
+
+ /**
+ * Should Mesa project vertex data or will the hardware do it?
+ */
+ GLboolean needproj;
+
+ struct r200_dma_region indexed_verts;
+};
+
+
+struct r200_ioctl {
+ GLuint vertex_offset;
+ GLuint vertex_size;
+};
+
+
+
+#define R200_MAX_PRIMS 64
+
+
+/* Want to keep a cache of these around. Each is parameterized by
+ * only a single value which has only a small range. Only expect a
+ * few, so just rescan the list each time?
+ */
+struct dynfn {
+ struct dynfn *next, *prev;
+ int key[2];
+ char *code;
+};
+
+struct dfn_lists {
+ struct dynfn Vertex2f;
+ struct dynfn Vertex2fv;
+ struct dynfn Vertex3f;
+ struct dynfn Vertex3fv;
+ struct dynfn Color4ub;
+ struct dynfn Color4ubv;
+ struct dynfn Color3ub;
+ struct dynfn Color3ubv;
+ struct dynfn Color4f;
+ struct dynfn Color4fv;
+ struct dynfn Color3f;
+ struct dynfn Color3fv;
+ struct dynfn SecondaryColor3ubEXT;
+ struct dynfn SecondaryColor3ubvEXT;
+ struct dynfn SecondaryColor3fEXT;
+ struct dynfn SecondaryColor3fvEXT;
+ struct dynfn Normal3f;
+ struct dynfn Normal3fv;
+ struct dynfn TexCoord3f;
+ struct dynfn TexCoord3fv;
+ struct dynfn TexCoord2f;
+ struct dynfn TexCoord2fv;
+ struct dynfn TexCoord1f;
+ struct dynfn TexCoord1fv;
+ struct dynfn MultiTexCoord3fARB;
+ struct dynfn MultiTexCoord3fvARB;
+ struct dynfn MultiTexCoord2fARB;
+ struct dynfn MultiTexCoord2fvARB;
+ struct dynfn MultiTexCoord1fARB;
+ struct dynfn MultiTexCoord1fvARB;
+ struct dynfn FogCoordfEXT;
+ struct dynfn FogCoordfvEXT;
+};
+
+struct dfn_generators {
+ struct dynfn *(*Vertex2f)( GLcontext *, const int * );
+ struct dynfn *(*Vertex2fv)( GLcontext *, const int * );
+ struct dynfn *(*Vertex3f)( GLcontext *, const int * );
+ struct dynfn *(*Vertex3fv)( GLcontext *, const int * );
+ struct dynfn *(*Color4ub)( GLcontext *, const int * );
+ struct dynfn *(*Color4ubv)( GLcontext *, const int * );
+ struct dynfn *(*Color3ub)( GLcontext *, const int * );
+ struct dynfn *(*Color3ubv)( GLcontext *, const int * );
+ struct dynfn *(*Color4f)( GLcontext *, const int * );
+ struct dynfn *(*Color4fv)( GLcontext *, const int * );
+ struct dynfn *(*Color3f)( GLcontext *, const int * );
+ struct dynfn *(*Color3fv)( GLcontext *, const int * );
+ struct dynfn *(*SecondaryColor3ubEXT)( GLcontext *, const int * );
+ struct dynfn *(*SecondaryColor3ubvEXT)( GLcontext *, const int * );
+ struct dynfn *(*SecondaryColor3fEXT)( GLcontext *, const int * );
+ struct dynfn *(*SecondaryColor3fvEXT)( GLcontext *, const int * );
+ struct dynfn *(*Normal3f)( GLcontext *, const int * );
+ struct dynfn *(*Normal3fv)( GLcontext *, const int * );
+ struct dynfn *(*TexCoord3f)( GLcontext *, const int * );
+ struct dynfn *(*TexCoord3fv)( GLcontext *, const int * );
+ struct dynfn *(*TexCoord2f)( GLcontext *, const int * );
+ struct dynfn *(*TexCoord2fv)( GLcontext *, const int * );
+ struct dynfn *(*TexCoord1f)( GLcontext *, const int * );
+ struct dynfn *(*TexCoord1fv)( GLcontext *, const int * );
+ struct dynfn *(*MultiTexCoord3fARB)( GLcontext *, const int * );
+ struct dynfn *(*MultiTexCoord3fvARB)( GLcontext *, const int * );
+ struct dynfn *(*MultiTexCoord2fARB)( GLcontext *, const int * );
+ struct dynfn *(*MultiTexCoord2fvARB)( GLcontext *, const int * );
+ struct dynfn *(*MultiTexCoord1fARB)( GLcontext *, const int * );
+ struct dynfn *(*MultiTexCoord1fvARB)( GLcontext *, const int * );
+ struct dynfn *(*FogCoordfEXT)( GLcontext *, const int * );
+ struct dynfn *(*FogCoordfvEXT)( GLcontext *, const int * );
+};
+
+
+
+struct r200_prim {
+ GLuint start;
+ GLuint end;
+ GLuint prim;
+};
+
+ /* A maximum total of 29 elements per vertex: 3 floats for position, 3
+ * floats for normal, 4 floats for color, 4 bytes for secondary color,
+ * 3 floats for each texture unit (18 floats total).
+ *
+ * we maybe need add. 4 to prevent segfault if someone specifies
+ * GL_TEXTURE6/GL_TEXTURE7 (esp. for the codegen-path) (FIXME: )
+ *
+ * The position data is never actually stored here, so 3 elements could be
+ * trimmed out of the buffer.
+ */
+
+#define R200_MAX_VERTEX_SIZE ((3*6)+11)
+
+struct r200_vbinfo {
+ GLint counter, initial_counter;
+ GLint *dmaptr;
+ void (*notify)( void );
+ GLint vertex_size;
+
+ union { float f; int i; r200_color_t color; } vertex[R200_MAX_VERTEX_SIZE];
+
+ GLfloat *normalptr;
+ GLfloat *floatcolorptr;
+ GLfloat *fogptr;
+ r200_color_t *colorptr;
+ GLfloat *floatspecptr;
+ r200_color_t *specptr;
+ GLfloat *texcoordptr[8]; /* 6 (TMU) + 2 for r200_vtxfmt_c.c when GL_TEXTURE6/7 */
+
+
+ GLenum *prim; /* &ctx->Driver.CurrentExecPrimitive */
+ GLuint primflags;
+ GLboolean enabled; /* *_NO_VTXFMT / *_NO_TCL env vars */
+ GLboolean installed;
+ GLboolean fell_back;
+ GLboolean recheck;
+ GLint nrverts;
+ GLuint vtxfmt_0, vtxfmt_1;
+
+ GLuint installed_vertex_format;
+ GLuint installed_color_3f_sz;
+
+ struct r200_prim primlist[R200_MAX_PRIMS];
+ int nrprims;
+
+ struct dfn_lists dfn_cache;
+ struct dfn_generators codegen;
+ GLvertexformat vtxfmt;
+};
+
+
+struct r200_context {
+ GLcontext *glCtx; /* Mesa context */
+
+ /* Driver and hardware state management
+ */
+ struct r200_hw_state hw;
+ struct r200_state state;
+
+ /* Texture object bookkeeping
+ */
+ unsigned nr_heaps;
+ driTexHeap * texture_heaps[ R200_NR_TEX_HEAPS ];
+ driTextureObject swapped;
+ int texture_depth;
+ float initialMaxAnisotropy;
+
+ /* Rasterization and vertex state:
+ */
+ GLuint TclFallback;
+ GLuint Fallback;
+ GLuint NewGLState;
+ GLuint tnl_index; /* index of bits for last tnl_install_attrs */
+
+ /* Vertex buffers
+ */
+ struct r200_ioctl ioctl;
+ struct r200_dma dma;
+ struct r200_store store;
+ /* A full state emit as of the first state emit in the main store, in case
+ * the context is lost.
+ */
+ struct r200_store backup_store;
+
+ /* Page flipping
+ */
+ GLuint doPageFlip;
+
+ /* Busy waiting
+ */
+ GLuint do_usleeps;
+ GLuint do_irqs;
+ GLuint irqsEmitted;
+ drm_radeon_irq_wait_t iw;
+
+ /* Clientdata textures;
+ */
+ GLuint prefer_gart_client_texturing;
+
+ /* Drawable, cliprect and scissor information
+ */
+ GLuint numClipRects; /* Cliprects for the draw buffer */
+ drm_clip_rect_t *pClipRects;
+ unsigned int lastStamp;
+ GLboolean lost_context;
+ GLboolean save_on_next_emit;
+ r200ScreenPtr r200Screen; /* Screen private DRI data */
+ drm_radeon_sarea_t *sarea; /* Private SAREA data */
+
+ /* TCL stuff
+ */
+ GLmatrix TexGenMatrix[R200_MAX_TEXTURE_UNITS];
+ GLboolean recheck_texgen[R200_MAX_TEXTURE_UNITS];
+ GLboolean TexGenNeedNormals[R200_MAX_TEXTURE_UNITS];
+ GLuint TexMatEnabled;
+ GLuint TexMatCompSel;
+ GLuint TexGenEnabled;
+ GLuint TexGenCompSel;
+ GLmatrix tmpmat;
+
+ /* VBI / buffer swap
+ */
+ GLuint vbl_seq;
+ GLuint vblank_flags;
+
+ int64_t swap_ust;
+ int64_t swap_missed_ust;
+
+ GLuint swap_count;
+ GLuint swap_missed_count;
+
+
+ /* r200_tcl.c
+ */
+ struct r200_tcl_info tcl;
+
+ /* r200_swtcl.c
+ */
+ struct r200_swtcl_info swtcl;
+
+ /* r200_vtxfmt.c
+ */
+ struct r200_vbinfo vb;
+
+ /* Mirrors of some DRI state
+ */
+ struct r200_dri_mirror dri;
+
+ /* Configuration cache
+ */
+ driOptionCache optionCache;
+
+ GLboolean using_hyperz;
+ GLboolean texmicrotile;
+};
+
+#define R200_CONTEXT(ctx) ((r200ContextPtr)(ctx->DriverCtx))
+
+
+static __inline GLuint r200PackColor( GLuint cpp,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a )
+{
+ switch ( cpp ) {
+ case 2:
+ return PACK_COLOR_565( r, g, b );
+ case 4:
+ return PACK_COLOR_8888( a, r, g, b );
+ default:
+ return 0;
+ }
+}
+
+
+extern void r200DestroyContext( __DRIcontextPrivate *driContextPriv );
+extern GLboolean r200CreateContext( const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate);
+extern void r200SwapBuffers( __DRIdrawablePrivate *dPriv );
+extern GLboolean r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv );
+extern GLboolean r200UnbindContext( __DRIcontextPrivate *driContextPriv );
+
+/* ================================================================
+ * Debugging:
+ */
+#define DO_DEBUG 1
+
+#if DO_DEBUG
+extern int R200_DEBUG;
+#else
+#define R200_DEBUG 0
+#endif
+
+#define DEBUG_TEXTURE 0x001
+#define DEBUG_STATE 0x002
+#define DEBUG_IOCTL 0x004
+#define DEBUG_PRIMS 0x008
+#define DEBUG_VERTS 0x010
+#define DEBUG_FALLBACKS 0x020
+#define DEBUG_VFMT 0x040
+#define DEBUG_CODEGEN 0x080
+#define DEBUG_VERBOSE 0x100
+#define DEBUG_DRI 0x200
+#define DEBUG_DMA 0x400
+#define DEBUG_SANITY 0x800
+#define DEBUG_SYNC 0x1000
+#define DEBUG_PIXEL 0x2000
+#define DEBUG_MEMORY 0x4000
+
+#endif /* __R200_CONTEXT_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_ioctl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_ioctl.c
new file mode 100644
index 000000000..a2336ce4f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_ioctl.c
@@ -0,0 +1,966 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_ioctl.c,v 1.4 2002/12/17 00:32:56 dawes Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include <sched.h>
+#include <errno.h>
+
+#include "glheader.h"
+#include "imports.h"
+#include "macros.h"
+#include "context.h"
+#include "swrast/swrast.h"
+
+#include "r200_context.h"
+#include "r200_state.h"
+#include "r200_ioctl.h"
+#include "r200_tcl.h"
+#include "r200_sanity.h"
+#include "radeon_reg.h"
+
+#include "vblank.h"
+
+
+#define R200_TIMEOUT 512
+#define R200_IDLE_RETRY 16
+
+
+static void r200WaitForIdle( r200ContextPtr rmesa );
+
+
+/* At this point we were in FlushCmdBufLocked but we had lost our context, so
+ * we need to unwire our current cmdbuf, hook the one with the saved state in
+ * it, flush it, and then put the current one back. This is so commands at the
+ * start of a cmdbuf can rely on the state being kept from the previous one.
+ */
+static void r200BackUpAndEmitLostStateLocked( r200ContextPtr rmesa )
+{
+ GLuint nr_released_bufs;
+ struct r200_store saved_store;
+
+ if (rmesa->backup_store.cmd_used == 0)
+ return;
+
+ if (R200_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "Emitting backup state on lost context\n");
+
+ rmesa->lost_context = GL_FALSE;
+
+ nr_released_bufs = rmesa->dma.nr_released_bufs;
+ saved_store = rmesa->store;
+ rmesa->dma.nr_released_bufs = 0;
+ rmesa->store = rmesa->backup_store;
+ r200FlushCmdBufLocked( rmesa, __FUNCTION__ );
+ rmesa->dma.nr_released_bufs = nr_released_bufs;
+ rmesa->store = saved_store;
+}
+
+int r200FlushCmdBufLocked( r200ContextPtr rmesa, const char * caller )
+{
+ int ret, i;
+ drm_radeon_cmd_buffer_t cmd;
+
+ if (rmesa->lost_context)
+ r200BackUpAndEmitLostStateLocked( rmesa );
+
+ if (R200_DEBUG & DEBUG_IOCTL) {
+ fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
+
+ if (0 & R200_DEBUG & DEBUG_VERBOSE)
+ for (i = 0 ; i < rmesa->store.cmd_used ; i += 4 )
+ fprintf(stderr, "%d: %x\n", i/4,
+ *(int *)(&rmesa->store.cmd_buf[i]));
+ }
+
+ if (R200_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "%s: Releasing %d buffers\n", __FUNCTION__,
+ rmesa->dma.nr_released_bufs);
+
+
+ if (R200_DEBUG & DEBUG_SANITY) {
+ if (rmesa->state.scissor.enabled)
+ ret = r200SanityCmdBuffer( rmesa,
+ rmesa->state.scissor.numClipRects,
+ rmesa->state.scissor.pClipRects);
+ else
+ ret = r200SanityCmdBuffer( rmesa,
+ rmesa->numClipRects,
+ rmesa->pClipRects);
+ if (ret) {
+ fprintf(stderr, "drmSanityCommandWrite: %d\n", ret);
+ goto out;
+ }
+ }
+
+
+ if (R200_DEBUG & DEBUG_MEMORY) {
+ if (! driValidateTextureHeaps( rmesa->texture_heaps, rmesa->nr_heaps,
+ & rmesa->swapped ) ) {
+ fprintf( stderr, "%s: texture memory is inconsistent - expect "
+ "mangled textures\n", __FUNCTION__ );
+ }
+ }
+
+
+ cmd.bufsz = rmesa->store.cmd_used;
+ cmd.buf = rmesa->store.cmd_buf;
+
+ if (rmesa->state.scissor.enabled) {
+ cmd.nbox = rmesa->state.scissor.numClipRects;
+ cmd.boxes = (drm_clip_rect_t *)rmesa->state.scissor.pClipRects;
+ } else {
+ cmd.nbox = rmesa->numClipRects;
+ cmd.boxes = (drm_clip_rect_t *)rmesa->pClipRects;
+ }
+
+ ret = drmCommandWrite( rmesa->dri.fd,
+ DRM_RADEON_CMDBUF,
+ &cmd, sizeof(cmd) );
+
+ if (ret)
+ fprintf(stderr, "drmCommandWrite: %d\n", ret);
+
+ if (R200_DEBUG & DEBUG_SYNC) {
+ fprintf(stderr, "\nSyncing in %s\n\n", __FUNCTION__);
+ r200WaitForIdleLocked( rmesa );
+ }
+
+
+ out:
+ rmesa->store.primnr = 0;
+ rmesa->store.statenr = 0;
+ rmesa->store.cmd_used = 0;
+ rmesa->dma.nr_released_bufs = 0;
+ rmesa->save_on_next_emit = 1;
+
+ return ret;
+}
+
+
+/* Note: does not emit any commands to avoid recursion on
+ * r200AllocCmdBuf.
+ */
+void r200FlushCmdBuf( r200ContextPtr rmesa, const char *caller )
+{
+ int ret;
+
+ LOCK_HARDWARE( rmesa );
+
+ ret = r200FlushCmdBufLocked( rmesa, caller );
+
+ UNLOCK_HARDWARE( rmesa );
+
+ if (ret) {
+ fprintf(stderr, "drmRadeonCmdBuffer: %d (exiting)\n", ret);
+ exit(ret);
+ }
+}
+
+
+/* =============================================================
+ * Hardware vertex buffer handling
+ */
+
+
+void r200RefillCurrentDmaRegion( r200ContextPtr rmesa )
+{
+ struct r200_dma_buffer *dmabuf;
+ int fd = rmesa->dri.fd;
+ int index = 0;
+ int size = 0;
+ drmDMAReq dma;
+ int ret;
+
+ if (R200_DEBUG & (DEBUG_IOCTL|DEBUG_DMA))
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (rmesa->dma.flush) {
+ rmesa->dma.flush( rmesa );
+ }
+
+ if (rmesa->dma.current.buf)
+ r200ReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );
+
+ if (rmesa->dma.nr_released_bufs > 4)
+ r200FlushCmdBuf( rmesa, __FUNCTION__ );
+
+ dma.context = rmesa->dri.hwContext;
+ dma.send_count = 0;
+ dma.send_list = NULL;
+ dma.send_sizes = NULL;
+ dma.flags = 0;
+ dma.request_count = 1;
+ dma.request_size = RADEON_BUFFER_SIZE;
+ dma.request_list = &index;
+ dma.request_sizes = &size;
+ dma.granted_count = 0;
+
+ LOCK_HARDWARE(rmesa); /* no need to validate */
+
+ while (1) {
+ ret = drmDMA( fd, &dma );
+ if (ret == 0)
+ break;
+
+ if (rmesa->dma.nr_released_bufs) {
+ r200FlushCmdBufLocked( rmesa, __FUNCTION__ );
+ }
+
+ if (rmesa->do_usleeps) {
+ UNLOCK_HARDWARE( rmesa );
+ DO_USLEEP( 1 );
+ LOCK_HARDWARE( rmesa );
+ }
+ }
+
+ UNLOCK_HARDWARE(rmesa);
+
+ if (R200_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "Allocated buffer %d\n", index);
+
+ dmabuf = CALLOC_STRUCT( r200_dma_buffer );
+ dmabuf->buf = &rmesa->r200Screen->buffers->list[index];
+ dmabuf->refcount = 1;
+
+ rmesa->dma.current.buf = dmabuf;
+ rmesa->dma.current.address = dmabuf->buf->address;
+ rmesa->dma.current.end = dmabuf->buf->total;
+ rmesa->dma.current.start = 0;
+ rmesa->dma.current.ptr = 0;
+}
+
+void r200ReleaseDmaRegion( r200ContextPtr rmesa,
+ struct r200_dma_region *region,
+ const char *caller )
+{
+ if (R200_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
+
+ if (!region->buf)
+ return;
+
+ if (rmesa->dma.flush)
+ rmesa->dma.flush( rmesa );
+
+ if (--region->buf->refcount == 0) {
+ drm_radeon_cmd_header_t *cmd;
+
+ if (R200_DEBUG & (DEBUG_IOCTL|DEBUG_DMA))
+ fprintf(stderr, "%s -- DISCARD BUF %d\n", __FUNCTION__,
+ region->buf->buf->idx);
+
+ cmd = (drm_radeon_cmd_header_t *)r200AllocCmdBuf( rmesa, sizeof(*cmd),
+ __FUNCTION__ );
+ cmd->dma.cmd_type = RADEON_CMD_DMA_DISCARD;
+ cmd->dma.buf_idx = region->buf->buf->idx;
+ FREE(region->buf);
+ rmesa->dma.nr_released_bufs++;
+ }
+
+ region->buf = NULL;
+ region->start = 0;
+}
+
+/* Allocates a region from rmesa->dma.current. If there isn't enough
+ * space in current, grab a new buffer (and discard what was left of current)
+ */
+void r200AllocDmaRegion( r200ContextPtr rmesa,
+ struct r200_dma_region *region,
+ int bytes,
+ int alignment )
+{
+ if (R200_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s %d\n", __FUNCTION__, bytes);
+
+ if (rmesa->dma.flush)
+ rmesa->dma.flush( rmesa );
+
+ if (region->buf)
+ r200ReleaseDmaRegion( rmesa, region, __FUNCTION__ );
+
+ alignment--;
+ rmesa->dma.current.start = rmesa->dma.current.ptr =
+ (rmesa->dma.current.ptr + alignment) & ~alignment;
+
+ if ( rmesa->dma.current.ptr + bytes > rmesa->dma.current.end )
+ r200RefillCurrentDmaRegion( rmesa );
+
+ region->start = rmesa->dma.current.start;
+ region->ptr = rmesa->dma.current.start;
+ region->end = rmesa->dma.current.start + bytes;
+ region->address = rmesa->dma.current.address;
+ region->buf = rmesa->dma.current.buf;
+ region->buf->refcount++;
+
+ rmesa->dma.current.ptr += bytes; /* bug - if alignment > 7 */
+ rmesa->dma.current.start =
+ rmesa->dma.current.ptr = (rmesa->dma.current.ptr + 0x7) & ~0x7;
+
+ assert( rmesa->dma.current.ptr <= rmesa->dma.current.end );
+}
+
+void r200AllocDmaRegionVerts( r200ContextPtr rmesa,
+ struct r200_dma_region *region,
+ int numverts,
+ int vertsize,
+ int alignment )
+{
+ r200AllocDmaRegion( rmesa, region, vertsize * numverts, alignment );
+}
+
+/* ================================================================
+ * SwapBuffers with client-side throttling
+ */
+
+static u_int32_t r200GetLastFrame(r200ContextPtr rmesa)
+{
+ drm_radeon_getparam_t gp;
+ int ret;
+ u_int32_t frame;
+
+ gp.param = RADEON_PARAM_LAST_FRAME;
+ gp.value = (int *)&frame;
+ ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_GETPARAM,
+ &gp, sizeof(gp) );
+ if ( ret ) {
+ fprintf( stderr, "%s: drmRadeonGetParam: %d\n", __FUNCTION__, ret );
+ exit(1);
+ }
+
+ return frame;
+}
+
+static void r200EmitIrqLocked( r200ContextPtr rmesa )
+{
+ drm_radeon_irq_emit_t ie;
+ int ret;
+
+ ie.irq_seq = &rmesa->iw.irq_seq;
+ ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_IRQ_EMIT,
+ &ie, sizeof(ie) );
+ if ( ret ) {
+ fprintf( stderr, "%s: drmRadeonIrqEmit: %d\n", __FUNCTION__, ret );
+ exit(1);
+ }
+}
+
+
+static void r200WaitIrq( r200ContextPtr rmesa )
+{
+ int ret;
+
+ do {
+ ret = drmCommandWrite( rmesa->dri.fd, DRM_RADEON_IRQ_WAIT,
+ &rmesa->iw, sizeof(rmesa->iw) );
+ } while (ret && (errno == EINTR || errno == EAGAIN));
+
+ if ( ret ) {
+ fprintf( stderr, "%s: drmRadeonIrqWait: %d\n", __FUNCTION__, ret );
+ exit(1);
+ }
+}
+
+
+static void r200WaitForFrameCompletion( r200ContextPtr rmesa )
+{
+ drm_radeon_sarea_t *sarea = rmesa->sarea;
+
+ if (rmesa->do_irqs) {
+ if (r200GetLastFrame(rmesa) < sarea->last_frame) {
+ if (!rmesa->irqsEmitted) {
+ while (r200GetLastFrame (rmesa) < sarea->last_frame)
+ ;
+ }
+ else {
+ UNLOCK_HARDWARE( rmesa );
+ r200WaitIrq( rmesa );
+ LOCK_HARDWARE( rmesa );
+ }
+ rmesa->irqsEmitted = 10;
+ }
+
+ if (rmesa->irqsEmitted) {
+ r200EmitIrqLocked( rmesa );
+ rmesa->irqsEmitted--;
+ }
+ }
+ else {
+ while (r200GetLastFrame (rmesa) < sarea->last_frame) {
+ UNLOCK_HARDWARE( rmesa );
+ if (rmesa->do_usleeps)
+ DO_USLEEP( 1 );
+ LOCK_HARDWARE( rmesa );
+ }
+ }
+}
+
+
+
+/* Copy the back color buffer to the front color buffer.
+ */
+void r200CopyBuffer( const __DRIdrawablePrivate *dPriv )
+{
+ r200ContextPtr rmesa;
+ GLint nbox, i, ret;
+ GLboolean missed_target;
+ int64_t ust;
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ rmesa = (r200ContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ if ( R200_DEBUG & DEBUG_IOCTL ) {
+ fprintf( stderr, "\n%s( %p )\n\n", __FUNCTION__, (void *)rmesa->glCtx );
+ }
+
+ R200_FIREVERTICES( rmesa );
+
+ LOCK_HARDWARE( rmesa );
+
+
+ /* Throttle the frame rate -- only allow one pending swap buffers
+ * request at a time.
+ */
+ r200WaitForFrameCompletion( rmesa );
+ UNLOCK_HARDWARE( rmesa );
+ driWaitForVBlank( dPriv, & rmesa->vbl_seq, rmesa->vblank_flags, & missed_target );
+ LOCK_HARDWARE( rmesa );
+
+ nbox = dPriv->numClipRects; /* must be in locked region */
+
+ for ( i = 0 ; i < nbox ; ) {
+ GLint nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS , nbox );
+ drm_clip_rect_t *box = dPriv->pClipRects;
+ drm_clip_rect_t *b = rmesa->sarea->boxes;
+ GLint n = 0;
+
+ for ( ; i < nr ; i++ ) {
+ *b++ = box[i];
+ n++;
+ }
+ rmesa->sarea->nbox = n;
+
+ ret = drmCommandNone( rmesa->dri.fd, DRM_RADEON_SWAP );
+
+ if ( ret ) {
+ fprintf( stderr, "DRM_R200_SWAP_BUFFERS: return = %d\n", ret );
+ UNLOCK_HARDWARE( rmesa );
+ exit( 1 );
+ }
+ }
+
+ UNLOCK_HARDWARE( rmesa );
+ rmesa->hw.all_dirty = GL_TRUE;
+
+ rmesa->swap_count++;
+ (*dri_interface->getUST)( & ust );
+ if ( missed_target ) {
+ rmesa->swap_missed_count++;
+ rmesa->swap_missed_ust = ust - rmesa->swap_ust;
+ }
+
+ rmesa->swap_ust = ust;
+
+ sched_yield();
+}
+
+void r200PageFlip( const __DRIdrawablePrivate *dPriv )
+{
+ r200ContextPtr rmesa;
+ GLint ret;
+ GLboolean missed_target;
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ rmesa = (r200ContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ if ( R200_DEBUG & DEBUG_IOCTL ) {
+ fprintf(stderr, "%s: pfCurrentPage: %d\n", __FUNCTION__,
+ rmesa->sarea->pfCurrentPage);
+ }
+
+ R200_FIREVERTICES( rmesa );
+ LOCK_HARDWARE( rmesa );
+
+ if (!dPriv->numClipRects) {
+ UNLOCK_HARDWARE( rmesa );
+ usleep( 10000 ); /* throttle invisible client 10ms */
+ return;
+ }
+
+ /* Need to do this for the perf box placement:
+ */
+ {
+ drm_clip_rect_t *box = dPriv->pClipRects;
+ drm_clip_rect_t *b = rmesa->sarea->boxes;
+ b[0] = box[0];
+ rmesa->sarea->nbox = 1;
+ }
+
+ /* Throttle the frame rate -- only allow a few pending swap buffers
+ * request at a time.
+ */
+ r200WaitForFrameCompletion( rmesa );
+ UNLOCK_HARDWARE( rmesa );
+ driWaitForVBlank( dPriv, & rmesa->vbl_seq, rmesa->vblank_flags, & missed_target );
+ if ( missed_target ) {
+ rmesa->swap_missed_count++;
+ (void) (*dri_interface->getUST)( & rmesa->swap_missed_ust );
+ }
+ LOCK_HARDWARE( rmesa );
+
+ ret = drmCommandNone( rmesa->dri.fd, DRM_RADEON_FLIP );
+
+ UNLOCK_HARDWARE( rmesa );
+
+ if ( ret ) {
+ fprintf( stderr, "DRM_RADEON_FLIP: return = %d\n", ret );
+ exit( 1 );
+ }
+
+ rmesa->swap_count++;
+ (void) (*dri_interface->getUST)( & rmesa->swap_ust );
+
+ if ( rmesa->sarea->pfCurrentPage == 1 ) {
+ rmesa->state.color.drawOffset = rmesa->r200Screen->frontOffset;
+ rmesa->state.color.drawPitch = rmesa->r200Screen->frontPitch;
+ } else {
+ rmesa->state.color.drawOffset = rmesa->r200Screen->backOffset;
+ rmesa->state.color.drawPitch = rmesa->r200Screen->backPitch;
+ }
+
+ R200_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = rmesa->state.color.drawOffset
+ + rmesa->r200Screen->fbLocation;
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = rmesa->state.color.drawPitch;
+ if (rmesa->sarea->tiling_enabled) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;
+ }
+}
+
+
+/* ================================================================
+ * Buffer clear
+ */
+static void r200Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+ GLuint flags = 0;
+ GLuint color_mask = 0;
+ GLint ret, i;
+
+ if ( R200_DEBUG & DEBUG_IOCTL ) {
+ fprintf( stderr, "%s: all=%d cx=%d cy=%d cw=%d ch=%d\n",
+ __FUNCTION__, all, cx, cy, cw, ch );
+ }
+
+ {
+ LOCK_HARDWARE( rmesa );
+ UNLOCK_HARDWARE( rmesa );
+ if ( dPriv->numClipRects == 0 )
+ return;
+ }
+
+ r200Flush( ctx );
+
+ if ( mask & BUFFER_BIT_FRONT_LEFT ) {
+ flags |= RADEON_FRONT;
+ color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
+ }
+
+ if ( mask & BUFFER_BIT_BACK_LEFT ) {
+ flags |= RADEON_BACK;
+ color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
+ mask &= ~BUFFER_BIT_BACK_LEFT;
+ }
+
+ if ( mask & BUFFER_BIT_DEPTH ) {
+ flags |= RADEON_DEPTH;
+ mask &= ~BUFFER_BIT_DEPTH;
+ }
+
+ if ( (mask & BUFFER_BIT_STENCIL) && rmesa->state.stencil.hwBuffer ) {
+ flags |= RADEON_STENCIL;
+ mask &= ~BUFFER_BIT_STENCIL;
+ }
+
+ if ( mask ) {
+ if (R200_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "%s: swrast clear, mask: %x\n", __FUNCTION__, mask);
+ _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
+ }
+
+ if ( !flags )
+ return;
+
+ if (rmesa->using_hyperz) {
+ flags |= RADEON_USE_COMP_ZBUF;
+/* if (rmesa->r200Screen->chipset & R200_CHIPSET_REAL_R200)
+ flags |= RADEON_USE_HIERZ; */
+ if (!(rmesa->state.stencil.hwBuffer) ||
+ ((flags & RADEON_DEPTH) && (flags & RADEON_STENCIL) &&
+ ((rmesa->state.stencil.clear & R200_STENCIL_WRITE_MASK) == R200_STENCIL_WRITE_MASK))) {
+ flags |= RADEON_CLEAR_FASTZ;
+ }
+ }
+
+ /* Flip top to bottom */
+ cx += dPriv->x;
+ cy = dPriv->y + dPriv->h - cy - ch;
+
+ LOCK_HARDWARE( rmesa );
+
+ /* Throttle the number of clear ioctls we do.
+ */
+ while ( 1 ) {
+ drm_radeon_getparam_t gp;
+ int ret;
+ int clear;
+
+ gp.param = RADEON_PARAM_LAST_CLEAR;
+ gp.value = (int *)&clear;
+ ret = drmCommandWriteRead( rmesa->dri.fd,
+ DRM_RADEON_GETPARAM, &gp, sizeof(gp) );
+
+ if ( ret ) {
+ fprintf( stderr, "%s: drmRadeonGetParam: %d\n", __FUNCTION__, ret );
+ exit(1);
+ }
+
+ /* Clear throttling needs more thought.
+ */
+ if ( rmesa->sarea->last_clear - clear <= 25 ) {
+ break;
+ }
+
+ if (rmesa->do_usleeps) {
+ UNLOCK_HARDWARE( rmesa );
+ DO_USLEEP( 1 );
+ LOCK_HARDWARE( rmesa );
+ }
+ }
+
+ /* Send current state to the hardware */
+ r200FlushCmdBufLocked( rmesa, __FUNCTION__ );
+
+ for ( i = 0 ; i < dPriv->numClipRects ; ) {
+ GLint nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS, dPriv->numClipRects );
+ drm_clip_rect_t *box = dPriv->pClipRects;
+ drm_clip_rect_t *b = rmesa->sarea->boxes;
+ drm_radeon_clear_t clear;
+ drm_radeon_clear_rect_t depth_boxes[RADEON_NR_SAREA_CLIPRECTS];
+ GLint n = 0;
+
+ if ( !all ) {
+ for ( ; i < nr ; i++ ) {
+ GLint x = box[i].x1;
+ GLint y = box[i].y1;
+ GLint w = box[i].x2 - x;
+ GLint h = box[i].y2 - y;
+
+ 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 ) continue;
+ if ( h <= 0 ) continue;
+
+ b->x1 = x;
+ b->y1 = y;
+ b->x2 = x + w;
+ b->y2 = y + h;
+ b++;
+ n++;
+ }
+ } else {
+ for ( ; i < nr ; i++ ) {
+ *b++ = box[i];
+ n++;
+ }
+ }
+
+ rmesa->sarea->nbox = n;
+
+ clear.flags = flags;
+ clear.clear_color = rmesa->state.color.clear;
+ clear.clear_depth = rmesa->state.depth.clear; /* needed for hyperz */
+ clear.color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
+ clear.depth_mask = rmesa->state.stencil.clear;
+ clear.depth_boxes = depth_boxes;
+
+ n--;
+ b = rmesa->sarea->boxes;
+ for ( ; n >= 0 ; n-- ) {
+ depth_boxes[n].f[CLEAR_X1] = (float)b[n].x1;
+ depth_boxes[n].f[CLEAR_Y1] = (float)b[n].y1;
+ depth_boxes[n].f[CLEAR_X2] = (float)b[n].x2;
+ depth_boxes[n].f[CLEAR_Y2] = (float)b[n].y2;
+ depth_boxes[n].f[CLEAR_DEPTH] = ctx->Depth.Clear;
+ }
+
+ ret = drmCommandWrite( rmesa->dri.fd, DRM_RADEON_CLEAR,
+ &clear, sizeof(clear));
+
+
+ if ( ret ) {
+ UNLOCK_HARDWARE( rmesa );
+ fprintf( stderr, "DRM_RADEON_CLEAR: return = %d\n", ret );
+ exit( 1 );
+ }
+ }
+
+ UNLOCK_HARDWARE( rmesa );
+ rmesa->hw.all_dirty = GL_TRUE;
+}
+
+
+void r200WaitForIdleLocked( r200ContextPtr rmesa )
+{
+ int ret;
+ int i = 0;
+
+ do {
+ ret = drmCommandNone( rmesa->dri.fd, DRM_RADEON_CP_IDLE);
+ if (ret)
+ DO_USLEEP( 1 );
+ } while (ret && ++i < 100);
+
+ if ( ret < 0 ) {
+ UNLOCK_HARDWARE( rmesa );
+ fprintf( stderr, "Error: R200 timed out... exiting\n" );
+ exit( -1 );
+ }
+}
+
+
+static void r200WaitForIdle( r200ContextPtr rmesa )
+{
+ LOCK_HARDWARE(rmesa);
+ r200WaitForIdleLocked( rmesa );
+ UNLOCK_HARDWARE(rmesa);
+}
+
+
+void r200Flush( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT( ctx );
+
+ if (R200_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (rmesa->dma.flush)
+ rmesa->dma.flush( rmesa );
+
+ r200EmitState( rmesa );
+
+ if (rmesa->store.cmd_used)
+ r200FlushCmdBuf( rmesa, __FUNCTION__ );
+}
+
+/* Make sure all commands have been sent to the hardware and have
+ * completed processing.
+ */
+void r200Finish( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ r200Flush( ctx );
+
+ if (rmesa->do_irqs) {
+ LOCK_HARDWARE( rmesa );
+ r200EmitIrqLocked( rmesa );
+ UNLOCK_HARDWARE( rmesa );
+ r200WaitIrq( rmesa );
+ }
+ else
+ r200WaitForIdle( rmesa );
+}
+
+
+/* This version of AllocateMemoryMESA allocates only GART memory, and
+ * only does so after the point at which the driver has been
+ * initialized.
+ *
+ * Theoretically a valid context isn't required. However, in this
+ * implementation, it is, as I'm using the hardware lock to protect
+ * the kernel data structures, and the current context to get the
+ * device fd.
+ */
+void *r200AllocateMemoryMESA(__DRInativeDisplay *dpy, int scrn, GLsizei size,
+ GLfloat readfreq, GLfloat writefreq,
+ GLfloat priority)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa;
+ int region_offset;
+ drm_radeon_mem_alloc_t alloc;
+ int ret;
+
+ if (R200_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s sz %d %f/%f/%f\n", __FUNCTION__, size, readfreq,
+ writefreq, priority);
+
+ if (!ctx || !(rmesa = R200_CONTEXT(ctx)) || !rmesa->r200Screen->gartTextures.map)
+ return NULL;
+
+ if (getenv("R200_NO_ALLOC"))
+ return NULL;
+
+ if (rmesa->dri.drmMinor < 6)
+ return NULL;
+
+ alloc.region = RADEON_MEM_REGION_GART;
+ alloc.alignment = 0;
+ alloc.size = size;
+ alloc.region_offset = &region_offset;
+
+ ret = drmCommandWriteRead( rmesa->r200Screen->driScreen->fd,
+ DRM_RADEON_ALLOC,
+ &alloc, sizeof(alloc));
+
+ if (ret) {
+ fprintf(stderr, "%s: DRM_RADEON_ALLOC ret %d\n", __FUNCTION__, ret);
+ return NULL;
+ }
+
+ {
+ char *region_start = (char *)rmesa->r200Screen->gartTextures.map;
+ return (void *)(region_start + region_offset);
+ }
+}
+
+
+/* Called via glXFreeMemoryMESA() */
+void r200FreeMemoryMESA(__DRInativeDisplay *dpy, int scrn, GLvoid *pointer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa;
+ ptrdiff_t region_offset;
+ drm_radeon_mem_free_t memfree;
+ int ret;
+
+ if (R200_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s %p\n", __FUNCTION__, pointer);
+
+ if (!ctx || !(rmesa = R200_CONTEXT(ctx)) || !rmesa->r200Screen->gartTextures.map) {
+ fprintf(stderr, "%s: no context\n", __FUNCTION__);
+ return;
+ }
+
+ if (rmesa->dri.drmMinor < 6)
+ return;
+
+ region_offset = (char *)pointer - (char *)rmesa->r200Screen->gartTextures.map;
+
+ if (region_offset < 0 ||
+ region_offset > rmesa->r200Screen->gartTextures.size) {
+ fprintf(stderr, "offset %d outside range 0..%d\n", region_offset,
+ rmesa->r200Screen->gartTextures.size);
+ return;
+ }
+
+ memfree.region = RADEON_MEM_REGION_GART;
+ memfree.region_offset = region_offset;
+
+ ret = drmCommandWrite( rmesa->r200Screen->driScreen->fd,
+ DRM_RADEON_FREE,
+ &memfree, sizeof(memfree));
+
+ if (ret)
+ fprintf(stderr, "%s: DRM_RADEON_FREE ret %d\n", __FUNCTION__, ret);
+}
+
+/* Called via glXGetMemoryOffsetMESA() */
+GLuint r200GetMemoryOffsetMESA(__DRInativeDisplay *dpy, int scrn, const GLvoid *pointer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa;
+ GLuint card_offset;
+
+ if (!ctx || !(rmesa = R200_CONTEXT(ctx)) ) {
+ fprintf(stderr, "%s: no context\n", __FUNCTION__);
+ return ~0;
+ }
+
+ if (!r200IsGartMemory( rmesa, pointer, 0 ))
+ return ~0;
+
+ if (rmesa->dri.drmMinor < 6)
+ return ~0;
+
+ card_offset = r200GartOffsetFromVirtual( rmesa, pointer );
+
+ return card_offset - rmesa->r200Screen->gart_base;
+}
+
+GLboolean r200IsGartMemory( r200ContextPtr rmesa, const GLvoid *pointer,
+ GLint size )
+{
+ ptrdiff_t offset = (char *)pointer - (char *)rmesa->r200Screen->gartTextures.map;
+ int valid = (size >= 0 &&
+ offset >= 0 &&
+ offset + size < rmesa->r200Screen->gartTextures.size);
+
+ if (R200_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "r200IsGartMemory( %p ) : %d\n", pointer, valid );
+
+ return valid;
+}
+
+
+GLuint r200GartOffsetFromVirtual( r200ContextPtr rmesa, const GLvoid *pointer )
+{
+ ptrdiff_t offset = (char *)pointer - (char *)rmesa->r200Screen->gartTextures.map;
+
+ if (offset < 0 || offset > rmesa->r200Screen->gartTextures.size)
+ return ~0;
+ else
+ return rmesa->r200Screen->gart_texture_offset + offset;
+}
+
+
+
+void r200InitIoctlFuncs( struct dd_function_table *functions )
+{
+ functions->Clear = r200Clear;
+ functions->Finish = r200Finish;
+ functions->Flush = r200Flush;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_ioctl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_ioctl.h
new file mode 100644
index 000000000..8927acd7f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_ioctl.h
@@ -0,0 +1,215 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_ioctl.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R200_IOCTL_H__
+#define __R200_IOCTL_H__
+
+#include "simple_list.h"
+#include "radeon_dri.h"
+#include "r200_lock.h"
+
+#include "xf86drm.h"
+#include "drm.h"
+#include "radeon_drm.h"
+
+extern void r200EmitState( r200ContextPtr rmesa );
+extern void r200EmitVertexAOS( r200ContextPtr rmesa,
+ GLuint vertex_size,
+ GLuint offset );
+
+extern void r200EmitVbufPrim( r200ContextPtr rmesa,
+ GLuint primitive,
+ GLuint vertex_nr );
+
+extern void r200FlushElts( r200ContextPtr rmesa );
+
+extern GLushort *r200AllocEltsOpenEnded( r200ContextPtr rmesa,
+ GLuint primitive,
+ GLuint min_nr );
+
+extern void r200EmitAOS( r200ContextPtr rmesa,
+ struct r200_dma_region **regions,
+ GLuint n,
+ GLuint offset );
+
+extern void r200EmitBlit( r200ContextPtr rmesa,
+ GLuint color_fmt,
+ GLuint src_pitch,
+ GLuint src_offset,
+ GLuint dst_pitch,
+ GLuint dst_offset,
+ GLint srcx, GLint srcy,
+ GLint dstx, GLint dsty,
+ GLuint w, GLuint h );
+
+extern void r200EmitWait( r200ContextPtr rmesa, GLuint flags );
+
+extern void r200FlushCmdBuf( r200ContextPtr rmesa, const char * );
+extern int r200FlushCmdBufLocked( r200ContextPtr rmesa, const char * caller );
+
+extern void r200RefillCurrentDmaRegion( r200ContextPtr rmesa );
+
+extern void r200AllocDmaRegion( r200ContextPtr rmesa,
+ struct r200_dma_region *region,
+ int bytes,
+ int alignment );
+
+extern void r200AllocDmaRegionVerts( r200ContextPtr rmesa,
+ struct r200_dma_region *region,
+ int numverts,
+ int vertsize,
+ int alignment );
+
+extern void r200ReleaseDmaRegion( r200ContextPtr rmesa,
+ struct r200_dma_region *region,
+ const char *caller );
+
+extern void r200CopyBuffer( const __DRIdrawablePrivate *drawable );
+extern void r200PageFlip( const __DRIdrawablePrivate *drawable );
+extern void r200Flush( GLcontext *ctx );
+extern void r200Finish( GLcontext *ctx );
+extern void r200WaitForIdleLocked( r200ContextPtr rmesa );
+extern void r200WaitForVBlank( r200ContextPtr rmesa );
+extern void r200InitIoctlFuncs( struct dd_function_table *functions );
+
+extern void *r200AllocateMemoryMESA( __DRInativeDisplay *dpy, int scrn, GLsizei size, GLfloat readfreq,
+ GLfloat writefreq, GLfloat priority );
+extern void r200FreeMemoryMESA( __DRInativeDisplay *dpy, int scrn, GLvoid *pointer );
+extern GLuint r200GetMemoryOffsetMESA( __DRInativeDisplay *dpy, int scrn, const GLvoid *pointer );
+
+extern GLboolean r200IsGartMemory( r200ContextPtr rmesa, const GLvoid *pointer,
+ GLint size );
+
+extern GLuint r200GartOffsetFromVirtual( r200ContextPtr rmesa,
+ const GLvoid *pointer );
+
+void r200SetUpAtomList( r200ContextPtr rmesa );
+
+/* ================================================================
+ * Helper macros:
+ */
+
+/* Close off the last primitive, if it exists.
+ */
+#define R200_NEWPRIM( rmesa ) \
+do { \
+ if ( rmesa->dma.flush ) \
+ rmesa->dma.flush( rmesa ); \
+} while (0)
+
+/* Can accomodate several state changes and primitive changes without
+ * actually firing the buffer.
+ */
+#define R200_STATECHANGE( rmesa, ATOM ) \
+do { \
+ R200_NEWPRIM( rmesa ); \
+ rmesa->hw.ATOM.dirty = GL_TRUE; \
+ rmesa->hw.is_dirty = GL_TRUE; \
+} while (0)
+
+#define R200_DB_STATE( ATOM ) \
+ memcpy( rmesa->hw.ATOM.lastcmd, rmesa->hw.ATOM.cmd, \
+ rmesa->hw.ATOM.cmd_size * 4)
+
+static __inline int R200_DB_STATECHANGE(
+ r200ContextPtr rmesa,
+ struct r200_state_atom *atom )
+{
+ if (memcmp(atom->cmd, atom->lastcmd, atom->cmd_size*4)) {
+ int *tmp;
+ R200_NEWPRIM( rmesa );
+ atom->dirty = GL_TRUE;
+ rmesa->hw.is_dirty = GL_TRUE;
+ tmp = atom->cmd;
+ atom->cmd = atom->lastcmd;
+ atom->lastcmd = tmp;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+
+/* Fire the buffered vertices no matter what.
+ */
+#define R200_FIREVERTICES( rmesa ) \
+do { \
+ if ( rmesa->store.cmd_used || rmesa->dma.flush ) { \
+ r200Flush( rmesa->glCtx ); \
+ } \
+} while (0)
+
+/* Command lengths. Note that any time you ensure ELTS_BUFSZ or VBUF_BUFSZ
+ * are available, you will also be adding an rmesa->state.max_state_size because
+ * r200EmitState is called from within r200EmitVbufPrim and r200FlushElts.
+ */
+#define AOS_BUFSZ(nr) ((3 + ((nr / 2) * 3) + ((nr & 1) * 2)) * sizeof(int))
+#define VERT_AOS_BUFSZ (5 * sizeof(int))
+#define ELTS_BUFSZ(nr) (12 + nr * 2)
+#define VBUF_BUFSZ (3 * sizeof(int))
+
+/* Ensure that a minimum amount of space is available in the command buffer.
+ * This is used to ensure atomicity of state updates with the rendering requests
+ * that rely on them.
+ *
+ * An alternative would be to implement a "soft lock" such that when the buffer
+ * wraps at an inopportune time, we grab the lock, flush the current buffer,
+ * and hang on to the lock until the critical section is finished and we flush
+ * the buffer again and unlock.
+ */
+static __inline void r200EnsureCmdBufSpace( r200ContextPtr rmesa, int bytes )
+{
+ if (rmesa->store.cmd_used + bytes > R200_CMD_BUF_SZ)
+ r200FlushCmdBuf( rmesa, __FUNCTION__ );
+ assert( bytes <= R200_CMD_BUF_SZ );
+}
+
+/* Alloc space in the command buffer
+ */
+static __inline char *r200AllocCmdBuf( r200ContextPtr rmesa,
+ int bytes, const char *where )
+{
+ char * head;
+
+ if (rmesa->store.cmd_used + bytes > R200_CMD_BUF_SZ)
+ r200FlushCmdBuf( rmesa, where );
+
+ head = rmesa->store.cmd_buf + rmesa->store.cmd_used;
+ rmesa->store.cmd_used += bytes;
+ assert( rmesa->store.cmd_used <= R200_CMD_BUF_SZ );
+ return head;
+}
+
+#endif /* __R200_IOCTL_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_lock.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_lock.c
new file mode 100644
index 000000000..9b82c18d1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_lock.c
@@ -0,0 +1,127 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_lock.c,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+#include <string.h>
+
+#include "r200_context.h"
+#include "r200_lock.h"
+#include "r200_tex.h"
+#include "r200_state.h"
+#include "r200_ioctl.h"
+
+#if DEBUG_LOCKING
+char *prevLockFile = NULL;
+int prevLockLine = 0;
+#endif
+
+/* Turn on/off page flipping according to the flags in the sarea:
+ */
+static void
+r200UpdatePageFlipping( r200ContextPtr rmesa )
+{
+ int use_back;
+ rmesa->doPageFlip = rmesa->sarea->pfState;
+
+ use_back = (rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT);
+ use_back ^= (rmesa->sarea->pfCurrentPage == 1);
+
+ if (use_back) {
+ rmesa->state.color.drawOffset = rmesa->r200Screen->backOffset;
+ rmesa->state.color.drawPitch = rmesa->r200Screen->backPitch;
+ } else {
+ rmesa->state.color.drawOffset = rmesa->r200Screen->frontOffset;
+ rmesa->state.color.drawPitch = rmesa->r200Screen->frontPitch;
+ }
+
+ R200_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = rmesa->state.color.drawOffset
+ + rmesa->r200Screen->fbLocation;
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = rmesa->state.color.drawPitch;
+}
+
+
+
+/* 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.
+ */
+void r200GetLock( r200ContextPtr rmesa, GLuint flags )
+{
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+ __DRIscreenPrivate *sPriv = rmesa->dri.screen;
+ drm_radeon_sarea_t *sarea = rmesa->sarea;
+ int i;
+
+ drmGetLock( rmesa->dri.fd, rmesa->dri.hwContext, flags );
+
+ /* 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.
+ */
+ DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
+
+ if ( rmesa->lastStamp != dPriv->lastStamp ) {
+ r200UpdatePageFlipping( rmesa );
+ if (rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT)
+ r200SetCliprects( rmesa, GL_BACK_LEFT );
+ else
+ r200SetCliprects( rmesa, GL_FRONT_LEFT );
+ r200UpdateViewportOffset( rmesa->glCtx );
+ rmesa->lastStamp = dPriv->lastStamp;
+ }
+
+ R200_STATECHANGE( rmesa, ctx );
+ if (rmesa->sarea->tiling_enabled) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;
+ }
+ else rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] &= ~R200_COLOR_TILE_ENABLE;
+
+ if ( sarea->ctx_owner != rmesa->dri.hwContext ) {
+ sarea->ctx_owner = rmesa->dri.hwContext;
+ }
+
+ for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
+ DRI_AGE_TEXTURES( rmesa->texture_heaps[ i ] );
+ }
+
+ rmesa->lost_context = GL_TRUE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_lock.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_lock.h
new file mode 100644
index 000000000..e4c3a7e93
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_lock.h
@@ -0,0 +1,107 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_lock.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R200_LOCK_H__
+#define __R200_LOCK_H__
+
+extern void r200GetLock( r200ContextPtr rmesa, GLuint flags );
+
+/* Turn DEBUG_LOCKING on to find locking conflicts.
+ */
+#define DEBUG_LOCKING 0
+
+#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 and validate our state.
+ */
+#define LOCK_HARDWARE( rmesa ) \
+ do { \
+ char __ret = 0; \
+ DEBUG_CHECK_LOCK(); \
+ DRM_CAS( rmesa->dri.hwLock, rmesa->dri.hwContext, \
+ (DRM_LOCK_HELD | rmesa->dri.hwContext), __ret ); \
+ if ( __ret ) \
+ r200GetLock( rmesa, 0 ); \
+ DEBUG_LOCK(); \
+ } while (0)
+
+#define UNLOCK_HARDWARE( rmesa ) \
+ do { \
+ DRM_UNLOCK( rmesa->dri.fd, \
+ rmesa->dri.hwLock, \
+ rmesa->dri.hwContext ); \
+ DEBUG_RESET(); \
+ } while (0)
+
+#endif /* __R200_LOCK_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_maos.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_maos.c
new file mode 100644
index 000000000..23e1c962a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_maos.c
@@ -0,0 +1,15 @@
+
+
+/* Currently, can only use arrays, verts are not implemented, though
+ * verts are suspected to be faster.
+ * To get an idea how the verts path works, look at the radeon implementation.
+ */
+#include <string.h>
+
+#include "r200_context.h"
+#define R200_MAOS_VERTS 0
+#if (R200_MAOS_VERTS)
+#include "r200_maos_verts.c"
+#else
+#include "r200_maos_arrays.c"
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_maos.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_maos.h
new file mode 100644
index 000000000..b9e4d3c23
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_maos.h
@@ -0,0 +1,44 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_maos.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R200_MAOS_H__
+#define __R200_MAOS_H__
+
+#include "r200_context.h"
+
+extern void r200EmitArrays( GLcontext *ctx, GLuint inputs );
+extern void r200ReleaseArrays( GLcontext *ctx, GLuint newinputs );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_maos_arrays.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_maos_arrays.c
new file mode 100644
index 000000000..12ea462a4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_maos_arrays.c
@@ -0,0 +1,530 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_maos_arrays.c,v 1.3 2003/02/23 23:59:01 dawes Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "colormac.h"
+#include "imports.h"
+#include "macros.h"
+
+#include "swrast_setup/swrast_setup.h"
+#include "math/m_translate.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+
+#include "r200_context.h"
+#include "r200_ioctl.h"
+#include "r200_state.h"
+#include "r200_swtcl.h"
+#include "r200_maos.h"
+#include "r200_tcl.h"
+
+
+#if 0
+/* Usage:
+ * - from r200_tcl_render
+ * - call r200EmitArrays to ensure uptodate arrays in dma
+ * - emit primitives (new type?) which reference the data
+ * -- need to use elts for lineloop, quads, quadstrip/flat
+ * -- other primitives are all well-formed (need tristrip-1,fake-poly)
+ *
+ */
+static void emit_ubyte_rgba3( GLcontext *ctx,
+ struct r200_dma_region *rvb,
+ char *data,
+ int stride,
+ int count )
+{
+ int i;
+ r200_color_t *out = (r200_color_t *)(rvb->start + rvb->address);
+
+ if (R200_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d out %p\n",
+ __FUNCTION__, count, stride, (void *)out);
+
+ for (i = 0; i < count; i++) {
+ out->red = *data;
+ out->green = *(data+1);
+ out->blue = *(data+2);
+ out->alpha = 0xFF;
+ out++;
+ data += stride;
+ }
+}
+
+static void emit_ubyte_rgba4( GLcontext *ctx,
+ struct r200_dma_region *rvb,
+ char *data,
+ int stride,
+ int count )
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (R200_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d\n",
+ __FUNCTION__, count, stride);
+
+ if (stride == 4) {
+ for (i = 0; i < count; i++)
+ ((int *)out)[i] = LE32_TO_CPU(((int *)data)[i]);
+ } else {
+ for (i = 0; i < count; i++) {
+ *(int *)out++ = LE32_TO_CPU(*(int *)data);
+ data += stride;
+ }
+ }
+}
+
+
+static void emit_ubyte_rgba( GLcontext *ctx,
+ struct r200_dma_region *rvb,
+ char *data,
+ int size,
+ int stride,
+ int count )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if (R200_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s %d/%d\n", __FUNCTION__, count, size);
+
+ assert (!rvb->buf);
+
+ if (stride == 0) {
+ r200AllocDmaRegion( rmesa, rvb, 4, 4 );
+ count = 1;
+ rvb->aos_start = GET_START(rvb);
+ rvb->aos_stride = 0;
+ rvb->aos_size = 1;
+ }
+ else {
+ r200AllocDmaRegion( rmesa, rvb, 4 * count, 4 ); /* alignment? */
+ rvb->aos_start = GET_START(rvb);
+ rvb->aos_stride = 1;
+ rvb->aos_size = 1;
+ }
+
+ /* Emit the data
+ */
+ switch (size) {
+ case 3:
+ emit_ubyte_rgba3( ctx, rvb, data, stride, count );
+ break;
+ case 4:
+ emit_ubyte_rgba4( ctx, rvb, data, stride, count );
+ break;
+ default:
+ assert(0);
+ exit(1);
+ break;
+ }
+}
+#endif
+
+
+#if defined(USE_X86_ASM)
+#define COPY_DWORDS( dst, src, nr ) \
+do { \
+ int __tmp; \
+ __asm__ __volatile__( "rep ; movsl" \
+ : "=%c" (__tmp), "=D" (dst), "=S" (__tmp) \
+ : "0" (nr), \
+ "D" ((long)dst), \
+ "S" ((long)src) ); \
+} while (0)
+#else
+#define COPY_DWORDS( dst, src, nr ) \
+do { \
+ int j; \
+ for ( j = 0 ; j < nr ; j++ ) \
+ dst[j] = ((int *)src)[j]; \
+ dst += nr; \
+} while (0)
+#endif
+
+
+static void emit_vecfog( GLcontext *ctx,
+ struct r200_dma_region *rvb,
+ char *data,
+ int stride,
+ int count )
+{
+ int i;
+ GLfloat *out;
+
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if (R200_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d\n",
+ __FUNCTION__, count, stride);
+
+ assert (!rvb->buf);
+
+ if (stride == 0) {
+ r200AllocDmaRegion( rmesa, rvb, 4, 4 );
+ count = 1;
+ rvb->aos_start = GET_START(rvb);
+ rvb->aos_stride = 0;
+ rvb->aos_size = 1;
+ }
+ else {
+ r200AllocDmaRegion( rmesa, rvb, count * 4, 4 ); /* alignment? */
+ rvb->aos_start = GET_START(rvb);
+ rvb->aos_stride = 1;
+ rvb->aos_size = 1;
+ }
+
+ /* Emit the data
+ */
+ out = (GLfloat *)(rvb->address + rvb->start);
+ for (i = 0; i < count; i++) {
+ out[0] = r200ComputeFogBlendFactor( ctx, *(GLfloat *)data );
+ out++;
+ data += stride;
+ }
+
+}
+
+
+static void emit_vec4( GLcontext *ctx,
+ struct r200_dma_region *rvb,
+ char *data,
+ int stride,
+ int count )
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (R200_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d\n",
+ __FUNCTION__, count, stride);
+
+ if (stride == 4)
+ COPY_DWORDS( out, data, count );
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out++;
+ data += stride;
+ }
+}
+
+
+static void emit_vec8( GLcontext *ctx,
+ struct r200_dma_region *rvb,
+ char *data,
+ int stride,
+ int count )
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (R200_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d\n",
+ __FUNCTION__, count, stride);
+
+ if (stride == 8)
+ COPY_DWORDS( out, data, count*2 );
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out[1] = *(int *)(data+4);
+ out += 2;
+ data += stride;
+ }
+}
+
+static void emit_vec12( GLcontext *ctx,
+ struct r200_dma_region *rvb,
+ char *data,
+ int stride,
+ int count )
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (R200_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d out %p data %p\n",
+ __FUNCTION__, count, stride, (void *)out, (void *)data);
+
+ if (stride == 12)
+ COPY_DWORDS( out, data, count*3 );
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out[1] = *(int *)(data+4);
+ out[2] = *(int *)(data+8);
+ out += 3;
+ data += stride;
+ }
+}
+
+static void emit_vec16( GLcontext *ctx,
+ struct r200_dma_region *rvb,
+ char *data,
+ int stride,
+ int count )
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (R200_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d\n",
+ __FUNCTION__, count, stride);
+
+ if (stride == 16)
+ COPY_DWORDS( out, data, count*4 );
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out[1] = *(int *)(data+4);
+ out[2] = *(int *)(data+8);
+ out[3] = *(int *)(data+12);
+ out += 4;
+ data += stride;
+ }
+}
+
+
+static void emit_vector( GLcontext *ctx,
+ struct r200_dma_region *rvb,
+ char *data,
+ int size,
+ int stride,
+ int count )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if (R200_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d size %d stride %d\n",
+ __FUNCTION__, count, size, stride);
+
+ assert (!rvb->buf);
+
+ if (stride == 0) {
+ r200AllocDmaRegion( rmesa, rvb, size * 4, 4 );
+ count = 1;
+ rvb->aos_start = GET_START(rvb);
+ rvb->aos_stride = 0;
+ rvb->aos_size = size;
+ }
+ else {
+ r200AllocDmaRegion( rmesa, rvb, size * count * 4, 4 ); /* alignment? */
+ rvb->aos_start = GET_START(rvb);
+ rvb->aos_stride = size;
+ rvb->aos_size = size;
+ }
+
+ /* Emit the data
+ */
+ switch (size) {
+ case 1:
+ emit_vec4( ctx, rvb, data, stride, count );
+ break;
+ case 2:
+ emit_vec8( ctx, rvb, data, stride, count );
+ break;
+ case 3:
+ emit_vec12( ctx, rvb, data, stride, count );
+ break;
+ case 4:
+ emit_vec16( ctx, rvb, data, stride, count );
+ break;
+ default:
+ assert(0);
+ exit(1);
+ break;
+ }
+
+}
+
+
+
+/* Emit any changed arrays to new GART memory, re-emit a packet to
+ * update the arrays.
+ */
+void r200EmitArrays( GLcontext *ctx, GLuint inputs )
+{
+ r200ContextPtr rmesa = R200_CONTEXT( ctx );
+ struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
+ struct r200_dma_region **component = rmesa->tcl.aos_components;
+ GLuint nr = 0;
+ GLuint vfmt0 = 0, vfmt1 = 0;
+ GLuint count = VB->Count;
+ GLuint i;
+
+ if (1) {
+ if (!rmesa->tcl.obj.buf)
+ emit_vector( ctx,
+ &rmesa->tcl.obj,
+ (char *)VB->ObjPtr->data,
+ VB->ObjPtr->size,
+ VB->ObjPtr->stride,
+ count);
+
+ switch( VB->ObjPtr->size ) {
+ case 4: vfmt0 |= R200_VTX_W0;
+ case 3: vfmt0 |= R200_VTX_Z0;
+ case 2:
+ default:
+ break;
+ }
+ component[nr++] = &rmesa->tcl.obj;
+ }
+
+
+ if (inputs & VERT_BIT_NORMAL) {
+ if (!rmesa->tcl.norm.buf)
+ emit_vector( ctx,
+ &(rmesa->tcl.norm),
+ (char *)VB->NormalPtr->data,
+ 3,
+ VB->NormalPtr->stride,
+ count);
+
+ vfmt0 |= R200_VTX_N0;
+ component[nr++] = &rmesa->tcl.norm;
+ }
+
+ if (inputs & VERT_BIT_FOG) {
+ if (!rmesa->tcl.fog.buf)
+ emit_vecfog( ctx,
+ &(rmesa->tcl.fog),
+ (char *)VB->FogCoordPtr->data,
+ VB->FogCoordPtr->stride,
+ count);
+
+ vfmt0 |= R200_VTX_DISCRETE_FOG;
+ component[nr++] = &rmesa->tcl.fog;
+ }
+
+ if (inputs & VERT_BIT_COLOR0) {
+ int emitsize;
+
+ if (VB->ColorPtr[0]->size == 4 &&
+ (VB->ColorPtr[0]->stride != 0 ||
+ VB->ColorPtr[0]->data[0][3] != 1.0)) {
+ vfmt0 |= R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT;
+ emitsize = 4;
+ }
+ else {
+ vfmt0 |= R200_VTX_FP_RGB << R200_VTX_COLOR_0_SHIFT;
+ emitsize = 3;
+ }
+
+ if (!rmesa->tcl.rgba.buf)
+ emit_vector( ctx,
+ &(rmesa->tcl.rgba),
+ (char *)VB->ColorPtr[0]->data,
+ emitsize,
+ VB->ColorPtr[0]->stride,
+ count);
+
+ component[nr++] = &rmesa->tcl.rgba;
+ }
+
+
+ if (inputs & VERT_BIT_COLOR1) {
+ if (!rmesa->tcl.spec.buf) {
+ emit_vector( ctx,
+ &rmesa->tcl.spec,
+ (char *)VB->SecondaryColorPtr[0]->data,
+ 3,
+ VB->SecondaryColorPtr[0]->stride,
+ count);
+ }
+
+ /* How does this work?
+ */
+ vfmt0 |= R200_VTX_FP_RGB << R200_VTX_COLOR_1_SHIFT;
+ component[nr++] = &rmesa->tcl.spec;
+ }
+
+ for ( i = 0 ; i < ctx->Const.MaxTextureUnits ; i++ ) {
+ if (inputs & (VERT_BIT_TEX0 << i)) {
+ if (!rmesa->tcl.tex[i].buf)
+ emit_vector( ctx,
+ &(rmesa->tcl.tex[i]),
+ (char *)VB->TexCoordPtr[i]->data,
+ VB->TexCoordPtr[i]->size,
+ VB->TexCoordPtr[i]->stride,
+ count );
+
+ vfmt1 |= VB->TexCoordPtr[i]->size << (i * 3);
+ component[nr++] = &rmesa->tcl.tex[i];
+ }
+ }
+
+ if (vfmt0 != rmesa->hw.vtx.cmd[VTX_VTXFMT_0] ||
+ vfmt1 != rmesa->hw.vtx.cmd[VTX_VTXFMT_1]) {
+ R200_STATECHANGE( rmesa, vtx );
+ rmesa->hw.vtx.cmd[VTX_VTXFMT_0] = vfmt0;
+ rmesa->hw.vtx.cmd[VTX_VTXFMT_1] = vfmt1;
+ }
+
+ rmesa->tcl.nr_aos_components = nr;
+ rmesa->tcl.vertex_format = vfmt0;
+}
+
+
+void r200ReleaseArrays( GLcontext *ctx, GLuint newinputs )
+{
+ GLuint unit;
+ r200ContextPtr rmesa = R200_CONTEXT( ctx );
+
+/* if (R200_DEBUG & DEBUG_VERTS) */
+/* _tnl_print_vert_flags( __FUNCTION__, newinputs ); */
+
+ if (newinputs & VERT_BIT_POS)
+ r200ReleaseDmaRegion( rmesa, &rmesa->tcl.obj, __FUNCTION__ );
+
+ if (newinputs & VERT_BIT_NORMAL)
+ r200ReleaseDmaRegion( rmesa, &rmesa->tcl.norm, __FUNCTION__ );
+
+ if (newinputs & VERT_BIT_FOG)
+ r200ReleaseDmaRegion( rmesa, &rmesa->tcl.fog, __FUNCTION__ );
+
+ if (newinputs & VERT_BIT_COLOR0)
+ r200ReleaseDmaRegion( rmesa, &rmesa->tcl.rgba, __FUNCTION__ );
+
+ if (newinputs & VERT_BIT_COLOR1)
+ r200ReleaseDmaRegion( rmesa, &rmesa->tcl.spec, __FUNCTION__ );
+
+ for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++) {
+ if (newinputs & VERT_BIT_TEX(unit))
+ r200ReleaseDmaRegion( rmesa, &rmesa->tcl.tex[unit], __FUNCTION__ );
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_pixel.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_pixel.c
new file mode 100644
index 000000000..adc6a2aa2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_pixel.c
@@ -0,0 +1,492 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_pixel.c,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "enums.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "swrast/swrast.h"
+
+#include "r200_context.h"
+#include "r200_ioctl.h"
+#include "r200_pixel.h"
+#include "r200_swtcl.h"
+
+
+
+static GLboolean
+check_color( const GLcontext *ctx, GLenum type, GLenum format,
+ const struct gl_pixelstore_attrib *packing,
+ const void *pixels, GLint sz, GLint pitch )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint cpp = rmesa->r200Screen->cpp;
+
+ if (R200_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if ( (pitch & 63) ||
+ ctx->_ImageTransferState ||
+ packing->SwapBytes ||
+ packing->LsbFirst) {
+ if (R200_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s: failed 1\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+
+ if ( type == GL_UNSIGNED_INT_8_8_8_8_REV &&
+ cpp == 4 &&
+ format == GL_BGRA ) {
+ if (R200_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s: passed 2\n", __FUNCTION__);
+ return GL_TRUE;
+ }
+
+ if (R200_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s: failed\n", __FUNCTION__);
+
+ return GL_FALSE;
+}
+
+static GLboolean
+check_color_per_fragment_ops( const GLcontext *ctx )
+{
+ int result;
+ result = (!( ctx->Color.AlphaEnabled ||
+ ctx->Depth.Test ||
+ ctx->Fog.Enabled ||
+ ctx->Scissor.Enabled ||
+ ctx->Stencil.Enabled ||
+ !ctx->Color.ColorMask[0] ||
+ !ctx->Color.ColorMask[1] ||
+ !ctx->Color.ColorMask[2] ||
+ !ctx->Color.ColorMask[3] ||
+ ctx->Color.ColorLogicOpEnabled ||
+ ctx->Texture._EnabledUnits ||
+ ctx->Depth.OcclusionTest
+ ) &&
+ ctx->Current.RasterPosValid);
+
+ return result;
+}
+
+
+
+static GLboolean
+clip_pixelrect( const GLcontext *ctx,
+ const GLframebuffer *buffer,
+ GLint *x, GLint *y,
+ GLsizei *width, GLsizei *height,
+ GLint *size )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ /* left clipping */
+ if (*x < buffer->_Xmin) {
+ *width -= (buffer->_Xmin - *x);
+ *x = buffer->_Xmin;
+ }
+
+ /* right clipping */
+ if (*x + *width > buffer->_Xmax)
+ *width -= (*x + *width - buffer->_Xmax - 1);
+
+ if (*width <= 0)
+ return GL_FALSE;
+
+ /* bottom clipping */
+ if (*y < buffer->_Ymin) {
+ *height -= (buffer->_Ymin - *y);
+ *y = buffer->_Ymin;
+ }
+
+ /* top clipping */
+ if (*y + *height > buffer->_Ymax)
+ *height -= (*y + *height - buffer->_Ymax - 1);
+
+ if (*height <= 0)
+ return GL_FALSE;
+
+ *size = ((*y + *height - 1) * rmesa->r200Screen->frontPitch +
+ (*x + *width - 1) * rmesa->r200Screen->cpp);
+
+ return GL_TRUE;
+}
+
+static GLboolean
+r200TryReadPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack,
+ GLvoid *pixels )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLint pitch = pack->RowLength ? pack->RowLength : width;
+ GLint blit_format;
+ GLuint cpp = rmesa->r200Screen->cpp;
+ GLint size = width * height * cpp;
+
+ if (R200_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ /* Only accelerate reading to GART buffers.
+ */
+ if ( !r200IsGartMemory(rmesa, pixels,
+ pitch * height * rmesa->r200Screen->cpp ) ) {
+ if (R200_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s: dest not GART\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+
+ /* Need GL_PACK_INVERT_MESA to cope with upsidedown results from
+ * blitter:
+ */
+ if (!pack->Invert) {
+ if (R200_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s: MESA_PACK_INVERT not set\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+
+ if (!check_color(ctx, type, format, pack, pixels, size, pitch))
+ return GL_FALSE;
+
+ switch ( rmesa->r200Screen->cpp ) {
+ case 4:
+ blit_format = R200_CP_COLOR_FORMAT_ARGB8888;
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+
+ /* Although the blits go on the command buffer, need to do this and
+ * fire with lock held to guarentee cliprects and drawOffset are
+ * correct.
+ *
+ * This is an unusual situation however, as the code which flushes
+ * a full command buffer expects to be called unlocked. As a
+ * workaround, immediately flush the buffer on aquiring the lock.
+ */
+ LOCK_HARDWARE( rmesa );
+
+ if (rmesa->store.cmd_used)
+ r200FlushCmdBufLocked( rmesa, __FUNCTION__ );
+
+ if (!clip_pixelrect(ctx, ctx->ReadBuffer, &x, &y, &width, &height,
+ &size)) {
+ UNLOCK_HARDWARE( rmesa );
+ if (R200_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s totally clipped -- nothing to do\n",
+ __FUNCTION__);
+ return GL_TRUE;
+ }
+
+ {
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+ int nbox = dPriv->numClipRects;
+ int src_offset = rmesa->state.color.drawOffset
+ + rmesa->r200Screen->fbLocation;
+ int src_pitch = rmesa->state.color.drawPitch * rmesa->r200Screen->cpp;
+ int dst_offset = r200GartOffsetFromVirtual( rmesa, pixels );
+ int dst_pitch = pitch * rmesa->r200Screen->cpp;
+ drm_clip_rect_t *box = dPriv->pClipRects;
+ int i;
+
+ r200EmitWait( rmesa, RADEON_WAIT_3D );
+
+ y = dPriv->h - y - height;
+ x += dPriv->x;
+ y += dPriv->y;
+
+
+ if (R200_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "readpixel blit src_pitch %d dst_pitch %d\n",
+ src_pitch, dst_pitch);
+
+ for (i = 0 ; i < nbox ; i++)
+ {
+ GLint bx = box[i].x1;
+ GLint by = box[i].y1;
+ GLint bw = box[i].x2 - bx;
+ GLint bh = box[i].y2 - by;
+
+ if (bx < x) bw -= x - bx, bx = x;
+ if (by < y) bh -= y - by, by = y;
+ if (bx + bw > x + width) bw = x + width - bx;
+ if (by + bh > y + height) bh = y + height - by;
+ if (bw <= 0) continue;
+ if (bh <= 0) continue;
+
+ r200EmitBlit( rmesa,
+ blit_format,
+ src_pitch, src_offset,
+ dst_pitch, dst_offset,
+ bx, by,
+ bx - x, by - y,
+ bw, bh );
+ }
+
+ r200FlushCmdBufLocked( rmesa, __FUNCTION__ );
+ }
+ UNLOCK_HARDWARE( rmesa );
+
+ r200Finish( ctx ); /* required by GL */
+
+ return GL_TRUE;
+}
+
+static void
+r200ReadPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *pack,
+ GLvoid *pixels )
+{
+ if (R200_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (!r200TryReadPixels( ctx, x, y, width, height, format, type, pack,
+ pixels))
+ _swrast_ReadPixels( ctx, x, y, width, height, format, type, pack,
+ pixels);
+}
+
+
+
+
+static void do_draw_pix( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLint pitch,
+ const void *pixels,
+ GLuint planemask)
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+ drm_clip_rect_t *box = dPriv->pClipRects;
+ int nbox = dPriv->numClipRects;
+ int i;
+ int blit_format;
+ int size;
+ int src_offset = r200GartOffsetFromVirtual( rmesa, pixels );
+ int src_pitch = pitch * rmesa->r200Screen->cpp;
+
+ if (R200_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ switch ( rmesa->r200Screen->cpp ) {
+ case 2:
+ blit_format = R200_CP_COLOR_FORMAT_RGB565;
+ break;
+ case 4:
+ blit_format = R200_CP_COLOR_FORMAT_ARGB8888;
+ break;
+ default:
+ return;
+ }
+
+
+ LOCK_HARDWARE( rmesa );
+
+ if (rmesa->store.cmd_used)
+ r200FlushCmdBufLocked( rmesa, __FUNCTION__ );
+
+ y -= height; /* cope with pixel zoom */
+
+ if (!clip_pixelrect(ctx, ctx->DrawBuffer,
+ &x, &y, &width, &height,
+ &size)) {
+ UNLOCK_HARDWARE( rmesa );
+ return;
+ }
+
+ y = dPriv->h - y - height; /* convert from gl to hardware coords */
+ x += dPriv->x;
+ y += dPriv->y;
+
+
+ r200EmitWait( rmesa, RADEON_WAIT_3D );
+
+ for (i = 0 ; i < nbox ; i++ )
+ {
+ GLint bx = box[i].x1;
+ GLint by = box[i].y1;
+ GLint bw = box[i].x2 - bx;
+ GLint bh = box[i].y2 - by;
+
+ if (bx < x) bw -= x - bx, bx = x;
+ if (by < y) bh -= y - by, by = y;
+ if (bx + bw > x + width) bw = x + width - bx;
+ if (by + bh > y + height) bh = y + height - by;
+ if (bw <= 0) continue;
+ if (bh <= 0) continue;
+
+ r200EmitBlit( rmesa,
+ blit_format,
+ src_pitch, src_offset,
+ rmesa->state.color.drawPitch * rmesa->r200Screen->cpp,
+ rmesa->state.color.drawOffset + rmesa->r200Screen->fbLocation,
+ bx - x, by - y,
+ bx, by,
+ bw, bh );
+ }
+
+ r200FlushCmdBufLocked( rmesa, __FUNCTION__ );
+ r200WaitForIdleLocked( rmesa ); /* required by GL */
+ UNLOCK_HARDWARE( rmesa );
+}
+
+
+
+
+static GLboolean
+r200TryDrawPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLint pitch = unpack->RowLength ? unpack->RowLength : width;
+ GLuint planemask;
+ GLuint cpp = rmesa->r200Screen->cpp;
+ GLint size = width * pitch * cpp;
+
+ if (R200_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ switch (format) {
+ case GL_RGB:
+ case GL_RGBA:
+ case GL_BGRA:
+ planemask = r200PackColor(cpp,
+ ctx->Color.ColorMask[RCOMP],
+ ctx->Color.ColorMask[GCOMP],
+ ctx->Color.ColorMask[BCOMP],
+ ctx->Color.ColorMask[ACOMP]);
+
+ if (cpp == 2)
+ planemask |= planemask << 16;
+
+ if (planemask != ~0)
+ return GL_FALSE; /* fix me -- should be possible */
+
+ /* Can't do conversions on GART reads/draws.
+ */
+ if ( !r200IsGartMemory( rmesa, pixels, size ) ) {
+ if (R200_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s: not GART memory\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+
+ if (!check_color(ctx, type, format, unpack, pixels, size, pitch)) {
+ return GL_FALSE;
+ }
+ if (!check_color_per_fragment_ops(ctx)) {
+ return GL_FALSE;
+ }
+
+ if (ctx->Pixel.ZoomX != 1.0F ||
+ ctx->Pixel.ZoomY != -1.0F)
+ return GL_FALSE;
+ break;
+
+ default:
+ return GL_FALSE;
+ }
+
+ if ( r200IsGartMemory(rmesa, pixels, size) )
+ {
+ do_draw_pix( ctx, x, y, width, height, pitch, pixels, planemask );
+ return GL_TRUE;
+ }
+ else if (0)
+ {
+ /* Pixels is in regular memory -- get dma buffers and perform
+ * upload through them.
+ */
+ }
+ else
+ return GL_FALSE;
+}
+
+static void
+r200DrawPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels )
+{
+ if (R200_DEBUG & DEBUG_PIXEL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (!r200TryDrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels ))
+ _swrast_DrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels );
+}
+
+
+static void
+r200Bitmap( GLcontext *ctx, GLint px, GLint py,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if (rmesa->Fallback)
+ _swrast_Bitmap( ctx, px, py, width, height, unpack, bitmap );
+ else
+ r200PointsBitmap( ctx, px, py, width, height, unpack, bitmap );
+}
+
+
+
+void r200InitPixelFuncs( GLcontext *ctx )
+{
+ /* Pixel path fallbacks.
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+
+ if (!getenv("R200_NO_BLITS") && R200_CONTEXT(ctx)->dri.drmMinor >= 6) {
+ ctx->Driver.ReadPixels = r200ReadPixels;
+ ctx->Driver.DrawPixels = r200DrawPixels;
+ if (getenv("R200_HW_BITMAP"))
+ ctx->Driver.Bitmap = r200Bitmap;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_pixel.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_pixel.h
new file mode 100644
index 000000000..8f3923b6b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_pixel.h
@@ -0,0 +1,40 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_pixel.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R200_PIXEL_H__
+#define __R200_PIXEL_H__
+
+extern void r200InitPixelFuncs( GLcontext *ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_reg.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_reg.h
new file mode 100644
index 000000000..dd5f17cc3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_reg.h
@@ -0,0 +1,1454 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_reg.h,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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.
+*/
+
+#ifndef _R200_REG_H_
+#define _R200_REG_H_
+
+#define R200_PP_MISC 0x1c14
+#define R200_REF_ALPHA_MASK 0x000000ff
+#define R200_ALPHA_TEST_FAIL (0 << 8)
+#define R200_ALPHA_TEST_LESS (1 << 8)
+#define R200_ALPHA_TEST_LEQUAL (2 << 8)
+#define R200_ALPHA_TEST_EQUAL (3 << 8)
+#define R200_ALPHA_TEST_GEQUAL (4 << 8)
+#define R200_ALPHA_TEST_GREATER (5 << 8)
+#define R200_ALPHA_TEST_NEQUAL (6 << 8)
+#define R200_ALPHA_TEST_PASS (7 << 8)
+#define R200_ALPHA_TEST_OP_MASK (7 << 8)
+#define R200_CHROMA_FUNC_FAIL (0 << 16)
+#define R200_CHROMA_FUNC_PASS (1 << 16)
+#define R200_CHROMA_FUNC_NEQUAL (2 << 16)
+#define R200_CHROMA_FUNC_EQUAL (3 << 16)
+#define R200_CHROMA_KEY_NEAREST (0 << 18)
+#define R200_CHROMA_KEY_ZERO (1 << 18)
+#define R200_RIGHT_HAND_CUBE_D3D (0 << 24)
+#define R200_RIGHT_HAND_CUBE_OGL (1 << 24)
+#define R200_PP_FOG_COLOR 0x1c18
+#define R200_FOG_COLOR_MASK 0x00ffffff
+#define R200_FOG_VERTEX (0 << 24)
+#define R200_FOG_TABLE (1 << 24)
+#define R200_FOG_USE_DEPTH (0 << 25)
+#define R200_FOG_USE_W (1 << 25)
+#define R200_FOG_USE_DIFFUSE_ALPHA (2 << 25)
+#define R200_FOG_USE_SPEC_ALPHA (3 << 25)
+#define R200_FOG_USE_VTX_FOG (4 << 25)
+#define R200_FOG_USE_MASK (7 << 25)
+#define R200_RE_SOLID_COLOR 0x1c1c
+#define R200_RB3D_BLENDCNTL 0x1c20
+#define R200_COMB_FCN_MASK (7 << 12)
+#define R200_COMB_FCN_ADD_CLAMP (0 << 12)
+#define R200_COMB_FCN_ADD_NOCLAMP (1 << 12)
+#define R200_COMB_FCN_SUB_CLAMP (2 << 12)
+#define R200_COMB_FCN_SUB_NOCLAMP (3 << 12)
+#define R200_COMB_FCN_MIN (4 << 12)
+#define R200_COMB_FCN_MAX (5 << 12)
+#define R200_COMB_FCN_RSUB_CLAMP (6 << 12)
+#define R200_COMB_FCN_RSUB_NOCLAMP (7 << 12)
+#define R200_BLEND_GL_ZERO (32)
+#define R200_BLEND_GL_ONE (33)
+#define R200_BLEND_GL_SRC_COLOR (34)
+#define R200_BLEND_GL_ONE_MINUS_SRC_COLOR (35)
+#define R200_BLEND_GL_DST_COLOR (36)
+#define R200_BLEND_GL_ONE_MINUS_DST_COLOR (37)
+#define R200_BLEND_GL_SRC_ALPHA (38)
+#define R200_BLEND_GL_ONE_MINUS_SRC_ALPHA (39)
+#define R200_BLEND_GL_DST_ALPHA (40)
+#define R200_BLEND_GL_ONE_MINUS_DST_ALPHA (41)
+#define R200_BLEND_GL_SRC_ALPHA_SATURATE (42) /* src factor only */
+#define R200_BLEND_GL_CONST_COLOR (43)
+#define R200_BLEND_GL_ONE_MINUS_CONST_COLOR (44)
+#define R200_BLEND_GL_CONST_ALPHA (45)
+#define R200_BLEND_GL_ONE_MINUS_CONST_ALPHA (46)
+#define R200_BLEND_MASK (63)
+#define R200_SRC_BLEND_SHIFT (16)
+#define R200_DST_BLEND_SHIFT (24)
+#define R200_RB3D_DEPTHOFFSET 0x1c24
+#define R200_RB3D_DEPTHPITCH 0x1c28
+#define R200_DEPTHPITCH_MASK 0x00001ff8
+#define R200_DEPTH_HYPERZ (3 << 16)
+#define R200_DEPTH_ENDIAN_NO_SWAP (0 << 18)
+#define R200_DEPTH_ENDIAN_WORD_SWAP (1 << 18)
+#define R200_DEPTH_ENDIAN_DWORD_SWAP (2 << 18)
+#define R200_RB3D_ZSTENCILCNTL 0x1c2c
+#define R200_DEPTH_FORMAT_MASK (0xf << 0)
+#define R200_DEPTH_FORMAT_16BIT_INT_Z (0 << 0)
+#define R200_DEPTH_FORMAT_24BIT_INT_Z (2 << 0)
+#define R200_DEPTH_FORMAT_24BIT_FLOAT_Z (3 << 0)
+#define R200_DEPTH_FORMAT_32BIT_INT_Z (4 << 0)
+#define R200_DEPTH_FORMAT_32BIT_FLOAT_Z (5 << 0)
+#define R200_DEPTH_FORMAT_24BIT_FLOAT_W (9 << 0)
+#define R200_DEPTH_FORMAT_32BIT_FLOAT_W (11 << 0)
+#define R200_Z_TEST_NEVER (0 << 4)
+#define R200_Z_TEST_LESS (1 << 4)
+#define R200_Z_TEST_LEQUAL (2 << 4)
+#define R200_Z_TEST_EQUAL (3 << 4)
+#define R200_Z_TEST_GEQUAL (4 << 4)
+#define R200_Z_TEST_GREATER (5 << 4)
+#define R200_Z_TEST_NEQUAL (6 << 4)
+#define R200_Z_TEST_ALWAYS (7 << 4)
+#define R200_Z_TEST_MASK (7 << 4)
+#define R200_Z_HIERARCHY_ENABLE (1 << 8)
+#define R200_STENCIL_TEST_NEVER (0 << 12)
+#define R200_STENCIL_TEST_LESS (1 << 12)
+#define R200_STENCIL_TEST_LEQUAL (2 << 12)
+#define R200_STENCIL_TEST_EQUAL (3 << 12)
+#define R200_STENCIL_TEST_GEQUAL (4 << 12)
+#define R200_STENCIL_TEST_GREATER (5 << 12)
+#define R200_STENCIL_TEST_NEQUAL (6 << 12)
+#define R200_STENCIL_TEST_ALWAYS (7 << 12)
+#define R200_STENCIL_TEST_MASK (0x7 << 12)
+#define R200_STENCIL_FAIL_KEEP (0 << 16)
+#define R200_STENCIL_FAIL_ZERO (1 << 16)
+#define R200_STENCIL_FAIL_REPLACE (2 << 16)
+#define R200_STENCIL_FAIL_INC (3 << 16)
+#define R200_STENCIL_FAIL_DEC (4 << 16)
+#define R200_STENCIL_FAIL_INVERT (5 << 16)
+#define R200_STENCIL_FAIL_INC_WRAP (6 << 16)
+#define R200_STENCIL_FAIL_DEC_WRAP (7 << 16)
+#define R200_STENCIL_FAIL_MASK (0x7 << 16)
+#define R200_STENCIL_ZPASS_KEEP (0 << 20)
+#define R200_STENCIL_ZPASS_ZERO (1 << 20)
+#define R200_STENCIL_ZPASS_REPLACE (2 << 20)
+#define R200_STENCIL_ZPASS_INC (3 << 20)
+#define R200_STENCIL_ZPASS_DEC (4 << 20)
+#define R200_STENCIL_ZPASS_INVERT (5 << 20)
+#define R200_STENCIL_ZPASS_INC_WRAP (6 << 20)
+#define R200_STENCIL_ZPASS_DEC_WRAP (7 << 20)
+#define R200_STENCIL_ZPASS_MASK (0x7 << 20)
+#define R200_STENCIL_ZFAIL_KEEP (0 << 24)
+#define R200_STENCIL_ZFAIL_ZERO (1 << 24)
+#define R200_STENCIL_ZFAIL_REPLACE (2 << 24)
+#define R200_STENCIL_ZFAIL_INC (3 << 24)
+#define R200_STENCIL_ZFAIL_DEC (4 << 24)
+#define R200_STENCIL_ZFAIL_INVERT (5 << 24)
+#define R200_STENCIL_ZFAIL_INC_WRAP (6 << 24)
+#define R200_STENCIL_ZFAIL_DEC_WRAP (7 << 24)
+#define R200_STENCIL_ZFAIL_MASK (0x7 << 24)
+#define R200_Z_COMPRESSION_ENABLE (1 << 28)
+#define R200_FORCE_Z_DIRTY (1 << 29)
+#define R200_Z_WRITE_ENABLE (1 << 30)
+#define R200_Z_DECOMPRESSION_ENABLE (1 << 31)
+/*gap*/
+#define R200_PP_CNTL 0x1c38
+#define R200_TEX_0_ENABLE 0x00000010
+#define R200_TEX_1_ENABLE 0x00000020
+#define R200_TEX_2_ENABLE 0x00000040
+#define R200_TEX_3_ENABLE 0x00000080
+#define R200_TEX_4_ENABLE 0x00000100
+#define R200_TEX_5_ENABLE 0x00000200
+#define R200_TEX_ENABLE_MASK 0x000003f0
+#define R200_FILTER_ROUND_MODE_MASK 0x00000400
+#define R200_TEX_BLEND_7_ENABLE 0x00000800
+#define R200_TEX_BLEND_0_ENABLE 0x00001000
+#define R200_TEX_BLEND_1_ENABLE 0x00002000
+#define R200_TEX_BLEND_2_ENABLE 0x00004000
+#define R200_TEX_BLEND_3_ENABLE 0x00008000
+#define R200_TEX_BLEND_4_ENABLE 0x00010000
+#define R200_TEX_BLEND_5_ENABLE 0x00020000
+#define R200_TEX_BLEND_6_ENABLE 0x00040000
+#define R200_MULTI_PASS_ENABLE 0x00080000
+#define R200_SPECULAR_ENABLE 0x00200000
+#define R200_FOG_ENABLE 0x00400000
+#define R200_ALPHA_TEST_ENABLE 0x00800000
+#define R200_ANTI_ALIAS_NONE 0x00000000
+#define R200_ANTI_ALIAS_LINE 0x01000000
+#define R200_ANTI_ALIAS_POLY 0x02000000
+#define R200_ANTI_ALIAS_MASK 0x03000000
+#define R200_RB3D_CNTL 0x1c3c
+#define R200_ALPHA_BLEND_ENABLE (1 << 0)
+#define R200_PLANE_MASK_ENABLE (1 << 1)
+#define R200_DITHER_ENABLE (1 << 2)
+#define R200_ROUND_ENABLE (1 << 3)
+#define R200_SCALE_DITHER_ENABLE (1 << 4)
+#define R200_DITHER_INIT (1 << 5)
+#define R200_ROP_ENABLE (1 << 6)
+#define R200_STENCIL_ENABLE (1 << 7)
+#define R200_Z_ENABLE (1 << 8)
+#define R200_DEPTH_XZ_OFFEST_ENABLE (1 << 9)
+#define R200_COLOR_FORMAT_ARGB1555 (3 << 10)
+#define R200_COLOR_FORMAT_RGB565 (4 << 10)
+#define R200_COLOR_FORMAT_ARGB8888 (6 << 10)
+#define R200_COLOR_FORMAT_RGB332 (7 << 10)
+#define R200_COLOR_FORMAT_Y8 (8 << 10)
+#define R200_COLOR_FORMAT_RGB8 (9 << 10)
+#define R200_COLOR_FORMAT_YUV422_VYUY (11 << 10)
+#define R200_COLOR_FORMAT_YUV422_YVYU (12 << 10)
+#define R200_COLOR_FORMAT_aYUV444 (14 << 10)
+#define R200_COLOR_FORMAT_ARGB4444 (15 << 10)
+#define R200_CLRCMP_FLIP_ENABLE (1 << 14)
+#define R200_SEPARATE_ALPHA_ENABLE (1 << 16)
+#define R200_RB3D_COLOROFFSET 0x1c40
+#define R200_COLOROFFSET_MASK 0xfffffff0
+#define R200_RE_WIDTH_HEIGHT 0x1c44
+#define R200_RE_WIDTH_SHIFT 0
+#define R200_RE_HEIGHT_SHIFT 16
+#define R200_RB3D_COLORPITCH 0x1c48
+#define R200_COLORPITCH_MASK 0x000001ff8
+#define R200_COLOR_TILE_ENABLE (1 << 16)
+#define R200_COLOR_MICROTILE_ENABLE (1 << 17)
+#define R200_COLOR_ENDIAN_NO_SWAP (0 << 18)
+#define R200_COLOR_ENDIAN_WORD_SWAP (1 << 18)
+#define R200_COLOR_ENDIAN_DWORD_SWAP (2 << 18)
+#define R200_SE_CNTL 0x1c4c
+#define R200_FFACE_CULL_CW (0 << 0)
+#define R200_FFACE_CULL_CCW (1 << 0)
+#define R200_FFACE_CULL_DIR_MASK (1 << 0)
+#define R200_BFACE_CULL (0 << 1)
+#define R200_BFACE_SOLID (3 << 1)
+#define R200_FFACE_CULL (0 << 3)
+#define R200_FFACE_SOLID (3 << 3)
+#define R200_FFACE_CULL_MASK (3 << 3)
+#define R200_FLAT_SHADE_VTX_0 (0 << 6)
+#define R200_FLAT_SHADE_VTX_1 (1 << 6)
+#define R200_FLAT_SHADE_VTX_2 (2 << 6)
+#define R200_FLAT_SHADE_VTX_LAST (3 << 6)
+#define R200_DIFFUSE_SHADE_SOLID (0 << 8)
+#define R200_DIFFUSE_SHADE_FLAT (1 << 8)
+#define R200_DIFFUSE_SHADE_GOURAUD (2 << 8)
+#define R200_DIFFUSE_SHADE_MASK (3 << 8)
+#define R200_ALPHA_SHADE_SOLID (0 << 10)
+#define R200_ALPHA_SHADE_FLAT (1 << 10)
+#define R200_ALPHA_SHADE_GOURAUD (2 << 10)
+#define R200_ALPHA_SHADE_MASK (3 << 10)
+#define R200_SPECULAR_SHADE_SOLID (0 << 12)
+#define R200_SPECULAR_SHADE_FLAT (1 << 12)
+#define R200_SPECULAR_SHADE_GOURAUD (2 << 12)
+#define R200_SPECULAR_SHADE_MASK (3 << 12)
+#define R200_FOG_SHADE_SOLID (0 << 14)
+#define R200_FOG_SHADE_FLAT (1 << 14)
+#define R200_FOG_SHADE_GOURAUD (2 << 14)
+#define R200_FOG_SHADE_MASK (3 << 14)
+#define R200_ZBIAS_ENABLE_POINT (1 << 16)
+#define R200_ZBIAS_ENABLE_LINE (1 << 17)
+#define R200_ZBIAS_ENABLE_TRI (1 << 18)
+#define R200_WIDELINE_ENABLE (1 << 20)
+#define R200_VTX_PIX_CENTER_D3D (0 << 27)
+#define R200_VTX_PIX_CENTER_OGL (1 << 27)
+#define R200_ROUND_MODE_TRUNC (0 << 28)
+#define R200_ROUND_MODE_ROUND (1 << 28)
+#define R200_ROUND_MODE_ROUND_EVEN (2 << 28)
+#define R200_ROUND_MODE_ROUND_ODD (3 << 28)
+#define R200_ROUND_PREC_16TH_PIX (0 << 30)
+#define R200_ROUND_PREC_8TH_PIX (1 << 30)
+#define R200_ROUND_PREC_4TH_PIX (2 << 30)
+#define R200_ROUND_PREC_HALF_PIX (3 << 30)
+#define R200_RE_CNTL 0x1c50
+#define R200_STIPPLE_ENABLE 0x1
+#define R200_SCISSOR_ENABLE 0x2
+#define R200_PATTERN_ENABLE 0x4
+#define R200_PERSPECTIVE_ENABLE 0x8
+#define R200_POINT_SMOOTH 0x20
+#define R200_VTX_STQ0_D3D 0x00010000
+#define R200_VTX_STQ1_D3D 0x00040000
+#define R200_VTX_STQ2_D3D 0x00100000
+#define R200_VTX_STQ3_D3D 0x00400000
+#define R200_VTX_STQ4_D3D 0x01000000
+#define R200_VTX_STQ5_D3D 0x04000000
+/* gap */
+#define R200_RE_STIPPLE_ADDR 0x1cc8
+#define R200_RE_STIPPLE_DATA 0x1ccc
+#define R200_RE_LINE_PATTERN 0x1cd0
+#define R200_LINE_PATTERN_MASK 0x0000ffff
+#define R200_LINE_REPEAT_COUNT_SHIFT 16
+#define R200_LINE_PATTERN_START_SHIFT 24
+#define R200_LINE_PATTERN_LITTLE_BIT_ORDER (0 << 28)
+#define R200_LINE_PATTERN_BIG_BIT_ORDER (1 << 28)
+#define R200_LINE_PATTERN_AUTO_RESET (1 << 29)
+#define R200_RE_LINE_STATE 0x1cd4
+#define R200_LINE_CURRENT_PTR_SHIFT 0
+#define R200_LINE_CURRENT_COUNT_SHIFT 8
+#define R200_RE_SCISSOR_TL_0 0x1cd8
+#define R200_RE_SCISSOR_BR_0 0x1cdc
+#define R200_RE_SCISSOR_TL_1 0x1ce0
+#define R200_RE_SCISSOR_BR_1 0x1ce4
+#define R200_RE_SCISSOR_TL_2 0x1ce8
+#define R200_RE_SCISSOR_BR_2 0x1cec
+/* gap */
+#define R200_RB3D_DEPTHXY_OFFSET 0x1d60
+#define R200_DEPTHX_SHIFT 0
+#define R200_DEPTHY_SHIFT 16
+/* gap */
+#define R200_RB3D_STENCILREFMASK 0x1d7c
+#define R200_STENCIL_REF_SHIFT 0
+#define R200_STENCIL_REF_MASK (0xff << 0)
+#define R200_STENCIL_MASK_SHIFT 16
+#define R200_STENCIL_VALUE_MASK (0xff << 16)
+#define R200_STENCIL_WRITEMASK_SHIFT 24
+#define R200_STENCIL_WRITE_MASK (0xff << 24)
+#define R200_RB3D_ROPCNTL 0x1d80
+#define R200_ROP_MASK (15 << 8)
+#define R200_ROP_CLEAR (0 << 8)
+#define R200_ROP_NOR (1 << 8)
+#define R200_ROP_AND_INVERTED (2 << 8)
+#define R200_ROP_COPY_INVERTED (3 << 8)
+#define R200_ROP_AND_REVERSE (4 << 8)
+#define R200_ROP_INVERT (5 << 8)
+#define R200_ROP_XOR (6 << 8)
+#define R200_ROP_NAND (7 << 8)
+#define R200_ROP_AND (8 << 8)
+#define R200_ROP_EQUIV (9 << 8)
+#define R200_ROP_NOOP (10 << 8)
+#define R200_ROP_OR_INVERTED (11 << 8)
+#define R200_ROP_COPY (12 << 8)
+#define R200_ROP_OR_REVERSE (13 << 8)
+#define R200_ROP_OR (14 << 8)
+#define R200_ROP_SET (15 << 8)
+#define R200_RB3D_PLANEMASK 0x1d84
+/* gap */
+#define R200_SE_VPORT_XSCALE 0x1d98
+#define R200_SE_VPORT_XOFFSET 0x1d9c
+#define R200_SE_VPORT_YSCALE 0x1da0
+#define R200_SE_VPORT_YOFFSET 0x1da4
+#define R200_SE_VPORT_ZSCALE 0x1da8
+#define R200_SE_VPORT_ZOFFSET 0x1dac
+#define R200_SE_ZBIAS_FACTOR 0x1db0
+#define R200_SE_ZBIAS_CONSTANT 0x1db4
+#define R200_SE_LINE_WIDTH 0x1db8
+#define R200_LINE_WIDTH_SHIFT 0x00000000
+#define R200_MINPOINTSIZE_SHIFT 0x00000010
+/* gap */
+#define R200_SE_VAP_CNTL 0x2080
+#define R200_VAP_TCL_ENABLE 0x00000001
+#define R200_VAP_SINGLE_BUF_STATE_ENABLE 0x00000010
+#define R200_VAP_FORCE_W_TO_ONE 0x00010000
+#define R200_VAP_D3D_TEX_DEFAULT 0x00020000
+#define R200_VAP_VF_MAX_VTX_NUM__SHIFT 18
+#define R200_VAP_DX_CLIP_SPACE_DEF 0x00400000
+#define R200_SE_VF_CNTL 0x2084
+#define R200_VF_PRIM_NONE 0x00000000
+#define R200_VF_PRIM_POINTS 0x00000001
+#define R200_VF_PRIM_LINES 0x00000002
+#define R200_VF_PRIM_LINE_STRIP 0x00000003
+#define R200_VF_PRIM_TRIANGLES 0x00000004
+#define R200_VF_PRIM_TRIANGLE_FAN 0x00000005
+#define R200_VF_PRIM_TRIANGLE_STRIP 0x00000006
+#define R200_VF_PRIM_RECT_LIST 0x00000008
+#define R200_VF_PRIM_3VRT_POINTS 0x00000009
+#define R200_VF_PRIM_3VRT_LINES 0x0000000a
+#define R200_VF_PRIM_POINT_SPRITES 0x0000000b
+#define R200_VF_PRIM_LINE_LOOP 0x0000000c
+#define R200_VF_PRIM_QUADS 0x0000000d
+#define R200_VF_PRIM_QUAD_STRIP 0x0000000e
+#define R200_VF_PRIM_POLYGON 0x0000000f
+#define R200_VF_PRIM_MASK 0x0000000f
+#define R200_VF_PRIM_WALK_IND 0x00000010
+#define R200_VF_PRIM_WALK_LIST 0x00000020
+#define R200_VF_PRIM_WALK_RING 0x00000030
+#define R200_VF_PRIM_WALK_MASK 0x00000030
+#define R200_VF_COLOR_ORDER_RGBA 0x00000040
+#define R200_VF_TCL_OUTPUT_VTX_ENABLE 0x00000200
+#define R200_VF_INDEX_SZ_4 0x00000800
+#define R200_VF_VERTEX_NUMBER_MASK 0xffff0000
+#define R200_VF_VERTEX_NUMBER_SHIFT 16
+#define R200_SE_VTX_FMT_0 0x2088
+#define R200_VTX_XY 0 /* always have xy */
+#define R200_VTX_Z0 (1<<0)
+#define R200_VTX_W0 (1<<1)
+#define R200_VTX_WEIGHT_COUNT_SHIFT (2)
+#define R200_VTX_PV_MATRIX_SEL (1<<5)
+#define R200_VTX_N0 (1<<6)
+#define R200_VTX_POINT_SIZE (1<<7)
+#define R200_VTX_DISCRETE_FOG (1<<8)
+#define R200_VTX_SHININESS_0 (1<<9)
+#define R200_VTX_SHININESS_1 (1<<10)
+#define R200_VTX_COLOR_NOT_PRESENT 0
+#define R200_VTX_PK_RGBA 1
+#define R200_VTX_FP_RGB 2
+#define R200_VTX_FP_RGBA 3
+#define R200_VTX_COLOR_MASK 3
+#define R200_VTX_COLOR_0_SHIFT 11
+#define R200_VTX_COLOR_1_SHIFT 13
+#define R200_VTX_COLOR_2_SHIFT 15
+#define R200_VTX_COLOR_3_SHIFT 17
+#define R200_VTX_COLOR_4_SHIFT 19
+#define R200_VTX_COLOR_5_SHIFT 21
+#define R200_VTX_COLOR_6_SHIFT 23
+#define R200_VTX_COLOR_7_SHIFT 25
+#define R200_VTX_XY1 (1<<28)
+#define R200_VTX_Z1 (1<<29)
+#define R200_VTX_W1 (1<<30)
+#define R200_VTX_N1 (1<<31)
+#define R200_SE_VTX_FMT_1 0x208c
+#define R200_VTX_TEX0_COMP_CNT_SHIFT 0
+#define R200_VTX_TEX1_COMP_CNT_SHIFT 3
+#define R200_VTX_TEX2_COMP_CNT_SHIFT 6
+#define R200_VTX_TEX3_COMP_CNT_SHIFT 9
+#define R200_VTX_TEX4_COMP_CNT_SHIFT 12
+#define R200_VTX_TEX5_COMP_CNT_SHIFT 15
+#define R200_SE_TCL_OUTPUT_VTX_FMT_0 0x2090
+#define R200_SE_TCL_OUTPUT_VTX_FMT_1 0x2094
+/* gap */
+#define R200_SE_VTE_CNTL 0x20b0
+#define R200_VPORT_X_SCALE_ENA 0x00000001
+#define R200_VPORT_X_OFFSET_ENA 0x00000002
+#define R200_VPORT_Y_SCALE_ENA 0x00000004
+#define R200_VPORT_Y_OFFSET_ENA 0x00000008
+#define R200_VPORT_Z_SCALE_ENA 0x00000010
+#define R200_VPORT_Z_OFFSET_ENA 0x00000020
+#define R200_VTX_XY_FMT 0x00000100
+#define R200_VTX_Z_FMT 0x00000200
+#define R200_VTX_W0_FMT 0x00000400
+#define R200_VTX_W0_NORMALIZE 0x00000800
+#define R200_VTX_ST_DENORMALIZED 0x00001000
+/* gap */
+#define R200_SE_VTX_NUM_ARRAYS 0x20c0
+#define R200_SE_VTX_AOS_ATTR01 0x20c4
+#define R200_SE_VTX_AOS_ADDR0 0x20c8
+#define R200_SE_VTX_AOS_ADDR1 0x20cc
+#define R200_SE_VTX_AOS_ATTR23 0x20d0
+#define R200_SE_VTX_AOS_ADDR2 0x20d4
+#define R200_SE_VTX_AOS_ADDR3 0x20d8
+#define R200_SE_VTX_AOS_ATTR45 0x20dc
+#define R200_SE_VTX_AOS_ADDR4 0x20e0
+#define R200_SE_VTX_AOS_ADDR5 0x20e4
+#define R200_SE_VTX_AOS_ATTR67 0x20e8
+#define R200_SE_VTX_AOS_ADDR6 0x20ec
+#define R200_SE_VTX_AOS_ADDR7 0x20f0
+#define R200_SE_VTX_AOS_ATTR89 0x20f4
+#define R200_SE_VTX_AOS_ADDR8 0x20f8
+#define R200_SE_VTX_AOS_ADDR9 0x20fc
+#define R200_SE_VTX_AOS_ATTR1011 0x2100
+#define R200_SE_VTX_AOS_ADDR10 0x2104
+#define R200_SE_VTX_AOS_ADDR11 0x2108
+#define R200_SE_VF_MAX_VTX_INDX 0x210c
+#define R200_SE_VF_MIN_VTX_INDX 0x2110
+/* gap */
+#define R200_SE_VAP_CNTL_STATUS 0x2140
+#define R200_VC_NO_SWAP (0 << 0)
+#define R200_VC_16BIT_SWAP (1 << 0)
+#define R200_VC_32BIT_SWAP (2 << 0)
+/* gap */
+#define R200_SE_VTX_STATE_CNTL 0x2180
+#define R200_VSC_COLOR_0_ASSEMBLY_CNTL_SHIFT 0x00000000
+#define R200_VSC_COLOR_1_ASSEMBLY_CNTL_SHIFT 0x00000002
+#define R200_VSC_COLOR_2_ASSEMBLY_CNTL_SHIFT 0x00000004
+#define R200_VSC_COLOR_3_ASSEMBLY_CNTL_SHIFT 0x00000006
+#define R200_VSC_COLOR_4_ASSEMBLY_CNTL_SHIFT 0x00000008
+#define R200_VSC_COLOR_5_ASSEMBLY_CNTL_SHIFT 0x0000000a
+#define R200_VSC_COLOR_6_ASSEMBLY_CNTL_SHIFT 0x0000000c
+#define R200_VSC_COLOR_7_ASSEMBLY_CNTL_SHIFT 0x0000000e
+#define R200_VSC_UPDATE_USER_COLOR_0_ENABLE 0x00010000
+#define R200_VSC_UPDATE_USER_COLOR_1_ENABLE 0x00020000
+/* gap */
+#define R200_SE_TCL_VECTOR_INDX_REG 0x2200
+#define R200_SE_TCL_VECTOR_DATA_REG 0x2204
+#define R200_SE_TCL_SCALAR_INDX_REG 0x2208
+#define R200_SE_TCL_SCALAR_DATA_REG 0x220c
+/* gap */
+#define R200_SE_TCL_MATRIX_SEL_0 0x2230
+#define R200_MODELVIEW_0_SHIFT (0)
+#define R200_MODELVIEW_1_SHIFT (8)
+#define R200_MODELVIEW_2_SHIFT (16)
+#define R200_MODELVIEW_3_SHIFT (24)
+#define R200_SE_TCL_MATRIX_SEL_1 0x2234
+#define R200_IT_MODELVIEW_0_SHIFT (0)
+#define R200_IT_MODELVIEW_1_SHIFT (8)
+#define R200_IT_MODELVIEW_2_SHIFT (16)
+#define R200_IT_MODELVIEW_3_SHIFT (24)
+#define R200_SE_TCL_MATRIX_SEL_2 0x2238
+#define R200_MODELPROJECT_0_SHIFT (0)
+#define R200_MODELPROJECT_1_SHIFT (8)
+#define R200_MODELPROJECT_2_SHIFT (16)
+#define R200_MODELPROJECT_3_SHIFT (24)
+#define R200_SE_TCL_MATRIX_SEL_3 0x223c
+#define R200_TEXMAT_0_SHIFT 0
+#define R200_TEXMAT_1_SHIFT 8
+#define R200_TEXMAT_2_SHIFT 16
+#define R200_TEXMAT_3_SHIFT 24
+#define R200_SE_TCL_MATRIX_SEL_4 0x2240
+#define R200_TEXMAT_4_SHIFT 0
+#define R200_TEXMAT_5_SHIFT 8
+/* gap */
+#define R200_SE_TCL_OUTPUT_VTX_COMP_SEL 0x2250
+#define R200_OUTPUT_XYZW (1<<0)
+#define R200_OUTPUT_COLOR_0 (1<<8)
+#define R200_OUTPUT_COLOR_1 (1<<9)
+#define R200_OUTPUT_TEX_0 (1<<16)
+#define R200_OUTPUT_TEX_1 (1<<17)
+#define R200_OUTPUT_TEX_2 (1<<18)
+#define R200_OUTPUT_TEX_3 (1<<19)
+#define R200_OUTPUT_TEX_4 (1<<20)
+#define R200_OUTPUT_TEX_5 (1<<21)
+#define R200_OUTPUT_TEX_MASK (0x3f<<16)
+#define R200_OUTPUT_DISCRETE_FOG (1<<24)
+#define R200_OUTPUT_PT_SIZE (1<<25)
+#define R200_FORCE_INORDER_PROC (1<<31)
+#define R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0 0x2254
+#define R200_VERTEX_POSITION_ADDR__SHIFT 0x00000000
+#define R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_1 0x2258
+#define R200_VTX_COLOR_0_ADDR__SHIFT 0x00000000
+#define R200_VTX_COLOR_1_ADDR__SHIFT 0x00000008
+#define R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_2 0x225c
+#define R200_VTX_TEX_0_ADDR__SHIFT 0x00000000
+#define R200_VTX_TEX_1_ADDR__SHIFT 0x00000008
+#define R200_VTX_TEX_2_ADDR__SHIFT 0x00000010
+#define R200_VTX_TEX_3_ADDR__SHIFT 0x00000018
+#define R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_3 0x2260
+#define R200_VTX_TEX_4_ADDR__SHIFT 0x00000000
+#define R200_VTX_TEX_5_ADDR__SHIFT 0x00000008
+
+/* gap */
+#define R200_SE_TCL_LIGHT_MODEL_CTL_0 0x2268
+#define R200_LIGHTING_ENABLE (1<<0)
+#define R200_LIGHT_IN_MODELSPACE (1<<1)
+#define R200_LOCAL_VIEWER (1<<2)
+#define R200_NORMALIZE_NORMALS (1<<3)
+#define R200_RESCALE_NORMALS (1<<4)
+#define R200_SPECULAR_LIGHTS (1<<5)
+#define R200_DIFFUSE_SPECULAR_COMBINE (1<<6)
+#define R200_LIGHT_ALPHA (1<<7)
+#define R200_LOCAL_LIGHT_VEC_GL (1<<8)
+#define R200_LIGHT_NO_NORMAL_AMBIENT_ONLY (1<<9)
+#define R200_LIGHT_TWOSIDE (1<<10)
+#define R200_FRONT_SHININESS_SOURCE_SHIFT (0xb)
+#define R200_BACK_SHININESS_SOURCE_SHIFT (0xd)
+#define R200_LM0_SOURCE_MATERIAL_0 (0)
+#define R200_LM0_SOURCE_MATERIAL_1 (1)
+#define R200_LM0_SOURCE_VERTEX_SHININESS_0 (2)
+#define R200_LM0_SOURCE_VERTEX_SHININESS_1 (3)
+#define R200_SE_TCL_LIGHT_MODEL_CTL_1 0x226c
+#define R200_LM1_SOURCE_LIGHT_PREMULT (0)
+#define R200_LM1_SOURCE_MATERIAL_0 (1)
+#define R200_LM1_SOURCE_VERTEX_COLOR_0 (2)
+#define R200_LM1_SOURCE_VERTEX_COLOR_1 (3)
+#define R200_LM1_SOURCE_VERTEX_COLOR_2 (4)
+#define R200_LM1_SOURCE_VERTEX_COLOR_3 (5)
+#define R200_LM1_SOURCE_VERTEX_COLOR_4 (6)
+#define R200_LM1_SOURCE_VERTEX_COLOR_5 (7)
+#define R200_LM1_SOURCE_VERTEX_COLOR_6 (8)
+#define R200_LM1_SOURCE_VERTEX_COLOR_7 (9)
+#define R200_LM1_SOURCE_MATERIAL_1 (0xf)
+#define R200_FRONT_EMISSIVE_SOURCE_SHIFT (0)
+#define R200_FRONT_AMBIENT_SOURCE_SHIFT (4)
+#define R200_FRONT_DIFFUSE_SOURCE_SHIFT (8)
+#define R200_FRONT_SPECULAR_SOURCE_SHIFT (12)
+#define R200_BACK_EMISSIVE_SOURCE_SHIFT (16)
+#define R200_BACK_AMBIENT_SOURCE_SHIFT (20)
+#define R200_BACK_DIFFUSE_SOURCE_SHIFT (24)
+#define R200_BACK_SPECULAR_SOURCE_SHIFT (28)
+#define R200_SE_TCL_PER_LIGHT_CTL_0 0x2270
+#define R200_LIGHT_0_ENABLE (1<<0)
+#define R200_LIGHT_0_ENABLE_AMBIENT (1<<1)
+#define R200_LIGHT_0_ENABLE_SPECULAR (1<<2)
+#define R200_LIGHT_0_IS_LOCAL (1<<3)
+#define R200_LIGHT_0_IS_SPOT (1<<4)
+#define R200_LIGHT_0_DUAL_CONE (1<<5)
+#define R200_LIGHT_0_ENABLE_RANGE_ATTEN (1<<6)
+#define R200_LIGHT_0_CONSTANT_RANGE_ATTEN (1<<7)
+#define R200_LIGHT_1_ENABLE (1<<16)
+#define R200_LIGHT_1_ENABLE_AMBIENT (1<<17)
+#define R200_LIGHT_1_ENABLE_SPECULAR (1<<18)
+#define R200_LIGHT_1_IS_LOCAL (1<<19)
+#define R200_LIGHT_1_IS_SPOT (1<<20)
+#define R200_LIGHT_1_DUAL_CONE (1<<21)
+#define R200_LIGHT_1_ENABLE_RANGE_ATTEN (1<<22)
+#define R200_LIGHT_1_CONSTANT_RANGE_ATTEN (1<<23)
+#define R200_LIGHT_0_SHIFT (0)
+#define R200_LIGHT_1_SHIFT (16)
+#define R200_SE_TCL_PER_LIGHT_CTL_1 0x2274
+#define R200_LIGHT_2_SHIFT (0)
+#define R200_LIGHT_3_SHIFT (16)
+#define R200_SE_TCL_PER_LIGHT_CTL_2 0x2278
+#define R200_LIGHT_4_SHIFT (0)
+#define R200_LIGHT_5_SHIFT (16)
+#define R200_SE_TCL_PER_LIGHT_CTL_3 0x227c
+#define R200_LIGHT_6_SHIFT (0)
+#define R200_LIGHT_7_SHIFT (16)
+/* gap */
+#define R200_SE_TCL_TEX_PROC_CTL_2 0x22a8
+#define R200_TEXGEN_COMP_MASK (0xf)
+#define R200_TEXGEN_COMP_S (0x1)
+#define R200_TEXGEN_COMP_T (0x2)
+#define R200_TEXGEN_COMP_R (0x4)
+#define R200_TEXGEN_COMP_Q (0x8)
+#define R200_TEXGEN_0_COMP_MASK_SHIFT (0)
+#define R200_TEXGEN_1_COMP_MASK_SHIFT (4)
+#define R200_TEXGEN_2_COMP_MASK_SHIFT (8)
+#define R200_TEXGEN_3_COMP_MASK_SHIFT (12)
+#define R200_TEXGEN_4_COMP_MASK_SHIFT (16)
+#define R200_TEXGEN_5_COMP_MASK_SHIFT (20)
+#define R200_SE_TCL_TEX_PROC_CTL_3 0x22ac
+#define R200_TEXGEN_0_INPUT_TEX_SHIFT (0)
+#define R200_TEXGEN_1_INPUT_TEX_SHIFT (4)
+#define R200_TEXGEN_2_INPUT_TEX_SHIFT (8)
+#define R200_TEXGEN_3_INPUT_TEX_SHIFT (12)
+#define R200_TEXGEN_4_INPUT_TEX_SHIFT (16)
+#define R200_TEXGEN_5_INPUT_TEX_SHIFT (20)
+#define R200_SE_TCL_TEX_PROC_CTL_0 0x22b0
+#define R200_TEXGEN_TEXMAT_0_ENABLE (1<<0)
+#define R200_TEXGEN_TEXMAT_1_ENABLE (1<<1)
+#define R200_TEXGEN_TEXMAT_2_ENABLE (1<<2)
+#define R200_TEXGEN_TEXMAT_3_ENABLE (1<<3)
+#define R200_TEXGEN_TEXMAT_4_ENABLE (1<<4)
+#define R200_TEXGEN_TEXMAT_5_ENABLE (1<<5)
+#define R200_TEXMAT_0_ENABLE (1<<8)
+#define R200_TEXMAT_1_ENABLE (1<<9)
+#define R200_TEXMAT_2_ENABLE (1<<10)
+#define R200_TEXMAT_3_ENABLE (1<<11)
+#define R200_TEXMAT_4_ENABLE (1<<12)
+#define R200_TEXMAT_5_ENABLE (1<<13)
+#define R200_TEXGEN_FORCE_W_TO_ONE (1<<16)
+#define R200_SE_TCL_TEX_PROC_CTL_1 0x22b4
+#define R200_TEXGEN_INPUT_MASK (0xf)
+#define R200_TEXGEN_INPUT_TEXCOORD_0 (0)
+#define R200_TEXGEN_INPUT_TEXCOORD_1 (1)
+#define R200_TEXGEN_INPUT_TEXCOORD_2 (2)
+#define R200_TEXGEN_INPUT_TEXCOORD_3 (3)
+#define R200_TEXGEN_INPUT_TEXCOORD_4 (4)
+#define R200_TEXGEN_INPUT_TEXCOORD_5 (5)
+#define R200_TEXGEN_INPUT_OBJ (8)
+#define R200_TEXGEN_INPUT_EYE (9)
+#define R200_TEXGEN_INPUT_EYE_NORMAL (0xa)
+#define R200_TEXGEN_INPUT_EYE_REFLECT (0xb)
+#define R200_TEXGEN_INPUT_SPHERE (0xd)
+#define R200_TEXGEN_0_INPUT_SHIFT (0)
+#define R200_TEXGEN_1_INPUT_SHIFT (4)
+#define R200_TEXGEN_2_INPUT_SHIFT (8)
+#define R200_TEXGEN_3_INPUT_SHIFT (12)
+#define R200_TEXGEN_4_INPUT_SHIFT (16)
+#define R200_TEXGEN_5_INPUT_SHIFT (20)
+#define R200_SE_TC_TEX_CYL_WRAP_CTL 0x22b8
+/* gap */
+#define R200_SE_TCL_UCP_VERT_BLEND_CTL 0x22c0
+#define R200_UCP_IN_CLIP_SPACE (1<<0)
+#define R200_UCP_IN_MODEL_SPACE (1<<1)
+#define R200_UCP_ENABLE_0 (1<<2)
+#define R200_UCP_ENABLE_1 (1<<3)
+#define R200_UCP_ENABLE_2 (1<<4)
+#define R200_UCP_ENABLE_3 (1<<5)
+#define R200_UCP_ENABLE_4 (1<<6)
+#define R200_UCP_ENABLE_5 (1<<7)
+#define R200_TCL_FOG_MASK (3<<8)
+#define R200_TCL_FOG_DISABLE (0<<8)
+#define R200_TCL_FOG_EXP (1<<8)
+#define R200_TCL_FOG_EXP2 (2<<8)
+#define R200_TCL_FOG_LINEAR (3<<8)
+#define R200_RNG_BASED_FOG (1<<10)
+#define R200_CLIP_DISABLE (1<<11)
+#define R200_CULL_FRONT_IS_CW (0<<28)
+#define R200_CULL_FRONT_IS_CCW (1<<28)
+#define R200_CULL_FRONT (1<<29)
+#define R200_CULL_BACK (1<<30)
+#define R200_SE_TCL_POINT_SPRITE_CNTL 0x22c4
+#define R200_POINTSIZE_SEL_STATE (1<<16)
+/* gap */
+#define R200_SE_VTX_ST_POS_0_X_4 0x2300
+#define R200_SE_VTX_ST_POS_0_Y_4 0x2304
+#define R200_SE_VTX_ST_POS_0_Z_4 0x2308
+#define R200_SE_VTX_ST_POS_0_W_4 0x230c
+#define R200_SE_VTX_ST_NORM_0_X 0x2310
+#define R200_SE_VTX_ST_NORM_0_Y 0x2314
+#define R200_SE_VTX_ST_NORM_0_Z 0x2318
+#define R200_SE_VTX_ST_PVMS 0x231c
+#define R200_SE_VTX_ST_CLR_0_R 0x2320
+#define R200_SE_VTX_ST_CLR_0_G 0x2324
+#define R200_SE_VTX_ST_CLR_0_B 0x2328
+#define R200_SE_VTX_ST_CLR_0_A 0x232c
+#define R200_SE_VTX_ST_CLR_1_R 0x2330
+#define R200_SE_VTX_ST_CLR_1_G 0x2334
+#define R200_SE_VTX_ST_CLR_1_B 0x2338
+#define R200_SE_VTX_ST_CLR_1_A 0x233c
+#define R200_SE_VTX_ST_CLR_2_R 0x2340
+#define R200_SE_VTX_ST_CLR_2_G 0x2344
+#define R200_SE_VTX_ST_CLR_2_B 0x2348
+#define R200_SE_VTX_ST_CLR_2_A 0x234c
+#define R200_SE_VTX_ST_CLR_3_R 0x2350
+#define R200_SE_VTX_ST_CLR_3_G 0x2354
+#define R200_SE_VTX_ST_CLR_3_B 0x2358
+#define R200_SE_VTX_ST_CLR_3_A 0x235c
+#define R200_SE_VTX_ST_CLR_4_R 0x2360
+#define R200_SE_VTX_ST_CLR_4_G 0x2364
+#define R200_SE_VTX_ST_CLR_4_B 0x2368
+#define R200_SE_VTX_ST_CLR_4_A 0x236c
+#define R200_SE_VTX_ST_CLR_5_R 0x2370
+#define R200_SE_VTX_ST_CLR_5_G 0x2374
+#define R200_SE_VTX_ST_CLR_5_B 0x2378
+#define R200_SE_VTX_ST_CLR_5_A 0x237c
+#define R200_SE_VTX_ST_CLR_6_R 0x2380
+#define R200_SE_VTX_ST_CLR_6_G 0x2384
+#define R200_SE_VTX_ST_CLR_6_B 0x2388
+#define R200_SE_VTX_ST_CLR_6_A 0x238c
+#define R200_SE_VTX_ST_CLR_7_R 0x2390
+#define R200_SE_VTX_ST_CLR_7_G 0x2394
+#define R200_SE_VTX_ST_CLR_7_B 0x2398
+#define R200_SE_VTX_ST_CLR_7_A 0x239c
+#define R200_SE_VTX_ST_TEX_0_S 0x23a0
+#define R200_SE_VTX_ST_TEX_0_T 0x23a4
+#define R200_SE_VTX_ST_TEX_0_R 0x23a8
+#define R200_SE_VTX_ST_TEX_0_Q 0x23ac
+#define R200_SE_VTX_ST_TEX_1_S 0x23b0
+#define R200_SE_VTX_ST_TEX_1_T 0x23b4
+#define R200_SE_VTX_ST_TEX_1_R 0x23b8
+#define R200_SE_VTX_ST_TEX_1_Q 0x23bc
+#define R200_SE_VTX_ST_TEX_2_S 0x23c0
+#define R200_SE_VTX_ST_TEX_2_T 0x23c4
+#define R200_SE_VTX_ST_TEX_2_R 0x23c8
+#define R200_SE_VTX_ST_TEX_2_Q 0x23cc
+#define R200_SE_VTX_ST_TEX_3_S 0x23d0
+#define R200_SE_VTX_ST_TEX_3_T 0x23d4
+#define R200_SE_VTX_ST_TEX_3_R 0x23d8
+#define R200_SE_VTX_ST_TEX_3_Q 0x23dc
+#define R200_SE_VTX_ST_TEX_4_S 0x23e0
+#define R200_SE_VTX_ST_TEX_4_T 0x23e4
+#define R200_SE_VTX_ST_TEX_4_R 0x23e8
+#define R200_SE_VTX_ST_TEX_4_Q 0x23ec
+#define R200_SE_VTX_ST_TEX_5_S 0x23f0
+#define R200_SE_VTX_ST_TEX_5_T 0x23f4
+#define R200_SE_VTX_ST_TEX_5_R 0x23f8
+#define R200_SE_VTX_ST_TEX_5_Q 0x23fc
+#define R200_SE_VTX_ST_PNT_SPRT_SZ 0x2400
+#define R200_SE_VTX_ST_DISC_FOG 0x2404
+#define R200_SE_VTX_ST_SHININESS_0 0x2408
+#define R200_SE_VTX_ST_SHININESS_1 0x240c
+#define R200_SE_VTX_ST_BLND_WT_0 0x2410
+#define R200_SE_VTX_ST_BLND_WT_1 0x2414
+#define R200_SE_VTX_ST_BLND_WT_2 0x2418
+#define R200_SE_VTX_ST_BLND_WT_3 0x241c
+#define R200_SE_VTX_ST_POS_1_X 0x2420
+#define R200_SE_VTX_ST_POS_1_Y 0x2424
+#define R200_SE_VTX_ST_POS_1_Z 0x2428
+#define R200_SE_VTX_ST_POS_1_W 0x242c
+#define R200_SE_VTX_ST_NORM_1_X 0x2430
+#define R200_SE_VTX_ST_NORM_1_Y 0x2434
+#define R200_SE_VTX_ST_NORM_1_Z 0x2438
+#define R200_SE_VTX_ST_USR_CLR_0_R 0x2440
+#define R200_SE_VTX_ST_USR_CLR_0_G 0x2444
+#define R200_SE_VTX_ST_USR_CLR_0_B 0x2448
+#define R200_SE_VTX_ST_USR_CLR_0_A 0x244c
+#define R200_SE_VTX_ST_USR_CLR_1_R 0x2450
+#define R200_SE_VTX_ST_USR_CLR_1_G 0x2454
+#define R200_SE_VTX_ST_USR_CLR_1_B 0x2458
+#define R200_SE_VTX_ST_USR_CLR_1_A 0x245c
+#define R200_SE_VTX_ST_CLR_0_PKD 0x2460
+#define R200_SE_VTX_ST_CLR_1_PKD 0x2464
+#define R200_SE_VTX_ST_CLR_2_PKD 0x2468
+#define R200_SE_VTX_ST_CLR_3_PKD 0x246c
+#define R200_SE_VTX_ST_CLR_4_PKD 0x2470
+#define R200_SE_VTX_ST_CLR_5_PKD 0x2474
+#define R200_SE_VTX_ST_CLR_6_PKD 0x2478
+#define R200_SE_VTX_ST_CLR_7_PKD 0x247c
+#define R200_SE_VTX_ST_POS_0_X_2 0x2480
+#define R200_SE_VTX_ST_POS_0_Y_2 0x2484
+#define R200_SE_VTX_ST_PAR_CLR_LD 0x2488
+#define R200_SE_VTX_ST_USR_CLR_PKD 0x248c
+#define R200_SE_VTX_ST_POS_0_X_3 0x2490
+#define R200_SE_VTX_ST_POS_0_Y_3 0x2494
+#define R200_SE_VTX_ST_POS_0_Z_3 0x2498
+#define R200_SE_VTX_ST_END_OF_PKT 0x249c
+/* gap */
+#define R200_RE_POINTSIZE 0x2648
+#define R200_POINTSIZE_SHIFT 0
+#define R200_MAXPOINTSIZE_SHIFT 16
+/* gap */
+#define R200_RE_TOP_LEFT 0x26c0
+#define R200_RE_LEFT_SHIFT 0
+#define R200_RE_TOP_SHIFT 16
+#define R200_RE_MISC 0x26c4
+#define R200_STIPPLE_COORD_MASK 0x1f
+#define R200_STIPPLE_X_OFFSET_SHIFT 0
+#define R200_STIPPLE_X_OFFSET_MASK (0x1f << 0)
+#define R200_STIPPLE_Y_OFFSET_SHIFT 8
+#define R200_STIPPLE_Y_OFFSET_MASK (0x1f << 8)
+#define R200_STIPPLE_LITTLE_BIT_ORDER (0 << 16)
+#define R200_STIPPLE_BIG_BIT_ORDER (1 << 16)
+/* gap */
+#define R200_RE_AUX_SCISSOR_CNTL 0x26f0
+#define R200_EXCLUSIVE_SCISSOR_0 0x01000000
+#define R200_EXCLUSIVE_SCISSOR_1 0x02000000
+#define R200_EXCLUSIVE_SCISSOR_2 0x04000000
+#define R200_SCISSOR_ENABLE_0 0x10000000
+#define R200_SCISSOR_ENABLE_1 0x20000000
+#define R200_SCISSOR_ENABLE_2 0x40000000
+/* gap */
+#define R200_PP_TXFILTER_0 0x2c00
+#define R200_MAG_FILTER_NEAREST (0 << 0)
+#define R200_MAG_FILTER_LINEAR (1 << 0)
+#define R200_MAG_FILTER_MASK (1 << 0)
+#define R200_MIN_FILTER_NEAREST (0 << 1)
+#define R200_MIN_FILTER_LINEAR (1 << 1)
+#define R200_MIN_FILTER_NEAREST_MIP_NEAREST (2 << 1)
+#define R200_MIN_FILTER_NEAREST_MIP_LINEAR (3 << 1)
+#define R200_MIN_FILTER_LINEAR_MIP_NEAREST (6 << 1)
+#define R200_MIN_FILTER_LINEAR_MIP_LINEAR (7 << 1)
+#define R200_MIN_FILTER_ANISO_NEAREST (8 << 1)
+#define R200_MIN_FILTER_ANISO_LINEAR (9 << 1)
+#define R200_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST (10 << 1)
+#define R200_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR (11 << 1)
+#define R200_MIN_FILTER_MASK (15 << 1)
+#define R200_MAX_ANISO_1_TO_1 (0 << 5)
+#define R200_MAX_ANISO_2_TO_1 (1 << 5)
+#define R200_MAX_ANISO_4_TO_1 (2 << 5)
+#define R200_MAX_ANISO_8_TO_1 (3 << 5)
+#define R200_MAX_ANISO_16_TO_1 (4 << 5)
+#define R200_MAX_ANISO_MASK (7 << 5)
+#define R200_MAX_MIP_LEVEL_MASK (0x0f << 16)
+#define R200_MAX_MIP_LEVEL_SHIFT 16
+#define R200_YUV_TO_RGB (1 << 20)
+#define R200_YUV_TEMPERATURE_COOL (0 << 21)
+#define R200_YUV_TEMPERATURE_HOT (1 << 21)
+#define R200_YUV_TEMPERATURE_MASK (1 << 21)
+#define R200_WRAPEN_S (1 << 22)
+#define R200_CLAMP_S_WRAP (0 << 23)
+#define R200_CLAMP_S_MIRROR (1 << 23)
+#define R200_CLAMP_S_CLAMP_LAST (2 << 23)
+#define R200_CLAMP_S_MIRROR_CLAMP_LAST (3 << 23)
+#define R200_CLAMP_S_CLAMP_BORDER (4 << 23)
+#define R200_CLAMP_S_MIRROR_CLAMP_BORDER (5 << 23)
+#define R200_CLAMP_S_CLAMP_GL (6 << 23)
+#define R200_CLAMP_S_MIRROR_CLAMP_GL (7 << 23)
+#define R200_CLAMP_S_MASK (7 << 23)
+#define R200_WRAPEN_T (1 << 26)
+#define R200_CLAMP_T_WRAP (0 << 27)
+#define R200_CLAMP_T_MIRROR (1 << 27)
+#define R200_CLAMP_T_CLAMP_LAST (2 << 27)
+#define R200_CLAMP_T_MIRROR_CLAMP_LAST (3 << 27)
+#define R200_CLAMP_T_CLAMP_BORDER (4 << 27)
+#define R200_CLAMP_T_MIRROR_CLAMP_BORDER (5 << 27)
+#define R200_CLAMP_T_CLAMP_GL (6 << 27)
+#define R200_CLAMP_T_MIRROR_CLAMP_GL (7 << 27)
+#define R200_CLAMP_T_MASK (7 << 27)
+#define R200_KILL_LT_ZERO (1 << 30)
+#define R200_BORDER_MODE_OGL (0 << 31)
+#define R200_BORDER_MODE_D3D (1 << 31)
+#define R200_PP_TXFORMAT_0 0x2c04
+#define R200_TXFORMAT_I8 (0 << 0)
+#define R200_TXFORMAT_AI88 (1 << 0)
+#define R200_TXFORMAT_RGB332 (2 << 0)
+#define R200_TXFORMAT_ARGB1555 (3 << 0)
+#define R200_TXFORMAT_RGB565 (4 << 0)
+#define R200_TXFORMAT_ARGB4444 (5 << 0)
+#define R200_TXFORMAT_ARGB8888 (6 << 0)
+#define R200_TXFORMAT_RGBA8888 (7 << 0)
+#define R200_TXFORMAT_Y8 (8 << 0)
+#define R200_TXFORMAT_AVYU4444 (9 << 0)
+#define R200_TXFORMAT_VYUY422 (10 << 0)
+#define R200_TXFORMAT_YVYU422 (11 << 0)
+#define R200_TXFORMAT_DXT1 (12 << 0)
+#define R200_TXFORMAT_DXT23 (14 << 0)
+#define R200_TXFORMAT_DXT45 (15 << 0)
+#define R200_TXFORMAT_DVDU88 (18 << 0)
+#define R200_TXFORMAT_LDVDU655 (19 << 0)
+#define R200_TXFORMAT_LDVDU8888 (20 << 0)
+#define R200_TXFORMAT_GR1616 (21 << 0)
+#define R200_TXFORMAT_ABGR8888 (22 << 0)
+#define R200_TXFORMAT_BGR111110 (23 << 0)
+#define R200_TXFORMAT_FORMAT_MASK (31 << 0)
+#define R200_TXFORMAT_FORMAT_SHIFT 0
+#define R200_TXFORMAT_APPLE_YUV (1 << 5)
+#define R200_TXFORMAT_ALPHA_IN_MAP (1 << 6)
+#define R200_TXFORMAT_NON_POWER2 (1 << 7)
+#define R200_TXFORMAT_WIDTH_MASK (15 << 8)
+#define R200_TXFORMAT_WIDTH_SHIFT 8
+#define R200_TXFORMAT_HEIGHT_MASK (15 << 12)
+#define R200_TXFORMAT_HEIGHT_SHIFT 12
+#define R200_TXFORMAT_F5_WIDTH_MASK (15 << 16) /* cube face 5 */
+#define R200_TXFORMAT_F5_WIDTH_SHIFT 16
+#define R200_TXFORMAT_F5_HEIGHT_MASK (15 << 20)
+#define R200_TXFORMAT_F5_HEIGHT_SHIFT 20
+#define R200_TXFORMAT_ST_ROUTE_STQ0 (0 << 24)
+#define R200_TXFORMAT_ST_ROUTE_STQ1 (1 << 24)
+#define R200_TXFORMAT_ST_ROUTE_STQ2 (2 << 24)
+#define R200_TXFORMAT_ST_ROUTE_STQ3 (3 << 24)
+#define R200_TXFORMAT_ST_ROUTE_STQ4 (4 << 24)
+#define R200_TXFORMAT_ST_ROUTE_STQ5 (5 << 24)
+#define R200_TXFORMAT_ST_ROUTE_MASK (7 << 24)
+#define R200_TXFORMAT_ST_ROUTE_SHIFT 24
+#define R200_TXFORMAT_LOOKUP_DISABLE (1 << 27)
+#define R200_TXFORMAT_ALPHA_MASK_ENABLE (1 << 28)
+#define R200_TXFORMAT_CHROMA_KEY_ENABLE (1 << 29)
+#define R200_TXFORMAT_CUBIC_MAP_ENABLE (1 << 30)
+#define R200_PP_TXFORMAT_X_0 0x2c08
+#define R200_DEPTH_LOG2_MASK (0xf << 0)
+#define R200_DEPTH_LOG2_SHIFT 0
+#define R200_VOLUME_FILTER_SHIFT 4
+#define R200_VOLUME_FILTER_MASK (1 << 4)
+#define R200_VOLUME_FILTER_NEAREST (0 << 4)
+#define R200_VOLUME_FILTER_LINEAR (1 << 4)
+#define R200_WRAPEN_Q (1 << 8)
+#define R200_CLAMP_Q_WRAP (0 << 9)
+#define R200_CLAMP_Q_MIRROR (1 << 9)
+#define R200_CLAMP_Q_CLAMP_LAST (2 << 9)
+#define R200_CLAMP_Q_MIRROR_CLAMP_LAST (3 << 9)
+#define R200_CLAMP_Q_CLAMP_BORDER (4 << 9)
+#define R200_CLAMP_Q_MIRROR_CLAMP_BORDER (5 << 9)
+#define R200_CLAMP_Q_CLAMP_GL (6 << 9)
+#define R200_CLAMP_Q_MIRROR_CLAMP_GL (7 << 9)
+#define R200_CLAMP_Q_MASK (7 << 9)
+#define R200_MIN_MIP_LEVEL_MASK (0xff << 12)
+#define R200_MIN_MIP_LEVEL_SHIFT 12
+#define R200_TEXCOORD_NONPROJ (0 << 16)
+#define R200_TEXCOORD_CUBIC_ENV (1 << 16)
+#define R200_TEXCOORD_VOLUME (2 << 16)
+#define R200_TEXCOORD_PROJ (3 << 16)
+#define R200_TEXCOORD_DEPTH (4 << 16)
+#define R200_TEXCOORD_1D_PROJ (5 << 16)
+#define R200_TEXCOORD_1D (6 << 16)
+#define R200_TEXCOORD_ZERO (7 << 16)
+#define R200_TEXCOORD_MASK (7 << 16)
+#define R200_LOD_BIAS_MASK (0xfff80000)
+#define R200_LOD_BIAS_SHIFT 19
+#define R200_PP_TXSIZE_0 0x2c0c /* NPOT only */
+#define R200_PP_TXPITCH_0 0x2c10 /* NPOT only */
+#define R200_PP_BORDER_COLOR_0 0x2c14
+#define R200_PP_CUBIC_FACES_0 0x2c18
+#define R200_FACE_WIDTH_1_SHIFT 0
+#define R200_FACE_HEIGHT_1_SHIFT 4
+#define R200_FACE_WIDTH_1_MASK (0xf << 0)
+#define R200_FACE_HEIGHT_1_MASK (0xf << 4)
+#define R200_FACE_WIDTH_2_SHIFT 8
+#define R200_FACE_HEIGHT_2_SHIFT 12
+#define R200_FACE_WIDTH_2_MASK (0xf << 8)
+#define R200_FACE_HEIGHT_2_MASK (0xf << 12)
+#define R200_FACE_WIDTH_3_SHIFT 16
+#define R200_FACE_HEIGHT_3_SHIFT 20
+#define R200_FACE_WIDTH_3_MASK (0xf << 16)
+#define R200_FACE_HEIGHT_3_MASK (0xf << 20)
+#define R200_FACE_WIDTH_4_SHIFT 24
+#define R200_FACE_HEIGHT_4_SHIFT 28
+#define R200_FACE_WIDTH_4_MASK (0xf << 24)
+#define R200_FACE_HEIGHT_4_MASK (0xf << 28)
+#define R200_PP_TXFILTER_1 0x2c20
+#define R200_PP_TXFORMAT_1 0x2c24
+#define R200_PP_TXFORMAT_X_1 0x2c28
+#define R200_PP_TXSIZE_1 0x2c2c
+#define R200_PP_TXPITCH_1 0x2c30
+#define R200_PP_BORDER_COLOR_1 0x2c34
+#define R200_PP_CUBIC_FACES_1 0x2c38
+#define R200_PP_TXFILTER_2 0x2c40
+#define R200_PP_TXFORMAT_2 0x2c44
+#define R200_PP_TXSIZE_2 0x2c4c
+#define R200_PP_TXFORMAT_X_2 0x2c48
+#define R200_PP_TXPITCH_2 0x2c50
+#define R200_PP_BORDER_COLOR_2 0x2c54
+#define R200_PP_CUBIC_FACES_2 0x2c58
+#define R200_PP_TXFILTER_3 0x2c60
+#define R200_PP_TXFORMAT_3 0x2c64
+#define R200_PP_TXSIZE_3 0x2c6c
+#define R200_PP_TXFORMAT_X_3 0x2c68
+#define R200_PP_TXPITCH_3 0x2c70
+#define R200_PP_BORDER_COLOR_3 0x2c74
+#define R200_PP_CUBIC_FACES_3 0x2c78
+#define R200_PP_TXFILTER_4 0x2c80
+#define R200_PP_TXFORMAT_4 0x2c84
+#define R200_PP_TXSIZE_4 0x2c8c
+#define R200_PP_TXFORMAT_X_4 0x2c88
+#define R200_PP_TXPITCH_4 0x2c90
+#define R200_PP_BORDER_COLOR_4 0x2c94
+#define R200_PP_CUBIC_FACES_4 0x2c98
+#define R200_PP_TXFILTER_5 0x2ca0
+#define R200_PP_TXFORMAT_5 0x2ca4
+#define R200_PP_TXSIZE_5 0x2cac
+#define R200_PP_TXFORMAT_X_5 0x2ca8
+#define R200_PP_TXPITCH_5 0x2cb0
+#define R200_PP_BORDER_COLOR_5 0x2cb4
+#define R200_PP_CUBIC_FACES_5 0x2cb8
+/* gap */
+#define R200_PP_CNTL_X 0x2cc4
+/* gap */
+#define R200_PP_TRI_PERF 0x2cf8
+#define R200_TRI_CUTOFF_MASK (0x1f << 0)
+#define R200_PP_PERF_CNTL 0x2cfc
+#define R200_PP_TXOFFSET_0 0x2d00
+#define R200_TXO_ENDIAN_NO_SWAP (0 << 0)
+#define R200_TXO_ENDIAN_BYTE_SWAP (1 << 0)
+#define R200_TXO_ENDIAN_WORD_SWAP (2 << 0)
+#define R200_TXO_ENDIAN_HALFDW_SWAP (3 << 0)
+#define R200_TXO_MACRO_TILE (1 << 2)
+#define R200_TXO_MICRO_TILE (1 << 3)
+#define R200_TXO_OFFSET_MASK 0xffffffe0
+#define R200_TXO_OFFSET_SHIFT 5
+#define R200_PP_CUBIC_OFFSET_F1_0 0x2d04
+#define R200_PP_CUBIC_OFFSET_F2_0 0x2d08
+#define R200_PP_CUBIC_OFFSET_F3_0 0x2d0c
+#define R200_PP_CUBIC_OFFSET_F4_0 0x2d10
+#define R200_PP_CUBIC_OFFSET_F5_0 0x2d14
+#define R200_PP_TXOFFSET_1 0x2d18
+#define R200_PP_CUBIC_OFFSET_F1_1 0x2d1c
+#define R200_PP_CUBIC_OFFSET_F2_1 0x2d20
+#define R200_PP_CUBIC_OFFSET_F3_1 0x2d24
+#define R200_PP_CUBIC_OFFSET_F4_1 0x2d28
+#define R200_PP_CUBIC_OFFSET_F5_1 0x2d2c
+#define R200_PP_TXOFFSET_2 0x2d30
+#define R200_PP_CUBIC_OFFSET_F1_2 0x2d34
+#define R200_PP_CUBIC_OFFSET_F2_2 0x2d38
+#define R200_PP_CUBIC_OFFSET_F3_2 0x2d3c
+#define R200_PP_CUBIC_OFFSET_F4_2 0x2d40
+#define R200_PP_CUBIC_OFFSET_F5_2 0x2d44
+#define R200_PP_TXOFFSET_3 0x2d48
+#define R200_PP_CUBIC_OFFSET_F1_3 0x2d4c
+#define R200_PP_CUBIC_OFFSET_F2_3 0x2d50
+#define R200_PP_CUBIC_OFFSET_F3_3 0x2d54
+#define R200_PP_CUBIC_OFFSET_F4_3 0x2d58
+#define R200_PP_CUBIC_OFFSET_F5_3 0x2d5c
+#define R200_PP_TXOFFSET_4 0x2d60
+#define R200_PP_CUBIC_OFFSET_F1_4 0x2d64
+#define R200_PP_CUBIC_OFFSET_F2_4 0x2d68
+#define R200_PP_CUBIC_OFFSET_F3_4 0x2d6c
+#define R200_PP_CUBIC_OFFSET_F4_4 0x2d70
+#define R200_PP_CUBIC_OFFSET_F5_4 0x2d74
+#define R200_PP_TXOFFSET_5 0x2d78
+#define R200_PP_CUBIC_OFFSET_F1_5 0x2d7c
+#define R200_PP_CUBIC_OFFSET_F2_5 0x2d80
+#define R200_PP_CUBIC_OFFSET_F3_5 0x2d84
+#define R200_PP_CUBIC_OFFSET_F4_5 0x2d88
+#define R200_PP_CUBIC_OFFSET_F5_5 0x2d8c
+/* gap */
+#define R200_PP_TAM_DEBUG3 0x2d9c
+/* gap */
+#define R200_PP_TFACTOR_0 0x2ee0
+#define R200_PP_TFACTOR_1 0x2ee4
+#define R200_PP_TFACTOR_2 0x2ee8
+#define R200_PP_TFACTOR_3 0x2eec
+#define R200_PP_TFACTOR_4 0x2ef0
+#define R200_PP_TFACTOR_5 0x2ef4
+/* gap */
+#define R200_PP_TXCBLEND_0 0x2f00
+#define R200_TXC_ARG_A_ZERO (0)
+#define R200_TXC_ARG_A_CURRENT_COLOR (2)
+#define R200_TXC_ARG_A_CURRENT_ALPHA (3)
+#define R200_TXC_ARG_A_DIFFUSE_COLOR (4)
+#define R200_TXC_ARG_A_DIFFUSE_ALPHA (5)
+#define R200_TXC_ARG_A_SPECULAR_COLOR (6)
+#define R200_TXC_ARG_A_SPECULAR_ALPHA (7)
+#define R200_TXC_ARG_A_TFACTOR_COLOR (8)
+#define R200_TXC_ARG_A_TFACTOR_ALPHA (9)
+#define R200_TXC_ARG_A_R0_COLOR (10)
+#define R200_TXC_ARG_A_R0_ALPHA (11)
+#define R200_TXC_ARG_A_R1_COLOR (12)
+#define R200_TXC_ARG_A_R1_ALPHA (13)
+#define R200_TXC_ARG_A_R2_COLOR (14)
+#define R200_TXC_ARG_A_R2_ALPHA (15)
+#define R200_TXC_ARG_A_R3_COLOR (16)
+#define R200_TXC_ARG_A_R3_ALPHA (17)
+#define R200_TXC_ARG_A_R4_COLOR (18)
+#define R200_TXC_ARG_A_R4_ALPHA (19)
+#define R200_TXC_ARG_A_R5_COLOR (20)
+#define R200_TXC_ARG_A_R5_ALPHA (21)
+#define R200_TXC_ARG_A_TFACTOR1_COLOR (26)
+#define R200_TXC_ARG_A_TFACTOR1_ALPHA (27)
+#define R200_TXC_ARG_A_MASK (31 << 0)
+#define R200_TXC_ARG_A_SHIFT 0
+#define R200_TXC_ARG_B_ZERO (0<<5)
+#define R200_TXC_ARG_B_CURRENT_COLOR (2<<5)
+#define R200_TXC_ARG_B_CURRENT_ALPHA (3<<5)
+#define R200_TXC_ARG_B_DIFFUSE_COLOR (4<<5)
+#define R200_TXC_ARG_B_DIFFUSE_ALPHA (5<<5)
+#define R200_TXC_ARG_B_SPECULAR_COLOR (6<<5)
+#define R200_TXC_ARG_B_SPECULAR_ALPHA (7<<5)
+#define R200_TXC_ARG_B_TFACTOR_COLOR (8<<5)
+#define R200_TXC_ARG_B_TFACTOR_ALPHA (9<<5)
+#define R200_TXC_ARG_B_R0_COLOR (10<<5)
+#define R200_TXC_ARG_B_R0_ALPHA (11<<5)
+#define R200_TXC_ARG_B_R1_COLOR (12<<5)
+#define R200_TXC_ARG_B_R1_ALPHA (13<<5)
+#define R200_TXC_ARG_B_R2_COLOR (14<<5)
+#define R200_TXC_ARG_B_R2_ALPHA (15<<5)
+#define R200_TXC_ARG_B_R3_COLOR (16<<5)
+#define R200_TXC_ARG_B_R3_ALPHA (17<<5)
+#define R200_TXC_ARG_B_R4_COLOR (18<<5)
+#define R200_TXC_ARG_B_R4_ALPHA (19<<5)
+#define R200_TXC_ARG_B_R5_COLOR (20<<5)
+#define R200_TXC_ARG_B_R5_ALPHA (21<<5)
+#define R200_TXC_ARG_B_TFACTOR1_COLOR (26<<5)
+#define R200_TXC_ARG_B_TFACTOR1_ALPHA (27<<5)
+#define R200_TXC_ARG_B_MASK (31 << 5)
+#define R200_TXC_ARG_B_SHIFT 5
+#define R200_TXC_ARG_C_ZERO (0<<10)
+#define R200_TXC_ARG_C_CURRENT_COLOR (2<<10)
+#define R200_TXC_ARG_C_CURRENT_ALPHA (3<<10)
+#define R200_TXC_ARG_C_DIFFUSE_COLOR (4<<10)
+#define R200_TXC_ARG_C_DIFFUSE_ALPHA (5<<10)
+#define R200_TXC_ARG_C_SPECULAR_COLOR (6<<10)
+#define R200_TXC_ARG_C_SPECULAR_ALPHA (7<<10)
+#define R200_TXC_ARG_C_TFACTOR_COLOR (8<<10)
+#define R200_TXC_ARG_C_TFACTOR_ALPHA (9<<10)
+#define R200_TXC_ARG_C_R0_COLOR (10<<10)
+#define R200_TXC_ARG_C_R0_ALPHA (11<<10)
+#define R200_TXC_ARG_C_R1_COLOR (12<<10)
+#define R200_TXC_ARG_C_R1_ALPHA (13<<10)
+#define R200_TXC_ARG_C_R2_COLOR (14<<10)
+#define R200_TXC_ARG_C_R2_ALPHA (15<<10)
+#define R200_TXC_ARG_C_R3_COLOR (16<<10)
+#define R200_TXC_ARG_C_R3_ALPHA (17<<10)
+#define R200_TXC_ARG_C_R4_COLOR (18<<10)
+#define R200_TXC_ARG_C_R4_ALPHA (19<<10)
+#define R200_TXC_ARG_C_R5_COLOR (20<<10)
+#define R200_TXC_ARG_C_R5_ALPHA (21<<10)
+#define R200_TXC_ARG_C_TFACTOR1_COLOR (26<<10)
+#define R200_TXC_ARG_C_TFACTOR1_ALPHA (27<<10)
+#define R200_TXC_ARG_C_MASK (31 << 10)
+#define R200_TXC_ARG_C_SHIFT 10
+#define R200_TXC_COMP_ARG_A (1 << 16)
+#define R200_TXC_COMP_ARG_A_SHIFT (16)
+#define R200_TXC_BIAS_ARG_A (1 << 17)
+#define R200_TXC_SCALE_ARG_A (1 << 18)
+#define R200_TXC_NEG_ARG_A (1 << 19)
+#define R200_TXC_COMP_ARG_B (1 << 20)
+#define R200_TXC_COMP_ARG_B_SHIFT (20)
+#define R200_TXC_BIAS_ARG_B (1 << 21)
+#define R200_TXC_SCALE_ARG_B (1 << 22)
+#define R200_TXC_NEG_ARG_B (1 << 23)
+#define R200_TXC_COMP_ARG_C (1 << 24)
+#define R200_TXC_COMP_ARG_C_SHIFT (24)
+#define R200_TXC_BIAS_ARG_C (1 << 25)
+#define R200_TXC_SCALE_ARG_C (1 << 26)
+#define R200_TXC_NEG_ARG_C (1 << 27)
+#define R200_TXC_OP_MADD (0 << 28)
+#define R200_TXC_OP_CND0 (2 << 28)
+#define R200_TXC_OP_LERP (3 << 28)
+#define R200_TXC_OP_DOT3 (4 << 28)
+#define R200_TXC_OP_DOT4 (5 << 28)
+#define R200_TXC_OP_CONDITIONAL (6 << 28)
+#define R200_TXC_OP_DOT2_ADD (7 << 28)
+#define R200_TXC_OP_MASK (7 << 28)
+#define R200_PP_TXCBLEND2_0 0x2f04
+#define R200_TXC_TFACTOR_SEL_SHIFT 0
+#define R200_TXC_TFACTOR_SEL_MASK 0x7
+#define R200_TXC_TFACTOR1_SEL_SHIFT 4
+#define R200_TXC_TFACTOR1_SEL_MASK (0x7 << 4)
+#define R200_TXC_SCALE_SHIFT 8
+#define R200_TXC_SCALE_MASK (7 << 8)
+#define R200_TXC_SCALE_1X (0 << 8)
+#define R200_TXC_SCALE_2X (1 << 8)
+#define R200_TXC_SCALE_4X (2 << 8)
+#define R200_TXC_SCALE_8X (3 << 8)
+#define R200_TXC_SCALE_INV2 (5 << 8)
+#define R200_TXC_SCALE_INV4 (6 << 8)
+#define R200_TXC_SCALE_INV8 (7 << 8)
+#define R200_TXC_CLAMP_SHIFT 12
+#define R200_TXC_CLAMP_MASK (3 << 12)
+#define R200_TXC_CLAMP_WRAP (0 << 12)
+#define R200_TXC_CLAMP_0_1 (1 << 12)
+#define R200_TXC_CLAMP_8_8 (2 << 12)
+#define R200_TXC_OUTPUT_REG_MASK (7 << 16)
+#define R200_TXC_OUTPUT_REG_NONE (0 << 16)
+#define R200_TXC_OUTPUT_REG_R0 (1 << 16)
+#define R200_TXC_OUTPUT_REG_R1 (2 << 16)
+#define R200_TXC_OUTPUT_REG_R2 (3 << 16)
+#define R200_TXC_OUTPUT_REG_R3 (4 << 16)
+#define R200_TXC_OUTPUT_REG_R4 (5 << 16)
+#define R200_TXC_OUTPUT_REG_R5 (6 << 16)
+#define R200_TXC_OUTPUT_MASK_MASK (7 << 20)
+#define R200_TXC_OUTPUT_MASK_RGB (0 << 20)
+#define R200_TXC_OUTPUT_MASK_RG (1 << 20)
+#define R200_TXC_OUTPUT_MASK_RB (2 << 20)
+#define R200_TXC_OUTPUT_MASK_R (3 << 20)
+#define R200_TXC_OUTPUT_MASK_GB (4 << 20)
+#define R200_TXC_OUTPUT_MASK_G (5 << 20)
+#define R200_TXC_OUTPUT_MASK_B (6 << 20)
+#define R200_TXC_OUTPUT_MASK_NONE (7 << 20)
+#define R200_TXC_REPL_NORMAL 0
+#define R200_TXC_REPL_RED 1
+#define R200_TXC_REPL_GREEN 2
+#define R200_TXC_REPL_BLUE 3
+#define R200_TXC_REPL_ARG_A_SHIFT 26
+#define R200_TXC_REPL_ARG_A_MASK (3 << 26)
+#define R200_TXC_REPL_ARG_B_SHIFT 28
+#define R200_TXC_REPL_ARG_B_MASK (3 << 28)
+#define R200_TXC_REPL_ARG_C_SHIFT 30
+#define R200_TXC_REPL_ARG_C_MASK (3 << 30)
+#define R200_PP_TXABLEND_0 0x2f08
+#define R200_TXA_ARG_A_ZERO (0)
+#define R200_TXA_ARG_A_CURRENT_ALPHA (2) /* guess */
+#define R200_TXA_ARG_A_CURRENT_BLUE (3) /* guess */
+#define R200_TXA_ARG_A_DIFFUSE_ALPHA (4)
+#define R200_TXA_ARG_A_DIFFUSE_BLUE (5)
+#define R200_TXA_ARG_A_SPECULAR_ALPHA (6)
+#define R200_TXA_ARG_A_SPECULAR_BLUE (7)
+#define R200_TXA_ARG_A_TFACTOR_ALPHA (8)
+#define R200_TXA_ARG_A_TFACTOR_BLUE (9)
+#define R200_TXA_ARG_A_R0_ALPHA (10)
+#define R200_TXA_ARG_A_R0_BLUE (11)
+#define R200_TXA_ARG_A_R1_ALPHA (12)
+#define R200_TXA_ARG_A_R1_BLUE (13)
+#define R200_TXA_ARG_A_R2_ALPHA (14)
+#define R200_TXA_ARG_A_R2_BLUE (15)
+#define R200_TXA_ARG_A_R3_ALPHA (16)
+#define R200_TXA_ARG_A_R3_BLUE (17)
+#define R200_TXA_ARG_A_R4_ALPHA (18)
+#define R200_TXA_ARG_A_R4_BLUE (19)
+#define R200_TXA_ARG_A_R5_ALPHA (20)
+#define R200_TXA_ARG_A_R5_BLUE (21)
+#define R200_TXA_ARG_A_TFACTOR1_ALPHA (26)
+#define R200_TXA_ARG_A_TFACTOR1_BLUE (27)
+#define R200_TXA_ARG_A_MASK (31 << 0)
+#define R200_TXA_ARG_A_SHIFT 0
+#define R200_TXA_ARG_B_ZERO (0<<5)
+#define R200_TXA_ARG_B_CURRENT_ALPHA (2<<5) /* guess */
+#define R200_TXA_ARG_B_CURRENT_BLUE (3<<5) /* guess */
+#define R200_TXA_ARG_B_DIFFUSE_ALPHA (4<<5)
+#define R200_TXA_ARG_B_DIFFUSE_BLUE (5<<5)
+#define R200_TXA_ARG_B_SPECULAR_ALPHA (6<<5)
+#define R200_TXA_ARG_B_SPECULAR_BLUE (7<<5)
+#define R200_TXA_ARG_B_TFACTOR_ALPHA (8<<5)
+#define R200_TXA_ARG_B_TFACTOR_BLUE (9<<5)
+#define R200_TXA_ARG_B_R0_ALPHA (10<<5)
+#define R200_TXA_ARG_B_R0_BLUE (11<<5)
+#define R200_TXA_ARG_B_R1_ALPHA (12<<5)
+#define R200_TXA_ARG_B_R1_BLUE (13<<5)
+#define R200_TXA_ARG_B_R2_ALPHA (14<<5)
+#define R200_TXA_ARG_B_R2_BLUE (15<<5)
+#define R200_TXA_ARG_B_R3_ALPHA (16<<5)
+#define R200_TXA_ARG_B_R3_BLUE (17<<5)
+#define R200_TXA_ARG_B_R4_ALPHA (18<<5)
+#define R200_TXA_ARG_B_R4_BLUE (19<<5)
+#define R200_TXA_ARG_B_R5_ALPHA (20<<5)
+#define R200_TXA_ARG_B_R5_BLUE (21<<5)
+#define R200_TXA_ARG_B_TFACTOR1_ALPHA (26<<5)
+#define R200_TXA_ARG_B_TFACTOR1_BLUE (27<<5)
+#define R200_TXA_ARG_B_MASK (31 << 5)
+#define R200_TXA_ARG_B_SHIFT 5
+#define R200_TXA_ARG_C_ZERO (0<<10)
+#define R200_TXA_ARG_C_CURRENT_ALPHA (2<<10) /* guess */
+#define R200_TXA_ARG_C_CURRENT_BLUE (3<<10) /* guess */
+#define R200_TXA_ARG_C_DIFFUSE_ALPHA (4<<10)
+#define R200_TXA_ARG_C_DIFFUSE_BLUE (5<<10)
+#define R200_TXA_ARG_C_SPECULAR_ALPHA (6<<10)
+#define R200_TXA_ARG_C_SPECULAR_BLUE (7<<10)
+#define R200_TXA_ARG_C_TFACTOR_ALPHA (8<<10)
+#define R200_TXA_ARG_C_TFACTOR_BLUE (9<<10)
+#define R200_TXA_ARG_C_R0_ALPHA (10<<10)
+#define R200_TXA_ARG_C_R0_BLUE (11<<10)
+#define R200_TXA_ARG_C_R1_ALPHA (12<<10)
+#define R200_TXA_ARG_C_R1_BLUE (13<<10)
+#define R200_TXA_ARG_C_R2_ALPHA (14<<10)
+#define R200_TXA_ARG_C_R2_BLUE (15<<10)
+#define R200_TXA_ARG_C_R3_ALPHA (16<<10)
+#define R200_TXA_ARG_C_R3_BLUE (17<<10)
+#define R200_TXA_ARG_C_R4_ALPHA (18<<10)
+#define R200_TXA_ARG_C_R4_BLUE (19<<10)
+#define R200_TXA_ARG_C_R5_ALPHA (20<<10)
+#define R200_TXA_ARG_C_R5_BLUE (21<<10)
+#define R200_TXA_ARG_C_TFACTOR1_ALPHA (26<<10)
+#define R200_TXA_ARG_C_TFACTOR1_BLUE (27<<10)
+#define R200_TXA_ARG_C_MASK (31 << 10)
+#define R200_TXA_ARG_C_SHIFT 10
+#define R200_TXA_COMP_ARG_A (1 << 16)
+#define R200_TXA_COMP_ARG_A_SHIFT (16)
+#define R200_TXA_BIAS_ARG_A (1 << 17)
+#define R200_TXA_SCALE_ARG_A (1 << 18)
+#define R200_TXA_NEG_ARG_A (1 << 19)
+#define R200_TXA_COMP_ARG_B (1 << 20)
+#define R200_TXA_COMP_ARG_B_SHIFT (20)
+#define R200_TXA_BIAS_ARG_B (1 << 21)
+#define R200_TXA_SCALE_ARG_B (1 << 22)
+#define R200_TXA_NEG_ARG_B (1 << 23)
+#define R200_TXA_COMP_ARG_C (1 << 24)
+#define R200_TXA_COMP_ARG_C_SHIFT (24)
+#define R200_TXA_BIAS_ARG_C (1 << 25)
+#define R200_TXA_SCALE_ARG_C (1 << 26)
+#define R200_TXA_NEG_ARG_C (1 << 27)
+#define R200_TXA_OP_MADD (0 << 28)
+#define R200_TXA_OP_CND0 (2 << 28)
+#define R200_TXA_OP_LERP (3 << 28)
+#define R200_TXA_OP_CONDITIONAL (6 << 28)
+#define R200_TXA_OP_MASK (7 << 28)
+#define R200_PP_TXABLEND2_0 0x2f0c
+#define R200_TXA_TFACTOR_SEL_SHIFT 0
+#define R200_TXA_TFACTOR_SEL_MASK 0x7
+#define R200_TXA_TFACTOR1_SEL_SHIFT 4
+#define R200_TXA_TFACTOR1_SEL_MASK (0x7 << 4)
+#define R200_TXA_SCALE_SHIFT 8
+#define R200_TXA_SCALE_MASK (7 << 8)
+#define R200_TXA_SCALE_1X (0 << 8)
+#define R200_TXA_SCALE_2X (1 << 8)
+#define R200_TXA_SCALE_4X (2 << 8)
+#define R200_TXA_SCALE_8X (3 << 8)
+#define R200_TXA_SCALE_INV2 (5 << 8)
+#define R200_TXA_SCALE_INV4 (6 << 8)
+#define R200_TXA_SCALE_INV8 (7 << 8)
+#define R200_TXA_CLAMP_SHIFT 12
+#define R200_TXA_CLAMP_MASK (3 << 12)
+#define R200_TXA_CLAMP_WRAP (0 << 12)
+#define R200_TXA_CLAMP_0_1 (1 << 12)
+#define R200_TXA_CLAMP_8_8 (2 << 12)
+#define R200_TXA_OUTPUT_REG_MASK (7 << 16)
+#define R200_TXA_OUTPUT_REG_NONE (0 << 16)
+#define R200_TXA_OUTPUT_REG_R0 (1 << 16)
+#define R200_TXA_OUTPUT_REG_R1 (2 << 16)
+#define R200_TXA_OUTPUT_REG_R2 (3 << 16)
+#define R200_TXA_OUTPUT_REG_R3 (4 << 16)
+#define R200_TXA_OUTPUT_REG_R4 (5 << 16)
+#define R200_TXA_OUTPUT_REG_R5 (6 << 16)
+#define R200_TXA_DOT_ALPHA (1 << 20)
+#define R200_TXA_REPL_NORMAL 0
+#define R200_TXA_REPL_RED 1
+#define R200_TXA_REPL_GREEN 2
+#define R200_TXA_REPL_ARG_A_SHIFT 26
+#define R200_TXA_REPL_ARG_A_MASK (3 << 26)
+#define R200_TXA_REPL_ARG_B_SHIFT 28
+#define R200_TXA_REPL_ARG_B_MASK (3 << 28)
+#define R200_TXA_REPL_ARG_C_SHIFT 30
+#define R200_TXA_REPL_ARG_C_MASK (3 << 30)
+#define R200_PP_TXCBLEND_1 0x2f10
+#define R200_PP_TXCBLEND2_1 0x2f14
+#define R200_PP_TXABLEND_1 0x2f18
+#define R200_PP_TXABLEND2_1 0x2f1c
+#define R200_PP_TXCBLEND_2 0x2f20
+#define R200_PP_TXCBLEND2_2 0x2f24
+#define R200_PP_TXABLEND_2 0x2f28
+#define R200_PP_TXABLEND2_2 0x2f2c
+#define R200_PP_TXCBLEND_3 0x2f30
+#define R200_PP_TXCBLEND2_3 0x2f34
+#define R200_PP_TXABLEND_3 0x2f38
+#define R200_PP_TXABLEND2_3 0x2f3c
+#define R200_PP_TXCBLEND_4 0x2f40
+#define R200_PP_TXCBLEND2_4 0x2f44
+#define R200_PP_TXABLEND_4 0x2f48
+#define R200_PP_TXABLEND2_4 0x2f4c
+#define R200_PP_TXCBLEND_5 0x2f50
+#define R200_PP_TXCBLEND2_5 0x2f54
+#define R200_PP_TXABLEND_5 0x2f58
+#define R200_PP_TXABLEND2_5 0x2f5c
+#define R200_PP_TXCBLEND_6 0x2f60
+#define R200_PP_TXCBLEND2_6 0x2f64
+#define R200_PP_TXABLEND_6 0x2f68
+#define R200_PP_TXABLEND2_6 0x2f6c
+#define R200_PP_TXCBLEND_7 0x2f70
+#define R200_PP_TXCBLEND2_7 0x2f74
+#define R200_PP_TXABLEND_7 0x2f78
+#define R200_PP_TXABLEND2_7 0x2f7c
+/* gap */
+#define R200_RB3D_BLENDCOLOR 0x3218 /* ARGB 8888 */
+#define R200_RB3D_ABLENDCNTL 0x321C /* see BLENDCTL */
+#define R200_RB3D_CBLENDCNTL 0x3220 /* see BLENDCTL */
+
+
+/*
+ * Offsets in TCL vector state. NOTE: Hardwiring matrix positions.
+ * Multiple contexts could collaberate to eliminate state bouncing.
+ */
+#define R200_VS_LIGHT_AMBIENT_ADDR 0x00000028
+#define R200_VS_LIGHT_DIFFUSE_ADDR 0x00000030
+#define R200_VS_LIGHT_SPECULAR_ADDR 0x00000038
+#define R200_VS_LIGHT_DIRPOS_ADDR 0x00000040
+#define R200_VS_LIGHT_HWVSPOT_ADDR 0x00000048
+#define R200_VS_LIGHT_ATTENUATION_ADDR 0x00000050
+#define R200_VS_SPOT_DUAL_CONE 0x00000058
+#define R200_VS_GLOBAL_AMBIENT_ADDR 0x0000005C
+#define R200_VS_FOG_PARAM_ADDR 0x0000005D
+#define R200_VS_EYE_VECTOR_ADDR 0x0000005E
+#define R200_VS_UCP_ADDR 0x00000060
+#define R200_VS_PNT_SPRITE_VPORT_SCALE 0x00000068
+#define R200_VS_MATRIX_0_MV 0x00000080
+#define R200_VS_MATRIX_1_INV_MV 0x00000084
+#define R200_VS_MATRIX_2_MVP 0x00000088
+#define R200_VS_MATRIX_3_TEX0 0x0000008C
+#define R200_VS_MATRIX_4_TEX1 0x00000090
+#define R200_VS_MATRIX_5_TEX2 0x00000094
+#define R200_VS_MATRIX_6_TEX3 0x00000098
+#define R200_VS_MATRIX_7_TEX4 0x0000009C
+#define R200_VS_MATRIX_8_TEX5 0x000000A0
+#define R200_VS_MAT_0_EMISS 0x000000B0
+#define R200_VS_MAT_0_AMB 0x000000B1
+#define R200_VS_MAT_0_DIF 0x000000B2
+#define R200_VS_MAT_0_SPEC 0x000000B3
+#define R200_VS_MAT_1_EMISS 0x000000B4
+#define R200_VS_MAT_1_AMB 0x000000B5
+#define R200_VS_MAT_1_DIF 0x000000B6
+#define R200_VS_MAT_1_SPEC 0x000000B7
+#define R200_VS_EYE2CLIP_MTX 0x000000B8
+#define R200_VS_PNT_SPRITE_ATT_CONST 0x000000BC
+#define R200_VS_PNT_SPRITE_EYE_IN_MODEL 0x000000BD
+#define R200_VS_PNT_SPRITE_CLAMP 0x000000BE
+#define R200_VS_MAX 0x000001C0
+
+
+/*
+ * Offsets in TCL scalar state
+ */
+#define R200_SS_LIGHT_DCD_ADDR 0x00000000
+#define R200_SS_LIGHT_DCM_ADDR 0x00000008
+#define R200_SS_LIGHT_SPOT_EXPONENT_ADDR 0x00000010
+#define R200_SS_LIGHT_SPOT_CUTOFF_ADDR 0x00000018
+#define R200_SS_LIGHT_SPECULAR_THRESH_ADDR 0x00000020
+#define R200_SS_LIGHT_RANGE_CUTOFF_SQRD 0x00000028
+#define R200_SS_LIGHT_RANGE_ATT_CONST 0x00000030
+#define R200_SS_VERT_GUARD_CLIP_ADJ_ADDR 0x00000080
+#define R200_SS_VERT_GUARD_DISCARD_ADJ_ADDR 0x00000081
+#define R200_SS_HORZ_GUARD_CLIP_ADJ_ADDR 0x00000082
+#define R200_SS_HORZ_GUARD_DISCARD_ADJ_ADDR 0x00000083
+#define R200_SS_MAT_0_SHININESS 0x00000100
+#define R200_SS_MAT_1_SHININESS 0x00000101
+
+
+/*
+ * Matrix indices
+ */
+#define R200_MTX_MV 0
+#define R200_MTX_IMV 1
+#define R200_MTX_MVP 2
+#define R200_MTX_TEX0 3
+#define R200_MTX_TEX1 4
+#define R200_MTX_TEX2 5
+#define R200_MTX_TEX3 6
+#define R200_MTX_TEX4 7
+#define R200_MTX_TEX5 8
+
+/* Color formats for 2d packets
+ */
+#define R200_CP_COLOR_FORMAT_CI8 2
+#define R200_CP_COLOR_FORMAT_ARGB1555 3
+#define R200_CP_COLOR_FORMAT_RGB565 4
+#define R200_CP_COLOR_FORMAT_ARGB8888 6
+#define R200_CP_COLOR_FORMAT_RGB332 7
+#define R200_CP_COLOR_FORMAT_RGB8 9
+#define R200_CP_COLOR_FORMAT_ARGB4444 15
+
+
+/*
+ * CP type-3 packets
+ */
+#define R200_CP_CMD_NOP 0xC0001000
+#define R200_CP_CMD_NEXT_CHAR 0xC0001900
+#define R200_CP_CMD_PLY_NEXTSCAN 0xC0001D00
+#define R200_CP_CMD_SET_SCISSORS 0xC0001E00
+#define R200_CP_CMD_LOAD_MICROCODE 0xC0002400
+#define R200_CP_CMD_WAIT_FOR_IDLE 0xC0002600
+#define R200_CP_CMD_3D_DRAW_VBUF 0xC0002800
+#define R200_CP_CMD_3D_DRAW_IMMD 0xC0002900
+#define R200_CP_CMD_3D_DRAW_INDX 0xC0002A00
+#define R200_CP_CMD_LOAD_PALETTE 0xC0002C00
+#define R200_CP_CMD_3D_LOAD_VBPNTR 0xC0002F00
+#define R200_CP_CMD_INDX_BUFFER 0xC0003300
+#define R200_CP_CMD_3D_DRAW_VBUF_2 0xC0003400
+#define R200_CP_CMD_3D_DRAW_IMMD_2 0xC0003500
+#define R200_CP_CMD_3D_DRAW_INDX_2 0xC0003600
+#define R200_CP_CMD_PAINT 0xC0009100
+#define R200_CP_CMD_BITBLT 0xC0009200
+#define R200_CP_CMD_SMALLTEXT 0xC0009300
+#define R200_CP_CMD_HOSTDATA_BLT 0xC0009400
+#define R200_CP_CMD_POLYLINE 0xC0009500
+#define R200_CP_CMD_POLYSCANLINES 0xC0009800
+#define R200_CP_CMD_PAINT_MULTI 0xC0009A00
+#define R200_CP_CMD_BITBLT_MULTI 0xC0009B00
+#define R200_CP_CMD_TRANS_BITBLT 0xC0009C00
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_sanity.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_sanity.c
new file mode 100644
index 000000000..79d0f3c55
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_sanity.c
@@ -0,0 +1,1341 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_sanity.c,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/**************************************************************************
+
+Copyright 2002 ATI Technologies Inc., Ontario, Canada, and
+ Tungsten Graphics Inc, Cedar Park, TX.
+
+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, TUNGSTEN GRAPHICS 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ *
+ */
+
+#include <errno.h>
+
+#include "glheader.h"
+#include "imports.h"
+
+#include "r200_context.h"
+#include "r200_ioctl.h"
+#include "r200_sanity.h"
+#include "radeon_reg.h"
+#include "r200_reg.h"
+
+/* Set this '1' to get more verbiage.
+ */
+#define MORE_VERBOSE 1
+
+#if MORE_VERBOSE
+#define VERBOSE (R200_DEBUG & DEBUG_VERBOSE)
+#define NORMAL (1)
+#else
+#define VERBOSE 0
+#define NORMAL (R200_DEBUG & DEBUG_VERBOSE)
+#endif
+
+
+/* New (1.3) state mechanism. 3 commands (packet, scalar, vector) in
+ * 1.3 cmdbuffers allow all previous state to be updated as well as
+ * the tcl scalar and vector areas.
+ */
+static struct {
+ int start;
+ int len;
+ const char *name;
+} packet[RADEON_MAX_STATE_PACKETS] = {
+ { RADEON_PP_MISC,7,"RADEON_PP_MISC" },
+ { RADEON_PP_CNTL,3,"RADEON_PP_CNTL" },
+ { RADEON_RB3D_COLORPITCH,1,"RADEON_RB3D_COLORPITCH" },
+ { RADEON_RE_LINE_PATTERN,2,"RADEON_RE_LINE_PATTERN" },
+ { RADEON_SE_LINE_WIDTH,1,"RADEON_SE_LINE_WIDTH" },
+ { RADEON_PP_LUM_MATRIX,1,"RADEON_PP_LUM_MATRIX" },
+ { RADEON_PP_ROT_MATRIX_0,2,"RADEON_PP_ROT_MATRIX_0" },
+ { RADEON_RB3D_STENCILREFMASK,3,"RADEON_RB3D_STENCILREFMASK" },
+ { RADEON_SE_VPORT_XSCALE,6,"RADEON_SE_VPORT_XSCALE" },
+ { RADEON_SE_CNTL,2,"RADEON_SE_CNTL" },
+ { RADEON_SE_CNTL_STATUS,1,"RADEON_SE_CNTL_STATUS" },
+ { RADEON_RE_MISC,1,"RADEON_RE_MISC" },
+ { RADEON_PP_TXFILTER_0,6,"RADEON_PP_TXFILTER_0" },
+ { RADEON_PP_BORDER_COLOR_0,1,"RADEON_PP_BORDER_COLOR_0" },
+ { RADEON_PP_TXFILTER_1,6,"RADEON_PP_TXFILTER_1" },
+ { RADEON_PP_BORDER_COLOR_1,1,"RADEON_PP_BORDER_COLOR_1" },
+ { RADEON_PP_TXFILTER_2,6,"RADEON_PP_TXFILTER_2" },
+ { RADEON_PP_BORDER_COLOR_2,1,"RADEON_PP_BORDER_COLOR_2" },
+ { RADEON_SE_ZBIAS_FACTOR,2,"RADEON_SE_ZBIAS_FACTOR" },
+ { RADEON_SE_TCL_OUTPUT_VTX_FMT,11,"RADEON_SE_TCL_OUTPUT_VTX_FMT" },
+ { RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED,17,"RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED" },
+ { R200_PP_TXCBLEND_0, 4, "R200_EMIT_PP_TXCBLEND_0" },
+ { R200_PP_TXCBLEND_1, 4, "R200_PP_TXCBLEND_1" },
+ { R200_PP_TXCBLEND_2, 4, "R200_PP_TXCBLEND_2" },
+ { R200_PP_TXCBLEND_3, 4, "R200_PP_TXCBLEND_3" },
+ { R200_PP_TXCBLEND_4, 4, "R200_PP_TXCBLEND_4" },
+ { R200_PP_TXCBLEND_5, 4, "R200_PP_TXCBLEND_5" },
+ { R200_PP_TXCBLEND_6, 4, "R200_PP_TXCBLEND_6" },
+ { R200_PP_TXCBLEND_7, 4, "R200_PP_TXCBLEND_7" },
+ { R200_SE_TCL_LIGHT_MODEL_CTL_0, 6, "R200_SE_TCL_LIGHT_MODEL_CTL_0" },
+ { R200_PP_TFACTOR_0, 6, "R200_PP_TFACTOR_0" },
+ { R200_SE_VTX_FMT_0, 4, "R200_SE_VTX_FMT_0" },
+ { R200_SE_VAP_CNTL, 1, "R200_SE_VAP_CNTL" },
+ { R200_SE_TCL_MATRIX_SEL_0, 5, "R200_SE_TCL_MATRIX_SEL_0" },
+ { R200_SE_TCL_TEX_PROC_CTL_2, 5, "R200_SE_TCL_TEX_PROC_CTL_2" },
+ { R200_SE_TCL_UCP_VERT_BLEND_CTL, 1, "R200_SE_TCL_UCP_VERT_BLEND_CTL" },
+ { R200_PP_TXFILTER_0, 6, "R200_PP_TXFILTER_0" },
+ { R200_PP_TXFILTER_1, 6, "R200_PP_TXFILTER_1" },
+ { R200_PP_TXFILTER_2, 6, "R200_PP_TXFILTER_2" },
+ { R200_PP_TXFILTER_3, 6, "R200_PP_TXFILTER_3" },
+ { R200_PP_TXFILTER_4, 6, "R200_PP_TXFILTER_4" },
+ { R200_PP_TXFILTER_5, 6, "R200_PP_TXFILTER_5" },
+ { R200_PP_TXOFFSET_0, 1, "R200_PP_TXOFFSET_0" },
+ { R200_PP_TXOFFSET_1, 1, "R200_PP_TXOFFSET_1" },
+ { R200_PP_TXOFFSET_2, 1, "R200_PP_TXOFFSET_2" },
+ { R200_PP_TXOFFSET_3, 1, "R200_PP_TXOFFSET_3" },
+ { R200_PP_TXOFFSET_4, 1, "R200_PP_TXOFFSET_4" },
+ { R200_PP_TXOFFSET_5, 1, "R200_PP_TXOFFSET_5" },
+ { R200_SE_VTE_CNTL, 1, "R200_SE_VTE_CNTL" },
+ { R200_SE_TCL_OUTPUT_VTX_COMP_SEL, 1, "R200_SE_TCL_OUTPUT_VTX_COMP_SEL" },
+ { R200_PP_TAM_DEBUG3, 1, "R200_PP_TAM_DEBUG3" },
+ { R200_PP_CNTL_X, 1, "R200_PP_CNTL_X" },
+ { R200_RB3D_DEPTHXY_OFFSET, 1, "R200_RB3D_DEPTHXY_OFFSET" },
+ { R200_RE_AUX_SCISSOR_CNTL, 1, "R200_RE_AUX_SCISSOR_CNTL" },
+ { R200_RE_SCISSOR_TL_0, 2, "R200_RE_SCISSOR_TL_0" },
+ { R200_RE_SCISSOR_TL_1, 2, "R200_RE_SCISSOR_TL_1" },
+ { R200_RE_SCISSOR_TL_2, 2, "R200_RE_SCISSOR_TL_2" },
+ { R200_SE_VAP_CNTL_STATUS, 1, "R200_SE_VAP_CNTL_STATUS" },
+ { R200_SE_VTX_STATE_CNTL, 1, "R200_SE_VTX_STATE_CNTL" },
+ { R200_RE_POINTSIZE, 1, "R200_RE_POINTSIZE" },
+ { R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0, 4, "R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0" },
+ { R200_PP_CUBIC_FACES_0, 1, "R200_PP_CUBIC_FACES_0" }, /* 61 */
+ { R200_PP_CUBIC_OFFSET_F1_0, 5, "R200_PP_CUBIC_OFFSET_F1_0" }, /* 62 */
+ { R200_PP_CUBIC_FACES_1, 1, "R200_PP_CUBIC_FACES_1" },
+ { R200_PP_CUBIC_OFFSET_F1_1, 5, "R200_PP_CUBIC_OFFSET_F1_1" },
+ { R200_PP_CUBIC_FACES_2, 1, "R200_PP_CUBIC_FACES_2" },
+ { R200_PP_CUBIC_OFFSET_F1_2, 5, "R200_PP_CUBIC_OFFSET_F1_2" },
+ { R200_PP_CUBIC_FACES_3, 1, "R200_PP_CUBIC_FACES_3" },
+ { R200_PP_CUBIC_OFFSET_F1_3, 5, "R200_PP_CUBIC_OFFSET_F1_3" },
+ { R200_PP_CUBIC_FACES_4, 1, "R200_PP_CUBIC_FACES_4" },
+ { R200_PP_CUBIC_OFFSET_F1_4, 5, "R200_PP_CUBIC_OFFSET_F1_4" },
+ { R200_PP_CUBIC_FACES_5, 1, "R200_PP_CUBIC_FACES_5" },
+ { R200_PP_CUBIC_OFFSET_F1_5, 5, "R200_PP_CUBIC_OFFSET_F1_5" },
+ { RADEON_PP_TEX_SIZE_0, 2, "RADEON_PP_TEX_SIZE_0" },
+ { RADEON_PP_TEX_SIZE_1, 2, "RADEON_PP_TEX_SIZE_1" },
+ { RADEON_PP_TEX_SIZE_2, 2, "RADEON_PP_TEX_SIZE_2" },
+ { R200_RB3D_BLENDCOLOR, 3, "R200_RB3D_BLENDCOLOR" },
+ { R200_SE_TCL_POINT_SPRITE_CNTL, 1, "R200_SE_TCL_POINT_SPRITE_CNTL" },
+ { RADEON_PP_CUBIC_FACES_0, 1, "RADEON_PP_CUBIC_FACES_0" },
+ { RADEON_PP_CUBIC_OFFSET_T0_0, 5, "RADEON_PP_CUBIC_OFFSET_T0_0" },
+ { RADEON_PP_CUBIC_FACES_1, 1, "RADEON_PP_CUBIC_FACES_1" },
+ { RADEON_PP_CUBIC_OFFSET_T1_0, 5, "RADEON_PP_CUBIC_OFFSET_T1_0" },
+ { RADEON_PP_CUBIC_FACES_2, 1, "RADEON_PP_CUBIC_FACES_2" },
+ { RADEON_PP_CUBIC_OFFSET_T2_0, 5, "RADEON_PP_CUBIC_OFFSET_T2_0" },
+ { R200_PP_TRI_PERF, 2, "R200_PP_TRI_PERF" },
+};
+
+struct reg_names {
+ int idx;
+ const char *name;
+};
+
+static struct reg_names reg_names[] = {
+ { R200_PP_MISC, "R200_PP_MISC" },
+ { R200_PP_FOG_COLOR, "R200_PP_FOG_COLOR" },
+ { R200_RE_SOLID_COLOR, "R200_RE_SOLID_COLOR" },
+ { R200_RB3D_BLENDCNTL, "R200_RB3D_BLENDCNTL" },
+ { R200_RB3D_DEPTHOFFSET, "R200_RB3D_DEPTHOFFSET" },
+ { R200_RB3D_DEPTHPITCH, "R200_RB3D_DEPTHPITCH" },
+ { R200_RB3D_ZSTENCILCNTL, "R200_RB3D_ZSTENCILCNTL" },
+ { R200_PP_CNTL, "R200_PP_CNTL" },
+ { R200_RB3D_CNTL, "R200_RB3D_CNTL" },
+ { R200_RB3D_COLOROFFSET, "R200_RB3D_COLOROFFSET" },
+ { R200_RE_WIDTH_HEIGHT, "R200_RE_WIDTH_HEIGHT" },
+ { R200_RB3D_COLORPITCH, "R200_RB3D_COLORPITCH" },
+ { R200_SE_CNTL, "R200_SE_CNTL" },
+ { R200_RE_CNTL, "R200_RE_CNTL" },
+ { R200_RE_MISC, "R200_RE_MISC" },
+ { R200_RE_STIPPLE_ADDR, "R200_RE_STIPPLE_ADDR" },
+ { R200_RE_STIPPLE_DATA, "R200_RE_STIPPLE_DATA" },
+ { R200_RE_LINE_PATTERN, "R200_RE_LINE_PATTERN" },
+ { R200_RE_LINE_STATE, "R200_RE_LINE_STATE" },
+ { R200_RE_SCISSOR_TL_0, "R200_RE_SCISSOR_TL_0" },
+ { R200_RE_SCISSOR_BR_0, "R200_RE_SCISSOR_BR_0" },
+ { R200_RE_SCISSOR_TL_1, "R200_RE_SCISSOR_TL_1" },
+ { R200_RE_SCISSOR_BR_1, "R200_RE_SCISSOR_BR_1" },
+ { R200_RE_SCISSOR_TL_2, "R200_RE_SCISSOR_TL_2" },
+ { R200_RE_SCISSOR_BR_2, "R200_RE_SCISSOR_BR_2" },
+ { R200_RB3D_DEPTHXY_OFFSET, "R200_RB3D_DEPTHXY_OFFSET" },
+ { R200_RB3D_STENCILREFMASK, "R200_RB3D_STENCILREFMASK" },
+ { R200_RB3D_ROPCNTL, "R200_RB3D_ROPCNTL" },
+ { R200_RB3D_PLANEMASK, "R200_RB3D_PLANEMASK" },
+ { R200_SE_VPORT_XSCALE, "R200_SE_VPORT_XSCALE" },
+ { R200_SE_VPORT_XOFFSET, "R200_SE_VPORT_XOFFSET" },
+ { R200_SE_VPORT_YSCALE, "R200_SE_VPORT_YSCALE" },
+ { R200_SE_VPORT_YOFFSET, "R200_SE_VPORT_YOFFSET" },
+ { R200_SE_VPORT_ZSCALE, "R200_SE_VPORT_ZSCALE" },
+ { R200_SE_VPORT_ZOFFSET, "R200_SE_VPORT_ZOFFSET" },
+ { R200_SE_ZBIAS_FACTOR, "R200_SE_ZBIAS_FACTOR" },
+ { R200_SE_ZBIAS_CONSTANT, "R200_SE_ZBIAS_CONSTANT" },
+ { R200_SE_LINE_WIDTH, "R200_SE_LINE_WIDTH" },
+ { R200_SE_VAP_CNTL, "R200_SE_VAP_CNTL" },
+ { R200_SE_VF_CNTL, "R200_SE_VF_CNTL" },
+ { R200_SE_VTX_FMT_0, "R200_SE_VTX_FMT_0" },
+ { R200_SE_VTX_FMT_1, "R200_SE_VTX_FMT_1" },
+ { R200_SE_TCL_OUTPUT_VTX_FMT_0, "R200_SE_TCL_OUTPUT_VTX_FMT_0" },
+ { R200_SE_TCL_OUTPUT_VTX_FMT_1, "R200_SE_TCL_OUTPUT_VTX_FMT_1" },
+ { R200_SE_VTE_CNTL, "R200_SE_VTE_CNTL" },
+ { R200_SE_VTX_NUM_ARRAYS, "R200_SE_VTX_NUM_ARRAYS" },
+ { R200_SE_VTX_AOS_ATTR01, "R200_SE_VTX_AOS_ATTR01" },
+ { R200_SE_VTX_AOS_ADDR0, "R200_SE_VTX_AOS_ADDR0" },
+ { R200_SE_VTX_AOS_ADDR1, "R200_SE_VTX_AOS_ADDR1" },
+ { R200_SE_VTX_AOS_ATTR23, "R200_SE_VTX_AOS_ATTR23" },
+ { R200_SE_VTX_AOS_ADDR2, "R200_SE_VTX_AOS_ADDR2" },
+ { R200_SE_VTX_AOS_ADDR3, "R200_SE_VTX_AOS_ADDR3" },
+ { R200_SE_VTX_AOS_ATTR45, "R200_SE_VTX_AOS_ATTR45" },
+ { R200_SE_VTX_AOS_ADDR4, "R200_SE_VTX_AOS_ADDR4" },
+ { R200_SE_VTX_AOS_ADDR5, "R200_SE_VTX_AOS_ADDR5" },
+ { R200_SE_VTX_AOS_ATTR67, "R200_SE_VTX_AOS_ATTR67" },
+ { R200_SE_VTX_AOS_ADDR6, "R200_SE_VTX_AOS_ADDR6" },
+ { R200_SE_VTX_AOS_ADDR7, "R200_SE_VTX_AOS_ADDR7" },
+ { R200_SE_VTX_AOS_ATTR89, "R200_SE_VTX_AOS_ATTR89" },
+ { R200_SE_VTX_AOS_ADDR8, "R200_SE_VTX_AOS_ADDR8" },
+ { R200_SE_VTX_AOS_ADDR9, "R200_SE_VTX_AOS_ADDR9" },
+ { R200_SE_VTX_AOS_ATTR1011, "R200_SE_VTX_AOS_ATTR1011" },
+ { R200_SE_VTX_AOS_ADDR10, "R200_SE_VTX_AOS_ADDR10" },
+ { R200_SE_VTX_AOS_ADDR11, "R200_SE_VTX_AOS_ADDR11" },
+ { R200_SE_VF_MAX_VTX_INDX, "R200_SE_VF_MAX_VTX_INDX" },
+ { R200_SE_VF_MIN_VTX_INDX, "R200_SE_VF_MIN_VTX_INDX" },
+ { R200_SE_VTX_STATE_CNTL, "R200_SE_VTX_STATE_CNTL" },
+ { R200_SE_TCL_VECTOR_INDX_REG, "R200_SE_TCL_VECTOR_INDX_REG" },
+ { R200_SE_TCL_VECTOR_DATA_REG, "R200_SE_TCL_VECTOR_DATA_REG" },
+ { R200_SE_TCL_SCALAR_INDX_REG, "R200_SE_TCL_SCALAR_INDX_REG" },
+ { R200_SE_TCL_SCALAR_DATA_REG, "R200_SE_TCL_SCALAR_DATA_REG" },
+ { R200_SE_TCL_MATRIX_SEL_0, "R200_SE_TCL_MATRIX_SEL_0" },
+ { R200_SE_TCL_MATRIX_SEL_1, "R200_SE_TCL_MATRIX_SEL_1" },
+ { R200_SE_TCL_MATRIX_SEL_2, "R200_SE_TCL_MATRIX_SEL_2" },
+ { R200_SE_TCL_MATRIX_SEL_3, "R200_SE_TCL_MATRIX_SEL_3" },
+ { R200_SE_TCL_MATRIX_SEL_4, "R200_SE_TCL_MATRIX_SEL_4" },
+ { R200_SE_TCL_LIGHT_MODEL_CTL_0, "R200_SE_TCL_LIGHT_MODEL_CTL_0" },
+ { R200_SE_TCL_LIGHT_MODEL_CTL_1, "R200_SE_TCL_LIGHT_MODEL_CTL_1" },
+ { R200_SE_TCL_PER_LIGHT_CTL_0, "R200_SE_TCL_PER_LIGHT_CTL_0" },
+ { R200_SE_TCL_PER_LIGHT_CTL_1, "R200_SE_TCL_PER_LIGHT_CTL_1" },
+ { R200_SE_TCL_PER_LIGHT_CTL_2, "R200_SE_TCL_PER_LIGHT_CTL_2" },
+ { R200_SE_TCL_PER_LIGHT_CTL_3, "R200_SE_TCL_PER_LIGHT_CTL_3" },
+ { R200_SE_TCL_TEX_PROC_CTL_2, "R200_SE_TCL_TEX_PROC_CTL_2" },
+ { R200_SE_TCL_TEX_PROC_CTL_3, "R200_SE_TCL_TEX_PROC_CTL_3" },
+ { R200_SE_TCL_TEX_PROC_CTL_0, "R200_SE_TCL_TEX_PROC_CTL_0" },
+ { R200_SE_TCL_TEX_PROC_CTL_1, "R200_SE_TCL_TEX_PROC_CTL_1" },
+ { R200_SE_TC_TEX_CYL_WRAP_CTL, "R200_SE_TC_TEX_CYL_WRAP_CTL" },
+ { R200_SE_TCL_UCP_VERT_BLEND_CTL, "R200_SE_TCL_UCP_VERT_BLEND_CTL" },
+ { R200_SE_TCL_POINT_SPRITE_CNTL, "R200_SE_TCL_POINT_SPRITE_CNTL" },
+ { R200_SE_VTX_ST_POS_0_X_4, "R200_SE_VTX_ST_POS_0_X_4" },
+ { R200_SE_VTX_ST_POS_0_Y_4, "R200_SE_VTX_ST_POS_0_Y_4" },
+ { R200_SE_VTX_ST_POS_0_Z_4, "R200_SE_VTX_ST_POS_0_Z_4" },
+ { R200_SE_VTX_ST_POS_0_W_4, "R200_SE_VTX_ST_POS_0_W_4" },
+ { R200_SE_VTX_ST_NORM_0_X, "R200_SE_VTX_ST_NORM_0_X" },
+ { R200_SE_VTX_ST_NORM_0_Y, "R200_SE_VTX_ST_NORM_0_Y" },
+ { R200_SE_VTX_ST_NORM_0_Z, "R200_SE_VTX_ST_NORM_0_Z" },
+ { R200_SE_VTX_ST_PVMS, "R200_SE_VTX_ST_PVMS" },
+ { R200_SE_VTX_ST_CLR_0_R, "R200_SE_VTX_ST_CLR_0_R" },
+ { R200_SE_VTX_ST_CLR_0_G, "R200_SE_VTX_ST_CLR_0_G" },
+ { R200_SE_VTX_ST_CLR_0_B, "R200_SE_VTX_ST_CLR_0_B" },
+ { R200_SE_VTX_ST_CLR_0_A, "R200_SE_VTX_ST_CLR_0_A" },
+ { R200_SE_VTX_ST_CLR_1_R, "R200_SE_VTX_ST_CLR_1_R" },
+ { R200_SE_VTX_ST_CLR_1_G, "R200_SE_VTX_ST_CLR_1_G" },
+ { R200_SE_VTX_ST_CLR_1_B, "R200_SE_VTX_ST_CLR_1_B" },
+ { R200_SE_VTX_ST_CLR_1_A, "R200_SE_VTX_ST_CLR_1_A" },
+ { R200_SE_VTX_ST_CLR_2_R, "R200_SE_VTX_ST_CLR_2_R" },
+ { R200_SE_VTX_ST_CLR_2_G, "R200_SE_VTX_ST_CLR_2_G" },
+ { R200_SE_VTX_ST_CLR_2_B, "R200_SE_VTX_ST_CLR_2_B" },
+ { R200_SE_VTX_ST_CLR_2_A, "R200_SE_VTX_ST_CLR_2_A" },
+ { R200_SE_VTX_ST_CLR_3_R, "R200_SE_VTX_ST_CLR_3_R" },
+ { R200_SE_VTX_ST_CLR_3_G, "R200_SE_VTX_ST_CLR_3_G" },
+ { R200_SE_VTX_ST_CLR_3_B, "R200_SE_VTX_ST_CLR_3_B" },
+ { R200_SE_VTX_ST_CLR_3_A, "R200_SE_VTX_ST_CLR_3_A" },
+ { R200_SE_VTX_ST_CLR_4_R, "R200_SE_VTX_ST_CLR_4_R" },
+ { R200_SE_VTX_ST_CLR_4_G, "R200_SE_VTX_ST_CLR_4_G" },
+ { R200_SE_VTX_ST_CLR_4_B, "R200_SE_VTX_ST_CLR_4_B" },
+ { R200_SE_VTX_ST_CLR_4_A, "R200_SE_VTX_ST_CLR_4_A" },
+ { R200_SE_VTX_ST_CLR_5_R, "R200_SE_VTX_ST_CLR_5_R" },
+ { R200_SE_VTX_ST_CLR_5_G, "R200_SE_VTX_ST_CLR_5_G" },
+ { R200_SE_VTX_ST_CLR_5_B, "R200_SE_VTX_ST_CLR_5_B" },
+ { R200_SE_VTX_ST_CLR_5_A, "R200_SE_VTX_ST_CLR_5_A" },
+ { R200_SE_VTX_ST_CLR_6_R, "R200_SE_VTX_ST_CLR_6_R" },
+ { R200_SE_VTX_ST_CLR_6_G, "R200_SE_VTX_ST_CLR_6_G" },
+ { R200_SE_VTX_ST_CLR_6_B, "R200_SE_VTX_ST_CLR_6_B" },
+ { R200_SE_VTX_ST_CLR_6_A, "R200_SE_VTX_ST_CLR_6_A" },
+ { R200_SE_VTX_ST_CLR_7_R, "R200_SE_VTX_ST_CLR_7_R" },
+ { R200_SE_VTX_ST_CLR_7_G, "R200_SE_VTX_ST_CLR_7_G" },
+ { R200_SE_VTX_ST_CLR_7_B, "R200_SE_VTX_ST_CLR_7_B" },
+ { R200_SE_VTX_ST_CLR_7_A, "R200_SE_VTX_ST_CLR_7_A" },
+ { R200_SE_VTX_ST_TEX_0_S, "R200_SE_VTX_ST_TEX_0_S" },
+ { R200_SE_VTX_ST_TEX_0_T, "R200_SE_VTX_ST_TEX_0_T" },
+ { R200_SE_VTX_ST_TEX_0_R, "R200_SE_VTX_ST_TEX_0_R" },
+ { R200_SE_VTX_ST_TEX_0_Q, "R200_SE_VTX_ST_TEX_0_Q" },
+ { R200_SE_VTX_ST_TEX_1_S, "R200_SE_VTX_ST_TEX_1_S" },
+ { R200_SE_VTX_ST_TEX_1_T, "R200_SE_VTX_ST_TEX_1_T" },
+ { R200_SE_VTX_ST_TEX_1_R, "R200_SE_VTX_ST_TEX_1_R" },
+ { R200_SE_VTX_ST_TEX_1_Q, "R200_SE_VTX_ST_TEX_1_Q" },
+ { R200_SE_VTX_ST_TEX_2_S, "R200_SE_VTX_ST_TEX_2_S" },
+ { R200_SE_VTX_ST_TEX_2_T, "R200_SE_VTX_ST_TEX_2_T" },
+ { R200_SE_VTX_ST_TEX_2_R, "R200_SE_VTX_ST_TEX_2_R" },
+ { R200_SE_VTX_ST_TEX_2_Q, "R200_SE_VTX_ST_TEX_2_Q" },
+ { R200_SE_VTX_ST_TEX_3_S, "R200_SE_VTX_ST_TEX_3_S" },
+ { R200_SE_VTX_ST_TEX_3_T, "R200_SE_VTX_ST_TEX_3_T" },
+ { R200_SE_VTX_ST_TEX_3_R, "R200_SE_VTX_ST_TEX_3_R" },
+ { R200_SE_VTX_ST_TEX_3_Q, "R200_SE_VTX_ST_TEX_3_Q" },
+ { R200_SE_VTX_ST_TEX_4_S, "R200_SE_VTX_ST_TEX_4_S" },
+ { R200_SE_VTX_ST_TEX_4_T, "R200_SE_VTX_ST_TEX_4_T" },
+ { R200_SE_VTX_ST_TEX_4_R, "R200_SE_VTX_ST_TEX_4_R" },
+ { R200_SE_VTX_ST_TEX_4_Q, "R200_SE_VTX_ST_TEX_4_Q" },
+ { R200_SE_VTX_ST_TEX_5_S, "R200_SE_VTX_ST_TEX_5_S" },
+ { R200_SE_VTX_ST_TEX_5_T, "R200_SE_VTX_ST_TEX_5_T" },
+ { R200_SE_VTX_ST_TEX_5_R, "R200_SE_VTX_ST_TEX_5_R" },
+ { R200_SE_VTX_ST_TEX_5_Q, "R200_SE_VTX_ST_TEX_5_Q" },
+ { R200_SE_VTX_ST_PNT_SPRT_SZ, "R200_SE_VTX_ST_PNT_SPRT_SZ" },
+ { R200_SE_VTX_ST_DISC_FOG, "R200_SE_VTX_ST_DISC_FOG" },
+ { R200_SE_VTX_ST_SHININESS_0, "R200_SE_VTX_ST_SHININESS_0" },
+ { R200_SE_VTX_ST_SHININESS_1, "R200_SE_VTX_ST_SHININESS_1" },
+ { R200_SE_VTX_ST_BLND_WT_0, "R200_SE_VTX_ST_BLND_WT_0" },
+ { R200_SE_VTX_ST_BLND_WT_1, "R200_SE_VTX_ST_BLND_WT_1" },
+ { R200_SE_VTX_ST_BLND_WT_2, "R200_SE_VTX_ST_BLND_WT_2" },
+ { R200_SE_VTX_ST_BLND_WT_3, "R200_SE_VTX_ST_BLND_WT_3" },
+ { R200_SE_VTX_ST_POS_1_X, "R200_SE_VTX_ST_POS_1_X" },
+ { R200_SE_VTX_ST_POS_1_Y, "R200_SE_VTX_ST_POS_1_Y" },
+ { R200_SE_VTX_ST_POS_1_Z, "R200_SE_VTX_ST_POS_1_Z" },
+ { R200_SE_VTX_ST_POS_1_W, "R200_SE_VTX_ST_POS_1_W" },
+ { R200_SE_VTX_ST_NORM_1_X, "R200_SE_VTX_ST_NORM_1_X" },
+ { R200_SE_VTX_ST_NORM_1_Y, "R200_SE_VTX_ST_NORM_1_Y" },
+ { R200_SE_VTX_ST_NORM_1_Z, "R200_SE_VTX_ST_NORM_1_Z" },
+ { R200_SE_VTX_ST_USR_CLR_0_R, "R200_SE_VTX_ST_USR_CLR_0_R" },
+ { R200_SE_VTX_ST_USR_CLR_0_G, "R200_SE_VTX_ST_USR_CLR_0_G" },
+ { R200_SE_VTX_ST_USR_CLR_0_B, "R200_SE_VTX_ST_USR_CLR_0_B" },
+ { R200_SE_VTX_ST_USR_CLR_0_A, "R200_SE_VTX_ST_USR_CLR_0_A" },
+ { R200_SE_VTX_ST_USR_CLR_1_R, "R200_SE_VTX_ST_USR_CLR_1_R" },
+ { R200_SE_VTX_ST_USR_CLR_1_G, "R200_SE_VTX_ST_USR_CLR_1_G" },
+ { R200_SE_VTX_ST_USR_CLR_1_B, "R200_SE_VTX_ST_USR_CLR_1_B" },
+ { R200_SE_VTX_ST_USR_CLR_1_A, "R200_SE_VTX_ST_USR_CLR_1_A" },
+ { R200_SE_VTX_ST_CLR_0_PKD, "R200_SE_VTX_ST_CLR_0_PKD" },
+ { R200_SE_VTX_ST_CLR_1_PKD, "R200_SE_VTX_ST_CLR_1_PKD" },
+ { R200_SE_VTX_ST_CLR_2_PKD, "R200_SE_VTX_ST_CLR_2_PKD" },
+ { R200_SE_VTX_ST_CLR_3_PKD, "R200_SE_VTX_ST_CLR_3_PKD" },
+ { R200_SE_VTX_ST_CLR_4_PKD, "R200_SE_VTX_ST_CLR_4_PKD" },
+ { R200_SE_VTX_ST_CLR_5_PKD, "R200_SE_VTX_ST_CLR_5_PKD" },
+ { R200_SE_VTX_ST_CLR_6_PKD, "R200_SE_VTX_ST_CLR_6_PKD" },
+ { R200_SE_VTX_ST_CLR_7_PKD, "R200_SE_VTX_ST_CLR_7_PKD" },
+ { R200_SE_VTX_ST_POS_0_X_2, "R200_SE_VTX_ST_POS_0_X_2" },
+ { R200_SE_VTX_ST_POS_0_Y_2, "R200_SE_VTX_ST_POS_0_Y_2" },
+ { R200_SE_VTX_ST_PAR_CLR_LD, "R200_SE_VTX_ST_PAR_CLR_LD" },
+ { R200_SE_VTX_ST_USR_CLR_PKD, "R200_SE_VTX_ST_USR_CLR_PKD" },
+ { R200_SE_VTX_ST_POS_0_X_3, "R200_SE_VTX_ST_POS_0_X_3" },
+ { R200_SE_VTX_ST_POS_0_Y_3, "R200_SE_VTX_ST_POS_0_Y_3" },
+ { R200_SE_VTX_ST_POS_0_Z_3, "R200_SE_VTX_ST_POS_0_Z_3" },
+ { R200_SE_VTX_ST_END_OF_PKT, "R200_SE_VTX_ST_END_OF_PKT" },
+ { R200_RE_POINTSIZE, "R200_RE_POINTSIZE" },
+ { R200_RE_TOP_LEFT, "R200_RE_TOP_LEFT" },
+ { R200_RE_AUX_SCISSOR_CNTL, "R200_RE_AUX_SCISSOR_CNTL" },
+ { R200_PP_TXFILTER_0, "R200_PP_TXFILTER_0" },
+ { R200_PP_TXFORMAT_0, "R200_PP_TXFORMAT_0" },
+ { R200_PP_TXSIZE_0, "R200_PP_TXSIZE_0" },
+ { R200_PP_TXFORMAT_X_0, "R200_PP_TXFORMAT_X_0" },
+ { R200_PP_TXPITCH_0, "R200_PP_TXPITCH_0" },
+ { R200_PP_BORDER_COLOR_0, "R200_PP_BORDER_COLOR_0" },
+ { R200_PP_CUBIC_FACES_0, "R200_PP_CUBIC_FACES_0" },
+ { R200_PP_TXFILTER_1, "R200_PP_TXFILTER_1" },
+ { R200_PP_TXFORMAT_1, "R200_PP_TXFORMAT_1" },
+ { R200_PP_TXSIZE_1, "R200_PP_TXSIZE_1" },
+ { R200_PP_TXFORMAT_X_1, "R200_PP_TXFORMAT_X_1" },
+ { R200_PP_TXPITCH_1, "R200_PP_TXPITCH_1" },
+ { R200_PP_BORDER_COLOR_1, "R200_PP_BORDER_COLOR_1" },
+ { R200_PP_CUBIC_FACES_1, "R200_PP_CUBIC_FACES_1" },
+ { R200_PP_TXFILTER_2, "R200_PP_TXFILTER_2" },
+ { R200_PP_TXFORMAT_2, "R200_PP_TXFORMAT_2" },
+ { R200_PP_TXSIZE_2, "R200_PP_TXSIZE_2" },
+ { R200_PP_TXFORMAT_X_2, "R200_PP_TXFORMAT_X_2" },
+ { R200_PP_TXPITCH_2, "R200_PP_TXPITCH_2" },
+ { R200_PP_BORDER_COLOR_2, "R200_PP_BORDER_COLOR_2" },
+ { R200_PP_CUBIC_FACES_2, "R200_PP_CUBIC_FACES_2" },
+ { R200_PP_TXFILTER_3, "R200_PP_TXFILTER_3" },
+ { R200_PP_TXFORMAT_3, "R200_PP_TXFORMAT_3" },
+ { R200_PP_TXSIZE_3, "R200_PP_TXSIZE_3" },
+ { R200_PP_TXFORMAT_X_3, "R200_PP_TXFORMAT_X_3" },
+ { R200_PP_TXPITCH_3, "R200_PP_TXPITCH_3" },
+ { R200_PP_BORDER_COLOR_3, "R200_PP_BORDER_COLOR_3" },
+ { R200_PP_CUBIC_FACES_3, "R200_PP_CUBIC_FACES_3" },
+ { R200_PP_TXFILTER_4, "R200_PP_TXFILTER_4" },
+ { R200_PP_TXFORMAT_4, "R200_PP_TXFORMAT_4" },
+ { R200_PP_TXSIZE_4, "R200_PP_TXSIZE_4" },
+ { R200_PP_TXFORMAT_X_4, "R200_PP_TXFORMAT_X_4" },
+ { R200_PP_TXPITCH_4, "R200_PP_TXPITCH_4" },
+ { R200_PP_BORDER_COLOR_4, "R200_PP_BORDER_COLOR_4" },
+ { R200_PP_CUBIC_FACES_4, "R200_PP_CUBIC_FACES_4" },
+ { R200_PP_TXFILTER_5, "R200_PP_TXFILTER_5" },
+ { R200_PP_TXFORMAT_5, "R200_PP_TXFORMAT_5" },
+ { R200_PP_TXSIZE_5, "R200_PP_TXSIZE_5" },
+ { R200_PP_TXFORMAT_X_5, "R200_PP_TXFORMAT_X_5" },
+ { R200_PP_TXPITCH_5, "R200_PP_TXPITCH_5" },
+ { R200_PP_BORDER_COLOR_5, "R200_PP_BORDER_COLOR_5" },
+ { R200_PP_CUBIC_FACES_5, "R200_PP_CUBIC_FACES_5" },
+ { R200_PP_TXOFFSET_0, "R200_PP_TXOFFSET_0" },
+ { R200_PP_CUBIC_OFFSET_F1_0, "R200_PP_CUBIC_OFFSET_F1_0" },
+ { R200_PP_CUBIC_OFFSET_F2_0, "R200_PP_CUBIC_OFFSET_F2_0" },
+ { R200_PP_CUBIC_OFFSET_F3_0, "R200_PP_CUBIC_OFFSET_F3_0" },
+ { R200_PP_CUBIC_OFFSET_F4_0, "R200_PP_CUBIC_OFFSET_F4_0" },
+ { R200_PP_CUBIC_OFFSET_F5_0, "R200_PP_CUBIC_OFFSET_F5_0" },
+ { R200_PP_TXOFFSET_1, "R200_PP_TXOFFSET_1" },
+ { R200_PP_CUBIC_OFFSET_F1_1, "R200_PP_CUBIC_OFFSET_F1_1" },
+ { R200_PP_CUBIC_OFFSET_F2_1, "R200_PP_CUBIC_OFFSET_F2_1" },
+ { R200_PP_CUBIC_OFFSET_F3_1, "R200_PP_CUBIC_OFFSET_F3_1" },
+ { R200_PP_CUBIC_OFFSET_F4_1, "R200_PP_CUBIC_OFFSET_F4_1" },
+ { R200_PP_CUBIC_OFFSET_F5_1, "R200_PP_CUBIC_OFFSET_F5_1" },
+ { R200_PP_TXOFFSET_2, "R200_PP_TXOFFSET_2" },
+ { R200_PP_CUBIC_OFFSET_F1_2, "R200_PP_CUBIC_OFFSET_F1_2" },
+ { R200_PP_CUBIC_OFFSET_F2_2, "R200_PP_CUBIC_OFFSET_F2_2" },
+ { R200_PP_CUBIC_OFFSET_F3_2, "R200_PP_CUBIC_OFFSET_F3_2" },
+ { R200_PP_CUBIC_OFFSET_F4_2, "R200_PP_CUBIC_OFFSET_F4_2" },
+ { R200_PP_CUBIC_OFFSET_F5_2, "R200_PP_CUBIC_OFFSET_F5_2" },
+ { R200_PP_TXOFFSET_3, "R200_PP_TXOFFSET_3" },
+ { R200_PP_CUBIC_OFFSET_F1_3, "R200_PP_CUBIC_OFFSET_F1_3" },
+ { R200_PP_CUBIC_OFFSET_F2_3, "R200_PP_CUBIC_OFFSET_F2_3" },
+ { R200_PP_CUBIC_OFFSET_F3_3, "R200_PP_CUBIC_OFFSET_F3_3" },
+ { R200_PP_CUBIC_OFFSET_F4_3, "R200_PP_CUBIC_OFFSET_F4_3" },
+ { R200_PP_CUBIC_OFFSET_F5_3, "R200_PP_CUBIC_OFFSET_F5_3" },
+ { R200_PP_TXOFFSET_4, "R200_PP_TXOFFSET_4" },
+ { R200_PP_CUBIC_OFFSET_F1_4, "R200_PP_CUBIC_OFFSET_F1_4" },
+ { R200_PP_CUBIC_OFFSET_F2_4, "R200_PP_CUBIC_OFFSET_F2_4" },
+ { R200_PP_CUBIC_OFFSET_F3_4, "R200_PP_CUBIC_OFFSET_F3_4" },
+ { R200_PP_CUBIC_OFFSET_F4_4, "R200_PP_CUBIC_OFFSET_F4_4" },
+ { R200_PP_CUBIC_OFFSET_F5_4, "R200_PP_CUBIC_OFFSET_F5_4" },
+ { R200_PP_TXOFFSET_5, "R200_PP_TXOFFSET_5" },
+ { R200_PP_CUBIC_OFFSET_F1_5, "R200_PP_CUBIC_OFFSET_F1_5" },
+ { R200_PP_CUBIC_OFFSET_F2_5, "R200_PP_CUBIC_OFFSET_F2_5" },
+ { R200_PP_CUBIC_OFFSET_F3_5, "R200_PP_CUBIC_OFFSET_F3_5" },
+ { R200_PP_CUBIC_OFFSET_F4_5, "R200_PP_CUBIC_OFFSET_F4_5" },
+ { R200_PP_CUBIC_OFFSET_F5_5, "R200_PP_CUBIC_OFFSET_F5_5" },
+ { R200_PP_TAM_DEBUG3, "R200_PP_TAM_DEBUG3" },
+ { R200_PP_TFACTOR_0, "R200_PP_TFACTOR_0" },
+ { R200_PP_TFACTOR_1, "R200_PP_TFACTOR_1" },
+ { R200_PP_TFACTOR_2, "R200_PP_TFACTOR_2" },
+ { R200_PP_TFACTOR_3, "R200_PP_TFACTOR_3" },
+ { R200_PP_TFACTOR_4, "R200_PP_TFACTOR_4" },
+ { R200_PP_TFACTOR_5, "R200_PP_TFACTOR_5" },
+ { R200_PP_TXCBLEND_0, "R200_PP_TXCBLEND_0" },
+ { R200_PP_TXCBLEND2_0, "R200_PP_TXCBLEND2_0" },
+ { R200_PP_TXABLEND_0, "R200_PP_TXABLEND_0" },
+ { R200_PP_TXABLEND2_0, "R200_PP_TXABLEND2_0" },
+ { R200_PP_TXCBLEND_1, "R200_PP_TXCBLEND_1" },
+ { R200_PP_TXCBLEND2_1, "R200_PP_TXCBLEND2_1" },
+ { R200_PP_TXABLEND_1, "R200_PP_TXABLEND_1" },
+ { R200_PP_TXABLEND2_1, "R200_PP_TXABLEND2_1" },
+ { R200_PP_TXCBLEND_2, "R200_PP_TXCBLEND_2" },
+ { R200_PP_TXCBLEND2_2, "R200_PP_TXCBLEND2_2" },
+ { R200_PP_TXABLEND_2, "R200_PP_TXABLEND_2" },
+ { R200_PP_TXABLEND2_2, "R200_PP_TXABLEND2_2" },
+ { R200_PP_TXCBLEND_3, "R200_PP_TXCBLEND_3" },
+ { R200_PP_TXCBLEND2_3, "R200_PP_TXCBLEND2_3" },
+ { R200_PP_TXABLEND_3, "R200_PP_TXABLEND_3" },
+ { R200_PP_TXABLEND2_3, "R200_PP_TXABLEND2_3" },
+ { R200_PP_TXCBLEND_4, "R200_PP_TXCBLEND_4" },
+ { R200_PP_TXCBLEND2_4, "R200_PP_TXCBLEND2_4" },
+ { R200_PP_TXABLEND_4, "R200_PP_TXABLEND_4" },
+ { R200_PP_TXABLEND2_4, "R200_PP_TXABLEND2_4" },
+ { R200_PP_TXCBLEND_5, "R200_PP_TXCBLEND_5" },
+ { R200_PP_TXCBLEND2_5, "R200_PP_TXCBLEND2_5" },
+ { R200_PP_TXABLEND_5, "R200_PP_TXABLEND_5" },
+ { R200_PP_TXABLEND2_5, "R200_PP_TXABLEND2_5" },
+ { R200_PP_TXCBLEND_6, "R200_PP_TXCBLEND_6" },
+ { R200_PP_TXCBLEND2_6, "R200_PP_TXCBLEND2_6" },
+ { R200_PP_TXABLEND_6, "R200_PP_TXABLEND_6" },
+ { R200_PP_TXABLEND2_6, "R200_PP_TXABLEND2_6" },
+ { R200_PP_TXCBLEND_7, "R200_PP_TXCBLEND_7" },
+ { R200_PP_TXCBLEND2_7, "R200_PP_TXCBLEND2_7" },
+ { R200_PP_TXABLEND_7, "R200_PP_TXABLEND_7" },
+ { R200_PP_TXABLEND2_7, "R200_PP_TXABLEND2_7" },
+ { R200_RB3D_BLENDCOLOR, "R200_RB3D_BLENDCOLOR" },
+ { R200_RB3D_ABLENDCNTL, "R200_RB3D_ABLENDCNTL" },
+ { R200_RB3D_CBLENDCNTL, "R200_RB3D_CBLENDCNTL" },
+ { R200_SE_TCL_OUTPUT_VTX_COMP_SEL, "R200_SE_TCL_OUTPUT_VTX_COMP_SEL" },
+ { R200_PP_CNTL_X, "R200_PP_CNTL_X" },
+ { R200_SE_VAP_CNTL_STATUS, "R200_SE_VAP_CNTL_STATUS" },
+ { R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0, "R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0" },
+ { R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_1, "R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_1" },
+ { R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_2, "R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_2" },
+ { R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_3, "R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_3" },
+ { R200_PP_TRI_PERF, "R200_PP_TRI_PERF" },
+ { R200_PP_PERF_CNTL, "R200_PP_PERF_CNTL" },
+};
+
+static struct reg_names scalar_names[] = {
+ { R200_SS_LIGHT_DCD_ADDR, "R200_SS_LIGHT_DCD_ADDR" },
+ { R200_SS_LIGHT_DCM_ADDR, "R200_SS_LIGHT_DCM_ADDR" },
+ { R200_SS_LIGHT_SPOT_EXPONENT_ADDR, "R200_SS_LIGHT_SPOT_EXPONENT_ADDR" },
+ { R200_SS_LIGHT_SPOT_CUTOFF_ADDR, "R200_SS_LIGHT_SPOT_CUTOFF_ADDR" },
+ { R200_SS_LIGHT_SPECULAR_THRESH_ADDR, "R200_SS_LIGHT_SPECULAR_THRESH_ADDR" },
+ { R200_SS_LIGHT_RANGE_CUTOFF_SQRD, "R200_SS_LIGHT_RANGE_CUTOFF_SQRD" },
+ { R200_SS_LIGHT_RANGE_ATT_CONST, "R200_SS_LIGHT_RANGE_ATT_CONST" },
+ { R200_SS_VERT_GUARD_CLIP_ADJ_ADDR, "R200_SS_VERT_GUARD_CLIP_ADJ_ADDR" },
+ { R200_SS_VERT_GUARD_DISCARD_ADJ_ADDR, "R200_SS_VERT_GUARD_DISCARD_ADJ_ADDR" },
+ { R200_SS_HORZ_GUARD_CLIP_ADJ_ADDR, "R200_SS_HORZ_GUARD_CLIP_ADJ_ADDR" },
+ { R200_SS_HORZ_GUARD_DISCARD_ADJ_ADDR, "R200_SS_HORZ_GUARD_DISCARD_ADJ_ADDR" },
+ { R200_SS_MAT_0_SHININESS, "R200_SS_MAT_0_SHININESS" },
+ { R200_SS_MAT_1_SHININESS, "R200_SS_MAT_1_SHININESS" },
+ { 1000, "" },
+};
+
+/* Puff these out to make them look like normal (dword) registers.
+ */
+static struct reg_names vector_names[] = {
+ { 0, "start" },
+ { R200_VS_LIGHT_AMBIENT_ADDR, "R200_VS_LIGHT_AMBIENT_ADDR" },
+ { R200_VS_LIGHT_DIFFUSE_ADDR, "R200_VS_LIGHT_DIFFUSE_ADDR" },
+ { R200_VS_LIGHT_SPECULAR_ADDR, "R200_VS_LIGHT_SPECULAR_ADDR" },
+ { R200_VS_LIGHT_DIRPOS_ADDR, "R200_VS_LIGHT_DIRPOS_ADDR" },
+ { R200_VS_LIGHT_HWVSPOT_ADDR, "R200_VS_LIGHT_HWVSPOT_ADDR" },
+ { R200_VS_LIGHT_ATTENUATION_ADDR, "R200_VS_LIGHT_ATTENUATION_ADDR" },
+ { R200_VS_SPOT_DUAL_CONE, "R200_VS_SPOT_DUAL_CONE" },
+ { R200_VS_GLOBAL_AMBIENT_ADDR, "R200_VS_GLOBAL_AMBIENT_ADDR" },
+ { R200_VS_FOG_PARAM_ADDR, "R200_VS_FOG_PARAM_ADDR" },
+ { R200_VS_EYE_VECTOR_ADDR, "R200_VS_EYE_VECTOR_ADDR" },
+ { R200_VS_UCP_ADDR, "R200_VS_UCP_ADDR" },
+ { R200_VS_PNT_SPRITE_VPORT_SCALE, "R200_VS_PNT_SPRITE_VPORT_SCALE" },
+ { R200_VS_MATRIX_0_MV, "R200_VS_MATRIX_0_MV" },
+ { R200_VS_MATRIX_1_INV_MV, "R200_VS_MATRIX_1_INV_MV" },
+ { R200_VS_MATRIX_2_MVP, "R200_VS_MATRIX_2_MVP" },
+ { R200_VS_MATRIX_3_TEX0, "R200_VS_MATRIX_3_TEX0" },
+ { R200_VS_MATRIX_4_TEX1, "R200_VS_MATRIX_4_TEX1" },
+ { R200_VS_MATRIX_5_TEX2, "R200_VS_MATRIX_5_TEX2" },
+ { R200_VS_MATRIX_6_TEX3, "R200_VS_MATRIX_6_TEX3" },
+ { R200_VS_MATRIX_7_TEX4, "R200_VS_MATRIX_7_TEX4" },
+ { R200_VS_MATRIX_8_TEX5, "R200_VS_MATRIX_8_TEX5" },
+ { R200_VS_MAT_0_EMISS, "R200_VS_MAT_0_EMISS" },
+ { R200_VS_MAT_0_AMB, "R200_VS_MAT_0_AMB" },
+ { R200_VS_MAT_0_DIF, "R200_VS_MAT_0_DIF" },
+ { R200_VS_MAT_0_SPEC, "R200_VS_MAT_0_SPEC" },
+ { R200_VS_MAT_1_EMISS, "R200_VS_MAT_1_EMISS" },
+ { R200_VS_MAT_1_AMB, "R200_VS_MAT_1_AMB" },
+ { R200_VS_MAT_1_DIF, "R200_VS_MAT_1_DIF" },
+ { R200_VS_MAT_1_SPEC, "R200_VS_MAT_1_SPEC" },
+ { R200_VS_EYE2CLIP_MTX, "R200_VS_EYE2CLIP_MTX" },
+ { R200_VS_PNT_SPRITE_ATT_CONST, "R200_VS_PNT_SPRITE_ATT_CONST" },
+ { R200_VS_PNT_SPRITE_EYE_IN_MODEL, "R200_VS_PNT_SPRITE_EYE_IN_MODEL" },
+ { R200_VS_PNT_SPRITE_CLAMP, "R200_VS_PNT_SPRITE_CLAMP" },
+ { R200_VS_MAX, "R200_VS_MAX" },
+ { 1000, "" },
+};
+
+union fi { float f; int i; };
+
+#define ISVEC 1
+#define ISFLOAT 2
+#define TOUCHED 4
+
+struct reg {
+ int idx;
+ struct reg_names *closest;
+ int flags;
+ union fi current;
+ union fi *values;
+ int nvalues;
+ int nalloc;
+ float vmin, vmax;
+};
+
+
+static struct reg regs[Elements(reg_names)+1];
+static struct reg scalars[512+1];
+static struct reg vectors[512*4+1];
+
+static int total, total_changed, bufs;
+
+static void init_regs( void )
+{
+ struct reg_names *tmp;
+ int i;
+
+ for (i = 0 ; i < Elements(regs) ; i++) {
+ regs[i].idx = reg_names[i].idx;
+ regs[i].closest = &reg_names[i];
+ regs[i].flags = 0;
+ }
+
+ for (i = 0, tmp = scalar_names ; i < Elements(scalars) ; i++) {
+ if (tmp[1].idx == i) tmp++;
+ scalars[i].idx = i;
+ scalars[i].closest = tmp;
+ scalars[i].flags = ISFLOAT;
+ }
+
+ for (i = 0, tmp = vector_names ; i < Elements(vectors) ; i++) {
+ if (tmp[1].idx*4 == i) tmp++;
+ vectors[i].idx = i;
+ vectors[i].closest = tmp;
+ vectors[i].flags = ISFLOAT|ISVEC;
+ }
+
+ regs[Elements(regs)-1].idx = -1;
+ scalars[Elements(scalars)-1].idx = -1;
+ vectors[Elements(vectors)-1].idx = -1;
+}
+
+static int find_or_add_value( struct reg *reg, int val )
+{
+ int j;
+
+ for ( j = 0 ; j < reg->nvalues ; j++)
+ if ( val == reg->values[j].i )
+ return 1;
+
+ if (j == reg->nalloc) {
+ reg->nalloc += 5;
+ reg->nalloc *= 2;
+ reg->values = (union fi *) realloc( reg->values,
+ reg->nalloc * sizeof(union fi) );
+ }
+
+ reg->values[reg->nvalues++].i = val;
+ return 0;
+}
+
+static struct reg *lookup_reg( struct reg *tab, int reg )
+{
+ int i;
+
+ for (i = 0 ; tab[i].idx != -1 ; i++) {
+ if (tab[i].idx == reg)
+ return &tab[i];
+ }
+
+ fprintf(stderr, "*** unknown reg 0x%x\n", reg);
+ return NULL;
+}
+
+
+static const char *get_reg_name( struct reg *reg )
+{
+ static char tmp[80];
+
+ if (reg->idx == reg->closest->idx)
+ return reg->closest->name;
+
+
+ if (reg->flags & ISVEC) {
+ if (reg->idx/4 != reg->closest->idx)
+ sprintf(tmp, "%s+%d[%d]",
+ reg->closest->name,
+ (reg->idx/4) - reg->closest->idx,
+ reg->idx%4);
+ else
+ sprintf(tmp, "%s[%d]", reg->closest->name, reg->idx%4);
+ }
+ else {
+ if (reg->idx != reg->closest->idx)
+ sprintf(tmp, "%s+%d", reg->closest->name, reg->idx - reg->closest->idx);
+ else
+ sprintf(tmp, "%s", reg->closest->name);
+ }
+
+ return tmp;
+}
+
+static int print_int_reg_assignment( struct reg *reg, int data )
+{
+ int changed = (reg->current.i != data);
+ int ever_seen = find_or_add_value( reg, data );
+
+ if (VERBOSE || (NORMAL && (changed || !ever_seen)))
+ fprintf(stderr, " %s <-- 0x%x", get_reg_name(reg), data);
+
+ if (NORMAL) {
+ if (!ever_seen)
+ fprintf(stderr, " *** BRAND NEW VALUE");
+ else if (changed)
+ fprintf(stderr, " *** CHANGED");
+ }
+
+ reg->current.i = data;
+
+ if (VERBOSE || (NORMAL && (changed || !ever_seen)))
+ fprintf(stderr, "\n");
+
+ return changed;
+}
+
+
+static int print_float_reg_assignment( struct reg *reg, float data )
+{
+ int changed = (reg->current.f != data);
+ int newmin = (data < reg->vmin);
+ int newmax = (data > reg->vmax);
+
+ if (VERBOSE || (NORMAL && (newmin || newmax || changed)))
+ fprintf(stderr, " %s <-- %.3f", get_reg_name(reg), data);
+
+ if (NORMAL) {
+ if (newmin) {
+ fprintf(stderr, " *** NEW MIN (prev %.3f)", reg->vmin);
+ reg->vmin = data;
+ }
+ else if (newmax) {
+ fprintf(stderr, " *** NEW MAX (prev %.3f)", reg->vmax);
+ reg->vmax = data;
+ }
+ else if (changed) {
+ fprintf(stderr, " *** CHANGED");
+ }
+ }
+
+ reg->current.f = data;
+
+ if (VERBOSE || (NORMAL && (newmin || newmax || changed)))
+ fprintf(stderr, "\n");
+
+ return changed;
+}
+
+static int print_reg_assignment( struct reg *reg, int data )
+{
+ reg->flags |= TOUCHED;
+ if (reg->flags & ISFLOAT)
+ return print_float_reg_assignment( reg, *(float *)&data );
+ else
+ return print_int_reg_assignment( reg, data );
+}
+
+static void print_reg( struct reg *reg )
+{
+ if (reg->flags & TOUCHED) {
+ if (reg->flags & ISFLOAT) {
+ fprintf(stderr, " %s == %f\n", get_reg_name(reg), reg->current.f);
+ } else {
+ fprintf(stderr, " %s == 0x%x\n", get_reg_name(reg), reg->current.i);
+ }
+ }
+}
+
+
+static void dump_state( void )
+{
+ int i;
+
+ for (i = 0 ; i < Elements(regs) ; i++)
+ print_reg( &regs[i] );
+
+ for (i = 0 ; i < Elements(scalars) ; i++)
+ print_reg( &scalars[i] );
+
+ for (i = 0 ; i < Elements(vectors) ; i++)
+ print_reg( &vectors[i] );
+}
+
+
+
+static int radeon_emit_packets(
+ drm_radeon_cmd_header_t header,
+ drm_radeon_cmd_buffer_t *cmdbuf )
+{
+ int id = (int)header.packet.packet_id;
+ int sz = packet[id].len;
+ int *data = (int *)cmdbuf->buf;
+ int i;
+
+ if (sz * sizeof(int) > cmdbuf->bufsz) {
+ fprintf(stderr, "Packet overflows cmdbuf\n");
+ return -EINVAL;
+ }
+
+ if (!packet[id].name) {
+ fprintf(stderr, "*** Unknown packet 0 nr %d\n", id );
+ return -EINVAL;
+ }
+
+
+ if (VERBOSE)
+ fprintf(stderr, "Packet 0 reg %s nr %d\n", packet[id].name, sz );
+
+ for ( i = 0 ; i < sz ; i++) {
+ struct reg *reg = lookup_reg( regs, packet[id].start + i*4 );
+ if (print_reg_assignment( reg, data[i] ))
+ total_changed++;
+ total++;
+ }
+
+ cmdbuf->buf += sz * sizeof(int);
+ cmdbuf->bufsz -= sz * sizeof(int);
+ return 0;
+}
+
+
+static int radeon_emit_scalars(
+ drm_radeon_cmd_header_t header,
+ drm_radeon_cmd_buffer_t *cmdbuf )
+{
+ int sz = header.scalars.count;
+ int *data = (int *)cmdbuf->buf;
+ int start = header.scalars.offset;
+ int stride = header.scalars.stride;
+ int i;
+
+ if (VERBOSE)
+ fprintf(stderr, "emit scalars, start %d stride %d nr %d (end %d)\n",
+ start, stride, sz, start + stride * sz);
+
+
+ for (i = 0 ; i < sz ; i++, start += stride) {
+ struct reg *reg = lookup_reg( scalars, start );
+ if (print_reg_assignment( reg, data[i] ))
+ total_changed++;
+ total++;
+ }
+
+ cmdbuf->buf += sz * sizeof(int);
+ cmdbuf->bufsz -= sz * sizeof(int);
+ return 0;
+}
+
+
+static int radeon_emit_scalars2(
+ drm_radeon_cmd_header_t header,
+ drm_radeon_cmd_buffer_t *cmdbuf )
+{
+ int sz = header.scalars.count;
+ int *data = (int *)cmdbuf->buf;
+ int start = header.scalars.offset + 0x100;
+ int stride = header.scalars.stride;
+ int i;
+
+ if (VERBOSE)
+ fprintf(stderr, "emit scalars2, start %d stride %d nr %d (end %d)\n",
+ start, stride, sz, start + stride * sz);
+
+ if (start + stride * sz > 258) {
+ fprintf(stderr, "emit scalars OVERFLOW %d/%d/%d\n", start, stride, sz);
+ return -1;
+ }
+
+ for (i = 0 ; i < sz ; i++, start += stride) {
+ struct reg *reg = lookup_reg( scalars, start );
+ if (print_reg_assignment( reg, data[i] ))
+ total_changed++;
+ total++;
+ }
+
+ cmdbuf->buf += sz * sizeof(int);
+ cmdbuf->bufsz -= sz * sizeof(int);
+ return 0;
+}
+
+/* Check: inf/nan/extreme-size?
+ * Check: table start, end, nr, etc.
+ */
+static int radeon_emit_vectors(
+ drm_radeon_cmd_header_t header,
+ drm_radeon_cmd_buffer_t *cmdbuf )
+{
+ int sz = header.vectors.count;
+ int *data = (int *)cmdbuf->buf;
+ int start = header.vectors.offset;
+ int stride = header.vectors.stride;
+ int i,j;
+
+ if (VERBOSE)
+ fprintf(stderr, "emit vectors, start %d stride %d nr %d (end %d) (0x%x)\n",
+ start, stride, sz, start + stride * sz, header.i);
+
+/* if (start + stride * (sz/4) > 128) { */
+/* fprintf(stderr, "emit vectors OVERFLOW %d/%d/%d\n", start, stride, sz); */
+/* return -1; */
+/* } */
+
+ for (i = 0 ; i < sz ; start += stride) {
+ int changed = 0;
+ for (j = 0 ; j < 4 ; i++,j++) {
+ struct reg *reg = lookup_reg( vectors, start*4+j );
+ if (print_reg_assignment( reg, data[i] ))
+ changed = 1;
+ }
+ if (changed)
+ total_changed += 4;
+ total += 4;
+ }
+
+
+ cmdbuf->buf += sz * sizeof(int);
+ cmdbuf->bufsz -= sz * sizeof(int);
+ return 0;
+}
+
+#if 0
+static int print_vertex_format( int vfmt )
+{
+ if (NORMAL) {
+ fprintf(stderr, " %s(%x): %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+ "vertex format",
+ vfmt,
+ "xy,",
+ (vfmt & R200_VTX_Z0) ? "z," : "",
+ (vfmt & R200_VTX_W0) ? "w0," : "",
+ (vfmt & R200_VTX_FPCOLOR) ? "fpcolor," : "",
+ (vfmt & R200_VTX_FPALPHA) ? "fpalpha," : "",
+ (vfmt & R200_VTX_PKCOLOR) ? "pkcolor," : "",
+ (vfmt & R200_VTX_FPSPEC) ? "fpspec," : "",
+ (vfmt & R200_VTX_FPFOG) ? "fpfog," : "",
+ (vfmt & R200_VTX_PKSPEC) ? "pkspec," : "",
+ (vfmt & R200_VTX_ST0) ? "st0," : "",
+ (vfmt & R200_VTX_ST1) ? "st1," : "",
+ (vfmt & R200_VTX_Q1) ? "q1," : "",
+ (vfmt & R200_VTX_ST2) ? "st2," : "",
+ (vfmt & R200_VTX_Q2) ? "q2," : "",
+ (vfmt & R200_VTX_ST3) ? "st3," : "",
+ (vfmt & R200_VTX_Q3) ? "q3," : "",
+ (vfmt & R200_VTX_Q0) ? "q0," : "",
+ (vfmt & R200_VTX_N0) ? "n0," : "",
+ (vfmt & R200_VTX_XY1) ? "xy1," : "",
+ (vfmt & R200_VTX_Z1) ? "z1," : "",
+ (vfmt & R200_VTX_W1) ? "w1," : "",
+ (vfmt & R200_VTX_N1) ? "n1," : "");
+
+
+ if (!find_or_add_value( &others[V_VTXFMT], vfmt ))
+ fprintf(stderr, " *** NEW VALUE");
+
+ fprintf(stderr, "\n");
+ }
+
+ return 0;
+}
+#endif
+
+static char *primname[0x10] = {
+ "NONE",
+ "POINTS",
+ "LINES",
+ "LINE_STRIP",
+ "TRIANGLES",
+ "TRIANGLE_FAN",
+ "TRIANGLE_STRIP",
+ "RECT_LIST",
+ NULL,
+ "3VRT_POINTS",
+ "3VRT_LINES",
+ "POINT_SPRITES",
+ "LINE_LOOP",
+ "QUADS",
+ "QUAD_STRIP",
+ "POLYGON",
+};
+
+static int print_prim_and_flags( int prim )
+{
+ int numverts;
+
+ if (NORMAL)
+ fprintf(stderr, " %s(%x): %s%s%s%s%s%s\n",
+ "prim flags",
+ prim,
+ ((prim & 0x30) == R200_VF_PRIM_WALK_IND) ? "IND," : "",
+ ((prim & 0x30) == R200_VF_PRIM_WALK_LIST) ? "LIST," : "",
+ ((prim & 0x30) == R200_VF_PRIM_WALK_RING) ? "RING," : "",
+ (prim & R200_VF_COLOR_ORDER_RGBA) ? "RGBA," : "BGRA, ",
+ (prim & R200_VF_INDEX_SZ_4) ? "INDX-32," : "",
+ (prim & R200_VF_TCL_OUTPUT_VTX_ENABLE) ? "TCL_OUT_VTX," : "");
+
+ numverts = prim>>16;
+
+ if (NORMAL)
+ fprintf(stderr, " prim: %s numverts %d\n", primname[prim&0xf], numverts);
+
+ switch (prim & 0xf) {
+ case R200_VF_PRIM_NONE:
+ case R200_VF_PRIM_POINTS:
+ if (numverts < 1) {
+ fprintf(stderr, "Bad nr verts for line %d\n", numverts);
+ return -1;
+ }
+ break;
+ case R200_VF_PRIM_LINES:
+ case R200_VF_PRIM_POINT_SPRITES:
+ if ((numverts & 1) || numverts == 0) {
+ fprintf(stderr, "Bad nr verts for line %d\n", numverts);
+ return -1;
+ }
+ break;
+ case R200_VF_PRIM_LINE_STRIP:
+ case R200_VF_PRIM_LINE_LOOP:
+ if (numverts < 2) {
+ fprintf(stderr, "Bad nr verts for line_strip %d\n", numverts);
+ return -1;
+ }
+ break;
+ case R200_VF_PRIM_TRIANGLES:
+ case R200_VF_PRIM_3VRT_POINTS:
+ case R200_VF_PRIM_3VRT_LINES:
+ case R200_VF_PRIM_RECT_LIST:
+ if (numverts % 3 || numverts == 0) {
+ fprintf(stderr, "Bad nr verts for tri %d\n", numverts);
+ return -1;
+ }
+ break;
+ case R200_VF_PRIM_TRIANGLE_FAN:
+ case R200_VF_PRIM_TRIANGLE_STRIP:
+ case R200_VF_PRIM_POLYGON:
+ if (numverts < 3) {
+ fprintf(stderr, "Bad nr verts for strip/fan %d\n", numverts);
+ return -1;
+ }
+ break;
+ case R200_VF_PRIM_QUADS:
+ if (numverts % 4 || numverts == 0) {
+ fprintf(stderr, "Bad nr verts for quad %d\n", numverts);
+ return -1;
+ }
+ break;
+ case R200_VF_PRIM_QUAD_STRIP:
+ if (numverts % 2 || numverts < 4) {
+ fprintf(stderr, "Bad nr verts for quadstrip %d\n", numverts);
+ return -1;
+ }
+ break;
+ default:
+ fprintf(stderr, "Bad primitive\n");
+ return -1;
+ }
+ return 0;
+}
+
+/* build in knowledge about each packet type
+ */
+static int radeon_emit_packet3( drm_radeon_cmd_buffer_t *cmdbuf )
+{
+ int cmdsz;
+ int *cmd = (int *)cmdbuf->buf;
+ int *tmp;
+ int i, stride, size, start;
+
+ cmdsz = 2 + ((cmd[0] & RADEON_CP_PACKET_COUNT_MASK) >> 16);
+
+ if ((cmd[0] & RADEON_CP_PACKET_MASK) != RADEON_CP_PACKET3 ||
+ cmdsz * 4 > cmdbuf->bufsz ||
+ cmdsz > RADEON_CP_PACKET_MAX_DWORDS) {
+ fprintf(stderr, "Bad packet\n");
+ return -EINVAL;
+ }
+
+ switch( cmd[0] & ~RADEON_CP_PACKET_COUNT_MASK ) {
+ case R200_CP_CMD_NOP:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_NOP, %d dwords\n", cmdsz);
+ break;
+ case R200_CP_CMD_NEXT_CHAR:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_NEXT_CHAR, %d dwords\n", cmdsz);
+ break;
+ case R200_CP_CMD_PLY_NEXTSCAN:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_PLY_NEXTSCAN, %d dwords\n", cmdsz);
+ break;
+ case R200_CP_CMD_SET_SCISSORS:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_SET_SCISSORS, %d dwords\n", cmdsz);
+ break;
+ case R200_CP_CMD_LOAD_MICROCODE:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_LOAD_MICROCODE, %d dwords\n", cmdsz);
+ break;
+ case R200_CP_CMD_WAIT_FOR_IDLE:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_WAIT_FOR_IDLE, %d dwords\n", cmdsz);
+ break;
+
+ case R200_CP_CMD_3D_DRAW_VBUF:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_3D_DRAW_VBUF, %d dwords\n", cmdsz);
+/* print_vertex_format(cmd[1]); */
+ if (print_prim_and_flags(cmd[2]))
+ return -EINVAL;
+ break;
+
+ case R200_CP_CMD_3D_DRAW_IMMD:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_3D_DRAW_IMMD, %d dwords\n", cmdsz);
+ break;
+ case R200_CP_CMD_3D_DRAW_INDX: {
+ int neltdwords;
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_3D_DRAW_INDX, %d dwords\n", cmdsz);
+/* print_vertex_format(cmd[1]); */
+ if (print_prim_and_flags(cmd[2]))
+ return -EINVAL;
+ neltdwords = cmd[2]>>16;
+ neltdwords += neltdwords & 1;
+ neltdwords /= 2;
+ if (neltdwords + 3 != cmdsz)
+ fprintf(stderr, "Mismatch in DRAW_INDX, %d vs cmdsz %d\n",
+ neltdwords, cmdsz);
+ break;
+ }
+ case R200_CP_CMD_LOAD_PALETTE:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_LOAD_PALETTE, %d dwords\n", cmdsz);
+ break;
+ case R200_CP_CMD_3D_LOAD_VBPNTR:
+ if (NORMAL) {
+ fprintf(stderr, "PACKET3_3D_LOAD_VBPNTR, %d dwords\n", cmdsz);
+ fprintf(stderr, " nr arrays: %d\n", cmd[1]);
+ }
+
+ if (((cmd[1]/2)*3) + ((cmd[1]%2)*2) != cmdsz - 2) {
+ fprintf(stderr, " ****** MISMATCH %d/%d *******\n",
+ ((cmd[1]/2)*3) + ((cmd[1]%2)*2) + 2, cmdsz);
+ return -EINVAL;
+ }
+
+ if (NORMAL) {
+ tmp = cmd+2;
+ for (i = 0 ; i < cmd[1] ; i++) {
+ if (i & 1) {
+ stride = (tmp[0]>>24) & 0xff;
+ size = (tmp[0]>>16) & 0xff;
+ start = tmp[2];
+ tmp += 3;
+ }
+ else {
+ stride = (tmp[0]>>8) & 0xff;
+ size = (tmp[0]) & 0xff;
+ start = tmp[1];
+ }
+ fprintf(stderr, " array %d: start 0x%x vsize %d vstride %d\n",
+ i, start, size, stride );
+ }
+ }
+ break;
+ case R200_CP_CMD_PAINT:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_PAINT, %d dwords\n", cmdsz);
+ break;
+ case R200_CP_CMD_BITBLT:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_BITBLT, %d dwords\n", cmdsz);
+ break;
+ case R200_CP_CMD_SMALLTEXT:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_SMALLTEXT, %d dwords\n", cmdsz);
+ break;
+ case R200_CP_CMD_HOSTDATA_BLT:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_HOSTDATA_BLT, %d dwords\n",
+ cmdsz);
+ break;
+ case R200_CP_CMD_POLYLINE:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_POLYLINE, %d dwords\n", cmdsz);
+ break;
+ case R200_CP_CMD_POLYSCANLINES:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_POLYSCANLINES, %d dwords\n",
+ cmdsz);
+ break;
+ case R200_CP_CMD_PAINT_MULTI:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_PAINT_MULTI, %d dwords\n",
+ cmdsz);
+ break;
+ case R200_CP_CMD_BITBLT_MULTI:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_BITBLT_MULTI, %d dwords\n",
+ cmdsz);
+ break;
+ case R200_CP_CMD_TRANS_BITBLT:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_TRANS_BITBLT, %d dwords\n",
+ cmdsz);
+ break;
+ case R200_CP_CMD_3D_DRAW_VBUF_2:
+ if (NORMAL)
+ fprintf(stderr, "R200_CP_CMD_3D_DRAW_VBUF_2, %d dwords\n",
+ cmdsz);
+ if (print_prim_and_flags(cmd[1]))
+ return -EINVAL;
+ break;
+ case R200_CP_CMD_3D_DRAW_IMMD_2:
+ if (NORMAL)
+ fprintf(stderr, "R200_CP_CMD_3D_DRAW_IMMD_2, %d dwords\n",
+ cmdsz);
+ if (print_prim_and_flags(cmd[1]))
+ return -EINVAL;
+ break;
+ case R200_CP_CMD_3D_DRAW_INDX_2:
+ if (NORMAL)
+ fprintf(stderr, "R200_CP_CMD_3D_DRAW_INDX_2, %d dwords\n",
+ cmdsz);
+ if (print_prim_and_flags(cmd[1]))
+ return -EINVAL;
+ break;
+ default:
+ fprintf(stderr, "UNKNOWN PACKET, %d dwords\n", cmdsz);
+ break;
+ }
+
+ cmdbuf->buf += cmdsz * 4;
+ cmdbuf->bufsz -= cmdsz * 4;
+ return 0;
+}
+
+
+/* Check cliprects for bounds, then pass on to above:
+ */
+static int radeon_emit_packet3_cliprect( drm_radeon_cmd_buffer_t *cmdbuf )
+{
+ drm_clip_rect_t *boxes = (drm_clip_rect_t *)cmdbuf->boxes;
+ int i = 0;
+
+ if (VERBOSE && total_changed) {
+ dump_state();
+ total_changed = 0;
+ }
+
+ if (NORMAL) {
+ do {
+ if ( i < cmdbuf->nbox ) {
+ fprintf(stderr, "Emit box %d/%d %d,%d %d,%d\n",
+ i, cmdbuf->nbox,
+ boxes[i].x1, boxes[i].y1, boxes[i].x2, boxes[i].y2);
+ }
+ } while ( ++i < cmdbuf->nbox );
+ }
+
+ if (cmdbuf->nbox == 1)
+ cmdbuf->nbox = 0;
+
+ return radeon_emit_packet3( cmdbuf );
+}
+
+
+int r200SanityCmdBuffer( r200ContextPtr rmesa,
+ int nbox,
+ drm_clip_rect_t *boxes )
+{
+ int idx;
+ drm_radeon_cmd_buffer_t cmdbuf;
+ drm_radeon_cmd_header_t header;
+ static int inited = 0;
+
+ if (!inited) {
+ init_regs();
+ inited = 1;
+ }
+
+
+ cmdbuf.buf = rmesa->store.cmd_buf;
+ cmdbuf.bufsz = rmesa->store.cmd_used;
+ cmdbuf.boxes = (drm_clip_rect_t *)boxes;
+ cmdbuf.nbox = nbox;
+
+ while ( cmdbuf.bufsz >= sizeof(header) ) {
+
+ header.i = *(int *)cmdbuf.buf;
+ cmdbuf.buf += sizeof(header);
+ cmdbuf.bufsz -= sizeof(header);
+
+ switch (header.header.cmd_type) {
+ case RADEON_CMD_PACKET:
+ if (radeon_emit_packets( header, &cmdbuf )) {
+ fprintf(stderr,"radeon_emit_packets failed\n");
+ return -EINVAL;
+ }
+ break;
+
+ case RADEON_CMD_SCALARS:
+ if (radeon_emit_scalars( header, &cmdbuf )) {
+ fprintf(stderr,"radeon_emit_scalars failed\n");
+ return -EINVAL;
+ }
+ break;
+
+ case RADEON_CMD_SCALARS2:
+ if (radeon_emit_scalars2( header, &cmdbuf )) {
+ fprintf(stderr,"radeon_emit_scalars failed\n");
+ return -EINVAL;
+ }
+ break;
+
+ case RADEON_CMD_VECTORS:
+ if (radeon_emit_vectors( header, &cmdbuf )) {
+ fprintf(stderr,"radeon_emit_vectors failed\n");
+ return -EINVAL;
+ }
+ break;
+
+ case RADEON_CMD_DMA_DISCARD:
+ idx = header.dma.buf_idx;
+ if (NORMAL)
+ fprintf(stderr, "RADEON_CMD_DMA_DISCARD buf %d\n", idx);
+ bufs++;
+ break;
+
+ case RADEON_CMD_PACKET3:
+ if (radeon_emit_packet3( &cmdbuf )) {
+ fprintf(stderr,"radeon_emit_packet3 failed\n");
+ return -EINVAL;
+ }
+ break;
+
+ case RADEON_CMD_PACKET3_CLIP:
+ if (radeon_emit_packet3_cliprect( &cmdbuf )) {
+ fprintf(stderr,"radeon_emit_packet3_clip failed\n");
+ return -EINVAL;
+ }
+ break;
+
+ case RADEON_CMD_WAIT:
+ break;
+
+ default:
+ fprintf(stderr,"bad cmd_type %d at %p\n",
+ header.header.cmd_type,
+ cmdbuf.buf - sizeof(header));
+ return -EINVAL;
+ }
+ }
+
+ if (0)
+ {
+ static int n = 0;
+ n++;
+ if (n == 10) {
+ fprintf(stderr, "Bufs %d Total emitted %d real changes %d (%.2f%%)\n",
+ bufs,
+ total, total_changed,
+ ((float)total_changed/(float)total*100.0));
+ fprintf(stderr, "Total emitted per buf: %.2f\n",
+ (float)total/(float)bufs);
+ fprintf(stderr, "Real changes per buf: %.2f\n",
+ (float)total_changed/(float)bufs);
+
+ bufs = n = total = total_changed = 0;
+ }
+ }
+
+ fprintf(stderr, "leaving %s\n\n\n", __FUNCTION__);
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_sanity.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_sanity.h
new file mode 100644
index 000000000..f4c110dba
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_sanity.h
@@ -0,0 +1,8 @@
+#ifndef R200_SANITY_H
+#define R200_SANITY_H
+
+extern int r200SanityCmdBuffer( r200ContextPtr rmesa,
+ int nbox,
+ drm_clip_rect_t *boxes );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_screen.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_screen.c
new file mode 100644
index 000000000..08e4a3548
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_screen.c
@@ -0,0 +1,737 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_screen.c,v 1.4 2003/05/08 09:25:35 herrb Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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.
+
+**************************************************************************/
+
+/**
+ * \file r200_screen.c
+ * Screen initialization functions for the R200 driver.
+ *
+ * \author Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include <dlfcn.h>
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+
+#define STANDALONE_MMIO
+#include "r200_screen.h"
+#include "r200_context.h"
+#include "r200_ioctl.h"
+#include "r200_span.h"
+#include "radeon_macros.h"
+#include "radeon_reg.h"
+
+#include "drirenderbuffer.h"
+#include "utils.h"
+#include "vblank.h"
+#include "GL/internal/dri_interface.h"
+
+/* R200 configuration
+ */
+#include "xmlpool.h"
+
+PUBLIC const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
+ DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_MAX_TEXTURE_UNITS(4,2,6)
+ DRI_CONF_HYPERZ(false)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_QUALITY
+ DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
+ DRI_CONF_DEF_MAX_ANISOTROPY(1.0,"1.0,2.0,4.0,8.0,16.0")
+ DRI_CONF_NO_NEG_LOD_BIAS(false)
+ DRI_CONF_FORCE_S3TC_ENABLE(false)
+ DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
+ DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC)
+ DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF)
+ DRI_CONF_TEXTURE_LEVEL_HACK(false)
+ DRI_CONF_TEXTURE_BLEND_QUALITY(1.0,"0.0:1.0")
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_NO_RAST(false)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_SOFTWARE
+ DRI_CONF_ARB_VERTEX_PROGRAM(false)
+ DRI_CONF_NV_VERTEX_PROGRAM(false)
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+static const GLuint __driNConfigOptions = 17;
+
+extern const struct dri_extension card_extensions[];
+extern const struct dri_extension blend_extensions[];
+extern const struct dri_extension ARB_vp_extension[];
+extern const struct dri_extension NV_vp_extension[];
+
+#if 1
+/* Including xf86PciInfo.h introduces a bunch of errors...
+ */
+#define PCI_CHIP_R200_QD 0x5144 /* why do they have r200 names? */
+#define PCI_CHIP_R200_QE 0x5145 /* Those are all standard radeons */
+#define PCI_CHIP_R200_QF 0x5146
+#define PCI_CHIP_R200_QG 0x5147
+#define PCI_CHIP_R200_QY 0x5159
+#define PCI_CHIP_R200_QZ 0x515A
+#define PCI_CHIP_R200_LW 0x4C57
+#define PCI_CHIP_R200_LX 0x4C58
+#define PCI_CHIP_R200_LY 0x4C59
+#define PCI_CHIP_R200_LZ 0x4C5A
+#define PCI_CHIP_RV200_QW 0x5157 /* Radeon 7500 - not an R200 at all */
+#define PCI_CHIP_RV200_QX 0x5158
+#define PCI_CHIP_RS100_4136 0x4136 /* IGP RS100, RS200, RS250 are not R200 */
+#define PCI_CHIP_RS200_4137 0x4137
+#define PCI_CHIP_RS250_4237 0x4237
+#define PCI_CHIP_RS100_4336 0x4336
+#define PCI_CHIP_RS200_4337 0x4337
+#define PCI_CHIP_RS250_4437 0x4437
+#define PCI_CHIP_RS300_5834 0x5834 /* All RS300's are R200 */
+#define PCI_CHIP_RS300_5835 0x5835
+#define PCI_CHIP_RS300_5836 0x5836
+#define PCI_CHIP_RS300_5837 0x5837
+#define PCI_CHIP_R200_BB 0x4242 /* r200 (non-derived) start */
+#define PCI_CHIP_R200_BC 0x4243
+#define PCI_CHIP_R200_QH 0x5148
+#define PCI_CHIP_R200_QI 0x5149
+#define PCI_CHIP_R200_QJ 0x514A
+#define PCI_CHIP_R200_QK 0x514B
+#define PCI_CHIP_R200_QL 0x514C
+#define PCI_CHIP_R200_QM 0x514D
+#define PCI_CHIP_R200_QN 0x514E
+#define PCI_CHIP_R200_QO 0x514F /* r200 (non-derived) end */
+/* are the R200 Qh (0x5168) and following needed too? They are not in
+ xf86PciInfo.h but in the pci database. Maybe just secondary ports or
+ something ? Ah well, better be safe than sorry */
+#define PCI_CHIP_R200_Qh 0x5168
+#define PCI_CHIP_R200_Qi 0x5169
+#define PCI_CHIP_R200_Qj 0x516A
+#define PCI_CHIP_R200_Qk 0x516B
+#define PCI_CHIP_R200_Ql 0x516C
+
+#endif
+
+
+static r200ScreenPtr __r200Screen;
+
+static int getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo );
+
+static __GLcontextModes *
+r200FillInModes( unsigned pixel_bits, unsigned depth_bits,
+ unsigned stencil_bits, GLboolean have_back_buffer )
+{
+ __GLcontextModes * modes;
+ __GLcontextModes * m;
+ unsigned num_modes;
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ GLenum fb_format;
+ GLenum fb_type;
+
+ /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
+ * enough to add support. Basically, if a context is created with an
+ * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
+ * will never be used.
+ */
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
+ };
+
+ u_int8_t depth_bits_array[2];
+ u_int8_t stencil_bits_array[2];
+
+
+ depth_bits_array[0] = depth_bits;
+ depth_bits_array[1] = depth_bits;
+
+ /* Just like with the accumulation buffer, always provide some modes
+ * with a stencil buffer. It will be a sw fallback, but some apps won't
+ * care about that.
+ */
+ stencil_bits_array[0] = 0;
+ stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
+
+ depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1;
+ back_buffer_factor = (have_back_buffer) ? 2 : 1;
+
+ num_modes = depth_buffer_factor * back_buffer_factor * 4;
+
+ if ( pixel_bits == 16 ) {
+ fb_format = GL_RGB;
+ fb_type = GL_UNSIGNED_SHORT_5_6_5;
+ }
+ else {
+ fb_format = GL_BGRA;
+ fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ }
+
+ modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
+ m = modes;
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_TRUE_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_DIRECT_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+
+ /* Mark the visual as slow if there are "fake" stencil bits.
+ */
+ for ( m = modes ; m != NULL ; m = m->next ) {
+ if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) {
+ m->visualRating = GLX_SLOW_CONFIG;
+ }
+ }
+
+ return modes;
+}
+
+
+/* Create the device specific screen private data struct.
+ */
+static r200ScreenPtr
+r200CreateScreen( __DRIscreenPrivate *sPriv )
+{
+ r200ScreenPtr screen;
+ RADEONDRIPtr dri_priv = (RADEONDRIPtr)sPriv->pDevPriv;
+ unsigned char *RADEONMMIO;
+ PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
+ (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
+ void * const psc = sPriv->psc->screenConfigs;
+
+ if (sPriv->devPrivSize != sizeof(RADEONDRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(RADEONDRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
+
+ /* Allocate the private area */
+ screen = (r200ScreenPtr) CALLOC( sizeof(*screen) );
+ if ( !screen ) {
+ __driUtilMessage("%s: Could not allocate memory for screen structure",
+ __FUNCTION__);
+ return NULL;
+ }
+
+ screen->chipset = 0;
+ switch ( dri_priv->deviceID ) {
+ case PCI_CHIP_R200_QD:
+ case PCI_CHIP_R200_QE:
+ case PCI_CHIP_R200_QF:
+ case PCI_CHIP_R200_QG:
+ case PCI_CHIP_R200_QY:
+ case PCI_CHIP_R200_QZ:
+ case PCI_CHIP_RV200_QW:
+ case PCI_CHIP_RV200_QX:
+ case PCI_CHIP_R200_LW:
+ case PCI_CHIP_R200_LX:
+ case PCI_CHIP_R200_LY:
+ case PCI_CHIP_R200_LZ:
+ case PCI_CHIP_RS100_4136:
+ case PCI_CHIP_RS200_4137:
+ case PCI_CHIP_RS250_4237:
+ case PCI_CHIP_RS100_4336:
+ case PCI_CHIP_RS200_4337:
+ case PCI_CHIP_RS250_4437:
+ __driUtilMessage("r200CreateScreen(): Device isn't an r200!\n");
+ FREE( screen );
+ return NULL;
+
+ case PCI_CHIP_RS300_5834:
+ case PCI_CHIP_RS300_5835:
+ case PCI_CHIP_RS300_5836:
+ case PCI_CHIP_RS300_5837:
+ break;
+
+ case PCI_CHIP_R200_BB:
+ case PCI_CHIP_R200_BC:
+ case PCI_CHIP_R200_QH:
+ case PCI_CHIP_R200_QI:
+ case PCI_CHIP_R200_QJ:
+ case PCI_CHIP_R200_QK:
+ case PCI_CHIP_R200_QL:
+ case PCI_CHIP_R200_QM:
+ case PCI_CHIP_R200_QN:
+ case PCI_CHIP_R200_QO:
+ case PCI_CHIP_R200_Qh:
+ case PCI_CHIP_R200_Qi:
+ case PCI_CHIP_R200_Qj:
+ case PCI_CHIP_R200_Qk:
+ case PCI_CHIP_R200_Ql:
+ screen->chipset |= R200_CHIPSET_REAL_R200;
+ /* fallthrough */
+ default:
+ screen->chipset |= R200_CHIPSET_TCL;
+ break;
+ }
+
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo (&screen->optionCache,
+ __driConfigOptions, __driNConfigOptions);
+
+ /* This is first since which regions we map depends on whether or
+ * not we are using a PCI card.
+ */
+ screen->IsPCI = dri_priv->IsPCI;
+
+ {
+ int ret;
+ drm_radeon_getparam_t gp;
+
+ gp.param = RADEON_PARAM_GART_BUFFER_OFFSET;
+ gp.value = &screen->gart_buffer_offset;
+
+ ret = drmCommandWriteRead( sPriv->fd, DRM_RADEON_GETPARAM,
+ &gp, sizeof(gp));
+ if (ret) {
+ FREE( screen );
+ fprintf(stderr, "drmRadeonGetParam (RADEON_PARAM_GART_BUFFER_OFFSET): %d\n", ret);
+ return NULL;
+ }
+
+ if (sPriv->drmMinor >= 6) {
+ gp.param = RADEON_PARAM_GART_BASE;
+ gp.value = &screen->gart_base;
+
+ ret = drmCommandWriteRead( sPriv->fd, DRM_RADEON_GETPARAM,
+ &gp, sizeof(gp));
+ if (ret) {
+ FREE( screen );
+ fprintf(stderr, "drmR200GetParam (RADEON_PARAM_GART_BASE): %d\n", ret);
+ return NULL;
+ }
+
+
+ gp.param = RADEON_PARAM_IRQ_NR;
+ gp.value = &screen->irq;
+
+ ret = drmCommandWriteRead( sPriv->fd, DRM_RADEON_GETPARAM,
+ &gp, sizeof(gp));
+ if (ret) {
+ FREE( screen );
+ fprintf(stderr, "drmRadeonGetParam (RADEON_PARAM_IRQ_NR): %d\n", ret);
+ return NULL;
+ }
+
+ /* Check if kernel module is new enough to support cube maps */
+ screen->drmSupportsCubeMaps = (sPriv->drmMinor >= 7);
+ /* Check if kernel module is new enough to support blend color and
+ separate blend functions/equations */
+ screen->drmSupportsBlendColor = (sPriv->drmMinor >= 11);
+
+ screen->drmSupportsTriPerf = (sPriv->drmMinor >= 16);
+ }
+ /* Check if ddx has set up a surface reg to cover depth buffer */
+ screen->depthHasSurface = (sPriv->ddxMajor > 4);
+ }
+
+ screen->mmio.handle = dri_priv->registerHandle;
+ screen->mmio.size = dri_priv->registerSize;
+ if ( drmMap( sPriv->fd,
+ screen->mmio.handle,
+ screen->mmio.size,
+ &screen->mmio.map ) ) {
+ FREE( screen );
+ __driUtilMessage("%s: drmMap failed\n", __FUNCTION__ );
+ return NULL;
+ }
+
+ RADEONMMIO = screen->mmio.map;
+
+ screen->status.handle = dri_priv->statusHandle;
+ screen->status.size = dri_priv->statusSize;
+ if ( drmMap( sPriv->fd,
+ screen->status.handle,
+ screen->status.size,
+ &screen->status.map ) ) {
+ drmUnmap( screen->mmio.map, screen->mmio.size );
+ FREE( screen );
+ __driUtilMessage("%s: drmMap (2) failed\n", __FUNCTION__ );
+ return NULL;
+ }
+ screen->scratch = (__volatile__ u_int32_t *)
+ ((GLubyte *)screen->status.map + RADEON_SCRATCH_REG_OFFSET);
+
+ screen->buffers = drmMapBufs( sPriv->fd );
+ if ( !screen->buffers ) {
+ drmUnmap( screen->status.map, screen->status.size );
+ drmUnmap( screen->mmio.map, screen->mmio.size );
+ FREE( screen );
+ __driUtilMessage("%s: drmMapBufs failed\n", __FUNCTION__ );
+ return NULL;
+ }
+
+ RADEONMMIO = screen->mmio.map;
+
+ if ( dri_priv->gartTexHandle && dri_priv->gartTexMapSize ) {
+
+ screen->gartTextures.handle = dri_priv->gartTexHandle;
+ screen->gartTextures.size = dri_priv->gartTexMapSize;
+ if ( drmMap( sPriv->fd,
+ screen->gartTextures.handle,
+ screen->gartTextures.size,
+ (drmAddressPtr)&screen->gartTextures.map ) ) {
+ drmUnmapBufs( screen->buffers );
+ drmUnmap( screen->status.map, screen->status.size );
+ drmUnmap( screen->mmio.map, screen->mmio.size );
+ FREE( screen );
+ __driUtilMessage("%s: drmMAP failed for GART texture area\n", __FUNCTION__);
+ return NULL;
+ }
+
+ screen->gart_texture_offset = dri_priv->gartTexOffset + ( screen->IsPCI
+ ? INREG( RADEON_AIC_LO_ADDR )
+ : ( ( INREG( RADEON_MC_AGP_LOCATION ) & 0x0ffffU ) << 16 ) );
+ }
+
+ screen->cpp = dri_priv->bpp / 8;
+ screen->AGPMode = dri_priv->AGPMode;
+
+ screen->fbLocation = ( INREG( RADEON_MC_FB_LOCATION ) & 0xffff ) << 16;
+
+ if ( sPriv->drmMinor >= 10 ) {
+ drm_radeon_setparam_t sp;
+
+ sp.param = RADEON_SETPARAM_FB_LOCATION;
+ sp.value = screen->fbLocation;
+
+ drmCommandWrite( sPriv->fd, DRM_RADEON_SETPARAM,
+ &sp, sizeof( sp ) );
+ }
+
+ screen->frontOffset = dri_priv->frontOffset;
+ screen->frontPitch = dri_priv->frontPitch;
+ screen->backOffset = dri_priv->backOffset;
+ screen->backPitch = dri_priv->backPitch;
+ screen->depthOffset = dri_priv->depthOffset;
+ screen->depthPitch = dri_priv->depthPitch;
+
+ if ( dri_priv->textureSize == 0 ) {
+ screen->texOffset[RADEON_LOCAL_TEX_HEAP] = screen->gart_texture_offset;
+ screen->texSize[RADEON_GART_TEX_HEAP] = dri_priv->gartTexMapSize;
+ screen->logTexGranularity[RADEON_GART_TEX_HEAP] =
+ dri_priv->log2GARTTexGran;
+ } else {
+ screen->texOffset[RADEON_LOCAL_TEX_HEAP] = dri_priv->textureOffset
+ + screen->fbLocation;
+ screen->texSize[RADEON_LOCAL_TEX_HEAP] = dri_priv->textureSize;
+ screen->logTexGranularity[RADEON_LOCAL_TEX_HEAP] =
+ dri_priv->log2TexGran;
+ }
+
+ if ( !screen->gartTextures.map || dri_priv->textureSize == 0 ) {
+ screen->numTexHeaps = RADEON_NR_TEX_HEAPS - 1;
+ screen->texOffset[RADEON_GART_TEX_HEAP] = 0;
+ screen->texSize[RADEON_GART_TEX_HEAP] = 0;
+ screen->logTexGranularity[RADEON_GART_TEX_HEAP] = 0;
+ } else {
+ screen->numTexHeaps = RADEON_NR_TEX_HEAPS;
+ screen->texOffset[RADEON_GART_TEX_HEAP] = screen->gart_texture_offset;
+ screen->texSize[RADEON_GART_TEX_HEAP] = dri_priv->gartTexMapSize;
+ screen->logTexGranularity[RADEON_GART_TEX_HEAP] =
+ dri_priv->log2GARTTexGran;
+ }
+
+ screen->driScreen = sPriv;
+ screen->sarea_priv_offset = dri_priv->sarea_priv_offset;
+
+ if ( glx_enable_extension != NULL ) {
+ if ( screen->irq != 0 ) {
+ (*glx_enable_extension)( psc, "GLX_SGI_swap_control" );
+ (*glx_enable_extension)( psc, "GLX_SGI_video_sync" );
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_control" );
+ }
+
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
+ (*glx_enable_extension)( psc, "GLX_MESA_allocate_memory" );
+ }
+
+ sPriv->psc->allocateMemory = (void *) r200AllocateMemoryMESA;
+ sPriv->psc->freeMemory = (void *) r200FreeMemoryMESA;
+ sPriv->psc->memoryOffset = (void *) r200GetMemoryOffsetMESA;
+
+ return screen;
+}
+
+/* Destroy the device specific screen private data struct.
+ */
+static void
+r200DestroyScreen( __DRIscreenPrivate *sPriv )
+{
+ r200ScreenPtr screen = (r200ScreenPtr)sPriv->private;
+
+ if (!screen)
+ return;
+
+ if ( screen->gartTextures.map ) {
+ drmUnmap( screen->gartTextures.map, screen->gartTextures.size );
+ }
+ drmUnmapBufs( screen->buffers );
+ drmUnmap( screen->status.map, screen->status.size );
+ drmUnmap( screen->mmio.map, screen->mmio.size );
+
+ /* free all option information */
+ driDestroyOptionInfo (&screen->optionCache);
+
+ FREE( screen );
+ sPriv->private = NULL;
+}
+
+
+/* Initialize the driver specific screen private data.
+ */
+static GLboolean
+r200InitDriver( __DRIscreenPrivate *sPriv )
+{
+ __r200Screen = r200CreateScreen( sPriv );
+
+ sPriv->private = (void *) __r200Screen;
+
+ return sPriv->private ? GL_TRUE : GL_FALSE;
+}
+
+
+/**
+ * Create and initialize the Mesa and driver specific pixmap buffer
+ * data. This is called to setup rendering to a particular window.
+ *
+ * \todo This function (and its interface) will need to be updated to support
+ * pbuffers.
+ */
+static GLboolean
+r200CreateBuffer( __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ r200ScreenPtr screen = (r200ScreenPtr) driScrnPriv->private;
+
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+ const GLboolean swDepth = GL_FALSE;
+ const GLboolean swAlpha = GL_FALSE;
+ const GLboolean swAccum = mesaVis->accumRedBits > 0;
+ const GLboolean swStencil = mesaVis->stencilBits > 0 &&
+ mesaVis->depthBits != 24;
+#if 0
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer( mesaVis,
+ swDepth,
+ swStencil,
+ swAccum,
+ swAlpha );
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->frontPitch);
+ r200SetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ r200SetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ r200SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ r200SetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ r200SetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ swDepth,
+ swStencil,
+ swAccum,
+ swAlpha,
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+
+static void
+r200DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+
+
+
+static const struct __DriverAPIRec r200API = {
+ .InitDriver = r200InitDriver,
+ .DestroyScreen = r200DestroyScreen,
+ .CreateContext = r200CreateContext,
+ .DestroyContext = r200DestroyContext,
+ .CreateBuffer = r200CreateBuffer,
+ .DestroyBuffer = r200DestroyBuffer,
+ .SwapBuffers = r200SwapBuffers,
+ .MakeCurrent = r200MakeCurrent,
+ .UnbindContext = r200UnbindContext,
+ .GetSwapInfo = getSwapInfo,
+ .GetMSC = driGetMSC32,
+ .WaitForMSC = driWaitForMSC32,
+ .WaitForSBC = NULL,
+ .SwapBuffersMSC = NULL
+};
+
+
+/**
+ * This is the bootstrap function for the driver. libGL supplies all of the
+ * requisite information about the system, and the driver initializes itself.
+ * This routine also fills in the linked list pointed to by \c driver_modes
+ * with the \c __GLcontextModes that the driver can support for windows or
+ * pbuffers.
+ *
+ * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
+ * failure.
+ */
+PUBLIC
+void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
+ const __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drmAddress pSAREA, int fd,
+ int internal_api_version,
+ const __DRIinterfaceMethods * interface,
+ __GLcontextModes ** driver_modes )
+
+{
+ __DRIscreenPrivate *psp;
+ static const __DRIutilversion2 ddx_expected = { 4, 5, 0, 0 };
+ static const __DRIversion dri_expected = { 4, 0, 0 };
+ static const __DRIversion drm_expected = { 1, 5, 0 };
+
+ dri_interface = interface;
+
+ if ( ! driCheckDriDdxDrmVersions3( "R200",
+ dri_version, & dri_expected,
+ ddx_version, & ddx_expected,
+ drm_version, & drm_expected ) ) {
+ return NULL;
+ }
+
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &r200API);
+ if ( psp != NULL ) {
+ RADEONDRIPtr dri_priv = (RADEONDRIPtr) psp->pDevPriv;
+ *driver_modes = r200FillInModes( dri_priv->bpp,
+ (dri_priv->bpp == 16) ? 16 : 24,
+ (dri_priv->bpp == 16) ? 0 : 8,
+ (dri_priv->backOffset != dri_priv->depthOffset) );
+
+ /* Calling driInitExtensions here, with a NULL context pointer, does not actually
+ * enable the extensions. It just makes sure that all the dispatch offsets for all
+ * the extensions that *might* be enables are known. This is needed because the
+ * dispatch offsets need to be known when _mesa_context_create is called, but we can't
+ * enable the extensions until we have a context pointer.
+ *
+ * Hello chicken. Hello egg. How are you two today?
+ */
+ driInitExtensions( NULL, card_extensions, GL_FALSE );
+ driInitExtensions( NULL, blend_extensions, GL_FALSE );
+ driInitSingleExtension( NULL, ARB_vp_extension );
+ driInitSingleExtension( NULL, NV_vp_extension );
+ }
+
+ return (void *) psp;
+}
+
+
+/**
+ * Get information about previous buffer swaps.
+ */
+static int
+getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
+{
+ r200ContextPtr rmesa;
+
+ if ( (dPriv == NULL) || (dPriv->driContextPriv == NULL)
+ || (dPriv->driContextPriv->driverPrivate == NULL)
+ || (sInfo == NULL) ) {
+ return -1;
+ }
+
+ rmesa = (r200ContextPtr) dPriv->driContextPriv->driverPrivate;
+ sInfo->swap_count = rmesa->swap_count;
+ sInfo->swap_ust = rmesa->swap_ust;
+ sInfo->swap_missed_count = rmesa->swap_missed_count;
+
+ sInfo->swap_missed_usage = (sInfo->swap_missed_count != 0)
+ ? driCalculateSwapUsage( dPriv, 0, rmesa->swap_missed_ust )
+ : 0.0;
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_screen.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_screen.h
new file mode 100644
index 000000000..91b43cbd7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_screen.h
@@ -0,0 +1,106 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_screen.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R200_SCREEN_H__
+#define __R200_SCREEN_H__
+
+#include "xf86drm.h"
+#include "drm.h"
+#include "radeon_drm.h"
+#include "dri_util.h"
+#include "xmlconfig.h"
+
+typedef struct {
+ drm_handle_t handle; /* Handle to the DRM region */
+ drmSize size; /* Size of the DRM region */
+ drmAddress map; /* Mapping of the DRM region */
+} r200RegionRec, *r200RegionPtr;
+
+
+/* chipset features */
+#define R200_CHIPSET_TCL (1 << 0)
+#define R200_CHIPSET_REAL_R200 (1 << 1)
+#define R200_CHIPSET_YCBCR_BROKEN (1 << 2)
+
+
+#define R200_NR_TEX_HEAPS 2
+
+typedef struct {
+
+ int chipset;
+ int cpp;
+ int IsPCI; /* Current card is a PCI card */
+ int AGPMode;
+ unsigned int irq; /* IRQ number (0 means none) */
+
+ unsigned int fbLocation;
+ unsigned int frontOffset;
+ unsigned int frontPitch;
+ unsigned int backOffset;
+ unsigned int backPitch;
+
+ unsigned int depthOffset;
+ unsigned int depthPitch;
+
+ /* Shared texture data */
+ int numTexHeaps;
+ int texOffset[R200_NR_TEX_HEAPS];
+ int texSize[R200_NR_TEX_HEAPS];
+ int logTexGranularity[R200_NR_TEX_HEAPS];
+
+ r200RegionRec mmio;
+ r200RegionRec status;
+ r200RegionRec gartTextures;
+
+ drmBufMapPtr buffers;
+
+ __volatile__ int32_t *scratch;
+
+ __DRIscreenPrivate *driScreen;
+ unsigned int sarea_priv_offset;
+ unsigned int gart_buffer_offset; /* offset in card memory space */
+ unsigned int gart_texture_offset; /* offset in card memory space */
+ unsigned int gart_base;
+
+ GLboolean drmSupportsCubeMaps; /* need radeon kernel module >=1.7 */
+ GLboolean drmSupportsBlendColor; /* need radeon kernel module >= 1.11 */
+ GLboolean drmSupportsTriPerf; /* need radeon kernel module >= 1.16 */
+ GLboolean depthHasSurface;
+
+ /* Configuration cache with default values for all contexts */
+ driOptionCache optionCache;
+} r200ScreenRec, *r200ScreenPtr;
+
+#endif /* __R200_SCREEN_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_span.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_span.c
new file mode 100644
index 000000000..024e89461
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_span.c
@@ -0,0 +1,367 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_span.c,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "swrast/swrast.h"
+#include "colormac.h"
+
+#include "r200_context.h"
+#include "r200_ioctl.h"
+#include "r200_state.h"
+#include "r200_span.h"
+#include "r200_tex.h"
+
+#define DBG 0
+
+#define LOCAL_VARS \
+ r200ContextPtr rmesa = R200_CONTEXT(ctx); \
+ r200ScreenPtr r200Screen = rmesa->r200Screen; \
+ __DRIscreenPrivate *sPriv = rmesa->dri.screen; \
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable; \
+ GLuint pitch = r200Screen->frontPitch * r200Screen->cpp; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(sPriv->pFB + \
+ rmesa->state.color.drawOffset + \
+ (dPriv->x * r200Screen->cpp) + \
+ (dPriv->y * pitch)); \
+ char *read_buf = (char *)(sPriv->pFB + \
+ rmesa->state.pixel.readOffset + \
+ (dPriv->x * r200Screen->cpp) + \
+ (dPriv->y * pitch)); \
+ GLuint p; \
+ (void) read_buf; (void) buf; (void) p
+
+#define LOCAL_DEPTH_VARS \
+ r200ContextPtr rmesa = R200_CONTEXT(ctx); \
+ r200ScreenPtr r200Screen = rmesa->r200Screen; \
+ __DRIscreenPrivate *sPriv = rmesa->dri.screen; \
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable; \
+ GLuint height = dPriv->h; \
+ GLuint xo = dPriv->x; \
+ GLuint yo = dPriv->y; \
+ char *buf = (char *)(sPriv->pFB + r200Screen->depthOffset); \
+ (void) buf
+
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
+
+#define Y_FLIP( _y ) (height - _y - 1)
+
+#define HW_LOCK()
+
+#define HW_UNLOCK()
+
+
+
+/* ================================================================
+ * Color buffer
+ */
+
+/* 16 bit, RGB565 color spanline and pixel functions
+ */
+#define SPANTMP_PIXEL_FMT GL_RGB
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
+
+#define TAG(x) r200##x##_RGB565
+#define TAG2(x,y) r200##x##_RGB565##y
+#include "spantmp2.h"
+
+/* 32 bit, ARGB8888 color spanline and pixel functions
+ */
+#define SPANTMP_PIXEL_FMT GL_BGRA
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
+
+#define TAG(x) r200##x##_ARGB8888
+#define TAG2(x,y) r200##x##_ARGB8888##y
+#include "spantmp2.h"
+
+
+/* ================================================================
+ * Depth buffer
+ */
+
+/* The Radeon family has depth tiling on all the time, so we have to convert
+ * the x,y coordinates into the memory bus address (mba) in the same
+ * manner as the engine. In each case, the linear block address (ba)
+ * is calculated, and then wired with x and y to produce the final
+ * memory address.
+ * The chip will do address translation on its own if the surface registers
+ * are set up correctly. It is not quite enough to get it working with hyperz too...
+ */
+
+#define BIT(x,b) ((x & (1<<b))>>b)
+static GLuint r200_mba_z32( r200ContextPtr rmesa,
+ GLint x, GLint y )
+{
+ GLuint pitch = rmesa->r200Screen->frontPitch;
+ if (rmesa->r200Screen->depthHasSurface) {
+ return 4*(x + y*pitch);
+ }
+ else {
+ GLuint b = ((y & 0x7FF) >> 4) * ((pitch & 0xFFF) >> 5) + ((x & 0x7FF) >> 5);
+ GLuint a =
+ (BIT(x,0) << 2) |
+ (BIT(y,0) << 3) |
+ (BIT(x,1) << 4) |
+ (BIT(y,1) << 5) |
+ (BIT(x,3) << 6) |
+ (BIT(x,4) << 7) |
+ (BIT(x,2) << 8) |
+ (BIT(y,2) << 9) |
+ (BIT(y,3) << 10) |
+ (((pitch & 0x20) ? (b & 0x01) : ((b & 0x01) ^ (BIT(y,4)))) << 11) |
+ ((b >> 1) << 12);
+ return a;
+ }
+}
+
+static GLuint r200_mba_z16( r200ContextPtr rmesa, GLint x, GLint y )
+{
+ GLuint pitch = rmesa->r200Screen->frontPitch;
+ if (rmesa->r200Screen->depthHasSurface) {
+ return 2*(x + y*pitch);
+ }
+ else {
+ GLuint b = ((y & 0x7FF) >> 4) * ((pitch & 0xFFF) >> 6) + ((x & 0x7FF) >> 6);
+ GLuint a =
+ (BIT(x,0) << 1) |
+ (BIT(y,0) << 2) |
+ (BIT(x,1) << 3) |
+ (BIT(y,1) << 4) |
+ (BIT(x,2) << 5) |
+ (BIT(x,4) << 6) |
+ (BIT(x,5) << 7) |
+ (BIT(x,3) << 8) |
+ (BIT(y,2) << 9) |
+ (BIT(y,3) << 10) |
+ (((pitch & 0x40) ? (b & 0x01) : ((b & 0x01) ^ (BIT(y,4)))) << 11) |
+ ((b >> 1) << 12);
+ return a;
+ }
+}
+
+
+/* 16-bit depth buffer functions
+ */
+
+#define WRITE_DEPTH( _x, _y, d ) \
+ *(GLushort *)(buf + r200_mba_z16( rmesa, _x + xo, _y + yo )) = d;
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLushort *)(buf + r200_mba_z16( rmesa, _x + xo, _y + yo ));
+
+#define TAG(x) r200##x##_16
+#include "depthtmp.h"
+
+
+/* 24 bit depth, 8 bit stencil depthbuffer functions
+ */
+
+#define WRITE_DEPTH( _x, _y, d ) \
+do { \
+ GLuint offset = r200_mba_z32( rmesa, _x + xo, _y + yo ); \
+ GLuint tmp = *(GLuint *)(buf + offset); \
+ tmp &= 0xff000000; \
+ tmp |= ((d) & 0x00ffffff); \
+ *(GLuint *)(buf + offset) = tmp; \
+} while (0)
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLuint *)(buf + r200_mba_z32( rmesa, _x + xo, \
+ _y + yo )) & 0x00ffffff;
+
+#define TAG(x) r200##x##_24_8
+#include "depthtmp.h"
+
+
+/* ================================================================
+ * Stencil buffer
+ */
+
+/* 24 bit depth, 8 bit stencil depthbuffer functions
+ */
+#define WRITE_STENCIL( _x, _y, d ) \
+do { \
+ GLuint offset = r200_mba_z32( rmesa, _x + xo, _y + yo ); \
+ GLuint tmp = *(GLuint *)(buf + offset); \
+ tmp &= 0x00ffffff; \
+ tmp |= (((d) & 0xff) << 24); \
+ *(GLuint *)(buf + offset) = tmp; \
+} while (0)
+
+#define READ_STENCIL( d, _x, _y ) \
+do { \
+ GLuint offset = r200_mba_z32( rmesa, _x + xo, _y + yo ); \
+ GLuint tmp = *(GLuint *)(buf + offset); \
+ tmp &= 0xff000000; \
+ d = tmp >> 24; \
+} while (0)
+
+#define TAG(x) r200##x##_24_8
+#include "stenciltmp.h"
+
+
+/*
+ * This function is called to specify which buffer to read and write
+ * for software rasterization (swrast) fallbacks. This doesn't necessarily
+ * correspond to glDrawBuffer() or glReadBuffer() calls.
+ */
+static void r200SetBuffer( GLcontext *ctx,
+ GLframebuffer *colorBuffer,
+ GLuint bufferBit )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ switch ( bufferBit ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ if ( rmesa->doPageFlip && rmesa->sarea->pfCurrentPage == 1 ) {
+ rmesa->state.pixel.readOffset = rmesa->r200Screen->backOffset;
+ rmesa->state.pixel.readPitch = rmesa->r200Screen->backPitch;
+ rmesa->state.color.drawOffset = rmesa->r200Screen->backOffset;
+ rmesa->state.color.drawPitch = rmesa->r200Screen->backPitch;
+ } else {
+ rmesa->state.pixel.readOffset = rmesa->r200Screen->frontOffset;
+ rmesa->state.pixel.readPitch = rmesa->r200Screen->frontPitch;
+ rmesa->state.color.drawOffset = rmesa->r200Screen->frontOffset;
+ rmesa->state.color.drawPitch = rmesa->r200Screen->frontPitch;
+ }
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ if ( rmesa->doPageFlip && rmesa->sarea->pfCurrentPage == 1 ) {
+ rmesa->state.pixel.readOffset = rmesa->r200Screen->frontOffset;
+ rmesa->state.pixel.readPitch = rmesa->r200Screen->frontPitch;
+ rmesa->state.color.drawOffset = rmesa->r200Screen->frontOffset;
+ rmesa->state.color.drawPitch = rmesa->r200Screen->frontPitch;
+ } else {
+ rmesa->state.pixel.readOffset = rmesa->r200Screen->backOffset;
+ rmesa->state.pixel.readPitch = rmesa->r200Screen->backPitch;
+ rmesa->state.color.drawOffset = rmesa->r200Screen->backOffset;
+ rmesa->state.color.drawPitch = rmesa->r200Screen->backPitch;
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad bufferBit in %s", __FUNCTION__);
+ break;
+ }
+}
+
+/* Move locking out to get reasonable span performance (10x better
+ * than doing this in HW_LOCK above). WaitForIdle() is the main
+ * culprit.
+ */
+
+static void r200SpanRenderStart( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT( ctx );
+
+ R200_FIREVERTICES( rmesa );
+ LOCK_HARDWARE( rmesa );
+ r200WaitForIdleLocked( rmesa );
+
+ /* Read & rewrite the first pixel in the frame buffer. This should
+ * be a noop, right? In fact without this conform fails as reading
+ * from the framebuffer sometimes produces old results -- the
+ * on-card read cache gets mixed up and doesn't notice that the
+ * framebuffer has been updated.
+ *
+ * In the worst case this is buggy too as p might get the wrong
+ * value first time, so really need a hidden pixel somewhere for this.
+ */
+ {
+ int p;
+ volatile int *read_buf = (volatile int *)(rmesa->dri.screen->pFB +
+ rmesa->state.pixel.readOffset);
+ p = *read_buf;
+ *read_buf = p;
+ }
+}
+
+static void r200SpanRenderFinish( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT( ctx );
+ _swrast_flush( ctx );
+ UNLOCK_HARDWARE( rmesa );
+}
+
+void r200InitSpanFuncs( GLcontext *ctx )
+{
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetBuffer = r200SetBuffer;
+ swdd->SpanRenderStart = r200SpanRenderStart;
+ swdd->SpanRenderFinish = r200SpanRenderFinish;
+}
+
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+r200SetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ r200InitPointers_RGB565(&drb->Base);
+ }
+ else {
+ r200InitPointers_ARGB8888(&drb->Base);
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = r200ReadDepthSpan_16;
+ drb->Base.GetValues = r200ReadDepthPixels_16;
+ drb->Base.PutRow = r200WriteDepthSpan_16;
+ drb->Base.PutMonoRow = r200WriteMonoDepthSpan_16;
+ drb->Base.PutValues = r200WriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = r200ReadDepthSpan_24_8;
+ drb->Base.GetValues = r200ReadDepthPixels_24_8;
+ drb->Base.PutRow = r200WriteDepthSpan_24_8;
+ drb->Base.PutMonoRow = r200WriteMonoDepthSpan_24_8;
+ drb->Base.PutValues = r200WriteDepthPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = r200ReadStencilSpan_24_8;
+ drb->Base.GetValues = r200ReadStencilPixels_24_8;
+ drb->Base.PutRow = r200WriteStencilSpan_24_8;
+ drb->Base.PutMonoRow = r200WriteMonoStencilSpan_24_8;
+ drb->Base.PutValues = r200WriteStencilPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_span.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_span.h
new file mode 100644
index 000000000..8b9909559
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_span.h
@@ -0,0 +1,46 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_span.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R200_SPAN_H__
+#define __R200_SPAN_H__
+
+#include "drirenderbuffer.h"
+
+extern void r200InitSpanFuncs( GLcontext *ctx );
+
+extern void
+r200SetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_state.c
new file mode 100644
index 000000000..9a116f108
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_state.c
@@ -0,0 +1,2383 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "api_arrayelt.h"
+#include "enums.h"
+#include "colormac.h"
+#include "light.h"
+#include "buffers.h"
+
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+#include "swrast_setup/swrast_setup.h"
+
+
+#include "r200_context.h"
+#include "r200_ioctl.h"
+#include "r200_state.h"
+#include "r200_tcl.h"
+#include "r200_tex.h"
+#include "r200_swtcl.h"
+#include "r200_vtxfmt.h"
+
+
+/* =============================================================
+ * Alpha blending
+ */
+
+static void r200AlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ int pp_misc = rmesa->hw.ctx.cmd[CTX_PP_MISC];
+ GLubyte refByte;
+
+ CLAMPED_FLOAT_TO_UBYTE(refByte, ref);
+
+ R200_STATECHANGE( rmesa, ctx );
+
+ pp_misc &= ~(R200_ALPHA_TEST_OP_MASK | R200_REF_ALPHA_MASK);
+ pp_misc |= (refByte & R200_REF_ALPHA_MASK);
+
+ switch ( func ) {
+ case GL_NEVER:
+ pp_misc |= R200_ALPHA_TEST_FAIL;
+ break;
+ case GL_LESS:
+ pp_misc |= R200_ALPHA_TEST_LESS;
+ break;
+ case GL_EQUAL:
+ pp_misc |= R200_ALPHA_TEST_EQUAL;
+ break;
+ case GL_LEQUAL:
+ pp_misc |= R200_ALPHA_TEST_LEQUAL;
+ break;
+ case GL_GREATER:
+ pp_misc |= R200_ALPHA_TEST_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ pp_misc |= R200_ALPHA_TEST_NEQUAL;
+ break;
+ case GL_GEQUAL:
+ pp_misc |= R200_ALPHA_TEST_GEQUAL;
+ break;
+ case GL_ALWAYS:
+ pp_misc |= R200_ALPHA_TEST_PASS;
+ break;
+ }
+
+ rmesa->hw.ctx.cmd[CTX_PP_MISC] = pp_misc;
+}
+
+static void r200BlendColor( GLcontext *ctx, const GLfloat cf[4] )
+{
+ GLubyte color[4];
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ R200_STATECHANGE( rmesa, ctx );
+ CLAMPED_FLOAT_TO_UBYTE(color[0], cf[0]);
+ CLAMPED_FLOAT_TO_UBYTE(color[1], cf[1]);
+ CLAMPED_FLOAT_TO_UBYTE(color[2], cf[2]);
+ CLAMPED_FLOAT_TO_UBYTE(color[3], cf[3]);
+ if (rmesa->r200Screen->drmSupportsBlendColor)
+ rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCOLOR] = r200PackColor( 4, color[0], color[1], color[2], color[3] );
+}
+
+/**
+ * Calculate the hardware blend factor setting. This same function is used
+ * for source and destination of both alpha and RGB.
+ *
+ * \returns
+ * The hardware register value for the specified blend factor. This value
+ * will need to be shifted into the correct position for either source or
+ * destination factor.
+ *
+ * \todo
+ * Since the two cases where source and destination are handled differently
+ * are essentially error cases, they should never happen. Determine if these
+ * cases can be removed.
+ */
+static int blend_factor( GLenum factor, GLboolean is_src )
+{
+ int func;
+
+ switch ( factor ) {
+ case GL_ZERO:
+ func = R200_BLEND_GL_ZERO;
+ break;
+ case GL_ONE:
+ func = R200_BLEND_GL_ONE;
+ break;
+ case GL_DST_COLOR:
+ func = R200_BLEND_GL_DST_COLOR;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ func = R200_BLEND_GL_ONE_MINUS_DST_COLOR;
+ break;
+ case GL_SRC_COLOR:
+ func = R200_BLEND_GL_SRC_COLOR;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ func = R200_BLEND_GL_ONE_MINUS_SRC_COLOR;
+ break;
+ case GL_SRC_ALPHA:
+ func = R200_BLEND_GL_SRC_ALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ func = R200_BLEND_GL_ONE_MINUS_SRC_ALPHA;
+ break;
+ case GL_DST_ALPHA:
+ func = R200_BLEND_GL_DST_ALPHA;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ func = R200_BLEND_GL_ONE_MINUS_DST_ALPHA;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ func = (is_src) ? R200_BLEND_GL_SRC_ALPHA_SATURATE : R200_BLEND_GL_ZERO;
+ break;
+ case GL_CONSTANT_COLOR:
+ func = R200_BLEND_GL_CONST_COLOR;
+ break;
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ func = R200_BLEND_GL_ONE_MINUS_CONST_COLOR;
+ break;
+ case GL_CONSTANT_ALPHA:
+ func = R200_BLEND_GL_CONST_ALPHA;
+ break;
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ func = R200_BLEND_GL_ONE_MINUS_CONST_ALPHA;
+ break;
+ default:
+ func = (is_src) ? R200_BLEND_GL_ONE : R200_BLEND_GL_ZERO;
+ }
+ return func;
+}
+
+/**
+ * Sets both the blend equation and the blend function.
+ * This is done in a single
+ * function because some blend equations (i.e., \c GL_MIN and \c GL_MAX)
+ * change the interpretation of the blend function.
+ * Also, make sure that blend function and blend equation are set to their default
+ * value if color blending is not enabled, since at least blend equations GL_MIN
+ * and GL_FUNC_REVERSE_SUBTRACT will cause wrong results otherwise for
+ * unknown reasons.
+ */
+static void r200_set_blend_state( GLcontext * ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint cntl = rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &
+ ~(R200_ROP_ENABLE | R200_ALPHA_BLEND_ENABLE | R200_SEPARATE_ALPHA_ENABLE);
+
+ int func = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
+ (R200_BLEND_GL_ZERO << R200_DST_BLEND_SHIFT);
+ int eqn = R200_COMB_FCN_ADD_CLAMP;
+ int funcA = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
+ (R200_BLEND_GL_ZERO << R200_DST_BLEND_SHIFT);
+ int eqnA = R200_COMB_FCN_ADD_CLAMP;
+
+ R200_STATECHANGE( rmesa, ctx );
+
+ if (rmesa->r200Screen->drmSupportsBlendColor) {
+ if (ctx->Color._LogicOpEnabled) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] = cntl | R200_ROP_ENABLE;
+ rmesa->hw.ctx.cmd[CTX_RB3D_ABLENDCNTL] = eqn | func;
+ rmesa->hw.ctx.cmd[CTX_RB3D_CBLENDCNTL] = eqn | func;
+ return;
+ } else if (ctx->Color.BlendEnabled) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] = cntl | R200_ALPHA_BLEND_ENABLE | R200_SEPARATE_ALPHA_ENABLE;
+ }
+ else {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] = cntl;
+ rmesa->hw.ctx.cmd[CTX_RB3D_ABLENDCNTL] = eqn | func;
+ rmesa->hw.ctx.cmd[CTX_RB3D_CBLENDCNTL] = eqn | func;
+ return;
+ }
+ }
+ else {
+ if (ctx->Color._LogicOpEnabled) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] = cntl | R200_ROP_ENABLE;
+ rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] = eqn | func;
+ return;
+ } else if (ctx->Color.BlendEnabled) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] = cntl | R200_ALPHA_BLEND_ENABLE;
+ }
+ else {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] = cntl;
+ rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] = eqn | func;
+ return;
+ }
+ }
+
+ func = (blend_factor( ctx->Color.BlendSrcRGB, GL_TRUE ) << R200_SRC_BLEND_SHIFT) |
+ (blend_factor( ctx->Color.BlendDstRGB, GL_FALSE ) << R200_DST_BLEND_SHIFT);
+
+ switch(ctx->Color.BlendEquationRGB) {
+ case GL_FUNC_ADD:
+ eqn = R200_COMB_FCN_ADD_CLAMP;
+ break;
+
+ case GL_FUNC_SUBTRACT:
+ eqn = R200_COMB_FCN_SUB_CLAMP;
+ break;
+
+ case GL_FUNC_REVERSE_SUBTRACT:
+ eqn = R200_COMB_FCN_RSUB_CLAMP;
+ break;
+
+ case GL_MIN:
+ eqn = R200_COMB_FCN_MIN;
+ func = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
+ (R200_BLEND_GL_ONE << R200_DST_BLEND_SHIFT);
+ break;
+
+ case GL_MAX:
+ eqn = R200_COMB_FCN_MAX;
+ func = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
+ (R200_BLEND_GL_ONE << R200_DST_BLEND_SHIFT);
+ break;
+
+ default:
+ fprintf( stderr, "[%s:%u] Invalid RGB blend equation (0x%04x).\n",
+ __FUNCTION__, __LINE__, ctx->Color.BlendEquationRGB );
+ return;
+ }
+
+ if (!rmesa->r200Screen->drmSupportsBlendColor) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] = eqn | func;
+ return;
+ }
+
+ funcA = (blend_factor( ctx->Color.BlendSrcA, GL_TRUE ) << R200_SRC_BLEND_SHIFT) |
+ (blend_factor( ctx->Color.BlendDstA, GL_FALSE ) << R200_DST_BLEND_SHIFT);
+
+ switch(ctx->Color.BlendEquationA) {
+ case GL_FUNC_ADD:
+ eqnA = R200_COMB_FCN_ADD_CLAMP;
+ break;
+
+ case GL_FUNC_SUBTRACT:
+ eqnA = R200_COMB_FCN_SUB_CLAMP;
+ break;
+
+ case GL_FUNC_REVERSE_SUBTRACT:
+ eqnA = R200_COMB_FCN_RSUB_CLAMP;
+ break;
+
+ case GL_MIN:
+ eqnA = R200_COMB_FCN_MIN;
+ funcA = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
+ (R200_BLEND_GL_ONE << R200_DST_BLEND_SHIFT);
+ break;
+
+ case GL_MAX:
+ eqnA = R200_COMB_FCN_MAX;
+ funcA = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
+ (R200_BLEND_GL_ONE << R200_DST_BLEND_SHIFT);
+ break;
+
+ default:
+ fprintf( stderr, "[%s:%u] Invalid A blend equation (0x%04x).\n",
+ __FUNCTION__, __LINE__, ctx->Color.BlendEquationA );
+ return;
+ }
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_ABLENDCNTL] = eqnA | funcA;
+ rmesa->hw.ctx.cmd[CTX_RB3D_CBLENDCNTL] = eqn | func;
+
+}
+
+static void r200BlendEquationSeparate( GLcontext *ctx,
+ GLenum modeRGB, GLenum modeA )
+{
+ r200_set_blend_state( ctx );
+}
+
+static void r200BlendFuncSeparate( GLcontext *ctx,
+ GLenum sfactorRGB, GLenum dfactorRGB,
+ GLenum sfactorA, GLenum dfactorA )
+{
+ r200_set_blend_state( ctx );
+}
+
+
+/* =============================================================
+ * Depth testing
+ */
+
+static void r200DepthFunc( GLcontext *ctx, GLenum func )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ R200_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] &= ~R200_Z_TEST_MASK;
+
+ switch ( ctx->Depth.Func ) {
+ case GL_NEVER:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_Z_TEST_NEVER;
+ break;
+ case GL_LESS:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_Z_TEST_LESS;
+ break;
+ case GL_EQUAL:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_Z_TEST_EQUAL;
+ break;
+ case GL_LEQUAL:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_Z_TEST_LEQUAL;
+ break;
+ case GL_GREATER:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_Z_TEST_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_Z_TEST_NEQUAL;
+ break;
+ case GL_GEQUAL:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_Z_TEST_GEQUAL;
+ break;
+ case GL_ALWAYS:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_Z_TEST_ALWAYS;
+ break;
+ }
+}
+
+static void r200ClearDepth( GLcontext *ctx, GLclampd d )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint format = (rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] &
+ R200_DEPTH_FORMAT_MASK);
+
+ switch ( format ) {
+ case R200_DEPTH_FORMAT_16BIT_INT_Z:
+ rmesa->state.depth.clear = d * 0x0000ffff;
+ break;
+ case R200_DEPTH_FORMAT_24BIT_INT_Z:
+ rmesa->state.depth.clear = d * 0x00ffffff;
+ break;
+ }
+}
+
+static void r200DepthMask( GLcontext *ctx, GLboolean flag )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ R200_STATECHANGE( rmesa, ctx );
+
+ if ( ctx->Depth.Mask ) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_Z_WRITE_ENABLE;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] &= ~R200_Z_WRITE_ENABLE;
+ }
+}
+
+
+/* =============================================================
+ * Fog
+ */
+
+
+static void r200Fogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ union { int i; float f; } c, d;
+ GLchan col[4];
+ GLuint i;
+
+ c.i = rmesa->hw.fog.cmd[FOG_C];
+ d.i = rmesa->hw.fog.cmd[FOG_D];
+
+ switch (pname) {
+ case GL_FOG_MODE:
+ if (!ctx->Fog.Enabled)
+ return;
+ R200_STATECHANGE(rmesa, tcl);
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~R200_TCL_FOG_MASK;
+ switch (ctx->Fog.Mode) {
+ case GL_LINEAR:
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= R200_TCL_FOG_LINEAR;
+ if (ctx->Fog.Start == ctx->Fog.End) {
+ c.f = 1.0F;
+ d.f = 1.0F;
+ }
+ else {
+ c.f = ctx->Fog.End/(ctx->Fog.End-ctx->Fog.Start);
+ d.f = -1.0/(ctx->Fog.End-ctx->Fog.Start);
+ }
+ break;
+ case GL_EXP:
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= R200_TCL_FOG_EXP;
+ c.f = 0.0;
+ d.f = -ctx->Fog.Density;
+ break;
+ case GL_EXP2:
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= R200_TCL_FOG_EXP2;
+ c.f = 0.0;
+ d.f = -(ctx->Fog.Density * ctx->Fog.Density);
+ break;
+ default:
+ return;
+ }
+ break;
+ case GL_FOG_DENSITY:
+ switch (ctx->Fog.Mode) {
+ case GL_EXP:
+ c.f = 0.0;
+ d.f = -ctx->Fog.Density;
+ break;
+ case GL_EXP2:
+ c.f = 0.0;
+ d.f = -(ctx->Fog.Density * ctx->Fog.Density);
+ break;
+ default:
+ break;
+ }
+ break;
+ case GL_FOG_START:
+ case GL_FOG_END:
+ if (ctx->Fog.Mode == GL_LINEAR) {
+ if (ctx->Fog.Start == ctx->Fog.End) {
+ c.f = 1.0F;
+ d.f = 1.0F;
+ } else {
+ c.f = ctx->Fog.End/(ctx->Fog.End-ctx->Fog.Start);
+ d.f = -1.0/(ctx->Fog.End-ctx->Fog.Start);
+ }
+ }
+ break;
+ case GL_FOG_COLOR:
+ R200_STATECHANGE( rmesa, ctx );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( col, ctx->Fog.Color );
+ i = r200PackColor( 4, col[0], col[1], col[2], 0 );
+ rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] &= ~R200_FOG_COLOR_MASK;
+ rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] |= i;
+ break;
+ case GL_FOG_COORD_SRC: {
+ GLuint fmt_0 = rmesa->hw.vtx.cmd[VTX_VTXFMT_0];
+ GLuint out_0 = rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0];
+ GLuint fog = rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR];
+
+ fog &= ~R200_FOG_USE_MASK;
+ if ( ctx->Fog.FogCoordinateSource == GL_FOG_COORD ) {
+ fog |= R200_FOG_USE_VTX_FOG;
+ fmt_0 |= R200_VTX_DISCRETE_FOG;
+ out_0 |= R200_VTX_DISCRETE_FOG;
+ }
+ else {
+ fog |= R200_FOG_USE_SPEC_ALPHA;
+ fmt_0 &= ~R200_VTX_DISCRETE_FOG;
+ out_0 &= ~R200_VTX_DISCRETE_FOG;
+ }
+
+ if ( fog != rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] ) {
+ R200_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] = fog;
+ }
+
+ if ( (fmt_0 != rmesa->hw.vtx.cmd[VTX_VTXFMT_0])
+ || (out_0 != rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0])) {
+ R200_STATECHANGE( rmesa, vtx );
+ rmesa->hw.vtx.cmd[VTX_VTXFMT_0] = fmt_0;
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] = out_0;
+ }
+
+ break;
+ }
+ default:
+ return;
+ }
+
+ if (c.i != rmesa->hw.fog.cmd[FOG_C] || d.i != rmesa->hw.fog.cmd[FOG_D]) {
+ R200_STATECHANGE( rmesa, fog );
+ rmesa->hw.fog.cmd[FOG_C] = c.i;
+ rmesa->hw.fog.cmd[FOG_D] = d.i;
+ }
+}
+
+
+/* =============================================================
+ * Scissoring
+ */
+
+
+static GLboolean intersect_rect( drm_clip_rect_t *out,
+ drm_clip_rect_t *a,
+ drm_clip_rect_t *b )
+{
+ *out = *a;
+ if ( b->x1 > out->x1 ) out->x1 = b->x1;
+ if ( b->y1 > out->y1 ) out->y1 = b->y1;
+ if ( b->x2 < out->x2 ) out->x2 = b->x2;
+ if ( b->y2 < out->y2 ) out->y2 = b->y2;
+ if ( out->x1 >= out->x2 ) return GL_FALSE;
+ if ( out->y1 >= out->y2 ) return GL_FALSE;
+ return GL_TRUE;
+}
+
+
+void r200RecalcScissorRects( r200ContextPtr rmesa )
+{
+ drm_clip_rect_t *out;
+ int i;
+
+ /* Grow cliprect store?
+ */
+ if (rmesa->state.scissor.numAllocedClipRects < rmesa->numClipRects) {
+ while (rmesa->state.scissor.numAllocedClipRects < rmesa->numClipRects) {
+ rmesa->state.scissor.numAllocedClipRects += 1; /* zero case */
+ rmesa->state.scissor.numAllocedClipRects *= 2;
+ }
+
+ if (rmesa->state.scissor.pClipRects)
+ FREE(rmesa->state.scissor.pClipRects);
+
+ rmesa->state.scissor.pClipRects =
+ MALLOC( rmesa->state.scissor.numAllocedClipRects *
+ sizeof(drm_clip_rect_t) );
+
+ if ( rmesa->state.scissor.pClipRects == NULL ) {
+ rmesa->state.scissor.numAllocedClipRects = 0;
+ return;
+ }
+ }
+
+ out = rmesa->state.scissor.pClipRects;
+ rmesa->state.scissor.numClipRects = 0;
+
+ for ( i = 0 ; i < rmesa->numClipRects ; i++ ) {
+ if ( intersect_rect( out,
+ &rmesa->pClipRects[i],
+ &rmesa->state.scissor.rect ) ) {
+ rmesa->state.scissor.numClipRects++;
+ out++;
+ }
+ }
+}
+
+
+static void r200UpdateScissor( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if ( rmesa->dri.drawable ) {
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+
+ int x = ctx->Scissor.X;
+ int y = dPriv->h - ctx->Scissor.Y - ctx->Scissor.Height;
+ int w = ctx->Scissor.X + ctx->Scissor.Width - 1;
+ int h = dPriv->h - ctx->Scissor.Y - 1;
+
+ rmesa->state.scissor.rect.x1 = x + dPriv->x;
+ rmesa->state.scissor.rect.y1 = y + dPriv->y;
+ rmesa->state.scissor.rect.x2 = w + dPriv->x + 1;
+ rmesa->state.scissor.rect.y2 = h + dPriv->y + 1;
+
+ r200RecalcScissorRects( rmesa );
+ }
+}
+
+
+static void r200Scissor( GLcontext *ctx,
+ GLint x, GLint y, GLsizei w, GLsizei h )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if ( ctx->Scissor.Enabled ) {
+ R200_FIREVERTICES( rmesa ); /* don't pipeline cliprect changes */
+ r200UpdateScissor( ctx );
+ }
+
+}
+
+
+/* =============================================================
+ * Culling
+ */
+
+static void r200CullFace( GLcontext *ctx, GLenum unused )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint s = rmesa->hw.set.cmd[SET_SE_CNTL];
+ GLuint t = rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL];
+
+ s |= R200_FFACE_SOLID | R200_BFACE_SOLID;
+ t &= ~(R200_CULL_FRONT | R200_CULL_BACK);
+
+ if ( ctx->Polygon.CullFlag ) {
+ switch ( ctx->Polygon.CullFaceMode ) {
+ case GL_FRONT:
+ s &= ~R200_FFACE_SOLID;
+ t |= R200_CULL_FRONT;
+ break;
+ case GL_BACK:
+ s &= ~R200_BFACE_SOLID;
+ t |= R200_CULL_BACK;
+ break;
+ case GL_FRONT_AND_BACK:
+ s &= ~(R200_FFACE_SOLID | R200_BFACE_SOLID);
+ t |= (R200_CULL_FRONT | R200_CULL_BACK);
+ break;
+ }
+ }
+
+ if ( rmesa->hw.set.cmd[SET_SE_CNTL] != s ) {
+ R200_STATECHANGE(rmesa, set );
+ rmesa->hw.set.cmd[SET_SE_CNTL] = s;
+ }
+
+ if ( rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] != t ) {
+ R200_STATECHANGE(rmesa, tcl );
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] = t;
+ }
+}
+
+static void r200FrontFace( GLcontext *ctx, GLenum mode )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ R200_STATECHANGE( rmesa, set );
+ rmesa->hw.set.cmd[SET_SE_CNTL] &= ~R200_FFACE_CULL_DIR_MASK;
+
+ R200_STATECHANGE( rmesa, tcl );
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~R200_CULL_FRONT_IS_CCW;
+
+ switch ( mode ) {
+ case GL_CW:
+ rmesa->hw.set.cmd[SET_SE_CNTL] |= R200_FFACE_CULL_CW;
+ break;
+ case GL_CCW:
+ rmesa->hw.set.cmd[SET_SE_CNTL] |= R200_FFACE_CULL_CCW;
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= R200_CULL_FRONT_IS_CCW;
+ break;
+ }
+}
+
+/* =============================================================
+ * Point state
+ */
+static void r200PointSize( GLcontext *ctx, GLfloat size )
+{
+ if (0) fprintf(stderr, "%s: %f\n", __FUNCTION__, size );
+}
+
+/* =============================================================
+ * Line state
+ */
+static void r200LineWidth( GLcontext *ctx, GLfloat widthf )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ R200_STATECHANGE( rmesa, lin );
+ R200_STATECHANGE( rmesa, set );
+
+ /* Line width is stored in U6.4 format.
+ */
+ rmesa->hw.lin.cmd[LIN_SE_LINE_WIDTH] &= ~0xffff;
+ rmesa->hw.lin.cmd[LIN_SE_LINE_WIDTH] |= (GLuint)(ctx->Line._Width * 16.0);
+
+ if ( widthf > 1.0 ) {
+ rmesa->hw.set.cmd[SET_SE_CNTL] |= R200_WIDELINE_ENABLE;
+ } else {
+ rmesa->hw.set.cmd[SET_SE_CNTL] &= ~R200_WIDELINE_ENABLE;
+ }
+}
+
+static void r200LineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ R200_STATECHANGE( rmesa, lin );
+ rmesa->hw.lin.cmd[LIN_RE_LINE_PATTERN] =
+ ((((GLuint)factor & 0xff) << 16) | ((GLuint)pattern));
+}
+
+
+/* =============================================================
+ * Masks
+ */
+static void r200ColorMask( GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint mask = r200PackColor( rmesa->r200Screen->cpp,
+ ctx->Color.ColorMask[RCOMP],
+ ctx->Color.ColorMask[GCOMP],
+ ctx->Color.ColorMask[BCOMP],
+ ctx->Color.ColorMask[ACOMP] );
+
+ GLuint flag = rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] & ~R200_PLANE_MASK_ENABLE;
+
+ if (!(r && g && b && a))
+ flag |= R200_PLANE_MASK_ENABLE;
+
+ if ( rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] != flag ) {
+ R200_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] = flag;
+ }
+
+ if ( rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK] != mask ) {
+ R200_STATECHANGE( rmesa, msk );
+ rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK] = mask;
+ }
+}
+
+
+/* =============================================================
+ * Polygon state
+ */
+
+static void r200PolygonOffset( GLcontext *ctx,
+ GLfloat factor, GLfloat units )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat constant = units * rmesa->state.depth.scale;
+
+/* factor *= 2; */
+/* constant *= 2; */
+
+/* fprintf(stderr, "%s f:%f u:%f\n", __FUNCTION__, factor, constant); */
+
+ R200_STATECHANGE( rmesa, zbs );
+ rmesa->hw.zbs.cmd[ZBS_SE_ZBIAS_FACTOR] = *(GLuint *)&factor;
+ rmesa->hw.zbs.cmd[ZBS_SE_ZBIAS_CONSTANT] = *(GLuint *)&constant;
+}
+
+static void r200PolygonStipple( GLcontext *ctx, const GLubyte *mask )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint i;
+ drm_radeon_stipple_t stipple;
+
+ /* Must flip pattern upside down.
+ */
+ for ( i = 0 ; i < 32 ; i++ ) {
+ rmesa->state.stipple.mask[31 - i] = ((GLuint *) mask)[i];
+ }
+
+ /* TODO: push this into cmd mechanism
+ */
+ R200_FIREVERTICES( rmesa );
+ LOCK_HARDWARE( rmesa );
+
+ /* FIXME: Use window x,y offsets into stipple RAM.
+ */
+ stipple.mask = rmesa->state.stipple.mask;
+ drmCommandWrite( rmesa->dri.fd, DRM_RADEON_STIPPLE,
+ &stipple, sizeof(stipple) );
+ UNLOCK_HARDWARE( rmesa );
+}
+
+static void r200PolygonMode( GLcontext *ctx, GLenum face, GLenum mode )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLboolean flag = (ctx->_TriangleCaps & DD_TRI_UNFILLED) != 0;
+
+ /* Can't generally do unfilled via tcl, but some good special
+ * cases work.
+ */
+ TCL_FALLBACK( ctx, R200_TCL_FALLBACK_UNFILLED, flag);
+ if (rmesa->TclFallback) {
+ r200ChooseRenderState( ctx );
+ r200ChooseVertexState( ctx );
+ }
+}
+
+
+/* =============================================================
+ * Rendering attributes
+ *
+ * We really don't want to recalculate all this every time we bind a
+ * texture. These things shouldn't change all that often, so it makes
+ * sense to break them out of the core texture state update routines.
+ */
+
+/* Examine lighting and texture state to determine if separate specular
+ * should be enabled.
+ */
+static void r200UpdateSpecular( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ u_int32_t p = rmesa->hw.ctx.cmd[CTX_PP_CNTL];
+
+ R200_STATECHANGE( rmesa, tcl );
+ R200_STATECHANGE( rmesa, vtx );
+
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] &= ~(3<<R200_VTX_COLOR_0_SHIFT);
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] &= ~(3<<R200_VTX_COLOR_1_SHIFT);
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] &= ~R200_OUTPUT_COLOR_0;
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] &= ~R200_OUTPUT_COLOR_1;
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] &= ~R200_LIGHTING_ENABLE;
+
+ p &= ~R200_SPECULAR_ENABLE;
+
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] |= R200_DIFFUSE_SPECULAR_COMBINE;
+
+
+ if (ctx->Light.Enabled &&
+ ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) {
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] |=
+ ((R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT) |
+ (R200_VTX_FP_RGBA << R200_VTX_COLOR_1_SHIFT));
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] |= R200_OUTPUT_COLOR_0;
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] |= R200_OUTPUT_COLOR_1;
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] |= R200_LIGHTING_ENABLE;
+ p |= R200_SPECULAR_ENABLE;
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] &=
+ ~R200_DIFFUSE_SPECULAR_COMBINE;
+ }
+ else if (ctx->Light.Enabled) {
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] |=
+ ((R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT));
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] |= R200_OUTPUT_COLOR_0;
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] |= R200_LIGHTING_ENABLE;
+ } else if (ctx->Fog.ColorSumEnabled ) {
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] |=
+ ((R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT) |
+ (R200_VTX_FP_RGBA << R200_VTX_COLOR_1_SHIFT));
+ p |= R200_SPECULAR_ENABLE;
+ } else {
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] |=
+ ((R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT));
+ }
+
+ if (ctx->Fog.Enabled) {
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] |=
+ ((R200_VTX_FP_RGBA << R200_VTX_COLOR_1_SHIFT));
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] |= R200_OUTPUT_COLOR_1;
+ }
+
+ if ( rmesa->hw.ctx.cmd[CTX_PP_CNTL] != p ) {
+ R200_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] = p;
+ }
+
+ /* Update vertex/render formats
+ */
+ if (rmesa->TclFallback) {
+ r200ChooseRenderState( ctx );
+ r200ChooseVertexState( ctx );
+ }
+}
+
+
+/* =============================================================
+ * Materials
+ */
+
+
+/* Update on colormaterial, material emmissive/ambient,
+ * lightmodel.globalambient
+ */
+static void update_global_ambient( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ float *fcmd = (float *)R200_DB_STATE( glt );
+
+ /* Need to do more if both emmissive & ambient are PREMULT:
+ * I believe this is not nessary when using source_material. This condition thus
+ * will never happen currently, and the function has no dependencies on materials now
+ */
+ if ((rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_1] &
+ ((3 << R200_FRONT_EMISSIVE_SOURCE_SHIFT) |
+ (3 << R200_FRONT_AMBIENT_SOURCE_SHIFT))) == 0)
+ {
+ COPY_3V( &fcmd[GLT_RED],
+ ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_EMISSION]);
+ ACC_SCALE_3V( &fcmd[GLT_RED],
+ ctx->Light.Model.Ambient,
+ ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_AMBIENT]);
+ }
+ else
+ {
+ COPY_3V( &fcmd[GLT_RED], ctx->Light.Model.Ambient );
+ }
+
+ R200_DB_STATECHANGE(rmesa, &rmesa->hw.glt);
+}
+
+/* Update on change to
+ * - light[p].colors
+ * - light[p].enabled
+ */
+static void update_light_colors( GLcontext *ctx, GLuint p )
+{
+ struct gl_light *l = &ctx->Light.Light[p];
+
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ if (l->Enabled) {
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ float *fcmd = (float *)R200_DB_STATE( lit[p] );
+
+ COPY_4V( &fcmd[LIT_AMBIENT_RED], l->Ambient );
+ COPY_4V( &fcmd[LIT_DIFFUSE_RED], l->Diffuse );
+ COPY_4V( &fcmd[LIT_SPECULAR_RED], l->Specular );
+
+ R200_DB_STATECHANGE( rmesa, &rmesa->hw.lit[p] );
+ }
+}
+
+static void r200ColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint light_model_ctl1 = rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_1];
+ light_model_ctl1 &= ~((0xf << R200_FRONT_EMISSIVE_SOURCE_SHIFT) |
+ (0xf << R200_FRONT_AMBIENT_SOURCE_SHIFT) |
+ (0xf << R200_FRONT_DIFFUSE_SOURCE_SHIFT) |
+ (0xf << R200_FRONT_SPECULAR_SOURCE_SHIFT) |
+ (0xf << R200_BACK_EMISSIVE_SOURCE_SHIFT) |
+ (0xf << R200_BACK_AMBIENT_SOURCE_SHIFT) |
+ (0xf << R200_BACK_DIFFUSE_SOURCE_SHIFT) |
+ (0xf << R200_BACK_SPECULAR_SOURCE_SHIFT));
+
+ if (ctx->Light.ColorMaterialEnabled) {
+ GLuint mask = ctx->Light.ColorMaterialBitmask;
+
+ if (mask & MAT_BIT_FRONT_EMISSION) {
+ light_model_ctl1 |= (R200_LM1_SOURCE_VERTEX_COLOR_0 <<
+ R200_FRONT_EMISSIVE_SOURCE_SHIFT);
+ }
+ else
+ light_model_ctl1 |= (R200_LM1_SOURCE_MATERIAL_0 <<
+ R200_FRONT_EMISSIVE_SOURCE_SHIFT);
+
+ if (mask & MAT_BIT_FRONT_AMBIENT) {
+ light_model_ctl1 |= (R200_LM1_SOURCE_VERTEX_COLOR_0 <<
+ R200_FRONT_AMBIENT_SOURCE_SHIFT);
+ }
+ else
+ light_model_ctl1 |= (R200_LM1_SOURCE_MATERIAL_0 <<
+ R200_FRONT_AMBIENT_SOURCE_SHIFT);
+
+ if (mask & MAT_BIT_FRONT_DIFFUSE) {
+ light_model_ctl1 |= (R200_LM1_SOURCE_VERTEX_COLOR_0 <<
+ R200_FRONT_DIFFUSE_SOURCE_SHIFT);
+ }
+ else
+ light_model_ctl1 |= (R200_LM1_SOURCE_MATERIAL_0 <<
+ R200_FRONT_DIFFUSE_SOURCE_SHIFT);
+
+ if (mask & MAT_BIT_FRONT_SPECULAR) {
+ light_model_ctl1 |= (R200_LM1_SOURCE_VERTEX_COLOR_0 <<
+ R200_FRONT_SPECULAR_SOURCE_SHIFT);
+ }
+ else {
+ light_model_ctl1 |= (R200_LM1_SOURCE_MATERIAL_0 <<
+ R200_FRONT_SPECULAR_SOURCE_SHIFT);
+ }
+
+ if (mask & MAT_BIT_BACK_EMISSION) {
+ light_model_ctl1 |= (R200_LM1_SOURCE_VERTEX_COLOR_0 <<
+ R200_BACK_EMISSIVE_SOURCE_SHIFT);
+ }
+
+ else light_model_ctl1 |= (R200_LM1_SOURCE_MATERIAL_1 <<
+ R200_BACK_EMISSIVE_SOURCE_SHIFT);
+
+ if (mask & MAT_BIT_BACK_AMBIENT) {
+ light_model_ctl1 |= (R200_LM1_SOURCE_VERTEX_COLOR_0 <<
+ R200_BACK_AMBIENT_SOURCE_SHIFT);
+ }
+ else light_model_ctl1 |= (R200_LM1_SOURCE_MATERIAL_1 <<
+ R200_BACK_AMBIENT_SOURCE_SHIFT);
+
+ if (mask & MAT_BIT_BACK_DIFFUSE) {
+ light_model_ctl1 |= (R200_LM1_SOURCE_VERTEX_COLOR_0 <<
+ R200_BACK_DIFFUSE_SOURCE_SHIFT);
+ }
+ else light_model_ctl1 |= (R200_LM1_SOURCE_MATERIAL_1 <<
+ R200_BACK_DIFFUSE_SOURCE_SHIFT);
+
+ if (mask & MAT_BIT_BACK_SPECULAR) {
+ light_model_ctl1 |= (R200_LM1_SOURCE_VERTEX_COLOR_0 <<
+ R200_BACK_SPECULAR_SOURCE_SHIFT);
+ }
+ else {
+ light_model_ctl1 |= (R200_LM1_SOURCE_MATERIAL_1 <<
+ R200_BACK_SPECULAR_SOURCE_SHIFT);
+ }
+ }
+ else {
+ /* Default to SOURCE_MATERIAL:
+ */
+ light_model_ctl1 |=
+ (R200_LM1_SOURCE_MATERIAL_0 << R200_FRONT_EMISSIVE_SOURCE_SHIFT) |
+ (R200_LM1_SOURCE_MATERIAL_0 << R200_FRONT_AMBIENT_SOURCE_SHIFT) |
+ (R200_LM1_SOURCE_MATERIAL_0 << R200_FRONT_DIFFUSE_SOURCE_SHIFT) |
+ (R200_LM1_SOURCE_MATERIAL_0 << R200_FRONT_SPECULAR_SOURCE_SHIFT) |
+ (R200_LM1_SOURCE_MATERIAL_1 << R200_BACK_EMISSIVE_SOURCE_SHIFT) |
+ (R200_LM1_SOURCE_MATERIAL_1 << R200_BACK_AMBIENT_SOURCE_SHIFT) |
+ (R200_LM1_SOURCE_MATERIAL_1 << R200_BACK_DIFFUSE_SOURCE_SHIFT) |
+ (R200_LM1_SOURCE_MATERIAL_1 << R200_BACK_SPECULAR_SOURCE_SHIFT);
+ }
+
+ if (light_model_ctl1 != rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_1]) {
+ R200_STATECHANGE( rmesa, tcl );
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_1] = light_model_ctl1;
+ }
+
+
+}
+
+void r200UpdateMaterial( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
+ GLfloat *fcmd = (GLfloat *)R200_DB_STATE( mtl[0] );
+ GLfloat *fcmd2 = (GLfloat *)R200_DB_STATE( mtl[1] );
+ GLuint mask = ~0;
+
+ /* Might be possible and faster to update everything unconditionally? */
+ if (ctx->Light.ColorMaterialEnabled)
+ mask &= ~ctx->Light.ColorMaterialBitmask;
+
+ if (R200_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (mask & MAT_BIT_FRONT_EMISSION) {
+ fcmd[MTL_EMMISSIVE_RED] = mat[MAT_ATTRIB_FRONT_EMISSION][0];
+ fcmd[MTL_EMMISSIVE_GREEN] = mat[MAT_ATTRIB_FRONT_EMISSION][1];
+ fcmd[MTL_EMMISSIVE_BLUE] = mat[MAT_ATTRIB_FRONT_EMISSION][2];
+ fcmd[MTL_EMMISSIVE_ALPHA] = mat[MAT_ATTRIB_FRONT_EMISSION][3];
+ }
+ if (mask & MAT_BIT_FRONT_AMBIENT) {
+ fcmd[MTL_AMBIENT_RED] = mat[MAT_ATTRIB_FRONT_AMBIENT][0];
+ fcmd[MTL_AMBIENT_GREEN] = mat[MAT_ATTRIB_FRONT_AMBIENT][1];
+ fcmd[MTL_AMBIENT_BLUE] = mat[MAT_ATTRIB_FRONT_AMBIENT][2];
+ fcmd[MTL_AMBIENT_ALPHA] = mat[MAT_ATTRIB_FRONT_AMBIENT][3];
+ }
+ if (mask & MAT_BIT_FRONT_DIFFUSE) {
+ fcmd[MTL_DIFFUSE_RED] = mat[MAT_ATTRIB_FRONT_DIFFUSE][0];
+ fcmd[MTL_DIFFUSE_GREEN] = mat[MAT_ATTRIB_FRONT_DIFFUSE][1];
+ fcmd[MTL_DIFFUSE_BLUE] = mat[MAT_ATTRIB_FRONT_DIFFUSE][2];
+ fcmd[MTL_DIFFUSE_ALPHA] = mat[MAT_ATTRIB_FRONT_DIFFUSE][3];
+ }
+ if (mask & MAT_BIT_FRONT_SPECULAR) {
+ fcmd[MTL_SPECULAR_RED] = mat[MAT_ATTRIB_FRONT_SPECULAR][0];
+ fcmd[MTL_SPECULAR_GREEN] = mat[MAT_ATTRIB_FRONT_SPECULAR][1];
+ fcmd[MTL_SPECULAR_BLUE] = mat[MAT_ATTRIB_FRONT_SPECULAR][2];
+ fcmd[MTL_SPECULAR_ALPHA] = mat[MAT_ATTRIB_FRONT_SPECULAR][3];
+ }
+ if (mask & MAT_BIT_FRONT_SHININESS) {
+ fcmd[MTL_SHININESS] = mat[MAT_ATTRIB_FRONT_SHININESS][0];
+ }
+
+ if (mask & MAT_BIT_BACK_EMISSION) {
+ fcmd2[MTL_EMMISSIVE_RED] = mat[MAT_ATTRIB_BACK_EMISSION][0];
+ fcmd2[MTL_EMMISSIVE_GREEN] = mat[MAT_ATTRIB_BACK_EMISSION][1];
+ fcmd2[MTL_EMMISSIVE_BLUE] = mat[MAT_ATTRIB_BACK_EMISSION][2];
+ fcmd2[MTL_EMMISSIVE_ALPHA] = mat[MAT_ATTRIB_BACK_EMISSION][3];
+ }
+ if (mask & MAT_BIT_BACK_AMBIENT) {
+ fcmd2[MTL_AMBIENT_RED] = mat[MAT_ATTRIB_BACK_AMBIENT][0];
+ fcmd2[MTL_AMBIENT_GREEN] = mat[MAT_ATTRIB_BACK_AMBIENT][1];
+ fcmd2[MTL_AMBIENT_BLUE] = mat[MAT_ATTRIB_BACK_AMBIENT][2];
+ fcmd2[MTL_AMBIENT_ALPHA] = mat[MAT_ATTRIB_BACK_AMBIENT][3];
+ }
+ if (mask & MAT_BIT_BACK_DIFFUSE) {
+ fcmd2[MTL_DIFFUSE_RED] = mat[MAT_ATTRIB_BACK_DIFFUSE][0];
+ fcmd2[MTL_DIFFUSE_GREEN] = mat[MAT_ATTRIB_BACK_DIFFUSE][1];
+ fcmd2[MTL_DIFFUSE_BLUE] = mat[MAT_ATTRIB_BACK_DIFFUSE][2];
+ fcmd2[MTL_DIFFUSE_ALPHA] = mat[MAT_ATTRIB_BACK_DIFFUSE][3];
+ }
+ if (mask & MAT_BIT_BACK_SPECULAR) {
+ fcmd2[MTL_SPECULAR_RED] = mat[MAT_ATTRIB_BACK_SPECULAR][0];
+ fcmd2[MTL_SPECULAR_GREEN] = mat[MAT_ATTRIB_BACK_SPECULAR][1];
+ fcmd2[MTL_SPECULAR_BLUE] = mat[MAT_ATTRIB_BACK_SPECULAR][2];
+ fcmd2[MTL_SPECULAR_ALPHA] = mat[MAT_ATTRIB_BACK_SPECULAR][3];
+ }
+ if (mask & MAT_BIT_BACK_SHININESS) {
+ fcmd2[MTL_SHININESS] = mat[MAT_ATTRIB_BACK_SHININESS][0];
+ }
+
+ R200_DB_STATECHANGE( rmesa, &rmesa->hw.mtl[0] );
+ R200_DB_STATECHANGE( rmesa, &rmesa->hw.mtl[1] );
+
+ /* currently material changes cannot trigger a global ambient change, I believe this is correct
+ update_global_ambient( ctx ); */
+}
+
+/* _NEW_LIGHT
+ * _NEW_MODELVIEW
+ * _MESA_NEW_NEED_EYE_COORDS
+ *
+ * Uses derived state from mesa:
+ * _VP_inf_norm
+ * _h_inf_norm
+ * _Position
+ * _NormDirection
+ * _ModelViewInvScale
+ * _NeedEyeCoords
+ * _EyeZDir
+ *
+ * which are calculated in light.c and are correct for the current
+ * lighting space (model or eye), hence dependencies on _NEW_MODELVIEW
+ * and _MESA_NEW_NEED_EYE_COORDS.
+ */
+static void update_light( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ /* Have to check these, or have an automatic shortcircuit mechanism
+ * to remove noop statechanges. (Or just do a better job on the
+ * front end).
+ */
+ {
+ GLuint tmp = rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0];
+
+ if (ctx->_NeedEyeCoords)
+ tmp &= ~R200_LIGHT_IN_MODELSPACE;
+ else
+ tmp |= R200_LIGHT_IN_MODELSPACE;
+
+ if (tmp != rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0])
+ {
+ R200_STATECHANGE( rmesa, tcl );
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] = tmp;
+ }
+ }
+
+ {
+ GLfloat *fcmd = (GLfloat *)R200_DB_STATE( eye );
+ fcmd[EYE_X] = ctx->_EyeZDir[0];
+ fcmd[EYE_Y] = ctx->_EyeZDir[1];
+ fcmd[EYE_Z] = - ctx->_EyeZDir[2];
+ fcmd[EYE_RESCALE_FACTOR] = ctx->_ModelViewInvScale;
+ R200_DB_STATECHANGE( rmesa, &rmesa->hw.eye );
+ }
+
+
+
+ if (ctx->Light.Enabled) {
+ GLint p;
+ for (p = 0 ; p < MAX_LIGHTS; p++) {
+ if (ctx->Light.Light[p].Enabled) {
+ struct gl_light *l = &ctx->Light.Light[p];
+ GLfloat *fcmd = (GLfloat *)R200_DB_STATE( lit[p] );
+
+ if (l->EyePosition[3] == 0.0) {
+ COPY_3FV( &fcmd[LIT_POSITION_X], l->_VP_inf_norm );
+ COPY_3FV( &fcmd[LIT_DIRECTION_X], l->_h_inf_norm );
+ fcmd[LIT_POSITION_W] = 0;
+ fcmd[LIT_DIRECTION_W] = 0;
+ } else {
+ COPY_4V( &fcmd[LIT_POSITION_X], l->_Position );
+ fcmd[LIT_DIRECTION_X] = -l->_NormDirection[0];
+ fcmd[LIT_DIRECTION_Y] = -l->_NormDirection[1];
+ fcmd[LIT_DIRECTION_Z] = -l->_NormDirection[2];
+ fcmd[LIT_DIRECTION_W] = 0;
+ }
+
+ R200_DB_STATECHANGE( rmesa, &rmesa->hw.lit[p] );
+ }
+ }
+ }
+}
+
+static void r200Lightfv( GLcontext *ctx, GLenum light,
+ GLenum pname, const GLfloat *params )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLint p = light - GL_LIGHT0;
+ struct gl_light *l = &ctx->Light.Light[p];
+ GLfloat *fcmd = (GLfloat *)rmesa->hw.lit[p].cmd;
+
+
+ switch (pname) {
+ case GL_AMBIENT:
+ case GL_DIFFUSE:
+ case GL_SPECULAR:
+ update_light_colors( ctx, p );
+ break;
+
+ case GL_SPOT_DIRECTION:
+ /* picked up in update_light */
+ break;
+
+ case GL_POSITION: {
+ /* positions picked up in update_light, but can do flag here */
+ GLuint flag = (p&1)? R200_LIGHT_1_IS_LOCAL : R200_LIGHT_0_IS_LOCAL;
+ GLuint idx = TCL_PER_LIGHT_CTL_0 + p/2;
+
+ R200_STATECHANGE(rmesa, tcl);
+ if (l->EyePosition[3] != 0.0F)
+ rmesa->hw.tcl.cmd[idx] |= flag;
+ else
+ rmesa->hw.tcl.cmd[idx] &= ~flag;
+ break;
+ }
+
+ case GL_SPOT_EXPONENT:
+ R200_STATECHANGE(rmesa, lit[p]);
+ fcmd[LIT_SPOT_EXPONENT] = params[0];
+ break;
+
+ case GL_SPOT_CUTOFF: {
+ GLuint flag = (p&1) ? R200_LIGHT_1_IS_SPOT : R200_LIGHT_0_IS_SPOT;
+ GLuint idx = TCL_PER_LIGHT_CTL_0 + p/2;
+
+ R200_STATECHANGE(rmesa, lit[p]);
+ fcmd[LIT_SPOT_CUTOFF] = l->_CosCutoff;
+
+ R200_STATECHANGE(rmesa, tcl);
+ if (l->SpotCutoff != 180.0F)
+ rmesa->hw.tcl.cmd[idx] |= flag;
+ else
+ rmesa->hw.tcl.cmd[idx] &= ~flag;
+
+ break;
+ }
+
+ case GL_CONSTANT_ATTENUATION:
+ R200_STATECHANGE(rmesa, lit[p]);
+ fcmd[LIT_ATTEN_CONST] = params[0];
+ if ( params[0] == 0.0 )
+ fcmd[LIT_ATTEN_CONST_INV] = FLT_MAX;
+ else
+ fcmd[LIT_ATTEN_CONST_INV] = 1.0 / params[0];
+ break;
+ case GL_LINEAR_ATTENUATION:
+ R200_STATECHANGE(rmesa, lit[p]);
+ fcmd[LIT_ATTEN_LINEAR] = params[0];
+ break;
+ case GL_QUADRATIC_ATTENUATION:
+ R200_STATECHANGE(rmesa, lit[p]);
+ fcmd[LIT_ATTEN_QUADRATIC] = params[0];
+ break;
+ default:
+ return;
+ }
+
+ /* Set RANGE_ATTEN only when needed */
+ switch (pname) {
+ case GL_POSITION:
+ case GL_CONSTANT_ATTENUATION:
+ case GL_LINEAR_ATTENUATION:
+ case GL_QUADRATIC_ATTENUATION: {
+ GLuint *icmd = (GLuint *)R200_DB_STATE( tcl );
+ GLuint idx = TCL_PER_LIGHT_CTL_0 + p/2;
+ GLuint atten_flag = ( p&1 ) ? R200_LIGHT_1_ENABLE_RANGE_ATTEN
+ : R200_LIGHT_0_ENABLE_RANGE_ATTEN;
+ GLuint atten_const_flag = ( p&1 ) ? R200_LIGHT_1_CONSTANT_RANGE_ATTEN
+ : R200_LIGHT_0_CONSTANT_RANGE_ATTEN;
+
+ if ( l->EyePosition[3] == 0.0F ||
+ ( ( fcmd[LIT_ATTEN_CONST] == 0.0 || fcmd[LIT_ATTEN_CONST] == 1.0 ) &&
+ fcmd[LIT_ATTEN_QUADRATIC] == 0.0 && fcmd[LIT_ATTEN_LINEAR] == 0.0 ) ) {
+ /* Disable attenuation */
+ icmd[idx] &= ~atten_flag;
+ } else {
+ if ( fcmd[LIT_ATTEN_QUADRATIC] == 0.0 && fcmd[LIT_ATTEN_LINEAR] == 0.0 ) {
+ /* Enable only constant portion of attenuation calculation */
+ icmd[idx] |= ( atten_flag | atten_const_flag );
+ } else {
+ /* Enable full attenuation calculation */
+ icmd[idx] &= ~atten_const_flag;
+ icmd[idx] |= atten_flag;
+ }
+ }
+
+ R200_DB_STATECHANGE( rmesa, &rmesa->hw.tcl );
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+
+
+
+static void r200LightModelfv( GLcontext *ctx, GLenum pname,
+ const GLfloat *param )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ switch (pname) {
+ case GL_LIGHT_MODEL_AMBIENT:
+ update_global_ambient( ctx );
+ break;
+
+ case GL_LIGHT_MODEL_LOCAL_VIEWER:
+ R200_STATECHANGE( rmesa, tcl );
+ if (ctx->Light.Model.LocalViewer)
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] |= R200_LOCAL_VIEWER;
+ else
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] &= ~R200_LOCAL_VIEWER;
+ break;
+
+ case GL_LIGHT_MODEL_TWO_SIDE:
+ R200_STATECHANGE( rmesa, tcl );
+ if (ctx->Light.Model.TwoSide)
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] |= R200_LIGHT_TWOSIDE;
+ else
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] &= ~(R200_LIGHT_TWOSIDE);
+ if (rmesa->TclFallback) {
+ r200ChooseRenderState( ctx );
+ r200ChooseVertexState( ctx );
+ }
+ break;
+
+ case GL_LIGHT_MODEL_COLOR_CONTROL:
+ r200UpdateSpecular(ctx);
+ break;
+
+ default:
+ break;
+ }
+}
+
+static void r200ShadeModel( GLcontext *ctx, GLenum mode )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint s = rmesa->hw.set.cmd[SET_SE_CNTL];
+
+ s &= ~(R200_DIFFUSE_SHADE_MASK |
+ R200_ALPHA_SHADE_MASK |
+ R200_SPECULAR_SHADE_MASK |
+ R200_FOG_SHADE_MASK);
+
+ switch ( mode ) {
+ case GL_FLAT:
+ s |= (R200_DIFFUSE_SHADE_FLAT |
+ R200_ALPHA_SHADE_FLAT |
+ R200_SPECULAR_SHADE_FLAT |
+ R200_FOG_SHADE_FLAT);
+ break;
+ case GL_SMOOTH:
+ s |= (R200_DIFFUSE_SHADE_GOURAUD |
+ R200_ALPHA_SHADE_GOURAUD |
+ R200_SPECULAR_SHADE_GOURAUD |
+ R200_FOG_SHADE_GOURAUD);
+ break;
+ default:
+ return;
+ }
+
+ if ( rmesa->hw.set.cmd[SET_SE_CNTL] != s ) {
+ R200_STATECHANGE( rmesa, set );
+ rmesa->hw.set.cmd[SET_SE_CNTL] = s;
+ }
+}
+
+
+/* =============================================================
+ * User clip planes
+ */
+
+static void r200ClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *eq )
+{
+ GLint p = (GLint) plane - (GLint) GL_CLIP_PLANE0;
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLint *ip = (GLint *)ctx->Transform._ClipUserPlane[p];
+
+ R200_STATECHANGE( rmesa, ucp[p] );
+ rmesa->hw.ucp[p].cmd[UCP_X] = ip[0];
+ rmesa->hw.ucp[p].cmd[UCP_Y] = ip[1];
+ rmesa->hw.ucp[p].cmd[UCP_Z] = ip[2];
+ rmesa->hw.ucp[p].cmd[UCP_W] = ip[3];
+}
+
+static void r200UpdateClipPlanes( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint p;
+
+ for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
+ GLint *ip = (GLint *)ctx->Transform._ClipUserPlane[p];
+
+ R200_STATECHANGE( rmesa, ucp[p] );
+ rmesa->hw.ucp[p].cmd[UCP_X] = ip[0];
+ rmesa->hw.ucp[p].cmd[UCP_Y] = ip[1];
+ rmesa->hw.ucp[p].cmd[UCP_Z] = ip[2];
+ rmesa->hw.ucp[p].cmd[UCP_W] = ip[3];
+ }
+ }
+}
+
+
+/* =============================================================
+ * Stencil
+ */
+
+static void r200StencilFunc( GLcontext *ctx, GLenum func,
+ GLint ref, GLuint mask )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint refmask = ((ctx->Stencil.Ref[0] << R200_STENCIL_REF_SHIFT) |
+ (ctx->Stencil.ValueMask[0] << R200_STENCIL_MASK_SHIFT));
+
+ R200_STATECHANGE( rmesa, ctx );
+ R200_STATECHANGE( rmesa, msk );
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] &= ~R200_STENCIL_TEST_MASK;
+ rmesa->hw.msk.cmd[MSK_RB3D_STENCILREFMASK] &= ~(R200_STENCIL_REF_MASK|
+ R200_STENCIL_VALUE_MASK);
+
+ switch ( ctx->Stencil.Function[0] ) {
+ case GL_NEVER:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_TEST_NEVER;
+ break;
+ case GL_LESS:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_TEST_LESS;
+ break;
+ case GL_EQUAL:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_TEST_EQUAL;
+ break;
+ case GL_LEQUAL:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_TEST_LEQUAL;
+ break;
+ case GL_GREATER:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_TEST_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_TEST_NEQUAL;
+ break;
+ case GL_GEQUAL:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_TEST_GEQUAL;
+ break;
+ case GL_ALWAYS:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_TEST_ALWAYS;
+ break;
+ }
+
+ rmesa->hw.msk.cmd[MSK_RB3D_STENCILREFMASK] |= refmask;
+}
+
+static void r200StencilMask( GLcontext *ctx, GLuint mask )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ R200_STATECHANGE( rmesa, msk );
+ rmesa->hw.msk.cmd[MSK_RB3D_STENCILREFMASK] &= ~R200_STENCIL_WRITE_MASK;
+ rmesa->hw.msk.cmd[MSK_RB3D_STENCILREFMASK] |=
+ (ctx->Stencil.WriteMask[0] << R200_STENCIL_WRITEMASK_SHIFT);
+}
+
+static void r200StencilOp( GLcontext *ctx, GLenum fail,
+ GLenum zfail, GLenum zpass )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ R200_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] &= ~(R200_STENCIL_FAIL_MASK |
+ R200_STENCIL_ZFAIL_MASK |
+ R200_STENCIL_ZPASS_MASK);
+
+ switch ( ctx->Stencil.FailFunc[0] ) {
+ case GL_KEEP:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_FAIL_KEEP;
+ break;
+ case GL_ZERO:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_FAIL_ZERO;
+ break;
+ case GL_REPLACE:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_FAIL_REPLACE;
+ break;
+ case GL_INCR:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_FAIL_INC;
+ break;
+ case GL_DECR:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_FAIL_DEC;
+ break;
+ case GL_INCR_WRAP_EXT:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_FAIL_INC_WRAP;
+ break;
+ case GL_DECR_WRAP_EXT:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_FAIL_DEC_WRAP;
+ break;
+ case GL_INVERT:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_FAIL_INVERT;
+ break;
+ }
+
+ switch ( ctx->Stencil.ZFailFunc[0] ) {
+ case GL_KEEP:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZFAIL_KEEP;
+ break;
+ case GL_ZERO:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZFAIL_ZERO;
+ break;
+ case GL_REPLACE:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZFAIL_REPLACE;
+ break;
+ case GL_INCR:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZFAIL_INC;
+ break;
+ case GL_DECR:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZFAIL_DEC;
+ break;
+ case GL_INCR_WRAP_EXT:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZFAIL_INC_WRAP;
+ break;
+ case GL_DECR_WRAP_EXT:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZFAIL_DEC_WRAP;
+ break;
+ case GL_INVERT:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZFAIL_INVERT;
+ break;
+ }
+
+ switch ( ctx->Stencil.ZPassFunc[0] ) {
+ case GL_KEEP:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZPASS_KEEP;
+ break;
+ case GL_ZERO:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZPASS_ZERO;
+ break;
+ case GL_REPLACE:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZPASS_REPLACE;
+ break;
+ case GL_INCR:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZPASS_INC;
+ break;
+ case GL_DECR:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZPASS_DEC;
+ break;
+ case GL_INCR_WRAP_EXT:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZPASS_INC_WRAP;
+ break;
+ case GL_DECR_WRAP_EXT:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZPASS_DEC_WRAP;
+ break;
+ case GL_INVERT:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_STENCIL_ZPASS_INVERT;
+ break;
+ }
+}
+
+static void r200ClearStencil( GLcontext *ctx, GLint s )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ rmesa->state.stencil.clear =
+ ((GLuint) ctx->Stencil.Clear |
+ (0xff << R200_STENCIL_MASK_SHIFT) |
+ (ctx->Stencil.WriteMask[0] << R200_STENCIL_WRITEMASK_SHIFT));
+}
+
+
+/* =============================================================
+ * Window position and viewport transformation
+ */
+
+/*
+ * To correctly position primitives:
+ */
+#define SUBPIXEL_X 0.125
+#define SUBPIXEL_Y 0.125
+
+void r200UpdateWindow( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+ GLfloat xoffset = (GLfloat)dPriv->x;
+ GLfloat yoffset = (GLfloat)dPriv->y + dPriv->h;
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+
+ GLfloat sx = v[MAT_SX];
+ GLfloat tx = v[MAT_TX] + xoffset + SUBPIXEL_X;
+ GLfloat sy = - v[MAT_SY];
+ GLfloat ty = (- v[MAT_TY]) + yoffset + SUBPIXEL_Y;
+ GLfloat sz = v[MAT_SZ] * rmesa->state.depth.scale;
+ GLfloat tz = v[MAT_TZ] * rmesa->state.depth.scale;
+
+ R200_FIREVERTICES( rmesa );
+ R200_STATECHANGE( rmesa, vpt );
+
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_XSCALE] = *(GLuint *)&sx;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] = *(GLuint *)&tx;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_YSCALE] = *(GLuint *)&sy;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] = *(GLuint *)&ty;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_ZSCALE] = *(GLuint *)&sz;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_ZOFFSET] = *(GLuint *)&tz;
+}
+
+
+
+static void r200Viewport( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
+ /* Don't pipeline viewport changes, conflict with window offset
+ * setting below. Could apply deltas to rescue pipelined viewport
+ * values, or keep the originals hanging around.
+ */
+ R200_FIREVERTICES( R200_CONTEXT(ctx) );
+ r200UpdateWindow( ctx );
+}
+
+static void r200DepthRange( GLcontext *ctx, GLclampd nearval,
+ GLclampd farval )
+{
+ r200UpdateWindow( ctx );
+}
+
+void r200UpdateViewportOffset( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+ GLfloat xoffset = (GLfloat)dPriv->x;
+ GLfloat yoffset = (GLfloat)dPriv->y + dPriv->h;
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+
+ GLfloat tx = v[MAT_TX] + xoffset + SUBPIXEL_X;
+ GLfloat ty = (- v[MAT_TY]) + yoffset + SUBPIXEL_Y;
+
+ if ( rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] != *(GLuint *)&tx ||
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] != *(GLuint *)&ty )
+ {
+ /* Note: this should also modify whatever data the context reset
+ * code uses...
+ */
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] = *(GLuint *)&tx;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] = *(GLuint *)&ty;
+
+ /* update polygon stipple x/y screen offset */
+ {
+ GLuint stx, sty;
+ GLuint m = rmesa->hw.msc.cmd[MSC_RE_MISC];
+
+ m &= ~(R200_STIPPLE_X_OFFSET_MASK |
+ R200_STIPPLE_Y_OFFSET_MASK);
+
+ /* add magic offsets, then invert */
+ stx = 31 - ((rmesa->dri.drawable->x - 1) & R200_STIPPLE_COORD_MASK);
+ sty = 31 - ((rmesa->dri.drawable->y + rmesa->dri.drawable->h - 1)
+ & R200_STIPPLE_COORD_MASK);
+
+ m |= ((stx << R200_STIPPLE_X_OFFSET_SHIFT) |
+ (sty << R200_STIPPLE_Y_OFFSET_SHIFT));
+
+ if ( rmesa->hw.msc.cmd[MSC_RE_MISC] != m ) {
+ R200_STATECHANGE( rmesa, msc );
+ rmesa->hw.msc.cmd[MSC_RE_MISC] = m;
+ }
+ }
+ }
+
+ r200UpdateScissor( ctx );
+}
+
+
+
+/* =============================================================
+ * Miscellaneous
+ */
+
+static void r200ClearColor( GLcontext *ctx, const GLfloat c[4] )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLubyte color[4];
+ CLAMPED_FLOAT_TO_UBYTE(color[0], c[0]);
+ CLAMPED_FLOAT_TO_UBYTE(color[1], c[1]);
+ CLAMPED_FLOAT_TO_UBYTE(color[2], c[2]);
+ CLAMPED_FLOAT_TO_UBYTE(color[3], c[3]);
+ rmesa->state.color.clear = r200PackColor( rmesa->r200Screen->cpp,
+ color[0], color[1],
+ color[2], color[3] );
+}
+
+
+static void r200RenderMode( GLcontext *ctx, GLenum mode )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ FALLBACK( rmesa, R200_FALLBACK_RENDER_MODE, (mode != GL_RENDER) );
+}
+
+
+static GLuint r200_rop_tab[] = {
+ R200_ROP_CLEAR,
+ R200_ROP_AND,
+ R200_ROP_AND_REVERSE,
+ R200_ROP_COPY,
+ R200_ROP_AND_INVERTED,
+ R200_ROP_NOOP,
+ R200_ROP_XOR,
+ R200_ROP_OR,
+ R200_ROP_NOR,
+ R200_ROP_EQUIV,
+ R200_ROP_INVERT,
+ R200_ROP_OR_REVERSE,
+ R200_ROP_COPY_INVERTED,
+ R200_ROP_OR_INVERTED,
+ R200_ROP_NAND,
+ R200_ROP_SET,
+};
+
+static void r200LogicOpCode( GLcontext *ctx, GLenum opcode )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint rop = (GLuint)opcode - GL_CLEAR;
+
+ ASSERT( rop < 16 );
+
+ R200_STATECHANGE( rmesa, msk );
+ rmesa->hw.msk.cmd[MSK_RB3D_ROPCNTL] = r200_rop_tab[rop];
+}
+
+
+void r200SetCliprects( r200ContextPtr rmesa, GLenum mode )
+{
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+
+ switch ( mode ) {
+ case GL_FRONT_LEFT:
+ rmesa->numClipRects = dPriv->numClipRects;
+ rmesa->pClipRects = dPriv->pClipRects;
+ break;
+ case GL_BACK_LEFT:
+ /* Can't ignore 2d windows if we are page flipping.
+ */
+ if ( dPriv->numBackClipRects == 0 || rmesa->doPageFlip ) {
+ rmesa->numClipRects = dPriv->numClipRects;
+ rmesa->pClipRects = dPriv->pClipRects;
+ }
+ else {
+ rmesa->numClipRects = dPriv->numBackClipRects;
+ rmesa->pClipRects = dPriv->pBackClipRects;
+ }
+ break;
+ default:
+ fprintf(stderr, "bad mode in r200SetCliprects\n");
+ return;
+ }
+
+ if (rmesa->state.scissor.enabled)
+ r200RecalcScissorRects( rmesa );
+}
+
+
+static void r200DrawBuffer( GLcontext *ctx, GLenum mode )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if (R200_DEBUG & DEBUG_DRI)
+ fprintf(stderr, "%s %s\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr( mode ));
+
+ R200_FIREVERTICES(rmesa); /* don't pipeline cliprect changes */
+
+ /*
+ * _DrawDestMask is easier to cope with than <mode>.
+ */
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ r200SetCliprects( rmesa, GL_FRONT_LEFT );
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ r200SetCliprects( rmesa, GL_BACK_LEFT );
+ break;
+ default:
+ /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
+ FALLBACK( rmesa, R200_FALLBACK_DRAW_BUFFER, GL_TRUE );
+ return;
+ }
+
+ /* We want to update the s/w rast state too so that r200SetBuffer()
+ * gets called.
+ */
+ _swrast_DrawBuffer(ctx, mode);
+
+ R200_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = ((rmesa->state.color.drawOffset +
+ rmesa->r200Screen->fbLocation)
+ & R200_COLOROFFSET_MASK);
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = rmesa->state.color.drawPitch;
+ if (rmesa->sarea->tiling_enabled) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;
+ }
+}
+
+
+static void r200ReadBuffer( GLcontext *ctx, GLenum mode )
+{
+ /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
+}
+
+/* =============================================================
+ * State enable/disable
+ */
+
+static void r200Enable( GLcontext *ctx, GLenum cap, GLboolean state )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint p, flag;
+
+ if ( R200_DEBUG & DEBUG_STATE )
+ fprintf( stderr, "%s( %s = %s )\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr( cap ),
+ state ? "GL_TRUE" : "GL_FALSE" );
+
+ switch ( cap ) {
+ /* Fast track this one...
+ */
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ break;
+
+ case GL_ALPHA_TEST:
+ R200_STATECHANGE( rmesa, ctx );
+ if (state) {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_ALPHA_TEST_ENABLE;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~R200_ALPHA_TEST_ENABLE;
+ }
+ break;
+
+ case GL_BLEND:
+ case GL_COLOR_LOGIC_OP:
+ r200_set_blend_state( ctx );
+ 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:
+ p = cap-GL_CLIP_PLANE0;
+ R200_STATECHANGE( rmesa, tcl );
+ if (state) {
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= (R200_UCP_ENABLE_0<<p);
+ r200ClipPlane( ctx, cap, NULL );
+ }
+ else {
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~(R200_UCP_ENABLE_0<<p);
+ }
+ break;
+
+ case GL_COLOR_MATERIAL:
+ r200ColorMaterial( ctx, 0, 0 );
+ r200UpdateMaterial( ctx );
+ break;
+
+ case GL_CULL_FACE:
+ r200CullFace( ctx, 0 );
+ break;
+
+ case GL_DEPTH_TEST:
+ R200_STATECHANGE(rmesa, ctx );
+ if ( state ) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= R200_Z_ENABLE;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~R200_Z_ENABLE;
+ }
+ break;
+
+ case GL_DITHER:
+ R200_STATECHANGE(rmesa, ctx );
+ if ( state ) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= R200_DITHER_ENABLE;
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~rmesa->state.color.roundEnable;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~R200_DITHER_ENABLE;
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= rmesa->state.color.roundEnable;
+ }
+ break;
+
+ case GL_FOG:
+ R200_STATECHANGE(rmesa, ctx );
+ if ( state ) {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_FOG_ENABLE;
+ r200Fogfv( ctx, GL_FOG_MODE, NULL );
+ } else {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~R200_FOG_ENABLE;
+ R200_STATECHANGE(rmesa, tcl);
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~R200_TCL_FOG_MASK;
+ }
+ r200UpdateSpecular( ctx ); /* for PK_SPEC */
+ if (rmesa->TclFallback)
+ r200ChooseVertexState( ctx );
+ _mesa_allow_light_in_model( ctx, !state );
+ 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:
+ R200_STATECHANGE(rmesa, tcl);
+ p = cap - GL_LIGHT0;
+ if (p&1)
+ flag = (R200_LIGHT_1_ENABLE |
+ R200_LIGHT_1_ENABLE_AMBIENT |
+ R200_LIGHT_1_ENABLE_SPECULAR);
+ else
+ flag = (R200_LIGHT_0_ENABLE |
+ R200_LIGHT_0_ENABLE_AMBIENT |
+ R200_LIGHT_0_ENABLE_SPECULAR);
+
+ if (state)
+ rmesa->hw.tcl.cmd[p/2 + TCL_PER_LIGHT_CTL_0] |= flag;
+ else
+ rmesa->hw.tcl.cmd[p/2 + TCL_PER_LIGHT_CTL_0] &= ~flag;
+
+ /*
+ */
+ update_light_colors( ctx, p );
+ break;
+
+ case GL_LIGHTING:
+ r200UpdateSpecular(ctx);
+ break;
+
+ case GL_LINE_SMOOTH:
+ R200_STATECHANGE( rmesa, ctx );
+ if ( state ) {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_ANTI_ALIAS_LINE;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~R200_ANTI_ALIAS_LINE;
+ }
+ break;
+
+ case GL_LINE_STIPPLE:
+ R200_STATECHANGE( rmesa, set );
+ if ( state ) {
+ rmesa->hw.set.cmd[SET_RE_CNTL] |= R200_PATTERN_ENABLE;
+ } else {
+ rmesa->hw.set.cmd[SET_RE_CNTL] &= ~R200_PATTERN_ENABLE;
+ }
+ break;
+
+ case GL_NORMALIZE:
+ R200_STATECHANGE( rmesa, tcl );
+ if ( state ) {
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] |= R200_NORMALIZE_NORMALS;
+ } else {
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] &= ~R200_NORMALIZE_NORMALS;
+ }
+ break;
+
+ /* Pointsize registers on r200 don't seem to do anything. Maybe
+ * have to pass pointsizes as vertex parameters? In any case,
+ * setting pointmin == pointsizemax == 1.0, and doing nothing
+ * for aa is enough to satisfy conform.
+ */
+ case GL_POINT_SMOOTH:
+ break;
+
+ /* These don't really do anything, as we don't use the 3vtx
+ * primitives yet.
+ */
+#if 0
+ case GL_POLYGON_OFFSET_POINT:
+ R200_STATECHANGE( rmesa, set );
+ if ( state ) {
+ rmesa->hw.set.cmd[SET_SE_CNTL] |= R200_ZBIAS_ENABLE_POINT;
+ } else {
+ rmesa->hw.set.cmd[SET_SE_CNTL] &= ~R200_ZBIAS_ENABLE_POINT;
+ }
+ break;
+
+ case GL_POLYGON_OFFSET_LINE:
+ R200_STATECHANGE( rmesa, set );
+ if ( state ) {
+ rmesa->hw.set.cmd[SET_SE_CNTL] |= R200_ZBIAS_ENABLE_LINE;
+ } else {
+ rmesa->hw.set.cmd[SET_SE_CNTL] &= ~R200_ZBIAS_ENABLE_LINE;
+ }
+ break;
+#endif
+
+ case GL_POLYGON_OFFSET_FILL:
+ R200_STATECHANGE( rmesa, set );
+ if ( state ) {
+ rmesa->hw.set.cmd[SET_SE_CNTL] |= R200_ZBIAS_ENABLE_TRI;
+ } else {
+ rmesa->hw.set.cmd[SET_SE_CNTL] &= ~R200_ZBIAS_ENABLE_TRI;
+ }
+ break;
+
+ case GL_POLYGON_SMOOTH:
+ R200_STATECHANGE( rmesa, ctx );
+ if ( state ) {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_ANTI_ALIAS_POLY;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~R200_ANTI_ALIAS_POLY;
+ }
+ break;
+
+ case GL_POLYGON_STIPPLE:
+ R200_STATECHANGE(rmesa, set );
+ if ( state ) {
+ rmesa->hw.set.cmd[SET_RE_CNTL] |= R200_STIPPLE_ENABLE;
+ } else {
+ rmesa->hw.set.cmd[SET_RE_CNTL] &= ~R200_STIPPLE_ENABLE;
+ }
+ break;
+
+ case GL_RESCALE_NORMAL_EXT: {
+ GLboolean tmp = ctx->_NeedEyeCoords ? state : !state;
+ R200_STATECHANGE( rmesa, tcl );
+ if ( tmp ) {
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] |= R200_RESCALE_NORMALS;
+ } else {
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] &= ~R200_RESCALE_NORMALS;
+ }
+ break;
+ }
+
+ case GL_SCISSOR_TEST:
+ R200_FIREVERTICES( rmesa );
+ rmesa->state.scissor.enabled = state;
+ r200UpdateScissor( ctx );
+ break;
+
+ case GL_STENCIL_TEST:
+ if ( rmesa->state.stencil.hwBuffer ) {
+ R200_STATECHANGE( rmesa, ctx );
+ if ( state ) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= R200_STENCIL_ENABLE;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~R200_STENCIL_ENABLE;
+ }
+ } else {
+ FALLBACK( rmesa, R200_FALLBACK_STENCIL, state );
+ }
+ break;
+
+ case GL_TEXTURE_GEN_Q:
+ case GL_TEXTURE_GEN_R:
+ case GL_TEXTURE_GEN_S:
+ case GL_TEXTURE_GEN_T:
+ /* Picked up in r200UpdateTextureState.
+ */
+ rmesa->recheck_texgen[ctx->Texture.CurrentUnit] = GL_TRUE;
+ break;
+
+ case GL_COLOR_SUM_EXT:
+ r200UpdateSpecular ( ctx );
+ break;
+
+ case GL_VERTEX_PROGRAM_ARB:
+ TCL_FALLBACK(rmesa->glCtx, R200_TCL_FALLBACK_VERTEX_PROGRAM, state);
+ break;
+
+ default:
+ return;
+ }
+}
+
+
+void r200LightingSpaceChange( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLboolean tmp;
+
+ if (R200_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s %d BEFORE %x\n", __FUNCTION__, ctx->_NeedEyeCoords,
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0]);
+
+ if (ctx->_NeedEyeCoords)
+ tmp = ctx->Transform.RescaleNormals;
+ else
+ tmp = !ctx->Transform.RescaleNormals;
+
+ R200_STATECHANGE( rmesa, tcl );
+ if ( tmp ) {
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] |= R200_RESCALE_NORMALS;
+ } else {
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] &= ~R200_RESCALE_NORMALS;
+ }
+
+ if (R200_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s %d AFTER %x\n", __FUNCTION__, ctx->_NeedEyeCoords,
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0]);
+}
+
+/* =============================================================
+ * Deferred state management - matrices, textures, other?
+ */
+
+
+
+
+static void upload_matrix( r200ContextPtr rmesa, GLfloat *src, int idx )
+{
+ float *dest = ((float *)R200_DB_STATE( mat[idx] ))+MAT_ELT_0;
+ int i;
+
+
+ for (i = 0 ; i < 4 ; i++) {
+ *dest++ = src[i];
+ *dest++ = src[i+4];
+ *dest++ = src[i+8];
+ *dest++ = src[i+12];
+ }
+
+ R200_DB_STATECHANGE( rmesa, &rmesa->hw.mat[idx] );
+}
+
+static void upload_matrix_t( r200ContextPtr rmesa, const GLfloat *src, int idx )
+{
+ float *dest = ((float *)R200_DB_STATE( mat[idx] ))+MAT_ELT_0;
+ memcpy(dest, src, 16*sizeof(float));
+ R200_DB_STATECHANGE( rmesa, &rmesa->hw.mat[idx] );
+}
+
+
+static void update_texturematrix( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT( ctx );
+ GLuint tpc = rmesa->hw.tcg.cmd[TCG_TEX_PROC_CTL_0];
+ GLuint compsel = rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL];
+ int unit;
+
+ if (R200_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s before COMPSEL: %x\n", __FUNCTION__,
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL]);
+
+ rmesa->TexMatEnabled = 0;
+ rmesa->TexMatCompSel = 0;
+
+ for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++) {
+ if (!ctx->Texture.Unit[unit]._ReallyEnabled)
+ continue;
+
+ if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) {
+ rmesa->TexMatEnabled |= (R200_TEXGEN_TEXMAT_0_ENABLE|
+ R200_TEXMAT_0_ENABLE) << unit;
+
+ rmesa->TexMatCompSel |= R200_OUTPUT_TEX_0 << unit;
+
+ if (rmesa->TexGenEnabled & (R200_TEXMAT_0_ENABLE << unit)) {
+ /* Need to preconcatenate any active texgen
+ * obj/eyeplane matrices:
+ */
+ _math_matrix_mul_matrix( &rmesa->tmpmat,
+ ctx->TextureMatrixStack[unit].Top,
+ &rmesa->TexGenMatrix[unit] );
+ upload_matrix( rmesa, rmesa->tmpmat.m, R200_MTX_TEX0+unit );
+ }
+ else {
+ upload_matrix( rmesa, ctx->TextureMatrixStack[unit].Top->m,
+ R200_MTX_TEX0+unit );
+ }
+ }
+ else if (rmesa->TexGenEnabled & (R200_TEXMAT_0_ENABLE << unit)) {
+ upload_matrix( rmesa, rmesa->TexGenMatrix[unit].m,
+ R200_MTX_TEX0+unit );
+ }
+ }
+
+ tpc = (rmesa->TexMatEnabled | rmesa->TexGenEnabled);
+ if (tpc != rmesa->hw.tcg.cmd[TCG_TEX_PROC_CTL_0]) {
+ R200_STATECHANGE(rmesa, tcg);
+ rmesa->hw.tcg.cmd[TCG_TEX_PROC_CTL_0] = tpc;
+ }
+
+ compsel &= ~R200_OUTPUT_TEX_MASK;
+ compsel |= rmesa->TexMatCompSel | rmesa->TexGenCompSel;
+ if (compsel != rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL]) {
+ R200_STATECHANGE(rmesa, vtx);
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] = compsel;
+ }
+}
+
+
+
+void r200ValidateState( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint new_state = rmesa->NewGLState;
+
+ if (new_state & _NEW_TEXTURE) {
+ r200UpdateTextureState( ctx );
+ new_state |= rmesa->NewGLState; /* may add TEXTURE_MATRIX */
+ }
+
+ /* Need an event driven matrix update?
+ */
+ if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
+ upload_matrix( rmesa, ctx->_ModelProjectMatrix.m, R200_MTX_MVP );
+
+ /* Need these for lighting (shouldn't upload otherwise)
+ */
+ if (new_state & (_NEW_MODELVIEW)) {
+ upload_matrix( rmesa, ctx->ModelviewMatrixStack.Top->m, R200_MTX_MV );
+ upload_matrix_t( rmesa, ctx->ModelviewMatrixStack.Top->inv, R200_MTX_IMV );
+ }
+
+ /* Does this need to be triggered on eg. modelview for
+ * texgen-derived objplane/eyeplane matrices?
+ */
+ if (new_state & (_NEW_TEXTURE|_NEW_TEXTURE_MATRIX)) {
+ update_texturematrix( ctx );
+ }
+
+ if (new_state & (_NEW_LIGHT|_NEW_MODELVIEW|_MESA_NEW_NEED_EYE_COORDS)) {
+ update_light( ctx );
+ }
+
+ /* emit all active clip planes if projection matrix changes.
+ */
+ if (new_state & (_NEW_PROJECTION)) {
+ if (ctx->Transform.ClipPlanesEnabled)
+ r200UpdateClipPlanes( ctx );
+ }
+
+
+ rmesa->NewGLState = 0;
+}
+
+
+static void r200InvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ _ae_invalidate_state( ctx, new_state );
+ R200_CONTEXT(ctx)->NewGLState |= new_state;
+ r200VtxfmtInvalidate( ctx );
+}
+
+/* A hack. The r200 can actually cope just fine with materials
+ * between begin/ends, so fix this. But how ?
+ */
+static GLboolean check_material( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLint i;
+
+ for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT;
+ i < _TNL_ATTRIB_MAT_BACK_INDEXES;
+ i++)
+ if (tnl->vb.AttribPtr[i] &&
+ tnl->vb.AttribPtr[i]->stride)
+ return GL_TRUE;
+
+ return GL_FALSE;
+}
+
+static void r200WrapRunPipeline( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLboolean has_material;
+
+ if (0)
+ fprintf(stderr, "%s, newstate: %x\n", __FUNCTION__, rmesa->NewGLState);
+
+ /* Validate state:
+ */
+ if (rmesa->NewGLState)
+ r200ValidateState( ctx );
+
+ has_material = (ctx->Light.Enabled && check_material( ctx ));
+
+ if (has_material) {
+ TCL_FALLBACK( ctx, R200_TCL_FALLBACK_MATERIAL, GL_TRUE );
+ }
+
+ /* Run the pipeline.
+ */
+ _tnl_run_pipeline( ctx );
+
+ if (has_material) {
+ TCL_FALLBACK( ctx, R200_TCL_FALLBACK_MATERIAL, GL_FALSE );
+ }
+}
+
+
+/* Initialize the driver's state functions.
+ */
+void r200InitStateFuncs( struct dd_function_table *functions )
+{
+ functions->UpdateState = r200InvalidateState;
+ functions->LightingSpaceChange = r200LightingSpaceChange;
+
+ functions->DrawBuffer = r200DrawBuffer;
+ functions->ReadBuffer = r200ReadBuffer;
+
+ functions->AlphaFunc = r200AlphaFunc;
+ functions->BlendColor = r200BlendColor;
+ functions->BlendEquationSeparate = r200BlendEquationSeparate;
+ functions->BlendFuncSeparate = r200BlendFuncSeparate;
+ functions->ClearColor = r200ClearColor;
+ functions->ClearDepth = r200ClearDepth;
+ functions->ClearIndex = NULL;
+ functions->ClearStencil = r200ClearStencil;
+ functions->ClipPlane = r200ClipPlane;
+ functions->ColorMask = r200ColorMask;
+ functions->CullFace = r200CullFace;
+ functions->DepthFunc = r200DepthFunc;
+ functions->DepthMask = r200DepthMask;
+ functions->DepthRange = r200DepthRange;
+ functions->Enable = r200Enable;
+ functions->Fogfv = r200Fogfv;
+ functions->FrontFace = r200FrontFace;
+ functions->Hint = NULL;
+ functions->IndexMask = NULL;
+ functions->LightModelfv = r200LightModelfv;
+ functions->Lightfv = r200Lightfv;
+ functions->LineStipple = r200LineStipple;
+ functions->LineWidth = r200LineWidth;
+ functions->LogicOpcode = r200LogicOpCode;
+ functions->PolygonMode = r200PolygonMode;
+ functions->PolygonOffset = r200PolygonOffset;
+ functions->PolygonStipple = r200PolygonStipple;
+ functions->PointSize = r200PointSize;
+ functions->RenderMode = r200RenderMode;
+ functions->Scissor = r200Scissor;
+ functions->ShadeModel = r200ShadeModel;
+ functions->StencilFunc = r200StencilFunc;
+ functions->StencilMask = r200StencilMask;
+ functions->StencilOp = r200StencilOp;
+ functions->Viewport = r200Viewport;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ functions->CopyColorTable = _swrast_CopyColorTable;
+ functions->CopyColorSubTable = _swrast_CopyColorSubTable;
+ functions->CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ functions->CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+}
+
+
+void r200InitTnlFuncs( GLcontext *ctx )
+{
+ TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange = r200UpdateMaterial;
+ TNL_CONTEXT(ctx)->Driver.RunPipeline = r200WrapRunPipeline;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_state.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_state.h
new file mode 100644
index 000000000..d467d73bd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_state.h
@@ -0,0 +1,67 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_state.h,v 1.2 2002/11/05 17:46:08 tsi Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R200_STATE_H__
+#define __R200_STATE_H__
+
+#include "r200_context.h"
+
+extern void r200InitState( r200ContextPtr rmesa );
+extern void r200InitStateFuncs( struct dd_function_table *functions );
+extern void r200InitTnlFuncs( GLcontext *ctx );
+
+extern void r200UpdateMaterial( GLcontext *ctx );
+
+extern void r200SetCliprects( r200ContextPtr rmesa, GLenum mode );
+extern void r200RecalcScissorRects( r200ContextPtr rmesa );
+extern void r200UpdateViewportOffset( GLcontext *ctx );
+extern void r200UpdateWindow( GLcontext *ctx );
+
+extern void r200ValidateState( GLcontext *ctx );
+
+extern void r200PrintDirty( r200ContextPtr rmesa,
+ const char *msg );
+
+
+extern void r200Fallback( GLcontext *ctx, GLuint bit, GLboolean mode );
+#define FALLBACK( rmesa, bit, mode ) do { \
+ if ( 0 ) fprintf( stderr, "FALLBACK in %s: #%d=%d\n", \
+ __FUNCTION__, bit, mode ); \
+ r200Fallback( rmesa->glCtx, bit, mode ); \
+} while (0)
+
+extern void r200LightingSpaceChange( GLcontext *ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_state_init.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_state_init.c
new file mode 100644
index 000000000..f004cf79c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_state_init.c
@@ -0,0 +1,798 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_state_init.c,v 1.4 2003/02/22 06:21:11 dawes Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "enums.h"
+#include "colormac.h"
+#include "api_arrayelt.h"
+
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "r200_context.h"
+#include "r200_ioctl.h"
+#include "r200_state.h"
+#include "r200_tcl.h"
+#include "r200_tex.h"
+#include "r200_swtcl.h"
+#include "r200_vtxfmt.h"
+
+#include "xmlpool.h"
+
+/* =============================================================
+ * State initialization
+ */
+
+void r200PrintDirty( r200ContextPtr rmesa, const char *msg )
+{
+ struct r200_state_atom *l;
+
+ fprintf(stderr, msg);
+ fprintf(stderr, ": ");
+
+ foreach(l, &rmesa->hw.atomlist) {
+ if (l->dirty || rmesa->hw.all_dirty)
+ fprintf(stderr, "%s, ", l->name);
+ }
+
+ fprintf(stderr, "\n");
+}
+
+static int cmdpkt( int id )
+{
+ drm_radeon_cmd_header_t h;
+ h.i = 0;
+ h.packet.cmd_type = RADEON_CMD_PACKET;
+ h.packet.packet_id = id;
+ return h.i;
+}
+
+static int cmdvec( int offset, int stride, int count )
+{
+ drm_radeon_cmd_header_t h;
+ h.i = 0;
+ h.vectors.cmd_type = RADEON_CMD_VECTORS;
+ h.vectors.offset = offset;
+ h.vectors.stride = stride;
+ h.vectors.count = count;
+ return h.i;
+}
+
+static int cmdscl( int offset, int stride, int count )
+{
+ drm_radeon_cmd_header_t h;
+ h.i = 0;
+ h.scalars.cmd_type = RADEON_CMD_SCALARS;
+ h.scalars.offset = offset;
+ h.scalars.stride = stride;
+ h.scalars.count = count;
+ return h.i;
+}
+
+static int cmdscl2( int offset, int stride, int count )
+{
+ drm_radeon_cmd_header_t h;
+ h.i = 0;
+ h.scalars.cmd_type = RADEON_CMD_SCALARS2;
+ h.scalars.offset = offset - 0x100;
+ h.scalars.stride = stride;
+ h.scalars.count = count;
+ return h.i;
+}
+
+#define CHECK( NM, FLAG ) \
+static GLboolean check_##NM( GLcontext *ctx, int idx ) \
+{ \
+ (void) idx; \
+ return FLAG; \
+}
+
+#define TCL_CHECK( NM, FLAG ) \
+static GLboolean check_##NM( GLcontext *ctx, int idx ) \
+{ \
+ r200ContextPtr rmesa = R200_CONTEXT(ctx); \
+ (void) idx; \
+ return !rmesa->TclFallback && (FLAG); \
+}
+
+
+
+CHECK( always, GL_TRUE )
+CHECK( never, GL_FALSE )
+CHECK( tex_any, ctx->Texture._EnabledUnits )
+CHECK( tex_pair, (ctx->Texture.Unit[idx]._ReallyEnabled | ctx->Texture.Unit[idx & ~1]._ReallyEnabled))
+CHECK( tex, ctx->Texture.Unit[idx]._ReallyEnabled )
+CHECK( tex_cube, ctx->Texture.Unit[idx]._ReallyEnabled & TEXTURE_CUBE_BIT)
+CHECK( fog, ctx->Fog.Enabled )
+TCL_CHECK( tcl, GL_TRUE )
+TCL_CHECK( tcl_tex, ctx->Texture.Unit[idx]._ReallyEnabled )
+TCL_CHECK( tcl_lighting, ctx->Light.Enabled )
+TCL_CHECK( tcl_light, ctx->Light.Enabled && ctx->Light.Light[idx].Enabled )
+TCL_CHECK( tcl_ucp, (ctx->Transform.ClipPlanesEnabled & (1 << idx)) )
+
+
+/* Initialize the context's hardware state.
+ */
+void r200InitState( r200ContextPtr rmesa )
+{
+ GLcontext *ctx = rmesa->glCtx;
+ GLuint color_fmt, depth_fmt, i;
+
+ switch ( rmesa->r200Screen->cpp ) {
+ case 2:
+ color_fmt = R200_COLOR_FORMAT_RGB565;
+ break;
+ case 4:
+ color_fmt = R200_COLOR_FORMAT_ARGB8888;
+ break;
+ default:
+ fprintf( stderr, "Error: Unsupported pixel depth... exiting\n" );
+ exit( -1 );
+ }
+
+ rmesa->state.color.clear = 0x00000000;
+
+ switch ( ctx->Visual.depthBits ) {
+ case 16:
+ rmesa->state.depth.clear = 0x0000ffff;
+ rmesa->state.depth.scale = 1.0 / (GLfloat)0xffff;
+ depth_fmt = R200_DEPTH_FORMAT_16BIT_INT_Z;
+ rmesa->state.stencil.clear = 0x00000000;
+ break;
+ case 24:
+ rmesa->state.depth.clear = 0x00ffffff;
+ rmesa->state.depth.scale = 1.0 / (GLfloat)0xffffff;
+ depth_fmt = R200_DEPTH_FORMAT_24BIT_INT_Z;
+ rmesa->state.stencil.clear = 0xffff0000;
+ break;
+ default:
+ fprintf( stderr, "Error: Unsupported depth %d... exiting\n",
+ ctx->Visual.depthBits );
+ exit( -1 );
+ }
+
+ /* Only have hw stencil when depth buffer is 24 bits deep */
+ rmesa->state.stencil.hwBuffer = ( ctx->Visual.stencilBits > 0 &&
+ ctx->Visual.depthBits == 24 );
+
+ rmesa->Fallback = 0;
+
+ if ( ctx->Visual.doubleBufferMode && rmesa->sarea->pfCurrentPage == 0 ) {
+ rmesa->state.color.drawOffset = rmesa->r200Screen->backOffset;
+ rmesa->state.color.drawPitch = rmesa->r200Screen->backPitch;
+ } else {
+ rmesa->state.color.drawOffset = rmesa->r200Screen->frontOffset;
+ rmesa->state.color.drawPitch = rmesa->r200Screen->frontPitch;
+ }
+
+ rmesa->state.pixel.readOffset = rmesa->state.color.drawOffset;
+ rmesa->state.pixel.readPitch = rmesa->state.color.drawPitch;
+
+ rmesa->hw.max_state_size = 0;
+
+#define ALLOC_STATE( ATOM, CHK, SZ, NM, IDX ) \
+ do { \
+ rmesa->hw.ATOM.cmd_size = SZ; \
+ rmesa->hw.ATOM.cmd = (int *)CALLOC(SZ * sizeof(int)); \
+ rmesa->hw.ATOM.lastcmd = (int *)CALLOC(SZ * sizeof(int)); \
+ rmesa->hw.ATOM.name = NM; \
+ rmesa->hw.ATOM.idx = IDX; \
+ rmesa->hw.ATOM.check = check_##CHK; \
+ rmesa->hw.ATOM.dirty = GL_FALSE; \
+ rmesa->hw.max_state_size += SZ * sizeof(int); \
+ } while (0)
+
+
+ /* Allocate state buffers:
+ */
+ if (rmesa->r200Screen->drmSupportsBlendColor)
+ ALLOC_STATE( ctx, always, CTX_STATE_SIZE_NEWDRM, "CTX/context", 0 );
+ else
+ ALLOC_STATE( ctx, always, CTX_STATE_SIZE_OLDDRM, "CTX/context", 0 );
+ ALLOC_STATE( set, always, SET_STATE_SIZE, "SET/setup", 0 );
+ ALLOC_STATE( lin, always, LIN_STATE_SIZE, "LIN/line", 0 );
+ ALLOC_STATE( msk, always, MSK_STATE_SIZE, "MSK/mask", 0 );
+ ALLOC_STATE( vpt, always, VPT_STATE_SIZE, "VPT/viewport", 0 );
+ ALLOC_STATE( vtx, always, VTX_STATE_SIZE, "VTX/vertex", 0 );
+ ALLOC_STATE( vap, always, VAP_STATE_SIZE, "VAP/vap", 0 );
+ ALLOC_STATE( vte, always, VTE_STATE_SIZE, "VTE/vte", 0 );
+ ALLOC_STATE( msc, always, MSC_STATE_SIZE, "MSC/misc", 0 );
+ ALLOC_STATE( cst, always, CST_STATE_SIZE, "CST/constant", 0 );
+ ALLOC_STATE( zbs, always, ZBS_STATE_SIZE, "ZBS/zbias", 0 );
+ ALLOC_STATE( tf, tex_any, TF_STATE_SIZE, "TF/tfactor", 0 );
+ if (rmesa->r200Screen->chipset & R200_CHIPSET_REAL_R200) {
+ /* make sure texture units 0/1 are emitted pair-wise for r200 t0 hang workaround */
+ ALLOC_STATE( tex[0], tex_pair, TEX_STATE_SIZE, "TEX/tex-0", 0 );
+ ALLOC_STATE( tex[1], tex_pair, TEX_STATE_SIZE, "TEX/tex-1", 1 );
+ ALLOC_STATE( tam, tex_any, TAM_STATE_SIZE, "TAM/tam", 0 );
+ }
+ else {
+ ALLOC_STATE( tex[0], tex, TEX_STATE_SIZE, "TEX/tex-0", 0 );
+ ALLOC_STATE( tex[1], tex, TEX_STATE_SIZE, "TEX/tex-1", 1 );
+ ALLOC_STATE( tam, never, TAM_STATE_SIZE, "TAM/tam", 0 );
+ }
+ ALLOC_STATE( tex[2], tex, TEX_STATE_SIZE, "TEX/tex-2", 2 );
+ ALLOC_STATE( tex[3], tex, TEX_STATE_SIZE, "TEX/tex-3", 3 );
+ ALLOC_STATE( tex[4], tex, TEX_STATE_SIZE, "TEX/tex-4", 4 );
+ ALLOC_STATE( tex[5], tex, TEX_STATE_SIZE, "TEX/tex-5", 5 );
+ if (rmesa->r200Screen->drmSupportsCubeMaps) {
+ ALLOC_STATE( cube[0], tex_cube, CUBE_STATE_SIZE, "CUBE/tex-0", 0 );
+ ALLOC_STATE( cube[1], tex_cube, CUBE_STATE_SIZE, "CUBE/tex-1", 1 );
+ ALLOC_STATE( cube[2], tex_cube, CUBE_STATE_SIZE, "CUBE/tex-2", 2 );
+ ALLOC_STATE( cube[3], tex_cube, CUBE_STATE_SIZE, "CUBE/tex-3", 3 );
+ ALLOC_STATE( cube[4], tex_cube, CUBE_STATE_SIZE, "CUBE/tex-4", 4 );
+ ALLOC_STATE( cube[5], tex_cube, CUBE_STATE_SIZE, "CUBE/tex-5", 5 );
+ }
+ else {
+ ALLOC_STATE( cube[0], never, CUBE_STATE_SIZE, "CUBE/tex-0", 0 );
+ ALLOC_STATE( cube[1], never, CUBE_STATE_SIZE, "CUBE/tex-1", 1 );
+ ALLOC_STATE( cube[2], never, CUBE_STATE_SIZE, "CUBE/tex-2", 2 );
+ ALLOC_STATE( cube[3], never, CUBE_STATE_SIZE, "CUBE/tex-3", 3 );
+ ALLOC_STATE( cube[4], never, CUBE_STATE_SIZE, "CUBE/tex-4", 4 );
+ ALLOC_STATE( cube[5], never, CUBE_STATE_SIZE, "CUBE/tex-5", 5 );
+ }
+
+ ALLOC_STATE( tcl, tcl, TCL_STATE_SIZE, "TCL/tcl", 0 );
+ ALLOC_STATE( msl, tcl, MSL_STATE_SIZE, "MSL/matrix-select", 0 );
+ ALLOC_STATE( tcg, tcl, TCG_STATE_SIZE, "TCG/texcoordgen", 0 );
+ ALLOC_STATE( mtl[0], tcl_lighting, MTL_STATE_SIZE, "MTL0/material0", 0 );
+ ALLOC_STATE( mtl[1], tcl_lighting, MTL_STATE_SIZE, "MTL1/material1", 1 );
+ ALLOC_STATE( grd, tcl, GRD_STATE_SIZE, "GRD/guard-band", 0 );
+ ALLOC_STATE( fog, fog, FOG_STATE_SIZE, "FOG/fog", 0 );
+ ALLOC_STATE( glt, tcl_lighting, GLT_STATE_SIZE, "GLT/light-global", 0 );
+ ALLOC_STATE( eye, tcl_lighting, EYE_STATE_SIZE, "EYE/eye-vector", 0 );
+ ALLOC_STATE( mat[R200_MTX_MV], tcl, MAT_STATE_SIZE, "MAT/modelview", 0 );
+ ALLOC_STATE( mat[R200_MTX_IMV], tcl, MAT_STATE_SIZE, "MAT/it-modelview", 0 );
+ ALLOC_STATE( mat[R200_MTX_MVP], tcl, MAT_STATE_SIZE, "MAT/modelproject", 0 );
+ ALLOC_STATE( mat[R200_MTX_TEX0], tcl_tex, MAT_STATE_SIZE, "MAT/texmat0", 0 );
+ ALLOC_STATE( mat[R200_MTX_TEX1], tcl_tex, MAT_STATE_SIZE, "MAT/texmat1", 1 );
+ ALLOC_STATE( mat[R200_MTX_TEX2], tcl_tex, MAT_STATE_SIZE, "MAT/texmat2", 2 );
+ ALLOC_STATE( mat[R200_MTX_TEX3], tcl_tex, MAT_STATE_SIZE, "MAT/texmat3", 3 );
+ ALLOC_STATE( mat[R200_MTX_TEX4], tcl_tex, MAT_STATE_SIZE, "MAT/texmat4", 4 );
+ ALLOC_STATE( mat[R200_MTX_TEX5], tcl_tex, MAT_STATE_SIZE, "MAT/texmat5", 5 );
+ ALLOC_STATE( ucp[0], tcl_ucp, UCP_STATE_SIZE, "UCP/userclip-0", 0 );
+ ALLOC_STATE( ucp[1], tcl_ucp, UCP_STATE_SIZE, "UCP/userclip-1", 1 );
+ ALLOC_STATE( ucp[2], tcl_ucp, UCP_STATE_SIZE, "UCP/userclip-2", 2 );
+ ALLOC_STATE( ucp[3], tcl_ucp, UCP_STATE_SIZE, "UCP/userclip-3", 3 );
+ ALLOC_STATE( ucp[4], tcl_ucp, UCP_STATE_SIZE, "UCP/userclip-4", 4 );
+ ALLOC_STATE( ucp[5], tcl_ucp, UCP_STATE_SIZE, "UCP/userclip-5", 5 );
+ ALLOC_STATE( lit[0], tcl_light, LIT_STATE_SIZE, "LIT/light-0", 0 );
+ ALLOC_STATE( lit[1], tcl_light, LIT_STATE_SIZE, "LIT/light-1", 1 );
+ ALLOC_STATE( lit[2], tcl_light, LIT_STATE_SIZE, "LIT/light-2", 2 );
+ ALLOC_STATE( lit[3], tcl_light, LIT_STATE_SIZE, "LIT/light-3", 3 );
+ ALLOC_STATE( lit[4], tcl_light, LIT_STATE_SIZE, "LIT/light-4", 4 );
+ ALLOC_STATE( lit[5], tcl_light, LIT_STATE_SIZE, "LIT/light-5", 5 );
+ ALLOC_STATE( lit[6], tcl_light, LIT_STATE_SIZE, "LIT/light-6", 6 );
+ ALLOC_STATE( lit[7], tcl_light, LIT_STATE_SIZE, "LIT/light-7", 7 );
+ ALLOC_STATE( pix[0], always, PIX_STATE_SIZE, "PIX/pixstage-0", 0 );
+ ALLOC_STATE( pix[1], tex, PIX_STATE_SIZE, "PIX/pixstage-1", 1 );
+ ALLOC_STATE( pix[2], tex, PIX_STATE_SIZE, "PIX/pixstage-2", 2 );
+ ALLOC_STATE( pix[3], tex, PIX_STATE_SIZE, "PIX/pixstage-3", 3 );
+ ALLOC_STATE( pix[4], tex, PIX_STATE_SIZE, "PIX/pixstage-4", 4 );
+ ALLOC_STATE( pix[5], tex, PIX_STATE_SIZE, "PIX/pixstage-5", 5 );
+ if (rmesa->r200Screen->drmSupportsTriPerf) {
+ ALLOC_STATE( prf, always, PRF_STATE_SIZE, "PRF/performance-tri", 0 );
+ }
+ else {
+ ALLOC_STATE( prf, never, PRF_STATE_SIZE, "PRF/performance-tri", 0 );
+ }
+
+ r200SetUpAtomList( rmesa );
+
+ /* Fill in the packet headers:
+ */
+ rmesa->hw.ctx.cmd[CTX_CMD_0] = cmdpkt(RADEON_EMIT_PP_MISC);
+ rmesa->hw.ctx.cmd[CTX_CMD_1] = cmdpkt(RADEON_EMIT_PP_CNTL);
+ rmesa->hw.ctx.cmd[CTX_CMD_2] = cmdpkt(RADEON_EMIT_RB3D_COLORPITCH);
+ if (rmesa->r200Screen->drmSupportsBlendColor)
+ rmesa->hw.ctx.cmd[CTX_CMD_3] = cmdpkt(R200_EMIT_RB3D_BLENDCOLOR);
+ rmesa->hw.lin.cmd[LIN_CMD_0] = cmdpkt(RADEON_EMIT_RE_LINE_PATTERN);
+ rmesa->hw.lin.cmd[LIN_CMD_1] = cmdpkt(RADEON_EMIT_SE_LINE_WIDTH);
+ rmesa->hw.msk.cmd[MSK_CMD_0] = cmdpkt(RADEON_EMIT_RB3D_STENCILREFMASK);
+ rmesa->hw.vpt.cmd[VPT_CMD_0] = cmdpkt(RADEON_EMIT_SE_VPORT_XSCALE);
+ rmesa->hw.set.cmd[SET_CMD_0] = cmdpkt(RADEON_EMIT_SE_CNTL);
+ rmesa->hw.msc.cmd[MSC_CMD_0] = cmdpkt(RADEON_EMIT_RE_MISC);
+ rmesa->hw.cst.cmd[CST_CMD_0] = cmdpkt(R200_EMIT_PP_CNTL_X);
+ rmesa->hw.cst.cmd[CST_CMD_1] = cmdpkt(R200_EMIT_RB3D_DEPTHXY_OFFSET);
+ rmesa->hw.cst.cmd[CST_CMD_2] = cmdpkt(R200_EMIT_RE_AUX_SCISSOR_CNTL);
+ rmesa->hw.cst.cmd[CST_CMD_3] = cmdpkt(R200_EMIT_RE_SCISSOR_TL_0);
+ rmesa->hw.cst.cmd[CST_CMD_4] = cmdpkt(R200_EMIT_SE_VAP_CNTL_STATUS);
+ rmesa->hw.cst.cmd[CST_CMD_5] = cmdpkt(R200_EMIT_RE_POINTSIZE);
+ rmesa->hw.cst.cmd[CST_CMD_6] = cmdpkt(R200_EMIT_TCL_INPUT_VTX_VECTOR_ADDR_0);
+ rmesa->hw.tam.cmd[TAM_CMD_0] = cmdpkt(R200_EMIT_PP_TAM_DEBUG3);
+ rmesa->hw.tf.cmd[TF_CMD_0] = cmdpkt(R200_EMIT_TFACTOR_0);
+ rmesa->hw.tex[0].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXFILTER_0);
+ rmesa->hw.tex[0].cmd[TEX_CMD_1] = cmdpkt(R200_EMIT_PP_TXOFFSET_0);
+ rmesa->hw.tex[1].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXFILTER_1);
+ rmesa->hw.tex[1].cmd[TEX_CMD_1] = cmdpkt(R200_EMIT_PP_TXOFFSET_1);
+ rmesa->hw.tex[2].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXFILTER_2);
+ rmesa->hw.tex[2].cmd[TEX_CMD_1] = cmdpkt(R200_EMIT_PP_TXOFFSET_2);
+ rmesa->hw.tex[3].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXFILTER_3);
+ rmesa->hw.tex[3].cmd[TEX_CMD_1] = cmdpkt(R200_EMIT_PP_TXOFFSET_3);
+ rmesa->hw.tex[4].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXFILTER_4);
+ rmesa->hw.tex[4].cmd[TEX_CMD_1] = cmdpkt(R200_EMIT_PP_TXOFFSET_4);
+ rmesa->hw.tex[5].cmd[TEX_CMD_0] = cmdpkt(R200_EMIT_PP_TXFILTER_5);
+ rmesa->hw.tex[5].cmd[TEX_CMD_1] = cmdpkt(R200_EMIT_PP_TXOFFSET_5);
+ rmesa->hw.cube[0].cmd[CUBE_CMD_0] = cmdpkt(R200_EMIT_PP_CUBIC_FACES_0);
+ rmesa->hw.cube[0].cmd[CUBE_CMD_1] = cmdpkt(R200_EMIT_PP_CUBIC_OFFSETS_0);
+ rmesa->hw.cube[1].cmd[CUBE_CMD_0] = cmdpkt(R200_EMIT_PP_CUBIC_FACES_1);
+ rmesa->hw.cube[1].cmd[CUBE_CMD_1] = cmdpkt(R200_EMIT_PP_CUBIC_OFFSETS_1);
+ rmesa->hw.cube[2].cmd[CUBE_CMD_0] = cmdpkt(R200_EMIT_PP_CUBIC_FACES_2);
+ rmesa->hw.cube[2].cmd[CUBE_CMD_1] = cmdpkt(R200_EMIT_PP_CUBIC_OFFSETS_2);
+ rmesa->hw.cube[3].cmd[CUBE_CMD_0] = cmdpkt(R200_EMIT_PP_CUBIC_FACES_3);
+ rmesa->hw.cube[3].cmd[CUBE_CMD_1] = cmdpkt(R200_EMIT_PP_CUBIC_OFFSETS_3);
+ rmesa->hw.cube[4].cmd[CUBE_CMD_0] = cmdpkt(R200_EMIT_PP_CUBIC_FACES_4);
+ rmesa->hw.cube[4].cmd[CUBE_CMD_1] = cmdpkt(R200_EMIT_PP_CUBIC_OFFSETS_4);
+ rmesa->hw.cube[5].cmd[CUBE_CMD_0] = cmdpkt(R200_EMIT_PP_CUBIC_FACES_5);
+ rmesa->hw.cube[5].cmd[CUBE_CMD_1] = cmdpkt(R200_EMIT_PP_CUBIC_OFFSETS_5);
+ rmesa->hw.pix[0].cmd[PIX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCBLEND_0);
+ rmesa->hw.pix[1].cmd[PIX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCBLEND_1);
+ rmesa->hw.pix[2].cmd[PIX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCBLEND_2);
+ rmesa->hw.pix[3].cmd[PIX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCBLEND_3);
+ rmesa->hw.pix[4].cmd[PIX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCBLEND_4);
+ rmesa->hw.pix[5].cmd[PIX_CMD_0] = cmdpkt(R200_EMIT_PP_TXCBLEND_5);
+ rmesa->hw.zbs.cmd[ZBS_CMD_0] = cmdpkt(RADEON_EMIT_SE_ZBIAS_FACTOR);
+ rmesa->hw.tcl.cmd[TCL_CMD_0] = cmdpkt(R200_EMIT_TCL_LIGHT_MODEL_CTL_0);
+ rmesa->hw.tcl.cmd[TCL_CMD_1] = cmdpkt(R200_EMIT_TCL_UCP_VERT_BLEND_CTL);
+ rmesa->hw.tcg.cmd[TCG_CMD_0] = cmdpkt(R200_EMIT_TEX_PROC_CTL_2);
+ rmesa->hw.msl.cmd[MSL_CMD_0] = cmdpkt(R200_EMIT_MATRIX_SELECT_0);
+ rmesa->hw.vap.cmd[VAP_CMD_0] = cmdpkt(R200_EMIT_VAP_CTL);
+ rmesa->hw.vtx.cmd[VTX_CMD_0] = cmdpkt(R200_EMIT_VTX_FMT_0);
+ rmesa->hw.vtx.cmd[VTX_CMD_1] = cmdpkt(R200_EMIT_OUTPUT_VTX_COMP_SEL);
+ rmesa->hw.vtx.cmd[VTX_CMD_2] = cmdpkt(R200_EMIT_SE_VTX_STATE_CNTL);
+ rmesa->hw.vte.cmd[VTE_CMD_0] = cmdpkt(R200_EMIT_VTE_CNTL);
+ rmesa->hw.prf.cmd[PRF_CMD_0] = cmdpkt(R200_EMIT_PP_TRI_PERF_CNTL);
+ rmesa->hw.mtl[0].cmd[MTL_CMD_0] =
+ cmdvec( R200_VS_MAT_0_EMISS, 1, 16 );
+ rmesa->hw.mtl[0].cmd[MTL_CMD_1] =
+ cmdscl2( R200_SS_MAT_0_SHININESS, 1, 1 );
+ rmesa->hw.mtl[1].cmd[MTL_CMD_0] =
+ cmdvec( R200_VS_MAT_1_EMISS, 1, 16 );
+ rmesa->hw.mtl[1].cmd[MTL_CMD_1] =
+ cmdscl2( R200_SS_MAT_1_SHININESS, 1, 1 );
+
+ rmesa->hw.grd.cmd[GRD_CMD_0] =
+ cmdscl( R200_SS_VERT_GUARD_CLIP_ADJ_ADDR, 1, 4 );
+ rmesa->hw.fog.cmd[FOG_CMD_0] =
+ cmdvec( R200_VS_FOG_PARAM_ADDR, 1, 4 );
+ rmesa->hw.glt.cmd[GLT_CMD_0] =
+ cmdvec( R200_VS_GLOBAL_AMBIENT_ADDR, 1, 4 );
+ rmesa->hw.eye.cmd[EYE_CMD_0] =
+ cmdvec( R200_VS_EYE_VECTOR_ADDR, 1, 4 );
+
+ rmesa->hw.mat[R200_MTX_MV].cmd[MAT_CMD_0] =
+ cmdvec( R200_VS_MATRIX_0_MV, 1, 16);
+ rmesa->hw.mat[R200_MTX_IMV].cmd[MAT_CMD_0] =
+ cmdvec( R200_VS_MATRIX_1_INV_MV, 1, 16);
+ rmesa->hw.mat[R200_MTX_MVP].cmd[MAT_CMD_0] =
+ cmdvec( R200_VS_MATRIX_2_MVP, 1, 16);
+ rmesa->hw.mat[R200_MTX_TEX0].cmd[MAT_CMD_0] =
+ cmdvec( R200_VS_MATRIX_3_TEX0, 1, 16);
+ rmesa->hw.mat[R200_MTX_TEX1].cmd[MAT_CMD_0] =
+ cmdvec( R200_VS_MATRIX_4_TEX1, 1, 16);
+ rmesa->hw.mat[R200_MTX_TEX2].cmd[MAT_CMD_0] =
+ cmdvec( R200_VS_MATRIX_5_TEX2, 1, 16);
+ rmesa->hw.mat[R200_MTX_TEX3].cmd[MAT_CMD_0] =
+ cmdvec( R200_VS_MATRIX_6_TEX3, 1, 16);
+ rmesa->hw.mat[R200_MTX_TEX4].cmd[MAT_CMD_0] =
+ cmdvec( R200_VS_MATRIX_7_TEX4, 1, 16);
+ rmesa->hw.mat[R200_MTX_TEX5].cmd[MAT_CMD_0] =
+ cmdvec( R200_VS_MATRIX_8_TEX5, 1, 16);
+
+ for (i = 0 ; i < 8; i++) {
+ rmesa->hw.lit[i].cmd[LIT_CMD_0] =
+ cmdvec( R200_VS_LIGHT_AMBIENT_ADDR + i, 8, 24 );
+ rmesa->hw.lit[i].cmd[LIT_CMD_1] =
+ cmdscl( R200_SS_LIGHT_DCD_ADDR + i, 8, 7 );
+ }
+
+ for (i = 0 ; i < 6; i++) {
+ rmesa->hw.ucp[i].cmd[UCP_CMD_0] =
+ cmdvec( R200_VS_UCP_ADDR + i, 1, 4 );
+ }
+
+ /* Initial Harware state:
+ */
+ rmesa->hw.ctx.cmd[CTX_PP_MISC] = (R200_ALPHA_TEST_PASS
+ /* | R200_RIGHT_HAND_CUBE_OGL*/);
+
+ rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] = (R200_FOG_VERTEX |
+ R200_FOG_USE_SPEC_ALPHA);
+
+ rmesa->hw.ctx.cmd[CTX_RE_SOLID_COLOR] = 0x00000000;
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] = (R200_COMB_FCN_ADD_CLAMP |
+ (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
+ (R200_BLEND_GL_ZERO << R200_DST_BLEND_SHIFT));
+
+ if (rmesa->r200Screen->drmSupportsBlendColor) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCOLOR] = 0x00000000;
+ rmesa->hw.ctx.cmd[CTX_RB3D_ABLENDCNTL] = (R200_COMB_FCN_ADD_CLAMP |
+ (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
+ (R200_BLEND_GL_ZERO << R200_DST_BLEND_SHIFT));
+ rmesa->hw.ctx.cmd[CTX_RB3D_CBLENDCNTL] = (R200_COMB_FCN_ADD_CLAMP |
+ (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
+ (R200_BLEND_GL_ZERO << R200_DST_BLEND_SHIFT));
+ }
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_DEPTHOFFSET] =
+ rmesa->r200Screen->depthOffset + rmesa->r200Screen->fbLocation;
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_DEPTHPITCH] =
+ ((rmesa->r200Screen->depthPitch &
+ R200_DEPTHPITCH_MASK) |
+ R200_DEPTH_ENDIAN_NO_SWAP);
+
+ if (rmesa->using_hyperz)
+ rmesa->hw.ctx.cmd[CTX_RB3D_DEPTHPITCH] |= R200_DEPTH_HYPERZ;
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] = (depth_fmt |
+ R200_Z_TEST_LESS |
+ R200_STENCIL_TEST_ALWAYS |
+ R200_STENCIL_FAIL_KEEP |
+ R200_STENCIL_ZPASS_KEEP |
+ R200_STENCIL_ZFAIL_KEEP |
+ R200_Z_WRITE_ENABLE);
+
+ if (rmesa->using_hyperz) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= R200_Z_COMPRESSION_ENABLE |
+ R200_Z_DECOMPRESSION_ENABLE;
+/* if (rmesa->r200Screen->chipset & R200_CHIPSET_REAL_R200)
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_Z_HIERARCHY_ENABLE;*/
+ }
+
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] = (R200_ANTI_ALIAS_NONE
+ | R200_TEX_BLEND_0_ENABLE);
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] = color_fmt;
+ switch ( driQueryOptioni( &rmesa->optionCache, "dither_mode" ) ) {
+ case DRI_CONF_DITHER_XERRORDIFFRESET:
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= R200_DITHER_INIT;
+ break;
+ case DRI_CONF_DITHER_ORDERED:
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= R200_SCALE_DITHER_ENABLE;
+ break;
+ }
+ if ( driQueryOptioni( &rmesa->optionCache, "round_mode" ) ==
+ DRI_CONF_ROUND_ROUND )
+ rmesa->state.color.roundEnable = R200_ROUND_ENABLE;
+ else
+ rmesa->state.color.roundEnable = 0;
+ if ( driQueryOptioni (&rmesa->optionCache, "color_reduction" ) ==
+ DRI_CONF_COLOR_REDUCTION_DITHER )
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= R200_DITHER_ENABLE;
+ else
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= rmesa->state.color.roundEnable;
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = ((rmesa->state.color.drawOffset +
+ rmesa->r200Screen->fbLocation)
+ & R200_COLOROFFSET_MASK);
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = ((rmesa->state.color.drawPitch &
+ R200_COLORPITCH_MASK) |
+ R200_COLOR_ENDIAN_NO_SWAP);
+ /* (fixed size) sarea is initialized to zero afaics so can omit version check. Phew! */
+ if (rmesa->sarea->tiling_enabled) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= R200_COLOR_TILE_ENABLE;
+ }
+
+ rmesa->hw.prf.cmd[PRF_PP_TRI_PERF] = R200_TRI_CUTOFF_MASK - R200_TRI_CUTOFF_MASK *
+ driQueryOptionf (&rmesa->optionCache,"texture_blend_quality");
+ rmesa->hw.prf.cmd[PRF_PP_PERF_CNTL] = 0;
+
+ rmesa->hw.set.cmd[SET_SE_CNTL] = (R200_FFACE_CULL_CCW |
+ R200_BFACE_SOLID |
+ R200_FFACE_SOLID |
+ R200_FLAT_SHADE_VTX_LAST |
+ R200_DIFFUSE_SHADE_GOURAUD |
+ R200_ALPHA_SHADE_GOURAUD |
+ R200_SPECULAR_SHADE_GOURAUD |
+ R200_FOG_SHADE_GOURAUD |
+ R200_VTX_PIX_CENTER_OGL |
+ R200_ROUND_MODE_TRUNC |
+ R200_ROUND_PREC_8TH_PIX);
+
+ rmesa->hw.set.cmd[SET_RE_CNTL] = (R200_PERSPECTIVE_ENABLE |
+ R200_SCISSOR_ENABLE);
+
+ rmesa->hw.lin.cmd[LIN_RE_LINE_PATTERN] = ((1 << 16) | 0xffff);
+
+ rmesa->hw.lin.cmd[LIN_RE_LINE_STATE] =
+ ((0 << R200_LINE_CURRENT_PTR_SHIFT) |
+ (1 << R200_LINE_CURRENT_COUNT_SHIFT));
+
+ rmesa->hw.lin.cmd[LIN_SE_LINE_WIDTH] = (1 << 4);
+
+ rmesa->hw.msk.cmd[MSK_RB3D_STENCILREFMASK] =
+ ((0x00 << R200_STENCIL_REF_SHIFT) |
+ (0xff << R200_STENCIL_MASK_SHIFT) |
+ (0xff << R200_STENCIL_WRITEMASK_SHIFT));
+
+ rmesa->hw.msk.cmd[MSK_RB3D_ROPCNTL] = R200_ROP_COPY;
+ rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK] = 0xffffffff;
+
+ rmesa->hw.tam.cmd[TAM_DEBUG3] = 0;
+
+ rmesa->hw.msc.cmd[MSC_RE_MISC] =
+ ((0 << R200_STIPPLE_X_OFFSET_SHIFT) |
+ (0 << R200_STIPPLE_Y_OFFSET_SHIFT) |
+ R200_STIPPLE_BIG_BIT_ORDER);
+
+
+ rmesa->hw.cst.cmd[CST_PP_CNTL_X] = 0;
+ rmesa->hw.cst.cmd[CST_RB3D_DEPTHXY_OFFSET] = 0;
+ rmesa->hw.cst.cmd[CST_RE_AUX_SCISSOR_CNTL] = 0x0;
+ rmesa->hw.cst.cmd[CST_RE_SCISSOR_TL_0] = 0;
+ rmesa->hw.cst.cmd[CST_RE_SCISSOR_BR_0] = 0;
+ rmesa->hw.cst.cmd[CST_SE_VAP_CNTL_STATUS] =
+#ifdef MESA_BIG_ENDIAN
+ R200_VC_32BIT_SWAP;
+#else
+ R200_VC_NO_SWAP;
+#endif
+
+ if (!(rmesa->r200Screen->chipset & R200_CHIPSET_TCL)) {
+ /* Bypass TCL */
+ rmesa->hw.cst.cmd[CST_SE_VAP_CNTL_STATUS] |= (1<<8);
+ }
+
+ rmesa->hw.cst.cmd[CST_RE_POINTSIZE] = 0x100010;
+ rmesa->hw.cst.cmd[CST_SE_TCL_INPUT_VTX_0] =
+ (0x0 << R200_VERTEX_POSITION_ADDR__SHIFT);
+ rmesa->hw.cst.cmd[CST_SE_TCL_INPUT_VTX_1] =
+ (0x02 << R200_VTX_COLOR_0_ADDR__SHIFT) |
+ (0x03 << R200_VTX_COLOR_1_ADDR__SHIFT);
+ rmesa->hw.cst.cmd[CST_SE_TCL_INPUT_VTX_2] =
+ (0x06 << R200_VTX_TEX_0_ADDR__SHIFT) |
+ (0x07 << R200_VTX_TEX_1_ADDR__SHIFT) |
+ (0x08 << R200_VTX_TEX_2_ADDR__SHIFT) |
+ (0x09 << R200_VTX_TEX_3_ADDR__SHIFT);
+ rmesa->hw.cst.cmd[CST_SE_TCL_INPUT_VTX_3] =
+ (0x0A << R200_VTX_TEX_4_ADDR__SHIFT) |
+ (0x0B << R200_VTX_TEX_5_ADDR__SHIFT);
+
+
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_XSCALE] = 0x00000000;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] = 0x00000000;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_YSCALE] = 0x00000000;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] = 0x00000000;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_ZSCALE] = 0x00000000;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_ZOFFSET] = 0x00000000;
+
+ for ( i = 0 ; i < ctx->Const.MaxTextureUnits ; i++ ) {
+ rmesa->hw.tex[i].cmd[TEX_PP_TXFILTER] = R200_BORDER_MODE_OGL;
+ rmesa->hw.tex[i].cmd[TEX_PP_TXFORMAT] =
+ ((i << R200_TXFORMAT_ST_ROUTE_SHIFT) | /* <-- note i */
+ (2 << R200_TXFORMAT_WIDTH_SHIFT) |
+ (2 << R200_TXFORMAT_HEIGHT_SHIFT));
+ rmesa->hw.tex[i].cmd[TEX_PP_TXOFFSET] =
+ rmesa->r200Screen->texOffset[RADEON_LOCAL_TEX_HEAP];
+ rmesa->hw.tex[i].cmd[TEX_PP_BORDER_COLOR] = 0;
+ rmesa->hw.tex[i].cmd[TEX_PP_TXFORMAT_X] =
+ (/* R200_TEXCOORD_PROJ | */
+ 0x100000); /* Small default bias */
+
+ rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_FACES] = 0;
+ rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_OFFSET_F1] =
+ rmesa->r200Screen->texOffset[RADEON_LOCAL_TEX_HEAP];
+ rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_OFFSET_F2] =
+ rmesa->r200Screen->texOffset[RADEON_LOCAL_TEX_HEAP];
+ rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_OFFSET_F3] =
+ rmesa->r200Screen->texOffset[RADEON_LOCAL_TEX_HEAP];
+ rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_OFFSET_F4] =
+ rmesa->r200Screen->texOffset[RADEON_LOCAL_TEX_HEAP];
+ rmesa->hw.cube[i].cmd[CUBE_PP_CUBIC_OFFSET_F5] =
+ rmesa->r200Screen->texOffset[RADEON_LOCAL_TEX_HEAP];
+
+ rmesa->hw.pix[i].cmd[PIX_PP_TXCBLEND] =
+ (R200_TXC_ARG_A_ZERO |
+ R200_TXC_ARG_B_ZERO |
+ R200_TXC_ARG_C_DIFFUSE_COLOR |
+ R200_TXC_OP_MADD);
+
+ rmesa->hw.pix[i].cmd[PIX_PP_TXCBLEND2] =
+ ((i << R200_TXC_TFACTOR_SEL_SHIFT) |
+ R200_TXC_SCALE_1X |
+ R200_TXC_CLAMP_0_1 |
+ R200_TXC_OUTPUT_REG_R0);
+
+ rmesa->hw.pix[i].cmd[PIX_PP_TXABLEND] =
+ (R200_TXA_ARG_A_ZERO |
+ R200_TXA_ARG_B_ZERO |
+ R200_TXA_ARG_C_DIFFUSE_ALPHA |
+ R200_TXA_OP_MADD);
+
+ rmesa->hw.pix[i].cmd[PIX_PP_TXABLEND2] =
+ ((i << R200_TXA_TFACTOR_SEL_SHIFT) |
+ R200_TXA_SCALE_1X |
+ R200_TXA_CLAMP_0_1 |
+ R200_TXA_OUTPUT_REG_R0);
+ }
+
+ rmesa->hw.tf.cmd[TF_TFACTOR_0] = 0;
+ rmesa->hw.tf.cmd[TF_TFACTOR_1] = 0;
+ rmesa->hw.tf.cmd[TF_TFACTOR_2] = 0;
+ rmesa->hw.tf.cmd[TF_TFACTOR_3] = 0;
+ rmesa->hw.tf.cmd[TF_TFACTOR_4] = 0;
+ rmesa->hw.tf.cmd[TF_TFACTOR_5] = 0;
+
+ rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] =
+ (R200_VAP_TCL_ENABLE |
+ (0x9 << R200_VAP_VF_MAX_VTX_NUM__SHIFT));
+
+ rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] =
+ (R200_VPORT_X_SCALE_ENA |
+ R200_VPORT_Y_SCALE_ENA |
+ R200_VPORT_Z_SCALE_ENA |
+ R200_VPORT_X_OFFSET_ENA |
+ R200_VPORT_Y_OFFSET_ENA |
+ R200_VPORT_Z_OFFSET_ENA |
+/* FIXME: Turn on for tex rect only */
+ R200_VTX_ST_DENORMALIZED |
+ R200_VTX_W0_FMT);
+
+
+ rmesa->hw.vtx.cmd[VTX_VTXFMT_0] = 0;
+ rmesa->hw.vtx.cmd[VTX_VTXFMT_1] = 0;
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_0] =
+ ((R200_VTX_Z0 | R200_VTX_W0 |
+ (R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT)));
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] = 0;
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_COMPSEL] = (R200_OUTPUT_XYZW);
+ rmesa->hw.vtx.cmd[VTX_STATE_CNTL] = R200_VSC_UPDATE_USER_COLOR_0_ENABLE;
+
+
+ /* Matrix selection */
+ rmesa->hw.msl.cmd[MSL_MATRIX_SELECT_0] =
+ (R200_MTX_MV << R200_MODELVIEW_0_SHIFT);
+
+ rmesa->hw.msl.cmd[MSL_MATRIX_SELECT_1] =
+ (R200_MTX_IMV << R200_IT_MODELVIEW_0_SHIFT);
+
+ rmesa->hw.msl.cmd[MSL_MATRIX_SELECT_2] =
+ (R200_MTX_MVP << R200_MODELPROJECT_0_SHIFT);
+
+ rmesa->hw.msl.cmd[MSL_MATRIX_SELECT_3] =
+ ((R200_MTX_TEX0 << R200_TEXMAT_0_SHIFT) |
+ (R200_MTX_TEX1 << R200_TEXMAT_1_SHIFT) |
+ (R200_MTX_TEX2 << R200_TEXMAT_2_SHIFT) |
+ (R200_MTX_TEX3 << R200_TEXMAT_3_SHIFT));
+
+ rmesa->hw.msl.cmd[MSL_MATRIX_SELECT_4] =
+ ((R200_MTX_TEX4 << R200_TEXMAT_4_SHIFT) |
+ (R200_MTX_TEX5 << R200_TEXMAT_5_SHIFT));
+
+
+ /* General TCL state */
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_0] =
+ (R200_SPECULAR_LIGHTS |
+ R200_DIFFUSE_SPECULAR_COMBINE |
+ R200_LOCAL_LIGHT_VEC_GL |
+ R200_LM0_SOURCE_MATERIAL_0 << R200_FRONT_SHININESS_SOURCE_SHIFT |
+ R200_LM0_SOURCE_MATERIAL_1 << R200_BACK_SHININESS_SOURCE_SHIFT);
+
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL_1] =
+ ((R200_LM1_SOURCE_MATERIAL_0 << R200_FRONT_EMISSIVE_SOURCE_SHIFT) |
+ (R200_LM1_SOURCE_MATERIAL_0 << R200_FRONT_AMBIENT_SOURCE_SHIFT) |
+ (R200_LM1_SOURCE_MATERIAL_0 << R200_FRONT_DIFFUSE_SOURCE_SHIFT) |
+ (R200_LM1_SOURCE_MATERIAL_0 << R200_FRONT_SPECULAR_SOURCE_SHIFT) |
+ (R200_LM1_SOURCE_MATERIAL_1 << R200_BACK_EMISSIVE_SOURCE_SHIFT) |
+ (R200_LM1_SOURCE_MATERIAL_1 << R200_BACK_AMBIENT_SOURCE_SHIFT) |
+ (R200_LM1_SOURCE_MATERIAL_1 << R200_BACK_DIFFUSE_SOURCE_SHIFT) |
+ (R200_LM1_SOURCE_MATERIAL_1 << R200_BACK_SPECULAR_SOURCE_SHIFT));
+
+ rmesa->hw.tcl.cmd[TCL_PER_LIGHT_CTL_0] = 0; /* filled in via callbacks */
+ rmesa->hw.tcl.cmd[TCL_PER_LIGHT_CTL_1] = 0;
+ rmesa->hw.tcl.cmd[TCL_PER_LIGHT_CTL_2] = 0;
+ rmesa->hw.tcl.cmd[TCL_PER_LIGHT_CTL_3] = 0;
+
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] =
+ (R200_UCP_IN_CLIP_SPACE |
+ R200_CULL_FRONT_IS_CCW);
+
+ /* Texgen/Texmat state */
+ rmesa->hw.tcg.cmd[TCG_TEX_PROC_CTL_2] = 0x00ffffff;
+ rmesa->hw.tcg.cmd[TCG_TEX_PROC_CTL_3] =
+ ((0 << R200_TEXGEN_0_INPUT_TEX_SHIFT) |
+ (1 << R200_TEXGEN_1_INPUT_TEX_SHIFT) |
+ (2 << R200_TEXGEN_2_INPUT_TEX_SHIFT) |
+ (3 << R200_TEXGEN_3_INPUT_TEX_SHIFT) |
+ (4 << R200_TEXGEN_4_INPUT_TEX_SHIFT) |
+ (5 << R200_TEXGEN_5_INPUT_TEX_SHIFT));
+ rmesa->hw.tcg.cmd[TCG_TEX_PROC_CTL_0] = 0;
+ rmesa->hw.tcg.cmd[TCG_TEX_PROC_CTL_1] =
+ ((0 << R200_TEXGEN_0_INPUT_SHIFT) |
+ (1 << R200_TEXGEN_1_INPUT_SHIFT) |
+ (2 << R200_TEXGEN_2_INPUT_SHIFT) |
+ (3 << R200_TEXGEN_3_INPUT_SHIFT) |
+ (4 << R200_TEXGEN_4_INPUT_SHIFT) |
+ (5 << R200_TEXGEN_5_INPUT_SHIFT));
+ rmesa->hw.tcg.cmd[TCG_TEX_CYL_WRAP_CTL] = 0;
+
+
+ for (i = 0 ; i < 8; i++) {
+ struct gl_light *l = &ctx->Light.Light[i];
+ GLenum p = GL_LIGHT0 + i;
+ *(float *)&(rmesa->hw.lit[i].cmd[LIT_RANGE_CUTOFF]) = FLT_MAX;
+
+ ctx->Driver.Lightfv( ctx, p, GL_AMBIENT, l->Ambient );
+ ctx->Driver.Lightfv( ctx, p, GL_DIFFUSE, l->Diffuse );
+ ctx->Driver.Lightfv( ctx, p, GL_SPECULAR, l->Specular );
+ ctx->Driver.Lightfv( ctx, p, GL_POSITION, NULL );
+ ctx->Driver.Lightfv( ctx, p, GL_SPOT_DIRECTION, NULL );
+ ctx->Driver.Lightfv( ctx, p, GL_SPOT_EXPONENT, &l->SpotExponent );
+ ctx->Driver.Lightfv( ctx, p, GL_SPOT_CUTOFF, &l->SpotCutoff );
+ ctx->Driver.Lightfv( ctx, p, GL_CONSTANT_ATTENUATION,
+ &l->ConstantAttenuation );
+ ctx->Driver.Lightfv( ctx, p, GL_LINEAR_ATTENUATION,
+ &l->LinearAttenuation );
+ ctx->Driver.Lightfv( ctx, p, GL_QUADRATIC_ATTENUATION,
+ &l->QuadraticAttenuation );
+ *(float *)&(rmesa->hw.lit[i].cmd[LIT_ATTEN_XXX]) = 0.0;
+ }
+
+ ctx->Driver.LightModelfv( ctx, GL_LIGHT_MODEL_AMBIENT,
+ ctx->Light.Model.Ambient );
+
+ TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx );
+
+ for (i = 0 ; i < 6; i++) {
+ ctx->Driver.ClipPlane( ctx, GL_CLIP_PLANE0 + i, NULL );
+ }
+
+ ctx->Driver.Fogfv( ctx, GL_FOG_MODE, NULL );
+ ctx->Driver.Fogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );
+ ctx->Driver.Fogfv( ctx, GL_FOG_START, &ctx->Fog.Start );
+ ctx->Driver.Fogfv( ctx, GL_FOG_END, &ctx->Fog.End );
+ ctx->Driver.Fogfv( ctx, GL_FOG_COLOR, ctx->Fog.Color );
+ ctx->Driver.Fogfv( ctx, GL_FOG_COORDINATE_SOURCE_EXT, NULL );
+
+ rmesa->hw.grd.cmd[GRD_VERT_GUARD_CLIP_ADJ] = IEEE_ONE;
+ rmesa->hw.grd.cmd[GRD_VERT_GUARD_DISCARD_ADJ] = IEEE_ONE;
+ rmesa->hw.grd.cmd[GRD_HORZ_GUARD_CLIP_ADJ] = IEEE_ONE;
+ rmesa->hw.grd.cmd[GRD_HORZ_GUARD_DISCARD_ADJ] = IEEE_ONE;
+
+ rmesa->hw.eye.cmd[EYE_X] = 0;
+ rmesa->hw.eye.cmd[EYE_Y] = 0;
+ rmesa->hw.eye.cmd[EYE_Z] = IEEE_ONE;
+ rmesa->hw.eye.cmd[EYE_RESCALE_FACTOR] = IEEE_ONE;
+
+ r200LightingSpaceChange( ctx );
+
+ rmesa->hw.all_dirty = GL_TRUE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_swtcl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_swtcl.c
new file mode 100644
index 000000000..94b4978fa
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_swtcl.c
@@ -0,0 +1,957 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_swtcl.c,v 1.5 2003/05/06 23:52:08 daenzer Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "colormac.h"
+#include "enums.h"
+#include "image.h"
+#include "imports.h"
+#include "macros.h"
+
+#include "swrast/s_context.h"
+#include "swrast/s_fog.h"
+#include "swrast_setup/swrast_setup.h"
+#include "math/m_translate.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+#include "tnl/t_vtx_api.h"
+
+#include "r200_context.h"
+#include "r200_ioctl.h"
+#include "r200_state.h"
+#include "r200_swtcl.h"
+#include "r200_tcl.h"
+
+
+static void flush_last_swtcl_prim( r200ContextPtr rmesa );
+
+
+/***********************************************************************
+ * Initialization
+ ***********************************************************************/
+
+#define EMIT_ATTR( ATTR, STYLE, F0 ) \
+do { \
+ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].attrib = (ATTR); \
+ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].format = (STYLE); \
+ rmesa->swtcl.vertex_attr_count++; \
+ fmt_0 |= F0; \
+} while (0)
+
+#define EMIT_PAD( N ) \
+do { \
+ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].attrib = 0; \
+ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].format = EMIT_PAD; \
+ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].offset = (N); \
+ rmesa->swtcl.vertex_attr_count++; \
+} while (0)
+
+static void r200SetVertexFormat( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint index = tnl->render_inputs;
+ int fmt_0 = 0;
+ int fmt_1 = 0;
+ int offset = 0;
+
+
+ /* Important:
+ */
+ if ( VB->NdcPtr != NULL ) {
+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
+ }
+ else {
+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->ClipPtr;
+ }
+
+ assert( VB->AttribPtr[VERT_ATTRIB_POS] != NULL );
+ rmesa->swtcl.vertex_attr_count = 0;
+
+ /* EMIT_ATTR's must be in order as they tell t_vertex.c how to
+ * build up a hardware vertex.
+ */
+ if ( !rmesa->swtcl.needproj || (index & _TNL_BITS_TEX_ANY)) { /* need w coord for projected textures */
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F, R200_VTX_XY | R200_VTX_Z0 | R200_VTX_W0 );
+ offset = 4;
+ }
+ else {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F, R200_VTX_XY | R200_VTX_Z0 );
+ offset = 3;
+ }
+
+ rmesa->swtcl.coloroffset = offset;
+#if MESA_LITTLE_ENDIAN
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_RGBA, (R200_VTX_PK_RGBA << R200_VTX_COLOR_0_SHIFT) );
+#else
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_ABGR, (R200_VTX_PK_RGBA << R200_VTX_COLOR_0_SHIFT) );
+#endif
+ offset += 1;
+
+ rmesa->swtcl.specoffset = 0;
+ if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) {
+
+#if MESA_LITTLE_ENDIAN
+ if (index & _TNL_BIT_COLOR1) {
+ rmesa->swtcl.specoffset = offset;
+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_RGB, (R200_VTX_PK_RGBA << R200_VTX_COLOR_1_SHIFT) );
+ }
+ else {
+ EMIT_PAD( 3 );
+ }
+
+ if (index & _TNL_BIT_FOG) {
+ EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, (R200_VTX_PK_RGBA << R200_VTX_COLOR_1_SHIFT) );
+ }
+ else {
+ EMIT_PAD( 1 );
+ }
+#else
+ if (index & _TNL_BIT_FOG) {
+ EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, (R200_VTX_PK_RGBA << R200_VTX_COLOR_1_SHIFT) );
+ }
+ else {
+ EMIT_PAD( 1 );
+ }
+
+ if (index & _TNL_BIT_COLOR1) {
+ rmesa->swtcl.specoffset = offset;
+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, (R200_VTX_PK_RGBA << R200_VTX_COLOR_1_SHIFT) );
+ }
+ else {
+ EMIT_PAD( 3 );
+ }
+#endif
+ }
+
+ if (index & _TNL_BITS_TEX_ANY) {
+ int i;
+
+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+ if (index & _TNL_BIT_TEX(i)) {
+ GLuint sz = VB->TexCoordPtr[i]->size;
+
+ fmt_1 |= sz << (3 * i);
+ EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_1F + sz - 1, 0 );
+ }
+ }
+ }
+
+ if ( (rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] & R200_FOG_USE_MASK)
+ != R200_FOG_USE_SPEC_ALPHA ) {
+ R200_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] &= ~R200_FOG_USE_MASK;
+ rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] |= R200_FOG_USE_SPEC_ALPHA;
+ }
+
+ if ( rmesa->tnl_index != index ||
+ (rmesa->hw.vtx.cmd[VTX_VTXFMT_0] != fmt_0) ||
+ (rmesa->hw.vtx.cmd[VTX_VTXFMT_1] != fmt_1) ) {
+ R200_NEWPRIM(rmesa);
+ R200_STATECHANGE( rmesa, vtx );
+ rmesa->hw.vtx.cmd[VTX_VTXFMT_0] = fmt_0;
+ rmesa->hw.vtx.cmd[VTX_VTXFMT_1] = fmt_1;
+
+ rmesa->swtcl.vertex_size =
+ _tnl_install_attrs( ctx,
+ rmesa->swtcl.vertex_attrs,
+ rmesa->swtcl.vertex_attr_count,
+ NULL, 0 );
+ rmesa->swtcl.vertex_size /= 4;
+ rmesa->tnl_index = index;
+ }
+}
+
+
+static void r200RenderStart( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT( ctx );
+
+ r200SetVertexFormat( ctx );
+
+ if (rmesa->dma.flush != 0 &&
+ rmesa->dma.flush != flush_last_swtcl_prim)
+ rmesa->dma.flush( rmesa );
+}
+
+
+/**
+ * Set vertex state for SW TCL. The primary purpose of this function is to
+ * determine in advance whether or not the hardware can / should do the
+ * projection divide or Mesa should do it.
+ */
+void r200ChooseVertexState( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint vte;
+ GLuint vap;
+
+ /* We must ensure that we don't do _tnl_need_projected_coords while in a
+ * rasterization fallback. As this function will be called again when we
+ * leave a rasterization fallback, we can just skip it for now.
+ */
+ if (rmesa->Fallback != 0)
+ return;
+
+ vte = rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL];
+ vap = rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL];
+
+ /* HW perspective divide is a win, but tiny vertex formats are a
+ * bigger one.
+ */
+ if ( ((tnl->render_inputs & _TNL_BITS_TEX_ANY) == 0)
+ || (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ rmesa->swtcl.needproj = GL_TRUE;
+ vte |= R200_VTX_XY_FMT | R200_VTX_Z_FMT;
+ vte &= ~R200_VTX_W0_FMT;
+ if (tnl->render_inputs & _TNL_BITS_TEX_ANY) {
+ vap &= ~R200_VAP_FORCE_W_TO_ONE;
+ }
+ else {
+ vap |= R200_VAP_FORCE_W_TO_ONE;
+ }
+ }
+ else {
+ rmesa->swtcl.needproj = GL_FALSE;
+ vte &= ~(R200_VTX_XY_FMT | R200_VTX_Z_FMT);
+ vte |= R200_VTX_W0_FMT;
+ vap &= ~R200_VAP_FORCE_W_TO_ONE;
+ }
+
+ _tnl_need_projected_coords( ctx, rmesa->swtcl.needproj );
+
+ if (vte != rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL]) {
+ R200_STATECHANGE( rmesa, vte );
+ rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] = vte;
+ }
+
+ if (vap != rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL]) {
+ R200_STATECHANGE( rmesa, vap );
+ rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] = vap;
+ }
+}
+
+
+/* Flush vertices in the current dma region.
+ */
+static void flush_last_swtcl_prim( r200ContextPtr rmesa )
+{
+ if (R200_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ rmesa->dma.flush = NULL;
+
+ if (rmesa->dma.current.buf) {
+ struct r200_dma_region *current = &rmesa->dma.current;
+ GLuint current_offset = (rmesa->r200Screen->gart_buffer_offset +
+ current->buf->buf->idx * RADEON_BUFFER_SIZE +
+ current->start);
+
+ assert (!(rmesa->swtcl.hw_primitive & R200_VF_PRIM_WALK_IND));
+
+ assert (current->start +
+ rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
+ current->ptr);
+
+ if (rmesa->dma.current.start != rmesa->dma.current.ptr) {
+ r200EnsureCmdBufSpace( rmesa, VERT_AOS_BUFSZ +
+ rmesa->hw.max_state_size + VBUF_BUFSZ );
+ r200EmitVertexAOS( rmesa,
+ rmesa->swtcl.vertex_size,
+ current_offset);
+
+ r200EmitVbufPrim( rmesa,
+ rmesa->swtcl.hw_primitive,
+ rmesa->swtcl.numverts);
+ }
+
+ rmesa->swtcl.numverts = 0;
+ current->start = current->ptr;
+ }
+}
+
+
+/* Alloc space in the current dma region.
+ */
+static __inline void *r200AllocDmaLowVerts( r200ContextPtr rmesa,
+ int nverts, int vsize )
+{
+ GLuint bytes = vsize * nverts;
+
+ if ( rmesa->dma.current.ptr + bytes > rmesa->dma.current.end )
+ r200RefillCurrentDmaRegion( rmesa );
+
+ if (!rmesa->dma.flush) {
+ rmesa->glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
+ rmesa->dma.flush = flush_last_swtcl_prim;
+ }
+
+ ASSERT( vsize == rmesa->swtcl.vertex_size * 4 );
+ ASSERT( rmesa->dma.flush == flush_last_swtcl_prim );
+ ASSERT( rmesa->dma.current.start +
+ rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
+ rmesa->dma.current.ptr );
+
+
+ {
+ GLubyte *head = (GLubyte *) (rmesa->dma.current.address + rmesa->dma.current.ptr);
+ rmesa->dma.current.ptr += bytes;
+ rmesa->swtcl.numverts += nverts;
+ return head;
+ }
+
+}
+
+
+/**************************************************************************/
+
+
+static const GLuint reduced_hw_prim[GL_POLYGON+1] = {
+ R200_VF_PRIM_POINTS,
+ R200_VF_PRIM_LINES,
+ R200_VF_PRIM_LINES,
+ R200_VF_PRIM_LINES,
+ R200_VF_PRIM_TRIANGLES,
+ R200_VF_PRIM_TRIANGLES,
+ R200_VF_PRIM_TRIANGLES,
+ R200_VF_PRIM_TRIANGLES,
+ R200_VF_PRIM_TRIANGLES,
+ R200_VF_PRIM_TRIANGLES
+};
+
+static void r200RasterPrimitive( GLcontext *ctx, GLuint hwprim );
+static void r200RenderPrimitive( GLcontext *ctx, GLenum prim );
+static void r200ResetLineStipple( GLcontext *ctx );
+
+/***********************************************************************
+ * Emit primitives as inline vertices *
+ ***********************************************************************/
+
+#define HAVE_POINTS 1
+#define HAVE_LINES 1
+#define HAVE_LINE_STRIPS 1
+#define HAVE_TRIANGLES 1
+#define HAVE_TRI_STRIPS 1
+#define HAVE_TRI_STRIP_1 0
+#define HAVE_TRI_FANS 1
+#define HAVE_QUADS 0
+#define HAVE_QUAD_STRIPS 0
+#define HAVE_POLYGONS 1
+#define HAVE_ELTS 0
+
+#undef LOCAL_VARS
+#undef ALLOC_VERTS
+#define CTX_ARG r200ContextPtr rmesa
+#define GET_VERTEX_DWORDS() rmesa->swtcl.vertex_size
+#define ALLOC_VERTS( n, size ) r200AllocDmaLowVerts( rmesa, n, size * 4 )
+#define LOCAL_VARS \
+ r200ContextPtr rmesa = R200_CONTEXT(ctx); \
+ const char *r200verts = (char *)rmesa->swtcl.verts;
+#define VERT(x) (r200Vertex *)(r200verts + ((x) * vertsize * sizeof(int)))
+#define VERTEX r200Vertex
+#define DO_DEBUG_VERTS (1 && (R200_DEBUG & DEBUG_VERTS))
+
+#undef TAG
+#define TAG(x) r200_##x
+#include "tnl_dd/t_dd_triemit.h"
+
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define QUAD( a, b, c, d ) r200_quad( rmesa, a, b, c, d )
+#define TRI( a, b, c ) r200_triangle( rmesa, a, b, c )
+#define LINE( a, b ) r200_line( rmesa, a, b )
+#define POINT( a ) r200_point( rmesa, a )
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define R200_TWOSIDE_BIT 0x01
+#define R200_UNFILLED_BIT 0x02
+#define R200_MAX_TRIFUNC 0x04
+
+
+static struct {
+ tnl_points_func points;
+ tnl_line_func line;
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
+} rast_tab[R200_MAX_TRIFUNC];
+
+
+#define DO_FALLBACK 0
+#define DO_UNFILLED (IND & R200_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & R200_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_OFFSET 0
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 1
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define TAB rast_tab
+
+#define DEPTH_SCALE 1.0
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a < 0)
+#define GET_VERTEX(e) (rmesa->swtcl.verts + (e*rmesa->swtcl.vertex_size*sizeof(int)))
+
+#define VERT_SET_RGBA( v, c ) \
+do { \
+ r200_color_t *color = (r200_color_t *)&((v)->ui[coloroffset]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \
+} while (0)
+
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+
+#define VERT_SET_SPEC( v, c ) \
+do { \
+ if (specoffset) { \
+ r200_color_t *spec = (r200_color_t *)&((v)->ui[specoffset]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(spec->red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(spec->green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(spec->blue, (c)[2]); \
+ } \
+} while (0)
+#define VERT_COPY_SPEC( v0, v1 ) \
+do { \
+ if (specoffset) { \
+ r200_color_t *spec0 = (r200_color_t *)&((v0)->ui[specoffset]); \
+ r200_color_t *spec1 = (r200_color_t *)&((v1)->ui[specoffset]); \
+ spec0->red = spec1->red; \
+ spec0->green = spec1->green; \
+ spec0->blue = spec1->blue; \
+ } \
+} while (0)
+
+/* These don't need LE32_TO_CPU() as they used to save and restore
+ * colors which are already in the correct format.
+ */
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
+#define VERT_SAVE_SPEC( idx ) if (specoffset) spec[idx] = v[idx]->ui[specoffset]
+#define VERT_RESTORE_SPEC( idx ) if (specoffset) v[idx]->ui[specoffset] = spec[idx]
+
+#undef LOCAL_VARS
+#undef TAG
+#undef INIT
+
+#define LOCAL_VARS(n) \
+ r200ContextPtr rmesa = R200_CONTEXT(ctx); \
+ GLuint color[n], spec[n]; \
+ GLuint coloroffset = rmesa->swtcl.coloroffset; \
+ GLuint specoffset = rmesa->swtcl.specoffset; \
+ (void) color; (void) spec; (void) coloroffset; (void) specoffset;
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+#define RASTERIZE(x) r200RasterPrimitive( ctx, reduced_hw_prim[x] )
+#define RENDER_PRIMITIVE rmesa->swtcl.render_primitive
+#undef TAG
+#define TAG(x) x
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
+
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R200_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R200_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (R200_TWOSIDE_BIT|R200_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+static void init_rast_tab( void )
+{
+ init();
+ init_twoside();
+ init_unfilled();
+ init_twoside_unfilled();
+}
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ r200_point( rmesa, VERT(start) )
+#define RENDER_LINE( v0, v1 ) \
+ r200_line( rmesa, VERT(v0), VERT(v1) )
+#define RENDER_TRI( v0, v1, v2 ) \
+ r200_triangle( rmesa, VERT(v0), VERT(v1), VERT(v2) )
+#define RENDER_QUAD( v0, v1, v2, v3 ) \
+ r200_quad( rmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
+#define INIT(x) do { \
+ r200RenderPrimitive( ctx, x ); \
+} while (0)
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ r200ContextPtr rmesa = R200_CONTEXT(ctx); \
+ const GLuint vertsize = rmesa->swtcl.vertex_size; \
+ const char *r200verts = (char *)rmesa->swtcl.verts; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ const GLboolean stipple = ctx->Line.StippleFlag; \
+ (void) elt; (void) stipple;
+#define RESET_STIPPLE if ( stipple ) r200ResetLineStipple( ctx );
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) (x)
+#define TAG(x) r200_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+#undef ELT
+#undef TAG
+#define TAG(x) r200_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl/t_vb_rendertmp.h"
+
+
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+void r200ChooseRenderState( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint index = 0;
+ GLuint flags = ctx->_TriangleCaps;
+
+ if (!rmesa->TclFallback || rmesa->Fallback)
+ return;
+
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R200_TWOSIDE_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= R200_UNFILLED_BIT;
+
+ if (index != rmesa->swtcl.RenderIndex) {
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.ClippedLine = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = r200_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = r200_render_tab_elts;
+ tnl->Driver.Render.ClippedPolygon = r200_fast_clipped_poly;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon;
+ }
+
+ rmesa->swtcl.RenderIndex = index;
+ }
+}
+
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+
+static void r200RasterPrimitive( GLcontext *ctx, GLuint hwprim )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if (rmesa->swtcl.hw_primitive != hwprim) {
+ R200_NEWPRIM( rmesa );
+ rmesa->swtcl.hw_primitive = hwprim;
+ }
+}
+
+static void r200RenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ rmesa->swtcl.render_primitive = prim;
+ if (prim < GL_TRIANGLES || !(ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ r200RasterPrimitive( ctx, reduced_hw_prim[prim] );
+}
+
+static void r200RenderFinish( GLcontext *ctx )
+{
+}
+
+static void r200ResetLineStipple( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ R200_STATECHANGE( rmesa, lin );
+}
+
+
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+
+static const char * const fallbackStrings[] = {
+ "Texture mode",
+ "glDrawBuffer(GL_FRONT_AND_BACK)",
+ "glEnable(GL_STENCIL) without hw stencil buffer",
+ "glRenderMode(selection or feedback)",
+ "R200_NO_RAST",
+ "Mixing GL_CLAMP_TO_BORDER and GL_CLAMP (or GL_MIRROR_CLAMP_ATI)"
+};
+
+
+static const char *getFallbackString(GLuint bit)
+{
+ int i = 0;
+ while (bit > 1) {
+ i++;
+ bit >>= 1;
+ }
+ return fallbackStrings[i];
+}
+
+
+void r200Fallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldfallback = rmesa->Fallback;
+
+ if (mode) {
+ rmesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ R200_FIREVERTICES( rmesa );
+ TCL_FALLBACK( ctx, R200_TCL_FALLBACK_RASTER, GL_TRUE );
+ _swsetup_Wakeup( ctx );
+ rmesa->swtcl.RenderIndex = ~0;
+ if (R200_DEBUG & DEBUG_FALLBACKS) {
+ fprintf(stderr, "R200 begin rasterization fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ }
+ }
+ else {
+ rmesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = r200RenderStart;
+ tnl->Driver.Render.PrimitiveNotify = r200RenderPrimitive;
+ tnl->Driver.Render.Finish = r200RenderFinish;
+
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+
+ tnl->Driver.Render.ResetLineStipple = r200ResetLineStipple;
+ TCL_FALLBACK( ctx, R200_TCL_FALLBACK_RASTER, GL_FALSE );
+ if (rmesa->TclFallback) {
+ /* These are already done if rmesa->TclFallback goes to
+ * zero above. But not if it doesn't (R200_NO_TCL for
+ * example?)
+ */
+ r200ChooseVertexState( ctx );
+ r200ChooseRenderState( ctx );
+ }
+ if (R200_DEBUG & DEBUG_FALLBACKS) {
+ fprintf(stderr, "R200 end rasterization fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ }
+ }
+}
+
+
+
+
+/**
+ * Cope with depth operations by drawing individual pixels as points.
+ *
+ * \todo
+ * The way the vertex state is set in this routine is hokey. It seems to
+ * work, but it's very hackish. This whole routine is pretty hackish. If
+ * the bitmap is small enough, it seems like it would be faster to copy it
+ * to AGP memory and use it as a non-power-of-two texture (i.e.,
+ * NV_texture_rectangle).
+ */
+void
+r200PointsBitmap( GLcontext *ctx, GLint px, GLint py,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ const GLfloat *rc = ctx->Current.RasterColor;
+ GLint row, col;
+ r200Vertex vert;
+ GLuint orig_vte;
+ GLuint h;
+
+
+ /* Turn off tcl.
+ */
+ TCL_FALLBACK( ctx, R200_TCL_FALLBACK_BITMAP, 1 );
+
+ /* Choose tiny vertex format
+ */
+ {
+ const GLuint fmt_0 = R200_VTX_XY | R200_VTX_Z0 | R200_VTX_W0
+ | (R200_VTX_PK_RGBA << R200_VTX_COLOR_0_SHIFT);
+ const GLuint fmt_1 = 0;
+ GLuint vte = rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL];
+ GLuint vap = rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL];
+
+ vte &= ~(R200_VTX_XY_FMT | R200_VTX_Z_FMT);
+ vte |= R200_VTX_W0_FMT;
+ vap &= ~R200_VAP_FORCE_W_TO_ONE;
+
+ rmesa->swtcl.vertex_size = 5;
+
+ if ( (rmesa->hw.vtx.cmd[VTX_VTXFMT_0] != fmt_0)
+ || (rmesa->hw.vtx.cmd[VTX_VTXFMT_1] != fmt_1) ) {
+ R200_NEWPRIM(rmesa);
+ R200_STATECHANGE( rmesa, vtx );
+ rmesa->hw.vtx.cmd[VTX_VTXFMT_0] = fmt_0;
+ rmesa->hw.vtx.cmd[VTX_VTXFMT_1] = fmt_1;
+ }
+
+ if (vte != rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL]) {
+ R200_STATECHANGE( rmesa, vte );
+ rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] = vte;
+ }
+
+ if (vap != rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL]) {
+ R200_STATECHANGE( rmesa, vap );
+ rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] = vap;
+ }
+ }
+
+ /* Ready for point primitives:
+ */
+ r200RenderPrimitive( ctx, GL_POINTS );
+
+ /* Turn off the hw viewport transformation:
+ */
+ R200_STATECHANGE( rmesa, vte );
+ orig_vte = rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL];
+ rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] &= ~(R200_VPORT_X_SCALE_ENA |
+ R200_VPORT_Y_SCALE_ENA |
+ R200_VPORT_Z_SCALE_ENA |
+ R200_VPORT_X_OFFSET_ENA |
+ R200_VPORT_Y_OFFSET_ENA |
+ R200_VPORT_Z_OFFSET_ENA);
+
+ /* Turn off other stuff: Stipple?, texture?, blending?, etc.
+ */
+
+
+ /* Populate the vertex
+ *
+ * Incorporate FOG into RGBA
+ */
+ if (ctx->Fog.Enabled) {
+ const GLfloat *fc = ctx->Fog.Color;
+ GLfloat color[4];
+ GLfloat f;
+
+ if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
+ f = _swrast_z_to_fogfactor(ctx, ctx->Current.Attrib[VERT_ATTRIB_FOG][0]);
+ else
+ f = _swrast_z_to_fogfactor(ctx, ctx->Current.RasterDistance);
+
+ color[0] = f * rc[0] + (1.F - f) * fc[0];
+ color[1] = f * rc[1] + (1.F - f) * fc[1];
+ color[2] = f * rc[2] + (1.F - f) * fc[2];
+ color[3] = rc[3];
+
+ UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.red, color[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.green, color[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.blue, color[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.alpha, color[3]);
+ }
+ else {
+ UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.red, rc[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.green, rc[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.blue, rc[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(vert.tv.color.alpha, rc[3]);
+ }
+
+
+ vert.tv.z = ctx->Current.RasterPos[2];
+
+
+ /* Update window height
+ */
+ LOCK_HARDWARE( rmesa );
+ UNLOCK_HARDWARE( rmesa );
+ h = rmesa->dri.drawable->h + rmesa->dri.drawable->y;
+ px += rmesa->dri.drawable->x;
+
+ /* Clipping handled by existing mechansims in r200_ioctl.c?
+ */
+ for (row=0; row<height; row++) {
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address2d(unpack, bitmap, width, height,
+ GL_COLOR_INDEX, GL_BITMAP, row, 0 );
+
+ if (unpack->LsbFirst) {
+ /* Lsb first */
+ GLubyte mask = 1U << (unpack->SkipPixels & 0x7);
+ for (col=0; col<width; col++) {
+ if (*src & mask) {
+ vert.tv.x = px+col;
+ vert.tv.y = h - (py+row) - 1;
+ r200_point( rmesa, &vert );
+ }
+ src += (mask >> 7);
+ mask = ((mask << 1) & 0xff) | (mask >> 7);
+ }
+
+ /* get ready for next row */
+ if (mask != 1)
+ src++;
+ }
+ else {
+ /* Msb first */
+ GLubyte mask = 128U >> (unpack->SkipPixels & 0x7);
+ for (col=0; col<width; col++) {
+ if (*src & mask) {
+ vert.tv.x = px+col;
+ vert.tv.y = h - (py+row) - 1;
+ r200_point( rmesa, &vert );
+ }
+ src += mask & 1;
+ mask = ((mask << 7) & 0xff) | (mask >> 1);
+ }
+ /* get ready for next row */
+ if (mask != 128)
+ src++;
+ }
+ }
+
+ /* Fire outstanding vertices, restore state
+ */
+ R200_STATECHANGE( rmesa, vte );
+ rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] = orig_vte;
+
+ /* Unfallback
+ */
+ TCL_FALLBACK( ctx, R200_TCL_FALLBACK_BITMAP, 0 );
+
+ /* Need to restore vertexformat?
+ */
+ if (rmesa->TclFallback)
+ r200ChooseVertexState( ctx );
+}
+
+
+void r200FlushVertices( GLcontext *ctx, GLuint flags )
+{
+ _tnl_FlushVertices( ctx, flags );
+
+ if (flags & FLUSH_STORED_VERTICES)
+ R200_NEWPRIM( R200_CONTEXT( ctx ) );
+}
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+void r200InitSwtcl( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+ }
+
+ tnl->Driver.Render.Start = r200RenderStart;
+ tnl->Driver.Render.Finish = r200RenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = r200RenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = r200ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+
+ /* FIXME: what are these numbers? */
+ _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
+ 36 * sizeof(GLfloat) );
+
+ rmesa->swtcl.verts = (GLubyte *)tnl->clipspace.vertex_buf;
+ rmesa->swtcl.RenderIndex = ~0;
+ rmesa->swtcl.render_primitive = GL_TRIANGLES;
+ rmesa->swtcl.hw_primitive = 0;
+}
+
+
+void r200DestroySwtcl( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if (rmesa->swtcl.indexed_verts.buf)
+ r200ReleaseDmaRegion( rmesa, &rmesa->swtcl.indexed_verts, __FUNCTION__ );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_swtcl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_swtcl.h
new file mode 100644
index 000000000..ce2b6b5f0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_swtcl.h
@@ -0,0 +1,76 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_swtcl.h,v 1.3 2003/05/06 23:52:08 daenzer Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R200_SWTCL_H__
+#define __R200_SWTCL_H__
+
+#include "mtypes.h"
+#include "swrast/swrast.h"
+#include "r200_context.h"
+
+extern void r200InitSwtcl( GLcontext *ctx );
+extern void r200DestroySwtcl( GLcontext *ctx );
+
+extern void r200FlushVertices( GLcontext *ctx, GLuint flags );
+extern void r200ChooseRenderState( GLcontext *ctx );
+extern void r200ChooseVertexState( GLcontext *ctx );
+
+extern void r200CheckTexSizes( GLcontext *ctx );
+
+extern void r200BuildVertices( GLcontext *ctx, GLuint start, GLuint count,
+ GLuint newinputs );
+
+extern void r200PrintSetupFlags(char *msg, GLuint flags );
+
+
+extern void r200_emit_indexed_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count );
+
+extern void r200_translate_vertex( GLcontext *ctx,
+ const r200Vertex *src,
+ SWvertex *dst );
+
+extern void r200_print_vertex( GLcontext *ctx, const r200Vertex *v );
+
+extern void r200_import_float_colors( GLcontext *ctx );
+extern void r200_import_float_spec_colors( GLcontext *ctx );
+
+extern void r200PointsBitmap( GLcontext *ctx, GLint px, GLint py,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_tcl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_tcl.c
new file mode 100644
index 000000000..05c658fbe
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_tcl.c
@@ -0,0 +1,583 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tcl.c,v 1.2 2002/12/16 16:18:55 dawes Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "enums.h"
+#include "colormac.h"
+#include "light.h"
+
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+
+#include "r200_context.h"
+#include "r200_state.h"
+#include "r200_ioctl.h"
+#include "r200_tex.h"
+#include "r200_tcl.h"
+#include "r200_swtcl.h"
+#include "r200_maos.h"
+
+
+
+#define HAVE_POINTS 1
+#define HAVE_LINES 1
+#define HAVE_LINE_LOOP 0
+#define HAVE_LINE_STRIPS 1
+#define HAVE_TRIANGLES 1
+#define HAVE_TRI_STRIPS 1
+#define HAVE_TRI_STRIP_1 0
+#define HAVE_TRI_FANS 1
+#define HAVE_QUADS 1
+#define HAVE_QUAD_STRIPS 1
+#define HAVE_POLYGONS 1
+#define HAVE_ELTS 1
+
+
+#define HW_POINTS R200_VF_PRIM_POINTS
+#define HW_LINES R200_VF_PRIM_LINES
+#define HW_LINE_LOOP 0
+#define HW_LINE_STRIP R200_VF_PRIM_LINE_STRIP
+#define HW_TRIANGLES R200_VF_PRIM_TRIANGLES
+#define HW_TRIANGLE_STRIP_0 R200_VF_PRIM_TRIANGLE_STRIP
+#define HW_TRIANGLE_STRIP_1 0
+#define HW_TRIANGLE_FAN R200_VF_PRIM_TRIANGLE_FAN
+#define HW_QUADS R200_VF_PRIM_QUADS
+#define HW_QUAD_STRIP R200_VF_PRIM_QUAD_STRIP
+#define HW_POLYGON R200_VF_PRIM_POLYGON
+
+
+static GLboolean discrete_prim[0x10] = {
+ 0, /* 0 none */
+ 1, /* 1 points */
+ 1, /* 2 lines */
+ 0, /* 3 line_strip */
+ 1, /* 4 tri_list */
+ 0, /* 5 tri_fan */
+ 0, /* 6 tri_strip */
+ 0, /* 7 tri_w_flags */
+ 1, /* 8 rect list (unused) */
+ 1, /* 9 3vert point */
+ 1, /* a 3vert line */
+ 0, /* b point sprite */
+ 0, /* c line loop */
+ 1, /* d quads */
+ 0, /* e quad strip */
+ 0, /* f polygon */
+};
+
+
+#define LOCAL_VARS r200ContextPtr rmesa = R200_CONTEXT(ctx)
+#define ELT_TYPE GLushort
+
+#define ELT_INIT(prim, hw_prim) \
+ r200TclPrimitive( ctx, prim, hw_prim | R200_VF_PRIM_WALK_IND )
+
+#define GET_MESA_ELTS() rmesa->tcl.Elts
+
+
+/* Don't really know how many elts will fit in what's left of cmdbuf,
+ * as there is state to emit, etc:
+ */
+
+/* Testing on isosurf shows a maximum around here. Don't know if it's
+ * the card or driver or kernel module that is causing the behaviour.
+ */
+#define GET_MAX_HW_ELTS() 300
+
+#define RESET_STIPPLE() do { \
+ R200_STATECHANGE( rmesa, lin ); \
+ r200EmitState( rmesa ); \
+} while (0)
+
+#define AUTO_STIPPLE( mode ) do { \
+ R200_STATECHANGE( rmesa, lin ); \
+ if (mode) \
+ rmesa->hw.lin.cmd[LIN_RE_LINE_PATTERN] |= \
+ R200_LINE_PATTERN_AUTO_RESET; \
+ else \
+ rmesa->hw.lin.cmd[LIN_RE_LINE_PATTERN] &= \
+ ~R200_LINE_PATTERN_AUTO_RESET; \
+ r200EmitState( rmesa ); \
+} while (0)
+
+
+#define ALLOC_ELTS(nr) r200AllocElts( rmesa, nr )
+
+static GLushort *r200AllocElts( r200ContextPtr rmesa, GLuint nr )
+{
+ if (rmesa->dma.flush == r200FlushElts &&
+ rmesa->store.cmd_used + nr*2 < R200_CMD_BUF_SZ) {
+
+ GLushort *dest = (GLushort *)(rmesa->store.cmd_buf +
+ rmesa->store.cmd_used);
+
+ rmesa->store.cmd_used += nr*2;
+
+ return dest;
+ }
+ else {
+ if (rmesa->dma.flush)
+ rmesa->dma.flush( rmesa );
+
+ r200EnsureCmdBufSpace( rmesa, AOS_BUFSZ(rmesa->tcl.nr_aos_components) +
+ rmesa->hw.max_state_size + ELTS_BUFSZ(nr) );
+
+ r200EmitAOS( rmesa,
+ rmesa->tcl.aos_components,
+ rmesa->tcl.nr_aos_components, 0 );
+
+ return r200AllocEltsOpenEnded( rmesa, rmesa->tcl.hw_primitive, nr );
+ }
+}
+
+
+#define CLOSE_ELTS() \
+do { \
+ if (0) R200_NEWPRIM( rmesa ); \
+} \
+while (0)
+
+
+/* TODO: Try to extend existing primitive if both are identical,
+ * discrete and there are no intervening state changes. (Somewhat
+ * duplicates changes to DrawArrays code)
+ */
+static void r200EmitPrim( GLcontext *ctx,
+ GLenum prim,
+ GLuint hwprim,
+ GLuint start,
+ GLuint count)
+{
+ r200ContextPtr rmesa = R200_CONTEXT( ctx );
+ r200TclPrimitive( ctx, prim, hwprim );
+
+ r200EnsureCmdBufSpace( rmesa, AOS_BUFSZ(rmesa->tcl.nr_aos_components) +
+ rmesa->hw.max_state_size + VBUF_BUFSZ );
+
+ r200EmitAOS( rmesa,
+ rmesa->tcl.aos_components,
+ rmesa->tcl.nr_aos_components,
+ start );
+
+ /* Why couldn't this packet have taken an offset param?
+ */
+ r200EmitVbufPrim( rmesa,
+ rmesa->tcl.hw_primitive,
+ count - start );
+}
+
+#define EMIT_PRIM(ctx, prim, hwprim, start, count) do { \
+ r200EmitPrim( ctx, prim, hwprim, start, count ); \
+ (void) rmesa; } while (0)
+
+/* Try & join small primitives
+ */
+#if 0
+#define PREFER_DISCRETE_ELT_PRIM( NR, PRIM ) 0
+#else
+#define PREFER_DISCRETE_ELT_PRIM( NR, PRIM ) \
+ ((NR) < 20 || \
+ ((NR) < 40 && \
+ rmesa->tcl.hw_primitive == (PRIM| \
+ R200_VF_TCL_OUTPUT_VTX_ENABLE| \
+ R200_VF_PRIM_WALK_IND)))
+#endif
+
+#ifdef MESA_BIG_ENDIAN
+/* We could do without (most of) this ugliness if dest was always 32 bit word aligned... */
+#define EMIT_ELT(dest, offset, x) do { \
+ int off = offset + ( ( (GLuint)dest & 0x2 ) >> 1 ); \
+ GLushort *des = (GLushort *)( (GLuint)dest & ~0x2 ); \
+ (des)[ off + 1 - 2 * ( off & 1 ) ] = (GLushort)(x); \
+ (void)rmesa; } while (0)
+#else
+#define EMIT_ELT(dest, offset, x) do { \
+ (dest)[offset] = (GLushort) (x); \
+ (void)rmesa; } while (0)
+#endif
+
+#define EMIT_TWO_ELTS(dest, offset, x, y) *(GLuint *)((dest)+offset) = ((y)<<16)|(x);
+
+
+
+#define TAG(x) tcl_##x
+#include "tnl_dd/t_dd_dmatmp2.h"
+
+/**********************************************************************/
+/* External entrypoints */
+/**********************************************************************/
+
+void r200EmitPrimitive( GLcontext *ctx,
+ GLuint first,
+ GLuint last,
+ GLuint flags )
+{
+ tcl_render_tab_verts[flags&PRIM_MODE_MASK]( ctx, first, last, flags );
+}
+
+void r200EmitEltPrimitive( GLcontext *ctx,
+ GLuint first,
+ GLuint last,
+ GLuint flags )
+{
+ tcl_render_tab_elts[flags&PRIM_MODE_MASK]( ctx, first, last, flags );
+}
+
+void r200TclPrimitive( GLcontext *ctx,
+ GLenum prim,
+ int hw_prim )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint newprim = hw_prim | R200_VF_TCL_OUTPUT_VTX_ENABLE;
+
+ if (newprim != rmesa->tcl.hw_primitive ||
+ !discrete_prim[hw_prim&0xf]) {
+ R200_NEWPRIM( rmesa );
+ rmesa->tcl.hw_primitive = newprim;
+ }
+}
+
+
+/**********************************************************************/
+/* Fog blend factor computation for hw tcl */
+/* same calculation used as in t_vb_fog.c */
+/**********************************************************************/
+
+#define FOG_EXP_TABLE_SIZE 256
+#define FOG_MAX (10.0)
+#define EXP_FOG_MAX .0006595
+#define FOG_INCR (FOG_MAX/FOG_EXP_TABLE_SIZE)
+static GLfloat exp_table[FOG_EXP_TABLE_SIZE];
+
+#if 1
+#define NEG_EXP( result, narg ) \
+do { \
+ GLfloat f = (GLfloat) (narg * (1.0/FOG_INCR)); \
+ GLint k = (GLint) f; \
+ if (k > FOG_EXP_TABLE_SIZE-2) \
+ result = (GLfloat) EXP_FOG_MAX; \
+ else \
+ result = exp_table[k] + (f-k)*(exp_table[k+1]-exp_table[k]); \
+} while (0)
+#else
+#define NEG_EXP( result, narg ) \
+do { \
+ result = exp(-narg); \
+} while (0)
+#endif
+
+
+/**
+ * Initialize the exp_table[] lookup table for approximating exp().
+ */
+void
+r200InitStaticFogData( void )
+{
+ GLfloat f = 0.0F;
+ GLint i = 0;
+ for ( ; i < FOG_EXP_TABLE_SIZE ; i++, f += FOG_INCR) {
+ exp_table[i] = (GLfloat) exp(-f);
+ }
+}
+
+
+/**
+ * Compute per-vertex fog blend factors from fog coordinates by
+ * evaluating the GL_LINEAR, GL_EXP or GL_EXP2 fog function.
+ * Fog coordinates are distances from the eye (typically between the
+ * near and far clip plane distances).
+ * Note the fog (eye Z) coords may be negative so we use ABS(z) below.
+ * Fog blend factors are in the range [0,1].
+ */
+float
+r200ComputeFogBlendFactor( GLcontext *ctx, GLfloat fogcoord )
+{
+ GLfloat end = ctx->Fog.End;
+ GLfloat d, temp;
+ const GLfloat z = FABSF(fogcoord);
+
+ switch (ctx->Fog.Mode) {
+ case GL_LINEAR:
+ if (ctx->Fog.Start == ctx->Fog.End)
+ d = 1.0F;
+ else
+ d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
+ temp = (end - z) * d;
+ return CLAMP(temp, 0.0F, 1.0F);
+ break;
+ case GL_EXP:
+ d = ctx->Fog.Density;
+ NEG_EXP( temp, d * z );
+ return temp;
+ break;
+ case GL_EXP2:
+ d = ctx->Fog.Density*ctx->Fog.Density;
+ NEG_EXP( temp, d * z * z );
+ return temp;
+ break;
+ default:
+ _mesa_problem(ctx, "Bad fog mode in make_fog_coord");
+ return 0;
+ }
+}
+
+
+/**********************************************************************/
+/* Render pipeline stage */
+/**********************************************************************/
+
+
+/* TCL render.
+ */
+static GLboolean r200_run_tcl_render( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint inputs = VERT_BIT_POS | VERT_BIT_COLOR0;
+ GLuint i;
+
+ /* TODO: separate this from the swtnl pipeline
+ */
+ if (rmesa->TclFallback)
+ return GL_TRUE; /* fallback to software t&l */
+
+ if (R200_DEBUG & DEBUG_PRIMS)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (VB->Count == 0)
+ return GL_FALSE;
+
+ /* Validate state:
+ */
+ if (rmesa->NewGLState)
+ r200ValidateState( ctx );
+
+ /* NOTE: inputs != tnl->render_inputs - these are the untransformed
+ * inputs.
+ */
+ if (ctx->Light.Enabled) {
+ inputs |= VERT_BIT_NORMAL;
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
+ inputs |= VERT_BIT_COLOR1;
+ }
+ }
+
+ if ( ctx->Fog.FogCoordinateSource == GL_FOG_COORD ) {
+ inputs |= VERT_BIT_FOG;
+ }
+
+ for (i = 0 ; i < ctx->Const.MaxTextureUnits; i++) {
+ if (ctx->Texture.Unit[i]._ReallyEnabled) {
+ if (rmesa->TexGenNeedNormals[i]) {
+ inputs |= VERT_BIT_NORMAL;
+ }
+ inputs |= VERT_BIT_TEX(i);
+ }
+ }
+
+ /* Do the actual work:
+ */
+ r200ReleaseArrays( ctx, ~0 /* stage->changed_inputs */ );
+ r200EmitArrays( ctx, inputs );
+
+ rmesa->tcl.Elts = VB->Elts;
+
+ for (i = 0 ; i < VB->PrimitiveCount ; i++)
+ {
+ GLuint prim = VB->Primitive[i].mode;
+ GLuint start = VB->Primitive[i].start;
+ GLuint length = VB->Primitive[i].count;
+
+ if (!length)
+ continue;
+
+ if (rmesa->tcl.Elts)
+ r200EmitEltPrimitive( ctx, start, start+length, prim );
+ else
+ r200EmitPrimitive( ctx, start, start+length, prim );
+ }
+
+ return GL_FALSE; /* finished the pipe */
+}
+
+
+
+/* Initial state for tcl stage.
+ */
+const struct tnl_pipeline_stage _r200_tcl_stage =
+{
+ "r200 render",
+ NULL, /* private */
+ NULL,
+ NULL,
+ NULL,
+ r200_run_tcl_render /* run */
+};
+
+
+
+/**********************************************************************/
+/* Validate state at pipeline start */
+/**********************************************************************/
+
+
+/*-----------------------------------------------------------------------
+ * Manage TCL fallbacks
+ */
+
+
+static void transition_to_swtnl( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ R200_NEWPRIM( rmesa );
+
+ r200ChooseVertexState( ctx );
+ r200ChooseRenderState( ctx );
+
+ _mesa_validate_all_lighting_tables( ctx );
+
+ tnl->Driver.NotifyMaterialChange =
+ _mesa_validate_all_lighting_tables;
+
+ r200ReleaseArrays( ctx, ~0 );
+
+ /* Still using the D3D based hardware-rasterizer from the radeon;
+ * need to put the card into D3D mode to make it work:
+ */
+ R200_STATECHANGE( rmesa, vap );
+ rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] &= ~R200_VAP_TCL_ENABLE;
+}
+
+static void transition_to_hwtnl( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ _tnl_need_projected_coords( ctx, GL_FALSE );
+
+ r200UpdateMaterial( ctx );
+
+ tnl->Driver.NotifyMaterialChange = r200UpdateMaterial;
+
+ if ( rmesa->dma.flush )
+ rmesa->dma.flush( rmesa );
+
+ rmesa->dma.flush = NULL;
+
+ if (rmesa->swtcl.indexed_verts.buf)
+ r200ReleaseDmaRegion( rmesa, &rmesa->swtcl.indexed_verts,
+ __FUNCTION__ );
+
+ R200_STATECHANGE( rmesa, vap );
+ rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] |= R200_VAP_TCL_ENABLE;
+ rmesa->hw.vap.cmd[VAP_SE_VAP_CNTL] &= ~R200_VAP_FORCE_W_TO_ONE;
+
+ if ( ((rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] & R200_FOG_USE_MASK)
+ == R200_FOG_USE_SPEC_ALPHA) &&
+ (ctx->Fog.FogCoordinateSource == GL_FOG_COORD )) {
+ R200_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] &= ~R200_FOG_USE_MASK;
+ rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] |= R200_FOG_USE_VTX_FOG;
+ }
+
+ R200_STATECHANGE( rmesa, vte );
+ rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] &= ~(R200_VTX_XY_FMT|R200_VTX_Z_FMT);
+ rmesa->hw.vte.cmd[VTE_SE_VTE_CNTL] |= R200_VTX_W0_FMT;
+
+ if (R200_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "R200 end tcl fallback\n");
+}
+
+
+static char *fallbackStrings[] = {
+ "Rasterization fallback",
+ "Unfilled triangles",
+ "Twosided lighting, differing materials",
+ "Materials in VB (maybe between begin/end)",
+ "Texgen unit 0",
+ "Texgen unit 1",
+ "Texgen unit 2",
+ "Texgen unit 3",
+ "Texgen unit 4",
+ "Texgen unit 5",
+ "User disable",
+ "Bitmap as points",
+ "Vertex program"
+};
+
+
+static char *getFallbackString(GLuint bit)
+{
+ int i = 0;
+ while (bit > 1) {
+ i++;
+ bit >>= 1;
+ }
+ return fallbackStrings[i];
+}
+
+
+
+void r200TclFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint oldfallback = rmesa->TclFallback;
+
+ if (mode) {
+ rmesa->TclFallback |= bit;
+ if (oldfallback == 0) {
+ if (R200_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "R200 begin tcl fallback %s\n",
+ getFallbackString( bit ));
+ transition_to_swtnl( ctx );
+ }
+ }
+ else {
+ rmesa->TclFallback &= ~bit;
+ if (oldfallback == bit) {
+ if (R200_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "R200 end tcl fallback %s\n",
+ getFallbackString( bit ));
+ transition_to_hwtnl( ctx );
+ }
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_tcl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_tcl.h
new file mode 100644
index 000000000..ac5bc1194
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_tcl.h
@@ -0,0 +1,69 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tcl.h,v 1.2 2002/12/16 16:18:55 dawes Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R200_TCL_H__
+#define __R200_TCL_H__
+
+#include "r200_context.h"
+
+extern void r200TclPrimitive( GLcontext *ctx, GLenum prim, int hw_prim );
+extern void r200EmitEltPrimitive( GLcontext *ctx, GLuint first, GLuint last,
+ GLuint flags );
+extern void r200EmitPrimitive( GLcontext *ctx, GLuint first, GLuint last,
+ GLuint flags );
+
+extern void r200TclFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
+
+extern void r200InitStaticFogData( void );
+
+extern float r200ComputeFogBlendFactor( GLcontext *ctx, GLfloat fogcoord );
+
+#define R200_TCL_FALLBACK_RASTER 0x1 /* rasterization */
+#define R200_TCL_FALLBACK_UNFILLED 0x2 /* unfilled tris */
+#define R200_TCL_FALLBACK_LIGHT_TWOSIDE 0x4 /* twoside tris */
+#define R200_TCL_FALLBACK_MATERIAL 0x8 /* material in vb */
+#define R200_TCL_FALLBACK_TEXGEN_0 0x10 /* texgen, unit 0 */
+#define R200_TCL_FALLBACK_TEXGEN_1 0x20 /* texgen, unit 1 */
+#define R200_TCL_FALLBACK_TEXGEN_2 0x40 /* texgen, unit 2 */
+#define R200_TCL_FALLBACK_TEXGEN_3 0x80 /* texgen, unit 3 */
+#define R200_TCL_FALLBACK_TEXGEN_4 0x100 /* texgen, unit 4 */
+#define R200_TCL_FALLBACK_TEXGEN_5 0x200 /* texgen, unit 5 */
+#define R200_TCL_FALLBACK_TCL_DISABLE 0x400 /* user disable */
+#define R200_TCL_FALLBACK_BITMAP 0x800 /* draw bitmap with points */
+#define R200_TCL_FALLBACK_VERTEX_PROGRAM 0x1000/* vertex program active */
+
+#define TCL_FALLBACK( ctx, bit, mode ) r200TclFallback( ctx, bit, mode )
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_tex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_tex.c
new file mode 100644
index 000000000..3d259c2ca
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_tex.c
@@ -0,0 +1,1183 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tex.c,v 1.2 2002/11/05 17:46:08 tsi Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "colormac.h"
+#include "context.h"
+#include "enums.h"
+#include "image.h"
+#include "simple_list.h"
+#include "texformat.h"
+#include "texstore.h"
+#include "texmem.h"
+#include "teximage.h"
+#include "texobj.h"
+
+#include "r200_context.h"
+#include "r200_state.h"
+#include "r200_ioctl.h"
+#include "r200_swtcl.h"
+#include "r200_tex.h"
+
+#include "xmlpool.h"
+
+
+
+/**
+ * Set the texture wrap modes.
+ *
+ * \param t Texture object whose wrap modes are to be set
+ * \param swrap Wrap mode for the \a s texture coordinate
+ * \param twrap Wrap mode for the \a t texture coordinate
+ */
+
+static void r200SetTexWrap( r200TexObjPtr t, GLenum swrap, GLenum twrap, GLenum rwrap )
+{
+ GLboolean is_clamp = GL_FALSE;
+ GLboolean is_clamp_to_border = GL_FALSE;
+
+ t->pp_txfilter &= ~(R200_CLAMP_S_MASK | R200_CLAMP_T_MASK | R200_BORDER_MODE_D3D);
+
+ switch ( swrap ) {
+ case GL_REPEAT:
+ t->pp_txfilter |= R200_CLAMP_S_WRAP;
+ break;
+ case GL_CLAMP:
+ t->pp_txfilter |= R200_CLAMP_S_CLAMP_GL;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_CLAMP_TO_EDGE:
+ t->pp_txfilter |= R200_CLAMP_S_CLAMP_LAST;
+ break;
+ case GL_CLAMP_TO_BORDER:
+ t->pp_txfilter |= R200_CLAMP_S_CLAMP_GL;
+ is_clamp_to_border = GL_TRUE;
+ break;
+ case GL_MIRRORED_REPEAT:
+ t->pp_txfilter |= R200_CLAMP_S_MIRROR;
+ break;
+ case GL_MIRROR_CLAMP_EXT:
+ t->pp_txfilter |= R200_CLAMP_S_MIRROR_CLAMP_GL;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_MIRROR_CLAMP_TO_EDGE_EXT:
+ t->pp_txfilter |= R200_CLAMP_S_MIRROR_CLAMP_LAST;
+ break;
+ case GL_MIRROR_CLAMP_TO_BORDER_EXT:
+ t->pp_txfilter |= R200_CLAMP_S_MIRROR_CLAMP_GL;
+ is_clamp_to_border = GL_TRUE;
+ break;
+ default:
+ _mesa_problem(NULL, "bad S wrap mode in %s", __FUNCTION__);
+ }
+
+ switch ( twrap ) {
+ case GL_REPEAT:
+ t->pp_txfilter |= R200_CLAMP_T_WRAP;
+ break;
+ case GL_CLAMP:
+ t->pp_txfilter |= R200_CLAMP_T_CLAMP_GL;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_CLAMP_TO_EDGE:
+ t->pp_txfilter |= R200_CLAMP_T_CLAMP_LAST;
+ break;
+ case GL_CLAMP_TO_BORDER:
+ t->pp_txfilter |= R200_CLAMP_T_CLAMP_GL | R200_BORDER_MODE_D3D;
+ is_clamp_to_border = GL_TRUE;
+ break;
+ case GL_MIRRORED_REPEAT:
+ t->pp_txfilter |= R200_CLAMP_T_MIRROR;
+ break;
+ case GL_MIRROR_CLAMP_EXT:
+ t->pp_txfilter |= R200_CLAMP_T_MIRROR_CLAMP_GL;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_MIRROR_CLAMP_TO_EDGE_EXT:
+ t->pp_txfilter |= R200_CLAMP_T_MIRROR_CLAMP_LAST;
+ break;
+ case GL_MIRROR_CLAMP_TO_BORDER_EXT:
+ t->pp_txfilter |= R200_CLAMP_T_MIRROR_CLAMP_GL;
+ is_clamp_to_border = GL_TRUE;
+ break;
+ default:
+ _mesa_problem(NULL, "bad T wrap mode in %s", __FUNCTION__);
+ }
+
+ t->pp_txformat_x &= ~R200_CLAMP_Q_MASK;
+
+ switch ( rwrap ) {
+ case GL_REPEAT:
+ t->pp_txformat_x |= R200_CLAMP_Q_WRAP;
+ break;
+ case GL_CLAMP:
+ t->pp_txformat_x |= R200_CLAMP_Q_CLAMP_GL;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_CLAMP_TO_EDGE:
+ t->pp_txformat_x |= R200_CLAMP_Q_CLAMP_LAST;
+ break;
+ case GL_CLAMP_TO_BORDER:
+ t->pp_txformat_x |= R200_CLAMP_Q_CLAMP_GL;
+ is_clamp_to_border = GL_TRUE;
+ break;
+ case GL_MIRRORED_REPEAT:
+ t->pp_txformat_x |= R200_CLAMP_Q_MIRROR;
+ break;
+ case GL_MIRROR_CLAMP_EXT:
+ t->pp_txformat_x |= R200_CLAMP_Q_MIRROR_CLAMP_GL;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_MIRROR_CLAMP_TO_EDGE_EXT:
+ t->pp_txformat_x |= R200_CLAMP_Q_MIRROR_CLAMP_LAST;
+ break;
+ case GL_MIRROR_CLAMP_TO_BORDER_EXT:
+ t->pp_txformat_x |= R200_CLAMP_Q_MIRROR_CLAMP_GL;
+ is_clamp_to_border = GL_TRUE;
+ break;
+ default:
+ _mesa_problem(NULL, "bad R wrap mode in %s", __FUNCTION__);
+ }
+
+ if ( is_clamp_to_border ) {
+ t->pp_txfilter |= R200_BORDER_MODE_D3D;
+ }
+
+ t->border_fallback = (is_clamp && is_clamp_to_border);
+}
+
+static void r200SetTexMaxAnisotropy( r200TexObjPtr t, GLfloat max )
+{
+ t->pp_txfilter &= ~R200_MAX_ANISO_MASK;
+
+ if ( max == 1.0 ) {
+ t->pp_txfilter |= R200_MAX_ANISO_1_TO_1;
+ } else if ( max <= 2.0 ) {
+ t->pp_txfilter |= R200_MAX_ANISO_2_TO_1;
+ } else if ( max <= 4.0 ) {
+ t->pp_txfilter |= R200_MAX_ANISO_4_TO_1;
+ } else if ( max <= 8.0 ) {
+ t->pp_txfilter |= R200_MAX_ANISO_8_TO_1;
+ } else {
+ t->pp_txfilter |= R200_MAX_ANISO_16_TO_1;
+ }
+}
+
+/**
+ * Set the texture magnification and minification modes.
+ *
+ * \param t Texture whose filter modes are to be set
+ * \param minf Texture minification mode
+ * \param magf Texture magnification mode
+ */
+
+static void r200SetTexFilter( r200TexObjPtr t, GLenum minf, GLenum magf )
+{
+ GLuint anisotropy = (t->pp_txfilter & R200_MAX_ANISO_MASK);
+
+ t->pp_txfilter &= ~(R200_MIN_FILTER_MASK | R200_MAG_FILTER_MASK);
+ t->pp_txformat_x &= ~R200_VOLUME_FILTER_MASK;
+
+ if ( anisotropy == R200_MAX_ANISO_1_TO_1 ) {
+ switch ( minf ) {
+ case GL_NEAREST:
+ t->pp_txfilter |= R200_MIN_FILTER_NEAREST;
+ break;
+ case GL_LINEAR:
+ t->pp_txfilter |= R200_MIN_FILTER_LINEAR;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ t->pp_txfilter |= R200_MIN_FILTER_NEAREST_MIP_NEAREST;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ t->pp_txfilter |= R200_MIN_FILTER_LINEAR_MIP_NEAREST;
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ t->pp_txfilter |= R200_MIN_FILTER_NEAREST_MIP_LINEAR;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ t->pp_txfilter |= R200_MIN_FILTER_LINEAR_MIP_LINEAR;
+ break;
+ }
+ } else {
+ switch ( minf ) {
+ case GL_NEAREST:
+ t->pp_txfilter |= R200_MIN_FILTER_ANISO_NEAREST;
+ break;
+ case GL_LINEAR:
+ t->pp_txfilter |= R200_MIN_FILTER_ANISO_LINEAR;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ case GL_LINEAR_MIPMAP_NEAREST:
+ t->pp_txfilter |= R200_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ case GL_LINEAR_MIPMAP_LINEAR:
+ t->pp_txfilter |= R200_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR;
+ break;
+ }
+ }
+
+ /* Note we don't have 3D mipmaps so only use the mag filter setting
+ * to set the 3D texture filter mode.
+ */
+ switch ( magf ) {
+ case GL_NEAREST:
+ t->pp_txfilter |= R200_MAG_FILTER_NEAREST;
+ t->pp_txformat_x |= R200_VOLUME_FILTER_NEAREST;
+ break;
+ case GL_LINEAR:
+ t->pp_txfilter |= R200_MAG_FILTER_LINEAR;
+ t->pp_txformat_x |= R200_VOLUME_FILTER_LINEAR;
+ break;
+ }
+}
+
+static void r200SetTexBorderColor( r200TexObjPtr t, GLubyte c[4] )
+{
+ t->pp_border_color = r200PackColor( 4, c[0], c[1], c[2], c[3] );
+}
+
+
+/**
+ * Allocate space for and load the mesa images into the texture memory block.
+ * This will happen before drawing with a new texture, or drawing with a
+ * texture after it was swapped out or teximaged again.
+ */
+
+static r200TexObjPtr r200AllocTexObj( struct gl_texture_object *texObj )
+{
+ r200TexObjPtr t;
+
+ t = CALLOC_STRUCT( r200_tex_obj );
+ texObj->DriverData = t;
+ if ( t != NULL ) {
+ if ( R200_DEBUG & DEBUG_TEXTURE ) {
+ fprintf( stderr, "%s( %p, %p )\n", __FUNCTION__, (void *)texObj,
+ (void *)t );
+ }
+
+ /* Initialize non-image-dependent parts of the state:
+ */
+ t->base.tObj = texObj;
+ t->border_fallback = GL_FALSE;
+
+ make_empty_list( & t->base );
+
+ r200SetTexWrap( t, texObj->WrapS, texObj->WrapT, texObj->WrapR );
+ r200SetTexMaxAnisotropy( t, texObj->MaxAnisotropy );
+ r200SetTexFilter( t, texObj->MinFilter, texObj->MagFilter );
+ r200SetTexBorderColor( t, texObj->_BorderChan );
+ }
+
+ return t;
+}
+
+
+static const struct gl_texture_format *
+r200ChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ const GLboolean do32bpt =
+ ( rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32 );
+ const GLboolean force16bpt =
+ ( rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16 );
+ (void) format;
+
+ switch ( internalFormat ) {
+ case 4:
+ case GL_RGBA:
+ case GL_COMPRESSED_RGBA:
+ switch ( type ) {
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return do32bpt ? _dri_texformat_argb8888 : _dri_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return _dri_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return _dri_texformat_argb1555;
+ default:
+ return do32bpt ? _dri_texformat_rgba8888 : _dri_texformat_argb4444;
+ }
+
+ case 3:
+ case GL_RGB:
+ case GL_COMPRESSED_RGB:
+ switch ( type ) {
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return _dri_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return _dri_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ return _dri_texformat_rgb565;
+ default:
+ return do32bpt ? _dri_texformat_rgba8888 : _dri_texformat_rgb565;
+ }
+
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return !force16bpt ?
+ _dri_texformat_rgba8888 : _dri_texformat_argb4444;
+
+ case GL_RGBA4:
+ case GL_RGBA2:
+ return _dri_texformat_argb4444;
+
+ case GL_RGB5_A1:
+ return _dri_texformat_argb1555;
+
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ return !force16bpt ? _dri_texformat_rgba8888 : _dri_texformat_rgb565;
+
+ case GL_RGB5:
+ case GL_RGB4:
+ case GL_R3_G3_B2:
+ return _dri_texformat_rgb565;
+
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ case GL_COMPRESSED_ALPHA:
+ return _dri_texformat_a8;
+
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ case GL_COMPRESSED_LUMINANCE:
+ return _dri_texformat_l8;
+
+ 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_COMPRESSED_LUMINANCE_ALPHA:
+ return _dri_texformat_al88;
+
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case GL_COMPRESSED_INTENSITY:
+ return _dri_texformat_i8;
+
+ case GL_YCBCR_MESA:
+ if (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
+ type == GL_UNSIGNED_BYTE)
+ return &_mesa_texformat_ycbcr;
+ else
+ return &_mesa_texformat_ycbcr_rev;
+
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgb_dxt1;
+
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgba_dxt1;
+
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ return &_mesa_texformat_rgba_dxt3;
+
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ return &_mesa_texformat_rgba_dxt5;
+
+ default:
+ _mesa_problem(ctx,
+ "unexpected internalFormat 0x%x in r200ChooseTextureFormat",
+ (int) internalFormat);
+ return NULL;
+ }
+
+ return NULL; /* never get here */
+}
+
+
+static GLboolean
+r200ValidateClientStorage( GLcontext *ctx, GLenum target,
+ GLint internalFormat,
+ GLint srcWidth, GLint srcHeight,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if (0)
+ fprintf(stderr, "intformat %s format %s type %s\n",
+ _mesa_lookup_enum_by_nr( internalFormat ),
+ _mesa_lookup_enum_by_nr( format ),
+ _mesa_lookup_enum_by_nr( type ));
+
+ if (!ctx->Unpack.ClientStorage)
+ return 0;
+
+ if (ctx->_ImageTransferState ||
+ texImage->IsCompressed ||
+ texObj->GenerateMipmap)
+ return 0;
+
+
+ /* This list is incomplete, may be different on ppc???
+ */
+ switch ( internalFormat ) {
+ case GL_RGBA:
+ if ( format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV ) {
+ texImage->TexFormat = _dri_texformat_argb8888;
+ }
+ else
+ return 0;
+ break;
+
+ case GL_RGB:
+ if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
+ texImage->TexFormat = _dri_texformat_rgb565;
+ }
+ else
+ return 0;
+ break;
+
+ case GL_YCBCR_MESA:
+ if ( format == GL_YCBCR_MESA &&
+ type == GL_UNSIGNED_SHORT_8_8_REV_APPLE ) {
+ texImage->TexFormat = &_mesa_texformat_ycbcr_rev;
+ }
+ else if ( format == GL_YCBCR_MESA &&
+ (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
+ type == GL_UNSIGNED_BYTE)) {
+ texImage->TexFormat = &_mesa_texformat_ycbcr;
+ }
+ else
+ return 0;
+ break;
+
+ default:
+ return 0;
+ }
+
+ /* Could deal with these packing issues, but currently don't:
+ */
+ if (packing->SkipPixels ||
+ packing->SkipRows ||
+ packing->SwapBytes ||
+ packing->LsbFirst) {
+ return 0;
+ }
+
+ {
+ GLint srcRowStride = _mesa_image_row_stride(packing, srcWidth,
+ format, type);
+
+
+ if (0)
+ fprintf(stderr, "%s: srcRowStride %d/%x\n",
+ __FUNCTION__, srcRowStride, srcRowStride);
+
+ /* Could check this later in upload, pitch restrictions could be
+ * relaxed, but would need to store the image pitch somewhere,
+ * as packing details might change before image is uploaded:
+ */
+ if (!r200IsGartMemory( rmesa, pixels, srcHeight * srcRowStride ) ||
+ (srcRowStride & 63))
+ return 0;
+
+
+ /* Have validated that _mesa_transfer_teximage would be a straight
+ * memcpy at this point. NOTE: future calls to TexSubImage will
+ * overwrite the client data. This is explicitly mentioned in the
+ * extension spec.
+ */
+ texImage->Data = (void *)pixels;
+ texImage->IsClientData = GL_TRUE;
+ texImage->RowStride = srcRowStride / texImage->TexFormat->TexelBytes;
+
+ return 1;
+ }
+}
+
+
+static void r200TexImage1D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+ if ( t ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) r200AllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
+ return;
+ }
+ }
+
+ /* Note, this will call ChooseTextureFormat */
+ _mesa_store_teximage1d(ctx, target, level, internalFormat,
+ width, border, format, type, pixels,
+ &ctx->Unpack, texObj, texImage);
+
+ t->dirty_images[0] |= (1 << level);
+}
+
+
+static void r200TexSubImage1D( 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 )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+ assert( t ); /* this _should_ be true */
+ if ( t ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) r200AllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
+ return;
+ }
+ }
+
+ _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
+ format, type, pixels, packing, texObj,
+ texImage);
+
+ t->dirty_images[0] |= (1 << level);
+}
+
+
+static void r200TexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ if ( t != NULL ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) r200AllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ }
+
+ texImage->IsClientData = GL_FALSE;
+
+ if (r200ValidateClientStorage( ctx, target,
+ internalFormat,
+ width, height,
+ format, type, pixels,
+ packing, texObj, texImage)) {
+ if (R200_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: Using client storage\n", __FUNCTION__);
+ }
+ else {
+ if (R200_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: Using normal storage\n", __FUNCTION__);
+
+ /* Normal path: copy (to cached memory) and eventually upload
+ * via another copy to GART memory and then a blit... Could
+ * eliminate one copy by going straight to (permanent) GART.
+ *
+ * Note, this will call r200ChooseTextureFormat.
+ */
+ _mesa_store_teximage2d(ctx, target, level, internalFormat,
+ width, height, border, format, type, pixels,
+ &ctx->Unpack, texObj, texImage);
+
+ t->dirty_images[face] |= (1 << level);
+ }
+}
+
+
+static void r200TexSubImage2D( 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 )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ assert( t ); /* this _should_ be true */
+ if ( t ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) r200AllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
+ return;
+ }
+ }
+
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
+
+ t->dirty_images[face] |= (1 << level);
+}
+
+
+static void r200CompressedTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ if ( t != NULL ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) r200AllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
+ return;
+ }
+ }
+
+ texImage->IsClientData = GL_FALSE;
+/* can't call this, different parameters. Would never evaluate to true anyway currently
+ if (r200ValidateClientStorage( ctx, target,
+ internalFormat,
+ width, height,
+ format, type, pixels,
+ packing, texObj, texImage)) {
+ if (R200_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: Using client storage\n", __FUNCTION__);
+ }
+ else */{
+ if (R200_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: Using normal storage\n", __FUNCTION__);
+
+ /* Normal path: copy (to cached memory) and eventually upload
+ * via another copy to GART memory and then a blit... Could
+ * eliminate one copy by going straight to (permanent) GART.
+ *
+ * Note, this will call r200ChooseTextureFormat.
+ */
+ _mesa_store_compressed_teximage2d(ctx, target, level, internalFormat, width,
+ height, border, imageSize, data, texObj, texImage);
+
+ t->dirty_images[face] |= (1 << level);
+ }
+}
+
+
+static void r200CompressedTexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ assert( t ); /* this _should_ be true */
+ if ( t ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) r200AllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2D");
+ return;
+ }
+ }
+
+ _mesa_store_compressed_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, imageSize, data, texObj, texImage);
+
+ t->dirty_images[face] |= (1 << level);
+}
+
+
+#if ENABLE_HW_3D_TEXTURE
+static void r200TexImage3D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint depth,
+ GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+ if ( t ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) r200AllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
+ return;
+ }
+ }
+
+ texImage->IsClientData = GL_FALSE;
+
+#if 0
+ if (r200ValidateClientStorage( ctx, target,
+ internalFormat,
+ width, height,
+ format, type, pixels,
+ packing, texObj, texImage)) {
+ if (R200_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: Using client storage\n", __FUNCTION__);
+ }
+ else
+#endif
+ {
+ if (R200_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: Using normal storage\n", __FUNCTION__);
+
+ /* Normal path: copy (to cached memory) and eventually upload
+ * via another copy to GART memory and then a blit... Could
+ * eliminate one copy by going straight to (permanent) GART.
+ *
+ * Note, this will call r200ChooseTextureFormat.
+ */
+ _mesa_store_teximage3d(ctx, target, level, internalFormat,
+ width, height, depth, border,
+ format, type, pixels,
+ &ctx->Unpack, texObj, texImage);
+
+ t->dirty_images[0] |= (1 << level);
+ }
+}
+#endif
+
+
+#if ENABLE_HW_3D_TEXTURE
+static void
+r200TexSubImage3D( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ assert( t ); /* this _should_ be true */
+ if ( t ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) r200AllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D");
+ return;
+ }
+ texObj->DriverData = t;
+ }
+
+ _mesa_store_texsubimage3d(ctx, target, level, xoffset, yoffset, zoffset,
+ width, height, depth,
+ format, type, pixels, packing, texObj, texImage);
+
+ t->dirty_images[0] |= (1 << level);
+}
+#endif
+
+
+
+static void r200TexEnv( GLcontext *ctx, GLenum target,
+ GLenum pname, const GLfloat *param )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint unit = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+ if ( R200_DEBUG & DEBUG_STATE ) {
+ fprintf( stderr, "%s( %s )\n",
+ __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) );
+ }
+
+ /* This is incorrect: Need to maintain this data for each of
+ * GL_TEXTURE_{123}D, GL_TEXTURE_RECTANGLE_NV, etc, and switch
+ * between them according to _ReallyEnabled.
+ */
+ switch ( pname ) {
+ case GL_TEXTURE_ENV_COLOR: {
+ GLubyte c[4];
+ GLuint envColor;
+ UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor );
+ envColor = r200PackColor( 4, c[0], c[1], c[2], c[3] );
+ if ( rmesa->hw.tf.cmd[TF_TFACTOR_0 + unit] != envColor ) {
+ R200_STATECHANGE( rmesa, tf );
+ rmesa->hw.tf.cmd[TF_TFACTOR_0 + unit] = envColor;
+ }
+ break;
+ }
+
+ case GL_TEXTURE_LOD_BIAS_EXT: {
+ GLfloat bias, min;
+ GLuint b;
+ const int fixed_one = 0x8000000;
+
+ /* The R200's LOD bias is a signed 2's complement value with a
+ * range of -16.0 <= bias < 16.0.
+ *
+ * NOTE: Add a small bias to the bias for conform mipsel.c test.
+ */
+ bias = *param + .01;
+ min = driQueryOptionb (&rmesa->optionCache, "no_neg_lod_bias") ?
+ 0.0 : -16.0;
+ bias = CLAMP( bias, min, 16.0 );
+ b = (int)(bias * fixed_one) & R200_LOD_BIAS_MASK;
+
+ if ( (rmesa->hw.tex[unit].cmd[TEX_PP_TXFORMAT_X] & R200_LOD_BIAS_MASK) != b ) {
+ R200_STATECHANGE( rmesa, tex[unit] );
+ rmesa->hw.tex[unit].cmd[TEX_PP_TXFORMAT_X] &= ~R200_LOD_BIAS_MASK;
+ rmesa->hw.tex[unit].cmd[TEX_PP_TXFORMAT_X] |= b;
+ }
+ break;
+ }
+
+ default:
+ return;
+ }
+}
+
+
+/**
+ * Changes variables and flags for a state update, which will happen at the
+ * next UpdateTextureState
+ */
+
+static void r200TexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj,
+ GLenum pname, const GLfloat *params )
+{
+ r200TexObjPtr t = (r200TexObjPtr) texObj->DriverData;
+
+ if ( R200_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
+ fprintf( stderr, "%s( %s )\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr( pname ) );
+ }
+
+ switch ( pname ) {
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+ r200SetTexMaxAnisotropy( t, texObj->MaxAnisotropy );
+ r200SetTexFilter( t, texObj->MinFilter, texObj->MagFilter );
+ break;
+
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ case GL_TEXTURE_WRAP_R:
+ r200SetTexWrap( t, texObj->WrapS, texObj->WrapT, texObj->WrapR );
+ break;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ r200SetTexBorderColor( t, texObj->_BorderChan );
+ break;
+
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ /* This isn't the most efficient solution but there doesn't appear to
+ * be a nice alternative. Since there's no LOD clamping,
+ * we just have to rely on loading the right subset of mipmap levels
+ * to simulate a clamped LOD.
+ */
+ driSwapOutTextureObject( (driTextureObject *) t );
+ break;
+
+ default:
+ return;
+ }
+
+ /* Mark this texobj as dirty (one bit per tex unit)
+ */
+ t->dirty_state = TEX_ALL;
+}
+
+
+
+static void r200BindTexture( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj )
+{
+ if ( R200_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
+ fprintf( stderr, "%s( %p ) unit=%d\n", __FUNCTION__, (void *)texObj,
+ ctx->Texture.CurrentUnit );
+ }
+
+ if ( (target == GL_TEXTURE_1D)
+ || (target == GL_TEXTURE_2D)
+#if ENABLE_HW_3D_TEXTURE
+ || (target == GL_TEXTURE_3D)
+#endif
+ || (target == GL_TEXTURE_CUBE_MAP)
+ || (target == GL_TEXTURE_RECTANGLE_NV) ) {
+ assert( texObj->DriverData != NULL );
+ }
+}
+
+
+static void r200DeleteTexture( GLcontext *ctx,
+ struct gl_texture_object *texObj )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+ if ( R200_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
+ fprintf( stderr, "%s( %p (target = %s) )\n", __FUNCTION__, (void *)texObj,
+ _mesa_lookup_enum_by_nr( texObj->Target ) );
+ }
+
+ if ( t != NULL ) {
+ if ( rmesa ) {
+ R200_FIREVERTICES( rmesa );
+ }
+
+ driDestroyTextureObject( t );
+ }
+ /* Free mipmap images and the texture object itself */
+ _mesa_delete_texture_object(ctx, texObj);
+}
+
+/* Need:
+ * - Same GEN_MODE for all active bits
+ * - Same EyePlane/ObjPlane for all active bits when using Eye/Obj
+ * - STRQ presumably all supported (matrix means incoming R values
+ * can end up in STQ, this has implications for vertex support,
+ * presumably ok if maos is used, though?)
+ *
+ * Basically impossible to do this on the fly - just collect some
+ * basic info & do the checks from ValidateState().
+ */
+static void r200TexGen( GLcontext *ctx,
+ GLenum coord,
+ GLenum pname,
+ const GLfloat *params )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint unit = ctx->Texture.CurrentUnit;
+ rmesa->recheck_texgen[unit] = GL_TRUE;
+}
+
+
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
+ * Note: this function will be called during context creation to
+ * allocate the default texture objects.
+ * Note: we could use containment here to 'derive' the driver-specific
+ * texture object from the core mesa gl_texture_object. Not done at this time.
+ * Fixup MaxAnisotropy according to user preference.
+ */
+static struct gl_texture_object *
+r200NewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ struct gl_texture_object *obj;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ if (!obj)
+ return NULL;
+ obj->MaxAnisotropy = rmesa->initialMaxAnisotropy;
+ r200AllocTexObj( obj );
+ return obj;
+}
+
+
+void r200InitTextureFuncs( struct dd_function_table *functions )
+{
+ /* Note: we only plug in the functions we implement in the driver
+ * since _mesa_init_driver_functions() was already called.
+ */
+ functions->ChooseTextureFormat = r200ChooseTextureFormat;
+ functions->TexImage1D = r200TexImage1D;
+ functions->TexImage2D = r200TexImage2D;
+#if ENABLE_HW_3D_TEXTURE
+ functions->TexImage3D = r200TexImage3D;
+#else
+ functions->TexImage3D = _mesa_store_teximage3d;
+#endif
+ functions->TexSubImage1D = r200TexSubImage1D;
+ functions->TexSubImage2D = r200TexSubImage2D;
+#if ENABLE_HW_3D_TEXTURE
+ functions->TexSubImage3D = r200TexSubImage3D;
+#else
+ functions->TexSubImage3D = _mesa_store_texsubimage3d;
+#endif
+ functions->NewTextureObject = r200NewTextureObject;
+ functions->BindTexture = r200BindTexture;
+ functions->DeleteTexture = r200DeleteTexture;
+ functions->IsTextureResident = driIsTextureResident;
+
+ functions->TexEnv = r200TexEnv;
+ functions->TexParameter = r200TexParameter;
+ functions->TexGen = r200TexGen;
+
+ functions->CompressedTexImage2D = r200CompressedTexImage2D;
+ functions->CompressedTexSubImage2D = r200CompressedTexSubImage2D;
+
+ driInitTextureFormats();
+
+#if 000
+ /* moved or obsolete code */
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ driInitTextureObjects( ctx, & rmesa->swapped,
+ DRI_TEXMGR_DO_TEXTURE_1D
+ | DRI_TEXMGR_DO_TEXTURE_2D );
+
+ /* Hack: r200NewTextureObject is not yet installed when the
+ * default textures are created. Therefore set MaxAnisotropy of the
+ * default 2D texture now. */
+ ctx->Shared->Default2D->MaxAnisotropy = driQueryOptionf (&rmesa->optionCache,
+ "def_max_anisotropy");
+#endif
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_tex.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_tex.h
new file mode 100644
index 000000000..acabbc11b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_tex.h
@@ -0,0 +1,47 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tex.h,v 1.1 2002/10/30 12:51:53 alanh Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R200_TEX_H__
+#define __R200_TEX_H__
+
+extern void r200UpdateTextureState( GLcontext *ctx );
+
+extern int r200UploadTexImages( r200ContextPtr rmesa, r200TexObjPtr t, GLuint face );
+
+extern void r200DestroyTexObj( r200ContextPtr rmesa, r200TexObjPtr t );
+
+extern void r200InitTextureFuncs( struct dd_function_table *functions );
+
+#endif /* __R200_TEX_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_texmem.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_texmem.c
new file mode 100644
index 000000000..7472afeed
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_texmem.c
@@ -0,0 +1,526 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_texmem.c,v 1.5 2002/12/17 00:32:56 dawes Exp $ */
+/**************************************************************************
+
+Copyright (C) Tungsten Graphics 2002. All Rights Reserved.
+The Weather Channel, Inc. funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86
+license. This notice must be preserved.
+
+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, VA LINUX SYSTEMS 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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#include <errno.h>
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "colormac.h"
+#include "macros.h"
+#include "r200_context.h"
+#include "r200_ioctl.h"
+#include "r200_tex.h"
+#include "radeon_reg.h"
+
+#include <unistd.h> /* for usleep() */
+
+
+/**
+ * Destroy any device-dependent state associated with the texture. This may
+ * include NULLing out hardware state that points to the texture.
+ */
+void
+r200DestroyTexObj( r200ContextPtr rmesa, r200TexObjPtr t )
+{
+ if ( R200_DEBUG & DEBUG_TEXTURE ) {
+ fprintf( stderr, "%s( %p, %p )\n", __FUNCTION__,
+ (void *)t, (void *)t->base.tObj );
+ }
+
+ if ( rmesa != NULL ) {
+ unsigned i;
+
+
+ for ( i = 0 ; i < rmesa->glCtx->Const.MaxTextureUnits ; i++ ) {
+ if ( t == rmesa->state.texture.unit[i].texobj ) {
+ rmesa->state.texture.unit[i].texobj = NULL;
+ rmesa->hw.tex[i].dirty = GL_FALSE;
+ rmesa->hw.cube[i].dirty = GL_FALSE;
+ }
+ }
+ }
+}
+
+
+/* ------------------------------------------------------------
+ * Texture image conversions
+ */
+
+
+static void r200UploadGARTClientSubImage( r200ContextPtr rmesa,
+ r200TexObjPtr t,
+ struct gl_texture_image *texImage,
+ GLint hwlevel,
+ GLint x, GLint y,
+ GLint width, GLint height )
+{
+ const struct gl_texture_format *texFormat = texImage->TexFormat;
+ GLuint srcPitch, dstPitch;
+ int blit_format;
+ int srcOffset;
+
+ /*
+ * XXX it appears that we always upload the full image, not a subimage.
+ * I.e. x==0, y==0, width=texWidth, height=texWidth. If this is ever
+ * changed, the src pitch will have to change.
+ */
+ switch ( texFormat->TexelBytes ) {
+ case 1:
+ blit_format = R200_CP_COLOR_FORMAT_CI8;
+ srcPitch = t->image[0][0].width * texFormat->TexelBytes;
+ dstPitch = t->image[0][0].width * texFormat->TexelBytes;
+ break;
+ case 2:
+ blit_format = R200_CP_COLOR_FORMAT_RGB565;
+ srcPitch = t->image[0][0].width * texFormat->TexelBytes;
+ dstPitch = t->image[0][0].width * texFormat->TexelBytes;
+ break;
+ case 4:
+ blit_format = R200_CP_COLOR_FORMAT_ARGB8888;
+ srcPitch = t->image[0][0].width * texFormat->TexelBytes;
+ dstPitch = t->image[0][0].width * texFormat->TexelBytes;
+ break;
+ default:
+ return;
+ }
+
+ t->image[0][hwlevel].data = texImage->Data;
+ srcOffset = r200GartOffsetFromVirtual( rmesa, texImage->Data );
+
+ assert( srcOffset != ~0 );
+
+ /* Don't currently need to cope with small pitches?
+ */
+ width = texImage->Width;
+ height = texImage->Height;
+
+ r200EmitWait( rmesa, RADEON_WAIT_3D );
+
+ r200EmitBlit( rmesa, blit_format,
+ srcPitch,
+ srcOffset,
+ dstPitch,
+ t->bufAddr,
+ x,
+ y,
+ t->image[0][hwlevel].x + x,
+ t->image[0][hwlevel].y + y,
+ width,
+ height );
+
+ r200EmitWait( rmesa, RADEON_WAIT_2D );
+}
+
+static void r200UploadRectSubImage( r200ContextPtr rmesa,
+ r200TexObjPtr t,
+ struct gl_texture_image *texImage,
+ GLint x, GLint y,
+ GLint width, GLint height )
+{
+ const struct gl_texture_format *texFormat = texImage->TexFormat;
+ int blit_format, dstPitch, done;
+
+ switch ( texFormat->TexelBytes ) {
+ case 1:
+ blit_format = R200_CP_COLOR_FORMAT_CI8;
+ break;
+ case 2:
+ blit_format = R200_CP_COLOR_FORMAT_RGB565;
+ break;
+ case 4:
+ blit_format = R200_CP_COLOR_FORMAT_ARGB8888;
+ break;
+ default:
+ return;
+ }
+
+ t->image[0][0].data = texImage->Data;
+
+ /* Currently don't need to cope with small pitches.
+ */
+ width = texImage->Width;
+ height = texImage->Height;
+ dstPitch = t->pp_txpitch + 32;
+
+ if (rmesa->prefer_gart_client_texturing && texImage->IsClientData) {
+ /* In this case, could also use GART texturing. This is
+ * currently disabled, but has been tested & works.
+ */
+ t->pp_txoffset = r200GartOffsetFromVirtual( rmesa, texImage->Data );
+ t->pp_txpitch = texImage->RowStride * texFormat->TexelBytes - 32;
+
+ if (R200_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr,
+ "Using GART texturing for rectangular client texture\n");
+
+ /* Release FB memory allocated for this image:
+ */
+ /* FIXME This may not be correct as driSwapOutTextureObject sets
+ * FIXME dirty_images. It may be fine, though.
+ */
+ if ( t->base.memBlock ) {
+ driSwapOutTextureObject( (driTextureObject *) t );
+ }
+ }
+ else if (texImage->IsClientData) {
+ /* Data already in GART memory, with usable pitch.
+ */
+ GLuint srcPitch;
+ srcPitch = texImage->RowStride * texFormat->TexelBytes;
+ r200EmitBlit( rmesa,
+ blit_format,
+ srcPitch,
+ r200GartOffsetFromVirtual( rmesa, texImage->Data ),
+ dstPitch, t->bufAddr,
+ 0, 0,
+ 0, 0,
+ width, height );
+ }
+ else {
+ /* Data not in GART memory, or bad pitch.
+ */
+ for (done = 0; done < height ; ) {
+ struct r200_dma_region region;
+ int lines = MIN2( height - done, RADEON_BUFFER_SIZE / dstPitch );
+ int src_pitch;
+ char *tex;
+
+ src_pitch = texImage->RowStride * texFormat->TexelBytes;
+
+ tex = (char *)texImage->Data + done * src_pitch;
+
+ memset(&region, 0, sizeof(region));
+ r200AllocDmaRegion( rmesa, &region, lines * dstPitch, 1024 );
+
+ /* Copy texdata to dma:
+ */
+ if (0)
+ fprintf(stderr, "%s: src_pitch %d dst_pitch %d\n",
+ __FUNCTION__, src_pitch, dstPitch);
+
+ if (src_pitch == dstPitch) {
+ memcpy( region.address + region.start, tex, lines * src_pitch );
+ }
+ else {
+ char *buf = region.address + region.start;
+ int i;
+ for (i = 0 ; i < lines ; i++) {
+ memcpy( buf, tex, src_pitch );
+ buf += dstPitch;
+ tex += src_pitch;
+ }
+ }
+
+ r200EmitWait( rmesa, RADEON_WAIT_3D );
+
+ /* Blit to framebuffer
+ */
+ r200EmitBlit( rmesa,
+ blit_format,
+ dstPitch, GET_START( &region ),
+ dstPitch | (t->tile_bits >> 16),
+ t->bufAddr,
+ 0, 0,
+ 0, done,
+ width, lines );
+
+ r200EmitWait( rmesa, RADEON_WAIT_2D );
+
+ r200ReleaseDmaRegion( rmesa, &region, __FUNCTION__ );
+ done += lines;
+ }
+ }
+}
+
+
+/**
+ * Upload the texture image associated with texture \a t at the specified
+ * level at the address relative to \a start.
+ */
+static void uploadSubImage( r200ContextPtr rmesa, r200TexObjPtr t,
+ GLint hwlevel,
+ GLint x, GLint y, GLint width, GLint height,
+ GLuint face )
+{
+ struct gl_texture_image *texImage = NULL;
+ GLuint offset;
+ GLint imageWidth, imageHeight;
+ GLint ret;
+ drm_radeon_texture_t tex;
+ drm_radeon_tex_image_t tmp;
+ const int level = hwlevel + t->base.firstLevel;
+
+ if ( R200_DEBUG & DEBUG_TEXTURE ) {
+ fprintf( stderr, "%s( %p, %p ) level/width/height/face = %d/%d/%d/%u\n",
+ __FUNCTION__, (void *)t, (void *)t->base.tObj,
+ level, width, height, face );
+ }
+
+ ASSERT(face < 6);
+
+ /* Ensure we have a valid texture to upload */
+ if ( ( hwlevel < 0 ) || ( hwlevel >= RADEON_MAX_TEXTURE_LEVELS ) ) {
+ _mesa_problem(NULL, "bad texture level in %s", __FUNCTION__);
+ return;
+ }
+
+ texImage = t->base.tObj->Image[face][level];
+
+ if ( !texImage ) {
+ if ( R200_DEBUG & DEBUG_TEXTURE )
+ fprintf( stderr, "%s: texImage %d is NULL!\n", __FUNCTION__, level );
+ return;
+ }
+ if ( !texImage->Data ) {
+ if ( R200_DEBUG & DEBUG_TEXTURE )
+ fprintf( stderr, "%s: image data is NULL!\n", __FUNCTION__ );
+ return;
+ }
+
+
+ if (t->base.tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
+ assert(level == 0);
+ assert(hwlevel == 0);
+ if ( R200_DEBUG & DEBUG_TEXTURE )
+ fprintf( stderr, "%s: image data is rectangular\n", __FUNCTION__);
+ r200UploadRectSubImage( rmesa, t, texImage, x, y, width, height );
+ return;
+ }
+ else if (texImage->IsClientData) {
+ if ( R200_DEBUG & DEBUG_TEXTURE )
+ fprintf( stderr, "%s: image data is in GART client storage\n",
+ __FUNCTION__);
+ r200UploadGARTClientSubImage( rmesa, t, texImage, hwlevel,
+ x, y, width, height );
+ return;
+ }
+ else if ( R200_DEBUG & DEBUG_TEXTURE )
+ fprintf( stderr, "%s: image data is in normal memory\n",
+ __FUNCTION__);
+
+
+ imageWidth = texImage->Width;
+ imageHeight = texImage->Height;
+
+ offset = t->bufAddr + t->base.totalSize / 6 * face;
+
+ if ( R200_DEBUG & (DEBUG_TEXTURE|DEBUG_IOCTL) ) {
+ GLint imageX = 0;
+ GLint imageY = 0;
+ GLint blitX = t->image[face][hwlevel].x;
+ GLint blitY = t->image[face][hwlevel].y;
+ GLint blitWidth = t->image[face][hwlevel].width;
+ GLint blitHeight = t->image[face][hwlevel].height;
+ fprintf( stderr, " upload image: %d,%d at %d,%d\n",
+ imageWidth, imageHeight, imageX, imageY );
+ fprintf( stderr, " upload blit: %d,%d at %d,%d\n",
+ blitWidth, blitHeight, blitX, blitY );
+ fprintf( stderr, " blit ofs: 0x%07x level: %d/%d\n",
+ (GLuint)offset, hwlevel, level );
+ }
+
+ t->image[face][hwlevel].data = texImage->Data;
+
+ /* Init the DRM_RADEON_TEXTURE command / drm_radeon_texture_t struct.
+ * NOTE: we're always use a 1KB-wide blit and I8 texture format.
+ * We used to use 1, 2 and 4-byte texels and used to use the texture
+ * width to dictate the blit width - but that won't work for compressed
+ * textures. (Brian)
+ * NOTE: can't do that with texture tiling. (sroland)
+ */
+ tex.offset = offset;
+ tex.image = &tmp;
+ /* copy (x,y,width,height,data) */
+ memcpy( &tmp, &t->image[face][hwlevel], sizeof(tmp) );
+
+ if (texImage->TexFormat->TexelBytes) {
+ /* use multi-byte upload scheme */
+ tex.height = imageHeight;
+ tex.width = imageWidth;
+ tex.format = t->pp_txformat & R200_TXFORMAT_FORMAT_MASK;
+ tex.pitch = MAX2((texImage->Width * texImage->TexFormat->TexelBytes) / 64, 1);
+ tex.offset += tmp.x & ~1023;
+ tmp.x = tmp.x % 1024;
+ if (t->tile_bits & R200_TXO_MICRO_TILE) {
+ /* need something like "tiled coordinates" ? */
+ tmp.y = tmp.x / (tex.pitch * 128) * 2;
+ tmp.x = tmp.x % (tex.pitch * 128) / 2 / texImage->TexFormat->TexelBytes;
+ tex.pitch |= RADEON_DST_TILE_MICRO >> 22;
+ }
+ else {
+ tmp.x = tmp.x >> (texImage->TexFormat->TexelBytes >> 1);
+ }
+ if ((t->tile_bits & R200_TXO_MACRO_TILE) &&
+ (texImage->Width * texImage->TexFormat->TexelBytes >= 256) &&
+ ((!(t->tile_bits & R200_TXO_MICRO_TILE) && (texImage->Height >= 8)) ||
+ (texImage->Height >= 16))) {
+ /* weird: R200 disables macro tiling if mip width is smaller than 256 bytes,
+ OR if height is smaller than 8 automatically, but if micro tiling is active
+ the limit is height 16 instead ? */
+ tex.pitch |= RADEON_DST_TILE_MACRO >> 22;
+ }
+ }
+ else {
+ /* In case of for instance 8x8 texture (2x2 dxt blocks), padding after the first two blocks is
+ needed (only with dxt1 since 2 dxt3/dxt5 blocks already use 32 Byte). */
+ /* set tex.height to 1/4 since 1 "macropixel" (dxt-block) has 4 real pixels. Needed
+ so the kernel module reads the right amount of data. */
+ tex.format = R200_TXFORMAT_I8; /* any 1-byte texel format */
+ tex.pitch = (BLIT_WIDTH_BYTES / 64);
+ tex.height = (imageHeight + 3) / 4;
+ tex.width = (imageWidth + 3) / 4;
+ switch (t->pp_txformat & R200_TXFORMAT_FORMAT_MASK) {
+ case R200_TXFORMAT_DXT1:
+ tex.width *= 8;
+ break;
+ case R200_TXFORMAT_DXT23:
+ case R200_TXFORMAT_DXT45:
+ tex.width *= 16;
+ break;
+ default:
+ fprintf(stderr, "unknown compressed tex format in uploadSubImage\n");
+ }
+ }
+
+ LOCK_HARDWARE( rmesa );
+ do {
+ ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_TEXTURE,
+ &tex, sizeof(drm_radeon_texture_t) );
+ if (ret) {
+ if (R200_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "DRM_RADEON_TEXTURE: again!\n");
+ usleep(1);
+ }
+ } while ( ret && errno == EAGAIN );
+
+ UNLOCK_HARDWARE( rmesa );
+
+ if ( ret ) {
+ fprintf( stderr, "DRM_RADEON_TEXTURE: return = %d\n", ret );
+ fprintf( stderr, " offset=0x%08x\n",
+ offset );
+ fprintf( stderr, " image width=%d height=%d\n",
+ imageWidth, imageHeight );
+ fprintf( stderr, " blit width=%d height=%d data=%p\n",
+ t->image[face][hwlevel].width, t->image[face][hwlevel].height,
+ t->image[face][hwlevel].data );
+ exit( 1 );
+ }
+}
+
+
+/**
+ * Upload the texture images associated with texture \a t. This might
+ * require the allocation of texture memory.
+ *
+ * \param rmesa Context pointer
+ * \param t Texture to be uploaded
+ * \param face Cube map face to be uploaded. Zero for non-cube maps.
+ */
+
+int r200UploadTexImages( r200ContextPtr rmesa, r200TexObjPtr t, GLuint face )
+{
+ const int numLevels = t->base.lastLevel - t->base.firstLevel + 1;
+
+ if ( R200_DEBUG & (DEBUG_TEXTURE|DEBUG_IOCTL) ) {
+ fprintf( stderr, "%s( %p, %p ) sz=%d lvls=%d-%d\n", __FUNCTION__,
+ (void *)rmesa->glCtx, (void *)t->base.tObj, t->base.totalSize,
+ t->base.firstLevel, t->base.lastLevel );
+ }
+
+ if ( !t || t->base.totalSize == 0 )
+ return 0;
+
+ if (R200_DEBUG & DEBUG_SYNC) {
+ fprintf(stderr, "%s: Syncing\n", __FUNCTION__ );
+ r200Finish( rmesa->glCtx );
+ }
+
+ LOCK_HARDWARE( rmesa );
+
+ if ( t->base.memBlock == NULL ) {
+ int heap;
+
+ heap = driAllocateTexture( rmesa->texture_heaps, rmesa->nr_heaps,
+ (driTextureObject *) t );
+ if ( heap == -1 ) {
+ UNLOCK_HARDWARE( rmesa );
+ return -1;
+ }
+
+ /* Set the base offset of the texture image */
+ t->bufAddr = rmesa->r200Screen->texOffset[heap]
+ + t->base.memBlock->ofs;
+ t->pp_txoffset = t->bufAddr;
+
+ if (!(t->base.tObj->Image[0][0]->IsClientData)) {
+ /* hope it's safe to add that here... */
+ t->pp_txoffset |= t->tile_bits;
+ }
+
+ /* Mark this texobj as dirty on all units:
+ */
+ t->dirty_state = TEX_ALL;
+ }
+
+ /* Let the world know we've used this memory recently.
+ */
+ driUpdateTextureLRU( (driTextureObject *) t );
+ UNLOCK_HARDWARE( rmesa );
+
+ /* Upload any images that are new */
+ if (t->base.dirty_images[face]) {
+ int i;
+ for ( i = 0 ; i < numLevels ; i++ ) {
+ if ( (t->base.dirty_images[face] & (1 << (i+t->base.firstLevel))) != 0 ) {
+ uploadSubImage( rmesa, t, i, 0, 0, t->image[face][i].width,
+ t->image[face][i].height, face );
+ }
+ }
+ t->base.dirty_images[face] = 0;
+ }
+
+
+ if (R200_DEBUG & DEBUG_SYNC) {
+ fprintf(stderr, "%s: Syncing\n", __FUNCTION__ );
+ r200Finish( rmesa->glCtx );
+ }
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_texstate.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_texstate.c
new file mode 100644
index 000000000..4a6b285a5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_texstate.c
@@ -0,0 +1,1468 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_texstate.c,v 1.3 2003/02/15 22:18:47 dawes Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "macros.h"
+#include "texformat.h"
+#include "enums.h"
+
+#include "r200_context.h"
+#include "r200_state.h"
+#include "r200_ioctl.h"
+#include "r200_swtcl.h"
+#include "r200_tex.h"
+#include "r200_tcl.h"
+
+
+#define R200_TXFORMAT_A8 R200_TXFORMAT_I8
+#define R200_TXFORMAT_L8 R200_TXFORMAT_I8
+#define R200_TXFORMAT_AL88 R200_TXFORMAT_AI88
+#define R200_TXFORMAT_YCBCR R200_TXFORMAT_YVYU422
+#define R200_TXFORMAT_YCBCR_REV R200_TXFORMAT_VYUY422
+#define R200_TXFORMAT_RGB_DXT1 R200_TXFORMAT_DXT1
+#define R200_TXFORMAT_RGBA_DXT1 R200_TXFORMAT_DXT1
+#define R200_TXFORMAT_RGBA_DXT3 R200_TXFORMAT_DXT23
+#define R200_TXFORMAT_RGBA_DXT5 R200_TXFORMAT_DXT45
+
+#define _COLOR(f) \
+ [ MESA_FORMAT_ ## f ] = { R200_TXFORMAT_ ## f, 0 }
+#define _COLOR_REV(f) \
+ [ MESA_FORMAT_ ## f ## _REV ] = { R200_TXFORMAT_ ## f, 0 }
+#define _ALPHA(f) \
+ [ MESA_FORMAT_ ## f ] = { R200_TXFORMAT_ ## f | R200_TXFORMAT_ALPHA_IN_MAP, 0 }
+#define _ALPHA_REV(f) \
+ [ MESA_FORMAT_ ## f ## _REV ] = { R200_TXFORMAT_ ## f | R200_TXFORMAT_ALPHA_IN_MAP, 0 }
+#define _YUV(f) \
+ [ MESA_FORMAT_ ## f ] = { R200_TXFORMAT_ ## f, R200_YUV_TO_RGB }
+#define _INVALID(f) \
+ [ MESA_FORMAT_ ## f ] = { 0xffffffff, 0 }
+#define VALID_FORMAT(f) ( ((f) <= MESA_FORMAT_RGBA_DXT5) \
+ && (tx_table[f].format != 0xffffffff) )
+
+static const struct {
+ GLuint format, filter;
+}
+tx_table[] =
+{
+ _ALPHA(RGBA8888),
+ _ALPHA_REV(RGBA8888),
+ _ALPHA(ARGB8888),
+ _ALPHA_REV(ARGB8888),
+ _INVALID(RGB888),
+ _COLOR(RGB565),
+ _COLOR_REV(RGB565),
+ _ALPHA(ARGB4444),
+ _ALPHA_REV(ARGB4444),
+ _ALPHA(ARGB1555),
+ _ALPHA_REV(ARGB1555),
+ _ALPHA(AL88),
+ _ALPHA_REV(AL88),
+ _ALPHA(A8),
+ _COLOR(L8),
+ _ALPHA(I8),
+ _INVALID(CI8),
+ _YUV(YCBCR),
+ _YUV(YCBCR_REV),
+ _INVALID(RGB_FXT1),
+ _INVALID(RGBA_FXT1),
+ _COLOR(RGB_DXT1),
+ _ALPHA(RGBA_DXT1),
+ _ALPHA(RGBA_DXT3),
+ _ALPHA(RGBA_DXT5),
+};
+
+#undef _COLOR
+#undef _ALPHA
+#undef _INVALID
+
+/**
+ * This function computes the number of bytes of storage needed for
+ * the given texture object (all mipmap levels, all cube faces).
+ * The \c image[face][level].x/y/width/height parameters for upload/blitting
+ * are computed here. \c pp_txfilter, \c pp_txformat, etc. will be set here
+ * too.
+ *
+ * \param rmesa Context pointer
+ * \param tObj GL texture object whose images are to be posted to
+ * hardware state.
+ */
+static void r200SetTexImages( r200ContextPtr rmesa,
+ struct gl_texture_object *tObj )
+{
+ r200TexObjPtr t = (r200TexObjPtr)tObj->DriverData;
+ const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
+ GLint curOffset, blitWidth;
+ GLint i, texelBytes;
+ GLint numLevels;
+ GLint log2Width, log2Height, log2Depth;
+
+ /* Set the hardware texture format
+ */
+
+ t->pp_txformat &= ~(R200_TXFORMAT_FORMAT_MASK |
+ R200_TXFORMAT_ALPHA_IN_MAP);
+ t->pp_txfilter &= ~R200_YUV_TO_RGB;
+
+ if ( VALID_FORMAT( baseImage->TexFormat->MesaFormat ) ) {
+ t->pp_txformat |= tx_table[ baseImage->TexFormat->MesaFormat ].format;
+ t->pp_txfilter |= tx_table[ baseImage->TexFormat->MesaFormat ].filter;
+ }
+ else {
+ _mesa_problem(NULL, "unexpected texture format in %s", __FUNCTION__);
+ return;
+ }
+
+ texelBytes = baseImage->TexFormat->TexelBytes;
+
+ /* Compute which mipmap levels we really want to send to the hardware.
+ */
+
+ driCalculateTextureFirstLastLevel( (driTextureObject *) t );
+ log2Width = tObj->Image[0][t->base.firstLevel]->WidthLog2;
+ log2Height = tObj->Image[0][t->base.firstLevel]->HeightLog2;
+ log2Depth = tObj->Image[0][t->base.firstLevel]->DepthLog2;
+
+ numLevels = t->base.lastLevel - t->base.firstLevel + 1;
+
+ assert(numLevels <= RADEON_MAX_TEXTURE_LEVELS);
+
+ /* Calculate mipmap offsets and dimensions for blitting (uploading)
+ * The idea is that we lay out the mipmap levels within a block of
+ * memory organized as a rectangle of width BLIT_WIDTH_BYTES.
+ */
+ curOffset = 0;
+ blitWidth = BLIT_WIDTH_BYTES;
+ t->tile_bits = 0;
+
+ /* figure out if this texture is suitable for tiling. */
+ if (texelBytes) {
+ if (rmesa->texmicrotile && (tObj->Target != GL_TEXTURE_RECTANGLE_NV) &&
+ /* texrect might be able to use micro tiling too in theory? */
+ (baseImage->Height > 1)) {
+ /* allow 32 (bytes) x 1 mip (which will use two times the space
+ the non-tiled version would use) max if base texture is large enough */
+ if ((numLevels == 1) ||
+ (((baseImage->Width * texelBytes / baseImage->Height) <= 32) &&
+ (baseImage->Width * texelBytes > 64)) ||
+ ((baseImage->Width * texelBytes / baseImage->Height) <= 16)) {
+ t->tile_bits |= R200_TXO_MICRO_TILE;
+ }
+ }
+ if (tObj->Target != GL_TEXTURE_RECTANGLE_NV) {
+ /* we can set macro tiling even for small textures, they will be untiled anyway */
+ t->tile_bits |= R200_TXO_MACRO_TILE;
+ }
+ }
+
+ for (i = 0; i < numLevels; i++) {
+ const struct gl_texture_image *texImage;
+ GLuint size;
+
+ texImage = tObj->Image[0][i + t->base.firstLevel];
+ if ( !texImage )
+ break;
+
+ /* find image size in bytes */
+ if (texImage->IsCompressed) {
+ /* need to calculate the size AFTER padding even though the texture is
+ submitted without padding.
+ Only handle pot textures currently - don't know if npot is even possible,
+ size calculation would certainly need (trivial) adjustments.
+ Align (and later pad) to 32byte, not sure what that 64byte blit width is
+ good for? */
+ if ((t->pp_txformat & R200_TXFORMAT_FORMAT_MASK) == R200_TXFORMAT_DXT1) {
+ /* RGB_DXT1/RGBA_DXT1, 8 bytes per block */
+ if ((texImage->Width + 3) < 8) /* width one block */
+ size = texImage->CompressedSize * 4;
+ else if ((texImage->Width + 3) < 16)
+ size = texImage->CompressedSize * 2;
+ else size = texImage->CompressedSize;
+ }
+ else /* DXT3/5, 16 bytes per block */
+ if ((texImage->Width + 3) < 8)
+ size = texImage->CompressedSize * 2;
+ else size = texImage->CompressedSize;
+ }
+ else if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
+ size = ((texImage->Width * texelBytes + 63) & ~63) * texImage->Height;
+ }
+ else if (t->tile_bits & R200_TXO_MICRO_TILE) {
+ /* tile pattern is 16 bytes x2. mipmaps stay 32 byte aligned,
+ though the actual offset may be different (if texture is less than
+ 32 bytes width) to the untiled case */
+ int w = (texImage->Width * texelBytes * 2 + 31) & ~31;
+ size = (w * ((texImage->Height + 1) / 2)) * texImage->Depth;
+ blitWidth = MAX2(texImage->Width, 64 / texelBytes);
+ }
+ else {
+ int w = (texImage->Width * texelBytes + 31) & ~31;
+ size = w * texImage->Height * texImage->Depth;
+ blitWidth = MAX2(texImage->Width, 64 / texelBytes);
+ }
+ assert(size > 0);
+
+ /* Align to 32-byte offset. It is faster to do this unconditionally
+ * (no branch penalty).
+ */
+
+ curOffset = (curOffset + 0x1f) & ~0x1f;
+
+ if (texelBytes) {
+ t->image[0][i].x = curOffset; /* fix x and y coords up later together with offset */
+ t->image[0][i].y = 0;
+ t->image[0][i].width = MIN2(size / texelBytes, blitWidth);
+ t->image[0][i].height = (size / texelBytes) / t->image[0][i].width;
+ }
+ else {
+ t->image[0][i].x = curOffset % BLIT_WIDTH_BYTES;
+ t->image[0][i].y = curOffset / BLIT_WIDTH_BYTES;
+ t->image[0][i].width = MIN2(size, BLIT_WIDTH_BYTES);
+ t->image[0][i].height = size / t->image[0][i].width;
+ }
+
+#if 0
+ /* for debugging only and only applicable to non-rectangle targets */
+ assert(size % t->image[0][i].width == 0);
+ assert(t->image[0][i].x == 0
+ || (size < BLIT_WIDTH_BYTES && t->image[0][i].height == 1));
+#endif
+
+ if (0)
+ fprintf(stderr,
+ "level %d: %dx%d x=%d y=%d w=%d h=%d size=%d at %d\n",
+ i, texImage->Width, texImage->Height,
+ t->image[0][i].x, t->image[0][i].y,
+ t->image[0][i].width, t->image[0][i].height, size, curOffset);
+
+ curOffset += size;
+
+ }
+
+ /* Align the total size of texture memory block.
+ */
+ t->base.totalSize = (curOffset + RADEON_OFFSET_MASK) & ~RADEON_OFFSET_MASK;
+
+ /* Setup remaining cube face blits, if needed */
+ if (tObj->Target == GL_TEXTURE_CUBE_MAP) {
+ const GLuint faceSize = t->base.totalSize;
+ GLuint face;
+ /* reuse face 0 x/y/width/height - just update the offset when uploading */
+ for (face = 1; face < 6; face++) {
+ for (i = 0; i < numLevels; i++) {
+ t->image[face][i].x = t->image[0][i].x;
+ t->image[face][i].y = t->image[0][i].y;
+ t->image[face][i].width = t->image[0][i].width;
+ t->image[face][i].height = t->image[0][i].height;
+ }
+ }
+ t->base.totalSize = 6 * faceSize; /* total texmem needed */
+ }
+
+
+ /* Hardware state:
+ */
+ t->pp_txfilter &= ~R200_MAX_MIP_LEVEL_MASK;
+ t->pp_txfilter |= (numLevels - 1) << R200_MAX_MIP_LEVEL_SHIFT;
+
+ t->pp_txformat &= ~(R200_TXFORMAT_WIDTH_MASK |
+ R200_TXFORMAT_HEIGHT_MASK |
+ R200_TXFORMAT_CUBIC_MAP_ENABLE |
+ R200_TXFORMAT_F5_WIDTH_MASK |
+ R200_TXFORMAT_F5_HEIGHT_MASK);
+ t->pp_txformat |= ((log2Width << R200_TXFORMAT_WIDTH_SHIFT) |
+ (log2Height << R200_TXFORMAT_HEIGHT_SHIFT));
+
+ t->pp_txformat_x &= ~(R200_DEPTH_LOG2_MASK | R200_TEXCOORD_MASK);
+ if (tObj->Target == GL_TEXTURE_3D) {
+ t->pp_txformat_x |= (log2Depth << R200_DEPTH_LOG2_SHIFT);
+ t->pp_txformat_x |= R200_TEXCOORD_VOLUME;
+ }
+ else if (tObj->Target == GL_TEXTURE_CUBE_MAP) {
+ ASSERT(log2Width == log2Height);
+ t->pp_txformat |= ((log2Width << R200_TXFORMAT_F5_WIDTH_SHIFT) |
+ (log2Height << R200_TXFORMAT_F5_HEIGHT_SHIFT) |
+ (R200_TXFORMAT_CUBIC_MAP_ENABLE));
+ t->pp_txformat_x |= R200_TEXCOORD_CUBIC_ENV;
+ t->pp_cubic_faces = ((log2Width << R200_FACE_WIDTH_1_SHIFT) |
+ (log2Height << R200_FACE_HEIGHT_1_SHIFT) |
+ (log2Width << R200_FACE_WIDTH_2_SHIFT) |
+ (log2Height << R200_FACE_HEIGHT_2_SHIFT) |
+ (log2Width << R200_FACE_WIDTH_3_SHIFT) |
+ (log2Height << R200_FACE_HEIGHT_3_SHIFT) |
+ (log2Width << R200_FACE_WIDTH_4_SHIFT) |
+ (log2Height << R200_FACE_HEIGHT_4_SHIFT));
+ }
+ else {
+ /* If we don't in fact send enough texture coordinates, q will be 1,
+ * making TEXCOORD_PROJ act like TEXCOORD_NONPROJ (Right?)
+ */
+ t->pp_txformat_x |= R200_TEXCOORD_PROJ;
+ }
+
+ t->pp_txsize = (((tObj->Image[0][t->base.firstLevel]->Width - 1) << 0) |
+ ((tObj->Image[0][t->base.firstLevel]->Height - 1) << 16));
+
+ /* Only need to round to nearest 32 for textures, but the blitter
+ * requires 64-byte aligned pitches, and we may/may not need the
+ * blitter. NPOT only!
+ */
+ if (baseImage->IsCompressed)
+ t->pp_txpitch = (tObj->Image[0][t->base.firstLevel]->Width + 63) & ~(63);
+ else
+ t->pp_txpitch = ((tObj->Image[0][t->base.firstLevel]->Width * texelBytes) + 63) & ~(63);
+ t->pp_txpitch -= 32;
+
+ t->dirty_state = TEX_ALL;
+
+ /* FYI: r200UploadTexImages( rmesa, t ) used to be called here */
+}
+
+
+
+/* ================================================================
+ * Texture combine functions
+ */
+
+/* GL_ARB_texture_env_combine support
+ */
+
+/* The color tables have combine functions for GL_SRC_COLOR,
+ * GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA.
+ */
+static GLuint r200_register_color[][R200_MAX_TEXTURE_UNITS] =
+{
+ {
+ R200_TXC_ARG_A_R0_COLOR,
+ R200_TXC_ARG_A_R1_COLOR,
+ R200_TXC_ARG_A_R2_COLOR,
+ R200_TXC_ARG_A_R3_COLOR,
+ R200_TXC_ARG_A_R4_COLOR,
+ R200_TXC_ARG_A_R5_COLOR
+ },
+ {
+ R200_TXC_ARG_A_R0_COLOR | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R1_COLOR | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R2_COLOR | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R3_COLOR | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R4_COLOR | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R5_COLOR | R200_TXC_COMP_ARG_A
+ },
+ {
+ R200_TXC_ARG_A_R0_ALPHA,
+ R200_TXC_ARG_A_R1_ALPHA,
+ R200_TXC_ARG_A_R2_ALPHA,
+ R200_TXC_ARG_A_R3_ALPHA,
+ R200_TXC_ARG_A_R4_ALPHA,
+ R200_TXC_ARG_A_R5_ALPHA
+ },
+ {
+ R200_TXC_ARG_A_R0_ALPHA | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R1_ALPHA | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R2_ALPHA | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R3_ALPHA | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R4_ALPHA | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R5_ALPHA | R200_TXC_COMP_ARG_A
+ },
+};
+
+static GLuint r200_tfactor_color[] =
+{
+ R200_TXC_ARG_A_TFACTOR_COLOR,
+ R200_TXC_ARG_A_TFACTOR_COLOR | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_TFACTOR_ALPHA,
+ R200_TXC_ARG_A_TFACTOR_ALPHA | R200_TXC_COMP_ARG_A
+};
+
+static GLuint r200_primary_color[] =
+{
+ R200_TXC_ARG_A_DIFFUSE_COLOR,
+ R200_TXC_ARG_A_DIFFUSE_COLOR | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_DIFFUSE_ALPHA,
+ R200_TXC_ARG_A_DIFFUSE_ALPHA | R200_TXC_COMP_ARG_A
+};
+
+/* GL_ZERO table - indices 0-3
+ * GL_ONE table - indices 1-4
+ */
+static GLuint r200_zero_color[] =
+{
+ R200_TXC_ARG_A_ZERO,
+ R200_TXC_ARG_A_ZERO | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_ZERO,
+ R200_TXC_ARG_A_ZERO | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_ZERO
+};
+
+/* The alpha tables only have GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA.
+ */
+static GLuint r200_register_alpha[][R200_MAX_TEXTURE_UNITS] =
+{
+ {
+ R200_TXA_ARG_A_R0_ALPHA,
+ R200_TXA_ARG_A_R1_ALPHA,
+ R200_TXA_ARG_A_R2_ALPHA,
+ R200_TXA_ARG_A_R3_ALPHA,
+ R200_TXA_ARG_A_R4_ALPHA,
+ R200_TXA_ARG_A_R5_ALPHA
+ },
+ {
+ R200_TXA_ARG_A_R0_ALPHA | R200_TXA_COMP_ARG_A,
+ R200_TXA_ARG_A_R1_ALPHA | R200_TXA_COMP_ARG_A,
+ R200_TXA_ARG_A_R2_ALPHA | R200_TXA_COMP_ARG_A,
+ R200_TXA_ARG_A_R3_ALPHA | R200_TXA_COMP_ARG_A,
+ R200_TXA_ARG_A_R4_ALPHA | R200_TXA_COMP_ARG_A,
+ R200_TXA_ARG_A_R5_ALPHA | R200_TXA_COMP_ARG_A
+ },
+};
+
+static GLuint r200_tfactor_alpha[] =
+{
+ R200_TXA_ARG_A_TFACTOR_ALPHA,
+ R200_TXA_ARG_A_TFACTOR_ALPHA | R200_TXA_COMP_ARG_A
+};
+
+static GLuint r200_primary_alpha[] =
+{
+ R200_TXA_ARG_A_DIFFUSE_ALPHA,
+ R200_TXA_ARG_A_DIFFUSE_ALPHA | R200_TXA_COMP_ARG_A
+};
+
+/* GL_ZERO table - indices 0-1
+ * GL_ONE table - indices 1-2
+ */
+static GLuint r200_zero_alpha[] =
+{
+ R200_TXA_ARG_A_ZERO,
+ R200_TXA_ARG_A_ZERO | R200_TXA_COMP_ARG_A,
+ R200_TXA_ARG_A_ZERO,
+};
+
+
+/* Extract the arg from slot A, shift it into the correct argument slot
+ * and set the corresponding complement bit.
+ */
+#define R200_COLOR_ARG( n, arg ) \
+do { \
+ color_combine |= \
+ ((color_arg[n] & R200_TXC_ARG_A_MASK) \
+ << R200_TXC_ARG_##arg##_SHIFT); \
+ color_combine |= \
+ ((color_arg[n] >> R200_TXC_COMP_ARG_A_SHIFT) \
+ << R200_TXC_COMP_ARG_##arg##_SHIFT); \
+} while (0)
+
+#define R200_ALPHA_ARG( n, arg ) \
+do { \
+ alpha_combine |= \
+ ((alpha_arg[n] & R200_TXA_ARG_A_MASK) \
+ << R200_TXA_ARG_##arg##_SHIFT); \
+ alpha_combine |= \
+ ((alpha_arg[n] >> R200_TXA_COMP_ARG_A_SHIFT) \
+ << R200_TXA_COMP_ARG_##arg##_SHIFT); \
+} while (0)
+
+
+/* ================================================================
+ * Texture unit state management
+ */
+
+static GLboolean r200UpdateTextureEnv( GLcontext *ctx, int unit )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ GLuint color_combine, alpha_combine;
+ GLuint color_scale = rmesa->hw.pix[unit].cmd[PIX_PP_TXCBLEND2] &
+ ~(R200_TXC_SCALE_MASK);
+ GLuint alpha_scale = rmesa->hw.pix[unit].cmd[PIX_PP_TXABLEND2] &
+ ~(R200_TXA_DOT_ALPHA | R200_TXA_SCALE_MASK);
+
+ /* texUnit->_Current can be NULL if and only if the texture unit is
+ * not actually enabled.
+ */
+ assert( (texUnit->_ReallyEnabled == 0)
+ || (texUnit->_Current != NULL) );
+
+ if ( R200_DEBUG & DEBUG_TEXTURE ) {
+ fprintf( stderr, "%s( %p, %d )\n", __FUNCTION__, (void *)ctx, unit );
+ }
+
+ /* Set the texture environment state. Isn't this nice and clean?
+ * The chip will automagically set the texture alpha to 0xff when
+ * the texture format does not include an alpha component. This
+ * reduces the amount of special-casing we have to do, alpha-only
+ * textures being a notable exception.
+ */
+ /* Don't cache these results.
+ */
+ rmesa->state.texture.unit[unit].format = 0;
+ rmesa->state.texture.unit[unit].envMode = 0;
+
+ if ( !texUnit->_ReallyEnabled ) {
+ if ( unit == 0 ) {
+ color_combine = R200_TXC_ARG_A_ZERO | R200_TXC_ARG_B_ZERO
+ | R200_TXC_ARG_C_DIFFUSE_COLOR | R200_TXC_OP_MADD;
+ alpha_combine = R200_TXA_ARG_A_ZERO | R200_TXA_ARG_B_ZERO
+ | R200_TXA_ARG_C_DIFFUSE_ALPHA | R200_TXA_OP_MADD;
+ }
+ else {
+ color_combine = R200_TXC_ARG_A_ZERO | R200_TXC_ARG_B_ZERO
+ | R200_TXC_ARG_C_R0_COLOR | R200_TXC_OP_MADD;
+ alpha_combine = R200_TXA_ARG_A_ZERO | R200_TXA_ARG_B_ZERO
+ | R200_TXA_ARG_C_R0_ALPHA | R200_TXA_OP_MADD;
+ }
+ }
+ else {
+ GLuint color_arg[3], alpha_arg[3];
+ GLuint i;
+ const GLuint numColorArgs = texUnit->_CurrentCombine->_NumArgsRGB;
+ const GLuint numAlphaArgs = texUnit->_CurrentCombine->_NumArgsA;
+ GLuint RGBshift = texUnit->_CurrentCombine->ScaleShiftRGB;
+ GLuint Ashift = texUnit->_CurrentCombine->ScaleShiftA;
+
+
+ /* Step 1:
+ * Extract the color and alpha combine function arguments.
+ */
+ for ( i = 0 ; i < numColorArgs ; i++ ) {
+ const GLint op = texUnit->_CurrentCombine->OperandRGB[i] - GL_SRC_COLOR;
+ assert(op >= 0);
+ assert(op <= 3);
+ switch ( texUnit->_CurrentCombine->SourceRGB[i] ) {
+ case GL_TEXTURE:
+ color_arg[i] = r200_register_color[op][unit];
+ break;
+ case GL_CONSTANT:
+ color_arg[i] = r200_tfactor_color[op];
+ break;
+ case GL_PRIMARY_COLOR:
+ color_arg[i] = r200_primary_color[op];
+ break;
+ case GL_PREVIOUS:
+ if (unit == 0)
+ color_arg[i] = r200_primary_color[op];
+ else
+ color_arg[i] = r200_register_color[op][0];
+ break;
+ case GL_ZERO:
+ color_arg[i] = r200_zero_color[op];
+ break;
+ case GL_ONE:
+ color_arg[i] = r200_zero_color[op+1];
+ break;
+ default:
+ return GL_FALSE;
+ }
+ }
+
+ for ( i = 0 ; i < numAlphaArgs ; i++ ) {
+ const GLint op = texUnit->_CurrentCombine->OperandA[i] - GL_SRC_ALPHA;
+ assert(op >= 0);
+ assert(op <= 1);
+ switch ( texUnit->_CurrentCombine->SourceA[i] ) {
+ case GL_TEXTURE:
+ alpha_arg[i] = r200_register_alpha[op][unit];
+ break;
+ case GL_CONSTANT:
+ alpha_arg[i] = r200_tfactor_alpha[op];
+ break;
+ case GL_PRIMARY_COLOR:
+ alpha_arg[i] = r200_primary_alpha[op];
+ break;
+ case GL_PREVIOUS:
+ if (unit == 0)
+ alpha_arg[i] = r200_primary_alpha[op];
+ else
+ alpha_arg[i] = r200_register_alpha[op][0];
+ break;
+ case GL_ZERO:
+ alpha_arg[i] = r200_zero_alpha[op];
+ break;
+ case GL_ONE:
+ alpha_arg[i] = r200_zero_alpha[op+1];
+ break;
+ default:
+ return GL_FALSE;
+ }
+ }
+
+ /* Step 2:
+ * Build up the color and alpha combine functions.
+ */
+ switch ( texUnit->_CurrentCombine->ModeRGB ) {
+ case GL_REPLACE:
+ color_combine = (R200_TXC_ARG_A_ZERO |
+ R200_TXC_ARG_B_ZERO |
+ R200_TXC_OP_MADD);
+ R200_COLOR_ARG( 0, C );
+ break;
+ case GL_MODULATE:
+ color_combine = (R200_TXC_ARG_C_ZERO |
+ R200_TXC_OP_MADD);
+ R200_COLOR_ARG( 0, A );
+ R200_COLOR_ARG( 1, B );
+ break;
+ case GL_ADD:
+ color_combine = (R200_TXC_ARG_B_ZERO |
+ R200_TXC_COMP_ARG_B |
+ R200_TXC_OP_MADD);
+ R200_COLOR_ARG( 0, A );
+ R200_COLOR_ARG( 1, C );
+ break;
+ case GL_ADD_SIGNED:
+ color_combine = (R200_TXC_ARG_B_ZERO |
+ R200_TXC_COMP_ARG_B |
+ R200_TXC_BIAS_ARG_C | /* new */
+ R200_TXC_OP_MADD); /* was ADDSIGNED */
+ R200_COLOR_ARG( 0, A );
+ R200_COLOR_ARG( 1, C );
+ break;
+ case GL_SUBTRACT:
+ color_combine = (R200_TXC_ARG_B_ZERO |
+ R200_TXC_COMP_ARG_B |
+ R200_TXC_NEG_ARG_C |
+ R200_TXC_OP_MADD);
+ R200_COLOR_ARG( 0, A );
+ R200_COLOR_ARG( 1, C );
+ break;
+ case GL_INTERPOLATE:
+ color_combine = (R200_TXC_OP_LERP);
+ R200_COLOR_ARG( 0, B );
+ R200_COLOR_ARG( 1, A );
+ R200_COLOR_ARG( 2, C );
+ break;
+
+ case GL_DOT3_RGB_EXT:
+ case GL_DOT3_RGBA_EXT:
+ /* The EXT version of the DOT3 extension does not support the
+ * scale factor, but the ARB version (and the version in OpenGL
+ * 1.3) does.
+ */
+ RGBshift = 0;
+ /* FALLTHROUGH */
+
+ case GL_DOT3_RGB:
+ case GL_DOT3_RGBA:
+ /* DOT3 works differently on R200 than on R100. On R100, just
+ * setting the DOT3 mode did everything for you. On R200, the
+ * driver has to enable the biasing and scale in the inputs to
+ * put them in the proper [-1,1] range. This is what the 4x and
+ * the -0.5 in the DOT3 spec do. The post-scale is then set
+ * normally.
+ */
+
+ color_combine = (R200_TXC_ARG_C_ZERO |
+ R200_TXC_OP_DOT3 |
+ R200_TXC_BIAS_ARG_A |
+ R200_TXC_BIAS_ARG_B |
+ R200_TXC_SCALE_ARG_A |
+ R200_TXC_SCALE_ARG_B);
+ R200_COLOR_ARG( 0, A );
+ R200_COLOR_ARG( 1, B );
+ break;
+
+ case GL_MODULATE_ADD_ATI:
+ color_combine = (R200_TXC_OP_MADD);
+ R200_COLOR_ARG( 0, A );
+ R200_COLOR_ARG( 1, C );
+ R200_COLOR_ARG( 2, B );
+ break;
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ color_combine = (R200_TXC_BIAS_ARG_C | /* new */
+ R200_TXC_OP_MADD); /* was ADDSIGNED */
+ R200_COLOR_ARG( 0, A );
+ R200_COLOR_ARG( 1, C );
+ R200_COLOR_ARG( 2, B );
+ break;
+ case GL_MODULATE_SUBTRACT_ATI:
+ color_combine = (R200_TXC_NEG_ARG_C |
+ R200_TXC_OP_MADD);
+ R200_COLOR_ARG( 0, A );
+ R200_COLOR_ARG( 1, C );
+ R200_COLOR_ARG( 2, B );
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+ switch ( texUnit->_CurrentCombine->ModeA ) {
+ case GL_REPLACE:
+ alpha_combine = (R200_TXA_ARG_A_ZERO |
+ R200_TXA_ARG_B_ZERO |
+ R200_TXA_OP_MADD);
+ R200_ALPHA_ARG( 0, C );
+ break;
+ case GL_MODULATE:
+ alpha_combine = (R200_TXA_ARG_C_ZERO |
+ R200_TXA_OP_MADD);
+ R200_ALPHA_ARG( 0, A );
+ R200_ALPHA_ARG( 1, B );
+ break;
+ case GL_ADD:
+ alpha_combine = (R200_TXA_ARG_B_ZERO |
+ R200_TXA_COMP_ARG_B |
+ R200_TXA_OP_MADD);
+ R200_ALPHA_ARG( 0, A );
+ R200_ALPHA_ARG( 1, C );
+ break;
+ case GL_ADD_SIGNED:
+ alpha_combine = (R200_TXA_ARG_B_ZERO |
+ R200_TXA_COMP_ARG_B |
+ R200_TXA_BIAS_ARG_C | /* new */
+ R200_TXA_OP_MADD); /* was ADDSIGNED */
+ R200_ALPHA_ARG( 0, A );
+ R200_ALPHA_ARG( 1, C );
+ break;
+ case GL_SUBTRACT:
+ alpha_combine = (R200_TXA_ARG_B_ZERO |
+ R200_TXA_COMP_ARG_B |
+ R200_TXA_NEG_ARG_C |
+ R200_TXA_OP_MADD);
+ R200_ALPHA_ARG( 0, A );
+ R200_ALPHA_ARG( 1, C );
+ break;
+ case GL_INTERPOLATE:
+ alpha_combine = (R200_TXA_OP_LERP);
+ R200_ALPHA_ARG( 0, B );
+ R200_ALPHA_ARG( 1, A );
+ R200_ALPHA_ARG( 2, C );
+ break;
+
+ case GL_MODULATE_ADD_ATI:
+ alpha_combine = (R200_TXA_OP_MADD);
+ R200_ALPHA_ARG( 0, A );
+ R200_ALPHA_ARG( 1, C );
+ R200_ALPHA_ARG( 2, B );
+ break;
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ alpha_combine = (R200_TXA_BIAS_ARG_C | /* new */
+ R200_TXA_OP_MADD); /* was ADDSIGNED */
+ R200_ALPHA_ARG( 0, A );
+ R200_ALPHA_ARG( 1, C );
+ R200_ALPHA_ARG( 2, B );
+ break;
+ case GL_MODULATE_SUBTRACT_ATI:
+ alpha_combine = (R200_TXA_NEG_ARG_C |
+ R200_TXA_OP_MADD);
+ R200_ALPHA_ARG( 0, A );
+ R200_ALPHA_ARG( 1, C );
+ R200_ALPHA_ARG( 2, B );
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+ if ( (texUnit->_CurrentCombine->ModeRGB == GL_DOT3_RGBA_EXT)
+ || (texUnit->_CurrentCombine->ModeRGB == GL_DOT3_RGBA) ) {
+ alpha_scale |= R200_TXA_DOT_ALPHA;
+ Ashift = RGBshift;
+ }
+
+ /* Step 3:
+ * Apply the scale factor.
+ */
+ color_scale |= (RGBshift << R200_TXC_SCALE_SHIFT);
+ alpha_scale |= (Ashift << R200_TXA_SCALE_SHIFT);
+
+ /* All done!
+ */
+ }
+
+ if ( rmesa->hw.pix[unit].cmd[PIX_PP_TXCBLEND] != color_combine ||
+ rmesa->hw.pix[unit].cmd[PIX_PP_TXABLEND] != alpha_combine ||
+ rmesa->hw.pix[unit].cmd[PIX_PP_TXCBLEND2] != color_scale ||
+ rmesa->hw.pix[unit].cmd[PIX_PP_TXABLEND2] != alpha_scale) {
+ R200_STATECHANGE( rmesa, pix[unit] );
+ rmesa->hw.pix[unit].cmd[PIX_PP_TXCBLEND] = color_combine;
+ rmesa->hw.pix[unit].cmd[PIX_PP_TXABLEND] = alpha_combine;
+ rmesa->hw.pix[unit].cmd[PIX_PP_TXCBLEND2] = color_scale;
+ rmesa->hw.pix[unit].cmd[PIX_PP_TXABLEND2] = alpha_scale;
+ }
+
+ return GL_TRUE;
+}
+
+#define TEXOBJ_TXFILTER_MASK (R200_MAX_MIP_LEVEL_MASK | \
+ R200_MIN_FILTER_MASK | \
+ R200_MAG_FILTER_MASK | \
+ R200_MAX_ANISO_MASK | \
+ R200_YUV_TO_RGB | \
+ R200_YUV_TEMPERATURE_MASK | \
+ R200_CLAMP_S_MASK | \
+ R200_CLAMP_T_MASK | \
+ R200_BORDER_MODE_D3D )
+
+#define TEXOBJ_TXFORMAT_MASK (R200_TXFORMAT_WIDTH_MASK | \
+ R200_TXFORMAT_HEIGHT_MASK | \
+ R200_TXFORMAT_FORMAT_MASK | \
+ R200_TXFORMAT_F5_WIDTH_MASK | \
+ R200_TXFORMAT_F5_HEIGHT_MASK | \
+ R200_TXFORMAT_ALPHA_IN_MAP | \
+ R200_TXFORMAT_CUBIC_MAP_ENABLE | \
+ R200_TXFORMAT_NON_POWER2)
+
+#define TEXOBJ_TXFORMAT_X_MASK (R200_DEPTH_LOG2_MASK | \
+ R200_TEXCOORD_MASK | \
+ R200_CLAMP_Q_MASK | \
+ R200_VOLUME_FILTER_MASK)
+
+
+static void import_tex_obj_state( r200ContextPtr rmesa,
+ int unit,
+ r200TexObjPtr texobj )
+{
+ GLuint *cmd = R200_DB_STATE( tex[unit] );
+
+ cmd[TEX_PP_TXFILTER] &= ~TEXOBJ_TXFILTER_MASK;
+ cmd[TEX_PP_TXFILTER] |= texobj->pp_txfilter & TEXOBJ_TXFILTER_MASK;
+ cmd[TEX_PP_TXFORMAT] &= ~TEXOBJ_TXFORMAT_MASK;
+ cmd[TEX_PP_TXFORMAT] |= texobj->pp_txformat & TEXOBJ_TXFORMAT_MASK;
+ cmd[TEX_PP_TXFORMAT_X] &= ~TEXOBJ_TXFORMAT_X_MASK;
+ cmd[TEX_PP_TXFORMAT_X] |= texobj->pp_txformat_x & TEXOBJ_TXFORMAT_X_MASK;
+ cmd[TEX_PP_TXSIZE] = texobj->pp_txsize; /* NPOT only! */
+ cmd[TEX_PP_TXPITCH] = texobj->pp_txpitch; /* NPOT only! */
+ cmd[TEX_PP_TXOFFSET] = texobj->pp_txoffset;
+ cmd[TEX_PP_BORDER_COLOR] = texobj->pp_border_color;
+ R200_DB_STATECHANGE( rmesa, &rmesa->hw.tex[unit] );
+
+ if (texobj->base.tObj->Target == GL_TEXTURE_CUBE_MAP) {
+ GLuint *cube_cmd = R200_DB_STATE( cube[unit] );
+ GLuint bytesPerFace = texobj->base.totalSize / 6;
+ ASSERT(texobj->base.totalSize % 6 == 0);
+ cube_cmd[CUBE_PP_CUBIC_FACES] = texobj->pp_cubic_faces;
+ cube_cmd[CUBE_PP_CUBIC_OFFSET_F1] = texobj->pp_txoffset + 1 * bytesPerFace;
+ cube_cmd[CUBE_PP_CUBIC_OFFSET_F2] = texobj->pp_txoffset + 2 * bytesPerFace;
+ cube_cmd[CUBE_PP_CUBIC_OFFSET_F3] = texobj->pp_txoffset + 3 * bytesPerFace;
+ cube_cmd[CUBE_PP_CUBIC_OFFSET_F4] = texobj->pp_txoffset + 4 * bytesPerFace;
+ cube_cmd[CUBE_PP_CUBIC_OFFSET_F5] = texobj->pp_txoffset + 5 * bytesPerFace;
+ R200_DB_STATECHANGE( rmesa, &rmesa->hw.cube[unit] );
+ }
+
+ texobj->dirty_state &= ~(1<<unit);
+}
+
+
+static void set_texgen_matrix( r200ContextPtr rmesa,
+ GLuint unit,
+ const GLfloat *s_plane,
+ const GLfloat *t_plane,
+ const GLfloat *r_plane,
+ const GLfloat *q_plane )
+{
+ GLfloat m[16];
+
+ m[0] = s_plane[0];
+ m[4] = s_plane[1];
+ m[8] = s_plane[2];
+ m[12] = s_plane[3];
+
+ m[1] = t_plane[0];
+ m[5] = t_plane[1];
+ m[9] = t_plane[2];
+ m[13] = t_plane[3];
+
+ m[2] = r_plane[0];
+ m[6] = r_plane[1];
+ m[10] = r_plane[2];
+ m[14] = r_plane[3];
+
+ m[3] = q_plane[0];
+ m[7] = q_plane[1];
+ m[11] = q_plane[2];
+ m[15] = q_plane[3];
+
+ _math_matrix_loadf( &(rmesa->TexGenMatrix[unit]), m);
+ _math_matrix_analyse( &(rmesa->TexGenMatrix[unit]) );
+ rmesa->TexGenEnabled |= R200_TEXMAT_0_ENABLE<<unit;
+}
+
+
+/*
+ * Returns GL_FALSE if fallback required.
+ */
+static GLboolean r200_validate_texgen( GLcontext *ctx, GLuint unit )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ GLuint inputshift = R200_TEXGEN_0_INPUT_SHIFT + unit*4;
+ GLuint tgi, tgcm;
+ GLuint mode = 0;
+ GLboolean mixed_fallback = GL_FALSE;
+ static const GLfloat I[16] = {
+ 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 1, 0,
+ 0, 0, 0, 1 };
+ static const GLfloat reflect[16] = {
+ -1, 0, 0, 0,
+ 0, -1, 0, 0,
+ 0, 0, -1, 0,
+ 0, 0, 0, 1 };
+
+ rmesa->TexGenCompSel &= ~(R200_OUTPUT_TEX_0 << unit);
+ rmesa->TexGenEnabled &= ~(R200_TEXGEN_TEXMAT_0_ENABLE<<unit);
+ rmesa->TexGenEnabled &= ~(R200_TEXMAT_0_ENABLE<<unit);
+ rmesa->TexGenNeedNormals[unit] = GL_FALSE;
+ tgi = rmesa->hw.tcg.cmd[TCG_TEX_PROC_CTL_1] & ~(R200_TEXGEN_INPUT_MASK <<
+ inputshift);
+ tgcm = rmesa->hw.tcg.cmd[TCG_TEX_PROC_CTL_2] & ~(R200_TEXGEN_COMP_MASK <<
+ (unit * 4));
+
+ if (0)
+ fprintf(stderr, "%s unit %d\n", __FUNCTION__, unit);
+
+ if (texUnit->TexGenEnabled & S_BIT) {
+ mode = texUnit->GenModeS;
+ } else {
+ tgcm |= R200_TEXGEN_COMP_S << (unit * 4);
+ }
+
+ if (texUnit->TexGenEnabled & T_BIT) {
+ if (texUnit->GenModeT != mode)
+ mixed_fallback = GL_TRUE;
+ } else {
+ tgcm |= R200_TEXGEN_COMP_T << (unit * 4);
+ }
+
+ if (texUnit->TexGenEnabled & R_BIT) {
+ if (texUnit->GenModeR != mode)
+ mixed_fallback = GL_TRUE;
+ } else {
+ tgcm |= R200_TEXGEN_COMP_R << (unit * 4);
+ }
+
+ if (texUnit->TexGenEnabled & Q_BIT) {
+ if (texUnit->GenModeQ != mode)
+ mixed_fallback = GL_TRUE;
+ } else {
+ tgcm |= R200_TEXGEN_COMP_Q << (unit * 4);
+ }
+
+ if (mixed_fallback) {
+ if (R200_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "fallback mixed texgen, 0x%x (0x%x 0x%x 0x%x 0x%x)\n",
+ texUnit->TexGenEnabled, texUnit->GenModeS, texUnit->GenModeT,
+ texUnit->GenModeR, texUnit->GenModeQ);
+ return GL_FALSE;
+ }
+
+ switch (mode) {
+ case GL_OBJECT_LINEAR:
+ tgi |= R200_TEXGEN_INPUT_OBJ << inputshift;
+ set_texgen_matrix( rmesa, unit,
+ (texUnit->TexGenEnabled & S_BIT) ? texUnit->ObjectPlaneS : I,
+ (texUnit->TexGenEnabled & T_BIT) ? texUnit->ObjectPlaneT : I + 4,
+ (texUnit->TexGenEnabled & R_BIT) ? texUnit->ObjectPlaneR : I + 8,
+ (texUnit->TexGenEnabled & Q_BIT) ? texUnit->ObjectPlaneQ : I + 12);
+ break;
+
+ case GL_EYE_LINEAR:
+ tgi |= R200_TEXGEN_INPUT_EYE << inputshift;
+ set_texgen_matrix( rmesa, unit,
+ (texUnit->TexGenEnabled & S_BIT) ? texUnit->EyePlaneS : I,
+ (texUnit->TexGenEnabled & T_BIT) ? texUnit->EyePlaneT : I + 4,
+ (texUnit->TexGenEnabled & R_BIT) ? texUnit->EyePlaneR : I + 8,
+ (texUnit->TexGenEnabled & Q_BIT) ? texUnit->EyePlaneQ : I + 12);
+ break;
+
+ case GL_REFLECTION_MAP_NV:
+ rmesa->TexGenNeedNormals[unit] = GL_TRUE;
+ tgi |= R200_TEXGEN_INPUT_EYE_REFLECT<<inputshift;
+ set_texgen_matrix( rmesa, unit,
+ (texUnit->TexGenEnabled & S_BIT) ? reflect : I,
+ (texUnit->TexGenEnabled & T_BIT) ? reflect + 4 : I + 4,
+ (texUnit->TexGenEnabled & R_BIT) ? reflect + 8 : I + 8,
+ I + 12);
+ break;
+
+ case GL_NORMAL_MAP_NV:
+ rmesa->TexGenNeedNormals[unit] = GL_TRUE;
+ tgi |= R200_TEXGEN_INPUT_EYE_NORMAL<<inputshift;
+ break;
+
+ case GL_SPHERE_MAP:
+ rmesa->TexGenNeedNormals[unit] = GL_TRUE;
+ tgi |= R200_TEXGEN_INPUT_SPHERE<<inputshift;
+ break;
+
+ case 0:
+ /* All texgen units were disabled, so just pass coords through. */
+ tgi |= unit << inputshift;
+ break;
+
+ default:
+ /* Unsupported mode, fallback:
+ */
+ if (R200_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "fallback unsupported texgen, %d\n",
+ texUnit->GenModeS);
+ return GL_FALSE;
+ }
+
+ rmesa->TexGenEnabled |= R200_TEXGEN_TEXMAT_0_ENABLE << unit;
+ rmesa->TexGenCompSel |= R200_OUTPUT_TEX_0 << unit;
+
+ if (tgi != rmesa->hw.tcg.cmd[TCG_TEX_PROC_CTL_1] ||
+ tgcm != rmesa->hw.tcg.cmd[TCG_TEX_PROC_CTL_2])
+ {
+ R200_STATECHANGE(rmesa, tcg);
+ rmesa->hw.tcg.cmd[TCG_TEX_PROC_CTL_1] = tgi;
+ rmesa->hw.tcg.cmd[TCG_TEX_PROC_CTL_2] = tgcm;
+ }
+
+ return GL_TRUE;
+}
+
+
+static void disable_tex( GLcontext *ctx, int unit )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if (rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_0_ENABLE<<unit)) {
+ /* Texture unit disabled */
+ if ( rmesa->state.texture.unit[unit].texobj != NULL ) {
+ /* The old texture is no longer bound to this texture unit.
+ * Mark it as such.
+ */
+
+ rmesa->state.texture.unit[unit].texobj->base.bound &= ~(1UL << unit);
+ rmesa->state.texture.unit[unit].texobj = NULL;
+ }
+
+ R200_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~((R200_TEX_0_ENABLE |
+ R200_TEX_BLEND_0_ENABLE) << unit);
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_TEX_BLEND_0_ENABLE;
+
+ R200_STATECHANGE( rmesa, vtx );
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] &= ~(7 << (unit * 3));
+
+ if (rmesa->TclFallback & (R200_TCL_FALLBACK_TEXGEN_0<<unit)) {
+ TCL_FALLBACK( ctx, (R200_TCL_FALLBACK_TEXGEN_0<<unit), GL_FALSE);
+ }
+
+ /* Actually want to keep all units less than max active texture
+ * enabled, right? Fix this for >2 texunits.
+ */
+ /* FIXME: What should happen here if r200UpdateTextureEnv fails? */
+ if (unit == 0)
+ r200UpdateTextureEnv( ctx, unit );
+
+
+ {
+ GLuint tmp = rmesa->TexGenEnabled;
+
+ rmesa->TexGenEnabled &= ~(R200_TEXGEN_TEXMAT_0_ENABLE<<unit);
+ rmesa->TexGenEnabled &= ~(R200_TEXMAT_0_ENABLE<<unit);
+ rmesa->TexGenNeedNormals[unit] = GL_FALSE;
+ rmesa->TexGenCompSel &= ~(R200_OUTPUT_TEX_0 << unit);
+
+ if (tmp != rmesa->TexGenEnabled) {
+ rmesa->recheck_texgen[unit] = GL_TRUE;
+ rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
+ }
+ }
+ }
+}
+
+static void set_re_cntl_d3d( GLcontext *ctx, int unit, GLboolean use_d3d )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ GLuint re_cntl;
+
+ re_cntl = rmesa->hw.set.cmd[SET_RE_CNTL] & ~(R200_VTX_STQ0_D3D << (2 * unit));
+ if (use_d3d)
+ re_cntl |= R200_VTX_STQ0_D3D << (2 * unit);
+
+ if ( re_cntl != rmesa->hw.set.cmd[SET_RE_CNTL] ) {
+ R200_STATECHANGE( rmesa, set );
+ rmesa->hw.set.cmd[SET_RE_CNTL] = re_cntl;
+ }
+}
+
+static GLboolean enable_tex_2d( GLcontext *ctx, int unit )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ r200TexObjPtr t = (r200TexObjPtr) tObj->DriverData;
+
+ /* Need to load the 2d images associated with this unit.
+ */
+ if (t->pp_txformat & R200_TXFORMAT_NON_POWER2) {
+ t->pp_txformat &= ~R200_TXFORMAT_NON_POWER2;
+ t->base.dirty_images[0] = ~0;
+ }
+
+ ASSERT(tObj->Target == GL_TEXTURE_2D || tObj->Target == GL_TEXTURE_1D);
+
+ if ( t->base.dirty_images[0] ) {
+ R200_FIREVERTICES( rmesa );
+ r200SetTexImages( rmesa, tObj );
+ r200UploadTexImages( rmesa, (r200TexObjPtr) tObj->DriverData, 0 );
+ if ( !t->base.memBlock )
+ return GL_FALSE;
+ }
+
+ set_re_cntl_d3d( ctx, unit, GL_FALSE );
+
+ return GL_TRUE;
+}
+
+#if ENABLE_HW_3D_TEXTURE
+static GLboolean enable_tex_3d( GLcontext *ctx, int unit )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ r200TexObjPtr t = (r200TexObjPtr) tObj->DriverData;
+
+ /* Need to load the 3d images associated with this unit.
+ */
+ if (t->pp_txformat & R200_TXFORMAT_NON_POWER2) {
+ t->pp_txformat &= ~R200_TXFORMAT_NON_POWER2;
+ t->base.dirty_images[0] = ~0;
+ }
+
+ ASSERT(tObj->Target == GL_TEXTURE_3D);
+
+ /* R100 & R200 do not support mipmaps for 3D textures.
+ */
+ if ( (tObj->MinFilter != GL_NEAREST) && (tObj->MinFilter != GL_LINEAR) ) {
+ return GL_FALSE;
+ }
+
+ if ( t->base.dirty_images[0] ) {
+ R200_FIREVERTICES( rmesa );
+ r200SetTexImages( rmesa, tObj );
+ r200UploadTexImages( rmesa, (r200TexObjPtr) tObj->DriverData, 0 );
+ if ( !t->base.memBlock )
+ return GL_FALSE;
+ }
+
+ set_re_cntl_d3d( ctx, unit, GL_TRUE );
+
+ return GL_TRUE;
+}
+#endif
+
+static GLboolean enable_tex_cube( GLcontext *ctx, int unit )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ r200TexObjPtr t = (r200TexObjPtr) tObj->DriverData;
+ GLuint face;
+
+ /* Need to load the 2d images associated with this unit.
+ */
+ if (t->pp_txformat & R200_TXFORMAT_NON_POWER2) {
+ t->pp_txformat &= ~R200_TXFORMAT_NON_POWER2;
+ for (face = 0; face < 6; face++)
+ t->base.dirty_images[face] = ~0;
+ }
+
+ ASSERT(tObj->Target == GL_TEXTURE_CUBE_MAP);
+
+ if ( t->base.dirty_images[0] || t->base.dirty_images[1] ||
+ t->base.dirty_images[2] || t->base.dirty_images[3] ||
+ t->base.dirty_images[4] || t->base.dirty_images[5] ) {
+ /* flush */
+ R200_FIREVERTICES( rmesa );
+ /* layout memory space, once for all faces */
+ r200SetTexImages( rmesa, tObj );
+ }
+
+ /* upload (per face) */
+ for (face = 0; face < 6; face++) {
+ if (t->base.dirty_images[face]) {
+ r200UploadTexImages( rmesa, (r200TexObjPtr) tObj->DriverData, face );
+ }
+ }
+
+ if ( !t->base.memBlock ) {
+ /* texmem alloc failed, use s/w fallback */
+ return GL_FALSE;
+ }
+
+ set_re_cntl_d3d( ctx, unit, GL_TRUE );
+
+ return GL_TRUE;
+}
+
+static GLboolean enable_tex_rect( GLcontext *ctx, int unit )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ r200TexObjPtr t = (r200TexObjPtr) tObj->DriverData;
+
+ if (!(t->pp_txformat & R200_TXFORMAT_NON_POWER2)) {
+ t->pp_txformat |= R200_TXFORMAT_NON_POWER2;
+ t->base.dirty_images[0] = ~0;
+ }
+
+ ASSERT(tObj->Target == GL_TEXTURE_RECTANGLE_NV);
+
+ if ( t->base.dirty_images[0] ) {
+ R200_FIREVERTICES( rmesa );
+ r200SetTexImages( rmesa, tObj );
+ r200UploadTexImages( rmesa, (r200TexObjPtr) tObj->DriverData, 0 );
+ if ( !t->base.memBlock && !rmesa->prefer_gart_client_texturing )
+ return GL_FALSE;
+ }
+
+ set_re_cntl_d3d( ctx, unit, GL_FALSE );
+
+ return GL_TRUE;
+}
+
+
+static GLboolean update_tex_common( GLcontext *ctx, int unit )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ r200TexObjPtr t = (r200TexObjPtr) tObj->DriverData;
+ GLenum format;
+
+ /* Fallback if there's a texture border */
+ if ( tObj->Image[0][tObj->BaseLevel]->Border > 0 )
+ return GL_FALSE;
+
+ /* Update state if this is a different texture object to last
+ * time.
+ */
+ if ( rmesa->state.texture.unit[unit].texobj != t ) {
+ if ( rmesa->state.texture.unit[unit].texobj != NULL ) {
+ /* The old texture is no longer bound to this texture unit.
+ * Mark it as such.
+ */
+
+ rmesa->state.texture.unit[unit].texobj->base.bound &=
+ ~(1UL << unit);
+ }
+
+ rmesa->state.texture.unit[unit].texobj = t;
+ t->base.bound |= (1UL << unit);
+ t->dirty_state |= 1<<unit;
+ driUpdateTextureLRU( (driTextureObject *) t ); /* XXX: should be locked! */
+ }
+
+
+ /* Newly enabled?
+ */
+ if ( 1|| !(rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_0_ENABLE<<unit))) {
+ R200_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= (R200_TEX_0_ENABLE |
+ R200_TEX_BLEND_0_ENABLE) << unit;
+
+ R200_STATECHANGE( rmesa, vtx );
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] &= ~(7 << (unit * 3));
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] |= 4 << (unit * 3);
+
+ rmesa->recheck_texgen[unit] = GL_TRUE;
+ }
+
+ if (t->dirty_state & (1<<unit)) {
+ import_tex_obj_state( rmesa, unit, t );
+ }
+
+ if (rmesa->recheck_texgen[unit]) {
+ GLboolean fallback = !r200_validate_texgen( ctx, unit );
+ TCL_FALLBACK( ctx, (R200_TCL_FALLBACK_TEXGEN_0<<unit), fallback);
+ rmesa->recheck_texgen[unit] = 0;
+ rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
+ }
+
+ format = tObj->Image[0][tObj->BaseLevel]->Format;
+ if ( rmesa->state.texture.unit[unit].format != format ||
+ rmesa->state.texture.unit[unit].envMode != texUnit->EnvMode ) {
+ rmesa->state.texture.unit[unit].format = format;
+ rmesa->state.texture.unit[unit].envMode = texUnit->EnvMode;
+ if ( ! r200UpdateTextureEnv( ctx, unit ) ) {
+ return GL_FALSE;
+ }
+ }
+
+ FALLBACK( rmesa, R200_FALLBACK_BORDER_MODE, t->border_fallback );
+ return !t->border_fallback;
+}
+
+
+
+static GLboolean r200UpdateTextureUnit( GLcontext *ctx, int unit )
+{
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+ if ( texUnit->_ReallyEnabled & (TEXTURE_RECT_BIT) ) {
+ return (enable_tex_rect( ctx, unit ) &&
+ update_tex_common( ctx, unit ));
+ }
+ else if ( texUnit->_ReallyEnabled & (TEXTURE_1D_BIT | TEXTURE_2D_BIT) ) {
+ return (enable_tex_2d( ctx, unit ) &&
+ update_tex_common( ctx, unit ));
+ }
+#if ENABLE_HW_3D_TEXTURE
+ else if ( texUnit->_ReallyEnabled & (TEXTURE_3D_BIT) ) {
+ return (enable_tex_3d( ctx, unit ) &&
+ update_tex_common( ctx, unit ));
+ }
+#endif
+ else if ( texUnit->_ReallyEnabled & (TEXTURE_CUBE_BIT) ) {
+ return (enable_tex_cube( ctx, unit ) &&
+ update_tex_common( ctx, unit ));
+ }
+ else if ( texUnit->_ReallyEnabled ) {
+ return GL_FALSE;
+ }
+ else {
+ disable_tex( ctx, unit );
+ return GL_TRUE;
+ }
+}
+
+
+void r200UpdateTextureState( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLboolean ok;
+ GLuint dbg;
+
+ ok = (r200UpdateTextureUnit( ctx, 0 ) &&
+ r200UpdateTextureUnit( ctx, 1 ) &&
+ r200UpdateTextureUnit( ctx, 2 ) &&
+ r200UpdateTextureUnit( ctx, 3 ) &&
+ r200UpdateTextureUnit( ctx, 4 ) &&
+ r200UpdateTextureUnit( ctx, 5 ));
+
+ FALLBACK( rmesa, R200_FALLBACK_TEXTURE, !ok );
+
+ if (rmesa->TclFallback)
+ r200ChooseVertexState( ctx );
+
+
+ if (rmesa->r200Screen->chipset & R200_CHIPSET_REAL_R200) {
+
+ /*
+ * T0 hang workaround -------------
+ * not needed for r200 derivatives?
+ */
+ if ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_ENABLE_MASK) == R200_TEX_0_ENABLE &&
+ (rmesa->hw.tex[0].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK) > R200_MIN_FILTER_LINEAR) {
+
+ R200_STATECHANGE(rmesa, ctx);
+ R200_STATECHANGE(rmesa, tex[1]);
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_TEX_1_ENABLE;
+ rmesa->hw.tex[1].cmd[TEX_PP_TXFORMAT] &= ~TEXOBJ_TXFORMAT_MASK;
+ rmesa->hw.tex[1].cmd[TEX_PP_TXFORMAT] |= 0x08000000;
+ }
+ else {
+ if ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_1_ENABLE) &&
+ (rmesa->hw.tex[1].cmd[TEX_PP_TXFORMAT] & 0x08000000)) {
+ R200_STATECHANGE(rmesa, tex[1]);
+ rmesa->hw.tex[1].cmd[TEX_PP_TXFORMAT] &= ~0x08000000;
+ }
+ }
+
+ /* maybe needs to be done pairwise due to 2 parallel (physical) tex units ?
+ looks like that's not the case, if 8500/9100 owners don't complain remove this...
+ for ( i = 0; i < ctx->Const.MaxTextureUnits; i += 2) {
+ if (((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & ((R200_TEX_0_ENABLE |
+ R200_TEX_1_ENABLE ) << i)) == (R200_TEX_0_ENABLE << i)) &&
+ ((rmesa->hw.tex[i].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK) >
+ R200_MIN_FILTER_LINEAR)) {
+ R200_STATECHANGE(rmesa, ctx);
+ R200_STATECHANGE(rmesa, tex[i+1]);
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= (R200_TEX_1_ENABLE << i);
+ rmesa->hw.tex[i+1].cmd[TEX_PP_TXFORMAT] &= ~TEXOBJ_TXFORMAT_MASK;
+ rmesa->hw.tex[i+1].cmd[TEX_PP_TXFORMAT] |= 0x08000000;
+ }
+ else {
+ if ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_1_ENABLE << i)) &&
+ (rmesa->hw.tex[i+1].cmd[TEX_PP_TXFORMAT] & 0x08000000)) {
+ R200_STATECHANGE(rmesa, tex[i+1]);
+ rmesa->hw.tex[i+1].cmd[TEX_PP_TXFORMAT] &= ~0x08000000;
+ }
+ }
+ } */
+
+ /*
+ * Texture cache LRU hang workaround -------------
+ * not needed for r200 derivatives?
+ */
+
+ /* While the cases below attempt to only enable the workaround in the
+ * specific cases necessary, they were insufficient. See bugzilla #1519,
+ * #729, #814. Tests with quake3 showed no impact on performance.
+ */
+ dbg = 0x6;
+
+ /*
+ if (((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_0_ENABLE )) &&
+ ((((rmesa->hw.tex[0].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
+ 0x04) == 0)) ||
+ ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_2_ENABLE) &&
+ ((((rmesa->hw.tex[2].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
+ 0x04) == 0)) ||
+ ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_4_ENABLE) &&
+ ((((rmesa->hw.tex[4].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
+ 0x04) == 0)))
+ {
+ dbg |= 0x02;
+ }
+
+ if (((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_1_ENABLE )) &&
+ ((((rmesa->hw.tex[1].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
+ 0x04) == 0)) ||
+ ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_3_ENABLE) &&
+ ((((rmesa->hw.tex[3].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
+ 0x04) == 0)) ||
+ ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_5_ENABLE) &&
+ ((((rmesa->hw.tex[5].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
+ 0x04) == 0)))
+ {
+ dbg |= 0x04;
+ }*/
+
+ if (dbg != rmesa->hw.tam.cmd[TAM_DEBUG3]) {
+ R200_STATECHANGE( rmesa, tam );
+ rmesa->hw.tam.cmd[TAM_DEBUG3] = dbg;
+ if (0) printf("TEXCACHE LRU HANG WORKAROUND %x\n", dbg);
+ }
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt.c
new file mode 100644
index 000000000..08173fda2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt.c
@@ -0,0 +1,1227 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_vtxfmt.c,v 1.4 2003/05/06 23:52:08 daenzer Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "r200_context.h"
+#include "r200_state.h"
+#include "r200_ioctl.h"
+#include "r200_tex.h"
+#include "r200_tcl.h"
+#include "r200_swtcl.h"
+#include "r200_vtxfmt.h"
+
+#include "api_noop.h"
+#include "api_arrayelt.h"
+#include "context.h"
+#include "mtypes.h"
+#include "enums.h"
+#include "glapi.h"
+#include "colormac.h"
+#include "light.h"
+#include "state.h"
+#include "vtxfmt.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_array_api.h"
+
+#include "dispatch.h"
+
+static void r200VtxFmtFlushVertices( GLcontext *, GLuint );
+
+static void count_func( const char *name, struct dynfn *l )
+{
+ int i = 0;
+ struct dynfn *f;
+ foreach (f, l) i++;
+ if (i) fprintf(stderr, "%s: %d\n", name, i );
+}
+
+static void count_funcs( r200ContextPtr rmesa )
+{
+ count_func( "Vertex2f", &rmesa->vb.dfn_cache.Vertex2f );
+ count_func( "Vertex2fv", &rmesa->vb.dfn_cache.Vertex2fv );
+ count_func( "Vertex3f", &rmesa->vb.dfn_cache.Vertex3f );
+ count_func( "Vertex3fv", &rmesa->vb.dfn_cache.Vertex3fv );
+ count_func( "Color4ub", &rmesa->vb.dfn_cache.Color4ub );
+ count_func( "Color4ubv", &rmesa->vb.dfn_cache.Color4ubv );
+ count_func( "Color3ub", &rmesa->vb.dfn_cache.Color3ub );
+ count_func( "Color3ubv", &rmesa->vb.dfn_cache.Color3ubv );
+ count_func( "Color4f", &rmesa->vb.dfn_cache.Color4f );
+ count_func( "Color4fv", &rmesa->vb.dfn_cache.Color4fv );
+ count_func( "Color3f", &rmesa->vb.dfn_cache.Color3f );
+ count_func( "Color3fv", &rmesa->vb.dfn_cache.Color3fv );
+ count_func( "SecondaryColor3f", &rmesa->vb.dfn_cache.SecondaryColor3fEXT );
+ count_func( "SecondaryColor3fv", &rmesa->vb.dfn_cache.SecondaryColor3fvEXT );
+ count_func( "SecondaryColor3ub", &rmesa->vb.dfn_cache.SecondaryColor3ubEXT );
+ count_func( "SecondaryColor3ubv", &rmesa->vb.dfn_cache.SecondaryColor3ubvEXT );
+ count_func( "Normal3f", &rmesa->vb.dfn_cache.Normal3f );
+ count_func( "Normal3fv", &rmesa->vb.dfn_cache.Normal3fv );
+ count_func( "TexCoord3f", &rmesa->vb.dfn_cache.TexCoord3f );
+ count_func( "TexCoord3fv", &rmesa->vb.dfn_cache.TexCoord3fv );
+ count_func( "TexCoord2f", &rmesa->vb.dfn_cache.TexCoord2f );
+ count_func( "TexCoord2fv", &rmesa->vb.dfn_cache.TexCoord2fv );
+ count_func( "TexCoord1f", &rmesa->vb.dfn_cache.TexCoord1f );
+ count_func( "TexCoord1fv", &rmesa->vb.dfn_cache.TexCoord1fv );
+ count_func( "MultiTexCoord3fARB", &rmesa->vb.dfn_cache.MultiTexCoord3fARB );
+ count_func( "MultiTexCoord3fvARB", &rmesa->vb.dfn_cache.MultiTexCoord3fvARB );
+ count_func( "MultiTexCoord2fARB", &rmesa->vb.dfn_cache.MultiTexCoord2fARB );
+ count_func( "MultiTexCoord2fvARB", &rmesa->vb.dfn_cache.MultiTexCoord2fvARB );
+ count_func( "MultiTexCoord1fARB", &rmesa->vb.dfn_cache.MultiTexCoord1fARB );
+ count_func( "MultiTexCoord1fvARB", &rmesa->vb.dfn_cache.MultiTexCoord1fvARB );
+/* count_func( "FogCoordfEXT", &rmesa->vb.dfn_cache.FogCoordfEXT );
+ count_func( "FogCoordfvEXT", &rmesa->vb.dfn_cache.FogCoordfvEXT );*/
+}
+
+
+void r200_copy_to_current( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ unsigned i;
+
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ assert(ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT);
+
+ if (rmesa->vb.vtxfmt_0 & R200_VTX_N0) {
+ ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0] = rmesa->vb.normalptr[0];
+ ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1] = rmesa->vb.normalptr[1];
+ ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2] = rmesa->vb.normalptr[2];
+ }
+
+ if (rmesa->vb.vtxfmt_0 & R200_VTX_DISCRETE_FOG) {
+ ctx->Current.Attrib[VERT_ATTRIB_FOG][0] = rmesa->vb.fogptr[0];
+ }
+
+ switch( VTX_COLOR(rmesa->vb.vtxfmt_0, 0) ) {
+ case R200_VTX_PK_RGBA:
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0] = UBYTE_TO_FLOAT( rmesa->vb.colorptr->red );
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1] = UBYTE_TO_FLOAT( rmesa->vb.colorptr->green );
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2] = UBYTE_TO_FLOAT( rmesa->vb.colorptr->blue );
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3] = UBYTE_TO_FLOAT( rmesa->vb.colorptr->alpha );
+ break;
+
+ case R200_VTX_FP_RGB:
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0] = rmesa->vb.floatcolorptr[0];
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1] = rmesa->vb.floatcolorptr[1];
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2] = rmesa->vb.floatcolorptr[2];
+ break;
+
+ case R200_VTX_FP_RGBA:
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0] = rmesa->vb.floatcolorptr[0];
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1] = rmesa->vb.floatcolorptr[1];
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2] = rmesa->vb.floatcolorptr[2];
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3] = rmesa->vb.floatcolorptr[3];
+ break;
+
+ default:
+ break;
+ }
+
+ if (VTX_COLOR(rmesa->vb.vtxfmt_0, 1) == R200_VTX_PK_RGBA) {
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0] = UBYTE_TO_FLOAT( rmesa->vb.specptr->red );
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1] = UBYTE_TO_FLOAT( rmesa->vb.specptr->green );
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2] = UBYTE_TO_FLOAT( rmesa->vb.specptr->blue );
+ }
+
+ for ( i = 0 ; i < ctx->Const.MaxTextureUnits ; i++ ) {
+ const unsigned count = VTX_TEXn_COUNT( rmesa->vb.vtxfmt_1, i );
+ GLfloat * const src = rmesa->vb.texcoordptr[i];
+
+ if ( count != 0 ) {
+ switch( count ) {
+ case 3:
+ ctx->Current.Attrib[VERT_ATTRIB_TEX0+i][1] = src[1];
+ ctx->Current.Attrib[VERT_ATTRIB_TEX0+i][2] = src[2];
+ break;
+ case 2:
+ ctx->Current.Attrib[VERT_ATTRIB_TEX0+i][1] = src[1];
+ ctx->Current.Attrib[VERT_ATTRIB_TEX0+i][2] = 0.0F;
+ break;
+ case 1:
+ ctx->Current.Attrib[VERT_ATTRIB_TEX0+i][1] = 0.0F;
+ ctx->Current.Attrib[VERT_ATTRIB_TEX0+i][2] = 0.0F;
+ break;
+ }
+
+ ctx->Current.Attrib[VERT_ATTRIB_TEX0+i][0] = src[0];
+ ctx->Current.Attrib[VERT_ATTRIB_TEX0+i][3] = 1.0F;
+ }
+ }
+
+ ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT;
+}
+
+static GLboolean discreet_gl_prim[GL_POLYGON+1] = {
+ 1, /* 0 points */
+ 1, /* 1 lines */
+ 0, /* 2 line_strip */
+ 0, /* 3 line_loop */
+ 1, /* 4 tris */
+ 0, /* 5 tri_fan */
+ 0, /* 6 tri_strip */
+ 1, /* 7 quads */
+ 0, /* 8 quadstrip */
+ 0, /* 9 poly */
+};
+
+static void flush_prims( r200ContextPtr rmesa )
+{
+ int i,j;
+ struct r200_dma_region tmp = rmesa->dma.current;
+
+ tmp.buf->refcount++;
+ tmp.aos_size = rmesa->vb.vertex_size;
+ tmp.aos_stride = rmesa->vb.vertex_size;
+ tmp.aos_start = GET_START(&tmp);
+
+ rmesa->dma.current.ptr = rmesa->dma.current.start +=
+ (rmesa->vb.initial_counter - rmesa->vb.counter) *
+ rmesa->vb.vertex_size * 4;
+
+ rmesa->tcl.vertex_format = rmesa->vb.vtxfmt_0;
+ rmesa->tcl.aos_components[0] = &tmp;
+ rmesa->tcl.nr_aos_components = 1;
+ rmesa->dma.flush = NULL;
+
+ /* Optimize the primitive list:
+ */
+ if (rmesa->vb.nrprims > 1) {
+ for (j = 0, i = 1 ; i < rmesa->vb.nrprims; i++) {
+ int pj = rmesa->vb.primlist[j].prim & 0xf;
+ int pi = rmesa->vb.primlist[i].prim & 0xf;
+
+ if (pj == pi && discreet_gl_prim[pj] &&
+ rmesa->vb.primlist[i].start == rmesa->vb.primlist[j].end) {
+ rmesa->vb.primlist[j].end = rmesa->vb.primlist[i].end;
+ }
+ else {
+ j++;
+ if (j != i) rmesa->vb.primlist[j] = rmesa->vb.primlist[i];
+ }
+ }
+ rmesa->vb.nrprims = j+1;
+ }
+
+ if (rmesa->vb.vtxfmt_0 != rmesa->hw.vtx.cmd[VTX_VTXFMT_0] ||
+ rmesa->vb.vtxfmt_1 != rmesa->hw.vtx.cmd[VTX_VTXFMT_1]) {
+ R200_STATECHANGE( rmesa, vtx );
+ rmesa->hw.vtx.cmd[VTX_VTXFMT_0] = rmesa->vb.vtxfmt_0;
+ rmesa->hw.vtx.cmd[VTX_VTXFMT_1] = rmesa->vb.vtxfmt_1;
+ }
+
+
+ for (i = 0 ; i < rmesa->vb.nrprims; i++) {
+ if (R200_DEBUG & DEBUG_PRIMS)
+ fprintf(stderr, "vtxfmt prim %d: %s %d..%d\n", i,
+ _mesa_lookup_enum_by_nr( rmesa->vb.primlist[i].prim &
+ PRIM_MODE_MASK ),
+ rmesa->vb.primlist[i].start,
+ rmesa->vb.primlist[i].end);
+
+ if (rmesa->vb.primlist[i].start < rmesa->vb.primlist[i].end)
+ r200EmitPrimitive( rmesa->glCtx,
+ rmesa->vb.primlist[i].start,
+ rmesa->vb.primlist[i].end,
+ rmesa->vb.primlist[i].prim );
+ }
+
+ rmesa->vb.nrprims = 0;
+ r200ReleaseDmaRegion( rmesa, &tmp, __FUNCTION__ );
+}
+
+
+static void start_prim( r200ContextPtr rmesa, GLuint mode )
+{
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s %d\n", __FUNCTION__,
+ rmesa->vb.initial_counter - rmesa->vb.counter);
+
+ rmesa->vb.primlist[rmesa->vb.nrprims].start =
+ rmesa->vb.initial_counter - rmesa->vb.counter;
+ rmesa->vb.primlist[rmesa->vb.nrprims].prim = mode;
+}
+
+static void note_last_prim( r200ContextPtr rmesa, GLuint flags )
+{
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s %d\n", __FUNCTION__,
+ rmesa->vb.initial_counter - rmesa->vb.counter);
+
+ if (rmesa->vb.prim[0] != GL_POLYGON+1) {
+ rmesa->vb.primlist[rmesa->vb.nrprims].prim |= flags;
+ rmesa->vb.primlist[rmesa->vb.nrprims].end =
+ rmesa->vb.initial_counter - rmesa->vb.counter;
+
+ if (++(rmesa->vb.nrprims) == R200_MAX_PRIMS)
+ flush_prims( rmesa );
+ }
+}
+
+
+static void copy_vertex( r200ContextPtr rmesa, GLuint n, GLfloat *dst )
+{
+ GLuint i;
+ GLfloat *src = (GLfloat *)(rmesa->dma.current.address +
+ rmesa->dma.current.ptr +
+ (rmesa->vb.primlist[rmesa->vb.nrprims].start + n) *
+ rmesa->vb.vertex_size * 4);
+
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "copy_vertex %d\n", rmesa->vb.primlist[rmesa->vb.nrprims].start + n);
+
+ for (i = 0 ; i < rmesa->vb.vertex_size; i++) {
+ dst[i] = src[i];
+ }
+}
+
+/* NOTE: This actually reads the copied vertices back from uncached
+ * memory. Could also use the counter/notify mechanism to populate
+ * tmp on the fly as vertices are generated.
+ */
+static GLuint copy_dma_verts( r200ContextPtr rmesa, GLfloat (*tmp)[R200_MAX_VERTEX_SIZE] )
+{
+ GLuint ovf, i;
+ GLuint nr = (rmesa->vb.initial_counter - rmesa->vb.counter) -
+ rmesa->vb.primlist[rmesa->vb.nrprims].start;
+
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s %d verts\n", __FUNCTION__, nr);
+
+ switch( rmesa->vb.prim[0] )
+ {
+ case GL_POINTS:
+ return 0;
+ case GL_LINES:
+ ovf = nr&1;
+ for (i = 0 ; i < ovf ; i++)
+ copy_vertex( rmesa, nr-ovf+i, tmp[i] );
+ return i;
+ case GL_TRIANGLES:
+ ovf = nr%3;
+ for (i = 0 ; i < ovf ; i++)
+ copy_vertex( rmesa, nr-ovf+i, tmp[i] );
+ return i;
+ case GL_QUADS:
+ ovf = nr&3;
+ for (i = 0 ; i < ovf ; i++)
+ copy_vertex( rmesa, nr-ovf+i, tmp[i] );
+ return i;
+ case GL_LINE_STRIP:
+ if (nr == 0)
+ return 0;
+ copy_vertex( rmesa, nr-1, tmp[0] );
+ return 1;
+ case GL_LINE_LOOP:
+ case GL_TRIANGLE_FAN:
+ case GL_POLYGON:
+ if (nr == 0)
+ return 0;
+ else if (nr == 1) {
+ copy_vertex( rmesa, 0, tmp[0] );
+ return 1;
+ } else {
+ copy_vertex( rmesa, 0, tmp[0] );
+ copy_vertex( rmesa, nr-1, tmp[1] );
+ return 2;
+ }
+ case GL_TRIANGLE_STRIP:
+ ovf = MIN2( nr, 2 );
+ for (i = 0 ; i < ovf ; i++)
+ copy_vertex( rmesa, nr-ovf+i, tmp[i] );
+ return i;
+ case GL_QUAD_STRIP:
+ switch (nr) {
+ case 0: ovf = 0; break;
+ case 1: ovf = 1; break;
+ default: ovf = 2 + (nr&1); break;
+ }
+ for (i = 0 ; i < ovf ; i++)
+ copy_vertex( rmesa, nr-ovf+i, tmp[i] );
+ return i;
+ default:
+ assert(0);
+ return 0;
+ }
+}
+
+static void VFMT_FALLBACK_OUTSIDE_BEGIN_END( const char *caller )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if (R200_DEBUG & (DEBUG_VFMT|DEBUG_FALLBACKS))
+ fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
+
+ if (ctx->Driver.NeedFlush)
+ r200VtxFmtFlushVertices( ctx, ctx->Driver.NeedFlush );
+
+ if (ctx->NewState)
+ _mesa_update_state( ctx ); /* clear state so fell_back sticks */
+
+ _tnl_wakeup_exec( ctx );
+ ctx->Driver.FlushVertices = r200FlushVertices;
+
+ assert( rmesa->dma.flush == 0 );
+ rmesa->vb.fell_back = GL_TRUE;
+ rmesa->vb.installed = GL_FALSE;
+}
+
+
+/**
+ * \todo
+ * An interesting optimization of this function would be to have 3 element
+ * table with the dispatch offsets of the TexCoord?fv functions, use count
+ * to look-up the table, and a specialized version of GL_CALL that used the
+ * offset number instead of the name.
+ */
+static void dispatch_multitexcoord( GLuint count, GLuint unit, GLfloat * f )
+{
+ switch( count ) {
+ case 3:
+ CALL_MultiTexCoord3fvARB(GET_DISPATCH(), (GL_TEXTURE0+unit, f));
+ break;
+ case 2:
+ CALL_MultiTexCoord2fvARB(GET_DISPATCH(), (GL_TEXTURE0+unit, f));
+ break;
+ case 1:
+ CALL_MultiTexCoord1fvARB(GET_DISPATCH(), (GL_TEXTURE0+unit, f));
+ break;
+ default:
+ assert( count == 0 );
+ break;
+ }
+}
+
+void VFMT_FALLBACK( const char *caller )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat tmp[3][R200_MAX_VERTEX_SIZE];
+ GLuint i, prim;
+ GLuint ind0 = rmesa->vb.vtxfmt_0;
+ GLuint ind1 = rmesa->vb.vtxfmt_1;
+ GLuint nrverts;
+ GLfloat alpha = 1.0;
+ GLuint count;
+ GLuint unit;
+
+ if (R200_DEBUG & (DEBUG_FALLBACKS|DEBUG_VFMT))
+ fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
+
+ if (rmesa->vb.prim[0] == GL_POLYGON+1) {
+ VFMT_FALLBACK_OUTSIDE_BEGIN_END( __FUNCTION__ );
+ return;
+ }
+
+ /* Copy vertices out of dma:
+ */
+ nrverts = copy_dma_verts( rmesa, tmp );
+
+ /* Finish the prim at this point:
+ */
+ note_last_prim( rmesa, 0 );
+ flush_prims( rmesa );
+
+ /* Update ctx->Driver.CurrentExecPrimitive and swap in swtnl.
+ */
+ prim = rmesa->vb.prim[0];
+ ctx->Driver.CurrentExecPrimitive = GL_POLYGON+1;
+ _tnl_wakeup_exec( ctx );
+ ctx->Driver.FlushVertices = r200FlushVertices;
+
+ assert(rmesa->dma.flush == 0);
+ rmesa->vb.fell_back = GL_TRUE;
+ rmesa->vb.installed = GL_FALSE;
+ CALL_Begin(GET_DISPATCH(), (prim));
+
+ if (rmesa->vb.installed_color_3f_sz == 4)
+ alpha = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3];
+
+ /* Replay saved vertices
+ */
+ for (i = 0 ; i < nrverts; i++) {
+ GLuint offset = 3;
+
+ if (ind0 & R200_VTX_N0) {
+ CALL_Normal3fv(GET_DISPATCH(), (&tmp[i][offset]));
+ offset += 3;
+ }
+
+ if (ind0 & R200_VTX_DISCRETE_FOG) {
+ CALL_FogCoordfvEXT(GET_DISPATCH(), (&tmp[i][offset]));
+ offset++;
+ }
+
+ if (VTX_COLOR(ind0, 0) == R200_VTX_PK_RGBA) {
+ CALL_Color4ubv(GET_DISPATCH(), ((GLubyte *)&tmp[i][offset]));
+ offset++;
+ }
+ else if (VTX_COLOR(ind0, 0) == R200_VTX_FP_RGBA) {
+ CALL_Color4fv(GET_DISPATCH(), (&tmp[i][offset]));
+ offset+=4;
+ }
+ else if (VTX_COLOR(ind0, 0) == R200_VTX_FP_RGB) {
+ CALL_Color3fv(GET_DISPATCH(), (&tmp[i][offset]));
+ offset+=3;
+ }
+
+ if (VTX_COLOR(ind0, 1) == R200_VTX_PK_RGBA) {
+ CALL_SecondaryColor3ubvEXT(GET_DISPATCH(), ((GLubyte *)&tmp[i][offset]));
+ offset++;
+ }
+
+ for ( unit = 0 ; unit < ctx->Const.MaxTextureUnits ; unit++ ) {
+ count = VTX_TEXn_COUNT( ind1, unit );
+ dispatch_multitexcoord( count, unit, &tmp[i][offset] );
+ offset += count;
+ }
+
+ CALL_Vertex3fv(GET_DISPATCH(), (&tmp[i][0]));
+ }
+
+ /* Replay current vertex
+ */
+ if (ind0 & R200_VTX_N0)
+ CALL_Normal3fv(GET_DISPATCH(), (rmesa->vb.normalptr));
+ if (ind0 & R200_VTX_DISCRETE_FOG) {
+ CALL_FogCoordfvEXT(GET_DISPATCH(), (rmesa->vb.fogptr));
+ }
+
+ if (VTX_COLOR(ind0, 0) == R200_VTX_PK_RGBA) {
+ CALL_Color4ub(GET_DISPATCH(), (rmesa->vb.colorptr->red,
+ rmesa->vb.colorptr->green,
+ rmesa->vb.colorptr->blue,
+ rmesa->vb.colorptr->alpha));
+ }
+ else if (VTX_COLOR(ind0, 0) == R200_VTX_FP_RGBA) {
+ CALL_Color4fv(GET_DISPATCH(), (rmesa->vb.floatcolorptr));
+ }
+ else if (VTX_COLOR(ind0, 0) == R200_VTX_FP_RGB) {
+ if (rmesa->vb.installed_color_3f_sz == 4 && alpha != 1.0) {
+ CALL_Color4f(GET_DISPATCH(), (rmesa->vb.floatcolorptr[0],
+ rmesa->vb.floatcolorptr[1],
+ rmesa->vb.floatcolorptr[2],
+ alpha));
+ }
+ else {
+ CALL_Color3fv(GET_DISPATCH(), (rmesa->vb.floatcolorptr));
+ }
+ }
+
+ if (VTX_COLOR(ind0, 1) == R200_VTX_PK_RGBA)
+ CALL_SecondaryColor3ubEXT(GET_DISPATCH(), (rmesa->vb.specptr->red,
+ rmesa->vb.specptr->green,
+ rmesa->vb.specptr->blue));
+
+ for ( unit = 0 ; unit < ctx->Const.MaxTextureUnits ; unit++ ) {
+ count = VTX_TEXn_COUNT( ind1, unit );
+ dispatch_multitexcoord( count, unit, rmesa->vb.texcoordptr[unit] );
+ }
+}
+
+
+
+static void wrap_buffer( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat tmp[3][R200_MAX_VERTEX_SIZE];
+ GLuint i, nrverts;
+
+ if (R200_DEBUG & (DEBUG_VFMT|DEBUG_PRIMS))
+ fprintf(stderr, "%s %d\n", __FUNCTION__,
+ rmesa->vb.initial_counter - rmesa->vb.counter);
+
+ /* Don't deal with parity.
+ */
+ if ((((rmesa->vb.initial_counter - rmesa->vb.counter) -
+ rmesa->vb.primlist[rmesa->vb.nrprims].start) & 1)) {
+ rmesa->vb.counter++;
+ rmesa->vb.initial_counter++;
+ return;
+ }
+
+ /* Copy vertices out of dma:
+ */
+ if (rmesa->vb.prim[0] == GL_POLYGON+1)
+ nrverts = 0;
+ else {
+ nrverts = copy_dma_verts( rmesa, tmp );
+
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%d vertices to copy\n", nrverts);
+
+ /* Finish the prim at this point:
+ */
+ note_last_prim( rmesa, 0 );
+ }
+
+ /* Fire any buffered primitives
+ */
+ flush_prims( rmesa );
+
+ /* Get new buffer
+ */
+ r200RefillCurrentDmaRegion( rmesa );
+
+ /* Reset counter, dmaptr
+ */
+ rmesa->vb.dmaptr = (int *)(rmesa->dma.current.ptr + rmesa->dma.current.address);
+ rmesa->vb.counter = (rmesa->dma.current.end - rmesa->dma.current.ptr) /
+ (rmesa->vb.vertex_size * 4);
+ rmesa->vb.counter--;
+ rmesa->vb.initial_counter = rmesa->vb.counter;
+ rmesa->vb.notify = wrap_buffer;
+
+ rmesa->dma.flush = flush_prims;
+
+ /* Restart wrapped primitive:
+ */
+ if (rmesa->vb.prim[0] != GL_POLYGON+1)
+ start_prim( rmesa, rmesa->vb.prim[0] );
+
+
+ /* Reemit saved vertices
+ */
+ for (i = 0 ; i < nrverts; i++) {
+ if (R200_DEBUG & DEBUG_VERTS) {
+ int j;
+ fprintf(stderr, "re-emit vertex %d to %p\n", i,
+ (void *)rmesa->vb.dmaptr);
+ if (R200_DEBUG & DEBUG_VERBOSE)
+ for (j = 0 ; j < rmesa->vb.vertex_size; j++)
+ fprintf(stderr, "\t%08x/%f\n", *(int*)&tmp[i][j], tmp[i][j]);
+ }
+
+ memcpy( rmesa->vb.dmaptr, tmp[i], rmesa->vb.vertex_size * 4 );
+ rmesa->vb.dmaptr += rmesa->vb.vertex_size;
+ rmesa->vb.counter--;
+ }
+}
+
+
+/**
+ * Determines the hardware vertex format based on the current state vector.
+ *
+ * \returns
+ * If the hardware TCL unit is capable of handling the current state vector,
+ * \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned.
+ *
+ * \todo
+ * Make this color format selection data driven. If we receive only ubytes,
+ * send color as ubytes. Also check if converting (with free checking for
+ * overflow) is cheaper than sending floats directly.
+ *
+ * \todo
+ * When intializing texture coordinates, it might be faster to just copy the
+ * entire \c VERT_ATTRIB_TEX0 vector into the vertex buffer. It may mean that
+ * some of the data (i.e., the last texture coordinate components) get copied
+ * over, but that still may be faster than the conditional branching. If
+ * nothing else, the code will be smaller and easier to follow.
+ */
+static GLboolean check_vtx_fmt( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLuint ind0 = R200_VTX_Z0;
+ GLuint ind1 = 0;
+ GLuint i;
+ GLuint count[R200_MAX_TEXTURE_UNITS];
+
+ if (rmesa->TclFallback || rmesa->vb.fell_back || ctx->CompileFlag)
+ return GL_FALSE;
+
+ if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT)
+ ctx->Driver.FlushVertices( ctx, FLUSH_UPDATE_CURRENT );
+
+ /* Make all this event-driven:
+ */
+ if (ctx->Light.Enabled) {
+ ind0 |= R200_VTX_N0;
+
+ if (ctx->Light.ColorMaterialEnabled)
+ ind0 |= R200_VTX_FP_RGBA << R200_VTX_COLOR_0_SHIFT;
+ else
+ ind0 |= R200_VTX_PK_RGBA << R200_VTX_COLOR_0_SHIFT;
+ }
+ else {
+ /* TODO: make this data driven?
+ */
+ ind0 |= R200_VTX_PK_RGBA << R200_VTX_COLOR_0_SHIFT;
+
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
+ ind0 |= R200_VTX_PK_RGBA << R200_VTX_COLOR_1_SHIFT;
+ }
+ }
+
+ if ( ctx->Fog.FogCoordinateSource == GL_FOG_COORD ) {
+ ind0 |= R200_VTX_DISCRETE_FOG;
+ }
+
+ for ( i = 0 ; i < ctx->Const.MaxTextureUnits ; i++ ) {
+ count[i] = 0;
+
+ if (ctx->Texture.Unit[i]._ReallyEnabled) {
+ if (rmesa->TexGenNeedNormals[i]) {
+ ind0 |= R200_VTX_N0;
+ }
+ else {
+ switch( ctx->Texture.Unit[i]._ReallyEnabled ) {
+ case TEXTURE_CUBE_BIT:
+ case TEXTURE_3D_BIT:
+ count[i] = 3;
+ break;
+ case TEXTURE_2D_BIT:
+ case TEXTURE_RECT_BIT:
+ count[i] = 2;
+ break;
+ case TEXTURE_1D_BIT:
+ count[i] = 1;
+ break;
+ }
+
+ ind1 |= count[i] << (3 * i);
+ }
+ }
+ }
+
+ if (R200_DEBUG & (DEBUG_VFMT|DEBUG_STATE))
+ fprintf(stderr, "%s: format: 0x%x, 0x%x\n", __FUNCTION__, ind0, ind1 );
+
+ R200_NEWPRIM(rmesa);
+ rmesa->vb.vtxfmt_0 = ind0;
+ rmesa->vb.vtxfmt_1 = ind1;
+ rmesa->vb.prim = &ctx->Driver.CurrentExecPrimitive;
+
+ rmesa->vb.vertex_size = 3;
+ rmesa->vb.normalptr = ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
+ rmesa->vb.colorptr = NULL;
+ rmesa->vb.floatcolorptr = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
+ rmesa->vb.fogptr = ctx->Current.Attrib[VERT_ATTRIB_FOG];
+ rmesa->vb.specptr = NULL;
+ rmesa->vb.floatspecptr = ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
+ rmesa->vb.texcoordptr[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
+ rmesa->vb.texcoordptr[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX1];
+ rmesa->vb.texcoordptr[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX2];
+ rmesa->vb.texcoordptr[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX3];
+ rmesa->vb.texcoordptr[4] = ctx->Current.Attrib[VERT_ATTRIB_TEX4];
+ rmesa->vb.texcoordptr[5] = ctx->Current.Attrib[VERT_ATTRIB_TEX5];
+ rmesa->vb.texcoordptr[6] = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; /* dummy */
+ rmesa->vb.texcoordptr[7] = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; /* dummy */
+
+ /* Run through and initialize the vertex components in the order
+ * the hardware understands:
+ */
+ if (ind0 & R200_VTX_N0) {
+ rmesa->vb.normalptr = &rmesa->vb.vertex[rmesa->vb.vertex_size].f;
+ rmesa->vb.vertex_size += 3;
+ rmesa->vb.normalptr[0] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0];
+ rmesa->vb.normalptr[1] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1];
+ rmesa->vb.normalptr[2] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2];
+ }
+
+ if (ind0 & R200_VTX_DISCRETE_FOG) {
+ rmesa->vb.fogptr = &rmesa->vb.vertex[rmesa->vb.vertex_size].f;
+ rmesa->vb.vertex_size += 1;
+ rmesa->vb.fogptr[0] = ctx->Current.Attrib[VERT_ATTRIB_FOG][0];
+ }
+
+ if (VTX_COLOR(ind0, 0) == R200_VTX_PK_RGBA) {
+ rmesa->vb.colorptr = &rmesa->vb.vertex[rmesa->vb.vertex_size].color;
+ rmesa->vb.vertex_size += 1;
+ UNCLAMPED_FLOAT_TO_CHAN( rmesa->vb.colorptr->red, ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0] );
+ UNCLAMPED_FLOAT_TO_CHAN( rmesa->vb.colorptr->green, ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1] );
+ UNCLAMPED_FLOAT_TO_CHAN( rmesa->vb.colorptr->blue, ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2] );
+ UNCLAMPED_FLOAT_TO_CHAN( rmesa->vb.colorptr->alpha, ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3] );
+ }
+ else if (VTX_COLOR(ind0, 0) == R200_VTX_FP_RGBA) {
+ rmesa->vb.floatcolorptr = &rmesa->vb.vertex[rmesa->vb.vertex_size].f;
+ rmesa->vb.vertex_size += 4;
+ rmesa->vb.floatcolorptr[0] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0];
+ rmesa->vb.floatcolorptr[1] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1];
+ rmesa->vb.floatcolorptr[2] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2];
+ rmesa->vb.floatcolorptr[3] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3];
+ }
+ else if (VTX_COLOR(ind0, 0) == R200_VTX_FP_RGB) {
+ rmesa->vb.floatcolorptr = &rmesa->vb.vertex[rmesa->vb.vertex_size].f;
+ rmesa->vb.vertex_size += 3;
+ rmesa->vb.floatcolorptr[0] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0];
+ rmesa->vb.floatcolorptr[1] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1];
+ rmesa->vb.floatcolorptr[2] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2];
+ }
+
+ if (VTX_COLOR(ind0, 1) == R200_VTX_PK_RGBA) {
+ rmesa->vb.specptr = &rmesa->vb.vertex[rmesa->vb.vertex_size].color;
+ rmesa->vb.vertex_size += 1;
+ UNCLAMPED_FLOAT_TO_CHAN( rmesa->vb.specptr->red, ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0] );
+ UNCLAMPED_FLOAT_TO_CHAN( rmesa->vb.specptr->green, ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1] );
+ UNCLAMPED_FLOAT_TO_CHAN( rmesa->vb.specptr->blue, ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2] );
+ }
+
+
+ for ( i = 0 ; i < ctx->Const.MaxTextureUnits ; i++ ) {
+ if ( count[i] != 0 ) {
+ float * const attr = ctx->Current.Attrib[VERT_ATTRIB_TEX0+i];
+ unsigned j;
+
+ rmesa->vb.texcoordptr[i] = &rmesa->vb.vertex[rmesa->vb.vertex_size].f;
+
+ for ( j = 0 ; j < count[i] ; j++ ) {
+ rmesa->vb.texcoordptr[i][j] = attr[j];
+ }
+
+ rmesa->vb.vertex_size += count[i];
+ }
+ }
+
+ if (rmesa->vb.installed_vertex_format != rmesa->vb.vtxfmt_0) {
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "reinstall on vertex_format change\n");
+ _mesa_install_exec_vtxfmt( ctx, &rmesa->vb.vtxfmt );
+ rmesa->vb.installed_vertex_format = rmesa->vb.vtxfmt_0;
+ }
+
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s -- success\n", __FUNCTION__);
+
+ return GL_TRUE;
+}
+
+
+void r200VtxfmtInvalidate( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT( ctx );
+
+ rmesa->vb.recheck = GL_TRUE;
+ rmesa->vb.fell_back = GL_FALSE;
+}
+
+
+static void r200VtxfmtValidate( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT( ctx );
+
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (ctx->Driver.NeedFlush)
+ ctx->Driver.FlushVertices( ctx, ctx->Driver.NeedFlush );
+
+ rmesa->vb.recheck = GL_FALSE;
+
+ if (check_vtx_fmt( ctx )) {
+ if (!rmesa->vb.installed) {
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "reinstall (new install)\n");
+
+ _mesa_install_exec_vtxfmt( ctx, &rmesa->vb.vtxfmt );
+ ctx->Driver.FlushVertices = r200VtxFmtFlushVertices;
+ rmesa->vb.installed = GL_TRUE;
+ }
+ else if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s: already installed", __FUNCTION__);
+ }
+ else {
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s: failed\n", __FUNCTION__);
+
+ if (rmesa->vb.installed) {
+ if (rmesa->dma.flush)
+ rmesa->dma.flush( rmesa );
+ _tnl_wakeup_exec( ctx );
+ ctx->Driver.FlushVertices = r200FlushVertices;
+ rmesa->vb.installed = GL_FALSE;
+ }
+ }
+}
+
+
+
+/* Materials:
+ */
+static void r200_Materialfv( GLenum face, GLenum pname,
+ const GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT( ctx );
+
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (rmesa->vb.prim[0] != GL_POLYGON+1) {
+ VFMT_FALLBACK( __FUNCTION__ );
+ CALL_Materialfv(GET_DISPATCH(), (face, pname, params));
+ return;
+ }
+ _mesa_noop_Materialfv( face, pname, params );
+ r200UpdateMaterial( ctx );
+}
+
+
+/* Begin/End
+ */
+static void r200_Begin( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s( %s )\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr( mode ));
+
+ if (mode > GL_POLYGON) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBegin" );
+ return;
+ }
+
+ if (rmesa->vb.prim[0] != GL_POLYGON+1) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glBegin" );
+ return;
+ }
+
+ if (ctx->NewState)
+ _mesa_update_state( ctx );
+
+ if (rmesa->NewGLState)
+ r200ValidateState( ctx );
+
+ if (rmesa->vb.recheck)
+ r200VtxfmtValidate( ctx );
+
+ if (!rmesa->vb.installed) {
+ CALL_Begin(GET_DISPATCH(), (mode));
+ return;
+ }
+
+
+ if (rmesa->dma.flush && rmesa->vb.counter < 12) {
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s: flush almost-empty buffers\n", __FUNCTION__);
+ flush_prims( rmesa );
+ }
+
+ /* Need to arrange to save vertices here? Or always copy from dma (yuk)?
+ */
+ if (!rmesa->dma.flush) {
+ if (rmesa->dma.current.ptr + 12*rmesa->vb.vertex_size*4 >
+ rmesa->dma.current.end) {
+ R200_NEWPRIM( rmesa );
+ r200RefillCurrentDmaRegion( rmesa );
+ }
+
+ rmesa->vb.dmaptr = (int *)(rmesa->dma.current.address + rmesa->dma.current.ptr);
+ rmesa->vb.counter = (rmesa->dma.current.end - rmesa->dma.current.ptr) /
+ (rmesa->vb.vertex_size * 4);
+ rmesa->vb.counter--;
+ rmesa->vb.initial_counter = rmesa->vb.counter;
+ rmesa->vb.notify = wrap_buffer;
+ rmesa->dma.flush = flush_prims;
+ ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
+ }
+
+
+ rmesa->vb.prim[0] = mode;
+ start_prim( rmesa, mode | PRIM_BEGIN );
+}
+
+
+
+static void r200_End( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (rmesa->vb.prim[0] == GL_POLYGON+1) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd" );
+ return;
+ }
+
+ note_last_prim( rmesa, PRIM_END );
+ rmesa->vb.prim[0] = GL_POLYGON+1;
+}
+
+
+/* Fallback on difficult entrypoints:
+ */
+#define PRE_LOOPBACK( FUNC ) \
+do { \
+ if (R200_DEBUG & DEBUG_VFMT) \
+ fprintf(stderr, "%s\n", __FUNCTION__); \
+ VFMT_FALLBACK( __FUNCTION__ ); \
+} while (0)
+#define TAG(x) r200_fallback_##x
+#include "vtxfmt_tmp.h"
+
+
+
+static GLboolean r200NotifyBegin( GLcontext *ctx, GLenum p )
+{
+ r200ContextPtr rmesa = R200_CONTEXT( ctx );
+
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ assert(!rmesa->vb.installed);
+
+ if (ctx->NewState)
+ _mesa_update_state( ctx );
+
+ if (rmesa->NewGLState)
+ r200ValidateState( ctx );
+
+ if (ctx->Driver.NeedFlush)
+ ctx->Driver.FlushVertices( ctx, ctx->Driver.NeedFlush );
+
+ if (rmesa->vb.recheck)
+ r200VtxfmtValidate( ctx );
+
+ if (!rmesa->vb.installed) {
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s -- failed\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+
+ r200_Begin( p );
+ return GL_TRUE;
+}
+
+static void r200VtxFmtFlushVertices( GLcontext *ctx, GLuint flags )
+{
+ r200ContextPtr rmesa = R200_CONTEXT( ctx );
+
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ assert(rmesa->vb.installed);
+
+ if (flags & FLUSH_UPDATE_CURRENT) {
+ r200_copy_to_current( ctx );
+ if (R200_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "reinstall on update_current\n");
+ _mesa_install_exec_vtxfmt( ctx, &rmesa->vb.vtxfmt );
+ ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT;
+ }
+
+ if (flags & FLUSH_STORED_VERTICES) {
+ assert (rmesa->dma.flush == 0 ||
+ rmesa->dma.flush == flush_prims);
+ if (rmesa->dma.flush == flush_prims)
+ flush_prims( rmesa );
+ ctx->Driver.NeedFlush &= ~FLUSH_STORED_VERTICES;
+ }
+}
+
+
+
+/* At this point, don't expect very many versions of each function to
+ * be generated, so not concerned about freeing them?
+ */
+
+
+void r200VtxfmtInit( GLcontext *ctx, GLboolean useCodegen )
+{
+ r200ContextPtr rmesa = R200_CONTEXT( ctx );
+ GLvertexformat *vfmt = &(rmesa->vb.vtxfmt);
+
+ MEMSET( vfmt, 0, sizeof(GLvertexformat) );
+
+ /* Hook in chooser functions for codegen, etc:
+ */
+ r200VtxfmtInitChoosers( vfmt );
+
+ /* Handled fully in supported states, but no codegen:
+ */
+ vfmt->Materialfv = r200_Materialfv;
+ vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */
+ vfmt->Rectf = _mesa_noop_Rectf; /* generic helper */
+ vfmt->Begin = r200_Begin;
+ vfmt->End = r200_End;
+
+ /* Fallback for performance reasons: (Fix with cva/elt path here and
+ * dmatmp2.h style primitive-merging)
+ *
+ * These should call NotifyBegin(), as should _tnl_EvalMesh, to allow
+ * a driver-hook.
+ */
+ vfmt->DrawArrays = r200_fallback_DrawArrays;
+ vfmt->DrawElements = r200_fallback_DrawElements;
+ vfmt->DrawRangeElements = r200_fallback_DrawRangeElements;
+
+
+ /* Not active in supported states; just keep ctx->Current uptodate:
+ */
+ vfmt->EdgeFlag = _mesa_noop_EdgeFlag;
+ vfmt->EdgeFlagv = _mesa_noop_EdgeFlagv;
+ vfmt->Indexf = _mesa_noop_Indexf;
+ vfmt->Indexfv = _mesa_noop_Indexfv;
+
+
+ /* Active but unsupported -- fallback if we receive these:
+ */
+ vfmt->CallList = r200_fallback_CallList;
+ vfmt->CallLists = r200_fallback_CallLists;
+ vfmt->EvalCoord1f = r200_fallback_EvalCoord1f;
+ vfmt->EvalCoord1fv = r200_fallback_EvalCoord1fv;
+ vfmt->EvalCoord2f = r200_fallback_EvalCoord2f;
+ vfmt->EvalCoord2fv = r200_fallback_EvalCoord2fv;
+ vfmt->EvalMesh1 = r200_fallback_EvalMesh1;
+ vfmt->EvalMesh2 = r200_fallback_EvalMesh2;
+ vfmt->EvalPoint1 = r200_fallback_EvalPoint1;
+ vfmt->EvalPoint2 = r200_fallback_EvalPoint2;
+ vfmt->TexCoord4f = r200_fallback_TexCoord4f;
+ vfmt->TexCoord4fv = r200_fallback_TexCoord4fv;
+ vfmt->MultiTexCoord4fARB = r200_fallback_MultiTexCoord4fARB;
+ vfmt->MultiTexCoord4fvARB = r200_fallback_MultiTexCoord4fvARB;
+ vfmt->Vertex4f = r200_fallback_Vertex4f;
+ vfmt->Vertex4fv = r200_fallback_Vertex4fv;
+ vfmt->VertexAttrib1fNV = r200_fallback_VertexAttrib1fNV;
+ vfmt->VertexAttrib1fvNV = r200_fallback_VertexAttrib1fvNV;
+ vfmt->VertexAttrib2fNV = r200_fallback_VertexAttrib2fNV;
+ vfmt->VertexAttrib2fvNV = r200_fallback_VertexAttrib2fvNV;
+ vfmt->VertexAttrib3fNV = r200_fallback_VertexAttrib3fNV;
+ vfmt->VertexAttrib3fvNV = r200_fallback_VertexAttrib3fvNV;
+ vfmt->VertexAttrib4fNV = r200_fallback_VertexAttrib4fNV;
+ vfmt->VertexAttrib4fvNV = r200_fallback_VertexAttrib4fvNV;
+ vfmt->FogCoordfEXT = r200_fallback_FogCoordfEXT;
+ vfmt->FogCoordfvEXT = r200_fallback_FogCoordfvEXT;
+
+ (void)r200_fallback_vtxfmt;
+
+ TNL_CONTEXT(ctx)->Driver.NotifyBegin = r200NotifyBegin;
+
+ rmesa->vb.enabled = 1;
+ rmesa->vb.prim = &ctx->Driver.CurrentExecPrimitive;
+ rmesa->vb.primflags = 0;
+
+ make_empty_list( &rmesa->vb.dfn_cache.Vertex2f );
+ make_empty_list( &rmesa->vb.dfn_cache.Vertex2fv );
+ make_empty_list( &rmesa->vb.dfn_cache.Vertex3f );
+ make_empty_list( &rmesa->vb.dfn_cache.Vertex3fv );
+ make_empty_list( &rmesa->vb.dfn_cache.Color4ub );
+ make_empty_list( &rmesa->vb.dfn_cache.Color4ubv );
+ make_empty_list( &rmesa->vb.dfn_cache.Color3ub );
+ make_empty_list( &rmesa->vb.dfn_cache.Color3ubv );
+ make_empty_list( &rmesa->vb.dfn_cache.Color4f );
+ make_empty_list( &rmesa->vb.dfn_cache.Color4fv );
+ make_empty_list( &rmesa->vb.dfn_cache.Color3f );
+ make_empty_list( &rmesa->vb.dfn_cache.Color3fv );
+ make_empty_list( &rmesa->vb.dfn_cache.SecondaryColor3fEXT );
+ make_empty_list( &rmesa->vb.dfn_cache.SecondaryColor3fvEXT );
+ make_empty_list( &rmesa->vb.dfn_cache.SecondaryColor3ubEXT );
+ make_empty_list( &rmesa->vb.dfn_cache.SecondaryColor3ubvEXT );
+ make_empty_list( &rmesa->vb.dfn_cache.Normal3f );
+ make_empty_list( &rmesa->vb.dfn_cache.Normal3fv );
+ make_empty_list( &rmesa->vb.dfn_cache.TexCoord3f );
+ make_empty_list( &rmesa->vb.dfn_cache.TexCoord3fv );
+ make_empty_list( &rmesa->vb.dfn_cache.TexCoord2f );
+ make_empty_list( &rmesa->vb.dfn_cache.TexCoord2fv );
+ make_empty_list( &rmesa->vb.dfn_cache.TexCoord1f );
+ make_empty_list( &rmesa->vb.dfn_cache.TexCoord1fv );
+ make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord3fARB );
+ make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord3fvARB );
+ make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord2fARB );
+ make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord2fvARB );
+ make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord1fARB );
+ make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord1fvARB );
+/* make_empty_list( &rmesa->vb.dfn_cache.FogCoordfEXT );
+ make_empty_list( &rmesa->vb.dfn_cache.FogCoordfvEXT );*/
+
+ r200InitCodegen( &rmesa->vb.codegen, useCodegen );
+}
+
+static void free_funcs( struct dynfn *l )
+{
+ struct dynfn *f, *tmp;
+ foreach_s (f, tmp, l) {
+ remove_from_list( f );
+ _mesa_exec_free( f->code );
+ _mesa_free( f );
+ }
+}
+
+void r200VtxfmtUnbindContext( GLcontext *ctx )
+{
+}
+
+
+void r200VtxfmtMakeCurrent( GLcontext *ctx )
+{
+}
+
+
+void r200VtxfmtDestroy( GLcontext *ctx )
+{
+ r200ContextPtr rmesa = R200_CONTEXT( ctx );
+
+ count_funcs( rmesa );
+ free_funcs( &rmesa->vb.dfn_cache.Vertex2f );
+ free_funcs( &rmesa->vb.dfn_cache.Vertex2fv );
+ free_funcs( &rmesa->vb.dfn_cache.Vertex3f );
+ free_funcs( &rmesa->vb.dfn_cache.Vertex3fv );
+ free_funcs( &rmesa->vb.dfn_cache.Color4ub );
+ free_funcs( &rmesa->vb.dfn_cache.Color4ubv );
+ free_funcs( &rmesa->vb.dfn_cache.Color3ub );
+ free_funcs( &rmesa->vb.dfn_cache.Color3ubv );
+ free_funcs( &rmesa->vb.dfn_cache.Color4f );
+ free_funcs( &rmesa->vb.dfn_cache.Color4fv );
+ free_funcs( &rmesa->vb.dfn_cache.Color3f );
+ free_funcs( &rmesa->vb.dfn_cache.Color3fv );
+ free_funcs( &rmesa->vb.dfn_cache.SecondaryColor3ubEXT );
+ free_funcs( &rmesa->vb.dfn_cache.SecondaryColor3ubvEXT );
+ free_funcs( &rmesa->vb.dfn_cache.SecondaryColor3fEXT );
+ free_funcs( &rmesa->vb.dfn_cache.SecondaryColor3fvEXT );
+ free_funcs( &rmesa->vb.dfn_cache.Normal3f );
+ free_funcs( &rmesa->vb.dfn_cache.Normal3fv );
+ free_funcs( &rmesa->vb.dfn_cache.TexCoord3f );
+ free_funcs( &rmesa->vb.dfn_cache.TexCoord3fv );
+ free_funcs( &rmesa->vb.dfn_cache.TexCoord2f );
+ free_funcs( &rmesa->vb.dfn_cache.TexCoord2fv );
+ free_funcs( &rmesa->vb.dfn_cache.TexCoord1f );
+ free_funcs( &rmesa->vb.dfn_cache.TexCoord1fv );
+ free_funcs( &rmesa->vb.dfn_cache.MultiTexCoord3fARB );
+ free_funcs( &rmesa->vb.dfn_cache.MultiTexCoord3fvARB );
+ free_funcs( &rmesa->vb.dfn_cache.MultiTexCoord2fARB );
+ free_funcs( &rmesa->vb.dfn_cache.MultiTexCoord2fvARB );
+ free_funcs( &rmesa->vb.dfn_cache.MultiTexCoord1fARB );
+ free_funcs( &rmesa->vb.dfn_cache.MultiTexCoord1fvARB );
+/* free_funcs( &rmesa->vb.dfn_cache.FogCoordfEXT );
+ free_funcs( &rmesa->vb.dfn_cache.FogCoordfvEXT );*/
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt.h
new file mode 100644
index 000000000..c347dcfb2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt.h
@@ -0,0 +1,123 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_vtxfmt.h,v 1.1 2002/10/30 12:51:53 alanh Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R200_VTXFMT_H__
+#define __R200_VTXFMT_H__
+
+#include "r200_context.h"
+
+
+
+extern void r200VtxfmtUpdate( GLcontext *ctx );
+extern void r200VtxfmtInit( GLcontext *ctx, GLboolean useCodegen );
+extern void r200VtxfmtInvalidate( GLcontext *ctx );
+extern void r200VtxfmtDestroy( GLcontext *ctx );
+extern void r200VtxfmtInitChoosers( GLvertexformat *vfmt );
+
+extern void r200VtxfmtMakeCurrent( GLcontext *ctx );
+extern void r200VtxfmtUnbindContext( GLcontext *ctx );
+
+extern void r200_copy_to_current( GLcontext *ctx );
+extern void VFMT_FALLBACK( const char *caller );
+
+#define DFN( FUNC, CACHE) \
+do { \
+ char *start = (char *)&FUNC; \
+ char *end = (char *)&FUNC##_end; \
+ insert_at_head( &CACHE, dfn ); \
+ dfn->key[0] = key[0]; \
+ dfn->key[1] = key[1]; \
+ dfn->code = _mesa_exec_malloc(end - start); \
+ _mesa_memcpy(dfn->code, start, end - start); \
+} \
+while ( 0 )
+
+#define FIXUP( CODE, OFFSET, CHECKVAL, NEWVAL ) \
+do { \
+ int *icode = (int *)(CODE+OFFSET); \
+ assert (*icode == CHECKVAL); \
+ *icode = (int)NEWVAL; \
+} while (0)
+
+
+/* Useful for figuring out the offsets:
+ */
+#define FIXUP2( CODE, OFFSET, CHECKVAL, NEWVAL ) \
+do { \
+ while (*(int *)(CODE+OFFSET) != CHECKVAL) OFFSET++; \
+ /*fprintf(stderr, "%s/%d CVAL %x OFFSET %d VAL %x\n", __FUNCTION__,*/ \
+ /* __LINE__, CHECKVAL, OFFSET, (int)(NEWVAL));*/ \
+ *(int *)(CODE+OFFSET) = (int)(NEWVAL); \
+ OFFSET += 4; \
+} while (0)
+
+/*
+ */
+void r200InitCodegen( struct dfn_generators *gen, GLboolean useCodegen );
+void r200InitX86Codegen( struct dfn_generators *gen );
+void r200InitSSECodegen( struct dfn_generators *gen );
+
+
+
+/* Defined in r200_vtxfmt_x86.c
+ */
+struct dynfn *r200_makeX86Vertex2f( GLcontext *, const int * );
+struct dynfn *r200_makeX86Vertex2fv( GLcontext *, const int * );
+struct dynfn *r200_makeX86Vertex3f( GLcontext *, const int * );
+struct dynfn *r200_makeX86Vertex3fv( GLcontext *, const int * );
+struct dynfn *r200_makeX86Color4ub( GLcontext *, const int * );
+struct dynfn *r200_makeX86Color4ubv( GLcontext *, const int * );
+struct dynfn *r200_makeX86Color3ub( GLcontext *, const int * );
+struct dynfn *r200_makeX86Color3ubv( GLcontext *, const int * );
+struct dynfn *r200_makeX86Color4f( GLcontext *, const int * );
+struct dynfn *r200_makeX86Color4fv( GLcontext *, const int * );
+struct dynfn *r200_makeX86Color3f( GLcontext *, const int * );
+struct dynfn *r200_makeX86Color3fv( GLcontext *, const int * );
+struct dynfn *r200_makeX86SecondaryColor3ubEXT( GLcontext *, const int * );
+struct dynfn *r200_makeX86SecondaryColor3ubvEXT( GLcontext *, const int * );
+struct dynfn *r200_makeX86SecondaryColor3fEXT( GLcontext *, const int * );
+struct dynfn *r200_makeX86SecondaryColor3fvEXT( GLcontext *, const int * );
+struct dynfn *r200_makeX86Normal3f( GLcontext *, const int * );
+struct dynfn *r200_makeX86Normal3fv( GLcontext *, const int * );
+struct dynfn *r200_makeX86TexCoord2f( GLcontext *, const int * );
+struct dynfn *r200_makeX86TexCoord2fv( GLcontext *, const int * );
+struct dynfn *r200_makeX86TexCoord1f( GLcontext *, const int * );
+struct dynfn *r200_makeX86TexCoord1fv( GLcontext *, const int * );
+struct dynfn *r200_makeX86MultiTexCoord2fARB( GLcontext *, const int * );
+struct dynfn *r200_makeX86MultiTexCoord2fvARB( GLcontext *, const int * );
+struct dynfn *r200_makeX86MultiTexCoord1fARB( GLcontext *, const int * );
+struct dynfn *r200_makeX86MultiTexCoord1fvARB( GLcontext *, const int * );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt_c.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt_c.c
new file mode 100644
index 000000000..1db5950c8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt_c.c
@@ -0,0 +1,1002 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_vtxfmt_c.c,v 1.2 2002/12/16 16:18:56 dawes Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "colormac.h"
+#include "simple_list.h"
+#include "api_noop.h"
+#include "vtxfmt.h"
+
+#include "r200_vtxfmt.h"
+#include "r200_tcl.h"
+
+#include "dispatch.h"
+
+/* Fallback versions of all the entrypoints for situations where
+ * codegen isn't available. This is still a lot faster than the
+ * vb/pipeline implementation in Mesa.
+ */
+static void r200_Vertex3f( GLfloat x, GLfloat y, GLfloat z )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ int i;
+
+ *rmesa->vb.dmaptr++ = *(int *)&x;
+ *rmesa->vb.dmaptr++ = *(int *)&y;
+ *rmesa->vb.dmaptr++ = *(int *)&z;
+
+ for (i = 3; i < rmesa->vb.vertex_size; i++)
+ *rmesa->vb.dmaptr++ = rmesa->vb.vertex[i].i;
+
+ if (--rmesa->vb.counter == 0)
+ rmesa->vb.notify();
+}
+
+
+static void r200_Vertex3fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ int i;
+
+ *rmesa->vb.dmaptr++ = *(int *)&v[0];
+ *rmesa->vb.dmaptr++ = *(int *)&v[1];
+ *rmesa->vb.dmaptr++ = *(int *)&v[2];
+
+ for (i = 3; i < rmesa->vb.vertex_size; i++)
+ *rmesa->vb.dmaptr++ = rmesa->vb.vertex[i].i;
+
+ if (--rmesa->vb.counter == 0)
+ rmesa->vb.notify();
+}
+
+
+static void r200_Vertex2f( GLfloat x, GLfloat y )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ int i;
+
+ *rmesa->vb.dmaptr++ = *(int *)&x;
+ *rmesa->vb.dmaptr++ = *(int *)&y;
+ *rmesa->vb.dmaptr++ = 0;
+
+ for (i = 3; i < rmesa->vb.vertex_size; i++)
+ *rmesa->vb.dmaptr++ = rmesa->vb.vertex[i].i;
+
+ if (--rmesa->vb.counter == 0)
+ rmesa->vb.notify();
+}
+
+
+static void r200_Vertex2fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ int i;
+
+ *rmesa->vb.dmaptr++ = *(int *)&v[0];
+ *rmesa->vb.dmaptr++ = *(int *)&v[1];
+ *rmesa->vb.dmaptr++ = 0;
+
+ for (i = 3; i < rmesa->vb.vertex_size; i++)
+ *rmesa->vb.dmaptr++ = rmesa->vb.vertex[i].i;
+
+ if (--rmesa->vb.counter == 0)
+ rmesa->vb.notify();
+}
+
+
+
+/* Color for ubyte (packed) color formats:
+ */
+#if 0
+static void r200_Color3ub_ub( GLubyte r, GLubyte g, GLubyte b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ r200_color_t *dest = rmesa->vb.colorptr;
+ dest->red = r;
+ dest->green = g;
+ dest->blue = b;
+ dest->alpha = 0xff;
+}
+
+static void r200_Color3ubv_ub( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ r200_color_t *dest = rmesa->vb.colorptr;
+ dest->red = v[0];
+ dest->green = v[1];
+ dest->blue = v[2];
+ dest->alpha = 0xff;
+}
+
+static void r200_Color4ub_ub( GLubyte r, GLubyte g, GLubyte b, GLubyte a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ r200_color_t *dest = rmesa->vb.colorptr;
+ dest->red = r;
+ dest->green = g;
+ dest->blue = b;
+ dest->alpha = a;
+}
+
+static void r200_Color4ubv_ub( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ *(GLuint *)rmesa->vb.colorptr = LE32_TO_CPU(*(GLuint *)v);
+}
+#endif /* 0 */
+
+static void r200_Color3f_ub( GLfloat r, GLfloat g, GLfloat b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ r200_color_t *dest = rmesa->vb.colorptr;
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->red, r );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->green, g );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->blue, b );
+ dest->alpha = 255;
+}
+
+static void r200_Color3fv_ub( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ r200_color_t *dest = rmesa->vb.colorptr;
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->red, v[0] );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->green, v[1] );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->blue, v[2] );
+ dest->alpha = 255;
+}
+
+static void r200_Color4f_ub( GLfloat r, GLfloat g, GLfloat b, GLfloat a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ r200_color_t *dest = rmesa->vb.colorptr;
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->red, r );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->green, g );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->blue, b );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->alpha, a );
+}
+
+static void r200_Color4fv_ub( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ r200_color_t *dest = rmesa->vb.colorptr;
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->red, v[0] );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->green, v[1] );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->blue, v[2] );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->alpha, v[3] );
+}
+
+
+/* Color for float color+alpha formats:
+ */
+#if 0
+static void r200_Color3ub_4f( GLubyte r, GLubyte g, GLubyte b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = UBYTE_TO_FLOAT(r);
+ dest[1] = UBYTE_TO_FLOAT(g);
+ dest[2] = UBYTE_TO_FLOAT(b);
+ dest[3] = 1.0;
+}
+
+static void r200_Color3ubv_4f( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = UBYTE_TO_FLOAT(v[0]);
+ dest[1] = UBYTE_TO_FLOAT(v[1]);
+ dest[2] = UBYTE_TO_FLOAT(v[2]);
+ dest[3] = 1.0;
+}
+
+static void r200_Color4ub_4f( GLubyte r, GLubyte g, GLubyte b, GLubyte a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = UBYTE_TO_FLOAT(r);
+ dest[1] = UBYTE_TO_FLOAT(g);
+ dest[2] = UBYTE_TO_FLOAT(b);
+ dest[3] = UBYTE_TO_FLOAT(a);
+}
+
+static void r200_Color4ubv_4f( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = UBYTE_TO_FLOAT(v[0]);
+ dest[1] = UBYTE_TO_FLOAT(v[1]);
+ dest[2] = UBYTE_TO_FLOAT(v[2]);
+ dest[3] = UBYTE_TO_FLOAT(v[3]);
+}
+#endif /* 0 */
+
+
+static void r200_Color3f_4f( GLfloat r, GLfloat g, GLfloat b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = r;
+ dest[1] = g;
+ dest[2] = b;
+ dest[3] = 1.0;
+}
+
+static void r200_Color3fv_4f( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = v[2];
+ dest[3] = 1.0;
+}
+
+static void r200_Color4f_4f( GLfloat r, GLfloat g, GLfloat b, GLfloat a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = r;
+ dest[1] = g;
+ dest[2] = b;
+ dest[3] = a;
+}
+
+static void r200_Color4fv_4f( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = v[2];
+ dest[3] = v[3];
+}
+
+
+/* Color for float color formats:
+ */
+#if 0
+static void r200_Color3ub_3f( GLubyte r, GLubyte g, GLubyte b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = UBYTE_TO_FLOAT(r);
+ dest[1] = UBYTE_TO_FLOAT(g);
+ dest[2] = UBYTE_TO_FLOAT(b);
+}
+
+static void r200_Color3ubv_3f( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = UBYTE_TO_FLOAT(v[0]);
+ dest[1] = UBYTE_TO_FLOAT(v[1]);
+ dest[2] = UBYTE_TO_FLOAT(v[2]);
+}
+
+static void r200_Color4ub_3f( GLubyte r, GLubyte g, GLubyte b, GLubyte a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = UBYTE_TO_FLOAT(r);
+ dest[1] = UBYTE_TO_FLOAT(g);
+ dest[2] = UBYTE_TO_FLOAT(b);
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3] = UBYTE_TO_FLOAT(a);
+}
+
+static void r200_Color4ubv_3f( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = UBYTE_TO_FLOAT(v[0]);
+ dest[1] = UBYTE_TO_FLOAT(v[1]);
+ dest[2] = UBYTE_TO_FLOAT(v[2]);
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3] = UBYTE_TO_FLOAT(v[3]);
+}
+#endif /* 0 */
+
+
+static void r200_Color3f_3f( GLfloat r, GLfloat g, GLfloat b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = r;
+ dest[1] = g;
+ dest[2] = b;
+}
+
+static void r200_Color3fv_3f( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = v[2];
+}
+
+static void r200_Color4f_3f( GLfloat r, GLfloat g, GLfloat b, GLfloat a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = r;
+ dest[1] = g;
+ dest[2] = b;
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3] = a;
+}
+
+static void r200_Color4fv_3f( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = v[2];
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3] = v[3];
+}
+
+
+/* Secondary Color:
+ */
+#if 0
+static void r200_SecondaryColor3ubEXT_ub( GLubyte r, GLubyte g, GLubyte b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ r200_color_t *dest = rmesa->vb.specptr;
+ dest->red = r;
+ dest->green = g;
+ dest->blue = b;
+ dest->alpha = 0xff;
+}
+
+static void r200_SecondaryColor3ubvEXT_ub( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ r200_color_t *dest = rmesa->vb.specptr;
+ dest->red = v[0];
+ dest->green = v[1];
+ dest->blue = v[2];
+ dest->alpha = 0xff;
+}
+#endif /* 0 */
+
+static void r200_SecondaryColor3fEXT_ub( GLfloat r, GLfloat g, GLfloat b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ r200_color_t *dest = rmesa->vb.specptr;
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->red, r );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->green, g );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->blue, b );
+ dest->alpha = 255;
+}
+
+static void r200_SecondaryColor3fvEXT_ub( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ r200_color_t *dest = rmesa->vb.specptr;
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->red, v[0] );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->green, v[1] );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->blue, v[2] );
+ dest->alpha = 255;
+}
+
+#if 0
+static void r200_SecondaryColor3ubEXT_3f( GLubyte r, GLubyte g, GLubyte b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatspecptr;
+ dest[0] = UBYTE_TO_FLOAT(r);
+ dest[1] = UBYTE_TO_FLOAT(g);
+ dest[2] = UBYTE_TO_FLOAT(b);
+ dest[3] = 1.0;
+}
+
+static void r200_SecondaryColor3ubvEXT_3f( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatspecptr;
+ dest[0] = UBYTE_TO_FLOAT(v[0]);
+ dest[1] = UBYTE_TO_FLOAT(v[1]);
+ dest[2] = UBYTE_TO_FLOAT(v[2]);
+ dest[3] = 1.0;
+}
+#endif /* 0 */
+
+static void r200_SecondaryColor3fEXT_3f( GLfloat r, GLfloat g, GLfloat b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatspecptr;
+ dest[0] = r;
+ dest[1] = g;
+ dest[2] = b;
+ dest[3] = 1.0;
+}
+
+static void r200_SecondaryColor3fvEXT_3f( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatspecptr;
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = v[2];
+ dest[3] = 1.0;
+}
+
+
+
+/* Normal
+ */
+static void r200_Normal3f( GLfloat n0, GLfloat n1, GLfloat n2 )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.normalptr;
+ dest[0] = n0;
+ dest[1] = n1;
+ dest[2] = n2;
+}
+
+static void r200_Normal3fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.normalptr;
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = v[2];
+}
+
+
+/* FogCoord
+ */
+static void r200_FogCoordfEXT( GLfloat f )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.fogptr;
+ dest[0] = r200ComputeFogBlendFactor( ctx, f );
+/* ctx->Current.Attrib[VERT_ATTRIB_FOG][0] = f;*/
+}
+
+static void r200_FogCoordfvEXT( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.fogptr;
+ dest[0] = r200ComputeFogBlendFactor( ctx, v[0] );
+/* ctx->Current.Attrib[VERT_ATTRIB_FOG][0] = v[0];*/
+}
+
+
+/* TexCoord
+ */
+
+/* \todo maybe (target & 4 ? target & 5 : target & 3) is more save than (target & 7) */
+static void r200_MultiTexCoord1fARB(GLenum target, GLfloat s)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLint unit = (target & 7);
+ GLfloat * const dest = rmesa->vb.texcoordptr[unit];
+
+ switch( ctx->Texture.Unit[unit]._ReallyEnabled ) {
+ case TEXTURE_CUBE_BIT:
+ case TEXTURE_3D_BIT:
+ dest[2] = 0.0;
+ /* FALLTHROUGH */
+ case TEXTURE_2D_BIT:
+ case TEXTURE_RECT_BIT:
+ dest[1] = 0.0;
+ /* FALLTHROUGH */
+ case TEXTURE_1D_BIT:
+ dest[0] = s;
+ }
+}
+
+static void r200_MultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLint unit = (target & 7);
+ GLfloat * const dest = rmesa->vb.texcoordptr[unit];
+
+ switch( ctx->Texture.Unit[unit]._ReallyEnabled ) {
+ case TEXTURE_CUBE_BIT:
+ case TEXTURE_3D_BIT:
+ dest[2] = 0.0;
+ /* FALLTHROUGH */
+ case TEXTURE_2D_BIT:
+ case TEXTURE_RECT_BIT:
+ dest[1] = t;
+ dest[0] = s;
+ break;
+ default:
+ VFMT_FALLBACK(__FUNCTION__);
+ CALL_MultiTexCoord2fARB(GET_DISPATCH(), (target, s, t));
+ return;
+ }
+}
+
+static void r200_MultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ GLint unit = (target & 7);
+ GLfloat * const dest = rmesa->vb.texcoordptr[unit];
+
+ switch( ctx->Texture.Unit[unit]._ReallyEnabled ) {
+ case TEXTURE_CUBE_BIT:
+ case TEXTURE_3D_BIT:
+ dest[2] = r;
+ dest[1] = t;
+ dest[0] = s;
+ break;
+ default:
+ VFMT_FALLBACK(__FUNCTION__);
+ CALL_MultiTexCoord3fARB(GET_DISPATCH(), (target, s, t, r));
+ return;
+ }
+}
+
+static void r200_TexCoord1f(GLfloat s)
+{
+ r200_MultiTexCoord1fARB(GL_TEXTURE0, s);
+}
+
+static void r200_TexCoord2f(GLfloat s, GLfloat t)
+{
+ r200_MultiTexCoord2fARB(GL_TEXTURE0, s, t);
+}
+
+static void r200_TexCoord3f(GLfloat s, GLfloat t, GLfloat r)
+{
+ r200_MultiTexCoord3fARB(GL_TEXTURE0, s, t, r);
+}
+
+static void r200_TexCoord1fv(const GLfloat *v)
+{
+ r200_MultiTexCoord1fARB(GL_TEXTURE0, v[0]);
+}
+
+static void r200_TexCoord2fv(const GLfloat *v)
+{
+ r200_MultiTexCoord2fARB(GL_TEXTURE0, v[0], v[1]);
+}
+
+static void r200_TexCoord3fv(const GLfloat *v)
+{
+ r200_MultiTexCoord3fARB(GL_TEXTURE0, v[0], v[1], v[2]);
+}
+
+static void r200_MultiTexCoord1fvARB(GLenum target, const GLfloat *v)
+{
+ r200_MultiTexCoord1fARB(target, v[0]);
+}
+
+static void r200_MultiTexCoord2fvARB(GLenum target, const GLfloat *v)
+{
+ r200_MultiTexCoord2fARB(target, v[0], v[1]);
+}
+
+static void r200_MultiTexCoord3fvARB(GLenum target, const GLfloat *v)
+{
+ r200_MultiTexCoord3fARB(target, v[0], v[1], v[2]);
+}
+
+
+static struct dynfn *lookup( struct dynfn *l, const int *key )
+{
+ struct dynfn *f;
+
+ foreach( f, l ) {
+ if (f->key[0] == key[0] && f->key[1] == key[1])
+ return f;
+ }
+
+ return NULL;
+}
+
+/* Can't use the loopback template for this:
+ */
+
+#define CHOOSE(FN, FNTYPE, MASK0, MASK1, ARGS1, ARGS2 ) \
+static void choose_##FN ARGS1 \
+{ \
+ GET_CURRENT_CONTEXT(ctx); \
+ r200ContextPtr rmesa = R200_CONTEXT(ctx); \
+ int key[2]; \
+ struct dynfn *dfn; \
+ \
+ key[0] = rmesa->vb.vtxfmt_0 & MASK0; \
+ key[1] = rmesa->vb.vtxfmt_1 & MASK1; \
+ \
+ dfn = lookup( &rmesa->vb.dfn_cache.FN, key ); \
+ if (dfn == 0) \
+ dfn = rmesa->vb.codegen.FN( ctx, key ); \
+ else if (R200_DEBUG & DEBUG_CODEGEN) \
+ fprintf(stderr, "%s -- cached codegen\n", __FUNCTION__ ); \
+ \
+ if (dfn) \
+ SET_ ## FN (ctx->Exec, (FNTYPE)(dfn->code)); \
+ else { \
+ if (R200_DEBUG & DEBUG_CODEGEN) \
+ fprintf(stderr, "%s -- generic version\n", __FUNCTION__ ); \
+ SET_ ## FN (ctx->Exec, r200_##FN); \
+ } \
+ \
+ ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; \
+ CALL_ ## FN (ctx->Exec, ARGS2); \
+}
+
+
+
+/* For the _3f case, only allow one color function to be hooked in at
+ * a time. Eventually, use a similar mechanism to allow selecting the
+ * color component of the vertex format based on client behaviour.
+ *
+ * Note: Perform these actions even if there is a codegen or cached
+ * codegen version of the chosen function.
+ */
+#define CHOOSE_COLOR(FN, FNTYPE, NR, MASK0, MASK1, ARGS1, ARGS2 ) \
+static void choose_##FN ARGS1 \
+{ \
+ GET_CURRENT_CONTEXT(ctx); \
+ r200ContextPtr rmesa = R200_CONTEXT(ctx); \
+ int key[2]; \
+ struct dynfn *dfn; \
+ \
+ key[0] = rmesa->vb.vtxfmt_0 & MASK0; \
+ key[1] = rmesa->vb.vtxfmt_1 & MASK1; \
+ \
+ if (VTX_COLOR(rmesa->vb.vtxfmt_0,0) == R200_VTX_PK_RGBA) { \
+ SET_ ## FN (ctx->Exec, r200_##FN##_ub); \
+ } \
+ else if (VTX_COLOR(rmesa->vb.vtxfmt_0,0) == R200_VTX_FP_RGB) { \
+ \
+ if (rmesa->vb.installed_color_3f_sz != NR) { \
+ rmesa->vb.installed_color_3f_sz = NR; \
+ if (NR == 3) ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3] = 1.0; \
+ if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) { \
+ r200_copy_to_current( ctx ); \
+ _mesa_install_exec_vtxfmt( ctx, &rmesa->vb.vtxfmt ); \
+ CALL_ ## FN (ctx->Exec, ARGS2); \
+ return; \
+ } \
+ } \
+ \
+ SET_ ## FN (ctx->Exec, r200_##FN##_3f); \
+ } \
+ else { \
+ SET_ ## FN (ctx->Exec, r200_##FN##_4f); \
+ } \
+ \
+ \
+ dfn = lookup( &rmesa->vb.dfn_cache.FN, key ); \
+ if (!dfn) dfn = rmesa->vb.codegen.FN( ctx, key ); \
+ \
+ if (dfn) { \
+ if (R200_DEBUG & DEBUG_CODEGEN) \
+ fprintf(stderr, "%s -- codegen version\n", __FUNCTION__ ); \
+ SET_ ## FN (ctx->Exec, (FNTYPE)dfn->code); \
+ } \
+ else if (R200_DEBUG & DEBUG_CODEGEN) \
+ fprintf(stderr, "%s -- 'c' version\n", __FUNCTION__ ); \
+ \
+ ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; \
+ CALL_ ## FN (ctx->Exec, ARGS2); \
+}
+
+
+
+/* Right now there are both _ub and _3f versions of the secondary color
+ * functions. Currently, we only set-up the hardware to use the _ub versions.
+ * The _3f versions are needed for the cases where secondary color isn't used
+ * in the vertex format, but it still needs to be stored in the context
+ * state vector.
+ */
+#define CHOOSE_SECONDARY_COLOR(FN, FNTYPE, MASK0, MASK1, ARGS1, ARGS2 ) \
+static void choose_##FN ARGS1 \
+{ \
+ GET_CURRENT_CONTEXT(ctx); \
+ r200ContextPtr rmesa = R200_CONTEXT(ctx); \
+ int key[2]; \
+ struct dynfn *dfn; \
+ \
+ key[0] = rmesa->vb.vtxfmt_0 & MASK0; \
+ key[1] = rmesa->vb.vtxfmt_1 & MASK1; \
+ \
+ dfn = lookup( &rmesa->vb.dfn_cache.FN, key ); \
+ if (dfn == 0) \
+ dfn = rmesa->vb.codegen.FN( ctx, key ); \
+ else if (R200_DEBUG & DEBUG_CODEGEN) \
+ fprintf(stderr, "%s -- cached version\n", __FUNCTION__ ); \
+ \
+ if (dfn) \
+ SET_ ## FN (ctx->Exec, (FNTYPE)(dfn->code)); \
+ else { \
+ if (R200_DEBUG & DEBUG_CODEGEN) \
+ fprintf(stderr, "%s -- generic version\n", __FUNCTION__ ); \
+ SET_ ## FN (ctx->Exec, (VTX_COLOR(rmesa->vb.vtxfmt_0,1) == R200_VTX_PK_RGBA) \
+ ? r200_##FN##_ub : r200_##FN##_3f); \
+ } \
+ \
+ ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; \
+ CALL_ ## FN (ctx->Exec, ARGS2); \
+}
+
+
+
+
+
+
+
+/* VTXFMT_0
+ */
+#define MASK_XYZW (R200_VTX_W0|R200_VTX_Z0)
+#define MASK_NORM (MASK_XYZW|R200_VTX_N0)
+#define MASK_FOG (MASK_NORM |R200_VTX_DISCRETE_FOG)
+#define MASK_COLOR (MASK_FOG |(R200_VTX_COLOR_MASK<<R200_VTX_COLOR_0_SHIFT))
+#define MASK_SPEC (MASK_COLOR|(R200_VTX_COLOR_MASK<<R200_VTX_COLOR_1_SHIFT))
+
+/* VTXFMT_1
+ */
+#define MASK_ST0 (0x7 << R200_VTX_TEX0_COMP_CNT_SHIFT)
+/* FIXME: maybe something like in the radeon driver is needed here? */
+
+
+typedef void (*p4f)( GLfloat, GLfloat, GLfloat, GLfloat );
+typedef void (*p3f)( GLfloat, GLfloat, GLfloat );
+typedef void (*p2f)( GLfloat, GLfloat );
+typedef void (*p1f)( GLfloat );
+typedef void (*pe3f)( GLenum, GLfloat, GLfloat, GLfloat );
+typedef void (*pe2f)( GLenum, GLfloat, GLfloat );
+typedef void (*pe1f)( GLenum, GLfloat );
+typedef void (*p4ub)( GLubyte, GLubyte, GLubyte, GLubyte );
+typedef void (*p3ub)( GLubyte, GLubyte, GLubyte );
+typedef void (*pfv)( const GLfloat * );
+typedef void (*pefv)( GLenum, const GLfloat * );
+typedef void (*pubv)( const GLubyte * );
+
+
+CHOOSE(Normal3f, p3f, MASK_NORM, 0,
+ (GLfloat a,GLfloat b,GLfloat c), (a,b,c))
+CHOOSE(Normal3fv, pfv, MASK_NORM, 0,
+ (const GLfloat *v), (v))
+
+#if 0
+CHOOSE_COLOR(Color4ub, p4ub, 4, MASK_COLOR, 0,
+ (GLubyte a,GLubyte b, GLubyte c, GLubyte d), (a,b,c,d))
+CHOOSE_COLOR(Color4ubv, pubv, 4, MASK_COLOR, 0,
+ (const GLubyte *v), (v))
+CHOOSE_COLOR(Color3ub, p3ub, 3, MASK_COLOR, 0,
+ (GLubyte a,GLubyte b, GLubyte c), (a,b,c))
+CHOOSE_COLOR(Color3ubv, pubv, 3, MASK_COLOR, 0,
+ (const GLubyte *v), (v))
+CHOOSE_SECONDARY_COLOR(SecondaryColor3ubEXT, p3ub, MASK_SPEC, 0,
+ (GLubyte a,GLubyte b, GLubyte c), (a,b,c))
+CHOOSE_SECONDARY_COLOR(SecondaryColor3ubvEXT, pubv, MASK_SPEC, 0,
+ (const GLubyte *v), (v))
+#endif
+
+CHOOSE_COLOR(Color4f, p4f, 4, MASK_COLOR, 0,
+ (GLfloat a,GLfloat b, GLfloat c, GLfloat d), (a,b,c,d))
+CHOOSE_COLOR(Color4fv, pfv, 4, MASK_COLOR, 0,
+ (const GLfloat *v), (v))
+CHOOSE_COLOR(Color3f, p3f, 3, MASK_COLOR, 0,
+ (GLfloat a,GLfloat b, GLfloat c), (a,b,c))
+CHOOSE_COLOR(Color3fv, pfv, 3, MASK_COLOR, 0,
+ (const GLfloat *v), (v))
+
+
+CHOOSE_SECONDARY_COLOR(SecondaryColor3fEXT, p3f, MASK_SPEC, 0,
+ (GLfloat a,GLfloat b, GLfloat c), (a,b,c))
+CHOOSE_SECONDARY_COLOR(SecondaryColor3fvEXT, pfv, MASK_SPEC, 0,
+ (const GLfloat *v), (v))
+
+CHOOSE(TexCoord3f, p3f, ~0, MASK_ST0,
+ (GLfloat a,GLfloat b,GLfloat c), (a,b,c))
+CHOOSE(TexCoord3fv, pfv, ~0, MASK_ST0,
+ (const GLfloat *v), (v))
+CHOOSE(TexCoord2f, p2f, ~0, MASK_ST0,
+ (GLfloat a,GLfloat b), (a,b))
+CHOOSE(TexCoord2fv, pfv, ~0, MASK_ST0,
+ (const GLfloat *v), (v))
+CHOOSE(TexCoord1f, p1f, ~0, MASK_ST0,
+ (GLfloat a), (a))
+CHOOSE(TexCoord1fv, pfv, ~0, MASK_ST0,
+ (const GLfloat *v), (v))
+
+CHOOSE(MultiTexCoord3fARB, pe3f, ~0, ~0,
+ (GLenum u,GLfloat a,GLfloat b,GLfloat c), (u,a,b,c))
+CHOOSE(MultiTexCoord3fvARB, pefv, ~0, ~0,
+ (GLenum u,const GLfloat *v), (u,v))
+CHOOSE(MultiTexCoord2fARB, pe2f, ~0, ~0,
+ (GLenum u,GLfloat a,GLfloat b), (u,a,b))
+CHOOSE(MultiTexCoord2fvARB, pefv, ~0, ~0,
+ (GLenum u,const GLfloat *v), (u,v))
+CHOOSE(MultiTexCoord1fARB, pe1f, ~0, ~0,
+ (GLenum u,GLfloat a), (u,a))
+CHOOSE(MultiTexCoord1fvARB, pefv, ~0, ~0,
+ (GLenum u,const GLfloat *v), (u,v))
+
+CHOOSE(Vertex3f, p3f, ~0, ~0,
+ (GLfloat a,GLfloat b,GLfloat c), (a,b,c))
+CHOOSE(Vertex3fv, pfv, ~0, ~0,
+ (const GLfloat *v), (v))
+CHOOSE(Vertex2f, p2f, ~0, ~0,
+ (GLfloat a,GLfloat b), (a,b))
+CHOOSE(Vertex2fv, pfv, ~0, ~0,
+ (const GLfloat *v), (v))
+
+CHOOSE(FogCoordfEXT, p1f, MASK_FOG, ~0,
+ (GLfloat f), (f))
+CHOOSE(FogCoordfvEXT, pfv, MASK_FOG, ~0,
+ (const GLfloat *f), (f))
+
+
+
+
+void r200VtxfmtInitChoosers( GLvertexformat *vfmt )
+{
+ vfmt->Color3f = choose_Color3f;
+ vfmt->Color3fv = choose_Color3fv;
+ vfmt->Color4f = choose_Color4f;
+ vfmt->Color4fv = choose_Color4fv;
+ vfmt->SecondaryColor3fEXT = choose_SecondaryColor3fEXT;
+ vfmt->SecondaryColor3fvEXT = choose_SecondaryColor3fvEXT;
+ vfmt->MultiTexCoord1fARB = choose_MultiTexCoord1fARB;
+ vfmt->MultiTexCoord1fvARB = choose_MultiTexCoord1fvARB;
+ vfmt->MultiTexCoord2fARB = choose_MultiTexCoord2fARB;
+ vfmt->MultiTexCoord2fvARB = choose_MultiTexCoord2fvARB;
+ vfmt->MultiTexCoord3fARB = choose_MultiTexCoord3fARB;
+ vfmt->MultiTexCoord3fvARB = choose_MultiTexCoord3fvARB;
+ vfmt->Normal3f = choose_Normal3f;
+ vfmt->Normal3fv = choose_Normal3fv;
+ vfmt->TexCoord1f = choose_TexCoord1f;
+ vfmt->TexCoord1fv = choose_TexCoord1fv;
+ vfmt->TexCoord2f = choose_TexCoord2f;
+ vfmt->TexCoord2fv = choose_TexCoord2fv;
+ vfmt->TexCoord3f = choose_TexCoord3f;
+ vfmt->TexCoord3fv = choose_TexCoord3fv;
+ vfmt->Vertex2f = choose_Vertex2f;
+ vfmt->Vertex2fv = choose_Vertex2fv;
+ vfmt->Vertex3f = choose_Vertex3f;
+ vfmt->Vertex3fv = choose_Vertex3fv;
+/* vfmt->FogCoordfEXT = choose_FogCoordfEXT;
+ vfmt->FogCoordfvEXT = choose_FogCoordfvEXT;*/
+
+ /* TODO: restore ubyte colors to vtxfmt.
+ */
+#if 0
+ vfmt->Color3ub = choose_Color3ub;
+ vfmt->Color3ubv = choose_Color3ubv;
+ vfmt->Color4ub = choose_Color4ub;
+ vfmt->Color4ubv = choose_Color4ubv;
+ vfmt->SecondaryColor3ubEXT = choose_SecondaryColor3ubEXT;
+ vfmt->SecondaryColor3ubvEXT = choose_SecondaryColor3ubvEXT;
+#endif
+}
+
+
+static struct dynfn *codegen_noop( GLcontext *ctx, const int *key )
+{
+ (void) ctx; (void) key;
+ return NULL;
+}
+
+void r200InitCodegen( struct dfn_generators *gen, GLboolean useCodegen )
+{
+ gen->Vertex3f = codegen_noop;
+ gen->Vertex3fv = codegen_noop;
+ gen->Color4ub = codegen_noop;
+ gen->Color4ubv = codegen_noop;
+ gen->Normal3f = codegen_noop;
+ gen->Normal3fv = codegen_noop;
+
+ gen->TexCoord3f = codegen_noop;
+ gen->TexCoord3fv = codegen_noop;
+ gen->TexCoord2f = codegen_noop;
+ gen->TexCoord2fv = codegen_noop;
+ gen->TexCoord1f = codegen_noop;
+ gen->TexCoord1fv = codegen_noop;
+
+ gen->MultiTexCoord3fARB = codegen_noop;
+ gen->MultiTexCoord3fvARB = codegen_noop;
+ gen->MultiTexCoord2fARB = codegen_noop;
+ gen->MultiTexCoord2fvARB = codegen_noop;
+ gen->MultiTexCoord1fARB = codegen_noop;
+ gen->MultiTexCoord1fvARB = codegen_noop;
+/* gen->FogCoordfEXT = codegen_noop;
+ gen->FogCoordfvEXT = codegen_noop;*/
+
+ gen->Vertex2f = codegen_noop;
+ gen->Vertex2fv = codegen_noop;
+ gen->Color3ub = codegen_noop;
+ gen->Color3ubv = codegen_noop;
+ gen->Color4f = codegen_noop;
+ gen->Color4fv = codegen_noop;
+ gen->Color3f = codegen_noop;
+ gen->Color3fv = codegen_noop;
+ gen->SecondaryColor3fEXT = codegen_noop;
+ gen->SecondaryColor3fvEXT = codegen_noop;
+ gen->SecondaryColor3ubEXT = codegen_noop;
+ gen->SecondaryColor3ubvEXT = codegen_noop;
+
+ if (useCodegen) {
+#if defined(USE_X86_ASM)
+ r200InitX86Codegen( gen );
+#endif
+
+#if defined(USE_SSE_ASM)
+ r200InitSSECodegen( gen );
+#endif
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt_sse.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt_sse.c
new file mode 100644
index 000000000..590173049
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt_sse.c
@@ -0,0 +1,234 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_vtxfmt_sse.c,v 1.1 2002/10/30 12:51:53 alanh Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "simple_list.h"
+#include "r200_vtxfmt.h"
+
+#if defined(USE_SSE_ASM)
+#include "x86/common_x86_asm.h"
+
+#define EXTERN( FUNC ) \
+extern const char *FUNC; \
+extern const char *FUNC##_end
+
+EXTERN( _sse_Attribute2fv );
+EXTERN( _sse_Attribute2f );
+EXTERN( _sse_Attribute3fv );
+EXTERN( _sse_Attribute3f );
+EXTERN( _sse_MultiTexCoord2fv );
+EXTERN( _sse_MultiTexCoord2f );
+EXTERN( _sse_MultiTexCoord2fv_2 );
+EXTERN( _sse_MultiTexCoord2f_2 );
+
+/* Build specialized versions of the immediate calls on the fly for
+ * the current state.
+ */
+
+static struct dynfn *r200_makeSSEAttribute2fv( struct dynfn * cache, const int * key,
+ const char * name, void * dest)
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (R200_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", name, key[0] );
+
+ DFN ( _sse_Attribute2fv, (*cache) );
+ FIXUP(dfn->code, 10, 0x0, (int)dest);
+ return dfn;
+}
+
+static struct dynfn *r200_makeSSEAttribute2f( struct dynfn * cache, const int * key,
+ const char * name, void * dest )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (R200_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", name, key[0] );
+
+ DFN ( _sse_Attribute2f, (*cache) );
+ FIXUP(dfn->code, 8, 0x0, (int)dest);
+ return dfn;
+}
+
+static struct dynfn *r200_makeSSEAttribute3fv( struct dynfn * cache, const int * key,
+ const char * name, void * dest)
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (R200_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", name, key[0] );
+
+ DFN ( _sse_Attribute3fv, (*cache) );
+ FIXUP(dfn->code, 13, 0x0, (int)dest);
+ FIXUP(dfn->code, 18, 0x8, 8+(int)dest);
+ return dfn;
+}
+
+static struct dynfn *r200_makeSSEAttribute3f( struct dynfn * cache, const int * key,
+ const char * name, void * dest )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (R200_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", name, key[0] );
+
+ DFN ( _sse_Attribute3f, (*cache) );
+ FIXUP(dfn->code, 12, 0x0, (int)dest);
+ FIXUP(dfn->code, 17, 0x8, 8+(int)dest);
+ return dfn;
+}
+
+static struct dynfn *r200_makeSSENormal3fv( GLcontext *ctx, const int *key )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ return r200_makeSSEAttribute3fv( & rmesa->vb.dfn_cache.Normal3fv, key,
+ __FUNCTION__, rmesa->vb.normalptr );
+}
+
+static struct dynfn *r200_makeSSENormal3f( GLcontext *ctx, const int * key )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ return r200_makeSSEAttribute3f( & rmesa->vb.dfn_cache.Normal3f, key,
+ __FUNCTION__, rmesa->vb.normalptr );
+}
+
+static struct dynfn *r200_makeSSEColor3fv( GLcontext *ctx, const int * key )
+{
+ if (VTX_COLOR(key[0],0) != R200_VTX_FP_RGB)
+ return NULL;
+ else
+ {
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ return r200_makeSSEAttribute3fv( & rmesa->vb.dfn_cache.Color3fv, key,
+ __FUNCTION__, rmesa->vb.floatcolorptr );
+ }
+}
+
+static struct dynfn *r200_makeSSEColor3f( GLcontext *ctx, const int * key )
+{
+ if (VTX_COLOR(key[0],0) != R200_VTX_FP_RGB)
+ return NULL;
+ else
+ {
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ return r200_makeSSEAttribute3f( & rmesa->vb.dfn_cache.Color3f, key,
+ __FUNCTION__, rmesa->vb.floatcolorptr );
+ }
+}
+
+#if 0 /* Temporarily disabled as it is broken w/the new cubemap code. - idr */
+static struct dynfn *r200_makeSSETexCoord2fv( GLcontext *ctx, const int * key )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ return r200_makeSSEAttribute2fv( & rmesa->vb.dfn_cache.TexCoord2fv, key,
+ __FUNCTION__, rmesa->vb.texcoordptr[0] );
+}
+
+static struct dynfn *r200_makeSSETexCoord2f( GLcontext *ctx, const int * key )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ return r200_makeSSEAttribute2f( & rmesa->vb.dfn_cache.TexCoord2f, key,
+ __FUNCTION__, rmesa->vb.texcoordptr[0] );
+}
+
+static struct dynfn *r200_makeSSEMultiTexCoord2fv( GLcontext *ctx, const int * key )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if (R200_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", __FUNCTION__, key[0] );
+
+ if (rmesa->vb.texcoordptr[1] == rmesa->vb.texcoordptr[0]+4) {
+ DFN ( _sse_MultiTexCoord2fv, rmesa->vb.dfn_cache.MultiTexCoord2fvARB );
+ FIXUP(dfn->code, 18, 0xdeadbeef, (int)rmesa->vb.texcoordptr[0]);
+ } else {
+ DFN ( _sse_MultiTexCoord2fv_2, rmesa->vb.dfn_cache.MultiTexCoord2fvARB );
+ FIXUP(dfn->code, 14, 0x0, (int)rmesa->vb.texcoordptr);
+ }
+ return dfn;
+}
+
+static struct dynfn *r200_makeSSEMultiTexCoord2f( GLcontext *ctx, const int * key )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if (R200_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", __FUNCTION__, key[0] );
+
+ if (rmesa->vb.texcoordptr[1] == rmesa->vb.texcoordptr[0]+4) {
+ DFN ( _sse_MultiTexCoord2f, rmesa->vb.dfn_cache.MultiTexCoord2fARB );
+ FIXUP(dfn->code, 16, 0xdeadbeef, (int)rmesa->vb.texcoordptr[0]);
+ } else {
+ DFN ( _sse_MultiTexCoord2f_2, rmesa->vb.dfn_cache.MultiTexCoord2fARB );
+ FIXUP(dfn->code, 15, 0x0, (int)rmesa->vb.texcoordptr);
+ }
+ return dfn;
+}
+#endif
+
+void r200InitSSECodegen( struct dfn_generators *gen )
+{
+ if ( cpu_has_xmm ) {
+ gen->Normal3fv = (void *) r200_makeSSENormal3fv;
+ gen->Normal3f = (void *) r200_makeSSENormal3f;
+ gen->Color3fv = (void *) r200_makeSSEColor3fv;
+ gen->Color3f = (void *) r200_makeSSEColor3f;
+#if 0 /* Temporarily disabled as it is broken w/the new cubemap code. - idr */
+ gen->TexCoord2fv = (void *) r200_makeSSETexCoord2fv;
+ gen->TexCoord2f = (void *) r200_makeSSETexCoord2f;
+ gen->MultiTexCoord2fvARB = (void *) r200_makeSSEMultiTexCoord2fv;
+ gen->MultiTexCoord2fARB = (void *) r200_makeSSEMultiTexCoord2f;
+#endif
+ }
+}
+
+#else
+
+void r200InitSSECodegen( struct dfn_generators *gen )
+{
+ (void) gen;
+}
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt_x86.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt_x86.c
new file mode 100644
index 000000000..b78a55c31
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxfmt_x86.c
@@ -0,0 +1,440 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_vtxfmt_x86.c,v 1.2 2002/12/16 16:18:56 dawes Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "simple_list.h"
+#include "r200_vtxfmt.h"
+
+#if defined(USE_X86_ASM)
+
+#define EXTERN( FUNC ) \
+extern const char *FUNC; \
+extern const char *FUNC##_end
+
+EXTERN ( _x86_Attribute2fv );
+EXTERN ( _x86_Attribute2f );
+EXTERN ( _x86_Attribute3fv );
+EXTERN ( _x86_Attribute3f );
+EXTERN ( _x86_Vertex3fv_6 );
+EXTERN ( _x86_Vertex3fv_8 );
+EXTERN ( _x86_Vertex3fv );
+EXTERN ( _x86_Vertex3f_4 );
+EXTERN ( _x86_Vertex3f_6 );
+EXTERN ( _x86_Vertex3f );
+EXTERN ( _x86_Color4ubv_ub );
+EXTERN ( _x86_Color4ubv_4f );
+EXTERN ( _x86_Color4ub_ub );
+EXTERN ( _x86_MultiTexCoord2fv );
+EXTERN ( _x86_MultiTexCoord2fv_2 );
+EXTERN ( _x86_MultiTexCoord2f );
+EXTERN ( _x86_MultiTexCoord2f_2 );
+
+
+/* Build specialized versions of the immediate calls on the fly for
+ * the current state. Generic x86 versions.
+ */
+
+struct dynfn *r200_makeX86Vertex3f( GLcontext *ctx, const int *key )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (R200_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x 0x%08x %d\n", __FUNCTION__,
+ key[0], key[1], rmesa->vb.vertex_size );
+
+ switch (rmesa->vb.vertex_size) {
+ case 4: {
+
+ DFN ( _x86_Vertex3f_4, rmesa->vb.dfn_cache.Vertex3f );
+ FIXUP(dfn->code, 2, 0x0, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 25, 0x0, (int)&rmesa->vb.vertex[3]);
+ FIXUP(dfn->code, 36, 0x0, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 46, 0x0, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 51, 0x0, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 60, 0x0, (int)&rmesa->vb.notify);
+ break;
+ }
+ case 6: {
+
+ DFN ( _x86_Vertex3f_6, rmesa->vb.dfn_cache.Vertex3f );
+ FIXUP(dfn->code, 3, 0x0, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 28, 0x0, (int)&rmesa->vb.vertex[3]);
+ FIXUP(dfn->code, 34, 0x0, (int)&rmesa->vb.vertex[4]);
+ FIXUP(dfn->code, 40, 0x0, (int)&rmesa->vb.vertex[5]);
+ FIXUP(dfn->code, 57, 0x0, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 63, 0x0, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 70, 0x0, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 79, 0x0, (int)&rmesa->vb.notify);
+ break;
+ }
+ default: {
+
+ DFN ( _x86_Vertex3f, rmesa->vb.dfn_cache.Vertex3f );
+ FIXUP(dfn->code, 3, 0x0, (int)&rmesa->vb.vertex[3]);
+ FIXUP(dfn->code, 9, 0x0, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 37, 0x0, rmesa->vb.vertex_size-3);
+ FIXUP(dfn->code, 44, 0x0, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 50, 0x0, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 56, 0x0, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 67, 0x0, (int)&rmesa->vb.notify);
+ break;
+ }
+ }
+
+ return dfn;
+}
+
+
+
+struct dynfn *r200_makeX86Vertex3fv( GLcontext *ctx, const int *key )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (R200_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x 0x%08x %d\n", __FUNCTION__,
+ key[0], key[1], rmesa->vb.vertex_size );
+
+ switch (rmesa->vb.vertex_size) {
+ case 6: {
+
+ DFN ( _x86_Vertex3fv_6, rmesa->vb.dfn_cache.Vertex3fv );
+ FIXUP(dfn->code, 1, 0x00000000, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 27, 0x0000001c, (int)&rmesa->vb.vertex[3]);
+ FIXUP(dfn->code, 33, 0x00000020, (int)&rmesa->vb.vertex[4]);
+ FIXUP(dfn->code, 45, 0x00000024, (int)&rmesa->vb.vertex[5]);
+ FIXUP(dfn->code, 56, 0x00000000, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 61, 0x00000004, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 67, 0x00000004, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 76, 0x00000008, (int)&rmesa->vb.notify);
+ break;
+ }
+
+
+ case 8: {
+
+ DFN ( _x86_Vertex3fv_8, rmesa->vb.dfn_cache.Vertex3fv );
+ FIXUP(dfn->code, 1, 0x00000000, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 27, 0x0000001c, (int)&rmesa->vb.vertex[3]);
+ FIXUP(dfn->code, 33, 0x00000020, (int)&rmesa->vb.vertex[4]);
+ FIXUP(dfn->code, 45, 0x0000001c, (int)&rmesa->vb.vertex[5]);
+ FIXUP(dfn->code, 51, 0x00000020, (int)&rmesa->vb.vertex[6]);
+ FIXUP(dfn->code, 63, 0x00000024, (int)&rmesa->vb.vertex[7]);
+ FIXUP(dfn->code, 74, 0x00000000, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 79, 0x00000004, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 85, 0x00000004, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 94, 0x00000008, (int)&rmesa->vb.notify);
+ break;
+ }
+
+
+
+ default: {
+
+ DFN ( _x86_Vertex3fv, rmesa->vb.dfn_cache.Vertex3fv );
+ FIXUP(dfn->code, 8, 0x01010101, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 32, 0x00000006, rmesa->vb.vertex_size-3);
+ FIXUP(dfn->code, 37, 0x00000058, (int)&rmesa->vb.vertex[3]);
+ FIXUP(dfn->code, 45, 0x01010101, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 50, 0x02020202, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 58, 0x02020202, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 67, 0x0, (int)&rmesa->vb.notify);
+ break;
+ }
+ }
+
+ return dfn;
+}
+
+static struct dynfn *
+r200_makeX86Attribute2fv( struct dynfn * cache, const int *key,
+ const char * name, void * dest )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (R200_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", name, key[0] );
+
+ DFN ( _x86_Attribute2fv, (*cache) );
+ FIXUP(dfn->code, 11, 0x0, (int)dest);
+ FIXUP(dfn->code, 16, 0x4, 4+(int)dest);
+
+ return dfn;
+}
+
+static struct dynfn *
+r200_makeX86Attribute2f( struct dynfn * cache, const int *key,
+ const char * name, void * dest )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (R200_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", name, key[0] );
+
+ DFN ( _x86_Attribute2f, (*cache) );
+ FIXUP(dfn->code, 1, 0x0, (int)dest);
+
+ return dfn;
+}
+
+
+static struct dynfn *
+r200_makeX86Attribute3fv( struct dynfn * cache, const int *key,
+ const char * name, void * dest )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (R200_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", name, key[0] );
+
+ DFN ( _x86_Attribute3fv, (*cache) );
+ FIXUP(dfn->code, 14, 0x0, (int)dest);
+ FIXUP(dfn->code, 20, 0x4, 4+(int)dest);
+ FIXUP(dfn->code, 25, 0x8, 8+(int)dest);
+
+ return dfn;
+}
+
+static struct dynfn *
+r200_makeX86Attribute3f( struct dynfn * cache, const int *key,
+ const char * name, void * dest )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (R200_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", name, key[0] );
+
+ DFN ( _x86_Attribute3f, (*cache) );
+ FIXUP(dfn->code, 14, 0x0, (int)dest);
+ FIXUP(dfn->code, 20, 0x4, 4+(int)dest);
+ FIXUP(dfn->code, 25, 0x8, 8+(int)dest);
+
+ return dfn;
+}
+
+struct dynfn *r200_makeX86Normal3fv( GLcontext *ctx, const int *key )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ return r200_makeX86Attribute3fv( & rmesa->vb.dfn_cache.Normal3fv, key,
+ __FUNCTION__, rmesa->vb.normalptr );
+}
+
+struct dynfn *r200_makeX86Normal3f( GLcontext *ctx, const int *key )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ return r200_makeX86Attribute3f( & rmesa->vb.dfn_cache.Normal3f, key,
+ __FUNCTION__, rmesa->vb.normalptr );
+}
+
+struct dynfn *r200_makeX86Color4ubv( GLcontext *ctx, const int *key )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+
+ if (R200_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", __FUNCTION__, key[0] );
+
+ if (VTX_COLOR(key[0],0) == R200_VTX_PK_RGBA) {
+ DFN ( _x86_Color4ubv_ub, rmesa->vb.dfn_cache.Color4ubv);
+ FIXUP(dfn->code, 5, 0x12345678, (int)rmesa->vb.colorptr);
+ return dfn;
+ }
+ else {
+
+ DFN ( _x86_Color4ubv_4f, rmesa->vb.dfn_cache.Color4ubv);
+ FIXUP(dfn->code, 2, 0x00000000, (int)_mesa_ubyte_to_float_color_tab);
+ FIXUP(dfn->code, 27, 0xdeadbeaf, (int)rmesa->vb.floatcolorptr);
+ FIXUP(dfn->code, 33, 0xdeadbeaf, (int)rmesa->vb.floatcolorptr+4);
+ FIXUP(dfn->code, 55, 0xdeadbeaf, (int)rmesa->vb.floatcolorptr+8);
+ FIXUP(dfn->code, 61, 0xdeadbeaf, (int)rmesa->vb.floatcolorptr+12);
+ return dfn;
+ }
+}
+
+struct dynfn *r200_makeX86Color4ub( GLcontext *ctx, const int *key )
+{
+ if (R200_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", __FUNCTION__, key[0] );
+
+ if (VTX_COLOR(key[0],0) == R200_VTX_PK_RGBA) {
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ DFN ( _x86_Color4ub_ub, rmesa->vb.dfn_cache.Color4ub );
+ FIXUP(dfn->code, 18, 0x0, (int)rmesa->vb.colorptr);
+ FIXUP(dfn->code, 24, 0x0, (int)rmesa->vb.colorptr+1);
+ FIXUP(dfn->code, 30, 0x0, (int)rmesa->vb.colorptr+2);
+ FIXUP(dfn->code, 36, 0x0, (int)rmesa->vb.colorptr+3);
+ return dfn;
+ }
+ else
+ return NULL;
+}
+
+
+struct dynfn *r200_makeX86Color3fv( GLcontext *ctx, const int *key )
+{
+ if (VTX_COLOR(key[0],0) != R200_VTX_FP_RGB)
+ return NULL;
+ else
+ {
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ return r200_makeX86Attribute3fv( & rmesa->vb.dfn_cache.Color3fv, key,
+ __FUNCTION__, rmesa->vb.floatcolorptr );
+ }
+}
+
+struct dynfn *r200_makeX86Color3f( GLcontext *ctx, const int *key )
+{
+ if (VTX_COLOR(key[0],0) != R200_VTX_FP_RGB)
+ return NULL;
+ else
+ {
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ return r200_makeX86Attribute3f( & rmesa->vb.dfn_cache.Color3f, key,
+ __FUNCTION__, rmesa->vb.floatcolorptr );
+ }
+}
+
+
+
+#if 0 /* Temporarily disabled as it is broken w/the new cubemap code. - idr */
+struct dynfn *r200_makeX86TexCoord2fv( GLcontext *ctx, const int *key )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ return r200_makeX86Attribute2fv( & rmesa->vb.dfn_cache.TexCoord2fv, key,
+ __FUNCTION__, rmesa->vb.texcoordptr[0] );
+}
+
+struct dynfn *r200_makeX86TexCoord2f( GLcontext *ctx, const int *key )
+{
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ return r200_makeX86Attribute2f( & rmesa->vb.dfn_cache.TexCoord2f, key,
+ __FUNCTION__, rmesa->vb.texcoordptr[0] );
+}
+
+struct dynfn *r200_makeX86MultiTexCoord2fvARB( GLcontext *ctx, const int *key )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if (R200_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x 0x%08x\n", __FUNCTION__, key[0], key[1] );
+
+ if (rmesa->vb.texcoordptr[1] == rmesa->vb.texcoordptr[0]+4) {
+ DFN ( _x86_MultiTexCoord2fv, rmesa->vb.dfn_cache.MultiTexCoord2fvARB );
+ FIXUP(dfn->code, 21, 0xdeadbeef, (int)rmesa->vb.texcoordptr[0]);
+ FIXUP(dfn->code, 27, 0xdeadbeef, (int)rmesa->vb.texcoordptr[0]+4);
+ } else {
+ DFN ( _x86_MultiTexCoord2fv_2, rmesa->vb.dfn_cache.MultiTexCoord2fvARB );
+ FIXUP(dfn->code, 14, 0x0, (int)rmesa->vb.texcoordptr);
+ }
+ return dfn;
+}
+
+struct dynfn *r200_makeX86MultiTexCoord2fARB( GLcontext *ctx,
+ const int *key )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+ r200ContextPtr rmesa = R200_CONTEXT(ctx);
+
+ if (R200_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x 0x%08x\n", __FUNCTION__, key[0], key[1] );
+
+ if (rmesa->vb.texcoordptr[1] == rmesa->vb.texcoordptr[0]+4) {
+ DFN ( _x86_MultiTexCoord2f, rmesa->vb.dfn_cache.MultiTexCoord2fARB );
+ FIXUP(dfn->code, 20, 0xdeadbeef, (int)rmesa->vb.texcoordptr[0]);
+ FIXUP(dfn->code, 26, 0xdeadbeef, (int)rmesa->vb.texcoordptr[0]+4);
+ }
+ else {
+ /* Note: this might get generated multiple times, even though the
+ * actual emitted code is the same.
+ */
+ DFN ( _x86_MultiTexCoord2f_2, rmesa->vb.dfn_cache.MultiTexCoord2fARB );
+ FIXUP(dfn->code, 18, 0x0, (int)rmesa->vb.texcoordptr);
+ }
+ return dfn;
+}
+#endif
+
+void r200InitX86Codegen( struct dfn_generators *gen )
+{
+ gen->Vertex3f = r200_makeX86Vertex3f;
+ gen->Vertex3fv = r200_makeX86Vertex3fv;
+ gen->Color4ub = r200_makeX86Color4ub; /* PKCOLOR only */
+ gen->Color4ubv = r200_makeX86Color4ubv; /* PKCOLOR only */
+ gen->Normal3f = r200_makeX86Normal3f;
+ gen->Normal3fv = r200_makeX86Normal3fv;
+#if 0 /* Temporarily disabled as it is broken w/the new cubemap code. - idr */
+ gen->TexCoord2f = r200_makeX86TexCoord2f;
+ gen->TexCoord2fv = r200_makeX86TexCoord2fv;
+ gen->MultiTexCoord2fARB = r200_makeX86MultiTexCoord2fARB;
+ gen->MultiTexCoord2fvARB = r200_makeX86MultiTexCoord2fvARB;
+#endif
+ gen->Color3f = r200_makeX86Color3f;
+ gen->Color3fv = r200_makeX86Color3fv;
+
+ /* Not done:
+ */
+/* gen->Vertex2f = r200_makeX86Vertex2f; */
+/* gen->Vertex2fv = r200_makeX86Vertex2fv; */
+/* gen->Color3ub = r200_makeX86Color3ub; */
+/* gen->Color3ubv = r200_makeX86Color3ubv; */
+/* gen->Color4f = r200_makeX86Color4f; */
+/* gen->Color4fv = r200_makeX86Color4fv; */
+/* gen->TexCoord1f = r200_makeX86TexCoord1f; */
+/* gen->TexCoord1fv = r200_makeX86TexCoord1fv; */
+/* gen->MultiTexCoord1fARB = r200_makeX86MultiTexCoord1fARB; */
+/* gen->MultiTexCoord1fvARB = r200_makeX86MultiTexCoord1fvARB; */
+}
+
+
+#else
+
+void r200InitX86Codegen( struct dfn_generators *gen )
+{
+ (void) gen;
+}
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxtmp_x86.S b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxtmp_x86.S
new file mode 100644
index 000000000..57a35c657
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r200/r200_vtxtmp_x86.S
@@ -0,0 +1,495 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_vtxtmp_x86.S,v 1.2 2002/11/07 18:31:59 tsi Exp $ */
+/**************************************************************************
+
+Copyright 2002 Tungsten Graphics 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, TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#define GLOBL( x ) \
+.globl x; \
+x:
+
+.data
+.align 4
+
+/*
+ vertex 3f vertex size 4
+*/
+
+GLOBL ( _x86_Vertex3f_4 )
+ movl (0), %ecx
+ movl 4(%esp), %eax
+ movl 8(%esp), %edx
+ movl %eax, (%ecx)
+ movl %edx, 4(%ecx)
+ movl 12(%esp), %eax
+ movl (0), %edx
+ movl %eax, 8(%ecx)
+ movl %edx, 12(%ecx)
+ movl (0), %eax
+ addl $16, %ecx
+ dec %eax
+ movl %ecx, (0)
+ movl %eax, (0)
+ je .1
+ ret
+.1: jmp *0
+
+GLOBL ( _x86_Vertex3f_4_end )
+
+/*
+ vertex 3f vertex size 6
+*/
+GLOBL ( _x86_Vertex3f_6 )
+ push %edi
+ movl (0), %edi
+ movl 8(%esp), %eax
+ movl 12(%esp), %edx
+ movl 16(%esp), %ecx
+ movl %eax, (%edi)
+ movl %edx, 4(%edi)
+ movl %ecx, 8(%edi)
+ movl (0), %eax
+ movl (0), %edx
+ movl (0), %ecx
+ movl %eax, 12(%edi)
+ movl %edx, 16(%edi)
+ movl %ecx, 20(%edi)
+ addl $24, %edi
+ movl (0), %eax
+ movl %edi, (0)
+ dec %eax
+ pop %edi
+ movl %eax, (0)
+ je .2
+ ret
+.2: jmp *0
+GLOBL ( _x86_Vertex3f_6_end )
+/*
+ vertex 3f generic size
+*/
+GLOBL ( _x86_Vertex3f )
+ push %edi
+ push %esi
+ movl $0, %esi
+ movl (0), %edi
+ movl 12(%esp), %eax
+ movl 16(%esp), %edx
+ movl 20(%esp), %ecx
+ movl %eax, (%edi)
+ movl %edx, 4(%edi)
+ movl %ecx, 8(%edi)
+ addl $12, %edi
+ movl $0, %ecx
+ repz
+ movsl %ds:(%esi), %es:(%edi)
+ movl (0), %eax
+ movl %edi, (0)
+ dec %eax
+ movl %eax, (0)
+ pop %esi
+ pop %edi
+ je .3
+ ret
+.3: jmp *0
+
+GLOBL ( _x86_Vertex3f_end )
+
+/*
+ Vertex 3fv vertex size 6
+*/
+GLOBL ( _x86_Vertex3fv_6 )
+ movl (0), %eax
+ movl 4(%esp), %ecx
+ movl (%ecx), %edx
+ movl %edx, (%eax)
+ movl 4(%ecx), %edx
+ movl 8(%ecx), %ecx
+ movl %edx, 4(%eax)
+ movl %ecx, 8(%eax)
+ movl (28), %edx
+ movl (32), %ecx
+ movl %edx, 12(%eax)
+ movl %ecx, 16(%eax)
+ movl (36), %edx
+ movl %edx, 20(%eax)
+ addl $24, %eax
+ movl %eax, 0
+ movl 4, %eax
+ dec %eax
+ movl %eax, 4
+ je .4
+ ret
+.4: jmp *8
+
+GLOBL ( _x86_Vertex3fv_6_end )
+
+/*
+ Vertex 3fv vertex size 8
+*/
+GLOBL ( _x86_Vertex3fv_8 )
+ movl (0), %eax
+ movl 4(%esp), %ecx
+ movl (%ecx), %edx
+ movl %edx ,(%eax)
+ movl 4(%ecx) ,%edx
+ movl 8(%ecx) ,%ecx
+ movl %edx, 4(%eax)
+ movl %ecx, 8(%eax)
+ movl (28), %edx
+ movl (32), %ecx
+ movl %edx, 12(%eax)
+ movl %ecx, 16(%eax)
+ movl (28), %edx
+ movl (32), %ecx
+ movl %edx, 20(%eax)
+ movl %ecx, 24(%eax)
+ movl (36), %edx
+ movl %edx, 28(%eax)
+ addl $32, %eax
+ movl %eax, (0)
+ movl 4, %eax
+ dec %eax
+ movl %eax, (4)
+ je .5
+ ret
+.5: jmp *8
+
+GLOBL ( _x86_Vertex3fv_8_end )
+
+/*
+ Vertex 3fv generic vertex size
+*/
+GLOBL ( _x86_Vertex3fv )
+ movl 4(%esp), %edx
+ push %edi
+ push %esi
+ movl (0x1010101), %edi
+ movl (%edx), %eax
+ movl 4(%edx), %ecx
+ movl 8(%edx), %esi
+ movl %eax, (%edi)
+ movl %ecx, 4(%edi)
+ movl %esi, 8(%edi)
+ addl $12, %edi
+ movl $6, %ecx
+ movl $0x58, %esi
+ repz
+ movsl %ds:(%esi), %es:(%edi)
+ movl %edi, (0x1010101)
+ movl (0x2020202), %eax
+ pop %esi
+ pop %edi
+ dec %eax
+ movl %eax, (0x2020202)
+ je .6
+ ret
+.6: jmp *0
+GLOBL ( _x86_Vertex3fv_end )
+
+
+/**
+ * Generic handler for 2 float format data. This can be used for
+ * TexCoord2f and possibly other functions.
+ */
+
+GLOBL ( _x86_Attribute2f )
+ movl $0x0, %edx
+ movl 4(%esp), %eax
+ movl 8(%esp), %ecx
+ movl %eax, (%edx)
+ movl %ecx, 4(%edx)
+ ret
+GLOBL ( _x86_Attribute2f_end )
+
+
+/**
+ * Generic handler for 2 float vector format data. This can be used for
+ * TexCoord2fv and possibly other functions.
+ */
+
+GLOBL( _x86_Attribute2fv)
+ movl 4(%esp), %eax /* load 'v' off stack */
+ movl (%eax), %ecx /* load v[0] */
+ movl 4(%eax), %eax /* load v[1] */
+ movl %ecx, 0 /* store v[0] to current vertex */
+ movl %eax, 4 /* store v[1] to current vertex */
+ ret
+GLOBL ( _x86_Attribute2fv_end )
+
+
+/**
+ * Generic handler for 3 float format data. This can be used for
+ * Normal3f, Color3f (when the color target is also float), or
+ * TexCoord3f.
+ */
+
+GLOBL ( _x86_Attribute3f )
+ movl 4(%esp), %ecx
+ movl 8(%esp), %edx
+ movl 12(%esp), %eax
+ movl %ecx, 0
+ movl %edx, 4
+ movl %eax, 8
+ ret
+GLOBL ( _x86_Attribute3f_end )
+
+/**
+ * Generic handler for 3 float vector format data. This can be used for
+ * Normal3f, Color3f (when the color target is also float), or
+ * TexCoord3f.
+ */
+
+GLOBL( _x86_Attribute3fv)
+ movl 4(%esp), %eax /* load 'v' off stack */
+ movl (%eax), %ecx /* load v[0] */
+ movl 4(%eax), %edx /* load v[1] */
+ movl 8(%eax), %eax /* load v[2] */
+ movl %ecx, 0 /* store v[0] to current vertex */
+ movl %edx, 4 /* store v[1] to current vertex */
+ movl %eax, 8 /* store v[2] to current vertex */
+ ret
+GLOBL ( _x86_Attribute3fv_end )
+
+
+/*
+ Color 4ubv_ub
+*/
+GLOBL ( _x86_Color4ubv_ub )
+ movl 4(%esp), %eax
+ movl $0x12345678, %edx
+ movl (%eax), %eax
+ movl %eax, (%edx)
+ ret
+GLOBL ( _x86_Color4ubv_ub_end )
+
+/*
+ Color 4ubv 4f
+*/
+GLOBL ( _x86_Color4ubv_4f )
+ push %ebx
+ movl $0, %edx
+ xor %eax, %eax
+ xor %ecx, %ecx
+ movl 8(%esp), %ebx
+ movl (%ebx), %ebx
+ mov %bl, %al
+ mov %bh, %cl
+ movl (%edx,%eax,4),%eax
+ movl (%edx,%ecx,4),%ecx
+ movl %eax, (0xdeadbeaf)
+ movl %ecx, (0xdeadbeaf)
+ xor %eax, %eax
+ xor %ecx, %ecx
+ shr $16, %ebx
+ mov %bl, %al
+ mov %bh, %cl
+ movl (%edx,%eax,4), %eax
+ movl (%edx,%ecx,4), %ecx
+ movl %eax, (0xdeadbeaf)
+ movl %ecx, (0xdeadbeaf)
+ pop %ebx
+ ret
+GLOBL ( _x86_Color4ubv_4f_end )
+
+/*
+
+ Color4ub_ub
+*/
+GLOBL( _x86_Color4ub_ub )
+ push %ebx
+ movl 8(%esp), %eax
+ movl 12(%esp), %edx
+ movl 16(%esp), %ecx
+ movl 20(%esp), %ebx
+ mov %al, (0)
+ mov %dl, (0)
+ mov %cl, (0)
+ mov %bl, (0)
+ pop %ebx
+ ret
+GLOBL( _x86_Color4ub_ub_end )
+
+
+/* \todo: change the "and $7, %eax" to something like "target & 4 ? target & 5 : target & 3)" */
+/*
+ MultiTexCoord2fv st0/st1
+*/
+GLOBL( _x86_MultiTexCoord2fv )
+ movl 4(%esp), %eax
+ movl 8(%esp), %ecx
+ and $7, %eax
+ movl (%ecx), %edx
+ shl $3, %eax
+ movl 4(%ecx), %ecx
+ movl %edx, 0xdeadbeef(%eax)
+ movl %ecx, 0xdeadbeef(%eax)
+ ret
+GLOBL( _x86_MultiTexCoord2fv_end )
+
+/*
+ MultiTexCoord2fv
+*/
+
+GLOBL( _x86_MultiTexCoord2fv_2 )
+ movl 4(%esp,1), %eax
+ movl 8(%esp,1), %ecx
+ and $0x7, %eax
+ movl 0(,%eax,4), %edx
+ movl (%ecx), %eax
+ movl %eax, (%edx)
+ movl 4(%ecx), %eax
+ movl %eax, 4(%edx)
+ ret
+GLOBL( _x86_MultiTexCoord2fv_2_end )
+
+/*
+ MultiTexCoord2f st0/st1
+*/
+GLOBL( _x86_MultiTexCoord2f )
+ movl 4(%esp), %eax
+ movl 8(%esp), %edx
+ movl 12(%esp), %ecx
+ and $7, %eax
+ shl $3, %eax
+ movl %edx, 0xdeadbeef(%eax)
+ movl %ecx, 0xdeadbeef(%eax)
+ ret
+GLOBL( _x86_MultiTexCoord2f_end )
+
+/*
+ MultiTexCoord2f
+*/
+GLOBL( _x86_MultiTexCoord2f_2 )
+ movl 4(%esp), %eax
+ movl 8(%esp), %edx
+ movl 12(%esp,1), %ecx
+ and $7,%eax
+ movl 0(,%eax,4), %eax
+ movl %edx, (%eax)
+ movl %ecx, 4(%eax)
+ ret
+GLOBL( _x86_MultiTexCoord2f_2_end )
+
+#if defined(USE_SSE_ASM)
+/**
+ * This can be used as a template for either Color3fv (when the color
+ * target is also a 3f) or Normal3fv.
+ */
+
+GLOBL( _sse_Attribute3fv )
+ movl 4(%esp), %eax
+ movlps (%eax), %xmm0
+ movl 8(%eax), %eax
+ movlps %xmm0, 0
+ movl %eax, 8
+ ret
+GLOBL( _sse_Attribute3fv_end )
+
+/**
+ * This can be used as a template for either Color3f (when the color
+ * target is also a 3f) or Normal3f.
+ */
+
+GLOBL( _sse_Attribute3f )
+ movlps 4(%esp), %xmm0
+ movl 12(%esp), %eax
+ movlps %xmm0, 0
+ movl %eax, 8
+ ret
+GLOBL( _sse_Attribute3f_end )
+
+
+/**
+ * Generic handler for 2 float vector format data. This can be used for
+ * TexCoord2fv and possibly other functions.
+ */
+
+GLOBL( _sse_Attribute2fv )
+ movl 4(%esp), %eax
+ movlps (%eax), %xmm0
+ movlps %xmm0, 0
+ ret
+GLOBL( _sse_Attribute2fv_end )
+
+
+/**
+ * Generic handler for 2 float format data. This can be used for
+ * TexCoord2f and possibly other functions.
+ */
+
+GLOBL( _sse_Attribute2f )
+ movlps 4(%esp), %xmm0
+ movlps %xmm0, 0
+ ret
+GLOBL( _sse_Attribute2f_end )
+
+/*
+ MultiTexCoord2fv st0/st1
+*/
+GLOBL( _sse_MultiTexCoord2fv )
+ movl 4(%esp), %eax
+ movl 8(%esp), %ecx
+ and $7, %eax
+ movlps (%ecx), %xmm0
+ movlps %xmm0, 0xdeadbeef(,%eax,8)
+ ret
+GLOBL( _sse_MultiTexCoord2fv_end )
+
+/*
+ MultiTexCoord2fv
+*/
+GLOBL( _sse_MultiTexCoord2fv_2 )
+ movl 4(%esp), %eax
+ movl 8(%esp), %ecx
+ and $0x7, %eax
+ movl 0(,%eax,4), %edx
+ movlps (%ecx), %xmm0
+ movlps %xmm0, (%edx)
+ ret
+GLOBL( _sse_MultiTexCoord2fv_2_end )
+
+/*
+ MultiTexCoord2f st0/st1
+*/
+GLOBL( _sse_MultiTexCoord2f )
+ movl 4(%esp), %eax
+ and $7, %eax
+ movlps 8(%esp), %xmm0
+ movlps %xmm0, 0xdeadbeef(,%eax,8)
+ ret
+GLOBL( _sse_MultiTexCoord2f_end )
+
+/*
+ MultiTexCoord2f
+*/
+GLOBL( _sse_MultiTexCoord2f_2 )
+ movl 4(%esp), %eax
+ movlps 8(%esp), %xmm0
+ and $7,%eax
+ movl 0(,%eax,4), %eax
+ movlps %xmm0, (%eax)
+ ret
+GLOBL( _sse_MultiTexCoord2f_2_end )
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/Makefile
new file mode 100644
index 000000000..57c7fc7aa
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/Makefile
@@ -0,0 +1,83 @@
+# src/mesa/drivers/dri/r300/Makefile
+
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = r300_dri.so
+DEFINES += -DCOMPILE_R300 -DGLX_DIRECT_RENDERING -DR200_MERGED=0
+
+MINIGLX_SOURCES = server/radeon_dri.c
+
+COMMON_SOURCES = \
+ ../../common/driverfuncs.c \
+ ../common/mm.c \
+ ../common/utils.c \
+ ../common/texmem.c \
+ ../common/vblank.c \
+ ../common/xmlconfig.c \
+ ../common/dri_util.c
+
+DRIVER_SOURCES = \
+ radeon_screen.c \
+ radeon_context.c \
+ radeon_ioctl.c \
+ radeon_lock.c \
+ radeon_span.c \
+ radeon_state.c \
+ \
+ r300_context.c \
+ r300_ioctl.c \
+ r300_cmdbuf.c \
+ r300_state.c \
+ r300_render.c \
+ r300_texmem.c \
+ r300_tex.c \
+ r300_texstate.c \
+ r300_texprog.c \
+ r300_vertexprog.c \
+ r300_fragprog.c \
+ r300_shader.c \
+ r300_maos.c
+# \
+# r200_context.c \
+# r200_ioctl.c \
+# r200_state.c \
+# r200_state_init.c \
+# r200_cmdbuf.c \
+# r200_pixel.c \
+# r200_tex.c \
+# r200_texmem.c \
+# r200_texstate.c \
+# r200_swtcl.c \
+# r200_maos.c \
+# r200_sanity.c \
+# r200_vtxfmt.c \
+# r200_vtxfmt_c.c \
+# r200_vtxfmt_sse.c \
+# r200_vtxfmt_x86.c
+
+
+C_SOURCES = $(COMMON_SOURCES) $(DRIVER_SOURCES)
+
+X86_SOURCES =
+#r200_vtxtmp_x86.S
+
+SYMLINKS = \
+ server/radeon_dri.c \
+ server/radeon_dri.h \
+ server/radeon.h \
+ server/radeon_macros.h \
+ server/radeon_reg.h
+
+##### TARGETS #####
+
+
+include ../Makefile.template
+
+$(SYMLINKS):
+ mkdir -p server
+ for i in $(SYMLINKS) ; do rm -f $$i && test -f ../radeon/$$i && ln -s ../../radeon/$$i $$i ; done
+
+symlinks: $(SYMLINKS)
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/pixel_shader.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/pixel_shader.h
new file mode 100644
index 000000000..0d04859f9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/pixel_shader.h
@@ -0,0 +1,103 @@
+#ifndef __PIXEL_SHADER_H__
+#define __PIXEL_SHADER_H__
+
+#include "r300_reg.h"
+
+
+/* INSTR 0 */
+
+#define PFS_OP_MAD 0
+#define PFS_OP_DP3 1
+#define PFS_OP_DP4 2
+#define PFS_OP_MIN 4
+#define PFS_OP_MAX 5
+#define PFS_OP_CMP 8
+#define PFS_OP_FRC 9
+#define PFS_OP_OUTC_REPL_ALPHA 10
+
+/* "or" these with arg0 value to negate or take absolute value of an argument */
+#define PFS_ARG_NEG (1<<5)
+#define PFS_ARG_ABS (1<<6)
+
+#define MAKE_PFS_INSTR0(op, arg0, arg1, arg2, flags) \
+ ( ((op)<<23) \
+ | ((arg0)<<R300_FPI0_ARG0C_SHIFT) \
+ | ((arg1)<<R300_FPI0_ARG1C_SHIFT) \
+ | ((arg2)<<R300_FPI0_ARG2C_SHIFT) \
+ | (flags) \
+ )
+
+#define PFS_FLAG_X 1
+#define PFS_FLAG_Y 2
+#define PFS_FLAG_XY 3
+#define PFS_FLAG_Z 4
+#define PFS_FLAG_XZ 5
+#define PFS_FLAG_YZ 6
+#define PFS_FLAG_ALL 7
+#define PFS_FLAG_NONE 0
+
+#define EASY_PFS_INSTR0(op, arg0, arg1, arg2) \
+ MAKE_PFS_INSTR0(PFS_OP_##op, \
+ R300_FPI0_ARGC_##arg0, \
+ R300_FPI0_ARGC_##arg1, \
+ R300_FPI0_ARGC_##arg2, \
+ 0)
+
+/* INSTR 1 */
+
+#define PFS_FLAG_CONST (1<<5)
+
+#define MAKE_PFS_INSTR1(dstc, src0, src1, src2, reg, output) \
+ ((src0) | ((src1) << R300_FPI1_SRC1C_SHIFT) \
+ | ((src2)<<R300_FPI1_SRC2C_SHIFT) \
+ | ((dstc) << R300_FPI1_DSTC_SHIFT) \
+ | ((reg) << 23) | ((output)<<26))
+
+#define EASY_PFS_INSTR1(dstc, src0, src1, src2, reg, output) \
+ MAKE_PFS_INSTR1(dstc, src0, src1, src2, PFS_FLAG_##reg, PFS_FLAG_##output)
+
+/* INSTR 2 */
+
+/* you can "or" PFS_ARG_NEG with these values to negate them */
+
+#define MAKE_PFS_INSTR2(op, arg0, arg1, arg2, flags) \
+ (((op) << 23) | \
+ ((arg0)<<R300_FPI2_ARG0A_SHIFT) | \
+ ((arg1)<<R300_FPI2_ARG1A_SHIFT) | \
+ ((arg2)<<R300_FPI2_ARG2A_SHIFT) | \
+ (flags))
+
+#define EASY_PFS_INSTR2(op, arg0, arg1, arg2) \
+ MAKE_PFS_INSTR2(R300_FPI2_OUTA_##op, \
+ R300_FPI2_ARGA_##arg0, \
+ R300_FPI2_ARGA_##arg1, \
+ R300_FPI2_ARGA_##arg2, \
+ 0)
+
+
+/* INSTR 3 */
+
+#define PFS_FLAG_NONE 0
+#define PFS_FLAG_REG 1
+#define PFS_FLAG_OUTPUT 2
+#define PFS_FLAG_BOTH 3
+
+#define MAKE_PFS_INSTR3(dstc, src0, src1, src2, flags) \
+ ((src0) | ((src1) << R300_FPI1_SRC1C_SHIFT) \
+ | ((src2)<<R300_FPI1_SRC2C_SHIFT) \
+ | ((dstc) << R300_FPI1_DSTC_SHIFT) \
+ | ((flags) << 23))
+
+#define EASY_PFS_INSTR3(dstc, src0, src1, src2, flag) \
+ MAKE_PFS_INSTR3(dstc, src0, src1, src2, PFS_FLAG_##flag)
+
+ /* What are 0's ORed with flags ? They are register numbers that
+ just happen to be 0 */
+#define PFS_NOP { \
+ EASY_PFS_INSTR0(MAD, SRC0C_XYZ, ONE, ZERO), \
+ EASY_PFS_INSTR1(0, 0, 0 | PFS_FLAG_CONST, 0 | PFS_FLAG_CONST, NONE, ALL), \
+ EASY_PFS_INSTR2(MAD, SRC0A, ONE, ZERO), \
+ EASY_PFS_INSTR3(0, 0, 0 | PFS_FLAG_CONST, 0 | PFS_FLAG_CONST, OUTPUT) \
+ }
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_context.h
new file mode 100644
index 000000000..2c1eda33f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_context.h
@@ -0,0 +1,822 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_context.h,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R200_CONTEXT_H__
+#define __R200_CONTEXT_H__
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include "tnl/t_vertex.h"
+#include "drm.h"
+#include "radeon_drm.h"
+#include "dri_util.h"
+#include "texmem.h"
+
+#include "macros.h"
+#include "mtypes.h"
+#include "colormac.h"
+#include "r200_reg.h"
+#include "radeon_context.h"
+
+#define ENABLE_HW_3D_TEXTURE 1 /* XXX this is temporary! */
+
+struct r200_context;
+typedef struct r200_context r200ContextRec;
+typedef struct r200_context *r200ContextPtr;
+
+#include "mm.h"
+
+/* The blit width for texture uploads
+ */
+#define BLIT_WIDTH_BYTES 1024
+
+/* Use the templated vertex format:
+ */
+#define COLOR_IS_RGBA
+#define TAG(x) r200##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+typedef void (*r200_tri_func) (r200ContextPtr,
+ r200Vertex *, r200Vertex *, r200Vertex *);
+
+typedef void (*r200_line_func) (r200ContextPtr, r200Vertex *, r200Vertex *);
+
+typedef void (*r200_point_func) (r200ContextPtr, r200Vertex *);
+
+struct r200_depthbuffer_state {
+ GLfloat scale;
+};
+
+struct r200_stencilbuffer_state {
+ GLboolean hwBuffer;
+ GLuint clear; /* rb3d_stencilrefmask value */
+};
+
+struct r200_stipple_state {
+ GLuint mask[32];
+};
+
+typedef struct r200_tex_obj r200TexObj, *r200TexObjPtr;
+
+/* Texture object in locally shared texture space.
+ */
+struct r200_tex_obj {
+ driTextureObject base;
+
+ GLuint bufAddr; /* Offset to start of locally
+ shared texture block */
+
+ GLuint dirty_state; /* Flags (1 per texunit) for
+ whether or not this texobj
+ has dirty hardware state
+ (pp_*) that needs to be
+ brought into the
+ texunit. */
+
+ drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
+ /* Six, for the cube faces */
+
+ GLuint pp_txfilter; /* hardware register values */
+ GLuint pp_txformat;
+ GLuint pp_txformat_x;
+ GLuint pp_txoffset; /* Image location in texmem.
+ All cube faces follow. */
+ GLuint pp_txsize; /* npot only */
+ GLuint pp_txpitch; /* npot only */
+ GLuint pp_border_color;
+ GLuint pp_cubic_faces; /* cube face 1,2,3,4 log2 sizes */
+
+ GLboolean border_fallback;
+};
+
+struct r200_texture_env_state {
+ r200TexObjPtr texobj;
+ GLenum format;
+ GLenum envMode;
+};
+
+#define R200_MAX_TEXTURE_UNITS 6
+
+struct r200_texture_state {
+ struct r200_texture_env_state unit[R200_MAX_TEXTURE_UNITS];
+};
+
+struct r200_state_atom {
+ struct r200_state_atom *next, *prev;
+ const char *name; /* for debug */
+ int cmd_size; /* size in bytes */
+ GLuint idx;
+ int *cmd; /* one or more cmd's */
+ int *lastcmd; /* one or more cmd's */
+ int *savedcmd; /* one or more cmd's */
+ GLboolean dirty;
+ GLboolean(*check) (GLcontext *, int); /* is this state active? */
+};
+
+/* Trying to keep these relatively short as the variables are becoming
+ * extravagently long. Drop the driver name prefix off the front of
+ * everything - I think we know which driver we're in by now, and keep the
+ * prefix to 3 letters unless absolutely impossible.
+ */
+
+#define CTX_CMD_0 0
+#define CTX_PP_MISC 1
+#define CTX_PP_FOG_COLOR 2
+#define CTX_RE_SOLID_COLOR 3
+#define CTX_RB3D_BLENDCNTL 4
+#define CTX_RB3D_DEPTHOFFSET 5
+#define CTX_RB3D_DEPTHPITCH 6
+#define CTX_RB3D_ZSTENCILCNTL 7
+#define CTX_CMD_1 8
+#define CTX_PP_CNTL 9
+#define CTX_RB3D_CNTL 10
+#define CTX_RB3D_COLOROFFSET 11
+#define CTX_CMD_2 12 /* why */
+#define CTX_RB3D_COLORPITCH 13 /* why */
+#define CTX_STATE_SIZE_OLDDRM 14
+#define CTX_CMD_3 14
+#define CTX_RB3D_BLENDCOLOR 15
+#define CTX_RB3D_ABLENDCNTL 16
+#define CTX_RB3D_CBLENDCNTL 17
+#define CTX_STATE_SIZE_NEWDRM 18
+
+#define SET_CMD_0 0
+#define SET_SE_CNTL 1
+#define SET_RE_CNTL 2 /* replace se_coord_fmt */
+#define SET_STATE_SIZE 3
+
+#define VTE_CMD_0 0
+#define VTE_SE_VTE_CNTL 1
+#define VTE_STATE_SIZE 2
+
+#define LIN_CMD_0 0
+#define LIN_RE_LINE_PATTERN 1
+#define LIN_RE_LINE_STATE 2
+#define LIN_CMD_1 3
+#define LIN_SE_LINE_WIDTH 4
+#define LIN_STATE_SIZE 5
+
+#define MSK_CMD_0 0
+#define MSK_RB3D_STENCILREFMASK 1
+#define MSK_RB3D_ROPCNTL 2
+#define MSK_RB3D_PLANEMASK 3
+#define MSK_STATE_SIZE 4
+
+#define VPT_CMD_0 0
+#define VPT_SE_VPORT_XSCALE 1
+#define VPT_SE_VPORT_XOFFSET 2
+#define VPT_SE_VPORT_YSCALE 3
+#define VPT_SE_VPORT_YOFFSET 4
+#define VPT_SE_VPORT_ZSCALE 5
+#define VPT_SE_VPORT_ZOFFSET 6
+#define VPT_STATE_SIZE 7
+
+#define ZBS_CMD_0 0
+#define ZBS_SE_ZBIAS_FACTOR 1
+#define ZBS_SE_ZBIAS_CONSTANT 2
+#define ZBS_STATE_SIZE 3
+
+#define MSC_CMD_0 0
+#define MSC_RE_MISC 1
+#define MSC_STATE_SIZE 2
+
+#define TAM_CMD_0 0
+#define TAM_DEBUG3 1
+#define TAM_STATE_SIZE 2
+
+#define TEX_CMD_0 0
+#define TEX_PP_TXFILTER 1 /*2c00 */
+#define TEX_PP_TXFORMAT 2 /*2c04 */
+#define TEX_PP_TXFORMAT_X 3 /*2c08 */
+#define TEX_PP_TXSIZE 4 /*2c0c */
+#define TEX_PP_TXPITCH 5 /*2c10 */
+#define TEX_PP_BORDER_COLOR 6 /*2c14 */
+#define TEX_CMD_1 7
+#define TEX_PP_TXOFFSET 8 /*2d00 */
+#define TEX_STATE_SIZE 9
+
+#define CUBE_CMD_0 0 /* 1 register follows */
+#define CUBE_PP_CUBIC_FACES 1 /* 0x2c18 */
+#define CUBE_CMD_1 2 /* 5 registers follow */
+#define CUBE_PP_CUBIC_OFFSET_F1 3 /* 0x2d04 */
+#define CUBE_PP_CUBIC_OFFSET_F2 4 /* 0x2d08 */
+#define CUBE_PP_CUBIC_OFFSET_F3 5 /* 0x2d0c */
+#define CUBE_PP_CUBIC_OFFSET_F4 6 /* 0x2d10 */
+#define CUBE_PP_CUBIC_OFFSET_F5 7 /* 0x2d14 */
+#define CUBE_STATE_SIZE 8
+
+#define PIX_CMD_0 0
+#define PIX_PP_TXCBLEND 1
+#define PIX_PP_TXCBLEND2 2
+#define PIX_PP_TXABLEND 3
+#define PIX_PP_TXABLEND2 4
+#define PIX_STATE_SIZE 5
+
+#define TF_CMD_0 0
+#define TF_TFACTOR_0 1
+#define TF_TFACTOR_1 2
+#define TF_TFACTOR_2 3
+#define TF_TFACTOR_3 4
+#define TF_TFACTOR_4 5
+#define TF_TFACTOR_5 6
+#define TF_STATE_SIZE 7
+
+#define TCL_CMD_0 0
+#define TCL_LIGHT_MODEL_CTL_0 1
+#define TCL_LIGHT_MODEL_CTL_1 2
+#define TCL_PER_LIGHT_CTL_0 3
+#define TCL_PER_LIGHT_CTL_1 4
+#define TCL_PER_LIGHT_CTL_2 5
+#define TCL_PER_LIGHT_CTL_3 6
+#define TCL_CMD_1 7
+#define TCL_UCP_VERT_BLEND_CTL 8
+#define TCL_STATE_SIZE 9
+
+#define MSL_CMD_0 0
+#define MSL_MATRIX_SELECT_0 1
+#define MSL_MATRIX_SELECT_1 2
+#define MSL_MATRIX_SELECT_2 3
+#define MSL_MATRIX_SELECT_3 4
+#define MSL_MATRIX_SELECT_4 5
+#define MSL_STATE_SIZE 6
+
+#define TCG_CMD_0 0
+#define TCG_TEX_PROC_CTL_2 1
+#define TCG_TEX_PROC_CTL_3 2
+#define TCG_TEX_PROC_CTL_0 3
+#define TCG_TEX_PROC_CTL_1 4
+#define TCG_TEX_CYL_WRAP_CTL 5
+#define TCG_STATE_SIZE 6
+
+#define MTL_CMD_0 0
+#define MTL_EMMISSIVE_RED 1
+#define MTL_EMMISSIVE_GREEN 2
+#define MTL_EMMISSIVE_BLUE 3
+#define MTL_EMMISSIVE_ALPHA 4
+#define MTL_AMBIENT_RED 5
+#define MTL_AMBIENT_GREEN 6
+#define MTL_AMBIENT_BLUE 7
+#define MTL_AMBIENT_ALPHA 8
+#define MTL_DIFFUSE_RED 9
+#define MTL_DIFFUSE_GREEN 10
+#define MTL_DIFFUSE_BLUE 11
+#define MTL_DIFFUSE_ALPHA 12
+#define MTL_SPECULAR_RED 13
+#define MTL_SPECULAR_GREEN 14
+#define MTL_SPECULAR_BLUE 15
+#define MTL_SPECULAR_ALPHA 16
+#define MTL_CMD_1 17
+#define MTL_SHININESS 18
+#define MTL_STATE_SIZE 19
+
+#define VAP_CMD_0 0
+#define VAP_SE_VAP_CNTL 1
+#define VAP_STATE_SIZE 2
+
+/* Replaces a lot of packet info from radeon
+ */
+#define VTX_CMD_0 0
+#define VTX_VTXFMT_0 1
+#define VTX_VTXFMT_1 2
+#define VTX_TCL_OUTPUT_VTXFMT_0 3
+#define VTX_TCL_OUTPUT_VTXFMT_1 4
+#define VTX_CMD_1 5
+#define VTX_TCL_OUTPUT_COMPSEL 6
+#define VTX_CMD_2 7
+#define VTX_STATE_CNTL 8
+#define VTX_STATE_SIZE 9
+
+#define VTX_COLOR(v,n) (((v)>>(R200_VTX_COLOR_0_SHIFT+(n)*2))&\
+ R200_VTX_COLOR_MASK)
+
+/**
+ * Given the \c R200_SE_VTX_FMT_1 for the current vertex state, determine
+ * how many components are in texture coordinate \c n.
+ */
+#define VTX_TEXn_COUNT(v,n) (((v) >> (3 * n)) & 0x07)
+
+#define MAT_CMD_0 0
+#define MAT_ELT_0 1
+#define MAT_STATE_SIZE 17
+
+#define GRD_CMD_0 0
+#define GRD_VERT_GUARD_CLIP_ADJ 1
+#define GRD_VERT_GUARD_DISCARD_ADJ 2
+#define GRD_HORZ_GUARD_CLIP_ADJ 3
+#define GRD_HORZ_GUARD_DISCARD_ADJ 4
+#define GRD_STATE_SIZE 5
+
+/* position changes frequently when lighting in modelpos - separate
+ * out to new state item?
+ */
+#define LIT_CMD_0 0
+#define LIT_AMBIENT_RED 1
+#define LIT_AMBIENT_GREEN 2
+#define LIT_AMBIENT_BLUE 3
+#define LIT_AMBIENT_ALPHA 4
+#define LIT_DIFFUSE_RED 5
+#define LIT_DIFFUSE_GREEN 6
+#define LIT_DIFFUSE_BLUE 7
+#define LIT_DIFFUSE_ALPHA 8
+#define LIT_SPECULAR_RED 9
+#define LIT_SPECULAR_GREEN 10
+#define LIT_SPECULAR_BLUE 11
+#define LIT_SPECULAR_ALPHA 12
+#define LIT_POSITION_X 13
+#define LIT_POSITION_Y 14
+#define LIT_POSITION_Z 15
+#define LIT_POSITION_W 16
+#define LIT_DIRECTION_X 17
+#define LIT_DIRECTION_Y 18
+#define LIT_DIRECTION_Z 19
+#define LIT_DIRECTION_W 20
+#define LIT_ATTEN_QUADRATIC 21
+#define LIT_ATTEN_LINEAR 22
+#define LIT_ATTEN_CONST 23
+#define LIT_ATTEN_XXX 24
+#define LIT_CMD_1 25
+#define LIT_SPOT_DCD 26
+#define LIT_SPOT_DCM 27
+#define LIT_SPOT_EXPONENT 28
+#define LIT_SPOT_CUTOFF 29
+#define LIT_SPECULAR_THRESH 30
+#define LIT_RANGE_CUTOFF 31 /* ? */
+#define LIT_ATTEN_CONST_INV 32
+#define LIT_STATE_SIZE 33
+
+/* Fog
+ */
+#define FOG_CMD_0 0
+#define FOG_R 1
+#define FOG_C 2
+#define FOG_D 3
+#define FOG_PAD 4
+#define FOG_STATE_SIZE 5
+
+/* UCP
+ */
+#define UCP_CMD_0 0
+#define UCP_X 1
+#define UCP_Y 2
+#define UCP_Z 3
+#define UCP_W 4
+#define UCP_STATE_SIZE 5
+
+/* GLT - Global ambient
+ */
+#define GLT_CMD_0 0
+#define GLT_RED 1
+#define GLT_GREEN 2
+#define GLT_BLUE 3
+#define GLT_ALPHA 4
+#define GLT_STATE_SIZE 5
+
+/* EYE
+ */
+#define EYE_CMD_0 0
+#define EYE_X 1
+#define EYE_Y 2
+#define EYE_Z 3
+#define EYE_RESCALE_FACTOR 4
+#define EYE_STATE_SIZE 5
+
+/* CST - constant state
+ */
+#define CST_CMD_0 0
+#define CST_PP_CNTL_X 1
+#define CST_CMD_1 2
+#define CST_RB3D_DEPTHXY_OFFSET 3
+#define CST_CMD_2 4
+#define CST_RE_AUX_SCISSOR_CNTL 5
+#define CST_CMD_3 6
+#define CST_RE_SCISSOR_TL_0 7
+#define CST_RE_SCISSOR_BR_0 8
+#define CST_CMD_4 9
+#define CST_SE_VAP_CNTL_STATUS 10
+#define CST_CMD_5 11
+#define CST_RE_POINTSIZE 12
+#define CST_CMD_6 13
+#define CST_SE_TCL_INPUT_VTX_0 14
+#define CST_SE_TCL_INPUT_VTX_1 15
+#define CST_SE_TCL_INPUT_VTX_2 16
+#define CST_SE_TCL_INPUT_VTX_3 17
+#define CST_STATE_SIZE 18
+
+struct r200_hw_state {
+ /* Head of the linked list of state atoms. */
+ struct r200_state_atom atomlist;
+
+ /* Hardware state, stored as cmdbuf commands:
+ * -- Need to doublebuffer for
+ * - reviving state after loss of context
+ * - eliding noop statechange loops? (except line stipple count)
+ */
+ struct r200_state_atom ctx;
+ struct r200_state_atom set;
+ struct r200_state_atom vte;
+ struct r200_state_atom lin;
+ struct r200_state_atom msk;
+ struct r200_state_atom vpt;
+ struct r200_state_atom vap;
+ struct r200_state_atom vtx;
+ struct r200_state_atom tcl;
+ struct r200_state_atom msl;
+ struct r200_state_atom tcg;
+ struct r200_state_atom msc;
+ struct r200_state_atom cst;
+ struct r200_state_atom tam;
+ struct r200_state_atom tf;
+ struct r200_state_atom tex[6];
+ struct r200_state_atom cube[6];
+ struct r200_state_atom zbs;
+ struct r200_state_atom mtl[2];
+ struct r200_state_atom mat[9];
+ struct r200_state_atom lit[8]; /* includes vec, scl commands */
+ struct r200_state_atom ucp[6];
+ struct r200_state_atom pix[6]; /* pixshader stages */
+ struct r200_state_atom eye; /* eye pos */
+ struct r200_state_atom grd; /* guard band clipping */
+ struct r200_state_atom fog;
+ struct r200_state_atom glt;
+
+ int max_state_size; /* Number of bytes necessary for a full state emit. */
+ GLboolean is_dirty, all_dirty;
+};
+
+struct r200_colorbuffer_state {
+ int roundEnable;
+};
+
+struct r200_state {
+ /* Derived state for internal purposes:
+ */
+ struct r200_colorbuffer_state color;
+ struct r200_depthbuffer_state depth;
+ struct r200_stencilbuffer_state stencil;
+ struct r200_stipple_state stipple;
+ struct r200_texture_state texture;
+};
+
+/* Need refcounting on dma buffers:
+ */
+struct r200_dma_buffer {
+ int refcount; /* the number of retained regions in buf */
+ drmBufPtr buf;
+};
+
+#define GET_START(rvb) (rmesa->radeon.radeonScreen->gart_buffer_offset + \
+ (rvb)->address - rmesa->dma.buf0_address + \
+ (rvb)->start)
+
+/* A retained region, eg vertices for indexed vertices.
+ */
+struct r200_dma_region {
+ struct r200_dma_buffer *buf;
+ char *address; /* == buf->address */
+ int start, end, ptr; /* offsets from start of buf */
+ int aos_start;
+ int aos_stride;
+ int aos_size;
+};
+
+struct r200_dma {
+ /* Active dma region. Allocations for vertices and retained
+ * regions come from here. Also used for emitting random vertices,
+ * these may be flushed by calling flush_current();
+ */
+ struct r200_dma_region current;
+
+ void (*flush) (r200ContextPtr);
+
+ char *buf0_address; /* start of buf[0], for index calcs */
+ GLuint nr_released_bufs; /* flush after so many buffers released */
+};
+
+#define R200_CMD_BUF_SZ (8*1024)
+
+struct r200_store {
+ GLuint statenr;
+ GLuint primnr;
+ char cmd_buf[R200_CMD_BUF_SZ];
+ int cmd_used;
+ int elts_start;
+};
+
+/* r200_tcl.c
+ */
+struct r200_tcl_info {
+ GLuint vertex_format;
+ GLint last_offset;
+ GLuint hw_primitive;
+
+ struct r200_dma_region *aos_components[8];
+ GLuint nr_aos_components;
+
+ GLuint *Elts;
+
+ struct r200_dma_region indexed_verts;
+ struct r200_dma_region obj;
+ struct r200_dma_region rgba;
+ struct r200_dma_region spec;
+ struct r200_dma_region fog;
+ struct r200_dma_region tex[R200_MAX_TEXTURE_UNITS];
+ struct r200_dma_region norm;
+};
+
+/* r200_swtcl.c
+ */
+struct r200_swtcl_info {
+ GLuint RenderIndex;
+
+ /**
+ * Size of a hardware vertex. This is calculated when \c ::vertex_attrs is
+ * installed in the Mesa state vector.
+ */
+ GLuint vertex_size;
+
+ /**
+ * Attributes instructing the Mesa TCL pipeline where / how to put vertex
+ * data in the hardware buffer.
+ */
+ struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
+
+ /**
+ * Number of elements of \c ::vertex_attrs that are actually used.
+ */
+ GLuint vertex_attr_count;
+
+ /**
+ * Cached pointer to the buffer where Mesa will store vertex data.
+ */
+ GLubyte *verts;
+
+ /* Fallback rasterization functions
+ */
+ r200_point_func draw_point;
+ r200_line_func draw_line;
+ r200_tri_func draw_tri;
+
+ GLuint hw_primitive;
+ GLenum render_primitive;
+ GLuint numverts;
+
+ /**
+ * Offset of the 4UB color data within a hardware (swtcl) vertex.
+ */
+ GLuint coloroffset;
+
+ /**
+ * Offset of the 3UB specular color data within a hardware (swtcl) vertex.
+ */
+ GLuint specoffset;
+
+ /**
+ * Should Mesa project vertex data or will the hardware do it?
+ */
+ GLboolean needproj;
+
+ struct r200_dma_region indexed_verts;
+};
+
+struct r200_ioctl {
+ GLuint vertex_offset;
+ GLuint vertex_size;
+};
+
+#define R200_MAX_PRIMS 64
+
+/* Want to keep a cache of these around. Each is parameterized by
+ * only a single value which has only a small range. Only expect a
+ * few, so just rescan the list each time?
+ */
+struct dynfn {
+ struct dynfn *next, *prev;
+ int key[2];
+ char *code;
+};
+
+struct dfn_lists {
+ struct dynfn Vertex2f;
+ struct dynfn Vertex2fv;
+ struct dynfn Vertex3f;
+ struct dynfn Vertex3fv;
+ struct dynfn Color4ub;
+ struct dynfn Color4ubv;
+ struct dynfn Color3ub;
+ struct dynfn Color3ubv;
+ struct dynfn Color4f;
+ struct dynfn Color4fv;
+ struct dynfn Color3f;
+ struct dynfn Color3fv;
+ struct dynfn SecondaryColor3ubEXT;
+ struct dynfn SecondaryColor3ubvEXT;
+ struct dynfn SecondaryColor3fEXT;
+ struct dynfn SecondaryColor3fvEXT;
+ struct dynfn Normal3f;
+ struct dynfn Normal3fv;
+ struct dynfn TexCoord3f;
+ struct dynfn TexCoord3fv;
+ struct dynfn TexCoord2f;
+ struct dynfn TexCoord2fv;
+ struct dynfn TexCoord1f;
+ struct dynfn TexCoord1fv;
+ struct dynfn MultiTexCoord3fARB;
+ struct dynfn MultiTexCoord3fvARB;
+ struct dynfn MultiTexCoord2fARB;
+ struct dynfn MultiTexCoord2fvARB;
+ struct dynfn MultiTexCoord1fARB;
+ struct dynfn MultiTexCoord1fvARB;
+};
+
+struct dfn_generators {
+ struct dynfn *(*Vertex2f) (GLcontext *, const int *);
+ struct dynfn *(*Vertex2fv) (GLcontext *, const int *);
+ struct dynfn *(*Vertex3f) (GLcontext *, const int *);
+ struct dynfn *(*Vertex3fv) (GLcontext *, const int *);
+ struct dynfn *(*Color4ub) (GLcontext *, const int *);
+ struct dynfn *(*Color4ubv) (GLcontext *, const int *);
+ struct dynfn *(*Color3ub) (GLcontext *, const int *);
+ struct dynfn *(*Color3ubv) (GLcontext *, const int *);
+ struct dynfn *(*Color4f) (GLcontext *, const int *);
+ struct dynfn *(*Color4fv) (GLcontext *, const int *);
+ struct dynfn *(*Color3f) (GLcontext *, const int *);
+ struct dynfn *(*Color3fv) (GLcontext *, const int *);
+ struct dynfn *(*SecondaryColor3ubEXT) (GLcontext *, const int *);
+ struct dynfn *(*SecondaryColor3ubvEXT) (GLcontext *, const int *);
+ struct dynfn *(*SecondaryColor3fEXT) (GLcontext *, const int *);
+ struct dynfn *(*SecondaryColor3fvEXT) (GLcontext *, const int *);
+ struct dynfn *(*Normal3f) (GLcontext *, const int *);
+ struct dynfn *(*Normal3fv) (GLcontext *, const int *);
+ struct dynfn *(*TexCoord3f) (GLcontext *, const int *);
+ struct dynfn *(*TexCoord3fv) (GLcontext *, const int *);
+ struct dynfn *(*TexCoord2f) (GLcontext *, const int *);
+ struct dynfn *(*TexCoord2fv) (GLcontext *, const int *);
+ struct dynfn *(*TexCoord1f) (GLcontext *, const int *);
+ struct dynfn *(*TexCoord1fv) (GLcontext *, const int *);
+ struct dynfn *(*MultiTexCoord3fARB) (GLcontext *, const int *);
+ struct dynfn *(*MultiTexCoord3fvARB) (GLcontext *, const int *);
+ struct dynfn *(*MultiTexCoord2fARB) (GLcontext *, const int *);
+ struct dynfn *(*MultiTexCoord2fvARB) (GLcontext *, const int *);
+ struct dynfn *(*MultiTexCoord1fARB) (GLcontext *, const int *);
+ struct dynfn *(*MultiTexCoord1fvARB) (GLcontext *, const int *);
+};
+
+struct r200_prim {
+ GLuint start;
+ GLuint end;
+ GLuint prim;
+};
+
+ /* A maximum total of 29 elements per vertex: 3 floats for position, 3
+ * floats for normal, 4 floats for color, 4 bytes for secondary color,
+ * 3 floats for each texture unit (18 floats total).
+ *
+ * we maybe need add. 4 to prevent segfault if someone specifies
+ * GL_TEXTURE6/GL_TEXTURE7 (esp. for the codegen-path) (FIXME: )
+ *
+ * The position data is never actually stored here, so 3 elements could be
+ * trimmed out of the buffer.
+ */
+
+#define R200_MAX_VERTEX_SIZE ((3*6)+11)
+
+struct r200_vbinfo {
+ GLint counter, initial_counter;
+ GLint *dmaptr;
+ void (*notify) (void);
+ GLint vertex_size;
+
+ union {
+ float f;
+ int i;
+ r200_color_t color;
+ } vertex[R200_MAX_VERTEX_SIZE];
+
+ GLfloat *normalptr;
+ GLfloat *floatcolorptr;
+ r200_color_t *colorptr;
+ GLfloat *floatspecptr;
+ r200_color_t *specptr;
+ GLfloat *texcoordptr[8]; /* 6 (TMU) + 2 for r200_vtxfmt_c.c when GL_TEXTURE6/7 */
+
+ GLenum *prim; /* &ctx->Driver.CurrentExecPrimitive */
+ GLuint primflags;
+ GLboolean enabled; /* *_NO_VTXFMT / *_NO_TCL env vars */
+ GLboolean installed;
+ GLboolean fell_back;
+ GLboolean recheck;
+ GLint nrverts;
+ GLuint vtxfmt_0, vtxfmt_1;
+
+ GLuint installed_vertex_format;
+ GLuint installed_color_3f_sz;
+
+ struct r200_prim primlist[R200_MAX_PRIMS];
+ int nrprims;
+
+ struct dfn_lists dfn_cache;
+ struct dfn_generators codegen;
+ GLvertexformat vtxfmt;
+};
+
+/**
+ * R200 context structure.
+ */
+struct r200_context {
+ struct radeon_context radeon; /* parent class, must be first */
+
+ /* Driver and hardware state management
+ */
+ struct r200_hw_state hw;
+ struct r200_state state;
+
+ /* Texture object bookkeeping
+ */
+ unsigned nr_heaps;
+ driTexHeap *texture_heaps[R200_NR_TEX_HEAPS];
+ driTextureObject swapped;
+ int texture_depth;
+ float initialMaxAnisotropy;
+
+ /* Rasterization and vertex state:
+ */
+ GLuint NewGLState;
+
+ /* Vertex buffers
+ */
+ struct r200_ioctl ioctl;
+ struct r200_dma dma;
+ struct r200_store store;
+ GLboolean save_on_next_unlock;
+
+ /* Clientdata textures;
+ */
+ GLuint prefer_gart_client_texturing;
+
+ /* TCL stuff
+ */
+ GLmatrix TexGenMatrix[R200_MAX_TEXTURE_UNITS];
+ GLboolean recheck_texgen[R200_MAX_TEXTURE_UNITS];
+ GLboolean TexGenNeedNormals[R200_MAX_TEXTURE_UNITS];
+ GLuint TexMatEnabled;
+ GLuint TexMatCompSel;
+ GLuint TexGenEnabled;
+ GLuint TexGenInputs;
+ GLuint TexGenCompSel;
+ GLmatrix tmpmat;
+
+ /* r200_tcl.c
+ */
+ struct r200_tcl_info tcl;
+
+ /* r200_swtcl.c
+ */
+ struct r200_swtcl_info swtcl;
+
+ /* r200_vtxfmt.c
+ */
+ struct r200_vbinfo vb;
+};
+
+#define R200_CONTEXT(ctx) ((r200ContextPtr)(ctx->DriverCtx))
+
+extern void r200DestroyContext(__DRIcontextPrivate * driContextPriv);
+extern GLboolean r200CreateContext(const __GLcontextModes * glVisual,
+ __DRIcontextPrivate * driContextPriv,
+ void *sharedContextPrivate);
+
+#endif
+#endif /* __R200_CONTEXT_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_ioctl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_ioctl.h
new file mode 100644
index 000000000..db7bd7697
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_ioctl.h
@@ -0,0 +1,204 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R200_IOCTL_H__
+#define __R200_IOCTL_H__
+
+#include "simple_list.h"
+#include "radeon_dri.h"
+#include "radeon_lock.h"
+
+#include "xf86drm.h"
+#include "drm.h"
+#include "r200_context.h"
+#include "radeon_drm.h"
+
+extern void r200EmitState(r200ContextPtr rmesa);
+extern void r200EmitVertexAOS(r200ContextPtr rmesa,
+ GLuint vertex_size, GLuint offset);
+
+extern void r200EmitVbufPrim(r200ContextPtr rmesa,
+ GLuint primitive, GLuint vertex_nr);
+
+extern void r200FlushElts(r200ContextPtr rmesa);
+
+extern GLushort *r200AllocEltsOpenEnded(r200ContextPtr rmesa,
+ GLuint primitive, GLuint min_nr);
+
+extern void r200EmitAOS(r200ContextPtr rmesa,
+ struct r200_dma_region **regions,
+ GLuint n, GLuint offset);
+
+extern void r200EmitBlit(r200ContextPtr rmesa,
+ GLuint color_fmt,
+ GLuint src_pitch,
+ GLuint src_offset,
+ GLuint dst_pitch,
+ GLuint dst_offset,
+ GLint srcx, GLint srcy,
+ GLint dstx, GLint dsty, GLuint w, GLuint h);
+
+extern void r200EmitWait(r200ContextPtr rmesa, GLuint flags);
+
+extern void r200FlushCmdBuf(r200ContextPtr rmesa, const char *);
+extern int r200FlushCmdBufLocked(r200ContextPtr rmesa, const char *caller);
+extern void r200Flush(GLcontext * ctx);
+
+extern void r200RefillCurrentDmaRegion(r200ContextPtr rmesa);
+
+extern void r200AllocDmaRegion(r200ContextPtr rmesa,
+ struct r200_dma_region *region,
+ int bytes, int alignment);
+
+extern void r200AllocDmaRegionVerts(r200ContextPtr rmesa,
+ struct r200_dma_region *region,
+ int numverts, int vertsize, int alignment);
+
+extern void r200ReleaseDmaRegion(r200ContextPtr rmesa,
+ struct r200_dma_region *region,
+ const char *caller);
+
+extern void r200WaitForVBlank(r200ContextPtr rmesa);
+extern void r200InitIoctlFuncs(struct dd_function_table *functions);
+
+extern void *r200AllocateMemoryMESA(__DRInativeDisplay * dpy, int scrn,
+ GLsizei size, GLfloat readfreq,
+ GLfloat writefreq, GLfloat priority);
+extern void r200FreeMemoryMESA(__DRInativeDisplay * dpy, int scrn,
+ GLvoid * pointer);
+extern GLuint r200GetMemoryOffsetMESA(__DRInativeDisplay * dpy, int scrn,
+ const GLvoid * pointer);
+
+extern GLboolean r200IsGartMemory(r200ContextPtr rmesa, const GLvoid * pointer,
+ GLint size);
+
+extern GLuint r200GartOffsetFromVirtual(r200ContextPtr rmesa,
+ const GLvoid * pointer);
+
+void r200SaveHwState(r200ContextPtr radeon);
+void r200SetUpAtomList(r200ContextPtr rmesa);
+
+/* ================================================================
+ * Helper macros:
+ */
+
+/* Close off the last primitive, if it exists.
+ */
+#define R200_NEWPRIM( rmesa ) \
+do { \
+ if ( rmesa->dma.flush ) \
+ rmesa->dma.flush( rmesa ); \
+} while (0)
+
+/* Can accomodate several state changes and primitive changes without
+ * actually firing the buffer.
+ */
+#define R200_STATECHANGE( rmesa, ATOM ) \
+do { \
+ R200_NEWPRIM( rmesa ); \
+ rmesa->hw.ATOM.dirty = GL_TRUE; \
+ rmesa->hw.is_dirty = GL_TRUE; \
+} while (0)
+
+#define R200_DB_STATE( ATOM ) \
+ memcpy( rmesa->hw.ATOM.lastcmd, rmesa->hw.ATOM.cmd, \
+ rmesa->hw.ATOM.cmd_size * 4)
+
+static __inline int R200_DB_STATECHANGE(r200ContextPtr rmesa,
+ struct r200_state_atom *atom)
+{
+ if (memcmp(atom->cmd, atom->lastcmd, atom->cmd_size * 4)) {
+ int *tmp;
+ R200_NEWPRIM(rmesa);
+ atom->dirty = GL_TRUE;
+ rmesa->hw.is_dirty = GL_TRUE;
+ tmp = atom->cmd;
+ atom->cmd = atom->lastcmd;
+ atom->lastcmd = tmp;
+ return 1;
+ } else
+ return 0;
+}
+
+/* Fire the buffered vertices no matter what.
+ */
+#define R200_FIREVERTICES( r200 ) \
+do { \
+ if ( (r200)->store.cmd_used || (r200)->dma.flush ) { \
+ radeonFlush( (r200)->radeon.glCtx ); \
+ } \
+} while (0)
+
+/* Command lengths. Note that any time you ensure ELTS_BUFSZ or VBUF_BUFSZ
+ * are available, you will also be adding an rmesa->state.max_state_size because
+ * r200EmitState is called from within r200EmitVbufPrim and r200FlushElts.
+ */
+#define AOS_BUFSZ(nr) ((3 + ((nr / 2) * 3) + ((nr & 1) * 2)) * sizeof(int))
+#define VERT_AOS_BUFSZ (5 * sizeof(int))
+#define ELTS_BUFSZ(nr) (12 + nr * 2)
+#define VBUF_BUFSZ (3 * sizeof(int))
+
+/* Ensure that a minimum amount of space is available in the command buffer.
+ * This is used to ensure atomicity of state updates with the rendering requests
+ * that rely on them.
+ *
+ * An alternative would be to implement a "soft lock" such that when the buffer
+ * wraps at an inopportune time, we grab the lock, flush the current buffer,
+ * and hang on to the lock until the critical section is finished and we flush
+ * the buffer again and unlock.
+ */
+static __inline void r200EnsureCmdBufSpace(r200ContextPtr rmesa, int bytes)
+{
+ if (rmesa->store.cmd_used + bytes > R200_CMD_BUF_SZ)
+ r200FlushCmdBuf(rmesa, __FUNCTION__);
+ assert(bytes <= R200_CMD_BUF_SZ);
+}
+
+/* Alloc space in the command buffer
+ */
+static __inline char *r200AllocCmdBuf(r200ContextPtr rmesa,
+ int bytes, const char *where)
+{
+ char *head;
+
+ if (rmesa->store.cmd_used + bytes > R200_CMD_BUF_SZ)
+ r200FlushCmdBuf(rmesa, where);
+
+ head = rmesa->store.cmd_buf + rmesa->store.cmd_used;
+ rmesa->store.cmd_used += bytes;
+ assert(rmesa->store.cmd_used <= R200_CMD_BUF_SZ);
+ return head;
+}
+
+#endif /* __R200_IOCTL_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_reg.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_reg.h
new file mode 100644
index 000000000..1336e961a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_reg.h
@@ -0,0 +1,1423 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_reg.h,v 1.2 2002/12/16 16:18:54 dawes Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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.
+*/
+
+#ifndef _R200_REG_H_
+#define _R200_REG_H_
+
+#define R200_PP_MISC 0x1c14
+#define R200_REF_ALPHA_MASK 0x000000ff
+#define R200_ALPHA_TEST_FAIL (0 << 8)
+#define R200_ALPHA_TEST_LESS (1 << 8)
+#define R200_ALPHA_TEST_LEQUAL (2 << 8)
+#define R200_ALPHA_TEST_EQUAL (3 << 8)
+#define R200_ALPHA_TEST_GEQUAL (4 << 8)
+#define R200_ALPHA_TEST_GREATER (5 << 8)
+#define R200_ALPHA_TEST_NEQUAL (6 << 8)
+#define R200_ALPHA_TEST_PASS (7 << 8)
+#define R200_ALPHA_TEST_OP_MASK (7 << 8)
+#define R200_CHROMA_FUNC_FAIL (0 << 16)
+#define R200_CHROMA_FUNC_PASS (1 << 16)
+#define R200_CHROMA_FUNC_NEQUAL (2 << 16)
+#define R200_CHROMA_FUNC_EQUAL (3 << 16)
+#define R200_CHROMA_KEY_NEAREST (0 << 18)
+#define R200_CHROMA_KEY_ZERO (1 << 18)
+#define R200_RIGHT_HAND_CUBE_D3D (0 << 24)
+#define R200_RIGHT_HAND_CUBE_OGL (1 << 24)
+#define R200_PP_FOG_COLOR 0x1c18
+#define R200_FOG_COLOR_MASK 0x00ffffff
+#define R200_FOG_VERTEX (0 << 24)
+#define R200_FOG_TABLE (1 << 24)
+#define R200_FOG_USE_DEPTH (0 << 25)
+#define R200_FOG_USE_W (1 << 25)
+#define R200_FOG_USE_DIFFUSE_ALPHA (2 << 25)
+#define R200_FOG_USE_SPEC_ALPHA (3 << 25)
+#define R200_FOG_USE_VTX_FOG (4 << 25)
+#define R200_FOG_USE_MASK (7 << 25)
+#define R200_RE_SOLID_COLOR 0x1c1c
+#define R200_RB3D_BLENDCNTL 0x1c20
+#define R200_COMB_FCN_MASK (7 << 12)
+#define R200_COMB_FCN_ADD_CLAMP (0 << 12)
+#define R200_COMB_FCN_ADD_NOCLAMP (1 << 12)
+#define R200_COMB_FCN_SUB_CLAMP (2 << 12)
+#define R200_COMB_FCN_SUB_NOCLAMP (3 << 12)
+#define R200_COMB_FCN_MIN (4 << 12)
+#define R200_COMB_FCN_MAX (5 << 12)
+#define R200_COMB_FCN_RSUB_CLAMP (6 << 12)
+#define R200_COMB_FCN_RSUB_NOCLAMP (7 << 12)
+#define R200_BLEND_GL_ZERO (32)
+#define R200_BLEND_GL_ONE (33)
+#define R200_BLEND_GL_SRC_COLOR (34)
+#define R200_BLEND_GL_ONE_MINUS_SRC_COLOR (35)
+#define R200_BLEND_GL_DST_COLOR (36)
+#define R200_BLEND_GL_ONE_MINUS_DST_COLOR (37)
+#define R200_BLEND_GL_SRC_ALPHA (38)
+#define R200_BLEND_GL_ONE_MINUS_SRC_ALPHA (39)
+#define R200_BLEND_GL_DST_ALPHA (40)
+#define R200_BLEND_GL_ONE_MINUS_DST_ALPHA (41)
+#define R200_BLEND_GL_SRC_ALPHA_SATURATE (42) /* src factor only */
+#define R200_BLEND_GL_CONST_COLOR (43)
+#define R200_BLEND_GL_ONE_MINUS_CONST_COLOR (44)
+#define R200_BLEND_GL_CONST_ALPHA (45)
+#define R200_BLEND_GL_ONE_MINUS_CONST_ALPHA (46)
+#define R200_BLEND_MASK (63)
+#define R200_SRC_BLEND_SHIFT (16)
+#define R200_DST_BLEND_SHIFT (24)
+#define R200_RB3D_DEPTHOFFSET 0x1c24
+#define R200_RB3D_DEPTHPITCH 0x1c28
+#define R200_DEPTHPITCH_MASK 0x00001ff8
+#define R200_DEPTH_ENDIAN_NO_SWAP (0 << 18)
+#define R200_DEPTH_ENDIAN_WORD_SWAP (1 << 18)
+#define R200_DEPTH_ENDIAN_DWORD_SWAP (2 << 18)
+#define R200_RB3D_ZSTENCILCNTL 0x1c2c
+#define R200_DEPTH_FORMAT_MASK (0xf << 0)
+#define R200_DEPTH_FORMAT_16BIT_INT_Z (0 << 0)
+#define R200_DEPTH_FORMAT_24BIT_INT_Z (2 << 0)
+#define R200_DEPTH_FORMAT_24BIT_FLOAT_Z (3 << 0)
+#define R200_DEPTH_FORMAT_32BIT_INT_Z (4 << 0)
+#define R200_DEPTH_FORMAT_32BIT_FLOAT_Z (5 << 0)
+#define R200_DEPTH_FORMAT_24BIT_FLOAT_W (9 << 0)
+#define R200_DEPTH_FORMAT_32BIT_FLOAT_W (11 << 0)
+#define R200_Z_TEST_NEVER (0 << 4)
+#define R200_Z_TEST_LESS (1 << 4)
+#define R200_Z_TEST_LEQUAL (2 << 4)
+#define R200_Z_TEST_EQUAL (3 << 4)
+#define R200_Z_TEST_GEQUAL (4 << 4)
+#define R200_Z_TEST_GREATER (5 << 4)
+#define R200_Z_TEST_NEQUAL (6 << 4)
+#define R200_Z_TEST_ALWAYS (7 << 4)
+#define R200_Z_TEST_MASK (7 << 4)
+#define R200_STENCIL_TEST_NEVER (0 << 12)
+#define R200_STENCIL_TEST_LESS (1 << 12)
+#define R200_STENCIL_TEST_LEQUAL (2 << 12)
+#define R200_STENCIL_TEST_EQUAL (3 << 12)
+#define R200_STENCIL_TEST_GEQUAL (4 << 12)
+#define R200_STENCIL_TEST_GREATER (5 << 12)
+#define R200_STENCIL_TEST_NEQUAL (6 << 12)
+#define R200_STENCIL_TEST_ALWAYS (7 << 12)
+#define R200_STENCIL_TEST_MASK (0x7 << 12)
+#define R200_STENCIL_FAIL_KEEP (0 << 16)
+#define R200_STENCIL_FAIL_ZERO (1 << 16)
+#define R200_STENCIL_FAIL_REPLACE (2 << 16)
+#define R200_STENCIL_FAIL_INC (3 << 16)
+#define R200_STENCIL_FAIL_DEC (4 << 16)
+#define R200_STENCIL_FAIL_INVERT (5 << 16)
+#define R200_STENCIL_FAIL_INC_WRAP (6 << 16)
+#define R200_STENCIL_FAIL_DEC_WRAP (7 << 16)
+#define R200_STENCIL_FAIL_MASK (0x7 << 16)
+#define R200_STENCIL_ZPASS_KEEP (0 << 20)
+#define R200_STENCIL_ZPASS_ZERO (1 << 20)
+#define R200_STENCIL_ZPASS_REPLACE (2 << 20)
+#define R200_STENCIL_ZPASS_INC (3 << 20)
+#define R200_STENCIL_ZPASS_DEC (4 << 20)
+#define R200_STENCIL_ZPASS_INVERT (5 << 20)
+#define R200_STENCIL_ZPASS_INC_WRAP (6 << 20)
+#define R200_STENCIL_ZPASS_DEC_WRAP (7 << 20)
+#define R200_STENCIL_ZPASS_MASK (0x7 << 20)
+#define R200_STENCIL_ZFAIL_KEEP (0 << 24)
+#define R200_STENCIL_ZFAIL_ZERO (1 << 24)
+#define R200_STENCIL_ZFAIL_REPLACE (2 << 24)
+#define R200_STENCIL_ZFAIL_INC (3 << 24)
+#define R200_STENCIL_ZFAIL_DEC (4 << 24)
+#define R200_STENCIL_ZFAIL_INVERT (5 << 24)
+#define R200_STENCIL_ZFAIL_INC_WRAP (6 << 24)
+#define R200_STENCIL_ZFAIL_DEC_WRAP (7 << 24)
+#define R200_STENCIL_ZFAIL_MASK (0x7 << 24)
+#define R200_Z_WRITE_ENABLE (1 << 30)
+/*gap*/
+#define R200_PP_CNTL 0x1c38
+#define R200_TEX_0_ENABLE 0x00000010
+#define R200_TEX_1_ENABLE 0x00000020
+#define R200_TEX_2_ENABLE 0x00000040
+#define R200_TEX_3_ENABLE 0x00000080
+#define R200_TEX_4_ENABLE 0x00000100
+#define R200_TEX_5_ENABLE 0x00000200
+#define R200_TEX_ENABLE_MASK 0x000003f0
+#define R200_FILTER_ROUND_MODE_MASK 0x00000400
+#define R200_TEX_BLEND_7_ENABLE 0x00000800
+#define R200_TEX_BLEND_0_ENABLE 0x00001000
+#define R200_TEX_BLEND_1_ENABLE 0x00002000
+#define R200_TEX_BLEND_2_ENABLE 0x00004000
+#define R200_TEX_BLEND_3_ENABLE 0x00008000
+#define R200_TEX_BLEND_4_ENABLE 0x00010000
+#define R200_TEX_BLEND_5_ENABLE 0x00020000
+#define R200_TEX_BLEND_6_ENABLE 0x00040000
+#define R200_MULTI_PASS_ENABLE 0x00080000
+#define R200_SPECULAR_ENABLE 0x00200000
+#define R200_FOG_ENABLE 0x00400000
+#define R200_ALPHA_TEST_ENABLE 0x00800000
+#define R200_ANTI_ALIAS_NONE 0x00000000
+#define R200_ANTI_ALIAS_LINE 0x01000000
+#define R200_ANTI_ALIAS_POLY 0x02000000
+#define R200_ANTI_ALIAS_MASK 0x03000000
+#define R200_RB3D_CNTL 0x1c3c
+#define R200_ALPHA_BLEND_ENABLE (1 << 0)
+#define R200_PLANE_MASK_ENABLE (1 << 1)
+#define R200_DITHER_ENABLE (1 << 2)
+#define R200_ROUND_ENABLE (1 << 3)
+#define R200_SCALE_DITHER_ENABLE (1 << 4)
+#define R200_DITHER_INIT (1 << 5)
+#define R200_ROP_ENABLE (1 << 6)
+#define R200_STENCIL_ENABLE (1 << 7)
+#define R200_Z_ENABLE (1 << 8)
+#define R200_DEPTH_XZ_OFFEST_ENABLE (1 << 9)
+#define R200_COLOR_FORMAT_ARGB1555 (3 << 10)
+#define R200_COLOR_FORMAT_RGB565 (4 << 10)
+#define R200_COLOR_FORMAT_ARGB8888 (6 << 10)
+#define R200_COLOR_FORMAT_RGB332 (7 << 10)
+#define R200_COLOR_FORMAT_Y8 (8 << 10)
+#define R200_COLOR_FORMAT_RGB8 (9 << 10)
+#define R200_COLOR_FORMAT_YUV422_VYUY (11 << 10)
+#define R200_COLOR_FORMAT_YUV422_YVYU (12 << 10)
+#define R200_COLOR_FORMAT_aYUV444 (14 << 10)
+#define R200_COLOR_FORMAT_ARGB4444 (15 << 10)
+#define R200_CLRCMP_FLIP_ENABLE (1 << 14)
+#define R200_SEPARATE_ALPHA_ENABLE (1 << 16)
+#define R200_RB3D_COLOROFFSET 0x1c40
+#define R200_COLOROFFSET_MASK 0xfffffff0
+#define R200_RE_WIDTH_HEIGHT 0x1c44
+#define R200_RE_WIDTH_SHIFT 0
+#define R200_RE_HEIGHT_SHIFT 16
+#define R200_RB3D_COLORPITCH 0x1c48
+#define R200_COLORPITCH_MASK 0x000001ff8
+#define R200_COLOR_ENDIAN_NO_SWAP (0 << 18)
+#define R200_COLOR_ENDIAN_WORD_SWAP (1 << 18)
+#define R200_COLOR_ENDIAN_DWORD_SWAP (2 << 18)
+#define R200_SE_CNTL 0x1c4c
+#define R200_FFACE_CULL_CW (0 << 0)
+#define R200_FFACE_CULL_CCW (1 << 0)
+#define R200_FFACE_CULL_DIR_MASK (1 << 0)
+#define R200_BFACE_CULL (0 << 1)
+#define R200_BFACE_SOLID (3 << 1)
+#define R200_FFACE_CULL (0 << 3)
+#define R200_FFACE_SOLID (3 << 3)
+#define R200_FFACE_CULL_MASK (3 << 3)
+#define R200_FLAT_SHADE_VTX_0 (0 << 6)
+#define R200_FLAT_SHADE_VTX_1 (1 << 6)
+#define R200_FLAT_SHADE_VTX_2 (2 << 6)
+#define R200_FLAT_SHADE_VTX_LAST (3 << 6)
+#define R200_DIFFUSE_SHADE_SOLID (0 << 8)
+#define R200_DIFFUSE_SHADE_FLAT (1 << 8)
+#define R200_DIFFUSE_SHADE_GOURAUD (2 << 8)
+#define R200_DIFFUSE_SHADE_MASK (3 << 8)
+#define R200_ALPHA_SHADE_SOLID (0 << 10)
+#define R200_ALPHA_SHADE_FLAT (1 << 10)
+#define R200_ALPHA_SHADE_GOURAUD (2 << 10)
+#define R200_ALPHA_SHADE_MASK (3 << 10)
+#define R200_SPECULAR_SHADE_SOLID (0 << 12)
+#define R200_SPECULAR_SHADE_FLAT (1 << 12)
+#define R200_SPECULAR_SHADE_GOURAUD (2 << 12)
+#define R200_SPECULAR_SHADE_MASK (3 << 12)
+#define R200_FOG_SHADE_SOLID (0 << 14)
+#define R200_FOG_SHADE_FLAT (1 << 14)
+#define R200_FOG_SHADE_GOURAUD (2 << 14)
+#define R200_FOG_SHADE_MASK (3 << 14)
+#define R200_ZBIAS_ENABLE_POINT (1 << 16)
+#define R200_ZBIAS_ENABLE_LINE (1 << 17)
+#define R200_ZBIAS_ENABLE_TRI (1 << 18)
+#define R200_WIDELINE_ENABLE (1 << 20)
+#define R200_VTX_PIX_CENTER_D3D (0 << 27)
+#define R200_VTX_PIX_CENTER_OGL (1 << 27)
+#define R200_ROUND_MODE_TRUNC (0 << 28)
+#define R200_ROUND_MODE_ROUND (1 << 28)
+#define R200_ROUND_MODE_ROUND_EVEN (2 << 28)
+#define R200_ROUND_MODE_ROUND_ODD (3 << 28)
+#define R200_ROUND_PREC_16TH_PIX (0 << 30)
+#define R200_ROUND_PREC_8TH_PIX (1 << 30)
+#define R200_ROUND_PREC_4TH_PIX (2 << 30)
+#define R200_ROUND_PREC_HALF_PIX (3 << 30)
+#define R200_RE_CNTL 0x1c50
+#define R200_STIPPLE_ENABLE 0x1
+#define R200_SCISSOR_ENABLE 0x2
+#define R200_PATTERN_ENABLE 0x4
+#define R200_PERSPECTIVE_ENABLE 0x8
+#define R200_POINT_SMOOTH 0x20
+#define R200_VTX_STQ0_D3D 0x00010000
+#define R200_VTX_STQ1_D3D 0x00040000
+#define R200_VTX_STQ2_D3D 0x00100000
+#define R200_VTX_STQ3_D3D 0x00400000
+#define R200_VTX_STQ4_D3D 0x01000000
+#define R200_VTX_STQ5_D3D 0x04000000
+/* gap */
+#define R200_RE_STIPPLE_ADDR 0x1cc8
+#define R200_RE_STIPPLE_DATA 0x1ccc
+#define R200_RE_LINE_PATTERN 0x1cd0
+#define R200_LINE_PATTERN_MASK 0x0000ffff
+#define R200_LINE_REPEAT_COUNT_SHIFT 16
+#define R200_LINE_PATTERN_START_SHIFT 24
+#define R200_LINE_PATTERN_LITTLE_BIT_ORDER (0 << 28)
+#define R200_LINE_PATTERN_BIG_BIT_ORDER (1 << 28)
+#define R200_LINE_PATTERN_AUTO_RESET (1 << 29)
+#define R200_RE_LINE_STATE 0x1cd4
+#define R200_LINE_CURRENT_PTR_SHIFT 0
+#define R200_LINE_CURRENT_COUNT_SHIFT 8
+#define R200_RE_SCISSOR_TL_0 0x1cd8
+#define R200_RE_SCISSOR_BR_0 0x1cdc
+#define R200_RE_SCISSOR_TL_1 0x1ce0
+#define R200_RE_SCISSOR_BR_1 0x1ce4
+#define R200_RE_SCISSOR_TL_2 0x1ce8
+#define R200_RE_SCISSOR_BR_2 0x1cec
+/* gap */
+#define R200_RB3D_DEPTHXY_OFFSET 0x1d60
+#define R200_DEPTHX_SHIFT 0
+#define R200_DEPTHY_SHIFT 16
+/* gap */
+#define R200_RB3D_STENCILREFMASK 0x1d7c
+#define R200_STENCIL_REF_SHIFT 0
+#define R200_STENCIL_REF_MASK (0xff << 0)
+#define R200_STENCIL_MASK_SHIFT 16
+#define R200_STENCIL_VALUE_MASK (0xff << 16)
+#define R200_STENCIL_WRITEMASK_SHIFT 24
+#define R200_STENCIL_WRITE_MASK (0xff << 24)
+#define R200_RB3D_ROPCNTL 0x1d80
+#define R200_ROP_MASK (15 << 8)
+#define R200_ROP_CLEAR (0 << 8)
+#define R200_ROP_NOR (1 << 8)
+#define R200_ROP_AND_INVERTED (2 << 8)
+#define R200_ROP_COPY_INVERTED (3 << 8)
+#define R200_ROP_AND_REVERSE (4 << 8)
+#define R200_ROP_INVERT (5 << 8)
+#define R200_ROP_XOR (6 << 8)
+#define R200_ROP_NAND (7 << 8)
+#define R200_ROP_AND (8 << 8)
+#define R200_ROP_EQUIV (9 << 8)
+#define R200_ROP_NOOP (10 << 8)
+#define R200_ROP_OR_INVERTED (11 << 8)
+#define R200_ROP_COPY (12 << 8)
+#define R200_ROP_OR_REVERSE (13 << 8)
+#define R200_ROP_OR (14 << 8)
+#define R200_ROP_SET (15 << 8)
+#define R200_RB3D_PLANEMASK 0x1d84
+/* gap */
+#define R200_SE_VPORT_XSCALE 0x1d98
+#define R200_SE_VPORT_XOFFSET 0x1d9c
+#define R200_SE_VPORT_YSCALE 0x1da0
+#define R200_SE_VPORT_YOFFSET 0x1da4
+#define R200_SE_VPORT_ZSCALE 0x1da8
+#define R200_SE_VPORT_ZOFFSET 0x1dac
+#define R200_SE_ZBIAS_FACTOR 0x1db0
+#define R200_SE_ZBIAS_CONSTANT 0x1db4
+#define R200_SE_LINE_WIDTH 0x1db8
+#define R200_LINE_WIDTH_SHIFT 0x00000000
+#define R200_MINPOINTSIZE_SHIFT 0x00000010
+/* gap */
+#define R200_SE_VAP_CNTL 0x2080
+#define R200_VAP_TCL_ENABLE 0x00000001
+#define R200_VAP_SINGLE_BUF_STATE_ENABLE 0x00000010
+#define R200_VAP_FORCE_W_TO_ONE 0x00010000
+#define R200_VAP_D3D_TEX_DEFAULT 0x00020000
+#define R200_VAP_VF_MAX_VTX_NUM__SHIFT 18
+#define R200_VAP_DX_CLIP_SPACE_DEF 0x00400000
+#define R200_SE_VF_CNTL 0x2084
+#define R200_VF_PRIM_NONE 0x00000000
+#define R200_VF_PRIM_POINTS 0x00000001
+#define R200_VF_PRIM_LINES 0x00000002
+#define R200_VF_PRIM_LINE_STRIP 0x00000003
+#define R200_VF_PRIM_TRIANGLES 0x00000004
+#define R200_VF_PRIM_TRIANGLE_FAN 0x00000005
+#define R200_VF_PRIM_TRIANGLE_STRIP 0x00000006
+#define R200_VF_PRIM_RECT_LIST 0x00000008
+#define R200_VF_PRIM_3VRT_POINTS 0x00000009
+#define R200_VF_PRIM_3VRT_LINES 0x0000000a
+#define R200_VF_PRIM_POINT_SPRITES 0x0000000b
+#define R200_VF_PRIM_LINE_LOOP 0x0000000c
+#define R200_VF_PRIM_QUADS 0x0000000d
+#define R200_VF_PRIM_QUAD_STRIP 0x0000000e
+#define R200_VF_PRIM_POLYGON 0x0000000f
+#define R200_VF_PRIM_MASK 0x0000000f
+#define R200_VF_PRIM_WALK_IND 0x00000010
+#define R200_VF_PRIM_WALK_LIST 0x00000020
+#define R200_VF_PRIM_WALK_RING 0x00000030
+#define R200_VF_PRIM_WALK_MASK 0x00000030
+#define R200_VF_COLOR_ORDER_RGBA 0x00000040
+#define R200_VF_TCL_OUTPUT_VTX_ENABLE 0x00000200
+#define R200_VF_INDEX_SZ_4 0x00000800
+#define R200_VF_VERTEX_NUMBER_MASK 0xffff0000
+#define R200_VF_VERTEX_NUMBER_SHIFT 16
+#define R200_SE_VTX_FMT_0 0x2088
+#define R200_VTX_XY 0 /* always have xy */
+#define R200_VTX_Z0 (1<<0)
+#define R200_VTX_W0 (1<<1)
+#define R200_VTX_WEIGHT_COUNT_SHIFT (2)
+#define R200_VTX_PV_MATRIX_SEL (1<<5)
+#define R200_VTX_N0 (1<<6)
+#define R200_VTX_POINT_SIZE (1<<7)
+#define R200_VTX_DISCRETE_FOG (1<<8)
+#define R200_VTX_SHININESS_0 (1<<9)
+#define R200_VTX_SHININESS_1 (1<<10)
+#define R200_VTX_COLOR_NOT_PRESENT 0
+#define R200_VTX_PK_RGBA 1
+#define R200_VTX_FP_RGB 2
+#define R200_VTX_FP_RGBA 3
+#define R200_VTX_COLOR_MASK 3
+#define R200_VTX_COLOR_0_SHIFT 11
+#define R200_VTX_COLOR_1_SHIFT 13
+#define R200_VTX_COLOR_2_SHIFT 15
+#define R200_VTX_COLOR_3_SHIFT 17
+#define R200_VTX_COLOR_4_SHIFT 19
+#define R200_VTX_COLOR_5_SHIFT 21
+#define R200_VTX_COLOR_6_SHIFT 23
+#define R200_VTX_COLOR_7_SHIFT 25
+#define R200_VTX_XY1 (1<<28)
+#define R200_VTX_Z1 (1<<29)
+#define R200_VTX_W1 (1<<30)
+#define R200_VTX_N1 (1<<31)
+#define R200_SE_VTX_FMT_1 0x208c
+#define R200_VTX_TEX0_COMP_CNT_SHIFT 0
+#define R200_VTX_TEX1_COMP_CNT_SHIFT 3
+#define R200_VTX_TEX2_COMP_CNT_SHIFT 6
+#define R200_VTX_TEX3_COMP_CNT_SHIFT 9
+#define R200_VTX_TEX4_COMP_CNT_SHIFT 12
+#define R200_VTX_TEX5_COMP_CNT_SHIFT 15
+#define R200_SE_TCL_OUTPUT_VTX_FMT_0 0x2090
+#define R200_SE_TCL_OUTPUT_VTX_FMT_1 0x2094
+/* gap */
+#define R200_SE_VTE_CNTL 0x20b0
+#define R200_VPORT_X_SCALE_ENA 0x00000001
+#define R200_VPORT_X_OFFSET_ENA 0x00000002
+#define R200_VPORT_Y_SCALE_ENA 0x00000004
+#define R200_VPORT_Y_OFFSET_ENA 0x00000008
+#define R200_VPORT_Z_SCALE_ENA 0x00000010
+#define R200_VPORT_Z_OFFSET_ENA 0x00000020
+#define R200_VTX_XY_FMT 0x00000100
+#define R200_VTX_Z_FMT 0x00000200
+#define R200_VTX_W0_FMT 0x00000400
+#define R200_VTX_W0_NORMALIZE 0x00000800
+#define R200_VTX_ST_DENORMALIZED 0x00001000
+/* gap */
+#define R200_SE_VTX_NUM_ARRAYS 0x20c0
+#define R200_SE_VTX_AOS_ATTR01 0x20c4
+#define R200_SE_VTX_AOS_ADDR0 0x20c8
+#define R200_SE_VTX_AOS_ADDR1 0x20cc
+#define R200_SE_VTX_AOS_ATTR23 0x20d0
+#define R200_SE_VTX_AOS_ADDR2 0x20d4
+#define R200_SE_VTX_AOS_ADDR3 0x20d8
+#define R200_SE_VTX_AOS_ATTR45 0x20dc
+#define R200_SE_VTX_AOS_ADDR4 0x20e0
+#define R200_SE_VTX_AOS_ADDR5 0x20e4
+#define R200_SE_VTX_AOS_ATTR67 0x20e8
+#define R200_SE_VTX_AOS_ADDR6 0x20ec
+#define R200_SE_VTX_AOS_ADDR7 0x20f0
+#define R200_SE_VTX_AOS_ATTR89 0x20f4
+#define R200_SE_VTX_AOS_ADDR8 0x20f8
+#define R200_SE_VTX_AOS_ADDR9 0x20fc
+#define R200_SE_VTX_AOS_ATTR1011 0x2100
+#define R200_SE_VTX_AOS_ADDR10 0x2104
+#define R200_SE_VTX_AOS_ADDR11 0x2108
+#define R200_SE_VF_MAX_VTX_INDX 0x210c
+#define R200_SE_VF_MIN_VTX_INDX 0x2110
+/* gap */
+#define R200_SE_VAP_CNTL_STATUS 0x2140
+#define R200_VC_NO_SWAP (0 << 0)
+#define R200_VC_16BIT_SWAP (1 << 0)
+#define R200_VC_32BIT_SWAP (2 << 0)
+/* gap */
+#define R200_SE_VTX_STATE_CNTL 0x2180
+#define R200_VSC_COLOR_0_ASSEMBLY_CNTL_SHIFT 0x00000000
+#define R200_VSC_COLOR_1_ASSEMBLY_CNTL_SHIFT 0x00000002
+#define R200_VSC_COLOR_2_ASSEMBLY_CNTL_SHIFT 0x00000004
+#define R200_VSC_COLOR_3_ASSEMBLY_CNTL_SHIFT 0x00000006
+#define R200_VSC_COLOR_4_ASSEMBLY_CNTL_SHIFT 0x00000008
+#define R200_VSC_COLOR_5_ASSEMBLY_CNTL_SHIFT 0x0000000a
+#define R200_VSC_COLOR_6_ASSEMBLY_CNTL_SHIFT 0x0000000c
+#define R200_VSC_COLOR_7_ASSEMBLY_CNTL_SHIFT 0x0000000e
+#define R200_VSC_UPDATE_USER_COLOR_0_ENABLE 0x00010000
+#define R200_VSC_UPDATE_USER_COLOR_1_ENABLE 0x00020000
+/* gap */
+#define R200_SE_TCL_VECTOR_INDX_REG 0x2200
+#define R200_SE_TCL_VECTOR_DATA_REG 0x2204
+#define R200_SE_TCL_SCALAR_INDX_REG 0x2208
+#define R200_SE_TCL_SCALAR_DATA_REG 0x220c
+/* gap */
+#define R200_SE_TCL_MATRIX_SEL_0 0x2230
+#define R200_MODELVIEW_0_SHIFT (0)
+#define R200_MODELVIEW_1_SHIFT (8)
+#define R200_MODELVIEW_2_SHIFT (16)
+#define R200_MODELVIEW_3_SHIFT (24)
+#define R200_SE_TCL_MATRIX_SEL_1 0x2234
+#define R200_IT_MODELVIEW_0_SHIFT (0)
+#define R200_IT_MODELVIEW_1_SHIFT (8)
+#define R200_IT_MODELVIEW_2_SHIFT (16)
+#define R200_IT_MODELVIEW_3_SHIFT (24)
+#define R200_SE_TCL_MATRIX_SEL_2 0x2238
+#define R200_MODELPROJECT_0_SHIFT (0)
+#define R200_MODELPROJECT_1_SHIFT (8)
+#define R200_MODELPROJECT_2_SHIFT (16)
+#define R200_MODELPROJECT_3_SHIFT (24)
+#define R200_SE_TCL_MATRIX_SEL_3 0x223c
+#define R200_TEXMAT_0_SHIFT 0
+#define R200_TEXMAT_1_SHIFT 8
+#define R200_TEXMAT_2_SHIFT 16
+#define R200_TEXMAT_3_SHIFT 24
+#define R200_SE_TCL_MATRIX_SEL_4 0x2240
+#define R200_TEXMAT_4_SHIFT 0
+#define R200_TEXMAT_5_SHIFT 8
+/* gap */
+#define R200_SE_TCL_OUTPUT_VTX_COMP_SEL 0x2250
+#define R200_OUTPUT_XYZW (1<<0)
+#define R200_OUTPUT_COLOR_0 (1<<8)
+#define R200_OUTPUT_COLOR_1 (1<<9)
+#define R200_OUTPUT_TEX_0 (1<<16)
+#define R200_OUTPUT_TEX_1 (1<<17)
+#define R200_OUTPUT_TEX_2 (1<<18)
+#define R200_OUTPUT_TEX_3 (1<<19)
+#define R200_OUTPUT_TEX_4 (1<<20)
+#define R200_OUTPUT_TEX_5 (1<<21)
+#define R200_OUTPUT_TEX_MASK (0x3f<<16)
+#define R200_OUTPUT_DISCRETE_FOG (1<<24)
+#define R200_OUTPUT_PT_SIZE (1<<25)
+#define R200_FORCE_INORDER_PROC (1<<31)
+#define R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0 0x2254
+#define R200_VERTEX_POSITION_ADDR__SHIFT 0x00000000
+#define R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_1 0x2258
+#define R200_VTX_COLOR_0_ADDR__SHIFT 0x00000000
+#define R200_VTX_COLOR_1_ADDR__SHIFT 0x00000008
+#define R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_2 0x225c
+#define R200_VTX_TEX_0_ADDR__SHIFT 0x00000000
+#define R200_VTX_TEX_1_ADDR__SHIFT 0x00000008
+#define R200_VTX_TEX_2_ADDR__SHIFT 0x00000010
+#define R200_VTX_TEX_3_ADDR__SHIFT 0x00000018
+#define R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_3 0x2260
+#define R200_VTX_TEX_4_ADDR__SHIFT 0x00000000
+#define R200_VTX_TEX_5_ADDR__SHIFT 0x00000008
+
+/* gap */
+#define R200_SE_TCL_LIGHT_MODEL_CTL_0 0x2268
+#define R200_LIGHTING_ENABLE (1<<0)
+#define R200_LIGHT_IN_MODELSPACE (1<<1)
+#define R200_LOCAL_VIEWER (1<<2)
+#define R200_NORMALIZE_NORMALS (1<<3)
+#define R200_RESCALE_NORMALS (1<<4)
+#define R200_SPECULAR_LIGHTS (1<<5)
+#define R200_DIFFUSE_SPECULAR_COMBINE (1<<6)
+#define R200_LIGHT_ALPHA (1<<7)
+#define R200_LOCAL_LIGHT_VEC_GL (1<<8)
+#define R200_LIGHT_NO_NORMAL_AMBIENT_ONLY (1<<9)
+#define R200_LIGHT_TWOSIDE (1<<10)
+#define R200_FRONT_SHININESS_SOURCE_SHIFT (0xb)
+#define R200_BACK_SHININESS_SOURCE_SHIFT (0xd)
+#define R200_LM0_SOURCE_MATERIAL_0 (0)
+#define R200_LM0_SOURCE_MATERIAL_1 (1)
+#define R200_LM0_SOURCE_VERTEX_SHININESS_0 (2)
+#define R200_LM0_SOURCE_VERTEX_SHININESS_1 (3)
+#define R200_SE_TCL_LIGHT_MODEL_CTL_1 0x226c
+#define R200_LM1_SOURCE_LIGHT_PREMULT (0)
+#define R200_LM1_SOURCE_MATERIAL_0 (1)
+#define R200_LM1_SOURCE_VERTEX_COLOR_0 (2)
+#define R200_LM1_SOURCE_VERTEX_COLOR_1 (3)
+#define R200_LM1_SOURCE_VERTEX_COLOR_2 (4)
+#define R200_LM1_SOURCE_VERTEX_COLOR_3 (5)
+#define R200_LM1_SOURCE_VERTEX_COLOR_4 (6)
+#define R200_LM1_SOURCE_VERTEX_COLOR_5 (7)
+#define R200_LM1_SOURCE_VERTEX_COLOR_6 (8)
+#define R200_LM1_SOURCE_VERTEX_COLOR_7 (9)
+#define R200_LM1_SOURCE_MATERIAL_1 (0xf)
+#define R200_FRONT_EMISSIVE_SOURCE_SHIFT (0)
+#define R200_FRONT_AMBIENT_SOURCE_SHIFT (4)
+#define R200_FRONT_DIFFUSE_SOURCE_SHIFT (8)
+#define R200_FRONT_SPECULAR_SOURCE_SHIFT (12)
+#define R200_BACK_EMISSIVE_SOURCE_SHIFT (16)
+#define R200_BACK_AMBIENT_SOURCE_SHIFT (20)
+#define R200_BACK_DIFFUSE_SOURCE_SHIFT (24)
+#define R200_BACK_SPECULAR_SOURCE_SHIFT (28)
+#define R200_SE_TCL_PER_LIGHT_CTL_0 0x2270
+#define R200_LIGHT_0_ENABLE (1<<0)
+#define R200_LIGHT_0_ENABLE_AMBIENT (1<<1)
+#define R200_LIGHT_0_ENABLE_SPECULAR (1<<2)
+#define R200_LIGHT_0_IS_LOCAL (1<<3)
+#define R200_LIGHT_0_IS_SPOT (1<<4)
+#define R200_LIGHT_0_DUAL_CONE (1<<5)
+#define R200_LIGHT_0_ENABLE_RANGE_ATTEN (1<<6)
+#define R200_LIGHT_0_CONSTANT_RANGE_ATTEN (1<<7)
+#define R200_LIGHT_1_ENABLE (1<<16)
+#define R200_LIGHT_1_ENABLE_AMBIENT (1<<17)
+#define R200_LIGHT_1_ENABLE_SPECULAR (1<<18)
+#define R200_LIGHT_1_IS_LOCAL (1<<19)
+#define R200_LIGHT_1_IS_SPOT (1<<20)
+#define R200_LIGHT_1_DUAL_CONE (1<<21)
+#define R200_LIGHT_1_ENABLE_RANGE_ATTEN (1<<22)
+#define R200_LIGHT_1_CONSTANT_RANGE_ATTEN (1<<23)
+#define R200_LIGHT_0_SHIFT (0)
+#define R200_LIGHT_1_SHIFT (16)
+#define R200_SE_TCL_PER_LIGHT_CTL_1 0x2274
+#define R200_LIGHT_2_SHIFT (0)
+#define R200_LIGHT_3_SHIFT (16)
+#define R200_SE_TCL_PER_LIGHT_CTL_2 0x2278
+#define R200_LIGHT_4_SHIFT (0)
+#define R200_LIGHT_5_SHIFT (16)
+#define R200_SE_TCL_PER_LIGHT_CTL_3 0x227c
+#define R200_LIGHT_6_SHIFT (0)
+#define R200_LIGHT_7_SHIFT (16)
+/* gap */
+#define R200_SE_TCL_TEX_PROC_CTL_2 0x22a8
+#define R200_TEXGEN_0_COMP_MASK_SHIFT (0)
+#define R200_TEXGEN_1_COMP_MASK_SHIFT (4)
+#define R200_TEXGEN_2_COMP_MASK_SHIFT (8)
+#define R200_TEXGEN_3_COMP_MASK_SHIFT (12)
+#define R200_TEXGEN_4_COMP_MASK_SHIFT (16)
+#define R200_TEXGEN_5_COMP_MASK_SHIFT (20)
+#define R200_SE_TCL_TEX_PROC_CTL_3 0x22ac
+#define R200_TEXGEN_0_INPUT_TEX_SHIFT (0)
+#define R200_TEXGEN_1_INPUT_TEX_SHIFT (4)
+#define R200_TEXGEN_2_INPUT_TEX_SHIFT (8)
+#define R200_TEXGEN_3_INPUT_TEX_SHIFT (12)
+#define R200_TEXGEN_4_INPUT_TEX_SHIFT (16)
+#define R200_TEXGEN_5_INPUT_TEX_SHIFT (20)
+#define R200_SE_TCL_TEX_PROC_CTL_0 0x22b0
+#define R200_TEXGEN_TEXMAT_0_ENABLE (1<<0)
+#define R200_TEXGEN_TEXMAT_1_ENABLE (1<<1)
+#define R200_TEXGEN_TEXMAT_2_ENABLE (1<<2)
+#define R200_TEXGEN_TEXMAT_3_ENABLE (1<<3)
+#define R200_TEXGEN_TEXMAT_4_ENABLE (1<<4)
+#define R200_TEXGEN_TEXMAT_5_ENABLE (1<<5)
+#define R200_TEXMAT_0_ENABLE (1<<8)
+#define R200_TEXMAT_1_ENABLE (1<<9)
+#define R200_TEXMAT_2_ENABLE (1<<10)
+#define R200_TEXMAT_3_ENABLE (1<<11)
+#define R200_TEXMAT_4_ENABLE (1<<12)
+#define R200_TEXMAT_5_ENABLE (1<<13)
+#define R200_TEXGEN_FORCE_W_TO_ONE (1<<16)
+#define R200_SE_TCL_TEX_PROC_CTL_1 0x22b4
+#define R200_TEXGEN_INPUT_MASK (0xf)
+#define R200_TEXGEN_INPUT_TEXCOORD_0 (0)
+#define R200_TEXGEN_INPUT_TEXCOORD_1 (1)
+#define R200_TEXGEN_INPUT_TEXCOORD_2 (2)
+#define R200_TEXGEN_INPUT_TEXCOORD_3 (3)
+#define R200_TEXGEN_INPUT_TEXCOORD_4 (4)
+#define R200_TEXGEN_INPUT_TEXCOORD_5 (5)
+#define R200_TEXGEN_INPUT_OBJ (8)
+#define R200_TEXGEN_INPUT_EYE (9)
+#define R200_TEXGEN_INPUT_EYE_NORMAL (0xa)
+#define R200_TEXGEN_INPUT_EYE_REFLECT (0xb)
+#define R200_TEXGEN_INPUT_SPHERE (0xd)
+#define R200_TEXGEN_0_INPUT_SHIFT (0)
+#define R200_TEXGEN_1_INPUT_SHIFT (4)
+#define R200_TEXGEN_2_INPUT_SHIFT (8)
+#define R200_TEXGEN_3_INPUT_SHIFT (12)
+#define R200_TEXGEN_4_INPUT_SHIFT (16)
+#define R200_TEXGEN_5_INPUT_SHIFT (20)
+#define R200_SE_TC_TEX_CYL_WRAP_CTL 0x22b8
+/* gap */
+#define R200_SE_TCL_UCP_VERT_BLEND_CTL 0x22c0
+#define R200_UCP_IN_CLIP_SPACE (1<<0)
+#define R200_UCP_IN_MODEL_SPACE (1<<1)
+#define R200_UCP_ENABLE_0 (1<<2)
+#define R200_UCP_ENABLE_1 (1<<3)
+#define R200_UCP_ENABLE_2 (1<<4)
+#define R200_UCP_ENABLE_3 (1<<5)
+#define R200_UCP_ENABLE_4 (1<<6)
+#define R200_UCP_ENABLE_5 (1<<7)
+#define R200_TCL_FOG_MASK (3<<8)
+#define R200_TCL_FOG_DISABLE (0<<8)
+#define R200_TCL_FOG_EXP (1<<8)
+#define R200_TCL_FOG_EXP2 (2<<8)
+#define R200_TCL_FOG_LINEAR (3<<8)
+#define R200_RNG_BASED_FOG (1<<10)
+#define R200_CLIP_DISABLE (1<<11)
+#define R200_CULL_FRONT_IS_CW (0<<28)
+#define R200_CULL_FRONT_IS_CCW (1<<28)
+#define R200_CULL_FRONT (1<<29)
+#define R200_CULL_BACK (1<<30)
+#define R200_SE_TCL_POINT_SPRITE_CNTL 0x22c4
+/* gap */
+#define R200_SE_VTX_ST_POS_0_X_4 0x2300
+#define R200_SE_VTX_ST_POS_0_Y_4 0x2304
+#define R200_SE_VTX_ST_POS_0_Z_4 0x2308
+#define R200_SE_VTX_ST_POS_0_W_4 0x230c
+#define R200_SE_VTX_ST_NORM_0_X 0x2310
+#define R200_SE_VTX_ST_NORM_0_Y 0x2314
+#define R200_SE_VTX_ST_NORM_0_Z 0x2318
+#define R200_SE_VTX_ST_PVMS 0x231c
+#define R200_SE_VTX_ST_CLR_0_R 0x2320
+#define R200_SE_VTX_ST_CLR_0_G 0x2324
+#define R200_SE_VTX_ST_CLR_0_B 0x2328
+#define R200_SE_VTX_ST_CLR_0_A 0x232c
+#define R200_SE_VTX_ST_CLR_1_R 0x2330
+#define R200_SE_VTX_ST_CLR_1_G 0x2334
+#define R200_SE_VTX_ST_CLR_1_B 0x2338
+#define R200_SE_VTX_ST_CLR_1_A 0x233c
+#define R200_SE_VTX_ST_CLR_2_R 0x2340
+#define R200_SE_VTX_ST_CLR_2_G 0x2344
+#define R200_SE_VTX_ST_CLR_2_B 0x2348
+#define R200_SE_VTX_ST_CLR_2_A 0x234c
+#define R200_SE_VTX_ST_CLR_3_R 0x2350
+#define R200_SE_VTX_ST_CLR_3_G 0x2354
+#define R200_SE_VTX_ST_CLR_3_B 0x2358
+#define R200_SE_VTX_ST_CLR_3_A 0x235c
+#define R200_SE_VTX_ST_CLR_4_R 0x2360
+#define R200_SE_VTX_ST_CLR_4_G 0x2364
+#define R200_SE_VTX_ST_CLR_4_B 0x2368
+#define R200_SE_VTX_ST_CLR_4_A 0x236c
+#define R200_SE_VTX_ST_CLR_5_R 0x2370
+#define R200_SE_VTX_ST_CLR_5_G 0x2374
+#define R200_SE_VTX_ST_CLR_5_B 0x2378
+#define R200_SE_VTX_ST_CLR_5_A 0x237c
+#define R200_SE_VTX_ST_CLR_6_R 0x2380
+#define R200_SE_VTX_ST_CLR_6_G 0x2384
+#define R200_SE_VTX_ST_CLR_6_B 0x2388
+#define R200_SE_VTX_ST_CLR_6_A 0x238c
+#define R200_SE_VTX_ST_CLR_7_R 0x2390
+#define R200_SE_VTX_ST_CLR_7_G 0x2394
+#define R200_SE_VTX_ST_CLR_7_B 0x2398
+#define R200_SE_VTX_ST_CLR_7_A 0x239c
+#define R200_SE_VTX_ST_TEX_0_S 0x23a0
+#define R200_SE_VTX_ST_TEX_0_T 0x23a4
+#define R200_SE_VTX_ST_TEX_0_R 0x23a8
+#define R200_SE_VTX_ST_TEX_0_Q 0x23ac
+#define R200_SE_VTX_ST_TEX_1_S 0x23b0
+#define R200_SE_VTX_ST_TEX_1_T 0x23b4
+#define R200_SE_VTX_ST_TEX_1_R 0x23b8
+#define R200_SE_VTX_ST_TEX_1_Q 0x23bc
+#define R200_SE_VTX_ST_TEX_2_S 0x23c0
+#define R200_SE_VTX_ST_TEX_2_T 0x23c4
+#define R200_SE_VTX_ST_TEX_2_R 0x23c8
+#define R200_SE_VTX_ST_TEX_2_Q 0x23cc
+#define R200_SE_VTX_ST_TEX_3_S 0x23d0
+#define R200_SE_VTX_ST_TEX_3_T 0x23d4
+#define R200_SE_VTX_ST_TEX_3_R 0x23d8
+#define R200_SE_VTX_ST_TEX_3_Q 0x23dc
+#define R200_SE_VTX_ST_TEX_4_S 0x23e0
+#define R200_SE_VTX_ST_TEX_4_T 0x23e4
+#define R200_SE_VTX_ST_TEX_4_R 0x23e8
+#define R200_SE_VTX_ST_TEX_4_Q 0x23ec
+#define R200_SE_VTX_ST_TEX_5_S 0x23f0
+#define R200_SE_VTX_ST_TEX_5_T 0x23f4
+#define R200_SE_VTX_ST_TEX_5_R 0x23f8
+#define R200_SE_VTX_ST_TEX_5_Q 0x23fc
+#define R200_SE_VTX_ST_PNT_SPRT_SZ 0x2400
+#define R200_SE_VTX_ST_DISC_FOG 0x2404
+#define R200_SE_VTX_ST_SHININESS_0 0x2408
+#define R200_SE_VTX_ST_SHININESS_1 0x240c
+#define R200_SE_VTX_ST_BLND_WT_0 0x2410
+#define R200_SE_VTX_ST_BLND_WT_1 0x2414
+#define R200_SE_VTX_ST_BLND_WT_2 0x2418
+#define R200_SE_VTX_ST_BLND_WT_3 0x241c
+#define R200_SE_VTX_ST_POS_1_X 0x2420
+#define R200_SE_VTX_ST_POS_1_Y 0x2424
+#define R200_SE_VTX_ST_POS_1_Z 0x2428
+#define R200_SE_VTX_ST_POS_1_W 0x242c
+#define R200_SE_VTX_ST_NORM_1_X 0x2430
+#define R200_SE_VTX_ST_NORM_1_Y 0x2434
+#define R200_SE_VTX_ST_NORM_1_Z 0x2438
+#define R200_SE_VTX_ST_USR_CLR_0_R 0x2440
+#define R200_SE_VTX_ST_USR_CLR_0_G 0x2444
+#define R200_SE_VTX_ST_USR_CLR_0_B 0x2448
+#define R200_SE_VTX_ST_USR_CLR_0_A 0x244c
+#define R200_SE_VTX_ST_USR_CLR_1_R 0x2450
+#define R200_SE_VTX_ST_USR_CLR_1_G 0x2454
+#define R200_SE_VTX_ST_USR_CLR_1_B 0x2458
+#define R200_SE_VTX_ST_USR_CLR_1_A 0x245c
+#define R200_SE_VTX_ST_CLR_0_PKD 0x2460
+#define R200_SE_VTX_ST_CLR_1_PKD 0x2464
+#define R200_SE_VTX_ST_CLR_2_PKD 0x2468
+#define R200_SE_VTX_ST_CLR_3_PKD 0x246c
+#define R200_SE_VTX_ST_CLR_4_PKD 0x2470
+#define R200_SE_VTX_ST_CLR_5_PKD 0x2474
+#define R200_SE_VTX_ST_CLR_6_PKD 0x2478
+#define R200_SE_VTX_ST_CLR_7_PKD 0x247c
+#define R200_SE_VTX_ST_POS_0_X_2 0x2480
+#define R200_SE_VTX_ST_POS_0_Y_2 0x2484
+#define R200_SE_VTX_ST_PAR_CLR_LD 0x2488
+#define R200_SE_VTX_ST_USR_CLR_PKD 0x248c
+#define R200_SE_VTX_ST_POS_0_X_3 0x2490
+#define R200_SE_VTX_ST_POS_0_Y_3 0x2494
+#define R200_SE_VTX_ST_POS_0_Z_3 0x2498
+#define R200_SE_VTX_ST_END_OF_PKT 0x249c
+/* gap */
+#define R200_RE_POINTSIZE 0x2648
+#define R200_POINTSIZE_SHIFT 0
+#define R200_MAXPOINTSIZE_SHIFT 16
+/* gap */
+#define R200_RE_TOP_LEFT 0x26c0
+#define R200_RE_LEFT_SHIFT 0
+#define R200_RE_TOP_SHIFT 16
+#define R200_RE_MISC 0x26c4
+#define R200_STIPPLE_COORD_MASK 0x1f
+#define R200_STIPPLE_X_OFFSET_SHIFT 0
+#define R200_STIPPLE_X_OFFSET_MASK (0x1f << 0)
+#define R200_STIPPLE_Y_OFFSET_SHIFT 8
+#define R200_STIPPLE_Y_OFFSET_MASK (0x1f << 8)
+#define R200_STIPPLE_LITTLE_BIT_ORDER (0 << 16)
+#define R200_STIPPLE_BIG_BIT_ORDER (1 << 16)
+/* gap */
+#define R200_RE_AUX_SCISSOR_CNTL 0x26f0
+#define R200_EXCLUSIVE_SCISSOR_0 0x01000000
+#define R200_EXCLUSIVE_SCISSOR_1 0x02000000
+#define R200_EXCLUSIVE_SCISSOR_2 0x04000000
+#define R200_SCISSOR_ENABLE_0 0x10000000
+#define R200_SCISSOR_ENABLE_1 0x20000000
+#define R200_SCISSOR_ENABLE_2 0x40000000
+/* gap */
+#define R200_PP_TXFILTER_0 0x2c00
+#define R200_MAG_FILTER_NEAREST (0 << 0)
+#define R200_MAG_FILTER_LINEAR (1 << 0)
+#define R200_MAG_FILTER_MASK (1 << 0)
+#define R200_MIN_FILTER_NEAREST (0 << 1)
+#define R200_MIN_FILTER_LINEAR (1 << 1)
+#define R200_MIN_FILTER_NEAREST_MIP_NEAREST (2 << 1)
+#define R200_MIN_FILTER_NEAREST_MIP_LINEAR (3 << 1)
+#define R200_MIN_FILTER_LINEAR_MIP_NEAREST (6 << 1)
+#define R200_MIN_FILTER_LINEAR_MIP_LINEAR (7 << 1)
+#define R200_MIN_FILTER_ANISO_NEAREST (8 << 1)
+#define R200_MIN_FILTER_ANISO_LINEAR (9 << 1)
+#define R200_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST (10 << 1)
+#define R200_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR (11 << 1)
+#define R200_MIN_FILTER_MASK (15 << 1)
+#define R200_MAX_ANISO_1_TO_1 (0 << 5)
+#define R200_MAX_ANISO_2_TO_1 (1 << 5)
+#define R200_MAX_ANISO_4_TO_1 (2 << 5)
+#define R200_MAX_ANISO_8_TO_1 (3 << 5)
+#define R200_MAX_ANISO_16_TO_1 (4 << 5)
+#define R200_MAX_ANISO_MASK (7 << 5)
+#define R200_MAX_MIP_LEVEL_MASK (0x0f << 16)
+#define R200_MAX_MIP_LEVEL_SHIFT 16
+#define R200_YUV_TO_RGB (1 << 20)
+#define R200_YUV_TEMPERATURE_COOL (0 << 21)
+#define R200_YUV_TEMPERATURE_HOT (1 << 21)
+#define R200_YUV_TEMPERATURE_MASK (1 << 21)
+#define R200_WRAPEN_S (1 << 22)
+#define R200_CLAMP_S_WRAP (0 << 23)
+#define R200_CLAMP_S_MIRROR (1 << 23)
+#define R200_CLAMP_S_CLAMP_LAST (2 << 23)
+#define R200_CLAMP_S_MIRROR_CLAMP_LAST (3 << 23)
+#define R200_CLAMP_S_CLAMP_BORDER (4 << 23)
+#define R200_CLAMP_S_MIRROR_CLAMP_BORDER (5 << 23)
+#define R200_CLAMP_S_CLAMP_GL (6 << 23)
+#define R200_CLAMP_S_MIRROR_CLAMP_GL (7 << 23)
+#define R200_CLAMP_S_MASK (7 << 23)
+#define R200_WRAPEN_T (1 << 26)
+#define R200_CLAMP_T_WRAP (0 << 27)
+#define R200_CLAMP_T_MIRROR (1 << 27)
+#define R200_CLAMP_T_CLAMP_LAST (2 << 27)
+#define R200_CLAMP_T_MIRROR_CLAMP_LAST (3 << 27)
+#define R200_CLAMP_T_CLAMP_BORDER (4 << 27)
+#define R200_CLAMP_T_MIRROR_CLAMP_BORDER (5 << 27)
+#define R200_CLAMP_T_CLAMP_GL (6 << 27)
+#define R200_CLAMP_T_MIRROR_CLAMP_GL (7 << 27)
+#define R200_CLAMP_T_MASK (7 << 27)
+#define R200_KILL_LT_ZERO (1 << 30)
+#define R200_BORDER_MODE_OGL (0 << 31)
+#define R200_BORDER_MODE_D3D (1 << 31)
+#define R200_PP_TXFORMAT_0 0x2c04
+#define R200_TXFORMAT_I8 (0 << 0)
+#define R200_TXFORMAT_AI88 (1 << 0)
+#define R200_TXFORMAT_RGB332 (2 << 0)
+#define R200_TXFORMAT_ARGB1555 (3 << 0)
+#define R200_TXFORMAT_RGB565 (4 << 0)
+#define R200_TXFORMAT_ARGB4444 (5 << 0)
+#define R200_TXFORMAT_ARGB8888 (6 << 0)
+#define R200_TXFORMAT_RGBA8888 (7 << 0)
+#define R200_TXFORMAT_Y8 (8 << 0)
+#define R200_TXFORMAT_AVYU4444 (9 << 0)
+#define R200_TXFORMAT_VYUY422 (10 << 0)
+#define R200_TXFORMAT_YVYU422 (11 << 0)
+#define R200_TXFORMAT_DXT1 (12 << 0)
+#define R200_TXFORMAT_DXT23 (14 << 0)
+#define R200_TXFORMAT_DXT45 (15 << 0)
+#define R200_TXFORMAT_FORMAT_MASK (31 << 0)
+#define R200_TXFORMAT_FORMAT_SHIFT 0
+#define R200_TXFORMAT_ALPHA_IN_MAP (1 << 6)
+#define R200_TXFORMAT_NON_POWER2 (1 << 7)
+#define R200_TXFORMAT_WIDTH_MASK (15 << 8)
+#define R200_TXFORMAT_WIDTH_SHIFT 8
+#define R200_TXFORMAT_HEIGHT_MASK (15 << 12)
+#define R200_TXFORMAT_HEIGHT_SHIFT 12
+#define R200_TXFORMAT_F5_WIDTH_MASK (15 << 16) /* cube face 5 */
+#define R200_TXFORMAT_F5_WIDTH_SHIFT 16
+#define R200_TXFORMAT_F5_HEIGHT_MASK (15 << 20)
+#define R200_TXFORMAT_F5_HEIGHT_SHIFT 20
+#define R200_TXFORMAT_ST_ROUTE_STQ0 (0 << 24)
+#define R200_TXFORMAT_ST_ROUTE_STQ1 (1 << 24)
+#define R200_TXFORMAT_ST_ROUTE_STQ2 (2 << 24)
+#define R200_TXFORMAT_ST_ROUTE_STQ3 (3 << 24)
+#define R200_TXFORMAT_ST_ROUTE_STQ4 (4 << 24)
+#define R200_TXFORMAT_ST_ROUTE_STQ5 (5 << 24)
+#define R200_TXFORMAT_ST_ROUTE_MASK (7 << 24)
+#define R200_TXFORMAT_ST_ROUTE_SHIFT 24
+#define R200_TXFORMAT_ALPHA_MASK_ENABLE (1 << 28)
+#define R200_TXFORMAT_CHROMA_KEY_ENABLE (1 << 29)
+#define R200_TXFORMAT_CUBIC_MAP_ENABLE (1 << 30)
+#define R200_PP_TXFORMAT_X_0 0x2c08
+#define R200_DEPTH_LOG2_MASK (0xf << 0)
+#define R200_DEPTH_LOG2_SHIFT 0
+#define R200_VOLUME_FILTER_SHIFT 4
+#define R200_VOLUME_FILTER_MASK (1 << 4)
+#define R200_VOLUME_FILTER_NEAREST (0 << 4)
+#define R200_VOLUME_FILTER_LINEAR (1 << 4)
+#define R200_WRAPEN_Q (1 << 8)
+#define R200_CLAMP_Q_WRAP (0 << 9)
+#define R200_CLAMP_Q_MIRROR (1 << 9)
+#define R200_CLAMP_Q_CLAMP_LAST (2 << 9)
+#define R200_CLAMP_Q_MIRROR_CLAMP_LAST (3 << 9)
+#define R200_CLAMP_Q_CLAMP_BORDER (4 << 9)
+#define R200_CLAMP_Q_MIRROR_CLAMP_BORDER (5 << 9)
+#define R200_CLAMP_Q_CLAMP_GL (6 << 9)
+#define R200_CLAMP_Q_MIRROR_CLAMP_GL (7 << 9)
+#define R200_CLAMP_Q_MASK (7 << 9)
+#define R200_MIN_MIP_LEVEL_MASK (0xff << 12)
+#define R200_MIN_MIP_LEVEL_SHIFT 12
+#define R200_TEXCOORD_NONPROJ (0 << 16)
+#define R200_TEXCOORD_CUBIC_ENV (1 << 16)
+#define R200_TEXCOORD_VOLUME (2 << 16)
+#define R200_TEXCOORD_PROJ (3 << 16)
+#define R200_TEXCOORD_DEPTH (4 << 16)
+#define R200_TEXCOORD_1D_PROJ (5 << 16)
+#define R200_TEXCOORD_1D (6 << 16)
+#define R200_TEXCOORD_ZERO (7 << 16)
+#define R200_TEXCOORD_MASK (7 << 16)
+#define R200_LOD_BIAS_MASK (0xfff80000)
+#define R200_LOD_BIAS_SHIFT 19
+#define R200_PP_TXSIZE_0 0x2c0c /* NPOT only */
+#define R200_PP_TXPITCH_0 0x2c10 /* NPOT only */
+#define R200_PP_BORDER_COLOR_0 0x2c14
+#define R200_PP_CUBIC_FACES_0 0x2c18
+#define R200_FACE_WIDTH_1_SHIFT 0
+#define R200_FACE_HEIGHT_1_SHIFT 4
+#define R200_FACE_WIDTH_1_MASK (0xf << 0)
+#define R200_FACE_HEIGHT_1_MASK (0xf << 4)
+#define R200_FACE_WIDTH_2_SHIFT 8
+#define R200_FACE_HEIGHT_2_SHIFT 12
+#define R200_FACE_WIDTH_2_MASK (0xf << 8)
+#define R200_FACE_HEIGHT_2_MASK (0xf << 12)
+#define R200_FACE_WIDTH_3_SHIFT 16
+#define R200_FACE_HEIGHT_3_SHIFT 20
+#define R200_FACE_WIDTH_3_MASK (0xf << 16)
+#define R200_FACE_HEIGHT_3_MASK (0xf << 20)
+#define R200_FACE_WIDTH_4_SHIFT 24
+#define R200_FACE_HEIGHT_4_SHIFT 28
+#define R200_FACE_WIDTH_4_MASK (0xf << 24)
+#define R200_FACE_HEIGHT_4_MASK (0xf << 28)
+#define R200_PP_TXFILTER_1 0x2c20
+#define R200_PP_TXFORMAT_1 0x2c24
+#define R200_PP_TXFORMAT_X_1 0x2c28
+#define R200_PP_TXSIZE_1 0x2c2c
+#define R200_PP_TXPITCH_1 0x2c30
+#define R200_PP_BORDER_COLOR_1 0x2c34
+#define R200_PP_CUBIC_FACES_1 0x2c38
+#define R200_PP_TXFILTER_2 0x2c40
+#define R200_PP_TXFORMAT_2 0x2c44
+#define R200_PP_TXSIZE_2 0x2c4c
+#define R200_PP_TXFORMAT_X_2 0x2c48
+#define R200_PP_TXPITCH_2 0x2c50
+#define R200_PP_BORDER_COLOR_2 0x2c54
+#define R200_PP_CUBIC_FACES_2 0x2c58
+#define R200_PP_TXFILTER_3 0x2c60
+#define R200_PP_TXFORMAT_3 0x2c64
+#define R200_PP_TXSIZE_3 0x2c6c
+#define R200_PP_TXFORMAT_X_3 0x2c68
+#define R200_PP_TXPITCH_3 0x2c70
+#define R200_PP_BORDER_COLOR_3 0x2c74
+#define R200_PP_CUBIC_FACES_3 0x2c78
+#define R200_PP_TXFILTER_4 0x2c80
+#define R200_PP_TXFORMAT_4 0x2c84
+#define R200_PP_TXSIZE_4 0x2c8c
+#define R200_PP_TXFORMAT_X_4 0x2c88
+#define R200_PP_TXPITCH_4 0x2c90
+#define R200_PP_BORDER_COLOR_4 0x2c94
+#define R200_PP_CUBIC_FACES_4 0x2c98
+#define R200_PP_TXFILTER_5 0x2ca0
+#define R200_PP_TXFORMAT_5 0x2ca4
+#define R200_PP_TXSIZE_5 0x2cac
+#define R200_PP_TXFORMAT_X_5 0x2ca8
+#define R200_PP_TXPITCH_5 0x2cb0
+#define R200_PP_BORDER_COLOR_5 0x2cb4
+#define R200_PP_CUBIC_FACES_5 0x2cb8
+/* gap */
+#define R200_PP_CNTL_X 0x2cc4
+/* gap */
+#define R200_PP_TXOFFSET_0 0x2d00
+#define R200_TXO_ENDIAN_NO_SWAP (0 << 0)
+#define R200_TXO_ENDIAN_BYTE_SWAP (1 << 0)
+#define R200_TXO_ENDIAN_WORD_SWAP (2 << 0)
+#define R200_TXO_ENDIAN_HALFDW_SWAP (3 << 0)
+#define R200_TXO_OFFSET_MASK 0xffffffe0
+#define R200_TXO_OFFSET_SHIFT 5
+#define R200_PP_CUBIC_OFFSET_F1_0 0x2d04
+#define R200_PP_CUBIC_OFFSET_F2_0 0x2d08
+#define R200_PP_CUBIC_OFFSET_F3_0 0x2d0c
+#define R200_PP_CUBIC_OFFSET_F4_0 0x2d10
+#define R200_PP_CUBIC_OFFSET_F5_0 0x2d14
+#define R200_PP_TXOFFSET_1 0x2d18
+#define R200_PP_CUBIC_OFFSET_F1_1 0x2d1c
+#define R200_PP_CUBIC_OFFSET_F2_1 0x2d20
+#define R200_PP_CUBIC_OFFSET_F3_1 0x2d24
+#define R200_PP_CUBIC_OFFSET_F4_1 0x2d28
+#define R200_PP_CUBIC_OFFSET_F5_1 0x2d2c
+#define R200_PP_TXOFFSET_2 0x2d30
+#define R200_PP_CUBIC_OFFSET_F1_2 0x2d34
+#define R200_PP_CUBIC_OFFSET_F2_2 0x2d38
+#define R200_PP_CUBIC_OFFSET_F3_2 0x2d3c
+#define R200_PP_CUBIC_OFFSET_F4_2 0x2d40
+#define R200_PP_CUBIC_OFFSET_F5_2 0x2d44
+#define R200_PP_TXOFFSET_3 0x2d48
+#define R200_PP_CUBIC_OFFSET_F1_3 0x2d4c
+#define R200_PP_CUBIC_OFFSET_F2_3 0x2d50
+#define R200_PP_CUBIC_OFFSET_F3_3 0x2d54
+#define R200_PP_CUBIC_OFFSET_F4_3 0x2d58
+#define R200_PP_CUBIC_OFFSET_F5_3 0x2d5c
+#define R200_PP_TXOFFSET_4 0x2d60
+#define R200_PP_CUBIC_OFFSET_F1_4 0x2d64
+#define R200_PP_CUBIC_OFFSET_F2_4 0x2d68
+#define R200_PP_CUBIC_OFFSET_F3_4 0x2d6c
+#define R200_PP_CUBIC_OFFSET_F4_4 0x2d70
+#define R200_PP_CUBIC_OFFSET_F5_4 0x2d74
+#define R200_PP_TXOFFSET_5 0x2d78
+#define R200_PP_CUBIC_OFFSET_F1_5 0x2d7c
+#define R200_PP_CUBIC_OFFSET_F2_5 0x2d80
+#define R200_PP_CUBIC_OFFSET_F3_5 0x2d84
+#define R200_PP_CUBIC_OFFSET_F4_5 0x2d88
+#define R200_PP_CUBIC_OFFSET_F5_5 0x2d8c
+/* gap */
+#define R200_PP_TAM_DEBUG3 0x2d9c
+/* gap */
+#define R200_PP_TFACTOR_0 0x2ee0
+#define R200_PP_TFACTOR_1 0x2ee4
+#define R200_PP_TFACTOR_2 0x2ee8
+#define R200_PP_TFACTOR_3 0x2eec
+#define R200_PP_TFACTOR_4 0x2ef0
+#define R200_PP_TFACTOR_5 0x2ef4
+/* gap */
+#define R200_PP_TXCBLEND_0 0x2f00
+#define R200_TXC_ARG_A_ZERO (0)
+#define R200_TXC_ARG_A_CURRENT_COLOR (2)
+#define R200_TXC_ARG_A_CURRENT_ALPHA (3)
+#define R200_TXC_ARG_A_DIFFUSE_COLOR (4)
+#define R200_TXC_ARG_A_DIFFUSE_ALPHA (5)
+#define R200_TXC_ARG_A_SPECULAR_COLOR (6)
+#define R200_TXC_ARG_A_SPECULAR_ALPHA (7)
+#define R200_TXC_ARG_A_TFACTOR_COLOR (8)
+#define R200_TXC_ARG_A_TFACTOR_ALPHA (9)
+#define R200_TXC_ARG_A_R0_COLOR (10)
+#define R200_TXC_ARG_A_R0_ALPHA (11)
+#define R200_TXC_ARG_A_R1_COLOR (12)
+#define R200_TXC_ARG_A_R1_ALPHA (13)
+#define R200_TXC_ARG_A_R2_COLOR (14)
+#define R200_TXC_ARG_A_R2_ALPHA (15)
+#define R200_TXC_ARG_A_R3_COLOR (16)
+#define R200_TXC_ARG_A_R3_ALPHA (17)
+#define R200_TXC_ARG_A_R4_COLOR (18)
+#define R200_TXC_ARG_A_R4_ALPHA (19)
+#define R200_TXC_ARG_A_R5_COLOR (20)
+#define R200_TXC_ARG_A_R5_ALPHA (21)
+#define R200_TXC_ARG_A_TFACTOR1_COLOR (26)
+#define R200_TXC_ARG_A_TFACTOR1_ALPHA (27)
+#define R200_TXC_ARG_A_MASK (31 << 0)
+#define R200_TXC_ARG_A_SHIFT 0
+#define R200_TXC_ARG_B_ZERO (0<<5)
+#define R200_TXC_ARG_B_CURRENT_COLOR (2<<5)
+#define R200_TXC_ARG_B_CURRENT_ALPHA (3<<5)
+#define R200_TXC_ARG_B_DIFFUSE_COLOR (4<<5)
+#define R200_TXC_ARG_B_DIFFUSE_ALPHA (5<<5)
+#define R200_TXC_ARG_B_SPECULAR_COLOR (6<<5)
+#define R200_TXC_ARG_B_SPECULAR_ALPHA (7<<5)
+#define R200_TXC_ARG_B_TFACTOR_COLOR (8<<5)
+#define R200_TXC_ARG_B_TFACTOR_ALPHA (9<<5)
+#define R200_TXC_ARG_B_R0_COLOR (10<<5)
+#define R200_TXC_ARG_B_R0_ALPHA (11<<5)
+#define R200_TXC_ARG_B_R1_COLOR (12<<5)
+#define R200_TXC_ARG_B_R1_ALPHA (13<<5)
+#define R200_TXC_ARG_B_R2_COLOR (14<<5)
+#define R200_TXC_ARG_B_R2_ALPHA (15<<5)
+#define R200_TXC_ARG_B_R3_COLOR (16<<5)
+#define R200_TXC_ARG_B_R3_ALPHA (17<<5)
+#define R200_TXC_ARG_B_R4_COLOR (18<<5)
+#define R200_TXC_ARG_B_R4_ALPHA (19<<5)
+#define R200_TXC_ARG_B_R5_COLOR (20<<5)
+#define R200_TXC_ARG_B_R5_ALPHA (21<<5)
+#define R200_TXC_ARG_B_TFACTOR1_COLOR (26<<5)
+#define R200_TXC_ARG_B_TFACTOR1_ALPHA (27<<5)
+#define R200_TXC_ARG_B_MASK (31 << 5)
+#define R200_TXC_ARG_B_SHIFT 5
+#define R200_TXC_ARG_C_ZERO (0<<10)
+#define R200_TXC_ARG_C_CURRENT_COLOR (2<<10)
+#define R200_TXC_ARG_C_CURRENT_ALPHA (3<<10)
+#define R200_TXC_ARG_C_DIFFUSE_COLOR (4<<10)
+#define R200_TXC_ARG_C_DIFFUSE_ALPHA (5<<10)
+#define R200_TXC_ARG_C_SPECULAR_COLOR (6<<10)
+#define R200_TXC_ARG_C_SPECULAR_ALPHA (7<<10)
+#define R200_TXC_ARG_C_TFACTOR_COLOR (8<<10)
+#define R200_TXC_ARG_C_TFACTOR_ALPHA (9<<10)
+#define R200_TXC_ARG_C_R0_COLOR (10<<10)
+#define R200_TXC_ARG_C_R0_ALPHA (11<<10)
+#define R200_TXC_ARG_C_R1_COLOR (12<<10)
+#define R200_TXC_ARG_C_R1_ALPHA (13<<10)
+#define R200_TXC_ARG_C_R2_COLOR (14<<10)
+#define R200_TXC_ARG_C_R2_ALPHA (15<<10)
+#define R200_TXC_ARG_C_R3_COLOR (16<<10)
+#define R200_TXC_ARG_C_R3_ALPHA (17<<10)
+#define R200_TXC_ARG_C_R4_COLOR (18<<10)
+#define R200_TXC_ARG_C_R4_ALPHA (19<<10)
+#define R200_TXC_ARG_C_R5_COLOR (20<<10)
+#define R200_TXC_ARG_C_R5_ALPHA (21<<10)
+#define R200_TXC_ARG_C_TFACTOR1_COLOR (26<<10)
+#define R200_TXC_ARG_C_TFACTOR1_ALPHA (27<<10)
+#define R200_TXC_ARG_C_MASK (31 << 10)
+#define R200_TXC_ARG_C_SHIFT 10
+#define R200_TXC_COMP_ARG_A (1 << 16)
+#define R200_TXC_COMP_ARG_A_SHIFT (16)
+#define R200_TXC_BIAS_ARG_A (1 << 17)
+#define R200_TXC_SCALE_ARG_A (1 << 18)
+#define R200_TXC_NEG_ARG_A (1 << 19)
+#define R200_TXC_COMP_ARG_B (1 << 20)
+#define R200_TXC_COMP_ARG_B_SHIFT (20)
+#define R200_TXC_BIAS_ARG_B (1 << 21)
+#define R200_TXC_SCALE_ARG_B (1 << 22)
+#define R200_TXC_NEG_ARG_B (1 << 23)
+#define R200_TXC_COMP_ARG_C (1 << 24)
+#define R200_TXC_COMP_ARG_C_SHIFT (24)
+#define R200_TXC_BIAS_ARG_C (1 << 25)
+#define R200_TXC_SCALE_ARG_C (1 << 26)
+#define R200_TXC_NEG_ARG_C (1 << 27)
+#define R200_TXC_OP_MADD (0 << 28)
+#define R200_TXC_OP_CND0 (2 << 28)
+#define R200_TXC_OP_LERP (3 << 28)
+#define R200_TXC_OP_DOT3 (4 << 28)
+#define R200_TXC_OP_DOT4 (5 << 28)
+#define R200_TXC_OP_CONDITIONAL (6 << 28)
+#define R200_TXC_OP_DOT2_ADD (7 << 28)
+#define R200_TXC_OP_MASK (7 << 28)
+#define R200_PP_TXCBLEND2_0 0x2f04
+#define R200_TXC_TFACTOR_SEL_SHIFT 0
+#define R200_TXC_TFACTOR_SEL_MASK 0x7
+#define R200_TXC_TFACTOR1_SEL_SHIFT 4
+#define R200_TXC_TFACTOR1_SEL_MASK (0x7 << 4)
+#define R200_TXC_SCALE_SHIFT 8
+#define R200_TXC_SCALE_MASK (7 << 8)
+#define R200_TXC_SCALE_1X (0 << 8)
+#define R200_TXC_SCALE_2X (1 << 8)
+#define R200_TXC_SCALE_4X (2 << 8)
+#define R200_TXC_SCALE_8X (3 << 8)
+#define R200_TXC_SCALE_INV2 (5 << 8)
+#define R200_TXC_SCALE_INV4 (6 << 8)
+#define R200_TXC_SCALE_INV8 (7 << 8)
+#define R200_TXC_CLAMP_SHIFT 12
+#define R200_TXC_CLAMP_MASK (3 << 12)
+#define R200_TXC_CLAMP_WRAP (0 << 12)
+#define R200_TXC_CLAMP_0_1 (1 << 12)
+#define R200_TXC_CLAMP_8_8 (2 << 12)
+#define R200_TXC_OUTPUT_REG_MASK (7 << 16)
+#define R200_TXC_OUTPUT_REG_NONE (0 << 16)
+#define R200_TXC_OUTPUT_REG_R0 (1 << 16)
+#define R200_TXC_OUTPUT_REG_R1 (2 << 16)
+#define R200_TXC_OUTPUT_REG_R2 (3 << 16)
+#define R200_TXC_OUTPUT_REG_R3 (4 << 16)
+#define R200_TXC_OUTPUT_REG_R4 (5 << 16)
+#define R200_TXC_OUTPUT_REG_R5 (6 << 16)
+#define R200_TXC_OUTPUT_MASK_MASK (7 << 20)
+#define R200_TXC_OUTPUT_MASK_RGB (0 << 20)
+#define R200_TXC_OUTPUT_MASK_RG (1 << 20)
+#define R200_TXC_OUTPUT_MASK_RB (2 << 20)
+#define R200_TXC_OUTPUT_MASK_R (3 << 20)
+#define R200_TXC_OUTPUT_MASK_GB (4 << 20)
+#define R200_TXC_OUTPUT_MASK_G (5 << 20)
+#define R200_TXC_OUTPUT_MASK_B (6 << 20)
+#define R200_TXC_OUTPUT_MASK_NONE (7 << 20)
+#define R200_TXC_REPL_NORMAL 0
+#define R200_TXC_REPL_RED 1
+#define R200_TXC_REPL_GREEN 2
+#define R200_TXC_REPL_BLUE 3
+#define R200_TXC_REPL_ARG_A_SHIFT 26
+#define R200_TXC_REPL_ARG_A_MASK (3 << 26)
+#define R200_TXC_REPL_ARG_B_SHIFT 28
+#define R200_TXC_REPL_ARG_B_MASK (3 << 28)
+#define R200_TXC_REPL_ARG_C_SHIFT 30
+#define R200_TXC_REPL_ARG_C_MASK (3 << 30)
+#define R200_PP_TXABLEND_0 0x2f08
+#define R200_TXA_ARG_A_ZERO (0)
+#define R200_TXA_ARG_A_CURRENT_ALPHA (2) /* guess */
+#define R200_TXA_ARG_A_CURRENT_BLUE (3) /* guess */
+#define R200_TXA_ARG_A_DIFFUSE_ALPHA (4)
+#define R200_TXA_ARG_A_DIFFUSE_BLUE (5)
+#define R200_TXA_ARG_A_SPECULAR_ALPHA (6)
+#define R200_TXA_ARG_A_SPECULAR_BLUE (7)
+#define R200_TXA_ARG_A_TFACTOR_ALPHA (8)
+#define R200_TXA_ARG_A_TFACTOR_BLUE (9)
+#define R200_TXA_ARG_A_R0_ALPHA (10)
+#define R200_TXA_ARG_A_R0_BLUE (11)
+#define R200_TXA_ARG_A_R1_ALPHA (12)
+#define R200_TXA_ARG_A_R1_BLUE (13)
+#define R200_TXA_ARG_A_R2_ALPHA (14)
+#define R200_TXA_ARG_A_R2_BLUE (15)
+#define R200_TXA_ARG_A_R3_ALPHA (16)
+#define R200_TXA_ARG_A_R3_BLUE (17)
+#define R200_TXA_ARG_A_R4_ALPHA (18)
+#define R200_TXA_ARG_A_R4_BLUE (19)
+#define R200_TXA_ARG_A_R5_ALPHA (20)
+#define R200_TXA_ARG_A_R5_BLUE (21)
+#define R200_TXA_ARG_A_TFACTOR1_ALPHA (26)
+#define R200_TXA_ARG_A_TFACTOR1_BLUE (27)
+#define R200_TXA_ARG_A_MASK (31 << 0)
+#define R200_TXA_ARG_A_SHIFT 0
+#define R200_TXA_ARG_B_ZERO (0<<5)
+#define R200_TXA_ARG_B_CURRENT_ALPHA (2<<5) /* guess */
+#define R200_TXA_ARG_B_CURRENT_BLUE (3<<5) /* guess */
+#define R200_TXA_ARG_B_DIFFUSE_ALPHA (4<<5)
+#define R200_TXA_ARG_B_DIFFUSE_BLUE (5<<5)
+#define R200_TXA_ARG_B_SPECULAR_ALPHA (6<<5)
+#define R200_TXA_ARG_B_SPECULAR_BLUE (7<<5)
+#define R200_TXA_ARG_B_TFACTOR_ALPHA (8<<5)
+#define R200_TXA_ARG_B_TFACTOR_BLUE (9<<5)
+#define R200_TXA_ARG_B_R0_ALPHA (10<<5)
+#define R200_TXA_ARG_B_R0_BLUE (11<<5)
+#define R200_TXA_ARG_B_R1_ALPHA (12<<5)
+#define R200_TXA_ARG_B_R1_BLUE (13<<5)
+#define R200_TXA_ARG_B_R2_ALPHA (14<<5)
+#define R200_TXA_ARG_B_R2_BLUE (15<<5)
+#define R200_TXA_ARG_B_R3_ALPHA (16<<5)
+#define R200_TXA_ARG_B_R3_BLUE (17<<5)
+#define R200_TXA_ARG_B_R4_ALPHA (18<<5)
+#define R200_TXA_ARG_B_R4_BLUE (19<<5)
+#define R200_TXA_ARG_B_R5_ALPHA (20<<5)
+#define R200_TXA_ARG_B_R5_BLUE (21<<5)
+#define R200_TXA_ARG_B_TFACTOR1_ALPHA (26<<5)
+#define R200_TXA_ARG_B_TFACTOR1_BLUE (27<<5)
+#define R200_TXA_ARG_B_MASK (31 << 5)
+#define R200_TXA_ARG_B_SHIFT 5
+#define R200_TXA_ARG_C_ZERO (0<<10)
+#define R200_TXA_ARG_C_CURRENT_ALPHA (2<<10) /* guess */
+#define R200_TXA_ARG_C_CURRENT_BLUE (3<<10) /* guess */
+#define R200_TXA_ARG_C_DIFFUSE_ALPHA (4<<10)
+#define R200_TXA_ARG_C_DIFFUSE_BLUE (5<<10)
+#define R200_TXA_ARG_C_SPECULAR_ALPHA (6<<10)
+#define R200_TXA_ARG_C_SPECULAR_BLUE (7<<10)
+#define R200_TXA_ARG_C_TFACTOR_ALPHA (8<<10)
+#define R200_TXA_ARG_C_TFACTOR_BLUE (9<<10)
+#define R200_TXA_ARG_C_R0_ALPHA (10<<10)
+#define R200_TXA_ARG_C_R0_BLUE (11<<10)
+#define R200_TXA_ARG_C_R1_ALPHA (12<<10)
+#define R200_TXA_ARG_C_R1_BLUE (13<<10)
+#define R200_TXA_ARG_C_R2_ALPHA (14<<10)
+#define R200_TXA_ARG_C_R2_BLUE (15<<10)
+#define R200_TXA_ARG_C_R3_ALPHA (16<<10)
+#define R200_TXA_ARG_C_R3_BLUE (17<<10)
+#define R200_TXA_ARG_C_R4_ALPHA (18<<10)
+#define R200_TXA_ARG_C_R4_BLUE (19<<10)
+#define R200_TXA_ARG_C_R5_ALPHA (20<<10)
+#define R200_TXA_ARG_C_R5_BLUE (21<<10)
+#define R200_TXA_ARG_C_TFACTOR1_ALPHA (26<<10)
+#define R200_TXA_ARG_C_TFACTOR1_BLUE (27<<10)
+#define R200_TXA_ARG_C_MASK (31 << 10)
+#define R200_TXA_ARG_C_SHIFT 10
+#define R200_TXA_COMP_ARG_A (1 << 16)
+#define R200_TXA_COMP_ARG_A_SHIFT (16)
+#define R200_TXA_BIAS_ARG_A (1 << 17)
+#define R200_TXA_SCALE_ARG_A (1 << 18)
+#define R200_TXA_NEG_ARG_A (1 << 19)
+#define R200_TXA_COMP_ARG_B (1 << 20)
+#define R200_TXA_COMP_ARG_B_SHIFT (20)
+#define R200_TXA_BIAS_ARG_B (1 << 21)
+#define R200_TXA_SCALE_ARG_B (1 << 22)
+#define R200_TXA_NEG_ARG_B (1 << 23)
+#define R200_TXA_COMP_ARG_C (1 << 24)
+#define R200_TXA_COMP_ARG_C_SHIFT (24)
+#define R200_TXA_BIAS_ARG_C (1 << 25)
+#define R200_TXA_SCALE_ARG_C (1 << 26)
+#define R200_TXA_NEG_ARG_C (1 << 27)
+#define R200_TXA_OP_MADD (0 << 28)
+#define R200_TXA_OP_CND0 (2 << 28)
+#define R200_TXA_OP_LERP (3 << 28)
+#define R200_TXA_OP_CONDITIONAL (6 << 28)
+#define R200_TXA_OP_MASK (7 << 28)
+#define R200_PP_TXABLEND2_0 0x2f0c
+#define R200_TXA_TFACTOR_SEL_SHIFT 0
+#define R200_TXA_TFACTOR_SEL_MASK 0x7
+#define R200_TXA_TFACTOR1_SEL_SHIFT 4
+#define R200_TXA_TFACTOR1_SEL_MASK (0x7 << 4)
+#define R200_TXA_SCALE_SHIFT 8
+#define R200_TXA_SCALE_MASK (7 << 8)
+#define R200_TXA_SCALE_1X (0 << 8)
+#define R200_TXA_SCALE_2X (1 << 8)
+#define R200_TXA_SCALE_4X (2 << 8)
+#define R200_TXA_SCALE_8X (3 << 8)
+#define R200_TXA_SCALE_INV2 (5 << 8)
+#define R200_TXA_SCALE_INV4 (6 << 8)
+#define R200_TXA_SCALE_INV8 (7 << 8)
+#define R200_TXA_CLAMP_SHIFT 12
+#define R200_TXA_CLAMP_MASK (3 << 12)
+#define R200_TXA_CLAMP_WRAP (0 << 12)
+#define R200_TXA_CLAMP_0_1 (1 << 12)
+#define R200_TXA_CLAMP_8_8 (2 << 12)
+#define R200_TXA_OUTPUT_REG_MASK (7 << 16)
+#define R200_TXA_OUTPUT_REG_NONE (0 << 16)
+#define R200_TXA_OUTPUT_REG_R0 (1 << 16)
+#define R200_TXA_OUTPUT_REG_R1 (2 << 16)
+#define R200_TXA_OUTPUT_REG_R2 (3 << 16)
+#define R200_TXA_OUTPUT_REG_R3 (4 << 16)
+#define R200_TXA_OUTPUT_REG_R4 (5 << 16)
+#define R200_TXA_OUTPUT_REG_R5 (6 << 16)
+#define R200_TXA_DOT_ALPHA (1 << 20)
+#define R200_TXA_REPL_NORMAL 0
+#define R200_TXA_REPL_RED 1
+#define R200_TXA_REPL_GREEN 2
+#define R200_TXA_REPL_ARG_A_SHIFT 26
+#define R200_TXA_REPL_ARG_A_MASK (3 << 26)
+#define R200_TXA_REPL_ARG_B_SHIFT 28
+#define R200_TXA_REPL_ARG_B_MASK (3 << 28)
+#define R200_TXA_REPL_ARG_C_SHIFT 30
+#define R200_TXA_REPL_ARG_C_MASK (3 << 30)
+#define R200_PP_TXCBLEND_1 0x2f10
+#define R200_PP_TXCBLEND2_1 0x2f14
+#define R200_PP_TXABLEND_1 0x2f18
+#define R200_PP_TXABLEND2_1 0x2f1c
+#define R200_PP_TXCBLEND_2 0x2f20
+#define R200_PP_TXCBLEND2_2 0x2f24
+#define R200_PP_TXABLEND_2 0x2f28
+#define R200_PP_TXABLEND2_2 0x2f2c
+#define R200_PP_TXCBLEND_3 0x2f30
+#define R200_PP_TXCBLEND2_3 0x2f34
+#define R200_PP_TXABLEND_3 0x2f38
+#define R200_PP_TXABLEND2_3 0x2f3c
+#define R200_PP_TXCBLEND_4 0x2f40
+#define R200_PP_TXCBLEND2_4 0x2f44
+#define R200_PP_TXABLEND_4 0x2f48
+#define R200_PP_TXABLEND2_4 0x2f4c
+#define R200_PP_TXCBLEND_5 0x2f50
+#define R200_PP_TXCBLEND2_5 0x2f54
+#define R200_PP_TXABLEND_5 0x2f58
+#define R200_PP_TXABLEND2_5 0x2f5c
+#define R200_PP_TXCBLEND_6 0x2f60
+#define R200_PP_TXCBLEND2_6 0x2f64
+#define R200_PP_TXABLEND_6 0x2f68
+#define R200_PP_TXABLEND2_6 0x2f6c
+#define R200_PP_TXCBLEND_7 0x2f70
+#define R200_PP_TXCBLEND2_7 0x2f74
+#define R200_PP_TXABLEND_7 0x2f78
+#define R200_PP_TXABLEND2_7 0x2f7c
+/* gap */
+#define R200_RB3D_BLENDCOLOR 0x3218 /* ARGB 8888 */
+#define R200_RB3D_ABLENDCNTL 0x321C /* see BLENDCTL */
+#define R200_RB3D_CBLENDCNTL 0x3220 /* see BLENDCTL */
+
+/*
+ * Offsets in TCL vector state. NOTE: Hardwiring matrix positions.
+ * Multiple contexts could collaberate to eliminate state bouncing.
+ */
+#define R200_VS_LIGHT_AMBIENT_ADDR 0x00000028
+#define R200_VS_LIGHT_DIFFUSE_ADDR 0x00000030
+#define R200_VS_LIGHT_SPECULAR_ADDR 0x00000038
+#define R200_VS_LIGHT_DIRPOS_ADDR 0x00000040
+#define R200_VS_LIGHT_HWVSPOT_ADDR 0x00000048
+#define R200_VS_LIGHT_ATTENUATION_ADDR 0x00000050
+#define R200_VS_SPOT_DUAL_CONE 0x00000058
+#define R200_VS_GLOBAL_AMBIENT_ADDR 0x0000005C
+#define R200_VS_FOG_PARAM_ADDR 0x0000005D
+#define R200_VS_EYE_VECTOR_ADDR 0x0000005E
+#define R200_VS_UCP_ADDR 0x00000060
+#define R200_VS_PNT_SPRITE_VPORT_SCALE 0x00000068
+#define R200_VS_MATRIX_0_MV 0x00000080
+#define R200_VS_MATRIX_1_INV_MV 0x00000084
+#define R200_VS_MATRIX_2_MVP 0x00000088
+#define R200_VS_MATRIX_3_TEX0 0x0000008C
+#define R200_VS_MATRIX_4_TEX1 0x00000090
+#define R200_VS_MATRIX_5_TEX2 0x00000094
+#define R200_VS_MATRIX_6_TEX3 0x00000098
+#define R200_VS_MATRIX_7_TEX4 0x0000009C
+#define R200_VS_MATRIX_8_TEX5 0x000000A0
+#define R200_VS_MAT_0_EMISS 0x000000B0
+#define R200_VS_MAT_0_AMB 0x000000B1
+#define R200_VS_MAT_0_DIF 0x000000B2
+#define R200_VS_MAT_0_SPEC 0x000000B3
+#define R200_VS_MAT_1_EMISS 0x000000B4
+#define R200_VS_MAT_1_AMB 0x000000B5
+#define R200_VS_MAT_1_DIF 0x000000B6
+#define R200_VS_MAT_1_SPEC 0x000000B7
+#define R200_VS_EYE2CLIP_MTX 0x000000B8
+#define R200_VS_PNT_SPRITE_ATT_CONST 0x000000BC
+#define R200_VS_PNT_SPRITE_EYE_IN_MODEL 0x000000BD
+#define R200_VS_PNT_SPRITE_CLAMP 0x000000BE
+#define R200_VS_MAX 0x000001C0
+
+/*
+ * Offsets in TCL scalar state
+ */
+#define R200_SS_LIGHT_DCD_ADDR 0x00000000
+#define R200_SS_LIGHT_DCM_ADDR 0x00000008
+#define R200_SS_LIGHT_SPOT_EXPONENT_ADDR 0x00000010
+#define R200_SS_LIGHT_SPOT_CUTOFF_ADDR 0x00000018
+#define R200_SS_LIGHT_SPECULAR_THRESH_ADDR 0x00000020
+#define R200_SS_LIGHT_RANGE_CUTOFF_SQRD 0x00000028
+#define R200_SS_LIGHT_RANGE_ATT_CONST 0x00000030
+#define R200_SS_VERT_GUARD_CLIP_ADJ_ADDR 0x00000080
+#define R200_SS_VERT_GUARD_DISCARD_ADJ_ADDR 0x00000081
+#define R200_SS_HORZ_GUARD_CLIP_ADJ_ADDR 0x00000082
+#define R200_SS_HORZ_GUARD_DISCARD_ADJ_ADDR 0x00000083
+#define R200_SS_MAT_0_SHININESS 0x00000100
+#define R200_SS_MAT_1_SHININESS 0x00000101
+
+/*
+ * Matrix indices
+ */
+#define R200_MTX_MV 0
+#define R200_MTX_IMV 1
+#define R200_MTX_MVP 2
+#define R200_MTX_TEX0 3
+#define R200_MTX_TEX1 4
+#define R200_MTX_TEX2 5
+#define R200_MTX_TEX3 6
+#define R200_MTX_TEX4 7
+#define R200_MTX_TEX5 8
+
+/* Color formats for 2d packets
+ */
+#define R200_CP_COLOR_FORMAT_CI8 2
+#define R200_CP_COLOR_FORMAT_ARGB1555 3
+#define R200_CP_COLOR_FORMAT_RGB565 4
+#define R200_CP_COLOR_FORMAT_ARGB8888 6
+#define R200_CP_COLOR_FORMAT_RGB332 7
+#define R200_CP_COLOR_FORMAT_RGB8 9
+#define R200_CP_COLOR_FORMAT_ARGB4444 15
+
+/*
+ * CP type-3 packets
+ */
+#define R200_CP_CMD_NOP 0xC0001000
+#define R200_CP_CMD_NEXT_CHAR 0xC0001900
+#define R200_CP_CMD_PLY_NEXTSCAN 0xC0001D00
+#define R200_CP_CMD_SET_SCISSORS 0xC0001E00
+#define R200_CP_CMD_LOAD_MICROCODE 0xC0002400
+#define R200_CP_CMD_WAIT_FOR_IDLE 0xC0002600
+#define R200_CP_CMD_3D_DRAW_VBUF 0xC0002800
+#define R200_CP_CMD_3D_DRAW_IMMD 0xC0002900
+#define R200_CP_CMD_3D_DRAW_INDX 0xC0002A00
+#define R200_CP_CMD_LOAD_PALETTE 0xC0002C00
+#define R200_CP_CMD_3D_LOAD_VBPNTR 0xC0002F00
+#define R200_CP_CMD_INDX_BUFFER 0xC0003300
+#define R200_CP_CMD_3D_DRAW_VBUF_2 0xC0003400
+#define R200_CP_CMD_3D_DRAW_IMMD_2 0xC0003500
+#define R200_CP_CMD_3D_DRAW_INDX_2 0xC0003600
+#define R200_CP_CMD_PAINT 0xC0009100
+#define R200_CP_CMD_BITBLT 0xC0009200
+#define R200_CP_CMD_SMALLTEXT 0xC0009300
+#define R200_CP_CMD_HOSTDATA_BLT 0xC0009400
+#define R200_CP_CMD_POLYLINE 0xC0009500
+#define R200_CP_CMD_POLYSCANLINES 0xC0009800
+#define R200_CP_CMD_PAINT_MULTI 0xC0009A00
+#define R200_CP_CMD_BITBLT_MULTI 0xC0009B00
+#define R200_CP_CMD_TRANS_BITBLT 0xC0009C00
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_sanity.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_sanity.h
new file mode 100644
index 000000000..30852b490
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_sanity.h
@@ -0,0 +1,7 @@
+#ifndef R200_SANITY_H
+#define R200_SANITY_H
+
+extern int r200SanityCmdBuffer(r200ContextPtr rmesa,
+ int nbox, drm_clip_rect_t * boxes);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_state.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_state.h
new file mode 100644
index 000000000..3e1a9c8ba
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_state.h
@@ -0,0 +1,58 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R200_STATE_H__
+#define __R200_STATE_H__
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include "r200_context.h"
+
+extern void r200InitState(r200ContextPtr rmesa);
+extern void r200InitStateFuncs(struct dd_function_table *functions);
+extern void r200InitTnlFuncs(GLcontext * ctx);
+
+extern void r200UpdateMaterial(GLcontext * ctx);
+
+extern void r200UpdateViewportOffset(GLcontext * ctx);
+extern void r200UpdateWindow(GLcontext * ctx);
+
+extern void r200ValidateState(GLcontext * ctx);
+
+extern void r200PrintDirty(r200ContextPtr rmesa, const char *msg);
+
+extern void r200LightingSpaceChange(GLcontext * ctx);
+
+#endif
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_tcl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_tcl.h
new file mode 100644
index 000000000..4528cf152
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_tcl.h
@@ -0,0 +1,50 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tcl.h,v 1.2 2002/12/16 16:18:55 dawes Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R200_TCL_H__
+#define __R200_TCL_H__
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include "r200_context.h"
+
+extern void r200TclPrimitive(GLcontext * ctx, GLenum prim, int hw_prim);
+extern void r200EmitEltPrimitive(GLcontext * ctx, GLuint first, GLuint last,
+ GLuint flags);
+extern void r200EmitPrimitive(GLcontext * ctx, GLuint first, GLuint last,
+ GLuint flags);
+
+#endif
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_tex.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_tex.h
new file mode 100644
index 000000000..bc0dbc3fb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r200_tex.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_tex.h,v 1.1 2002/10/30 12:51:53 alanh Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R200_TEX_H__
+#define __R200_TEX_H__
+
+#ifdef GLX_DIRECT_RENDERING
+
+extern void r200UpdateTextureState(GLcontext * ctx);
+
+extern int r200UploadTexImages(r200ContextPtr rmesa, r200TexObjPtr t,
+ GLuint face);
+
+extern void r200DestroyTexObj(r200ContextPtr rmesa, r200TexObjPtr t);
+
+extern void r200InitTextureFuncs(struct dd_function_table *functions);
+
+#endif
+#endif /* __R200_TEX_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_cmdbuf.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_cmdbuf.c
new file mode 100644
index 000000000..d3c22fda1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_cmdbuf.c
@@ -0,0 +1,655 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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:
+ * Nicolai Haehnle <prefect_@gmx.net>
+ */
+
+#include "glheader.h"
+#include "state.h"
+#include "imports.h"
+#include "macros.h"
+#include "context.h"
+#include "swrast/swrast.h"
+#include "simple_list.h"
+
+#include "drm.h"
+#include "radeon_drm.h"
+
+#include "radeon_ioctl.h"
+#include "r300_context.h"
+#include "r300_ioctl.h"
+#include "radeon_reg.h"
+#include "r300_reg.h"
+#include "r300_cmdbuf.h"
+#include "r300_emit.h"
+
+
+// Set this to 1 for extremely verbose debugging of command buffers
+#define DEBUG_CMDBUF 0
+
+
+/**
+ * Send the current command buffer via ioctl to the hardware.
+ */
+int r300FlushCmdBufLocked(r300ContextPtr r300, const char* caller)
+{
+ int ret;
+ int i;
+ drm_radeon_cmd_buffer_t cmd;
+ int start;
+
+ if (r300->radeon.lost_context) {
+ start = 0;
+ r300->radeon.lost_context = GL_FALSE;
+ } else
+ start = r300->cmdbuf.count_reemit;
+
+ if (RADEON_DEBUG & DEBUG_IOCTL) {
+ fprintf(stderr, "%s from %s - %i cliprects\n",
+ __FUNCTION__, caller, r300->radeon.numClipRects);
+
+ if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_VERBOSE)
+ for (i = start; i < r300->cmdbuf.count_used; ++i)
+ fprintf(stderr, "%d: %08x\n", i,
+ r300->cmdbuf.cmd_buf[i]);
+ }
+
+ cmd.buf = (char*)(r300->cmdbuf.cmd_buf + start);
+ cmd.bufsz = (r300->cmdbuf.count_used - start) * 4;
+
+ if (r300->radeon.state.scissor.enabled) {
+ cmd.nbox = r300->radeon.state.scissor.numClipRects;
+ cmd.boxes = (drm_clip_rect_t *)r300->radeon.state.scissor.pClipRects;
+ } else {
+ cmd.nbox = r300->radeon.numClipRects;
+ cmd.boxes = (drm_clip_rect_t *)r300->radeon.pClipRects;
+ }
+
+ ret = drmCommandWrite(r300->radeon.dri.fd,
+ DRM_RADEON_CMDBUF, &cmd, sizeof(cmd));
+
+ if (RADEON_DEBUG & DEBUG_SYNC) {
+ fprintf(stderr, "Syncing in %s (from %s)\n\n", __FUNCTION__, caller);
+ radeonWaitForIdleLocked(&r300->radeon);
+ }
+
+ r300->dma.nr_released_bufs = 0;
+ r300->cmdbuf.count_used = 0;
+ r300->cmdbuf.count_reemit = 0;
+
+ return ret;
+}
+
+
+int r300FlushCmdBuf(r300ContextPtr r300, const char* caller)
+{
+ int ret;
+ int i;
+ drm_radeon_cmd_buffer_t cmd;
+ int start;
+
+ LOCK_HARDWARE(&r300->radeon);
+
+ ret=r300FlushCmdBufLocked(r300, caller);
+
+ UNLOCK_HARDWARE(&r300->radeon);
+
+ if (ret) {
+ fprintf(stderr, "drmRadeonCmdBuffer: %d (exiting)\n", ret);
+ exit(ret);
+ }
+
+ return ret;
+}
+
+
+static void print_state_atom(struct r300_state_atom *state, int dwords)
+{
+ int i;
+
+ fprintf(stderr, " emit %s/%d/%d\n", state->name, dwords, state->cmd_size);
+
+ if (RADEON_DEBUG & DEBUG_VERBOSE)
+ for (i = 0; i < dwords; i++)
+ fprintf(stderr, " %s[%d]: %08X\n", state->name, i,
+ state->cmd[i]);
+}
+
+/**
+ * Emit all atoms with a dirty field equal to dirty.
+ *
+ * The caller must have ensured that there is enough space in the command
+ * buffer.
+ */
+static __inline__ void r300DoEmitState(r300ContextPtr r300, GLboolean dirty)
+{
+ struct r300_state_atom* atom;
+ uint32_t* dest;
+
+ dest = r300->cmdbuf.cmd_buf + r300->cmdbuf.count_used;
+
+ if (DEBUG_CMDBUF && RADEON_DEBUG & DEBUG_STATE) {
+ foreach(atom, &r300->hw.atomlist) {
+ if ((atom->dirty || r300->hw.all_dirty) == dirty) {
+ int dwords = (*atom->check)(r300, atom);
+
+ if (dwords)
+ print_state_atom(atom, dwords);
+ else
+ fprintf(stderr, " skip state %s\n",
+ atom->name);
+ }
+ }
+ }
+
+
+ /* Emit WAIT */
+ *dest = cmdwait(R300_WAIT_3D | R300_WAIT_3D_CLEAN);
+ dest ++;
+ r300->cmdbuf.count_used ++;
+
+ /* Emit END3D */
+ *dest = cmdpacify();
+ dest ++;
+ r300->cmdbuf.count_used ++;
+
+ /* Emit actual atoms */
+
+ foreach(atom, &r300->hw.atomlist) {
+ if ((atom->dirty || r300->hw.all_dirty) == dirty) {
+ int dwords = (*atom->check)(r300, atom);
+
+ if (dwords) {
+ memcpy(dest, atom->cmd, dwords*4);
+ dest += dwords;
+ r300->cmdbuf.count_used += dwords;
+ atom->dirty = GL_FALSE;
+ }
+ }
+ }
+}
+
+/**
+ * Copy dirty hardware state atoms into the command buffer.
+ *
+ * We also copy out clean state if we're at the start of a buffer. That makes
+ * it easy to recover from lost contexts.
+ */
+void r300EmitState(r300ContextPtr r300)
+{
+ if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_PRIMS))
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (r300->cmdbuf.count_used && !r300->hw.is_dirty && !r300->hw.all_dirty)
+ return;
+
+ /* To avoid going across the entire set of states multiple times, just check
+ * for enough space for the case of emitting all state, and inline the
+ * r300AllocCmdBuf code here without all the checks.
+ */
+ r300EnsureCmdBufSpace(r300, r300->hw.max_state_size, __FUNCTION__);
+
+ if (!r300->cmdbuf.count_used) {
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "Begin reemit state\n");
+
+ r300DoEmitState(r300, GL_FALSE);
+ r300->cmdbuf.count_reemit = r300->cmdbuf.count_used;
+ }
+
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "Begin dirty state\n");
+
+ r300DoEmitState(r300, GL_TRUE);
+
+ assert(r300->cmdbuf.count_used < r300->cmdbuf.size);
+
+ r300->hw.is_dirty = GL_FALSE;
+ r300->hw.all_dirty = GL_FALSE;
+}
+
+#define CHECK( NM, COUNT ) \
+static int check_##NM( r300ContextPtr r300, \
+ struct r300_state_atom* atom ) \
+{ \
+ (void) atom; (void) r300; \
+ return (COUNT); \
+}
+
+#define packet0_count(ptr) (((drm_r300_cmd_header_t*)(ptr))->packet0.count)
+#define vpu_count(ptr) (((drm_r300_cmd_header_t*)(ptr))->vpu.count)
+
+CHECK( always, atom->cmd_size )
+CHECK( never, 0 )
+CHECK( variable, packet0_count(atom->cmd) ? (1 + packet0_count(atom->cmd)) : 0 )
+CHECK( vpu, vpu_count(atom->cmd) ? (1 + vpu_count(atom->cmd)*4) : 0 )
+
+#undef packet0_count
+#undef vpu_count
+
+#define ALLOC_STATE( ATOM, CHK, SZ, NM, IDX ) \
+ do { \
+ r300->hw.ATOM.cmd_size = (SZ); \
+ r300->hw.ATOM.cmd = (uint32_t*)CALLOC((SZ) * sizeof(uint32_t)); \
+ r300->hw.ATOM.name = (NM); \
+ r300->hw.ATOM.idx = (IDX); \
+ r300->hw.ATOM.check = check_##CHK; \
+ r300->hw.ATOM.dirty = GL_FALSE; \
+ r300->hw.max_state_size += (SZ); \
+ } while (0)
+
+
+/**
+ * Allocate memory for the command buffer and initialize the state atom
+ * list. Note that the initial hardware state is set by r300InitState().
+ */
+void r300InitCmdBuf(r300ContextPtr r300)
+{
+ int size, i, mtu;
+
+ r300->hw.max_state_size = 2; /* reserve extra space for WAIT_IDLE */
+
+ mtu = r300->radeon.glCtx->Const.MaxTextureUnits;
+ if (RADEON_DEBUG & DEBUG_TEXTURE) {
+ fprintf(stderr, "Using %d maximum texture units..\n", mtu);
+ }
+
+ /* Initialize state atoms */
+ ALLOC_STATE( vpt, always, R300_VPT_CMDSIZE, "vpt", 0 );
+ r300->hw.vpt.cmd[R300_VPT_CMD_0] = cmdpacket0(R300_SE_VPORT_XSCALE, 6);
+ ALLOC_STATE( unk2080, always, 2, "unk2080", 0 );
+ r300->hw.unk2080.cmd[0] = cmdpacket0(0x2080, 1);
+ ALLOC_STATE( vte, always, 3, "vte", 0 );
+ r300->hw.vte.cmd[0] = cmdpacket0(R300_SE_VTE_CNTL, 2);
+ ALLOC_STATE( unk2134, always, 3, "unk2134", 0 );
+ r300->hw.unk2134.cmd[0] = cmdpacket0(0x2134, 2);
+ ALLOC_STATE( unk2140, always, 2, "unk2140", 0 );
+ r300->hw.unk2140.cmd[0] = cmdpacket0(0x2140, 1);
+ ALLOC_STATE( vir[0], variable, R300_VIR_CMDSIZE, "vir/0", 0 );
+ r300->hw.vir[0].cmd[R300_VIR_CMD_0] = cmdpacket0(R300_VAP_INPUT_ROUTE_0_0, 1);
+ ALLOC_STATE( vir[1], variable, R300_VIR_CMDSIZE, "vir/1", 1 );
+ r300->hw.vir[1].cmd[R300_VIR_CMD_0] = cmdpacket0(R300_VAP_INPUT_ROUTE_1_0, 1);
+ ALLOC_STATE( vic, always, R300_VIC_CMDSIZE, "vic", 0 );
+ r300->hw.vic.cmd[R300_VIC_CMD_0] = cmdpacket0(R300_VAP_INPUT_CNTL_0, 2);
+ ALLOC_STATE( unk21DC, always, 2, "unk21DC", 0 );
+ r300->hw.unk21DC.cmd[0] = cmdpacket0(0x21DC, 1);
+ ALLOC_STATE( unk221C, always, 2, "unk221C", 0 );
+ r300->hw.unk221C.cmd[0] = cmdpacket0(0x221C, 1);
+ ALLOC_STATE( unk2220, always, 5, "unk2220", 0 );
+ r300->hw.unk2220.cmd[0] = cmdpacket0(0x2220, 4);
+ ALLOC_STATE( unk2288, always, 2, "unk2288", 0 );
+ r300->hw.unk2288.cmd[0] = cmdpacket0(0x2288, 1);
+ ALLOC_STATE( vof, always, R300_VOF_CMDSIZE, "vof", 0 );
+ r300->hw.vof.cmd[R300_VOF_CMD_0] = cmdpacket0(R300_VAP_OUTPUT_VTX_FMT_0, 2);
+ ALLOC_STATE( pvs, always, R300_PVS_CMDSIZE, "pvs", 0 );
+ r300->hw.pvs.cmd[R300_PVS_CMD_0] = cmdpacket0(R300_VAP_PVS_CNTL_1, 3);
+ ALLOC_STATE( gb_enable, always, 2, "gb_enable", 0 );
+ r300->hw.gb_enable.cmd[0] = cmdpacket0(R300_GB_ENABLE, 1);
+ ALLOC_STATE( gb_misc, always, R300_GB_MISC_CMDSIZE, "gb_misc", 0 );
+ r300->hw.gb_misc.cmd[0] = cmdpacket0(R300_GB_MSPOS0, 5);
+ ALLOC_STATE( txe, always, R300_TXE_CMDSIZE, "txe", 0 );
+ r300->hw.txe.cmd[R300_TXE_CMD_0] = cmdpacket0(R300_TX_ENABLE, 1);
+ ALLOC_STATE( unk4200, always, 5, "unk4200", 0 );
+ r300->hw.unk4200.cmd[0] = cmdpacket0(0x4200, 4);
+ ALLOC_STATE( unk4214, always, 2, "unk4214", 0 );
+ r300->hw.unk4214.cmd[0] = cmdpacket0(0x4214, 1);
+ ALLOC_STATE( ps, always, R300_PS_CMDSIZE, "ps", 0 );
+ r300->hw.ps.cmd[0] = cmdpacket0(R300_RE_POINTSIZE, 1);
+ ALLOC_STATE( unk4230, always, 4, "unk4230", 0 );
+ r300->hw.unk4230.cmd[0] = cmdpacket0(0x4230, 3);
+ ALLOC_STATE( lcntl, always, 2, "lcntl", 0 );
+ r300->hw.lcntl.cmd[0] = cmdpacket0(R300_RE_LINE_CNT, 1);
+ ALLOC_STATE( unk4260, always, 4, "unk4260", 0 );
+ r300->hw.unk4260.cmd[0] = cmdpacket0(0x4260, 3);
+ ALLOC_STATE( unk4274, always, 5, "unk4274", 0 );
+ r300->hw.unk4274.cmd[0] = cmdpacket0(0x4274, 4);
+ ALLOC_STATE( unk4288, always, 6, "unk4288", 0 );
+ r300->hw.unk4288.cmd[0] = cmdpacket0(0x4288, 5);
+ ALLOC_STATE( unk42A0, always, 2, "unk42A0", 0 );
+ r300->hw.unk42A0.cmd[0] = cmdpacket0(0x42A0, 1);
+ ALLOC_STATE( zbs, always, R300_ZBS_CMDSIZE, "zbs", 0 );
+ r300->hw.zbs.cmd[R300_ZBS_CMD_0] = cmdpacket0(R300_RE_ZBIAS_T_FACTOR, 4);
+ ALLOC_STATE( unk42B4, always, 2, "unk42B4", 0 );
+ r300->hw.unk42B4.cmd[0] = cmdpacket0(0x42B4, 1);
+ ALLOC_STATE( cul, always, R300_CUL_CMDSIZE, "cul", 0 );
+ r300->hw.cul.cmd[R300_CUL_CMD_0] = cmdpacket0(R300_RE_CULL_CNTL, 1);
+ ALLOC_STATE( unk42C0, always, 3, "unk42C0", 0 );
+ r300->hw.unk42C0.cmd[0] = cmdpacket0(0x42C0, 2);
+ ALLOC_STATE( rc, always, R300_RC_CMDSIZE, "rc", 0 );
+ r300->hw.rc.cmd[R300_RC_CMD_0] = cmdpacket0(R300_RS_CNTL_0, 2);
+ ALLOC_STATE( ri, always, R300_RI_CMDSIZE, "ri", 0 );
+ r300->hw.ri.cmd[R300_RI_CMD_0] = cmdpacket0(R300_RS_INTERP_0, 8);
+ ALLOC_STATE( rr, variable, R300_RR_CMDSIZE, "rr", 0 );
+ r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R300_RS_ROUTE_0, 1);
+ ALLOC_STATE( unk43A4, always, 3, "unk43A4", 0 );
+ r300->hw.unk43A4.cmd[0] = cmdpacket0(0x43A4, 2);
+ ALLOC_STATE( unk43E8, always, 2, "unk43E8", 0 );
+ r300->hw.unk43E8.cmd[0] = cmdpacket0(0x43E8, 1);
+ ALLOC_STATE( fp, always, R300_FP_CMDSIZE, "fp", 0 );
+ r300->hw.fp.cmd[R300_FP_CMD_0] = cmdpacket0(R300_PFS_CNTL_0, 3);
+ r300->hw.fp.cmd[R300_FP_CMD_1] = cmdpacket0(R300_PFS_NODE_0, 4);
+ ALLOC_STATE( fpt, variable, R300_FPT_CMDSIZE, "fpt", 0 );
+ r300->hw.fpt.cmd[R300_FPT_CMD_0] = cmdpacket0(R300_PFS_TEXI_0, 0);
+ ALLOC_STATE( unk46A4, always, 6, "unk46A4", 0 );
+ r300->hw.unk46A4.cmd[0] = cmdpacket0(0x46A4, 5);
+ ALLOC_STATE( fpi[0], variable, R300_FPI_CMDSIZE, "fpi/0", 0 );
+ r300->hw.fpi[0].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR0_0, 1);
+ ALLOC_STATE( fpi[1], variable, R300_FPI_CMDSIZE, "fpi/1", 1 );
+ r300->hw.fpi[1].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR1_0, 1);
+ ALLOC_STATE( fpi[2], variable, R300_FPI_CMDSIZE, "fpi/2", 2 );
+ r300->hw.fpi[2].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR2_0, 1);
+ ALLOC_STATE( fpi[3], variable, R300_FPI_CMDSIZE, "fpi/3", 3 );
+ r300->hw.fpi[3].cmd[R300_FPI_CMD_0] = cmdpacket0(R300_PFS_INSTR3_0, 1);
+ ALLOC_STATE( unk4BC0, always, 2, "unk4BC0", 0 );
+ r300->hw.unk4BC0.cmd[0] = cmdpacket0(0x4BC0, 1);
+ ALLOC_STATE( unk4BC8, always, 4, "unk4BC8", 0 );
+ r300->hw.unk4BC8.cmd[0] = cmdpacket0(0x4BC8, 3);
+ ALLOC_STATE( at, always, R300_AT_CMDSIZE, "at", 0 );
+ r300->hw.at.cmd[R300_AT_CMD_0] = cmdpacket0(R300_PP_ALPHA_TEST, 2);
+ ALLOC_STATE( unk4BD8, always, 2, "unk4BD8", 0 );
+ r300->hw.unk4BD8.cmd[0] = cmdpacket0(0x4BD8, 1);
+ ALLOC_STATE( fpp, variable, R300_FPP_CMDSIZE, "fpp", 0 );
+ r300->hw.fpp.cmd[R300_FPP_CMD_0] = cmdpacket0(R300_PFS_PARAM_0_X, 0);
+ ALLOC_STATE( unk4E00, always, 2, "unk4E00", 0 );
+ r300->hw.unk4E00.cmd[0] = cmdpacket0(0x4E00, 1);
+ ALLOC_STATE( bld, always, R300_BLD_CMDSIZE, "bld", 0 );
+ r300->hw.bld.cmd[R300_BLD_CMD_0] = cmdpacket0(R300_RB3D_CBLEND, 2);
+ ALLOC_STATE( cmk, always, R300_CMK_CMDSIZE, "cmk", 0 );
+ r300->hw.cmk.cmd[R300_CMK_CMD_0] = cmdpacket0(R300_RB3D_COLORMASK, 1);
+ ALLOC_STATE( unk4E10, always, 4, "unk4E10", 0 );
+ r300->hw.unk4E10.cmd[0] = cmdpacket0(0x4E10, 3);
+ ALLOC_STATE( cb, always, R300_CB_CMDSIZE, "cb", 0 );
+ r300->hw.cb.cmd[R300_CB_CMD_0] = cmdpacket0(R300_RB3D_COLOROFFSET0, 1);
+ r300->hw.cb.cmd[R300_CB_CMD_1] = cmdpacket0(R300_RB3D_COLORPITCH0, 1);
+ ALLOC_STATE( unk4E50, always, 10, "unk4E50", 0 );
+ r300->hw.unk4E50.cmd[0] = cmdpacket0(0x4E50, 9);
+ ALLOC_STATE( unk4E88, always, 2, "unk4E88", 0 );
+ r300->hw.unk4E88.cmd[0] = cmdpacket0(0x4E88, 1);
+ ALLOC_STATE( unk4EA0, always, 3, "unk4EA0 R350 only", 0 );
+ r300->hw.unk4EA0.cmd[0] = cmdpacket0(0x4EA0, 2);
+ ALLOC_STATE( zs, always, R300_ZS_CMDSIZE, "zstencil", 0 );
+ r300->hw.zs.cmd[R300_ZS_CMD_0] = cmdpacket0(R300_RB3D_ZSTENCIL_CNTL_0, 3);
+ ALLOC_STATE( unk4F10, always, 5, "unk4F10", 0 );
+ r300->hw.unk4F10.cmd[0] = cmdpacket0(0x4F10, 4);
+ ALLOC_STATE( zb, always, R300_ZB_CMDSIZE, "zb", 0 );
+ r300->hw.zb.cmd[R300_ZB_CMD_0] = cmdpacket0(R300_RB3D_DEPTHOFFSET, 2);
+ ALLOC_STATE( unk4F28, always, 2, "unk4F28", 0 );
+ r300->hw.unk4F28.cmd[0] = cmdpacket0(0x4F28, 1);
+ ALLOC_STATE( unk4F30, always, 3, "unk4F30", 0 );
+ r300->hw.unk4F30.cmd[0] = cmdpacket0(0x4F30, 2);
+ ALLOC_STATE( unk4F44, always, 2, "unk4F44", 0 );
+ r300->hw.unk4F44.cmd[0] = cmdpacket0(0x4F44, 1);
+ ALLOC_STATE( unk4F54, always, 2, "unk4F54", 0 );
+ r300->hw.unk4F54.cmd[0] = cmdpacket0(0x4F54, 1);
+
+ ALLOC_STATE( vpi, vpu, R300_VPI_CMDSIZE, "vpi", 0 );
+ r300->hw.vpi.cmd[R300_VPI_CMD_0] = cmdvpu(R300_PVS_UPLOAD_PROGRAM, 0);
+ ALLOC_STATE( vpp, vpu, R300_VPP_CMDSIZE, "vpp", 0 );
+ r300->hw.vpp.cmd[R300_VPP_CMD_0] = cmdvpu(R300_PVS_UPLOAD_PARAMETERS, 0);
+ ALLOC_STATE( vps, vpu, R300_VPS_CMDSIZE, "vps", 0 );
+ r300->hw.vps.cmd[R300_VPS_CMD_0] = cmdvpu(R300_PVS_UPLOAD_POINTSIZE, 1);
+
+ /* Textures */
+ ALLOC_STATE( tex.filter, variable, mtu+1, "tex_filter", 0 );
+ r300->hw.tex.filter.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_FILTER_0, 0);
+
+ ALLOC_STATE( tex.unknown1, variable, mtu+1, "tex_unknown1", 0 );
+ r300->hw.tex.unknown1.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_UNK1_0, 0);
+
+ ALLOC_STATE( tex.size, variable, mtu+1, "tex_size", 0 );
+ r300->hw.tex.size.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_SIZE_0, 0);
+
+ ALLOC_STATE( tex.format, variable, mtu+1, "tex_format", 0 );
+ r300->hw.tex.format.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_FORMAT_0, 0);
+
+ ALLOC_STATE( tex.offset, variable, mtu+1, "tex_offset", 0 );
+ r300->hw.tex.offset.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_OFFSET_0, 0);
+
+ ALLOC_STATE( tex.unknown4, variable, mtu+1, "tex_unknown4", 0 );
+ r300->hw.tex.unknown4.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_UNK4_0, 0);
+
+ ALLOC_STATE( tex.border_color, variable, mtu+1, "tex_border_color", 0 );
+ r300->hw.tex.border_color.cmd[R300_TEX_CMD_0] = cmdpacket0(R300_TX_BORDER_COLOR_0, 0);
+
+
+ /* Setup the atom linked list */
+ make_empty_list(&r300->hw.atomlist);
+ r300->hw.atomlist.name = "atom-list";
+
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.vpt);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2080);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.vte);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2134);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2140);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.vir[0]);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.vir[1]);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.vic);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk21DC);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk221C);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2220);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk2288);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.vof);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.pvs);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.gb_enable);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.gb_misc);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.txe);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4200);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4214);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.ps);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4230);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.lcntl);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4260);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4274);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4288);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk42A0);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.zbs);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk42B4);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.cul);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk42C0);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.rc);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.ri);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.rr);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk43A4);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk43E8);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.fp);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.fpt);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk46A4);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.fpi[0]);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.fpi[1]);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.fpi[2]);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.fpi[3]);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4BC0);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4BC8);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.at);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4BD8);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.fpp);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4E00);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.bld);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.cmk);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4E10);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.cb);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4E50);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4E88);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4EA0);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.zs);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4F10);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.zb);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4F28);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4F30);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4F44);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.unk4F54);
+
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.vpi);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.vpp);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.vps);
+
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.filter);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.unknown1);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.size);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.format);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.offset);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.unknown4);
+ insert_at_tail(&r300->hw.atomlist, &r300->hw.tex.border_color);
+
+ r300->hw.is_dirty = GL_TRUE;
+ r300->hw.all_dirty = GL_TRUE;
+
+ /* Initialize command buffer */
+ size = 256 * driQueryOptioni(&r300->radeon.optionCache, "command_buffer_size");
+ if (size < 2*r300->hw.max_state_size) {
+ size = 2*r300->hw.max_state_size+65535;
+ }
+ if (size > 64*256)
+ size = 64*256;
+
+ if (RADEON_DEBUG & (DEBUG_IOCTL|DEBUG_DMA)) {
+ fprintf(stderr, "sizeof(drm_r300_cmd_header_t)=%d\n",
+ sizeof(drm_r300_cmd_header_t));
+ fprintf(stderr, "sizeof(drm_radeon_cmd_buffer_t)=%d\n",
+ sizeof(drm_radeon_cmd_buffer_t));
+ fprintf(stderr,
+ "Allocating %d bytes command buffer (max state is %d bytes)\n",
+ size*4, r300->hw.max_state_size*4);
+ }
+
+ r300->cmdbuf.size = size;
+ r300->cmdbuf.cmd_buf = (uint32_t*)CALLOC(size*4);
+ r300->cmdbuf.count_used = 0;
+ r300->cmdbuf.count_reemit = 0;
+}
+
+
+/**
+ * Destroy the command buffer and state atoms.
+ */
+void r300DestroyCmdBuf(r300ContextPtr r300)
+{
+ struct r300_state_atom* atom;
+
+ FREE(r300->cmdbuf.cmd_buf);
+
+ foreach(atom, &r300->hw.atomlist) {
+ FREE(atom->cmd);
+ }
+}
+
+void r300EmitBlit(r300ContextPtr rmesa,
+ GLuint color_fmt,
+ GLuint src_pitch,
+ GLuint src_offset,
+ GLuint dst_pitch,
+ GLuint dst_offset,
+ GLint srcx, GLint srcy,
+ GLint dstx, GLint dsty, GLuint w, GLuint h)
+{
+ drm_radeon_cmd_header_t *cmd;
+
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr,
+ "%s src %x/%x %d,%d dst: %x/%x %d,%d sz: %dx%d\n",
+ __FUNCTION__, src_pitch, src_offset, srcx, srcy,
+ dst_pitch, dst_offset, dstx, dsty, w, h);
+
+ assert((src_pitch & 63) == 0);
+ assert((dst_pitch & 63) == 0);
+ assert((src_offset & 1023) == 0);
+ assert((dst_offset & 1023) == 0);
+ assert(w < (1 << 16));
+ assert(h < (1 << 16));
+
+ cmd =
+ (drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, 8,
+ __FUNCTION__);
+
+ cmd[0].header.cmd_type = R300_CMD_PACKET3;
+ cmd[1].i = R200_CP_CMD_BITBLT_MULTI | (5 << 16);
+ cmd[2].i = (RADEON_GMC_SRC_PITCH_OFFSET_CNTL |
+ RADEON_GMC_DST_PITCH_OFFSET_CNTL |
+ RADEON_GMC_BRUSH_NONE |
+ (color_fmt << 8) |
+ RADEON_GMC_SRC_DATATYPE_COLOR |
+ RADEON_ROP3_S |
+ RADEON_DP_SRC_SOURCE_MEMORY |
+ RADEON_GMC_CLR_CMP_CNTL_DIS | RADEON_GMC_WR_MSK_DIS);
+
+ cmd[3].i = ((src_pitch / 64) << 22) | (src_offset >> 10);
+ cmd[4].i = ((dst_pitch / 64) << 22) | (dst_offset >> 10);
+ cmd[5].i = (srcx << 16) | srcy;
+ cmd[6].i = (dstx << 16) | dsty; /* dst */
+ cmd[7].i = (w << 16) | h;
+}
+
+void r300EmitWait(r300ContextPtr rmesa, GLuint flags)
+{
+ if (rmesa->radeon.dri.drmMinor >= 6) {
+ drm_radeon_cmd_header_t *cmd;
+
+ assert(!(flags & ~(R300_WAIT_2D | R300_WAIT_3D)));
+
+ cmd =
+ (drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa,
+ 1,
+ __FUNCTION__);
+ cmd[0].i = 0;
+ cmd[0].wait.cmd_type = R300_CMD_WAIT;
+ cmd[0].wait.flags = flags;
+ }
+}
+
+void r300EmitAOS(r300ContextPtr rmesa, GLuint nr, GLuint offset)
+{
+ int sz = 1 + (nr >> 1) * 3 + (nr & 1) * 2;
+ int i;
+ LOCAL_VARS
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s: nr=%d, ofs=0x%08x\n", __func__, nr, offset);
+
+ start_packet3(RADEON_CP_PACKET3_3D_LOAD_VBPNTR, sz-1);
+ e32(nr);
+ for(i=0;i+1<nr;i+=2){
+ e32( (rmesa->state.aos[i].aos_size << 0)
+ |(rmesa->state.aos[i].aos_stride << 8)
+ |(rmesa->state.aos[i+1].aos_size << 16)
+ |(rmesa->state.aos[i+1].aos_stride << 24)
+ );
+ e32(rmesa->state.aos[i].aos_offset+offset*4*rmesa->state.aos[i].aos_stride);
+ e32(rmesa->state.aos[i+1].aos_offset+offset*4*rmesa->state.aos[i+1].aos_stride);
+ }
+ if(nr & 1){
+ e32( (rmesa->state.aos[nr-1].aos_size << 0)
+ |(rmesa->state.aos[nr-1].aos_stride << 8)
+ );
+ e32(rmesa->state.aos[nr-1].aos_offset+offset*4*rmesa->state.aos[nr-1].aos_stride);
+ }
+
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_cmdbuf.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_cmdbuf.h
new file mode 100644
index 000000000..b471f2ac4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_cmdbuf.h
@@ -0,0 +1,118 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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:
+ * Nicolai Haehnle <prefect_@gmx.net>
+ */
+
+#ifndef __R300_CMDBUF_H__
+#define __R300_CMDBUF_H__
+
+#include "r300_context.h"
+
+
+extern int r300FlushCmdBufLocked(r300ContextPtr r300, const char* caller);
+extern int r300FlushCmdBuf(r300ContextPtr r300, const char* caller);
+
+extern void r300EmitState(r300ContextPtr r300);
+
+extern void r300InitCmdBuf(r300ContextPtr r300);
+extern void r300DestroyCmdBuf(r300ContextPtr r300);
+
+extern void r300EmitAOS(r300ContextPtr rmesa, GLuint nr, GLuint offset);
+
+
+/**
+ * Make sure that enough space is available in the command buffer
+ * by flushing if necessary.
+ */
+static __inline__ void r300EnsureCmdBufSpace(r300ContextPtr r300,
+ int dwords, const char* caller)
+{
+ assert(dwords < r300->cmdbuf.size);
+
+ if (r300->cmdbuf.count_used + dwords > r300->cmdbuf.size)
+ r300FlushCmdBuf(r300, caller);
+}
+
+
+/**
+ * Allocate the given number of dwords in the command buffer and return
+ * a pointer to the allocated area.
+ * When necessary, these functions cause a flush. r300AllocCmdBuf() also
+ * causes state reemission after a flush. This is necessary to ensure
+ * correct hardware state after an unlock.
+ */
+static __inline__ uint32_t* r300RawAllocCmdBuf(r300ContextPtr r300,
+ int dwords, const char* caller)
+{
+ uint32_t* ptr;
+
+ r300EnsureCmdBufSpace(r300, dwords, caller);
+
+ ptr = &r300->cmdbuf.cmd_buf[r300->cmdbuf.count_used];
+ r300->cmdbuf.count_used += dwords;
+ return ptr;
+}
+
+static __inline__ uint32_t* r300AllocCmdBuf(r300ContextPtr r300,
+ int dwords, const char* caller)
+{
+ uint32_t* ptr;
+
+ r300EnsureCmdBufSpace(r300, dwords, caller);
+
+ if (!r300->cmdbuf.count_used) {
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "Reemit state after flush (from %s)\n",
+ caller);
+ r300EmitState(r300);
+ }
+
+ ptr = &r300->cmdbuf.cmd_buf[r300->cmdbuf.count_used];
+ r300->cmdbuf.count_used += dwords;
+ return ptr;
+}
+
+extern void r300EmitBlit(r300ContextPtr rmesa,
+ GLuint color_fmt,
+ GLuint src_pitch,
+ GLuint src_offset,
+ GLuint dst_pitch,
+ GLuint dst_offset,
+ GLint srcx, GLint srcy,
+ GLint dstx, GLint dsty, GLuint w, GLuint h);
+
+extern void r300EmitWait(r300ContextPtr rmesa, GLuint flags);
+extern void r300EmitLOAD_VBPNTR(r300ContextPtr rmesa, int start);
+extern void r300EmitVertexShader(r300ContextPtr rmesa);
+extern void r300EmitPixelShader(r300ContextPtr rmesa);
+
+#endif /* __R300_CMDBUF_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_context.c
new file mode 100644
index 000000000..ba0c55069
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_context.c
@@ -0,0 +1,453 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ * Nicolai Haehnle <prefect_@gmx.net>
+ */
+#include "glheader.h"
+#include "api_arrayelt.h"
+#include "context.h"
+#include "simple_list.h"
+#include "imports.h"
+#include "matrix.h"
+#include "extensions.h"
+#include "state.h"
+#include "bufferobj.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+
+#include "drivers/common/driverfuncs.h"
+
+#include "radeon_ioctl.h"
+#include "radeon_span.h"
+#include "r300_context.h"
+#include "r300_cmdbuf.h"
+#include "r300_state.h"
+#include "r300_ioctl.h"
+#include "r300_tex.h"
+
+#include "vblank.h"
+#include "utils.h"
+#include "xmlpool.h" /* for symbolic values of enum-type options */
+
+/* hw_tcl_on derives from future_hw_tcl_on when its safe to change it. */
+int future_hw_tcl_on=0;
+int hw_tcl_on=0;
+
+#define need_GL_ARB_multisample
+#define need_GL_ARB_texture_compression
+#define need_GL_ARB_vertex_buffer_object
+#define need_GL_ARB_vertex_program
+#define need_GL_EXT_blend_minmax
+#define need_GL_EXT_secondary_color
+#define need_GL_EXT_blend_equation_separate
+#define need_GL_EXT_blend_func_separate
+#define need_GL_NV_vertex_program
+#include "extension_helper.h"
+
+const struct dri_extension card_extensions[] = {
+ {"GL_ARB_multisample", GL_ARB_multisample_functions},
+ {"GL_ARB_multitexture", NULL},
+ {"GL_ARB_texture_border_clamp", NULL},
+ {"GL_ARB_texture_compression", GL_ARB_texture_compression_functions},
+/* disable until we support it, fixes a few things in ut2004 */
+/* {"GL_ARB_texture_cube_map", NULL}, */
+ {"GL_ARB_texture_env_add", NULL},
+ {"GL_ARB_texture_env_combine", NULL},
+ {"GL_ARB_texture_env_crossbar", NULL},
+ {"GL_ARB_texture_env_dot3", NULL},
+ {"GL_ARB_texture_mirrored_repeat", NULL},
+ {"GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions},
+ {"GL_ARB_vertex_program", GL_ARB_vertex_program_functions},
+#if USE_ARB_F_P == 1
+ {"GL_ARB_fragment_program", NULL},
+#endif
+ {"GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions},
+ {"GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions},
+ {"GL_EXT_blend_minmax", GL_EXT_blend_minmax_functions},
+ {"GL_EXT_blend_subtract", NULL},
+ {"GL_EXT_secondary_color", GL_EXT_secondary_color_functions},
+ {"GL_EXT_stencil_wrap", NULL},
+ {"GL_EXT_texture_edge_clamp", NULL},
+ {"GL_EXT_texture_env_combine", NULL},
+ {"GL_EXT_texture_env_dot3", NULL},
+ {"GL_EXT_texture_filter_anisotropic", NULL},
+ {"GL_EXT_texture_lod_bias", NULL},
+ {"GL_EXT_texture_mirror_clamp", NULL},
+ {"GL_EXT_texture_rectangle", NULL},
+ {"GL_ATI_texture_env_combine3", NULL},
+ {"GL_ATI_texture_mirror_once", NULL},
+ {"GL_MESA_pack_invert", NULL},
+ {"GL_MESA_ycbcr_texture", NULL},
+ {"GL_NV_blend_square", NULL},
+ {"GL_NV_vertex_program", GL_NV_vertex_program_functions},
+ {"GL_SGIS_generate_mipmap", NULL},
+ {NULL, NULL}
+};
+
+extern struct tnl_pipeline_stage _r300_render_stage;
+extern struct tnl_pipeline_stage _r300_tcl_stage;
+
+static const struct tnl_pipeline_stage *r300_pipeline[] = {
+
+ /* Try and go straight to t&l
+ */
+ &_r300_tcl_stage,
+
+ /* Catch any t&l fallbacks
+ */
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ &_tnl_arb_vertex_program_stage,
+ &_tnl_vertex_program_stage,
+
+ /* Try again to go to tcl?
+ * - no good for asymmetric-twoside (do with multipass)
+ * - no good for asymmetric-unfilled (do with multipass)
+ * - good for material
+ * - good for texgen
+ * - need to manipulate a bit of state
+ *
+ * - worth it/not worth it?
+ */
+
+ /* Else do them here.
+ */
+ &_r300_render_stage,
+ &_tnl_render_stage, /* FALLBACK */
+ 0,
+};
+
+static void r300BufferData(GLcontext *ctx, GLenum target, GLsizeiptrARB size,
+ const GLvoid *data, GLenum usage, struct gl_buffer_object *obj)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ drm_radeon_mem_alloc_t alloc;
+ int offset, ret;
+
+ /* Free previous buffer */
+ if (obj->OnCard) {
+ drm_radeon_mem_free_t memfree;
+
+ memfree.region = RADEON_MEM_REGION_GART;
+ memfree.region_offset = (char *)obj->Data - (char *)rmesa->radeon.radeonScreen->gartTextures.map;
+
+ ret = drmCommandWrite(rmesa->radeon.radeonScreen->driScreen->fd,
+ DRM_RADEON_FREE, &memfree, sizeof(memfree));
+
+ if (ret) {
+ WARN_ONCE("Failed to free GART memroy!\n");
+ }
+ obj->OnCard = GL_FALSE;
+ }
+
+ alloc.region = RADEON_MEM_REGION_GART;
+ alloc.alignment = 4;
+ alloc.size = size;
+ alloc.region_offset = &offset;
+
+ ret = drmCommandWriteRead( rmesa->radeon.dri.fd, DRM_RADEON_ALLOC, &alloc, sizeof(alloc));
+ if (ret) {
+ WARN_ONCE("Ran out of GART memory!\n");
+ obj->Data = NULL;
+ _mesa_buffer_data(ctx, target, size, data, usage, obj);
+ return ;
+ }
+ obj->Data = ((char *)rmesa->radeon.radeonScreen->gartTextures.map) + offset;
+
+ if (data)
+ memcpy(obj->Data, data, size);
+
+ obj->Size = size;
+ obj->Usage = usage;
+ obj->OnCard = GL_TRUE;
+#if 0
+ fprintf(stderr, "allocated %d bytes at %p, offset=%d\n", size, obj->Data, offset);
+#endif
+}
+
+static void r300DeleteBuffer(GLcontext *ctx, struct gl_buffer_object *obj)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+
+ if(r300IsGartMemory(rmesa, obj->Data, obj->Size)){
+ drm_radeon_mem_free_t memfree;
+ int ret;
+
+ memfree.region = RADEON_MEM_REGION_GART;
+ memfree.region_offset = (char *)obj->Data - (char *)rmesa->radeon.radeonScreen->gartTextures.map;
+
+ ret = drmCommandWrite(rmesa->radeon.radeonScreen->driScreen->fd,
+ DRM_RADEON_FREE, &memfree, sizeof(memfree));
+
+ if(ret){
+ WARN_ONCE("Failed to free GART memroy!\n");
+ }
+ obj->Data = NULL;
+ }
+ _mesa_delete_buffer_object(ctx, obj);
+}
+
+/* Create the device specific rendering context.
+ */
+GLboolean r300CreateContext(const __GLcontextModes * glVisual,
+ __DRIcontextPrivate * driContextPriv,
+ void *sharedContextPrivate)
+{
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ radeonScreenPtr screen = (radeonScreenPtr) (sPriv->private);
+ struct dd_function_table functions;
+ r300ContextPtr r300;
+ GLcontext *ctx;
+ int tcl_mode, i;
+
+ assert(glVisual);
+ assert(driContextPriv);
+ assert(screen);
+
+ /* Allocate the R300 context */
+ r300 = (r300ContextPtr)CALLOC(sizeof(*r300));
+ if (!r300)
+ return GL_FALSE;
+
+ /* Parse configuration files.
+ * Do this here so that initialMaxAnisotropy is set before we create
+ * the default textures.
+ */
+ driParseConfigFiles(&r300->radeon.optionCache, &screen->optionCache,
+ screen->driScreen->myNum, "r300");
+
+ /* Init default driver functions then plug in our R300-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions(&functions);
+ r300InitIoctlFuncs(&functions);
+ r300InitStateFuncs(&functions);
+ r300InitTextureFuncs(&functions);
+ r300InitShaderFuncs(&functions);
+
+#if 0 /* Needs various Mesa changes... */
+ if (hw_tcl_on) {
+ functions.BufferData = r300BufferData;
+ functions.DeleteBuffer = r300DeleteBuffer;
+ }
+#endif
+
+ if (!radeonInitContext(&r300->radeon, &functions,
+ glVisual, driContextPriv, sharedContextPrivate)) {
+ FREE(r300);
+ return GL_FALSE;
+ }
+
+ /* Init r300 context data */
+ r300->dma.buf0_address = r300->radeon.radeonScreen->buffers->list[0].address;
+
+ (void)memset(r300->texture_heaps, 0, sizeof(r300->texture_heaps));
+ make_empty_list(&r300->swapped);
+
+ r300->nr_heaps = 1 /* screen->numTexHeaps */ ;
+ assert(r300->nr_heaps < R200_NR_TEX_HEAPS);
+ for (i = 0; i < r300->nr_heaps; i++) {
+ r300->texture_heaps[i] = driCreateTextureHeap(i, r300,
+ screen->
+ texSize[i], 12,
+ RADEON_NR_TEX_REGIONS,
+ (drmTextureRegionPtr)
+ r300->radeon.sarea->
+ tex_list[i],
+ &r300->radeon.sarea->
+ tex_age[i],
+ &r300->swapped,
+ sizeof
+ (r300TexObj),
+ (destroy_texture_object_t
+ *)
+ r300DestroyTexObj);
+ }
+ r300->texture_depth = driQueryOptioni(&r300->radeon.optionCache,
+ "texture_depth");
+ if (r300->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
+ r300->texture_depth = (screen->cpp == 4) ?
+ DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
+
+ /* Set the maximum texture size small enough that we can guarentee that
+ * all texture units can bind a maximal texture and have them both in
+ * texturable memory at once.
+ */
+
+ ctx = r300->radeon.glCtx;
+
+ ctx->Const.MaxTextureImageUnits = driQueryOptioni(&r300->radeon.optionCache,
+ "texture_image_units");
+ ctx->Const.MaxTextureCoordUnits = driQueryOptioni(&r300->radeon.optionCache,
+ "texture_coord_units");
+ ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureImageUnits,
+ ctx->Const.MaxTextureCoordUnits);
+ ctx->Const.MaxTextureMaxAnisotropy = 16.0;
+
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = R300_POINTSIZE_MAX;
+ ctx->Const.MaxPointSizeAA = R300_POINTSIZE_MAX;
+
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = R300_LINESIZE_MAX;
+ ctx->Const.MaxLineWidthAA = R300_LINESIZE_MAX;
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext(ctx);
+ _ac_CreateContext(ctx);
+ _tnl_CreateContext(ctx);
+ _swsetup_CreateContext(ctx);
+ _swsetup_Wakeup(ctx);
+ _ae_create_context(ctx);
+
+ /* Install the customized pipeline:
+ */
+ _tnl_destroy_pipeline(ctx);
+ _tnl_install_pipeline(ctx, r300_pipeline);
+
+ /* Try and keep materials and vertices separate:
+ */
+ _tnl_isolate_materials(ctx, GL_TRUE);
+
+ /* Configure swrast and TNL to match hardware characteristics:
+ */
+ _swrast_allow_pixel_fog(ctx, GL_FALSE);
+ _swrast_allow_vertex_fog(ctx, GL_TRUE);
+ _tnl_allow_pixel_fog(ctx, GL_FALSE);
+ _tnl_allow_vertex_fog(ctx, GL_TRUE);
+
+ /* currently bogus data */
+ ctx->Const.MaxVertexProgramInstructions=VSF_MAX_FRAGMENT_LENGTH;
+ ctx->Const.MaxVertexProgramAttribs=16; // r420
+ ctx->Const.MaxVertexProgramTemps=VSF_MAX_FRAGMENT_TEMPS;
+ ctx->Const.MaxVertexProgramLocalParams=256; // r420
+ ctx->Const.MaxVertexProgramEnvParams=256; // r420
+ ctx->Const.MaxVertexProgramAddressRegs=1;
+
+#if USE_ARB_F_P
+ ctx->Const.MaxFragmentProgramTemps = PFS_NUM_TEMP_REGS;
+ ctx->Const.MaxFragmentProgramAttribs = 11; /* copy i915... */
+ ctx->Const.MaxFragmentProgramLocalParams = PFS_NUM_CONST_REGS;
+ ctx->Const.MaxFragmentProgramEnvParams = PFS_NUM_CONST_REGS;
+ ctx->Const.MaxFragmentProgramAluInstructions = PFS_MAX_ALU_INST;
+ ctx->Const.MaxFragmentProgramTexInstructions = PFS_MAX_TEX_INST;
+ ctx->Const.MaxFragmentProgramInstructions = PFS_MAX_ALU_INST+PFS_MAX_TEX_INST;
+ ctx->Const.MaxFragmentProgramTexIndirections = PFS_MAX_TEX_INDIRECT;
+ ctx->Const.MaxFragmentProgramAddressRegs = 0; /* and these are?? */
+ ctx->_MaintainTexEnvProgram = GL_TRUE;
+#endif
+
+ driInitExtensions(ctx, card_extensions, GL_TRUE);
+
+ radeonInitSpanFuncs(ctx);
+ r300InitCmdBuf(r300);
+ r300InitState(r300);
+
+#if 0
+ /* plug in a few more device driver functions */
+ /* XXX these should really go right after _mesa_init_driver_functions() */
+ r300InitPixelFuncs(ctx);
+ r300InitSwtcl(ctx);
+#endif
+ TNL_CONTEXT(ctx)->Driver.RunPipeline = _tnl_run_pipeline;
+
+ tcl_mode = driQueryOptioni(&r300->radeon.optionCache, "tcl_mode");
+ if (driQueryOptionb(&r300->radeon.optionCache, "no_rast")) {
+ fprintf(stderr, "disabling 3D acceleration\n");
+#if R200_MERGED
+ FALLBACK(&r300->radeon, RADEON_FALLBACK_DISABLE, 1);
+#endif
+ }
+ if (tcl_mode == DRI_CONF_TCL_SW ||
+ !(r300->radeon.radeonScreen->chipset & RADEON_CHIPSET_TCL)) {
+ if (r300->radeon.radeonScreen->chipset & RADEON_CHIPSET_TCL) {
+ r300->radeon.radeonScreen->chipset &= ~RADEON_CHIPSET_TCL;
+ fprintf(stderr, "Disabling HW TCL support\n");
+ }
+ TCL_FALLBACK(r300->radeon.glCtx, RADEON_TCL_FALLBACK_TCL_DISABLE, 1);
+ }
+
+ return GL_TRUE;
+}
+
+/* Destroy the device specific context.
+ */
+void r300DestroyContext(__DRIcontextPrivate * driContextPriv)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r300ContextPtr r300 = (r300ContextPtr) driContextPriv->driverPrivate;
+ radeonContextPtr current = ctx ? RADEON_CONTEXT(ctx) : NULL;
+
+ if (RADEON_DEBUG & DEBUG_DRI) {
+ fprintf(stderr, "Destroying context !\n");
+ }
+
+ /* check if we're deleting the currently bound context */
+ if (&r300->radeon == current) {
+ radeonFlush(r300->radeon.glCtx);
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ /* Free r300 context resources */
+ assert(r300); /* should never be null */
+
+ if (r300) {
+ GLboolean release_texture_heaps;
+
+ release_texture_heaps = (r300->radeon.glCtx->Shared->RefCount == 1);
+ _swsetup_DestroyContext(r300->radeon.glCtx);
+ _tnl_DestroyContext(r300->radeon.glCtx);
+ _ac_DestroyContext(r300->radeon.glCtx);
+ _swrast_DestroyContext(r300->radeon.glCtx);
+
+ r300DestroyCmdBuf(r300);
+
+ radeonCleanupContext(&r300->radeon);
+
+ /* free the option cache */
+ driDestroyOptionCache(&r300->radeon.optionCache);
+
+ FREE(r300);
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_context.h
new file mode 100644
index 000000000..b59f184e3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_context.h
@@ -0,0 +1,844 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ * Nicolai Haehnle <prefect_@gmx.net>
+ */
+
+#ifndef __R300_CONTEXT_H__
+#define __R300_CONTEXT_H__
+
+#include "tnl/t_vertex.h"
+#include "drm.h"
+#include "radeon_drm.h"
+#include "dri_util.h"
+#include "texmem.h"
+
+#include "macros.h"
+#include "mtypes.h"
+#include "colormac.h"
+#include "radeon_context.h"
+
+#define USE_ARB_F_P 1
+
+struct r300_context;
+typedef struct r300_context r300ContextRec;
+typedef struct r300_context *r300ContextPtr;
+
+#include "radeon_lock.h"
+#include "mm.h"
+
+/* Checkpoint.. for convenience */
+#define CPT { fprintf(stderr, "%s:%s line %d\n", __FILE__, __FUNCTION__, __LINE__); }
+/* From http://gcc.gnu.org/onlinedocs/gcc-3.2.3/gcc/Variadic-Macros.html .
+ I suppose we could inline this and use macro to fetch out __LINE__ and stuff in case we run into trouble
+ with other compilers ... GLUE!
+*/
+#if 1
+#define WARN_ONCE(a, ...) { \
+ static int warn##__LINE__=1; \
+ if(warn##__LINE__){ \
+ fprintf(stderr, "*********************************WARN_ONCE*********************************\n"); \
+ fprintf(stderr, "File %s function %s line %d\n", \
+ __FILE__, __FUNCTION__, __LINE__); \
+ fprintf(stderr, a, ## __VA_ARGS__);\
+ fprintf(stderr, "***************************************************************************\n"); \
+ warn##__LINE__=0;\
+ } \
+ }
+#else
+#define WARN_ONCE(a, ...) {}
+#endif
+
+typedef GLuint uint32_t;
+typedef GLubyte uint8_t;
+struct r300_fragment_program;
+
+ /* We should probably change types within vertex_shader
+ and pixel_shader structure later on */
+#define CARD32 GLuint
+#include "vertex_shader.h"
+#if USE_ARB_F_P == 1
+#include "r300_fragprog.h"
+#else
+#include "pixel_shader.h"
+#endif
+#undef CARD32
+
+static __inline__ uint32_t r300PackFloat32(float fl)
+{
+ union { float fl; uint32_t u; } u;
+
+ u.fl = fl;
+ return u.u;
+}
+
+
+/************ DMA BUFFERS **************/
+
+/* Need refcounting on dma buffers:
+ */
+struct r300_dma_buffer {
+ int refcount; /* the number of retained regions in buf */
+ drmBufPtr buf;
+};
+
+#define GET_START(rvb) (rmesa->radeon.radeonScreen->gart_buffer_offset + \
+ (rvb)->address - rmesa->dma.buf0_address + \
+ (rvb)->start)
+
+/* A retained region, eg vertices for indexed vertices.
+ */
+struct r300_dma_region {
+ struct r300_dma_buffer *buf;
+ char *address; /* == buf->address */
+ int start, end, ptr; /* offsets from start of buf */
+
+ int aos_offset; /* address in GART memory */
+ int aos_stride; /* distance between elements, in dwords */
+ int aos_size; /* number of components (1-4) */
+ int aos_format; /* format of components */
+ int aos_reg; /* VAP register assignment */
+};
+
+struct r300_dma {
+ /* Active dma region. Allocations for vertices and retained
+ * regions come from here. Also used for emitting random vertices,
+ * these may be flushed by calling flush_current();
+ */
+ struct r300_dma_region current;
+
+ void (*flush) (r300ContextPtr);
+
+ char *buf0_address; /* start of buf[0], for index calcs */
+
+ /* Number of "in-flight" DMA buffers, i.e. the number of buffers
+ * for which a DISCARD command is currently queued in the command buffer.
+ */
+ GLuint nr_released_bufs;
+};
+
+ /* Texture related */
+
+typedef struct r300_tex_obj r300TexObj, *r300TexObjPtr;
+
+/* Texture object in locally shared texture space.
+ */
+struct r300_tex_obj {
+ driTextureObject base;
+
+ GLuint bufAddr; /* Offset to start of locally
+ shared texture block */
+
+ GLuint dirty_state; /* Flags (1 per texunit) for
+ whether or not this texobj
+ has dirty hardware state
+ (pp_*) that needs to be
+ brought into the
+ texunit. */
+
+ drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
+ /* Six, for the cube faces */
+
+
+ /* hardware register values */
+ /* Note that R200 has 8 registers per texture and R300 only 7 */
+ GLuint filter;
+ GLuint pitch; /* one of the unknown registers.. unknown 1 ?*/
+ GLuint size; /* npot only */
+ GLuint format;
+ GLuint offset; /* Image location in the card's address space.
+ All cube faces follow. */
+ GLuint unknown4;
+ GLuint unknown5;
+ /* end hardware registers */
+
+ /* registers computed by r200 code - keep them here to
+ compare against what is actually written.
+
+ to be removed later.. */
+ GLuint pp_border_color;
+ GLuint pp_cubic_faces; /* cube face 1,2,3,4 log2 sizes */
+ GLuint format_x;
+
+
+ GLboolean border_fallback;
+};
+
+struct r300_texture_env_state {
+ r300TexObjPtr texobj;
+ GLenum format;
+ GLenum envMode;
+};
+
+#define R300_MAX_TEXTURE_UNITS 8
+
+struct r300_texture_state {
+ struct r300_texture_env_state unit[R300_MAX_TEXTURE_UNITS];
+ int tc_count; /* number of incoming texture coordinates from VAP */
+};
+
+/**
+ * A block of hardware state.
+ *
+ * When check returns non-zero, the returned number of dwords must be
+ * copied verbatim into the command buffer in order to update a state atom
+ * when it is dirty.
+ */
+struct r300_state_atom {
+ struct r300_state_atom *next, *prev;
+ const char* name; /* for debug */
+ int cmd_size; /* maximum size in dwords */
+ GLuint idx; /* index in an array (e.g. textures) */
+ uint32_t* cmd;
+ GLboolean dirty;
+
+ int (*check)(r300ContextPtr, struct r300_state_atom* atom);
+};
+
+
+#define R300_VPT_CMD_0 0
+#define R300_VPT_XSCALE 1
+#define R300_VPT_XOFFSET 2
+#define R300_VPT_YSCALE 3
+#define R300_VPT_YOFFSET 4
+#define R300_VPT_ZSCALE 5
+#define R300_VPT_ZOFFSET 6
+#define R300_VPT_CMDSIZE 7
+
+#define R300_VIR_CMD_0 0 /* vir is variable size (at least 1) */
+#define R300_VIR_CNTL_0 1
+#define R300_VIR_CNTL_1 2
+#define R300_VIR_CNTL_2 3
+#define R300_VIR_CNTL_3 4
+#define R300_VIR_CNTL_4 5
+#define R300_VIR_CNTL_5 6
+#define R300_VIR_CNTL_6 7
+#define R300_VIR_CNTL_7 8
+#define R300_VIR_CMDSIZE 9
+
+#define R300_VIC_CMD_0 0
+#define R300_VIC_CNTL_0 1
+#define R300_VIC_CNTL_1 2
+#define R300_VIC_CMDSIZE 3
+
+#define R300_VOF_CMD_0 0
+#define R300_VOF_CNTL_0 1
+#define R300_VOF_CNTL_1 2
+#define R300_VOF_CMDSIZE 3
+
+
+#define R300_PVS_CMD_0 0
+#define R300_PVS_CNTL_1 1
+#define R300_PVS_CNTL_2 2
+#define R300_PVS_CNTL_3 3
+#define R300_PVS_CMDSIZE 4
+
+#define R300_GB_MISC_CMD_0 0
+#define R300_GB_MISC_MSPOS_0 1
+#define R300_GB_MISC_MSPOS_1 2
+#define R300_GB_MISC_TILE_CONFIG 3
+#define R300_GB_MISC_SELECT 4
+#define R300_GB_MISC_AA_CONFIG 5
+#define R300_GB_MISC_CMDSIZE 6
+
+#define R300_TXE_CMD_0 0
+#define R300_TXE_ENABLE 1
+#define R300_TXE_CMDSIZE 2
+
+#define R300_PS_CMD_0 0
+#define R300_PS_POINTSIZE 1
+#define R300_PS_CMDSIZE 2
+
+#define R300_ZBS_CMD_0 0
+#define R300_ZBS_T_FACTOR 1
+#define R300_ZBS_T_CONSTANT 2
+#define R300_ZBS_W_FACTOR 3
+#define R300_ZBS_W_CONSTANT 4
+#define R300_ZBS_CMDSIZE 5
+
+#define R300_CUL_CMD_0 0
+#define R300_CUL_CULL 1
+#define R300_CUL_CMDSIZE 2
+
+#define R300_RC_CMD_0 0
+#define R300_RC_CNTL_0 1
+#define R300_RC_CNTL_1 2
+#define R300_RC_CMDSIZE 3
+
+#define R300_RI_CMD_0 0
+#define R300_RI_INTERP_0 1
+#define R300_RI_INTERP_1 2
+#define R300_RI_INTERP_2 3
+#define R300_RI_INTERP_3 4
+#define R300_RI_INTERP_4 5
+#define R300_RI_INTERP_5 6
+#define R300_RI_INTERP_6 7
+#define R300_RI_INTERP_7 8
+#define R300_RI_CMDSIZE 9
+
+#define R300_RR_CMD_0 0 /* rr is variable size (at least 1) */
+#define R300_RR_ROUTE_0 1
+#define R300_RR_ROUTE_1 2
+#define R300_RR_ROUTE_2 3
+#define R300_RR_ROUTE_3 4
+#define R300_RR_ROUTE_4 5
+#define R300_RR_ROUTE_5 6
+#define R300_RR_ROUTE_6 7
+#define R300_RR_ROUTE_7 8
+#define R300_RR_CMDSIZE 9
+
+#define R300_FP_CMD_0 0
+#define R300_FP_CNTL0 1
+#define R300_FP_CNTL1 2
+#define R300_FP_CNTL2 3
+#define R300_FP_CMD_1 4
+#define R300_FP_NODE0 5
+#define R300_FP_NODE1 6
+#define R300_FP_NODE2 7
+#define R300_FP_NODE3 8
+#define R300_FP_CMDSIZE 9
+
+#define R300_FPT_CMD_0 0
+#define R300_FPT_INSTR_0 1
+#define R300_FPT_CMDSIZE 65
+
+#define R300_FPI_CMD_0 0
+#define R300_FPI_INSTR_0 1
+#define R300_FPI_CMDSIZE 65
+
+#define R300_FPP_CMD_0 0
+#define R300_FPP_PARAM_0 1
+#define R300_FPP_CMDSIZE (32*4+1)
+
+#define R300_AT_CMD_0 0
+#define R300_AT_ALPHA_TEST 1
+#define R300_AT_UNKNOWN 2
+#define R300_AT_CMDSIZE 3
+
+#define R300_BLD_CMD_0 0
+#define R300_BLD_CBLEND 1
+#define R300_BLD_ABLEND 2
+#define R300_BLD_CMDSIZE 3
+
+#define R300_CMK_CMD_0 0
+#define R300_CMK_COLORMASK 1
+#define R300_CMK_CMDSIZE 2
+
+#define R300_CB_CMD_0 0
+#define R300_CB_OFFSET 1
+#define R300_CB_CMD_1 2
+#define R300_CB_PITCH 3
+#define R300_CB_CMDSIZE 4
+
+#define R300_ZS_CMD_0 0
+#define R300_ZS_CNTL_0 1
+#define R300_ZS_CNTL_1 2
+#define R300_ZS_CNTL_2 3
+#define R300_ZS_CMDSIZE 4
+
+#define R300_ZB_CMD_0 0
+#define R300_ZB_OFFSET 1
+#define R300_ZB_PITCH 2
+#define R300_ZB_CMDSIZE 3
+
+#define R300_VPI_CMD_0 0
+#define R300_VPI_INSTR_0 1
+#define R300_VPI_CMDSIZE 1025 /* 256 16 byte instructions */
+
+#define R300_VPP_CMD_0 0
+#define R300_VPP_PARAM_0 1
+#define R300_VPP_CMDSIZE 1025 /* 256 4-component parameters */
+
+#define R300_VPS_CMD_0 0
+#define R300_VPS_ZERO_0 1
+#define R300_VPS_ZERO_1 2
+#define R300_VPS_POINTSIZE 3
+#define R300_VPS_ZERO_3 4
+#define R300_VPS_CMDSIZE 5
+
+ /* the layout is common for all fields inside tex */
+#define R300_TEX_CMD_0 0
+#define R300_TEX_VALUE_0 1
+/* We don't really use this, instead specify mtu+1 dynamically
+#define R300_TEX_CMDSIZE (MAX_TEXTURE_UNITS+1)
+*/
+
+/**
+ * Cache for hardware register state.
+ */
+struct r300_hw_state {
+ struct r300_state_atom atomlist;
+
+ GLboolean is_dirty;
+ GLboolean all_dirty;
+ int max_state_size; /* in dwords */
+
+ struct r300_state_atom vpt; /* viewport (1D98) */
+ struct r300_state_atom unk2080; /* (2080) */
+ struct r300_state_atom vof; /* VAP output format register 0x2090 */
+ struct r300_state_atom vte; /* (20B0) */
+ struct r300_state_atom unk2134; /* (2134) */
+ struct r300_state_atom unk2140; /* (2140) */
+ struct r300_state_atom vir[2]; /* vap input route (2150/21E0) */
+ struct r300_state_atom vic; /* vap input control (2180) */
+ struct r300_state_atom unk21DC; /* (21DC) */
+ struct r300_state_atom unk221C; /* (221C) */
+ struct r300_state_atom unk2220; /* (2220) */
+ struct r300_state_atom unk2288; /* (2288) */
+ struct r300_state_atom pvs; /* pvs_cntl (22D0) */
+ struct r300_state_atom gb_enable; /* (4008) */
+ struct r300_state_atom gb_misc; /* Multisampling position shifts ? (4010) */
+ struct r300_state_atom unk4200; /* (4200) */
+ struct r300_state_atom unk4214; /* (4214) */
+ struct r300_state_atom ps; /* pointsize (421C) */
+ struct r300_state_atom unk4230; /* (4230) */
+ struct r300_state_atom lcntl; /* line control */
+ struct r300_state_atom unk4260; /* (4260) */
+ struct r300_state_atom unk4274; /* (4274) */
+ struct r300_state_atom unk4288; /* (4288) */
+ struct r300_state_atom unk42A0; /* (42A0) */
+ struct r300_state_atom zbs; /* zbias (42A4) */
+ struct r300_state_atom unk42B4; /* (42B4) */
+ struct r300_state_atom cul; /* cull cntl (42B8) */
+ struct r300_state_atom unk42C0; /* (42C0) */
+ struct r300_state_atom rc; /* rs control (4300) */
+ struct r300_state_atom ri; /* rs interpolators (4310) */
+ struct r300_state_atom rr; /* rs route (4330) */
+ struct r300_state_atom unk43A4; /* (43A4) */
+ struct r300_state_atom unk43E8; /* (43E8) */
+ struct r300_state_atom fp; /* fragment program cntl + nodes (4600) */
+ struct r300_state_atom fpt; /* texi - (4620) */
+ struct r300_state_atom unk46A4; /* (46A4) */
+ struct r300_state_atom fpi[4]; /* fp instructions (46C0/47C0/48C0/49C0) */
+ struct r300_state_atom unk4BC0; /* (4BC0) */
+ struct r300_state_atom unk4BC8; /* (4BC8) */
+ struct r300_state_atom at; /* alpha test (4BD4) */
+ struct r300_state_atom unk4BD8; /* (4BD8) */
+ struct r300_state_atom fpp; /* 0x4C00 and following */
+ struct r300_state_atom unk4E00; /* (4E00) */
+ struct r300_state_atom bld; /* blending (4E04) */
+ struct r300_state_atom cmk; /* colormask (4E0C) */
+ struct r300_state_atom unk4E10; /* (4E10) */
+ struct r300_state_atom cb; /* colorbuffer (4E28) */
+ struct r300_state_atom unk4E50; /* (4E50) */
+ struct r300_state_atom unk4E88; /* (4E88) */
+ struct r300_state_atom unk4EA0; /* (4E88) I saw it only written on RV350 hardware.. */
+ struct r300_state_atom zs; /* zstencil control (4F00) */
+ struct r300_state_atom unk4F10; /* (4F10) */
+ struct r300_state_atom zb; /* z buffer (4F20) */
+ struct r300_state_atom unk4F28; /* (4F28) */
+ struct r300_state_atom unk4F30; /* (4F30) */
+ struct r300_state_atom unk4F44; /* (4F44) */
+ struct r300_state_atom unk4F54; /* (4F54) */
+
+ struct r300_state_atom vpi; /* vp instructions */
+ struct r300_state_atom vpp; /* vp parameters */
+ struct r300_state_atom vps; /* vertex point size (?) */
+ /* 8 texture units */
+ /* the state is grouped by function and not by
+ texture unit. This makes single unit updates
+ really awkward - we are much better off
+ updating the whole thing at once */
+ struct {
+ struct r300_state_atom filter;
+ struct r300_state_atom unknown1;
+ struct r300_state_atom size;
+ struct r300_state_atom format;
+ struct r300_state_atom offset;
+ struct r300_state_atom unknown4;
+ struct r300_state_atom border_color;
+ } tex;
+ struct r300_state_atom txe; /* tex enable (4104) */
+};
+
+
+/**
+ * This structure holds the command buffer while it is being constructed.
+ *
+ * The first batch of commands in the buffer is always the state that needs
+ * to be re-emitted when the context is lost. This batch can be skipped
+ * otherwise.
+ */
+struct r300_cmdbuf {
+ int size; /* DWORDs allocated for buffer */
+ uint32_t* cmd_buf;
+ int count_used; /* DWORDs filled so far */
+ int count_reemit; /* size of re-emission batch */
+};
+
+
+/**
+ * State cache
+ */
+
+struct r300_depthbuffer_state {
+ GLfloat scale;
+};
+
+struct r300_stencilbuffer_state {
+ GLuint clear;
+ GLboolean hw_stencil;
+
+};
+
+struct r300_vap_reg_state {
+ /* input register assigments */
+ int i_coords;
+ int i_normal;
+ int i_color[2];
+ int i_fog;
+ int i_tex[R300_MAX_TEXTURE_UNITS];
+ int i_index;
+ int i_pointsize;
+ };
+
+/* Vertex shader state */
+
+/* Tested with rv350 and verified from misc web pages. */
+#define VSF_MAX_FRAGMENT_LENGTH (256*4)
+
+/* Tested with rv350 and verified from misc web pages. */
+#define VSF_MAX_FRAGMENT_TEMPS (32)
+
+
+struct r300_vertex_shader_fragment {
+ int length;
+ union {
+ GLuint d[VSF_MAX_FRAGMENT_LENGTH];
+ float f[VSF_MAX_FRAGMENT_LENGTH];
+ VERTEX_SHADER_INSTRUCTION i[VSF_MAX_FRAGMENT_LENGTH/4];
+ } body;
+ };
+
+#define VSF_DEST_PROGRAM 0x0
+#define VSF_DEST_MATRIX0 0x200
+#define VSF_DEST_MATRIX1 0x204
+#define VSF_DEST_MATRIX2 0x208
+#define VSF_DEST_VECTOR0 0x20c
+#define VSF_DEST_VECTOR1 0x20d
+#define VSF_DEST_UNKNOWN1 0x400
+#define VSF_DEST_UNKNOWN2 0x406
+
+struct r300_vertex_shader_state {
+ struct r300_vertex_shader_fragment program;
+
+ /* a bit of a waste - each uses only a subset of allocated space..
+ but easier to program */
+ struct r300_vertex_shader_fragment matrix[3];
+ struct r300_vertex_shader_fragment vector[2];
+
+ struct r300_vertex_shader_fragment unknown1;
+ struct r300_vertex_shader_fragment unknown2;
+
+ int program_start;
+ int unknown_ptr1; /* pointer within program space */
+ int program_end;
+
+ int param_offset;
+ int param_count;
+
+ int unknown_ptr2; /* pointer within program space */
+ int unknown_ptr3; /* pointer within program space */
+ };
+
+extern int hw_tcl_on;
+
+#define CURRENT_VERTEX_SHADER(ctx) (ctx->VertexProgram._Enabled ? ctx->VertexProgram.Current : ctx->_TnlProgram)
+
+//#define TMU_ENABLED(ctx, unit) (hw_tcl_on ? ctx->Texture.Unit[unit]._ReallyEnabled && (OutputsWritten & (1<<(VERT_RESULT_TEX0+(unit)))) :
+// (r300->state.render_inputs & (_TNL_BIT_TEX0<<(unit))))
+#define TMU_ENABLED(ctx, unit) (hw_tcl_on ? ctx->Texture.Unit[unit]._ReallyEnabled && OutputsWritten & (1<<(VERT_RESULT_TEX0+(unit))) : \
+ ctx->Texture.Unit[unit]._ReallyEnabled && r300->state.render_inputs & (_TNL_BIT_TEX0<<(unit)))
+
+/* r300_vertex_shader_state and r300_vertex_program should probably be merged together someday.
+ * Keeping them them seperate for now should ensure fixed pipeline keeps functioning properly.
+ */
+struct r300_vertex_program {
+ struct vertex_program mesa_program; /* Must be first */
+ int translated;
+
+ struct r300_vertex_shader_fragment program;
+ struct r300_vertex_shader_fragment params;
+
+ int pos_end;
+ unsigned long num_temporaries; /* Number of temp vars used by program */
+ int inputs[VERT_ATTRIB_MAX];
+ int outputs[VERT_RESULT_MAX];
+};
+
+#if USE_ARB_F_P == 1
+#define PFS_MAX_ALU_INST 64
+#define PFS_MAX_TEX_INST 64
+#define PFS_MAX_TEX_INDIRECT 4
+#define PFS_NUM_TEMP_REGS 32
+#define PFS_NUM_CONST_REGS 32
+struct r300_fragment_program {
+ struct fragment_program mesa_program;
+
+ GLcontext *ctx;
+ GLboolean translated;
+ GLboolean error;
+
+ struct {
+ int length;
+ GLuint inst[PFS_MAX_TEX_INST];
+ } tex;
+
+ struct {
+ struct {
+ GLuint inst0;
+ GLuint inst1;
+ GLuint inst2;
+ GLuint inst3;
+ } inst[PFS_MAX_ALU_INST];
+ } alu;
+ int v_pos;
+ int s_pos;
+
+ struct {
+ int tex_offset;
+ int tex_end;
+ int alu_offset;
+ int alu_end;
+ } node[4];
+ int cur_node;
+ int first_node_has_tex;
+
+ int alu_offset;
+ int alu_end;
+ int tex_offset;
+ int tex_end;
+
+ /* Hardware constants */
+ GLfloat constant[PFS_NUM_CONST_REGS][4];
+ int const_nr;
+
+ /* Tracked parameters */
+ struct {
+ int idx; /* hardware index */
+ GLfloat *values; /* pointer to values */
+ } param[PFS_NUM_CONST_REGS];
+ int param_nr;
+ GLboolean params_uptodate;
+
+ GLuint temps[PFS_NUM_TEMP_REGS];
+ int temp_in_use;
+ GLuint used_in_node;
+ GLuint dest_in_node;
+ GLuint inputs[32]; /* don't actually need 32... */
+
+ int hwreg_in_use;
+ int max_temp_idx;
+};
+
+#else
+/* 64 appears to be the maximum */
+#define PSF_MAX_PROGRAM_LENGTH 64
+
+struct r300_pixel_shader_program {
+ struct {
+ int length;
+ GLuint inst[PSF_MAX_PROGRAM_LENGTH];
+ } tex;
+
+ /* ALU intructions (logic and integer) */
+ struct {
+ int length;
+ struct {
+ GLuint inst0;
+ GLuint inst1;
+ GLuint inst2;
+ GLuint inst3;
+ } inst[PSF_MAX_PROGRAM_LENGTH];
+ } alu;
+
+ /* node information */
+ /* nodes are used to synchronize ALU and TEX streams */
+ /* There could be up to 4 nodes each consisting of
+ a number of TEX instructions followed by some ALU
+ instructions */
+ /* the last node of a program should always be node3 */
+ struct {
+ int tex_offset;
+ int tex_end;
+ int alu_offset;
+ int alu_end;
+ } node[4];
+
+ int active_nodes; /* must be between 1 and 4, inclusive */
+ int first_node_has_tex; /* other nodes always have it */
+
+ int temp_register_count; /* magic value goes into PFS_CNTL_1 */
+
+ /* entire program */
+ int tex_offset;
+ int tex_end;
+ int alu_offset;
+ int alu_end;
+
+ };
+
+#define MAX_PIXEL_SHADER_PARAMS 32
+struct r300_pixel_shader_state {
+ struct r300_pixel_shader_program program;
+
+ int translated;
+ int have_sample;
+ GLuint color_reg;
+ GLuint src_previous;
+
+ /* parameters */
+ int param_length; /* to limit the number of unnecessary writes */
+ struct {
+ float x;
+ float y;
+ float z;
+ float w;
+ } param[MAX_PIXEL_SHADER_PARAMS];
+ };
+#endif // USE_ARB_F_P
+
+/* 8 is somewhat bogus... it is probably something like 24 */
+#define R300_MAX_AOS_ARRAYS 16
+
+#define AOS_FORMAT_FLOAT 1
+#define AOS_FORMAT_UBYTE 2
+#define AOS_FORMAT_FLOAT_COLOR 3
+
+#define REG_COORDS 0
+#define REG_COLOR0 1
+#define REG_TEX0 2
+
+struct r300_aos_rec {
+ GLuint offset;
+ int element_size; /* in dwords */
+ int stride; /* distance between elements, in dwords */
+
+ int format;
+
+ int ncomponents; /* number of components - between 1 and 4, inclusive */
+
+ int reg; /* which register they are assigned to. */
+
+ };
+
+struct r300_state {
+ struct r300_depthbuffer_state depth;
+ struct r300_texture_state texture;
+ struct r300_vap_reg_state vap_reg;
+ struct r300_vertex_shader_state vertex_shader;
+#if USE_ARB_F_P == 0
+ struct r300_pixel_shader_state pixel_shader;
+#endif
+ struct r300_dma_region aos[R300_MAX_AOS_ARRAYS];
+ int aos_count;
+
+ GLuint *Elts;
+ struct r300_dma_region elt_dma;
+
+ GLuint render_inputs; /* actual render inputs that R300 was configured for.
+ They are the same as tnl->render_inputs for fixed pipeline */
+
+ struct {
+ int transform_offset; /* Transform matrix offset, -1 if none */
+ } vap_param; /* vertex processor parameter allocation - tells where to write parameters */
+
+ struct r300_stencilbuffer_state stencil;
+
+};
+
+
+/**
+ * R300 context structure.
+ */
+struct r300_context {
+ struct radeon_context radeon; /* parent class, must be first */
+
+ struct r300_hw_state hw;
+ struct r300_cmdbuf cmdbuf;
+ struct r300_state state;
+
+ /* Vertex buffers
+ */
+ struct r300_dma dma;
+ GLboolean save_on_next_unlock;
+
+ /* Texture object bookkeeping
+ */
+ unsigned nr_heaps;
+ driTexHeap *texture_heaps[R200_NR_TEX_HEAPS];
+ driTextureObject swapped;
+ int texture_depth;
+ float initialMaxAnisotropy;
+
+ /* Clientdata textures;
+ */
+ GLuint prefer_gart_client_texturing;
+
+ /* TCL stuff
+ */
+ GLmatrix TexGenMatrix[R300_MAX_TEXTURE_UNITS];
+ GLboolean recheck_texgen[R300_MAX_TEXTURE_UNITS];
+ GLboolean TexGenNeedNormals[R300_MAX_TEXTURE_UNITS];
+ GLuint TexMatEnabled;
+ GLuint TexMatCompSel;
+ GLuint TexGenEnabled;
+ GLuint TexGenInputs;
+ GLuint TexGenCompSel;
+ GLmatrix tmpmat;
+};
+
+#define R300_CONTEXT(ctx) ((r300ContextPtr)(ctx->DriverCtx))
+
+static __inline GLuint r300PackColor( GLuint cpp,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a )
+{
+ switch ( cpp ) {
+ case 2:
+ return PACK_COLOR_565( r, g, b );
+ case 4:
+ return PACK_COLOR_8888( r, g, b, a );
+ default:
+ return 0;
+ }
+}
+extern void r300DestroyContext(__DRIcontextPrivate * driContextPriv);
+extern GLboolean r300CreateContext(const __GLcontextModes * glVisual,
+ __DRIcontextPrivate * driContextPriv,
+ void *sharedContextPrivate);
+
+void translate_vertex_shader(struct r300_vertex_program *vp);
+extern void r300InitShaderFuncs(struct dd_function_table *functions);
+extern void r300VertexProgUpdateParams(GLcontext *ctx, struct r300_vertex_program *vp);
+
+#endif /* __R300_CONTEXT_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_emit.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_emit.h
new file mode 100644
index 000000000..c7cb93d0a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_emit.h
@@ -0,0 +1,282 @@
+#ifndef __EMIT_H__
+#define __EMIT_H__
+#include "glheader.h"
+#include "r300_context.h"
+#include "r300_cmdbuf.h"
+
+/* convenience macros */
+#define RADEON_CP_PACKET0 0x00000000
+#define RADEON_CP_PACKET1 0x40000000
+#define RADEON_CP_PACKET2 0x80000000
+#define RADEON_CP_PACKET3 0xC0000000
+
+#define RADEON_CP_PACKET3_NOP 0xC0001000
+#define RADEON_CP_PACKET3_NEXT_CHAR 0xC0001900
+#define RADEON_CP_PACKET3_UNK1B 0xC0001B00
+#define RADEON_CP_PACKET3_PLY_NEXTSCAN 0xC0001D00
+#define RADEON_CP_PACKET3_SET_SCISSORS 0xC0001E00
+#define RADEON_CP_PACKET3_3D_RNDR_GEN_INDX_PRIM 0xC0002300
+#define RADEON_CP_PACKET3_LOAD_MICROCODE 0xC0002400
+#define RADEON_CP_PACKET3_WAIT_FOR_IDLE 0xC0002600
+#define RADEON_CP_PACKET3_3D_DRAW_VBUF 0xC0002800
+#define RADEON_CP_PACKET3_3D_DRAW_IMMD 0xC0002900
+#define RADEON_CP_PACKET3_3D_DRAW_INDX 0xC0002A00
+#define RADEON_CP_PACKET3_LOAD_PALETTE 0xC0002C00
+#define RADEON_CP_PACKET3_INDX_BUFFER 0xC0003300
+#define RADEON_CP_PACKET3_3D_DRAW_VBUF_2 0xC0003400
+#define RADEON_CP_PACKET3_3D_DRAW_IMMD_2 0xC0003500
+#define RADEON_CP_PACKET3_3D_DRAW_INDX_2 0xC0003600
+#define RADEON_CP_PACKET3_3D_LOAD_VBPNTR 0xC0002F00
+#define RADEON_CP_PACKET3_CNTL_PAINT 0xC0009100
+#define RADEON_CP_PACKET3_CNTL_BITBLT 0xC0009200
+#define RADEON_CP_PACKET3_CNTL_SMALLTEXT 0xC0009300
+#define RADEON_CP_PACKET3_CNTL_HOSTDATA_BLT 0xC0009400
+#define RADEON_CP_PACKET3_CNTL_POLYLINE 0xC0009500
+#define RADEON_CP_PACKET3_CNTL_POLYSCANLINES 0xC0009800
+#define RADEON_CP_PACKET3_CNTL_PAINT_MULTI 0xC0009A00
+#define RADEON_CP_PACKET3_CNTL_BITBLT_MULTI 0xC0009B00
+#define RADEON_CP_PACKET3_CNTL_TRANS_BITBLT 0xC0009C00
+#define RADEON_CP_PACKET3_3D_CLEAR_ZMASK 0xC0003202
+#define RADEON_CP_PACKET3_3D_CLEAR_CMASK 0xC0003802
+#define RADEON_CP_PACKET3_3D_CLEAR_HIZ 0xC0003702
+
+#define CP_PACKET0(reg, n) (RADEON_CP_PACKET0 | ((n)<<16) | ((reg)>>2))
+
+/* Glue to R300 Mesa driver */
+#define LOCAL_VARS int cmd_reserved=0;\
+ int cmd_written=0; \
+ drm_radeon_cmd_header_t *cmd=NULL;
+
+#define PREFIX_VOID r300ContextPtr rmesa
+
+#define PREFIX PREFIX_VOID ,
+
+#define PASS_PREFIX_VOID rmesa
+#define PASS_PREFIX rmesa ,
+
+typedef GLuint CARD32;
+
+/* This files defines functions for accessing R300 hardware.
+ It needs to be customized to whatever code r300_lib.c is used
+ in */
+
+void static inline check_space(int dwords)
+{
+}
+
+static __inline__ uint32_t cmdpacket0(int reg, int count)
+{
+ drm_r300_cmd_header_t cmd;
+
+ cmd.packet0.cmd_type = R300_CMD_PACKET0;
+ cmd.packet0.count = count;
+ cmd.packet0.reghi = ((unsigned int)reg & 0xFF00) >> 8;
+ cmd.packet0.reglo = ((unsigned int)reg & 0x00FF);
+
+ return cmd.u;
+}
+
+static __inline__ uint32_t cmdvpu(int addr, int count)
+{
+ drm_r300_cmd_header_t cmd;
+
+ cmd.vpu.cmd_type = R300_CMD_VPU;
+ cmd.vpu.count = count;
+ cmd.vpu.adrhi = ((unsigned int)addr & 0xFF00) >> 8;
+ cmd.vpu.adrlo = ((unsigned int)addr & 0x00FF);
+
+ return cmd.u;
+}
+
+static __inline__ uint32_t cmdpacket3(int packet)
+{
+ drm_r300_cmd_header_t cmd;
+
+ cmd.packet3.cmd_type = R300_CMD_PACKET3;
+ cmd.packet3.packet = packet;
+
+ return cmd.u;
+}
+
+static __inline__ uint32_t cmdcpdelay(unsigned short count)
+{
+ drm_r300_cmd_header_t cmd;
+
+ cmd.delay.cmd_type = R300_CMD_CP_DELAY;
+ cmd.delay.count = count;
+
+ return cmd.u;
+}
+
+static __inline__ uint32_t cmdwait(unsigned char flags)
+{
+ drm_r300_cmd_header_t cmd;
+
+ cmd.wait.cmd_type = R300_CMD_WAIT;
+ cmd.wait.flags = flags;
+
+ return cmd.u;
+}
+
+static __inline__ uint32_t cmdpacify(void)
+{
+ drm_r300_cmd_header_t cmd;
+
+ cmd.header.cmd_type = R300_CMD_END3D;
+
+ return cmd.u;
+}
+
+/* Prepare to write a register value to register at address reg.
+ If num_extra > 0 then the following extra values are written
+ to registers with address +4, +8 and so on.. */
+#define reg_start(reg, num_extra) \
+ { \
+ int _n; \
+ _n=(num_extra); \
+ cmd=(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, \
+ (_n+2), \
+ __FUNCTION__); \
+ cmd_reserved=_n+2; \
+ cmd_written=1; \
+ cmd[0].i=cmdpacket0((reg), _n+1); \
+ }
+
+/* Prepare to write a register value to register at address reg.
+ If num_extra > 0 then the following extra values are written
+ into the same register. */
+/* It is here to permit r300_lib to compile and link anyway, but
+ complain if actually called */
+#define reg_start_pump(reg, num_extra) \
+ { \
+ fprintf(stderr, "I am not defined.. Error ! in %s::%s at line %d\n", \
+ __FILE__, __FUNCTION__, __LINE__); \
+ exit(-1); \
+ }
+
+/* Emit CARD32 freestyle*/
+#define e32(dword) { \
+ if(cmd_written<cmd_reserved){\
+ cmd[cmd_written].i=(dword); \
+ cmd_written++; \
+ } else { \
+ fprintf(stderr, "e32 but no previous packet declaration.. Aborting! in %s::%s at line %d, cmd_written=%d cmd_reserved=%d\n", \
+ __FILE__, __FUNCTION__, __LINE__, cmd_written, cmd_reserved); \
+ exit(-1); \
+ } \
+ }
+
+#define efloat(f) e32(r300PackFloat32(f))
+
+#define vsf_start_fragment(dest, length) \
+ { \
+ int _n; \
+ _n=(length); \
+ cmd=(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, \
+ (_n+1), \
+ __FUNCTION__); \
+ cmd_reserved=_n+2; \
+ cmd_written=1; \
+ cmd[0].i=cmdvpu((dest), _n/4); \
+ }
+
+#define start_packet3(packet, count) \
+ { \
+ int _n; \
+ CARD32 _p; \
+ _n=(count); \
+ _p=(packet); \
+ cmd=(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, \
+ (_n+3), \
+ __FUNCTION__); \
+ cmd_reserved=_n+3; \
+ cmd_written=2; \
+ if(_n>0x3fff) {\
+ fprintf(stderr,"Too big packet3 %08x: cannot store %d dwords\n", \
+ _p, _n); \
+ exit(-1); \
+ } \
+ cmd[0].i=cmdpacket3(R300_CMD_PACKET3_RAW); \
+ cmd[1].i=_p | ((_n & 0x3fff)<<16); \
+ }
+
+ /* must be sent to switch to 2d commands */
+
+void static inline end_3d(PREFIX_VOID)
+{
+LOCAL_VARS
+(void)cmd_reserved; (void)cmd_written;
+
+cmd=(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, \
+ 1, \
+ __FUNCTION__); \
+
+cmd[0].header.cmd_type=R300_CMD_END3D;
+}
+
+void static inline cp_delay(PREFIX unsigned short count)
+{
+LOCAL_VARS
+(void)cmd_reserved; (void)cmd_written;
+
+cmd=(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, \
+ 1, \
+ __FUNCTION__); \
+
+cmd[0].i=cmdcpdelay(count);
+}
+
+void static inline cp_wait(PREFIX unsigned char flags)
+{
+LOCAL_VARS
+(void)cmd_reserved; (void)cmd_written;
+
+cmd=(drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa, \
+ 1, \
+ __FUNCTION__); \
+
+cmd[0].i=cmdwait(flags);
+}
+
+/* fire vertex buffer */
+static void inline fire_AOS(PREFIX int vertex_count, int type)
+{
+LOCAL_VARS
+check_space(9);
+
+start_packet3(RADEON_CP_PACKET3_3D_DRAW_VBUF_2, 0);
+/* e32(0x840c0024); */
+ e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST | (vertex_count<<16) | type);
+}
+
+/* these are followed by the corresponding data */
+#define start_index32_packet(vertex_count, type) \
+ {\
+ int _vc;\
+ _vc=(vertex_count); \
+ start_packet3(RADEON_CP_PACKET3_3D_DRAW_INDX_2, _vc); \
+ e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (_vc<<16) | type \
+ | R300_VAP_VF_CNTL__INDEX_SIZE_32bit); \
+ }
+
+#define start_index16_packet(vertex_count, type) \
+ {\
+ int _vc, _n;\
+ _vc=(vertex_count); \
+ _n=(vertex_count+1)>>1; \
+ start_packet3(RADEON_CP_PACKET3_3D_DRAW_INDX_2, _n); \
+ e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (_vc<<16) | type); \
+ }
+
+/* Interestingly enough this ones needs the call to setup_AOS, even thought
+ some of the data so setup is not needed and some is not as arbitrary
+ as when used by DRAW_VBUF_2 or DRAW_INDX_2 */
+#define start_immediate_packet(vertex_count, type, vertex_size) \
+ {\
+ int _vc; \
+ _vc=(vertex_count); \
+ start_packet3(RADEON_CP_PACKET3_3D_DRAW_IMMD_2, _vc*(vertex_size)); \
+ e32(R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_EMBEDDED | (_vc<<16) | type); \
+ }
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_fixed_pipelines.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_fixed_pipelines.h
new file mode 100644
index 000000000..65e1836af
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_fixed_pipelines.h
@@ -0,0 +1,294 @@
+#ifndef __R300_FIXED_PIPELINES_H__
+#define __R300_FIXED_PIPELINES_H__
+
+/******** Flat color pipeline **********/
+static struct r300_vertex_shader_state FLAT_COLOR_VERTEX_SHADER={
+ program: {
+ length: 20,
+
+ body:{ d: {
+ EASY_VSF_OP(MUL, 0, ALL, TMP),
+ VSF_PARAM(3),
+ VSF_ATTR_W(0),
+ EASY_VSF_SOURCE(0, W, W, W, W, NONE, NONE),
+
+ EASY_VSF_OP(MUL, 1, ALL, RESULT),
+ VSF_REG(1),
+ VSF_ATTR_UNITY(1),
+ VSF_UNITY(1),
+
+ EASY_VSF_OP(MAD, 0, ALL, TMP),
+ VSF_PARAM(2),
+ VSF_ATTR_Z(0),
+ VSF_TMP(0),
+
+ EASY_VSF_OP(MAD, 0, ALL, TMP),
+ VSF_PARAM(1),
+ VSF_ATTR_Y(0),
+ VSF_TMP(0),
+
+ EASY_VSF_OP(MAD, 0, ALL, RESULT),
+ VSF_PARAM(0),
+ VSF_ATTR_X(0),
+ VSF_TMP(0),
+ } }
+ },
+
+ matrix:{
+ {
+ length: 16,
+ body: { f: {
+ 2.0,
+ 0,
+ 0.0,
+ 0.0,
+ 0,
+ 2.5,
+ 0,
+ 0,
+ 0.0,
+ 0,
+ -1.00,
+ -1.0,
+ -3.0,
+ 0,
+ 6.0,
+ 6.0
+ } }
+ },
+ {
+ length: 0,
+ },
+ {
+ length: 0,
+ }
+ },
+
+ vector: {
+ {
+ length: 0,
+ },
+ {
+ length: 0,
+ }
+ },
+
+ unknown1: {
+ length: 0
+ },
+
+ unknown2: {
+ length: 0
+ },
+
+ program_start: 0,
+ unknown_ptr1: 4,
+ program_end: 4,
+
+ param_offset: 0,
+ param_count: 4,
+
+ unknown_ptr2: 0,
+ unknown_ptr3: 4
+ };
+
+static struct r300_pixel_shader_state FLAT_COLOR_PIXEL_SHADER={
+ program: {
+ tex: {
+ length: 0
+ },
+ alu: {
+ length: 1,
+ /* My understanding is that we need at least 1 instructions for pixel shader,
+ in particular because alu_end==0 means there is one instruction */
+ inst: {
+ PFS_NOP
+ }
+ },
+ node: {
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0}
+ },
+ active_nodes: 1,
+ first_node_has_tex: 0,
+ temp_register_count: 0,
+
+ tex_offset: 0,
+ tex_end: 0,
+ alu_offset: 0,
+ alu_end: 0
+ },
+
+ param_length: 0
+ };
+
+
+/******** Single texture pipeline ***********/
+static struct r300_vertex_shader_state SINGLE_TEXTURE_VERTEX_SHADER={
+ program: {
+ length: 24,
+
+ body: { d: {
+ EASY_VSF_OP(MUL, 0, ALL, TMP),
+ VSF_PARAM(3),
+ VSF_ATTR_W(0),
+ EASY_VSF_SOURCE(0, W, W, W, W, NONE, NONE),
+
+ EASY_VSF_OP(MUL, 2, ALL, RESULT),
+ VSF_REG(2),
+ VSF_ATTR_UNITY(2),
+ VSF_UNITY(2),
+
+ EASY_VSF_OP(MAD, 0, ALL, TMP),
+ VSF_PARAM(2),
+ VSF_ATTR_Z(0),
+ VSF_TMP(0),
+
+ EASY_VSF_OP(MUL, 1, ALL, RESULT),
+ VSF_REG(1),
+ VSF_ATTR_UNITY(1),
+ VSF_UNITY(1),
+
+ EASY_VSF_OP(MAD, 0, ALL, TMP),
+ VSF_PARAM(1),
+ VSF_ATTR_Y(0),
+ VSF_TMP(0),
+
+ EASY_VSF_OP(MAD, 0, ALL, RESULT),
+ VSF_PARAM(0),
+ VSF_ATTR_X(0),
+ VSF_TMP(0),
+ } }
+ },
+
+ matrix:{
+ {
+ length: 16,
+ body: { f: {
+ 2.0,
+ 0,
+ 0.0,
+ 0.0,
+ 0,
+ 2.5,
+ 0,
+ 0,
+ 0.0,
+ 0,
+ -1.00,
+ -1.0,
+ -3.0,
+ 0,
+ 6.0,
+ 6.0
+ } }
+ },
+ {
+ length: 0,
+ },
+ {
+ length: 0,
+ }
+ },
+
+ vector: {
+ {
+ length: 0,
+ },
+ {
+ length: 0,
+ }
+ },
+
+ unknown1: {
+ length: 0
+ },
+
+ unknown2: {
+ length: 4,
+ body: { f: {
+ 0.0,
+ 0.0,
+ 1.0,
+ 0.0
+ } }
+ },
+
+ program_start: 0,
+ unknown_ptr1: 5,
+ program_end: 5,
+
+ param_offset: 0,
+ param_count: 4,
+
+ unknown_ptr2: 0,
+ unknown_ptr3: 5
+ };
+
+static struct r300_pixel_shader_state SINGLE_TEXTURE_PIXEL_SHADER={
+ program: {
+ tex: {
+ length: 1,
+ inst: { 0x00018000 }
+ },
+ alu: {
+ length: 2,
+ inst:
+ {
+/* I get misc problems without this after doing cold-reboot.
+ This would imply that alu programming is buggy. --aet */
+#if 1
+ PFS_NOP,
+#endif
+
+ /* What are 0's ORed with flags ? They are register numbers that
+ just happen to be 0 */
+ {
+ EASY_PFS_INSTR0(MAD, SRC0C_XYZ, SRC1C_XYZ, ZERO),
+ EASY_PFS_INSTR1(0, 0, 1, 0 | PFS_FLAG_CONST, NONE, ALL),
+
+#if 0
+ /* no alpha in textures */
+ EASY_PFS_INSTR2(MAD, SRC0A, ONE, ZERO),
+ EASY_PFS_INSTR3(0, 1, 0 | PFS_FLAG_CONST, 0 | PFS_FLAG_CONST, OUTPUT)
+#endif
+
+ /* alpha in textures */
+ EASY_PFS_INSTR2(MAD, SRC0A, SRC1A, ZERO),
+ EASY_PFS_INSTR3(0, 0, 1, 0 | PFS_FLAG_CONST, OUTPUT)
+ }
+ }
+ },
+ node: {
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0},
+ { 0, 0, 0, 0}
+ },
+
+ active_nodes: 1,
+ first_node_has_tex: 1,
+ temp_register_count: 1,
+
+ tex_offset: 0,
+ tex_end: 0,
+ alu_offset: 0,
+ alu_end: 0
+ },
+
+ param_length: 8,
+ param: {
+ { 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}
+ }
+ };
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_fragprog.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_fragprog.c
new file mode 100644
index 000000000..8750ff60c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_fragprog.c
@@ -0,0 +1,1090 @@
+/*
+ * Copyright (C) 2005 Ben Skeggs.
+ *
+ * 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 THE COPYRIGHT OWNER(S) 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:
+ * Ben Skeggs <darktama@iinet.net.au>
+ */
+
+/*TODO'S
+ *
+ * - Implement remaining arb_f_p opcodes
+ * - Depth write
+ * - Negate on individual components (implement in swizzle code?)
+ * - Reuse input/temp regs, if they're no longer needed.
+ * - Find out whether there's any benifit in ordering registers the way
+ * fglrx does (see r300_reg.h).
+ * - Verify results of opcodes for accuracy, I've only checked them
+ * in specific cases.
+ * - and more...
+ */
+
+#include "glheader.h"
+#include "macros.h"
+#include "enums.h"
+#include "arbfragparse.h"
+
+#include "program.h"
+#include "nvfragprog.h"
+#include "r300_context.h"
+#if USE_ARB_F_P == 1
+#include "r300_fragprog.h"
+#include "r300_reg.h"
+
+#define PFS_INVAL 0xFFFFFFFF
+
+static void dump_program(struct r300_fragment_program *rp);
+static void emit_arith(struct r300_fragment_program *rp, int op,
+ pfs_reg_t dest, int mask,
+ pfs_reg_t src0, pfs_reg_t src1, pfs_reg_t src2,
+ int flags);
+
+/***************************************
+ * begin: useful data structions for fragment program generation
+ ***************************************/
+
+/* description of r300 native hw instructions */
+const struct {
+ const char *name;
+ int argc;
+ int v_op;
+ int s_op;
+} r300_fpop[] = {
+ { "MAD", 3, R300_FPI0_OUTC_MAD, R300_FPI2_OUTA_MAD },
+ { "DP3", 2, R300_FPI0_OUTC_DP3, PFS_INVAL },
+ { "DP4", 2, R300_FPI0_OUTC_DP4, R300_FPI2_OUTA_DP4 },
+ { "MIN", 2, R300_FPI0_OUTC_MIN, R300_FPI2_OUTA_MIN },
+ { "MAX", 2, R300_FPI0_OUTC_MAX, R300_FPI2_OUTA_MAX },
+ { "CMP", 3, R300_FPI0_OUTC_CMP, R300_FPI2_OUTA_CMP },
+ { "FRC", 1, R300_FPI0_OUTC_FRC, R300_FPI2_OUTA_FRC },
+ { "EX2", 1, R300_FPI0_OUTC_REPL_ALPHA, R300_FPI2_OUTA_EX2 },
+ { "LG2", 1, R300_FPI0_OUTC_REPL_ALPHA, R300_FPI2_OUTA_LG2 },
+ { "RCP", 1, R300_FPI0_OUTC_REPL_ALPHA, R300_FPI2_OUTA_RCP },
+ { "RSQ", 1, R300_FPI0_OUTC_REPL_ALPHA, R300_FPI2_OUTA_RSQ },
+ { "REPL_ALPHA", 1, R300_FPI0_OUTC_REPL_ALPHA, PFS_INVAL }
+};
+
+#define MAKE_SWZ3(x, y, z) (MAKE_SWIZZLE4(SWIZZLE_##x, \
+ SWIZZLE_##y, \
+ SWIZZLE_##z, \
+ SWIZZLE_ZERO))
+
+/* vector swizzles r300 can support natively, with a couple of
+ * cases we handle specially
+ *
+ * pfs_reg_t.v_swz/pfs_reg_t.s_swz is an index into this table
+ **/
+static const struct r300_pfv_swizzle {
+ const char *name;
+ GLuint hash; /* swizzle value this matches */
+ GLboolean native;
+ GLuint base; /* base value for hw swizzle */
+ GLuint stride; /* difference in base between arg0/1/2 */
+ GLboolean dep_sca;
+} v_swiz[] = {
+/* native swizzles */
+ { "xyz", MAKE_SWZ3(X, Y, Z), GL_TRUE, R300_FPI0_ARGC_SRC0C_XYZ, 4, GL_FALSE },
+ { "xxx", MAKE_SWZ3(X, X, X), GL_TRUE, R300_FPI0_ARGC_SRC0C_XXX, 4, GL_FALSE },
+ { "yyy", MAKE_SWZ3(Y, Y, Y), GL_TRUE, R300_FPI0_ARGC_SRC0C_YYY, 4, GL_FALSE },
+ { "zzz", MAKE_SWZ3(Z, Z, Z), GL_TRUE, R300_FPI0_ARGC_SRC0C_ZZZ, 4, GL_FALSE },
+ { "www", MAKE_SWZ3(W, W, W), GL_TRUE, R300_FPI0_ARGC_SRC0A, 1, GL_TRUE },
+ { "yzx", MAKE_SWZ3(Y, Z, X), GL_TRUE, R300_FPI0_ARGC_SRC0C_YZX, 1, GL_FALSE },
+ { "zxy", MAKE_SWZ3(Z, X, Y), GL_TRUE, R300_FPI0_ARGC_SRC0C_ZXY, 1, GL_FALSE },
+/* disable this for now, until I find a clean way of making sure xyz/w streams
+ * have a source in the same register slot.. */
+// { "wzy", MAKE_SWZ3(W, Z, Y), GL_TRUE, R300_FPI0_ARGC_SRC0CA_WZY, 1, GL_TRUE },
+/* special cases */
+ { NULL, MAKE_SWZ3(ONE, ONE, ONE), GL_FALSE, R300_FPI0_ARGC_ONE, 0, GL_FALSE},
+ { NULL, MAKE_SWZ3(ZERO, ZERO, ZERO), GL_FALSE, R300_FPI0_ARGC_ZERO, 0, GL_FALSE},
+ { NULL, PFS_INVAL, GL_FALSE, R300_FPI0_ARGC_HALF, 0, GL_FALSE},
+ { NULL, PFS_INVAL, GL_FALSE, 0, 0, 0 },
+};
+#define SWIZZLE_XYZ 0
+#define SWIZZLE_XXX 1
+#define SWIZZLE_WWW 4
+#define SWIZZLE_111 7
+#define SWIZZLE_000 8
+#define SWIZZLE_HHH 9
+
+#define SWZ_X_MASK (7 << 0)
+#define SWZ_Y_MASK (7 << 3)
+#define SWZ_Z_MASK (7 << 6)
+#define SWZ_W_MASK (7 << 9)
+/* used during matching of non-native swizzles */
+static const struct {
+ GLuint hash; /* used to mask matching swizzle components */
+ int mask; /* actual outmask */
+ int count; /* count of components matched */
+} s_mask[] = {
+ { SWZ_X_MASK|SWZ_Y_MASK|SWZ_Z_MASK, 1|2|4, 3},
+ { SWZ_X_MASK|SWZ_Y_MASK, 1|2, 2},
+ { SWZ_X_MASK|SWZ_Z_MASK, 1|4, 2},
+ { SWZ_Y_MASK|SWZ_Z_MASK, 2|4, 2},
+ { SWZ_X_MASK, 1, 1},
+ { SWZ_Y_MASK, 2, 1},
+ { SWZ_Z_MASK, 4, 1},
+ { PFS_INVAL, PFS_INVAL, PFS_INVAL}
+};
+
+/* mapping from SWIZZLE_* to r300 native values for scalar insns */
+static const struct {
+ const char *name;
+ int base; /* hw value of swizzle */
+ int stride; /* difference between SRC0/1/2 */
+ GLboolean dep_vec;
+} s_swiz[] = {
+ { "x", R300_FPI2_ARGA_SRC0C_X, 3, GL_TRUE },
+ { "y", R300_FPI2_ARGA_SRC0C_Y, 3, GL_TRUE },
+ { "z", R300_FPI2_ARGA_SRC0C_Z, 3, GL_TRUE },
+ { "w", R300_FPI2_ARGA_SRC0A , 1, GL_FALSE },
+ { "0", R300_FPI2_ARGA_ZERO , 0, GL_FALSE },
+ { "1", R300_FPI2_ARGA_ONE , 0, GL_FALSE },
+ { ".5", R300_FPI2_ARGA_HALF, 0, GL_FALSE }
+};
+#define SWIZZLE_HALF 6
+
+/* boiler-plate reg, for convenience */
+const pfs_reg_t pfs_default_reg = {
+ type: REG_TYPE_TEMP,
+ index: 0,
+ v_swz: 0 /* matches XYZ in table */,
+ s_swz: SWIZZLE_W,
+ negate: 0,
+ valid: GL_FALSE
+};
+
+/* constant zero source */
+const pfs_reg_t pfs_one = {
+ type: REG_TYPE_CONST,
+ index: 0,
+ v_swz: SWIZZLE_111,
+ s_swz: SWIZZLE_ONE,
+ valid: GL_TRUE
+};
+
+/* constant one source */
+const pfs_reg_t pfs_zero = {
+ type: REG_TYPE_CONST,
+ index: 0,
+ v_swz: SWIZZLE_000,
+ s_swz: SWIZZLE_ZERO,
+ valid: GL_TRUE
+};
+
+/***************************************
+ * end: data structures
+ ***************************************/
+
+#define ERROR(fmt, args...) do { \
+ fprintf(stderr, "%s::%s(): " fmt "\n", __FILE__, __func__, ##args); \
+ rp->error = GL_TRUE; \
+} while(0)
+
+static int get_hw_temp(struct r300_fragment_program *rp)
+{
+ int r = ffs(~rp->hwreg_in_use);
+ if (!r) {
+ ERROR("Out of hardware temps\n");
+ return 0;
+ }
+
+ rp->hwreg_in_use |= (1 << --r);
+ if (r > rp->max_temp_idx)
+ rp->max_temp_idx = r;
+
+ return r;
+}
+
+static void free_hw_temp(struct r300_fragment_program *rp, int idx)
+{
+ rp->hwreg_in_use &= ~(1<<idx);
+}
+
+static pfs_reg_t get_temp_reg(struct r300_fragment_program *rp)
+{
+ pfs_reg_t r = pfs_default_reg;
+
+ r.index = ffs(~rp->temp_in_use);
+ if (!r.index) {
+ ERROR("Out of program temps\n");
+ return r;
+ }
+ rp->temp_in_use |= (1 << --r.index);
+
+ rp->temps[r.index] = get_hw_temp(rp);
+ r.valid = GL_TRUE;
+ return r;
+}
+
+static pfs_reg_t get_temp_reg_tex(struct r300_fragment_program *rp)
+{
+ pfs_reg_t r = pfs_default_reg;
+ int hwreg;
+
+ hwreg = ffs(~(rp->hwreg_in_use | rp->used_in_node));
+ if (!hwreg) {
+ /* Try and grab an already used temp, will
+ * cause an indirection, but better than failing */
+ return get_temp_reg(rp);
+ }
+ if (hwreg > rp->max_temp_idx)
+ rp->max_temp_idx = hwreg;
+
+ r.index = ffs(~rp->temp_in_use);
+ if (!r.index) {
+ ERROR("Out of program temps\n");
+ return r;
+ }
+ rp->temp_in_use |= (1 << --r.index);
+ rp->temps[r.index] = --hwreg;
+
+ r.valid = GL_TRUE;
+ return r;
+}
+
+static void free_temp(struct r300_fragment_program *rp, pfs_reg_t r)
+{
+ if (!rp || !(rp->temp_in_use & (1<<r.index))) return;
+
+ free_hw_temp(rp, rp->temps[r.index]);
+ rp->temp_in_use &= ~(1<<r.index);
+}
+
+static pfs_reg_t emit_param4fv(struct r300_fragment_program *rp, GLfloat *values)
+{
+ pfs_reg_t r = pfs_default_reg;
+ int pidx;
+
+ r.type = REG_TYPE_CONST;
+ pidx = rp->param_nr++;
+ r.index = rp->const_nr++;
+ if (pidx >= PFS_NUM_CONST_REGS || r.index >= PFS_NUM_CONST_REGS) {
+ ERROR("Out of const/param slots!\n");
+ return r;
+ }
+
+ rp->param[pidx].idx = r.index;
+ rp->param[pidx].values = values;
+ rp->params_uptodate = GL_FALSE;
+
+ r.valid = GL_TRUE;
+ return r;
+}
+
+static pfs_reg_t emit_const4fv(struct r300_fragment_program *rp, GLfloat *cp)
+{
+ pfs_reg_t r = pfs_default_reg;
+ r.type = REG_TYPE_CONST;
+
+ r.index = rp->const_nr++;
+ if (r.index >= PFS_NUM_CONST_REGS) {
+ ERROR("Out of hw constants!\n");
+ return r;
+ }
+
+ COPY_4V(rp->constant[r.index], cp);
+
+ r.valid = GL_TRUE;
+ return r;
+}
+
+static pfs_reg_t negate(pfs_reg_t r)
+{
+ r.negate = 1;
+ return r;
+}
+
+static int swz_native(struct r300_fragment_program *rp,
+ pfs_reg_t src, pfs_reg_t *r)
+{
+ /* Native swizzle, nothing to see here */
+ *r = src;
+ return 3;
+}
+
+static int swz_emit_partial(struct r300_fragment_program *rp,
+ pfs_reg_t src, pfs_reg_t *r, int mask, int mc)
+{
+ if (!r->valid)
+ *r = get_temp_reg(rp);
+
+ /* A partial match, src.v_swz/mask define what parts of the
+ * desired swizzle we match */
+ if (mc + s_mask[mask].count == 3)
+ emit_arith(rp, PFS_OP_MAD, *r, s_mask[mask].mask|WRITEMASK_W, src, pfs_one, pfs_zero, 0);
+ else
+ emit_arith(rp, PFS_OP_MAD, *r, s_mask[mask].mask, src, pfs_one, pfs_zero, 0);
+ return s_mask[mask].count;
+}
+
+static int swz_special_case(struct r300_fragment_program *rp,
+ pfs_reg_t src, pfs_reg_t *r, int mask, int mc)
+{
+ switch(GET_SWZ(v_swiz[src.v_swz].hash, 0)) {
+ case SWIZZLE_ONE:
+ case SWIZZLE_ZERO:
+ if (!r->valid)
+ *r = get_temp_reg(rp);
+ if (mc + s_mask[mask].count == 3)
+ emit_arith(rp, PFS_OP_MAD, *r, s_mask[mask].mask|WRITEMASK_W, src, pfs_one, pfs_zero, 0);
+ else
+ emit_arith(rp, PFS_OP_MAD, *r, s_mask[mask].mask, src, pfs_one, pfs_zero, 0);
+ break;
+ default:
+ ERROR("Unknown special-case swizzle! %d\n", src.v_swz);
+ return 0;
+ }
+
+ return s_mask[mask].count;
+}
+
+static pfs_reg_t swizzle(struct r300_fragment_program *rp,
+ pfs_reg_t src,
+ GLuint arbswz)
+{
+ pfs_reg_t r = pfs_default_reg;
+
+ int c_mask = 0;
+ int v_matched = 0;
+ src.v_swz = SWIZZLE_XYZ;
+ src.s_swz = GET_SWZ(arbswz, 3);
+
+ do {
+ do {
+#define CUR_HASH (v_swiz[src.v_swz].hash & s_mask[c_mask].hash)
+ if (CUR_HASH == (arbswz & s_mask[c_mask].hash)) {
+ if (v_swiz[src.v_swz].native == GL_FALSE)
+ v_matched += swz_special_case(rp, src, &r, c_mask, v_matched);
+ else if (s_mask[c_mask].count == 3)
+ v_matched += swz_native(rp, src, &r);
+ else
+ v_matched += swz_emit_partial(rp, src, &r, c_mask, v_matched);
+
+ if (v_matched == 3)
+ return r;
+
+ /* Fill with something invalid.. all 0's was wrong before, matched
+ * SWIZZLE_X. So all 1's will be okay for now */
+ arbswz |= (PFS_INVAL & s_mask[c_mask].hash);
+ }
+ } while(v_swiz[++src.v_swz].hash != PFS_INVAL);
+ src.v_swz = SWIZZLE_XYZ;
+ } while (s_mask[++c_mask].hash != PFS_INVAL);
+
+ ERROR("should NEVER get here\n");
+ return r;
+}
+
+static pfs_reg_t t_src(struct r300_fragment_program *rp,
+ struct fp_src_register fpsrc) {
+ pfs_reg_t r = pfs_default_reg;
+
+ switch (fpsrc.File) {
+ case PROGRAM_TEMPORARY:
+ r.index = fpsrc.Index;
+ r.valid = GL_TRUE;
+ break;
+ case PROGRAM_INPUT:
+ r.index = fpsrc.Index;
+ r.type = REG_TYPE_INPUT;
+ r.valid = GL_TRUE;
+ break;
+ case PROGRAM_LOCAL_PARAM:
+ r = emit_param4fv(rp, rp->mesa_program.Base.LocalParams[fpsrc.Index]);
+ break;
+ case PROGRAM_ENV_PARAM:
+ r = emit_param4fv(rp, rp->ctx->FragmentProgram.Parameters[fpsrc.Index]);
+ break;
+ case PROGRAM_STATE_VAR:
+ case PROGRAM_NAMED_PARAM:
+ r = emit_param4fv(rp, rp->mesa_program.Parameters->ParameterValues[fpsrc.Index]);
+ break;
+ default:
+ ERROR("unknown SrcReg->File %x\n", fpsrc.File);
+ return r;
+ }
+
+ /* no point swizzling ONE/ZERO/HALF constants... */
+ if (r.v_swz < SWIZZLE_111 && r.s_swz < SWIZZLE_ZERO)
+ r = swizzle(rp, r, fpsrc.Swizzle);
+
+ /* WRONG! Need to be able to do individual component negation,
+ * should probably handle this in the swizzling code unless
+ * all components are negated, then we can do this natively */
+ if (fpsrc.NegateBase)
+ r.negate = GL_TRUE;
+
+ return r;
+}
+
+static pfs_reg_t t_dst(struct r300_fragment_program *rp,
+ struct fp_dst_register dest) {
+ pfs_reg_t r = pfs_default_reg;
+
+ switch (dest.File) {
+ case PROGRAM_TEMPORARY:
+ r.index = dest.Index;
+ r.valid = GL_TRUE;
+ return r;
+ case PROGRAM_OUTPUT:
+ r.type = REG_TYPE_OUTPUT;
+ switch (dest.Index) {
+ case 0:
+ r.valid = GL_TRUE;
+ return r;
+ case 1:
+ ERROR("I don't know how to write depth!\n");
+ return r;
+ default:
+ ERROR("Bad DstReg->Index 0x%x\n", dest.Index);
+ return r;
+ }
+ default:
+ ERROR("Bad DstReg->File 0x%x\n", dest.File);
+ return r;
+ }
+}
+
+static void sync_streams(struct r300_fragment_program *rp) {
+ /* Bring vector/scalar streams into sync, inserting nops into
+ * whatever stream is lagging behind
+ *
+ * Using NOP == MAD out.none, 0, 0, 0
+ */
+ while (rp->v_pos != rp->s_pos) {
+ if (rp->s_pos > rp->v_pos) {
+ rp->alu.inst[rp->v_pos].inst0 = 0x00050A14;
+ rp->alu.inst[rp->v_pos].inst1 = 0x00020820;
+ rp->v_pos++;
+ } else {
+ rp->alu.inst[rp->s_pos].inst2 = 0x00040810;
+ rp->alu.inst[rp->s_pos].inst3 = 0x00020820;
+ rp->s_pos++;
+ }
+ }
+}
+
+static void emit_tex(struct r300_fragment_program *rp,
+ struct fp_instruction *fpi,
+ int opcode)
+{
+ pfs_reg_t coord = t_src(rp, fpi->SrcReg[0]);
+ pfs_reg_t dest = t_dst(rp, fpi->DstReg), rdest = pfs_default_reg;
+ int unit = fpi->TexSrcUnit;
+ int hwsrc, hwdest, flags = 0;
+
+ if (dest.type == REG_TYPE_OUTPUT) {
+ rdest = dest;
+ dest = get_temp_reg_tex(rp);
+ }
+
+ switch (coord.type) {
+ case REG_TYPE_TEMP:
+ hwsrc = rp->temps[coord.index];
+ break;
+ case REG_TYPE_INPUT:
+ hwsrc = rp->inputs[coord.index];
+ break;
+ case REG_TYPE_CONST:
+ hwsrc = coord.index;
+ flags = R300_FPITX_SRC_CONST;
+ break;
+ default:
+ ERROR("Unknown coord.type = %d\n", coord.type);
+ return;
+ }
+ hwdest = rp->temps[dest.index];
+
+ /* Indirection if source has been written in this node, or if the dest has
+ * been read/written in this node
+ */
+ if ((coord.type != REG_TYPE_CONST && (rp->dest_in_node & (1<<hwsrc))) ||
+ (rp->used_in_node & (1<<hwdest))) {
+
+ if (rp->cur_node == 3) { /* We only support 4 natively */
+ ERROR("too many levels of texture indirection\n");
+ return;
+ }
+
+ /* Finish off current node */
+ sync_streams(rp);
+ rp->node[rp->cur_node].alu_end = rp->v_pos - 1;
+
+ /* Start new node */
+ rp->cur_node++;
+ rp->used_in_node = 0;
+ rp->dest_in_node = 0;
+ rp->node[rp->cur_node].tex_offset = rp->tex.length;
+ rp->node[rp->cur_node].alu_offset = rp->v_pos;
+ rp->node[rp->cur_node].tex_end = -1;
+ rp->node[rp->cur_node].alu_end = -1;
+ }
+
+ if (rp->cur_node == 0) rp->first_node_has_tex = 1;
+
+ rp->tex.inst[rp->tex.length++] = 0
+ | (hwsrc << R300_FPITX_SRC_SHIFT)
+ | (hwdest << R300_FPITX_DST_SHIFT)
+ | (unit << R300_FPITX_IMAGE_SHIFT)
+ | (opcode << R300_FPITX_OPCODE_SHIFT) /* not entirely sure about this */
+ | flags;
+ rp->dest_in_node |= (1 << hwdest);
+ if (coord.type != REG_TYPE_CONST)
+ rp->used_in_node |= (1 << hwsrc);
+
+ rp->node[rp->cur_node].tex_end++;
+
+ /* Copy from temp to output if needed */
+ if (rdest.valid) {
+ emit_arith(rp, PFS_OP_MAD, rdest, WRITEMASK_XYZW, dest, pfs_one, pfs_zero, 0);
+ free_temp(rp, dest);
+ }
+}
+
+#define ARG_NEG (1<<5)
+#define ARG_ABS (1<<6)
+#define SRC_CONST (1<<5)
+#define SRC_STRIDE 6
+
+static int t_hw_src(struct r300_fragment_program *rp, pfs_reg_t src)
+{
+ int idx;
+
+ switch (src.type) {
+ case REG_TYPE_TEMP:
+ idx = rp->temps[src.index];
+ break;
+ case REG_TYPE_INPUT:
+ idx = rp->inputs[src.index];
+ break;
+ case REG_TYPE_CONST:
+ return (src.index | SRC_CONST);
+ default:
+ ERROR("Invalid type for source reg\n");
+ return (0 | SRC_CONST);
+ }
+
+ rp->used_in_node |= (1 << idx);
+ return idx;
+}
+
+/* Add sources to FPI1/FPI3 lists. If source is already on list,
+ * reuse the index instead of wasting a source.
+ */
+static inline int add_src(int src[3], int *cnt, int reg) {
+ int i;
+
+ for (i=0;i<*cnt;i++)
+ if (src[i] == reg) return i;
+
+ if (*cnt == 3) assert(0); /* I don't *think* this can happen */
+
+ src[*cnt] = reg;
+ return (*cnt)++;
+}
+
+static void emit_arith(struct r300_fragment_program *rp, int op,
+ pfs_reg_t dest, int mask,
+ pfs_reg_t src0, pfs_reg_t src1, pfs_reg_t src2,
+ int flags)
+{
+ pfs_reg_t src[3] = { src0, src1, src2 };
+ /* XYZ/W emit control */
+ int v_idx = rp->v_pos, s_idx = rp->s_pos;
+ GLboolean emit_v = GL_FALSE, emit_s = GL_FALSE;
+ /* INST1/INST3 sources */
+ int vsrc[3], ssrc[3];
+ int nvs = 0, nss = 0;
+ /* INST0/INST2 sources */
+ int vswz[3], sswz[3];
+ /* temp stuff */
+ int hwdest, hwsrc;
+ int argc;
+ int vop, sop;
+ int i;
+ int str;
+
+ if (!dest.valid || !src0.valid || !src1.valid || !src2.valid) {
+ ERROR("invalid register. dest/src0/src1/src2 valid = %d/%d/%d/%d\n",
+ dest.valid, src0.valid, src1.valid, src2.valid);
+ return;
+ }
+
+ /* check opcode */
+ if (op > MAX_PFS_OP) {
+ ERROR("unknown opcode!\n");
+ return;
+ }
+ argc = r300_fpop[op].argc;
+ vop = r300_fpop[op].v_op;
+ sop = r300_fpop[op].s_op;
+
+ /* grab hwregs of dest */
+ switch (dest.type) {
+ case REG_TYPE_TEMP:
+ hwdest = rp->temps[dest.index];
+ rp->dest_in_node |= (1 << hwdest);
+ rp->used_in_node |= (1 << hwdest);
+ break;
+ case REG_TYPE_OUTPUT:
+ hwdest = 0;
+ break;
+ default:
+ ERROR("invalid dest reg type %d\n", dest.type);
+ return;
+ }
+
+ for (i=0;i<3;i++) {
+ if (i<argc) {
+ hwsrc = t_hw_src(rp, src[i]);
+ if (mask & WRITEMASK_XYZ && vop != R300_FPI0_OUTC_REPL_ALPHA) {
+ if (v_swiz[src[i].v_swz].dep_sca) {
+ sync_streams(rp);
+ v_idx = s_idx = rp->v_pos;
+ emit_s = GL_TRUE;
+ str = add_src(ssrc, &nss, hwsrc);
+ } else
+ str = add_src(vsrc, &nvs, hwsrc);
+ vswz[i] = v_swiz[src[i].v_swz].base + (str * v_swiz[src[i].v_swz].stride);
+ } else
+ vswz[i] = R300_FPI0_ARGC_ZERO;
+
+ if (mask & WRITEMASK_W || vop == R300_FPI0_OUTC_REPL_ALPHA) {
+ if (s_swiz[src[i].s_swz].dep_vec) {
+ sync_streams(rp);
+ v_idx = s_idx = rp->v_pos;
+ emit_v = GL_TRUE;
+ str = add_src(vsrc, &nvs, hwsrc);
+ } else
+ str = add_src(ssrc, &nss, hwsrc);
+ sswz[i] = s_swiz[src[i].s_swz].base + (str * s_swiz[src[i].s_swz].stride);
+ } else
+ sswz[i] = R300_FPI2_ARGA_ZERO;
+
+ if (src[i].negate) {
+ vswz[i] |= ARG_NEG;
+ sswz[i] |= ARG_NEG;
+ }
+
+ if (flags & PFS_FLAG_ABS) {
+ vswz[i] |= ARG_ABS;
+ sswz[i] |= ARG_ABS;
+ }
+ } else {
+ vswz[i] = R300_FPI0_ARGC_ZERO;
+ sswz[i] = R300_FPI2_ARGA_ZERO;
+ }
+ }
+ /* Unused sources, read constant reg 0 */
+ for (i=nvs;i<3;i++)
+ vsrc[i] = 0 | SRC_CONST;
+ for (i=nss;i<3;i++)
+ ssrc[i] = 0 | SRC_CONST;
+
+ if (flags & PFS_FLAG_SAT) {
+ vop |= R300_FPI0_OUTC_SAT;
+ sop |= R300_FPI2_OUTA_SAT;
+ }
+
+ if (mask & WRITEMASK_XYZ || emit_v) {
+ if (r300_fpop[op].v_op == R300_FPI0_OUTC_REPL_ALPHA) {
+ sync_streams(rp);
+ s_idx = v_idx = rp->v_pos;
+ }
+ rp->alu.inst[v_idx].inst0 = vop |
+ vswz[0] << R300_FPI0_ARG0C_SHIFT |
+ vswz[1] << R300_FPI0_ARG1C_SHIFT |
+ vswz[2] << R300_FPI0_ARG2C_SHIFT;
+ rp->alu.inst[v_idx].inst1 = hwdest << R300_FPI1_DSTC_SHIFT |
+ vsrc[0] << R300_FPI1_SRC0C_SHIFT |
+ vsrc[1] << R300_FPI1_SRC1C_SHIFT |
+ vsrc[2] << R300_FPI1_SRC2C_SHIFT |
+ ((mask & WRITEMASK_XYZ) << (dest.type == REG_TYPE_OUTPUT ? 26 : 23));
+ rp->v_pos = v_idx + 1;
+ }
+
+ if (mask & WRITEMASK_W || emit_s || vop == R300_FPI0_OUTC_REPL_ALPHA) {
+ rp->alu.inst[s_idx].inst2 = sop |
+ sswz[0] << R300_FPI2_ARG0A_SHIFT |
+ sswz[1] << R300_FPI2_ARG1A_SHIFT |
+ sswz[2] << R300_FPI2_ARG2A_SHIFT;
+ rp->alu.inst[s_idx].inst3 = hwdest << R300_FPI3_DSTA_SHIFT |
+ ssrc[0] << R300_FPI3_SRC0A_SHIFT |
+ ssrc[1] << R300_FPI3_SRC1A_SHIFT |
+ ssrc[2] << R300_FPI3_SRC2A_SHIFT |
+ (((mask & WRITEMASK_W)?1:0) << (dest.type == REG_TYPE_OUTPUT ? 24 : 23));
+ rp->s_pos = s_idx + 1;
+ }
+
+/* sync_streams(rp); */
+ return;
+};
+
+static GLboolean parse_program(struct r300_fragment_program *rp)
+{
+ struct fragment_program *mp = &rp->mesa_program;
+ const struct fp_instruction *inst = mp->Instructions;
+ struct fp_instruction *fpi;
+ pfs_reg_t src0, src1, src2, dest, temp;
+ int flags = 0;
+
+ if (!inst || inst[0].Opcode == FP_OPCODE_END) {
+ ERROR("empty program?\n");
+ return GL_FALSE;
+ }
+
+ for (fpi=mp->Instructions; fpi->Opcode != FP_OPCODE_END; fpi++) {
+ if (fpi->Saturate) {
+ flags = PFS_FLAG_SAT;
+ }
+
+ switch (fpi->Opcode) {
+ case FP_OPCODE_ABS:
+ ERROR("unknown fpi->Opcode %d\n", fpi->Opcode);
+ break;
+ case FP_OPCODE_ADD:
+ emit_arith(rp, PFS_OP_MAD, t_dst(rp, fpi->DstReg), fpi->DstReg.WriteMask,
+ t_src(rp, fpi->SrcReg[0]),
+ pfs_one,
+ t_src(rp, fpi->SrcReg[1]),
+ flags);
+ break;
+ case FP_OPCODE_CMP:
+ case FP_OPCODE_COS:
+ ERROR("unknown fpi->Opcode %d\n", fpi->Opcode);
+ break;
+ case FP_OPCODE_DP3:
+ dest = t_dst(rp, fpi->DstReg);
+ if (fpi->DstReg.WriteMask & WRITEMASK_W) {
+ /* I assume these need to share the same alu slot */
+ sync_streams(rp);
+ emit_arith(rp, PFS_OP_DP4, dest, WRITEMASK_W,
+ pfs_zero, pfs_zero, pfs_zero,
+ flags);
+ }
+ emit_arith(rp, PFS_OP_DP3, t_dst(rp, fpi->DstReg),
+ fpi->DstReg.WriteMask & WRITEMASK_XYZ,
+ t_src(rp, fpi->SrcReg[0]),
+ t_src(rp, fpi->SrcReg[1]),
+ pfs_zero, flags);
+ break;
+ case FP_OPCODE_DP4:
+ case FP_OPCODE_DPH:
+ case FP_OPCODE_DST:
+ case FP_OPCODE_EX2:
+ case FP_OPCODE_FLR:
+ case FP_OPCODE_FRC:
+ case FP_OPCODE_KIL:
+ case FP_OPCODE_LG2:
+ case FP_OPCODE_LIT:
+ ERROR("unknown fpi->Opcode %d\n", fpi->Opcode);
+ break;
+ case FP_OPCODE_LRP:
+ /* TODO: use the special LRP form if possible */
+ src0 = t_src(rp, fpi->SrcReg[0]);
+ src1 = t_src(rp, fpi->SrcReg[1]);
+ src2 = t_src(rp, fpi->SrcReg[2]);
+ // result = tmp0tmp1 + (1 - tmp0)tmp2
+ // = tmp0tmp1 + tmp2 + (-tmp0)tmp2
+ // MAD temp, -tmp0, tmp2, tmp2
+ // MAD result, tmp0, tmp1, temp
+ temp = get_temp_reg(rp);
+ emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_XYZW,
+ negate(src0), src2, src2, 0);
+ emit_arith(rp, PFS_OP_MAD, t_dst(rp, fpi->DstReg), fpi->DstReg.WriteMask,
+ src0, src1, temp, flags);
+ free_temp(rp, temp);
+ break;
+ case FP_OPCODE_MAD:
+ emit_arith(rp, PFS_OP_MAD, t_dst(rp, fpi->DstReg), fpi->DstReg.WriteMask,
+ t_src(rp, fpi->SrcReg[0]),
+ t_src(rp, fpi->SrcReg[1]),
+ t_src(rp, fpi->SrcReg[2]),
+ flags);
+ break;
+ case FP_OPCODE_MAX:
+ case FP_OPCODE_MIN:
+ ERROR("unknown fpi->Opcode %d\n", fpi->Opcode);
+ break;
+ case FP_OPCODE_MOV:
+ case FP_OPCODE_SWZ:
+ emit_arith(rp, PFS_OP_MAD, t_dst(rp, fpi->DstReg), fpi->DstReg.WriteMask,
+ t_src(rp, fpi->SrcReg[0]), pfs_one, pfs_zero,
+ flags);
+ break;
+ case FP_OPCODE_MUL:
+ emit_arith(rp, PFS_OP_MAD, t_dst(rp, fpi->DstReg), fpi->DstReg.WriteMask,
+ t_src(rp, fpi->SrcReg[0]),
+ t_src(rp, fpi->SrcReg[1]),
+ pfs_zero,
+ flags);
+ break;
+ case FP_OPCODE_POW:
+ src0 = t_src(rp, fpi->SrcReg[0]);
+ src1 = t_src(rp, fpi->SrcReg[1]);
+ dest = t_dst(rp, fpi->DstReg);
+ temp = get_temp_reg(rp);
+
+ emit_arith(rp, PFS_OP_LG2, temp, WRITEMASK_W,
+ src0, pfs_zero, pfs_zero, 0);
+ emit_arith(rp, PFS_OP_MAD, temp, WRITEMASK_W,
+ temp, src1, pfs_zero, 0);
+ emit_arith(rp, PFS_OP_EX2, dest, fpi->DstReg.WriteMask,
+ temp, pfs_zero, pfs_zero, 0);
+ free_temp(rp, temp);
+ break;
+ case FP_OPCODE_RCP:
+ ERROR("unknown fpi->Opcode %d\n", fpi->Opcode);
+ break;
+ case FP_OPCODE_RSQ:
+ emit_arith(rp, PFS_OP_RSQ, t_dst(rp, fpi->DstReg),
+ fpi->DstReg.WriteMask,
+ t_src(rp, fpi->SrcReg[0]), pfs_zero, pfs_zero,
+ flags | PFS_FLAG_ABS);
+ break;
+ case FP_OPCODE_SCS:
+ case FP_OPCODE_SGE:
+ case FP_OPCODE_SIN:
+ case FP_OPCODE_SLT:
+ ERROR("unknown fpi->Opcode %d\n", fpi->Opcode);
+ break;
+ case FP_OPCODE_SUB:
+ emit_arith(rp, PFS_OP_MAD, t_dst(rp, fpi->DstReg), fpi->DstReg.WriteMask,
+ t_src(rp, fpi->SrcReg[0]),
+ pfs_one,
+ negate(t_src(rp, fpi->SrcReg[1])),
+ flags);
+ break;
+ case FP_OPCODE_TEX:
+ emit_tex(rp, fpi, R300_FPITX_OP_TEX);
+ break;
+ case FP_OPCODE_TXB:
+ emit_tex(rp, fpi, R300_FPITX_OP_TXB);
+ break;
+ case FP_OPCODE_TXP:
+ emit_tex(rp, fpi, R300_FPITX_OP_TXP);
+ break;
+ case FP_OPCODE_XPD:
+ ERROR("unknown fpi->Opcode %d\n", fpi->Opcode);
+ break;
+ default:
+ ERROR("unknown fpi->Opcode %d\n", fpi->Opcode);
+ break;
+ }
+
+ if (rp->error)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+/* - Init structures
+ * - Determine what hwregs each input corresponds to
+ */
+static void init_program(struct r300_fragment_program *rp)
+{
+ struct fragment_program *mp = &rp->mesa_program;
+ struct fp_instruction *fpi;
+ GLuint InputsRead = mp->InputsRead;
+ GLuint fp_reg = 0;
+ GLuint temps_used = 0; /* for rp->temps[] */
+ int i;
+
+ rp->translated = GL_FALSE;
+ rp->error = GL_FALSE;
+
+ rp->v_pos = 0;
+ rp->s_pos = 0;
+
+ rp->tex.length = 0;
+ rp->node[0].alu_offset = 0;
+ rp->node[0].alu_end = -1;
+ rp->node[0].tex_offset = 0;
+ rp->node[0].tex_end = -1;
+ rp->cur_node = 0;
+ rp->first_node_has_tex = 0;
+ rp->used_in_node = 0;
+ rp->dest_in_node = 0;
+
+ rp->const_nr = 0;
+ rp->param_nr = 0;
+ rp->params_uptodate = GL_FALSE;
+
+ rp->temp_in_use = 0;
+ rp->hwreg_in_use = 0;
+ rp->max_temp_idx = 0;
+
+ /* Work out what temps the Mesa inputs correspond to, this must match
+ * what setup_rs_unit does, which shouldn't be a problem as rs_unit
+ * configures itself based on the fragprog's InputsRead
+ *
+ * I'm using get_hw_temp() here now rather than doing this manually.
+ * This depends on get_hw_temp() allocating registers in order, starting
+ * at 0 (which it currently does).
+ */
+
+ /* Texcoords come first */
+ for (i=0;i<rp->ctx->Const.MaxTextureUnits;i++) {
+ if (InputsRead & (FRAG_BIT_TEX0 << i))
+ rp->inputs[FRAG_ATTRIB_TEX0+i] = get_hw_temp(rp);
+ }
+ InputsRead &= ~FRAG_BITS_TEX_ANY;
+
+ /* Then primary colour */
+ if (InputsRead & FRAG_BIT_COL0)
+ rp->inputs[FRAG_ATTRIB_COL0] = get_hw_temp(rp);
+ InputsRead &= ~FRAG_BIT_COL0;
+
+ /* Secondary color */
+ if (InputsRead & FRAG_BIT_COL1)
+ rp->inputs[FRAG_ATTRIB_COL1] = get_hw_temp(rp);
+ InputsRead &= ~FRAG_BIT_COL1;
+
+ /* Anything else */
+ if (InputsRead) {
+ WARN_ONCE("Don't know how to handle inputs 0x%x\n", InputsRead);
+ /* force read from hwreg 0 for now */
+ for (i=0;i<32;i++)
+ if (InputsRead & (1<<i)) rp->inputs[i] = 0;
+ }
+
+ /* Possibly the worst part of how I went about this... Find out what
+ * temps are used by the mesa program so we don't clobber something
+ * when we need a temp for other reasons.
+ *
+ * Possibly not too bad actually, as we could add to this later and
+ * find out when inputs are last used so we can reuse them as temps.
+ */
+ if (!mp->Instructions) {
+ ERROR("No instructions found in program\n");
+ return;
+ }
+ for (fpi=mp->Instructions;fpi->Opcode != FP_OPCODE_END; fpi++) {
+ for (i=0;i<3;i++) {
+ if (fpi->SrcReg[i].File == PROGRAM_TEMPORARY) {
+ if (!(temps_used & (1 << fpi->SrcReg[i].Index))) {
+ temps_used |= (1 << fpi->SrcReg[i].Index);
+ rp->temps[fpi->SrcReg[i].Index] = get_hw_temp(rp);
+ }
+ }
+ }
+ /* needed? surely if a program writes a temp it'll read it again */
+ if (fpi->DstReg.File == PROGRAM_TEMPORARY) {
+ if (!(temps_used & (1 << fpi->DstReg.Index))) {
+ temps_used |= (1 << fpi->DstReg.Index);
+ rp->temps[fpi->DstReg.Index] = get_hw_temp(rp);
+ }
+ }
+ }
+ rp->temp_in_use = temps_used;
+}
+
+static void update_params(struct r300_fragment_program *rp) {
+ struct fragment_program *mp = &rp->mesa_program;
+ int i;
+
+ /* Ask Mesa nicely to fill in ParameterValues for us */
+ if (rp->param_nr)
+ _mesa_load_state_parameters(rp->ctx, mp->Parameters);
+
+ for (i=0;i<rp->param_nr;i++)
+ COPY_4V(rp->constant[rp->param[i].idx], rp->param[i].values);
+
+ rp->params_uptodate = GL_TRUE;
+}
+
+void translate_fragment_shader(struct r300_fragment_program *rp)
+{
+ int i;
+
+ if (!rp->translated) {
+ init_program(rp);
+
+ if (parse_program(rp) == GL_FALSE) {
+ dump_program(rp);
+ return;
+ }
+
+ /* Finish off */
+ sync_streams(rp);
+ rp->node[rp->cur_node].alu_end = rp->v_pos - 1;
+ rp->alu_offset = 0;
+ rp->alu_end = rp->v_pos - 1;
+ rp->tex_offset = 0;
+ rp->tex_end = rp->tex.length - 1;
+
+ rp->translated = GL_TRUE;
+ if (0) dump_program(rp);
+ }
+
+
+ update_params(rp);
+}
+
+/* just some random things... */
+static void dump_program(struct r300_fragment_program *rp)
+{
+ int i;
+ static int pc = 0;
+
+ fprintf(stderr, "pc=%d*************************************\n", pc++);
+
+ fprintf(stderr, "Mesa program:\n");
+ fprintf(stderr, "-------------\n");
+ _mesa_debug_fp_inst(rp->mesa_program.NumTexInstructions +
+ rp->mesa_program.NumAluInstructions,
+ rp->mesa_program.Instructions);
+ fflush(stdout);
+
+ fprintf(stderr, "Hardware program\n");
+ fprintf(stderr, "----------------\n");
+ for (i=0;i<(rp->cur_node+1);i++) {
+ fprintf(stderr, "NODE %d: alu_offset: %d, tex_offset: %d, alu_end: %d, tex_end: %d\n", i,
+ rp->node[i].alu_offset,
+ rp->node[i].tex_offset,
+ rp->node[i].alu_end,
+ rp->node[i].tex_end);
+ }
+
+/* dump program in pretty_print_command_stream.tcl-readable format */
+ fprintf(stderr, "%08x\n", ((rp->alu_end << 16) | (R300_PFS_INSTR0_0 >> 2)));
+ for (i=0;i<=rp->alu_end;i++)
+ fprintf(stderr, "%08x\n", rp->alu.inst[i].inst0);
+ fprintf(stderr, "%08x\n", ((rp->alu_end << 16) | (R300_PFS_INSTR1_0 >> 2)));
+ for (i=0;i<=rp->alu_end;i++)
+ fprintf(stderr, "%08x\n", rp->alu.inst[i].inst1);
+ fprintf(stderr, "%08x\n", ((rp->alu_end << 16) | (R300_PFS_INSTR2_0 >> 2)));
+ for (i=0;i<=rp->alu_end;i++)
+ fprintf(stderr, "%08x\n", rp->alu.inst[i].inst2);
+ fprintf(stderr, "%08x\n", ((rp->alu_end << 16) | (R300_PFS_INSTR3_0 >> 2)));
+ for (i=0;i<=rp->alu_end;i++)
+ fprintf(stderr, "%08x\n", rp->alu.inst[i].inst3);
+ fprintf(stderr, "00000000\n");
+
+}
+#endif // USE_ARB_F_P == 1
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_fragprog.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_fragprog.h
new file mode 100644
index 000000000..ed318eb6a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_fragprog.h
@@ -0,0 +1,49 @@
+#ifndef __R300_FRAGPROG_H_
+#define __R300_FRAGPROG_H_
+
+#include "glheader.h"
+#include "macros.h"
+#include "enums.h"
+
+#include "program.h"
+#include "r300_context.h"
+#include "nvfragprog.h"
+
+/* representation of a register for emit_arith/swizzle */
+typedef struct _pfs_reg_t {
+ enum {
+ REG_TYPE_INPUT,
+ REG_TYPE_OUTPUT,
+ REG_TYPE_TEMP,
+ REG_TYPE_CONST
+ } type:2;
+ GLuint index:6;
+ GLuint v_swz:5;
+ GLuint s_swz:5;
+ GLuint negate:1; //XXX: we need to handle negate individually
+ GLboolean valid:1;
+} pfs_reg_t;
+
+/* supported hw opcodes */
+#define PFS_OP_MAD 0
+#define PFS_OP_DP3 1
+#define PFS_OP_DP4 2
+#define PFS_OP_MIN 3
+#define PFS_OP_MAX 4
+#define PFS_OP_CMP 5
+#define PFS_OP_FRC 6
+#define PFS_OP_EX2 7
+#define PFS_OP_LG2 8
+#define PFS_OP_RCP 9
+#define PFS_OP_RSQ 10
+#define PFS_OP_REPL_ALPHA 11
+#define MAX_PFS_OP 11
+#define OP(n) PFS_OP_##n
+
+#define PFS_FLAG_SAT (1 << 0)
+#define PFS_FLAG_ABS (1 << 1)
+
+extern void translate_fragment_shader(struct r300_fragment_program *rp);
+
+#endif /* __R300_FRAGPROG_H_ */
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_fragprog_swz.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_fragprog_swz.c
new file mode 100644
index 000000000..00977ce68
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_fragprog_swz.c
@@ -0,0 +1,1343 @@
+/*
+ * Copyright (C) 2005 Jerome Glisse. 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 THE COPYRIGHT OWNER(S) 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.
+ *
+ */
+#include "r300_fragprog.h"
+#include "r300_reg.h"
+
+
+#define I0_000 ( (R300_FPI0_OUTC_MAD) | \
+ (R300_FPI0_ARGC_ZERO) | \
+ (R300_FPI0_ARGC_ZERO << R300_FPI0_ARG1C_SHIFT) | \
+ (R300_FPI0_ARGC_ZERO << R300_FPI0_ARG2C_SHIFT) )
+#define I0_111 ( (R300_FPI0_OUTC_MAD) | \
+ (R300_FPI0_ARGC_ZERO) | \
+ (R300_FPI0_ARGC_ZERO << R300_FPI0_ARG1C_SHIFT) | \
+ (R300_FPI0_ARGC_ONE << R300_FPI0_ARG2C_SHIFT) )
+#define I0_XXX ( (R300_FPI0_OUTC_MAD) | \
+ (R300_FPI0_ARGC_SRC0C_XXX) | \
+ (R300_FPI0_ARGC_ONE << R300_FPI0_ARG1C_SHIFT) | \
+ (R300_FPI0_ARGC_ZERO << R300_FPI0_ARG2C_SHIFT) )
+#define I0_YYY ( (R300_FPI0_OUTC_MAD) | \
+ (R300_FPI0_ARGC_SRC0C_YYY) | \
+ (R300_FPI0_ARGC_ONE << R300_FPI0_ARG1C_SHIFT) | \
+ (R300_FPI0_ARGC_ZERO << R300_FPI0_ARG2C_SHIFT) )
+#define I0_ZZZ ( (R300_FPI0_OUTC_MAD) | \
+ (R300_FPI0_ARGC_SRC0C_ZZZ) | \
+ (R300_FPI0_ARGC_ONE << R300_FPI0_ARG1C_SHIFT) | \
+ (R300_FPI0_ARGC_ZERO << R300_FPI0_ARG2C_SHIFT) )
+#define I0_XYZ ( (R300_FPI0_OUTC_MAD) | \
+ (R300_FPI0_ARGC_SRC0C_XYZ) | \
+ (R300_FPI0_ARGC_ONE << R300_FPI0_ARG1C_SHIFT) | \
+ (R300_FPI0_ARGC_ZERO << R300_FPI0_ARG2C_SHIFT) )
+#define I0_YZX ( (R300_FPI0_OUTC_MAD) | \
+ (R300_FPI0_ARGC_SRC0C_YZX) | \
+ (R300_FPI0_ARGC_ONE << R300_FPI0_ARG1C_SHIFT) | \
+ (R300_FPI0_ARGC_ZERO << R300_FPI0_ARG2C_SHIFT) )
+#define I0_ZXY ( (R300_FPI0_OUTC_MAD) | \
+ (R300_FPI0_ARGC_SRC0C_ZXY) | \
+ (R300_FPI0_ARGC_ONE << R300_FPI0_ARG1C_SHIFT) | \
+ (R300_FPI0_ARGC_ZERO << R300_FPI0_ARG2C_SHIFT) )
+#define I0_WZY ( (R300_FPI0_OUTC_MAD) | \
+ (R300_FPI0_ARGC_SRC0CA_WZY) | \
+ (R300_FPI0_ARGC_ONE << R300_FPI0_ARG1C_SHIFT) | \
+ (R300_FPI0_ARGC_ZERO << R300_FPI0_ARG2C_SHIFT) )
+
+#define IEMPTY 0
+#define I1_CST R300_FPI1_SRC0C_CONST
+
+#define I1_XYZ ( R300_FPI1_SRC1C_CONST | \
+ R300_FPI1_SRC2C_CONST | \
+ R300_FPI1_DSTC_REG_X | \
+ R300_FPI1_DSTC_REG_Y | \
+ R300_FPI1_DSTC_REG_Z )
+#define I1_XY_ ( R300_FPI1_SRC1C_CONST | \
+ R300_FPI1_SRC2C_CONST | \
+ R300_FPI1_DSTC_REG_X | \
+ R300_FPI1_DSTC_REG_Y )
+#define I1_X_Z ( R300_FPI1_SRC1C_CONST | \
+ R300_FPI1_SRC2C_CONST | \
+ R300_FPI1_DSTC_REG_X | \
+ R300_FPI1_DSTC_REG_Z )
+#define I1__YZ ( R300_FPI1_SRC1C_CONST | \
+ R300_FPI1_SRC2C_CONST | \
+ R300_FPI1_DSTC_REG_Y | \
+ R300_FPI1_DSTC_REG_Z )
+#define I1_X__ ( R300_FPI1_SRC1C_CONST | \
+ R300_FPI1_SRC2C_CONST | \
+ R300_FPI1_DSTC_REG_X )
+#define I1__Y_ ( R300_FPI1_SRC1C_CONST | \
+ R300_FPI1_SRC2C_CONST | \
+ R300_FPI1_DSTC_REG_Y )
+#define I1___Z ( R300_FPI1_SRC1C_CONST | \
+ R300_FPI1_SRC2C_CONST | \
+ R300_FPI1_DSTC_REG_Z )
+
+#define SEMPTY {0,{0,0,0,0},{0,0,0,0,0,0,0,0}}
+
+struct r300_fragment_program_swizzle r300_swizzle [512] = {
+ /* XXX */
+ {1,{0,0,0,0},{ I0_XXX, I1_XYZ,
+ 0, 0, 0, 0, 0, 0 } },
+ /* YXX */
+ {2,{0,0,0,0},{ I0_YYY, I1_X__,
+ I0_XXX, I1__YZ,
+ 0,0,
+ 0,0 } },
+ /* ZXX */
+ {2,{0,0,0,0},{ I0_ZZZ, I1_X__,
+ I0_XXX, I1__YZ,
+ 0,0,
+ 0,0 } },
+ /* WXX */
+ {2,{0,0,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1__YZ,
+ 0,0,
+ 0,0} },
+ /* 0XX */
+ {2,{0,2,0,0},{ I0_XXX, I1__YZ,
+ I0_000, I1_X__ | I1_CST,
+ 0,0,
+ 0,0 } },
+ /* 1XX */
+ {2,{0,2,0,0},{ I0_XXX, I1__YZ,
+ I0_111, I1_X__ | I1_CST,
+ 0,0,0,0}},
+ SEMPTY,SEMPTY,
+ /* XYX */
+ {2,{0,0,0,0},{ I0_YYY, I1__Y_,
+ I0_XXX, I1_X_Z,
+ 0,0,0,0}},
+ /* YYX */
+ {2,{0,0,0,0},{ I0_YYY, I1_XY_,
+ I0_XXX, I1___Z,
+ 0,0,0,0}},
+ /* ZYX */
+ {3,{0,0,0,0},{ I0_ZZZ, I1_X__,
+ I0_YYY, I1__Y_,
+ I0_XXX, I1___Z,
+ 0,0}},
+ /* WYX */
+ {3,{0,0,0,0},{ I0_WZY, I1_X__,
+ I0_YYY, I1__Y_,
+ I0_XXX, I1___Z,
+ 0,0}},
+ /* 0YX */
+ {3,{0,0,2,0},{ I0_YYY, I1__Y_,
+ I0_XXX, I1___Z,
+ I0_000, I1_X__ | I1_CST,
+ 0,0}},
+ /* 1YX */
+ {3,{0,0,2,0},{ I0_YYY, I1__Y_,
+ I0_XXX, I1___Z,
+ I0_111, I1_X__ | I1_CST,
+ 0,0}},
+ SEMPTY,SEMPTY,
+ /* XZX */
+ {2,{0,0,0,0},{ I0_YZX, I1__YZ,
+ I0_XXX, I1_X__,
+ 0,0,0,0}},
+ /* YZX */
+ {1,{0,0,0,0},{ I0_YZX, I1_XYZ,
+ 0, 0, 0, 0, 0, 0 } },
+ /* ZZX */
+ {2,{0,0,0,0},{ I0_YZX, I1__YZ,
+ I0_ZZZ, I1_X__,0,0,0,0}},
+ /* WZX */
+ {2,{0,0,0,0},{ I0_WZY, I1__YZ,
+ I0_XXX, I1_X__,0,0,0,0}},
+ /* 0ZX */
+ {2,{0,2,0,0},{ I0_YZX, I1__YZ,
+ I0_000, I1_X__ | I1_CST,
+ 0,0,0,0}},
+ /* 1ZX */
+ {2,{0,2,0,0},{ I0_YZX, I1__YZ,
+ I0_111, I1_X__ | I1_CST,
+ 0,0,0,0}},
+ SEMPTY,SEMPTY,
+ /* XWX */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1__Y_,
+ I0_XXX, I1_X_Z,
+ 0,0}},
+ /* YWX */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1__Y_,
+ I0_YZX, I1_X_Z,
+ 0,0}},
+ /* ZWX */
+ {4,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1__Y_,
+ I0_ZZZ, I1_X__,
+ I0_XXX, I1___Z } },
+ /* WWX */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1_XY_,
+ I0_YZX, I1___Z,
+ 0,0}},
+ /* 0WX */
+ {4,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1__Y_,
+ I0_YZX, I1___Z,
+ I0_000, I1_X__ | I1_CST } },
+ /* 1WX */
+ {4,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1__Y_,
+ I0_YZX, I1___Z,
+ I0_111, I1_X__ | I1_CST } },
+ SEMPTY,SEMPTY,
+ /* X0X */
+ {2,{0,2,0,0},{ I0_XXX, I1_X_Z,
+ I0_000, I1__Y_ | I1_CST,
+ 0,0,0,0}},
+ /* Y0X */
+ {2,{0,2,0,0},{ I0_YZX, I1_X_Z,
+ I0_000, I1__Y_ | I1_CST,
+ 0,0,0,0}},
+ /* Z0X */
+ {3,{0,2,0,0},{ I0_XXX, I1___Z,
+ I0_000, I1__Y_ | I1_CST,
+ I0_ZZZ, I1_X__,
+ 0,0}},
+ /* W0X */
+ {3,{0,2,0,0},{ I0_XXX, I1___Z,
+ I0_000, I1__Y_ | I1_CST,
+ I0_WZY, I1_X__,
+ 0,0}},
+ /* 00X */
+ {2,{0,2,0,0},{ I0_XXX, I1___Z,
+ I0_000, I1_XY_ | I1_CST,
+ 0,0,0,0}},
+ /* 10X */
+ {3,{0,2,0,0},{ I0_XXX, I1___Z,
+ I0_000, I1__Y_ | I1_CST,
+ I0_111, I1_X__ | I1_CST,
+ 0,0}},
+ SEMPTY,SEMPTY,
+ /* X1X */
+ {2,{0,2,0,0},{ I0_XXX, I1_X_Z,
+ I0_111, I1__Y_ | I1_CST,
+ 0,0,0,0}},
+ /* Y1X */
+ {2,{0,2,0,0},{ I0_YZX, I1_X_Z,
+ I0_111, I1__Y_ | I1_CST,
+ 0,0,0,0}},
+ /* Z1X */
+ {3,{0,2,0,0},{ I0_XXX, I1___Z,
+ I0_111, I1__Y_ | I1_CST,
+ I0_ZZZ, I1_X__,
+ 0,0}},
+ /* W1X */
+ {3,{0,2,0,0},{ I0_XXX, I1___Z,
+ I0_111, I1__Y_ | I1_CST,
+ I0_WZY, I1_X__,
+ 0,0}},
+ /* 01X */
+ {3,{0,2,0,0},{ I0_XXX, I1___Z,
+ I0_111, I1__Y_ | I1_CST,
+ I0_000, I1_X__ | I1_CST,
+ 0,0}},
+ /* 11X */
+ {2,{0,2,0,0},{ I0_XXX, I1___Z,
+ I0_111, I1_XY_ | I1_CST,
+ 0,0,0,0}},
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ /* XXY */
+ {2,{0,0,0,0},{ I0_YYY, I1___Z,
+ I0_XXX, I1_XY_,
+ 0,0,0,0}},
+ /* YXY */
+ {2,{0,0,0,0},{ I0_YYY, I1_X_Z,
+ I0_XXX, I1__Y_,
+ 0,0,0,0}},
+ /* ZXY */
+ {1,{0,0,0,0},{ I0_ZXY, I1_XYZ,
+ 0, 0, 0, 0, 0, 0 } },
+ /* WXY */
+ {2,{0,0,0,0},{ I0_WZY, I1_X__,
+ I0_ZXY, I1__YZ,
+ 0,0,0,0}},
+ /* 0XY */
+ {2,{0,0,0,0},{ I0_ZXY, I1__YZ,
+ I0_000, I1_X__ | I1_CST,
+ 0,0,0,0}},
+ /* 1XY */
+ {2,{0,0,0,0},{ I0_ZXY, I1__YZ,
+ I0_111, I1_X__ | I1_CST,
+ 0,0,0,0}},
+ SEMPTY,SEMPTY,
+ /* XYY */
+ {2,{0,0,0,0},{ I0_YYY, I1__YZ,
+ I0_XXX, I1_X__,
+ 0,0,0,0}},
+ /* YYY */
+ {1,{0,0,0,0},{ I0_YYY, I1_XYZ,
+ 0, 0, 0, 0, 0, 0 } },
+ /* ZYY */
+ {2,{0,0,0,0},{ I0_YYY, I1__YZ,
+ I0_ZZZ, I1_X__,
+ 0,0,0,0}},
+ /* WYY */
+ {2,{0,0,0,0},{ I0_YYY, I1__YZ,
+ I0_WZY, I1_X__,
+ 0,0,0,0}},
+ /* 0YY */
+ {2,{0,0,0,0},{ I0_YYY, I1__YZ,
+ I0_000, I1_X__ | I1_CST,
+ 0,0,0,0}},
+ /* 1YY */
+ {2,{0,0,0,0},{ I0_YYY, I1__YZ,
+ I0_111, I1_X__ | I1_CST,
+ 0,0,0,0}},
+ SEMPTY,SEMPTY,
+ /* XZY */
+ {2,{0,0,0,0},{ I0_WZY, I1__YZ,
+ I0_XXX, I1_X__,
+ 0,0,0,0}},
+ /* YZY */
+ {2,{0,0,0,0},{ I0_WZY, I1__YZ,
+ I0_YYY, I1_X__,
+ 0,0,0,0}},
+ /* ZZY */
+ {2,{0,0,0,0},{ I0_WZY, I1__YZ,
+ I0_ZZZ, I1_X__,
+ 0,0,0,0}},
+ /* WZY */
+ {1,{0,0,0,0},{ I0_WZY, I1_XYZ,
+ 0, 0, 0, 0, 0, 0 } },
+ /* 0ZY */
+ {2,{0,0,0,0},{ I0_WZY, I1__YZ,
+ I0_000, I1_X__ | I1_CST,
+ 0,0,0,0}},
+ /* 1ZY */
+ {2,{0,0,0,0},{ I0_WZY, I1__YZ,
+ I0_111, I1_X__ | I1_CST,
+ 0,0,0,0}},
+ SEMPTY,SEMPTY,
+ /* XWY */
+ {4,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1__Y_,
+ I0_XXX, I1_X__,
+ I0_YYY, I1___Z } },
+ /* YWY */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1__Y_,
+ I0_YYY, I1_X_Z,
+ 0,0}},
+ /* ZWY */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1__Y_,
+ I0_ZXY, I1_X_Z,
+ 0,0}},
+ /* WWY */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1_XY_,
+ I0_ZXY, I1___Z,
+ 0,0}},
+ /* 0WY */
+ {4,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1__Y_,
+ I0_ZXY, I1___Z,
+ I0_000, I1_X__ | I1_CST } },
+ /* 1WY */
+ {4,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1__Y_,
+ I0_ZXY, I1___Z,
+ I0_111, I1_X__ | I1_CST } },
+ SEMPTY,SEMPTY,
+ /* X0Y */
+ {3,{0,2,0,0},{ I0_XXX, I1_X__,
+ I0_000, I1__Y_ | I1_CST,
+ I0_YYY, I1___Z,
+ 0,0}},
+ /* Y0Y */
+ {2,{0,2,0,0},{ I0_YYY, I1_X_Z,
+ I0_000, I1__Y_ | I1_CST,
+ 0,0,0,0}},
+ /* Z0Y */
+ {2,{0,2,0,0},{ I0_ZXY, I1_X_Z,
+ I0_000, I1__Y_ | I1_CST,
+ 0,0,0,0}},
+ /* W0Y */
+ {2,{0,2,0,0},{ I0_WZY, I1_X_Z,
+ I0_000, I1__Y_ | I1_CST,
+ 0,0,0,0}},
+ /* 00Y */
+ {2,{0,2,0,0},{ I0_YYY, I1___Z,
+ I0_000, I1_XY_ | I1_CST,
+ 0,0,0,0}},
+ /* 10Y */
+ {3,{0,2,0,0},{ I0_YYY, I1___Z,
+ I0_000, I1__Y_ | I1_CST,
+ I0_111, I1_X__ | I1_CST,
+ 0,0}},
+ SEMPTY,SEMPTY,
+ /* X1Y */
+ {3,{0,2,0,0},{ I0_XXX, I1_X__,
+ I0_111, I1__Y_ | I1_CST,
+ I0_YYY, I1___Z,
+ 0,0}},
+ /* Y1Y */
+ {2,{0,2,0,0},{ I0_YYY, I1_X_Z,
+ I0_111, I1__Y_ | I1_CST,
+ 0,0,0,0}},
+ /* Z1Y */
+ {2,{0,2,0,0},{ I0_ZXY, I1_X_Z,
+ I0_111, I1__Y_ | I1_CST,
+ 0,0,0,0}},
+ /* W1Y */
+ {3,{0,2,0,0},{ I0_WZY, I1_X_Z,
+ I0_111, I1__Y_ | I1_CST,
+ 0,0,0,0}},
+ /* 01Y */
+ {3,{0,2,0,0},{ I0_YYY, I1___Z,
+ I0_111, I1__Y_ | I1_CST,
+ I0_000, I1_X__ | I1_CST,
+ 0,0}},
+ /* 11Y */
+ {2,{0,2,0,0},{ I0_YYY, I1___Z,
+ I0_111, I1_XY_ | I1_CST,
+ 0,0,0,0}},
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ /* XXZ */
+ {2,{0,0,0,0},{ I0_XXX, I1_XY_,
+ I0_ZZZ, I1___Z,
+ 0,0,0,0}},
+ /* YXZ */
+ {3,{0,0,0,0},{ I0_XXX, I1__Y_,
+ I0_YYY, I1_X__,
+ I0_ZZZ, I1___Z,
+ 0,0}},
+ /* ZXZ */
+ {2,{0,0,0,0},{ I0_XXX, I1__Y_,
+ I0_ZZZ, I1_X_Z,
+ 0,0,0,0}},
+ /* WXZ */
+ {3,{0,0,0,0},{ I0_XXX, I1__Y_,
+ I0_ZZZ, I1___Z,
+ I0_WZY, I1_X__,
+ 0,0}},
+ /* 0XZ */
+ {3,{0,0,2,0},{ I0_XXX, I1__Y_,
+ I0_ZZZ, I1___Z,
+ I0_000, I1_X__ | I1_CST,
+ 0,0}},
+ /* 1XZ */
+ {3,{0,0,2,0},{ I0_XXX, I1__Y_,
+ I0_ZZZ, I1___Z,
+ I0_111, I1_X__ | I1_CST,
+ 0,0}},
+ SEMPTY,SEMPTY,
+ /* XYZ */
+ {1,{0,0,0,0},{ I0_XYZ, I1_XYZ,
+ 0, 0, 0, 0, 0, 0 } },
+ /* YYZ */
+ {2,{0,0,0,0},{ I0_ZZZ, I1___Z,
+ I0_YYY, I1_XY_,
+ 0,0,0,0}},
+ /* ZYZ */
+ {2,{0,0,0,0},{ I0_ZZZ, I1_X_Z,
+ I0_YYY, I1__Y_,
+ 0,0,0,0}},
+ /* WYZ */
+ {2,{0,0,0,0},{ I0_XYZ, I1__YZ,
+ I0_WZY, I1_X__,
+ 0,0,0,0}},
+ /* 0YZ */
+ {2,{0,2,0,0},{ I0_XYZ, I1__YZ,
+ I0_000, I1_X__ | I1_CST,
+ 0,0,0,0}},
+ /* 1YZ */
+ {2,{0,2,0,0},{ I0_XYZ, I1__YZ,
+ I0_111, I1_X__ | I1_CST,
+ 0,0,0,0}},
+ SEMPTY,SEMPTY,
+ /* XZZ */
+ {2,{0,0,0,0},{ I0_ZZZ, I1__YZ,
+ I0_XXX, I1_X__,
+ 0,0,0,0}},
+ /* YZZ */
+ {2,{0,0,0,0},{ I0_ZZZ, I1__YZ,
+ I0_YYY, I1_X__,
+ 0,0,0,0}},
+ /* ZZZ */
+ {1,{0,0,0,0},{ I0_ZZZ, I1_XYZ,
+ 0, 0, 0, 0, 0, 0 } },
+ /* WZZ */
+ {2,{0,0,0,0},{ I0_ZZZ, I1__YZ,
+ I0_WZY, I1_X__,
+ 0,0,0,0}},
+ /* 0ZZ */
+ {2,{0,2,0,0},{ I0_ZZZ, I1__YZ,
+ I0_000, I1_X__ | I1_CST,
+ 0,0,0,0}},
+ /* 1ZZ */
+ {2,{0,2,0,0},{ I0_ZZZ, I1__YZ,
+ I0_111, I1_X__ | I1_CST,
+ 0,0,0,0}},
+ SEMPTY,SEMPTY,
+ /* XWZ */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1__Y_,
+ I0_XYZ, I1_X_Z,
+ 0,0}},
+ /* YWZ */
+ {4,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1__Y_,
+ I0_YYY, I1_X__,
+ I0_XYZ, I1___Z } },
+ /* ZWZ */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1__Y_,
+ I0_ZZZ, I1_X_Z,
+ 0,0}},
+ /* WWZ */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1_XY_,
+ I0_XYZ, I1___Z,
+ 0,0}},
+ /* 0WZ */
+ {4,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1__Y_,
+ I0_XYZ, I1___Z,
+ I0_000, I1_X__ | I1_CST } },
+ /* 1WZ */
+ {4,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1__Y_,
+ I0_XYZ, I1___Z,
+ I0_111, I1_X__ | I1_CST } },
+ SEMPTY,SEMPTY,
+ /* X0Z */
+ {2,{0,2,0,0},{ I0_XYZ, I1_X_Z,
+ I0_000, I1__Y_ | I1_CST,
+ 0,0,0,0}},
+ /* Y0Z */
+ {3,{0,2,0,0},{ I0_ZZZ, I1___Z,
+ I0_000, I1__Y_ | I1_CST,
+ I0_YYY, I1_X__,
+ 0,0}},
+ /* Z0Z */
+ {2,{0,2,0,0},{ I0_ZZZ, I1_X_Z,
+ I0_000, I1__Y_ | I1_CST,
+ 0,0,0,0}},
+ /* W0Z */
+ {3,{0,2,0,0},{ I0_ZZZ, I1___Z,
+ I0_000, I1__Y_ | I1_CST,
+ I0_WZY, I1_X__,
+ 0,0}},
+ /* 00Z */
+ {2,{0,2,0,0},{ I0_ZZZ, I1___Z,
+ I0_000, I1_XY_ | I1_CST,
+ 0,0,0,0}},
+ /* 10Z */
+ {3,{0,2,2,0},{ I0_ZZZ, I1___Z,
+ I0_000, I1__Y_ | I1_CST,
+ I0_111, I1_X__ | I1_CST,
+ 0,0}},
+ SEMPTY,SEMPTY,
+ /* X1Z */
+ {2,{0,2,0,0},{ I0_XYZ, I1_X_Z,
+ I0_111, I1__Y_ | I1_CST,
+ 0,0,0,0}},
+ /* Y1Z */
+ {3,{0,2,0,0},{ I0_ZZZ, I1___Z,
+ I0_111, I1__Y_ | I1_CST,
+ I0_YYY, I1_X__,
+ 0,0}},
+ /* Z1Z */
+ {2,{0,2,0,0},{ I0_ZZZ, I1_X_Z,
+ I0_111, I1__Y_ | I1_CST,
+ 0,0,0,0}},
+ /* W1Z */
+ {3,{0,2,0,0},{ I0_ZZZ, I1___Z,
+ I0_111, I1__Y_ | I1_CST,
+ I0_WZY, I1_X__,
+ 0,0}},
+ /* 01Z */
+ {3,{0,2,2,0},{ I0_ZZZ, I1___Z,
+ I0_111, I1__Y_ | I1_CST,
+ I0_000, I1_X__ | I1_CST,
+ 0,0}},
+ /* 11Z */
+ {2,{0,2,0,0},{ I0_ZZZ, I1___Z,
+ I0_111, I1_XY_ | I1_CST,
+ 0,0,0,0}},
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ /* XXW */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_XXX, I1_XY_,
+ 0,0}},
+ /* YXW */
+ {4,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_XXX, I1__Y_,
+ I0_YYY, I1_X__ } },
+ /* ZXW */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_ZXY, I1_XY_,
+ 0,0}},
+ /* WXW */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1_X_Z,
+ I0_XXX, I1__Y_,
+ 0,0}},
+ /* 0XW */
+ {4,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_XXX, I1__Y_,
+ I0_000, I1_X__ | I1_CST } },
+ /* 1XW */
+ {4,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_XXX, I1__Y_,
+ I0_111, I1_X__ | I1_CST } },
+ SEMPTY,SEMPTY,
+ /* XYW */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_XYZ, I1_XY_,
+ 0,0}},
+ /* YYW */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_YYY, I1_XY_,
+ 0,0}},
+ /* ZYW */
+ {4,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_XYZ, I1__Y_,
+ I0_ZZZ, I1_X__ } },
+ /* WYW */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1_X_Z,
+ I0_YYY, I1__Y_,
+ 0,0}},
+ /* 0YW */
+ {4,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_YYY, I1__Y_,
+ I0_000, I1_X__ | I1_CST } },
+ /* 1YW */
+ {4,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_YYY, I1__Y_,
+ I0_111, I1_X__ | I1_CST } },
+
+ SEMPTY,SEMPTY,
+ /* XZW */
+ {4,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_XYZ, I1_X__,
+ I0_ZZZ, I1__Y_ } },
+ /* YZW */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_YZX, I1_XY_,
+ 0,0}},
+ /* ZZW */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_ZZZ, I1_XY_,
+ 0,0}},
+ /* WZW */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1_X_Z,
+ I0_ZZZ, I1__Y_,
+ 0,0}},
+ /* 0ZW */
+ {4,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_ZZZ, I1__Y_,
+ I0_000, I1_X__ | I1_CST } },
+ /* 1ZW */
+ {4,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_ZZZ, I1__Y_,
+ I0_111, I1_X__ | I1_CST } },
+
+ SEMPTY,SEMPTY,
+ /* XWW */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1__YZ,
+ I0_XYZ, I1_X__,
+ 0,0}},
+ /* YWW */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1__YZ,
+ I0_YYY, I1_X__,
+ 0,0}},
+ /* ZWW */
+ {3,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1__YZ,
+ I0_ZZZ, I1_X__,
+ 0,0}},
+ /* WWW */
+ {2,{0,1,0,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1_XYZ,
+ 0,0,0,0}},
+ /* 0WW */
+ {3,{0,1,2,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1__YZ,
+ I0_000, I1_X__ | I1_CST,
+ 0,0}},
+ /* 1WW */
+ {3,{0,1,2,0},{ I0_WZY, I1_X__,
+ I0_XXX, I1__YZ,
+ I0_111, I1_X__ | I1_CST,
+ 0,0}},
+ SEMPTY,SEMPTY,
+ /* X0W */
+ {4,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_XYZ, I1_X__,
+ I0_000, I1__Y_ | I1_CST } },
+ /* Y0W */
+ {4,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_YYY, I1_X__,
+ I0_000, I1__Y_ | I1_CST } },
+ /* Z0W */
+ {4,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_ZZZ, I1_X__,
+ I0_000, I1__Y_ | I1_CST } },
+ /* 00W */
+ {3,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_000, I1_XY_ | I1_CST,
+ 0,0}},
+ /* 10W */
+ {4,{0,1,2,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_111, I1_X__ | I1_CST,
+ I0_000, I1__Y_ | I1_CST } },
+ SEMPTY,SEMPTY,
+ /* X1W */
+ {4,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_XYZ, I1_X__,
+ I0_111, I1__Y_ | I1_CST } },
+ /* Y1W */
+ {4,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_YYY, I1_X__,
+ I0_111, I1__Y_ | I1_CST } },
+ /* Z1W */
+ {4,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_ZZZ, I1_X__,
+ I0_111, I1__Y_ | I1_CST } },
+ /* 01W */
+ {4,{0,1,2,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_000, I1_X__ | I1_CST,
+ I0_111, I1__Y_ | I1_CST } },
+ /* 11W */
+ {3,{0,1,0,2},{ I0_WZY, I1_X__,
+ I0_XXX, I1___Z,
+ I0_111, I1_XY_ | I1_CST,
+ 0,0}},
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ /* XX0 */
+ {2,{2,0,0,0},{ I0_000, I1___Z | I1_CST,
+ I0_XXX, I1_XY_,
+ 0,0,0,0}},
+ /* YX0 */
+ {3,{2,0,0,0},{ I0_000, I1___Z | I1_CST,
+ I0_XXX, I1__Y_,
+ I0_YYY, I1_X__,
+ 0,0}},
+ /* ZX0 */
+ {2,{2,0,0,0},{ I0_000, I1___Z | I1_CST,
+ I0_ZXY, I1_XY_,
+ 0,0,0,0}},
+ /* WX0 */
+ {3,{2,0,0,0},{ I0_000, I1___Z | I1_CST,
+ I0_XXX, I1__Y_,
+ I0_WZY, I1_X__,
+ 0,0}},
+ /* 0X0 */
+ {2,{2,0,0,0},{ I0_000, I1_X_Z | I1_CST,
+ I0_XXX, I1__Y_,
+ 0,0,0,0}},
+ /* 1X0 */
+ {3,{2,0,2,0},{ I0_000, I1___Z | I1_CST,
+ I0_XXX, I1__Y_,
+ I0_111, I1_X__ | I1_CST,
+ 0,0}},
+ SEMPTY,SEMPTY,
+ /* XY0 */
+ {2,{2,0,0,0},{ I0_000, I1___Z | I1_CST,
+ I0_XYZ, I1_XY_,
+ 0,0,0,0}},
+ /* YY0 */
+ {2,{2,0,0,0},{ I0_000, I1___Z | I1_CST,
+ I0_YYY, I1_XY_,
+ 0,0,0,0}},
+ /* ZY0 */
+ {3,{2,0,0,0},{ I0_000, I1___Z | I1_CST,
+ I0_ZZZ, I1_X__,
+ I0_YYY, I1__Y_,
+ 0,0}},
+ /* WY0 */
+ {3,{2,0,0,0},{ I0_000, I1___Z | I1_CST,
+ I0_XYZ, I1__Y_,
+ I0_WZY, I1_X__,
+ 0,0}},
+ /* 0Y0 */
+ {2,{2,0,0,0},{ I0_000, I1_X_Z | I1_CST,
+ I0_XYZ, I1__Y_,
+ 0,0,0,0}},
+ /* 1Y0 */
+ {3,{2,0,2,0},{ I0_000, I1___Z | I1_CST,
+ I0_XYZ, I1__Y_,
+ I0_111, I1_X__ | I1_CST,
+ 0,0}},
+ SEMPTY,SEMPTY,
+ /* XZ0 */
+ {3,{2,0,0,0},{ I0_000, I1___Z | I1_CST,
+ I0_XYZ, I1_X__,
+ I0_ZZZ, I1__Y_,
+ 0,0}},
+ /* YZ0 */
+ {2,{2,0,0,0},{ I0_000, I1___Z | I1_CST,
+ I0_YZX, I1_XY_,
+ 0,0,0,0}},
+ /* ZZ0 */
+ {2,{2,0,0,0},{ I0_000, I1___Z | I1_CST,
+ I0_ZZZ, I1_XY_,
+ 0,0,0,0}},
+ /* WZ0 */
+ {2,{2,0,0,0},{ I0_000, I1___Z | I1_CST,
+ I0_WZY, I1_XY_,
+ 0,0,0,0}},
+ /* 0Z0 */
+ {2,{2,0,0,0},{ I0_000, I1_X_Z | I1_CST,
+ I0_ZZZ, I1__Y_,
+ 0,0,0,0}},
+ /* 1Z0 */
+ {3,{2,0,2,0},{ I0_000, I1___Z | I1_CST,
+ I0_ZZZ, I1__Y_,
+ I0_111, I1_X__ | I1_CST,
+ 0,0}},
+ SEMPTY,SEMPTY,
+ /* XW0 */
+ {4,{0,1,2,0},{ I0_WZY, I1_XYZ,
+ I0_XXX, I1__Y_,
+ I0_000, I1___Z | I1_CST,
+ I0_XYZ, I1_X__ } },
+ /* YW0 */
+ {4,{0,1,2,0},{ I0_WZY, I1_XYZ,
+ I0_XXX, I1__Y_,
+ I0_000, I1___Z | I1_CST,
+ I0_YYY, I1_X__ } },
+ /* ZW0 */
+ {4,{0,1,2,0},{ I0_WZY, I1_XYZ,
+ I0_XXX, I1__Y_,
+ I0_000, I1___Z | I1_CST,
+ I0_ZZZ, I1_X__ } },
+ /* WW0 */
+ {3,{0,1,2,0},{ I0_WZY, I1_XYZ,
+ I0_XXX, I1_XY_,
+ I0_000, I1___Z | I1_CST,
+ 0,0}},
+ /* 0W0 */
+ {3,{0,1,2,0},{ I0_WZY, I1_XYZ,
+ I0_XXX, I1__Y_,
+ I0_000, I1_X_Z | I1_CST,
+ 0,0}},
+ /* 1W0 */
+ {4,{0,1,2,2},{ I0_WZY, I1_XYZ,
+ I0_XXX, I1__Y_,
+ I0_000, I1___Z | I1_CST,
+ I0_111, I1_X__ | I1_CST } },
+ SEMPTY,SEMPTY,
+ /* X00 */
+ {2,{2,0,0,0},{ I0_000, I1__YZ | I1_CST,
+ I0_XYZ, I1_X__,
+ 0,0,0,0}},
+ /* Y00 */
+ {2,{2,0,0,0},{ I0_000, I1__YZ | I1_CST,
+ I0_YYY, I1_X__,
+ 0,0,0,0}},
+ /* Z00 */
+ {2,{2,0,0,0},{ I0_000, I1__YZ | I1_CST,
+ I0_ZZZ, I1_X__,
+ 0,0,0,0}},
+ /* W00 */
+ {2,{2,0,0,0},{ I0_000, I1__YZ | I1_CST,
+ I0_WZY, I1_X__,
+ 0,0,0,0}},
+ /* 000 */
+ {1,{2,0,0,0},{ I0_000, I1_XYZ | I1_CST,
+ 0, 0, 0, 0, 0, 0 } },
+ /* 100 */
+ {2,{2,2,0,0},{ I0_000, I1__YZ | I1_CST,
+ I0_111, I1_X__ | I1_CST,
+ 0,0,0,0}},
+ SEMPTY,SEMPTY,
+ /* X10 */
+ {3,{2,0,2,0},{ I0_000, I1___Z | I1_CST,
+ I0_XYZ, I1_X__,
+ I0_111, I1__Y_ | I1_CST,
+ 0,0}},
+ /* Y10 */
+ {3,{2,0,2,0},{ I0_000, I1___Z | I1_CST,
+ I0_YYY, I1_X__,
+ I0_111, I1__Y_ | I1_CST,
+ 0,0}},
+ /* Z10 */
+ {3,{2,0,2,0},{ I0_000, I1___Z | I1_CST,
+ I0_ZZZ, I1_X__,
+ I0_111, I1__Y_ | I1_CST,
+ 0,0}},
+ /* W10 */
+ {3,{2,0,2,0},{ I0_000, I1___Z | I1_CST,
+ I0_WZY, I1_X__,
+ I0_111, I1__Y_ | I1_CST,
+ 0,0}},
+ /* 010 */
+ {2,{2,2,0,0},{ I0_000, I1_X_Z | I1_CST,
+ I0_111, I1__Y_ | I1_CST,
+ 0, 0, 0, 0 } },
+ /* 110 */
+ {2,{2,2,0,0},{ I0_000, I1___Z | I1_CST,
+ I0_111, I1_XY_ | I1_CST,
+ 0,0,0,0}},
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+
+
+
+ /* XX1 */
+ {2,{2,0,0,0},{ I0_111, I1___Z | I1_CST,
+ I0_XXX, I1_XY_,
+ 0,0,0,0}},
+ /* YX1 */
+ {3,{2,0,0,0},{ I0_111, I1___Z | I1_CST,
+ I0_XXX, I1__Y_,
+ I0_YYY, I1_X__,
+ 0,0}},
+ /* ZX1 */
+ {2,{2,0,0,0},{ I0_111, I1___Z | I1_CST,
+ I0_ZXY, I1_XY_,
+ 0,0,0,0}},
+ /* WX1 */
+ {3,{2,0,0,0},{ I0_111, I1___Z | I1_CST,
+ I0_XXX, I1__Y_,
+ I0_WZY, I1_X__,
+ 0,0}},
+ /* 0X1 */
+ {3,{2,0,2,0},{ I0_111, I1___Z | I1_CST,
+ I0_XXX, I1__Y_,
+ I0_000, I1_X__ | I1_CST,
+ 0,0}},
+ /* 1X1 */
+ {2,{2,0,0,0},{ I0_111, I1_X_Z | I1_CST,
+ I0_XXX, I1__Y_,
+ 0,0,0,0}},
+ SEMPTY,SEMPTY,
+ /* XY1 */
+ {2,{2,0,0,0},{ I0_111, I1___Z | I1_CST,
+ I0_XYZ, I1_XY_,
+ 0,0,0,0}},
+ /* YY1 */
+ {2,{2,0,0,0},{ I0_111, I1___Z | I1_CST,
+ I0_YYY, I1_XY_,
+ 0,0,0,0}},
+ /* ZY1 */
+ {3,{2,0,0,0},{ I0_111, I1___Z | I1_CST,
+ I0_ZZZ, I1_X__,
+ I0_YYY, I1__Y_,
+ 0,0}},
+ /* WY1 */
+ {3,{2,0,0,0},{ I0_111, I1___Z | I1_CST,
+ I0_XYZ, I1__Y_,
+ I0_WZY, I1_X__,
+ 0,0}},
+ /* 0Y1 */
+ {3,{2,0,2,0},{ I0_111, I1___Z | I1_CST,
+ I0_XYZ, I1__Y_,
+ I0_000, I1_X__ | I1_CST,
+ 0,0}},
+ /* 1Y1 */
+ {2,{2,0,0,0},{ I0_111, I1_X_Z | I1_CST,
+ I0_XYZ, I1__Y_,
+ 0,0,0,0}},
+ SEMPTY,SEMPTY,
+ /* XZ1 */
+ {3,{2,0,0,0},{ I0_111, I1___Z | I1_CST,
+ I0_XYZ, I1_X__,
+ I0_ZZZ, I1__Y_,
+ 0,0}},
+ /* YZ1 */
+ {2,{2,0,0,0},{ I0_111, I1___Z | I1_CST,
+ I0_YZX, I1_XY_,
+ 0,0,0,0}},
+ /* ZZ1 */
+ {2,{2,0,0,0},{ I0_111, I1___Z | I1_CST,
+ I0_ZZZ, I1_XY_,
+ 0,0,0,0}},
+ /* WZ1 */
+ {2,{2,0,0,0},{ I0_111, I1___Z | I1_CST,
+ I0_WZY, I1_XY_,
+ 0,0,0,0}},
+ /* 0Z1 */
+ {3,{2,0,2,0},{ I0_111, I1___Z | I1_CST,
+ I0_ZZZ, I1__Y_,
+ I0_000, I1_X__ | I1_CST,
+ 0,0}},
+ /* 1Z1 */
+ {2,{2,0,0,0},{ I0_111, I1_X_Z | I1_CST,
+ I0_ZZZ, I1__Y_,
+ 0,0,0,0}},
+ SEMPTY,SEMPTY,
+ /* XW1 */
+ {4,{0,1,2,0},{ I0_WZY, I1_XYZ,
+ I0_XXX, I1__Y_,
+ I0_000, I1___Z | I1_CST,
+ I0_XYZ, I1_X__ } },
+ /* YW1 */
+ {4,{0,1,2,0},{ I0_WZY, I1_XYZ,
+ I0_XXX, I1__Y_,
+ I0_111, I1___Z | I1_CST,
+ I0_YYY, I1_X__ } },
+ /* ZW1 */
+ {4,{0,1,2,0},{ I0_WZY, I1_XYZ,
+ I0_XXX, I1__Y_,
+ I0_111, I1___Z | I1_CST,
+ I0_ZZZ, I1_X__ } },
+ /* WW1 */
+ {3,{0,1,2,0},{ I0_WZY, I1_XYZ,
+ I0_XXX, I1_XY_,
+ I0_111, I1___Z | I1_CST,
+ 0,0}},
+ /* 0W1 */
+ {4,{0,1,2,2},{ I0_WZY, I1_XYZ,
+ I0_XXX, I1__Y_,
+ I0_111, I1___Z | I1_CST,
+ I0_000, I1_X__ | I1_CST } },
+ /* 1W1 */
+ {3,{0,1,2,0},{ I0_WZY, I1_XYZ,
+ I0_XXX, I1__Y_,
+ I0_111, I1_X_Z | I1_CST,
+ 0,0}},
+ SEMPTY,SEMPTY,
+ /* X01 */
+ {3,{2,0,2,0},{ I0_111, I1___Z | I1_CST,
+ I0_XYZ, I1_X__,
+ I0_000, I1__Y_ | I1_CST,
+ 0,0}},
+ /* Y01 */
+ {3,{2,0,2,0},{ I0_111, I1___Z | I1_CST,
+ I0_YYY, I1_X__,
+ I0_000, I1__Y_ | I1_CST,
+ 0,0}},
+ /* Z01 */
+ {3,{2,0,2,0},{ I0_111, I1___Z | I1_CST,
+ I0_ZZZ, I1_X__,
+ I0_000, I1__Y_ | I1_CST,
+ 0,0}},
+ /* W01 */
+ {3,{2,0,2,0},{ I0_111, I1___Z | I1_CST,
+ I0_WZY, I1_X__,
+ I0_000, I1__Y_ | I1_CST,
+ 0,0}},
+ /* 001 */
+ {2,{2,2,0,0},{ I0_111, I1___Z | I1_CST,
+ I0_000, I1_XY_ | I1_CST,
+ 0,0,0,0}},
+ /* 101 */
+ {2,{2,2,0,0},{ I0_111, I1_X_Z | I1_CST,
+ I0_000, I1__Y_ | I1_CST,
+ 0, 0, 0, 0 } },
+ SEMPTY,SEMPTY,
+ /* X11 */
+ {2,{2,0,0,0},{ I0_111, I1__YZ | I1_CST,
+ I0_XYZ, I1_X__,
+ 0,0,0,0}},
+ /* Y11 */
+ {2,{2,0,0,0},{ I0_111, I1__YZ | I1_CST,
+ I0_YYY, I1_X__,
+ 0,0,0,0}},
+ /* Z11 */
+ {2,{2,0,0,0},{ I0_111, I1__YZ | I1_CST,
+ I0_ZZZ, I1_X__,
+ 0,0,0,0}},
+ /* W11 */
+ {2,{2,0,0,0},{ I0_111, I1__YZ | I1_CST,
+ I0_WZY, I1_X__,
+ 0,0,0,0}},
+ /* 011 */
+ {2,{2,2,0,0},{ I0_111, I1__YZ | I1_CST,
+ I0_000, I1_X__ | I1_CST,
+ 0,0,0,0}},
+ /* 111 */
+ {1,{2,0,0,0},{ I0_111, I1_XYZ | I1_CST,
+ 0, 0, 0, 0, 0, 0 } },
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,
+ SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY,SEMPTY
+};
+
+/******************************************************************************
+* Color source mask table
+******************************************************************************/
+
+#define S_111 R300_FPI0_ARGC_ONE
+#define S_000 R300_FPI0_ARGC_ZERO
+
+#define S0XXX R300_FPI0_ARGC_SRC0C_XXX
+#define S0YYY R300_FPI0_ARGC_SRC0C_YYY
+#define S0ZZZ R300_FPI0_ARGC_SRC0C_ZZZ
+#define S0XYZ R300_FPI0_ARGC_SRC0C_XYZ
+#define S0ZXY R300_FPI0_ARGC_SRC0C_ZXY
+#define S0YZX R300_FPI0_ARGC_SRC0C_YZX
+#define S0WZY R300_FPI0_ARGC_SRC0CA_WZY
+#define S0WZY R300_FPI0_ARGC_SRC0CA_WZY
+
+#define S1XXX R300_FPI0_ARGC_SRC1C_XXX
+#define S1YYY R300_FPI0_ARGC_SRC1C_YYY
+#define S1ZZZ R300_FPI0_ARGC_SRC1C_ZZZ
+#define S1XYZ R300_FPI0_ARGC_SRC1C_XYZ
+#define S1ZXY R300_FPI0_ARGC_SRC1C_ZXY
+#define S1YZX R300_FPI0_ARGC_SRC1C_YZX
+#define S1WZY R300_FPI0_ARGC_SRC1CA_WZY
+
+#define S2XXX R300_FPI0_ARGC_SRC2C_XXX
+#define S2YYY R300_FPI0_ARGC_SRC2C_YYY
+#define S2ZZZ R300_FPI0_ARGC_SRC2C_ZZZ
+#define S2XYZ R300_FPI0_ARGC_SRC2C_XYZ
+#define S2ZXY R300_FPI0_ARGC_SRC2C_ZXY
+#define S2YZX R300_FPI0_ARGC_SRC2C_YZX
+#define S2WZY R300_FPI0_ARGC_SRC2CA_WZY
+
+#define ntnat 32
+
+const GLuint r300_swz_srcc_mask[3][512] = {
+ {
+ S0XXX,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,S0YZX,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,S0ZXY,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,S0YYY,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,S0WZY,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,S0XYZ,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,S0ZZZ,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,S_000,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,S_111,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat
+ },
+ {
+ S1XXX,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,S1YZX,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,S1ZXY,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,S1YYY,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,S1WZY,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,S1XYZ,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,S1ZZZ,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,S_000,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,S_111,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat
+ },
+ {
+ S2XXX,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,S2YZX,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,S2ZXY,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,S2YYY,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,S2WZY,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,S2XYZ,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,S2ZZZ,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,S_000,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,S_111,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,ntnat,
+ ntnat,ntnat
+ }
+};
+
+/******************************************************************************
+* Alpha source mask table
+******************************************************************************/
+
+GLuint r300_swz_srca_mask[3][6] = {
+ { R300_FPI2_ARGA_SRC0C_X,
+ R300_FPI2_ARGA_SRC0C_Y,
+ R300_FPI2_ARGA_SRC0C_Z,
+ R300_FPI2_ARGA_SRC0A,
+ R300_FPI2_ARGA_ZERO,
+ R300_FPI2_ARGA_ONE },
+ { R300_FPI2_ARGA_SRC1C_X,
+ R300_FPI2_ARGA_SRC1C_Y,
+ R300_FPI2_ARGA_SRC1C_Z,
+ R300_FPI2_ARGA_SRC1A,
+ R300_FPI2_ARGA_ZERO,
+ R300_FPI2_ARGA_ONE },
+ { R300_FPI2_ARGA_SRC2C_X,
+ R300_FPI2_ARGA_SRC2C_Y,
+ R300_FPI2_ARGA_SRC2C_Z,
+ R300_FPI2_ARGA_SRC2A,
+ R300_FPI2_ARGA_ZERO,
+ R300_FPI2_ARGA_ONE },
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_ioctl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_ioctl.c
new file mode 100644
index 000000000..82379ebb3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_ioctl.c
@@ -0,0 +1,774 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002.
+Copyright (C) 2004 Nicolai Haehnle.
+All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ * Nicolai Haehnle <prefect_@gmx.net>
+ */
+
+#include <sched.h>
+#include <errno.h>
+
+#include "glheader.h"
+#include "imports.h"
+#include "macros.h"
+#include "context.h"
+#include "swrast/swrast.h"
+
+#include "r300_context.h"
+#include "radeon_ioctl.h"
+#include "r300_ioctl.h"
+#include "r300_cmdbuf.h"
+#include "r300_state.h"
+#include "r300_program.h"
+#include "radeon_reg.h"
+#include "r300_emit.h"
+
+#include "vblank.h"
+
+//#define CB_DPATH
+
+#define CLEARBUFFER_COLOR 0x1
+#define CLEARBUFFER_DEPTH 0x2
+#define CLEARBUFFER_STENCIL 0x4
+
+static void r300ClearBuffer(r300ContextPtr r300, int flags, int buffer)
+{
+ GLcontext* ctx = r300->radeon.glCtx;
+ __DRIdrawablePrivate *dPriv = r300->radeon.dri.drawable;
+ GLuint cboffset, cbpitch;
+ drm_r300_cmd_header_t* cmd2;
+#ifdef CB_DPATH
+ r300ContextPtr rmesa=r300;
+ LOCAL_VARS;
+#else
+ int i;
+#endif
+
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s: %s buffer (%i,%i %ix%i)\n",
+ __FUNCTION__, buffer ? "back" : "front",
+ dPriv->x, dPriv->y, dPriv->w, dPriv->h);
+
+ if (buffer) {
+ cboffset = r300->radeon.radeonScreen->backOffset;
+ cbpitch = r300->radeon.radeonScreen->backPitch;
+ } else {
+ cboffset = r300->radeon.radeonScreen->frontOffset;
+ cbpitch = r300->radeon.radeonScreen->frontPitch;
+ }
+
+ cboffset += r300->radeon.radeonScreen->fbLocation;
+
+#ifndef CB_DPATH
+ R300_STATECHANGE(r300, vir[0]);
+ ((drm_r300_cmd_header_t*)r300->hw.vir[0].cmd)->packet0.count = 1;
+ r300->hw.vir[0].cmd[1] = 0x21030003;
+
+ R300_STATECHANGE(r300, vir[1]);
+ ((drm_r300_cmd_header_t*)r300->hw.vir[1].cmd)->packet0.count = 1;
+ r300->hw.vir[1].cmd[1] = 0xF688F688;
+
+ R300_STATECHANGE(r300, vic);
+ r300->hw.vic.cmd[R300_VIC_CNTL_0] = 0x00000001;
+ r300->hw.vic.cmd[R300_VIC_CNTL_1] = 0x00000405;
+
+ R300_STATECHANGE(r300, vof);
+ r300->hw.vof.cmd[R300_VOF_CNTL_0] = R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT
+ | R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
+ r300->hw.vof.cmd[R300_VOF_CNTL_1] = 0; /* no textures */
+
+ R300_STATECHANGE(r300, txe);
+ r300->hw.txe.cmd[R300_TXE_ENABLE] = 0;
+
+ R300_STATECHANGE(r300, vpt);
+ r300->hw.vpt.cmd[R300_VPT_XSCALE] = r300PackFloat32(1.0);
+ r300->hw.vpt.cmd[R300_VPT_XOFFSET] = r300PackFloat32(dPriv->x);
+ r300->hw.vpt.cmd[R300_VPT_YSCALE] = r300PackFloat32(1.0);
+ r300->hw.vpt.cmd[R300_VPT_YOFFSET] = r300PackFloat32(dPriv->y);
+ r300->hw.vpt.cmd[R300_VPT_ZSCALE] = r300PackFloat32(1.0);
+ r300->hw.vpt.cmd[R300_VPT_ZOFFSET] = r300PackFloat32(0.0);
+
+ R300_STATECHANGE(r300, at);
+ r300->hw.at.cmd[R300_AT_ALPHA_TEST] = 0;
+
+ R300_STATECHANGE(r300, bld);
+ r300->hw.bld.cmd[R300_BLD_CBLEND] = 0;
+ r300->hw.bld.cmd[R300_BLD_ABLEND] = 0;
+
+ if (r300->radeon.radeonScreen->cpp == 4)
+ cbpitch |= R300_COLOR_FORMAT_ARGB8888;
+ else
+ cbpitch |= R300_COLOR_FORMAT_RGB565;
+
+ if (r300->radeon.sarea->tiling_enabled)
+ cbpitch |= R300_COLOR_TILE_ENABLE;
+
+ R300_STATECHANGE(r300, cb);
+ r300->hw.cb.cmd[R300_CB_OFFSET] = cboffset;
+ r300->hw.cb.cmd[R300_CB_PITCH] = cbpitch;
+
+ R300_STATECHANGE(r300, unk221C);
+ r300->hw.unk221C.cmd[1] = R300_221C_CLEAR;
+
+ R300_STATECHANGE(r300, ps);
+ r300->hw.ps.cmd[R300_PS_POINTSIZE] =
+ ((dPriv->w * 6) << R300_POINTSIZE_X_SHIFT) |
+ ((dPriv->h * 6) << R300_POINTSIZE_Y_SHIFT);
+
+ R300_STATECHANGE(r300, ri);
+ for(i = 1; i <= 8; ++i)
+ r300->hw.ri.cmd[i] = R300_RS_INTERP_USED;
+
+ R300_STATECHANGE(r300, rc);
+ /* The second constant is needed to get glxgears display anything .. */
+ r300->hw.rc.cmd[1] = (1 << R300_RS_CNTL_CI_CNT_SHIFT) | R300_RS_CNTL_0_UNKNOWN_18;
+ r300->hw.rc.cmd[2] = 0;
+
+ R300_STATECHANGE(r300, rr);
+ ((drm_r300_cmd_header_t*)r300->hw.rr.cmd)->packet0.count = 1;
+ r300->hw.rr.cmd[1] = 0x00004000;
+
+ R300_STATECHANGE(r300, cmk);
+ if (flags & CLEARBUFFER_COLOR) {
+ r300->hw.cmk.cmd[R300_CMK_COLORMASK] =
+ (ctx->Color.ColorMask[BCOMP] ? R300_COLORMASK0_B : 0) |
+ (ctx->Color.ColorMask[GCOMP] ? R300_COLORMASK0_G : 0) |
+ (ctx->Color.ColorMask[RCOMP] ? R300_COLORMASK0_R : 0) |
+ (ctx->Color.ColorMask[ACOMP] ? R300_COLORMASK0_A : 0);
+ } else {
+ r300->hw.cmk.cmd[R300_CMK_COLORMASK] = 0;
+ }
+
+ R300_STATECHANGE(r300, fp);
+ r300->hw.fp.cmd[R300_FP_CNTL0] = 0; /* 1 pass, no textures */
+ r300->hw.fp.cmd[R300_FP_CNTL1] = 0; /* no temporaries */
+ r300->hw.fp.cmd[R300_FP_CNTL2] = 0; /* no offset, one ALU instr */
+ r300->hw.fp.cmd[R300_FP_NODE0] = 0;
+ r300->hw.fp.cmd[R300_FP_NODE1] = 0;
+ r300->hw.fp.cmd[R300_FP_NODE2] = 0;
+ r300->hw.fp.cmd[R300_FP_NODE3] = R300_PFS_NODE_LAST_NODE;
+
+ R300_STATECHANGE(r300, fpi[0]);
+ R300_STATECHANGE(r300, fpi[1]);
+ R300_STATECHANGE(r300, fpi[2]);
+ R300_STATECHANGE(r300, fpi[3]);
+ ((drm_r300_cmd_header_t*)r300->hw.fpi[0].cmd)->packet0.count = 1;
+ ((drm_r300_cmd_header_t*)r300->hw.fpi[1].cmd)->packet0.count = 1;
+ ((drm_r300_cmd_header_t*)r300->hw.fpi[2].cmd)->packet0.count = 1;
+ ((drm_r300_cmd_header_t*)r300->hw.fpi[3].cmd)->packet0.count = 1;
+
+ /* MOV o0, t0 */
+ r300->hw.fpi[0].cmd[1] = FP_INSTRC(MAD, FP_ARGC(SRC0C_XYZ), FP_ARGC(ONE), FP_ARGC(ZERO));
+ r300->hw.fpi[1].cmd[1] = FP_SELC(0,NO,XYZ,FP_TMP(0),0,0);
+ r300->hw.fpi[2].cmd[1] = FP_INSTRA(MAD, FP_ARGA(SRC0A), FP_ARGA(ONE), FP_ARGA(ZERO));
+ r300->hw.fpi[3].cmd[1] = FP_SELA(0,NO,W,FP_TMP(0),0,0);
+
+ R300_STATECHANGE(r300, pvs);
+ r300->hw.pvs.cmd[R300_PVS_CNTL_1] =
+ (0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) |
+ (0 << R300_PVS_CNTL_1_POS_END_SHIFT) |
+ (1 << R300_PVS_CNTL_1_PROGRAM_END_SHIFT);
+ r300->hw.pvs.cmd[R300_PVS_CNTL_2] = 0; /* no parameters */
+ r300->hw.pvs.cmd[R300_PVS_CNTL_3] =
+ (1 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT);
+
+ R300_STATECHANGE(r300, vpi);
+ ((drm_r300_cmd_header_t*)r300->hw.vpi.cmd)->packet0.count = 8;
+
+ /* MOV o0, i0; */
+ r300->hw.vpi.cmd[1] = VP_OUT(ADD,OUT,0,XYZW);
+ r300->hw.vpi.cmd[2] = VP_IN(IN,0);
+ r300->hw.vpi.cmd[3] = VP_ZERO();
+ r300->hw.vpi.cmd[4] = 0;
+
+ /* MOV o1, i1; */
+ r300->hw.vpi.cmd[5] = VP_OUT(ADD,OUT,1,XYZW);
+ r300->hw.vpi.cmd[6] = VP_IN(IN,1);
+ r300->hw.vpi.cmd[7] = VP_ZERO();
+ r300->hw.vpi.cmd[8] = 0;
+
+ R300_STATECHANGE(r300, zs);
+ if (flags & CLEARBUFFER_DEPTH) {
+ r300->hw.zs.cmd[R300_ZS_CNTL_0] &= R300_RB3D_STENCIL_ENABLE;
+ r300->hw.zs.cmd[R300_ZS_CNTL_0] |= 0x6; // test and write
+ r300->hw.zs.cmd[R300_ZS_CNTL_1] &= ~(R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
+ r300->hw.zs.cmd[R300_ZS_CNTL_1] |= (R300_ZS_ALWAYS<<R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
+/*
+ R300_STATECHANGE(r300, zb);
+ r300->hw.zb.cmd[R300_ZB_OFFSET] =
+ 1024*4*300 +
+ r300->radeon.radeonScreen->frontOffset +
+ r300->radeon.radeonScreen->fbLocation;
+ r300->hw.zb.cmd[R300_ZB_PITCH] =
+ r300->radeon.radeonScreen->depthPitch;
+*/
+ } else {
+ r300->hw.zs.cmd[R300_ZS_CNTL_0] &= R300_RB3D_STENCIL_ENABLE;
+ r300->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_RB3D_Z_DISABLED_1; // disable
+ r300->hw.zs.cmd[R300_ZS_CNTL_1] &= ~(R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
+ }
+
+ R300_STATECHANGE(r300, zs);
+ if (flags & CLEARBUFFER_STENCIL) {
+ r300->hw.zs.cmd[R300_ZS_CNTL_0] &= ~R300_RB3D_STENCIL_ENABLE;
+ r300->hw.zs.cmd[R300_ZS_CNTL_0] |= R300_RB3D_STENCIL_ENABLE;
+ r300->hw.zs.cmd[R300_ZS_CNTL_1] &=
+ ~((R300_ZS_MASK << R300_RB3D_ZS1_FRONT_FUNC_SHIFT) | (R300_ZS_MASK << R300_RB3D_ZS1_BACK_FUNC_SHIFT));
+ r300->hw.zs.cmd[R300_ZS_CNTL_1] |=
+ (R300_ZS_ALWAYS<<R300_RB3D_ZS1_FRONT_FUNC_SHIFT) |
+ (R300_ZS_REPLACE<<R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT) |
+ (R300_ZS_REPLACE<<R300_RB3D_ZS1_FRONT_ZPASS_OP_SHIFT) |
+ (R300_ZS_REPLACE<<R300_RB3D_ZS1_FRONT_ZFAIL_OP_SHIFT) |
+ (R300_ZS_ALWAYS<<R300_RB3D_ZS1_BACK_FUNC_SHIFT) |
+ (R300_ZS_REPLACE<<R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT) |
+ (R300_ZS_REPLACE<<R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT) |
+ (R300_ZS_REPLACE<<R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT) ;
+ r300->hw.zs.cmd[R300_ZS_CNTL_2] = r300->state.stencil.clear;
+ }
+
+ /* Make sure we have enough space */
+ r300EnsureCmdBufSpace(r300, r300->hw.max_state_size + 9+8, __FUNCTION__);
+
+ r300EmitState(r300);
+#else
+ R300_STATECHANGE(r300, cb);
+ reg_start(R300_RB3D_COLOROFFSET0, 0);
+ e32(cboffset);
+
+ if (r300->radeon.radeonScreen->cpp == 4)
+ cbpitch |= R300_COLOR_FORMAT_ARGB8888;
+ else
+ cbpitch |= R300_COLOR_FORMAT_RGB565;
+
+ reg_start(R300_RB3D_COLORPITCH0, 0);
+ e32(cbpitch);
+
+ R300_STATECHANGE(r300, cmk);
+ reg_start(R300_RB3D_COLORMASK, 0);
+
+ if (flags & CLEARBUFFER_COLOR) {
+ e32((ctx->Color.ColorMask[BCOMP] ? R300_COLORMASK0_B : 0) |
+ (ctx->Color.ColorMask[GCOMP] ? R300_COLORMASK0_G : 0) |
+ (ctx->Color.ColorMask[RCOMP] ? R300_COLORMASK0_R : 0) |
+ (ctx->Color.ColorMask[ACOMP] ? R300_COLORMASK0_A : 0));
+ } else {
+ e32(0);
+ }
+
+ R300_STATECHANGE(r300, zs);
+ reg_start(R300_RB3D_ZSTENCIL_CNTL_0, 2);
+
+ {
+ uint32_t t1, t2;
+
+ t1 = r300->hw.zs.cmd[R300_ZS_CNTL_0];
+ t2 = r300->hw.zs.cmd[R300_ZS_CNTL_1];
+
+ if (flags & CLEARBUFFER_DEPTH) {
+ t1 &= R300_RB3D_STENCIL_ENABLE;
+ t1 |= 0x6; // test and write
+
+ t2 &= ~(R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
+ t2 |= (R300_ZS_ALWAYS<<R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
+/*
+ R300_STATECHANGE(r300, zb);
+ r300->hw.zb.cmd[R300_ZB_OFFSET] =
+ 1024*4*300 +
+ r300->radeon.radeonScreen->frontOffset +
+ r300->radeon.radeonScreen->fbLocation;
+ r300->hw.zb.cmd[R300_ZB_PITCH] =
+ r300->radeon.radeonScreen->depthPitch;
+*/
+ } else {
+ t1 &= R300_RB3D_STENCIL_ENABLE;
+ t1 |= R300_RB3D_Z_DISABLED_1; // disable
+
+ t2 &= ~(R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
+ }
+
+ if (flags & CLEARBUFFER_STENCIL) {
+ t1 &= ~R300_RB3D_STENCIL_ENABLE;
+ t1 |= R300_RB3D_STENCIL_ENABLE;
+
+ t2 &=
+ ~((R300_ZS_MASK << R300_RB3D_ZS1_FRONT_FUNC_SHIFT) | (R300_ZS_MASK << R300_RB3D_ZS1_BACK_FUNC_SHIFT));
+ t2 |=
+ (R300_ZS_ALWAYS<<R300_RB3D_ZS1_FRONT_FUNC_SHIFT) |
+ (R300_ZS_REPLACE<<R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT) |
+ (R300_ZS_REPLACE<<R300_RB3D_ZS1_FRONT_ZPASS_OP_SHIFT) |
+ (R300_ZS_REPLACE<<R300_RB3D_ZS1_FRONT_ZFAIL_OP_SHIFT) |
+ (R300_ZS_ALWAYS<<R300_RB3D_ZS1_BACK_FUNC_SHIFT) |
+ (R300_ZS_REPLACE<<R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT) |
+ (R300_ZS_REPLACE<<R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT) |
+ (R300_ZS_REPLACE<<R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT) ;
+ }
+
+ e32(t1);
+ e32(t2);
+ e32(r300->state.stencil.clear);
+ }
+
+#endif
+
+ cmd2 = (drm_r300_cmd_header_t*)r300AllocCmdBuf(r300, 9, __FUNCTION__);
+ cmd2[0].packet3.cmd_type = R300_CMD_PACKET3;
+ cmd2[0].packet3.packet = R300_CMD_PACKET3_CLEAR;
+ cmd2[1].u = r300PackFloat32(dPriv->w / 2.0);
+ cmd2[2].u = r300PackFloat32(dPriv->h / 2.0);
+ cmd2[3].u = r300PackFloat32(ctx->Depth.Clear);
+ cmd2[4].u = r300PackFloat32(1.0);
+ cmd2[5].u = r300PackFloat32(ctx->Color.ClearColor[0]);
+ cmd2[6].u = r300PackFloat32(ctx->Color.ClearColor[1]);
+ cmd2[7].u = r300PackFloat32(ctx->Color.ClearColor[2]);
+ cmd2[8].u = r300PackFloat32(ctx->Color.ClearColor[3]);
+
+}
+
+#ifdef CB_DPATH
+static void r300EmitClearState(GLcontext * ctx)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+ r300ContextPtr rmesa=r300;
+ __DRIdrawablePrivate *dPriv = r300->radeon.dri.drawable;
+ int i;
+ LOCAL_VARS;
+
+ R300_STATECHANGE(r300, vir[0]);
+ reg_start(R300_VAP_INPUT_ROUTE_0_0, 0);
+ e32(0x21030003);
+
+ R300_STATECHANGE(r300, vir[1]);
+ reg_start(R300_VAP_INPUT_ROUTE_1_0, 0);
+ e32(0xF688F688);
+
+ R300_STATECHANGE(r300, vic);
+ reg_start(R300_VAP_INPUT_CNTL_0, 1);
+ e32(0x00000001);
+ e32(0x00000405);
+
+ R300_STATECHANGE(r300, vof);
+ reg_start(R300_VAP_OUTPUT_VTX_FMT_0, 1);
+ e32(R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT | R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT);
+ e32(0); /* no textures */
+
+
+ R300_STATECHANGE(r300, txe);
+ reg_start(R300_TX_ENABLE, 0);
+ e32(0);
+
+ R300_STATECHANGE(r300, vpt);
+ reg_start(R300_SE_VPORT_XSCALE, 5);
+ efloat(1.0);
+ efloat(dPriv->x);
+ efloat(1.0);
+ efloat(dPriv->y);
+ efloat(1.0);
+ efloat(0.0);
+
+ R300_STATECHANGE(r300, at);
+ reg_start(R300_PP_ALPHA_TEST, 0);
+ e32(0);
+
+ R300_STATECHANGE(r300, bld);
+ reg_start(R300_RB3D_CBLEND, 1);
+ e32(0);
+ e32(0);
+
+ R300_STATECHANGE(r300, unk221C);
+ reg_start(0x221C, 0);
+ e32(R300_221C_CLEAR);
+
+ R300_STATECHANGE(r300, ps);
+ reg_start(R300_RE_POINTSIZE, 0);
+ e32(((dPriv->w * 6) << R300_POINTSIZE_X_SHIFT) |
+ ((dPriv->h * 6) << R300_POINTSIZE_Y_SHIFT));
+
+ R300_STATECHANGE(r300, ri);
+ reg_start(R300_RS_INTERP_0, 8);
+ for(i = 0; i < 8; ++i){
+ e32(R300_RS_INTERP_USED);
+ }
+
+ R300_STATECHANGE(r300, rc);
+ /* The second constant is needed to get glxgears display anything .. */
+ reg_start(R300_RS_CNTL_0, 1);
+ e32(R300_RS_CNTL_0_UNKNOWN_7 | R300_RS_CNTL_0_UNKNOWN_18);
+ e32(0);
+
+ R300_STATECHANGE(r300, rr);
+ reg_start(R300_RS_ROUTE_0, 0);
+ e32(0x00004000);
+
+ R300_STATECHANGE(r300, fp);
+ reg_start(R300_PFS_CNTL_0, 2);
+ e32(0);
+ e32(0);
+ e32(0);
+ reg_start(R300_PFS_NODE_0, 3);
+ e32(0);
+ e32(0);
+ e32(0);
+ e32(R300_PFS_NODE_LAST_NODE);
+
+ R300_STATECHANGE(r300, fpi[0]);
+ R300_STATECHANGE(r300, fpi[1]);
+ R300_STATECHANGE(r300, fpi[2]);
+ R300_STATECHANGE(r300, fpi[3]);
+
+ reg_start(R300_PFS_INSTR0_0, 0);
+ e32(FP_INSTRC(MAD, FP_ARGC(SRC0C_XYZ), FP_ARGC(ONE), FP_ARGC(ZERO)));
+
+ reg_start(R300_PFS_INSTR1_0, 0);
+ e32(FP_SELC(0,NO,XYZ,FP_TMP(0),0,0));
+
+ reg_start(R300_PFS_INSTR2_0, 0);
+ e32(FP_INSTRA(MAD, FP_ARGA(SRC0A), FP_ARGA(ONE), FP_ARGA(ZERO)));
+
+ reg_start(R300_PFS_INSTR3_0, 0);
+ e32(FP_SELA(0,NO,W,FP_TMP(0),0,0));
+
+ R300_STATECHANGE(r300, pvs);
+ reg_start(R300_VAP_PVS_CNTL_1, 2);
+ e32((0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT) |
+ (0 << R300_PVS_CNTL_1_POS_END_SHIFT) |
+ (1 << R300_PVS_CNTL_1_PROGRAM_END_SHIFT));
+ e32(0);
+ e32(1 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT);
+
+ R300_STATECHANGE(r300, vpi);
+ vsf_start_fragment(0x0, 8);
+ e32(VP_OUT(ADD,OUT,0,XYZW));
+ e32(VP_IN(IN,0));
+ e32(VP_ZERO());
+ e32(0);
+
+ e32(VP_OUT(ADD,OUT,1,XYZW));
+ e32(VP_IN(IN,1));
+ e32(VP_ZERO());
+ e32(0);
+
+}
+#endif
+
+/**
+ * Buffer clear
+ */
+static void r300Clear(GLcontext * ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = r300->radeon.dri.drawable;
+ int flags = 0;
+ int bits = 0;
+ int swapped;
+
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s: all=%d cx=%d cy=%d cw=%d ch=%d\n",
+ __FUNCTION__, all, cx, cy, cw, ch);
+
+ {
+ LOCK_HARDWARE(&r300->radeon);
+ UNLOCK_HARDWARE(&r300->radeon);
+ if (dPriv->numClipRects == 0)
+ return;
+ }
+
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
+ flags |= BUFFER_BIT_FRONT_LEFT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
+ }
+
+ if (mask & BUFFER_BIT_BACK_LEFT) {
+ flags |= BUFFER_BIT_BACK_LEFT;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
+ }
+
+ if (mask & BUFFER_BIT_DEPTH) {
+ bits |= CLEARBUFFER_DEPTH;
+ mask &= ~BUFFER_BIT_DEPTH;
+ }
+
+ if ( (mask & BUFFER_BIT_STENCIL) && r300->state.stencil.hw_stencil) {
+ bits |= CLEARBUFFER_STENCIL;
+ mask &= ~BUFFER_BIT_STENCIL;
+ }
+
+ if (mask) {
+ if (RADEON_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "%s: swrast clear, mask: %x\n",
+ __FUNCTION__, mask);
+ _swrast_Clear(ctx, mask, all, cx, cy, cw, ch);
+ }
+
+ swapped = r300->radeon.doPageFlip && (r300->radeon.sarea->pfCurrentPage == 1);
+
+#ifdef CB_DPATH
+ if(flags || bits)
+ r300EmitClearState(ctx);
+#endif
+
+ if (flags & BUFFER_BIT_FRONT_LEFT) {
+ r300ClearBuffer(r300, bits | CLEARBUFFER_COLOR, swapped);
+ bits = 0;
+ }
+
+ if (flags & BUFFER_BIT_BACK_LEFT) {
+ r300ClearBuffer(r300, bits | CLEARBUFFER_COLOR, swapped ^ 1);
+ bits = 0;
+ }
+
+ if (bits)
+ r300ClearBuffer(r300, bits, 0);
+
+#ifndef CB_DPATH
+ /* Recalculate the hardware state. This could be done more efficiently,
+ * but do keep it like this for now.
+ */
+ r300ResetHwState(r300);
+
+ /* r300ClearBuffer has trampled all over the hardware state.. */
+ r300->hw.all_dirty=GL_TRUE;
+#endif
+}
+
+void r300Flush(GLcontext * ctx)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (r300->cmdbuf.count_used > r300->cmdbuf.count_reemit)
+ r300FlushCmdBuf(r300, __FUNCTION__);
+}
+
+void r300RefillCurrentDmaRegion(r300ContextPtr rmesa)
+{
+ struct r300_dma_buffer *dmabuf;
+ int fd = rmesa->radeon.dri.fd;
+ int index = 0;
+ int size = 0;
+ drmDMAReq dma;
+ int ret;
+
+ if (RADEON_DEBUG & (DEBUG_IOCTL | DEBUG_DMA))
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (rmesa->dma.flush) {
+ rmesa->dma.flush(rmesa);
+ }
+
+ if (rmesa->dma.current.buf)
+ r300ReleaseDmaRegion(rmesa, &rmesa->dma.current, __FUNCTION__);
+
+ if (rmesa->dma.nr_released_bufs > 4)
+ r300FlushCmdBuf(rmesa, __FUNCTION__);
+
+ dma.context = rmesa->radeon.dri.hwContext;
+ dma.send_count = 0;
+ dma.send_list = NULL;
+ dma.send_sizes = NULL;
+ dma.flags = 0;
+ dma.request_count = 1;
+ dma.request_size = RADEON_BUFFER_SIZE;
+ dma.request_list = &index;
+ dma.request_sizes = &size;
+ dma.granted_count = 0;
+
+ LOCK_HARDWARE(&rmesa->radeon); /* no need to validate */
+
+ ret = drmDMA(fd, &dma);
+
+ if (ret != 0) {
+ /* Try to release some buffers and wait until we can't get any more */
+ if (rmesa->dma.nr_released_bufs) {
+ r300FlushCmdBufLocked(rmesa, __FUNCTION__);
+ }
+
+ if (RADEON_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "Waiting for buffers\n");
+
+ radeonWaitForIdleLocked(&rmesa->radeon);
+ ret = drmDMA(fd, &dma);
+
+ if (ret != 0) {
+ UNLOCK_HARDWARE(&rmesa->radeon);
+ fprintf(stderr, "Error: Could not get dma buffer... exiting\n");
+ exit(-1);
+ }
+ }
+
+ UNLOCK_HARDWARE(&rmesa->radeon);
+
+ if (RADEON_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "Allocated buffer %d\n", index);
+
+ dmabuf = CALLOC_STRUCT(r300_dma_buffer);
+ dmabuf->buf = &rmesa->radeon.radeonScreen->buffers->list[index];
+ dmabuf->refcount = 1;
+
+ rmesa->dma.current.buf = dmabuf;
+ rmesa->dma.current.address = dmabuf->buf->address;
+ rmesa->dma.current.end = dmabuf->buf->total;
+ rmesa->dma.current.start = 0;
+ rmesa->dma.current.ptr = 0;
+}
+
+void r300ReleaseDmaRegion(r300ContextPtr rmesa,
+ struct r300_dma_region *region, const char *caller)
+{
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
+
+ if (!region->buf)
+ return;
+
+ if (rmesa->dma.flush)
+ rmesa->dma.flush(rmesa);
+
+ if (--region->buf->refcount == 0) {
+ drm_radeon_cmd_header_t *cmd;
+
+ if (RADEON_DEBUG & (DEBUG_IOCTL | DEBUG_DMA))
+ fprintf(stderr, "%s -- DISCARD BUF %d\n", __FUNCTION__,
+ region->buf->buf->idx);
+ cmd =
+ (drm_radeon_cmd_header_t *) r300AllocCmdBuf(rmesa,
+ sizeof(*cmd) / 4,
+ __FUNCTION__);
+ cmd->dma.cmd_type = R300_CMD_DMA_DISCARD;
+ cmd->dma.buf_idx = region->buf->buf->idx;
+
+ FREE(region->buf);
+ rmesa->dma.nr_released_bufs++;
+ }
+
+ region->buf = 0;
+ region->start = 0;
+}
+
+/* Allocates a region from rmesa->dma.current. If there isn't enough
+ * space in current, grab a new buffer (and discard what was left of current)
+ */
+void r300AllocDmaRegion(r300ContextPtr rmesa,
+ struct r300_dma_region *region,
+ int bytes, int alignment)
+{
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s %d\n", __FUNCTION__, bytes);
+
+ if (rmesa->dma.flush)
+ rmesa->dma.flush(rmesa);
+
+ if (region->buf)
+ r300ReleaseDmaRegion(rmesa, region, __FUNCTION__);
+
+ alignment--;
+ rmesa->dma.current.start = rmesa->dma.current.ptr =
+ (rmesa->dma.current.ptr + alignment) & ~alignment;
+
+ if (rmesa->dma.current.ptr + bytes > rmesa->dma.current.end)
+ r300RefillCurrentDmaRegion(rmesa);
+
+ region->start = rmesa->dma.current.start;
+ region->ptr = rmesa->dma.current.start;
+ region->end = rmesa->dma.current.start + bytes;
+ region->address = rmesa->dma.current.address;
+ region->buf = rmesa->dma.current.buf;
+ region->buf->refcount++;
+
+ rmesa->dma.current.ptr += bytes; /* bug - if alignment > 7 */
+ rmesa->dma.current.start =
+ rmesa->dma.current.ptr = (rmesa->dma.current.ptr + 0x7) & ~0x7;
+
+ assert(rmesa->dma.current.ptr <= rmesa->dma.current.end);
+}
+
+/* Called via glXGetMemoryOffsetMESA() */
+GLuint r300GetMemoryOffsetMESA(__DRInativeDisplay * dpy, int scrn,
+ const GLvoid * pointer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ r300ContextPtr rmesa;
+ GLuint card_offset;
+
+ if (!ctx || !(rmesa = R300_CONTEXT(ctx))) {
+ fprintf(stderr, "%s: no context\n", __FUNCTION__);
+ return ~0;
+ }
+
+ if (!r300IsGartMemory(rmesa, pointer, 0))
+ return ~0;
+
+ if (rmesa->radeon.dri.drmMinor < 6)
+ return ~0;
+
+ card_offset = r300GartOffsetFromVirtual(rmesa, pointer);
+
+ return card_offset - rmesa->radeon.radeonScreen->gart_base;
+}
+
+GLboolean r300IsGartMemory(r300ContextPtr rmesa, const GLvoid * pointer,
+ GLint size)
+{
+ int offset =
+ (char *)pointer - (char *)rmesa->radeon.radeonScreen->gartTextures.map;
+ int valid = (size >= 0 && offset >= 0
+ && offset + size < rmesa->radeon.radeonScreen->gartTextures.size);
+
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "r300IsGartMemory( %p ) : %d\n", pointer,
+ valid);
+
+ return valid;
+}
+
+GLuint r300GartOffsetFromVirtual(r300ContextPtr rmesa, const GLvoid * pointer)
+{
+ int offset =
+ (char *)pointer - (char *)rmesa->radeon.radeonScreen->gartTextures.map;
+
+ //fprintf(stderr, "offset=%08x\n", offset);
+
+ if (offset < 0 || offset > rmesa->radeon.radeonScreen->gartTextures.size)
+ return ~0;
+ else
+ return rmesa->radeon.radeonScreen->gart_texture_offset + offset;
+}
+
+void r300InitIoctlFuncs(struct dd_function_table *functions)
+{
+ functions->Clear = r300Clear;
+ functions->Finish = radeonFinish;
+ functions->Flush = r300Flush;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_ioctl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_ioctl.h
new file mode 100644
index 000000000..5514214cc
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_ioctl.h
@@ -0,0 +1,62 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ * Nicolai Haehnle <prefect_@gmx.net>
+ */
+
+#ifndef __R300_IOCTL_H__
+#define __R300_IOCTL_H__
+
+#include "r300_context.h"
+#include "radeon_drm.h"
+
+extern GLuint r300GetMemoryOffsetMESA(__DRInativeDisplay * dpy, int scrn,
+ const GLvoid * pointer);
+
+extern GLboolean r300IsGartMemory(r300ContextPtr rmesa, const GLvoid * pointer,
+ GLint size);
+
+extern GLuint r300GartOffsetFromVirtual(r300ContextPtr rmesa,
+ const GLvoid * pointer);
+
+extern void r300Flush(GLcontext * ctx);
+
+extern void r300RefillCurrentDmaRegion(r300ContextPtr rmesa);
+extern void r300ReleaseDmaRegion(r300ContextPtr rmesa,
+ struct r300_dma_region *region, const char *caller);
+extern void r300AllocDmaRegion(r300ContextPtr rmesa,
+ struct r300_dma_region *region,
+ int bytes, int alignment);
+
+extern void r300InitIoctlFuncs(struct dd_function_table *functions);
+
+#endif /* __R300_IOCTL_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_maos.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_maos.c
new file mode 100644
index 000000000..1908ac07a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_maos.c
@@ -0,0 +1,561 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r300/r300_maos_arrays.c,v 1.3 2003/02/23 23:59:01 dawes Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "colormac.h"
+#include "imports.h"
+#include "macros.h"
+
+#include "swrast_setup/swrast_setup.h"
+#include "math/m_translate.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+
+#include "r300_context.h"
+#include "radeon_ioctl.h"
+#include "r300_state.h"
+#include "r300_maos.h"
+#include "r300_ioctl.h"
+
+#define DEBUG_ALL DEBUG_VERTS
+
+
+#if defined(USE_X86_ASM)
+#define COPY_DWORDS( dst, src, nr ) \
+do { \
+ int __tmp; \
+ __asm__ __volatile__( "rep ; movsl" \
+ : "=%c" (__tmp), "=D" (dst), "=S" (__tmp) \
+ : "0" (nr), \
+ "D" ((long)dst), \
+ "S" ((long)src) ); \
+} while (0)
+#else
+#define COPY_DWORDS( dst, src, nr ) \
+do { \
+ int j; \
+ for ( j = 0 ; j < nr ; j++ ) \
+ dst[j] = ((int *)src)[j]; \
+ dst += nr; \
+} while (0)
+#endif
+
+static void emit_vec4(GLcontext * ctx,
+ struct r300_dma_region *rvb,
+ GLvoid *data, int stride, int count)
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d\n",
+ __FUNCTION__, count, stride);
+
+ if (stride == 4)
+ COPY_DWORDS(out, data, count);
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out++;
+ data += stride;
+ }
+}
+
+static void emit_vec8(GLcontext * ctx,
+ struct r300_dma_region *rvb,
+ GLvoid *data, int stride, int count)
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d\n",
+ __FUNCTION__, count, stride);
+
+ if (stride == 8)
+ COPY_DWORDS(out, data, count * 2);
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out[1] = *(int *)(data + 4);
+ out += 2;
+ data += stride;
+ }
+}
+
+static void emit_vec12(GLcontext * ctx,
+ struct r300_dma_region *rvb,
+ GLvoid *data, int stride, int count)
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d out %p data %p\n",
+ __FUNCTION__, count, stride, (void *)out, (void *)data);
+
+ if (stride == 12)
+ COPY_DWORDS(out, data, count * 3);
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out[1] = *(int *)(data + 4);
+ out[2] = *(int *)(data + 8);
+ out += 3;
+ data += stride;
+ }
+}
+
+static void emit_vec16(GLcontext * ctx,
+ struct r300_dma_region *rvb,
+ GLvoid *data, int stride, int count)
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d\n",
+ __FUNCTION__, count, stride);
+
+ if (stride == 16)
+ COPY_DWORDS(out, data, count * 4);
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out[1] = *(int *)(data + 4);
+ out[2] = *(int *)(data + 8);
+ out[3] = *(int *)(data + 12);
+ out += 4;
+ data += stride;
+ }
+}
+
+static void emit_vector(GLcontext * ctx,
+ struct r300_dma_region *rvb,
+ GLvoid *data, int size, int stride, int count)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d size %d stride %d\n",
+ __FUNCTION__, count, size, stride);
+
+ if(r300IsGartMemory(rmesa, data, size*stride)){
+ rvb->address = rmesa->radeon.radeonScreen->gartTextures.map;
+ rvb->start = (char *)data - rvb->address;
+ rvb->aos_offset = r300GartOffsetFromVirtual(rmesa, data);
+
+ if(stride == 0)
+ rvb->aos_stride = 0;
+ else
+ rvb->aos_stride = stride / 4;
+
+ rvb->aos_size = size;
+ return;
+ }
+
+ /* Gets triggered when playing with future_hw_tcl_on ...*/
+ //assert(!rvb->buf);
+
+ if (stride == 0) {
+ r300AllocDmaRegion(rmesa, rvb, size * 4, 4);
+ count = 1;
+ rvb->aos_offset = GET_START(rvb);
+ rvb->aos_stride = 0;
+ rvb->aos_size = size;
+ } else {
+ r300AllocDmaRegion(rmesa, rvb, size * count * 4, 4); /* alignment? */
+ rvb->aos_offset = GET_START(rvb);
+ rvb->aos_stride = size;
+ rvb->aos_size = size;
+ }
+
+ /* Emit the data
+ */
+ switch (size) {
+ case 1:
+ emit_vec4(ctx, rvb, data, stride, count);
+ break;
+ case 2:
+ emit_vec8(ctx, rvb, data, stride, count);
+ break;
+ case 3:
+ emit_vec12(ctx, rvb, data, stride, count);
+ break;
+ case 4:
+ emit_vec16(ctx, rvb, data, stride, count);
+ break;
+ default:
+ assert(0);
+ exit(1);
+ break;
+ }
+
+}
+
+void r300EmitElts(GLcontext * ctx, GLuint *elts, unsigned long n_elts)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ struct r300_dma_region *rvb=&rmesa->state.elt_dma;
+ unsigned short int *out;
+ int i;
+
+ if(r300IsGartMemory(rmesa, elts, n_elts*sizeof(unsigned short int))){
+ rvb->address = rmesa->radeon.radeonScreen->gartTextures.map;
+ rvb->start = (char *)elts - rvb->address;
+ rvb->aos_offset = rmesa->radeon.radeonScreen->gart_texture_offset + rvb->start;
+ return ;
+ }
+
+ r300AllocDmaRegion(rmesa, rvb, n_elts*sizeof(unsigned short int), 2);
+
+ out = (unsigned short int *)(rvb->address + rvb->start);
+
+ for(i=0; i < n_elts; i++)
+ out[i]=(unsigned short int)elts[i];
+}
+
+/* Emit vertex data to GART memory (unless immediate mode)
+ * Route inputs to the vertex processor
+ */
+void r300EmitArrays(GLcontext * ctx, GLboolean immd)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ r300ContextPtr r300 = rmesa;
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLuint nr = 0;
+ GLuint count = VB->Count;
+ GLuint dw,mask;
+ GLuint vic_1 = 0; /* R300_VAP_INPUT_CNTL_1 */
+ GLuint aa_vap_reg = 0; /* VAP register assignment */
+ GLuint i;
+ GLuint inputs = 0;
+
+
+#define CONFIGURE_AOS(r, f, v, sz, cn) { \
+ if (RADEON_DEBUG & DEBUG_STATE) \
+ fprintf(stderr, "Enabling "#v "\n"); \
+ if (++nr >= R300_MAX_AOS_ARRAYS) { \
+ fprintf(stderr, "Aieee! AOS array count exceeded!\n"); \
+ exit(-1); \
+ } \
+ \
+ if (hw_tcl_on == GL_FALSE) \
+ rmesa->state.aos[nr-1].aos_reg = aa_vap_reg++; \
+ rmesa->state.aos[nr-1].aos_format = f; \
+ if (immd) { \
+ rmesa->state.aos[nr-1].aos_size = 4; \
+ rmesa->state.aos[nr-1].aos_stride = 4; \
+ rmesa->state.aos[nr-1].aos_offset = 0; \
+ } else { \
+ emit_vector(ctx, \
+ &rmesa->state.aos[nr-1], \
+ v->data, \
+ sz, \
+ v->stride, \
+ cn); \
+ rmesa->state.vap_reg.r=rmesa->state.aos[nr-1].aos_reg; \
+ } \
+}
+
+ if (hw_tcl_on) {
+ GLuint InputsRead = CURRENT_VERTEX_SHADER(ctx)->InputsRead;
+ struct r300_vertex_program *prog=(struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
+ if (InputsRead & (1<<VERT_ATTRIB_POS)) {
+ inputs |= _TNL_BIT_POS;
+ rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_POS];
+ }
+ if (InputsRead & (1<<VERT_ATTRIB_NORMAL)) {
+ inputs |= _TNL_BIT_NORMAL;
+ rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_NORMAL];
+ }
+ if (InputsRead & (1<<VERT_ATTRIB_COLOR0)) {
+ inputs |= _TNL_BIT_COLOR0;
+ rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_COLOR0];
+ }
+ if (InputsRead & (1<<VERT_ATTRIB_COLOR1)) {
+ inputs |= _TNL_BIT_COLOR1;
+ rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_COLOR1];
+ }
+ if (InputsRead & (1<<VERT_ATTRIB_FOG)) {
+ inputs |= _TNL_BIT_FOG;
+ rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_FOG];
+ }
+ if(ctx->Const.MaxTextureUnits > 8) { /* Not sure if this can even happen... */
+ fprintf(stderr, "%s: Cant handle that many inputs\n", __FUNCTION__);
+ exit(-1);
+ }
+ for (i=0;i<ctx->Const.MaxTextureUnits;i++) {
+ if (InputsRead & (1<<(VERT_ATTRIB_TEX0+i))) {
+ inputs |= _TNL_BIT_TEX0<<i;
+ rmesa->state.aos[nr++].aos_reg = prog->inputs[VERT_ATTRIB_TEX0+i];
+ }
+ }
+ nr = 0;
+ } else {
+ inputs = TNL_CONTEXT(ctx)->render_inputs;
+ }
+ rmesa->state.render_inputs = inputs;
+
+ if (inputs & _TNL_BIT_POS) {
+ CONFIGURE_AOS(i_coords, AOS_FORMAT_FLOAT,
+ VB->ObjPtr,
+ immd ? 4 : VB->ObjPtr->size,
+ count);
+
+ vic_1 |= R300_INPUT_CNTL_POS;
+ }
+
+ if (inputs & _TNL_BIT_NORMAL) {
+ CONFIGURE_AOS(i_normal, AOS_FORMAT_FLOAT,
+ VB->NormalPtr,
+ immd ? 4 : VB->NormalPtr->size,
+ count);
+
+ vic_1 |= R300_INPUT_CNTL_NORMAL;
+ }
+
+ if (inputs & _TNL_BIT_COLOR0) {
+ int emitsize=4;
+
+ if (!immd) {
+ if (VB->ColorPtr[0]->size == 4 &&
+ (VB->ColorPtr[0]->stride != 0 ||
+ VB->ColorPtr[0]->data[0][3] != 1.0)) {
+ emitsize = 4;
+ } else {
+ emitsize = 3;
+ }
+ }
+
+ CONFIGURE_AOS(i_color[0], AOS_FORMAT_FLOAT_COLOR,
+ VB->ColorPtr[0],
+ immd ? 4 : emitsize,
+ count);
+
+ vic_1 |= R300_INPUT_CNTL_COLOR;
+ }
+
+ if (inputs & _TNL_BIT_COLOR1) {
+ CONFIGURE_AOS(i_color[1], AOS_FORMAT_FLOAT_COLOR,
+ VB->SecondaryColorPtr[0],
+ immd ? 4 : VB->SecondaryColorPtr[0]->size,
+ count);
+ }
+
+#if 0
+ if (inputs & _TNL_BIT_FOG) {
+ CONFIGURE_AOS( AOS_FORMAT_FLOAT,
+ VB->FogCoordPtr,
+ immd ? 4 : VB->FogCoordPtr->size,
+ count);
+ }
+#endif
+
+ r300->state.texture.tc_count = 0;
+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+ if (inputs & (_TNL_BIT_TEX0 << i)) {
+ CONFIGURE_AOS(i_tex[i], AOS_FORMAT_FLOAT,
+ VB->TexCoordPtr[i],
+ immd ? 4 : VB->TexCoordPtr[i]->size,
+ count);
+
+ vic_1 |= R300_INPUT_CNTL_TC0 << i;
+ r300->state.texture.tc_count++;
+ }
+ }
+
+#define SHOW_INFO(n) do { \
+ if (RADEON_DEBUG & DEBUG_ALL) { \
+ fprintf(stderr, "RR[%d] - sz=%d, reg=%d, fmt=%d -- st=%d, of=0x%08x\n", \
+ n, \
+ r300->state.aos[n].aos_size, \
+ r300->state.aos[n].aos_reg, \
+ r300->state.aos[n].aos_format, \
+ r300->state.aos[n].aos_stride, \
+ r300->state.aos[n].aos_offset); \
+ } \
+} while(0);
+
+ /* setup INPUT_ROUTE */
+ R300_STATECHANGE(r300, vir[0]);
+ for(i=0;i+1<nr;i+=2){
+ SHOW_INFO(i)
+ SHOW_INFO(i+1)
+ dw=(r300->state.aos[i].aos_size-1)
+ | ((r300->state.aos[i].aos_reg)<<8)
+ | (r300->state.aos[i].aos_format<<14)
+ | (((r300->state.aos[i+1].aos_size-1)
+ | ((r300->state.aos[i+1].aos_reg)<<8)
+ | (r300->state.aos[i+1].aos_format<<14))<<16);
+
+ if(i+2==nr){
+ dw|=(1<<(13+16));
+ }
+ r300->hw.vir[0].cmd[R300_VIR_CNTL_0+(i>>1)]=dw;
+ }
+ if(nr & 1){
+ SHOW_INFO(nr-1)
+ dw=(r300->state.aos[nr-1].aos_size-1)
+ | (r300->state.aos[nr-1].aos_format<<14)
+ | ((r300->state.aos[nr-1].aos_reg)<<8)
+ | (1<<13);
+ r300->hw.vir[0].cmd[R300_VIR_CNTL_0+(nr>>1)]=dw;
+ //fprintf(stderr, "vir0 dw=%08x\n", dw);
+ }
+ /* Set the rest of INPUT_ROUTE_0 to 0 */
+ //for(i=((count+1)>>1); i<8; i++)r300->hw.vir[0].cmd[R300_VIR_CNTL_0+i]=(0x0);
+ ((drm_r300_cmd_header_t*)r300->hw.vir[0].cmd)->packet0.count = (nr+1)>>1;
+
+
+ /* Mesa assumes that all missing components are from (0, 0, 0, 1) */
+#define ALL_COMPONENTS ((R300_INPUT_ROUTE_SELECT_X<<R300_INPUT_ROUTE_X_SHIFT) \
+ | (R300_INPUT_ROUTE_SELECT_Y<<R300_INPUT_ROUTE_Y_SHIFT) \
+ | (R300_INPUT_ROUTE_SELECT_Z<<R300_INPUT_ROUTE_Z_SHIFT) \
+ | (R300_INPUT_ROUTE_SELECT_W<<R300_INPUT_ROUTE_W_SHIFT))
+
+#define ALL_DEFAULT ((R300_INPUT_ROUTE_SELECT_ZERO<<R300_INPUT_ROUTE_X_SHIFT) \
+ | (R300_INPUT_ROUTE_SELECT_ZERO<<R300_INPUT_ROUTE_Y_SHIFT) \
+ | (R300_INPUT_ROUTE_SELECT_ZERO<<R300_INPUT_ROUTE_Z_SHIFT) \
+ | (R300_INPUT_ROUTE_SELECT_ONE<<R300_INPUT_ROUTE_W_SHIFT))
+
+ R300_STATECHANGE(r300, vir[1]);
+
+ for(i=0;i+1<nr;i+=2){
+ /* do i first.. */
+ mask=(1<<(r300->state.aos[i].aos_size*3))-1;
+ dw=(ALL_COMPONENTS & mask)
+ | (ALL_DEFAULT & ~mask)
+ | R300_INPUT_ROUTE_ENABLE;
+
+ /* i+1 */
+ mask=(1<<(r300->state.aos[i+1].aos_size*3))-1;
+ dw|=(
+ (ALL_COMPONENTS & mask)
+ | (ALL_DEFAULT & ~mask)
+ | R300_INPUT_ROUTE_ENABLE
+ )<<16;
+
+ r300->hw.vir[1].cmd[R300_VIR_CNTL_0+(i>>1)]=dw;
+ }
+ if(nr & 1){
+ mask=(1<<(r300->state.aos[nr-1].aos_size*3))-1;
+ dw=(ALL_COMPONENTS & mask)
+ | (ALL_DEFAULT & ~mask)
+ | R300_INPUT_ROUTE_ENABLE;
+ r300->hw.vir[1].cmd[R300_VIR_CNTL_0+(nr>>1)]=dw;
+ //fprintf(stderr, "vir1 dw=%08x\n", dw);
+ }
+ /* Set the rest of INPUT_ROUTE_1 to 0 */
+ //for(i=((count+1)>>1); i<8; i++)r300->hw.vir[1].cmd[R300_VIR_CNTL_0+i]=0x0;
+ ((drm_r300_cmd_header_t*)r300->hw.vir[1].cmd)->packet0.count = (nr+1)>>1;
+
+ /* Set up input_cntl */
+ /* I don't think this is needed for vertex buffers, but it doesn't hurt anything */
+ R300_STATECHANGE(r300, vic);
+ r300->hw.vic.cmd[R300_VIC_CNTL_0]=0x5555; /* Hard coded value, no idea what it means */
+ r300->hw.vic.cmd[R300_VIC_CNTL_1]=vic_1;
+
+#if 0
+ r300->hw.vic.cmd[R300_VIC_CNTL_1]=0;
+
+ if(r300->state.render_inputs & _TNL_BIT_POS)
+ r300->hw.vic.cmd[R300_VIC_CNTL_1]|=R300_INPUT_CNTL_POS;
+
+ if(r300->state.render_inputs & _TNL_BIT_NORMAL)
+ r300->hw.vic.cmd[R300_VIC_CNTL_1]|=R300_INPUT_CNTL_NORMAL;
+
+ if(r300->state.render_inputs & _TNL_BIT_COLOR0)
+ r300->hw.vic.cmd[R300_VIC_CNTL_1]|=R300_INPUT_CNTL_COLOR;
+
+ for(i=0;i < ctx->Const.MaxTextureUnits;i++)
+ if(r300->state.render_inputs & (_TNL_BIT_TEX0<<i))
+ r300->hw.vic.cmd[R300_VIC_CNTL_1]|=(R300_INPUT_CNTL_TC0<<i);
+#endif
+
+ /* Stage 3: VAP output */
+
+ R300_STATECHANGE(r300, vof);
+
+ r300->hw.vof.cmd[R300_VOF_CNTL_0]=0;
+ r300->hw.vof.cmd[R300_VOF_CNTL_1]=0;
+ if (hw_tcl_on){
+ GLuint OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten;
+
+ if(OutputsWritten & (1<<VERT_RESULT_HPOS))
+ r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
+ if(OutputsWritten & (1<<VERT_RESULT_COL0))
+ r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
+ /*if(OutputsWritten & (1<<VERT_RESULT_COL1))
+ r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
+ if(OutputsWritten & (1<<VERT_RESULT_BFC0))
+ r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT;
+ if(OutputsWritten & (1<<VERT_RESULT_BFC1))
+ r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT;*/
+ //if(OutputsWritten & (1<<VERT_RESULT_FOGC))
+
+ if(OutputsWritten & (1<<VERT_RESULT_PSIZ))
+ r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT;
+
+ for(i=0;i < ctx->Const.MaxTextureUnits;i++)
+ if(OutputsWritten & (1<<(VERT_RESULT_TEX0+i)))
+ r300->hw.vof.cmd[R300_VOF_CNTL_1] |= (4<<(3*i));
+ } else {
+ if(inputs & _TNL_BIT_POS)
+ r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT;
+ if(inputs & _TNL_BIT_COLOR0)
+ r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
+ if(inputs & _TNL_BIT_COLOR1)
+ r300->hw.vof.cmd[R300_VOF_CNTL_0] |= R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT;
+
+ for(i=0;i < ctx->Const.MaxTextureUnits;i++)
+ if(inputs & (_TNL_BIT_TEX0<<i))
+ r300->hw.vof.cmd[R300_VOF_CNTL_1]|=(4<<(3*i));
+ }
+
+ rmesa->state.aos_count = nr;
+}
+
+void r300ReleaseArrays(GLcontext * ctx)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ int i;
+
+ r300ReleaseDmaRegion(rmesa, &rmesa->state.elt_dma, __FUNCTION__);
+ for (i=0;i<rmesa->state.aos_count;i++) {
+ r300ReleaseDmaRegion(rmesa, &rmesa->state.aos[i], __FUNCTION__);
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_maos.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_maos.h
new file mode 100644
index 000000000..f76c94a21
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_maos.h
@@ -0,0 +1,49 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r200/r200_maos.h,v 1.1 2002/10/30 12:51:52 alanh Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __R300_MAOS_H__
+#define __R300_MAOS_H__
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include "r300_context.h"
+
+extern void r300EmitElts(GLcontext * ctx, GLuint *elts, unsigned long n_elts);
+extern void r300EmitArrays(GLcontext * ctx, GLboolean immd);
+extern void r300ReleaseArrays(GLcontext * ctx);
+
+#endif
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_program.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_program.h
new file mode 100644
index 000000000..d1754c066
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_program.h
@@ -0,0 +1,151 @@
+/*
+Copyright (C) 2004 Nicolai Haehnle. 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 THE COPYRIGHT OWNER(S) 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:
+ * Nicolai Haehnle <prefect_@gmx.net>
+ */
+
+#ifndef __R300_PROGRAM_H__
+#define __R300_PROGRAM_H__
+
+#include "r300_reg.h"
+
+/**
+ * Vertex program helper macros
+ */
+
+/* Produce out dword */
+#define VP_OUTCLASS_TMP R300_VPI_OUT_REG_CLASS_TEMPORARY
+#define VP_OUTCLASS_OUT R300_VPI_OUT_REG_CLASS_RESULT
+
+#define VP_OUTMASK_X R300_VPI_OUT_WRITE_X
+#define VP_OUTMASK_Y R300_VPI_OUT_WRITE_Y
+#define VP_OUTMASK_Z R300_VPI_OUT_WRITE_Z
+#define VP_OUTMASK_W R300_VPI_OUT_WRITE_W
+#define VP_OUTMASK_XY (VP_OUTMASK_X|VP_OUTMASK_Y)
+#define VP_OUTMASK_XZ (VP_OUTMASK_X|VP_OUTMASK_Z)
+#define VP_OUTMASK_XW (VP_OUTMASK_X|VP_OUTMASK_W)
+#define VP_OUTMASK_XYZ (VP_OUTMASK_XY|VP_OUTMASK_Z)
+#define VP_OUTMASK_XYW (VP_OUTMASK_XY|VP_OUTMASK_W)
+#define VP_OUTMASK_XZW (VP_OUTMASK_XZ|VP_OUTMASK_W)
+#define VP_OUTMASK_XYZW (VP_OUTMASK_XYZ|VP_OUTMASK_W)
+#define VP_OUTMASK_YZ (VP_OUTMASK_Y|VP_OUTMASK_Z)
+#define VP_OUTMASK_YW (VP_OUTMASK_Y|VP_OUTMASK_W)
+#define VP_OUTMASK_YZW (VP_OUTMASK_YZ|VP_OUTMASK_W)
+#define VP_OUTMASK_ZW (VP_OUTMASK_Z|VP_OUTMASK_W)
+
+#define VP_OUT(instr,outclass,outidx,outmask) \
+ (R300_VPI_OUT_OP_##instr | \
+ ((outidx) << R300_VPI_OUT_REG_INDEX_SHIFT) | \
+ VP_OUTCLASS_##outclass | \
+ VP_OUTMASK_##outmask)
+
+/* Produce in dword */
+#define VP_INCLASS_TMP R300_VPI_IN_REG_CLASS_TEMPORARY
+#define VP_INCLASS_IN R300_VPI_IN_REG_CLASS_ATTRIBUTE
+#define VP_INCLASS_CONST R300_VPI_IN_REG_CLASS_PARAMETER
+
+#define VP_IN(class,idx) \
+ (((idx) << R300_VPI_IN_REG_INDEX_SHIFT) | \
+ VP_INCLASS_##class | \
+ (R300_VPI_IN_SELECT_X << R300_VPI_IN_X_SHIFT) | \
+ (R300_VPI_IN_SELECT_Y << R300_VPI_IN_Y_SHIFT) | \
+ (R300_VPI_IN_SELECT_Z << R300_VPI_IN_Z_SHIFT) | \
+ (R300_VPI_IN_SELECT_W << R300_VPI_IN_W_SHIFT))
+#define VP_ZERO() \
+ ((R300_VPI_IN_SELECT_ZERO << R300_VPI_IN_X_SHIFT) | \
+ (R300_VPI_IN_SELECT_ZERO << R300_VPI_IN_Y_SHIFT) | \
+ (R300_VPI_IN_SELECT_ZERO << R300_VPI_IN_Z_SHIFT) | \
+ (R300_VPI_IN_SELECT_ZERO << R300_VPI_IN_W_SHIFT))
+#define VP_ONE() \
+ ((R300_VPI_IN_SELECT_ONE << R300_VPI_IN_X_SHIFT) | \
+ (R300_VPI_IN_SELECT_ONE << R300_VPI_IN_Y_SHIFT) | \
+ (R300_VPI_IN_SELECT_ONE << R300_VPI_IN_Z_SHIFT) | \
+ (R300_VPI_IN_SELECT_ONE << R300_VPI_IN_W_SHIFT))
+
+#define VP_NEG(in,comp) ((in) ^ (R300_VPI_IN_NEG_##comp))
+#define VP_NEGALL(in,comp) VP_NEG(VP_NEG(VP_NEG(VP_NEG((in),X),Y),Z),W)
+
+/**
+ * Fragment program helper macros
+ */
+
+/* Produce unshifted source selectors */
+#define FP_TMP(idx) (idx)
+#define FP_CONST(idx) ((idx) | (1 << 5))
+
+/* Produce source/dest selector dword */
+#define FP_SELC_MASK_NO 0
+#define FP_SELC_MASK_X 1
+#define FP_SELC_MASK_Y 2
+#define FP_SELC_MASK_XY 3
+#define FP_SELC_MASK_Z 4
+#define FP_SELC_MASK_XZ 5
+#define FP_SELC_MASK_YZ 6
+#define FP_SELC_MASK_XYZ 7
+
+#define FP_SELC(destidx,regmask,outmask,src0,src1,src2) \
+ (((destidx) << R300_FPI1_DSTC_SHIFT) | \
+ (FP_SELC_MASK_##regmask << 23) | \
+ (FP_SELC_MASK_##outmask << 26) | \
+ ((src0) << R300_FPI1_SRC0C_SHIFT) | \
+ ((src1) << R300_FPI1_SRC1C_SHIFT) | \
+ ((src2) << R300_FPI1_SRC2C_SHIFT))
+
+#define FP_SELA_MASK_NO 0
+#define FP_SELA_MASK_W 1
+
+#define FP_SELA(destidx,regmask,outmask,src0,src1,src2) \
+ (((destidx) << R300_FPI3_DSTA_SHIFT) | \
+ (FP_SELA_MASK_##regmask << 23) | \
+ (FP_SELA_MASK_##outmask << 24) | \
+ ((src0) << R300_FPI3_SRC0A_SHIFT) | \
+ ((src1) << R300_FPI3_SRC1A_SHIFT) | \
+ ((src2) << R300_FPI3_SRC2A_SHIFT))
+
+/* Produce unshifted argument selectors */
+#define FP_ARGC(source) R300_FPI0_ARGC_##source
+#define FP_ARGA(source) R300_FPI2_ARGA_##source
+#define FP_ABS(arg) ((arg) | (1 << 6))
+#define FP_NEG(arg) ((arg) ^ (1 << 5))
+
+/* Produce instruction dword */
+#define FP_INSTRC(opcode,arg0,arg1,arg2) \
+ (R300_FPI0_OUTC_##opcode | \
+ ((arg0) << R300_FPI0_ARG0C_SHIFT) | \
+ ((arg1) << R300_FPI0_ARG1C_SHIFT) | \
+ ((arg2) << R300_FPI0_ARG2C_SHIFT))
+
+#define FP_INSTRA(opcode,arg0,arg1,arg2) \
+ (R300_FPI2_OUTA_##opcode | \
+ ((arg0) << R300_FPI2_ARG0A_SHIFT) | \
+ ((arg1) << R300_FPI2_ARG1A_SHIFT) | \
+ ((arg2) << R300_FPI2_ARG2A_SHIFT))
+
+extern void debug_vp(GLcontext *ctx, struct vertex_program *vp);
+extern void dump_program_params(GLcontext *ctx, struct vertex_program *vp);
+
+#endif /* __R300_PROGRAM_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_reg.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_reg.h
new file mode 100644
index 000000000..3ea4f4fe8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_reg.h
@@ -0,0 +1,1387 @@
+#ifndef _R300_REG_H
+#define _R300_REG_H
+
+#define R300_MC_INIT_MISC_LAT_TIMER 0x180
+# define R300_MC_MISC__MC_CPR_INIT_LAT_SHIFT 0
+# define R300_MC_MISC__MC_VF_INIT_LAT_SHIFT 4
+# define R300_MC_MISC__MC_DISP0R_INIT_LAT_SHIFT 8
+# define R300_MC_MISC__MC_DISP1R_INIT_LAT_SHIFT 12
+# define R300_MC_MISC__MC_FIXED_INIT_LAT_SHIFT 16
+# define R300_MC_MISC__MC_E2R_INIT_LAT_SHIFT 20
+# define R300_MC_MISC__MC_SAME_PAGE_PRIO_SHIFT 24
+# define R300_MC_MISC__MC_GLOBW_INIT_LAT_SHIFT 28
+
+
+#define R300_MC_INIT_GFX_LAT_TIMER 0x154
+# define R300_MC_MISC__MC_G3D0R_INIT_LAT_SHIFT 0
+# define R300_MC_MISC__MC_G3D1R_INIT_LAT_SHIFT 4
+# define R300_MC_MISC__MC_G3D2R_INIT_LAT_SHIFT 8
+# define R300_MC_MISC__MC_G3D3R_INIT_LAT_SHIFT 12
+# define R300_MC_MISC__MC_TX0R_INIT_LAT_SHIFT 16
+# define R300_MC_MISC__MC_TX1R_INIT_LAT_SHIFT 20
+# define R300_MC_MISC__MC_GLOBR_INIT_LAT_SHIFT 24
+# define R300_MC_MISC__MC_GLOBW_FULL_LAT_SHIFT 28
+
+/*
+This file contains registers and constants for the R300. They have been
+found mostly by examining command buffers captured using glxtest, as well
+as by extrapolating some known registers and constants from the R200.
+
+I am fairly certain that they are correct unless stated otherwise in comments.
+*/
+
+#define R300_SE_VPORT_XSCALE 0x1D98
+#define R300_SE_VPORT_XOFFSET 0x1D9C
+#define R300_SE_VPORT_YSCALE 0x1DA0
+#define R300_SE_VPORT_YOFFSET 0x1DA4
+#define R300_SE_VPORT_ZSCALE 0x1DA8
+#define R300_SE_VPORT_ZOFFSET 0x1DAC
+
+
+/* This register is written directly and also starts data section in many 3d CP_PACKET3's */
+#define R300_VAP_VF_CNTL 0x2084
+
+# define R300_VAP_VF_CNTL__PRIM_TYPE__SHIFT 0
+# define R300_VAP_VF_CNTL__PRIM_NONE (0<<0)
+# define R300_VAP_VF_CNTL__PRIM_POINTS (1<<0)
+# define R300_VAP_VF_CNTL__PRIM_LINES (2<<0)
+# define R300_VAP_VF_CNTL__PRIM_LINE_STRIP (3<<0)
+# define R300_VAP_VF_CNTL__PRIM_TRIANGLES (4<<0)
+# define R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN (5<<0)
+# define R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP (6<<0)
+# define R300_VAP_VF_CNTL__PRIM_LINE_LOOP (12<<0)
+# define R300_VAP_VF_CNTL__PRIM_QUADS (13<<0)
+# define R300_VAP_VF_CNTL__PRIM_QUAD_STRIP (14<<0)
+# define R300_VAP_VF_CNTL__PRIM_POLYGON (15<<0)
+
+# define R300_VAP_VF_CNTL__PRIM_WALK__SHIFT 4
+ /* State based - direct writes to registers trigger vertex generation */
+# define R300_VAP_VF_CNTL__PRIM_WALK_STATE_BASED (0<<4)
+# define R300_VAP_VF_CNTL__PRIM_WALK_INDICES (1<<4)
+# define R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_LIST (2<<4)
+# define R300_VAP_VF_CNTL__PRIM_WALK_VERTEX_EMBEDDED (3<<4)
+
+ /* I don't think I saw these three used.. */
+# define R300_VAP_VF_CNTL__COLOR_ORDER__SHIFT 6
+# define R300_VAP_VF_CNTL__TCL_OUTPUT_CTL_ENA__SHIFT 9
+# define R300_VAP_VF_CNTL__PROG_STREAM_ENA__SHIFT 10
+
+ /* index size - when not set the indices are assumed to be 16 bit */
+# define R300_VAP_VF_CNTL__INDEX_SIZE_32bit (1<<11)
+ /* number of vertices */
+# define R300_VAP_VF_CNTL__NUM_VERTICES__SHIFT 16
+
+/* BEGIN: Wild guesses */
+#define R300_VAP_OUTPUT_VTX_FMT_0 0x2090
+# define R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT (1<<0)
+# define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT (1<<1)
+# define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_1_PRESENT (1<<2) /* GUESS */
+# define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_2_PRESENT (1<<3) /* GUESS */
+# define R300_VAP_OUTPUT_VTX_FMT_0__COLOR_3_PRESENT (1<<4) /* GUESS */
+# define R300_VAP_OUTPUT_VTX_FMT_0__PT_SIZE_PRESENT (1<<16) /* GUESS */
+
+#define R300_VAP_OUTPUT_VTX_FMT_1 0x2094
+# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_0_COMP_CNT_SHIFT 0
+# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_1_COMP_CNT_SHIFT 3
+# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_2_COMP_CNT_SHIFT 6
+# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_3_COMP_CNT_SHIFT 9
+# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_4_COMP_CNT_SHIFT 12
+# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_5_COMP_CNT_SHIFT 15
+# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_6_COMP_CNT_SHIFT 18
+# define R300_VAP_OUTPUT_VTX_FMT_1__TEX_7_COMP_CNT_SHIFT 21
+/* END */
+
+#define R300_SE_VTE_CNTL 0x20b0
+# define R300_VPORT_X_SCALE_ENA 0x00000001
+# define R300_VPORT_X_OFFSET_ENA 0x00000002
+# define R300_VPORT_Y_SCALE_ENA 0x00000004
+# define R300_VPORT_Y_OFFSET_ENA 0x00000008
+# define R300_VPORT_Z_SCALE_ENA 0x00000010
+# define R300_VPORT_Z_OFFSET_ENA 0x00000020
+# define R300_VTX_XY_FMT 0x00000100
+# define R300_VTX_Z_FMT 0x00000200
+# define R300_VTX_W0_FMT 0x00000400
+# define R300_VTX_W0_NORMALIZE 0x00000800
+# define R300_VTX_ST_DENORMALIZED 0x00001000
+
+/* BEGIN: Vertex data assembly - lots of uncertainties */
+/* gap */
+/* Where do we get our vertex data?
+//
+// Vertex data either comes either from immediate mode registers or from
+// vertex arrays.
+// There appears to be no mixed mode (though we can force the pitch of
+// vertex arrays to 0, effectively reusing the same element over and over
+// again).
+//
+// Immediate mode is controlled by the INPUT_CNTL registers. I am not sure
+// if these registers influence vertex array processing.
+//
+// Vertex arrays are controlled via the 3D_LOAD_VBPNTR packet3.
+//
+// In both cases, vertex attributes are then passed through INPUT_ROUTE.
+
+// Beginning with INPUT_ROUTE_0_0 is a list of WORDs that route vertex data
+// into the vertex processor's input registers.
+// The first word routes the first input, the second word the second, etc.
+// The corresponding input is routed into the register with the given index.
+// The list is ended by a word with INPUT_ROUTE_END set.
+//
+// Always set COMPONENTS_4 in immediate mode. */
+
+#define R300_VAP_INPUT_ROUTE_0_0 0x2150
+# define R300_INPUT_ROUTE_COMPONENTS_1 (0 << 0)
+# define R300_INPUT_ROUTE_COMPONENTS_2 (1 << 0)
+# define R300_INPUT_ROUTE_COMPONENTS_3 (2 << 0)
+# define R300_INPUT_ROUTE_COMPONENTS_4 (3 << 0)
+# define R300_INPUT_ROUTE_COMPONENTS_RGBA (4 << 0) /* GUESS */
+# define R300_VAP_INPUT_ROUTE_IDX_SHIFT 8
+# define R300_VAP_INPUT_ROUTE_IDX_MASK (31 << 8) /* GUESS */
+# define R300_VAP_INPUT_ROUTE_END (1 << 13)
+# define R300_INPUT_ROUTE_IMMEDIATE_MODE (0 << 14) /* GUESS */
+# define R300_INPUT_ROUTE_FLOAT (1 << 14) /* GUESS */
+# define R300_INPUT_ROUTE_UNSIGNED_BYTE (2 << 14) /* GUESS */
+# define R300_INPUT_ROUTE_FLOAT_COLOR (3 << 14) /* GUESS */
+#define R300_VAP_INPUT_ROUTE_0_1 0x2154
+#define R300_VAP_INPUT_ROUTE_0_2 0x2158
+#define R300_VAP_INPUT_ROUTE_0_3 0x215C
+#define R300_VAP_INPUT_ROUTE_0_4 0x2160
+#define R300_VAP_INPUT_ROUTE_0_5 0x2164
+#define R300_VAP_INPUT_ROUTE_0_6 0x2168
+#define R300_VAP_INPUT_ROUTE_0_7 0x216C
+
+/* gap */
+/* Notes:
+// - always set up to produce at least two attributes:
+// if vertex program uses only position, fglrx will set normal, too
+// - INPUT_CNTL_0_COLOR and INPUT_CNTL_COLOR bits are always equal */
+#define R300_VAP_INPUT_CNTL_0 0x2180
+# define R300_INPUT_CNTL_0_COLOR 0x00000001
+#define R300_VAP_INPUT_CNTL_1 0x2184
+# define R300_INPUT_CNTL_POS 0x00000001
+# define R300_INPUT_CNTL_NORMAL 0x00000002
+# define R300_INPUT_CNTL_COLOR 0x00000004
+# define R300_INPUT_CNTL_TC0 0x00000400
+# define R300_INPUT_CNTL_TC1 0x00000800
+# define R300_INPUT_CNTL_TC2 0x00001000 /* GUESS */
+# define R300_INPUT_CNTL_TC3 0x00002000 /* GUESS */
+# define R300_INPUT_CNTL_TC4 0x00004000 /* GUESS */
+# define R300_INPUT_CNTL_TC5 0x00008000 /* GUESS */
+# define R300_INPUT_CNTL_TC6 0x00010000 /* GUESS */
+# define R300_INPUT_CNTL_TC7 0x00020000 /* GUESS */
+
+/* gap */
+/* Words parallel to INPUT_ROUTE_0; All words that are active in INPUT_ROUTE_0
+// are set to a swizzling bit pattern, other words are 0.
+//
+// In immediate mode, the pattern is always set to xyzw. In vertex array
+// mode, the swizzling pattern is e.g. used to set zw components in texture
+// coordinates with only tweo components. */
+#define R300_VAP_INPUT_ROUTE_1_0 0x21E0
+# define R300_INPUT_ROUTE_SELECT_X 0
+# define R300_INPUT_ROUTE_SELECT_Y 1
+# define R300_INPUT_ROUTE_SELECT_Z 2
+# define R300_INPUT_ROUTE_SELECT_W 3
+# define R300_INPUT_ROUTE_SELECT_ZERO 4
+# define R300_INPUT_ROUTE_SELECT_ONE 5
+# define R300_INPUT_ROUTE_SELECT_MASK 7
+# define R300_INPUT_ROUTE_X_SHIFT 0
+# define R300_INPUT_ROUTE_Y_SHIFT 3
+# define R300_INPUT_ROUTE_Z_SHIFT 6
+# define R300_INPUT_ROUTE_W_SHIFT 9
+# define R300_INPUT_ROUTE_ENABLE (15 << 12)
+#define R300_VAP_INPUT_ROUTE_1_1 0x21E4
+#define R300_VAP_INPUT_ROUTE_1_2 0x21E8
+#define R300_VAP_INPUT_ROUTE_1_3 0x21EC
+#define R300_VAP_INPUT_ROUTE_1_4 0x21F0
+#define R300_VAP_INPUT_ROUTE_1_5 0x21F4
+#define R300_VAP_INPUT_ROUTE_1_6 0x21F8
+#define R300_VAP_INPUT_ROUTE_1_7 0x21FC
+
+/* END */
+
+/* gap */
+/* BEGIN: Upload vertex program and data
+// The programmable vertex shader unit has a memory bank of unknown size
+// that can be written to in 16 byte units by writing the address into
+// UPLOAD_ADDRESS, followed by data in UPLOAD_DATA (multiples of 4 DWORDs).
+//
+// Pointers into the memory bank are always in multiples of 16 bytes.
+//
+// The memory bank is divided into areas with fixed meaning.
+//
+// Starting at address UPLOAD_PROGRAM: Vertex program instructions.
+// Native limits reported by drivers from ATI suggest size 256 (i.e. 4KB),
+// whereas the difference between known addresses suggests size 512.
+//
+// Starting at address UPLOAD_PARAMETERS: Vertex program parameters.
+// Native reported limits and the VPI layout suggest size 256, whereas
+// difference between known addresses suggests size 512.
+//
+// At address UPLOAD_POINTSIZE is a vector (0, 0, ps, 0), where ps is the
+// floating point pointsize. The exact purpose of this state is uncertain,
+// as there is also the R300_RE_POINTSIZE register.
+//
+// Multiple vertex programs and parameter sets can be loaded at once,
+// which could explain the size discrepancy. */
+#define R300_VAP_PVS_UPLOAD_ADDRESS 0x2200
+# define R300_PVS_UPLOAD_PROGRAM 0x00000000
+# define R300_PVS_UPLOAD_PARAMETERS 0x00000200
+# define R300_PVS_UPLOAD_POINTSIZE 0x00000406
+/* gap */
+#define R300_VAP_PVS_UPLOAD_DATA 0x2208
+/* END */
+
+/* gap */
+/* I do not know the purpose of this register. However, I do know that
+// it is set to 221C_CLEAR for clear operations and to 221C_NORMAL
+// for normal rendering. */
+#define R300_VAP_UNKNOWN_221C 0x221C
+# define R300_221C_NORMAL 0x00000000
+# define R300_221C_CLEAR 0x0001C000
+
+/* gap */
+/* Sometimes, END_OF_PKT and 0x2284=0 are the only commands sent between
+// rendering commands and overwriting vertex program parameters.
+// Therefore, I suspect writing zero to 0x2284 synchronizes the engine and
+// avoids bugs caused by still running shaders reading bad data from memory. */
+#define R300_VAP_PVS_WAITIDLE 0x2284 /* GUESS */
+
+/* Absolutely no clue what this register is about. */
+#define R300_VAP_UNKNOWN_2288 0x2288
+# define R300_2288_R300 0x00750000 /* -- nh */
+# define R300_2288_RV350 0x0000FFFF /* -- Vladimir */
+
+/* gap */
+/* Addresses are relative to the vertex program instruction area of the
+// memory bank. PROGRAM_END points to the last instruction of the active
+// program
+//
+// The meaning of the two UNKNOWN fields is obviously not known. However,
+// experiments so far have shown that both *must* point to an instruction
+// inside the vertex program, otherwise the GPU locks up.
+// fglrx usually sets CNTL_3_UNKNOWN to the end of the program and
+// CNTL_1_UNKNOWN points to instruction where last write to position takes place.
+// Most likely this is used to ignore rest of the program in cases where group of verts arent visible.
+// For some reason this "section" is sometimes accepted other instruction that have
+// no relationship with position calculations.
+*/
+#define R300_VAP_PVS_CNTL_1 0x22D0
+# define R300_PVS_CNTL_1_PROGRAM_START_SHIFT 0
+# define R300_PVS_CNTL_1_POS_END_SHIFT 10
+# define R300_PVS_CNTL_1_PROGRAM_END_SHIFT 20
+/* Addresses are relative the the vertex program parameters area. */
+#define R300_VAP_PVS_CNTL_2 0x22D4
+# define R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT 0
+# define R300_PVS_CNTL_2_PARAM_COUNT_SHIFT 16
+#define R300_VAP_PVS_CNTL_3 0x22D8
+# define R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT 10
+# define R300_PVS_CNTL_3_PROGRAM_UNKNOWN2_SHIFT 0
+
+/* The entire range from 0x2300 to 0x2AC inclusive seems to be used for
+// immediate vertices */
+#define R300_VAP_VTX_COLOR_R 0x2464
+#define R300_VAP_VTX_COLOR_G 0x2468
+#define R300_VAP_VTX_COLOR_B 0x246C
+#define R300_VAP_VTX_POS_0_X_1 0x2490 /* used for glVertex2*() */
+#define R300_VAP_VTX_POS_0_Y_1 0x2494
+#define R300_VAP_VTX_COLOR_PKD 0x249C /* RGBA */
+#define R300_VAP_VTX_POS_0_X_2 0x24A0 /* used for glVertex3*() */
+#define R300_VAP_VTX_POS_0_Y_2 0x24A4
+#define R300_VAP_VTX_POS_0_Z_2 0x24A8
+#define R300_VAP_VTX_END_OF_PKT 0x24AC /* write 0 to indicate end of packet? */
+
+/* gap */
+
+/* These are values from r300_reg/r300_reg.h - they are known to be correct
+ and are here so we can use one register file instead of several
+ - Vladimir */
+#define R300_GB_VAP_RASTER_VTX_FMT_0 0x4000
+# define R300_GB_VAP_RASTER_VTX_FMT_0__POS_PRESENT (1<<0)
+# define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_0_PRESENT (1<<1)
+# define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_1_PRESENT (1<<2)
+# define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_2_PRESENT (1<<3)
+# define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_3_PRESENT (1<<4)
+# define R300_GB_VAP_RASTER_VTX_FMT_0__COLOR_SPACE (0xf<<5)
+# define R300_GB_VAP_RASTER_VTX_FMT_0__PT_SIZE_PRESENT (0x1<<16)
+
+#define R300_GB_VAP_RASTER_VTX_FMT_1 0x4004
+ /* each of the following is 3 bits wide, specifies number
+ of components */
+# define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_0_COMP_CNT_SHIFT 0
+# define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_1_COMP_CNT_SHIFT 3
+# define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_2_COMP_CNT_SHIFT 6
+# define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_3_COMP_CNT_SHIFT 9
+# define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_4_COMP_CNT_SHIFT 12
+# define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_5_COMP_CNT_SHIFT 15
+# define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_6_COMP_CNT_SHIFT 18
+# define R300_GB_VAP_RASTER_VTX_FMT_1__TEX_7_COMP_CNT_SHIFT 21
+
+/* UNK30 seems to enables point to quad transformation on textures
+ (or something closely related to that).
+ This bit is rather fatal at the time being due to lackings at pixel shader side */
+#define R300_GB_ENABLE 0x4008
+# define R300_GB_POINT_STUFF_ENABLE (1<<0)
+# define R300_GB_LINE_STUFF_ENABLE (1<<1)
+# define R300_GB_TRIANGLE_STUFF_ENABLE (1<<2)
+# define R300_GB_STENCIL_AUTO_ENABLE (1<<4)
+# define R300_GB_UNK30 (1<<30)
+ /* each of the following is 2 bits wide */
+#define R300_GB_TEX_REPLICATE 0
+#define R300_GB_TEX_ST 1
+#define R300_GB_TEX_STR 2
+# define R300_GB_TEX0_SOURCE_SHIFT 16
+# define R300_GB_TEX1_SOURCE_SHIFT 18
+# define R300_GB_TEX2_SOURCE_SHIFT 20
+# define R300_GB_TEX3_SOURCE_SHIFT 22
+# define R300_GB_TEX4_SOURCE_SHIFT 24
+# define R300_GB_TEX5_SOURCE_SHIFT 26
+# define R300_GB_TEX6_SOURCE_SHIFT 28
+# define R300_GB_TEX7_SOURCE_SHIFT 30
+
+/* MSPOS - positions for multisample antialiasing (?) */
+#define R300_GB_MSPOS0 0x4010
+ /* shifts - each of the fields is 4 bits */
+# define R300_GB_MSPOS0__MS_X0_SHIFT 0
+# define R300_GB_MSPOS0__MS_Y0_SHIFT 4
+# define R300_GB_MSPOS0__MS_X1_SHIFT 8
+# define R300_GB_MSPOS0__MS_Y1_SHIFT 12
+# define R300_GB_MSPOS0__MS_X2_SHIFT 16
+# define R300_GB_MSPOS0__MS_Y2_SHIFT 20
+# define R300_GB_MSPOS0__MSBD0_Y 24
+# define R300_GB_MSPOS0__MSBD0_X 28
+
+#define R300_GB_MSPOS1 0x4014
+# define R300_GB_MSPOS1__MS_X3_SHIFT 0
+# define R300_GB_MSPOS1__MS_Y3_SHIFT 4
+# define R300_GB_MSPOS1__MS_X4_SHIFT 8
+# define R300_GB_MSPOS1__MS_Y4_SHIFT 12
+# define R300_GB_MSPOS1__MS_X5_SHIFT 16
+# define R300_GB_MSPOS1__MS_Y5_SHIFT 20
+# define R300_GB_MSPOS1__MSBD1 24
+
+
+#define R300_GB_TILE_CONFIG 0x4018
+# define R300_GB_TILE_ENABLE (1<<0)
+# define R300_GB_TILE_PIPE_COUNT_RV300 0
+# define R300_GB_TILE_PIPE_COUNT_R300 (3<<1)
+# define R300_GB_TILE_PIPE_COUNT_R420 (7<<1)
+# define R300_GB_TILE_SIZE_8 0
+# define R300_GB_TILE_SIZE_16 (1<<4)
+# define R300_GB_TILE_SIZE_32 (2<<4)
+# define R300_GB_SUPER_SIZE_1 (0<<6)
+# define R300_GB_SUPER_SIZE_2 (1<<6)
+# define R300_GB_SUPER_SIZE_4 (2<<6)
+# define R300_GB_SUPER_SIZE_8 (3<<6)
+# define R300_GB_SUPER_SIZE_16 (4<<6)
+# define R300_GB_SUPER_SIZE_32 (5<<6)
+# define R300_GB_SUPER_SIZE_64 (6<<6)
+# define R300_GB_SUPER_SIZE_128 (7<<6)
+# define R300_GB_SUPER_X_SHIFT 9 /* 3 bits wide */
+# define R300_GB_SUPER_Y_SHIFT 12 /* 3 bits wide */
+# define R300_GB_SUPER_TILE_A 0
+# define R300_GB_SUPER_TILE_B (1<<15)
+# define R300_GB_SUBPIXEL_1_12 0
+# define R300_GB_SUBPIXEL_1_16 (1<<16)
+
+#define R300_GB_FIFO_SIZE 0x4024
+ /* each of the following is 2 bits wide */
+#define R300_GB_FIFO_SIZE_32 0
+#define R300_GB_FIFO_SIZE_64 1
+#define R300_GB_FIFO_SIZE_128 2
+#define R300_GB_FIFO_SIZE_256 3
+# define R300_SC_IFIFO_SIZE_SHIFT 0
+# define R300_SC_TZFIFO_SIZE_SHIFT 2
+# define R300_SC_BFIFO_SIZE_SHIFT 4
+
+# define R300_US_OFIFO_SIZE_SHIFT 12
+# define R300_US_WFIFO_SIZE_SHIFT 14
+ /* the following use the same constants as above, but meaning is
+ is times 2 (i.e. instead of 32 words it means 64 */
+# define R300_RS_TFIFO_SIZE_SHIFT 6
+# define R300_RS_CFIFO_SIZE_SHIFT 8
+# define R300_US_RAM_SIZE_SHIFT 10
+ /* watermarks, 3 bits wide */
+# define R300_RS_HIGHWATER_COL_SHIFT 16
+# define R300_RS_HIGHWATER_TEX_SHIFT 19
+# define R300_OFIFO_HIGHWATER_SHIFT 22 /* two bits only */
+# define R300_CUBE_FIFO_HIGHWATER_COL_SHIFT 24
+
+#define R300_GB_SELECT 0x401C
+# define R300_GB_FOG_SELECT_C0A 0
+# define R300_GB_FOG_SELECT_C1A 1
+# define R300_GB_FOG_SELECT_C2A 2
+# define R300_GB_FOG_SELECT_C3A 3
+# define R300_GB_FOG_SELECT_1_1_W 4
+# define R300_GB_FOG_SELECT_Z 5
+# define R300_GB_DEPTH_SELECT_Z 0
+# define R300_GB_DEPTH_SELECT_1_1_W (1<<3)
+# define R300_GB_W_SELECT_1_W 0
+# define R300_GB_W_SELECT_1 (1<<4)
+
+#define R300_GB_AA_CONFIG 0x4020
+# define R300_AA_ENABLE 0x01
+# define R300_AA_SUBSAMPLES_2 0
+# define R300_AA_SUBSAMPLES_3 (1<<1)
+# define R300_AA_SUBSAMPLES_4 (2<<1)
+# define R300_AA_SUBSAMPLES_6 (3<<1)
+
+/* END */
+
+/* gap */
+/* The upper enable bits are guessed, based on fglrx reported limits. */
+#define R300_TX_ENABLE 0x4104
+# define R300_TX_ENABLE_0 (1 << 0)
+# define R300_TX_ENABLE_1 (1 << 1)
+# define R300_TX_ENABLE_2 (1 << 2)
+# define R300_TX_ENABLE_3 (1 << 3)
+# define R300_TX_ENABLE_4 (1 << 4)
+# define R300_TX_ENABLE_5 (1 << 5)
+# define R300_TX_ENABLE_6 (1 << 6)
+# define R300_TX_ENABLE_7 (1 << 7)
+# define R300_TX_ENABLE_8 (1 << 8)
+# define R300_TX_ENABLE_9 (1 << 9)
+# define R300_TX_ENABLE_10 (1 << 10)
+# define R300_TX_ENABLE_11 (1 << 11)
+# define R300_TX_ENABLE_12 (1 << 12)
+# define R300_TX_ENABLE_13 (1 << 13)
+# define R300_TX_ENABLE_14 (1 << 14)
+# define R300_TX_ENABLE_15 (1 << 15)
+
+/* The pointsize is given in multiples of 6. The pointsize can be
+// enormous: Clear() renders a single point that fills the entire
+// framebuffer. */
+#define R300_RE_POINTSIZE 0x421C
+# define R300_POINTSIZE_Y_SHIFT 0
+# define R300_POINTSIZE_Y_MASK (0xFFFF << 0) /* GUESS */
+# define R300_POINTSIZE_X_SHIFT 16
+# define R300_POINTSIZE_X_MASK (0xFFFF << 16) /* GUESS */
+# define R300_POINTSIZE_MAX (R300_POINTSIZE_Y_MASK / 6)
+
+/* The line width is given in multiples of 6.
+ In default mode lines are classified as vertical lines.
+ HO: horizontal
+ VE: vertical or horizontal
+ HO & VE: no classification
+*/
+#define R300_RE_LINE_CNT 0x4234
+# define R300_LINESIZE_SHIFT 0
+# define R300_LINESIZE_MASK (0xFFFF << 0) /* GUESS */
+# define R300_LINESIZE_MAX (R300_LINESIZE_MASK / 6)
+# define R300_LINE_CNT_HO (1 << 16)
+# define R300_LINE_CNT_VE (1 << 17)
+
+/* Some sort of scale or clamp value for texcoordless textures. */
+#define R300_RE_UNK4238 0x4238
+
+#define R300_RE_SHADE_MODEL 0x4278
+# define R300_RE_SHADE_MODEL_SMOOTH 0x3aaaa
+# define R300_RE_SHADE_MODEL_FLAT 0x39595
+
+/* Dangerous */
+#define R300_RE_POLYGON_MODE 0x4288
+# define R300_PM_ENABLED (1 << 0)
+# define R300_PM_FRONT_POINT (0 << 0)
+# define R300_PM_BACK_POINT (0 << 0)
+# define R300_PM_FRONT_LINE (1 << 4)
+# define R300_PM_FRONT_FILL (1 << 5)
+# define R300_PM_BACK_LINE (1 << 7)
+# define R300_PM_BACK_FILL (1 << 8)
+
+/* Not sure why there are duplicate of factor and constant values.
+ My best guess so far is that there are seperate zbiases for test and write.
+ Ordering might be wrong.
+ Some of the tests indicate that fgl has a fallback implementation of zbias
+ via pixel shaders. */
+#define R300_RE_ZBIAS_T_FACTOR 0x42A4
+#define R300_RE_ZBIAS_T_CONSTANT 0x42A8
+#define R300_RE_ZBIAS_W_FACTOR 0x42AC
+#define R300_RE_ZBIAS_W_CONSTANT 0x42B0
+
+/* This register needs to be set to (1<<1) for RV350 to correctly
+ perform depth test (see --vb-triangles in r300_demo)
+ Don't know about other chips. - Vladimir
+ This is set to 3 when GL_POLYGON_OFFSET_FILL is on.
+ My guess is that there are two bits for each zbias primitive (FILL, LINE, POINT).
+ One to enable depth test and one for depth write.
+ Yet this doesnt explain why depth writes work ...
+ */
+#define R300_RE_OCCLUSION_CNTL 0x42B4
+# define R300_OCCLUSION_ON (1<<1)
+
+#define R300_RE_CULL_CNTL 0x42B8
+# define R300_CULL_FRONT (1 << 0)
+# define R300_CULL_BACK (1 << 1)
+# define R300_FRONT_FACE_CCW (0 << 2)
+# define R300_FRONT_FACE_CW (1 << 2)
+
+
+/* BEGIN: Rasterization / Interpolators - many guesses
+// 0_UNKNOWN_18 has always been set except for clear operations.
+// TC_CNT is the number of incoming texture coordinate sets (i.e. it depends
+// on the vertex program, *not* the fragment program) */
+#define R300_RS_CNTL_0 0x4300
+# define R300_RS_CNTL_TC_CNT_SHIFT 2
+# define R300_RS_CNTL_TC_CNT_MASK (7 << 2)
+# define R300_RS_CNTL_CI_CNT_SHIFT 7 /* number of color interpolators used */
+# define R300_RS_CNTL_0_UNKNOWN_18 (1 << 18)
+/* Guess: RS_CNTL_1 holds the index of the highest used RS_ROUTE_n register. */
+#define R300_RS_CNTL_1 0x4304
+
+/* gap */
+/* Only used for texture coordinates.
+// Use the source field to route texture coordinate input from the vertex program
+// to the desired interpolator. Note that the source field is relative to the
+// outputs the vertex program *actually* writes. If a vertex program only writes
+// texcoord[1], this will be source index 0.
+// Set INTERP_USED on all interpolators that produce data used by the
+// fragment program. INTERP_USED looks like a swizzling mask, but
+// I haven't seen it used that way.
+//
+// Note: The _UNKNOWN constants are always set in their respective register.
+// I don't know if this is necessary. */
+#define R300_RS_INTERP_0 0x4310
+#define R300_RS_INTERP_1 0x4314
+# define R300_RS_INTERP_1_UNKNOWN 0x40
+#define R300_RS_INTERP_2 0x4318
+# define R300_RS_INTERP_2_UNKNOWN 0x80
+#define R300_RS_INTERP_3 0x431C
+# define R300_RS_INTERP_3_UNKNOWN 0xC0
+#define R300_RS_INTERP_4 0x4320
+#define R300_RS_INTERP_5 0x4324
+#define R300_RS_INTERP_6 0x4328
+#define R300_RS_INTERP_7 0x432C
+# define R300_RS_INTERP_SRC_SHIFT 2
+# define R300_RS_INTERP_SRC_MASK (7 << 2)
+# define R300_RS_INTERP_USED 0x00D10000
+
+/* These DWORDs control how vertex data is routed into fragment program
+// registers, after interpolators. */
+#define R300_RS_ROUTE_0 0x4330
+#define R300_RS_ROUTE_1 0x4334
+#define R300_RS_ROUTE_2 0x4338
+#define R300_RS_ROUTE_3 0x433C /* GUESS */
+#define R300_RS_ROUTE_4 0x4340 /* GUESS */
+#define R300_RS_ROUTE_5 0x4344 /* GUESS */
+#define R300_RS_ROUTE_6 0x4348 /* GUESS */
+#define R300_RS_ROUTE_7 0x434C /* GUESS */
+# define R300_RS_ROUTE_SOURCE_INTERP_0 0
+# define R300_RS_ROUTE_SOURCE_INTERP_1 1
+# define R300_RS_ROUTE_SOURCE_INTERP_2 2
+# define R300_RS_ROUTE_SOURCE_INTERP_3 3
+# define R300_RS_ROUTE_SOURCE_INTERP_4 4
+# define R300_RS_ROUTE_SOURCE_INTERP_5 5 /* GUESS */
+# define R300_RS_ROUTE_SOURCE_INTERP_6 6 /* GUESS */
+# define R300_RS_ROUTE_SOURCE_INTERP_7 7 /* GUESS */
+# define R300_RS_ROUTE_ENABLE (1 << 3) /* GUESS */
+# define R300_RS_ROUTE_DEST_SHIFT 6
+# define R300_RS_ROUTE_DEST_MASK (31 << 6) /* GUESS */
+
+/* Special handling for color: When the fragment program uses color,
+// the ROUTE_0_COLOR bit is set and ROUTE_0_COLOR_DEST contains the
+// color register index. */
+# define R300_RS_ROUTE_0_COLOR (1 << 14)
+# define R300_RS_ROUTE_0_COLOR_DEST_SHIFT 17
+# define R300_RS_ROUTE_0_COLOR_DEST_MASK (31 << 17) /* GUESS */
+/* As above, but for secondary color */
+# define R300_RS_ROUTE_1_COLOR1 (1 << 14)
+# define R300_RS_ROUTE_1_COLOR1_DEST_SHIFT 17
+# define R300_RS_ROUTE_1_COLOR1_DEST_MASK (31 << 17)
+# define R300_RS_ROUTE_1_UNKNOWN11 (1 << 11)
+/* END */
+
+/* BEGIN: Scissors and cliprects
+// There are four clipping rectangles. Their corner coordinates are inclusive.
+// Every pixel is assigned a number from 0 and 15 by setting bits 0-3 depending
+// on whether the pixel is inside cliprects 0-3, respectively. For example,
+// if a pixel is inside cliprects 0 and 1, but outside 2 and 3, it is assigned
+// the number 3 (binary 0011).
+// Iff the bit corresponding to the pixel's number in RE_CLIPRECT_CNTL is set,
+// the pixel is rasterized.
+//
+// In addition to this, there is a scissors rectangle. Only pixels inside the
+// scissors rectangle are drawn. (coordinates are inclusive)
+//
+// For some reason, the top-left corner of the framebuffer is at (1440, 1440)
+// for the purpose of clipping and scissors. */
+#define R300_RE_CLIPRECT_TL_0 0x43B0
+#define R300_RE_CLIPRECT_BR_0 0x43B4
+#define R300_RE_CLIPRECT_TL_1 0x43B8
+#define R300_RE_CLIPRECT_BR_1 0x43BC
+#define R300_RE_CLIPRECT_TL_2 0x43C0
+#define R300_RE_CLIPRECT_BR_2 0x43C4
+#define R300_RE_CLIPRECT_TL_3 0x43C8
+#define R300_RE_CLIPRECT_BR_3 0x43CC
+# define R300_CLIPRECT_OFFSET 1440
+# define R300_CLIPRECT_MASK 0x1FFF
+# define R300_CLIPRECT_X_SHIFT 0
+# define R300_CLIPRECT_X_MASK (0x1FFF << 0)
+# define R300_CLIPRECT_Y_SHIFT 13
+# define R300_CLIPRECT_Y_MASK (0x1FFF << 13)
+#define R300_RE_CLIPRECT_CNTL 0x43D0
+# define R300_CLIP_OUT (1 << 0)
+# define R300_CLIP_0 (1 << 1)
+# define R300_CLIP_1 (1 << 2)
+# define R300_CLIP_10 (1 << 3)
+# define R300_CLIP_2 (1 << 4)
+# define R300_CLIP_20 (1 << 5)
+# define R300_CLIP_21 (1 << 6)
+# define R300_CLIP_210 (1 << 7)
+# define R300_CLIP_3 (1 << 8)
+# define R300_CLIP_30 (1 << 9)
+# define R300_CLIP_31 (1 << 10)
+# define R300_CLIP_310 (1 << 11)
+# define R300_CLIP_32 (1 << 12)
+# define R300_CLIP_320 (1 << 13)
+# define R300_CLIP_321 (1 << 14)
+# define R300_CLIP_3210 (1 << 15)
+
+/* gap */
+#define R300_RE_SCISSORS_TL 0x43E0
+#define R300_RE_SCISSORS_BR 0x43E4
+# define R300_SCISSORS_OFFSET 1440
+# define R300_SCISSORS_X_SHIFT 0
+# define R300_SCISSORS_X_MASK (0x1FFF << 0)
+# define R300_SCISSORS_Y_SHIFT 13
+# define R300_SCISSORS_Y_MASK (0x1FFF << 13)
+/* END */
+
+/* BEGIN: Texture specification
+// The texture specification dwords are grouped by meaning and not by texture unit.
+// This means that e.g. the offset for texture image unit N is found in register
+// TX_OFFSET_0 + (4*N) */
+#define R300_TX_FILTER_0 0x4400
+# define R300_TX_REPEAT 0
+# define R300_TX_MIRRORED 1
+# define R300_TX_CLAMP 4
+# define R300_TX_CLAMP_TO_EDGE 2
+# define R300_TX_CLAMP_TO_BORDER 6
+# define R300_TX_WRAP_S_SHIFT 0
+# define R300_TX_WRAP_S_MASK (7 << 0)
+# define R300_TX_WRAP_T_SHIFT 3
+# define R300_TX_WRAP_T_MASK (7 << 3)
+# define R300_TX_WRAP_Q_SHIFT 6
+# define R300_TX_WRAP_Q_MASK (7 << 6)
+# define R300_TX_MAG_FILTER_NEAREST (1 << 9)
+# define R300_TX_MAG_FILTER_LINEAR (2 << 9)
+# define R300_TX_MAG_FILTER_MASK (3 << 9)
+# define R300_TX_MIN_FILTER_NEAREST (1 << 11)
+# define R300_TX_MIN_FILTER_LINEAR (2 << 11)
+# define R300_TX_MIN_FILTER_NEAREST_MIP_NEAREST (5 << 11)
+# define R300_TX_MIN_FILTER_NEAREST_MIP_LINEAR (9 << 11)
+# define R300_TX_MIN_FILTER_LINEAR_MIP_NEAREST (6 << 11)
+# define R300_TX_MIN_FILTER_LINEAR_MIP_LINEAR (10 << 11)
+
+/* NOTE: NEAREST doesnt seem to exist.
+ Im not seting MAG_FILTER_MASK and (3 << 11) on for all
+ anisotropy modes because that would void selected mag filter */
+# define R300_TX_MIN_FILTER_ANISO_NEAREST ((0 << 13) /*|R300_TX_MAG_FILTER_MASK|(3<<11)*/)
+# define R300_TX_MIN_FILTER_ANISO_LINEAR ((0 << 13) /*|R300_TX_MAG_FILTER_MASK|(3<<11)*/)
+# define R300_TX_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST ((1 << 13) /*|R300_TX_MAG_FILTER_MASK|(3<<11)*/)
+# define R300_TX_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR ((2 << 13) /*|R300_TX_MAG_FILTER_MASK|(3<<11)*/)
+# define R300_TX_MIN_FILTER_MASK ( (15 << 11) | (3 << 13) )
+# define R300_TX_MAX_ANISO_1_TO_1 (0 << 21)
+# define R300_TX_MAX_ANISO_2_TO_1 (2 << 21)
+# define R300_TX_MAX_ANISO_4_TO_1 (4 << 21)
+# define R300_TX_MAX_ANISO_8_TO_1 (6 << 21)
+# define R300_TX_MAX_ANISO_16_TO_1 (8 << 21)
+# define R300_TX_MAX_ANISO_MASK (14 << 21)
+
+#define R300_TX_UNK1_0 0x4440
+# define R300_LOD_BIAS_MASK 0x1fff
+
+#define R300_TX_SIZE_0 0x4480
+# define R300_TX_WIDTHMASK_SHIFT 0
+# define R300_TX_WIDTHMASK_MASK (2047 << 0)
+# define R300_TX_HEIGHTMASK_SHIFT 11
+# define R300_TX_HEIGHTMASK_MASK (2047 << 11)
+# define R300_TX_UNK23 (1 << 23)
+# define R300_TX_SIZE_SHIFT 26 /* largest of width, height */
+# define R300_TX_SIZE_MASK (15 << 26)
+#define R300_TX_FORMAT_0 0x44C0
+ /* The interpretation of the format word by Wladimir van der Laan */
+ /* The X, Y, Z and W refer to the layout of the components.
+ They are given meanings as R, G, B and Alpha by the swizzle
+ specification */
+# define R300_TX_FORMAT_X8 0x0
+# define R300_TX_FORMAT_X16 0x1
+# define R300_TX_FORMAT_Y4X4 0x2
+# define R300_TX_FORMAT_Y8X8 0x3
+# define R300_TX_FORMAT_Y16X16 0x4
+# define R300_TX_FORMAT_Z3Y3X2 0x5
+# define R300_TX_FORMAT_Z5Y6X5 0x6
+# define R300_TX_FORMAT_Z6Y5X5 0x7
+# define R300_TX_FORMAT_Z11Y11X10 0x8
+# define R300_TX_FORMAT_Z10Y11X11 0x9
+# define R300_TX_FORMAT_W4Z4Y4X4 0xA
+# define R300_TX_FORMAT_W1Z5Y5X5 0xB
+# define R300_TX_FORMAT_W8Z8Y8X8 0xC
+# define R300_TX_FORMAT_W2Z10Y10X10 0xD
+# define R300_TX_FORMAT_W16Z16Y16X16 0xE
+# define R300_TX_FORMAT_DXT1 0xF
+# define R300_TX_FORMAT_DXT3 0x10
+# define R300_TX_FORMAT_DXT5 0x11
+# define R300_TX_FORMAT_D3DMFT_CxV8U8 0x12 /* no swizzle */
+# define R300_TX_FORMAT_A8R8G8B8 0x13 /* no swizzle */
+# define R300_TX_FORMAT_B8G8_B8G8 0x14 /* no swizzle */
+# define R300_TX_FORMAT_G8R8_G8B8 0x15 /* no swizzle */
+ /* 0x16 - some 16 bit green format.. ?? */
+# define R300_TX_FORMAT_UNK25 (1 << 25) /* no swizzle */
+
+ /* gap */
+ /* Floating point formats */
+ /* Note - hardware supports both 16 and 32 bit floating point */
+# define R300_TX_FORMAT_FL_I16 0x18
+# define R300_TX_FORMAT_FL_I16A16 0x19
+# define R300_TX_FORMAT_FL_R16G16B16A16 0x1A
+# define R300_TX_FORMAT_FL_I32 0x1B
+# define R300_TX_FORMAT_FL_I32A32 0x1C
+# define R300_TX_FORMAT_FL_R32G32B32A32 0x1D
+ /* alpha modes, convenience mostly */
+ /* if you have alpha, pick constant appropriate to the
+ number of channels (1 for I8, 2 for I8A8, 4 for R8G8B8A8, etc */
+# define R300_TX_FORMAT_ALPHA_1CH 0x000
+# define R300_TX_FORMAT_ALPHA_2CH 0x200
+# define R300_TX_FORMAT_ALPHA_4CH 0x600
+# define R300_TX_FORMAT_ALPHA_NONE 0xA00
+ /* Swizzling */
+ /* constants */
+# define R300_TX_FORMAT_X 0
+# define R300_TX_FORMAT_Y 1
+# define R300_TX_FORMAT_Z 2
+# define R300_TX_FORMAT_W 3
+# define R300_TX_FORMAT_ZERO 4
+# define R300_TX_FORMAT_ONE 5
+# define R300_TX_FORMAT_CUT_Z 6 /* 2.0*Z, everything above 1.0 is set to 0.0 */
+# define R300_TX_FORMAT_CUT_W 7 /* 2.0*W, everything above 1.0 is set to 0.0 */
+
+# define R300_TX_FORMAT_B_SHIFT 18
+# define R300_TX_FORMAT_G_SHIFT 15
+# define R300_TX_FORMAT_R_SHIFT 12
+# define R300_TX_FORMAT_A_SHIFT 9
+ /* Convenience macro to take care of layout and swizzling */
+# define R300_EASY_TX_FORMAT(B, G, R, A, FMT) (\
+ ((R300_TX_FORMAT_##B)<<R300_TX_FORMAT_B_SHIFT) \
+ | ((R300_TX_FORMAT_##G)<<R300_TX_FORMAT_G_SHIFT) \
+ | ((R300_TX_FORMAT_##R)<<R300_TX_FORMAT_R_SHIFT) \
+ | ((R300_TX_FORMAT_##A)<<R300_TX_FORMAT_A_SHIFT) \
+ | (R300_TX_FORMAT_##FMT) \
+ )
+ /* These can be ORed with result of R300_EASY_TX_FORMAT() */
+ /* We don't really know what they do. Take values from a constant color ? */
+# define R300_TX_FORMAT_CONST_X (1<<5)
+# define R300_TX_FORMAT_CONST_Y (2<<5)
+# define R300_TX_FORMAT_CONST_Z (4<<5)
+# define R300_TX_FORMAT_CONST_W (8<<5)
+
+# define R300_TX_FORMAT_YUV_MODE 0x00800000
+
+#define R300_TX_OFFSET_0 0x4540
+/* BEGIN: Guess from R200 */
+# define R300_TXO_ENDIAN_NO_SWAP (0 << 0)
+# define R300_TXO_ENDIAN_BYTE_SWAP (1 << 0)
+# define R300_TXO_ENDIAN_WORD_SWAP (2 << 0)
+# define R300_TXO_ENDIAN_HALFDW_SWAP (3 << 0)
+# define R300_TXO_OFFSET_MASK 0xffffffe0
+# define R300_TXO_OFFSET_SHIFT 5
+/* END */
+#define R300_TX_UNK4_0 0x4580
+#define R300_TX_BORDER_COLOR_0 0x45C0 //ff00ff00 == { 0, 1.0, 0, 1.0 }
+
+/* END */
+
+/* BEGIN: Fragment program instruction set
+// Fragment programs are written directly into register space.
+// There are separate instruction streams for texture instructions and ALU
+// instructions.
+// In order to synchronize these streams, the program is divided into up
+// to 4 nodes. Each node begins with a number of TEX operations, followed
+// by a number of ALU operations.
+// The first node can have zero TEX ops, all subsequent nodes must have at least
+// one TEX ops.
+// All nodes must have at least one ALU op.
+//
+// The index of the last node is stored in PFS_CNTL_0: A value of 0 means
+// 1 node, a value of 3 means 4 nodes.
+// The total amount of instructions is defined in PFS_CNTL_2. The offsets are
+// offsets into the respective instruction streams, while *_END points to the
+// last instruction relative to this offset. */
+#define R300_PFS_CNTL_0 0x4600
+# define R300_PFS_CNTL_LAST_NODES_SHIFT 0
+# define R300_PFS_CNTL_LAST_NODES_MASK (3 << 0)
+# define R300_PFS_CNTL_FIRST_NODE_HAS_TEX (1 << 3)
+#define R300_PFS_CNTL_1 0x4604
+/* There is an unshifted value here which has so far always been equal to the
+// index of the highest used temporary register. */
+#define R300_PFS_CNTL_2 0x4608
+# define R300_PFS_CNTL_ALU_OFFSET_SHIFT 0
+# define R300_PFS_CNTL_ALU_OFFSET_MASK (63 << 0)
+# define R300_PFS_CNTL_ALU_END_SHIFT 6
+# define R300_PFS_CNTL_ALU_END_MASK (63 << 0)
+# define R300_PFS_CNTL_TEX_OFFSET_SHIFT 12
+# define R300_PFS_CNTL_TEX_OFFSET_MASK (31 << 12) /* GUESS */
+# define R300_PFS_CNTL_TEX_END_SHIFT 18
+# define R300_PFS_CNTL_TEX_END_MASK (31 << 18) /* GUESS */
+
+/* gap */
+/* Nodes are stored backwards. The last active node is always stored in
+// PFS_NODE_3.
+// Example: In a 2-node program, NODE_0 and NODE_1 are set to 0. The
+// first node is stored in NODE_2, the second node is stored in NODE_3.
+//
+// Offsets are relative to the master offset from PFS_CNTL_2.
+// LAST_NODE is set for the last node, and only for the last node. */
+#define R300_PFS_NODE_0 0x4610
+#define R300_PFS_NODE_1 0x4614
+#define R300_PFS_NODE_2 0x4618
+#define R300_PFS_NODE_3 0x461C
+# define R300_PFS_NODE_ALU_OFFSET_SHIFT 0
+# define R300_PFS_NODE_ALU_OFFSET_MASK (63 << 0)
+# define R300_PFS_NODE_ALU_END_SHIFT 6
+# define R300_PFS_NODE_ALU_END_MASK (63 << 6)
+# define R300_PFS_NODE_TEX_OFFSET_SHIFT 12
+# define R300_PFS_NODE_TEX_OFFSET_MASK (31 << 12)
+# define R300_PFS_NODE_TEX_END_SHIFT 17
+# define R300_PFS_NODE_TEX_END_MASK (31 << 17)
+# define R300_PFS_NODE_LAST_NODE (1 << 22)
+
+/* TEX
+// As far as I can tell, texture instructions cannot write into output
+// registers directly. A subsequent ALU instruction is always necessary,
+// even if it's just MAD o0, r0, 1, 0 */
+#define R300_PFS_TEXI_0 0x4620
+# define R300_FPITX_SRC_SHIFT 0
+# define R300_FPITX_SRC_MASK (31 << 0)
+# define R300_FPITX_SRC_CONST (1 << 5) /* GUESS */
+# define R300_FPITX_DST_SHIFT 6
+# define R300_FPITX_DST_MASK (31 << 6)
+# define R300_FPITX_IMAGE_SHIFT 11
+# define R300_FPITX_IMAGE_MASK (15 << 11) /* GUESS based on layout and native limits */
+/* Unsure if these are opcodes, or some kind of bitfield, but this is how
+ * they were set when I checked
+ */
+# define R300_FPITX_OPCODE_SHIFT 15
+# define R300_FPITX_OP_TEX 1
+# define R300_FPITX_OP_TXP 3
+# define R300_FPITX_OP_TXB 4
+
+/* ALU
+// The ALU instructions register blocks are enumerated according to the order
+// in which fglrx. I assume there is space for 64 instructions, since
+// each block has space for a maximum of 64 DWORDs, and this matches reported
+// native limits.
+//
+// The basic functional block seems to be one MAD for each color and alpha,
+// and an adder that adds all components after the MUL.
+// - ADD, MUL, MAD etc.: use MAD with appropriate neutral operands
+// - DP4: Use OUTC_DP4, OUTA_DP4
+// - DP3: Use OUTC_DP3, OUTA_DP4, appropriate alpha operands
+// - DPH: Use OUTC_DP4, OUTA_DP4, appropriate alpha operands
+// - CMP: If ARG2 < 0, return ARG1, else return ARG0
+// - FLR: use FRC+MAD
+// - XPD: use MAD+MAD
+// - SGE, SLT: use MAD+CMP
+// - RSQ: use ABS modifier for argument
+// - Use OUTC_REPL_ALPHA to write results of an alpha-only operation (e.g. RCP)
+// into color register
+// - apparently, there's no quick DST operation
+// - fglrx set FPI2_UNKNOWN_31 on a "MAD fragment.color, tmp0, tmp1, tmp2"
+// - fglrx set FPI2_UNKNOWN_31 on a "MAX r2, r1, c0"
+// - fglrx once set FPI0_UNKNOWN_31 on a "FRC r1, r1"
+//
+// Operand selection
+// First stage selects three sources from the available registers and
+// constant parameters. This is defined in INSTR1 (color) and INSTR3 (alpha).
+// fglrx sorts the three source fields: Registers before constants,
+// lower indices before higher indices; I do not know whether this is necessary.
+// fglrx fills unused sources with "read constant 0"
+// According to specs, you cannot select more than two different constants.
+//
+// Second stage selects the operands from the sources. This is defined in
+// INSTR0 (color) and INSTR2 (alpha). You can also select the special constants
+// zero and one.
+// Swizzling and negation happens in this stage, as well.
+//
+// Important: Color and alpha seem to be mostly separate, i.e. their sources
+// selection appears to be fully independent (the register storage is probably
+// physically split into a color and an alpha section).
+// However (because of the apparent physical split), there is some interaction
+// WRT swizzling. If, for example, you want to load an R component into an
+// Alpha operand, this R component is taken from a *color* source, not from
+// an alpha source. The corresponding register doesn't even have to appear in
+// the alpha sources list. (I hope this alll makes sense to you)
+//
+// Destination selection
+// The destination register index is in FPI1 (color) and FPI3 (alpha) together
+// with enable bits.
+// There are separate enable bits for writing into temporary registers
+// (DSTC_REG_* /DSTA_REG) and and program output registers (DSTC_OUTPUT_* /DSTA_OUTPUT).
+// You can write to both at once, or not write at all (the same index
+// must be used for both).
+//
+// Note: There is a special form for LRP
+// - Argument order is the same as in ARB_fragment_program.
+// - Operation is MAD
+// - ARG1 is set to ARGC_SRC1C_LRP/ARGC_SRC1A_LRP
+// - Set FPI0/FPI2_SPECIAL_LRP
+// Arbitrary LRP (including support for swizzling) requires vanilla MAD+MAD */
+#define R300_PFS_INSTR1_0 0x46C0
+# define R300_FPI1_SRC0C_SHIFT 0
+# define R300_FPI1_SRC0C_MASK (31 << 0)
+# define R300_FPI1_SRC0C_CONST (1 << 5)
+# define R300_FPI1_SRC1C_SHIFT 6
+# define R300_FPI1_SRC1C_MASK (31 << 6)
+# define R300_FPI1_SRC1C_CONST (1 << 11)
+# define R300_FPI1_SRC2C_SHIFT 12
+# define R300_FPI1_SRC2C_MASK (31 << 12)
+# define R300_FPI1_SRC2C_CONST (1 << 17)
+# define R300_FPI1_DSTC_SHIFT 18
+# define R300_FPI1_DSTC_MASK (31 << 18)
+# define R300_FPI1_DSTC_REG_X (1 << 23)
+# define R300_FPI1_DSTC_REG_Y (1 << 24)
+# define R300_FPI1_DSTC_REG_Z (1 << 25)
+# define R300_FPI1_DSTC_OUTPUT_X (1 << 26)
+# define R300_FPI1_DSTC_OUTPUT_Y (1 << 27)
+# define R300_FPI1_DSTC_OUTPUT_Z (1 << 28)
+
+#define R300_PFS_INSTR3_0 0x47C0
+# define R300_FPI3_SRC0A_SHIFT 0
+# define R300_FPI3_SRC0A_MASK (31 << 0)
+# define R300_FPI3_SRC0A_CONST (1 << 5)
+# define R300_FPI3_SRC1A_SHIFT 6
+# define R300_FPI3_SRC1A_MASK (31 << 6)
+# define R300_FPI3_SRC1A_CONST (1 << 11)
+# define R300_FPI3_SRC2A_SHIFT 12
+# define R300_FPI3_SRC2A_MASK (31 << 12)
+# define R300_FPI3_SRC2A_CONST (1 << 17)
+# define R300_FPI3_DSTA_SHIFT 18
+# define R300_FPI3_DSTA_MASK (31 << 18)
+# define R300_FPI3_DSTA_REG (1 << 23)
+# define R300_FPI3_DSTA_OUTPUT (1 << 24)
+
+#define R300_PFS_INSTR0_0 0x48C0
+# define R300_FPI0_ARGC_SRC0C_XYZ 0
+# define R300_FPI0_ARGC_SRC0C_XXX 1
+# define R300_FPI0_ARGC_SRC0C_YYY 2
+# define R300_FPI0_ARGC_SRC0C_ZZZ 3
+# define R300_FPI0_ARGC_SRC1C_XYZ 4
+# define R300_FPI0_ARGC_SRC1C_XXX 5
+# define R300_FPI0_ARGC_SRC1C_YYY 6
+# define R300_FPI0_ARGC_SRC1C_ZZZ 7
+# define R300_FPI0_ARGC_SRC2C_XYZ 8
+# define R300_FPI0_ARGC_SRC2C_XXX 9
+# define R300_FPI0_ARGC_SRC2C_YYY 10
+# define R300_FPI0_ARGC_SRC2C_ZZZ 11
+# define R300_FPI0_ARGC_SRC0A 12
+# define R300_FPI0_ARGC_SRC1A 13
+# define R300_FPI0_ARGC_SRC2A 14
+# define R300_FPI0_ARGC_SRC1C_LRP 15
+# define R300_FPI0_ARGC_ZERO 20
+# define R300_FPI0_ARGC_ONE 21
+# define R300_FPI0_ARGC_HALF 22 /* GUESS */
+# define R300_FPI0_ARGC_SRC0C_YZX 23
+# define R300_FPI0_ARGC_SRC1C_YZX 24
+# define R300_FPI0_ARGC_SRC2C_YZX 25
+# define R300_FPI0_ARGC_SRC0C_ZXY 26
+# define R300_FPI0_ARGC_SRC1C_ZXY 27
+# define R300_FPI0_ARGC_SRC2C_ZXY 28
+# define R300_FPI0_ARGC_SRC0CA_WZY 29
+# define R300_FPI0_ARGC_SRC1CA_WZY 30
+# define R300_FPI0_ARGC_SRC2CA_WZY 31
+
+# define R300_FPI0_ARG0C_SHIFT 0
+# define R300_FPI0_ARG0C_MASK (31 << 0)
+# define R300_FPI0_ARG0C_NEG (1 << 5)
+# define R300_FPI0_ARG0C_ABS (1 << 6)
+# define R300_FPI0_ARG1C_SHIFT 7
+# define R300_FPI0_ARG1C_MASK (31 << 7)
+# define R300_FPI0_ARG1C_NEG (1 << 12)
+# define R300_FPI0_ARG1C_ABS (1 << 13)
+# define R300_FPI0_ARG2C_SHIFT 14
+# define R300_FPI0_ARG2C_MASK (31 << 14)
+# define R300_FPI0_ARG2C_NEG (1 << 19)
+# define R300_FPI0_ARG2C_ABS (1 << 20)
+# define R300_FPI0_SPECIAL_LRP (1 << 21)
+# define R300_FPI0_OUTC_MAD (0 << 23)
+# define R300_FPI0_OUTC_DP3 (1 << 23)
+# define R300_FPI0_OUTC_DP4 (2 << 23)
+# define R300_FPI0_OUTC_MIN (4 << 23)
+# define R300_FPI0_OUTC_MAX (5 << 23)
+# define R300_FPI0_OUTC_CMP (8 << 23)
+# define R300_FPI0_OUTC_FRC (9 << 23)
+# define R300_FPI0_OUTC_REPL_ALPHA (10 << 23)
+# define R300_FPI0_OUTC_SAT (1 << 30)
+# define R300_FPI0_UNKNOWN_31 (1 << 31)
+
+#define R300_PFS_INSTR2_0 0x49C0
+# define R300_FPI2_ARGA_SRC0C_X 0
+# define R300_FPI2_ARGA_SRC0C_Y 1
+# define R300_FPI2_ARGA_SRC0C_Z 2
+# define R300_FPI2_ARGA_SRC1C_X 3
+# define R300_FPI2_ARGA_SRC1C_Y 4
+# define R300_FPI2_ARGA_SRC1C_Z 5
+# define R300_FPI2_ARGA_SRC2C_X 6
+# define R300_FPI2_ARGA_SRC2C_Y 7
+# define R300_FPI2_ARGA_SRC2C_Z 8
+# define R300_FPI2_ARGA_SRC0A 9
+# define R300_FPI2_ARGA_SRC1A 10
+# define R300_FPI2_ARGA_SRC2A 11
+# define R300_FPI2_ARGA_SRC1A_LRP 15
+# define R300_FPI2_ARGA_ZERO 16
+# define R300_FPI2_ARGA_ONE 17
+# define R300_FPI2_ARGA_HALF 18 /* GUESS */
+
+# define R300_FPI2_ARG0A_SHIFT 0
+# define R300_FPI2_ARG0A_MASK (31 << 0)
+# define R300_FPI2_ARG0A_NEG (1 << 5)
+# define R300_FPI2_ARG0A_ABS (1 << 6) /* GUESS */
+# define R300_FPI2_ARG1A_SHIFT 7
+# define R300_FPI2_ARG1A_MASK (31 << 7)
+# define R300_FPI2_ARG1A_NEG (1 << 12)
+# define R300_FPI2_ARG1A_ABS (1 << 13) /* GUESS */
+# define R300_FPI2_ARG2A_SHIFT 14
+# define R300_FPI2_ARG2A_MASK (31 << 14)
+# define R300_FPI2_ARG2A_NEG (1 << 19)
+# define R300_FPI2_ARG2A_ABS (1 << 20) /* GUESS */
+# define R300_FPI2_SPECIAL_LRP (1 << 21)
+# define R300_FPI2_OUTA_MAD (0 << 23)
+# define R300_FPI2_OUTA_DP4 (1 << 23)
+# define R300_FPI2_OUTA_MIN (2 << 23)
+# define R300_FPI2_OUTA_MAX (3 << 23)
+# define R300_FPI2_OUTA_CMP (6 << 23)
+# define R300_FPI2_OUTA_FRC (7 << 23)
+# define R300_FPI2_OUTA_EX2 (8 << 23)
+# define R300_FPI2_OUTA_LG2 (9 << 23)
+# define R300_FPI2_OUTA_RCP (10 << 23)
+# define R300_FPI2_OUTA_RSQ (11 << 23)
+# define R300_FPI2_OUTA_SAT (1 << 30)
+# define R300_FPI2_UNKNOWN_31 (1 << 31)
+/* END */
+
+/* gap */
+#define R300_PP_ALPHA_TEST 0x4BD4
+# define R300_REF_ALPHA_MASK 0x000000ff
+# define R300_ALPHA_TEST_FAIL (0 << 8)
+# define R300_ALPHA_TEST_LESS (1 << 8)
+# define R300_ALPHA_TEST_LEQUAL (3 << 8)
+# define R300_ALPHA_TEST_EQUAL (2 << 8)
+# define R300_ALPHA_TEST_GEQUAL (6 << 8)
+# define R300_ALPHA_TEST_GREATER (4 << 8)
+# define R300_ALPHA_TEST_NEQUAL (5 << 8)
+# define R300_ALPHA_TEST_PASS (7 << 8)
+# define R300_ALPHA_TEST_OP_MASK (7 << 8)
+# define R300_ALPHA_TEST_ENABLE (1 << 11)
+
+/* gap */
+/* Fragment program parameters in 7.16 floating point */
+#define R300_PFS_PARAM_0_X 0x4C00
+#define R300_PFS_PARAM_0_Y 0x4C04
+#define R300_PFS_PARAM_0_Z 0x4C08
+#define R300_PFS_PARAM_0_W 0x4C0C
+/* GUESS: PARAM_31 is last, based on native limits reported by fglrx */
+#define R300_PFS_PARAM_31_X 0x4DF0
+#define R300_PFS_PARAM_31_Y 0x4DF4
+#define R300_PFS_PARAM_31_Z 0x4DF8
+#define R300_PFS_PARAM_31_W 0x4DFC
+
+/* Notes:
+// - AFAIK fglrx always sets BLEND_UNKNOWN when blending is used in the application
+// - AFAIK fglrx always sets BLEND_NO_SEPARATE when CBLEND and ABLEND are set to the same
+// function (both registers are always set up completely in any case)
+// - Most blend flags are simply copied from R200 and not tested yet */
+#define R300_RB3D_CBLEND 0x4E04
+#define R300_RB3D_ABLEND 0x4E08
+ /* the following only appear in CBLEND */
+# define R300_BLEND_ENABLE (1 << 0)
+# define R300_BLEND_UNKNOWN (3 << 1)
+# define R300_BLEND_NO_SEPARATE (1 << 3)
+ /* the following are shared between CBLEND and ABLEND */
+# define R300_FCN_MASK (3 << 12)
+# define R300_COMB_FCN_ADD_CLAMP (0 << 12)
+# define R300_COMB_FCN_ADD_NOCLAMP (1 << 12)
+# define R300_COMB_FCN_SUB_CLAMP (2 << 12)
+# define R300_COMB_FCN_SUB_NOCLAMP (3 << 12)
+# define R300_SRC_BLEND_GL_ZERO (32 << 16)
+# define R300_SRC_BLEND_GL_ONE (33 << 16)
+# define R300_SRC_BLEND_GL_SRC_COLOR (34 << 16)
+# define R300_SRC_BLEND_GL_ONE_MINUS_SRC_COLOR (35 << 16)
+# define R300_SRC_BLEND_GL_DST_COLOR (36 << 16)
+# define R300_SRC_BLEND_GL_ONE_MINUS_DST_COLOR (37 << 16)
+# define R300_SRC_BLEND_GL_SRC_ALPHA (38 << 16)
+# define R300_SRC_BLEND_GL_ONE_MINUS_SRC_ALPHA (39 << 16)
+# define R300_SRC_BLEND_GL_DST_ALPHA (40 << 16)
+# define R300_SRC_BLEND_GL_ONE_MINUS_DST_ALPHA (41 << 16)
+# define R300_SRC_BLEND_GL_SRC_ALPHA_SATURATE (42 << 16)
+# define R300_SRC_BLEND_MASK (63 << 16)
+# define R300_DST_BLEND_GL_ZERO (32 << 24)
+# define R300_DST_BLEND_GL_ONE (33 << 24)
+# define R300_DST_BLEND_GL_SRC_COLOR (34 << 24)
+# define R300_DST_BLEND_GL_ONE_MINUS_SRC_COLOR (35 << 24)
+# define R300_DST_BLEND_GL_DST_COLOR (36 << 24)
+# define R300_DST_BLEND_GL_ONE_MINUS_DST_COLOR (37 << 24)
+# define R300_DST_BLEND_GL_SRC_ALPHA (38 << 24)
+# define R300_DST_BLEND_GL_ONE_MINUS_SRC_ALPHA (39 << 24)
+# define R300_DST_BLEND_GL_DST_ALPHA (40 << 24)
+# define R300_DST_BLEND_GL_ONE_MINUS_DST_ALPHA (41 << 24)
+# define R300_DST_BLEND_MASK (63 << 24)
+#define R300_RB3D_COLORMASK 0x4E0C
+# define R300_COLORMASK0_B (1<<0)
+# define R300_COLORMASK0_G (1<<1)
+# define R300_COLORMASK0_R (1<<2)
+# define R300_COLORMASK0_A (1<<3)
+
+/* gap */
+#define R300_RB3D_COLOROFFSET0 0x4E28
+# define R300_COLOROFFSET_MASK 0xFFFFFFF0 /* GUESS */
+#define R300_RB3D_COLOROFFSET1 0x4E2C /* GUESS */
+#define R300_RB3D_COLOROFFSET2 0x4E30 /* GUESS */
+#define R300_RB3D_COLOROFFSET3 0x4E34 /* GUESS */
+/* gap */
+/* Bit 16: Larger tiles
+// Bit 17: 4x2 tiles
+// Bit 18: Extremely weird tile like, but some pixels duplicated? */
+#define R300_RB3D_COLORPITCH0 0x4E38
+# define R300_COLORPITCH_MASK 0x00001FF8 /* GUESS */
+# define R300_COLOR_TILE_ENABLE (1 << 16) /* GUESS */
+# define R300_COLOR_MICROTILE_ENABLE (1 << 17) /* GUESS */
+# define R300_COLOR_ENDIAN_NO_SWAP (0 << 18) /* GUESS */
+# define R300_COLOR_ENDIAN_WORD_SWAP (1 << 18) /* GUESS */
+# define R300_COLOR_ENDIAN_DWORD_SWAP (2 << 18) /* GUESS */
+# define R300_COLOR_FORMAT_RGB565 (2 << 22)
+# define R300_COLOR_FORMAT_ARGB8888 (3 << 22)
+#define R300_RB3D_COLORPITCH1 0x4E3C /* GUESS */
+#define R300_RB3D_COLORPITCH2 0x4E40 /* GUESS */
+#define R300_RB3D_COLORPITCH3 0x4E44 /* GUESS */
+
+/* gap */
+/* Guess by Vladimir.
+// Set to 0A before 3D operations, set to 02 afterwards. */
+#define R300_RB3D_DSTCACHE_CTLSTAT 0x4E4C
+# define R300_RB3D_DSTCACHE_02 0x00000002
+# define R300_RB3D_DSTCACHE_0A 0x0000000A
+
+/* gap */
+/* There seems to be no "write only" setting, so use Z-test = ALWAYS for this. */
+/* Bit (1<<8) is the "test" bit. so plain write is 6 - vd */
+#define R300_RB3D_ZSTENCIL_CNTL_0 0x4F00
+# define R300_RB3D_Z_DISABLED_1 0x00000010 /* GUESS */
+# define R300_RB3D_Z_DISABLED_2 0x00000014 /* GUESS */
+# define R300_RB3D_Z_TEST 0x00000012
+# define R300_RB3D_Z_TEST_AND_WRITE 0x00000016
+# define R300_RB3D_Z_WRITE_ONLY 0x00000006
+
+# define R300_RB3D_Z_TEST 0x00000012
+# define R300_RB3D_Z_TEST_AND_WRITE 0x00000016
+# define R300_RB3D_Z_WRITE_ONLY 0x00000006
+# define R300_RB3D_STENCIL_ENABLE 0x00000001
+
+#define R300_RB3D_ZSTENCIL_CNTL_1 0x4F04
+ /* functions */
+# define R300_ZS_NEVER 0
+# define R300_ZS_LESS 1
+# define R300_ZS_LEQUAL 2
+# define R300_ZS_EQUAL 3
+# define R300_ZS_GEQUAL 4
+# define R300_ZS_GREATER 5
+# define R300_ZS_NOTEQUAL 6
+# define R300_ZS_ALWAYS 7
+# define R300_ZS_MASK 7
+ /* operations */
+# define R300_ZS_KEEP 0
+# define R300_ZS_ZERO 1
+# define R300_ZS_REPLACE 2
+# define R300_ZS_INCR 3
+# define R300_ZS_DECR 4
+# define R300_ZS_INVERT 5
+# define R300_ZS_INCR_WRAP 6
+# define R300_ZS_DECR_WRAP 7
+
+ /* front and back refer to operations done for front
+ and back faces, i.e. separate stencil function support */
+# define R300_RB3D_ZS1_DEPTH_FUNC_SHIFT 0
+# define R300_RB3D_ZS1_FRONT_FUNC_SHIFT 3
+# define R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT 6
+# define R300_RB3D_ZS1_FRONT_ZPASS_OP_SHIFT 9
+# define R300_RB3D_ZS1_FRONT_ZFAIL_OP_SHIFT 12
+# define R300_RB3D_ZS1_BACK_FUNC_SHIFT 15
+# define R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT 18
+# define R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT 21
+# define R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT 24
+
+
+
+#define R300_RB3D_ZSTENCIL_CNTL_2 0x4F08
+# define R300_RB3D_ZS2_STENCIL_REF_SHIFT 0
+# define R300_RB3D_ZS2_STENCIL_MASK 0xFF
+# define R300_RB3D_ZS2_STENCIL_MASK_SHIFT 8
+# define R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT 16
+
+/* gap */
+
+#define R300_RB3D_ZSTENCIL_FORMAT 0x4F10
+# define R300_DEPTH_FORMAT_16BIT_INT_Z (0 << 0)
+# define R300_DEPTH_FORMAT_24BIT_INT_Z (2 << 0)
+
+/* gap */
+#define R300_RB3D_DEPTHOFFSET 0x4F20
+#define R300_RB3D_DEPTHPITCH 0x4F24
+# define R300_DEPTHPITCH_MASK 0x00001FF8 /* GUESS */
+# define R300_DEPTH_TILE_ENABLE (1 << 16) /* GUESS */
+# define R300_DEPTH_MICROTILE_ENABLE (1 << 17) /* GUESS */
+# define R300_DEPTH_ENDIAN_NO_SWAP (0 << 18) /* GUESS */
+# define R300_DEPTH_ENDIAN_WORD_SWAP (1 << 18) /* GUESS */
+# define R300_DEPTH_ENDIAN_DWORD_SWAP (2 << 18) /* GUESS */
+
+/* BEGIN: Vertex program instruction set
+// Every instruction is four dwords long:
+// DWORD 0: output and opcode
+// DWORD 1: first argument
+// DWORD 2: second argument
+// DWORD 3: third argument
+//
+// Notes:
+// - ABS r, a is implemented as MAX r, a, -a
+// - MOV is implemented as ADD to zero
+// - XPD is implemented as MUL + MAD
+// - FLR is implemented as FRC + ADD
+// - apparently, fglrx tries to schedule instructions so that there is at least
+// one instruction between the write to a temporary and the first read
+// from said temporary; however, violations of this scheduling are allowed
+// - register indices seem to be unrelated with OpenGL aliasing to conventional state
+// - only one attribute and one parameter can be loaded at a time; however, the
+// same attribute/parameter can be used for more than one argument
+// - the second software argument for POW is the third hardware argument (no idea why)
+// - MAD with only temporaries as input seems to use VPI_OUT_SELECT_MAD_2
+//
+// There is some magic surrounding LIT:
+// The single argument is replicated across all three inputs, but swizzled:
+// First argument: xyzy
+// Second argument: xyzx
+// Third argument: xyzw
+// Whenever the result is used later in the fragment program, fglrx forces x and w
+// to be 1.0 in the input selection; I don't know whether this is strictly necessary */
+#define R300_VPI_OUT_OP_DOT (1 << 0)
+#define R300_VPI_OUT_OP_MUL (2 << 0)
+#define R300_VPI_OUT_OP_ADD (3 << 0)
+#define R300_VPI_OUT_OP_MAD (4 << 0)
+#define R300_VPI_OUT_OP_DST (5 << 0)
+#define R300_VPI_OUT_OP_FRC (6 << 0)
+#define R300_VPI_OUT_OP_MAX (7 << 0)
+#define R300_VPI_OUT_OP_MIN (8 << 0)
+#define R300_VPI_OUT_OP_SGE (9 << 0)
+#define R300_VPI_OUT_OP_SLT (10 << 0)
+#define R300_VPI_OUT_OP_UNK12 (12 << 0) /* Used in GL_POINT_DISTANCE_ATTENUATION_ARB, vector(scalar, vector) */
+#define R300_VPI_OUT_OP_EXP (65 << 0)
+#define R300_VPI_OUT_OP_LOG (66 << 0)
+#define R300_VPI_OUT_OP_UNK67 (67 << 0) /* Used in fog computations, scalar(scalar) */
+#define R300_VPI_OUT_OP_LIT (68 << 0)
+#define R300_VPI_OUT_OP_POW (69 << 0)
+#define R300_VPI_OUT_OP_RCP (70 << 0)
+#define R300_VPI_OUT_OP_RSQ (72 << 0)
+#define R300_VPI_OUT_OP_UNK73 (73 << 0) /* Used in GL_POINT_DISTANCE_ATTENUATION_ARB, scalar(scalar) */
+#define R300_VPI_OUT_OP_EX2 (75 << 0)
+#define R300_VPI_OUT_OP_LG2 (76 << 0)
+#define R300_VPI_OUT_OP_MAD_2 (128 << 0)
+#define R300_VPI_OUT_OP_UNK129 (129 << 0) /* all temps, vector(scalar, vector, vector) */
+
+#define R300_VPI_OUT_REG_CLASS_TEMPORARY (0 << 8)
+#define R300_VPI_OUT_REG_CLASS_RESULT (2 << 8)
+#define R300_VPI_OUT_REG_CLASS_MASK (31 << 8)
+
+#define R300_VPI_OUT_REG_INDEX_SHIFT 13
+#define R300_VPI_OUT_REG_INDEX_MASK (31 << 13) /* GUESS based on fglrx native limits */
+
+#define R300_VPI_OUT_WRITE_X (1 << 20)
+#define R300_VPI_OUT_WRITE_Y (1 << 21)
+#define R300_VPI_OUT_WRITE_Z (1 << 22)
+#define R300_VPI_OUT_WRITE_W (1 << 23)
+
+#define R300_VPI_IN_REG_CLASS_TEMPORARY (0 << 0)
+#define R300_VPI_IN_REG_CLASS_ATTRIBUTE (1 << 0)
+#define R300_VPI_IN_REG_CLASS_PARAMETER (2 << 0)
+#define R300_VPI_IN_REG_CLASS_NONE (9 << 0)
+#define R300_VPI_IN_REG_CLASS_MASK (31 << 0) /* GUESS */
+
+#define R300_VPI_IN_REG_INDEX_SHIFT 5
+#define R300_VPI_IN_REG_INDEX_MASK (255 << 5) /* GUESS based on fglrx native limits */
+
+/* The R300 can select components from the input register arbitrarily.
+// Use the following constants, shifted by the component shift you
+// want to select */
+#define R300_VPI_IN_SELECT_X 0
+#define R300_VPI_IN_SELECT_Y 1
+#define R300_VPI_IN_SELECT_Z 2
+#define R300_VPI_IN_SELECT_W 3
+#define R300_VPI_IN_SELECT_ZERO 4
+#define R300_VPI_IN_SELECT_ONE 5
+#define R300_VPI_IN_SELECT_MASK 7
+
+#define R300_VPI_IN_X_SHIFT 13
+#define R300_VPI_IN_Y_SHIFT 16
+#define R300_VPI_IN_Z_SHIFT 19
+#define R300_VPI_IN_W_SHIFT 22
+
+#define R300_VPI_IN_NEG_X (1 << 25)
+#define R300_VPI_IN_NEG_Y (1 << 26)
+#define R300_VPI_IN_NEG_Z (1 << 27)
+#define R300_VPI_IN_NEG_W (1 << 28)
+/* END */
+
+//BEGIN: Packet 3 commands
+
+// A primitive emission dword.
+#define R300_PRIM_TYPE_NONE (0 << 0)
+#define R300_PRIM_TYPE_POINT (1 << 0)
+#define R300_PRIM_TYPE_LINE (2 << 0)
+#define R300_PRIM_TYPE_LINE_STRIP (3 << 0)
+#define R300_PRIM_TYPE_TRI_LIST (4 << 0)
+#define R300_PRIM_TYPE_TRI_FAN (5 << 0)
+#define R300_PRIM_TYPE_TRI_STRIP (6 << 0)
+#define R300_PRIM_TYPE_TRI_TYPE2 (7 << 0)
+#define R300_PRIM_TYPE_RECT_LIST (8 << 0)
+#define R300_PRIM_TYPE_3VRT_POINT_LIST (9 << 0)
+#define R300_PRIM_TYPE_3VRT_LINE_LIST (10 << 0)
+#define R300_PRIM_TYPE_POINT_SPRITES (11 << 0) // GUESS (based on r200)
+#define R300_PRIM_TYPE_LINE_LOOP (12 << 0)
+#define R300_PRIM_TYPE_QUADS (13 << 0)
+#define R300_PRIM_TYPE_QUAD_STRIP (14 << 0)
+#define R300_PRIM_TYPE_POLYGON (15 << 0)
+#define R300_PRIM_TYPE_MASK 0xF
+#define R300_PRIM_WALK_IND (1 << 4)
+#define R300_PRIM_WALK_LIST (2 << 4)
+#define R300_PRIM_WALK_RING (3 << 4)
+#define R300_PRIM_WALK_MASK (3 << 4)
+#define R300_PRIM_COLOR_ORDER_BGRA (0 << 6) // GUESS (based on r200)
+#define R300_PRIM_COLOR_ORDER_RGBA (1 << 6) // GUESS
+#define R300_PRIM_NUM_VERTICES_SHIFT 16
+
+// Draw a primitive from vertex data in arrays loaded via 3D_LOAD_VBPNTR.
+// Two parameter dwords:
+// 0. The first parameter appears to be always 0
+// 1. The second parameter is a standard primitive emission dword.
+#define R300_PACKET3_3D_DRAW_VBUF 0x00002800
+
+// Specify the full set of vertex arrays as (address, stride).
+// The first parameter is the number of vertex arrays specified.
+// The rest of the command is a variable length list of blocks, where
+// each block is three dwords long and specifies two arrays.
+// The first dword of a block is split into two words, the lower significant
+// word refers to the first array, the more significant word to the second
+// array in the block.
+// The low byte of each word contains the size of an array entry in dwords,
+// the high byte contains the stride of the array.
+// The second dword of a block contains the pointer to the first array,
+// the third dword of a block contains the pointer to the second array.
+// Note that if the total number of arrays is odd, the third dword of
+// the last block is omitted.
+#define R300_PACKET3_3D_LOAD_VBPNTR 0x00002F00
+
+#define R300_PACKET3_INDX_BUFFER 0x00003300
+# define R300_EB_UNK1_SHIFT 24
+# define R300_EB_UNK1 (0x80<<24)
+# define R300_EB_UNK2 0x0810
+#define R300_PACKET3_3D_DRAW_INDX_2 0x00003600
+
+//END
+
+#endif /* _R300_REG_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_render.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_render.c
new file mode 100644
index 000000000..a0769e27f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_render.c
@@ -0,0 +1,726 @@
+/**************************************************************************
+
+Copyright (C) 2004 Nicolai Haehnle.
+
+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, VA LINUX SYSTEMS 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:
+ * Nicolai Haehnle <prefect_@gmx.net>
+ */
+
+#include "glheader.h"
+#include "state.h"
+#include "imports.h"
+#include "enums.h"
+#include "macros.h"
+#include "context.h"
+#include "dd.h"
+#include "simple_list.h"
+
+#include "api_arrayelt.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "tnl/t_vp_build.h"
+
+#include "radeon_reg.h"
+#include "radeon_macros.h"
+#include "radeon_ioctl.h"
+#include "radeon_state.h"
+#include "r300_context.h"
+#include "r300_ioctl.h"
+#include "r300_state.h"
+#include "r300_reg.h"
+#include "r300_program.h"
+#include "r300_tex.h"
+#include "r300_maos.h"
+#include "r300_emit.h"
+
+extern int future_hw_tcl_on;
+
+/**********************************************************************
+* Hardware rasterization
+*
+* When we fell back to software TCL, we still try to use the
+* rasterization hardware for rendering.
+**********************************************************************/
+
+static int r300_get_primitive_type(r300ContextPtr rmesa, GLcontext *ctx, int prim)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i;
+ int type=-1;
+
+ switch (prim & PRIM_MODE_MASK) {
+ case GL_POINTS:
+ type=R300_VAP_VF_CNTL__PRIM_POINTS;
+ break;
+ case GL_LINES:
+ type=R300_VAP_VF_CNTL__PRIM_LINES;
+ break;
+ case GL_LINE_STRIP:
+ type=R300_VAP_VF_CNTL__PRIM_LINE_STRIP;
+ break;
+ case GL_LINE_LOOP:
+ type=R300_VAP_VF_CNTL__PRIM_LINE_LOOP;
+ break;
+ case GL_TRIANGLES:
+ type=R300_VAP_VF_CNTL__PRIM_TRIANGLES;
+ break;
+ case GL_TRIANGLE_STRIP:
+ type=R300_VAP_VF_CNTL__PRIM_TRIANGLE_STRIP;
+ break;
+ case GL_TRIANGLE_FAN:
+ type=R300_VAP_VF_CNTL__PRIM_TRIANGLE_FAN;
+ break;
+ case GL_QUADS:
+ type=R300_VAP_VF_CNTL__PRIM_QUADS;
+ break;
+ case GL_QUAD_STRIP:
+ type=R300_VAP_VF_CNTL__PRIM_QUAD_STRIP;
+ break;
+ case GL_POLYGON:
+ type=R300_VAP_VF_CNTL__PRIM_POLYGON;
+ break;
+ default:
+ fprintf(stderr, "%s:%s Do not know how to handle primitive %02x - help me !\n",
+ __FILE__, __FUNCTION__,
+ prim & PRIM_MODE_MASK);
+ return -1;
+ break;
+ }
+ return type;
+}
+
+static int r300_get_num_verts(r300ContextPtr rmesa,
+ GLcontext *ctx,
+ int num_verts,
+ int prim)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i;
+ int type=-1, verts_off=0;
+ char *name="UNKNOWN";
+
+ switch (prim & PRIM_MODE_MASK) {
+ case GL_POINTS:
+ name="P";
+ verts_off = 0;
+ break;
+ case GL_LINES:
+ name="L";
+ verts_off = num_verts % 2;
+ break;
+ case GL_LINE_STRIP:
+ name="LS";
+ if(num_verts < 2)
+ verts_off = num_verts;
+ break;
+ case GL_LINE_LOOP:
+ name="LL";
+ if(num_verts < 2)
+ verts_off = num_verts;
+ break;
+ case GL_TRIANGLES:
+ name="T";
+ verts_off = num_verts % 3;
+ break;
+ case GL_TRIANGLE_STRIP:
+ name="TS";
+ if(num_verts < 3)
+ verts_off = num_verts;
+ break;
+ case GL_TRIANGLE_FAN:
+ name="TF";
+ if(num_verts < 3)
+ verts_off = num_verts;
+ break;
+ case GL_QUADS:
+ name="Q";
+ verts_off = num_verts % 4;
+ break;
+ case GL_QUAD_STRIP:
+ name="QS";
+ if(num_verts < 4)
+ verts_off = num_verts;
+ else
+ verts_off = num_verts % 2;
+ break;
+ case GL_POLYGON:
+ name="P";
+ if(num_verts < 3)
+ verts_off = num_verts;
+ break;
+ default:
+ fprintf(stderr, "%s:%s Do not know how to handle primitive %02x - help me !\n",
+ __FILE__, __FUNCTION__,
+ prim & PRIM_MODE_MASK);
+ return -1;
+ break;
+ }
+
+ if(num_verts - verts_off == 0){
+ WARN_ONCE("user error: Need more than %d vertices to draw primitive %s !\n", num_verts, name);
+ return 0;
+ }
+
+ if(verts_off > 0){
+ WARN_ONCE("user error: %d is not a valid number of vertices for primitive %s !\n", num_verts, name);
+ }
+
+ return num_verts - verts_off;
+}
+
+/* This function compiles GL context into state registers that
+ describe data routing inside of R300 pipeline.
+
+ In particular, it programs input_route, output_vtx_fmt, texture
+ unit configuration and gb_output_vtx_fmt
+
+ This function encompasses setup_AOS() from r300_lib.c
+*/
+
+
+
+
+/* Immediate implementation - vertex data is sent via command stream */
+
+static GLfloat default_vector[4]={0.0, 0.0, 0.0, 1.0};
+
+#define output_vector(v, i) { \
+ int _i; \
+ for(_i=0;_i<v->size;_i++){ \
+ if(VB->Elts){ \
+ efloat(VEC_ELT(v, GLfloat, VB->Elts[i])[_i]); \
+ }else{ \
+ efloat(VEC_ELT(v, GLfloat, i)[_i]); \
+ } \
+ } \
+ for(_i=v->size;_i<4;_i++){ \
+ efloat(default_vector[_i]); \
+ } \
+}
+
+/* Immediate implementation - vertex data is sent via command stream */
+
+static void r300_render_immediate_primitive(r300ContextPtr rmesa,
+ GLcontext *ctx,
+ int start,
+ int end,
+ int prim)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i, render_inputs;
+ int k, type, num_verts;
+ LOCAL_VARS
+
+ type=r300_get_primitive_type(rmesa, ctx, prim);
+ num_verts=r300_get_num_verts(rmesa, ctx, end-start, prim);
+
+#if 0
+ fprintf(stderr,"ObjPtr: size=%d stride=%d\n",
+ VB->ObjPtr->size, VB->ObjPtr->stride);
+ fprintf(stderr,"ColorPtr[0]: size=%d stride=%d\n",
+ VB->ColorPtr[0]->size, VB->ColorPtr[0]->stride);
+ fprintf(stderr,"TexCoordPtr[0]: size=%d stride=%d\n",
+ VB->TexCoordPtr[0]->size, VB->TexCoordPtr[0]->stride);
+#endif
+
+ if(type<0 || num_verts <= 0)return;
+
+ if(!VB->ObjPtr){
+ WARN_ONCE("FIXME: Don't know how to handle GL_ARB_vertex_buffer_object correctly\n");
+ return;
+ }
+ /* A packet cannot have more than 16383 data words.. */
+ if((num_verts*4*rmesa->state.aos_count)>16380){
+ WARN_ONCE("Too many vertices to paint. Fix me !\n");
+ return;
+ }
+
+ //fprintf(stderr, "aos_count=%d start=%d end=%d\n", rmesa->state.aos_count, start, end);
+
+ if(rmesa->state.aos_count==0){
+ WARN_ONCE("Aeiee ! aos_count==0, while it shouldn't. Skipping rendering\n");
+ return;
+ }
+
+ render_inputs = rmesa->state.render_inputs;
+
+ if(!render_inputs){
+ WARN_ONCE("Aeiee ! render_inputs==0. Skipping rendering.\n");
+ return;
+ }
+
+
+ start_immediate_packet(num_verts, type, 4*rmesa->state.aos_count);
+
+ for(i=start;i<start+num_verts;i++){
+#if 0
+ fprintf(stderr, "* (%f %f %f %f) (%f %f %f %f)\n",
+ VEC_ELT(VB->ObjPtr, GLfloat, i)[0],
+ VEC_ELT(VB->ObjPtr, GLfloat, i)[1],
+ VEC_ELT(VB->ObjPtr, GLfloat, i)[2],
+ VEC_ELT(VB->ObjPtr, GLfloat, i)[3],
+
+ VEC_ELT(VB->ColorPtr[0], GLfloat, i)[0],
+ VEC_ELT(VB->ColorPtr[0], GLfloat, i)[1],
+ VEC_ELT(VB->ColorPtr[0], GLfloat, i)[2],
+ VEC_ELT(VB->ColorPtr[0], GLfloat, i)[3]
+ );
+#endif
+
+
+ /* coordinates */
+ if(render_inputs & _TNL_BIT_POS)
+ output_vector(VB->ObjPtr, i);
+ if(render_inputs & _TNL_BIT_NORMAL)
+ output_vector(VB->NormalPtr, i);
+
+ /* color components */
+ if(render_inputs & _TNL_BIT_COLOR0)
+ output_vector(VB->ColorPtr[0], i);
+ if(render_inputs & _TNL_BIT_COLOR1)
+ output_vector(VB->SecondaryColorPtr[0], i);
+
+/* if(render_inputs & _TNL_BIT_FOG) // Causes lock ups when immediate mode is on
+ output_vector(VB->FogCoordPtr, i);*/
+
+ /* texture coordinates */
+ for(k=0;k < ctx->Const.MaxTextureUnits;k++)
+ if(render_inputs & (_TNL_BIT_TEX0<<k))
+ output_vector(VB->TexCoordPtr[k], i);
+
+ if(render_inputs & _TNL_BIT_INDEX)
+ output_vector(VB->IndexPtr[0], i);
+ if(render_inputs & _TNL_BIT_POINTSIZE)
+ output_vector(VB->PointSizePtr, i);
+ }
+
+}
+
+
+static GLboolean r300_run_immediate_render(GLcontext *ctx,
+ struct tnl_pipeline_stage *stage)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i;
+ /* Only do 2d textures */
+ struct gl_texture_object *to=ctx->Texture.Unit[0].Current2D;
+ r300TexObjPtr t=to->DriverData;
+ LOCAL_VARS
+
+
+ /* Update texture state - needs to be done only when actually changed..
+ All the time for now.. */
+
+
+ if (RADEON_DEBUG == DEBUG_PRIMS)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+#if 1 /* we need this, somehow */
+ /* Flush state - make sure command buffer is nice and large */
+ r300Flush(ctx);
+ /* Make sure we have enough space */
+#else
+ /* Count is very imprecize, but should be good upper bound */
+ r300EnsureCmdBufSpace(rmesa, rmesa->hw.max_state_size + 4+2+30
+ +VB->PrimitiveCount*(1+8)+VB->Count*4*rmesa->state.texture.tc_count+4, __FUNCTION__);
+#endif
+
+ /* needed before starting 3d operation .. */
+ reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
+ e32(0x0000000a);
+
+ reg_start(0x4f18,0);
+ e32(0x00000003);
+
+
+#if 0 /* looks like the Z offset issue got fixed */
+ rmesa->hw.vte.cmd[1] = R300_VPORT_X_SCALE_ENA
+ | R300_VPORT_X_OFFSET_ENA
+ | R300_VPORT_Y_SCALE_ENA
+ | R300_VPORT_Y_OFFSET_ENA
+ | R300_VTX_W0_FMT;
+ R300_STATECHANGE(rmesa, vte);
+#endif
+
+
+
+ /* Magic register - note it is right after 20b0 */
+
+
+ if(rmesa->state.texture.tc_count>0){
+ reg_start(0x20b4,0);
+ e32(0x0000000c);
+
+ }
+
+ r300EmitState(rmesa);
+
+/* Setup INPUT_ROUTE and INPUT_CNTL */
+ r300EmitArrays(ctx, GL_TRUE);
+
+/* Why do we need this for immediate mode?? Vertex processor needs it to know proper regs */
+// r300EmitLOAD_VBPNTR(rmesa, 0);
+/* Okay, it seems I misunderstood something, EmitAOS does the same thing */
+ r300EmitAOS(rmesa, rmesa->state.aos_count, 0);
+
+ for(i=0; i < VB->PrimitiveCount; i++){
+ GLuint prim = VB->Primitive[i].mode;
+ GLuint start = VB->Primitive[i].start;
+ GLuint length = VB->Primitive[i].count;
+
+ r300_render_immediate_primitive(rmesa, ctx, start, start + length, prim);
+ }
+
+ /* This sequence is required after any 3d drawing packet
+ I suspect it work arounds a bug (or deficiency) in hardware */
+
+ reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
+ e32(0x0000000a);
+
+ reg_start(0x4f18,0);
+ e32(0x00000003);
+
+ return GL_FALSE;
+}
+
+
+/* vertex buffer implementation */
+
+static void inline fire_EB(PREFIX unsigned long addr, int vertex_count, int type)
+{
+ LOCAL_VARS
+ unsigned long addr_a;
+
+ if(addr & 1){
+ WARN_ONCE("Badly aligned buffer\n");
+ return ;
+ }
+ addr_a = 0; /*addr & 0x1c;*/
+
+ check_space(6);
+
+ start_packet3(RADEON_CP_PACKET3_3D_DRAW_INDX_2, 0);
+ /* TODO: R300_VAP_VF_CNTL__INDEX_SIZE_32bit . */
+ e32(R300_VAP_VF_CNTL__PRIM_WALK_INDICES | (vertex_count<<16) | type);
+
+ start_packet3(RADEON_CP_PACKET3_INDX_BUFFER, 2);
+ e32(R300_EB_UNK1 | (addr_a << 16) | R300_EB_UNK2);
+ e32(addr /*& 0xffffffe3*/);
+ e32((vertex_count+1)/2 /*+ addr_a/4*/); /* Total number of dwords needed? */
+}
+
+static void r300_render_vb_primitive(r300ContextPtr rmesa,
+ GLcontext *ctx,
+ int start,
+ int end,
+ int prim)
+{
+ int type, num_verts;
+ radeonScreenPtr rsp=rmesa->radeon.radeonScreen;
+ LOCAL_VARS
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ int i;
+
+ type=r300_get_primitive_type(rmesa, ctx, prim);
+ num_verts=r300_get_num_verts(rmesa, ctx, end-start, prim);
+
+ if(type<0 || num_verts <= 0)return;
+
+ if(rmesa->state.Elts){
+ r300EmitAOS(rmesa, rmesa->state.aos_count, 0);
+#if 0
+ start_index32_packet(num_verts, type);
+ for(i=0; i < num_verts; i++)
+ e32(rmesa->state.Elts[start+i]); /* start ? */
+#else
+ WARN_ONCE("Rendering with elt buffers\n");
+ if(num_verts == 1){
+ start_index32_packet(num_verts, type);
+ e32(rmesa->state.Elts[start]);
+ return;
+ }
+
+ if(num_verts > 65535){ /* not implemented yet */
+ WARN_ONCE("Too many elts\n");
+ return;
+ }
+ r300EmitElts(ctx, rmesa->state.Elts+start, num_verts);
+ fire_EB(PASS_PREFIX GET_START(&(rmesa->state.elt_dma)), num_verts, type);
+#endif
+ }else{
+ r300EmitAOS(rmesa, rmesa->state.aos_count, start);
+ fire_AOS(PASS_PREFIX num_verts, type);
+ }
+}
+
+static GLboolean r300_run_vb_render(GLcontext *ctx,
+ struct tnl_pipeline_stage *stage)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ int i, j;
+ LOCAL_VARS
+
+ if (RADEON_DEBUG & DEBUG_PRIMS)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+
+ r300ReleaseArrays(ctx);
+ r300EmitArrays(ctx, GL_FALSE);
+
+// LOCK_HARDWARE(&(rmesa->radeon));
+
+ reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
+ e32(0x0000000a);
+
+ reg_start(0x4f18,0);
+ e32(0x00000003);
+ r300EmitState(rmesa);
+
+ rmesa->state.Elts = VB->Elts;
+
+ for(i=0; i < VB->PrimitiveCount; i++){
+ GLuint prim = VB->Primitive[i].mode;
+ GLuint start = VB->Primitive[i].start;
+ GLuint length = VB->Primitive[i].count;
+
+ r300_render_vb_primitive(rmesa, ctx, start, start + length, prim);
+ }
+
+ reg_start(R300_RB3D_DSTCACHE_CTLSTAT,0);
+ e32(0x0000000a);
+
+ reg_start(0x4f18,0);
+ e32(0x00000003);
+
+// end_3d(PASS_PREFIX_VOID);
+
+ /* Flush state - we are done drawing.. */
+// r300FlushCmdBufLocked(rmesa, __FUNCTION__);
+// radeonWaitForIdleLocked(&(rmesa->radeon));
+
+// UNLOCK_HARDWARE(&(rmesa->radeon));
+ return GL_FALSE;
+}
+
+/**
+ * Called by the pipeline manager to render a batch of primitives.
+ * We can return true to pass on to the next stage (i.e. software
+ * rasterization) or false to indicate that the pipeline has finished
+ * after we render something.
+ */
+static GLboolean r300_run_render(GLcontext *ctx,
+ struct tnl_pipeline_stage *stage)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i;
+
+ if (RADEON_DEBUG & DEBUG_PRIMS)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+
+#if 1
+
+#if 0
+ return r300_run_immediate_render(ctx, stage);
+#else
+ return r300_run_vb_render(ctx, stage);
+#endif
+#else
+ return GL_TRUE;
+#endif
+}
+
+
+/**
+ * Called by the pipeline manager once before rendering.
+ * We check the GL state here to
+ * a) decide whether we can do the current state in hardware and
+ * b) update hardware registers
+ */
+#define FALLBACK_IF(expr) \
+do { \
+ if (expr) { \
+ if (1 || RADEON_DEBUG & DEBUG_FALLBACKS) \
+ fprintf(stderr, "%s: fallback:%s\n", \
+ __FUNCTION__, #expr); \
+ /*stage->active = GL_FALSE*/; \
+ return; \
+ } \
+} while(0)
+
+static void r300_check_render(GLcontext *ctx, struct tnl_pipeline_stage *stage)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+ int i;
+
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ /* We only support rendering in hardware for now */
+ if (ctx->RenderMode != GL_RENDER) {
+ //stage->active = GL_FALSE;
+ return;
+ }
+
+
+ /* I'm almost certain I forgot something here */
+#if 0 /* These should work now.. */
+ FALLBACK_IF(ctx->Color.DitherFlag);
+ FALLBACK_IF(ctx->Color.AlphaEnabled); // GL_ALPHA_TEST
+ FALLBACK_IF(ctx->Color.BlendEnabled); // GL_BLEND
+ FALLBACK_IF(ctx->Polygon.OffsetFill); // GL_POLYGON_OFFSET_FILL
+#endif
+ //FALLBACK_IF(ctx->Polygon.OffsetPoint); // GL_POLYGON_OFFSET_POINT
+ //FALLBACK_IF(ctx->Polygon.OffsetLine); // GL_POLYGON_OFFSET_LINE
+ //FALLBACK_IF(ctx->Stencil.Enabled); // GL_STENCIL_TEST
+
+ //FALLBACK_IF(ctx->Fog.Enabled); // GL_FOG disable as swtcl doesnt seem to support this
+ //FALLBACK_IF(ctx->Polygon.SmoothFlag); // GL_POLYGON_SMOOTH disabling to get blender going
+ FALLBACK_IF(ctx->Polygon.StippleFlag); // GL_POLYGON_STIPPLE
+ FALLBACK_IF(ctx->Multisample.Enabled); // GL_MULTISAMPLE_ARB
+
+ FALLBACK_IF(ctx->RenderMode != GL_RENDER); // We do not do SELECT or FEEDBACK (yet ?)
+
+#if 0 /* ut2k3 fails to start if this is on */
+ /* One step at a time - let one texture pass.. */
+ for (i = 1; i < ctx->Const.MaxTextureUnits; i++)
+ FALLBACK_IF(ctx->Texture.Unit[i].Enabled);
+#endif
+
+ /* Assumed factor reg is found but pattern is still missing */
+ //FALLBACK_IF(ctx->Line.StippleFlag); // GL_LINE_STIPPLE disabling to get blender going
+
+ /* HW doesnt appear to directly support these */
+ //FALLBACK_IF(ctx->Line.SmoothFlag); // GL_LINE_SMOOTH disabling to get blender going
+ FALLBACK_IF(ctx->Point.SmoothFlag); // GL_POINT_SMOOTH
+ /* Rest could be done with vertex fragments */
+ if (ctx->Extensions.NV_point_sprite || ctx->Extensions.ARB_point_sprite)
+ FALLBACK_IF(ctx->Point.PointSprite); // GL_POINT_SPRITE_NV
+ //GL_POINT_DISTANCE_ATTENUATION_ARB
+ //GL_POINT_FADE_THRESHOLD_SIZE_ARB
+
+ /* let r300_run_render do its job */
+#if 0
+ stage->active = GL_FALSE;
+#endif
+}
+
+
+static void dtr(struct tnl_pipeline_stage *stage)
+{
+ (void)stage;
+}
+
+static GLboolean r300_create_render(GLcontext *ctx,
+ struct tnl_pipeline_stage *stage)
+{
+ return GL_TRUE;
+}
+
+
+const struct tnl_pipeline_stage _r300_render_stage = {
+ "r300 hw rasterize",
+ NULL,
+ r300_create_render,
+ dtr, /* destructor */
+ r300_check_render, /* check */
+ r300_run_render /* run */
+};
+
+static GLboolean r300_run_tcl_render(GLcontext *ctx,
+ struct tnl_pipeline_stage *stage)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i;
+ struct r300_vertex_program *vp;
+
+ hw_tcl_on=future_hw_tcl_on;
+
+ if (RADEON_DEBUG & DEBUG_PRIMS)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+ if(hw_tcl_on == GL_FALSE)
+ return GL_TRUE;
+ if(ctx->VertexProgram._Enabled == GL_FALSE){
+ _tnl_UpdateFixedFunctionProgram(ctx);
+ }
+ vp = (struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
+ if(vp->translated == GL_FALSE)
+ translate_vertex_shader(vp);
+ if(vp->translated == GL_FALSE){
+ fprintf(stderr, "Failing back to sw-tcl\n");
+ debug_vp(ctx, &vp->mesa_program);
+ hw_tcl_on=future_hw_tcl_on=0;
+ r300ResetHwState(rmesa);
+ return GL_TRUE;
+ }
+
+ r300_setup_textures(ctx);
+ r300_setup_rs_unit(ctx);
+
+ r300SetupVertexShader(rmesa);
+ r300SetupPixelShader(rmesa);
+
+ return r300_run_vb_render(ctx, stage);
+}
+
+static void r300_check_tcl_render(GLcontext *ctx, struct tnl_pipeline_stage *stage)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+ int i;
+
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ /* We only support rendering in hardware for now */
+ if (ctx->RenderMode != GL_RENDER) {
+ //stage->active = GL_FALSE;
+ return;
+ }
+}
+
+const struct tnl_pipeline_stage _r300_tcl_stage = {
+ "r300 tcl",
+ NULL,
+ r300_create_render,
+ dtr, /* destructor */
+ r300_check_tcl_render, /* check */
+ r300_run_tcl_render /* run */
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_shader.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_shader.c
new file mode 100644
index 000000000..9c6788ec3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_shader.c
@@ -0,0 +1,112 @@
+#include "glheader.h"
+#include "macros.h"
+#include "enums.h"
+
+#include "program.h"
+#include "r300_context.h"
+#include "nvvertprog.h"
+#if USE_ARB_F_P == 1
+#include "r300_fragprog.h"
+#endif
+
+static void r300BindProgram(GLcontext *ctx, GLenum target, struct program *prog)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ struct r300_vertex_program *vp=(void *)prog;
+
+ switch(target){
+ case GL_VERTEX_PROGRAM_ARB:
+#if USE_ARB_F_P == 1
+ case GL_FRAGMENT_PROGRAM_ARB:
+#endif
+ //rmesa->current_vp = vp;
+ break;
+ default:
+ WARN_ONCE("Target not supported yet!\n");
+ break;
+ }
+}
+
+static struct program *r300NewProgram(GLcontext *ctx, GLenum target, GLuint id)
+{
+ struct r300_vertex_program *vp;
+#if USE_ARB_F_P == 1
+ struct r300_fragment_program *fp;
+#else
+ struct fragment_program *fp;
+#endif
+ struct ati_fragment_shader *afs;
+
+ switch(target){
+ case GL_VERTEX_PROGRAM_ARB:
+ vp=CALLOC_STRUCT(r300_vertex_program);
+ return _mesa_init_vertex_program(ctx, &vp->mesa_program, target, id);
+
+ case GL_FRAGMENT_PROGRAM_ARB:
+#if USE_ARB_F_P == 1
+ fp=CALLOC_STRUCT(r300_fragment_program);
+ fp->ctx = ctx;
+ return _mesa_init_fragment_program(ctx, &fp->mesa_program, target, id);
+#else
+ fp=CALLOC_STRUCT(fragment_program);
+ return _mesa_init_fragment_program(ctx, fp, target, id);
+#endif
+ case GL_FRAGMENT_PROGRAM_NV:
+ fp=CALLOC_STRUCT(fragment_program);
+ return _mesa_init_fragment_program(ctx, fp, target, id);
+
+ case GL_FRAGMENT_SHADER_ATI:
+ afs=CALLOC_STRUCT(ati_fragment_shader);
+ return _mesa_init_ati_fragment_shader(ctx, afs, target, id);
+ }
+
+ return NULL;
+}
+
+
+static void r300DeleteProgram(GLcontext *ctx, struct program *prog)
+{
+ //r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ //struct r300_vertex_program *vp=(void *)prog;
+
+ _mesa_delete_program(ctx, prog);
+}
+
+static void r300ProgramStringNotify(GLcontext *ctx, GLenum target,
+ struct program *prog)
+{
+ struct r300_vertex_program *vp=(void *)prog;
+#if USE_ARB_F_P == 1
+ struct r300_fragment_program *fp=(void *)prog;
+#endif
+
+ switch(target) {
+ case GL_VERTEX_PROGRAM_ARB:
+ /*vp->translated=GL_FALSE;
+ translate_vertex_shader(vp);*/
+ //debug_vp(ctx, vp);
+ break;
+ case GL_FRAGMENT_PROGRAM_ARB:
+#if USE_ARB_F_P == 1
+ fp->translated = GL_FALSE;
+#endif
+ break;
+ }
+}
+
+static GLboolean r300IsProgramNative(GLcontext *ctx, GLenum target, struct program *prog)
+{
+ //struct r300_vertex_program *vp=(void *)prog;
+ //r300ContextPtr rmesa = R300_CONTEXT(ctx);
+
+ return 1;
+}
+
+void r300InitShaderFuncs(struct dd_function_table *functions)
+{
+ functions->NewProgram=r300NewProgram;
+ functions->BindProgram=r300BindProgram;
+ functions->DeleteProgram=r300DeleteProgram;
+ functions->ProgramStringNotify=r300ProgramStringNotify;
+ functions->IsProgramNative=r300IsProgramNative;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_state.c
new file mode 100644
index 000000000..b6a03a227
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_state.c
@@ -0,0 +1,2321 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002.
+Copyright (C) 2004 Nicolai Haehnle.
+All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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:
+ * Nicolai Haehnle <prefect_@gmx.net>
+ */
+
+#include "glheader.h"
+#include "state.h"
+#include "imports.h"
+#include "enums.h"
+#include "macros.h"
+#include "context.h"
+#include "dd.h"
+#include "simple_list.h"
+
+#include "api_arrayelt.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "texformat.h"
+
+#include "radeon_ioctl.h"
+#include "radeon_state.h"
+#include "r300_context.h"
+#include "r300_ioctl.h"
+#include "r300_state.h"
+#include "r300_reg.h"
+#include "r300_program.h"
+#include "r300_emit.h"
+#if USE_ARB_F_P == 1
+#include "r300_fragprog.h"
+#else
+#include "r300_fixed_pipelines.h"
+#include "r300_texprog.h"
+#endif
+#include "r300_tex.h"
+#include "r300_maos.h"
+
+static void r300AlphaFunc(GLcontext * ctx, GLenum func, GLfloat ref)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ int pp_misc = rmesa->hw.at.cmd[R300_AT_ALPHA_TEST];
+ GLubyte refByte;
+
+ CLAMPED_FLOAT_TO_UBYTE(refByte, ref);
+
+ R300_STATECHANGE(rmesa, at);
+
+ pp_misc &= ~(R300_ALPHA_TEST_OP_MASK | R300_REF_ALPHA_MASK);
+ pp_misc |= (refByte & R300_REF_ALPHA_MASK);
+
+ switch (func) {
+ case GL_NEVER:
+ pp_misc |= R300_ALPHA_TEST_FAIL;
+ break;
+ case GL_LESS:
+ pp_misc |= R300_ALPHA_TEST_LESS;
+ break;
+ case GL_EQUAL:
+ pp_misc |= R300_ALPHA_TEST_EQUAL;
+ break;
+ case GL_LEQUAL:
+ pp_misc |= R300_ALPHA_TEST_LEQUAL;
+ break;
+ case GL_GREATER:
+ pp_misc |= R300_ALPHA_TEST_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ pp_misc |= R300_ALPHA_TEST_NEQUAL;
+ break;
+ case GL_GEQUAL:
+ pp_misc |= R300_ALPHA_TEST_GEQUAL;
+ break;
+ case GL_ALWAYS:
+ pp_misc |= R300_ALPHA_TEST_PASS;
+ //pp_misc &= ~R300_ALPHA_TEST_ENABLE;
+ break;
+ }
+
+ rmesa->hw.at.cmd[R300_AT_ALPHA_TEST] = pp_misc;
+}
+
+static void r300BlendColor(GLcontext * ctx, const GLfloat cf[4])
+{
+ GLubyte color[4];
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+
+ R300_STATECHANGE(rmesa, unk4E10);
+
+ /* Ordering might be wrong */
+ CLAMPED_FLOAT_TO_UBYTE(color[0], cf[0]);
+ CLAMPED_FLOAT_TO_UBYTE(color[1], cf[1]);
+ CLAMPED_FLOAT_TO_UBYTE(color[2], cf[2]);
+ CLAMPED_FLOAT_TO_UBYTE(color[3], cf[3]);
+
+ rmesa->hw.unk4E10.cmd[1]=r300PackColor(4, color[0], color[1], color[2], color[3]);
+}
+
+/**
+ * Calculate the hardware blend factor setting. This same function is used
+ * for source and destination of both alpha and RGB.
+ *
+ * \returns
+ * The hardware register value for the specified blend factor. This value
+ * will need to be shifted into the correct position for either source or
+ * destination factor.
+ *
+ * \todo
+ * Since the two cases where source and destination are handled differently
+ * are essentially error cases, they should never happen. Determine if these
+ * cases can be removed.
+ */
+static int blend_factor(GLenum factor, GLboolean is_src)
+{
+ int func;
+
+ switch (factor) {
+ case GL_ZERO:
+ func = R200_BLEND_GL_ZERO;
+ break;
+ case GL_ONE:
+ func = R200_BLEND_GL_ONE;
+ break;
+ case GL_DST_COLOR:
+ func = R200_BLEND_GL_DST_COLOR;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ func = R200_BLEND_GL_ONE_MINUS_DST_COLOR;
+ break;
+ case GL_SRC_COLOR:
+ func = R200_BLEND_GL_SRC_COLOR;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ func = R200_BLEND_GL_ONE_MINUS_SRC_COLOR;
+ break;
+ case GL_SRC_ALPHA:
+ func = R200_BLEND_GL_SRC_ALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ func = R200_BLEND_GL_ONE_MINUS_SRC_ALPHA;
+ break;
+ case GL_DST_ALPHA:
+ func = R200_BLEND_GL_DST_ALPHA;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ func = R200_BLEND_GL_ONE_MINUS_DST_ALPHA;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ func =
+ (is_src) ? R200_BLEND_GL_SRC_ALPHA_SATURATE :
+ R200_BLEND_GL_ZERO;
+ break;
+ case GL_CONSTANT_COLOR:
+ func = R200_BLEND_GL_CONST_COLOR;
+ break;
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ func = R200_BLEND_GL_ONE_MINUS_CONST_COLOR;
+ break;
+ case GL_CONSTANT_ALPHA:
+ func = R200_BLEND_GL_CONST_ALPHA;
+ break;
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ func = R200_BLEND_GL_ONE_MINUS_CONST_ALPHA;
+ break;
+ default:
+ func = (is_src) ? R200_BLEND_GL_ONE : R200_BLEND_GL_ZERO;
+ }
+ return func;
+}
+
+/**
+ * Sets both the blend equation and the blend function.
+ * This is done in a single
+ * function because some blend equations (i.e., \c GL_MIN and \c GL_MAX)
+ * change the interpretation of the blend function.
+ * Also, make sure that blend function and blend equation are set to their default
+ * value if color blending is not enabled, since at least blend equations GL_MIN
+ * and GL_FUNC_REVERSE_SUBTRACT will cause wrong results otherwise for
+ * unknown reasons.
+ */
+
+/* helper function */
+static void r300_set_blend_cntl(r300ContextPtr r300, int func, int eqn, int cbits, int funcA, int eqnA)
+{
+ GLuint new_ablend, new_cblend;
+
+#if 0
+ fprintf(stderr, "eqnA=%08x funcA=%08x eqn=%08x func=%08x cbits=%08x\n", eqnA, funcA, eqn, func, cbits);
+#endif
+ new_ablend = eqnA | funcA;
+ new_cblend = eqn | func;
+
+ /* Some blend factor combinations don't seem to work when the
+ * BLEND_NO_SEPARATE bit is set.
+ *
+ * Especially problematic candidates are the ONE_MINUS_* flags,
+ * but I can't see a real pattern.
+ */
+#if 0
+ if (new_ablend == new_cblend) {
+ new_cblend |= R300_BLEND_NO_SEPARATE;
+ }
+#endif
+ new_cblend |= cbits;
+
+ if((new_ablend != r300->hw.bld.cmd[R300_BLD_ABLEND]) ||
+ (new_cblend != r300->hw.bld.cmd[R300_BLD_CBLEND])) {
+ R300_STATECHANGE(r300, bld);
+ r300->hw.bld.cmd[R300_BLD_ABLEND]=new_ablend;
+ r300->hw.bld.cmd[R300_BLD_CBLEND]=new_cblend;
+ }
+}
+
+
+static void r300_set_blend_state(GLcontext * ctx)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+ int func = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
+ (R200_BLEND_GL_ZERO << R200_DST_BLEND_SHIFT);
+ int eqn = R200_COMB_FCN_ADD_CLAMP;
+ int funcA = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
+ (R200_BLEND_GL_ZERO << R200_DST_BLEND_SHIFT);
+ int eqnA = R200_COMB_FCN_ADD_CLAMP;
+
+ if (ctx->Color._LogicOpEnabled || !ctx->Color.BlendEnabled) {
+ r300_set_blend_cntl(r300,
+ func, eqn, 0,
+ func, eqn);
+ return;
+ }
+
+ func = (blend_factor(ctx->Color.BlendSrcRGB, GL_TRUE) << R200_SRC_BLEND_SHIFT) |
+ (blend_factor(ctx->Color.BlendDstRGB, GL_FALSE) << R200_DST_BLEND_SHIFT);
+
+ switch (ctx->Color.BlendEquationRGB) {
+ case GL_FUNC_ADD:
+ eqn = R300_COMB_FCN_ADD_CLAMP;
+ break;
+
+ case GL_FUNC_SUBTRACT:
+ eqn = R300_COMB_FCN_SUB_CLAMP;
+ break;
+
+ case GL_FUNC_REVERSE_SUBTRACT:
+ eqn = R200_COMB_FCN_RSUB_CLAMP;
+ break;
+
+ case GL_MIN:
+ eqn = R200_COMB_FCN_MIN;
+ func = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
+ (R200_BLEND_GL_ONE << R200_DST_BLEND_SHIFT);
+ break;
+
+ case GL_MAX:
+ eqn = R200_COMB_FCN_MAX;
+ func = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
+ (R200_BLEND_GL_ONE << R200_DST_BLEND_SHIFT);
+ break;
+
+ default:
+ fprintf(stderr,
+ "[%s:%u] Invalid RGB blend equation (0x%04x).\n",
+ __func__, __LINE__, ctx->Color.BlendEquationRGB);
+ return;
+ }
+
+
+ funcA = (blend_factor(ctx->Color.BlendSrcA, GL_TRUE) << R200_SRC_BLEND_SHIFT) |
+ (blend_factor(ctx->Color.BlendDstA, GL_FALSE) << R200_DST_BLEND_SHIFT);
+
+ switch (ctx->Color.BlendEquationA) {
+ case GL_FUNC_ADD:
+ eqnA = R300_COMB_FCN_ADD_CLAMP;
+ break;
+
+ case GL_FUNC_SUBTRACT:
+ eqnA = R300_COMB_FCN_SUB_CLAMP;
+ break;
+
+ case GL_FUNC_REVERSE_SUBTRACT:
+ eqnA = R200_COMB_FCN_RSUB_CLAMP;
+ break;
+
+ case GL_MIN:
+ eqnA = R200_COMB_FCN_MIN;
+ funcA = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
+ (R200_BLEND_GL_ONE << R200_DST_BLEND_SHIFT);
+ break;
+
+ case GL_MAX:
+ eqnA = R200_COMB_FCN_MAX;
+ funcA = (R200_BLEND_GL_ONE << R200_SRC_BLEND_SHIFT) |
+ (R200_BLEND_GL_ONE << R200_DST_BLEND_SHIFT);
+ break;
+
+ default:
+ fprintf(stderr, "[%s:%u] Invalid A blend equation (0x%04x).\n",
+ __func__, __LINE__, ctx->Color.BlendEquationA);
+ return;
+ }
+
+ r300_set_blend_cntl(r300,
+ func, eqn, R300_BLEND_UNKNOWN | R300_BLEND_ENABLE,
+ funcA, eqnA);
+}
+
+static void r300BlendEquationSeparate(GLcontext * ctx,
+ GLenum modeRGB, GLenum modeA)
+{
+ r300_set_blend_state(ctx);
+}
+
+static void r300BlendFuncSeparate(GLcontext * ctx,
+ GLenum sfactorRGB, GLenum dfactorRGB,
+ GLenum sfactorA, GLenum dfactorA)
+{
+ r300_set_blend_state(ctx);
+}
+
+/**
+ * Update our tracked culling state based on Mesa's state.
+ */
+static void r300UpdateCulling(GLcontext* ctx)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+ uint32_t val = 0;
+
+ R300_STATECHANGE(r300, cul);
+ if (ctx->Polygon.CullFlag) {
+ if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
+ val = R300_CULL_FRONT|R300_CULL_BACK;
+ else if (ctx->Polygon.CullFaceMode == GL_FRONT)
+ val = R300_CULL_FRONT;
+ else
+ val = R300_CULL_BACK;
+
+ if (ctx->Polygon.FrontFace == GL_CW)
+ val |= R300_FRONT_FACE_CW;
+ else
+ val |= R300_FRONT_FACE_CCW;
+ }
+ r300->hw.cul.cmd[R300_CUL_CULL] = val;
+}
+
+static void update_early_z(GLcontext* ctx)
+{
+ /* updates register 0x4f14
+ if depth test is not enabled it should be 0x00000000
+ if depth is enabled and alpha not it should be 0x00000001
+ if depth and alpha is enabled it should be 0x00000000
+ */
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+
+ R300_STATECHANGE(r300, unk4F10);
+ if (ctx->Color.AlphaEnabled)
+ /* disable early Z */
+ r300->hw.unk4F10.cmd[2] = 0x00000000;
+ else {
+ if (ctx->Depth.Test)
+ /* enable early Z */
+ r300->hw.unk4F10.cmd[2] = 0x00000001;
+ else
+ /* disable early Z */
+ r300->hw.unk4F10.cmd[2] = 0x00000000;
+ }
+}
+
+/**
+ * Handle glEnable()/glDisable().
+ *
+ * \note Mesa already filters redundant calls to glEnable/glDisable.
+ */
+static void r300Enable(GLcontext* ctx, GLenum cap, GLboolean state)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+ uint32_t newval;
+
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s( %s = %s )\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(cap),
+ state ? "GL_TRUE" : "GL_FALSE");
+
+ switch (cap) {
+ /* Fast track this one...
+ */
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ break;
+
+ case GL_ALPHA_TEST:
+ R300_STATECHANGE(r300, at);
+ if (state) {
+ r300->hw.at.cmd[R300_AT_ALPHA_TEST] |=
+ R300_ALPHA_TEST_ENABLE;
+ } else {
+ r300->hw.at.cmd[R300_AT_ALPHA_TEST] &=
+ ~R300_ALPHA_TEST_ENABLE;
+ }
+ update_early_z(ctx);
+ break;
+
+ case GL_BLEND:
+ case GL_COLOR_LOGIC_OP:
+ r300_set_blend_state(ctx);
+ break;
+
+ case GL_DEPTH_TEST:
+ R300_STATECHANGE(r300, zs);
+
+ if (state) {
+ if (ctx->Depth.Mask)
+ newval = R300_RB3D_Z_TEST_AND_WRITE;
+ else
+ newval = R300_RB3D_Z_TEST;
+ } else
+ newval = R300_RB3D_Z_DISABLED_1;
+
+ r300->hw.zs.cmd[R300_ZS_CNTL_0] &= R300_RB3D_STENCIL_ENABLE;
+ r300->hw.zs.cmd[R300_ZS_CNTL_0] |= newval;
+ update_early_z(ctx);
+ break;
+
+ case GL_STENCIL_TEST:
+ WARN_ONCE("TODO - double side stencil !\n");
+ if (r300->state.stencil.hw_stencil) {
+ R300_STATECHANGE(r300, zs);
+ if (state) {
+ r300->hw.zs.cmd[R300_ZS_CNTL_0] |=
+ R300_RB3D_STENCIL_ENABLE;
+ } else {
+ r300->hw.zs.cmd[R300_ZS_CNTL_0] &=
+ ~R300_RB3D_STENCIL_ENABLE;
+ }
+ } else {
+#if R200_MERGED
+ FALLBACK(&r300->radeon, RADEON_FALLBACK_STENCIL, state);
+#endif
+ }
+ break;
+
+ case GL_CULL_FACE:
+ r300UpdateCulling(ctx);
+ break;
+
+ case GL_POLYGON_OFFSET_POINT:
+ case GL_POLYGON_OFFSET_LINE:
+ break;
+
+ case GL_POLYGON_OFFSET_FILL:
+ R300_STATECHANGE(r300, unk42B4);
+ if(state){
+ r300->hw.unk42B4.cmd[1] |= (3<<0);
+ } else {
+ r300->hw.unk42B4.cmd[1] &= ~(3<<0);
+ }
+ break;
+ default:
+ radeonEnable(ctx, cap, state);
+ return;
+ }
+}
+
+
+static void r300UpdatePolygonMode(GLcontext *ctx)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+ uint32_t hw_mode=0;
+
+ if (ctx->Polygon.FrontMode != GL_FILL ||
+ ctx->Polygon.BackMode != GL_FILL) {
+ GLenum f, b;
+
+ if (ctx->Polygon.FrontFace == GL_CCW) {
+ f = ctx->Polygon.FrontMode;
+ b = ctx->Polygon.BackMode;
+ } else {
+ f = ctx->Polygon.BackMode;
+ b = ctx->Polygon.FrontMode;
+ }
+
+ hw_mode |= R300_PM_ENABLED;
+
+ switch (f) {
+ case GL_LINE:
+ hw_mode |= R300_PM_FRONT_LINE;
+ break;
+ case GL_POINT: /* noop */
+ hw_mode |= R300_PM_FRONT_POINT;
+ break;
+ case GL_FILL:
+ hw_mode |= R300_PM_FRONT_FILL;
+ break;
+ }
+
+ switch (b) {
+ case GL_LINE:
+ hw_mode |= R300_PM_BACK_LINE;
+ break;
+ case GL_POINT: /* noop */
+ hw_mode |= R300_PM_BACK_POINT;
+ break;
+ case GL_FILL:
+ hw_mode |= R300_PM_BACK_FILL;
+ break;
+ }
+ }
+
+ if (r300->hw.unk4288.cmd[1] != hw_mode) {
+ R300_STATECHANGE(r300, unk4288);
+ r300->hw.unk4288.cmd[1] = hw_mode;
+ }
+}
+
+/**
+ * Change the culling mode.
+ *
+ * \note Mesa already filters redundant calls to this function.
+ */
+static void r300CullFace(GLcontext* ctx, GLenum mode)
+{
+ (void)mode;
+
+ r300UpdateCulling(ctx);
+}
+
+
+/**
+ * Change the polygon orientation.
+ *
+ * \note Mesa already filters redundant calls to this function.
+ */
+static void r300FrontFace(GLcontext* ctx, GLenum mode)
+{
+ (void)mode;
+
+ r300UpdateCulling(ctx);
+ r300UpdatePolygonMode(ctx);
+}
+
+
+/**
+ * Change the depth testing function.
+ *
+ * \note Mesa already filters redundant calls to this function.
+ */
+static void r300DepthFunc(GLcontext* ctx, GLenum func)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+
+ R300_STATECHANGE(r300, zs);
+
+ r300->hw.zs.cmd[R300_ZS_CNTL_1] &= ~(R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT);
+
+ switch(func) {
+ case GL_NEVER:
+ r300->hw.zs.cmd[R300_ZS_CNTL_1] |= R300_ZS_NEVER << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT;
+ break;
+ case GL_LESS:
+ r300->hw.zs.cmd[R300_ZS_CNTL_1] |= R300_ZS_LESS << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT;
+ break;
+ case GL_EQUAL:
+ r300->hw.zs.cmd[R300_ZS_CNTL_1] |= R300_ZS_EQUAL << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT;
+ break;
+ case GL_LEQUAL:
+ r300->hw.zs.cmd[R300_ZS_CNTL_1] |= R300_ZS_LEQUAL << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT;
+ break;
+ case GL_GREATER:
+ r300->hw.zs.cmd[R300_ZS_CNTL_1] |= R300_ZS_GREATER << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT;
+ break;
+ case GL_NOTEQUAL:
+ r300->hw.zs.cmd[R300_ZS_CNTL_1] |= R300_ZS_NOTEQUAL << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT;
+ break;
+ case GL_GEQUAL:
+ r300->hw.zs.cmd[R300_ZS_CNTL_1] |= R300_ZS_GEQUAL << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT;
+ break;
+ case GL_ALWAYS:
+ r300->hw.zs.cmd[R300_ZS_CNTL_1] |= R300_ZS_ALWAYS << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT;
+ break;
+ }
+}
+
+
+/**
+ * Enable/Disable depth writing.
+ *
+ * \note Mesa already filters redundant calls to this function.
+ */
+static void r300DepthMask(GLcontext* ctx, GLboolean mask)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+
+ if (!ctx->Depth.Test)
+ return;
+
+ R300_STATECHANGE(r300, zs);
+ r300->hw.zs.cmd[R300_ZS_CNTL_0] &= R300_RB3D_STENCIL_ENABLE;
+ r300->hw.zs.cmd[R300_ZS_CNTL_0] |= mask
+ ? R300_RB3D_Z_TEST_AND_WRITE : R300_RB3D_Z_TEST;
+}
+
+
+/**
+ * Handle glColorMask()
+ */
+static void r300ColorMask(GLcontext* ctx,
+ GLboolean r, GLboolean g, GLboolean b, GLboolean a)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+ int mask = (r ? R300_COLORMASK0_R : 0) |
+ (g ? R300_COLORMASK0_G : 0) |
+ (b ? R300_COLORMASK0_B : 0) |
+ (a ? R300_COLORMASK0_A : 0);
+
+ if (mask != r300->hw.cmk.cmd[R300_CMK_COLORMASK]) {
+ R300_STATECHANGE(r300, cmk);
+ r300->hw.cmk.cmd[R300_CMK_COLORMASK] = mask;
+ }
+}
+
+/* =============================================================
+ * Point state
+ */
+static void r300PointSize(GLcontext * ctx, GLfloat size)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+
+ size = ctx->Point._Size;
+
+ R300_STATECHANGE(r300, ps);
+ r300->hw.ps.cmd[R300_PS_POINTSIZE] =
+ ((int)(size * 6) << R300_POINTSIZE_X_SHIFT) |
+ ((int)(size * 6) << R300_POINTSIZE_Y_SHIFT);
+}
+
+/* =============================================================
+ * Line state
+ */
+static void r300LineWidth(GLcontext *ctx, GLfloat widthf)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+
+ widthf = ctx->Line._Width;
+
+ R300_STATECHANGE(r300, lcntl);
+ r300->hw.lcntl.cmd[1] = (int)(widthf * 6.0);
+ r300->hw.lcntl.cmd[1] |= R300_LINE_CNT_VE;
+}
+
+static void r300PolygonMode(GLcontext *ctx, GLenum face, GLenum mode)
+{
+ (void)face;
+ (void)mode;
+
+ r300UpdatePolygonMode(ctx);
+}
+
+/* =============================================================
+ * Stencil
+ */
+
+static int translate_stencil_func(int func)
+{
+ switch (func) {
+ case GL_NEVER:
+ return R300_ZS_NEVER;
+ case GL_LESS:
+ return R300_ZS_LESS;
+ case GL_EQUAL:
+ return R300_ZS_EQUAL;
+ case GL_LEQUAL:
+ return R300_ZS_LEQUAL;
+ case GL_GREATER:
+ return R300_ZS_GREATER;
+ case GL_NOTEQUAL:
+ return R300_ZS_NOTEQUAL;
+ case GL_GEQUAL:
+ return R300_ZS_GEQUAL;
+ case GL_ALWAYS:
+ return R300_ZS_ALWAYS;
+ }
+ return 0;
+}
+
+static int translate_stencil_op(int op)
+{
+ switch (op) {
+ case GL_KEEP:
+ return R300_ZS_KEEP;
+ case GL_ZERO:
+ return R300_ZS_ZERO;
+ case GL_REPLACE:
+ return R300_ZS_REPLACE;
+ case GL_INCR:
+ return R300_ZS_INCR;
+ case GL_DECR:
+ return R300_ZS_DECR;
+ case GL_INCR_WRAP_EXT:
+ return R300_ZS_INCR_WRAP;
+ case GL_DECR_WRAP_EXT:
+ return R300_ZS_DECR_WRAP;
+ case GL_INVERT:
+ return R300_ZS_INVERT;
+ default:
+ WARN_ONCE("Do not know how to translate stencil op");
+ return R300_ZS_KEEP;
+ }
+ return 0;
+}
+
+static void r300ShadeModel(GLcontext * ctx, GLenum mode)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+
+ R300_STATECHANGE(rmesa, unk4274);
+ switch (mode) {
+ case GL_FLAT:
+ rmesa->hw.unk4274.cmd[2] = R300_RE_SHADE_MODEL_FLAT;
+ break;
+ case GL_SMOOTH:
+ rmesa->hw.unk4274.cmd[2] = R300_RE_SHADE_MODEL_SMOOTH;
+ break;
+ default:
+ return;
+ }
+}
+
+static void r300StencilFunc(GLcontext * ctx, GLenum func,
+ GLint ref, GLuint mask)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ GLuint refmask = ((ctx->Stencil.Ref[0] << R300_RB3D_ZS2_STENCIL_REF_SHIFT) |
+ (ctx->Stencil.ValueMask[0] << R300_RB3D_ZS2_STENCIL_MASK_SHIFT));
+
+ GLuint flag;
+
+ R300_STATECHANGE(rmesa, zs);
+
+ rmesa->hw.zs.cmd[R300_ZS_CNTL_1] &= ~(
+ (R300_ZS_MASK << R300_RB3D_ZS1_FRONT_FUNC_SHIFT)
+ | (R300_ZS_MASK << R300_RB3D_ZS1_BACK_FUNC_SHIFT));
+
+ rmesa->hw.zs.cmd[R300_ZS_CNTL_2] &= ~((R300_RB3D_ZS2_STENCIL_MASK << R300_RB3D_ZS2_STENCIL_REF_SHIFT) |
+ (R300_RB3D_ZS2_STENCIL_MASK << R300_RB3D_ZS2_STENCIL_MASK_SHIFT));
+
+ flag = translate_stencil_func(ctx->Stencil.Function[0]);
+
+ rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |= (flag << R300_RB3D_ZS1_FRONT_FUNC_SHIFT)
+ | (flag << R300_RB3D_ZS1_BACK_FUNC_SHIFT);
+ rmesa->hw.zs.cmd[R300_ZS_CNTL_2] |= refmask;
+}
+
+static void r300StencilMask(GLcontext * ctx, GLuint mask)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+
+ R300_STATECHANGE(rmesa, zs);
+ rmesa->hw.zs.cmd[R300_ZS_CNTL_2] &= ~(R300_RB3D_ZS2_STENCIL_MASK << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT);
+ rmesa->hw.zs.cmd[R300_ZS_CNTL_2] |= ctx->Stencil.WriteMask[0] << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT;
+}
+
+
+static void r300StencilOp(GLcontext * ctx, GLenum fail,
+ GLenum zfail, GLenum zpass)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+
+ R300_STATECHANGE(rmesa, zs);
+ /* It is easier to mask what's left.. */
+ rmesa->hw.zs.cmd[R300_ZS_CNTL_1] &=
+ (R300_ZS_MASK << R300_RB3D_ZS1_DEPTH_FUNC_SHIFT) |
+ (R300_ZS_MASK << R300_RB3D_ZS1_FRONT_FUNC_SHIFT) |
+ (R300_ZS_MASK << R300_RB3D_ZS1_BACK_FUNC_SHIFT);
+
+ rmesa->hw.zs.cmd[R300_ZS_CNTL_1] |=
+ (translate_stencil_op(ctx->Stencil.FailFunc[0]) << R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT)
+ |(translate_stencil_op(ctx->Stencil.ZFailFunc[0]) << R300_RB3D_ZS1_FRONT_ZFAIL_OP_SHIFT)
+ |(translate_stencil_op(ctx->Stencil.ZPassFunc[0]) << R300_RB3D_ZS1_FRONT_ZPASS_OP_SHIFT)
+ |(translate_stencil_op(ctx->Stencil.FailFunc[0]) << R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT)
+ |(translate_stencil_op(ctx->Stencil.ZFailFunc[0]) << R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT)
+ |(translate_stencil_op(ctx->Stencil.ZPassFunc[0]) << R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT);
+}
+
+static void r300ClearStencil(GLcontext * ctx, GLint s)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+
+ rmesa->state.stencil.clear =
+ ((GLuint) ctx->Stencil.Clear |
+ (R300_RB3D_ZS2_STENCIL_MASK << R300_RB3D_ZS2_STENCIL_MASK_SHIFT) |
+ (ctx->Stencil.WriteMask[0] << R300_RB3D_ZS2_STENCIL_WRITE_MASK_SHIFT));
+}
+
+/* =============================================================
+ * Window position and viewport transformation
+ */
+
+/*
+ * To correctly position primitives:
+ */
+#define SUBPIXEL_X 0.125
+#define SUBPIXEL_Y 0.125
+
+static void r300UpdateWindow(GLcontext * ctx)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = rmesa->radeon.dri.drawable;
+ GLfloat xoffset = dPriv ? (GLfloat) dPriv->x : 0;
+ GLfloat yoffset = dPriv ? (GLfloat) dPriv->y + dPriv->h : 0;
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+
+ GLfloat sx = v[MAT_SX];
+ GLfloat tx = v[MAT_TX] + xoffset + SUBPIXEL_X;
+ GLfloat sy = -v[MAT_SY];
+ GLfloat ty = (-v[MAT_TY]) + yoffset + SUBPIXEL_Y;
+ GLfloat sz = v[MAT_SZ] * rmesa->state.depth.scale;
+ GLfloat tz = v[MAT_TZ] * rmesa->state.depth.scale;
+
+ R300_FIREVERTICES(rmesa);
+ R300_STATECHANGE(rmesa, vpt);
+
+ rmesa->hw.vpt.cmd[R300_VPT_XSCALE] = r300PackFloat32(sx);
+ rmesa->hw.vpt.cmd[R300_VPT_XOFFSET] = r300PackFloat32(tx);
+ rmesa->hw.vpt.cmd[R300_VPT_YSCALE] = r300PackFloat32(sy);
+ rmesa->hw.vpt.cmd[R300_VPT_YOFFSET] = r300PackFloat32(ty);
+ rmesa->hw.vpt.cmd[R300_VPT_ZSCALE] = r300PackFloat32(sz);
+ rmesa->hw.vpt.cmd[R300_VPT_ZOFFSET] = r300PackFloat32(tz);
+}
+
+static void r300Viewport(GLcontext * ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height)
+{
+ /* Don't pipeline viewport changes, conflict with window offset
+ * setting below. Could apply deltas to rescue pipelined viewport
+ * values, or keep the originals hanging around.
+ */
+ R300_FIREVERTICES(R300_CONTEXT(ctx));
+ r300UpdateWindow(ctx);
+}
+
+static void r300DepthRange(GLcontext * ctx, GLclampd nearval, GLclampd farval)
+{
+ r300UpdateWindow(ctx);
+}
+
+/* =============================================================
+ * Polygon state
+ */
+static void r300PolygonOffset(GLcontext * ctx, GLfloat factor, GLfloat units)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ GLfloat constant = units;
+
+ switch (ctx->Visual.depthBits) {
+ case 16:
+ constant *= 4.0;
+ break;
+ case 24:
+ constant *= 2.0;
+ break;
+ }
+
+ factor *= 12.0;
+
+/* fprintf(stderr, "%s f:%f u:%f\n", __FUNCTION__, factor, constant); */
+
+ R300_STATECHANGE(rmesa, zbs);
+ rmesa->hw.zbs.cmd[R300_ZBS_T_FACTOR] = r300PackFloat32(factor);
+ rmesa->hw.zbs.cmd[R300_ZBS_T_CONSTANT] = r300PackFloat32(constant);
+ rmesa->hw.zbs.cmd[R300_ZBS_W_FACTOR] = r300PackFloat32(factor);
+ rmesa->hw.zbs.cmd[R300_ZBS_W_CONSTANT] = r300PackFloat32(constant);
+}
+
+/* Routing and texture-related */
+
+static r300TexObj default_tex_obj={
+ filter:R300_TX_MAG_FILTER_LINEAR | R300_TX_MIN_FILTER_LINEAR,
+ pitch: 0x8000,
+ size: (0xff << R300_TX_WIDTHMASK_SHIFT)
+ | (0xff << R300_TX_HEIGHTMASK_SHIFT)
+ | (0x8 << R300_TX_SIZE_SHIFT),
+ format: 0x88a0c,
+ offset: 0x0,
+ unknown4: 0x0,
+ unknown5: 0x0
+ };
+
+ /* there is probably a system to these value, but, for now,
+ we just try by hand */
+
+static int inline translate_src(int src)
+{
+ switch (src) {
+ case GL_TEXTURE:
+ return 1;
+ break;
+ case GL_CONSTANT:
+ return 2;
+ break;
+ case GL_PRIMARY_COLOR:
+ return 3;
+ break;
+ case GL_PREVIOUS:
+ return 4;
+ break;
+ case GL_ZERO:
+ return 5;
+ break;
+ case GL_ONE:
+ return 6;
+ break;
+ default:
+ return 0;
+ }
+}
+
+/* r300 doesnt handle GL_CLAMP and GL_MIRROR_CLAMP_EXT correctly when filter is NEAREST.
+ * Since texwrap produces same results for GL_CLAMP and GL_CLAMP_TO_EDGE we use them instead.
+ * We need to recalculate wrap modes whenever filter mode is changed because someone might do:
+ * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+ * glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ * Since r300 completely ignores R300_TX_CLAMP when either min or mag is nearest it cant handle
+ * combinations where only one of them is nearest.
+ */
+static unsigned long gen_fixed_filter(unsigned long f)
+{
+ unsigned long mag, min, needs_fixing=0;
+ //return f;
+
+ /* We ignore MIRROR bit so we dont have to do everything twice */
+ if((f & ((7-1) << R300_TX_WRAP_S_SHIFT)) == (R300_TX_CLAMP << R300_TX_WRAP_S_SHIFT)){
+ needs_fixing |= 1;
+ }
+ if((f & ((7-1) << R300_TX_WRAP_T_SHIFT)) == (R300_TX_CLAMP << R300_TX_WRAP_T_SHIFT)){
+ needs_fixing |= 2;
+ }
+ if((f & ((7-1) << R300_TX_WRAP_Q_SHIFT)) == (R300_TX_CLAMP << R300_TX_WRAP_Q_SHIFT)){
+ needs_fixing |= 4;
+ }
+
+ if(!needs_fixing)
+ return f;
+
+ mag=f & R300_TX_MAG_FILTER_MASK;
+ min=f & R300_TX_MIN_FILTER_MASK;
+
+ /* TODO: Check for anisto filters too */
+ if((mag != R300_TX_MAG_FILTER_NEAREST) && (min != R300_TX_MIN_FILTER_NEAREST))
+ return f;
+
+ /* r300 cant handle these modes hence we force nearest to linear */
+ if((mag == R300_TX_MAG_FILTER_NEAREST) && (min != R300_TX_MIN_FILTER_NEAREST)){
+ f &= ~R300_TX_MAG_FILTER_NEAREST;
+ f |= R300_TX_MAG_FILTER_LINEAR;
+ return f;
+ }
+
+ if((min == R300_TX_MIN_FILTER_NEAREST) && (mag != R300_TX_MAG_FILTER_NEAREST)){
+ f &= ~R300_TX_MIN_FILTER_NEAREST;
+ f |= R300_TX_MIN_FILTER_LINEAR;
+ return f;
+ }
+
+ /* Both are nearest */
+ if(needs_fixing & 1){
+ f &= ~((7-1) << R300_TX_WRAP_S_SHIFT);
+ f |= R300_TX_CLAMP_TO_EDGE << R300_TX_WRAP_S_SHIFT;
+ }
+ if(needs_fixing & 2){
+ f &= ~((7-1) << R300_TX_WRAP_T_SHIFT);
+ f |= R300_TX_CLAMP_TO_EDGE << R300_TX_WRAP_T_SHIFT;
+ }
+ if(needs_fixing & 4){
+ f &= ~((7-1) << R300_TX_WRAP_Q_SHIFT);
+ f |= R300_TX_CLAMP_TO_EDGE << R300_TX_WRAP_Q_SHIFT;
+ }
+ return f;
+}
+
+void r300_setup_textures(GLcontext *ctx)
+{
+ int i, mtu;
+ struct r300_tex_obj *t;
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+ int max_texture_unit=-1; /* -1 translates into no setup costs for fields */
+ struct gl_texture_unit *texUnit;
+ GLuint OutputsWritten;
+
+ if(hw_tcl_on)
+ OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten;
+
+ R300_STATECHANGE(r300, txe);
+ R300_STATECHANGE(r300, tex.filter);
+ R300_STATECHANGE(r300, tex.unknown1);
+ R300_STATECHANGE(r300, tex.size);
+ R300_STATECHANGE(r300, tex.format);
+ R300_STATECHANGE(r300, tex.offset);
+ R300_STATECHANGE(r300, tex.unknown4);
+ R300_STATECHANGE(r300, tex.border_color);
+
+ r300->hw.txe.cmd[R300_TXE_ENABLE]=0x0;
+
+ mtu = r300->radeon.glCtx->Const.MaxTextureUnits;
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "mtu=%d\n", mtu);
+
+ if(mtu > R300_MAX_TEXTURE_UNITS) {
+ fprintf(stderr, "Aiiee ! mtu=%d is greater than R300_MAX_TEXTURE_UNITS=%d\n",
+ mtu, R300_MAX_TEXTURE_UNITS);
+ exit(-1);
+ }
+
+ for(i=0; i < mtu; i++) {
+ /*if( ((r300->state.render_inputs & (_TNL_BIT_TEX0<<i))!=0) != ((ctx->Texture.Unit[i].Enabled)!=0) ) {
+ WARN_ONCE("Mismatch between render_inputs and ctx->Texture.Unit[i].Enabled value(%d vs %d).\n",
+ ((r300->state.render_inputs & (_TNL_BIT_TEX0<<i))!=0), ((ctx->Texture.Unit[i].Enabled)!=0));
+ }*/
+
+ if(TMU_ENABLED(ctx, i)) {
+ t=r300->state.texture.unit[i].texobj;
+ //fprintf(stderr, "format=%08x\n", r300->state.texture.unit[i].format);
+
+ if(t == NULL){
+ fprintf(stderr, "Texture unit %d enabled, but corresponding texobj is NULL, using default object.\n", i);
+ //exit(-1);
+ t=&default_tex_obj;
+ }
+
+ //fprintf(stderr, "t->format=%08x\n", t->format);
+ if((t->format & 0xffffff00)==0xffffff00) {
+ WARN_ONCE("unknown texture format (entry %x) encountered. Help me !\n", t->format & 0xff);
+ //fprintf(stderr, "t->format=%08x\n", t->format);
+ }
+
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "Activating texture unit %d\n", i);
+ max_texture_unit=i;
+ r300->hw.txe.cmd[R300_TXE_ENABLE]|=(1<<i);
+
+ r300->hw.tex.filter.cmd[R300_TEX_VALUE_0+i]=gen_fixed_filter(t->filter) | (i << 28);
+ //r300->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+i]=0x0; /* move lod bias here? */
+
+ /* No idea why linear filtered textures shake when puting random data */
+ /*r300->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+i]=(rand()%0xffffffff) & (~0x1fff);*/
+ r300->hw.tex.size.cmd[R300_TEX_VALUE_0+i]=t->size;
+ r300->hw.tex.format.cmd[R300_TEX_VALUE_0+i]=t->format;
+ //fprintf(stderr, "t->format=%08x\n", t->format);
+ r300->hw.tex.offset.cmd[R300_TEX_VALUE_0+i]=t->offset;
+ r300->hw.tex.unknown4.cmd[R300_TEX_VALUE_0+i]=0x0;
+ r300->hw.tex.border_color.cmd[R300_TEX_VALUE_0+i]=t->pp_border_color;
+ }
+ }
+
+ ((drm_r300_cmd_header_t*)r300->hw.tex.filter.cmd)->packet0.count = max_texture_unit+1;
+ ((drm_r300_cmd_header_t*)r300->hw.tex.unknown1.cmd)->packet0.count = max_texture_unit+1;
+ ((drm_r300_cmd_header_t*)r300->hw.tex.size.cmd)->packet0.count = max_texture_unit+1;
+ ((drm_r300_cmd_header_t*)r300->hw.tex.format.cmd)->packet0.count = max_texture_unit+1;
+ ((drm_r300_cmd_header_t*)r300->hw.tex.offset.cmd)->packet0.count = max_texture_unit+1;
+ ((drm_r300_cmd_header_t*)r300->hw.tex.unknown4.cmd)->packet0.count = max_texture_unit+1;
+ ((drm_r300_cmd_header_t*)r300->hw.tex.border_color.cmd)->packet0.count = max_texture_unit+1;
+
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "TX_ENABLE: %08x max_texture_unit=%d\n", r300->hw.txe.cmd[R300_TXE_ENABLE], max_texture_unit);
+}
+
+#if USE_ARB_F_P == 1
+void r300_setup_rs_unit(GLcontext *ctx)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+ /* I'm still unsure if these are needed */
+ GLuint interp_magic[8] = {
+ 0x00,
+ 0x40,
+ 0x80,
+ 0xC0,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00
+ };
+ GLuint OutputsWritten;
+ GLuint InputsRead;
+ int vp_reg, fp_reg, high_rr;
+ int in_texcoords, col_interp_nr;
+ int i;
+
+ if(hw_tcl_on)
+ OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten;
+ else
+ OutputsWritten = r300->state.render_inputs;
+
+ if (ctx->FragmentProgram._Current)
+ InputsRead = ctx->FragmentProgram._Current->InputsRead;
+ else {
+ fprintf(stderr, "No ctx->FragmentProgram._Current!!\n");
+ return; /* This should only ever happen once.. */
+ }
+
+ R300_STATECHANGE(r300, ri);
+ R300_STATECHANGE(r300, rc);
+ R300_STATECHANGE(r300, rr);
+
+ vp_reg = fp_reg = in_texcoords = col_interp_nr = high_rr = 0;
+ r300->hw.rr.cmd[R300_RR_ROUTE_0] = 0;
+ r300->hw.rr.cmd[R300_RR_ROUTE_1] = 0;
+
+ for (i=0;i<ctx->Const.MaxTextureUnits;i++) {
+ if (OutputsWritten & (hw_tcl_on ? (1 << (VERT_RESULT_TEX0+i)) : (_TNL_BIT_TEX0<<i)))
+ in_texcoords++;
+
+ r300->hw.ri.cmd[R300_RI_INTERP_0+i] = 0
+ | R300_RS_INTERP_USED
+ | (vp_reg << R300_RS_INTERP_SRC_SHIFT)
+ | interp_magic[i];
+
+ if (InputsRead & (FRAG_BIT_TEX0<<i)) {
+ //assert(r300->state.texture.tc_count != 0);
+ r300->hw.rr.cmd[R300_RR_ROUTE_0 + fp_reg] = 0
+ | R300_RS_ROUTE_ENABLE
+ | i /* source INTERP */
+ | (fp_reg << R300_RS_ROUTE_DEST_SHIFT);
+ high_rr = fp_reg;
+
+ if (OutputsWritten & (hw_tcl_on ? (1 << (VERT_RESULT_TEX0+i)) : (_TNL_BIT_TEX0<<i))) {
+ vp_reg++;
+ } else {
+ /* Unsure of how to handle this situation, for now print errors and
+ * the program will just recieve bogus data
+ */
+ fprintf(stderr, "fragprog wants coords for tex%d, vp doesn't provide them!\n", i);
+ }
+ InputsRead &= ~(FRAG_BIT_TEX0<<i);
+ fp_reg++;
+ }
+ }
+
+ if (InputsRead & FRAG_BIT_COL0) {
+ if (!(OutputsWritten & (hw_tcl_on ? (1<<VERT_RESULT_COL0) : _TNL_BIT_COLOR0)))
+ fprintf(stderr, "fragprog wants col0, vp doesn't provide it\n");
+
+ r300->hw.rr.cmd[R300_RR_ROUTE_0] |= 0
+ | R300_RS_ROUTE_0_COLOR
+ | (fp_reg++ << R300_RS_ROUTE_0_COLOR_DEST_SHIFT);
+ InputsRead &= ~FRAG_BIT_COL0;
+ col_interp_nr++;
+ }
+
+ if (InputsRead & FRAG_BIT_COL1) {
+ if (!(OutputsWritten & (hw_tcl_on ? (1<<VERT_RESULT_COL1) : _TNL_BIT_COLOR1)))
+ fprintf(stderr, "fragprog wants col1, vp doesn't provide it\n");
+
+ r300->hw.rr.cmd[R300_RR_ROUTE_1] |= R300_RS_ROUTE_1_UNKNOWN11
+ | R300_RS_ROUTE_1_COLOR1
+ | (fp_reg++ << R300_RS_ROUTE_1_COLOR1_DEST_SHIFT);
+ InputsRead &= ~FRAG_BIT_COL1;
+ if (high_rr < 1) high_rr = 1;
+ col_interp_nr++;
+ }
+
+ r300->hw.rc.cmd[1] = 0
+ | (in_texcoords << R300_RS_CNTL_TC_CNT_SHIFT)
+ | (col_interp_nr << R300_RS_CNTL_CI_CNT_SHIFT)
+ | R300_RS_CNTL_0_UNKNOWN_18;
+
+ assert(high_rr >= 0);
+ r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R300_RS_ROUTE_0, high_rr+1);
+ r300->hw.rc.cmd[2] = 0xC0 | high_rr;
+
+ if (InputsRead)
+ WARN_ONCE("Don't know how to satisfy InputsRead=0x%08x\n", InputsRead);
+}
+#else
+void r300_setup_rs_unit(GLcontext *ctx)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+ int i, cur_reg;
+ /* I'm still unsure if these are needed */
+ GLuint interp_magic[8] = {
+ 0x00,
+ 0x40,
+ 0x80,
+ 0xC0,
+ 0x00,
+ 0x00,
+ 0x00,
+ 0x00
+ };
+ GLuint OutputsWritten;
+
+ if(hw_tcl_on)
+ OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten;
+
+ /* This needs to be rewritten - it is a hack at best */
+
+ R300_STATECHANGE(r300, ri);
+ R300_STATECHANGE(r300, rc);
+ R300_STATECHANGE(r300, rr);
+
+ cur_reg = 0;
+ r300->hw.rr.cmd[R300_RR_ROUTE_0] = 0;
+
+ for (i=0;i<ctx->Const.MaxTextureUnits;i++) {
+ r300->hw.ri.cmd[R300_RI_INTERP_0+i] = 0
+ | R300_RS_INTERP_USED
+ | (cur_reg << R300_RS_INTERP_SRC_SHIFT)
+ | interp_magic[i];
+// fprintf(stderr, "RS_INTERP[%d] = 0x%x\n", i, r300->hw.ri.cmd[R300_RI_INTERP_0+i]);
+
+ if (TMU_ENABLED(ctx, i)) {
+ assert(r300->state.texture.tc_count != 0);
+ r300->hw.rr.cmd[R300_RR_ROUTE_0 + cur_reg] = 0
+ | R300_RS_ROUTE_ENABLE
+ | i /* source INTERP */
+ | (cur_reg << R300_RS_ROUTE_DEST_SHIFT);
+// fprintf(stderr, "RS_ROUTE[%d] = 0x%x\n", cur_reg, r300->hw.rr.cmd[R300_RR_ROUTE_0 + cur_reg]);
+ cur_reg++;
+ }
+ }
+ if (hw_tcl_on ? OutputsWritten & (1<<VERT_RESULT_COL0) : r300->state.render_inputs & _TNL_BIT_COLOR0)
+ r300->hw.rr.cmd[R300_RR_ROUTE_0] |= 0
+ | R300_RS_ROUTE_0_COLOR
+ | (cur_reg << R300_RS_ROUTE_0_COLOR_DEST_SHIFT);
+
+// fprintf(stderr, "ADJ_RR0 = 0x%x\n", r300->hw.rr.cmd[R300_RR_ROUTE_0]);
+
+ r300->hw.rc.cmd[1] = 0
+ | (cur_reg /* count */ << R300_RS_CNTL_TC_CNT_SHIFT)
+ | R300_RS_CNTL_0_UNKNOWN_7
+ | R300_RS_CNTL_0_UNKNOWN_18;
+
+ if (r300->state.texture.tc_count > 0) {
+ r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R300_RS_ROUTE_0, cur_reg);
+ r300->hw.rc.cmd[2] = 0xC0 | (cur_reg-1); /* index of highest */
+ } else {
+ r300->hw.rr.cmd[R300_RR_CMD_0] = cmdpacket0(R300_RS_ROUTE_0, 1);
+ r300->hw.rc.cmd[2] = 0x0;
+ }
+
+
+// fprintf(stderr, "rendering with %d texture co-ordinate sets\n", cur_reg);
+}
+#endif // USE_ARB_F_P
+
+#define vpucount(ptr) (((drm_r300_cmd_header_t*)(ptr))->vpu.count)
+
+#define bump_vpu_count(ptr, new_count) do{\
+ drm_r300_cmd_header_t* _p=((drm_r300_cmd_header_t*)(ptr));\
+ int _nc=(new_count)/4; \
+ if(_nc>_p->vpu.count)_p->vpu.count=_nc;\
+ }while(0)
+
+void static inline setup_vertex_shader_fragment(r300ContextPtr r300, int dest, struct r300_vertex_shader_fragment *vsf)
+{
+ int i;
+
+ if(vsf->length==0)return;
+
+ if(vsf->length & 0x3){
+ fprintf(stderr,"VERTEX_SHADER_FRAGMENT must have length divisible by 4\n");
+ exit(-1);
+ }
+
+ switch((dest>>8) & 0xf){
+ case 0:
+ R300_STATECHANGE(r300, vpi);
+ for(i=0;i<vsf->length;i++)
+ r300->hw.vpi.cmd[R300_VPI_INSTR_0+i+4*(dest & 0xff)]=(vsf->body.d[i]);
+ bump_vpu_count(r300->hw.vpi.cmd, vsf->length+4*(dest & 0xff));
+ break;
+
+ case 2:
+ R300_STATECHANGE(r300, vpp);
+ for(i=0;i<vsf->length;i++)
+ r300->hw.vpp.cmd[R300_VPP_PARAM_0+i+4*(dest & 0xff)]=(vsf->body.d[i]);
+ bump_vpu_count(r300->hw.vpp.cmd, vsf->length+4*(dest & 0xff));
+ break;
+ case 4:
+ R300_STATECHANGE(r300, vps);
+ for(i=0;i<vsf->length;i++)
+ r300->hw.vps.cmd[1+i+4*(dest & 0xff)]=(vsf->body.d[i]);
+ bump_vpu_count(r300->hw.vps.cmd, vsf->length+4*(dest & 0xff));
+ break;
+ default:
+ fprintf(stderr, "%s:%s don't know how to handle dest %04x\n", __FILE__, __FUNCTION__, dest);
+ exit(-1);
+ }
+}
+
+void r300SetupVertexProgram(r300ContextPtr rmesa);
+
+/* just a skeleton for now.. */
+
+/* Generate a vertex shader that simply transforms vertex and texture coordinates,
+ while leaving colors intact. Nothing fancy (like lights)
+
+ If implementing lights make a copy first, so it is easy to switch between the two versions */
+static void r300GenerateSimpleVertexShader(r300ContextPtr r300)
+{
+ int i;
+ GLuint o_reg = 0;
+
+ /* Allocate parameters */
+ r300->state.vap_param.transform_offset=0x0; /* transform matrix */
+ r300->state.vertex_shader.param_offset=0x0;
+ r300->state.vertex_shader.param_count=0x4; /* 4 vector values - 4x4 matrix */
+
+ r300->state.vertex_shader.program_start=0x0;
+ r300->state.vertex_shader.unknown_ptr1=0x4; /* magic value ? */
+ r300->state.vertex_shader.program_end=0x0;
+
+ r300->state.vertex_shader.unknown_ptr2=0x0; /* magic value */
+ r300->state.vertex_shader.unknown_ptr3=0x4; /* magic value */
+
+ /* Initialize matrix and vector parameters.. these should really be restructured */
+ /* TODO: fix vertex_shader structure */
+ r300->state.vertex_shader.matrix[0].length=16;
+ r300->state.vertex_shader.matrix[1].length=0;
+ r300->state.vertex_shader.matrix[2].length=0;
+ r300->state.vertex_shader.vector[0].length=0;
+ r300->state.vertex_shader.vector[1].length=0;
+ r300->state.vertex_shader.unknown1.length=0;
+ r300->state.vertex_shader.unknown2.length=0;
+
+#define WRITE_OP(oper,source1,source2,source3) {\
+ r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].op=(oper); \
+ r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].src1=(source1); \
+ r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].src2=(source2); \
+ r300->state.vertex_shader.program.body.i[r300->state.vertex_shader.program_end].src3=(source3); \
+ r300->state.vertex_shader.program_end++; \
+ }
+
+ /* Multiply vertex coordinates with transform matrix */
+
+ WRITE_OP(
+ EASY_VSF_OP(MUL, 0, ALL, TMP),
+ VSF_PARAM(3),
+ VSF_ATTR_W(0),
+ EASY_VSF_SOURCE(0, W, W, W, W, NONE, NONE)
+ )
+
+ WRITE_OP(
+ EASY_VSF_OP(MUL, 1, ALL, RESULT),
+ VSF_REG(1),
+ VSF_ATTR_UNITY(1),
+ VSF_UNITY(1)
+ )
+
+ WRITE_OP(
+ EASY_VSF_OP(MAD, 0, ALL, TMP),
+ VSF_PARAM(2),
+ VSF_ATTR_Z(0),
+ VSF_TMP(0)
+ )
+
+ WRITE_OP(
+ EASY_VSF_OP(MAD, 0, ALL, TMP),
+ VSF_PARAM(1),
+ VSF_ATTR_Y(0),
+ VSF_TMP(0)
+ )
+
+ WRITE_OP(
+ EASY_VSF_OP(MAD, 0, ALL, RESULT),
+ VSF_PARAM(0),
+ VSF_ATTR_X(0),
+ VSF_TMP(0)
+ )
+ o_reg += 2;
+
+ if (r300->state.render_inputs & _TNL_BIT_COLOR1) {
+ WRITE_OP(
+ EASY_VSF_OP(MUL, o_reg++, ALL, RESULT),
+ VSF_REG(r300->state.vap_reg.i_color[1]),
+ VSF_ATTR_UNITY(r300->state.vap_reg.i_color[1]),
+ VSF_UNITY(r300->state.vap_reg.i_color[1])
+ )
+ }
+
+ /* Pass through texture coordinates, if any */
+ for(i=0;i < r300->radeon.glCtx->Const.MaxTextureUnits;i++)
+ if(r300->state.render_inputs & (_TNL_BIT_TEX0<<i)){
+ // fprintf(stderr, "i_tex[%d]=%d\n", i, r300->state.vap_reg.i_tex[i]);
+ WRITE_OP(
+ EASY_VSF_OP(MUL, o_reg++ /* 2+i */, ALL, RESULT),
+ VSF_REG(r300->state.vap_reg.i_tex[i]),
+ VSF_ATTR_UNITY(r300->state.vap_reg.i_tex[i]),
+ VSF_UNITY(r300->state.vap_reg.i_tex[i])
+ )
+ }
+
+ r300->state.vertex_shader.program_end--; /* r300 wants program length to be one more - no idea why */
+ r300->state.vertex_shader.program.length=(r300->state.vertex_shader.program_end+1)*4;
+
+ r300->state.vertex_shader.unknown_ptr1=r300->state.vertex_shader.program_end; /* magic value ? */
+ r300->state.vertex_shader.unknown_ptr2=r300->state.vertex_shader.program_end; /* magic value ? */
+ r300->state.vertex_shader.unknown_ptr3=r300->state.vertex_shader.program_end; /* magic value ? */
+
+}
+
+
+void r300SetupVertexShader(r300ContextPtr rmesa)
+{
+ GLcontext* ctx = rmesa->radeon.glCtx;
+ struct r300_vertex_shader_fragment unk4={
+ length: 4,
+ body: { f: {
+ /*0.0*/(rand()%100)/10.0,
+ /*0.0*/(rand()%100)/10.0,
+ /*1.0*/(rand()%100)/10.0,
+ /*0.0*/(rand()%100)/10.0
+ } }
+ };
+ LOCAL_VARS
+
+ /* Reset state, in case we don't use something */
+ ((drm_r300_cmd_header_t*)rmesa->hw.vpp.cmd)->vpu.count = 0;
+ ((drm_r300_cmd_header_t*)rmesa->hw.vpi.cmd)->vpu.count = 0;
+ ((drm_r300_cmd_header_t*)rmesa->hw.vps.cmd)->vpu.count = 0;
+
+ /* Not sure why this doesnt work...
+ 0x400 area might have something to do with pixel shaders as it appears right after pfs programming.
+ 0x406 is set to { 0.0, 0.0, 1.0, 0.0 } most of the time but should change with smooth points and in other rare cases. */
+ //setup_vertex_shader_fragment(rmesa, 0x406, &unk4);
+ if(hw_tcl_on && ((struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx))->translated){
+ r300SetupVertexProgram(rmesa);
+ return ;
+ }
+
+/* This needs to be replaced by vertex shader generation code */
+
+
+#if 0
+ /* textures enabled ? */
+ if(rmesa->state.texture.tc_count>0){
+ rmesa->state.vertex_shader=SINGLE_TEXTURE_VERTEX_SHADER;
+ } else {
+ rmesa->state.vertex_shader=FLAT_COLOR_VERTEX_SHADER;
+ }
+#endif
+
+ r300GenerateSimpleVertexShader(rmesa);
+
+ rmesa->state.vertex_shader.matrix[0].length=16;
+ memcpy(rmesa->state.vertex_shader.matrix[0].body.f, ctx->_ModelProjectMatrix.m, 16*4);
+
+ setup_vertex_shader_fragment(rmesa, VSF_DEST_PROGRAM, &(rmesa->state.vertex_shader.program));
+
+ setup_vertex_shader_fragment(rmesa, VSF_DEST_MATRIX0, &(rmesa->state.vertex_shader.matrix[0]));
+#if 0
+ setup_vertex_shader_fragment(rmesa, VSF_DEST_MATRIX1, &(rmesa->state.vertex_shader.matrix[0]));
+ setup_vertex_shader_fragment(rmesa, VSF_DEST_MATRIX2, &(rmesa->state.vertex_shader.matrix[0]));
+
+ setup_vertex_shader_fragment(rmesa, VSF_DEST_VECTOR0, &(rmesa->state.vertex_shader.vector[0]));
+ setup_vertex_shader_fragment(rmesa, VSF_DEST_VECTOR1, &(rmesa->state.vertex_shader.vector[1]));
+#endif
+
+#if 0
+ setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN1, &(rmesa->state.vertex_shader.unknown1));
+ setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN2, &(rmesa->state.vertex_shader.unknown2));
+#endif
+
+ R300_STATECHANGE(rmesa, pvs);
+ rmesa->hw.pvs.cmd[R300_PVS_CNTL_1]=(rmesa->state.vertex_shader.program_start << R300_PVS_CNTL_1_PROGRAM_START_SHIFT)
+ | (rmesa->state.vertex_shader.unknown_ptr1 << R300_PVS_CNTL_1_POS_END_SHIFT)
+ | (rmesa->state.vertex_shader.program_end << R300_PVS_CNTL_1_PROGRAM_END_SHIFT);
+ rmesa->hw.pvs.cmd[R300_PVS_CNTL_2]=(rmesa->state.vertex_shader.param_offset << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT)
+ | (rmesa->state.vertex_shader.param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT);
+ rmesa->hw.pvs.cmd[R300_PVS_CNTL_3]=(rmesa->state.vertex_shader.unknown_ptr2 << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT)
+ | (rmesa->state.vertex_shader.unknown_ptr3 << 0);
+
+ /* This is done for vertex shader fragments, but also needs to be done for vap_pvs,
+ so I leave it as a reminder */
+#if 0
+ reg_start(R300_VAP_PVS_WAITIDLE,0);
+ e32(0x00000000);
+#endif
+}
+
+void r300SetupVertexProgram(r300ContextPtr rmesa)
+{
+ GLcontext* ctx = rmesa->radeon.glCtx;
+ int inst_count;
+ int param_count;
+ LOCAL_VARS
+ struct r300_vertex_program *prog=(struct r300_vertex_program *)CURRENT_VERTEX_SHADER(ctx);
+
+
+ /* Reset state, in case we don't use something */
+ ((drm_r300_cmd_header_t*)rmesa->hw.vpp.cmd)->vpu.count = 0;
+ ((drm_r300_cmd_header_t*)rmesa->hw.vpi.cmd)->vpu.count = 0;
+ ((drm_r300_cmd_header_t*)rmesa->hw.vps.cmd)->vpu.count = 0;
+
+ r300VertexProgUpdateParams(ctx, prog);
+
+ setup_vertex_shader_fragment(rmesa, VSF_DEST_PROGRAM, &(prog->program));
+
+ setup_vertex_shader_fragment(rmesa, VSF_DEST_MATRIX0, &(prog->params));
+
+#if 0
+ setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN1, &(rmesa->state.vertex_shader.unknown1));
+ setup_vertex_shader_fragment(rmesa, VSF_DEST_UNKNOWN2, &(rmesa->state.vertex_shader.unknown2));
+#endif
+
+ inst_count=prog->program.length/4 - 1;
+ param_count=prog->params.length/4;
+
+ R300_STATECHANGE(rmesa, pvs);
+ rmesa->hw.pvs.cmd[R300_PVS_CNTL_1]=(0 << R300_PVS_CNTL_1_PROGRAM_START_SHIFT)
+ | (inst_count/*pos_end*/ << R300_PVS_CNTL_1_POS_END_SHIFT)
+ | (inst_count << R300_PVS_CNTL_1_PROGRAM_END_SHIFT);
+ rmesa->hw.pvs.cmd[R300_PVS_CNTL_2]=(0 << R300_PVS_CNTL_2_PARAM_OFFSET_SHIFT)
+ | (param_count << R300_PVS_CNTL_2_PARAM_COUNT_SHIFT);
+ rmesa->hw.pvs.cmd[R300_PVS_CNTL_3]=(0/*rmesa->state.vertex_shader.unknown_ptr2*/ << R300_PVS_CNTL_3_PROGRAM_UNKNOWN_SHIFT)
+ | (inst_count /*rmesa->state.vertex_shader.unknown_ptr3*/ << 0);
+
+ /* This is done for vertex shader fragments, but also needs to be done for vap_pvs,
+ so I leave it as a reminder */
+#if 0
+ reg_start(R300_VAP_PVS_WAITIDLE,0);
+ e32(0x00000000);
+#endif
+}
+
+/* This is probably wrong for some values, I need to test this
+ * some more. Range checking would be a good idea also..
+ *
+ * But it works for most things. I'll fix it later if someone
+ * else with a better clue doesn't
+ */
+static unsigned int r300PackFloat24(float f)
+{
+ float mantissa;
+ int exponent;
+ unsigned int float24 = 0;
+
+ if (f == 0.0) return 0;
+
+ mantissa = frexpf(f, &exponent);
+
+ /* Handle -ve */
+ if (mantissa < 0) {
+ float24 |= (1<<23);
+ mantissa = mantissa * -1.0;
+ }
+ /* Handle exponent, bias of 63 */
+ exponent += 62;
+ float24 |= (exponent << 16);
+ /* Kill 7 LSB of mantissa */
+ float24 |= (r300PackFloat32(mantissa) & 0x7FFFFF) >> 7;
+
+ return float24;
+}
+
+#if USE_ARB_F_P == 1
+void r300SetupPixelShader(r300ContextPtr rmesa)
+{
+ GLcontext *ctx = rmesa->radeon.glCtx;
+ struct r300_fragment_program *rp =
+ (struct r300_fragment_program *)ctx->FragmentProgram._Current;
+ int i,k;
+
+ if (!rp) /* should only happenen once, just after context is created */
+ return;
+
+ translate_fragment_shader(rp);
+ if (!rp->translated) {
+ fprintf(stderr, "%s: No valid fragment shader, exiting\n", __func__);
+ exit(-1);
+ }
+
+ R300_STATECHANGE(rmesa, fpt);
+ for(i=0;i<rp->tex.length;i++)
+ rmesa->hw.fpt.cmd[R300_FPT_INSTR_0+i]=rp->tex.inst[i];
+ rmesa->hw.fpt.cmd[R300_FPT_CMD_0]=cmdpacket0(R300_PFS_TEXI_0, rp->tex.length);
+
+#define OUTPUT_FIELD(st, reg, field) \
+ R300_STATECHANGE(rmesa, st); \
+ for(i=0;i<=rp->alu_end;i++) \
+ rmesa->hw.st.cmd[R300_FPI_INSTR_0+i]=rp->alu.inst[i].field;\
+ rmesa->hw.st.cmd[R300_FPI_CMD_0]=cmdpacket0(reg, rp->alu_end+1);
+
+ OUTPUT_FIELD(fpi[0], R300_PFS_INSTR0_0, inst0);
+ OUTPUT_FIELD(fpi[1], R300_PFS_INSTR1_0, inst1);
+ OUTPUT_FIELD(fpi[2], R300_PFS_INSTR2_0, inst2);
+ OUTPUT_FIELD(fpi[3], R300_PFS_INSTR3_0, inst3);
+#undef OUTPUT_FIELD
+
+ R300_STATECHANGE(rmesa, fp);
+ /* I just want to say, the way these nodes are stored.. weird.. */
+ for (i=0,k=(4-(rp->cur_node+1));i<4;i++,k++) {
+ if (i<(rp->cur_node+1)) {
+ rmesa->hw.fp.cmd[R300_FP_NODE0+k]=
+ (rp->node[i].alu_offset << R300_PFS_NODE_ALU_OFFSET_SHIFT)
+ | (rp->node[i].alu_end << R300_PFS_NODE_ALU_END_SHIFT)
+ | (rp->node[i].tex_offset << R300_PFS_NODE_TEX_OFFSET_SHIFT)
+ | (rp->node[i].tex_end << R300_PFS_NODE_TEX_END_SHIFT)
+ | ( (k==3) ? R300_PFS_NODE_LAST_NODE : 0);
+ } else {
+ rmesa->hw.fp.cmd[R300_FP_NODE0+(3-i)] = 0;
+ }
+ }
+
+ /* PFS_CNTL_0 */
+ rmesa->hw.fp.cmd[R300_FP_CNTL0]=
+ rp->cur_node
+ | (rp->first_node_has_tex<<3);
+ /* PFS_CNTL_1 */
+ rmesa->hw.fp.cmd[R300_FP_CNTL1]=rp->max_temp_idx;
+ /* PFS_CNTL_2 */
+ rmesa->hw.fp.cmd[R300_FP_CNTL2]=
+ (rp->alu_offset << R300_PFS_CNTL_ALU_OFFSET_SHIFT)
+ | (rp->alu_end << R300_PFS_CNTL_ALU_END_SHIFT)
+ | (rp->tex_offset << R300_PFS_CNTL_TEX_OFFSET_SHIFT)
+ | (rp->tex_end << R300_PFS_CNTL_TEX_END_SHIFT);
+
+ R300_STATECHANGE(rmesa, fpp);
+ for(i=0;i<rp->const_nr;i++){
+ rmesa->hw.fpp.cmd[R300_FPP_PARAM_0+4*i+0]=r300PackFloat24(rp->constant[i][0]);
+ rmesa->hw.fpp.cmd[R300_FPP_PARAM_0+4*i+1]=r300PackFloat24(rp->constant[i][1]);
+ rmesa->hw.fpp.cmd[R300_FPP_PARAM_0+4*i+2]=r300PackFloat24(rp->constant[i][2]);
+ rmesa->hw.fpp.cmd[R300_FPP_PARAM_0+4*i+3]=r300PackFloat24(rp->constant[i][3]);
+ }
+ rmesa->hw.fpp.cmd[R300_FPP_CMD_0]=cmdpacket0(R300_PFS_PARAM_0_X, rp->const_nr*4);
+}
+#else
+/* just a skeleton for now.. */
+void r300GenerateTexturePixelShader(r300ContextPtr r300)
+{
+ int i, mtu;
+ mtu = r300->radeon.glCtx->Const.MaxTextureUnits;
+ GLenum envMode;
+ GLuint OutputsWritten = CURRENT_VERTEX_SHADER(r300->radeon.glCtx)->OutputsWritten;
+
+ int tex_inst=0, alu_inst=0;
+
+ for(i=0;i<mtu;i++){
+ /* No need to proliferate {} */
+ if(!TMU_ENABLED(r300->radeon.glCtx, i))continue;
+
+ envMode = r300->radeon.glCtx->Texture.Unit[i].EnvMode;
+ //fprintf(stderr, "envMode=%s\n", _mesa_lookup_enum_by_nr(envMode));
+
+ /* Fetch textured pixel */
+
+ r300->state.pixel_shader.program.tex.inst[tex_inst]=0x00018000;
+ tex_inst++;
+
+ switch(r300->radeon.glCtx->Texture.Unit[i]._CurrentCombine->ModeRGB){
+ case GL_REPLACE:
+ WARN_ONCE("ModeA==GL_REPLACE is possibly broken.\n");
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst0=
+ EASY_PFS_INSTR0(MAD, SRC0C_XYZ, ONE, ZERO);
+
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst1=
+ EASY_PFS_INSTR1(0, 0, 0 | PFS_FLAG_CONST, 0 | PFS_FLAG_CONST, NONE, ALL);
+ break;
+ case GL_MODULATE:
+ WARN_ONCE("ModeRGB==GL_MODULATE is possibly broken.\n");
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst0=
+ EASY_PFS_INSTR0(MAD, SRC0C_XYZ, SRC1C_XYZ, ZERO);
+
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst1=
+ EASY_PFS_INSTR1(0, 0, 1, 0 | PFS_FLAG_CONST, NONE, ALL);
+
+ break;
+ default:
+ WARN_ONCE("ModeRGB=%s is not implemented yet !\n",
+ _mesa_lookup_enum_by_nr(r300->radeon.glCtx->Texture.Unit[i]._CurrentCombine->ModeRGB));
+ /* PFS_NOP */
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst0=
+ EASY_PFS_INSTR0(MAD, SRC0C_XYZ, ONE, ZERO);
+
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst1=
+ EASY_PFS_INSTR1(0, 0, 0 | PFS_FLAG_CONST, 0 | PFS_FLAG_CONST, NONE, ALL);
+ }
+ switch(r300->radeon.glCtx->Texture.Unit[i]._CurrentCombine->ModeA){
+ case GL_REPLACE:
+ WARN_ONCE("ModeA==GL_REPLACE is possibly broken.\n");
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst2=
+ EASY_PFS_INSTR2(MAD, SRC0A, ONE, ZERO);
+
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst3=
+ EASY_PFS_INSTR3(0, 0, 0| PFS_FLAG_CONST, 0 | PFS_FLAG_CONST, OUTPUT);
+
+#if 0
+ fprintf(stderr, "numArgsA=%d sourceA[0]=%s op=%d\n",
+ r300->radeon.glCtx->Texture.Unit[i]._CurrentCombine->_NumArgsA,
+ _mesa_lookup_enum_by_nr(r300->radeon.glCtx->Texture.Unit[i]._CurrentCombine->SourceA[0]),
+ r300->radeon.glCtx->Texture.Unit[i]._CurrentCombine->OperandA[0]-GL_SRC_ALPHA);
+#endif
+ break;
+ case GL_MODULATE:
+ WARN_ONCE("ModeA==GL_MODULATE is possibly broken.\n");
+
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst2=
+ EASY_PFS_INSTR2(MAD, SRC0A, SRC1A, ZERO);
+
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst3=
+ EASY_PFS_INSTR3(0, 0, 1, 0 | PFS_FLAG_CONST, OUTPUT);
+
+ break;
+ default:
+ WARN_ONCE("ModeA=%s is not implemented yet !\n",
+ _mesa_lookup_enum_by_nr(r300->radeon.glCtx->Texture.Unit[i]._CurrentCombine->ModeA));
+ /* PFS_NOP */
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst2=
+ EASY_PFS_INSTR2(MAD, SRC0A, ONE, ZERO);
+
+ r300->state.pixel_shader.program.alu.inst[alu_inst].inst3=
+ EASY_PFS_INSTR3(0, 0, 0 | PFS_FLAG_CONST, 0 | PFS_FLAG_CONST, OUTPUT);
+
+ }
+
+ alu_inst++;
+ }
+
+ r300->state.pixel_shader.program.tex.length=tex_inst;
+ r300->state.pixel_shader.program.tex_offset=0;
+ r300->state.pixel_shader.program.tex_end=tex_inst-1;
+
+#if 0
+ /* saturate last instruction, like i915 driver does */
+ r300->state.pixel_shader.program.alu.inst[alu_inst-1].inst0|=R300_FPI0_OUTC_SAT;
+ r300->state.pixel_shader.program.alu.inst[alu_inst-1].inst2|=R300_FPI2_OUTA_SAT;
+#endif
+
+ r300->state.pixel_shader.program.alu.length=alu_inst;
+ r300->state.pixel_shader.program.alu_offset=0;
+ r300->state.pixel_shader.program.alu_end=alu_inst-1;
+}
+
+void r300SetupPixelShader(r300ContextPtr rmesa)
+{
+int i,k;
+
+ /* This needs to be replaced by pixel shader generation code */
+
+ /* textures enabled ? */
+ if(rmesa->state.texture.tc_count>0){
+#if 1
+ r300GenerateTextureFragmentShader(rmesa);
+#else
+ rmesa->state.pixel_shader=SINGLE_TEXTURE_PIXEL_SHADER;
+ r300GenerateTexturePixelShader(rmesa);
+#endif
+ } else {
+ rmesa->state.pixel_shader=FLAT_COLOR_PIXEL_SHADER;
+ }
+
+ R300_STATECHANGE(rmesa, fpt);
+ for(i=0;i<rmesa->state.pixel_shader.program.tex.length;i++)
+ rmesa->hw.fpt.cmd[R300_FPT_INSTR_0+i]=rmesa->state.pixel_shader.program.tex.inst[i];
+ rmesa->hw.fpt.cmd[R300_FPT_CMD_0]=cmdpacket0(R300_PFS_TEXI_0, rmesa->state.pixel_shader.program.tex.length);
+
+#define OUTPUT_FIELD(st, reg, field) \
+ R300_STATECHANGE(rmesa, st); \
+ for(i=0;i<rmesa->state.pixel_shader.program.alu.length;i++) \
+ rmesa->hw.st.cmd[R300_FPI_INSTR_0+i]=rmesa->state.pixel_shader.program.alu.inst[i].field;\
+ rmesa->hw.st.cmd[R300_FPI_CMD_0]=cmdpacket0(reg, rmesa->state.pixel_shader.program.alu.length);
+
+ OUTPUT_FIELD(fpi[0], R300_PFS_INSTR0_0, inst0);
+ OUTPUT_FIELD(fpi[1], R300_PFS_INSTR1_0, inst1);
+ OUTPUT_FIELD(fpi[2], R300_PFS_INSTR2_0, inst2);
+ OUTPUT_FIELD(fpi[3], R300_PFS_INSTR3_0, inst3);
+#undef OUTPUT_FIELD
+
+ R300_STATECHANGE(rmesa, fp);
+ for(i=0;i<4;i++){
+ rmesa->hw.fp.cmd[R300_FP_NODE0+i]=
+ (rmesa->state.pixel_shader.program.node[i].alu_offset << R300_PFS_NODE_ALU_OFFSET_SHIFT)
+ | (rmesa->state.pixel_shader.program.node[i].alu_end << R300_PFS_NODE_ALU_END_SHIFT)
+ | (rmesa->state.pixel_shader.program.node[i].tex_offset << R300_PFS_NODE_TEX_OFFSET_SHIFT)
+ | (rmesa->state.pixel_shader.program.node[i].tex_end << R300_PFS_NODE_TEX_END_SHIFT)
+ | ( (i==3) ? R300_PFS_NODE_LAST_NODE : 0);
+ }
+
+ /* PFS_CNTL_0 */
+ rmesa->hw.fp.cmd[R300_FP_CNTL0]=
+ (rmesa->state.pixel_shader.program.active_nodes-1)
+ | (rmesa->state.pixel_shader.program.first_node_has_tex<<3);
+ /* PFS_CNTL_1 */
+ rmesa->hw.fp.cmd[R300_FP_CNTL1]=rmesa->state.pixel_shader.program.temp_register_count;
+ /* PFS_CNTL_2 */
+ rmesa->hw.fp.cmd[R300_FP_CNTL2]=
+ (rmesa->state.pixel_shader.program.alu_offset << R300_PFS_CNTL_ALU_OFFSET_SHIFT)
+ | (rmesa->state.pixel_shader.program.alu_end << R300_PFS_CNTL_ALU_END_SHIFT)
+ | (rmesa->state.pixel_shader.program.tex_offset << R300_PFS_CNTL_TEX_OFFSET_SHIFT)
+ | (rmesa->state.pixel_shader.program.tex_end << R300_PFS_CNTL_TEX_END_SHIFT);
+
+ R300_STATECHANGE(rmesa, fpp);
+ for(i=0;i<rmesa->state.pixel_shader.param_length;i++){
+ rmesa->hw.fpp.cmd[R300_FPP_PARAM_0+4*i+0]=r300PackFloat32(rmesa->state.pixel_shader.param[i].x);
+ rmesa->hw.fpp.cmd[R300_FPP_PARAM_0+4*i+1]=r300PackFloat32(rmesa->state.pixel_shader.param[i].y);
+ rmesa->hw.fpp.cmd[R300_FPP_PARAM_0+4*i+2]=r300PackFloat32(rmesa->state.pixel_shader.param[i].z);
+ rmesa->hw.fpp.cmd[R300_FPP_PARAM_0+4*i+3]=r300PackFloat32(rmesa->state.pixel_shader.param[i].w);
+ }
+ rmesa->hw.fpp.cmd[R300_FPP_CMD_0]=cmdpacket0(R300_PFS_PARAM_0_X, rmesa->state.pixel_shader.param_length);
+
+}
+#endif
+
+/**
+ * Called by Mesa after an internal state update.
+ */
+static void r300InvalidateState(GLcontext * ctx, GLuint new_state)
+{
+ r300ContextPtr r300 = R300_CONTEXT(ctx);
+
+ _swrast_InvalidateState(ctx, new_state);
+ _swsetup_InvalidateState(ctx, new_state);
+ _ac_InvalidateState(ctx, new_state);
+ _tnl_InvalidateState(ctx, new_state);
+ _ae_invalidate_state(ctx, new_state);
+
+ /* Go inefficiency! */
+ r300ResetHwState(r300);
+}
+
+/* Checks that r300ResetHwState actually modifies all states.
+ Should probably be burried in somewhere else as this file is getting longish. */
+static void verify_r300ResetHwState(r300ContextPtr r300, int stage)
+{
+ struct r300_state_atom* atom;
+ int i;
+ drm_r300_cmd_header_t cmd;
+
+ if(stage){ /* mess around with states */
+ unsigned long fp1, cb1;
+
+ fp1=r300->hw.fp.cmd[R300_FP_CMD_1]; /* some special cases... */
+ cb1=r300->hw.cb.cmd[R300_CB_CMD_1];
+
+ fprintf(stderr, "verify begin:\n");
+
+ foreach(atom, &r300->hw.atomlist) {
+ for(i=1; i < (*atom->check)(r300, atom); i++)
+ atom->cmd[i]=0xdeadbeef;
+ }
+ r300->hw.fp.cmd[R300_FP_CMD_1]=fp1;
+ r300->hw.cb.cmd[R300_CB_CMD_1]=cb1;
+
+ foreach(atom, &r300->hw.atomlist) {
+ cmd.u=atom->cmd[0];
+ switch(cmd.header.cmd_type){
+ case R300_CMD_PACKET0:
+ case R300_CMD_VPU:
+ case R300_CMD_PACKET3:
+ case R300_CMD_END3D:
+ case R300_CMD_CP_DELAY:
+ case R300_CMD_DMA_DISCARD:
+ break;
+ default: fprintf(stderr, "unknown cmd_type %d in atom %s\n",
+ cmd.header.cmd_type, atom->name);
+ }
+
+ }
+ } else { /* check that they were set */
+ foreach(atom, &r300->hw.atomlist) {
+ for(i=1; i < (*atom->check)(r300, atom); i++)
+ if(atom->cmd[i]==0xdeadbeef)
+ fprintf(stderr, "atom %s is untouched\n", atom->name);
+ }
+ }
+}
+
+/**
+ * Completely recalculates hardware state based on the Mesa state.
+ */
+void r300ResetHwState(r300ContextPtr r300)
+{
+ GLcontext* ctx = r300->radeon.glCtx;
+ int i;
+
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ //verify_r300ResetHwState(r300, 1);
+
+ /* This is a place to initialize registers which
+ have bitfields accessed by different functions
+ and not all bits are used */
+#if 0
+ /* initialize similiar to r200 */
+ r300->hw.zs.cmd[R300_ZS_CNTL_0] = 0;
+ r300->hw.zs.cmd[R300_ZS_CNTL_1] =
+ (R300_ZS_ALWAYS << R300_RB3D_ZS1_FRONT_FUNC_SHIFT) |
+ (R300_ZS_KEEP << R300_RB3D_ZS1_FRONT_FAIL_OP_SHIFT) |
+ (R300_ZS_KEEP << R300_RB3D_ZS1_FRONT_ZPASS_OP_SHIFT) |
+ (R300_ZS_KEEP << R300_RB3D_ZS1_FRONT_ZFAIL_OP_SHIFT) |
+ (R300_ZS_ALWAYS << R300_RB3D_ZS1_BACK_FUNC_SHIFT) |
+ (R300_ZS_KEEP << R300_RB3D_ZS1_BACK_FAIL_OP_SHIFT) |
+ (R300_ZS_KEEP << R300_RB3D_ZS1_BACK_ZPASS_OP_SHIFT) |
+ (R300_ZS_KEEP << R300_RB3D_ZS1_BACK_ZFAIL_OP_SHIFT);
+ r300->hw.zs.cmd[R300_ZS_CNTL_2] = 0x00ffff00;
+#endif
+
+ /* go and compute register values from GL state */
+
+ r300UpdateWindow(ctx);
+
+ r300ColorMask(ctx,
+ ctx->Color.ColorMask[RCOMP],
+ ctx->Color.ColorMask[GCOMP],
+ ctx->Color.ColorMask[BCOMP],
+ ctx->Color.ColorMask[ACOMP]);
+
+ r300Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test);
+ r300DepthMask(ctx, ctx->Depth.Mask);
+ r300DepthFunc(ctx, ctx->Depth.Func);
+
+ /* stencil */
+ r300Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled);
+ r300StencilMask(ctx, ctx->Stencil.WriteMask[0]);
+ r300StencilFunc(ctx, ctx->Stencil.Function[0], ctx->Stencil.Ref[0], ctx->Stencil.ValueMask[0]);
+ r300StencilOp(ctx, ctx->Stencil.FailFunc[0], ctx->Stencil.ZFailFunc[0], ctx->Stencil.ZPassFunc[0]);
+
+ r300UpdateCulling(ctx);
+
+ r300UpdateTextureState(ctx);
+
+// r300_setup_routing(ctx, GL_TRUE);
+ if(hw_tcl_on == GL_FALSE){
+ r300EmitArrays(ctx, GL_TRUE); /* Just do the routing */
+ r300_setup_textures(ctx);
+ r300_setup_rs_unit(ctx);
+
+ r300SetupVertexShader(r300);
+ r300SetupPixelShader(r300);
+ }
+
+ r300_set_blend_state(ctx);
+
+ r300AlphaFunc(ctx, ctx->Color.AlphaFunc, ctx->Color.AlphaRef);
+ r300Enable(ctx, GL_ALPHA_TEST, ctx->Color.AlphaEnabled);
+
+ /* Initialize magic registers
+ TODO : learn what they really do, or get rid of
+ those we don't have to touch */
+ r300->hw.unk2080.cmd[1] = 0x0030045A; /* Dangerous */
+
+ r300->hw.vte.cmd[1] = R300_VPORT_X_SCALE_ENA
+ | R300_VPORT_X_OFFSET_ENA
+ | R300_VPORT_Y_SCALE_ENA
+ | R300_VPORT_Y_OFFSET_ENA
+ | R300_VPORT_Z_SCALE_ENA
+ | R300_VPORT_Z_OFFSET_ENA
+ | R300_VTX_W0_FMT;
+ r300->hw.vte.cmd[2] = 0x00000008;
+
+ r300->hw.unk2134.cmd[1] = 0x00FFFFFF;
+ r300->hw.unk2134.cmd[2] = 0x00000000;
+#ifdef MESA_BIG_ENDIAN
+ r300->hw.unk2140.cmd[1] = 0x00000002;
+#else
+ r300->hw.unk2140.cmd[1] = 0x00000000;
+#endif
+
+#if 0 /* Done in setup routing */
+ ((drm_r300_cmd_header_t*)r300->hw.vir[0].cmd)->packet0.count = 1;
+ r300->hw.vir[0].cmd[1] = 0x21030003;
+
+ ((drm_r300_cmd_header_t*)r300->hw.vir[1].cmd)->packet0.count = 1;
+ r300->hw.vir[1].cmd[1] = 0xF688F688;
+
+ r300->hw.vic.cmd[R300_VIR_CNTL_0] = 0x00000001;
+ r300->hw.vic.cmd[R300_VIR_CNTL_1] = 0x00000405;
+#endif
+
+ r300->hw.unk21DC.cmd[1] = 0xAAAAAAAA;
+
+ r300->hw.unk221C.cmd[1] = R300_221C_NORMAL;
+
+ r300->hw.unk2220.cmd[1] = r300PackFloat32(1.0);
+ r300->hw.unk2220.cmd[2] = r300PackFloat32(1.0);
+ r300->hw.unk2220.cmd[3] = r300PackFloat32(1.0);
+ r300->hw.unk2220.cmd[4] = r300PackFloat32(1.0);
+
+ if (GET_CHIP(r300->radeon.radeonScreen) == RADEON_CHIP_R300)
+ r300->hw.unk2288.cmd[1] = R300_2288_R300;
+ else
+ r300->hw.unk2288.cmd[1] = R300_2288_RV350;
+
+#if 0
+ r300->hw.vof.cmd[R300_VOF_CNTL_0] = R300_VAP_OUTPUT_VTX_FMT_0__POS_PRESENT
+ | R300_VAP_OUTPUT_VTX_FMT_0__COLOR_PRESENT;
+ r300->hw.vof.cmd[R300_VOF_CNTL_1] = 0; /* no textures */
+
+
+ r300->hw.pvs.cmd[R300_PVS_CNTL_1] = 0;
+ r300->hw.pvs.cmd[R300_PVS_CNTL_2] = 0;
+ r300->hw.pvs.cmd[R300_PVS_CNTL_3] = 0;
+#endif
+
+ r300->hw.gb_enable.cmd[1] = R300_GB_POINT_STUFF_ENABLE
+ | R300_GB_LINE_STUFF_ENABLE
+ | R300_GB_TRIANGLE_STUFF_ENABLE /*| R300_GB_UNK30*/;
+
+ r300->hw.gb_misc.cmd[R300_GB_MISC_MSPOS_0] = 0x66666666;
+ r300->hw.gb_misc.cmd[R300_GB_MISC_MSPOS_1] = 0x06666666;
+ if (GET_CHIP(r300->radeon.radeonScreen) == RADEON_CHIP_R300)
+ r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] = R300_GB_TILE_ENABLE
+ | R300_GB_TILE_PIPE_COUNT_R300
+ | R300_GB_TILE_SIZE_16;
+ else if (GET_CHIP(r300->radeon.radeonScreen) == RADEON_CHIP_R420)
+ r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] = R300_GB_TILE_ENABLE
+ | R300_GB_TILE_PIPE_COUNT_R420
+ | R300_GB_TILE_SIZE_16;
+ else
+ r300->hw.gb_misc.cmd[R300_GB_MISC_TILE_CONFIG] = R300_GB_TILE_ENABLE
+ | R300_GB_TILE_PIPE_COUNT_RV300
+ | R300_GB_TILE_SIZE_16;
+ r300->hw.gb_misc.cmd[R300_GB_MISC_SELECT] = 0x00000000;
+ r300->hw.gb_misc.cmd[R300_GB_MISC_AA_CONFIG] = 0x00000000; /* No antialiasing */
+
+ //r300->hw.txe.cmd[R300_TXE_ENABLE] = 0;
+
+ r300->hw.unk4200.cmd[1] = r300PackFloat32(0.0);
+ r300->hw.unk4200.cmd[2] = r300PackFloat32(0.0);
+ r300->hw.unk4200.cmd[3] = r300PackFloat32(1.0);
+ r300->hw.unk4200.cmd[4] = r300PackFloat32(1.0);
+
+ r300->hw.unk4214.cmd[1] = 0x00050005;
+
+ r300PointSize(ctx, 0.0);
+#if 0
+ r300->hw.ps.cmd[R300_PS_POINTSIZE] = (6 << R300_POINTSIZE_X_SHIFT) |
+ (6 << R300_POINTSIZE_Y_SHIFT);
+#endif
+
+ r300->hw.unk4230.cmd[1] = 0x01800000;//18000006;
+ r300->hw.unk4230.cmd[2] = 0x00020006;
+ r300->hw.unk4230.cmd[3] = r300PackFloat32(1.0 / 192.0);
+
+ r300LineWidth(ctx, 0.0);
+
+ r300->hw.unk4260.cmd[1] = 0;
+ r300->hw.unk4260.cmd[2] = r300PackFloat32(0.0);
+ r300->hw.unk4260.cmd[3] = r300PackFloat32(1.0);
+
+ r300->hw.unk4274.cmd[1] = 0x00000002;
+ r300ShadeModel(ctx, ctx->Light.ShadeModel);
+ r300->hw.unk4274.cmd[3] = 0x00000000;
+ r300->hw.unk4274.cmd[4] = 0x00000000;
+
+ r300PolygonMode(ctx, GL_FRONT, ctx->Polygon.FrontMode);
+ r300PolygonMode(ctx, GL_BACK, ctx->Polygon.BackMode);
+ r300->hw.unk4288.cmd[2] = 0x00000001;
+ r300->hw.unk4288.cmd[3] = 0x00000000;
+ r300->hw.unk4288.cmd[4] = 0x00000000;
+ r300->hw.unk4288.cmd[5] = 0x00000000;
+
+ r300->hw.unk42A0.cmd[1] = 0x00000000;
+
+ r300PolygonOffset(ctx, ctx->Polygon.OffsetFactor, ctx->Polygon.OffsetUnits);
+ r300Enable(ctx, GL_POLYGON_OFFSET_FILL, ctx->Polygon.OffsetFill);
+
+ r300->hw.unk42C0.cmd[1] = 0x4B7FFFFF;
+ r300->hw.unk42C0.cmd[2] = 0x00000000;
+
+
+ r300->hw.unk43A4.cmd[1] = 0x0000001C;
+ r300->hw.unk43A4.cmd[2] = 0x2DA49525;
+
+ r300->hw.unk43E8.cmd[1] = 0x00FFFFFF;
+
+#if 0
+ r300->hw.fp.cmd[R300_FP_CNTL0] = 0;
+ r300->hw.fp.cmd[R300_FP_CNTL1] = 0;
+ r300->hw.fp.cmd[R300_FP_CNTL2] = 0;
+ r300->hw.fp.cmd[R300_FP_NODE0] = 0;
+ r300->hw.fp.cmd[R300_FP_NODE1] = 0;
+ r300->hw.fp.cmd[R300_FP_NODE2] = 0;
+ r300->hw.fp.cmd[R300_FP_NODE3] = 0;
+#endif
+
+ r300->hw.unk46A4.cmd[1] = 0x00001B01;
+ r300->hw.unk46A4.cmd[2] = 0x00001B0F;
+ r300->hw.unk46A4.cmd[3] = 0x00001B0F;
+ r300->hw.unk46A4.cmd[4] = 0x00001B0F;
+ r300->hw.unk46A4.cmd[5] = 0x00000001;
+
+#if 0
+ for(i = 1; i <= 64; ++i) {
+ /* create NOP instructions */
+ r300->hw.fpi[0].cmd[i] = FP_INSTRC(MAD, FP_ARGC(SRC0C_XYZ), FP_ARGC(ONE), FP_ARGC(ZERO));
+ r300->hw.fpi[1].cmd[i] = FP_SELC(0,XYZ,NO,FP_TMP(0),0,0);
+ r300->hw.fpi[2].cmd[i] = FP_INSTRA(MAD, FP_ARGA(SRC0A), FP_ARGA(ONE), FP_ARGA(ZERO));
+ r300->hw.fpi[3].cmd[i] = FP_SELA(0,W,NO,FP_TMP(0),0,0);
+ }
+#endif
+
+ r300->hw.unk4BC0.cmd[1] = 0;
+
+ r300->hw.unk4BC8.cmd[1] = 0;
+ r300->hw.unk4BC8.cmd[2] = 0;
+ r300->hw.unk4BC8.cmd[3] = 0;
+
+
+ r300->hw.at.cmd[R300_AT_UNKNOWN] = 0;
+ r300->hw.unk4BD8.cmd[1] = 0;
+
+ r300->hw.unk4E00.cmd[1] = 0;
+
+#if 0
+ r300->hw.bld.cmd[R300_BLD_CBLEND] = 0;
+ r300->hw.bld.cmd[R300_BLD_ABLEND] = 0;
+#endif
+
+ r300BlendColor(ctx, ctx->Color.BlendColor);
+ r300->hw.unk4E10.cmd[2] = 0;
+ r300->hw.unk4E10.cmd[3] = 0;
+
+ /* Again, r300ClearBuffer uses this */
+ r300->hw.cb.cmd[R300_CB_OFFSET] = r300->radeon.state.color.drawOffset +
+ r300->radeon.radeonScreen->fbLocation;
+ r300->hw.cb.cmd[R300_CB_PITCH] = r300->radeon.state.color.drawPitch;
+
+ if (r300->radeon.radeonScreen->cpp == 4)
+ r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_ARGB8888;
+ else
+ r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_RGB565;
+
+ if (r300->radeon.sarea->tiling_enabled)
+ r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_TILE_ENABLE;
+
+ r300->hw.unk4E50.cmd[1] = 0;
+ r300->hw.unk4E50.cmd[2] = 0;
+ r300->hw.unk4E50.cmd[3] = 0;
+ r300->hw.unk4E50.cmd[4] = 0;
+ r300->hw.unk4E50.cmd[5] = 0;
+ r300->hw.unk4E50.cmd[6] = 0;
+ r300->hw.unk4E50.cmd[7] = 0;
+ r300->hw.unk4E50.cmd[8] = 0;
+ r300->hw.unk4E50.cmd[9] = 0;
+
+ r300->hw.unk4E88.cmd[1] = 0;
+
+ r300->hw.unk4EA0.cmd[1] = 0x00000000;
+ r300->hw.unk4EA0.cmd[2] = 0xffffffff;
+
+ switch (ctx->Visual.depthBits) {
+ case 16:
+ r300->hw.unk4F10.cmd[1] = R300_DEPTH_FORMAT_16BIT_INT_Z;
+ break;
+ case 24:
+ r300->hw.unk4F10.cmd[1] = R300_DEPTH_FORMAT_24BIT_INT_Z;
+ break;
+ default:
+ fprintf(stderr, "Error: Unsupported depth %d... exiting\n",
+ ctx->Visual.depthBits);
+ exit(-1);
+
+ }
+ r300->hw.unk4F10.cmd[3] = 0x00000003;
+ r300->hw.unk4F10.cmd[4] = 0x00000000;
+
+ r300->hw.zb.cmd[R300_ZB_OFFSET] =
+ r300->radeon.radeonScreen->depthOffset +
+ r300->radeon.radeonScreen->fbLocation;
+ r300->hw.zb.cmd[R300_ZB_PITCH] = r300->radeon.radeonScreen->depthPitch;
+
+ if (r300->radeon.sarea->tiling_enabled) {
+ /* Turn off when clearing buffers ? */
+ r300->hw.zb.cmd[R300_ZB_PITCH] |= R300_DEPTH_TILE_ENABLE;
+
+ if (ctx->Visual.depthBits == 24)
+ r300->hw.zb.cmd[R300_ZB_PITCH] |= R300_DEPTH_MICROTILE_ENABLE;
+ }
+
+ r300->hw.unk4F28.cmd[1] = 0;
+
+ r300->hw.unk4F30.cmd[1] = 0;
+ r300->hw.unk4F30.cmd[2] = 0;
+
+ r300->hw.unk4F44.cmd[1] = 0;
+
+ r300->hw.unk4F54.cmd[1] = 0;
+
+#if 0
+ ((drm_r300_cmd_header_t*)r300->hw.vpi.cmd)->vpu.count = 0;
+ for(i = 1; i < R300_VPI_CMDSIZE; i += 4) {
+ /* MOV t0, t0 */
+ r300->hw.vpi.cmd[i+0] = VP_OUT(ADD,TMP,0,XYZW);
+ r300->hw.vpi.cmd[i+1] = VP_IN(TMP,0);
+ r300->hw.vpi.cmd[i+2] = VP_ZERO();
+ r300->hw.vpi.cmd[i+3] = VP_ZERO();
+ }
+
+ ((drm_r300_cmd_header_t*)r300->hw.vpp.cmd)->vpu.count = 0;
+ for(i = 1; i < R300_VPP_CMDSIZE; ++i)
+ r300->hw.vpp.cmd[i] = 0;
+#endif
+
+ r300->hw.vps.cmd[R300_VPS_ZERO_0] = 0;
+ r300->hw.vps.cmd[R300_VPS_ZERO_1] = 0;
+ r300->hw.vps.cmd[R300_VPS_POINTSIZE] = r300PackFloat32(1.0);
+ r300->hw.vps.cmd[R300_VPS_ZERO_3] = 0;
+
+//END: TODO
+ //verify_r300ResetHwState(r300, 0);
+ r300->hw.all_dirty = GL_TRUE;
+}
+
+
+
+/**
+ * Calculate initial hardware state and register state functions.
+ * Assumes that the command buffer and state atoms have been
+ * initialized already.
+ */
+void r300InitState(r300ContextPtr r300)
+{
+ GLcontext *ctx = r300->radeon.glCtx;
+ GLuint depth_fmt;
+
+ radeonInitState(&r300->radeon);
+
+ switch (ctx->Visual.depthBits) {
+ case 16:
+ r300->state.depth.scale = 1.0 / (GLfloat) 0xffff;
+ depth_fmt = R200_DEPTH_FORMAT_16BIT_INT_Z;
+ r300->state.stencil.clear = 0x00000000;
+ break;
+ case 24:
+ r300->state.depth.scale = 1.0 / (GLfloat) 0xffffff;
+ depth_fmt = R200_DEPTH_FORMAT_24BIT_INT_Z;
+ r300->state.stencil.clear = 0x00ff0000;
+ break;
+ default:
+ fprintf(stderr, "Error: Unsupported depth %d... exiting\n",
+ ctx->Visual.depthBits);
+ exit(-1);
+ }
+
+ /* Only have hw stencil when depth buffer is 24 bits deep */
+ r300->state.stencil.hw_stencil = (ctx->Visual.stencilBits > 0 &&
+ ctx->Visual.depthBits == 24);
+
+ memset(&(r300->state.texture), 0, sizeof(r300->state.texture));
+
+ r300ResetHwState(r300);
+}
+
+static void r300RenderMode( GLcontext *ctx, GLenum mode )
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ WARN_ONCE("TODO: fallback properly when rendering mode is not GL_RENDER\n"
+ "\tThe way things are now neither selection nor feedback modes work\n")
+// FALLBACK( rmesa, R300_FALLBACK_RENDER_MODE, (mode != GL_RENDER) );
+}
+
+/**
+ * Initialize driver's state callback functions
+ */
+void r300InitStateFuncs(struct dd_function_table* functions)
+{
+ radeonInitStateFuncs(functions);
+
+ functions->UpdateState = r300InvalidateState;
+ functions->AlphaFunc = r300AlphaFunc;
+ functions->BlendColor = r300BlendColor;
+ functions->BlendEquationSeparate = r300BlendEquationSeparate;
+ functions->BlendFuncSeparate = r300BlendFuncSeparate;
+ functions->Enable = r300Enable;
+ functions->ColorMask = r300ColorMask;
+ functions->DepthFunc = r300DepthFunc;
+ functions->DepthMask = r300DepthMask;
+ functions->CullFace = r300CullFace;
+ functions->FrontFace = r300FrontFace;
+ functions->ShadeModel = r300ShadeModel;
+
+ /* Stencil related */
+ functions->ClearStencil = r300ClearStencil;
+ functions->StencilFunc = r300StencilFunc;
+ functions->StencilMask = r300StencilMask;
+ functions->StencilOp = r300StencilOp;
+
+ /* Viewport related */
+ functions->Viewport = r300Viewport;
+ functions->DepthRange = r300DepthRange;
+ functions->PointSize = r300PointSize;
+ functions->LineWidth = r300LineWidth;
+
+ functions->PolygonOffset = r300PolygonOffset;
+ functions->PolygonMode = r300PolygonMode;
+
+ functions->RenderMode = r300RenderMode;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_state.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_state.h
new file mode 100644
index 000000000..131834fa7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_state.h
@@ -0,0 +1,69 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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:
+ * Nicolai Haehnle <prefect_@gmx.net>
+ */
+
+#ifndef __R300_STATE_H__
+#define __R300_STATE_H__
+
+#include "r300_context.h"
+
+#define R300_STATECHANGE(r300, atom) \
+ do { \
+ r300->hw.atom.dirty = GL_TRUE; \
+ r300->hw.is_dirty = GL_TRUE; \
+ } while(0)
+
+/* Fire the buffered vertices no matter what.
+ TODO: This has not been implemented yet
+ */
+#define R300_FIREVERTICES( r300 ) \
+do { \
+ \
+ if ( (r300)->cmdbuf.count_used || (r300)->dma.flush ) { \
+ r300Flush( (r300)->radeon.glCtx ); \
+ } \
+ \
+} while (0)
+
+
+extern void r300ResetHwState(r300ContextPtr r300);
+
+extern void r300InitState(r300ContextPtr r300);
+extern void r300InitStateFuncs(struct dd_function_table* functions);
+extern void r300SetupVertexShader(r300ContextPtr rmesa);
+extern void r300SetupPixelShader(r300ContextPtr rmesa);
+
+extern void r300_setup_textures(GLcontext *ctx);
+extern void r300_setup_rs_unit(GLcontext *ctx);
+
+#endif /* __R300_STATE_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_tex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_tex.c
new file mode 100644
index 000000000..e6c8c1801
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_tex.c
@@ -0,0 +1,1051 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r300/r300_tex.c,v 1.2 2002/11/05 17:46:08 tsi Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "colormac.h"
+#include "context.h"
+#include "enums.h"
+#include "image.h"
+#include "simple_list.h"
+#include "texformat.h"
+#include "texstore.h"
+#include "texmem.h"
+#include "teximage.h"
+#include "texobj.h"
+
+#include "r300_context.h"
+#include "r300_state.h"
+#include "r300_ioctl.h"
+//#include "r300_swtcl.h"
+#include "r300_tex.h"
+
+#include "xmlpool.h"
+
+/**
+ * Set the texture wrap modes.
+ *
+ * \param t Texture object whose wrap modes are to be set
+ * \param swrap Wrap mode for the \a s texture coordinate
+ * \param twrap Wrap mode for the \a t texture coordinate
+ */
+
+static void r300SetTexWrap(r300TexObjPtr t, GLenum swrap, GLenum twrap,
+ GLenum rwrap)
+{
+ GLboolean is_clamp = GL_FALSE;
+ unsigned long hw_swrap=0, hw_twrap=0, hw_qwrap=0;
+
+ t->filter &=
+ ~(R300_TX_WRAP_S_MASK | R300_TX_WRAP_T_MASK | R300_TX_WRAP_Q_MASK);
+
+ switch (swrap) {
+ case GL_REPEAT:
+ hw_swrap |= R300_TX_REPEAT;
+ break;
+ case GL_CLAMP:
+ hw_swrap |= R300_TX_CLAMP;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_CLAMP_TO_EDGE:
+ hw_swrap |= R300_TX_CLAMP_TO_EDGE;
+ break;
+ case GL_CLAMP_TO_BORDER:
+ hw_swrap |= R300_TX_CLAMP_TO_BORDER;
+ break;
+ case GL_MIRRORED_REPEAT:
+ hw_swrap |= R300_TX_REPEAT | R300_TX_MIRRORED;
+ break;
+ case GL_MIRROR_CLAMP_EXT:
+ hw_swrap |= R300_TX_CLAMP | R300_TX_MIRRORED;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_MIRROR_CLAMP_TO_EDGE_EXT:
+ hw_swrap |= R300_TX_CLAMP_TO_EDGE | R300_TX_MIRRORED;
+ break;
+ case GL_MIRROR_CLAMP_TO_BORDER_EXT:
+ hw_swrap |= R300_TX_CLAMP_TO_BORDER | R300_TX_MIRRORED;
+ break;
+ default:
+ _mesa_problem(NULL, "bad S wrap mode in %s", __FUNCTION__);
+ }
+
+ switch (twrap) {
+ case GL_REPEAT:
+ hw_twrap |= R300_TX_REPEAT;
+ break;
+ case GL_CLAMP:
+ hw_twrap |= R300_TX_CLAMP;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_CLAMP_TO_EDGE:
+ hw_twrap |= R300_TX_CLAMP_TO_EDGE;
+ break;
+ case GL_CLAMP_TO_BORDER:
+ hw_twrap |= R300_TX_CLAMP_TO_BORDER;
+ break;
+ case GL_MIRRORED_REPEAT:
+ hw_twrap |= R300_TX_REPEAT | R300_TX_MIRRORED;
+ break;
+ case GL_MIRROR_CLAMP_EXT:
+ hw_twrap |= R300_TX_CLAMP | R300_TX_MIRRORED;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_MIRROR_CLAMP_TO_EDGE_EXT:
+ hw_twrap |= R300_TX_CLAMP_TO_EDGE | R300_TX_MIRRORED;
+ break;
+ case GL_MIRROR_CLAMP_TO_BORDER_EXT:
+ hw_twrap |= R300_TX_CLAMP_TO_BORDER | R300_TX_MIRRORED;
+ break;
+ default:
+ _mesa_problem(NULL, "bad T wrap mode in %s", __FUNCTION__);
+ }
+
+ switch (rwrap) {
+ case GL_REPEAT:
+ hw_qwrap |= R300_TX_REPEAT;
+ break;
+ case GL_CLAMP:
+ hw_qwrap |= R300_TX_CLAMP;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_CLAMP_TO_EDGE:
+ hw_qwrap |= R300_TX_CLAMP_TO_EDGE;
+ break;
+ case GL_CLAMP_TO_BORDER:
+ hw_qwrap |= R300_TX_CLAMP_TO_BORDER;
+ break;
+ case GL_MIRRORED_REPEAT:
+ hw_qwrap |= R300_TX_REPEAT | R300_TX_MIRRORED;
+ break;
+ case GL_MIRROR_CLAMP_EXT:
+ hw_qwrap |= R300_TX_CLAMP | R300_TX_MIRRORED;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_MIRROR_CLAMP_TO_EDGE_EXT:
+ hw_qwrap |= R300_TX_CLAMP_TO_EDGE | R300_TX_MIRRORED;
+ break;
+ case GL_MIRROR_CLAMP_TO_BORDER_EXT:
+ hw_qwrap |= R300_TX_CLAMP_TO_BORDER | R300_TX_MIRRORED;
+ break;
+ default:
+ _mesa_problem(NULL, "bad R wrap mode in %s", __FUNCTION__);
+ }
+
+ t->filter |= hw_swrap << R300_TX_WRAP_S_SHIFT;
+ t->filter |= hw_twrap << R300_TX_WRAP_T_SHIFT;
+ t->filter |= hw_qwrap << R300_TX_WRAP_Q_SHIFT;
+
+#if 0
+ t->format_x &= ~R200_CLAMP_Q_MASK;
+ t->border_fallback = (is_clamp && is_clamp_to_border);
+#endif
+}
+
+static void r300SetTexMaxAnisotropy(r300TexObjPtr t, GLfloat max)
+{
+
+ t->filter &= ~R300_TX_MAX_ANISO_MASK;
+
+ if (max <= 1.0) {
+ t->filter |= R300_TX_MAX_ANISO_1_TO_1;
+ } else if (max <= 2.0) {
+ t->filter |= R300_TX_MAX_ANISO_2_TO_1;
+ } else if (max <= 4.0) {
+ t->filter |= R300_TX_MAX_ANISO_4_TO_1;
+ } else if (max <= 8.0) {
+ t->filter |= R300_TX_MAX_ANISO_8_TO_1;
+ } else {
+ t->filter |= R300_TX_MAX_ANISO_16_TO_1;
+ }
+}
+
+/**
+ * Set the texture magnification and minification modes.
+ *
+ * \param t Texture whose filter modes are to be set
+ * \param minf Texture minification mode
+ * \param magf Texture magnification mode
+ */
+
+static void r300SetTexFilter(r300TexObjPtr t, GLenum minf, GLenum magf)
+{
+ GLuint anisotropy = (t->filter & R300_TX_MAX_ANISO_MASK);
+
+ t->filter &= ~(R300_TX_MIN_FILTER_MASK | R300_TX_MAG_FILTER_MASK);
+#if 0
+ //t->format_x &= ~R200_VOLUME_FILTER_MASK;
+#endif
+
+ if (anisotropy == R300_TX_MAX_ANISO_1_TO_1) {
+ switch (minf) {
+ case GL_NEAREST:
+ t->filter |= R300_TX_MIN_FILTER_NEAREST;
+ break;
+ case GL_LINEAR:
+ t->filter |= R300_TX_MIN_FILTER_LINEAR;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ t->filter |= R300_TX_MIN_FILTER_NEAREST_MIP_NEAREST;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ t->filter |= R300_TX_MIN_FILTER_LINEAR_MIP_NEAREST;
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ t->filter |= R300_TX_MIN_FILTER_NEAREST_MIP_LINEAR;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ t->filter |= R300_TX_MIN_FILTER_LINEAR_MIP_LINEAR;
+ break;
+ }
+ } else {
+ switch (minf) {
+ case GL_NEAREST:
+ t->filter |= R300_TX_MIN_FILTER_ANISO_NEAREST;
+ break;
+ case GL_LINEAR:
+ t->filter |= R300_TX_MIN_FILTER_ANISO_LINEAR;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ case GL_LINEAR_MIPMAP_NEAREST:
+ t->filter |=
+ R300_TX_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ case GL_LINEAR_MIPMAP_LINEAR:
+ t->filter |=
+ R300_TX_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR;
+ break;
+ }
+ }
+
+ /* Note we don't have 3D mipmaps so only use the mag filter setting
+ * to set the 3D texture filter mode.
+ */
+ switch (magf) {
+ case GL_NEAREST:
+ t->filter |= R300_TX_MAG_FILTER_NEAREST;
+ /*t->format_x |= R200_VOLUME_FILTER_NEAREST;*/
+ break;
+ case GL_LINEAR:
+ t->filter |= R300_TX_MAG_FILTER_LINEAR;
+ /*t->format_x |= R200_VOLUME_FILTER_LINEAR;*/
+ break;
+ }
+}
+
+static void r300SetTexBorderColor(r300TexObjPtr t, GLubyte c[4])
+{
+ t->pp_border_color = r300PackColor(4, c[0], c[1], c[2], c[3]);
+}
+
+/**
+ * Allocate space for and load the mesa images into the texture memory block.
+ * This will happen before drawing with a new texture, or drawing with a
+ * texture after it was swapped out or teximaged again.
+ */
+
+static r300TexObjPtr r300AllocTexObj(struct gl_texture_object *texObj)
+{
+ r300TexObjPtr t;
+
+ t = CALLOC_STRUCT(r300_tex_obj);
+ texObj->DriverData = t;
+ if (t != NULL) {
+ if (RADEON_DEBUG & DEBUG_TEXTURE) {
+ fprintf(stderr, "%s( %p, %p )\n", __FUNCTION__,
+ (void *)texObj, (void *)t);
+ }
+
+ /* Initialize non-image-dependent parts of the state:
+ */
+ t->base.tObj = texObj;
+ t->border_fallback = GL_FALSE;
+
+ make_empty_list(&t->base);
+
+ r300SetTexWrap(t, texObj->WrapS, texObj->WrapT, texObj->WrapR);
+ r300SetTexMaxAnisotropy(t, texObj->MaxAnisotropy);
+ r300SetTexFilter(t, texObj->MinFilter, texObj->MagFilter);
+ r300SetTexBorderColor(t, texObj->_BorderChan);
+ }
+
+ return t;
+}
+
+static const struct gl_texture_format *r300ChooseTextureFormat(GLcontext * ctx,
+ GLint
+ internalFormat,
+ GLenum format,
+ GLenum type)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ const GLboolean do32bpt =
+ (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32);
+ const GLboolean force16bpt =
+ (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16);
+ (void)format;
+
+#if 0
+ fprintf(stderr, "InternalFormat=%s(%d) type=%s format=%s\n",
+ _mesa_lookup_enum_by_nr(internalFormat), internalFormat,
+ _mesa_lookup_enum_by_nr(type),
+ _mesa_lookup_enum_by_nr(format));
+ fprintf(stderr, "do32bpt=%d force16bpt=%d\n",
+ do32bpt, force16bpt);
+#endif
+
+ switch (internalFormat) {
+ case 4:
+ case GL_RGBA:
+ case GL_COMPRESSED_RGBA:
+ switch (type) {
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return do32bpt ? _dri_texformat_argb8888 :
+ _dri_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return _dri_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return _dri_texformat_argb1555;
+ default:
+ return do32bpt ? _dri_texformat_rgba8888 :
+ _dri_texformat_argb4444;
+ }
+
+ case 3:
+ case GL_RGB:
+ case GL_COMPRESSED_RGB:
+ switch (type) {
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return _dri_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return _dri_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ return _dri_texformat_rgb565;
+ default:
+ return do32bpt ? _dri_texformat_rgba8888 :
+ _dri_texformat_rgb565;
+ }
+
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return !force16bpt ?
+ _dri_texformat_rgba8888 : _dri_texformat_argb4444;
+
+ case GL_RGBA4:
+ case GL_RGBA2:
+ return _dri_texformat_argb4444;
+
+ case GL_RGB5_A1:
+ return _dri_texformat_argb1555;
+
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ return !force16bpt ? _dri_texformat_rgba8888 :
+ _dri_texformat_rgb565;
+
+ case GL_RGB5:
+ case GL_RGB4:
+ case GL_R3_G3_B2:
+ return _dri_texformat_rgb565;
+
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ case GL_COMPRESSED_ALPHA:
+ return _dri_texformat_a8;
+
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ case GL_COMPRESSED_LUMINANCE:
+ return _dri_texformat_l8;
+
+ 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_COMPRESSED_LUMINANCE_ALPHA:
+ return _dri_texformat_al88;
+
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case GL_COMPRESSED_INTENSITY:
+ return _dri_texformat_i8;
+
+ case GL_YCBCR_MESA:
+ if (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
+ type == GL_UNSIGNED_BYTE)
+ return &_mesa_texformat_ycbcr;
+ else
+ return &_mesa_texformat_ycbcr_rev;
+
+ default:
+ _mesa_problem(ctx,
+ "unexpected internalFormat 0x%x in r300ChooseTextureFormat",
+ (int)internalFormat);
+ return NULL;
+ }
+
+ return NULL; /* never get here */
+}
+
+static GLboolean
+r300ValidateClientStorage(GLcontext * ctx, GLenum target,
+ GLint internalFormat,
+ GLint srcWidth, GLint srcHeight,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+
+ if (0)
+ fprintf(stderr, "intformat %s format %s type %s\n",
+ _mesa_lookup_enum_by_nr(internalFormat),
+ _mesa_lookup_enum_by_nr(format),
+ _mesa_lookup_enum_by_nr(type));
+
+ if (!ctx->Unpack.ClientStorage)
+ return 0;
+
+ if (ctx->_ImageTransferState ||
+ texImage->IsCompressed || texObj->GenerateMipmap)
+ return 0;
+
+ /* This list is incomplete, may be different on ppc???
+ */
+ switch (internalFormat) {
+ case GL_RGBA:
+ if (format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV) {
+ texImage->TexFormat = _dri_texformat_argb8888;
+ } else
+ return 0;
+ break;
+
+ case GL_RGB:
+ if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) {
+ texImage->TexFormat = _dri_texformat_rgb565;
+ } else
+ return 0;
+ break;
+
+ case GL_YCBCR_MESA:
+ if (format == GL_YCBCR_MESA &&
+ type == GL_UNSIGNED_SHORT_8_8_REV_APPLE) {
+ texImage->TexFormat = &_mesa_texformat_ycbcr_rev;
+ } else if (format == GL_YCBCR_MESA &&
+ (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
+ type == GL_UNSIGNED_BYTE)) {
+ texImage->TexFormat = &_mesa_texformat_ycbcr;
+ } else
+ return 0;
+ break;
+
+ default:
+ return 0;
+ }
+
+ /* Could deal with these packing issues, but currently don't:
+ */
+ if (packing->SkipPixels ||
+ packing->SkipRows || packing->SwapBytes || packing->LsbFirst) {
+ return 0;
+ }
+
+ {
+ GLint srcRowStride = _mesa_image_row_stride(packing, srcWidth,
+ format, type);
+
+ if (0)
+ fprintf(stderr, "%s: srcRowStride %d/%x\n",
+ __FUNCTION__, srcRowStride, srcRowStride);
+
+ /* Could check this later in upload, pitch restrictions could be
+ * relaxed, but would need to store the image pitch somewhere,
+ * as packing details might change before image is uploaded:
+ */
+ if (!r300IsGartMemory(rmesa, pixels, srcHeight * srcRowStride)
+ || (srcRowStride & 63))
+ return 0;
+
+ /* Have validated that _mesa_transfer_teximage would be a straight
+ * memcpy at this point. NOTE: future calls to TexSubImage will
+ * overwrite the client data. This is explicitly mentioned in the
+ * extension spec.
+ */
+ texImage->Data = (void *)pixels;
+ texImage->IsClientData = GL_TRUE;
+ texImage->RowStride =
+ srcRowStride / texImage->TexFormat->TexelBytes;
+
+ return 1;
+ }
+}
+
+static void r300TexImage1D(GLcontext * ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type, const GLvoid * pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ driTextureObject *t = (driTextureObject *) texObj->DriverData;
+
+ if (t) {
+ driSwapOutTextureObject(t);
+ } else {
+ t = (driTextureObject *) r300AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
+ return;
+ }
+ }
+
+ /* Note, this will call ChooseTextureFormat */
+ _mesa_store_teximage1d(ctx, target, level, internalFormat,
+ width, border, format, type, pixels,
+ &ctx->Unpack, texObj, texImage);
+
+ t->dirty_images[0] |= (1 << level);
+}
+
+static void r300TexSubImage1D(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)
+{
+ driTextureObject *t = (driTextureObject *) texObj->DriverData;
+
+ assert(t); /* this _should_ be true */
+ if (t) {
+ driSwapOutTextureObject(t);
+ } else {
+ t = (driTextureObject *) r300AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
+ return;
+ }
+ }
+
+ _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
+ format, type, pixels, packing, texObj,
+ texImage);
+
+ t->dirty_images[0] |= (1 << level);
+}
+
+static void r300TexImage2D(GLcontext * ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid * pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ driTextureObject *t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face =
+ (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ if (t != NULL) {
+ driSwapOutTextureObject(t);
+ } else {
+ t = (driTextureObject *) r300AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ }
+
+ texImage->IsClientData = GL_FALSE;
+
+ if (r300ValidateClientStorage(ctx, target,
+ internalFormat,
+ width, height,
+ format, type, pixels,
+ packing, texObj, texImage)) {
+ if (RADEON_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: Using client storage\n",
+ __FUNCTION__);
+ } else {
+ if (RADEON_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: Using normal storage\n",
+ __FUNCTION__);
+
+ /* Normal path: copy (to cached memory) and eventually upload
+ * via another copy to GART memory and then a blit... Could
+ * eliminate one copy by going straight to (permanent) GART.
+ *
+ * Note, this will call r300ChooseTextureFormat.
+ */
+ _mesa_store_teximage2d(ctx, target, level, internalFormat,
+ width, height, border, format, type,
+ pixels, &ctx->Unpack, texObj, texImage);
+
+ t->dirty_images[face] |= (1 << level);
+ }
+}
+
+static void r300TexSubImage2D(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)
+{
+ driTextureObject *t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face =
+ (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ assert(t); /* this _should_ be true */
+ if (t) {
+ driSwapOutTextureObject(t);
+ } else {
+ t = (driTextureObject *) r300AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
+ return;
+ }
+ }
+
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
+
+ t->dirty_images[face] |= (1 << level);
+}
+
+#if ENABLE_HW_3D_TEXTURE
+static void r300TexImage3D(GLcontext * ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint depth,
+ GLint border,
+ GLenum format, GLenum type, const GLvoid * pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ driTextureObject *t = (driTextureObject *) texObj->DriverData;
+
+ if (t) {
+ driSwapOutTextureObject(t);
+ } else {
+ t = (driTextureObject *) r300AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
+ return;
+ }
+ }
+
+ texImage->IsClientData = GL_FALSE;
+
+#if 0
+ if (r300ValidateClientStorage(ctx, target,
+ internalFormat,
+ width, height,
+ format, type, pixels,
+ packing, texObj, texImage)) {
+ if (RADEON_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: Using client storage\n",
+ __FUNCTION__);
+ } else
+#endif
+ {
+ if (RADEON_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: Using normal storage\n",
+ __FUNCTION__);
+
+ /* Normal path: copy (to cached memory) and eventually upload
+ * via another copy to GART memory and then a blit... Could
+ * eliminate one copy by going straight to (permanent) GART.
+ *
+ * Note, this will call r300ChooseTextureFormat.
+ */
+ _mesa_store_teximage3d(ctx, target, level, internalFormat,
+ width, height, depth, border,
+ format, type, pixels,
+ &ctx->Unpack, texObj, texImage);
+
+ t->dirty_images[0] |= (1 << level);
+ }
+}
+#endif
+
+#if ENABLE_HW_3D_TEXTURE
+static void
+r300TexSubImage3D(GLcontext * ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type,
+ const GLvoid * pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ driTextureObject *t = (driTextureObject *) texObj->DriverData;
+
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ assert(t); /* this _should_ be true */
+ if (t) {
+ driSwapOutTextureObject(t);
+ } else {
+ t = (driTextureObject *) r300AllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D");
+ return;
+ }
+ texObj->DriverData = t;
+ }
+
+ _mesa_store_texsubimage3d(ctx, target, level, xoffset, yoffset, zoffset,
+ width, height, depth,
+ format, type, pixels, packing, texObj,
+ texImage);
+
+ t->dirty_images[0] |= (1 << level);
+}
+#endif
+
+static void r300TexEnv(GLcontext * ctx, GLenum target,
+ GLenum pname, const GLfloat * param)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ GLuint unit = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+ if (RADEON_DEBUG & DEBUG_STATE) {
+ fprintf(stderr, "%s( %s )\n",
+ __FUNCTION__, _mesa_lookup_enum_by_nr(pname));
+ }
+
+ /* This is incorrect: Need to maintain this data for each of
+ * GL_TEXTURE_{123}D, GL_TEXTURE_RECTANGLE_NV, etc, and switch
+ * between them according to _ReallyEnabled.
+ */
+ switch (pname) {
+ case GL_TEXTURE_ENV_COLOR:{
+ WARN_ONCE("I am broken - Fixme !\n");
+ /*
+ GLubyte c[4];
+ GLuint envColor;
+ UNCLAMPED_FLOAT_TO_RGBA_CHAN(c, texUnit->EnvColor);
+ envColor = radeonPackColor(4, c[0], c[1], c[2], c[3]);
+ if (rmesa->hw.tf.cmd[TF_TFACTOR_0 + unit] != envColor) {
+ R200_STATECHANGE(rmesa, tf);
+ rmesa->hw.tf.cmd[TF_TFACTOR_0 + unit] =
+ envColor;
+ }
+ break;
+ */}
+
+ case GL_TEXTURE_LOD_BIAS_EXT:{
+ GLfloat bias, min;
+ GLuint b;
+
+ /* The R300's LOD bias is a signed 2's complement value with a
+ * range of -16.0 <= bias < 16.0.
+ *
+ * NOTE: Add a small bias to the bias for conform mipsel.c test.
+ */
+ bias = *param + .01;
+ min =
+ driQueryOptionb(&rmesa->radeon.optionCache,
+ "no_neg_lod_bias") ? 0.0 : -16.0;
+ bias = CLAMP(bias, min, 16.0);
+
+ /* 0.0 - 16.0 == 0x0 - 0x1000 */
+ /* 0.0 - -16.0 == 0x1001 - 0x1fff */
+ b = 0x1000 / 16.0 * bias;
+ b &= R300_LOD_BIAS_MASK;
+
+ if(b != (rmesa->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+unit] & R300_LOD_BIAS_MASK)){
+ R300_STATECHANGE(rmesa, tex.unknown1);
+ rmesa->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+unit] &= ~R300_LOD_BIAS_MASK;
+ rmesa->hw.tex.unknown1.cmd[R300_TEX_VALUE_0+unit] |= b;
+ }
+ break;
+ }
+
+ default:
+ return;
+ }
+}
+
+/**
+ * Changes variables and flags for a state update, which will happen at the
+ * next UpdateTextureState
+ */
+
+static void r300TexParameter(GLcontext * ctx, GLenum target,
+ struct gl_texture_object *texObj,
+ GLenum pname, const GLfloat * params)
+{
+ r300TexObjPtr t = (r300TexObjPtr) texObj->DriverData;
+
+ if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_TEXTURE)) {
+ fprintf(stderr, "%s( %s )\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(pname));
+ }
+
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+ r300SetTexMaxAnisotropy(t, texObj->MaxAnisotropy);
+ r300SetTexFilter(t, texObj->MinFilter, texObj->MagFilter);
+ break;
+
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ case GL_TEXTURE_WRAP_R:
+ r300SetTexWrap(t, texObj->WrapS, texObj->WrapT, texObj->WrapR);
+ break;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ r300SetTexBorderColor(t, texObj->_BorderChan);
+ break;
+
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ /* This isn't the most efficient solution but there doesn't appear to
+ * be a nice alternative. Since there's no LOD clamping,
+ * we just have to rely on loading the right subset of mipmap levels
+ * to simulate a clamped LOD.
+ */
+ driSwapOutTextureObject((driTextureObject *) t);
+ break;
+
+ default:
+ return;
+ }
+
+ /* Mark this texobj as dirty (one bit per tex unit)
+ */
+ t->dirty_state = TEX_ALL;
+}
+
+static void r300BindTexture(GLcontext * ctx, GLenum target,
+ struct gl_texture_object *texObj)
+{
+ if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_TEXTURE)) {
+ fprintf(stderr, "%s( %p ) unit=%d\n", __FUNCTION__,
+ (void *)texObj, ctx->Texture.CurrentUnit);
+ }
+
+ if ((target == GL_TEXTURE_1D)
+ || (target == GL_TEXTURE_2D)
+#if ENABLE_HW_3D_TEXTURE
+ || (target == GL_TEXTURE_3D)
+#endif
+ || (target == GL_TEXTURE_CUBE_MAP)
+ || (target == GL_TEXTURE_RECTANGLE_NV)) {
+ assert(texObj->DriverData != NULL);
+ }
+}
+
+static void r300DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ driTextureObject *t = (driTextureObject *) texObj->DriverData;
+
+ if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_TEXTURE)) {
+ fprintf(stderr, "%s( %p (target = %s) )\n", __FUNCTION__,
+ (void *)texObj,
+ _mesa_lookup_enum_by_nr(texObj->Target));
+ }
+
+ if (t != NULL) {
+ if (rmesa) {
+ R300_FIREVERTICES(rmesa);
+ }
+
+ driDestroyTextureObject(t);
+ }
+ /* Free mipmap images and the texture object itself */
+ _mesa_delete_texture_object(ctx, texObj);
+}
+
+/* Need:
+ * - Same GEN_MODE for all active bits
+ * - Same EyePlane/ObjPlane for all active bits when using Eye/Obj
+ * - STRQ presumably all supported (matrix means incoming R values
+ * can end up in STQ, this has implications for vertex support,
+ * presumably ok if maos is used, though?)
+ *
+ * Basically impossible to do this on the fly - just collect some
+ * basic info & do the checks from ValidateState().
+ */
+static void r300TexGen(GLcontext * ctx,
+ GLenum coord, GLenum pname, const GLfloat * params)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ GLuint unit = ctx->Texture.CurrentUnit;
+#if 0 /* Disable this for now - looks like we will be recalculating everything
+ anyway */
+ rmesa->recheck_texgen[unit] = GL_TRUE;
+#endif
+}
+
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
+ * Note: this function will be called during context creation to
+ * allocate the default texture objects.
+ * Note: we could use containment here to 'derive' the driver-specific
+ * texture object from the core mesa gl_texture_object. Not done at this time.
+ * Fixup MaxAnisotropy according to user preference.
+ */
+static struct gl_texture_object *r300NewTextureObject(GLcontext * ctx,
+ GLuint name,
+ GLenum target)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ struct gl_texture_object *obj;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ if (!obj)
+ return NULL;
+ obj->MaxAnisotropy = rmesa->initialMaxAnisotropy;
+
+ r300AllocTexObj(obj);
+ return obj;
+}
+
+void r300InitTextureFuncs(struct dd_function_table *functions)
+{
+ /* Note: we only plug in the functions we implement in the driver
+ * since _mesa_init_driver_functions() was already called.
+ */
+ functions->ChooseTextureFormat = r300ChooseTextureFormat;
+ functions->TexImage1D = r300TexImage1D;
+ functions->TexImage2D = r300TexImage2D;
+#if ENABLE_HW_3D_TEXTURE
+ functions->TexImage3D = r300TexImage3D;
+#else
+ functions->TexImage3D = _mesa_store_teximage3d;
+#endif
+ functions->TexSubImage1D = r300TexSubImage1D;
+ functions->TexSubImage2D = r300TexSubImage2D;
+#if ENABLE_HW_3D_TEXTURE
+ functions->TexSubImage3D = r300TexSubImage3D;
+#else
+ functions->TexSubImage3D = _mesa_store_texsubimage3d;
+#endif
+ functions->NewTextureObject = r300NewTextureObject;
+ functions->BindTexture = r300BindTexture;
+ functions->DeleteTexture = r300DeleteTexture;
+ functions->IsTextureResident = driIsTextureResident;
+
+ functions->TexEnv = r300TexEnv;
+ functions->TexParameter = r300TexParameter;
+ functions->TexGen = r300TexGen;
+
+ driInitTextureFormats();
+
+#if 0
+ /* moved or obsolete code */
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ driInitTextureObjects(ctx, &rmesa->swapped,
+ DRI_TEXMGR_DO_TEXTURE_1D
+ | DRI_TEXMGR_DO_TEXTURE_2D);
+
+ /* Hack: r300NewTextureObject is not yet installed when the
+ * default textures are created. Therefore set MaxAnisotropy of the
+ * default 2D texture now. */
+ ctx->Shared->Default2D->MaxAnisotropy =
+ driQueryOptionf(&rmesa->optionCache, "def_max_anisotropy");
+#endif
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_tex.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_tex.h
new file mode 100644
index 000000000..a18ff0e2c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_tex.h
@@ -0,0 +1,51 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r300/r300_tex.h,v 1.1 2002/10/30 12:51:53 alanh Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __r300_TEX_H__
+#define __r300_TEX_H__
+
+#ifdef GLX_DIRECT_RENDERING
+
+extern void r300UpdateTextureState(GLcontext * ctx);
+
+extern int r300UploadTexImages(r300ContextPtr rmesa, r300TexObjPtr t,
+ GLuint face);
+
+extern void r300DestroyTexObj(r300ContextPtr rmesa, r300TexObjPtr t);
+
+extern void r300InitTextureFuncs(struct dd_function_table *functions);
+
+#endif
+#endif /* __r300_TEX_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_texmem.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_texmem.c
new file mode 100644
index 000000000..5c70e2e3c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_texmem.c
@@ -0,0 +1,514 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r300/r300_texmem.c,v 1.5 2002/12/17 00:32:56 dawes Exp $ */
+/**************************************************************************
+
+Copyright (C) Tungsten Graphics 2002. All Rights Reserved.
+The Weather Channel, Inc. funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86
+license. This notice must be preserved.
+
+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, VA LINUX SYSTEMS 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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#include <errno.h>
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "colormac.h"
+#include "macros.h"
+#include "simple_list.h"
+#include "radeon_reg.h" /* gets definition for usleep */
+#include "r300_context.h"
+#include "r300_state.h"
+#include "r300_cmdbuf.h"
+#include "radeon_ioctl.h"
+/*
+#include "r300_swtcl.h"
+*/
+#include "r300_tex.h"
+#include "r300_ioctl.h"
+#include <unistd.h> /* for usleep() */
+
+/**
+ * Destroy any device-dependent state associated with the texture. This may
+ * include NULLing out hardware state that points to the texture.
+ */
+void r300DestroyTexObj(r300ContextPtr rmesa, r300TexObjPtr t)
+{
+ if (RADEON_DEBUG & DEBUG_TEXTURE) {
+ fprintf(stderr, "%s( %p, %p )\n", __FUNCTION__,
+ (void *)t, (void *)t->base.tObj);
+ }
+
+ if (rmesa != NULL) {
+ unsigned i;
+
+ for (i = 0; i < rmesa->radeon.glCtx->Const.MaxTextureUnits; i++) {
+ if (t == rmesa->state.texture.unit[i].texobj) {
+ rmesa->state.texture.unit[i].texobj = NULL;
+ /* This code below is meant to shorten state
+ pushed to the hardware by not programming
+ unneeded units.
+
+ This does not appear to be worthwhile on R300 */
+#if 0
+ remove_from_list(&rmesa->hw.tex[i]);
+ make_empty_list(&rmesa->hw.tex[i]);
+ remove_from_list(&rmesa->hw.cube[i]);
+ make_empty_list(&rmesa->hw.cube[i]);
+#endif
+ }
+ }
+ }
+}
+
+/* ------------------------------------------------------------
+ * Texture image conversions
+ */
+
+static void r300UploadGARTClientSubImage(r300ContextPtr rmesa,
+ r300TexObjPtr t,
+ struct gl_texture_image *texImage,
+ GLint hwlevel,
+ GLint x, GLint y,
+ GLint width, GLint height)
+{
+ const struct gl_texture_format *texFormat = texImage->TexFormat;
+ GLuint srcPitch, dstPitch;
+ int blit_format;
+ int srcOffset;
+
+ /*
+ * XXX it appears that we always upload the full image, not a subimage.
+ * I.e. x==0, y==0, width=texWidth, height=texWidth. If this is ever
+ * changed, the src pitch will have to change.
+ */
+ switch (texFormat->TexelBytes) {
+ case 1:
+ blit_format = R200_CP_COLOR_FORMAT_CI8;
+ srcPitch = t->image[0][0].width * texFormat->TexelBytes;
+ dstPitch = t->image[0][0].width * texFormat->TexelBytes;
+ break;
+ case 2:
+ blit_format = R200_CP_COLOR_FORMAT_RGB565;
+ srcPitch = t->image[0][0].width * texFormat->TexelBytes;
+ dstPitch = t->image[0][0].width * texFormat->TexelBytes;
+ break;
+ case 4:
+ blit_format = R200_CP_COLOR_FORMAT_ARGB8888;
+ srcPitch = t->image[0][0].width * texFormat->TexelBytes;
+ dstPitch = t->image[0][0].width * texFormat->TexelBytes;
+ break;
+ default:
+ return;
+ }
+
+ t->image[0][hwlevel].data = texImage->Data;
+ srcOffset = r300GartOffsetFromVirtual(rmesa, texImage->Data);
+
+ assert(srcOffset != ~0);
+
+ /* Don't currently need to cope with small pitches?
+ */
+ width = texImage->Width;
+ height = texImage->Height;
+
+ r300EmitWait(rmesa, R300_WAIT_3D);
+
+ r300EmitBlit(rmesa, blit_format,
+ srcPitch,
+ srcOffset,
+ dstPitch,
+ t->bufAddr,
+ x,
+ y,
+ t->image[0][hwlevel].x + x,
+ t->image[0][hwlevel].y + y, width, height);
+
+ r300EmitWait(rmesa, R300_WAIT_2D);
+}
+
+static void r300UploadRectSubImage(r300ContextPtr rmesa,
+ r300TexObjPtr t,
+ struct gl_texture_image *texImage,
+ GLint x, GLint y, GLint width, GLint height)
+{
+ const struct gl_texture_format *texFormat = texImage->TexFormat;
+ int blit_format, dstPitch, done;
+
+ switch (texFormat->TexelBytes) {
+ case 1:
+ blit_format = R200_CP_COLOR_FORMAT_CI8;
+ break;
+ case 2:
+ blit_format = R200_CP_COLOR_FORMAT_RGB565;
+ break;
+ case 4:
+ blit_format = R200_CP_COLOR_FORMAT_ARGB8888;
+ break;
+ default:
+ return;
+ }
+
+ t->image[0][0].data = texImage->Data;
+
+ /* Currently don't need to cope with small pitches.
+ */
+ width = texImage->Width;
+ height = texImage->Height;
+ dstPitch = t->pitch + 32;
+
+ if (rmesa->prefer_gart_client_texturing && texImage->IsClientData) {
+ /* In this case, could also use GART texturing. This is
+ * currently disabled, but has been tested & works.
+ */
+ t->offset =
+ r300GartOffsetFromVirtual(rmesa, texImage->Data);
+ t->pitch =
+ texImage->RowStride * texFormat->TexelBytes - 32;
+
+ if (RADEON_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr,
+ "Using GART texturing for rectangular client texture\n");
+
+ /* Release FB memory allocated for this image:
+ */
+ /* FIXME This may not be correct as driSwapOutTextureObject sets
+ * FIXME dirty_images. It may be fine, though.
+ */
+ if (t->base.memBlock) {
+ driSwapOutTextureObject((driTextureObject *) t);
+ }
+ } else if (texImage->IsClientData) {
+ /* Data already in GART memory, with usable pitch.
+ */
+ GLuint srcPitch;
+ srcPitch = texImage->RowStride * texFormat->TexelBytes;
+ r300EmitBlit(rmesa,
+ blit_format,
+ srcPitch,
+ r300GartOffsetFromVirtual(rmesa, texImage->Data),
+ dstPitch, t->bufAddr, 0, 0, 0, 0, width, height);
+ } else {
+ /* Data not in GART memory, or bad pitch.
+ */
+ for (done = 0; done < height;) {
+ struct r300_dma_region region;
+ int lines =
+ MIN2(height - done, RADEON_BUFFER_SIZE / dstPitch);
+ int src_pitch;
+ char *tex;
+
+ src_pitch = texImage->RowStride * texFormat->TexelBytes;
+
+ tex = (char *)texImage->Data + done * src_pitch;
+
+ memset(&region, 0, sizeof(region));
+ r300AllocDmaRegion(rmesa, &region, lines * dstPitch,
+ 1024);
+
+ /* Copy texdata to dma:
+ */
+ if (0)
+ fprintf(stderr,
+ "%s: src_pitch %d dst_pitch %d\n",
+ __FUNCTION__, src_pitch, dstPitch);
+
+ if (src_pitch == dstPitch) {
+ memcpy(region.address + region.start, tex,
+ lines * src_pitch);
+ } else {
+ char *buf = region.address + region.start;
+ int i;
+ for (i = 0; i < lines; i++) {
+ memcpy(buf, tex, src_pitch);
+ buf += dstPitch;
+ tex += src_pitch;
+ }
+ }
+
+ r300EmitWait(rmesa, R300_WAIT_3D);
+
+ /* Blit to framebuffer
+ */
+ r300EmitBlit(rmesa,
+ blit_format,
+ dstPitch, GET_START(&region),
+ dstPitch, t->bufAddr,
+ 0, 0, 0, done, width, lines);
+
+ r300EmitWait(rmesa, R300_WAIT_2D);
+
+ r300ReleaseDmaRegion(rmesa, &region, __FUNCTION__);
+ done += lines;
+ }
+ }
+}
+
+/**
+ * Upload the texture image associated with texture \a t at the specified
+ * level at the address relative to \a start.
+ */
+static void uploadSubImage(r300ContextPtr rmesa, r300TexObjPtr t,
+ GLint hwlevel,
+ GLint x, GLint y, GLint width, GLint height,
+ GLuint face)
+{
+ struct gl_texture_image *texImage = NULL;
+ GLuint offset;
+ GLint imageWidth, imageHeight;
+ GLint ret;
+ drm_radeon_texture_t tex;
+ drm_radeon_tex_image_t tmp;
+ const int level = hwlevel + t->base.firstLevel;
+
+ if (RADEON_DEBUG & DEBUG_TEXTURE) {
+ fprintf(stderr,
+ "%s( %p, %p ) level/width/height/face = %d/%d/%d/%u\n",
+ __FUNCTION__, (void *)t, (void *)t->base.tObj, level,
+ width, height, face);
+ }
+
+ ASSERT(face < 6);
+
+ /* Ensure we have a valid texture to upload */
+ if ((hwlevel < 0) || (hwlevel >= RADEON_MAX_TEXTURE_LEVELS)) {
+ _mesa_problem(NULL, "bad texture level in %s", __FUNCTION__);
+ return;
+ }
+
+ texImage = t->base.tObj->Image[face][level];
+
+ if (!texImage) {
+ if (RADEON_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: texImage %d is NULL!\n",
+ __FUNCTION__, level);
+ return;
+ }
+ if (!texImage->Data) {
+ if (RADEON_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: image data is NULL!\n",
+ __FUNCTION__);
+ return;
+ }
+
+ if (t->base.tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
+ assert(level == 0);
+ assert(hwlevel == 0);
+ if (RADEON_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: image data is rectangular\n",
+ __FUNCTION__);
+ r300UploadRectSubImage(rmesa, t, texImage, x, y, width, height);
+ return;
+ } else if (texImage->IsClientData) {
+ if (RADEON_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr,
+ "%s: image data is in GART client storage\n",
+ __FUNCTION__);
+ r300UploadGARTClientSubImage(rmesa, t, texImage, hwlevel, x, y,
+ width, height);
+ return;
+ } else if (RADEON_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: image data is in normal memory\n",
+ __FUNCTION__);
+
+ imageWidth = texImage->Width;
+ imageHeight = texImage->Height;
+
+ offset = t->bufAddr;
+
+ if (RADEON_DEBUG & (DEBUG_TEXTURE | DEBUG_IOCTL)) {
+ GLint imageX = 0;
+ GLint imageY = 0;
+ GLint blitX = t->image[face][hwlevel].x;
+ GLint blitY = t->image[face][hwlevel].y;
+ GLint blitWidth = t->image[face][hwlevel].width;
+ GLint blitHeight = t->image[face][hwlevel].height;
+ fprintf(stderr, " upload image: %d,%d at %d,%d\n",
+ imageWidth, imageHeight, imageX, imageY);
+ fprintf(stderr, " upload blit: %d,%d at %d,%d\n",
+ blitWidth, blitHeight, blitX, blitY);
+ fprintf(stderr, " blit ofs: 0x%07x level: %d/%d\n",
+ (GLuint) offset, hwlevel, level);
+ }
+
+ t->image[face][hwlevel].data = texImage->Data;
+
+ /* Init the DRM_RADEON_TEXTURE command / drm_radeon_texture_t struct.
+ * NOTE: we're always use a 1KB-wide blit and I8 texture format.
+ * We used to use 1, 2 and 4-byte texels and used to use the texture
+ * width to dictate the blit width - but that won't work for compressed
+ * textures. (Brian)
+ */
+
+ tex.offset = offset;
+ tex.pitch = BLIT_WIDTH_BYTES / 64;
+ tex.format = R200_TXFORMAT_I8; /* any 1-byte texel format */
+#if 0 /* I am not sure HOSTDATA_BLT actually works.. Experiment here - V.D */
+ tex.format = R200_TXFORMAT_RGBA8888; /* any 4-byte texel format */
+#endif
+ if (texImage->TexFormat->TexelBytes) {
+ tex.width = imageWidth * texImage->TexFormat->TexelBytes; /* in bytes */
+ tex.height = imageHeight;
+ } else {
+ tex.width = imageWidth; /* compressed */
+ tex.height = imageHeight;
+ if (tex.height < 4)
+ tex.height = 4;
+ }
+ tex.image = &tmp;
+#if 0
+ tex.width /= 4;
+#endif
+
+ /* copy (x,y,width,height,data) */
+ memcpy(&tmp, &t->image[face][hwlevel], sizeof(tmp));
+#if 0
+ tex.image->width /=4;
+#endif
+
+#if 0
+ sleep(1);
+
+ fprintf(stderr, "*** Uploading texture\n");
+ fprintf(stderr, " offset=0x%08x\n", offset);
+ fprintf(stderr, " image width=%d height=%d\n",
+ imageWidth, imageHeight);
+ fprintf(stderr, " blit width=%d height=%d data=%p\n",
+ t->image[face][hwlevel].width,
+ t->image[face][hwlevel].height,
+ t->image[face][hwlevel].data);
+#endif
+
+ LOCK_HARDWARE(&rmesa->radeon);
+ do {
+ ret = drmCommandWriteRead(rmesa->radeon.dri.fd, DRM_RADEON_TEXTURE,
+ &tex, sizeof(drm_radeon_texture_t));
+ if (ret) {
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr,
+ "DRM_RADEON_TEXTURE: again!\n");
+ usleep(1);
+ }
+ } while (ret && errno == EAGAIN);
+
+ UNLOCK_HARDWARE(&rmesa->radeon);
+
+ if (ret) {
+ fprintf(stderr, "DRM_RADEON_TEXTURE: return = %d\n", ret);
+ fprintf(stderr, " offset=0x%08x\n", offset);
+ fprintf(stderr, " image width=%d height=%d\n",
+ imageWidth, imageHeight);
+ fprintf(stderr, " blit width=%d height=%d data=%p\n",
+ t->image[face][hwlevel].width,
+ t->image[face][hwlevel].height,
+ t->image[face][hwlevel].data);
+ exit(1);
+ }
+}
+
+/**
+ * Upload the texture images associated with texture \a t. This might
+ * require the allocation of texture memory.
+ *
+ * \param rmesa Context pointer
+ * \param t Texture to be uploaded
+ * \param face Cube map face to be uploaded. Zero for non-cube maps.
+ */
+
+int r300UploadTexImages(r300ContextPtr rmesa, r300TexObjPtr t, GLuint face)
+{
+ const int numLevels = t->base.lastLevel - t->base.firstLevel + 1;
+
+ if (RADEON_DEBUG & (DEBUG_TEXTURE | DEBUG_IOCTL)) {
+ fprintf(stderr, "%s( %p, %p ) sz=%d lvls=%d-%d\n", __FUNCTION__,
+ (void *)rmesa->radeon.glCtx, (void *)t->base.tObj,
+ t->base.totalSize, t->base.firstLevel,
+ t->base.lastLevel);
+ }
+
+ if (!t || t->base.totalSize == 0)
+ return 0;
+
+ if (RADEON_DEBUG & DEBUG_SYNC) {
+ fprintf(stderr, "%s: Syncing\n", __FUNCTION__);
+ radeonFinish(rmesa->radeon.glCtx);
+ }
+
+ LOCK_HARDWARE(&rmesa->radeon);
+
+ if (t->base.memBlock == NULL) {
+ int heap;
+
+ heap = driAllocateTexture(rmesa->texture_heaps, rmesa->nr_heaps,
+ (driTextureObject *) t);
+ if (heap == -1) {
+ UNLOCK_HARDWARE(&rmesa->radeon);
+ return -1;
+ }
+
+ /* Set the base offset of the texture image */
+ t->bufAddr = rmesa->radeon.radeonScreen->texOffset[heap]
+ + t->base.memBlock->ofs;
+ t->offset = t->bufAddr;
+
+ /* Mark this texobj as dirty on all units:
+ */
+ t->dirty_state = TEX_ALL;
+ }
+
+ /* Let the world know we've used this memory recently.
+ */
+ driUpdateTextureLRU((driTextureObject *) t);
+ UNLOCK_HARDWARE(&rmesa->radeon);
+
+ /* Upload any images that are new */
+ if (t->base.dirty_images[face]) {
+ int i;
+ for (i = 0; i < numLevels; i++) {
+ if ((t->base.
+ dirty_images[face] & (1 <<
+ (i + t->base.firstLevel))) !=
+ 0) {
+ uploadSubImage(rmesa, t, i, 0, 0,
+ t->image[face][i].width,
+ t->image[face][i].height, face);
+ }
+ }
+ t->base.dirty_images[face] = 0;
+ }
+
+ if (RADEON_DEBUG & DEBUG_SYNC) {
+ fprintf(stderr, "%s: Syncing\n", __FUNCTION__);
+ radeonFinish(rmesa->radeon.glCtx);
+ }
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_texprog.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_texprog.c
new file mode 100644
index 000000000..71d28db05
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_texprog.c
@@ -0,0 +1,270 @@
+#include "glheader.h"
+#include "state.h"
+#include "imports.h"
+#include "enums.h"
+#include "macros.h"
+#include "context.h"
+#include "dd.h"
+#include "simple_list.h"
+
+#include "api_arrayelt.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "texformat.h"
+
+#include "radeon_ioctl.h"
+#include "radeon_state.h"
+#include "r300_context.h"
+#if USE_ARB_F_P == 0
+#include "r300_ioctl.h"
+#include "r300_state.h"
+#include "r300_reg.h"
+#include "r300_program.h"
+#include "r300_emit.h"
+#include "r300_fixed_pipelines.h"
+#include "r300_tex.h"
+#include "pixel_shader.h"
+#include "r300_texprog.h"
+
+/* TODO: we probably should have a better way to emit alu instructions */
+#define INST0 p->alu.inst[p->alu.length].inst0 =
+#define INST1 p->alu.inst[p->alu.length].inst1 =
+#define INST2 p->alu.inst[p->alu.length].inst2 =
+#define INST3 p->alu.inst[p->alu.length].inst3 =
+#define EMIT_INST p->alu.length++
+
+void emit_tex(struct r300_pixel_shader_program *p, GLuint dest, GLuint unit, GLuint src)
+{
+ p->tex.inst[p->tex.length++] = 0
+ | (src << R300_FPITX_SRC_SHIFT)
+ | (dest << R300_FPITX_DST_SHIFT)
+ | (unit << R300_FPITX_IMAGE_SHIFT)
+ /* I don't know if this is needed, but the hardcoded 0x18000 set it, so I will too */
+ | (3 << 15);
+// fprintf(stderr, "emit texinst: 0x%x\n", p->tex.inst[p->tex.length-1]);
+}
+
+GLuint get_source(struct r300_pixel_shader_state *ps, GLenum src, GLuint unit, GLuint tc_reg) {
+ switch (src) {
+ case GL_TEXTURE:
+ if (!ps->have_sample) {
+ emit_tex(&ps->program, tc_reg, unit, tc_reg);
+ ps->have_sample = 1;
+ }
+ return tc_reg;
+ case GL_CONSTANT:
+ WARN_ONCE("TODO: Implement envcolor\n");
+ return ps->color_reg;
+ case GL_PRIMARY_COLOR:
+ return ps->color_reg;
+ case GL_PREVIOUS:
+ return ps->src_previous;
+ default:
+ WARN_ONCE("Unknown source enum\n");
+ return ps->src_previous;
+ }
+}
+
+GLuint get_temp(struct r300_pixel_shader_program *p)
+{
+ return p->temp_register_count++;
+}
+
+inline void emit_texenv_color(r300ContextPtr r300, struct r300_pixel_shader_state *ps,
+ GLuint out, GLenum envmode, GLenum format, GLuint unit, GLuint tc_reg) {
+ struct r300_pixel_shader_program *p = &ps->program;
+
+ const GLuint Cp = get_source(ps, GL_PREVIOUS, unit, tc_reg);
+ const GLuint Cs = get_source(ps, GL_TEXTURE, unit, tc_reg);
+
+ switch(envmode) {
+ case GL_DECAL: /* TODO */
+ case GL_BLEND: /* TODO */
+ case GL_REPLACE:
+ INST0 EASY_PFS_INSTR0(MAD, SRC0C_XYZ, ONE, ZERO);
+ switch (format) {
+ case GL_ALPHA:
+ // Cv = Cp
+ INST1 EASY_PFS_INSTR1(out, Cp, PFS_FLAG_CONST, PFS_FLAG_CONST, ALL, NONE);
+ break;
+ default:
+ // Cv = Cs
+ INST1 EASY_PFS_INSTR1(out, Cs, PFS_FLAG_CONST, PFS_FLAG_CONST, ALL, NONE);
+ break;
+ }
+ break;
+ case GL_MODULATE:
+ switch (format) {
+ case GL_ALPHA:
+ // Cv = Cp
+ INST0 EASY_PFS_INSTR0(MAD, SRC0C_XYZ, ONE, ZERO);
+ INST1 EASY_PFS_INSTR1(out, Cp, PFS_FLAG_CONST, PFS_FLAG_CONST, ALL, NONE);
+ break;
+ default:
+ // Cv = CpCs
+ INST0 EASY_PFS_INSTR0(MAD, SRC0C_XYZ, SRC1C_XYZ, ZERO);
+ INST1 EASY_PFS_INSTR1(out, Cp, Cs, PFS_FLAG_CONST, ALL, NONE);
+ break;
+ }
+ break;
+ case GL_ADD:
+ switch (format) {
+ case GL_ALPHA:
+ // Cv = Cp
+ INST0 EASY_PFS_INSTR0(MAD, SRC0C_XYZ, ONE, ZERO);
+ INST1 EASY_PFS_INSTR1(out, Cp, PFS_FLAG_CONST, PFS_FLAG_CONST, ALL, NONE);
+ break;
+ default:
+ // Cv = Cp + Cs
+ INST0 EASY_PFS_INSTR0(MAD, SRC0C_XYZ, ONE, SRC1C_XYZ);
+ INST1 EASY_PFS_INSTR1(out, Cp, Cs, PFS_FLAG_CONST, ALL, NONE);
+ break;
+ }
+ break;
+ default:
+ fprintf(stderr, "%s: should never get here!\n", __func__);
+ break;
+ }
+
+ return;
+}
+
+inline void emit_texenv_alpha(r300ContextPtr r300, struct r300_pixel_shader_state *ps,
+ GLuint out, GLenum envmode, GLenum format, GLuint unit, GLuint tc_reg) {
+ struct r300_pixel_shader_program *p = &ps->program;
+
+ const GLuint Ap = get_source(ps, GL_PREVIOUS, unit, tc_reg);
+ const GLuint As = get_source(ps, GL_TEXTURE, unit, tc_reg);
+
+ switch(envmode) {
+ case GL_DECAL: /* TODO */
+ case GL_BLEND: /* TODO */
+ case GL_REPLACE:
+ INST2 EASY_PFS_INSTR2(MAD, SRC0A, ONE, ZERO);
+ switch (format) {
+ case GL_LUMINANCE:
+ case GL_RGB:
+ // Av = Ap
+ INST3 EASY_PFS_INSTR3(out, Ap, PFS_FLAG_CONST, PFS_FLAG_CONST, REG);
+ break;
+ default:
+ INST3 EASY_PFS_INSTR3(out, As, PFS_FLAG_CONST, PFS_FLAG_CONST, REG);
+ break;
+ }
+ break;
+ case GL_MODULATE:
+ case GL_ADD:
+ switch (format) {
+ case GL_LUMINANCE:
+ case GL_RGB:
+ // Av = Ap
+ INST2 EASY_PFS_INSTR2(MAD, SRC0A, ONE, ZERO);
+ INST3 EASY_PFS_INSTR3(out, Ap, PFS_FLAG_CONST, PFS_FLAG_CONST, REG);
+ break;
+ default:
+ // Av = ApAs
+ INST2 EASY_PFS_INSTR2(MAD, SRC0A, SRC1A, ZERO);
+ INST3 EASY_PFS_INSTR3(out, Ap, As, PFS_FLAG_CONST, REG);
+ break;
+ }
+ break;
+ default:
+ fprintf(stderr, "%s: should never get here!\n", __func__);
+ break;
+ }
+
+ return;
+}
+
+GLuint emit_texenv(r300ContextPtr r300, GLuint tc_reg, GLuint unit)
+{
+ struct r300_pixel_shader_state *ps = &r300->state.pixel_shader;
+ struct r300_pixel_shader_program *p = &ps->program;
+ GLcontext *ctx = r300->radeon.glCtx;
+ struct gl_texture_object *texobj = ctx->Texture.Unit[unit]._Current;
+ GLenum envmode = ctx->Texture.Unit[unit].EnvMode;
+ GLenum format = texobj->Image[0][texobj->BaseLevel]->Format;
+
+ const GLuint out = tc_reg;
+ const GLuint Cf = get_source(ps, GL_PRIMARY_COLOR, unit, tc_reg);
+
+ WARN_ONCE("Texture environments are currently incomplete / wrong! Help me!\n");
+// fprintf(stderr, "EnvMode = %s\n", _mesa_lookup_enum_by_nr(ctx->Texture.Unit[unit].EnvMode));
+
+ switch (envmode) {
+ case GL_REPLACE:
+ case GL_MODULATE:
+ case GL_DECAL:
+ case GL_BLEND:
+ case GL_ADD:
+ /* Maybe these should be combined? I thought it'd be messy */
+ emit_texenv_color(r300, ps, out, envmode, format, unit, tc_reg);
+ emit_texenv_alpha(r300, ps, out, envmode, format, unit, tc_reg);
+ EMIT_INST;
+ return out;
+ break;
+ case GL_COMBINE:
+ WARN_ONCE("EnvMode == GL_COMBINE unsupported! Help Me!!\n");
+ return get_source(ps, GL_TEXTURE, unit, tc_reg);
+ break;
+ default:
+ WARN_ONCE("Unknown EnvMode == %d, name=%s\n", envmode,
+ _mesa_lookup_enum_by_nr(envmode));
+ return get_source(ps, GL_TEXTURE, unit, tc_reg);
+ break;
+ }
+
+}
+
+void r300GenerateTextureFragmentShader(r300ContextPtr r300)
+{
+ struct r300_pixel_shader_state *ps = &r300->state.pixel_shader;
+ struct r300_pixel_shader_program *p = &ps->program;
+ GLcontext *ctx = r300->radeon.glCtx;
+ int i, tc_reg;
+ GLuint OutputsWritten;
+
+ if(hw_tcl_on)
+ OutputsWritten = CURRENT_VERTEX_SHADER(ctx)->OutputsWritten;
+
+ p->tex.length = 0;
+ p->alu.length = 0;
+ p->active_nodes = 1;
+ p->first_node_has_tex = 1;
+ p->temp_register_count = r300->state.texture.tc_count + 1; /* texcoords and colour reg */
+
+ ps->color_reg = r300->state.texture.tc_count;
+ ps->src_previous = ps->color_reg;
+
+ tc_reg = 0;
+ for (i=0;i<ctx->Const.MaxTextureUnits;i++) {
+ if (TMU_ENABLED(ctx, i)) {
+ ps->have_sample = 0;
+ ps->src_previous = emit_texenv(r300, tc_reg, i);
+ tc_reg++;
+ }
+ }
+
+/* Do a MOV from last output, to destination reg.. This won't be needed when we
+ * have a better way of emitting alu instructions
+ */
+ INST0 EASY_PFS_INSTR0(MAD, SRC0C_XYZ, ONE, ZERO);
+ INST1 EASY_PFS_INSTR1(0, ps->src_previous, PFS_FLAG_CONST, PFS_FLAG_CONST, NONE, ALL);
+ INST2 EASY_PFS_INSTR2(MAD, SRC0A, ONE, ZERO);
+ INST3 EASY_PFS_INSTR3(0, ps->src_previous, PFS_FLAG_CONST, PFS_FLAG_CONST, OUTPUT);
+ EMIT_INST;
+
+ p->node[3].tex_end = ps->program.tex.length - 1;
+ p->node[3].tex_offset = 0;
+ p->node[3].alu_end = ps->program.alu.length - 1;
+ p->node[3].alu_offset = 0;
+
+ p->tex_end = ps->program.tex.length - 1;
+ p->tex_offset = 0;
+ p->alu_end = ps->program.alu.length - 1;
+ p->alu_offset = 0;
+}
+#endif // USE_ARB_F_P == 0
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_texprog.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_texprog.h
new file mode 100644
index 000000000..4e91a1169
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_texprog.h
@@ -0,0 +1,9 @@
+#ifndef __R300_TEXPROG_H_
+#define __R300_TEXPROG_H_
+
+#include "r300_context.h"
+
+void r300GenerateTextureFragmentShader(r300ContextPtr r300);
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_texstate.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_texstate.c
new file mode 100644
index 000000000..b06629ca1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_texstate.c
@@ -0,0 +1,1465 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r300/r300_texstate.c,v 1.3 2003/02/15 22:18:47 dawes Exp $ */
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "macros.h"
+#include "texformat.h"
+#include "enums.h"
+
+#include "r300_context.h"
+#include "r300_state.h"
+#include "r300_ioctl.h"
+#include "radeon_ioctl.h"
+//#include "r300_swtcl.h"
+#include "r300_tex.h"
+//#include "r300_tcl.h"
+#include "r300_reg.h"
+
+#define R200_TXFORMAT_A8 R200_TXFORMAT_I8
+#define R200_TXFORMAT_L8 R200_TXFORMAT_I8
+#define R200_TXFORMAT_AL88 R200_TXFORMAT_AI88
+#define R200_TXFORMAT_YCBCR R200_TXFORMAT_YVYU422
+#define R200_TXFORMAT_YCBCR_REV R200_TXFORMAT_VYUY422
+
+#define _COLOR(f) \
+ [ MESA_FORMAT_ ## f ] = { R200_TXFORMAT_ ## f, 0 }
+#define _COLOR_REV(f) \
+ [ MESA_FORMAT_ ## f ## _REV ] = { R200_TXFORMAT_ ## f, 0 }
+#define _ALPHA(f) \
+ [ MESA_FORMAT_ ## f ] = { R200_TXFORMAT_ ## f | R200_TXFORMAT_ALPHA_IN_MAP, 0 }
+#define _ALPHA_REV(f) \
+ [ MESA_FORMAT_ ## f ## _REV ] = { R200_TXFORMAT_ ## f | R200_TXFORMAT_ALPHA_IN_MAP, 0 }
+#define _YUV(f) \
+ [ MESA_FORMAT_ ## f ] = { R200_TXFORMAT_ ## f, R200_YUV_TO_RGB }
+#define _INVALID(f) \
+ [ MESA_FORMAT_ ## f ] = { 0xffffffff, 0 }
+#define VALID_FORMAT(f) ( ((f) <= MESA_FORMAT_YCBCR_REV) \
+ && tx_table[f].flag )
+
+#define _ASSIGN(entry, format) \
+ [ MESA_FORMAT_ ## entry ] = { format, 0, 1}
+
+static const struct {
+ GLuint format, filter;
+} tx_table0[] = {
+ _ALPHA(RGBA8888),
+ _ALPHA_REV(RGBA8888),
+ _ALPHA(ARGB8888),
+ _ALPHA_REV(ARGB8888),
+ _INVALID(RGB888),
+ _COLOR(RGB565),
+ _COLOR_REV(RGB565),
+ _ALPHA(ARGB4444),
+ _ALPHA_REV(ARGB4444),
+ _ALPHA(ARGB1555),
+ _ALPHA_REV(ARGB1555),
+ _ALPHA(AL88),
+ _ALPHA_REV(AL88),
+ _ALPHA(A8),
+ _COLOR(L8),
+ _ALPHA(I8),
+ _INVALID(CI8),
+ _YUV(YCBCR),
+ _YUV(YCBCR_REV),
+ };
+
+static const struct {
+ GLuint format, filter, flag;
+} tx_table[] = {
+ /*
+ * Note that the _REV formats are the same as the non-REV formats.
+ * This is because the REV and non-REV formats are identical as a
+ * byte string, but differ when accessed as 16-bit or 32-bit words
+ * depending on the endianness of the host. Since the textures are
+ * transferred to the R300 as a byte string (i.e. without any
+ * byte-swapping), the R300 sees the REV and non-REV formats
+ * identically. -- paulus
+ */
+ _ASSIGN(RGBA8888, R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8)),
+ _ASSIGN(RGBA8888_REV, R300_EASY_TX_FORMAT(Y, Z, W, X, W8Z8Y8X8)),
+ _ASSIGN(ARGB8888, R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8)),
+ _ASSIGN(ARGB8888_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W8Z8Y8X8)),
+ _ASSIGN(RGB888, 0xffffffff),
+ _ASSIGN(RGB565, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5)),
+ _ASSIGN(RGB565_REV, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z5Y6X5)),
+ _ASSIGN(ARGB4444, R300_EASY_TX_FORMAT(X, Y, Z, W, W4Z4Y4X4)),
+ _ASSIGN(ARGB4444_REV, R300_EASY_TX_FORMAT(X, Y, Z, W, W4Z4Y4X4)),
+ _ASSIGN(ARGB1555, R300_EASY_TX_FORMAT(Z, Y, X, W, W1Z5Y5X5)),
+ _ASSIGN(ARGB1555_REV, R300_EASY_TX_FORMAT(Z, Y, X, W, W1Z5Y5X5)),
+ _ASSIGN(AL88, R300_EASY_TX_FORMAT(Y, Y, Y, X, Y8X8)),
+ _ASSIGN(AL88_REV, R300_EASY_TX_FORMAT(Y, Y, Y, X, Y8X8)),
+ _ASSIGN(RGB332, R300_EASY_TX_FORMAT(X, Y, Z, ONE, Z3Y3X2)),
+ _ASSIGN(A8, R300_EASY_TX_FORMAT(ZERO, ZERO, ZERO, X, X8)),
+ _ASSIGN(L8, R300_EASY_TX_FORMAT(X, X, X, ONE, X8)),
+ _ASSIGN(I8, R300_EASY_TX_FORMAT(X, X, X, X, X8)),
+ _ASSIGN(CI8, R300_EASY_TX_FORMAT(X, X, X, X, X8)),
+ _ASSIGN(YCBCR, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8)|R300_TX_FORMAT_YUV_MODE ),
+ _ASSIGN(YCBCR_REV, R300_EASY_TX_FORMAT(X, Y, Z, ONE, G8R8_G8B8)|R300_TX_FORMAT_YUV_MODE),
+ };
+
+#undef _COLOR
+#undef _ALPHA
+#undef _INVALID
+#undef _ASSIGN
+
+
+/**
+ * This function computes the number of bytes of storage needed for
+ * the given texture object (all mipmap levels, all cube faces).
+ * The \c image[face][level].x/y/width/height parameters for upload/blitting
+ * are computed here. \c filter, \c format, etc. will be set here
+ * too.
+ *
+ * \param rmesa Context pointer
+ * \param tObj GL texture object whose images are to be posted to
+ * hardware state.
+ */
+static void r300SetTexImages(r300ContextPtr rmesa,
+ struct gl_texture_object *tObj)
+{
+ r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
+ const struct gl_texture_image *baseImage =
+ tObj->Image[0][tObj->BaseLevel];
+ GLint curOffset;
+ GLint i;
+ GLint numLevels;
+ GLint log2Width, log2Height, log2Depth;
+
+ /* Set the hardware texture format
+ */
+
+ t->format &= ~(R200_TXFORMAT_FORMAT_MASK |
+ R200_TXFORMAT_ALPHA_IN_MAP);
+#if 0
+ t->filter &= ~R200_YUV_TO_RGB;
+#endif
+ if (VALID_FORMAT(baseImage->TexFormat->MesaFormat)) {
+ t->format =
+ tx_table[baseImage->TexFormat->MesaFormat].format;
+#if 1
+ t->filter |=
+ tx_table[baseImage->TexFormat->MesaFormat].filter;
+#endif
+ } else {
+ _mesa_problem(NULL, "unexpected texture format in %s",
+ __FUNCTION__);
+ return;
+ }
+
+ /* Compute which mipmap levels we really want to send to the hardware.
+ */
+
+ driCalculateTextureFirstLastLevel((driTextureObject *) t);
+ log2Width = tObj->Image[0][t->base.firstLevel]->WidthLog2;
+ log2Height = tObj->Image[0][t->base.firstLevel]->HeightLog2;
+ log2Depth = tObj->Image[0][t->base.firstLevel]->DepthLog2;
+
+ numLevels = t->base.lastLevel - t->base.firstLevel + 1;
+
+ assert(numLevels <= RADEON_MAX_TEXTURE_LEVELS);
+
+ /* Calculate mipmap offsets and dimensions for blitting (uploading)
+ * The idea is that we lay out the mipmap levels within a block of
+ * memory organized as a rectangle of width BLIT_WIDTH_BYTES.
+ */
+ curOffset = 0;
+
+ for (i = 0; i < numLevels; i++) {
+ const struct gl_texture_image *texImage;
+ GLuint size;
+
+ texImage = tObj->Image[0][i + t->base.firstLevel];
+ if (!texImage)
+ break;
+
+ /* find image size in bytes */
+ if (texImage->IsCompressed) {
+ size = texImage->CompressedSize;
+ } else if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
+ size =
+ ((texImage->Width *
+ texImage->TexFormat->TexelBytes + 63)
+ & ~63) * texImage->Height;
+ } else {
+ int w =
+ texImage->Width * texImage->TexFormat->TexelBytes;
+ if (w < 32)
+ w = 32;
+ size = w * texImage->Height * texImage->Depth;
+ }
+ assert(size > 0);
+
+ if(0)
+ fprintf(stderr, "w=%d h=%d d=%d tb=%d intFormat=%d\n", texImage->Width, texImage->Height,
+ texImage->Depth, texImage->TexFormat->TexelBytes,
+ texImage->IntFormat);
+
+ /* Align to 32-byte offset. It is faster to do this unconditionally
+ * (no branch penalty).
+ */
+
+ curOffset = (curOffset + 0x1f) & ~0x1f;
+
+ t->image[0][i].x = curOffset % BLIT_WIDTH_BYTES;
+ t->image[0][i].y = curOffset / BLIT_WIDTH_BYTES;
+ t->image[0][i].width = MIN2(size, BLIT_WIDTH_BYTES);
+ t->image[0][i].height = size / t->image[0][i].width;
+
+#if 0
+ /* for debugging only and only applicable to non-rectangle targets */
+ assert(size % t->image[0][i].width == 0);
+ assert(t->image[0][i].x == 0
+ || (size < BLIT_WIDTH_BYTES
+ && t->image[0][i].height == 1));
+#endif
+
+ if (0)
+ fprintf(stderr,
+ "level %d: %dx%d x=%d y=%d w=%d h=%d size=%d at %d\n",
+ i, texImage->Width, texImage->Height,
+ t->image[0][i].x, t->image[0][i].y,
+ t->image[0][i].width, t->image[0][i].height,
+ size, curOffset);
+
+ curOffset += size;
+
+ }
+
+ /* Align the total size of texture memory block.
+ */
+ t->base.totalSize =
+ (curOffset + RADEON_OFFSET_MASK) & ~RADEON_OFFSET_MASK;
+
+ /* Setup remaining cube face blits, if needed */
+ if (tObj->Target == GL_TEXTURE_CUBE_MAP) {
+ /* Round totalSize up to multiple of BLIT_WIDTH_BYTES */
+ const GLuint faceSize =
+ (t->base.totalSize + BLIT_WIDTH_BYTES - 1)
+ & ~(BLIT_WIDTH_BYTES - 1);
+ const GLuint lines = faceSize / BLIT_WIDTH_BYTES;
+ GLuint face;
+ /* reuse face 0 x/y/width/height - just adjust y */
+ for (face = 1; face < 6; face++) {
+ for (i = 0; i < numLevels; i++) {
+ t->image[face][i].x = t->image[0][i].x;
+ t->image[face][i].y =
+ t->image[0][i].y + face * lines;
+ t->image[face][i].width = t->image[0][i].width;
+ t->image[face][i].height =
+ t->image[0][i].height;
+ }
+ }
+ t->base.totalSize = 6 * faceSize; /* total texmem needed */
+ }
+
+ /* Hardware state:
+ */
+#if 0
+ t->filter &= ~R200_MAX_MIP_LEVEL_MASK;
+ t->filter |= (numLevels - 1) << R200_MAX_MIP_LEVEL_SHIFT;
+#endif
+#if 0
+ t->format &= ~(R200_TXFORMAT_WIDTH_MASK |
+ R200_TXFORMAT_HEIGHT_MASK |
+ R200_TXFORMAT_CUBIC_MAP_ENABLE |
+ R200_TXFORMAT_F5_WIDTH_MASK |
+ R200_TXFORMAT_F5_HEIGHT_MASK);
+ t->format |= ((log2Width << R200_TXFORMAT_WIDTH_SHIFT) |
+ (log2Height << R200_TXFORMAT_HEIGHT_SHIFT));
+#endif
+
+ t->format_x &= ~(R200_DEPTH_LOG2_MASK | R200_TEXCOORD_MASK);
+ if (tObj->Target == GL_TEXTURE_3D) {
+ t->format_x |= (log2Depth << R200_DEPTH_LOG2_SHIFT);
+ t->format_x |= R200_TEXCOORD_VOLUME;
+ } else if (tObj->Target == GL_TEXTURE_CUBE_MAP) {
+ ASSERT(log2Width == log2Height);
+ t->format |= ((log2Width << R200_TXFORMAT_F5_WIDTH_SHIFT) |
+ (log2Height << R200_TXFORMAT_F5_HEIGHT_SHIFT)
+ | (R200_TXFORMAT_CUBIC_MAP_ENABLE));
+ t->format_x |= R200_TEXCOORD_CUBIC_ENV;
+ t->pp_cubic_faces = ((log2Width << R200_FACE_WIDTH_1_SHIFT) |
+ (log2Height << R200_FACE_HEIGHT_1_SHIFT) |
+ (log2Width << R200_FACE_WIDTH_2_SHIFT) |
+ (log2Height << R200_FACE_HEIGHT_2_SHIFT) |
+ (log2Width << R200_FACE_WIDTH_3_SHIFT) |
+ (log2Height << R200_FACE_HEIGHT_3_SHIFT) |
+ (log2Width << R200_FACE_WIDTH_4_SHIFT) |
+ (log2Height << R200_FACE_HEIGHT_4_SHIFT));
+ }
+
+ t->size = (((tObj->Image[0][t->base.firstLevel]->Width - 1) << R300_TX_WIDTHMASK_SHIFT)
+ |((tObj->Image[0][t->base.firstLevel]->Height - 1) << R300_TX_HEIGHTMASK_SHIFT)
+ |((log2Width>log2Height)?log2Width:log2Height)<<R300_TX_SIZE_SHIFT);
+
+ /* Only need to round to nearest 32 for textures, but the blitter
+ * requires 64-byte aligned pitches, and we may/may not need the
+ * blitter. NPOT only!
+ */
+ if (baseImage->IsCompressed)
+ t->pitch =
+ (tObj->Image[0][t->base.firstLevel]->Width + 63) & ~(63);
+ else
+ t->pitch =
+ ((tObj->Image[0][t->base.firstLevel]->Width *
+ baseImage->TexFormat->TexelBytes) + 63) & ~(63);
+ t->pitch -= 32;
+
+ t->dirty_state = TEX_ALL;
+
+ /* FYI: r300UploadTexImages( rmesa, t ) used to be called here */
+}
+
+/* ================================================================
+ * Texture combine functions
+ */
+
+/* GL_ARB_texture_env_combine support
+ */
+
+/* The color tables have combine functions for GL_SRC_COLOR,
+ * GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA.
+ */
+static GLuint r300_register_color[][R200_MAX_TEXTURE_UNITS] = {
+ {
+ R200_TXC_ARG_A_R0_COLOR,
+ R200_TXC_ARG_A_R1_COLOR,
+ R200_TXC_ARG_A_R2_COLOR,
+ R200_TXC_ARG_A_R3_COLOR,
+ R200_TXC_ARG_A_R4_COLOR,
+ R200_TXC_ARG_A_R5_COLOR},
+ {
+ R200_TXC_ARG_A_R0_COLOR | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R1_COLOR | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R2_COLOR | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R3_COLOR | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R4_COLOR | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R5_COLOR | R200_TXC_COMP_ARG_A},
+ {
+ R200_TXC_ARG_A_R0_ALPHA,
+ R200_TXC_ARG_A_R1_ALPHA,
+ R200_TXC_ARG_A_R2_ALPHA,
+ R200_TXC_ARG_A_R3_ALPHA,
+ R200_TXC_ARG_A_R4_ALPHA,
+ R200_TXC_ARG_A_R5_ALPHA},
+ {
+ R200_TXC_ARG_A_R0_ALPHA | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R1_ALPHA | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R2_ALPHA | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R3_ALPHA | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R4_ALPHA | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_R5_ALPHA | R200_TXC_COMP_ARG_A},
+};
+
+static GLuint r300_tfactor_color[] = {
+ R200_TXC_ARG_A_TFACTOR_COLOR,
+ R200_TXC_ARG_A_TFACTOR_COLOR | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_TFACTOR_ALPHA,
+ R200_TXC_ARG_A_TFACTOR_ALPHA | R200_TXC_COMP_ARG_A
+};
+
+static GLuint r300_primary_color[] = {
+ R200_TXC_ARG_A_DIFFUSE_COLOR,
+ R200_TXC_ARG_A_DIFFUSE_COLOR | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_DIFFUSE_ALPHA,
+ R200_TXC_ARG_A_DIFFUSE_ALPHA | R200_TXC_COMP_ARG_A
+};
+
+/* GL_ZERO table - indices 0-3
+ * GL_ONE table - indices 1-4
+ */
+static GLuint r300_zero_color[] = {
+ R200_TXC_ARG_A_ZERO,
+ R200_TXC_ARG_A_ZERO | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_ZERO,
+ R200_TXC_ARG_A_ZERO | R200_TXC_COMP_ARG_A,
+ R200_TXC_ARG_A_ZERO
+};
+
+/* The alpha tables only have GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA.
+ */
+static GLuint r300_register_alpha[][R200_MAX_TEXTURE_UNITS] = {
+ {
+ R200_TXA_ARG_A_R0_ALPHA,
+ R200_TXA_ARG_A_R1_ALPHA,
+ R200_TXA_ARG_A_R2_ALPHA,
+ R200_TXA_ARG_A_R3_ALPHA,
+ R200_TXA_ARG_A_R4_ALPHA,
+ R200_TXA_ARG_A_R5_ALPHA},
+ {
+ R200_TXA_ARG_A_R0_ALPHA | R200_TXA_COMP_ARG_A,
+ R200_TXA_ARG_A_R1_ALPHA | R200_TXA_COMP_ARG_A,
+ R200_TXA_ARG_A_R2_ALPHA | R200_TXA_COMP_ARG_A,
+ R200_TXA_ARG_A_R3_ALPHA | R200_TXA_COMP_ARG_A,
+ R200_TXA_ARG_A_R4_ALPHA | R200_TXA_COMP_ARG_A,
+ R200_TXA_ARG_A_R5_ALPHA | R200_TXA_COMP_ARG_A},
+};
+
+static GLuint r300_tfactor_alpha[] = {
+ R200_TXA_ARG_A_TFACTOR_ALPHA,
+ R200_TXA_ARG_A_TFACTOR_ALPHA | R200_TXA_COMP_ARG_A
+};
+
+static GLuint r300_primary_alpha[] = {
+ R200_TXA_ARG_A_DIFFUSE_ALPHA,
+ R200_TXA_ARG_A_DIFFUSE_ALPHA | R200_TXA_COMP_ARG_A
+};
+
+/* GL_ZERO table - indices 0-1
+ * GL_ONE table - indices 1-2
+ */
+static GLuint r300_zero_alpha[] = {
+ R200_TXA_ARG_A_ZERO,
+ R200_TXA_ARG_A_ZERO | R200_TXA_COMP_ARG_A,
+ R200_TXA_ARG_A_ZERO,
+};
+
+/* Extract the arg from slot A, shift it into the correct argument slot
+ * and set the corresponding complement bit.
+ */
+#define R200_COLOR_ARG( n, arg ) \
+do { \
+ color_combine |= \
+ ((color_arg[n] & R200_TXC_ARG_A_MASK) \
+ << R200_TXC_ARG_##arg##_SHIFT); \
+ color_combine |= \
+ ((color_arg[n] >> R200_TXC_COMP_ARG_A_SHIFT) \
+ << R200_TXC_COMP_ARG_##arg##_SHIFT); \
+} while (0)
+
+#define R200_ALPHA_ARG( n, arg ) \
+do { \
+ alpha_combine |= \
+ ((alpha_arg[n] & R200_TXA_ARG_A_MASK) \
+ << R200_TXA_ARG_##arg##_SHIFT); \
+ alpha_combine |= \
+ ((alpha_arg[n] >> R200_TXA_COMP_ARG_A_SHIFT) \
+ << R200_TXA_COMP_ARG_##arg##_SHIFT); \
+} while (0)
+
+/* ================================================================
+ * Texture unit state management
+ */
+
+static GLboolean r300UpdateTextureEnv(GLcontext * ctx, int unit)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ GLuint color_combine, alpha_combine;
+
+#if 0 /* disable for now.. */
+ GLuint color_scale = rmesa->hw.pix[unit].cmd[PIX_PP_TXCBLEND2] &
+ ~(R200_TXC_SCALE_MASK);
+ GLuint alpha_scale = rmesa->hw.pix[unit].cmd[PIX_PP_TXABLEND2] &
+ ~(R200_TXA_DOT_ALPHA | R200_TXA_SCALE_MASK);
+#endif
+
+ GLuint color_scale=0, alpha_scale=0;
+
+ /* texUnit->_Current can be NULL if and only if the texture unit is
+ * not actually enabled.
+ */
+ assert((texUnit->_ReallyEnabled == 0)
+ || (texUnit->_Current != NULL));
+
+ if (RADEON_DEBUG & DEBUG_TEXTURE) {
+ fprintf(stderr, "%s( %p, %d )\n", __FUNCTION__, (void *)ctx,
+ unit);
+ }
+
+ /* Set the texture environment state. Isn't this nice and clean?
+ * The chip will automagically set the texture alpha to 0xff when
+ * the texture format does not include an alpha component. This
+ * reduces the amount of special-casing we have to do, alpha-only
+ * textures being a notable exception.
+ */
+ /* Don't cache these results.
+ */
+#if 0
+ rmesa->state.texture.unit[unit].format = 0;
+#endif
+ rmesa->state.texture.unit[unit].envMode = 0;
+
+
+ if (!texUnit->_ReallyEnabled) {
+ if (unit == 0) {
+ color_combine =
+ R200_TXC_ARG_A_ZERO | R200_TXC_ARG_B_ZERO |
+ R200_TXC_ARG_C_DIFFUSE_COLOR | R200_TXC_OP_MADD;
+ alpha_combine =
+ R200_TXA_ARG_A_ZERO | R200_TXA_ARG_B_ZERO |
+ R200_TXA_ARG_C_DIFFUSE_ALPHA | R200_TXA_OP_MADD;
+ } else {
+ color_combine =
+ R200_TXC_ARG_A_ZERO | R200_TXC_ARG_B_ZERO |
+ R200_TXC_ARG_C_R0_COLOR | R200_TXC_OP_MADD;
+ alpha_combine =
+ R200_TXA_ARG_A_ZERO | R200_TXA_ARG_B_ZERO |
+ R200_TXA_ARG_C_R0_ALPHA | R200_TXA_OP_MADD;
+ }
+ } else {
+ GLuint color_arg[3], alpha_arg[3];
+ GLuint i;
+ const GLuint numColorArgs =
+ texUnit->_CurrentCombine->_NumArgsRGB;
+ const GLuint numAlphaArgs = texUnit->_CurrentCombine->_NumArgsA;
+ GLuint RGBshift = texUnit->_CurrentCombine->ScaleShiftRGB;
+ GLuint Ashift = texUnit->_CurrentCombine->ScaleShiftA;
+
+ /* Step 1:
+ * Extract the color and alpha combine function arguments.
+ */
+ for (i = 0; i < numColorArgs; i++) {
+ const GLint op =
+ texUnit->_CurrentCombine->OperandRGB[i] -
+ GL_SRC_COLOR;
+ assert(op >= 0);
+ assert(op <= 3);
+ switch (texUnit->_CurrentCombine->SourceRGB[i]) {
+ case GL_TEXTURE:
+ color_arg[i] = r300_register_color[op][unit];
+ break;
+ case GL_CONSTANT:
+ color_arg[i] = r300_tfactor_color[op];
+ break;
+ case GL_PRIMARY_COLOR:
+ color_arg[i] = r300_primary_color[op];
+ break;
+ case GL_PREVIOUS:
+ if (unit == 0)
+ color_arg[i] = r300_primary_color[op];
+ else
+ color_arg[i] =
+ r300_register_color[op][0];
+ break;
+ case GL_ZERO:
+ color_arg[i] = r300_zero_color[op];
+ break;
+ case GL_ONE:
+ color_arg[i] = r300_zero_color[op + 1];
+ break;
+ default:
+ return GL_FALSE;
+ }
+ }
+
+ for (i = 0; i < numAlphaArgs; i++) {
+ const GLint op =
+ texUnit->_CurrentCombine->OperandA[i] -
+ GL_SRC_ALPHA;
+ assert(op >= 0);
+ assert(op <= 1);
+ switch (texUnit->_CurrentCombine->SourceA[i]) {
+ case GL_TEXTURE:
+ alpha_arg[i] = r300_register_alpha[op][unit];
+ break;
+ case GL_CONSTANT:
+ alpha_arg[i] = r300_tfactor_alpha[op];
+ break;
+ case GL_PRIMARY_COLOR:
+ alpha_arg[i] = r300_primary_alpha[op];
+ break;
+ case GL_PREVIOUS:
+ if (unit == 0)
+ alpha_arg[i] = r300_primary_alpha[op];
+ else
+ alpha_arg[i] =
+ r300_register_alpha[op][0];
+ break;
+ case GL_ZERO:
+ alpha_arg[i] = r300_zero_alpha[op];
+ break;
+ case GL_ONE:
+ alpha_arg[i] = r300_zero_alpha[op + 1];
+ break;
+ default:
+ return GL_FALSE;
+ }
+ }
+
+ /* Step 2:
+ * Build up the color and alpha combine functions.
+ */
+ switch (texUnit->_CurrentCombine->ModeRGB) {
+ case GL_REPLACE:
+ color_combine = (R200_TXC_ARG_A_ZERO |
+ R200_TXC_ARG_B_ZERO |
+ R200_TXC_OP_MADD);
+ R200_COLOR_ARG(0, C);
+ break;
+ case GL_MODULATE:
+ color_combine = (R200_TXC_ARG_C_ZERO |
+ R200_TXC_OP_MADD);
+ R200_COLOR_ARG(0, A);
+ R200_COLOR_ARG(1, B);
+ break;
+ case GL_ADD:
+ color_combine = (R200_TXC_ARG_B_ZERO |
+ R200_TXC_COMP_ARG_B |
+ R200_TXC_OP_MADD);
+ R200_COLOR_ARG(0, A);
+ R200_COLOR_ARG(1, C);
+ break;
+ case GL_ADD_SIGNED:
+ color_combine = (R200_TXC_ARG_B_ZERO | R200_TXC_COMP_ARG_B | R200_TXC_BIAS_ARG_C | /* new */
+ R200_TXC_OP_MADD); /* was ADDSIGNED */
+ R200_COLOR_ARG(0, A);
+ R200_COLOR_ARG(1, C);
+ break;
+ case GL_SUBTRACT:
+ color_combine = (R200_TXC_ARG_B_ZERO |
+ R200_TXC_COMP_ARG_B |
+ R200_TXC_NEG_ARG_C | R200_TXC_OP_MADD);
+ R200_COLOR_ARG(0, A);
+ R200_COLOR_ARG(1, C);
+ break;
+ case GL_INTERPOLATE:
+ color_combine = (R200_TXC_OP_LERP);
+ R200_COLOR_ARG(0, B);
+ R200_COLOR_ARG(1, A);
+ R200_COLOR_ARG(2, C);
+ break;
+
+ case GL_DOT3_RGB_EXT:
+ case GL_DOT3_RGBA_EXT:
+ /* The EXT version of the DOT3 extension does not support the
+ * scale factor, but the ARB version (and the version in OpenGL
+ * 1.3) does.
+ */
+ RGBshift = 0;
+ /* FALLTHROUGH */
+
+ case GL_DOT3_RGB:
+ case GL_DOT3_RGBA:
+ /* DOT3 works differently on R200 than on R100. On R100, just
+ * setting the DOT3 mode did everything for you. On R200, the
+ * driver has to enable the biasing and scale in the inputs to
+ * put them in the proper [-1,1] range. This is what the 4x and
+ * the -0.5 in the DOT3 spec do. The post-scale is then set
+ * normally.
+ */
+
+ color_combine = (R200_TXC_ARG_C_ZERO |
+ R200_TXC_OP_DOT3 |
+ R200_TXC_BIAS_ARG_A |
+ R200_TXC_BIAS_ARG_B |
+ R200_TXC_SCALE_ARG_A |
+ R200_TXC_SCALE_ARG_B);
+ R200_COLOR_ARG(0, A);
+ R200_COLOR_ARG(1, B);
+ break;
+
+ case GL_MODULATE_ADD_ATI:
+ color_combine = (R200_TXC_OP_MADD);
+ R200_COLOR_ARG(0, A);
+ R200_COLOR_ARG(1, C);
+ R200_COLOR_ARG(2, B);
+ break;
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ color_combine = (R200_TXC_BIAS_ARG_C | /* new */
+ R200_TXC_OP_MADD); /* was ADDSIGNED */
+ R200_COLOR_ARG(0, A);
+ R200_COLOR_ARG(1, C);
+ R200_COLOR_ARG(2, B);
+ break;
+ case GL_MODULATE_SUBTRACT_ATI:
+ color_combine = (R200_TXC_NEG_ARG_C | R200_TXC_OP_MADD);
+ R200_COLOR_ARG(0, A);
+ R200_COLOR_ARG(1, C);
+ R200_COLOR_ARG(2, B);
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+ switch (texUnit->_CurrentCombine->ModeA) {
+ case GL_REPLACE:
+ alpha_combine = (R200_TXA_ARG_A_ZERO |
+ R200_TXA_ARG_B_ZERO |
+ R200_TXA_OP_MADD);
+ R200_ALPHA_ARG(0, C);
+ break;
+ case GL_MODULATE:
+ alpha_combine = (R200_TXA_ARG_C_ZERO |
+ R200_TXA_OP_MADD);
+ R200_ALPHA_ARG(0, A);
+ R200_ALPHA_ARG(1, B);
+ break;
+ case GL_ADD:
+ alpha_combine = (R200_TXA_ARG_B_ZERO |
+ R200_TXA_COMP_ARG_B |
+ R200_TXA_OP_MADD);
+ R200_ALPHA_ARG(0, A);
+ R200_ALPHA_ARG(1, C);
+ break;
+ case GL_ADD_SIGNED:
+ alpha_combine = (R200_TXA_ARG_B_ZERO | R200_TXA_COMP_ARG_B | R200_TXA_BIAS_ARG_C | /* new */
+ R200_TXA_OP_MADD); /* was ADDSIGNED */
+ R200_ALPHA_ARG(0, A);
+ R200_ALPHA_ARG(1, C);
+ break;
+ case GL_SUBTRACT:
+ alpha_combine = (R200_TXA_ARG_B_ZERO |
+ R200_TXA_COMP_ARG_B |
+ R200_TXA_NEG_ARG_C | R200_TXA_OP_MADD);
+ R200_ALPHA_ARG(0, A);
+ R200_ALPHA_ARG(1, C);
+ break;
+ case GL_INTERPOLATE:
+ alpha_combine = (R200_TXA_OP_LERP);
+ R200_ALPHA_ARG(0, B);
+ R200_ALPHA_ARG(1, A);
+ R200_ALPHA_ARG(2, C);
+ break;
+
+ case GL_MODULATE_ADD_ATI:
+ alpha_combine = (R200_TXA_OP_MADD);
+ R200_ALPHA_ARG(0, A);
+ R200_ALPHA_ARG(1, C);
+ R200_ALPHA_ARG(2, B);
+ break;
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ alpha_combine = (R200_TXA_BIAS_ARG_C | /* new */
+ R200_TXA_OP_MADD); /* was ADDSIGNED */
+ R200_ALPHA_ARG(0, A);
+ R200_ALPHA_ARG(1, C);
+ R200_ALPHA_ARG(2, B);
+ break;
+ case GL_MODULATE_SUBTRACT_ATI:
+ alpha_combine = (R200_TXA_NEG_ARG_C | R200_TXA_OP_MADD);
+ R200_ALPHA_ARG(0, A);
+ R200_ALPHA_ARG(1, C);
+ R200_ALPHA_ARG(2, B);
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+ if ((texUnit->_CurrentCombine->ModeRGB == GL_DOT3_RGBA_EXT)
+ || (texUnit->_CurrentCombine->ModeRGB == GL_DOT3_RGBA)) {
+ alpha_scale |= R200_TXA_DOT_ALPHA;
+ Ashift = RGBshift;
+ }
+
+ /* Step 3:
+ * Apply the scale factor.
+ */
+ color_scale |= (RGBshift << R200_TXC_SCALE_SHIFT);
+ alpha_scale |= (Ashift << R200_TXA_SCALE_SHIFT);
+
+ /* All done!
+ */
+ }
+
+#if 0
+ fprintf(stderr, "color_combine=%08x alpha_combine=%08x color_scale=%08x alpha_scale=%08x\n",
+ color_combine, alpha_combine, color_scale, alpha_scale);
+#endif
+
+#if 0
+ if (rmesa->hw.pix[unit].cmd[PIX_PP_TXCBLEND] != color_combine ||
+ rmesa->hw.pix[unit].cmd[PIX_PP_TXABLEND] != alpha_combine ||
+ rmesa->hw.pix[unit].cmd[PIX_PP_TXCBLEND2] != color_scale ||
+ rmesa->hw.pix[unit].cmd[PIX_PP_TXABLEND2] != alpha_scale) {
+ R300_STATECHANGE(rmesa, pix[unit]);
+ rmesa->hw.pix[unit].cmd[PIX_PP_TXCBLEND] = color_combine;
+ rmesa->hw.pix[unit].cmd[PIX_PP_TXABLEND] = alpha_combine;
+ rmesa->hw.pix[unit].cmd[PIX_PP_TXCBLEND2] = color_scale;
+ rmesa->hw.pix[unit].cmd[PIX_PP_TXABLEND2] = alpha_scale;
+ }
+
+#endif
+
+ return GL_TRUE;
+}
+
+#define TEXOBJ_TXFILTER_MASK (R200_MAX_MIP_LEVEL_MASK | \
+ R200_MIN_FILTER_MASK | \
+ R200_MAG_FILTER_MASK | \
+ R200_MAX_ANISO_MASK | \
+ R200_YUV_TO_RGB | \
+ R200_YUV_TEMPERATURE_MASK | \
+ R200_CLAMP_S_MASK | \
+ R200_CLAMP_T_MASK | \
+ R200_BORDER_MODE_D3D )
+
+#define TEXOBJ_TXFORMAT_MASK (R200_TXFORMAT_WIDTH_MASK | \
+ R200_TXFORMAT_HEIGHT_MASK | \
+ R200_TXFORMAT_FORMAT_MASK | \
+ R200_TXFORMAT_F5_WIDTH_MASK | \
+ R200_TXFORMAT_F5_HEIGHT_MASK | \
+ R200_TXFORMAT_ALPHA_IN_MAP | \
+ R200_TXFORMAT_CUBIC_MAP_ENABLE | \
+ R200_TXFORMAT_NON_POWER2)
+
+#define TEXOBJ_TXFORMAT_X_MASK (R200_DEPTH_LOG2_MASK | \
+ R200_TEXCOORD_MASK | \
+ R200_CLAMP_Q_MASK | \
+ R200_VOLUME_FILTER_MASK)
+
+static void import_tex_obj_state(r300ContextPtr rmesa,
+ int unit, r300TexObjPtr texobj)
+{
+#if 0 /* needs fixing.. or should be done elsewhere */
+ GLuint *cmd = R300_DB_STATE(tex[unit]);
+
+ cmd[TEX_PP_TXFILTER] &= ~TEXOBJ_TXFILTER_MASK;
+ cmd[TEX_PP_TXFILTER] |= texobj->filter & TEXOBJ_TXFILTER_MASK;
+ cmd[TEX_PP_TXFORMAT] &= ~TEXOBJ_TXFORMAT_MASK;
+ cmd[TEX_PP_TXFORMAT] |= texobj->format & TEXOBJ_TXFORMAT_MASK;
+ cmd[TEX_PP_TXFORMAT_X] &= ~TEXOBJ_TXFORMAT_X_MASK;
+ cmd[TEX_PP_TXFORMAT_X] |=
+ texobj->format_x & TEXOBJ_TXFORMAT_X_MASK;
+ cmd[TEX_PP_TXSIZE] = texobj->size; /* NPOT only! */
+ cmd[TEX_PP_TXPITCH] = texobj->pitch; /* NPOT only! */
+ cmd[TEX_PP_TXOFFSET] = texobj->pp_txoffset;
+ cmd[TEX_PP_BORDER_COLOR] = texobj->pp_border_color;
+ R200_DB_STATECHANGE(rmesa, &rmesa->hw.tex[unit]);
+
+ if (texobj->base.tObj->Target == GL_TEXTURE_CUBE_MAP) {
+ GLuint *cube_cmd = R200_DB_STATE(cube[unit]);
+ GLuint bytesPerFace = texobj->base.totalSize / 6;
+ ASSERT(texobj->totalSize % 6 == 0);
+ cube_cmd[CUBE_PP_CUBIC_FACES] = texobj->pp_cubic_faces;
+ cube_cmd[CUBE_PP_CUBIC_OFFSET_F1] =
+ texobj->pp_txoffset + 1 * bytesPerFace;
+ cube_cmd[CUBE_PP_CUBIC_OFFSET_F2] =
+ texobj->pp_txoffset + 2 * bytesPerFace;
+ cube_cmd[CUBE_PP_CUBIC_OFFSET_F3] =
+ texobj->pp_txoffset + 3 * bytesPerFace;
+ cube_cmd[CUBE_PP_CUBIC_OFFSET_F4] =
+ texobj->pp_txoffset + 4 * bytesPerFace;
+ cube_cmd[CUBE_PP_CUBIC_OFFSET_F5] =
+ texobj->pp_txoffset + 5 * bytesPerFace;
+ R200_DB_STATECHANGE(rmesa, &rmesa->hw.cube[unit]);
+ }
+
+ texobj->dirty_state &= ~(1 << unit);
+#endif
+}
+
+static void set_texgen_matrix(r300ContextPtr rmesa,
+ GLuint unit,
+ const GLfloat * s_plane,
+ const GLfloat * t_plane, const GLfloat * r_plane)
+{
+ static const GLfloat scale_identity[4] = { 1, 1, 1, 1 };
+
+ if (!TEST_EQ_4V(s_plane, scale_identity) ||
+ !TEST_EQ_4V(t_plane, scale_identity) ||
+ !TEST_EQ_4V(r_plane, scale_identity)) {
+ rmesa->TexGenEnabled |= R200_TEXMAT_0_ENABLE << unit;
+ rmesa->TexGenMatrix[unit].m[0] = s_plane[0];
+ rmesa->TexGenMatrix[unit].m[4] = s_plane[1];
+ rmesa->TexGenMatrix[unit].m[8] = s_plane[2];
+ rmesa->TexGenMatrix[unit].m[12] = s_plane[3];
+
+ rmesa->TexGenMatrix[unit].m[1] = t_plane[0];
+ rmesa->TexGenMatrix[unit].m[5] = t_plane[1];
+ rmesa->TexGenMatrix[unit].m[9] = t_plane[2];
+ rmesa->TexGenMatrix[unit].m[13] = t_plane[3];
+
+ /* NOTE: r_plane goes in the 4th row, not 3rd! */
+ rmesa->TexGenMatrix[unit].m[3] = r_plane[0];
+ rmesa->TexGenMatrix[unit].m[7] = r_plane[1];
+ rmesa->TexGenMatrix[unit].m[11] = r_plane[2];
+ rmesa->TexGenMatrix[unit].m[15] = r_plane[3];
+
+ //rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
+ }
+}
+
+/* Need this special matrix to get correct reflection map coords */
+static void set_texgen_reflection_matrix(r300ContextPtr rmesa, GLuint unit)
+{
+ static const GLfloat m[16] = {
+ -1, 0, 0, 0,
+ 0, -1, 0, 0,
+ 0, 0, 0, -1,
+ 0, 0, -1, 0
+ };
+ _math_matrix_loadf(&(rmesa->TexGenMatrix[unit]), m);
+ _math_matrix_analyse(&(rmesa->TexGenMatrix[unit]));
+ rmesa->TexGenEnabled |= R200_TEXMAT_0_ENABLE << unit;
+}
+
+/* Need this special matrix to get correct normal map coords */
+static void set_texgen_normal_map_matrix(r300ContextPtr rmesa, GLuint unit)
+{
+ static const GLfloat m[16] = {
+ 1, 0, 0, 0,
+ 0, 1, 0, 0,
+ 0, 0, 0, 1,
+ 0, 0, 1, 0
+ };
+ _math_matrix_loadf(&(rmesa->TexGenMatrix[unit]), m);
+ _math_matrix_analyse(&(rmesa->TexGenMatrix[unit]));
+ rmesa->TexGenEnabled |= R200_TEXMAT_0_ENABLE << unit;
+}
+
+/* Ignoring the Q texcoord for now.
+ *
+ * Returns GL_FALSE if fallback required.
+ */
+static GLboolean r300_validate_texgen(GLcontext * ctx, GLuint unit)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ GLuint inputshift = R200_TEXGEN_0_INPUT_SHIFT + unit * 4;
+ GLuint tmp = rmesa->TexGenEnabled;
+
+ rmesa->TexGenCompSel &= ~(R200_OUTPUT_TEX_0 << unit);
+ rmesa->TexGenEnabled &= ~(R200_TEXGEN_TEXMAT_0_ENABLE << unit);
+ rmesa->TexGenEnabled &= ~(R200_TEXMAT_0_ENABLE << unit);
+ rmesa->TexGenInputs &= ~(R200_TEXGEN_INPUT_MASK << inputshift);
+ rmesa->TexGenNeedNormals[unit] = 0;
+
+ if (0)
+ fprintf(stderr, "%s unit %d\n", __FUNCTION__, unit);
+
+ if ((texUnit->TexGenEnabled & (S_BIT | T_BIT | R_BIT)) == 0) {
+ /* Disabled, no fallback:
+ */
+ rmesa->TexGenInputs |=
+ (R200_TEXGEN_INPUT_TEXCOORD_0 + unit) << inputshift;
+ return GL_TRUE;
+ } else if (texUnit->TexGenEnabled & Q_BIT) {
+ /* Very easy to do this, in fact would remove a fallback case
+ * elsewhere, but I haven't done it yet... Fallback:
+ */
+ /*fprintf(stderr, "fallback Q_BIT\n"); */
+ return GL_FALSE;
+ } else if (texUnit->TexGenEnabled == (S_BIT | T_BIT) &&
+ texUnit->GenModeS == texUnit->GenModeT) {
+ /* OK */
+ rmesa->TexGenEnabled |= R200_TEXGEN_TEXMAT_0_ENABLE << unit;
+ /* continue */
+ } else if (texUnit->TexGenEnabled == (S_BIT | T_BIT | R_BIT) &&
+ texUnit->GenModeS == texUnit->GenModeT &&
+ texUnit->GenModeT == texUnit->GenModeR) {
+ /* OK */
+ rmesa->TexGenEnabled |= R200_TEXGEN_TEXMAT_0_ENABLE << unit;
+ /* continue */
+ } else {
+ /* Mixed modes, fallback:
+ */
+ /* fprintf(stderr, "fallback mixed texgen\n"); */
+ return GL_FALSE;
+ }
+
+ rmesa->TexGenEnabled |= R200_TEXGEN_TEXMAT_0_ENABLE << unit;
+
+ switch (texUnit->GenModeS) {
+ case GL_OBJECT_LINEAR:
+ rmesa->TexGenInputs |= R200_TEXGEN_INPUT_OBJ << inputshift;
+ set_texgen_matrix(rmesa, unit,
+ texUnit->ObjectPlaneS,
+ texUnit->ObjectPlaneT, texUnit->ObjectPlaneR);
+ break;
+
+ case GL_EYE_LINEAR:
+ rmesa->TexGenInputs |= R200_TEXGEN_INPUT_EYE << inputshift;
+ set_texgen_matrix(rmesa, unit,
+ texUnit->EyePlaneS,
+ texUnit->EyePlaneT, texUnit->EyePlaneR);
+ break;
+
+ case GL_REFLECTION_MAP_NV:
+ rmesa->TexGenNeedNormals[unit] = GL_TRUE;
+ rmesa->TexGenInputs |=
+ R200_TEXGEN_INPUT_EYE_REFLECT << inputshift;
+ set_texgen_reflection_matrix(rmesa, unit);
+ break;
+
+ case GL_NORMAL_MAP_NV:
+ rmesa->TexGenNeedNormals[unit] = GL_TRUE;
+ rmesa->TexGenInputs |=
+ R200_TEXGEN_INPUT_EYE_NORMAL << inputshift;
+ set_texgen_normal_map_matrix(rmesa, unit);
+ break;
+
+ case GL_SPHERE_MAP:
+ rmesa->TexGenNeedNormals[unit] = GL_TRUE;
+ rmesa->TexGenInputs |= R200_TEXGEN_INPUT_SPHERE << inputshift;
+ break;
+
+ default:
+ /* Unsupported mode, fallback:
+ */
+ /* fprintf(stderr, "fallback unsupported texgen\n"); */
+ return GL_FALSE;
+ }
+
+ rmesa->TexGenCompSel |= R200_OUTPUT_TEX_0 << unit;
+
+ if (tmp != rmesa->TexGenEnabled) {
+ //rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
+ }
+
+ return GL_TRUE;
+}
+
+static void disable_tex(GLcontext * ctx, int unit)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+
+#if 0 /* This needs to be redone.. or done elsewhere */
+ if (rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_0_ENABLE << unit)) {
+ /* Texture unit disabled */
+ if (rmesa->state.texture.unit[unit].texobj != NULL) {
+ /* The old texture is no longer bound to this texture unit.
+ * Mark it as such.
+ */
+
+ rmesa->state.texture.unit[unit].texobj->base.bound &=
+ ~(1UL << unit);
+ rmesa->state.texture.unit[unit].texobj = NULL;
+ }
+
+ R300_STATECHANGE(rmesa, ctx);
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~((R200_TEX_0_ENABLE |
+ R200_TEX_BLEND_0_ENABLE) <<
+ unit);
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_TEX_BLEND_0_ENABLE;
+
+ R300_STATECHANGE(rmesa, tcl);
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] &=
+ ~(7 << (unit * 3));
+
+ if (rmesa->radeon.TclFallback & (RADEON_TCL_FALLBACK_TEXGEN_0 << unit)) {
+ TCL_FALLBACK(ctx, (RADEON_TCL_FALLBACK_TEXGEN_0 << unit),
+ GL_FALSE);
+ }
+
+ /* Actually want to keep all units less than max active texture
+ * enabled, right? Fix this for >2 texunits.
+ */
+ /* FIXME: What should happen here if r300UpdateTextureEnv fails? */
+ if (unit == 0)
+ r300UpdateTextureEnv(ctx, unit);
+
+ {
+ GLuint inputshift =
+ R200_TEXGEN_0_INPUT_SHIFT + unit * 4;
+ GLuint tmp = rmesa->TexGenEnabled;
+
+ rmesa->TexGenEnabled &=
+ ~(R200_TEXGEN_TEXMAT_0_ENABLE << unit);
+ rmesa->TexGenEnabled &= ~(R200_TEXMAT_0_ENABLE << unit);
+ rmesa->TexGenEnabled &=
+ ~(R200_TEXGEN_INPUT_MASK << inputshift);
+ rmesa->TexGenNeedNormals[unit] = 0;
+ rmesa->TexGenCompSel &= ~(R200_OUTPUT_TEX_0 << unit);
+ rmesa->TexGenInputs &=
+ ~(R200_TEXGEN_INPUT_MASK << inputshift);
+
+ if (tmp != rmesa->TexGenEnabled) {
+ rmesa->recheck_texgen[unit] = GL_TRUE;
+ rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
+ }
+ }
+ }
+#endif
+}
+
+static GLboolean enable_tex_2d(GLcontext * ctx, int unit)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
+
+ /* Need to load the 2d images associated with this unit.
+ */
+#if 0
+ if (t->format & R200_TXFORMAT_NON_POWER2) {
+ t->format &= ~R200_TXFORMAT_NON_POWER2;
+ t->base.dirty_images[0] = ~0;
+ }
+#endif
+
+ ASSERT(tObj->Target == GL_TEXTURE_2D || tObj->Target == GL_TEXTURE_1D);
+
+ if (t->base.dirty_images[0]) {
+ R300_FIREVERTICES(rmesa);
+ r300SetTexImages(rmesa, tObj);
+ r300UploadTexImages(rmesa, (r300TexObjPtr) tObj->DriverData, 0);
+ if (!t->base.memBlock)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+#if ENABLE_HW_3D_TEXTURE
+static GLboolean enable_tex_3d(GLcontext * ctx, int unit)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
+
+ /* Need to load the 3d images associated with this unit.
+ */
+ if (t->format & R200_TXFORMAT_NON_POWER2) {
+ t->format &= ~R200_TXFORMAT_NON_POWER2;
+ t->base.dirty_images[0] = ~0;
+ }
+
+ ASSERT(tObj->Target == GL_TEXTURE_3D);
+
+ /* R100 & R200 do not support mipmaps for 3D textures.
+ */
+ if ((tObj->MinFilter != GL_NEAREST) && (tObj->MinFilter != GL_LINEAR)) {
+ return GL_FALSE;
+ }
+
+ if (t->base.dirty_images[0]) {
+ R300_FIREVERTICES(rmesa);
+ r300SetTexImages(rmesa, tObj);
+ r300UploadTexImages(rmesa, (r300TexObjPtr) tObj->DriverData, 0);
+ if (!t->base.memBlock)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+#endif
+
+static GLboolean enable_tex_cube(GLcontext * ctx, int unit)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
+ GLuint face;
+
+ /* Need to load the 2d images associated with this unit.
+ */
+ if (t->format & R200_TXFORMAT_NON_POWER2) {
+ t->format &= ~R200_TXFORMAT_NON_POWER2;
+ for (face = 0; face < 6; face++)
+ t->base.dirty_images[face] = ~0;
+ }
+
+ ASSERT(tObj->Target == GL_TEXTURE_CUBE_MAP);
+
+ if (t->base.dirty_images[0] || t->base.dirty_images[1] ||
+ t->base.dirty_images[2] || t->base.dirty_images[3] ||
+ t->base.dirty_images[4] || t->base.dirty_images[5]) {
+ /* flush */
+ R300_FIREVERTICES(rmesa);
+ /* layout memory space, once for all faces */
+ r300SetTexImages(rmesa, tObj);
+ }
+
+ /* upload (per face) */
+ for (face = 0; face < 6; face++) {
+ if (t->base.dirty_images[face]) {
+ r300UploadTexImages(rmesa,
+ (r300TexObjPtr) tObj->DriverData,
+ face);
+ }
+ }
+
+ if (!t->base.memBlock) {
+ /* texmem alloc failed, use s/w fallback */
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean enable_tex_rect(GLcontext * ctx, int unit)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
+
+#if 0
+ if (!(t->format & R200_TXFORMAT_NON_POWER2)) {
+ t->format |= R200_TXFORMAT_NON_POWER2;
+ t->base.dirty_images[0] = ~0;
+ }
+#endif
+
+ ASSERT(tObj->Target == GL_TEXTURE_RECTANGLE_NV);
+
+ if (t->base.dirty_images[0]) {
+ R300_FIREVERTICES(rmesa);
+ r300SetTexImages(rmesa, tObj);
+ r300UploadTexImages(rmesa, (r300TexObjPtr) tObj->DriverData, 0);
+ if (!t->base.memBlock && !rmesa->prefer_gart_client_texturing)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean update_tex_common(GLcontext * ctx, int unit)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ r300TexObjPtr t = (r300TexObjPtr) tObj->DriverData;
+ GLenum format;
+
+ /* Fallback if there's a texture border */
+ if (tObj->Image[0][tObj->BaseLevel]->Border > 0)
+ return GL_FALSE;
+
+ /* Update state if this is a different texture object to last
+ * time.
+ */
+ if (rmesa->state.texture.unit[unit].texobj != t) {
+ if (rmesa->state.texture.unit[unit].texobj != NULL) {
+ /* The old texture is no longer bound to this texture unit.
+ * Mark it as such.
+ */
+
+ rmesa->state.texture.unit[unit].texobj->base.bound &=
+ ~(1UL << unit);
+ }
+
+ rmesa->state.texture.unit[unit].texobj = t;
+ t->base.bound |= (1UL << unit);
+ t->dirty_state |= 1 << unit;
+ driUpdateTextureLRU((driTextureObject *) t); /* XXX: should be locked! */
+ }
+
+#if 0 /* do elsewhere ? */
+ /* Newly enabled?
+ */
+ if (1
+ || !(rmesa->hw.ctx.
+ cmd[CTX_PP_CNTL] & (R200_TEX_0_ENABLE << unit))) {
+ R300_STATECHANGE(rmesa, ctx);
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= (R200_TEX_0_ENABLE |
+ R200_TEX_BLEND_0_ENABLE) <<
+ unit;
+
+ R300_STATECHANGE(rmesa, vtx);
+ rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] |= 4 << (unit * 3);
+
+ rmesa->recheck_texgen[unit] = GL_TRUE;
+ }
+
+ if (t->dirty_state & (1 << unit)) {
+ import_tex_obj_state(rmesa, unit, t);
+ }
+
+ if (rmesa->recheck_texgen[unit]) {
+ GLboolean fallback = !r300_validate_texgen(ctx, unit);
+ TCL_FALLBACK(ctx, (RADEON_TCL_FALLBACK_TEXGEN_0 << unit),
+ fallback);
+ rmesa->recheck_texgen[unit] = 0;
+ rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
+ }
+#endif
+
+ format = tObj->Image[0][tObj->BaseLevel]->Format;
+ if (rmesa->state.texture.unit[unit].format != format ||
+ rmesa->state.texture.unit[unit].envMode != texUnit->EnvMode) {
+ //rmesa->state.texture.unit[unit].format = format;
+ rmesa->state.texture.unit[unit].envMode = texUnit->EnvMode;
+ if (!r300UpdateTextureEnv(ctx, unit)) {
+ return GL_FALSE;
+ }
+ }
+
+#if R200_MERGED
+ FALLBACK(&rmesa->radeon, RADEON_FALLBACK_BORDER_MODE, t->border_fallback);
+#endif
+
+ return !t->border_fallback;
+}
+
+static GLboolean r300UpdateTextureUnit(GLcontext * ctx, int unit)
+{
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+ if (texUnit->_ReallyEnabled & (TEXTURE_RECT_BIT)) {
+ return (enable_tex_rect(ctx, unit) &&
+ update_tex_common(ctx, unit));
+ } else if (texUnit->_ReallyEnabled & (TEXTURE_1D_BIT | TEXTURE_2D_BIT)) {
+ return (enable_tex_2d(ctx, unit) &&
+ update_tex_common(ctx, unit));
+ }
+#if ENABLE_HW_3D_TEXTURE
+ else if (texUnit->_ReallyEnabled & (TEXTURE_3D_BIT)) {
+ return (enable_tex_3d(ctx, unit) &&
+ update_tex_common(ctx, unit));
+ }
+#endif
+ else if (texUnit->_ReallyEnabled & (TEXTURE_CUBE_BIT)) {
+ return (enable_tex_cube(ctx, unit) &&
+ update_tex_common(ctx, unit));
+ } else if (texUnit->_ReallyEnabled) {
+ return GL_FALSE;
+ } else {
+ disable_tex(ctx, unit);
+ return GL_TRUE;
+ }
+}
+
+void r300UpdateTextureState(GLcontext * ctx)
+{
+ r300ContextPtr rmesa = R300_CONTEXT(ctx);
+ GLboolean ok;
+ GLuint dbg;
+ int i;
+
+ ok = (r300UpdateTextureUnit(ctx, 0) &&
+ r300UpdateTextureUnit(ctx, 1) &&
+ r300UpdateTextureUnit(ctx, 2) &&
+ r300UpdateTextureUnit(ctx, 3) &&
+ r300UpdateTextureUnit(ctx, 4) &&
+ r300UpdateTextureUnit(ctx, 5) &&
+ r300UpdateTextureUnit(ctx, 6) &&
+ r300UpdateTextureUnit(ctx, 7)
+ );
+
+#if R200_MERGED
+ FALLBACK(&rmesa->radeon, RADEON_FALLBACK_TEXTURE, !ok);
+#endif
+
+ /* This needs correction, or just be done elsewhere
+ if (rmesa->radeon.TclFallback)
+ r300ChooseVertexState(ctx);
+ */
+
+#if 0 /* Workaround - disable.. */
+ if (GET_CHIP(rmesa->radeon.radeonScreen) == RADEON_CHIP_REAL_R200) {
+ /*
+ * T0 hang workaround -------------
+ * not needed for r200 derivatives?
+ */
+ if ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_ENABLE_MASK) ==
+ R200_TEX_0_ENABLE
+ && (rmesa->hw.tex[0].
+ cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK) >
+ R200_MIN_FILTER_LINEAR) {
+
+ R300_STATECHANGE(rmesa, ctx);
+ R300_STATECHANGE(rmesa, tex[1]);
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_TEX_1_ENABLE;
+ rmesa->hw.tex[1].cmd[TEX_PP_TXFORMAT] &=
+ ~TEXOBJ_TXFORMAT_MASK;
+ rmesa->hw.tex[1].cmd[TEX_PP_TXFORMAT] |= 0x08000000;
+ } else {
+ if ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_1_ENABLE)
+ && (rmesa->hw.tex[1].
+ cmd[TEX_PP_TXFORMAT] & 0x08000000)) {
+ R300_STATECHANGE(rmesa, tex[1]);
+ rmesa->hw.tex[1].cmd[TEX_PP_TXFORMAT] &=
+ ~0x08000000;
+ }
+ }
+
+ /* maybe needs to be done pairwise due to 2 parallel (physical) tex units ?
+ looks like that's not the case, if 8500/9100 owners don't complain remove this...
+ for ( i = 0; i < ctx->Const.MaxTextureUnits; i += 2) {
+ if (((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & ((R200_TEX_0_ENABLE |
+ R200_TEX_1_ENABLE ) << i)) == (R200_TEX_0_ENABLE << i)) &&
+ ((rmesa->hw.tex[i].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK) >
+ R200_MIN_FILTER_LINEAR)) {
+ R300_STATECHANGE(rmesa, ctx);
+ R300_STATECHANGE(rmesa, tex[i+1]);
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= (R200_TEX_1_ENABLE << i);
+ rmesa->hw.tex[i+1].cmd[TEX_PP_TXFORMAT] &= ~TEXOBJ_TXFORMAT_MASK;
+ rmesa->hw.tex[i+1].cmd[TEX_PP_TXFORMAT] |= 0x08000000;
+ }
+ else {
+ if ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_1_ENABLE << i)) &&
+ (rmesa->hw.tex[i+1].cmd[TEX_PP_TXFORMAT] & 0x08000000)) {
+ R300_STATECHANGE(rmesa, tex[i+1]);
+ rmesa->hw.tex[i+1].cmd[TEX_PP_TXFORMAT] &= ~0x08000000;
+ }
+ }
+ } */
+
+ /*
+ * Texture cache LRU hang workaround -------------
+ * not needed for r200 derivatives?
+ */
+ dbg = 0x0;
+
+ if (((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_0_ENABLE)) &&
+ ((((rmesa->hw.tex[0].
+ cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) & 0x04)
+ == 0))
+ || ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_2_ENABLE)
+ &&
+ ((((rmesa->hw.tex[2].
+ cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
+ 0x04) == 0))
+ || ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_4_ENABLE)
+ &&
+ ((((rmesa->hw.tex[4].
+ cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
+ 0x04) == 0))) {
+ dbg |= 0x02;
+ }
+
+ if (((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_1_ENABLE)) &&
+ ((((rmesa->hw.tex[1].
+ cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) & 0x04)
+ == 0))
+ || ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_3_ENABLE)
+ &&
+ ((((rmesa->hw.tex[3].
+ cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
+ 0x04) == 0))
+ || ((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & R200_TEX_5_ENABLE)
+ &&
+ ((((rmesa->hw.tex[5].
+ cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) &
+ 0x04) == 0))) {
+ dbg |= 0x04;
+ }
+
+ if (dbg != rmesa->hw.tam.cmd[TAM_DEBUG3]) {
+ R300_STATECHANGE(rmesa, tam);
+ rmesa->hw.tam.cmd[TAM_DEBUG3] = dbg;
+ if (0)
+ printf("TEXCACHE LRU HANG WORKAROUND %x\n",
+ dbg);
+ }
+ }
+#endif
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_vertexprog.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_vertexprog.c
new file mode 100644
index 000000000..717832048
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/r300_vertexprog.c
@@ -0,0 +1,952 @@
+/**************************************************************************
+
+Copyright (C) 2005 Aapo Tahkola.
+
+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, VA LINUX SYSTEMS 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:
+ * Aapo Tahkola <aet@rasterburn.org>
+ */
+#include "glheader.h"
+#include "macros.h"
+#include "enums.h"
+
+#include "program.h"
+#include "r300_context.h"
+#include "r300_program.h"
+#include "nvvertprog.h"
+
+#define SCALAR_FLAG (1<<31)
+#define FLAG_MASK (1<<31)
+#define OP_MASK (0xf) /* we are unlikely to have more than 15 */
+#define OPN(operator, ip, op) {#operator, VP_OPCODE_##operator, ip, op}
+
+static struct{
+ char *name;
+ int opcode;
+ unsigned long ip; /* number of input operands and flags */
+ unsigned long op;
+}op_names[]={
+ OPN(ABS, 1, 1),
+ OPN(ADD, 2, 1),
+ OPN(ARL, 1, 1|SCALAR_FLAG),
+ OPN(DP3, 2, 3|SCALAR_FLAG),
+ OPN(DP4, 2, 3|SCALAR_FLAG),
+ OPN(DPH, 2, 3|SCALAR_FLAG),
+ OPN(DST, 2, 1),
+ OPN(EX2, 1|SCALAR_FLAG, 4|SCALAR_FLAG),
+ OPN(EXP, 1|SCALAR_FLAG, 1),
+ OPN(FLR, 1, 1),
+ OPN(FRC, 1, 1),
+ OPN(LG2, 1|SCALAR_FLAG, 4|SCALAR_FLAG),
+ OPN(LIT, 1, 1),
+ OPN(LOG, 1|SCALAR_FLAG, 1),
+ OPN(MAD, 3, 1),
+ OPN(MAX, 2, 1),
+ OPN(MIN, 2, 1),
+ OPN(MOV, 1, 1),
+ OPN(MUL, 2, 1),
+ OPN(POW, 2|SCALAR_FLAG, 4|SCALAR_FLAG),
+ OPN(RCP, 1|SCALAR_FLAG, 4|SCALAR_FLAG),
+ OPN(RSQ, 1|SCALAR_FLAG, 4|SCALAR_FLAG),
+ OPN(SGE, 2, 1),
+ OPN(SLT, 2, 1),
+ OPN(SUB, 2, 1),
+ OPN(SWZ, 1, 1),
+ OPN(XPD, 2, 1),
+ OPN(RCC, 0, 0), //extra
+ OPN(PRINT, 0, 0),
+ OPN(END, 0, 0),
+};
+#undef OPN
+#define OPN(rf) {#rf, PROGRAM_##rf}
+
+static struct{
+ char *name;
+ int id;
+}register_file_names[]={
+ OPN(TEMPORARY),
+ OPN(INPUT),
+ OPN(OUTPUT),
+ OPN(LOCAL_PARAM),
+ OPN(ENV_PARAM),
+ OPN(NAMED_PARAM),
+ OPN(STATE_VAR),
+ OPN(WRITE_ONLY),
+ OPN(ADDRESS),
+};
+
+static char *dst_mask_names[4]={ "X", "Y", "Z", "W" };
+
+/* from vertex program spec:
+ Instruction Inputs Output Description
+ ----------- ------ ------ --------------------------------
+ ABS v v absolute value
+ ADD v,v v add
+ ARL v a address register load
+ DP3 v,v ssss 3-component dot product
+ DP4 v,v ssss 4-component dot product
+ DPH v,v ssss homogeneous dot product
+ DST v,v v distance vector
+ EX2 s ssss exponential base 2
+ EXP s v exponential base 2 (approximate)
+ FLR v v floor
+ FRC v v fraction
+ LG2 s ssss logarithm base 2
+ LIT v v compute light coefficients
+ LOG s v logarithm base 2 (approximate)
+ MAD v,v,v v multiply and add
+ MAX v,v v maximum
+ MIN v,v v minimum
+ MOV v v move
+ MUL v,v v multiply
+ POW s,s ssss exponentiate
+ RCP s ssss reciprocal
+ RSQ s ssss reciprocal square root
+ SGE v,v v set on greater than or equal
+ SLT v,v v set on less than
+ SUB v,v v subtract
+ SWZ v v extended swizzle
+ XPD v,v v cross product
+*/
+
+void dump_program_params(GLcontext *ctx, struct vertex_program *vp)
+{
+ int i;
+ int pi;
+
+ fprintf(stderr, "NumInstructions=%d\n", vp->Base.NumInstructions);
+ fprintf(stderr, "NumTemporaries=%d\n", vp->Base.NumTemporaries);
+ fprintf(stderr, "NumParameters=%d\n", vp->Base.NumParameters);
+ fprintf(stderr, "NumAttributes=%d\n", vp->Base.NumAttributes);
+ fprintf(stderr, "NumAddressRegs=%d\n", vp->Base.NumAddressRegs);
+
+ _mesa_load_state_parameters(ctx, vp->Parameters);
+
+#if 0
+ for(pi=0; pi < vp->Base.NumParameters; pi++){
+ fprintf(stderr, "{ ");
+ for(i=0; i < 4; i++)
+ fprintf(stderr, "%f ", vp->Base.LocalParams[pi][i]);
+ fprintf(stderr, "}\n");
+ }
+#endif
+ for(pi=0; pi < vp->Parameters->NumParameters; pi++){
+ fprintf(stderr, "param %02d:", pi);
+
+ switch(vp->Parameters->Parameters[pi].Type){
+
+ case NAMED_PARAMETER:
+ fprintf(stderr, "%s", vp->Parameters->Parameters[pi].Name);
+ fprintf(stderr, "(NAMED_PARAMETER)");
+ break;
+
+ case CONSTANT:
+ fprintf(stderr, "(CONSTANT)");
+ break;
+
+ case STATE:
+ fprintf(stderr, "(STATE)\n");
+ break;
+
+ }
+
+ fprintf(stderr, "{ ");
+ for(i=0; i < 4; i++)
+ fprintf(stderr, "%f ", vp->Parameters->ParameterValues[pi][i]);
+ fprintf(stderr, "}\n");
+
+ }
+}
+
+void debug_vp(GLcontext *ctx, struct vertex_program *vp)
+{
+ struct vp_instruction *vpi;
+ int i, operand_index;
+ int operator_index;
+
+ dump_program_params(ctx, vp);
+
+ vpi=vp->Instructions;
+
+ for(;; vpi++){
+ if(vpi->Opcode == VP_OPCODE_END)
+ break;
+
+ for(i=0; i < sizeof(op_names) / sizeof(*op_names); i++){
+ if(vpi->Opcode == op_names[i].opcode){
+ fprintf(stderr, "%s ", op_names[i].name);
+ break;
+ }
+ }
+ operator_index=i;
+
+ for(i=0; i < sizeof(register_file_names) / sizeof(*register_file_names); i++){
+ if(vpi->DstReg.File == register_file_names[i].id){
+ fprintf(stderr, "%s ", register_file_names[i].name);
+ break;
+ }
+ }
+
+ fprintf(stderr, "%d.", vpi->DstReg.Index);
+
+ for(i=0; i < 4; i++)
+ if(vpi->DstReg.WriteMask & (1<<i))
+ fprintf(stderr, "%s", dst_mask_names[i]);
+ fprintf(stderr, " ");
+
+ for(operand_index=0; operand_index < (op_names[operator_index].ip & (~FLAG_MASK));
+ operand_index++){
+
+ if(vpi->SrcReg[operand_index].Negate)
+ fprintf(stderr, "-");
+
+ for(i=0; i < sizeof(register_file_names) / sizeof(*register_file_names); i++){
+ if(vpi->SrcReg[operand_index].File == register_file_names[i].id){
+ fprintf(stderr, "%s ", register_file_names[i].name);
+ break;
+ }
+ }
+ fprintf(stderr, "%d.", vpi->SrcReg[operand_index].Index);
+
+ for(i=0; i < 4; i++)
+ fprintf(stderr, "%s", dst_mask_names[GET_SWZ(vpi->SrcReg[operand_index].Swizzle, i)]);
+
+ if(operand_index+1 < (op_names[operator_index].ip & (~FLAG_MASK)) )
+ fprintf(stderr, ",");
+ }
+ fprintf(stderr, "\n");
+ }
+
+}
+
+void r300VertexProgUpdateParams(GLcontext *ctx, struct r300_vertex_program *vp)
+{
+ int pi;
+ struct vertex_program *mesa_vp=(void *)vp;
+ int dst_index;
+
+ _mesa_load_state_parameters(ctx, mesa_vp->Parameters);
+
+ //debug_vp(ctx, mesa_vp);
+ if(mesa_vp->Parameters->NumParameters * 4 > VSF_MAX_FRAGMENT_LENGTH){
+ fprintf(stderr, "%s:Params exhausted\n", __FUNCTION__);
+ exit(-1);
+ }
+ dst_index=0;
+ for(pi=0; pi < mesa_vp->Parameters->NumParameters; pi++){
+ switch(mesa_vp->Parameters->Parameters[pi].Type){
+
+ case STATE:
+ case NAMED_PARAMETER:
+ //fprintf(stderr, "%s", vp->Parameters->Parameters[pi].Name);
+ case CONSTANT:
+ vp->params.body.f[dst_index++]=mesa_vp->Parameters->ParameterValues[pi][0];
+ vp->params.body.f[dst_index++]=mesa_vp->Parameters->ParameterValues[pi][1];
+ vp->params.body.f[dst_index++]=mesa_vp->Parameters->ParameterValues[pi][2];
+ vp->params.body.f[dst_index++]=mesa_vp->Parameters->ParameterValues[pi][3];
+ break;
+
+ default: _mesa_problem(NULL, "Bad param type in %s", __FUNCTION__);
+ }
+
+ }
+
+ vp->params.length=dst_index;
+}
+
+static unsigned long t_dst_mask(GLuint mask)
+{
+ unsigned long flags=0;
+
+ if(mask & WRITEMASK_X) flags |= VSF_FLAG_X;
+ if(mask & WRITEMASK_Y) flags |= VSF_FLAG_Y;
+ if(mask & WRITEMASK_Z) flags |= VSF_FLAG_Z;
+ if(mask & WRITEMASK_W) flags |= VSF_FLAG_W;
+
+ return flags;
+}
+
+static unsigned long t_dst_class(enum register_file file)
+{
+
+ switch(file){
+ case PROGRAM_TEMPORARY:
+ return VSF_OUT_CLASS_TMP;
+ case PROGRAM_OUTPUT:
+ return VSF_OUT_CLASS_RESULT;
+ /*
+ case PROGRAM_INPUT:
+ case PROGRAM_LOCAL_PARAM:
+ case PROGRAM_ENV_PARAM:
+ case PROGRAM_NAMED_PARAM:
+ case PROGRAM_STATE_VAR:
+ case PROGRAM_WRITE_ONLY:
+ case PROGRAM_ADDRESS:
+ */
+ default:
+ fprintf(stderr, "problem in %s", __FUNCTION__);
+ exit(0);
+ }
+}
+
+static unsigned long t_dst_index(struct r300_vertex_program *vp, struct vp_dst_register *dst)
+{
+ if(dst->File == PROGRAM_OUTPUT) {
+ if (vp->outputs[dst->Index] != -1)
+ return vp->outputs[dst->Index];
+ else {
+ WARN_ONCE("Unknown output %d\n", dst->Index);
+ return 10;
+ }
+ }
+ return dst->Index;
+}
+
+static unsigned long t_src_class(enum register_file file)
+{
+
+ switch(file){
+ case PROGRAM_TEMPORARY:
+ return VSF_IN_CLASS_TMP;
+
+ case PROGRAM_INPUT:
+ return VSF_IN_CLASS_ATTR;
+
+ case PROGRAM_LOCAL_PARAM:
+ case PROGRAM_ENV_PARAM:
+ case PROGRAM_NAMED_PARAM:
+ case PROGRAM_STATE_VAR:
+ return VSF_IN_CLASS_PARAM;
+ /*
+ case PROGRAM_OUTPUT:
+ case PROGRAM_WRITE_ONLY:
+ case PROGRAM_ADDRESS:
+ */
+ default:
+ fprintf(stderr, "problem in %s", __FUNCTION__);
+ exit(0);
+ }
+}
+
+static unsigned long t_swizzle(GLubyte swizzle)
+{
+ switch(swizzle){
+ case SWIZZLE_X: return VSF_IN_COMPONENT_X;
+ case SWIZZLE_Y: return VSF_IN_COMPONENT_Y;
+ case SWIZZLE_Z: return VSF_IN_COMPONENT_Z;
+ case SWIZZLE_W: return VSF_IN_COMPONENT_W;
+ case SWIZZLE_ZERO: return VSF_IN_COMPONENT_ZERO;
+ case SWIZZLE_ONE: return VSF_IN_COMPONENT_ONE;
+ default:
+ fprintf(stderr, "problem in %s", __FUNCTION__);
+ exit(0);
+ }
+}
+
+static void vp_dump_inputs(struct r300_vertex_program *vp, char *caller)
+{
+ int i;
+
+ if(vp == NULL){
+ fprintf(stderr, "vp null in call to %s from %s\n", __FUNCTION__, caller);
+ return ;
+ }
+
+ fprintf(stderr, "%s:<", caller);
+ for(i=0; i < VERT_ATTRIB_MAX; i++)
+ fprintf(stderr, "%d ", vp->inputs[i]);
+ fprintf(stderr, ">\n");
+
+}
+
+static unsigned long t_src_index(struct r300_vertex_program *vp, struct vp_src_register *src)
+{
+ int i;
+ int max_reg=-1;
+
+ if(src->File == PROGRAM_INPUT){
+ if(vp->inputs[src->Index] != -1)
+ return vp->inputs[src->Index];
+
+ for(i=0; i < VERT_ATTRIB_MAX; i++)
+ if(vp->inputs[i] > max_reg)
+ max_reg=vp->inputs[i];
+
+ vp->inputs[src->Index]=max_reg+1;
+
+ //vp_dump_inputs(vp, __FUNCTION__);
+
+ return vp->inputs[src->Index];
+ }else{
+ return src->Index;
+ }
+}
+
+static unsigned long t_src(struct r300_vertex_program *vp, struct vp_src_register *src)
+{
+
+ return MAKE_VSF_SOURCE(t_src_index(vp, src),
+ t_swizzle(GET_SWZ(src->Swizzle, 0)),
+ t_swizzle(GET_SWZ(src->Swizzle, 1)),
+ t_swizzle(GET_SWZ(src->Swizzle, 2)),
+ t_swizzle(GET_SWZ(src->Swizzle, 3)),
+ t_src_class(src->File),
+ src->Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
+}
+
+static unsigned long t_src_scalar(struct r300_vertex_program *vp, struct vp_src_register *src)
+{
+
+ return MAKE_VSF_SOURCE(t_src_index(vp, src),
+ t_swizzle(GET_SWZ(src->Swizzle, 0)),
+ t_swizzle(GET_SWZ(src->Swizzle, 0)),
+ t_swizzle(GET_SWZ(src->Swizzle, 0)),
+ t_swizzle(GET_SWZ(src->Swizzle, 0)),
+ t_src_class(src->File),
+ src->Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
+}
+
+static unsigned long t_opcode(enum vp_opcode opcode)
+{
+
+ switch(opcode){
+ case VP_OPCODE_DST: return R300_VPI_OUT_OP_DST;
+ case VP_OPCODE_EX2: return R300_VPI_OUT_OP_EX2;
+ case VP_OPCODE_EXP: return R300_VPI_OUT_OP_EXP;
+ case VP_OPCODE_FRC: return R300_VPI_OUT_OP_FRC;
+ case VP_OPCODE_LG2: return R300_VPI_OUT_OP_LG2;
+ case VP_OPCODE_LOG: return R300_VPI_OUT_OP_LOG;
+ case VP_OPCODE_MAX: return R300_VPI_OUT_OP_MAX;
+ case VP_OPCODE_MIN: return R300_VPI_OUT_OP_MIN;
+ case VP_OPCODE_MUL: return R300_VPI_OUT_OP_MUL;
+ case VP_OPCODE_POW: return R300_VPI_OUT_OP_POW;
+ case VP_OPCODE_RCP: return R300_VPI_OUT_OP_RCP;
+ case VP_OPCODE_RSQ: return R300_VPI_OUT_OP_RSQ;
+ case VP_OPCODE_SGE: return R300_VPI_OUT_OP_SGE;
+ case VP_OPCODE_SLT: return R300_VPI_OUT_OP_SLT;
+ case VP_OPCODE_DP4: return R300_VPI_OUT_OP_DOT;
+
+ default:
+ fprintf(stderr, "%s: Should not be called with opcode %d!", __FUNCTION__, opcode);
+ }
+ exit(-1);
+ return 0;
+}
+
+static unsigned long op_operands(enum vp_opcode opcode)
+{
+ int i;
+
+ /* Can we trust mesas opcodes to be in order ? */
+ for(i=0; i < sizeof(op_names) / sizeof(*op_names); i++)
+ if(op_names[i].opcode == opcode)
+ return op_names[i].ip;
+
+ fprintf(stderr, "op %d not found in op_names\n", opcode);
+ exit(-1);
+ return 0;
+}
+
+/* TODO: Get rid of t_src_class call */
+#define CMP_SRCS(a, b) (a.Index != b.Index && \
+ ((t_src_class(a.File) == VSF_IN_CLASS_PARAM && \
+ t_src_class(b.File) == VSF_IN_CLASS_PARAM) || \
+ (t_src_class(a.File) == VSF_IN_CLASS_ATTR && \
+ t_src_class(b.File) == VSF_IN_CLASS_ATTR))) \
+
+#define SRCS_WRITABLE 1
+void translate_vertex_shader(struct r300_vertex_program *vp)
+{
+ struct vertex_program *mesa_vp=(void *)vp;
+ struct vp_instruction *vpi;
+ int i, cur_reg=0;
+ VERTEX_SHADER_INSTRUCTION *o_inst;
+ unsigned long operands;
+ int are_srcs_scalar;
+ unsigned long hw_op;
+ /* Initial value should be last tmp reg that hw supports.
+ Strangely enough r300 doesnt mind even though these would be out of range.
+ Smart enough to realize that it doesnt need it? */
+ int u_temp_i=VSF_MAX_FRAGMENT_TEMPS-1;
+#ifdef SRCS_WRITABLE
+ struct vp_src_register src[3];
+#else
+#define src vpi->SrcReg
+#endif
+ vp->pos_end=0; /* Not supported yet */
+ vp->program.length=0;
+ vp->num_temporaries=mesa_vp->Base.NumTemporaries;
+
+ for(i=0; i < VERT_ATTRIB_MAX; i++)
+ vp->inputs[i] = -1;
+
+ for(i=0; i < VERT_RESULT_MAX; i++)
+ vp->outputs[i] = -1;
+
+ assert(mesa_vp->OutputsWritten & (1 << VERT_RESULT_HPOS));
+ assert(mesa_vp->OutputsWritten & (1 << VERT_RESULT_COL0));
+
+ /* Assign outputs */
+ if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_HPOS))
+ vp->outputs[VERT_RESULT_HPOS] = cur_reg++;
+
+ if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_PSIZ))
+ vp->outputs[VERT_RESULT_PSIZ] = cur_reg++;
+
+ if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_COL0))
+ vp->outputs[VERT_RESULT_COL0] = cur_reg++;
+
+#if 0 /* Not supported yet */
+ if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_BFC0))
+ vp->outputs[VERT_RESULT_BFC0] = cur_reg++;
+
+ if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_COL1))
+ vp->outputs[VERT_RESULT_COL1] = cur_reg++;
+
+ if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_BFC1))
+ vp->outputs[VERT_RESULT_BFC1] = cur_reg++;
+
+ if(mesa_vp->OutputsWritten & (1 << VERT_RESULT_FOGC))
+ vp->outputs[VERT_RESULT_FOGC] = cur_reg++;
+#endif
+
+ for(i=VERT_RESULT_TEX0; i <= VERT_RESULT_TEX7; i++)
+ if(mesa_vp->OutputsWritten & (1 << i))
+ vp->outputs[i] = cur_reg++;
+
+ o_inst=vp->program.body.i;
+ for(vpi=mesa_vp->Instructions; vpi->Opcode != VP_OPCODE_END; vpi++, o_inst++){
+
+ operands=op_operands(vpi->Opcode);
+ are_srcs_scalar=operands & SCALAR_FLAG;
+ operands &= OP_MASK;
+
+ for(i=0; i < operands; i++)
+ src[i]=vpi->SrcReg[i];
+#if 1
+ if(operands == 3){ /* TODO: scalars */
+ if( CMP_SRCS(src[1], src[2]) || CMP_SRCS(src[0], src[2]) ){
+ o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, u_temp_i,
+ VSF_FLAG_ALL, VSF_OUT_CLASS_TMP);
+
+ o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[2]),
+ SWIZZLE_X, SWIZZLE_Y,
+ SWIZZLE_Z, SWIZZLE_W,
+ t_src_class(src[2].File), VSF_FLAG_NONE);
+
+ o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[2]),
+ SWIZZLE_ZERO, SWIZZLE_ZERO,
+ SWIZZLE_ZERO, SWIZZLE_ZERO,
+ t_src_class(src[2].File), VSF_FLAG_NONE);
+ o_inst->src3=0;
+ o_inst++;
+
+ src[2].File=PROGRAM_TEMPORARY;
+ src[2].Index=u_temp_i;
+ u_temp_i--;
+ }
+
+ }
+ if(operands >= 2){
+ if( CMP_SRCS(src[1], src[0]) ){
+ o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, u_temp_i,
+ VSF_FLAG_ALL, VSF_OUT_CLASS_TMP);
+
+ o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ SWIZZLE_X, SWIZZLE_Y,
+ SWIZZLE_Z, SWIZZLE_W,
+ t_src_class(src[0].File), VSF_FLAG_NONE);
+
+ o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ SWIZZLE_ZERO, SWIZZLE_ZERO,
+ SWIZZLE_ZERO, SWIZZLE_ZERO,
+ t_src_class(src[0].File), VSF_FLAG_NONE);
+ o_inst->src3=0;
+ o_inst++;
+
+ src[0].File=PROGRAM_TEMPORARY;
+ src[0].Index=u_temp_i;
+ u_temp_i--;
+ }
+ }
+#endif
+ /* these ops need special handling.
+ Ops that need temp vars should probably be given reg indexes starting at the end of tmp area. */
+ switch(vpi->Opcode){
+ case VP_OPCODE_MOV://ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{} {ZERO ZERO ZERO ZERO}
+ o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
+ o_inst->src1=t_src(vp, &src[0]);
+ o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ SWIZZLE_ZERO, SWIZZLE_ZERO,
+ SWIZZLE_ZERO, SWIZZLE_ZERO,
+ t_src_class(src[0].File), VSF_FLAG_NONE);
+
+ o_inst->src3=0;
+
+ goto next;
+
+ case VP_OPCODE_ADD:
+ hw_op=(src[0].File == PROGRAM_TEMPORARY &&
+ src[1].File == PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD;
+
+ o_inst->op=MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
+ o_inst->src1=t_src(vp, &src[0]);
+ o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ SWIZZLE_ONE, SWIZZLE_ONE,
+ SWIZZLE_ONE, SWIZZLE_ONE,
+ t_src_class(src[0].File), VSF_FLAG_NONE);
+ o_inst->src3=t_src(vp, &src[1]);
+ goto next;
+
+ case VP_OPCODE_MAD:
+ hw_op=(src[0].File == PROGRAM_TEMPORARY &&
+ src[1].File == PROGRAM_TEMPORARY &&
+ src[2].File == PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD;
+
+ o_inst->op=MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
+ o_inst->src1=t_src(vp, &src[0]);
+ o_inst->src2=t_src(vp, &src[1]);
+ o_inst->src3=t_src(vp, &src[2]);
+ goto next;
+
+ case VP_OPCODE_MUL: /* HW mul can take third arg but appears to have some other limitations. */
+ hw_op=(src[0].File == PROGRAM_TEMPORARY &&
+ src[1].File == PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD;
+
+ o_inst->op=MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
+ o_inst->src1=t_src(vp, &src[0]);
+ o_inst->src2=t_src(vp, &src[1]);
+
+ o_inst->src3=MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
+ SWIZZLE_ZERO, SWIZZLE_ZERO,
+ SWIZZLE_ZERO, SWIZZLE_ZERO,
+ t_src_class(src[1].File), VSF_FLAG_NONE);
+ goto next;
+
+ case VP_OPCODE_DP3://DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ZERO} PARAM 0{} {X Y Z ZERO}
+ o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
+
+ o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
+ SWIZZLE_ZERO,
+ t_src_class(src[0].File),
+ src[0].Negate ? VSF_FLAG_XYZ : VSF_FLAG_NONE);
+
+ o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 1)),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 2)),
+ SWIZZLE_ZERO,
+ t_src_class(src[1].File),
+ src[1].Negate ? VSF_FLAG_XYZ : VSF_FLAG_NONE);
+
+ o_inst->src3=0;
+ goto next;
+
+ case VP_OPCODE_SUB://ADD RESULT 1.X Y Z W TMP 0{} {X Y Z W} PARAM 1{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W
+#if 1
+ hw_op=(src[0].File == PROGRAM_TEMPORARY &&
+ src[1].File == PROGRAM_TEMPORARY) ? R300_VPI_OUT_OP_MAD_2 : R300_VPI_OUT_OP_MAD;
+
+ o_inst->op=MAKE_VSF_OP(hw_op, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
+ o_inst->src1=t_src(vp, &src[0]);
+ o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ SWIZZLE_ONE, SWIZZLE_ONE,
+ SWIZZLE_ONE, SWIZZLE_ONE,
+ t_src_class(src[0].File), VSF_FLAG_NONE);
+ o_inst->src3=MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 1)),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 2)),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 3)),
+ t_src_class(src[1].File),
+ (!src[1].Negate) ? VSF_FLAG_ALL : VSF_FLAG_NONE);
+#else
+ o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
+
+ o_inst->src1=t_src(vp, &src[0]);
+ o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 1)),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 2)),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 3)),
+ t_src_class(src[1].File),
+ (!src[1].Negate) ? VSF_FLAG_ALL : VSF_FLAG_NONE);
+ o_inst->src3=0;
+#endif
+ goto next;
+
+ case VP_OPCODE_ABS://MAX RESULT 1.X Y Z W PARAM 0{} {X Y Z W} PARAM 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W
+ o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_MAX, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
+
+ o_inst->src1=t_src(vp, &src[0]);
+ o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)),
+ t_src_class(src[0].File),
+ (!src[0].Negate) ? VSF_FLAG_ALL : VSF_FLAG_NONE);
+ o_inst->src3=0;
+ goto next;
+
+ case VP_OPCODE_FLR:
+ /* FRC TMP 0.X Y Z W PARAM 0{} {X Y Z W}
+ ADD RESULT 1.X Y Z W PARAM 0{} {X Y Z W} TMP 0{X Y Z W } {X Y Z W} neg Xneg Yneg Zneg W */
+
+ o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_FRC, u_temp_i,
+ t_dst_mask(vpi->DstReg.WriteMask), VSF_OUT_CLASS_TMP);
+
+ o_inst->src1=t_src(vp, &src[0]);
+ o_inst->src2=0;
+ o_inst->src3=0;
+ o_inst++;
+
+ o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_ADD, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
+
+ o_inst->src1=t_src(vp, &src[0]);
+ o_inst->src2=MAKE_VSF_SOURCE(u_temp_i,
+ VSF_IN_COMPONENT_X,
+ VSF_IN_COMPONENT_Y,
+ VSF_IN_COMPONENT_Z,
+ VSF_IN_COMPONENT_W,
+ VSF_IN_CLASS_TMP,
+ /* Not 100% sure about this */
+ (!src[1].Negate) ? VSF_FLAG_ALL : VSF_FLAG_NONE/*VSF_FLAG_ALL*/);
+
+ o_inst->src3=0;
+ u_temp_i--;
+ goto next;
+
+ case VP_OPCODE_LG2:// LG2 RESULT 1.X Y Z W PARAM 0{} {X X X X}
+ o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_LG2, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
+
+ o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+ t_src_class(src[0].File),
+ src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
+ o_inst->src2=0;
+ o_inst->src3=0;
+ goto next;
+
+ case VP_OPCODE_LIT://LIT TMP 1.Y Z TMP 1{} {X W Z Y} TMP 1{} {Y W Z X} TMP 1{} {Y X Z W}
+ o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_LIT, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
+ /* NOTE: Users swizzling might not work. */
+ o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
+ t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z
+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
+ t_src_class(src[0].File),
+ src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
+ o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
+ t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
+ t_src_class(src[0].File),
+ src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
+ o_inst->src3=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
+ t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z
+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
+ t_src_class(src[0].File),
+ src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
+ goto next;
+
+ case VP_OPCODE_DPH://DOT RESULT 1.X Y Z W PARAM 0{} {X Y Z ONE} PARAM 0{} {X Y Z W}
+ o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_DOT, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
+
+ o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 2)),
+ VSF_IN_COMPONENT_ONE,
+ t_src_class(src[0].File),
+ src[0].Negate ? VSF_FLAG_XYZ : VSF_FLAG_NONE);
+ o_inst->src2=t_src(vp, &src[1]);
+ o_inst->src3=0;
+ goto next;
+
+ case VP_OPCODE_XPD:
+ /* mul r0, r1.yzxw, r2.zxyw
+ mad r0, -r2.yzxw, r1.zxyw, r0
+ NOTE: might need MAD_2
+ */
+
+ o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, u_temp_i,
+ t_dst_mask(vpi->DstReg.WriteMask), VSF_OUT_CLASS_TMP);
+
+ o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
+ t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
+ t_src_class(src[0].File),
+ src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
+
+ o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z
+ t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x
+ t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y
+ t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w
+ t_src_class(src[1].File),
+ src[1].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
+
+ o_inst->src3=MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
+ SWIZZLE_ZERO, SWIZZLE_ZERO,
+ SWIZZLE_ZERO, SWIZZLE_ZERO,
+ t_src_class(src[1].File),
+ VSF_FLAG_NONE);
+ o_inst++;
+ u_temp_i--;
+
+ o_inst->op=MAKE_VSF_OP(R300_VPI_OUT_OP_MAD, t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
+
+ o_inst->src1=MAKE_VSF_SOURCE(t_src_index(vp, &src[1]),
+ t_swizzle(GET_SWZ(src[1].Swizzle, 1)), // y
+ t_swizzle(GET_SWZ(src[1].Swizzle, 2)), // z
+ t_swizzle(GET_SWZ(src[1].Swizzle, 0)), // x
+ t_swizzle(GET_SWZ(src[1].Swizzle, 3)), // w
+ t_src_class(src[1].File),
+ (!src[1].Negate) ? VSF_FLAG_ALL : VSF_FLAG_NONE);
+
+ o_inst->src2=MAKE_VSF_SOURCE(t_src_index(vp, &src[0]),
+ t_swizzle(GET_SWZ(src[0].Swizzle, 2)), // z
+ t_swizzle(GET_SWZ(src[0].Swizzle, 0)), // x
+ t_swizzle(GET_SWZ(src[0].Swizzle, 1)), // y
+ t_swizzle(GET_SWZ(src[0].Swizzle, 3)), // w
+ t_src_class(src[0].File),
+ src[0].Negate ? VSF_FLAG_ALL : VSF_FLAG_NONE);
+
+ o_inst->src3=MAKE_VSF_SOURCE(u_temp_i+1,
+ VSF_IN_COMPONENT_X,
+ VSF_IN_COMPONENT_Y,
+ VSF_IN_COMPONENT_Z,
+ VSF_IN_COMPONENT_W,
+ VSF_IN_CLASS_TMP,
+ VSF_FLAG_NONE);
+
+ goto next;
+
+ case VP_OPCODE_ARL:
+ case VP_OPCODE_SWZ:
+ case VP_OPCODE_RCC:
+ case VP_OPCODE_PRINT:
+ //vp->num_temporaries++;
+ fprintf(stderr, "Dont know how to handle op %d yet\n", vpi->Opcode);
+ exit(-1);
+ break;
+ case VP_OPCODE_END:
+ break;
+ default:
+ break;
+ }
+
+ o_inst->op=MAKE_VSF_OP(t_opcode(vpi->Opcode), t_dst_index(vp, &vpi->DstReg),
+ t_dst_mask(vpi->DstReg.WriteMask), t_dst_class(vpi->DstReg.File));
+
+ if(are_srcs_scalar){
+ switch(operands){
+ case 1:
+ o_inst->src1=t_src_scalar(vp, &src[0]);
+ o_inst->src2=0;
+ o_inst->src3=0;
+ break;
+
+ case 2:
+ o_inst->src1=t_src_scalar(vp, &src[0]);
+ o_inst->src2=t_src_scalar(vp, &src[1]);
+ o_inst->src3=0;
+ break;
+
+ case 3:
+ o_inst->src1=t_src_scalar(vp, &src[0]);
+ o_inst->src2=t_src_scalar(vp, &src[1]);
+ o_inst->src3=t_src_scalar(vp, &src[2]);
+ break;
+
+ default:
+ fprintf(stderr, "scalars and op RCC not handled yet");
+ exit(-1);
+ break;
+ }
+ }else{
+ switch(operands){
+ case 1:
+ o_inst->src1=t_src(vp, &src[0]);
+ o_inst->src2=0;
+ o_inst->src3=0;
+ break;
+
+ case 2:
+ o_inst->src1=t_src(vp, &src[0]);
+ o_inst->src2=t_src(vp, &src[1]);
+ o_inst->src3=0;
+ break;
+
+ case 3:
+ o_inst->src1=t_src(vp, &src[0]);
+ o_inst->src2=t_src(vp, &src[1]);
+ o_inst->src3=t_src(vp, &src[2]);
+ break;
+
+ default:
+ fprintf(stderr, "scalars and op RCC not handled yet");
+ exit(-1);
+ break;
+ }
+ }
+ next: ;
+ }
+
+ vp->program.length=(o_inst - vp->program.body.i) * 4;
+
+ if(u_temp_i < vp->num_temporaries)
+ vp->translated=GL_FALSE; /* temps exhausted - program cannot be run */
+ else
+ vp->translated=GL_TRUE;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_context.c
new file mode 100644
index 000000000..97507617c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_context.c
@@ -0,0 +1,312 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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.
+
+**************************************************************************/
+
+/**
+ * \file radeon_context.c
+ * Common context initialization.
+ *
+ * \author Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include <dlfcn.h>
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "state.h"
+#include "matrix.h"
+#include "framebuffer.h"
+
+#include "drivers/common/driverfuncs.h"
+#include "swrast/swrast.h"
+
+#include "radeon_screen.h"
+#include "r200_context.h"
+#include "radeon_ioctl.h"
+#include "radeon_macros.h"
+#include "radeon_reg.h"
+#include "r200_state.h"
+
+#include "utils.h"
+#include "vblank.h"
+#include "xmlpool.h" /* for symbolic values of enum-type options */
+
+#define DRIVER_DATE "20040924"
+
+
+/* Return various strings for glGetString().
+ */
+static const GLubyte *radeonGetString(GLcontext * ctx, GLenum name)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ static char buffer[128];
+
+ switch (name) {
+ case GL_VENDOR:
+ return (GLubyte *) "Tungsten Graphics, Inc.";
+
+ case GL_RENDERER:
+ {
+ unsigned offset;
+ GLuint agp_mode = radeon->radeonScreen->IsPCI ? 0 :
+ radeon->radeonScreen->AGPMode;
+ const char* chipname;
+
+ if (IS_FAMILY_R300(radeon))
+ chipname = "R300";
+ else
+ chipname = "R200";
+
+ offset = driGetRendererString(buffer, chipname, DRIVER_DATE,
+ agp_mode);
+
+ sprintf(&buffer[offset], " %sTCL",
+ !(radeon->TclFallback & RADEON_TCL_FALLBACK_TCL_DISABLE)
+ ? "" : "NO-");
+
+ return (GLubyte *) buffer;
+ }
+
+ default:
+ return NULL;
+ }
+}
+
+
+/* Return the width and height of the given buffer.
+ */
+static void radeonGetBufferSize(GLframebuffer * buffer,
+ GLuint * width, GLuint * height)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+
+ LOCK_HARDWARE(radeon);
+ *width = radeon->dri.drawable->w;
+ *height = radeon->dri.drawable->h;
+ UNLOCK_HARDWARE(radeon);
+}
+
+
+/* Initialize the driver's misc functions.
+ */
+static void radeonInitDriverFuncs(struct dd_function_table *functions)
+{
+ functions->GetBufferSize = radeonGetBufferSize;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
+ functions->GetString = radeonGetString;
+}
+
+
+/**
+ * Create and initialize all common fields of the context,
+ * including the Mesa context itself.
+ */
+GLboolean radeonInitContext(radeonContextPtr radeon,
+ struct dd_function_table* functions,
+ const __GLcontextModes * glVisual,
+ __DRIcontextPrivate * driContextPriv,
+ void *sharedContextPrivate)
+{
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ radeonScreenPtr screen = (radeonScreenPtr) (sPriv->private);
+ GLcontext* ctx;
+ GLcontext* shareCtx;
+ int fthrottle_mode;
+
+ /* Fill in additional standard functions. */
+ radeonInitDriverFuncs(functions);
+
+ /* Allocate and initialize the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((radeonContextPtr)sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ radeon->glCtx = _mesa_create_context(glVisual, shareCtx,
+ functions, (void *)radeon);
+ if (!radeon->glCtx)
+ return GL_FALSE;
+
+ ctx = radeon->glCtx;
+ driContextPriv->driverPrivate = radeon;
+
+ /* DRI fields */
+ radeon->dri.context = driContextPriv;
+ radeon->dri.screen = sPriv;
+ radeon->dri.drawable = NULL; /* Set by XMesaMakeCurrent */
+ radeon->dri.hwContext = driContextPriv->hHWContext;
+ radeon->dri.hwLock = &sPriv->pSAREA->lock;
+ radeon->dri.fd = sPriv->fd;
+ radeon->dri.drmMinor = sPriv->drmMinor;
+
+ radeon->radeonScreen = screen;
+ radeon->sarea = (drm_radeon_sarea_t *) ((GLubyte *) sPriv->pSAREA +
+ screen->sarea_priv_offset);
+
+ /* Setup IRQs */
+ fthrottle_mode = driQueryOptioni(&radeon->optionCache, "fthrottle_mode");
+ radeon->iw.irq_seq = -1;
+ radeon->irqsEmitted = 0;
+ radeon->do_irqs = (radeon->dri.drmMinor >= 6 &&
+ fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS &&
+ radeon->radeonScreen->irq);
+
+ radeon->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
+
+ if (!radeon->do_irqs)
+ fprintf(stderr,
+ "IRQ's not enabled, falling back to %s: %d %d %d\n",
+ radeon->do_usleeps ? "usleeps" : "busy waits",
+ radeon->dri.drmMinor,
+ fthrottle_mode, radeon->radeonScreen->irq);
+
+ radeon->vblank_flags = (radeon->radeonScreen->irq != 0)
+ ? driGetDefaultVBlankFlags(&radeon->optionCache) : VBLANK_FLAG_NO_IRQ;
+
+ (*dri_interface->getUST) (&radeon->swap_ust);
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Cleanup common context fields.
+ * Called by r200DestroyContext/r300DestroyContext
+ */
+void radeonCleanupContext(radeonContextPtr radeon)
+{
+ /* free the Mesa context */
+ radeon->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(radeon->glCtx);
+
+ if (radeon->state.scissor.pClipRects) {
+ FREE(radeon->state.scissor.pClipRects);
+ radeon->state.scissor.pClipRects = 0;
+ }
+}
+
+
+/**
+ * Swap front and back buffer.
+ */
+void radeonSwapBuffers(__DRIdrawablePrivate * dPriv)
+{
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ radeonContextPtr radeon;
+ GLcontext *ctx;
+
+ radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+ ctx = radeon->glCtx;
+
+ if (ctx->Visual.doubleBufferMode) {
+ _mesa_notifySwapBuffers(ctx); /* flush pending rendering comands */
+ if (radeon->doPageFlip) {
+ radeonPageFlip(dPriv);
+ } else {
+ radeonCopyBuffer(dPriv);
+ }
+ }
+ } else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ _mesa_problem(NULL, "%s: drawable has no context!",
+ __FUNCTION__);
+ }
+}
+
+
+/* Force the context `c' to be the current context and associate with it
+ * buffer `b'.
+ */
+GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
+ __DRIdrawablePrivate * driDrawPriv,
+ __DRIdrawablePrivate * driReadPriv)
+{
+ if (driContextPriv) {
+ radeonContextPtr radeon =
+ (radeonContextPtr) driContextPriv->driverPrivate;
+
+ if (RADEON_DEBUG & DEBUG_DRI)
+ fprintf(stderr, "%s ctx %p\n", __FUNCTION__,
+ radeon->glCtx);
+
+ if (radeon->dri.drawable != driDrawPriv) {
+ driDrawableInitVBlank(driDrawPriv,
+ radeon->vblank_flags);
+ radeon->dri.drawable = driDrawPriv;
+
+#if R200_MERGED
+ if (IS_FAMILY_R200(radeon)) {
+ r200UpdateWindow(radeon->glCtx);
+ r200UpdateViewportOffset(radeon->glCtx);
+ }
+#endif
+ }
+
+ _mesa_make_current(radeon->glCtx,
+ (GLframebuffer *) driDrawPriv->
+ driverPrivate,
+ (GLframebuffer *) driReadPriv->
+ driverPrivate);
+
+ if (!radeon->glCtx->Viewport.Width) {
+ _mesa_set_viewport(radeon->glCtx, 0, 0,
+ driDrawPriv->w, driDrawPriv->h);
+ }
+
+ _mesa_update_state(radeon->glCtx);
+
+#if R200_MERGED
+ if (IS_FAMILY_R200(radeon))
+ r200ValidateState(radeon->glCtx);
+#endif
+
+ } else {
+ if (RADEON_DEBUG & DEBUG_DRI)
+ fprintf(stderr, "%s ctx is null\n", __FUNCTION__);
+ _mesa_make_current(0, 0, 0);
+ }
+
+ if (RADEON_DEBUG & DEBUG_DRI)
+ fprintf(stderr, "End %s\n", __FUNCTION__);
+ return GL_TRUE;
+}
+
+/* Force the context `c' to be unbound from its buffer.
+ */
+GLboolean radeonUnbindContext(__DRIcontextPrivate * driContextPriv)
+{
+ radeonContextPtr radeon = (radeonContextPtr) driContextPriv->driverPrivate;
+
+ if (RADEON_DEBUG & DEBUG_DRI)
+ fprintf(stderr, "%s ctx %p\n", __FUNCTION__,
+ radeon->glCtx);
+
+ return GL_TRUE;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_context.h
new file mode 100644
index 000000000..189bc6ad0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_context.h
@@ -0,0 +1,249 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ * Nicolai Haehnle <prefect_@gmx.net>
+ */
+
+#ifndef __RADEON_CONTEXT_H__
+#define __RADEON_CONTEXT_H__
+
+#include "mtypes.h"
+#include "radeon_screen.h"
+#include "drm.h"
+#include "dri_util.h"
+
+struct radeon_context;
+typedef struct radeon_context radeonContextRec;
+typedef struct radeon_context* radeonContextPtr;
+
+static __inline GLuint radeonPackColor(GLuint cpp,
+ GLubyte r, GLubyte g, GLubyte b, GLubyte a)
+{
+ switch (cpp) {
+ case 2:
+ return PACK_COLOR_565(r, g, b);
+ case 4:
+ return PACK_COLOR_8888(a, r, g, b);
+ default:
+ return 0;
+ }
+}
+
+#define TEX_0 0x1
+#define TEX_1 0x2
+#define TEX_2 0x4
+#define TEX_3 0x8
+#define TEX_4 0x10
+#define TEX_5 0x20
+#define TEX_6 0x40
+#define TEX_7 0x80
+#define TEX_ALL 0xff
+
+
+/* Rasterizing fallbacks */
+/* See correponding strings in r200_swtcl.c */
+#define RADEON_FALLBACK_TEXTURE 0x01
+#define RADEON_FALLBACK_DRAW_BUFFER 0x02
+#define RADEON_FALLBACK_STENCIL 0x04
+#define RADEON_FALLBACK_RENDER_MODE 0x08
+#define RADEON_FALLBACK_BLEND_EQ 0x10
+#define RADEON_FALLBACK_BLEND_FUNC 0x20
+#define RADEON_FALLBACK_DISABLE 0x40
+#define RADEON_FALLBACK_BORDER_MODE 0x80
+
+#if R200_MERGED
+extern void radeonFallback(GLcontext * ctx, GLuint bit, GLboolean mode);
+
+#define FALLBACK( radeon, bit, mode ) do { \
+ if ( 0 ) fprintf( stderr, "FALLBACK in %s: #%d=%d\n", \
+ __FUNCTION__, bit, mode ); \
+ radeonFallback( (radeon)->glCtx, bit, mode ); \
+} while (0)
+#else
+#define FALLBACK( radeon, bit, mode ) fprintf(stderr, "%s:%s\n", __LINE__, __FILE__);
+#endif
+
+/* TCL fallbacks */
+extern void radeonTclFallback(GLcontext * ctx, GLuint bit, GLboolean mode);
+
+#define RADEON_TCL_FALLBACK_RASTER 0x0001 /* rasterization */
+#define RADEON_TCL_FALLBACK_UNFILLED 0x0002 /* unfilled tris */
+#define RADEON_TCL_FALLBACK_LIGHT_TWOSIDE 0x0004 /* twoside tris */
+#define RADEON_TCL_FALLBACK_MATERIAL 0x0008 /* material in vb */
+#define RADEON_TCL_FALLBACK_TEXGEN_0 0x0010 /* texgen, unit 0 */
+#define RADEON_TCL_FALLBACK_TEXGEN_1 0x0020 /* texgen, unit 1 */
+#define RADEON_TCL_FALLBACK_TEXGEN_2 0x0040 /* texgen, unit 2 */
+#define RADEON_TCL_FALLBACK_TEXGEN_3 0x0080 /* texgen, unit 3 */
+#define RADEON_TCL_FALLBACK_TEXGEN_4 0x0100 /* texgen, unit 4 */
+#define RADEON_TCL_FALLBACK_TEXGEN_5 0x0200 /* texgen, unit 5 */
+#define RADEON_TCL_FALLBACK_TCL_DISABLE 0x0400 /* user disable */
+#define RADEON_TCL_FALLBACK_BITMAP 0x0800 /* draw bitmap with points */
+#define RADEON_TCL_FALLBACK_VERTEX_PROGRAM 0x1000 /* vertex program active */
+
+#if R200_MERGED
+#define TCL_FALLBACK( ctx, bit, mode ) radeonTclFallback( ctx, bit, mode )
+#else
+#define TCL_FALLBACK( ctx, bit, mode ) ;
+#endif
+
+
+struct radeon_dri_mirror {
+ __DRIcontextPrivate *context; /* DRI context */
+ __DRIscreenPrivate *screen; /* DRI screen */
+ __DRIdrawablePrivate *drawable; /* DRI drawable bound to this ctx */
+
+ drm_context_t hwContext;
+ drm_hw_lock_t *hwLock;
+ int fd;
+ int drmMinor;
+};
+
+/**
+ * Derived state for internal purposes.
+ */
+struct radeon_scissor_state {
+ drm_clip_rect_t rect;
+ GLboolean enabled;
+
+ GLuint numClipRects; /* Cliprects active */
+ GLuint numAllocedClipRects; /* Cliprects available */
+ drm_clip_rect_t *pClipRects;
+};
+
+struct radeon_colorbuffer_state {
+ GLuint clear;
+ GLint drawOffset, drawPitch;
+};
+
+struct radeon_pixel_state {
+ GLint readOffset, readPitch;
+};
+
+struct radeon_state {
+ struct radeon_colorbuffer_state color;
+ struct radeon_pixel_state pixel;
+ struct radeon_scissor_state scissor;
+};
+
+/**
+ * Common per-context variables shared by R200 and R300.
+ * R200- and R300-specific code "derive" their own context from this
+ * structure.
+ */
+struct radeon_context {
+ GLcontext *glCtx; /* Mesa context */
+ radeonScreenPtr radeonScreen; /* Screen private DRI data */
+
+ /* Fallback state */
+ GLuint Fallback;
+ GLuint TclFallback;
+
+ /* Page flipping */
+ GLuint doPageFlip;
+
+ /* Drawable, cliprect and scissor information */
+ GLuint numClipRects; /* Cliprects for the draw buffer */
+ drm_clip_rect_t *pClipRects;
+ unsigned int lastStamp;
+ GLboolean lost_context;
+ drm_radeon_sarea_t *sarea; /* Private SAREA data */
+
+ /* Mirrors of some DRI state */
+ struct radeon_dri_mirror dri;
+
+ /* Busy waiting */
+ GLuint do_usleeps;
+ GLuint do_irqs;
+ GLuint irqsEmitted;
+ drm_radeon_irq_wait_t iw;
+
+ /* VBI / buffer swap */
+ GLuint vbl_seq;
+ GLuint vblank_flags;
+
+ int64_t swap_ust;
+ int64_t swap_missed_ust;
+
+ GLuint swap_count;
+ GLuint swap_missed_count;
+
+
+ /* Derived state */
+ struct radeon_state state;
+
+ /* Configuration cache
+ */
+ driOptionCache optionCache;
+};
+
+#define RADEON_CONTEXT(glctx) ((radeonContextPtr)(ctx->DriverCtx))
+
+extern void radeonSwapBuffers(__DRIdrawablePrivate * dPriv);
+extern GLboolean radeonInitContext(radeonContextPtr radeon,
+ struct dd_function_table* functions,
+ const __GLcontextModes * glVisual,
+ __DRIcontextPrivate * driContextPriv,
+ void *sharedContextPrivate);
+extern void radeonCleanupContext(radeonContextPtr radeon);
+extern GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
+ __DRIdrawablePrivate * driDrawPriv,
+ __DRIdrawablePrivate * driReadPriv);
+extern GLboolean radeonUnbindContext(__DRIcontextPrivate * driContextPriv);
+
+/* ================================================================
+ * Debugging:
+ */
+#define DO_DEBUG 1
+
+#if DO_DEBUG
+extern int RADEON_DEBUG;
+#else
+#define RADEON_DEBUG 0
+#endif
+
+#define DEBUG_TEXTURE 0x0001
+#define DEBUG_STATE 0x0002
+#define DEBUG_IOCTL 0x0004
+#define DEBUG_PRIMS 0x0008
+#define DEBUG_VERTS 0x0010
+#define DEBUG_FALLBACKS 0x0020
+#define DEBUG_VFMT 0x0040
+#define DEBUG_CODEGEN 0x0080
+#define DEBUG_VERBOSE 0x0100
+#define DEBUG_DRI 0x0200
+#define DEBUG_DMA 0x0400
+#define DEBUG_SANITY 0x0800
+#define DEBUG_SYNC 0x1000
+#define DEBUG_PIXEL 0x2000
+#define DEBUG_MEMORY 0x4000
+
+#endif /* __RADEON_CONTEXT_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_ioctl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_ioctl.c
new file mode 100644
index 000000000..af489e2a8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_ioctl.c
@@ -0,0 +1,372 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include <sched.h>
+#include <errno.h>
+
+#include "glheader.h"
+#include "imports.h"
+#include "macros.h"
+#include "context.h"
+#include "swrast/swrast.h"
+#include "r200_context.h"
+#include "r300_context.h"
+#include "r200_state.h"
+#include "radeon_ioctl.h"
+#include "r200_ioctl.h"
+#include "r300_ioctl.h"
+#include "r200_tcl.h"
+#include "r200_sanity.h"
+#include "r300_state.h"
+#include "radeon_reg.h"
+
+#include "vblank.h"
+
+static void radeonWaitForIdle(radeonContextPtr radeon);
+
+/* ================================================================
+ * SwapBuffers with client-side throttling
+ */
+
+static uint32_t radeonGetLastFrame(radeonContextPtr radeon)
+{
+ drm_radeon_getparam_t gp;
+ int ret;
+ uint32_t frame;
+
+ gp.param = RADEON_PARAM_LAST_FRAME;
+ gp.value = (int *)&frame;
+ ret = drmCommandWriteRead(radeon->dri.fd, DRM_RADEON_GETPARAM,
+ &gp, sizeof(gp));
+ if (ret) {
+ fprintf(stderr, "%s: drmRadeonGetParam: %d\n", __FUNCTION__,
+ ret);
+ exit(1);
+ }
+
+ return frame;
+}
+
+static void radeonEmitIrqLocked(radeonContextPtr radeon)
+{
+ drm_radeon_irq_emit_t ie;
+ int ret;
+
+ ie.irq_seq = &radeon->iw.irq_seq;
+ ret = drmCommandWriteRead(radeon->dri.fd, DRM_RADEON_IRQ_EMIT,
+ &ie, sizeof(ie));
+ if (ret) {
+ fprintf(stderr, "%s: drmRadeonIrqEmit: %d\n", __FUNCTION__,
+ ret);
+ exit(1);
+ }
+}
+
+static void radeonWaitIrq(radeonContextPtr radeon)
+{
+ int ret;
+
+ do {
+ ret = drmCommandWrite(radeon->dri.fd, DRM_RADEON_IRQ_WAIT,
+ &radeon->iw, sizeof(radeon->iw));
+ } while (ret && (errno == EINTR || errno == EAGAIN));
+
+ if (ret) {
+ fprintf(stderr, "%s: drmRadeonIrqWait: %d\n", __FUNCTION__,
+ ret);
+ exit(1);
+ }
+}
+
+static void radeonWaitForFrameCompletion(radeonContextPtr radeon)
+{
+ drm_radeon_sarea_t *sarea = radeon->sarea;
+
+ if (radeon->do_irqs) {
+ if (radeonGetLastFrame(radeon) < sarea->last_frame) {
+ if (!radeon->irqsEmitted) {
+ while (radeonGetLastFrame(radeon) <
+ sarea->last_frame) ;
+ } else {
+ UNLOCK_HARDWARE(radeon);
+ radeonWaitIrq(radeon);
+ LOCK_HARDWARE(radeon);
+ }
+ radeon->irqsEmitted = 10;
+ }
+
+ if (radeon->irqsEmitted) {
+ radeonEmitIrqLocked(radeon);
+ radeon->irqsEmitted--;
+ }
+ } else {
+ while (radeonGetLastFrame(radeon) < sarea->last_frame) {
+ UNLOCK_HARDWARE(radeon);
+ if (radeon->do_usleeps)
+ DO_USLEEP(1);
+ LOCK_HARDWARE(radeon);
+ }
+ }
+}
+
+/* Copy the back color buffer to the front color buffer.
+ */
+void radeonCopyBuffer(const __DRIdrawablePrivate * dPriv)
+{
+ radeonContextPtr radeon;
+ GLint nbox, i, ret;
+ GLboolean missed_target;
+ int64_t ust;
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ if (RADEON_DEBUG & DEBUG_IOCTL) {
+ fprintf(stderr, "\n%s( %p )\n\n", __FUNCTION__,
+ (void *)radeon->glCtx);
+ }
+
+ if (IS_FAMILY_R200(radeon))
+ R200_FIREVERTICES((r200ContextPtr)radeon);
+ else
+ r300Flush(radeon->glCtx);
+
+ LOCK_HARDWARE(radeon);
+
+ /* Throttle the frame rate -- only allow one pending swap buffers
+ * request at a time.
+ */
+ radeonWaitForFrameCompletion(radeon);
+ UNLOCK_HARDWARE(radeon);
+ driWaitForVBlank(dPriv, &radeon->vbl_seq, radeon->vblank_flags,
+ &missed_target);
+ LOCK_HARDWARE(radeon);
+
+ nbox = dPriv->numClipRects; /* must be in locked region */
+
+ for (i = 0; i < nbox;) {
+ GLint nr = MIN2(i + RADEON_NR_SAREA_CLIPRECTS, nbox);
+ drm_clip_rect_t *box = dPriv->pClipRects;
+ drm_clip_rect_t *b = radeon->sarea->boxes;
+ GLint n = 0;
+
+ for (; i < nr; i++) {
+ *b++ = box[i];
+ n++;
+ }
+ radeon->sarea->nbox = n;
+
+ ret = drmCommandNone(radeon->dri.fd, DRM_RADEON_SWAP);
+
+ if (ret) {
+ fprintf(stderr, "DRM_RADEON_SWAP: return = %d\n",
+ ret);
+ UNLOCK_HARDWARE(radeon);
+ exit(1);
+ }
+ }
+
+ UNLOCK_HARDWARE(radeon);
+
+ if (IS_FAMILY_R200(radeon))
+ ((r200ContextPtr)radeon)->hw.all_dirty = GL_TRUE;
+ else
+ ((r300ContextPtr)radeon)->hw.all_dirty = GL_TRUE;
+
+ radeon->swap_count++;
+ (*dri_interface->getUST) (&ust);
+ if (missed_target) {
+ radeon->swap_missed_count++;
+ radeon->swap_missed_ust = ust - radeon->swap_ust;
+ }
+
+ radeon->swap_ust = ust;
+
+ sched_yield();
+}
+
+void radeonPageFlip(const __DRIdrawablePrivate * dPriv)
+{
+ radeonContextPtr radeon;
+ GLint ret;
+ GLboolean missed_target;
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ if (RADEON_DEBUG & DEBUG_IOCTL) {
+ fprintf(stderr, "%s: pfCurrentPage: %d\n", __FUNCTION__,
+ radeon->sarea->pfCurrentPage);
+ }
+
+ if (IS_FAMILY_R200(radeon))
+ R200_FIREVERTICES((r200ContextPtr)radeon);
+ else
+ r300Flush(radeon->glCtx);
+ LOCK_HARDWARE(radeon);
+
+ if (!dPriv->numClipRects) {
+ UNLOCK_HARDWARE(radeon);
+ usleep(10000); /* throttle invisible client 10ms */
+ return;
+ }
+
+ /* Need to do this for the perf box placement:
+ */
+ {
+ drm_clip_rect_t *box = dPriv->pClipRects;
+ drm_clip_rect_t *b = radeon->sarea->boxes;
+ b[0] = box[0];
+ radeon->sarea->nbox = 1;
+ }
+
+ /* Throttle the frame rate -- only allow a few pending swap buffers
+ * request at a time.
+ */
+ radeonWaitForFrameCompletion(radeon);
+ UNLOCK_HARDWARE(radeon);
+ driWaitForVBlank(dPriv, &radeon->vbl_seq, radeon->vblank_flags,
+ &missed_target);
+ if (missed_target) {
+ radeon->swap_missed_count++;
+ (void)(*dri_interface->getUST) (&radeon->swap_missed_ust);
+ }
+ LOCK_HARDWARE(radeon);
+
+ ret = drmCommandNone(radeon->dri.fd, DRM_RADEON_FLIP);
+
+ UNLOCK_HARDWARE(radeon);
+
+ if (ret) {
+ fprintf(stderr, "DRM_RADEON_FLIP: return = %d\n", ret);
+ exit(1);
+ }
+
+ radeon->swap_count++;
+ (void)(*dri_interface->getUST) (&radeon->swap_ust);
+
+ if (radeon->sarea->pfCurrentPage == 1) {
+ radeon->state.color.drawOffset = radeon->radeonScreen->frontOffset;
+ radeon->state.color.drawPitch = radeon->radeonScreen->frontPitch;
+ } else {
+ radeon->state.color.drawOffset = radeon->radeonScreen->backOffset;
+ radeon->state.color.drawPitch = radeon->radeonScreen->backPitch;
+ }
+
+ if (IS_FAMILY_R200(radeon)) {
+ r200ContextPtr r200 = (r200ContextPtr)radeon;
+
+ R200_STATECHANGE(r200, ctx);
+ r200->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = radeon->state.color.drawOffset
+ + radeon->radeonScreen->fbLocation;
+ r200->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = radeon->state.color.drawPitch;
+ }
+ if (IS_FAMILY_R300(radeon)) {
+ r300ContextPtr r300 = (r300ContextPtr)radeon;
+ R300_STATECHANGE(r300, cb);
+ r300->hw.cb.cmd[R300_CB_OFFSET] = r300->radeon.state.color.drawOffset +
+ r300->radeon.radeonScreen->fbLocation;
+ r300->hw.cb.cmd[R300_CB_PITCH] = r300->radeon.state.color.drawPitch;
+
+ if (r300->radeon.radeonScreen->cpp == 4)
+ r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_ARGB8888;
+ else
+ r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_FORMAT_RGB565;
+
+ if (r300->radeon.sarea->tiling_enabled)
+ r300->hw.cb.cmd[R300_CB_PITCH] |= R300_COLOR_TILE_ENABLE;
+ }
+}
+
+void radeonWaitForIdleLocked(radeonContextPtr radeon)
+{
+ int ret;
+ int i = 0;
+
+ do {
+ ret = drmCommandNone(radeon->dri.fd, DRM_RADEON_CP_IDLE);
+ if (ret)
+ DO_USLEEP(1);
+ } while (ret && ++i < 100);
+
+ if (ret < 0) {
+ UNLOCK_HARDWARE(radeon);
+ fprintf(stderr, "Error: R200 timed out... exiting\n");
+ exit(-1);
+ }
+}
+
+static void radeonWaitForIdle(radeonContextPtr radeon)
+{
+ LOCK_HARDWARE(radeon);
+ radeonWaitForIdleLocked(radeon);
+ UNLOCK_HARDWARE(radeon);
+}
+
+void radeonFlush(GLcontext * ctx)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+
+ if (IS_FAMILY_R300(radeon))
+ r300Flush(ctx);
+#if R200_MERGED
+ else
+ r200Flush(ctx);
+#endif
+}
+
+
+/* Make sure all commands have been sent to the hardware and have
+ * completed processing.
+ */
+void radeonFinish(GLcontext * ctx)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+
+ radeonFlush(ctx);
+
+ if (radeon->do_irqs) {
+ LOCK_HARDWARE(radeon);
+ radeonEmitIrqLocked(radeon);
+ UNLOCK_HARDWARE(radeon);
+ radeonWaitIrq(radeon);
+ } else
+ radeonWaitForIdle(radeon);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_ioctl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_ioctl.h
new file mode 100644
index 000000000..7c19325dd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_ioctl.h
@@ -0,0 +1,53 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __RADEON_IOCTL_H__
+#define __RADEON_IOCTL_H__
+
+#include "simple_list.h"
+#include "radeon_dri.h"
+#include "radeon_lock.h"
+
+#include "xf86drm.h"
+#include "drm.h"
+#include "r200_context.h"
+#include "radeon_drm.h"
+
+extern void radeonCopyBuffer(const __DRIdrawablePrivate * drawable);
+extern void radeonPageFlip(const __DRIdrawablePrivate * drawable);
+extern void radeonFlush(GLcontext * ctx);
+extern void radeonFinish(GLcontext * ctx);
+extern void radeonWaitForIdleLocked(radeonContextPtr radeon);
+
+#endif /* __RADEON_IOCTL_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_lock.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_lock.c
new file mode 100644
index 000000000..3c7fc72a4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_lock.c
@@ -0,0 +1,166 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+#include <string.h>
+
+#include "r200_context.h"
+#include "radeon_lock.h"
+#include "r200_tex.h"
+#include "r200_state.h"
+#include "radeon_ioctl.h"
+#include "radeon_state.h"
+
+#include "framebuffer.h"
+
+#if DEBUG_LOCKING
+char *prevLockFile = NULL;
+int prevLockLine = 0;
+#endif
+
+/* Turn on/off page flipping according to the flags in the sarea:
+ */
+static void radeonUpdatePageFlipping(radeonContextPtr radeon)
+{
+ int use_back;
+
+ radeon->doPageFlip = radeon->sarea->pfState;
+
+ use_back = (radeon->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT);
+ use_back ^= (radeon->sarea->pfCurrentPage == 1);
+
+ if (use_back) {
+ radeon->state.color.drawOffset = radeon->radeonScreen->backOffset;
+ radeon->state.color.drawPitch = radeon->radeonScreen->backPitch;
+ } else {
+ radeon->state.color.drawOffset = radeon->radeonScreen->frontOffset;
+ radeon->state.color.drawPitch = radeon->radeonScreen->frontPitch;
+ }
+}
+
+/**
+ * Called by radeonGetLock() after the lock has been obtained.
+ */
+#if R200_MERGED
+static void r200RegainedLock(r200ContextPtr r200)
+{
+ __DRIdrawablePrivate *dPriv = r200->radeon.dri.drawable;
+ int i;
+
+ if (r200->radeon.lastStamp != dPriv->lastStamp) {
+ radeonUpdatePageFlipping(&r200->radeon);
+ R200_STATECHANGE(r200, ctx);
+ r200->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] =
+ r200->radeon.state.color.drawOffset
+ + r200->radeon.radeonScreen->fbLocation;
+ r200->hw.ctx.cmd[CTX_RB3D_COLORPITCH] =
+ r200->radeon.state.color.drawPitch;
+
+ if (r200->radeon.glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT)
+ radeonSetCliprects(&r200->radeon, GL_BACK_LEFT);
+ else
+ radeonSetCliprects(&r200->radeon, GL_FRONT_LEFT);
+ r200UpdateViewportOffset(r200->radeon.glCtx);
+ r200->radeon.lastStamp = dPriv->lastStamp;
+ }
+
+ for (i = 0; i < r200->nr_heaps; i++) {
+ DRI_AGE_TEXTURES(r200->texture_heaps[i]);
+ }
+}
+#endif
+
+static void r300RegainedLock(radeonContextPtr radeon)
+{
+ __DRIdrawablePrivate *dPriv = radeon->dri.drawable;
+
+ if (radeon->lastStamp != dPriv->lastStamp) {
+ _mesa_resize_framebuffer(radeon->glCtx,
+ (GLframebuffer*)dPriv->driverPrivate,
+ dPriv->w, dPriv->h);
+
+ radeonUpdatePageFlipping(radeon);
+
+ if (radeon->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT)
+ radeonSetCliprects(radeon, GL_BACK_LEFT);
+ else
+ radeonSetCliprects(radeon, GL_FRONT_LEFT);
+
+ radeonUpdateScissor(radeon->glCtx);
+ radeon->lastStamp = dPriv->lastStamp;
+ }
+
+#if R200_MERGED
+ for (i = 0; i < r200->nr_heaps; i++) {
+ DRI_AGE_TEXTURES(r200->texture_heaps[i]);
+ }
+#endif
+}
+
+/* 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.
+ */
+void radeonGetLock(radeonContextPtr radeon, GLuint flags)
+{
+ __DRIdrawablePrivate *dPriv = radeon->dri.drawable;
+ __DRIscreenPrivate *sPriv = radeon->dri.screen;
+ drm_radeon_sarea_t *sarea = radeon->sarea;
+
+ drmGetLock(radeon->dri.fd, radeon->dri.hwContext, flags);
+
+ /* 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.
+ */
+ DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
+
+ if (sarea->ctx_owner != radeon->dri.hwContext)
+ sarea->ctx_owner = radeon->dri.hwContext;
+
+ if (IS_FAMILY_R300(radeon))
+ r300RegainedLock(radeon);
+#if R200_MERGED
+ else
+ r200RegainedLock((r200ContextPtr)radeon);
+#endif
+
+ radeon->lost_context = GL_TRUE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_lock.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_lock.h
new file mode 100644
index 000000000..c9acbce0c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_lock.h
@@ -0,0 +1,122 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __RADEON_LOCK_H__
+#define __RADEON_LOCK_H__
+
+#include "r200_ioctl.h"
+
+extern void radeonGetLock(radeonContextPtr radeon, GLuint flags);
+
+/* Turn DEBUG_LOCKING on to find locking conflicts.
+ */
+#define DEBUG_LOCKING 0
+
+#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 and validate our state.
+ */
+#define LOCK_HARDWARE( radeon ) \
+ do { \
+ char __ret = 0; \
+ DEBUG_CHECK_LOCK(); \
+ DRM_CAS( (radeon)->dri.hwLock, (radeon)->dri.hwContext, \
+ (DRM_LOCK_HELD | (radeon)->dri.hwContext), __ret ); \
+ if ( __ret ) \
+ radeonGetLock( (radeon), 0 ); \
+ DEBUG_LOCK(); \
+ } while (0)
+
+#if R200_MERGED
+#define UNLOCK_HARDWARE( radeon ) \
+ do { \
+ DRM_UNLOCK( (radeon)->dri.fd, \
+ (radeon)->dri.hwLock, \
+ (radeon)->dri.hwContext ); \
+ DEBUG_RESET(); \
+ if (IS_FAMILY_R200((radeon))) { \
+ r200ContextPtr __r200 = (r200ContextPtr)(radeon); \
+ if (__r200->save_on_next_unlock) \
+ r200SaveHwState( __r200 ); \
+ __r200->save_on_next_unlock = GL_FALSE; \
+ } \
+ } while (0)
+#else
+#define UNLOCK_HARDWARE( radeon ) \
+ do { \
+ DRM_UNLOCK( (radeon)->dri.fd, \
+ (radeon)->dri.hwLock, \
+ (radeon)->dri.hwContext ); \
+ DEBUG_RESET(); \
+ } while (0)
+#endif
+#endif /* __RADEON_LOCK_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_screen.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_screen.c
new file mode 100644
index 000000000..663bc973b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_screen.c
@@ -0,0 +1,879 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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.
+
+**************************************************************************/
+
+/**
+ * \file radeon_screen.c
+ * Screen initialization functions for the R200 driver.
+ *
+ * \author Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include <dlfcn.h>
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "mtypes.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+
+#define STANDALONE_MMIO
+#include "radeon_screen.h"
+#include "r200_context.h"
+#include "r300_context.h"
+#include "radeon_ioctl.h"
+#include "r200_ioctl.h"
+#include "radeon_macros.h"
+#include "radeon_reg.h"
+#include "radeon_span.h"
+
+#include "utils.h"
+#include "vblank.h"
+#include "GL/internal/dri_interface.h"
+#include "drirenderbuffer.h"
+
+/* R200 configuration
+ */
+#include "xmlpool.h"
+
+const char __driR200ConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
+ DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_MAX_TEXTURE_UNITS(4, 2, 6)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_QUALITY
+ DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
+ DRI_CONF_DEF_MAX_ANISOTROPY(1.0, "1.0,2.0,4.0,8.0,16.0")
+ DRI_CONF_NO_NEG_LOD_BIAS(false)
+ DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
+ DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC)
+ DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_NO_RAST(false)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_SOFTWARE
+ DRI_CONF_ARB_VERTEX_PROGRAM(true)
+ DRI_CONF_NV_VERTEX_PROGRAM(false)
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+static const GLuint __driR200NConfigOptions = 13;
+
+/* TODO: integrate these into xmlpool.h! */
+#define DRI_CONF_MAX_TEXTURE_IMAGE_UNITS(def,min,max) \
+DRI_CONF_OPT_BEGIN_V(texture_image_units,int,def, # min ":" # max ) \
+ DRI_CONF_DESC(en,"Number of texture image units") \
+ DRI_CONF_DESC(de,"Anzahl der Textureinheiten") \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_MAX_TEXTURE_COORD_UNITS(def,min,max) \
+DRI_CONF_OPT_BEGIN_V(texture_coord_units,int,def, # min ":" # max ) \
+ DRI_CONF_DESC(en,"Number of texture coordinate units") \
+ DRI_CONF_DESC(de,"Anzahl der Texturkoordinateneinheiten") \
+DRI_CONF_OPT_END
+
+#define DRI_CONF_COMMAND_BUFFER_SIZE(def,min,max) \
+DRI_CONF_OPT_BEGIN_V(command_buffer_size,int,def, # min ":" # max ) \
+ DRI_CONF_DESC(en,"Size of command buffer (in KB)") \
+ DRI_CONF_DESC(de,"Grösse des Befehlspuffers (in KB)") \
+DRI_CONF_OPT_END
+
+
+const char __driR300ConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
+ DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_MAX_TEXTURE_IMAGE_UNITS(16, 2, 16)
+ DRI_CONF_MAX_TEXTURE_COORD_UNITS(8, 2, 8)
+ DRI_CONF_COMMAND_BUFFER_SIZE(8, 8, 32)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_QUALITY
+ DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
+ DRI_CONF_DEF_MAX_ANISOTROPY(1.0, "1.0,2.0,4.0,8.0,16.0")
+ DRI_CONF_NO_NEG_LOD_BIAS(false)
+ DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
+ DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC)
+ DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_NO_RAST(false)
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+static const GLuint __driR300NConfigOptions = 13;
+
+extern const struct dri_extension card_extensions[];
+
+#ifndef RADEON_DEBUG
+int RADEON_DEBUG = 0;
+#endif
+
+static const struct dri_debug_control debug_control[] = {
+ {"fall", DEBUG_FALLBACKS},
+ {"tex", DEBUG_TEXTURE},
+ {"ioctl", DEBUG_IOCTL},
+ {"prim", DEBUG_PRIMS},
+ {"vert", DEBUG_VERTS},
+ {"state", DEBUG_STATE},
+ {"code", DEBUG_CODEGEN},
+ {"vfmt", DEBUG_VFMT},
+ {"vtxf", DEBUG_VFMT},
+ {"verb", DEBUG_VERBOSE},
+ {"dri", DEBUG_DRI},
+ {"dma", DEBUG_DMA},
+ {"san", DEBUG_SANITY},
+ {"sync", DEBUG_SYNC},
+ {"pix", DEBUG_PIXEL},
+ {"mem", DEBUG_MEMORY},
+ {"allmsg", ~DEBUG_SYNC}, /* avoid the term "sync" because the parser uses strstr */
+ {NULL, 0}
+};
+
+#if 1
+/* Including xf86PciInfo.h introduces a bunch of errors...
+ */
+#define PCI_CHIP_R200_QD 0x5144 /* why do they have r200 names? */
+#define PCI_CHIP_R200_QE 0x5145 /* Those are all standard radeons */
+#define PCI_CHIP_R200_QF 0x5146
+#define PCI_CHIP_R200_QG 0x5147
+#define PCI_CHIP_R200_QY 0x5159
+#define PCI_CHIP_R200_QZ 0x515A
+#define PCI_CHIP_R200_LW 0x4C57
+#define PCI_CHIP_R200_LY 0x4C59
+#define PCI_CHIP_R200_LZ 0x4C5A
+#define PCI_CHIP_RV200_QW 0x5157 /* Radeon 7500 - not an R200 at all */
+#define PCI_CHIP_RV200_QX 0x5158
+#define PCI_CHIP_RS100_4136 0x4136 /* IGP RS100, RS200, RS250 are not R200 */
+#define PCI_CHIP_RS200_4137 0x4137
+#define PCI_CHIP_RS250_4237 0x4237
+#define PCI_CHIP_RS100_4336 0x4336
+#define PCI_CHIP_RS200_4337 0x4337
+#define PCI_CHIP_RS250_4437 0x4437
+#define PCI_CHIP_RS300_5834 0x5834 /* All RS300's are R200 */
+#define PCI_CHIP_RS300_5835 0x5835
+#define PCI_CHIP_RS300_5836 0x5836
+#define PCI_CHIP_RS300_5837 0x5837
+#define PCI_CHIP_R200_BB 0x4242 /* r200 (non-derived) start */
+#define PCI_CHIP_R200_BC 0x4243
+#define PCI_CHIP_R200_QH 0x5148
+#define PCI_CHIP_R200_QI 0x5149
+#define PCI_CHIP_R200_QJ 0x514A
+#define PCI_CHIP_R200_QK 0x514B
+#define PCI_CHIP_R200_QL 0x514C
+#define PCI_CHIP_R200_QM 0x514D
+#define PCI_CHIP_R200_QN 0x514E
+#define PCI_CHIP_R200_QO 0x514F /* r200 (non-derived) end */
+/* are the R200 Qh (0x5168) and following needed too? They are not in xf86PciInfo.h
+ but in the pci database. Maybe just secondary ports or something ? */
+
+#define PCI_CHIP_R300_AD 0x4144
+#define PCI_CHIP_R300_AE 0x4145
+#define PCI_CHIP_R300_AF 0x4146
+#define PCI_CHIP_R300_AG 0x4147
+#define PCI_CHIP_RV350_AP 0x4150
+#define PCI_CHIP_RV350_AR 0x4152
+#define PCI_CHIP_RV350_AS 0x4153
+#define PCI_CHIP_RV350_NJ 0x4E4A
+#define PCI_CHIP_RV350_NP 0x4E50
+#define PCI_CHIP_RV350_NQ 0x4E51 /* Saphire 9600 256MB card */
+#define PCI_CHIP_RV350_NT 0x4E54
+#define PCI_CHIP_RV350_NQ_2 0x4E71 /* Saphire 9600 256MB card - Second Head */
+#define PCI_CHIP_R300_ND 0x4E44
+#define PCI_CHIP_R300_NE 0x4E45
+#define PCI_CHIP_R300_NF 0x4E46
+#define PCI_CHIP_R300_NG 0x4E47
+#define PCI_CHIP_R350_NH 0x4E48
+#define PCI_CHIP_R420_JI 0x4A49
+#define PCI_CHIP_R420_JK 0x4a4b
+#endif
+
+
+static radeonScreenPtr __radeonScreen;
+
+static int getSwapInfo(__DRIdrawablePrivate * dPriv, __DRIswapInfo * sInfo);
+
+static __GLcontextModes *radeonFillInModes(unsigned pixel_bits,
+ unsigned depth_bits,
+ unsigned stencil_bits,
+ GLboolean have_back_buffer)
+{
+ __GLcontextModes *modes;
+ __GLcontextModes *m;
+ unsigned num_modes;
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ GLenum fb_format;
+ GLenum fb_type;
+
+ /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
+ * enough to add support. Basically, if a context is created with an
+ * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
+ * will never be used.
+ */
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
+ };
+
+ uint8_t depth_bits_array[2];
+ uint8_t stencil_bits_array[2];
+
+ depth_bits_array[0] = depth_bits;
+ depth_bits_array[1] = depth_bits;
+
+ /* Just like with the accumulation buffer, always provide some modes
+ * with a stencil buffer. It will be a sw fallback, but some apps won't
+ * care about that.
+ */
+ stencil_bits_array[0] = 0;
+ stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
+
+ depth_buffer_factor = ((depth_bits != 0)
+ || (stencil_bits != 0)) ? 2 : 1;
+ back_buffer_factor = (have_back_buffer) ? 2 : 1;
+
+ num_modes = depth_buffer_factor * back_buffer_factor * 4;
+
+ if (pixel_bits == 16) {
+ fb_format = GL_RGB;
+ fb_type = GL_UNSIGNED_SHORT_5_6_5;
+ } else {
+ fb_format = GL_BGRA;
+ fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ }
+
+ modes = (*dri_interface->createContextModes) (num_modes, sizeof(__GLcontextModes));
+ m = modes;
+ if (!driFillInModes(&m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array,
+ depth_buffer_factor, back_buffer_modes,
+ back_buffer_factor, GLX_TRUE_COLOR)) {
+ fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
+ __LINE__);
+ return NULL;
+ }
+
+ if (!driFillInModes(&m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array,
+ depth_buffer_factor, back_buffer_modes,
+ back_buffer_factor, GLX_DIRECT_COLOR)) {
+ fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
+ __LINE__);
+ return NULL;
+ }
+
+ /* Mark the visual as slow if there are "fake" stencil bits.
+ */
+ for (m = modes; m != NULL; m = m->next) {
+ if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
+ m->visualRating = GLX_SLOW_CONFIG;
+ }
+ }
+
+ return modes;
+}
+
+
+/* Create the device specific screen private data struct.
+ */
+static radeonScreenPtr radeonCreateScreen(__DRIscreenPrivate * sPriv)
+{
+ radeonScreenPtr screen;
+ RADEONDRIPtr dri_priv = (RADEONDRIPtr) sPriv->pDevPriv;
+ unsigned char *RADEONMMIO;
+ PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
+ (PFNGLXSCRENABLEEXTENSIONPROC)
+ (*dri_interface->getProcAddress("glxEnableExtension"));
+ void *const psc = sPriv->psc->screenConfigs;
+
+ if (sPriv->devPrivSize != sizeof(RADEONDRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(RADEONDRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
+
+ /* Allocate the private area */
+ screen = (radeonScreenPtr) CALLOC(sizeof(*screen));
+ if (!screen) {
+ __driUtilMessage
+ ("%s: Could not allocate memory for screen structure",
+ __FUNCTION__);
+ return NULL;
+ }
+
+#if DO_DEBUG
+ RADEON_DEBUG = driParseDebugString(getenv("RADEON_DEBUG"), debug_control);
+#endif
+
+ /* Get family and potential quirks from the PCI device ID.
+ */
+ switch (dri_priv->deviceID) {
+ case PCI_CHIP_R200_QD:
+ case PCI_CHIP_R200_QE:
+ case PCI_CHIP_R200_QF:
+ case PCI_CHIP_R200_QG:
+ case PCI_CHIP_R200_QY:
+ case PCI_CHIP_R200_QZ:
+ case PCI_CHIP_RV200_QW:
+ case PCI_CHIP_RV200_QX:
+ case PCI_CHIP_R200_LW:
+ case PCI_CHIP_R200_LY:
+ case PCI_CHIP_R200_LZ:
+ case PCI_CHIP_RS100_4136:
+ case PCI_CHIP_RS200_4137:
+ case PCI_CHIP_RS250_4237:
+ case PCI_CHIP_RS100_4336:
+ case PCI_CHIP_RS200_4337:
+ case PCI_CHIP_RS250_4437:
+ __driUtilMessage("radeonCreateScreen(): Device isn't an r200!\n");
+ FREE(screen);
+ return NULL;
+
+ case PCI_CHIP_RS300_5834:
+ case PCI_CHIP_RS300_5835:
+ case PCI_CHIP_RS300_5836:
+ case PCI_CHIP_RS300_5837:
+ screen->chipset = RADEON_CHIP_UNREAL_R200;
+ break;
+
+ case PCI_CHIP_R200_BB:
+ case PCI_CHIP_R200_BC:
+ case PCI_CHIP_R200_QH:
+ case PCI_CHIP_R200_QI:
+ case PCI_CHIP_R200_QJ:
+ case PCI_CHIP_R200_QK:
+ case PCI_CHIP_R200_QL:
+ case PCI_CHIP_R200_QM:
+ case PCI_CHIP_R200_QN:
+ case PCI_CHIP_R200_QO:
+ screen->chipset = RADEON_CHIP_REAL_R200 | RADEON_CHIPSET_TCL;
+ break;
+
+ /* TODO: Check all those chips for the exact flags required.
+ */
+ case PCI_CHIP_R300_AD:
+ case PCI_CHIP_R300_AE:
+ case PCI_CHIP_R300_AF:
+ case PCI_CHIP_R300_AG:
+ case PCI_CHIP_RV350_AP:
+ case PCI_CHIP_RV350_AR:
+ case PCI_CHIP_RV350_AS:
+ case PCI_CHIP_RV350_NJ:
+ case PCI_CHIP_RV350_NP:
+ case PCI_CHIP_RV350_NT:
+ case PCI_CHIP_RV350_NQ:
+/* case PCI_CHIP_RV350_NQ: -- Should we have the second head in here too? */
+ screen->chipset = RADEON_CHIP_RV350;
+ break;
+
+ case PCI_CHIP_R300_ND: /* confirmed -- nh */
+ case PCI_CHIP_R300_NE:
+ case PCI_CHIP_R300_NF:
+ case PCI_CHIP_R300_NG:
+ case PCI_CHIP_R350_NH:
+ screen->chipset = RADEON_CHIP_R300;
+ break;
+
+ case PCI_CHIP_R420_JI:
+ case PCI_CHIP_R420_JK:
+ screen->chipset = RADEON_CHIP_R420;
+ break;
+
+ default:
+ fprintf(stderr,
+ "Unknown device ID %04X, please report. Assuming plain R300.\n",
+ dri_priv->deviceID);
+ screen->chipset = RADEON_CHIP_R300;
+ }
+
+ /* Parse configuration */
+ if (GET_CHIP(screen) >= RADEON_CHIP_R300) {
+ driParseOptionInfo(&screen->optionCache,
+ __driR300ConfigOptions, __driR300NConfigOptions);
+ } else {
+ driParseOptionInfo(&screen->optionCache,
+ __driR200ConfigOptions, __driR200NConfigOptions);
+ }
+
+ /* This is first since which regions we map depends on whether or
+ * not we are using a PCI card.
+ */
+ screen->IsPCI = dri_priv->IsPCI;
+
+ {
+ int ret;
+ drm_radeon_getparam_t gp;
+
+ gp.param = RADEON_PARAM_GART_BUFFER_OFFSET;
+ gp.value = &screen->gart_buffer_offset;
+
+ ret = drmCommandWriteRead(sPriv->fd, DRM_RADEON_GETPARAM,
+ &gp, sizeof(gp));
+ if (ret) {
+ FREE(screen);
+ fprintf(stderr,
+ "drmRadeonGetParam (RADEON_PARAM_GART_BUFFER_OFFSET): %d\n",
+ ret);
+ return NULL;
+ }
+
+ if (sPriv->drmMinor >= 6) {
+ gp.param = RADEON_PARAM_GART_BASE;
+ gp.value = &screen->gart_base;
+
+ ret =
+ drmCommandWriteRead(sPriv->fd, DRM_RADEON_GETPARAM,
+ &gp, sizeof(gp));
+ if (ret) {
+ FREE(screen);
+ fprintf(stderr,
+ "drmR200GetParam (RADEON_PARAM_GART_BASE): %d\n",
+ ret);
+ return NULL;
+ }
+
+ gp.param = RADEON_PARAM_IRQ_NR;
+ gp.value = &screen->irq;
+
+ ret =
+ drmCommandWriteRead(sPriv->fd, DRM_RADEON_GETPARAM,
+ &gp, sizeof(gp));
+ if (ret) {
+ FREE(screen);
+ fprintf(stderr,
+ "drmRadeonGetParam (RADEON_PARAM_IRQ_NR): %d\n",
+ ret);
+ return NULL;
+ }
+
+ /* Check if kernel module is new enough to support cube maps */
+ screen->drmSupportsCubeMaps = (sPriv->drmMinor >= 7);
+ /* Check if kernel module is new enough to support blend color and
+ separate blend functions/equations */
+ screen->drmSupportsBlendColor = (sPriv->drmMinor >= 11);
+
+ }
+ }
+
+ screen->mmio.handle = dri_priv->registerHandle;
+ screen->mmio.size = dri_priv->registerSize;
+ if (drmMap(sPriv->fd,
+ screen->mmio.handle, screen->mmio.size, &screen->mmio.map)) {
+ FREE(screen);
+ __driUtilMessage("%s: drmMap failed\n", __FUNCTION__);
+ return NULL;
+ }
+
+ RADEONMMIO = screen->mmio.map;
+
+ screen->status.handle = dri_priv->statusHandle;
+ screen->status.size = dri_priv->statusSize;
+ if (drmMap(sPriv->fd,
+ screen->status.handle,
+ screen->status.size, &screen->status.map)) {
+ drmUnmap(screen->mmio.map, screen->mmio.size);
+ FREE(screen);
+ __driUtilMessage("%s: drmMap (2) failed\n", __FUNCTION__);
+ return NULL;
+ }
+ screen->scratch = (__volatile__ uint32_t *)
+ ((GLubyte *) screen->status.map + RADEON_SCRATCH_REG_OFFSET);
+
+ screen->buffers = drmMapBufs(sPriv->fd);
+ if (!screen->buffers) {
+ drmUnmap(screen->status.map, screen->status.size);
+ drmUnmap(screen->mmio.map, screen->mmio.size);
+ FREE(screen);
+ __driUtilMessage("%s: drmMapBufs failed\n", __FUNCTION__);
+ return NULL;
+ }
+
+ if (dri_priv->gartTexHandle && dri_priv->gartTexMapSize) {
+
+ screen->gartTextures.handle = dri_priv->gartTexHandle;
+ screen->gartTextures.size = dri_priv->gartTexMapSize;
+ if (drmMap(sPriv->fd,
+ screen->gartTextures.handle,
+ screen->gartTextures.size,
+ (drmAddressPtr) & screen->gartTextures.map)) {
+ drmUnmapBufs(screen->buffers);
+ drmUnmap(screen->status.map, screen->status.size);
+ drmUnmap(screen->mmio.map, screen->mmio.size);
+ FREE(screen);
+ __driUtilMessage
+ ("%s: drmMAP failed for GART texture area\n",
+ __FUNCTION__);
+ return NULL;
+ }
+
+ screen->gart_texture_offset =
+ dri_priv->gartTexOffset +
+ (screen->IsPCI ? INREG(RADEON_AIC_LO_ADDR)
+ : ((INREG(RADEON_MC_AGP_LOCATION) & 0x0ffffU) << 16));
+ }
+
+ screen->cpp = dri_priv->bpp / 8;
+ screen->AGPMode = dri_priv->AGPMode;
+
+ screen->fbLocation = (INREG(RADEON_MC_FB_LOCATION) & 0xffff) << 16;
+
+ if (sPriv->drmMinor >= 10) {
+ drm_radeon_setparam_t sp;
+
+ sp.param = RADEON_SETPARAM_FB_LOCATION;
+ sp.value = screen->fbLocation;
+
+ drmCommandWrite(sPriv->fd, DRM_RADEON_SETPARAM,
+ &sp, sizeof(sp));
+ }
+
+ screen->frontOffset = dri_priv->frontOffset;
+ screen->frontPitch = dri_priv->frontPitch;
+ screen->backOffset = dri_priv->backOffset;
+ screen->backPitch = dri_priv->backPitch;
+ screen->depthOffset = dri_priv->depthOffset;
+ screen->depthPitch = dri_priv->depthPitch;
+
+ if ( dri_priv->textureSize == 0 ) {
+ screen->texOffset[RADEON_LOCAL_TEX_HEAP] = screen->gart_texture_offset;
+ screen->texSize[RADEON_GART_TEX_HEAP] = dri_priv->gartTexMapSize;
+ screen->logTexGranularity[RADEON_GART_TEX_HEAP] =
+ dri_priv->log2GARTTexGran;
+ } else {
+ screen->texOffset[RADEON_LOCAL_TEX_HEAP] = dri_priv->textureOffset
+ + screen->fbLocation;
+ screen->texSize[RADEON_LOCAL_TEX_HEAP] = dri_priv->textureSize;
+ screen->logTexGranularity[RADEON_LOCAL_TEX_HEAP] =
+ dri_priv->log2TexGran;
+ }
+
+ if (!screen->gartTextures.map || dri_priv->textureSize == 0) {
+ screen->numTexHeaps = RADEON_NR_TEX_HEAPS - 1;
+ screen->texOffset[RADEON_GART_TEX_HEAP] = 0;
+ screen->texSize[RADEON_GART_TEX_HEAP] = 0;
+ screen->logTexGranularity[RADEON_GART_TEX_HEAP] = 0;
+ } else {
+ screen->numTexHeaps = RADEON_NR_TEX_HEAPS;
+ screen->texOffset[RADEON_GART_TEX_HEAP] =
+ screen->gart_texture_offset;
+ screen->texSize[RADEON_GART_TEX_HEAP] =
+ dri_priv->gartTexMapSize;
+ screen->logTexGranularity[RADEON_GART_TEX_HEAP] =
+ dri_priv->log2GARTTexGran;
+ }
+
+ screen->driScreen = sPriv;
+ screen->sarea_priv_offset = dri_priv->sarea_priv_offset;
+
+ if (glx_enable_extension != NULL) {
+ if (screen->irq != 0) {
+ (*glx_enable_extension) (psc, "GLX_SGI_swap_control");
+ (*glx_enable_extension) (psc, "GLX_SGI_video_sync");
+ (*glx_enable_extension) (psc, "GLX_MESA_swap_control");
+ }
+
+ (*glx_enable_extension) (psc, "GLX_MESA_swap_frame_usage");
+ }
+
+#if R200_MERGED
+ sPriv->psc->allocateMemory = (void *)r200AllocateMemoryMESA;
+ sPriv->psc->freeMemory = (void *)r200FreeMemoryMESA;
+ sPriv->psc->memoryOffset = (void *)r200GetMemoryOffsetMESA;
+
+ if (glx_enable_extension != NULL) {
+ (*glx_enable_extension) (psc, "GLX_MESA_allocate_memory");
+ }
+#endif
+
+ return screen;
+}
+
+/* Destroy the device specific screen private data struct.
+ */
+static void radeonDestroyScreen(__DRIscreenPrivate * sPriv)
+{
+ radeonScreenPtr screen = (radeonScreenPtr) sPriv->private;
+
+ if (!screen)
+ return;
+
+ if (screen->gartTextures.map) {
+ drmUnmap(screen->gartTextures.map, screen->gartTextures.size);
+ }
+ drmUnmapBufs(screen->buffers);
+ drmUnmap(screen->status.map, screen->status.size);
+ drmUnmap(screen->mmio.map, screen->mmio.size);
+
+ /* free all option information */
+ driDestroyOptionInfo(&screen->optionCache);
+
+ FREE(screen);
+ sPriv->private = NULL;
+}
+
+/* Initialize the driver specific screen private data.
+ */
+static GLboolean radeonInitDriver(__DRIscreenPrivate * sPriv)
+{
+ __radeonScreen = radeonCreateScreen(sPriv);
+
+ sPriv->private = (void *)__radeonScreen;
+
+ return sPriv->private ? GL_TRUE : GL_FALSE;
+}
+
+/**
+ * Create and initialize the Mesa and driver specific pixmap buffer
+ * data.
+ *
+ * \todo This function (and its interface) will need to be updated to support
+ * pbuffers.
+ */
+static GLboolean
+radeonCreateBuffer(__DRIscreenPrivate * driScrnPriv,
+ __DRIdrawablePrivate * driDrawPriv,
+ const __GLcontextModes * mesaVis, GLboolean isPixmap)
+{
+ radeonScreenPtr screen = (radeonScreenPtr)driScrnPriv->private;
+
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ } else {
+ const GLboolean swDepth = GL_FALSE;
+ const GLboolean swAlpha = GL_FALSE;
+ const GLboolean swAccum = mesaVis->accumRedBits > 0;
+ const GLboolean swStencil = mesaVis->stencilBits > 0 &&
+ mesaVis->depthBits != 24;
+#if 0
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer(mesaVis,
+ swDepth,
+ swStencil, swAccum, swAlpha);
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->frontPitch);
+ radeonSetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ radeonSetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ radeonSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ radeonSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ radeonSetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ swDepth,
+ swStencil,
+ swAccum,
+ swAlpha,
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+static void radeonDestroyBuffer(__DRIdrawablePrivate * driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->
+ driverPrivate));
+}
+
+
+/**
+ * Choose the appropriate CreateContext function based on the chipset.
+ */
+static GLboolean radeonCreateContext(const __GLcontextModes * glVisual,
+ __DRIcontextPrivate * driContextPriv,
+ void *sharedContextPriv)
+{
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ radeonScreenPtr screen = (radeonScreenPtr) (sPriv->private);
+ int chip = GET_CHIP(screen);
+
+ if (chip >= RADEON_CHIP_R300)
+ return r300CreateContext(glVisual, driContextPriv, sharedContextPriv);
+#if R200_MERGED
+ else
+ return r200CreateContext(glVisual, driContextPriv, sharedContextPriv);
+#endif
+}
+
+
+/**
+ * Choose the appropriate DestroyContext function based on the chipset.
+ */
+static void radeonDestroyContext(__DRIcontextPrivate * driContextPriv)
+{
+ radeonContextPtr radeon = (radeonContextPtr) driContextPriv->driverPrivate;
+ int chip = GET_CHIP(radeon->radeonScreen);
+
+ if (chip >= RADEON_CHIP_R300)
+ return r300DestroyContext(driContextPriv);
+#if R200_MERGED
+ else
+ return r200DestroyContext(driContextPriv);
+#endif
+}
+
+
+static const struct __DriverAPIRec radeonAPI = {
+ .InitDriver = radeonInitDriver,
+ .DestroyScreen = radeonDestroyScreen,
+ .CreateContext = radeonCreateContext,
+ .DestroyContext = radeonDestroyContext,
+ .CreateBuffer = radeonCreateBuffer,
+ .DestroyBuffer = radeonDestroyBuffer,
+ .SwapBuffers = radeonSwapBuffers,
+ .MakeCurrent = radeonMakeCurrent,
+ .UnbindContext = radeonUnbindContext,
+ .GetSwapInfo = getSwapInfo,
+ .GetMSC = driGetMSC32,
+ .WaitForMSC = driWaitForMSC32,
+ .WaitForSBC = NULL,
+ .SwapBuffersMSC = NULL
+};
+
+
+/**
+ * This is the bootstrap function for the driver. libGL supplies all of the
+ * requisite information about the system, and the driver initializes itself.
+ * This routine also fills in the linked list pointed to by \c driver_modes
+ * with the \c __GLcontextModes that the driver can support for windows or
+ * pbuffers.
+ *
+ * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
+ * failure.
+ */
+void *__driCreateNewScreen_20050727(__DRInativeDisplay * dpy, int scrn,
+ __DRIscreen * psc, const __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drmAddress pSAREA, int fd, int internal_api_version,
+ const __DRIinterfaceMethods * interface,
+ __GLcontextModes ** driver_modes)
+{
+ __DRIscreenPrivate *psp;
+ static const __DRIutilversion2 ddx_expected = { 4, 5, 0, 0 };
+ static const __DRIversion dri_expected = { 4, 0, 0 };
+ static const __DRIversion drm_expected = { 1, 17, 0 };
+
+ dri_interface = interface;
+
+ if (!driCheckDriDdxDrmVersions3("R300",
+ dri_version, &dri_expected,
+ ddx_version, &ddx_expected,
+ drm_version, &drm_expected)) {
+ return NULL;
+ }
+
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &radeonAPI);
+ if (psp != NULL) {
+ RADEONDRIPtr dri_priv = (RADEONDRIPtr) psp->pDevPriv;
+ *driver_modes = radeonFillInModes(dri_priv->bpp,
+ (dri_priv->bpp ==
+ 16) ? 16 : 24,
+ (dri_priv->bpp ==
+ 16) ? 0 : 8,
+ (dri_priv->backOffset !=
+ dri_priv->depthOffset));
+ /* Calling driInitExtensions here, with a NULL context pointer, does not actually
+ * enable the extensions. It just makes sure that all the dispatch offsets for all
+ * the extensions that *might* be enables are known. This is needed because the
+ * dispatch offsets need to be known when _mesa_context_create is called, but we can't
+ * enable the extensions until we have a context pointer.
+ *
+ * Hello chicken. Hello egg. How are you two today?
+ */
+ driInitExtensions( NULL, card_extensions, GL_FALSE );
+ }
+
+ return (void *)psp;
+}
+
+
+/**
+ * Get information about previous buffer swaps.
+ */
+static int getSwapInfo(__DRIdrawablePrivate * dPriv, __DRIswapInfo * sInfo)
+{
+ radeonContextPtr radeon;
+
+ if ((dPriv == NULL) || (dPriv->driContextPriv == NULL)
+ || (dPriv->driContextPriv->driverPrivate == NULL)
+ || (sInfo == NULL)) {
+ return -1;
+ }
+
+ radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+ sInfo->swap_count = radeon->swap_count;
+ sInfo->swap_ust = radeon->swap_ust;
+ sInfo->swap_missed_count = radeon->swap_missed_count;
+
+ sInfo->swap_missed_usage = (sInfo->swap_missed_count != 0)
+ ? driCalculateSwapUsage(dPriv, 0, radeon->swap_missed_ust)
+ : 0.0;
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_screen.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_screen.h
new file mode 100644
index 000000000..ac8471fea
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_screen.h
@@ -0,0 +1,112 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __RADEON_SCREEN_H__
+#define __RADEON_SCREEN_H__
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include "xf86drm.h"
+#include "drm.h"
+#include "radeon_drm.h"
+#include "dri_util.h"
+#include "xmlconfig.h"
+
+typedef struct {
+ drm_handle_t handle; /* Handle to the DRM region */
+ drmSize size; /* Size of the DRM region */
+ drmAddress map; /* Mapping of the DRM region */
+} radeonRegionRec, *radeonRegionPtr;
+
+/* chipset features */
+#define RADEON_CHIP_UNREAL_R200 0
+#define RADEON_CHIP_REAL_R200 1
+#define RADEON_CHIP_R300 2
+#define RADEON_CHIP_RV350 3
+#define RADEON_CHIP_R420 4
+#define RADEON_CHIP_MASK 0x0f
+
+#define RADEON_CHIPSET_TCL (1 << 8)
+
+#define GET_CHIP(screen) ((screen)->chipset & RADEON_CHIP_MASK)
+#define IS_FAMILY_R200(radeon) (GET_CHIP((radeon)->radeonScreen) < RADEON_CHIP_R300)
+#define IS_FAMILY_R300(radeon) (GET_CHIP((radeon)->radeonScreen) >= RADEON_CHIP_R300)
+
+#define R200_NR_TEX_HEAPS 2
+
+typedef struct {
+ int chipset;
+ int cpp;
+ int IsPCI; /* Current card is a PCI card */
+ int AGPMode;
+ unsigned int irq; /* IRQ number (0 means none) */
+
+ unsigned int fbLocation;
+ unsigned int frontOffset;
+ unsigned int frontPitch;
+ unsigned int backOffset;
+ unsigned int backPitch;
+
+ unsigned int depthOffset;
+ unsigned int depthPitch;
+
+ /* Shared texture data */
+ int numTexHeaps;
+ int texOffset[R200_NR_TEX_HEAPS];
+ int texSize[R200_NR_TEX_HEAPS];
+ int logTexGranularity[R200_NR_TEX_HEAPS];
+
+ radeonRegionRec mmio;
+ radeonRegionRec status;
+ radeonRegionRec gartTextures;
+
+ drmBufMapPtr buffers;
+
+ __volatile__ int32_t *scratch;
+
+ __DRIscreenPrivate *driScreen;
+ unsigned int sarea_priv_offset;
+ unsigned int gart_buffer_offset; /* offset in card memory space */
+ unsigned int gart_texture_offset; /* offset in card memory space */
+ unsigned int gart_base;
+
+ GLboolean drmSupportsCubeMaps; /* need radeon kernel module >=1.7 */
+ GLboolean drmSupportsBlendColor; /* need radeon kernel module >= 1.11 */
+
+ /* Configuration cache with default values for all contexts */
+ driOptionCache optionCache;
+} radeonScreenRec, *radeonScreenPtr;
+
+#endif
+#endif /* __RADEON_SCREEN_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_span.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_span.c
new file mode 100644
index 000000000..8902c93e5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_span.c
@@ -0,0 +1,391 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "swrast/swrast.h"
+#include "colormac.h"
+
+#include "r200_context.h"
+#include "radeon_ioctl.h"
+#include "r300_ioctl.h"
+#include "radeon_span.h"
+
+#define DBG 0
+
+#define LOCAL_VARS \
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx); \
+ driRenderbuffer* drb = (driRenderbuffer*)rb; \
+ __DRIscreenPrivate *sPriv = radeon->dri.screen; \
+ __DRIdrawablePrivate *dPriv = radeon->dri.drawable; \
+ GLuint pitch = drb->pitch * drb->cpp; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(sPriv->pFB + \
+ drb->offset + \
+ (dPriv->x * drb->cpp) + \
+ (dPriv->y * pitch)); \
+ GLuint p; \
+ (void) p
+
+#define LOCAL_DEPTH_VARS \
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx); \
+ driRenderbuffer* drb = (driRenderbuffer*)rb; \
+ __DRIscreenPrivate *sPriv = radeon->dri.screen; \
+ __DRIdrawablePrivate *dPriv = radeon->dri.drawable; \
+ GLuint pitch = drb->pitch; \
+ GLuint height = dPriv->h; \
+ GLuint xo = dPriv->x; \
+ GLuint yo = dPriv->y; \
+ char *buf = (char *)(sPriv->pFB + drb->offset); \
+ (void) buf; (void) pitch
+
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
+
+#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), _n1 -= (minx-_x1), _x1 = minx; \
+ if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + _n1 - maxx); \
+ }
+
+#define Y_FLIP( _y ) (height - _y - 1)
+
+#define HW_LOCK()
+
+#define HW_CLIPLOOP() \
+ do { \
+ 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()
+
+/* ================================================================
+ * Color buffer
+ */
+
+/* 16 bit, RGB565 color spanline and pixel functions
+ */
+#define INIT_MONO_PIXEL(p, color) \
+ p = PACK_COLOR_565( color[0], color[1], color[2] )
+
+#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 *)(buf + _x*2 + _y*pitch); \
+ rgba[0] = ((p >> 8) & 0xf8) * 255 / 0xf8; \
+ rgba[1] = ((p >> 3) & 0xfc) * 255 / 0xfc; \
+ rgba[2] = ((p << 3) & 0xf8) * 255 / 0xf8; \
+ rgba[3] = 0xff; \
+ } while (0)
+
+#define TAG(x) radeon##x##_RGB565
+#include "spantmp.h"
+
+/* 32 bit, ARGB8888 color spanline and pixel functions
+ */
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = PACK_COLOR_8888( color[3], color[0], color[1], color[2] )
+
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+do { \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = ((b << 0) | \
+ (g << 8) | \
+ (r << 16) | \
+ (a << 24) ); \
+} while (0)
+
+#define WRITE_PIXEL( _x, _y, p ) \
+do { \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = p; \
+} while (0)
+
+#define READ_RGBA( rgba, _x, _y ) \
+do { \
+ volatile GLuint *ptr = (volatile GLuint *)(buf + _x*4 + _y*pitch); \
+ GLuint p = *ptr; \
+ 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) radeon##x##_ARGB8888
+#include "spantmp.h"
+
+/* ================================================================
+ * Depth buffer
+ */
+
+/* 16-bit depth buffer functions
+ */
+#define WRITE_DEPTH( _x, _y, d ) \
+ *(GLushort *)(buf + (_x + xo + (_y + yo)*pitch)*2 ) = d;
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLushort *)(buf + (_x + xo + (_y + yo)*pitch)*2 );
+
+#define TAG(x) radeon##x##_16_LINEAR
+#include "depthtmp.h"
+
+/* 24 bit depth, 8 bit stencil depthbuffer functions
+ *
+ * Careful: It looks like the R300 uses ZZZS byte order while the R200
+ * uses SZZZ for 24 bit depth, 8 bit stencil mode.
+ */
+#define WRITE_DEPTH( _x, _y, d ) \
+do { \
+ GLuint offset = ((_x) + xo + ((_y) + yo)*pitch)*4; \
+ GLuint tmp = *(GLuint *)(buf + offset); \
+ tmp &= 0x000000ff; \
+ tmp |= ((d << 8) & 0xffffff00); \
+ *(GLuint *)(buf + offset) = tmp; \
+} while (0)
+
+#define READ_DEPTH( d, _x, _y ) \
+do { \
+ d = (*(GLuint *)(buf + ((_x) + xo + ((_y) + yo)*pitch)*4) & 0xffffff00) >> 8; \
+} while(0)
+
+#define TAG(x) radeon##x##_24_8_LINEAR
+#include "depthtmp.h"
+
+/* ================================================================
+ * Stencil buffer
+ */
+
+/* 24 bit depth, 8 bit stencil depthbuffer functions
+ */
+#define WRITE_STENCIL( _x, _y, d ) \
+do { \
+ GLuint offset = (_x + xo + (_y + yo)*pitch)*4; \
+ GLuint tmp = *(GLuint *)(buf + offset); \
+ tmp &= 0xffffff00; \
+ tmp |= (d) & 0xff; \
+ *(GLuint *)(buf + offset) = tmp; \
+} while (0)
+
+#define READ_STENCIL( d, _x, _y ) \
+do { \
+ GLuint offset = (_x + xo + (_y + yo)*pitch)*4; \
+ GLuint tmp = *(GLuint *)(buf + offset); \
+ d = tmp & 0x000000ff; \
+} while (0)
+
+#define TAG(x) radeon##x##_24_8_LINEAR
+#include "stenciltmp.h"
+
+/*
+ * This function is called to specify which buffer to read and write
+ * for software rasterization (swrast) fallbacks. This doesn't necessarily
+ * correspond to glDrawBuffer() or glReadBuffer() calls.
+ */
+static void radeonSetBuffer(GLcontext * ctx,
+ GLframebuffer * colorBuffer, GLuint bufferBit)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ int buffer;
+
+ switch (bufferBit) {
+ case BUFFER_BIT_FRONT_LEFT:
+ buffer = 0;
+ break;
+
+ case BUFFER_BIT_BACK_LEFT:
+ buffer = 1;
+ break;
+
+ default:
+ _mesa_problem(ctx, "Bad bufferBit in %s", __FUNCTION__);
+ return;
+ }
+
+ if (radeon->doPageFlip && radeon->sarea->pfCurrentPage == 1)
+ buffer ^= 1;
+
+#if 0
+ fprintf(stderr, "%s: using %s buffer\n", __FUNCTION__,
+ buffer ? "back" : "front");
+#endif
+
+ if (buffer) {
+ radeon->state.pixel.readOffset =
+ radeon->radeonScreen->backOffset;
+ radeon->state.pixel.readPitch =
+ radeon->radeonScreen->backPitch;
+ radeon->state.color.drawOffset =
+ radeon->radeonScreen->backOffset;
+ radeon->state.color.drawPitch =
+ radeon->radeonScreen->backPitch;
+ } else {
+ radeon->state.pixel.readOffset =
+ radeon->radeonScreen->frontOffset;
+ radeon->state.pixel.readPitch =
+ radeon->radeonScreen->frontPitch;
+ radeon->state.color.drawOffset =
+ radeon->radeonScreen->frontOffset;
+ radeon->state.color.drawPitch =
+ radeon->radeonScreen->frontPitch;
+ }
+}
+
+/* Move locking out to get reasonable span performance (10x better
+ * than doing this in HW_LOCK above). WaitForIdle() is the main
+ * culprit.
+ */
+
+static void radeonSpanRenderStart(GLcontext * ctx)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+
+ if (IS_FAMILY_R200(radeon))
+ R200_FIREVERTICES((r200ContextPtr)radeon);
+ else
+ r300Flush(ctx);
+
+ LOCK_HARDWARE(radeon);
+ radeonWaitForIdleLocked(radeon);
+
+ /* Read & rewrite the first pixel in the frame buffer. This should
+ * be a noop, right? In fact without this conform fails as reading
+ * from the framebuffer sometimes produces old results -- the
+ * on-card read cache gets mixed up and doesn't notice that the
+ * framebuffer has been updated.
+ *
+ * In the worst case this is buggy too as p might get the wrong
+ * value first time, so really need a hidden pixel somewhere for this.
+ */
+ {
+ int p;
+ volatile int *read_buf =
+ (volatile int *)(radeon->dri.screen->pFB +
+ radeon->state.pixel.readOffset);
+ p = *read_buf;
+ *read_buf = p;
+ }
+}
+
+static void radeonSpanRenderFinish(GLcontext * ctx)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+
+ _swrast_flush(ctx);
+ UNLOCK_HARDWARE(radeon);
+}
+
+void radeonInitSpanFuncs(GLcontext * ctx)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+ struct swrast_device_driver *swdd =
+ _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetBuffer = radeonSetBuffer;
+
+ swdd->SpanRenderStart = radeonSpanRenderStart;
+ swdd->SpanRenderFinish = radeonSpanRenderFinish;
+}
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void radeonSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ drb->Base.GetRow = radeonReadRGBASpan_RGB565;
+ drb->Base.GetValues = radeonReadRGBAPixels_RGB565;
+ drb->Base.PutRow = radeonWriteRGBASpan_RGB565;
+ drb->Base.PutRowRGB = radeonWriteRGBSpan_RGB565;
+ drb->Base.PutMonoRow = radeonWriteMonoRGBASpan_RGB565;
+ drb->Base.PutValues = radeonWriteRGBAPixels_RGB565;
+ drb->Base.PutMonoValues = radeonWriteMonoRGBAPixels_RGB565;
+ }
+ else {
+ drb->Base.GetRow = radeonReadRGBASpan_ARGB8888;
+ drb->Base.GetValues = radeonReadRGBAPixels_ARGB8888;
+ drb->Base.PutRow = radeonWriteRGBASpan_ARGB8888;
+ drb->Base.PutRowRGB = radeonWriteRGBSpan_ARGB8888;
+ drb->Base.PutMonoRow = radeonWriteMonoRGBASpan_ARGB8888;
+ drb->Base.PutValues = radeonWriteRGBAPixels_ARGB8888;
+ drb->Base.PutMonoValues = radeonWriteMonoRGBAPixels_ARGB8888;
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = radeonReadDepthSpan_16_LINEAR;
+ drb->Base.GetValues = radeonReadDepthPixels_16_LINEAR;
+ drb->Base.PutRow = radeonWriteDepthSpan_16_LINEAR;
+ drb->Base.PutMonoRow = radeonWriteMonoDepthSpan_16_LINEAR;
+ drb->Base.PutValues = radeonWriteDepthPixels_16_LINEAR;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = radeonReadDepthSpan_24_8_LINEAR;
+ drb->Base.GetValues = radeonReadDepthPixels_24_8_LINEAR;
+ drb->Base.PutRow = radeonWriteDepthSpan_24_8_LINEAR;
+ drb->Base.PutMonoRow = radeonWriteMonoDepthSpan_24_8_LINEAR;
+ drb->Base.PutValues = radeonWriteDepthPixels_24_8_LINEAR;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = radeonReadStencilSpan_24_8_LINEAR;
+ drb->Base.GetValues = radeonReadStencilPixels_24_8_LINEAR;
+ drb->Base.PutRow = radeonWriteStencilSpan_24_8_LINEAR;
+ drb->Base.PutMonoRow = radeonWriteMonoStencilSpan_24_8_LINEAR;
+ drb->Base.PutValues = radeonWriteStencilPixels_24_8_LINEAR;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_span.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_span.h
new file mode 100644
index 000000000..c4280b1b6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_span.h
@@ -0,0 +1,46 @@
+/*
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __RADEON_SPAN_H__
+#define __RADEON_SPAN_H__
+
+#ifdef GLX_DIRECT_RENDERING
+
+#include "drirenderbuffer.h"
+
+extern void radeonInitSpanFuncs(GLcontext * ctx);
+extern void radeonSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
+#endif
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_state.c
new file mode 100644
index 000000000..0cacbb5eb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_state.c
@@ -0,0 +1,245 @@
+/**************************************************************************
+
+Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
+
+The Weather Channel (TM) funded Tungsten Graphics to develop the
+initial release of the Radeon 8500 driver under the XFree86 license.
+This notice must be preserved.
+
+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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "api_arrayelt.h"
+#include "enums.h"
+#include "colormac.h"
+#include "light.h"
+
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "r200_context.h"
+#include "radeon_ioctl.h"
+#include "radeon_state.h"
+#include "r200_state.h"
+#include "r300_ioctl.h"
+
+
+/* =============================================================
+ * Scissoring
+ */
+
+static GLboolean intersect_rect(drm_clip_rect_t * out,
+ drm_clip_rect_t * a, drm_clip_rect_t * b)
+{
+ *out = *a;
+ if (b->x1 > out->x1)
+ out->x1 = b->x1;
+ if (b->y1 > out->y1)
+ out->y1 = b->y1;
+ if (b->x2 < out->x2)
+ out->x2 = b->x2;
+ if (b->y2 < out->y2)
+ out->y2 = b->y2;
+ if (out->x1 >= out->x2)
+ return GL_FALSE;
+ if (out->y1 >= out->y2)
+ return GL_FALSE;
+ return GL_TRUE;
+}
+
+void radeonRecalcScissorRects(radeonContextPtr radeon)
+{
+ drm_clip_rect_t *out;
+ int i;
+
+ /* Grow cliprect store?
+ */
+ if (radeon->state.scissor.numAllocedClipRects < radeon->numClipRects) {
+ while (radeon->state.scissor.numAllocedClipRects <
+ radeon->numClipRects) {
+ radeon->state.scissor.numAllocedClipRects += 1; /* zero case */
+ radeon->state.scissor.numAllocedClipRects *= 2;
+ }
+
+ if (radeon->state.scissor.pClipRects)
+ FREE(radeon->state.scissor.pClipRects);
+
+ radeon->state.scissor.pClipRects =
+ MALLOC(radeon->state.scissor.numAllocedClipRects *
+ sizeof(drm_clip_rect_t));
+
+ if (radeon->state.scissor.pClipRects == NULL) {
+ radeon->state.scissor.numAllocedClipRects = 0;
+ return;
+ }
+ }
+
+ out = radeon->state.scissor.pClipRects;
+ radeon->state.scissor.numClipRects = 0;
+
+ for (i = 0; i < radeon->numClipRects; i++) {
+ if (intersect_rect(out,
+ &radeon->pClipRects[i],
+ &radeon->state.scissor.rect)) {
+ radeon->state.scissor.numClipRects++;
+ out++;
+ }
+ }
+}
+
+void radeonUpdateScissor(GLcontext* ctx)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+
+ assert(radeon->state.scissor.enabled == ctx->Scissor.Enabled);
+
+ if (radeon->dri.drawable) {
+ __DRIdrawablePrivate *dPriv = radeon->dri.drawable;
+ int x1 = dPriv->x + ctx->Scissor.X;
+ int y1 = dPriv->y + dPriv->h - (ctx->Scissor.Y + ctx->Scissor.Height);
+
+ radeon->state.scissor.rect.x1 = x1;
+ radeon->state.scissor.rect.y1 = y1;
+ radeon->state.scissor.rect.x2 = x1 + ctx->Scissor.Width - 1;
+ radeon->state.scissor.rect.y2 = y1 + ctx->Scissor.Height - 1;
+
+ radeonRecalcScissorRects(radeon);
+ }
+}
+
+static void radeonScissor(GLcontext* ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+
+ if (ctx->Scissor.Enabled) {
+ /* We don't pipeline cliprect changes */
+ if (IS_FAMILY_R200(radeon))
+ R200_FIREVERTICES((r200ContextPtr)radeon);
+ else
+ r300Flush(ctx);
+
+ radeonUpdateScissor(ctx);
+ }
+}
+
+
+/**
+ * Update cliprects and scissors.
+ */
+void radeonSetCliprects(radeonContextPtr radeon, GLenum mode)
+{
+ __DRIdrawablePrivate *dPriv = radeon->dri.drawable;
+
+ switch (mode) {
+ case GL_FRONT_LEFT:
+ radeon->numClipRects = dPriv->numClipRects;
+ radeon->pClipRects = dPriv->pClipRects;
+ break;
+ case GL_BACK_LEFT:
+ /* Can't ignore 2d windows if we are page flipping.
+ */
+ if (dPriv->numBackClipRects == 0 || radeon->doPageFlip) {
+ radeon->numClipRects = dPriv->numClipRects;
+ radeon->pClipRects = dPriv->pClipRects;
+ } else {
+ radeon->numClipRects = dPriv->numBackClipRects;
+ radeon->pClipRects = dPriv->pBackClipRects;
+ }
+ break;
+ default:
+ fprintf(stderr, "bad mode in radeonSetCliprects\n");
+ radeon->numClipRects = 0;
+ radeon->pClipRects = 0;
+ return;
+ }
+
+ if (radeon->state.scissor.enabled)
+ radeonRecalcScissorRects(radeon);
+}
+
+
+/**
+ * Handle common enable bits.
+ * Called as a fallback by r200Enable/r300Enable.
+ */
+void radeonEnable(GLcontext* ctx, GLenum cap, GLboolean state)
+{
+ radeonContextPtr radeon = RADEON_CONTEXT(ctx);
+
+ switch(cap) {
+ case GL_SCISSOR_TEST:
+ /* We don't pipeline cliprect & scissor changes */
+ if (IS_FAMILY_R200(radeon))
+ R200_FIREVERTICES((r200ContextPtr)radeon);
+ else
+ r300Flush(ctx);
+
+ radeon->state.scissor.enabled = state;
+ radeonUpdateScissor(ctx);
+ break;
+
+ default:
+ return;
+ }
+}
+
+
+/**
+ * Initialize default state.
+ * This function is called once at context init time from
+ * r200InitState/r300InitState
+ */
+void radeonInitState(radeonContextPtr radeon)
+{
+ radeon->Fallback = 0;
+
+ if (radeon->glCtx->Visual.doubleBufferMode && radeon->sarea->pfCurrentPage == 0) {
+ radeon->state.color.drawOffset = radeon->radeonScreen->backOffset;
+ radeon->state.color.drawPitch = radeon->radeonScreen->backPitch;
+ } else {
+ radeon->state.color.drawOffset = radeon->radeonScreen->frontOffset;
+ radeon->state.color.drawPitch = radeon->radeonScreen->frontPitch;
+ }
+
+ radeon->state.pixel.readOffset = radeon->state.color.drawOffset;
+ radeon->state.pixel.readPitch = radeon->state.color.drawPitch;
+}
+
+
+/**
+ * Initialize common state functions.
+ * Called by r200InitStateFuncs/r300InitStateFuncs
+ */
+void radeonInitStateFuncs(struct dd_function_table *functions)
+{
+ functions->Scissor = radeonScissor;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_state.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_state.h
new file mode 100644
index 000000000..636bf5d00
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/radeon_state.h
@@ -0,0 +1,45 @@
+/*
+Copyright (C) 2004 Nicolai Haehnle. 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 THE COPYRIGHT OWNER(S) 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:
+ * Nicolai Haehnle <prefect_@gmx.net>
+ */
+
+#ifndef __RADEON_STATE_H__
+#define __RADEON_STATE_H__
+
+#include "radeon_context.h"
+
+extern void radeonRecalcScissorRects(radeonContextPtr radeon);
+extern void radeonSetCliprects(radeonContextPtr radeon, GLenum mode);
+extern void radeonUpdateScissor(GLcontext* ctx);
+
+extern void radeonEnable(GLcontext* ctx, GLenum cap, GLboolean state);
+
+extern void radeonInitState(radeonContextPtr radeon);
+extern void radeonInitStateFuncs(struct dd_function_table* functions);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/vertex_shader.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/vertex_shader.h
new file mode 100644
index 000000000..6293915bf
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/r300/vertex_shader.h
@@ -0,0 +1,91 @@
+#ifndef __VERTEX_SHADER_H__
+#define __VERTEX_SHADER_H__
+
+#include "r300_reg.h"
+
+typedef struct {
+ CARD32 op;
+ CARD32 src1;
+ CARD32 src2;
+ CARD32 src3;
+ } VERTEX_SHADER_INSTRUCTION;
+
+#define VSF_FLAG_X 1
+#define VSF_FLAG_Y 2
+#define VSF_FLAG_Z 4
+#define VSF_FLAG_W 8
+#define VSF_FLAG_XYZ (VSF_FLAG_X | VSF_FLAG_Y | VSF_FLAG_Z)
+#define VSF_FLAG_ALL 0xf
+#define VSF_FLAG_NONE 0
+
+#define VSF_OUT_CLASS_TMP 0
+#define VSF_OUT_CLASS_RESULT 2
+
+
+/* first CARD32 of an instruction */
+
+/* possible operations:
+ DOT, MUL, ADD, MAD, FRC, MAX, MIN, SGE, SLT, EXP, LOG, LIT, POW, RCP, RSQ, EX2,
+ LG2, MAD_2 */
+
+#define MAKE_VSF_OP(op, out_reg_index, out_reg_fields, class) \
+ ((op) \
+ | ((out_reg_index) << R300_VPI_OUT_REG_INDEX_SHIFT) \
+ | ((out_reg_fields) << 20) \
+ | ( (class) << 8 ) )
+
+#define EASY_VSF_OP(op, out_reg_index, out_reg_fields, class) \
+ MAKE_VSF_OP(R300_VPI_OUT_OP_##op, out_reg_index, VSF_FLAG_##out_reg_fields, VSF_OUT_CLASS_##class) \
+
+/* according to Nikolai, the subsequent 3 CARD32 are sources, use same define for each */
+
+#define VSF_IN_CLASS_TMP 0
+#define VSF_IN_CLASS_ATTR 1
+#define VSF_IN_CLASS_PARAM 2
+#define VSF_IN_CLASS_NONE 9
+
+#define VSF_IN_COMPONENT_X 0
+#define VSF_IN_COMPONENT_Y 1
+#define VSF_IN_COMPONENT_Z 2
+#define VSF_IN_COMPONENT_W 3
+#define VSF_IN_COMPONENT_ZERO 4
+#define VSF_IN_COMPONENT_ONE 5
+
+#define MAKE_VSF_SOURCE(in_reg_index, comp_x, comp_y, comp_z, comp_w, class, negate) \
+ ( ((in_reg_index)<<R300_VPI_IN_REG_INDEX_SHIFT) \
+ | ((comp_x)<<R300_VPI_IN_X_SHIFT) \
+ | ((comp_y)<<R300_VPI_IN_Y_SHIFT) \
+ | ((comp_z)<<R300_VPI_IN_Z_SHIFT) \
+ | ((comp_w)<<R300_VPI_IN_W_SHIFT) \
+ | ((negate)<<25) | ((class)))
+
+#define EASY_VSF_SOURCE(in_reg_index, comp_x, comp_y, comp_z, comp_w, class, negate) \
+ MAKE_VSF_SOURCE(in_reg_index, \
+ VSF_IN_COMPONENT_##comp_x, \
+ VSF_IN_COMPONENT_##comp_y, \
+ VSF_IN_COMPONENT_##comp_z, \
+ VSF_IN_COMPONENT_##comp_w, \
+ VSF_IN_CLASS_##class, VSF_FLAG_##negate)
+
+/* special sources: */
+
+/* (1.0,1.0,1.0,1.0) vector (ATTR, plain ) */
+#define VSF_ATTR_UNITY(reg) EASY_VSF_SOURCE(reg, ONE, ONE, ONE, ONE, ATTR, NONE)
+#define VSF_UNITY(reg) EASY_VSF_SOURCE(reg, ONE, ONE, ONE, ONE, NONE, NONE)
+
+/* contents of unmodified register */
+#define VSF_REG(reg) EASY_VSF_SOURCE(reg, X, Y, Z, W, ATTR, NONE)
+
+/* contents of unmodified parameter */
+#define VSF_PARAM(reg) EASY_VSF_SOURCE(reg, X, Y, Z, W, PARAM, NONE)
+
+/* contents of unmodified temporary register */
+#define VSF_TMP(reg) EASY_VSF_SOURCE(reg, X, Y, Z, W, TMP, NONE)
+
+/* components of ATTR register */
+#define VSF_ATTR_X(reg) EASY_VSF_SOURCE(reg, X, X, X, X, ATTR, NONE)
+#define VSF_ATTR_Y(reg) EASY_VSF_SOURCE(reg, Y, Y, Y, Y, ATTR, NONE)
+#define VSF_ATTR_Z(reg) EASY_VSF_SOURCE(reg, Z, Z, Z, Z, ATTR, NONE)
+#define VSF_ATTR_W(reg) EASY_VSF_SOURCE(reg, W, W, W, W, ATTR, NONE)
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/Makefile
new file mode 100644
index 000000000..b0ef17299
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/Makefile
@@ -0,0 +1,42 @@
+# src/mesa/drivers/dri/radeon/Makefile
+# Note, this Makefile requires GNU make
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = radeon_dri.so
+
+MINIGLX_SOURCES = server/radeon_dri.c
+
+DRIVER_SOURCES = \
+ radeon_context.c \
+ radeon_ioctl.c \
+ radeon_lock.c \
+ radeon_screen.c \
+ radeon_state.c \
+ radeon_state_init.c \
+ radeon_tex.c \
+ radeon_texmem.c \
+ radeon_texstate.c \
+ radeon_tcl.c \
+ radeon_swtcl.c \
+ radeon_span.c \
+ radeon_maos.c \
+ radeon_sanity.c \
+ radeon_compat.c \
+ radeon_vtxfmt.c \
+ radeon_vtxfmt_c.c \
+ radeon_vtxfmt_sse.c \
+ radeon_vtxfmt_x86.c
+
+C_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(DRIVER_SOURCES)
+
+
+X86_SOURCES = \
+ radeon_vtxtmp_x86.S
+
+include ../Makefile.template
+
+symlinks:
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_compat.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_compat.c
new file mode 100644
index 000000000..1cbe3407b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_compat.c
@@ -0,0 +1,302 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 2002 ATI Technologies Inc., Ontario, Canada, and
+ Tungsten Graphics Inc., Austin, 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, TUNGSTEN GRAPHICS 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ *
+ */
+
+#include "glheader.h"
+#include "imports.h"
+
+#include "radeon_context.h"
+#include "radeon_state.h"
+#include "radeon_ioctl.h"
+
+
+static struct {
+ int start;
+ int len;
+ const char *name;
+} packet[RADEON_MAX_STATE_PACKETS] = {
+ { RADEON_PP_MISC,7,"RADEON_PP_MISC" },
+ { RADEON_PP_CNTL,3,"RADEON_PP_CNTL" },
+ { RADEON_RB3D_COLORPITCH,1,"RADEON_RB3D_COLORPITCH" },
+ { RADEON_RE_LINE_PATTERN,2,"RADEON_RE_LINE_PATTERN" },
+ { RADEON_SE_LINE_WIDTH,1,"RADEON_SE_LINE_WIDTH" },
+ { RADEON_PP_LUM_MATRIX,1,"RADEON_PP_LUM_MATRIX" },
+ { RADEON_PP_ROT_MATRIX_0,2,"RADEON_PP_ROT_MATRIX_0" },
+ { RADEON_RB3D_STENCILREFMASK,3,"RADEON_RB3D_STENCILREFMASK" },
+ { RADEON_SE_VPORT_XSCALE,6,"RADEON_SE_VPORT_XSCALE" },
+ { RADEON_SE_CNTL,2,"RADEON_SE_CNTL" },
+ { RADEON_SE_CNTL_STATUS,1,"RADEON_SE_CNTL_STATUS" },
+ { RADEON_RE_MISC,1,"RADEON_RE_MISC" },
+ { RADEON_PP_TXFILTER_0,6,"RADEON_PP_TXFILTER_0" },
+ { RADEON_PP_BORDER_COLOR_0,1,"RADEON_PP_BORDER_COLOR_0" },
+ { RADEON_PP_TXFILTER_1,6,"RADEON_PP_TXFILTER_1" },
+ { RADEON_PP_BORDER_COLOR_1,1,"RADEON_PP_BORDER_COLOR_1" },
+ { RADEON_PP_TXFILTER_2,6,"RADEON_PP_TXFILTER_2" },
+ { RADEON_PP_BORDER_COLOR_2,1,"RADEON_PP_BORDER_COLOR_2" },
+ { RADEON_SE_ZBIAS_FACTOR,2,"RADEON_SE_ZBIAS_FACTOR" },
+ { RADEON_SE_TCL_OUTPUT_VTX_FMT,11,"RADEON_SE_TCL_OUTPUT_VTX_FMT" },
+ { RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED,17,"RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED" },
+};
+
+
+static void radeonCompatEmitPacket( radeonContextPtr rmesa,
+ struct radeon_state_atom *state )
+{
+ drm_radeon_sarea_t *sarea = rmesa->sarea;
+ drm_radeon_context_regs_t *ctx = &sarea->context_state;
+ drm_radeon_texture_regs_t *tex0 = &sarea->tex_state[0];
+ drm_radeon_texture_regs_t *tex1 = &sarea->tex_state[1];
+ int i;
+ int *buf = state->cmd;
+
+ for ( i = 0 ; i < state->cmd_size ; ) {
+ drm_radeon_cmd_header_t *header = (drm_radeon_cmd_header_t *)&buf[i++];
+
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s %d: %s\n", __FUNCTION__, header->packet.packet_id,
+ packet[(int)header->packet.packet_id].name);
+
+ switch (header->packet.packet_id) {
+ case RADEON_EMIT_PP_MISC:
+ ctx->pp_misc = buf[i++];
+ ctx->pp_fog_color = buf[i++];
+ ctx->re_solid_color = buf[i++];
+ ctx->rb3d_blendcntl = buf[i++];
+ ctx->rb3d_depthoffset = buf[i++];
+ ctx->rb3d_depthpitch = buf[i++];
+ ctx->rb3d_zstencilcntl = buf[i++];
+ sarea->dirty |= RADEON_UPLOAD_CONTEXT;
+ break;
+ case RADEON_EMIT_PP_CNTL:
+ ctx->pp_cntl = buf[i++];
+ ctx->rb3d_cntl = buf[i++];
+ ctx->rb3d_coloroffset = buf[i++];
+ sarea->dirty |= RADEON_UPLOAD_CONTEXT;
+ break;
+ case RADEON_EMIT_RB3D_COLORPITCH:
+ ctx->rb3d_colorpitch = buf[i++];
+ sarea->dirty |= RADEON_UPLOAD_CONTEXT;
+ break;
+ case RADEON_EMIT_RE_LINE_PATTERN:
+ ctx->re_line_pattern = buf[i++];
+ ctx->re_line_state = buf[i++];
+ sarea->dirty |= RADEON_UPLOAD_LINE;
+ break;
+ case RADEON_EMIT_SE_LINE_WIDTH:
+ ctx->se_line_width = buf[i++];
+ sarea->dirty |= RADEON_UPLOAD_LINE;
+ break;
+ case RADEON_EMIT_PP_LUM_MATRIX:
+ ctx->pp_lum_matrix = buf[i++];
+ sarea->dirty |= RADEON_UPLOAD_BUMPMAP;
+ break;
+ case RADEON_EMIT_PP_ROT_MATRIX_0:
+ ctx->pp_rot_matrix_0 = buf[i++];
+ ctx->pp_rot_matrix_1 = buf[i++];
+ sarea->dirty |= RADEON_UPLOAD_BUMPMAP;
+ break;
+ case RADEON_EMIT_RB3D_STENCILREFMASK:
+ ctx->rb3d_stencilrefmask = buf[i++];
+ ctx->rb3d_ropcntl = buf[i++];
+ ctx->rb3d_planemask = buf[i++];
+ sarea->dirty |= RADEON_UPLOAD_MASKS;
+ break;
+ case RADEON_EMIT_SE_VPORT_XSCALE:
+ ctx->se_vport_xscale = buf[i++];
+ ctx->se_vport_xoffset = buf[i++];
+ ctx->se_vport_yscale = buf[i++];
+ ctx->se_vport_yoffset = buf[i++];
+ ctx->se_vport_zscale = buf[i++];
+ ctx->se_vport_zoffset = buf[i++];
+ sarea->dirty |= RADEON_UPLOAD_VIEWPORT;
+ break;
+ case RADEON_EMIT_SE_CNTL:
+ ctx->se_cntl = buf[i++];
+ ctx->se_coord_fmt = buf[i++];
+ sarea->dirty |= RADEON_UPLOAD_CONTEXT | RADEON_UPLOAD_VERTFMT;
+ break;
+ case RADEON_EMIT_SE_CNTL_STATUS:
+ ctx->se_cntl_status = buf[i++];
+ sarea->dirty |= RADEON_UPLOAD_SETUP;
+ break;
+ case RADEON_EMIT_RE_MISC:
+ ctx->re_misc = buf[i++];
+ sarea->dirty |= RADEON_UPLOAD_MISC;
+ break;
+ case RADEON_EMIT_PP_TXFILTER_0:
+ tex0->pp_txfilter = buf[i++];
+ tex0->pp_txformat = buf[i++];
+ tex0->pp_txoffset = buf[i++];
+ tex0->pp_txcblend = buf[i++];
+ tex0->pp_txablend = buf[i++];
+ tex0->pp_tfactor = buf[i++];
+ sarea->dirty |= RADEON_UPLOAD_TEX0;
+ break;
+ case RADEON_EMIT_PP_BORDER_COLOR_0:
+ tex0->pp_border_color = buf[i++];
+ sarea->dirty |= RADEON_UPLOAD_TEX0;
+ break;
+ case RADEON_EMIT_PP_TXFILTER_1:
+ tex1->pp_txfilter = buf[i++];
+ tex1->pp_txformat = buf[i++];
+ tex1->pp_txoffset = buf[i++];
+ tex1->pp_txcblend = buf[i++];
+ tex1->pp_txablend = buf[i++];
+ tex1->pp_tfactor = buf[i++];
+ sarea->dirty |= RADEON_UPLOAD_TEX1;
+ break;
+ case RADEON_EMIT_PP_BORDER_COLOR_1:
+ tex1->pp_border_color = buf[i++];
+ sarea->dirty |= RADEON_UPLOAD_TEX1;
+ break;
+
+ case RADEON_EMIT_SE_ZBIAS_FACTOR:
+ i++;
+ i++;
+ break;
+
+ case RADEON_EMIT_PP_TXFILTER_2:
+ case RADEON_EMIT_PP_BORDER_COLOR_2:
+ case RADEON_EMIT_SE_TCL_OUTPUT_VTX_FMT:
+ case RADEON_EMIT_SE_TCL_MATERIAL_EMMISSIVE_RED:
+ default:
+ /* These states aren't understood by radeon drm 1.1 */
+ fprintf(stderr, "Tried to emit unsupported state\n");
+ return;
+ }
+ }
+}
+
+
+
+static void radeonCompatEmitStateLocked( radeonContextPtr rmesa )
+{
+ struct radeon_state_atom *atom;
+
+ if (RADEON_DEBUG & (DEBUG_STATE|DEBUG_PRIMS))
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (!rmesa->hw.is_dirty && !rmesa->hw.all_dirty)
+ return;
+
+ foreach(atom, &rmesa->hw.atomlist) {
+ if (rmesa->hw.all_dirty)
+ atom->dirty = GL_TRUE;
+ if (atom->is_tcl)
+ atom->dirty = GL_FALSE;
+ if (atom->dirty)
+ radeonCompatEmitPacket(rmesa, atom);
+ }
+
+ rmesa->hw.is_dirty = GL_FALSE;
+ rmesa->hw.all_dirty = GL_FALSE;
+}
+
+
+static void radeonCompatEmitPrimitiveLocked( radeonContextPtr rmesa,
+ GLuint hw_primitive,
+ GLuint nverts,
+ drm_clip_rect_t *pbox,
+ GLuint nbox )
+{
+ int i;
+
+ for ( i = 0 ; i < nbox ; ) {
+ int nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS, nbox );
+ drm_clip_rect_t *b = rmesa->sarea->boxes;
+ drm_radeon_vertex_t vtx;
+
+ rmesa->sarea->dirty |= RADEON_UPLOAD_CLIPRECTS;
+ rmesa->sarea->nbox = nr - i;
+
+ for ( ; i < nr ; i++)
+ *b++ = pbox[i];
+
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr,
+ "RadeonFlushVertexBuffer: prim %x buf %d verts %d "
+ "disc %d nbox %d\n",
+ hw_primitive,
+ rmesa->dma.current.buf->buf->idx,
+ nverts,
+ nr == nbox,
+ rmesa->sarea->nbox );
+
+ vtx.prim = hw_primitive;
+ vtx.idx = rmesa->dma.current.buf->buf->idx;
+ vtx.count = nverts;
+ vtx.discard = (nr == nbox);
+
+ drmCommandWrite( rmesa->dri.fd,
+ DRM_RADEON_VERTEX,
+ &vtx, sizeof(vtx));
+ }
+}
+
+
+
+/* No 'start' for 1.1 vertices ioctl: only one vertex prim/buffer!
+ */
+void radeonCompatEmitPrimitive( radeonContextPtr rmesa,
+ GLuint vertex_format,
+ GLuint hw_primitive,
+ GLuint nrverts )
+{
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ LOCK_HARDWARE( rmesa );
+
+ radeonCompatEmitStateLocked( rmesa );
+ rmesa->sarea->vc_format = vertex_format;
+
+ if (rmesa->state.scissor.enabled) {
+ radeonCompatEmitPrimitiveLocked( rmesa,
+ hw_primitive,
+ nrverts,
+ rmesa->state.scissor.pClipRects,
+ rmesa->state.scissor.numClipRects );
+ }
+ else {
+ radeonCompatEmitPrimitiveLocked( rmesa,
+ hw_primitive,
+ nrverts,
+ rmesa->pClipRects,
+ rmesa->numClipRects );
+ }
+
+
+ UNLOCK_HARDWARE( rmesa );
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_context.c
new file mode 100644
index 000000000..c96f38e0a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_context.c
@@ -0,0 +1,630 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_context.c,v 1.9 2003/09/24 02:43:12 dawes Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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 THE COPYRIGHT OWNER(S) 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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "api_arrayelt.h"
+#include "context.h"
+#include "simple_list.h"
+#include "imports.h"
+#include "matrix.h"
+#include "extensions.h"
+#include "framebuffer.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+
+#include "drivers/common/driverfuncs.h"
+
+#include "radeon_context.h"
+#include "radeon_ioctl.h"
+#include "radeon_state.h"
+#include "radeon_span.h"
+#include "radeon_tex.h"
+#include "radeon_swtcl.h"
+#include "radeon_tcl.h"
+#include "radeon_vtxfmt.h"
+#include "radeon_maos.h"
+
+#define need_GL_ARB_multisample
+#define need_GL_ARB_texture_compression
+#define need_GL_EXT_blend_minmax
+#define need_GL_EXT_secondary_color
+#include "extension_helper.h"
+
+#define DRIVER_DATE "20050528"
+
+#include "vblank.h"
+#include "utils.h"
+#include "xmlpool.h" /* for symbolic values of enum-type options */
+#ifndef RADEON_DEBUG
+int RADEON_DEBUG = (0);
+#endif
+
+
+/* Return the width and height of the given buffer.
+ */
+static void radeonGetBufferSize( GLframebuffer *buffer,
+ GLuint *width, GLuint *height )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ LOCK_HARDWARE( rmesa );
+ *width = rmesa->dri.drawable->w;
+ *height = rmesa->dri.drawable->h;
+ UNLOCK_HARDWARE( rmesa );
+}
+
+/* Return various strings for glGetString().
+ */
+static const GLubyte *radeonGetString( GLcontext *ctx, GLenum name )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ static char buffer[128];
+ unsigned offset;
+ GLuint agp_mode = rmesa->radeonScreen->IsPCI ? 0 :
+ rmesa->radeonScreen->AGPMode;
+
+ switch ( name ) {
+ case GL_VENDOR:
+ return (GLubyte *)"Tungsten Graphics, Inc.";
+
+ case GL_RENDERER:
+ offset = driGetRendererString( buffer, "Radeon", DRIVER_DATE,
+ agp_mode );
+
+ sprintf( & buffer[ offset ], " %sTCL",
+ !(rmesa->TclFallback & RADEON_TCL_FALLBACK_TCL_DISABLE)
+ ? "" : "NO-" );
+
+ return (GLubyte *)buffer;
+
+ default:
+ return NULL;
+ }
+}
+
+
+/* Extension strings exported by the R100 driver.
+ */
+const struct dri_extension card_extensions[] =
+{
+ { "GL_ARB_multisample", GL_ARB_multisample_functions },
+ { "GL_ARB_multitexture", NULL },
+ { "GL_ARB_texture_border_clamp", NULL },
+ { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions },
+ { "GL_ARB_texture_env_add", NULL },
+ { "GL_ARB_texture_env_combine", NULL },
+ { "GL_ARB_texture_env_crossbar", NULL },
+ { "GL_ARB_texture_env_dot3", NULL },
+ { "GL_ARB_texture_mirrored_repeat", NULL },
+ { "GL_EXT_blend_logic_op", NULL },
+ { "GL_EXT_blend_subtract", GL_EXT_blend_minmax_functions },
+ { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions },
+ { "GL_EXT_stencil_wrap", NULL },
+ { "GL_EXT_texture_edge_clamp", NULL },
+ { "GL_EXT_texture_env_combine", NULL },
+ { "GL_EXT_texture_env_dot3", NULL },
+ { "GL_EXT_texture_filter_anisotropic", NULL },
+ { "GL_EXT_texture_lod_bias", NULL },
+ { "GL_EXT_texture_mirror_clamp", NULL },
+ { "GL_ATI_texture_env_combine3", NULL },
+ { "GL_ATI_texture_mirror_once", NULL },
+ { "GL_MESA_ycbcr_texture", NULL },
+ { "GL_NV_blend_square", NULL },
+ { "GL_SGIS_generate_mipmap", NULL },
+ { NULL, NULL }
+};
+
+extern const struct tnl_pipeline_stage _radeon_texrect_stage;
+extern const struct tnl_pipeline_stage _radeon_render_stage;
+extern const struct tnl_pipeline_stage _radeon_tcl_stage;
+
+static const struct tnl_pipeline_stage *radeon_pipeline[] = {
+
+ /* Try and go straight to t&l
+ */
+ &_radeon_tcl_stage,
+
+ /* Catch any t&l fallbacks
+ */
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+
+ /* Scale texture rectangle to 0..1.
+ */
+ &_radeon_texrect_stage,
+
+ &_radeon_render_stage,
+ &_tnl_render_stage, /* FALLBACK: */
+ NULL,
+};
+
+
+
+/* Initialize the driver's misc functions.
+ */
+static void radeonInitDriverFuncs( struct dd_function_table *functions )
+{
+ functions->GetBufferSize = radeonGetBufferSize;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
+ functions->GetString = radeonGetString;
+}
+
+static const struct dri_debug_control debug_control[] =
+{
+ { "fall", DEBUG_FALLBACKS },
+ { "tex", DEBUG_TEXTURE },
+ { "ioctl", DEBUG_IOCTL },
+ { "prim", DEBUG_PRIMS },
+ { "vert", DEBUG_VERTS },
+ { "state", DEBUG_STATE },
+ { "code", DEBUG_CODEGEN },
+ { "vfmt", DEBUG_VFMT },
+ { "vtxf", DEBUG_VFMT },
+ { "verb", DEBUG_VERBOSE },
+ { "dri", DEBUG_DRI },
+ { "dma", DEBUG_DMA },
+ { "san", DEBUG_SANITY },
+ { "sync", DEBUG_SYNC },
+ { NULL, 0 }
+};
+
+
+/* Create the device specific context.
+ */
+GLboolean
+radeonCreateContext( const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate)
+{
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ radeonScreenPtr screen = (radeonScreenPtr)(sPriv->private);
+ struct dd_function_table functions;
+ radeonContextPtr rmesa;
+ GLcontext *ctx, *shareCtx;
+ int i;
+ int tcl_mode, fthrottle_mode;
+
+ assert(glVisual);
+ assert(driContextPriv);
+ assert(screen);
+
+ /* Allocate the Radeon context */
+ rmesa = (radeonContextPtr) CALLOC( sizeof(*rmesa) );
+ if ( !rmesa )
+ return GL_FALSE;
+
+ /* Parse configuration files.
+ * Do this here so that initialMaxAnisotropy is set before we create
+ * the default textures.
+ */
+ driParseConfigFiles (&rmesa->optionCache, &screen->optionCache,
+ screen->driScreen->myNum, "radeon");
+ rmesa->initialMaxAnisotropy = driQueryOptionf(&rmesa->optionCache,
+ "def_max_anisotropy");
+
+ if ( driQueryOptionb( &rmesa->optionCache, "hyperz" ) ) {
+ if ( sPriv->drmMinor < 13 )
+ fprintf( stderr, "DRM version 1.%d too old to support HyperZ, "
+ "disabling.\n",sPriv->drmMinor );
+ else
+ rmesa->using_hyperz = GL_TRUE;
+ }
+
+ if ( sPriv->drmMinor >= 15 )
+ rmesa->texmicrotile = GL_TRUE;
+
+ /* Init default driver functions then plug in our Radeon-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions( &functions );
+ radeonInitDriverFuncs( &functions );
+ radeonInitTextureFuncs( &functions );
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((radeonContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ rmesa->glCtx = _mesa_create_context(glVisual, shareCtx,
+ &functions, (void *) rmesa);
+ if (!rmesa->glCtx) {
+ FREE(rmesa);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = rmesa;
+
+ /* Init radeon context data */
+ rmesa->dri.context = driContextPriv;
+ rmesa->dri.screen = sPriv;
+ rmesa->dri.drawable = NULL; /* Set by XMesaMakeCurrent */
+ rmesa->dri.hwContext = driContextPriv->hHWContext;
+ rmesa->dri.hwLock = &sPriv->pSAREA->lock;
+ rmesa->dri.fd = sPriv->fd;
+ rmesa->dri.drmMinor = sPriv->drmMinor;
+
+ rmesa->radeonScreen = screen;
+ rmesa->sarea = (drm_radeon_sarea_t *)((GLubyte *)sPriv->pSAREA +
+ screen->sarea_priv_offset);
+
+
+ rmesa->dma.buf0_address = rmesa->radeonScreen->buffers->list[0].address;
+
+ (void) memset( rmesa->texture_heaps, 0, sizeof( rmesa->texture_heaps ) );
+ make_empty_list( & rmesa->swapped );
+
+ rmesa->nr_heaps = screen->numTexHeaps;
+ for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
+ rmesa->texture_heaps[i] = driCreateTextureHeap( i, rmesa,
+ screen->texSize[i],
+ 12,
+ RADEON_NR_TEX_REGIONS,
+ (drmTextureRegionPtr)rmesa->sarea->tex_list[i],
+ & rmesa->sarea->tex_age[i],
+ & rmesa->swapped,
+ sizeof( radeonTexObj ),
+ (destroy_texture_object_t *) radeonDestroyTexObj );
+
+ driSetTextureSwapCounterLocation( rmesa->texture_heaps[i],
+ & rmesa->c_textureSwaps );
+ }
+ rmesa->texture_depth = driQueryOptioni (&rmesa->optionCache,
+ "texture_depth");
+ if (rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
+ rmesa->texture_depth = ( screen->cpp == 4 ) ?
+ DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
+
+ rmesa->swtcl.RenderIndex = ~0;
+ rmesa->hw.all_dirty = GL_TRUE;
+
+ /* Set the maximum texture size small enough that we can guarentee that
+ * all texture units can bind a maximal texture and have them both in
+ * texturable memory at once.
+ */
+
+ ctx = rmesa->glCtx;
+ ctx->Const.MaxTextureUnits = 2;
+ ctx->Const.MaxTextureImageUnits = 2;
+ ctx->Const.MaxTextureCoordUnits = 2;
+
+ driCalculateMaxTextureLevels( rmesa->texture_heaps,
+ rmesa->nr_heaps,
+ & ctx->Const,
+ 4,
+ 11, /* max 2D texture size is 2048x2048 */
+ 0, /* 3D textures unsupported. */
+ 0, /* cube textures unsupported. */
+ 11, /* max rect texture size is 2048x2048. */
+ 12,
+ GL_FALSE );
+
+ /* adjust max texture size a bit. Hack, but I really want to use larger textures
+ which will work just fine in 99.999999% of all cases, especially with texture compression... */
+ if (driQueryOptionb( &rmesa->optionCache, "texture_level_hack" ))
+ {
+ if (ctx->Const.MaxTextureLevels < 12) ctx->Const.MaxTextureLevels += 1;
+ }
+
+ ctx->Const.MaxTextureMaxAnisotropy = 16.0;
+
+ /* No wide points.
+ */
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = 1.0;
+ ctx->Const.MaxPointSizeAA = 1.0;
+
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 10.0;
+ ctx->Const.MaxLineWidthAA = 10.0;
+ ctx->Const.LineWidthGranularity = 0.0625;
+
+ /* Set maxlocksize (and hence vb size) small enough to avoid
+ * fallbacks in radeon_tcl.c. ie. guarentee that all vertices can
+ * fit in a single dma buffer for indexed rendering of quad strips,
+ * etc.
+ */
+ ctx->Const.MaxArrayLockSize =
+ MIN2( ctx->Const.MaxArrayLockSize,
+ RADEON_BUFFER_SIZE / RADEON_MAX_TCL_VERTSIZE );
+
+ rmesa->boxes = 0;
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+ _ae_create_context( ctx );
+
+ /* Install the customized pipeline:
+ */
+ _tnl_destroy_pipeline( ctx );
+ _tnl_install_pipeline( ctx, radeon_pipeline );
+ ctx->Driver.FlushVertices = radeonFlushVertices;
+
+ /* Try and keep materials and vertices separate:
+ */
+ _tnl_isolate_materials( ctx, GL_TRUE );
+
+/* _mesa_allow_light_in_model( ctx, GL_FALSE ); */
+
+ /* Configure swrast and T&L to match hardware characteristics:
+ */
+ _swrast_allow_pixel_fog( ctx, GL_FALSE );
+ _swrast_allow_vertex_fog( ctx, GL_TRUE );
+ _tnl_allow_pixel_fog( ctx, GL_FALSE );
+ _tnl_allow_vertex_fog( ctx, GL_TRUE );
+
+
+ _math_matrix_ctr( &rmesa->TexGenMatrix[0] );
+ _math_matrix_ctr( &rmesa->TexGenMatrix[1] );
+ _math_matrix_ctr( &rmesa->tmpmat );
+ _math_matrix_set_identity( &rmesa->TexGenMatrix[0] );
+ _math_matrix_set_identity( &rmesa->TexGenMatrix[1] );
+ _math_matrix_set_identity( &rmesa->tmpmat );
+
+ driInitExtensions( ctx, card_extensions, GL_TRUE );
+ if (rmesa->glCtx->Mesa_DXTn) {
+ _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
+ _mesa_enable_extension( ctx, "GL_S3_s3tc" );
+ }
+ else if (driQueryOptionb (&rmesa->optionCache, "force_s3tc_enable")) {
+ _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
+ }
+
+ if (rmesa->dri.drmMinor >= 9)
+ _mesa_enable_extension( ctx, "GL_NV_texture_rectangle");
+
+ /* XXX these should really go right after _mesa_init_driver_functions() */
+ radeonInitIoctlFuncs( ctx );
+ radeonInitStateFuncs( ctx );
+ radeonInitSpanFuncs( ctx );
+ radeonInitState( rmesa );
+ radeonInitSwtcl( ctx );
+
+ _mesa_vector4f_alloc( &rmesa->tcl.ObjClean, 0,
+ ctx->Const.MaxArrayLockSize, 32 );
+
+ fthrottle_mode = driQueryOptioni(&rmesa->optionCache, "fthrottle_mode");
+ rmesa->iw.irq_seq = -1;
+ rmesa->irqsEmitted = 0;
+ rmesa->do_irqs = (rmesa->radeonScreen->irq != 0 &&
+ fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS);
+
+ rmesa->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
+
+ rmesa->vblank_flags = (rmesa->radeonScreen->irq != 0)
+ ? driGetDefaultVBlankFlags(&rmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
+
+ (*dri_interface->getUST)( & rmesa->swap_ust );
+
+
+#if DO_DEBUG
+ RADEON_DEBUG = driParseDebugString( getenv( "RADEON_DEBUG" ),
+ debug_control );
+#endif
+
+ tcl_mode = driQueryOptioni(&rmesa->optionCache, "tcl_mode");
+ if (driQueryOptionb(&rmesa->optionCache, "no_rast")) {
+ fprintf(stderr, "disabling 3D acceleration\n");
+ FALLBACK(rmesa, RADEON_FALLBACK_DISABLE, 1);
+ } else if (tcl_mode == DRI_CONF_TCL_SW ||
+ !(rmesa->radeonScreen->chipset & RADEON_CHIPSET_TCL)) {
+ if (rmesa->radeonScreen->chipset & RADEON_CHIPSET_TCL) {
+ rmesa->radeonScreen->chipset &= ~RADEON_CHIPSET_TCL;
+ fprintf(stderr, "Disabling HW TCL support\n");
+ }
+ TCL_FALLBACK(rmesa->glCtx, RADEON_TCL_FALLBACK_TCL_DISABLE, 1);
+ }
+
+ if (rmesa->radeonScreen->chipset & RADEON_CHIPSET_TCL) {
+ if (tcl_mode >= DRI_CONF_TCL_VTXFMT)
+ radeonVtxfmtInit( ctx, tcl_mode >= DRI_CONF_TCL_CODEGEN );
+
+ _tnl_need_dlist_norm_lengths( ctx, GL_FALSE );
+ }
+ return GL_TRUE;
+}
+
+
+/* Destroy the device specific context.
+ */
+/* Destroy the Mesa and driver specific context data.
+ */
+void radeonDestroyContext( __DRIcontextPrivate *driContextPriv )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = (radeonContextPtr) driContextPriv->driverPrivate;
+ radeonContextPtr current = ctx ? RADEON_CONTEXT(ctx) : NULL;
+
+ /* check if we're deleting the currently bound context */
+ if (rmesa == current) {
+ RADEON_FIREVERTICES( rmesa );
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ /* Free radeon context resources */
+ assert(rmesa); /* should never be null */
+ if ( rmesa ) {
+ GLboolean release_texture_heaps;
+
+
+ release_texture_heaps = (rmesa->glCtx->Shared->RefCount == 1);
+ _swsetup_DestroyContext( rmesa->glCtx );
+ _tnl_DestroyContext( rmesa->glCtx );
+ _ac_DestroyContext( rmesa->glCtx );
+ _swrast_DestroyContext( rmesa->glCtx );
+
+ radeonDestroySwtcl( rmesa->glCtx );
+ radeonReleaseArrays( rmesa->glCtx, ~0 );
+ if (rmesa->dma.current.buf) {
+ radeonReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );
+ radeonFlushCmdBuf( rmesa, __FUNCTION__ );
+ }
+
+ if (!(rmesa->TclFallback & RADEON_TCL_FALLBACK_TCL_DISABLE)) {
+ int tcl_mode = driQueryOptioni(&rmesa->optionCache, "tcl_mode");
+ if (tcl_mode >= DRI_CONF_TCL_VTXFMT)
+ radeonVtxfmtDestroy( rmesa->glCtx );
+ }
+
+ /* free the Mesa context */
+ rmesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context( rmesa->glCtx );
+
+ _mesa_vector4f_free( &rmesa->tcl.ObjClean );
+
+ if (rmesa->state.scissor.pClipRects) {
+ FREE(rmesa->state.scissor.pClipRects);
+ rmesa->state.scissor.pClipRects = NULL;
+ }
+
+ if ( release_texture_heaps ) {
+ /* This share group is about to go away, free our private
+ * texture object data.
+ */
+ int i;
+
+ for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
+ driDestroyTextureHeap( rmesa->texture_heaps[ i ] );
+ rmesa->texture_heaps[ i ] = NULL;
+ }
+
+ assert( is_empty_list( & rmesa->swapped ) );
+ }
+
+ /* free the option cache */
+ driDestroyOptionCache (&rmesa->optionCache);
+
+ FREE( rmesa );
+ }
+}
+
+
+
+
+void
+radeonSwapBuffers( __DRIdrawablePrivate *dPriv )
+{
+
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ radeonContextPtr rmesa;
+ GLcontext *ctx;
+ rmesa = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+ ctx = rmesa->glCtx;
+ if (ctx->Visual.doubleBufferMode) {
+ _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
+
+ if ( rmesa->doPageFlip ) {
+ radeonPageFlip( dPriv );
+ }
+ else {
+ radeonCopyBuffer( dPriv );
+ }
+ }
+ }
+ else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__);
+ }
+}
+
+
+/* Force the context `c' to be the current context and associate with it
+ * buffer `b'.
+ */
+GLboolean
+radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv )
+{
+ if ( driContextPriv ) {
+ radeonContextPtr newCtx =
+ (radeonContextPtr) driContextPriv->driverPrivate;
+
+ if (RADEON_DEBUG & DEBUG_DRI)
+ fprintf(stderr, "%s ctx %p\n", __FUNCTION__, (void *) newCtx->glCtx);
+
+ if ( newCtx->dri.drawable != driDrawPriv ) {
+ driDrawableInitVBlank( driDrawPriv, newCtx->vblank_flags );
+ newCtx->dri.drawable = driDrawPriv;
+ radeonUpdateWindow( newCtx->glCtx );
+ radeonUpdateViewportOffset( newCtx->glCtx );
+ }
+
+ _mesa_make_current( newCtx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
+
+ if (newCtx->vb.enabled)
+ radeonVtxfmtMakeCurrent( newCtx->glCtx );
+
+ } else {
+ if (RADEON_DEBUG & DEBUG_DRI)
+ fprintf(stderr, "%s ctx is null\n", __FUNCTION__);
+ _mesa_make_current( NULL, NULL, NULL );
+ }
+
+ if (RADEON_DEBUG & DEBUG_DRI)
+ fprintf(stderr, "End %s\n", __FUNCTION__);
+ return GL_TRUE;
+}
+
+/* Force the context `c' to be unbound from its buffer.
+ */
+GLboolean
+radeonUnbindContext( __DRIcontextPrivate *driContextPriv )
+{
+ radeonContextPtr rmesa = (radeonContextPtr) driContextPriv->driverPrivate;
+
+ if (RADEON_DEBUG & DEBUG_DRI)
+ fprintf(stderr, "%s ctx %p\n", __FUNCTION__, (void *) rmesa->glCtx);
+
+ return GL_TRUE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_context.h
new file mode 100644
index 000000000..621a4c655
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_context.h
@@ -0,0 +1,868 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_context.h,v 1.6 2002/12/16 16:18:58 dawes Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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 THE COPYRIGHT OWNER(S) 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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef __RADEON_CONTEXT_H__
+#define __RADEON_CONTEXT_H__
+
+#include "tnl/t_vertex.h"
+#include "dri_util.h"
+#include "drm.h"
+#include "radeon_drm.h"
+#include "texmem.h"
+
+#include "macros.h"
+#include "mtypes.h"
+#include "colormac.h"
+
+struct radeon_context;
+typedef struct radeon_context radeonContextRec;
+typedef struct radeon_context *radeonContextPtr;
+
+#include "radeon_lock.h"
+#include "radeon_screen.h"
+#include "mm.h"
+
+#include "math/m_vector.h"
+
+/* Flags for software fallback cases */
+/* See correponding strings in radeon_swtcl.c */
+#define RADEON_FALLBACK_TEXTURE 0x0001
+#define RADEON_FALLBACK_DRAW_BUFFER 0x0002
+#define RADEON_FALLBACK_STENCIL 0x0004
+#define RADEON_FALLBACK_RENDER_MODE 0x0008
+#define RADEON_FALLBACK_BLEND_EQ 0x0010
+#define RADEON_FALLBACK_BLEND_FUNC 0x0020
+#define RADEON_FALLBACK_DISABLE 0x0040
+#define RADEON_FALLBACK_BORDER_MODE 0x0080
+
+/* The blit width for texture uploads
+ */
+#define BLIT_WIDTH_BYTES 1024
+
+/* Use the templated vertex format:
+ */
+#define COLOR_IS_RGBA
+#define TAG(x) radeon##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+typedef void (*radeon_tri_func)( radeonContextPtr,
+ radeonVertex *,
+ radeonVertex *,
+ radeonVertex * );
+
+typedef void (*radeon_line_func)( radeonContextPtr,
+ radeonVertex *,
+ radeonVertex * );
+
+typedef void (*radeon_point_func)( radeonContextPtr,
+ radeonVertex * );
+
+
+struct radeon_colorbuffer_state {
+ GLuint clear;
+ GLint drawOffset, drawPitch;
+ int roundEnable;
+};
+
+
+struct radeon_depthbuffer_state {
+ GLuint clear;
+ GLfloat scale;
+};
+
+struct radeon_pixel_state {
+ GLint readOffset, readPitch;
+};
+
+struct radeon_scissor_state {
+ drm_clip_rect_t rect;
+ GLboolean enabled;
+
+ GLuint numClipRects; /* Cliprects active */
+ GLuint numAllocedClipRects; /* Cliprects available */
+ drm_clip_rect_t *pClipRects;
+};
+
+struct radeon_stencilbuffer_state {
+ GLboolean hwBuffer;
+ GLuint clear; /* rb3d_stencilrefmask value */
+};
+
+struct radeon_stipple_state {
+ GLuint mask[32];
+};
+
+
+
+#define TEX_0 0x1
+#define TEX_1 0x2
+#define TEX_ALL 0x3
+
+typedef struct radeon_tex_obj radeonTexObj, *radeonTexObjPtr;
+
+/* Texture object in locally shared texture space.
+ */
+struct radeon_tex_obj {
+ driTextureObject base;
+
+ GLuint bufAddr; /* Offset to start of locally
+ shared texture block */
+
+ GLuint dirty_state; /* Flags (1 per texunit) for
+ whether or not this texobj
+ has dirty hardware state
+ (pp_*) that needs to be
+ brought into the
+ texunit. */
+
+ drm_radeon_tex_image_t image[6][RADEON_MAX_TEXTURE_LEVELS];
+ /* Six, for the cube faces */
+
+ GLuint pp_txfilter; /* hardware register values */
+ GLuint pp_txformat;
+ GLuint pp_txoffset; /* Image location in texmem.
+ All cube faces follow. */
+ GLuint pp_txsize; /* npot only */
+ GLuint pp_txpitch; /* npot only */
+ GLuint pp_border_color;
+ GLuint pp_cubic_faces; /* cube face 1,2,3,4 log2 sizes */
+
+ GLboolean border_fallback;
+
+ GLuint tile_bits; /* hw texture tile bits used on this texture */
+};
+
+
+struct radeon_texture_env_state {
+ radeonTexObjPtr texobj;
+ GLenum format;
+ GLenum envMode;
+};
+
+struct radeon_texture_state {
+ struct radeon_texture_env_state unit[RADEON_MAX_TEXTURE_UNITS];
+};
+
+
+struct radeon_state_atom {
+ struct radeon_state_atom *next, *prev;
+ const char *name; /* for debug */
+ int cmd_size; /* size in bytes */
+ GLuint is_tcl;
+ int *cmd; /* one or more cmd's */
+ int *lastcmd; /* one or more cmd's */
+ GLboolean dirty; /* dirty-mark in emit_state_list */
+ GLboolean (*check)( GLcontext * ); /* is this state active? */
+};
+
+
+
+/* Trying to keep these relatively short as the variables are becoming
+ * extravagently long. Drop the driver name prefix off the front of
+ * everything - I think we know which driver we're in by now, and keep the
+ * prefix to 3 letters unless absolutely impossible.
+ */
+
+#define CTX_CMD_0 0
+#define CTX_PP_MISC 1
+#define CTX_PP_FOG_COLOR 2
+#define CTX_RE_SOLID_COLOR 3
+#define CTX_RB3D_BLENDCNTL 4
+#define CTX_RB3D_DEPTHOFFSET 5
+#define CTX_RB3D_DEPTHPITCH 6
+#define CTX_RB3D_ZSTENCILCNTL 7
+#define CTX_CMD_1 8
+#define CTX_PP_CNTL 9
+#define CTX_RB3D_CNTL 10
+#define CTX_RB3D_COLOROFFSET 11
+#define CTX_CMD_2 12
+#define CTX_RB3D_COLORPITCH 13
+#define CTX_STATE_SIZE 14
+
+#define SET_CMD_0 0
+#define SET_SE_CNTL 1
+#define SET_SE_COORDFMT 2
+#define SET_CMD_1 3
+#define SET_SE_CNTL_STATUS 4
+#define SET_STATE_SIZE 5
+
+#define LIN_CMD_0 0
+#define LIN_RE_LINE_PATTERN 1
+#define LIN_RE_LINE_STATE 2
+#define LIN_CMD_1 3
+#define LIN_SE_LINE_WIDTH 4
+#define LIN_STATE_SIZE 5
+
+#define MSK_CMD_0 0
+#define MSK_RB3D_STENCILREFMASK 1
+#define MSK_RB3D_ROPCNTL 2
+#define MSK_RB3D_PLANEMASK 3
+#define MSK_STATE_SIZE 4
+
+#define VPT_CMD_0 0
+#define VPT_SE_VPORT_XSCALE 1
+#define VPT_SE_VPORT_XOFFSET 2
+#define VPT_SE_VPORT_YSCALE 3
+#define VPT_SE_VPORT_YOFFSET 4
+#define VPT_SE_VPORT_ZSCALE 5
+#define VPT_SE_VPORT_ZOFFSET 6
+#define VPT_STATE_SIZE 7
+
+#define MSC_CMD_0 0
+#define MSC_RE_MISC 1
+#define MSC_STATE_SIZE 2
+
+#define TEX_CMD_0 0
+#define TEX_PP_TXFILTER 1
+#define TEX_PP_TXFORMAT 2
+#define TEX_PP_TXOFFSET 3
+#define TEX_PP_TXCBLEND 4
+#define TEX_PP_TXABLEND 5
+#define TEX_PP_TFACTOR 6
+#define TEX_CMD_1 7
+#define TEX_PP_BORDER_COLOR 8
+#define TEX_STATE_SIZE 9
+
+#define TXR_CMD_0 0 /* rectangle textures */
+#define TXR_PP_TEX_SIZE 1 /* 0x1d04, 0x1d0c for NPOT! */
+#define TXR_PP_TEX_PITCH 2 /* 0x1d08, 0x1d10 for NPOT! */
+#define TXR_STATE_SIZE 3
+
+#define ZBS_CMD_0 0
+#define ZBS_SE_ZBIAS_FACTOR 1
+#define ZBS_SE_ZBIAS_CONSTANT 2
+#define ZBS_STATE_SIZE 3
+
+#define TCL_CMD_0 0
+#define TCL_OUTPUT_VTXFMT 1
+#define TCL_OUTPUT_VTXSEL 2
+#define TCL_MATRIX_SELECT_0 3
+#define TCL_MATRIX_SELECT_1 4
+#define TCL_UCP_VERT_BLEND_CTL 5
+#define TCL_TEXTURE_PROC_CTL 6
+#define TCL_LIGHT_MODEL_CTL 7
+#define TCL_PER_LIGHT_CTL_0 8
+#define TCL_PER_LIGHT_CTL_1 9
+#define TCL_PER_LIGHT_CTL_2 10
+#define TCL_PER_LIGHT_CTL_3 11
+#define TCL_STATE_SIZE 12
+
+#define MTL_CMD_0 0
+#define MTL_EMMISSIVE_RED 1
+#define MTL_EMMISSIVE_GREEN 2
+#define MTL_EMMISSIVE_BLUE 3
+#define MTL_EMMISSIVE_ALPHA 4
+#define MTL_AMBIENT_RED 5
+#define MTL_AMBIENT_GREEN 6
+#define MTL_AMBIENT_BLUE 7
+#define MTL_AMBIENT_ALPHA 8
+#define MTL_DIFFUSE_RED 9
+#define MTL_DIFFUSE_GREEN 10
+#define MTL_DIFFUSE_BLUE 11
+#define MTL_DIFFUSE_ALPHA 12
+#define MTL_SPECULAR_RED 13
+#define MTL_SPECULAR_GREEN 14
+#define MTL_SPECULAR_BLUE 15
+#define MTL_SPECULAR_ALPHA 16
+#define MTL_SHININESS 17
+#define MTL_STATE_SIZE 18
+
+#define VTX_CMD_0 0
+#define VTX_SE_COORD_FMT 1
+#define VTX_STATE_SIZE 2
+
+#define MAT_CMD_0 0
+#define MAT_ELT_0 1
+#define MAT_STATE_SIZE 17
+
+#define GRD_CMD_0 0
+#define GRD_VERT_GUARD_CLIP_ADJ 1
+#define GRD_VERT_GUARD_DISCARD_ADJ 2
+#define GRD_HORZ_GUARD_CLIP_ADJ 3
+#define GRD_HORZ_GUARD_DISCARD_ADJ 4
+#define GRD_STATE_SIZE 5
+
+/* position changes frequently when lighting in modelpos - separate
+ * out to new state item?
+ */
+#define LIT_CMD_0 0
+#define LIT_AMBIENT_RED 1
+#define LIT_AMBIENT_GREEN 2
+#define LIT_AMBIENT_BLUE 3
+#define LIT_AMBIENT_ALPHA 4
+#define LIT_DIFFUSE_RED 5
+#define LIT_DIFFUSE_GREEN 6
+#define LIT_DIFFUSE_BLUE 7
+#define LIT_DIFFUSE_ALPHA 8
+#define LIT_SPECULAR_RED 9
+#define LIT_SPECULAR_GREEN 10
+#define LIT_SPECULAR_BLUE 11
+#define LIT_SPECULAR_ALPHA 12
+#define LIT_POSITION_X 13
+#define LIT_POSITION_Y 14
+#define LIT_POSITION_Z 15
+#define LIT_POSITION_W 16
+#define LIT_DIRECTION_X 17
+#define LIT_DIRECTION_Y 18
+#define LIT_DIRECTION_Z 19
+#define LIT_DIRECTION_W 20
+#define LIT_ATTEN_QUADRATIC 21
+#define LIT_ATTEN_LINEAR 22
+#define LIT_ATTEN_CONST 23
+#define LIT_ATTEN_XXX 24
+#define LIT_CMD_1 25
+#define LIT_SPOT_DCD 26
+#define LIT_SPOT_EXPONENT 27
+#define LIT_SPOT_CUTOFF 28
+#define LIT_SPECULAR_THRESH 29
+#define LIT_RANGE_CUTOFF 30 /* ? */
+#define LIT_ATTEN_CONST_INV 31
+#define LIT_STATE_SIZE 32
+
+/* Fog
+ */
+#define FOG_CMD_0 0
+#define FOG_R 1
+#define FOG_C 2
+#define FOG_D 3
+#define FOG_PAD 4
+#define FOG_STATE_SIZE 5
+
+/* UCP
+ */
+#define UCP_CMD_0 0
+#define UCP_X 1
+#define UCP_Y 2
+#define UCP_Z 3
+#define UCP_W 4
+#define UCP_STATE_SIZE 5
+
+/* GLT - Global ambient
+ */
+#define GLT_CMD_0 0
+#define GLT_RED 1
+#define GLT_GREEN 2
+#define GLT_BLUE 3
+#define GLT_ALPHA 4
+#define GLT_STATE_SIZE 5
+
+/* EYE
+ */
+#define EYE_CMD_0 0
+#define EYE_X 1
+#define EYE_Y 2
+#define EYE_Z 3
+#define EYE_RESCALE_FACTOR 4
+#define EYE_STATE_SIZE 5
+
+#define SHN_CMD_0 0
+#define SHN_SHININESS 1
+#define SHN_STATE_SIZE 2
+
+
+
+
+
+struct radeon_hw_state {
+ /* Head of the linked list of state atoms. */
+ struct radeon_state_atom atomlist;
+
+ /* Hardware state, stored as cmdbuf commands:
+ * -- Need to doublebuffer for
+ * - eliding noop statechange loops? (except line stipple count)
+ */
+ struct radeon_state_atom ctx;
+ struct radeon_state_atom set;
+ struct radeon_state_atom lin;
+ struct radeon_state_atom msk;
+ struct radeon_state_atom vpt;
+ struct radeon_state_atom tcl;
+ struct radeon_state_atom msc;
+ struct radeon_state_atom tex[2];
+ struct radeon_state_atom zbs;
+ struct radeon_state_atom mtl;
+ struct radeon_state_atom mat[5];
+ struct radeon_state_atom lit[8]; /* includes vec, scl commands */
+ struct radeon_state_atom ucp[6];
+ struct radeon_state_atom eye; /* eye pos */
+ struct radeon_state_atom grd; /* guard band clipping */
+ struct radeon_state_atom fog;
+ struct radeon_state_atom glt;
+ struct radeon_state_atom txr[2]; /* for NPOT */
+
+ int max_state_size; /* Number of bytes necessary for a full state emit. */
+ GLboolean is_dirty, all_dirty;
+};
+
+struct radeon_state {
+ /* Derived state for internal purposes:
+ */
+ struct radeon_colorbuffer_state color;
+ struct radeon_depthbuffer_state depth;
+ struct radeon_pixel_state pixel;
+ struct radeon_scissor_state scissor;
+ struct radeon_stencilbuffer_state stencil;
+ struct radeon_stipple_state stipple;
+ struct radeon_texture_state texture;
+};
+
+
+/* Need refcounting on dma buffers:
+ */
+struct radeon_dma_buffer {
+ int refcount; /* the number of retained regions in buf */
+ drmBufPtr buf;
+};
+
+#define GET_START(rvb) (rmesa->radeonScreen->gart_buffer_offset + \
+ (rvb)->address - rmesa->dma.buf0_address + \
+ (rvb)->start)
+
+/* A retained region, eg vertices for indexed vertices.
+ */
+struct radeon_dma_region {
+ struct radeon_dma_buffer *buf;
+ char *address; /* == buf->address */
+ int start, end, ptr; /* offsets from start of buf */
+ int aos_start;
+ int aos_stride;
+ int aos_size;
+};
+
+
+struct radeon_dma {
+ /* Active dma region. Allocations for vertices and retained
+ * regions come from here. Also used for emitting random vertices,
+ * these may be flushed by calling flush_current();
+ */
+ struct radeon_dma_region current;
+
+ void (*flush)( radeonContextPtr );
+
+ char *buf0_address; /* start of buf[0], for index calcs */
+ GLuint nr_released_bufs; /* flush after so many buffers released */
+};
+
+struct radeon_dri_mirror {
+ __DRIcontextPrivate *context; /* DRI context */
+ __DRIscreenPrivate *screen; /* DRI screen */
+ __DRIdrawablePrivate *drawable; /* DRI drawable bound to this ctx */
+
+ drm_context_t hwContext;
+ drm_hw_lock_t *hwLock;
+ int fd;
+ int drmMinor;
+};
+
+
+#define RADEON_CMD_BUF_SZ (8*1024)
+
+struct radeon_store {
+ GLuint statenr;
+ GLuint primnr;
+ char cmd_buf[RADEON_CMD_BUF_SZ];
+ int cmd_used;
+ int elts_start;
+};
+
+
+/* radeon_tcl.c
+ */
+struct radeon_tcl_info {
+ GLuint vertex_format;
+ GLint last_offset;
+ GLuint hw_primitive;
+
+ /* Temporary for cases where incoming vertex data is incompatible
+ * with maos code.
+ */
+ GLvector4f ObjClean;
+
+ struct radeon_dma_region *aos_components[8];
+ GLuint nr_aos_components;
+
+ GLuint *Elts;
+
+ struct radeon_dma_region indexed_verts;
+ struct radeon_dma_region obj;
+ struct radeon_dma_region rgba;
+ struct radeon_dma_region spec;
+ struct radeon_dma_region fog;
+ struct radeon_dma_region tex[RADEON_MAX_TEXTURE_UNITS];
+ struct radeon_dma_region norm;
+};
+
+
+/* radeon_swtcl.c
+ */
+struct radeon_swtcl_info {
+ GLuint RenderIndex;
+ GLuint vertex_size;
+ GLuint vertex_format;
+
+ struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
+ GLuint vertex_attr_count;
+
+ GLubyte *verts;
+
+ /* Fallback rasterization functions
+ */
+ radeon_point_func draw_point;
+ radeon_line_func draw_line;
+ radeon_tri_func draw_tri;
+
+ GLuint hw_primitive;
+ GLenum render_primitive;
+ GLuint numverts;
+
+ /**
+ * Offset of the 4UB color data within a hardware (swtcl) vertex.
+ */
+ GLuint coloroffset;
+
+ /**
+ * Offset of the 3UB specular color data within a hardware (swtcl) vertex.
+ */
+ GLuint specoffset;
+
+ GLboolean needproj;
+
+ struct radeon_dma_region indexed_verts;
+};
+
+
+struct radeon_ioctl {
+ GLuint vertex_offset;
+ GLuint vertex_size;
+};
+
+
+
+#define RADEON_MAX_PRIMS 64
+
+
+/* Want to keep a cache of these around. Each is parameterized by
+ * only a single value which has only a small range. Only expect a
+ * few, so just rescan the list each time?
+ */
+struct dynfn {
+ struct dynfn *next, *prev;
+ int key;
+ char *code;
+};
+
+struct dfn_lists {
+ struct dynfn Vertex2f;
+ struct dynfn Vertex2fv;
+ struct dynfn Vertex3f;
+ struct dynfn Vertex3fv;
+ struct dynfn Color4ub;
+ struct dynfn Color4ubv;
+ struct dynfn Color3ub;
+ struct dynfn Color3ubv;
+ struct dynfn Color4f;
+ struct dynfn Color4fv;
+ struct dynfn Color3f;
+ struct dynfn Color3fv;
+ struct dynfn SecondaryColor3ubEXT;
+ struct dynfn SecondaryColor3ubvEXT;
+ struct dynfn SecondaryColor3fEXT;
+ struct dynfn SecondaryColor3fvEXT;
+ struct dynfn Normal3f;
+ struct dynfn Normal3fv;
+ struct dynfn TexCoord2f;
+ struct dynfn TexCoord2fv;
+ struct dynfn TexCoord1f;
+ struct dynfn TexCoord1fv;
+ struct dynfn MultiTexCoord2fARB;
+ struct dynfn MultiTexCoord2fvARB;
+ struct dynfn MultiTexCoord1fARB;
+ struct dynfn MultiTexCoord1fvARB;
+};
+
+struct dfn_generators {
+ struct dynfn *(*Vertex2f)( GLcontext *, int );
+ struct dynfn *(*Vertex2fv)( GLcontext *, int );
+ struct dynfn *(*Vertex3f)( GLcontext *, int );
+ struct dynfn *(*Vertex3fv)( GLcontext *, int );
+ struct dynfn *(*Color4ub)( GLcontext *, int );
+ struct dynfn *(*Color4ubv)( GLcontext *, int );
+ struct dynfn *(*Color3ub)( GLcontext *, int );
+ struct dynfn *(*Color3ubv)( GLcontext *, int );
+ struct dynfn *(*Color4f)( GLcontext *, int );
+ struct dynfn *(*Color4fv)( GLcontext *, int );
+ struct dynfn *(*Color3f)( GLcontext *, int );
+ struct dynfn *(*Color3fv)( GLcontext *, int );
+ struct dynfn *(*SecondaryColor3ubEXT)( GLcontext *, int );
+ struct dynfn *(*SecondaryColor3ubvEXT)( GLcontext *, int );
+ struct dynfn *(*SecondaryColor3fEXT)( GLcontext *, int );
+ struct dynfn *(*SecondaryColor3fvEXT)( GLcontext *, int );
+ struct dynfn *(*Normal3f)( GLcontext *, int );
+ struct dynfn *(*Normal3fv)( GLcontext *, int );
+ struct dynfn *(*TexCoord2f)( GLcontext *, int );
+ struct dynfn *(*TexCoord2fv)( GLcontext *, int );
+ struct dynfn *(*TexCoord1f)( GLcontext *, int );
+ struct dynfn *(*TexCoord1fv)( GLcontext *, int );
+ struct dynfn *(*MultiTexCoord2fARB)( GLcontext *, int );
+ struct dynfn *(*MultiTexCoord2fvARB)( GLcontext *, int );
+ struct dynfn *(*MultiTexCoord1fARB)( GLcontext *, int );
+ struct dynfn *(*MultiTexCoord1fvARB)( GLcontext *, int );
+};
+
+
+
+struct radeon_prim {
+ GLuint start;
+ GLuint end;
+ GLuint prim;
+};
+
+struct radeon_vbinfo {
+ GLint counter, initial_counter;
+ GLint *dmaptr;
+ void (*notify)( void );
+ GLint vertex_size;
+
+ /* A maximum total of 15 elements per vertex: 3 floats for position, 3
+ * floats for normal, 4 floats for color, 4 bytes for secondary color,
+ * 2 floats for each texture unit (4 floats total).
+ *
+ * As soon as the 3rd TMU is supported or cube maps (or 3D textures) are
+ * supported, this value will grow.
+ *
+ * The position data is never actually stored here, so 3 elements could be
+ * trimmed out of the buffer.
+ */
+ union { float f; int i; radeon_color_t color; } vertex[15];
+
+ GLfloat *normalptr;
+ GLfloat *floatcolorptr;
+ radeon_color_t *colorptr;
+ GLfloat *floatspecptr;
+ radeon_color_t *specptr;
+ GLfloat *texcoordptr[2];
+
+ GLenum *prim; /* &ctx->Driver.CurrentExecPrimitive */
+ GLuint primflags;
+ GLboolean enabled; /* *_NO_VTXFMT / *_NO_TCL env vars */
+ GLboolean installed;
+ GLboolean fell_back;
+ GLboolean recheck;
+ GLint nrverts;
+ GLuint vertex_format;
+
+ GLuint installed_vertex_format;
+ GLuint installed_color_3f_sz;
+
+ struct radeon_prim primlist[RADEON_MAX_PRIMS];
+ int nrprims;
+
+ struct dfn_lists dfn_cache;
+ struct dfn_generators codegen;
+ GLvertexformat vtxfmt;
+};
+
+
+
+
+struct radeon_context {
+ GLcontext *glCtx; /* Mesa context */
+
+ /* Driver and hardware state management
+ */
+ struct radeon_hw_state hw;
+ struct radeon_state state;
+
+ /* Texture object bookkeeping
+ */
+ unsigned nr_heaps;
+ driTexHeap * texture_heaps[ RADEON_NR_TEX_HEAPS ];
+ driTextureObject swapped;
+ int texture_depth;
+ float initialMaxAnisotropy;
+
+ /* Rasterization and vertex state:
+ */
+ GLuint TclFallback;
+ GLuint Fallback;
+ GLuint NewGLState;
+ GLuint tnl_index; /* index of bits for last tnl_install_attrs */
+
+ /* Vertex buffers
+ */
+ struct radeon_ioctl ioctl;
+ struct radeon_dma dma;
+ struct radeon_store store;
+ /* A full state emit as of the first state emit in the main store, in case
+ * the context is lost.
+ */
+ struct radeon_store backup_store;
+
+ /* Page flipping
+ */
+ GLuint doPageFlip;
+
+ /* Busy waiting
+ */
+ GLuint do_usleeps;
+ GLuint do_irqs;
+ GLuint irqsEmitted;
+ drm_radeon_irq_wait_t iw;
+
+ /* Drawable, cliprect and scissor information
+ */
+ GLuint numClipRects; /* Cliprects for the draw buffer */
+ drm_clip_rect_t *pClipRects;
+ unsigned int lastStamp;
+ GLboolean lost_context;
+ GLboolean save_on_next_emit;
+ radeonScreenPtr radeonScreen; /* Screen private DRI data */
+ drm_radeon_sarea_t *sarea; /* Private SAREA data */
+
+ /* TCL stuff
+ */
+ GLmatrix TexGenMatrix[RADEON_MAX_TEXTURE_UNITS];
+ GLboolean recheck_texgen[RADEON_MAX_TEXTURE_UNITS];
+ GLboolean TexGenNeedNormals[RADEON_MAX_TEXTURE_UNITS];
+ GLuint TexMatEnabled;
+ GLuint TexGenEnabled;
+ GLmatrix tmpmat;
+ GLuint last_ReallyEnabled;
+
+ /* VBI
+ */
+ GLuint vbl_seq;
+ GLuint vblank_flags;
+
+ int64_t swap_ust;
+ int64_t swap_missed_ust;
+
+ GLuint swap_count;
+ GLuint swap_missed_count;
+
+
+ /* radeon_tcl.c
+ */
+ struct radeon_tcl_info tcl;
+
+ /* radeon_swtcl.c
+ */
+ struct radeon_swtcl_info swtcl;
+
+ /* radeon_vtxfmt.c
+ */
+ struct radeon_vbinfo vb;
+
+ /* Mirrors of some DRI state
+ */
+ struct radeon_dri_mirror dri;
+
+ /* Configuration cache
+ */
+ driOptionCache optionCache;
+
+ GLboolean using_hyperz;
+ GLboolean texmicrotile;
+
+ /* Performance counters
+ */
+ GLuint boxes; /* Draw performance boxes */
+ GLuint hardwareWentIdle;
+ GLuint c_clears;
+ GLuint c_drawWaits;
+ GLuint c_textureSwaps;
+ GLuint c_textureBytes;
+ GLuint c_vertexBuffers;
+};
+
+#define RADEON_CONTEXT(ctx) ((radeonContextPtr)(ctx->DriverCtx))
+
+
+static __inline GLuint radeonPackColor( GLuint cpp,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a )
+{
+ switch ( cpp ) {
+ case 2:
+ return PACK_COLOR_565( r, g, b );
+ case 4:
+ return PACK_COLOR_8888( a, r, g, b );
+ default:
+ return 0;
+ }
+}
+
+#define RADEON_OLD_PACKETS 1
+
+
+extern void radeonDestroyContext( __DRIcontextPrivate *driContextPriv );
+extern GLboolean radeonCreateContext(const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate);
+extern void radeonSwapBuffers( __DRIdrawablePrivate *dPriv );
+extern GLboolean radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv );
+extern GLboolean radeonUnbindContext( __DRIcontextPrivate *driContextPriv );
+
+/* ================================================================
+ * Debugging:
+ */
+#define DO_DEBUG 1
+
+#if DO_DEBUG
+extern int RADEON_DEBUG;
+#else
+#define RADEON_DEBUG 0
+#endif
+
+#define DEBUG_TEXTURE 0x001
+#define DEBUG_STATE 0x002
+#define DEBUG_IOCTL 0x004
+#define DEBUG_PRIMS 0x008
+#define DEBUG_VERTS 0x010
+#define DEBUG_FALLBACKS 0x020
+#define DEBUG_VFMT 0x040
+#define DEBUG_CODEGEN 0x080
+#define DEBUG_VERBOSE 0x100
+#define DEBUG_DRI 0x200
+#define DEBUG_DMA 0x400
+#define DEBUG_SANITY 0x800
+#define DEBUG_SYNC 0x1000
+
+#endif /* __RADEON_CONTEXT_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_ioctl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_ioctl.c
new file mode 100644
index 000000000..53c5d5ca5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_ioctl.c
@@ -0,0 +1,1283 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_ioctl.c,v 1.11 2003/01/29 22:04:59 dawes Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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 THE COPYRIGHT OWNER(S) 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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include <sched.h>
+#include <errno.h>
+
+#include "glheader.h"
+#include "imports.h"
+#include "simple_list.h"
+#include "swrast/swrast.h"
+
+#include "radeon_context.h"
+#include "radeon_state.h"
+#include "radeon_ioctl.h"
+#include "radeon_tcl.h"
+#include "radeon_sanity.h"
+
+#define STANDALONE_MMIO
+#include "radeon_macros.h" /* for INREG() */
+
+#include "vblank.h"
+
+#define RADEON_TIMEOUT 512
+#define RADEON_IDLE_RETRY 16
+
+
+static void radeonWaitForIdle( radeonContextPtr rmesa );
+static int radeonFlushCmdBufLocked( radeonContextPtr rmesa,
+ const char * caller );
+
+static void print_state_atom( struct radeon_state_atom *state )
+{
+ int i;
+
+ fprintf(stderr, "emit %s/%d\n", state->name, state->cmd_size);
+
+ if (RADEON_DEBUG & DEBUG_VERBOSE)
+ for (i = 0 ; i < state->cmd_size ; i++)
+ fprintf(stderr, "\t%s[%d]: %x\n", state->name, i, state->cmd[i]);
+
+}
+
+static void radeonSaveHwState( radeonContextPtr rmesa )
+{
+ struct radeon_state_atom *atom;
+ char * dest = rmesa->backup_store.cmd_buf;
+
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ rmesa->backup_store.cmd_used = 0;
+
+ foreach( atom, &rmesa->hw.atomlist ) {
+ if ( atom->check( rmesa->glCtx ) ) {
+ int size = atom->cmd_size * 4;
+ memcpy( dest, atom->cmd, size);
+ dest += size;
+ rmesa->backup_store.cmd_used += size;
+ if (RADEON_DEBUG & DEBUG_STATE)
+ print_state_atom( atom );
+ }
+ }
+
+ assert( rmesa->backup_store.cmd_used <= RADEON_CMD_BUF_SZ );
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "Returning to radeonEmitState\n");
+}
+
+/* At this point we were in FlushCmdBufLocked but we had lost our context, so
+ * we need to unwire our current cmdbuf, hook the one with the saved state in
+ * it, flush it, and then put the current one back. This is so commands at the
+ * start of a cmdbuf can rely on the state being kept from the previous one.
+ */
+static void radeonBackUpAndEmitLostStateLocked( radeonContextPtr rmesa )
+{
+ GLuint nr_released_bufs;
+ struct radeon_store saved_store;
+
+ if (rmesa->backup_store.cmd_used == 0)
+ return;
+
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "Emitting backup state on lost context\n");
+
+ rmesa->lost_context = GL_FALSE;
+
+ nr_released_bufs = rmesa->dma.nr_released_bufs;
+ saved_store = rmesa->store;
+ rmesa->dma.nr_released_bufs = 0;
+ rmesa->store = rmesa->backup_store;
+ radeonFlushCmdBufLocked( rmesa, __FUNCTION__ );
+ rmesa->dma.nr_released_bufs = nr_released_bufs;
+ rmesa->store = saved_store;
+}
+
+/* =============================================================
+ * Kernel command buffer handling
+ */
+
+/* The state atoms will be emitted in the order they appear in the atom list,
+ * so this step is important.
+ */
+void radeonSetUpAtomList( radeonContextPtr rmesa )
+{
+ int i, mtu = rmesa->glCtx->Const.MaxTextureUnits;
+
+ make_empty_list(&rmesa->hw.atomlist);
+ rmesa->hw.atomlist.name = "atom-list";
+
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.ctx);
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.set);
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.lin);
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.msk);
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.vpt);
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.tcl);
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.msc);
+ for (i = 0; i < mtu; ++i) {
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.tex[i]);
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.txr[i]);
+ }
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.zbs);
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.mtl);
+ for (i = 0; i < 3 + mtu; ++i)
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.mat[i]);
+ for (i = 0; i < 8; ++i)
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.lit[i]);
+ for (i = 0; i < 6; ++i)
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.ucp[i]);
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.eye);
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.grd);
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.fog);
+ insert_at_tail(&rmesa->hw.atomlist, &rmesa->hw.glt);
+}
+
+void radeonEmitState( radeonContextPtr rmesa )
+{
+ struct radeon_state_atom *atom;
+ char *dest;
+
+ if (RADEON_DEBUG & (DEBUG_STATE|DEBUG_PRIMS))
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (rmesa->save_on_next_emit) {
+ radeonSaveHwState(rmesa);
+ rmesa->save_on_next_emit = GL_FALSE;
+ }
+
+ /* this code used to return here but now it emits zbs */
+
+ /* To avoid going across the entire set of states multiple times, just check
+ * for enough space for the case of emitting all state, and inline the
+ * radeonAllocCmdBuf code here without all the checks.
+ */
+ radeonEnsureCmdBufSpace(rmesa, rmesa->hw.max_state_size);
+ dest = rmesa->store.cmd_buf + rmesa->store.cmd_used;
+
+ /* We always always emit zbs, this is due to a bug found by keithw in
+ the hardware and rediscovered after Erics changes by me.
+ if you ever touch this code make sure you emit zbs otherwise
+ you get tcl lockups on at least M7/7500 class of chips - airlied */
+ rmesa->hw.zbs.dirty=1;
+
+ if (RADEON_DEBUG & DEBUG_STATE) {
+ foreach(atom, &rmesa->hw.atomlist) {
+ if (atom->dirty || rmesa->hw.all_dirty) {
+ if (atom->check(rmesa->glCtx))
+ print_state_atom(atom);
+ else
+ fprintf(stderr, "skip state %s\n", atom->name);
+ }
+ }
+ }
+
+ foreach(atom, &rmesa->hw.atomlist) {
+ if (rmesa->hw.all_dirty)
+ atom->dirty = GL_TRUE;
+ if (!(rmesa->radeonScreen->chipset & RADEON_CHIPSET_TCL) &&
+ atom->is_tcl)
+ atom->dirty = GL_FALSE;
+ if (atom->dirty) {
+ if (atom->check(rmesa->glCtx)) {
+ int size = atom->cmd_size * 4;
+ memcpy(dest, atom->cmd, size);
+ dest += size;
+ rmesa->store.cmd_used += size;
+ atom->dirty = GL_FALSE;
+ }
+ }
+ }
+
+ assert(rmesa->store.cmd_used <= RADEON_CMD_BUF_SZ);
+
+ rmesa->hw.is_dirty = GL_FALSE;
+ rmesa->hw.all_dirty = GL_FALSE;
+}
+
+/* Fire a section of the retained (indexed_verts) buffer as a regular
+ * primtive.
+ */
+extern void radeonEmitVbufPrim( radeonContextPtr rmesa,
+ GLuint vertex_format,
+ GLuint primitive,
+ GLuint vertex_nr )
+{
+ drm_radeon_cmd_header_t *cmd;
+
+
+ assert(!(primitive & RADEON_CP_VC_CNTL_PRIM_WALK_IND));
+
+ radeonEmitState( rmesa );
+
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s cmd_used/4: %d\n", __FUNCTION__,
+ rmesa->store.cmd_used/4);
+
+ cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, VBUF_BUFSZ,
+ __FUNCTION__ );
+#if RADEON_OLD_PACKETS
+ cmd[0].i = 0;
+ cmd[0].header.cmd_type = RADEON_CMD_PACKET3_CLIP;
+ cmd[1].i = RADEON_CP_PACKET3_3D_RNDR_GEN_INDX_PRIM | (3 << 16);
+ cmd[2].i = rmesa->ioctl.vertex_offset;
+ cmd[3].i = vertex_nr;
+ cmd[4].i = vertex_format;
+ cmd[5].i = (primitive |
+ RADEON_CP_VC_CNTL_PRIM_WALK_LIST |
+ RADEON_CP_VC_CNTL_COLOR_ORDER_RGBA |
+ RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE |
+ (vertex_nr << RADEON_CP_VC_CNTL_NUM_SHIFT));
+
+ if (RADEON_DEBUG & DEBUG_PRIMS)
+ fprintf(stderr, "%s: header 0x%x offt 0x%x vfmt 0x%x vfcntl %x \n",
+ __FUNCTION__,
+ cmd[1].i, cmd[2].i, cmd[4].i, cmd[5].i);
+#else
+ cmd[0].i = 0;
+ cmd[0].header.cmd_type = RADEON_CMD_PACKET3_CLIP;
+ cmd[1].i = RADEON_CP_PACKET3_3D_DRAW_VBUF | (1 << 16);
+ cmd[2].i = vertex_format;
+ cmd[3].i = (primitive |
+ RADEON_CP_VC_CNTL_PRIM_WALK_LIST |
+ RADEON_CP_VC_CNTL_COLOR_ORDER_RGBA |
+ RADEON_CP_VC_CNTL_MAOS_ENABLE |
+ RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE |
+ (vertex_nr << RADEON_CP_VC_CNTL_NUM_SHIFT));
+
+
+ if (RADEON_DEBUG & DEBUG_PRIMS)
+ fprintf(stderr, "%s: header 0x%x vfmt 0x%x vfcntl %x \n",
+ __FUNCTION__,
+ cmd[1].i, cmd[2].i, cmd[3].i);
+#endif
+}
+
+
+void radeonFlushElts( radeonContextPtr rmesa )
+{
+ int *cmd = (int *)(rmesa->store.cmd_buf + rmesa->store.elts_start);
+ int dwords;
+#if RADEON_OLD_PACKETS
+ int nr = (rmesa->store.cmd_used - (rmesa->store.elts_start + 24)) / 2;
+#else
+ int nr = (rmesa->store.cmd_used - (rmesa->store.elts_start + 16)) / 2;
+#endif
+
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ assert( rmesa->dma.flush == radeonFlushElts );
+ rmesa->dma.flush = NULL;
+
+ /* Cope with odd number of elts:
+ */
+ rmesa->store.cmd_used = (rmesa->store.cmd_used + 2) & ~2;
+ dwords = (rmesa->store.cmd_used - rmesa->store.elts_start) / 4;
+
+#if RADEON_OLD_PACKETS
+ cmd[1] |= (dwords - 3) << 16;
+ cmd[5] |= nr << RADEON_CP_VC_CNTL_NUM_SHIFT;
+#else
+ cmd[1] |= (dwords - 3) << 16;
+ cmd[3] |= nr << RADEON_CP_VC_CNTL_NUM_SHIFT;
+#endif
+
+ if (RADEON_DEBUG & DEBUG_SYNC) {
+ fprintf(stderr, "%s: Syncing\n", __FUNCTION__);
+ radeonFinish( rmesa->glCtx );
+ }
+}
+
+
+GLushort *radeonAllocEltsOpenEnded( radeonContextPtr rmesa,
+ GLuint vertex_format,
+ GLuint primitive,
+ GLuint min_nr )
+{
+ drm_radeon_cmd_header_t *cmd;
+ GLushort *retval;
+
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s %d\n", __FUNCTION__, min_nr);
+
+ assert((primitive & RADEON_CP_VC_CNTL_PRIM_WALK_IND));
+
+ radeonEmitState( rmesa );
+
+ cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa,
+ ELTS_BUFSZ(min_nr),
+ __FUNCTION__ );
+#if RADEON_OLD_PACKETS
+ cmd[0].i = 0;
+ cmd[0].header.cmd_type = RADEON_CMD_PACKET3_CLIP;
+ cmd[1].i = RADEON_CP_PACKET3_3D_RNDR_GEN_INDX_PRIM;
+ cmd[2].i = rmesa->ioctl.vertex_offset;
+ cmd[3].i = 0xffff;
+ cmd[4].i = vertex_format;
+ cmd[5].i = (primitive |
+ RADEON_CP_VC_CNTL_PRIM_WALK_IND |
+ RADEON_CP_VC_CNTL_COLOR_ORDER_RGBA |
+ RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE);
+
+ retval = (GLushort *)(cmd+6);
+#else
+ cmd[0].i = 0;
+ cmd[0].header.cmd_type = RADEON_CMD_PACKET3_CLIP;
+ cmd[1].i = RADEON_CP_PACKET3_3D_DRAW_INDX;
+ cmd[2].i = vertex_format;
+ cmd[3].i = (primitive |
+ RADEON_CP_VC_CNTL_PRIM_WALK_IND |
+ RADEON_CP_VC_CNTL_COLOR_ORDER_RGBA |
+ RADEON_CP_VC_CNTL_MAOS_ENABLE |
+ RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE);
+
+ retval = (GLushort *)(cmd+4);
+#endif
+
+ if (RADEON_DEBUG & DEBUG_PRIMS)
+ fprintf(stderr, "%s: header 0x%x vfmt 0x%x prim %x \n",
+ __FUNCTION__,
+ cmd[1].i, vertex_format, primitive);
+
+ assert(!rmesa->dma.flush);
+ rmesa->glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
+ rmesa->dma.flush = radeonFlushElts;
+
+ rmesa->store.elts_start = ((char *)cmd) - rmesa->store.cmd_buf;
+
+ return retval;
+}
+
+
+
+void radeonEmitVertexAOS( radeonContextPtr rmesa,
+ GLuint vertex_size,
+ GLuint offset )
+{
+#if RADEON_OLD_PACKETS
+ rmesa->ioctl.vertex_size = vertex_size;
+ rmesa->ioctl.vertex_offset = offset;
+#else
+ drm_radeon_cmd_header_t *cmd;
+
+ if (RADEON_DEBUG & (DEBUG_PRIMS|DEBUG_IOCTL))
+ fprintf(stderr, "%s: vertex_size 0x%x offset 0x%x \n",
+ __FUNCTION__, vertex_size, offset);
+
+ cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, VERT_AOS_BUFSZ,
+ __FUNCTION__ );
+
+ cmd[0].i = 0;
+ cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
+ cmd[1].i = RADEON_CP_PACKET3_3D_LOAD_VBPNTR | (2 << 16);
+ cmd[2].i = 1;
+ cmd[3].i = vertex_size | (vertex_size << 8);
+ cmd[4].i = offset;
+#endif
+}
+
+
+void radeonEmitAOS( radeonContextPtr rmesa,
+ struct radeon_dma_region **component,
+ GLuint nr,
+ GLuint offset )
+{
+#if RADEON_OLD_PACKETS
+ assert( nr == 1 );
+ assert( component[0]->aos_size == component[0]->aos_stride );
+ rmesa->ioctl.vertex_size = component[0]->aos_size;
+ rmesa->ioctl.vertex_offset =
+ (component[0]->aos_start + offset * component[0]->aos_stride * 4);
+#else
+ drm_radeon_cmd_header_t *cmd;
+ int sz = AOS_BUFSZ(nr);
+ int i;
+ int *tmp;
+
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+
+ cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, sz,
+ __FUNCTION__ );
+ cmd[0].i = 0;
+ cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
+ cmd[1].i = RADEON_CP_PACKET3_3D_LOAD_VBPNTR | (((sz / sizeof(int))-3) << 16);
+ cmd[2].i = nr;
+ tmp = &cmd[0].i;
+ cmd += 3;
+
+ for (i = 0 ; i < nr ; i++) {
+ if (i & 1) {
+ cmd[0].i |= ((component[i]->aos_stride << 24) |
+ (component[i]->aos_size << 16));
+ cmd[2].i = (component[i]->aos_start +
+ offset * component[i]->aos_stride * 4);
+ cmd += 3;
+ }
+ else {
+ cmd[0].i = ((component[i]->aos_stride << 8) |
+ (component[i]->aos_size << 0));
+ cmd[1].i = (component[i]->aos_start +
+ offset * component[i]->aos_stride * 4);
+ }
+ }
+
+ if (RADEON_DEBUG & DEBUG_VERTS) {
+ fprintf(stderr, "%s:\n", __FUNCTION__);
+ for (i = 0 ; i < sz ; i++)
+ fprintf(stderr, " %d: %x\n", i, tmp[i]);
+ }
+#endif
+}
+
+/* using already shifted color_fmt! */
+void radeonEmitBlit( radeonContextPtr rmesa, /* FIXME: which drmMinor is required? */
+ GLuint color_fmt,
+ GLuint src_pitch,
+ GLuint src_offset,
+ GLuint dst_pitch,
+ GLuint dst_offset,
+ GLint srcx, GLint srcy,
+ GLint dstx, GLint dsty,
+ GLuint w, GLuint h )
+{
+ drm_radeon_cmd_header_t *cmd;
+
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s src %x/%x %d,%d dst: %x/%x %d,%d sz: %dx%d\n",
+ __FUNCTION__,
+ src_pitch, src_offset, srcx, srcy,
+ dst_pitch, dst_offset, dstx, dsty,
+ w, h);
+
+ assert( (src_pitch & 63) == 0 );
+ assert( (dst_pitch & 63) == 0 );
+ assert( (src_offset & 1023) == 0 );
+ assert( (dst_offset & 1023) == 0 );
+ assert( w < (1<<16) );
+ assert( h < (1<<16) );
+
+ cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, 8 * sizeof(int),
+ __FUNCTION__ );
+
+
+ cmd[0].i = 0;
+ cmd[0].header.cmd_type = RADEON_CMD_PACKET3;
+ cmd[1].i = RADEON_CP_PACKET3_CNTL_BITBLT_MULTI | (5 << 16);
+ cmd[2].i = (RADEON_GMC_SRC_PITCH_OFFSET_CNTL |
+ RADEON_GMC_DST_PITCH_OFFSET_CNTL |
+ RADEON_GMC_BRUSH_NONE |
+ color_fmt |
+ RADEON_GMC_SRC_DATATYPE_COLOR |
+ RADEON_ROP3_S |
+ RADEON_DP_SRC_SOURCE_MEMORY |
+ RADEON_GMC_CLR_CMP_CNTL_DIS |
+ RADEON_GMC_WR_MSK_DIS );
+
+ cmd[3].i = ((src_pitch/64)<<22) | (src_offset >> 10);
+ cmd[4].i = ((dst_pitch/64)<<22) | (dst_offset >> 10);
+ cmd[5].i = (srcx << 16) | srcy;
+ cmd[6].i = (dstx << 16) | dsty; /* dst */
+ cmd[7].i = (w << 16) | h;
+}
+
+
+void radeonEmitWait( radeonContextPtr rmesa, GLuint flags )
+{
+ if (rmesa->dri.drmMinor >= 6) {
+ drm_radeon_cmd_header_t *cmd;
+
+ assert( !(flags & ~(RADEON_WAIT_2D|RADEON_WAIT_3D)) );
+
+ cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, 1 * sizeof(int),
+ __FUNCTION__ );
+ cmd[0].i = 0;
+ cmd[0].wait.cmd_type = RADEON_CMD_WAIT;
+ cmd[0].wait.flags = flags;
+ }
+}
+
+
+static int radeonFlushCmdBufLocked( radeonContextPtr rmesa,
+ const char * caller )
+{
+ int ret, i;
+ drm_radeon_cmd_buffer_t cmd;
+
+ if (rmesa->lost_context)
+ radeonBackUpAndEmitLostStateLocked(rmesa);
+
+ if (RADEON_DEBUG & DEBUG_IOCTL) {
+ fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
+
+ if (RADEON_DEBUG & DEBUG_VERBOSE)
+ for (i = 0 ; i < rmesa->store.cmd_used ; i += 4 )
+ fprintf(stderr, "%d: %x\n", i/4,
+ *(int *)(&rmesa->store.cmd_buf[i]));
+ }
+
+ if (RADEON_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "%s: Releasing %d buffers\n", __FUNCTION__,
+ rmesa->dma.nr_released_bufs);
+
+
+ if (RADEON_DEBUG & DEBUG_SANITY) {
+ if (rmesa->state.scissor.enabled)
+ ret = radeonSanityCmdBuffer( rmesa,
+ rmesa->state.scissor.numClipRects,
+ rmesa->state.scissor.pClipRects);
+ else
+ ret = radeonSanityCmdBuffer( rmesa,
+ rmesa->numClipRects,
+ rmesa->pClipRects);
+ if (ret) {
+ fprintf(stderr, "drmSanityCommandWrite: %d\n", ret);
+ goto out;
+ }
+ }
+
+
+ cmd.bufsz = rmesa->store.cmd_used;
+ cmd.buf = rmesa->store.cmd_buf;
+
+ if (rmesa->state.scissor.enabled) {
+ cmd.nbox = rmesa->state.scissor.numClipRects;
+ cmd.boxes = rmesa->state.scissor.pClipRects;
+ } else {
+ cmd.nbox = rmesa->numClipRects;
+ cmd.boxes = rmesa->pClipRects;
+ }
+
+ ret = drmCommandWrite( rmesa->dri.fd,
+ DRM_RADEON_CMDBUF,
+ &cmd, sizeof(cmd) );
+
+ if (ret)
+ fprintf(stderr, "drmCommandWrite: %d\n", ret);
+
+ if (RADEON_DEBUG & DEBUG_SYNC) {
+ fprintf(stderr, "\nSyncing in %s\n\n", __FUNCTION__);
+ radeonWaitForIdleLocked( rmesa );
+ }
+
+ out:
+ rmesa->store.primnr = 0;
+ rmesa->store.statenr = 0;
+ rmesa->store.cmd_used = 0;
+ rmesa->dma.nr_released_bufs = 0;
+ rmesa->save_on_next_emit = 1;
+
+ return ret;
+}
+
+
+/* Note: does not emit any commands to avoid recursion on
+ * radeonAllocCmdBuf.
+ */
+void radeonFlushCmdBuf( radeonContextPtr rmesa, const char *caller )
+{
+ int ret;
+
+
+ LOCK_HARDWARE( rmesa );
+
+ ret = radeonFlushCmdBufLocked( rmesa, caller );
+
+ UNLOCK_HARDWARE( rmesa );
+
+ if (ret) {
+ fprintf(stderr, "drm_radeon_cmd_buffer_t: %d (exiting)\n", ret);
+ exit(ret);
+ }
+}
+
+/* =============================================================
+ * Hardware vertex buffer handling
+ */
+
+
+void radeonRefillCurrentDmaRegion( radeonContextPtr rmesa )
+{
+ struct radeon_dma_buffer *dmabuf;
+ int fd = rmesa->dri.fd;
+ int index = 0;
+ int size = 0;
+ drmDMAReq dma;
+ int ret;
+
+ if (RADEON_DEBUG & (DEBUG_IOCTL|DEBUG_DMA))
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (rmesa->dma.flush) {
+ rmesa->dma.flush( rmesa );
+ }
+
+ if (rmesa->dma.current.buf)
+ radeonReleaseDmaRegion( rmesa, &rmesa->dma.current, __FUNCTION__ );
+
+ if (rmesa->dma.nr_released_bufs > 4)
+ radeonFlushCmdBuf( rmesa, __FUNCTION__ );
+
+ dma.context = rmesa->dri.hwContext;
+ dma.send_count = 0;
+ dma.send_list = NULL;
+ dma.send_sizes = NULL;
+ dma.flags = 0;
+ dma.request_count = 1;
+ dma.request_size = RADEON_BUFFER_SIZE;
+ dma.request_list = &index;
+ dma.request_sizes = &size;
+ dma.granted_count = 0;
+
+ LOCK_HARDWARE(rmesa); /* no need to validate */
+
+ ret = drmDMA( fd, &dma );
+
+ if (ret != 0) {
+ /* Free some up this way?
+ */
+ if (rmesa->dma.nr_released_bufs) {
+ radeonFlushCmdBufLocked( rmesa, __FUNCTION__ );
+ }
+
+ if (RADEON_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "Waiting for buffers\n");
+
+ radeonWaitForIdleLocked( rmesa );
+ ret = drmDMA( fd, &dma );
+
+ if ( ret != 0 ) {
+ UNLOCK_HARDWARE( rmesa );
+ fprintf( stderr, "Error: Could not get dma buffer... exiting\n" );
+ exit( -1 );
+ }
+ }
+
+ UNLOCK_HARDWARE(rmesa);
+
+ if (RADEON_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "Allocated buffer %d\n", index);
+
+ dmabuf = CALLOC_STRUCT( radeon_dma_buffer );
+ dmabuf->buf = &rmesa->radeonScreen->buffers->list[index];
+ dmabuf->refcount = 1;
+
+ rmesa->dma.current.buf = dmabuf;
+ rmesa->dma.current.address = dmabuf->buf->address;
+ rmesa->dma.current.end = dmabuf->buf->total;
+ rmesa->dma.current.start = 0;
+ rmesa->dma.current.ptr = 0;
+
+ rmesa->c_vertexBuffers++;
+}
+
+void radeonReleaseDmaRegion( radeonContextPtr rmesa,
+ struct radeon_dma_region *region,
+ const char *caller )
+{
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
+
+ if (!region->buf)
+ return;
+
+ if (rmesa->dma.flush)
+ rmesa->dma.flush( rmesa );
+
+ if (--region->buf->refcount == 0) {
+ drm_radeon_cmd_header_t *cmd;
+
+ if (RADEON_DEBUG & (DEBUG_IOCTL|DEBUG_DMA))
+ fprintf(stderr, "%s -- DISCARD BUF %d\n", __FUNCTION__,
+ region->buf->buf->idx);
+
+ cmd = (drm_radeon_cmd_header_t *)radeonAllocCmdBuf( rmesa, sizeof(*cmd),
+ __FUNCTION__ );
+ cmd->dma.cmd_type = RADEON_CMD_DMA_DISCARD;
+ cmd->dma.buf_idx = region->buf->buf->idx;
+ FREE(region->buf);
+ rmesa->dma.nr_released_bufs++;
+ }
+
+ region->buf = NULL;
+ region->start = 0;
+}
+
+/* Allocates a region from rmesa->dma.current. If there isn't enough
+ * space in current, grab a new buffer (and discard what was left of current)
+ */
+void radeonAllocDmaRegion( radeonContextPtr rmesa,
+ struct radeon_dma_region *region,
+ int bytes,
+ int alignment )
+{
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s %d\n", __FUNCTION__, bytes);
+
+ if (rmesa->dma.flush)
+ rmesa->dma.flush( rmesa );
+
+ if (region->buf)
+ radeonReleaseDmaRegion( rmesa, region, __FUNCTION__ );
+
+ alignment--;
+ rmesa->dma.current.start = rmesa->dma.current.ptr =
+ (rmesa->dma.current.ptr + alignment) & ~alignment;
+
+ if ( rmesa->dma.current.ptr + bytes > rmesa->dma.current.end )
+ radeonRefillCurrentDmaRegion( rmesa );
+
+ region->start = rmesa->dma.current.start;
+ region->ptr = rmesa->dma.current.start;
+ region->end = rmesa->dma.current.start + bytes;
+ region->address = rmesa->dma.current.address;
+ region->buf = rmesa->dma.current.buf;
+ region->buf->refcount++;
+
+ rmesa->dma.current.ptr += bytes; /* bug - if alignment > 7 */
+ rmesa->dma.current.start =
+ rmesa->dma.current.ptr = (rmesa->dma.current.ptr + 0x7) & ~0x7;
+}
+
+void radeonAllocDmaRegionVerts( radeonContextPtr rmesa,
+ struct radeon_dma_region *region,
+ int numverts,
+ int vertsize,
+ int alignment )
+{
+ radeonAllocDmaRegion( rmesa, region, vertsize * numverts, alignment );
+}
+
+/* ================================================================
+ * SwapBuffers with client-side throttling
+ */
+
+static u_int32_t radeonGetLastFrame (radeonContextPtr rmesa)
+{
+ unsigned char *RADEONMMIO = rmesa->radeonScreen->mmio.map;
+ int ret;
+ u_int32_t frame;
+
+ if (rmesa->dri.screen->drmMinor >= 4) {
+ drm_radeon_getparam_t gp;
+
+ gp.param = RADEON_PARAM_LAST_FRAME;
+ gp.value = (int *)&frame;
+ ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_GETPARAM,
+ &gp, sizeof(gp) );
+ }
+ else
+ ret = -EINVAL;
+
+ if ( ret == -EINVAL ) {
+ frame = INREG( RADEON_LAST_FRAME_REG );
+ ret = 0;
+ }
+ if ( ret ) {
+ fprintf( stderr, "%s: drm_radeon_getparam_t: %d\n", __FUNCTION__, ret );
+ exit(1);
+ }
+
+ return frame;
+}
+
+static void radeonEmitIrqLocked( radeonContextPtr rmesa )
+{
+ drm_radeon_irq_emit_t ie;
+ int ret;
+
+ ie.irq_seq = &rmesa->iw.irq_seq;
+ ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_IRQ_EMIT,
+ &ie, sizeof(ie) );
+ if ( ret ) {
+ fprintf( stderr, "%s: drm_radeon_irq_emit_t: %d\n", __FUNCTION__, ret );
+ exit(1);
+ }
+}
+
+
+static void radeonWaitIrq( radeonContextPtr rmesa )
+{
+ int ret;
+
+ do {
+ ret = drmCommandWrite( rmesa->dri.fd, DRM_RADEON_IRQ_WAIT,
+ &rmesa->iw, sizeof(rmesa->iw) );
+ } while (ret && (errno == EINTR || errno == EAGAIN));
+
+ if ( ret ) {
+ fprintf( stderr, "%s: drmRadeonIrqWait: %d\n", __FUNCTION__, ret );
+ exit(1);
+ }
+}
+
+
+static void radeonWaitForFrameCompletion( radeonContextPtr rmesa )
+{
+ drm_radeon_sarea_t *sarea = rmesa->sarea;
+
+ if (rmesa->do_irqs) {
+ if (radeonGetLastFrame(rmesa) < sarea->last_frame) {
+ if (!rmesa->irqsEmitted) {
+ while (radeonGetLastFrame (rmesa) < sarea->last_frame)
+ ;
+ }
+ else {
+ UNLOCK_HARDWARE( rmesa );
+ radeonWaitIrq( rmesa );
+ LOCK_HARDWARE( rmesa );
+ }
+ rmesa->irqsEmitted = 10;
+ }
+
+ if (rmesa->irqsEmitted) {
+ radeonEmitIrqLocked( rmesa );
+ rmesa->irqsEmitted--;
+ }
+ }
+ else {
+ while (radeonGetLastFrame (rmesa) < sarea->last_frame) {
+ UNLOCK_HARDWARE( rmesa );
+ if (rmesa->do_usleeps)
+ DO_USLEEP( 1 );
+ LOCK_HARDWARE( rmesa );
+ }
+ }
+}
+
+/* Copy the back color buffer to the front color buffer.
+ */
+void radeonCopyBuffer( const __DRIdrawablePrivate *dPriv )
+{
+ radeonContextPtr rmesa;
+ GLint nbox, i, ret;
+ GLboolean missed_target;
+ int64_t ust;
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ rmesa = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ if ( RADEON_DEBUG & DEBUG_IOCTL ) {
+ fprintf( stderr, "\n%s( %p )\n\n", __FUNCTION__, (void *) rmesa->glCtx );
+ }
+
+ RADEON_FIREVERTICES( rmesa );
+ LOCK_HARDWARE( rmesa );
+
+ /* Throttle the frame rate -- only allow one pending swap buffers
+ * request at a time.
+ */
+ radeonWaitForFrameCompletion( rmesa );
+ UNLOCK_HARDWARE( rmesa );
+ driWaitForVBlank( dPriv, & rmesa->vbl_seq, rmesa->vblank_flags, & missed_target );
+ LOCK_HARDWARE( rmesa );
+
+ nbox = dPriv->numClipRects; /* must be in locked region */
+
+ for ( i = 0 ; i < nbox ; ) {
+ GLint nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS , nbox );
+ drm_clip_rect_t *box = dPriv->pClipRects;
+ drm_clip_rect_t *b = rmesa->sarea->boxes;
+ GLint n = 0;
+
+ for ( ; i < nr ; i++ ) {
+ *b++ = box[i];
+ n++;
+ }
+ rmesa->sarea->nbox = n;
+
+ ret = drmCommandNone( rmesa->dri.fd, DRM_RADEON_SWAP );
+
+ if ( ret ) {
+ fprintf( stderr, "DRM_RADEON_SWAP_BUFFERS: return = %d\n", ret );
+ UNLOCK_HARDWARE( rmesa );
+ exit( 1 );
+ }
+ }
+
+ UNLOCK_HARDWARE( rmesa );
+ rmesa->swap_count++;
+ (*dri_interface->getUST)( & ust );
+ if ( missed_target ) {
+ rmesa->swap_missed_count++;
+ rmesa->swap_missed_ust = ust - rmesa->swap_ust;
+ }
+
+ rmesa->swap_ust = ust;
+ rmesa->hw.all_dirty = GL_TRUE;
+}
+
+void radeonPageFlip( const __DRIdrawablePrivate *dPriv )
+{
+ radeonContextPtr rmesa;
+ GLint ret;
+ GLboolean missed_target;
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ rmesa = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ if ( RADEON_DEBUG & DEBUG_IOCTL ) {
+ fprintf(stderr, "%s: pfCurrentPage: %d\n", __FUNCTION__,
+ rmesa->sarea->pfCurrentPage);
+ }
+
+ RADEON_FIREVERTICES( rmesa );
+ LOCK_HARDWARE( rmesa );
+
+ /* Need to do this for the perf box placement:
+ */
+ if (dPriv->numClipRects)
+ {
+ drm_clip_rect_t *box = dPriv->pClipRects;
+ drm_clip_rect_t *b = rmesa->sarea->boxes;
+ b[0] = box[0];
+ rmesa->sarea->nbox = 1;
+ }
+
+ /* Throttle the frame rate -- only allow a few pending swap buffers
+ * request at a time.
+ */
+ radeonWaitForFrameCompletion( rmesa );
+ UNLOCK_HARDWARE( rmesa );
+ driWaitForVBlank( dPriv, & rmesa->vbl_seq, rmesa->vblank_flags, & missed_target );
+ if ( missed_target ) {
+ rmesa->swap_missed_count++;
+ (void) (*dri_interface->getUST)( & rmesa->swap_missed_ust );
+ }
+ LOCK_HARDWARE( rmesa );
+
+ ret = drmCommandNone( rmesa->dri.fd, DRM_RADEON_FLIP );
+
+ UNLOCK_HARDWARE( rmesa );
+
+ if ( ret ) {
+ fprintf( stderr, "DRM_RADEON_FLIP: return = %d\n", ret );
+ exit( 1 );
+ }
+
+ rmesa->swap_count++;
+ (void) (*dri_interface->getUST)( & rmesa->swap_ust );
+
+ if ( rmesa->sarea->pfCurrentPage == 1 ) {
+ rmesa->state.color.drawOffset = rmesa->radeonScreen->frontOffset;
+ rmesa->state.color.drawPitch = rmesa->radeonScreen->frontPitch;
+ } else {
+ rmesa->state.color.drawOffset = rmesa->radeonScreen->backOffset;
+ rmesa->state.color.drawPitch = rmesa->radeonScreen->backPitch;
+ }
+
+ RADEON_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = rmesa->state.color.drawOffset
+ + rmesa->radeonScreen->fbLocation;
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = rmesa->state.color.drawPitch;
+ if (rmesa->sarea->tiling_enabled) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= RADEON_COLOR_TILE_ENABLE;
+ }
+}
+
+
+/* ================================================================
+ * Buffer clear
+ */
+#define RADEON_MAX_CLEARS 256
+
+static void radeonClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+ drm_radeon_sarea_t *sarea = rmesa->sarea;
+ unsigned char *RADEONMMIO = rmesa->radeonScreen->mmio.map;
+ u_int32_t clear;
+ GLuint flags = 0;
+ GLuint color_mask = 0;
+ GLint ret, i;
+
+ if ( RADEON_DEBUG & DEBUG_IOCTL ) {
+ fprintf( stderr, "%s: all=%d cx=%d cy=%d cw=%d ch=%d\n",
+ __FUNCTION__, all, cx, cy, cw, ch );
+ }
+
+ {
+ LOCK_HARDWARE( rmesa );
+ UNLOCK_HARDWARE( rmesa );
+ if ( dPriv->numClipRects == 0 )
+ return;
+ }
+
+ radeonFlush( ctx );
+
+ if ( mask & BUFFER_BIT_FRONT_LEFT ) {
+ flags |= RADEON_FRONT;
+ color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
+ }
+
+ if ( mask & BUFFER_BIT_BACK_LEFT ) {
+ flags |= RADEON_BACK;
+ color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
+ mask &= ~BUFFER_BIT_BACK_LEFT;
+ }
+
+ if ( mask & BUFFER_BIT_DEPTH ) {
+ flags |= RADEON_DEPTH;
+ mask &= ~BUFFER_BIT_DEPTH;
+ }
+
+ if ( (mask & BUFFER_BIT_STENCIL) && rmesa->state.stencil.hwBuffer ) {
+ flags |= RADEON_STENCIL;
+ mask &= ~BUFFER_BIT_STENCIL;
+ }
+
+ if ( mask ) {
+ if (RADEON_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "%s: swrast clear, mask: %x\n", __FUNCTION__, mask);
+ _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
+ }
+
+ if ( !flags )
+ return;
+
+ if (rmesa->using_hyperz) {
+ flags |= RADEON_USE_COMP_ZBUF;
+/* if (rmesa->radeonScreen->chipset & RADEON_CHIPSET_TCL)
+ flags |= RADEON_USE_HIERZ; */
+ if (!(rmesa->state.stencil.hwBuffer) ||
+ ((flags & RADEON_DEPTH) && (flags & RADEON_STENCIL) &&
+ ((rmesa->state.stencil.clear & RADEON_STENCIL_WRITE_MASK) == RADEON_STENCIL_WRITE_MASK))) {
+ flags |= RADEON_CLEAR_FASTZ;
+ }
+ }
+
+ /* Flip top to bottom */
+ cx += dPriv->x;
+ cy = dPriv->y + dPriv->h - cy - ch;
+
+ LOCK_HARDWARE( rmesa );
+
+ /* Throttle the number of clear ioctls we do.
+ */
+ while ( 1 ) {
+ int ret;
+
+ if (rmesa->dri.screen->drmMinor >= 4) {
+ drm_radeon_getparam_t gp;
+
+ gp.param = RADEON_PARAM_LAST_CLEAR;
+ gp.value = (int *)&clear;
+ ret = drmCommandWriteRead( rmesa->dri.fd,
+ DRM_RADEON_GETPARAM, &gp, sizeof(gp) );
+ } else
+ ret = -EINVAL;
+
+ if ( ret == -EINVAL ) {
+ clear = INREG( RADEON_LAST_CLEAR_REG );
+ ret = 0;
+ }
+ if ( ret ) {
+ fprintf( stderr, "%s: drm_radeon_getparam_t: %d\n", __FUNCTION__, ret );
+ exit(1);
+ }
+ if ( RADEON_DEBUG & DEBUG_IOCTL ) {
+ fprintf( stderr, "%s( %d )\n", __FUNCTION__, (int)clear );
+ if ( ret ) fprintf( stderr, " ( RADEON_LAST_CLEAR register read directly )\n" );
+ }
+
+ if ( sarea->last_clear - clear <= RADEON_MAX_CLEARS ) {
+ break;
+ }
+
+ if ( rmesa->do_usleeps ) {
+ UNLOCK_HARDWARE( rmesa );
+ DO_USLEEP( 1 );
+ LOCK_HARDWARE( rmesa );
+ }
+ }
+
+ /* Send current state to the hardware */
+ radeonFlushCmdBufLocked( rmesa, __FUNCTION__ );
+
+ for ( i = 0 ; i < dPriv->numClipRects ; ) {
+ GLint nr = MIN2( i + RADEON_NR_SAREA_CLIPRECTS, dPriv->numClipRects );
+ drm_clip_rect_t *box = dPriv->pClipRects;
+ drm_clip_rect_t *b = rmesa->sarea->boxes;
+ drm_radeon_clear_t clear;
+ drm_radeon_clear_rect_t depth_boxes[RADEON_NR_SAREA_CLIPRECTS];
+ GLint n = 0;
+
+ if ( !all ) {
+ for ( ; i < nr ; i++ ) {
+ GLint x = box[i].x1;
+ GLint y = box[i].y1;
+ GLint w = box[i].x2 - x;
+ GLint h = box[i].y2 - y;
+
+ 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 ) continue;
+ if ( h <= 0 ) continue;
+
+ b->x1 = x;
+ b->y1 = y;
+ b->x2 = x + w;
+ b->y2 = y + h;
+ b++;
+ n++;
+ }
+ } else {
+ for ( ; i < nr ; i++ ) {
+ *b++ = box[i];
+ n++;
+ }
+ }
+
+ rmesa->sarea->nbox = n;
+
+ clear.flags = flags;
+ clear.clear_color = rmesa->state.color.clear;
+ clear.clear_depth = rmesa->state.depth.clear;
+ clear.color_mask = rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK];
+ clear.depth_mask = rmesa->state.stencil.clear;
+ clear.depth_boxes = depth_boxes;
+
+ n--;
+ b = rmesa->sarea->boxes;
+ for ( ; n >= 0 ; n-- ) {
+ depth_boxes[n].f[CLEAR_X1] = (float)b[n].x1;
+ depth_boxes[n].f[CLEAR_Y1] = (float)b[n].y1;
+ depth_boxes[n].f[CLEAR_X2] = (float)b[n].x2;
+ depth_boxes[n].f[CLEAR_Y2] = (float)b[n].y2;
+ depth_boxes[n].f[CLEAR_DEPTH] =
+ (float)rmesa->state.depth.clear;
+ }
+
+ ret = drmCommandWrite( rmesa->dri.fd, DRM_RADEON_CLEAR,
+ &clear, sizeof(drm_radeon_clear_t));
+
+ if ( ret ) {
+ UNLOCK_HARDWARE( rmesa );
+ fprintf( stderr, "DRM_RADEON_CLEAR: return = %d\n", ret );
+ exit( 1 );
+ }
+ }
+
+ UNLOCK_HARDWARE( rmesa );
+ rmesa->hw.all_dirty = GL_TRUE;
+}
+
+
+void radeonWaitForIdleLocked( radeonContextPtr rmesa )
+{
+ int fd = rmesa->dri.fd;
+ int to = 0;
+ int ret, i = 0;
+
+ rmesa->c_drawWaits++;
+
+ do {
+ do {
+ ret = drmCommandNone( fd, DRM_RADEON_CP_IDLE);
+ } while ( ret && errno == EBUSY && i++ < RADEON_IDLE_RETRY );
+ } while ( ( ret == -EBUSY ) && ( to++ < RADEON_TIMEOUT ) );
+
+ if ( ret < 0 ) {
+ UNLOCK_HARDWARE( rmesa );
+ fprintf( stderr, "Error: Radeon timed out... exiting\n" );
+ exit( -1 );
+ }
+}
+
+
+static void radeonWaitForIdle( radeonContextPtr rmesa )
+{
+ LOCK_HARDWARE(rmesa);
+ radeonWaitForIdleLocked( rmesa );
+ UNLOCK_HARDWARE(rmesa);
+}
+
+
+void radeonFlush( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (rmesa->dma.flush)
+ rmesa->dma.flush( rmesa );
+
+ radeonEmitState( rmesa );
+
+ if (rmesa->store.cmd_used)
+ radeonFlushCmdBuf( rmesa, __FUNCTION__ );
+}
+
+/* Make sure all commands have been sent to the hardware and have
+ * completed processing.
+ */
+void radeonFinish( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ radeonFlush( ctx );
+
+ if (rmesa->do_irqs) {
+ LOCK_HARDWARE( rmesa );
+ radeonEmitIrqLocked( rmesa );
+ UNLOCK_HARDWARE( rmesa );
+ radeonWaitIrq( rmesa );
+ }
+ else
+ radeonWaitForIdle( rmesa );
+}
+
+
+void radeonInitIoctlFuncs( GLcontext *ctx )
+{
+ ctx->Driver.Clear = radeonClear;
+ ctx->Driver.Finish = radeonFinish;
+ ctx->Driver.Flush = radeonFlush;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_ioctl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_ioctl.h
new file mode 100644
index 000000000..8b21920c5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_ioctl.h
@@ -0,0 +1,217 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_ioctl.h,v 1.6 2002/12/16 16:18:58 dawes Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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 THE COPYRIGHT OWNER(S) 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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ */
+
+#ifndef __RADEON_IOCTL_H__
+#define __RADEON_IOCTL_H__
+
+#include "simple_list.h"
+#include "radeon_lock.h"
+
+
+extern void radeonEmitState( radeonContextPtr rmesa );
+extern void radeonEmitVertexAOS( radeonContextPtr rmesa,
+ GLuint vertex_size,
+ GLuint offset );
+
+extern void radeonEmitVbufPrim( radeonContextPtr rmesa,
+ GLuint vertex_format,
+ GLuint primitive,
+ GLuint vertex_nr );
+
+extern void radeonFlushElts( radeonContextPtr rmesa );
+
+extern GLushort *radeonAllocEltsOpenEnded( radeonContextPtr rmesa,
+ GLuint vertex_format,
+ GLuint primitive,
+ GLuint min_nr );
+
+extern void radeonEmitAOS( radeonContextPtr rmesa,
+ struct radeon_dma_region **regions,
+ GLuint n,
+ GLuint offset );
+
+extern void radeonEmitBlit( radeonContextPtr rmesa,
+ GLuint color_fmt,
+ GLuint src_pitch,
+ GLuint src_offset,
+ GLuint dst_pitch,
+ GLuint dst_offset,
+ GLint srcx, GLint srcy,
+ GLint dstx, GLint dsty,
+ GLuint w, GLuint h );
+
+extern void radeonEmitWait( radeonContextPtr rmesa, GLuint flags );
+
+extern void radeonFlushCmdBuf( radeonContextPtr rmesa, const char * );
+extern void radeonRefillCurrentDmaRegion( radeonContextPtr rmesa );
+
+extern void radeonAllocDmaRegion( radeonContextPtr rmesa,
+ struct radeon_dma_region *region,
+ int bytes,
+ int alignment );
+
+extern void radeonAllocDmaRegionVerts( radeonContextPtr rmesa,
+ struct radeon_dma_region *region,
+ int numverts,
+ int vertsize,
+ int alignment );
+
+extern void radeonReleaseDmaRegion( radeonContextPtr rmesa,
+ struct radeon_dma_region *region,
+ const char *caller );
+
+extern void radeonCopyBuffer( const __DRIdrawablePrivate *drawable );
+extern void radeonPageFlip( const __DRIdrawablePrivate *drawable );
+extern void radeonFlush( GLcontext *ctx );
+extern void radeonFinish( GLcontext *ctx );
+extern void radeonWaitForIdleLocked( radeonContextPtr rmesa );
+extern void radeonWaitForVBlank( radeonContextPtr rmesa );
+extern void radeonInitIoctlFuncs( GLcontext *ctx );
+extern void radeonGetAllParams( radeonContextPtr rmesa );
+extern void radeonSetUpAtomList( radeonContextPtr rmesa );
+
+/* radeon_compat.c:
+ */
+extern void radeonCompatEmitPrimitive( radeonContextPtr rmesa,
+ GLuint vertex_format,
+ GLuint hw_primitive,
+ GLuint nrverts );
+
+/* ================================================================
+ * Helper macros:
+ */
+
+/* Close off the last primitive, if it exists.
+ */
+#define RADEON_NEWPRIM( rmesa ) \
+do { \
+ if ( rmesa->dma.flush ) \
+ rmesa->dma.flush( rmesa ); \
+} while (0)
+
+/* Can accomodate several state changes and primitive changes without
+ * actually firing the buffer.
+ */
+#define RADEON_STATECHANGE( rmesa, ATOM ) \
+do { \
+ RADEON_NEWPRIM( rmesa ); \
+ rmesa->hw.ATOM.dirty = GL_TRUE; \
+ rmesa->hw.is_dirty = GL_TRUE; \
+} while (0)
+
+#define RADEON_DB_STATE( ATOM ) \
+ memcpy( rmesa->hw.ATOM.lastcmd, rmesa->hw.ATOM.cmd, \
+ rmesa->hw.ATOM.cmd_size * 4)
+
+static __inline int RADEON_DB_STATECHANGE(
+ radeonContextPtr rmesa,
+ struct radeon_state_atom *atom )
+{
+ if (memcmp(atom->cmd, atom->lastcmd, atom->cmd_size*4)) {
+ int *tmp;
+ RADEON_NEWPRIM( rmesa );
+ atom->dirty = GL_TRUE;
+ rmesa->hw.is_dirty = GL_TRUE;
+ tmp = atom->cmd;
+ atom->cmd = atom->lastcmd;
+ atom->lastcmd = tmp;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+
+/* Fire the buffered vertices no matter what.
+ */
+#define RADEON_FIREVERTICES( rmesa ) \
+do { \
+ if ( rmesa->store.cmd_used || rmesa->dma.flush ) { \
+ radeonFlush( rmesa->glCtx ); \
+ } \
+} while (0)
+
+/* Command lengths. Note that any time you ensure ELTS_BUFSZ or VBUF_BUFSZ
+ * are available, you will also be adding an rmesa->state.max_state_size because
+ * r200EmitState is called from within r200EmitVbufPrim and r200FlushElts.
+ */
+#if RADEON_OLD_PACKETS
+#define AOS_BUFSZ(nr) ((3 + ((nr / 2) * 3) + ((nr & 1) * 2)) * sizeof(int))
+#define VERT_AOS_BUFSZ (0)
+#define ELTS_BUFSZ(nr) (24 + nr * 2)
+#define VBUF_BUFSZ (6 * sizeof(int))
+#else
+#define AOS_BUFSZ(nr) ((3 + ((nr / 2) * 3) + ((nr & 1) * 2)) * sizeof(int))
+#define VERT_AOS_BUFSZ (5 * sizeof(int))
+#define ELTS_BUFSZ(nr) (16 + nr * 2)
+#define VBUF_BUFSZ (4 * sizeof(int))
+#endif
+
+/* Ensure that a minimum amount of space is available in the command buffer.
+ * This is used to ensure atomicity of state updates with the rendering requests
+ * that rely on them.
+ *
+ * An alternative would be to implement a "soft lock" such that when the buffer
+ * wraps at an inopportune time, we grab the lock, flush the current buffer,
+ * and hang on to the lock until the critical section is finished and we flush
+ * the buffer again and unlock.
+ */
+static __inline void radeonEnsureCmdBufSpace( radeonContextPtr rmesa,
+ int bytes )
+{
+ if (rmesa->store.cmd_used + bytes > RADEON_CMD_BUF_SZ)
+ radeonFlushCmdBuf( rmesa, __FUNCTION__ );
+ assert( bytes <= RADEON_CMD_BUF_SZ );
+}
+
+/* Alloc space in the command buffer
+ */
+static __inline char *radeonAllocCmdBuf( radeonContextPtr rmesa,
+ int bytes, const char *where )
+{
+ if (rmesa->store.cmd_used + bytes > RADEON_CMD_BUF_SZ)
+ radeonFlushCmdBuf( rmesa, __FUNCTION__ );
+
+ assert(rmesa->dri.drmMinor >= 3);
+
+ {
+ char *head = rmesa->store.cmd_buf + rmesa->store.cmd_used;
+ rmesa->store.cmd_used += bytes;
+ return head;
+ }
+}
+
+#endif /* __RADEON_IOCTL_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_lighting.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_lighting.c
new file mode 100644
index 000000000..44e00af0e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_lighting.c
@@ -0,0 +1,682 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_state.c,v 1.5 2002/09/16 18:05:20 eich Exp $ */
+/*
+ * Copyright 2000, 2001 VA Linux Systems Inc., Fremont, 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
+ * 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
+ * VA LINUX SYSTEMS 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:
+ * Gareth Hughes <gareth@valinux.com>
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "api_arrayelt.h"
+/* #include "mmath.h" */
+#include "enums.h"
+#include "colormac.h"
+
+
+#include "radeon_context.h"
+#include "radeon_ioctl.h"
+#include "radeon_state.h"
+#include "radeon_tcl.h"
+#include "radeon_tex.h"
+#include "radeon_vtxfmt.h"
+
+
+
+/* =============================================================
+ * Materials
+ */
+
+
+/* Update on colormaterial, material emmissive/ambient,
+ * lightmodel.globalambient
+ */
+void update_global_ambient( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ float *fcmd = (float *)RADEON_DB_STATE( glt );
+
+ /* Need to do more if both emmissive & ambient are PREMULT:
+ */
+ if ((rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &
+ ((3 << RADEON_EMISSIVE_SOURCE_SHIFT) |
+ (3 << RADEON_AMBIENT_SOURCE_SHIFT))) == 0)
+ {
+ COPY_3V( &fcmd[GLT_RED],
+ ctx->Light.Material[0].Emission);
+ ACC_SCALE_3V( &fcmd[GLT_RED],
+ ctx->Light.Model.Ambient,
+ ctx->Light.Material[0].Ambient);
+ }
+ else
+ {
+ COPY_3V( &fcmd[GLT_RED], ctx->Light.Model.Ambient );
+ }
+
+ RADEON_DB_STATECHANGE(rmesa, &rmesa->hw.glt);
+}
+
+/* Update on change to
+ * - light[p].colors
+ * - light[p].enabled
+ * - material,
+ * - colormaterial enabled
+ * - colormaterial bitmask
+ */
+void update_light_colors( GLcontext *ctx, GLuint p )
+{
+ struct gl_light *l = &ctx->Light.Light[p];
+
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ if (l->Enabled) {
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ float *fcmd = (float *)RADEON_DB_STATE( lit[p] );
+ GLuint bitmask = ctx->Light.ColorMaterialBitmask;
+ struct gl_material *mat = &ctx->Light.Material[0];
+
+ COPY_4V( &fcmd[LIT_AMBIENT_RED], l->Ambient );
+ COPY_4V( &fcmd[LIT_DIFFUSE_RED], l->Diffuse );
+ COPY_4V( &fcmd[LIT_SPECULAR_RED], l->Specular );
+
+ if (!ctx->Light.ColorMaterialEnabled)
+ bitmask = 0;
+
+ if ((bitmask & FRONT_AMBIENT_BIT) == 0)
+ SELF_SCALE_3V( &fcmd[LIT_AMBIENT_RED], mat->Ambient );
+
+ if ((bitmask & FRONT_DIFFUSE_BIT) == 0)
+ SELF_SCALE_3V( &fcmd[LIT_DIFFUSE_RED], mat->Diffuse );
+
+ if ((bitmask & FRONT_SPECULAR_BIT) == 0)
+ SELF_SCALE_3V( &fcmd[LIT_SPECULAR_RED], mat->Specular );
+
+ RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.lit[p] );
+ }
+}
+
+/* Also fallback for asym colormaterial mode in twoside lighting...
+ */
+void check_twoside_fallback( GLcontext *ctx )
+{
+ GLboolean fallback = GL_FALSE;
+
+ if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) {
+ if (memcmp( &ctx->Light.Material[0],
+ &ctx->Light.Material[1],
+ sizeof(struct gl_material)) != 0)
+ fallback = GL_TRUE;
+ else if (ctx->Light.ColorMaterialEnabled &&
+ (ctx->Light.ColorMaterialBitmask & BACK_MATERIAL_BITS) !=
+ ((ctx->Light.ColorMaterialBitmask & FRONT_MATERIAL_BITS)<<1))
+ fallback = GL_TRUE;
+ }
+
+ TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_LIGHT_TWOSIDE, fallback );
+}
+
+void radeonColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
+{
+ if (ctx->Light.ColorMaterialEnabled) {
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint light_model_ctl = rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL];
+ GLuint mask = ctx->Light.ColorMaterialBitmask;
+
+ /* Default to PREMULT:
+ */
+ light_model_ctl &= ~((3 << RADEON_EMISSIVE_SOURCE_SHIFT) |
+ (3 << RADEON_AMBIENT_SOURCE_SHIFT) |
+ (3 << RADEON_DIFFUSE_SOURCE_SHIFT) |
+ (3 << RADEON_SPECULAR_SOURCE_SHIFT));
+
+ if (mask & FRONT_EMISSION_BIT) {
+ light_model_ctl |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE <<
+ RADEON_EMISSIVE_SOURCE_SHIFT);
+ }
+
+ if (mask & FRONT_AMBIENT_BIT) {
+ light_model_ctl |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE <<
+ RADEON_AMBIENT_SOURCE_SHIFT);
+ }
+
+ if (mask & FRONT_DIFFUSE_BIT) {
+ light_model_ctl |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE <<
+ RADEON_DIFFUSE_SOURCE_SHIFT);
+ }
+
+ if (mask & FRONT_SPECULAR_BIT) {
+ light_model_ctl |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE <<
+ RADEON_SPECULAR_SOURCE_SHIFT);
+ }
+
+ if (light_model_ctl != rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL]) {
+ GLuint p;
+
+ RADEON_STATECHANGE( rmesa, tcl );
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] = light_model_ctl;
+
+ for (p = 0 ; p < MAX_LIGHTS; p++)
+ update_light_colors( ctx, p );
+ update_global_ambient( ctx );
+ }
+ }
+
+ check_twoside_fallback( ctx );
+}
+
+void radeonUpdateMaterial( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *fcmd = (GLfloat *)RADEON_DB_STATE( mtl );
+ GLuint p;
+ GLuint mask = ~0;
+
+ if (ctx->Light.ColorMaterialEnabled)
+ mask &= ~ctx->Light.ColorMaterialBitmask;
+
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+
+ if (mask & FRONT_EMISSION_BIT) {
+ fcmd[MTL_EMMISSIVE_RED] = ctx->Light.Material[0].Emission[0];
+ fcmd[MTL_EMMISSIVE_GREEN] = ctx->Light.Material[0].Emission[1];
+ fcmd[MTL_EMMISSIVE_BLUE] = ctx->Light.Material[0].Emission[2];
+ fcmd[MTL_EMMISSIVE_ALPHA] = ctx->Light.Material[0].Emission[3];
+ }
+ if (mask & FRONT_AMBIENT_BIT) {
+ fcmd[MTL_AMBIENT_RED] = ctx->Light.Material[0].Ambient[0];
+ fcmd[MTL_AMBIENT_GREEN] = ctx->Light.Material[0].Ambient[1];
+ fcmd[MTL_AMBIENT_BLUE] = ctx->Light.Material[0].Ambient[2];
+ fcmd[MTL_AMBIENT_ALPHA] = ctx->Light.Material[0].Ambient[3];
+ }
+ if (mask & FRONT_DIFFUSE_BIT) {
+ fcmd[MTL_DIFFUSE_RED] = ctx->Light.Material[0].Diffuse[0];
+ fcmd[MTL_DIFFUSE_GREEN] = ctx->Light.Material[0].Diffuse[1];
+ fcmd[MTL_DIFFUSE_BLUE] = ctx->Light.Material[0].Diffuse[2];
+ fcmd[MTL_DIFFUSE_ALPHA] = ctx->Light.Material[0].Diffuse[3];
+ }
+ if (mask & FRONT_SPECULAR_BIT) {
+ fcmd[MTL_SPECULAR_RED] = ctx->Light.Material[0].Specular[0];
+ fcmd[MTL_SPECULAR_GREEN] = ctx->Light.Material[0].Specular[1];
+ fcmd[MTL_SPECULAR_BLUE] = ctx->Light.Material[0].Specular[2];
+ fcmd[MTL_SPECULAR_ALPHA] = ctx->Light.Material[0].Specular[3];
+ }
+ if (mask & FRONT_SHININESS_BIT) {
+ fcmd[MTL_SHININESS] = ctx->Light.Material[0].Shininess;
+ }
+
+ if (RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.mtl )) {
+ for (p = 0 ; p < MAX_LIGHTS; p++)
+ update_light_colors( ctx, p );
+
+ check_twoside_fallback( ctx );
+ update_global_ambient( ctx );
+ }
+ else if (RADEON_DEBUG & (DEBUG_PRIMS|DEBUG_STATE))
+ fprintf(stderr, "%s: Elided noop material call\n", __FUNCTION__);
+}
+
+/* _NEW_LIGHT
+ * _NEW_MODELVIEW
+ * _MESA_NEW_NEED_EYE_COORDS
+ *
+ * Uses derived state from mesa:
+ * _VP_inf_norm
+ * _h_inf_norm
+ * _Position
+ * _NormDirection
+ * _ModelViewInvScale
+ * _NeedEyeCoords
+ * _EyeZDir
+ *
+ * which are calculated in light.c and are correct for the current
+ * lighting space (model or eye), hence dependencies on _NEW_MODELVIEW
+ * and _MESA_NEW_NEED_EYE_COORDS.
+ */
+void radeonUpdateLighting( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ /* Have to check these, or have an automatic shortcircuit mechanism
+ * to remove noop statechanges. (Or just do a better job on the
+ * front end).
+ */
+ {
+ GLuint tmp = rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL];
+
+ if (ctx->_NeedEyeCoords)
+ tmp &= ~RADEON_LIGHT_IN_MODELSPACE;
+ else
+ tmp |= RADEON_LIGHT_IN_MODELSPACE;
+
+
+ /* Leave this test disabled: (unexplained q3 lockup) (even with
+ new packets)
+ */
+ if (tmp != rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL])
+ {
+ RADEON_STATECHANGE( rmesa, tcl );
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] = tmp;
+ }
+ }
+
+ {
+ GLfloat *fcmd = (GLfloat *)RADEON_DB_STATE( eye );
+ fcmd[EYE_X] = ctx->_EyeZDir[0];
+ fcmd[EYE_Y] = ctx->_EyeZDir[1];
+ fcmd[EYE_Z] = - ctx->_EyeZDir[2];
+ fcmd[EYE_RESCALE_FACTOR] = ctx->_ModelViewInvScale;
+ RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.eye );
+ }
+
+
+/* RADEON_STATECHANGE( rmesa, glt ); */
+
+ if (ctx->Light.Enabled) {
+ GLint p;
+ for (p = 0 ; p < MAX_LIGHTS; p++) {
+ if (ctx->Light.Light[p].Enabled) {
+ struct gl_light *l = &ctx->Light.Light[p];
+ GLfloat *fcmd = (GLfloat *)RADEON_DB_STATE( lit[p] );
+
+ if (l->EyePosition[3] == 0.0) {
+ COPY_3FV( &fcmd[LIT_POSITION_X], l->_VP_inf_norm );
+ COPY_3FV( &fcmd[LIT_DIRECTION_X], l->_h_inf_norm );
+ fcmd[LIT_POSITION_W] = 0;
+ fcmd[LIT_DIRECTION_W] = 0;
+ } else {
+ COPY_4V( &fcmd[LIT_POSITION_X], l->_Position );
+ fcmd[LIT_DIRECTION_X] = -l->_NormDirection[0];
+ fcmd[LIT_DIRECTION_Y] = -l->_NormDirection[1];
+ fcmd[LIT_DIRECTION_Z] = -l->_NormDirection[2];
+ fcmd[LIT_DIRECTION_W] = 0;
+ }
+
+ RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.lit[p] );
+ }
+ }
+ }
+}
+
+
+void radeonLightfv( GLcontext *ctx, GLenum light,
+ GLenum pname, const GLfloat *params )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLint p = light - GL_LIGHT0;
+ struct gl_light *l = &ctx->Light.Light[p];
+ GLfloat *fcmd = (GLfloat *)rmesa->hw.lit[p].cmd;
+
+
+ switch (pname) {
+ case GL_AMBIENT:
+ case GL_DIFFUSE:
+ case GL_SPECULAR:
+ update_light_colors( ctx, p );
+ break;
+
+ case GL_SPOT_DIRECTION:
+ /* picked up in update_light */
+ break;
+
+ case GL_POSITION: {
+ /* positions picked up in update_light, but can do flag here */
+ GLuint flag = (p&1)? RADEON_LIGHT_1_IS_LOCAL : RADEON_LIGHT_0_IS_LOCAL;
+ GLuint idx = TCL_PER_LIGHT_CTL_0 + p/2;
+
+ RADEON_STATECHANGE(rmesa, tcl);
+ if (l->EyePosition[3] != 0.0F)
+ rmesa->hw.tcl.cmd[idx] |= flag;
+ else
+ rmesa->hw.tcl.cmd[idx] &= ~flag;
+ break;
+ }
+
+ case GL_SPOT_EXPONENT:
+ RADEON_STATECHANGE(rmesa, lit[p]);
+ fcmd[LIT_SPOT_EXPONENT] = params[0];
+ break;
+
+ case GL_SPOT_CUTOFF: {
+ GLuint flag = (p&1) ? RADEON_LIGHT_1_IS_SPOT : RADEON_LIGHT_0_IS_SPOT;
+ GLuint idx = TCL_PER_LIGHT_CTL_0 + p/2;
+
+ RADEON_STATECHANGE(rmesa, lit[p]);
+ fcmd[LIT_SPOT_CUTOFF] = l->_CosCutoff;
+
+ RADEON_STATECHANGE(rmesa, tcl);
+ if (l->SpotCutoff != 180.0F)
+ rmesa->hw.tcl.cmd[idx] |= flag;
+ else
+ rmesa->hw.tcl.cmd[idx] &= ~flag;
+ break;
+ }
+
+ case GL_CONSTANT_ATTENUATION:
+ RADEON_STATECHANGE(rmesa, lit[p]);
+ fcmd[LIT_ATTEN_CONST] = params[0];
+ break;
+ case GL_LINEAR_ATTENUATION:
+ RADEON_STATECHANGE(rmesa, lit[p]);
+ fcmd[LIT_ATTEN_LINEAR] = params[0];
+ break;
+ case GL_QUADRATIC_ATTENUATION:
+ RADEON_STATECHANGE(rmesa, lit[p]);
+ fcmd[LIT_ATTEN_QUADRATIC] = params[0];
+ break;
+ default:
+ return;
+ }
+
+}
+
+
+
+
+void radeonLightModelfv( GLcontext *ctx, GLenum pname,
+ const GLfloat *param )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ switch (pname) {
+ case GL_LIGHT_MODEL_AMBIENT:
+ update_global_ambient( ctx );
+ break;
+
+ case GL_LIGHT_MODEL_LOCAL_VIEWER:
+ RADEON_STATECHANGE( rmesa, tcl );
+ if (ctx->Light.Model.LocalViewer)
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LOCAL_VIEWER;
+ else
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_LOCAL_VIEWER;
+ break;
+
+ case GL_LIGHT_MODEL_TWO_SIDE:
+ RADEON_STATECHANGE( rmesa, tcl );
+ if (ctx->Light.Model.TwoSide)
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_LIGHT_TWOSIDE;
+ else
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~RADEON_LIGHT_TWOSIDE;
+
+ check_twoside_fallback( ctx );
+
+#if _HAVE_SWTNL
+ if (rmesa->TclFallback) {
+ radeonChooseRenderState( ctx );
+ radeonChooseVertexState( ctx );
+ }
+#endif
+ break;
+
+ case GL_LIGHT_MODEL_COLOR_CONTROL:
+ radeonUpdateSpecular(ctx);
+
+ RADEON_STATECHANGE( rmesa, tcl );
+ if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &=
+ ~RADEON_DIFFUSE_SPECULAR_COMBINE;
+ else
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |=
+ RADEON_DIFFUSE_SPECULAR_COMBINE;
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+/* =============================================================
+ * Fog
+ */
+
+
+static void radeonFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ union { int i; float f; } c, d;
+ GLchan col[4];
+
+ c.i = rmesa->hw.fog.cmd[FOG_C];
+ d.i = rmesa->hw.fog.cmd[FOG_D];
+
+ switch (pname) {
+ case GL_FOG_MODE:
+ if (!ctx->Fog.Enabled)
+ return;
+ RADEON_STATECHANGE(rmesa, tcl);
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~RADEON_TCL_FOG_MASK;
+ switch (ctx->Fog.Mode) {
+ case GL_LINEAR:
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_TCL_FOG_LINEAR;
+ if (ctx->Fog.Start == ctx->Fog.End) {
+ c.f = 1.0F;
+ d.f = 1.0F;
+ }
+ else {
+ c.f = ctx->Fog.End/(ctx->Fog.End-ctx->Fog.Start);
+ d.f = 1.0/(ctx->Fog.End-ctx->Fog.Start);
+ }
+ break;
+ case GL_EXP:
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_TCL_FOG_EXP;
+ c.f = 0.0;
+ d.f = ctx->Fog.Density;
+ break;
+ case GL_EXP2:
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_TCL_FOG_EXP2;
+ c.f = 0.0;
+ d.f = -(ctx->Fog.Density * ctx->Fog.Density);
+ break;
+ default:
+ return;
+ }
+ break;
+ case GL_FOG_DENSITY:
+ switch (ctx->Fog.Mode) {
+ case GL_EXP:
+ c.f = 0.0;
+ d.f = ctx->Fog.Density;
+ break;
+ case GL_EXP2:
+ c.f = 0.0;
+ d.f = -(ctx->Fog.Density * ctx->Fog.Density);
+ break;
+ default:
+ break;
+ }
+ break;
+ case GL_FOG_START:
+ case GL_FOG_END:
+ if (ctx->Fog.Mode == GL_LINEAR) {
+ if (ctx->Fog.Start == ctx->Fog.End) {
+ c.f = 1.0F;
+ d.f = 1.0F;
+ } else {
+ c.f = ctx->Fog.End/(ctx->Fog.End-ctx->Fog.Start);
+ d.f = 1.0/(ctx->Fog.End-ctx->Fog.Start);
+ }
+ }
+ break;
+ case GL_FOG_COLOR:
+ RADEON_STATECHANGE( rmesa, ctx );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( col, ctx->Fog.Color );
+ rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] =
+ radeonPackColor( 4, col[0], col[1], col[2], 0 );
+ break;
+ case GL_FOG_COORDINATE_SOURCE_EXT:
+ /* What to do?
+ */
+ break;
+ default:
+ return;
+ }
+
+ if (c.i != rmesa->hw.fog.cmd[FOG_C] || d.i != rmesa->hw.fog.cmd[FOG_D]) {
+ RADEON_STATECHANGE( rmesa, fog );
+ rmesa->hw.fog.cmd[FOG_C] = c.i;
+ rmesa->hw.fog.cmd[FOG_D] = d.i;
+ }
+}
+
+/* Examine lighting and texture state to determine if separate specular
+ * should be enabled.
+ */
+void radeonUpdateSpecular( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint p = rmesa->hw.ctx.cmd[CTX_PP_CNTL];
+
+ if (NEED_SECONDARY_COLOR(ctx)) {
+ p |= RADEON_SPECULAR_ENABLE;
+ } else {
+ p &= ~RADEON_SPECULAR_ENABLE;
+ }
+
+ if ( rmesa->hw.ctx.cmd[CTX_PP_CNTL] != p ) {
+ RADEON_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] = p;
+ }
+
+ /* Bizzare: have to leave lighting enabled to get fog.
+ */
+ RADEON_STATECHANGE( rmesa, tcl );
+ if ((ctx->Light.Enabled &&
+ ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)) {
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_SPECULAR;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_SPEC;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LIGHTING_ENABLE;
+ }
+ else if (ctx->Fog.Enabled) {
+ if (ctx->Light.Enabled) {
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_SPECULAR;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_SPEC;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LIGHTING_ENABLE;
+ } else {
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_SPECULAR;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_SPEC;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LIGHTING_ENABLE;
+ }
+ }
+ else if (ctx->Light.Enabled) {
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_SPECULAR;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] &= ~RADEON_TCL_VTX_PK_SPEC;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LIGHTING_ENABLE;
+ } else if (ctx->Fog.ColorSumEnabled ) {
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_SPECULAR;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_SPEC;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_LIGHTING_ENABLE;
+ } else {
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_SPECULAR;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] &= ~RADEON_TCL_VTX_PK_SPEC;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_LIGHTING_ENABLE;
+ }
+
+#if _HAVE_SWTNL
+ /* Update vertex/render formats
+ */
+ if (rmesa->TclFallback) {
+ radeonChooseRenderState( ctx );
+ radeonChooseVertexState( ctx );
+ }
+#endif
+}
+
+
+
+static void radeonLightingSpaceChange( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLboolean tmp;
+ RADEON_STATECHANGE( rmesa, tcl );
+
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s %d\n", __FUNCTION__, ctx->_NeedEyeCoords);
+
+ if (ctx->_NeedEyeCoords)
+ tmp = ctx->Transform.RescaleNormals;
+ else
+ tmp = !ctx->Transform.RescaleNormals;
+
+ if ( tmp ) {
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_RESCALE_NORMALS;
+ } else {
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_RESCALE_NORMALS;
+ }
+}
+
+void radeonInitLightStateFuncs( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ int i;
+
+ ctx->Driver.LightModelfv = radeonLightModelfv;
+ ctx->Driver.Lightfv = radeonLightfv;
+ ctx->Driver.Fogfv = radeonFogfv;
+ ctx->Driver.LightingSpaceChange = radeonLightingSpaceChange;
+
+ for (i = 0 ; i < 8; i++) {
+ struct gl_light *l = &ctx->Light.Light[i];
+ GLenum p = GL_LIGHT0 + i;
+ *(float *)&(rmesa->hw.lit[i].cmd[LIT_RANGE_CUTOFF]) = FLT_MAX;
+
+ ctx->Driver.Lightfv( ctx, p, GL_AMBIENT, l->Ambient );
+ ctx->Driver.Lightfv( ctx, p, GL_DIFFUSE, l->Diffuse );
+ ctx->Driver.Lightfv( ctx, p, GL_SPECULAR, l->Specular );
+ ctx->Driver.Lightfv( ctx, p, GL_POSITION, 0 );
+ ctx->Driver.Lightfv( ctx, p, GL_SPOT_DIRECTION, 0 );
+ ctx->Driver.Lightfv( ctx, p, GL_SPOT_EXPONENT, &l->SpotExponent );
+ ctx->Driver.Lightfv( ctx, p, GL_SPOT_CUTOFF, &l->SpotCutoff );
+ ctx->Driver.Lightfv( ctx, p, GL_CONSTANT_ATTENUATION,
+ &l->ConstantAttenuation );
+ ctx->Driver.Lightfv( ctx, p, GL_LINEAR_ATTENUATION,
+ &l->LinearAttenuation );
+ ctx->Driver.Lightfv( ctx, p, GL_QUADRATIC_ATTENUATION,
+ &l->QuadraticAttenuation );
+ }
+
+ ctx->Driver.LightModelfv( ctx, GL_LIGHT_MODEL_AMBIENT,
+ ctx->Light.Model.Ambient );
+
+ ctx->Driver.Fogfv( ctx, GL_FOG_MODE, 0 );
+ ctx->Driver.Fogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );
+ ctx->Driver.Fogfv( ctx, GL_FOG_START, &ctx->Fog.Start );
+ ctx->Driver.Fogfv( ctx, GL_FOG_END, &ctx->Fog.End );
+ ctx->Driver.Fogfv( ctx, GL_FOG_COLOR, ctx->Fog.Color );
+ ctx->Driver.Fogfv( ctx, GL_FOG_COORDINATE_SOURCE_EXT, 0 );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_lock.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_lock.c
new file mode 100644
index 000000000..bb121fc58
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_lock.c
@@ -0,0 +1,135 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_lock.c,v 1.5 2002/10/30 12:51:55 alanh Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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 THE COPYRIGHT OWNER(S) 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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ */
+
+#include "glheader.h"
+#include "radeon_context.h"
+#include "radeon_lock.h"
+#include "radeon_tex.h"
+#include "radeon_state.h"
+#include "radeon_ioctl.h"
+
+#if DEBUG_LOCKING
+char *prevLockFile = NULL;
+int prevLockLine = 0;
+#endif
+
+/* Turn on/off page flipping according to the flags in the sarea:
+ */
+static void
+radeonUpdatePageFlipping( radeonContextPtr rmesa )
+{
+ int use_back;
+
+
+ rmesa->doPageFlip = rmesa->sarea->pfState;
+
+ use_back = (rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT);
+ use_back ^= (rmesa->sarea->pfCurrentPage == 1);
+
+ if ( RADEON_DEBUG & DEBUG_VERBOSE )
+ fprintf(stderr, "%s allow %d current %d\n", __FUNCTION__,
+ rmesa->doPageFlip,
+ rmesa->sarea->pfCurrentPage );
+
+ if ( use_back ) {
+ rmesa->state.color.drawOffset = rmesa->radeonScreen->backOffset;
+ rmesa->state.color.drawPitch = rmesa->radeonScreen->backPitch;
+ } else {
+ rmesa->state.color.drawOffset = rmesa->radeonScreen->frontOffset;
+ rmesa->state.color.drawPitch = rmesa->radeonScreen->frontPitch;
+ }
+
+ RADEON_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = rmesa->state.color.drawOffset
+ + rmesa->radeonScreen->fbLocation;
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = rmesa->state.color.drawPitch;
+}
+
+
+
+/* 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.
+ */
+void radeonGetLock( radeonContextPtr rmesa, GLuint flags )
+{
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+ __DRIscreenPrivate *sPriv = rmesa->dri.screen;
+ drm_radeon_sarea_t *sarea = rmesa->sarea;
+
+ drmGetLock( rmesa->dri.fd, rmesa->dri.hwContext, flags );
+
+ /* 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.
+ */
+ DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
+
+ if ( rmesa->lastStamp != dPriv->lastStamp ) {
+ radeonUpdatePageFlipping( rmesa );
+ if (rmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_BACK_LEFT)
+ radeonSetCliprects( rmesa, GL_BACK_LEFT );
+ else
+ radeonSetCliprects( rmesa, GL_FRONT_LEFT );
+ radeonUpdateViewportOffset( rmesa->glCtx );
+ rmesa->lastStamp = dPriv->lastStamp;
+ }
+
+ RADEON_STATECHANGE( rmesa, ctx );
+ if (rmesa->sarea->tiling_enabled) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= RADEON_COLOR_TILE_ENABLE;
+ }
+ else rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] &= ~RADEON_COLOR_TILE_ENABLE;
+
+ if ( sarea->ctx_owner != rmesa->dri.hwContext ) {
+ int i;
+ sarea->ctx_owner = rmesa->dri.hwContext;
+
+ for ( i = 0 ; i < rmesa->nr_heaps ; i++ ) {
+ DRI_AGE_TEXTURES( rmesa->texture_heaps[ i ] );
+ }
+ }
+
+ rmesa->lost_context = GL_TRUE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_lock.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_lock.h
new file mode 100644
index 000000000..4e8617eb8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_lock.h
@@ -0,0 +1,108 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_lock.h,v 1.3 2002/10/30 12:51:55 alanh Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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 THE COPYRIGHT OWNER(S) 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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ */
+
+#ifndef __RADEON_LOCK_H__
+#define __RADEON_LOCK_H__
+
+extern void radeonGetLock( radeonContextPtr rmesa, GLuint flags );
+
+/* Turn DEBUG_LOCKING on to find locking conflicts.
+ */
+#define DEBUG_LOCKING 0
+
+#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 and validate our state.
+ */
+#define LOCK_HARDWARE( rmesa ) \
+ do { \
+ char __ret = 0; \
+ DEBUG_CHECK_LOCK(); \
+ DRM_CAS( rmesa->dri.hwLock, rmesa->dri.hwContext, \
+ (DRM_LOCK_HELD | rmesa->dri.hwContext), __ret ); \
+ if ( __ret ) \
+ radeonGetLock( rmesa, 0 ); \
+ DEBUG_LOCK(); \
+ } while (0)
+
+#define UNLOCK_HARDWARE( rmesa ) \
+ do { \
+ DRM_UNLOCK( rmesa->dri.fd, \
+ rmesa->dri.hwLock, \
+ rmesa->dri.hwContext ); \
+ DEBUG_RESET(); \
+ } while (0)
+
+#endif /* __RADEON_LOCK_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos.c
new file mode 100644
index 000000000..c62edd715
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos.c
@@ -0,0 +1,12 @@
+
+
+/* If using new packets, can choose either verts or arrays.
+ * Otherwise, must use verts.
+ */
+#include "radeon_context.h"
+#define RADEON_MAOS_VERTS 1
+#if (RADEON_MAOS_VERTS) || (RADEON_OLD_PACKETS)
+#include "radeon_maos_verts.c"
+#else
+#include "radeon_maos_arrays.c"
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos.h
new file mode 100644
index 000000000..09039d684
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos.h
@@ -0,0 +1,44 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_maos.h,v 1.1 2002/10/30 12:51:55 alanh Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ Tungsten Grahpics Inc., Austin, 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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __RADEON_MAOS_H__
+#define __RADEON_MAOS_H__
+
+#include "radeon_context.h"
+
+extern void radeonEmitArrays( GLcontext *ctx, GLuint inputs );
+extern void radeonReleaseArrays( GLcontext *ctx, GLuint newinputs );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos_arrays.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos_arrays.c
new file mode 100644
index 000000000..98f66898c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos_arrays.c
@@ -0,0 +1,604 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_maos_arrays.c,v 1.1 2002/10/30 12:51:55 alanh Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ Tungsten Graphics 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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "macros.h"
+
+#include "swrast_setup/swrast_setup.h"
+#include "math/m_translate.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+
+#include "radeon_context.h"
+#include "radeon_ioctl.h"
+#include "radeon_state.h"
+#include "radeon_swtcl.h"
+#include "radeon_maos.h"
+
+#if 0
+/* Usage:
+ * - from radeon_tcl_render
+ * - call radeonEmitArrays to ensure uptodate arrays in dma
+ * - emit primitives (new type?) which reference the data
+ * -- need to use elts for lineloop, quads, quadstrip/flat
+ * -- other primitives are all well-formed (need tristrip-1,fake-poly)
+ *
+ */
+static void emit_ubyte_rgba3( GLcontext *ctx,
+ struct radeon_dma_region *rvb,
+ char *data,
+ int stride,
+ int count )
+{
+ int i;
+ radeon_color_t *out = (radeon_color_t *)(rvb->start + rvb->address);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d out %p\n",
+ __FUNCTION__, count, stride, (void *)out);
+
+ for (i = 0; i < count; i++) {
+ out->red = *data;
+ out->green = *(data+1);
+ out->blue = *(data+2);
+ out->alpha = 0xFF;
+ out++;
+ data += stride;
+ }
+}
+
+static void emit_ubyte_rgba4( GLcontext *ctx,
+ struct radeon_dma_region *rvb,
+ char *data,
+ int stride,
+ int count )
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d\n",
+ __FUNCTION__, count, stride);
+
+ if (stride == 4)
+ COPY_DWORDS( out, data, count );
+ else
+ for (i = 0; i < count; i++) {
+ *out++ = LE32_TO_CPU(*(int *)data);
+ data += stride;
+ }
+}
+
+
+static void emit_ubyte_rgba( GLcontext *ctx,
+ struct radeon_dma_region *rvb,
+ char *data,
+ int size,
+ int stride,
+ int count )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s %d/%d\n", __FUNCTION__, count, size);
+
+ assert (!rvb->buf);
+
+ if (stride == 0) {
+ radeonAllocDmaRegion( rmesa, rvb, 4, 4 );
+ count = 1;
+ rvb->aos_start = GET_START(rvb);
+ rvb->aos_stride = 0;
+ rvb->aos_size = 1;
+ }
+ else {
+ radeonAllocDmaRegion( rmesa, rvb, 4 * count, 4 ); /* alignment? */
+ rvb->aos_start = GET_START(rvb);
+ rvb->aos_stride = 1;
+ rvb->aos_size = 1;
+ }
+
+ /* Emit the data
+ */
+ switch (size) {
+ case 3:
+ emit_ubyte_rgba3( ctx, rvb, data, stride, count );
+ break;
+ case 4:
+ emit_ubyte_rgba4( ctx, rvb, data, stride, count );
+ break;
+ default:
+ assert(0);
+ exit(1);
+ break;
+ }
+}
+#endif
+
+#if defined(USE_X86_ASM)
+#define COPY_DWORDS( dst, src, nr ) \
+do { \
+ int __tmp; \
+ __asm__ __volatile__( "rep ; movsl" \
+ : "=%c" (__tmp), "=D" (dst), "=S" (__tmp) \
+ : "0" (nr), \
+ "D" ((long)dst), \
+ "S" ((long)src) ); \
+} while (0)
+#else
+#define COPY_DWORDS( dst, src, nr ) \
+do { \
+ int j; \
+ for ( j = 0 ; j < nr ; j++ ) \
+ dst[j] = ((int *)src)[j]; \
+ dst += nr; \
+} while (0)
+#endif
+
+
+static void emit_vec4( GLcontext *ctx,
+ struct radeon_dma_region *rvb,
+ char *data,
+ int stride,
+ int count )
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d\n",
+ __FUNCTION__, count, stride);
+
+ if (stride == 4)
+ COPY_DWORDS( out, data, count );
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out++;
+ data += stride;
+ }
+}
+
+
+static void emit_vec8( GLcontext *ctx,
+ struct radeon_dma_region *rvb,
+ char *data,
+ int stride,
+ int count )
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d\n",
+ __FUNCTION__, count, stride);
+
+ if (stride == 8)
+ COPY_DWORDS( out, data, count*2 );
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out[1] = *(int *)(data+4);
+ out += 2;
+ data += stride;
+ }
+}
+
+static void emit_vec12( GLcontext *ctx,
+ struct radeon_dma_region *rvb,
+ char *data,
+ int stride,
+ int count )
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d out %p data %p\n",
+ __FUNCTION__, count, stride, (void *)out, (void *)data);
+
+ if (stride == 12)
+ COPY_DWORDS( out, data, count*3 );
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out[1] = *(int *)(data+4);
+ out[2] = *(int *)(data+8);
+ out += 3;
+ data += stride;
+ }
+}
+
+static void emit_vec16( GLcontext *ctx,
+ struct radeon_dma_region *rvb,
+ char *data,
+ int stride,
+ int count )
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d\n",
+ __FUNCTION__, count, stride);
+
+ if (stride == 16)
+ COPY_DWORDS( out, data, count*4 );
+ else
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out[1] = *(int *)(data+4);
+ out[2] = *(int *)(data+8);
+ out[3] = *(int *)(data+12);
+ out += 4;
+ data += stride;
+ }
+}
+
+
+static void emit_vector( GLcontext *ctx,
+ struct radeon_dma_region *rvb,
+ char *data,
+ int size,
+ int stride,
+ int count )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d size %d stride %d\n",
+ __FUNCTION__, count, size, stride);
+
+ assert (!rvb->buf);
+
+ if (stride == 0) {
+ radeonAllocDmaRegion( rmesa, rvb, size * 4, 4 );
+ count = 1;
+ rvb->aos_start = GET_START(rvb);
+ rvb->aos_stride = 0;
+ rvb->aos_size = size;
+ }
+ else {
+ radeonAllocDmaRegion( rmesa, rvb, size * count * 4, 4 ); /* alignment? */
+ rvb->aos_start = GET_START(rvb);
+ rvb->aos_stride = size;
+ rvb->aos_size = size;
+ }
+
+ /* Emit the data
+ */
+ switch (size) {
+ case 1:
+ emit_vec4( ctx, rvb, data, stride, count );
+ break;
+ case 2:
+ emit_vec8( ctx, rvb, data, stride, count );
+ break;
+ case 3:
+ emit_vec12( ctx, rvb, data, stride, count );
+ break;
+ case 4:
+ emit_vec16( ctx, rvb, data, stride, count );
+ break;
+ default:
+ assert(0);
+ exit(1);
+ break;
+ }
+
+}
+
+
+
+static void emit_s0_vec( GLcontext *ctx,
+ struct radeon_dma_region *rvb,
+ char *data,
+ int stride,
+ int count )
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d\n",
+ __FUNCTION__, count, stride);
+
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out[1] = 0;
+ out += 2;
+ data += stride;
+ }
+}
+
+static void emit_stq_vec( GLcontext *ctx,
+ struct radeon_dma_region *rvb,
+ char *data,
+ int stride,
+ int count )
+{
+ int i;
+ int *out = (int *)(rvb->address + rvb->start);
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s count %d stride %d\n",
+ __FUNCTION__, count, stride);
+
+ for (i = 0; i < count; i++) {
+ out[0] = *(int *)data;
+ out[1] = *(int *)(data+4);
+ out[2] = *(int *)(data+12);
+ out += 3;
+ data += stride;
+ }
+}
+
+
+
+
+static void emit_tex_vector( GLcontext *ctx,
+ struct radeon_dma_region *rvb,
+ char *data,
+ int size,
+ int stride,
+ int count )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ int emitsize;
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s %d/%d\n", __FUNCTION__, count, size);
+
+ assert (!rvb->buf);
+
+ switch (size) {
+ case 4: emitsize = 3; break;
+ default: emitsize = 2; break;
+ }
+
+
+ if (stride == 0) {
+ radeonAllocDmaRegion( rmesa, rvb, 4 * emitsize, 4 );
+ count = 1;
+ rvb->aos_start = GET_START(rvb);
+ rvb->aos_stride = 0;
+ rvb->aos_size = emitsize;
+ }
+ else {
+ radeonAllocDmaRegion( rmesa, rvb, 4 * emitsize * count, 4 );
+ rvb->aos_start = GET_START(rvb);
+ rvb->aos_stride = emitsize;
+ rvb->aos_size = emitsize;
+ }
+
+
+ /* Emit the data
+ */
+ switch (size) {
+ case 1:
+ emit_s0_vec( ctx, rvb, data, stride, count );
+ break;
+ case 2:
+ emit_vec8( ctx, rvb, data, stride, count );
+ break;
+ case 3:
+ emit_vec8( ctx, rvb, data, stride, count );
+ break;
+ case 4:
+ emit_stq_vec( ctx, rvb, data, stride, count );
+ break;
+ default:
+ assert(0);
+ exit(1);
+ break;
+ }
+}
+
+
+
+
+/* Emit any changed arrays to new GART memory, re-emit a packet to
+ * update the arrays.
+ */
+void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+ struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
+ struct radeon_dma_region **component = rmesa->tcl.aos_components;
+ GLuint nr = 0;
+ GLuint vfmt = 0;
+ GLuint count = VB->Count;
+ GLuint vtx;
+
+#if 0
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ _tnl_print_vert_flags( __FUNCTION__, inputs );
+#endif
+
+ if (1) {
+ if (!rmesa->tcl.obj.buf)
+ emit_vector( ctx,
+ &rmesa->tcl.obj,
+ (char *)VB->ObjPtr->data,
+ VB->ObjPtr->size,
+ VB->ObjPtr->stride,
+ count);
+
+ switch( VB->ObjPtr->size ) {
+ case 4: vfmt |= RADEON_CP_VC_FRMT_W0;
+ case 3: vfmt |= RADEON_CP_VC_FRMT_Z;
+ case 2: vfmt |= RADEON_CP_VC_FRMT_XY;
+ default:
+ break;
+ }
+ component[nr++] = &rmesa->tcl.obj;
+ }
+
+
+ if (inputs & VERT_BIT_NORMAL) {
+ if (!rmesa->tcl.norm.buf)
+ emit_vector( ctx,
+ &(rmesa->tcl.norm),
+ (char *)VB->NormalPtr->data,
+ 3,
+ VB->NormalPtr->stride,
+ count);
+
+ vfmt |= RADEON_CP_VC_FRMT_N0;
+ component[nr++] = &rmesa->tcl.norm;
+ }
+
+ if (inputs & VERT_BIT_COLOR0) {
+ int emitsize;
+ if (VB->ColorPtr[0]->size == 4 &&
+ (VB->ColorPtr[0]->stride != 0 ||
+ VB->ColorPtr[0]->data[0][3] != 1.0)) {
+ vfmt |= RADEON_CP_VC_FRMT_FPCOLOR | RADEON_CP_VC_FRMT_FPALPHA;
+ emitsize = 4;
+ }
+
+ else {
+ vfmt |= RADEON_CP_VC_FRMT_FPCOLOR;
+ emitsize = 3;
+ }
+
+ if (!rmesa->tcl.rgba.buf)
+ emit_vector( ctx,
+ &(rmesa->tcl.rgba),
+ (char *)VB->ColorPtr[0]->data,
+ emitsize,
+ VB->ColorPtr[0]->stride,
+ count);
+
+
+ component[nr++] = &rmesa->tcl.rgba;
+ }
+
+
+ if (inputs & VERT_BIT_COLOR1) {
+ if (!rmesa->tcl.spec.buf) {
+
+ emit_vector( ctx,
+ &rmesa->tcl.spec,
+ (char *)VB->SecondaryColorPtr[0]->data,
+ 3,
+ VB->SecondaryColorPtr[0]->stride,
+ count);
+ }
+
+ vfmt |= RADEON_CP_VC_FRMT_FPSPEC;
+ component[nr++] = &rmesa->tcl.spec;
+ }
+
+ vtx = (rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] &
+ ~(RADEON_TCL_VTX_Q0|RADEON_TCL_VTX_Q1));
+
+ if (inputs & VERT_BIT_TEX0) {
+ if (!rmesa->tcl.tex[0].buf)
+ emit_tex_vector( ctx,
+ &(rmesa->tcl.tex[0]),
+ (char *)VB->TexCoordPtr[0]->data,
+ VB->TexCoordPtr[0]->size,
+ VB->TexCoordPtr[0]->stride,
+ count );
+
+ switch( VB->TexCoordPtr[0]->size ) {
+ case 4:
+ vtx |= RADEON_TCL_VTX_Q0;
+ vfmt |= RADEON_CP_VC_FRMT_Q0;
+ default:
+ vfmt |= RADEON_CP_VC_FRMT_ST0;
+ }
+ component[nr++] = &rmesa->tcl.tex[0];
+ }
+
+ if (inputs & VERT_BIT_TEX1) {
+ if (!rmesa->tcl.tex[1].buf)
+ emit_tex_vector( ctx,
+ &(rmesa->tcl.tex[1]),
+ (char *)VB->TexCoordPtr[1]->data,
+ VB->TexCoordPtr[1]->size,
+ VB->TexCoordPtr[1]->stride,
+ count );
+
+ switch( VB->TexCoordPtr[1]->size ) {
+ case 4:
+ vtx |= RADEON_TCL_VTX_Q1;
+ vfmt |= RADEON_CP_VC_FRMT_Q1;
+ default:
+ vfmt |= RADEON_CP_VC_FRMT_ST1;
+ }
+ component[nr++] = &rmesa->tcl.tex[1];
+ }
+
+ if (vtx != rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT]) {
+ RADEON_STATECHANGE( rmesa, tcl );
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] = vtx;
+ }
+
+ rmesa->tcl.nr_aos_components = nr;
+ rmesa->tcl.vertex_format = vfmt;
+}
+
+
+void radeonReleaseArrays( GLcontext *ctx, GLuint newinputs )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+
+#if 0
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ _tnl_print_vert_flags( __FUNCTION__, newinputs );
+#endif
+
+ if (newinputs & VERT_BIT_POS)
+ radeonReleaseDmaRegion( rmesa, &rmesa->tcl.obj, __FUNCTION__ );
+
+ if (newinputs & VERT_BIT_NORMAL)
+ radeonReleaseDmaRegion( rmesa, &rmesa->tcl.norm, __FUNCTION__ );
+
+ if (newinputs & VERT_BIT_COLOR0)
+ radeonReleaseDmaRegion( rmesa, &rmesa->tcl.rgba, __FUNCTION__ );
+
+ if (newinputs & VERT_BIT_COLOR1)
+ radeonReleaseDmaRegion( rmesa, &rmesa->tcl.spec, __FUNCTION__ );
+
+ if (newinputs & VERT_BIT_TEX0)
+ radeonReleaseDmaRegion( rmesa, &rmesa->tcl.tex[0], __FUNCTION__ );
+
+ if (newinputs & VERT_BIT_TEX1)
+ radeonReleaseDmaRegion( rmesa, &rmesa->tcl.tex[1], __FUNCTION__ );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos_vbtmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos_vbtmp.h
new file mode 100644
index 000000000..c16234a94
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos_vbtmp.h
@@ -0,0 +1,284 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef LOCALVARS
+#define LOCALVARS
+#endif
+
+#undef TCL_DEBUG
+#ifndef TCL_DEBUG
+#define TCL_DEBUG 0
+#endif
+
+static void TAG(emit)( GLcontext *ctx,
+ GLuint start, GLuint end,
+ void *dest )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLuint (*tc0)[4], (*tc1)[4], (*tc2)[4];
+ GLfloat (*col)[4], (*spec)[4];
+ GLfloat (*fog)[4];
+ GLuint (*norm)[4];
+ GLuint tc0_stride, tc1_stride, col_stride, spec_stride, fog_stride;
+ GLuint tc2_stride, norm_stride;
+ GLuint fill_tex = 0;
+ GLuint (*coord)[4];
+ GLuint coord_stride; /* object coordinates */
+ GLubyte dummy[4];
+ int i;
+
+ union emit_union *v = (union emit_union *)dest;
+
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ coord = (GLuint (*)[4])VB->ObjPtr->data;
+ coord_stride = VB->ObjPtr->stride;
+
+ if (DO_TEX2) {
+ if (VB->TexCoordPtr[2]) {
+ const GLuint t2 = GET_TEXSOURCE(2);
+ tc2 = (GLuint (*)[4])VB->TexCoordPtr[t2]->data;
+ tc2_stride = VB->TexCoordPtr[t2]->stride;
+ if (DO_PTEX && VB->TexCoordPtr[t2]->size < 4) {
+ fill_tex |= (1<<2);
+ }
+ } else {
+ tc2 = (GLuint (*)[4])&ctx->Current.Attrib[VERT_ATTRIB_TEX2];
+ tc2_stride = 0;
+ }
+ }
+
+ if (DO_TEX1) {
+ if (VB->TexCoordPtr[1]) {
+ const GLuint t1 = GET_TEXSOURCE(1);
+ tc1 = (GLuint (*)[4])VB->TexCoordPtr[t1]->data;
+ tc1_stride = VB->TexCoordPtr[t1]->stride;
+ if (DO_PTEX && VB->TexCoordPtr[t1]->size < 4) {
+ fill_tex |= (1<<1);
+ }
+ } else {
+ tc1 = (GLuint (*)[4])&ctx->Current.Attrib[VERT_ATTRIB_TEX1];
+ tc1_stride = 0;
+ }
+ }
+
+ if (DO_TEX0) {
+ if (VB->TexCoordPtr[0]) {
+ const GLuint t0 = GET_TEXSOURCE(0);
+ tc0_stride = VB->TexCoordPtr[t0]->stride;
+ tc0 = (GLuint (*)[4])VB->TexCoordPtr[t0]->data;
+ if (DO_PTEX && VB->TexCoordPtr[t0]->size < 4) {
+ fill_tex |= (1<<0);
+ }
+ } else {
+ tc0 = (GLuint (*)[4])&ctx->Current.Attrib[VERT_ATTRIB_TEX0];
+ tc0_stride = 0;
+ }
+
+ }
+
+ if (DO_NORM) {
+ if (VB->NormalPtr) {
+ norm_stride = VB->NormalPtr->stride;
+ norm = (GLuint (*)[4])VB->NormalPtr->data;
+ } else {
+ norm_stride = 0;
+ norm = (GLuint (*)[4])&ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
+ }
+ }
+
+ if (DO_RGBA) {
+ if (VB->ColorPtr[0]) {
+ col = VB->ColorPtr[0]->data;
+ col_stride = VB->ColorPtr[0]->stride;
+ } else {
+ col = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
+ col_stride = 0;
+ }
+ }
+
+ if (DO_SPEC) {
+ if (VB->SecondaryColorPtr[0]) {
+ spec = VB->SecondaryColorPtr[0]->data;
+ spec_stride = VB->SecondaryColorPtr[0]->stride;
+ } else {
+ spec = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
+ spec_stride = 0;
+ }
+ }
+
+ if (DO_FOG) {
+ if (VB->FogCoordPtr) {
+ fog = VB->FogCoordPtr->data;
+ fog_stride = VB->FogCoordPtr->stride;
+ } else {
+ fog = (GLfloat (*)[4])&dummy; fog[0][0] = 0.0F;
+ fog_stride = 0;
+ }
+ }
+
+
+ if (start) {
+ coord = (GLuint (*)[4])((GLubyte *)coord + start * coord_stride);
+ if (DO_TEX0)
+ tc0 = (GLuint (*)[4])((GLubyte *)tc0 + start * tc0_stride);
+ if (DO_TEX1)
+ tc1 = (GLuint (*)[4])((GLubyte *)tc1 + start * tc1_stride);
+ if (DO_TEX2)
+ tc2 = (GLuint (*)[4])((GLubyte *)tc2 + start * tc2_stride);
+ if (DO_NORM)
+ norm = (GLuint (*)[4])((GLubyte *)norm + start * norm_stride);
+ if (DO_RGBA)
+ STRIDE_4F(col, start * col_stride);
+ if (DO_SPEC)
+ STRIDE_4F(spec, start * spec_stride);
+ if (DO_FOG)
+ STRIDE_4F(fog, start * fog_stride);
+ }
+
+
+ {
+ for (i=start; i < end; i++) {
+
+ v[0].ui = coord[0][0];
+ v[1].ui = coord[0][1];
+ v[2].ui = coord[0][2];
+ if (DO_W) {
+ v[3].ui = coord[0][3];
+ v += 4;
+ }
+ else
+ v += 3;
+ coord = (GLuint (*)[4])((GLubyte *)coord + coord_stride);
+
+ if (DO_NORM) {
+ v[0].ui = norm[0][0];
+ v[1].ui = norm[0][1];
+ v[2].ui = norm[0][2];
+ v += 3;
+ norm = (GLuint (*)[4])((GLubyte *)norm + norm_stride);
+ }
+ if (DO_RGBA) {
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0].rgba.red, col[0][0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0].rgba.green, col[0][1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0].rgba.blue, col[0][2]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0].rgba.alpha, col[0][3]);
+ STRIDE_4F(col, col_stride);
+ v++;
+ }
+ if (DO_SPEC || DO_FOG) {
+ if (DO_SPEC) {
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0].rgba.red, spec[0][0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0].rgba.green, spec[0][1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0].rgba.blue, spec[0][2]);
+ STRIDE_4F(spec, spec_stride);
+ }
+ if (DO_FOG) {
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0].rgba.alpha, fog[0][0]);
+ fog = (GLfloat (*)[4])((GLubyte *)fog + fog_stride);
+ }
+ if (TCL_DEBUG) fprintf(stderr, "%x ", v[0].ui);
+ v++;
+ }
+ if (DO_TEX0) {
+ v[0].ui = tc0[0][0];
+ v[1].ui = tc0[0][1];
+ if (TCL_DEBUG) fprintf(stderr, "t0: %.2f %.2f ", v[0].f, v[1].f);
+ if (DO_PTEX) {
+ if (fill_tex & (1<<0))
+ v[2].f = 1.0;
+ else
+ v[2].ui = tc0[0][3];
+ if (TCL_DEBUG) fprintf(stderr, "%.2f ", v[2].f);
+ v += 3;
+ }
+ else
+ v += 2;
+ tc0 = (GLuint (*)[4])((GLubyte *)tc0 + tc0_stride);
+ }
+ if (DO_TEX1) {
+ v[0].ui = tc1[0][0];
+ v[1].ui = tc1[0][1];
+ if (TCL_DEBUG) fprintf(stderr, "t1: %.2f %.2f ", v[0].f, v[1].f);
+ if (DO_PTEX) {
+ if (fill_tex & (1<<1))
+ v[2].f = 1.0;
+ else
+ v[2].ui = tc1[0][3];
+ if (TCL_DEBUG) fprintf(stderr, "%.2f ", v[2].f);
+ v += 3;
+ }
+ else
+ v += 2;
+ tc1 = (GLuint (*)[4])((GLubyte *)tc1 + tc1_stride);
+ }
+ if (DO_TEX2) {
+ v[0].ui = tc2[0][0];
+ v[1].ui = tc2[0][1];
+ if (DO_PTEX) {
+ if (fill_tex & (1<<2))
+ v[2].f = 1.0;
+ else
+ v[2].ui = tc2[0][3];
+ v += 3;
+ }
+ else
+ v += 2;
+ tc2 = (GLuint (*)[4])((GLubyte *)tc2 + tc2_stride);
+ }
+ if (TCL_DEBUG) fprintf(stderr, "\n");
+ }
+ }
+}
+
+
+
+static void TAG(init)( void )
+{
+ int sz = 3;
+ if (DO_W) sz++;
+ if (DO_NORM) sz += 3;
+ if (DO_RGBA) sz++;
+ if (DO_SPEC || DO_FOG) sz++;
+ if (DO_TEX0) sz += 2;
+ if (DO_TEX0 && DO_PTEX) sz++;
+ if (DO_TEX1) sz += 2;
+ if (DO_TEX1 && DO_PTEX) sz++;
+ if (DO_TEX2) sz += 2;
+ if (DO_TEX2 && DO_PTEX) sz++;
+
+ setup_tab[IDX].emit = TAG(emit);
+ setup_tab[IDX].vertex_format = IND;
+ setup_tab[IDX].vertex_size = sz;
+}
+
+
+#undef IND
+#undef TAG
+#undef IDX
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos_verts.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos_verts.c
new file mode 100644
index 000000000..8cb08a812
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_maos_verts.c
@@ -0,0 +1,367 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_maos_verts.c,v 1.1 2002/10/30 12:51:55 alanh Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ Tungsten Graphics Inc., Austin, 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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "mtypes.h"
+
+#include "array_cache/acache.h"
+#include "math/m_translate.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+#include "math/m_translate.h"
+#include "radeon_context.h"
+#include "radeon_state.h"
+#include "radeon_ioctl.h"
+#include "radeon_tex.h"
+#include "radeon_tcl.h"
+#include "radeon_swtcl.h"
+#include "radeon_maos.h"
+
+
+#define RADEON_TCL_MAX_SETUP 13
+
+union emit_union { float f; GLuint ui; radeon_color_t rgba; };
+
+static struct {
+ void (*emit)( GLcontext *, GLuint, GLuint, void * );
+ GLuint vertex_size;
+ GLuint vertex_format;
+} setup_tab[RADEON_TCL_MAX_SETUP];
+
+#define DO_W (IND & RADEON_CP_VC_FRMT_W0)
+#define DO_RGBA (IND & RADEON_CP_VC_FRMT_PKCOLOR)
+#define DO_SPEC (IND & RADEON_CP_VC_FRMT_PKSPEC)
+#define DO_FOG (IND & RADEON_CP_VC_FRMT_PKSPEC)
+#define DO_TEX0 (IND & RADEON_CP_VC_FRMT_ST0)
+#define DO_TEX1 (IND & RADEON_CP_VC_FRMT_ST1)
+#define DO_PTEX (IND & RADEON_CP_VC_FRMT_Q0)
+#define DO_NORM (IND & RADEON_CP_VC_FRMT_N0)
+
+#define DO_TEX2 0
+#define DO_TEX3 0
+
+#define GET_TEXSOURCE(n) n
+
+/***********************************************************************
+ * Generate vertex emit functions *
+ ***********************************************************************/
+
+
+/* Defined in order of increasing vertex size:
+ */
+#define IDX 0
+#define IND (RADEON_CP_VC_FRMT_XY| \
+ RADEON_CP_VC_FRMT_Z| \
+ RADEON_CP_VC_FRMT_PKCOLOR)
+#define TAG(x) x##_rgba
+#include "radeon_maos_vbtmp.h"
+
+#define IDX 1
+#define IND (RADEON_CP_VC_FRMT_XY| \
+ RADEON_CP_VC_FRMT_Z| \
+ RADEON_CP_VC_FRMT_N0)
+#define TAG(x) x##_n
+#include "radeon_maos_vbtmp.h"
+
+#define IDX 2
+#define IND (RADEON_CP_VC_FRMT_XY| \
+ RADEON_CP_VC_FRMT_Z| \
+ RADEON_CP_VC_FRMT_PKCOLOR| \
+ RADEON_CP_VC_FRMT_ST0)
+#define TAG(x) x##_rgba_st
+#include "radeon_maos_vbtmp.h"
+
+#define IDX 3
+#define IND (RADEON_CP_VC_FRMT_XY| \
+ RADEON_CP_VC_FRMT_Z| \
+ RADEON_CP_VC_FRMT_PKCOLOR| \
+ RADEON_CP_VC_FRMT_N0)
+#define TAG(x) x##_rgba_n
+#include "radeon_maos_vbtmp.h"
+
+#define IDX 4
+#define IND (RADEON_CP_VC_FRMT_XY| \
+ RADEON_CP_VC_FRMT_Z| \
+ RADEON_CP_VC_FRMT_ST0| \
+ RADEON_CP_VC_FRMT_N0)
+#define TAG(x) x##_st_n
+#include "radeon_maos_vbtmp.h"
+
+#define IDX 5
+#define IND (RADEON_CP_VC_FRMT_XY| \
+ RADEON_CP_VC_FRMT_Z| \
+ RADEON_CP_VC_FRMT_PKCOLOR| \
+ RADEON_CP_VC_FRMT_ST0| \
+ RADEON_CP_VC_FRMT_ST1)
+#define TAG(x) x##_rgba_st_st
+#include "radeon_maos_vbtmp.h"
+
+#define IDX 6
+#define IND (RADEON_CP_VC_FRMT_XY| \
+ RADEON_CP_VC_FRMT_Z| \
+ RADEON_CP_VC_FRMT_PKCOLOR| \
+ RADEON_CP_VC_FRMT_ST0| \
+ RADEON_CP_VC_FRMT_N0)
+#define TAG(x) x##_rgba_st_n
+#include "radeon_maos_vbtmp.h"
+
+#define IDX 7
+#define IND (RADEON_CP_VC_FRMT_XY| \
+ RADEON_CP_VC_FRMT_Z| \
+ RADEON_CP_VC_FRMT_PKCOLOR| \
+ RADEON_CP_VC_FRMT_PKSPEC| \
+ RADEON_CP_VC_FRMT_ST0| \
+ RADEON_CP_VC_FRMT_ST1)
+#define TAG(x) x##_rgba_spec_st_st
+#include "radeon_maos_vbtmp.h"
+
+#define IDX 8
+#define IND (RADEON_CP_VC_FRMT_XY| \
+ RADEON_CP_VC_FRMT_Z| \
+ RADEON_CP_VC_FRMT_ST0| \
+ RADEON_CP_VC_FRMT_ST1| \
+ RADEON_CP_VC_FRMT_N0)
+#define TAG(x) x##_st_st_n
+#include "radeon_maos_vbtmp.h"
+
+#define IDX 9
+#define IND (RADEON_CP_VC_FRMT_XY| \
+ RADEON_CP_VC_FRMT_Z| \
+ RADEON_CP_VC_FRMT_PKCOLOR| \
+ RADEON_CP_VC_FRMT_PKSPEC| \
+ RADEON_CP_VC_FRMT_ST0| \
+ RADEON_CP_VC_FRMT_ST1| \
+ RADEON_CP_VC_FRMT_N0)
+#define TAG(x) x##_rgba_spec_st_st_n
+#include "radeon_maos_vbtmp.h"
+
+#define IDX 10
+#define IND (RADEON_CP_VC_FRMT_XY| \
+ RADEON_CP_VC_FRMT_Z| \
+ RADEON_CP_VC_FRMT_PKCOLOR| \
+ RADEON_CP_VC_FRMT_ST0| \
+ RADEON_CP_VC_FRMT_Q0)
+#define TAG(x) x##_rgba_stq
+#include "radeon_maos_vbtmp.h"
+
+#define IDX 11
+#define IND (RADEON_CP_VC_FRMT_XY| \
+ RADEON_CP_VC_FRMT_Z| \
+ RADEON_CP_VC_FRMT_PKCOLOR| \
+ RADEON_CP_VC_FRMT_ST1| \
+ RADEON_CP_VC_FRMT_Q1| \
+ RADEON_CP_VC_FRMT_ST0| \
+ RADEON_CP_VC_FRMT_Q0)
+#define TAG(x) x##_rgba_stq_stq
+#include "radeon_maos_vbtmp.h"
+
+#define IDX 12
+#define IND (RADEON_CP_VC_FRMT_XY| \
+ RADEON_CP_VC_FRMT_Z| \
+ RADEON_CP_VC_FRMT_W0| \
+ RADEON_CP_VC_FRMT_PKCOLOR| \
+ RADEON_CP_VC_FRMT_PKSPEC| \
+ RADEON_CP_VC_FRMT_ST0| \
+ RADEON_CP_VC_FRMT_Q0| \
+ RADEON_CP_VC_FRMT_ST1| \
+ RADEON_CP_VC_FRMT_Q1| \
+ RADEON_CP_VC_FRMT_N0)
+#define TAG(x) x##_w_rgba_spec_stq_stq_n
+#include "radeon_maos_vbtmp.h"
+
+
+
+
+
+/***********************************************************************
+ * Initialization
+ ***********************************************************************/
+
+
+static void init_tcl_verts( void )
+{
+ init_rgba();
+ init_n();
+ init_rgba_n();
+ init_rgba_st();
+ init_st_n();
+ init_rgba_st_st();
+ init_rgba_st_n();
+ init_rgba_spec_st_st();
+ init_st_st_n();
+ init_rgba_spec_st_st_n();
+ init_rgba_stq();
+ init_rgba_stq_stq();
+ init_w_rgba_spec_stq_stq_n();
+}
+
+
+void radeonEmitArrays( GLcontext *ctx, GLuint inputs )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLuint req = 0;
+ GLuint vtx = (rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] &
+ ~(RADEON_TCL_VTX_Q0|RADEON_TCL_VTX_Q1));
+ int i;
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_tcl_verts();
+ firsttime = 0;
+ }
+
+ if (1) {
+ req |= RADEON_CP_VC_FRMT_Z;
+ if (VB->ObjPtr->size == 4) {
+ req |= RADEON_CP_VC_FRMT_W0;
+ }
+ }
+
+ if (inputs & VERT_BIT_NORMAL) {
+ req |= RADEON_CP_VC_FRMT_N0;
+ }
+
+ if (inputs & VERT_BIT_COLOR0) {
+ req |= RADEON_CP_VC_FRMT_PKCOLOR;
+ }
+
+ if (inputs & VERT_BIT_COLOR1) {
+ req |= RADEON_CP_VC_FRMT_PKSPEC;
+ }
+
+ if (inputs & VERT_BIT_TEX0) {
+ req |= RADEON_CP_VC_FRMT_ST0;
+
+ if (VB->TexCoordPtr[0]->size == 4) {
+ req |= RADEON_CP_VC_FRMT_Q0;
+ vtx |= RADEON_TCL_VTX_Q0;
+ }
+ }
+
+ if (inputs & VERT_BIT_TEX1) {
+ req |= RADEON_CP_VC_FRMT_ST1;
+
+ if (VB->TexCoordPtr[1]->size == 4) {
+ req |= RADEON_CP_VC_FRMT_Q1;
+ vtx |= RADEON_TCL_VTX_Q1;
+ }
+ }
+
+ if (vtx != rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT]) {
+ RADEON_STATECHANGE( rmesa, tcl );
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] = vtx;
+ }
+
+ for (i = 0 ; i < RADEON_TCL_MAX_SETUP ; i++)
+ if ((setup_tab[i].vertex_format & req) == req)
+ break;
+
+ if (rmesa->tcl.vertex_format == setup_tab[i].vertex_format &&
+ rmesa->tcl.indexed_verts.buf)
+ return;
+
+ if (rmesa->tcl.indexed_verts.buf)
+ radeonReleaseArrays( ctx, ~0 );
+
+ radeonAllocDmaRegionVerts( rmesa,
+ &rmesa->tcl.indexed_verts,
+ VB->Count,
+ setup_tab[i].vertex_size * 4,
+ 4);
+
+ /* The vertex code expects Obj to be clean to element 3. To fix
+ * this, add more vertex code (for obj-2, obj-3) or preferably move
+ * to maos.
+ */
+ if (VB->ObjPtr->size < 3 ||
+ (VB->ObjPtr->size == 3 &&
+ (setup_tab[i].vertex_format & RADEON_CP_VC_FRMT_W0))) {
+
+ _math_trans_4f( rmesa->tcl.ObjClean.data,
+ VB->ObjPtr->data,
+ VB->ObjPtr->stride,
+ GL_FLOAT,
+ VB->ObjPtr->size,
+ 0,
+ VB->Count );
+
+ switch (VB->ObjPtr->size) {
+ case 1:
+ _mesa_vector4f_clean_elem(&rmesa->tcl.ObjClean, VB->Count, 1);
+ case 2:
+ _mesa_vector4f_clean_elem(&rmesa->tcl.ObjClean, VB->Count, 2);
+ case 3:
+ if (setup_tab[i].vertex_format & RADEON_CP_VC_FRMT_W0) {
+ _mesa_vector4f_clean_elem(&rmesa->tcl.ObjClean, VB->Count, 3);
+ }
+ case 4:
+ default:
+ break;
+ }
+
+ VB->ObjPtr = &rmesa->tcl.ObjClean;
+ }
+
+
+
+ setup_tab[i].emit( ctx, 0, VB->Count,
+ rmesa->tcl.indexed_verts.address +
+ rmesa->tcl.indexed_verts.start );
+
+ rmesa->tcl.vertex_format = setup_tab[i].vertex_format;
+ rmesa->tcl.indexed_verts.aos_start = GET_START( &rmesa->tcl.indexed_verts );
+ rmesa->tcl.indexed_verts.aos_size = setup_tab[i].vertex_size;
+ rmesa->tcl.indexed_verts.aos_stride = setup_tab[i].vertex_size;
+
+ rmesa->tcl.aos_components[0] = &rmesa->tcl.indexed_verts;
+ rmesa->tcl.nr_aos_components = 1;
+}
+
+
+
+void radeonReleaseArrays( GLcontext *ctx, GLuint newinputs )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+
+#if 0
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ _tnl_print_vert_flags( __FUNCTION__, newinputs );
+#endif
+
+ if (newinputs)
+ radeonReleaseDmaRegion( rmesa, &rmesa->tcl.indexed_verts, __FUNCTION__ );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_sanity.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_sanity.c
new file mode 100644
index 000000000..84112464e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_sanity.c
@@ -0,0 +1,1070 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_sanity.c,v 1.1 2002/10/30 12:51:55 alanh Exp $ */
+/**************************************************************************
+
+Copyright 2002 ATI Technologies Inc., Ontario, Canada, and
+ Tungsten Graphics Inc, Cedar Park, TX.
+
+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, TUNGSTEN GRAPHICS 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ *
+ */
+#include <errno.h>
+
+#include "glheader.h"
+
+#include "radeon_context.h"
+#include "radeon_ioctl.h"
+#include "radeon_sanity.h"
+
+/* Set this '1' to get more verbiage.
+ */
+#define MORE_VERBOSE 1
+
+#if MORE_VERBOSE
+#define VERBOSE (RADEON_DEBUG & DEBUG_VERBOSE)
+#define NORMAL (1)
+#else
+#define VERBOSE 0
+#define NORMAL (RADEON_DEBUG & DEBUG_VERBOSE)
+#endif
+
+
+/* New (1.3) state mechanism. 3 commands (packet, scalar, vector) in
+ * 1.3 cmdbuffers allow all previous state to be updated as well as
+ * the tcl scalar and vector areas.
+ */
+static struct {
+ int start;
+ int len;
+ const char *name;
+} packet[RADEON_MAX_STATE_PACKETS] = {
+ { RADEON_PP_MISC,7,"RADEON_PP_MISC" },
+ { RADEON_PP_CNTL,3,"RADEON_PP_CNTL" },
+ { RADEON_RB3D_COLORPITCH,1,"RADEON_RB3D_COLORPITCH" },
+ { RADEON_RE_LINE_PATTERN,2,"RADEON_RE_LINE_PATTERN" },
+ { RADEON_SE_LINE_WIDTH,1,"RADEON_SE_LINE_WIDTH" },
+ { RADEON_PP_LUM_MATRIX,1,"RADEON_PP_LUM_MATRIX" },
+ { RADEON_PP_ROT_MATRIX_0,2,"RADEON_PP_ROT_MATRIX_0" },
+ { RADEON_RB3D_STENCILREFMASK,3,"RADEON_RB3D_STENCILREFMASK" },
+ { RADEON_SE_VPORT_XSCALE,6,"RADEON_SE_VPORT_XSCALE" },
+ { RADEON_SE_CNTL,2,"RADEON_SE_CNTL" },
+ { RADEON_SE_CNTL_STATUS,1,"RADEON_SE_CNTL_STATUS" },
+ { RADEON_RE_MISC,1,"RADEON_RE_MISC" },
+ { RADEON_PP_TXFILTER_0,6,"RADEON_PP_TXFILTER_0" },
+ { RADEON_PP_BORDER_COLOR_0,1,"RADEON_PP_BORDER_COLOR_0" },
+ { RADEON_PP_TXFILTER_1,6,"RADEON_PP_TXFILTER_1" },
+ { RADEON_PP_BORDER_COLOR_1,1,"RADEON_PP_BORDER_COLOR_1" },
+ { RADEON_PP_TXFILTER_2,6,"RADEON_PP_TXFILTER_2" },
+ { RADEON_PP_BORDER_COLOR_2,1,"RADEON_PP_BORDER_COLOR_2" },
+ { RADEON_SE_ZBIAS_FACTOR,2,"RADEON_SE_ZBIAS_FACTOR" },
+ { RADEON_SE_TCL_OUTPUT_VTX_FMT,11,"RADEON_SE_TCL_OUTPUT_VTX_FMT" },
+ { RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED,17,"RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED" },
+ { 0, 4, "R200_PP_TXCBLEND_0" },
+ { 0, 4, "R200_PP_TXCBLEND_1" },
+ { 0, 4, "R200_PP_TXCBLEND_2" },
+ { 0, 4, "R200_PP_TXCBLEND_3" },
+ { 0, 4, "R200_PP_TXCBLEND_4" },
+ { 0, 4, "R200_PP_TXCBLEND_5" },
+ { 0, 4, "R200_PP_TXCBLEND_6" },
+ { 0, 4, "R200_PP_TXCBLEND_7" },
+ { 0, 6, "R200_SE_TCL_LIGHT_MODEL_CTL_0" },
+ { 0, 6, "R200_PP_TFACTOR_0" },
+ { 0, 4, "R200_SE_VTX_FMT_0" },
+ { 0, 1, "R200_SE_VAP_CNTL" },
+ { 0, 5, "R200_SE_TCL_MATRIX_SEL_0" },
+ { 0, 5, "R200_SE_TCL_TEX_PROC_CTL_2" },
+ { 0, 1, "R200_SE_TCL_UCP_VERT_BLEND_CTL" },
+ { 0, 6, "R200_PP_TXFILTER_0" },
+ { 0, 6, "R200_PP_TXFILTER_1" },
+ { 0, 6, "R200_PP_TXFILTER_2" },
+ { 0, 6, "R200_PP_TXFILTER_3" },
+ { 0, 6, "R200_PP_TXFILTER_4" },
+ { 0, 6, "R200_PP_TXFILTER_5" },
+ { 0, 1, "R200_PP_TXOFFSET_0" },
+ { 0, 1, "R200_PP_TXOFFSET_1" },
+ { 0, 1, "R200_PP_TXOFFSET_2" },
+ { 0, 1, "R200_PP_TXOFFSET_3" },
+ { 0, 1, "R200_PP_TXOFFSET_4" },
+ { 0, 1, "R200_PP_TXOFFSET_5" },
+ { 0, 1, "R200_SE_VTE_CNTL" },
+ { 0, 1, "R200_SE_TCL_OUTPUT_VTX_COMP_SEL" },
+ { 0, 1, "R200_PP_TAM_DEBUG3" },
+ { 0, 1, "R200_PP_CNTL_X" },
+ { 0, 1, "R200_RB3D_DEPTHXY_OFFSET" },
+ { 0, 1, "R200_RE_AUX_SCISSOR_CNTL" },
+ { 0, 2, "R200_RE_SCISSOR_TL_0" },
+ { 0, 2, "R200_RE_SCISSOR_TL_1" },
+ { 0, 2, "R200_RE_SCISSOR_TL_2" },
+ { 0, 1, "R200_SE_VAP_CNTL_STATUS" },
+ { 0, 1, "R200_SE_VTX_STATE_CNTL" },
+ { 0, 1, "R200_RE_POINTSIZE" },
+ { 0, 4, "R200_SE_TCL_INPUT_VTX_VECTOR_ADDR_0" },
+ { 0, 1, "R200_PP_CUBIC_FACES_0" }, /* 61 */
+ { 0, 5, "R200_PP_CUBIC_OFFSET_F1_0" }, /* 62 */
+ { 0, 1, "R200_PP_CUBIC_FACES_1" },
+ { 0, 5, "R200_PP_CUBIC_OFFSET_F1_1" },
+ { 0, 1, "R200_PP_CUBIC_FACES_2" },
+ { 0, 5, "R200_PP_CUBIC_OFFSET_F1_2" },
+ { 0, 1, "R200_PP_CUBIC_FACES_3" },
+ { 0, 5, "R200_PP_CUBIC_OFFSET_F1_3" },
+ { 0, 1, "R200_PP_CUBIC_FACES_4" },
+ { 0, 5, "R200_PP_CUBIC_OFFSET_F1_4" },
+ { 0, 1, "R200_PP_CUBIC_FACES_5" },
+ { 0, 5, "R200_PP_CUBIC_OFFSET_F1_5" },
+ { RADEON_PP_TEX_SIZE_0, 2, "RADEON_PP_TEX_SIZE_0" },
+ { RADEON_PP_TEX_SIZE_1, 2, "RADEON_PP_TEX_SIZE_1" },
+ { RADEON_PP_TEX_SIZE_2, 2, "RADEON_PP_TEX_SIZE_2" },
+ { 0, 3, "R200_RB3D_BLENDCOLOR" },
+ { 0, 1, "R200_SE_TCL_POINT_SPRITE_CNTL" },
+ { RADEON_PP_CUBIC_FACES_0, 1, "RADEON_PP_CUBIC_FACES_0" },
+ { RADEON_PP_CUBIC_OFFSET_T0_0, 5, "RADEON_PP_CUBIC_OFFSET_T0_0" },
+ { RADEON_PP_CUBIC_FACES_1, 1, "RADEON_PP_CUBIC_FACES_1" },
+ { RADEON_PP_CUBIC_OFFSET_T1_0, 5, "RADEON_PP_CUBIC_OFFSET_T1_0" },
+ { RADEON_PP_CUBIC_FACES_2, 1, "RADEON_PP_CUBIC_FACES_2" },
+ { RADEON_PP_CUBIC_OFFSET_T2_0, 5, "RADEON_PP_CUBIC_OFFSET_T2_0" },
+ { 0, 2, "R200_PP_TRI_PERF" },
+};
+
+struct reg_names {
+ int idx;
+ const char *name;
+};
+
+static struct reg_names reg_names[] = {
+ { RADEON_PP_MISC, "RADEON_PP_MISC" },
+ { RADEON_PP_FOG_COLOR, "RADEON_PP_FOG_COLOR" },
+ { RADEON_RE_SOLID_COLOR, "RADEON_RE_SOLID_COLOR" },
+ { RADEON_RB3D_BLENDCNTL, "RADEON_RB3D_BLENDCNTL" },
+ { RADEON_RB3D_DEPTHOFFSET, "RADEON_RB3D_DEPTHOFFSET" },
+ { RADEON_RB3D_DEPTHPITCH, "RADEON_RB3D_DEPTHPITCH" },
+ { RADEON_RB3D_ZSTENCILCNTL, "RADEON_RB3D_ZSTENCILCNTL" },
+ { RADEON_PP_CNTL, "RADEON_PP_CNTL" },
+ { RADEON_RB3D_CNTL, "RADEON_RB3D_CNTL" },
+ { RADEON_RB3D_COLOROFFSET, "RADEON_RB3D_COLOROFFSET" },
+ { RADEON_RB3D_COLORPITCH, "RADEON_RB3D_COLORPITCH" },
+ { RADEON_SE_CNTL, "RADEON_SE_CNTL" },
+ { RADEON_SE_COORD_FMT, "RADEON_SE_COORDFMT" },
+ { RADEON_SE_CNTL_STATUS, "RADEON_SE_CNTL_STATUS" },
+ { RADEON_RE_LINE_PATTERN, "RADEON_RE_LINE_PATTERN" },
+ { RADEON_RE_LINE_STATE, "RADEON_RE_LINE_STATE" },
+ { RADEON_SE_LINE_WIDTH, "RADEON_SE_LINE_WIDTH" },
+ { RADEON_RB3D_STENCILREFMASK, "RADEON_RB3D_STENCILREFMASK" },
+ { RADEON_RB3D_ROPCNTL, "RADEON_RB3D_ROPCNTL" },
+ { RADEON_RB3D_PLANEMASK, "RADEON_RB3D_PLANEMASK" },
+ { RADEON_SE_VPORT_XSCALE, "RADEON_SE_VPORT_XSCALE" },
+ { RADEON_SE_VPORT_XOFFSET, "RADEON_SE_VPORT_XOFFSET" },
+ { RADEON_SE_VPORT_YSCALE, "RADEON_SE_VPORT_YSCALE" },
+ { RADEON_SE_VPORT_YOFFSET, "RADEON_SE_VPORT_YOFFSET" },
+ { RADEON_SE_VPORT_ZSCALE, "RADEON_SE_VPORT_ZSCALE" },
+ { RADEON_SE_VPORT_ZOFFSET, "RADEON_SE_VPORT_ZOFFSET" },
+ { RADEON_RE_MISC, "RADEON_RE_MISC" },
+ { RADEON_PP_TXFILTER_0, "RADEON_PP_TXFILTER_0" },
+ { RADEON_PP_TXFILTER_1, "RADEON_PP_TXFILTER_1" },
+ { RADEON_PP_TXFILTER_2, "RADEON_PP_TXFILTER_2" },
+ { RADEON_PP_TXFORMAT_0, "RADEON_PP_TXFORMAT_0" },
+ { RADEON_PP_TXFORMAT_1, "RADEON_PP_TXFORMAT_1" },
+ { RADEON_PP_TXFORMAT_2, "RADEON_PP_TXFORMAT_2" },
+ { RADEON_PP_TXOFFSET_0, "RADEON_PP_TXOFFSET_0" },
+ { RADEON_PP_TXOFFSET_1, "RADEON_PP_TXOFFSET_1" },
+ { RADEON_PP_TXOFFSET_2, "RADEON_PP_TXOFFSET_2" },
+ { RADEON_PP_TXCBLEND_0, "RADEON_PP_TXCBLEND_0" },
+ { RADEON_PP_TXCBLEND_1, "RADEON_PP_TXCBLEND_1" },
+ { RADEON_PP_TXCBLEND_2, "RADEON_PP_TXCBLEND_2" },
+ { RADEON_PP_TXABLEND_0, "RADEON_PP_TXABLEND_0" },
+ { RADEON_PP_TXABLEND_1, "RADEON_PP_TXABLEND_1" },
+ { RADEON_PP_TXABLEND_2, "RADEON_PP_TXABLEND_2" },
+ { RADEON_PP_TFACTOR_0, "RADEON_PP_TFACTOR_0" },
+ { RADEON_PP_TFACTOR_1, "RADEON_PP_TFACTOR_1" },
+ { RADEON_PP_TFACTOR_2, "RADEON_PP_TFACTOR_2" },
+ { RADEON_PP_BORDER_COLOR_0, "RADEON_PP_BORDER_COLOR_0" },
+ { RADEON_PP_BORDER_COLOR_1, "RADEON_PP_BORDER_COLOR_1" },
+ { RADEON_PP_BORDER_COLOR_2, "RADEON_PP_BORDER_COLOR_2" },
+ { RADEON_SE_ZBIAS_FACTOR, "RADEON_SE_ZBIAS_FACTOR" },
+ { RADEON_SE_ZBIAS_CONSTANT, "RADEON_SE_ZBIAS_CONSTANT" },
+ { RADEON_SE_TCL_OUTPUT_VTX_FMT, "RADEON_SE_TCL_OUTPUT_VTXFMT" },
+ { RADEON_SE_TCL_OUTPUT_VTX_SEL, "RADEON_SE_TCL_OUTPUT_VTXSEL" },
+ { RADEON_SE_TCL_MATRIX_SELECT_0, "RADEON_SE_TCL_MATRIX_SELECT_0" },
+ { RADEON_SE_TCL_MATRIX_SELECT_1, "RADEON_SE_TCL_MATRIX_SELECT_1" },
+ { RADEON_SE_TCL_UCP_VERT_BLEND_CTL, "RADEON_SE_TCL_UCP_VERT_BLEND_CTL" },
+ { RADEON_SE_TCL_TEXTURE_PROC_CTL, "RADEON_SE_TCL_TEXTURE_PROC_CTL" },
+ { RADEON_SE_TCL_LIGHT_MODEL_CTL, "RADEON_SE_TCL_LIGHT_MODEL_CTL" },
+ { RADEON_SE_TCL_PER_LIGHT_CTL_0, "RADEON_SE_TCL_PER_LIGHT_CTL_0" },
+ { RADEON_SE_TCL_PER_LIGHT_CTL_1, "RADEON_SE_TCL_PER_LIGHT_CTL_1" },
+ { RADEON_SE_TCL_PER_LIGHT_CTL_2, "RADEON_SE_TCL_PER_LIGHT_CTL_2" },
+ { RADEON_SE_TCL_PER_LIGHT_CTL_3, "RADEON_SE_TCL_PER_LIGHT_CTL_3" },
+ { RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED, "RADEON_SE_TCL_EMMISSIVE_RED" },
+ { RADEON_SE_TCL_MATERIAL_EMMISSIVE_GREEN, "RADEON_SE_TCL_EMMISSIVE_GREEN" },
+ { RADEON_SE_TCL_MATERIAL_EMMISSIVE_BLUE, "RADEON_SE_TCL_EMMISSIVE_BLUE" },
+ { RADEON_SE_TCL_MATERIAL_EMMISSIVE_ALPHA, "RADEON_SE_TCL_EMMISSIVE_ALPHA" },
+ { RADEON_SE_TCL_MATERIAL_AMBIENT_RED, "RADEON_SE_TCL_AMBIENT_RED" },
+ { RADEON_SE_TCL_MATERIAL_AMBIENT_GREEN, "RADEON_SE_TCL_AMBIENT_GREEN" },
+ { RADEON_SE_TCL_MATERIAL_AMBIENT_BLUE, "RADEON_SE_TCL_AMBIENT_BLUE" },
+ { RADEON_SE_TCL_MATERIAL_AMBIENT_ALPHA, "RADEON_SE_TCL_AMBIENT_ALPHA" },
+ { RADEON_SE_TCL_MATERIAL_DIFFUSE_RED, "RADEON_SE_TCL_DIFFUSE_RED" },
+ { RADEON_SE_TCL_MATERIAL_DIFFUSE_GREEN, "RADEON_SE_TCL_DIFFUSE_GREEN" },
+ { RADEON_SE_TCL_MATERIAL_DIFFUSE_BLUE, "RADEON_SE_TCL_DIFFUSE_BLUE" },
+ { RADEON_SE_TCL_MATERIAL_DIFFUSE_ALPHA, "RADEON_SE_TCL_DIFFUSE_ALPHA" },
+ { RADEON_SE_TCL_MATERIAL_SPECULAR_RED, "RADEON_SE_TCL_SPECULAR_RED" },
+ { RADEON_SE_TCL_MATERIAL_SPECULAR_GREEN, "RADEON_SE_TCL_SPECULAR_GREEN" },
+ { RADEON_SE_TCL_MATERIAL_SPECULAR_BLUE, "RADEON_SE_TCL_SPECULAR_BLUE" },
+ { RADEON_SE_TCL_MATERIAL_SPECULAR_ALPHA, "RADEON_SE_TCL_SPECULAR_ALPHA" },
+ { RADEON_SE_TCL_SHININESS, "RADEON_SE_TCL_SHININESS" },
+ { RADEON_SE_COORD_FMT, "RADEON_SE_COORD_FMT" },
+ { RADEON_PP_TEX_SIZE_0, "RADEON_PP_TEX_SIZE_0" },
+ { RADEON_PP_TEX_SIZE_1, "RADEON_PP_TEX_SIZE_1" },
+ { RADEON_PP_TEX_SIZE_2, "RADEON_PP_TEX_SIZE_2" },
+ { RADEON_PP_TEX_SIZE_0+4, "RADEON_PP_TEX_PITCH_0" },
+ { RADEON_PP_TEX_SIZE_1+4, "RADEON_PP_TEX_PITCH_1" },
+ { RADEON_PP_TEX_SIZE_2+4, "RADEON_PP_TEX_PITCH_2" },
+ { RADEON_PP_CUBIC_FACES_0, "RADEON_PP_CUBIC_FACES_0" },
+ { RADEON_PP_CUBIC_FACES_1, "RADEON_PP_CUBIC_FACES_1" },
+ { RADEON_PP_CUBIC_FACES_2, "RADEON_PP_CUBIC_FACES_2" },
+ { RADEON_PP_CUBIC_OFFSET_T0_0, "RADEON_PP_CUBIC_OFFSET_T0_0" },
+ { RADEON_PP_CUBIC_OFFSET_T0_1, "RADEON_PP_CUBIC_OFFSET_T0_1" },
+ { RADEON_PP_CUBIC_OFFSET_T0_2, "RADEON_PP_CUBIC_OFFSET_T0_2" },
+ { RADEON_PP_CUBIC_OFFSET_T0_3, "RADEON_PP_CUBIC_OFFSET_T0_3" },
+ { RADEON_PP_CUBIC_OFFSET_T0_4, "RADEON_PP_CUBIC_OFFSET_T0_4" },
+ { RADEON_PP_CUBIC_OFFSET_T1_0, "RADEON_PP_CUBIC_OFFSET_T1_0" },
+ { RADEON_PP_CUBIC_OFFSET_T1_1, "RADEON_PP_CUBIC_OFFSET_T1_1" },
+ { RADEON_PP_CUBIC_OFFSET_T1_2, "RADEON_PP_CUBIC_OFFSET_T1_2" },
+ { RADEON_PP_CUBIC_OFFSET_T1_3, "RADEON_PP_CUBIC_OFFSET_T1_3" },
+ { RADEON_PP_CUBIC_OFFSET_T1_4, "RADEON_PP_CUBIC_OFFSET_T1_4" },
+ { RADEON_PP_CUBIC_OFFSET_T2_0, "RADEON_PP_CUBIC_OFFSET_T2_0" },
+ { RADEON_PP_CUBIC_OFFSET_T2_1, "RADEON_PP_CUBIC_OFFSET_T2_1" },
+ { RADEON_PP_CUBIC_OFFSET_T2_2, "RADEON_PP_CUBIC_OFFSET_T2_2" },
+ { RADEON_PP_CUBIC_OFFSET_T2_3, "RADEON_PP_CUBIC_OFFSET_T2_3" },
+ { RADEON_PP_CUBIC_OFFSET_T2_4, "RADEON_PP_CUBIC_OFFSET_T2_4" },
+};
+
+static struct reg_names scalar_names[] = {
+ { RADEON_SS_LIGHT_DCD_ADDR, "LIGHT_DCD" },
+ { RADEON_SS_LIGHT_SPOT_EXPONENT_ADDR, "LIGHT_SPOT_EXPONENT" },
+ { RADEON_SS_LIGHT_SPOT_CUTOFF_ADDR, "LIGHT_SPOT_CUTOFF" },
+ { RADEON_SS_LIGHT_SPECULAR_THRESH_ADDR, "LIGHT_SPECULAR_THRESH" },
+ { RADEON_SS_LIGHT_RANGE_CUTOFF_ADDR, "LIGHT_RANGE_CUTOFF" },
+ { RADEON_SS_VERT_GUARD_CLIP_ADJ_ADDR, "VERT_GUARD_CLIP" },
+ { RADEON_SS_VERT_GUARD_DISCARD_ADJ_ADDR, "VERT_GUARD_DISCARD" },
+ { RADEON_SS_HORZ_GUARD_CLIP_ADJ_ADDR, "HORZ_GUARD_CLIP" },
+ { RADEON_SS_HORZ_GUARD_DISCARD_ADJ_ADDR, "HORZ_GUARD_DISCARD" },
+ { RADEON_SS_SHININESS, "SHININESS" },
+ { 1000, "" },
+};
+
+/* Puff these out to make them look like normal (dword) registers.
+ */
+static struct reg_names vector_names[] = {
+ { RADEON_VS_MATRIX_0_ADDR * 4, "MATRIX_0" },
+ { RADEON_VS_MATRIX_1_ADDR * 4, "MATRIX_1" },
+ { RADEON_VS_MATRIX_2_ADDR * 4, "MATRIX_2" },
+ { RADEON_VS_MATRIX_3_ADDR * 4, "MATRIX_3" },
+ { RADEON_VS_MATRIX_4_ADDR * 4, "MATRIX_4" },
+ { RADEON_VS_MATRIX_5_ADDR * 4, "MATRIX_5" },
+ { RADEON_VS_MATRIX_6_ADDR * 4, "MATRIX_6" },
+ { RADEON_VS_MATRIX_7_ADDR * 4, "MATRIX_7" },
+ { RADEON_VS_MATRIX_8_ADDR * 4, "MATRIX_8" },
+ { RADEON_VS_MATRIX_9_ADDR * 4, "MATRIX_9" },
+ { RADEON_VS_MATRIX_10_ADDR * 4, "MATRIX_10" },
+ { RADEON_VS_MATRIX_11_ADDR * 4, "MATRIX_11" },
+ { RADEON_VS_MATRIX_12_ADDR * 4, "MATRIX_12" },
+ { RADEON_VS_MATRIX_13_ADDR * 4, "MATRIX_13" },
+ { RADEON_VS_MATRIX_14_ADDR * 4, "MATRIX_14" },
+ { RADEON_VS_MATRIX_15_ADDR * 4, "MATRIX_15" },
+ { RADEON_VS_LIGHT_AMBIENT_ADDR * 4, "LIGHT_AMBIENT" },
+ { RADEON_VS_LIGHT_DIFFUSE_ADDR * 4, "LIGHT_DIFFUSE" },
+ { RADEON_VS_LIGHT_SPECULAR_ADDR * 4, "LIGHT_SPECULAR" },
+ { RADEON_VS_LIGHT_DIRPOS_ADDR * 4, "LIGHT_DIRPOS" },
+ { RADEON_VS_LIGHT_HWVSPOT_ADDR * 4, "LIGHT_HWVSPOT" },
+ { RADEON_VS_LIGHT_ATTENUATION_ADDR * 4, "LIGHT_ATTENUATION" },
+ { RADEON_VS_MATRIX_EYE2CLIP_ADDR * 4, "MATRIX_EYE2CLIP" },
+ { RADEON_VS_UCP_ADDR * 4, "UCP" },
+ { RADEON_VS_GLOBAL_AMBIENT_ADDR * 4, "GLOBAL_AMBIENT" },
+ { RADEON_VS_FOG_PARAM_ADDR * 4, "FOG_PARAM" },
+ { RADEON_VS_EYE_VECTOR_ADDR * 4, "EYE_VECTOR" },
+ { 1000, "" },
+};
+
+union fi { float f; int i; };
+
+#define ISVEC 1
+#define ISFLOAT 2
+#define TOUCHED 4
+
+struct reg {
+ int idx;
+ struct reg_names *closest;
+ int flags;
+ union fi current;
+ union fi *values;
+ int nvalues;
+ int nalloc;
+ float vmin, vmax;
+};
+
+
+static struct reg regs[Elements(reg_names)+1];
+static struct reg scalars[512+1];
+static struct reg vectors[512*4+1];
+
+static int total, total_changed, bufs;
+
+static void init_regs( void )
+{
+ struct reg_names *tmp;
+ int i;
+
+ for (i = 0 ; i < Elements(regs) ; i++) {
+ regs[i].idx = reg_names[i].idx;
+ regs[i].closest = &reg_names[i];
+ regs[i].flags = 0;
+ }
+
+ for (i = 0, tmp = scalar_names ; i < Elements(scalars) ; i++) {
+ if (tmp[1].idx == i) tmp++;
+ scalars[i].idx = i;
+ scalars[i].closest = tmp;
+ scalars[i].flags = ISFLOAT;
+ }
+
+ for (i = 0, tmp = vector_names ; i < Elements(vectors) ; i++) {
+ if (tmp[1].idx*4 == i) tmp++;
+ vectors[i].idx = i;
+ vectors[i].closest = tmp;
+ vectors[i].flags = ISFLOAT|ISVEC;
+ }
+
+ regs[Elements(regs)-1].idx = -1;
+ scalars[Elements(scalars)-1].idx = -1;
+ vectors[Elements(vectors)-1].idx = -1;
+}
+
+static int find_or_add_value( struct reg *reg, int val )
+{
+ int j;
+
+ for ( j = 0 ; j < reg->nvalues ; j++)
+ if ( val == reg->values[j].i )
+ return 1;
+
+ if (j == reg->nalloc) {
+ reg->nalloc += 5;
+ reg->nalloc *= 2;
+ reg->values = (union fi *) realloc( reg->values,
+ reg->nalloc * sizeof(union fi) );
+ }
+
+ reg->values[reg->nvalues++].i = val;
+ return 0;
+}
+
+static struct reg *lookup_reg( struct reg *tab, int reg )
+{
+ int i;
+
+ for (i = 0 ; tab[i].idx != -1 ; i++) {
+ if (tab[i].idx == reg)
+ return &tab[i];
+ }
+
+ fprintf(stderr, "*** unknown reg 0x%x\n", reg);
+ return NULL;
+}
+
+
+static const char *get_reg_name( struct reg *reg )
+{
+ static char tmp[80];
+
+ if (reg->idx == reg->closest->idx)
+ return reg->closest->name;
+
+
+ if (reg->flags & ISVEC) {
+ if (reg->idx/4 != reg->closest->idx)
+ sprintf(tmp, "%s+%d[%d]",
+ reg->closest->name,
+ (reg->idx/4) - reg->closest->idx,
+ reg->idx%4);
+ else
+ sprintf(tmp, "%s[%d]", reg->closest->name, reg->idx%4);
+ }
+ else {
+ if (reg->idx != reg->closest->idx)
+ sprintf(tmp, "%s+%d", reg->closest->name, reg->idx - reg->closest->idx);
+ else
+ sprintf(tmp, "%s", reg->closest->name);
+ }
+
+ return tmp;
+}
+
+static int print_int_reg_assignment( struct reg *reg, int data )
+{
+ int changed = (reg->current.i != data);
+ int ever_seen = find_or_add_value( reg, data );
+
+ if (VERBOSE || (NORMAL && (changed || !ever_seen)))
+ fprintf(stderr, " %s <-- 0x%x", get_reg_name(reg), data);
+
+ if (NORMAL) {
+ if (!ever_seen)
+ fprintf(stderr, " *** BRAND NEW VALUE");
+ else if (changed)
+ fprintf(stderr, " *** CHANGED");
+ }
+
+ reg->current.i = data;
+
+ if (VERBOSE || (NORMAL && (changed || !ever_seen)))
+ fprintf(stderr, "\n");
+
+ return changed;
+}
+
+
+static int print_float_reg_assignment( struct reg *reg, float data )
+{
+ int changed = (reg->current.f != data);
+ int newmin = (data < reg->vmin);
+ int newmax = (data > reg->vmax);
+
+ if (VERBOSE || (NORMAL && (newmin || newmax || changed)))
+ fprintf(stderr, " %s <-- %.3f", get_reg_name(reg), data);
+
+ if (NORMAL) {
+ if (newmin) {
+ fprintf(stderr, " *** NEW MIN (prev %.3f)", reg->vmin);
+ reg->vmin = data;
+ }
+ else if (newmax) {
+ fprintf(stderr, " *** NEW MAX (prev %.3f)", reg->vmax);
+ reg->vmax = data;
+ }
+ else if (changed) {
+ fprintf(stderr, " *** CHANGED");
+ }
+ }
+
+ reg->current.f = data;
+
+ if (VERBOSE || (NORMAL && (newmin || newmax || changed)))
+ fprintf(stderr, "\n");
+
+ return changed;
+}
+
+static int print_reg_assignment( struct reg *reg, int data )
+{
+ reg->flags |= TOUCHED;
+ if (reg->flags & ISFLOAT)
+ return print_float_reg_assignment( reg, *(float *)&data );
+ else
+ return print_int_reg_assignment( reg, data );
+}
+
+static void print_reg( struct reg *reg )
+{
+ if (reg->flags & TOUCHED) {
+ if (reg->flags & ISFLOAT) {
+ fprintf(stderr, " %s == %f\n", get_reg_name(reg), reg->current.f);
+ } else {
+ fprintf(stderr, " %s == 0x%x\n", get_reg_name(reg), reg->current.i);
+ }
+ }
+}
+
+
+static void dump_state( void )
+{
+ int i;
+
+ for (i = 0 ; i < Elements(regs) ; i++)
+ print_reg( &regs[i] );
+
+ for (i = 0 ; i < Elements(scalars) ; i++)
+ print_reg( &scalars[i] );
+
+ for (i = 0 ; i < Elements(vectors) ; i++)
+ print_reg( &vectors[i] );
+}
+
+
+
+static int radeon_emit_packets(
+ drm_radeon_cmd_header_t header,
+ drm_radeon_cmd_buffer_t *cmdbuf )
+{
+ int id = (int)header.packet.packet_id;
+ int sz = packet[id].len;
+ int *data = (int *)cmdbuf->buf;
+ int i;
+
+ if (sz * sizeof(int) > cmdbuf->bufsz) {
+ fprintf(stderr, "Packet overflows cmdbuf\n");
+ return -EINVAL;
+ }
+
+ if (!packet[id].name) {
+ fprintf(stderr, "*** Unknown packet 0 nr %d\n", id );
+ return -EINVAL;
+ }
+
+
+ if (VERBOSE)
+ fprintf(stderr, "Packet 0 reg %s nr %d\n", packet[id].name, sz );
+
+ for ( i = 0 ; i < sz ; i++) {
+ struct reg *reg = lookup_reg( regs, packet[id].start + i*4 );
+ if (print_reg_assignment( reg, data[i] ))
+ total_changed++;
+ total++;
+ }
+
+ cmdbuf->buf += sz * sizeof(int);
+ cmdbuf->bufsz -= sz * sizeof(int);
+ return 0;
+}
+
+
+static int radeon_emit_scalars(
+ drm_radeon_cmd_header_t header,
+ drm_radeon_cmd_buffer_t *cmdbuf )
+{
+ int sz = header.scalars.count;
+ int *data = (int *)cmdbuf->buf;
+ int start = header.scalars.offset;
+ int stride = header.scalars.stride;
+ int i;
+
+ if (VERBOSE)
+ fprintf(stderr, "emit scalars, start %d stride %d nr %d (end %d)\n",
+ start, stride, sz, start + stride * sz);
+
+
+ for (i = 0 ; i < sz ; i++, start += stride) {
+ struct reg *reg = lookup_reg( scalars, start );
+ if (print_reg_assignment( reg, data[i] ))
+ total_changed++;
+ total++;
+ }
+
+ cmdbuf->buf += sz * sizeof(int);
+ cmdbuf->bufsz -= sz * sizeof(int);
+ return 0;
+}
+
+
+static int radeon_emit_scalars2(
+ drm_radeon_cmd_header_t header,
+ drm_radeon_cmd_buffer_t *cmdbuf )
+{
+ int sz = header.scalars.count;
+ int *data = (int *)cmdbuf->buf;
+ int start = header.scalars.offset + 0x100;
+ int stride = header.scalars.stride;
+ int i;
+
+ if (VERBOSE)
+ fprintf(stderr, "emit scalars2, start %d stride %d nr %d (end %d)\n",
+ start, stride, sz, start + stride * sz);
+
+ if (start + stride * sz > 257) {
+ fprintf(stderr, "emit scalars OVERFLOW %d/%d/%d\n", start, stride, sz);
+ return -1;
+ }
+
+ for (i = 0 ; i < sz ; i++, start += stride) {
+ struct reg *reg = lookup_reg( scalars, start );
+ if (print_reg_assignment( reg, data[i] ))
+ total_changed++;
+ total++;
+ }
+
+ cmdbuf->buf += sz * sizeof(int);
+ cmdbuf->bufsz -= sz * sizeof(int);
+ return 0;
+}
+
+/* Check: inf/nan/extreme-size?
+ * Check: table start, end, nr, etc.
+ */
+static int radeon_emit_vectors(
+ drm_radeon_cmd_header_t header,
+ drm_radeon_cmd_buffer_t *cmdbuf )
+{
+ int sz = header.vectors.count;
+ int *data = (int *)cmdbuf->buf;
+ int start = header.vectors.offset;
+ int stride = header.vectors.stride;
+ int i,j;
+
+ if (VERBOSE)
+ fprintf(stderr, "emit vectors, start %d stride %d nr %d (end %d) (0x%x)\n",
+ start, stride, sz, start + stride * sz, header.i);
+
+/* if (start + stride * (sz/4) > 128) { */
+/* fprintf(stderr, "emit vectors OVERFLOW %d/%d/%d\n", start, stride, sz); */
+/* return -1; */
+/* } */
+
+ for (i = 0 ; i < sz ; start += stride) {
+ int changed = 0;
+ for (j = 0 ; j < 4 ; i++,j++) {
+ struct reg *reg = lookup_reg( vectors, start*4+j );
+ if (print_reg_assignment( reg, data[i] ))
+ changed = 1;
+ }
+ if (changed)
+ total_changed += 4;
+ total += 4;
+ }
+
+
+ cmdbuf->buf += sz * sizeof(int);
+ cmdbuf->bufsz -= sz * sizeof(int);
+ return 0;
+}
+
+
+static int print_vertex_format( int vfmt )
+{
+ if (NORMAL) {
+ fprintf(stderr, " %s(%x): %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+ "vertex format",
+ vfmt,
+ "xy,",
+ (vfmt & RADEON_CP_VC_FRMT_Z) ? "z," : "",
+ (vfmt & RADEON_CP_VC_FRMT_W0) ? "w0," : "",
+ (vfmt & RADEON_CP_VC_FRMT_FPCOLOR) ? "fpcolor," : "",
+ (vfmt & RADEON_CP_VC_FRMT_FPALPHA) ? "fpalpha," : "",
+ (vfmt & RADEON_CP_VC_FRMT_PKCOLOR) ? "pkcolor," : "",
+ (vfmt & RADEON_CP_VC_FRMT_FPSPEC) ? "fpspec," : "",
+ (vfmt & RADEON_CP_VC_FRMT_FPFOG) ? "fpfog," : "",
+ (vfmt & RADEON_CP_VC_FRMT_PKSPEC) ? "pkspec," : "",
+ (vfmt & RADEON_CP_VC_FRMT_ST0) ? "st0," : "",
+ (vfmt & RADEON_CP_VC_FRMT_ST1) ? "st1," : "",
+ (vfmt & RADEON_CP_VC_FRMT_Q1) ? "q1," : "",
+ (vfmt & RADEON_CP_VC_FRMT_ST2) ? "st2," : "",
+ (vfmt & RADEON_CP_VC_FRMT_Q2) ? "q2," : "",
+ (vfmt & RADEON_CP_VC_FRMT_ST3) ? "st3," : "",
+ (vfmt & RADEON_CP_VC_FRMT_Q3) ? "q3," : "",
+ (vfmt & RADEON_CP_VC_FRMT_Q0) ? "q0," : "",
+ (vfmt & RADEON_CP_VC_FRMT_N0) ? "n0," : "",
+ (vfmt & RADEON_CP_VC_FRMT_XY1) ? "xy1," : "",
+ (vfmt & RADEON_CP_VC_FRMT_Z1) ? "z1," : "",
+ (vfmt & RADEON_CP_VC_FRMT_W1) ? "w1," : "",
+ (vfmt & RADEON_CP_VC_FRMT_N1) ? "n1," : "");
+
+
+/* if (!find_or_add_value( &others[V_VTXFMT], vfmt )) */
+/* fprintf(stderr, " *** NEW VALUE"); */
+
+ fprintf(stderr, "\n");
+ }
+
+ return 0;
+}
+
+static char *primname[0xf] = {
+ "NONE",
+ "POINTS",
+ "LINES",
+ "LINE_STRIP",
+ "TRIANGLES",
+ "TRIANGLE_FAN",
+ "TRIANGLE_STRIP",
+ "TRI_TYPE_2",
+ "RECT_LIST",
+ "3VRT_POINTS",
+ "3VRT_LINES",
+};
+
+static int print_prim_and_flags( int prim )
+{
+ int numverts;
+
+ if (NORMAL)
+ fprintf(stderr, " %s(%x): %s%s%s%s%s%s%s\n",
+ "prim flags",
+ prim,
+ ((prim & 0x30) == RADEON_CP_VC_CNTL_PRIM_WALK_IND) ? "IND," : "",
+ ((prim & 0x30) == RADEON_CP_VC_CNTL_PRIM_WALK_LIST) ? "LIST," : "",
+ ((prim & 0x30) == RADEON_CP_VC_CNTL_PRIM_WALK_RING) ? "RING," : "",
+ (prim & RADEON_CP_VC_CNTL_COLOR_ORDER_RGBA) ? "RGBA," : "BGRA, ",
+ (prim & RADEON_CP_VC_CNTL_MAOS_ENABLE) ? "MAOS," : "",
+ (prim & RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE) ? "RADEON," : "",
+ (prim & RADEON_CP_VC_CNTL_TCL_ENABLE) ? "TCL," : "");
+
+ if ((prim & 0xf) > RADEON_CP_VC_CNTL_PRIM_TYPE_3VRT_LINE_LIST) {
+ fprintf(stderr, " *** Bad primitive: %x\n", prim & 0xf);
+ return -1;
+ }
+
+ numverts = prim>>16;
+
+ if (NORMAL)
+ fprintf(stderr, " prim: %s numverts %d\n", primname[prim&0xf], numverts);
+
+ switch (prim & 0xf) {
+ case RADEON_CP_VC_CNTL_PRIM_TYPE_NONE:
+ case RADEON_CP_VC_CNTL_PRIM_TYPE_POINT:
+ if (numverts < 1) {
+ fprintf(stderr, "Bad nr verts for line %d\n", numverts);
+ return -1;
+ }
+ break;
+ case RADEON_CP_VC_CNTL_PRIM_TYPE_LINE:
+ if ((numverts & 1) || numverts == 0) {
+ fprintf(stderr, "Bad nr verts for line %d\n", numverts);
+ return -1;
+ }
+ break;
+ case RADEON_CP_VC_CNTL_PRIM_TYPE_LINE_STRIP:
+ if (numverts < 2) {
+ fprintf(stderr, "Bad nr verts for line_strip %d\n", numverts);
+ return -1;
+ }
+ break;
+ case RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST:
+ case RADEON_CP_VC_CNTL_PRIM_TYPE_3VRT_POINT_LIST:
+ case RADEON_CP_VC_CNTL_PRIM_TYPE_3VRT_LINE_LIST:
+ case RADEON_CP_VC_CNTL_PRIM_TYPE_RECT_LIST:
+ if (numverts % 3 || numverts == 0) {
+ fprintf(stderr, "Bad nr verts for tri %d\n", numverts);
+ return -1;
+ }
+ break;
+ case RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN:
+ case RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_STRIP:
+ if (numverts < 3) {
+ fprintf(stderr, "Bad nr verts for strip/fan %d\n", numverts);
+ return -1;
+ }
+ break;
+ default:
+ fprintf(stderr, "Bad primitive\n");
+ return -1;
+ }
+ return 0;
+}
+
+/* build in knowledge about each packet type
+ */
+static int radeon_emit_packet3( drm_radeon_cmd_buffer_t *cmdbuf )
+{
+ int cmdsz;
+ int *cmd = (int *)cmdbuf->buf;
+ int *tmp;
+ int i, stride, size, start;
+
+ cmdsz = 2 + ((cmd[0] & RADEON_CP_PACKET_COUNT_MASK) >> 16);
+
+ if ((cmd[0] & RADEON_CP_PACKET_MASK) != RADEON_CP_PACKET3 ||
+ cmdsz * 4 > cmdbuf->bufsz ||
+ cmdsz > RADEON_CP_PACKET_MAX_DWORDS) {
+ fprintf(stderr, "Bad packet\n");
+ return -EINVAL;
+ }
+
+ switch( cmd[0] & ~RADEON_CP_PACKET_COUNT_MASK ) {
+ case RADEON_CP_PACKET3_NOP:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_NOP, %d dwords\n", cmdsz);
+ break;
+ case RADEON_CP_PACKET3_NEXT_CHAR:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_NEXT_CHAR, %d dwords\n", cmdsz);
+ break;
+ case RADEON_CP_PACKET3_PLY_NEXTSCAN:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_PLY_NEXTSCAN, %d dwords\n", cmdsz);
+ break;
+ case RADEON_CP_PACKET3_SET_SCISSORS:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_SET_SCISSORS, %d dwords\n", cmdsz);
+ break;
+ case RADEON_CP_PACKET3_3D_RNDR_GEN_INDX_PRIM:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_3D_RNDR_GEN_INDX_PRIM, %d dwords\n",
+ cmdsz);
+ break;
+ case RADEON_CP_PACKET3_LOAD_MICROCODE:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_LOAD_MICROCODE, %d dwords\n", cmdsz);
+ break;
+ case RADEON_CP_PACKET3_WAIT_FOR_IDLE:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_WAIT_FOR_IDLE, %d dwords\n", cmdsz);
+ break;
+
+ case RADEON_CP_PACKET3_3D_DRAW_VBUF:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_3D_DRAW_VBUF, %d dwords\n", cmdsz);
+ print_vertex_format(cmd[1]);
+ print_prim_and_flags(cmd[2]);
+ break;
+
+ case RADEON_CP_PACKET3_3D_DRAW_IMMD:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_3D_DRAW_IMMD, %d dwords\n", cmdsz);
+ break;
+ case RADEON_CP_PACKET3_3D_DRAW_INDX: {
+ int neltdwords;
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_3D_DRAW_INDX, %d dwords\n", cmdsz);
+ print_vertex_format(cmd[1]);
+ print_prim_and_flags(cmd[2]);
+ neltdwords = cmd[2]>>16;
+ neltdwords += neltdwords & 1;
+ neltdwords /= 2;
+ if (neltdwords + 3 != cmdsz)
+ fprintf(stderr, "Mismatch in DRAW_INDX, %d vs cmdsz %d\n",
+ neltdwords, cmdsz);
+ break;
+ }
+ case RADEON_CP_PACKET3_LOAD_PALETTE:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_LOAD_PALETTE, %d dwords\n", cmdsz);
+ break;
+ case RADEON_CP_PACKET3_3D_LOAD_VBPNTR:
+ if (NORMAL) {
+ fprintf(stderr, "PACKET3_3D_LOAD_VBPNTR, %d dwords\n", cmdsz);
+ fprintf(stderr, " nr arrays: %d\n", cmd[1]);
+ }
+
+ if (cmd[1]/2 + cmd[1]%2 != cmdsz - 3) {
+ fprintf(stderr, " ****** MISMATCH %d/%d *******\n",
+ cmd[1]/2 + cmd[1]%2 + 3, cmdsz);
+ return -EINVAL;
+ }
+
+ if (NORMAL) {
+ tmp = cmd+2;
+ for (i = 0 ; i < cmd[1] ; i++) {
+ if (i & 1) {
+ stride = (tmp[0]>>24) & 0xff;
+ size = (tmp[0]>>16) & 0xff;
+ start = tmp[2];
+ tmp += 3;
+ }
+ else {
+ stride = (tmp[0]>>8) & 0xff;
+ size = (tmp[0]) & 0xff;
+ start = tmp[1];
+ }
+ fprintf(stderr, " array %d: start 0x%x vsize %d vstride %d\n",
+ i, start, size, stride );
+ }
+ }
+ break;
+ case RADEON_CP_PACKET3_CNTL_PAINT:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_PAINT, %d dwords\n", cmdsz);
+ break;
+ case RADEON_CP_PACKET3_CNTL_BITBLT:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_BITBLT, %d dwords\n", cmdsz);
+ break;
+ case RADEON_CP_PACKET3_CNTL_SMALLTEXT:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_SMALLTEXT, %d dwords\n", cmdsz);
+ break;
+ case RADEON_CP_PACKET3_CNTL_HOSTDATA_BLT:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_HOSTDATA_BLT, %d dwords\n",
+ cmdsz);
+ break;
+ case RADEON_CP_PACKET3_CNTL_POLYLINE:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_POLYLINE, %d dwords\n", cmdsz);
+ break;
+ case RADEON_CP_PACKET3_CNTL_POLYSCANLINES:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_POLYSCANLINES, %d dwords\n",
+ cmdsz);
+ break;
+ case RADEON_CP_PACKET3_CNTL_PAINT_MULTI:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_PAINT_MULTI, %d dwords\n",
+ cmdsz);
+ break;
+ case RADEON_CP_PACKET3_CNTL_BITBLT_MULTI:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_BITBLT_MULTI, %d dwords\n",
+ cmdsz);
+ break;
+ case RADEON_CP_PACKET3_CNTL_TRANS_BITBLT:
+ if (NORMAL)
+ fprintf(stderr, "PACKET3_CNTL_TRANS_BITBLT, %d dwords\n",
+ cmdsz);
+ break;
+ default:
+ fprintf(stderr, "UNKNOWN PACKET, %d dwords\n", cmdsz);
+ break;
+ }
+
+ cmdbuf->buf += cmdsz * 4;
+ cmdbuf->bufsz -= cmdsz * 4;
+ return 0;
+}
+
+
+/* Check cliprects for bounds, then pass on to above:
+ */
+static int radeon_emit_packet3_cliprect( drm_radeon_cmd_buffer_t *cmdbuf )
+{
+ drm_clip_rect_t *boxes = cmdbuf->boxes;
+ int i = 0;
+
+ if (VERBOSE && total_changed) {
+ dump_state();
+ total_changed = 0;
+ }
+ else fprintf(stderr, "total_changed zero\n");
+
+ if (NORMAL) {
+ do {
+ if ( i < cmdbuf->nbox ) {
+ fprintf(stderr, "Emit box %d/%d %d,%d %d,%d\n",
+ i, cmdbuf->nbox,
+ boxes[i].x1, boxes[i].y1, boxes[i].x2, boxes[i].y2);
+ }
+ } while ( ++i < cmdbuf->nbox );
+ }
+
+ if (cmdbuf->nbox == 1)
+ cmdbuf->nbox = 0;
+
+ return radeon_emit_packet3( cmdbuf );
+}
+
+
+int radeonSanityCmdBuffer( radeonContextPtr rmesa,
+ int nbox,
+ drm_clip_rect_t *boxes )
+{
+ int idx;
+ drm_radeon_cmd_buffer_t cmdbuf;
+ drm_radeon_cmd_header_t header;
+ static int inited = 0;
+
+ if (!inited) {
+ init_regs();
+ inited = 1;
+ }
+
+ cmdbuf.buf = rmesa->store.cmd_buf;
+ cmdbuf.bufsz = rmesa->store.cmd_used;
+ cmdbuf.boxes = boxes;
+ cmdbuf.nbox = nbox;
+
+ while ( cmdbuf.bufsz >= sizeof(header) ) {
+
+ header.i = *(int *)cmdbuf.buf;
+ cmdbuf.buf += sizeof(header);
+ cmdbuf.bufsz -= sizeof(header);
+
+ switch (header.header.cmd_type) {
+ case RADEON_CMD_PACKET:
+ if (radeon_emit_packets( header, &cmdbuf )) {
+ fprintf(stderr,"radeon_emit_packets failed\n");
+ return -EINVAL;
+ }
+ break;
+
+ case RADEON_CMD_SCALARS:
+ if (radeon_emit_scalars( header, &cmdbuf )) {
+ fprintf(stderr,"radeon_emit_scalars failed\n");
+ return -EINVAL;
+ }
+ break;
+
+ case RADEON_CMD_SCALARS2:
+ if (radeon_emit_scalars2( header, &cmdbuf )) {
+ fprintf(stderr,"radeon_emit_scalars failed\n");
+ return -EINVAL;
+ }
+ break;
+
+ case RADEON_CMD_VECTORS:
+ if (radeon_emit_vectors( header, &cmdbuf )) {
+ fprintf(stderr,"radeon_emit_vectors failed\n");
+ return -EINVAL;
+ }
+ break;
+
+ case RADEON_CMD_DMA_DISCARD:
+ idx = header.dma.buf_idx;
+ if (NORMAL)
+ fprintf(stderr, "RADEON_CMD_DMA_DISCARD buf %d\n", idx);
+ bufs++;
+ break;
+
+ case RADEON_CMD_PACKET3:
+ if (radeon_emit_packet3( &cmdbuf )) {
+ fprintf(stderr,"radeon_emit_packet3 failed\n");
+ return -EINVAL;
+ }
+ break;
+
+ case RADEON_CMD_PACKET3_CLIP:
+ if (radeon_emit_packet3_cliprect( &cmdbuf )) {
+ fprintf(stderr,"radeon_emit_packet3_clip failed\n");
+ return -EINVAL;
+ }
+ break;
+
+ case RADEON_CMD_WAIT:
+ break;
+
+ default:
+ fprintf(stderr,"bad cmd_type %d at %p\n",
+ header.header.cmd_type,
+ cmdbuf.buf - sizeof(header));
+ return -EINVAL;
+ }
+ }
+
+ if (0)
+ {
+ static int n = 0;
+ n++;
+ if (n == 10) {
+ fprintf(stderr, "Bufs %d Total emitted %d real changes %d (%.2f%%)\n",
+ bufs,
+ total, total_changed,
+ ((float)total_changed/(float)total*100.0));
+ fprintf(stderr, "Total emitted per buf: %.2f\n",
+ (float)total/(float)bufs);
+ fprintf(stderr, "Real changes per buf: %.2f\n",
+ (float)total_changed/(float)bufs);
+
+ bufs = n = total = total_changed = 0;
+ }
+ }
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_sanity.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_sanity.h
new file mode 100644
index 000000000..1ec06bc58
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_sanity.h
@@ -0,0 +1,8 @@
+#ifndef RADEON_SANITY_H
+#define RADEON_SANITY_H
+
+extern int radeonSanityCmdBuffer( radeonContextPtr rmesa,
+ int nbox,
+ drm_clip_rect_t *boxes );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.c
new file mode 100644
index 000000000..80710294c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.c
@@ -0,0 +1,656 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_screen.c,v 1.7 2003/03/26 20:43:51 tsi Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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 THE COPYRIGHT OWNER(S) 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.
+
+**************************************************************************/
+
+/**
+ * \file radeon_screen.c
+ * Screen initialization functions for the Radeon driver.
+ *
+ * \author Kevin E. Martin <martin@valinux.com>
+ * \author Gareth Hughes <gareth@valinux.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+
+#define STANDALONE_MMIO
+#include "radeon_context.h"
+#include "radeon_screen.h"
+#include "radeon_macros.h"
+#include "radeon_span.h"
+
+#include "utils.h"
+#include "context.h"
+#include "vblank.h"
+#include "drirenderbuffer.h"
+
+#include "GL/internal/dri_interface.h"
+
+/* Radeon configuration
+ */
+#include "xmlpool.h"
+
+PUBLIC const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_TCL_MODE(DRI_CONF_TCL_CODEGEN)
+ DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_HYPERZ(false)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_QUALITY
+ DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
+ DRI_CONF_DEF_MAX_ANISOTROPY(1.0,"1.0,2.0,4.0,8.0,16.0")
+ DRI_CONF_NO_NEG_LOD_BIAS(false)
+ DRI_CONF_FORCE_S3TC_ENABLE(false)
+ DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
+ DRI_CONF_ROUND_MODE(DRI_CONF_ROUND_TRUNC)
+ DRI_CONF_DITHER_MODE(DRI_CONF_DITHER_XERRORDIFF)
+ DRI_CONF_TEXTURE_LEVEL_HACK(false)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_NO_RAST(false)
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+static const GLuint __driNConfigOptions = 13;
+
+extern const struct dri_extension card_extensions[];
+
+#if 1
+/* Including xf86PciInfo.h introduces a bunch of errors...
+ */
+#define PCI_CHIP_RADEON_QD 0x5144
+#define PCI_CHIP_RADEON_QE 0x5145
+#define PCI_CHIP_RADEON_QF 0x5146
+#define PCI_CHIP_RADEON_QG 0x5147
+
+#define PCI_CHIP_RADEON_QY 0x5159
+#define PCI_CHIP_RADEON_QZ 0x515A
+
+#define PCI_CHIP_RN50_515E 0x515E
+#define PCI_CHIP_RN50_5969 0x5969
+
+#define PCI_CHIP_RADEON_LW 0x4C57 /* mobility 7 - has tcl */
+#define PCI_CHIP_RADEON_LX 0x4C58 /* mobility FireGL 7800 m7 */
+
+#define PCI_CHIP_RADEON_LY 0x4C59
+#define PCI_CHIP_RADEON_LZ 0x4C5A
+
+#define PCI_CHIP_RV200_QW 0x5157 /* Radeon 7500 - not an R200 at all */
+#define PCI_CHIP_RV200_QX 0x5158
+
+/* IGP Chipsets */
+#define PCI_CHIP_RS100_4136 0x4136
+#define PCI_CHIP_RS200_4137 0x4137
+#define PCI_CHIP_RS250_4237 0x4237
+#define PCI_CHIP_RS100_4336 0x4336
+#define PCI_CHIP_RS200_4337 0x4337
+#define PCI_CHIP_RS250_4437 0x4437
+#endif
+
+
+static int getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo );
+
+static __GLcontextModes *
+radeonFillInModes( unsigned pixel_bits, unsigned depth_bits,
+ unsigned stencil_bits, GLboolean have_back_buffer )
+{
+ __GLcontextModes * modes;
+ __GLcontextModes * m;
+ unsigned num_modes;
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ GLenum fb_format;
+ GLenum fb_type;
+
+ /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
+ * enough to add support. Basically, if a context is created with an
+ * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
+ * will never be used.
+ */
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
+ };
+
+ u_int8_t depth_bits_array[2];
+ u_int8_t stencil_bits_array[2];
+
+
+ depth_bits_array[0] = depth_bits;
+ depth_bits_array[1] = depth_bits;
+
+ /* Just like with the accumulation buffer, always provide some modes
+ * with a stencil buffer. It will be a sw fallback, but some apps won't
+ * care about that.
+ */
+ stencil_bits_array[0] = 0;
+ stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
+
+ depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1;
+ back_buffer_factor = (have_back_buffer) ? 2 : 1;
+
+ num_modes = depth_buffer_factor * back_buffer_factor * 4;
+
+ if ( pixel_bits == 16 ) {
+ fb_format = GL_RGB;
+ fb_type = GL_UNSIGNED_SHORT_5_6_5;
+ }
+ else {
+ fb_format = GL_BGRA;
+ fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ }
+
+ modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
+ m = modes;
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_TRUE_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_DIRECT_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+
+ /* Mark the visual as slow if there are "fake" stencil bits.
+ */
+ for ( m = modes ; m != NULL ; m = m->next ) {
+ if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) {
+ m->visualRating = GLX_SLOW_CONFIG;
+ }
+ }
+
+ return modes;
+}
+
+
+/* Create the device specific screen private data struct.
+ */
+radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv )
+{
+ radeonScreenPtr screen;
+ RADEONDRIPtr dri_priv = (RADEONDRIPtr)sPriv->pDevPriv;
+ unsigned char *RADEONMMIO;
+ PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
+ (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
+ void * const psc = sPriv->psc->screenConfigs;
+
+ if (sPriv->devPrivSize != sizeof(RADEONDRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(RADEONDRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
+
+ /* Allocate the private area */
+ screen = (radeonScreenPtr) CALLOC( sizeof(*screen) );
+ if ( !screen ) {
+ __driUtilMessage("%s: Could not allocate memory for screen structure",
+ __FUNCTION__);
+ return NULL;
+ }
+
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo (&screen->optionCache,
+ __driConfigOptions, __driNConfigOptions);
+
+ /* This is first since which regions we map depends on whether or
+ * not we are using a PCI card.
+ */
+ screen->IsPCI = dri_priv->IsPCI;
+
+ {
+ int ret;
+ drm_radeon_getparam_t gp;
+
+ gp.param = RADEON_PARAM_GART_BUFFER_OFFSET;
+ gp.value = &screen->gart_buffer_offset;
+
+ ret = drmCommandWriteRead( sPriv->fd, DRM_RADEON_GETPARAM,
+ &gp, sizeof(gp));
+ if (ret) {
+ FREE( screen );
+ fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_GART_BUFFER_OFFSET): %d\n", ret);
+ return NULL;
+ }
+
+ if (sPriv->drmMinor >= 6) {
+ gp.param = RADEON_PARAM_IRQ_NR;
+ gp.value = &screen->irq;
+
+ ret = drmCommandWriteRead( sPriv->fd, DRM_RADEON_GETPARAM,
+ &gp, sizeof(gp));
+ if (ret) {
+ FREE( screen );
+ fprintf(stderr, "drm_radeon_getparam_t (RADEON_PARAM_IRQ_NR): %d\n", ret);
+ return NULL;
+ }
+ }
+ }
+
+ screen->mmio.handle = dri_priv->registerHandle;
+ screen->mmio.size = dri_priv->registerSize;
+ if ( drmMap( sPriv->fd,
+ screen->mmio.handle,
+ screen->mmio.size,
+ &screen->mmio.map ) ) {
+ FREE( screen );
+ __driUtilMessage("%s: drmMap failed\n", __FUNCTION__ );
+ return NULL;
+ }
+
+ RADEONMMIO = screen->mmio.map;
+
+ screen->status.handle = dri_priv->statusHandle;
+ screen->status.size = dri_priv->statusSize;
+ if ( drmMap( sPriv->fd,
+ screen->status.handle,
+ screen->status.size,
+ &screen->status.map ) ) {
+ drmUnmap( screen->mmio.map, screen->mmio.size );
+ FREE( screen );
+ __driUtilMessage("%s: drmMap (2) failed\n", __FUNCTION__ );
+ return NULL;
+ }
+ screen->scratch = (__volatile__ u_int32_t *)
+ ((GLubyte *)screen->status.map + RADEON_SCRATCH_REG_OFFSET);
+
+ screen->buffers = drmMapBufs( sPriv->fd );
+ if ( !screen->buffers ) {
+ drmUnmap( screen->status.map, screen->status.size );
+ drmUnmap( screen->mmio.map, screen->mmio.size );
+ FREE( screen );
+ __driUtilMessage("%s: drmMapBufs failed\n", __FUNCTION__ );
+ return NULL;
+ }
+
+ if ( dri_priv->gartTexHandle && dri_priv->gartTexMapSize ) {
+ screen->gartTextures.handle = dri_priv->gartTexHandle;
+ screen->gartTextures.size = dri_priv->gartTexMapSize;
+ if ( drmMap( sPriv->fd,
+ screen->gartTextures.handle,
+ screen->gartTextures.size,
+ (drmAddressPtr)&screen->gartTextures.map ) ) {
+ drmUnmapBufs( screen->buffers );
+ drmUnmap( screen->status.map, screen->status.size );
+ drmUnmap( screen->mmio.map, screen->mmio.size );
+ FREE( screen );
+ __driUtilMessage("%s: drmMap failed for GART texture area\n", __FUNCTION__);
+ return NULL;
+ }
+
+ screen->gart_texture_offset = dri_priv->gartTexOffset + ( screen->IsPCI
+ ? INREG( RADEON_AIC_LO_ADDR )
+ : ( ( INREG( RADEON_MC_AGP_LOCATION ) & 0x0ffffU ) << 16 ) );
+ }
+
+ screen->chipset = 0;
+ switch ( dri_priv->deviceID ) {
+ default:
+ fprintf(stderr, "unknown chip id, assuming full radeon support\n");
+ case PCI_CHIP_RADEON_QD:
+ case PCI_CHIP_RADEON_QE:
+ case PCI_CHIP_RADEON_QF:
+ case PCI_CHIP_RADEON_QG:
+ /* all original radeons (7200) presumably have a stencil op bug */
+ screen->chipset |= RADEON_CHIPSET_BROKEN_STENCIL;
+ case PCI_CHIP_RV200_QW:
+ case PCI_CHIP_RV200_QX:
+ case PCI_CHIP_RADEON_LW:
+ case PCI_CHIP_RADEON_LX:
+ screen->chipset |= RADEON_CHIPSET_TCL;
+ case PCI_CHIP_RADEON_QY:
+ case PCI_CHIP_RADEON_QZ:
+ case PCI_CHIP_RN50_515E:
+ case PCI_CHIP_RN50_5969:
+ case PCI_CHIP_RADEON_LY:
+ case PCI_CHIP_RADEON_LZ:
+ case PCI_CHIP_RS100_4136: /* IGPs don't have TCL */
+ case PCI_CHIP_RS200_4137:
+ case PCI_CHIP_RS250_4237:
+ case PCI_CHIP_RS100_4336:
+ case PCI_CHIP_RS200_4337:
+ case PCI_CHIP_RS250_4437:
+ break;
+ }
+
+ screen->cpp = dri_priv->bpp / 8;
+ screen->AGPMode = dri_priv->AGPMode;
+
+ screen->fbLocation = ( INREG( RADEON_MC_FB_LOCATION ) & 0xffff ) << 16;
+
+ if ( sPriv->drmMinor >= 10 ) {
+ drm_radeon_setparam_t sp;
+
+ sp.param = RADEON_SETPARAM_FB_LOCATION;
+ sp.value = screen->fbLocation;
+
+ drmCommandWrite( sPriv->fd, DRM_RADEON_SETPARAM,
+ &sp, sizeof( sp ) );
+ }
+
+ screen->frontOffset = dri_priv->frontOffset;
+ screen->frontPitch = dri_priv->frontPitch;
+ screen->backOffset = dri_priv->backOffset;
+ screen->backPitch = dri_priv->backPitch;
+ screen->depthOffset = dri_priv->depthOffset;
+ screen->depthPitch = dri_priv->depthPitch;
+
+ /* Check if ddx has set up a surface reg to cover depth buffer */
+ screen->depthHasSurface = ((sPriv->ddxMajor > 4) &&
+ (screen->chipset & RADEON_CHIPSET_TCL));
+
+ if ( dri_priv->textureSize == 0 ) {
+ screen->texOffset[RADEON_LOCAL_TEX_HEAP] = screen->gart_texture_offset;
+ screen->texSize[RADEON_LOCAL_TEX_HEAP] = dri_priv->gartTexMapSize;
+ screen->logTexGranularity[RADEON_LOCAL_TEX_HEAP] =
+ dri_priv->log2GARTTexGran;
+ } else {
+ screen->texOffset[RADEON_LOCAL_TEX_HEAP] = dri_priv->textureOffset
+ + screen->fbLocation;
+ screen->texSize[RADEON_LOCAL_TEX_HEAP] = dri_priv->textureSize;
+ screen->logTexGranularity[RADEON_LOCAL_TEX_HEAP] =
+ dri_priv->log2TexGran;
+ }
+
+ if ( !screen->gartTextures.map || dri_priv->textureSize == 0
+ || getenv( "RADEON_GARTTEXTURING_FORCE_DISABLE" ) ) {
+ screen->numTexHeaps = RADEON_NR_TEX_HEAPS - 1;
+ screen->texOffset[RADEON_GART_TEX_HEAP] = 0;
+ screen->texSize[RADEON_GART_TEX_HEAP] = 0;
+ screen->logTexGranularity[RADEON_GART_TEX_HEAP] = 0;
+ } else {
+ screen->numTexHeaps = RADEON_NR_TEX_HEAPS;
+ screen->texOffset[RADEON_GART_TEX_HEAP] = screen->gart_texture_offset;
+ screen->texSize[RADEON_GART_TEX_HEAP] = dri_priv->gartTexMapSize;
+ screen->logTexGranularity[RADEON_GART_TEX_HEAP] =
+ dri_priv->log2GARTTexGran;
+ }
+
+ if ( glx_enable_extension != NULL ) {
+ if ( screen->irq != 0 ) {
+ (*glx_enable_extension)( psc, "GLX_SGI_swap_control" );
+ (*glx_enable_extension)( psc, "GLX_SGI_video_sync" );
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_control" );
+ }
+
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
+ }
+
+ screen->driScreen = sPriv;
+ screen->sarea_priv_offset = dri_priv->sarea_priv_offset;
+ return screen;
+}
+
+/* Destroy the device specific screen private data struct.
+ */
+void radeonDestroyScreen( __DRIscreenPrivate *sPriv )
+{
+ radeonScreenPtr screen = (radeonScreenPtr)sPriv->private;
+
+ if (!screen)
+ return;
+
+ if ( screen->gartTextures.map ) {
+ drmUnmap( screen->gartTextures.map, screen->gartTextures.size );
+ }
+ drmUnmapBufs( screen->buffers );
+ drmUnmap( screen->status.map, screen->status.size );
+ drmUnmap( screen->mmio.map, screen->mmio.size );
+
+ /* free all option information */
+ driDestroyOptionInfo (&screen->optionCache);
+
+ FREE( screen );
+ sPriv->private = NULL;
+}
+
+
+/* Initialize the driver specific screen private data.
+ */
+static GLboolean
+radeonInitDriver( __DRIscreenPrivate *sPriv )
+{
+ sPriv->private = (void *) radeonCreateScreen( sPriv );
+ if ( !sPriv->private ) {
+ radeonDestroyScreen( sPriv );
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Create the Mesa framebuffer and renderbuffers for a given window/drawable.
+ *
+ * \todo This function (and its interface) will need to be updated to support
+ * pbuffers.
+ */
+static GLboolean
+radeonCreateBuffer( __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ radeonScreenPtr screen = (radeonScreenPtr) driScrnPriv->private;
+
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+ const GLboolean swDepth = GL_FALSE;
+ const GLboolean swAlpha = GL_FALSE;
+ const GLboolean swAccum = mesaVis->accumRedBits > 0;
+ const GLboolean swStencil = mesaVis->stencilBits > 0 &&
+ mesaVis->depthBits != 24;
+#if 0
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer( mesaVis,
+ swDepth,
+ swStencil,
+ swAccum,
+ swAlpha );
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->frontPitch);
+ radeonSetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ radeonSetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ radeonSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ radeonSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ radeonSetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ swDepth,
+ swStencil,
+ swAccum,
+ swAlpha,
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+
+static void
+radeonDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+static struct __DriverAPIRec radeonAPI = {
+ .InitDriver = radeonInitDriver,
+ .DestroyScreen = radeonDestroyScreen,
+ .CreateContext = radeonCreateContext,
+ .DestroyContext = radeonDestroyContext,
+ .CreateBuffer = radeonCreateBuffer,
+ .DestroyBuffer = radeonDestroyBuffer,
+ .SwapBuffers = radeonSwapBuffers,
+ .MakeCurrent = radeonMakeCurrent,
+ .UnbindContext = radeonUnbindContext,
+ .GetSwapInfo = getSwapInfo,
+ .GetMSC = driGetMSC32,
+ .WaitForMSC = driWaitForMSC32,
+ .WaitForSBC = NULL,
+ .SwapBuffersMSC = NULL
+};
+
+
+/**
+ * This is the bootstrap function for the driver. libGL supplies all of the
+ * requisite information about the system, and the driver initializes itself.
+ * This routine also fills in the linked list pointed to by \c driver_modes
+ * with the \c __GLcontextModes that the driver can support for windows or
+ * pbuffers.
+ *
+ * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
+ * failure.
+ */
+PUBLIC
+void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
+ const __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drmAddress pSAREA, int fd,
+ int internal_api_version,
+ const __DRIinterfaceMethods * interface,
+ __GLcontextModes ** driver_modes )
+
+{
+ __DRIscreenPrivate *psp;
+ static const __DRIutilversion2 ddx_expected = { 4, 5, 0, 0 };
+ static const __DRIversion dri_expected = { 4, 0, 0 };
+ static const __DRIversion drm_expected = { 1, 3, 0 };
+
+ dri_interface = interface;
+
+ if ( ! driCheckDriDdxDrmVersions3( "Radeon",
+ dri_version, & dri_expected,
+ ddx_version, & ddx_expected,
+ drm_version, & drm_expected ) ) {
+ return NULL;
+ }
+
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &radeonAPI);
+ if ( psp != NULL ) {
+ RADEONDRIPtr dri_priv = (RADEONDRIPtr) psp->pDevPriv;
+ *driver_modes = radeonFillInModes( dri_priv->bpp,
+ (dri_priv->bpp == 16) ? 16 : 24,
+ (dri_priv->bpp == 16) ? 0 : 8,
+ (dri_priv->backOffset != dri_priv->depthOffset) );
+
+ /* Calling driInitExtensions here, with a NULL context pointer, does not actually
+ * enable the extensions. It just makes sure that all the dispatch offsets for all
+ * the extensions that *might* be enables are known. This is needed because the
+ * dispatch offsets need to be known when _mesa_context_create is called, but we can't
+ * enable the extensions until we have a context pointer.
+ *
+ * Hello chicken. Hello egg. How are you two today?
+ */
+ driInitExtensions( NULL, card_extensions, GL_FALSE );
+ }
+
+ return (void *) psp;
+}
+
+
+/**
+ * Get information about previous buffer swaps.
+ */
+static int
+getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
+{
+ radeonContextPtr rmesa;
+
+ if ( (dPriv == NULL) || (dPriv->driContextPriv == NULL)
+ || (dPriv->driContextPriv->driverPrivate == NULL)
+ || (sInfo == NULL) ) {
+ return -1;
+ }
+
+ rmesa = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+ sInfo->swap_count = rmesa->swap_count;
+ sInfo->swap_ust = rmesa->swap_ust;
+ sInfo->swap_missed_count = rmesa->swap_missed_count;
+
+ sInfo->swap_missed_usage = (sInfo->swap_missed_count != 0)
+ ? driCalculateSwapUsage( dPriv, 0, rmesa->swap_missed_ust )
+ : 0.0;
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.h
new file mode 100644
index 000000000..b9cbeaac3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.h
@@ -0,0 +1,103 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_screen.h,v 1.5 2002/12/16 16:18:58 dawes Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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 THE COPYRIGHT OWNER(S) 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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ */
+
+#ifndef __RADEON_SCREEN_H__
+#define __RADEON_SCREEN_H__
+
+/*
+ * IMPORTS: these headers contain all the DRI, X and kernel-related
+ * definitions that we need.
+ */
+/* #include "dri_util.h" */
+#include "radeon_dri.h"
+#include "radeon_reg.h"
+#include "drm_sarea.h"
+#include "xmlconfig.h"
+
+
+typedef struct {
+ drm_handle_t handle; /* Handle to the DRM region */
+ drmSize size; /* Size of the DRM region */
+ drmAddress map; /* Mapping of the DRM region */
+} radeonRegionRec, *radeonRegionPtr;
+
+/* chipset features */
+#define RADEON_CHIPSET_TCL (1 << 0)
+#define RADEON_CHIPSET_BROKEN_STENCIL (1 << 1)
+
+typedef struct {
+
+ int chipset;
+ int cpp;
+ int IsPCI; /* Current card is a PCI card */
+ int AGPMode;
+ unsigned int irq; /* IRQ number (0 means none) */
+
+ unsigned int fbLocation;
+ unsigned int frontOffset;
+ unsigned int frontPitch;
+ unsigned int backOffset;
+ unsigned int backPitch;
+
+ unsigned int depthOffset;
+ unsigned int depthPitch;
+
+ /* Shared texture data */
+ int numTexHeaps;
+ int texOffset[RADEON_NR_TEX_HEAPS];
+ int texSize[RADEON_NR_TEX_HEAPS];
+ int logTexGranularity[RADEON_NR_TEX_HEAPS];
+
+ radeonRegionRec mmio;
+ radeonRegionRec status;
+ radeonRegionRec gartTextures;
+
+ drmBufMapPtr buffers;
+
+ __volatile__ u_int32_t *scratch;
+
+ __DRIscreenPrivate *driScreen;
+ unsigned int sarea_priv_offset;
+ unsigned int gart_buffer_offset; /* offset in card memory space */
+ unsigned int gart_texture_offset; /* offset in card memory space */
+
+ GLboolean depthHasSurface;
+
+ /* Configuration cache with default values for all contexts */
+ driOptionCache optionCache;
+} radeonScreenRec, *radeonScreenPtr;
+
+#endif /* __RADEON_SCREEN_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_span.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_span.c
new file mode 100644
index 000000000..2d15078d6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_span.c
@@ -0,0 +1,346 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_span.c,v 1.6 2002/10/30 12:51:56 alanh Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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 THE COPYRIGHT OWNER(S) 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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ * Keith Whitwell <keith@tungstengraphics.com>
+ *
+ */
+
+#include "glheader.h"
+#include "swrast/swrast.h"
+
+#include "radeon_context.h"
+#include "radeon_ioctl.h"
+#include "radeon_state.h"
+#include "radeon_span.h"
+#include "radeon_tex.h"
+
+#define DBG 0
+
+#define LOCAL_VARS \
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx); \
+ radeonScreenPtr radeonScreen = rmesa->radeonScreen; \
+ __DRIscreenPrivate *sPriv = rmesa->dri.screen; \
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable; \
+ GLuint pitch = radeonScreen->frontPitch * radeonScreen->cpp; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(sPriv->pFB + \
+ rmesa->state.color.drawOffset + \
+ (dPriv->x * radeonScreen->cpp) + \
+ (dPriv->y * pitch)); \
+ char *read_buf = (char *)(sPriv->pFB + \
+ rmesa->state.pixel.readOffset + \
+ (dPriv->x * radeonScreen->cpp) + \
+ (dPriv->y * pitch)); \
+ GLuint p; \
+ (void) read_buf; (void) buf; (void) p
+
+#define LOCAL_DEPTH_VARS \
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx); \
+ radeonScreenPtr radeonScreen = rmesa->radeonScreen; \
+ __DRIscreenPrivate *sPriv = rmesa->dri.screen; \
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable; \
+ GLuint height = dPriv->h; \
+ GLuint xo = dPriv->x; \
+ GLuint yo = dPriv->y; \
+ char *buf = (char *)(sPriv->pFB + radeonScreen->depthOffset); \
+ (void) buf
+
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
+
+#define Y_FLIP( _y ) (height - _y - 1)
+
+#define HW_LOCK()
+
+#define HW_UNLOCK()
+
+
+
+/* ================================================================
+ * Color buffer
+ */
+
+/* 16 bit, RGB565 color spanline and pixel functions
+ */
+#define SPANTMP_PIXEL_FMT GL_RGB
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
+
+#define TAG(x) radeon##x##_RGB565
+#define TAG2(x,y) radeon##x##_RGB565##y
+#include "spantmp2.h"
+
+/* 32 bit, ARGB8888 color spanline and pixel functions
+ */
+#define SPANTMP_PIXEL_FMT GL_BGRA
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
+
+#define TAG(x) radeon##x##_ARGB8888
+#define TAG2(x,y) radeon##x##_ARGB8888##y
+#include "spantmp2.h"
+
+
+/* ================================================================
+ * Depth buffer
+ */
+
+/* The Radeon family has depth tiling on all the time, so we have to convert
+ * the x,y coordinates into the memory bus address (mba) in the same
+ * manner as the engine. In each case, the linear block address (ba)
+ * is calculated, and then wired with x and y to produce the final
+ * memory address.
+ * The chip will do address translation on its own if the surface registers
+ * are set up correctly. It is not quite enough to get it working with hyperz too...
+ */
+
+static GLuint radeon_mba_z32( radeonContextPtr rmesa,
+ GLint x, GLint y )
+{
+ GLuint pitch = rmesa->radeonScreen->frontPitch;
+ if (rmesa->radeonScreen->depthHasSurface) {
+ return 4*(x + y*pitch);
+ }
+ else {
+ GLuint ba, address = 0; /* a[0..1] = 0 */
+
+ ba = (y / 16) * (pitch / 16) + (x / 16);
+
+ address |= (x & 0x7) << 2; /* a[2..4] = x[0..2] */
+ address |= (y & 0x3) << 5; /* a[5..6] = y[0..1] */
+ address |=
+ (((x & 0x10) >> 2) ^ (y & 0x4)) << 5; /* a[7] = x[4] ^ y[2] */
+ address |= (ba & 0x3) << 8; /* a[8..9] = ba[0..1] */
+
+ address |= (y & 0x8) << 7; /* a[10] = y[3] */
+ address |=
+ (((x & 0x8) << 1) ^ (y & 0x10)) << 7; /* a[11] = x[3] ^ y[4] */
+ address |= (ba & ~0x3) << 10; /* a[12..] = ba[2..] */
+
+ return address;
+ }
+}
+
+static __inline GLuint radeon_mba_z16( radeonContextPtr rmesa, GLint x, GLint y )
+{
+ GLuint pitch = rmesa->radeonScreen->frontPitch;
+ if (rmesa->radeonScreen->depthHasSurface) {
+ return 2*(x + y*pitch);
+ }
+ else {
+ GLuint ba, address = 0; /* a[0] = 0 */
+
+ ba = (y / 16) * (pitch / 32) + (x / 32);
+
+ address |= (x & 0x7) << 1; /* a[1..3] = x[0..2] */
+ address |= (y & 0x7) << 4; /* a[4..6] = y[0..2] */
+ address |= (x & 0x8) << 4; /* a[7] = x[3] */
+ address |= (ba & 0x3) << 8; /* a[8..9] = ba[0..1] */
+ address |= (y & 0x8) << 7; /* a[10] = y[3] */
+ address |= ((x & 0x10) ^ (y & 0x10)) << 7; /* a[11] = x[4] ^ y[4] */
+ address |= (ba & ~0x3) << 10; /* a[12..] = ba[2..] */
+
+ return address;
+ }
+}
+
+
+/* 16-bit depth buffer functions
+ */
+#define WRITE_DEPTH( _x, _y, d ) \
+ *(GLushort *)(buf + radeon_mba_z16( rmesa, _x + xo, _y + yo )) = d;
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLushort *)(buf + radeon_mba_z16( rmesa, _x + xo, _y + yo ));
+
+#define TAG(x) radeon##x##_16
+#include "depthtmp.h"
+
+/* 24 bit depth, 8 bit stencil depthbuffer functions
+ */
+#define WRITE_DEPTH( _x, _y, d ) \
+do { \
+ GLuint offset = radeon_mba_z32( rmesa, _x + xo, _y + yo ); \
+ GLuint tmp = *(GLuint *)(buf + offset); \
+ tmp &= 0xff000000; \
+ tmp |= ((d) & 0x00ffffff); \
+ *(GLuint *)(buf + offset) = tmp; \
+} while (0)
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLuint *)(buf + radeon_mba_z32( rmesa, _x + xo, \
+ _y + yo )) & 0x00ffffff;
+
+#define TAG(x) radeon##x##_24_8
+#include "depthtmp.h"
+
+
+/* ================================================================
+ * Stencil buffer
+ */
+
+/* 24 bit depth, 8 bit stencil depthbuffer functions
+ */
+#define WRITE_STENCIL( _x, _y, d ) \
+do { \
+ GLuint offset = radeon_mba_z32( rmesa, _x + xo, _y + yo ); \
+ GLuint tmp = *(GLuint *)(buf + offset); \
+ tmp &= 0x00ffffff; \
+ tmp |= (((d) & 0xff) << 24); \
+ *(GLuint *)(buf + offset) = tmp; \
+} while (0)
+
+#define READ_STENCIL( d, _x, _y ) \
+do { \
+ GLuint offset = radeon_mba_z32( rmesa, _x + xo, _y + yo ); \
+ GLuint tmp = *(GLuint *)(buf + offset); \
+ tmp &= 0xff000000; \
+ d = tmp >> 24; \
+} while (0)
+
+#define TAG(x) radeon##x##_24_8
+#include "stenciltmp.h"
+
+
+/*
+ * This function is called to specify which buffer to read and write
+ * for software rasterization (swrast) fallbacks. This doesn't necessarily
+ * correspond to glDrawBuffer() or glReadBuffer() calls.
+ */
+static void radeonSetBuffer( GLcontext *ctx,
+ GLframebuffer *colorBuffer,
+ GLuint bufferBit )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ switch ( bufferBit ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ if ( rmesa->sarea->pfCurrentPage == 1 ) {
+ rmesa->state.pixel.readOffset = rmesa->radeonScreen->backOffset;
+ rmesa->state.pixel.readPitch = rmesa->radeonScreen->backPitch;
+ rmesa->state.color.drawOffset = rmesa->radeonScreen->backOffset;
+ rmesa->state.color.drawPitch = rmesa->radeonScreen->backPitch;
+ } else {
+ rmesa->state.pixel.readOffset = rmesa->radeonScreen->frontOffset;
+ rmesa->state.pixel.readPitch = rmesa->radeonScreen->frontPitch;
+ rmesa->state.color.drawOffset = rmesa->radeonScreen->frontOffset;
+ rmesa->state.color.drawPitch = rmesa->radeonScreen->frontPitch;
+ }
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ if ( rmesa->sarea->pfCurrentPage == 1 ) {
+ rmesa->state.pixel.readOffset = rmesa->radeonScreen->frontOffset;
+ rmesa->state.pixel.readPitch = rmesa->radeonScreen->frontPitch;
+ rmesa->state.color.drawOffset = rmesa->radeonScreen->frontOffset;
+ rmesa->state.color.drawPitch = rmesa->radeonScreen->frontPitch;
+ } else {
+ rmesa->state.pixel.readOffset = rmesa->radeonScreen->backOffset;
+ rmesa->state.pixel.readPitch = rmesa->radeonScreen->backPitch;
+ rmesa->state.color.drawOffset = rmesa->radeonScreen->backOffset;
+ rmesa->state.color.drawPitch = rmesa->radeonScreen->backPitch;
+ }
+ break;
+ default:
+ assert(0);
+ break;
+ }
+}
+
+/* Move locking out to get reasonable span performance (10x better
+ * than doing this in HW_LOCK above). WaitForIdle() is the main
+ * culprit.
+ */
+
+static void radeonSpanRenderStart( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+
+ RADEON_FIREVERTICES( rmesa );
+ LOCK_HARDWARE( rmesa );
+ radeonWaitForIdleLocked( rmesa );
+}
+
+static void radeonSpanRenderFinish( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+ _swrast_flush( ctx );
+ UNLOCK_HARDWARE( rmesa );
+}
+
+void radeonInitSpanFuncs( GLcontext *ctx )
+{
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetBuffer = radeonSetBuffer;
+ swdd->SpanRenderStart = radeonSpanRenderStart;
+ swdd->SpanRenderFinish = radeonSpanRenderFinish;
+}
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+radeonSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ radeonInitPointers_RGB565(&drb->Base);
+ }
+ else {
+ radeonInitPointers_ARGB8888(&drb->Base);
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = radeonReadDepthSpan_16;
+ drb->Base.GetValues = radeonReadDepthPixels_16;
+ drb->Base.PutRow = radeonWriteDepthSpan_16;
+ drb->Base.PutMonoRow = radeonWriteMonoDepthSpan_16;
+ drb->Base.PutValues = radeonWriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = radeonReadDepthSpan_24_8;
+ drb->Base.GetValues = radeonReadDepthPixels_24_8;
+ drb->Base.PutRow = radeonWriteDepthSpan_24_8;
+ drb->Base.PutMonoRow = radeonWriteMonoDepthSpan_24_8;
+ drb->Base.PutValues = radeonWriteDepthPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = radeonReadStencilSpan_24_8;
+ drb->Base.GetValues = radeonReadStencilPixels_24_8;
+ drb->Base.PutRow = radeonWriteStencilSpan_24_8;
+ drb->Base.PutMonoRow = radeonWriteMonoStencilSpan_24_8;
+ drb->Base.PutValues = radeonWriteStencilPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_span.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_span.h
new file mode 100644
index 000000000..13b308e1c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_span.h
@@ -0,0 +1,46 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_span.h,v 1.2 2002/02/22 21:45:01 dawes Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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 THE COPYRIGHT OWNER(S) 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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ */
+
+#ifndef __RADEON_SPAN_H__
+#define __RADEON_SPAN_H__
+
+#include "drirenderbuffer.h"
+
+extern void radeonInitSpanFuncs( GLcontext *ctx );
+
+extern void radeonSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_state.c
new file mode 100644
index 000000000..3a491f5de
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_state.c
@@ -0,0 +1,2295 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_state.c,v 1.8 2002/12/16 16:18:58 dawes Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 VA Linux Systems Inc., Fremont, 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 THE COPYRIGHT OWNER(S) 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:
+ * Gareth Hughes <gareth@valinux.com>
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "api_arrayelt.h"
+#include "enums.h"
+#include "colormac.h"
+#include "state.h"
+#include "buffers.h"
+#include "context.h"
+
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+#include "main/light.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "radeon_context.h"
+#include "radeon_ioctl.h"
+#include "radeon_state.h"
+#include "radeon_tcl.h"
+#include "radeon_tex.h"
+#include "radeon_swtcl.h"
+#include "radeon_vtxfmt.h"
+
+/* =============================================================
+ * Alpha blending
+ */
+
+static void radeonAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ int pp_misc = rmesa->hw.ctx.cmd[CTX_PP_MISC];
+ GLubyte refByte;
+
+ CLAMPED_FLOAT_TO_UBYTE(refByte, ref);
+
+ RADEON_STATECHANGE( rmesa, ctx );
+
+ pp_misc &= ~(RADEON_ALPHA_TEST_OP_MASK | RADEON_REF_ALPHA_MASK);
+ pp_misc |= (refByte & RADEON_REF_ALPHA_MASK);
+
+ switch ( func ) {
+ case GL_NEVER:
+ pp_misc |= RADEON_ALPHA_TEST_FAIL;
+ break;
+ case GL_LESS:
+ pp_misc |= RADEON_ALPHA_TEST_LESS;
+ break;
+ case GL_EQUAL:
+ pp_misc |= RADEON_ALPHA_TEST_EQUAL;
+ break;
+ case GL_LEQUAL:
+ pp_misc |= RADEON_ALPHA_TEST_LEQUAL;
+ break;
+ case GL_GREATER:
+ pp_misc |= RADEON_ALPHA_TEST_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ pp_misc |= RADEON_ALPHA_TEST_NEQUAL;
+ break;
+ case GL_GEQUAL:
+ pp_misc |= RADEON_ALPHA_TEST_GEQUAL;
+ break;
+ case GL_ALWAYS:
+ pp_misc |= RADEON_ALPHA_TEST_PASS;
+ break;
+ }
+
+ rmesa->hw.ctx.cmd[CTX_PP_MISC] = pp_misc;
+}
+
+static void radeonBlendEquationSeparate( GLcontext *ctx,
+ GLenum modeRGB, GLenum modeA )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint b = rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] & ~RADEON_COMB_FCN_MASK;
+ GLboolean fallback = GL_FALSE;
+
+ assert( modeRGB == modeA );
+
+ switch ( modeRGB ) {
+ case GL_FUNC_ADD:
+ case GL_LOGIC_OP:
+ b |= RADEON_COMB_FCN_ADD_CLAMP;
+ break;
+
+ case GL_FUNC_SUBTRACT:
+ b |= RADEON_COMB_FCN_SUB_CLAMP;
+ break;
+
+ default:
+ if (ctx->Color.BlendEnabled)
+ fallback = GL_TRUE;
+ else
+ b |= RADEON_COMB_FCN_ADD_CLAMP;
+ break;
+ }
+
+ FALLBACK( rmesa, RADEON_FALLBACK_BLEND_EQ, fallback );
+ if ( !fallback ) {
+ RADEON_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] = b;
+ if ( ctx->Color._LogicOpEnabled ) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_ROP_ENABLE;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ROP_ENABLE;
+ }
+ }
+}
+
+static void radeonBlendFuncSeparate( GLcontext *ctx,
+ GLenum sfactorRGB, GLenum dfactorRGB,
+ GLenum sfactorA, GLenum dfactorA )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint b = rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] &
+ ~(RADEON_SRC_BLEND_MASK | RADEON_DST_BLEND_MASK);
+ GLboolean fallback = GL_FALSE;
+
+ switch ( ctx->Color.BlendSrcRGB ) {
+ case GL_ZERO:
+ b |= RADEON_SRC_BLEND_GL_ZERO;
+ break;
+ case GL_ONE:
+ b |= RADEON_SRC_BLEND_GL_ONE;
+ break;
+ case GL_DST_COLOR:
+ b |= RADEON_SRC_BLEND_GL_DST_COLOR;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ b |= RADEON_SRC_BLEND_GL_ONE_MINUS_DST_COLOR;
+ break;
+ case GL_SRC_COLOR:
+ b |= RADEON_SRC_BLEND_GL_SRC_COLOR;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ b |= RADEON_SRC_BLEND_GL_ONE_MINUS_SRC_COLOR;
+ break;
+ case GL_SRC_ALPHA:
+ b |= RADEON_SRC_BLEND_GL_SRC_ALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ b |= RADEON_SRC_BLEND_GL_ONE_MINUS_SRC_ALPHA;
+ break;
+ case GL_DST_ALPHA:
+ b |= RADEON_SRC_BLEND_GL_DST_ALPHA;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ b |= RADEON_SRC_BLEND_GL_ONE_MINUS_DST_ALPHA;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ b |= RADEON_SRC_BLEND_GL_SRC_ALPHA_SATURATE;
+ break;
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ if (ctx->Color.BlendEnabled)
+ fallback = GL_TRUE;
+ else
+ b |= RADEON_SRC_BLEND_GL_ONE;
+ break;
+ default:
+ break;
+ }
+
+ switch ( ctx->Color.BlendDstRGB ) {
+ case GL_ZERO:
+ b |= RADEON_DST_BLEND_GL_ZERO;
+ break;
+ case GL_ONE:
+ b |= RADEON_DST_BLEND_GL_ONE;
+ break;
+ case GL_SRC_COLOR:
+ b |= RADEON_DST_BLEND_GL_SRC_COLOR;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ b |= RADEON_DST_BLEND_GL_ONE_MINUS_SRC_COLOR;
+ break;
+ case GL_SRC_ALPHA:
+ b |= RADEON_DST_BLEND_GL_SRC_ALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ b |= RADEON_DST_BLEND_GL_ONE_MINUS_SRC_ALPHA;
+ break;
+ case GL_DST_COLOR:
+ b |= RADEON_DST_BLEND_GL_DST_COLOR;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ b |= RADEON_DST_BLEND_GL_ONE_MINUS_DST_COLOR;
+ break;
+ case GL_DST_ALPHA:
+ b |= RADEON_DST_BLEND_GL_DST_ALPHA;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ b |= RADEON_DST_BLEND_GL_ONE_MINUS_DST_ALPHA;
+ break;
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ if (ctx->Color.BlendEnabled)
+ fallback = GL_TRUE;
+ else
+ b |= RADEON_DST_BLEND_GL_ZERO;
+ break;
+ default:
+ break;
+ }
+
+ FALLBACK( rmesa, RADEON_FALLBACK_BLEND_FUNC, fallback );
+ if ( !fallback ) {
+ RADEON_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] = b;
+ }
+}
+
+
+/* =============================================================
+ * Depth testing
+ */
+
+static void radeonDepthFunc( GLcontext *ctx, GLenum func )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ RADEON_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] &= ~RADEON_Z_TEST_MASK;
+
+ switch ( ctx->Depth.Func ) {
+ case GL_NEVER:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_Z_TEST_NEVER;
+ break;
+ case GL_LESS:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_Z_TEST_LESS;
+ break;
+ case GL_EQUAL:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_Z_TEST_EQUAL;
+ break;
+ case GL_LEQUAL:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_Z_TEST_LEQUAL;
+ break;
+ case GL_GREATER:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_Z_TEST_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_Z_TEST_NEQUAL;
+ break;
+ case GL_GEQUAL:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_Z_TEST_GEQUAL;
+ break;
+ case GL_ALWAYS:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_Z_TEST_ALWAYS;
+ break;
+ }
+}
+
+
+static void radeonDepthMask( GLcontext *ctx, GLboolean flag )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ RADEON_STATECHANGE( rmesa, ctx );
+
+ if ( ctx->Depth.Mask ) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_Z_WRITE_ENABLE;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] &= ~RADEON_Z_WRITE_ENABLE;
+ }
+}
+
+static void radeonClearDepth( GLcontext *ctx, GLclampd d )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint format = (rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] &
+ RADEON_DEPTH_FORMAT_MASK);
+
+ switch ( format ) {
+ case RADEON_DEPTH_FORMAT_16BIT_INT_Z:
+ rmesa->state.depth.clear = d * 0x0000ffff;
+ break;
+ case RADEON_DEPTH_FORMAT_24BIT_INT_Z:
+ rmesa->state.depth.clear = d * 0x00ffffff;
+ break;
+ }
+}
+
+
+/* =============================================================
+ * Fog
+ */
+
+
+static void radeonFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ union { int i; float f; } c, d;
+ GLchan col[4];
+
+ c.i = rmesa->hw.fog.cmd[FOG_C];
+ d.i = rmesa->hw.fog.cmd[FOG_D];
+
+ switch (pname) {
+ case GL_FOG_MODE:
+ if (!ctx->Fog.Enabled)
+ return;
+ RADEON_STATECHANGE(rmesa, tcl);
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~RADEON_TCL_FOG_MASK;
+ switch (ctx->Fog.Mode) {
+ case GL_LINEAR:
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_TCL_FOG_LINEAR;
+ if (ctx->Fog.Start == ctx->Fog.End) {
+ c.f = 1.0F;
+ d.f = 1.0F;
+ }
+ else {
+ c.f = ctx->Fog.End/(ctx->Fog.End-ctx->Fog.Start);
+ d.f = 1.0/(ctx->Fog.End-ctx->Fog.Start);
+ }
+ break;
+ case GL_EXP:
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_TCL_FOG_EXP;
+ c.f = 0.0;
+ d.f = ctx->Fog.Density;
+ break;
+ case GL_EXP2:
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_TCL_FOG_EXP2;
+ c.f = 0.0;
+ d.f = -(ctx->Fog.Density * ctx->Fog.Density);
+ break;
+ default:
+ return;
+ }
+ break;
+ case GL_FOG_DENSITY:
+ switch (ctx->Fog.Mode) {
+ case GL_EXP:
+ c.f = 0.0;
+ d.f = ctx->Fog.Density;
+ break;
+ case GL_EXP2:
+ c.f = 0.0;
+ d.f = -(ctx->Fog.Density * ctx->Fog.Density);
+ break;
+ default:
+ break;
+ }
+ break;
+ case GL_FOG_START:
+ case GL_FOG_END:
+ if (ctx->Fog.Mode == GL_LINEAR) {
+ if (ctx->Fog.Start == ctx->Fog.End) {
+ c.f = 1.0F;
+ d.f = 1.0F;
+ } else {
+ c.f = ctx->Fog.End/(ctx->Fog.End-ctx->Fog.Start);
+ d.f = 1.0/(ctx->Fog.End-ctx->Fog.Start);
+ }
+ }
+ break;
+ case GL_FOG_COLOR:
+ RADEON_STATECHANGE( rmesa, ctx );
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( col, ctx->Fog.Color );
+ rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] =
+ radeonPackColor( 4, col[0], col[1], col[2], 0 );
+ break;
+ case GL_FOG_COORDINATE_SOURCE_EXT:
+ /* What to do?
+ */
+ break;
+ default:
+ return;
+ }
+
+ if (c.i != rmesa->hw.fog.cmd[FOG_C] || d.i != rmesa->hw.fog.cmd[FOG_D]) {
+ RADEON_STATECHANGE( rmesa, fog );
+ rmesa->hw.fog.cmd[FOG_C] = c.i;
+ rmesa->hw.fog.cmd[FOG_D] = d.i;
+ }
+}
+
+
+/* =============================================================
+ * Scissoring
+ */
+
+
+static GLboolean intersect_rect( drm_clip_rect_t *out,
+ drm_clip_rect_t *a,
+ drm_clip_rect_t *b )
+{
+ *out = *a;
+ if ( b->x1 > out->x1 ) out->x1 = b->x1;
+ if ( b->y1 > out->y1 ) out->y1 = b->y1;
+ if ( b->x2 < out->x2 ) out->x2 = b->x2;
+ if ( b->y2 < out->y2 ) out->y2 = b->y2;
+ if ( out->x1 >= out->x2 ) return GL_FALSE;
+ if ( out->y1 >= out->y2 ) return GL_FALSE;
+ return GL_TRUE;
+}
+
+
+void radeonRecalcScissorRects( radeonContextPtr rmesa )
+{
+ drm_clip_rect_t *out;
+ int i;
+
+ /* Grow cliprect store?
+ */
+ if (rmesa->state.scissor.numAllocedClipRects < rmesa->numClipRects) {
+ while (rmesa->state.scissor.numAllocedClipRects < rmesa->numClipRects) {
+ rmesa->state.scissor.numAllocedClipRects += 1; /* zero case */
+ rmesa->state.scissor.numAllocedClipRects *= 2;
+ }
+
+ if (rmesa->state.scissor.pClipRects)
+ FREE(rmesa->state.scissor.pClipRects);
+
+ rmesa->state.scissor.pClipRects =
+ MALLOC( rmesa->state.scissor.numAllocedClipRects *
+ sizeof(drm_clip_rect_t) );
+
+ if ( rmesa->state.scissor.pClipRects == NULL ) {
+ rmesa->state.scissor.numAllocedClipRects = 0;
+ return;
+ }
+ }
+
+ out = rmesa->state.scissor.pClipRects;
+ rmesa->state.scissor.numClipRects = 0;
+
+ for ( i = 0 ; i < rmesa->numClipRects ; i++ ) {
+ if ( intersect_rect( out,
+ &rmesa->pClipRects[i],
+ &rmesa->state.scissor.rect ) ) {
+ rmesa->state.scissor.numClipRects++;
+ out++;
+ }
+ }
+}
+
+
+static void radeonUpdateScissor( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if ( rmesa->dri.drawable ) {
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+
+ int x = ctx->Scissor.X;
+ int y = dPriv->h - ctx->Scissor.Y - ctx->Scissor.Height;
+ int w = ctx->Scissor.X + ctx->Scissor.Width - 1;
+ int h = dPriv->h - ctx->Scissor.Y - 1;
+
+ rmesa->state.scissor.rect.x1 = x + dPriv->x;
+ rmesa->state.scissor.rect.y1 = y + dPriv->y;
+ rmesa->state.scissor.rect.x2 = w + dPriv->x + 1;
+ rmesa->state.scissor.rect.y2 = h + dPriv->y + 1;
+
+ radeonRecalcScissorRects( rmesa );
+ }
+}
+
+
+static void radeonScissor( GLcontext *ctx,
+ GLint x, GLint y, GLsizei w, GLsizei h )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if ( ctx->Scissor.Enabled ) {
+ RADEON_FIREVERTICES( rmesa ); /* don't pipeline cliprect changes */
+ radeonUpdateScissor( ctx );
+ }
+
+}
+
+
+/* =============================================================
+ * Culling
+ */
+
+static void radeonCullFace( GLcontext *ctx, GLenum unused )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint s = rmesa->hw.set.cmd[SET_SE_CNTL];
+ GLuint t = rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL];
+
+ s |= RADEON_FFACE_SOLID | RADEON_BFACE_SOLID;
+ t &= ~(RADEON_CULL_FRONT | RADEON_CULL_BACK);
+
+ if ( ctx->Polygon.CullFlag ) {
+ switch ( ctx->Polygon.CullFaceMode ) {
+ case GL_FRONT:
+ s &= ~RADEON_FFACE_SOLID;
+ t |= RADEON_CULL_FRONT;
+ break;
+ case GL_BACK:
+ s &= ~RADEON_BFACE_SOLID;
+ t |= RADEON_CULL_BACK;
+ break;
+ case GL_FRONT_AND_BACK:
+ s &= ~(RADEON_FFACE_SOLID | RADEON_BFACE_SOLID);
+ t |= (RADEON_CULL_FRONT | RADEON_CULL_BACK);
+ break;
+ }
+ }
+
+ if ( rmesa->hw.set.cmd[SET_SE_CNTL] != s ) {
+ RADEON_STATECHANGE(rmesa, set );
+ rmesa->hw.set.cmd[SET_SE_CNTL] = s;
+ }
+
+ if ( rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] != t ) {
+ RADEON_STATECHANGE(rmesa, tcl );
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] = t;
+ }
+}
+
+static void radeonFrontFace( GLcontext *ctx, GLenum mode )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ RADEON_STATECHANGE( rmesa, set );
+ rmesa->hw.set.cmd[SET_SE_CNTL] &= ~RADEON_FFACE_CULL_DIR_MASK;
+
+ RADEON_STATECHANGE( rmesa, tcl );
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~RADEON_CULL_FRONT_IS_CCW;
+
+ switch ( mode ) {
+ case GL_CW:
+ rmesa->hw.set.cmd[SET_SE_CNTL] |= RADEON_FFACE_CULL_CW;
+ break;
+ case GL_CCW:
+ rmesa->hw.set.cmd[SET_SE_CNTL] |= RADEON_FFACE_CULL_CCW;
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_CULL_FRONT_IS_CCW;
+ break;
+ }
+}
+
+
+/* =============================================================
+ * Line state
+ */
+static void radeonLineWidth( GLcontext *ctx, GLfloat widthf )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ RADEON_STATECHANGE( rmesa, lin );
+ RADEON_STATECHANGE( rmesa, set );
+
+ /* Line width is stored in U6.4 format.
+ */
+ rmesa->hw.lin.cmd[LIN_SE_LINE_WIDTH] = (GLuint)(widthf * 16.0);
+ if ( widthf > 1.0 ) {
+ rmesa->hw.set.cmd[SET_SE_CNTL] |= RADEON_WIDELINE_ENABLE;
+ } else {
+ rmesa->hw.set.cmd[SET_SE_CNTL] &= ~RADEON_WIDELINE_ENABLE;
+ }
+}
+
+static void radeonLineStipple( GLcontext *ctx, GLint factor, GLushort pattern )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ RADEON_STATECHANGE( rmesa, lin );
+ rmesa->hw.lin.cmd[LIN_RE_LINE_PATTERN] =
+ ((((GLuint)factor & 0xff) << 16) | ((GLuint)pattern));
+}
+
+
+/* =============================================================
+ * Masks
+ */
+static void radeonColorMask( GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint mask = radeonPackColor( rmesa->radeonScreen->cpp,
+ ctx->Color.ColorMask[RCOMP],
+ ctx->Color.ColorMask[GCOMP],
+ ctx->Color.ColorMask[BCOMP],
+ ctx->Color.ColorMask[ACOMP] );
+
+ if ( rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK] != mask ) {
+ RADEON_STATECHANGE( rmesa, msk );
+ rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK] = mask;
+ }
+}
+
+
+/* =============================================================
+ * Polygon state
+ */
+
+static void radeonPolygonOffset( GLcontext *ctx,
+ GLfloat factor, GLfloat units )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat constant = units * rmesa->state.depth.scale;
+
+ RADEON_STATECHANGE( rmesa, zbs );
+ rmesa->hw.zbs.cmd[ZBS_SE_ZBIAS_FACTOR] = *(GLuint *)&factor;
+ rmesa->hw.zbs.cmd[ZBS_SE_ZBIAS_CONSTANT] = *(GLuint *)&constant;
+}
+
+static void radeonPolygonStipple( GLcontext *ctx, const GLubyte *mask )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint i;
+ drm_radeon_stipple_t stipple;
+
+ /* Must flip pattern upside down.
+ */
+ for ( i = 0 ; i < 32 ; i++ ) {
+ rmesa->state.stipple.mask[31 - i] = ((GLuint *) mask)[i];
+ }
+
+ /* TODO: push this into cmd mechanism
+ */
+ RADEON_FIREVERTICES( rmesa );
+ LOCK_HARDWARE( rmesa );
+
+ /* FIXME: Use window x,y offsets into stipple RAM.
+ */
+ stipple.mask = rmesa->state.stipple.mask;
+ drmCommandWrite( rmesa->dri.fd, DRM_RADEON_STIPPLE,
+ &stipple, sizeof(drm_radeon_stipple_t) );
+ UNLOCK_HARDWARE( rmesa );
+}
+
+static void radeonPolygonMode( GLcontext *ctx, GLenum face, GLenum mode )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLboolean flag = (ctx->_TriangleCaps & DD_TRI_UNFILLED) != 0;
+
+ /* Can't generally do unfilled via tcl, but some good special
+ * cases work.
+ */
+ TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_UNFILLED, flag);
+ if (rmesa->TclFallback) {
+ radeonChooseRenderState( ctx );
+ radeonChooseVertexState( ctx );
+ }
+}
+
+
+/* =============================================================
+ * Rendering attributes
+ *
+ * We really don't want to recalculate all this every time we bind a
+ * texture. These things shouldn't change all that often, so it makes
+ * sense to break them out of the core texture state update routines.
+ */
+
+/* Examine lighting and texture state to determine if separate specular
+ * should be enabled.
+ */
+static void radeonUpdateSpecular( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ u_int32_t p = rmesa->hw.ctx.cmd[CTX_PP_CNTL];
+
+ RADEON_STATECHANGE( rmesa, tcl );
+
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_SPECULAR;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] &= ~RADEON_TCL_COMPUTE_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] &= ~RADEON_TCL_VTX_PK_SPEC;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] &= ~RADEON_TCL_VTX_PK_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_LIGHTING_ENABLE;
+
+ p &= ~RADEON_SPECULAR_ENABLE;
+
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_DIFFUSE_SPECULAR_COMBINE;
+
+
+ if (ctx->Light.Enabled &&
+ ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) {
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_SPECULAR;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_SPEC;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LIGHTING_ENABLE;
+ p |= RADEON_SPECULAR_ENABLE;
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &=
+ ~RADEON_DIFFUSE_SPECULAR_COMBINE;
+ }
+ else if (ctx->Light.Enabled) {
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE;
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LIGHTING_ENABLE;
+ } else if (ctx->Fog.ColorSumEnabled ) {
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_SPEC;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE;
+ p |= RADEON_SPECULAR_ENABLE;
+ } else {
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_DIFFUSE;
+ }
+
+ if (ctx->Fog.Enabled) {
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] |= RADEON_TCL_COMPUTE_SPECULAR;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_PK_SPEC;
+
+ /* Bizzare: have to leave lighting enabled to get fog.
+ */
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LIGHTING_ENABLE;
+ }
+
+ if (NEED_SECONDARY_COLOR(ctx)) {
+ assert( (p & RADEON_SPECULAR_ENABLE) != 0 );
+ } else {
+ assert( (p & RADEON_SPECULAR_ENABLE) == 0 );
+ }
+
+ if ( rmesa->hw.ctx.cmd[CTX_PP_CNTL] != p ) {
+ RADEON_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] = p;
+ }
+
+ /* Update vertex/render formats
+ */
+ if (rmesa->TclFallback) {
+ radeonChooseRenderState( ctx );
+ radeonChooseVertexState( ctx );
+ }
+}
+
+
+/* =============================================================
+ * Materials
+ */
+
+
+/* Update on colormaterial, material emmissive/ambient,
+ * lightmodel.globalambient
+ */
+static void update_global_ambient( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ float *fcmd = (float *)RADEON_DB_STATE( glt );
+
+ /* Need to do more if both emmissive & ambient are PREMULT:
+ * Hope this is not needed for MULT
+ */
+ if ((rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &
+ ((3 << RADEON_EMISSIVE_SOURCE_SHIFT) |
+ (3 << RADEON_AMBIENT_SOURCE_SHIFT))) == 0)
+ {
+ COPY_3V( &fcmd[GLT_RED],
+ ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_EMISSION]);
+ ACC_SCALE_3V( &fcmd[GLT_RED],
+ ctx->Light.Model.Ambient,
+ ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_AMBIENT]);
+ }
+ else
+ {
+ COPY_3V( &fcmd[GLT_RED], ctx->Light.Model.Ambient );
+ }
+
+ RADEON_DB_STATECHANGE(rmesa, &rmesa->hw.glt);
+}
+
+/* Update on change to
+ * - light[p].colors
+ * - light[p].enabled
+ */
+static void update_light_colors( GLcontext *ctx, GLuint p )
+{
+ struct gl_light *l = &ctx->Light.Light[p];
+
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ if (l->Enabled) {
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ float *fcmd = (float *)RADEON_DB_STATE( lit[p] );
+
+ COPY_4V( &fcmd[LIT_AMBIENT_RED], l->Ambient );
+ COPY_4V( &fcmd[LIT_DIFFUSE_RED], l->Diffuse );
+ COPY_4V( &fcmd[LIT_SPECULAR_RED], l->Specular );
+
+ RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.lit[p] );
+ }
+}
+
+/* Also fallback for asym colormaterial mode in twoside lighting...
+ */
+static void check_twoside_fallback( GLcontext *ctx )
+{
+ GLboolean fallback = GL_FALSE;
+ GLint i;
+
+ if (ctx->Light.Enabled && ctx->Light.Model.TwoSide) {
+ if (ctx->Light.ColorMaterialEnabled &&
+ (ctx->Light.ColorMaterialBitmask & BACK_MATERIAL_BITS) !=
+ ((ctx->Light.ColorMaterialBitmask & FRONT_MATERIAL_BITS)<<1))
+ fallback = GL_TRUE;
+ else {
+ for (i = MAT_ATTRIB_FRONT_AMBIENT; i < MAT_ATTRIB_FRONT_INDEXES; i+=2)
+ if (memcmp( ctx->Light.Material.Attrib[i],
+ ctx->Light.Material.Attrib[i+1],
+ sizeof(GLfloat)*4) != 0) {
+ fallback = GL_TRUE;
+ break;
+ }
+ }
+ }
+
+ TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_LIGHT_TWOSIDE, fallback );
+}
+
+
+static void radeonColorMaterial( GLcontext *ctx, GLenum face, GLenum mode )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint light_model_ctl1 = rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL];
+
+ light_model_ctl1 &= ~((3 << RADEON_EMISSIVE_SOURCE_SHIFT) |
+ (3 << RADEON_AMBIENT_SOURCE_SHIFT) |
+ (3 << RADEON_DIFFUSE_SOURCE_SHIFT) |
+ (3 << RADEON_SPECULAR_SOURCE_SHIFT));
+
+ if (ctx->Light.ColorMaterialEnabled) {
+ GLuint mask = ctx->Light.ColorMaterialBitmask;
+
+ if (mask & MAT_BIT_FRONT_EMISSION) {
+ light_model_ctl1 |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE <<
+ RADEON_EMISSIVE_SOURCE_SHIFT);
+ }
+ else {
+ light_model_ctl1 |= (RADEON_LM_SOURCE_STATE_MULT <<
+ RADEON_EMISSIVE_SOURCE_SHIFT);
+ }
+
+ if (mask & MAT_BIT_FRONT_AMBIENT) {
+ light_model_ctl1 |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE <<
+ RADEON_AMBIENT_SOURCE_SHIFT);
+ }
+ else {
+ light_model_ctl1 |= (RADEON_LM_SOURCE_STATE_MULT <<
+ RADEON_AMBIENT_SOURCE_SHIFT);
+ }
+
+ if (mask & MAT_BIT_FRONT_DIFFUSE) {
+ light_model_ctl1 |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE <<
+ RADEON_DIFFUSE_SOURCE_SHIFT);
+ }
+ else {
+ light_model_ctl1 |= (RADEON_LM_SOURCE_STATE_MULT <<
+ RADEON_DIFFUSE_SOURCE_SHIFT);
+ }
+
+ if (mask & MAT_BIT_FRONT_SPECULAR) {
+ light_model_ctl1 |= (RADEON_LM_SOURCE_VERTEX_DIFFUSE <<
+ RADEON_SPECULAR_SOURCE_SHIFT);
+ }
+ else {
+ light_model_ctl1 |= (RADEON_LM_SOURCE_STATE_MULT <<
+ RADEON_SPECULAR_SOURCE_SHIFT);
+ }
+ }
+ else {
+ /* Default to MULT:
+ */
+ light_model_ctl1 |= (RADEON_LM_SOURCE_STATE_MULT << RADEON_EMISSIVE_SOURCE_SHIFT) |
+ (RADEON_LM_SOURCE_STATE_MULT << RADEON_AMBIENT_SOURCE_SHIFT) |
+ (RADEON_LM_SOURCE_STATE_MULT << RADEON_DIFFUSE_SOURCE_SHIFT) |
+ (RADEON_LM_SOURCE_STATE_MULT << RADEON_SPECULAR_SOURCE_SHIFT);
+ }
+
+ if (light_model_ctl1 != rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL]) {
+ RADEON_STATECHANGE( rmesa, tcl );
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] = light_model_ctl1;
+ }
+}
+
+void radeonUpdateMaterial( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
+ GLfloat *fcmd = (GLfloat *)RADEON_DB_STATE( mtl );
+ GLuint mask = ~0;
+
+ if (ctx->Light.ColorMaterialEnabled)
+ mask &= ~ctx->Light.ColorMaterialBitmask;
+
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+
+ if (mask & MAT_BIT_FRONT_EMISSION) {
+ fcmd[MTL_EMMISSIVE_RED] = mat[MAT_ATTRIB_FRONT_EMISSION][0];
+ fcmd[MTL_EMMISSIVE_GREEN] = mat[MAT_ATTRIB_FRONT_EMISSION][1];
+ fcmd[MTL_EMMISSIVE_BLUE] = mat[MAT_ATTRIB_FRONT_EMISSION][2];
+ fcmd[MTL_EMMISSIVE_ALPHA] = mat[MAT_ATTRIB_FRONT_EMISSION][3];
+ }
+ if (mask & MAT_BIT_FRONT_AMBIENT) {
+ fcmd[MTL_AMBIENT_RED] = mat[MAT_ATTRIB_FRONT_AMBIENT][0];
+ fcmd[MTL_AMBIENT_GREEN] = mat[MAT_ATTRIB_FRONT_AMBIENT][1];
+ fcmd[MTL_AMBIENT_BLUE] = mat[MAT_ATTRIB_FRONT_AMBIENT][2];
+ fcmd[MTL_AMBIENT_ALPHA] = mat[MAT_ATTRIB_FRONT_AMBIENT][3];
+ }
+ if (mask & MAT_BIT_FRONT_DIFFUSE) {
+ fcmd[MTL_DIFFUSE_RED] = mat[MAT_ATTRIB_FRONT_DIFFUSE][0];
+ fcmd[MTL_DIFFUSE_GREEN] = mat[MAT_ATTRIB_FRONT_DIFFUSE][1];
+ fcmd[MTL_DIFFUSE_BLUE] = mat[MAT_ATTRIB_FRONT_DIFFUSE][2];
+ fcmd[MTL_DIFFUSE_ALPHA] = mat[MAT_ATTRIB_FRONT_DIFFUSE][3];
+ }
+ if (mask & MAT_BIT_FRONT_SPECULAR) {
+ fcmd[MTL_SPECULAR_RED] = mat[MAT_ATTRIB_FRONT_SPECULAR][0];
+ fcmd[MTL_SPECULAR_GREEN] = mat[MAT_ATTRIB_FRONT_SPECULAR][1];
+ fcmd[MTL_SPECULAR_BLUE] = mat[MAT_ATTRIB_FRONT_SPECULAR][2];
+ fcmd[MTL_SPECULAR_ALPHA] = mat[MAT_ATTRIB_FRONT_SPECULAR][3];
+ }
+ if (mask & MAT_BIT_FRONT_SHININESS) {
+ fcmd[MTL_SHININESS] = mat[MAT_ATTRIB_FRONT_SHININESS][0];
+ }
+
+ RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.mtl );
+
+ check_twoside_fallback( ctx );
+/* update_global_ambient( ctx );*/
+}
+
+/* _NEW_LIGHT
+ * _NEW_MODELVIEW
+ * _MESA_NEW_NEED_EYE_COORDS
+ *
+ * Uses derived state from mesa:
+ * _VP_inf_norm
+ * _h_inf_norm
+ * _Position
+ * _NormDirection
+ * _ModelViewInvScale
+ * _NeedEyeCoords
+ * _EyeZDir
+ *
+ * which are calculated in light.c and are correct for the current
+ * lighting space (model or eye), hence dependencies on _NEW_MODELVIEW
+ * and _MESA_NEW_NEED_EYE_COORDS.
+ */
+static void update_light( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ /* Have to check these, or have an automatic shortcircuit mechanism
+ * to remove noop statechanges. (Or just do a better job on the
+ * front end).
+ */
+ {
+ GLuint tmp = rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL];
+
+ if (ctx->_NeedEyeCoords)
+ tmp &= ~RADEON_LIGHT_IN_MODELSPACE;
+ else
+ tmp |= RADEON_LIGHT_IN_MODELSPACE;
+
+
+ /* Leave this test disabled: (unexplained q3 lockup) (even with
+ new packets)
+ */
+ if (tmp != rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL])
+ {
+ RADEON_STATECHANGE( rmesa, tcl );
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] = tmp;
+ }
+ }
+
+ {
+ GLfloat *fcmd = (GLfloat *)RADEON_DB_STATE( eye );
+ fcmd[EYE_X] = ctx->_EyeZDir[0];
+ fcmd[EYE_Y] = ctx->_EyeZDir[1];
+ fcmd[EYE_Z] = - ctx->_EyeZDir[2];
+ fcmd[EYE_RESCALE_FACTOR] = ctx->_ModelViewInvScale;
+ RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.eye );
+ }
+
+
+
+ if (ctx->Light.Enabled) {
+ GLint p;
+ for (p = 0 ; p < MAX_LIGHTS; p++) {
+ if (ctx->Light.Light[p].Enabled) {
+ struct gl_light *l = &ctx->Light.Light[p];
+ GLfloat *fcmd = (GLfloat *)RADEON_DB_STATE( lit[p] );
+
+ if (l->EyePosition[3] == 0.0) {
+ COPY_3FV( &fcmd[LIT_POSITION_X], l->_VP_inf_norm );
+ COPY_3FV( &fcmd[LIT_DIRECTION_X], l->_h_inf_norm );
+ fcmd[LIT_POSITION_W] = 0;
+ fcmd[LIT_DIRECTION_W] = 0;
+ } else {
+ COPY_4V( &fcmd[LIT_POSITION_X], l->_Position );
+ fcmd[LIT_DIRECTION_X] = -l->_NormDirection[0];
+ fcmd[LIT_DIRECTION_Y] = -l->_NormDirection[1];
+ fcmd[LIT_DIRECTION_Z] = -l->_NormDirection[2];
+ fcmd[LIT_DIRECTION_W] = 0;
+ }
+
+ RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.lit[p] );
+ }
+ }
+ }
+}
+
+static void radeonLightfv( GLcontext *ctx, GLenum light,
+ GLenum pname, const GLfloat *params )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLint p = light - GL_LIGHT0;
+ struct gl_light *l = &ctx->Light.Light[p];
+ GLfloat *fcmd = (GLfloat *)rmesa->hw.lit[p].cmd;
+
+
+ switch (pname) {
+ case GL_AMBIENT:
+ case GL_DIFFUSE:
+ case GL_SPECULAR:
+ update_light_colors( ctx, p );
+ break;
+
+ case GL_SPOT_DIRECTION:
+ /* picked up in update_light */
+ break;
+
+ case GL_POSITION: {
+ /* positions picked up in update_light, but can do flag here */
+ GLuint flag;
+ GLuint idx = TCL_PER_LIGHT_CTL_0 + p/2;
+
+ /* FIXME: Set RANGE_ATTEN only when needed */
+ if (p&1)
+ flag = RADEON_LIGHT_1_IS_LOCAL;
+ else
+ flag = RADEON_LIGHT_0_IS_LOCAL;
+
+ RADEON_STATECHANGE(rmesa, tcl);
+ if (l->EyePosition[3] != 0.0F)
+ rmesa->hw.tcl.cmd[idx] |= flag;
+ else
+ rmesa->hw.tcl.cmd[idx] &= ~flag;
+ break;
+ }
+
+ case GL_SPOT_EXPONENT:
+ RADEON_STATECHANGE(rmesa, lit[p]);
+ fcmd[LIT_SPOT_EXPONENT] = params[0];
+ break;
+
+ case GL_SPOT_CUTOFF: {
+ GLuint flag = (p&1) ? RADEON_LIGHT_1_IS_SPOT : RADEON_LIGHT_0_IS_SPOT;
+ GLuint idx = TCL_PER_LIGHT_CTL_0 + p/2;
+
+ RADEON_STATECHANGE(rmesa, lit[p]);
+ fcmd[LIT_SPOT_CUTOFF] = l->_CosCutoff;
+
+ RADEON_STATECHANGE(rmesa, tcl);
+ if (l->SpotCutoff != 180.0F)
+ rmesa->hw.tcl.cmd[idx] |= flag;
+ else
+ rmesa->hw.tcl.cmd[idx] &= ~flag;
+
+ break;
+ }
+
+ case GL_CONSTANT_ATTENUATION:
+ RADEON_STATECHANGE(rmesa, lit[p]);
+ fcmd[LIT_ATTEN_CONST] = params[0];
+ if ( params[0] == 0.0 )
+ fcmd[LIT_ATTEN_CONST_INV] = FLT_MAX;
+ else
+ fcmd[LIT_ATTEN_CONST_INV] = 1.0 / params[0];
+ break;
+ case GL_LINEAR_ATTENUATION:
+ RADEON_STATECHANGE(rmesa, lit[p]);
+ fcmd[LIT_ATTEN_LINEAR] = params[0];
+ break;
+ case GL_QUADRATIC_ATTENUATION:
+ RADEON_STATECHANGE(rmesa, lit[p]);
+ fcmd[LIT_ATTEN_QUADRATIC] = params[0];
+ break;
+ default:
+ return;
+ }
+
+ /* Set RANGE_ATTEN only when needed */
+ switch (pname) {
+ case GL_POSITION:
+ case GL_CONSTANT_ATTENUATION:
+ case GL_LINEAR_ATTENUATION:
+ case GL_QUADRATIC_ATTENUATION:
+ {
+ GLuint *icmd = (GLuint *)RADEON_DB_STATE( tcl );
+ GLuint idx = TCL_PER_LIGHT_CTL_0 + p/2;
+ GLuint atten_flag = ( p&1 ) ? RADEON_LIGHT_1_ENABLE_RANGE_ATTEN
+ : RADEON_LIGHT_0_ENABLE_RANGE_ATTEN;
+ GLuint atten_const_flag = ( p&1 ) ? RADEON_LIGHT_1_CONSTANT_RANGE_ATTEN
+ : RADEON_LIGHT_0_CONSTANT_RANGE_ATTEN;
+
+ if ( l->EyePosition[3] == 0.0F ||
+ ( ( fcmd[LIT_ATTEN_CONST] == 0.0 || fcmd[LIT_ATTEN_CONST] == 1.0 ) &&
+ fcmd[LIT_ATTEN_QUADRATIC] == 0.0 && fcmd[LIT_ATTEN_LINEAR] == 0.0 ) ) {
+ /* Disable attenuation */
+ icmd[idx] &= ~atten_flag;
+ } else {
+ if ( fcmd[LIT_ATTEN_QUADRATIC] == 0.0 && fcmd[LIT_ATTEN_LINEAR] == 0.0 ) {
+ /* Enable only constant portion of attenuation calculation */
+ icmd[idx] |= ( atten_flag | atten_const_flag );
+ } else {
+ /* Enable full attenuation calculation */
+ icmd[idx] &= ~atten_const_flag;
+ icmd[idx] |= atten_flag;
+ }
+ }
+
+ RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.tcl );
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+
+
+
+static void radeonLightModelfv( GLcontext *ctx, GLenum pname,
+ const GLfloat *param )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ switch (pname) {
+ case GL_LIGHT_MODEL_AMBIENT:
+ update_global_ambient( ctx );
+ break;
+
+ case GL_LIGHT_MODEL_LOCAL_VIEWER:
+ RADEON_STATECHANGE( rmesa, tcl );
+ if (ctx->Light.Model.LocalViewer)
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_LOCAL_VIEWER;
+ else
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_LOCAL_VIEWER;
+ break;
+
+ case GL_LIGHT_MODEL_TWO_SIDE:
+ RADEON_STATECHANGE( rmesa, tcl );
+ if (ctx->Light.Model.TwoSide)
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= RADEON_LIGHT_TWOSIDE;
+ else
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~RADEON_LIGHT_TWOSIDE;
+
+ check_twoside_fallback( ctx );
+
+ if (rmesa->TclFallback) {
+ radeonChooseRenderState( ctx );
+ radeonChooseVertexState( ctx );
+ }
+ break;
+
+ case GL_LIGHT_MODEL_COLOR_CONTROL:
+ radeonUpdateSpecular(ctx);
+ break;
+
+ default:
+ break;
+ }
+}
+
+static void radeonShadeModel( GLcontext *ctx, GLenum mode )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint s = rmesa->hw.set.cmd[SET_SE_CNTL];
+
+ s &= ~(RADEON_DIFFUSE_SHADE_MASK |
+ RADEON_ALPHA_SHADE_MASK |
+ RADEON_SPECULAR_SHADE_MASK |
+ RADEON_FOG_SHADE_MASK);
+
+ switch ( mode ) {
+ case GL_FLAT:
+ s |= (RADEON_DIFFUSE_SHADE_FLAT |
+ RADEON_ALPHA_SHADE_FLAT |
+ RADEON_SPECULAR_SHADE_FLAT |
+ RADEON_FOG_SHADE_FLAT);
+ break;
+ case GL_SMOOTH:
+ s |= (RADEON_DIFFUSE_SHADE_GOURAUD |
+ RADEON_ALPHA_SHADE_GOURAUD |
+ RADEON_SPECULAR_SHADE_GOURAUD |
+ RADEON_FOG_SHADE_GOURAUD);
+ break;
+ default:
+ return;
+ }
+
+ if ( rmesa->hw.set.cmd[SET_SE_CNTL] != s ) {
+ RADEON_STATECHANGE( rmesa, set );
+ rmesa->hw.set.cmd[SET_SE_CNTL] = s;
+ }
+}
+
+
+/* =============================================================
+ * User clip planes
+ */
+
+static void radeonClipPlane( GLcontext *ctx, GLenum plane, const GLfloat *eq )
+{
+ GLint p = (GLint) plane - (GLint) GL_CLIP_PLANE0;
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLint *ip = (GLint *)ctx->Transform._ClipUserPlane[p];
+
+ RADEON_STATECHANGE( rmesa, ucp[p] );
+ rmesa->hw.ucp[p].cmd[UCP_X] = ip[0];
+ rmesa->hw.ucp[p].cmd[UCP_Y] = ip[1];
+ rmesa->hw.ucp[p].cmd[UCP_Z] = ip[2];
+ rmesa->hw.ucp[p].cmd[UCP_W] = ip[3];
+}
+
+static void radeonUpdateClipPlanes( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint p;
+
+ for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
+ GLint *ip = (GLint *)ctx->Transform._ClipUserPlane[p];
+
+ RADEON_STATECHANGE( rmesa, ucp[p] );
+ rmesa->hw.ucp[p].cmd[UCP_X] = ip[0];
+ rmesa->hw.ucp[p].cmd[UCP_Y] = ip[1];
+ rmesa->hw.ucp[p].cmd[UCP_Z] = ip[2];
+ rmesa->hw.ucp[p].cmd[UCP_W] = ip[3];
+ }
+ }
+}
+
+
+/* =============================================================
+ * Stencil
+ */
+
+static void radeonStencilFunc( GLcontext *ctx, GLenum func,
+ GLint ref, GLuint mask )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint refmask = ((ctx->Stencil.Ref[0] << RADEON_STENCIL_REF_SHIFT) |
+ (ctx->Stencil.ValueMask[0] << RADEON_STENCIL_MASK_SHIFT));
+
+ RADEON_STATECHANGE( rmesa, ctx );
+ RADEON_STATECHANGE( rmesa, msk );
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] &= ~RADEON_STENCIL_TEST_MASK;
+ rmesa->hw.msk.cmd[MSK_RB3D_STENCILREFMASK] &= ~(RADEON_STENCIL_REF_MASK|
+ RADEON_STENCIL_VALUE_MASK);
+
+ switch ( ctx->Stencil.Function[0] ) {
+ case GL_NEVER:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_TEST_NEVER;
+ break;
+ case GL_LESS:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_TEST_LESS;
+ break;
+ case GL_EQUAL:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_TEST_EQUAL;
+ break;
+ case GL_LEQUAL:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_TEST_LEQUAL;
+ break;
+ case GL_GREATER:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_TEST_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_TEST_NEQUAL;
+ break;
+ case GL_GEQUAL:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_TEST_GEQUAL;
+ break;
+ case GL_ALWAYS:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_TEST_ALWAYS;
+ break;
+ }
+
+ rmesa->hw.msk.cmd[MSK_RB3D_STENCILREFMASK] |= refmask;
+}
+
+static void radeonStencilMask( GLcontext *ctx, GLuint mask )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ RADEON_STATECHANGE( rmesa, msk );
+ rmesa->hw.msk.cmd[MSK_RB3D_STENCILREFMASK] &= ~RADEON_STENCIL_WRITE_MASK;
+ rmesa->hw.msk.cmd[MSK_RB3D_STENCILREFMASK] |=
+ (ctx->Stencil.WriteMask[0] << RADEON_STENCIL_WRITEMASK_SHIFT);
+}
+
+static void radeonStencilOp( GLcontext *ctx, GLenum fail,
+ GLenum zfail, GLenum zpass )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ /* radeon 7200 have stencil bug, DEC and INC_WRAP will actually both do DEC_WRAP,
+ and DEC_WRAP (and INVERT) will do INVERT. No way to get correct INC_WRAP and DEC,
+ but DEC_WRAP can be fixed by using DEC and INC_WRAP at least use INC. */
+
+ GLuint tempRADEON_STENCIL_FAIL_DEC_WRAP;
+ GLuint tempRADEON_STENCIL_FAIL_INC_WRAP;
+ GLuint tempRADEON_STENCIL_ZFAIL_DEC_WRAP;
+ GLuint tempRADEON_STENCIL_ZFAIL_INC_WRAP;
+ GLuint tempRADEON_STENCIL_ZPASS_DEC_WRAP;
+ GLuint tempRADEON_STENCIL_ZPASS_INC_WRAP;
+
+ if (rmesa->radeonScreen->chipset & RADEON_CHIPSET_BROKEN_STENCIL) {
+ tempRADEON_STENCIL_FAIL_DEC_WRAP = RADEON_STENCIL_FAIL_DEC;
+ tempRADEON_STENCIL_FAIL_INC_WRAP = RADEON_STENCIL_FAIL_INC;
+ tempRADEON_STENCIL_ZFAIL_DEC_WRAP = RADEON_STENCIL_ZFAIL_DEC;
+ tempRADEON_STENCIL_ZFAIL_INC_WRAP = RADEON_STENCIL_ZFAIL_INC;
+ tempRADEON_STENCIL_ZPASS_DEC_WRAP = RADEON_STENCIL_ZPASS_DEC;
+ tempRADEON_STENCIL_ZPASS_INC_WRAP = RADEON_STENCIL_ZPASS_INC;
+ }
+ else {
+ tempRADEON_STENCIL_FAIL_DEC_WRAP = RADEON_STENCIL_FAIL_DEC_WRAP;
+ tempRADEON_STENCIL_FAIL_INC_WRAP = RADEON_STENCIL_FAIL_INC_WRAP;
+ tempRADEON_STENCIL_ZFAIL_DEC_WRAP = RADEON_STENCIL_ZFAIL_DEC_WRAP;
+ tempRADEON_STENCIL_ZFAIL_INC_WRAP = RADEON_STENCIL_ZFAIL_INC_WRAP;
+ tempRADEON_STENCIL_ZPASS_DEC_WRAP = RADEON_STENCIL_ZPASS_DEC_WRAP;
+ tempRADEON_STENCIL_ZPASS_INC_WRAP = RADEON_STENCIL_ZPASS_INC_WRAP;
+ }
+
+ RADEON_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] &= ~(RADEON_STENCIL_FAIL_MASK |
+ RADEON_STENCIL_ZFAIL_MASK |
+ RADEON_STENCIL_ZPASS_MASK);
+
+ switch ( ctx->Stencil.FailFunc[0] ) {
+ case GL_KEEP:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_FAIL_KEEP;
+ break;
+ case GL_ZERO:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_FAIL_ZERO;
+ break;
+ case GL_REPLACE:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_FAIL_REPLACE;
+ break;
+ case GL_INCR:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_FAIL_INC;
+ break;
+ case GL_DECR:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_FAIL_DEC;
+ break;
+ case GL_INCR_WRAP:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= tempRADEON_STENCIL_FAIL_INC_WRAP;
+ break;
+ case GL_DECR_WRAP:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= tempRADEON_STENCIL_FAIL_DEC_WRAP;
+ break;
+ case GL_INVERT:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_FAIL_INVERT;
+ break;
+ }
+
+ switch ( ctx->Stencil.ZFailFunc[0] ) {
+ case GL_KEEP:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_ZFAIL_KEEP;
+ break;
+ case GL_ZERO:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_ZFAIL_ZERO;
+ break;
+ case GL_REPLACE:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_ZFAIL_REPLACE;
+ break;
+ case GL_INCR:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_ZFAIL_INC;
+ break;
+ case GL_DECR:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_ZFAIL_DEC;
+ break;
+ case GL_INCR_WRAP:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= tempRADEON_STENCIL_ZFAIL_INC_WRAP;
+ break;
+ case GL_DECR_WRAP:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= tempRADEON_STENCIL_ZFAIL_DEC_WRAP;
+ break;
+ case GL_INVERT:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_ZFAIL_INVERT;
+ break;
+ }
+
+ switch ( ctx->Stencil.ZPassFunc[0] ) {
+ case GL_KEEP:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_ZPASS_KEEP;
+ break;
+ case GL_ZERO:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_ZPASS_ZERO;
+ break;
+ case GL_REPLACE:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_ZPASS_REPLACE;
+ break;
+ case GL_INCR:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_ZPASS_INC;
+ break;
+ case GL_DECR:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_ZPASS_DEC;
+ break;
+ case GL_INCR_WRAP:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= tempRADEON_STENCIL_ZPASS_INC_WRAP;
+ break;
+ case GL_DECR_WRAP:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= tempRADEON_STENCIL_ZPASS_DEC_WRAP;
+ break;
+ case GL_INVERT:
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_STENCIL_ZPASS_INVERT;
+ break;
+ }
+}
+
+static void radeonClearStencil( GLcontext *ctx, GLint s )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ rmesa->state.stencil.clear =
+ ((GLuint) ctx->Stencil.Clear |
+ (0xff << RADEON_STENCIL_MASK_SHIFT) |
+ (ctx->Stencil.WriteMask[0] << RADEON_STENCIL_WRITEMASK_SHIFT));
+}
+
+
+/* =============================================================
+ * Window position and viewport transformation
+ */
+
+/*
+ * To correctly position primitives:
+ */
+#define SUBPIXEL_X 0.125
+#define SUBPIXEL_Y 0.125
+
+void radeonUpdateWindow( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+ GLfloat xoffset = (GLfloat)dPriv->x;
+ GLfloat yoffset = (GLfloat)dPriv->y + dPriv->h;
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+
+ GLfloat sx = v[MAT_SX];
+ GLfloat tx = v[MAT_TX] + xoffset + SUBPIXEL_X;
+ GLfloat sy = - v[MAT_SY];
+ GLfloat ty = (- v[MAT_TY]) + yoffset + SUBPIXEL_Y;
+ GLfloat sz = v[MAT_SZ] * rmesa->state.depth.scale;
+ GLfloat tz = v[MAT_TZ] * rmesa->state.depth.scale;
+ RADEON_FIREVERTICES( rmesa );
+ RADEON_STATECHANGE( rmesa, vpt );
+
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_XSCALE] = *(GLuint *)&sx;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] = *(GLuint *)&tx;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_YSCALE] = *(GLuint *)&sy;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] = *(GLuint *)&ty;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_ZSCALE] = *(GLuint *)&sz;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_ZOFFSET] = *(GLuint *)&tz;
+}
+
+
+
+static void radeonViewport( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
+ /* Don't pipeline viewport changes, conflict with window offset
+ * setting below. Could apply deltas to rescue pipelined viewport
+ * values, or keep the originals hanging around.
+ */
+ RADEON_FIREVERTICES( RADEON_CONTEXT(ctx) );
+ radeonUpdateWindow( ctx );
+}
+
+static void radeonDepthRange( GLcontext *ctx, GLclampd nearval,
+ GLclampd farval )
+{
+ radeonUpdateWindow( ctx );
+}
+
+void radeonUpdateViewportOffset( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+ GLfloat xoffset = (GLfloat)dPriv->x;
+ GLfloat yoffset = (GLfloat)dPriv->y + dPriv->h;
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+
+ GLfloat tx = v[MAT_TX] + xoffset + SUBPIXEL_X;
+ GLfloat ty = (- v[MAT_TY]) + yoffset + SUBPIXEL_Y;
+
+ if ( rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] != *(GLuint *)&tx ||
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] != *(GLuint *)&ty )
+ {
+ /* Note: this should also modify whatever data the context reset
+ * code uses...
+ */
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] = *(GLuint *)&tx;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] = *(GLuint *)&ty;
+
+ /* update polygon stipple x/y screen offset */
+ {
+ GLuint stx, sty;
+ GLuint m = rmesa->hw.msc.cmd[MSC_RE_MISC];
+
+ m &= ~(RADEON_STIPPLE_X_OFFSET_MASK |
+ RADEON_STIPPLE_Y_OFFSET_MASK);
+
+ /* add magic offsets, then invert */
+ stx = 31 - ((rmesa->dri.drawable->x - 1) & RADEON_STIPPLE_COORD_MASK);
+ sty = 31 - ((rmesa->dri.drawable->y + rmesa->dri.drawable->h - 1)
+ & RADEON_STIPPLE_COORD_MASK);
+
+ m |= ((stx << RADEON_STIPPLE_X_OFFSET_SHIFT) |
+ (sty << RADEON_STIPPLE_Y_OFFSET_SHIFT));
+
+ if ( rmesa->hw.msc.cmd[MSC_RE_MISC] != m ) {
+ RADEON_STATECHANGE( rmesa, msc );
+ rmesa->hw.msc.cmd[MSC_RE_MISC] = m;
+ }
+ }
+ }
+
+ radeonUpdateScissor( ctx );
+}
+
+
+
+/* =============================================================
+ * Miscellaneous
+ */
+
+static void radeonClearColor( GLcontext *ctx, const GLfloat color[4] )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLubyte c[4];
+ CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
+ rmesa->state.color.clear = radeonPackColor( rmesa->radeonScreen->cpp,
+ c[0], c[1], c[2], c[3] );
+}
+
+
+static void radeonRenderMode( GLcontext *ctx, GLenum mode )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ FALLBACK( rmesa, RADEON_FALLBACK_RENDER_MODE, (mode != GL_RENDER) );
+}
+
+
+static GLuint radeon_rop_tab[] = {
+ RADEON_ROP_CLEAR,
+ RADEON_ROP_AND,
+ RADEON_ROP_AND_REVERSE,
+ RADEON_ROP_COPY,
+ RADEON_ROP_AND_INVERTED,
+ RADEON_ROP_NOOP,
+ RADEON_ROP_XOR,
+ RADEON_ROP_OR,
+ RADEON_ROP_NOR,
+ RADEON_ROP_EQUIV,
+ RADEON_ROP_INVERT,
+ RADEON_ROP_OR_REVERSE,
+ RADEON_ROP_COPY_INVERTED,
+ RADEON_ROP_OR_INVERTED,
+ RADEON_ROP_NAND,
+ RADEON_ROP_SET,
+};
+
+static void radeonLogicOpCode( GLcontext *ctx, GLenum opcode )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint rop = (GLuint)opcode - GL_CLEAR;
+
+ ASSERT( rop < 16 );
+
+ RADEON_STATECHANGE( rmesa, msk );
+ rmesa->hw.msk.cmd[MSK_RB3D_ROPCNTL] = radeon_rop_tab[rop];
+}
+
+
+void radeonSetCliprects( radeonContextPtr rmesa, GLenum mode )
+{
+ __DRIdrawablePrivate *dPriv = rmesa->dri.drawable;
+
+ switch ( mode ) {
+ case GL_FRONT_LEFT:
+ rmesa->numClipRects = dPriv->numClipRects;
+ rmesa->pClipRects = dPriv->pClipRects;
+ break;
+ case GL_BACK_LEFT:
+ /* Can't ignore 2d windows if we are page flipping.
+ */
+ if ( dPriv->numBackClipRects == 0 || rmesa->doPageFlip ) {
+ rmesa->numClipRects = dPriv->numClipRects;
+ rmesa->pClipRects = dPriv->pClipRects;
+ }
+ else {
+ rmesa->numClipRects = dPriv->numBackClipRects;
+ rmesa->pClipRects = dPriv->pBackClipRects;
+ }
+ break;
+ default:
+ fprintf(stderr, "bad mode in radeonSetCliprects\n");
+ return;
+ }
+
+ if (rmesa->state.scissor.enabled)
+ radeonRecalcScissorRects( rmesa );
+}
+
+
+static void radeonDrawBuffer( GLcontext *ctx, GLenum mode )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if (RADEON_DEBUG & DEBUG_DRI)
+ fprintf(stderr, "%s %s\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr( mode ));
+
+ RADEON_FIREVERTICES(rmesa); /* don't pipeline cliprect changes */
+
+ /*
+ * _DrawDestMask is easier to cope with than <mode>.
+ */
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ FALLBACK( rmesa, RADEON_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ radeonSetCliprects( rmesa, GL_FRONT_LEFT );
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ FALLBACK( rmesa, RADEON_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ radeonSetCliprects( rmesa, GL_BACK_LEFT );
+ break;
+ default:
+ /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
+ FALLBACK( rmesa, RADEON_FALLBACK_DRAW_BUFFER, GL_TRUE );
+ return;
+ }
+
+ /* We want to update the s/w rast state too so that r200SetBuffer()
+ * gets called.
+ */
+ _swrast_DrawBuffer(ctx, mode);
+
+ RADEON_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = ((rmesa->state.color.drawOffset +
+ rmesa->radeonScreen->fbLocation)
+ & RADEON_COLOROFFSET_MASK);
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = rmesa->state.color.drawPitch;
+ if (rmesa->sarea->tiling_enabled) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= RADEON_COLOR_TILE_ENABLE;
+ }
+}
+
+static void radeonReadBuffer( GLcontext *ctx, GLenum mode )
+{
+ /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
+}
+
+
+/* =============================================================
+ * State enable/disable
+ */
+
+static void radeonEnable( GLcontext *ctx, GLenum cap, GLboolean state )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint p, flag;
+
+ if ( RADEON_DEBUG & DEBUG_STATE )
+ fprintf( stderr, "%s( %s = %s )\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr( cap ),
+ state ? "GL_TRUE" : "GL_FALSE" );
+
+ switch ( cap ) {
+ /* Fast track this one...
+ */
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ break;
+
+ case GL_ALPHA_TEST:
+ RADEON_STATECHANGE( rmesa, ctx );
+ if (state) {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= RADEON_ALPHA_TEST_ENABLE;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~RADEON_ALPHA_TEST_ENABLE;
+ }
+ break;
+
+ case GL_BLEND:
+ RADEON_STATECHANGE( rmesa, ctx );
+ if (state) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_ALPHA_BLEND_ENABLE;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ALPHA_BLEND_ENABLE;
+ }
+ if ( ctx->Color._LogicOpEnabled ) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_ROP_ENABLE;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ROP_ENABLE;
+ }
+
+ /* Catch a possible fallback:
+ */
+ if (state) {
+ ctx->Driver.BlendEquationSeparate( ctx,
+ ctx->Color.BlendEquationRGB,
+ ctx->Color.BlendEquationA );
+ ctx->Driver.BlendFuncSeparate( ctx, ctx->Color.BlendSrcRGB,
+ ctx->Color.BlendDstRGB,
+ ctx->Color.BlendSrcA,
+ ctx->Color.BlendDstA );
+ }
+ else {
+ FALLBACK( rmesa, RADEON_FALLBACK_BLEND_FUNC, GL_FALSE );
+ FALLBACK( rmesa, RADEON_FALLBACK_BLEND_EQ, GL_FALSE );
+ }
+ 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:
+ p = cap-GL_CLIP_PLANE0;
+ RADEON_STATECHANGE( rmesa, tcl );
+ if (state) {
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] |= (RADEON_UCP_ENABLE_0<<p);
+ radeonClipPlane( ctx, cap, NULL );
+ }
+ else {
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~(RADEON_UCP_ENABLE_0<<p);
+ }
+ break;
+
+ case GL_COLOR_MATERIAL:
+ radeonColorMaterial( ctx, 0, 0 );
+ radeonUpdateMaterial( ctx );
+ break;
+
+ case GL_CULL_FACE:
+ radeonCullFace( ctx, 0 );
+ break;
+
+ case GL_DEPTH_TEST:
+ RADEON_STATECHANGE(rmesa, ctx );
+ if ( state ) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_Z_ENABLE;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_Z_ENABLE;
+ }
+ break;
+
+ case GL_DITHER:
+ RADEON_STATECHANGE(rmesa, ctx );
+ if ( state ) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_DITHER_ENABLE;
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~rmesa->state.color.roundEnable;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_DITHER_ENABLE;
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= rmesa->state.color.roundEnable;
+ }
+ break;
+
+ case GL_FOG:
+ RADEON_STATECHANGE(rmesa, ctx );
+ if ( state ) {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= RADEON_FOG_ENABLE;
+ radeonFogfv( ctx, GL_FOG_MODE, NULL );
+ } else {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~RADEON_FOG_ENABLE;
+ RADEON_STATECHANGE(rmesa, tcl);
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] &= ~RADEON_TCL_FOG_MASK;
+ }
+ radeonUpdateSpecular( ctx ); /* for PK_SPEC */
+ if (rmesa->TclFallback)
+ radeonChooseVertexState( ctx );
+ _mesa_allow_light_in_model( ctx, !state );
+ 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:
+ RADEON_STATECHANGE(rmesa, tcl);
+ p = cap - GL_LIGHT0;
+ if (p&1)
+ flag = (RADEON_LIGHT_1_ENABLE |
+ RADEON_LIGHT_1_ENABLE_AMBIENT |
+ RADEON_LIGHT_1_ENABLE_SPECULAR);
+ else
+ flag = (RADEON_LIGHT_0_ENABLE |
+ RADEON_LIGHT_0_ENABLE_AMBIENT |
+ RADEON_LIGHT_0_ENABLE_SPECULAR);
+
+ if (state)
+ rmesa->hw.tcl.cmd[p/2 + TCL_PER_LIGHT_CTL_0] |= flag;
+ else
+ rmesa->hw.tcl.cmd[p/2 + TCL_PER_LIGHT_CTL_0] &= ~flag;
+
+ /*
+ */
+ update_light_colors( ctx, p );
+ break;
+
+ case GL_LIGHTING:
+ RADEON_STATECHANGE(rmesa, tcl);
+ radeonUpdateSpecular(ctx);
+ check_twoside_fallback( ctx );
+ break;
+
+ case GL_LINE_SMOOTH:
+ RADEON_STATECHANGE( rmesa, ctx );
+ if ( state ) {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= RADEON_ANTI_ALIAS_LINE;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~RADEON_ANTI_ALIAS_LINE;
+ }
+ break;
+
+ case GL_LINE_STIPPLE:
+ RADEON_STATECHANGE( rmesa, ctx );
+ if ( state ) {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= RADEON_PATTERN_ENABLE;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~RADEON_PATTERN_ENABLE;
+ }
+ break;
+
+ case GL_COLOR_LOGIC_OP:
+ RADEON_STATECHANGE( rmesa, ctx );
+ if ( ctx->Color._LogicOpEnabled ) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_ROP_ENABLE;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_ROP_ENABLE;
+ }
+ break;
+
+ case GL_NORMALIZE:
+ RADEON_STATECHANGE( rmesa, tcl );
+ if ( state ) {
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_NORMALIZE_NORMALS;
+ } else {
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_NORMALIZE_NORMALS;
+ }
+ break;
+
+ case GL_POLYGON_OFFSET_POINT:
+ if (rmesa->dri.drmMinor == 1) {
+ radeonChooseRenderState( ctx );
+ }
+ else {
+ RADEON_STATECHANGE( rmesa, set );
+ if ( state ) {
+ rmesa->hw.set.cmd[SET_SE_CNTL] |= RADEON_ZBIAS_ENABLE_POINT;
+ } else {
+ rmesa->hw.set.cmd[SET_SE_CNTL] &= ~RADEON_ZBIAS_ENABLE_POINT;
+ }
+ }
+ break;
+
+ case GL_POLYGON_OFFSET_LINE:
+ if (rmesa->dri.drmMinor == 1) {
+ radeonChooseRenderState( ctx );
+ }
+ else {
+ RADEON_STATECHANGE( rmesa, set );
+ if ( state ) {
+ rmesa->hw.set.cmd[SET_SE_CNTL] |= RADEON_ZBIAS_ENABLE_LINE;
+ } else {
+ rmesa->hw.set.cmd[SET_SE_CNTL] &= ~RADEON_ZBIAS_ENABLE_LINE;
+ }
+ }
+ break;
+
+ case GL_POLYGON_OFFSET_FILL:
+ if (rmesa->dri.drmMinor == 1) {
+ radeonChooseRenderState( ctx );
+ }
+ else {
+ RADEON_STATECHANGE( rmesa, set );
+ if ( state ) {
+ rmesa->hw.set.cmd[SET_SE_CNTL] |= RADEON_ZBIAS_ENABLE_TRI;
+ } else {
+ rmesa->hw.set.cmd[SET_SE_CNTL] &= ~RADEON_ZBIAS_ENABLE_TRI;
+ }
+ }
+ break;
+
+ case GL_POLYGON_SMOOTH:
+ RADEON_STATECHANGE( rmesa, ctx );
+ if ( state ) {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= RADEON_ANTI_ALIAS_POLY;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~RADEON_ANTI_ALIAS_POLY;
+ }
+ break;
+
+ case GL_POLYGON_STIPPLE:
+ RADEON_STATECHANGE(rmesa, ctx );
+ if ( state ) {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= RADEON_STIPPLE_ENABLE;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] &= ~RADEON_STIPPLE_ENABLE;
+ }
+ break;
+
+ case GL_RESCALE_NORMAL_EXT: {
+ GLboolean tmp = ctx->_NeedEyeCoords ? state : !state;
+ RADEON_STATECHANGE( rmesa, tcl );
+ if ( tmp ) {
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_RESCALE_NORMALS;
+ } else {
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_RESCALE_NORMALS;
+ }
+ break;
+ }
+
+ case GL_SCISSOR_TEST:
+ RADEON_FIREVERTICES( rmesa );
+ rmesa->state.scissor.enabled = state;
+ radeonUpdateScissor( ctx );
+ break;
+
+ case GL_STENCIL_TEST:
+ if ( rmesa->state.stencil.hwBuffer ) {
+ RADEON_STATECHANGE( rmesa, ctx );
+ if ( state ) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_STENCIL_ENABLE;
+ } else {
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] &= ~RADEON_STENCIL_ENABLE;
+ }
+ } else {
+ FALLBACK( rmesa, RADEON_FALLBACK_STENCIL, state );
+ }
+ break;
+
+ case GL_TEXTURE_GEN_Q:
+ case GL_TEXTURE_GEN_R:
+ case GL_TEXTURE_GEN_S:
+ case GL_TEXTURE_GEN_T:
+ /* Picked up in radeonUpdateTextureState.
+ */
+ rmesa->recheck_texgen[ctx->Texture.CurrentUnit] = GL_TRUE;
+ break;
+
+ case GL_COLOR_SUM_EXT:
+ radeonUpdateSpecular ( ctx );
+ break;
+
+ default:
+ return;
+ }
+}
+
+
+static void radeonLightingSpaceChange( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLboolean tmp;
+ RADEON_STATECHANGE( rmesa, tcl );
+
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s %d BEFORE %x\n", __FUNCTION__, ctx->_NeedEyeCoords,
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL]);
+
+ if (ctx->_NeedEyeCoords)
+ tmp = ctx->Transform.RescaleNormals;
+ else
+ tmp = !ctx->Transform.RescaleNormals;
+
+ if ( tmp ) {
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] |= RADEON_RESCALE_NORMALS;
+ } else {
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] &= ~RADEON_RESCALE_NORMALS;
+ }
+
+ if (RADEON_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s %d AFTER %x\n", __FUNCTION__, ctx->_NeedEyeCoords,
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL]);
+}
+
+/* =============================================================
+ * Deferred state management - matrices, textures, other?
+ */
+
+
+
+
+static void upload_matrix( radeonContextPtr rmesa, GLfloat *src, int idx )
+{
+ float *dest = ((float *)RADEON_DB_STATE( mat[idx] ))+MAT_ELT_0;
+ int i;
+
+
+ for (i = 0 ; i < 4 ; i++) {
+ *dest++ = src[i];
+ *dest++ = src[i+4];
+ *dest++ = src[i+8];
+ *dest++ = src[i+12];
+ }
+
+ RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.mat[idx] );
+}
+
+static void upload_matrix_t( radeonContextPtr rmesa, GLfloat *src, int idx )
+{
+ float *dest = ((float *)RADEON_DB_STATE( mat[idx] ))+MAT_ELT_0;
+ memcpy(dest, src, 16*sizeof(float));
+ RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.mat[idx] );
+}
+
+
+static void update_texturematrix( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+ GLuint tpc = rmesa->hw.tcl.cmd[TCL_TEXTURE_PROC_CTL];
+ GLuint vs = rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL];
+ int unit;
+
+ rmesa->TexMatEnabled = 0;
+
+ for (unit = 0 ; unit < 2; unit++) {
+ if (!ctx->Texture.Unit[unit]._ReallyEnabled) {
+ }
+ else if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY) {
+ GLuint inputshift = RADEON_TEXGEN_0_INPUT_SHIFT + unit*4;
+
+ rmesa->TexMatEnabled |= (RADEON_TEXGEN_TEXMAT_0_ENABLE|
+ RADEON_TEXMAT_0_ENABLE) << unit;
+
+ if (rmesa->TexGenEnabled & (RADEON_TEXMAT_0_ENABLE << unit)) {
+ /* Need to preconcatenate any active texgen
+ * obj/eyeplane matrices:
+ */
+ _math_matrix_mul_matrix( &rmesa->tmpmat,
+ &rmesa->TexGenMatrix[unit],
+ ctx->TextureMatrixStack[unit].Top );
+ upload_matrix( rmesa, rmesa->tmpmat.m, TEXMAT_0+unit );
+ }
+ else {
+ rmesa->TexMatEnabled |=
+ (RADEON_TEXGEN_INPUT_TEXCOORD_0+unit) << inputshift;
+ upload_matrix( rmesa, ctx->TextureMatrixStack[unit].Top->m,
+ TEXMAT_0+unit );
+ }
+ }
+ else if (rmesa->TexGenEnabled & (RADEON_TEXMAT_0_ENABLE << unit)) {
+ upload_matrix( rmesa, rmesa->TexGenMatrix[unit].m,
+ TEXMAT_0+unit );
+ }
+ }
+
+
+ tpc = (rmesa->TexMatEnabled | rmesa->TexGenEnabled);
+
+ vs &= ~((0xf << RADEON_TCL_TEX_0_OUTPUT_SHIFT) |
+ (0xf << RADEON_TCL_TEX_1_OUTPUT_SHIFT));
+
+ if (tpc & RADEON_TEXGEN_TEXMAT_0_ENABLE)
+ vs |= RADEON_TCL_TEX_COMPUTED_TEX_0 << RADEON_TCL_TEX_0_OUTPUT_SHIFT;
+ else
+ vs |= RADEON_TCL_TEX_INPUT_TEX_0 << RADEON_TCL_TEX_0_OUTPUT_SHIFT;
+
+ if (tpc & RADEON_TEXGEN_TEXMAT_1_ENABLE)
+ vs |= RADEON_TCL_TEX_COMPUTED_TEX_1 << RADEON_TCL_TEX_1_OUTPUT_SHIFT;
+ else
+ vs |= RADEON_TCL_TEX_INPUT_TEX_1 << RADEON_TCL_TEX_1_OUTPUT_SHIFT;
+
+ if (tpc != rmesa->hw.tcl.cmd[TCL_TEXTURE_PROC_CTL] ||
+ vs != rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL]) {
+
+ RADEON_STATECHANGE(rmesa, tcl);
+ rmesa->hw.tcl.cmd[TCL_TEXTURE_PROC_CTL] = tpc;
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] = vs;
+ }
+}
+
+
+
+void radeonValidateState( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint new_state = rmesa->NewGLState;
+
+ if (new_state & _NEW_TEXTURE) {
+ radeonUpdateTextureState( ctx );
+ new_state |= rmesa->NewGLState; /* may add TEXTURE_MATRIX */
+ }
+
+ /* Need an event driven matrix update?
+ */
+ if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
+ upload_matrix( rmesa, ctx->_ModelProjectMatrix.m, MODEL_PROJ );
+
+ /* Need these for lighting (shouldn't upload otherwise)
+ */
+ if (new_state & (_NEW_MODELVIEW)) {
+ upload_matrix( rmesa, ctx->ModelviewMatrixStack.Top->m, MODEL );
+ upload_matrix_t( rmesa, ctx->ModelviewMatrixStack.Top->inv, MODEL_IT );
+ }
+
+ /* Does this need to be triggered on eg. modelview for
+ * texgen-derived objplane/eyeplane matrices?
+ */
+ if (new_state & _NEW_TEXTURE_MATRIX) {
+ update_texturematrix( ctx );
+ }
+
+ if (new_state & (_NEW_LIGHT|_NEW_MODELVIEW|_MESA_NEW_NEED_EYE_COORDS)) {
+ update_light( ctx );
+ }
+
+ /* emit all active clip planes if projection matrix changes.
+ */
+ if (new_state & (_NEW_PROJECTION)) {
+ if (ctx->Transform.ClipPlanesEnabled)
+ radeonUpdateClipPlanes( ctx );
+ }
+
+
+ rmesa->NewGLState = 0;
+}
+
+
+static void radeonInvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ _ae_invalidate_state( ctx, new_state );
+ RADEON_CONTEXT(ctx)->NewGLState |= new_state;
+ radeonVtxfmtInvalidate( ctx );
+}
+
+
+/* A hack. Need a faster way to find this out.
+ */
+static GLboolean check_material( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLint i;
+
+ for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT;
+ i < _TNL_ATTRIB_MAT_BACK_INDEXES;
+ i++)
+ if (tnl->vb.AttribPtr[i] &&
+ tnl->vb.AttribPtr[i]->stride)
+ return GL_TRUE;
+
+ return GL_FALSE;
+}
+
+
+static void radeonWrapRunPipeline( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLboolean has_material;
+
+ if (0)
+ fprintf(stderr, "%s, newstate: %x\n", __FUNCTION__, rmesa->NewGLState);
+
+ /* Validate state:
+ */
+ if (rmesa->NewGLState)
+ radeonValidateState( ctx );
+
+ has_material = (ctx->Light.Enabled && check_material( ctx ));
+
+ if (has_material) {
+ TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_MATERIAL, GL_TRUE );
+ }
+
+ /* Run the pipeline.
+ */
+ _tnl_run_pipeline( ctx );
+
+ if (has_material) {
+ TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_MATERIAL, GL_FALSE );
+ }
+}
+
+
+/* Initialize the driver's state functions.
+ */
+void radeonInitStateFuncs( GLcontext *ctx )
+{
+ ctx->Driver.UpdateState = radeonInvalidateState;
+ ctx->Driver.LightingSpaceChange = radeonLightingSpaceChange;
+
+ ctx->Driver.DrawBuffer = radeonDrawBuffer;
+ ctx->Driver.ReadBuffer = radeonReadBuffer;
+
+ ctx->Driver.AlphaFunc = radeonAlphaFunc;
+ ctx->Driver.BlendEquationSeparate = radeonBlendEquationSeparate;
+ ctx->Driver.BlendFuncSeparate = radeonBlendFuncSeparate;
+ ctx->Driver.ClearColor = radeonClearColor;
+ ctx->Driver.ClearDepth = radeonClearDepth;
+ ctx->Driver.ClearIndex = NULL;
+ ctx->Driver.ClearStencil = radeonClearStencil;
+ ctx->Driver.ClipPlane = radeonClipPlane;
+ ctx->Driver.ColorMask = radeonColorMask;
+ ctx->Driver.CullFace = radeonCullFace;
+ ctx->Driver.DepthFunc = radeonDepthFunc;
+ ctx->Driver.DepthMask = radeonDepthMask;
+ ctx->Driver.DepthRange = radeonDepthRange;
+ ctx->Driver.Enable = radeonEnable;
+ ctx->Driver.Fogfv = radeonFogfv;
+ ctx->Driver.FrontFace = radeonFrontFace;
+ ctx->Driver.Hint = NULL;
+ ctx->Driver.IndexMask = NULL;
+ ctx->Driver.LightModelfv = radeonLightModelfv;
+ ctx->Driver.Lightfv = radeonLightfv;
+ ctx->Driver.LineStipple = radeonLineStipple;
+ ctx->Driver.LineWidth = radeonLineWidth;
+ ctx->Driver.LogicOpcode = radeonLogicOpCode;
+ ctx->Driver.PolygonMode = radeonPolygonMode;
+
+ if (RADEON_CONTEXT(ctx)->dri.drmMinor > 1)
+ ctx->Driver.PolygonOffset = radeonPolygonOffset;
+
+ ctx->Driver.PolygonStipple = radeonPolygonStipple;
+ ctx->Driver.RenderMode = radeonRenderMode;
+ ctx->Driver.Scissor = radeonScissor;
+ ctx->Driver.ShadeModel = radeonShadeModel;
+ ctx->Driver.StencilFunc = radeonStencilFunc;
+ ctx->Driver.StencilMask = radeonStencilMask;
+ ctx->Driver.StencilOp = radeonStencilOp;
+ ctx->Driver.Viewport = radeonViewport;
+
+ /* Pixel path fallbacks
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+
+ TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange = radeonUpdateMaterial;
+ TNL_CONTEXT(ctx)->Driver.RunPipeline = radeonWrapRunPipeline;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_state.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_state.h
new file mode 100644
index 000000000..07739be94
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_state.h
@@ -0,0 +1,74 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_state.h,v 1.5 2002/11/05 17:46:09 tsi Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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 THE COPYRIGHT OWNER(S) 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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#ifndef __RADEON_STATE_H__
+#define __RADEON_STATE_H__
+
+#include "radeon_context.h"
+
+extern void radeonInitState( radeonContextPtr rmesa );
+extern void radeonInitStateFuncs( GLcontext *ctx );
+
+extern void radeonUpdateMaterial( GLcontext *ctx );
+
+extern void radeonSetCliprects( radeonContextPtr rmesa, GLenum mode );
+extern void radeonRecalcScissorRects( radeonContextPtr rmesa );
+extern void radeonUpdateViewportOffset( GLcontext *ctx );
+extern void radeonUpdateWindow( GLcontext *ctx );
+
+extern void radeonValidateState( GLcontext *ctx );
+
+extern void radeonPrintDirty( radeonContextPtr rmesa,
+ const char *msg );
+
+
+extern void radeonFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
+#define FALLBACK( rmesa, bit, mode ) do { \
+ if ( 0 ) fprintf( stderr, "FALLBACK in %s: #%d=%d\n", \
+ __FUNCTION__, bit, mode ); \
+ radeonFallback( rmesa->glCtx, bit, mode ); \
+} while (0)
+
+
+#define MODEL_PROJ 0
+#define MODEL 1
+#define MODEL_IT 2
+#define TEXMAT_0 3
+#define TEXMAT_1 4
+#define TEXMAT_2 5
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_state_init.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_state_init.c
new file mode 100644
index 000000000..1caffe132
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_state_init.c
@@ -0,0 +1,572 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_state_init.c,v 1.3 2003/02/22 06:21:11 dawes Exp $ */
+/*
+ * Copyright 2000, 2001 VA Linux Systems Inc., Fremont, 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
+ * 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
+ * VA LINUX SYSTEMS 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:
+ * Gareth Hughes <gareth@valinux.com>
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "api_arrayelt.h"
+
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "radeon_context.h"
+#include "radeon_ioctl.h"
+#include "radeon_state.h"
+#include "radeon_tcl.h"
+#include "radeon_tex.h"
+#include "radeon_swtcl.h"
+#include "radeon_vtxfmt.h"
+
+#include "xmlpool.h"
+
+/* =============================================================
+ * State initialization
+ */
+
+void radeonPrintDirty( radeonContextPtr rmesa, const char *msg )
+{
+ struct radeon_state_atom *l;
+
+ fprintf(stderr, msg);
+ fprintf(stderr, ": ");
+
+ foreach(l, &rmesa->hw.atomlist) {
+ if (l->dirty || rmesa->hw.all_dirty)
+ fprintf(stderr, "%s, ", l->name);
+ }
+
+ fprintf(stderr, "\n");
+}
+
+static int cmdpkt( int id )
+{
+ drm_radeon_cmd_header_t h;
+ h.i = 0;
+ h.packet.cmd_type = RADEON_CMD_PACKET;
+ h.packet.packet_id = id;
+ return h.i;
+}
+
+static int cmdvec( int offset, int stride, int count )
+{
+ drm_radeon_cmd_header_t h;
+ h.i = 0;
+ h.vectors.cmd_type = RADEON_CMD_VECTORS;
+ h.vectors.offset = offset;
+ h.vectors.stride = stride;
+ h.vectors.count = count;
+ return h.i;
+}
+
+static int cmdscl( int offset, int stride, int count )
+{
+ drm_radeon_cmd_header_t h;
+ h.i = 0;
+ h.scalars.cmd_type = RADEON_CMD_SCALARS;
+ h.scalars.offset = offset;
+ h.scalars.stride = stride;
+ h.scalars.count = count;
+ return h.i;
+}
+
+#define CHECK( NM, FLAG ) \
+static GLboolean check_##NM( GLcontext *ctx ) \
+{ \
+ return FLAG; \
+}
+
+#define TCL_CHECK( NM, FLAG ) \
+static GLboolean check_##NM( GLcontext *ctx ) \
+{ \
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx); \
+ return !rmesa->TclFallback && (FLAG); \
+}
+
+
+CHECK( always, GL_TRUE )
+CHECK( tex0, ctx->Texture.Unit[0]._ReallyEnabled )
+CHECK( tex1, ctx->Texture.Unit[1]._ReallyEnabled )
+CHECK( fog, ctx->Fog.Enabled )
+TCL_CHECK( tcl, GL_TRUE )
+TCL_CHECK( tcl_tex0, ctx->Texture.Unit[0]._ReallyEnabled )
+TCL_CHECK( tcl_tex1, ctx->Texture.Unit[1]._ReallyEnabled )
+TCL_CHECK( tcl_lighting, ctx->Light.Enabled )
+TCL_CHECK( tcl_eyespace_or_lighting, ctx->_NeedEyeCoords || ctx->Light.Enabled )
+TCL_CHECK( tcl_lit0, ctx->Light.Enabled && ctx->Light.Light[0].Enabled )
+TCL_CHECK( tcl_lit1, ctx->Light.Enabled && ctx->Light.Light[1].Enabled )
+TCL_CHECK( tcl_lit2, ctx->Light.Enabled && ctx->Light.Light[2].Enabled )
+TCL_CHECK( tcl_lit3, ctx->Light.Enabled && ctx->Light.Light[3].Enabled )
+TCL_CHECK( tcl_lit4, ctx->Light.Enabled && ctx->Light.Light[4].Enabled )
+TCL_CHECK( tcl_lit5, ctx->Light.Enabled && ctx->Light.Light[5].Enabled )
+TCL_CHECK( tcl_lit6, ctx->Light.Enabled && ctx->Light.Light[6].Enabled )
+TCL_CHECK( tcl_lit7, ctx->Light.Enabled && ctx->Light.Light[7].Enabled )
+TCL_CHECK( tcl_ucp0, (ctx->Transform.ClipPlanesEnabled & 0x1) )
+TCL_CHECK( tcl_ucp1, (ctx->Transform.ClipPlanesEnabled & 0x2) )
+TCL_CHECK( tcl_ucp2, (ctx->Transform.ClipPlanesEnabled & 0x4) )
+TCL_CHECK( tcl_ucp3, (ctx->Transform.ClipPlanesEnabled & 0x8) )
+TCL_CHECK( tcl_ucp4, (ctx->Transform.ClipPlanesEnabled & 0x10) )
+TCL_CHECK( tcl_ucp5, (ctx->Transform.ClipPlanesEnabled & 0x20) )
+TCL_CHECK( tcl_eyespace_or_fog, ctx->_NeedEyeCoords || ctx->Fog.Enabled )
+
+CHECK( txr0, (ctx->Texture.Unit[0]._ReallyEnabled & TEXTURE_RECT_BIT))
+CHECK( txr1, (ctx->Texture.Unit[1]._ReallyEnabled & TEXTURE_RECT_BIT))
+
+
+
+/* Initialize the context's hardware state.
+ */
+void radeonInitState( radeonContextPtr rmesa )
+{
+ GLcontext *ctx = rmesa->glCtx;
+ GLuint color_fmt, depth_fmt, i;
+
+ switch ( rmesa->radeonScreen->cpp ) {
+ case 2:
+ color_fmt = RADEON_COLOR_FORMAT_RGB565;
+ break;
+ case 4:
+ color_fmt = RADEON_COLOR_FORMAT_ARGB8888;
+ break;
+ default:
+ fprintf( stderr, "Error: Unsupported pixel depth... exiting\n" );
+ exit( -1 );
+ }
+
+ rmesa->state.color.clear = 0x00000000;
+
+ switch ( ctx->Visual.depthBits ) {
+ case 16:
+ rmesa->state.depth.clear = 0x0000ffff;
+ rmesa->state.depth.scale = 1.0 / (GLfloat)0xffff;
+ depth_fmt = RADEON_DEPTH_FORMAT_16BIT_INT_Z;
+ rmesa->state.stencil.clear = 0x00000000;
+ break;
+ case 24:
+ rmesa->state.depth.clear = 0x00ffffff;
+ rmesa->state.depth.scale = 1.0 / (GLfloat)0xffffff;
+ depth_fmt = RADEON_DEPTH_FORMAT_24BIT_INT_Z;
+ rmesa->state.stencil.clear = 0xffff0000;
+ break;
+ default:
+ fprintf( stderr, "Error: Unsupported depth %d... exiting\n",
+ ctx->Visual.depthBits );
+ exit( -1 );
+ }
+
+ /* Only have hw stencil when depth buffer is 24 bits deep */
+ rmesa->state.stencil.hwBuffer = ( ctx->Visual.stencilBits > 0 &&
+ ctx->Visual.depthBits == 24 );
+
+ rmesa->Fallback = 0;
+
+ if ( ctx->Visual.doubleBufferMode && rmesa->sarea->pfCurrentPage == 0 ) {
+ rmesa->state.color.drawOffset = rmesa->radeonScreen->backOffset;
+ rmesa->state.color.drawPitch = rmesa->radeonScreen->backPitch;
+ } else {
+ rmesa->state.color.drawOffset = rmesa->radeonScreen->frontOffset;
+ rmesa->state.color.drawPitch = rmesa->radeonScreen->frontPitch;
+ }
+ rmesa->state.pixel.readOffset = rmesa->state.color.drawOffset;
+ rmesa->state.pixel.readPitch = rmesa->state.color.drawPitch;
+
+ rmesa->hw.max_state_size = 0;
+
+#define ALLOC_STATE( ATOM, CHK, SZ, NM, FLAG ) \
+ do { \
+ rmesa->hw.ATOM.cmd_size = SZ; \
+ rmesa->hw.ATOM.cmd = (int *)CALLOC(SZ * sizeof(int)); \
+ rmesa->hw.ATOM.lastcmd = (int *)CALLOC(SZ * sizeof(int)); \
+ rmesa->hw.ATOM.name = NM; \
+ rmesa->hw.ATOM.is_tcl = FLAG; \
+ rmesa->hw.ATOM.check = check_##CHK; \
+ rmesa->hw.ATOM.dirty = GL_TRUE; \
+ rmesa->hw.max_state_size += SZ * sizeof(int); \
+ } while (0)
+
+
+ /* Allocate state buffers:
+ */
+ ALLOC_STATE( ctx, always, CTX_STATE_SIZE, "CTX/context", 0 );
+ ALLOC_STATE( lin, always, LIN_STATE_SIZE, "LIN/line", 0 );
+ ALLOC_STATE( msk, always, MSK_STATE_SIZE, "MSK/mask", 0 );
+ ALLOC_STATE( vpt, always, VPT_STATE_SIZE, "VPT/viewport", 0 );
+ ALLOC_STATE( set, always, SET_STATE_SIZE, "SET/setup", 0 );
+ ALLOC_STATE( msc, always, MSC_STATE_SIZE, "MSC/misc", 0 );
+ ALLOC_STATE( zbs, always, ZBS_STATE_SIZE, "ZBS/zbias", 0 );
+ ALLOC_STATE( tcl, always, TCL_STATE_SIZE, "TCL/tcl", 1 );
+ ALLOC_STATE( mtl, tcl_lighting, MTL_STATE_SIZE, "MTL/material", 1 );
+ ALLOC_STATE( grd, always, GRD_STATE_SIZE, "GRD/guard-band", 1 );
+ ALLOC_STATE( fog, fog, FOG_STATE_SIZE, "FOG/fog", 1 );
+ ALLOC_STATE( glt, tcl_lighting, GLT_STATE_SIZE, "GLT/light-global", 1 );
+ ALLOC_STATE( eye, tcl_lighting, EYE_STATE_SIZE, "EYE/eye-vector", 1 );
+ ALLOC_STATE( tex[0], tex0, TEX_STATE_SIZE, "TEX/tex-0", 0 );
+ ALLOC_STATE( tex[1], tex1, TEX_STATE_SIZE, "TEX/tex-1", 0 );
+ ALLOC_STATE( mat[0], tcl, MAT_STATE_SIZE, "MAT/modelproject", 1 );
+ ALLOC_STATE( mat[1], tcl_eyespace_or_fog, MAT_STATE_SIZE, "MAT/modelview", 1 );
+ ALLOC_STATE( mat[2], tcl_eyespace_or_lighting, MAT_STATE_SIZE, "MAT/it-modelview", 1 );
+ ALLOC_STATE( mat[3], tcl_tex0, MAT_STATE_SIZE, "MAT/texmat0", 1 );
+ ALLOC_STATE( mat[4], tcl_tex1, MAT_STATE_SIZE, "MAT/texmat1", 1 );
+ ALLOC_STATE( ucp[0], tcl_ucp0, UCP_STATE_SIZE, "UCP/userclip-0", 1 );
+ ALLOC_STATE( ucp[1], tcl_ucp1, UCP_STATE_SIZE, "UCP/userclip-1", 1 );
+ ALLOC_STATE( ucp[2], tcl_ucp2, UCP_STATE_SIZE, "UCP/userclip-2", 1 );
+ ALLOC_STATE( ucp[3], tcl_ucp3, UCP_STATE_SIZE, "UCP/userclip-3", 1 );
+ ALLOC_STATE( ucp[4], tcl_ucp4, UCP_STATE_SIZE, "UCP/userclip-4", 1 );
+ ALLOC_STATE( ucp[5], tcl_ucp5, UCP_STATE_SIZE, "UCP/userclip-5", 1 );
+ ALLOC_STATE( lit[0], tcl_lit0, LIT_STATE_SIZE, "LIT/light-0", 1 );
+ ALLOC_STATE( lit[1], tcl_lit1, LIT_STATE_SIZE, "LIT/light-1", 1 );
+ ALLOC_STATE( lit[2], tcl_lit2, LIT_STATE_SIZE, "LIT/light-2", 1 );
+ ALLOC_STATE( lit[3], tcl_lit3, LIT_STATE_SIZE, "LIT/light-3", 1 );
+ ALLOC_STATE( lit[4], tcl_lit4, LIT_STATE_SIZE, "LIT/light-4", 1 );
+ ALLOC_STATE( lit[5], tcl_lit5, LIT_STATE_SIZE, "LIT/light-5", 1 );
+ ALLOC_STATE( lit[6], tcl_lit6, LIT_STATE_SIZE, "LIT/light-6", 1 );
+ ALLOC_STATE( lit[7], tcl_lit7, LIT_STATE_SIZE, "LIT/light-7", 1 );
+ ALLOC_STATE( txr[0], txr0, TXR_STATE_SIZE, "TXR/txr-0", 0 );
+ ALLOC_STATE( txr[1], txr1, TXR_STATE_SIZE, "TXR/txr-1", 0 );
+
+ radeonSetUpAtomList( rmesa );
+
+ /* Fill in the packet headers:
+ */
+ rmesa->hw.ctx.cmd[CTX_CMD_0] = cmdpkt(RADEON_EMIT_PP_MISC);
+ rmesa->hw.ctx.cmd[CTX_CMD_1] = cmdpkt(RADEON_EMIT_PP_CNTL);
+ rmesa->hw.ctx.cmd[CTX_CMD_2] = cmdpkt(RADEON_EMIT_RB3D_COLORPITCH);
+ rmesa->hw.lin.cmd[LIN_CMD_0] = cmdpkt(RADEON_EMIT_RE_LINE_PATTERN);
+ rmesa->hw.lin.cmd[LIN_CMD_1] = cmdpkt(RADEON_EMIT_SE_LINE_WIDTH);
+ rmesa->hw.msk.cmd[MSK_CMD_0] = cmdpkt(RADEON_EMIT_RB3D_STENCILREFMASK);
+ rmesa->hw.vpt.cmd[VPT_CMD_0] = cmdpkt(RADEON_EMIT_SE_VPORT_XSCALE);
+ rmesa->hw.set.cmd[SET_CMD_0] = cmdpkt(RADEON_EMIT_SE_CNTL);
+ rmesa->hw.set.cmd[SET_CMD_1] = cmdpkt(RADEON_EMIT_SE_CNTL_STATUS);
+ rmesa->hw.msc.cmd[MSC_CMD_0] = cmdpkt(RADEON_EMIT_RE_MISC);
+ rmesa->hw.tex[0].cmd[TEX_CMD_0] = cmdpkt(RADEON_EMIT_PP_TXFILTER_0);
+ rmesa->hw.tex[0].cmd[TEX_CMD_1] = cmdpkt(RADEON_EMIT_PP_BORDER_COLOR_0);
+ rmesa->hw.tex[1].cmd[TEX_CMD_0] = cmdpkt(RADEON_EMIT_PP_TXFILTER_1);
+ rmesa->hw.tex[1].cmd[TEX_CMD_1] = cmdpkt(RADEON_EMIT_PP_BORDER_COLOR_1);
+ rmesa->hw.zbs.cmd[ZBS_CMD_0] = cmdpkt(RADEON_EMIT_SE_ZBIAS_FACTOR);
+ rmesa->hw.tcl.cmd[TCL_CMD_0] = cmdpkt(RADEON_EMIT_SE_TCL_OUTPUT_VTX_FMT);
+ rmesa->hw.mtl.cmd[MTL_CMD_0] =
+ cmdpkt(RADEON_EMIT_SE_TCL_MATERIAL_EMMISSIVE_RED);
+ rmesa->hw.txr[0].cmd[TXR_CMD_0] = cmdpkt(RADEON_EMIT_PP_TEX_SIZE_0);
+ rmesa->hw.txr[1].cmd[TXR_CMD_0] = cmdpkt(RADEON_EMIT_PP_TEX_SIZE_1);
+ rmesa->hw.grd.cmd[GRD_CMD_0] =
+ cmdscl( RADEON_SS_VERT_GUARD_CLIP_ADJ_ADDR, 1, 4 );
+ rmesa->hw.fog.cmd[FOG_CMD_0] =
+ cmdvec( RADEON_VS_FOG_PARAM_ADDR, 1, 4 );
+ rmesa->hw.glt.cmd[GLT_CMD_0] =
+ cmdvec( RADEON_VS_GLOBAL_AMBIENT_ADDR, 1, 4 );
+ rmesa->hw.eye.cmd[EYE_CMD_0] =
+ cmdvec( RADEON_VS_EYE_VECTOR_ADDR, 1, 4 );
+
+ for (i = 0 ; i < 5; i++) {
+ rmesa->hw.mat[i].cmd[MAT_CMD_0] =
+ cmdvec( RADEON_VS_MATRIX_0_ADDR + i*4, 1, 16);
+ }
+
+ for (i = 0 ; i < 8; i++) {
+ rmesa->hw.lit[i].cmd[LIT_CMD_0] =
+ cmdvec( RADEON_VS_LIGHT_AMBIENT_ADDR + i, 8, 24 );
+ rmesa->hw.lit[i].cmd[LIT_CMD_1] =
+ cmdscl( RADEON_SS_LIGHT_DCD_ADDR + i, 8, 6 );
+ }
+
+ for (i = 0 ; i < 6; i++) {
+ rmesa->hw.ucp[i].cmd[UCP_CMD_0] =
+ cmdvec( RADEON_VS_UCP_ADDR + i, 1, 4 );
+ }
+
+ rmesa->last_ReallyEnabled = -1;
+
+ /* Initial Harware state:
+ */
+ rmesa->hw.ctx.cmd[CTX_PP_MISC] = (RADEON_ALPHA_TEST_PASS |
+ RADEON_CHROMA_FUNC_FAIL |
+ RADEON_CHROMA_KEY_NEAREST |
+ RADEON_SHADOW_FUNC_EQUAL |
+ RADEON_SHADOW_PASS_1 |
+ RADEON_RIGHT_HAND_CUBE_OGL);
+
+ rmesa->hw.ctx.cmd[CTX_PP_FOG_COLOR] = (RADEON_FOG_VERTEX |
+ RADEON_FOG_USE_DEPTH);
+
+ rmesa->hw.ctx.cmd[CTX_RE_SOLID_COLOR] = 0x00000000;
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_BLENDCNTL] = (RADEON_COMB_FCN_ADD_CLAMP |
+ RADEON_SRC_BLEND_GL_ONE |
+ RADEON_DST_BLEND_GL_ZERO );
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_DEPTHOFFSET] =
+ rmesa->radeonScreen->depthOffset + rmesa->radeonScreen->fbLocation;
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_DEPTHPITCH] =
+ ((rmesa->radeonScreen->depthPitch &
+ RADEON_DEPTHPITCH_MASK) |
+ RADEON_DEPTH_ENDIAN_NO_SWAP);
+
+ if (rmesa->using_hyperz)
+ rmesa->hw.ctx.cmd[CTX_RB3D_DEPTHPITCH] |= RADEON_DEPTH_HYPERZ;
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] = (depth_fmt |
+ RADEON_Z_TEST_LESS |
+ RADEON_STENCIL_TEST_ALWAYS |
+ RADEON_STENCIL_FAIL_KEEP |
+ RADEON_STENCIL_ZPASS_KEEP |
+ RADEON_STENCIL_ZFAIL_KEEP |
+ RADEON_Z_WRITE_ENABLE);
+
+ if (rmesa->using_hyperz) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_Z_COMPRESSION_ENABLE |
+ RADEON_Z_DECOMPRESSION_ENABLE;
+ if (rmesa->radeonScreen->chipset & RADEON_CHIPSET_TCL) {
+ /* works for q3, but slight rendering errors with glxgears ? */
+/* rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_Z_HIERARCHY_ENABLE;*/
+ /* need this otherwise get lots of lockups with q3 ??? */
+ rmesa->hw.ctx.cmd[CTX_RB3D_ZSTENCILCNTL] |= RADEON_FORCE_Z_DIRTY;
+ }
+ }
+
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] = (RADEON_SCISSOR_ENABLE |
+ RADEON_ANTI_ALIAS_NONE);
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] = (RADEON_PLANE_MASK_ENABLE |
+ color_fmt |
+ RADEON_ZBLOCK16);
+
+ switch ( driQueryOptioni( &rmesa->optionCache, "dither_mode" ) ) {
+ case DRI_CONF_DITHER_XERRORDIFFRESET:
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_DITHER_INIT;
+ break;
+ case DRI_CONF_DITHER_ORDERED:
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_SCALE_DITHER_ENABLE;
+ break;
+ }
+ if ( driQueryOptioni( &rmesa->optionCache, "round_mode" ) ==
+ DRI_CONF_ROUND_ROUND )
+ rmesa->state.color.roundEnable = RADEON_ROUND_ENABLE;
+ else
+ rmesa->state.color.roundEnable = 0;
+ if ( driQueryOptioni (&rmesa->optionCache, "color_reduction" ) ==
+ DRI_CONF_COLOR_REDUCTION_DITHER )
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= RADEON_DITHER_ENABLE;
+ else
+ rmesa->hw.ctx.cmd[CTX_RB3D_CNTL] |= rmesa->state.color.roundEnable;
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLOROFFSET] = ((rmesa->state.color.drawOffset +
+ rmesa->radeonScreen->fbLocation)
+ & RADEON_COLOROFFSET_MASK);
+
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] = ((rmesa->state.color.drawPitch &
+ RADEON_COLORPITCH_MASK) |
+ RADEON_COLOR_ENDIAN_NO_SWAP);
+ /* (fixed size) sarea is initialized to zero afaics so can omit version check. Phew! */
+ if (rmesa->sarea->tiling_enabled) {
+ rmesa->hw.ctx.cmd[CTX_RB3D_COLORPITCH] |= RADEON_COLOR_TILE_ENABLE;
+ }
+
+ rmesa->hw.set.cmd[SET_SE_CNTL] = (RADEON_FFACE_CULL_CCW |
+ RADEON_BFACE_SOLID |
+ RADEON_FFACE_SOLID |
+/* RADEON_BADVTX_CULL_DISABLE | */
+ RADEON_FLAT_SHADE_VTX_LAST |
+ RADEON_DIFFUSE_SHADE_GOURAUD |
+ RADEON_ALPHA_SHADE_GOURAUD |
+ RADEON_SPECULAR_SHADE_GOURAUD |
+ RADEON_FOG_SHADE_GOURAUD |
+ RADEON_VPORT_XY_XFORM_ENABLE |
+ RADEON_VPORT_Z_XFORM_ENABLE |
+ RADEON_VTX_PIX_CENTER_OGL |
+ RADEON_ROUND_MODE_TRUNC |
+ RADEON_ROUND_PREC_8TH_PIX);
+
+ rmesa->hw.set.cmd[SET_SE_CNTL_STATUS] =
+#ifdef MESA_BIG_ENDIAN
+ RADEON_VC_32BIT_SWAP;
+#else
+ RADEON_VC_NO_SWAP;
+#endif
+
+ if (!(rmesa->radeonScreen->chipset & RADEON_CHIPSET_TCL)) {
+ rmesa->hw.set.cmd[SET_SE_CNTL_STATUS] |= RADEON_TCL_BYPASS;
+ }
+
+ rmesa->hw.set.cmd[SET_SE_COORDFMT] = (
+ RADEON_VTX_W0_IS_NOT_1_OVER_W0 |
+ RADEON_TEX1_W_ROUTING_USE_Q1);
+
+
+ rmesa->hw.lin.cmd[LIN_RE_LINE_PATTERN] = ((1 << 16) | 0xffff);
+
+ rmesa->hw.lin.cmd[LIN_RE_LINE_STATE] =
+ ((0 << RADEON_LINE_CURRENT_PTR_SHIFT) |
+ (1 << RADEON_LINE_CURRENT_COUNT_SHIFT));
+
+ rmesa->hw.lin.cmd[LIN_SE_LINE_WIDTH] = (1 << 4);
+
+ rmesa->hw.msk.cmd[MSK_RB3D_STENCILREFMASK] =
+ ((0x00 << RADEON_STENCIL_REF_SHIFT) |
+ (0xff << RADEON_STENCIL_MASK_SHIFT) |
+ (0xff << RADEON_STENCIL_WRITEMASK_SHIFT));
+
+ rmesa->hw.msk.cmd[MSK_RB3D_ROPCNTL] = RADEON_ROP_COPY;
+ rmesa->hw.msk.cmd[MSK_RB3D_PLANEMASK] = 0xffffffff;
+
+ rmesa->hw.msc.cmd[MSC_RE_MISC] =
+ ((0 << RADEON_STIPPLE_X_OFFSET_SHIFT) |
+ (0 << RADEON_STIPPLE_Y_OFFSET_SHIFT) |
+ RADEON_STIPPLE_BIG_BIT_ORDER);
+
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_XSCALE] = 0x00000000;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_XOFFSET] = 0x00000000;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_YSCALE] = 0x00000000;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_YOFFSET] = 0x00000000;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_ZSCALE] = 0x00000000;
+ rmesa->hw.vpt.cmd[VPT_SE_VPORT_ZOFFSET] = 0x00000000;
+
+ for ( i = 0 ; i < ctx->Const.MaxTextureUnits ; i++ ) {
+ rmesa->hw.tex[i].cmd[TEX_PP_TXFILTER] = RADEON_BORDER_MODE_OGL;
+ rmesa->hw.tex[i].cmd[TEX_PP_TXFORMAT] =
+ (RADEON_TXFORMAT_ENDIAN_NO_SWAP |
+ RADEON_TXFORMAT_PERSPECTIVE_ENABLE |
+ (i << 24) | /* This is one of RADEON_TXFORMAT_ST_ROUTE_STQ[012] */
+ (2 << RADEON_TXFORMAT_WIDTH_SHIFT) |
+ (2 << RADEON_TXFORMAT_HEIGHT_SHIFT));
+
+ /* Initialize the texture offset to the start of the card texture heap */
+ rmesa->hw.tex[i].cmd[TEX_PP_TXOFFSET] =
+ rmesa->radeonScreen->texOffset[RADEON_LOCAL_TEX_HEAP];
+
+ rmesa->hw.tex[i].cmd[TEX_PP_BORDER_COLOR] = 0;
+ rmesa->hw.tex[i].cmd[TEX_PP_TXCBLEND] =
+ (RADEON_COLOR_ARG_A_ZERO |
+ RADEON_COLOR_ARG_B_ZERO |
+ RADEON_COLOR_ARG_C_CURRENT_COLOR |
+ RADEON_BLEND_CTL_ADD |
+ RADEON_SCALE_1X |
+ RADEON_CLAMP_TX);
+ rmesa->hw.tex[i].cmd[TEX_PP_TXABLEND] =
+ (RADEON_ALPHA_ARG_A_ZERO |
+ RADEON_ALPHA_ARG_B_ZERO |
+ RADEON_ALPHA_ARG_C_CURRENT_ALPHA |
+ RADEON_BLEND_CTL_ADD |
+ RADEON_SCALE_1X |
+ RADEON_CLAMP_TX);
+ rmesa->hw.tex[i].cmd[TEX_PP_TFACTOR] = 0;
+ }
+
+ /* Can only add ST1 at the time of doing some multitex but can keep
+ * it after that. Errors if DIFFUSE is missing.
+ */
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] =
+ (RADEON_TCL_VTX_Z0 |
+ RADEON_TCL_VTX_W0 |
+ RADEON_TCL_VTX_PK_DIFFUSE
+ ); /* need to keep this uptodate */
+
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXSEL] =
+ ( RADEON_TCL_COMPUTE_XYZW |
+ (RADEON_TCL_TEX_INPUT_TEX_0 << RADEON_TCL_TEX_0_OUTPUT_SHIFT) |
+ (RADEON_TCL_TEX_INPUT_TEX_1 << RADEON_TCL_TEX_1_OUTPUT_SHIFT) |
+ (RADEON_TCL_TEX_INPUT_TEX_2 << RADEON_TCL_TEX_2_OUTPUT_SHIFT));
+
+
+ /* XXX */
+ rmesa->hw.tcl.cmd[TCL_MATRIX_SELECT_0] =
+ ((MODEL << RADEON_MODELVIEW_0_SHIFT) |
+ (MODEL_IT << RADEON_IT_MODELVIEW_0_SHIFT));
+
+ rmesa->hw.tcl.cmd[TCL_MATRIX_SELECT_1] =
+ ((MODEL_PROJ << RADEON_MODELPROJECT_0_SHIFT) |
+ (TEXMAT_0 << RADEON_TEXMAT_0_SHIFT) |
+ (TEXMAT_1 << RADEON_TEXMAT_1_SHIFT));
+
+ rmesa->hw.tcl.cmd[TCL_UCP_VERT_BLEND_CTL] =
+ (RADEON_UCP_IN_CLIP_SPACE |
+ RADEON_CULL_FRONT_IS_CCW);
+
+ rmesa->hw.tcl.cmd[TCL_TEXTURE_PROC_CTL] = 0;
+
+ rmesa->hw.tcl.cmd[TCL_LIGHT_MODEL_CTL] =
+ (RADEON_SPECULAR_LIGHTS |
+ RADEON_DIFFUSE_SPECULAR_COMBINE |
+ RADEON_LOCAL_LIGHT_VEC_GL |
+ (RADEON_LM_SOURCE_STATE_MULT << RADEON_EMISSIVE_SOURCE_SHIFT) |
+ (RADEON_LM_SOURCE_STATE_MULT << RADEON_AMBIENT_SOURCE_SHIFT) |
+ (RADEON_LM_SOURCE_STATE_MULT << RADEON_DIFFUSE_SOURCE_SHIFT) |
+ (RADEON_LM_SOURCE_STATE_MULT << RADEON_SPECULAR_SOURCE_SHIFT));
+
+ for (i = 0 ; i < 8; i++) {
+ struct gl_light *l = &ctx->Light.Light[i];
+ GLenum p = GL_LIGHT0 + i;
+ *(float *)&(rmesa->hw.lit[i].cmd[LIT_RANGE_CUTOFF]) = FLT_MAX;
+
+ ctx->Driver.Lightfv( ctx, p, GL_AMBIENT, l->Ambient );
+ ctx->Driver.Lightfv( ctx, p, GL_DIFFUSE, l->Diffuse );
+ ctx->Driver.Lightfv( ctx, p, GL_SPECULAR, l->Specular );
+ ctx->Driver.Lightfv( ctx, p, GL_POSITION, NULL );
+ ctx->Driver.Lightfv( ctx, p, GL_SPOT_DIRECTION, NULL );
+ ctx->Driver.Lightfv( ctx, p, GL_SPOT_EXPONENT, &l->SpotExponent );
+ ctx->Driver.Lightfv( ctx, p, GL_SPOT_CUTOFF, &l->SpotCutoff );
+ ctx->Driver.Lightfv( ctx, p, GL_CONSTANT_ATTENUATION,
+ &l->ConstantAttenuation );
+ ctx->Driver.Lightfv( ctx, p, GL_LINEAR_ATTENUATION,
+ &l->LinearAttenuation );
+ ctx->Driver.Lightfv( ctx, p, GL_QUADRATIC_ATTENUATION,
+ &l->QuadraticAttenuation );
+ *(float *)&(rmesa->hw.lit[i].cmd[LIT_ATTEN_XXX]) = 0.0;
+ }
+
+ ctx->Driver.LightModelfv( ctx, GL_LIGHT_MODEL_AMBIENT,
+ ctx->Light.Model.Ambient );
+
+ TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx );
+
+ for (i = 0 ; i < 6; i++) {
+ ctx->Driver.ClipPlane( ctx, GL_CLIP_PLANE0 + i, NULL );
+ }
+
+ ctx->Driver.Fogfv( ctx, GL_FOG_MODE, NULL );
+ ctx->Driver.Fogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );
+ ctx->Driver.Fogfv( ctx, GL_FOG_START, &ctx->Fog.Start );
+ ctx->Driver.Fogfv( ctx, GL_FOG_END, &ctx->Fog.End );
+ ctx->Driver.Fogfv( ctx, GL_FOG_COLOR, ctx->Fog.Color );
+ ctx->Driver.Fogfv( ctx, GL_FOG_COORDINATE_SOURCE_EXT, NULL );
+
+ rmesa->hw.grd.cmd[GRD_VERT_GUARD_CLIP_ADJ] = IEEE_ONE;
+ rmesa->hw.grd.cmd[GRD_VERT_GUARD_DISCARD_ADJ] = IEEE_ONE;
+ rmesa->hw.grd.cmd[GRD_HORZ_GUARD_CLIP_ADJ] = IEEE_ONE;
+ rmesa->hw.grd.cmd[GRD_HORZ_GUARD_DISCARD_ADJ] = IEEE_ONE;
+
+ rmesa->hw.eye.cmd[EYE_X] = 0;
+ rmesa->hw.eye.cmd[EYE_Y] = 0;
+ rmesa->hw.eye.cmd[EYE_Z] = IEEE_ONE;
+ rmesa->hw.eye.cmd[EYE_RESCALE_FACTOR] = IEEE_ONE;
+
+ rmesa->hw.all_dirty = GL_TRUE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_swtcl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_swtcl.c
new file mode 100644
index 000000000..924d4028d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_swtcl.c
@@ -0,0 +1,983 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_swtcl.c,v 1.6 2003/05/06 23:52:08 daenzer Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "colormac.h"
+#include "enums.h"
+#include "imports.h"
+#include "macros.h"
+
+#include "swrast_setup/swrast_setup.h"
+#include "math/m_translate.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+#include "tnl/t_vtx_api.h" /* for _tnl_FlushVertices */
+
+#include "radeon_context.h"
+#include "radeon_ioctl.h"
+#include "radeon_state.h"
+#include "radeon_swtcl.h"
+#include "radeon_tcl.h"
+
+
+static void flush_last_swtcl_prim( radeonContextPtr rmesa );
+
+/* R100: xyzw, c0, c1/fog, stq[0..2] = 4+1+1+3*3 = 15 right? */
+/* R200: xyzw, c0, c1/fog, strq[0..5] = 4+1+1+4*6 = 30 */
+#define RADEON_MAX_TNL_VERTEX_SIZE (15 * sizeof(GLfloat)) /* for mesa _tnl stage */
+
+/***********************************************************************
+ * Initialization
+ ***********************************************************************/
+
+#define EMIT_ATTR( ATTR, STYLE, F0 ) \
+do { \
+ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].attrib = (ATTR); \
+ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].format = (STYLE); \
+ rmesa->swtcl.vertex_attr_count++; \
+ fmt_0 |= F0; \
+} while (0)
+
+#define EMIT_PAD( N ) \
+do { \
+ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].attrib = 0; \
+ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].format = EMIT_PAD; \
+ rmesa->swtcl.vertex_attrs[rmesa->swtcl.vertex_attr_count].offset = (N); \
+ rmesa->swtcl.vertex_attr_count++; \
+} while (0)
+
+static GLuint radeon_cp_vc_frmts[3][2] =
+{
+ { RADEON_CP_VC_FRMT_ST0, RADEON_CP_VC_FRMT_ST0 | RADEON_CP_VC_FRMT_Q0 },
+ { RADEON_CP_VC_FRMT_ST1, RADEON_CP_VC_FRMT_ST1 | RADEON_CP_VC_FRMT_Q1 },
+ { RADEON_CP_VC_FRMT_ST2, RADEON_CP_VC_FRMT_ST2 | RADEON_CP_VC_FRMT_Q2 },
+};
+
+static void radeonSetVertexFormat( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint index = tnl->render_inputs;
+ int fmt_0 = 0;
+ int offset = 0;
+
+
+ /* Important:
+ */
+ if ( VB->NdcPtr != NULL ) {
+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
+ }
+ else {
+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->ClipPtr;
+ }
+
+ assert( VB->AttribPtr[VERT_ATTRIB_POS] != NULL );
+ rmesa->swtcl.vertex_attr_count = 0;
+
+ /* EMIT_ATTR's must be in order as they tell t_vertex.c how to
+ * build up a hardware vertex.
+ */
+ if ( !rmesa->swtcl.needproj ||
+ (index & _TNL_BITS_TEX_ANY)) { /* for projtex */
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F,
+ RADEON_CP_VC_FRMT_XY | RADEON_CP_VC_FRMT_Z | RADEON_CP_VC_FRMT_W0 );
+ offset = 4;
+ }
+ else {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F,
+ RADEON_CP_VC_FRMT_XY | RADEON_CP_VC_FRMT_Z );
+ offset = 3;
+ }
+
+ rmesa->swtcl.coloroffset = offset;
+#if MESA_LITTLE_ENDIAN
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_RGBA,
+ RADEON_CP_VC_FRMT_PKCOLOR );
+#else
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_ABGR,
+ RADEON_CP_VC_FRMT_PKCOLOR );
+#endif
+ offset += 1;
+
+ rmesa->swtcl.specoffset = 0;
+ if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) {
+
+#if MESA_LITTLE_ENDIAN
+ if (index & _TNL_BIT_COLOR1) {
+ rmesa->swtcl.specoffset = offset;
+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_RGB,
+ RADEON_CP_VC_FRMT_PKSPEC );
+ }
+ else {
+ EMIT_PAD( 3 );
+ }
+
+ if (index & _TNL_BIT_FOG) {
+ EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F,
+ RADEON_CP_VC_FRMT_PKSPEC );
+ }
+ else {
+ EMIT_PAD( 1 );
+ }
+#else
+ if (index & _TNL_BIT_FOG) {
+ EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F,
+ RADEON_CP_VC_FRMT_PKSPEC );
+ }
+ else {
+ EMIT_PAD( 1 );
+ }
+
+ if (index & _TNL_BIT_COLOR1) {
+ rmesa->swtcl.specoffset = offset;
+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR,
+ RADEON_CP_VC_FRMT_PKSPEC );
+ }
+ else {
+ EMIT_PAD( 3 );
+ }
+#endif
+ }
+
+ if (index & _TNL_BITS_TEX_ANY) {
+ int i;
+
+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+ if (index & _TNL_BIT_TEX(i)) {
+ GLuint sz = VB->TexCoordPtr[i]->size;
+
+ switch (sz) {
+ case 1:
+ case 2:
+ case 3:
+ EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_2F,
+ radeon_cp_vc_frmts[i][0] );
+ break;
+ case 4:
+ EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_3F_XYW,
+ radeon_cp_vc_frmts[i][1] );
+ break;
+ default:
+ continue;
+ };
+ }
+ }
+ }
+
+ if ( rmesa->tnl_index != index ||
+ fmt_0 != rmesa->swtcl.vertex_format) {
+ RADEON_NEWPRIM(rmesa);
+ rmesa->swtcl.vertex_format = fmt_0;
+ rmesa->swtcl.vertex_size =
+ _tnl_install_attrs( ctx,
+ rmesa->swtcl.vertex_attrs,
+ rmesa->swtcl.vertex_attr_count,
+ NULL, 0 );
+ rmesa->swtcl.vertex_size /= 4;
+ rmesa->tnl_index = index;
+ if (RADEON_DEBUG & DEBUG_VERTS)
+ fprintf( stderr, "%s: vertex_size= %d floats\n",
+ __FUNCTION__, rmesa->swtcl.vertex_size);
+ }
+}
+
+
+static void radeonRenderStart( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+
+ radeonSetVertexFormat( ctx );
+
+ if (rmesa->dma.flush != 0 &&
+ rmesa->dma.flush != flush_last_swtcl_prim)
+ rmesa->dma.flush( rmesa );
+}
+
+
+/**
+ * Set vertex state for SW TCL. The primary purpose of this function is to
+ * determine in advance whether or not the hardware can / should do the
+ * projection divide or Mesa should do it.
+ */
+void radeonChooseVertexState( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ GLuint se_coord_fmt;
+
+ /* We must ensure that we don't do _tnl_need_projected_coords while in a
+ * rasterization fallback. As this function will be called again when we
+ * leave a rasterization fallback, we can just skip it for now.
+ */
+ if (rmesa->Fallback != 0)
+ return;
+
+ /* HW perspective divide is a win, but tiny vertex formats are a
+ * bigger one.
+ */
+
+ if ( ((tnl->render_inputs & (_TNL_BITS_TEX_ANY|_TNL_BIT_COLOR1) ) == 0)
+ || (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ rmesa->swtcl.needproj = GL_TRUE;
+ se_coord_fmt = (RADEON_VTX_XY_PRE_MULT_1_OVER_W0 |
+ RADEON_VTX_Z_PRE_MULT_1_OVER_W0 |
+ RADEON_TEX1_W_ROUTING_USE_Q1);
+ }
+ else {
+ rmesa->swtcl.needproj = GL_FALSE;
+ se_coord_fmt = (RADEON_VTX_W0_IS_NOT_1_OVER_W0 |
+ RADEON_TEX1_W_ROUTING_USE_Q1);
+ }
+
+ _tnl_need_projected_coords( ctx, rmesa->swtcl.needproj );
+
+ if ( se_coord_fmt != rmesa->hw.set.cmd[SET_SE_COORDFMT] ) {
+ RADEON_STATECHANGE( rmesa, set );
+ rmesa->hw.set.cmd[SET_SE_COORDFMT] = se_coord_fmt;
+ }
+}
+
+
+/* Flush vertices in the current dma region.
+ */
+static void flush_last_swtcl_prim( radeonContextPtr rmesa )
+{
+ if (RADEON_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ rmesa->dma.flush = NULL;
+
+ if (rmesa->dma.current.buf) {
+ struct radeon_dma_region *current = &rmesa->dma.current;
+ GLuint current_offset = (rmesa->radeonScreen->gart_buffer_offset +
+ current->buf->buf->idx * RADEON_BUFFER_SIZE +
+ current->start);
+
+ assert (!(rmesa->swtcl.hw_primitive & RADEON_CP_VC_CNTL_PRIM_WALK_IND));
+
+ assert (current->start +
+ rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
+ current->ptr);
+
+ if (rmesa->dma.current.start != rmesa->dma.current.ptr) {
+ radeonEnsureCmdBufSpace( rmesa, VERT_AOS_BUFSZ +
+ rmesa->hw.max_state_size + VBUF_BUFSZ );
+
+ radeonEmitVertexAOS( rmesa,
+ rmesa->swtcl.vertex_size,
+ current_offset);
+
+ radeonEmitVbufPrim( rmesa,
+ rmesa->swtcl.vertex_format,
+ rmesa->swtcl.hw_primitive,
+ rmesa->swtcl.numverts);
+ }
+
+ rmesa->swtcl.numverts = 0;
+ current->start = current->ptr;
+ }
+}
+
+
+/* Alloc space in the current dma region.
+ */
+static __inline void *radeonAllocDmaLowVerts( radeonContextPtr rmesa,
+ int nverts, int vsize )
+{
+ GLuint bytes = vsize * nverts;
+
+ if ( rmesa->dma.current.ptr + bytes > rmesa->dma.current.end )
+ radeonRefillCurrentDmaRegion( rmesa );
+
+ if (!rmesa->dma.flush) {
+ rmesa->glCtx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
+ rmesa->dma.flush = flush_last_swtcl_prim;
+ }
+
+ assert( vsize == rmesa->swtcl.vertex_size * 4 );
+ assert( rmesa->dma.flush == flush_last_swtcl_prim );
+ assert (rmesa->dma.current.start +
+ rmesa->swtcl.numverts * rmesa->swtcl.vertex_size * 4 ==
+ rmesa->dma.current.ptr);
+
+
+ {
+ GLubyte *head = (GLubyte *)(rmesa->dma.current.address + rmesa->dma.current.ptr);
+ rmesa->dma.current.ptr += bytes;
+ rmesa->swtcl.numverts += nverts;
+ return head;
+ }
+
+}
+
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * dma buffers. Use strip/fan hardware primitives where possible.
+ * Try to simulate missing primitives with indexed vertices.
+ */
+#define HAVE_POINTS 1
+#define HAVE_LINES 1
+#define HAVE_LINE_STRIPS 1
+#define HAVE_TRIANGLES 1
+#define HAVE_TRI_STRIPS 1
+#define HAVE_TRI_STRIP_1 0
+#define HAVE_TRI_FANS 1
+#define HAVE_QUADS 0
+#define HAVE_QUAD_STRIPS 0
+#define HAVE_POLYGONS 0
+/* \todo: is it possible to make "ELTS" work with t_vertex code ? */
+#define HAVE_ELTS 0
+
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ RADEON_CP_VC_CNTL_PRIM_TYPE_POINT,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_LINE,
+ 0,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_LINE_STRIP,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_STRIP,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN,
+ 0,
+ 0,
+ 0
+};
+
+static __inline void radeonDmaPrimitive( radeonContextPtr rmesa, GLenum prim )
+{
+ RADEON_NEWPRIM( rmesa );
+ rmesa->swtcl.hw_primitive = hw_prim[prim];
+ assert(rmesa->dma.current.ptr == rmesa->dma.current.start);
+}
+
+#define LOCAL_VARS radeonContextPtr rmesa = RADEON_CONTEXT(ctx)
+#define INIT( prim ) radeonDmaPrimitive( rmesa, prim )
+#define FLUSH() RADEON_NEWPRIM( rmesa )
+#define GET_CURRENT_VB_MAX_VERTS() \
+ (((int)rmesa->dma.current.end - (int)rmesa->dma.current.ptr) / (rmesa->swtcl.vertex_size*4))
+#define GET_SUBSEQUENT_VB_MAX_VERTS() \
+ ((RADEON_BUFFER_SIZE) / (rmesa->swtcl.vertex_size*4))
+#define ALLOC_VERTS( nr ) \
+ radeonAllocDmaLowVerts( rmesa, nr, rmesa->swtcl.vertex_size * 4 )
+#define EMIT_VERTS( ctx, j, nr, buf ) \
+ _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf)
+
+#define TAG(x) radeon_dma_##x
+#include "tnl_dd/t_dd_dmatmp.h"
+
+
+/**********************************************************************/
+/* Render pipeline stage */
+/**********************************************************************/
+
+
+static GLboolean radeon_run_render( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ tnl_render_func *tab = TAG(render_tab_verts);
+ GLuint i;
+
+ if (rmesa->swtcl.indexed_verts.buf)
+ RELEASE_ELT_VERTS();
+
+ if (rmesa->swtcl.RenderIndex != 0 ||
+ !radeon_dma_validate_render( ctx, VB ))
+ return GL_TRUE;
+
+ tnl->Driver.Render.Start( ctx );
+
+ for (i = 0 ; i < VB->PrimitiveCount ; i++)
+ {
+ GLuint prim = VB->Primitive[i].mode;
+ GLuint start = VB->Primitive[i].start;
+ GLuint length = VB->Primitive[i].count;
+
+ if (!length)
+ continue;
+
+ if (RADEON_DEBUG & DEBUG_PRIMS)
+ fprintf(stderr, "radeon_render.c: prim %s %d..%d\n",
+ _mesa_lookup_enum_by_nr(prim & PRIM_MODE_MASK),
+ start, start+length);
+
+ if (length)
+ tab[prim & PRIM_MODE_MASK]( ctx, start, start + length, prim );
+ }
+
+ tnl->Driver.Render.Finish( ctx );
+
+ return GL_FALSE; /* finished the pipe */
+}
+
+
+
+
+const struct tnl_pipeline_stage _radeon_render_stage =
+{
+ "radeon render",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ radeon_run_render /* run */
+};
+
+
+/**************************************************************************/
+
+/* Radeon texture rectangle expects coords in 0..1 range, not 0..dimension
+ * as in the extension spec. Need to translate here.
+ *
+ * Note that swrast expects 0..dimension, so if a fallback is active,
+ * don't do anything. (Maybe need to configure swrast to match hw)
+ */
+struct texrect_stage_data {
+ GLvector4f texcoord[MAX_TEXTURE_UNITS];
+};
+
+#define TEXRECT_STAGE_DATA(stage) ((struct texrect_stage_data *)stage->privatePtr)
+
+
+static GLboolean run_texrect_stage( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ struct texrect_stage_data *store = TEXRECT_STAGE_DATA(stage);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i;
+
+ if (rmesa->Fallback)
+ return GL_TRUE;
+
+ for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) {
+ if (ctx->Texture.Unit[i]._ReallyEnabled & TEXTURE_RECT_BIT) {
+ struct gl_texture_object *texObj = ctx->Texture.Unit[i].CurrentRect;
+ struct gl_texture_image *texImage = texObj->Image[0][texObj->BaseLevel];
+ const GLfloat iw = 1.0/texImage->Width;
+ const GLfloat ih = 1.0/texImage->Height;
+ GLfloat *in = (GLfloat *)VB->TexCoordPtr[i]->data;
+ GLint instride = VB->TexCoordPtr[i]->stride;
+ GLfloat (*out)[4] = store->texcoord[i].data;
+ GLint j;
+
+ for (j = 0 ; j < VB->Count ; j++) {
+ out[j][0] = in[0] * iw;
+ out[j][1] = in[1] * ih;
+ in = (GLfloat *)((GLubyte *)in + instride);
+ }
+
+ VB->AttribPtr[VERT_ATTRIB_TEX0+i] = VB->TexCoordPtr[i] = &store->texcoord[i];
+ }
+ }
+
+ return GL_TRUE;
+}
+
+
+/* Called the first time stage->run() is invoked.
+ */
+static GLboolean alloc_texrect_data( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ struct texrect_stage_data *store;
+ GLuint i;
+
+ stage->privatePtr = CALLOC(sizeof(*store));
+ store = TEXRECT_STAGE_DATA(stage);
+ if (!store)
+ return GL_FALSE;
+
+ for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
+ _mesa_vector4f_alloc( &store->texcoord[i], 0, VB->Size, 32 );
+
+ return GL_TRUE;
+}
+
+static void free_texrect_data( struct tnl_pipeline_stage *stage )
+{
+ struct texrect_stage_data *store = TEXRECT_STAGE_DATA(stage);
+ GLuint i;
+
+ if (store) {
+ for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++)
+ if (store->texcoord[i].data)
+ _mesa_vector4f_free( &store->texcoord[i] );
+ FREE( store );
+ stage->privatePtr = NULL;
+ }
+}
+
+const struct tnl_pipeline_stage _radeon_texrect_stage =
+{
+ "radeon texrect stage", /* name */
+ NULL,
+ alloc_texrect_data,
+ free_texrect_data,
+ NULL,
+ run_texrect_stage
+};
+
+
+/**************************************************************************/
+
+
+static const GLuint reduced_hw_prim[GL_POLYGON+1] = {
+ RADEON_CP_VC_CNTL_PRIM_TYPE_POINT,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_LINE,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_LINE,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_LINE,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST,
+ RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST
+};
+
+static void radeonRasterPrimitive( GLcontext *ctx, GLuint hwprim );
+static void radeonRenderPrimitive( GLcontext *ctx, GLenum prim );
+static void radeonResetLineStipple( GLcontext *ctx );
+
+
+/***********************************************************************
+ * Emit primitives as inline vertices *
+ ***********************************************************************/
+
+#undef LOCAL_VARS
+#undef ALLOC_VERTS
+#define CTX_ARG radeonContextPtr rmesa
+#define GET_VERTEX_DWORDS() rmesa->swtcl.vertex_size
+#define ALLOC_VERTS( n, size ) radeonAllocDmaLowVerts( rmesa, n, (size) * 4 )
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx); \
+ const char *radeonverts = (char *)rmesa->swtcl.verts;
+#define VERT(x) (radeonVertex *)(radeonverts + ((x) * (vertsize) * sizeof(int)))
+#define VERTEX radeonVertex
+#undef TAG
+#define TAG(x) radeon_##x
+#include "tnl_dd/t_dd_triemit.h"
+
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define QUAD( a, b, c, d ) radeon_quad( rmesa, a, b, c, d )
+#define TRI( a, b, c ) radeon_triangle( rmesa, a, b, c )
+#define LINE( a, b ) radeon_line( rmesa, a, b )
+#define POINT( a ) radeon_point( rmesa, a )
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define RADEON_TWOSIDE_BIT 0x01
+#define RADEON_UNFILLED_BIT 0x02
+#define RADEON_MAX_TRIFUNC 0x08
+
+
+static struct {
+ tnl_points_func points;
+ tnl_line_func line;
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
+} rast_tab[RADEON_MAX_TRIFUNC];
+
+
+#define DO_FALLBACK 0
+#define DO_OFFSET 0
+#define DO_UNFILLED (IND & RADEON_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & RADEON_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 1
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define TAB rast_tab
+
+#define DEPTH_SCALE 1.0
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a < 0)
+#define GET_VERTEX(e) (rmesa->swtcl.verts + ((e) * rmesa->swtcl.vertex_size * sizeof(int)))
+
+#define VERT_SET_RGBA( v, c ) \
+do { \
+ radeon_color_t *color = (radeon_color_t *)&((v)->ui[coloroffset]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \
+} while (0)
+
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+
+#define VERT_SET_SPEC( v, c ) \
+do { \
+ if (specoffset) { \
+ radeon_color_t *spec = (radeon_color_t *)&((v)->ui[specoffset]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(spec->red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(spec->green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(spec->blue, (c)[2]); \
+ } \
+} while (0)
+#define VERT_COPY_SPEC( v0, v1 ) \
+do { \
+ if (specoffset) { \
+ radeon_color_t *spec0 = (radeon_color_t *)&((v0)->ui[specoffset]); \
+ radeon_color_t *spec1 = (radeon_color_t *)&((v1)->ui[specoffset]); \
+ spec0->red = spec1->red; \
+ spec0->green = spec1->green; \
+ spec0->blue = spec1->blue; \
+ } \
+} while (0)
+
+/* These don't need LE32_TO_CPU() as they used to save and restore
+ * colors which are already in the correct format.
+ */
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
+#define VERT_SAVE_SPEC( idx ) if (specoffset) spec[idx] = v[idx]->ui[specoffset]
+#define VERT_RESTORE_SPEC( idx ) if (specoffset) v[idx]->ui[specoffset] = spec[idx]
+
+#undef LOCAL_VARS
+#undef TAG
+#undef INIT
+
+#define LOCAL_VARS(n) \
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx); \
+ GLuint color[n], spec[n]; \
+ GLuint coloroffset = rmesa->swtcl.coloroffset; \
+ GLuint specoffset = rmesa->swtcl.specoffset; \
+ (void) color; (void) spec; (void) coloroffset; (void) specoffset;
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+#define RASTERIZE(x) radeonRasterPrimitive( ctx, reduced_hw_prim[x] )
+#define RENDER_PRIMITIVE rmesa->swtcl.render_primitive
+#undef TAG
+#define TAG(x) x
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
+
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (RADEON_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (RADEON_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (RADEON_TWOSIDE_BIT|RADEON_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+static void init_rast_tab( void )
+{
+ init();
+ init_twoside();
+ init_unfilled();
+ init_twoside_unfilled();
+}
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ radeon_point( rmesa, VERT(start) )
+#define RENDER_LINE( v0, v1 ) \
+ radeon_line( rmesa, VERT(v0), VERT(v1) )
+#define RENDER_TRI( v0, v1, v2 ) \
+ radeon_triangle( rmesa, VERT(v0), VERT(v1), VERT(v2) )
+#define RENDER_QUAD( v0, v1, v2, v3 ) \
+ radeon_quad( rmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
+#undef INIT
+#define INIT(x) do { \
+ radeonRenderPrimitive( ctx, x ); \
+} while (0)
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx); \
+ const GLuint vertsize = rmesa->swtcl.vertex_size; \
+ const char *radeonverts = (char *)rmesa->swtcl.verts; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ const GLboolean stipple = ctx->Line.StippleFlag; \
+ (void) elt; (void) stipple;
+#define RESET_STIPPLE if ( stipple ) radeonResetLineStipple( ctx );
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) (x)
+#define TAG(x) radeon_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+#undef ELT
+#undef TAG
+#define TAG(x) radeon_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl/t_vb_rendertmp.h"
+
+
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+void radeonChooseRenderState( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint index = 0;
+ GLuint flags = ctx->_TriangleCaps;
+
+ if (!rmesa->TclFallback || rmesa->Fallback)
+ return;
+
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= RADEON_TWOSIDE_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= RADEON_UNFILLED_BIT;
+
+ if (index != rmesa->swtcl.RenderIndex) {
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.ClippedLine = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = radeon_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = radeon_render_tab_elts;
+ tnl->Driver.Render.ClippedPolygon = radeon_fast_clipped_poly;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon;
+ }
+
+ rmesa->swtcl.RenderIndex = index;
+ }
+}
+
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+
+static void radeonRasterPrimitive( GLcontext *ctx, GLuint hwprim )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if (rmesa->swtcl.hw_primitive != hwprim) {
+ RADEON_NEWPRIM( rmesa );
+ rmesa->swtcl.hw_primitive = hwprim;
+ }
+}
+
+static void radeonRenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ rmesa->swtcl.render_primitive = prim;
+ if (prim < GL_TRIANGLES || !(ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ radeonRasterPrimitive( ctx, reduced_hw_prim[prim] );
+}
+
+static void radeonRenderFinish( GLcontext *ctx )
+{
+}
+
+static void radeonResetLineStipple( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ RADEON_STATECHANGE( rmesa, lin );
+}
+
+
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+
+static const char * const fallbackStrings[] = {
+ "Texture mode",
+ "glDrawBuffer(GL_FRONT_AND_BACK)",
+ "glEnable(GL_STENCIL) without hw stencil buffer",
+ "glRenderMode(selection or feedback)",
+ "glBlendEquation",
+ "glBlendFunc",
+ "RADEON_NO_RAST",
+ "Mixing GL_CLAMP_TO_BORDER and GL_CLAMP (or GL_MIRROR_CLAMP_ATI)"
+};
+
+
+static const char *getFallbackString(GLuint bit)
+{
+ int i = 0;
+ while (bit > 1) {
+ i++;
+ bit >>= 1;
+ }
+ return fallbackStrings[i];
+}
+
+
+void radeonFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldfallback = rmesa->Fallback;
+
+ if (mode) {
+ rmesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ RADEON_FIREVERTICES( rmesa );
+ TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_RASTER, GL_TRUE );
+ _swsetup_Wakeup( ctx );
+ rmesa->swtcl.RenderIndex = ~0;
+ if (RADEON_DEBUG & DEBUG_FALLBACKS) {
+ fprintf(stderr, "Radeon begin rasterization fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ }
+ }
+ else {
+ rmesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = radeonRenderStart;
+ tnl->Driver.Render.PrimitiveNotify = radeonRenderPrimitive;
+ tnl->Driver.Render.Finish = radeonRenderFinish;
+
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+
+ tnl->Driver.Render.ResetLineStipple = radeonResetLineStipple;
+ TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_RASTER, GL_FALSE );
+ if (rmesa->TclFallback) {
+ /* These are already done if rmesa->TclFallback goes to
+ * zero above. But not if it doesn't (RADEON_NO_TCL for
+ * example?)
+ */
+ radeonChooseVertexState( ctx );
+ radeonChooseRenderState( ctx );
+ }
+ if (RADEON_DEBUG & DEBUG_FALLBACKS) {
+ fprintf(stderr, "Radeon end rasterization fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ }
+ }
+}
+
+
+void radeonFlushVertices( GLcontext *ctx, GLuint flags )
+{
+ _tnl_FlushVertices( ctx, flags );
+
+ if (flags & FLUSH_STORED_VERTICES)
+ RADEON_NEWPRIM( RADEON_CONTEXT( ctx ) );
+}
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+void radeonInitSwtcl( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+ }
+
+ tnl->Driver.Render.Start = radeonRenderStart;
+ tnl->Driver.Render.Finish = radeonRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = radeonRenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = radeonResetLineStipple;
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+
+ _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
+ RADEON_MAX_TNL_VERTEX_SIZE);
+
+ rmesa->swtcl.verts = (GLubyte *)tnl->clipspace.vertex_buf;
+ rmesa->swtcl.RenderIndex = ~0;
+ rmesa->swtcl.render_primitive = GL_TRIANGLES;
+ rmesa->swtcl.hw_primitive = 0;
+}
+
+
+void radeonDestroySwtcl( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if (rmesa->swtcl.indexed_verts.buf)
+ radeonReleaseDmaRegion( rmesa, &rmesa->swtcl.indexed_verts,
+ __FUNCTION__ );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_swtcl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_swtcl.h
new file mode 100644
index 000000000..f95a52c0b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_swtcl.h
@@ -0,0 +1,69 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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
+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, VA LINUX SYSTEMS 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ *
+ */
+
+#ifndef __RADEON_TRIS_H__
+#define __RADEON_TRIS_H__
+
+#include "mtypes.h"
+#include "swrast/swrast.h"
+#include "radeon_context.h"
+
+extern void radeonInitSwtcl( GLcontext *ctx );
+extern void radeonDestroySwtcl( GLcontext *ctx );
+
+extern void radeonFlushVertices( GLcontext *ctx, GLuint flags );
+extern void radeonChooseRenderState( GLcontext *ctx );
+extern void radeonChooseVertexState( GLcontext *ctx );
+
+extern void radeonCheckTexSizes( GLcontext *ctx );
+
+extern void radeonBuildVertices( GLcontext *ctx, GLuint start, GLuint count,
+ GLuint newinputs );
+
+extern void radeonPrintSetupFlags(char *msg, GLuint flags );
+
+
+extern void radeon_emit_indexed_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count );
+
+extern void radeon_translate_vertex( GLcontext *ctx,
+ const radeonVertex *src,
+ SWvertex *dst );
+
+extern void radeon_print_vertex( GLcontext *ctx, const radeonVertex *v );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tcl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tcl.c
new file mode 100644
index 000000000..b13042d96
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tcl.c
@@ -0,0 +1,489 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ Tungsten Graphics Inc., Austin, 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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "light.h"
+#include "mtypes.h"
+#include "enums.h"
+
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+
+#include "radeon_context.h"
+#include "radeon_state.h"
+#include "radeon_ioctl.h"
+#include "radeon_tex.h"
+#include "radeon_tcl.h"
+#include "radeon_swtcl.h"
+#include "radeon_maos.h"
+
+
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * dma buffers. Use strip/fan hardware primitives where possible.
+ * Try to simulate missing primitives with indexed vertices.
+ */
+#define HAVE_POINTS 1
+#define HAVE_LINES 1
+#define HAVE_LINE_LOOP 0
+#define HAVE_LINE_STRIPS 1
+#define HAVE_TRIANGLES 1
+#define HAVE_TRI_STRIPS 1
+#define HAVE_TRI_STRIP_1 0
+#define HAVE_TRI_FANS 1
+#define HAVE_QUADS 0
+#define HAVE_QUAD_STRIPS 0
+#define HAVE_POLYGONS 1
+#define HAVE_ELTS 1
+
+
+#define HW_POINTS RADEON_CP_VC_CNTL_PRIM_TYPE_POINT
+#define HW_LINES RADEON_CP_VC_CNTL_PRIM_TYPE_LINE
+#define HW_LINE_LOOP 0
+#define HW_LINE_STRIP RADEON_CP_VC_CNTL_PRIM_TYPE_LINE_STRIP
+#define HW_TRIANGLES RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST
+#define HW_TRIANGLE_STRIP_0 RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_STRIP
+#define HW_TRIANGLE_STRIP_1 0
+#define HW_TRIANGLE_FAN RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN
+#define HW_QUADS 0
+#define HW_QUAD_STRIP 0
+#define HW_POLYGON RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN
+
+
+static GLboolean discrete_prim[0x10] = {
+ 0, /* 0 none */
+ 1, /* 1 points */
+ 1, /* 2 lines */
+ 0, /* 3 line_strip */
+ 1, /* 4 tri_list */
+ 0, /* 5 tri_fan */
+ 0, /* 6 tri_type2 */
+ 1, /* 7 rect list (unused) */
+ 1, /* 8 3vert point */
+ 1, /* 9 3vert line */
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+};
+
+
+#define LOCAL_VARS radeonContextPtr rmesa = RADEON_CONTEXT(ctx)
+#define ELT_TYPE GLushort
+
+#define ELT_INIT(prim, hw_prim) \
+ radeonTclPrimitive( ctx, prim, hw_prim | RADEON_CP_VC_CNTL_PRIM_WALK_IND )
+
+#define GET_MESA_ELTS() rmesa->tcl.Elts
+
+
+/* Don't really know how many elts will fit in what's left of cmdbuf,
+ * as there is state to emit, etc:
+ */
+
+/* Testing on isosurf shows a maximum around here. Don't know if it's
+ * the card or driver or kernel module that is causing the behaviour.
+ */
+#define GET_MAX_HW_ELTS() 300
+
+
+#define RESET_STIPPLE() do { \
+ RADEON_STATECHANGE( rmesa, lin ); \
+ radeonEmitState( rmesa ); \
+} while (0)
+
+#define AUTO_STIPPLE( mode ) do { \
+ RADEON_STATECHANGE( rmesa, lin ); \
+ if (mode) \
+ rmesa->hw.lin.cmd[LIN_RE_LINE_PATTERN] |= \
+ RADEON_LINE_PATTERN_AUTO_RESET; \
+ else \
+ rmesa->hw.lin.cmd[LIN_RE_LINE_PATTERN] &= \
+ ~RADEON_LINE_PATTERN_AUTO_RESET; \
+ radeonEmitState( rmesa ); \
+} while (0)
+
+
+
+#define ALLOC_ELTS(nr) radeonAllocElts( rmesa, nr )
+
+static GLushort *radeonAllocElts( radeonContextPtr rmesa, GLuint nr )
+{
+ if (rmesa->dma.flush)
+ rmesa->dma.flush( rmesa );
+
+ radeonEnsureCmdBufSpace(rmesa, AOS_BUFSZ(rmesa->tcl.nr_aos_components) +
+ rmesa->hw.max_state_size + ELTS_BUFSZ(nr));
+
+ radeonEmitAOS( rmesa,
+ rmesa->tcl.aos_components,
+ rmesa->tcl.nr_aos_components, 0 );
+
+ return radeonAllocEltsOpenEnded( rmesa,
+ rmesa->tcl.vertex_format,
+ rmesa->tcl.hw_primitive, nr );
+}
+
+#define CLOSE_ELTS() RADEON_NEWPRIM( rmesa )
+
+
+
+/* TODO: Try to extend existing primitive if both are identical,
+ * discrete and there are no intervening state changes. (Somewhat
+ * duplicates changes to DrawArrays code)
+ */
+static void radeonEmitPrim( GLcontext *ctx,
+ GLenum prim,
+ GLuint hwprim,
+ GLuint start,
+ GLuint count)
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+ radeonTclPrimitive( ctx, prim, hwprim );
+
+ radeonEnsureCmdBufSpace( rmesa, AOS_BUFSZ(rmesa->tcl.nr_aos_components) +
+ rmesa->hw.max_state_size + VBUF_BUFSZ );
+
+ radeonEmitAOS( rmesa,
+ rmesa->tcl.aos_components,
+ rmesa->tcl.nr_aos_components,
+ start );
+
+ /* Why couldn't this packet have taken an offset param?
+ */
+ radeonEmitVbufPrim( rmesa,
+ rmesa->tcl.vertex_format,
+ rmesa->tcl.hw_primitive,
+ count - start );
+}
+
+#define EMIT_PRIM( ctx, prim, hwprim, start, count ) do { \
+ radeonEmitPrim( ctx, prim, hwprim, start, count ); \
+ (void) rmesa; } while (0)
+
+/* Try & join small primitives
+ */
+#if 0
+#define PREFER_DISCRETE_ELT_PRIM( NR, PRIM ) 0
+#else
+#define PREFER_DISCRETE_ELT_PRIM( NR, PRIM ) \
+ ((NR) < 20 || \
+ ((NR) < 40 && \
+ rmesa->tcl.hw_primitive == (PRIM| \
+ RADEON_CP_VC_CNTL_PRIM_WALK_IND| \
+ RADEON_CP_VC_CNTL_TCL_ENABLE)))
+#endif
+
+#ifdef MESA_BIG_ENDIAN
+/* We could do without (most of) this ugliness if dest was always 32 bit word aligned... */
+#define EMIT_ELT(dest, offset, x) do { \
+ int off = offset + ( ( (GLuint)dest & 0x2 ) >> 1 ); \
+ GLushort *des = (GLushort *)( (GLuint)dest & ~0x2 ); \
+ (des)[ off + 1 - 2 * ( off & 1 ) ] = (GLushort)(x); \
+ (void)rmesa; } while (0)
+#else
+#define EMIT_ELT(dest, offset, x) do { \
+ (dest)[offset] = (GLushort) (x); \
+ (void)rmesa; } while (0)
+#endif
+
+#define EMIT_TWO_ELTS(dest, offset, x, y) *(GLuint *)(dest+offset) = ((y)<<16)|(x);
+
+
+
+#define TAG(x) tcl_##x
+#include "tnl_dd/t_dd_dmatmp2.h"
+
+/**********************************************************************/
+/* External entrypoints */
+/**********************************************************************/
+
+void radeonEmitPrimitive( GLcontext *ctx,
+ GLuint first,
+ GLuint last,
+ GLuint flags )
+{
+ tcl_render_tab_verts[flags&PRIM_MODE_MASK]( ctx, first, last, flags );
+}
+
+void radeonEmitEltPrimitive( GLcontext *ctx,
+ GLuint first,
+ GLuint last,
+ GLuint flags )
+{
+ tcl_render_tab_elts[flags&PRIM_MODE_MASK]( ctx, first, last, flags );
+}
+
+void radeonTclPrimitive( GLcontext *ctx,
+ GLenum prim,
+ int hw_prim )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint se_cntl;
+ GLuint newprim = hw_prim | RADEON_CP_VC_CNTL_TCL_ENABLE;
+
+ if (newprim != rmesa->tcl.hw_primitive ||
+ !discrete_prim[hw_prim&0xf]) {
+ RADEON_NEWPRIM( rmesa );
+ rmesa->tcl.hw_primitive = newprim;
+ }
+
+ se_cntl = rmesa->hw.set.cmd[SET_SE_CNTL];
+ se_cntl &= ~RADEON_FLAT_SHADE_VTX_LAST;
+
+ if (prim == GL_POLYGON && (ctx->_TriangleCaps & DD_FLATSHADE))
+ se_cntl |= RADEON_FLAT_SHADE_VTX_0;
+ else
+ se_cntl |= RADEON_FLAT_SHADE_VTX_LAST;
+
+ if (se_cntl != rmesa->hw.set.cmd[SET_SE_CNTL]) {
+ RADEON_STATECHANGE( rmesa, set );
+ rmesa->hw.set.cmd[SET_SE_CNTL] = se_cntl;
+ }
+}
+
+
+/**********************************************************************/
+/* Render pipeline stage */
+/**********************************************************************/
+
+
+/* TCL render.
+ */
+static GLboolean radeon_run_tcl_render( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint inputs = VERT_BIT_POS | VERT_BIT_COLOR0;
+ GLuint i;
+
+ /* TODO: separate this from the swtnl pipeline
+ */
+ if (rmesa->TclFallback)
+ return GL_TRUE; /* fallback to software t&l */
+
+ if (VB->Count == 0)
+ return GL_FALSE;
+
+ /* NOTE: inputs != tnl->render_inputs - these are the untransformed
+ * inputs.
+ */
+ if (ctx->Light.Enabled) {
+ inputs |= VERT_BIT_NORMAL;
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
+ inputs |= VERT_BIT_COLOR1;
+ }
+ }
+
+ if ( ctx->Fog.FogCoordinateSource == GL_FOG_COORD ) {
+ inputs |= VERT_BIT_FOG;
+ }
+
+ for (i = 0 ; i < ctx->Const.MaxTextureUnits; i++) {
+ if (ctx->Texture.Unit[i]._ReallyEnabled) {
+ if (rmesa->TexGenNeedNormals[i]) {
+ inputs |= VERT_BIT_NORMAL;
+ }
+ inputs |= VERT_BIT_TEX(i);
+ }
+ }
+
+ radeonReleaseArrays( ctx, ~0 );
+ radeonEmitArrays( ctx, inputs );
+
+ rmesa->tcl.Elts = VB->Elts;
+
+ for (i = 0 ; i < VB->PrimitiveCount ; i++)
+ {
+ GLuint prim = VB->Primitive[i].mode;
+ GLuint start = VB->Primitive[i].start;
+ GLuint length = VB->Primitive[i].count;
+
+ if (!length)
+ continue;
+
+ if (rmesa->tcl.Elts)
+ radeonEmitEltPrimitive( ctx, start, start+length, prim );
+ else
+ radeonEmitPrimitive( ctx, start, start+length, prim );
+ }
+
+ return GL_FALSE; /* finished the pipe */
+}
+
+
+
+/* Initial state for tcl stage.
+ */
+const struct tnl_pipeline_stage _radeon_tcl_stage =
+{
+ "radeon render",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ radeon_run_tcl_render /* run */
+};
+
+
+
+/**********************************************************************/
+/* Validate state at pipeline start */
+/**********************************************************************/
+
+
+/*-----------------------------------------------------------------------
+ * Manage TCL fallbacks
+ */
+
+
+static void transition_to_swtnl( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint se_cntl;
+
+ RADEON_NEWPRIM( rmesa );
+ rmesa->swtcl.vertex_format = 0;
+
+ radeonChooseVertexState( ctx );
+ radeonChooseRenderState( ctx );
+
+ _mesa_validate_all_lighting_tables( ctx );
+
+ tnl->Driver.NotifyMaterialChange =
+ _mesa_validate_all_lighting_tables;
+
+ radeonReleaseArrays( ctx, ~0 );
+
+ se_cntl = rmesa->hw.set.cmd[SET_SE_CNTL];
+ se_cntl |= RADEON_FLAT_SHADE_VTX_LAST;
+
+ if (se_cntl != rmesa->hw.set.cmd[SET_SE_CNTL]) {
+ RADEON_STATECHANGE( rmesa, set );
+ rmesa->hw.set.cmd[SET_SE_CNTL] = se_cntl;
+ }
+}
+
+
+static void transition_to_hwtnl( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint se_coord_fmt = (RADEON_VTX_W0_IS_NOT_1_OVER_W0 |
+ RADEON_TEX1_W_ROUTING_USE_Q1);
+
+ if ( se_coord_fmt != rmesa->hw.set.cmd[SET_SE_COORDFMT] ) {
+ RADEON_STATECHANGE( rmesa, set );
+ rmesa->hw.set.cmd[SET_SE_COORDFMT] = se_coord_fmt;
+ _tnl_need_projected_coords( ctx, GL_FALSE );
+ }
+
+ radeonUpdateMaterial( ctx );
+
+ tnl->Driver.NotifyMaterialChange = radeonUpdateMaterial;
+
+ if ( rmesa->dma.flush )
+ rmesa->dma.flush( rmesa );
+
+ rmesa->dma.flush = NULL;
+ rmesa->swtcl.vertex_format = 0;
+
+ if (rmesa->swtcl.indexed_verts.buf)
+ radeonReleaseDmaRegion( rmesa, &rmesa->swtcl.indexed_verts,
+ __FUNCTION__ );
+
+ if (RADEON_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "Radeon end tcl fallback\n");
+}
+
+static char *fallbackStrings[] = {
+ "Rasterization fallback",
+ "Unfilled triangles",
+ "Twosided lighting, differing materials",
+ "Materials in VB (maybe between begin/end)",
+ "Texgen unit 0",
+ "Texgen unit 1",
+ "Texgen unit 2",
+ "User disable",
+ "texture rectangle unit 0",
+ "texture rectangle unit 1",
+ "texture rectangle unit 2"
+};
+
+
+static char *getFallbackString(GLuint bit)
+{
+ int i = 0;
+ while (bit > 1) {
+ i++;
+ bit >>= 1;
+ }
+ return fallbackStrings[i];
+}
+
+
+
+void radeonTclFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint oldfallback = rmesa->TclFallback;
+
+ if (mode) {
+ rmesa->TclFallback |= bit;
+ if (oldfallback == 0) {
+ if (RADEON_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "Radeon begin tcl fallback %s\n",
+ getFallbackString( bit ));
+ transition_to_swtnl( ctx );
+ }
+ }
+ else {
+ rmesa->TclFallback &= ~bit;
+ if (oldfallback == bit) {
+ if (RADEON_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "Radeon end tcl fallback %s\n",
+ getFallbackString( bit ));
+ transition_to_hwtnl( ctx );
+ }
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tcl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tcl.h
new file mode 100644
index 000000000..e292d2303
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tcl.h
@@ -0,0 +1,66 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_tcl.h,v 1.2 2003/02/08 21:26:45 dawes Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ Tungsten Grahpics Inc., Austin, 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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ *
+ */
+
+#ifndef __RADEON_TCL_H__
+#define __RADEON_TCL_H__
+
+#include "radeon_context.h"
+
+extern void radeonTclPrimitive( GLcontext *ctx, GLenum prim, int hw_prim );
+extern void radeonEmitEltPrimitive( GLcontext *ctx, GLuint first, GLuint last,
+ GLuint flags );
+extern void radeonEmitPrimitive( GLcontext *ctx, GLuint first, GLuint last,
+ GLuint flags );
+
+extern void radeonTclFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
+
+#define RADEON_TCL_FALLBACK_RASTER 0x1 /* rasterization */
+#define RADEON_TCL_FALLBACK_UNFILLED 0x2 /* unfilled tris */
+#define RADEON_TCL_FALLBACK_LIGHT_TWOSIDE 0x4 /* twoside tris */
+#define RADEON_TCL_FALLBACK_MATERIAL 0x8 /* material in vb */
+#define RADEON_TCL_FALLBACK_TEXGEN_0 0x10 /* texgen, unit 0 */
+#define RADEON_TCL_FALLBACK_TEXGEN_1 0x20 /* texgen, unit 1 */
+#define RADEON_TCL_FALLBACK_TEXGEN_2 0x40 /* texgen, unit 2 */
+#define RADEON_TCL_FALLBACK_TCL_DISABLE 0x80 /* user disable */
+#define RADEON_TCL_FALLBACK_TEXRECT_0 0x100 /* texture rectangle */
+#define RADEON_TCL_FALLBACK_TEXRECT_1 0x200 /* texture rectangle */
+#define RADEON_TCL_FALLBACK_TEXRECT_2 0x400 /* texture rectangle */
+
+#define RADEON_MAX_TCL_VERTSIZE (15*4)
+
+#define TCL_FALLBACK( ctx, bit, mode ) radeonTclFallback( ctx, bit, mode )
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tex.c
new file mode 100644
index 000000000..c466af868
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tex.c
@@ -0,0 +1,866 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_tex.c,v 1.6 2002/09/16 18:05:20 eich Exp $ */
+/*
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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 THE COPYRIGHT OWNER(S) 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:
+ * Gareth Hughes <gareth@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "colormac.h"
+#include "context.h"
+#include "enums.h"
+#include "image.h"
+#include "simple_list.h"
+#include "texformat.h"
+#include "texstore.h"
+#include "teximage.h"
+#include "texobj.h"
+
+
+#include "radeon_context.h"
+#include "radeon_state.h"
+#include "radeon_ioctl.h"
+#include "radeon_swtcl.h"
+#include "radeon_tex.h"
+
+#include "xmlpool.h"
+
+
+
+/**
+ * Set the texture wrap modes.
+ *
+ * \param t Texture object whose wrap modes are to be set
+ * \param swrap Wrap mode for the \a s texture coordinate
+ * \param twrap Wrap mode for the \a t texture coordinate
+ */
+
+static void radeonSetTexWrap( radeonTexObjPtr t, GLenum swrap, GLenum twrap )
+{
+ GLboolean is_clamp = GL_FALSE;
+ GLboolean is_clamp_to_border = GL_FALSE;
+
+ t->pp_txfilter &= ~(RADEON_CLAMP_S_MASK | RADEON_CLAMP_T_MASK | RADEON_BORDER_MODE_D3D);
+
+ switch ( swrap ) {
+ case GL_REPEAT:
+ t->pp_txfilter |= RADEON_CLAMP_S_WRAP;
+ break;
+ case GL_CLAMP:
+ t->pp_txfilter |= RADEON_CLAMP_S_CLAMP_GL;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_CLAMP_TO_EDGE:
+ t->pp_txfilter |= RADEON_CLAMP_S_CLAMP_LAST;
+ break;
+ case GL_CLAMP_TO_BORDER:
+ t->pp_txfilter |= RADEON_CLAMP_S_CLAMP_GL;
+ is_clamp_to_border = GL_TRUE;
+ break;
+ case GL_MIRRORED_REPEAT:
+ t->pp_txfilter |= RADEON_CLAMP_S_MIRROR;
+ break;
+ case GL_MIRROR_CLAMP_EXT:
+ t->pp_txfilter |= RADEON_CLAMP_S_MIRROR_CLAMP_GL;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_MIRROR_CLAMP_TO_EDGE_EXT:
+ t->pp_txfilter |= RADEON_CLAMP_S_MIRROR_CLAMP_LAST;
+ break;
+ case GL_MIRROR_CLAMP_TO_BORDER_EXT:
+ t->pp_txfilter |= RADEON_CLAMP_S_MIRROR_CLAMP_GL;
+ is_clamp_to_border = GL_TRUE;
+ break;
+ default:
+ _mesa_problem(NULL, "bad S wrap mode in %s", __FUNCTION__);
+ }
+
+ switch ( twrap ) {
+ case GL_REPEAT:
+ t->pp_txfilter |= RADEON_CLAMP_T_WRAP;
+ break;
+ case GL_CLAMP:
+ t->pp_txfilter |= RADEON_CLAMP_T_CLAMP_GL;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_CLAMP_TO_EDGE:
+ t->pp_txfilter |= RADEON_CLAMP_T_CLAMP_LAST;
+ break;
+ case GL_CLAMP_TO_BORDER:
+ t->pp_txfilter |= RADEON_CLAMP_T_CLAMP_GL;
+ is_clamp_to_border = GL_TRUE;
+ break;
+ case GL_MIRRORED_REPEAT:
+ t->pp_txfilter |= RADEON_CLAMP_T_MIRROR;
+ break;
+ case GL_MIRROR_CLAMP_EXT:
+ t->pp_txfilter |= RADEON_CLAMP_T_MIRROR_CLAMP_GL;
+ is_clamp = GL_TRUE;
+ break;
+ case GL_MIRROR_CLAMP_TO_EDGE_EXT:
+ t->pp_txfilter |= RADEON_CLAMP_T_MIRROR_CLAMP_LAST;
+ break;
+ case GL_MIRROR_CLAMP_TO_BORDER_EXT:
+ t->pp_txfilter |= RADEON_CLAMP_T_MIRROR_CLAMP_GL;
+ is_clamp_to_border = GL_TRUE;
+ break;
+ default:
+ _mesa_problem(NULL, "bad T wrap mode in %s", __FUNCTION__);
+ }
+
+ if ( is_clamp_to_border ) {
+ t->pp_txfilter |= RADEON_BORDER_MODE_D3D;
+ }
+
+ t->border_fallback = (is_clamp && is_clamp_to_border);
+}
+
+static void radeonSetTexMaxAnisotropy( radeonTexObjPtr t, GLfloat max )
+{
+ t->pp_txfilter &= ~RADEON_MAX_ANISO_MASK;
+
+ if ( max == 1.0 ) {
+ t->pp_txfilter |= RADEON_MAX_ANISO_1_TO_1;
+ } else if ( max <= 2.0 ) {
+ t->pp_txfilter |= RADEON_MAX_ANISO_2_TO_1;
+ } else if ( max <= 4.0 ) {
+ t->pp_txfilter |= RADEON_MAX_ANISO_4_TO_1;
+ } else if ( max <= 8.0 ) {
+ t->pp_txfilter |= RADEON_MAX_ANISO_8_TO_1;
+ } else {
+ t->pp_txfilter |= RADEON_MAX_ANISO_16_TO_1;
+ }
+}
+
+/**
+ * Set the texture magnification and minification modes.
+ *
+ * \param t Texture whose filter modes are to be set
+ * \param minf Texture minification mode
+ * \param magf Texture magnification mode
+ */
+
+static void radeonSetTexFilter( radeonTexObjPtr t, GLenum minf, GLenum magf )
+{
+ GLuint anisotropy = (t->pp_txfilter & RADEON_MAX_ANISO_MASK);
+
+ t->pp_txfilter &= ~(RADEON_MIN_FILTER_MASK | RADEON_MAG_FILTER_MASK);
+
+ if ( anisotropy == RADEON_MAX_ANISO_1_TO_1 ) {
+ switch ( minf ) {
+ case GL_NEAREST:
+ t->pp_txfilter |= RADEON_MIN_FILTER_NEAREST;
+ break;
+ case GL_LINEAR:
+ t->pp_txfilter |= RADEON_MIN_FILTER_LINEAR;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ t->pp_txfilter |= RADEON_MIN_FILTER_NEAREST_MIP_NEAREST;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ t->pp_txfilter |= RADEON_MIN_FILTER_LINEAR_MIP_NEAREST;
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ t->pp_txfilter |= RADEON_MIN_FILTER_NEAREST_MIP_LINEAR;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ t->pp_txfilter |= RADEON_MIN_FILTER_LINEAR_MIP_LINEAR;
+ break;
+ }
+ } else {
+ switch ( minf ) {
+ case GL_NEAREST:
+ t->pp_txfilter |= RADEON_MIN_FILTER_ANISO_NEAREST;
+ break;
+ case GL_LINEAR:
+ t->pp_txfilter |= RADEON_MIN_FILTER_ANISO_LINEAR;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ case GL_LINEAR_MIPMAP_NEAREST:
+ t->pp_txfilter |= RADEON_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ case GL_LINEAR_MIPMAP_LINEAR:
+ t->pp_txfilter |= RADEON_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR;
+ break;
+ }
+ }
+
+ switch ( magf ) {
+ case GL_NEAREST:
+ t->pp_txfilter |= RADEON_MAG_FILTER_NEAREST;
+ break;
+ case GL_LINEAR:
+ t->pp_txfilter |= RADEON_MAG_FILTER_LINEAR;
+ break;
+ }
+}
+
+static void radeonSetTexBorderColor( radeonTexObjPtr t, GLubyte c[4] )
+{
+ t->pp_border_color = radeonPackColor( 4, c[0], c[1], c[2], c[3] );
+}
+
+
+/**
+ * Allocate space for and load the mesa images into the texture memory block.
+ * This will happen before drawing with a new texture, or drawing with a
+ * texture after it was swapped out or teximaged again.
+ */
+
+static radeonTexObjPtr radeonAllocTexObj( struct gl_texture_object *texObj )
+{
+ radeonTexObjPtr t;
+
+ t = CALLOC_STRUCT( radeon_tex_obj );
+ texObj->DriverData = t;
+ if ( t != NULL ) {
+ if ( RADEON_DEBUG & DEBUG_TEXTURE ) {
+ fprintf( stderr, "%s( %p, %p )\n", __FUNCTION__, (void *)texObj, (void *)t );
+ }
+
+ /* Initialize non-image-dependent parts of the state:
+ */
+ t->base.tObj = texObj;
+ t->border_fallback = GL_FALSE;
+
+ t->pp_txfilter = RADEON_BORDER_MODE_OGL;
+ t->pp_txformat = (RADEON_TXFORMAT_ENDIAN_NO_SWAP |
+ RADEON_TXFORMAT_PERSPECTIVE_ENABLE);
+
+ make_empty_list( & t->base );
+
+ radeonSetTexWrap( t, texObj->WrapS, texObj->WrapT );
+ radeonSetTexMaxAnisotropy( t, texObj->MaxAnisotropy );
+ radeonSetTexFilter( t, texObj->MinFilter, texObj->MagFilter );
+ radeonSetTexBorderColor( t, texObj->_BorderChan );
+ }
+
+ return t;
+}
+
+
+static const struct gl_texture_format *
+radeonChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ const GLboolean do32bpt =
+ ( rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32 );
+ const GLboolean force16bpt =
+ ( rmesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16 );
+ (void) format;
+
+ switch ( internalFormat ) {
+ case 4:
+ case GL_RGBA:
+ case GL_COMPRESSED_RGBA:
+ switch ( type ) {
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return do32bpt ? _dri_texformat_argb8888 : _dri_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return _dri_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return _dri_texformat_argb1555;
+ default:
+ return do32bpt ? _dri_texformat_rgba8888 : _dri_texformat_argb4444;
+ }
+
+ case 3:
+ case GL_RGB:
+ case GL_COMPRESSED_RGB:
+ switch ( type ) {
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return _dri_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return _dri_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ return _dri_texformat_rgb565;
+ default:
+ return do32bpt ? _dri_texformat_rgba8888 : _dri_texformat_rgb565;
+ }
+
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return !force16bpt ?
+ _dri_texformat_rgba8888 : _dri_texformat_argb4444;
+
+ case GL_RGBA4:
+ case GL_RGBA2:
+ return _dri_texformat_argb4444;
+
+ case GL_RGB5_A1:
+ return _dri_texformat_argb1555;
+
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ return !force16bpt ? _dri_texformat_rgba8888 : _dri_texformat_rgb565;
+
+ case GL_RGB5:
+ case GL_RGB4:
+ case GL_R3_G3_B2:
+ return _dri_texformat_rgb565;
+
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ case GL_COMPRESSED_ALPHA:
+ return _dri_texformat_a8;
+
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ case GL_COMPRESSED_LUMINANCE:
+ return _dri_texformat_l8;
+
+ 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_COMPRESSED_LUMINANCE_ALPHA:
+ return _dri_texformat_al88;
+
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case GL_COMPRESSED_INTENSITY:
+ return _dri_texformat_i8;
+
+ case GL_YCBCR_MESA:
+ if (type == GL_UNSIGNED_SHORT_8_8_APPLE ||
+ type == GL_UNSIGNED_BYTE)
+ return &_mesa_texformat_ycbcr;
+ else
+ return &_mesa_texformat_ycbcr_rev;
+
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgb_dxt1;
+
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgba_dxt1;
+
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ return &_mesa_texformat_rgba_dxt3;
+
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ return &_mesa_texformat_rgba_dxt5;
+
+ default:
+ _mesa_problem(ctx, "unexpected texture format in %s", __FUNCTION__);
+ return NULL;
+ }
+
+ return NULL; /* never get here */
+}
+
+
+static void radeonTexImage1D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+ if ( t ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) radeonAllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
+ return;
+ }
+ }
+
+ /* Note, this will call ChooseTextureFormat */
+ _mesa_store_teximage1d(ctx, target, level, internalFormat,
+ width, border, format, type, pixels,
+ &ctx->Unpack, texObj, texImage);
+
+ t->dirty_images[0] |= (1 << level);
+}
+
+
+static void radeonTexSubImage1D( 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 )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+ assert( t ); /* this _should_ be true */
+ if ( t ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) radeonAllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
+ return;
+ }
+ }
+
+ _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
+ format, type, pixels, packing, texObj,
+ texImage);
+
+ t->dirty_images[0] |= (1 << level);
+}
+
+
+static void radeonTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ if ( t != NULL ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) radeonAllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ }
+
+ /* Note, this will call ChooseTextureFormat */
+ _mesa_store_teximage2d(ctx, target, level, internalFormat,
+ width, height, border, format, type, pixels,
+ &ctx->Unpack, texObj, texImage);
+
+ t->dirty_images[face] |= (1 << level);
+}
+
+
+static void radeonTexSubImage2D( 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 )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ assert( t ); /* this _should_ be true */
+ if ( t ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) radeonAllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
+ return;
+ }
+ }
+
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
+
+ t->dirty_images[face] |= (1 << level);
+}
+
+static void radeonCompressedTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ if ( t != NULL ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) radeonAllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
+ return;
+ }
+ }
+
+ /* Note, this will call ChooseTextureFormat */
+ _mesa_store_compressed_teximage2d(ctx, target, level, internalFormat, width,
+ height, border, imageSize, data, texObj, texImage);
+
+ t->dirty_images[face] |= (1 << level);
+}
+
+
+static void radeonCompressedTexSubImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+ GLuint face;
+
+
+ /* which cube face or ordinary 2D image */
+ switch (target) {
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ face = (GLuint) target - (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ ASSERT(face < 6);
+ break;
+ default:
+ face = 0;
+ }
+
+ assert( t ); /* this _should_ be true */
+ if ( t ) {
+ driSwapOutTextureObject( t );
+ }
+ else {
+ t = (driTextureObject *) radeonAllocTexObj( texObj );
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2D");
+ return;
+ }
+ }
+
+ _mesa_store_compressed_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, imageSize, data, texObj, texImage);
+
+ t->dirty_images[face] |= (1 << level);
+}
+
+#define SCALED_FLOAT_TO_BYTE( x, scale ) \
+ (((GLuint)((255.0F / scale) * (x))) / 2)
+
+static void radeonTexEnv( GLcontext *ctx, GLenum target,
+ GLenum pname, const GLfloat *param )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint unit = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+ if ( RADEON_DEBUG & DEBUG_STATE ) {
+ fprintf( stderr, "%s( %s )\n",
+ __FUNCTION__, _mesa_lookup_enum_by_nr( pname ) );
+ }
+
+ switch ( pname ) {
+ case GL_TEXTURE_ENV_COLOR: {
+ GLubyte c[4];
+ GLuint envColor;
+ UNCLAMPED_FLOAT_TO_RGBA_CHAN( c, texUnit->EnvColor );
+ envColor = radeonPackColor( 4, c[0], c[1], c[2], c[3] );
+ if ( rmesa->hw.tex[unit].cmd[TEX_PP_TFACTOR] != envColor ) {
+ RADEON_STATECHANGE( rmesa, tex[unit] );
+ rmesa->hw.tex[unit].cmd[TEX_PP_TFACTOR] = envColor;
+ }
+ break;
+ }
+
+ case GL_TEXTURE_LOD_BIAS_EXT: {
+ GLfloat bias, min;
+ GLuint b;
+
+ /* The Radeon's LOD bias is a signed 2's complement value with a
+ * range of -1.0 <= bias < 4.0. We break this into two linear
+ * functions, one mapping [-1.0,0.0] to [-128,0] and one mapping
+ * [0.0,4.0] to [0,127].
+ */
+ min = driQueryOptionb (&rmesa->optionCache, "no_neg_lod_bias") ?
+ 0.0 : -1.0;
+ bias = CLAMP( *param, min, 4.0 );
+ if ( bias == 0 ) {
+ b = 0;
+ } else if ( bias > 0 ) {
+ b = ((GLuint)SCALED_FLOAT_TO_BYTE( bias, 4.0 )) << RADEON_LOD_BIAS_SHIFT;
+ } else {
+ b = ((GLuint)SCALED_FLOAT_TO_BYTE( bias, 1.0 )) << RADEON_LOD_BIAS_SHIFT;
+ }
+ if ( (rmesa->hw.tex[unit].cmd[TEX_PP_TXFILTER] & RADEON_LOD_BIAS_MASK) != b ) {
+ RADEON_STATECHANGE( rmesa, tex[unit] );
+ rmesa->hw.tex[unit].cmd[TEX_PP_TXFILTER] &= ~RADEON_LOD_BIAS_MASK;
+ rmesa->hw.tex[unit].cmd[TEX_PP_TXFILTER] |= (b & RADEON_LOD_BIAS_MASK);
+ }
+ break;
+ }
+
+ default:
+ return;
+ }
+}
+
+
+/**
+ * Changes variables and flags for a state update, which will happen at the
+ * next UpdateTextureState
+ */
+
+static void radeonTexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj,
+ GLenum pname, const GLfloat *params )
+{
+ radeonTexObjPtr t = (radeonTexObjPtr) texObj->DriverData;
+
+ if ( RADEON_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
+ fprintf( stderr, "%s( %s )\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr( pname ) );
+ }
+
+ switch ( pname ) {
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+ radeonSetTexMaxAnisotropy( t, texObj->MaxAnisotropy );
+ radeonSetTexFilter( t, texObj->MinFilter, texObj->MagFilter );
+ break;
+
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ radeonSetTexWrap( t, texObj->WrapS, texObj->WrapT );
+ break;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ radeonSetTexBorderColor( t, texObj->_BorderChan );
+ break;
+
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ /* This isn't the most efficient solution but there doesn't appear to
+ * be a nice alternative. Since there's no LOD clamping,
+ * we just have to rely on loading the right subset of mipmap levels
+ * to simulate a clamped LOD.
+ */
+ driSwapOutTextureObject( (driTextureObject *) t );
+ break;
+
+ default:
+ return;
+ }
+
+ /* Mark this texobj as dirty (one bit per tex unit)
+ */
+ t->dirty_state = TEX_ALL;
+}
+
+
+static void radeonBindTexture( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj )
+{
+ if ( RADEON_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
+ fprintf( stderr, "%s( %p ) unit=%d\n", __FUNCTION__, (void *)texObj,
+ ctx->Texture.CurrentUnit );
+ }
+
+ assert( (target != GL_TEXTURE_1D && target != GL_TEXTURE_2D &&
+ target != GL_TEXTURE_RECTANGLE_NV) ||
+ (texObj->DriverData != NULL) );
+}
+
+
+static void radeonDeleteTexture( GLcontext *ctx,
+ struct gl_texture_object *texObj )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ driTextureObject * t = (driTextureObject *) texObj->DriverData;
+
+ if ( RADEON_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
+ fprintf( stderr, "%s( %p (target = %s) )\n", __FUNCTION__, (void *)texObj,
+ _mesa_lookup_enum_by_nr( texObj->Target ) );
+ }
+
+ if ( t != NULL ) {
+ if ( rmesa ) {
+ RADEON_FIREVERTICES( rmesa );
+ }
+
+ driDestroyTextureObject( t );
+ }
+
+ /* Free mipmap images and the texture object itself */
+ _mesa_delete_texture_object(ctx, texObj);
+}
+
+/* Need:
+ * - Same GEN_MODE for all active bits
+ * - Same EyePlane/ObjPlane for all active bits when using Eye/Obj
+ * - STRQ presumably all supported (matrix means incoming R values
+ * can end up in STQ, this has implications for vertex support,
+ * presumably ok if maos is used, though?)
+ *
+ * Basically impossible to do this on the fly - just collect some
+ * basic info & do the checks from ValidateState().
+ */
+static void radeonTexGen( GLcontext *ctx,
+ GLenum coord,
+ GLenum pname,
+ const GLfloat *params )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint unit = ctx->Texture.CurrentUnit;
+ rmesa->recheck_texgen[unit] = GL_TRUE;
+}
+
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
+ * Note: we could use containment here to 'derive' the driver-specific
+ * texture object from the core mesa gl_texture_object. Not done at this time.
+ */
+static struct gl_texture_object *
+radeonNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ struct gl_texture_object *obj;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ if (!obj)
+ return NULL;
+ obj->MaxAnisotropy = rmesa->initialMaxAnisotropy;
+ radeonAllocTexObj( obj );
+ return obj;
+}
+
+
+void radeonInitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->ChooseTextureFormat = radeonChooseTextureFormat;
+ functions->TexImage1D = radeonTexImage1D;
+ functions->TexImage2D = radeonTexImage2D;
+ functions->TexSubImage1D = radeonTexSubImage1D;
+ functions->TexSubImage2D = radeonTexSubImage2D;
+
+ functions->NewTextureObject = radeonNewTextureObject;
+ functions->BindTexture = radeonBindTexture;
+ functions->DeleteTexture = radeonDeleteTexture;
+ functions->IsTextureResident = driIsTextureResident;
+
+ functions->TexEnv = radeonTexEnv;
+ functions->TexParameter = radeonTexParameter;
+ functions->TexGen = radeonTexGen;
+
+ functions->CompressedTexImage2D = radeonCompressedTexImage2D;
+ functions->CompressedTexSubImage2D = radeonCompressedTexSubImage2D;
+
+ driInitTextureFormats();
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tex.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tex.h
new file mode 100644
index 000000000..a806981ae
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tex.h
@@ -0,0 +1,50 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_tex.h,v 1.3 2002/02/22 21:45:01 dawes Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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 THE COPYRIGHT OWNER(S) 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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#ifndef __RADEON_TEX_H__
+#define __RADEON_TEX_H__
+
+extern void radeonUpdateTextureState( GLcontext *ctx );
+
+extern int radeonUploadTexImages( radeonContextPtr rmesa, radeonTexObjPtr t,
+ GLuint face );
+
+extern void radeonDestroyTexObj( radeonContextPtr rmesa, radeonTexObjPtr t );
+
+extern void radeonInitTextureFuncs( struct dd_function_table *functions );
+
+#endif /* __RADEON_TEX_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_texmem.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_texmem.c
new file mode 100644
index 000000000..d492e190c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_texmem.c
@@ -0,0 +1,404 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_texmem.c,v 1.7 2002/12/16 16:18:59 dawes Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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 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, VA LINUX SYSTEMS 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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+#include <errno.h>
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "macros.h"
+
+#include "radeon_context.h"
+#include "radeon_ioctl.h"
+#include "radeon_tex.h"
+
+#include <unistd.h> /* for usleep() */
+
+
+/**
+ * Destroy any device-dependent state associated with the texture. This may
+ * include NULLing out hardware state that points to the texture.
+ */
+void
+radeonDestroyTexObj( radeonContextPtr rmesa, radeonTexObjPtr t )
+{
+ if ( RADEON_DEBUG & DEBUG_TEXTURE ) {
+ fprintf( stderr, "%s( %p, %p )\n", __FUNCTION__, (void *)t, (void *)t->base.tObj );
+ }
+
+ if ( rmesa != NULL ) {
+ unsigned i;
+
+
+ for ( i = 0 ; i < rmesa->glCtx->Const.MaxTextureUnits ; i++ ) {
+ if ( t == rmesa->state.texture.unit[i].texobj ) {
+ rmesa->state.texture.unit[i].texobj = NULL;
+ rmesa->hw.tex[i].dirty = GL_FALSE;
+ }
+ }
+ }
+}
+
+
+/* ------------------------------------------------------------
+ * Texture image conversions
+ */
+
+
+static void radeonUploadRectSubImage( radeonContextPtr rmesa,
+ radeonTexObjPtr t,
+ struct gl_texture_image *texImage,
+ GLint x, GLint y,
+ GLint width, GLint height )
+{
+ const struct gl_texture_format *texFormat = texImage->TexFormat;
+ int blit_format, dstPitch, done;
+
+ switch ( texFormat->TexelBytes ) {
+ case 1:
+ blit_format = RADEON_GMC_DST_8BPP_CI;
+ break;
+ case 2:
+ blit_format = RADEON_GMC_DST_16BPP;
+ break;
+ case 4:
+ blit_format = RADEON_GMC_DST_32BPP;
+ break;
+ default:
+ fprintf( stderr, "radeonUploadRectSubImage: unknown blit_format (texelbytes=%d)\n",
+ texFormat->TexelBytes);
+ return;
+ }
+
+ t->image[0][0].data = texImage->Data;
+
+ /* Currently don't need to cope with small pitches.
+ */
+ width = texImage->Width;
+ height = texImage->Height;
+ dstPitch = t->pp_txpitch + 32;
+
+ { /* FIXME: prefer GART-texturing if possible */
+ /* Data not in GART memory, or bad pitch.
+ */
+ for (done = 0; done < height ; ) {
+ struct radeon_dma_region region;
+ int lines = MIN2( height - done, RADEON_BUFFER_SIZE / dstPitch );
+ int src_pitch;
+ char *tex;
+
+ src_pitch = texImage->RowStride * texFormat->TexelBytes;
+
+ tex = (char *)texImage->Data + done * src_pitch;
+
+ memset(&region, 0, sizeof(region));
+ radeonAllocDmaRegion( rmesa, &region, lines * dstPitch, 1024 );
+
+ /* Copy texdata to dma:
+ */
+ if (0)
+ fprintf(stderr, "%s: src_pitch %d dst_pitch %d\n",
+ __FUNCTION__, src_pitch, dstPitch);
+
+ if (src_pitch == dstPitch) {
+ memcpy( region.address + region.start, tex, lines * src_pitch );
+ }
+ else {
+ char *buf = region.address + region.start;
+ int i;
+ for (i = 0 ; i < lines ; i++) {
+ memcpy( buf, tex, src_pitch );
+ buf += dstPitch;
+ tex += src_pitch;
+ }
+ }
+
+ radeonEmitWait( rmesa, RADEON_WAIT_3D );
+
+
+
+ /* Blit to framebuffer
+ */
+ radeonEmitBlit( rmesa,
+ blit_format,
+ dstPitch, GET_START( &region ),
+ dstPitch, t->bufAddr,
+ 0, 0,
+ 0, done,
+ width, lines );
+
+ radeonEmitWait( rmesa, RADEON_WAIT_2D );
+
+ radeonReleaseDmaRegion( rmesa, &region, __FUNCTION__ );
+ done += lines;
+ }
+ }
+}
+
+
+/**
+ * Upload the texture image associated with texture \a t at the specified
+ * level at the address relative to \a start.
+ */
+static void uploadSubImage( radeonContextPtr rmesa, radeonTexObjPtr t,
+ GLint hwlevel,
+ GLint x, GLint y, GLint width, GLint height,
+ GLuint face )
+{
+ struct gl_texture_image *texImage = NULL;
+ GLuint offset;
+ GLint imageWidth, imageHeight;
+ GLint ret;
+ drm_radeon_texture_t tex;
+ drm_radeon_tex_image_t tmp;
+ const int level = hwlevel + t->base.firstLevel;
+
+ if ( RADEON_DEBUG & DEBUG_TEXTURE ) {
+ fprintf( stderr, "%s( %p, %p ) level/width/height/face = %d/%d/%d/%u\n",
+ __FUNCTION__, (void *)t, (void *)t->base.tObj, level, width, height, face );
+ }
+
+ ASSERT(face < 6);
+
+ /* Ensure we have a valid texture to upload */
+ if ( ( hwlevel < 0 ) || ( hwlevel >= RADEON_MAX_TEXTURE_LEVELS ) ) {
+ _mesa_problem(NULL, "bad texture level in %s", __FUNCTION__);
+ return;
+ }
+
+ texImage = t->base.tObj->Image[face][level];
+
+ if ( !texImage ) {
+ if ( RADEON_DEBUG & DEBUG_TEXTURE )
+ fprintf( stderr, "%s: texImage %d is NULL!\n", __FUNCTION__, level );
+ return;
+ }
+ if ( !texImage->Data ) {
+ if ( RADEON_DEBUG & DEBUG_TEXTURE )
+ fprintf( stderr, "%s: image data is NULL!\n", __FUNCTION__ );
+ return;
+ }
+
+
+ if (t->base.tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
+ assert(level == 0);
+ assert(hwlevel == 0);
+ if ( RADEON_DEBUG & DEBUG_TEXTURE )
+ fprintf( stderr, "%s: image data is rectangular\n", __FUNCTION__);
+ radeonUploadRectSubImage( rmesa, t, texImage, x, y, width, height );
+ return;
+ }
+
+ imageWidth = texImage->Width;
+ imageHeight = texImage->Height;
+
+ offset = t->bufAddr;
+
+ if ( RADEON_DEBUG & (DEBUG_TEXTURE|DEBUG_IOCTL) ) {
+ GLint imageX = 0;
+ GLint imageY = 0;
+ GLint blitX = t->image[face][hwlevel].x;
+ GLint blitY = t->image[face][hwlevel].y;
+ GLint blitWidth = t->image[face][hwlevel].width;
+ GLint blitHeight = t->image[face][hwlevel].height;
+ fprintf( stderr, " upload image: %d,%d at %d,%d\n",
+ imageWidth, imageHeight, imageX, imageY );
+ fprintf( stderr, " upload blit: %d,%d at %d,%d\n",
+ blitWidth, blitHeight, blitX, blitY );
+ fprintf( stderr, " blit ofs: 0x%07x level: %d/%d\n",
+ (GLuint)offset, hwlevel, level );
+ }
+
+ t->image[face][hwlevel].data = texImage->Data;
+
+ /* Init the DRM_RADEON_TEXTURE command / drm_radeon_texture_t struct.
+ * NOTE: we're always use a 1KB-wide blit and I8 texture format.
+ * We used to use 1, 2 and 4-byte texels and used to use the texture
+ * width to dictate the blit width - but that won't work for compressed
+ * textures. (Brian)
+ * NOTE: can't do that with texture tiling. (sroland)
+ */
+ tex.offset = offset;
+ tex.image = &tmp;
+ /* copy (x,y,width,height,data) */
+ memcpy( &tmp, &t->image[face][hwlevel], sizeof(drm_radeon_tex_image_t) );
+
+ if (texImage->TexFormat->TexelBytes) {
+ /* use multi-byte upload scheme */
+ tex.height = imageHeight;
+ tex.width = imageWidth;
+ tex.format = t->pp_txformat & RADEON_TXFORMAT_FORMAT_MASK;
+ tex.pitch = MAX2((texImage->Width * texImage->TexFormat->TexelBytes) / 64, 1);
+ tex.offset += tmp.x & ~1023;
+ tmp.x = tmp.x % 1024;
+ if (t->tile_bits & RADEON_TXO_MICRO_TILE_X2) {
+ /* need something like "tiled coordinates" ? */
+ tmp.y = tmp.x / (tex.pitch * 128) * 2;
+ tmp.x = tmp.x % (tex.pitch * 128) / 2 / texImage->TexFormat->TexelBytes;
+ tex.pitch |= RADEON_DST_TILE_MICRO >> 22;
+ }
+ else {
+ tmp.x = tmp.x >> (texImage->TexFormat->TexelBytes >> 1);
+ }
+ if ((t->tile_bits & RADEON_TXO_MACRO_TILE) &&
+ (texImage->Width * texImage->TexFormat->TexelBytes >= 256)) {
+ /* radeon switches off macro tiling for small textures/mipmaps it seems */
+ tex.pitch |= RADEON_DST_TILE_MACRO >> 22;
+ }
+ }
+ else {
+ /* In case of for instance 8x8 texture (2x2 dxt blocks), padding after the first two blocks is
+ needed (only with dxt1 since 2 dxt3/dxt5 blocks already use 32 Byte). */
+ /* set tex.height to 1/4 since 1 "macropixel" (dxt-block) has 4 real pixels. Needed
+ so the kernel module reads the right amount of data. */
+ tex.format = RADEON_TXFORMAT_I8; /* any 1-byte texel format */
+ tex.pitch = (BLIT_WIDTH_BYTES / 64);
+ tex.height = (imageHeight + 3) / 4;
+ tex.width = (imageWidth + 3) / 4;
+ switch (t->pp_txformat & RADEON_TXFORMAT_FORMAT_MASK) {
+ case RADEON_TXFORMAT_DXT1:
+ tex.width *= 8;
+ break;
+ case RADEON_TXFORMAT_DXT23:
+ case RADEON_TXFORMAT_DXT45:
+ tex.width *= 16;
+ break;
+ }
+ }
+
+ LOCK_HARDWARE( rmesa );
+ do {
+ ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_TEXTURE,
+ &tex, sizeof(drm_radeon_texture_t) );
+ } while ( ret && errno == EAGAIN );
+
+ UNLOCK_HARDWARE( rmesa );
+
+ if ( ret ) {
+ fprintf( stderr, "DRM_RADEON_TEXTURE: return = %d\n", ret );
+ fprintf( stderr, " offset=0x%08x\n",
+ offset );
+ fprintf( stderr, " image width=%d height=%d\n",
+ imageWidth, imageHeight );
+ fprintf( stderr, " blit width=%d height=%d data=%p\n",
+ t->image[face][hwlevel].width, t->image[face][hwlevel].height,
+ t->image[face][hwlevel].data );
+ exit( 1 );
+ }
+}
+
+
+/**
+ * Upload the texture images associated with texture \a t. This might
+ * require the allocation of texture memory.
+ *
+ * \param rmesa Context pointer
+ * \param t Texture to be uploaded
+ * \param face Cube map face to be uploaded. Zero for non-cube maps.
+ */
+
+int radeonUploadTexImages( radeonContextPtr rmesa, radeonTexObjPtr t, GLuint face )
+{
+ const int numLevels = t->base.lastLevel - t->base.firstLevel + 1;
+
+ if ( RADEON_DEBUG & (DEBUG_TEXTURE|DEBUG_IOCTL) ) {
+ fprintf( stderr, "%s( %p, %p ) sz=%d lvls=%d-%d\n", __FUNCTION__,
+ (void *)rmesa->glCtx, (void *)t->base.tObj, t->base.totalSize,
+ t->base.firstLevel, t->base.lastLevel );
+ }
+
+ if ( !t || t->base.totalSize == 0 )
+ return 0;
+
+ if (RADEON_DEBUG & DEBUG_SYNC) {
+ fprintf(stderr, "%s: Syncing\n", __FUNCTION__ );
+ radeonFinish( rmesa->glCtx );
+ }
+
+ LOCK_HARDWARE( rmesa );
+
+ if ( t->base.memBlock == NULL ) {
+ int heap;
+
+ heap = driAllocateTexture( rmesa->texture_heaps, rmesa->nr_heaps,
+ (driTextureObject *) t );
+ if ( heap == -1 ) {
+ UNLOCK_HARDWARE( rmesa );
+ return -1;
+ }
+
+ /* Set the base offset of the texture image */
+ t->bufAddr = rmesa->radeonScreen->texOffset[heap]
+ + t->base.memBlock->ofs;
+ t->pp_txoffset = t->bufAddr;
+
+ if (!(t->base.tObj->Image[0][0]->IsClientData)) {
+ /* hope it's safe to add that here... */
+ t->pp_txoffset |= t->tile_bits;
+ }
+
+ /* Mark this texobj as dirty on all units:
+ */
+ t->dirty_state = TEX_ALL;
+ }
+
+
+ /* Let the world know we've used this memory recently.
+ */
+ driUpdateTextureLRU( (driTextureObject *) t );
+ UNLOCK_HARDWARE( rmesa );
+
+
+ /* Upload any images that are new */
+ if (t->base.dirty_images[face]) {
+ int i;
+ for ( i = 0 ; i < numLevels ; i++ ) {
+ if ( (t->base.dirty_images[face] & (1 << (i+t->base.firstLevel))) != 0 ) {
+ uploadSubImage( rmesa, t, i, 0, 0, t->image[face][i].width,
+ t->image[face][i].height, face );
+ }
+ }
+ t->base.dirty_images[face] = 0;
+ }
+
+ if (RADEON_DEBUG & DEBUG_SYNC) {
+ fprintf(stderr, "%s: Syncing\n", __FUNCTION__ );
+ radeonFinish( rmesa->glCtx );
+ }
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_texstate.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_texstate.c
new file mode 100644
index 000000000..43fe509fb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_texstate.c
@@ -0,0 +1,1171 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_texstate.c,v 1.6 2002/12/16 16:18:59 dawes Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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 THE COPYRIGHT OWNER(S) 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 <martin@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "colormac.h"
+#include "context.h"
+#include "macros.h"
+#include "texformat.h"
+#include "enums.h"
+
+#include "radeon_context.h"
+#include "radeon_state.h"
+#include "radeon_ioctl.h"
+#include "radeon_swtcl.h"
+#include "radeon_tex.h"
+#include "radeon_tcl.h"
+
+
+#define RADEON_TXFORMAT_A8 RADEON_TXFORMAT_I8
+#define RADEON_TXFORMAT_L8 RADEON_TXFORMAT_I8
+#define RADEON_TXFORMAT_AL88 RADEON_TXFORMAT_AI88
+#define RADEON_TXFORMAT_YCBCR RADEON_TXFORMAT_YVYU422
+#define RADEON_TXFORMAT_YCBCR_REV RADEON_TXFORMAT_VYUY422
+#define RADEON_TXFORMAT_RGB_DXT1 RADEON_TXFORMAT_DXT1
+#define RADEON_TXFORMAT_RGBA_DXT1 RADEON_TXFORMAT_DXT1
+#define RADEON_TXFORMAT_RGBA_DXT3 RADEON_TXFORMAT_DXT23
+#define RADEON_TXFORMAT_RGBA_DXT5 RADEON_TXFORMAT_DXT45
+
+#define _COLOR(f) \
+ [ MESA_FORMAT_ ## f ] = { RADEON_TXFORMAT_ ## f, 0 }
+#define _COLOR_REV(f) \
+ [ MESA_FORMAT_ ## f ## _REV ] = { RADEON_TXFORMAT_ ## f, 0 }
+#define _ALPHA(f) \
+ [ MESA_FORMAT_ ## f ] = { RADEON_TXFORMAT_ ## f | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 }
+#define _ALPHA_REV(f) \
+ [ MESA_FORMAT_ ## f ## _REV ] = { RADEON_TXFORMAT_ ## f | RADEON_TXFORMAT_ALPHA_IN_MAP, 0 }
+#define _YUV(f) \
+ [ MESA_FORMAT_ ## f ] = { RADEON_TXFORMAT_ ## f, RADEON_YUV_TO_RGB }
+#define _INVALID(f) \
+ [ MESA_FORMAT_ ## f ] = { 0xffffffff, 0 }
+#define VALID_FORMAT(f) ( ((f) <= MESA_FORMAT_RGBA_DXT5) \
+ && (tx_table[f].format != 0xffffffff) )
+
+static const struct {
+ GLuint format, filter;
+}
+tx_table[] =
+{
+ _ALPHA(RGBA8888),
+ _ALPHA_REV(RGBA8888),
+ _ALPHA(ARGB8888),
+ _ALPHA_REV(ARGB8888),
+ _INVALID(RGB888),
+ _COLOR(RGB565),
+ _COLOR_REV(RGB565),
+ _ALPHA(ARGB4444),
+ _ALPHA_REV(ARGB4444),
+ _ALPHA(ARGB1555),
+ _ALPHA_REV(ARGB1555),
+ _ALPHA(AL88),
+ _ALPHA_REV(AL88),
+ _ALPHA(A8),
+ _COLOR(L8),
+ _ALPHA(I8),
+ _INVALID(CI8),
+ _YUV(YCBCR),
+ _YUV(YCBCR_REV),
+ _INVALID(RGB_FXT1),
+ _INVALID(RGBA_FXT1),
+ _COLOR(RGB_DXT1),
+ _ALPHA(RGBA_DXT1),
+ _ALPHA(RGBA_DXT3),
+ _ALPHA(RGBA_DXT5),
+};
+
+#undef _COLOR
+#undef _ALPHA
+#undef _INVALID
+
+/**
+ * This function computes the number of bytes of storage needed for
+ * the given texture object (all mipmap levels, all cube faces).
+ * The \c image[face][level].x/y/width/height parameters for upload/blitting
+ * are computed here. \c pp_txfilter, \c pp_txformat, etc. will be set here
+ * too.
+ *
+ * \param rmesa Context pointer
+ * \param tObj GL texture object whose images are to be posted to
+ * hardware state.
+ */
+static void radeonSetTexImages( radeonContextPtr rmesa,
+ struct gl_texture_object *tObj )
+{
+ radeonTexObjPtr t = (radeonTexObjPtr)tObj->DriverData;
+ const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
+ GLint curOffset, blitWidth;
+ GLint i, texelBytes;
+ GLint numLevels;
+ GLint log2Width, log2Height, log2Depth;
+
+ /* Set the hardware texture format
+ */
+
+ t->pp_txformat &= ~(RADEON_TXFORMAT_FORMAT_MASK |
+ RADEON_TXFORMAT_ALPHA_IN_MAP);
+ t->pp_txfilter &= ~RADEON_YUV_TO_RGB;
+
+ if ( VALID_FORMAT( baseImage->TexFormat->MesaFormat ) ) {
+ t->pp_txformat |= tx_table[ baseImage->TexFormat->MesaFormat ].format;
+ t->pp_txfilter |= tx_table[ baseImage->TexFormat->MesaFormat ].filter;
+ }
+ else {
+ _mesa_problem(NULL, "unexpected texture format in %s", __FUNCTION__);
+ return;
+ }
+
+ texelBytes = baseImage->TexFormat->TexelBytes;
+
+ /* Compute which mipmap levels we really want to send to the hardware.
+ */
+
+ driCalculateTextureFirstLastLevel( (driTextureObject *) t );
+ log2Width = tObj->Image[0][t->base.firstLevel]->WidthLog2;
+ log2Height = tObj->Image[0][t->base.firstLevel]->HeightLog2;
+ log2Depth = tObj->Image[0][t->base.firstLevel]->DepthLog2;
+
+ numLevels = t->base.lastLevel - t->base.firstLevel + 1;
+
+ assert(numLevels <= RADEON_MAX_TEXTURE_LEVELS);
+
+ /* Calculate mipmap offsets and dimensions for blitting (uploading)
+ * The idea is that we lay out the mipmap levels within a block of
+ * memory organized as a rectangle of width BLIT_WIDTH_BYTES.
+ */
+ curOffset = 0;
+ blitWidth = BLIT_WIDTH_BYTES;
+ t->tile_bits = 0;
+
+ /* figure out if this texture is suitable for tiling. */
+ if (texelBytes && (tObj->Target != GL_TEXTURE_RECTANGLE_NV)) {
+ if (rmesa->texmicrotile && (baseImage->Height > 1)) {
+ /* allow 32 (bytes) x 1 mip (which will use two times the space
+ the non-tiled version would use) max if base texture is large enough */
+ if ((numLevels == 1) ||
+ (((baseImage->Width * texelBytes / baseImage->Height) <= 32) &&
+ (baseImage->Width * texelBytes > 64)) ||
+ ((baseImage->Width * texelBytes / baseImage->Height) <= 16)) {
+ /* R100 has two microtile bits (only the txoffset reg, not the blitter)
+ weird: X2 + OPT: 32bit correct, 16bit completely hosed
+ X2: 32bit correct, 16bit correct
+ OPT: 32bit large mips correct, small mips hosed, 16bit completely hosed */
+ t->tile_bits |= RADEON_TXO_MICRO_TILE_X2 /*| RADEON_TXO_MICRO_TILE_OPT*/;
+ }
+ }
+ if ((baseImage->Width * texelBytes >= 256) && (baseImage->Height >= 16)) {
+ /* R100 disables macro tiling only if mip width is smaller than 256 bytes, and not
+ in the case if height is smaller than 16 (not 100% sure), as does the r200,
+ so need to disable macro tiling in that case */
+ if ((numLevels == 1) || ((baseImage->Width * texelBytes / baseImage->Height) <= 4)) {
+ t->tile_bits |= RADEON_TXO_MACRO_TILE;
+ }
+ }
+ }
+
+ for (i = 0; i < numLevels; i++) {
+ const struct gl_texture_image *texImage;
+ GLuint size;
+
+ texImage = tObj->Image[0][i + t->base.firstLevel];
+ if ( !texImage )
+ break;
+
+ /* find image size in bytes */
+ if (texImage->IsCompressed) {
+ /* need to calculate the size AFTER padding even though the texture is
+ submitted without padding.
+ Only handle pot textures currently - don't know if npot is even possible,
+ size calculation would certainly need (trivial) adjustments.
+ Align (and later pad) to 32byte, not sure what that 64byte blit width is
+ good for? */
+ if ((t->pp_txformat & RADEON_TXFORMAT_FORMAT_MASK) == RADEON_TXFORMAT_DXT1) {
+ /* RGB_DXT1/RGBA_DXT1, 8 bytes per block */
+ if ((texImage->Width + 3) < 8) /* width one block */
+ size = texImage->CompressedSize * 4;
+ else if ((texImage->Width + 3) < 16)
+ size = texImage->CompressedSize * 2;
+ else size = texImage->CompressedSize;
+ }
+ else /* DXT3/5, 16 bytes per block */
+ if ((texImage->Width + 3) < 8)
+ size = texImage->CompressedSize * 2;
+ else size = texImage->CompressedSize;
+ }
+ else if (tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
+ size = ((texImage->Width * texelBytes + 63) & ~63) * texImage->Height;
+ }
+ else if (t->tile_bits & RADEON_TXO_MICRO_TILE_X2) {
+ /* tile pattern is 16 bytes x2. mipmaps stay 32 byte aligned,
+ though the actual offset may be different (if texture is less than
+ 32 bytes width) to the untiled case */
+ int w = (texImage->Width * texelBytes * 2 + 31) & ~31;
+ size = (w * ((texImage->Height + 1) / 2)) * texImage->Depth;
+ blitWidth = MAX2(texImage->Width, 64 / texelBytes);
+ }
+ else {
+ int w = (texImage->Width * texelBytes + 31) & ~31;
+ size = w * texImage->Height * texImage->Depth;
+ blitWidth = MAX2(texImage->Width, 64 / texelBytes);
+ }
+ assert(size > 0);
+
+ /* Align to 32-byte offset. It is faster to do this unconditionally
+ * (no branch penalty).
+ */
+
+ curOffset = (curOffset + 0x1f) & ~0x1f;
+
+ if (texelBytes) {
+ t->image[0][i].x = curOffset; /* fix x and y coords up later together with offset */
+ t->image[0][i].y = 0;
+ t->image[0][i].width = MIN2(size / texelBytes, blitWidth);
+ t->image[0][i].height = (size / texelBytes) / t->image[0][i].width;
+ }
+ else {
+ t->image[0][i].x = curOffset % BLIT_WIDTH_BYTES;
+ t->image[0][i].y = curOffset / BLIT_WIDTH_BYTES;
+ t->image[0][i].width = MIN2(size, BLIT_WIDTH_BYTES);
+ t->image[0][i].height = size / t->image[0][i].width;
+ }
+
+#if 0
+ /* for debugging only and only applicable to non-rectangle targets */
+ assert(size % t->image[0][i].width == 0);
+ assert(t->image[0][i].x == 0
+ || (size < BLIT_WIDTH_BYTES && t->image[0][i].height == 1));
+#endif
+
+ if (0)
+ fprintf(stderr,
+ "level %d: %dx%d x=%d y=%d w=%d h=%d size=%d at %d\n",
+ i, texImage->Width, texImage->Height,
+ t->image[0][i].x, t->image[0][i].y,
+ t->image[0][i].width, t->image[0][i].height, size, curOffset);
+
+ curOffset += size;
+
+ }
+
+ /* Align the total size of texture memory block.
+ */
+ t->base.totalSize = (curOffset + RADEON_OFFSET_MASK) & ~RADEON_OFFSET_MASK;
+
+ /* Hardware state:
+ */
+ t->pp_txfilter &= ~RADEON_MAX_MIP_LEVEL_MASK;
+ t->pp_txfilter |= (numLevels - 1) << RADEON_MAX_MIP_LEVEL_SHIFT;
+
+ t->pp_txformat &= ~(RADEON_TXFORMAT_WIDTH_MASK |
+ RADEON_TXFORMAT_HEIGHT_MASK |
+ RADEON_TXFORMAT_CUBIC_MAP_ENABLE);
+ t->pp_txformat |= ((log2Width << RADEON_TXFORMAT_WIDTH_SHIFT) |
+ (log2Height << RADEON_TXFORMAT_HEIGHT_SHIFT));
+
+ t->pp_txsize = (((tObj->Image[0][t->base.firstLevel]->Width - 1) << 0) |
+ ((tObj->Image[0][t->base.firstLevel]->Height - 1) << 16));
+
+ /* Only need to round to nearest 32 for textures, but the blitter
+ * requires 64-byte aligned pitches, and we may/may not need the
+ * blitter. NPOT only!
+ */
+ if (baseImage->IsCompressed)
+ t->pp_txpitch = (tObj->Image[0][t->base.firstLevel]->Width + 63) & ~(63);
+ else
+ t->pp_txpitch = ((tObj->Image[0][t->base.firstLevel]->Width * texelBytes) + 63) & ~(63);
+ t->pp_txpitch -= 32;
+
+ t->dirty_state = TEX_ALL;
+
+ /* FYI: radeonUploadTexImages( rmesa, t ); used to be called here */
+}
+
+
+
+/* ================================================================
+ * Texture combine functions
+ */
+
+/* GL_ARB_texture_env_combine support
+ */
+
+/* The color tables have combine functions for GL_SRC_COLOR,
+ * GL_ONE_MINUS_SRC_COLOR, GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA.
+ */
+static GLuint radeon_texture_color[][RADEON_MAX_TEXTURE_UNITS] =
+{
+ {
+ RADEON_COLOR_ARG_A_T0_COLOR,
+ RADEON_COLOR_ARG_A_T1_COLOR,
+ RADEON_COLOR_ARG_A_T2_COLOR
+ },
+ {
+ RADEON_COLOR_ARG_A_T0_COLOR | RADEON_COMP_ARG_A,
+ RADEON_COLOR_ARG_A_T1_COLOR | RADEON_COMP_ARG_A,
+ RADEON_COLOR_ARG_A_T2_COLOR | RADEON_COMP_ARG_A
+ },
+ {
+ RADEON_COLOR_ARG_A_T0_ALPHA,
+ RADEON_COLOR_ARG_A_T1_ALPHA,
+ RADEON_COLOR_ARG_A_T2_ALPHA
+ },
+ {
+ RADEON_COLOR_ARG_A_T0_ALPHA | RADEON_COMP_ARG_A,
+ RADEON_COLOR_ARG_A_T1_ALPHA | RADEON_COMP_ARG_A,
+ RADEON_COLOR_ARG_A_T2_ALPHA | RADEON_COMP_ARG_A
+ },
+};
+
+static GLuint radeon_tfactor_color[] =
+{
+ RADEON_COLOR_ARG_A_TFACTOR_COLOR,
+ RADEON_COLOR_ARG_A_TFACTOR_COLOR | RADEON_COMP_ARG_A,
+ RADEON_COLOR_ARG_A_TFACTOR_ALPHA,
+ RADEON_COLOR_ARG_A_TFACTOR_ALPHA | RADEON_COMP_ARG_A
+};
+
+static GLuint radeon_primary_color[] =
+{
+ RADEON_COLOR_ARG_A_DIFFUSE_COLOR,
+ RADEON_COLOR_ARG_A_DIFFUSE_COLOR | RADEON_COMP_ARG_A,
+ RADEON_COLOR_ARG_A_DIFFUSE_ALPHA,
+ RADEON_COLOR_ARG_A_DIFFUSE_ALPHA | RADEON_COMP_ARG_A
+};
+
+static GLuint radeon_previous_color[] =
+{
+ RADEON_COLOR_ARG_A_CURRENT_COLOR,
+ RADEON_COLOR_ARG_A_CURRENT_COLOR | RADEON_COMP_ARG_A,
+ RADEON_COLOR_ARG_A_CURRENT_ALPHA,
+ RADEON_COLOR_ARG_A_CURRENT_ALPHA | RADEON_COMP_ARG_A
+};
+
+/* GL_ZERO table - indices 0-3
+ * GL_ONE table - indices 1-4
+ */
+static GLuint radeon_zero_color[] =
+{
+ RADEON_COLOR_ARG_A_ZERO,
+ RADEON_COLOR_ARG_A_ZERO | RADEON_COMP_ARG_A,
+ RADEON_COLOR_ARG_A_ZERO,
+ RADEON_COLOR_ARG_A_ZERO | RADEON_COMP_ARG_A,
+ RADEON_COLOR_ARG_A_ZERO
+};
+
+
+/* The alpha tables only have GL_SRC_ALPHA and GL_ONE_MINUS_SRC_ALPHA.
+ */
+static GLuint radeon_texture_alpha[][RADEON_MAX_TEXTURE_UNITS] =
+{
+ {
+ RADEON_ALPHA_ARG_A_T0_ALPHA,
+ RADEON_ALPHA_ARG_A_T1_ALPHA,
+ RADEON_ALPHA_ARG_A_T2_ALPHA
+ },
+ {
+ RADEON_ALPHA_ARG_A_T0_ALPHA | RADEON_COMP_ARG_A,
+ RADEON_ALPHA_ARG_A_T1_ALPHA | RADEON_COMP_ARG_A,
+ RADEON_ALPHA_ARG_A_T2_ALPHA | RADEON_COMP_ARG_A
+ },
+};
+
+static GLuint radeon_tfactor_alpha[] =
+{
+ RADEON_ALPHA_ARG_A_TFACTOR_ALPHA,
+ RADEON_ALPHA_ARG_A_TFACTOR_ALPHA | RADEON_COMP_ARG_A
+};
+
+static GLuint radeon_primary_alpha[] =
+{
+ RADEON_ALPHA_ARG_A_DIFFUSE_ALPHA,
+ RADEON_ALPHA_ARG_A_DIFFUSE_ALPHA | RADEON_COMP_ARG_A
+};
+
+static GLuint radeon_previous_alpha[] =
+{
+ RADEON_ALPHA_ARG_A_CURRENT_ALPHA,
+ RADEON_ALPHA_ARG_A_CURRENT_ALPHA | RADEON_COMP_ARG_A
+};
+
+/* GL_ZERO table - indices 0-1
+ * GL_ONE table - indices 1-2
+ */
+static GLuint radeon_zero_alpha[] =
+{
+ RADEON_ALPHA_ARG_A_ZERO,
+ RADEON_ALPHA_ARG_A_ZERO | RADEON_COMP_ARG_A,
+ RADEON_ALPHA_ARG_A_ZERO
+};
+
+
+/* Extract the arg from slot A, shift it into the correct argument slot
+ * and set the corresponding complement bit.
+ */
+#define RADEON_COLOR_ARG( n, arg ) \
+do { \
+ color_combine |= \
+ ((color_arg[n] & RADEON_COLOR_ARG_MASK) \
+ << RADEON_COLOR_ARG_##arg##_SHIFT); \
+ color_combine |= \
+ ((color_arg[n] >> RADEON_COMP_ARG_SHIFT) \
+ << RADEON_COMP_ARG_##arg##_SHIFT); \
+} while (0)
+
+#define RADEON_ALPHA_ARG( n, arg ) \
+do { \
+ alpha_combine |= \
+ ((alpha_arg[n] & RADEON_ALPHA_ARG_MASK) \
+ << RADEON_ALPHA_ARG_##arg##_SHIFT); \
+ alpha_combine |= \
+ ((alpha_arg[n] >> RADEON_COMP_ARG_SHIFT) \
+ << RADEON_COMP_ARG_##arg##_SHIFT); \
+} while (0)
+
+
+/* ================================================================
+ * Texture unit state management
+ */
+
+static GLboolean radeonUpdateTextureEnv( GLcontext *ctx, int unit )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ GLuint color_combine, alpha_combine;
+ const GLuint color_combine0 = RADEON_COLOR_ARG_A_ZERO | RADEON_COLOR_ARG_B_ZERO
+ | RADEON_COLOR_ARG_C_CURRENT_COLOR | RADEON_BLEND_CTL_ADD
+ | RADEON_SCALE_1X | RADEON_CLAMP_TX;
+ const GLuint alpha_combine0 = RADEON_ALPHA_ARG_A_ZERO | RADEON_ALPHA_ARG_B_ZERO
+ | RADEON_ALPHA_ARG_C_CURRENT_ALPHA | RADEON_BLEND_CTL_ADD
+ | RADEON_SCALE_1X | RADEON_CLAMP_TX;
+
+
+ /* texUnit->_Current can be NULL if and only if the texture unit is
+ * not actually enabled.
+ */
+ assert( (texUnit->_ReallyEnabled == 0)
+ || (texUnit->_Current != NULL) );
+
+ if ( RADEON_DEBUG & DEBUG_TEXTURE ) {
+ fprintf( stderr, "%s( %p, %d )\n", __FUNCTION__, (void *)ctx, unit );
+ }
+
+ /* Set the texture environment state. Isn't this nice and clean?
+ * The chip will automagically set the texture alpha to 0xff when
+ * the texture format does not include an alpha component. This
+ * reduces the amount of special-casing we have to do, alpha-only
+ * textures being a notable exception.
+ */
+ /* Don't cache these results.
+ */
+ rmesa->state.texture.unit[unit].format = 0;
+ rmesa->state.texture.unit[unit].envMode = 0;
+
+ if ( !texUnit->_ReallyEnabled ) {
+ color_combine = color_combine0;
+ alpha_combine = alpha_combine0;
+ }
+ else {
+ GLuint color_arg[3], alpha_arg[3];
+ GLuint i;
+ const GLuint numColorArgs = texUnit->_CurrentCombine->_NumArgsRGB;
+ const GLuint numAlphaArgs = texUnit->_CurrentCombine->_NumArgsA;
+ GLuint RGBshift = texUnit->_CurrentCombine->ScaleShiftRGB;
+ GLuint Ashift = texUnit->_CurrentCombine->ScaleShiftA;
+
+
+ /* Step 1:
+ * Extract the color and alpha combine function arguments.
+ */
+ for ( i = 0 ; i < numColorArgs ; i++ ) {
+ const GLint op = texUnit->_CurrentCombine->OperandRGB[i] - GL_SRC_COLOR;
+ const GLuint srcRGBi = texUnit->_CurrentCombine->SourceRGB[i];
+ assert(op >= 0);
+ assert(op <= 3);
+ switch ( srcRGBi ) {
+ case GL_TEXTURE:
+ color_arg[i] = radeon_texture_color[op][unit];
+ break;
+ case GL_CONSTANT:
+ color_arg[i] = radeon_tfactor_color[op];
+ break;
+ case GL_PRIMARY_COLOR:
+ color_arg[i] = radeon_primary_color[op];
+ break;
+ case GL_PREVIOUS:
+ color_arg[i] = radeon_previous_color[op];
+ break;
+ case GL_ZERO:
+ color_arg[i] = radeon_zero_color[op];
+ break;
+ case GL_ONE:
+ color_arg[i] = radeon_zero_color[op+1];
+ break;
+ case GL_TEXTURE0:
+ case GL_TEXTURE1:
+ case GL_TEXTURE2:
+ /* implement ogl 1.4/1.5 core spec here, not specification of
+ * GL_ARB_texture_env_crossbar (which would require disabling blending
+ * instead of undefined results when referencing not enabled texunit) */
+ color_arg[i] = radeon_texture_color[op][srcRGBi - GL_TEXTURE0];
+ break;
+ default:
+ return GL_FALSE;
+ }
+ }
+
+ for ( i = 0 ; i < numAlphaArgs ; i++ ) {
+ const GLint op = texUnit->_CurrentCombine->OperandA[i] - GL_SRC_ALPHA;
+ const GLuint srcAi = texUnit->_CurrentCombine->SourceA[i];
+ assert(op >= 0);
+ assert(op <= 1);
+ switch ( srcAi ) {
+ case GL_TEXTURE:
+ alpha_arg[i] = radeon_texture_alpha[op][unit];
+ break;
+ case GL_CONSTANT:
+ alpha_arg[i] = radeon_tfactor_alpha[op];
+ break;
+ case GL_PRIMARY_COLOR:
+ alpha_arg[i] = radeon_primary_alpha[op];
+ break;
+ case GL_PREVIOUS:
+ alpha_arg[i] = radeon_previous_alpha[op];
+ break;
+ case GL_ZERO:
+ alpha_arg[i] = radeon_zero_alpha[op];
+ break;
+ case GL_ONE:
+ alpha_arg[i] = radeon_zero_alpha[op+1];
+ break;
+ case GL_TEXTURE0:
+ case GL_TEXTURE1:
+ case GL_TEXTURE2:
+ alpha_arg[i] = radeon_texture_alpha[op][srcAi - GL_TEXTURE0];
+ break;
+ default:
+ return GL_FALSE;
+ }
+ }
+
+ /* Step 2:
+ * Build up the color and alpha combine functions.
+ */
+ switch ( texUnit->_CurrentCombine->ModeRGB ) {
+ case GL_REPLACE:
+ color_combine = (RADEON_COLOR_ARG_A_ZERO |
+ RADEON_COLOR_ARG_B_ZERO |
+ RADEON_BLEND_CTL_ADD |
+ RADEON_CLAMP_TX);
+ RADEON_COLOR_ARG( 0, C );
+ break;
+ case GL_MODULATE:
+ color_combine = (RADEON_COLOR_ARG_C_ZERO |
+ RADEON_BLEND_CTL_ADD |
+ RADEON_CLAMP_TX);
+ RADEON_COLOR_ARG( 0, A );
+ RADEON_COLOR_ARG( 1, B );
+ break;
+ case GL_ADD:
+ color_combine = (RADEON_COLOR_ARG_B_ZERO |
+ RADEON_COMP_ARG_B |
+ RADEON_BLEND_CTL_ADD |
+ RADEON_CLAMP_TX);
+ RADEON_COLOR_ARG( 0, A );
+ RADEON_COLOR_ARG( 1, C );
+ break;
+ case GL_ADD_SIGNED:
+ color_combine = (RADEON_COLOR_ARG_B_ZERO |
+ RADEON_COMP_ARG_B |
+ RADEON_BLEND_CTL_ADDSIGNED |
+ RADEON_CLAMP_TX);
+ RADEON_COLOR_ARG( 0, A );
+ RADEON_COLOR_ARG( 1, C );
+ break;
+ case GL_SUBTRACT:
+ color_combine = (RADEON_COLOR_ARG_B_ZERO |
+ RADEON_COMP_ARG_B |
+ RADEON_BLEND_CTL_SUBTRACT |
+ RADEON_CLAMP_TX);
+ RADEON_COLOR_ARG( 0, A );
+ RADEON_COLOR_ARG( 1, C );
+ break;
+ case GL_INTERPOLATE:
+ color_combine = (RADEON_BLEND_CTL_BLEND |
+ RADEON_CLAMP_TX);
+ RADEON_COLOR_ARG( 0, B );
+ RADEON_COLOR_ARG( 1, A );
+ RADEON_COLOR_ARG( 2, C );
+ break;
+
+ case GL_DOT3_RGB_EXT:
+ case GL_DOT3_RGBA_EXT:
+ /* The EXT version of the DOT3 extension does not support the
+ * scale factor, but the ARB version (and the version in OpenGL
+ * 1.3) does.
+ */
+ RGBshift = 0;
+ /* FALLTHROUGH */
+
+ case GL_DOT3_RGB:
+ case GL_DOT3_RGBA:
+ /* The R100 / RV200 only support a 1X multiplier in hardware
+ * w/the ARB version.
+ */
+ if ( RGBshift != (RADEON_SCALE_1X >> RADEON_SCALE_SHIFT) ) {
+ return GL_FALSE;
+ }
+
+ RGBshift += 2;
+ if ( (texUnit->_CurrentCombine->ModeRGB == GL_DOT3_RGBA_EXT)
+ || (texUnit->_CurrentCombine->ModeRGB == GL_DOT3_RGBA) ) {
+ /* is it necessary to set this or will it be ignored anyway? */
+ Ashift = RGBshift;
+ }
+
+ color_combine = (RADEON_COLOR_ARG_C_ZERO |
+ RADEON_BLEND_CTL_DOT3 |
+ RADEON_CLAMP_TX);
+ RADEON_COLOR_ARG( 0, A );
+ RADEON_COLOR_ARG( 1, B );
+ break;
+
+ case GL_MODULATE_ADD_ATI:
+ color_combine = (RADEON_BLEND_CTL_ADD |
+ RADEON_CLAMP_TX);
+ RADEON_COLOR_ARG( 0, A );
+ RADEON_COLOR_ARG( 1, C );
+ RADEON_COLOR_ARG( 2, B );
+ break;
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ color_combine = (RADEON_BLEND_CTL_ADDSIGNED |
+ RADEON_CLAMP_TX);
+ RADEON_COLOR_ARG( 0, A );
+ RADEON_COLOR_ARG( 1, C );
+ RADEON_COLOR_ARG( 2, B );
+ break;
+ case GL_MODULATE_SUBTRACT_ATI:
+ color_combine = (RADEON_BLEND_CTL_SUBTRACT |
+ RADEON_CLAMP_TX);
+ RADEON_COLOR_ARG( 0, A );
+ RADEON_COLOR_ARG( 1, C );
+ RADEON_COLOR_ARG( 2, B );
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+ switch ( texUnit->_CurrentCombine->ModeA ) {
+ case GL_REPLACE:
+ alpha_combine = (RADEON_ALPHA_ARG_A_ZERO |
+ RADEON_ALPHA_ARG_B_ZERO |
+ RADEON_BLEND_CTL_ADD |
+ RADEON_CLAMP_TX);
+ RADEON_ALPHA_ARG( 0, C );
+ break;
+ case GL_MODULATE:
+ alpha_combine = (RADEON_ALPHA_ARG_C_ZERO |
+ RADEON_BLEND_CTL_ADD |
+ RADEON_CLAMP_TX);
+ RADEON_ALPHA_ARG( 0, A );
+ RADEON_ALPHA_ARG( 1, B );
+ break;
+ case GL_ADD:
+ alpha_combine = (RADEON_ALPHA_ARG_B_ZERO |
+ RADEON_COMP_ARG_B |
+ RADEON_BLEND_CTL_ADD |
+ RADEON_CLAMP_TX);
+ RADEON_ALPHA_ARG( 0, A );
+ RADEON_ALPHA_ARG( 1, C );
+ break;
+ case GL_ADD_SIGNED:
+ alpha_combine = (RADEON_ALPHA_ARG_B_ZERO |
+ RADEON_COMP_ARG_B |
+ RADEON_BLEND_CTL_ADDSIGNED |
+ RADEON_CLAMP_TX);
+ RADEON_ALPHA_ARG( 0, A );
+ RADEON_ALPHA_ARG( 1, C );
+ break;
+ case GL_SUBTRACT:
+ alpha_combine = (RADEON_COLOR_ARG_B_ZERO |
+ RADEON_COMP_ARG_B |
+ RADEON_BLEND_CTL_SUBTRACT |
+ RADEON_CLAMP_TX);
+ RADEON_ALPHA_ARG( 0, A );
+ RADEON_ALPHA_ARG( 1, C );
+ break;
+ case GL_INTERPOLATE:
+ alpha_combine = (RADEON_BLEND_CTL_BLEND |
+ RADEON_CLAMP_TX);
+ RADEON_ALPHA_ARG( 0, B );
+ RADEON_ALPHA_ARG( 1, A );
+ RADEON_ALPHA_ARG( 2, C );
+ break;
+
+ case GL_MODULATE_ADD_ATI:
+ alpha_combine = (RADEON_BLEND_CTL_ADD |
+ RADEON_CLAMP_TX);
+ RADEON_ALPHA_ARG( 0, A );
+ RADEON_ALPHA_ARG( 1, C );
+ RADEON_ALPHA_ARG( 2, B );
+ break;
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ alpha_combine = (RADEON_BLEND_CTL_ADDSIGNED |
+ RADEON_CLAMP_TX);
+ RADEON_ALPHA_ARG( 0, A );
+ RADEON_ALPHA_ARG( 1, C );
+ RADEON_ALPHA_ARG( 2, B );
+ break;
+ case GL_MODULATE_SUBTRACT_ATI:
+ alpha_combine = (RADEON_BLEND_CTL_SUBTRACT |
+ RADEON_CLAMP_TX);
+ RADEON_ALPHA_ARG( 0, A );
+ RADEON_ALPHA_ARG( 1, C );
+ RADEON_ALPHA_ARG( 2, B );
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+ if ( (texUnit->_CurrentCombine->ModeRGB == GL_DOT3_RGB_EXT)
+ || (texUnit->_CurrentCombine->ModeRGB == GL_DOT3_RGB) ) {
+ alpha_combine |= RADEON_DOT_ALPHA_DONT_REPLICATE;
+ }
+
+ /* Step 3:
+ * Apply the scale factor.
+ */
+ color_combine |= (RGBshift << RADEON_SCALE_SHIFT);
+ alpha_combine |= (Ashift << RADEON_SCALE_SHIFT);
+
+ /* All done!
+ */
+ }
+
+ if ( rmesa->hw.tex[unit].cmd[TEX_PP_TXCBLEND] != color_combine ||
+ rmesa->hw.tex[unit].cmd[TEX_PP_TXABLEND] != alpha_combine ) {
+ RADEON_STATECHANGE( rmesa, tex[unit] );
+ rmesa->hw.tex[unit].cmd[TEX_PP_TXCBLEND] = color_combine;
+ rmesa->hw.tex[unit].cmd[TEX_PP_TXABLEND] = alpha_combine;
+ }
+
+ return GL_TRUE;
+}
+
+#define TEXOBJ_TXFILTER_MASK (RADEON_MAX_MIP_LEVEL_MASK | \
+ RADEON_MIN_FILTER_MASK | \
+ RADEON_MAG_FILTER_MASK | \
+ RADEON_MAX_ANISO_MASK | \
+ RADEON_YUV_TO_RGB | \
+ RADEON_YUV_TEMPERATURE_MASK | \
+ RADEON_CLAMP_S_MASK | \
+ RADEON_CLAMP_T_MASK | \
+ RADEON_BORDER_MODE_D3D )
+
+#define TEXOBJ_TXFORMAT_MASK (RADEON_TXFORMAT_WIDTH_MASK | \
+ RADEON_TXFORMAT_HEIGHT_MASK | \
+ RADEON_TXFORMAT_FORMAT_MASK | \
+ RADEON_TXFORMAT_F5_WIDTH_MASK | \
+ RADEON_TXFORMAT_F5_HEIGHT_MASK | \
+ RADEON_TXFORMAT_ALPHA_IN_MAP | \
+ RADEON_TXFORMAT_CUBIC_MAP_ENABLE | \
+ RADEON_TXFORMAT_NON_POWER2)
+
+
+static void import_tex_obj_state( radeonContextPtr rmesa,
+ int unit,
+ radeonTexObjPtr texobj )
+{
+ GLuint *cmd = RADEON_DB_STATE( tex[unit] );
+
+ cmd[TEX_PP_TXFILTER] &= ~TEXOBJ_TXFILTER_MASK;
+ cmd[TEX_PP_TXFILTER] |= texobj->pp_txfilter & TEXOBJ_TXFILTER_MASK;
+ cmd[TEX_PP_TXFORMAT] &= ~TEXOBJ_TXFORMAT_MASK;
+ cmd[TEX_PP_TXFORMAT] |= texobj->pp_txformat & TEXOBJ_TXFORMAT_MASK;
+ cmd[TEX_PP_TXOFFSET] = texobj->pp_txoffset;
+ cmd[TEX_PP_BORDER_COLOR] = texobj->pp_border_color;
+ RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.tex[unit] );
+
+ if (texobj->base.tObj->Target == GL_TEXTURE_RECTANGLE_NV) {
+ GLuint *txr_cmd = RADEON_DB_STATE( txr[unit] );
+ txr_cmd[TXR_PP_TEX_SIZE] = texobj->pp_txsize; /* NPOT only! */
+ txr_cmd[TXR_PP_TEX_PITCH] = texobj->pp_txpitch; /* NPOT only! */
+ RADEON_DB_STATECHANGE( rmesa, &rmesa->hw.txr[unit] );
+ }
+
+ texobj->dirty_state &= ~(1<<unit);
+}
+
+
+
+
+static void set_texgen_matrix( radeonContextPtr rmesa,
+ GLuint unit,
+ const GLfloat *s_plane,
+ const GLfloat *t_plane )
+{
+ static const GLfloat scale_identity[4] = { 1,1,1,1 };
+
+ if (!TEST_EQ_4V( s_plane, scale_identity) ||
+ !TEST_EQ_4V( t_plane, scale_identity)) {
+ rmesa->TexGenEnabled |= RADEON_TEXMAT_0_ENABLE<<unit;
+ rmesa->TexGenMatrix[unit].m[0] = s_plane[0];
+ rmesa->TexGenMatrix[unit].m[4] = s_plane[1];
+ rmesa->TexGenMatrix[unit].m[8] = s_plane[2];
+ rmesa->TexGenMatrix[unit].m[12] = s_plane[3];
+
+ rmesa->TexGenMatrix[unit].m[1] = t_plane[0];
+ rmesa->TexGenMatrix[unit].m[5] = t_plane[1];
+ rmesa->TexGenMatrix[unit].m[9] = t_plane[2];
+ rmesa->TexGenMatrix[unit].m[13] = t_plane[3];
+ rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
+ }
+}
+
+/* Ignoring the Q texcoord for now.
+ *
+ * Returns GL_FALSE if fallback required.
+ */
+static GLboolean radeon_validate_texgen( GLcontext *ctx, GLuint unit )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ GLuint inputshift = RADEON_TEXGEN_0_INPUT_SHIFT + unit*4;
+ GLuint tmp = rmesa->TexGenEnabled;
+
+ rmesa->TexGenEnabled &= ~(RADEON_TEXGEN_TEXMAT_0_ENABLE<<unit);
+ rmesa->TexGenEnabled &= ~(RADEON_TEXMAT_0_ENABLE<<unit);
+ rmesa->TexGenEnabled &= ~(RADEON_TEXGEN_INPUT_MASK<<inputshift);
+ rmesa->TexGenNeedNormals[unit] = 0;
+
+ if ((texUnit->TexGenEnabled & (S_BIT|T_BIT)) == 0) {
+ /* Disabled, no fallback:
+ */
+ rmesa->TexGenEnabled |=
+ (RADEON_TEXGEN_INPUT_TEXCOORD_0+unit) << inputshift;
+ return GL_TRUE;
+ }
+ else if (texUnit->TexGenEnabled & Q_BIT) {
+ /* Very easy to do this, in fact would remove a fallback case
+ * elsewhere, but I haven't done it yet... Fallback:
+ */
+ if (RADEON_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "fallback Q_BIT\n");
+ return GL_FALSE;
+ }
+ else if ((texUnit->TexGenEnabled & (S_BIT|T_BIT)) != (S_BIT|T_BIT) ||
+ texUnit->GenModeS != texUnit->GenModeT) {
+ /* Mixed modes, fallback:
+ */
+ if (RADEON_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "fallback mixed texgen\n");
+ return GL_FALSE;
+ }
+ else
+ rmesa->TexGenEnabled |= RADEON_TEXGEN_TEXMAT_0_ENABLE << unit;
+
+ switch (texUnit->GenModeS) {
+ case GL_OBJECT_LINEAR:
+ rmesa->TexGenEnabled |= RADEON_TEXGEN_INPUT_OBJ << inputshift;
+ set_texgen_matrix( rmesa, unit,
+ texUnit->ObjectPlaneS,
+ texUnit->ObjectPlaneT);
+ break;
+
+ case GL_EYE_LINEAR:
+ rmesa->TexGenEnabled |= RADEON_TEXGEN_INPUT_EYE << inputshift;
+ set_texgen_matrix( rmesa, unit,
+ texUnit->EyePlaneS,
+ texUnit->EyePlaneT);
+ break;
+
+ case GL_REFLECTION_MAP_NV:
+ rmesa->TexGenNeedNormals[unit] = GL_TRUE;
+ rmesa->TexGenEnabled |= RADEON_TEXGEN_INPUT_EYE_REFLECT<<inputshift;
+ break;
+
+ case GL_NORMAL_MAP_NV:
+ rmesa->TexGenNeedNormals[unit] = GL_TRUE;
+ rmesa->TexGenEnabled |= RADEON_TEXGEN_INPUT_EYE_NORMAL<<inputshift;
+ break;
+
+ case GL_SPHERE_MAP:
+ default:
+ /* Unsupported mode, fallback:
+ */
+ if (RADEON_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "fallback GL_SPHERE_MAP\n");
+ return GL_FALSE;
+ }
+
+ if (tmp != rmesa->TexGenEnabled) {
+ rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
+ }
+
+ return GL_TRUE;
+}
+
+
+static void disable_tex( GLcontext *ctx, int unit )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if (rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (RADEON_TEX_0_ENABLE<<unit)) {
+ /* Texture unit disabled */
+ if ( rmesa->state.texture.unit[unit].texobj != NULL ) {
+ /* The old texture is no longer bound to this texture unit.
+ * Mark it as such.
+ */
+
+ rmesa->state.texture.unit[unit].texobj->base.bound &= ~(1UL << unit);
+ rmesa->state.texture.unit[unit].texobj = NULL;
+ }
+
+ RADEON_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] &=
+ ~((RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE) << unit);
+
+ RADEON_STATECHANGE( rmesa, tcl );
+ switch (unit) {
+ case 0:
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] &= ~(RADEON_TCL_VTX_ST0 |
+ RADEON_TCL_VTX_Q0);
+ break;
+ case 1:
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] &= ~(RADEON_TCL_VTX_ST1 |
+ RADEON_TCL_VTX_Q1);
+ break;
+ default:
+ break;
+ }
+
+
+ if (rmesa->TclFallback & (RADEON_TCL_FALLBACK_TEXGEN_0<<unit)) {
+ TCL_FALLBACK( ctx, (RADEON_TCL_FALLBACK_TEXGEN_0<<unit), GL_FALSE);
+ rmesa->recheck_texgen[unit] = GL_TRUE;
+ }
+
+
+
+ {
+ GLuint inputshift = RADEON_TEXGEN_0_INPUT_SHIFT + unit*4;
+ GLuint tmp = rmesa->TexGenEnabled;
+
+ rmesa->TexGenEnabled &= ~(RADEON_TEXGEN_TEXMAT_0_ENABLE<<unit);
+ rmesa->TexGenEnabled &= ~(RADEON_TEXMAT_0_ENABLE<<unit);
+ rmesa->TexGenEnabled &= ~(RADEON_TEXGEN_INPUT_MASK<<inputshift);
+ rmesa->TexGenNeedNormals[unit] = 0;
+ rmesa->TexGenEnabled |=
+ (RADEON_TEXGEN_INPUT_TEXCOORD_0+unit) << inputshift;
+
+ if (tmp != rmesa->TexGenEnabled) {
+ rmesa->recheck_texgen[unit] = GL_TRUE;
+ rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
+ }
+ }
+ }
+}
+
+static GLboolean enable_tex_2d( GLcontext *ctx, int unit )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ radeonTexObjPtr t = (radeonTexObjPtr) tObj->DriverData;
+
+ /* Need to load the 2d images associated with this unit.
+ */
+ if (t->pp_txformat & RADEON_TXFORMAT_NON_POWER2) {
+ t->pp_txformat &= ~RADEON_TXFORMAT_NON_POWER2;
+ t->base.dirty_images[0] = ~0;
+ }
+
+ ASSERT(tObj->Target == GL_TEXTURE_2D || tObj->Target == GL_TEXTURE_1D);
+
+ if ( t->base.dirty_images[0] ) {
+ RADEON_FIREVERTICES( rmesa );
+ radeonSetTexImages( rmesa, tObj );
+ radeonUploadTexImages( rmesa, (radeonTexObjPtr) tObj->DriverData, 0 );
+ if ( !t->base.memBlock )
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean enable_tex_rect( GLcontext *ctx, int unit )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ radeonTexObjPtr t = (radeonTexObjPtr) tObj->DriverData;
+
+ if (!(t->pp_txformat & RADEON_TXFORMAT_NON_POWER2)) {
+ t->pp_txformat |= RADEON_TXFORMAT_NON_POWER2;
+ t->base.dirty_images[0] = ~0;
+ }
+
+ ASSERT(tObj->Target == GL_TEXTURE_RECTANGLE_NV);
+
+ if ( t->base.dirty_images[0] ) {
+ RADEON_FIREVERTICES( rmesa );
+ radeonSetTexImages( rmesa, tObj );
+ radeonUploadTexImages( rmesa, (radeonTexObjPtr) tObj->DriverData, 0 );
+ if ( !t->base.memBlock /* && !rmesa->prefer_gart_client_texturing FIXME */ ) {
+ fprintf(stderr, "%s: upload failed\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLboolean update_tex_common( GLcontext *ctx, int unit )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *tObj = texUnit->_Current;
+ radeonTexObjPtr t = (radeonTexObjPtr) tObj->DriverData;
+ GLenum format;
+
+ /* Fallback if there's a texture border */
+ if ( tObj->Image[0][tObj->BaseLevel]->Border > 0 ) {
+ fprintf(stderr, "%s: border\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+
+ /* Update state if this is a different texture object to last
+ * time.
+ */
+ if ( rmesa->state.texture.unit[unit].texobj != t ) {
+ if ( rmesa->state.texture.unit[unit].texobj != NULL ) {
+ /* The old texture is no longer bound to this texture unit.
+ * Mark it as such.
+ */
+
+ rmesa->state.texture.unit[unit].texobj->base.bound &=
+ ~(1UL << unit);
+ }
+
+ rmesa->state.texture.unit[unit].texobj = t;
+ t->base.bound |= (1UL << unit);
+ t->dirty_state |= 1<<unit;
+ driUpdateTextureLRU( (driTextureObject *) t ); /* XXX: should be locked! */
+ }
+
+
+ /* Newly enabled?
+ */
+ if ( !(rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (RADEON_TEX_0_ENABLE<<unit))) {
+ RADEON_STATECHANGE( rmesa, ctx );
+ rmesa->hw.ctx.cmd[CTX_PP_CNTL] |=
+ (RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE) << unit;
+
+ RADEON_STATECHANGE( rmesa, tcl );
+
+ if (unit == 0)
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_ST0;
+ else
+ rmesa->hw.tcl.cmd[TCL_OUTPUT_VTXFMT] |= RADEON_TCL_VTX_ST1;
+
+ rmesa->recheck_texgen[unit] = GL_TRUE;
+ }
+
+ if (t->dirty_state & (1<<unit)) {
+ import_tex_obj_state( rmesa, unit, t );
+ }
+
+ if (rmesa->recheck_texgen[unit]) {
+ GLboolean fallback = !radeon_validate_texgen( ctx, unit );
+ TCL_FALLBACK( ctx, (RADEON_TCL_FALLBACK_TEXGEN_0<<unit), fallback);
+ rmesa->recheck_texgen[unit] = 0;
+ rmesa->NewGLState |= _NEW_TEXTURE_MATRIX;
+ }
+
+ format = tObj->Image[0][tObj->BaseLevel]->Format;
+ if ( rmesa->state.texture.unit[unit].format != format ||
+ rmesa->state.texture.unit[unit].envMode != texUnit->EnvMode ) {
+ rmesa->state.texture.unit[unit].format = format;
+ rmesa->state.texture.unit[unit].envMode = texUnit->EnvMode;
+ if ( ! radeonUpdateTextureEnv( ctx, unit ) ) {
+ return GL_FALSE;
+ }
+ }
+
+ FALLBACK( rmesa, RADEON_FALLBACK_BORDER_MODE, t->border_fallback );
+ return !t->border_fallback;
+}
+
+
+
+static GLboolean radeonUpdateTextureUnit( GLcontext *ctx, int unit )
+{
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+ TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_TEXRECT_0 << unit, 0 );
+
+ if ( texUnit->_ReallyEnabled & (TEXTURE_RECT_BIT) ) {
+ TCL_FALLBACK( ctx, RADEON_TCL_FALLBACK_TEXRECT_0 << unit, 1 );
+
+ return (enable_tex_rect( ctx, unit ) &&
+ update_tex_common( ctx, unit ));
+ }
+ else if ( texUnit->_ReallyEnabled & (TEXTURE_1D_BIT | TEXTURE_2D_BIT) ) {
+ return (enable_tex_2d( ctx, unit ) &&
+ update_tex_common( ctx, unit ));
+ }
+ else if ( texUnit->_ReallyEnabled ) {
+ return GL_FALSE;
+ }
+ else {
+ disable_tex( ctx, unit );
+ return GL_TRUE;
+ }
+}
+
+void radeonUpdateTextureState( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLboolean ok;
+
+ ok = (radeonUpdateTextureUnit( ctx, 0 ) &&
+ radeonUpdateTextureUnit( ctx, 1 ));
+
+ FALLBACK( rmesa, RADEON_FALLBACK_TEXTURE, !ok );
+
+ if (rmesa->TclFallback)
+ radeonChooseVertexState( ctx );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt.c
new file mode 100644
index 000000000..5a4cad8ba
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt.c
@@ -0,0 +1,1093 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt.c,v 1.6 2003/05/06 23:52:08 daenzer Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ Tungsten Graphics 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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+#include "glheader.h"
+#include "imports.h"
+#include "api_noop.h"
+#include "api_arrayelt.h"
+#include "context.h"
+#include "mtypes.h"
+#include "enums.h"
+#include "glapi.h"
+#include "colormac.h"
+#include "light.h"
+#include "state.h"
+#include "vtxfmt.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_array_api.h"
+
+#include "radeon_context.h"
+#include "radeon_state.h"
+#include "radeon_ioctl.h"
+#include "radeon_tex.h"
+#include "radeon_tcl.h"
+#include "radeon_swtcl.h"
+#include "radeon_vtxfmt.h"
+
+#include "dispatch.h"
+
+static void radeonVtxfmtFlushVertices( GLcontext *, GLuint );
+
+static void count_func( const char *name, struct dynfn *l )
+{
+ int i = 0;
+ struct dynfn *f;
+ foreach (f, l) i++;
+ if (i) fprintf(stderr, "%s: %d\n", name, i );
+}
+
+static void count_funcs( radeonContextPtr rmesa )
+{
+ count_func( "Vertex2f", &rmesa->vb.dfn_cache.Vertex2f );
+ count_func( "Vertex2fv", &rmesa->vb.dfn_cache.Vertex2fv );
+ count_func( "Vertex3f", &rmesa->vb.dfn_cache.Vertex3f );
+ count_func( "Vertex3fv", &rmesa->vb.dfn_cache.Vertex3fv );
+ count_func( "Color4ub", &rmesa->vb.dfn_cache.Color4ub );
+ count_func( "Color4ubv", &rmesa->vb.dfn_cache.Color4ubv );
+ count_func( "Color3ub", &rmesa->vb.dfn_cache.Color3ub );
+ count_func( "Color3ubv", &rmesa->vb.dfn_cache.Color3ubv );
+ count_func( "Color4f", &rmesa->vb.dfn_cache.Color4f );
+ count_func( "Color4fv", &rmesa->vb.dfn_cache.Color4fv );
+ count_func( "Color3f", &rmesa->vb.dfn_cache.Color3f );
+ count_func( "Color3fv", &rmesa->vb.dfn_cache.Color3fv );
+ count_func( "SecondaryColor3f", &rmesa->vb.dfn_cache.SecondaryColor3fEXT );
+ count_func( "SecondaryColor3fv", &rmesa->vb.dfn_cache.SecondaryColor3fvEXT );
+ count_func( "SecondaryColor3ub", &rmesa->vb.dfn_cache.SecondaryColor3ubEXT );
+ count_func( "SecondaryColor3ubv", &rmesa->vb.dfn_cache.SecondaryColor3ubvEXT );
+ count_func( "Normal3f", &rmesa->vb.dfn_cache.Normal3f );
+ count_func( "Normal3fv", &rmesa->vb.dfn_cache.Normal3fv );
+ count_func( "TexCoord2f", &rmesa->vb.dfn_cache.TexCoord2f );
+ count_func( "TexCoord2fv", &rmesa->vb.dfn_cache.TexCoord2fv );
+ count_func( "TexCoord1f", &rmesa->vb.dfn_cache.TexCoord1f );
+ count_func( "TexCoord1fv", &rmesa->vb.dfn_cache.TexCoord1fv );
+ count_func( "MultiTexCoord2fARB", &rmesa->vb.dfn_cache.MultiTexCoord2fARB );
+ count_func( "MultiTexCoord2fvARB", &rmesa->vb.dfn_cache.MultiTexCoord2fvARB );
+ count_func( "MultiTexCoord1fARB", &rmesa->vb.dfn_cache.MultiTexCoord1fARB );
+ count_func( "MultiTexCoord1fvARB", &rmesa->vb.dfn_cache.MultiTexCoord1fvARB );
+}
+
+
+void radeon_copy_to_current( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ assert(ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT);
+
+ if (rmesa->vb.vertex_format & RADEON_CP_VC_FRMT_N0) {
+ ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0] = rmesa->vb.normalptr[0];
+ ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1] = rmesa->vb.normalptr[1];
+ ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2] = rmesa->vb.normalptr[2];
+ }
+
+ if (rmesa->vb.vertex_format & RADEON_CP_VC_FRMT_PKCOLOR) {
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0] = UBYTE_TO_FLOAT( rmesa->vb.colorptr->red );
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1] = UBYTE_TO_FLOAT( rmesa->vb.colorptr->green );
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2] = UBYTE_TO_FLOAT( rmesa->vb.colorptr->blue );
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3] = UBYTE_TO_FLOAT( rmesa->vb.colorptr->alpha );
+ }
+
+ if (rmesa->vb.vertex_format & RADEON_CP_VC_FRMT_FPCOLOR) {
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0] = rmesa->vb.floatcolorptr[0];
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1] = rmesa->vb.floatcolorptr[1];
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2] = rmesa->vb.floatcolorptr[2];
+ }
+
+ if (rmesa->vb.vertex_format & RADEON_CP_VC_FRMT_FPALPHA)
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3] = rmesa->vb.floatcolorptr[3];
+
+ if (rmesa->vb.vertex_format & RADEON_CP_VC_FRMT_PKSPEC) {
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0] = UBYTE_TO_FLOAT( rmesa->vb.specptr->red );
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1] = UBYTE_TO_FLOAT( rmesa->vb.specptr->green );
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2] = UBYTE_TO_FLOAT( rmesa->vb.specptr->blue );
+ }
+
+ if (rmesa->vb.vertex_format & RADEON_CP_VC_FRMT_ST0) {
+ ctx->Current.Attrib[VERT_ATTRIB_TEX0][0] = rmesa->vb.texcoordptr[0][0];
+ ctx->Current.Attrib[VERT_ATTRIB_TEX0][1] = rmesa->vb.texcoordptr[0][1];
+ ctx->Current.Attrib[VERT_ATTRIB_TEX0][2] = 0.0F;
+ ctx->Current.Attrib[VERT_ATTRIB_TEX0][3] = 1.0F;
+ }
+
+ if (rmesa->vb.vertex_format & RADEON_CP_VC_FRMT_ST1) {
+ ctx->Current.Attrib[VERT_ATTRIB_TEX1][0] = rmesa->vb.texcoordptr[1][0];
+ ctx->Current.Attrib[VERT_ATTRIB_TEX1][1] = rmesa->vb.texcoordptr[1][1];
+ ctx->Current.Attrib[VERT_ATTRIB_TEX1][2] = 0.0F;
+ ctx->Current.Attrib[VERT_ATTRIB_TEX1][3] = 1.0F;
+ }
+
+ ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT;
+}
+
+static GLboolean discreet_gl_prim[GL_POLYGON+1] = {
+ 1, /* 0 points */
+ 1, /* 1 lines */
+ 0, /* 2 line_strip */
+ 0, /* 3 line_loop */
+ 1, /* 4 tris */
+ 0, /* 5 tri_fan */
+ 0, /* 6 tri_strip */
+ 1, /* 7 quads */
+ 0, /* 8 quadstrip */
+ 0, /* 9 poly */
+};
+
+static void flush_prims( radeonContextPtr rmesa )
+{
+ int i,j;
+ struct radeon_dma_region tmp = rmesa->dma.current;
+
+ tmp.buf->refcount++;
+ tmp.aos_size = rmesa->vb.vertex_size;
+ tmp.aos_stride = rmesa->vb.vertex_size;
+ tmp.aos_start = GET_START(&tmp);
+
+ rmesa->dma.current.ptr = rmesa->dma.current.start +=
+ (rmesa->vb.initial_counter - rmesa->vb.counter) * rmesa->vb.vertex_size * 4;
+
+ rmesa->tcl.vertex_format = rmesa->vb.vertex_format;
+ rmesa->tcl.aos_components[0] = &tmp;
+ rmesa->tcl.nr_aos_components = 1;
+ rmesa->dma.flush = NULL;
+
+ /* Optimize the primitive list:
+ */
+ if (rmesa->vb.nrprims > 1) {
+ for (j = 0, i = 1 ; i < rmesa->vb.nrprims; i++) {
+ int pj = rmesa->vb.primlist[j].prim & 0xf;
+ int pi = rmesa->vb.primlist[i].prim & 0xf;
+
+ if (pj == pi && discreet_gl_prim[pj] &&
+ rmesa->vb.primlist[i].start == rmesa->vb.primlist[j].end) {
+ rmesa->vb.primlist[j].end = rmesa->vb.primlist[i].end;
+ }
+ else {
+ j++;
+ if (j != i) rmesa->vb.primlist[j] = rmesa->vb.primlist[i];
+ }
+ }
+ rmesa->vb.nrprims = j+1;
+ }
+
+ for (i = 0 ; i < rmesa->vb.nrprims; i++) {
+ if (RADEON_DEBUG & DEBUG_PRIMS)
+ fprintf(stderr, "vtxfmt prim %d: %s %d..%d\n", i,
+ _mesa_lookup_enum_by_nr( rmesa->vb.primlist[i].prim &
+ PRIM_MODE_MASK ),
+ rmesa->vb.primlist[i].start,
+ rmesa->vb.primlist[i].end);
+
+ radeonEmitPrimitive( rmesa->glCtx,
+ rmesa->vb.primlist[i].start,
+ rmesa->vb.primlist[i].end,
+ rmesa->vb.primlist[i].prim );
+ }
+
+ rmesa->vb.nrprims = 0;
+ radeonReleaseDmaRegion( rmesa, &tmp, __FUNCTION__ );
+}
+
+
+static void start_prim( radeonContextPtr rmesa, GLuint mode )
+{
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s %d\n", __FUNCTION__, rmesa->vb.initial_counter - rmesa->vb.counter);
+
+ rmesa->vb.primlist[rmesa->vb.nrprims].start = rmesa->vb.initial_counter - rmesa->vb.counter;
+ rmesa->vb.primlist[rmesa->vb.nrprims].prim = mode;
+}
+
+static void note_last_prim( radeonContextPtr rmesa, GLuint flags )
+{
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s %d\n", __FUNCTION__, rmesa->vb.initial_counter - rmesa->vb.counter);
+
+ if (rmesa->vb.prim[0] != GL_POLYGON+1) {
+ rmesa->vb.primlist[rmesa->vb.nrprims].prim |= flags;
+ rmesa->vb.primlist[rmesa->vb.nrprims].end = rmesa->vb.initial_counter - rmesa->vb.counter;
+
+ if (++(rmesa->vb.nrprims) == RADEON_MAX_PRIMS)
+ flush_prims( rmesa );
+ }
+}
+
+
+static void copy_vertex( radeonContextPtr rmesa, GLuint n, GLfloat *dst )
+{
+ GLuint i;
+ GLfloat *src = (GLfloat *)(rmesa->dma.current.address +
+ rmesa->dma.current.ptr +
+ (rmesa->vb.primlist[rmesa->vb.nrprims].start + n) *
+ rmesa->vb.vertex_size * 4);
+
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "copy_vertex %d\n", rmesa->vb.primlist[rmesa->vb.nrprims].start + n);
+
+ for (i = 0 ; i < rmesa->vb.vertex_size; i++) {
+ dst[i] = src[i];
+ }
+}
+
+/* NOTE: This actually reads the copied vertices back from uncached
+ * memory. Could also use the counter/notify mechanism to populate
+ * tmp on the fly as vertices are generated.
+ */
+static GLuint copy_dma_verts( radeonContextPtr rmesa, GLfloat (*tmp)[15] )
+{
+ GLuint ovf, i;
+ GLuint nr = (rmesa->vb.initial_counter - rmesa->vb.counter) - rmesa->vb.primlist[rmesa->vb.nrprims].start;
+
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s %d verts\n", __FUNCTION__, nr);
+
+ switch( rmesa->vb.prim[0] )
+ {
+ case GL_POINTS:
+ return 0;
+ case GL_LINES:
+ ovf = nr&1;
+ for (i = 0 ; i < ovf ; i++)
+ copy_vertex( rmesa, nr-ovf+i, tmp[i] );
+ return i;
+ case GL_TRIANGLES:
+ ovf = nr%3;
+ for (i = 0 ; i < ovf ; i++)
+ copy_vertex( rmesa, nr-ovf+i, tmp[i] );
+ return i;
+ case GL_QUADS:
+ ovf = nr&3;
+ for (i = 0 ; i < ovf ; i++)
+ copy_vertex( rmesa, nr-ovf+i, tmp[i] );
+ return i;
+ case GL_LINE_STRIP:
+ if (nr == 0)
+ return 0;
+ copy_vertex( rmesa, nr-1, tmp[0] );
+ return 1;
+ case GL_LINE_LOOP:
+ case GL_TRIANGLE_FAN:
+ case GL_POLYGON:
+ if (nr == 0)
+ return 0;
+ else if (nr == 1) {
+ copy_vertex( rmesa, 0, tmp[0] );
+ return 1;
+ } else {
+ copy_vertex( rmesa, 0, tmp[0] );
+ copy_vertex( rmesa, nr-1, tmp[1] );
+ return 2;
+ }
+ case GL_TRIANGLE_STRIP:
+ ovf = MIN2(nr, 2);
+ for (i = 0 ; i < ovf ; i++)
+ copy_vertex( rmesa, nr-ovf+i, tmp[i] );
+ return i;
+ case GL_QUAD_STRIP:
+ switch (nr) {
+ case 0: ovf = 0; break;
+ case 1: ovf = 1; break;
+ default: ovf = 2 + (nr&1); break;
+ }
+ for (i = 0 ; i < ovf ; i++)
+ copy_vertex( rmesa, nr-ovf+i, tmp[i] );
+ return i;
+ default:
+ assert(0);
+ return 0;
+ }
+}
+
+static void VFMT_FALLBACK_OUTSIDE_BEGIN_END( const char *caller )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if (RADEON_DEBUG & (DEBUG_VFMT|DEBUG_FALLBACKS))
+ fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
+
+ if (ctx->Driver.NeedFlush)
+ radeonVtxfmtFlushVertices( ctx, ctx->Driver.NeedFlush );
+
+ if (ctx->NewState)
+ _mesa_update_state( ctx ); /* clear state so fell_back sticks */
+
+ _tnl_wakeup_exec( ctx );
+ ctx->Driver.FlushVertices = radeonFlushVertices;
+
+ assert( rmesa->dma.flush == 0 );
+ rmesa->vb.fell_back = GL_TRUE;
+ rmesa->vb.installed = GL_FALSE;
+}
+
+
+static void VFMT_FALLBACK( const char *caller )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat tmp[3][15];
+ GLuint i, prim;
+ GLuint ind = rmesa->vb.vertex_format;
+ GLuint nrverts;
+ GLfloat alpha = 1.0;
+
+ if (RADEON_DEBUG & (DEBUG_FALLBACKS|DEBUG_VFMT))
+ fprintf(stderr, "%s from %s\n", __FUNCTION__, caller);
+
+ if (rmesa->vb.prim[0] == GL_POLYGON+1) {
+ VFMT_FALLBACK_OUTSIDE_BEGIN_END( __FUNCTION__ );
+ return;
+ }
+
+ /* Copy vertices out of dma:
+ */
+ nrverts = copy_dma_verts( rmesa, tmp );
+
+ /* Finish the prim at this point:
+ */
+ note_last_prim( rmesa, 0 );
+ flush_prims( rmesa );
+
+ /* Update ctx->Driver.CurrentExecPrimitive and swap in swtnl.
+ */
+ prim = rmesa->vb.prim[0];
+ ctx->Driver.CurrentExecPrimitive = GL_POLYGON+1;
+ _tnl_wakeup_exec( ctx );
+ ctx->Driver.FlushVertices = radeonFlushVertices;
+
+ assert(rmesa->dma.flush == 0);
+ rmesa->vb.fell_back = GL_TRUE;
+ rmesa->vb.installed = GL_FALSE;
+ CALL_Begin(GET_DISPATCH(), (prim));
+
+ if (rmesa->vb.installed_color_3f_sz == 4)
+ alpha = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3];
+
+ /* Replay saved vertices
+ */
+ for (i = 0 ; i < nrverts; i++) {
+ GLuint offset = 3;
+ if (ind & RADEON_CP_VC_FRMT_N0) {
+ CALL_Normal3fv(GET_DISPATCH(), (&tmp[i][offset]));
+ offset += 3;
+ }
+
+ if (ind & RADEON_CP_VC_FRMT_PKCOLOR) {
+ radeon_color_t *col = (radeon_color_t *)&tmp[i][offset];
+ CALL_Color4ub(GET_DISPATCH(), (col->red, col->green, col->blue, col->alpha));
+ offset++;
+ }
+ else if (ind & RADEON_CP_VC_FRMT_FPALPHA) {
+ CALL_Color4fv(GET_DISPATCH(), (&tmp[i][offset]));
+ offset+=4;
+ }
+ else if (ind & RADEON_CP_VC_FRMT_FPCOLOR) {
+ CALL_Color3fv(GET_DISPATCH(), (&tmp[i][offset]));
+ offset+=3;
+ }
+
+ if (ind & RADEON_CP_VC_FRMT_PKSPEC) {
+ radeon_color_t *spec = (radeon_color_t *)&tmp[i][offset];
+ CALL_SecondaryColor3ubEXT(GET_DISPATCH(), (spec->red, spec->green, spec->blue));
+ offset++;
+ }
+
+ if (ind & RADEON_CP_VC_FRMT_ST0) {
+ CALL_TexCoord2fv(GET_DISPATCH(), (&tmp[i][offset]));
+ offset += 2;
+ }
+
+ if (ind & RADEON_CP_VC_FRMT_ST1) {
+ CALL_MultiTexCoord2fvARB(GET_DISPATCH(), (GL_TEXTURE1_ARB, &tmp[i][offset]));
+ offset += 2;
+ }
+ CALL_Vertex3fv(GET_DISPATCH(), (&tmp[i][0]));
+ }
+
+ /* Replay current vertex
+ */
+ if (ind & RADEON_CP_VC_FRMT_N0)
+ CALL_Normal3fv(GET_DISPATCH(), (rmesa->vb.normalptr));
+
+ if (ind & RADEON_CP_VC_FRMT_PKCOLOR)
+ CALL_Color4ub(GET_DISPATCH(), (rmesa->vb.colorptr->red, rmesa->vb.colorptr->green, rmesa->vb.colorptr->blue, rmesa->vb.colorptr->alpha));
+ else if (ind & RADEON_CP_VC_FRMT_FPALPHA)
+ CALL_Color4fv(GET_DISPATCH(), (rmesa->vb.floatcolorptr));
+ else if (ind & RADEON_CP_VC_FRMT_FPCOLOR) {
+ if (rmesa->vb.installed_color_3f_sz == 4 && alpha != 1.0)
+ CALL_Color4f(GET_DISPATCH(), (rmesa->vb.floatcolorptr[0],
+ rmesa->vb.floatcolorptr[1],
+ rmesa->vb.floatcolorptr[2],
+ alpha));
+ else
+ CALL_Color3fv(GET_DISPATCH(), (rmesa->vb.floatcolorptr));
+ }
+
+ if (ind & RADEON_CP_VC_FRMT_PKSPEC)
+ CALL_SecondaryColor3ubEXT(GET_DISPATCH(), (rmesa->vb.specptr->red, rmesa->vb.specptr->green, rmesa->vb.specptr->blue));
+
+ if (ind & RADEON_CP_VC_FRMT_ST0)
+ CALL_TexCoord2fv(GET_DISPATCH(), (rmesa->vb.texcoordptr[0]));
+
+ if (ind & RADEON_CP_VC_FRMT_ST1)
+ CALL_MultiTexCoord2fvARB(GET_DISPATCH(), (GL_TEXTURE1_ARB, rmesa->vb.texcoordptr[1]));
+}
+
+
+
+static void wrap_buffer( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat tmp[3][15];
+ GLuint i, nrverts;
+
+ if (RADEON_DEBUG & (DEBUG_VFMT|DEBUG_PRIMS))
+ fprintf(stderr, "%s %d\n", __FUNCTION__, rmesa->vb.initial_counter - rmesa->vb.counter);
+
+ /* Don't deal with parity.
+ */
+ if ((((rmesa->vb.initial_counter - rmesa->vb.counter) -
+ rmesa->vb.primlist[rmesa->vb.nrprims].start) & 1)) {
+ rmesa->vb.counter++;
+ rmesa->vb.initial_counter++;
+ return;
+ }
+
+ /* Copy vertices out of dma:
+ */
+ if (rmesa->vb.prim[0] == GL_POLYGON+1)
+ nrverts = 0;
+ else {
+ nrverts = copy_dma_verts( rmesa, tmp );
+
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%d vertices to copy\n", nrverts);
+
+ /* Finish the prim at this point:
+ */
+ note_last_prim( rmesa, 0 );
+ }
+
+ /* Fire any buffered primitives
+ */
+ flush_prims( rmesa );
+
+ /* Get new buffer
+ */
+ radeonRefillCurrentDmaRegion( rmesa );
+
+ /* Reset counter, dmaptr
+ */
+ rmesa->vb.dmaptr = (int *)(rmesa->dma.current.ptr + rmesa->dma.current.address);
+ rmesa->vb.counter = (rmesa->dma.current.end - rmesa->dma.current.ptr) /
+ (rmesa->vb.vertex_size * 4);
+ rmesa->vb.counter--;
+ rmesa->vb.initial_counter = rmesa->vb.counter;
+ rmesa->vb.notify = wrap_buffer;
+
+ rmesa->dma.flush = flush_prims;
+
+ /* Restart wrapped primitive:
+ */
+ if (rmesa->vb.prim[0] != GL_POLYGON+1)
+ start_prim( rmesa, rmesa->vb.prim[0] );
+
+ /* Reemit saved vertices
+ */
+ for (i = 0 ; i < nrverts; i++) {
+ if (RADEON_DEBUG & DEBUG_VERTS) {
+ int j;
+ fprintf(stderr, "re-emit vertex %d to %p\n", i, (void *)rmesa->vb.dmaptr);
+ if (RADEON_DEBUG & DEBUG_VERBOSE)
+ for (j = 0 ; j < rmesa->vb.vertex_size; j++)
+ fprintf(stderr, "\t%08x/%f\n", *(int*)&tmp[i][j], tmp[i][j]);
+ }
+
+ memcpy( rmesa->vb.dmaptr, tmp[i], rmesa->vb.vertex_size * 4 );
+ rmesa->vb.dmaptr += rmesa->vb.vertex_size;
+ rmesa->vb.counter--;
+ }
+}
+
+
+
+static GLboolean check_vtx_fmt( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLuint ind = RADEON_CP_VC_FRMT_Z;
+
+ if (rmesa->TclFallback || rmesa->vb.fell_back || ctx->CompileFlag)
+ return GL_FALSE;
+
+ if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT)
+ ctx->Driver.FlushVertices( ctx, FLUSH_UPDATE_CURRENT );
+
+ /* Make all this event-driven:
+ */
+ if (ctx->Light.Enabled) {
+ ind |= RADEON_CP_VC_FRMT_N0;
+
+ /* TODO: make this data driven: If we receive only ubytes, send
+ * color as ubytes. Also check if converting (with free
+ * checking for overflow) is cheaper than sending floats
+ * directly.
+ */
+ if (ctx->Light.ColorMaterialEnabled) {
+ ind |= (RADEON_CP_VC_FRMT_FPCOLOR |
+ RADEON_CP_VC_FRMT_FPALPHA);
+ }
+ else
+ ind |= RADEON_CP_VC_FRMT_PKCOLOR; /* for alpha? */
+ }
+ else {
+ /* TODO: make this data driven?
+ */
+ ind |= RADEON_CP_VC_FRMT_PKCOLOR;
+
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
+ ind |= RADEON_CP_VC_FRMT_PKSPEC;
+ }
+ }
+
+ if (ctx->Texture.Unit[0]._ReallyEnabled) {
+ if (ctx->Texture.Unit[0].TexGenEnabled) {
+ if (rmesa->TexGenNeedNormals[0]) {
+ ind |= RADEON_CP_VC_FRMT_N0;
+ }
+ } else {
+ if (ctx->Current.Attrib[VERT_ATTRIB_TEX0][2] != 0.0F ||
+ ctx->Current.Attrib[VERT_ATTRIB_TEX0][3] != 1.0) {
+ if (RADEON_DEBUG & (DEBUG_VFMT|DEBUG_FALLBACKS))
+ fprintf(stderr, "%s: rq0\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+ ind |= RADEON_CP_VC_FRMT_ST0;
+ }
+ }
+
+ if (ctx->Texture.Unit[1]._ReallyEnabled) {
+ if (ctx->Texture.Unit[1].TexGenEnabled) {
+ if (rmesa->TexGenNeedNormals[1]) {
+ ind |= RADEON_CP_VC_FRMT_N0;
+ }
+ } else {
+ if (ctx->Current.Attrib[VERT_ATTRIB_TEX1][2] != 0.0F ||
+ ctx->Current.Attrib[VERT_ATTRIB_TEX1][3] != 1.0) {
+ if (RADEON_DEBUG & (DEBUG_VFMT|DEBUG_FALLBACKS))
+ fprintf(stderr, "%s: rq1\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+ ind |= RADEON_CP_VC_FRMT_ST1;
+ }
+ }
+
+ if (RADEON_DEBUG & (DEBUG_VFMT|DEBUG_STATE))
+ fprintf(stderr, "%s: format: 0x%x\n", __FUNCTION__, ind );
+
+ RADEON_NEWPRIM(rmesa);
+ rmesa->vb.vertex_format = ind;
+ rmesa->vb.vertex_size = 3;
+ rmesa->vb.prim = &ctx->Driver.CurrentExecPrimitive;
+
+ rmesa->vb.normalptr = ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
+ rmesa->vb.colorptr = NULL;
+ rmesa->vb.floatcolorptr = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
+ rmesa->vb.specptr = NULL;
+ rmesa->vb.floatspecptr = ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
+ rmesa->vb.texcoordptr[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
+ rmesa->vb.texcoordptr[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX1];
+
+ /* Run through and initialize the vertex components in the order
+ * the hardware understands:
+ */
+ if (ind & RADEON_CP_VC_FRMT_N0) {
+ rmesa->vb.normalptr = &rmesa->vb.vertex[rmesa->vb.vertex_size].f;
+ rmesa->vb.vertex_size += 3;
+ rmesa->vb.normalptr[0] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0];
+ rmesa->vb.normalptr[1] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1];
+ rmesa->vb.normalptr[2] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2];
+ }
+
+ if (ind & RADEON_CP_VC_FRMT_PKCOLOR) {
+ rmesa->vb.colorptr = &rmesa->vb.vertex[rmesa->vb.vertex_size].color;
+ rmesa->vb.vertex_size += 1;
+ UNCLAMPED_FLOAT_TO_CHAN( rmesa->vb.colorptr->red, ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0] );
+ UNCLAMPED_FLOAT_TO_CHAN( rmesa->vb.colorptr->green, ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1] );
+ UNCLAMPED_FLOAT_TO_CHAN( rmesa->vb.colorptr->blue, ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2] );
+ UNCLAMPED_FLOAT_TO_CHAN( rmesa->vb.colorptr->alpha, ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3] );
+ }
+
+ if (ind & RADEON_CP_VC_FRMT_FPCOLOR) {
+ assert(!(ind & RADEON_CP_VC_FRMT_PKCOLOR));
+ rmesa->vb.floatcolorptr = &rmesa->vb.vertex[rmesa->vb.vertex_size].f;
+ rmesa->vb.vertex_size += 3;
+ rmesa->vb.floatcolorptr[0] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0];
+ rmesa->vb.floatcolorptr[1] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1];
+ rmesa->vb.floatcolorptr[2] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2];
+
+ if (ind & RADEON_CP_VC_FRMT_FPALPHA) {
+ rmesa->vb.vertex_size += 1;
+ rmesa->vb.floatcolorptr[3] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3];
+ }
+ }
+
+ if (ind & RADEON_CP_VC_FRMT_PKSPEC) {
+ rmesa->vb.specptr = &rmesa->vb.vertex[rmesa->vb.vertex_size].color;
+ rmesa->vb.vertex_size += 1;
+ UNCLAMPED_FLOAT_TO_CHAN( rmesa->vb.specptr->red, ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0] );
+ UNCLAMPED_FLOAT_TO_CHAN( rmesa->vb.specptr->green, ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1] );
+ UNCLAMPED_FLOAT_TO_CHAN( rmesa->vb.specptr->blue, ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2] );
+ }
+
+ if (ind & RADEON_CP_VC_FRMT_ST0) {
+ rmesa->vb.texcoordptr[0] = &rmesa->vb.vertex[rmesa->vb.vertex_size].f;
+ rmesa->vb.vertex_size += 2;
+ rmesa->vb.texcoordptr[0][0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0][0];
+ rmesa->vb.texcoordptr[0][1] = ctx->Current.Attrib[VERT_ATTRIB_TEX0][1];
+ }
+
+ if (ind & RADEON_CP_VC_FRMT_ST1) {
+ rmesa->vb.texcoordptr[1] = &rmesa->vb.vertex[rmesa->vb.vertex_size].f;
+ rmesa->vb.vertex_size += 2;
+ rmesa->vb.texcoordptr[1][0] = ctx->Current.Attrib[VERT_ATTRIB_TEX1][0];
+ rmesa->vb.texcoordptr[1][1] = ctx->Current.Attrib[VERT_ATTRIB_TEX1][1];
+ }
+
+ if (rmesa->vb.installed_vertex_format != rmesa->vb.vertex_format) {
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "reinstall on vertex_format change\n");
+ _mesa_install_exec_vtxfmt( ctx, &rmesa->vb.vtxfmt );
+ rmesa->vb.installed_vertex_format = rmesa->vb.vertex_format;
+ }
+
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s -- success\n", __FUNCTION__);
+
+ return GL_TRUE;
+}
+
+void radeonVtxfmtInvalidate( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+
+ rmesa->vb.recheck = GL_TRUE;
+ rmesa->vb.fell_back = GL_FALSE;
+}
+
+
+static void radeonVtxfmtValidate( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (ctx->Driver.NeedFlush)
+ ctx->Driver.FlushVertices( ctx, ctx->Driver.NeedFlush );
+
+ rmesa->vb.recheck = GL_FALSE;
+
+ if (check_vtx_fmt( ctx )) {
+ if (!rmesa->vb.installed) {
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "reinstall (new install)\n");
+
+ _mesa_install_exec_vtxfmt( ctx, &rmesa->vb.vtxfmt );
+ ctx->Driver.FlushVertices = radeonVtxfmtFlushVertices;
+ rmesa->vb.installed = GL_TRUE;
+ }
+ else if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s: already installed", __FUNCTION__);
+ }
+ else {
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s: failed\n", __FUNCTION__);
+
+ if (rmesa->vb.installed) {
+ if (rmesa->dma.flush)
+ rmesa->dma.flush( rmesa );
+ _tnl_wakeup_exec( ctx );
+ ctx->Driver.FlushVertices = radeonFlushVertices;
+ rmesa->vb.installed = GL_FALSE;
+ }
+ }
+}
+
+
+
+/* Materials:
+ */
+static void radeon_Materialfv( GLenum face, GLenum pname,
+ const GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (rmesa->vb.prim[0] != GL_POLYGON+1) {
+ VFMT_FALLBACK( __FUNCTION__ );
+ CALL_Materialfv(GET_DISPATCH(), (face, pname, params));
+ return;
+ }
+ _mesa_noop_Materialfv( face, pname, params );
+ radeonUpdateMaterial( ctx );
+}
+
+
+/* Begin/End
+ */
+static void radeon_Begin( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s( %s )\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr( mode ));
+
+ if (mode > GL_POLYGON) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBegin" );
+ return;
+ }
+
+ if (rmesa->vb.prim[0] != GL_POLYGON+1) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glBegin" );
+ return;
+ }
+
+ if (ctx->NewState)
+ _mesa_update_state( ctx );
+
+ if (rmesa->NewGLState)
+ radeonValidateState( ctx );
+
+ if (rmesa->vb.recheck)
+ radeonVtxfmtValidate( ctx );
+
+ if (!rmesa->vb.installed) {
+ CALL_Begin(GET_DISPATCH(), (mode));
+ return;
+ }
+
+
+ if (rmesa->dma.flush && rmesa->vb.counter < 12) {
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s: flush almost-empty buffers\n", __FUNCTION__);
+ flush_prims( rmesa );
+ }
+
+ /* Need to arrange to save vertices here? Or always copy from dma (yuk)?
+ */
+ if (!rmesa->dma.flush) {
+ if (rmesa->dma.current.ptr + 12*rmesa->vb.vertex_size*4 >
+ rmesa->dma.current.end) {
+ RADEON_NEWPRIM( rmesa );
+ radeonRefillCurrentDmaRegion( rmesa );
+ }
+
+ rmesa->vb.dmaptr = (int *)(rmesa->dma.current.address + rmesa->dma.current.ptr);
+ rmesa->vb.counter = (rmesa->dma.current.end - rmesa->dma.current.ptr) /
+ (rmesa->vb.vertex_size * 4);
+ rmesa->vb.counter--;
+ rmesa->vb.initial_counter = rmesa->vb.counter;
+ rmesa->vb.notify = wrap_buffer;
+ rmesa->dma.flush = flush_prims;
+ ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
+ }
+
+
+ rmesa->vb.prim[0] = mode;
+ start_prim( rmesa, mode | PRIM_BEGIN );
+}
+
+
+
+static void radeon_End( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (rmesa->vb.prim[0] == GL_POLYGON+1) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd" );
+ return;
+ }
+
+ note_last_prim( rmesa, PRIM_END );
+ rmesa->vb.prim[0] = GL_POLYGON+1;
+}
+
+
+/* Fallback on difficult entrypoints:
+ */
+#define PRE_LOOPBACK( FUNC ) \
+do { \
+ if (RADEON_DEBUG & DEBUG_VFMT) \
+ fprintf(stderr, "%s\n", __FUNCTION__); \
+ VFMT_FALLBACK( __FUNCTION__ ); \
+} while (0)
+#define TAG(x) radeon_fallback_##x
+#include "vtxfmt_tmp.h"
+
+
+
+static GLboolean radeonNotifyBegin( GLcontext *ctx, GLenum p )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ assert(!rmesa->vb.installed);
+
+ if (ctx->NewState)
+ _mesa_update_state( ctx );
+
+ if (rmesa->NewGLState)
+ radeonValidateState( ctx );
+
+ if (ctx->Driver.NeedFlush)
+ ctx->Driver.FlushVertices( ctx, ctx->Driver.NeedFlush );
+
+ if (rmesa->vb.recheck)
+ radeonVtxfmtValidate( ctx );
+
+ if (!rmesa->vb.installed) {
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s -- failed\n", __FUNCTION__);
+ return GL_FALSE;
+ }
+
+ radeon_Begin( p );
+ return GL_TRUE;
+}
+
+static void radeonVtxfmtFlushVertices( GLcontext *ctx, GLuint flags )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ assert(rmesa->vb.installed);
+
+ if (flags & FLUSH_UPDATE_CURRENT) {
+ radeon_copy_to_current( ctx );
+ if (RADEON_DEBUG & DEBUG_VFMT)
+ fprintf(stderr, "reinstall on update_current\n");
+ _mesa_install_exec_vtxfmt( ctx, &rmesa->vb.vtxfmt );
+ ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT;
+ }
+
+ if (flags & FLUSH_STORED_VERTICES) {
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+ assert (rmesa->dma.flush == 0 ||
+ rmesa->dma.flush == flush_prims);
+ if (rmesa->dma.flush == flush_prims)
+ flush_prims( RADEON_CONTEXT( ctx ) );
+ ctx->Driver.NeedFlush &= ~FLUSH_STORED_VERTICES;
+ }
+}
+
+
+
+/* At this point, don't expect very many versions of each function to
+ * be generated, so not concerned about freeing them?
+ */
+
+
+void radeonVtxfmtInit( GLcontext *ctx, GLboolean useCodegen )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+ GLvertexformat *vfmt = &(rmesa->vb.vtxfmt);
+
+ MEMSET( vfmt, 0, sizeof(GLvertexformat) );
+
+ /* Hook in chooser functions for codegen, etc:
+ */
+ radeonVtxfmtInitChoosers( vfmt );
+
+ /* Handled fully in supported states, but no codegen:
+ */
+ vfmt->Materialfv = radeon_Materialfv;
+ vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */
+ vfmt->Rectf = _mesa_noop_Rectf; /* generic helper */
+ vfmt->Begin = radeon_Begin;
+ vfmt->End = radeon_End;
+
+ /* Fallback for performance reasons: (Fix with cva/elt path here and
+ * dmatmp2.h style primitive-merging)
+ *
+ * These should call NotifyBegin(), as should _tnl_EvalMesh, to allow
+ * a driver-hook.
+ */
+ vfmt->DrawArrays = radeon_fallback_DrawArrays;
+ vfmt->DrawElements = radeon_fallback_DrawElements;
+ vfmt->DrawRangeElements = radeon_fallback_DrawRangeElements;
+
+
+ /* Not active in supported states; just keep ctx->Current uptodate:
+ */
+ vfmt->FogCoordfvEXT = _mesa_noop_FogCoordfvEXT;
+ vfmt->FogCoordfEXT = _mesa_noop_FogCoordfEXT;
+ vfmt->EdgeFlag = _mesa_noop_EdgeFlag;
+ vfmt->EdgeFlagv = _mesa_noop_EdgeFlagv;
+ vfmt->Indexf = _mesa_noop_Indexf;
+ vfmt->Indexfv = _mesa_noop_Indexfv;
+
+
+ /* Active but unsupported -- fallback if we receive these:
+ */
+ vfmt->CallList = radeon_fallback_CallList;
+ vfmt->CallLists = radeon_fallback_CallLists;
+ vfmt->EvalCoord1f = radeon_fallback_EvalCoord1f;
+ vfmt->EvalCoord1fv = radeon_fallback_EvalCoord1fv;
+ vfmt->EvalCoord2f = radeon_fallback_EvalCoord2f;
+ vfmt->EvalCoord2fv = radeon_fallback_EvalCoord2fv;
+ vfmt->EvalMesh1 = radeon_fallback_EvalMesh1;
+ vfmt->EvalMesh2 = radeon_fallback_EvalMesh2;
+ vfmt->EvalPoint1 = radeon_fallback_EvalPoint1;
+ vfmt->EvalPoint2 = radeon_fallback_EvalPoint2;
+ vfmt->TexCoord3f = radeon_fallback_TexCoord3f;
+ vfmt->TexCoord3fv = radeon_fallback_TexCoord3fv;
+ vfmt->TexCoord4f = radeon_fallback_TexCoord4f;
+ vfmt->TexCoord4fv = radeon_fallback_TexCoord4fv;
+ vfmt->MultiTexCoord3fARB = radeon_fallback_MultiTexCoord3fARB;
+ vfmt->MultiTexCoord3fvARB = radeon_fallback_MultiTexCoord3fvARB;
+ vfmt->MultiTexCoord4fARB = radeon_fallback_MultiTexCoord4fARB;
+ vfmt->MultiTexCoord4fvARB = radeon_fallback_MultiTexCoord4fvARB;
+ vfmt->Vertex4f = radeon_fallback_Vertex4f;
+ vfmt->Vertex4fv = radeon_fallback_Vertex4fv;
+ vfmt->VertexAttrib1fNV = radeon_fallback_VertexAttrib1fNV;
+ vfmt->VertexAttrib1fvNV = radeon_fallback_VertexAttrib1fvNV;
+ vfmt->VertexAttrib2fNV = radeon_fallback_VertexAttrib2fNV;
+ vfmt->VertexAttrib2fvNV = radeon_fallback_VertexAttrib2fvNV;
+ vfmt->VertexAttrib3fNV = radeon_fallback_VertexAttrib3fNV;
+ vfmt->VertexAttrib3fvNV = radeon_fallback_VertexAttrib3fvNV;
+ vfmt->VertexAttrib4fNV = radeon_fallback_VertexAttrib4fNV;
+ vfmt->VertexAttrib4fvNV = radeon_fallback_VertexAttrib4fvNV;
+
+ (void)radeon_fallback_vtxfmt;
+
+ TNL_CONTEXT(ctx)->Driver.NotifyBegin = radeonNotifyBegin;
+
+ rmesa->vb.enabled = 1;
+ rmesa->vb.prim = &ctx->Driver.CurrentExecPrimitive;
+ rmesa->vb.primflags = 0;
+
+ make_empty_list( &rmesa->vb.dfn_cache.Vertex2f );
+ make_empty_list( &rmesa->vb.dfn_cache.Vertex2fv );
+ make_empty_list( &rmesa->vb.dfn_cache.Vertex3f );
+ make_empty_list( &rmesa->vb.dfn_cache.Vertex3fv );
+ make_empty_list( &rmesa->vb.dfn_cache.Color4ub );
+ make_empty_list( &rmesa->vb.dfn_cache.Color4ubv );
+ make_empty_list( &rmesa->vb.dfn_cache.Color3ub );
+ make_empty_list( &rmesa->vb.dfn_cache.Color3ubv );
+ make_empty_list( &rmesa->vb.dfn_cache.Color4f );
+ make_empty_list( &rmesa->vb.dfn_cache.Color4fv );
+ make_empty_list( &rmesa->vb.dfn_cache.Color3f );
+ make_empty_list( &rmesa->vb.dfn_cache.Color3fv );
+ make_empty_list( &rmesa->vb.dfn_cache.SecondaryColor3fEXT );
+ make_empty_list( &rmesa->vb.dfn_cache.SecondaryColor3fvEXT );
+ make_empty_list( &rmesa->vb.dfn_cache.SecondaryColor3ubEXT );
+ make_empty_list( &rmesa->vb.dfn_cache.SecondaryColor3ubvEXT );
+ make_empty_list( &rmesa->vb.dfn_cache.Normal3f );
+ make_empty_list( &rmesa->vb.dfn_cache.Normal3fv );
+ make_empty_list( &rmesa->vb.dfn_cache.TexCoord2f );
+ make_empty_list( &rmesa->vb.dfn_cache.TexCoord2fv );
+ make_empty_list( &rmesa->vb.dfn_cache.TexCoord1f );
+ make_empty_list( &rmesa->vb.dfn_cache.TexCoord1fv );
+ make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord2fARB );
+ make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord2fvARB );
+ make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord1fARB );
+ make_empty_list( &rmesa->vb.dfn_cache.MultiTexCoord1fvARB );
+
+ radeonInitCodegen( &rmesa->vb.codegen, useCodegen );
+}
+
+static void free_funcs( struct dynfn *l )
+{
+ struct dynfn *f, *tmp;
+ foreach_s (f, tmp, l) {
+ remove_from_list( f );
+ _mesa_exec_free( f->code );
+ _mesa_free( f );
+ }
+}
+
+
+
+void radeonVtxfmtMakeCurrent( GLcontext *ctx )
+{
+}
+
+
+void radeonVtxfmtDestroy( GLcontext *ctx )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT( ctx );
+
+ count_funcs( rmesa );
+ free_funcs( &rmesa->vb.dfn_cache.Vertex2f );
+ free_funcs( &rmesa->vb.dfn_cache.Vertex2fv );
+ free_funcs( &rmesa->vb.dfn_cache.Vertex3f );
+ free_funcs( &rmesa->vb.dfn_cache.Vertex3fv );
+ free_funcs( &rmesa->vb.dfn_cache.Color4ub );
+ free_funcs( &rmesa->vb.dfn_cache.Color4ubv );
+ free_funcs( &rmesa->vb.dfn_cache.Color3ub );
+ free_funcs( &rmesa->vb.dfn_cache.Color3ubv );
+ free_funcs( &rmesa->vb.dfn_cache.Color4f );
+ free_funcs( &rmesa->vb.dfn_cache.Color4fv );
+ free_funcs( &rmesa->vb.dfn_cache.Color3f );
+ free_funcs( &rmesa->vb.dfn_cache.Color3fv );
+ free_funcs( &rmesa->vb.dfn_cache.SecondaryColor3ubEXT );
+ free_funcs( &rmesa->vb.dfn_cache.SecondaryColor3ubvEXT );
+ free_funcs( &rmesa->vb.dfn_cache.SecondaryColor3fEXT );
+ free_funcs( &rmesa->vb.dfn_cache.SecondaryColor3fvEXT );
+ free_funcs( &rmesa->vb.dfn_cache.Normal3f );
+ free_funcs( &rmesa->vb.dfn_cache.Normal3fv );
+ free_funcs( &rmesa->vb.dfn_cache.TexCoord2f );
+ free_funcs( &rmesa->vb.dfn_cache.TexCoord2fv );
+ free_funcs( &rmesa->vb.dfn_cache.TexCoord1f );
+ free_funcs( &rmesa->vb.dfn_cache.TexCoord1fv );
+ free_funcs( &rmesa->vb.dfn_cache.MultiTexCoord2fARB );
+ free_funcs( &rmesa->vb.dfn_cache.MultiTexCoord2fvARB );
+ free_funcs( &rmesa->vb.dfn_cache.MultiTexCoord1fARB );
+ free_funcs( &rmesa->vb.dfn_cache.MultiTexCoord1fvARB );
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt.h
new file mode 100644
index 000000000..a656e49e4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt.h
@@ -0,0 +1,120 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt.h,v 1.3 2002/12/21 17:02:16 dawes Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ Tungsten Graphics 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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#ifndef __RADEON_VTXFMT_H__
+#define __RADEON_VTXFMT_H__
+
+#include "radeon_context.h"
+
+
+extern void radeonVtxfmtUpdate( GLcontext *ctx );
+extern void radeonVtxfmtInit( GLcontext *ctx, GLboolean useCodegen );
+extern void radeonVtxfmtInvalidate( GLcontext *ctx );
+extern void radeonVtxfmtDestroy( GLcontext *ctx );
+extern void radeonVtxfmtInitChoosers( GLvertexformat *vfmt );
+
+extern void radeonVtxfmtMakeCurrent( GLcontext *ctx );
+extern void radeonVtxfmtUnbindContext( GLcontext *ctx );
+
+extern void radeon_copy_to_current( GLcontext *ctx );
+
+#define DFN( FUNC, CACHE) \
+do { \
+ char *start = (char *)&FUNC; \
+ char *end = (char *)&FUNC##_end; \
+ insert_at_head( &CACHE, dfn ); \
+ dfn->key = key; \
+ dfn->code = _mesa_exec_malloc( end - start ); \
+ _mesa_memcpy(dfn->code, start, end - start); \
+} \
+while ( 0 )
+
+#define FIXUP( CODE, OFFSET, CHECKVAL, NEWVAL ) \
+do { \
+ int *icode = (int *)(CODE+OFFSET); \
+ assert (*icode == CHECKVAL); \
+ *icode = (int)NEWVAL; \
+} while (0)
+
+
+/* Useful for figuring out the offsets:
+ */
+#define FIXUP2( CODE, OFFSET, CHECKVAL, NEWVAL ) \
+do { \
+ while (*(int *)(CODE+OFFSET) != CHECKVAL) OFFSET++; \
+ fprintf(stderr, "%s/%d CVAL %x OFFSET %d VAL %x\n", __FUNCTION__, \
+ __LINE__, CHECKVAL, OFFSET, (int)(NEWVAL)); \
+ *(int *)(CODE+OFFSET) = (int)(NEWVAL); \
+ OFFSET += 4; \
+} while (0)
+
+/*
+ */
+void radeonInitCodegen( struct dfn_generators *gen, GLboolean useCodegen );
+void radeonInitX86Codegen( struct dfn_generators *gen );
+void radeonInitSSECodegen( struct dfn_generators *gen );
+
+
+
+/* Defined in radeon_vtxfmt_x86.c
+ */
+struct dynfn *radeon_makeX86Vertex2f( GLcontext *, int );
+struct dynfn *radeon_makeX86Vertex2fv( GLcontext *, int );
+struct dynfn *radeon_makeX86Vertex3f( GLcontext *, int );
+struct dynfn *radeon_makeX86Vertex3fv( GLcontext *, int );
+struct dynfn *radeon_makeX86Color4ub( GLcontext *, int );
+struct dynfn *radeon_makeX86Color4ubv( GLcontext *, int );
+struct dynfn *radeon_makeX86Color3ub( GLcontext *, int );
+struct dynfn *radeon_makeX86Color3ubv( GLcontext *, int );
+struct dynfn *radeon_makeX86Color4f( GLcontext *, int );
+struct dynfn *radeon_makeX86Color4fv( GLcontext *, int );
+struct dynfn *radeon_makeX86Color3f( GLcontext *, int );
+struct dynfn *radeon_makeX86Color3fv( GLcontext *, int );
+struct dynfn *radeon_makeX86SecondaryColor3ubEXT( GLcontext *, int );
+struct dynfn *radeon_makeX86SecondaryColor3ubvEXT( GLcontext *, int );
+struct dynfn *radeon_makeX86SecondaryColor3fEXT( GLcontext *, int );
+struct dynfn *radeon_makeX86SecondaryColor3fvEXT( GLcontext *, int );
+struct dynfn *radeon_makeX86Normal3f( GLcontext *, int );
+struct dynfn *radeon_makeX86Normal3fv( GLcontext *, int );
+struct dynfn *radeon_makeX86TexCoord2f( GLcontext *, int );
+struct dynfn *radeon_makeX86TexCoord2fv( GLcontext *, int );
+struct dynfn *radeon_makeX86TexCoord1f( GLcontext *, int );
+struct dynfn *radeon_makeX86TexCoord1fv( GLcontext *, int );
+struct dynfn *radeon_makeX86MultiTexCoord2fARB( GLcontext *, int );
+struct dynfn *radeon_makeX86MultiTexCoord2fvARB( GLcontext *, int );
+struct dynfn *radeon_makeX86MultiTexCoord1fARB( GLcontext *, int );
+struct dynfn *radeon_makeX86MultiTexCoord1fvARB( GLcontext *, int );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt_c.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt_c.c
new file mode 100644
index 000000000..342b0b39c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt_c.c
@@ -0,0 +1,922 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt_c.c,v 1.2 2002/12/16 16:18:59 dawes Exp $ */
+/**************************************************************************
+
+Copyright 2002 ATI Technologies Inc., Ontario, Canada, and
+ Tungsten Graphics 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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+#include "glheader.h"
+#include "mtypes.h"
+#include "colormac.h"
+#include "simple_list.h"
+#include "api_noop.h"
+#include "vtxfmt.h"
+
+#include "radeon_vtxfmt.h"
+
+#include "dispatch.h"
+
+/* Fallback versions of all the entrypoints for situations where
+ * codegen isn't available. This is still a lot faster than the
+ * vb/pipeline implementation in Mesa.
+ */
+static void radeon_Vertex3f( GLfloat x, GLfloat y, GLfloat z )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ int i;
+
+ *rmesa->vb.dmaptr++ = *(int *)&x;
+ *rmesa->vb.dmaptr++ = *(int *)&y;
+ *rmesa->vb.dmaptr++ = *(int *)&z;
+
+ for (i = 3; i < rmesa->vb.vertex_size; i++)
+ *rmesa->vb.dmaptr++ = rmesa->vb.vertex[i].i;
+
+ if (--rmesa->vb.counter == 0)
+ rmesa->vb.notify();
+}
+
+
+static void radeon_Vertex3fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ int i;
+
+ *rmesa->vb.dmaptr++ = *(int *)&v[0];
+ *rmesa->vb.dmaptr++ = *(int *)&v[1];
+ *rmesa->vb.dmaptr++ = *(int *)&v[2];
+
+ for (i = 3; i < rmesa->vb.vertex_size; i++)
+ *rmesa->vb.dmaptr++ = rmesa->vb.vertex[i].i;
+
+ if (--rmesa->vb.counter == 0)
+ rmesa->vb.notify();
+}
+
+
+static void radeon_Vertex2f( GLfloat x, GLfloat y )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ int i;
+
+ *rmesa->vb.dmaptr++ = *(int *)&x;
+ *rmesa->vb.dmaptr++ = *(int *)&y;
+ *rmesa->vb.dmaptr++ = 0;
+
+ for (i = 3; i < rmesa->vb.vertex_size; i++)
+ *rmesa->vb.dmaptr++ = *(int *)&rmesa->vb.vertex[i];
+
+ if (--rmesa->vb.counter == 0)
+ rmesa->vb.notify();
+}
+
+
+static void radeon_Vertex2fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ int i;
+
+ *rmesa->vb.dmaptr++ = *(int *)&v[0];
+ *rmesa->vb.dmaptr++ = *(int *)&v[1];
+ *rmesa->vb.dmaptr++ = 0;
+
+ for (i = 3; i < rmesa->vb.vertex_size; i++)
+ *rmesa->vb.dmaptr++ = rmesa->vb.vertex[i].i;
+
+ if (--rmesa->vb.counter == 0)
+ rmesa->vb.notify();
+}
+
+
+#if 0
+/* Color for ubyte (packed) color formats:
+ */
+static void radeon_Color3ub_ub( GLubyte r, GLubyte g, GLubyte b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ radeon_color_t *dest = rmesa->vb.colorptr;
+ dest->red = r;
+ dest->green = g;
+ dest->blue = b;
+ dest->alpha = 0xff;
+}
+
+static void radeon_Color3ubv_ub( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ radeon_color_t *dest = rmesa->vb.colorptr;
+ dest->red = v[0];
+ dest->green = v[1];
+ dest->blue = v[2];
+ dest->alpha = 0xff;
+}
+
+static void radeon_Color4ub_ub( GLubyte r, GLubyte g, GLubyte b, GLubyte a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ radeon_color_t *dest = rmesa->vb.colorptr;
+ dest->red = r;
+ dest->green = g;
+ dest->blue = b;
+ dest->alpha = a;
+}
+
+static void radeon_Color4ubv_ub( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ *(GLuint *)rmesa->vb.colorptr = LE32_TO_CPU(*(GLuint *)v);
+}
+#endif /* 0 */
+
+static void radeon_Color3f_ub( GLfloat r, GLfloat g, GLfloat b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ radeon_color_t *dest = rmesa->vb.colorptr;
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->red, r );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->green, g );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->blue, b );
+ dest->alpha = 255;
+}
+
+static void radeon_Color3fv_ub( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ radeon_color_t *dest = rmesa->vb.colorptr;
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->red, v[0] );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->green, v[1] );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->blue, v[2] );
+ dest->alpha = 255;
+}
+
+static void radeon_Color4f_ub( GLfloat r, GLfloat g, GLfloat b, GLfloat a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ radeon_color_t *dest = rmesa->vb.colorptr;
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->red, r );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->green, g );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->blue, b );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->alpha, a );
+}
+
+static void radeon_Color4fv_ub( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ radeon_color_t *dest = rmesa->vb.colorptr;
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->red, v[0] );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->green, v[1] );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->blue, v[2] );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->alpha, v[3] );
+}
+
+
+/* Color for float color+alpha formats:
+ */
+#if 0
+static void radeon_Color3ub_4f( GLubyte r, GLubyte g, GLubyte b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = UBYTE_TO_FLOAT(r);
+ dest[1] = UBYTE_TO_FLOAT(g);
+ dest[2] = UBYTE_TO_FLOAT(b);
+ dest[3] = 1.0;
+}
+
+static void radeon_Color3ubv_4f( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = UBYTE_TO_FLOAT(v[0]);
+ dest[1] = UBYTE_TO_FLOAT(v[1]);
+ dest[2] = UBYTE_TO_FLOAT(v[2]);
+ dest[3] = 1.0;
+}
+
+static void radeon_Color4ub_4f( GLubyte r, GLubyte g, GLubyte b, GLubyte a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = UBYTE_TO_FLOAT(r);
+ dest[1] = UBYTE_TO_FLOAT(g);
+ dest[2] = UBYTE_TO_FLOAT(b);
+ dest[3] = UBYTE_TO_FLOAT(a);
+}
+
+static void radeon_Color4ubv_4f( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = UBYTE_TO_FLOAT(v[0]);
+ dest[1] = UBYTE_TO_FLOAT(v[1]);
+ dest[2] = UBYTE_TO_FLOAT(v[2]);
+ dest[3] = UBYTE_TO_FLOAT(v[3]);
+}
+#endif /* 0 */
+
+
+static void radeon_Color3f_4f( GLfloat r, GLfloat g, GLfloat b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = r;
+ dest[1] = g;
+ dest[2] = b;
+ dest[3] = 1.0;
+}
+
+static void radeon_Color3fv_4f( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = v[2];
+ dest[3] = 1.0;
+}
+
+static void radeon_Color4f_4f( GLfloat r, GLfloat g, GLfloat b, GLfloat a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = r;
+ dest[1] = g;
+ dest[2] = b;
+ dest[3] = a;
+}
+
+static void radeon_Color4fv_4f( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = v[2];
+ dest[3] = v[3];
+}
+
+
+/* Color for float color formats:
+ */
+#if 0
+static void radeon_Color3ub_3f( GLubyte r, GLubyte g, GLubyte b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = UBYTE_TO_FLOAT(r);
+ dest[1] = UBYTE_TO_FLOAT(g);
+ dest[2] = UBYTE_TO_FLOAT(b);
+}
+
+static void radeon_Color3ubv_3f( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = UBYTE_TO_FLOAT(v[0]);
+ dest[1] = UBYTE_TO_FLOAT(v[1]);
+ dest[2] = UBYTE_TO_FLOAT(v[2]);
+}
+
+static void radeon_Color4ub_3f( GLubyte r, GLubyte g, GLubyte b, GLubyte a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = UBYTE_TO_FLOAT(r);
+ dest[1] = UBYTE_TO_FLOAT(g);
+ dest[2] = UBYTE_TO_FLOAT(b);
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3] = UBYTE_TO_FLOAT(a);
+}
+
+static void radeon_Color4ubv_3f( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = UBYTE_TO_FLOAT(v[0]);
+ dest[1] = UBYTE_TO_FLOAT(v[1]);
+ dest[2] = UBYTE_TO_FLOAT(v[2]);
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3] = UBYTE_TO_FLOAT(v[3]);
+}
+#endif /* 0 */
+
+
+static void radeon_Color3f_3f( GLfloat r, GLfloat g, GLfloat b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = r;
+ dest[1] = g;
+ dest[2] = b;
+}
+
+static void radeon_Color3fv_3f( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = v[2];
+}
+
+static void radeon_Color4f_3f( GLfloat r, GLfloat g, GLfloat b, GLfloat a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = r;
+ dest[1] = g;
+ dest[2] = b;
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3] = a;
+}
+
+static void radeon_Color4fv_3f( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatcolorptr;
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = v[2];
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3] = v[3];
+}
+
+
+/* Secondary Color:
+ */
+#if 0
+static void radeon_SecondaryColor3ubEXT_ub( GLubyte r, GLubyte g, GLubyte b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ radeon_color_t *dest = rmesa->vb.specptr;
+ dest->red = r;
+ dest->green = g;
+ dest->blue = b;
+ dest->alpha = 0xff;
+}
+
+static void radeon_SecondaryColor3ubvEXT_ub( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ radeon_color_t *dest = rmesa->vb.specptr;
+ dest->red = v[0];
+ dest->green = v[1];
+ dest->blue = v[2];
+ dest->alpha = 0xff;
+}
+#endif /* 0 */
+
+static void radeon_SecondaryColor3fEXT_ub( GLfloat r, GLfloat g, GLfloat b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ radeon_color_t *dest = rmesa->vb.specptr;
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->red, r );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->green, g );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->blue, b );
+ dest->alpha = 255;
+}
+
+static void radeon_SecondaryColor3fvEXT_ub( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ radeon_color_t *dest = rmesa->vb.specptr;
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->red, v[0] );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->green, v[1] );
+ UNCLAMPED_FLOAT_TO_UBYTE( dest->blue, v[2] );
+ dest->alpha = 255;
+}
+
+#if 0
+static void radeon_SecondaryColor3ubEXT_3f( GLubyte r, GLubyte g, GLubyte b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatspecptr;
+ dest[0] = UBYTE_TO_FLOAT(r);
+ dest[1] = UBYTE_TO_FLOAT(g);
+ dest[2] = UBYTE_TO_FLOAT(b);
+ dest[3] = 1.0;
+}
+
+static void radeon_SecondaryColor3ubvEXT_3f( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatspecptr;
+ dest[0] = UBYTE_TO_FLOAT(v[0]);
+ dest[1] = UBYTE_TO_FLOAT(v[1]);
+ dest[2] = UBYTE_TO_FLOAT(v[2]);
+ dest[3] = 1.0;
+}
+#endif /* 0 */
+
+static void radeon_SecondaryColor3fEXT_3f( GLfloat r, GLfloat g, GLfloat b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatspecptr;
+ dest[0] = r;
+ dest[1] = g;
+ dest[2] = b;
+ dest[3] = 1.0;
+}
+
+static void radeon_SecondaryColor3fvEXT_3f( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.floatspecptr;
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = v[2];
+ dest[3] = 1.0;
+}
+
+
+/* Normal
+ */
+static void radeon_Normal3f( GLfloat n0, GLfloat n1, GLfloat n2 )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.normalptr;
+ dest[0] = n0;
+ dest[1] = n1;
+ dest[2] = n2;
+}
+
+static void radeon_Normal3fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.normalptr;
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = v[2];
+}
+
+
+/* TexCoord
+ */
+static void radeon_TexCoord1f( GLfloat s )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.texcoordptr[0];
+ dest[0] = s;
+ dest[1] = 0;
+}
+
+static void radeon_TexCoord1fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.texcoordptr[0];
+ dest[0] = v[0];
+ dest[1] = 0;
+}
+
+static void radeon_TexCoord2f( GLfloat s, GLfloat t )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.texcoordptr[0];
+ dest[0] = s;
+ dest[1] = t;
+}
+
+static void radeon_TexCoord2fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.texcoordptr[0];
+ dest[0] = v[0];
+ dest[1] = v[1];
+}
+
+
+/* MultiTexcoord
+ *
+ * Technically speaking, these functions should subtract GL_TEXTURE0 from
+ * \c target before masking and using it. The value of GL_TEXTURE0 is 0x84C0,
+ * which has the low-order 5 bits 0. For all possible valid values of
+ * \c target. Subtracting GL_TEXTURE0 has the net effect of masking \c target
+ * with 0x1F. Masking with 0x1F and then masking with 0x01 is redundant, so
+ * the subtraction has been omitted.
+ */
+
+static void radeon_MultiTexCoord1fARB( GLenum target, GLfloat s )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.texcoordptr[target & 1];
+ dest[0] = s;
+ dest[1] = 0;
+}
+
+static void radeon_MultiTexCoord1fvARB( GLenum target, const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.texcoordptr[target & 1];
+ dest[0] = v[0];
+ dest[1] = 0;
+}
+
+static void radeon_MultiTexCoord2fARB( GLenum target, GLfloat s, GLfloat t )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.texcoordptr[target & 1];
+ dest[0] = s;
+ dest[1] = t;
+}
+
+static void radeon_MultiTexCoord2fvARB( GLenum target, const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ GLfloat *dest = rmesa->vb.texcoordptr[target & 1];
+ dest[0] = v[0];
+ dest[1] = v[1];
+}
+
+static struct dynfn *lookup( struct dynfn *l, int key )
+{
+ struct dynfn *f;
+
+ foreach( f, l ) {
+ if (f->key == key)
+ return f;
+ }
+
+ return NULL;
+}
+
+/* Can't use the loopback template for this:
+ */
+
+#define CHOOSE(FN, FNTYPE, MASK, ACTIVE, ARGS1, ARGS2 ) \
+static void choose_##FN ARGS1 \
+{ \
+ GET_CURRENT_CONTEXT(ctx); \
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx); \
+ int key = rmesa->vb.vertex_format & (MASK|ACTIVE); \
+ struct dynfn *dfn; \
+ \
+ dfn = lookup( &rmesa->vb.dfn_cache.FN, key ); \
+ if (dfn == 0) \
+ dfn = rmesa->vb.codegen.FN( ctx, key ); \
+ else if (RADEON_DEBUG & DEBUG_CODEGEN) \
+ fprintf(stderr, "%s -- cached codegen\n", __FUNCTION__ ); \
+ \
+ if (dfn) \
+ SET_ ## FN (ctx->Exec, (FNTYPE)(dfn->code)); \
+ else { \
+ if (RADEON_DEBUG & DEBUG_CODEGEN) \
+ fprintf(stderr, "%s -- generic version\n", __FUNCTION__ ); \
+ SET_ ## FN (ctx->Exec, radeon_##FN); \
+ } \
+ \
+ ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; \
+ CALL_ ## FN (ctx->Exec, ARGS2); \
+}
+
+
+
+/* For the _3f case, only allow one color function to be hooked in at
+ * a time. Eventually, use a similar mechanism to allow selecting the
+ * color component of the vertex format based on client behaviour.
+ *
+ * Note: Perform these actions even if there is a codegen or cached
+ * codegen version of the chosen function.
+ */
+#define CHOOSE_COLOR(FN, FNTYPE, NR, MASK, ACTIVE, ARGS1, ARGS2 ) \
+static void choose_##FN ARGS1 \
+{ \
+ GET_CURRENT_CONTEXT(ctx); \
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx); \
+ int key = rmesa->vb.vertex_format & (MASK|ACTIVE); \
+ struct dynfn *dfn; \
+ \
+ if (rmesa->vb.vertex_format & ACTIVE_PKCOLOR) { \
+ SET_ ## FN (ctx->Exec, radeon_##FN##_ub); \
+ } \
+ else if ((rmesa->vb.vertex_format & \
+ (ACTIVE_FPCOLOR|ACTIVE_FPALPHA)) == ACTIVE_FPCOLOR) { \
+ \
+ if (rmesa->vb.installed_color_3f_sz != NR) { \
+ rmesa->vb.installed_color_3f_sz = NR; \
+ if (NR == 3) ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3] = 1.0; \
+ if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) { \
+ radeon_copy_to_current( ctx ); \
+ _mesa_install_exec_vtxfmt( ctx, &rmesa->vb.vtxfmt ); \
+ CALL_ ## FN (ctx->Exec, ARGS2); \
+ return; \
+ } \
+ } \
+ \
+ SET_ ## FN (ctx->Exec, radeon_##FN##_3f); \
+ } \
+ else { \
+ SET_ ## FN (ctx->Exec, radeon_##FN##_4f); \
+ } \
+ \
+ \
+ dfn = lookup( &rmesa->vb.dfn_cache.FN, key ); \
+ if (!dfn) dfn = rmesa->vb.codegen.FN( ctx, key ); \
+ \
+ if (dfn) { \
+ if (RADEON_DEBUG & DEBUG_CODEGEN) \
+ fprintf(stderr, "%s -- codegen version\n", __FUNCTION__ ); \
+ SET_ ## FN (ctx->Exec, (FNTYPE)dfn->code); \
+ } \
+ else if (RADEON_DEBUG & DEBUG_CODEGEN) \
+ fprintf(stderr, "%s -- 'c' version\n", __FUNCTION__ ); \
+ \
+ ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; \
+ CALL_ ## FN (ctx->Exec, ARGS2); \
+}
+
+
+
+/* Right now there are both _ub and _3f versions of the secondary color
+ * functions. Currently, we only set-up the hardware to use the _ub versions.
+ * The _3f versions are needed for the cases where secondary color isn't used
+ * in the vertex format, but it still needs to be stored in the context
+ * state vector.
+ */
+#define CHOOSE_SECONDARY_COLOR(FN, FNTYPE, MASK, ACTIVE, ARGS1, ARGS2 ) \
+static void choose_##FN ARGS1 \
+{ \
+ GET_CURRENT_CONTEXT(ctx); \
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx); \
+ int key = rmesa->vb.vertex_format & (MASK|ACTIVE); \
+ struct dynfn *dfn = lookup( &rmesa->vb.dfn_cache.FN, key ); \
+ \
+ if (dfn == 0) \
+ dfn = rmesa->vb.codegen.FN( ctx, key ); \
+ else if (RADEON_DEBUG & DEBUG_CODEGEN) \
+ fprintf(stderr, "%s -- cached version\n", __FUNCTION__ ); \
+ \
+ if (dfn) \
+ SET_ ## FN (ctx->Exec, (FNTYPE)(dfn->code)); \
+ else { \
+ if (RADEON_DEBUG & DEBUG_CODEGEN) \
+ fprintf(stderr, "%s -- generic version\n", __FUNCTION__ ); \
+ SET_ ## FN (ctx->Exec, ((rmesa->vb.vertex_format & ACTIVE_PKSPEC) != 0) \
+ ? radeon_##FN##_ub : radeon_##FN##_3f); \
+ } \
+ \
+ ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT; \
+ CALL_ ## FN (ctx->Exec, ARGS2); \
+}
+
+
+
+
+
+/* Shorthands
+ */
+#define ACTIVE_XYZW (RADEON_CP_VC_FRMT_W0|RADEON_CP_VC_FRMT_Z)
+#define ACTIVE_NORM RADEON_CP_VC_FRMT_N0
+
+#define ACTIVE_PKCOLOR RADEON_CP_VC_FRMT_PKCOLOR
+#define ACTIVE_FPCOLOR RADEON_CP_VC_FRMT_FPCOLOR
+#define ACTIVE_FPALPHA RADEON_CP_VC_FRMT_FPALPHA
+#define ACTIVE_COLOR (ACTIVE_FPCOLOR|ACTIVE_PKCOLOR)
+
+#define ACTIVE_PKSPEC RADEON_CP_VC_FRMT_PKSPEC
+#define ACTIVE_FPSPEC RADEON_CP_VC_FRMT_FPSPEC
+#define ACTIVE_SPEC (ACTIVE_FPSPEC|ACTIVE_PKSPEC)
+
+#define ACTIVE_ST0 RADEON_CP_VC_FRMT_ST0
+#define ACTIVE_ST1 RADEON_CP_VC_FRMT_ST1
+#define ACTIVE_ST_ALL (RADEON_CP_VC_FRMT_ST1|RADEON_CP_VC_FRMT_ST0)
+
+/* Each codegen function should be able to be fully specified by a
+ * subsetted version of rmesa->vb.vertex_format.
+ */
+#define MASK_NORM (ACTIVE_XYZW)
+#define MASK_COLOR (MASK_NORM|ACTIVE_NORM)
+#define MASK_SPEC (MASK_COLOR|ACTIVE_COLOR)
+#define MASK_ST0 (MASK_SPEC|ACTIVE_SPEC)
+#define MASK_ST1 (MASK_ST0|ACTIVE_ST0)
+#define MASK_ST_ALL (MASK_ST1|ACTIVE_ST1)
+#define MASK_VERTEX (MASK_ST_ALL|ACTIVE_FPALPHA)
+
+
+typedef void (*p4f)( GLfloat, GLfloat, GLfloat, GLfloat );
+typedef void (*p3f)( GLfloat, GLfloat, GLfloat );
+typedef void (*p2f)( GLfloat, GLfloat );
+typedef void (*p1f)( GLfloat );
+typedef void (*pe2f)( GLenum, GLfloat, GLfloat );
+typedef void (*pe1f)( GLenum, GLfloat );
+typedef void (*p4ub)( GLubyte, GLubyte, GLubyte, GLubyte );
+typedef void (*p3ub)( GLubyte, GLubyte, GLubyte );
+typedef void (*pfv)( const GLfloat * );
+typedef void (*pefv)( GLenum, const GLfloat * );
+typedef void (*pubv)( const GLubyte * );
+
+
+CHOOSE(Normal3f, p3f, MASK_NORM, ACTIVE_NORM,
+ (GLfloat a,GLfloat b,GLfloat c), (a,b,c))
+CHOOSE(Normal3fv, pfv, MASK_NORM, ACTIVE_NORM,
+ (const GLfloat *v), (v))
+
+#if 0
+CHOOSE_COLOR(Color4ub, p4ub, 4, MASK_COLOR, ACTIVE_COLOR,
+ (GLubyte a,GLubyte b, GLubyte c, GLubyte d), (a,b,c,d))
+CHOOSE_COLOR(Color4ubv, pubv, 4, MASK_COLOR, ACTIVE_COLOR,
+ (const GLubyte *v), (v))
+CHOOSE_COLOR(Color3ub, p3ub, 3, MASK_COLOR, ACTIVE_COLOR,
+ (GLubyte a,GLubyte b, GLubyte c), (a,b,c))
+CHOOSE_COLOR(Color3ubv, pubv, 3, MASK_COLOR, ACTIVE_COLOR,
+ (const GLubyte *v), (v))
+#endif
+
+CHOOSE_COLOR(Color4f, p4f, 4, MASK_COLOR, ACTIVE_COLOR,
+ (GLfloat a,GLfloat b, GLfloat c, GLfloat d), (a,b,c,d))
+CHOOSE_COLOR(Color4fv, pfv, 4, MASK_COLOR, ACTIVE_COLOR,
+ (const GLfloat *v), (v))
+CHOOSE_COLOR(Color3f, p3f, 3, MASK_COLOR, ACTIVE_COLOR,
+ (GLfloat a,GLfloat b, GLfloat c), (a,b,c))
+CHOOSE_COLOR(Color3fv, pfv, 3, MASK_COLOR, ACTIVE_COLOR,
+ (const GLfloat *v), (v))
+
+
+#if 0
+CHOOSE_SECONDARY_COLOR(SecondaryColor3ubEXT, p3ub, MASK_SPEC, ACTIVE_SPEC,
+ (GLubyte a,GLubyte b, GLubyte c), (a,b,c))
+CHOOSE_SECONDARY_COLOR(SecondaryColor3ubvEXT, pubv, MASK_SPEC, ACTIVE_SPEC,
+ (const GLubyte *v), (v))
+#endif
+CHOOSE_SECONDARY_COLOR(SecondaryColor3fEXT, p3f, MASK_SPEC, ACTIVE_SPEC,
+ (GLfloat a,GLfloat b, GLfloat c), (a,b,c))
+CHOOSE_SECONDARY_COLOR(SecondaryColor3fvEXT, pfv, MASK_SPEC, ACTIVE_SPEC,
+ (const GLfloat *v), (v))
+
+CHOOSE(TexCoord2f, p2f, MASK_ST0, ACTIVE_ST0,
+ (GLfloat a,GLfloat b), (a,b))
+CHOOSE(TexCoord2fv, pfv, MASK_ST0, ACTIVE_ST0,
+ (const GLfloat *v), (v))
+CHOOSE(TexCoord1f, p1f, MASK_ST0, ACTIVE_ST0,
+ (GLfloat a), (a))
+CHOOSE(TexCoord1fv, pfv, MASK_ST0, ACTIVE_ST0,
+ (const GLfloat *v), (v))
+
+CHOOSE(MultiTexCoord2fARB, pe2f, MASK_ST_ALL, ACTIVE_ST_ALL,
+ (GLenum u,GLfloat a,GLfloat b), (u,a,b))
+CHOOSE(MultiTexCoord2fvARB, pefv, MASK_ST_ALL, ACTIVE_ST_ALL,
+ (GLenum u,const GLfloat *v), (u,v))
+CHOOSE(MultiTexCoord1fARB, pe1f, MASK_ST_ALL, ACTIVE_ST_ALL,
+ (GLenum u,GLfloat a), (u,a))
+CHOOSE(MultiTexCoord1fvARB, pefv, MASK_ST_ALL, ACTIVE_ST_ALL,
+ (GLenum u,const GLfloat *v), (u,v))
+
+CHOOSE(Vertex3f, p3f, MASK_VERTEX, MASK_VERTEX,
+ (GLfloat a,GLfloat b,GLfloat c), (a,b,c))
+CHOOSE(Vertex3fv, pfv, MASK_VERTEX, MASK_VERTEX,
+ (const GLfloat *v), (v))
+CHOOSE(Vertex2f, p2f, MASK_VERTEX, MASK_VERTEX,
+ (GLfloat a,GLfloat b), (a,b))
+CHOOSE(Vertex2fv, pfv, MASK_VERTEX, MASK_VERTEX,
+ (const GLfloat *v), (v))
+
+
+
+
+
+void radeonVtxfmtInitChoosers( GLvertexformat *vfmt )
+{
+ vfmt->Color3f = choose_Color3f;
+ vfmt->Color3fv = choose_Color3fv;
+ vfmt->Color4f = choose_Color4f;
+ vfmt->Color4fv = choose_Color4fv;
+ vfmt->SecondaryColor3fEXT = choose_SecondaryColor3fEXT;
+ vfmt->SecondaryColor3fvEXT = choose_SecondaryColor3fvEXT;
+ vfmt->MultiTexCoord1fARB = choose_MultiTexCoord1fARB;
+ vfmt->MultiTexCoord1fvARB = choose_MultiTexCoord1fvARB;
+ vfmt->MultiTexCoord2fARB = choose_MultiTexCoord2fARB;
+ vfmt->MultiTexCoord2fvARB = choose_MultiTexCoord2fvARB;
+ vfmt->Normal3f = choose_Normal3f;
+ vfmt->Normal3fv = choose_Normal3fv;
+ vfmt->TexCoord1f = choose_TexCoord1f;
+ vfmt->TexCoord1fv = choose_TexCoord1fv;
+ vfmt->TexCoord2f = choose_TexCoord2f;
+ vfmt->TexCoord2fv = choose_TexCoord2fv;
+ vfmt->Vertex2f = choose_Vertex2f;
+ vfmt->Vertex2fv = choose_Vertex2fv;
+ vfmt->Vertex3f = choose_Vertex3f;
+ vfmt->Vertex3fv = choose_Vertex3fv;
+
+#if 0
+ vfmt->Color3ub = choose_Color3ub;
+ vfmt->Color3ubv = choose_Color3ubv;
+ vfmt->Color4ub = choose_Color4ub;
+ vfmt->Color4ubv = choose_Color4ubv;
+ vfmt->SecondaryColor3ubEXT = choose_SecondaryColor3ubEXT;
+ vfmt->SecondaryColor3ubvEXT = choose_SecondaryColor3ubvEXT;
+#endif
+}
+
+
+static struct dynfn *codegen_noop( GLcontext *ctx, int key )
+{
+ (void) ctx; (void) key;
+ return NULL;
+}
+
+void radeonInitCodegen( struct dfn_generators *gen, GLboolean useCodegen )
+{
+ gen->Vertex3f = codegen_noop;
+ gen->Vertex3fv = codegen_noop;
+ gen->Color4ub = codegen_noop;
+ gen->Color4ubv = codegen_noop;
+ gen->Normal3f = codegen_noop;
+ gen->Normal3fv = codegen_noop;
+ gen->TexCoord2f = codegen_noop;
+ gen->TexCoord2fv = codegen_noop;
+ gen->MultiTexCoord2fARB = codegen_noop;
+ gen->MultiTexCoord2fvARB = codegen_noop;
+ gen->Vertex2f = codegen_noop;
+ gen->Vertex2fv = codegen_noop;
+ gen->Color3ub = codegen_noop;
+ gen->Color3ubv = codegen_noop;
+ gen->Color4f = codegen_noop;
+ gen->Color4fv = codegen_noop;
+ gen->Color3f = codegen_noop;
+ gen->Color3fv = codegen_noop;
+ gen->SecondaryColor3fEXT = codegen_noop;
+ gen->SecondaryColor3fvEXT = codegen_noop;
+ gen->SecondaryColor3ubEXT = codegen_noop;
+ gen->SecondaryColor3ubvEXT = codegen_noop;
+ gen->TexCoord1f = codegen_noop;
+ gen->TexCoord1fv = codegen_noop;
+ gen->MultiTexCoord1fARB = codegen_noop;
+ gen->MultiTexCoord1fvARB = codegen_noop;
+
+ if (useCodegen) {
+#if defined(USE_X86_ASM)
+ radeonInitX86Codegen( gen );
+#endif
+
+#if defined(USE_SSE_ASM)
+ radeonInitSSECodegen( gen );
+#endif
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt_sse.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt_sse.c
new file mode 100644
index 000000000..cb5d84011
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt_sse.c
@@ -0,0 +1,232 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt_sse.c,v 1.1 2002/10/30 12:51:58 alanh Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ Tungsten Graphics 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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "simple_list.h"
+#include "radeon_vtxfmt.h"
+
+#if defined(USE_SSE_ASM)
+#include "x86/common_x86_asm.h"
+
+#define EXTERN( FUNC ) \
+extern const char *FUNC; \
+extern const char *FUNC##_end
+
+EXTERN( _sse_Attribute2fv );
+EXTERN( _sse_Attribute2f );
+EXTERN( _sse_Attribute3fv );
+EXTERN( _sse_Attribute3f );
+EXTERN( _sse_MultiTexCoord2fv );
+EXTERN( _sse_MultiTexCoord2f );
+EXTERN( _sse_MultiTexCoord2fv_2 );
+EXTERN( _sse_MultiTexCoord2f_2 );
+
+/* Build specialized versions of the immediate calls on the fly for
+ * the current state.
+ */
+
+static struct dynfn *radeon_makeSSEAttribute2fv( struct dynfn * cache, int key,
+ const char * name, void * dest)
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (RADEON_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", name, key );
+
+ DFN ( _sse_Attribute2fv, (*cache) );
+ FIXUP(dfn->code, 10, 0x0, (int)dest);
+ return dfn;
+}
+
+static struct dynfn *radeon_makeSSEAttribute2f( struct dynfn * cache, int key,
+ const char * name, void * dest )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (RADEON_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", name, key );
+
+ DFN ( _sse_Attribute2f, (*cache) );
+ FIXUP(dfn->code, 8, 0x0, (int)dest);
+ return dfn;
+}
+
+static struct dynfn *radeon_makeSSEAttribute3fv( struct dynfn * cache, int key,
+ const char * name, void * dest)
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (RADEON_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", name, key );
+
+ DFN ( _sse_Attribute3fv, (*cache) );
+ FIXUP(dfn->code, 13, 0x0, (int)dest);
+ FIXUP(dfn->code, 18, 0x8, 8+(int)dest);
+ return dfn;
+}
+
+static struct dynfn *radeon_makeSSEAttribute3f( struct dynfn * cache, int key,
+ const char * name, void * dest )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (RADEON_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", name, key );
+
+ DFN ( _sse_Attribute3f, (*cache) );
+ FIXUP(dfn->code, 12, 0x0, (int)dest);
+ FIXUP(dfn->code, 17, 0x8, 8+(int)dest);
+ return dfn;
+}
+
+static struct dynfn * radeon_makeSSENormal3fv( GLcontext *ctx, int key )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ return radeon_makeSSEAttribute3fv( & rmesa->vb.dfn_cache.Normal3fv, key,
+ __FUNCTION__, rmesa->vb.normalptr );
+}
+
+static struct dynfn *radeon_makeSSENormal3f( GLcontext *ctx, int key )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ return radeon_makeSSEAttribute3f( & rmesa->vb.dfn_cache.Normal3f, key,
+ __FUNCTION__, rmesa->vb.normalptr );
+}
+
+static struct dynfn *radeon_makeSSEColor3fv( GLcontext *ctx, int key )
+{
+ if (key & (RADEON_CP_VC_FRMT_PKCOLOR|RADEON_CP_VC_FRMT_FPALPHA))
+ return NULL;
+ else
+ {
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ return radeon_makeSSEAttribute3fv( & rmesa->vb.dfn_cache.Color3fv, key,
+ __FUNCTION__, rmesa->vb.floatcolorptr );
+ }
+}
+
+static struct dynfn *radeon_makeSSEColor3f( GLcontext *ctx, int key )
+{
+ if (key & (RADEON_CP_VC_FRMT_PKCOLOR|RADEON_CP_VC_FRMT_FPALPHA))
+ return NULL;
+ else
+ {
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ return radeon_makeSSEAttribute3f( & rmesa->vb.dfn_cache.Color3f, key,
+ __FUNCTION__, rmesa->vb.floatcolorptr );
+ }
+}
+
+static struct dynfn *radeon_makeSSETexCoord2fv( GLcontext *ctx, int key )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ return radeon_makeSSEAttribute2fv( & rmesa->vb.dfn_cache.TexCoord2fv, key,
+ __FUNCTION__, rmesa->vb.texcoordptr[0] );
+}
+
+static struct dynfn *radeon_makeSSETexCoord2f( GLcontext *ctx, int key )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ return radeon_makeSSEAttribute2f( & rmesa->vb.dfn_cache.TexCoord2f, key,
+ __FUNCTION__, rmesa->vb.texcoordptr[0] );
+}
+
+static struct dynfn *radeon_makeSSEMultiTexCoord2fv( GLcontext *ctx, int key )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if (RADEON_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", __FUNCTION__, key );
+
+ if ((key & (RADEON_CP_VC_FRMT_ST0|RADEON_CP_VC_FRMT_ST1)) ==
+ (RADEON_CP_VC_FRMT_ST0|RADEON_CP_VC_FRMT_ST1)) {
+ DFN ( _sse_MultiTexCoord2fv, rmesa->vb.dfn_cache.MultiTexCoord2fvARB );
+ FIXUP(dfn->code, 18, 0xdeadbeef, (int)rmesa->vb.texcoordptr[0]);
+ } else {
+ DFN ( _sse_MultiTexCoord2fv_2, rmesa->vb.dfn_cache.MultiTexCoord2fvARB );
+ FIXUP(dfn->code, 14, 0x0, (int)rmesa->vb.texcoordptr);
+ }
+ return dfn;
+}
+
+static struct dynfn *radeon_makeSSEMultiTexCoord2f( GLcontext *ctx, int key )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if (RADEON_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", __FUNCTION__, key );
+
+ if ((key & (RADEON_CP_VC_FRMT_ST0|RADEON_CP_VC_FRMT_ST1)) ==
+ (RADEON_CP_VC_FRMT_ST0|RADEON_CP_VC_FRMT_ST1)) {
+ DFN ( _sse_MultiTexCoord2f, rmesa->vb.dfn_cache.MultiTexCoord2fARB );
+ FIXUP(dfn->code, 16, 0xdeadbeef, (int)rmesa->vb.texcoordptr[0]);
+ } else {
+ DFN ( _sse_MultiTexCoord2f_2, rmesa->vb.dfn_cache.MultiTexCoord2fARB );
+ FIXUP(dfn->code, 15, 0x0, (int)rmesa->vb.texcoordptr);
+ }
+ return dfn;
+}
+
+void radeonInitSSECodegen( struct dfn_generators *gen )
+{
+ if ( cpu_has_xmm ) {
+ gen->Normal3fv = (void *) radeon_makeSSENormal3fv;
+ gen->Normal3f = (void *) radeon_makeSSENormal3f;
+ gen->Color3fv = (void *) radeon_makeSSEColor3fv;
+ gen->Color3f = (void *) radeon_makeSSEColor3f;
+ gen->TexCoord2fv = (void *) radeon_makeSSETexCoord2fv;
+ gen->TexCoord2f = (void *) radeon_makeSSETexCoord2f;
+ gen->MultiTexCoord2fvARB = (void *) radeon_makeSSEMultiTexCoord2fv;
+ gen->MultiTexCoord2fARB = (void *) radeon_makeSSEMultiTexCoord2f;
+ }
+}
+
+#else
+
+void radeonInitSSECodegen( struct dfn_generators *gen )
+{
+ (void) gen;
+}
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt_x86.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt_x86.c
new file mode 100644
index 000000000..d1cf1979f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxfmt_x86.c
@@ -0,0 +1,437 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_vtxfmt_x86.c,v 1.2 2002/12/21 17:02:16 dawes Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ Tungsten Graphics 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 THE COPYRIGHT OWNER(S) 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 <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "simple_list.h"
+#include "radeon_vtxfmt.h"
+
+#if defined(USE_X86_ASM)
+
+#define EXTERN( FUNC ) \
+extern const char *FUNC; \
+extern const char *FUNC##_end
+
+EXTERN ( _x86_Attribute2fv );
+EXTERN ( _x86_Attribute2f );
+EXTERN ( _x86_Attribute3fv );
+EXTERN ( _x86_Attribute3f );
+EXTERN ( _x86_Vertex3fv_6 );
+EXTERN ( _x86_Vertex3fv_8 );
+EXTERN ( _x86_Vertex3fv );
+EXTERN ( _x86_Vertex3f_4 );
+EXTERN ( _x86_Vertex3f_6 );
+EXTERN ( _x86_Vertex3f );
+EXTERN ( _x86_Color4ubv_ub );
+EXTERN ( _x86_Color4ubv_4f );
+EXTERN ( _x86_Color4ub_ub );
+EXTERN ( _x86_MultiTexCoord2fv );
+EXTERN ( _x86_MultiTexCoord2fv_2 );
+EXTERN ( _x86_MultiTexCoord2f );
+EXTERN ( _x86_MultiTexCoord2f_2 );
+
+
+/* Build specialized versions of the immediate calls on the fly for
+ * the current state. Generic x86 versions.
+ */
+
+struct dynfn *radeon_makeX86Vertex3f( GLcontext *ctx, int key )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (RADEON_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x %d\n", __FUNCTION__, key, rmesa->vb.vertex_size );
+
+ switch (rmesa->vb.vertex_size) {
+ case 4: {
+
+ DFN ( _x86_Vertex3f_4, rmesa->vb.dfn_cache.Vertex3f );
+ FIXUP(dfn->code, 2, 0x0, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 25, 0x0, (int)&rmesa->vb.vertex[3]);
+ FIXUP(dfn->code, 36, 0x0, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 46, 0x0, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 51, 0x0, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 60, 0x0, (int)&rmesa->vb.notify);
+ break;
+ }
+ case 6: {
+
+ DFN ( _x86_Vertex3f_6, rmesa->vb.dfn_cache.Vertex3f );
+ FIXUP(dfn->code, 3, 0x0, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 28, 0x0, (int)&rmesa->vb.vertex[3]);
+ FIXUP(dfn->code, 34, 0x0, (int)&rmesa->vb.vertex[4]);
+ FIXUP(dfn->code, 40, 0x0, (int)&rmesa->vb.vertex[5]);
+ FIXUP(dfn->code, 57, 0x0, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 63, 0x0, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 70, 0x0, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 79, 0x0, (int)&rmesa->vb.notify);
+ break;
+ }
+ default: {
+
+ DFN ( _x86_Vertex3f, rmesa->vb.dfn_cache.Vertex3f );
+ FIXUP(dfn->code, 3, 0x0, (int)&rmesa->vb.vertex[3]);
+ FIXUP(dfn->code, 9, 0x0, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 37, 0x0, rmesa->vb.vertex_size-3);
+ FIXUP(dfn->code, 44, 0x0, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 50, 0x0, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 56, 0x0, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 67, 0x0, (int)&rmesa->vb.notify);
+ break;
+ }
+ }
+
+ return dfn;
+}
+
+
+
+struct dynfn *radeon_makeX86Vertex3fv( GLcontext *ctx, int key )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (RADEON_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x %d\n", __FUNCTION__, key, rmesa->vb.vertex_size );
+
+ switch (rmesa->vb.vertex_size) {
+ case 6: {
+
+ DFN ( _x86_Vertex3fv_6, rmesa->vb.dfn_cache.Vertex3fv );
+ FIXUP(dfn->code, 1, 0x00000000, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 27, 0x0000001c, (int)&rmesa->vb.vertex[3]);
+ FIXUP(dfn->code, 33, 0x00000020, (int)&rmesa->vb.vertex[4]);
+ FIXUP(dfn->code, 45, 0x00000024, (int)&rmesa->vb.vertex[5]);
+ FIXUP(dfn->code, 56, 0x00000000, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 61, 0x00000004, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 67, 0x00000004, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 76, 0x00000008, (int)&rmesa->vb.notify);
+ break;
+ }
+
+
+ case 8: {
+
+ DFN ( _x86_Vertex3fv_8, rmesa->vb.dfn_cache.Vertex3fv );
+ FIXUP(dfn->code, 1, 0x00000000, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 27, 0x0000001c, (int)&rmesa->vb.vertex[3]);
+ FIXUP(dfn->code, 33, 0x00000020, (int)&rmesa->vb.vertex[4]);
+ FIXUP(dfn->code, 45, 0x0000001c, (int)&rmesa->vb.vertex[5]);
+ FIXUP(dfn->code, 51, 0x00000020, (int)&rmesa->vb.vertex[6]);
+ FIXUP(dfn->code, 63, 0x00000024, (int)&rmesa->vb.vertex[7]);
+ FIXUP(dfn->code, 74, 0x00000000, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 79, 0x00000004, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 85, 0x00000004, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 94, 0x00000008, (int)&rmesa->vb.notify);
+ break;
+ }
+
+
+
+ default: {
+
+ DFN ( _x86_Vertex3fv, rmesa->vb.dfn_cache.Vertex3fv );
+ FIXUP(dfn->code, 8, 0x01010101, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 32, 0x00000006, rmesa->vb.vertex_size-3);
+ FIXUP(dfn->code, 37, 0x00000058, (int)&rmesa->vb.vertex[3]);
+ FIXUP(dfn->code, 45, 0x01010101, (int)&rmesa->vb.dmaptr);
+ FIXUP(dfn->code, 50, 0x02020202, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 58, 0x02020202, (int)&rmesa->vb.counter);
+ FIXUP(dfn->code, 67, 0x0, (int)&rmesa->vb.notify);
+ break;
+ }
+ }
+
+ return dfn;
+}
+
+static struct dynfn *
+radeon_makeX86Attribute2fv( struct dynfn * cache, int key,
+ const char * name, void * dest )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (RADEON_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", name, key );
+
+ DFN ( _x86_Attribute2fv, (*cache) );
+ FIXUP(dfn->code, 11, 0x0, (int)dest);
+ FIXUP(dfn->code, 16, 0x4, 4+(int)dest);
+
+ return dfn;
+}
+
+static struct dynfn *
+radeon_makeX86Attribute2f( struct dynfn * cache, int key,
+ const char * name, void * dest )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (RADEON_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", name, key );
+
+ DFN ( _x86_Attribute2f, (*cache) );
+ FIXUP(dfn->code, 1, 0x0, (int)dest);
+
+ return dfn;
+}
+
+
+static struct dynfn *
+radeon_makeX86Attribute3fv( struct dynfn * cache, int key,
+ const char * name, void * dest )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (RADEON_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", name, key );
+
+ DFN ( _x86_Attribute3fv, (*cache) );
+ FIXUP(dfn->code, 14, 0x0, (int)dest);
+ FIXUP(dfn->code, 20, 0x4, 4+(int)dest);
+ FIXUP(dfn->code, 25, 0x8, 8+(int)dest);
+
+ return dfn;
+}
+
+static struct dynfn *
+radeon_makeX86Attribute3f( struct dynfn * cache, int key,
+ const char * name, void * dest )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+
+ if (RADEON_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", name, key );
+
+ DFN ( _x86_Attribute3f, (*cache) );
+ FIXUP(dfn->code, 14, 0x0, (int)dest);
+ FIXUP(dfn->code, 20, 0x4, 4+(int)dest);
+ FIXUP(dfn->code, 25, 0x8, 8+(int)dest);
+
+ return dfn;
+}
+
+struct dynfn *radeon_makeX86Normal3fv( GLcontext *ctx, int key )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ return radeon_makeX86Attribute3fv( & rmesa->vb.dfn_cache.Normal3fv, key,
+ __FUNCTION__, rmesa->vb.normalptr );
+}
+
+struct dynfn *radeon_makeX86Normal3f( GLcontext *ctx, int key )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ return radeon_makeX86Attribute3f( & rmesa->vb.dfn_cache.Normal3f, key,
+ __FUNCTION__, rmesa->vb.normalptr );
+}
+
+struct dynfn *radeon_makeX86Color4ubv( GLcontext *ctx, int key )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+
+ if (RADEON_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", __FUNCTION__, key );
+
+ if (key & RADEON_CP_VC_FRMT_PKCOLOR) {
+ DFN ( _x86_Color4ubv_ub, rmesa->vb.dfn_cache.Color4ubv);
+ FIXUP(dfn->code, 5, 0x12345678, (int)rmesa->vb.colorptr);
+ return dfn;
+ }
+ else {
+
+ DFN ( _x86_Color4ubv_4f, rmesa->vb.dfn_cache.Color4ubv);
+ FIXUP(dfn->code, 2, 0x00000000, (int)_mesa_ubyte_to_float_color_tab);
+ FIXUP(dfn->code, 27, 0xdeadbeaf, (int)rmesa->vb.floatcolorptr);
+ FIXUP(dfn->code, 33, 0xdeadbeaf, (int)rmesa->vb.floatcolorptr+4);
+ FIXUP(dfn->code, 55, 0xdeadbeaf, (int)rmesa->vb.floatcolorptr+8);
+ FIXUP(dfn->code, 61, 0xdeadbeaf, (int)rmesa->vb.floatcolorptr+12);
+ return dfn;
+ }
+}
+
+struct dynfn *radeon_makeX86Color4ub( GLcontext *ctx, int key )
+{
+ if (RADEON_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", __FUNCTION__, key );
+
+ if (key & RADEON_CP_VC_FRMT_PKCOLOR) {
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ DFN ( _x86_Color4ub_ub, rmesa->vb.dfn_cache.Color4ub );
+ FIXUP(dfn->code, 18, 0x0, (int)rmesa->vb.colorptr);
+ FIXUP(dfn->code, 24, 0x0, (int)rmesa->vb.colorptr+1);
+ FIXUP(dfn->code, 30, 0x0, (int)rmesa->vb.colorptr+2);
+ FIXUP(dfn->code, 36, 0x0, (int)rmesa->vb.colorptr+3);
+ return dfn;
+ }
+ else
+ return NULL;
+}
+
+
+struct dynfn *radeon_makeX86Color3fv( GLcontext *ctx, int key )
+{
+ if (key & (RADEON_CP_VC_FRMT_PKCOLOR|RADEON_CP_VC_FRMT_FPALPHA))
+ return NULL;
+ else
+ {
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ return radeon_makeX86Attribute3fv( & rmesa->vb.dfn_cache.Color3fv, key,
+ __FUNCTION__, rmesa->vb.floatcolorptr );
+ }
+}
+
+struct dynfn *radeon_makeX86Color3f( GLcontext *ctx, int key )
+{
+ if (key & (RADEON_CP_VC_FRMT_PKCOLOR|RADEON_CP_VC_FRMT_FPALPHA))
+ return NULL;
+ else
+ {
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ return radeon_makeX86Attribute3f( & rmesa->vb.dfn_cache.Color3f, key,
+ __FUNCTION__, rmesa->vb.floatcolorptr );
+ }
+}
+
+
+
+struct dynfn *radeon_makeX86TexCoord2fv( GLcontext *ctx, int key )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ return radeon_makeX86Attribute2fv( & rmesa->vb.dfn_cache.TexCoord2fv, key,
+ __FUNCTION__, rmesa->vb.texcoordptr[0] );
+}
+
+struct dynfn *radeon_makeX86TexCoord2f( GLcontext *ctx, int key )
+{
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ return radeon_makeX86Attribute2f( & rmesa->vb.dfn_cache.TexCoord2f, key,
+ __FUNCTION__, rmesa->vb.texcoordptr[0] );
+}
+
+struct dynfn *radeon_makeX86MultiTexCoord2fvARB( GLcontext *ctx, int key )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if (RADEON_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", __FUNCTION__, key );
+
+ if ((key & (RADEON_CP_VC_FRMT_ST0|RADEON_CP_VC_FRMT_ST1)) ==
+ (RADEON_CP_VC_FRMT_ST0|RADEON_CP_VC_FRMT_ST1)) {
+ DFN ( _x86_MultiTexCoord2fv, rmesa->vb.dfn_cache.MultiTexCoord2fvARB );
+ FIXUP(dfn->code, 21, 0xdeadbeef, (int)rmesa->vb.texcoordptr[0]);
+ FIXUP(dfn->code, 27, 0xdeadbeef, (int)rmesa->vb.texcoordptr[0]+4);
+ } else {
+ DFN ( _x86_MultiTexCoord2fv_2, rmesa->vb.dfn_cache.MultiTexCoord2fvARB );
+ FIXUP(dfn->code, 14, 0x0, (int)rmesa->vb.texcoordptr);
+ }
+ return dfn;
+}
+
+struct dynfn *radeon_makeX86MultiTexCoord2fARB( GLcontext *ctx,
+ int key )
+{
+ struct dynfn *dfn = MALLOC_STRUCT( dynfn );
+ radeonContextPtr rmesa = RADEON_CONTEXT(ctx);
+
+ if (RADEON_DEBUG & DEBUG_CODEGEN)
+ fprintf(stderr, "%s 0x%08x\n", __FUNCTION__, key );
+
+ if ((key & (RADEON_CP_VC_FRMT_ST0|RADEON_CP_VC_FRMT_ST1)) ==
+ (RADEON_CP_VC_FRMT_ST0|RADEON_CP_VC_FRMT_ST1)) {
+ DFN ( _x86_MultiTexCoord2f, rmesa->vb.dfn_cache.MultiTexCoord2fARB );
+ FIXUP(dfn->code, 20, 0xdeadbeef, (int)rmesa->vb.texcoordptr[0]);
+ FIXUP(dfn->code, 26, 0xdeadbeef, (int)rmesa->vb.texcoordptr[0]+4);
+ }
+ else {
+ /* Note: this might get generated multiple times, even though the
+ * actual emitted code is the same.
+ */
+ DFN ( _x86_MultiTexCoord2f_2, rmesa->vb.dfn_cache.MultiTexCoord2fARB );
+ FIXUP(dfn->code, 18, 0x0, (int)rmesa->vb.texcoordptr);
+ }
+ return dfn;
+}
+
+
+void radeonInitX86Codegen( struct dfn_generators *gen )
+{
+ gen->Vertex3f = radeon_makeX86Vertex3f;
+ gen->Vertex3fv = radeon_makeX86Vertex3fv;
+ gen->Color4ub = radeon_makeX86Color4ub; /* PKCOLOR only */
+ gen->Color4ubv = radeon_makeX86Color4ubv; /* PKCOLOR only */
+ gen->Normal3f = radeon_makeX86Normal3f;
+ gen->Normal3fv = radeon_makeX86Normal3fv;
+ gen->TexCoord2f = radeon_makeX86TexCoord2f;
+ gen->TexCoord2fv = radeon_makeX86TexCoord2fv;
+ gen->MultiTexCoord2fARB = radeon_makeX86MultiTexCoord2fARB;
+ gen->MultiTexCoord2fvARB = radeon_makeX86MultiTexCoord2fvARB;
+ gen->Color3f = radeon_makeX86Color3f;
+ gen->Color3fv = radeon_makeX86Color3fv;
+
+ /* Not done:
+ */
+/* gen->Vertex2f = radeon_makeX86Vertex2f; */
+/* gen->Vertex2fv = radeon_makeX86Vertex2fv; */
+/* gen->Color3ub = radeon_makeX86Color3ub; */
+/* gen->Color3ubv = radeon_makeX86Color3ubv; */
+/* gen->Color4f = radeon_makeX86Color4f; */
+/* gen->Color4fv = radeon_makeX86Color4fv; */
+/* gen->TexCoord1f = radeon_makeX86TexCoord1f; */
+/* gen->TexCoord1fv = radeon_makeX86TexCoord1fv; */
+/* gen->MultiTexCoord1fARB = radeon_makeX86MultiTexCoord1fARB; */
+/* gen->MultiTexCoord1fvARB = radeon_makeX86MultiTexCoord1fvARB; */
+}
+
+
+#else
+
+void radeonInitX86Codegen( struct dfn_generators *gen )
+{
+ (void) gen;
+}
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxtmp_x86.S b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxtmp_x86.S
new file mode 100644
index 000000000..569d3b9b4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_vtxtmp_x86.S
@@ -0,0 +1,494 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/radeon/radeon_vtxtmp_x86.S,v 1.1 2002/10/30 12:51:58 alanh Exp $ */
+/**************************************************************************
+
+Copyright 2002 Tungsten Graphics 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, TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+#define GLOBL( x ) \
+.globl x; \
+x:
+
+.data
+.align 4
+
+/*
+ vertex 3f vertex size 4
+*/
+
+GLOBL ( _x86_Vertex3f_4 )
+ movl (0), %ecx
+ movl 4(%esp), %eax
+ movl 8(%esp), %edx
+ movl %eax, (%ecx)
+ movl %edx, 4(%ecx)
+ movl 12(%esp), %eax
+ movl (0), %edx
+ movl %eax, 8(%ecx)
+ movl %edx, 12(%ecx)
+ movl (0), %eax
+ addl $16, %ecx
+ dec %eax
+ movl %ecx, (0)
+ movl %eax, (0)
+ je .1
+ ret
+.1: jmp *0
+
+GLOBL ( _x86_Vertex3f_4_end )
+
+/*
+ vertex 3f vertex size 6
+*/
+GLOBL ( _x86_Vertex3f_6 )
+ push %edi
+ movl (0), %edi
+ movl 8(%esp), %eax
+ movl 12(%esp), %edx
+ movl 16(%esp), %ecx
+ movl %eax, (%edi)
+ movl %edx, 4(%edi)
+ movl %ecx, 8(%edi)
+ movl (0), %eax
+ movl (0), %edx
+ movl (0), %ecx
+ movl %eax, 12(%edi)
+ movl %edx, 16(%edi)
+ movl %ecx, 20(%edi)
+ addl $24, %edi
+ movl (0), %eax
+ movl %edi, (0)
+ dec %eax
+ pop %edi
+ movl %eax, (0)
+ je .2
+ ret
+.2: jmp *0
+GLOBL ( _x86_Vertex3f_6_end )
+/*
+ vertex 3f generic size
+*/
+GLOBL ( _x86_Vertex3f )
+ push %edi
+ push %esi
+ movl $0, %esi
+ movl (0), %edi
+ movl 12(%esp), %eax
+ movl 16(%esp), %edx
+ movl 20(%esp), %ecx
+ movl %eax, (%edi)
+ movl %edx, 4(%edi)
+ movl %ecx, 8(%edi)
+ addl $12, %edi
+ movl $0, %ecx
+ repz
+ movsl %ds:(%esi), %es:(%edi)
+ movl (0), %eax
+ movl %edi, (0)
+ dec %eax
+ movl %eax, (0)
+ pop %esi
+ pop %edi
+ je .3
+ ret
+.3: jmp *0
+
+GLOBL ( _x86_Vertex3f_end )
+
+/*
+ Vertex 3fv vertex size 6
+*/
+GLOBL ( _x86_Vertex3fv_6 )
+ movl (0), %eax
+ movl 4(%esp), %ecx
+ movl (%ecx), %edx
+ movl %edx, (%eax)
+ movl 4(%ecx), %edx
+ movl 8(%ecx), %ecx
+ movl %edx, 4(%eax)
+ movl %ecx, 8(%eax)
+ movl (28), %edx
+ movl (32), %ecx
+ movl %edx, 12(%eax)
+ movl %ecx, 16(%eax)
+ movl (36), %edx
+ movl %edx, 20(%eax)
+ addl $24, %eax
+ movl %eax, 0
+ movl 4, %eax
+ dec %eax
+ movl %eax, 4
+ je .4
+ ret
+.4: jmp *8
+
+GLOBL ( _x86_Vertex3fv_6_end )
+
+/*
+ Vertex 3fv vertex size 8
+*/
+GLOBL ( _x86_Vertex3fv_8 )
+ movl (0), %eax
+ movl 4(%esp), %ecx
+ movl (%ecx), %edx
+ movl %edx ,(%eax)
+ movl 4(%ecx) ,%edx
+ movl 8(%ecx) ,%ecx
+ movl %edx, 4(%eax)
+ movl %ecx, 8(%eax)
+ movl (28), %edx
+ movl (32), %ecx
+ movl %edx, 12(%eax)
+ movl %ecx, 16(%eax)
+ movl (28), %edx
+ movl (32), %ecx
+ movl %edx, 20(%eax)
+ movl %ecx, 24(%eax)
+ movl (36), %edx
+ movl %edx, 28(%eax)
+ addl $32, %eax
+ movl %eax, (0)
+ movl 4, %eax
+ dec %eax
+ movl %eax, (4)
+ je .5
+ ret
+.5: jmp *8
+
+GLOBL ( _x86_Vertex3fv_8_end )
+
+/*
+ Vertex 3fv generic vertex size
+*/
+GLOBL ( _x86_Vertex3fv )
+ movl 4(%esp), %edx
+ push %edi
+ push %esi
+ movl (0x1010101), %edi
+ movl (%edx), %eax
+ movl 4(%edx), %ecx
+ movl 8(%edx), %esi
+ movl %eax, (%edi)
+ movl %ecx, 4(%edi)
+ movl %esi, 8(%edi)
+ addl $12, %edi
+ movl $6, %ecx
+ movl $0x58, %esi
+ repz
+ movsl %ds:(%esi), %es:(%edi)
+ movl %edi, (0x1010101)
+ movl (0x2020202), %eax
+ pop %esi
+ pop %edi
+ dec %eax
+ movl %eax, (0x2020202)
+ je .6
+ ret
+.6: jmp *0
+GLOBL ( _x86_Vertex3fv_end )
+
+
+/**
+ * Generic handler for 2 float format data. This can be used for
+ * TexCoord2f and possibly other functions.
+ */
+
+GLOBL ( _x86_Attribute2f )
+ movl $0x0, %edx
+ movl 4(%esp), %eax
+ movl 8(%esp), %ecx
+ movl %eax, (%edx)
+ movl %ecx, 4(%edx)
+ ret
+GLOBL ( _x86_Attribute2f_end )
+
+
+/**
+ * Generic handler for 2 float vector format data. This can be used for
+ * TexCoord2fv and possibly other functions.
+ */
+
+GLOBL( _x86_Attribute2fv)
+ movl 4(%esp), %eax /* load 'v' off stack */
+ movl (%eax), %ecx /* load v[0] */
+ movl 4(%eax), %eax /* load v[1] */
+ movl %ecx, 0 /* store v[0] to current vertex */
+ movl %eax, 4 /* store v[1] to current vertex */
+ ret
+GLOBL ( _x86_Attribute2fv_end )
+
+
+/**
+ * Generic handler for 3 float format data. This can be used for
+ * Normal3f, Color3f (when the color target is also float), or
+ * TexCoord3f.
+ */
+
+GLOBL ( _x86_Attribute3f )
+ movl 4(%esp), %ecx
+ movl 8(%esp), %edx
+ movl 12(%esp), %eax
+ movl %ecx, 0
+ movl %edx, 4
+ movl %eax, 8
+ ret
+GLOBL ( _x86_Attribute3f_end )
+
+/**
+ * Generic handler for 3 float vector format data. This can be used for
+ * Normal3f, Color3f (when the color target is also float), or
+ * TexCoord3f.
+ */
+
+GLOBL( _x86_Attribute3fv)
+ movl 4(%esp), %eax /* load 'v' off stack */
+ movl (%eax), %ecx /* load v[0] */
+ movl 4(%eax), %edx /* load v[1] */
+ movl 8(%eax), %eax /* load v[2] */
+ movl %ecx, 0 /* store v[0] to current vertex */
+ movl %edx, 4 /* store v[1] to current vertex */
+ movl %eax, 8 /* store v[2] to current vertex */
+ ret
+GLOBL ( _x86_Attribute3fv_end )
+
+
+/*
+ Color 4ubv_ub
+*/
+GLOBL ( _x86_Color4ubv_ub )
+ movl 4(%esp), %eax
+ movl $0x12345678, %edx
+ movl (%eax), %eax
+ movl %eax, (%edx)
+ ret
+GLOBL ( _x86_Color4ubv_ub_end )
+
+/*
+ Color 4ubv 4f
+*/
+GLOBL ( _x86_Color4ubv_4f )
+ push %ebx
+ movl $0, %edx
+ xor %eax, %eax
+ xor %ecx, %ecx
+ movl 8(%esp), %ebx
+ movl (%ebx), %ebx
+ mov %bl, %al
+ mov %bh, %cl
+ movl (%edx,%eax,4),%eax
+ movl (%edx,%ecx,4),%ecx
+ movl %eax, (0xdeadbeaf)
+ movl %ecx, (0xdeadbeaf)
+ xor %eax, %eax
+ xor %ecx, %ecx
+ shr $16, %ebx
+ mov %bl, %al
+ mov %bh, %cl
+ movl (%edx,%eax,4), %eax
+ movl (%edx,%ecx,4), %ecx
+ movl %eax, (0xdeadbeaf)
+ movl %ecx, (0xdeadbeaf)
+ pop %ebx
+ ret
+GLOBL ( _x86_Color4ubv_4f_end )
+
+/*
+
+ Color4ub_ub
+*/
+GLOBL( _x86_Color4ub_ub )
+ push %ebx
+ movl 8(%esp), %eax
+ movl 12(%esp), %edx
+ movl 16(%esp), %ecx
+ movl 20(%esp), %ebx
+ mov %al, (0)
+ mov %dl, (0)
+ mov %cl, (0)
+ mov %bl, (0)
+ pop %ebx
+ ret
+GLOBL( _x86_Color4ub_ub_end )
+
+
+/*
+ MultiTexCoord2fv st0/st1
+*/
+GLOBL( _x86_MultiTexCoord2fv )
+ movl 4(%esp), %eax
+ movl 8(%esp), %ecx
+ and $1, %eax
+ movl (%ecx), %edx
+ shl $3, %eax
+ movl 4(%ecx), %ecx
+ movl %edx, 0xdeadbeef(%eax)
+ movl %ecx, 0xdeadbeef(%eax)
+ ret
+GLOBL( _x86_MultiTexCoord2fv_end )
+
+/*
+ MultiTexCoord2fv
+*/
+
+GLOBL( _x86_MultiTexCoord2fv_2 )
+ movl 4(%esp,1), %eax
+ movl 8(%esp,1), %ecx
+ and $0x1, %eax
+ movl 0(,%eax,4), %edx
+ movl (%ecx), %eax
+ movl %eax, (%edx)
+ movl 4(%ecx), %eax
+ movl %eax, 4(%edx)
+ ret
+GLOBL( _x86_MultiTexCoord2fv_2_end )
+
+/*
+ MultiTexCoord2f st0/st1
+*/
+GLOBL( _x86_MultiTexCoord2f )
+ movl 4(%esp), %eax
+ movl 8(%esp), %edx
+ movl 12(%esp), %ecx
+ and $1, %eax
+ shl $3, %eax
+ movl %edx, 0xdeadbeef(%eax)
+ movl %ecx, 0xdeadbeef(%eax)
+ ret
+GLOBL( _x86_MultiTexCoord2f_end )
+
+/*
+ MultiTexCoord2f
+*/
+GLOBL( _x86_MultiTexCoord2f_2 )
+ movl 4(%esp), %eax
+ movl 8(%esp), %edx
+ movl 12(%esp,1), %ecx
+ and $1,%eax
+ movl 0(,%eax,4), %eax
+ movl %edx, (%eax)
+ movl %ecx, 4(%eax)
+ ret
+GLOBL( _x86_MultiTexCoord2f_2_end )
+
+#if defined(USE_SSE_ASM)
+/**
+ * This can be used as a template for either Color3fv (when the color
+ * target is also a 3f) or Normal3fv.
+ */
+
+GLOBL( _sse_Attribute3fv )
+ movl 4(%esp), %eax
+ movlps (%eax), %xmm0
+ movl 8(%eax), %eax
+ movlps %xmm0, 0
+ movl %eax, 8
+ ret
+GLOBL( _sse_Attribute3fv_end )
+
+/**
+ * This can be used as a template for either Color3f (when the color
+ * target is also a 3f) or Normal3f.
+ */
+
+GLOBL( _sse_Attribute3f )
+ movlps 4(%esp), %xmm0
+ movl 12(%esp), %eax
+ movlps %xmm0, 0
+ movl %eax, 8
+ ret
+GLOBL( _sse_Attribute3f_end )
+
+
+/**
+ * Generic handler for 2 float vector format data. This can be used for
+ * TexCoord2fv and possibly other functions.
+ */
+
+GLOBL( _sse_Attribute2fv )
+ movl 4(%esp), %eax
+ movlps (%eax), %xmm0
+ movlps %xmm0, 0
+ ret
+GLOBL( _sse_Attribute2fv_end )
+
+
+/**
+ * Generic handler for 2 float format data. This can be used for
+ * TexCoord2f and possibly other functions.
+ */
+
+GLOBL( _sse_Attribute2f )
+ movlps 4(%esp), %xmm0
+ movlps %xmm0, 0
+ ret
+GLOBL( _sse_Attribute2f_end )
+
+/*
+ MultiTexCoord2fv st0/st1
+*/
+GLOBL( _sse_MultiTexCoord2fv )
+ movl 4(%esp), %eax
+ movl 8(%esp), %ecx
+ and $1, %eax
+ movlps (%ecx), %xmm0
+ movlps %xmm0, 0xdeadbeef(,%eax,8)
+ ret
+GLOBL( _sse_MultiTexCoord2fv_end )
+
+/*
+ MultiTexCoord2fv
+*/
+GLOBL( _sse_MultiTexCoord2fv_2 )
+ movl 4(%esp), %eax
+ movl 8(%esp), %ecx
+ and $0x1, %eax
+ movl 0(,%eax,4), %edx
+ movlps (%ecx), %xmm0
+ movlps %xmm0, (%edx)
+ ret
+GLOBL( _sse_MultiTexCoord2fv_2_end )
+
+/*
+ MultiTexCoord2f st0/st1
+*/
+GLOBL( _sse_MultiTexCoord2f )
+ movl 4(%esp), %eax
+ and $1, %eax
+ movlps 8(%esp), %xmm0
+ movlps %xmm0, 0xdeadbeef(,%eax,8)
+ ret
+GLOBL( _sse_MultiTexCoord2f_end )
+
+/*
+ MultiTexCoord2f
+*/
+GLOBL( _sse_MultiTexCoord2f_2 )
+ movl 4(%esp), %eax
+ movlps 8(%esp), %xmm0
+ and $1,%eax
+ movl 0(,%eax,4), %eax
+ movlps %xmm0, (%eax)
+ ret
+GLOBL( _sse_MultiTexCoord2f_2_end )
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon.h
new file mode 100644
index 000000000..21db825c9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon.h
@@ -0,0 +1,202 @@
+/**
+ * \file server/radeon.h
+ * \brief Radeon 2D driver data structures.
+ */
+
+/*
+ * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and
+ * VA Linux Systems Inc., Fremont, 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 on 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS 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.
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon.h,v 1.29 2002/10/12 01:38:07 martin Exp $ */
+
+#ifndef _RADEON_H_
+#define _RADEON_H_
+
+#include "xf86drm.h" /* drm_handle_t, etc */
+
+# define RADEON_AGP_1X_MODE 0x01
+# define RADEON_AGP_2X_MODE 0x02
+# define RADEON_AGP_4X_MODE 0x04
+# define RADEON_AGP_FW_MODE 0x10
+# define RADEON_AGP_MODE_MASK 0x17
+#define RADEON_CP_CSQ_CNTL 0x0740
+# define RADEON_CSQ_CNT_PRIMARY_MASK (0xff << 0)
+# define RADEON_CSQ_PRIDIS_INDDIS (0 << 28)
+# define RADEON_CSQ_PRIPIO_INDDIS (1 << 28)
+# define RADEON_CSQ_PRIBM_INDDIS (2 << 28)
+# define RADEON_CSQ_PRIPIO_INDBM (3 << 28)
+# define RADEON_CSQ_PRIBM_INDBM (4 << 28)
+# define RADEON_CSQ_PRIPIO_INDPIO (15 << 28)
+
+
+#define PCI_CHIP_R200_BB 0x4242
+#define PCI_CHIP_RV250_Id 0x4964
+#define PCI_CHIP_RV250_Ie 0x4965
+#define PCI_CHIP_RV250_If 0x4966
+#define PCI_CHIP_RV250_Ig 0x4967
+#define PCI_CHIP_RADEON_LW 0x4C57
+#define PCI_CHIP_RADEON_LX 0x4C58
+#define PCI_CHIP_RADEON_LY 0x4C59
+#define PCI_CHIP_RADEON_LZ 0x4C5A
+#define PCI_CHIP_RV250_Ld 0x4C64
+#define PCI_CHIP_RV250_Le 0x4C65
+#define PCI_CHIP_RV250_Lf 0x4C66
+#define PCI_CHIP_RV250_Lg 0x4C67
+#define PCI_CHIP_R300_ND 0x4E44
+#define PCI_CHIP_R300_NE 0x4E45
+#define PCI_CHIP_R300_NF 0x4E46
+#define PCI_CHIP_R300_NG 0x4E47
+#define PCI_CHIP_RADEON_QD 0x5144
+#define PCI_CHIP_RADEON_QE 0x5145
+#define PCI_CHIP_RADEON_QF 0x5146
+#define PCI_CHIP_RADEON_QG 0x5147
+#define PCI_CHIP_R200_QL 0x514C
+#define PCI_CHIP_R200_QN 0x514E
+#define PCI_CHIP_R200_QO 0x514F
+#define PCI_CHIP_RV200_QW 0x5157
+#define PCI_CHIP_RV200_QX 0x5158
+#define PCI_CHIP_RADEON_QY 0x5159
+#define PCI_CHIP_RADEON_QZ 0x515A
+#define PCI_CHIP_R200_Ql 0x516C
+#define PCI_CHIP_RV280_Y_ 0x5960
+#define PCI_CHIP_RV280_Ya 0x5961
+#define PCI_CHIP_RV280_Yb 0x5962
+#define PCI_CHIP_RV280_Yc 0x5963
+
+/**
+ * \brief Chip families.
+ */
+typedef enum {
+ CHIP_FAMILY_UNKNOW,
+ CHIP_FAMILY_LEGACY,
+ CHIP_FAMILY_R128,
+ CHIP_FAMILY_M3,
+ CHIP_FAMILY_RADEON,
+ CHIP_FAMILY_VE,
+ CHIP_FAMILY_M6,
+ CHIP_FAMILY_RV200,
+ CHIP_FAMILY_M7,
+ CHIP_FAMILY_R200,
+ CHIP_FAMILY_RV250,
+ CHIP_FAMILY_M9,
+ CHIP_FAMILY_RV280,
+ CHIP_FAMILY_R300
+} RADEONChipFamily;
+
+
+typedef unsigned long memType;
+
+
+/**
+ * \brief Radeon DDX driver private data.
+ */
+typedef struct {
+ int Chipset; /**< \brief Chipset number */
+ RADEONChipFamily ChipFamily; /**< \brief Chip family */
+
+ unsigned long LinearAddr; /**< \brief Frame buffer physical address */
+
+
+ drmSize registerSize; /**< \brief MMIO register map size */
+ drm_handle_t registerHandle; /**< \brief MMIO register map handle */
+
+ int IsPCI; /* Current card is a PCI card */
+
+ /**
+ * \name AGP
+ */
+ /*@{*/
+ drmSize gartSize; /**< \brief AGP map size */
+ drm_handle_t gartMemHandle; /**< \brief AGP map handle */
+ unsigned long gartOffset; /**< \brief AGP offset */
+ int gartMode; /**< \brief AGP mode */
+ int gartFastWrite;
+ /*@}*/
+
+ /**
+ * \name CP ring buffer data
+ */
+ /*@{*/
+ unsigned long ringStart; /**< \brief Offset into AGP space */
+ drm_handle_t ringHandle; /**< \brief Handle from drmAddMap() */
+ drmSize ringMapSize; /**< \brief Size of map */
+ int ringSize; /**< \brief Size of ring (in MB) */
+
+ unsigned long ringReadOffset; /**< \brief Read offset into AGP space */
+ drm_handle_t ringReadPtrHandle;/**< \brief Handle from drmAddMap() */
+ drmSize ringReadMapSize; /**< \brief Size of map */
+ /*@}*/
+
+ /**
+ * \name CP vertex/indirect buffer data
+ */
+ /*@{*/
+ unsigned long bufStart; /**< \brief Offset into AGP space */
+ drm_handle_t bufHandle; /**< \brief Handle from drmAddMap() */
+ drmSize bufMapSize; /**< \brief Size of map */
+ int bufSize; /**< \brief Size of buffers (in MB) */
+ int bufNumBufs; /**< \brief Number of buffers */
+ /*@}*/
+
+ /**
+ * \name CP AGP Texture data
+ */
+ /*@{*/
+ unsigned long gartTexStart; /**< \brief Offset into AGP space */
+ drm_handle_t gartTexHandle; /**< \brief Handle from drmAddMap() */
+ drmSize gartTexMapSize; /**< \brief Size of map */
+ int gartTexSize; /**< \brief Size of AGP tex space (in MB) */
+ int log2GARTTexGran;
+ /*@}*/
+
+ int drmMinor; /**< \brief DRM device minor number */
+
+ int frontOffset; /**< \brief Front color buffer offset */
+ int frontPitch; /**< \brief Front color buffer pitch */
+ int backOffset; /**< \brief Back color buffer offset */
+ int backPitch; /**< \brief Back color buffer pitch */
+ int depthOffset; /**< \brief Depth buffer offset */
+ int depthPitch; /**< \brief Depth buffer pitch */
+ int textureOffset; /**< \brief Texture area offset */
+ int textureSize; /**< \brief Texture area size */
+ int log2TexGran; /**< \brief Texture granularity in base 2 log */
+
+ unsigned int frontPitchOffset;
+ unsigned int backPitchOffset;
+ unsigned int depthPitchOffset;
+
+ int colorTiling; /**< \brief Enable color tiling */
+
+ int irq; /**< \brief IRQ number */
+ int page_flip_enable; /**< \brief Page Flip enable */
+ unsigned int gen_int_cntl;
+ unsigned int crtc_offset_cntl;
+
+} RADEONInfoRec, *RADEONInfoPtr;
+
+
+#endif /* _RADEON_H_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_dri.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_dri.c
new file mode 100644
index 000000000..7f83d868c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_dri.c
@@ -0,0 +1,1336 @@
+/**
+ * \file server/radeon_dri.c
+ * \brief File to perform the device-specific initialization tasks typically
+ * done in the X server.
+ *
+ * Here they are converted to run in the client (or perhaps a standalone
+ * process), and to work with the frame buffer device rather than the X
+ * server infrastructure.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include "driver.h"
+#include "drm.h"
+#include "memops.h"
+
+#include "radeon.h"
+#include "radeon_dri.h"
+#include "radeon_macros.h"
+#include "radeon_reg.h"
+#include "drm_sarea.h"
+
+static size_t radeon_drm_page_size;
+
+static int RadeonSetParam(const DRIDriverContext *ctx, int param, int value)
+{
+ drm_radeon_setparam_t sp;
+
+ memset(&sp, 0, sizeof(sp));
+ sp.param = param;
+ sp.value = value;
+
+ if (drmCommandWrite(ctx->drmFD, DRM_RADEON_SETPARAM, &sp, sizeof(sp))) {
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+ * \brief Wait for free FIFO entries.
+ *
+ * \param ctx display handle.
+ * \param entries number of free entries to wait.
+ *
+ * It polls the free entries from the chip until it reaches the requested value
+ * or a timeout (3000 tries) occurs. Aborts the program if the FIFO times out.
+ */
+static void RADEONWaitForFifo( const DRIDriverContext *ctx,
+ int entries )
+{
+ unsigned char *RADEONMMIO = ctx->MMIOAddress;
+ int i;
+
+ for (i = 0; i < 3000; i++) {
+ int fifo_slots =
+ INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK;
+ if (fifo_slots >= entries) return;
+ }
+
+ /* There are recoveries possible, but I haven't seen them work
+ * in practice:
+ */
+ fprintf(stderr, "FIFO timed out: %d entries, stat=0x%08x\n",
+ INREG(RADEON_RBBM_STATUS) & RADEON_RBBM_FIFOCNT_MASK,
+ INREG(RADEON_RBBM_STATUS));
+ exit(1);
+}
+
+/**
+ * \brief Read a PLL register.
+ *
+ * \param ctx display handle.
+ * \param addr PLL register index.
+ *
+ * \return value of the PLL register.
+ */
+static unsigned int RADEONINPLL( const DRIDriverContext *ctx, int addr)
+{
+ unsigned char *RADEONMMIO = ctx->MMIOAddress;
+ unsigned int data;
+
+ OUTREG8(RADEON_CLOCK_CNTL_INDEX, addr & 0x3f);
+ data = INREG(RADEON_CLOCK_CNTL_DATA);
+
+ return data;
+}
+
+/**
+ * \brief Reset graphics card to known state.
+ *
+ * \param ctx display handle.
+ *
+ * Resets the values of several Radeon registers.
+ */
+static void RADEONEngineReset( const DRIDriverContext *ctx )
+{
+ unsigned char *RADEONMMIO = ctx->MMIOAddress;
+ unsigned int clock_cntl_index;
+ unsigned int mclk_cntl;
+ unsigned int rbbm_soft_reset;
+ unsigned int host_path_cntl;
+ int i;
+
+ OUTREGP(RADEON_RB2D_DSTCACHE_CTLSTAT,
+ RADEON_RB2D_DC_FLUSH_ALL,
+ ~RADEON_RB2D_DC_FLUSH_ALL);
+ for (i = 0; i < 512; i++) {
+ if (!(INREG(RADEON_RB2D_DSTCACHE_CTLSTAT) & RADEON_RB2D_DC_BUSY))
+ break;
+ }
+
+ clock_cntl_index = INREG(RADEON_CLOCK_CNTL_INDEX);
+
+ mclk_cntl = INPLL(ctx, RADEON_MCLK_CNTL);
+ OUTPLL(RADEON_MCLK_CNTL, (mclk_cntl |
+ RADEON_FORCEON_MCLKA |
+ RADEON_FORCEON_MCLKB |
+ RADEON_FORCEON_YCLKA |
+ RADEON_FORCEON_YCLKB |
+ RADEON_FORCEON_MC |
+ RADEON_FORCEON_AIC));
+
+ /* Soft resetting HDP thru RBBM_SOFT_RESET register can cause some
+ * unexpected behaviour on some machines. Here we use
+ * RADEON_HOST_PATH_CNTL to reset it.
+ */
+ host_path_cntl = INREG(RADEON_HOST_PATH_CNTL);
+ rbbm_soft_reset = INREG(RADEON_RBBM_SOFT_RESET);
+
+ OUTREG(RADEON_RBBM_SOFT_RESET, (rbbm_soft_reset |
+ RADEON_SOFT_RESET_CP |
+ RADEON_SOFT_RESET_HI |
+ RADEON_SOFT_RESET_SE |
+ RADEON_SOFT_RESET_RE |
+ RADEON_SOFT_RESET_PP |
+ RADEON_SOFT_RESET_E2 |
+ RADEON_SOFT_RESET_RB));
+ INREG(RADEON_RBBM_SOFT_RESET);
+ OUTREG(RADEON_RBBM_SOFT_RESET, (rbbm_soft_reset &
+ (unsigned int) ~(RADEON_SOFT_RESET_CP |
+ RADEON_SOFT_RESET_HI |
+ RADEON_SOFT_RESET_SE |
+ RADEON_SOFT_RESET_RE |
+ RADEON_SOFT_RESET_PP |
+ RADEON_SOFT_RESET_E2 |
+ RADEON_SOFT_RESET_RB)));
+ INREG(RADEON_RBBM_SOFT_RESET);
+
+ OUTREG(RADEON_HOST_PATH_CNTL, host_path_cntl | RADEON_HDP_SOFT_RESET);
+ INREG(RADEON_HOST_PATH_CNTL);
+ OUTREG(RADEON_HOST_PATH_CNTL, host_path_cntl);
+
+ OUTREG(RADEON_RBBM_SOFT_RESET, rbbm_soft_reset);
+
+ OUTREG(RADEON_CLOCK_CNTL_INDEX, clock_cntl_index);
+ OUTPLL(RADEON_MCLK_CNTL, mclk_cntl);
+}
+
+/**
+ * \brief Restore the drawing engine.
+ *
+ * \param ctx display handle
+ *
+ * Resets the graphics card and sets initial values for several registers of
+ * the card's drawing engine.
+ *
+ * Turns on the radeon command processor engine (i.e., the ringbuffer).
+ */
+static int RADEONEngineRestore( const DRIDriverContext *ctx )
+{
+ RADEONInfoPtr info = ctx->driverPrivate;
+ unsigned char *RADEONMMIO = ctx->MMIOAddress;
+ int pitch64, datatype, dp_gui_master_cntl, err;
+
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ OUTREG(RADEON_RB3D_CNTL, 0);
+ RADEONEngineReset( ctx );
+
+ switch (ctx->bpp) {
+ case 16: datatype = 4; break;
+ case 32: datatype = 6; break;
+ default: return 0;
+ }
+
+ dp_gui_master_cntl =
+ ((datatype << RADEON_GMC_DST_DATATYPE_SHIFT)
+ | RADEON_GMC_CLR_CMP_CNTL_DIS);
+
+ pitch64 = ((ctx->shared.virtualWidth * (ctx->bpp / 8) + 0x3f)) >> 6;
+
+ RADEONWaitForFifo(ctx, 1);
+ OUTREG(RADEON_DEFAULT_OFFSET, ((INREG(RADEON_DEFAULT_OFFSET) & 0xC0000000)
+ | (pitch64 << 22)));
+
+ RADEONWaitForFifo(ctx, 1);
+ OUTREG(RADEON_SURFACE_CNTL, RADEON_SURF_TRANSLATION_DIS);
+
+ RADEONWaitForFifo(ctx, 1);
+ OUTREG(RADEON_DEFAULT_SC_BOTTOM_RIGHT, (RADEON_DEFAULT_SC_RIGHT_MAX
+ | RADEON_DEFAULT_SC_BOTTOM_MAX));
+
+ RADEONWaitForFifo(ctx, 1);
+ OUTREG(RADEON_DP_GUI_MASTER_CNTL, (dp_gui_master_cntl
+ | RADEON_GMC_BRUSH_SOLID_COLOR
+ | RADEON_GMC_SRC_DATATYPE_COLOR));
+
+ RADEONWaitForFifo(ctx, 7);
+ OUTREG(RADEON_DST_LINE_START, 0);
+ OUTREG(RADEON_DST_LINE_END, 0);
+ OUTREG(RADEON_DP_BRUSH_FRGD_CLR, 0xffffffff);
+ OUTREG(RADEON_DP_BRUSH_BKGD_CLR, 0);
+ OUTREG(RADEON_DP_SRC_FRGD_CLR, 0xffffffff);
+ OUTREG(RADEON_DP_SRC_BKGD_CLR, 0);
+ OUTREG(RADEON_DP_WRITE_MASK, 0xffffffff);
+ OUTREG(RADEON_AUX_SC_CNTL, 0);
+
+/* RADEONWaitForIdleMMIO(ctx); */
+ usleep(100);
+
+
+ OUTREG(RADEON_GEN_INT_CNTL, info->gen_int_cntl);
+ if (info->colorTiling)
+ info->crtc_offset_cntl |= RADEON_CRTC_TILE_EN;
+ OUTREG(RADEON_CRTC_OFFSET_CNTL, info->crtc_offset_cntl);
+
+ /* Initialize and start the CP if required */
+ if ((err = drmCommandNone(ctx->drmFD, DRM_RADEON_CP_START)) != 0) {
+ fprintf(stderr, "%s: CP start %d\n", __FUNCTION__, err);
+ return 0;
+ }
+
+ return 1;
+}
+
+
+/**
+ * \brief Shutdown the drawing engine.
+ *
+ * \param ctx display handle
+ *
+ * Turns off the command processor engine & restores the graphics card
+ * to a state that fbdev understands.
+ */
+static int RADEONEngineShutdown( const DRIDriverContext *ctx )
+{
+ drm_radeon_cp_stop_t stop;
+ int ret, i;
+
+ stop.flush = 1;
+ stop.idle = 1;
+
+ ret = drmCommandWrite(ctx->drmFD, DRM_RADEON_CP_STOP, &stop,
+ sizeof(drm_radeon_cp_stop_t));
+
+ if (ret == 0) {
+ return 0;
+ } else if (errno != EBUSY) {
+ return -errno;
+ }
+
+ stop.flush = 0;
+
+ i = 0;
+ do {
+ ret = drmCommandWrite(ctx->drmFD, DRM_RADEON_CP_STOP, &stop,
+ sizeof(drm_radeon_cp_stop_t));
+ } while (ret && errno == EBUSY && i++ < 10);
+
+ if (ret == 0) {
+ return 0;
+ } else if (errno != EBUSY) {
+ return -errno;
+ }
+
+ stop.idle = 0;
+
+ if (drmCommandWrite(ctx->drmFD, DRM_RADEON_CP_STOP,
+ &stop, sizeof(drm_radeon_cp_stop_t))) {
+ return -errno;
+ } else {
+ return 0;
+ }
+}
+
+/**
+ * \brief Compute base 2 logarithm.
+ *
+ * \param val value.
+ *
+ * \return base 2 logarithm of \p val.
+ */
+static int RADEONMinBits(int val)
+{
+ int bits;
+
+ if (!val) return 1;
+ for (bits = 0; val; val >>= 1, ++bits);
+ return bits;
+}
+
+/**
+ * \brief Initialize the AGP state
+ *
+ * \param ctx display handle.
+ * \param info driver private data.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Acquires and enables the AGP device. Reserves memory in the AGP space for
+ * the ring buffer, vertex buffers and textures. Initialize the Radeon
+ * registers to point to that memory and add client mappings.
+ */
+static int RADEONDRIAgpInit( const DRIDriverContext *ctx, RADEONInfoPtr info)
+{
+ unsigned char *RADEONMMIO = ctx->MMIOAddress;
+ unsigned long mode;
+ int ret;
+ int s, l;
+
+ if (drmAgpAcquire(ctx->drmFD) < 0) {
+ fprintf(stderr, "[gart] AGP not available\n");
+ return 0;
+ }
+
+ /* Modify the mode if the default mode is not appropriate for this
+ * particular combination of graphics card and AGP chipset.
+ */
+ mode = drmAgpGetMode(ctx->drmFD); /* Default mode */
+
+ /* Disable fast write entirely - too many lockups.
+ */
+ mode &= ~RADEON_AGP_MODE_MASK;
+ switch (ctx->agpmode) {
+ case 4: mode |= RADEON_AGP_4X_MODE;
+ case 2: mode |= RADEON_AGP_2X_MODE;
+ case 1: default: mode |= RADEON_AGP_1X_MODE;
+ }
+
+ if (drmAgpEnable(ctx->drmFD, mode) < 0) {
+ fprintf(stderr, "[gart] AGP not enabled\n");
+ drmAgpRelease(ctx->drmFD);
+ return 0;
+ }
+ else
+ fprintf(stderr, "[gart] AGP enabled at %dx\n", ctx->agpmode);
+
+ /* Workaround for some hardware bugs */
+ if (info->ChipFamily < CHIP_FAMILY_R200)
+ OUTREG(RADEON_AGP_CNTL, INREG(RADEON_AGP_CNTL) | 0x000e0000);
+
+ info->gartOffset = 0;
+
+ if ((ret = drmAgpAlloc(ctx->drmFD, info->gartSize*1024*1024, 0, NULL,
+ &info->gartMemHandle)) < 0) {
+ fprintf(stderr, "[gart] Out of memory (%d)\n", ret);
+ drmAgpRelease(ctx->drmFD);
+ return 0;
+ }
+ fprintf(stderr,
+ "[gart] %d kB allocated with handle 0x%08x\n",
+ info->gartSize*1024, (unsigned)info->gartMemHandle);
+
+ if (drmAgpBind(ctx->drmFD,
+ info->gartMemHandle, info->gartOffset) < 0) {
+ fprintf(stderr, "[gart] Could not bind\n");
+ drmAgpFree(ctx->drmFD, info->gartMemHandle);
+ drmAgpRelease(ctx->drmFD);
+ return 0;
+ }
+
+ /* Initialize the CP ring buffer data */
+ info->ringStart = info->gartOffset;
+ info->ringMapSize = info->ringSize*1024*1024 + radeon_drm_page_size;
+
+ info->ringReadOffset = info->ringStart + info->ringMapSize;
+ info->ringReadMapSize = radeon_drm_page_size;
+
+ /* Reserve space for vertex/indirect buffers */
+ info->bufStart = info->ringReadOffset + info->ringReadMapSize;
+ info->bufMapSize = info->bufSize*1024*1024;
+
+ /* Reserve the rest for AGP textures */
+ info->gartTexStart = info->bufStart + info->bufMapSize;
+ s = (info->gartSize*1024*1024 - info->gartTexStart);
+ l = RADEONMinBits((s-1) / RADEON_NR_TEX_REGIONS);
+ if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY;
+ info->gartTexMapSize = (s >> l) << l;
+ info->log2GARTTexGran = l;
+
+ if (drmAddMap(ctx->drmFD, info->ringStart, info->ringMapSize,
+ DRM_AGP, DRM_READ_ONLY, &info->ringHandle) < 0) {
+ fprintf(stderr, "[gart] Could not add ring mapping\n");
+ return 0;
+ }
+ fprintf(stderr, "[gart] ring handle = 0x%08x\n", info->ringHandle);
+
+
+ if (drmAddMap(ctx->drmFD, info->ringReadOffset, info->ringReadMapSize,
+ DRM_AGP, DRM_READ_ONLY, &info->ringReadPtrHandle) < 0) {
+ fprintf(stderr,
+ "[gart] Could not add ring read ptr mapping\n");
+ return 0;
+ }
+
+ fprintf(stderr,
+ "[gart] ring read ptr handle = 0x%08lx\n",
+ info->ringReadPtrHandle);
+
+ if (drmAddMap(ctx->drmFD, info->bufStart, info->bufMapSize,
+ DRM_AGP, 0, &info->bufHandle) < 0) {
+ fprintf(stderr,
+ "[gart] Could not add vertex/indirect buffers mapping\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[gart] vertex/indirect buffers handle = 0x%08x\n",
+ info->bufHandle);
+
+ if (drmAddMap(ctx->drmFD, info->gartTexStart, info->gartTexMapSize,
+ DRM_AGP, 0, &info->gartTexHandle) < 0) {
+ fprintf(stderr,
+ "[gart] Could not add AGP texture map mapping\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[gart] AGP texture map handle = 0x%08lx\n",
+ info->gartTexHandle);
+
+ /* Initialize Radeon's AGP registers */
+ /* Ring buffer is at AGP offset 0 */
+ OUTREG(RADEON_AGP_BASE, info->ringHandle);
+
+ return 1;
+}
+
+/* Initialize the PCI GART state. Request memory for use in PCI space,
+ * and initialize the Radeon registers to point to that memory.
+ */
+static int RADEONDRIPciInit(const DRIDriverContext *ctx, RADEONInfoPtr info)
+{
+ int ret;
+ int flags = DRM_READ_ONLY | DRM_LOCKED | DRM_KERNEL;
+ int s, l;
+
+ ret = drmScatterGatherAlloc(ctx->drmFD, info->gartSize*1024*1024,
+ &info->gartMemHandle);
+ if (ret < 0) {
+ fprintf(stderr, "[pci] Out of memory (%d)\n", ret);
+ return 0;
+ }
+ fprintf(stderr,
+ "[pci] %d kB allocated with handle 0x%08lx\n",
+ info->gartSize*1024, info->gartMemHandle);
+
+ info->gartOffset = 0;
+
+ /* Initialize the CP ring buffer data */
+ info->ringStart = info->gartOffset;
+ info->ringMapSize = info->ringSize*1024*1024 + radeon_drm_page_size;
+
+ info->ringReadOffset = info->ringStart + info->ringMapSize;
+ info->ringReadMapSize = radeon_drm_page_size;
+
+ /* Reserve space for vertex/indirect buffers */
+ info->bufStart = info->ringReadOffset + info->ringReadMapSize;
+ info->bufMapSize = info->bufSize*1024*1024;
+
+ /* Reserve the rest for AGP textures */
+ info->gartTexStart = info->bufStart + info->bufMapSize;
+ s = (info->gartSize*1024*1024 - info->gartTexStart);
+ l = RADEONMinBits((s-1) / RADEON_NR_TEX_REGIONS);
+ if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY;
+ info->gartTexMapSize = (s >> l) << l;
+ info->log2GARTTexGran = l;
+
+ if (drmAddMap(ctx->drmFD, info->ringStart, info->ringMapSize,
+ DRM_SCATTER_GATHER, flags, &info->ringHandle) < 0) {
+ fprintf(stderr,
+ "[pci] Could not add ring mapping\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[pci] ring handle = 0x%08x\n", info->ringHandle);
+
+ if (drmAddMap(ctx->drmFD, info->ringReadOffset, info->ringReadMapSize,
+ DRM_SCATTER_GATHER, flags, &info->ringReadPtrHandle) < 0) {
+ fprintf(stderr,
+ "[pci] Could not add ring read ptr mapping\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[pci] ring read ptr handle = 0x%08lx\n",
+ info->ringReadPtrHandle);
+
+ if (drmAddMap(ctx->drmFD, info->bufStart, info->bufMapSize,
+ DRM_SCATTER_GATHER, 0, &info->bufHandle) < 0) {
+ fprintf(stderr,
+ "[pci] Could not add vertex/indirect buffers mapping\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[pci] vertex/indirect buffers handle = 0x%08lx\n",
+ info->bufHandle);
+
+ if (drmAddMap(ctx->drmFD, info->gartTexStart, info->gartTexMapSize,
+ DRM_SCATTER_GATHER, 0, &info->gartTexHandle) < 0) {
+ fprintf(stderr,
+ "[pci] Could not add GART texture map mapping\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[pci] GART texture map handle = 0x%08x\n",
+ info->gartTexHandle);
+
+ return 1;
+}
+
+
+/**
+ * \brief Initialize the kernel data structures and enable the CP engine.
+ *
+ * \param ctx display handle.
+ * \param info driver private data.
+ *
+ * \return non-zero on success, or zero on failure.
+ *
+ * This function is a wrapper around the DRM_RADEON_CP_INIT command, passing
+ * all the parameters in a drm_radeon_init_t structure.
+ */
+static int RADEONDRIKernelInit( const DRIDriverContext *ctx,
+ RADEONInfoPtr info)
+{
+ int cpp = ctx->bpp / 8;
+ drm_radeon_init_t drmInfo;
+ int ret;
+
+ memset(&drmInfo, 0, sizeof(drm_radeon_init_t));
+
+ if ( (info->ChipFamily == CHIP_FAMILY_R200) ||
+ (info->ChipFamily == CHIP_FAMILY_RV250) ||
+ (info->ChipFamily == CHIP_FAMILY_M9) ||
+ (info->ChipFamily == CHIP_FAMILY_RV280) )
+ drmInfo.func = RADEON_INIT_R200_CP;
+ else
+ drmInfo.func = RADEON_INIT_CP;
+
+ /* This is the struct passed to the kernel module for its initialization */
+ drmInfo.sarea_priv_offset = sizeof(drm_sarea_t);
+ drmInfo.is_pci = ctx->isPCI;
+ drmInfo.cp_mode = RADEON_DEFAULT_CP_BM_MODE;
+ drmInfo.gart_size = info->gartSize*1024*1024;
+ drmInfo.ring_size = info->ringSize*1024*1024;
+ drmInfo.usec_timeout = 1000;
+ drmInfo.fb_bpp = ctx->bpp;
+ drmInfo.depth_bpp = ctx->bpp;
+ drmInfo.front_offset = info->frontOffset;
+ drmInfo.front_pitch = info->frontPitch * cpp;
+ drmInfo.back_offset = info->backOffset;
+ drmInfo.back_pitch = info->backPitch * cpp;
+ drmInfo.depth_offset = info->depthOffset;
+ drmInfo.depth_pitch = info->depthPitch * cpp;
+ drmInfo.fb_offset = info->LinearAddr;
+ drmInfo.mmio_offset = info->registerHandle;
+ drmInfo.ring_offset = info->ringHandle;
+ drmInfo.ring_rptr_offset = info->ringReadPtrHandle;
+ drmInfo.buffers_offset = info->bufHandle;
+ drmInfo.gart_textures_offset = info->gartTexHandle;
+
+ ret = drmCommandWrite(ctx->drmFD, DRM_RADEON_CP_INIT, &drmInfo,
+ sizeof(drm_radeon_init_t));
+
+ return ret >= 0;
+}
+
+
+/**
+ * \brief Initialize the AGP heap.
+ *
+ * \param ctx display handle.
+ * \param info driver private data.
+ *
+ * This function is a wrapper around the DRM_RADEON_INIT_HEAP command, passing
+ * all the parameters in a drm_radeon_mem_init_heap structure.
+ */
+static void RADEONDRIAgpHeapInit(const DRIDriverContext *ctx,
+ RADEONInfoPtr info)
+{
+ drm_radeon_mem_init_heap_t drmHeap;
+
+ /* Start up the simple memory manager for gart space */
+ drmHeap.region = RADEON_MEM_REGION_GART;
+ drmHeap.start = 0;
+ drmHeap.size = info->gartTexMapSize;
+
+ if (drmCommandWrite(ctx->drmFD, DRM_RADEON_INIT_HEAP,
+ &drmHeap, sizeof(drmHeap))) {
+ fprintf(stderr,
+ "[drm] Failed to initialized gart heap manager\n");
+ } else {
+ fprintf(stderr,
+ "[drm] Initialized kernel gart heap manager, %d\n",
+ info->gartTexMapSize);
+ }
+}
+
+/**
+ * \brief Add a map for the vertex buffers that will be accessed by any
+ * DRI-based clients.
+ *
+ * \param ctx display handle.
+ * \param info driver private data.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Calls drmAddBufs() with the previously allocated vertex buffers.
+ */
+static int RADEONDRIBufInit( const DRIDriverContext *ctx, RADEONInfoPtr info )
+{
+ /* Initialize vertex buffers */
+ info->bufNumBufs = drmAddBufs(ctx->drmFD,
+ info->bufMapSize / RADEON_BUFFER_SIZE,
+ RADEON_BUFFER_SIZE,
+ ctx->isPCI ? DRM_SG_BUFFER : DRM_AGP_BUFFER,
+ info->bufStart);
+
+ if (info->bufNumBufs <= 0) {
+ fprintf(stderr,
+ "[drm] Could not create vertex/indirect buffers list\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[drm] Added %d %d byte vertex/indirect buffers\n",
+ info->bufNumBufs, RADEON_BUFFER_SIZE);
+
+ return 1;
+}
+
+/**
+ * \brief Install an IRQ handler.
+ *
+ * \param ctx display handle.
+ * \param info driver private data.
+ *
+ * Attempts to install an IRQ handler via drmCtlInstHandler(), falling back to
+ * IRQ-free operation on failure.
+ */
+static void RADEONDRIIrqInit(const DRIDriverContext *ctx,
+ RADEONInfoPtr info)
+{
+ if (!info->irq) {
+ info->irq = drmGetInterruptFromBusID(ctx->drmFD,
+ ctx->pciBus,
+ ctx->pciDevice,
+ ctx->pciFunc);
+
+ if ((drmCtlInstHandler(ctx->drmFD, info->irq)) != 0) {
+ fprintf(stderr,
+ "[drm] failure adding irq handler, "
+ "there is a device already using that irq\n"
+ "[drm] falling back to irq-free operation\n");
+ info->irq = 0;
+ }
+ }
+
+ if (info->irq)
+ fprintf(stderr,
+ "[drm] dma control initialized, using IRQ %d\n",
+ info->irq);
+}
+
+static int RADEONCheckDRMVersion( const DRIDriverContext *ctx,
+ RADEONInfoPtr info )
+{
+ drmVersionPtr version;
+
+ version = drmGetVersion(ctx->drmFD);
+ if (version) {
+ int req_minor, req_patch;
+
+ /* Need 1.8.x for proper cleanup-on-client-exit behaviour.
+ */
+ req_minor = 8;
+ req_patch = 0;
+
+ if (version->version_major != 1 ||
+ version->version_minor < req_minor ||
+ (version->version_minor == req_minor &&
+ version->version_patchlevel < req_patch)) {
+ /* Incompatible drm version */
+ fprintf(stderr,
+ "[dri] RADEONDRIScreenInit failed because of a version "
+ "mismatch.\n"
+ "[dri] radeon.o kernel module version is %d.%d.%d "
+ "but version 1.%d.%d or newer is needed.\n"
+ "[dri] Disabling DRI.\n",
+ version->version_major,
+ version->version_minor,
+ version->version_patchlevel,
+ req_minor,
+ req_patch);
+ drmFreeVersion(version);
+ return 0;
+ }
+
+ info->drmMinor = version->version_minor;
+ drmFreeVersion(version);
+ }
+
+ return 1;
+}
+
+static int RADEONMemoryInit( const DRIDriverContext *ctx, RADEONInfoPtr info )
+{
+ int width_bytes = ctx->shared.virtualWidth * ctx->cpp;
+ int cpp = ctx->cpp;
+ int bufferSize = ((((ctx->shared.virtualHeight+15) & ~15) * width_bytes + RADEON_BUFFER_ALIGN) & ~RADEON_BUFFER_ALIGN);
+ int depthSize = ((((ctx->shared.virtualHeight+15) & ~15) * width_bytes
+ + RADEON_BUFFER_ALIGN) & ~RADEON_BUFFER_ALIGN);
+ int l;
+
+ info->frontOffset = 0;
+ info->frontPitch = ctx->shared.virtualWidth;
+
+ fprintf(stderr,
+ "Using %d MB AGP aperture\n", info->gartSize);
+ fprintf(stderr,
+ "Using %d MB for the ring buffer\n", info->ringSize);
+ fprintf(stderr,
+ "Using %d MB for vertex/indirect buffers\n", info->bufSize);
+ fprintf(stderr,
+ "Using %d MB for AGP textures\n", info->gartTexSize);
+
+ /* Front, back and depth buffers - everything else texture??
+ */
+ info->textureSize = ctx->shared.fbSize - 2 * bufferSize - depthSize;
+
+ if (ctx->colorTiling==1)
+ {
+ info->textureSize = ctx->shared.fbSize - ((ctx->shared.fbSize - info->textureSize + width_bytes * 16 - 1) / (width_bytes * 16)) * (width_bytes*16);
+ }
+
+ if (info->textureSize < 0)
+ return 0;
+
+ l = RADEONMinBits((info->textureSize-1) / RADEON_NR_TEX_REGIONS);
+ if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY;
+
+ /* Round the texture size up to the nearest whole number of
+ * texture regions. Again, be greedy about this, don't
+ * round down.
+ */
+ info->log2TexGran = l;
+ info->textureSize = (info->textureSize >> l) << l;
+
+ /* Set a minimum usable local texture heap size. This will fit
+ * two 256x256x32bpp textures.
+ */
+ if (info->textureSize < 512 * 1024) {
+ info->textureOffset = 0;
+ info->textureSize = 0;
+ }
+
+ /* Reserve space for textures */
+ if (ctx->colorTiling==1)
+ {
+ info->textureOffset = ((ctx->shared.fbSize - info->textureSize) /
+ (width_bytes * 16)) * (width_bytes*16);
+ }
+ else
+ {
+ info->textureOffset = ((ctx->shared.fbSize - info->textureSize +
+ RADEON_BUFFER_ALIGN) &
+ ~RADEON_BUFFER_ALIGN);
+ }
+ /* Reserve space for the shared depth
+ * buffer.
+ */
+ info->depthOffset = ((info->textureOffset - depthSize +
+ RADEON_BUFFER_ALIGN) &
+ ~RADEON_BUFFER_ALIGN);
+ info->depthPitch = ctx->shared.virtualWidth;
+
+ info->backOffset = ((info->depthOffset - bufferSize +
+ RADEON_BUFFER_ALIGN) &
+ ~RADEON_BUFFER_ALIGN);
+ info->backPitch = ctx->shared.virtualWidth;
+
+
+ fprintf(stderr,
+ "Will use back buffer at offset 0x%x\n",
+ info->backOffset);
+ fprintf(stderr,
+ "Will use depth buffer at offset 0x%x\n",
+ info->depthOffset);
+ fprintf(stderr,
+ "Will use %d kb for textures at offset 0x%x\n",
+ info->textureSize/1024, info->textureOffset);
+
+ info->frontPitchOffset = (((info->frontPitch * cpp / 64) << 22) |
+ (info->frontOffset >> 10));
+
+ info->backPitchOffset = (((info->backPitch * cpp / 64) << 22) |
+ (info->backOffset >> 10));
+
+ info->depthPitchOffset = (((info->depthPitch * cpp / 64) << 22) |
+ (info->depthOffset >> 10));
+
+ return 1;
+}
+
+static int RADEONColorTilingInit( const DRIDriverContext *ctx, RADEONInfoPtr info )
+{
+ int width_bytes = ctx->shared.virtualWidth * ctx->cpp;
+ int bufferSize = ((((ctx->shared.virtualHeight+15) & ~15) * width_bytes + RADEON_BUFFER_ALIGN)
+ & ~RADEON_BUFFER_ALIGN);
+ /* Setup color tiling */
+ if (info->drmMinor<14)
+ info->colorTiling=0;
+
+ if (info->colorTiling)
+ {
+
+ int colorTilingFlag;
+ drm_radeon_surface_alloc_t front,back;
+
+ RadeonSetParam(ctx, RADEON_SETPARAM_SWITCH_TILING, info->colorTiling ? 1 : 0);
+
+ /* Setup the surfaces */
+ if (info->ChipFamily < CHIP_FAMILY_R200)
+ colorTilingFlag=RADEON_SURF_TILE_COLOR_MACRO;
+ else
+ colorTilingFlag=R200_SURF_TILE_COLOR_MACRO;
+
+ front.address = info->frontOffset;
+ front.size = bufferSize;
+ front.flags = (width_bytes) | colorTilingFlag;
+ drmCommandWrite(ctx->drmFD, DRM_RADEON_SURF_ALLOC, &front,sizeof(front));
+
+ back.address = info->backOffset;
+ back.size = bufferSize;
+ back.flags = (width_bytes) | colorTilingFlag;
+ drmCommandWrite(ctx->drmFD, DRM_RADEON_SURF_ALLOC, &back,sizeof(back));
+
+ }
+ return 1;
+}
+
+
+
+/**
+ * Called at the start of each server generation.
+ *
+ * \param ctx display handle.
+ * \param info driver private data.
+ *
+ * \return non-zero on success, or zero on failure.
+ *
+ * Performs static frame buffer allocation. Opens the DRM device and add maps
+ * to the SAREA, framebuffer and MMIO regions. Fills in \p info with more
+ * information. Creates a \e server context to grab the lock for the
+ * initialization ioctls and calls the other initilization functions in this
+ * file. Starts the CP engine via the DRM_RADEON_CP_START command.
+ *
+ * Setups a RADEONDRIRec structure to be passed to radeon_dri.so for its
+ * initialization.
+ */
+static int RADEONScreenInit( DRIDriverContext *ctx, RADEONInfoPtr info )
+{
+ RADEONDRIPtr pRADEONDRI;
+ int err;
+
+ usleep(100);
+ /*assert(!ctx->IsClient);*/
+
+ {
+ int width_bytes = (ctx->shared.virtualWidth * ctx->cpp);
+ int maxy = ctx->shared.fbSize / width_bytes;
+
+
+ if (maxy <= ctx->shared.virtualHeight * 3) {
+ fprintf(stderr,
+ "Static buffer allocation failed -- "
+ "need at least %d kB video memory (have %d kB)\n",
+ (ctx->shared.virtualWidth * ctx->shared.virtualHeight *
+ ctx->cpp * 3 + 1023) / 1024,
+ ctx->shared.fbSize / 1024);
+ return 0;
+ }
+ }
+
+
+ if (info->ChipFamily >= CHIP_FAMILY_R300) {
+ fprintf(stderr,
+ "Direct rendering not yet supported on "
+ "Radeon 9700 and newer cards\n");
+ return 0;
+ }
+
+ radeon_drm_page_size = getpagesize();
+
+ info->registerSize = ctx->MMIOSize;
+ ctx->shared.SAREASize = SAREA_MAX;
+
+ /* Note that drmOpen will try to load the kernel module, if needed. */
+ ctx->drmFD = drmOpen("radeon", NULL );
+ if (ctx->drmFD < 0) {
+ fprintf(stderr, "[drm] drmOpen failed\n");
+ return 0;
+ }
+
+ if ((err = drmSetBusid(ctx->drmFD, ctx->pciBusID)) < 0) {
+ fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n",
+ ctx->drmFD, ctx->pciBusID, strerror(-err));
+ return 0;
+ }
+
+ if (drmAddMap( ctx->drmFD,
+ 0,
+ ctx->shared.SAREASize,
+ DRM_SHM,
+ DRM_CONTAINS_LOCK,
+ &ctx->shared.hSAREA) < 0)
+ {
+ fprintf(stderr, "[drm] drmAddMap failed\n");
+ return 0;
+ }
+ fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n",
+ ctx->shared.SAREASize, ctx->shared.hSAREA);
+
+ if (drmMap( ctx->drmFD,
+ ctx->shared.hSAREA,
+ ctx->shared.SAREASize,
+ (drmAddressPtr)(&ctx->pSAREA)) < 0)
+ {
+ fprintf(stderr, "[drm] drmMap failed\n");
+ return 0;
+ }
+ memset(ctx->pSAREA, 0, ctx->shared.SAREASize);
+ fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n",
+ ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize);
+
+ /* Need to AddMap the framebuffer and mmio regions here:
+ */
+ if (drmAddMap( ctx->drmFD,
+ (drm_handle_t)ctx->FBStart,
+ ctx->FBSize,
+ DRM_FRAME_BUFFER,
+#ifndef _EMBEDDED
+ 0,
+#else
+ DRM_READ_ONLY,
+#endif
+ &ctx->shared.hFrameBuffer) < 0)
+ {
+ fprintf(stderr, "[drm] drmAddMap framebuffer failed\n");
+ return 0;
+ }
+
+ fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n",
+ ctx->shared.hFrameBuffer);
+
+
+
+ if (drmAddMap(ctx->drmFD,
+ ctx->MMIOStart,
+ ctx->MMIOSize,
+ DRM_REGISTERS,
+ DRM_READ_ONLY,
+ &info->registerHandle) < 0) {
+ fprintf(stderr, "[drm] drmAddMap mmio failed\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[drm] register handle = 0x%08lx\n", info->registerHandle);
+
+ /* Check the radeon DRM version */
+ if (!RADEONCheckDRMVersion(ctx, info)) {
+ return 0;
+ }
+
+ if (ctx->isPCI) {
+ /* Initialize PCI */
+ if (!RADEONDRIPciInit(ctx, info))
+ return 0;
+ }
+ else {
+ /* Initialize AGP */
+ if (!RADEONDRIAgpInit(ctx, info))
+ return 0;
+ }
+
+ /* Memory manager setup */
+ if (!RADEONMemoryInit(ctx, info)) {
+ return 0;
+ }
+
+ /* Create a 'server' context so we can grab the lock for
+ * initialization ioctls.
+ */
+ if ((err = drmCreateContext(ctx->drmFD, &ctx->serverContext)) != 0) {
+ fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err);
+ return 0;
+ }
+
+ DRM_LOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext, 0);
+
+ /* Initialize the kernel data structures */
+ if (!RADEONDRIKernelInit(ctx, info)) {
+ fprintf(stderr, "RADEONDRIKernelInit failed\n");
+ DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext);
+ return 0;
+ }
+
+ /* Initialize the vertex buffers list */
+ if (!RADEONDRIBufInit(ctx, info)) {
+ fprintf(stderr, "RADEONDRIBufInit failed\n");
+ DRM_UNLOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext);
+ return 0;
+ }
+
+ RADEONColorTilingInit(ctx, info);
+
+ /* Initialize IRQ */
+ RADEONDRIIrqInit(ctx, info);
+
+ /* Initialize kernel gart memory manager */
+ RADEONDRIAgpHeapInit(ctx, info);
+
+ fprintf(stderr,"color tiling %sabled\n", info->colorTiling?"en":"dis");
+ fprintf(stderr,"page flipping %sabled\n", info->page_flip_enable?"en":"dis");
+ /* Initialize the SAREA private data structure */
+ {
+ drm_radeon_sarea_t *pSAREAPriv;
+ pSAREAPriv = (drm_radeon_sarea_t *)(((char*)ctx->pSAREA) +
+ sizeof(drm_sarea_t));
+ memset(pSAREAPriv, 0, sizeof(*pSAREAPriv));
+ pSAREAPriv->pfState = info->page_flip_enable;
+ }
+
+
+ /* Quick hack to clear the front & back buffers. Could also use
+ * the clear ioctl to do this, but would need to setup hw state
+ * first.
+ */
+ drimemsetio((char *)ctx->FBAddress + info->frontOffset,
+ 0,
+ info->frontPitch * ctx->cpp * ctx->shared.virtualHeight );
+
+ drimemsetio((char *)ctx->FBAddress + info->backOffset,
+ 0,
+ info->backPitch * ctx->cpp * ctx->shared.virtualHeight );
+
+ /* This is the struct passed to radeon_dri.so for its initialization */
+ ctx->driverClientMsg = malloc(sizeof(RADEONDRIRec));
+ ctx->driverClientMsgSize = sizeof(RADEONDRIRec);
+ pRADEONDRI = (RADEONDRIPtr)ctx->driverClientMsg;
+ pRADEONDRI->deviceID = info->Chipset;
+ pRADEONDRI->width = ctx->shared.virtualWidth;
+ pRADEONDRI->height = ctx->shared.virtualHeight;
+ pRADEONDRI->depth = ctx->bpp; /* XXX: depth */
+ pRADEONDRI->bpp = ctx->bpp;
+ pRADEONDRI->IsPCI = ctx->isPCI;
+ pRADEONDRI->AGPMode = ctx->agpmode;
+ pRADEONDRI->frontOffset = info->frontOffset;
+ pRADEONDRI->frontPitch = info->frontPitch;
+ pRADEONDRI->backOffset = info->backOffset;
+ pRADEONDRI->backPitch = info->backPitch;
+ pRADEONDRI->depthOffset = info->depthOffset;
+ pRADEONDRI->depthPitch = info->depthPitch;
+ pRADEONDRI->textureOffset = info->textureOffset;
+ pRADEONDRI->textureSize = info->textureSize;
+ pRADEONDRI->log2TexGran = info->log2TexGran;
+ pRADEONDRI->registerHandle = info->registerHandle;
+ pRADEONDRI->registerSize = info->registerSize;
+ pRADEONDRI->statusHandle = info->ringReadPtrHandle;
+ pRADEONDRI->statusSize = info->ringReadMapSize;
+ pRADEONDRI->gartTexHandle = info->gartTexHandle;
+ pRADEONDRI->gartTexMapSize = info->gartTexMapSize;
+ pRADEONDRI->log2GARTTexGran = info->log2GARTTexGran;
+ pRADEONDRI->gartTexOffset = info->gartTexStart;
+ pRADEONDRI->sarea_priv_offset = sizeof(drm_sarea_t);
+
+ /* Don't release the lock now - let the VT switch handler do it. */
+
+ return 1;
+}
+
+
+/**
+ * \brief Get Radeon chip family from chipset number.
+ *
+ * \param info driver private data.
+ *
+ * \return non-zero on success, or zero on failure.
+ *
+ * Called by radeonInitFBDev() to set RADEONInfoRec::ChipFamily
+ * according to the value of RADEONInfoRec::Chipset. Fails if the
+ * chipset is unrecognized or not appropriate for this driver (i.e., not
+ * an r100 style radeon)
+ */
+static int get_chipfamily_from_chipset( RADEONInfoPtr info )
+{
+ switch (info->Chipset) {
+ case PCI_CHIP_RADEON_LY:
+ case PCI_CHIP_RADEON_LZ:
+ info->ChipFamily = CHIP_FAMILY_M6;
+ break;
+
+ case PCI_CHIP_RADEON_QY:
+ case PCI_CHIP_RADEON_QZ:
+ info->ChipFamily = CHIP_FAMILY_VE;
+ break;
+
+ case PCI_CHIP_R200_QL:
+ case PCI_CHIP_R200_QN:
+ case PCI_CHIP_R200_QO:
+ case PCI_CHIP_R200_Ql:
+ case PCI_CHIP_R200_BB:
+ info->ChipFamily = CHIP_FAMILY_R200;
+ break;
+
+ case PCI_CHIP_RV200_QW: /* RV200 desktop */
+ case PCI_CHIP_RV200_QX:
+ info->ChipFamily = CHIP_FAMILY_RV200;
+ break;
+
+ case PCI_CHIP_RADEON_LW:
+ case PCI_CHIP_RADEON_LX:
+ info->ChipFamily = CHIP_FAMILY_M7;
+ break;
+
+ case PCI_CHIP_RV250_Id:
+ case PCI_CHIP_RV250_Ie:
+ case PCI_CHIP_RV250_If:
+ case PCI_CHIP_RV250_Ig:
+ info->ChipFamily = CHIP_FAMILY_RV250;
+ break;
+
+ case PCI_CHIP_RV250_Ld:
+ case PCI_CHIP_RV250_Le:
+ case PCI_CHIP_RV250_Lf:
+ case PCI_CHIP_RV250_Lg:
+ info->ChipFamily = CHIP_FAMILY_M9;
+ break;
+
+ case PCI_CHIP_RV280_Y_:
+ case PCI_CHIP_RV280_Ya:
+ case PCI_CHIP_RV280_Yb:
+ case PCI_CHIP_RV280_Yc:
+ info->ChipFamily = CHIP_FAMILY_RV280;
+ break;
+
+ case PCI_CHIP_R300_ND:
+ case PCI_CHIP_R300_NE:
+ case PCI_CHIP_R300_NF:
+ case PCI_CHIP_R300_NG:
+ info->ChipFamily = CHIP_FAMILY_R300;
+ break;
+
+ default:
+ /* Original Radeon/7200 */
+ info->ChipFamily = CHIP_FAMILY_RADEON;
+ }
+
+ return 1;
+}
+
+
+/**
+ * \brief Validate the fbdev mode.
+ *
+ * \param ctx display handle.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Saves some registers and returns 1.
+ *
+ * \sa radeonValidateMode().
+ */
+static int radeonValidateMode( const DRIDriverContext *ctx )
+{
+ unsigned char *RADEONMMIO = ctx->MMIOAddress;
+ RADEONInfoPtr info = ctx->driverPrivate;
+
+ info->gen_int_cntl = INREG(RADEON_GEN_INT_CNTL);
+ info->crtc_offset_cntl = INREG(RADEON_CRTC_OFFSET_CNTL);
+
+ if (info->colorTiling)
+ info->crtc_offset_cntl |= RADEON_CRTC_TILE_EN;
+ return 1;
+}
+
+
+/**
+ * \brief Examine mode returned by fbdev.
+ *
+ * \param ctx display handle.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Restores registers that fbdev has clobbered and returns 1.
+ *
+ * \sa radeonValidateMode().
+ */
+static int radeonPostValidateMode( const DRIDriverContext *ctx )
+{
+ unsigned char *RADEONMMIO = ctx->MMIOAddress;
+ RADEONInfoPtr info = ctx->driverPrivate;
+
+ RADEONColorTilingInit( ctx, info);
+ OUTREG(RADEON_GEN_INT_CNTL, info->gen_int_cntl);
+ if (info->colorTiling)
+ info->crtc_offset_cntl |= RADEON_CRTC_TILE_EN;
+ OUTREG(RADEON_CRTC_OFFSET_CNTL, info->crtc_offset_cntl);
+
+ return 1;
+}
+
+
+/**
+ * \brief Initialize the framebuffer device mode
+ *
+ * \param ctx display handle.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Fills in \p info with some default values and some information from \p ctx
+ * and then calls RADEONScreenInit() for the screen initialization.
+ *
+ * Before exiting clears the framebuffer memory accessing it directly.
+ */
+static int radeonInitFBDev( DRIDriverContext *ctx )
+{
+ RADEONInfoPtr info = calloc(1, sizeof(*info));
+
+ {
+ int dummy = ctx->shared.virtualWidth;
+
+ if (ctx->colorTiling==1)
+ {
+ switch (ctx->bpp / 8) {
+ case 1: dummy = (ctx->shared.virtualWidth + 255) & ~255; break;
+ case 2: dummy = (ctx->shared.virtualWidth + 127) & ~127; break;
+ case 3:
+ case 4: dummy = (ctx->shared.virtualWidth + 63) & ~63; break;
+ }
+ } else {
+ switch (ctx->bpp / 8) {
+ case 1: dummy = (ctx->shared.virtualWidth + 127) & ~127; break;
+ case 2: dummy = (ctx->shared.virtualWidth + 31) & ~31; break;
+ case 3:
+ case 4: dummy = (ctx->shared.virtualWidth + 15) & ~15; break;
+ }
+ }
+
+ ctx->shared.virtualWidth = dummy;
+ }
+
+ fprintf(stderr,"shared virtual width is %d\n", ctx->shared.virtualWidth);
+ ctx->driverPrivate = (void *)info;
+
+ info->gartFastWrite = RADEON_DEFAULT_AGP_FAST_WRITE;
+ info->gartSize = RADEON_DEFAULT_AGP_SIZE;
+ info->gartTexSize = RADEON_DEFAULT_AGP_TEX_SIZE;
+ info->bufSize = RADEON_DEFAULT_BUFFER_SIZE;
+ info->ringSize = RADEON_DEFAULT_RING_SIZE;
+ info->page_flip_enable = RADEON_DEFAULT_PAGE_FLIP;
+ info->colorTiling = ctx->colorTiling;
+
+ info->Chipset = ctx->chipset;
+
+ if (!get_chipfamily_from_chipset( info )) {
+ fprintf(stderr, "Unknown or non-radeon chipset -- cannot continue\n");
+ fprintf(stderr, "==> Verify PCI BusID is correct in miniglx.conf\n");
+ return 0;
+ }
+
+ info->frontPitch = ctx->shared.virtualWidth;
+ info->LinearAddr = ctx->FBStart & 0xfc000000;
+
+
+ if (!RADEONScreenInit( ctx, info ))
+ return 0;
+
+
+ return 1;
+}
+
+
+/**
+ * \brief The screen is being closed, so clean up any state and free any
+ * resources used by the DRI.
+ *
+ * \param ctx display handle.
+ *
+ * Unmaps the SAREA, closes the DRM device file descriptor and frees the driver
+ * private data.
+ */
+static void radeonHaltFBDev( DRIDriverContext *ctx )
+{
+ drmUnmap( ctx->pSAREA, ctx->shared.SAREASize );
+ drmClose(ctx->drmFD);
+
+ if (ctx->driverPrivate) {
+ free(ctx->driverPrivate);
+ ctx->driverPrivate = 0;
+ }
+}
+
+
+extern void radeonNotifyFocus( int );
+
+/**
+ * \brief Exported driver interface for Mini GLX.
+ *
+ * \sa DRIDriverRec.
+ */
+const struct DRIDriverRec __driDriver = {
+ radeonValidateMode,
+ radeonPostValidateMode,
+ radeonInitFBDev,
+ radeonHaltFBDev,
+ RADEONEngineShutdown,
+ RADEONEngineRestore,
+#ifndef _EMBEDDED
+ 0,
+#else
+ radeonNotifyFocus,
+#endif
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_dri.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_dri.h
new file mode 100644
index 000000000..ecd532333
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_dri.h
@@ -0,0 +1,116 @@
+/**
+ * \file server/radeon_dri.h
+ * \brief Radeon server-side structures.
+ *
+ * \author Kevin E. Martin <martin@xfree86.org>
+ * \author Rickard E. Faith <faith@valinux.com>
+ */
+
+/*
+ * Copyright 2000 ATI Technologies Inc., Markham, Ontario,
+ * VA Linux Systems Inc., Fremont, 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 on 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS 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.
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.h,v 1.3 2002/04/24 16:20:40 martin Exp $ */
+
+#ifndef _RADEON_DRI_
+#define _RADEON_DRI_
+
+#include "xf86drm.h"
+#include "drm.h"
+#include "radeon_drm.h"
+
+/* DRI Driver defaults */
+#define RADEON_DEFAULT_CP_PIO_MODE RADEON_CSQ_PRIPIO_INDPIO
+#define RADEON_DEFAULT_CP_BM_MODE RADEON_CSQ_PRIBM_INDBM
+#define RADEON_DEFAULT_AGP_MODE 1
+#define RADEON_DEFAULT_AGP_FAST_WRITE 0
+#define RADEON_DEFAULT_AGP_SIZE 8 /* MB (must be 2^n and > 4MB) */
+#define RADEON_DEFAULT_RING_SIZE 1 /* MB (must be page aligned) */
+#define RADEON_DEFAULT_BUFFER_SIZE 2 /* MB (must be page aligned) */
+#define RADEON_DEFAULT_AGP_TEX_SIZE 1 /* MB (must be page aligned) */
+#define RADEON_DEFAULT_CP_TIMEOUT 10000 /* usecs */
+#define RADEON_DEFAULT_PAGE_FLIP 0 /* page flipping diabled */
+#define RADEON_BUFFER_ALIGN 0x00000fff
+
+/**
+ * \brief Radeon DRI driver private data.
+ */
+typedef struct {
+ /**
+ * \name DRI screen private data
+ */
+ /*@{*/
+ int deviceID; /**< \brief PCI device ID */
+ int width; /**< \brief width in pixels of display */
+ int height; /**< \brief height in scanlines of display */
+ int depth; /**< \brief depth of display (8, 15, 16, 24) */
+ int bpp; /**< \brief bit depth of display (8, 16, 24, 32) */
+
+ int IsPCI; /**< \brief is current card a PCI card? */
+ int AGPMode; /**< \brief AGP mode */
+
+ int frontOffset; /**< \brief front buffer offset */
+ int frontPitch; /**< \brief front buffer pitch */
+ int backOffset; /**< \brief shared back buffer offset */
+ int backPitch; /**< \brief shared back buffer pitch */
+ int depthOffset; /**< \brief shared depth buffer offset */
+ int depthPitch; /**< \brief shared depth buffer pitch */
+ int textureOffset; /**< \brief start of texture data in frame buffer */
+ int textureSize; /**< \brief size of texture date */
+ int log2TexGran; /**< \brief log2 texture granularity */
+ /*@}*/
+
+ /**
+ * \name MMIO register data
+ */
+ /*@{*/
+ drm_handle_t registerHandle; /**< \brief MMIO register map size */
+ drmSize registerSize; /**< \brief MMIO register map handle */
+ /*@}*/
+
+ /**
+ * \name CP in-memory status information
+ */
+ /*@{*/
+ drm_handle_t statusHandle; /**< \brief status map handle */
+ drmSize statusSize; /**< \brief status map size */
+ /*@}*/
+
+ /**
+ * \name CP AGP Texture data
+ */
+ /*@{*/
+ drm_handle_t gartTexHandle; /**< \brief AGP texture area map handle */
+ drmSize gartTexMapSize; /**< \brief AGP texture area map size */
+ int log2GARTTexGran; /**< \brief AGP texture granularity in log base 2 */
+ int gartTexOffset; /**< \brief AGP texture area offset in AGP space */
+ /*@}*/
+
+ unsigned int sarea_priv_offset; /**< \brief offset of the private SAREA data*/
+} RADEONDRIRec, *RADEONDRIPtr;
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_egl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_egl.c
new file mode 100644
index 000000000..736fed5b5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_egl.c
@@ -0,0 +1,978 @@
+/*
+ * EGL driver for radeon_dri.so
+ */
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+
+#include "eglconfig.h"
+#include "eglcontext.h"
+#include "egldisplay.h"
+#include "egldriver.h"
+#include "eglglobals.h"
+#include "eglmode.h"
+#include "eglscreen.h"
+#include "eglsurface.h"
+#include "egldri.h"
+
+#include "mtypes.h"
+#include "memops.h"
+#include "drm.h"
+#include "drm_sarea.h"
+#include "radeon_drm.h"
+#include "radeon_dri.h"
+#include "radeon.h"
+
+static size_t radeon_drm_page_size;
+
+/**
+ * radeon driver-specific driver class derived from _EGLDriver
+ */
+typedef struct radeon_driver
+{
+ _EGLDriver Base; /* base class/object */
+ GLuint radeonStuff;
+} radeonDriver;
+
+static int RADEONCheckDRMVersion( driDisplay *disp,
+ RADEONInfoPtr info )
+{
+ drmVersionPtr version;
+
+ version = drmGetVersion(disp->drmFD);
+ if (version) {
+ int req_minor, req_patch;
+
+ /* Need 1.8.x for proper cleanup-on-client-exit behaviour.
+ */
+ req_minor = 8;
+ req_patch = 0;
+
+ if (version->version_major != 1 ||
+ version->version_minor < req_minor ||
+ (version->version_minor == req_minor &&
+ version->version_patchlevel < req_patch)) {
+ /* Incompatible drm version */
+ fprintf(stderr,
+ "[dri] RADEONDRIScreenInit failed because of a version "
+ "mismatch.\n"
+ "[dri] radeon.o kernel module version is %d.%d.%d "
+ "but version 1.%d.%d or newer is needed.\n"
+ "[dri] Disabling DRI.\n",
+ version->version_major,
+ version->version_minor,
+ version->version_patchlevel,
+ req_minor,
+ req_patch);
+ drmFreeVersion(version);
+ return 0;
+ }
+
+ info->drmMinor = version->version_minor;
+ drmFreeVersion(version);
+ }
+
+ return 1;
+}
+
+
+/**
+ * \brief Compute base 2 logarithm.
+ *
+ * \param val value.
+ *
+ * \return base 2 logarithm of \p val.
+ */
+static int RADEONMinBits(int val)
+{
+ int bits;
+
+ if (!val) return 1;
+ for (bits = 0; val; val >>= 1, ++bits);
+ return bits;
+}
+
+
+/* Initialize the PCI GART state. Request memory for use in PCI space,
+ * and initialize the Radeon registers to point to that memory.
+ */
+static int RADEONDRIPciInit(driDisplay *disp, RADEONInfoPtr info)
+{
+ int ret;
+ int flags = DRM_READ_ONLY | DRM_LOCKED | DRM_KERNEL;
+ int s, l;
+
+ ret = drmScatterGatherAlloc(disp->drmFD, info->gartSize*1024*1024,
+ &info->gartMemHandle);
+ if (ret < 0) {
+ fprintf(stderr, "[pci] Out of memory (%d)\n", ret);
+ return 0;
+ }
+ fprintf(stderr,
+ "[pci] %d kB allocated with handle 0x%04lx\n",
+ info->gartSize*1024, info->gartMemHandle);
+
+ info->gartOffset = 0;
+
+ /* Initialize the CP ring buffer data */
+ info->ringStart = info->gartOffset;
+ info->ringMapSize = info->ringSize*1024*1024 + radeon_drm_page_size;
+
+ info->ringReadOffset = info->ringStart + info->ringMapSize;
+ info->ringReadMapSize = radeon_drm_page_size;
+
+ /* Reserve space for vertex/indirect buffers */
+ info->bufStart = info->ringReadOffset + info->ringReadMapSize;
+ info->bufMapSize = info->bufSize*1024*1024;
+
+ /* Reserve the rest for AGP textures */
+ info->gartTexStart = info->bufStart + info->bufMapSize;
+ s = (info->gartSize*1024*1024 - info->gartTexStart);
+ l = RADEONMinBits((s-1) / RADEON_NR_TEX_REGIONS);
+ if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY;
+ info->gartTexMapSize = (s >> l) << l;
+ info->log2GARTTexGran = l;
+
+ if (drmAddMap(disp->drmFD, info->ringStart, info->ringMapSize,
+ DRM_SCATTER_GATHER, flags, &info->ringHandle) < 0) {
+ fprintf(stderr,
+ "[pci] Could not add ring mapping\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[pci] ring handle = 0x%08lx\n", info->ringHandle);
+
+ if (drmAddMap(disp->drmFD, info->ringReadOffset, info->ringReadMapSize,
+ DRM_SCATTER_GATHER, flags, &info->ringReadPtrHandle) < 0) {
+ fprintf(stderr,
+ "[pci] Could not add ring read ptr mapping\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[pci] ring read ptr handle = 0x%08lx\n",
+ info->ringReadPtrHandle);
+
+ if (drmAddMap(disp->drmFD, info->bufStart, info->bufMapSize,
+ DRM_SCATTER_GATHER, 0, &info->bufHandle) < 0) {
+ fprintf(stderr,
+ "[pci] Could not add vertex/indirect buffers mapping\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[pci] vertex/indirect buffers handle = 0x%08lx\n",
+ info->bufHandle);
+
+ if (drmAddMap(disp->drmFD, info->gartTexStart, info->gartTexMapSize,
+ DRM_SCATTER_GATHER, 0, &info->gartTexHandle) < 0) {
+ fprintf(stderr,
+ "[pci] Could not add GART texture map mapping\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[pci] GART texture map handle = 0x%08lx\n",
+ info->gartTexHandle);
+
+ return 1;
+}
+
+
+/**
+ * \brief Initialize the AGP state
+ *
+ * \param ctx display handle.
+ * \param info driver private data.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Acquires and enables the AGP device. Reserves memory in the AGP space for
+ * the ring buffer, vertex buffers and textures. Initialize the Radeon
+ * registers to point to that memory and add client mappings.
+ */
+static int RADEONDRIAgpInit( driDisplay *disp, RADEONInfoPtr info)
+{
+ int mode, ret;
+ int s, l;
+ int agpmode = 1;
+
+ if (drmAgpAcquire(disp->drmFD) < 0) {
+ fprintf(stderr, "[gart] AGP not available\n");
+ return 0;
+ }
+
+ mode = drmAgpGetMode(disp->drmFD); /* Default mode */
+ /* Disable fast write entirely - too many lockups.
+ */
+ mode &= ~RADEON_AGP_MODE_MASK;
+ switch (agpmode) {
+ case 4: mode |= RADEON_AGP_4X_MODE;
+ case 2: mode |= RADEON_AGP_2X_MODE;
+ case 1: default: mode |= RADEON_AGP_1X_MODE;
+ }
+
+ if (drmAgpEnable(disp->drmFD, mode) < 0) {
+ fprintf(stderr, "[gart] AGP not enabled\n");
+ drmAgpRelease(disp->drmFD);
+ return 0;
+ }
+
+#if 0
+ /* Workaround for some hardware bugs */
+ if (info->ChipFamily < CHIP_FAMILY_R200)
+ OUTREG(RADEON_AGP_CNTL, INREG(RADEON_AGP_CNTL) | 0x000e0000);
+#endif
+ info->gartOffset = 0;
+
+ if ((ret = drmAgpAlloc(disp->drmFD, info->gartSize*1024*1024, 0, NULL,
+ &info->gartMemHandle)) < 0) {
+ fprintf(stderr, "[gart] Out of memory (%d)\n", ret);
+ drmAgpRelease(disp->drmFD);
+ return 0;
+ }
+ fprintf(stderr,
+ "[gart] %d kB allocated with handle 0x%08x\n",
+ info->gartSize*1024, (unsigned)info->gartMemHandle);
+
+ if (drmAgpBind(disp->drmFD,
+ info->gartMemHandle, info->gartOffset) < 0) {
+ fprintf(stderr, "[gart] Could not bind\n");
+ drmAgpFree(disp->drmFD, info->gartMemHandle);
+ drmAgpRelease(disp->drmFD);
+ return 0;
+ }
+
+ /* Initialize the CP ring buffer data */
+ info->ringStart = info->gartOffset;
+ info->ringMapSize = info->ringSize*1024*1024 + radeon_drm_page_size;
+
+ info->ringReadOffset = info->ringStart + info->ringMapSize;
+ info->ringReadMapSize = radeon_drm_page_size;
+
+ /* Reserve space for vertex/indirect buffers */
+ info->bufStart = info->ringReadOffset + info->ringReadMapSize;
+ info->bufMapSize = info->bufSize*1024*1024;
+
+ /* Reserve the rest for AGP textures */
+ info->gartTexStart = info->bufStart + info->bufMapSize;
+ s = (info->gartSize*1024*1024 - info->gartTexStart);
+ l = RADEONMinBits((s-1) / RADEON_NR_TEX_REGIONS);
+ if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY;
+ info->gartTexMapSize = (s >> l) << l;
+ info->log2GARTTexGran = l;
+
+ if (drmAddMap(disp->drmFD, info->ringStart, info->ringMapSize,
+ DRM_AGP, DRM_READ_ONLY, &info->ringHandle) < 0) {
+ fprintf(stderr, "[gart] Could not add ring mapping\n");
+ return 0;
+ }
+ fprintf(stderr, "[gart] ring handle = 0x%08lx\n", info->ringHandle);
+
+
+ if (drmAddMap(disp->drmFD, info->ringReadOffset, info->ringReadMapSize,
+ DRM_AGP, DRM_READ_ONLY, &info->ringReadPtrHandle) < 0) {
+ fprintf(stderr,
+ "[gart] Could not add ring read ptr mapping\n");
+ return 0;
+ }
+
+ fprintf(stderr,
+ "[gart] ring read ptr handle = 0x%08lx\n",
+ info->ringReadPtrHandle);
+
+ if (drmAddMap(disp->drmFD, info->bufStart, info->bufMapSize,
+ DRM_AGP, 0, &info->bufHandle) < 0) {
+ fprintf(stderr,
+ "[gart] Could not add vertex/indirect buffers mapping\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[gart] vertex/indirect buffers handle = 0x%08lx\n",
+ info->bufHandle);
+
+ if (drmAddMap(disp->drmFD, info->gartTexStart, info->gartTexMapSize,
+ DRM_AGP, 0, &info->gartTexHandle) < 0) {
+ fprintf(stderr,
+ "[gart] Could not add AGP texture map mapping\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[gart] AGP texture map handle = 0x%08lx\n",
+ info->gartTexHandle);
+
+ return 1;
+}
+
+
+static int RADEONMemoryInit( driDisplay *disp, RADEONInfoPtr info )
+{
+ int width_bytes = disp->virtualWidth * disp->cpp;
+ int cpp = disp->cpp;
+ int bufferSize = ((disp->virtualHeight * width_bytes
+ + RADEON_BUFFER_ALIGN)
+ & ~RADEON_BUFFER_ALIGN);
+ int depthSize = ((((disp->virtualHeight+15) & ~15) * width_bytes
+ + RADEON_BUFFER_ALIGN)
+ & ~RADEON_BUFFER_ALIGN);
+ int l;
+
+ info->frontOffset = 0;
+ info->frontPitch = disp->virtualWidth;
+
+ fprintf(stderr,
+ "Using %d MB AGP aperture\n", info->gartSize);
+ fprintf(stderr,
+ "Using %d MB for the ring buffer\n", info->ringSize);
+ fprintf(stderr,
+ "Using %d MB for vertex/indirect buffers\n", info->bufSize);
+ fprintf(stderr,
+ "Using %d MB for AGP textures\n", info->gartTexSize);
+
+ /* Front, back and depth buffers - everything else texture??
+ */
+ info->textureSize = disp->fbSize - 2 * bufferSize - depthSize;
+
+ if (info->textureSize < 0)
+ return 0;
+
+ l = RADEONMinBits((info->textureSize-1) / RADEON_NR_TEX_REGIONS);
+ if (l < RADEON_LOG_TEX_GRANULARITY) l = RADEON_LOG_TEX_GRANULARITY;
+
+ /* Round the texture size up to the nearest whole number of
+ * texture regions. Again, be greedy about this, don't
+ * round down.
+ */
+ info->log2TexGran = l;
+ info->textureSize = (info->textureSize >> l) << l;
+
+ /* Set a minimum usable local texture heap size. This will fit
+ * two 256x256x32bpp textures.
+ */
+ if (info->textureSize < 512 * 1024) {
+ info->textureOffset = 0;
+ info->textureSize = 0;
+ }
+
+ /* Reserve space for textures */
+ info->textureOffset = ((disp->fbSize - info->textureSize +
+ RADEON_BUFFER_ALIGN) &
+ ~RADEON_BUFFER_ALIGN);
+
+ /* Reserve space for the shared depth
+ * buffer.
+ */
+ info->depthOffset = ((info->textureOffset - depthSize +
+ RADEON_BUFFER_ALIGN) &
+ ~RADEON_BUFFER_ALIGN);
+ info->depthPitch = disp->virtualWidth;
+
+ info->backOffset = ((info->depthOffset - bufferSize +
+ RADEON_BUFFER_ALIGN) &
+ ~RADEON_BUFFER_ALIGN);
+ info->backPitch = disp->virtualWidth;
+
+
+ fprintf(stderr,
+ "Will use back buffer at offset 0x%x\n",
+ info->backOffset);
+ fprintf(stderr,
+ "Will use depth buffer at offset 0x%x\n",
+ info->depthOffset);
+ fprintf(stderr,
+ "Will use %d kb for textures at offset 0x%x\n",
+ info->textureSize/1024, info->textureOffset);
+
+ info->frontPitchOffset = (((info->frontPitch * cpp / 64) << 22) |
+ (info->frontOffset >> 10));
+
+ info->backPitchOffset = (((info->backPitch * cpp / 64) << 22) |
+ (info->backOffset >> 10));
+
+ info->depthPitchOffset = (((info->depthPitch * cpp / 64) << 22) |
+ (info->depthOffset >> 10));
+
+ return 1;
+}
+
+
+/**
+ * \brief Initialize the kernel data structures and enable the CP engine.
+ *
+ * \param ctx display handle.
+ * \param info driver private data.
+ *
+ * \return non-zero on success, or zero on failure.
+ *
+ * This function is a wrapper around the DRM_RADEON_CP_INIT command, passing
+ * all the parameters in a drm_radeon_init_t structure.
+ */
+static int RADEONDRIKernelInit( driDisplay *disp,
+ RADEONInfoPtr info)
+{
+ int cpp = disp->bpp / 8;
+ drm_radeon_init_t drmInfo;
+ int ret;
+
+ memset(&drmInfo, 0, sizeof(drmInfo));
+
+ if ( (info->ChipFamily == CHIP_FAMILY_R200) ||
+ (info->ChipFamily == CHIP_FAMILY_RV250) ||
+ (info->ChipFamily == CHIP_FAMILY_M9) ||
+ (info->ChipFamily == CHIP_FAMILY_RV280) )
+ drmInfo.func = RADEON_INIT_R200_CP;
+ else
+ drmInfo.func = RADEON_INIT_CP;
+
+ /* This is the struct passed to the kernel module for its initialization */
+ drmInfo.sarea_priv_offset = sizeof(drm_sarea_t);
+ drmInfo.cp_mode = RADEON_DEFAULT_CP_BM_MODE;
+ drmInfo.gart_size = info->gartSize*1024*1024;
+ drmInfo.ring_size = info->ringSize*1024*1024;
+ drmInfo.usec_timeout = 1000;
+ drmInfo.fb_bpp = disp->bpp;
+ drmInfo.depth_bpp = disp->bpp;
+ drmInfo.front_offset = info->frontOffset;
+ drmInfo.front_pitch = info->frontPitch * cpp;
+ drmInfo.back_offset = info->backOffset;
+ drmInfo.back_pitch = info->backPitch * cpp;
+ drmInfo.depth_offset = info->depthOffset;
+ drmInfo.depth_pitch = info->depthPitch * cpp;
+ drmInfo.ring_offset = info->ringHandle;
+ drmInfo.ring_rptr_offset = info->ringReadPtrHandle;
+ drmInfo.buffers_offset = info->bufHandle;
+ drmInfo.gart_textures_offset = info->gartTexHandle;
+
+ ret = drmCommandWrite(disp->drmFD, DRM_RADEON_CP_INIT, &drmInfo,
+ sizeof(drm_radeon_init_t));
+
+ return ret >= 0;
+}
+
+
+/**
+ * \brief Add a map for the vertex buffers that will be accessed by any
+ * DRI-based clients.
+ *
+ * \param ctx display handle.
+ * \param info driver private data.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Calls drmAddBufs() with the previously allocated vertex buffers.
+ */
+static int RADEONDRIBufInit( driDisplay *disp, RADEONInfoPtr info )
+{
+ /* Initialize vertex buffers */
+ info->bufNumBufs = drmAddBufs(disp->drmFD,
+ info->bufMapSize / RADEON_BUFFER_SIZE,
+ RADEON_BUFFER_SIZE,
+ disp->isPCI ? DRM_SG_BUFFER : DRM_AGP_BUFFER,
+ info->bufStart);
+
+ if (info->bufNumBufs <= 0) {
+ fprintf(stderr,
+ "[drm] Could not create vertex/indirect buffers list\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[drm] Added %d %d byte vertex/indirect buffers\n",
+ info->bufNumBufs, RADEON_BUFFER_SIZE);
+
+ return 1;
+}
+
+
+/**
+ * \brief Install an IRQ handler.
+ *
+ * \param disp display handle.
+ * \param info driver private data.
+ *
+ * Attempts to install an IRQ handler via drmCtlInstHandler(), falling back to
+ * IRQ-free operation on failure.
+ */
+static void RADEONDRIIrqInit(driDisplay *disp, RADEONInfoPtr info)
+{
+ if ((drmCtlInstHandler(disp->drmFD, 0)) != 0)
+ fprintf(stderr, "[drm] failure adding irq handler, "
+ "there is a device already using that irq\n"
+ "[drm] falling back to irq-free operation\n");
+}
+
+
+/**
+ * \brief Initialize the AGP heap.
+ *
+ * \param disp display handle.
+ * \param info driver private data.
+ *
+ * This function is a wrapper around the DRM_RADEON_INIT_HEAP command, passing
+ * all the parameters in a drm_radeon_mem_init_heap structure.
+ */
+static void RADEONDRIAgpHeapInit(driDisplay *disp,
+ RADEONInfoPtr info)
+{
+ drm_radeon_mem_init_heap_t drmHeap;
+
+ /* Start up the simple memory manager for gart space */
+ drmHeap.region = RADEON_MEM_REGION_GART;
+ drmHeap.start = 0;
+ drmHeap.size = info->gartTexMapSize;
+
+ if (drmCommandWrite(disp->drmFD, DRM_RADEON_INIT_HEAP,
+ &drmHeap, sizeof(drmHeap))) {
+ fprintf(stderr,
+ "[drm] Failed to initialized gart heap manager\n");
+ } else {
+ fprintf(stderr,
+ "[drm] Initialized kernel gart heap manager, %d\n",
+ info->gartTexMapSize);
+ }
+}
+
+
+/**
+ * Called at the start of each server generation.
+ *
+ * \param disp display handle.
+ * \param info driver private data.
+ *
+ * \return non-zero on success, or zero on failure.
+ *
+ * Performs static frame buffer allocation. Opens the DRM device and add maps
+ * to the SAREA, framebuffer and MMIO regions. Fills in \p info with more
+ * information. Creates a \e server context to grab the lock for the
+ * initialization ioctls and calls the other initilization functions in this
+ * file. Starts the CP engine via the DRM_RADEON_CP_START command.
+ *
+ * Setups a RADEONDRIRec structure to be passed to radeon_dri.so for its
+ * initialization.
+ */
+static int RADEONScreenInit( driDisplay *disp, RADEONInfoPtr info, RADEONDRIPtr pRADEONDRI)
+{
+ int i, err;
+
+ {
+ int width_bytes = (disp->virtualWidth * disp->cpp);
+ int maxy = disp->fbSize / width_bytes;
+
+
+ if (maxy <= disp->virtualHeight * 3) {
+ fprintf(stderr,
+ "Static buffer allocation failed -- "
+ "need at least %d kB video memory (have %d kB)\n",
+ (disp->virtualWidth * disp->virtualHeight *
+ disp->cpp * 3 + 1023) / 1024,
+ disp->fbSize / 1024);
+ return 0;
+ }
+ }
+ if (info->ChipFamily >= CHIP_FAMILY_R300) {
+ fprintf(stderr,
+ "Direct rendering not yet supported on "
+ "Radeon 9700 and newer cards\n");
+ return 0;
+ }
+
+ radeon_drm_page_size = getpagesize();
+
+ /* Check the radeon DRM version */
+ if (!RADEONCheckDRMVersion(disp, info)) {
+ return 0;
+ }
+
+ if (disp->isPCI) {
+ /* Initialize PCI */
+ if (!RADEONDRIPciInit(disp, info))
+ return 0;
+ }
+ else {
+ /* Initialize AGP */
+ if (!RADEONDRIAgpInit(disp, info))
+ return 0;
+ }
+
+ /* Memory manager setup */
+ if (!RADEONMemoryInit(disp, info)) {
+ return 0;
+ }
+
+ /* Create a 'server' context so we can grab the lock for
+ * initialization ioctls.
+ */
+ if ((err = drmCreateContext(disp->drmFD, &disp->serverContext)) != 0) {
+ fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err);
+ return 0;
+ }
+
+ DRM_LOCK(disp->drmFD, disp->pSAREA, disp->serverContext, 0);
+
+ /* Initialize the kernel data structures */
+ if (!RADEONDRIKernelInit(disp, info)) {
+ fprintf(stderr, "RADEONDRIKernelInit failed\n");
+ DRM_UNLOCK(disp->drmFD, disp->pSAREA, disp->serverContext);
+ return 0;
+ }
+
+ /* Initialize the vertex buffers list */
+ if (!RADEONDRIBufInit(disp, info)) {
+ fprintf(stderr, "RADEONDRIBufInit failed\n");
+ DRM_UNLOCK(disp->drmFD, disp->pSAREA, disp->serverContext);
+ return 0;
+ }
+
+ /* Initialize IRQ */
+ RADEONDRIIrqInit(disp, info);
+
+ /* Initialize kernel gart memory manager */
+ RADEONDRIAgpHeapInit(disp, info);
+
+ fprintf(stderr,"page flipping %sabled\n", info->page_flip_enable?"en":"dis");
+ /* Initialize the SAREA private data structure */
+ {
+ drm_radeon_sarea_t *pSAREAPriv;
+ pSAREAPriv = (drm_radeon_sarea_t *)(((char*)disp->pSAREA) +
+ sizeof(drm_sarea_t));
+ memset(pSAREAPriv, 0, sizeof(*pSAREAPriv));
+ pSAREAPriv->pfState = info->page_flip_enable;
+ }
+
+ for ( i = 0;; i++ ) {
+ drmMapType type;
+ drmMapFlags flags;
+ drm_handle_t handle, offset;
+ drmSize size;
+ int rc, mtrr;
+
+ if ( ( rc = drmGetMap( disp->drmFD, i, &offset, &size, &type, &flags, &handle, &mtrr ) ) != 0 )
+ break;
+ if ( type == DRM_REGISTERS ) {
+ pRADEONDRI->registerHandle = offset;
+ pRADEONDRI->registerSize = size;
+ break;
+ }
+ }
+ /* Quick hack to clear the front & back buffers. Could also use
+ * the clear ioctl to do this, but would need to setup hw state
+ * first.
+ */
+ drimemsetio((char *)disp->pFB + info->frontOffset,
+ 0xEE,
+ info->frontPitch * disp->cpp * disp->virtualHeight );
+
+ drimemsetio((char *)disp->pFB + info->backOffset,
+ 0x30,
+ info->backPitch * disp->cpp * disp->virtualHeight );
+
+
+ /* This is the struct passed to radeon_dri.so for its initialization */
+ pRADEONDRI->deviceID = info->Chipset;
+ pRADEONDRI->width = disp->virtualWidth;
+ pRADEONDRI->height = disp->virtualHeight;
+ pRADEONDRI->depth = disp->bpp; /* XXX: depth */
+ pRADEONDRI->bpp = disp->bpp;
+ pRADEONDRI->IsPCI = disp->isPCI;
+ pRADEONDRI->frontOffset = info->frontOffset;
+ pRADEONDRI->frontPitch = info->frontPitch;
+ pRADEONDRI->backOffset = info->backOffset;
+ pRADEONDRI->backPitch = info->backPitch;
+ pRADEONDRI->depthOffset = info->depthOffset;
+ pRADEONDRI->depthPitch = info->depthPitch;
+ pRADEONDRI->textureOffset = info->textureOffset;
+ pRADEONDRI->textureSize = info->textureSize;
+ pRADEONDRI->log2TexGran = info->log2TexGran;
+ pRADEONDRI->statusHandle = info->ringReadPtrHandle;
+ pRADEONDRI->statusSize = info->ringReadMapSize;
+ pRADEONDRI->gartTexHandle = info->gartTexHandle;
+ pRADEONDRI->gartTexMapSize = info->gartTexMapSize;
+ pRADEONDRI->log2GARTTexGran = info->log2GARTTexGran;
+ pRADEONDRI->gartTexOffset = info->gartTexStart;
+ pRADEONDRI->sarea_priv_offset = sizeof(drm_sarea_t);
+
+ /* Don't release the lock now - let the VT switch handler do it. */
+
+ return 1;
+}
+
+
+/**
+ * \brief Get Radeon chip family from chipset number.
+ *
+ * \param info driver private data.
+ *
+ * \return non-zero on success, or zero on failure.
+ *
+ * Called by radeonInitFBDev() to set RADEONInfoRec::ChipFamily
+ * according to the value of RADEONInfoRec::Chipset. Fails if the
+ * chipset is unrecognized or not appropriate for this driver (i.e., not
+ * an r100 style radeon)
+ */
+static int get_chipfamily_from_chipset( RADEONInfoPtr info )
+{
+ switch (info->Chipset) {
+ case PCI_CHIP_RADEON_LY:
+ case PCI_CHIP_RADEON_LZ:
+ info->ChipFamily = CHIP_FAMILY_M6;
+ break;
+
+ case PCI_CHIP_RADEON_QY:
+ case PCI_CHIP_RADEON_QZ:
+ info->ChipFamily = CHIP_FAMILY_VE;
+ break;
+
+ case PCI_CHIP_R200_QL:
+ case PCI_CHIP_R200_QN:
+ case PCI_CHIP_R200_QO:
+ case PCI_CHIP_R200_Ql:
+ case PCI_CHIP_R200_BB:
+ info->ChipFamily = CHIP_FAMILY_R200;
+ break;
+
+ case PCI_CHIP_RV200_QW: /* RV200 desktop */
+ case PCI_CHIP_RV200_QX:
+ info->ChipFamily = CHIP_FAMILY_RV200;
+ break;
+
+ case PCI_CHIP_RADEON_LW:
+ case PCI_CHIP_RADEON_LX:
+ info->ChipFamily = CHIP_FAMILY_M7;
+ break;
+
+ case PCI_CHIP_RV250_Id:
+ case PCI_CHIP_RV250_Ie:
+ case PCI_CHIP_RV250_If:
+ case PCI_CHIP_RV250_Ig:
+ info->ChipFamily = CHIP_FAMILY_RV250;
+ break;
+
+ case PCI_CHIP_RV250_Ld:
+ case PCI_CHIP_RV250_Le:
+ case PCI_CHIP_RV250_Lf:
+ case PCI_CHIP_RV250_Lg:
+ info->ChipFamily = CHIP_FAMILY_M9;
+ break;
+
+ case PCI_CHIP_RV280_Y_:
+ case PCI_CHIP_RV280_Ya:
+ case PCI_CHIP_RV280_Yb:
+ case PCI_CHIP_RV280_Yc:
+ info->ChipFamily = CHIP_FAMILY_RV280;
+ break;
+
+ case PCI_CHIP_R300_ND:
+ case PCI_CHIP_R300_NE:
+ case PCI_CHIP_R300_NF:
+ case PCI_CHIP_R300_NG:
+ info->ChipFamily = CHIP_FAMILY_R300;
+ break;
+
+ default:
+ /* Original Radeon/7200 */
+ info->ChipFamily = CHIP_FAMILY_RADEON;
+ }
+
+ return 1;
+}
+
+
+/**
+ * \brief Initialize the framebuffer device mode
+ *
+ * \param disp display handle.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Fills in \p info with some default values and some information from \p disp
+ * and then calls RADEONScreenInit() for the screen initialization.
+ *
+ * Before exiting clears the framebuffer memory accessing it directly.
+ */
+static int radeonInitFBDev( driDisplay *disp, RADEONDRIPtr pRADEONDRI )
+{
+ int err;
+ RADEONInfoPtr info = calloc(1, sizeof(*info));
+
+ disp->driverPrivate = (void *)info;
+
+ info->gartFastWrite = RADEON_DEFAULT_AGP_FAST_WRITE;
+ info->gartSize = RADEON_DEFAULT_AGP_SIZE;
+ info->gartTexSize = RADEON_DEFAULT_AGP_TEX_SIZE;
+ info->bufSize = RADEON_DEFAULT_BUFFER_SIZE;
+ info->ringSize = RADEON_DEFAULT_RING_SIZE;
+ info->page_flip_enable = RADEON_DEFAULT_PAGE_FLIP;
+
+ info->Chipset = disp->chipset;
+
+ if (!get_chipfamily_from_chipset( info )) {
+ fprintf(stderr, "Unknown or non-radeon chipset -- cannot continue\n");
+ fprintf(stderr, "==> Verify PCI BusID is correct in miniglx.conf\n");
+ return 0;
+ }
+
+ info->frontPitch = disp->virtualWidth;
+
+ if (!RADEONScreenInit( disp, info, pRADEONDRI))
+ return 0;
+
+ /* Initialize and start the CP if required */
+ if ((err = drmCommandNone(disp->drmFD, DRM_RADEON_CP_START)) != 0) {
+ fprintf(stderr, "%s: CP start %d\n", __FUNCTION__, err);
+ return 0;
+ }
+
+ return 1;
+}
+
+static EGLBoolean
+radeonFillInConfigs(_EGLDisplay *disp, unsigned pixel_bits, unsigned depth_bits,
+ unsigned stencil_bits, GLboolean have_back_buffer) {
+ _EGLConfig *configs;
+ _EGLConfig *c;
+ unsigned int i, num_configs;
+ unsigned int depth_buffer_factor;
+ unsigned int back_buffer_factor;
+ GLenum fb_format;
+ GLenum fb_type;
+
+ /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
+ * enough to add support. Basically, if a context is created with an
+ * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
+ * will never be used.
+ */
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
+ };
+
+ u_int8_t depth_bits_array[2];
+ u_int8_t stencil_bits_array[2];
+
+ depth_bits_array[0] = depth_bits;
+ depth_bits_array[1] = depth_bits;
+
+ /* Just like with the accumulation buffer, always provide some modes
+ * with a stencil buffer. It will be a sw fallback, but some apps won't
+ * care about that.
+ */
+ stencil_bits_array[0] = 0;
+ stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
+
+ depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1;
+ back_buffer_factor = (have_back_buffer) ? 2 : 1;
+
+ num_configs = depth_buffer_factor * back_buffer_factor * 2;
+
+ if (pixel_bits == 16) {
+ fb_format = GL_RGB;
+ fb_type = GL_UNSIGNED_SHORT_5_6_5;
+ } else {
+ fb_format = GL_RGBA;
+ fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ }
+
+ configs = calloc(sizeof(*configs), num_configs);
+ c = configs;
+ if (!_eglFillInConfigs(c, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_TRUE_COLOR)) {
+ fprintf(stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__);
+ return EGL_FALSE;
+ }
+
+ /* Mark the visual as slow if there are "fake" stencil bits.
+ */
+ for (i = 0, c = configs; i < num_configs; i++, c++) {
+ int stencil = GET_CONFIG_ATTRIB(c, EGL_STENCIL_SIZE);
+ if ((stencil != 0) && (stencil != stencil_bits)) {
+ SET_CONFIG_ATTRIB(c, EGL_CONFIG_CAVEAT, EGL_SLOW_CONFIG);
+ }
+ }
+
+ for (i = 0, c = configs; i < num_configs; i++, c++)
+ _eglAddConfig(disp, c);
+
+ free(configs);
+
+ return EGL_TRUE;
+}
+
+/**
+ * Show the given surface on the named screen.
+ * If surface is EGL_NO_SURFACE, disable the screen's output.
+ */
+static EGLBoolean
+radeonShowSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
+ EGLSurface surface, EGLModeMESA m)
+{
+ _eglDRIShowSurfaceMESA(drv, dpy, screen, surface, m);
+ return EGL_FALSE;
+}
+
+static EGLBoolean
+radeonInitialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor)
+{
+ __DRIframebuffer framebuffer;
+ driDisplay *display;
+
+ if (!_eglDRIInitialize(drv, dpy, major, minor))
+ return EGL_FALSE;
+
+ display = Lookup_driDisplay(dpy);
+
+ framebuffer.dev_priv_size = sizeof(RADEONDRIRec);
+ framebuffer.dev_priv = malloc(sizeof(RADEONDRIRec));
+
+ display->virtualWidth = 1024;
+ display->virtualHeight = 768;
+ display->bpp = 32;
+ display->cpp = 4;
+
+ if (!_eglDRIGetDisplayInfo(display))
+ return EGL_FALSE;
+
+ framebuffer.base = display->pFB;
+ radeonInitFBDev( display, framebuffer.dev_priv );
+
+ if (!_eglDRICreateDisplay(display, &framebuffer))
+ return EGL_FALSE;
+
+ if (!_eglDRICreateScreen(display))
+ return EGL_FALSE;
+
+ radeonFillInConfigs(&display->Base, 32, 24, 8, 1);
+ radeonFillInConfigs(&display->Base, 16, 16, 0, 1);
+
+ drv->Initialized = EGL_TRUE;
+ return EGL_TRUE;
+}
+
+
+/**
+ * The bootstrap function. Return a new radeonDriver object and
+ * plug in API functions.
+ */
+_EGLDriver *
+_eglMain(_EGLDisplay *dpy)
+{
+ radeonDriver *radeon;
+
+ radeon = (radeonDriver *) calloc(1, sizeof(*radeon));
+ if (!radeon) {
+ return NULL;
+ }
+
+ /* First fill in the dispatch table with defaults */
+ _eglDRIInitDriverFallbacks(&radeon->Base);
+
+ /* then plug in our radeon-specific functions */
+ radeon->Base.Initialize = radeonInitialize;
+ radeon->Base.ShowSurfaceMESA = radeonShowSurfaceMESA;
+
+ return &radeon->Base;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_macros.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_macros.h
new file mode 100644
index 000000000..60f0fa2d3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_macros.h
@@ -0,0 +1,129 @@
+/**
+ * \file server/radeon_macros.h
+ * \brief Macros for Radeon MMIO operation.
+ *
+ * \authors Kevin E. Martin <martin@xfree86.org>
+ * \authors Rickard E. Faith <faith@valinux.com>
+ * \authors Alan Hourihane <alanh@fairlite.demon.co.uk>
+ */
+
+/*
+ * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and
+ * VA Linux Systems Inc., Fremont, 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 on 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS 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.
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_reg.h,v 1.20 2002/10/12 01:38:07 martin Exp $ */
+
+#ifndef _RADEON_MACROS_H_
+#define _RADEON_MACROS_H_
+
+#include <mmio.h>
+
+# define MMIO_IN8(base, offset) \
+ *(volatile unsigned char *)(((unsigned char*)(base)) + (offset))
+# define MMIO_IN32(base, offset) \
+ read_MMIO_LE32(base, offset)
+# define MMIO_OUT8(base, offset, val) \
+ *(volatile unsigned char *)(((unsigned char*)(base)) + (offset)) = (val)
+# define MMIO_OUT32(base, offset, val) \
+ *(volatile unsigned int *)(void *)(((unsigned char*)(base)) + (offset)) = CPU_TO_LE32(val)
+
+
+ /* Memory mapped register access macros */
+#define INREG8(addr) MMIO_IN8(RADEONMMIO, addr)
+#define INREG(addr) MMIO_IN32(RADEONMMIO, addr)
+#define OUTREG8(addr, val) MMIO_OUT8(RADEONMMIO, addr, val)
+#define OUTREG(addr, val) MMIO_OUT32(RADEONMMIO, addr, val)
+
+#define ADDRREG(addr) ((volatile GLuint *)(pointer)(RADEONMMIO + (addr)))
+
+
+#define OUTREGP(addr, val, mask) \
+do { \
+ GLuint tmp = INREG(addr); \
+ tmp &= (mask); \
+ tmp |= (val); \
+ OUTREG(addr, tmp); \
+} while (0)
+
+#define INPLL(dpy, addr) RADEONINPLL(dpy, addr)
+
+#define OUTPLL(addr, val) \
+do { \
+ OUTREG8(RADEON_CLOCK_CNTL_INDEX, (((addr) & 0x3f) | \
+ RADEON_PLL_WR_EN)); \
+ OUTREG(RADEON_CLOCK_CNTL_DATA, val); \
+} while (0)
+
+#define OUTPLLP(dpy, addr, val, mask) \
+do { \
+ GLuint tmp = INPLL(dpy, addr); \
+ tmp &= (mask); \
+ tmp |= (val); \
+ OUTPLL(addr, tmp); \
+} while (0)
+
+#define OUTPAL_START(idx) \
+do { \
+ OUTREG8(RADEON_PALETTE_INDEX, (idx)); \
+} while (0)
+
+#define OUTPAL_NEXT(r, g, b) \
+do { \
+ OUTREG(RADEON_PALETTE_DATA, ((r) << 16) | ((g) << 8) | (b)); \
+} while (0)
+
+#define OUTPAL_NEXT_CARD32(v) \
+do { \
+ OUTREG(RADEON_PALETTE_DATA, (v & 0x00ffffff)); \
+} while (0)
+
+#define OUTPAL(idx, r, g, b) \
+do { \
+ OUTPAL_START((idx)); \
+ OUTPAL_NEXT((r), (g), (b)); \
+} while (0)
+
+#define INPAL_START(idx) \
+do { \
+ OUTREG(RADEON_PALETTE_INDEX, (idx) << 16); \
+} while (0)
+
+#define INPAL_NEXT() INREG(RADEON_PALETTE_DATA)
+
+#define PAL_SELECT(idx) \
+do { \
+ if (!idx) { \
+ OUTREG(RADEON_DAC_CNTL2, INREG(RADEON_DAC_CNTL2) & \
+ (GLuint)~RADEON_DAC2_PALETTE_ACC_CTL); \
+ } else { \
+ OUTREG(RADEON_DAC_CNTL2, INREG(RADEON_DAC_CNTL2) | \
+ RADEON_DAC2_PALETTE_ACC_CTL); \
+ } \
+} while (0)
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_reg.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_reg.h
new file mode 100644
index 000000000..d290d43cf
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/radeon/server/radeon_reg.h
@@ -0,0 +1,2142 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_reg.h,v 1.30 2003/10/07 22:47:12 martin Exp $ */
+/*
+ * Copyright 2000 ATI Technologies Inc., Markham, Ontario, and
+ * VA Linux Systems Inc., Fremont, 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 on 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
+ * NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS 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 <martin@xfree86.org>
+ * Rickard E. Faith <faith@valinux.com>
+ * Alan Hourihane <alanh@fairlite.demon.co.uk>
+ *
+ * References:
+ *
+ * !!!! FIXME !!!!
+ * RAGE 128 VR/ RAGE 128 GL Register Reference Manual (Technical
+ * Reference Manual P/N RRG-G04100-C Rev. 0.04), ATI Technologies: April
+ * 1999.
+ *
+ * !!!! FIXME !!!!
+ * RAGE 128 Software Development Manual (Technical Reference Manual P/N
+ * SDK-G04000 Rev. 0.01), ATI Technologies: June 1999.
+ *
+ */
+
+/* !!!! FIXME !!!! NOTE: THIS FILE HAS BEEN CONVERTED FROM r128_reg.h
+ * AND CONTAINS REGISTERS AND REGISTER DEFINITIONS THAT ARE NOT CORRECT
+ * ON THE RADEON. A FULL AUDIT OF THIS CODE IS NEEDED! */
+
+#ifndef _RADEON_REG_H_
+#define _RADEON_REG_H_
+
+ /* Registers for 2D/Video/Overlay */
+#define RADEON_ADAPTER_ID 0x0f2c /* PCI */
+#define RADEON_AGP_BASE 0x0170
+#define RADEON_AGP_CNTL 0x0174
+# define RADEON_AGP_APER_SIZE_256MB (0x00 << 0)
+# define RADEON_AGP_APER_SIZE_128MB (0x20 << 0)
+# define RADEON_AGP_APER_SIZE_64MB (0x30 << 0)
+# define RADEON_AGP_APER_SIZE_32MB (0x38 << 0)
+# define RADEON_AGP_APER_SIZE_16MB (0x3c << 0)
+# define RADEON_AGP_APER_SIZE_8MB (0x3e << 0)
+# define RADEON_AGP_APER_SIZE_4MB (0x3f << 0)
+# define RADEON_AGP_APER_SIZE_MASK (0x3f << 0)
+#define RADEON_AGP_COMMAND 0x0f60 /* PCI */
+#define RADEON_AGP_COMMAND_PCI_CONFIG 0x0060 /* offset in PCI config*/
+# define RADEON_AGP_ENABLE (1<<8)
+#define RADEON_AGP_PLL_CNTL 0x000b /* PLL */
+#define RADEON_AGP_STATUS 0x0f5c /* PCI */
+# define RADEON_AGP_1X_MODE 0x01
+# define RADEON_AGP_2X_MODE 0x02
+# define RADEON_AGP_4X_MODE 0x04
+# define RADEON_AGP_FW_MODE 0x10
+# define RADEON_AGP_MODE_MASK 0x17
+#define RADEON_ATTRDR 0x03c1 /* VGA */
+#define RADEON_ATTRDW 0x03c0 /* VGA */
+#define RADEON_ATTRX 0x03c0 /* VGA */
+#define RADEON_AUX_SC_CNTL 0x1660
+# define RADEON_AUX1_SC_EN (1 << 0)
+# define RADEON_AUX1_SC_MODE_OR (0 << 1)
+# define RADEON_AUX1_SC_MODE_NAND (1 << 1)
+# define RADEON_AUX2_SC_EN (1 << 2)
+# define RADEON_AUX2_SC_MODE_OR (0 << 3)
+# define RADEON_AUX2_SC_MODE_NAND (1 << 3)
+# define RADEON_AUX3_SC_EN (1 << 4)
+# define RADEON_AUX3_SC_MODE_OR (0 << 5)
+# define RADEON_AUX3_SC_MODE_NAND (1 << 5)
+#define RADEON_AUX1_SC_BOTTOM 0x1670
+#define RADEON_AUX1_SC_LEFT 0x1664
+#define RADEON_AUX1_SC_RIGHT 0x1668
+#define RADEON_AUX1_SC_TOP 0x166c
+#define RADEON_AUX2_SC_BOTTOM 0x1680
+#define RADEON_AUX2_SC_LEFT 0x1674
+#define RADEON_AUX2_SC_RIGHT 0x1678
+#define RADEON_AUX2_SC_TOP 0x167c
+#define RADEON_AUX3_SC_BOTTOM 0x1690
+#define RADEON_AUX3_SC_LEFT 0x1684
+#define RADEON_AUX3_SC_RIGHT 0x1688
+#define RADEON_AUX3_SC_TOP 0x168c
+#define RADEON_AUX_WINDOW_HORZ_CNTL 0x02d8
+#define RADEON_AUX_WINDOW_VERT_CNTL 0x02dc
+
+#define RADEON_BASE_CODE 0x0f0b
+#define RADEON_BIOS_0_SCRATCH 0x0010
+#define RADEON_BIOS_1_SCRATCH 0x0014
+#define RADEON_BIOS_2_SCRATCH 0x0018
+#define RADEON_BIOS_3_SCRATCH 0x001c
+#define RADEON_BIOS_4_SCRATCH 0x0020
+#define RADEON_BIOS_5_SCRATCH 0x0024
+#define RADEON_BIOS_6_SCRATCH 0x0028
+#define RADEON_BIOS_7_SCRATCH 0x002c
+#define RADEON_BIOS_ROM 0x0f30 /* PCI */
+#define RADEON_BIST 0x0f0f /* PCI */
+#define RADEON_BRUSH_DATA0 0x1480
+#define RADEON_BRUSH_DATA1 0x1484
+#define RADEON_BRUSH_DATA10 0x14a8
+#define RADEON_BRUSH_DATA11 0x14ac
+#define RADEON_BRUSH_DATA12 0x14b0
+#define RADEON_BRUSH_DATA13 0x14b4
+#define RADEON_BRUSH_DATA14 0x14b8
+#define RADEON_BRUSH_DATA15 0x14bc
+#define RADEON_BRUSH_DATA16 0x14c0
+#define RADEON_BRUSH_DATA17 0x14c4
+#define RADEON_BRUSH_DATA18 0x14c8
+#define RADEON_BRUSH_DATA19 0x14cc
+#define RADEON_BRUSH_DATA2 0x1488
+#define RADEON_BRUSH_DATA20 0x14d0
+#define RADEON_BRUSH_DATA21 0x14d4
+#define RADEON_BRUSH_DATA22 0x14d8
+#define RADEON_BRUSH_DATA23 0x14dc
+#define RADEON_BRUSH_DATA24 0x14e0
+#define RADEON_BRUSH_DATA25 0x14e4
+#define RADEON_BRUSH_DATA26 0x14e8
+#define RADEON_BRUSH_DATA27 0x14ec
+#define RADEON_BRUSH_DATA28 0x14f0
+#define RADEON_BRUSH_DATA29 0x14f4
+#define RADEON_BRUSH_DATA3 0x148c
+#define RADEON_BRUSH_DATA30 0x14f8
+#define RADEON_BRUSH_DATA31 0x14fc
+#define RADEON_BRUSH_DATA32 0x1500
+#define RADEON_BRUSH_DATA33 0x1504
+#define RADEON_BRUSH_DATA34 0x1508
+#define RADEON_BRUSH_DATA35 0x150c
+#define RADEON_BRUSH_DATA36 0x1510
+#define RADEON_BRUSH_DATA37 0x1514
+#define RADEON_BRUSH_DATA38 0x1518
+#define RADEON_BRUSH_DATA39 0x151c
+#define RADEON_BRUSH_DATA4 0x1490
+#define RADEON_BRUSH_DATA40 0x1520
+#define RADEON_BRUSH_DATA41 0x1524
+#define RADEON_BRUSH_DATA42 0x1528
+#define RADEON_BRUSH_DATA43 0x152c
+#define RADEON_BRUSH_DATA44 0x1530
+#define RADEON_BRUSH_DATA45 0x1534
+#define RADEON_BRUSH_DATA46 0x1538
+#define RADEON_BRUSH_DATA47 0x153c
+#define RADEON_BRUSH_DATA48 0x1540
+#define RADEON_BRUSH_DATA49 0x1544
+#define RADEON_BRUSH_DATA5 0x1494
+#define RADEON_BRUSH_DATA50 0x1548
+#define RADEON_BRUSH_DATA51 0x154c
+#define RADEON_BRUSH_DATA52 0x1550
+#define RADEON_BRUSH_DATA53 0x1554
+#define RADEON_BRUSH_DATA54 0x1558
+#define RADEON_BRUSH_DATA55 0x155c
+#define RADEON_BRUSH_DATA56 0x1560
+#define RADEON_BRUSH_DATA57 0x1564
+#define RADEON_BRUSH_DATA58 0x1568
+#define RADEON_BRUSH_DATA59 0x156c
+#define RADEON_BRUSH_DATA6 0x1498
+#define RADEON_BRUSH_DATA60 0x1570
+#define RADEON_BRUSH_DATA61 0x1574
+#define RADEON_BRUSH_DATA62 0x1578
+#define RADEON_BRUSH_DATA63 0x157c
+#define RADEON_BRUSH_DATA7 0x149c
+#define RADEON_BRUSH_DATA8 0x14a0
+#define RADEON_BRUSH_DATA9 0x14a4
+#define RADEON_BRUSH_SCALE 0x1470
+#define RADEON_BRUSH_Y_X 0x1474
+#define RADEON_BUS_CNTL 0x0030
+# define RADEON_BUS_MASTER_DIS (1 << 6)
+# define RADEON_BUS_RD_DISCARD_EN (1 << 24)
+# define RADEON_BUS_RD_ABORT_EN (1 << 25)
+# define RADEON_BUS_MSTR_DISCONNECT_EN (1 << 28)
+# define RADEON_BUS_WRT_BURST (1 << 29)
+# define RADEON_BUS_READ_BURST (1 << 30)
+#define RADEON_BUS_CNTL1 0x0034
+# define RADEON_BUS_WAIT_ON_LOCK_EN (1 << 4)
+
+#define RADEON_CACHE_CNTL 0x1724
+#define RADEON_CACHE_LINE 0x0f0c /* PCI */
+#define RADEON_CAP0_TRIG_CNTL 0x0950 /* ? */
+#define RADEON_CAP1_TRIG_CNTL 0x09c0 /* ? */
+#define RADEON_CAPABILITIES_ID 0x0f50 /* PCI */
+#define RADEON_CAPABILITIES_PTR 0x0f34 /* PCI */
+#define RADEON_CLK_PIN_CNTL 0x0001 /* PLL */
+#define RADEON_CLOCK_CNTL_DATA 0x000c
+#define RADEON_CLOCK_CNTL_INDEX 0x0008
+# define RADEON_PLL_WR_EN (1 << 7)
+# define RADEON_PLL_DIV_SEL (3 << 8)
+# define RADEON_PLL2_DIV_SEL_MASK ~(3 << 8)
+#define RADEON_CLR_CMP_CLR_3D 0x1a24
+#define RADEON_CLR_CMP_CLR_DST 0x15c8
+#define RADEON_CLR_CMP_CLR_SRC 0x15c4
+#define RADEON_CLR_CMP_CNTL 0x15c0
+# define RADEON_SRC_CMP_EQ_COLOR (4 << 0)
+# define RADEON_SRC_CMP_NEQ_COLOR (5 << 0)
+# define RADEON_CLR_CMP_SRC_SOURCE (1 << 24)
+#define RADEON_CLR_CMP_MASK 0x15cc
+# define RADEON_CLR_CMP_MSK 0xffffffff
+#define RADEON_CLR_CMP_MASK_3D 0x1A28
+#define RADEON_COMMAND 0x0f04 /* PCI */
+#define RADEON_COMPOSITE_SHADOW_ID 0x1a0c
+#define RADEON_CONFIG_APER_0_BASE 0x0100
+#define RADEON_CONFIG_APER_1_BASE 0x0104
+#define RADEON_CONFIG_APER_SIZE 0x0108
+#define RADEON_CONFIG_BONDS 0x00e8
+#define RADEON_CONFIG_CNTL 0x00e0
+# define RADEON_CFG_ATI_REV_A11 (0 << 16)
+# define RADEON_CFG_ATI_REV_A12 (1 << 16)
+# define RADEON_CFG_ATI_REV_A13 (2 << 16)
+# define RADEON_CFG_ATI_REV_ID_MASK (0xf << 16)
+#define RADEON_CONFIG_MEMSIZE 0x00f8
+#define RADEON_CONFIG_MEMSIZE_EMBEDDED 0x0114
+#define RADEON_CONFIG_REG_1_BASE 0x010c
+#define RADEON_CONFIG_REG_APER_SIZE 0x0110
+#define RADEON_CONFIG_XSTRAP 0x00e4
+#define RADEON_CONSTANT_COLOR_C 0x1d34
+# define RADEON_CONSTANT_COLOR_MASK 0x00ffffff
+# define RADEON_CONSTANT_COLOR_ONE 0x00ffffff
+# define RADEON_CONSTANT_COLOR_ZERO 0x00000000
+#define RADEON_CRC_CMDFIFO_ADDR 0x0740
+#define RADEON_CRC_CMDFIFO_DOUT 0x0744
+#define RADEON_GRPH_BUFFER_CNTL 0x02f0
+# define RADEON_GRPH_START_REQ_MASK (0x7f)
+# define RADEON_GRPH_START_REQ_SHIFT 0
+# define RADEON_GRPH_STOP_REQ_MASK (0x7f<<8)
+# define RADEON_GRPH_STOP_REQ_SHIFT 8
+# define RADEON_GRPH_CRITICAL_POINT_MASK (0x7f<<16)
+# define RADEON_GRPH_CRITICAL_POINT_SHIFT 16
+# define RADEON_GRPH_CRITICAL_CNTL (1<<28)
+# define RADEON_GRPH_BUFFER_SIZE (1<<29)
+# define RADEON_GRPH_CRITICAL_AT_SOF (1<<30)
+# define RADEON_GRPH_STOP_CNTL (1<<31)
+#define RADEON_GRPH2_BUFFER_CNTL 0x03f0
+# define RADEON_GRPH2_START_REQ_MASK (0x7f)
+# define RADEON_GRPH2_START_REQ_SHIFT 0
+# define RADEON_GRPH2_STOP_REQ_MASK (0x7f<<8)
+# define RADEON_GRPH2_STOP_REQ_SHIFT 8
+# define RADEON_GRPH2_CRITICAL_POINT_MASK (0x7f<<16)
+# define RADEON_GRPH2_CRITICAL_POINT_SHIFT 16
+# define RADEON_GRPH2_CRITICAL_CNTL (1<<28)
+# define RADEON_GRPH2_BUFFER_SIZE (1<<29)
+# define RADEON_GRPH2_CRITICAL_AT_SOF (1<<30)
+# define RADEON_GRPH2_STOP_CNTL (1<<31)
+#define RADEON_CRTC_CRNT_FRAME 0x0214
+#define RADEON_CRTC_EXT_CNTL 0x0054
+# define RADEON_CRTC_VGA_XOVERSCAN (1 << 0)
+# define RADEON_VGA_ATI_LINEAR (1 << 3)
+# define RADEON_XCRT_CNT_EN (1 << 6)
+# define RADEON_CRTC_HSYNC_DIS (1 << 8)
+# define RADEON_CRTC_VSYNC_DIS (1 << 9)
+# define RADEON_CRTC_DISPLAY_DIS (1 << 10)
+# define RADEON_CRTC_SYNC_TRISTAT (1 << 11)
+# define RADEON_CRTC_CRT_ON (1 << 15)
+#define RADEON_CRTC_EXT_CNTL_DPMS_BYTE 0x0055
+# define RADEON_CRTC_HSYNC_DIS_BYTE (1 << 0)
+# define RADEON_CRTC_VSYNC_DIS_BYTE (1 << 1)
+# define RADEON_CRTC_DISPLAY_DIS_BYTE (1 << 2)
+#define RADEON_CRTC_GEN_CNTL 0x0050
+# define RADEON_CRTC_DBL_SCAN_EN (1 << 0)
+# define RADEON_CRTC_INTERLACE_EN (1 << 1)
+# define RADEON_CRTC_CSYNC_EN (1 << 4)
+# define RADEON_CRTC_CUR_EN (1 << 16)
+# define RADEON_CRTC_CUR_MODE_MASK (7 << 17)
+# define RADEON_CRTC_ICON_EN (1 << 20)
+# define RADEON_CRTC_EXT_DISP_EN (1 << 24)
+# define RADEON_CRTC_EN (1 << 25)
+# define RADEON_CRTC_DISP_REQ_EN_B (1 << 26)
+#define RADEON_CRTC2_GEN_CNTL 0x03f8
+# define RADEON_CRTC2_DBL_SCAN_EN (1 << 0)
+# define RADEON_CRTC2_INTERLACE_EN (1 << 1)
+# define RADEON_CRTC2_SYNC_TRISTAT (1 << 4)
+# define RADEON_CRTC2_HSYNC_TRISTAT (1 << 5)
+# define RADEON_CRTC2_VSYNC_TRISTAT (1 << 6)
+# define RADEON_CRTC2_CRT2_ON (1 << 7)
+# define RADEON_CRTC2_ICON_EN (1 << 15)
+# define RADEON_CRTC2_CUR_EN (1 << 16)
+# define RADEON_CRTC2_CUR_MODE_MASK (7 << 20)
+# define RADEON_CRTC2_DISP_DIS (1 << 23)
+# define RADEON_CRTC2_EN (1 << 25)
+# define RADEON_CRTC2_DISP_REQ_EN_B (1 << 26)
+# define RADEON_CRTC2_CSYNC_EN (1 << 27)
+# define RADEON_CRTC2_HSYNC_DIS (1 << 28)
+# define RADEON_CRTC2_VSYNC_DIS (1 << 29)
+#define RADEON_CRTC_MORE_CNTL 0x27c
+# define RADEON_CRTC_H_CUTOFF_ACTIVE_EN (1<<4)
+# define RADEON_CRTC_V_CUTOFF_ACTIVE_EN (1<<5)
+#define RADEON_CRTC_GUI_TRIG_VLINE 0x0218
+#define RADEON_CRTC_H_SYNC_STRT_WID 0x0204
+# define RADEON_CRTC_H_SYNC_STRT_PIX (0x07 << 0)
+# define RADEON_CRTC_H_SYNC_STRT_CHAR (0x3ff << 3)
+# define RADEON_CRTC_H_SYNC_STRT_CHAR_SHIFT 3
+# define RADEON_CRTC_H_SYNC_WID (0x3f << 16)
+# define RADEON_CRTC_H_SYNC_WID_SHIFT 16
+# define RADEON_CRTC_H_SYNC_POL (1 << 23)
+#define RADEON_CRTC2_H_SYNC_STRT_WID 0x0304
+# define RADEON_CRTC2_H_SYNC_STRT_PIX (0x07 << 0)
+# define RADEON_CRTC2_H_SYNC_STRT_CHAR (0x3ff << 3)
+# define RADEON_CRTC2_H_SYNC_STRT_CHAR_SHIFT 3
+# define RADEON_CRTC2_H_SYNC_WID (0x3f << 16)
+# define RADEON_CRTC2_H_SYNC_WID_SHIFT 16
+# define RADEON_CRTC2_H_SYNC_POL (1 << 23)
+#define RADEON_CRTC_H_TOTAL_DISP 0x0200
+# define RADEON_CRTC_H_TOTAL (0x03ff << 0)
+# define RADEON_CRTC_H_TOTAL_SHIFT 0
+# define RADEON_CRTC_H_DISP (0x01ff << 16)
+# define RADEON_CRTC_H_DISP_SHIFT 16
+#define RADEON_CRTC2_H_TOTAL_DISP 0x0300
+# define RADEON_CRTC2_H_TOTAL (0x03ff << 0)
+# define RADEON_CRTC2_H_TOTAL_SHIFT 0
+# define RADEON_CRTC2_H_DISP (0x01ff << 16)
+# define RADEON_CRTC2_H_DISP_SHIFT 16
+#define RADEON_CRTC_OFFSET 0x0224
+#define RADEON_CRTC2_OFFSET 0x0324
+#define RADEON_CRTC_OFFSET_CNTL 0x0228
+# define RADEON_CRTC_TILE_EN (1 << 15)
+#define RADEON_CRTC2_OFFSET_CNTL 0x0328
+# define RADEON_CRTC2_TILE_EN (1 << 15)
+#define RADEON_CRTC_PITCH 0x022c
+#define RADEON_CRTC2_PITCH 0x032c
+#define RADEON_CRTC_STATUS 0x005c
+# define RADEON_CRTC_VBLANK_SAVE (1 << 1)
+# define RADEON_CRTC_VBLANK_SAVE_CLEAR (1 << 1)
+#define RADEON_CRTC2_STATUS 0x03fc
+# define RADEON_CRTC2_VBLANK_SAVE (1 << 1)
+# define RADEON_CRTC2_VBLANK_SAVE_CLEAR (1 << 1)
+#define RADEON_CRTC_V_SYNC_STRT_WID 0x020c
+# define RADEON_CRTC_V_SYNC_STRT (0x7ff << 0)
+# define RADEON_CRTC_V_SYNC_STRT_SHIFT 0
+# define RADEON_CRTC_V_SYNC_WID (0x1f << 16)
+# define RADEON_CRTC_V_SYNC_WID_SHIFT 16
+# define RADEON_CRTC_V_SYNC_POL (1 << 23)
+#define RADEON_CRTC2_V_SYNC_STRT_WID 0x030c
+# define RADEON_CRTC2_V_SYNC_STRT (0x7ff << 0)
+# define RADEON_CRTC2_V_SYNC_STRT_SHIFT 0
+# define RADEON_CRTC2_V_SYNC_WID (0x1f << 16)
+# define RADEON_CRTC2_V_SYNC_WID_SHIFT 16
+# define RADEON_CRTC2_V_SYNC_POL (1 << 23)
+#define RADEON_CRTC_V_TOTAL_DISP 0x0208
+# define RADEON_CRTC_V_TOTAL (0x07ff << 0)
+# define RADEON_CRTC_V_TOTAL_SHIFT 0
+# define RADEON_CRTC_V_DISP (0x07ff << 16)
+# define RADEON_CRTC_V_DISP_SHIFT 16
+#define RADEON_CRTC2_V_TOTAL_DISP 0x0308
+# define RADEON_CRTC2_V_TOTAL (0x07ff << 0)
+# define RADEON_CRTC2_V_TOTAL_SHIFT 0
+# define RADEON_CRTC2_V_DISP (0x07ff << 16)
+# define RADEON_CRTC2_V_DISP_SHIFT 16
+#define RADEON_CRTC_VLINE_CRNT_VLINE 0x0210
+# define RADEON_CRTC_CRNT_VLINE_MASK (0x7ff << 16)
+#define RADEON_CRTC2_CRNT_FRAME 0x0314
+#define RADEON_CRTC2_GUI_TRIG_VLINE 0x0318
+#define RADEON_CRTC2_STATUS 0x03fc
+#define RADEON_CRTC2_VLINE_CRNT_VLINE 0x0310
+#define RADEON_CRTC8_DATA 0x03d5 /* VGA, 0x3b5 */
+#define RADEON_CRTC8_IDX 0x03d4 /* VGA, 0x3b4 */
+#define RADEON_CUR_CLR0 0x026c
+#define RADEON_CUR_CLR1 0x0270
+#define RADEON_CUR_HORZ_VERT_OFF 0x0268
+#define RADEON_CUR_HORZ_VERT_POSN 0x0264
+#define RADEON_CUR_OFFSET 0x0260
+# define RADEON_CUR_LOCK (1 << 31)
+#define RADEON_CUR2_CLR0 0x036c
+#define RADEON_CUR2_CLR1 0x0370
+#define RADEON_CUR2_HORZ_VERT_OFF 0x0368
+#define RADEON_CUR2_HORZ_VERT_POSN 0x0364
+#define RADEON_CUR2_OFFSET 0x0360
+# define RADEON_CUR2_LOCK (1 << 31)
+
+#define RADEON_DAC_CNTL 0x0058
+# define RADEON_DAC_RANGE_CNTL (3 << 0)
+# define RADEON_DAC_RANGE_CNTL_MASK 0x03
+# define RADEON_DAC_BLANKING (1 << 2)
+# define RADEON_DAC_CMP_EN (1 << 3)
+# define RADEON_DAC_CMP_OUTPUT (1 << 7)
+# define RADEON_DAC_8BIT_EN (1 << 8)
+# define RADEON_DAC_VGA_ADR_EN (1 << 13)
+# define RADEON_DAC_PDWN (1 << 15)
+# define RADEON_DAC_MASK_ALL (0xff << 24)
+#define RADEON_DAC_CNTL2 0x007c
+# define RADEON_DAC2_DAC_CLK_SEL (1 << 0)
+# define RADEON_DAC2_DAC2_CLK_SEL (1 << 1)
+# define RADEON_DAC2_PALETTE_ACC_CTL (1 << 5)
+#define RADEON_DAC_EXT_CNTL 0x0280
+# define RADEON_DAC_FORCE_BLANK_OFF_EN (1 << 4)
+# define RADEON_DAC_FORCE_DATA_EN (1 << 5)
+# define RADEON_DAC_FORCE_DATA_SEL_MASK (3 << 6)
+# define RADEON_DAC_FORCE_DATA_MASK 0x0003ff00
+# define RADEON_DAC_FORCE_DATA_SHIFT 8
+#define RADEON_TV_DAC_CNTL 0x088c
+# define RADEON_TV_DAC_STD_MASK 0x0300
+# define RADEON_TV_DAC_RDACPD (1 << 24)
+# define RADEON_TV_DAC_GDACPD (1 << 25)
+# define RADEON_TV_DAC_BDACPD (1 << 26)
+#define RADEON_DISP_HW_DEBUG 0x0d14
+# define RADEON_CRT2_DISP1_SEL (1 << 5)
+#define RADEON_DISP_OUTPUT_CNTL 0x0d64
+# define RADEON_DISP_DAC_SOURCE_MASK 0x03
+# define RADEON_DISP_DAC2_SOURCE_MASK 0x0c
+# define RADEON_DISP_DAC_SOURCE_CRTC2 0x01
+# define RADEON_DISP_DAC2_SOURCE_CRTC2 0x04
+#define RADEON_DAC_CRC_SIG 0x02cc
+#define RADEON_DAC_DATA 0x03c9 /* VGA */
+#define RADEON_DAC_MASK 0x03c6 /* VGA */
+#define RADEON_DAC_R_INDEX 0x03c7 /* VGA */
+#define RADEON_DAC_W_INDEX 0x03c8 /* VGA */
+#define RADEON_DDA_CONFIG 0x02e0
+#define RADEON_DDA_ON_OFF 0x02e4
+#define RADEON_DEFAULT_OFFSET 0x16e0
+#define RADEON_DEFAULT_PITCH 0x16e4
+#define RADEON_DEFAULT_SC_BOTTOM_RIGHT 0x16e8
+# define RADEON_DEFAULT_SC_RIGHT_MAX (0x1fff << 0)
+# define RADEON_DEFAULT_SC_BOTTOM_MAX (0x1fff << 16)
+#define RADEON_DESTINATION_3D_CLR_CMP_VAL 0x1820
+#define RADEON_DESTINATION_3D_CLR_CMP_MSK 0x1824
+#define RADEON_DEVICE_ID 0x0f02 /* PCI */
+#define RADEON_DISP_MISC_CNTL 0x0d00
+# define RADEON_SOFT_RESET_GRPH_PP (1 << 0)
+#define RADEON_DISP_MERGE_CNTL 0x0d60
+# define RADEON_DISP_ALPHA_MODE_MASK 0x03
+# define RADEON_DISP_ALPHA_MODE_KEY 0
+# define RADEON_DISP_ALPHA_MODE_PER_PIXEL 1
+# define RADEON_DISP_ALPHA_MODE_GLOBAL 2
+# define RADEON_DISP_RGB_OFFSET_EN (1<<8)
+# define RADEON_DISP_GRPH_ALPHA_MASK (0xff << 16)
+# define RADEON_DISP_OV0_ALPHA_MASK (0xff << 24)
+# define RADEON_DISP_LIN_TRANS_BYPASS (0x01 << 9)
+#define RADEON_DISP2_MERGE_CNTL 0x0d68
+# define RADEON_DISP2_RGB_OFFSET_EN (1<<8)
+#define RADEON_DISP_LIN_TRANS_GRPH_A 0x0d80
+#define RADEON_DISP_LIN_TRANS_GRPH_B 0x0d84
+#define RADEON_DISP_LIN_TRANS_GRPH_C 0x0d88
+#define RADEON_DISP_LIN_TRANS_GRPH_D 0x0d8c
+#define RADEON_DISP_LIN_TRANS_GRPH_E 0x0d90
+#define RADEON_DISP_LIN_TRANS_GRPH_F 0x0d98
+#define RADEON_DP_BRUSH_BKGD_CLR 0x1478
+#define RADEON_DP_BRUSH_FRGD_CLR 0x147c
+#define RADEON_DP_CNTL 0x16c0
+# define RADEON_DST_X_LEFT_TO_RIGHT (1 << 0)
+# define RADEON_DST_Y_TOP_TO_BOTTOM (1 << 1)
+#define RADEON_DP_CNTL_XDIR_YDIR_YMAJOR 0x16d0
+# define RADEON_DST_Y_MAJOR (1 << 2)
+# define RADEON_DST_Y_DIR_TOP_TO_BOTTOM (1 << 15)
+# define RADEON_DST_X_DIR_LEFT_TO_RIGHT (1 << 31)
+#define RADEON_DP_DATATYPE 0x16c4
+# define RADEON_HOST_BIG_ENDIAN_EN (1 << 29)
+#define RADEON_DP_GUI_MASTER_CNTL 0x146c
+# define RADEON_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0)
+# define RADEON_GMC_DST_PITCH_OFFSET_CNTL (1 << 1)
+# define RADEON_GMC_SRC_CLIPPING (1 << 2)
+# define RADEON_GMC_DST_CLIPPING (1 << 3)
+# define RADEON_GMC_BRUSH_DATATYPE_MASK (0x0f << 4)
+# define RADEON_GMC_BRUSH_8X8_MONO_FG_BG (0 << 4)
+# define RADEON_GMC_BRUSH_8X8_MONO_FG_LA (1 << 4)
+# define RADEON_GMC_BRUSH_1X8_MONO_FG_BG (4 << 4)
+# define RADEON_GMC_BRUSH_1X8_MONO_FG_LA (5 << 4)
+# define RADEON_GMC_BRUSH_32x1_MONO_FG_BG (6 << 4)
+# define RADEON_GMC_BRUSH_32x1_MONO_FG_LA (7 << 4)
+# define RADEON_GMC_BRUSH_32x32_MONO_FG_BG (8 << 4)
+# define RADEON_GMC_BRUSH_32x32_MONO_FG_LA (9 << 4)
+# define RADEON_GMC_BRUSH_8x8_COLOR (10 << 4)
+# define RADEON_GMC_BRUSH_1X8_COLOR (12 << 4)
+# define RADEON_GMC_BRUSH_SOLID_COLOR (13 << 4)
+# define RADEON_GMC_BRUSH_NONE (15 << 4)
+# define RADEON_GMC_DST_8BPP_CI (2 << 8)
+# define RADEON_GMC_DST_15BPP (3 << 8)
+# define RADEON_GMC_DST_16BPP (4 << 8)
+# define RADEON_GMC_DST_24BPP (5 << 8)
+# define RADEON_GMC_DST_32BPP (6 << 8)
+# define RADEON_GMC_DST_8BPP_RGB (7 << 8)
+# define RADEON_GMC_DST_Y8 (8 << 8)
+# define RADEON_GMC_DST_RGB8 (9 << 8)
+# define RADEON_GMC_DST_VYUY (11 << 8)
+# define RADEON_GMC_DST_YVYU (12 << 8)
+# define RADEON_GMC_DST_AYUV444 (14 << 8)
+# define RADEON_GMC_DST_ARGB4444 (15 << 8)
+# define RADEON_GMC_DST_DATATYPE_MASK (0x0f << 8)
+# define RADEON_GMC_DST_DATATYPE_SHIFT 8
+# define RADEON_GMC_SRC_DATATYPE_MASK (3 << 12)
+# define RADEON_GMC_SRC_DATATYPE_MONO_FG_BG (0 << 12)
+# define RADEON_GMC_SRC_DATATYPE_MONO_FG_LA (1 << 12)
+# define RADEON_GMC_SRC_DATATYPE_COLOR (3 << 12)
+# define RADEON_GMC_BYTE_PIX_ORDER (1 << 14)
+# define RADEON_GMC_BYTE_MSB_TO_LSB (0 << 14)
+# define RADEON_GMC_BYTE_LSB_TO_MSB (1 << 14)
+# define RADEON_GMC_CONVERSION_TEMP (1 << 15)
+# define RADEON_GMC_CONVERSION_TEMP_6500 (0 << 15)
+# define RADEON_GMC_CONVERSION_TEMP_9300 (1 << 15)
+# define RADEON_GMC_ROP3_MASK (0xff << 16)
+# define RADEON_DP_SRC_SOURCE_MASK (7 << 24)
+# define RADEON_DP_SRC_SOURCE_MEMORY (2 << 24)
+# define RADEON_DP_SRC_SOURCE_HOST_DATA (3 << 24)
+# define RADEON_GMC_3D_FCN_EN (1 << 27)
+# define RADEON_GMC_CLR_CMP_CNTL_DIS (1 << 28)
+# define RADEON_GMC_AUX_CLIP_DIS (1 << 29)
+# define RADEON_GMC_WR_MSK_DIS (1 << 30)
+# define RADEON_GMC_LD_BRUSH_Y_X (1 << 31)
+# define RADEON_ROP3_ZERO 0x00000000
+# define RADEON_ROP3_DSa 0x00880000
+# define RADEON_ROP3_SDna 0x00440000
+# define RADEON_ROP3_S 0x00cc0000
+# define RADEON_ROP3_DSna 0x00220000
+# define RADEON_ROP3_D 0x00aa0000
+# define RADEON_ROP3_DSx 0x00660000
+# define RADEON_ROP3_DSo 0x00ee0000
+# define RADEON_ROP3_DSon 0x00110000
+# define RADEON_ROP3_DSxn 0x00990000
+# define RADEON_ROP3_Dn 0x00550000
+# define RADEON_ROP3_SDno 0x00dd0000
+# define RADEON_ROP3_Sn 0x00330000
+# define RADEON_ROP3_DSno 0x00bb0000
+# define RADEON_ROP3_DSan 0x00770000
+# define RADEON_ROP3_ONE 0x00ff0000
+# define RADEON_ROP3_DPa 0x00a00000
+# define RADEON_ROP3_PDna 0x00500000
+# define RADEON_ROP3_P 0x00f00000
+# define RADEON_ROP3_DPna 0x000a0000
+# define RADEON_ROP3_D 0x00aa0000
+# define RADEON_ROP3_DPx 0x005a0000
+# define RADEON_ROP3_DPo 0x00fa0000
+# define RADEON_ROP3_DPon 0x00050000
+# define RADEON_ROP3_PDxn 0x00a50000
+# define RADEON_ROP3_PDno 0x00f50000
+# define RADEON_ROP3_Pn 0x000f0000
+# define RADEON_ROP3_DPno 0x00af0000
+# define RADEON_ROP3_DPan 0x005f0000
+#define RADEON_DP_GUI_MASTER_CNTL_C 0x1c84
+#define RADEON_DP_MIX 0x16c8
+#define RADEON_DP_SRC_BKGD_CLR 0x15dc
+#define RADEON_DP_SRC_FRGD_CLR 0x15d8
+#define RADEON_DP_WRITE_MASK 0x16cc
+#define RADEON_DST_BRES_DEC 0x1630
+#define RADEON_DST_BRES_ERR 0x1628
+#define RADEON_DST_BRES_INC 0x162c
+#define RADEON_DST_BRES_LNTH 0x1634
+#define RADEON_DST_BRES_LNTH_SUB 0x1638
+#define RADEON_DST_HEIGHT 0x1410
+#define RADEON_DST_HEIGHT_WIDTH 0x143c
+#define RADEON_DST_HEIGHT_WIDTH_8 0x158c
+#define RADEON_DST_HEIGHT_WIDTH_BW 0x15b4
+#define RADEON_DST_HEIGHT_Y 0x15a0
+#define RADEON_DST_LINE_START 0x1600
+#define RADEON_DST_LINE_END 0x1604
+#define RADEON_DST_LINE_PATCOUNT 0x1608
+# define RADEON_BRES_CNTL_SHIFT 8
+#define RADEON_DST_OFFSET 0x1404
+#define RADEON_DST_PITCH 0x1408
+#define RADEON_DST_PITCH_OFFSET 0x142c
+#define RADEON_DST_PITCH_OFFSET_C 0x1c80
+# define RADEON_PITCH_SHIFT 21
+# define RADEON_DST_TILE_LINEAR (0 << 30)
+# define RADEON_DST_TILE_MACRO (1 << 30)
+# define RADEON_DST_TILE_MICRO (2 << 30)
+# define RADEON_DST_TILE_BOTH (3 << 30)
+#define RADEON_DST_WIDTH 0x140c
+#define RADEON_DST_WIDTH_HEIGHT 0x1598
+#define RADEON_DST_WIDTH_X 0x1588
+#define RADEON_DST_WIDTH_X_INCY 0x159c
+#define RADEON_DST_X 0x141c
+#define RADEON_DST_X_SUB 0x15a4
+#define RADEON_DST_X_Y 0x1594
+#define RADEON_DST_Y 0x1420
+#define RADEON_DST_Y_SUB 0x15a8
+#define RADEON_DST_Y_X 0x1438
+
+#define RADEON_FCP_CNTL 0x0910
+# define RADEON_FCP0_SRC_PCICLK 0
+# define RADEON_FCP0_SRC_PCLK 1
+# define RADEON_FCP0_SRC_PCLKb 2
+# define RADEON_FCP0_SRC_HREF 3
+# define RADEON_FCP0_SRC_GND 4
+# define RADEON_FCP0_SRC_HREFb 5
+#define RADEON_FLUSH_1 0x1704
+#define RADEON_FLUSH_2 0x1708
+#define RADEON_FLUSH_3 0x170c
+#define RADEON_FLUSH_4 0x1710
+#define RADEON_FLUSH_5 0x1714
+#define RADEON_FLUSH_6 0x1718
+#define RADEON_FLUSH_7 0x171c
+#define RADEON_FOG_3D_TABLE_START 0x1810
+#define RADEON_FOG_3D_TABLE_END 0x1814
+#define RADEON_FOG_3D_TABLE_DENSITY 0x181c
+#define RADEON_FOG_TABLE_INDEX 0x1a14
+#define RADEON_FOG_TABLE_DATA 0x1a18
+#define RADEON_FP_CRTC_H_TOTAL_DISP 0x0250
+#define RADEON_FP_CRTC_V_TOTAL_DISP 0x0254
+#define RADEON_FP_CRTC2_H_TOTAL_DISP 0x0350
+#define RADEON_FP_CRTC2_V_TOTAL_DISP 0x0354
+# define RADEON_FP_CRTC_H_TOTAL_MASK 0x000003ff
+# define RADEON_FP_CRTC_H_DISP_MASK 0x01ff0000
+# define RADEON_FP_CRTC_V_TOTAL_MASK 0x00000fff
+# define RADEON_FP_CRTC_V_DISP_MASK 0x0fff0000
+# define RADEON_FP_H_SYNC_STRT_CHAR_MASK 0x00001ff8
+# define RADEON_FP_H_SYNC_WID_MASK 0x003f0000
+# define RADEON_FP_V_SYNC_STRT_MASK 0x00000fff
+# define RADEON_FP_V_SYNC_WID_MASK 0x001f0000
+# define RADEON_FP_CRTC_H_TOTAL_SHIFT 0x00000000
+# define RADEON_FP_CRTC_H_DISP_SHIFT 0x00000010
+# define RADEON_FP_CRTC_V_TOTAL_SHIFT 0x00000000
+# define RADEON_FP_CRTC_V_DISP_SHIFT 0x00000010
+# define RADEON_FP_H_SYNC_STRT_CHAR_SHIFT 0x00000003
+# define RADEON_FP_H_SYNC_WID_SHIFT 0x00000010
+# define RADEON_FP_V_SYNC_STRT_SHIFT 0x00000000
+# define RADEON_FP_V_SYNC_WID_SHIFT 0x00000010
+#define RADEON_FP_GEN_CNTL 0x0284
+# define RADEON_FP_FPON (1 << 0)
+# define RADEON_FP_TMDS_EN (1 << 2)
+# define RADEON_FP_PANEL_FORMAT (1 << 3)
+# define RADEON_FP_EN_TMDS (1 << 7)
+# define RADEON_FP_DETECT_SENSE (1 << 8)
+# define RADEON_FP_SEL_CRTC2 (1 << 13)
+# define RADEON_FP_CRTC_DONT_SHADOW_HPAR (1 << 15)
+# define RADEON_FP_CRTC_DONT_SHADOW_VPAR (1 << 16)
+# define RADEON_FP_CRTC_DONT_SHADOW_HEND (1 << 17)
+# define RADEON_FP_CRTC_USE_SHADOW_VEND (1 << 18)
+# define RADEON_FP_RMX_HVSYNC_CONTROL_EN (1 << 20)
+# define RADEON_FP_DFP_SYNC_SEL (1 << 21)
+# define RADEON_FP_CRTC_LOCK_8DOT (1 << 22)
+# define RADEON_FP_CRT_SYNC_SEL (1 << 23)
+# define RADEON_FP_USE_SHADOW_EN (1 << 24)
+# define RADEON_FP_CRT_SYNC_ALT (1 << 26)
+#define RADEON_FP2_GEN_CNTL 0x0288
+# define RADEON_FP2_BLANK_EN (1 << 1)
+# define RADEON_FP2_ON (1 << 2)
+# define RADEON_FP2_PANEL_FORMAT (1 << 3)
+# define RADEON_FP2_SOURCE_SEL_MASK (3 << 10)
+# define RADEON_FP2_SOURCE_SEL_CRTC2 (1 << 10)
+# define RADEON_FP2_SRC_SEL_MASK (3 << 13)
+# define RADEON_FP2_SRC_SEL_CRTC2 (1 << 13)
+# define RADEON_FP2_FP_POL (1 << 16)
+# define RADEON_FP2_LP_POL (1 << 17)
+# define RADEON_FP2_SCK_POL (1 << 18)
+# define RADEON_FP2_LCD_CNTL_MASK (7 << 19)
+# define RADEON_FP2_PAD_FLOP_EN (1 << 22)
+# define RADEON_FP2_CRC_EN (1 << 23)
+# define RADEON_FP2_CRC_READ_EN (1 << 24)
+# define RADEON_FP2_DV0_EN (1 << 25)
+# define RADEON_FP2_DV0_RATE_SEL_SDR (1 << 26)
+#define RADEON_FP_H_SYNC_STRT_WID 0x02c4
+#define RADEON_FP_H2_SYNC_STRT_WID 0x03c4
+#define RADEON_FP_HORZ_STRETCH 0x028c
+#define RADEON_FP_HORZ2_STRETCH 0x038c
+# define RADEON_HORZ_STRETCH_RATIO_MASK 0xffff
+# define RADEON_HORZ_STRETCH_RATIO_MAX 4096
+# define RADEON_HORZ_PANEL_SIZE (0x1ff << 16)
+# define RADEON_HORZ_PANEL_SHIFT 16
+# define RADEON_HORZ_STRETCH_PIXREP (0 << 25)
+# define RADEON_HORZ_STRETCH_BLEND (1 << 26)
+# define RADEON_HORZ_STRETCH_ENABLE (1 << 25)
+# define RADEON_HORZ_AUTO_RATIO (1 << 27)
+# define RADEON_HORZ_FP_LOOP_STRETCH (0x7 << 28)
+# define RADEON_HORZ_AUTO_RATIO_INC (1 << 31)
+#define RADEON_FP_V_SYNC_STRT_WID 0x02c8
+#define RADEON_FP_VERT_STRETCH 0x0290
+#define RADEON_FP_V2_SYNC_STRT_WID 0x03c8
+#define RADEON_FP_VERT2_STRETCH 0x0390
+# define RADEON_VERT_PANEL_SIZE (0xfff << 12)
+# define RADEON_VERT_PANEL_SHIFT 12
+# define RADEON_VERT_STRETCH_RATIO_MASK 0xfff
+# define RADEON_VERT_STRETCH_RATIO_SHIFT 0
+# define RADEON_VERT_STRETCH_RATIO_MAX 4096
+# define RADEON_VERT_STRETCH_ENABLE (1 << 25)
+# define RADEON_VERT_STRETCH_LINEREP (0 << 26)
+# define RADEON_VERT_STRETCH_BLEND (1 << 26)
+# define RADEON_VERT_AUTO_RATIO_EN (1 << 27)
+# define RADEON_VERT_STRETCH_RESERVED 0xf1000000
+
+#define RADEON_GEN_INT_CNTL 0x0040
+#define RADEON_GEN_INT_STATUS 0x0044
+# define RADEON_VSYNC_INT_AK (1 << 2)
+# define RADEON_VSYNC_INT (1 << 2)
+# define RADEON_VSYNC2_INT_AK (1 << 6)
+# define RADEON_VSYNC2_INT (1 << 6)
+#define RADEON_GENENB 0x03c3 /* VGA */
+#define RADEON_GENFC_RD 0x03ca /* VGA */
+#define RADEON_GENFC_WT 0x03da /* VGA, 0x03ba */
+#define RADEON_GENMO_RD 0x03cc /* VGA */
+#define RADEON_GENMO_WT 0x03c2 /* VGA */
+#define RADEON_GENS0 0x03c2 /* VGA */
+#define RADEON_GENS1 0x03da /* VGA, 0x03ba */
+#define RADEON_GPIO_MONID 0x0068 /* DDC interface via I2C */
+#define RADEON_GPIO_MONIDB 0x006c
+#define RADEON_GPIO_CRT2_DDC 0x006c
+#define RADEON_GPIO_DVI_DDC 0x0064
+#define RADEON_GPIO_VGA_DDC 0x0060
+# define RADEON_GPIO_A_0 (1 << 0)
+# define RADEON_GPIO_A_1 (1 << 1)
+# define RADEON_GPIO_Y_0 (1 << 8)
+# define RADEON_GPIO_Y_1 (1 << 9)
+# define RADEON_GPIO_Y_SHIFT_0 8
+# define RADEON_GPIO_Y_SHIFT_1 9
+# define RADEON_GPIO_EN_0 (1 << 16)
+# define RADEON_GPIO_EN_1 (1 << 17)
+# define RADEON_GPIO_MASK_0 (1 << 24) /*??*/
+# define RADEON_GPIO_MASK_1 (1 << 25) /*??*/
+#define RADEON_GRPH8_DATA 0x03cf /* VGA */
+#define RADEON_GRPH8_IDX 0x03ce /* VGA */
+#define RADEON_GUI_SCRATCH_REG0 0x15e0
+#define RADEON_GUI_SCRATCH_REG1 0x15e4
+#define RADEON_GUI_SCRATCH_REG2 0x15e8
+#define RADEON_GUI_SCRATCH_REG3 0x15ec
+#define RADEON_GUI_SCRATCH_REG4 0x15f0
+#define RADEON_GUI_SCRATCH_REG5 0x15f4
+
+#define RADEON_HEADER 0x0f0e /* PCI */
+#define RADEON_HOST_DATA0 0x17c0
+#define RADEON_HOST_DATA1 0x17c4
+#define RADEON_HOST_DATA2 0x17c8
+#define RADEON_HOST_DATA3 0x17cc
+#define RADEON_HOST_DATA4 0x17d0
+#define RADEON_HOST_DATA5 0x17d4
+#define RADEON_HOST_DATA6 0x17d8
+#define RADEON_HOST_DATA7 0x17dc
+#define RADEON_HOST_DATA_LAST 0x17e0
+#define RADEON_HOST_PATH_CNTL 0x0130
+# define RADEON_HDP_SOFT_RESET (1 << 26)
+#define RADEON_HTOTAL_CNTL 0x0009 /* PLL */
+#define RADEON_HTOTAL2_CNTL 0x002e /* PLL */
+
+#define RADEON_I2C_CNTL_1 0x0094 /* ? */
+#define RADEON_DVI_I2C_CNTL_1 0x02e4 /* ? */
+#define RADEON_INTERRUPT_LINE 0x0f3c /* PCI */
+#define RADEON_INTERRUPT_PIN 0x0f3d /* PCI */
+#define RADEON_IO_BASE 0x0f14 /* PCI */
+
+#define RADEON_LATENCY 0x0f0d /* PCI */
+#define RADEON_LEAD_BRES_DEC 0x1608
+#define RADEON_LEAD_BRES_LNTH 0x161c
+#define RADEON_LEAD_BRES_LNTH_SUB 0x1624
+#define RADEON_LVDS_GEN_CNTL 0x02d0
+# define RADEON_LVDS_ON (1 << 0)
+# define RADEON_LVDS_DISPLAY_DIS (1 << 1)
+# define RADEON_LVDS_PANEL_TYPE (1 << 2)
+# define RADEON_LVDS_PANEL_FORMAT (1 << 3)
+# define RADEON_LVDS_EN (1 << 7)
+# define RADEON_LVDS_DIGON (1 << 18)
+# define RADEON_LVDS_BLON (1 << 19)
+# define RADEON_LVDS_SEL_CRTC2 (1 << 23)
+#define RADEON_LVDS_PLL_CNTL 0x02d4
+# define RADEON_HSYNC_DELAY_SHIFT 28
+# define RADEON_HSYNC_DELAY_MASK (0xf << 28)
+
+#define RADEON_MAX_LATENCY 0x0f3f /* PCI */
+#define RADEON_MC_AGP_LOCATION 0x014c
+#define RADEON_MC_FB_LOCATION 0x0148
+#define RADEON_DISPLAY_BASE_ADDR 0x23c
+#define RADEON_DISPLAY2_BASE_ADDR 0x33c
+#define RADEON_OV0_BASE_ADDR 0x43c
+#define RADEON_NB_TOM 0x15c
+#define RADEON_MCLK_CNTL 0x0012 /* PLL */
+# define RADEON_FORCEON_MCLKA (1 << 16)
+# define RADEON_FORCEON_MCLKB (1 << 17)
+# define RADEON_FORCEON_YCLKA (1 << 18)
+# define RADEON_FORCEON_YCLKB (1 << 19)
+# define RADEON_FORCEON_MC (1 << 20)
+# define RADEON_FORCEON_AIC (1 << 21)
+#define RADEON_MDGPIO_A_REG 0x01ac
+#define RADEON_MDGPIO_EN_REG 0x01b0
+#define RADEON_MDGPIO_MASK 0x0198
+#define RADEON_MDGPIO_Y_REG 0x01b4
+#define RADEON_MEM_ADDR_CONFIG 0x0148
+#define RADEON_MEM_BASE 0x0f10 /* PCI */
+#define RADEON_MEM_CNTL 0x0140
+# define RADEON_MEM_NUM_CHANNELS_MASK 0x01
+# define RADEON_MEM_USE_B_CH_ONLY (1<<1)
+# define RV100_HALF_MODE (1<<3)
+# define R300_MEM_NUM_CHANNELS_MASK 0x03
+# define R300_MEM_USE_CD_CH_ONLY (1<<2)
+#define RADEON_MEM_TIMING_CNTL 0x0144 /* EXT_MEM_CNTL */
+#define RADEON_MEM_INIT_LAT_TIMER 0x0154
+#define RADEON_MEM_INTF_CNTL 0x014c
+#define RADEON_MEM_SDRAM_MODE_REG 0x0158
+#define RADEON_MEM_STR_CNTL 0x0150
+#define RADEON_MEM_VGA_RP_SEL 0x003c
+#define RADEON_MEM_VGA_WP_SEL 0x0038
+#define RADEON_MIN_GRANT 0x0f3e /* PCI */
+#define RADEON_MM_DATA 0x0004
+#define RADEON_MM_INDEX 0x0000
+#define RADEON_MPLL_CNTL 0x000e /* PLL */
+#define RADEON_MPP_TB_CONFIG 0x01c0 /* ? */
+#define RADEON_MPP_GP_CONFIG 0x01c8 /* ? */
+#define R300_MC_IND_INDEX 0x01f8
+# define R300_MC_IND_ADDR_MASK 0x3f
+#define R300_MC_IND_DATA 0x01fc
+#define R300_MC_READ_CNTL_AB 0x017c
+# define R300_MEM_RBS_POSITION_A_MASK 0x03
+#define R300_MC_READ_CNTL_CD_mcind 0x24
+# define R300_MEM_RBS_POSITION_C_MASK 0x03
+
+#define RADEON_N_VIF_COUNT 0x0248
+
+#define RADEON_OV0_AUTO_FLIP_CNTL 0x0470
+#define RADEON_OV0_COLOUR_CNTL 0x04E0
+#define RADEON_OV0_DEINTERLACE_PATTERN 0x0474
+#define RADEON_OV0_EXCLUSIVE_HORZ 0x0408
+# define RADEON_EXCL_HORZ_START_MASK 0x000000ff
+# define RADEON_EXCL_HORZ_END_MASK 0x0000ff00
+# define RADEON_EXCL_HORZ_BACK_PORCH_MASK 0x00ff0000
+# define RADEON_EXCL_HORZ_EXCLUSIVE_EN 0x80000000
+#define RADEON_OV0_EXCLUSIVE_VERT 0x040C
+# define RADEON_EXCL_VERT_START_MASK 0x000003ff
+# define RADEON_EXCL_VERT_END_MASK 0x03ff0000
+#define RADEON_OV0_FILTER_CNTL 0x04A0
+#define RADEON_OV0_FOUR_TAP_COEF_0 0x04B0
+#define RADEON_OV0_FOUR_TAP_COEF_1 0x04B4
+#define RADEON_OV0_FOUR_TAP_COEF_2 0x04B8
+#define RADEON_OV0_FOUR_TAP_COEF_3 0x04BC
+#define RADEON_OV0_FOUR_TAP_COEF_4 0x04C0
+#define RADEON_OV0_GAMMA_000_00F 0x0d40
+#define RADEON_OV0_GAMMA_010_01F 0x0d44
+#define RADEON_OV0_GAMMA_020_03F 0x0d48
+#define RADEON_OV0_GAMMA_040_07F 0x0d4c
+#define RADEON_OV0_GAMMA_080_0BF 0x0e00
+#define RADEON_OV0_GAMMA_0C0_0FF 0x0e04
+#define RADEON_OV0_GAMMA_100_13F 0x0e08
+#define RADEON_OV0_GAMMA_140_17F 0x0e0c
+#define RADEON_OV0_GAMMA_180_1BF 0x0e10
+#define RADEON_OV0_GAMMA_1C0_1FF 0x0e14
+#define RADEON_OV0_GAMMA_200_23F 0x0e18
+#define RADEON_OV0_GAMMA_240_27F 0x0e1c
+#define RADEON_OV0_GAMMA_280_2BF 0x0e20
+#define RADEON_OV0_GAMMA_2C0_2FF 0x0e24
+#define RADEON_OV0_GAMMA_300_33F 0x0e28
+#define RADEON_OV0_GAMMA_340_37F 0x0e2c
+#define RADEON_OV0_GAMMA_380_3BF 0x0d50
+#define RADEON_OV0_GAMMA_3C0_3FF 0x0d54
+#define RADEON_OV0_GRAPHICS_KEY_CLR_LOW 0x04EC
+#define RADEON_OV0_GRAPHICS_KEY_CLR_HIGH 0x04F0
+#define RADEON_OV0_H_INC 0x0480
+#define RADEON_OV0_KEY_CNTL 0x04F4
+# define RADEON_VIDEO_KEY_FN_MASK 0x00000003L
+# define RADEON_VIDEO_KEY_FN_FALSE 0x00000000L
+# define RADEON_VIDEO_KEY_FN_TRUE 0x00000001L
+# define RADEON_VIDEO_KEY_FN_EQ 0x00000002L
+# define RADEON_VIDEO_KEY_FN_NE 0x00000003L
+# define RADEON_GRAPHIC_KEY_FN_MASK 0x00000030L
+# define RADEON_GRAPHIC_KEY_FN_FALSE 0x00000000L
+# define RADEON_GRAPHIC_KEY_FN_TRUE 0x00000010L
+# define RADEON_GRAPHIC_KEY_FN_EQ 0x00000020L
+# define RADEON_GRAPHIC_KEY_FN_NE 0x00000030L
+# define RADEON_CMP_MIX_MASK 0x00000100L
+# define RADEON_CMP_MIX_OR 0x00000000L
+# define RADEON_CMP_MIX_AND 0x00000100L
+#define RADEON_OV0_LIN_TRANS_A 0x0d20
+#define RADEON_OV0_LIN_TRANS_B 0x0d24
+#define RADEON_OV0_LIN_TRANS_C 0x0d28
+#define RADEON_OV0_LIN_TRANS_D 0x0d2c
+#define RADEON_OV0_LIN_TRANS_E 0x0d30
+#define RADEON_OV0_LIN_TRANS_F 0x0d34
+#define RADEON_OV0_P1_BLANK_LINES_AT_TOP 0x0430
+# define RADEON_P1_BLNK_LN_AT_TOP_M1_MASK 0x00000fffL
+# define RADEON_P1_ACTIVE_LINES_M1 0x0fff0000L
+#define RADEON_OV0_P1_H_ACCUM_INIT 0x0488
+#define RADEON_OV0_P1_V_ACCUM_INIT 0x0428
+# define RADEON_OV0_P1_MAX_LN_IN_PER_LN_OUT 0x00000003L
+# define RADEON_OV0_P1_V_ACCUM_INIT_MASK 0x01ff8000L
+#define RADEON_OV0_P1_X_START_END 0x0494
+#define RADEON_OV0_P2_X_START_END 0x0498
+#define RADEON_OV0_P23_BLANK_LINES_AT_TOP 0x0434
+# define RADEON_P23_BLNK_LN_AT_TOP_M1_MASK 0x000007ffL
+# define RADEON_P23_ACTIVE_LINES_M1 0x07ff0000L
+#define RADEON_OV0_P23_H_ACCUM_INIT 0x048C
+#define RADEON_OV0_P23_V_ACCUM_INIT 0x042C
+#define RADEON_OV0_P3_X_START_END 0x049C
+#define RADEON_OV0_REG_LOAD_CNTL 0x0410
+# define RADEON_REG_LD_CTL_LOCK 0x00000001L
+# define RADEON_REG_LD_CTL_VBLANK_DURING_LOCK 0x00000002L
+# define RADEON_REG_LD_CTL_STALL_GUI_UNTIL_FLIP 0x00000004L
+# define RADEON_REG_LD_CTL_LOCK_READBACK 0x00000008L
+#define RADEON_OV0_SCALE_CNTL 0x0420
+# define RADEON_SCALER_HORZ_PICK_NEAREST 0x00000004L
+# define RADEON_SCALER_VERT_PICK_NEAREST 0x00000008L
+# define RADEON_SCALER_SIGNED_UV 0x00000010L
+# define RADEON_SCALER_GAMMA_SEL_MASK 0x00000060L
+# define RADEON_SCALER_GAMMA_SEL_BRIGHT 0x00000000L
+# define RADEON_SCALER_GAMMA_SEL_G22 0x00000020L
+# define RADEON_SCALER_GAMMA_SEL_G18 0x00000040L
+# define RADEON_SCALER_GAMMA_SEL_G14 0x00000060L
+# define RADEON_SCALER_COMCORE_SHIFT_UP_ONE 0x00000080L
+# define RADEON_SCALER_SURFAC_FORMAT 0x00000f00L
+# define RADEON_SCALER_SOURCE_15BPP 0x00000300L
+# define RADEON_SCALER_SOURCE_16BPP 0x00000400L
+# define RADEON_SCALER_SOURCE_32BPP 0x00000600L
+# define RADEON_SCALER_SOURCE_YUV9 0x00000900L
+# define RADEON_SCALER_SOURCE_YUV12 0x00000A00L
+# define RADEON_SCALER_SOURCE_VYUY422 0x00000B00L
+# define RADEON_SCALER_SOURCE_YVYU422 0x00000C00L
+# define RADEON_SCALER_ADAPTIVE_DEINT 0x00001000L
+# define RADEON_SCALER_TEMPORAL_DEINT 0x00002000L
+# define RADEON_SCALER_SMART_SWITCH 0x00008000L
+# define RADEON_SCALER_BURST_PER_PLANE 0x007F0000L
+# define RADEON_SCALER_DOUBLE_BUFFER 0x01000000L
+# define RADEON_SCALER_DIS_LIMIT 0x08000000L
+# define RADEON_SCALER_INT_EMU 0x20000000L
+# define RADEON_SCALER_ENABLE 0x40000000L
+# define RADEON_SCALER_SOFT_RESET 0x80000000L
+# define RADEON_SCALER_ADAPTIVE_DEINT 0x00001000L
+#define RADEON_OV0_STEP_BY 0x0484
+#define RADEON_OV0_TEST 0x04F8
+#define RADEON_OV0_V_INC 0x0424
+#define RADEON_OV0_VID_BUF_PITCH0_VALUE 0x0460
+#define RADEON_OV0_VID_BUF_PITCH1_VALUE 0x0464
+#define RADEON_OV0_VID_BUF0_BASE_ADRS 0x0440
+# define RADEON_VIF_BUF0_PITCH_SEL 0x00000001L
+# define RADEON_VIF_BUF0_TILE_ADRS 0x00000002L
+# define RADEON_VIF_BUF0_BASE_ADRS_MASK 0x03fffff0L
+# define RADEON_VIF_BUF0_1ST_LINE_LSBS_MASK 0x48000000L
+#define RADEON_OV0_VID_BUF1_BASE_ADRS 0x0444
+# define RADEON_VIF_BUF1_PITCH_SEL 0x00000001L
+# define RADEON_VIF_BUF1_TILE_ADRS 0x00000002L
+# define RADEON_VIF_BUF1_BASE_ADRS_MASK 0x03fffff0L
+# define RADEON_VIF_BUF1_1ST_LINE_LSBS_MASK 0x48000000L
+#define RADEON_OV0_VID_BUF2_BASE_ADRS 0x0448
+# define RADEON_VIF_BUF2_PITCH_SEL 0x00000001L
+# define RADEON_VIF_BUF2_TILE_ADRS 0x00000002L
+# define RADEON_VIF_BUF2_BASE_ADRS_MASK 0x03fffff0L
+# define RADEON_VIF_BUF2_1ST_LINE_LSBS_MASK 0x48000000L
+#define RADEON_OV0_VID_BUF3_BASE_ADRS 0x044C
+#define RADEON_OV0_VID_BUF4_BASE_ADRS 0x0450
+#define RADEON_OV0_VID_BUF5_BASE_ADRS 0x0454
+#define RADEON_OV0_VIDEO_KEY_CLR_HIGH 0x04E8
+#define RADEON_OV0_VIDEO_KEY_CLR_LOW 0x04E4
+#define RADEON_OV0_Y_X_START 0x0400
+#define RADEON_OV0_Y_X_END 0x0404
+#define RADEON_OV1_Y_X_START 0x0600
+#define RADEON_OV1_Y_X_END 0x0604
+#define RADEON_OVR_CLR 0x0230
+#define RADEON_OVR_WID_LEFT_RIGHT 0x0234
+#define RADEON_OVR_WID_TOP_BOTTOM 0x0238
+
+#define RADEON_P2PLL_CNTL 0x002a /* P2PLL */
+# define RADEON_P2PLL_RESET (1 << 0)
+# define RADEON_P2PLL_SLEEP (1 << 1)
+# define RADEON_P2PLL_ATOMIC_UPDATE_EN (1 << 16)
+# define RADEON_P2PLL_VGA_ATOMIC_UPDATE_EN (1 << 17)
+# define RADEON_P2PLL_ATOMIC_UPDATE_VSYNC (1 << 18)
+#define RADEON_P2PLL_DIV_0 0x002c
+# define RADEON_P2PLL_FB0_DIV_MASK 0x07ff
+# define RADEON_P2PLL_POST0_DIV_MASK 0x00070000
+#define RADEON_P2PLL_REF_DIV 0x002B /* PLL */
+# define RADEON_P2PLL_REF_DIV_MASK 0x03ff
+# define RADEON_P2PLL_ATOMIC_UPDATE_R (1 << 15) /* same as _W */
+# define RADEON_P2PLL_ATOMIC_UPDATE_W (1 << 15) /* same as _R */
+# define R300_PPLL_REF_DIV_ACC_MASK (0x3ff << 18)
+# define R300_PPLL_REF_DIV_ACC_SHIFT 18
+#define RADEON_PALETTE_DATA 0x00b4
+#define RADEON_PALETTE_30_DATA 0x00b8
+#define RADEON_PALETTE_INDEX 0x00b0
+#define RADEON_PCI_GART_PAGE 0x017c
+#define RADEON_PIXCLKS_CNTL 0x002d
+# define RADEON_PIX2CLK_SRC_SEL_MASK 0x03
+# define RADEON_PIX2CLK_SRC_SEL_CPUCLK 0x00
+# define RADEON_PIX2CLK_SRC_SEL_PSCANCLK 0x01
+# define RADEON_PIX2CLK_SRC_SEL_BYTECLK 0x02
+# define RADEON_PIX2CLK_SRC_SEL_P2PLLCLK 0x03
+# define RADEON_PIX2CLK_ALWAYS_ONb (1<<6)
+# define RADEON_PIX2CLK_DAC_ALWAYS_ONb (1<<7)
+# define RADEON_PIXCLK_TV_SRC_SEL (1 << 8)
+# define RADEON_PIXCLK_LVDS_ALWAYS_ONb (1 << 14)
+# define RADEON_PIXCLK_TMDS_ALWAYS_ONb (1 << 15)
+#define RADEON_PLANE_3D_MASK_C 0x1d44
+#define RADEON_PLL_TEST_CNTL 0x0013 /* PLL */
+#define RADEON_PMI_CAP_ID 0x0f5c /* PCI */
+#define RADEON_PMI_DATA 0x0f63 /* PCI */
+#define RADEON_PMI_NXT_CAP_PTR 0x0f5d /* PCI */
+#define RADEON_PMI_PMC_REG 0x0f5e /* PCI */
+#define RADEON_PMI_PMCSR_REG 0x0f60 /* PCI */
+#define RADEON_PMI_REGISTER 0x0f5c /* PCI */
+#define RADEON_PPLL_CNTL 0x0002 /* PLL */
+# define RADEON_PPLL_RESET (1 << 0)
+# define RADEON_PPLL_SLEEP (1 << 1)
+# define RADEON_PPLL_ATOMIC_UPDATE_EN (1 << 16)
+# define RADEON_PPLL_VGA_ATOMIC_UPDATE_EN (1 << 17)
+# define RADEON_PPLL_ATOMIC_UPDATE_VSYNC (1 << 18)
+#define RADEON_PPLL_DIV_0 0x0004 /* PLL */
+#define RADEON_PPLL_DIV_1 0x0005 /* PLL */
+#define RADEON_PPLL_DIV_2 0x0006 /* PLL */
+#define RADEON_PPLL_DIV_3 0x0007 /* PLL */
+# define RADEON_PPLL_FB3_DIV_MASK 0x07ff
+# define RADEON_PPLL_POST3_DIV_MASK 0x00070000
+#define RADEON_PPLL_REF_DIV 0x0003 /* PLL */
+# define RADEON_PPLL_REF_DIV_MASK 0x03ff
+# define RADEON_PPLL_ATOMIC_UPDATE_R (1 << 15) /* same as _W */
+# define RADEON_PPLL_ATOMIC_UPDATE_W (1 << 15) /* same as _R */
+#define RADEON_PWR_MNGMT_CNTL_STATUS 0x0f60 /* PCI */
+
+#define RADEON_RBBM_GUICNTL 0x172c
+# define RADEON_HOST_DATA_SWAP_NONE (0 << 0)
+# define RADEON_HOST_DATA_SWAP_16BIT (1 << 0)
+# define RADEON_HOST_DATA_SWAP_32BIT (2 << 0)
+# define RADEON_HOST_DATA_SWAP_HDW (3 << 0)
+#define RADEON_RBBM_SOFT_RESET 0x00f0
+# define RADEON_SOFT_RESET_CP (1 << 0)
+# define RADEON_SOFT_RESET_HI (1 << 1)
+# define RADEON_SOFT_RESET_SE (1 << 2)
+# define RADEON_SOFT_RESET_RE (1 << 3)
+# define RADEON_SOFT_RESET_PP (1 << 4)
+# define RADEON_SOFT_RESET_E2 (1 << 5)
+# define RADEON_SOFT_RESET_RB (1 << 6)
+# define RADEON_SOFT_RESET_HDP (1 << 7)
+#define RADEON_RBBM_STATUS 0x0e40
+# define RADEON_RBBM_FIFOCNT_MASK 0x007f
+# define RADEON_RBBM_ACTIVE (1 << 31)
+#define RADEON_RB2D_DSTCACHE_CTLSTAT 0x342c
+# define RADEON_RB2D_DC_FLUSH (3 << 0)
+# define RADEON_RB2D_DC_FREE (3 << 2)
+# define RADEON_RB2D_DC_FLUSH_ALL 0xf
+# define RADEON_RB2D_DC_BUSY (1 << 31)
+#define RADEON_RB2D_DSTCACHE_MODE 0x3428
+#define RADEON_REG_BASE 0x0f18 /* PCI */
+#define RADEON_REGPROG_INF 0x0f09 /* PCI */
+#define RADEON_REVISION_ID 0x0f08 /* PCI */
+
+#define RADEON_SC_BOTTOM 0x164c
+#define RADEON_SC_BOTTOM_RIGHT 0x16f0
+#define RADEON_SC_BOTTOM_RIGHT_C 0x1c8c
+#define RADEON_SC_LEFT 0x1640
+#define RADEON_SC_RIGHT 0x1644
+#define RADEON_SC_TOP 0x1648
+#define RADEON_SC_TOP_LEFT 0x16ec
+#define RADEON_SC_TOP_LEFT_C 0x1c88
+# define RADEON_SC_SIGN_MASK_LO 0x8000
+# define RADEON_SC_SIGN_MASK_HI 0x80000000
+#define RADEON_SCLK_CNTL 0x000d /* PLL */
+# define RADEON_DYN_STOP_LAT_MASK 0x00007ff8
+# define RADEON_CP_MAX_DYN_STOP_LAT 0x0008
+# define RADEON_SCLK_FORCEON_MASK 0xffff8000
+#define RADEON_SCLK_MORE_CNTL 0x0035 /* PLL */
+# define RADEON_SCLK_MORE_FORCEON 0x0700
+#define RADEON_SDRAM_MODE_REG 0x0158
+#define RADEON_SEQ8_DATA 0x03c5 /* VGA */
+#define RADEON_SEQ8_IDX 0x03c4 /* VGA */
+#define RADEON_SNAPSHOT_F_COUNT 0x0244
+#define RADEON_SNAPSHOT_VH_COUNTS 0x0240
+#define RADEON_SNAPSHOT_VIF_COUNT 0x024c
+#define RADEON_SRC_OFFSET 0x15ac
+#define RADEON_SRC_PITCH 0x15b0
+#define RADEON_SRC_PITCH_OFFSET 0x1428
+#define RADEON_SRC_SC_BOTTOM 0x165c
+#define RADEON_SRC_SC_BOTTOM_RIGHT 0x16f4
+#define RADEON_SRC_SC_RIGHT 0x1654
+#define RADEON_SRC_X 0x1414
+#define RADEON_SRC_X_Y 0x1590
+#define RADEON_SRC_Y 0x1418
+#define RADEON_SRC_Y_X 0x1434
+#define RADEON_STATUS 0x0f06 /* PCI */
+#define RADEON_SUBPIC_CNTL 0x0540 /* ? */
+#define RADEON_SUB_CLASS 0x0f0a /* PCI */
+#define RADEON_SURFACE_CNTL 0x0b00
+# define RADEON_SURF_TRANSLATION_DIS (1 << 8)
+# define RADEON_NONSURF_AP0_SWP_16BPP (1 << 20)
+# define RADEON_NONSURF_AP0_SWP_32BPP (1 << 21)
+#define RADEON_SURFACE0_INFO 0x0b0c
+# define RADEON_SURF_TILE_COLOR_MACRO (0 << 16)
+# define RADEON_SURF_TILE_COLOR_BOTH (1 << 16)
+# define RADEON_SURF_TILE_DEPTH_32BPP (2 << 16)
+# define RADEON_SURF_TILE_DEPTH_16BPP (3 << 16)
+# define R200_SURF_TILE_NONE (0 << 16)
+# define R200_SURF_TILE_COLOR_MACRO (1 << 16)
+# define R200_SURF_TILE_COLOR_MICRO (2 << 16)
+# define R200_SURF_TILE_COLOR_BOTH (3 << 16)
+# define R200_SURF_TILE_DEPTH_32BPP (4 << 16)
+# define R200_SURF_TILE_DEPTH_16BPP (5 << 16)
+# define RADEON_SURF_AP0_SWP_16BPP (1 << 20)
+# define RADEON_SURF_AP0_SWP_32BPP (1 << 21)
+# define RADEON_SURF_AP1_SWP_16BPP (1 << 22)
+# define RADEON_SURF_AP1_SWP_32BPP (1 << 23)
+#define RADEON_SURFACE0_LOWER_BOUND 0x0b04
+#define RADEON_SURFACE0_UPPER_BOUND 0x0b08
+#define RADEON_SURFACE1_INFO 0x0b1c
+#define RADEON_SURFACE1_LOWER_BOUND 0x0b14
+#define RADEON_SURFACE1_UPPER_BOUND 0x0b18
+#define RADEON_SURFACE2_INFO 0x0b2c
+#define RADEON_SURFACE2_LOWER_BOUND 0x0b24
+#define RADEON_SURFACE2_UPPER_BOUND 0x0b28
+#define RADEON_SURFACE3_INFO 0x0b3c
+#define RADEON_SURFACE3_LOWER_BOUND 0x0b34
+#define RADEON_SURFACE3_UPPER_BOUND 0x0b38
+#define RADEON_SURFACE4_INFO 0x0b4c
+#define RADEON_SURFACE4_LOWER_BOUND 0x0b44
+#define RADEON_SURFACE4_UPPER_BOUND 0x0b48
+#define RADEON_SURFACE5_INFO 0x0b5c
+#define RADEON_SURFACE5_LOWER_BOUND 0x0b54
+#define RADEON_SURFACE5_UPPER_BOUND 0x0b58
+#define RADEON_SURFACE6_INFO 0x0b6c
+#define RADEON_SURFACE6_LOWER_BOUND 0x0b64
+#define RADEON_SURFACE6_UPPER_BOUND 0x0b68
+#define RADEON_SURFACE7_INFO 0x0b7c
+#define RADEON_SURFACE7_LOWER_BOUND 0x0b74
+#define RADEON_SURFACE7_UPPER_BOUND 0x0b78
+#define RADEON_SW_SEMAPHORE 0x013c
+
+#define RADEON_TEST_DEBUG_CNTL 0x0120
+#define RADEON_TEST_DEBUG_MUX 0x0124
+#define RADEON_TEST_DEBUG_OUT 0x012c
+#define RADEON_TMDS_PLL_CNTL 0x02a8
+#define RADEON_TMDS_TRANSMITTER_CNTL 0x02a4
+# define RADEON_TMDS_TRANSMITTER_PLLEN 1
+# define RADEON_TMDS_TRANSMITTER_PLLRST 2
+#define RADEON_TRAIL_BRES_DEC 0x1614
+#define RADEON_TRAIL_BRES_ERR 0x160c
+#define RADEON_TRAIL_BRES_INC 0x1610
+#define RADEON_TRAIL_X 0x1618
+#define RADEON_TRAIL_X_SUB 0x1620
+
+#define RADEON_VCLK_ECP_CNTL 0x0008 /* PLL */
+# define RADEON_VCLK_SRC_SEL_MASK 0x03
+# define RADEON_VCLK_SRC_SEL_CPUCLK 0x00
+# define RADEON_VCLK_SRC_SEL_PSCANCLK 0x01
+# define RADEON_VCLK_SRC_SEL_BYTECLK 0x02
+# define RADEON_VCLK_SRC_SEL_PPLLCLK 0x03
+# define RADEON_PIXCLK_ALWAYS_ONb (1<<6)
+# define RADEON_PIXCLK_DAC_ALWAYS_ONb (1<<7)
+
+#define RADEON_VENDOR_ID 0x0f00 /* PCI */
+#define RADEON_VGA_DDA_CONFIG 0x02e8
+#define RADEON_VGA_DDA_ON_OFF 0x02ec
+#define RADEON_VID_BUFFER_CONTROL 0x0900
+#define RADEON_VIDEOMUX_CNTL 0x0190
+#define RADEON_VIPH_CONTROL 0x0c40 /* ? */
+
+#define RADEON_WAIT_UNTIL 0x1720
+# define RADEON_WAIT_CRTC_PFLIP (1 << 0)
+# define RADEON_WAIT_2D_IDLECLEAN (1 << 16)
+# define RADEON_WAIT_3D_IDLECLEAN (1 << 17)
+# define RADEON_WAIT_HOST_IDLECLEAN (1 << 18)
+
+#define RADEON_X_MPLL_REF_FB_DIV 0x000a /* PLL */
+#define RADEON_XCLK_CNTL 0x000d /* PLL */
+#define RADEON_XDLL_CNTL 0x000c /* PLL */
+#define RADEON_XPLL_CNTL 0x000b /* PLL */
+
+
+
+ /* Registers for 3D/TCL */
+#define RADEON_PP_BORDER_COLOR_0 0x1d40
+#define RADEON_PP_BORDER_COLOR_1 0x1d44
+#define RADEON_PP_BORDER_COLOR_2 0x1d48
+#define RADEON_PP_CNTL 0x1c38
+# define RADEON_STIPPLE_ENABLE (1 << 0)
+# define RADEON_SCISSOR_ENABLE (1 << 1)
+# define RADEON_PATTERN_ENABLE (1 << 2)
+# define RADEON_SHADOW_ENABLE (1 << 3)
+# define RADEON_TEX_ENABLE_MASK (0xf << 4)
+# define RADEON_TEX_0_ENABLE (1 << 4)
+# define RADEON_TEX_1_ENABLE (1 << 5)
+# define RADEON_TEX_2_ENABLE (1 << 6)
+# define RADEON_TEX_3_ENABLE (1 << 7)
+# define RADEON_TEX_BLEND_ENABLE_MASK (0xf << 12)
+# define RADEON_TEX_BLEND_0_ENABLE (1 << 12)
+# define RADEON_TEX_BLEND_1_ENABLE (1 << 13)
+# define RADEON_TEX_BLEND_2_ENABLE (1 << 14)
+# define RADEON_TEX_BLEND_3_ENABLE (1 << 15)
+# define RADEON_PLANAR_YUV_ENABLE (1 << 20)
+# define RADEON_SPECULAR_ENABLE (1 << 21)
+# define RADEON_FOG_ENABLE (1 << 22)
+# define RADEON_ALPHA_TEST_ENABLE (1 << 23)
+# define RADEON_ANTI_ALIAS_NONE (0 << 24)
+# define RADEON_ANTI_ALIAS_LINE (1 << 24)
+# define RADEON_ANTI_ALIAS_POLY (2 << 24)
+# define RADEON_ANTI_ALIAS_LINE_POLY (3 << 24)
+# define RADEON_BUMP_MAP_ENABLE (1 << 26)
+# define RADEON_BUMPED_MAP_T0 (0 << 27)
+# define RADEON_BUMPED_MAP_T1 (1 << 27)
+# define RADEON_BUMPED_MAP_T2 (2 << 27)
+# define RADEON_TEX_3D_ENABLE_0 (1 << 29)
+# define RADEON_TEX_3D_ENABLE_1 (1 << 30)
+# define RADEON_MC_ENABLE (1 << 31)
+#define RADEON_PP_FOG_COLOR 0x1c18
+# define RADEON_FOG_COLOR_MASK 0x00ffffff
+# define RADEON_FOG_VERTEX (0 << 24)
+# define RADEON_FOG_TABLE (1 << 24)
+# define RADEON_FOG_USE_DEPTH (0 << 25)
+# define RADEON_FOG_USE_DIFFUSE_ALPHA (2 << 25)
+# define RADEON_FOG_USE_SPEC_ALPHA (3 << 25)
+#define RADEON_PP_LUM_MATRIX 0x1d00
+#define RADEON_PP_MISC 0x1c14
+# define RADEON_REF_ALPHA_MASK 0x000000ff
+# define RADEON_ALPHA_TEST_FAIL (0 << 8)
+# define RADEON_ALPHA_TEST_LESS (1 << 8)
+# define RADEON_ALPHA_TEST_LEQUAL (2 << 8)
+# define RADEON_ALPHA_TEST_EQUAL (3 << 8)
+# define RADEON_ALPHA_TEST_GEQUAL (4 << 8)
+# define RADEON_ALPHA_TEST_GREATER (5 << 8)
+# define RADEON_ALPHA_TEST_NEQUAL (6 << 8)
+# define RADEON_ALPHA_TEST_PASS (7 << 8)
+# define RADEON_ALPHA_TEST_OP_MASK (7 << 8)
+# define RADEON_CHROMA_FUNC_FAIL (0 << 16)
+# define RADEON_CHROMA_FUNC_PASS (1 << 16)
+# define RADEON_CHROMA_FUNC_NEQUAL (2 << 16)
+# define RADEON_CHROMA_FUNC_EQUAL (3 << 16)
+# define RADEON_CHROMA_KEY_NEAREST (0 << 18)
+# define RADEON_CHROMA_KEY_ZERO (1 << 18)
+# define RADEON_SHADOW_ID_AUTO_INC (1 << 20)
+# define RADEON_SHADOW_FUNC_EQUAL (0 << 21)
+# define RADEON_SHADOW_FUNC_NEQUAL (1 << 21)
+# define RADEON_SHADOW_PASS_1 (0 << 22)
+# define RADEON_SHADOW_PASS_2 (1 << 22)
+# define RADEON_RIGHT_HAND_CUBE_D3D (0 << 24)
+# define RADEON_RIGHT_HAND_CUBE_OGL (1 << 24)
+#define RADEON_PP_ROT_MATRIX_0 0x1d58
+#define RADEON_PP_ROT_MATRIX_1 0x1d5c
+#define RADEON_PP_TXFILTER_0 0x1c54
+#define RADEON_PP_TXFILTER_1 0x1c6c
+#define RADEON_PP_TXFILTER_2 0x1c84
+# define RADEON_MAG_FILTER_NEAREST (0 << 0)
+# define RADEON_MAG_FILTER_LINEAR (1 << 0)
+# define RADEON_MAG_FILTER_MASK (1 << 0)
+# define RADEON_MIN_FILTER_NEAREST (0 << 1)
+# define RADEON_MIN_FILTER_LINEAR (1 << 1)
+# define RADEON_MIN_FILTER_NEAREST_MIP_NEAREST (2 << 1)
+# define RADEON_MIN_FILTER_NEAREST_MIP_LINEAR (3 << 1)
+# define RADEON_MIN_FILTER_LINEAR_MIP_NEAREST (6 << 1)
+# define RADEON_MIN_FILTER_LINEAR_MIP_LINEAR (7 << 1)
+# define RADEON_MIN_FILTER_ANISO_NEAREST (8 << 1)
+# define RADEON_MIN_FILTER_ANISO_LINEAR (9 << 1)
+# define RADEON_MIN_FILTER_ANISO_NEAREST_MIP_NEAREST (10 << 1)
+# define RADEON_MIN_FILTER_ANISO_NEAREST_MIP_LINEAR (11 << 1)
+# define RADEON_MIN_FILTER_MASK (15 << 1)
+# define RADEON_MAX_ANISO_1_TO_1 (0 << 5)
+# define RADEON_MAX_ANISO_2_TO_1 (1 << 5)
+# define RADEON_MAX_ANISO_4_TO_1 (2 << 5)
+# define RADEON_MAX_ANISO_8_TO_1 (3 << 5)
+# define RADEON_MAX_ANISO_16_TO_1 (4 << 5)
+# define RADEON_MAX_ANISO_MASK (7 << 5)
+# define RADEON_LOD_BIAS_MASK (0xff << 8)
+# define RADEON_LOD_BIAS_SHIFT 8
+# define RADEON_MAX_MIP_LEVEL_MASK (0x0f << 16)
+# define RADEON_MAX_MIP_LEVEL_SHIFT 16
+# define RADEON_YUV_TO_RGB (1 << 20)
+# define RADEON_YUV_TEMPERATURE_COOL (0 << 21)
+# define RADEON_YUV_TEMPERATURE_HOT (1 << 21)
+# define RADEON_YUV_TEMPERATURE_MASK (1 << 21)
+# define RADEON_WRAPEN_S (1 << 22)
+# define RADEON_CLAMP_S_WRAP (0 << 23)
+# define RADEON_CLAMP_S_MIRROR (1 << 23)
+# define RADEON_CLAMP_S_CLAMP_LAST (2 << 23)
+# define RADEON_CLAMP_S_MIRROR_CLAMP_LAST (3 << 23)
+# define RADEON_CLAMP_S_CLAMP_BORDER (4 << 23)
+# define RADEON_CLAMP_S_MIRROR_CLAMP_BORDER (5 << 23)
+# define RADEON_CLAMP_S_CLAMP_GL (6 << 23)
+# define RADEON_CLAMP_S_MIRROR_CLAMP_GL (7 << 23)
+# define RADEON_CLAMP_S_MASK (7 << 23)
+# define RADEON_WRAPEN_T (1 << 26)
+# define RADEON_CLAMP_T_WRAP (0 << 27)
+# define RADEON_CLAMP_T_MIRROR (1 << 27)
+# define RADEON_CLAMP_T_CLAMP_LAST (2 << 27)
+# define RADEON_CLAMP_T_MIRROR_CLAMP_LAST (3 << 27)
+# define RADEON_CLAMP_T_CLAMP_BORDER (4 << 27)
+# define RADEON_CLAMP_T_MIRROR_CLAMP_BORDER (5 << 27)
+# define RADEON_CLAMP_T_CLAMP_GL (6 << 27)
+# define RADEON_CLAMP_T_MIRROR_CLAMP_GL (7 << 27)
+# define RADEON_CLAMP_T_MASK (7 << 27)
+# define RADEON_BORDER_MODE_OGL (0 << 31)
+# define RADEON_BORDER_MODE_D3D (1 << 31)
+#define RADEON_PP_TXFORMAT_0 0x1c58
+#define RADEON_PP_TXFORMAT_1 0x1c70
+#define RADEON_PP_TXFORMAT_2 0x1c88
+# define RADEON_TXFORMAT_I8 (0 << 0)
+# define RADEON_TXFORMAT_AI88 (1 << 0)
+# define RADEON_TXFORMAT_RGB332 (2 << 0)
+# define RADEON_TXFORMAT_ARGB1555 (3 << 0)
+# define RADEON_TXFORMAT_RGB565 (4 << 0)
+# define RADEON_TXFORMAT_ARGB4444 (5 << 0)
+# define RADEON_TXFORMAT_ARGB8888 (6 << 0)
+# define RADEON_TXFORMAT_RGBA8888 (7 << 0)
+# define RADEON_TXFORMAT_Y8 (8 << 0)
+# define RADEON_TXFORMAT_VYUY422 (10 << 0)
+# define RADEON_TXFORMAT_YVYU422 (11 << 0)
+# define RADEON_TXFORMAT_DXT1 (12 << 0)
+# define RADEON_TXFORMAT_DXT23 (14 << 0)
+# define RADEON_TXFORMAT_DXT45 (15 << 0)
+# define RADEON_TXFORMAT_SHADOW16 (16 << 0)
+# define RADEON_TXFORMAT_SHADOW32 (17 << 0)
+# define RADEON_TXFORMAT_DUDV88 (18 << 0)
+# define RADEON_TXFORMAT_LDUDV655 (19 << 0)
+# define RADEON_TXFORMAT_LDUDUV8888 (20 << 0)
+# define RADEON_TXFORMAT_FORMAT_MASK (31 << 0)
+# define RADEON_TXFORMAT_FORMAT_SHIFT 0
+# define RADEON_TXFORMAT_APPLE_YUV_MODE (1 << 5)
+# define RADEON_TXFORMAT_ALPHA_IN_MAP (1 << 6)
+# define RADEON_TXFORMAT_NON_POWER2 (1 << 7)
+# define RADEON_TXFORMAT_WIDTH_MASK (15 << 8)
+# define RADEON_TXFORMAT_WIDTH_SHIFT 8
+# define RADEON_TXFORMAT_HEIGHT_MASK (15 << 12)
+# define RADEON_TXFORMAT_HEIGHT_SHIFT 12
+# define RADEON_TXFORMAT_F5_WIDTH_MASK (15 << 16)
+# define RADEON_TXFORMAT_F5_WIDTH_SHIFT 16
+# define RADEON_TXFORMAT_F5_HEIGHT_MASK (15 << 20)
+# define RADEON_TXFORMAT_F5_HEIGHT_SHIFT 20
+# define RADEON_TXFORMAT_ST_ROUTE_STQ0 (0 << 24)
+# define RADEON_TXFORMAT_ST_ROUTE_MASK (3 << 24)
+# define RADEON_TXFORMAT_ST_ROUTE_STQ1 (1 << 24)
+# define RADEON_TXFORMAT_ST_ROUTE_STQ2 (2 << 24)
+# define RADEON_TXFORMAT_ENDIAN_NO_SWAP (0 << 26)
+# define RADEON_TXFORMAT_ENDIAN_16BPP_SWAP (1 << 26)
+# define RADEON_TXFORMAT_ENDIAN_32BPP_SWAP (2 << 26)
+# define RADEON_TXFORMAT_ENDIAN_HALFDW_SWAP (3 << 26)
+# define RADEON_TXFORMAT_ALPHA_MASK_ENABLE (1 << 28)
+# define RADEON_TXFORMAT_CHROMA_KEY_ENABLE (1 << 29)
+# define RADEON_TXFORMAT_CUBIC_MAP_ENABLE (1 << 30)
+# define RADEON_TXFORMAT_PERSPECTIVE_ENABLE (1 << 31)
+#define RADEON_PP_CUBIC_FACES_0 0x1d24
+#define RADEON_PP_CUBIC_FACES_1 0x1d28
+#define RADEON_PP_CUBIC_FACES_2 0x1d2c
+# define RADEON_FACE_WIDTH_1_SHIFT 0
+# define RADEON_FACE_HEIGHT_1_SHIFT 4
+# define RADEON_FACE_WIDTH_1_MASK (0xf << 0)
+# define RADEON_FACE_HEIGHT_1_MASK (0xf << 4)
+# define RADEON_FACE_WIDTH_2_SHIFT 8
+# define RADEON_FACE_HEIGHT_2_SHIFT 12
+# define RADEON_FACE_WIDTH_2_MASK (0xf << 8)
+# define RADEON_FACE_HEIGHT_2_MASK (0xf << 12)
+# define RADEON_FACE_WIDTH_3_SHIFT 16
+# define RADEON_FACE_HEIGHT_3_SHIFT 20
+# define RADEON_FACE_WIDTH_3_MASK (0xf << 16)
+# define RADEON_FACE_HEIGHT_3_MASK (0xf << 20)
+# define RADEON_FACE_WIDTH_4_SHIFT 24
+# define RADEON_FACE_HEIGHT_4_SHIFT 28
+# define RADEON_FACE_WIDTH_4_MASK (0xf << 24)
+# define RADEON_FACE_HEIGHT_4_MASK (0xf << 28)
+
+#define RADEON_PP_TXOFFSET_0 0x1c5c
+#define RADEON_PP_TXOFFSET_1 0x1c74
+#define RADEON_PP_TXOFFSET_2 0x1c8c
+# define RADEON_TXO_ENDIAN_NO_SWAP (0 << 0)
+# define RADEON_TXO_ENDIAN_BYTE_SWAP (1 << 0)
+# define RADEON_TXO_ENDIAN_WORD_SWAP (2 << 0)
+# define RADEON_TXO_ENDIAN_HALFDW_SWAP (3 << 0)
+# define RADEON_TXO_MACRO_LINEAR (0 << 2)
+# define RADEON_TXO_MACRO_TILE (1 << 2)
+# define RADEON_TXO_MICRO_LINEAR (0 << 3)
+# define RADEON_TXO_MICRO_TILE_X2 (1 << 3)
+# define RADEON_TXO_MICRO_TILE_OPT (2 << 3)
+# define RADEON_TXO_OFFSET_MASK 0xffffffe0
+# define RADEON_TXO_OFFSET_SHIFT 5
+
+#define RADEON_PP_CUBIC_OFFSET_T0_0 0x1dd0 /* bits [31:5] */
+#define RADEON_PP_CUBIC_OFFSET_T0_1 0x1dd4
+#define RADEON_PP_CUBIC_OFFSET_T0_2 0x1dd8
+#define RADEON_PP_CUBIC_OFFSET_T0_3 0x1ddc
+#define RADEON_PP_CUBIC_OFFSET_T0_4 0x1de0
+#define RADEON_PP_CUBIC_OFFSET_T1_0 0x1e00
+#define RADEON_PP_CUBIC_OFFSET_T1_1 0x1e04
+#define RADEON_PP_CUBIC_OFFSET_T1_2 0x1e08
+#define RADEON_PP_CUBIC_OFFSET_T1_3 0x1e0c
+#define RADEON_PP_CUBIC_OFFSET_T1_4 0x1e10
+#define RADEON_PP_CUBIC_OFFSET_T2_0 0x1e14
+#define RADEON_PP_CUBIC_OFFSET_T2_1 0x1e18
+#define RADEON_PP_CUBIC_OFFSET_T2_2 0x1e1c
+#define RADEON_PP_CUBIC_OFFSET_T2_3 0x1e20
+#define RADEON_PP_CUBIC_OFFSET_T2_4 0x1e24
+
+#define RADEON_PP_TEX_SIZE_0 0x1d04 /* NPOT */
+#define RADEON_PP_TEX_SIZE_1 0x1d0c
+#define RADEON_PP_TEX_SIZE_2 0x1d14
+# define RADEON_TEX_USIZE_MASK (0x7ff << 0)
+# define RADEON_TEX_USIZE_SHIFT 0
+# define RADEON_TEX_VSIZE_MASK (0x7ff << 16)
+# define RADEON_TEX_VSIZE_SHIFT 16
+# define RADEON_SIGNED_RGB_MASK (1 << 30)
+# define RADEON_SIGNED_RGB_SHIFT 30
+# define RADEON_SIGNED_ALPHA_MASK (1 << 31)
+# define RADEON_SIGNED_ALPHA_SHIFT 31
+#define RADEON_PP_TEX_PITCH_0 0x1d08 /* NPOT */
+#define RADEON_PP_TEX_PITCH_1 0x1d10 /* NPOT */
+#define RADEON_PP_TEX_PITCH_2 0x1d18 /* NPOT */
+/* note: bits 13-5: 32 byte aligned stride of texture map */
+
+#define RADEON_PP_TXCBLEND_0 0x1c60
+#define RADEON_PP_TXCBLEND_1 0x1c78
+#define RADEON_PP_TXCBLEND_2 0x1c90
+# define RADEON_COLOR_ARG_A_SHIFT 0
+# define RADEON_COLOR_ARG_A_MASK (0x1f << 0)
+# define RADEON_COLOR_ARG_A_ZERO (0 << 0)
+# define RADEON_COLOR_ARG_A_CURRENT_COLOR (2 << 0)
+# define RADEON_COLOR_ARG_A_CURRENT_ALPHA (3 << 0)
+# define RADEON_COLOR_ARG_A_DIFFUSE_COLOR (4 << 0)
+# define RADEON_COLOR_ARG_A_DIFFUSE_ALPHA (5 << 0)
+# define RADEON_COLOR_ARG_A_SPECULAR_COLOR (6 << 0)
+# define RADEON_COLOR_ARG_A_SPECULAR_ALPHA (7 << 0)
+# define RADEON_COLOR_ARG_A_TFACTOR_COLOR (8 << 0)
+# define RADEON_COLOR_ARG_A_TFACTOR_ALPHA (9 << 0)
+# define RADEON_COLOR_ARG_A_T0_COLOR (10 << 0)
+# define RADEON_COLOR_ARG_A_T0_ALPHA (11 << 0)
+# define RADEON_COLOR_ARG_A_T1_COLOR (12 << 0)
+# define RADEON_COLOR_ARG_A_T1_ALPHA (13 << 0)
+# define RADEON_COLOR_ARG_A_T2_COLOR (14 << 0)
+# define RADEON_COLOR_ARG_A_T2_ALPHA (15 << 0)
+# define RADEON_COLOR_ARG_A_T3_COLOR (16 << 0)
+# define RADEON_COLOR_ARG_A_T3_ALPHA (17 << 0)
+# define RADEON_COLOR_ARG_B_SHIFT 5
+# define RADEON_COLOR_ARG_B_MASK (0x1f << 5)
+# define RADEON_COLOR_ARG_B_ZERO (0 << 5)
+# define RADEON_COLOR_ARG_B_CURRENT_COLOR (2 << 5)
+# define RADEON_COLOR_ARG_B_CURRENT_ALPHA (3 << 5)
+# define RADEON_COLOR_ARG_B_DIFFUSE_COLOR (4 << 5)
+# define RADEON_COLOR_ARG_B_DIFFUSE_ALPHA (5 << 5)
+# define RADEON_COLOR_ARG_B_SPECULAR_COLOR (6 << 5)
+# define RADEON_COLOR_ARG_B_SPECULAR_ALPHA (7 << 5)
+# define RADEON_COLOR_ARG_B_TFACTOR_COLOR (8 << 5)
+# define RADEON_COLOR_ARG_B_TFACTOR_ALPHA (9 << 5)
+# define RADEON_COLOR_ARG_B_T0_COLOR (10 << 5)
+# define RADEON_COLOR_ARG_B_T0_ALPHA (11 << 5)
+# define RADEON_COLOR_ARG_B_T1_COLOR (12 << 5)
+# define RADEON_COLOR_ARG_B_T1_ALPHA (13 << 5)
+# define RADEON_COLOR_ARG_B_T2_COLOR (14 << 5)
+# define RADEON_COLOR_ARG_B_T2_ALPHA (15 << 5)
+# define RADEON_COLOR_ARG_B_T3_COLOR (16 << 5)
+# define RADEON_COLOR_ARG_B_T3_ALPHA (17 << 5)
+# define RADEON_COLOR_ARG_C_SHIFT 10
+# define RADEON_COLOR_ARG_C_MASK (0x1f << 10)
+# define RADEON_COLOR_ARG_C_ZERO (0 << 10)
+# define RADEON_COLOR_ARG_C_CURRENT_COLOR (2 << 10)
+# define RADEON_COLOR_ARG_C_CURRENT_ALPHA (3 << 10)
+# define RADEON_COLOR_ARG_C_DIFFUSE_COLOR (4 << 10)
+# define RADEON_COLOR_ARG_C_DIFFUSE_ALPHA (5 << 10)
+# define RADEON_COLOR_ARG_C_SPECULAR_COLOR (6 << 10)
+# define RADEON_COLOR_ARG_C_SPECULAR_ALPHA (7 << 10)
+# define RADEON_COLOR_ARG_C_TFACTOR_COLOR (8 << 10)
+# define RADEON_COLOR_ARG_C_TFACTOR_ALPHA (9 << 10)
+# define RADEON_COLOR_ARG_C_T0_COLOR (10 << 10)
+# define RADEON_COLOR_ARG_C_T0_ALPHA (11 << 10)
+# define RADEON_COLOR_ARG_C_T1_COLOR (12 << 10)
+# define RADEON_COLOR_ARG_C_T1_ALPHA (13 << 10)
+# define RADEON_COLOR_ARG_C_T2_COLOR (14 << 10)
+# define RADEON_COLOR_ARG_C_T2_ALPHA (15 << 10)
+# define RADEON_COLOR_ARG_C_T3_COLOR (16 << 10)
+# define RADEON_COLOR_ARG_C_T3_ALPHA (17 << 10)
+# define RADEON_COMP_ARG_A (1 << 15)
+# define RADEON_COMP_ARG_A_SHIFT 15
+# define RADEON_COMP_ARG_B (1 << 16)
+# define RADEON_COMP_ARG_B_SHIFT 16
+# define RADEON_COMP_ARG_C (1 << 17)
+# define RADEON_COMP_ARG_C_SHIFT 17
+# define RADEON_BLEND_CTL_MASK (7 << 18)
+# define RADEON_BLEND_CTL_ADD (0 << 18)
+# define RADEON_BLEND_CTL_SUBTRACT (1 << 18)
+# define RADEON_BLEND_CTL_ADDSIGNED (2 << 18)
+# define RADEON_BLEND_CTL_BLEND (3 << 18)
+# define RADEON_BLEND_CTL_DOT3 (4 << 18)
+# define RADEON_SCALE_SHIFT 21
+# define RADEON_SCALE_MASK (3 << 21)
+# define RADEON_SCALE_1X (0 << 21)
+# define RADEON_SCALE_2X (1 << 21)
+# define RADEON_SCALE_4X (2 << 21)
+# define RADEON_CLAMP_TX (1 << 23)
+# define RADEON_T0_EQ_TCUR (1 << 24)
+# define RADEON_T1_EQ_TCUR (1 << 25)
+# define RADEON_T2_EQ_TCUR (1 << 26)
+# define RADEON_T3_EQ_TCUR (1 << 27)
+# define RADEON_COLOR_ARG_MASK 0x1f
+# define RADEON_COMP_ARG_SHIFT 15
+#define RADEON_PP_TXABLEND_0 0x1c64
+#define RADEON_PP_TXABLEND_1 0x1c7c
+#define RADEON_PP_TXABLEND_2 0x1c94
+# define RADEON_ALPHA_ARG_A_SHIFT 0
+# define RADEON_ALPHA_ARG_A_MASK (0xf << 0)
+# define RADEON_ALPHA_ARG_A_ZERO (0 << 0)
+# define RADEON_ALPHA_ARG_A_CURRENT_ALPHA (1 << 0)
+# define RADEON_ALPHA_ARG_A_DIFFUSE_ALPHA (2 << 0)
+# define RADEON_ALPHA_ARG_A_SPECULAR_ALPHA (3 << 0)
+# define RADEON_ALPHA_ARG_A_TFACTOR_ALPHA (4 << 0)
+# define RADEON_ALPHA_ARG_A_T0_ALPHA (5 << 0)
+# define RADEON_ALPHA_ARG_A_T1_ALPHA (6 << 0)
+# define RADEON_ALPHA_ARG_A_T2_ALPHA (7 << 0)
+# define RADEON_ALPHA_ARG_A_T3_ALPHA (8 << 0)
+# define RADEON_ALPHA_ARG_B_SHIFT 4
+# define RADEON_ALPHA_ARG_B_MASK (0xf << 4)
+# define RADEON_ALPHA_ARG_B_ZERO (0 << 4)
+# define RADEON_ALPHA_ARG_B_CURRENT_ALPHA (1 << 4)
+# define RADEON_ALPHA_ARG_B_DIFFUSE_ALPHA (2 << 4)
+# define RADEON_ALPHA_ARG_B_SPECULAR_ALPHA (3 << 4)
+# define RADEON_ALPHA_ARG_B_TFACTOR_ALPHA (4 << 4)
+# define RADEON_ALPHA_ARG_B_T0_ALPHA (5 << 4)
+# define RADEON_ALPHA_ARG_B_T1_ALPHA (6 << 4)
+# define RADEON_ALPHA_ARG_B_T2_ALPHA (7 << 4)
+# define RADEON_ALPHA_ARG_B_T3_ALPHA (8 << 4)
+# define RADEON_ALPHA_ARG_C_SHIFT 8
+# define RADEON_ALPHA_ARG_C_MASK (0xf << 8)
+# define RADEON_ALPHA_ARG_C_ZERO (0 << 8)
+# define RADEON_ALPHA_ARG_C_CURRENT_ALPHA (1 << 8)
+# define RADEON_ALPHA_ARG_C_DIFFUSE_ALPHA (2 << 8)
+# define RADEON_ALPHA_ARG_C_SPECULAR_ALPHA (3 << 8)
+# define RADEON_ALPHA_ARG_C_TFACTOR_ALPHA (4 << 8)
+# define RADEON_ALPHA_ARG_C_T0_ALPHA (5 << 8)
+# define RADEON_ALPHA_ARG_C_T1_ALPHA (6 << 8)
+# define RADEON_ALPHA_ARG_C_T2_ALPHA (7 << 8)
+# define RADEON_ALPHA_ARG_C_T3_ALPHA (8 << 8)
+# define RADEON_DOT_ALPHA_DONT_REPLICATE (1 << 9)
+# define RADEON_ALPHA_ARG_MASK 0xf
+
+#define RADEON_PP_TFACTOR_0 0x1c68
+#define RADEON_PP_TFACTOR_1 0x1c80
+#define RADEON_PP_TFACTOR_2 0x1c98
+
+#define RADEON_RB3D_BLENDCNTL 0x1c20
+# define RADEON_COMB_FCN_MASK (3 << 12)
+# define RADEON_COMB_FCN_ADD_CLAMP (0 << 12)
+# define RADEON_COMB_FCN_ADD_NOCLAMP (1 << 12)
+# define RADEON_COMB_FCN_SUB_CLAMP (2 << 12)
+# define RADEON_COMB_FCN_SUB_NOCLAMP (3 << 12)
+# define RADEON_SRC_BLEND_GL_ZERO (32 << 16)
+# define RADEON_SRC_BLEND_GL_ONE (33 << 16)
+# define RADEON_SRC_BLEND_GL_SRC_COLOR (34 << 16)
+# define RADEON_SRC_BLEND_GL_ONE_MINUS_SRC_COLOR (35 << 16)
+# define RADEON_SRC_BLEND_GL_DST_COLOR (36 << 16)
+# define RADEON_SRC_BLEND_GL_ONE_MINUS_DST_COLOR (37 << 16)
+# define RADEON_SRC_BLEND_GL_SRC_ALPHA (38 << 16)
+# define RADEON_SRC_BLEND_GL_ONE_MINUS_SRC_ALPHA (39 << 16)
+# define RADEON_SRC_BLEND_GL_DST_ALPHA (40 << 16)
+# define RADEON_SRC_BLEND_GL_ONE_MINUS_DST_ALPHA (41 << 16)
+# define RADEON_SRC_BLEND_GL_SRC_ALPHA_SATURATE (42 << 16)
+# define RADEON_SRC_BLEND_MASK (63 << 16)
+# define RADEON_DST_BLEND_GL_ZERO (32 << 24)
+# define RADEON_DST_BLEND_GL_ONE (33 << 24)
+# define RADEON_DST_BLEND_GL_SRC_COLOR (34 << 24)
+# define RADEON_DST_BLEND_GL_ONE_MINUS_SRC_COLOR (35 << 24)
+# define RADEON_DST_BLEND_GL_DST_COLOR (36 << 24)
+# define RADEON_DST_BLEND_GL_ONE_MINUS_DST_COLOR (37 << 24)
+# define RADEON_DST_BLEND_GL_SRC_ALPHA (38 << 24)
+# define RADEON_DST_BLEND_GL_ONE_MINUS_SRC_ALPHA (39 << 24)
+# define RADEON_DST_BLEND_GL_DST_ALPHA (40 << 24)
+# define RADEON_DST_BLEND_GL_ONE_MINUS_DST_ALPHA (41 << 24)
+# define RADEON_DST_BLEND_MASK (63 << 24)
+#define RADEON_RB3D_CNTL 0x1c3c
+# define RADEON_ALPHA_BLEND_ENABLE (1 << 0)
+# define RADEON_PLANE_MASK_ENABLE (1 << 1)
+# define RADEON_DITHER_ENABLE (1 << 2)
+# define RADEON_ROUND_ENABLE (1 << 3)
+# define RADEON_SCALE_DITHER_ENABLE (1 << 4)
+# define RADEON_DITHER_INIT (1 << 5)
+# define RADEON_ROP_ENABLE (1 << 6)
+# define RADEON_STENCIL_ENABLE (1 << 7)
+# define RADEON_Z_ENABLE (1 << 8)
+# define RADEON_DEPTH_XZ_OFFEST_ENABLE (1 << 9)
+# define RADEON_COLOR_FORMAT_ARGB1555 (3 << 10)
+# define RADEON_COLOR_FORMAT_RGB565 (4 << 10)
+# define RADEON_COLOR_FORMAT_ARGB8888 (6 << 10)
+# define RADEON_COLOR_FORMAT_RGB332 (7 << 10)
+# define RADEON_COLOR_FORMAT_Y8 (8 << 10)
+# define RADEON_COLOR_FORMAT_RGB8 (9 << 10)
+# define RADEON_COLOR_FORMAT_YUV422_VYUY (11 << 10)
+# define RADEON_COLOR_FORMAT_YUV422_YVYU (12 << 10)
+# define RADEON_COLOR_FORMAT_aYUV444 (14 << 10)
+# define RADEON_COLOR_FORMAT_ARGB4444 (15 << 10)
+# define RADEON_CLRCMP_FLIP_ENABLE (1 << 14)
+# define RADEON_ZBLOCK16 (1 << 15)
+#define RADEON_RB3D_COLOROFFSET 0x1c40
+# define RADEON_COLOROFFSET_MASK 0xfffffff0
+#define RADEON_RB3D_COLORPITCH 0x1c48
+# define RADEON_COLORPITCH_MASK 0x000001ff8
+# define RADEON_COLOR_TILE_ENABLE (1 << 16)
+# define RADEON_COLOR_MICROTILE_ENABLE (1 << 17)
+# define RADEON_COLOR_ENDIAN_NO_SWAP (0 << 18)
+# define RADEON_COLOR_ENDIAN_WORD_SWAP (1 << 18)
+# define RADEON_COLOR_ENDIAN_DWORD_SWAP (2 << 18)
+#define RADEON_RB3D_DEPTHOFFSET 0x1c24
+#define RADEON_RB3D_DEPTHPITCH 0x1c28
+# define RADEON_DEPTHPITCH_MASK 0x00001ff8
+# define RADEON_DEPTH_HYPERZ (3 << 16)
+# define RADEON_DEPTH_ENDIAN_NO_SWAP (0 << 18)
+# define RADEON_DEPTH_ENDIAN_WORD_SWAP (1 << 18)
+# define RADEON_DEPTH_ENDIAN_DWORD_SWAP (2 << 18)
+#define RADEON_RB3D_PLANEMASK 0x1d84
+#define RADEON_RB3D_ROPCNTL 0x1d80
+# define RADEON_ROP_MASK (15 << 8)
+# define RADEON_ROP_CLEAR (0 << 8)
+# define RADEON_ROP_NOR (1 << 8)
+# define RADEON_ROP_AND_INVERTED (2 << 8)
+# define RADEON_ROP_COPY_INVERTED (3 << 8)
+# define RADEON_ROP_AND_REVERSE (4 << 8)
+# define RADEON_ROP_INVERT (5 << 8)
+# define RADEON_ROP_XOR (6 << 8)
+# define RADEON_ROP_NAND (7 << 8)
+# define RADEON_ROP_AND (8 << 8)
+# define RADEON_ROP_EQUIV (9 << 8)
+# define RADEON_ROP_NOOP (10 << 8)
+# define RADEON_ROP_OR_INVERTED (11 << 8)
+# define RADEON_ROP_COPY (12 << 8)
+# define RADEON_ROP_OR_REVERSE (13 << 8)
+# define RADEON_ROP_OR (14 << 8)
+# define RADEON_ROP_SET (15 << 8)
+#define RADEON_RB3D_STENCILREFMASK 0x1d7c
+# define RADEON_STENCIL_REF_SHIFT 0
+# define RADEON_STENCIL_REF_MASK (0xff << 0)
+# define RADEON_STENCIL_MASK_SHIFT 16
+# define RADEON_STENCIL_VALUE_MASK (0xff << 16)
+# define RADEON_STENCIL_WRITEMASK_SHIFT 24
+# define RADEON_STENCIL_WRITE_MASK (0xff << 24)
+#define RADEON_RB3D_ZSTENCILCNTL 0x1c2c
+# define RADEON_DEPTH_FORMAT_MASK (0xf << 0)
+# define RADEON_DEPTH_FORMAT_16BIT_INT_Z (0 << 0)
+# define RADEON_DEPTH_FORMAT_24BIT_INT_Z (2 << 0)
+# define RADEON_DEPTH_FORMAT_24BIT_FLOAT_Z (3 << 0)
+# define RADEON_DEPTH_FORMAT_32BIT_INT_Z (4 << 0)
+# define RADEON_DEPTH_FORMAT_32BIT_FLOAT_Z (5 << 0)
+# define RADEON_DEPTH_FORMAT_16BIT_FLOAT_W (7 << 0)
+# define RADEON_DEPTH_FORMAT_24BIT_FLOAT_W (9 << 0)
+# define RADEON_DEPTH_FORMAT_32BIT_FLOAT_W (11 << 0)
+# define RADEON_Z_TEST_NEVER (0 << 4)
+# define RADEON_Z_TEST_LESS (1 << 4)
+# define RADEON_Z_TEST_LEQUAL (2 << 4)
+# define RADEON_Z_TEST_EQUAL (3 << 4)
+# define RADEON_Z_TEST_GEQUAL (4 << 4)
+# define RADEON_Z_TEST_GREATER (5 << 4)
+# define RADEON_Z_TEST_NEQUAL (6 << 4)
+# define RADEON_Z_TEST_ALWAYS (7 << 4)
+# define RADEON_Z_TEST_MASK (7 << 4)
+# define RADEON_Z_HIERARCHY_ENABLE (1 << 8)
+# define RADEON_STENCIL_TEST_NEVER (0 << 12)
+# define RADEON_STENCIL_TEST_LESS (1 << 12)
+# define RADEON_STENCIL_TEST_LEQUAL (2 << 12)
+# define RADEON_STENCIL_TEST_EQUAL (3 << 12)
+# define RADEON_STENCIL_TEST_GEQUAL (4 << 12)
+# define RADEON_STENCIL_TEST_GREATER (5 << 12)
+# define RADEON_STENCIL_TEST_NEQUAL (6 << 12)
+# define RADEON_STENCIL_TEST_ALWAYS (7 << 12)
+# define RADEON_STENCIL_TEST_MASK (0x7 << 12)
+# define RADEON_STENCIL_FAIL_KEEP (0 << 16)
+# define RADEON_STENCIL_FAIL_ZERO (1 << 16)
+# define RADEON_STENCIL_FAIL_REPLACE (2 << 16)
+# define RADEON_STENCIL_FAIL_INC (3 << 16)
+# define RADEON_STENCIL_FAIL_DEC (4 << 16)
+# define RADEON_STENCIL_FAIL_INVERT (5 << 16)
+# define RADEON_STENCIL_FAIL_INC_WRAP (6 << 16)
+# define RADEON_STENCIL_FAIL_DEC_WRAP (7 << 16)
+# define RADEON_STENCIL_FAIL_MASK (0x7 << 16)
+# define RADEON_STENCIL_ZPASS_KEEP (0 << 20)
+# define RADEON_STENCIL_ZPASS_ZERO (1 << 20)
+# define RADEON_STENCIL_ZPASS_REPLACE (2 << 20)
+# define RADEON_STENCIL_ZPASS_INC (3 << 20)
+# define RADEON_STENCIL_ZPASS_DEC (4 << 20)
+# define RADEON_STENCIL_ZPASS_INVERT (5 << 20)
+# define RADEON_STENCIL_ZPASS_INC_WRAP (6 << 20)
+# define RADEON_STENCIL_ZPASS_DEC_WRAP (7 << 20)
+# define RADEON_STENCIL_ZPASS_MASK (0x7 << 20)
+# define RADEON_STENCIL_ZFAIL_KEEP (0 << 24)
+# define RADEON_STENCIL_ZFAIL_ZERO (1 << 24)
+# define RADEON_STENCIL_ZFAIL_REPLACE (2 << 24)
+# define RADEON_STENCIL_ZFAIL_INC (3 << 24)
+# define RADEON_STENCIL_ZFAIL_DEC (4 << 24)
+# define RADEON_STENCIL_ZFAIL_INVERT (5 << 24)
+# define RADEON_STENCIL_ZFAIL_INC_WRAP (6 << 24)
+# define RADEON_STENCIL_ZFAIL_DEC_WRAP (7 << 24)
+# define RADEON_STENCIL_ZFAIL_MASK (0x7 << 24)
+# define RADEON_Z_COMPRESSION_ENABLE (1 << 28)
+# define RADEON_FORCE_Z_DIRTY (1 << 29)
+# define RADEON_Z_WRITE_ENABLE (1 << 30)
+# define RADEON_Z_DECOMPRESSION_ENABLE (1 << 31)
+#define RADEON_RE_LINE_PATTERN 0x1cd0
+# define RADEON_LINE_PATTERN_MASK 0x0000ffff
+# define RADEON_LINE_REPEAT_COUNT_SHIFT 16
+# define RADEON_LINE_PATTERN_START_SHIFT 24
+# define RADEON_LINE_PATTERN_LITTLE_BIT_ORDER (0 << 28)
+# define RADEON_LINE_PATTERN_BIG_BIT_ORDER (1 << 28)
+# define RADEON_LINE_PATTERN_AUTO_RESET (1 << 29)
+#define RADEON_RE_LINE_STATE 0x1cd4
+# define RADEON_LINE_CURRENT_PTR_SHIFT 0
+# define RADEON_LINE_CURRENT_COUNT_SHIFT 8
+#define RADEON_RE_MISC 0x26c4
+# define RADEON_STIPPLE_COORD_MASK 0x1f
+# define RADEON_STIPPLE_X_OFFSET_SHIFT 0
+# define RADEON_STIPPLE_X_OFFSET_MASK (0x1f << 0)
+# define RADEON_STIPPLE_Y_OFFSET_SHIFT 8
+# define RADEON_STIPPLE_Y_OFFSET_MASK (0x1f << 8)
+# define RADEON_STIPPLE_LITTLE_BIT_ORDER (0 << 16)
+# define RADEON_STIPPLE_BIG_BIT_ORDER (1 << 16)
+#define RADEON_RE_SOLID_COLOR 0x1c1c
+#define RADEON_RE_TOP_LEFT 0x26c0
+# define RADEON_RE_LEFT_SHIFT 0
+# define RADEON_RE_TOP_SHIFT 16
+#define RADEON_RE_WIDTH_HEIGHT 0x1c44
+# define RADEON_RE_WIDTH_SHIFT 0
+# define RADEON_RE_HEIGHT_SHIFT 16
+
+#define RADEON_SE_CNTL 0x1c4c
+# define RADEON_FFACE_CULL_CW (0 << 0)
+# define RADEON_FFACE_CULL_CCW (1 << 0)
+# define RADEON_FFACE_CULL_DIR_MASK (1 << 0)
+# define RADEON_BFACE_CULL (0 << 1)
+# define RADEON_BFACE_SOLID (3 << 1)
+# define RADEON_FFACE_CULL (0 << 3)
+# define RADEON_FFACE_SOLID (3 << 3)
+# define RADEON_FFACE_CULL_MASK (3 << 3)
+# define RADEON_BADVTX_CULL_DISABLE (1 << 5)
+# define RADEON_FLAT_SHADE_VTX_0 (0 << 6)
+# define RADEON_FLAT_SHADE_VTX_1 (1 << 6)
+# define RADEON_FLAT_SHADE_VTX_2 (2 << 6)
+# define RADEON_FLAT_SHADE_VTX_LAST (3 << 6)
+# define RADEON_DIFFUSE_SHADE_SOLID (0 << 8)
+# define RADEON_DIFFUSE_SHADE_FLAT (1 << 8)
+# define RADEON_DIFFUSE_SHADE_GOURAUD (2 << 8)
+# define RADEON_DIFFUSE_SHADE_MASK (3 << 8)
+# define RADEON_ALPHA_SHADE_SOLID (0 << 10)
+# define RADEON_ALPHA_SHADE_FLAT (1 << 10)
+# define RADEON_ALPHA_SHADE_GOURAUD (2 << 10)
+# define RADEON_ALPHA_SHADE_MASK (3 << 10)
+# define RADEON_SPECULAR_SHADE_SOLID (0 << 12)
+# define RADEON_SPECULAR_SHADE_FLAT (1 << 12)
+# define RADEON_SPECULAR_SHADE_GOURAUD (2 << 12)
+# define RADEON_SPECULAR_SHADE_MASK (3 << 12)
+# define RADEON_FOG_SHADE_SOLID (0 << 14)
+# define RADEON_FOG_SHADE_FLAT (1 << 14)
+# define RADEON_FOG_SHADE_GOURAUD (2 << 14)
+# define RADEON_FOG_SHADE_MASK (3 << 14)
+# define RADEON_ZBIAS_ENABLE_POINT (1 << 16)
+# define RADEON_ZBIAS_ENABLE_LINE (1 << 17)
+# define RADEON_ZBIAS_ENABLE_TRI (1 << 18)
+# define RADEON_WIDELINE_ENABLE (1 << 20)
+# define RADEON_VPORT_XY_XFORM_ENABLE (1 << 24)
+# define RADEON_VPORT_Z_XFORM_ENABLE (1 << 25)
+# define RADEON_VTX_PIX_CENTER_D3D (0 << 27)
+# define RADEON_VTX_PIX_CENTER_OGL (1 << 27)
+# define RADEON_ROUND_MODE_TRUNC (0 << 28)
+# define RADEON_ROUND_MODE_ROUND (1 << 28)
+# define RADEON_ROUND_MODE_ROUND_EVEN (2 << 28)
+# define RADEON_ROUND_MODE_ROUND_ODD (3 << 28)
+# define RADEON_ROUND_PREC_16TH_PIX (0 << 30)
+# define RADEON_ROUND_PREC_8TH_PIX (1 << 30)
+# define RADEON_ROUND_PREC_4TH_PIX (2 << 30)
+# define RADEON_ROUND_PREC_HALF_PIX (3 << 30)
+#define RADEON_SE_CNTL_STATUS 0x2140
+# define RADEON_VC_NO_SWAP (0 << 0)
+# define RADEON_VC_16BIT_SWAP (1 << 0)
+# define RADEON_VC_32BIT_SWAP (2 << 0)
+# define RADEON_VC_HALF_DWORD_SWAP (3 << 0)
+# define RADEON_TCL_BYPASS (1 << 8)
+#define RADEON_SE_COORD_FMT 0x1c50
+# define RADEON_VTX_XY_PRE_MULT_1_OVER_W0 (1 << 0)
+# define RADEON_VTX_Z_PRE_MULT_1_OVER_W0 (1 << 1)
+# define RADEON_VTX_ST0_NONPARAMETRIC (1 << 8)
+# define RADEON_VTX_ST1_NONPARAMETRIC (1 << 9)
+# define RADEON_VTX_ST2_NONPARAMETRIC (1 << 10)
+# define RADEON_VTX_ST3_NONPARAMETRIC (1 << 11)
+# define RADEON_VTX_W0_NORMALIZE (1 << 12)
+# define RADEON_VTX_W0_IS_NOT_1_OVER_W0 (1 << 16)
+# define RADEON_VTX_ST0_PRE_MULT_1_OVER_W0 (1 << 17)
+# define RADEON_VTX_ST1_PRE_MULT_1_OVER_W0 (1 << 19)
+# define RADEON_VTX_ST2_PRE_MULT_1_OVER_W0 (1 << 21)
+# define RADEON_VTX_ST3_PRE_MULT_1_OVER_W0 (1 << 23)
+# define RADEON_TEX1_W_ROUTING_USE_W0 (0 << 26)
+# define RADEON_TEX1_W_ROUTING_USE_Q1 (1 << 26)
+#define RADEON_SE_LINE_WIDTH 0x1db8
+#define RADEON_SE_TCL_LIGHT_MODEL_CTL 0x226c
+# define RADEON_LIGHTING_ENABLE (1 << 0)
+# define RADEON_LIGHT_IN_MODELSPACE (1 << 1)
+# define RADEON_LOCAL_VIEWER (1 << 2)
+# define RADEON_NORMALIZE_NORMALS (1 << 3)
+# define RADEON_RESCALE_NORMALS (1 << 4)
+# define RADEON_SPECULAR_LIGHTS (1 << 5)
+# define RADEON_DIFFUSE_SPECULAR_COMBINE (1 << 6)
+# define RADEON_LIGHT_ALPHA (1 << 7)
+# define RADEON_LOCAL_LIGHT_VEC_GL (1 << 8)
+# define RADEON_LIGHT_NO_NORMAL_AMBIENT_ONLY (1 << 9)
+# define RADEON_LM_SOURCE_STATE_PREMULT 0
+# define RADEON_LM_SOURCE_STATE_MULT 1
+# define RADEON_LM_SOURCE_VERTEX_DIFFUSE 2
+# define RADEON_LM_SOURCE_VERTEX_SPECULAR 3
+# define RADEON_EMISSIVE_SOURCE_SHIFT 16
+# define RADEON_AMBIENT_SOURCE_SHIFT 18
+# define RADEON_DIFFUSE_SOURCE_SHIFT 20
+# define RADEON_SPECULAR_SOURCE_SHIFT 22
+#define RADEON_SE_TCL_MATERIAL_AMBIENT_RED 0x2220
+#define RADEON_SE_TCL_MATERIAL_AMBIENT_GREEN 0x2224
+#define RADEON_SE_TCL_MATERIAL_AMBIENT_BLUE 0x2228
+#define RADEON_SE_TCL_MATERIAL_AMBIENT_ALPHA 0x222c
+#define RADEON_SE_TCL_MATERIAL_DIFFUSE_RED 0x2230
+#define RADEON_SE_TCL_MATERIAL_DIFFUSE_GREEN 0x2234
+#define RADEON_SE_TCL_MATERIAL_DIFFUSE_BLUE 0x2238
+#define RADEON_SE_TCL_MATERIAL_DIFFUSE_ALPHA 0x223c
+#define RADEON_SE_TCL_MATERIAL_EMMISSIVE_RED 0x2210
+#define RADEON_SE_TCL_MATERIAL_EMMISSIVE_GREEN 0x2214
+#define RADEON_SE_TCL_MATERIAL_EMMISSIVE_BLUE 0x2218
+#define RADEON_SE_TCL_MATERIAL_EMMISSIVE_ALPHA 0x221c
+#define RADEON_SE_TCL_MATERIAL_SPECULAR_RED 0x2240
+#define RADEON_SE_TCL_MATERIAL_SPECULAR_GREEN 0x2244
+#define RADEON_SE_TCL_MATERIAL_SPECULAR_BLUE 0x2248
+#define RADEON_SE_TCL_MATERIAL_SPECULAR_ALPHA 0x224c
+#define RADEON_SE_TCL_MATRIX_SELECT_0 0x225c
+# define RADEON_MODELVIEW_0_SHIFT 0
+# define RADEON_MODELVIEW_1_SHIFT 4
+# define RADEON_MODELVIEW_2_SHIFT 8
+# define RADEON_MODELVIEW_3_SHIFT 12
+# define RADEON_IT_MODELVIEW_0_SHIFT 16
+# define RADEON_IT_MODELVIEW_1_SHIFT 20
+# define RADEON_IT_MODELVIEW_2_SHIFT 24
+# define RADEON_IT_MODELVIEW_3_SHIFT 28
+#define RADEON_SE_TCL_MATRIX_SELECT_1 0x2260
+# define RADEON_MODELPROJECT_0_SHIFT 0
+# define RADEON_MODELPROJECT_1_SHIFT 4
+# define RADEON_MODELPROJECT_2_SHIFT 8
+# define RADEON_MODELPROJECT_3_SHIFT 12
+# define RADEON_TEXMAT_0_SHIFT 16
+# define RADEON_TEXMAT_1_SHIFT 20
+# define RADEON_TEXMAT_2_SHIFT 24
+# define RADEON_TEXMAT_3_SHIFT 28
+
+
+#define RADEON_SE_TCL_OUTPUT_VTX_FMT 0x2254
+# define RADEON_TCL_VTX_W0 (1 << 0)
+# define RADEON_TCL_VTX_FP_DIFFUSE (1 << 1)
+# define RADEON_TCL_VTX_FP_ALPHA (1 << 2)
+# define RADEON_TCL_VTX_PK_DIFFUSE (1 << 3)
+# define RADEON_TCL_VTX_FP_SPEC (1 << 4)
+# define RADEON_TCL_VTX_FP_FOG (1 << 5)
+# define RADEON_TCL_VTX_PK_SPEC (1 << 6)
+# define RADEON_TCL_VTX_ST0 (1 << 7)
+# define RADEON_TCL_VTX_ST1 (1 << 8)
+# define RADEON_TCL_VTX_Q1 (1 << 9)
+# define RADEON_TCL_VTX_ST2 (1 << 10)
+# define RADEON_TCL_VTX_Q2 (1 << 11)
+# define RADEON_TCL_VTX_ST3 (1 << 12)
+# define RADEON_TCL_VTX_Q3 (1 << 13)
+# define RADEON_TCL_VTX_Q0 (1 << 14)
+# define RADEON_TCL_VTX_WEIGHT_COUNT_SHIFT 15
+# define RADEON_TCL_VTX_NORM0 (1 << 18)
+# define RADEON_TCL_VTX_XY1 (1 << 27)
+# define RADEON_TCL_VTX_Z1 (1 << 28)
+# define RADEON_TCL_VTX_W1 (1 << 29)
+# define RADEON_TCL_VTX_NORM1 (1 << 30)
+# define RADEON_TCL_VTX_Z0 (1 << 31)
+
+#define RADEON_SE_TCL_OUTPUT_VTX_SEL 0x2258
+# define RADEON_TCL_COMPUTE_XYZW (1 << 0)
+# define RADEON_TCL_COMPUTE_DIFFUSE (1 << 1)
+# define RADEON_TCL_COMPUTE_SPECULAR (1 << 2)
+# define RADEON_TCL_FORCE_NAN_IF_COLOR_NAN (1 << 3)
+# define RADEON_TCL_FORCE_INORDER_PROC (1 << 4)
+# define RADEON_TCL_TEX_INPUT_TEX_0 0
+# define RADEON_TCL_TEX_INPUT_TEX_1 1
+# define RADEON_TCL_TEX_INPUT_TEX_2 2
+# define RADEON_TCL_TEX_INPUT_TEX_3 3
+# define RADEON_TCL_TEX_COMPUTED_TEX_0 8
+# define RADEON_TCL_TEX_COMPUTED_TEX_1 9
+# define RADEON_TCL_TEX_COMPUTED_TEX_2 10
+# define RADEON_TCL_TEX_COMPUTED_TEX_3 11
+# define RADEON_TCL_TEX_0_OUTPUT_SHIFT 16
+# define RADEON_TCL_TEX_1_OUTPUT_SHIFT 20
+# define RADEON_TCL_TEX_2_OUTPUT_SHIFT 24
+# define RADEON_TCL_TEX_3_OUTPUT_SHIFT 28
+
+#define RADEON_SE_TCL_PER_LIGHT_CTL_0 0x2270
+# define RADEON_LIGHT_0_ENABLE (1 << 0)
+# define RADEON_LIGHT_0_ENABLE_AMBIENT (1 << 1)
+# define RADEON_LIGHT_0_ENABLE_SPECULAR (1 << 2)
+# define RADEON_LIGHT_0_IS_LOCAL (1 << 3)
+# define RADEON_LIGHT_0_IS_SPOT (1 << 4)
+# define RADEON_LIGHT_0_DUAL_CONE (1 << 5)
+# define RADEON_LIGHT_0_ENABLE_RANGE_ATTEN (1 << 6)
+# define RADEON_LIGHT_0_CONSTANT_RANGE_ATTEN (1 << 7)
+# define RADEON_LIGHT_0_SHIFT 0
+# define RADEON_LIGHT_1_ENABLE (1 << 16)
+# define RADEON_LIGHT_1_ENABLE_AMBIENT (1 << 17)
+# define RADEON_LIGHT_1_ENABLE_SPECULAR (1 << 18)
+# define RADEON_LIGHT_1_IS_LOCAL (1 << 19)
+# define RADEON_LIGHT_1_IS_SPOT (1 << 20)
+# define RADEON_LIGHT_1_DUAL_CONE (1 << 21)
+# define RADEON_LIGHT_1_ENABLE_RANGE_ATTEN (1 << 22)
+# define RADEON_LIGHT_1_CONSTANT_RANGE_ATTEN (1 << 23)
+# define RADEON_LIGHT_1_SHIFT 16
+#define RADEON_SE_TCL_PER_LIGHT_CTL_1 0x2274
+# define RADEON_LIGHT_2_SHIFT 0
+# define RADEON_LIGHT_3_SHIFT 16
+#define RADEON_SE_TCL_PER_LIGHT_CTL_2 0x2278
+# define RADEON_LIGHT_4_SHIFT 0
+# define RADEON_LIGHT_5_SHIFT 16
+#define RADEON_SE_TCL_PER_LIGHT_CTL_3 0x227c
+# define RADEON_LIGHT_6_SHIFT 0
+# define RADEON_LIGHT_7_SHIFT 16
+
+#define RADEON_SE_TCL_SHININESS 0x2250
+
+#define RADEON_SE_TCL_TEXTURE_PROC_CTL 0x2268
+# define RADEON_TEXGEN_TEXMAT_0_ENABLE (1 << 0)
+# define RADEON_TEXGEN_TEXMAT_1_ENABLE (1 << 1)
+# define RADEON_TEXGEN_TEXMAT_2_ENABLE (1 << 2)
+# define RADEON_TEXGEN_TEXMAT_3_ENABLE (1 << 3)
+# define RADEON_TEXMAT_0_ENABLE (1 << 4)
+# define RADEON_TEXMAT_1_ENABLE (1 << 5)
+# define RADEON_TEXMAT_2_ENABLE (1 << 6)
+# define RADEON_TEXMAT_3_ENABLE (1 << 7)
+# define RADEON_TEXGEN_INPUT_MASK 0xf
+# define RADEON_TEXGEN_INPUT_TEXCOORD_0 0
+# define RADEON_TEXGEN_INPUT_TEXCOORD_1 1
+# define RADEON_TEXGEN_INPUT_TEXCOORD_2 2
+# define RADEON_TEXGEN_INPUT_TEXCOORD_3 3
+# define RADEON_TEXGEN_INPUT_OBJ 4
+# define RADEON_TEXGEN_INPUT_EYE 5
+# define RADEON_TEXGEN_INPUT_EYE_NORMAL 6
+# define RADEON_TEXGEN_INPUT_EYE_REFLECT 7
+# define RADEON_TEXGEN_INPUT_EYE_NORMALIZED 8
+# define RADEON_TEXGEN_0_INPUT_SHIFT 16
+# define RADEON_TEXGEN_1_INPUT_SHIFT 20
+# define RADEON_TEXGEN_2_INPUT_SHIFT 24
+# define RADEON_TEXGEN_3_INPUT_SHIFT 28
+
+#define RADEON_SE_TCL_UCP_VERT_BLEND_CTL 0x2264
+# define RADEON_UCP_IN_CLIP_SPACE (1 << 0)
+# define RADEON_UCP_IN_MODEL_SPACE (1 << 1)
+# define RADEON_UCP_ENABLE_0 (1 << 2)
+# define RADEON_UCP_ENABLE_1 (1 << 3)
+# define RADEON_UCP_ENABLE_2 (1 << 4)
+# define RADEON_UCP_ENABLE_3 (1 << 5)
+# define RADEON_UCP_ENABLE_4 (1 << 6)
+# define RADEON_UCP_ENABLE_5 (1 << 7)
+# define RADEON_TCL_FOG_MASK (3 << 8)
+# define RADEON_TCL_FOG_DISABLE (0 << 8)
+# define RADEON_TCL_FOG_EXP (1 << 8)
+# define RADEON_TCL_FOG_EXP2 (2 << 8)
+# define RADEON_TCL_FOG_LINEAR (3 << 8)
+# define RADEON_RNG_BASED_FOG (1 << 10)
+# define RADEON_LIGHT_TWOSIDE (1 << 11)
+# define RADEON_BLEND_OP_COUNT_MASK (7 << 12)
+# define RADEON_BLEND_OP_COUNT_SHIFT 12
+# define RADEON_POSITION_BLEND_OP_ENABLE (1 << 16)
+# define RADEON_NORMAL_BLEND_OP_ENABLE (1 << 17)
+# define RADEON_VERTEX_BLEND_SRC_0_PRIMARY (1 << 18)
+# define RADEON_VERTEX_BLEND_SRC_0_SECONDARY (1 << 18)
+# define RADEON_VERTEX_BLEND_SRC_1_PRIMARY (1 << 19)
+# define RADEON_VERTEX_BLEND_SRC_1_SECONDARY (1 << 19)
+# define RADEON_VERTEX_BLEND_SRC_2_PRIMARY (1 << 20)
+# define RADEON_VERTEX_BLEND_SRC_2_SECONDARY (1 << 20)
+# define RADEON_VERTEX_BLEND_SRC_3_PRIMARY (1 << 21)
+# define RADEON_VERTEX_BLEND_SRC_3_SECONDARY (1 << 21)
+# define RADEON_VERTEX_BLEND_WGT_MINUS_ONE (1 << 22)
+# define RADEON_CULL_FRONT_IS_CW (0 << 28)
+# define RADEON_CULL_FRONT_IS_CCW (1 << 28)
+# define RADEON_CULL_FRONT (1 << 29)
+# define RADEON_CULL_BACK (1 << 30)
+# define RADEON_FORCE_W_TO_ONE (1 << 31)
+
+#define RADEON_SE_VPORT_XSCALE 0x1d98
+#define RADEON_SE_VPORT_XOFFSET 0x1d9c
+#define RADEON_SE_VPORT_YSCALE 0x1da0
+#define RADEON_SE_VPORT_YOFFSET 0x1da4
+#define RADEON_SE_VPORT_ZSCALE 0x1da8
+#define RADEON_SE_VPORT_ZOFFSET 0x1dac
+#define RADEON_SE_ZBIAS_FACTOR 0x1db0
+#define RADEON_SE_ZBIAS_CONSTANT 0x1db4
+
+
+
+ /* Registers for CP and Microcode Engine */
+#define RADEON_CP_ME_RAM_ADDR 0x07d4
+#define RADEON_CP_ME_RAM_RADDR 0x07d8
+#define RADEON_CP_ME_RAM_DATAH 0x07dc
+#define RADEON_CP_ME_RAM_DATAL 0x07e0
+
+#define RADEON_CP_RB_BASE 0x0700
+#define RADEON_CP_RB_CNTL 0x0704
+#define RADEON_CP_RB_RPTR_ADDR 0x070c
+#define RADEON_CP_RB_RPTR 0x0710
+#define RADEON_CP_RB_WPTR 0x0714
+
+#define RADEON_CP_IB_BASE 0x0738
+#define RADEON_CP_IB_BUFSZ 0x073c
+
+#define RADEON_CP_CSQ_CNTL 0x0740
+# define RADEON_CSQ_CNT_PRIMARY_MASK (0xff << 0)
+# define RADEON_CSQ_PRIDIS_INDDIS (0 << 28)
+# define RADEON_CSQ_PRIPIO_INDDIS (1 << 28)
+# define RADEON_CSQ_PRIBM_INDDIS (2 << 28)
+# define RADEON_CSQ_PRIPIO_INDBM (3 << 28)
+# define RADEON_CSQ_PRIBM_INDBM (4 << 28)
+# define RADEON_CSQ_PRIPIO_INDPIO (15 << 28)
+#define RADEON_CP_CSQ_STAT 0x07f8
+# define RADEON_CSQ_RPTR_PRIMARY_MASK (0xff << 0)
+# define RADEON_CSQ_WPTR_PRIMARY_MASK (0xff << 8)
+# define RADEON_CSQ_RPTR_INDIRECT_MASK (0xff << 16)
+# define RADEON_CSQ_WPTR_INDIRECT_MASK (0xff << 24)
+#define RADEON_CP_CSQ_ADDR 0x07f0
+#define RADEON_CP_CSQ_DATA 0x07f4
+#define RADEON_CP_CSQ_APER_PRIMARY 0x1000
+#define RADEON_CP_CSQ_APER_INDIRECT 0x1300
+
+#define RADEON_CP_RB_WPTR_DELAY 0x0718
+# define RADEON_PRE_WRITE_TIMER_SHIFT 0
+# define RADEON_PRE_WRITE_LIMIT_SHIFT 23
+
+#define RADEON_AIC_CNTL 0x01d0
+# define RADEON_PCIGART_TRANSLATE_EN (1 << 0)
+#define RADEON_AIC_LO_ADDR 0x01dc
+
+
+
+ /* Constants */
+#define RADEON_LAST_FRAME_REG RADEON_GUI_SCRATCH_REG0
+#define RADEON_LAST_CLEAR_REG RADEON_GUI_SCRATCH_REG2
+
+
+
+ /* CP packet types */
+#define RADEON_CP_PACKET0 0x00000000
+#define RADEON_CP_PACKET1 0x40000000
+#define RADEON_CP_PACKET2 0x80000000
+#define RADEON_CP_PACKET3 0xC0000000
+# define RADEON_CP_PACKET_MASK 0xC0000000
+# define RADEON_CP_PACKET_COUNT_MASK 0x3fff0000
+# define RADEON_CP_PACKET_MAX_DWORDS (1 << 12)
+# define RADEON_CP_PACKET0_REG_MASK 0x000007ff
+# define RADEON_CP_PACKET1_REG0_MASK 0x000007ff
+# define RADEON_CP_PACKET1_REG1_MASK 0x003ff800
+
+#define RADEON_CP_PACKET0_ONE_REG_WR 0x00008000
+
+#define RADEON_CP_PACKET3_NOP 0xC0001000
+#define RADEON_CP_PACKET3_NEXT_CHAR 0xC0001900
+#define RADEON_CP_PACKET3_PLY_NEXTSCAN 0xC0001D00
+#define RADEON_CP_PACKET3_SET_SCISSORS 0xC0001E00
+#define RADEON_CP_PACKET3_3D_RNDR_GEN_INDX_PRIM 0xC0002300
+#define RADEON_CP_PACKET3_LOAD_MICROCODE 0xC0002400
+#define RADEON_CP_PACKET3_WAIT_FOR_IDLE 0xC0002600
+#define RADEON_CP_PACKET3_3D_DRAW_VBUF 0xC0002800
+#define RADEON_CP_PACKET3_3D_DRAW_IMMD 0xC0002900
+#define RADEON_CP_PACKET3_3D_DRAW_INDX 0xC0002A00
+#define RADEON_CP_PACKET3_LOAD_PALETTE 0xC0002C00
+#define RADEON_CP_PACKET3_3D_LOAD_VBPNTR 0xC0002F00
+#define RADEON_CP_PACKET3_CNTL_PAINT 0xC0009100
+#define RADEON_CP_PACKET3_CNTL_BITBLT 0xC0009200
+#define RADEON_CP_PACKET3_CNTL_SMALLTEXT 0xC0009300
+#define RADEON_CP_PACKET3_CNTL_HOSTDATA_BLT 0xC0009400
+#define RADEON_CP_PACKET3_CNTL_POLYLINE 0xC0009500
+#define RADEON_CP_PACKET3_CNTL_POLYSCANLINES 0xC0009800
+#define RADEON_CP_PACKET3_CNTL_PAINT_MULTI 0xC0009A00
+#define RADEON_CP_PACKET3_CNTL_BITBLT_MULTI 0xC0009B00
+#define RADEON_CP_PACKET3_CNTL_TRANS_BITBLT 0xC0009C00
+
+
+#define RADEON_CP_VC_FRMT_XY 0x00000000
+#define RADEON_CP_VC_FRMT_W0 0x00000001
+#define RADEON_CP_VC_FRMT_FPCOLOR 0x00000002
+#define RADEON_CP_VC_FRMT_FPALPHA 0x00000004
+#define RADEON_CP_VC_FRMT_PKCOLOR 0x00000008
+#define RADEON_CP_VC_FRMT_FPSPEC 0x00000010
+#define RADEON_CP_VC_FRMT_FPFOG 0x00000020
+#define RADEON_CP_VC_FRMT_PKSPEC 0x00000040
+#define RADEON_CP_VC_FRMT_ST0 0x00000080
+#define RADEON_CP_VC_FRMT_ST1 0x00000100
+#define RADEON_CP_VC_FRMT_Q1 0x00000200
+#define RADEON_CP_VC_FRMT_ST2 0x00000400
+#define RADEON_CP_VC_FRMT_Q2 0x00000800
+#define RADEON_CP_VC_FRMT_ST3 0x00001000
+#define RADEON_CP_VC_FRMT_Q3 0x00002000
+#define RADEON_CP_VC_FRMT_Q0 0x00004000
+#define RADEON_CP_VC_FRMT_BLND_WEIGHT_CNT_MASK 0x00038000
+#define RADEON_CP_VC_FRMT_N0 0x00040000
+#define RADEON_CP_VC_FRMT_XY1 0x08000000
+#define RADEON_CP_VC_FRMT_Z1 0x10000000
+#define RADEON_CP_VC_FRMT_W1 0x20000000
+#define RADEON_CP_VC_FRMT_N1 0x40000000
+#define RADEON_CP_VC_FRMT_Z 0x80000000
+
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_NONE 0x00000000
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_POINT 0x00000001
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_LINE 0x00000002
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_LINE_STRIP 0x00000003
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_LIST 0x00000004
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN 0x00000005
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_STRIP 0x00000006
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_TYPE_2 0x00000007
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_RECT_LIST 0x00000008
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_3VRT_POINT_LIST 0x00000009
+#define RADEON_CP_VC_CNTL_PRIM_TYPE_3VRT_LINE_LIST 0x0000000a
+#define RADEON_CP_VC_CNTL_PRIM_WALK_IND 0x00000010
+#define RADEON_CP_VC_CNTL_PRIM_WALK_LIST 0x00000020
+#define RADEON_CP_VC_CNTL_PRIM_WALK_RING 0x00000030
+#define RADEON_CP_VC_CNTL_COLOR_ORDER_BGRA 0x00000000
+#define RADEON_CP_VC_CNTL_COLOR_ORDER_RGBA 0x00000040
+#define RADEON_CP_VC_CNTL_MAOS_ENABLE 0x00000080
+#define RADEON_CP_VC_CNTL_VTX_FMT_NON_RADEON_MODE 0x00000000
+#define RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE 0x00000100
+#define RADEON_CP_VC_CNTL_TCL_DISABLE 0x00000000
+#define RADEON_CP_VC_CNTL_TCL_ENABLE 0x00000200
+#define RADEON_CP_VC_CNTL_NUM_SHIFT 16
+
+#define RADEON_VS_MATRIX_0_ADDR 0
+#define RADEON_VS_MATRIX_1_ADDR 4
+#define RADEON_VS_MATRIX_2_ADDR 8
+#define RADEON_VS_MATRIX_3_ADDR 12
+#define RADEON_VS_MATRIX_4_ADDR 16
+#define RADEON_VS_MATRIX_5_ADDR 20
+#define RADEON_VS_MATRIX_6_ADDR 24
+#define RADEON_VS_MATRIX_7_ADDR 28
+#define RADEON_VS_MATRIX_8_ADDR 32
+#define RADEON_VS_MATRIX_9_ADDR 36
+#define RADEON_VS_MATRIX_10_ADDR 40
+#define RADEON_VS_MATRIX_11_ADDR 44
+#define RADEON_VS_MATRIX_12_ADDR 48
+#define RADEON_VS_MATRIX_13_ADDR 52
+#define RADEON_VS_MATRIX_14_ADDR 56
+#define RADEON_VS_MATRIX_15_ADDR 60
+#define RADEON_VS_LIGHT_AMBIENT_ADDR 64
+#define RADEON_VS_LIGHT_DIFFUSE_ADDR 72
+#define RADEON_VS_LIGHT_SPECULAR_ADDR 80
+#define RADEON_VS_LIGHT_DIRPOS_ADDR 88
+#define RADEON_VS_LIGHT_HWVSPOT_ADDR 96
+#define RADEON_VS_LIGHT_ATTENUATION_ADDR 104
+#define RADEON_VS_MATRIX_EYE2CLIP_ADDR 112
+#define RADEON_VS_UCP_ADDR 116
+#define RADEON_VS_GLOBAL_AMBIENT_ADDR 122
+#define RADEON_VS_FOG_PARAM_ADDR 123
+#define RADEON_VS_EYE_VECTOR_ADDR 124
+
+#define RADEON_SS_LIGHT_DCD_ADDR 0
+#define RADEON_SS_LIGHT_SPOT_EXPONENT_ADDR 8
+#define RADEON_SS_LIGHT_SPOT_CUTOFF_ADDR 16
+#define RADEON_SS_LIGHT_SPECULAR_THRESH_ADDR 24
+#define RADEON_SS_LIGHT_RANGE_CUTOFF_ADDR 32
+#define RADEON_SS_VERT_GUARD_CLIP_ADJ_ADDR 48
+#define RADEON_SS_VERT_GUARD_DISCARD_ADJ_ADDR 49
+#define RADEON_SS_HORZ_GUARD_CLIP_ADJ_ADDR 50
+#define RADEON_SS_HORZ_GUARD_DISCARD_ADJ_ADDR 51
+#define RADEON_SS_SHININESS 60
+
+#define RADEON_TV_MASTER_CNTL 0x0800
+# define RADEON_TVCLK_ALWAYS_ONb (1 << 30)
+#define RADEON_TV_DAC_CNTL 0x088c
+# define RADEON_TV_DAC_CMPOUT (1 << 5)
+#define RADEON_TV_PRE_DAC_MUX_CNTL 0x0888
+# define RADEON_Y_RED_EN (1 << 0)
+# define RADEON_C_GRN_EN (1 << 1)
+# define RADEON_CMP_BLU_EN (1 << 2)
+# define RADEON_RED_MX_FORCE_DAC_DATA (6 << 4)
+# define RADEON_GRN_MX_FORCE_DAC_DATA (6 << 8)
+# define RADEON_BLU_MX_FORCE_DAC_DATA (6 << 12)
+# define RADEON_TV_FORCE_DAC_DATA_SHIFT 16
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/Makefile
new file mode 100644
index 000000000..9bd797315
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/Makefile
@@ -0,0 +1,36 @@
+# src/mesa/drivers/dri/s3v/Makefile
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = s3v_dri.so
+
+# Doesn't exist yet.
+#MINIGLX_SOURCES = server/savage_dri.c
+
+DRIVER_SOURCES = \
+ s3v_context.c \
+ s3v_dd.c \
+ s3v_inithw.c \
+ s3v_lock.c \
+ s3v_render.c \
+ s3v_screen.c \
+ s3v_span.c \
+ s3v_state.c \
+ s3v_tex.c \
+ s3v_texmem.c \
+ s3v_texstate.c \
+ s3v_tris.c \
+ s3v_vb.c \
+ s3v_xmesa.c
+
+C_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+
+include ../Makefile.template
+
+symlinks:
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_common.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_common.h
new file mode 100644
index 000000000..b66cdf1df
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_common.h
@@ -0,0 +1,83 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+/* WARNING: If you change any of these defines, make sure to change
+ * the kernel include file as well (s3v_drm.h)
+ */
+
+#ifndef _XF86DRI_S3V_H_
+#define _XF86DRI_S3V_H_
+
+#ifndef _S3V_DEFINES_
+#define _S3V_DEFINES_
+#define S3V_USE_BATCH 1
+
+/* #define S3V_BUF_4K 1 */
+
+#ifdef S3V_BUF_4K
+#define S3V_DMA_BUF_ORDER 12
+#define S3V_DMA_BUF_NR 256
+#else
+#define S3V_DMA_BUF_ORDER 16 /* -much- better */
+#define S3V_DMA_BUF_NR 16
+#endif
+/* on s3virge you can only choose between *
+ * 4k (2^12) and 64k (2^16) dma bufs */
+#define S3V_DMA_BUF_SZ (1<<S3V_DMA_BUF_ORDER)
+
+#define S3V_NR_SAREA_CLIPRECTS 8
+
+/* Each region is a minimum of 16k (64*64@4bpp)
+ * and there are at most 40 of them.
+ */
+#define S3V_NR_TEX_REGIONS 64 /* was 40 */
+#define S3V_LOG_TEX_GRANULARITY 16 /* was 4 */
+/* 40 * (2 ^ 4) = 640k, that's all we have for tex on 4mb gfx card */
+/* FIXME: will it work with card with less than 4mb? */
+/* FIXME: we should set this at run time */
+
+#endif /* _S3V_DEFINES */
+
+/*
+ * WARNING: If you change any of these defines, make sure to change
+ * the kernel include file as well (gamma_drm.h)
+ */
+
+/* Driver specific DRM command indices
+ * NOTE: these are not OS specific, but they are driver specific
+ */
+#define DRM_S3V_INIT_DMA 0x00
+#define DRM_S3V_CLEANUP_DMA 0x01
+
+typedef struct _drmS3VInit {
+ enum {
+ S3V_INIT_DMA = 0x01,
+ S3V_CLEANUP_DMA = 0x02
+ } func;
+
+ unsigned int pcimode; /* bool: 1=pci 0=agp */
+
+ unsigned int mmio_offset;
+ unsigned int buffers_offset;
+ unsigned int sarea_priv_offset;
+
+ unsigned int front_offset;
+ unsigned int front_width;
+ unsigned int front_height;
+ unsigned int front_pitch;
+
+ unsigned int back_offset;
+ unsigned int back_width;
+ unsigned int back_height;
+ unsigned int back_pitch;
+
+ unsigned int depth_offset;
+ unsigned int depth_width;
+ unsigned int depth_height;
+ unsigned int depth_pitch;
+
+ unsigned int texture_offset;
+} drmS3VInit;
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_context.c
new file mode 100644
index 000000000..7b0aa0dae
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_context.c
@@ -0,0 +1,258 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#include "s3v_context.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+
+#include "context.h"
+#include "simple_list.h"
+#include "matrix.h"
+#include "extensions.h"
+#if defined(USE_X86_ASM)
+#include "x86/common_x86_asm.h"
+#endif
+#include "simple_list.h"
+#include "mm.h"
+
+#include "drivers/common/driverfuncs.h"
+#include "s3v_vb.h"
+#include "s3v_tris.h"
+
+#if 0
+extern const struct tnl_pipeline_stage _s3v_render_stage;
+
+static const struct tnl_pipeline_stage *s3v_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ /* REMOVE: point attenuation stage */
+#if 1
+ &_s3v_render_stage, /* ADD: unclipped rastersetup-to-dma */
+#endif
+ &_tnl_render_stage,
+ 0,
+};
+#endif
+
+GLboolean s3vCreateContext(const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate)
+{
+ GLcontext *ctx, *shareCtx;
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ s3vContextPtr vmesa;
+ s3vScreenPtr s3vScrn;
+ S3VSAREAPtr saPriv=(S3VSAREAPtr)(((char*)sPriv->pSAREA) +
+ sizeof(drm_sarea_t));
+ struct dd_function_table functions;
+
+ DEBUG_WHERE(("*** s3vCreateContext ***\n"));
+
+ vmesa = (s3vContextPtr) CALLOC( sizeof(*vmesa) );
+ if ( !vmesa ) return GL_FALSE;
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((s3vContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+
+ _mesa_init_driver_functions(&functions);
+
+ vmesa->glCtx = _mesa_create_context(glVisual, shareCtx, &functions,
+ (void *)vmesa);
+ if (!vmesa->glCtx) {
+ FREE(vmesa);
+ return GL_FALSE;
+ }
+
+ vmesa->driContext = driContextPriv;
+ vmesa->driScreen = sPriv;
+ vmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */
+
+ vmesa->hHWContext = driContextPriv->hHWContext;
+ vmesa->driHwLock = (drmLock *)&sPriv->pSAREA->lock;
+ vmesa->driFd = sPriv->fd;
+ vmesa->sarea = saPriv;
+
+ s3vScrn = vmesa->s3vScreen = (s3vScreenPtr)(sPriv->private);
+
+ ctx = vmesa->glCtx;
+
+ ctx->Const.MaxTextureLevels = 11; /* it is (11-1) -> 1024 * 1024 FIXME */
+
+ ctx->Const.MaxTextureUnits = 1; /* FIXME: or 2 ? */
+
+ /* No wide points.
+ */
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = 1.0;
+ ctx->Const.MaxPointSizeAA = 1.0;
+
+ /* No wide lines.
+ */
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 1.0;
+ ctx->Const.MaxLineWidthAA = 1.0;
+ ctx->Const.LineWidthGranularity = 1.0;
+
+ vmesa->texHeap = mmInit( 0, vmesa->s3vScreen->textureSize );
+ DEBUG(("vmesa->s3vScreen->textureSize = 0x%x\n",
+ vmesa->s3vScreen->textureSize));
+
+ /* NOTE */
+ /* mmInit(offset, size); */
+
+ /* allocates a structure like this:
+
+ struct mem_block_t {
+ struct mem_block_t *next;
+ struct mem_block_t *heap;
+ int ofs,size;
+ int align;
+ int free:1;
+ int reserved:1;
+ };
+
+ */
+
+ make_empty_list(&vmesa->TexObjList);
+ make_empty_list(&vmesa->SwappedOut);
+
+ vmesa->CurrentTexObj[0] = 0;
+ vmesa->CurrentTexObj[1] = 0; /* FIXME */
+
+ vmesa->RenderIndex = ~0;
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+
+ /* Install the customized pipeline:
+ */
+#if 0
+ _tnl_destroy_pipeline( ctx );
+ _tnl_install_pipeline( ctx, s3v_pipeline );
+#endif
+ /* Configure swrast to match hardware characteristics:
+ */
+#if 0
+ _swrast_allow_pixel_fog( ctx, GL_FALSE );
+ _swrast_allow_vertex_fog( ctx, GL_TRUE );
+#endif
+ vmesa->_3d_mode = 0;
+
+ /* 3D lines / gouraud tris */
+ vmesa->CMD = ( AUTO_EXEC_ON | HW_CLIP_ON | DEST_COL_1555
+ | FOG_OFF | ALPHA_OFF | Z_OFF | Z_UPDATE_OFF
+ | Z_LESS | TEX_WRAP_ON | TEX_MODULATE | LINEAR
+ | TEX_COL_ARGB1555 | CMD_3D );
+
+ vmesa->_alpha[0] = vmesa->_alpha[1] = ALPHA_OFF;
+ vmesa->alpha_cmd = vmesa->_alpha[0];
+ vmesa->_tri[0] = DO_GOURAUD_TRI;
+ vmesa->_tri[1] = DO_TEX_LIT_TRI;
+ vmesa->prim_cmd = vmesa->_tri[0];
+
+ /* printf("first vmesa->CMD = 0x%x\n", vmesa->CMD); */
+
+ vmesa->TexOffset = vmesa->s3vScreen->texOffset;
+
+ s3vInitVB( ctx );
+ s3vInitExtensions( ctx );
+ s3vInitDriverFuncs( ctx );
+ s3vInitStateFuncs( ctx );
+ s3vInitSpanFuncs( ctx );
+ s3vInitTextureFuncs( ctx );
+ s3vInitTriFuncs( ctx );
+ s3vInitState( vmesa );
+
+ driContextPriv->driverPrivate = (void *)vmesa;
+
+ /* HACK */
+ vmesa->bufSize = S3V_DMA_BUF_SZ;
+
+ DEBUG(("vmesa->bufSize = %i\n", vmesa->bufSize));
+ DEBUG(("vmesa->bufCount = %i\n", vmesa->bufCount));
+
+
+ /* dma init */
+ DEBUG_BUFS(("GET_FIRST_DMA\n"));
+
+ vmesa->_bufNum = 0;
+
+ GET_FIRST_DMA(vmesa->driFd, vmesa->hHWContext,
+ 1, &(vmesa->bufIndex[0]), &(vmesa->bufSize),
+ &vmesa->_buf[0], &vmesa->bufCount, s3vScrn);
+
+ GET_FIRST_DMA(vmesa->driFd, vmesa->hHWContext,
+ 1, &(vmesa->bufIndex[1]), &(vmesa->bufSize),
+ &vmesa->_buf[1], &vmesa->bufCount, s3vScrn);
+
+ vmesa->buf = vmesa->_buf[vmesa->_bufNum];
+
+/*
+ vmesa->CMD = (AUTO_EXEC_ON | HW_CLIP_ON | DEST_COL_1555
+ | FOG_OFF | ALPHA_OFF | Z_OFF | Z_UPDATE_OFF
+ | DO_GOURAUD_TRI | CMD_3D);
+
+ vmesa->TexOffset = vmesa->s3vScreen->texOffset;
+*/
+
+/* ... but we should support only 15 bit in virge (out of 8/15/24)... */
+
+ DEBUG(("glVisual->depthBits = %i\n", glVisual->depthBits));
+
+ switch (glVisual->depthBits) {
+ case 8:
+ break;
+
+ case 15:
+ case 16:
+ vmesa->depth_scale = 1.0f / 0xffff;
+ break;
+ case 24:
+ vmesa->depth_scale = 1.0f / 0xffffff;
+ break;
+ default:
+ break;
+ }
+
+ vmesa->cull_zero = 0.0f;
+
+ vmesa->DepthSize = glVisual->depthBits;
+ vmesa->Flags = S3V_FRONT_BUFFER;
+ vmesa->Flags |= (glVisual->doubleBufferMode ? S3V_BACK_BUFFER : 0);
+ vmesa->Flags |= (vmesa->DepthSize > 0 ? S3V_DEPTH_BUFFER : 0);
+
+ vmesa->EnabledFlags = S3V_FRONT_BUFFER;
+ vmesa->EnabledFlags |= (glVisual->doubleBufferMode ? S3V_BACK_BUFFER : 0);
+
+
+ if (vmesa->Flags & S3V_BACK_BUFFER) {
+ vmesa->readOffset = vmesa->drawOffset = vmesa->s3vScreen->backOffset;
+ } else {
+ vmesa->readOffset = vmesa->drawOffset = 0;
+ }
+
+ s3vInitHW( vmesa );
+
+ driContextPriv->driverPrivate = (void *)vmesa;
+
+ return GL_TRUE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_context.h
new file mode 100644
index 000000000..b94fee6a8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_context.h
@@ -0,0 +1,444 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#ifndef _S3V_CONTEXT_H_
+#define _S3V_CONTEXT_H_
+
+#include "dri_util.h"
+
+#include "s3v_dri.h"
+#include "s3v_regs.h"
+#include "s3v_macros.h"
+#include "s3v_screen.h"
+#include "colormac.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "drm.h"
+#include "mm.h"
+#include "drirenderbuffer.h"
+
+/* Flags for context */
+#define S3V_FRONT_BUFFER 0x00000001
+#define S3V_BACK_BUFFER 0x00000002
+#define S3V_DEPTH_BUFFER 0x00000004
+
+ /* FIXME: check */
+#define S3V_MAX_TEXTURE_SIZE 2048
+
+/* These are the minimum requirements and should probably be increased */
+#define MAX_MODELVIEW_STACK 16
+#define MAX_PROJECTION_STACK 2
+#define MAX_TEXTURE_STACK 2
+
+extern void s3vDDUpdateHWState(GLcontext *ctx);
+extern s3vScreenPtr s3vCreateScreen(__DRIscreenPrivate *sPriv);
+extern void s3vDestroyScreen(__DRIscreenPrivate *sPriv);
+extern GLboolean s3vCreateContext(const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate);
+
+#define S3V_UPLOAD_ALL 0xffffffff
+/* #define S3V_UPLOAD_CLIPRECTS 0x00000002 */
+#define S3V_UPLOAD_ALPHA 0x00000004
+#define S3V_UPLOAD_BLEND 0x00000008
+#define S3V_UPLOAD_DEPTH 0x00000010
+#define S3V_UPLOAD_VIEWPORT 0x00000020
+#define S3V_UPLOAD_SHADE 0x00000040
+#define S3V_UPLOAD_CLIP 0x00000080
+#define S3V_UPLOAD_MASKS 0x00000100
+#define S3V_UPLOAD_WINDOW 0x00000200 /* defunct */
+#define S3V_UPLOAD_GEOMETRY 0x00000400
+#define S3V_UPLOAD_POLYGON 0x00000800
+#define S3V_UPLOAD_DITHER 0x00001000
+#define S3V_UPLOAD_LOGICOP 0x00002000
+#define S3V_UPLOAD_FOG 0x00004000
+#define S3V_UPLOAD_LIGHT 0x00008000
+#define S3V_UPLOAD_CONTEXT 0x00010000
+#define S3V_UPLOAD_TEX0 0x00020000
+#define S3V_UPLOAD_STIPPLE 0x00040000
+#define S3V_UPLOAD_TRANSFORM 0x00080000
+#define S3V_UPLOAD_LINEMODE 0x00100000
+#define S3V_UPLOAD_POINTMODE 0x00200000
+#define S3V_UPLOAD_TRIMODE 0x00400000
+
+#define S3V_NEW_CLIP 0x00000001
+#define S3V_NEW_WINDOW 0x00000002
+#define S3V_NEW_CONTEXT 0x00000004
+#define S3V_NEW_TEXTURE 0x00000008 /* defunct */
+#define S3V_NEW_ALPHA 0x00000010
+#define S3V_NEW_DEPTH 0x00000020
+#define S3V_NEW_MASKS 0x00000040
+#define S3V_NEW_POLYGON 0x00000080
+#define S3V_NEW_CULL 0x00000100
+#define S3V_NEW_LOGICOP 0x00000200
+#define S3V_NEW_FOG 0x00000400
+#define S3V_NEW_LIGHT 0x00000800
+#define S3V_NEW_STIPPLE 0x00001000
+#define S3V_NEW_ALL 0xffffffff
+
+#define S3V_FALLBACK_TRI 0x00000001
+#define S3V_FALLBACK_TEXTURE 0x00000002
+
+struct s3v_context;
+typedef struct s3v_context s3vContextRec;
+typedef struct s3v_context *s3vContextPtr;
+typedef struct s3v_texture_object_t *s3vTextureObjectPtr;
+
+#define VALID_S3V_TEXTURE_OBJECT(tobj) (tobj)
+
+#define S3V_TEX_MAXLEVELS 12
+
+/* For shared texture space managment, these texture objects may also
+ * be used as proxies for regions of texture memory containing other
+ * client's textures. Such proxy textures (not to be confused with GL
+ * proxy textures) are subject to the same LRU aging we use for our
+ * own private textures, and thus we have a mechanism where we can
+ * fairly decide between kicking out our own textures and those of
+ * other clients.
+ *
+ * Non-local texture objects have a valid MemBlock to describe the
+ * region managed by the other client, and can be identified by
+ * 't->globj == 0'
+ */
+struct s3v_texture_object_t {
+ struct s3v_texture_object_t *next, *prev;
+
+ GLuint age;
+ struct gl_texture_object *globj;
+
+ int Pitch;
+ int Height;
+ int WidthLog2;
+ int texelBytes;
+ int totalSize;
+ int bound;
+
+ PMemBlock MemBlock;
+ GLuint BufAddr;
+
+ GLuint min_level;
+ GLuint max_level;
+ GLuint dirty_images;
+
+ GLint firstLevel, lastLevel; /* upload tObj->Image[first .. lastLevel] */
+
+ struct {
+ const struct gl_texture_image *image;
+ int offset; /* into BufAddr */
+ int height;
+ int internalFormat;
+ } image[S3V_TEX_MAXLEVELS];
+
+ GLuint TextureCMD;
+
+ GLuint TextureColorMode;
+ GLuint TextureFilterMode;
+ GLuint TextureBorderColor;
+ GLuint TextureWrap;
+ GLuint TextureMipSize;
+
+ GLuint TextureBaseAddr[S3V_TEX_MAXLEVELS];
+ GLuint TextureFormat;
+ GLuint TextureReadMode;
+};
+
+#define S3V_NO_PALETTE 0x0
+#define S3V_USE_PALETTE 0x1
+#define S3V_UPDATE_PALETTE 0x2
+#define S3V_FALLBACK_PALETTE 0x4
+
+void s3vUpdateTextureState( GLcontext *ctx );
+
+void s3vDestroyTexObj( s3vContextPtr vmesa, s3vTextureObjectPtr t);
+void s3vUploadTexImages( s3vContextPtr vmesa, s3vTextureObjectPtr t );
+
+void s3vResetGlobalLRU( s3vContextPtr vmesa );
+void s3vTexturesGone( s3vContextPtr vmesa,
+ GLuint start, GLuint end,
+ GLuint in_use );
+
+void s3vEmitHwState( s3vContextPtr vmesa );
+void s3vGetLock( s3vContextPtr vmesa, GLuint flags );
+void s3vInitExtensions( GLcontext *ctx );
+void s3vInitDriverFuncs( GLcontext *ctx );
+void s3vInitSpanFuncs( GLcontext *ctx );
+void s3vSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+void s3vInitState( s3vContextPtr vmesa );
+void s3vInitHW( s3vContextPtr vmesa );
+void s3vInitStateFuncs( GLcontext *ctx );
+void s3vInitTextureFuncs( GLcontext *ctx );
+void s3vInitTriFuncs( GLcontext *ctx );
+
+void s3vUpdateWindow( GLcontext *ctx );
+void s3vUpdateViewportOffset( GLcontext *ctx );
+
+void s3vPrintLocalLRU( s3vContextPtr vmesa );
+void s3vPrintGlobalLRU( s3vContextPtr vmesa );
+
+extern void s3vFallback( s3vContextPtr vmesa, GLuint bit, GLboolean mode );
+#define FALLBACK( imesa, bit, mode ) s3vFallback( imesa, bit, mode )
+
+/* Use the templated vertex formats. Only one of these is used in s3v.
+ */
+#define TAG(x) s3v##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+typedef void (*s3v_quad_func)( s3vContextPtr,
+ const s3vVertex *,
+ const s3vVertex *,
+ const s3vVertex *,
+ const s3vVertex * );
+typedef void (*s3v_tri_func)( s3vContextPtr,
+ const s3vVertex *,
+ const s3vVertex *,
+ const s3vVertex * );
+typedef void (*s3v_line_func)( s3vContextPtr,
+ const s3vVertex *,
+ const s3vVertex * );
+typedef void (*s3v_point_func)( s3vContextPtr,
+ const s3vVertex * );
+
+
+/* static void s3v_lines_emit(GLcontext *ctx, GLuint start, GLuint end); */
+typedef void (*emit_func)( GLcontext *, GLuint, GLuint);
+
+struct s3v_context {
+ GLcontext *glCtx; /* Mesa context */
+
+ __DRIcontextPrivate *driContext;
+ __DRIscreenPrivate *driScreen;
+ __DRIdrawablePrivate *driDrawable;
+
+ GLuint new_gl_state;
+ GLuint new_state;
+ GLuint dirty;
+
+ S3VSAREAPtr sarea;
+
+ /* Temporaries for translating away float colors
+ */
+ struct gl_client_array UbyteColor;
+ struct gl_client_array UbyteSecondaryColor;
+
+ /* Mirrors of some DRI state
+ */
+
+ drm_context_t hHWContext;
+ drmLock *driHwLock;
+ int driFd;
+
+ GLuint numClipRects; /* Cliprects for the draw buffer */
+ drm_clip_rect_t *pClipRects;
+
+ GLuint* buf; /* FIXME */
+ GLuint* _buf[2];
+ int _bufNum;
+ int bufIndex[2];
+ int bufSize;
+ int bufCount;
+
+ s3vScreenPtr s3vScreen; /* Screen private DRI data */
+
+ int drawOffset;
+ int readOffset;
+
+ s3v_point_func draw_point;
+ s3v_line_func draw_line;
+ s3v_tri_func draw_tri;
+ s3v_quad_func draw_quad;
+
+ GLuint Fallback;
+ GLuint RenderIndex;
+ GLuint SetupNewInputs;
+ GLuint SetupIndex;
+
+ GLuint vertex_format;
+ GLuint vertex_size;
+ GLuint vertex_stride_shift;
+ char *verts;
+
+ GLfloat hw_viewport[16];
+ GLuint hw_primitive;
+ GLenum render_primitive;
+
+ GLfloat depth_scale;
+
+ s3vTextureObjectPtr CurrentTexObj[2];
+ struct s3v_texture_object_t TexObjList;
+ struct s3v_texture_object_t SwappedOut;
+ GLenum TexEnvImageFmt[2];
+
+ memHeap_t *texHeap;
+
+ int lastSwap;
+ int texAge;
+ int ctxAge;
+ int dirtyAge;
+ int lastStamp;
+
+ /* max was here: don't touch */
+
+ unsigned int S3V_REG[S3V_REGS_NUM];
+
+ GLuint texMode;
+ GLuint alphaMode;
+ GLuint lightMode;
+
+ GLuint SrcBase;
+ GLuint DestBase;
+ GLuint DestBlit;
+ GLuint ScissorLR;
+ GLuint ScissorTB;
+ GLuint ScissorWH; /* SubScissorWH */ /* RectWH */
+ GLuint FrontStride;
+ GLuint BackStride;
+ GLuint SrcStride;
+ GLuint DestStride;
+ GLuint SrcXY;
+ GLuint DestXY;
+
+ GLuint ClearColor;
+ GLuint Color;
+ GLuint DitherMode;
+ GLuint ClearDepth;
+
+ GLuint TextureBorderColor;
+ GLuint TexOffset;
+ GLuint TexStride;
+
+ GLuint CMD;
+ GLuint prim_cmd;
+ GLuint _tri[2]; /* 0 = gouraud; 1 = tex (lit or unlit) */
+ GLuint alpha_cmd; /* actual alpha cmd */
+ GLuint _alpha[2];
+ GLuint _alpha_tex; /* tex alpha type */
+ /* (3d_mode) 0 = 3d line/gourad tri; 1 = 3d tex tri */
+ GLuint _3d_mode;
+
+ GLfloat backface_sign;
+ GLfloat cull_zero;
+
+ int restore_primitive;
+
+/* *** 2check *** */
+
+ GLuint FogMode;
+ GLuint AreaStippleMode;
+ GLuint LBReadFormat;
+ GLuint LBWriteFormat;
+ GLuint LineMode;
+ GLuint PointMode;
+ GLuint TriangleMode;
+ GLuint AntialiasMode;
+ GLfloat ViewportScaleX;
+ GLfloat ViewportScaleY;
+ GLfloat ViewportScaleZ;
+ GLfloat ViewportOffsetX;
+ GLfloat ViewportOffsetY;
+ GLfloat ViewportOffsetZ;
+ int MatrixMode;
+ int DepthMode;
+ int TransformMode;
+ int LBReadMode;
+ int FBReadMode;
+ int FBWindowBase;
+ int LBWindowBase;
+ int ColorDDAMode;
+ int GeometryMode;
+ int AlphaTestMode;
+ int AlphaBlendMode;
+ int AB_FBReadMode;
+ int AB_FBReadMode_Save;
+ int DeltaMode;
+ int ColorMaterialMode;
+ int FBHardwareWriteMask;
+ int MaterialMode;
+ int NormalizeMode;
+ int LightingMode;
+ int Light0Mode;
+ int Light1Mode;
+ int Light2Mode;
+ int Light3Mode;
+ int Light4Mode;
+ int Light5Mode;
+ int Light6Mode;
+ int Light7Mode;
+ int Light8Mode;
+ int Light9Mode;
+ int Light10Mode;
+ int Light11Mode;
+ int Light12Mode;
+ int Light13Mode;
+ int Light14Mode;
+ int Light15Mode;
+ int LogicalOpMode;
+ int ScissorMode;
+ int ScissorMaxXY;
+ int ScissorMinXY;
+ int Window; /* GID part probably should be in draw priv */
+ int WindowOrigin;
+ int x, y, w, h; /* Probably should be in drawable priv */
+ int FrameCount; /* Probably should be in drawable priv */
+ int NotClipped; /* Probably should be in drawable priv */
+ int WindowChanged; /* Probably should be in drawabl... */
+ int Flags;
+ int EnabledFlags;
+ int DepthSize;
+ int Begin;
+ GLenum ErrorValue;
+ int Texture1DEnabled;
+ int Texture2DEnabled;
+
+ float ModelView[16];
+ float Proj[16];
+ float ModelViewProj[16];
+ float Texture[16];
+
+ float ModelViewStack[(MAX_MODELVIEW_STACK-1)*16];
+ int ModelViewCount;
+ float ProjStack[(MAX_PROJECTION_STACK-1)*16];
+ int ProjCount;
+ float TextureStack[(MAX_TEXTURE_STACK-1)*16];
+ int TextureCount;
+};
+
+#define S3VIRGEPACKCOLOR555( r, g, b, a ) \
+ ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
+ ((a) ? 0x8000 : 0))
+
+#define S3VIRGEPACKCOLOR565( r, g, b ) \
+ ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
+
+#define S3VIRGEPACKCOLOR888( r, g, b ) \
+ (((r) << 16) | ((g) << 8) | (b))
+
+#define S3VIRGEPACKCOLOR8888( r, g, b, a ) \
+ (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
+
+#define S3VIRGEPACKCOLOR4444( r, g, b, a ) \
+ ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
+
+static __inline GLuint s3vPackColor( GLuint cpp,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a )
+{
+ unsigned int ret;
+ DEBUG(("cpp = %i, r=0x%x, g=0x%x, b=0x%x, a=0x%x\n", cpp, r, g, b, a));
+
+ switch ( cpp ) {
+ case 2:
+ ret = S3VIRGEPACKCOLOR555( r, g, b, a );
+ DEBUG(("ret = 0x%x\n", ret));
+ return ret;
+ case 4:
+ return PACK_COLOR_8888( a, r, g, b );
+ default:
+ return 0;
+ }
+}
+
+#define S3V_CONTEXT(ctx) ((s3vContextPtr)(ctx->DriverCtx))
+
+#endif /* _S3V_CONTEXT_H_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_dd.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_dd.c
new file mode 100644
index 000000000..2c8e230f3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_dd.c
@@ -0,0 +1,108 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#include "s3v_context.h"
+#include "s3v_vb.h"
+#include "s3v_lock.h"
+#if defined(USE_X86_ASM)
+#include "x86/common_x86_asm.h"
+#endif
+
+#include "context.h"
+#include "framebuffer.h"
+#include "swrast/swrast.h"
+
+#define S3V_DATE "20020207"
+
+
+/* Return the width and height of the current color buffer.
+ */
+static void s3vDDGetBufferSize( GLframebuffer *buffer,
+ GLuint *width, GLuint *height )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+
+/* S3VHW_LOCK( vmesa ); */
+ *width = vmesa->driDrawable->w;
+ *height = vmesa->driDrawable->h;
+/* S3VHW_UNLOCK( vmesa ); */
+}
+
+
+/* Return various strings for glGetString().
+ */
+static const GLubyte *s3vDDGetString( GLcontext *ctx, GLenum name )
+{
+ static char buffer[128];
+
+ switch ( name ) {
+ case GL_VENDOR:
+ return (GLubyte *)"Max Lingua (ladybug)";
+
+ case GL_RENDERER:
+ sprintf( buffer, "Mesa DRI S3 Virge " S3V_DATE );
+
+ /* Append any CPU-specific information.
+ */
+#ifdef USE_X86_ASM
+ if ( _mesa_x86_cpu_features ) {
+ strncat( buffer, " x86", 4 );
+
+}
+#ifdef USE_MMX_ASM
+ if ( cpu_has_mmx ) {
+ strncat( buffer, "/MMX", 4 );
+ }
+#endif
+#ifdef USE_3DNOW_ASM
+ if ( cpu_has_3dnow ) {
+ strncat( buffer, "/3DNow!", 7 );
+ }
+#endif
+#ifdef USE_SSE_ASM
+ if ( cpu_has_xmm ) {
+ strncat( buffer, "/SSE", 4 );
+ }
+#endif
+#endif
+ return (GLubyte *)buffer;
+
+ default:
+ return NULL;
+ }
+}
+
+/* Enable the extensions supported by this driver.
+ */
+void s3vInitExtensions( GLcontext *ctx )
+{
+ /* None... */
+}
+
+/* Initialize the driver's misc functions.
+ */
+void s3vInitDriverFuncs( GLcontext *ctx )
+{
+ ctx->Driver.GetBufferSize = s3vDDGetBufferSize;
+ ctx->Driver.GetString = s3vDDGetString;
+
+ ctx->Driver.Error = NULL;
+
+ /* Pixel path fallbacks
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.ResizeBuffers = _mesa_resize_framebuffer;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_dri.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_dri.h
new file mode 100644
index 000000000..339c579f7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_dri.h
@@ -0,0 +1,143 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#ifndef _S3V_DRI
+#define _S3V_DRI
+
+#include "s3v_common.h"
+
+#define S3V_MAX_DRAWABLES (S3V_DMA_BUF_NR/2) /* 32 */ /* 256 */ /* FIXME */
+
+typedef struct
+{
+ int deviceID;
+ int width;
+ int height;
+ int mem;
+ int cpp;
+ int bitsPerPixel;
+
+ int fbOffset;
+ int fbStride;
+
+ int logTextureGranularity;
+ int textureOffset;
+
+ drm_handle_t regs;
+ drmSize regsSize;
+
+ unsigned int sarea_priv_offset;
+/*
+ drmAddress regsMap;
+
+ drmSize textureSize;
+ drm_handle_t textures;
+*/
+
+#if 0
+ drm_handle_t agp_buffers;
+ drmSize agp_buf_size;
+#endif
+
+/*
+ drmBufMapPtr drmBufs;
+ int irq;
+ unsigned int sarea_priv_offset;
+*/
+
+/* FIXME: cleanup ! */
+
+ drmSize registerSize; /* == S3V_MMIO_REGSIZE */
+ drm_handle_t registerHandle;
+
+ drmSize pciSize;
+ drm_handle_t pciMemHandle;
+
+ drmSize frontSize; /* == videoRambytes */
+/* drm_handle_t frontHandle; */
+ unsigned long frontOffset; /* == fbOffset */
+ int frontPitch;
+/* unsigned char *front; */
+
+ unsigned int bufferSize; /* size of depth/back buffer */
+
+ drmSize backSize;
+/* drm_handle_t backHandle; */
+ unsigned long backOffset;
+ int backPitch;
+/* unsigned char *back; */
+
+ drmSize depthSize;
+/* drm_handle_t depthHandle; */
+ unsigned long depthOffset;
+ int depthPitch;
+/* unsigned char *depth; */
+
+ drmSize texSize;
+/* drm_handle_t texHandle; */
+ unsigned long texOffset;
+ int texPitch;
+/* unsigned char *tex; */
+
+ drmSize dmaBufSize; /* Size of buffers (in bytes) */
+ drm_handle_t dmaBufHandle; /* Handle from drmAddMap */
+ unsigned long dmaBufOffset; /* Offset/Start */
+ int dmaBufPitch; /* Pitch */
+ unsigned char *dmaBuf; /* Map */
+ int bufNumBufs; /* Number of buffers */
+ drmBufMapPtr buffers; /* Buffer map */
+
+} S3VDRIRec, *S3VDRIPtr;
+
+/* WARNING: Do not change the SAREA structure without changing the kernel
+ * as well */
+
+typedef struct {
+ unsigned char next, prev; /* indices to form a circular LRU */
+ unsigned char in_use; /* owned by a client, or free? */
+ int age; /* tracked by clients to update local LRU's */
+} S3VTexRegionRec, *S3VTexRegionPtr;
+
+typedef struct {
+ unsigned int nbox;
+ drm_clip_rect_t boxes[S3V_NR_SAREA_CLIPRECTS];
+
+ /* Maintain an LRU of contiguous regions of texture space. If
+ * you think you own a region of texture memory, and it has an
+ * age different to the one you set, then you are mistaken and
+ * it has been stolen by another client. If global texAge
+ * hasn't changed, there is no need to walk the list.
+ *
+ * These regions can be used as a proxy for the fine-grained
+ * texture information of other clients - by maintaining them
+ * in the same lru which is used to age their own textures,
+ * clients have an approximate lru for the whole of global
+ * texture space, and can make informed decisions as to which
+ * areas to kick out. There is no need to choose whether to
+ * kick out your own texture or someone else's - simply eject
+ * them all in LRU order.
+ */
+ S3VTexRegionRec texList[S3V_NR_TEX_REGIONS+1]; /* Last elt is sentinal */
+
+ int texAge; /* last time texture was uploaded */
+
+ int last_enqueue; /* last time a buffer was enqueued */
+ int last_dispatch; /* age of the most recently dispatched buffer */
+ int last_quiescent; /* */
+
+ int ctxOwner; /* last context to upload state */
+} S3VSAREARec, *S3VSAREAPtr;
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} S3VConfigPrivRec, *S3VConfigPrivPtr;
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} S3VDRIContextRec, *S3VDRIContextPtr;
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_inithw.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_inithw.c
new file mode 100644
index 000000000..bdc9effb7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_inithw.c
@@ -0,0 +1,79 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#include <sys/ioctl.h>
+
+#include "s3v_context.h"
+
+void s3vInitHW( s3vContextPtr vmesa )
+{
+ int i;
+ static short _reset = 1;
+
+ DEBUG(("vmesa->driDrawable = %p\n", vmesa->driDrawable));
+ DEBUG(("stride = %i\n",
+ vmesa->driScreen->fbWidth*vmesa->s3vScreen->cpp));
+ DEBUG(("frontOffset = 0x%x\n", vmesa->s3vScreen->frontOffset));
+ DEBUG(("backOffset = 0x%x\n", vmesa->s3vScreen->backOffset));
+ DEBUG(("depthOffset = 0x%x\n", vmesa->s3vScreen->depthOffset));
+ DEBUG(("textureOffset = 0x%x\n", vmesa->s3vScreen->texOffset));
+
+/* if (_reset) { */
+/* ioctl(vmesa->driFd, 0x4a); */
+ ioctl(vmesa->driFd, 0x41); /* reset */
+ _reset = 0;
+/* ioctl(vmesa->driFd, 0x4c); */
+/* } */
+
+ /* FIXME */
+ switch (vmesa->s3vScreen->cpp) {
+ case 2:
+ break;
+ case 4:
+ break;
+ }
+
+ /* FIXME for stencil, gid, etc */
+ switch (vmesa->DepthSize) {
+ case 15:
+ case 16:
+ break;
+ case 24:
+ break;
+ case 32:
+ break;
+ }
+
+ vmesa->FogMode = 1;
+ vmesa->ClearDepth = 0xffff;
+ vmesa->x = 0;
+ vmesa->y = 0;
+ vmesa->w = 0;
+ vmesa->h = 0;
+ vmesa->FrameCount = 0;
+ vmesa->MatrixMode = GL_MODELVIEW;
+ vmesa->ModelViewCount = 0;
+ vmesa->ProjCount = 0;
+ vmesa->TextureCount = 0;
+
+
+ /* FIXME: do we need the following? */
+
+ for (i = 0; i < 16; i++)
+ if (i % 5 == 0)
+ vmesa->ModelView[i] =
+ vmesa->Proj[i] =
+ vmesa->ModelViewProj[i] =
+ vmesa->Texture[i] = 1.0;
+ else
+ vmesa->ModelView[i] =
+ vmesa->Proj[i] =
+ vmesa->ModelViewProj[i] =
+ vmesa->Texture[i] = 0.0;
+
+ vmesa->LBWindowBase = vmesa->driScreen->fbWidth *
+ (vmesa->driScreen->fbHeight - 1);
+ vmesa->FBWindowBase = vmesa->driScreen->fbWidth *
+ (vmesa->driScreen->fbHeight - 1);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_lock.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_lock.c
new file mode 100644
index 000000000..52bb87ece
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_lock.c
@@ -0,0 +1,62 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#include "s3v_context.h"
+
+#if DEBUG_LOCKING
+char *prevLockFile = NULL;
+int prevLockLine = 0;
+#endif
+
+
+/* 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.
+ */
+void s3vGetLock( s3vContextPtr vmesa, GLuint flags )
+{
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+/* __DRIscreenPrivate *sPriv = vmesa->driScreen; */
+
+ printf("s3vGetLock <- ***\n");
+
+ drmGetLock( vmesa->driFd, vmesa->hHWContext, flags );
+
+ /* 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.
+ */
+ /* DRI_VALIDATE_DRAWABLE_INFO( vmesa->display, sPriv, dPriv ); */
+
+ if ( vmesa->lastStamp != dPriv->lastStamp ) {
+ vmesa->lastStamp = dPriv->lastStamp;
+ vmesa->new_state |= S3V_NEW_WINDOW | S3V_NEW_CLIP;
+ }
+
+ vmesa->numClipRects = dPriv->numClipRects;
+ vmesa->pClipRects = dPriv->pClipRects;
+
+#if 0
+ vmesa->dirty = ~0;
+
+ if ( sarea->ctxOwner != vmesa->hHWContext ) {
+ sarea->ctxOwner = vmesa->hHWContext;
+ vmesa->dirty = S3V_UPLOAD_ALL;
+ }
+
+ for ( i = 0 ; i < vmesa->lastTexHeap ; i++ ) {
+ if ( sarea->texAge[i] != vmesa->lastTexAge[i] ) {
+ s3vAgeTextures( vmesa, i );
+ }
+ }
+#endif
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_lock.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_lock.h
new file mode 100644
index 000000000..c39d24a38
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_lock.h
@@ -0,0 +1,99 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#ifndef __S3V_LOCK_H__
+#define __S3V_LOCK_H__
+
+#include <sys/ioctl.h>
+
+extern void s3vGetLock( s3vContextPtr vmesa, GLuint flags );
+
+/* Turn DEBUG_LOCKING on to find locking conflicts.
+ */
+#define DEBUG_LOCKING 0
+
+#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 and validate our state.
+ */
+#define LOCK_HARDWARE( vmesa ) \
+ do { \
+ char __ret = 0; \
+ DEBUG_CHECK_LOCK(); \
+ DRM_CAS( vmesa->driHwLock, vmesa->hHWContext, \
+ (DRM_LOCK_HELD | vmesa->hHWContext), __ret ); \
+ if ( __ret ) \
+ s3vGetLock( vmesa, 0 ); \
+ DEBUG_LOCK(); \
+ } while (0)
+
+/* Unlock the hardware.
+ */
+#define UNLOCK_HARDWARE( vmesa ) \
+ do { \
+ DRM_UNLOCK( vmesa->driFd, \
+ vmesa->driHwLock, \
+ vmesa->hHWContext ); \
+ DEBUG_RESET(); \
+ } while (0)
+
+#define S3VHW_LOCK( vmesa ) \
+ DRM_UNLOCK(vmesa->driFd, vmesa->driHwLock, vmesa->hHWContext); \
+ DRM_SPINLOCK(&vmesa->driScreen->pSAREA->drawable_lock, \
+ vmesa->driScreen->drawLockID); \
+ /* VALIDATE_DRAWABLE_INFO_NO_LOCK(vmesa); */
+
+#define S3VHW_UNLOCK( vmesa ) \
+ DRM_SPINUNLOCK(&vmesa->driScreen->pSAREA->drawable_lock, \
+ vmesa->driScreen->drawLockID); \
+ /* VALIDATE_DRAWABLE_INFO_NO_LOCK_POST(vmesa); */
+
+#define S3V_SIMPLE_LOCK( vmesa ) \
+ ioctl(vmesa->driFd, 0x4a)
+
+#define S3V_SIMPLE_FLUSH_LOCK( vmesa ) \
+ ioctl(vmesa->driFd, 0x4b)
+
+#define S3V_SIMPLE_UNLOCK( vmesa ) \
+ ioctl(vmesa->driFd, 0x4c)
+
+#endif /* __S3V_LOCK_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_macros.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_macros.h
new file mode 100644
index 000000000..3bc871b7e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_macros.h
@@ -0,0 +1,229 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#ifndef _S3V_MACROS_H_
+#define _S3V_MACROS_H_
+
+/**************/
+/* DRI macros */
+/**************/
+
+#define GENERIC_DEBUG 0
+#define FLOW_DEBUG 0
+#define DMABUFS_DEBUG 0
+
+/* Note: The argument to DEBUG*() _must_ be enclosed in parenthesis */
+
+#if (GENERIC_DEBUG || FLOW_DEBUG || DMABUFS_DEBUG)
+#include <stdio.h>
+#endif
+
+#if GENERIC_DEBUG
+#define DEBUG(str) printf str
+#else
+#define DEBUG(str)
+#endif
+
+#if FLOW_DEBUG
+#define DEBUG_WHERE(str) printf str
+#else
+#define DEBUG_WHERE(str)
+#endif
+
+#if DMABUFS_DEBUG
+#define DEBUG_BUFS(str) printf str
+#else
+#define DEBUG_BUFS(str)
+#endif
+
+
+#if 0
+#define S3V_DMA_SEND_FLAGS DRM_DMA_PRIORITY
+#define S3V_DMA_SEND_FLAGS DRM_DMA_BLOCK
+#else
+#define S3V_DMA_SEND_FLAGS 0
+#endif
+
+#if 0
+#define S3V_DMA_GET_FLAGS \
+ (DRM_DMA_SMALLER_OK | DRM_DMA_LARGER_OK | DRM_DMA_WAIT)
+#else
+#define S3V_DMA_GET_FLAGS DRM_DMA_WAIT
+#endif
+
+
+#define DMAOUT_CHECK(reg,len) \
+do { \
+ DEBUG(("DMAOUT_CHECK: reg = 0x%x\n", S3V_##reg##_REG)); \
+ DEBUG_BUFS(("DMAOUT_CHECK (was): ")); \
+ DEBUG_BUFS(("vmesa->bufCount=%i of vmesa->bufSize=%i\n", \
+ vmesa->bufCount, vmesa->bufSize)); \
+ /* FIXME: > or >= */ \
+ if (vmesa->bufCount+(len+1) >= vmesa->bufSize) \
+ DMAFLUSH(); \
+\
+ vmesa->bufCount += (len+1); \
+ DEBUG_BUFS(("DMAOUT_CHECK (is): vmesa->bufCount=%i len=%i, reg=%x\n", \
+ vmesa->bufCount, len, S3V_##reg##_REG)); \
+ DMAOUT( ((len & 0xffff) | ((S3V_##reg##_REG & 0xfffc) << 14)) ); \
+} while (0)
+
+#define DMAOUT(val) \
+do { \
+ *(vmesa->buf++)=val; \
+ DEBUG_BUFS(("DMAOUT: val=0x%x\n", (unsigned int)val)); \
+} while(0)
+
+#define DMAFINISH() \
+do { \
+ /* NOTE: it does nothing - it just prints some summary infos */ \
+ DEBUG(("DMAFINISH: vmesa->bufCount=%i\n", vmesa->bufCount)); \
+ DEBUG(("buf: index=%i; addr=%p\n", vmesa->bufIndex[vmesa->_bufNum], \
+ vmesa->s3vScreen->bufs->list[vmesa->bufIndex[vmesa->_bufNum]].address)); \
+} while(0)
+
+#define DMAFLUSH() \
+do { \
+ if (vmesa->bufCount) { \
+ SEND_DMA(vmesa->driFd, vmesa->hHWContext, 1, \
+ &vmesa->bufIndex[vmesa->_bufNum], &vmesa->bufCount); \
+/*
+ GET_DMA(vmesa->driFd, vmesa->hHWContext, 1, \
+ &vmesa->bufIndex, &vmesa->bufSize); \
+*/ \
+ vmesa->_bufNum = !(vmesa->_bufNum); \
+ vmesa->buf = vmesa->_buf[vmesa->_bufNum]; \
+/*
+ vmesa->buf = \
+ vmesa->s3vScreen->bufs->list[vmesa->bufIndex].address; \
+*/ \
+ vmesa->bufCount = 0; \
+ } \
+} while (0)
+
+#define CMDCHANGE() \
+do { \
+ DMAOUT_CHECK(3DTRI_CMDSET, 1); /* FIXME: TRI/LINE */ \
+ DMAOUT(vmesa->CMD); \
+ DMAFINISH(); \
+} while (0)
+
+#ifdef DONT_SEND_DMA
+#define GET_DMA(fd, hHWCtx, n, idx, size)
+#define SEND_DMA(fd, hHWCtx,n, idx, cnt)
+#else
+#define GET_DMA(fd, hHWCtx, n, idx, size) \
+do { \
+ drmDMAReq dma; \
+ int retcode, i; \
+\
+ DEBUG(("GET_DMA: ")); \
+ DEBUG(("req_count=%i; req_list[#0]=%i; req_size[#0]=%i\n", \
+ n, (idx)[n-1], (size)[n-1])); \
+\
+ dma.context = (hHWCtx); \
+ dma.send_count = 0; \
+ dma.send_list = NULL; \
+ dma.send_sizes = NULL; \
+ dma.flags = S3V_DMA_GET_FLAGS; \
+ dma.request_count = (n); \
+ dma.request_size = S3V_DMA_BUF_SZ; \
+ dma.request_list = (idx); \
+ dma.request_sizes = (size); \
+\
+ do { \
+ if ((retcode = drmDMA((fd), &dma))) { \
+ DEBUG_BUFS(("drmDMA (get) returned %d\n", retcode)); \
+ } \
+} while (!(dma).granted_count); \
+\
+ for (i = 0; i < (n); i++) { \
+ DEBUG(("Got buffer %i (index #%i)\n", (idx)[i], i)); \
+ DEBUG(("of %i bytes (%i words) size\n", \
+ (size)[i], (size)[i] >>2)); \
+ /* Convert from bytes to words */ \
+ (size)[i] >>= 2; \
+ } \
+} while (0)
+
+#define SEND_DMA(fd, hHWCtx, n, idx, cnt) \
+do { \
+ drmDMAReq dma; \
+ int retcode, i; \
+\
+ DEBUG(("SEND_DMA: ")); \
+ DEBUG(("send_count=%i; send_list[#0]=%i; send_sizes[#0]=%i\n", \
+ n, (idx)[n-1], (cnt)[n-1])); \
+\
+ for (i = 0; i < (n); i++) { \
+ /* Convert from words to bytes */ \
+ (cnt)[i] <<= 2; \
+ } \
+\
+ dma.context = (hHWCtx); \
+ dma.send_count = (n); \
+ dma.send_list = (idx); \
+ dma.send_sizes = (cnt); \
+ dma.flags = S3V_DMA_SEND_FLAGS; \
+ dma.request_count = 0; \
+ dma.request_size = 0; \
+ dma.request_list = NULL; \
+ dma.request_sizes = NULL; \
+\
+ if ((retcode = drmDMA((fd), &dma))) { \
+ DEBUG_BUFS(("drmDMA (send) returned %d\n", retcode)); \
+ } \
+\
+ for (i = 0; i < (n); i++) { \
+ DEBUG(("Sent buffer %i (index #%i)\n", (idx)[i], i)); \
+ DEBUG(("of %i bytes (%i words) size\n", \
+ (cnt)[i], (cnt)[i] >>2)); \
+ (cnt)[i] = 0; \
+ } \
+} while (0)
+#endif /* DONT_SEND_DMA */
+
+#define GET_FIRST_DMA(fd, hHWCtx, n, idx, size, buf, cnt, vPriv) \
+do { \
+ int i; \
+ DEBUG_BUFS(("GET_FIRST_DMA\n")); \
+ DEBUG_BUFS(("n=%i idx=%i size=%i\n", n, *idx, *size)); \
+ DEBUG_BUFS(("going to GET_DMA\n")); \
+ GET_DMA(fd, hHWCtx, n, idx, size); \
+ DEBUG_BUFS(("coming from GET_DMA\n")); \
+ DEBUG_BUFS(("n=%i idx=%i size=%i\n", n, (idx)[0], (size)[0])); \
+ for (i = 0; i < (n); i++) { \
+ DEBUG_BUFS(("buf #%i @%p\n", \
+ i, (vPriv)->bufs->list[(idx)[i]].address)); \
+ (buf)[i] = (vPriv)->bufs->list[(idx)[i]].address; \
+ (cnt)[i] = 0; \
+ } \
+ DEBUG(("GOING HOME\n")); \
+} while (0)
+
+/**************************/
+/* generic, global macros */
+/**************************/
+
+#define CALC_LOG2(l2,s) \
+do { \
+ int __s = s; \
+ l2 = 0; \
+ while (__s > 1) { ++l2; __s >>= 1; } \
+} while (0)
+
+#define PrimType_Null 0x00000000
+#define PrimType_Points 0x10000000
+#define PrimType_Lines 0x20000000
+#define PrimType_LineLoop 0x30000000
+#define PrimType_LineStrip 0x40000000
+#define PrimType_Triangles 0x50000000
+#define PrimType_TriangleStrip 0x60000000
+#define PrimType_TriangleFan 0x70000000
+#define PrimType_Quads 0x80000000
+#define PrimType_QuadStrip 0x90000000
+#define PrimType_Polygon 0xa0000000
+#define PrimType_Mask 0xf0000000
+
+#endif /* _S3V_MACROS_H_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_regs.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_regs.h
new file mode 100644
index 000000000..26a7c54af
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_regs.h
@@ -0,0 +1,367 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#ifndef _S3V_REG_H
+#define _S3V_REG_H
+
+#define S3V_REGS_NUM 256
+
+/************
+ * DMA REGS *
+ ************/
+
+#define S3V_DMA_ID 0
+#define S3V_DMA_REG 0x8590
+#define S3V_DMA_WRITEP_ID 1
+#define S3V_DMA_WRITEP_REG 0x8594
+#define S3V_DMA_READP_ID 2
+#define S3V_DMA_READP_REG 0x8598
+#define S3V_DMA_ENABLE_ID 3
+#define S3V_DMA_ENABLE_REG 0x859C
+#define S3V_DMA_UPDATE_ID 4
+#define S3V_DMA_UPDATE_REG 0x10000
+
+/***************
+ * STATUS REGS *
+ ***************/
+
+#define S3V_STAT_ID 10
+#define S3V_STAT_REG 0x8504
+#define S3V_STAT_VSYNC_ID 11
+#define S3V_STAT_VSYNC_REG 0x8505
+#define S3V_STAT_3D_DONE_ID 12
+#define S3V_STAT_3D_DONE_REG 0x8506
+#define S3V_STAT_FIFO_OVER_ID 13
+#define S3V_STAT_FIFO_OVER_REG 0x8508
+#define S3V_STAT_FIFO_EMPTY_ID 14
+#define S3V_STAT_FIFO_EMPTY_REG 0x850C
+#define S3V_STAT_HDMA_DONE_ID 15
+#define S3V_STAT_HDMA_DONE_REG 0x8514
+#define S3V_STAT_CDMA_DONE_ID 16
+#define S3V_STAT_CDMA_DONE_REG 0x8524
+#define S3V_STAT_3D_FIFO_EMPTY_ID 17
+#define S3V_STAT_3D_FIFO_EMPTY_REG 0x8544
+#define S3V_STAT_LPB_ID 18
+#define S3V_STAT_LPB_REG 0x8584
+#define S3V_STAT_3D_BUSY_ID 19
+#define S3V_STAT_3D_BUSY_REG 0x8704
+
+/***********
+ * 2D REGS *
+ ***********/
+
+#define S3V_BITBLT_ID 30
+#define S3V_BITBLT_REG 0xA400
+#define S3V_BITBLT_SRC_BASE_ID 31
+#define S3V_BITBLT_SRC_BASE_REG 0xA4D4
+#define S3V_BITBLT_DEST_BASE_ID 32
+#define S3V_BITBLT_DEST_BASE_REG 0xA4D8
+#define S3V_BITBLT_CLIP_L_R_ID 33
+#define S3V_BITBLT_CLIP_L_R_REG 0xA4DC
+#define S3V_BITBLT_CLIP_T_B_ID 34
+#define S3V_BITBLT_CLIP_T_B_REG 0xA4E0
+#define S3V_BITBLT_DEST_SRC_STRIDE_ID 35
+#define S3V_BITBLT_DEST_SRC_STRIDE_REG 0xA4E4
+#define S3V_BITBLT_MONO_PAT0_ID 36
+#define S3V_BITBLT_MONO_PAT0_REG 0xA4E8
+#define S3V_BITBLT_MONO_PAT1_ID 37
+#define S3V_BITBLT_MONO_PAT1_REG 0xA4EC
+#define S3V_BITBLT_PAT_BG_COLOR_ID 38
+#define S3V_BITBLT_PAT_BG_COLOR_REG 0xA4F0
+#define S3V_BITBLT_PAT_FG_COLOR_ID 39
+#define S3V_BITBLT_PAT_FG_COLOR_REG 0xA4F4
+#define S3V_BITBLT_CMDSET_ID 40
+#define S3V_BITBLT_CMDSET_REG 0xA500
+#define S3V_BITBLT_WIDTH_HEIGHT_ID 41
+#define S3V_BITBLT_WIDTH_HEIGHT_REG 0xA504
+#define S3V_BITBLT_SRC_X_Y_ID 42
+#define S3V_BITBLT_SRC_X_Y_REG 0xA508
+#define S3V_BITBLT_DEST_X_Y_ID 43
+#define S3V_BITBLT_DEST_X_Y_REG 0xA50C
+#define S3V_2DLINE_ID 44
+#define S3V_2DLINE_REG 0xA800
+#define S3V_2DPOLY_ID 45
+#define S3V_2DPOLY_REG 0xAC00
+
+/***************
+ * 3DLINE REGS *
+ ***************/
+/* base regs */
+#define S3V_3DLINE_ID 50
+#define S3V_3DLINE_REG 0xB000
+#define S3V_3DLINE_Z_BASE_ID 51
+#define S3V_3DLINE_Z_BASE_REG 0xB0D4
+#define S3V_3DLINE_SRC_BASE_ID 52 /* it is the same reg */
+#define S3V_3DLINE_SRC_BASE_REG 0xB0D4
+#define S3V_3DLINE_DEST_BASE_ID 53
+#define S3V_3DLINE_DEST_BASE_REG 0xB0D8
+#define S3V_3DLINE_CLIP_L_R_ID 54
+#define S3V_3DLINE_CLIP_L_R_REG 0xB0DC
+#define S3V_3DLINE_CLIP_T_B_ID 55
+#define S3V_3DLINE_CLIP_T_B_REG 0xB0E0
+#define S3V_3DLINE_DEST_SRC_STRIDE_ID 56
+#define S3V_3DLINE_DEST_SRC_STRIDE_REG 0xB0E4
+#define S3V_3DLINE_Z_STRIDE_ID 57
+#define S3V_3DLINE_Z_STRIDE_REG 0xB0E8
+#define S3V_3DLINE_TEX_BASE_ID 58
+#define S3V_3DLINE_TEX_BASE_REG 0xB0EC
+#define S3V_3DLINE_TEX_B_COLOR_ID 59
+#define S3V_3DLINE_TEX_B_COLOR_REG 0xB0F0
+#define S3V_3DLINE_FOG_COLOR_ID 60
+#define S3V_3DLINE_FOG_COLOR_REG 0xB0F4
+#define S3V_3DLINE_COLOR0_ID 61
+#define S3V_3DLINE_COLOR0_REG 0xB0F8
+#define S3V_3DLINE_COLOR1_ID 62
+#define S3V_3DLINE_COLOR1_REG 0xB0FC
+#define S3V_3DLINE_CMDSET_ID 63
+#define S3V_3DLINE_CMDSET_REG 0xB100 /* special */
+/* tex regs */
+/* FIXME: shouldn't it be a 1D tex for lines? */
+#define S3V_3DLINE_BASEV_ID 64
+#define S3V_3DLINE_BASEV_REG 0xB104
+#define S3V_3DLINE_BASEU_ID 65
+#define S3V_3DLINE_BASEU_REG 0xB108
+#define S3V_3DLINE_WXD_ID 66
+#define S3V_3DLINE_WXD_REG 0xB10C
+#define S3V_3DLINE_WYD_ID 67
+#define S3V_3DLINE_WYD_REG 0xB110
+#define S3V_3DLINE_WSTART_ID 68
+#define S3V_3DLINE_WSTART_REG 0xB114
+#define S3V_3DLINE_DXD_ID 69
+#define S3V_3DLINE_DXD_REG 0xB118
+#define S3V_3DLINE_VXD_ID 70
+#define S3V_3DLINE_VXD_REG 0xB11C
+#define S3V_3DLINE_UXD_ID 71
+#define S3V_3DLINE_UXD_REG 0xB120
+#define S3V_3DLINE_DYD_ID 72
+#define S3V_3DLINE_DYD_REG 0xB124
+#define S3V_3DLINE_VYD_ID 73
+#define S3V_3DLINE_VYD_REG 0xB128
+#define S3V_3DLINE_UYD_ID 74
+#define S3V_3DLINE_UYD_REG 0xB12C
+#define S3V_3DLINE_DSTART_ID 75
+#define S3V_3DLINE_DSTART_REG 0xB130
+#define S3V_3DLINE_VSTART_ID 76
+#define S3V_3DLINE_VSTART_REG 0xB134
+#define S3V_3DLINE_USTART_ID 77
+#define S3V_3DLINE_USTART_REG 0xB138
+/* gourad regs */
+#define S3V_3DLINE_GBD_ID 78
+#define S3V_3DLINE_GBD_REG 0xB144
+#define S3V_3DLINE_ARD_ID 79
+#define S3V_3DLINE_ARD_REG 0xB148
+#define S3V_3DLINE_GS_BS_ID 80
+#define S3V_3DLINE_GS_BS_REG 0xB14C
+#define S3V_3DLINE_AS_RS_ID 81
+#define S3V_3DLINE_AS_RS_REG 0xB150
+/* vertex regs */
+#define S3V_3DLINE_DZ_ID 82
+#define S3V_3DLINE_DZ_REG 0xB158
+#define S3V_3DLINE_ZSTART_ID 83
+#define S3V_3DLINE_ZSTART_REG 0xB15C
+#define S3V_3DLINE_XEND0_END1_ID 84
+#define S3V_3DLINE_XEND0_END1_REG 0xB16C
+#define S3V_3DLINE_DX_ID 85
+#define S3V_3DLINE_DX_REG 0xB170
+#define S3V_3DLINE_XSTART_ID 86
+#define S3V_3DLINE_XSTART_REG 0xB174
+#define S3V_3DLINE_YSTART_ID 87
+#define S3V_3DLINE_YSTART_REG 0xB178
+#define S3V_3DLINE_YCNT_ID 88
+#define S3V_3DLINE_YCNT_REG 0xB17C
+
+/**************
+ * 3DTRI REGS *
+ **************/
+/* base regs */
+#define S3V_3DTRI_ID 100
+#define S3V_3DTRI_REG 0xB400
+#define S3V_3DTRI_Z_BASE_ID 101
+#define S3V_3DTRI_Z_BASE_REG 0xB4D4
+#define S3V_3DTRI_SRC_BASE_ID 102 /* it is the same reg */
+#define S3V_3DTRI_SRC_BASE_REG 0xB4D4
+#define S3V_3DTRI_DEST_BASE_ID 103
+#define S3V_3DTRI_DEST_BASE_REG 0xB4D8
+#define S3V_3DTRI_CLIP_L_R_ID 104
+#define S3V_3DTRI_CLIP_L_R_REG 0xB4DC
+#define S3V_3DTRI_CLIP_T_B_ID 105
+#define S3V_3DTRI_CLIP_T_B_REG 0xB4E0
+#define S3V_3DTRI_DEST_SRC_STRIDE_ID 106
+#define S3V_3DTRI_DEST_SRC_STRIDE_REG 0xB4E4
+#define S3V_3DTRI_Z_STRIDE_ID 107
+#define S3V_3DTRI_Z_STRIDE_REG 0xB4E8
+#define S3V_3DTRI_TEX_BASE_ID 108
+#define S3V_3DTRI_TEX_BASE_REG 0xB4EC
+#define S3V_3DTRI_TEX_B_COLOR_ID 109
+#define S3V_3DTRI_TEX_B_COLOR_REG 0xB4F0
+#define S3V_3DTRI_FOG_COLOR_ID 110
+#define S3V_3DTRI_FOG_COLOR_REG 0xB4F4
+#define S3V_3DTRI_COLOR0_ID 111
+#define S3V_3DTRI_COLOR0_REG 0xB4F8
+#define S3V_3DTRI_COLOR1_ID 112
+#define S3V_3DTRI_COLOR1_REG 0xB4FC
+#define S3V_3DTRI_CMDSET_ID 113 /* special */
+#define S3V_3DTRI_CMDSET_REG 0xB500
+/* tex regs */
+#define S3V_3DTRI_BASEV_ID 114
+#define S3V_3DTRI_BASEV_REG 0xB504
+#define S3V_3DTRI_BASEU_ID 115
+#define S3V_3DTRI_BASEU_REG 0xB508
+#define S3V_3DTRI_WXD_ID 116
+#define S3V_3DTRI_WXD_REG 0xB50C
+#define S3V_3DTRI_WYD_ID 117
+#define S3V_3DTRI_WYD_REG 0xB510
+#define S3V_3DTRI_WSTART_ID 118
+#define S3V_3DTRI_WSTART_REG 0xB514
+#define S3V_3DTRI_DXD_ID 119
+#define S3V_3DTRI_DXD_REG 0xB518
+#define S3V_3DTRI_VXD_ID 120
+#define S3V_3DTRI_VXD_REG 0xB51C
+#define S3V_3DTRI_UXD_ID 121
+#define S3V_3DTRI_UXD_REG 0xB520
+#define S3V_3DTRI_DYD_ID 122
+#define S3V_3DTRI_DYD_REG 0xB524
+#define S3V_3DTRI_VYD_ID 123
+#define S3V_3DTRI_VYD_REG 0xB528
+#define S3V_3DTRI_UYD_ID 124
+#define S3V_3DTRI_UYD_REG 0xB52C
+#define S3V_3DTRI_DSTART_ID 125
+#define S3V_3DTRI_DSTART_REG 0xB530
+#define S3V_3DTRI_VSTART_ID 126
+#define S3V_3DTRI_VSTART_REG 0xB534
+#define S3V_3DTRI_USTART_ID 127
+#define S3V_3DTRI_USTART_REG 0xB538
+/* gourad regs */
+#define S3V_3DTRI_GBX_ID 128
+#define S3V_3DTRI_GBX_REG 0xB53C
+#define S3V_3DTRI_ARX_ID 129
+#define S3V_3DTRI_ARX_REG 0xB540
+#define S3V_3DTRI_GBY_ID 130
+#define S3V_3DTRI_GBY_REG 0xB544
+#define S3V_3DTRI_ARY_ID 131
+#define S3V_3DTRI_ARY_REG 0xB548
+#define S3V_3DTRI_GS_BS_ID 132
+#define S3V_3DTRI_GS_BS_REG 0xB54C
+#define S3V_3DTRI_AS_RS_ID 133
+#define S3V_3DTRI_AS_RS_REG 0xB550
+/* vertex regs */
+#define S3V_3DTRI_ZXD_ID 134
+#define S3V_3DTRI_ZXD_REG 0xB554
+#define S3V_3DTRI_ZYD_ID 135
+#define S3V_3DTRI_ZYD_REG 0xB558
+#define S3V_3DTRI_ZSTART_ID 136
+#define S3V_3DTRI_ZSTART_REG 0xB55C
+#define S3V_3DTRI_TXDELTA12_ID 137
+#define S3V_3DTRI_TXDELTA12_REG 0xB560
+#define S3V_3DTRI_TXEND12_ID 138
+#define S3V_3DTRI_TXEND12_REG 0xB564
+#define S3V_3DTRI_TXDELTA01_ID 139
+#define S3V_3DTRI_TXDELTA01_REG 0xB568
+#define S3V_3DTRI_TXEND01_ID 140
+#define S3V_3DTRI_TXEND01_REG 0xB56C
+#define S3V_3DTRI_TXDELTA02_ID 141
+#define S3V_3DTRI_TXDELTA02_REG 0xB570
+#define S3V_3DTRI_TXSTART02_ID 142
+#define S3V_3DTRI_TXSTART02_REG 0xB574
+#define S3V_3DTRI_TYS_ID 143
+#define S3V_3DTRI_TYS_REG 0xB578
+#define S3V_3DTRI_TY01_Y12_ID 144
+#define S3V_3DTRI_TY01_Y12_REG 0xB57C
+
+/* COMMANDS (to 0xB100 [lines] or 0xB500 [tris]) */
+
+/* Auto execute */
+#define AUTO_EXEC_MASK 0x00000001
+#define AUTO_EXEC_OFF (0x0)
+#define AUTO_EXEC_ON (0x1)
+/* HW clipping */
+#define HW_CLIP_MASK 0x00000002
+#define HW_CLIP_OFF (0x0 << 1)
+#define HW_CLIP_ON (0x1 << 1)
+/* Destination color */
+#define DEST_COL_MASK 0x0000001c
+#define DEST_COL_PAL (0x0 << 2) /* 8 bpp - palettized */
+#define DEST_COL_1555 (0x1 << 2) /* 16 bpp - ZRGB */
+#define DEST_COL_888 (0x2 << 2) /* 24 bpp - RGB */
+/* Texture color */
+#define TEX_COL_MASK 0x000000e0
+#define TEX_COL_ARGB8888 (0x0 << 5) /* 32 bpp - ARGB */
+#define TEX_COL_ARGB4444 (0x1 << 5) /* 16 bpp - ARGB */
+#define TEX_COL_ARGB1555 (0x2 << 5) /* 16 bpp - ARGB */
+#define TEX_COL_ALPHA4 (0x3 << 5) /* 8 bpp - ALPHA4 */
+#define TEX_COL_BLEND4_LOW (0x4 << 5) /* 4 bpp - BLEND4 low nibble */
+#define TEX_COL_BLEND4_HIGH (0x5 << 5) /* 4 bpp - BLEND4 high nibble */
+#define TEX_COL_PAL (0x6 << 5) /* 8 bpp - palettized */
+#define TEX_COL_YUV (0x7 << 5) /* 16 bpp - YUV */
+/* Mipmap level */
+#define MIP_MASK 0x00000f00
+#define MIPMAP_LEVEL(s) (s << 8) /* 8 -> 11 bits */
+/* Texture filtering */
+#define TEX_FILTER_MASK 0x00007000
+#define MIP_NEAREST (0x0 << 12)
+#define LINEAR_MIP_NEAREST (0x1 << 12)
+#define MIP_LINEAR (0x2 << 12)
+#define LINEAR_MIP_LINEAR (0x3 << 12)
+#define NEAREST (0x4 << 12)
+#define FAST_BILINEAR (0x5 << 12)
+#define LINEAR (0x6 << 12)
+/* Texture blending */
+#define TEX_BLEND_MAKS 0x00018000
+#define TEX_REFLECT (0x0 << 15)
+#define TEX_MODULATE (0x1 << 15)
+#define TEX_DECAL (0x2 << 15)
+/* Fog */
+#define FOG_MASK 0x00020000
+#define FOG_OFF (0x0 << 17)
+#define FOG_ON (0x1 << 17)
+/* Alpha blending */
+#define ALPHA_BLEND_MASK 0x000c0000
+#define ALPHA_OFF (0x0 << 18) | (0x0 << 19)
+#define ALPHA_TEX (0x2 << 18)
+#define ALPHA_SRC (0x3 << 18)
+/* Depth compare mode */
+#define Z_MODE_MASK 0x00700000
+#define Z_NEVER (0x0 << 20)
+#define Z_GREATER (0x1 << 20)
+#define Z_EQUAL (0x2 << 20)
+#define Z_GEQUAL (0x3 << 20)
+#define Z_LESS (0x4 << 20)
+#define Z_NOTEQUAL (0x5 << 20)
+#define Z_LEQUAL (0x6 << 20)
+#define Z_ALWAYS (0x7 << 20)
+/* Depth update */
+#define Z_UPDATE_MASK 0x00800000
+#define Z_UPDATE_OFF (0x0 << 23) /* disable z update */
+#define Z_UPDATE_ON (0x1 << 23)
+/* Depth buffering mode */
+#define Z_BUFFER_MASK 0x03000000
+#define Z_BUFFER (0x0 << 24) | (0x0 << 25)
+#define Z_MUX_BUF (0x1 << 24) | (0x0 << 25)
+#define Z_MUX_DRAW (0x2 << 24)
+#define Z_OFF (0x3 << 24) /* no z buffering */
+/* Texture wrapping */
+#define TEX_WRAP_MASK 0x04000000
+#define TEX_WRAP_OFF (0x0 << 26)
+#define TEX_WRAP_ON (0x1 << 26)
+/* 3d command */
+#define DO_MASK 0x78000000
+#define DO_GOURAUD_TRI (0x0 << 27)
+#define DO_TEX_LIT_TRI_OLD (0x1 << 27)
+#define DO_TEX_UNLIT_TRI_OLD (0x2 << 27)
+#define DO_TEX_LIT_TRI (0x5 << 27)
+#define DO_TEX_UNLIT_TRI (0x6 << 27)
+#define DO_3D_LINE (0x8 << 27)
+#define DO_NOP (0xf << 27) /* turn on autoexec */
+/* status */
+#define CMD_MASK 0x80000000
+#define CMD_2D (0x0 << 31) /* execute a 2d cmd */
+#define CMD_3D (0x1 << 31) /* execute a 3d cmd */
+
+/* global masks */
+#define TEX_MASK ( TEX_COL_MASK | TEX_WRAP_MASK | MIP_MASK \
+ | TEX_FILTER_MASK | TEX_BLEND_MAKS \
+ | TEX_WRAP_MASK )
+#define Z_MASK ( Z_MODE_MASK | Z_UPDATE_MASK | Z_BUFFER_MASK )
+
+#endif /* _S3V_REG_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_render.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_render.c
new file mode 100644
index 000000000..6aaa94976
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_render.c
@@ -0,0 +1,203 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "mtypes.h"
+
+#include "tnl/t_context.h"
+
+#include "s3v_context.h"
+#include "s3v_tris.h"
+#include "s3v_vb.h"
+
+
+#define HAVE_POINTS 0
+#define HAVE_LINES 0
+#define HAVE_LINE_STRIPS 0
+#define HAVE_TRIANGLES 0
+#define HAVE_TRI_STRIPS 0
+#define HAVE_TRI_STRIP_1 0
+#define HAVE_TRI_FANS 0
+#define HAVE_QUADS 0
+#define HAVE_QUAD_STRIPS 0
+#define HAVE_POLYGONS 0
+
+#define HAVE_ELTS 0
+
+#if 0
+static void VERT_FALLBACK( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+/* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */
+ int _flags;
+
+ DEBUG(("VERT_FALLBACK: flags & PRIM_MODE_MASK = %i\n",
+ flags & PRIM_MODE_MASK));
+ DEBUG(("VERT_FALLBACK: flags=%i PRIM_MODE_MASK=%i\n",
+ flags, PRIM_MODE_MASK));
+#if 0
+ tnl->Driver.Render.PrimitiveNotify( ctx, flags & PRIM_MODE_MASK );
+#endif
+ tnl->Driver.Render.BuildVertices( ctx, start, count, ~0 );
+
+ _flags = flags & PRIM_MODE_MASK;
+
+ tnl->Driver.Render.PrimTabVerts[_flags]( ctx, start, count, flags );
+ S3V_CONTEXT(ctx)->SetupNewInputs = VERT_BIT_POS;
+}
+#endif
+
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ PrimType_Points,
+ PrimType_Lines,
+ PrimType_LineLoop,
+ PrimType_LineStrip,
+ PrimType_Triangles,
+ PrimType_TriangleStrip,
+ PrimType_TriangleFan,
+ PrimType_Quads,
+ PrimType_QuadStrip,
+ PrimType_Polygon
+};
+
+static __inline void s3vStartPrimitive( s3vContextPtr vmesa, GLenum prim )
+{
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+
+ int _hw_prim = hw_prim[prim];
+
+ DEBUG(("s3vStartPrimitive (new #%i) ", prim));
+
+ if (_hw_prim != vmesa->restore_primitive) {
+
+ if (prim == 4) { /* TRI */
+ DEBUG(("switching to tri\n"));
+ vmesa->prim_cmd = vmesa->_tri[vmesa->_3d_mode];
+ vmesa->alpha_cmd = vmesa->_alpha[vmesa->_3d_mode];
+ DMAOUT_CHECK(3DTRI_Z_BASE, 12);
+ } else if (prim == 1) { /* LINE */
+ DEBUG(("switching to line\n"));
+ vmesa->prim_cmd = DO_3D_LINE;
+ vmesa->alpha_cmd = vmesa->_alpha[0];
+ DMAOUT_CHECK(3DLINE_Z_BASE, 12);
+ } else {
+ DEBUG(("Never mind the bollocks!\n"));
+ }
+
+ DMAOUT(vmesa->s3vScreen->depthOffset & 0x003FFFF8);
+ DMAOUT(vmesa->DestBase);
+ /* DMAOUT(vmesa->ScissorLR); */
+ /* DMAOUT(vmesa->ScissorTB); */
+ DMAOUT( (0 << 16) | (dPriv->w-1) );
+ DMAOUT( (0 << 16) | (dPriv->h-1) );
+ DMAOUT( (vmesa->SrcStride << 16) | vmesa->TexStride );
+ DMAOUT(vmesa->SrcStride);
+ DMAOUT(vmesa->TexOffset);
+ DMAOUT(vmesa->TextureBorderColor);
+ DMAOUT(0); /* FOG */
+ DMAOUT(0);
+ DMAOUT(0);
+ DMAOUT(vmesa->CMD | vmesa->prim_cmd | vmesa->alpha_cmd);
+ DMAFINISH();
+ }
+
+ vmesa->restore_primitive = _hw_prim;
+}
+
+static __inline void s3vEndPrimitive( s3vContextPtr vmesa )
+{
+/* GLcontext *ctx = vmesa->glCtx; */
+ DEBUG(("s3vEndPrimitive\n"));
+}
+
+#define LOCAL_VARS s3vContextPtr vmesa = S3V_CONTEXT(ctx)
+#define INIT( prim ) s3vStartPrimitive( vmesa, prim )
+#define FINISH s3vEndPrimitive( vmesa )
+#define NEW_PRIMITIVE() (void) vmesa
+#define NEW_BUFFER() (void) vmesa
+#define FIRE_VERTICES() (void) vmesa
+#define GET_CURRENT_VB_MAX_VERTS() \
+ (vmesa->bufSize - vmesa->bufCount) / 2
+#define GET_SUBSEQUENT_VB_MAX_VERTS() \
+ S3V_DMA_BUF_SZ / 2
+/* XXX */
+#define ALLOC_VERTS(nr) NULL
+#define EMIT_VERTS(ctx, start, count, buf) NULL
+#define FLUSH() s3vEndPrimitive( vmesa )
+
+#define TAG(x) s3v_##x
+
+#include "tnl_dd/t_dd_dmatmp.h"
+
+/**********************************************************************/
+/* Render pipeline stage */
+/**********************************************************************/
+
+
+static GLboolean s3v_run_render( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i;
+ tnl_render_func *tab;
+
+ DEBUG(("s3v_run_render\n"));
+
+ /* FIXME: hw clip */
+ if (VB->ClipOrMask || vmesa->RenderIndex != 0) {
+ DEBUG(("*** CLIPPED in render ***\n"));
+#if 1
+ return GL_TRUE; /* don't handle clipping here */
+#endif
+ }
+
+
+ /* We don't do elts */
+ if (VB->Elts)
+ return GL_TRUE;
+
+ tab = TAG(render_tab_verts);
+
+ tnl->Driver.Render.Start( ctx );
+
+ for (i = 0 ; i < VB->PrimitiveCount ; i++ )
+ {
+ GLuint prim = VB->Primitive[i].mode;
+ GLuint start = VB->Primitive[i].start;
+ GLuint length = VB->Primitive[i].count;
+
+ DEBUG(("s3v_run_render (loop=%i) (lenght=%i)\n", i, length));
+
+ if (length) {
+ tnl->Driver.Render.BuildVertices( ctx, start,
+ start+length, ~0 /*stage->inputs*/); /* XXX */
+ tnl->Driver.Render.PrimTabVerts[prim & PRIM_MODE_MASK]
+ ( ctx, start, start + length, prim );
+ vmesa->SetupNewInputs = VERT_BIT_POS;
+ }
+ }
+
+ tnl->Driver.Render.Finish( ctx );
+
+ return GL_FALSE; /* finished the pipe */
+}
+
+
+
+const struct tnl_pipeline_stage _s3v_render_stage =
+{
+ "s3v render",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ s3v_run_render /* run */
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_screen.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_screen.c
new file mode 100644
index 000000000..f1810597e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_screen.c
@@ -0,0 +1,99 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#include "s3v_context.h"
+#include "s3v_vb.h"
+#include "s3v_dri.h"
+
+s3vScreenPtr s3vCreateScreen( __DRIscreenPrivate *sPriv )
+{
+ s3vScreenPtr s3vScreen;
+ S3VDRIPtr vDRIPriv = (S3VDRIPtr)sPriv->pDevPriv;
+
+/* int i; */
+
+ DEBUG(("s3vCreateScreen\n"));
+ DEBUG(("sPriv->pDevPriv at %p\n", sPriv->pDevPriv));
+ DEBUG(("size = %i\n", sizeof(*vDRIPriv)));
+
+ if (sPriv->devPrivSize != sizeof(S3VDRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(S3VDRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
+
+ /* Allocate the private area */
+ s3vScreen = (s3vScreenPtr) CALLOC( sizeof(*s3vScreen) );
+ if ( !s3vScreen ) return NULL;
+
+ s3vScreen->regionCount = 4; /* Magic number. Can we fix this? */
+
+ s3vScreen->regions = _mesa_malloc(s3vScreen->regionCount *
+ sizeof(s3vRegion));
+ DEBUG(("sPriv->fd = %i\nvDRIPriv->dmaBufHandle = %x\n",
+ sPriv->fd, vDRIPriv->dmaBufHandle));
+
+ DEBUG(("vDRIPriv->dmaBufSize=%i\nvDRIPriv->dmaBuf=%p\n",
+ vDRIPriv->dmaBufSize, vDRIPriv->dmaBuf));
+
+
+ /* Get the list of dma buffers */
+ s3vScreen->bufs = drmMapBufs(sPriv->fd);
+
+ if (!s3vScreen->bufs) {
+ DEBUG(("Helter/skelter with drmMapBufs\n"));
+ return GL_FALSE;
+ }
+
+ s3vScreen->textureSize = vDRIPriv->texSize;
+ s3vScreen->logTextureGranularity = vDRIPriv->logTextureGranularity;
+ s3vScreen->cpp = vDRIPriv->cpp;
+ s3vScreen->frontOffset = vDRIPriv->frontOffset;
+ s3vScreen->frontPitch = vDRIPriv->frontPitch;
+ s3vScreen->backOffset = vDRIPriv->backOffset;
+ s3vScreen->backPitch = vDRIPriv->frontPitch; /* FIXME: check */
+ s3vScreen->depthOffset = vDRIPriv->depthOffset;
+ s3vScreen->depthPitch = vDRIPriv->frontPitch;
+ s3vScreen->texOffset = vDRIPriv->texOffset;
+
+ s3vScreen->driScreen = sPriv;
+
+ DEBUG(("vDRIPriv->width =%i; vDRIPriv->deviceID =%x\n", vDRIPriv->width,
+ vDRIPriv->deviceID));
+ DEBUG(("vDRIPriv->mem =%i\n", vDRIPriv->mem));
+ DEBUG(("vDRIPriv->fbOffset =%i\n", vDRIPriv->fbOffset));
+ DEBUG((" ps3vDRI->fbStride =%i\n", vDRIPriv->fbStride));
+ DEBUG(("s3vScreen->cpp = %i\n", s3vScreen->cpp));
+ DEBUG(("s3vScreen->backOffset = %x\n", s3vScreen->backOffset));
+ DEBUG(("s3vScreen->depthOffset = %x\n", s3vScreen->depthOffset));
+ DEBUG(("s3vScreen->texOffset = %x\n", s3vScreen->texOffset));
+ DEBUG(("I will return from s3vCreateScreen now\n"));
+
+ DEBUG(("s3vScreen->bufs = 0x%x\n", s3vScreen->bufs));
+ return s3vScreen;
+}
+
+/* Destroy the device specific screen private data struct.
+ */
+void s3vDestroyScreen( __DRIscreenPrivate *sPriv )
+{
+ s3vScreenPtr s3vScreen = (s3vScreenPtr)sPriv->private;
+
+ DEBUG(("s3vDestroyScreen\n"));
+
+ /* First, unmap the dma buffers */
+/*
+ drmUnmapBufs( s3vScreen->bufs );
+*/
+ /* Next, unmap all the regions */
+/* while (s3vScreen->regionCount > 0) {
+
+ (void)drmUnmap(s3vScreen->regions[s3vScreen->regionCount].map,
+ s3vScreen->regions[s3vScreen->regionCount].size);
+ s3vScreen->regionCount--;
+
+ }
+ FREE(s3vScreen->regions); */
+ if (s3vScreen)
+ FREE(s3vScreen);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_screen.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_screen.h
new file mode 100644
index 000000000..0c4f69efa
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_screen.h
@@ -0,0 +1,39 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#include "mtypes.h"
+
+typedef struct _s3vRegion {
+ drm_handle_t handle;
+ drmSize size;
+ drmAddress map;
+} s3vRegion, *s3vRegionPtr;
+
+typedef struct {
+
+ int regionCount; /* Count of register regions */
+ s3vRegion *regions; /* Vector of mapped region info */
+
+ drmBufMapPtr bufs; /* Map of DMA buffers */
+
+ __DRIscreenPrivate *driScreen; /* Back pointer to DRI screen */
+
+ int cpp;
+ int frontPitch;
+ int frontOffset;
+
+ int backPitch;
+ int backOffset;
+ int backX;
+ int backY;
+
+ int depthOffset;
+ int depthPitch;
+
+ int texOffset;
+ int textureOffset;
+ int textureSize;
+ int logTextureGranularity;
+} s3vScreenRec, *s3vScreenPtr;
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_span.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_span.c
new file mode 100644
index 000000000..49135a9c3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_span.c
@@ -0,0 +1,334 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#include "s3v_context.h"
+#include "s3v_lock.h"
+
+#include "swrast/swrast.h"
+
+#define _SPANLOCK 1
+#define DBG 0
+
+#define LOCAL_VARS \
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx); \
+ s3vScreenPtr s3vscrn = vmesa->s3vScreen; \
+ __DRIscreenPrivate *sPriv = vmesa->driScreen; \
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
+ GLuint pitch = ( (vmesa->Flags & S3V_BACK_BUFFER) ? \
+ ((dPriv->w+31)&~31) * s3vscrn->cpp \
+ : sPriv->fbWidth * s3vscrn->cpp); \
+ GLuint height = dPriv->h; \
+ char *buf = ( (vmesa->Flags & S3V_BACK_BUFFER) ? \
+ (char *)(sPriv->pFB + vmesa->drawOffset) \
+ : (char *)(sPriv->pFB + vmesa->drawOffset \
+ + dPriv->x * s3vscrn->cpp + dPriv->y * pitch) ); \
+ char *read_buf = ( (vmesa->Flags & S3V_BACK_BUFFER) ? \
+ (char *)(sPriv->pFB + vmesa->drawOffset) \
+ : (char *)(sPriv->pFB + vmesa->drawOffset \
+ + dPriv->x * s3vscrn->cpp + dPriv->y * pitch) ); \
+ GLuint p; \
+ (void) read_buf; (void) buf; (void) p; (void) pitch
+
+/* FIXME! Depth/Stencil read/writes don't work ! */
+#define LOCAL_DEPTH_VARS \
+ s3vScreenPtr s3vscrn = vmesa->s3vScreen; \
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
+ __DRIscreenPrivate *sPriv = vmesa->driScreen; \
+ GLuint pitch = s3vscrn->depthPitch; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(sPriv->pFB + \
+ s3vscrn->depthOffset); /* + \
+ dPriv->x * s3vscrn->cpp + \
+ dPriv->y * pitch)*/ \
+ (void) pitch
+
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
+
+#define Y_FLIP( _y ) (height - _y - 1)
+
+#if _SPANLOCK /* OK, we lock */
+
+#define HW_LOCK() \
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx); \
+ (void) vmesa; \
+ DMAFLUSH(); \
+ S3V_SIMPLE_FLUSH_LOCK(vmesa);
+#define HW_UNLOCK() S3V_SIMPLE_UNLOCK(vmesa);
+
+#else /* plz, don't lock */
+
+#define HW_LOCK() \
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx); \
+ (void) vmesa; \
+ DMAFLUSH();
+#define HW_UNLOCK()
+
+#endif
+
+
+/* ================================================================
+ * Color buffer
+ */
+
+/* 16 bit, RGB565 color spanline and pixel functions
+ */
+#define INIT_MONO_PIXEL(p, color) \
+ p = S3VIRGEPACKCOLOR555( color[0], color[1], color[2], color[3] )
+
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+do { \
+ *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 7) | \
+ (((int)g & 0xf8) << 2) | \
+ (((int)b & 0xf8) >> 3)); \
+ DEBUG(("buf=0x%x drawOffset=0x%x dPriv->x=%i s3vscrn->cpp=%i dPriv->y=%i pitch=%i\n", \
+ sPriv->pFB, vmesa->drawOffset, dPriv->x, s3vscrn->cpp, dPriv->y, pitch)); \
+ DEBUG(("dPriv->w = %i\n", dPriv->w)); \
+} while(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] = 0xff; /*
+ if ( rgba[0] & 0x08 ) rgba[0] |= 0x07; \
+ if ( rgba[1] & 0x04 ) rgba[1] |= 0x03; \
+ if ( rgba[2] & 0x08 ) rgba[2] |= 0x07; */ \
+ } while (0)
+
+#define TAG(x) s3v##x##_RGB555
+#include "spantmp.h"
+
+
+/* 32 bit, ARGB8888 color spanline and pixel functions
+ */
+
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = PACK_COLOR_8888( color[3], color[0], color[1], color[2] )
+
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = ((b << 0) | \
+ (g << 8) | \
+ (r << 16) | \
+ (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) s3v##x##_ARGB8888
+#include "spantmp.h"
+
+
+/* 16 bit depthbuffer functions.
+ */
+#define WRITE_DEPTH( _x, _y, d ) \
+ *(GLushort *)(buf + _x*2 + _y*dPriv->w*2) = d
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLushort *)(buf + _x*2 + _y*dPriv->w*2);
+
+#define TAG(x) s3v##x##_16
+#include "depthtmp.h"
+
+
+
+
+/* 32 bit depthbuffer functions.
+ */
+#if 0
+#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) s3v##x##_32
+#include "depthtmp.h"
+#endif
+
+
+/* 24/8 bit interleaved depth/stencil functions
+ */
+#if 0
+#define WRITE_DEPTH( _x, _y, d ) { \
+ GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \
+ tmp &= 0xff; \
+ tmp |= (d) & 0xffffff00; \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \
+}
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLuint *)(buf + _x*4 + _y*pitch) & ~0xff
+
+
+#define TAG(x) s3v##x##_24_8
+#include "depthtmp.h"
+
+#define WRITE_STENCIL( _x, _y, d ) { \
+ GLuint tmp = *(GLuint *)(buf + _x*4 + _y*pitch); \
+ tmp &= 0xffffff00; \
+ tmp |= d & 0xff; \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = tmp; \
+}
+
+#define READ_STENCIL( d, _x, _y ) \
+ d = *(GLuint *)(buf + _x*4 + _y*pitch) & 0xff
+
+#define TAG(x) s3v##x##_24_8
+#include "stenciltmp.h"
+
+#endif
+
+static void s3vSetBuffer( GLcontext *ctx, GLframebuffer *colorBuffer,
+ GLuint bufferBit )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+
+ switch ( bufferBit ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ vmesa->drawOffset = vmesa->readOffset = 0;
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ vmesa->drawOffset = vmesa->readOffset = vmesa->driScreen->fbHeight *
+ vmesa->driScreen->fbWidth *
+ vmesa->s3vScreen->cpp;
+ break;
+ }
+}
+
+
+void s3vInitSpanFuncs( GLcontext *ctx )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetBuffer = s3vSetBuffer;
+
+#if 0
+ switch ( vmesa->s3vScreen->cpp ) {
+ case 2:
+ swdd->WriteRGBASpan = s3vWriteRGBASpan_RGB555;
+ swdd->WriteRGBSpan = s3vWriteRGBSpan_RGB555;
+ swdd->WriteMonoRGBASpan = s3vWriteMonoRGBASpan_RGB555;
+ swdd->WriteRGBAPixels = s3vWriteRGBAPixels_RGB555;
+ swdd->WriteMonoRGBAPixels = s3vWriteMonoRGBAPixels_RGB555;
+ swdd->ReadRGBASpan = s3vReadRGBASpan_RGB555;
+ swdd->ReadRGBAPixels = s3vReadRGBAPixels_RGB555;
+ break;
+
+ case 4:
+ swdd->WriteRGBASpan = s3vWriteRGBASpan_ARGB8888;
+ swdd->WriteRGBSpan = s3vWriteRGBSpan_ARGB8888;
+ swdd->WriteMonoRGBASpan = s3vWriteMonoRGBASpan_ARGB8888;
+ swdd->WriteRGBAPixels = s3vWriteRGBAPixels_ARGB8888;
+ swdd->WriteMonoRGBAPixels = s3vWriteMonoRGBAPixels_ARGB8888;
+#if 1
+ swdd->ReadRGBASpan = s3vReadRGBASpan_ARGB8888;
+#else
+ swdd->ReadRGBASpan = s3vReadRGBASpan8888;
+#endif
+ swdd->ReadRGBAPixels = s3vReadRGBAPixels_ARGB8888;
+ break;
+
+ default:
+ break;
+ }
+#endif
+
+ switch ( vmesa->glCtx->Visual.depthBits ) {
+ case 15:
+ case 16:
+#if 0
+ swdd->ReadDepthSpan = s3vReadDepthSpan_16;
+ swdd->WriteDepthSpan = s3vWriteDepthSpan_16;
+ swdd->ReadDepthPixels = s3vReadDepthPixels_16;
+ swdd->WriteDepthPixels = s3vWriteDepthPixels_16;
+#endif
+ break;
+
+#if 0
+ case 24:
+ swdd->ReadDepthSpan = s3vReadDepthSpan_24_8;
+ swdd->WriteDepthSpan = s3vWriteDepthSpan_24_8;
+ swdd->ReadDepthPixels = s3vReadDepthPixels_24_8;
+ swdd->WriteDepthPixels = s3vWriteDepthPixels_24_8;
+
+ swdd->ReadStencilSpan = s3vReadStencilSpan_24_8;
+ swdd->WriteStencilSpan = s3vWriteStencilSpan_24_8;
+ swdd->ReadStencilPixels = s3vReadStencilPixels_24_8;
+ swdd->WriteStencilPixels = s3vWriteStencilPixels_24_8;
+ break;
+#endif
+
+ default:
+ break;
+ }
+}
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+s3vSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ drb->Base.GetRow = s3vReadRGBASpan_RGB555;
+ drb->Base.GetValues = s3vReadRGBAPixels_RGB555;
+ drb->Base.PutRow = s3vWriteRGBASpan_RGB555;
+ drb->Base.PutRowRGB = s3vWriteRGBSpan_RGB555;
+ drb->Base.PutMonoRow = s3vWriteMonoRGBASpan_RGB555;
+ drb->Base.PutValues = s3vWriteRGBAPixels_RGB555;
+ drb->Base.PutMonoValues = s3vWriteMonoRGBAPixels_RGB555;
+ }
+ else {
+ drb->Base.GetRow = s3vReadRGBASpan_ARGB8888;
+ drb->Base.GetValues = s3vReadRGBAPixels_ARGB8888;
+ drb->Base.PutRow = s3vWriteRGBASpan_ARGB8888;
+ drb->Base.PutRowRGB = s3vWriteRGBSpan_ARGB8888;
+ drb->Base.PutMonoRow = s3vWriteMonoRGBASpan_ARGB8888;
+ drb->Base.PutValues = s3vWriteRGBAPixels_ARGB8888;
+ drb->Base.PutMonoValues = s3vWriteMonoRGBAPixels_ARGB8888;
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = s3vReadDepthSpan_16;
+ drb->Base.GetValues = s3vReadDepthPixels_16;
+ drb->Base.PutRow = s3vWriteDepthSpan_16;
+ drb->Base.PutMonoRow = s3vWriteMonoDepthSpan_16;
+ drb->Base.PutValues = s3vWriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = NULL;
+ drb->Base.GetValues = NULL;
+ drb->Base.PutRow = NULL;
+ drb->Base.PutMonoRow = NULL;
+ drb->Base.PutValues = NULL;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = NULL;
+ drb->Base.GetValues = NULL;
+ drb->Base.PutRow = NULL;
+ drb->Base.PutMonoRow = NULL;
+ drb->Base.PutValues = NULL;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_state.c
new file mode 100644
index 000000000..84aaf4c5b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_state.c
@@ -0,0 +1,888 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#include <X11/Xlibint.h>
+#include "s3v_context.h"
+#include "s3v_macros.h"
+#include "macros.h"
+#include "s3v_dri.h"
+#include "colormac.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+
+/* #define DEBUG(str) printf str */
+#define ENABLELIGHTING 0
+
+
+/* =============================================================
+ * Alpha blending
+ */
+
+static void s3vUpdateAlphaMode( GLcontext *ctx )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ CARD32 cmd = vmesa->CMD;
+ cmd &= ~ALPHA_BLEND_MASK;
+
+ if ( ctx->Color.BlendEnabled ) {
+ DEBUG(("ctx->Color.AlphaEnabled = 1"));
+ vmesa->_alpha[0] = ALPHA_SRC;
+ vmesa->_alpha[1] = vmesa->_alpha_tex; /* FIXME: not all tex modes
+ support alpha */
+ } else {
+ DEBUG(("ctx->Color.AlphaEnabled = 0"));
+ vmesa->_alpha[0] = vmesa->_alpha[1] = ALPHA_OFF;
+ }
+#if 1
+ if ((cmd & DO_MASK) & DO_3D_LINE) { /* we are drawing 3d lines */
+ /* which don't support tex */
+ cmd |= vmesa->_alpha[0];
+ } else {
+ cmd |= vmesa->_alpha[vmesa->_3d_mode];
+ }
+
+ vmesa->CMD = cmd; /* FIXME: enough? */
+#else
+ vmesa->restore_primitive = -1;
+#endif
+
+}
+
+static void s3vDDAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+
+ DEBUG(("s3vDDAlphaFunc\n"));
+
+ vmesa->new_state |= S3V_NEW_ALPHA;
+}
+
+static void s3vDDBlendFunc( GLcontext *ctx, GLenum sfactor, GLenum dfactor )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+
+ DEBUG(("s3vDDBlendFunc\n"));
+
+ vmesa->new_state |= S3V_NEW_ALPHA;
+}
+
+/* ================================================================
+ * Buffer clear
+ */
+
+static void s3vDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ unsigned int _stride;
+
+ vmesa->restore_primitive = -1;
+
+ /* Update and emit any new state. We need to do this here to catch
+ * changes to the masks.
+ * FIXME: Just update the masks?
+ */
+
+ if ( vmesa->new_state )
+ s3vDDUpdateHWState( ctx );
+
+/* s3vUpdateMasks( ctx ); */
+/* s3vUpdateClipping( ctx ); */
+/* s3vEmitHwState( vmesa ); */
+
+
+#if 1 /* soft (0)/hw (1)*/
+
+ DEBUG(("*** s3vDDClear ***\n"));
+
+ DMAOUT_CHECK(BITBLT_SRC_BASE, 15);
+ DMAOUT(vmesa->SrcBase);
+ DMAOUT(vmesa->DestBlit);
+ DMAOUT( vmesa->ScissorLR );
+ DMAOUT( vmesa->ScissorTB );
+ DMAOUT( (vmesa->SrcStride << 16) | vmesa->SrcStride ); /* FIXME: unify */
+ DMAOUT( (~(0)) ); /* masks */
+ DMAOUT( (~(0)) );
+ DMAOUT(0);
+ DMAOUT(vmesa->ClearColor);
+ DMAOUT(0);
+ DMAOUT(0);
+ /* FIXME */
+ DMAOUT(0x16000122 | 0x5 | (0xF0 << 17)); /* black magic to me */
+ DMAOUT(vmesa->ScissorWH);
+ DMAOUT(vmesa->SrcXY);
+ DMAOUT(vmesa->DestXY);
+ DMAFINISH();
+
+ if (mask & BUFFER_BIT_DEPTH) { /* depth */
+ DEBUG(("BUFFER_BIT_DEPTH\n"));
+
+ _stride = ((cw+31)&~31) * 2;
+
+ DMAOUT_CHECK(BITBLT_SRC_BASE, 15);
+ DMAOUT(0);
+ DMAOUT(vmesa->s3vScreen->depthOffset);
+ DMAOUT( (0 << 16) | cw );
+ DMAOUT( (0 << 16) | ch );
+ DMAOUT( (vmesa->SrcStride << 16) | vmesa->DestStride );
+ DMAOUT( (~(0)) ); /* masks */
+ DMAOUT( (~(0)) );
+ DMAOUT(0);
+ DMAOUT(vmesa->ClearDepth); /* 0x7FFF */
+ /* FIXME */
+ DMAOUT(0);
+ DMAOUT(0);
+ DMAOUT(0x16000122 | 0x5 | (0xF0 << 17));
+ DMAOUT( ((cw-1) << 16) | (ch-1) );
+ DMAOUT(0);
+ DMAOUT( (0 << 16) | 0 );
+ DMAFINISH();
+
+ DEBUG(("vmesa->ClearDepth = 0x%x\n", vmesa->ClearDepth));
+ mask &= ~BUFFER_BIT_DEPTH;
+ }
+
+ if (!vmesa->NotClipped) {
+ DEBUG(("vmesa->NotClipped\n")); /* yes */
+ }
+
+ if (!(vmesa->EnabledFlags & S3V_BACK_BUFFER)) {
+ DEBUG(("!S3V_BACK_BUFFER -> flush\n"));
+ DMAFLUSH();
+ }
+/*
+ if ( mask )
+ DEBUG(("still masked ;3(\n")); */ /* yes */
+#else
+ _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
+#endif
+}
+
+/* =============================================================
+ * Depth testing
+ */
+
+static void s3vUpdateZMode( GLcontext *ctx )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ CARD32 cmd = vmesa->CMD;
+
+ DEBUG(("Depth.Test = %i\n", ctx->Depth.Test));
+ DEBUG(("CMD was = 0x%x ", cmd));
+
+/* printf("depth --- CMD was = 0x%x \n", cmd); */
+
+ cmd &= ~Z_MASK; /* 0xfc0fffff; */
+ /* Z_BUFFER */ /* 000 mode */ /* Z_UPDATE_OFF */
+
+ if (!ctx->Depth.Test)
+ cmd |= Z_OFF;
+
+ if ( ctx->Depth.Mask )
+ cmd |= Z_UPDATE_ON;
+
+ switch ( ctx->Depth.Func ) {
+ case GL_NEVER:
+ cmd |= Z_NEVER;
+ break;
+ case GL_ALWAYS:
+ cmd |= Z_ALWAYS;
+ break;
+ case GL_LESS:
+ cmd |= Z_LESS;
+ break;
+ case GL_LEQUAL:
+ cmd |= Z_LEQUAL;
+ break;
+ case GL_EQUAL:
+ cmd |= Z_EQUAL;
+ break;
+ case GL_GEQUAL:
+ cmd |= Z_GEQUAL;
+ break;
+ case GL_GREATER:
+ cmd |= Z_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ cmd |= Z_NOTEQUAL;
+ break;
+ }
+
+ DEBUG(("CMD is 0x%x\n", cmd));
+
+ vmesa->dirty |= S3V_UPLOAD_DEPTH;
+ vmesa->CMD = cmd;
+}
+
+static void s3vDDDepthFunc( GLcontext *ctx, GLenum func )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+
+/* FLUSH_BATCH( vmesa ); */
+ DEBUG(("s3vDDDepthFunc\n"));
+ vmesa->new_state |= S3V_NEW_DEPTH;
+}
+
+static void s3vDDDepthMask( GLcontext *ctx, GLboolean flag )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+
+ /* FLUSH_BATCH( vmesa ); */
+ DEBUG(("s3vDDDepthMask\n"));
+ vmesa->new_state |= S3V_NEW_DEPTH;
+}
+
+static void s3vDDClearDepth( GLcontext *ctx, GLclampd d )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+
+ switch ( vmesa->DepthSize ) {
+ case 15:
+ case 16:
+ vmesa->ClearDepth = d * 0x0000ffff; /* 65536 */
+ DEBUG(("GLclampd d = %f\n", d));
+ DEBUG(("ctx->Depth.Clear = %f\n", ctx->Depth.Clear));
+ DEBUG(("(They should be the same)\n"));
+ break;
+ case 24:
+ vmesa->ClearDepth = d * 0x00ffffff;
+ break;
+ case 32:
+ vmesa->ClearDepth = d * 0xffffffff;
+ break;
+ }
+}
+
+static void s3vDDFinish( GLcontext *ctx )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ DMAFLUSH();
+}
+
+static void s3vDDFlush( GLcontext *ctx )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ DMAFLUSH();
+}
+
+/* =============================================================
+ * Fog
+ */
+
+static void s3vUpdateFogAttrib( GLcontext *ctx )
+{
+/* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */
+
+ if (ctx->Fog.Enabled) {
+ } else {
+ }
+
+ switch (ctx->Fog.Mode) {
+ case GL_LINEAR:
+ break;
+ case GL_EXP:
+ break;
+ case GL_EXP2:
+ break;
+ }
+}
+
+static void s3vDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ vmesa->new_state |= S3V_NEW_FOG;
+}
+
+/* =============================================================
+ * Lines
+ */
+static void s3vDDLineWidth( GLcontext *ctx, GLfloat width )
+{
+ /* FIXME: on virge you only have one size of 3d lines *
+ * if we wanted more, we should start using tris instead *
+ * but virge has problem with some tris when all of the *
+ * vertices stay on a line */
+}
+
+/* =============================================================
+ * Points
+ */
+static void s3vDDPointSize( GLcontext *ctx, GLfloat size )
+{
+ /* FIXME: we use 3d line to fake points. So same limitations
+ * as above apply */
+}
+
+/* =============================================================
+ * Polygon
+ */
+
+static void s3vUpdatePolygon( GLcontext *ctx )
+{
+ /* FIXME: I don't think we could do much here */
+
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ vmesa->dirty |= S3V_UPLOAD_POLYGON;
+}
+
+/* =============================================================
+ * Clipping
+ */
+
+static void s3vUpdateClipping( GLcontext *ctx )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+
+ int x0,y0,x1,y1;
+
+ DEBUG((">>> s3vUpdateClipping <<<\n"));
+/*
+ if ( vmesa->driDrawable ) {
+ DEBUG(("s3vUpdateClipping\n"));
+*/
+ if (vmesa->EnabledFlags & S3V_BACK_BUFFER) {
+ DEBUG(("S3V_BACK_BUFFER\n"));
+
+ x0 = 0;
+ y0 = 0;
+ x1 = dPriv->w - 1;
+ y1 = dPriv->h - 1;
+
+ vmesa->SrcBase = 0;
+ vmesa->DestBase = vmesa->s3vScreen->backOffset;
+ vmesa->DestBlit = vmesa->DestBase;
+ vmesa->ScissorLR = ( (0 << 16) | (dPriv->w-1) );
+ vmesa->ScissorTB = ( (0 << 16) | (dPriv->h-1) );
+/*
+ vmesa->ScissorLR = ( (x0 << 16) | x1 );
+ vmesa->ScissorTB = ( (y0 << 16) | y1 );
+*/
+ vmesa->SrcStride = ( ((dPriv->w+31)&~31) * vmesa->s3vScreen->cpp );
+ vmesa->DestStride = vmesa->driScreen->fbWidth*vmesa->s3vScreen->cpp;
+ vmesa->ScissorWH = ( (dPriv->w << 16) | dPriv->h );
+ vmesa->SrcXY = 0;
+/* vmesa->DestXY = ( (dPriv->x << 16) | dPriv->y ); */
+ vmesa->DestXY = ( (0 << 16) | 0 );
+ } else {
+ DEBUG(("S3V_FRONT_BUFFER\n"));
+
+ x0 = dPriv->x;
+ y0 = dPriv->y;
+ x1 = x0 + dPriv->w - 1;
+ y1 = y0 + dPriv->h - 1;
+
+ vmesa->SrcBase = 0;
+ vmesa->DestBase = 0;
+ vmesa->ScissorLR = ( (x0 << 16) | x1 );
+ vmesa->ScissorTB = ( (y0 << 16) | y1 );
+ vmesa->DestStride = vmesa->driScreen->fbWidth*vmesa->s3vScreen->cpp;
+ vmesa->SrcStride = vmesa->DestStride;
+ vmesa->DestBase = (y0 * vmesa->DestStride)
+ + x0*vmesa->s3vScreen->cpp;
+ vmesa->DestBlit = 0;
+ vmesa->ScissorWH = ( (x1 << 16) | y1 );
+ vmesa->SrcXY = 0;
+ vmesa->DestXY = ( (0 << 16) | 0 );
+/* vmesa->DestXY = ( (dPriv->x << 16) | dPriv->y ); */
+ }
+
+ DEBUG(("x0=%i y0=%i x1=%i y1=%i\n", x0, y0, x1, y1));
+ DEBUG(("stride=%i rectWH=0x%x\n\n", vmesa->DestStride, vmesa->ScissorWH));
+
+ /* FIXME: how could we use the following info? */
+ /* if (ctx->Scissor.Enabled) {} */
+
+ vmesa->dirty |= S3V_UPLOAD_CLIP;
+/* } */
+}
+
+static void s3vDDScissor( GLcontext *ctx,
+ GLint x, GLint y, GLsizei w, GLsizei h )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+
+ DEBUG((">>> s3vDDScissor <<<"));
+ /* FLUSH_BATCH( vmesa ); */
+ vmesa->new_state |= S3V_NEW_CLIP;
+}
+
+/* =============================================================
+ * Culling
+ */
+
+static void s3vUpdateCull( GLcontext *ctx )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ GLfloat backface_sign = 1;
+
+ DEBUG(("s3vUpdateCull\n"));
+ /* FIXME: GL_FRONT_AND_BACK */
+
+ switch ( ctx->Polygon.CullFaceMode ) {
+ case GL_BACK:
+ if (ctx->Polygon.FrontFace == GL_CCW)
+ backface_sign = -1;
+ break;
+
+ case GL_FRONT:
+ if (ctx->Polygon.FrontFace != GL_CCW)
+ backface_sign = -1;
+ break;
+
+ default:
+ break;
+ }
+
+ vmesa->backface_sign = backface_sign;
+ vmesa->dirty |= S3V_UPLOAD_GEOMETRY;
+}
+
+
+static void s3vDDCullFace( GLcontext *ctx, GLenum mode )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ /* FLUSH_BATCH( vmesa ); */
+ vmesa->new_state |= S3V_NEW_CULL;
+}
+
+static void s3vDDFrontFace( GLcontext *ctx, GLenum mode )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ /* FLUSH_BATCH( vmesa ); */
+ vmesa->new_state |= S3V_NEW_CULL;
+}
+
+/* =============================================================
+ * Masks
+ */
+
+static void s3vUpdateMasks( GLcontext *ctx )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+
+ GLuint mask = s3vPackColor( vmesa->s3vScreen->cpp,
+ ctx->Color.ColorMask[RCOMP],
+ ctx->Color.ColorMask[GCOMP],
+ ctx->Color.ColorMask[BCOMP],
+ ctx->Color.ColorMask[ACOMP] );
+
+ if (vmesa->s3vScreen->cpp == 2) mask |= mask << 16;
+
+ /* FIXME: can we do something in virge? */
+}
+/*
+static void s3vDDColorMask( GLcontext *ctx, GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a)
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+
+ FLUSH_BATCH( vmesa );
+ vmesa->new_state |= S3V_NEW_MASKS;
+}
+*/
+/* =============================================================
+ * Rendering attributes
+ */
+
+/* =============================================================
+ * Miscellaneous
+ */
+
+static void s3vDDClearColor( GLcontext *ctx, const GLfloat color[4])
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+
+ DEBUG(("*** s3vDDClearColor\n"));
+
+ vmesa->ClearColor = s3vPackColor( 2, /* vmesa->s3vScreen->cpp, */
+ color[0], color[1], color[2], color[3] );
+
+#if 0
+ if (vmesa->s3vScreen->cpp == 2) vmesa->ClearColor |= vmesa->ClearColor<<16;
+#endif
+}
+
+static void s3vDDSetDrawBuffer( GLcontext *ctx, GLenum mode )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ int found = GL_TRUE;
+
+ DEBUG(("*** s3vDDSetDrawBuffer ***\n"));
+
+ /* FLUSH_BATCH( vmesa ); */
+
+ switch ( mode ) {
+ case GL_FRONT_LEFT:
+ vmesa->drawOffset = vmesa->s3vScreen->frontOffset;
+ break;
+ case GL_BACK_LEFT:
+ vmesa->drawOffset = vmesa->s3vScreen->backOffset;
+ /* vmesa->driScreen->fbHeight *
+ * vmesa->driScreen->fbWidth *
+ * vmesa->s3vScreen->cpp; */
+ break;
+ default:
+ found = GL_FALSE;
+ break;
+ }
+
+ DEBUG(("vmesa->drawOffset = 0x%x\n", vmesa->drawOffset));
+/* return GL_TRUE; */
+}
+
+/* =============================================================
+ * Window position and viewport transformation
+ */
+
+void s3vUpdateWindow( GLcontext *ctx )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+ GLfloat xoffset = (GLfloat)dPriv->x;
+ GLfloat yoffset =
+ vmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h;
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+
+ GLfloat sx = v[MAT_SX];
+ GLfloat tx = v[MAT_TX] + xoffset;
+ GLfloat sy = v[MAT_SY];
+ GLfloat ty = v[MAT_TY] + yoffset;
+ GLfloat sz = v[MAT_SZ] * vmesa->depth_scale;
+ GLfloat tz = v[MAT_TZ] * vmesa->depth_scale;
+
+ vmesa->dirty |= S3V_UPLOAD_VIEWPORT;
+
+ vmesa->ViewportScaleX = sx;
+ vmesa->ViewportScaleY = sy;
+ vmesa->ViewportScaleZ = sz;
+ vmesa->ViewportOffsetX = tx;
+ vmesa->ViewportOffsetY = ty;
+ vmesa->ViewportOffsetZ = tz;
+}
+
+
+/*
+static void s3vDDViewport( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ s3vUpdateWindow( ctx );
+}
+
+static void s3vDDDepthRange( GLcontext *ctx, GLclampd nearval,
+ GLclampd farval )
+{
+ s3vUpdateWindow( ctx );
+}
+*/
+void s3vUpdateViewportOffset( GLcontext *ctx )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+ GLfloat xoffset = (GLfloat)dPriv->x;
+ GLfloat yoffset =
+ vmesa->driScreen->fbHeight - (GLfloat)dPriv->y - dPriv->h;
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+
+ GLfloat tx = v[MAT_TX] + xoffset;
+ GLfloat ty = v[MAT_TY] + yoffset;
+
+ DEBUG(("*** s3vUpdateViewportOffset ***\n"));
+
+ if ( vmesa->ViewportOffsetX != tx ||
+ vmesa->ViewportOffsetY != ty )
+ {
+ vmesa->ViewportOffsetX = tx;
+ vmesa->ViewportOffsetY = ty;
+
+ vmesa->new_state |= S3V_NEW_WINDOW;
+ }
+
+/* vmesa->new_state |= S3V_NEW_CLIP; */
+}
+
+/* =============================================================
+ * State enable/disable
+ */
+
+static void s3vDDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+
+ switch ( cap ) {
+ case GL_ALPHA_TEST:
+ case GL_BLEND:
+ vmesa->new_state |= S3V_NEW_ALPHA;
+ DEBUG(("s3vDDEnable: GL_BLEND\n"));
+ break;
+
+ case GL_CULL_FACE:
+ vmesa->new_state |= S3V_NEW_CULL;
+ DEBUG(("s3vDDEnable: GL_CULL_FACE\n"));
+ break;
+
+ case GL_DEPTH_TEST:
+ vmesa->new_state |= S3V_NEW_DEPTH;
+ DEBUG(("s3vDDEnable: GL_DEPTH\n"));
+ break;
+#if 0
+ case GL_FOG:
+ vmesa->new_state |= S3V_NEW_FOG;
+ break;
+#endif
+
+ case GL_SCISSOR_TEST:
+ vmesa->new_state |= S3V_NEW_CLIP;
+ break;
+
+ case GL_TEXTURE_2D:
+ DEBUG(("*** GL_TEXTURE_2D: %i\n", state));
+ vmesa->_3d_mode = state;
+ vmesa->restore_primitive = -1;
+ break;
+
+ default:
+ return;
+ }
+}
+
+/* =============================================================
+ * State initialization, management
+ */
+
+
+/*
+ * Load the current context's state into the hardware.
+ *
+ * NOTE: Be VERY careful about ensuring the context state is marked for
+ * upload, the only place it shouldn't be uploaded is when the setup
+ * state has changed in ReducedPrimitiveChange as this comes right after
+ * a state update.
+ *
+ * Blits of any type should always upload the context and masks after
+ * they are done.
+ */
+void s3vEmitHwState( s3vContextPtr vmesa )
+{
+ if (!vmesa->driDrawable) return;
+ if (!vmesa->dirty) return;
+
+ DEBUG(("**********************\n"));
+ DEBUG(("*** s3vEmitHwState ***\n"));
+ DEBUG(("**********************\n"));
+
+ if (vmesa->dirty & S3V_UPLOAD_VIEWPORT) {
+ vmesa->dirty &= ~S3V_UPLOAD_VIEWPORT;
+ DEBUG(("S3V_UPLOAD_VIEWPORT\n"));
+ }
+
+ if ( (vmesa->dirty & S3V_UPLOAD_POINTMODE) ||
+ (vmesa->dirty & S3V_UPLOAD_LINEMODE) ||
+ (vmesa->dirty & S3V_UPLOAD_TRIMODE) ) {
+
+ }
+
+ if (vmesa->dirty & S3V_UPLOAD_POINTMODE) {
+ vmesa->dirty &= ~S3V_UPLOAD_POINTMODE;
+ }
+
+ if (vmesa->dirty & S3V_UPLOAD_LINEMODE) {
+ vmesa->dirty &= ~S3V_UPLOAD_LINEMODE;
+ }
+
+ if (vmesa->dirty & S3V_UPLOAD_TRIMODE) {
+ vmesa->dirty &= ~S3V_UPLOAD_TRIMODE;
+ }
+
+ if (vmesa->dirty & S3V_UPLOAD_FOG) {
+ GLchan c[3], col;
+ UNCLAMPED_FLOAT_TO_RGB_CHAN( c, vmesa->glCtx->Fog.Color );
+ DEBUG(("uploading ** FOG **\n"));
+ col = s3vPackColor(2, c[0], c[1], c[2], 0);
+ vmesa->dirty &= ~S3V_UPLOAD_FOG;
+ }
+
+ if (vmesa->dirty & S3V_UPLOAD_DITHER) {
+ vmesa->dirty &= ~S3V_UPLOAD_DITHER;
+ }
+
+ if (vmesa->dirty & S3V_UPLOAD_LOGICOP) {
+ vmesa->dirty &= ~S3V_UPLOAD_LOGICOP;
+ }
+
+ if (vmesa->dirty & S3V_UPLOAD_CLIP) {
+ vmesa->dirty &= ~S3V_UPLOAD_CLIP;
+ DEBUG(("S3V_UPLOAD_CLIP\n"));
+ DEBUG(("vmesa->ScissorLR: %i\n", vmesa->ScissorLR));
+ DEBUG(("vmesa->ScissorTB: %i\n", vmesa->ScissorTB));
+ }
+
+ if (vmesa->dirty & S3V_UPLOAD_MASKS) {
+ vmesa->dirty &= ~S3V_UPLOAD_MASKS;
+ DEBUG(("S3V_UPLOAD_BLEND\n"));
+ }
+
+ if (vmesa->dirty & S3V_UPLOAD_ALPHA) {
+ vmesa->dirty &= ~S3V_UPLOAD_ALPHA;
+ DEBUG(("S3V_UPLOAD_ALPHA\n"));
+ }
+
+ if (vmesa->dirty & S3V_UPLOAD_SHADE) {
+ vmesa->dirty &= ~S3V_UPLOAD_SHADE;
+ }
+
+ if (vmesa->dirty & S3V_UPLOAD_POLYGON) {
+ vmesa->dirty &= ~S3V_UPLOAD_POLYGON;
+ }
+
+ if (vmesa->dirty & S3V_UPLOAD_DEPTH) {
+ vmesa->dirty &= ~S3V_UPLOAD_DEPTH;
+ DEBUG(("S3V_UPLOAD_DEPTH: DepthMode = 0x%x08\n", vmesa->DepthMode));
+ }
+
+ if (vmesa->dirty & S3V_UPLOAD_GEOMETRY) {
+ vmesa->dirty &= ~S3V_UPLOAD_GEOMETRY;
+ }
+
+ if (vmesa->dirty & S3V_UPLOAD_TRANSFORM) {
+ vmesa->dirty &= ~S3V_UPLOAD_TRANSFORM;
+ }
+
+ if (vmesa->dirty & S3V_UPLOAD_TEX0) {
+ s3vTextureObjectPtr curTex = vmesa->CurrentTexObj[0];
+ vmesa->dirty &= ~S3V_UPLOAD_TEX0;
+ DEBUG(("S3V_UPLOAD_TEX0\n"));
+ if (curTex) {
+ DEBUG(("S3V_UPLOAD_TEX0: curTex\n"));
+ } else {
+ DEBUG(("S3V_UPLOAD_TEX0: !curTex\n"));
+ }
+ }
+}
+
+void s3vDDUpdateHWState( GLcontext *ctx )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+
+ int new_state = vmesa->new_state;
+
+ /* s3vUpdateClipping( ctx ); */
+
+ if ( new_state )
+ {
+
+ vmesa->new_state = 0;
+
+ /* Update the various parts of the context's state.
+ */
+ if ( new_state & S3V_NEW_ALPHA )
+ s3vUpdateAlphaMode( ctx );
+
+ if ( new_state & S3V_NEW_DEPTH )
+ s3vUpdateZMode( ctx );
+
+ if ( new_state & S3V_NEW_FOG )
+ s3vUpdateFogAttrib( ctx );
+
+ if ( new_state & S3V_NEW_CLIP )
+ {
+ DEBUG(("---> going to s3vUpdateClipping\n"));
+ s3vUpdateClipping( ctx );
+ }
+
+ if ( new_state & S3V_NEW_POLYGON )
+ s3vUpdatePolygon( ctx );
+
+ if ( new_state & S3V_NEW_CULL )
+ s3vUpdateCull( ctx );
+
+ if ( new_state & S3V_NEW_MASKS )
+ s3vUpdateMasks( ctx );
+
+ if ( new_state & S3V_NEW_WINDOW )
+ s3vUpdateWindow( ctx );
+/*
+ if ( new_state & S3_NEW_TEXTURE )
+ s3vUpdateTextureState( ctx );
+*/
+ CMDCHANGE();
+ }
+
+ /* HACK ! */
+ s3vEmitHwState( vmesa );
+}
+
+
+static void s3vDDUpdateState( GLcontext *ctx, GLuint new_state )
+{
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ S3V_CONTEXT(ctx)->new_gl_state |= new_state;
+}
+
+
+/* Initialize the context's hardware state.
+ */
+void s3vInitState( s3vContextPtr vmesa )
+{
+ vmesa->new_state = 0;
+}
+
+/* Initialize the driver's state functions.
+ */
+void s3vInitStateFuncs( GLcontext *ctx )
+{
+ ctx->Driver.UpdateState = s3vDDUpdateState;
+
+ ctx->Driver.Clear = s3vDDClear;
+ ctx->Driver.ClearIndex = NULL;
+ ctx->Driver.ClearColor = s3vDDClearColor;
+ ctx->Driver.DrawBuffer = s3vDDSetDrawBuffer;
+ ctx->Driver.ReadBuffer = NULL; /* XXX */
+
+ ctx->Driver.IndexMask = NULL;
+ ctx->Driver.ColorMask = NULL; /* s3vDDColorMask; */ /* FIXME */
+
+ ctx->Driver.AlphaFunc = s3vDDAlphaFunc; /* FIXME */
+#if 0
+ ctx->Driver.BlendEquation = NULL; /* s3vDDBlendEquation; */
+ ctx->Driver.BlendFunc = s3vDDBlendFunc; /* FIXME */
+#endif
+ ctx->Driver.BlendFuncSeparate = NULL; /* s3vDDBlendFuncSeparate; */
+ ctx->Driver.ClearDepth = s3vDDClearDepth;
+ ctx->Driver.CullFace = s3vDDCullFace;
+ ctx->Driver.FrontFace = s3vDDFrontFace;
+ ctx->Driver.DepthFunc = s3vDDDepthFunc; /* FIXME */
+ ctx->Driver.DepthMask = s3vDDDepthMask; /* FIXME */
+ ctx->Driver.DepthRange = NULL; /* s3vDDDepthRange; */
+ ctx->Driver.Enable = s3vDDEnable; /* FIXME */
+ ctx->Driver.Finish = s3vDDFinish;
+ ctx->Driver.Flush = s3vDDFlush;
+#if 1
+ ctx->Driver.Fogfv = NULL; /* s3vDDFogfv; */
+#endif
+ ctx->Driver.Hint = NULL;
+ ctx->Driver.LineWidth = NULL; /* s3vDDLineWidth; */
+ ctx->Driver.LineStipple = NULL; /* s3vDDLineStipple; */
+#if ENABLELIGHTING
+ ctx->Driver.Lightfv = NULL; /* s3vDDLightfv; */
+
+ ctx->Driver.LightModelfv = NULL; /* s3vDDLightModelfv; */
+#endif
+ ctx->Driver.LogicOpcode = NULL; /* s3vDDLogicalOpcode; */
+ ctx->Driver.PointSize = NULL; /* s3vDDPointSize; */
+ ctx->Driver.PolygonMode = NULL; /* s3vDDPolygonMode; */
+ ctx->Driver.PolygonStipple = NULL; /* s3vDDPolygonStipple; */
+ ctx->Driver.Scissor = s3vDDScissor; /* ScissorLR / ScissorTB */
+ ctx->Driver.ShadeModel = NULL; /* s3vDDShadeModel; */
+ ctx->Driver.ClearStencil = NULL;
+ ctx->Driver.StencilFunc = NULL;
+ ctx->Driver.StencilMask = NULL;
+ ctx->Driver.StencilOp = NULL;
+ ctx->Driver.Viewport = NULL; /* s3vDDViewport; */
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tex.c
new file mode 100644
index 000000000..5bee051b0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tex.c
@@ -0,0 +1,554 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "texstore.h"
+#include "texformat.h"
+#include "teximage.h"
+#include "swrast/swrast.h"
+
+#include "mm.h"
+#include "s3v_context.h"
+#include "s3v_tex.h"
+
+
+extern void s3vSwapOutTexObj(s3vContextPtr vmesa, s3vTextureObjectPtr t);
+extern void s3vDestroyTexObj(s3vContextPtr vmesa, s3vTextureObjectPtr t);
+
+/*
+static GLuint s3vComputeLodBias(GLfloat bias)
+{
+#if TEX_DEBUG_ON
+ DEBUG_TEX(("*** s3vComputeLodBias ***\n"));
+#endif
+ return bias;
+}
+*/
+
+static void s3vSetTexWrapping(s3vContextPtr vmesa,
+ s3vTextureObjectPtr t,
+ GLenum wraps, GLenum wrapt)
+{
+ GLuint t0 = t->TextureCMD;
+ GLuint cmd = vmesa->CMD;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vSetTexWrapping: #%i ***\n", ++times));
+#endif
+
+
+ t0 &= ~TEX_WRAP_MASK;
+ cmd &= ~TEX_WRAP_MASK;
+
+ if ((wraps != GL_CLAMP) || (wrapt != GL_CLAMP)) {
+ DEBUG(("TEX_WRAP_ON\n"));
+ t0 |= TEX_WRAP_ON;
+ cmd |= TEX_WRAP_ON;
+ }
+
+ cmd |= TEX_WRAP_ON; /* FIXME: broken if off */
+ t->TextureCMD = t0;
+ vmesa->CMD = cmd;
+}
+
+
+static void s3vSetTexFilter(s3vContextPtr vmesa,
+ s3vTextureObjectPtr t,
+ GLenum minf, GLenum magf)
+{
+ GLuint t0 = t->TextureCMD;
+ GLuint cmd = vmesa->CMD;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vSetTexFilter: #%i ***\n", ++times));
+#endif
+
+ t0 &= ~TEX_FILTER_MASK;
+ cmd &= ~TEX_FILTER_MASK;
+
+ switch (minf) {
+ case GL_NEAREST:
+ DEBUG(("GL_NEAREST\n"));
+ t0 |= NEAREST;
+ cmd |= NEAREST;
+ break;
+ case GL_LINEAR:
+ DEBUG(("GL_LINEAR\n"));
+ t0 |= LINEAR;
+ cmd |= LINEAR;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ DEBUG(("GL_MIPMAP_NEAREST\n"));
+ t0 |= MIP_NEAREST;
+ cmd |= MIP_NEAREST;
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ DEBUG(("GL_LINEAR_MIPMAP_NEAREST\n"));
+ t0 |= LINEAR_MIP_NEAREST;
+ cmd |= LINEAR_MIP_NEAREST;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ DEBUG(("GL_NEAREST_MIPMAP_LINEAR\n"));
+ t0 |= MIP_LINEAR;
+ cmd |= MIP_LINEAR;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ DEBUG(("GL_LINEAR_MIPMAP_LINEAR\n"));
+ t0 |= LINEAR_MIP_LINEAR;
+ cmd |= LINEAR_MIP_LINEAR;
+ break;
+ default:
+ break;
+ }
+ /* FIXME: bilinear? */
+
+#if 0
+ switch (magf) {
+ case GL_NEAREST:
+ break;
+ case GL_LINEAR:
+ break;
+ default:
+ break;
+ }
+#endif
+
+ t->TextureCMD = t0;
+
+ DEBUG(("CMD was = 0x%x\n", vmesa->CMD));
+ DEBUG(("CMD is = 0x%x\n", cmd));
+
+ vmesa->CMD = cmd;
+ /* CMDCHANGE(); */
+}
+
+
+static void s3vSetTexBorderColor(s3vContextPtr vmesa,
+ s3vTextureObjectPtr t,
+ GLubyte color[4])
+{
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vSetTexBorderColor: #%i ***\n", ++times));
+#endif
+
+ /*FIXME: it should depend on tex col format */
+ /* switch(t0 ... t->TextureColorMode) */
+
+ /* case TEX_COL_ARGB1555: */
+ t->TextureBorderColor =
+ S3VIRGEPACKCOLOR555(color[0], color[1], color[2], color[3]);
+
+ DEBUG(("TextureBorderColor = 0x%x\n", t->TextureBorderColor));
+
+ vmesa->TextureBorderColor = t->TextureBorderColor;
+}
+
+static void s3vTexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat *params )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ s3vTextureObjectPtr t = (s3vTextureObjectPtr) tObj->DriverData;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vTexParameter: #%i ***\n", ++times));
+#endif
+
+ if (!t) return;
+
+ /* Can't do the update now as we don't know whether to flush
+ * vertices or not. Setting vmesa->new_state means that
+ * s3vUpdateTextureState() will be called before any triangles are
+ * rendered. If a statechange has occurred, it will be detected at
+ * that point, and buffered vertices flushed.
+ */
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ s3vSetTexFilter( vmesa, t, tObj->MinFilter, tObj->MagFilter );
+ break;
+
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ s3vSetTexWrapping( vmesa, t, tObj->WrapS, tObj->WrapT );
+ break;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ s3vSetTexBorderColor( vmesa, t, tObj->_BorderChan );
+ break;
+
+ case GL_TEXTURE_BASE_LEVEL:
+ case GL_TEXTURE_MAX_LEVEL:
+ case GL_TEXTURE_MIN_LOD:
+ case GL_TEXTURE_MAX_LOD:
+ /* This isn't the most efficient solution but there doesn't appear to
+ * be a nice alternative for Virge. Since there's no LOD clamping,
+ * we just have to rely on loading the right subset of mipmap levels
+ * to simulate a clamped LOD.
+ */
+ s3vSwapOutTexObj( vmesa, t );
+ break;
+
+ default:
+ return;
+ }
+
+ if (t == vmesa->CurrentTexObj[0])
+ vmesa->dirty |= S3V_UPLOAD_TEX0;
+
+#if 0
+ if (t == vmesa->CurrentTexObj[1]) {
+ vmesa->dirty |= S3V_UPLOAD_TEX1;
+ }
+#endif
+}
+
+
+static void s3vTexEnv( GLcontext *ctx, GLenum target,
+ GLenum pname, const GLfloat *param )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT( ctx );
+ GLuint unit = ctx->Texture.CurrentUnit;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vTexEnv: #%i ***\n", ++times));
+#endif
+
+ /* Only one env color. Need a fallback if env colors are different
+ * and texture setup references env color in both units.
+ */
+ switch (pname) {
+ case GL_TEXTURE_ENV_COLOR: {
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ GLfloat *fc = texUnit->EnvColor;
+ GLuint r, g, b, a, col;
+ CLAMPED_FLOAT_TO_UBYTE(r, fc[0]);
+ CLAMPED_FLOAT_TO_UBYTE(g, fc[1]);
+ CLAMPED_FLOAT_TO_UBYTE(b, fc[2]);
+ CLAMPED_FLOAT_TO_UBYTE(a, fc[3]);
+
+ col = ((a << 24) |
+ (r << 16) |
+ (g << 8) |
+ (b << 0));
+
+ break;
+ }
+ case GL_TEXTURE_ENV_MODE:
+ vmesa->TexEnvImageFmt[unit] = 0; /* force recalc of env state */
+ break;
+ case GL_TEXTURE_LOD_BIAS_EXT: {
+/*
+ struct gl_texture_object *tObj =
+ ctx->Texture.Unit[unit]._Current;
+
+ s3vTextureObjectPtr t = (s3vTextureObjectPtr) tObj->DriverData;
+*/
+ break;
+ }
+ default:
+ break;
+ }
+}
+
+static void s3vTexImage1D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *pack,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT( ctx );
+ s3vTextureObjectPtr t = (s3vTextureObjectPtr) texObj->DriverData;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vTexImage1D: #%i ***\n", ++times));
+#endif
+
+#if 1
+ if (t) {
+#if _TEXFLUSH
+ DMAFLUSH();
+#endif
+ s3vSwapOutTexObj( vmesa, t );
+/*
+ s3vDestroyTexObj( vmesa, t );
+ texObj->DriverData = 0;
+*/
+ }
+#endif
+ _mesa_store_teximage1d( ctx, target, level, internalFormat,
+ width, border, format, type,
+ pixels, pack, texObj, texImage );
+}
+
+static void s3vTexSubImage1D( GLcontext *ctx,
+ GLenum target,
+ GLint level,
+ GLint xoffset,
+ GLsizei width,
+ GLenum format, GLenum type,
+ const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *pack,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT( ctx );
+ s3vTextureObjectPtr t = (s3vTextureObjectPtr) texObj->DriverData;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vTexSubImage1D: #%i ***\n", ++times));
+#endif
+
+#if 1
+ if (t) {
+#if _TEXFLUSH
+ DMAFLUSH();
+#endif
+ s3vSwapOutTexObj( vmesa, t );
+/*
+ s3vDestroyTexObj( vmesa, t );
+ texObj->DriverData = 0;
+*/
+ }
+#endif
+ _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
+ format, type, pixels, pack, texObj,
+ texImage);
+}
+
+static void s3vTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT( ctx );
+ s3vTextureObjectPtr t = (s3vTextureObjectPtr) texObj->DriverData;
+
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vTexImage2D: #%i ***\n", ++times));
+#endif
+
+#if 1
+ if (t) {
+#if _TEXFLUSH
+ DMAFLUSH();
+#endif
+ s3vSwapOutTexObj( vmesa, t );
+/*
+ s3vDestroyTexObj( vmesa, t );
+ texObj->DriverData = 0;
+*/
+ }
+#endif
+ _mesa_store_teximage2d( ctx, target, level, internalFormat,
+ width, height, border, format, type,
+ pixels, packing, texObj, texImage );
+}
+
+static void s3vTexSubImage2D( 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 )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT( ctx );
+ s3vTextureObjectPtr t = (s3vTextureObjectPtr) texObj->DriverData;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vTexSubImage2D: #%i ***\n", ++times));
+#endif
+
+#if 1
+ if (t) {
+#if _TEXFLUSH
+ DMAFLUSH();
+#endif
+ s3vSwapOutTexObj( vmesa, t );
+/*
+ s3vDestroyTexObj( vmesa, t );
+ texObj->DriverData = 0;
+*/
+ }
+#endif
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
+}
+
+
+static void s3vBindTexture( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT( ctx );
+ s3vTextureObjectPtr t = (s3vTextureObjectPtr) tObj->DriverData;
+ GLuint cmd = vmesa->CMD;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vBindTexture: #%i ***\n", ++times));
+#endif
+
+ if (!t) {
+/*
+ GLfloat bias = ctx->Texture.Unit[ctx->Texture.CurrentUnit].LodBias;
+*/
+ t = CALLOC_STRUCT(s3v_texture_object_t);
+
+ /* Initialize non-image-dependent parts of the state:
+ */
+ t->globj = tObj;
+#if 0
+ if (target == GL_TEXTURE_2D) {
+ } else
+ if (target == GL_TEXTURE_1D) {
+ }
+
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
+ t->TextureFormat = (TF_LittleEndian |
+#else
+ t->TextureFormat = (TF_BigEndian |
+#endif
+#endif
+ t->dirty_images = ~0;
+
+ tObj->DriverData = t;
+ make_empty_list( t );
+#if 0
+ s3vSetTexWrapping( vmesa, t, tObj->WrapS, tObj->WrapT );
+ s3vSetTexFilter( vmesa, t, tObj->MinFilter, tObj->MagFilter );
+ s3vSetTexBorderColor( vmesa, t, tObj->BorderColor );
+#endif
+ }
+
+ cmd = vmesa->CMD & ~MIP_MASK;
+ vmesa->dirty |= S3V_UPLOAD_TEX0;
+ vmesa->TexOffset = t->TextureBaseAddr[tObj->BaseLevel];
+ vmesa->TexStride = t->Pitch;
+ cmd |= MIPMAP_LEVEL(t->WidthLog2);
+ vmesa->CMD = cmd;
+ vmesa->restore_primitive = -1;
+#if 0
+ printf("t->TextureBaseAddr[0] = 0x%x\n", t->TextureBaseAddr[0]);
+ printf("t->TextureBaseAddr[1] = 0x%x\n", t->TextureBaseAddr[1]);
+ printf("t->TextureBaseAddr[2] = 0x%x\n", t->TextureBaseAddr[2]);
+#endif
+}
+
+
+static void s3vDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
+{
+ s3vTextureObjectPtr t = (s3vTextureObjectPtr)tObj->DriverData;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vDeleteTexture: #%i ***\n", ++times));
+#endif
+
+ if (t) {
+ s3vContextPtr vmesa = S3V_CONTEXT( ctx );
+
+#if _TEXFLUSH
+ if (vmesa) {
+ DMAFLUSH();
+ }
+#endif
+
+ s3vDestroyTexObj( vmesa, t );
+ tObj->DriverData = 0;
+
+ }
+}
+
+static GLboolean s3vIsTextureResident( GLcontext *ctx,
+ struct gl_texture_object *tObj )
+{
+ s3vTextureObjectPtr t = (s3vTextureObjectPtr)tObj->DriverData;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vIsTextureResident: #%i ***\n", ++times));
+#endif
+
+ return (t && t->MemBlock);
+}
+
+static void s3vInitTextureObjects( GLcontext *ctx )
+{
+ /* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */
+ struct gl_texture_object *texObj;
+ GLuint tmp = ctx->Texture.CurrentUnit;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vInitTextureObjects: #%i ***\n", ++times));
+#endif
+
+#if 1
+ ctx->Texture.CurrentUnit = 0;
+
+ texObj = ctx->Texture.Unit[0].Current1D;
+ s3vBindTexture( ctx, GL_TEXTURE_1D, texObj );
+
+ texObj = ctx->Texture.Unit[0].Current2D;
+ s3vBindTexture( ctx, GL_TEXTURE_2D, texObj );
+#endif
+
+#if 0
+ ctx->Texture.CurrentUnit = 1;
+
+ texObj = ctx->Texture.Unit[1].Current1D;
+ s3vBindTexture( ctx, GL_TEXTURE_1D, texObj );
+
+ texObj = ctx->Texture.Unit[1].Current2D;
+ s3vBindTexture( ctx, GL_TEXTURE_2D, texObj );
+#endif
+
+ ctx->Texture.CurrentUnit = tmp;
+}
+
+
+void s3vInitTextureFuncs( GLcontext *ctx )
+{
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vInitTextureFuncs: #%i ***\n", ++times));
+#endif
+
+ ctx->Driver.TexEnv = s3vTexEnv;
+ ctx->Driver.ChooseTextureFormat = _mesa_choose_tex_format;
+ ctx->Driver.TexImage1D = _mesa_store_teximage1d;
+ ctx->Driver.TexImage2D = s3vTexImage2D;
+ ctx->Driver.TexImage3D = _mesa_store_teximage3d;
+ ctx->Driver.TexSubImage1D = _mesa_store_texsubimage1d;
+ ctx->Driver.TexSubImage2D = s3vTexSubImage2D;
+ ctx->Driver.TexSubImage3D = _mesa_store_texsubimage3d;
+ ctx->Driver.CopyTexImage1D = _swrast_copy_teximage1d;
+ ctx->Driver.CopyTexImage2D = _swrast_copy_teximage2d;
+ ctx->Driver.CopyTexSubImage1D = _swrast_copy_texsubimage1d;
+ ctx->Driver.CopyTexSubImage2D = _swrast_copy_texsubimage2d;
+ ctx->Driver.CopyTexSubImage3D = _swrast_copy_texsubimage3d;
+ ctx->Driver.BindTexture = s3vBindTexture;
+ ctx->Driver.DeleteTexture = s3vDeleteTexture;
+ ctx->Driver.TexParameter = s3vTexParameter;
+ ctx->Driver.UpdateTexturePalette = 0;
+ ctx->Driver.IsTextureResident = s3vIsTextureResident;
+ ctx->Driver.TestProxyTexImage = _mesa_test_proxy_teximage;
+
+ s3vInitTextureObjects( ctx );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tex.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tex.h
new file mode 100644
index 000000000..a823fe245
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tex.h
@@ -0,0 +1,28 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#ifndef _S3V_TEX_H
+#define _S3V_TEX_H
+
+#define TEX_DEBUG_ON 0
+
+extern void s3vUpdateTexLRU( s3vContextPtr vmesa, s3vTextureObjectPtr t );
+
+#if TEX_DEBUG_ON
+#define DEBUG_TEX(str) printf str
+#else
+#define DEBUG_TEX(str) /* str */
+#endif
+
+#define _TEXFLUSH 1 /* flush before uploading */
+#define _TEXLOCK 1 /* lock before writing new texures to card mem */
+ /* if you turn it on you will gain stability and image
+ quality, but you will loose performance (~10%) */
+#define _TEXFALLBACK 0 /* fallback to software for -big- textures (slow) */
+ /* turning this off, you will lose some tex (e.g. mountains
+ on tuxracer) but you will increase average playability */
+
+#define _TEXALIGN 0x00000007
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_texmem.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_texmem.c
new file mode 100644
index 000000000..0ce3ff5fc
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_texmem.c
@@ -0,0 +1,582 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "enums.h"
+
+#include "mm.h"
+#include "s3v_context.h"
+#include "s3v_lock.h"
+#include "s3v_tex.h"
+
+void s3vSwapOutTexObj(s3vContextPtr vmesa, s3vTextureObjectPtr t);
+void s3vUpdateTexLRU( s3vContextPtr vmesa, s3vTextureObjectPtr t );
+
+
+void s3vDestroyTexObj(s3vContextPtr vmesa, s3vTextureObjectPtr t)
+{
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vDestroyTexObj: #%i ***\n", ++times));
+#endif
+
+ if (!t) return;
+
+/* FIXME: useful? */
+#if _TEXFLUSH
+ if (vmesa)
+ DMAFLUSH();
+#endif
+
+ /* This is sad - need to sync *in case* we upload a texture
+ * to this newly free memory...
+ */
+ if (t->MemBlock) {
+ mmFreeMem(t->MemBlock);
+ t->MemBlock = 0;
+
+ if (vmesa && t->age > vmesa->dirtyAge)
+ vmesa->dirtyAge = t->age;
+ }
+
+ if (t->globj)
+ t->globj->DriverData = NULL;
+
+ if (vmesa) {
+ if (vmesa->CurrentTexObj[0] == t) {
+ vmesa->CurrentTexObj[0] = 0;
+ vmesa->dirty &= ~S3V_UPLOAD_TEX0;
+ }
+
+#if 0
+ if (vmesa->CurrentTexObj[1] == t) {
+ vmesa->CurrentTexObj[1] = 0;
+ vmesa->dirty &= ~S3V_UPLOAD_TEX1;
+ }
+#endif
+ }
+
+ remove_from_list(t);
+ FREE(t);
+}
+
+
+void s3vSwapOutTexObj(s3vContextPtr vmesa, s3vTextureObjectPtr t)
+{
+/* int i; */
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vSwapOutTexObj: #%i ***\n", ++times));
+#endif
+
+ if (t->MemBlock) {
+
+ mmFreeMem(t->MemBlock);
+ t->MemBlock = 0;
+
+ if (t->age > vmesa->dirtyAge)
+ vmesa->dirtyAge = t->age;
+
+ t->dirty_images = ~0;
+ move_to_tail(&(vmesa->SwappedOut), t);
+ }
+}
+
+
+/* Upload an image from mesa's internal copy.
+ */
+
+static void s3vUploadTexLevel( s3vContextPtr vmesa, s3vTextureObjectPtr t,
+ int level )
+{
+ __DRIscreenPrivate *sPriv = vmesa->driScreen;
+ const struct gl_texture_image *image = t->image[level].image;
+ int i,j;
+ int l2d;
+ /* int offset = 0; */
+ int words;
+ GLuint* dest;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+#endif
+ if ( !image ) return;
+ if (image->Data == 0) return;
+
+ DEBUG_TEX(("*** s3vUploadTexLevel: #%i ***\n", ++times));
+ DEBUG_TEX(("level = %i\n", level));
+
+ l2d = 5; /* 32bits per texel == 1<<5 */
+/*
+ if (level == 0)
+ ;
+*/
+ DEBUG_TEX(("t->image[%i].offset = 0x%x\n",
+ level, t->image[level].offset));
+
+ t->TextureBaseAddr[level] = (GLuint)(t->BufAddr + t->image[level].offset
+ + _TEXALIGN) & (GLuint)(~_TEXALIGN);
+ dest = (GLuint*)(sPriv->pFB + t->TextureBaseAddr[level]);
+
+ DEBUG_TEX(("sPriv->pFB = 0x%x\n", sPriv->pFB));
+ DEBUG_TEX(("dest = 0x%x\n", dest));
+ DEBUG_TEX(("dest - sPriv->pFB = 0x%x\n", ((int)dest - (int)sPriv->pFB)));
+
+ /* NOTE: we implicitly suppose t->texelBytes == 2 */
+
+ words = (image->Width * image->Height) >> 1;
+
+ DEBUG_TEX(("\n\n"));
+
+ switch (t->image[level].internalFormat) {
+ case GL_RGB:
+ case 3:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ DEBUG_TEX(("GL_RGB:\n"));
+/*
+ if (level == 0)
+ ;
+*/
+ /* The UGLY way, and SLOW : use DMA FIXME ! */
+
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+ /* data = PACK_COLOR_565(src[0],src[1],src[2]); */
+ data = S3VIRGEPACKCOLOR555(src[0],src[1],src[2],255)
+ |(S3VIRGEPACKCOLOR555(src[3],src[4],src[5],255)<<16);
+
+ *dest++ = data;
+ /* src += 3; */
+ src +=6;
+ }
+ }
+ break;
+
+ case GL_RGBA:
+ case 4:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ DEBUG_TEX(("GL_RGBA:\n"));
+/*
+ if (level == 0)
+ ;
+*/
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+
+ /* data = PACK_COLOR_8888(src[0],src[1],src[2],src[3]); */
+ data = S3VIRGEPACKCOLOR4444(src[0], src[1],src[2], src[3])
+ | (S3VIRGEPACKCOLOR4444(src[4], src[5], src[6], src[7]) << 16);
+
+ *dest++ = data;
+ /* src += 4; */
+ src += 8;
+ }
+ }
+ break;
+
+ case GL_LUMINANCE:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ DEBUG_TEX(("GL_LUMINANCE:\n"));
+/*
+ if (level == 0)
+ ;
+*/
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+
+ /* data = PACK_COLOR_888(src[0],src[0],src[0]); */
+ data = S3VIRGEPACKCOLOR4444(src[0],src[0],src[0],src[0])
+ | (S3VIRGEPACKCOLOR4444(src[1],src[1],src[1],src[1]) << 16);
+
+ *dest++ = data;
+ /* src ++; */
+ src +=2;
+ }
+ }
+ break;
+
+ case GL_INTENSITY:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ DEBUG_TEX(("GL_INTENSITY:\n"));
+/*
+ if (level == 0)
+ ;
+*/
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+
+ /* data = PACK_COLOR_8888(src[0],src[0],src[0],src[0]); */
+ data = S3VIRGEPACKCOLOR4444(src[0],src[0],src[0],src[0])
+ | (S3VIRGEPACKCOLOR4444(src[1],src[1],src[1],src[1]) << 16);
+
+ *dest++ = data;
+ /* src ++; */
+ src += 2;
+ }
+ }
+ break;
+
+ case GL_LUMINANCE_ALPHA:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ DEBUG_TEX(("GL_LUMINANCE_ALPHA:\n"));
+/*
+ if (level == 0)
+ ;
+*/
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+
+ /* data = PACK_COLOR_8888(src[0],src[0],src[0],src[1]); */
+ data = S3VIRGEPACKCOLOR4444(src[0],src[0],src[0],src[1])
+ | (S3VIRGEPACKCOLOR4444(src[2],src[2],src[2],src[3]) << 16);
+
+ *dest++ = data;
+ /* src += 2; */
+ src += 4;
+ }
+ }
+ break;
+
+ case GL_ALPHA:
+ {
+ GLubyte *src = (GLubyte *)image->Data;
+
+ DEBUG_TEX(("GL_ALPHA:\n"));
+/*
+ if (level == 0)
+ ;
+*/
+ for (i = 0; i < words; i++) {
+ unsigned int data;
+
+ /* data = PACK_COLOR_8888(255,255,255,src[0]); */
+ data = S3VIRGEPACKCOLOR4444(255,255,255,src[0])
+ | (S3VIRGEPACKCOLOR4444(255,255,255,src[1]) << 16);
+
+ *dest++ = data;
+ /* src += 1; */
+ src += 2;
+ }
+ }
+ break;
+
+ /* TODO: Translate color indices *now*:
+ */
+ case GL_COLOR_INDEX:
+ {
+
+ GLubyte *dst = (GLubyte *)(t->BufAddr + t->image[level].offset);
+ GLubyte *src = (GLubyte *)image->Data;
+
+ DEBUG_TEX(("GL_COLOR_INDEX:\n"));
+
+ for (j = 0 ; j < image->Height ; j++, dst += t->Pitch) {
+ for (i = 0 ; i < image->Width ; i++) {
+ dst[i] = src[0];
+ src += 1;
+ }
+ }
+ }
+ break;
+
+ default:
+ fprintf(stderr, "Not supported texture format %s\n",
+ _mesa_lookup_enum_by_nr(image->Format));
+ }
+
+ DEBUG_TEX(("words = %i\n\n", words));
+}
+
+void s3vPrintLocalLRU( s3vContextPtr vmesa )
+{
+ s3vTextureObjectPtr t;
+ int sz = 1 << (vmesa->s3vScreen->logTextureGranularity);
+
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vPrintLocalLRU: #%i ***\n", ++times));
+#endif
+
+ foreach( t, &vmesa->TexObjList ) {
+ if (!t->globj)
+ fprintf(stderr, "Placeholder %d at %x sz %x\n",
+ t->MemBlock->ofs / sz,
+ t->MemBlock->ofs,
+ t->MemBlock->size);
+ else
+ fprintf(stderr, "Texture at %x sz %x\n",
+ t->MemBlock->ofs,
+ t->MemBlock->size);
+
+ }
+}
+
+void s3vPrintGlobalLRU( s3vContextPtr vmesa )
+{
+ int i, j;
+ S3VTexRegionPtr list = vmesa->sarea->texList;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vPrintGlobalLRU: #%i ***\n", ++times));
+#endif
+
+ for (i = 0, j = S3V_NR_TEX_REGIONS ; i < S3V_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 == S3V_NR_TEX_REGIONS) break;
+ }
+
+ if (j != S3V_NR_TEX_REGIONS)
+ fprintf(stderr, "Loop detected in global LRU\n");
+}
+
+
+void s3vResetGlobalLRU( s3vContextPtr vmesa )
+{
+ S3VTexRegionPtr list = vmesa->sarea->texList;
+ int sz = 1 << vmesa->s3vScreen->logTextureGranularity;
+ int i;
+
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vResetGlobalLRU: #%i ***\n", ++times));
+#endif
+
+ /* (Re)initialize the global circular LRU list. The last element
+ * in the array (S3V_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) * sz <= vmesa->s3vScreen->textureSize ; i++) {
+ list[i].prev = i-1;
+ list[i].next = i+1;
+ list[i].age = 0;
+ }
+
+ i--;
+ list[0].prev = S3V_NR_TEX_REGIONS;
+ list[i].prev = i-1;
+ list[i].next = S3V_NR_TEX_REGIONS;
+ list[S3V_NR_TEX_REGIONS].prev = i;
+ list[S3V_NR_TEX_REGIONS].next = 0;
+ vmesa->sarea->texAge = 0;
+}
+
+
+void s3vUpdateTexLRU( s3vContextPtr vmesa, s3vTextureObjectPtr t )
+{
+/*
+ int i;
+ int logsz = vmesa->s3vScreen->logTextureGranularity;
+ int start = t->MemBlock->ofs >> logsz;
+ int end = (t->MemBlock->ofs + t->MemBlock->size - 1) >> logsz;
+ S3VTexRegionPtr list = vmesa->sarea->texList;
+*/
+
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vUpdateTexLRU: #%i ***\n", ++times));
+#endif
+
+ vmesa->texAge = ++vmesa->sarea->texAge;
+
+ /* Update our local LRU
+ */
+ move_to_head( &(vmesa->TexObjList), t );
+
+ /* Update the global LRU
+ */
+#if 0
+ for (i = start ; i <= end ; i++) {
+
+ list[i].in_use = 1;
+ list[i].age = vmesa->texAge;
+
+ /* remove_from_list(i)
+ */
+ list[(unsigned)list[i].next].prev = list[i].prev;
+ list[(unsigned)list[i].prev].next = list[i].next;
+
+ /* insert_at_head(list, i)
+ */
+ list[i].prev = S3V_NR_TEX_REGIONS;
+ list[i].next = list[S3V_NR_TEX_REGIONS].next;
+ list[(unsigned)list[S3V_NR_TEX_REGIONS].next].prev = i;
+ list[S3V_NR_TEX_REGIONS].next = i;
+ }
+#endif
+}
+
+
+/* Called for every shared texture region which has increased in age
+ * since we last held the lock.
+ *
+ * Figures out which of our textures have been ejected by other clients,
+ * and pushes a placeholder texture onto the LRU list to represent
+ * the other client's textures.
+ */
+void s3vTexturesGone( s3vContextPtr vmesa,
+ GLuint offset,
+ GLuint size,
+ GLuint in_use )
+{
+ s3vTextureObjectPtr t, tmp;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vTexturesGone: #%i ***\n", ++times));
+#endif
+
+ foreach_s ( t, tmp, &vmesa->TexObjList ) {
+
+ if (t->MemBlock->ofs >= offset + size ||
+ t->MemBlock->ofs + t->MemBlock->size <= offset)
+ continue;
+
+ /* It overlaps - kick it off. Need to hold onto the currently bound
+ * objects, however.
+ */
+ s3vSwapOutTexObj( vmesa, t );
+ }
+
+ if (in_use) {
+ t = (s3vTextureObjectPtr) calloc(1,sizeof(*t));
+ if (!t) return;
+
+ t->MemBlock = mmAllocMem( vmesa->texHeap, size, 0, offset);
+ insert_at_head( &vmesa->TexObjList, t );
+ }
+
+ /* Reload any lost textures referenced by current vertex buffer.
+ */
+#if 0
+ if (vmesa->vertex_buffer) {
+ int i, j;
+
+ fprintf(stderr, "\n\nreload tex\n");
+
+ for (i = 0 ; i < vmesa->statenr ; i++) {
+ for (j = 0 ; j < 2 ; j++) {
+ s3vTextureObjectPtr t = vmesa->state_tex[j][i];
+ if (t) {
+ if (t->MemBlock == 0)
+ s3vUploadTexImages( vmesa, t );
+ }
+ }
+ }
+
+ /* Hard to do this with the lock held:
+ */
+ /* S3V_FIREVERTICES( vmesa ); */
+ }
+#endif
+}
+
+
+/* This is called with the lock held. May have to eject our own and/or
+ * other client's texture objects to make room for the upload.
+ */
+void s3vUploadTexImages( s3vContextPtr vmesa, s3vTextureObjectPtr t )
+{
+ int i;
+ int ofs;
+ int numLevels;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ static unsigned int try=0;
+
+ DEBUG_TEX(("*** s3vUploadTexImages: #%i ***\n", ++times));
+ DEBUG_TEX(("vmesa->texHeap = 0x%x; t->totalSize = %i\n",
+ (unsigned int)vmesa->texHeap, t->totalSize));
+#endif
+
+ /* Do we need to eject LRU texture objects?
+ */
+ if (!t->MemBlock) {
+
+ while (1)
+ {
+ /* int try = 0; */
+ DEBUG_TEX(("trying to alloc mem for tex (try %i)\n", ++try));
+
+ t->MemBlock = mmAllocMem( vmesa->texHeap, t->totalSize, 12, 0 );
+
+ if (t->MemBlock)
+ break;
+
+ if (vmesa->TexObjList.prev == vmesa->CurrentTexObj[0]) {
+/* || vmesa->TexObjList.prev == vmesa->CurrentTexObj[1]) {
+ fprintf(stderr, "Hit bound texture in upload\n");
+ s3vPrintLocalLRU( vmesa ); */
+ return;
+ }
+
+ if (vmesa->TexObjList.prev == &(vmesa->TexObjList)) {
+/* fprintf(stderr, "Failed to upload texture, sz %d\n",
+ t->totalSize);
+ mmDumpMemInfo( vmesa->texHeap ); */
+ return;
+ }
+
+ DEBUG_TEX(("swapping out: %p\n", vmesa->TexObjList.prev));
+ s3vSwapOutTexObj( vmesa, vmesa->TexObjList.prev );
+ }
+
+ ofs = t->MemBlock->ofs;
+
+ t->BufAddr = vmesa->s3vScreen->texOffset + ofs;
+
+ DEBUG_TEX(("ofs = 0x%x\n", ofs));
+ DEBUG_TEX(("t->BufAddr = 0x%x\n", t->BufAddr));
+
+/* FIXME: check if we need it */
+#if 0
+ if (t == vmesa->CurrentTexObj[0]) {
+ vmesa->dirty |= S3V_UPLOAD_TEX0;
+ vmesa->restore_primitive = -1;
+ }
+#endif
+
+#if 0
+ if (t == vmesa->CurrentTexObj[1])
+ vmesa->dirty |= S3V_UPLOAD_TEX1;
+#endif
+
+ s3vUpdateTexLRU( vmesa, t );
+ }
+
+#if 0
+ if (vmesa->dirtyAge >= GET_DISPATCH_AGE(vmesa))
+ s3vWaitAgeLocked( vmesa, vmesa->dirtyAge );
+#endif
+
+#if _TEXLOCK
+ S3V_SIMPLE_FLUSH_LOCK(vmesa);
+#endif
+ numLevels = t->lastLevel - t->firstLevel + 1;
+ for (i = 0 ; i < numLevels ; i++)
+ if (t->dirty_images & (1<<i))
+ s3vUploadTexLevel( vmesa, t, i );
+
+ t->dirty_images = 0;
+#if _TEXLOCK
+ S3V_SIMPLE_UNLOCK(vmesa);
+#endif
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_texstate.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_texstate.c
new file mode 100644
index 000000000..b136c9d37
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_texstate.c
@@ -0,0 +1,300 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "simple_list.h"
+#include "enums.h"
+
+#include "mm.h"
+#include "s3v_context.h"
+#include "s3v_tex.h"
+
+
+static void s3vSetTexImages( s3vContextPtr vmesa,
+ struct gl_texture_object *tObj )
+{
+ GLuint height, width, pitch, i, /*textureFormat,*/ log_pitch;
+ s3vTextureObjectPtr t = (s3vTextureObjectPtr) tObj->DriverData;
+ const struct gl_texture_image *baseImage = tObj->Image[0][tObj->BaseLevel];
+ GLint firstLevel, lastLevel, numLevels;
+ GLint log2Width, log2Height;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vSetTexImages: #%i ***\n", ++times));
+#endif
+
+ t->texelBytes = 2; /* FIXME: always 2 ? */
+
+ /* Compute which mipmap levels we really want to send to the hardware.
+ * This depends on the base image size, GL_TEXTURE_MIN_LOD,
+ * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
+ * Yes, this looks overly complicated, but it's all needed.
+ */
+ if (tObj->MinFilter == GL_LINEAR || tObj->MinFilter == GL_NEAREST) {
+ firstLevel = lastLevel = tObj->BaseLevel;
+ }
+ else {
+ firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
+ firstLevel = MAX2(firstLevel, tObj->BaseLevel);
+ lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
+ lastLevel = MAX2(lastLevel, tObj->BaseLevel);
+ lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
+ lastLevel = MIN2(lastLevel, tObj->MaxLevel);
+ lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
+ }
+
+ /* save these values */
+ t->firstLevel = firstLevel;
+ t->lastLevel = lastLevel;
+
+ numLevels = lastLevel - firstLevel + 1;
+
+ log2Width = tObj->Image[0][firstLevel]->WidthLog2;
+ log2Height = tObj->Image[0][firstLevel]->HeightLog2;
+
+
+ /* Figure out the amount of memory required to hold all the mipmap
+ * levels. Choose the smallest pitch to accomodate the largest
+ * mipmap:
+ */
+ width = tObj->Image[0][firstLevel]->Width * t->texelBytes;
+ for (pitch = 32, log_pitch=2 ; pitch < width ; pitch *= 2 )
+ log_pitch++;
+
+ /* All images must be loaded at this pitch. Count the number of
+ * lines required:
+ */
+ for ( height = i = 0 ; i < numLevels ; i++ ) {
+ t->image[i].image = tObj->Image[0][firstLevel + i];
+ t->image[i].offset = height * pitch;
+ t->image[i].internalFormat = baseImage->Format;
+ height += t->image[i].image->Height;
+ t->TextureBaseAddr[i] = (t->BufAddr + t->image[i].offset +
+ _TEXALIGN) & (GLuint)(~_TEXALIGN);
+ }
+
+ t->Pitch = pitch;
+ t->WidthLog2 = log2Width;
+ t->totalSize = height*pitch;
+ t->max_level = i-1;
+ vmesa->dirty |= S3V_UPLOAD_TEX0 /* | S3V_UPLOAD_TEX1*/;
+ vmesa->restore_primitive = -1;
+ DEBUG(("<><>pitch = TexStride = %i\n", pitch));
+ DEBUG(("log2Width = %i\n", log2Width));
+
+ s3vUploadTexImages( vmesa, t );
+}
+
+static void s3vUpdateTexEnv( GLcontext *ctx, GLuint unit )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ const struct gl_texture_object *tObj = texUnit->_Current;
+ const GLuint format = tObj->Image[0][tObj->BaseLevel]->Format;
+/*
+ s3vTextureObjectPtr t = (s3vTextureObjectPtr)tObj->DriverData;
+ GLuint tc;
+*/
+ GLuint alpha = 0;
+ GLuint cmd = vmesa->CMD;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vUpdateTexEnv: %i ***\n", ++times));
+#endif
+
+ cmd &= ~TEX_COL_MASK;
+ cmd &= ~TEX_BLEND_MAKS;
+/* cmd &= ~ALPHA_BLEND_MASK; */
+
+ DEBUG(("format = "));
+
+ switch (format) {
+ case GL_RGB:
+ DEBUG_TEX(("GL_RGB\n"));
+ cmd |= TEX_COL_ARGB1555;
+ break;
+ case GL_LUMINANCE:
+ DEBUG_TEX(("GL_LUMINANCE\n"));
+ cmd |= TEX_COL_ARGB4444;
+ alpha = 1; /* FIXME: check */
+ break;
+ case GL_ALPHA:
+ DEBUG_TEX(("GL_ALPHA\n"));
+ cmd |= TEX_COL_ARGB4444;
+ alpha = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ DEBUG_TEX(("GL_LUMINANCE_ALPHA\n"));
+ cmd |= TEX_COL_ARGB4444;
+ alpha = 1;
+ break;
+ case GL_INTENSITY:
+ DEBUG_TEX(("GL_INTENSITY\n"));
+ cmd |= TEX_COL_ARGB4444;
+ alpha = 1;
+ break;
+ case GL_RGBA:
+ DEBUG_TEX(("GL_RGBA\n"));
+ cmd |= TEX_COL_ARGB4444;
+ alpha = 1;
+ break;
+ case GL_COLOR_INDEX:
+ DEBUG_TEX(("GL_COLOR_INDEX\n"));
+ cmd |= TEX_COL_PAL;
+ break;
+ }
+
+ DEBUG_TEX(("EnvMode = "));
+
+ switch (texUnit->EnvMode) {
+ case GL_REPLACE:
+ DEBUG_TEX(("GL_REPLACE\n"));
+ cmd |= TEX_REFLECT; /* FIXME */
+ vmesa->_tri[1] = DO_TEX_UNLIT_TRI; /* FIXME: white tri hack */
+ vmesa->_alpha_tex = ALPHA_TEX /* * alpha */;
+ break;
+ case GL_MODULATE:
+ DEBUG_TEX(("GL_MODULATE\n"));
+ cmd |= TEX_MODULATE;
+ vmesa->_tri[1] = DO_TEX_LIT_TRI;
+#if 0
+ if (alpha)
+ vmesa->_alpha_tex = ALPHA_TEX /* * alpha */;
+ else
+ vmesa->_alpha_tex = ALPHA_SRC /* * alpha */;
+#else
+ vmesa->_alpha_tex = ALPHA_TEX ;
+#endif
+ break;
+ case GL_ADD:
+ DEBUG_TEX(("DEBUG_TEX\n"));
+ /* do nothing ???*/
+ break;
+ case GL_DECAL:
+ DEBUG_TEX(("GL_DECAL\n"));
+ cmd |= TEX_DECAL;
+ vmesa->_tri[1] = DO_TEX_LIT_TRI;
+ vmesa->_alpha_tex = ALPHA_OFF;
+ break;
+ case GL_BLEND:
+ DEBUG_TEX(("GL_BLEND\n"));
+ cmd |= TEX_DECAL;
+ vmesa->_tri[1] = DO_TEX_LIT_TRI;
+ vmesa->_alpha_tex = ALPHA_OFF; /* FIXME: sure? */
+ break;
+ default:
+ fprintf(stderr, "unknown tex env mode");
+ return;
+ }
+
+ DEBUG_TEX(("\n\n vmesa->CMD was 0x%x\n", vmesa->CMD));
+ DEBUG_TEX(( " vmesa->CMD is 0x%x\n\n", cmd ));
+
+ vmesa->_alpha[1] = vmesa->_alpha_tex;
+ vmesa->CMD = cmd; /* | MIPMAP_LEVEL(8); */
+ vmesa->restore_primitive = -1;
+}
+
+static void s3vUpdateTexUnit( GLcontext *ctx, GLuint unit )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ GLuint cmd = vmesa->CMD;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vUpdateTexUnit: %i ***\n", ++times));
+ DEBUG_TEX(("and vmesa->CMD was 0x%x\n", vmesa->CMD));
+#endif
+
+ if (texUnit->_ReallyEnabled == TEXTURE_2D_BIT)
+ {
+ struct gl_texture_object *tObj = texUnit->_Current;
+ s3vTextureObjectPtr t = (s3vTextureObjectPtr)tObj->DriverData;
+
+ /* Upload teximages (not pipelined)
+ */
+ if (t->dirty_images) {
+#if _TEXFLUSH
+ DMAFLUSH();
+#endif
+ s3vSetTexImages( vmesa, tObj );
+ if (!t->MemBlock) {
+#if _TEXFALLBACK
+ FALLBACK( vmesa, S3V_FALLBACK_TEXTURE, GL_TRUE );
+#endif
+ return;
+ }
+ }
+
+ /* Update state if this is a different texture object to last
+ * time.
+ */
+#if 1
+ if (vmesa->CurrentTexObj[unit] != t) {
+ vmesa->dirty |= S3V_UPLOAD_TEX0 /* << unit */;
+ vmesa->CurrentTexObj[unit] = t;
+ s3vUpdateTexLRU( vmesa, t ); /* done too often */
+ }
+#endif
+
+ /* Update texture environment if texture object image format or
+ * texture environment state has changed.
+ */
+ if (tObj->Image[0][tObj->BaseLevel]->Format !=
+ vmesa->TexEnvImageFmt[unit]) {
+ vmesa->TexEnvImageFmt[unit] = tObj->Image[0][tObj->BaseLevel]->Format;
+ s3vUpdateTexEnv( ctx, unit );
+ }
+#if 1
+ cmd = vmesa->CMD & ~MIP_MASK;
+ vmesa->dirty |= S3V_UPLOAD_TEX0 /* << unit */;
+ vmesa->CurrentTexObj[unit] = t;
+ vmesa->TexOffset = t->TextureBaseAddr[tObj->BaseLevel];
+ vmesa->TexStride = t->Pitch;
+ cmd |= MIPMAP_LEVEL(t->WidthLog2);
+
+ DEBUG_TEX(("\n\n>> vmesa->CMD was 0x%x\n", vmesa->CMD));
+ DEBUG_TEX(( ">> vmesa->CMD is 0x%x\n\n", cmd ));
+ DEBUG_TEX(("t->WidthLog2 = %i\n", t->WidthLog2));
+ DEBUG_TEX(("MIPMAP_LEVEL(t->WidthLog2) = 0x%x\n", MIPMAP_LEVEL(t->WidthLog2)));
+
+ vmesa->CMD = cmd;
+ vmesa->restore_primitive = -1;
+#endif
+ }
+ else if (texUnit->_ReallyEnabled) { /* _ReallyEnabled but != TEXTURE0_2D */
+#if _TEXFALLBACK
+ FALLBACK( vmesa, S3V_FALLBACK_TEXTURE, GL_TRUE );
+#endif
+ }
+ else /*if (vmesa->CurrentTexObj[unit])*/ { /* !_ReallyEnabled */
+ vmesa->CurrentTexObj[unit] = 0;
+ vmesa->TexEnvImageFmt[unit] = 0;
+ vmesa->dirty &= ~(S3V_UPLOAD_TEX0<<unit);
+ }
+}
+
+
+void s3vUpdateTextureState( GLcontext *ctx )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ (void) vmesa;
+#if TEX_DEBUG_ON
+ static unsigned int times=0;
+ DEBUG_TEX(("*** s3vUpdateTextureState: #%i ***\n", ++times));
+#endif
+
+#if _TEXFALLBACK
+ FALLBACK( vmesa, S3V_FALLBACK_TEXTURE, GL_FALSE );
+#endif
+ s3vUpdateTexUnit( ctx, 0 );
+#if 0
+ s3vUpdateTexUnit( ctx, 1 );
+#endif
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tris.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tris.c
new file mode 100644
index 000000000..d6cceddd4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tris.c
@@ -0,0 +1,850 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sys/ioctl.h>
+
+#include "s3v_context.h"
+#include "s3v_vb.h"
+#include "s3v_tris.h"
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "colormac.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
+
+/***********************************************************************
+ * Build hardware rasterization functions *
+ ***********************************************************************/
+
+#define DO_TRI 1
+#define HAVE_RGBA 1
+#define HAVE_SPEC 0
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX s3vVertex
+#define TAB rast_tab
+
+#define VERT_SET_RGBA( v, c ) \
+do { \
+ UNCLAMPED_FLOAT_TO_RGBA_CHAN( v->ub4[4], c); \
+/* *(v->ub4[4]) = c; \ */ \
+} while (0)
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4]
+/*
+#define VERT_COPY_RGBA1( v0, v1 ) v0->ui[4] = v1->ui[4]
+*/
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[4]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx]
+
+#define S3V_OFFSET_BIT 0x01
+#define S3V_TWOSIDE_BIT 0x02
+#define S3V_UNFILLED_BIT 0x04
+#define S3V_FALLBACK_BIT 0x08
+#define S3V_MAX_TRIFUNC 0x10
+
+
+static struct {
+ tnl_points_func points;
+ tnl_line_func line;
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
+} rast_tab[S3V_MAX_TRIFUNC];
+
+#define S3V_RAST_CULL_BIT 0x01
+#define S3V_RAST_FLAT_BIT 0x02
+#define S3V_RAST_TEX_BIT 0x04
+
+static s3v_point_func s3v_point_tab[0x8];
+static s3v_line_func s3v_line_tab[0x8];
+static s3v_tri_func s3v_tri_tab[0x8];
+static s3v_quad_func s3v_quad_tab[0x8];
+
+#define IND (0)
+#define TAG(x) x
+#include "s3v_tritmp.h"
+
+#define IND (S3V_RAST_CULL_BIT)
+#define TAG(x) x##_cull
+#include "s3v_tritmp.h"
+
+#define IND (S3V_RAST_FLAT_BIT)
+#define TAG(x) x##_flat
+#include "s3v_tritmp.h"
+
+#define IND (S3V_RAST_CULL_BIT|S3V_RAST_FLAT_BIT)
+#define TAG(x) x##_cull_flat
+#include "s3v_tritmp.h"
+
+#define IND (S3V_RAST_TEX_BIT)
+#define TAG(x) x##_tex
+#include "s3v_tritmp.h"
+
+#define IND (S3V_RAST_CULL_BIT|S3V_RAST_TEX_BIT)
+#define TAG(x) x##_cull_tex
+#include "s3v_tritmp.h"
+
+#define IND (S3V_RAST_FLAT_BIT|S3V_RAST_TEX_BIT)
+#define TAG(x) x##_flat_tex
+#include "s3v_tritmp.h"
+
+#define IND (S3V_RAST_CULL_BIT|S3V_RAST_FLAT_BIT|S3V_RAST_TEX_BIT)
+#define TAG(x) x##_cull_flat_tex
+#include "s3v_tritmp.h"
+
+static void init_rast_tab( void )
+{
+ DEBUG(("*** init_rast_tab ***\n"));
+
+ s3v_init();
+ s3v_init_cull();
+ s3v_init_flat();
+ s3v_init_cull_flat();
+ s3v_init_tex();
+ s3v_init_cull_tex();
+ s3v_init_flat_tex();
+ s3v_init_cull_flat_tex();
+}
+
+/***********************************************************************
+ * Rasterization fallback helpers *
+ ***********************************************************************/
+
+
+/* This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+
+#if 0
+static void
+s3v_fallback_quad( s3vContextPtr vmesa,
+ const s3vVertex *v0,
+ const s3vVertex *v1,
+ const s3vVertex *v2,
+ const s3vVertex *v3 )
+{
+ GLcontext *ctx = vmesa->glCtx;
+ SWvertex v[4];
+ s3v_translate_vertex( ctx, v0, &v[0] );
+ s3v_translate_vertex( ctx, v1, &v[1] );
+ s3v_translate_vertex( ctx, v2, &v[2] );
+ s3v_translate_vertex( ctx, v3, &v[3] );
+ DEBUG(("s3v_fallback_quad\n"));
+/* _swrast_Quad( ctx, &v[0], &v[1], &v[2], &v[3] ); */
+}
+
+static void
+s3v_fallback_tri( s3vContextPtr vmesa,
+ const s3vVertex *v0,
+ const s3vVertex *v1,
+ const s3vVertex *v2 )
+{
+ GLcontext *ctx = vmesa->glCtx;
+ SWvertex v[3];
+ s3v_translate_vertex( ctx, v0, &v[0] );
+ s3v_translate_vertex( ctx, v1, &v[1] );
+ s3v_translate_vertex( ctx, v2, &v[2] );
+ DEBUG(("s3v_fallback_tri\n"));
+/* _swrast_Triangle( ctx, &v[0], &v[1], &v[2] ); */
+}
+
+static void
+s3v_fallback_line( s3vContextPtr vmesa,
+ const s3vVertex *v0,
+ const s3vVertex *v1 )
+{
+ GLcontext *ctx = vmesa->glCtx;
+ SWvertex v[2];
+ s3v_translate_vertex( ctx, v0, &v[0] );
+ s3v_translate_vertex( ctx, v1, &v[1] );
+ DEBUG(("s3v_fallback_line\n"));
+ _swrast_Line( ctx, &v[0], &v[1] );
+}
+
+/*
+static void
+s3v_fallback_point( s3vContextPtr vmesa,
+ const s3vVertex *v0 )
+{
+ GLcontext *ctx = vmesa->glCtx;
+ SWvertex v[1];
+ s3v_translate_vertex( ctx, v0, &v[0] );
+ _swrast_Point( ctx, &v[0] );
+}
+*/
+#endif
+
+/***********************************************************************
+ * Choose rasterization functions *
+ ***********************************************************************/
+
+#define _S3V_NEW_RASTER_STATE (_NEW_FOG | \
+ _NEW_TEXTURE | \
+ _DD_NEW_TRI_SMOOTH | \
+ _DD_NEW_LINE_SMOOTH | \
+ _DD_NEW_POINT_SMOOTH | \
+ _DD_NEW_TRI_STIPPLE | \
+ _DD_NEW_LINE_STIPPLE)
+
+#define LINE_FALLBACK (0)
+#define TRI_FALLBACK (0)
+
+static void s3v_nodraw_triangle(GLcontext *ctx, s3vVertex *v0,
+ s3vVertex *v1, s3vVertex *v2)
+{
+ (void) (ctx && v0 && v1 && v2);
+}
+
+static void s3v_nodraw_quad(GLcontext *ctx,
+ s3vVertex *v0, s3vVertex *v1,
+ s3vVertex *v2, s3vVertex *v3)
+{
+ (void) (ctx && v0 && v1 && v2 && v3);
+}
+
+void s3vChooseRasterState(GLcontext *ctx);
+
+void s3vChooseRasterState(GLcontext *ctx)
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint ind = 0;
+
+ DEBUG(("*** s3vChooseRasterState ***\n"));
+
+ if (ctx->Polygon.CullFlag) {
+ if (ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) {
+ vmesa->draw_tri = (s3v_tri_func)s3v_nodraw_triangle;
+ vmesa->draw_quad = (s3v_quad_func)s3v_nodraw_quad;
+ return;
+ }
+ ind |= S3V_RAST_CULL_BIT;
+ /* s3v_update_cullsign(ctx); */
+ } /* else vmesa->backface_sign = 0; */
+
+ if ( flags & DD_FLATSHADE )
+ ind |= S3V_RAST_FLAT_BIT;
+
+ if ( ctx->Texture.Unit[0]._ReallyEnabled ) {
+ ind |= S3V_RAST_TEX_BIT;
+ }
+
+ DEBUG(("ind = %i\n", ind));
+
+ vmesa->draw_line = s3v_line_tab[ind];
+ vmesa->draw_tri = s3v_tri_tab[ind];
+ vmesa->draw_quad = s3v_quad_tab[ind];
+ vmesa->draw_point = s3v_point_tab[ind];
+
+#if 0
+ /* Hook in fallbacks for specific primitives. CURRENTLY DISABLED
+ */
+
+ if (flags & LINE_FALLBACK)
+ vmesa->draw_line = s3v_fallback_line;
+
+ if (flags & TRI_FALLBACK) {
+ DEBUG(("TRI_FALLBACK\n"));
+ vmesa->draw_tri = s3v_fallback_tri;
+ vmesa->draw_quad = s3v_fallback_quad;
+ }
+#endif
+}
+
+
+
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( v0, v1, v2 ) \
+do { \
+ /*
+ if (DO_FALLBACK) \
+ vmesa->draw_tri( vmesa, v0, v1, v2 ); \
+ else */ \
+ DEBUG(("TRI: max was here\n")); /* \
+ s3v_draw_tex_triangle( vmesa, v0, v1, v2 ); */ \
+ vmesa->draw_tri( vmesa, v0, v1, v2 ); \
+} while (0)
+
+#define QUAD( v0, v1, v2, v3 ) \
+do { \
+ DEBUG(("QUAD: max was here\n")); \
+ vmesa->draw_quad( vmesa, v0, v1, v2, v3 ); \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ DEBUG(("LINE: max was here\n")); \
+ vmesa->draw_line( vmesa, v0, v1 ); \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ vmesa->draw_point( vmesa, v0 ); \
+} while (0)
+
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+/*
+#define S3V_OFFSET_BIT 0x01
+#define S3V_TWOSIDE_BIT 0x02
+#define S3V_UNFILLED_BIT 0x04
+#define S3V_FALLBACK_BIT 0x08
+#define S3V_MAX_TRIFUNC 0x10
+
+
+static struct {
+ points_func points;
+ line_func line;
+ triangle_func triangle;
+ quad_func quad;
+} rast_tab[S3V_MAX_TRIFUNC];
+*/
+
+#define DO_FALLBACK (IND & S3V_FALLBACK_BIT)
+#define DO_OFFSET (IND & S3V_OFFSET_BIT)
+#define DO_UNFILLED (IND & S3V_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & S3V_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 0
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX s3vVertex
+#define TAB rast_tab
+
+#define DEPTH_SCALE 1.0
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a > 0)
+#define GET_VERTEX(e) (vmesa->verts + (e<<vmesa->vertex_stride_shift))
+
+#if 0
+#define VERT_SET_RGBA( v, c ) \
+do { \
+/* UNCLAMPED_FLOAT_TO_RGBA_CHAN( v->ub4[4], c) */ \
+} while (0)
+
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[4] = v1->ui[4]
+/*
+#define VERT_COPY_RGBA1( v0, v1 ) v0->ui[4] = v1->ui[4]
+*/
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[4]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[4] = color[idx]
+#endif
+
+#define LOCAL_VARS(n) \
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx); \
+ GLuint color[n]; \
+ (void) color;
+
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ PrimType_Points,
+ PrimType_Lines,
+ PrimType_Lines,
+ PrimType_Lines,
+ PrimType_Triangles,
+ PrimType_Triangles,
+ PrimType_Triangles,
+ PrimType_Triangles,
+ PrimType_Triangles,
+ PrimType_Triangles
+};
+
+static void s3vResetLineStipple( GLcontext *ctx );
+static void s3vRasterPrimitive( GLcontext *ctx, GLuint hwprim );
+static void s3vRenderPrimitive( GLcontext *ctx, GLenum prim );
+/*
+extern static void s3v_lines_emit(GLcontext *ctx, GLuint start, GLuint end);
+extern static void s3v_tris_emit(GLcontext *ctx, GLuint start, GLuint end);
+*/
+#define RASTERIZE(x) if (vmesa->hw_primitive != hw_prim[x]) \
+ s3vRasterPrimitive( ctx, hw_prim[x] )
+#define RENDER_PRIMITIVE vmesa->render_primitive
+#define TAG(x) x
+#define IND S3V_FALLBACK_BIT
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (S3V_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (S3V_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (S3V_TWOSIDE_BIT|S3V_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (S3V_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (S3V_OFFSET_BIT|S3V_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (S3V_TWOSIDE_BIT|S3V_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (S3V_TWOSIDE_BIT|S3V_OFFSET_BIT|S3V_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+static void init_render_tab( void )
+{
+ DEBUG(("*** init_render_tab ***\n"));
+
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+}
+
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+#define VERT(x) (s3vVertex *)(s3vverts + (x << shift))
+
+#define RENDER_POINTS( start, count ) \
+ DEBUG(("RENDER_POINTS...(ok)\n")); \
+ for ( ; start < count ; start++) \
+ vmesa->draw_line( vmesa, VERT(start), VERT(start) )
+ /* vmesa->draw_point( vmesa, VERT(start) ) */
+
+#define RENDER_LINE( v0, v1 ) \
+ /* DEBUG(("RENDER_LINE...(ok)\n")); \ */ \
+ vmesa->draw_line( vmesa, VERT(v0), VERT(v1) ); \
+ DEBUG(("RENDER_LINE...(ok)\n"))
+
+#define RENDER_TRI( v0, v1, v2 ) \
+ DEBUG(("RENDER_TRI...(ok)\n")); \
+ vmesa->draw_tri( vmesa, VERT(v0), VERT(v1), VERT(v2) )
+
+#define RENDER_QUAD( v0, v1, v2, v3 ) \
+ DEBUG(("RENDER_QUAD...(ok)\n")); \
+ /* s3v_draw_quad( vmesa, VERT(v0), VERT(v1), VERT(v2),VERT(v3) ) */\
+ /* s3v_draw_triangle( vmesa, VERT(v0), VERT(v1), VERT(v2) ); \
+ s3v_draw_triangle( vmesa, VERT(v0), VERT(v2), VERT(v3) ) */ \
+ vmesa->draw_quad( vmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
+
+#define INIT(x) s3vRenderPrimitive( ctx, x );
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx); \
+ const GLuint shift = vmesa->vertex_stride_shift; \
+ const char *s3vverts = (char *)vmesa->verts; \
+ const GLboolean stipple = ctx->Line.StippleFlag; \
+ (void) stipple;
+#define RESET_STIPPLE if ( stipple ) s3vResetLineStipple( ctx );
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) (x)
+#define TAG(x) s3v_##x##_verts
+#include "tnl_dd/t_dd_rendertmp.h"
+
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+static void s3vRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint prim = vmesa->render_primitive;
+
+ DEBUG(("I AM in: s3vRenderClippedPoly\n"));
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ if (1)
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]
+ ( ctx, 0, n, PRIM_BEGIN|PRIM_END );
+
+ VB->Elts = tmp;
+ }
+
+ /* Restore the render primitive
+ */
+#if 1
+ if (prim != GL_POLYGON) {
+ DEBUG(("and prim != GL_POLYGON\n"));
+ tnl->Driver.Render.PrimitiveNotify( ctx, prim );
+ }
+
+#endif
+}
+
+static void s3vRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ /*tnl->Driver.LineFunc = s3v_line_tab[2];*/ /* _swsetup_Line; */
+
+ DEBUG(("I AM in: s3vRenderClippedLine\n"));
+ tnl->Driver.Render.Line( ctx, ii, jj );
+}
+
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+
+
+#define _S3V_NEW_RENDERSTATE (_DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET)
+
+#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
+
+static void s3vChooseRenderState(GLcontext *ctx)
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ DEBUG(("s3vChooseRenderState\n"));
+
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= S3V_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= S3V_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= S3V_UNFILLED_BIT;
+ }
+
+ DEBUG(("vmesa->RenderIndex = %i\n", vmesa->RenderIndex));
+ DEBUG(("index = %i\n", index));
+
+ if (vmesa->RenderIndex != index) {
+ vmesa->RenderIndex = index;
+
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (vmesa->RenderIndex == 0)
+ tnl->Driver.Render.PrimTabVerts = s3v_render_tab_verts;
+ else
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = s3vRenderClippedLine;
+ tnl->Driver.Render.ClippedPolygon = s3vRenderClippedPoly;
+ }
+}
+
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+
+
+/* Determine the rasterized primitive when not drawing unfilled
+ * polygons.
+ *
+ * Used only for the default render stage which always decomposes
+ * primitives to trianges/lines/points. For the accelerated stage,
+ * which renders strips as strips, the equivalent calculations are
+ * performed in s3v_render.c.
+ */
+
+static void s3vRasterPrimitive( GLcontext *ctx, GLuint hwprim )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+/* __DRIdrawablePrivate *dPriv = vmesa->driDrawable; */
+ GLuint cmd = vmesa->CMD;
+
+ unsigned int _hw_prim = hwprim;
+
+ DEBUG(("s3vRasterPrimitive: hwprim = 0x%x ", _hw_prim));
+
+/* printf("* vmesa->CMD = 0x%x\n", vmesa->CMD); */
+
+ if (vmesa->hw_primitive != _hw_prim)
+ {
+ DEBUG(("(new one) ***\n"));
+ cmd &= ~DO_MASK;
+ cmd &= ~ALPHA_BLEND_MASK;
+ vmesa->hw_primitive = _hw_prim;
+
+ if (_hw_prim == PrimType_Triangles) {
+ /* TRI */
+ DEBUG(("->switching to tri\n"));
+ cmd |= (vmesa->_tri[vmesa->_3d_mode] | vmesa->_alpha[vmesa->_3d_mode]);
+ } else if (_hw_prim == PrimType_Lines
+ || _hw_prim == PrimType_Points) {
+ /* LINE */
+ DEBUG(("->switching to line\n"));
+ cmd |= (DO_3D_LINE | vmesa->_alpha[0]);
+ } else {
+ /* ugh? */
+ DEBUG(("->switching to your sis'ass\n"));
+ }
+
+ DEBUG(("\n"));
+
+ vmesa->restore_primitive = _hw_prim;
+ /* 0xacc16827: good value -> lightened newave!!! */
+ vmesa->CMD = cmd;
+ CMDCHANGE();
+ }
+}
+
+static void s3vRenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+ GLuint cmd = vmesa->CMD;
+
+ unsigned int _hw_prim = hw_prim[prim];
+
+ vmesa->render_primitive = prim;
+ vmesa->hw_primitive = _hw_prim;
+
+ DEBUG(("s3vRenderPrimitive #%i ", prim));
+ DEBUG(("_hw_prim = 0x%x\n", _hw_prim));
+
+/* printf(" vmesa->CMD = 0x%x\n", vmesa->CMD); */
+
+ if (_hw_prim != vmesa->restore_primitive) {
+ DEBUG(("_hw_prim != vmesa->restore_primitive (was 0x%x)\n",
+ vmesa->restore_primitive));
+#if 1
+ cmd &= ~DO_MASK;
+ cmd &= ~ALPHA_BLEND_MASK;
+/*
+ printf(" cmd = 0x%x\n", cmd);
+ printf(" vmesa->_3d_mode=%i; vmesa->_tri[vmesa->_3d_mode]=0x%x\n",
+ vmesa->_3d_mode, vmesa->_tri[vmesa->_3d_mode]);
+ printf("vmesa->alpha[0] = 0x%x; vmesa->alpha[1] = 0x%x\n",
+ vmesa->_alpha[0], vmesa->_alpha[1]);
+*/
+ if (_hw_prim == PrimType_Triangles) { /* TRI */
+ DEBUG(("->switching to tri\n"));
+ cmd |= (vmesa->_tri[vmesa->_3d_mode] | vmesa->_alpha[vmesa->_3d_mode]);
+ DEBUG(("vmesa->TexStride = %i\n", vmesa->TexStride));
+ DEBUG(("vmesa->TexOffset = %i\n", vmesa->TexOffset));
+ DMAOUT_CHECK(3DTRI_Z_BASE, 12);
+ } else { /* LINE */
+ DEBUG(("->switching to line\n"));
+ cmd |= (DO_3D_LINE | vmesa->_alpha[0]);
+ DMAOUT_CHECK(3DLINE_Z_BASE, 12);
+ }
+
+ DMAOUT(vmesa->s3vScreen->depthOffset & 0x003FFFF8);
+ DMAOUT(vmesa->DestBase);
+ /* DMAOUT(vmesa->ScissorLR); */
+ /* DMAOUT(vmesa->ScissorTB); */
+
+ /* NOTE: we need to restore all these values since we
+ * are coming back from a vmesa->restore_primitive */
+ DMAOUT( (0 << 16) | (dPriv->w-1) );
+ DMAOUT( (0 << 16) | (dPriv->h-1) );
+ DMAOUT( (vmesa->SrcStride << 16) | vmesa->TexStride );
+ DMAOUT(vmesa->SrcStride);
+ DMAOUT(vmesa->TexOffset);
+ DMAOUT(vmesa->TextureBorderColor);
+ DMAOUT(0); /* FOG */
+ DMAOUT(0);
+ DMAOUT(0);
+ DMAOUT(cmd);
+ /* 0xacc16827: good value -> lightened newave!!! */
+ DMAFINISH();
+
+ vmesa->CMD = cmd;
+#endif
+ }
+
+ DEBUG(("\n"));
+
+ vmesa->restore_primitive = _hw_prim;
+}
+
+static void s3vRunPipeline( GLcontext *ctx )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+
+ DEBUG(("*** s3vRunPipeline ***\n"));
+
+ if ( vmesa->new_state )
+ s3vDDUpdateHWState( ctx );
+
+ if (vmesa->new_gl_state) {
+
+ if (vmesa->new_gl_state & _NEW_TEXTURE) {
+ s3vUpdateTextureState( ctx );
+ }
+
+ if (!vmesa->Fallback) {
+ if (vmesa->new_gl_state & _S3V_NEW_VERTEX)
+ s3vChooseVertexState( ctx );
+
+ if (vmesa->new_gl_state & _S3V_NEW_RASTER_STATE)
+ s3vChooseRasterState( ctx );
+
+ if (vmesa->new_gl_state & _S3V_NEW_RENDERSTATE)
+ s3vChooseRenderState( ctx );
+ }
+
+ vmesa->new_gl_state = 0;
+
+ }
+
+ _tnl_run_pipeline( ctx );
+}
+
+static void s3vRenderStart( GLcontext *ctx )
+{
+ /* Check for projective texturing. Make sure all texcoord
+ * pointers point to something. (fix in mesa?)
+ */
+
+ DEBUG(("s3vRenderStart\n"));
+ /* s3vCheckTexSizes( ctx ); */
+}
+
+static void s3vRenderFinish( GLcontext *ctx )
+{
+ if (0)
+ _swrast_flush( ctx ); /* never needed */
+}
+
+static void s3vResetLineStipple( GLcontext *ctx )
+{
+/* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */
+
+ /* Reset the hardware stipple counter.
+ */
+/*
+ CHECK_DMA_BUFFER(vmesa, 1);
+ WRITE(vmesa->buf, UpdateLineStippleCounters, 0);
+*/
+}
+
+
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+
+
+void s3vFallback( s3vContextPtr vmesa, GLuint bit, GLboolean mode )
+{
+ GLcontext *ctx = vmesa->glCtx;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldfallback = vmesa->Fallback;
+
+ DEBUG(("*** s3vFallback: "));
+
+ if (mode) {
+ vmesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ DEBUG(("oldfallback == 0 ***\n"));
+ _swsetup_Wakeup( ctx );
+ _tnl_need_projected_coords( ctx, GL_TRUE );
+ vmesa->RenderIndex = ~0;
+ }
+ }
+ else {
+ DEBUG(("***\n"));
+ vmesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = s3vRenderStart;
+ tnl->Driver.Render.PrimitiveNotify = s3vRenderPrimitive;
+ tnl->Driver.Render.Finish = s3vRenderFinish;
+ tnl->Driver.Render.BuildVertices = s3vBuildVertices;
+ tnl->Driver.Render.ResetLineStipple = s3vResetLineStipple;
+ vmesa->new_gl_state |= (_S3V_NEW_RENDERSTATE|
+ _S3V_NEW_RASTER_STATE|
+ _S3V_NEW_VERTEX);
+ }
+ }
+}
+
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+
+void s3vInitTriFuncs( GLcontext *ctx )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ init_render_tab();
+ firsttime = 0;
+ }
+
+ vmesa->RenderIndex = ~0;
+
+ tnl->Driver.RunPipeline = s3vRunPipeline;
+ tnl->Driver.Render.Start = s3vRenderStart;
+ tnl->Driver.Render.Finish = s3vRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = s3vRenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = s3vResetLineStipple;
+/*
+ tnl->Driver.RenderInterp = _swsetup_RenderInterp;
+ tnl->Driver.RenderCopyPV = _swsetup_RenderCopyPV;
+*/
+ tnl->Driver.Render.BuildVertices = s3vBuildVertices;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tris.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tris.h
new file mode 100644
index 000000000..0010a7fe0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tris.h
@@ -0,0 +1,11 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#ifndef _S3V_TRIS_H
+#define _S3V_TRIS_H
+
+extern void s3vDDTrifuncInit(void);
+extern void s3vDDChooseTriRenderState(GLcontext *);
+
+#endif /* !(_S3V_TRIS_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tritmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tritmp.h
new file mode 100644
index 000000000..16318f4c4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_tritmp.h
@@ -0,0 +1,958 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+/**** MACROS start ****/
+
+/* point/line macros */
+
+#define LINE_VERT_VARS \
+ SWvertex v[3]; \
+ s3vVertex* vvv[2]; \
+ int x[3], y[3], z[3]; \
+ int idx[3]; \
+ int dx01, dy01; \
+ int delt02; \
+ int deltzy, zstart; \
+ int start02, end01; \
+ int ystart, y01y12; \
+ int i, tmp, tmp2, tmp3; \
+ GLfloat ydiff, fy[3]
+#define LINE_VERT_VARS_VOIDS \
+ (void) v; (void) vvv; (void) x; (void) y; (void) z; (void) idx; \
+ (void) dx01; (void) dy01; (void) delt02; (void) deltzy; \
+ (void) zstart; (void) start02; (void) ystart; (void) y01y12; \
+ (void) i; (void) tmp; (void) tmp2; (void) tmp3; (void) ydiff; (void) fy
+
+#define LINE_FLAT_VARS \
+ int arstart, gbstart; \
+ int deltarx, deltgbx, deltary, deltgby; \
+ GLubyte *(col)[3]
+#define LINE_FLAT_VARS_VOIDS \
+ (void) arstart; (void) gbstart; (void) deltarx; (void) deltgbx; \
+ (void) deltary; (void) deltgby; (void) col
+
+#define LINE_GOURAUD_VARS \
+ int arstart, gbstart; \
+ int deltary, deltgby; \
+ int ctmp, ctmp2, ctmp3, ctmp4; \
+ GLubyte *(col)[3]
+#define LINE_GOURAUD_VARS_VOIDS \
+ (void) arstart; (void) gbstart; (void) deltary; (void) deltgby; \
+ (void) ctmp; (void) ctmp2; (void) ctmp3; (void) ctmp4; (void) col
+
+#define SORT_LINE_VERT() \
+do { \
+ if(v[0].win[1] <= v[1].win[1]) { \
+\
+ idx[0] = 0; \
+ idx[1] = 1; \
+\
+ } else if (v[0].win[1] > v[1].win[1]) { \
+\
+ idx[0] = 1; \
+ idx[1] = 0; \
+\
+ } \
+} while(0)
+
+#define SET_LINE_VERT() \
+do { \
+ x[0] = (v[idx[0]].win[0] * 1024.0f * 1024.0f); /* 0x100000 */ \
+ y[0] = fy[0] = dPriv->h - v[idx[0]].win[1]; \
+ z[0] = (v[idx[0]].win[2]) * 1024.0f * 32.0f; /* 0x8000; */ \
+\
+ x[1] = (v[idx[1]].win[0] * 1024.0f * 1024.0f); /* 0x100000 */ \
+ y[1] = dPriv->h - v[idx[1]].win[1]; \
+ z[1] = (v[idx[1]].win[2]) * 1024.0f * 32.0f; /* 0x8000 */ \
+} while(0)
+
+#define SET_LINE_XY() \
+do { \
+ tmp = v[idx[0]].win[0]; \
+ tmp2 = v[idx[1]].win[0]; \
+\
+ dx01 = x[0] - x[1]; \
+ dy01 = y[0] - y[1]; \
+\
+ ydiff = fy[0] - (float)y[0]; \
+ ystart = y[0]; \
+ y01y12 = dy01 + 1; \
+} while (0)
+
+#define SET_LINE_DIR() \
+do { \
+ if (tmp2 > tmp) { \
+ y01y12 |= 0x80000000; \
+ tmp3 = tmp2-tmp; \
+ } else { \
+ tmp3 = tmp-tmp2; \
+ } \
+\
+ end01 = ((tmp << 16) | tmp2); \
+\
+ if (dy01) \
+ delt02 = -(dx01/dy01); \
+ else \
+ delt02 = 0; \
+\
+ if (dy01 > tmp3) { /* Y MAJ */ \
+ /* NOTE: tmp3 always >=0 */ \
+ start02 = x[0]; \
+ } else if (delt02 >= 0){ /* X MAJ - positive delta */ \
+ start02 = x[0] + delt02/2; \
+ dy01 = tmp3; /* could be 0 */ \
+ } else { /* X MAJ - negative delta */ \
+ start02 = x[0] + delt02/2 + ((1 << 20) - 1); \
+ dy01 = tmp3; /* could be 0 */ \
+ } \
+} while(0)
+
+#define SET_LINE_Z() \
+do { \
+ zstart = z[0]; \
+\
+ if (dy01) { \
+ deltzy = (z[1] - z[0])/dy01; \
+ } else { \
+ deltzy = 0; /* dy01 = tmp3 = 0 (it's a point)*/ \
+ } \
+} while (0)
+
+#define SET_LINE_FLAT_COL() \
+do { \
+ col[0] = &(v[idx[0]].color[0]); \
+ deltarx = deltary = deltgbx = deltgby = 0; \
+ gbstart = (((col[0][1]) << 23) | ((col[0][2]) << 7)); \
+ arstart = (((col[0][3]) << 23) | ((col[0][0]) << 7)); \
+} while(0)
+
+#define SET_LINE_GOURAUD_COL() \
+do { \
+ col[0] = &(v[idx[0]].color[0]); \
+ col[1] = &(v[idx[1]].color[0]); \
+\
+ vvv[0] = _v0; \
+ vvv[1] = _v1; \
+\
+ for (i=0; i<2; i++) { \
+ /* FIXME: swapped ! */ \
+ col[i][0] = vvv[!idx[i]]->v.color.red; \
+ col[i][1] = vvv[!idx[i]]->v.color.green; \
+ col[i][2] = vvv[!idx[i]]->v.color.blue; \
+ col[i][3] = vvv[!idx[i]]->v.color.alpha; \
+ } \
+\
+ if (dy01) { \
+\
+ ctmp = ((col[0][1] - col[1][1]) << 7) / dy01; \
+ ctmp2 = ((col[0][2] - col[1][2]) << 7) / dy01; \
+ deltgby = ((ctmp << 16) & 0xFFFF0000) | (ctmp2 & 0xFFFF); \
+\
+ ctmp3 = ((col[0][3] - col[1][3]) << 7) / dy01; \
+ ctmp4 = ((col[0][0] - col[1][0]) << 7) / dy01; \
+ deltary = ((ctmp3 << 16) & 0xFFFF0000) | (ctmp4 & 0xFFFF); \
+ } else { \
+ ctmp = ((col[1][1] - col[0][1]) << 7); \
+ ctmp2 = ((col[1][2] - col[0][2]) << 7); \
+ deltgby = ((ctmp << 16) & 0xFFFF0000) | (ctmp2 & 0xFFFF); \
+\
+ ctmp3 = ((col[1][3] - col[0][3]) << 7); \
+ ctmp4 = ((col[1][0] - col[0][0]) << 7); \
+ deltary = ((ctmp3 << 16) & 0xFFFF0000) | (ctmp4 & 0xFFFF); \
+ deltgby = deltary = 0; \
+ } \
+\
+ idx[0] = 1; /* FIXME: swapped */ \
+\
+ gbstart = \
+ (((int)((ydiff * ctmp) + (col[idx[0]][1] << 7)) << 16) & 0x7FFF0000) \
+ | ((int)((ydiff * ctmp2) + (col[idx[0]][2] << 7)) & 0x7FFF); \
+ arstart = \
+ (((int)((ydiff * ctmp3) + (col[idx[0]][3] << 7)) << 16) & 0x7FFF0000) \
+ | ((int)((ydiff * ctmp4) + (col[idx[0]][0] << 7)) & 0x7FFF); \
+} while(0)
+
+#define SEND_LINE_COL() \
+do { \
+ DMAOUT(deltgby); \
+ DMAOUT(deltary); \
+ DMAOUT(gbstart); \
+ DMAOUT(arstart); \
+} while (0)
+
+#define SEND_LINE_VERT() \
+do { \
+ DMAOUT(deltzy); \
+ DMAOUT(zstart); \
+ DMAOUT(0); \
+ DMAOUT(0); \
+ DMAOUT(0); \
+ DMAOUT(end01); \
+ DMAOUT(delt02); \
+ DMAOUT(start02); \
+ DMAOUT(ystart); \
+ DMAOUT(y01y12); \
+} while (0)
+
+
+/* tri macros (mostly stolen from utah-glx...) */
+
+#define VERT_VARS \
+ SWvertex v[3]; \
+ int x[3], y[3], z[3]; \
+ int idx[3]; \
+ int dx01, dy01; \
+ int dx02, dy02; \
+ int dx12, dy12; \
+ int delt01, delt02, delt12; \
+ int deltzx, deltzy, zstart; \
+ int start02, end01, end12; \
+ int ystart, y01y12; \
+ int i, tmp, lr; \
+ GLfloat ydiff, fy[3]
+#define VERT_VARS_VOIDS \
+ (void) v; (void) x; (void) y; (void) z; (void) idx; (void) dx01; \
+ (void) dy01; (void) dx02; (void) dy02; (void) dx12; (void) dy12; \
+ (void) delt01; (void) delt02; (void) delt12; (void) deltzx; \
+ (void) deltzy; (void) zstart; (void) start02; (void) end01; \
+ (void) end12; (void) ystart; (void) y01y12; (void) i; (void) tmp; \
+ (void) lr; (void) ydiff; (void) fy
+
+#define GOURAUD_VARS \
+ int arstart, gbstart; \
+ int deltarx, deltgbx, deltary, deltgby; \
+ int ctmp, ctmp2, ctmp3, ctmp4; \
+ GLubyte *(col)[3]
+#define GOURAUD_VARS_VOIDS \
+ (void) arstart; (void) gbstart; (void) deltarx; (void) deltgbx; \
+ (void) deltary; (void) deltgby; (void) ctmp; (void) ctmp2; \
+ (void) ctmp3; (void) ctmp4; (void) col
+
+#define FLAT_VARS \
+ int arstart, gbstart; \
+ int deltarx, deltgbx, deltary, deltgby; \
+ GLubyte *(col)[3]
+#define FLAT_VARS_VOIDS \
+ (void) arstart; (void) gbstart; (void) deltarx; (void) deltgbx; \
+ (void) deltary; (void) deltgby; (void) col
+
+#define TEX_VARS \
+ int u0, u1, u2; \
+ GLfloat ru0, ru1, ru2; \
+ int v0, v1, v2; \
+ GLfloat rv0, rv1, rv2; \
+ GLfloat w0, w1, w2; \
+ GLfloat rw0, rw1, rw2; \
+ int baseu, basev; \
+ int d0, d1, d2; \
+ int deltdx, deltvx, deltux, deltdy, deltvy, deltuy; \
+ int deltwx, deltwy; \
+ int rbaseu, rbasev; \
+ int dstart, ustart, wstart, vstart; \
+ static int stmp = 0; \
+ s3vTextureObjectPtr t
+#define TEX_VARS_VOIDS \
+ (void) u0; (void) u1; (void) u2; (void) ru0; (void) ru1; (void) ru2; \
+ (void) v0; (void) v1; (void) v2; (void) rv0; (void) rv1; (void) rv2; \
+ (void) w0; (void) w1; (void) w2; (void) rw0; (void) rw1; (void) rw2; \
+ (void) baseu; (void) basev; (void) d0; (void) d1; (void) d2; \
+ (void) deltdx; (void) deltvx; (void) deltux; (void) deltdy; \
+ (void) deltuy; (void) deltwx; (void) deltwy; (void) rbaseu; \
+ (void) rbasev; (void) dstart; (void) ustart; (void) wstart; \
+ (void) vstart; (void) stmp; (void) t
+
+#define SORT_VERT() \
+do { \
+ for (i=0; i<3; i++) \
+ fy[i] = v[i].win[1]; \
+\
+ if (fy[1] > fy[0]) { /* (fy[1] > fy[0]) */ \
+\
+ if (fy[2] > fy[0]) { \
+ idx[0] = 0; \
+ if (fy[1] > fy[2]) { \
+ idx[1] = 2; \
+ idx[2] = 1; \
+ } else { \
+ idx[1] = 1; \
+ idx[2] = 2; \
+ } \
+ } else { \
+ idx[0] = 2; \
+ idx[1] = 0; \
+ idx[2] = 1; \
+ } \
+ } else { /* (fy[1] < y[0]) */ \
+ if (fy[2] > fy[0]) { \
+ idx[0] = 1; \
+ idx[1] = 0; \
+ idx[2] = 2; \
+ } else { \
+ idx[2] = 0; \
+ if (fy[2] > fy[1]) { \
+ idx[0] = 1; \
+ idx[1] = 2; \
+ } else { \
+ idx[0] = 2; \
+ idx[1] = 1; \
+ } \
+ } \
+ } \
+} while(0)
+
+#define SET_VERT() \
+do { \
+ for (i=0; i<3; i++) \
+ { \
+ x[i] = ((v[idx[i]].win[0]) * /* 0x100000*/ 1024.0 * 1024.0); \
+ y[i] = fy[i] = (dPriv->h - v[idx[i]].win[1]); \
+ z[i] = ((v[idx[i]].win[2]) * /* 0x8000 */ 1024.0 * 32.0); \
+ } \
+\
+ ydiff = fy[0] - (float)y[0]; \
+\
+ ystart = y[0]; \
+\
+ dx12 = x[2] - x[1]; \
+ dy12 = y[1] - y[2]; \
+ dx01 = x[1] - x[0]; \
+ dy01 = y[0] - y[1]; \
+ dx02 = x[2] - x[0]; \
+ dy02 = y[0] - y[2]; \
+\
+ delt01 = delt02 = delt12 = 0; \
+} while (0)
+
+
+#define SET_XY() \
+do { \
+ if (dy01) delt01 = dx01 / dy01; \
+ if (dy12) delt12 = dx12 / dy12; \
+ delt02 = dx02 / dy02; \
+\
+ start02 = x[0] + (ydiff * delt02); \
+ end01 = x[0] + (ydiff * delt01); \
+ end12 = x[1] + ((fy[1] - (GLfloat)y[1]) * delt12); \
+} while (0)
+
+#define SET_DIR() \
+do { \
+ tmp = x[1] - (dy01 * delt02 + x[0]); \
+ if (tmp > 0) { \
+ lr = 0x80000000; \
+ } else { \
+ tmp *= -1; \
+ lr = 0; \
+ } \
+ tmp >>= 20; \
+\
+ y01y12 = ((((y[0] - y[1]) & 0x7FF) << 16) \
+ | ((y[1] - y[2]) & 0x7FF) | lr); \
+} while (0)
+
+#define SET_Z() \
+do { \
+ deltzy = (z[2] - z[0]) / dy02; \
+ if (tmp) { \
+ deltzx = (z[1] - (dy01 * deltzy + z[0])) / tmp; \
+ } else { \
+ deltzx = 0; \
+ } \
+ zstart = (deltzy * ydiff) + z[0]; \
+} while (0)
+
+#define SET_FLAT_COL() \
+do { \
+ col[0] = &(v[0].color[0]); \
+ deltarx = deltary = deltgbx = deltgby = 0; \
+ gbstart = (((col[0][1]) << 23) | ((col[0][2]) << 7)); \
+ arstart = (((col[0][3]) << 23) | ((col[0][0]) << 7)); \
+} while(0)
+
+#define SET_GOURAUD_COL() \
+do { \
+ col[0] = &(v[idx[0]].color[0]); \
+ col[1] = &(v[idx[1]].color[0]); \
+ col[2] = &(v[idx[2]].color[0]); \
+\
+ ctmp = ((col[2][3] - col[0][3]) << 7) / dy02; \
+ ctmp2 = ((col[2][0] - col[0][0]) << 7) / dy02; \
+ deltary = ((ctmp << 16) & 0xFFFF0000) | (ctmp2 & 0xFFFF); \
+ ctmp3 = ((col[2][1] - col[0][1]) << 7) / dy02; \
+ ctmp4 = ((col[2][2] - col[0][2]) << 7) / dy02; \
+ deltgby = ((ctmp3 << 16) & 0xFFFF0000) | (ctmp4 & 0xFFFF); \
+ gbstart = \
+ (((int)((ydiff * ctmp3) + (col[0][1] << 7)) << 16) & 0x7FFF0000) \
+ | ((int)((ydiff * ctmp4) + (col[0][2] << 7)) & 0x7FFF); \
+ arstart = \
+ (((int)((ydiff * ctmp) + (col[0][3] << 7)) << 16) & 0x7FFF0000) \
+ | ((int)((ydiff * ctmp2) + (col[0][0] << 7)) & 0x7FFF); \
+ if (tmp) { \
+ int ax, rx, gx, bx; \
+ ax = ((col[1][3] << 7) - (dy01 * ctmp + (col[0][3] << 7))) / tmp; \
+ rx = ((col[1][0] << 7) - (dy01 * ctmp2 + (col[0][0] << 7))) / tmp; \
+ gx = ((col[1][1] << 7) - (dy01 * ctmp3 + (col[0][1] << 7))) / tmp; \
+ bx = ((col[1][2] << 7) - (dy01 * ctmp4 + (col[0][2] << 7))) / tmp; \
+ deltarx = ((ax << 16) & 0xFFFF0000) | (rx & 0xFFFF); \
+ deltgbx = ((gx << 16) & 0xFFFF0000) | (bx & 0xFFFF); \
+ } else { \
+ deltgbx = deltarx = 0; \
+ } \
+} while (0)
+
+#define SET_TEX_VERT() \
+do { \
+ t = ((s3vTextureObjectPtr) \
+ ctx->Texture.Unit[0]._Current->DriverData); \
+ deltwx = deltwy = wstart = deltdx = deltdy = dstart = 0; \
+\
+ u0 = (v[idx[0]].texcoord[0][0] \
+ * (GLfloat)(t->image[0].image->Width) * 256.0); \
+ u1 = (v[idx[1]].texcoord[0][0] \
+ * (GLfloat)(t->globj->Image[0][0]->Width) * 256.0); \
+ u2 = (v[idx[2]].texcoord[0][0] \
+ * (GLfloat)(t->globj->Image[0][0]->Width) * 256.0); \
+ v0 = (v[idx[0]].texcoord[0][1] \
+ * (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \
+ v1 = (v[idx[1]].texcoord[0][1] \
+ * (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \
+ v2 = (v[idx[2]].texcoord[0][1] \
+ * (GLfloat)(t->globj->Image[0][0]->Height) * 256.0); \
+\
+ w0 = (v[idx[0]].win[3]); \
+ w1 = (v[idx[1]].win[3]); \
+ w2 = (v[idx[2]].win[3]); \
+} while (0)
+
+#define SET_BASEUV() \
+do { \
+ if (u0 < u1) { \
+ if (u0 < u2) { \
+ baseu = u0; \
+ } else { \
+ baseu = u2; \
+ } \
+ } else { \
+ if (u1 < u2) { \
+ baseu = u1; \
+ } else { \
+ baseu = u2; \
+ } \
+ } \
+\
+ if (v0 < v1) { \
+ if (v0 < v2) { \
+ basev = v0; \
+ } else { \
+ basev = v2; \
+ } \
+ } else { \
+ if (v1 < v2) { \
+ basev = v1; \
+ } else { \
+ basev = v2; \
+ } \
+ } \
+} while (0)
+
+
+#define SET_RW() \
+do { \
+ /* GLfloat minW; \
+\
+ if (w0 < w1) { \
+ if (w0 < w2) { \
+ minW = w0; \
+ } else { \
+ minW = w2; \
+ } \
+ } else { \
+ if (w1 < w2) { \
+ minW = w1; \
+ } else { \
+ minW = w2; \
+ } \
+ } */ \
+\
+ rw0 = (512.0 * w0); \
+ rw1 = (512.0 * w1); \
+ rw2 = (512.0 * w2); \
+} while (0)
+
+#define SET_D() \
+do { \
+ GLfloat sxy, suv; \
+ int lev; \
+\
+ suv = (v[idx[0]].texcoord[0][0] - \
+ v[idx[2]].texcoord[0][0]) * \
+ (v[idx[1]].texcoord[0][1] - \
+ v[idx[2]].texcoord[0][1]) - \
+ (v[idx[1]].texcoord[0][0] - \
+ v[idx[2]].texcoord[0][0]) * \
+ (v[idx[0]].texcoord[0][1] - \
+ v[idx[2]].texcoord[0][2]); \
+\
+ sxy = (v[idx[0]].texcoord[0][0] - \
+ v[idx[2]].texcoord[0][0]) * \
+ (v[idx[1]].texcoord[0][1] - \
+ v[idx[2]].texcoord[0][1]) - \
+ (v[idx[1]].texcoord[0][0] - \
+ v[idx[2]].texcoord[0][0]) * \
+ (v[idx[0]].texcoord[0][1] - \
+ v[idx[2]].texcoord[0][2]); \
+\
+ if (sxy < 0) sxy *= -1.0; \
+ if (suv < 0) suv *= -1.0; \
+\
+ lev = *(int*)&suv - *(int *)&sxy; \
+ if (lev < 0) \
+ lev = 0; \
+ else \
+ lev >>=23; \
+ dstart = (lev << 27); \
+} while (0)
+
+#define SET_UVWD() \
+do { \
+ SET_BASEUV(); \
+ SET_RW(); \
+ SET_D(); \
+ ru0 = (((u0 - baseu) * rw0)); \
+ ru1 = (((u1 - baseu) * rw1)); \
+ ru2 = (((u2 - baseu) * rw2)); \
+ rv0 = (((v0 - basev) * rw0)); \
+ rv1 = (((v1 - basev) * rw1)); \
+ rv2 = (((v2 - basev) * rw2)); \
+\
+ while (baseu < 0) { baseu += (t->globj->Image[0][0]->Width << 8); } \
+ while (basev < 0) { basev += (t->globj->Image[0][0]->Height << 8); } \
+\
+ if (!(baseu & 0xFF)) \
+ { baseu = (baseu >> 8); } \
+ else \
+ { baseu = (baseu >> 8) + 1; } \
+\
+ if ((basev & 0x80) || !(basev & 0xFF)) \
+ { basev = (basev >> 8); } \
+ else \
+ { basev = (basev >> 8) - 1; } \
+\
+ rbaseu = (baseu) << (16 - t->globj->Image[0][0]->WidthLog2); \
+ rbasev = (basev) << (16 - t->globj->Image[0][0]->WidthLog2); \
+ deltuy = (((ru2 - ru0) / dy02)); \
+ deltvy = (((rv2 - rv0) / dy02)); \
+ rw0 *= (1024.0 * 512.0); \
+ rw1 *= (1024.0 * 512.0); \
+ rw2 *= (1024.0 * 512.0); \
+ deltwy = ((rw2 - rw0) / dy02); \
+ if (tmp) { \
+ deltux = ((ru1 - (dy01 * deltuy + ru0)) / tmp); \
+ deltvx = ((rv1 - (dy01 * deltvy + rv0)) / tmp); \
+ deltwx = ((rw1 - (dy01 * deltwy + rw0)) / tmp); \
+ } else { deltux = deltvx = deltwx = 0; } \
+ ustart = (deltuy * ydiff) + (ru0); \
+ vstart = (deltvy * ydiff) + (rv0); \
+ wstart = (deltwy * ydiff) + (rw0); \
+} while (0)
+
+#define SEND_UVWD() \
+do { \
+ DMAOUT((rbasev & 0xFFFF)); \
+ DMAOUT((0xa0000000 | (rbaseu & 0xFFFF))); \
+ DMAOUT(deltwx); \
+ DMAOUT(deltwy); \
+ DMAOUT(wstart); \
+ DMAOUT(deltdx); \
+ DMAOUT(deltvx); \
+ DMAOUT(deltux); \
+ DMAOUT(deltdy); \
+ DMAOUT(deltvy); \
+ DMAOUT(deltuy); \
+ DMAOUT(dstart); \
+ DMAOUT(vstart); \
+ DMAOUT(ustart); \
+} while (0)
+
+#define SEND_VERT() \
+do { \
+ DMAOUT(deltzx); \
+ DMAOUT(deltzy); \
+ DMAOUT(zstart); \
+ DMAOUT(delt12); \
+ DMAOUT(end12); \
+ DMAOUT(delt01); \
+ DMAOUT(end01); \
+ DMAOUT(delt02); \
+ DMAOUT(start02); \
+ DMAOUT(ystart); \
+ DMAOUT(y01y12); \
+} while (0)
+
+#define SEND_COL() \
+do { \
+ DMAOUT(deltgbx); \
+ DMAOUT(deltarx); \
+ DMAOUT(deltgby); \
+ DMAOUT(deltary); \
+ DMAOUT(gbstart); \
+ DMAOUT(arstart); \
+} while (0)
+
+/**** MACROS end ****/
+
+
+
+
+static void TAG(s3v_point)( s3vContextPtr vmesa,
+ const s3vVertex *_v0 )
+{
+}
+
+static void TAG(s3v_line)( s3vContextPtr vmesa,
+ const s3vVertex *_v0,
+ const s3vVertex *_v1 )
+{
+ GLcontext *ctx = vmesa->glCtx;
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+
+ LINE_VERT_VARS;
+#if (IND & S3V_RAST_FLAT_BIT)
+ LINE_FLAT_VARS;
+#else
+ LINE_GOURAUD_VARS;
+#endif
+#if (IND & S3V_RAST_CULL_BIT)
+ GLfloat cull;
+ (void) cull;
+#endif
+ LINE_VERT_VARS_VOIDS;
+#if (IND & S3V_RAST_FLAT_BIT)
+ LINE_FLAT_VARS_VOIDS;
+#else
+ LINE_GOURAUD_VARS_VOIDS;
+#endif
+
+ DEBUG(("*** s3v_line: "));
+#if (IND & S3V_RAST_CULL_BIT)
+ DEBUG(("cull "));
+#endif
+#if (IND & S3V_RAST_FLAT_BIT)
+ DEBUG(("flat "));
+#endif
+
+ DEBUG(("***\n"));
+
+#if 0
+ s3v_print_vertex(ctx, _v0);
+ s3v_print_vertex(ctx, _v1);
+#endif
+
+ s3v_translate_vertex( ctx, _v0, &v[0] );
+ s3v_translate_vertex( ctx, _v1, &v[1] );
+
+#if (IND & S3V_RAST_CULL_BIT)
+ /* FIXME: should we cull lines too? */
+#endif
+ (void)v; /* v[0]; v[1]; */
+
+ SORT_LINE_VERT();
+ SET_LINE_VERT();
+
+ SET_LINE_XY();
+ SET_LINE_DIR();
+ SET_LINE_Z();
+
+#if (IND & S3V_RAST_FLAT_BIT)
+ SET_LINE_FLAT_COL();
+#else
+ SET_LINE_GOURAUD_COL();
+#endif
+
+ DMAOUT_CHECK(3DLINE_GBD, 15);
+ SEND_LINE_COL();
+ DMAOUT(0);
+ SEND_LINE_VERT();
+ DMAFINISH();
+}
+
+static void TAG(s3v_triangle)( s3vContextPtr vmesa,
+ const s3vVertex *_v0,
+ const s3vVertex *_v1,
+ const s3vVertex *_v2 )
+{
+ GLcontext *ctx = vmesa->glCtx;
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+
+ VERT_VARS;
+#if (IND & S3v_RAST_FLAT_BIT)
+ FLAT_VARS;
+#else
+ GOURAUD_VARS;
+#endif
+#if (IND & S3V_RAST_TEX_BIT)
+ TEX_VARS;
+#endif
+#if (IND & S3V_RAST_CULL_BIT)
+ GLfloat cull;
+#endif
+ VERT_VARS_VOIDS;
+#if (IND & S3v_RAST_FLAT_BIT)
+ FLAT_VARS_VOIDS;
+#else
+ GOURAUD_VARS_VOIDS;
+#endif
+#if (IND & S3V_RAST_TEX_BIT)
+ TEX_VARS_VOIDS;
+#endif
+
+ DEBUG(("*** s3v_triangle: "));
+#if (IND & S3V_RAST_CULL_BIT)
+ DEBUG(("cull "));
+#endif
+#if (IND & S3V_RAST_FLAT_BIT)
+ DEBUG(("flat "));
+#endif
+#if (IND & S3V_RAST_TEX_BIT)
+ DEBUG(("tex "));
+#endif
+
+DEBUG(("***\n"));
+
+#if 0
+ s3v_print_vertex(ctx, _v0);
+ s3v_print_vertex(ctx, _v1);
+ s3v_print_vertex(ctx, _v2);
+#endif
+
+ s3v_translate_vertex( ctx, _v0, &v[0] );
+ s3v_translate_vertex( ctx, _v1, &v[1] );
+ s3v_translate_vertex( ctx, _v2, &v[2] );
+
+#if (IND & S3V_RAST_CULL_BIT)
+ cull = vmesa->backface_sign *
+ ((v[1].win[0] - v[0].win[0]) * (v[0].win[1] - v[2].win[1]) +
+ (v[1].win[1] - v[0].win[1]) * (v[2].win[0] - v[0].win[0]));
+
+ if (cull < vmesa->cull_zero /* -0.02f */) return;
+#endif
+
+ (void)v; /* v[0]; v[1]; v[2]; */
+
+ SORT_VERT();
+ SET_VERT();
+
+ if (dy02 == 0) return;
+
+ SET_XY();
+ SET_DIR();
+ SET_Z();
+
+#if (IND & S3V_RAST_TEX_BIT)
+ SET_TEX_VERT();
+ SET_UVWD();
+#endif
+
+#if (IND & S3V_RAST_FLAT_BIT)
+ SET_FLAT_COL();
+#else
+ SET_GOURAUD_COL();
+#endif
+
+#if (IND & S3V_RAST_TEX_BIT)
+ DMAOUT_CHECK(3DTRI_BASEV, 31);
+ SEND_UVWD();
+ SEND_COL();
+ SEND_VERT();
+ DMAFINISH();
+#else
+ DMAOUT_CHECK(3DTRI_GBX, 17);
+ SEND_COL();
+ SEND_VERT();
+ DMAFINISH();
+#endif
+}
+
+static void TAG(s3v_quad)( s3vContextPtr vmesa,
+ const s3vVertex *_v0,
+ const s3vVertex *_v1,
+ const s3vVertex *_v2,
+ const s3vVertex *_v3 )
+{
+ GLcontext *ctx = vmesa->glCtx;
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+
+ SWvertex temp_v[4];
+ VERT_VARS;
+#if (IND & S3v_RAST_FLAT_BIT)
+ FLAT_VARS;
+#else
+ GOURAUD_VARS;
+#endif
+#if (IND & S3V_RAST_TEX_BIT)
+ TEX_VARS;
+#endif
+#if (IND & S3V_RAST_CULL_BIT)
+ GLfloat cull;
+#endif
+ VERT_VARS_VOIDS;
+#if (IND & S3v_RAST_FLAT_BIT)
+ FLAT_VARS_VOIDS;
+#else
+ GOURAUD_VARS_VOIDS;
+#endif
+#if (IND & S3V_RAST_TEX_BIT)
+ TEX_VARS_VOIDS;
+#endif
+
+ DEBUG(("*** s3v_quad: "));
+#if (IND & S3V_RAST_CULL_BIT)
+ DEBUG(("cull "));
+ /* printf(""); */ /* speed trick */
+#endif
+#if (IND & S3V_RAST_FLAT_BIT)
+ DEBUG(("flat "));
+#endif
+#if (IND & S3V_RAST_TEX_BIT)
+ DEBUG(("tex "));
+#endif
+
+ DEBUG(("***\n"));
+
+#if 0
+ s3v_print_vertex(ctx, _v0);
+ s3v_print_vertex(ctx, _v1);
+ s3v_print_vertex(ctx, _v2);
+ s3v_print_vertex(ctx, _v3);
+#endif
+ s3v_translate_vertex( ctx, _v0, &temp_v[0] );
+ s3v_translate_vertex( ctx, _v1, &temp_v[1] );
+ s3v_translate_vertex( ctx, _v2, &temp_v[2] );
+ s3v_translate_vertex( ctx, _v3, &temp_v[3] );
+
+ /* FIRST TRI (0,1,2) */
+
+ /* ROMEO */
+ /* printf(""); */ /* speed trick (a) [turn on if (a) is return]*/
+
+ v[0] = temp_v[0];
+ v[1] = temp_v[1];
+ v[2] = temp_v[2];
+
+#if (IND & S3V_RAST_CULL_BIT)
+ cull = vmesa->backface_sign *
+ ((v[1].win[0] - v[0].win[0]) * (v[0].win[1] - v[2].win[1]) +
+ (v[1].win[1] - v[0].win[1]) * (v[2].win[0] - v[0].win[0]));
+
+ if (cull < vmesa->cull_zero /* -0.02f */) goto second; /* return; */ /* (a) */
+#endif
+
+#if 0
+ v[0] = temp_v[0];
+ v[1] = temp_v[1];
+ v[2] = temp_v[2];
+#else
+ (void) v;
+#endif
+ SORT_VERT();
+ SET_VERT();
+
+ if (dy02 == 0) goto second;
+
+ SET_XY();
+ SET_DIR();
+ SET_Z();
+
+#if (IND & S3V_RAST_TEX_BIT)
+ SET_TEX_VERT();
+ SET_UVWD();
+#endif
+
+#if (IND & S3V_RAST_FLAT_BIT)
+ SET_FLAT_COL();
+#else
+ SET_GOURAUD_COL();
+#endif
+
+#if (IND & S3V_RAST_TEX_BIT)
+ DMAOUT_CHECK(3DTRI_BASEV, 31);
+ SEND_UVWD();
+ SEND_COL();
+ SEND_VERT();
+ DMAFINISH();
+#else
+ DMAOUT_CHECK(3DTRI_GBX, 17);
+ SEND_COL();
+ SEND_VERT();
+ DMAFINISH();
+#endif
+
+ /* SECOND TRI (0,2,3) */
+
+second:
+ v[0] = temp_v[0];
+ v[1] = temp_v[2];
+ v[2] = temp_v[3];
+
+#if (IND & S3V_RAST_CULL_BIT)
+ cull = vmesa->backface_sign *
+ ((v[1].win[0] - v[0].win[0]) * (v[0].win[1] - v[2].win[1]) +
+ (v[1].win[1] - v[0].win[1]) * (v[2].win[0] - v[0].win[0]));
+
+ if (cull < /* -0.02f */ vmesa->cull_zero) return;
+#endif
+
+/* second: */
+
+ /* ROMEO */
+ /* printf(""); */ /* speed trick */
+
+ v[0] = temp_v[0];
+ v[1] = temp_v[2];
+ v[2] = temp_v[3];
+
+ SORT_VERT();
+ SET_VERT();
+
+ if (dy02 == 0) return;
+
+ SET_XY();
+ SET_DIR();
+ SET_Z();
+
+#if (IND & S3V_RAST_TEX_BIT)
+ SET_TEX_VERT();
+ SET_UVWD();
+#endif
+
+#if (IND & S3V_RAST_FLAT_BIT)
+ SET_FLAT_COL();
+#else
+ SET_GOURAUD_COL();
+#endif
+
+#if (IND & S3V_RAST_TEX_BIT)
+ DMAOUT_CHECK(3DTRI_BASEV, 31);
+ SEND_UVWD();
+ SEND_COL();
+ SEND_VERT();
+ DMAFINISH();
+#else
+ DMAOUT_CHECK(3DTRI_GBX, 17);
+ SEND_COL();
+ SEND_VERT();
+ DMAFINISH();
+#endif
+}
+
+static void TAG(s3v_init)(void)
+{
+ s3v_point_tab[IND] = TAG(s3v_point);
+ s3v_line_tab[IND] = TAG(s3v_line);
+ s3v_tri_tab[IND] = TAG(s3v_triangle);
+ s3v_quad_tab[IND] = TAG(s3v_quad);
+}
+
+#undef IND
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_vb.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_vb.c
new file mode 100644
index 000000000..dadf2b489
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_vb.c
@@ -0,0 +1,339 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "colormac.h"
+
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/t_context.h"
+#include "tnl/tnl.h"
+
+#include "s3v_context.h"
+#include "s3v_vb.h"
+#include "s3v_tris.h"
+
+#define S3V_XYZW_BIT 0x1
+#define S3V_RGBA_BIT 0x2
+#define S3V_TEX0_BIT 0x4
+#define S3V_PTEX_BIT 0x8
+#define S3V_FOG_BIT 0x10
+#define S3V_MAX_SETUP 0x20
+
+static struct {
+ void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
+ tnl_interp_func interp;
+ tnl_copy_pv_func copy_pv;
+ GLboolean (*check_tex_sizes)( GLcontext *ctx );
+ GLuint vertex_size;
+ GLuint vertex_stride_shift;
+ GLuint vertex_format;
+} setup_tab[S3V_MAX_SETUP];
+
+
+/* Only one vertex format, atm, so no need to give them names:
+ */
+#define TINY_VERTEX_FORMAT 1
+#define NOTEX_VERTEX_FORMAT 0
+#define TEX0_VERTEX_FORMAT 0
+#define TEX1_VERTEX_FORMAT 0
+#define PROJ_TEX1_VERTEX_FORMAT 0
+#define TEX2_VERTEX_FORMAT 0
+#define TEX3_VERTEX_FORMAT 0
+#define PROJ_TEX3_VERTEX_FORMAT 0
+
+#define DO_XYZW (IND & S3V_XYZW_BIT)
+#define DO_RGBA (IND & S3V_RGBA_BIT)
+#define DO_SPEC 0
+#define DO_FOG (IND & S3V_FOG_BIT)
+#define DO_TEX0 (IND & S3V_TEX0_BIT)
+#define DO_TEX1 0
+#define DO_TEX2 0
+#define DO_TEX3 0
+#define DO_PTEX (IND & S3V_PTEX_BIT)
+
+#define VERTEX s3vVertex
+#define LOCALVARS /* s3vContextPtr vmesa = S3V_CONTEXT(ctx); */
+#define GET_VIEWPORT_MAT() 0 /* vmesa->hw_viewport */
+#define GET_TEXSOURCE(n) n
+#define GET_VERTEX_FORMAT() 0
+#define GET_VERTEX_SIZE() S3V_CONTEXT(ctx)->vertex_size * sizeof(GLuint)
+#define GET_VERTEX_STORE() S3V_CONTEXT(ctx)->verts
+#define GET_VERTEX_STRIDE_SHIFT() S3V_CONTEXT(ctx)->vertex_stride_shift
+#define INVALIDATE_STORED_VERTICES()
+#define GET_UBYTE_COLOR_STORE() &S3V_CONTEXT(ctx)->UbyteColor
+#define GET_UBYTE_SPEC_COLOR_STORE() &S3V_CONTEXT(ctx)->UbyteSecondaryColor
+
+#define HAVE_HW_VIEWPORT 1 /* FIXME */
+#define HAVE_HW_DIVIDE 1
+#define HAVE_RGBA_COLOR 0 /* we're BGRA */
+#define HAVE_TINY_VERTICES 1
+#define HAVE_NOTEX_VERTICES 0
+#define HAVE_TEX0_VERTICES 0
+#define HAVE_TEX1_VERTICES 0
+#define HAVE_TEX2_VERTICES 0
+#define HAVE_TEX3_VERTICES 0
+#define HAVE_PTEX_VERTICES 1
+
+/*
+#define SUBPIXEL_X -.5
+#define SUBPIXEL_Y -.5
+#define UNVIEWPORT_VARS GLfloat h = S3V_CONTEXT(ctx)->driDrawable->h
+#define UNVIEWPORT_X(x) x - SUBPIXEL_X
+#define UNVIEWPORT_Y(y) - y + h + SUBPIXEL_Y
+#define UNVIEWPORT_Z(z) z / vmesa->depth_scale
+*/
+
+#define PTEX_FALLBACK() /* never needed */
+
+#define IMPORT_QUALIFIER
+#define IMPORT_FLOAT_COLORS s3v_import_float_colors
+#define IMPORT_FLOAT_SPEC_COLORS s3v_import_float_spec_colors
+
+#define INTERP_VERTEX setup_tab[S3V_CONTEXT(ctx)->SetupIndex].interp
+#define COPY_PV_VERTEX setup_tab[S3V_CONTEXT(ctx)->SetupIndex].copy_pv
+
+
+
+/***********************************************************************
+ * Generate pv-copying and translation functions *
+ ***********************************************************************/
+
+#define TAG(x) s3v_##x
+#include "tnl_dd/t_dd_vb.c"
+
+/***********************************************************************
+ * Generate vertex emit and interp functions *
+ ***********************************************************************/
+
+
+#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT)
+#define TAG(x) x##_wg
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT|S3V_TEX0_BIT)
+#define TAG(x) x##_wgt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT|S3V_TEX0_BIT|S3V_PTEX_BIT)
+#define TAG(x) x##_wgpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (S3V_TEX0_BIT)
+#define TAG(x) x##_t0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (S3V_RGBA_BIT)
+#define TAG(x) x##_g
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (S3V_RGBA_BIT|S3V_TEX0_BIT)
+#define TAG(x) x##_gt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT|S3V_FOG_BIT)
+#define TAG(x) x##_wgf
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT|S3V_FOG_BIT|S3V_TEX0_BIT)
+#define TAG(x) x##_wgft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (S3V_XYZW_BIT|S3V_RGBA_BIT|S3V_FOG_BIT|S3V_TEX0_BIT|S3V_PTEX_BIT)
+#define TAG(x) x##_wgfpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (S3V_FOG_BIT)
+#define TAG(x) x##_f
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (S3V_RGBA_BIT | S3V_FOG_BIT)
+#define TAG(x) x##_gf
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (S3V_RGBA_BIT | S3V_FOG_BIT | S3V_TEX0_BIT)
+#define TAG(x) x##_gft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+static void init_setup_tab( void )
+{
+ init_wg(); /* pos + col */
+ init_wgt0(); /* pos + col + tex0 */
+ init_wgpt0(); /* pos + col + p-tex0 (?) */
+ init_t0(); /* tex0 */
+ init_g(); /* col */
+ init_gt0(); /* col + tex */
+ init_wgf();
+ init_wgft0();
+ init_wgfpt0();
+ init_f();
+ init_gf();
+ init_gft0();
+}
+
+
+#if 0
+void s3vPrintSetupFlags(char *msg, GLuint flags )
+{
+ fprintf(stderr, "%s(%x): %s%s%s%s%s%s\n",
+ msg,
+ (int)flags,
+ (flags & S3V_XYZW_BIT) ? " xyzw," : "",
+ (flags & S3V_RGBA_BIT) ? " rgba," : "",
+ (flags & S3V_SPEC_BIT) ? " spec," : "",
+ (flags & S3V_FOG_BIT) ? " fog," : "",
+ (flags & S3V_TEX0_BIT) ? " tex-0," : "",
+ (flags & S3V_TEX1_BIT) ? " tex-1," : "");
+}
+#endif
+
+
+void s3vCheckTexSizes( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ s3vContextPtr vmesa = S3V_CONTEXT( ctx );
+
+ if (!setup_tab[vmesa->SetupIndex].check_tex_sizes(ctx)) {
+
+ vmesa->SetupIndex |= (S3V_PTEX_BIT|S3V_RGBA_BIT);
+
+ if (1 || !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ tnl->Driver.Render.Interp = setup_tab[vmesa->SetupIndex].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[vmesa->SetupIndex].copy_pv;
+ }
+ }
+}
+
+void s3vBuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT( ctx );
+ GLubyte *v = ((GLubyte *)vmesa->verts +
+ (start<<vmesa->vertex_stride_shift));
+ GLuint stride = 1<<vmesa->vertex_stride_shift;
+
+ DEBUG(("*** s3vBuildVertices ***\n"));
+ DEBUG(("vmesa->SetupNewInputs = 0x%x\n", vmesa->SetupNewInputs));
+ DEBUG(("vmesa->SetupIndex = 0x%x\n", vmesa->SetupIndex));
+
+#if 1
+ setup_tab[vmesa->SetupIndex].emit( ctx, start, count, v, stride );
+#else
+ newinputs |= vmesa->SetupNewInputs;
+ vmesa->SetupNewInputs = 0;
+
+ DEBUG(("newinputs is 0x%x\n", newinputs));
+
+ if (!newinputs) {
+ DEBUG(("!newinputs\n"));
+ return;
+ }
+
+ if (newinputs & VERT_CLIP) {
+ setup_tab[vmesa->SetupIndex].emit( ctx, start, count, v, stride );
+ DEBUG(("newinputs & VERT_CLIP\n"));
+ return;
+ } /* else { */
+/* GLuint ind = 0; */
+
+ if (newinputs & VERT_RGBA) {
+ DEBUG(("newinputs & VERT_RGBA\n"));
+ ind |= S3V_RGBA_BIT;
+ }
+
+ if (newinputs & VERT_TEX0) {
+ DEBUG(("newinputs & VERT_TEX0\n"));
+ ind |= S3V_TEX0_BIT;
+ }
+
+ if (newinputs & VERT_FOG_COORD)
+ ind |= S3V_FOG_BIT;
+
+ if (vmesa->SetupIndex & S3V_PTEX_BIT)
+ ind = ~0;
+
+ ind &= vmesa->SetupIndex;
+
+ DEBUG(("vmesa->SetupIndex = 0x%x\n", vmesa->SetupIndex));
+ DEBUG(("ind = 0x%x\n", ind));
+ DEBUG(("ind & vmesa->SetupIndex = 0x%x\n", (ind & vmesa->SetupIndex)));
+
+ if (ind) {
+ setup_tab[ind].emit( ctx, start, count, v, stride );
+ }
+#endif
+}
+
+void s3vChooseVertexState( GLcontext *ctx )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ GLuint ind = S3V_XYZW_BIT | S3V_RGBA_BIT;
+
+ /* FIXME: will segv in tnl_dd/t_dd_vbtmp.h (line 196) on some demos */
+/*
+ if (ctx->Fog.Enabled)
+ ind |= S3V_FOG_BIT;
+*/
+
+
+ if (ctx->Texture.Unit[0]._ReallyEnabled) {
+ _tnl_need_projected_coords( ctx, GL_FALSE );
+ ind |= S3V_TEX0_BIT;
+ } else {
+ _tnl_need_projected_coords( ctx, GL_TRUE );
+ }
+
+ vmesa->SetupIndex = ind;
+
+ if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
+ tnl->Driver.Render.Interp = s3v_interp_extras;
+ tnl->Driver.Render.CopyPV = s3v_copy_pv_extras;
+ } else {
+ tnl->Driver.Render.Interp = setup_tab[ind].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
+ }
+}
+
+
+void s3vInitVB( GLcontext *ctx )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ GLuint size = TNL_CONTEXT(ctx)->vb.Size;
+
+ vmesa->verts = (char *)ALIGN_MALLOC(size * 4 * 16, 32);
+
+ {
+ static int firsttime = 1;
+ if (firsttime) {
+ init_setup_tab();
+ firsttime = 0;
+ vmesa->vertex_stride_shift = 6 /* 4 */; /* FIXME - only one vertex setup */
+ }
+ }
+}
+
+
+void s3vFreeVB( GLcontext *ctx )
+{
+ s3vContextPtr vmesa = S3V_CONTEXT(ctx);
+ if (vmesa->verts) {
+ ALIGN_FREE(vmesa->verts);
+ vmesa->verts = 0;
+ }
+
+ if (vmesa->UbyteSecondaryColor.Ptr) {
+ ALIGN_FREE((void *)vmesa->UbyteSecondaryColor.Ptr);
+ vmesa->UbyteSecondaryColor.Ptr = 0;
+ }
+
+ if (vmesa->UbyteColor.Ptr) {
+ ALIGN_FREE((void *)vmesa->UbyteColor.Ptr);
+ vmesa->UbyteColor.Ptr = 0;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_vb.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_vb.h
new file mode 100644
index 000000000..b35d804e6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_vb.h
@@ -0,0 +1,39 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#ifndef S3VVB_INC
+#define S3VVB_INC
+
+#include "mtypes.h"
+#include "swrast/swrast.h"
+
+#define _S3V_NEW_VERTEX (_NEW_TEXTURE | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE)
+
+
+extern void s3vChooseVertexState( GLcontext *ctx );
+extern void s3vCheckTexSizes( GLcontext *ctx );
+extern void s3vBuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs );
+
+
+extern void s3v_import_float_colors( GLcontext *ctx );
+extern void s3v_import_float_spec_colors( GLcontext *ctx );
+
+extern void s3v_translate_vertex( GLcontext *ctx,
+ const s3vVertex *src,
+ SWvertex *dst );
+
+extern void s3vInitVB( GLcontext *ctx );
+extern void s3vFreeVB( GLcontext *ctx );
+
+extern void s3v_print_vertex( GLcontext *ctx, const s3vVertex *v );
+#if 0
+extern void s3vPrintSetupFlags(char *msg, GLuint flags );
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_xmesa.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_xmesa.c
new file mode 100644
index 000000000..4cdda1b58
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3v_xmesa.c
@@ -0,0 +1,362 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#include "s3v_context.h"
+#include "s3v_vb.h"
+#include "context.h"
+#include "matrix.h"
+#include "s3v_dri.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "array_cache/acache.h"
+
+/* #define DEBUG(str) printf str */
+
+static GLboolean
+s3vInitDriver(__DRIscreenPrivate *sPriv)
+{
+ sPriv->private = (void *) s3vCreateScreen( sPriv );
+
+ if (!sPriv->private) {
+ s3vDestroyScreen( sPriv );
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+static void
+s3vDestroyContext(__DRIcontextPrivate *driContextPriv)
+{
+ s3vContextPtr vmesa = (s3vContextPtr)driContextPriv->driverPrivate;
+
+ if (vmesa) {
+ _swsetup_DestroyContext( vmesa->glCtx );
+ _tnl_DestroyContext( vmesa->glCtx );
+ _ac_DestroyContext( vmesa->glCtx );
+ _swrast_DestroyContext( vmesa->glCtx );
+
+ s3vFreeVB( vmesa->glCtx );
+
+ /* free the Mesa context */
+ vmesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(vmesa->glCtx);
+
+ _mesa_free(vmesa);
+ driContextPriv->driverPrivate = NULL;
+ }
+}
+
+
+static GLboolean
+s3vCreateBuffer( __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ s3vScreenPtr screen = (s3vScreenPtr) driScrnPriv->private;
+
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+#if 0
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ mesaVis->alphaBits > 0
+ );
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->frontPitch);
+ s3vSetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ s3vSetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ s3vSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ s3vSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ /* no h/w stencil yet?
+ if (mesaVis->stencilBits > 0) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT);
+ s3vSetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+ */
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+
+static void
+s3vDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+static void
+s3vSwapBuffers(__DRIdrawablePrivate *drawablePrivate)
+{
+ __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
+ __DRIscreenPrivate *sPriv;
+ GLcontext *ctx;
+ s3vContextPtr vmesa;
+ s3vScreenPtr s3vscrn;
+
+ vmesa = (s3vContextPtr) dPriv->driContextPriv->driverPrivate;
+ sPriv = vmesa->driScreen;
+ s3vscrn = vmesa->s3vScreen;
+ ctx = vmesa->glCtx;
+
+ DEBUG(("*** s3vSwapBuffers ***\n"));
+
+/* DMAFLUSH(); */
+
+ _mesa_notifySwapBuffers( ctx );
+
+ vmesa = (s3vContextPtr) dPriv->driContextPriv->driverPrivate;
+/* driScrnPriv = vmesa->driScreen; */
+
+/* if (vmesa->EnabledFlags & S3V_BACK_BUFFER) */
+
+/* _mesa_notifySwapBuffers( ctx ); */
+#if 1
+{
+ int x0, y0, x1, y1;
+/*
+ int nRect = dPriv->numClipRects;
+ XF86DRIClipRectPtr pRect = dPriv->pClipRects;
+
+ __DRIscreenPrivate *driScrnPriv = vmesa->driScreen;
+*/
+
+/*
+ DEBUG(("s3vSwapBuffers: S3V_BACK_BUFFER = 1 - nClip = %i\n", nRect));
+*/
+/* vmesa->drawOffset=vmesa->s3vScreen->backOffset; */
+
+ x0 = dPriv->x;
+ y0 = dPriv->y;
+
+ x1 = x0 + dPriv->w - 1;
+ y1 = y0 + dPriv->h - 1;
+
+ DMAOUT_CHECK(BITBLT_SRC_BASE, 15);
+ DMAOUT(vmesa->s3vScreen->backOffset);
+ DMAOUT(0); /* 0xc0000000 */
+ DMAOUT( ((x0 << 16) | x1) );
+ DMAOUT( ((y0 << 16) | y1) );
+ DMAOUT( (vmesa->DestStride << 16) | vmesa->SrcStride );
+ DMAOUT( (~(0)) );
+ DMAOUT( (~(0)) );
+ DMAOUT(0);
+ DMAOUT(0);
+ /* FIXME */
+ DMAOUT(0);
+ DMAOUT(0);
+ DMAOUT( (0x01 | /* Autoexecute */
+ 0x02 | /* clip */
+ 0x04 | /* 16 bit */
+ 0x20 | /* draw */
+ 0x400 | /* word alignment (bit 10=1) */
+ (0x2 << 11) | /* offset = 1 byte */
+ (0xCC << 17) | /* rop #204 */
+ (0x3 << 25)) ); /* l-r, t-b */
+ DMAOUT(vmesa->ScissorWH);
+ DMAOUT( /* 0 */ vmesa->SrcXY );
+ DMAOUT( (dPriv->x << 16) | dPriv->y );
+ DMAFINISH();
+
+ DMAFLUSH();
+
+ vmesa->restore_primitive = -1;
+
+}
+#endif
+}
+
+static GLboolean
+s3vMakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
+{
+ int x1,x2,y1,y2;
+ int cx, cy, cw, ch;
+ unsigned int src_stride, dest_stride;
+ int cl;
+
+ s3vContextPtr vmesa;
+ __DRIdrawablePrivate *dPriv = driDrawPriv;
+ vmesa = (s3vContextPtr) dPriv->driContextPriv->driverPrivate;
+
+ DEBUG(("s3vMakeCurrent\n"));
+
+ DEBUG(("dPriv->x=%i y=%i w=%i h=%i\n", dPriv->x, dPriv->y,
+ dPriv->w, dPriv->h));
+
+ if (driContextPriv) {
+ GET_CURRENT_CONTEXT(ctx);
+ s3vContextPtr oldVirgeCtx = ctx ? S3V_CONTEXT(ctx) : NULL;
+ s3vContextPtr newVirgeCtx = (s3vContextPtr) driContextPriv->driverPrivate;
+
+ if ( newVirgeCtx != oldVirgeCtx ) {
+
+ newVirgeCtx->dirty = ~0;
+ cl = 1;
+ DEBUG(("newVirgeCtx != oldVirgeCtx\n"));
+/* s3vUpdateClipping(newVirgeCtx->glCtx ); */
+ }
+
+ if (newVirgeCtx->driDrawable != driDrawPriv) {
+ newVirgeCtx->driDrawable = driDrawPriv;
+ DEBUG(("driDrawable != driDrawPriv\n"));
+ s3vUpdateWindow ( newVirgeCtx->glCtx );
+ s3vUpdateViewportOffset( newVirgeCtx->glCtx );
+/* s3vUpdateClipping(newVirgeCtx->glCtx ); */
+ }
+/*
+ s3vUpdateWindow ( newVirgeCtx->glCtx );
+ s3vUpdateViewportOffset( newVirgeCtx->glCtx );
+*/
+
+/*
+ _mesa_make_current( newVirgeCtx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
+
+ _mesa_set_viewport(newVirgeCtx->glCtx, 0, 0,
+ newVirgeCtx->driDrawable->w,
+ newVirgeCtx->driDrawable->h);
+*/
+
+#if 0
+ newVirgeCtx->Window &= ~W_GIDMask;
+ newVirgeCtx->Window |= (driDrawPriv->index << 5);
+ CHECK_DMA_BUFFER(newVirgeCtx,1);
+ WRITE(newVirgeCtx->buf, S3VWindow, newVirgeCtx->Window);
+#endif
+
+ newVirgeCtx->new_state |= S3V_NEW_WINDOW; /* FIXME */
+
+ _mesa_make_current( newVirgeCtx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
+
+ if (!newVirgeCtx->glCtx->Viewport.Width) {
+ _mesa_set_viewport(newVirgeCtx->glCtx, 0, 0,
+ driDrawPriv->w, driDrawPriv->h);
+
+/* s3vUpdateClipping(newVirgeCtx->glCtx ); */
+ }
+
+/*
+ if (cl) {
+ s3vUpdateClipping(newVirgeCtx->glCtx );
+ cl =0;
+ }
+*/
+
+ newVirgeCtx->new_state |= S3V_NEW_CLIP;
+
+ if (1) {
+ cx = dPriv->x;
+ cw = dPriv->w;
+ cy = dPriv->y;
+ ch = dPriv->h;
+ }
+
+ x1 = y1 = 0;
+ x2 = cw-1;
+ y2 = ch-1;
+
+ /* src_stride = vmesa->s3vScreen->w * vmesa->s3vScreen->cpp;
+ dest_stride = ((x2+31)&~31) * vmesa->s3vScreen->cpp; */
+ src_stride = vmesa->driScreen->fbWidth * 2;
+ dest_stride = ((x2+31)&~31) * 2;
+ } else {
+ _mesa_make_current( NULL, NULL, NULL );
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+s3vUnbindContext( __DRIcontextPrivate *driContextPriv )
+{
+ return GL_TRUE;
+}
+
+
+static struct __DriverAPIRec s3vAPI = {
+ s3vInitDriver,
+ s3vDestroyScreen,
+ s3vCreateContext,
+ s3vDestroyContext,
+ s3vCreateBuffer,
+ s3vDestroyBuffer,
+ s3vSwapBuffers,
+ s3vMakeCurrent,
+ s3vUnbindContext,
+};
+
+
+#if 0
+/*
+ * This is the bootstrap function for the driver.
+ * The __driCreateScreen name is the symbol that libGL.so fetches.
+ * Return: pointer to a __DRIscreenPrivate.
+ */
+void *__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config)
+{
+ __DRIscreenPrivate *psp=NULL;
+
+ DEBUG(("__driCreateScreen: psp = %p\n", psp));
+ psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &s3vAPI);
+ DEBUG(("__driCreateScreen: psp = %p\n", psp));
+ return (void *) psp;
+}
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3virgetri.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3virgetri.h
new file mode 100644
index 000000000..5519cfd74
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/s3v/s3virgetri.h
@@ -0,0 +1,383 @@
+/*
+ * Author: Max Lingua <sunmax@libero.it>
+ */
+
+#define LOCAL_VARS \
+ int vert0, vert1, vert2; \
+ GLfloat y0, y1, y2, ydiff; \
+ int iy0, iy1, iy2; \
+ int x0, x1, x2, z0, z1, z2; \
+ int dy01, dy02, dy12, dx01, dx02, dx12; \
+ int delt02, delt01, delt12, end01, end12, start02; \
+ int zstart, arstart, gbstart; \
+ int deltzy, deltzx, deltarx, deltgbx, deltary, deltgby; \
+ GLubyte (*colours)[4]; \
+ GLubyte (*scolours)[4]; \
+ static int tp = 0; \
+ int tmp, lr
+
+#define LOCAL_TEX_VARS \
+ int u0, u1, u2; \
+ GLfloat ru0, ru1, ru2; \
+ int v0, v1, v2; \
+ GLfloat rv0, rv1, rv2; \
+ GLfloat w0, w1, w2; \
+ GLfloat rw0, rw1, rw2; \
+ int baseu, basev; \
+ int d0, d1, d2; \
+ int deltdx, deltvx, deltux, deltdy, deltvy, deltuy; \
+ int deltwx, deltwy; \
+ int rbaseu, rbasev; \
+ int dstart, ustart, wstart, vstart; \
+ static int stmp = 0; \
+ s3virgeTextureObject_t *t
+
+#define CULL_BACKFACE() \
+ do { \
+ GLfloat *w0 = VB->Win.data[e0]; \
+ GLfloat *w1 = VB->Win.data[e1]; \
+ GLfloat *w2 = VB->Win.data[e2]; \
+ float cull; \
+ cull = ctx->backface_sign * ((w1[0] - w0[0]) * (w0[1] - w2[1]) + \
+ (w1[1] - w0[1]) * (w2[0] - w0[0])); \
+ if (cull < 0) \
+ return; \
+ } while (0)
+
+#define SORT_VERTICES() \
+ do { \
+ y0 = VB->Win.data[e0][1]; \
+ y1 = VB->Win.data[e1][1]; \
+ y2 = VB->Win.data[e2][1]; \
+ if (y1 > y0) { \
+ if (y2 > y0) { \
+ vert0 = e0; \
+ if (y1 > y2) { vert2 = e1; vert1 = e2; } else { vert2 = e2; vert1 = e1; } \
+ } else { vert0 = e2; vert1 = e0; vert2 = e1; } \
+ } else { \
+ if (y2 > y0) { vert0 = e1; vert1 = e0; vert2 = e2; } else { \
+ vert2 = e0; \
+ if (y2 > y1) { vert0 = e1; vert1 = e2; } else { vert0 = e2; vert1 = e1; } \
+ } \
+ } \
+ } while (0)
+
+#define SET_VARIABLES() \
+ do { \
+ iy0 = y0 = ((s3virgeDB->height - (VB->Win.data[vert0][1]))); \
+ iy1 = y1 = ((s3virgeDB->height - (VB->Win.data[vert1][1]))); \
+ iy2 = y2 = ((s3virgeDB->height - (VB->Win.data[vert2][1]))); \
+ if (iy0 == iy2) { return; } \
+ ydiff = y0 - (float)iy0; \
+ x0 = ((VB->Win.data[vert0][0]) * 1024.0 * 1024.0); \
+ x1 = ((VB->Win.data[vert1][0]) * 1024.0 * 1024.0); \
+ x2 = ((VB->Win.data[vert2][0]) * 1024.0 * 1024.0); \
+ z0 = (VB->Win.data[vert0][2] * 1024.0 * 32.0); \
+ z1 = (VB->Win.data[vert1][2] * 1024.0 * 32.0); \
+ z2 = (VB->Win.data[vert2][2] * 1024.0 * 32.0); \
+ dx12 = x2 - x1; \
+ dy12 = iy1 - iy2; \
+ dx01 = x1 - x0; \
+ dy01 = iy0 - iy1; \
+ dx02 = x2 - x0; \
+ dy02 = iy0 - iy2; \
+ delt12 = delt02 = delt01 = 0; \
+ } while (0)
+
+#define SET_TEX_VARIABLES() \
+ do { \
+ t = ((s3virgeTextureObject_t *)ctx->Texture.Unit[0].Current->DriverData); \
+ deltwx = deltwy = wstart = deltdx = deltdy = dstart = 0; \
+ u0 = (VB->TexCoordPtr[0]->data[vert0][0] * (GLfloat)(t->tObj->Image[0]->Width) * 256.0); \
+ u1 = (VB->TexCoordPtr[0]->data[vert1][0] * (GLfloat)(t->tObj->Image[0]->Width) * 256.0); \
+ u2 = (VB->TexCoordPtr[0]->data[vert2][0] * (GLfloat)(t->tObj->Image[0]->Width) * 256.0); \
+ v0 = (VB->TexCoordPtr[0]->data[vert0][1] * (GLfloat)(t->tObj->Image[0]->Height) * 256.0); \
+ v1 = (VB->TexCoordPtr[0]->data[vert1][1] * (GLfloat)(t->tObj->Image[0]->Height) * 256.0); \
+ v2 = (VB->TexCoordPtr[0]->data[vert2][1] * (GLfloat)(t->tObj->Image[0]->Height) * 256.0); \
+ w0 = (VB->Win.data[vert0][3]); \
+ w1 = (VB->Win.data[vert1][3]); \
+ w2 = (VB->Win.data[vert2][3]); \
+ } while (0)
+
+#define FLATSHADE_COLORS() \
+ do { \
+ GLubyte *col = &(colours[pv][0]); \
+ deltarx = deltary = deltgbx = deltgby = 0; \
+ gbstart = (((col[1]) << 23) | ((col[2]) << 7)); \
+ arstart = (((col[3]) << 23) | ((col[0]) << 7)); \
+ } while (0)
+
+#define GOURAUD_COLORS() \
+ do { \
+ int ctmp, ctmp2, ctmp3, ctmp4; \
+ GLubyte *col0, *col1, *col2; \
+ col0 = &(colours[vert0][0]); \
+ col1 = &(colours[vert1][0]); \
+ col2 = &(colours[vert2][0]); \
+ ctmp = ((col2[3] - col0[3]) << 7) / dy02; \
+ ctmp2 = ((col2[0] - col0[0]) << 7) / dy02; \
+ deltary = ((ctmp << 16) & 0xFFFF0000) | (ctmp2 & 0xFFFF); \
+ ctmp3 = ((col2[1] - col0[1]) << 7) / dy02; \
+ ctmp4 = ((col2[2] - col0[2]) << 7) / dy02; \
+ deltgby = ((ctmp3 << 16) & 0xFFFF0000) | (ctmp4 & 0xFFFF); \
+ gbstart = (((int)((ydiff * ctmp3) + (col0[1] << 7)) << 16) & 0x7FFF0000) | \
+ ((int)((ydiff * ctmp4) + (col0[2] << 7)) & 0x7FFF); \
+ arstart = (((int)((ydiff * ctmp) + (col0[3] << 7)) << 16) & 0x7FFF0000) | \
+ ((int)((ydiff * ctmp2) + (col0[0] << 7)) & 0x7FFF); \
+ if (tmp) { \
+ int ax, rx, gx, bx; \
+ ax = ((col1[3] << 7) - (dy01 * ctmp + (col0[3] << 7))) / tmp; \
+ rx = ((col1[0] << 7) - (dy01 * ctmp2 + (col0[0] << 7))) / tmp; \
+ gx = ((col1[1] << 7) - (dy01 * ctmp3 + (col0[1] << 7))) / tmp; \
+ bx = ((col1[2] << 7) - (dy01 * ctmp4 + (col0[2] << 7))) / tmp; \
+ deltarx = ((ax << 16) & 0xFFFF0000) | (rx & 0xFFFF); \
+ deltgbx = ((gx << 16) & 0xFFFF0000) | (bx & 0xFFFF); \
+ } else { \
+ deltgbx = deltarx = 0; \
+ } \
+ } while (0)
+
+#define SET_XY() \
+ do { \
+ delt02 = dx02 / dy02; \
+ if (dy12) delt12 = dx12 / dy12; \
+ if (dy01) delt01 = dx01 / dy01; \
+ start02 = (ydiff * delt02) + x0; \
+ end01 = (ydiff * delt01) + x0; \
+ end12 = ((y1 - (GLfloat)iy1) * delt12) + x1; \
+ } while (0)
+
+#define SET_DIR() \
+ do { \
+ tmp = x1 - (dy01 * delt02 + x0); \
+ if (tmp > 0) { \
+ lr = 0x80000000; \
+ } else { \
+ tmp *= -1; \
+ lr = 0; \
+ } \
+ tmp >>= 20; \
+ } while (0)
+
+#define SET_Z() \
+ do { \
+ deltzy = (z2 - z0) / dy02; \
+ if (tmp) { \
+ deltzx = (z1 - (dy01 * deltzy + z0)) / tmp; \
+ } else { deltzx = 0; } \
+ zstart = (deltzy * ydiff) + z0; \
+ } while (0)
+
+#define SET_BASEUV() \
+ do { \
+ if (u0 < u1) { \
+ if (u0 < u2) { \
+ baseu = u0; \
+ } else { \
+ baseu = u2; \
+ } \
+ } else { \
+ if (u1 < u2) { \
+ baseu = u1; \
+ } else { \
+ baseu = u2; \
+ } \
+ } \
+ if (v0 < v1) { \
+ if (v0 < v2) { \
+ basev = v0; \
+ } else { \
+ basev = v2; \
+ } \
+ } else { \
+ if (v1 < v2) { \
+ basev = v1; \
+ } else { \
+ basev = v2; \
+ } \
+ } \
+ } while (0)
+
+#define SET_RW() \
+ do { \
+ /* GLfloat minW; \
+ if (w0 < w1) { \
+ if (w0 < w2) { \
+ minW = w0; \
+ } else { \
+ minW = w2; \
+ } \
+ } else { \
+ if (w1 < w2) { \
+ minW = w1; \
+ } else { \
+ minW = w2; \
+ } \
+ } */ \
+ rw0 = (512.0 * w0); \
+ rw1 = (512.0 * w1); \
+ rw2 = (512.0 * w2); \
+ } while (0)
+
+
+#define SET_D() \
+ do { \
+ GLfloat sxy, suv; \
+ int lev; \
+ suv = (VB->TexCoordPtr[0]->data[vert0][0] - \
+ VB->TexCoordPtr[0]->data[vert2][0]) * \
+ (VB->TexCoordPtr[0]->data[vert1][1] - \
+ VB->TexCoordPtr[0]->data[vert2][1]) - \
+ (VB->TexCoordPtr[0]->data[vert1][0] - \
+ VB->TexCoordPtr[0]->data[vert2][0]) * \
+ (VB->TexCoordPtr[0]->data[vert0][1] - \
+ VB->TexCoordPtr[0]->data[vert2][2]); \
+ sxy = (VB->Win.data[vert0][0] - \
+ VB->Win.data[vert2][0]) * \
+ (VB->Win.data[vert1][1] - \
+ VB->Win.data[vert2][1]) - \
+ (VB->Win.data[vert1][0] - \
+ VB->Win.data[vert2][0]) * \
+ (VB->Win.data[vert0][1] - \
+ VB->Win.data[vert2][2]); \
+ if (sxy < 0) sxy *= -1.0; \
+ if (suv < 0) suv *= -1.0; \
+ lev = *(int*)&suv - *(int *)&sxy; \
+ if (lev < 0) \
+ lev = 0; \
+ else \
+ lev >>=23; \
+ dstart = (lev << 27); \
+ } while (0)
+
+
+
+#define SET_UVWD() \
+ do { \
+ SET_BASEUV(); \
+ SET_RW(); \
+ SET_D(); \
+ ru0 = (((u0 - baseu) * rw0)); \
+ ru1 = (((u1 - baseu) * rw1)); \
+ ru2 = (((u2 - baseu) * rw2)); \
+ rv0 = (((v0 - basev) * rw0)); \
+ rv1 = (((v1 - basev) * rw1)); \
+ rv2 = (((v2 - basev) * rw2)); \
+ while (baseu < 0) { baseu += (t->tObj->Image[0]->Width << 8); } \
+ while (basev < 0) { basev += (t->tObj->Image[0]->Height << 8); } \
+ if (!(baseu & 0xFF)) { baseu = (baseu >> 8); } else { baseu = (baseu >> 8) + 1; } \
+ if ((basev & 0x80) || !(basev & 0xFF)) { basev = (basev >> 8); } else { basev = (basev >> 8) - 1; } \
+ rbaseu = (baseu) << (16 - t->widthLog2); \
+ rbasev = (basev) << (16 - t->widthLog2); \
+ deltuy = (((ru2 - ru0) / dy02)); \
+ deltvy = (((rv2 - rv0) / dy02)); \
+ rw0 *= (1024.0 * 512.0); \
+ rw1 *= (1024.0 * 512.0); \
+ rw2 *= (1024.0 * 512.0); \
+ deltwy = ((rw2 - rw0) / dy02); \
+ if (tmp) { \
+ deltux = ((ru1 - (dy01 * deltuy + ru0)) / tmp); \
+ deltvx = ((rv1 - (dy01 * deltvy + rv0)) / tmp); \
+ deltwx = ((rw1 - (dy01 * deltwy + rw0)) / tmp); \
+ } else { deltux = deltvx = deltwx = 0; } \
+ ustart = (deltuy * ydiff) + (ru0); \
+ vstart = (deltvy * ydiff) + (rv0); \
+ wstart = (deltwy * ydiff) + (rw0); \
+ } while (0)
+
+
+#define SEND_COLORS() \
+ do { \
+ WAITFIFOEMPTY(6); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_GBX), deltgbx); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_ARX), deltarx); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_GBY), deltgby); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_ARY), deltary); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_GS_BS), gbstart); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_AS_RS), arstart); \
+ } while (0)
+
+#define SEND_VERTICES() \
+ do { \
+ WAITFIFOEMPTY(6); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_ZSTART), zstart); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_ZXD), deltzx); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_ZYD), deltzy); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXDELTA12), delt12); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXEND12), end12); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXDELTA01), delt01); \
+ WAITFIFOEMPTY(5); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXEND01), end01); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXDELTA02), delt02); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TXSTART02), start02); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TYS), iy0); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_TY01_Y12), \
+ ((((iy0 - iy1) & 0x7FF) << 16) | \
+ ((iy1 - iy2) & 0x7FF) | lr)); \
+ } while (0)
+
+#define SEND_UVWD() \
+ do { \
+ WAITFIFOEMPTY(7); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_BASEV), (rbasev & 0xFFFF)); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_BASEU), (0xa0000000 | (rbaseu & 0xFFFF))); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_WXD), deltwx); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_WYD), deltwy); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_WSTART), wstart); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_DXD), deltdx); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_VXD), deltvx); \
+ WAITFIFOEMPTY(7); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_UXD), deltux); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_DYD), deltdy); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_VYD), deltvy); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_UYD), deltuy); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_DSTART), dstart); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_VSTART), vstart); \
+ OUTREG( (S3VIRGE_3DTRI_REG | S3VIRGE_3DTRI_USTART), ustart); \
+ } while (0)
+
+#define DMA_SEND_UVWD() \
+ do { \
+ DMAOUT((rbasev & 0xFFFF)); \
+ DMAOUT((0xa0000000 | (rbaseu & 0xFFFF))); \
+ DMAOUT(deltwx); \
+ DMAOUT(deltwy); \
+ DMAOUT(wstart); \
+ DMAOUT(deltdx); \
+ DMAOUT(deltvx); \
+ DMAOUT(deltux); \
+ DMAOUT(deltdy); \
+ DMAOUT(deltvy); \
+ DMAOUT(deltuy); \
+ DMAOUT(dstart); \
+ DMAOUT(vstart); \
+ DMAOUT(ustart); \
+ } while (0)
+
+
+#define DMA_SEND_COLORS() \
+ do { \
+ DMAOUT(deltgbx); \
+ DMAOUT(deltarx); \
+ DMAOUT(deltgby); \
+ DMAOUT(deltary); \
+ DMAOUT(gbstart); \
+ DMAOUT(arstart); \
+ } while (0)
+
+#define DMA_SEND_VERTICES() \
+ do { \
+ DMAOUT(deltzx); \
+ DMAOUT(deltzy); \
+ DMAOUT(zstart); \
+ DMAOUT(delt12); \
+ DMAOUT(end12); \
+ DMAOUT(delt01); \
+ DMAOUT(end01); \
+ DMAOUT(delt02); \
+ DMAOUT(start02); \
+ DMAOUT(iy0); \
+ DMAOUT(((((iy0 - iy1) & 0x7FF) << 16) | \
+ ((iy1 - iy2) & 0x7FF) | lr)); \
+ } while (0)
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/Makefile
new file mode 100644
index 000000000..018482f66
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/Makefile
@@ -0,0 +1,30 @@
+# src/mesa/drivers/dri/r128/Makefile
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = savage_dri.so
+
+# Doesn't exist yet.
+#MINIGLX_SOURCES = server/savage_dri.c
+
+DRIVER_SOURCES = \
+ savage_xmesa.c \
+ savagedd.c \
+ savagestate.c \
+ savagetex.c \
+ savagetris.c \
+ savagerender.c \
+ savageioctl.c \
+ savagespan.c
+
+C_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+
+include ../Makefile.template
+
+symlinks:
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savage_3d_reg.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savage_3d_reg.h
new file mode 100644
index 000000000..b7d1c3960
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savage_3d_reg.h
@@ -0,0 +1,699 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+#ifndef SAVAGE_3D_REG_H
+#define SAVAGE_3D_REG_H
+
+#define VIDEO_MEM_ADR 0x02
+#define SYSTEM_MEM_ADR 0x01
+#define AGP_MEM_ADR 0x03
+
+/***********************************************************
+
+ ----------- 3D ENGINE UNIT Registers -------------
+
+ *********************************************************/
+
+typedef union
+{
+ struct
+ {
+ unsigned reserved : 4;
+ unsigned ofs : 28;
+ }ni;
+ u_int32_t ui;
+} savageRegZPixelOffset;
+
+/* This reg exists only on Savage4. */
+typedef union
+{
+ struct
+ {
+ unsigned cmpFunc : 3;
+ unsigned stencilEn : 1;
+ unsigned readMask : 8;
+ unsigned writeMask : 8;
+ unsigned failOp : 3;
+ unsigned passZfailOp : 3;
+ unsigned passZpassOp : 3;
+ unsigned reserved : 3;
+ }ni;
+ u_int32_t ui;
+} savageRegStencilCtrl;
+
+/**************************
+ Texture Registers
+**************************/
+/* The layout of this reg differs between Savage4 and Savage3D. */
+typedef union
+{
+ struct
+ {
+ unsigned tex0Width : 4;
+ unsigned tex0Height : 4;
+ unsigned tex0Fmt : 4;
+ unsigned tex1Width : 4;
+ unsigned tex1Height : 4;
+ unsigned tex1Fmt : 4;
+ unsigned texBLoopEn : 1;
+ unsigned tex0En : 1;
+ unsigned tex1En : 1;
+ unsigned orthProjEn : 1;
+ unsigned reserved : 1;
+ unsigned palSize : 2;
+ unsigned newPal : 1;
+ }ni;
+ u_int32_t ui;
+} savageRegTexDescr_s4;
+typedef union
+{
+ struct
+ {
+ unsigned texWidth : 4;
+ unsigned reserved1 : 4;
+ unsigned texHeight : 4;
+ unsigned reserved2 : 4;
+ /* Savage3D supports only the first 8 texture formats defined in
+ enum TexFmt in savge_bci.h. */
+ unsigned texFmt : 3;
+ unsigned palSize : 2;
+ unsigned reserved3 : 10;
+ unsigned newPal : 1;
+ }ni;
+ u_int32_t ui;
+} savageRegTexDescr_s3d;
+
+/* The layout of this reg is the same on Savage4 and Savage3D,
+ but the Savage4 has two of them, Savage3D has only one. */
+typedef union
+{
+ struct
+ {
+ unsigned inSysTex : 1;
+ unsigned inAGPTex : 1;
+ unsigned reserved : 1;
+ unsigned addr : 29;
+ }ni;
+ u_int32_t ui;
+} savageRegTexAddr;
+
+/* The layout of this reg is the same on Savage4 and Savage3D. */
+typedef union
+{
+ struct
+ {
+ unsigned reserved : 3;
+ unsigned addr : 29;
+ }ni;
+ u_int32_t ui;
+} savageRegTexPalAddr;
+
+/* The layout of this reg on Savage4 and Savage3D are very similar. */
+typedef union
+{
+ struct
+ {
+ unsigned xprClr0 : 16;
+ unsigned xprClr1 : 16; /* this is reserved on Savage3D */
+ }ni;
+ u_int32_t ui;
+} savageRegTexXprClr; /* transparency color in RGB565 format*/
+
+/* The layout of this reg differs between Savage4 and Savage3D.
+ * Savage4 has two of them, Savage3D has only one. */
+typedef union
+{
+ struct
+ {
+ unsigned filterMode : 2;
+ unsigned mipmapEnable : 1;
+ unsigned dBias : 9;
+ unsigned dMax : 4;
+ unsigned uMode : 2;
+ unsigned vMode : 2;
+ unsigned useDFraction : 1;
+ unsigned texXprEn : 1;
+ unsigned clrBlendAlphaSel : 2;
+ unsigned clrArg1CopyAlpha : 1;
+ unsigned clrArg2CopyAlpha : 1;
+ unsigned clrArg1Invert : 1;
+ unsigned clrArg2Invert : 1;
+ unsigned alphaBlendAlphaSel : 2;
+ unsigned alphaArg1Invert : 1;
+ unsigned alphaArg2Invert : 1;
+ }ni;
+ u_int32_t ui;
+} savageRegTexCtrl_s4;
+typedef union
+{
+ struct
+ {
+ unsigned filterMode : 2;
+ unsigned mipmapDisable : 1;
+ unsigned dBias : 9;
+ unsigned uWrapEn : 1;
+ unsigned vWrapEn : 1;
+ unsigned wrapMode : 2;
+ unsigned texEn : 1;
+ unsigned useDFraction : 1;
+ unsigned reserved1 : 1;
+ /* Color Compare Alpha Blend Control
+ 0 - reduce dest alpha to 0 or 1
+ 1 - blend with destination
+ The Utah-Driver doesn't know how to use it and sets it to 0. */
+ unsigned CCA : 1;
+ unsigned texXprEn : 1;
+ unsigned reserved2 : 11;
+ }ni;
+ u_int32_t ui;
+} savageRegTexCtrl_s3d;
+
+/* This reg exists only on Savage4. */
+typedef union
+{
+ struct
+ {
+ unsigned colorArg1Sel : 2;
+ unsigned colorArg2Sel : 3;
+ unsigned colorInvAlphaEn : 1;
+ unsigned colorInvArg2En : 1;
+ unsigned colorPremodSel : 1;
+ unsigned colorMod1Sel : 1;
+ unsigned colorMod2Sel : 2;
+ unsigned colorAddSel : 2;
+ unsigned colorDoBlend : 1;
+ unsigned colorDo2sCompl : 1;
+ unsigned colorAddBiasEn : 1;
+ unsigned alphaArg1Sel : 2;
+ unsigned alphaArg2Sel : 3;
+ unsigned alphaMod1Sel : 1;
+ unsigned alphaMod2Sel : 2;
+ unsigned alphaAdd0Sel : 1;
+ unsigned alphaDoBlend : 1;
+ unsigned alphaDo2sCompl : 1;
+ unsigned colorStageClamp : 1;
+ unsigned alphaStageClamp : 1;
+ unsigned colorDoDiffMul : 1;
+ unsigned LeftShiftVal : 2;
+ }ni;
+ u_int32_t ui;
+} savageRegTexBlendCtrl;
+
+/* This reg exists only on Savage4. */
+typedef union
+{
+ struct
+ {
+ unsigned blue : 8;
+ unsigned green : 8;
+ unsigned red : 8;
+ unsigned alpha : 8;
+ }ni;
+ u_int32_t ui;
+} savageRegTexBlendColor;
+
+/********************************
+ Tiled Surface Registers
+**********************************/
+
+typedef union
+{
+ struct
+ {
+ unsigned frmBufOffset : 13;
+ unsigned reserved : 12;
+ unsigned widthInTile : 6;
+ unsigned bitPerPixel : 1;
+ }ni;
+ u_int32_t ui;
+} savageRegTiledSurface;
+
+/********************************
+ Draw/Shading Control Registers
+**********************************/
+
+/* This reg exists only on Savage4. */
+typedef union
+{
+ struct
+ {
+ unsigned scissorXStart : 11;
+ unsigned dPerfAccelEn : 1;
+ unsigned scissorYStart : 12;
+ unsigned alphaRefVal : 8;
+ }ni;
+ u_int32_t ui;
+} savageRegDrawCtrl0;
+
+/* This reg exists only on Savage4. */
+typedef union
+{
+ struct
+ {
+ unsigned scissorXEnd : 11;
+ unsigned xyOffsetEn : 1;
+ unsigned scissorYEnd : 12;
+ unsigned ditherEn : 1;
+ unsigned nonNormTexCoord : 1;
+ unsigned cullMode : 2;
+ unsigned alphaTestCmpFunc : 3;
+ unsigned alphaTestEn : 1;
+ }ni;
+ u_int32_t ui;
+} savageRegDrawCtrl1;
+
+/* This reg exists only on Savage4. */
+typedef union
+{
+ struct
+ {
+ unsigned dstAlphaMode : 3;
+ unsigned dstMinusSrc : 1;
+ unsigned srcAlphaMode : 3;
+ unsigned binaryFinalAlpha : 1;
+ unsigned dstAlphaModeHighBit : 1;
+ unsigned srcAlphaModeHighBit : 1;
+ unsigned reserved1 : 15;
+ unsigned wrZafterAlphaTst : 1;
+ unsigned drawUpdateEn : 1;
+ unsigned zUpdateEn : 1;
+ unsigned flatShadeEn : 1;
+ unsigned specShadeEn : 1;
+ unsigned flushPdDestWrites : 1;
+ unsigned flushPdZbufWrites : 1;
+ }ni;
+ u_int32_t ui;
+} savageRegDrawLocalCtrl;
+
+/* This reg exists only on Savage3D. */
+typedef union
+{
+ struct
+ {
+ unsigned ditherEn : 1;
+ unsigned xyOffsetEn : 1;
+ unsigned cullMode : 2;
+ unsigned vertexCountReset : 1;
+ unsigned flatShadeEn : 1;
+ unsigned specShadeEn : 1;
+ unsigned dstAlphaMode : 3;
+ unsigned srcAlphaMode : 3;
+ unsigned reserved1 : 1;
+ unsigned alphaTestCmpFunc : 3;
+ unsigned alphaTestEn : 1;
+ unsigned alphaRefVal : 8;
+ unsigned texBlendCtrl : 3;
+ unsigned flushPdDestWrites : 1;
+ unsigned flushPdZbufWrites : 1;
+ /* havn't found an equivalent for Savage4. Utah-driver sets it to 0. */
+ unsigned interpMode : 1;
+ }ni;
+ u_int32_t ui;
+} savageRegDrawCtrl;
+
+#define SAVAGETBC_DECAL_S3D 0
+#define SAVAGETBC_MODULATE_S3D 1
+#define SAVAGETBC_DECALALPHA_S3D 2
+#define SAVAGETBC_MODULATEALPHA_S3D 3
+#define SAVAGETBC_4_S3D 4
+#define SAVAGETBC_5_S3D 5
+#define SAVAGETBC_COPY_S3D 6
+#define SAVAGETBC_7_S3D 7
+
+/* This reg exists only on Savage3D. */
+typedef union
+{
+ struct
+ {
+ unsigned scissorXStart : 11;
+ unsigned reserved1 : 5;
+ unsigned scissorYStart : 11;
+ unsigned reserved2 : 5;
+ } ni;
+ u_int32_t ui;
+} savageRegScissorsStart;
+
+/* This reg exists only on Savage3D. */
+typedef union
+{
+ struct
+ {
+ unsigned scissorXEnd : 11;
+ unsigned reserved1 : 5;
+ unsigned scissorYEnd : 11;
+ unsigned reserved2 : 5;
+ } ni;
+ u_int32_t ui;
+} savageRegScissorsEnd;
+
+/********************************
+ Address Registers
+**********************************/
+
+/* I havn't found a Savage3D equivalent of this reg in the Utah-driver.
+ * But Tim Roberts claims that the Savage3D supports DMA vertex and
+ * command buffers. */
+typedef union
+{
+ struct
+ {
+ unsigned isSys : 1;
+ unsigned isAGP : 1;
+ unsigned reserved : 1;
+ unsigned addr : 29; /*quad word aligned*/
+ }ni;
+ u_int32_t ui;
+} savageRegVertBufAddr;
+
+/* I havn't found a Savage3D equivalent of this reg in the Utah-driver.
+ * But Tim Roberts claims that the Savage3D supports DMA vertex and
+ * command buffers. */
+typedef union
+{
+ struct
+ {
+ unsigned isSys : 1;
+ unsigned isAGP : 1;
+ unsigned reserved : 1;
+ unsigned addr : 29; /*4-quad word aligned*/
+ }ni;
+ u_int32_t ui;
+} savageRegDMABufAddr;
+
+/********************************
+ H/W Debug Registers
+**********************************/
+/* The layout of this reg is the same on Savage4 and Savage3D. */
+typedef union
+{
+ struct
+ {
+ unsigned y01 : 1;
+ unsigned y12 : 1;
+ unsigned y20 : 1;
+ unsigned u01 : 1;
+ unsigned u12 : 1;
+ unsigned u20 : 1;
+ unsigned v01 : 1;
+ unsigned v12 : 1;
+ unsigned v20 : 1;
+ unsigned cullEn : 1;
+ unsigned cullOrient : 1;
+ unsigned loadNewTex : 1;
+ unsigned loadNewPal : 1;
+ unsigned doDSetup : 1;
+ unsigned reserved : 17;
+ unsigned kickOff : 1;
+ }ni;
+ u_int32_t ui;
+} savageRegFlag;
+
+/********************************
+ Z Buffer Registers -- Global
+**********************************/
+
+/* The layout of this reg differs between Savage4 and Savage3D. */
+typedef union
+{
+ struct
+ {
+ unsigned zCmpFunc : 3;
+ unsigned reserved1 : 2;
+ unsigned zBufEn : 1;
+ unsigned reserved2 : 1;
+ unsigned zExpOffset : 8;
+ unsigned reserved3 : 1;
+ unsigned stencilRefVal : 8;
+ unsigned autoZEnable : 1;
+ unsigned frameID : 1;
+ unsigned reserved4 : 4;
+ unsigned floatZEn : 1;
+ unsigned wToZEn : 1;
+ }ni;
+ u_int32_t ui;
+} savageRegZBufCtrl_s4;
+typedef union
+{
+ struct {
+ unsigned zCmpFunc : 3;
+ unsigned drawUpdateEn : 1;
+ unsigned zUpdateEn : 1;
+ unsigned zBufEn : 1;
+
+ /**
+ * We suspect that, in conjunction with
+ * \c savageRegZBufOffset::zDepthSelect, these 2 bits are actually
+ * \c stencilUpdateEn and \c stencilBufEn. If not, then some of
+ * the bits in \c reserved2 may fulfill that purpose.
+ */
+ unsigned reserved1 : 2;
+
+ unsigned zExpOffset : 8;
+ unsigned wrZafterAlphaTst : 1;
+ unsigned reserved2 : 15;
+ }ni;
+ u_int32_t ui;
+} savageRegZBufCtrl_s3d;
+
+/* The layout of this reg on Savage4 and Savage3D is very similar. */
+typedef union
+{
+ struct
+ {
+ /* In the Utah-Driver the offset is defined as 13-bit, 2k-aligned. */
+ unsigned offset : 14;
+ unsigned reserved : 11; /* 12-bits in Utah-driver */
+ unsigned zBufWidthInTiles : 6;
+
+ /**
+ * 0 selects 16-bit depth buffer. On Savage4 hardware, 1 selects
+ * 24-bit depth buffer (with 8-bits for stencil). Though it has never
+ * been tried, we suspect that on Savage3D hardware, 1 selects 15-bit
+ * depth buffer (with 1-bit for stencil).
+ */
+ unsigned zDepthSelect : 1;
+ }ni;
+ u_int32_t ui;
+} savageRegZBufOffset;
+
+/* The layout of this reg is the same on Savage4 and Savage3D. */
+typedef union
+{
+ struct
+ {
+ unsigned rLow : 6;
+ unsigned reserved1 : 2;
+ unsigned rHigh : 6;
+ unsigned reserved2 : 2;
+ unsigned wLow : 6;
+ unsigned reserved3 : 2;
+ unsigned wHigh : 6;
+ unsigned reserved4 : 2;
+ }ni;
+ u_int32_t ui;
+} savageRegZWatermarks;
+
+/********************************
+ Fog Registers -- Global
+**********************************/
+/* The layout of this reg is the same on Savage4 and Savage3D. */
+typedef union
+{
+ struct
+ {
+ unsigned fogClr : 24;
+ unsigned expShift : 3;
+ unsigned reserved : 1;
+ unsigned fogEn : 1;
+ unsigned fogMode : 1;
+ unsigned fogEndShift : 2;
+ }ni;
+ u_int32_t ui;
+} savageRegFogCtrl;
+
+/*not in spec, but tempo for pp and driver*/
+typedef union
+{
+ struct
+ {
+ unsigned fogDensity : 16;
+ unsigned fogStart : 16;
+ }ni;
+ u_int32_t ui;
+} savageRegFogParam;
+
+/**************************************
+ Destination Buffer Registers -- Global
+***************************************/
+
+/* The layout of this reg on Savage4 and Savage3D are very similar. */
+typedef union
+{
+ struct
+ {
+ unsigned dstWidthInTile : 7;
+ unsigned reserved : 1;
+ /* In the Utah-Driver the offset is defined as 13-bit, 2k-aligned. */
+ unsigned offset : 14;
+ unsigned reserved1 : 7;
+ /* antiAliasMode does not exist in the Utah-driver. But it includes the
+ * high bit of this in the destPixFmt. However, only values 0 and 2
+ * are used as dstPixFmt, so antiAliasMode is effectively always 0
+ * in the Utah-driver. In other words, treat as reserved on Savage3D.*/
+ unsigned antiAliasMode : 2;
+ unsigned dstPixFmt : 1;
+ }ni;
+ u_int32_t ui;
+} savageRegDestCtrl;
+
+/* The layout of this reg on Savage4 and Savage3D are very similar. */
+typedef union
+{
+ struct
+ {
+ unsigned destReadLow : 6;
+ unsigned destReadHigh : 6;
+ unsigned destWriteLow : 6;
+ unsigned destWriteHigh : 6;
+ unsigned texRead : 4;
+ unsigned reserved4 : 2;
+ /* The Utah-driver calls this pixel FIFO length:
+ * 00 - 240, 01 - 180, 10 - 120, 11 - 60
+ * However, it is not used in either driver. */
+ unsigned destFlush : 2;
+ }ni;
+ u_int32_t ui;
+} savageRegDestTexWatermarks;
+
+/* Savage4/Twister/ProSavage register BCI addresses */
+#define SAVAGE_DRAWLOCALCTRL_S4 0x1e
+#define SAVAGE_TEXPALADDR_S4 0x1f
+#define SAVAGE_TEXCTRL0_S4 0x20
+#define SAVAGE_TEXCTRL1_S4 0x21
+#define SAVAGE_TEXADDR0_S4 0x22
+#define SAVAGE_TEXADDR1_S4 0x23
+#define SAVAGE_TEXBLEND0_S4 0x24
+#define SAVAGE_TEXBLEND1_S4 0x25
+#define SAVAGE_TEXXPRCLR_S4 0x26 /* never used */
+#define SAVAGE_TEXDESCR_S4 0x27
+#define SAVAGE_FOGTABLE_S4 0x28
+#define SAVAGE_FOGCTRL_S4 0x30
+#define SAVAGE_STENCILCTRL_S4 0x31
+#define SAVAGE_ZBUFCTRL_S4 0x32
+#define SAVAGE_ZBUFOFF_S4 0x33
+#define SAVAGE_DESTCTRL_S4 0x34
+#define SAVAGE_DRAWCTRLGLOBAL0_S4 0x35
+#define SAVAGE_DRAWCTRLGLOBAL1_S4 0x36
+#define SAVAGE_ZWATERMARK_S4 0x37
+#define SAVAGE_DESTTEXRWWATERMARK_S4 0x38
+#define SAVAGE_TEXBLENDCOLOR_S4 0x39
+/* Savage3D/MX/IC register BCI addresses */
+#define SAVAGE_TEXPALADDR_S3D 0x18
+#define SAVAGE_TEXXPRCLR_S3D 0x19 /* never used */
+#define SAVAGE_TEXADDR_S3D 0x1A
+#define SAVAGE_TEXDESCR_S3D 0x1B
+#define SAVAGE_TEXCTRL_S3D 0x1C
+#define SAVAGE_FOGTABLE_S3D 0x20
+#define SAVAGE_FOGCTRL_S3D 0x30
+#define SAVAGE_DRAWCTRL_S3D 0x31
+#define SAVAGE_ZBUFCTRL_S3D 0x32
+#define SAVAGE_ZBUFOFF_S3D 0x33
+#define SAVAGE_DESTCTRL_S3D 0x34
+#define SAVAGE_SCSTART_S3D 0x35
+#define SAVAGE_SCEND_S3D 0x36
+#define SAVAGE_ZWATERMARK_S3D 0x37
+#define SAVAGE_DESTTEXRWWATERMARK_S3D 0x38
+
+#define SAVAGE_FIRST_REG 0x18
+#define SAVAGE_NR_REGS 34
+typedef struct savage_registers_s4_t {
+ u_int32_t unused1[6]; /* 0x18-0x1d */
+ savageRegDrawLocalCtrl drawLocalCtrl; /* 0x1e */
+ savageRegTexPalAddr texPalAddr; /* 0x1f */
+ savageRegTexCtrl_s4 texCtrl[2]; /* 0x20, 0x21 */
+ savageRegTexAddr texAddr[2]; /* 0x22, 0x23 */
+ savageRegTexBlendCtrl texBlendCtrl[2]; /* 0x24, 0x25 */
+ savageRegTexXprClr texXprClr; /* 0x26 */
+ savageRegTexDescr_s4 texDescr; /* 0x27 */
+ u_int8_t fogTable[32]; /* 0x28-0x2f (8dwords) */
+ savageRegFogCtrl fogCtrl; /* 0x30 */
+ savageRegStencilCtrl stencilCtrl; /* 0x31 */
+ savageRegZBufCtrl_s4 zBufCtrl; /* 0x32 */
+ savageRegZBufOffset zBufOffset; /* 0x33 */
+ savageRegDestCtrl destCtrl; /* 0x34 */
+ savageRegDrawCtrl0 drawCtrl0; /* 0x35 */
+ savageRegDrawCtrl1 drawCtrl1; /* 0x36 */
+ savageRegZWatermarks zWatermarks; /* 0x37 */
+ savageRegDestTexWatermarks destTexWatermarks; /* 0x38 */
+ savageRegTexBlendColor texBlendColor; /* 0x39 */
+} savageRegistersS4;
+typedef struct savage_registers_s3d_t {
+ savageRegTexPalAddr texPalAddr; /* 0x18 */
+ savageRegTexXprClr texXprClr; /* 0x19 */
+ savageRegTexAddr texAddr; /* 0x1a */
+ savageRegTexDescr_s3d texDescr; /* 0x1b */
+ savageRegTexCtrl_s3d texCtrl; /* 0x1c */
+ u_int32_t unused1[3]; /* 0x1d-0x1f */
+ u_int8_t fogTable[64]; /* 0x20-0x2f (16dwords) */
+ savageRegFogCtrl fogCtrl; /* 0x30 */
+ savageRegDrawCtrl drawCtrl; /* 0x31 */
+ savageRegZBufCtrl_s3d zBufCtrl; /* 0x32 */
+ savageRegZBufOffset zBufOffset; /* 0x33 */
+ savageRegDestCtrl destCtrl; /* 0x34 */
+ savageRegScissorsStart scissorsStart; /* 0x35 */
+ savageRegScissorsEnd scissorsEnd; /* 0x36 */
+ savageRegZWatermarks zWatermarks; /* 0x37 */
+ savageRegDestTexWatermarks destTexWatermarks; /* 0x38 */
+ u_int32_t unused2; /* 0x39 */
+} savageRegistersS3D;
+typedef union savage_registers_t {
+ savageRegistersS4 s4;
+ savageRegistersS3D s3d;
+ u_int32_t ui[SAVAGE_NR_REGS];
+} savageRegisters;
+
+
+#define DV_PF_555 (0x1<<8)
+#define DV_PF_565 (0x2<<8)
+#define DV_PF_8888 (0x4<<8)
+
+#define SAVAGEPACKCOLORA4L4(l,a) \
+ ((l >> 4) | (a & 0xf0))
+
+#define SAVAGEPACKCOLOR4444(r,g,b,a) \
+ ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
+
+#define SAVAGEPACKCOLOR1555(r,g,b,a) \
+ ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
+ ((a) ? 0x8000 : 0))
+
+#define SAVAGEPACKCOLOR8888(r,g,b,a) \
+ (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
+
+#define SAVAGEPACKCOLOR565(r,g,b) \
+ ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savage_bci.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savage_bci.h
new file mode 100644
index 000000000..33cfac32c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savage_bci.h
@@ -0,0 +1,612 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+#ifndef SAVAGE_BCI_H
+#define SAVAGE_BCI_H
+/***********************
+ 3D and 2D command
+************************/
+
+typedef enum {
+ AMO_BurstCmdData= 0x01010000,
+ AMO_3DReg= 0x01048500,
+ AMO_MotionCompReg= 0x01048900,
+ AMO_VideoEngUnit= 0x01048A00,
+ AMO_CmdBufAddr= 0x01048c14,
+ AMO_TiledSurfReg0= 0x01048C40,
+ AMO_TiledSurfReg1= 0x01048C44,
+ AMO_TiledSurfReg2= 0x01048C48,
+ AMO_TiledSurfReg3= 0x01048C4C,
+ AMO_TiledSurfReg4= 0x01048C50,
+ AMO_TiledSurfReg5= 0x01048C54,
+ AMO_TiledSurfReg6= 0x01048C58,
+ AMO_TiledSurfReg7= 0x01048C5C,
+ AMO_LPBModeReg= 0x0100FF00,
+ AMO_LPBFifoSat= 0x0100FF04,
+ AMO_LPBIntFlag= 0x0100FF08,
+ AMO_LPBFmBufA0= 0x0100FF0C,
+ AMO_LPBFmBufA1= 0x0100FF10,
+ AMO_LPBRdWtAdr= 0x0100FF14,
+ AMO_LPBRdWtDat= 0x0100FF18,
+ AMO_LPBIOPort = 0x0100FF1C,
+ AMO_LPBSerPort= 0x0100FF20,
+ AMO_LPBVidInWinSz= 0x0100FF24,
+ AMO_LPBVidDatOffs= 0x0100FF28,
+ AMO_LPBHorScalCtrl= 0x0100FF2C,
+ AMO_LPBVerDeciCtrl= 0x0100FF30,
+ AMO_LPBLnStride= 0x0100FF34,
+ AMO_LPBFmBufAddr2= 0x0100FF38,
+ AMO_LPBVidCapVDCtrl=0x0100FF3C,
+
+ AMO_LPBVidCapFdStAd=0x0100FF60,
+ AMO_LPBVidCapFdMdAd=0x0100FF64,
+ AMO_LPBVidCapFdBtAd=0x0100FF68,
+ AMO_LPBVidCapFdSize=0x0100FF6C,
+ AMO_LPBBilinDecim1= 0x0100FF70,
+ AMO_LPBBilinDecim2= 0x0100FF74,
+ AMO_LPBBilinDecim3= 0x0100FF78,
+ AMO_LPBDspVEUHorSRR=0x0100FF7C,
+ AMO_LPBDspVEUVerSRR=0x0100FF80,
+ AMO_LPBDspVeuDnScDR=0x0100FF84,
+ AMO_LPB_VEUERPReg= 0x0100FF88,
+ AMO_LPB_VBISelReg= 0x0100FF8C,
+ AMO_LPB_VBIBasAdReg=0x0100FF90,
+ AMO_LPB_DatOffsReg= 0x0100FF94,
+ AMO_LPB_VBIVerDcReg=0x0100FF98,
+ AMO_LPB_VBICtrlReg= 0x0100FF9C,
+ AMO_LPB_VIPXferCtrl=0x0100FFA0,
+ AMO_LPB_FIFOWtMark= 0x0100FFA4,
+ AMO_LPB_FIFOCount= 0x0100FFA8,
+ AMO_LPBFdSkipPat= 0x0100FFAC,
+ AMO_LPBCapVEUHorSRR=0x0100FFB0,
+ AMO_LPBCapVEUVerSRR=0x0100FFB4,
+ AMO_LPBCapVeuDnScDR=0x0100FFB8
+
+}AddressMapOffset;
+/*more to add*/
+
+
+typedef enum {
+ CMD_DrawPrim=0x10, /*10000*/
+ CMD_DrawIdxPrim=0x11, /*10001*/
+ CMD_SetRegister=0x12, /*10010*/
+ CMD_UpdateShadowStat=0x13 , /*10011*/
+ CMD_PageFlip=0x14, /* 10100*/
+ CMD_BusMasterImgXfer=0x15, /* 10101*/
+ CMD_ScaledImgXfer=0x16, /* 10110*/
+ CMD_Macroblock=0x17, /*10111*/
+ CMD_Wait= 0x18, /*11000*/
+ CMD_2D_NOP=0x08, /* 01000*/
+ CMD_2D_RCT=0x09, /*01001 rectangular fill*/
+ CMD_2D_SCNL=0x0a, /* 01010 scan line*/
+ CMD_2D_LIN=0x0b, /*01011 line*/
+ CMD_2D_SMTXT=0x0c, /*01100*/
+ CMD_2D_BPTXT=0x0d, /*01101*/
+ CMD_InitFlag=0x1f /*11111, for S/W initialization control*/
+}Command;
+
+
+typedef enum {
+ VRR_List,
+ VRR_Strip,
+ VRR_Fan,
+ VRR_QuadList
+}VertexReplaceRule;
+
+/***********************
+ Destination
+************************/
+
+typedef enum {
+ DFT_RGB565 = 0,
+ DFT_XRGB8888
+}DestinationFmt;
+
+
+/*************************
+ Z Buffer / Alpha test
+*************************/
+
+typedef enum {
+ CF_Never,
+ CF_Less,
+ CF_Equal,
+ CF_LessEqual,
+ CF_Greater,
+ CF_NotEqual,
+ CF_GreaterEqual,
+ CF_Always
+}ZCmpFunc; /* same for Alpha test and Stencil test compare function */
+
+typedef ZCmpFunc ACmpFunc;
+
+typedef enum {
+ ZDS_16i, /* .16 fixed*/
+ ZDS_32f /* 1.8.15 float*/
+}ZDepthSelect;
+
+
+/**********************************
+ BCI Register Addressing Index
+***********************************/
+typedef enum {
+
+ CRI_VTX0_X = 0x00,
+ CRI_VTX0_Y = 0x01,
+ CRI_VTX0_W = 0x02,
+ CRI_VTX0_DIFFU= 0x03,
+ CRI_VTX0_SPECU= 0x04,
+ CRI_VTX0_U = 0x05,
+ CRI_VTX0_V = 0x06,
+ CRI_VTX0_U2 = 0x07,
+ CRI_VTX0_V2 = 0x08,
+ CRI_VTX1_X = 0x09,
+ CRI_VTX1_Y = 0x0a,
+ CRI_VTX1_W = 0x0b,
+ CRI_VTX1_DIFFU= 0x0c,
+ CRI_VTX1_SPECU= 0x0d,
+ CRI_VTX1_U = 0x0e,
+ CRI_VTX1_V = 0x0f,
+ CRI_VTX1_U2 = 0x10,
+ CRI_VTX1_V2 = 0x11,
+ CRI_VTX2_X = 0x12,
+ CRI_VTX2_Y = 0x13,
+ CRI_VTX2_W = 0x14,
+ CRI_VTX2_DIFFU= 0x15,
+ CRI_VTX2_SPECU= 0x16,
+ CRI_VTX2_U = 0x17,
+ CRI_VTX2_V = 0x18,
+ CRI_VTX2_U2 = 0x19,
+ CRI_VTX2_V2 = 0x1a,
+
+ CRI_ZPixelOffset = 0x1d,
+ CRI_DrawCtrlLocal = 0x1e,
+ CRI_TexPalAddr = 0x1f,
+ CRI_TexCtrl0 = 0x20,
+ CRI_TexCtrl1 = 0x21,
+ CRI_TexAddr0 = 0x22,
+ CRI_TexAddr1 = 0x23,
+ CRI_TexBlendCtrl0 = 0x24,
+ CRI_TexBlendCtrl1 = 0x25,
+ CRI_TexXprClr = 0x26,
+ CRI_TexDescr = 0x27,
+
+ CRI_FogTable00= 0x28,
+ CRI_FogTable04= 0x29,
+ CRI_FogTable08= 0x2a,
+ CRI_FogTable12= 0x2b,
+ CRI_FogTable16= 0x2c,
+ CRI_FogTable20= 0x2d,
+ CRI_FogTable24= 0x2e,
+ CRI_FogTable28= 0x2f,
+ CRI_FogCtrl= 0x30,
+ CRI_StencilCtrl= 0x31,
+ CRI_ZBufCtrl= 0x32,
+ CRI_ZBufOffset= 0x33,
+ CRI_DstCtrl= 0x34,
+ CRI_DrawCtrlGlobal0= 0x35,
+ CRI_DrawCtrlGlobal1= 0x36,
+ CRI_ZRW_WTMK = 0x37,
+ CRI_DST_WTMK = 0x38,
+ CRI_TexBlendColor= 0x39,
+
+ CRI_VertBufAddr= 0x3e,
+ /* new in ms1*/
+ CRI_MauFrameAddr0 = 0x40,
+ CRI_MauFrameAddr1 = 0x41,
+ CRI_MauFrameAddr2 = 0x42,
+ CRI_MauFrameAddr3 = 0x43,
+ CRI_FrameDesc = 0x44,
+ CRI_IDCT9bitEn = 0x45,
+ CRI_MV0 = 0x46,
+ CRI_MV1 = 0x47,
+ CRI_MV2 = 0x48,
+ CRI_MV3 = 0x49,
+ CRI_MacroDescr = 0x4a, /*kickoff?*/
+
+ CRI_MeuCtrl = 0x50,
+ CRI_SrcYAddr = 0x51,
+ CRI_DestAddr = 0x52,
+ CRI_FmtrSrcDimen = 0x53,
+ CRI_FmtrDestDimen = 0x54,
+ CRI_SrcCbAddr = 0x55,
+ CRI_SrcCrAddr = 0x56,
+ CRI_SrcCrCbStride = 0x57,
+
+ CRI_BCI_Power= 0x5f,
+
+ CRI_PSCtrl=0xA0,
+ CRI_SSClrKeyCtrl=0xA1,
+ CRI_SSCtrl=0xA4,
+ CRI_SSChromUpBound=0xA5,
+ CRI_SSHoriScaleCtrl=0xA6,
+ CRI_SSClrAdj=0xA7,
+ CRI_SSBlendCtrl=0xA8,
+ CRI_PSFBAddr0=0xB0,
+ CRI_PSFBAddr1=0xB1,
+ CRI_PSStride=0xB2,
+ CRI_DB_LPB_Support=0xB3,
+ CRI_SSFBAddr0=0xB4,
+ CRI_SSFBAddr1=0xB5,
+ CRI_SSStride=0xB6,
+ CRI_SSOpaqueCtrl=0xB7,
+ CRI_SSVertScaleCtrl=0xB8,
+ CRI_SSVertInitValue=0xB9,
+ CRI_SSSrcLineCnt=0xBA,
+ CRI_FIFO_RAS_Ctrl=0xBB,
+ CRI_PSWinStartCoord=0xBC,
+ CRI_PSWinSize=0xBD,
+ CRI_SSWinStartCoord=0xBE,
+ CRI_SSWinSize=0xBF,
+ CRI_PSFIFOMon0=0xC0,
+ CRI_SSFIFOMon0=0xC1,
+ CRI_PSFIFOMon1=0xC2,
+ CRI_SSFIFOMon1=0xC3,
+ CRI_PSFBSize=0xC4,
+ CRI_SSFBSize=0xC5,
+ CRI_SSFBAddr2=0xC6,
+ /* 2D register starts at D0*/
+ CRI_CurrXY=0xD0,
+ CRI_DstXYorStep=0xD1 ,
+ CRI_LineErr=0xD2 ,
+ CRI_DrawCmd=0xD3, /*kick off for image xfer*/
+ CRI_ShortStrkVecXfer=0xD4,
+ CRI_BackClr=0xD5,
+ CRI_ForeClr=0xD6,
+ CRI_BitPlaneWtMask=0xD7,
+ CRI_BitPlaneRdMask=0xD8,
+ CRI_ClrCmp=0xD9 ,
+ CRI_BackAndForeMix=0xDA ,
+ CRI_TopLeftSciss=0xDB ,
+ CRI_BotRightSciss=0xDC ,
+ CRI_PixOrMultiCtrl=0xDD ,
+ CRI_MultiCtrlOrRdSelct=0xDE ,
+ CRI_MinorOrMajorAxisCnt=0xDF ,
+ CRI_GlobalBmpDesc1=0xE0 ,
+ CRI_GlobalBmpDesc2=0xE1 ,
+ CRI_BurstPriBmpDesc1=0xE2 ,
+ CRI_BurstPriBmpDesc2=0xE3 ,
+ CRI_BurstSecBmpDesc1=0xE4 ,
+ CRI_BurstSecBmpDesc2=0xE5,
+ CRI_ImageDataPort=0xF8
+
+}CtrlRegIdx;
+
+/***********************
+ Fog Mode
+************************/
+typedef enum
+{
+ FGM_Z_FOG, /*Table*/
+ FGM_V_FOG /*Vertex*/
+} FogMode;
+
+/***********************
+ Texture
+************************/
+typedef enum
+{
+ TAM_Wrap,
+ TAM_Clamp,
+ TAM_Mirror
+} TexAddressModel;
+
+typedef enum
+{
+ TFT_S3TC4Bit,
+ TFT_Pal8Bit565,
+ TFT_Pal8Bit1555,
+ TFT_ARGB8888,
+ TFT_ARGB1555,
+ TFT_ARGB4444,
+ TFT_RGB565,
+ TFT_Pal8Bit4444,
+ TFT_S3TC4A4Bit, /*like S3TC4Bit but with 4 bit alpha*/
+ TFT_S3TC4CA4Bit, /*like S3TC4Bit, but with 4 bit compressed alpha*/
+ TFT_S3TCL4,
+ TFT_S3TCA4L4,
+ TFT_L8,
+ TFT_A4L4,
+ TFT_I8,
+ TFT_A8
+} TexFmt;
+
+typedef enum
+{
+ TPS_64,
+ TPS_128,
+ TPS_192,
+ TPS_256
+} TexPaletteSize;
+
+#define MAX_MIPMAP_LOD_BIAS 255
+#define MIN_MIPMAP_LOD_BIAS -255
+
+typedef enum
+{
+ TFM_Point, /*1 TPP*/
+ TFM_Bilin, /*2 TPP*/
+ TFM_Reserved,
+ TFM_Trilin /*16 TPP*/
+} TexFilterMode;
+
+
+#define TBC_Decal 0x00850410
+#define TBC_Modul 0x00850011
+#define TBC_DecalAlpha 0x00852A04
+#define TBC_ModulAlpha 0x00110011
+#define TBC_Copy 0x00840410
+#define TBC_CopyAlpha 0x00900405
+#define TBC_NoTexMap 0x00850405
+#define TBC_Blend0 0x00810004
+#define TBC_Blend1 0x00870e02
+#define TBC_BlendAlpha0 0x00040004
+#define TBC_BlendAlpha1 TBC_Blend1
+#define TBC_BlendInt0 0x00040004
+#define TBC_BlendInt1 0x01c20e02
+#define TBC_AddAlpha 0x19910c11
+#define TBC_Add 0x18110c11
+
+#define TBC_Decal1 0x00870410
+#define TBC_Modul1 0x00870013
+#define TBC_DecalAlpha1 0x00832A00
+#define TBC_ModulAlpha1 0x00130013
+#define TBC_NoTexMap1 0x00870407
+#define TBC_Copy1 0x00870400
+#define TBC_CopyAlpha1 0x00900400
+#define TBC_AddAlpha1 0x19930c13
+#define TBC_Add1 0x18130c13
+
+/*
+ * derived from TexBlendCtrl
+ */
+
+typedef enum
+{
+ TBC_UseSrc,
+ TBC_UseTex,
+ TBC_TexTimesSrc,
+ TBC_BlendTexWithSrc
+} TexBlendCtrlMode;
+
+/***********************
+ Draw Control
+************************/
+typedef enum
+{
+ BCM_Reserved,
+ BCM_None,
+ BCM_CW,
+ BCM_CCW
+} BackfaceCullingMode;
+
+typedef enum
+{
+ SAM_Zero,
+ SAM_One,
+ SAM_DstClr,
+ SAM_1DstClr,
+ SAM_SrcAlpha,
+ SAM_1SrcAlpha,
+ SAM_DstAlpha,
+ SAM_1DstAlpha
+} SrcAlphaBlendMode;
+
+/* -1 from state*/
+typedef enum
+{
+ DAM_Zero,
+ DAM_One,
+ DAM_SrcClr,
+ DAM_1SrcClr,
+ DAM_SrcAlpha,
+ DAM_1SrcAlpha,
+ DAM_DstAlpha,
+ DAM_1DstAlpha
+} DstAlphaBlendMode;
+
+/*
+ * stencil control
+ */
+
+typedef enum
+{
+ STENCIL_Keep,
+ STENCIL_Zero,
+ STENCIL_Equal,
+ STENCIL_IncClamp,
+ STENCIL_DecClamp,
+ STENCIL_Invert,
+ STENCIL_Inc,
+ STENCIL_Dec
+} StencilOp;
+
+/***************************************************************
+*** Bitfield Structures for Programming Interface **************
+***************************************************************/
+
+/**************************
+ Command Header Entry
+**************************/
+
+typedef struct { /*for DrawIndexPrimitive command, vert0Idx is meaningful.*/
+ unsigned int vert0Idx:16;
+ unsigned int vertCnt:8;
+ unsigned int cont:1;
+ unsigned int type:2; /*00=list, 01=strip, 10=fan, 11=reserved*/
+ unsigned int cmd:5;
+}Reg_DrawIndexPrimitive;
+
+typedef struct { /*for DrawIndexPrimitive command, vert0Idx is meaningful.*/
+ unsigned int noW:1;
+ unsigned int noCd:1;
+ unsigned int noCs:1;
+ unsigned int noU:1;
+ unsigned int noV:1;
+ unsigned int noU2:1;
+ unsigned int noV2:1;
+
+ unsigned int reserved:9;
+ unsigned int vertCnt:8;
+ unsigned int cont:1;
+ unsigned int type:2; /* 00=list, 01=strip, 10=fan, 11=reserved*/
+ unsigned int cmd:5;
+}Reg_DrawPrimitive;
+
+
+typedef struct {
+ unsigned int startRegIdx:8;
+ unsigned int reserved:8;
+ unsigned int regCnt:8;
+ unsigned int resvered1:1;
+ unsigned int lowEn:1;
+ unsigned int highEn:1;
+ unsigned int cmd:5;
+}Reg_SetRegister;
+
+typedef struct {
+ unsigned int reserved1:22;
+ unsigned int isPrimary:1;
+ unsigned int MIU_SYNC:1;
+ unsigned int reserved2:3;
+ unsigned int cmd:5;
+}Reg_QueuedPageFlip;
+
+typedef struct {
+ unsigned int reserved1:22;
+ unsigned int DIR:1;
+ unsigned int CTG:1; /*set to 0*/
+ unsigned int BPP:1;
+ unsigned int reserved2:1;
+ unsigned int cmd:5;
+}Reg_MasterImgXfer;
+
+typedef struct {
+ unsigned int PD:4; /*PM=mono, PS=descriptor specified*/
+ unsigned int PT:1;
+ unsigned int SD:4;
+ unsigned int ST:1;
+ unsigned int DD:3;
+ unsigned int DC:2; /*DC=destination clip*/
+ unsigned int CS:1; /*cs=color specified*/
+ unsigned int MIX3:8;
+ unsigned int XP:1;
+ unsigned int YP:1;
+ unsigned int LP:1;
+ unsigned int cmd:5;
+}Reg_2D;
+
+typedef struct {
+ unsigned int CodedBlkPattern:6;
+ unsigned int DCT_Type:1;
+ unsigned int MB_Type:2;
+ unsigned int MotionType:2;
+ unsigned int MB_Row:6;
+ unsigned int MB_Column:6;
+ unsigned int mv3:1;
+ unsigned int mv2:1;
+ unsigned int mv1:1;
+ unsigned int mv0:1;
+ unsigned int cmd:5;
+}Reg_MacroBlock;
+
+typedef struct {
+ unsigned int scanLnCnt:11;
+ unsigned int clkCnt:5;
+ unsigned int e3d:1;
+ unsigned int e2d:1;
+ unsigned int mau:1;
+ unsigned int veu:1;
+ unsigned int meuMit:1;
+ unsigned int meuSit:1;
+ unsigned int meuVx:1;
+ unsigned int meuMau:1;
+ unsigned int pageFlip:1;
+ unsigned int scanLn:1;
+ unsigned int clk:1;
+ unsigned int cmd:5;
+}Reg_Wait;
+
+typedef struct{
+ unsigned int reserved:27;
+ unsigned int cmd:5;
+}Reg_ScaledImgXfer ;
+
+typedef struct{
+ unsigned int eventTag:16;
+ unsigned int reserved2:6;
+ unsigned int ET:1;
+ unsigned int INT:1;
+ unsigned int reserved1:3;
+ unsigned int cmd:5;
+}Reg_UpdtShadowStat;
+
+typedef union {
+ Reg_DrawPrimitive vert;
+ Reg_DrawIndexPrimitive vertIdx;
+ Reg_SetRegister set;
+ Reg_QueuedPageFlip pageFlip;
+ Reg_MasterImgXfer masterImgXfer;
+ Reg_ScaledImgXfer scaledImgXfer;
+ Reg_UpdtShadowStat updtShadow;
+ Reg_MacroBlock macroBlk;
+ Reg_2D cmd2D;
+ Reg_Wait wait;
+}CmdHeaderUnion;
+
+
+/*frank 2001/11/14 add BCI write macros*/
+/* Registers not used in the X server
+ */
+
+#define SAVAGE_NOP_ID 0x2094
+#define SAVAGE_NOP_ID_MASK ((1<<22)-1)
+
+
+/* 3D instructions
+ */
+
+/* Draw Primitive Control */
+
+
+#define SAVAGE_HW_NO_Z (1<<0)
+#define SAVAGE_HW_NO_W (1<<1)
+#define SAVAGE_HW_NO_CD (1<<2)
+#define SAVAGE_HW_NO_CS (1<<3)
+#define SAVAGE_HW_NO_U0 (1<<4)
+#define SAVAGE_HW_NO_V0 (1<<5)
+#define SAVAGE_HW_NO_UV0 ((1<<4) | (1<<5))
+#define SAVAGE_HW_NO_U1 (1<<6)
+#define SAVAGE_HW_NO_V1 (1<<7)
+#define SAVAGE_HW_NO_UV1 ((1<<6) | (1<<7))
+#define SAVAGE_HW_SKIPFLAGS 0x000000ff
+
+#endif
+
+
+
+
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savage_init.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savage_init.h
new file mode 100644
index 000000000..0dec397b7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savage_init.h
@@ -0,0 +1,168 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+#ifndef _SAVAGE_INIT_H_
+#define _SAVAGE_INIT_H_
+
+#include <sys/time.h>
+#include "dri_util.h"
+#include "mtypes.h"
+
+#include "xmlconfig.h"
+
+typedef struct {
+ drm_handle_t handle;
+ drmSize size;
+ char *map;
+} savageRegion, *savageRegionPtr;
+
+typedef struct {
+ int chipset;
+ int width;
+ int height;
+ int mem;
+
+ int cpp; /* for front and back buffers */
+ int zpp;
+
+ int agpMode;
+
+ unsigned int bufferSize;
+
+#if 0
+ int bitsPerPixel;
+#endif
+ unsigned int frontFormat;
+ unsigned int frontOffset;
+ unsigned int backOffset;
+ unsigned int depthOffset;
+
+ unsigned int aperturePitch;
+
+ unsigned int textureOffset[SAVAGE_NR_TEX_HEAPS];
+ unsigned int textureSize[SAVAGE_NR_TEX_HEAPS];
+ unsigned int logTextureGranularity[SAVAGE_NR_TEX_HEAPS];
+ drmAddress texVirtual[SAVAGE_NR_TEX_HEAPS];
+
+ __DRIscreenPrivate *driScrnPriv;
+
+ savageRegion aperture;
+ savageRegion agpTextures;
+
+ drmBufMapPtr bufs;
+
+ unsigned int sarea_priv_offset;
+
+ /* Configuration cache with default values for all contexts */
+ driOptionCache optionCache;
+} savageScreenPrivate;
+
+
+/**
+ * savageRenderbuffer, derived from Mesa's gl_renderbuffer
+ */
+typedef struct {
+ struct gl_renderbuffer Base;
+ /* XXX per-window info should go here */
+ int foo, bar;
+} savageRenderbuffer;
+
+
+#include "savagecontext.h"
+
+extern void savageGetLock( savageContextPtr imesa, GLuint flags );
+extern void savageXMesaSetBackClipRects( savageContextPtr imesa );
+extern void savageXMesaSetFrontClipRects( savageContextPtr imesa );
+
+
+#define GET_DISPATCH_AGE( imesa ) imesa->sarea->last_dispatch
+#define GET_ENQUEUE_AGE( imesa ) imesa->sarea->last_enqueue
+
+
+/* Lock the hardware and validate our state.
+ */
+#define LOCK_HARDWARE( imesa ) \
+ do { \
+ char __ret=0; \
+ DRM_CAS(imesa->driHwLock, imesa->hHWContext, \
+ (DRM_LOCK_HELD|imesa->hHWContext), __ret); \
+ if (__ret) \
+ savageGetLock( imesa, 0 ); \
+ } while (0)
+
+
+
+/* Unlock the hardware using the global current context
+ */
+#define UNLOCK_HARDWARE(imesa) \
+ DRM_UNLOCK(imesa->driFd, imesa->driHwLock, imesa->hHWContext);
+
+
+/* This is the wrong way to do it, I'm sure. Otherwise the drm
+ * bitches that I've already got the heavyweight lock. At worst,
+ * this is 3 ioctls. The best solution probably only gets me down
+ * to 2 ioctls in the worst case.
+ */
+#define LOCK_HARDWARE_QUIESCENT( imesa ) do { \
+ LOCK_HARDWARE( imesa ); \
+ savageRegetLockQuiescent( imesa ); \
+} while(0)
+
+/* The following definitions are copied from savage_regs.h in the XFree86
+ * driver. They are unlikely to change. If they do we need to keep them in
+ * sync. */
+
+#define S3_SAVAGE3D_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE_MX))
+
+#define S3_SAVAGE4_SERIES(chip) ((chip==S3_SAVAGE4) \
+ || (chip==S3_PROSAVAGE) \
+ || (chip==S3_TWISTER) \
+ || (chip==S3_PROSAVAGEDDR))
+
+#define S3_SAVAGE_MOBILE_SERIES(chip) ((chip==S3_SAVAGE_MX) || (chip==S3_SUPERSAVAGE))
+
+#define S3_SAVAGE_SERIES(chip) ((chip>=S3_SAVAGE3D) && (chip<=S3_SAVAGE2000))
+
+#define S3_MOBILE_TWISTER_SERIES(chip) ((chip==S3_TWISTER) \
+ ||(chip==S3_PROSAVAGEDDR))
+
+/* Chip tags. These are used to group the adapters into
+ * related families.
+ */
+
+enum S3CHIPTAGS {
+ S3_UNKNOWN = 0,
+ S3_SAVAGE3D,
+ S3_SAVAGE_MX,
+ S3_SAVAGE4,
+ S3_PROSAVAGE,
+ S3_TWISTER,
+ S3_PROSAVAGEDDR,
+ S3_SUPERSAVAGE,
+ S3_SAVAGE2000,
+ S3_LAST
+};
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savage_xmesa.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savage_xmesa.c
new file mode 100644
index 000000000..0c2fc4767
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savage_xmesa.c
@@ -0,0 +1,1056 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+#include <X11/Xlibint.h>
+#include <stdio.h>
+
+#include "savagecontext.h"
+#include "context.h"
+#include "matrix.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+#include "simple_list.h"
+
+#include "utils.h"
+
+#include "extensions.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "array_cache/acache.h"
+
+#include "tnl/t_pipeline.h"
+
+#include "drivers/common/driverfuncs.h"
+
+#include "savagedd.h"
+#include "savagestate.h"
+#include "savagetex.h"
+#include "savagespan.h"
+#include "savagetris.h"
+#include "savageioctl.h"
+#include "savage_bci.h"
+
+#include "savage_dri.h"
+
+#include "texmem.h"
+
+#define need_GL_ARB_multisample
+#define need_GL_ARB_texture_compression
+#include "extension_helper.h"
+
+#include "xmlpool.h"
+
+/* Driver-specific options
+ */
+#define SAVAGE_ENABLE_VDMA(def) \
+DRI_CONF_OPT_BEGIN(enable_vdma,bool,def) \
+ DRI_CONF_DESC(en,"Use DMA for vertex transfers") \
+ DRI_CONF_DESC(de,"Benutze DMA für Vertextransfers") \
+DRI_CONF_OPT_END
+#define SAVAGE_ENABLE_FASTPATH(def) \
+DRI_CONF_OPT_BEGIN(enable_fastpath,bool,def) \
+ DRI_CONF_DESC(en,"Use fast path for unclipped primitives") \
+ DRI_CONF_DESC(de,"Schneller Codepfad für ungeschnittene Polygone") \
+DRI_CONF_OPT_END
+#define SAVAGE_SYNC_FRAMES(def) \
+DRI_CONF_OPT_BEGIN(sync_frames,bool,def) \
+ DRI_CONF_DESC(en,"Synchronize with graphics hardware after each frame") \
+ DRI_CONF_DESC(de,"Synchronisiere nach jedem Frame mit Grafikhardware") \
+DRI_CONF_OPT_END
+
+/* Configuration
+ */
+PUBLIC const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_QUALITY
+ DRI_CONF_TEXTURE_DEPTH(DRI_CONF_TEXTURE_DEPTH_FB)
+ DRI_CONF_COLOR_REDUCTION(DRI_CONF_COLOR_REDUCTION_DITHER)
+ DRI_CONF_FLOAT_DEPTH(false)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_PERFORMANCE
+ SAVAGE_ENABLE_VDMA(true)
+ SAVAGE_ENABLE_FASTPATH(true)
+ SAVAGE_SYNC_FRAMES(false)
+ DRI_CONF_MAX_TEXTURE_UNITS(2,1,2)
+ DRI_CONF_TEXTURE_HEAPS(DRI_CONF_TEXTURE_HEAPS_ALL)
+ DRI_CONF_FORCE_S3TC_ENABLE(false)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_NO_RAST(false)
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+static const GLuint __driNConfigOptions = 10;
+
+
+static const struct dri_debug_control debug_control[] =
+{
+ { "fall", DEBUG_FALLBACKS },
+ { "api", DEBUG_VERBOSE_API },
+ { "tex", DEBUG_VERBOSE_TEX },
+ { "verb", DEBUG_VERBOSE_MSG },
+ { "dma", DEBUG_DMA },
+ { "state", DEBUG_STATE },
+ { NULL, 0 }
+};
+#ifndef SAVAGE_DEBUG
+int SAVAGE_DEBUG = 0;
+#endif
+
+
+/*For time caculating test*/
+#if defined(DEBUG_TIME) && DEBUG_TIME
+struct timeval tv_s,tv_f;
+unsigned long time_sum=0;
+struct timeval tv_s1,tv_f1;
+#endif
+
+static const struct dri_extension card_extensions[] =
+{
+ { "GL_ARB_multisample", GL_ARB_multisample_functions },
+ { "GL_ARB_multitexture", NULL },
+ { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions },
+ { "GL_EXT_stencil_wrap", NULL },
+ { "GL_EXT_texture_lod_bias", NULL },
+ { NULL, NULL }
+};
+
+static const struct dri_extension s4_extensions[] =
+{
+ { "GL_ARB_texture_env_add", NULL },
+ { "GL_ARB_texture_mirrored_repeat", NULL },
+ { NULL, NULL }
+};
+
+extern struct tnl_pipeline_stage _savage_texnorm_stage;
+extern struct tnl_pipeline_stage _savage_render_stage;
+
+static const struct tnl_pipeline_stage *savage_pipeline[] = {
+
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ &_savage_texnorm_stage,
+ &_savage_render_stage,
+ &_tnl_render_stage,
+ 0,
+};
+
+
+/* this is first function called in dirver*/
+
+static GLboolean
+savageInitDriver(__DRIscreenPrivate *sPriv)
+{
+ savageScreenPrivate *savageScreen;
+ SAVAGEDRIPtr gDRIPriv = (SAVAGEDRIPtr)sPriv->pDevPriv;
+
+ if (sPriv->devPrivSize != sizeof(SAVAGEDRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(SAVAGEDRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
+
+ /* Allocate the private area */
+ savageScreen = (savageScreenPrivate *)Xmalloc(sizeof(savageScreenPrivate));
+ if (!savageScreen)
+ return GL_FALSE;
+
+ savageScreen->driScrnPriv = sPriv;
+ sPriv->private = (void *)savageScreen;
+
+ savageScreen->chipset=gDRIPriv->chipset;
+ savageScreen->width=gDRIPriv->width;
+ savageScreen->height=gDRIPriv->height;
+ savageScreen->mem=gDRIPriv->mem;
+ savageScreen->cpp=gDRIPriv->cpp;
+ savageScreen->zpp=gDRIPriv->zpp;
+
+ savageScreen->agpMode=gDRIPriv->agpMode;
+
+ savageScreen->bufferSize=gDRIPriv->bufferSize;
+
+ if (gDRIPriv->cpp == 4)
+ savageScreen->frontFormat = DV_PF_8888;
+ else
+ savageScreen->frontFormat = DV_PF_565;
+ savageScreen->frontOffset=gDRIPriv->frontOffset;
+ savageScreen->backOffset = gDRIPriv->backOffset;
+ savageScreen->depthOffset=gDRIPriv->depthOffset;
+
+ savageScreen->textureOffset[SAVAGE_CARD_HEAP] =
+ gDRIPriv->textureOffset;
+ savageScreen->textureSize[SAVAGE_CARD_HEAP] =
+ gDRIPriv->textureSize;
+ savageScreen->logTextureGranularity[SAVAGE_CARD_HEAP] =
+ gDRIPriv->logTextureGranularity;
+
+ savageScreen->textureOffset[SAVAGE_AGP_HEAP] =
+ gDRIPriv->agpTextureHandle;
+ savageScreen->textureSize[SAVAGE_AGP_HEAP] =
+ gDRIPriv->agpTextureSize;
+ savageScreen->logTextureGranularity[SAVAGE_AGP_HEAP] =
+ gDRIPriv->logAgpTextureGranularity;
+
+ savageScreen->agpTextures.handle = gDRIPriv->agpTextureHandle;
+ savageScreen->agpTextures.size = gDRIPriv->agpTextureSize;
+ if (gDRIPriv->agpTextureSize) {
+ if (drmMap(sPriv->fd,
+ savageScreen->agpTextures.handle,
+ savageScreen->agpTextures.size,
+ (drmAddress *)&(savageScreen->agpTextures.map)) != 0) {
+ Xfree(savageScreen);
+ sPriv->private = NULL;
+ return GL_FALSE;
+ }
+ } else
+ savageScreen->agpTextures.map = NULL;
+
+ savageScreen->texVirtual[SAVAGE_CARD_HEAP] =
+ (drmAddress)(((GLubyte *)sPriv->pFB)+gDRIPriv->textureOffset);
+ savageScreen->texVirtual[SAVAGE_AGP_HEAP] =
+ (drmAddress)(savageScreen->agpTextures.map);
+
+ savageScreen->aperture.handle = gDRIPriv->apertureHandle;
+ savageScreen->aperture.size = gDRIPriv->apertureSize;
+ savageScreen->aperturePitch = gDRIPriv->aperturePitch;
+ if (drmMap(sPriv->fd,
+ savageScreen->aperture.handle,
+ savageScreen->aperture.size,
+ (drmAddress *)&savageScreen->aperture.map) != 0)
+ {
+ Xfree(savageScreen);
+ sPriv->private = NULL;
+ return GL_FALSE;
+ }
+
+ savageScreen->bufs = drmMapBufs(sPriv->fd);
+
+ savageScreen->sarea_priv_offset = gDRIPriv->sarea_priv_offset;
+
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo (&savageScreen->optionCache,
+ __driConfigOptions, __driNConfigOptions);
+
+#if 0
+ savageDDFastPathInit();
+ savageDDTrifuncInit();
+ savageDDSetupInit();
+#endif
+ return GL_TRUE;
+}
+
+/* Accessed by dlsym from dri_mesa_init.c
+ */
+static void
+savageDestroyScreen(__DRIscreenPrivate *sPriv)
+{
+ savageScreenPrivate *savageScreen = (savageScreenPrivate *)sPriv->private;
+
+ if (savageScreen->bufs)
+ drmUnmapBufs(savageScreen->bufs);
+
+ /* free all option information */
+ driDestroyOptionInfo (&savageScreen->optionCache);
+
+ Xfree(savageScreen);
+ sPriv->private = NULL;
+}
+
+#if 0
+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 */ );
+}
+#endif
+
+
+static GLboolean
+savageCreateContext( const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate )
+{
+ GLcontext *ctx, *shareCtx;
+ savageContextPtr imesa;
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ struct dd_function_table functions;
+ savageScreenPrivate *savageScreen = (savageScreenPrivate *)sPriv->private;
+ drm_savage_sarea_t *saPriv=(drm_savage_sarea_t *)(((char*)sPriv->pSAREA)+
+ savageScreen->sarea_priv_offset);
+ int textureSize[SAVAGE_NR_TEX_HEAPS];
+ int i;
+ imesa = (savageContextPtr)Xcalloc(sizeof(savageContext), 1);
+ if (!imesa) {
+ return GL_FALSE;
+ }
+
+ /* Init default driver functions then plug in savage-specific texture
+ * functions that are needed as early as during context creation. */
+ _mesa_init_driver_functions( &functions );
+ savageDDInitTextureFuncs( &functions );
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((savageContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ ctx = _mesa_create_context(mesaVis, shareCtx, &functions, imesa);
+ if (!ctx) {
+ Xfree(imesa);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = imesa;
+
+ imesa->cmdBuf.size = SAVAGE_CMDBUF_SIZE;
+ imesa->cmdBuf.base = imesa->cmdBuf.write =
+ malloc(SAVAGE_CMDBUF_SIZE * sizeof(drm_savage_cmd_header_t));
+ if (!imesa->cmdBuf.base)
+ return GL_FALSE;
+
+ /* Parse configuration files */
+ driParseConfigFiles (&imesa->optionCache, &savageScreen->optionCache,
+ sPriv->myNum, "savage");
+
+ imesa->float_depth = driQueryOptionb(&imesa->optionCache, "float_depth") &&
+ savageScreen->chipset >= S3_SAVAGE4;
+ imesa->no_rast = driQueryOptionb(&imesa->optionCache, "no_rast");
+
+#if 0
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 3.0;
+ ctx->Const.MaxLineWidthAA = 3.0;
+ ctx->Const.LineWidthGranularity = 1.0;
+#endif
+
+ /* Dri stuff
+ */
+ imesa->hHWContext = driContextPriv->hHWContext;
+ imesa->driFd = sPriv->fd;
+ imesa->driHwLock = &sPriv->pSAREA->lock;
+
+ imesa->savageScreen = savageScreen;
+ imesa->driScreen = sPriv;
+ imesa->sarea = saPriv;
+ imesa->glBuffer = NULL;
+
+ /* DMA buffer */
+
+ for(i=0;i<5;i++)
+ {
+ imesa->apertureBase[i] = (GLubyte *)savageScreen->aperture.map +
+ 0x01000000 * i;
+ }
+
+ imesa->aperturePitch = savageScreen->aperturePitch;
+
+ /* change texHeap initialize to support two kind of texture heap*/
+ /* here is some parts of initialization, others in InitDriver() */
+
+ (void) memset( imesa->textureHeaps, 0, sizeof( imesa->textureHeaps ) );
+ make_empty_list( & imesa->swapped );
+
+ textureSize[SAVAGE_CARD_HEAP] = savageScreen->textureSize[SAVAGE_CARD_HEAP];
+ textureSize[SAVAGE_AGP_HEAP] = savageScreen->textureSize[SAVAGE_AGP_HEAP];
+ imesa->lastTexHeap = savageScreen->texVirtual[SAVAGE_AGP_HEAP] ? 2 : 1;
+ switch(driQueryOptioni (&imesa->optionCache, "texture_heaps")) {
+ case DRI_CONF_TEXTURE_HEAPS_CARD: /* only use card memory, if available */
+ if (textureSize[SAVAGE_CARD_HEAP])
+ imesa->lastTexHeap = 1;
+ break;
+ case DRI_CONF_TEXTURE_HEAPS_GART: /* only use gart memory, if available */
+ if (imesa->lastTexHeap == 2 && textureSize[SAVAGE_AGP_HEAP])
+ textureSize[SAVAGE_CARD_HEAP] = 0;
+ break;
+ /*default: Nothing to do, use all available memory. */
+ }
+
+ for (i = 0; i < imesa->lastTexHeap; i++) {
+ imesa->textureHeaps[i] = driCreateTextureHeap(
+ i, imesa,
+ textureSize[i],
+ 11, /* 2^11 = 2k alignment */
+ SAVAGE_NR_TEX_REGIONS,
+ (drmTextureRegionPtr)imesa->sarea->texList[i],
+ &imesa->sarea->texAge[i],
+ &imesa->swapped,
+ sizeof( savageTexObj ),
+ (destroy_texture_object_t *) savageDestroyTexObj );
+ /* If textureSize[i] == 0 textureHeaps[i] is NULL. This can happen
+ * if there is not enough card memory for a card texture heap. */
+ if (imesa->textureHeaps[i])
+ driSetTextureSwapCounterLocation( imesa->textureHeaps[i],
+ & imesa->c_textureSwaps );
+ }
+ imesa->texture_depth = driQueryOptioni (&imesa->optionCache,
+ "texture_depth");
+ if (imesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FB)
+ imesa->texture_depth = ( savageScreen->cpp == 4 ) ?
+ DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16;
+
+ if (savageScreen->chipset >= S3_SAVAGE4)
+ ctx->Const.MaxTextureUnits = 2;
+ else
+ ctx->Const.MaxTextureUnits = 1;
+ if (driQueryOptioni(&imesa->optionCache, "texture_units") <
+ ctx->Const.MaxTextureUnits)
+ ctx->Const.MaxTextureUnits =
+ driQueryOptioni(&imesa->optionCache, "texture_units");
+ ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;
+ ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;
+
+ driCalculateMaxTextureLevels( imesa->textureHeaps,
+ imesa->lastTexHeap,
+ & ctx->Const,
+ 4,
+ 11, /* max 2D texture size is 2048x2048 */
+ 0, /* 3D textures unsupported. */
+ 0, /* cube textures unsupported. */
+ 0, /* texture rectangles unsupported. */
+ 12,
+ GL_FALSE );
+ if (ctx->Const.MaxTextureLevels <= 6) { /*spec requires at least 64x64*/
+ __driUtilMessage("Not enough texture memory. "
+ "Falling back to indirect rendering.");
+ Xfree(imesa);
+ return GL_FALSE;
+ }
+
+ imesa->hw_stencil = mesaVis->stencilBits && mesaVis->depthBits == 24;
+ imesa->depth_scale = (imesa->savageScreen->zpp == 2) ?
+ (1.0F/0xffff):(1.0F/0xffffff);
+
+ imesa->bufferSize = savageScreen->bufferSize;
+ imesa->dmaVtxBuf.total = 0;
+ imesa->dmaVtxBuf.used = 0;
+ imesa->dmaVtxBuf.flushed = 0;
+
+ imesa->clientVtxBuf.total = imesa->bufferSize / 4;
+ imesa->clientVtxBuf.used = 0;
+ imesa->clientVtxBuf.flushed = 0;
+ imesa->clientVtxBuf.buf = (u_int32_t *)malloc(imesa->bufferSize);
+
+ imesa->vtxBuf = &imesa->clientVtxBuf;
+
+ imesa->firstElt = -1;
+
+ /* Uninitialized vertex format. Force setting the vertex state in
+ * savageRenderStart.
+ */
+ imesa->vertex_size = 0;
+
+ /* Utah stuff
+ */
+ imesa->new_state = ~0;
+ imesa->new_gl_state = ~0;
+ imesa->RenderIndex = ~0;
+ imesa->dirty = ~0;
+ imesa->lostContext = GL_TRUE;
+ imesa->CurrentTexObj[0] = 0;
+ imesa->CurrentTexObj[1] = 0;
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+
+ _swsetup_CreateContext( ctx );
+
+ /* Install the customized pipeline:
+ */
+ _tnl_destroy_pipeline( ctx );
+ _tnl_install_pipeline( ctx, savage_pipeline );
+
+ imesa->enable_fastpath = driQueryOptionb(&imesa->optionCache,
+ "enable_fastpath");
+ /* DRM versions before 2.1.3 would only render triangle lists. ELTS
+ * support was added in 2.2.0. */
+ if (imesa->enable_fastpath && sPriv->drmMinor < 2) {
+ fprintf (stderr,
+ "*** Disabling fast path because your DRM version is buggy "
+ "or doesn't\n*** support ELTS. You need at least Savage DRM "
+ "version 2.2.\n");
+ imesa->enable_fastpath = GL_FALSE;
+ }
+
+ if (!savageScreen->bufs || savageScreen->chipset == S3_SUPERSAVAGE)
+ imesa->enable_vdma = GL_FALSE;
+ else
+ imesa->enable_vdma = driQueryOptionb(&imesa->optionCache, "enable_vdma");
+
+ imesa->sync_frames = driQueryOptionb(&imesa->optionCache, "sync_frames");
+
+ /* Configure swrast to match hardware characteristics:
+ */
+ _tnl_allow_pixel_fog( ctx, GL_FALSE );
+ _tnl_allow_vertex_fog( ctx, GL_TRUE );
+ _swrast_allow_pixel_fog( ctx, GL_FALSE );
+ _swrast_allow_vertex_fog( ctx, GL_TRUE );
+
+ ctx->DriverCtx = (void *) imesa;
+ imesa->glCtx = ctx;
+
+#ifndef SAVAGE_DEBUG
+ SAVAGE_DEBUG = driParseDebugString( getenv( "SAVAGE_DEBUG" ),
+ debug_control );
+#endif
+
+ driInitExtensions( ctx, card_extensions, GL_TRUE );
+ if (savageScreen->chipset >= S3_SAVAGE4)
+ driInitExtensions( ctx, s4_extensions, GL_FALSE );
+ if (ctx->Mesa_DXTn ||
+ driQueryOptionb (&imesa->optionCache, "force_s3tc_enable")) {
+ _mesa_enable_extension( ctx, "GL_S3_s3tc" );
+ if (savageScreen->chipset >= S3_SAVAGE4)
+ /* This extension needs DXT3 and DTX5 support in hardware.
+ * Not available on Savage3D/MX/IX. */
+ _mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
+ }
+
+ savageDDInitStateFuncs( ctx );
+ savageDDInitSpanFuncs( ctx );
+ savageDDInitDriverFuncs( ctx );
+ savageDDInitIoctlFuncs( ctx );
+ savageInitTriFuncs( ctx );
+
+ savageDDInitState( imesa );
+
+ driContextPriv->driverPrivate = (void *) imesa;
+
+ return GL_TRUE;
+}
+
+static void
+savageDestroyContext(__DRIcontextPrivate *driContextPriv)
+{
+ savageContextPtr imesa = (savageContextPtr) driContextPriv->driverPrivate;
+ GLuint i;
+
+ assert (imesa); /* should never be NULL */
+ if (imesa) {
+ savageFlushVertices(imesa);
+ savageReleaseIndexedVerts(imesa);
+ savageFlushCmdBuf(imesa, GL_TRUE); /* release DMA buffer */
+ WAIT_IDLE_EMPTY(imesa);
+
+ for (i = 0; i < imesa->lastTexHeap; i++)
+ driDestroyTextureHeap(imesa->textureHeaps[i]);
+
+ free(imesa->cmdBuf.base);
+ free(imesa->clientVtxBuf.buf);
+
+ _swsetup_DestroyContext(imesa->glCtx );
+ _tnl_DestroyContext( imesa->glCtx );
+ _ac_DestroyContext( imesa->glCtx );
+ _swrast_DestroyContext( imesa->glCtx );
+
+ /* free the Mesa context */
+ imesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(imesa->glCtx);
+
+ /* no longer use vertex_dma_buf*/
+ Xfree(imesa);
+ }
+}
+
+
+static GLboolean
+savageCreateBuffer( __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap)
+{
+ savageScreenPrivate *screen = (savageScreenPrivate *) driScrnPriv->private;
+
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+ GLboolean swStencil = mesaVis->stencilBits > 0 && mesaVis->depthBits != 24;
+#if 0
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ mesaVis->alphaBits > 0 );
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+ /*
+ * XXX: this value needs to be set according to the config file
+ * setting. But we don't get that until we create a rendering
+ * context!!!!
+ */
+ GLboolean float_depth = GL_FALSE;
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->aperturePitch);
+ savageSetSpanFunctions(frontRb, mesaVis, float_depth);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->aperturePitch);
+ savageSetSpanFunctions(backRb, mesaVis, float_depth);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->aperturePitch);
+ savageSetSpanFunctions(depthRb, mesaVis, float_depth);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->aperturePitch);
+ savageSetSpanFunctions(depthRb, mesaVis, float_depth);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+ screen->depthOffset, screen->aperturePitch);
+ savageSetSpanFunctions(stencilRb, mesaVis, float_depth);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+static void
+savageDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+#if 0
+void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv)
+{
+ /* XXX should do swap according to the buffer, not the context! */
+ savageContextPtr imesa = savageCtx;
+
+ FLUSH_VB( imesa->glCtx, "swap buffers" );
+ savageSwapBuffers(imesa);
+}
+#endif
+
+void savageXMesaSetFrontClipRects( savageContextPtr imesa )
+{
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+
+ imesa->numClipRects = dPriv->numClipRects;
+ imesa->pClipRects = dPriv->pClipRects;
+ imesa->drawX = dPriv->x;
+ imesa->drawY = dPriv->y;
+
+ savageCalcViewport( imesa->glCtx );
+}
+
+
+void savageXMesaSetBackClipRects( savageContextPtr imesa )
+{
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+
+ if (dPriv->numBackClipRects == 0)
+ {
+
+
+ imesa->numClipRects = dPriv->numClipRects;
+ imesa->pClipRects = dPriv->pClipRects;
+ imesa->drawX = dPriv->x;
+ imesa->drawY = dPriv->y;
+ } else {
+
+
+ imesa->numClipRects = dPriv->numBackClipRects;
+ imesa->pClipRects = dPriv->pBackClipRects;
+ imesa->drawX = dPriv->backX;
+ imesa->drawY = dPriv->backY;
+ }
+
+ savageCalcViewport( imesa->glCtx );
+}
+
+
+static void savageXMesaWindowMoved( savageContextPtr imesa )
+{
+ if (0)
+ fprintf(stderr, "savageXMesaWindowMoved\n\n");
+
+ switch (imesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) {
+ case BUFFER_BIT_FRONT_LEFT:
+ savageXMesaSetFrontClipRects( imesa );
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ savageXMesaSetBackClipRects( imesa );
+ break;
+ default:
+ break;
+ }
+}
+
+
+static GLboolean
+savageUnbindContext(__DRIcontextPrivate *driContextPriv)
+{
+ savageContextPtr savage = (savageContextPtr) driContextPriv->driverPrivate;
+ if (savage)
+ savage->dirty = ~0;
+
+ return GL_TRUE;
+}
+
+#if 0
+static GLboolean
+savageOpenFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+
+
+
+ if (driContextPriv) {
+ savageContextPtr imesa = (savageContextPtr) driContextPriv->driverPrivate;
+ imesa->IsFullScreen = GL_TRUE;
+ imesa->backup_frontOffset = imesa->savageScreen->frontOffset;
+ imesa->backup_backOffset = imesa->savageScreen->backOffset;
+ imesa->backup_frontBitmapDesc = imesa->savageScreen->frontBitmapDesc;
+ imesa->savageScreen->frontBitmapDesc = imesa->savageScreen->backBitmapDesc;
+ imesa->toggle = TARGET_BACK;
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean
+savageCloseFullScreen(__DRIcontextPrivate *driContextPriv)
+{
+
+ if (driContextPriv) {
+ savageContextPtr imesa = (savageContextPtr) driContextPriv->driverPrivate;
+ WAIT_IDLE_EMPTY(imesa);
+ imesa->IsFullScreen = GL_FALSE;
+ imesa->savageScreen->frontOffset = imesa->backup_frontOffset;
+ imesa->savageScreen->backOffset = imesa->backup_backOffset;
+ imesa->savageScreen->frontBitmapDesc = imesa->backup_frontBitmapDesc;
+ }
+ return GL_TRUE;
+}
+#endif
+
+static GLboolean
+savageMakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
+{
+ if (driContextPriv) {
+ savageContextPtr imesa = (savageContextPtr) driContextPriv->driverPrivate;
+
+ imesa->driReadable = driReadPriv;
+ imesa->driDrawable = driDrawPriv;
+ imesa->mesa_drawable = driDrawPriv;
+ imesa->dirty = ~0;
+
+ _mesa_make_current(imesa->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate);
+
+ savageXMesaWindowMoved( imesa );
+ }
+ else
+ {
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+ return GL_TRUE;
+}
+
+
+void savageGetLock( savageContextPtr imesa, GLuint flags )
+{
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+ __DRIscreenPrivate *sPriv = imesa->driScreen;
+ drm_savage_sarea_t *sarea = imesa->sarea;
+ int me = imesa->hHWContext;
+ int stamp = dPriv->lastStamp;
+ int heap;
+ unsigned int timestamp = 0;
+
+
+
+ /* 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
+ * checking must be done *after* this call:
+ */
+ DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
+
+
+
+
+ /* 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) {
+ imesa->dirty |= (SAVAGE_UPLOAD_LOCAL |
+ SAVAGE_UPLOAD_GLOBAL |
+ SAVAGE_UPLOAD_FOGTBL |
+ SAVAGE_UPLOAD_TEX0 |
+ SAVAGE_UPLOAD_TEX1 |
+ SAVAGE_UPLOAD_TEXGLOBAL);
+ imesa->lostContext = GL_TRUE;
+ sarea->ctxOwner = me;
+ }
+
+ for (heap = 0; heap < imesa->lastTexHeap; ++heap) {
+ /* If a heap was changed, update its timestamp. Do this before
+ * DRI_AGE_TEXTURES updates the local_age. */
+ if (imesa->textureHeaps[heap] &&
+ imesa->textureHeaps[heap]->global_age[0] >
+ imesa->textureHeaps[heap]->local_age) {
+ if (timestamp == 0)
+ timestamp = savageEmitEventLocked(imesa, 0);
+ imesa->textureHeaps[heap]->timestamp = timestamp;
+ }
+ DRI_AGE_TEXTURES( imesa->textureHeaps[heap] );
+ }
+
+ if (dPriv->lastStamp != stamp)
+ savageXMesaWindowMoved( imesa );
+
+
+
+}
+
+
+
+static const struct __DriverAPIRec savageAPI = {
+ savageInitDriver,
+ savageDestroyScreen,
+ savageCreateContext,
+ savageDestroyContext,
+ savageCreateBuffer,
+ savageDestroyBuffer,
+ savageSwapBuffers,
+ savageMakeCurrent,
+ savageUnbindContext
+};
+
+
+static __GLcontextModes *
+savageFillInModes( unsigned pixel_bits, unsigned depth_bits,
+ unsigned stencil_bits, GLboolean have_back_buffer )
+{
+ __GLcontextModes * modes;
+ __GLcontextModes * m;
+ unsigned num_modes;
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ GLenum fb_format;
+ GLenum fb_type;
+
+ /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
+ * enough to add support. Basically, if a context is created with an
+ * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
+ * will never be used.
+ *
+ * FK: What about drivers that don't use page flipping? Could they
+ * just expose GLX_SWAP_COPY_OML?
+ */
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
+ };
+
+ u_int8_t depth_bits_array[2];
+ u_int8_t stencil_bits_array[2];
+
+
+ depth_bits_array[0] = depth_bits;
+ depth_bits_array[1] = depth_bits;
+
+ /* Just like with the accumulation buffer, always provide some modes
+ * with a stencil buffer. It will be a sw fallback, but some apps won't
+ * care about that.
+ */
+ stencil_bits_array[0] = 0;
+ stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
+
+ depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 2 : 1;
+ back_buffer_factor = (have_back_buffer) ? 2 : 1;
+
+ num_modes = depth_buffer_factor * back_buffer_factor * 4;
+
+ if ( pixel_bits == 16 ) {
+ fb_format = GL_RGB;
+ fb_type = GL_UNSIGNED_SHORT_5_6_5;
+ }
+ else {
+ fb_format = GL_BGR;
+ fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ }
+
+ modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
+ m = modes;
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_TRUE_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_DIRECT_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+
+ /* Mark the visual as slow if there are "fake" stencil bits.
+ */
+ for ( m = modes ; m != NULL ; m = m->next ) {
+ if ( (m->stencilBits != 0) && (m->stencilBits != stencil_bits) ) {
+ m->visualRating = GLX_SLOW_CONFIG;
+ }
+ }
+
+ return modes;
+}
+
+
+/**
+ * This is the bootstrap function for the driver. libGL supplies all of the
+ * requisite information about the system, and the driver initializes itself.
+ * This routine also fills in the linked list pointed to by \c driver_modes
+ * with the \c __GLcontextModes that the driver can support for windows or
+ * pbuffers.
+ *
+ * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
+ * failure.
+ */
+PUBLIC
+void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
+ const __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drmAddress pSAREA, int fd,
+ int internal_api_version,
+ const __DRIinterfaceMethods * interface,
+ __GLcontextModes ** driver_modes )
+
+{
+ __DRIscreenPrivate *psp;
+ static const __DRIversion ddx_expected = { 2, 0, 0 };
+ static const __DRIversion dri_expected = { 4, 0, 0 };
+ static const __DRIversion drm_expected = { 2, 1, 0 };
+
+ dri_interface = interface;
+
+ if ( ! driCheckDriDdxDrmVersions2( "Savage",
+ dri_version, & dri_expected,
+ ddx_version, & ddx_expected,
+ drm_version, & drm_expected ) ) {
+ return NULL;
+ }
+
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &savageAPI);
+ if ( psp != NULL ) {
+ SAVAGEDRIPtr dri_priv = (SAVAGEDRIPtr)psp->pDevPriv;
+ *driver_modes = savageFillInModes( dri_priv->cpp*8,
+ (dri_priv->cpp == 2) ? 16 : 24,
+ (dri_priv->cpp == 2) ? 0 : 8,
+ (dri_priv->backOffset != dri_priv->depthOffset) );
+
+ /* Calling driInitExtensions here, with a NULL context pointer, does not actually
+ * enable the extensions. It just makes sure that all the dispatch offsets for all
+ * the extensions that *might* be enables are known. This is needed because the
+ * dispatch offsets need to be known when _mesa_context_create is called, but we can't
+ * enable the extensions until we have a context pointer.
+ *
+ * Hello chicken. Hello egg. How are you two today?
+ */
+ driInitExtensions( NULL, card_extensions, GL_FALSE );
+ }
+
+ return (void *) psp;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagecontext.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagecontext.h
new file mode 100644
index 000000000..4c0959968
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagecontext.h
@@ -0,0 +1,331 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+
+#ifndef SAVAGECONTEXT_INC
+#define SAVAGECONTEXT_INC
+
+typedef struct savage_context_t savageContext;
+typedef struct savage_context_t *savageContextPtr;
+typedef struct savage_texture_object_t *savageTextureObjectPtr;
+
+#include <X11/Xlibint.h>
+#include "dri_util.h"
+#include "mtypes.h"
+#include "xf86drm.h"
+#include "drm.h"
+#include "savage_drm.h"
+#include "savage_init.h"
+#include "savage_3d_reg.h"
+#include "mm.h"
+#include "tnl/t_vertex.h"
+
+#include "texmem.h"
+
+#include "xmlconfig.h"
+
+/* Reasons to fallback on all primitives.
+ */
+#define SAVAGE_FALLBACK_TEXTURE 0x1
+#define SAVAGE_FALLBACK_DRAW_BUFFER 0x2
+#define SAVAGE_FALLBACK_READ_BUFFER 0x4
+#define SAVAGE_FALLBACK_COLORMASK 0x8
+#define SAVAGE_FALLBACK_SPECULAR 0x10
+#define SAVAGE_FALLBACK_LOGICOP 0x20
+/*frank 2001/11/12 add the stencil fallbak*/
+#define SAVAGE_FALLBACK_STENCIL 0x40
+#define SAVAGE_FALLBACK_RENDERMODE 0x80
+#define SAVAGE_FALLBACK_BLEND_EQ 0x100
+#define SAVAGE_FALLBACK_NORAST 0x200
+#define SAVAGE_FALLBACK_PROJ_TEXTURE 0x400
+
+
+#define HW_CULL 1
+
+/* for savagectx.new_state - manage GL->driver state changes
+ */
+#define SAVAGE_NEW_TEXTURE 0x1
+#define SAVAGE_NEW_CULL 0x2
+
+/* What needs to be changed for the current vertex dma buffer?
+ * This will go away!
+ */
+#define SAVAGE_UPLOAD_LOCAL 0x1 /* DrawLocalCtrl (S4) or
+ DrawCtrl and ZBufCtrl (S3D) */
+#define SAVAGE_UPLOAD_TEX0 0x2 /* texture unit 0 */
+#define SAVAGE_UPLOAD_TEX1 0x4 /* texture unit 1 (S4 only) */
+#define SAVAGE_UPLOAD_FOGTBL 0x8 /* fog table */
+#define SAVAGE_UPLOAD_GLOBAL 0x10 /* most global regs */
+#define SAVAGE_UPLOAD_TEXGLOBAL 0x20 /* TexBlendColor (S4 only) */
+
+/*define the max numer of vertex in vertex buf*/
+#define SAVAGE_MAX_VERTEXS 0x10000
+
+/* Don't make it too big. We don't want to buffer up a whole frame
+ * that would force the application to wait later. */
+#define SAVAGE_CMDBUF_SIZE 1024
+
+/* Use the templated vertex formats:
+ */
+#define TAG(x) savage##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+typedef void (*savage_tri_func)( savageContextPtr, savageVertex *,
+ savageVertex *, savageVertex * );
+typedef void (*savage_line_func)( savageContextPtr,
+ savageVertex *, savageVertex * );
+typedef void (*savage_point_func)( savageContextPtr, savageVertex * );
+
+
+/**************************************************************
+ **************** enums for chip IDs ************************
+ **************************************************************/
+
+#define CHIP_S3GX3MS1NB 0x8A25
+#define CHIP_S3GX3MS1NBK 0x8A26
+#define CHIP_S3TWISTER 0x8D01
+#define CHIP_S3TWISTERK 0x8D02
+#define CHIP_S3TWISTER_P4M 0x8D04
+#define CHIP_S3PARAMOUNT128 0x8C22 /*SuperSavage 128/MX*/
+#define CHIP_S3TRISTAR128SDR 0x8C2A /*SuperSavage 128/IX*/
+#define CHIP_S3TRISTAR64SDRM7 0x8C2C /*SuperSavage/IX M7 Package*/
+#define CHIP_S3TRISTAR64SDR 0x8C2E /*SuperSavage/IX*/
+#define CHIP_S3TRISTAR64CDDR 0x8C2F /*SuperSavage/IXC DDR*/
+
+#define IS_SAVAGE(imesa) (imesa->savageScreen->deviceID == CHIP_S3GX3MS1NB || \
+ imesa->savageScreen->deviceID == CHIP_S3GX3MS1NBK || \
+ imesa->savageScreen->deviceID == CHIP_S3TWISTER || \
+ imesa->savageScreen->deviceID == CHIP_S3TWISTERK || \
+ imesa->savageScreen->deviceID == CHIP_S3TWISTER_P4M || \
+ imesa->savageScreen->deviceID == CHIP_S3PARAMOUNT128 || \
+ imesa->savageScreen->deviceID == CHIP_S3TRISTAR128SDR || \
+ imesa->savageScreen->deviceID == CHIP_S3TRISTAR64SDRM7 || \
+ imesa->savageScreen->deviceID == CHIP_S3TRISTAR64SDR || \
+ imesa->savageScreen->deviceID == CHIP_S3TRISTAR64CDDR )
+
+
+struct savage_vtxbuf_t {
+ GLuint total, used, flushed; /* in 32 bit units */
+ GLuint idx; /* for DMA buffers */
+ u_int32_t *buf;
+};
+
+struct savage_cmdbuf_t {
+ GLuint size; /* size in qwords */
+ drm_savage_cmd_header_t *base; /* initial state starts here */
+ drm_savage_cmd_header_t *start; /* drawing/state commands start here */
+ drm_savage_cmd_header_t *write; /* append stuff here */
+};
+
+struct savage_elt_t {
+ GLuint n; /* number of elts currently allocated */
+ drm_savage_cmd_header_t *cmd; /* the indexed drawing command */
+};
+
+
+struct savage_context_t {
+ GLint refcount;
+
+ GLcontext *glCtx;
+
+ int lastTexHeap;
+ driTexHeap *textureHeaps[SAVAGE_NR_TEX_HEAPS];
+ driTextureObject swapped;
+
+ driTextureObject *CurrentTexObj[2];
+
+ /* Hardware state
+ */
+
+ savageRegisters regs, oldRegs, globalRegMask;
+
+ /* Manage our own state */
+ GLuint new_state;
+ GLuint new_gl_state;
+ GLboolean ptexHack;
+
+ /* Command buffer */
+ struct savage_cmdbuf_t cmdBuf;
+
+ /* Elt book-keeping */
+ struct savage_elt_t elts;
+ GLint firstElt;
+
+ /* Vertex buffers */
+ struct savage_vtxbuf_t dmaVtxBuf, clientVtxBuf;
+ struct savage_vtxbuf_t *vtxBuf;
+
+ /* aperture base */
+ GLubyte *apertureBase[5];
+ GLuint aperturePitch;
+ /* Manage hardware state */
+ GLuint dirty;
+ GLboolean lostContext;
+ GLuint bTexEn1;
+ /* One of the few bits of hardware state that can't be calculated
+ * completely on the fly:
+ */
+ GLuint LcsCullMode;
+ GLuint texEnvColor;
+
+ /* Vertex state
+ */
+ GLuint vertex_size;
+ struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
+ GLuint vertex_attr_count;
+ char *verts; /* points to tnl->clipspace.vertex_buf */
+
+ /* Rasterization state
+ */
+ GLuint SetupNewInputs;
+ GLuint SetupIndex;
+ GLuint RenderIndex;
+
+ GLuint hw_primitive;
+ GLenum raster_primitive;
+ GLenum render_primitive;
+
+ GLuint skip;
+ GLubyte HwPrim;
+ GLuint HwVertexSize;
+
+ /* Fallback rasterization functions
+ */
+ savage_point_func draw_point;
+ savage_line_func draw_line;
+ savage_tri_func draw_tri;
+
+ /* Funny mesa mirrors
+ */
+ GLuint MonoColor;
+ GLuint ClearColor;
+ GLfloat depth_scale;
+ GLfloat hw_viewport[16];
+ /* DRI stuff */
+ GLuint bufferSize;
+
+ GLframebuffer *glBuffer;
+
+ /* Two flags to keep track of fallbacks. */
+ GLuint Fallback;
+
+ GLuint needClip;
+
+ /* These refer to the current draw (front vs. back) buffer:
+ */
+ GLubyte *drawMap; /* draw buffer address in virtual mem */
+ GLubyte *readMap;
+ int drawX; /* origin of drawable in draw buffer */
+ int drawY;
+ GLuint numClipRects; /* cliprects for that buffer */
+ GLint currentClip;
+ drm_clip_rect_t *pClipRects;
+
+ /* use this bit to support single/double buffer */
+ GLuint IsDouble;
+ /* use this to indicate Fullscreen mode */
+ GLuint IsFullScreen; /* FIXME - open/close fullscreen is gone, is this needed? */
+ GLuint backup_frontOffset;
+ GLuint backup_backOffset;
+ GLuint backup_frontBitmapDesc;
+ GLuint toggle;
+ GLuint backup_streamFIFO;
+ GLuint NotFirstFrame;
+
+ GLboolean inSwap;
+ GLuint lastSwap;
+ GLuint ctxAge;
+ GLuint dirtyAge;
+ GLuint any_contend; /* throttle me harder */
+
+ /* Scissor state needs to be mirrored so buffered commands can be
+ * emitted with the old scissor state when scissor state changes.
+ */
+ struct {
+ GLboolean enabled;
+ GLint x, y;
+ GLsizei w, h;
+ } scissor;
+
+ drm_context_t hHWContext;
+ drm_hw_lock_t *driHwLock;
+ GLuint driFd;
+
+ __DRIdrawablePrivate *driDrawable;
+ __DRIdrawablePrivate *driReadable;
+
+ /**
+ * Drawable used by Mesa for software fallbacks for reading and
+ * writing. It is set by Mesa's \c SetBuffer callback, and will always be
+ * either \c mga_context_t::driDrawable or \c mga_context_t::driReadable.
+ */
+ __DRIdrawablePrivate *mesa_drawable;
+
+ __DRIscreenPrivate *driScreen;
+ savageScreenPrivate *savageScreen;
+ drm_savage_sarea_t *sarea;
+
+ GLboolean hw_stencil;
+
+ /* Performance counters
+ */
+ GLuint c_textureSwaps;
+
+ /* Configuration cache
+ */
+ driOptionCache optionCache;
+ GLint texture_depth;
+ GLboolean no_rast;
+ GLboolean float_depth;
+ GLboolean enable_fastpath;
+ GLboolean enable_vdma;
+ GLboolean sync_frames;
+};
+
+#define SAVAGE_CONTEXT(ctx) ((savageContextPtr)(ctx->DriverCtx))
+
+/* To remove all debugging, make sure SAVAGE_DEBUG is defined as a
+ * preprocessor symbol, and equal to zero.
+ */
+#ifndef SAVAGE_DEBUG
+extern int SAVAGE_DEBUG;
+#endif
+
+#define DEBUG_FALLBACKS 0x001
+#define DEBUG_VERBOSE_API 0x002
+#define DEBUG_VERBOSE_TEX 0x004
+#define DEBUG_VERBOSE_MSG 0x008
+#define DEBUG_DMA 0x010
+#define DEBUG_STATE 0x020
+
+#define TARGET_FRONT 0x0
+#define TARGET_BACK 0x1
+#define TARGET_DEPTH 0x2
+
+#define SUBPIXEL_X -0.5
+#define SUBPIXEL_Y -0.375
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagedd.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagedd.c
new file mode 100644
index 000000000..ced44e562
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagedd.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+#include "mtypes.h"
+#include "framebuffer.h"
+
+#include <stdio.h>
+
+#include "mm.h"
+#include "swrast/swrast.h"
+
+#include "savagedd.h"
+#include "savagestate.h"
+#include "savagespan.h"
+#include "savagetex.h"
+#include "savagetris.h"
+#include "savagecontext.h"
+#include "extensions.h"
+
+#include "utils.h"
+
+
+#define DRIVER_DATE "20050829"
+
+/***************************************
+ * Mesa's Driver Functions
+ ***************************************/
+
+
+static const GLubyte *savageDDGetString( GLcontext *ctx, GLenum name )
+{
+ static char *cardNames[S3_LAST] = {
+ "Unknown",
+ "Savage3D",
+ "Savage/MX/IX",
+ "Savage4",
+ "ProSavage",
+ "Twister",
+ "ProSavageDDR",
+ "SuperSavage",
+ "Savage2000"
+ };
+ static char buffer[128];
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ savageScreenPrivate *screen = imesa->savageScreen;
+ enum S3CHIPTAGS chipset = screen->chipset;
+ unsigned offset;
+
+ if (chipset < S3_SAVAGE3D || chipset >= S3_LAST)
+ chipset = S3_UNKNOWN; /* should not happen */
+
+ switch (name) {
+ case GL_VENDOR:
+ return (GLubyte *)"S3 Graphics Inc.";
+ case GL_RENDERER:
+ offset = driGetRendererString( buffer, cardNames[chipset], DRIVER_DATE,
+ screen->agpMode );
+ return (GLubyte *)buffer;
+ default:
+ return 0;
+ }
+}
+#if 0
+static GLint savageGetParameteri(const GLcontext *ctx, GLint param)
+{
+ switch (param) {
+ case DD_HAVE_HARDWARE_FOG:
+ return 1;
+ default:
+ return 0;
+ }
+}
+#endif
+
+
+static void savageBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+
+ /* Need to lock to make sure the driDrawable is uptodate. This
+ * information is used to resize Mesa's software buffers, so it has
+ * to be correct.
+ */
+ LOCK_HARDWARE(imesa);
+ *width = imesa->driDrawable->w;
+ *height = imesa->driDrawable->h;
+ UNLOCK_HARDWARE(imesa);
+}
+
+
+void savageDDInitDriverFuncs( GLcontext *ctx )
+{
+ ctx->Driver.GetBufferSize = savageBufferSize;
+ ctx->Driver.ResizeBuffers = _mesa_resize_framebuffer;
+ ctx->Driver.GetString = savageDDGetString;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagedd.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagedd.h
new file mode 100644
index 000000000..ae167be70
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagedd.h
@@ -0,0 +1,32 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+#ifndef SAVAGEDD_INC
+#define SAVAGEDD_INC
+
+#include "context.h"
+
+void savageDDInitDriverFuncs( GLcontext *ctx );
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savageioctl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savageioctl.c
new file mode 100644
index 000000000..f759034e4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savageioctl.c
@@ -0,0 +1,657 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+#include "mtypes.h"
+#include "macros.h"
+#include "dd.h"
+#include "context.h"
+#include "swrast/swrast.h"
+#include "colormac.h"
+
+#include "mm.h"
+#include "savagecontext.h"
+#include "savageioctl.h"
+#include "savage_bci.h"
+#include "savagestate.h"
+#include "savagespan.h"
+
+#include "drm.h"
+#include <sys/ioctl.h>
+#include <sys/timeb.h>
+
+#define DEPTH_SCALE_16 ((1<<16)-1)
+#define DEPTH_SCALE_24 ((1<<24)-1)
+
+
+void savageGetDMABuffer( savageContextPtr imesa )
+{
+ int idx = 0;
+ int size = 0;
+ drmDMAReq dma;
+ int retcode;
+ drmBufPtr buf;
+
+ assert (imesa->savageScreen->bufs);
+
+ if (SAVAGE_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "Getting dma buffer\n");
+
+ dma.context = imesa->hHWContext;
+ dma.send_count = 0;
+ dma.send_list = NULL;
+ dma.send_sizes = NULL;
+ dma.flags = 0;
+ dma.request_count = 1;
+ dma.request_size = imesa->bufferSize;
+ dma.request_list = &idx;
+ dma.request_sizes = &size;
+ dma.granted_count = 0;
+
+
+ if (SAVAGE_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "drmDMA (get) ctx %d count %d size 0x%x\n",
+ dma.context, dma.request_count,
+ dma.request_size);
+
+ while (1) {
+ retcode = drmDMA(imesa->driFd, &dma);
+
+ if (SAVAGE_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "retcode %d sz %d idx %d count %d\n",
+ retcode,
+ dma.request_sizes[0],
+ dma.request_list[0],
+ dma.granted_count);
+
+ if (retcode == 0 &&
+ dma.request_sizes[0] &&
+ dma.granted_count)
+ break;
+
+ if (SAVAGE_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "\n\nflush");
+ }
+
+ buf = &(imesa->savageScreen->bufs->list[idx]);
+
+ if (SAVAGE_DEBUG & DEBUG_DMA)
+ fprintf(stderr,
+ "drmDMA (get) returns size[0] 0x%x idx[0] %d\n"
+ "dma_buffer now: buf idx: %d size: %d used: %d addr %p\n",
+ dma.request_sizes[0], dma.request_list[0],
+ buf->idx, buf->total,
+ buf->used, buf->address);
+
+ imesa->dmaVtxBuf.total = buf->total / 4;
+ imesa->dmaVtxBuf.used = 0;
+ imesa->dmaVtxBuf.flushed = 0;
+ imesa->dmaVtxBuf.idx = buf->idx;
+ imesa->dmaVtxBuf.buf = (u_int32_t *)buf->address;
+
+ if (SAVAGE_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "finished getbuffer\n");
+}
+
+#if 0
+/* Still keeping this around because it demonstrates page flipping and
+ * automatic z-clear. */
+static void savage_BCI_clear(GLcontext *ctx, drm_savage_clear_t *pclear)
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ int nbox = imesa->sarea->nbox;
+ drm_clip_rect_t *pbox = imesa->sarea->boxes;
+ int i;
+
+
+ if (nbox > SAVAGE_NR_SAREA_CLIPRECTS)
+ nbox = SAVAGE_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;
+ unsigned int height = pbox->y2 - y;
+ u_int32_t *bciptr;
+
+ if (pbox->x1 > pbox->x2 ||
+ pbox->y1 > pbox->y2 ||
+ pbox->x2 > imesa->savageScreen->width ||
+ pbox->y2 > imesa->savageScreen->height)
+ continue;
+
+ if ( pclear->flags & SAVAGE_FRONT ) {
+ bciptr = savageDMAAlloc (imesa, 8);
+ WRITE_CMD((bciptr) , 0x4BCC8C00,u_int32_t);
+ WRITE_CMD((bciptr) , imesa->savageScreen->frontOffset,u_int32_t);
+ WRITE_CMD((bciptr) , imesa->savageScreen->frontBitmapDesc,u_int32_t);
+ WRITE_CMD((bciptr) , pclear->clear_color,u_int32_t);
+ WRITE_CMD((bciptr) , (y <<16) | x,u_int32_t);
+ WRITE_CMD((bciptr) , (height << 16) | width,u_int32_t);
+ savageDMACommit (imesa, bciptr);
+ }
+ if ( pclear->flags & SAVAGE_BACK ) {
+ bciptr = savageDMAAlloc (imesa, 8);
+ WRITE_CMD((bciptr) , 0x4BCC8C00,u_int32_t);
+ WRITE_CMD((bciptr) , imesa->savageScreen->backOffset,u_int32_t);
+ WRITE_CMD((bciptr) , imesa->savageScreen->backBitmapDesc,u_int32_t);
+ WRITE_CMD((bciptr) , pclear->clear_color,u_int32_t);
+ WRITE_CMD((bciptr) , (y <<16) | x,u_int32_t);
+ WRITE_CMD((bciptr) , (height << 16) | width,u_int32_t);
+ savageDMACommit (imesa, bciptr);
+ }
+
+ if ( pclear->flags & (SAVAGE_DEPTH |SAVAGE_STENCIL) ) {
+ u_int32_t writeMask = 0x0;
+ if(imesa->hw_stencil)
+ {
+ if(pclear->flags & SAVAGE_STENCIL)
+ {
+
+ writeMask |= 0xFF000000;
+ }
+ if(pclear->flags & SAVAGE_DEPTH)
+ {
+ writeMask |= 0x00FFFFFF;
+ }
+ }
+ if(imesa->IsFullScreen && imesa->NotFirstFrame &&
+ imesa->savageScreen->chipset >= S3_SAVAGE4)
+ {
+ imesa->regs.s4.zBufCtrl.ni.autoZEnable = GL_TRUE;
+ imesa->regs.s4.zBufCtrl.ni.frameID =
+ ~imesa->regs.s4.zBufCtrl.ni.frameID;
+
+ imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
+ }
+ else
+ {
+ if(imesa->IsFullScreen)
+ imesa->NotFirstFrame = GL_TRUE;
+
+ if(imesa->hw_stencil)
+ {
+ bciptr = savageDMAAlloc (imesa, 10);
+ if(writeMask != 0xFFFFFFFF)
+ {
+ WRITE_CMD((bciptr) , 0x960100D7,u_int32_t);
+ WRITE_CMD((bciptr) , writeMask,u_int32_t);
+ }
+ }
+ else
+ {
+ bciptr = savageDMAAlloc (imesa, 6);
+ }
+
+ WRITE_CMD((bciptr) , 0x4BCC8C00,u_int32_t);
+ WRITE_CMD((bciptr) , imesa->savageScreen->depthOffset,u_int32_t);
+ WRITE_CMD((bciptr) , imesa->savageScreen->depthBitmapDesc,u_int32_t);
+ WRITE_CMD((bciptr) , pclear->clear_depth,u_int32_t);
+ WRITE_CMD((bciptr) , (y <<16) | x,u_int32_t);
+ WRITE_CMD((bciptr) , (height << 16) | width,u_int32_t);
+ if(imesa->hw_stencil)
+ {
+ if(writeMask != 0xFFFFFFFF)
+ {
+ WRITE_CMD((bciptr) , 0x960100D7,u_int32_t);
+ WRITE_CMD((bciptr) , 0xFFFFFFFF,u_int32_t);
+ }
+ }
+ savageDMACommit (imesa, bciptr);
+ }
+ }
+ }
+ /* FK: Make sure that the clear stuff is emitted. Otherwise a
+ software fallback may get overwritten by a delayed clear. */
+ savageDMAFlush (imesa);
+}
+
+static void savage_BCI_swap(savageContextPtr imesa)
+{
+ int nbox = imesa->sarea->nbox;
+ drm_clip_rect_t *pbox = imesa->sarea->boxes;
+ int i;
+ volatile u_int32_t *bciptr;
+
+ if (nbox > SAVAGE_NR_SAREA_CLIPRECTS)
+ nbox = SAVAGE_NR_SAREA_CLIPRECTS;
+ savageDMAFlush (imesa);
+
+ if(imesa->IsFullScreen)
+ { /* full screen*/
+ unsigned int tmp0;
+ tmp0 = imesa->savageScreen->frontOffset;
+ imesa->savageScreen->frontOffset = imesa->savageScreen->backOffset;
+ imesa->savageScreen->backOffset = tmp0;
+
+ if(imesa->toggle == TARGET_BACK)
+ imesa->toggle = TARGET_FRONT;
+ else
+ imesa->toggle = TARGET_BACK;
+
+ imesa->drawMap = (char *)imesa->apertureBase[imesa->toggle];
+ imesa->readMap = (char *)imesa->apertureBase[imesa->toggle];
+
+ imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->backOffset>>11;
+ imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
+ bciptr = SAVAGE_GET_BCI_POINTER(imesa,3);
+ *(bciptr) = 0x960100B0;
+ *(bciptr) = (imesa->savageScreen->frontOffset);
+ *(bciptr) = 0xA0000000;
+ }
+
+ else
+ { /* Use bitblt copy from back to front buffer*/
+
+ for (i = 0 ; i < nbox; i++, pbox++)
+ {
+ unsigned int w = pbox->x2 - pbox->x1;
+ unsigned int h = pbox->y2 - pbox->y1;
+
+ if (pbox->x1 > pbox->x2 ||
+ pbox->y1 > pbox->y2 ||
+ pbox->x2 > imesa->savageScreen->width ||
+ pbox->y2 > imesa->savageScreen->height)
+ continue;
+
+ bciptr = SAVAGE_GET_BCI_POINTER(imesa,6);
+
+ *(bciptr) = 0x4BCC00C0;
+
+ *(bciptr) = imesa->savageScreen->backOffset;
+ *(bciptr) = imesa->savageScreen->backBitmapDesc;
+ *(bciptr) = (pbox->y1 <<16) | pbox->x1; /*x0, y0*/
+ *(bciptr) = (pbox->y1 <<16) | pbox->x1;
+ *(bciptr) = (h << 16) | w;
+ }
+
+ }
+}
+#endif
+
+
+static GLboolean intersect_rect( drm_clip_rect_t *out,
+ const drm_clip_rect_t *a,
+ const drm_clip_rect_t *b )
+{
+ *out = *a;
+ if (b->x1 > out->x1) out->x1 = b->x1;
+ if (b->y1 > out->y1) out->y1 = b->y1;
+ if (b->x2 < out->x2) out->x2 = b->x2;
+ if (b->y2 < out->y2) out->y2 = b->y2;
+
+ return ((out->x1 < out->x2) && (out->y1 < out->y2));
+}
+
+
+static GLuint savageIntersectClipRects(drm_clip_rect_t *dest,
+ const drm_clip_rect_t *src,
+ GLuint nsrc,
+ const drm_clip_rect_t *clip)
+{
+ GLuint i, ndest;
+
+ for (i = 0, ndest = 0; i < nsrc; ++i, ++src) {
+ if (intersect_rect(dest, src, clip)) {
+ dest++;
+ ndest++;
+ }
+ }
+
+ return ndest;
+}
+
+
+static void savageDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
+ GLuint colorMask, depthMask, clearColor, clearDepth, flags;
+
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf (stderr, "%s\n", __FUNCTION__);
+
+ clearColor = imesa->ClearColor;
+ if (imesa->float_depth) {
+ if (imesa->savageScreen->zpp == 2)
+ clearDepth = savageEncodeFloat16(1.0 - ctx->Depth.Clear);
+ else
+ clearDepth = savageEncodeFloat24(1.0 - ctx->Depth.Clear);
+ } else {
+ if (imesa->savageScreen->zpp == 2)
+ clearDepth = (GLuint) ((1.0 - ctx->Depth.Clear) * DEPTH_SCALE_16);
+ else
+ clearDepth = (GLuint) ((1.0 - ctx->Depth.Clear) * DEPTH_SCALE_24);
+ }
+
+ colorMask = 0;
+ depthMask = 0;
+ switch (imesa->savageScreen->cpp) {
+ case 2:
+ colorMask = PACK_COLOR_565(ctx->Color.ColorMask[0],
+ ctx->Color.ColorMask[1],
+ ctx->Color.ColorMask[2]);
+ break;
+ case 4:
+ colorMask = PACK_COLOR_8888(ctx->Color.ColorMask[3],
+ ctx->Color.ColorMask[2],
+ ctx->Color.ColorMask[1],
+ ctx->Color.ColorMask[0]);
+ break;
+ }
+
+ flags = 0;
+
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
+ flags |= SAVAGE_FRONT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
+ }
+
+ if (mask & BUFFER_BIT_BACK_LEFT) {
+ flags |= SAVAGE_BACK;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
+ }
+
+ if ((mask & BUFFER_BIT_DEPTH) && ctx->Depth.Mask) {
+ flags |= SAVAGE_DEPTH;
+ depthMask |=
+ (imesa->savageScreen->zpp == 2) ? 0xffffffff : 0x00ffffff;
+ mask &= ~BUFFER_BIT_DEPTH;
+ }
+
+ if((mask & BUFFER_BIT_STENCIL) && imesa->hw_stencil)
+ {
+ flags |= SAVAGE_DEPTH;
+ depthMask |= 0xff000000;
+ mask &= ~BUFFER_BIT_STENCIL;
+ }
+
+ savageFlushVertices(imesa);
+
+ if (flags) {
+ GLboolean depthCleared = GL_FALSE;
+ if (flags & (SAVAGE_FRONT|SAVAGE_BACK)) {
+ drm_savage_cmd_header_t *cmd;
+ cmd = savageAllocCmdBuf(imesa, sizeof(drm_savage_cmd_header_t));
+ cmd[0].clear0.cmd = SAVAGE_CMD_CLEAR;
+ if ((flags & SAVAGE_DEPTH) &&
+ clearDepth == clearColor && depthMask == colorMask) {
+ cmd[0].clear0.flags = flags;
+ depthCleared = GL_TRUE;
+ } else
+ cmd[0].clear0.flags = flags & (SAVAGE_FRONT|SAVAGE_BACK);
+ cmd[1].clear1.mask = colorMask;
+ cmd[1].clear1.value = clearColor;
+ }
+
+ if ((flags & SAVAGE_DEPTH) && !depthCleared) {
+ drm_savage_cmd_header_t *cmd;
+ cmd = savageAllocCmdBuf(imesa, sizeof(drm_savage_cmd_header_t));
+ cmd[0].clear0.cmd = SAVAGE_CMD_CLEAR;
+ cmd[0].clear0.flags = SAVAGE_DEPTH;
+ cmd[1].clear1.mask = depthMask;
+ cmd[1].clear1.value = clearDepth;
+ }
+ }
+
+ if (mask)
+ _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
+}
+
+/*
+ * Copy the back buffer to the front buffer.
+ */
+void savageSwapBuffers( __DRIdrawablePrivate *dPriv )
+{
+ savageContextPtr imesa;
+
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf (stderr, "%s\n================================\n", __FUNCTION__);
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ imesa = (savageContextPtr) dPriv->driContextPriv->driverPrivate;
+ if (imesa->IsDouble)
+ _mesa_notifySwapBuffers( imesa->glCtx );
+
+ FLUSH_BATCH(imesa);
+
+ if (imesa->sync_frames)
+ imesa->lastSwap = savageEmitEvent( imesa, 0 );
+
+ if (imesa->lastSwap != 0)
+ savageWaitEvent( imesa, imesa->lastSwap );
+
+ {
+ drm_savage_cmd_header_t *cmd = savageAllocCmdBuf(imesa, 0);
+ cmd->cmd.cmd = SAVAGE_CMD_SWAP;
+ imesa->inSwap = GL_TRUE; /* ignore scissors in savageFlushCmdBuf */
+ savageFlushCmdBuf(imesa, GL_FALSE);
+ imesa->inSwap = GL_FALSE;
+ }
+
+ if (!imesa->sync_frames)
+ /* don't sync, but limit the lag to one frame. */
+ imesa->lastSwap = savageEmitEvent( imesa, 0 );
+}
+
+unsigned int savageEmitEventLocked( savageContextPtr imesa, unsigned int flags )
+{
+ drm_savage_event_emit_t event;
+ int ret;
+ event.count = 0;
+ event.flags = flags;
+ ret = drmCommandWriteRead( imesa->driFd, DRM_SAVAGE_BCI_EVENT_EMIT,
+ &event, sizeof(event) );
+ if (ret) {
+ fprintf (stderr, "emit event returned %d\n", ret);
+ exit (1);
+ }
+ return event.count;
+}
+unsigned int savageEmitEvent( savageContextPtr imesa, unsigned int flags )
+{
+ unsigned int ret;
+ LOCK_HARDWARE( imesa );
+ ret = savageEmitEventLocked( imesa, flags );
+ UNLOCK_HARDWARE( imesa );
+ return ret;
+}
+
+
+void savageWaitEvent( savageContextPtr imesa, unsigned int count )
+{
+ drm_savage_event_wait_t event;
+ int ret;
+ event.count = count;
+ event.flags = 0;
+ ret = drmCommandWriteRead( imesa->driFd, DRM_SAVAGE_BCI_EVENT_WAIT,
+ &event, sizeof(event) );
+ if (ret) {
+ fprintf (stderr, "wait event returned %d\n", ret);
+ exit (1);
+ }
+}
+
+
+void savageFlushVertices( savageContextPtr imesa )
+{
+ struct savage_vtxbuf_t *buffer = imesa->vtxBuf;
+
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf (stderr, "%s\n", __FUNCTION__);
+
+ if (!buffer->total)
+ return;
+
+ if (buffer->used > buffer->flushed) {
+ drm_savage_cmd_header_t *cmd;
+ /* State must be updated "per primitive" because hardware
+ * culling must be disabled for unfilled primitives, points
+ * and lines. */
+ savageEmitChangedState (imesa);
+ cmd = savageAllocCmdBuf(imesa, 0);
+ cmd->prim.cmd = buffer == &imesa->dmaVtxBuf ?
+ SAVAGE_CMD_DMA_PRIM : SAVAGE_CMD_VB_PRIM;
+ cmd->prim.prim = imesa->HwPrim;
+ cmd->prim.skip = imesa->skip;
+ cmd->prim.start = buffer->flushed / imesa->HwVertexSize;
+ cmd->prim.count = buffer->used / imesa->HwVertexSize - cmd->prim.start;
+ buffer->flushed = buffer->used;
+ }
+}
+
+void savageFlushCmdBufLocked( savageContextPtr imesa, GLboolean discard )
+{
+ __DRIdrawablePrivate *dPriv = imesa->driDrawable;
+
+ if (!imesa->dmaVtxBuf.total)
+ discard = GL_FALSE;
+
+ /* complete indexed drawing commands */
+ savageFlushElts(imesa);
+
+ if (imesa->cmdBuf.write != imesa->cmdBuf.start || discard) {
+ drm_savage_cmdbuf_t cmdbuf;
+ drm_savage_cmd_header_t *start;
+ int ret;
+
+ /* If we lost the context we must restore the initial state (at
+ * the start of the command buffer). */
+ if (imesa->lostContext) {
+ start = imesa->cmdBuf.base;
+ imesa->lostContext = GL_FALSE;
+ } else
+ start = imesa->cmdBuf.start;
+
+ if ((SAVAGE_DEBUG & DEBUG_DMA) && discard)
+ fprintf (stderr, "Discarding DMA buffer, used=%u\n",
+ imesa->dmaVtxBuf.used);
+
+ cmdbuf.dma_idx = imesa->dmaVtxBuf.idx;
+ cmdbuf.discard = discard;
+ cmdbuf.vb_addr = imesa->clientVtxBuf.buf;
+ cmdbuf.vb_size = imesa->clientVtxBuf.total*4;
+ cmdbuf.vb_stride = imesa->HwVertexSize;
+ cmdbuf.cmd_addr = start;
+ cmdbuf.size = (imesa->cmdBuf.write - start);
+ if (!imesa->inSwap && imesa->scissor.enabled) {
+ drm_clip_rect_t *box = dPriv->pClipRects, *ibox;
+ drm_clip_rect_t scissor;
+ GLuint nbox = dPriv->numClipRects, nibox;
+ /* transform and clip scissor to viewport */
+ scissor.x1 = MAX2(imesa->scissor.x, 0) + dPriv->x;
+ scissor.y1 = MAX2(dPriv->h - imesa->scissor.y - imesa->scissor.h,
+ 0) + dPriv->y;
+ scissor.x2 = MIN2(imesa->scissor.x + imesa->scissor.w,
+ dPriv->w) + dPriv->x;
+ scissor.y2 = MIN2(dPriv->h - imesa->scissor.y,
+ dPriv->h) + dPriv->y;
+ /* intersect cliprects with scissor */
+ ibox = malloc(dPriv->numClipRects*sizeof(drm_clip_rect_t));
+ if (!ibox) {
+ fprintf(stderr, "Out of memory.\n");
+ exit(1);
+ }
+ nibox = savageIntersectClipRects(ibox, box, nbox, &scissor);
+ cmdbuf.nbox = nibox;
+ cmdbuf.box_addr = ibox;
+ } else {
+ cmdbuf.nbox = dPriv->numClipRects;
+ cmdbuf.box_addr = dPriv->pClipRects;
+ }
+
+ ret = drmCommandWrite( imesa->driFd, DRM_SAVAGE_BCI_CMDBUF,
+ &cmdbuf, sizeof(cmdbuf) );
+ if (ret) {
+ fprintf (stderr, "cmdbuf ioctl returned %d\n", ret);
+ exit(1);
+ }
+
+ if (cmdbuf.box_addr != dPriv->pClipRects) {
+ free(cmdbuf.box_addr);
+ }
+
+ /* Save the current state at the start of the command buffer. That
+ * state will only be emitted, if the context was lost since the
+ * last command buffer. */
+ imesa->cmdBuf.write = imesa->cmdBuf.base;
+ savageEmitOldState(imesa);
+ imesa->cmdBuf.start = imesa->cmdBuf.write;
+ }
+
+ if (discard) {
+ assert (!savageHaveIndexedVerts(imesa));
+ imesa->dmaVtxBuf.total = 0;
+ imesa->dmaVtxBuf.used = 0;
+ imesa->dmaVtxBuf.flushed = 0;
+ }
+ if (!savageHaveIndexedVerts(imesa)) {
+ imesa->clientVtxBuf.used = 0;
+ imesa->clientVtxBuf.flushed = 0;
+ }
+}
+
+
+void savageFlushCmdBuf( savageContextPtr imesa, GLboolean discard )
+{
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf (stderr, "%s\n", __FUNCTION__);
+ LOCK_HARDWARE(imesa);
+ savageFlushCmdBufLocked (imesa, discard);
+ UNLOCK_HARDWARE(imesa);
+}
+
+
+static void savageDDFlush( GLcontext *ctx )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf (stderr, "%s\n", __FUNCTION__);
+ savageFlushVertices (imesa);
+ savageFlushCmdBuf(imesa, GL_FALSE);
+}
+
+static void savageDDFinish( GLcontext *ctx )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf (stderr, "%s\n", __FUNCTION__);
+ savageFlushVertices (imesa);
+ savageFlushCmdBuf(imesa, GL_FALSE);
+ WAIT_IDLE_EMPTY(imesa);
+}
+
+void savageDDInitIoctlFuncs( GLcontext *ctx )
+{
+ ctx->Driver.Clear = savageDDClear;
+ ctx->Driver.Flush = savageDDFlush;
+ ctx->Driver.Finish = savageDDFinish;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savageioctl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savageioctl.h
new file mode 100644
index 000000000..c7ff0017f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savageioctl.h
@@ -0,0 +1,203 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+#ifndef SAVAGE_IOCTL_H
+#define SAVAGE_IOCTL_H
+
+#include "savagecontext.h"
+
+void savageFlushVertices( savageContextPtr mmesa );
+
+unsigned int savageEmitEventLocked( savageContextPtr imesa, unsigned int flags );
+unsigned int savageEmitEvent( savageContextPtr imesa, unsigned int flags );
+void savageWaitEvent( savageContextPtr imesa, unsigned int event);
+
+void savageFlushCmdBufLocked( savageContextPtr imesa, GLboolean discard );
+void savageFlushCmdBuf( savageContextPtr imesa, GLboolean discard );
+
+void savageDDInitIoctlFuncs( GLcontext *ctx );
+
+void savageSwapBuffers( __DRIdrawablePrivate *dPriv );
+
+#define WAIT_IDLE_EMPTY(imesa) do { \
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG) \
+ fprintf (stderr, "WAIT_IDLE_EMPTY in %s\n", __FUNCTION__); \
+ savageWaitEvent(imesa, \
+ savageEmitEvent(imesa, SAVAGE_WAIT_2D|SAVAGE_WAIT_3D)); \
+} while (0)
+
+#define WAIT_IDLE_EMPTY_LOCKED(imesa) do { \
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG) \
+ fprintf (stderr, "WAIT_IDLE_EMPTY_LOCKED in %s\n", __FUNCTION__); \
+ savageWaitEvent(imesa, savageEmitEventLocked( \
+ imesa, SAVAGE_WAIT_2D|SAVAGE_WAIT_3D)); \
+} while (0)
+
+#define FLUSH_BATCH(imesa) do { \
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG) \
+ fprintf (stderr, "FLUSH_BATCH in %s\n", __FUNCTION__); \
+ savageFlushVertices(imesa); \
+ savageFlushCmdBuf(imesa, GL_FALSE); \
+} while (0)
+
+extern void savageGetDMABuffer( savageContextPtr imesa );
+
+static __inline
+void savageReleaseIndexedVerts( savageContextPtr imesa )
+{
+ imesa->firstElt = -1;
+}
+
+static __inline
+GLboolean savageHaveIndexedVerts( savageContextPtr imesa )
+{
+ return (imesa->firstElt != -1);
+}
+
+static __inline
+u_int32_t *savageAllocVtxBuf( savageContextPtr imesa, GLuint words )
+{
+ struct savage_vtxbuf_t *buffer = imesa->vtxBuf;
+ u_int32_t *head;
+
+ if (buffer == &imesa->dmaVtxBuf) {
+ if (!buffer->total) {
+ LOCK_HARDWARE(imesa);
+ savageGetDMABuffer(imesa);
+ UNLOCK_HARDWARE(imesa);
+ } else if (buffer->used + words > buffer->total) {
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf (stderr, "... flushing DMA buffer in %s\n",
+ __FUNCTION__);
+ savageReleaseIndexedVerts(imesa);
+ savageFlushVertices(imesa);
+ LOCK_HARDWARE(imesa);
+ savageFlushCmdBufLocked(imesa, GL_TRUE); /* discard DMA buffer */
+ savageGetDMABuffer(imesa);
+ UNLOCK_HARDWARE(imesa);
+ }
+ } else if (buffer->used + words > buffer->total) {
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf (stderr, "... flushing client vertex buffer in %s\n",
+ __FUNCTION__);
+ savageReleaseIndexedVerts(imesa);
+ savageFlushVertices(imesa);
+ LOCK_HARDWARE(imesa);
+ savageFlushCmdBufLocked(imesa, GL_FALSE); /* free clientVtxBuf */
+ UNLOCK_HARDWARE(imesa);
+ }
+
+ head = &buffer->buf[buffer->used];
+
+ buffer->used += words;
+ return head;
+}
+
+static __inline
+u_int32_t *savageAllocIndexedVerts( savageContextPtr imesa, GLuint n )
+{
+ u_int32_t *ret;
+ savageFlushVertices(imesa);
+ ret = savageAllocVtxBuf(imesa, n*imesa->HwVertexSize);
+ imesa->firstElt = imesa->vtxBuf->flushed / imesa->HwVertexSize;
+ imesa->vtxBuf->flushed = imesa->vtxBuf->used;
+ return ret;
+}
+
+/* Flush Elts:
+ * - Complete the drawing command with the correct number of indices.
+ * - Actually allocate entries for the indices in the command buffer.
+ * (This allocation must succeed without wrapping the cmd buffer!)
+ */
+static __inline
+void savageFlushElts( savageContextPtr imesa )
+{
+ if (imesa->elts.cmd) {
+ GLuint qwords = (imesa->elts.n + 3) >> 2;
+ assert(imesa->cmdBuf.write - imesa->cmdBuf.base + qwords
+ <= imesa->cmdBuf.size);
+ imesa->cmdBuf.write += qwords;
+
+ imesa->elts.cmd->idx.count = imesa->elts.n;
+ imesa->elts.cmd = NULL;
+ }
+}
+
+/* Allocate a command buffer entry with <bytes> bytes of arguments:
+ * - implies savageFlushElts
+ */
+static __inline
+drm_savage_cmd_header_t *savageAllocCmdBuf( savageContextPtr imesa, GLuint bytes )
+{
+ drm_savage_cmd_header_t *ret;
+ GLuint qwords = ((bytes + 7) >> 3) + 1; /* round up */
+ assert (qwords < imesa->cmdBuf.size);
+
+ savageFlushElts(imesa);
+
+ if (imesa->cmdBuf.write - imesa->cmdBuf.base + qwords > imesa->cmdBuf.size)
+ savageFlushCmdBuf(imesa, GL_FALSE);
+
+ ret = (drm_savage_cmd_header_t *)imesa->cmdBuf.write;
+ imesa->cmdBuf.write += qwords;
+ return ret;
+}
+
+/* Allocate Elts:
+ * - if it doesn't fit, flush the cmd buffer first
+ * - allocates the drawing command on the cmd buffer if there is no
+ * incomplete indexed drawing command yet
+ * - increments the number of elts. Final allocation is done in savageFlushElts
+ */
+static __inline
+u_int16_t *savageAllocElts( savageContextPtr imesa, GLuint n )
+{
+ u_int16_t *ret;
+ GLuint qwords;
+ assert (savageHaveIndexedVerts(imesa));
+
+ if (imesa->elts.cmd)
+ qwords = (imesa->elts.n + n + 3) >> 2;
+ else
+ qwords = ((n + 3) >> 2) + 1;
+ if (imesa->cmdBuf.write - imesa->cmdBuf.base + qwords > imesa->cmdBuf.size)
+ savageFlushCmdBuf(imesa, GL_FALSE); /* implies savageFlushElts */
+
+ if (!imesa->elts.cmd) {
+ savageFlushVertices(imesa);
+ imesa->elts.cmd = savageAllocCmdBuf(imesa, 0);
+ imesa->elts.cmd->idx.cmd = (imesa->vtxBuf == &imesa->dmaVtxBuf) ?
+ SAVAGE_CMD_DMA_IDX : SAVAGE_CMD_VB_IDX;
+ imesa->elts.cmd->idx.prim = imesa->HwPrim;
+ imesa->elts.cmd->idx.skip = imesa->skip;
+ imesa->elts.n = 0;
+ }
+
+ ret = (u_int16_t *)(imesa->elts.cmd+1) + imesa->elts.n;
+ imesa->elts.n += n;
+ return ret;
+}
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagerender.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagerender.c
new file mode 100644
index 000000000..514434c42
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagerender.c
@@ -0,0 +1,370 @@
+/*
+ * Copyright 2005 Felix Kuehling
+ * 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 FELIX KUEHLING 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.
+ */
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * dma buffers. Use strip/fan hardware primitives where possible.
+ * Simulate missing primitives with indexed vertices.
+ */
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+
+#include "tnl/t_context.h"
+
+#include "savagecontext.h"
+#include "savagetris.h"
+#include "savagestate.h"
+#include "savageioctl.h"
+
+/*
+ * Standard render tab for Savage4 and smooth shading on Savage3D
+ */
+#define HAVE_POINTS 0
+#define HAVE_LINES 0
+#define HAVE_LINE_STRIPS 0
+#define HAVE_TRIANGLES 1
+#define HAVE_TRI_STRIPS 1
+#define HAVE_TRI_STRIP_1 0
+#define HAVE_TRI_FANS 1
+#define HAVE_POLYGONS 0
+#define HAVE_QUADS 0
+#define HAVE_QUAD_STRIPS 0
+
+#define HAVE_ELTS 1
+
+#define LOCAL_VARS savageContextPtr imesa = SAVAGE_CONTEXT(ctx)
+#define INIT( prim ) do { \
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__); \
+ savageFlushVertices(imesa); \
+ switch (prim) { \
+ case GL_TRIANGLES: imesa->HwPrim = SAVAGE_PRIM_TRILIST; break; \
+ case GL_TRIANGLE_STRIP: imesa->HwPrim = SAVAGE_PRIM_TRISTRIP; break; \
+ case GL_TRIANGLE_FAN: imesa->HwPrim = SAVAGE_PRIM_TRIFAN; break; \
+ } \
+} while (0)
+#define FLUSH() savageFlushElts(imesa), savageFlushVertices(imesa)
+
+#define GET_CURRENT_VB_MAX_VERTS() \
+ ((imesa->bufferSize/4 - imesa->vtxBuf->used) / imesa->HwVertexSize)
+#define GET_SUBSEQUENT_VB_MAX_VERTS() \
+ (imesa->bufferSize/4 / imesa->HwVertexSize)
+
+#define ALLOC_VERTS( nr ) \
+ savageAllocVtxBuf( imesa, (nr) * imesa->HwVertexSize )
+#define EMIT_VERTS( ctx, j, nr, buf ) \
+ _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf )
+
+#define ELTS_VARS( buf ) GLushort *dest = buf, firstElt = imesa->firstElt
+#define ELT_INIT( prim ) INIT(prim)
+
+/* (size - used - 1 qword for drawing command) * 4 elts per qword */
+#define GET_CURRENT_VB_MAX_ELTS() \
+ ((imesa->cmdBuf.size - (imesa->cmdBuf.write - imesa->cmdBuf.base) - 1)*4)
+/* (size - space for initial state - 1 qword for drawing command) * 4 elts
+ * imesa is not defined in validate_render :( */
+#define GET_SUBSEQUENT_VB_MAX_ELTS() \
+ ((SAVAGE_CONTEXT(ctx)->cmdBuf.size - \
+ (SAVAGE_CONTEXT(ctx)->cmdBuf.start - \
+ SAVAGE_CONTEXT(ctx)->cmdBuf.base) - 1)*4)
+
+#define ALLOC_ELTS(nr) savageAllocElts(imesa, nr)
+#define EMIT_ELT(offset, x) do { \
+ (dest)[offset] = (GLushort) ((x)+firstElt); \
+} while (0)
+#define EMIT_TWO_ELTS(offset, x, y) do { \
+ *(GLuint *)(dest + offset) = (((y)+firstElt) << 16) | \
+ ((x)+firstElt); \
+} while (0)
+
+#define INCR_ELTS( nr ) dest += nr
+#define ELTPTR dest
+#define RELEASE_ELT_VERTS() \
+ savageReleaseIndexedVerts(imesa)
+
+#define EMIT_INDEXED_VERTS( ctx, start, count ) do { \
+ GLuint *buf = savageAllocIndexedVerts(imesa, count-start); \
+ EMIT_VERTS(ctx, start, count-start, buf); \
+} while (0)
+
+#define TAG(x) savage_##x
+#include "tnl_dd/t_dd_dmatmp.h"
+
+/*
+ * On Savage3D triangle fans and strips are broken with flat
+ * shading. With triangles it wants the color for flat shading in the
+ * first vertex! So we make another template instance which uses
+ * triangles only (with reordered vertices: SAVAGE_PRIM_TRILIST_201).
+ * The reordering is done by the DRM.
+ */
+#undef HAVE_TRI_STRIPS
+#undef HAVE_TRI_FANS
+#define HAVE_TRI_STRIPS 0
+#define HAVE_TRI_FANS 0
+
+#undef INIT
+#define INIT( prim ) do { \
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__); \
+ savageFlushVertices(imesa); \
+ imesa->HwPrim = SAVAGE_PRIM_TRILIST_201; \
+} while(0)
+
+#undef TAG
+#define TAG(x) savage_flat_##x##_s3d
+#include "tnl_dd/t_dd_dmatmp.h"
+
+
+/**********************************************************************/
+/* Render pipeline stage */
+/**********************************************************************/
+
+static GLboolean savage_run_render( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ tnl_render_func *tab, *tab_elts;
+ GLboolean valid;
+ GLuint i;
+
+ if (savageHaveIndexedVerts(imesa))
+ savageReleaseIndexedVerts(imesa);
+
+ if (imesa->savageScreen->chipset < S3_SAVAGE4 &&
+ (ctx->_TriangleCaps & DD_FLATSHADE)) {
+ tab = savage_flat_render_tab_verts_s3d;
+ tab_elts = savage_flat_render_tab_elts_s3d;
+ valid = savage_flat_validate_render_s3d( ctx, VB );
+ } else {
+ tab = savage_render_tab_verts;
+ tab_elts = savage_render_tab_elts;
+ valid = savage_validate_render( ctx, VB );
+ }
+
+ /* Don't handle clipping or vertex manipulations.
+ */
+ if (imesa->RenderIndex != 0 || !valid) {
+ return GL_TRUE;
+ }
+
+ tnl->Driver.Render.Start( ctx );
+ /* Check RenderIndex again. The ptexHack is detected late in RenderStart.
+ * Also check for ptex fallbacks detected late.
+ */
+ if (imesa->RenderIndex != 0 || imesa->Fallback != 0) {
+ return GL_TRUE;
+ }
+
+ /* setup for hardware culling */
+ imesa->raster_primitive = GL_TRIANGLES;
+ imesa->new_state |= SAVAGE_NEW_CULL;
+
+ /* update and emit state */
+ savageDDUpdateHwState(ctx);
+ savageEmitChangedState(imesa);
+
+ if (VB->Elts) {
+ tab = tab_elts;
+ if (!savageHaveIndexedVerts(imesa)) {
+ if (VB->Count > GET_SUBSEQUENT_VB_MAX_VERTS())
+ return GL_TRUE;
+ EMIT_INDEXED_VERTS(ctx, 0, VB->Count);
+ }
+ }
+
+ for (i = 0 ; i < VB->PrimitiveCount ; i++)
+ {
+ GLuint prim = VB->Primitive[i].mode;
+ GLuint start = VB->Primitive[i].start;
+ GLuint length = VB->Primitive[i].count;
+
+ if (length)
+ tab[prim & PRIM_MODE_MASK]( ctx, start, start+length, prim);
+ }
+
+ tnl->Driver.Render.Finish( ctx );
+
+ return GL_FALSE; /* finished the pipe */
+}
+
+struct tnl_pipeline_stage _savage_render_stage =
+{
+ "savage render",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ savage_run_render /* run */
+};
+
+
+/**********************************************************************/
+/* Pipeline stage for texture coordinate normalization */
+/**********************************************************************/
+struct texnorm_stage_data {
+ GLboolean active;
+ GLvector4f texcoord[MAX_TEXTURE_UNITS];
+};
+
+#define TEXNORM_STAGE_DATA(stage) ((struct texnorm_stage_data *)stage->privatePtr)
+
+
+static GLboolean run_texnorm_stage( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ struct texnorm_stage_data *store = TEXNORM_STAGE_DATA(stage);
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i;
+
+ if (imesa->Fallback || !store->active)
+ return GL_TRUE;
+
+ for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) {
+ const GLbitfield reallyEnabled = ctx->Texture.Unit[i]._ReallyEnabled;
+ if (reallyEnabled) {
+ const struct gl_texture_object *texObj = ctx->Texture.Unit[i]._Current;
+ const GLboolean normalizeS = (texObj->WrapS == GL_REPEAT);
+ const GLboolean normalizeT = (reallyEnabled & TEXTURE_2D_BIT) &&
+ (texObj->WrapT == GL_REPEAT);
+ const GLfloat *in = (GLfloat *)VB->TexCoordPtr[i]->data;
+ const GLint instride = VB->TexCoordPtr[i]->stride;
+ GLfloat (*out)[4] = store->texcoord[i].data;
+ GLint j;
+
+ if (!ctx->Texture.Unit[i]._ReallyEnabled ||
+ VB->TexCoordPtr[i]->size == 4)
+ /* Never try to normalize homogenous tex coords! */
+ continue;
+
+ if (normalizeS && normalizeT) {
+ /* take first texcoords as rough estimate of mean value */
+ GLfloat correctionS = -floor(in[0]+0.5);
+ GLfloat correctionT = -floor(in[1]+0.5);
+ for (j = 0; j < VB->Count; ++j) {
+ out[j][0] = in[0] + correctionS;
+ out[j][1] = in[1] + correctionT;
+ in = (GLfloat *)((GLubyte *)in + instride);
+ }
+ } else if (normalizeS) {
+ /* take first texcoords as rough estimate of mean value */
+ GLfloat correctionS = -floor(in[0]+0.5);
+ if (reallyEnabled & TEXTURE_2D_BIT) {
+ for (j = 0; j < VB->Count; ++j) {
+ out[j][0] = in[0] + correctionS;
+ out[j][1] = in[1];
+ in = (GLfloat *)((GLubyte *)in + instride);
+ }
+ } else {
+ for (j = 0; j < VB->Count; ++j) {
+ out[j][0] = in[0] + correctionS;
+ in = (GLfloat *)((GLubyte *)in + instride);
+ }
+ }
+ } else if (normalizeT) {
+ /* take first texcoords as rough estimate of mean value */
+ GLfloat correctionT = -floor(in[1]+0.5);
+ for (j = 0; j < VB->Count; ++j) {
+ out[j][0] = in[0];
+ out[j][1] = in[1] + correctionT;
+ in = (GLfloat *)((GLubyte *)in + instride);
+ }
+ }
+
+ if (normalizeS || normalizeT)
+ VB->AttribPtr[VERT_ATTRIB_TEX0+i] = VB->TexCoordPtr[i] = &store->texcoord[i];
+ }
+ }
+
+ return GL_TRUE;
+}
+
+/* Called the first time stage->run() is invoked.
+ */
+static GLboolean alloc_texnorm_data( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ struct texnorm_stage_data *store;
+ GLuint i;
+
+ stage->privatePtr = CALLOC(sizeof(*store));
+ store = TEXNORM_STAGE_DATA(stage);
+ if (!store)
+ return GL_FALSE;
+
+ for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
+ _mesa_vector4f_alloc( &store->texcoord[i], 0, VB->Size, 32 );
+
+ return GL_TRUE;
+}
+
+static void validate_texnorm( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ struct texnorm_stage_data *store = TEXNORM_STAGE_DATA(stage);
+ GLuint flags = 0;
+
+ if (((ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) &&
+ (ctx->Texture.Unit[0]._Current->WrapS == GL_REPEAT)) ||
+ ((ctx->Texture.Unit[0]._ReallyEnabled & TEXTURE_2D_BIT) &&
+ (ctx->Texture.Unit[0]._Current->WrapT == GL_REPEAT)))
+ flags |= VERT_BIT_TEX0;
+
+ if (((ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) &&
+ (ctx->Texture.Unit[1]._Current->WrapS == GL_REPEAT)) ||
+ ((ctx->Texture.Unit[1]._ReallyEnabled & TEXTURE_2D_BIT) &&
+ (ctx->Texture.Unit[1]._Current->WrapT == GL_REPEAT)))
+ flags |= VERT_BIT_TEX1;
+
+ store->active = (flags != 0);
+}
+
+static void free_texnorm_data( struct tnl_pipeline_stage *stage )
+{
+ struct texnorm_stage_data *store = TEXNORM_STAGE_DATA(stage);
+ GLuint i;
+
+ if (store) {
+ for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++)
+ if (store->texcoord[i].data)
+ _mesa_vector4f_free( &store->texcoord[i] );
+ FREE( store );
+ stage->privatePtr = 0;
+ }
+}
+
+struct tnl_pipeline_stage _savage_texnorm_stage =
+{
+ "savage texture coordinate normalization stage", /* name */
+ NULL, /* private data */
+ alloc_texnorm_data, /* run -- initially set to init */
+ free_texnorm_data, /* destructor */
+ validate_texnorm,
+ run_texnorm_stage
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagespan.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagespan.c
new file mode 100644
index 000000000..a261299cc
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagespan.c
@@ -0,0 +1,343 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+#include "mtypes.h"
+#include "savagedd.h"
+#include "savagespan.h"
+#include "savageioctl.h"
+#include "savage_bci.h"
+#include "savage_3d_reg.h"
+#include "swrast/swrast.h"
+
+#define DBG 0
+
+#define LOCAL_VARS \
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = imesa->mesa_drawable; \
+ savageScreenPrivate *savageScreen = imesa->savageScreen; \
+ GLuint cpp = savageScreen->cpp; \
+ GLuint pitch = imesa->aperturePitch; \
+ GLuint height = dPriv->h; \
+ GLubyte *buf = map + \
+ dPriv->x * cpp + \
+ dPriv->y * pitch; \
+ char *read_buf = buf; \
+ GLuint p; \
+ (void) p
+
+#define LOCAL_DEPTH_VARS \
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = imesa->mesa_drawable; \
+ savageScreenPrivate *savageScreen = imesa->savageScreen; \
+ GLuint zpp = savageScreen->zpp; \
+ GLuint pitch = imesa->aperturePitch; \
+ GLuint height = dPriv->h; \
+ GLubyte *buf = imesa->apertureBase[TARGET_DEPTH] + \
+ dPriv->x * zpp + \
+ dPriv->y * pitch
+
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
+
+#define Y_FLIP(_y) (height - _y - 1)
+
+#define HW_LOCK()
+
+#define HW_UNLOCK()
+
+#define HW_WRITE_LOCK() \
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx); \
+ GLubyte *map = imesa->drawMap;
+
+#define HW_READ_LOCK() \
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx); \
+ GLubyte *map = imesa->readMap;
+
+
+/* 16 bit, 565 rgb color spanline and pixel functions
+ */
+#define SPANTMP_PIXEL_FMT GL_RGB
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
+
+#define TAG(x) savage##x##_565
+#define TAG2(x,y) savage##x##_565##y
+#include "spantmp2.h"
+
+
+/* 32 bit, 8888 ARGB color spanline and pixel functions
+ */
+#define SPANTMP_PIXEL_FMT GL_BGRA
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
+
+#define TAG(x) savage##x##_8888
+#define TAG2(x,y) savage##x##_8888##y
+#include "spantmp2.h"
+
+
+#undef HW_WRITE_LOCK
+#define HW_WRITE_LOCK()
+#undef HW_READ_LOCK
+#define HW_READ_LOCK()
+
+
+
+/* 16 bit integer depthbuffer functions
+ * Depth range is reversed. See also savageCalcViewport.
+ */
+#define WRITE_DEPTH( _x, _y, d ) \
+ *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch) = 0xFFFF - d
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = 0xFFFF - *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch)
+
+#define TAG(x) savage##x##_16
+#include "depthtmp.h"
+
+
+
+
+/* 16 bit float depthbuffer functions
+ */
+#define WRITE_DEPTH( _x, _y, d ) \
+ *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch) = \
+ savageEncodeFloat16( 1.0 - (GLfloat)d/65535.0 )
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = 65535 - \
+ savageDecodeFloat16( *(GLushort *)(buf + ((_x)<<1) + (_y)*pitch) ) * \
+ 65535.0
+
+#define TAG(x) savage##x##_16f
+#include "depthtmp.h"
+
+
+
+
+/* 8-bit stencil /24-bit integer depth depthbuffer functions.
+ * Depth range is reversed. See also savageCalcViewport.
+ */
+#define WRITE_DEPTH( _x, _y, d ) do { \
+ GLuint tmp = *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch); \
+ tmp &= 0xFF000000; \
+ tmp |= 0x00FFFFFF - d; \
+ *(GLuint *)(buf + (_x<<2) + _y*pitch) = tmp; \
+} while(0)
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = 0x00FFFFFF - (*(GLuint *)(buf + ((_x)<<2) + (_y)*pitch) & 0x00FFFFFF)
+
+#define TAG(x) savage##x##_8_24
+#include "depthtmp.h"
+
+
+
+
+/* 24 bit float depthbuffer functions
+ */
+#define WRITE_DEPTH( _x, _y, d ) do { \
+ GLuint tmp = *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch); \
+ tmp &= 0xFF000000; \
+ tmp |= savageEncodeFloat24( 1.0 - (GLfloat)d/16777215.0 ); \
+ *(GLuint *)(buf + (_x<<2) + _y*pitch) = tmp; \
+} while(0)
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = 16777215 - savageDecodeFloat24( \
+ *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch) & 0x00FFFFFF) \
+ * 16777215.0
+
+#define TAG(x) savage##x##_8_24f
+#include "depthtmp.h"
+
+
+#define WRITE_STENCIL( _x, _y, d ) do { \
+ GLuint tmp = *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch); \
+ tmp &= 0x00FFFFFF; \
+ tmp |= (((GLuint)d)<<24) & 0xFF000000; \
+ *(GLuint *)(buf + ((_x)<<2) + (_y)*pitch) = tmp; \
+} while(0)
+
+#define READ_STENCIL( d, _x, _y ) \
+ d = (GLstencil)((*(GLuint *)(buf + ((_x)<<2) + (_y)*pitch) & 0xFF000000) >> 24)
+
+#define TAG(x) savage##x##_8_24
+#include "stenciltmp.h"
+
+
+/*
+ * This function is called to specify which buffer to read and write
+ * for software rasterization (swrast) fallbacks. This doesn't necessarily
+ * correspond to glDrawBuffer() or glReadBuffer() calls.
+ */
+static void savageDDSetBuffer(GLcontext *ctx, GLframebuffer *buffer,
+ GLuint bufferBit)
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ char *map;
+
+ assert((bufferBit == BUFFER_BIT_FRONT_LEFT) || (bufferBit == BUFFER_BIT_BACK_LEFT));
+
+ map = (bufferBit == BUFFER_BIT_FRONT_LEFT)
+ ? imesa->apertureBase[TARGET_FRONT]
+ : imesa->apertureBase[TARGET_BACK];
+
+ imesa->drawMap = map;
+ imesa->readMap = map;
+
+ assert( (buffer == imesa->driDrawable->driverPrivate)
+ || (buffer == imesa->driReadable->driverPrivate) );
+
+ imesa->mesa_drawable = (buffer == imesa->driDrawable->driverPrivate)
+ ? imesa->driDrawable : imesa->driReadable;
+}
+
+/*
+ * Wrappers around _swrast_Copy/Draw/ReadPixels that make sure all
+ * primitives are flushed and the hardware is idle before accessing
+ * the frame buffer.
+ */
+static void
+savageCopyPixels( GLcontext *ctx,
+ GLint srcx, GLint srcy, GLsizei width, GLsizei height,
+ GLint destx, GLint desty,
+ GLenum type )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ FLUSH_BATCH(imesa);
+ WAIT_IDLE_EMPTY(imesa);
+ _swrast_CopyPixels(ctx, srcx, srcy, width, height, destx, desty, type);
+}
+static void
+savageDrawPixels( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ const GLvoid *pixels )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ FLUSH_BATCH(imesa);
+ WAIT_IDLE_EMPTY(imesa);
+ _swrast_DrawPixels(ctx, x, y, width, height, format, type, packing, pixels);
+}
+static void
+savageReadPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ GLvoid *pixels )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ FLUSH_BATCH(imesa);
+ WAIT_IDLE_EMPTY(imesa);
+ _swrast_ReadPixels(ctx, x, y, width, height, format, type, packing, pixels);
+}
+
+/*
+ * Make sure the hardware is idle when span-rendering.
+ */
+static void savageSpanRenderStart( GLcontext *ctx )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ FLUSH_BATCH(imesa);
+ WAIT_IDLE_EMPTY(imesa);
+}
+
+
+void savageDDInitSpanFuncs( GLcontext *ctx )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetBuffer = savageDDSetBuffer;
+ swdd->SpanRenderStart = savageSpanRenderStart;
+
+ /* Pixel path fallbacks.
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = savageCopyPixels;
+ ctx->Driver.DrawPixels = savageDrawPixels;
+ ctx->Driver.ReadPixels = savageReadPixels;
+}
+
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+savageSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis,
+ GLboolean float_depth)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ savageInitPointers_565(&drb->Base);
+ }
+ else {
+ savageInitPointers_8888(&drb->Base);
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ if (float_depth) {
+ drb->Base.GetRow = savageReadDepthSpan_16f;
+ drb->Base.GetValues = savageReadDepthPixels_16f;
+ drb->Base.PutRow = savageWriteDepthSpan_16f;
+ drb->Base.PutMonoRow = savageWriteMonoDepthSpan_16f;
+ drb->Base.PutValues = savageWriteDepthPixels_16f;
+ }
+ else {
+ drb->Base.GetRow = savageReadDepthSpan_16;
+ drb->Base.GetValues = savageReadDepthPixels_16;
+ drb->Base.PutRow = savageWriteDepthSpan_16;
+ drb->Base.PutMonoRow = savageWriteMonoDepthSpan_16;
+ drb->Base.PutValues = savageWriteDepthPixels_16;
+ }
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ if (float_depth) {
+ drb->Base.GetRow = savageReadDepthSpan_8_24f;
+ drb->Base.GetValues = savageReadDepthPixels_8_24f;
+ drb->Base.PutRow = savageWriteDepthSpan_8_24f;
+ drb->Base.PutMonoRow = savageWriteMonoDepthSpan_8_24f;
+ drb->Base.PutValues = savageWriteDepthPixels_8_24f;
+ }
+ else {
+ drb->Base.GetRow = savageReadDepthSpan_8_24;
+ drb->Base.GetValues = savageReadDepthPixels_8_24;
+ drb->Base.PutRow = savageWriteDepthSpan_8_24;
+ drb->Base.PutMonoRow = savageWriteMonoDepthSpan_8_24;
+ drb->Base.PutValues = savageWriteDepthPixels_8_24;
+ }
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = savageReadStencilSpan_8_24;
+ drb->Base.GetValues = savageReadStencilPixels_8_24;
+ drb->Base.PutRow = savageWriteStencilSpan_8_24;
+ drb->Base.PutMonoRow = savageWriteMonoStencilSpan_8_24;
+ drb->Base.PutValues = savageWriteStencilPixels_8_24;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagespan.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagespan.h
new file mode 100644
index 000000000..f6a312e82
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagespan.h
@@ -0,0 +1,137 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+#ifndef _SAVAGE_SPAN_H
+#define _SAVAGE_SPAN_H
+
+#include "drirenderbuffer.h"
+
+
+extern void savageDDInitSpanFuncs( GLcontext *ctx );
+
+extern void
+savageSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis,
+ GLboolean float_depth);
+
+
+/*
+ * Savage 16-bit float depth format with zExpOffset=16:
+ * 4 bit unsigned exponent, 12 bit mantissa
+ *
+ * The meaning of the mantissa is different from IEEE floatint point
+ * formats. The same number can't be encoded with different exponents.
+ * So no bits are wasted.
+ *
+ * exponent | range encoded by mantissa | accuracy or mantissa
+ * ---------+---------------------------+---------------------
+ * 15 | 2^-1 .. 1 | 2^-13
+ * 14 | 2^-2 .. 2^-1 | 2^-14
+ * 13 | 2^-3 .. 2^-2 | 2^-15
+ * ... | ... |
+ * 2 | 2^-14 .. 2^-13 | 2^-27
+ * 1 | 2^-15 .. 2^-14 | 2^-27
+ * 0 | 2^-16 .. 2^-15 | 2^-28
+ *
+ * Note that there is no encoding for numbers < 2^-16.
+ */
+static __inline GLuint savageEncodeFloat16( GLdouble x )
+{
+ GLint r = (GLint)(x * 0x10000000);
+ GLint exp = 0;
+ if (r < 0x1000)
+ return 0;
+ while (r - 0x1000 > 0x0fff) {
+ r >>= 1;
+ exp++;
+ }
+ return exp > 0xf ? 0xffff : (r - 0x1000) | (exp << 12);
+}
+static __inline GLdouble savageDecodeFloat16( GLuint x )
+{
+ static const GLdouble pow2[16] = {
+ 1.0/(1<<28), 1.0/(1<<27), 1.0/(1<<26), 1.0/(1<<25),
+ 1.0/(1<<24), 1.0/(1<<23), 1.0/(1<<22), 1.0/(1<<21),
+ 1.0/(1<<20), 1.0/(1<<19), 1.0/(1<<18), 1.0/(1<<17),
+ 1.0/(1<<16), 1.0/(1<<15), 1.0/(1<<14), 1.0/(1<<13)
+ };
+ static const GLdouble bias[16] = {
+ 1.0/(1<<16), 1.0/(1<<15), 1.0/(1<<14), 1.0/(1<<13),
+ 1.0/(1<<12), 1.0/(1<<11), 1.0/(1<<10), 1.0/(1<< 9),
+ 1.0/(1<< 8), 1.0/(1<< 7), 1.0/(1<< 6), 1.0/(1<< 5),
+ 1.0/(1<< 4), 1.0/(1<< 3), 1.0/(1<< 2), 1.0/(1<< 1)
+ };
+ GLuint mant = x & 0x0fff;
+ GLuint exp = (x >> 12) & 0xf;
+ return bias[exp] + pow2[exp]*mant;
+}
+
+/*
+ * Savage 24-bit float depth format with zExpOffset=32:
+ * 5 bit unsigned exponent, 19 bit mantissa
+ *
+ * Details analogous to the 16-bit format.
+ */
+static __inline GLuint savageEncodeFloat24( GLdouble x )
+{
+ int64_t r = (int64_t)(x * ((int64_t)1 << (19+32)));
+ GLint exp = 0;
+ if (r < 0x80000)
+ return 0;
+ while (r - 0x80000 > 0x7ffff) {
+ r >>= 1;
+ exp++;
+ }
+ return exp > 0x1f ? 0xffffff : (r - 0x80000) | (exp << 19);
+}
+#define _1 (int64_t)1
+static __inline GLdouble savageDecodeFloat24( GLuint x )
+{
+ static const GLdouble pow2[32] = {
+ 1.0/(_1<<51), 1.0/(_1<<50), 1.0/(_1<<49), 1.0/(_1<<48),
+ 1.0/(_1<<47), 1.0/(_1<<46), 1.0/(_1<<45), 1.0/(_1<<44),
+ 1.0/(_1<<43), 1.0/(_1<<42), 1.0/(_1<<41), 1.0/(_1<<40),
+ 1.0/(_1<<39), 1.0/(_1<<38), 1.0/(_1<<37), 1.0/(_1<<36),
+ 1.0/(_1<<35), 1.0/(_1<<34), 1.0/(_1<<33), 1.0/(_1<<32),
+ 1.0/(_1<<31), 1.0/(_1<<30), 1.0/(_1<<29), 1.0/(_1<<28),
+ 1.0/(_1<<27), 1.0/(_1<<26), 1.0/(_1<<25), 1.0/(_1<<24),
+ 1.0/(_1<<23), 1.0/(_1<<22), 1.0/(_1<<21), 1.0/(_1<<20)
+ };
+ static const GLdouble bias[32] = {
+ 1.0/(_1<<32), 1.0/(_1<<31), 1.0/(_1<<30), 1.0/(_1<<29),
+ 1.0/(_1<<28), 1.0/(_1<<27), 1.0/(_1<<26), 1.0/(_1<<25),
+ 1.0/(_1<<24), 1.0/(_1<<23), 1.0/(_1<<22), 1.0/(_1<<21),
+ 1.0/(_1<<20), 1.0/(_1<<19), 1.0/(_1<<18), 1.0/(_1<<17),
+ 1.0/(_1<<16), 1.0/(_1<<15), 1.0/(_1<<14), 1.0/(_1<<13),
+ 1.0/(_1<<12), 1.0/(_1<<11), 1.0/(_1<<10), 1.0/(_1<< 9),
+ 1.0/(_1<< 8), 1.0/(_1<< 7), 1.0/(_1<< 6), 1.0/(_1<< 5),
+ 1.0/(_1<< 4), 1.0/(_1<< 3), 1.0/(_1<< 2), 1.0/(_1<< 1)
+ };
+ GLuint mant = x & 0x7ffff;
+ GLuint exp = (x >> 19) & 0x1f;
+ return bias[exp] + pow2[exp]*mant;
+}
+#undef _1
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagestate.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagestate.c
new file mode 100644
index 000000000..996d5b917
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagestate.c
@@ -0,0 +1,1765 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+#include <stdio.h>
+
+#include "mtypes.h"
+#include "buffers.h"
+#include "enums.h"
+#include "macros.h"
+#include "dd.h"
+
+#include "mm.h"
+#include "savagedd.h"
+#include "savagecontext.h"
+
+#include "savagestate.h"
+#include "savagetex.h"
+#include "savagetris.h"
+#include "savageioctl.h"
+#include "savage_bci.h"
+
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "xmlpool.h"
+
+/* Savage4, ProSavage[DDR], SuperSavage watermarks */
+#define S4_ZRLO 24
+#define S4_ZRHI 24
+#define S4_ZWLO 0
+#define S4_ZWHI 0
+
+#define S4_DRLO 0
+#define S4_DRHI 0
+#define S4_DWLO 0
+#define S4_DWHI 0
+
+#define S4_TR 15
+
+/* Savage3D/MX/IX watermarks */
+#define S3D_ZRLO 8
+#define S3D_ZRHI 24
+#define S3D_ZWLO 0
+#define S3D_ZWHI 24
+
+#define S3D_DRLO 0
+#define S3D_DRHI 0
+#define S3D_DWLO 0
+#define S3D_DWHI 0
+
+#define S3D_TR 15
+
+static void savageBlendFunc_s4(GLcontext *);
+static void savageBlendFunc_s3d(GLcontext *);
+
+static __inline__ GLuint savagePackColor(GLuint format,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a)
+{
+ switch (format) {
+ case DV_PF_8888:
+ return SAVAGEPACKCOLOR8888(r,g,b,a);
+ case DV_PF_565:
+ return SAVAGEPACKCOLOR565(r,g,b);
+ default:
+
+ return 0;
+ }
+}
+
+
+static void savageDDAlphaFunc_s4(GLcontext *ctx, GLenum func, GLfloat ref)
+{
+ savageBlendFunc_s4(ctx);
+}
+static void savageDDAlphaFunc_s3d(GLcontext *ctx, GLenum func, GLfloat ref)
+{
+ savageBlendFunc_s3d(ctx);
+}
+
+static void savageDDBlendEquationSeparate(GLcontext *ctx,
+ GLenum modeRGB, GLenum modeA)
+{
+ assert( modeRGB == modeA );
+
+ /* BlendEquation sets ColorLogicOpEnabled in an unexpected
+ * manner.
+ */
+ FALLBACK( ctx, SAVAGE_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
+
+ /* Can only do blend addition, not min, max, subtract, etc. */
+ FALLBACK( ctx, SAVAGE_FALLBACK_BLEND_EQ,
+ modeRGB != GL_FUNC_ADD);
+}
+
+
+static void savageBlendFunc_s4(GLcontext *ctx)
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ u_int32_t drawLocalCtrl = imesa->regs.s4.drawLocalCtrl.ui;
+ u_int32_t drawCtrl0 = imesa->regs.s4.drawCtrl0.ui;
+ u_int32_t drawCtrl1 = imesa->regs.s4.drawCtrl1.ui;
+
+ /* set up draw control register (including blending, alpha
+ * test, and shading model)
+ */
+
+ imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_FALSE;
+
+ /*
+ * blend modes
+ */
+ if(ctx->Color.BlendEnabled){
+ switch (ctx->Color.BlendDstRGB)
+ {
+ case GL_ZERO:
+ imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_Zero;
+ break;
+
+ case GL_ONE:
+ imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_One;
+ imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_TRUE;
+ break;
+
+ case GL_SRC_COLOR:
+ imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_SrcClr;
+ imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_TRUE;
+ break;
+
+ case GL_ONE_MINUS_SRC_COLOR:
+ imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_1SrcClr;
+ imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_TRUE;
+ break;
+
+ case GL_SRC_ALPHA:
+ imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_SrcAlpha;
+ imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_TRUE;
+ break;
+
+ case GL_ONE_MINUS_SRC_ALPHA:
+ imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_1SrcAlpha;
+ imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_TRUE;
+ break;
+
+ case GL_DST_ALPHA:
+ if (imesa->glCtx->Visual.alphaBits == 0)
+ {
+ imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_One;
+ }
+ else
+ {
+ imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode= DAM_DstAlpha;
+ }
+ imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_TRUE;
+ break;
+
+ case GL_ONE_MINUS_DST_ALPHA:
+ if (imesa->glCtx->Visual.alphaBits == 0)
+ {
+ imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_Zero;
+ }
+ else
+ {
+ imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode=DAM_1DstAlpha;
+ imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites= GL_TRUE;
+ }
+ break;
+ }
+
+ switch (ctx->Color.BlendSrcRGB)
+ {
+ case GL_ZERO:
+ imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_Zero;
+ break;
+
+ case GL_ONE:
+ imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_One;
+ break;
+
+ case GL_DST_COLOR:
+ imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_DstClr;
+ imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_TRUE;
+ break;
+
+ case GL_ONE_MINUS_DST_COLOR:
+ imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_1DstClr;
+ imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites = GL_TRUE;
+ break;
+
+ case GL_SRC_ALPHA:
+ imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_SrcAlpha;
+ break;
+
+ case GL_ONE_MINUS_SRC_ALPHA:
+ imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_1SrcAlpha;
+ break;
+
+ case GL_DST_ALPHA:
+ if (imesa->glCtx->Visual.alphaBits == 0)
+ {
+ imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_One;
+ }
+ else
+ {
+ imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode= SAM_DstAlpha;
+ imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites= GL_TRUE;
+ }
+ break;
+
+ case GL_ONE_MINUS_DST_ALPHA:
+ if (imesa->glCtx->Visual.alphaBits == 0)
+ {
+ imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_Zero;
+ }
+ else
+ {
+ imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode=SAM_1DstAlpha;
+ imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites= GL_TRUE;
+ }
+ break;
+ }
+ }
+ else
+ {
+ imesa->regs.s4.drawLocalCtrl.ni.dstAlphaMode = DAM_Zero;
+ imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_One;
+ }
+
+ /* alpha test*/
+
+ if(ctx->Color.AlphaEnabled)
+ {
+ ACmpFunc a;
+ GLubyte alphaRef;
+
+ CLAMPED_FLOAT_TO_UBYTE(alphaRef,ctx->Color.AlphaRef);
+
+ switch(ctx->Color.AlphaFunc) {
+ case GL_NEVER: a = CF_Never; break;
+ case GL_ALWAYS: a = CF_Always; break;
+ case GL_LESS: a = CF_Less; break;
+ case GL_LEQUAL: a = CF_LessEqual; break;
+ case GL_EQUAL: a = CF_Equal; break;
+ case GL_GREATER: a = CF_Greater; break;
+ case GL_GEQUAL: a = CF_GreaterEqual; break;
+ case GL_NOTEQUAL: a = CF_NotEqual; break;
+ default:return;
+ }
+
+ imesa->regs.s4.drawCtrl1.ni.alphaTestEn = GL_TRUE;
+ imesa->regs.s4.drawCtrl1.ni.alphaTestCmpFunc = a;
+ imesa->regs.s4.drawCtrl0.ni.alphaRefVal = alphaRef;
+ }
+ else
+ {
+ imesa->regs.s4.drawCtrl1.ni.alphaTestEn = GL_FALSE;
+ }
+
+ /* Set/Reset Z-after-alpha*/
+
+ imesa->regs.s4.drawLocalCtrl.ni.wrZafterAlphaTst =
+ imesa->regs.s4.drawCtrl1.ni.alphaTestEn;
+ /*imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn =
+ ~drawLocalCtrl.ni.wrZafterAlphaTst;*/
+
+ if (drawLocalCtrl != imesa->regs.s4.drawLocalCtrl.ui)
+ imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
+ if (drawCtrl0 != imesa->regs.s4.drawCtrl0.ui ||
+ drawCtrl1 != imesa->regs.s4.drawCtrl1.ui)
+ imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
+}
+static void savageBlendFunc_s3d(GLcontext *ctx)
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ u_int32_t drawCtrl = imesa->regs.s3d.drawCtrl.ui;
+ u_int32_t zBufCtrl = imesa->regs.s3d.zBufCtrl.ui;
+
+ /* set up draw control register (including blending, alpha
+ * test, dithering, and shading model)
+ */
+
+ imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = 0;
+
+ /*
+ * blend modes
+ */
+ if(ctx->Color.BlendEnabled){
+ switch (ctx->Color.BlendDstRGB)
+ {
+ case GL_ZERO:
+ imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_Zero;
+ break;
+
+ case GL_ONE:
+ imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_One;
+ imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE;
+ break;
+
+ case GL_SRC_COLOR:
+ imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_SrcClr;
+ imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE;
+ break;
+
+ case GL_ONE_MINUS_SRC_COLOR:
+ imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_1SrcClr;
+ imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE;
+ break;
+
+ case GL_SRC_ALPHA:
+ imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_SrcAlpha;
+ imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE;
+ break;
+
+ case GL_ONE_MINUS_SRC_ALPHA:
+ imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_1SrcAlpha;
+ imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE;
+ break;
+
+ case GL_DST_ALPHA:
+ if (imesa->glCtx->Visual.alphaBits == 0)
+ {
+ imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_One;
+ }
+ else
+ {
+ imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_DstAlpha;
+ }
+ imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE;
+ break;
+
+ case GL_ONE_MINUS_DST_ALPHA:
+ if (imesa->glCtx->Visual.alphaBits == 0)
+ {
+ imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_Zero;
+ }
+ else
+ {
+ imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_1DstAlpha;
+ imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE;
+ }
+ break;
+ }
+
+ switch (ctx->Color.BlendSrcRGB)
+ {
+ case GL_ZERO:
+ imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_Zero;
+ break;
+
+ case GL_ONE:
+ imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_One;
+ break;
+
+ case GL_DST_COLOR:
+ imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_DstClr;
+ imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE;
+ break;
+
+ case GL_ONE_MINUS_DST_COLOR:
+ imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_1DstClr;
+ imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE;
+ break;
+
+ case GL_SRC_ALPHA:
+ imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_SrcAlpha;
+ break;
+
+ case GL_ONE_MINUS_SRC_ALPHA:
+ imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_1SrcAlpha;
+ break;
+
+ case GL_DST_ALPHA:
+ if (imesa->glCtx->Visual.alphaBits == 0)
+ {
+ imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_One;
+ }
+ else
+ {
+ imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_DstAlpha;
+ imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE;
+ }
+ break;
+
+ case GL_ONE_MINUS_DST_ALPHA:
+ if (imesa->glCtx->Visual.alphaBits == 0)
+ {
+ imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_Zero;
+ }
+ else
+ {
+ imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_1DstAlpha;
+ imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE;
+ }
+ break;
+ }
+ }
+ else
+ {
+ imesa->regs.s3d.drawCtrl.ni.dstAlphaMode = DAM_Zero;
+ imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_One;
+ }
+
+ /* alpha test*/
+
+ if(ctx->Color.AlphaEnabled)
+ {
+ ACmpFunc a;
+ GLubyte alphaRef;
+
+ CLAMPED_FLOAT_TO_UBYTE(alphaRef,ctx->Color.AlphaRef);
+
+ switch(ctx->Color.AlphaFunc) {
+ case GL_NEVER: a = CF_Never; break;
+ case GL_ALWAYS: a = CF_Always; break;
+ case GL_LESS: a = CF_Less; break;
+ case GL_LEQUAL: a = CF_LessEqual; break;
+ case GL_EQUAL: a = CF_Equal; break;
+ case GL_GREATER: a = CF_Greater; break;
+ case GL_GEQUAL: a = CF_GreaterEqual; break;
+ case GL_NOTEQUAL: a = CF_NotEqual; break;
+ default:return;
+ }
+
+ imesa->regs.s3d.drawCtrl.ni.alphaTestEn = GL_TRUE;
+ imesa->regs.s3d.drawCtrl.ni.alphaTestCmpFunc = a;
+ imesa->regs.s3d.drawCtrl.ni.alphaRefVal = alphaRef;
+ }
+ else
+ {
+ imesa->regs.s3d.drawCtrl.ni.alphaTestEn = GL_FALSE;
+ }
+
+ /* Set/Reset Z-after-alpha*/
+
+ imesa->regs.s3d.zBufCtrl.ni.wrZafterAlphaTst =
+ imesa->regs.s3d.drawCtrl.ni.alphaTestEn;
+
+ if (drawCtrl != imesa->regs.s3d.drawCtrl.ui ||
+ zBufCtrl != imesa->regs.s3d.zBufCtrl.ui)
+ imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
+}
+
+static void savageDDBlendFuncSeparate_s4( GLcontext *ctx, GLenum sfactorRGB,
+ GLenum dfactorRGB, GLenum sfactorA,
+ GLenum dfactorA )
+{
+ assert (dfactorRGB == dfactorA && sfactorRGB == sfactorA);
+ savageBlendFunc_s4( ctx );
+}
+static void savageDDBlendFuncSeparate_s3d( GLcontext *ctx, GLenum sfactorRGB,
+ GLenum dfactorRGB, GLenum sfactorA,
+ GLenum dfactorA )
+{
+ assert (dfactorRGB == dfactorA && sfactorRGB == sfactorA);
+ savageBlendFunc_s3d( ctx );
+}
+
+
+
+static void savageDDDepthFunc_s4(GLcontext *ctx, GLenum func)
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ ZCmpFunc zmode;
+ u_int32_t drawLocalCtrl = imesa->regs.s4.drawLocalCtrl.ui;
+ u_int32_t zBufCtrl = imesa->regs.s4.zBufCtrl.ui;
+ u_int32_t zWatermarks = imesa->regs.s4.zWatermarks.ui; /* FIXME: in DRM */
+
+ /* set up z-buffer control register (global)
+ * set up z-buffer offset register (global)
+ * set up z read/write watermarks register (global)
+ */
+
+ switch(func) { /* reversed (see savageCalcViewport) */
+ case GL_NEVER: zmode = CF_Never; break;
+ case GL_ALWAYS: zmode = CF_Always; break;
+ case GL_LESS: zmode = CF_Greater; break;
+ case GL_LEQUAL: zmode = CF_GreaterEqual; break;
+ case GL_EQUAL: zmode = CF_Equal; break;
+ case GL_GREATER: zmode = CF_Less; break;
+ case GL_GEQUAL: zmode = CF_LessEqual; break;
+ case GL_NOTEQUAL: zmode = CF_NotEqual; break;
+ default:return;
+ }
+ if (ctx->Depth.Test)
+ {
+
+ imesa->regs.s4.zBufCtrl.ni.zCmpFunc = zmode;
+ imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn = ctx->Depth.Mask;
+ imesa->regs.s4.drawLocalCtrl.ni.flushPdZbufWrites = GL_TRUE;
+ imesa->regs.s4.zBufCtrl.ni.zBufEn = GL_TRUE;
+ }
+ else if (imesa->glCtx->Stencil.Enabled && imesa->hw_stencil)
+ {
+ /* Need to keep Z on for Stencil. */
+ imesa->regs.s4.zBufCtrl.ni.zCmpFunc = CF_Always;
+ imesa->regs.s4.zBufCtrl.ni.zBufEn = GL_TRUE;
+ imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn = GL_FALSE;
+ imesa->regs.s4.drawLocalCtrl.ni.flushPdZbufWrites = GL_FALSE;
+ }
+ else
+ {
+
+ if (imesa->regs.s4.drawLocalCtrl.ni.drawUpdateEn == GL_FALSE)
+ {
+ imesa->regs.s4.zBufCtrl.ni.zCmpFunc = CF_Always;
+ imesa->regs.s4.zBufCtrl.ni.zBufEn = GL_TRUE;
+ }
+ else
+
+ /* DRAWUPDATE_REQUIRES_Z_ENABLED*/
+ {
+ imesa->regs.s4.zBufCtrl.ni.zBufEn = GL_FALSE;
+ }
+ imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn = GL_FALSE;
+ imesa->regs.s4.drawLocalCtrl.ni.flushPdZbufWrites = GL_FALSE;
+ }
+
+ if (drawLocalCtrl != imesa->regs.s4.drawLocalCtrl.ui)
+ imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
+ if (zBufCtrl != imesa->regs.s4.zBufCtrl.ui ||
+ zWatermarks != imesa->regs.s4.zWatermarks.ui)
+ imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
+}
+static void savageDDDepthFunc_s3d(GLcontext *ctx, GLenum func)
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ ZCmpFunc zmode;
+ u_int32_t drawCtrl = imesa->regs.s3d.drawCtrl.ui;
+ u_int32_t zBufCtrl = imesa->regs.s3d.zBufCtrl.ui;
+ u_int32_t zWatermarks = imesa->regs.s3d.zWatermarks.ui; /* FIXME: in DRM */
+
+ /* set up z-buffer control register (global)
+ * set up z-buffer offset register (global)
+ * set up z read/write watermarks register (global)
+ */
+ switch(func) { /* reversed (see savageCalcViewport) */
+ case GL_NEVER: zmode = CF_Never; break;
+ case GL_ALWAYS: zmode = CF_Always; break;
+ case GL_LESS: zmode = CF_Greater; break;
+ case GL_LEQUAL: zmode = CF_GreaterEqual; break;
+ case GL_EQUAL: zmode = CF_Equal; break;
+ case GL_GREATER: zmode = CF_Less; break;
+ case GL_GEQUAL: zmode = CF_LessEqual; break;
+ case GL_NOTEQUAL: zmode = CF_NotEqual; break;
+ default:return;
+ }
+ if (ctx->Depth.Test)
+ {
+ imesa->regs.s3d.zBufCtrl.ni.zBufEn = GL_TRUE;
+ imesa->regs.s3d.zBufCtrl.ni.zCmpFunc = zmode;
+ imesa->regs.s3d.zBufCtrl.ni.zUpdateEn = ctx->Depth.Mask;
+
+ imesa->regs.s3d.drawCtrl.ni.flushPdZbufWrites = GL_TRUE;
+ }
+ else
+ {
+ if (imesa->regs.s3d.zBufCtrl.ni.drawUpdateEn == GL_FALSE) {
+ imesa->regs.s3d.zBufCtrl.ni.zCmpFunc = CF_Always;
+ imesa->regs.s3d.zBufCtrl.ni.zBufEn = GL_TRUE;
+ }
+ else
+
+ /* DRAWUPDATE_REQUIRES_Z_ENABLED*/
+ {
+ imesa->regs.s3d.zBufCtrl.ni.zBufEn = GL_FALSE;
+ }
+ imesa->regs.s3d.zBufCtrl.ni.zUpdateEn = GL_FALSE;
+ imesa->regs.s3d.drawCtrl.ni.flushPdZbufWrites = GL_FALSE;
+ }
+
+ if (drawCtrl != imesa->regs.s3d.drawCtrl.ui ||
+ zBufCtrl != imesa->regs.s3d.zBufCtrl.ui)
+ imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
+ if (zWatermarks != imesa->regs.s3d.zWatermarks.ui)
+ imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
+}
+
+static void savageDDDepthMask_s4(GLcontext *ctx, GLboolean flag)
+{
+ savageDDDepthFunc_s4(ctx,ctx->Depth.Func);
+}
+static void savageDDDepthMask_s3d(GLcontext *ctx, GLboolean flag)
+{
+ savageDDDepthFunc_s3d(ctx,ctx->Depth.Func);
+}
+
+
+
+
+/* =============================================================
+ * Hardware clipping
+ */
+
+
+static void savageDDScissor( GLcontext *ctx, GLint x, GLint y,
+ GLsizei w, GLsizei h )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+
+ /* Emit buffered commands with old scissor state. */
+ FLUSH_BATCH(imesa);
+
+ /* Mirror scissors in private context. */
+ imesa->scissor.enabled = ctx->Scissor.Enabled;
+ imesa->scissor.x = x;
+ imesa->scissor.y = y;
+ imesa->scissor.w = w;
+ imesa->scissor.h = h;
+}
+
+
+
+static void savageDDDrawBuffer(GLcontext *ctx, GLenum mode )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ u_int32_t destCtrl = imesa->regs.s4.destCtrl.ui;
+
+ /*
+ * _DrawDestMask is easier to cope with than <mode>.
+ */
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ imesa->IsDouble = GL_FALSE;
+ imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->frontOffset>>11;
+
+ imesa->NotFirstFrame = GL_FALSE;
+ savageXMesaSetFrontClipRects( imesa );
+ FALLBACK( ctx, SAVAGE_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ imesa->IsDouble = GL_TRUE;
+ imesa->regs.s4.destCtrl.ni.offset = imesa->savageScreen->backOffset>>11;
+ imesa->NotFirstFrame = GL_FALSE;
+ savageXMesaSetBackClipRects( imesa );
+ FALLBACK( ctx, SAVAGE_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ break;
+ default:
+ FALLBACK( ctx, SAVAGE_FALLBACK_DRAW_BUFFER, GL_TRUE );
+ return;
+ }
+
+ /* We want to update the s/w rast state too so that r200SetBuffer() (?)
+ * gets called.
+ */
+ _swrast_DrawBuffer(ctx, mode);
+
+ if (destCtrl != imesa->regs.s4.destCtrl.ui)
+ imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
+}
+
+static void savageDDReadBuffer(GLcontext *ctx, GLenum mode )
+{
+ /* nothing, until we implement h/w glRead/CopyPixels or CopyTexImage */
+}
+
+#if 0
+static void savageDDSetColor(GLcontext *ctx,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ imesa->MonoColor = savagePackColor( imesa->savageScreen->frontFormat, r, g, b, a );
+}
+#endif
+
+/* =============================================================
+ * Window position and viewport transformation
+ */
+
+void savageCalcViewport( GLcontext *ctx )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat *m = imesa->hw_viewport;
+
+ m[MAT_SX] = v[MAT_SX];
+ m[MAT_TX] = v[MAT_TX] + imesa->drawX + SUBPIXEL_X;
+ m[MAT_SY] = - v[MAT_SY];
+ m[MAT_TY] = - v[MAT_TY] + imesa->driDrawable->h + imesa->drawY + SUBPIXEL_Y;
+ /* Depth range is reversed (far: 0, near: 1) so that float depth
+ * compensates for loss of accuracy of far coordinates. */
+ if (imesa->float_depth && imesa->savageScreen->zpp == 2) {
+ /* The Savage 16-bit floating point depth format can't encode
+ * numbers < 2^-16. Make sure all depth values stay greater
+ * than that. */
+ m[MAT_SZ] = - v[MAT_SZ] * imesa->depth_scale * (65535.0/65536.0);
+ m[MAT_TZ] = 1.0 - v[MAT_TZ] * imesa->depth_scale * (65535.0/65536.0);
+ } else {
+ m[MAT_SZ] = - v[MAT_SZ] * imesa->depth_scale;
+ m[MAT_TZ] = 1.0 - v[MAT_TZ] * imesa->depth_scale;
+ }
+
+ imesa->SetupNewInputs = ~0;
+}
+
+static void savageViewport( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
+ savageCalcViewport( ctx );
+}
+
+static void savageDepthRange( GLcontext *ctx,
+ GLclampd nearval, GLclampd farval )
+{
+ savageCalcViewport( ctx );
+}
+
+
+/* =============================================================
+ * Miscellaneous
+ */
+
+static void savageDDClearColor(GLcontext *ctx,
+ const GLfloat color[4] )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ GLubyte c[4];
+ CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
+
+ imesa->ClearColor = savagePackColor( imesa->savageScreen->frontFormat,
+ c[0], c[1], c[2], c[3] );
+}
+
+/* Fallback to swrast for select and feedback.
+ */
+static void savageRenderMode( GLcontext *ctx, GLenum mode )
+{
+ FALLBACK( ctx, SAVAGE_FALLBACK_RENDERMODE, (mode != GL_RENDER) );
+}
+
+
+#if HW_CULL
+
+/* =============================================================
+ * Culling - the savage isn't quite as clean here as the rest of
+ * its interfaces, but it's not bad.
+ */
+static void savageDDCullFaceFrontFace(GLcontext *ctx, GLenum unused)
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ GLuint cullMode=imesa->LcsCullMode;
+ switch (ctx->Polygon.CullFaceMode)
+ {
+ case GL_FRONT:
+ switch (ctx->Polygon.FrontFace)
+ {
+ case GL_CW:
+ cullMode = BCM_CW;
+ break;
+ case GL_CCW:
+ cullMode = BCM_CCW;
+ break;
+ }
+ break;
+
+ case GL_BACK:
+ switch (ctx->Polygon.FrontFace)
+ {
+ case GL_CW:
+ cullMode = BCM_CCW;
+ break;
+ case GL_CCW:
+ cullMode = BCM_CW;
+ break;
+ }
+ break;
+ }
+ imesa->LcsCullMode = cullMode;
+ imesa->new_state |= SAVAGE_NEW_CULL;
+}
+#endif /* end #if HW_CULL */
+
+static void savageUpdateCull( GLcontext *ctx )
+{
+#if HW_CULL
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ GLuint cullMode;
+ if (ctx->Polygon.CullFlag &&
+ imesa->raster_primitive >= GL_TRIANGLES &&
+ ctx->Polygon.CullFaceMode != GL_FRONT_AND_BACK)
+ cullMode = imesa->LcsCullMode;
+ else
+ cullMode = BCM_None;
+ if (imesa->savageScreen->chipset >= S3_SAVAGE4) {
+ if (imesa->regs.s4.drawCtrl1.ni.cullMode != cullMode) {
+ imesa->regs.s4.drawCtrl1.ni.cullMode = cullMode;
+ imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
+ }
+ } else {
+ if (imesa->regs.s3d.drawCtrl.ni.cullMode != cullMode) {
+ imesa->regs.s3d.drawCtrl.ni.cullMode = cullMode;
+ imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
+ }
+ }
+#endif /* end #if HW_CULL */
+}
+
+
+
+/* =============================================================
+ * Color masks
+ */
+
+/* Savage4 can disable draw updates when all channels are
+ * masked. Savage3D has a bit called drawUpdateEn, but it doesn't seem
+ * to have any effect. If only some channels are masked we need a
+ * software fallback on all chips.
+ */
+static void savageDDColorMask_s4(GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
+ GLboolean passAny, passAll;
+
+ if (ctx->Visual.alphaBits) {
+ passAny = b || g || r || a;
+ passAll = r && g && b && a;
+ } else {
+ passAny = b || g || r;
+ passAll = r && g && b;
+ }
+
+ if (passAny) {
+ if (!imesa->regs.s4.drawLocalCtrl.ni.drawUpdateEn) {
+ imesa->regs.s4.drawLocalCtrl.ni.drawUpdateEn = GL_TRUE;
+ imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
+ }
+ FALLBACK (ctx, SAVAGE_FALLBACK_COLORMASK, !passAll);
+ } else if (imesa->regs.s4.drawLocalCtrl.ni.drawUpdateEn) {
+ imesa->regs.s4.drawLocalCtrl.ni.drawUpdateEn = GL_FALSE;
+ imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
+ }
+}
+static void savageDDColorMask_s3d(GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a )
+{
+ if (ctx->Visual.alphaBits)
+ FALLBACK (ctx, SAVAGE_FALLBACK_COLORMASK, !(r && g && b && a));
+ else
+ FALLBACK (ctx, SAVAGE_FALLBACK_COLORMASK, !(r && g && b));
+}
+
+/* Seperate specular not fully implemented in hardware... Needs
+ * some interaction with material state? Just punt to software
+ * in all cases?
+ * FK: Don't fall back for now. Let's see the failure cases and
+ * fix them the right way. I don't see how this could be a
+ * hardware limitation.
+ */
+static void savageUpdateSpecular_s4(GLcontext *ctx) {
+ savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
+ u_int32_t drawLocalCtrl = imesa->regs.s4.drawLocalCtrl.ui;
+
+ if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR &&
+ ctx->Light.Enabled) {
+ imesa->regs.s4.drawLocalCtrl.ni.specShadeEn = GL_TRUE;
+ /*FALLBACK (ctx, SAVAGE_FALLBACK_SPECULAR, GL_TRUE);*/
+ } else {
+ imesa->regs.s4.drawLocalCtrl.ni.specShadeEn = GL_FALSE;
+ /*FALLBACK (ctx, SAVAGE_FALLBACK_SPECULAR, GL_FALSE);*/
+ }
+
+ if (drawLocalCtrl != imesa->regs.s4.drawLocalCtrl.ui)
+ imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
+}
+static void savageUpdateSpecular_s3d(GLcontext *ctx) {
+ savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
+ u_int32_t drawCtrl = imesa->regs.s3d.drawCtrl.ui;
+
+ if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR &&
+ ctx->Light.Enabled) {
+ imesa->regs.s3d.drawCtrl.ni.specShadeEn = GL_TRUE;
+ /*FALLBACK (ctx, SAVAGE_FALLBACK_SPECULAR, GL_TRUE);*/
+ } else {
+ imesa->regs.s3d.drawCtrl.ni.specShadeEn = GL_FALSE;
+ /*FALLBACK (ctx, SAVAGE_FALLBACK_SPECULAR, GL_FALSE);*/
+ }
+
+ if (drawCtrl != imesa->regs.s3d.drawCtrl.ui)
+ imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
+}
+
+static void savageDDLightModelfv_s4(GLcontext *ctx, GLenum pname,
+ const GLfloat *param)
+{
+ savageUpdateSpecular_s4 (ctx);
+}
+static void savageDDLightModelfv_s3d(GLcontext *ctx, GLenum pname,
+ const GLfloat *param)
+{
+ savageUpdateSpecular_s3d (ctx);
+}
+
+static void savageDDShadeModel_s4(GLcontext *ctx, GLuint mod)
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
+ u_int32_t drawLocalCtrl = imesa->regs.s4.drawLocalCtrl.ui;
+
+ if (mod == GL_SMOOTH)
+ {
+ imesa->regs.s4.drawLocalCtrl.ni.flatShadeEn = GL_FALSE;
+ }
+ else
+ {
+ imesa->regs.s4.drawLocalCtrl.ni.flatShadeEn = GL_TRUE;
+ }
+
+ if (drawLocalCtrl != imesa->regs.s4.drawLocalCtrl.ui)
+ imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
+}
+static void savageDDShadeModel_s3d(GLcontext *ctx, GLuint mod)
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
+ u_int32_t drawCtrl = imesa->regs.s3d.drawCtrl.ui;
+
+ if (mod == GL_SMOOTH)
+ {
+ imesa->regs.s3d.drawCtrl.ni.flatShadeEn = GL_FALSE;
+ }
+ else
+ {
+ imesa->regs.s3d.drawCtrl.ni.flatShadeEn = GL_TRUE;
+ }
+
+ if (drawCtrl != imesa->regs.s3d.drawCtrl.ui)
+ imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
+}
+
+
+/* =============================================================
+ * Fog
+ * The fogCtrl register has the same position and the same layout
+ * on savage3d and savage4. No need for two separate functions.
+ */
+
+static void savageDDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param)
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ GLuint fogClr;
+ u_int32_t fogCtrl = imesa->regs.s4.fogCtrl.ui;
+
+ /*if ((ctx->Fog.Enabled) &&(pname == GL_FOG_COLOR))*/
+ if (ctx->Fog.Enabled)
+ {
+ fogClr = (((GLubyte)(ctx->Fog.Color[0]*255.0F) << 16) |
+ ((GLubyte)(ctx->Fog.Color[1]*255.0F) << 8) |
+ ((GLubyte)(ctx->Fog.Color[2]*255.0F) << 0));
+ imesa->regs.s4.fogCtrl.ni.fogEn = GL_TRUE;
+ /*cheap fog*/
+ imesa->regs.s4.fogCtrl.ni.fogMode = GL_TRUE;
+ imesa->regs.s4.fogCtrl.ni.fogClr = fogClr;
+ }
+ else
+ {
+ /*No fog*/
+
+ imesa->regs.s4.fogCtrl.ni.fogEn = 0;
+ imesa->regs.s4.fogCtrl.ni.fogMode = 0;
+ }
+
+ if (fogCtrl != imesa->regs.s4.fogCtrl.ui)
+ imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
+}
+
+
+static void savageDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref,
+ GLuint mask)
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ unsigned a=0;
+ const u_int32_t zBufCtrl = imesa->regs.s4.zBufCtrl.ui;
+ const u_int32_t stencilCtrl = imesa->regs.s4.stencilCtrl.ui;
+
+ imesa->regs.s4.zBufCtrl.ni.stencilRefVal = ctx->Stencil.Ref[0];
+ imesa->regs.s4.stencilCtrl.ni.readMask = ctx->Stencil.ValueMask[0];
+
+ switch (ctx->Stencil.Function[0])
+ {
+ case GL_NEVER: a = CF_Never; break;
+ case GL_ALWAYS: a = CF_Always; break;
+ case GL_LESS: a = CF_Less; break;
+ case GL_LEQUAL: a = CF_LessEqual; break;
+ case GL_EQUAL: a = CF_Equal; break;
+ case GL_GREATER: a = CF_Greater; break;
+ case GL_GEQUAL: a = CF_GreaterEqual; break;
+ case GL_NOTEQUAL: a = CF_NotEqual; break;
+ default:
+ break;
+ }
+
+ imesa->regs.s4.stencilCtrl.ni.cmpFunc = a;
+
+ if (zBufCtrl != imesa->regs.s4.zBufCtrl.ui ||
+ stencilCtrl != imesa->regs.s4.stencilCtrl.ui)
+ imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
+}
+
+static void savageDDStencilMask(GLcontext *ctx, GLuint mask)
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+
+ if (imesa->regs.s4.stencilCtrl.ni.writeMask != ctx->Stencil.WriteMask[0]) {
+ imesa->regs.s4.stencilCtrl.ni.writeMask = ctx->Stencil.WriteMask[0];
+ imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
+ }
+}
+
+static unsigned get_stencil_op_value( GLenum op )
+{
+ switch (op)
+ {
+ case GL_KEEP: return STENCIL_Keep;
+ case GL_ZERO: return STENCIL_Zero;
+ case GL_REPLACE: return STENCIL_Equal;
+ case GL_INCR: return STENCIL_IncClamp;
+ case GL_DECR: return STENCIL_DecClamp;
+ case GL_INVERT: return STENCIL_Invert;
+ case GL_INCR_WRAP: return STENCIL_Inc;
+ case GL_DECR_WRAP: return STENCIL_Dec;
+ }
+
+ /* Should *never* get here. */
+ return STENCIL_Keep;
+}
+
+static void savageDDStencilOp(GLcontext *ctx, GLenum fail, GLenum zfail,
+ GLenum zpass)
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ const u_int32_t stencilCtrl = imesa->regs.s4.stencilCtrl.ui;
+
+ imesa->regs.s4.stencilCtrl.ni.failOp = get_stencil_op_value( ctx->Stencil.FailFunc[0] );
+ imesa->regs.s4.stencilCtrl.ni.passZfailOp = get_stencil_op_value( ctx->Stencil.ZFailFunc[0] );
+ imesa->regs.s4.stencilCtrl.ni.passZpassOp = get_stencil_op_value( ctx->Stencil.ZPassFunc[0] );
+
+ if (stencilCtrl != imesa->regs.s4.stencilCtrl.ui)
+ imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
+}
+
+
+/* =============================================================
+ */
+
+static void savageDDEnable_s4(GLcontext *ctx, GLenum cap, GLboolean state)
+{
+
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ switch(cap) {
+ case GL_ALPHA_TEST:
+ /* we should consider the disable case*/
+ savageBlendFunc_s4(ctx);
+ break;
+ case GL_BLEND:
+ /*add the savageBlendFunc 2001/11/25
+ * if call no such function, then glDisable(GL_BLEND) will do noting,
+ *our chip has no disable bit
+ */
+ savageBlendFunc_s4(ctx);
+ case GL_COLOR_LOGIC_OP:
+ /* Fall through:
+ * For some reason enable(GL_BLEND) affects ColorLogicOpEnabled.
+ */
+ FALLBACK (ctx, SAVAGE_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
+ break;
+ case GL_DEPTH_TEST:
+ savageDDDepthFunc_s4(ctx,ctx->Depth.Func);
+ break;
+ case GL_SCISSOR_TEST:
+ savageDDScissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
+ ctx->Scissor.Width, ctx->Scissor.Height);
+ break;
+ case GL_STENCIL_TEST:
+ if (!imesa->hw_stencil)
+ FALLBACK (ctx, SAVAGE_FALLBACK_STENCIL, state);
+ else {
+ imesa->regs.s4.stencilCtrl.ni.stencilEn = state;
+ if (ctx->Stencil.Enabled &&
+ imesa->regs.s4.zBufCtrl.ni.zBufEn != GL_TRUE)
+ {
+ /* Stencil buffer requires Z enabled. */
+ imesa->regs.s4.zBufCtrl.ni.zCmpFunc = CF_Always;
+ imesa->regs.s4.zBufCtrl.ni.zBufEn = GL_TRUE;
+ imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn = GL_FALSE;
+ }
+ imesa->dirty |= SAVAGE_UPLOAD_GLOBAL | SAVAGE_UPLOAD_LOCAL;
+ }
+ break;
+ case GL_FOG:
+ savageDDFogfv(ctx,0,0);
+ break;
+ case GL_CULL_FACE:
+#if HW_CULL
+ if (state)
+ {
+ savageDDCullFaceFrontFace(ctx,0);
+ }
+ else
+ {
+ imesa->LcsCullMode = BCM_None;
+ imesa->new_state |= SAVAGE_NEW_CULL;
+ }
+#endif
+ break;
+ case GL_DITHER:
+ if (state)
+ {
+ if ( ctx->Color.DitherFlag )
+ {
+ imesa->regs.s4.drawCtrl1.ni.ditherEn=GL_TRUE;
+ }
+ }
+ if (!ctx->Color.DitherFlag )
+ {
+ imesa->regs.s4.drawCtrl1.ni.ditherEn=GL_FALSE;
+ }
+ imesa->dirty |= SAVAGE_UPLOAD_GLOBAL;
+ break;
+
+ case GL_LIGHTING:
+ savageUpdateSpecular_s4 (ctx);
+ break;
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_3D:
+ imesa->new_state |= SAVAGE_NEW_TEXTURE;
+ break;
+ case GL_TEXTURE_2D:
+ imesa->new_state |= SAVAGE_NEW_TEXTURE;
+ break;
+ default:
+ ;
+ }
+}
+static void savageDDEnable_s3d(GLcontext *ctx, GLenum cap, GLboolean state)
+{
+
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ switch(cap) {
+ case GL_ALPHA_TEST:
+ /* we should consider the disable case*/
+ savageBlendFunc_s3d(ctx);
+ break;
+ case GL_BLEND:
+ /*add the savageBlendFunc 2001/11/25
+ * if call no such function, then glDisable(GL_BLEND) will do noting,
+ *our chip has no disable bit
+ */
+ savageBlendFunc_s3d(ctx);
+ case GL_COLOR_LOGIC_OP:
+ /* Fall through:
+ * For some reason enable(GL_BLEND) affects ColorLogicOpEnabled.
+ */
+ FALLBACK (ctx, SAVAGE_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
+ break;
+ case GL_DEPTH_TEST:
+ savageDDDepthFunc_s3d(ctx,ctx->Depth.Func);
+ break;
+ case GL_SCISSOR_TEST:
+ savageDDScissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
+ ctx->Scissor.Width, ctx->Scissor.Height);
+ break;
+ case GL_STENCIL_TEST:
+ FALLBACK (ctx, SAVAGE_FALLBACK_STENCIL, state);
+ break;
+ case GL_FOG:
+ savageDDFogfv(ctx,0,0);
+ break;
+ case GL_CULL_FACE:
+#if HW_CULL
+ if (state)
+ {
+ savageDDCullFaceFrontFace(ctx,0);
+ }
+ else
+ {
+ imesa->LcsCullMode = BCM_None;
+ imesa->new_state |= SAVAGE_NEW_CULL;
+ }
+#endif
+ break;
+ case GL_DITHER:
+ if (state)
+ {
+ if ( ctx->Color.DitherFlag )
+ {
+ imesa->regs.s3d.drawCtrl.ni.ditherEn=GL_TRUE;
+ }
+ }
+ if (!ctx->Color.DitherFlag )
+ {
+ imesa->regs.s3d.drawCtrl.ni.ditherEn=GL_FALSE;
+ }
+ imesa->dirty |= SAVAGE_UPLOAD_LOCAL;
+ break;
+
+ case GL_LIGHTING:
+ savageUpdateSpecular_s3d (ctx);
+ break;
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_3D:
+ imesa->new_state |= SAVAGE_NEW_TEXTURE;
+ break;
+ case GL_TEXTURE_2D:
+ imesa->new_state |= SAVAGE_NEW_TEXTURE;
+ break;
+ default:
+ ;
+ }
+}
+
+void savageDDUpdateHwState( GLcontext *ctx )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+
+ if (imesa->new_state) {
+ savageFlushVertices(imesa);
+ if (imesa->new_state & SAVAGE_NEW_TEXTURE) {
+ savageUpdateTextureState( ctx );
+ }
+ if ((imesa->new_state & SAVAGE_NEW_CULL)) {
+ savageUpdateCull(ctx);
+ }
+ imesa->new_state = 0;
+ }
+}
+
+
+static void savageDDPrintDirty( const char *msg, GLuint state )
+{
+ fprintf(stderr, "%s (0x%x): %s%s%s%s%s%s\n",
+ msg,
+ (unsigned int) state,
+ (state & SAVAGE_UPLOAD_LOCAL) ? "upload-local, " : "",
+ (state & SAVAGE_UPLOAD_TEX0) ? "upload-tex0, " : "",
+ (state & SAVAGE_UPLOAD_TEX1) ? "upload-tex1, " : "",
+ (state & SAVAGE_UPLOAD_FOGTBL) ? "upload-fogtbl, " : "",
+ (state & SAVAGE_UPLOAD_GLOBAL) ? "upload-global, " : "",
+ (state & SAVAGE_UPLOAD_TEXGLOBAL) ? "upload-texglobal, " : ""
+ );
+}
+
+
+/**
+ * Check if global registers were changed
+ */
+static GLboolean savageGlobalRegChanged (savageContextPtr imesa,
+ GLuint first, GLuint last) {
+ GLuint i;
+ for (i = first - SAVAGE_FIRST_REG; i <= last - SAVAGE_FIRST_REG; ++i) {
+ if (((imesa->oldRegs.ui[i] ^ imesa->regs.ui[i]) &
+ imesa->globalRegMask.ui[i]) != 0)
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+}
+static void savageEmitOldRegs (savageContextPtr imesa,
+ GLuint first, GLuint last, GLboolean global) {
+ GLuint n = last-first+1;
+ drm_savage_cmd_header_t *cmd = savageAllocCmdBuf(imesa, n*4);
+ cmd->state.cmd = SAVAGE_CMD_STATE;
+ cmd->state.global = global;
+ cmd->state.count = n;
+ cmd->state.start = first;
+ memcpy(cmd+1, &imesa->oldRegs.ui[first-SAVAGE_FIRST_REG], n*4);
+}
+static void savageEmitContiguousRegs (savageContextPtr imesa,
+ GLuint first, GLuint last) {
+ GLuint i;
+ GLuint n = last-first+1;
+ drm_savage_cmd_header_t *cmd = savageAllocCmdBuf(imesa, n*4);
+ cmd->state.cmd = SAVAGE_CMD_STATE;
+ cmd->state.global = savageGlobalRegChanged(imesa, first, last);
+ cmd->state.count = n;
+ cmd->state.start = first;
+ memcpy(cmd+1, &imesa->regs.ui[first-SAVAGE_FIRST_REG], n*4);
+ /* savageAllocCmdBuf may need to flush the cmd buffer and backup
+ * the current hardware state. It should see the "old" (current)
+ * state that has actually been emitted to the hardware. Therefore
+ * this update is done *after* savageAllocCmdBuf. */
+ for (i = first - SAVAGE_FIRST_REG; i <= last - SAVAGE_FIRST_REG; ++i)
+ imesa->oldRegs.ui[i] = imesa->regs.ui[i];
+ if (SAVAGE_DEBUG & DEBUG_STATE)
+ fprintf (stderr, "Emitting regs 0x%02x-0x%02x\n", first, last);
+}
+static void savageEmitChangedRegs (savageContextPtr imesa,
+ GLuint first, GLuint last) {
+ GLuint i, firstChanged;
+ firstChanged = SAVAGE_NR_REGS;
+ for (i = first - SAVAGE_FIRST_REG; i <= last - SAVAGE_FIRST_REG; ++i) {
+ if (imesa->oldRegs.ui[i] != imesa->regs.ui[i]) {
+ if (firstChanged == SAVAGE_NR_REGS)
+ firstChanged = i;
+ } else {
+ if (firstChanged != SAVAGE_NR_REGS) {
+ savageEmitContiguousRegs (imesa, firstChanged+SAVAGE_FIRST_REG,
+ i-1+SAVAGE_FIRST_REG);
+ firstChanged = SAVAGE_NR_REGS;
+ }
+ }
+ }
+ if (firstChanged != SAVAGE_NR_REGS)
+ savageEmitContiguousRegs (imesa, firstChanged+SAVAGE_FIRST_REG,
+ last);
+}
+static void savageEmitChangedRegChunk (savageContextPtr imesa,
+ GLuint first, GLuint last) {
+ GLuint i;
+ for (i = first - SAVAGE_FIRST_REG; i <= last - SAVAGE_FIRST_REG; ++i) {
+ if (imesa->oldRegs.ui[i] != imesa->regs.ui[i]) {
+ savageEmitContiguousRegs (imesa, first, last);
+ break;
+ }
+ }
+}
+static void savageUpdateRegister_s4(savageContextPtr imesa)
+{
+ /* In case the texture image was changed without changing the
+ * texture address as well, we need to force emitting the texture
+ * address in order to flush texture cashes. */
+ if ((imesa->dirty & SAVAGE_UPLOAD_TEX0) &&
+ imesa->oldRegs.s4.texAddr[0].ui == imesa->regs.s4.texAddr[0].ui)
+ imesa->oldRegs.s4.texAddr[0].ui = 0xffffffff;
+ if ((imesa->dirty & SAVAGE_UPLOAD_TEX1) &&
+ imesa->oldRegs.s4.texAddr[1].ui == imesa->regs.s4.texAddr[1].ui)
+ imesa->oldRegs.s4.texAddr[1].ui = 0xffffffff;
+
+ /* Fix up watermarks */
+ if (imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites) {
+ imesa->regs.s4.destTexWatermarks.ni.destWriteLow = 0;
+ imesa->regs.s4.destTexWatermarks.ni.destFlush = 1;
+ } else
+ imesa->regs.s4.destTexWatermarks.ni.destWriteLow = S4_DWLO;
+ if (imesa->regs.s4.drawLocalCtrl.ni.flushPdZbufWrites)
+ imesa->regs.s4.zWatermarks.ni.wLow = 0;
+ else
+ imesa->regs.s4.zWatermarks.ni.wLow = S4_ZWLO;
+
+ savageEmitChangedRegs (imesa, 0x1e, 0x39);
+
+ imesa->dirty=0;
+}
+static void savageUpdateRegister_s3d(savageContextPtr imesa)
+{
+ /* In case the texture image was changed without changing the
+ * texture address as well, we need to force emitting the texture
+ * address in order to flush texture cashes. */
+ if ((imesa->dirty & SAVAGE_UPLOAD_TEX0) &&
+ imesa->oldRegs.s3d.texAddr.ui == imesa->regs.s3d.texAddr.ui)
+ imesa->oldRegs.s3d.texAddr.ui = 0xffffffff;
+
+ /* Fix up watermarks */
+ if (imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites) {
+ imesa->regs.s3d.destTexWatermarks.ni.destWriteLow = 0;
+ imesa->regs.s3d.destTexWatermarks.ni.destFlush = 1;
+ } else
+ imesa->regs.s3d.destTexWatermarks.ni.destWriteLow = S3D_DWLO;
+ if (imesa->regs.s3d.drawCtrl.ni.flushPdZbufWrites)
+ imesa->regs.s3d.zWatermarks.ni.wLow = 0;
+ else
+ imesa->regs.s3d.zWatermarks.ni.wLow = S3D_ZWLO;
+
+
+ /* the savage3d uses two contiguous ranges of BCI registers:
+ * 0x18-0x1c and 0x20-0x38. Some texture registers need to be
+ * emitted in one chunk or we get some funky rendering errors. */
+ savageEmitChangedRegs (imesa, 0x18, 0x19);
+ savageEmitChangedRegChunk (imesa, 0x1a, 0x1c);
+ savageEmitChangedRegs (imesa, 0x20, 0x38);
+
+ imesa->dirty=0;
+}
+
+
+void savageEmitOldState( savageContextPtr imesa )
+{
+ assert(imesa->cmdBuf.write == imesa->cmdBuf.base);
+ if (imesa->savageScreen->chipset >= S3_SAVAGE4) {
+ savageEmitOldRegs (imesa, 0x1e, 0x39, GL_TRUE);
+ } else {
+ savageEmitOldRegs (imesa, 0x18, 0x1c, GL_TRUE);
+ savageEmitOldRegs (imesa, 0x20, 0x38, GL_FALSE);
+ }
+}
+
+
+/* Push the state into the sarea and/or texture memory.
+ */
+void savageEmitChangedState( savageContextPtr imesa )
+{
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_API)
+ savageDDPrintDirty( "\n\n\nsavageEmitHwStateLocked", imesa->dirty );
+
+ if (imesa->dirty)
+ {
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_MSG)
+ fprintf (stderr, "... emitting state\n");
+ if (imesa->savageScreen->chipset >= S3_SAVAGE4)
+ savageUpdateRegister_s4(imesa);
+ else
+ savageUpdateRegister_s3d(imesa);
+ }
+
+ imesa->dirty = 0;
+}
+
+
+static void savageDDInitState_s4( savageContextPtr imesa )
+{
+#if 1
+ imesa->regs.s4.destCtrl.ui = 1<<7;
+#endif
+
+ imesa->regs.s4.zBufCtrl.ni.zCmpFunc = CF_Less;
+ imesa->regs.s4.zBufCtrl.ni.wToZEn = GL_TRUE;
+ if (imesa->float_depth) {
+ imesa->regs.s4.zBufCtrl.ni.zExpOffset =
+ imesa->savageScreen->zpp == 2 ? 16 : 32;
+ imesa->regs.s4.zBufCtrl.ni.floatZEn = GL_TRUE;
+ } else {
+ imesa->regs.s4.zBufCtrl.ni.zExpOffset = 0;
+ imesa->regs.s4.zBufCtrl.ni.floatZEn = GL_FALSE;
+ }
+ imesa->regs.s4.texBlendCtrl[0].ui = TBC_NoTexMap;
+ imesa->regs.s4.texBlendCtrl[1].ui = TBC_NoTexMap1;
+ imesa->regs.s4.drawCtrl0.ui = 0;
+#if 0
+ imesa->regs.s4.drawCtrl1.ni.xyOffsetEn = 1;
+#endif
+
+ /* Set DestTexWatermarks_31,30 to 01 always.
+ *Has no effect if dest. flush is disabled.
+ */
+#if 0
+ imesa->regs.s4.zWatermarks.ui = 0x12000C04;
+ imesa->regs.s4.destTexWatermarks.ui = 0x40200400;
+#else
+ /*imesa->regs.s4.zWatermarks.ui = 0x16001808;*/
+ imesa->regs.s4.zWatermarks.ni.rLow = S4_ZRLO;
+ imesa->regs.s4.zWatermarks.ni.rHigh = S4_ZRHI;
+ imesa->regs.s4.zWatermarks.ni.wLow = S4_ZWLO;
+ imesa->regs.s4.zWatermarks.ni.wHigh = S4_ZWHI;
+ /*imesa->regs.s4.destTexWatermarks.ui = 0x4f000000;*/
+ imesa->regs.s4.destTexWatermarks.ni.destReadLow = S4_DRLO;
+ imesa->regs.s4.destTexWatermarks.ni.destReadHigh = S4_DRHI;
+ imesa->regs.s4.destTexWatermarks.ni.destWriteLow = S4_DWLO;
+ imesa->regs.s4.destTexWatermarks.ni.destWriteHigh = S4_DWHI;
+ imesa->regs.s4.destTexWatermarks.ni.texRead = S4_TR;
+ imesa->regs.s4.destTexWatermarks.ni.destFlush = 1;
+#endif
+ imesa->regs.s4.drawCtrl0.ni.dPerfAccelEn = GL_TRUE;
+
+ /* clrCmpAlphaBlendCtrl is needed to get alphatest and
+ * alpha blending working properly
+ */
+
+ imesa->regs.s4.texCtrl[0].ni.dBias = 0x08;
+ imesa->regs.s4.texCtrl[1].ni.dBias = 0x08;
+ imesa->regs.s4.texCtrl[0].ni.texXprEn = GL_TRUE;
+ imesa->regs.s4.texCtrl[1].ni.texXprEn = GL_TRUE;
+ imesa->regs.s4.texCtrl[0].ni.dMax = 0x0f;
+ imesa->regs.s4.texCtrl[1].ni.dMax = 0x0f;
+ /* programm a valid tex address, in case texture state is emitted
+ * in wrong order. */
+ if (imesa->lastTexHeap == 2 && imesa->savageScreen->textureSize[1]) {
+ /* AGP textures available */
+ imesa->regs.s4.texAddr[0].ui = imesa->savageScreen->textureOffset[1]|3;
+ imesa->regs.s4.texAddr[1].ui = imesa->savageScreen->textureOffset[1]|3;
+ } else {
+ /* no AGP textures available, use local */
+ imesa->regs.s4.texAddr[0].ui = imesa->savageScreen->textureOffset[0]|2;
+ imesa->regs.s4.texAddr[1].ui = imesa->savageScreen->textureOffset[0]|2;
+ }
+ imesa->regs.s4.drawLocalCtrl.ni.drawUpdateEn = GL_TRUE;
+ imesa->regs.s4.drawLocalCtrl.ni.srcAlphaMode = SAM_One;
+ imesa->regs.s4.drawLocalCtrl.ni.wrZafterAlphaTst = GL_FALSE;
+ imesa->regs.s4.drawLocalCtrl.ni.flushPdZbufWrites= GL_TRUE;
+ imesa->regs.s4.drawLocalCtrl.ni.flushPdDestWrites= GL_TRUE;
+
+ imesa->regs.s4.drawLocalCtrl.ni.zUpdateEn= GL_TRUE;
+ imesa->regs.s4.drawCtrl1.ni.ditherEn = (
+ driQueryOptioni(&imesa->optionCache, "color_reduction") ==
+ DRI_CONF_COLOR_REDUCTION_DITHER) ? GL_TRUE : GL_FALSE;
+ imesa->regs.s4.drawCtrl1.ni.cullMode = BCM_None;
+
+ imesa->regs.s4.zBufCtrl.ni.stencilRefVal = 0x00;
+
+ imesa->regs.s4.stencilCtrl.ni.stencilEn = GL_FALSE;
+ imesa->regs.s4.stencilCtrl.ni.cmpFunc = CF_Always;
+ imesa->regs.s4.stencilCtrl.ni.failOp = STENCIL_Keep;
+ imesa->regs.s4.stencilCtrl.ni.passZfailOp = STENCIL_Keep;
+ imesa->regs.s4.stencilCtrl.ni.passZpassOp = STENCIL_Keep;
+ imesa->regs.s4.stencilCtrl.ni.writeMask = 0xff;
+ imesa->regs.s4.stencilCtrl.ni.readMask = 0xff;
+
+ imesa->LcsCullMode=BCM_None;
+ imesa->regs.s4.texDescr.ni.palSize = TPS_256;
+
+ /* clear the local registers in the global reg mask */
+ imesa->globalRegMask.s4.drawLocalCtrl.ui = 0;
+ imesa->globalRegMask.s4.texPalAddr.ui = 0;
+ imesa->globalRegMask.s4.texCtrl[0].ui = 0;
+ imesa->globalRegMask.s4.texCtrl[1].ui = 0;
+ imesa->globalRegMask.s4.texAddr[0].ui = 0;
+ imesa->globalRegMask.s4.texAddr[1].ui = 0;
+ imesa->globalRegMask.s4.texBlendCtrl[0].ui = 0;
+ imesa->globalRegMask.s4.texBlendCtrl[1].ui = 0;
+ imesa->globalRegMask.s4.texXprClr.ui = 0;
+ imesa->globalRegMask.s4.texDescr.ui = 0;
+}
+static void savageDDInitState_s3d( savageContextPtr imesa )
+{
+#if 1
+ imesa->regs.s3d.destCtrl.ui = 1<<7;
+#endif
+
+ imesa->regs.s3d.zBufCtrl.ni.zCmpFunc = CF_Less;
+#if 0
+ imesa->regs.s3d.drawCtrl.ni.xyOffsetEn = 1;
+#endif
+
+ /* Set DestTexWatermarks_31,30 to 01 always.
+ *Has no effect if dest. flush is disabled.
+ */
+#if 0
+ imesa->regs.s3d.zWatermarks.ui = 0x12000C04;
+ imesa->regs.s3d.destTexWatermarks.ui = 0x40200400;
+#else
+ /*imesa->regs.s3d.zWatermarks.ui = 0x16001808;*/
+ imesa->regs.s3d.zWatermarks.ni.rLow = S3D_ZRLO;
+ imesa->regs.s3d.zWatermarks.ni.rHigh = S3D_ZRHI;
+ imesa->regs.s3d.zWatermarks.ni.wLow = S3D_ZWLO;
+ imesa->regs.s3d.zWatermarks.ni.wHigh = S3D_ZWHI;
+ /*imesa->regs.s3d.destTexWatermarks.ui = 0x4f000000;*/
+ imesa->regs.s3d.destTexWatermarks.ni.destReadLow = S3D_DRLO;
+ imesa->regs.s3d.destTexWatermarks.ni.destReadHigh = S3D_DRHI;
+ imesa->regs.s3d.destTexWatermarks.ni.destWriteLow = S3D_DWLO;
+ imesa->regs.s3d.destTexWatermarks.ni.destWriteHigh = S3D_DWHI;
+ imesa->regs.s3d.destTexWatermarks.ni.texRead = S3D_TR;
+ imesa->regs.s3d.destTexWatermarks.ni.destFlush = 1;
+#endif
+
+ imesa->regs.s3d.texCtrl.ni.dBias = 0x08;
+ imesa->regs.s3d.texCtrl.ni.texXprEn = GL_TRUE;
+ /* texXprEn is needed to get alphatest and alpha blending working
+ * properly. However, this makes texels with color texXprClr
+ * completely transparent in some texture environment modes. I
+ * couldn't find a way to disable this. So choose an arbitrary and
+ * improbable color. (0 is a bad choice, makes all black texels
+ * transparent.) */
+ imesa->regs.s3d.texXprClr.ui = 0x26ae26ae;
+ /* programm a valid tex address, in case texture state is emitted
+ * in wrong order. */
+ if (imesa->lastTexHeap == 2 && imesa->savageScreen->textureSize[1]) {
+ /* AGP textures available */
+ imesa->regs.s3d.texAddr.ui = imesa->savageScreen->textureOffset[1]|3;
+ } else {
+ /* no AGP textures available, use local */
+ imesa->regs.s3d.texAddr.ui = imesa->savageScreen->textureOffset[0]|2;
+ }
+
+ imesa->regs.s3d.zBufCtrl.ni.drawUpdateEn = GL_TRUE;
+ imesa->regs.s3d.zBufCtrl.ni.wrZafterAlphaTst = GL_FALSE;
+ imesa->regs.s3d.zBufCtrl.ni.zUpdateEn = GL_TRUE;
+
+ imesa->regs.s3d.drawCtrl.ni.srcAlphaMode = SAM_One;
+ imesa->regs.s3d.drawCtrl.ni.flushPdZbufWrites = GL_TRUE;
+ imesa->regs.s3d.drawCtrl.ni.flushPdDestWrites = GL_TRUE;
+
+ imesa->regs.s3d.drawCtrl.ni.ditherEn = (
+ driQueryOptioni(&imesa->optionCache, "color_reduction") ==
+ DRI_CONF_COLOR_REDUCTION_DITHER) ? GL_TRUE : GL_FALSE;
+ imesa->regs.s3d.drawCtrl.ni.cullMode = BCM_None;
+
+ imesa->LcsCullMode = BCM_None;
+ imesa->regs.s3d.texDescr.ni.palSize = TPS_256;
+
+ /* clear the local registers in the global reg mask */
+ imesa->globalRegMask.s3d.texPalAddr.ui = 0;
+ imesa->globalRegMask.s3d.texXprClr.ui = 0;
+ imesa->globalRegMask.s3d.texAddr.ui = 0;
+ imesa->globalRegMask.s3d.texDescr.ui = 0;
+ imesa->globalRegMask.s3d.texCtrl.ui = 0;
+
+ imesa->globalRegMask.s3d.fogCtrl.ui = 0;
+
+ /* drawCtrl is local with some exceptions */
+ imesa->globalRegMask.s3d.drawCtrl.ui = 0;
+ imesa->globalRegMask.s3d.drawCtrl.ni.cullMode = 0x3;
+ imesa->globalRegMask.s3d.drawCtrl.ni.alphaTestCmpFunc = 0x7;
+ imesa->globalRegMask.s3d.drawCtrl.ni.alphaTestEn = 0x1;
+ imesa->globalRegMask.s3d.drawCtrl.ni.alphaRefVal = 0xff;
+
+ /* zBufCtrl is local with some exceptions */
+ imesa->globalRegMask.s3d.zBufCtrl.ui = 0;
+ imesa->globalRegMask.s3d.zBufCtrl.ni.zCmpFunc = 0x7;
+ imesa->globalRegMask.s3d.zBufCtrl.ni.zBufEn = 0x1;
+}
+void savageDDInitState( savageContextPtr imesa ) {
+ memset (imesa->regs.ui, 0, SAVAGE_NR_REGS*sizeof(u_int32_t));
+ memset (imesa->globalRegMask.ui, 0xff, SAVAGE_NR_REGS*sizeof(u_int32_t));
+ if (imesa->savageScreen->chipset >= S3_SAVAGE4)
+ savageDDInitState_s4 (imesa);
+ else
+ savageDDInitState_s3d (imesa);
+
+ /*fprintf(stderr,"DBflag:%d\n",imesa->glCtx->Visual->DBflag);*/
+ /* zbufoffset and destctrl have the same position and layout on
+ * savage4 and savage3d. */
+ if (imesa->glCtx->Visual.doubleBufferMode) {
+ imesa->IsDouble = GL_TRUE;
+ imesa->toggle = TARGET_BACK;
+ imesa->regs.s4.destCtrl.ni.offset =
+ imesa->savageScreen->backOffset>>11;
+ } else {
+ imesa->IsDouble = GL_FALSE;
+ imesa->toggle = TARGET_FRONT;
+ imesa->regs.s4.destCtrl.ni.offset =
+ imesa->savageScreen->frontOffset>>11;
+ }
+ if(imesa->savageScreen->cpp == 2) {
+ imesa->regs.s4.destCtrl.ni.dstPixFmt = 0;
+ imesa->regs.s4.destCtrl.ni.dstWidthInTile =
+ (imesa->savageScreen->width+63)>>6;
+ } else {
+ imesa->regs.s4.destCtrl.ni.dstPixFmt = 1;
+ imesa->regs.s4.destCtrl.ni.dstWidthInTile =
+ (imesa->savageScreen->width+31)>>5;
+ }
+ imesa->drawMap = imesa->apertureBase[imesa->toggle];
+ imesa->readMap = imesa->apertureBase[imesa->toggle];
+ imesa->NotFirstFrame = GL_FALSE;
+
+ imesa->regs.s4.zBufOffset.ni.offset=imesa->savageScreen->depthOffset>>11;
+ if(imesa->savageScreen->zpp == 2) {
+ imesa->regs.s4.zBufOffset.ni.zBufWidthInTiles =
+ (imesa->savageScreen->width+63)>>6;
+ imesa->regs.s4.zBufOffset.ni.zDepthSelect = 0;
+ } else {
+ imesa->regs.s4.zBufOffset.ni.zBufWidthInTiles =
+ (imesa->savageScreen->width+31)>>5;
+ imesa->regs.s4.zBufOffset.ni.zDepthSelect = 1;
+ }
+
+ memcpy (imesa->oldRegs.ui, imesa->regs.ui, SAVAGE_NR_REGS*sizeof(u_int32_t));
+
+ /* Emit the initial state to the (empty) command buffer. */
+ assert (imesa->cmdBuf.write == imesa->cmdBuf.base);
+ savageEmitOldState(imesa);
+ imesa->cmdBuf.start = imesa->cmdBuf.write;
+}
+
+
+#define INTERESTED (~(NEW_MODELVIEW|NEW_PROJECTION|\
+ NEW_TEXTURE_MATRIX|\
+ NEW_USER_CLIP|NEW_CLIENT_STATE))
+
+static void savageDDInvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ SAVAGE_CONTEXT(ctx)->new_gl_state |= new_state;
+}
+
+
+void savageDDInitStateFuncs(GLcontext *ctx)
+{
+ ctx->Driver.UpdateState = savageDDInvalidateState;
+ ctx->Driver.BlendEquationSeparate = savageDDBlendEquationSeparate;
+ ctx->Driver.Fogfv = savageDDFogfv;
+ ctx->Driver.Scissor = savageDDScissor;
+#if HW_CULL
+ ctx->Driver.CullFace = savageDDCullFaceFrontFace;
+ ctx->Driver.FrontFace = savageDDCullFaceFrontFace;
+#else
+ ctx->Driver.CullFace = 0;
+ ctx->Driver.FrontFace = 0;
+#endif /* end #if HW_CULL */
+ ctx->Driver.PolygonMode=NULL;
+ ctx->Driver.PolygonStipple = 0;
+ ctx->Driver.LineStipple = 0;
+ ctx->Driver.LineWidth = 0;
+ ctx->Driver.LogicOpcode = 0;
+ ctx->Driver.DrawBuffer = savageDDDrawBuffer;
+ ctx->Driver.ReadBuffer = savageDDReadBuffer;
+ ctx->Driver.ClearColor = savageDDClearColor;
+
+ ctx->Driver.DepthRange = savageDepthRange;
+ ctx->Driver.Viewport = savageViewport;
+ ctx->Driver.RenderMode = savageRenderMode;
+
+ ctx->Driver.ClearIndex = 0;
+ ctx->Driver.IndexMask = 0;
+
+ if (SAVAGE_CONTEXT( ctx )->savageScreen->chipset >= S3_SAVAGE4) {
+ ctx->Driver.Enable = savageDDEnable_s4;
+ ctx->Driver.AlphaFunc = savageDDAlphaFunc_s4;
+ ctx->Driver.DepthFunc = savageDDDepthFunc_s4;
+ ctx->Driver.DepthMask = savageDDDepthMask_s4;
+ ctx->Driver.BlendFuncSeparate = savageDDBlendFuncSeparate_s4;
+ ctx->Driver.ColorMask = savageDDColorMask_s4;
+ ctx->Driver.ShadeModel = savageDDShadeModel_s4;
+ ctx->Driver.LightModelfv = savageDDLightModelfv_s4;
+ ctx->Driver.StencilFunc = savageDDStencilFunc;
+ ctx->Driver.StencilMask = savageDDStencilMask;
+ ctx->Driver.StencilOp = savageDDStencilOp;
+ } else {
+ ctx->Driver.Enable = savageDDEnable_s3d;
+ ctx->Driver.AlphaFunc = savageDDAlphaFunc_s3d;
+ ctx->Driver.DepthFunc = savageDDDepthFunc_s3d;
+ ctx->Driver.DepthMask = savageDDDepthMask_s3d;
+ ctx->Driver.BlendFuncSeparate = savageDDBlendFuncSeparate_s3d;
+ ctx->Driver.ColorMask = savageDDColorMask_s3d;
+ ctx->Driver.ShadeModel = savageDDShadeModel_s3d;
+ ctx->Driver.LightModelfv = savageDDLightModelfv_s3d;
+ ctx->Driver.StencilFunc = 0;
+ ctx->Driver.StencilMask = 0;
+ ctx->Driver.StencilOp = 0;
+ }
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagestate.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagestate.h
new file mode 100644
index 000000000..5fe718d7a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagestate.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+#ifndef _SAVAGE_STATE_H
+#define _SAVAGE_STATE_H
+
+#include "savagecontext.h"
+
+void savageCalcViewport( GLcontext *ctx );
+void savageEmitOldState( savageContextPtr imesa );
+void savageEmitChangedState( savageContextPtr imesa );
+
+extern void savageDDUpdateHwState( GLcontext *ctx );
+extern void savageDDInitState( savageContextPtr imesa );
+extern void savageDDInitStateFuncs( GLcontext *ctx );
+extern void savageDDRenderStart(GLcontext *ctx);
+extern void savageDDRenderEnd(GLcontext *ctx);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagetex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagetex.c
new file mode 100644
index 000000000..ce9d1def8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagetex.c
@@ -0,0 +1,2133 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <GL/gl.h>
+
+#include "mm.h"
+#include "savagecontext.h"
+#include "savagetex.h"
+#include "savagetris.h"
+#include "savageioctl.h"
+#include "simple_list.h"
+#include "enums.h"
+#include "savage_bci.h"
+
+#include "macros.h"
+#include "texformat.h"
+#include "texstore.h"
+#include "texobj.h"
+
+#include "convolve.h"
+#include "colormac.h"
+
+#include "swrast/swrast.h"
+
+#include "xmlpool.h"
+
+#define TILE_INDEX_DXT1 0
+#define TILE_INDEX_8 1
+#define TILE_INDEX_16 2
+#define TILE_INDEX_DXTn 3
+#define TILE_INDEX_32 4
+
+/* On Savage4 the texure LOD-bias needs an offset of ~ 0.3 to get
+ * somewhere close to software rendering.
+ */
+#define SAVAGE4_LOD_OFFSET 10
+
+/* Tile info for S3TC formats counts in 4x4 blocks instead of texels.
+ * In DXT1 each block is encoded in 64 bits. In DXT3 and 5 each block is
+ * encoded in 128 bits. */
+
+/* Size 1, 2 and 4 images are packed into the last subtile. Each image
+ * is repeated to fill a 4x4 pixel area. The figure below shows the
+ * layout of those 4x4 pixel areas in the 8x8 subtile.
+ *
+ * 4 2
+ * x 1
+ *
+ * Yuck! 8-bit texture formats use 4x8 subtiles. See below.
+ */
+static const savageTileInfo tileInfo_pro[5] = {
+ {16, 16, 16, 8, 1, 2, {0x18, 0x10}}, /* DXT1 */
+ {64, 32, 16, 4, 4, 8, {0x30, 0x20}}, /* 8-bit */
+ {64, 16, 8, 2, 8, 8, {0x48, 0x08}}, /* 16-bit */
+ {16, 8, 16, 4, 1, 2, {0x30, 0x20}}, /* DXT3, DXT5 */
+ {32, 16, 4, 2, 8, 8, {0x90, 0x10}}, /* 32-bit */
+};
+
+/* Size 1, 2 and 4 images are packed into the last two subtiles. Each
+ * image is repeated to fill a 4x4 pixel area. The figures below show
+ * the layout of those 4x4 pixel areas in the two 4x8 subtiles.
+ *
+ * second last subtile: 4 last subtile: 2
+ * x 1
+ */
+static const savageTileInfo tileInfo_s3d_s4[5] = {
+ {16, 16, 16, 8, 1, 2, {0x18, 0x10}}, /* DXT1 */
+ {64, 32, 16, 4, 4, 8, {0x30, 0x20}}, /* 8-bit */
+ {64, 16, 16, 2, 4, 8, {0x60, 0x40}}, /* 16-bit */
+ {16, 8, 16, 4, 1, 2, {0x30, 0x20}}, /* DXT3, DXT5 */
+ {32, 16, 8, 2, 4, 8, {0xc0, 0x80}}, /* 32-bit */
+};
+
+/** \brief Template for subtile uploads.
+ * \param h height in pixels
+ * \param w width in bytes
+ */
+#define SUBTILE_FUNC(w,h) \
+static __inline GLubyte *savageUploadSubtile_##w##x##h \
+(GLubyte *dest, GLubyte *src, GLuint srcStride) \
+{ \
+ GLuint y; \
+ for (y = 0; y < h; ++y) { \
+ memcpy (dest, src, w); \
+ src += srcStride; \
+ dest += w; \
+ } \
+ return dest; \
+}
+
+SUBTILE_FUNC(2, 8) /* 4 bits per pixel, 4 pixels wide */
+SUBTILE_FUNC(4, 8)
+SUBTILE_FUNC(8, 8)
+SUBTILE_FUNC(16, 8)
+SUBTILE_FUNC(32, 8) /* 4 bytes per pixel, 8 pixels wide */
+
+SUBTILE_FUNC(8, 2) /* DXT1 */
+SUBTILE_FUNC(16, 2) /* DXT3 and DXT5 */
+
+/** \brief Upload a complete tile from src (srcStride) to dest
+ *
+ * \param tileInfo Pointer to tiling information
+ * \param wInSub Width of source/dest image in subtiles
+ * \param hInSub Height of source/dest image in subtiles
+ * \param bpp Bytes per pixel
+ * \param src Pointer to source data
+ * \param srcStride Byte stride of rows in the source data
+ * \param dest Pointer to destination
+ *
+ * Writes linearly to the destination memory in order to exploit write
+ * combining.
+ *
+ * For a complete tile wInSub and hInSub are set to the same values as
+ * in tileInfo. If the source image is smaller than a whole tile in
+ * one or both dimensions then they are set to the values of the
+ * source image. This only works as long as the source image is bigger
+ * than 8x8 pixels.
+ */
+static void savageUploadTile (const savageTileInfo *tileInfo,
+ GLuint wInSub, GLuint hInSub, GLuint bpp,
+ GLubyte *src, GLuint srcStride, GLubyte *dest) {
+ GLuint subStride = tileInfo->subWidth * bpp;
+ GLubyte *srcSRow = src, *srcSTile = src;
+ GLubyte *(*subtileFunc) (GLubyte *, GLubyte *, GLuint);
+ GLuint sx, sy;
+ switch (subStride) {
+ case 2: subtileFunc = savageUploadSubtile_2x8; break;
+ case 4: subtileFunc = savageUploadSubtile_4x8; break;
+ case 8: subtileFunc = tileInfo->subHeight == 8 ?
+ savageUploadSubtile_8x8 : savageUploadSubtile_8x2; break;
+ case 16: subtileFunc = tileInfo->subHeight == 8 ?
+ savageUploadSubtile_16x8 : savageUploadSubtile_16x2; break;
+ case 32: subtileFunc = savageUploadSubtile_32x8; break;
+ default: assert(0);
+ }
+ for (sy = 0; sy < hInSub; ++sy) {
+ srcSTile = srcSRow;
+ for (sx = 0; sx < wInSub; ++sx) {
+ src = srcSTile;
+ dest = subtileFunc (dest, src, srcStride);
+ srcSTile += subStride;
+ }
+ srcSRow += srcStride * tileInfo->subHeight;
+ }
+}
+
+/** \brief Upload a image that is smaller than 8 pixels in either dimension.
+ *
+ * \param tileInfo Pointer to tiling information
+ * \param width Width of the image
+ * \param height Height of the image
+ * \param bpp Bytes per pixel
+ * \param src Pointer to source data
+ * \param dest Pointer to destination
+ *
+ * This function handles all the special cases that need to be taken
+ * care off. The caller may need to call this function multiple times
+ * with the destination offset in different ways since small texture
+ * images must be repeated in order to fill a whole tile (or 4x4 for
+ * the last 3 levels).
+ *
+ * FIXME: Repeating inside this function would be more efficient.
+ */
+static void savageUploadTiny (const savageTileInfo *tileInfo,
+ GLuint pixWidth, GLuint pixHeight,
+ GLuint width, GLuint height, GLuint bpp,
+ GLubyte *src, GLubyte *dest) {
+ GLuint size = MAX2(pixWidth, pixHeight);
+
+ if (width > tileInfo->subWidth) { /* assert: height <= subtile height */
+ GLuint wInSub = width / tileInfo->subWidth;
+ GLuint srcStride = width * bpp;
+ GLuint subStride = tileInfo->subWidth * bpp;
+ GLuint subSkip = (tileInfo->subHeight - height) * subStride;
+ GLubyte *srcSTile = src;
+ GLuint sx, y;
+ for (sx = 0; sx < wInSub; ++sx) {
+ src = srcSTile;
+ for (y = 0; y < height; ++y) {
+ memcpy (dest, src, subStride);
+ src += srcStride;
+ dest += subStride;
+ }
+ dest += subSkip;
+ srcSTile += subStride;
+ }
+ } else if (size > 4) { /* a tile or less wide, except the last 3 levels */
+ GLuint srcStride = width * bpp;
+ GLuint subStride = tileInfo->subWidth * bpp;
+ /* if the subtile width is 4 we have to skip every other subtile */
+ GLuint subSkip = tileInfo->subWidth <= 4 ?
+ subStride * tileInfo->subHeight : 0;
+ GLuint skipRemainder = tileInfo->subHeight - 1;
+ GLuint y;
+ for (y = 0; y < height; ++y) {
+ memcpy (dest, src, srcStride);
+ src += srcStride;
+ dest += subStride;
+ if ((y & skipRemainder) == skipRemainder)
+ dest += subSkip;
+ }
+ } else { /* the last 3 mipmap levels */
+ GLuint offset = (size <= 2 ? tileInfo->tinyOffset[size-1] : 0);
+ GLuint subStride = tileInfo->subWidth * bpp;
+ GLuint y;
+ dest += offset;
+ for (y = 0; y < height; ++y) {
+ memcpy (dest, src, bpp*width);
+ src += width * bpp;
+ dest += subStride;
+ }
+ }
+}
+
+/** \brief Upload an image from mesa's internal copy.
+ */
+static void savageUploadTexLevel( savageTexObjPtr t, int level )
+{
+ const struct gl_texture_image *image = t->base.tObj->Image[0][level];
+ const savageTileInfo *tileInfo = t->tileInfo;
+ GLuint pixWidth = image->Width2, pixHeight = image->Height2;
+ GLuint bpp = t->texelBytes;
+ GLuint width, height;
+
+ /* FIXME: Need triangle (rather than pixel) fallbacks to simulate
+ * this using normal textured triangles.
+ *
+ * DO THIS IN DRIVER STATE MANAGMENT, not hardware state.
+ */
+ if(image->Border != 0)
+ fprintf (stderr, "Not supported texture border %d.\n",
+ (int) image->Border);
+
+ if (t->hwFormat == TFT_S3TC4A4Bit || t->hwFormat == TFT_S3TC4CA4Bit ||
+ t->hwFormat == TFT_S3TC4Bit) {
+ width = (pixWidth+3) / 4;
+ height = (pixHeight+3) / 4;
+ } else {
+ width = pixWidth;
+ height = pixHeight;
+ }
+
+ if (pixWidth >= 8 && pixHeight >= 8) {
+ GLuint *dirtyPtr = t->image[level].dirtyTiles;
+ GLuint dirtyMask = 1;
+
+ if (width >= tileInfo->width && height >= tileInfo->height) {
+ GLuint wInTiles = width / tileInfo->width;
+ GLuint hInTiles = height / tileInfo->height;
+ GLubyte *srcTRow = image->Data, *src;
+ GLubyte *dest = (GLubyte *)(t->bufAddr + t->image[level].offset);
+ GLuint x, y;
+ for (y = 0; y < hInTiles; ++y) {
+ src = srcTRow;
+ for (x = 0; x < wInTiles; ++x) {
+ if (*dirtyPtr & dirtyMask) {
+ savageUploadTile (tileInfo,
+ tileInfo->wInSub, tileInfo->hInSub,
+ bpp, src, width * bpp, dest);
+ }
+ src += tileInfo->width * bpp;
+ dest += 2048; /* tile size is always 2k */
+ if (dirtyMask == 1<<31) {
+ dirtyMask = 1;
+ dirtyPtr++;
+ } else
+ dirtyMask <<= 1;
+ }
+ srcTRow += width * tileInfo->height * bpp;
+ }
+ } else if (width >= tileInfo->width) {
+ GLuint wInTiles = width / tileInfo->width;
+ GLubyte *src = image->Data;
+ GLubyte *dest = (GLubyte *)(t->bufAddr + t->image[level].offset);
+ GLuint tileStride = tileInfo->width * bpp * height;
+ savageContextPtr imesa = (savageContextPtr)t->base.heap->driverContext;
+ GLuint x;
+ /* Savage3D-based chips seem so use a constant tile stride
+ * of 2048 for vertically incomplete tiles, but only if
+ * the color depth is 32bpp. Nobody said this was supposed
+ * to be logical!
+ */
+ if (bpp == 4 && imesa->savageScreen->chipset < S3_SAVAGE4)
+ tileStride = 2048;
+ for (x = 0; x < wInTiles; ++x) {
+ if (*dirtyPtr & dirtyMask) {
+ savageUploadTile (tileInfo,
+ tileInfo->wInSub,
+ height / tileInfo->subHeight,
+ bpp, src, width * bpp, dest);
+ }
+ src += tileInfo->width * bpp;
+ dest += tileStride;
+ if (dirtyMask == 1<<31) {
+ dirtyMask = 1;
+ dirtyPtr++;
+ } else
+ dirtyMask <<= 1;
+ }
+ } else {
+ savageUploadTile (tileInfo, width / tileInfo->subWidth,
+ height / tileInfo->subHeight, bpp,
+ image->Data, width * bpp,
+ (GLubyte *)(t->bufAddr+t->image[level].offset));
+ }
+ } else {
+ GLuint minHeight, minWidth, hRepeat, vRepeat, x, y;
+ if (t->hwFormat == TFT_S3TC4A4Bit || t->hwFormat == TFT_S3TC4CA4Bit ||
+ t->hwFormat == TFT_S3TC4Bit)
+ minWidth = minHeight = 1;
+ else
+ minWidth = minHeight = 4;
+ if (width > minWidth || height > minHeight) {
+ minWidth = tileInfo->subWidth;
+ minHeight = tileInfo->subHeight;
+ }
+ hRepeat = width >= minWidth ? 1 : minWidth / width;
+ vRepeat = height >= minHeight ? 1 : minHeight / height;
+ for (y = 0; y < vRepeat; ++y) {
+ GLuint offset = y * tileInfo->subWidth*height * bpp;
+ for (x = 0; x < hRepeat; ++x) {
+ savageUploadTiny (tileInfo, pixWidth, pixHeight,
+ width, height, bpp, image->Data,
+ (GLubyte *)(t->bufAddr +
+ t->image[level].offset+offset));
+ offset += width * bpp;
+ }
+ }
+ }
+}
+
+/** \brief Compute the destination size of a texture image
+ */
+static GLuint savageTexImageSize (GLuint width, GLuint height, GLuint bpp) {
+ /* full subtiles */
+ if (width >= 8 && height >= 8)
+ return width * height * bpp;
+ /* special case for the last three mipmap levels: the hardware computes
+ * the offset internally */
+ else if (width <= 4 && height <= 4)
+ return 0;
+ /* partially filled sub tiles waste memory
+ * on Savage3D and Savage4 with subtile width 4 every other subtile is
+ * skipped if width < 8 so we can assume a uniform subtile width of 8 */
+ else if (width >= 8)
+ return width * 8 * bpp;
+ else if (height >= 8)
+ return 8 * height * bpp;
+ else
+ return 64 * bpp;
+}
+
+/** \brief Compute the destination size of a compressed texture image
+ */
+static GLuint savageCompressedTexImageSize (GLuint width, GLuint height,
+ GLuint bpp) {
+ width = (width+3) / 4;
+ height = (height+3) / 4;
+ /* full subtiles */
+ if (width >= 2 && height >= 2)
+ return width * height * bpp;
+ /* special case for the last three mipmap levels: the hardware computes
+ * the offset internally */
+ else if (width <= 1 && height <= 1)
+ return 0;
+ /* partially filled sub tiles waste memory
+ * on Savage3D and Savage4 with subtile width 4 every other subtile is
+ * skipped if width < 8 so we can assume a uniform subtile width of 8 */
+ else if (width >= 2)
+ return width * 2 * bpp;
+ else if (height >= 2)
+ return 2 * height * bpp;
+ else
+ return 4 * bpp;
+}
+
+/** \brief Compute the number of (partial) tiles of a texture image
+ */
+static GLuint savageTexImageTiles (GLuint width, GLuint height,
+ const savageTileInfo *tileInfo)
+{
+ return (width + tileInfo->width - 1) / tileInfo->width *
+ (height + tileInfo->height - 1) / tileInfo->height;
+}
+
+/** \brief Mark dirty tiles
+ *
+ * Some care must be taken because tileInfo may not be set or not
+ * up-to-date. So we check if tileInfo is initialized and if the number
+ * of tiles in the bit vector matches the number of tiles computed from
+ * the current tileInfo.
+ */
+static void savageMarkDirtyTiles (savageTexObjPtr t, GLuint level,
+ GLuint totalWidth, GLuint totalHeight,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height)
+{
+ GLuint wInTiles, hInTiles;
+ GLuint x0, y0, x1, y1;
+ GLuint x, y;
+ if (!t->tileInfo)
+ return;
+ wInTiles = (totalWidth + t->tileInfo->width - 1) / t->tileInfo->width;
+ hInTiles = (totalHeight + t->tileInfo->height - 1) / t->tileInfo->height;
+ if (wInTiles * hInTiles != t->image[level].nTiles)
+ return;
+
+ x0 = xoffset / t->tileInfo->width;
+ y0 = yoffset / t->tileInfo->height;
+ x1 = (xoffset + width - 1) / t->tileInfo->width;
+ y1 = (yoffset + height - 1) / t->tileInfo->height;
+
+ for (y = y0; y <= y1; ++y) {
+ GLuint *ptr = t->image[level].dirtyTiles + (y * wInTiles + x0) / 32;
+ GLuint mask = 1 << (y * wInTiles + x0) % 32;
+ for (x = x0; x <= x1; ++x) {
+ *ptr |= mask;
+ if (mask == (1<<31)) {
+ ptr++;
+ mask = 1;
+ } else {
+ mask <<= 1;
+ }
+ }
+ }
+}
+
+/** \brief Mark all tiles as dirty
+ */
+static void savageMarkAllTiles (savageTexObjPtr t, GLuint level)
+{
+ GLuint words = (t->image[level].nTiles + 31) / 32;
+ if (words)
+ memset(t->image[level].dirtyTiles, ~0, words*sizeof(GLuint));
+}
+
+
+static void savageSetTexWrapping(savageTexObjPtr tex, GLenum s, GLenum t)
+{
+ tex->setup.sWrapMode = s;
+ tex->setup.tWrapMode = t;
+}
+
+static void savageSetTexFilter(savageTexObjPtr t, GLenum minf, GLenum magf)
+{
+ t->setup.minFilter = minf;
+ t->setup.magFilter = magf;
+}
+
+
+/* Need a fallback ?
+ */
+static void savageSetTexBorderColor(savageTexObjPtr t, GLubyte color[4])
+{
+/* t->Setup[SAVAGE_TEXREG_TEXBORDERCOL] = */
+ /*t->setup.borderColor = SAVAGEPACKCOLOR8888(color[0],color[1],color[2],color[3]); */
+}
+
+
+
+static savageTexObjPtr
+savageAllocTexObj( struct gl_texture_object *texObj )
+{
+ savageTexObjPtr t;
+
+ t = (savageTexObjPtr) calloc(1,sizeof(*t));
+ texObj->DriverData = t;
+ if ( t != NULL ) {
+ GLuint i;
+
+ /* Initialize non-image-dependent parts of the state:
+ */
+ t->base.tObj = texObj;
+ t->base.dirty_images[0] = 0;
+ t->dirtySubImages = 0;
+ t->tileInfo = NULL;
+
+ /* Initialize dirty tiles bit vectors
+ */
+ for (i = 0; i < SAVAGE_TEX_MAXLEVELS; ++i)
+ t->image[i].nTiles = 0;
+
+ /* FIXME Something here to set initial values for other parts of
+ * FIXME t->setup?
+ */
+
+ make_empty_list( &t->base );
+
+ savageSetTexWrapping(t,texObj->WrapS,texObj->WrapT);
+ savageSetTexFilter(t,texObj->MinFilter,texObj->MagFilter);
+ savageSetTexBorderColor(t,texObj->_BorderChan);
+ }
+
+ return t;
+}
+
+/* Mesa texture formats for alpha-images on Savage3D/IX/MX
+ *
+ * Promoting texture images to ARGB888 or ARGB4444 doesn't work
+ * because we can't tell the hardware to ignore the color components
+ * and only use the alpha component. So we define our own texture
+ * formats that promote to ARGB8888 or ARGB4444 and set the color
+ * components to white. This way we get the correct result. */
+static GLboolean
+_savage_texstore_a1114444 (GLcontext *ctx, GLuint dims,
+ GLenum baseInternalFormat,
+ const struct gl_texture_format *dstFormat,
+ GLvoid *dstAddr,
+ GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
+ GLint dstRowStride, GLint dstImageStride,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *srcAddr,
+ const struct gl_pixelstore_attrib *srcPacking);
+static GLboolean
+_savage_texstore_a1118888 (GLcontext *ctx, GLuint dims,
+ GLenum baseInternalFormat,
+ const struct gl_texture_format *dstFormat,
+ GLvoid *dstAddr,
+ GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
+ GLint dstRowStride, GLint dstImageStride,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *srcAddr,
+ const struct gl_pixelstore_attrib *srcPacking);
+
+static struct gl_texture_format _savage_texformat_a1114444 = {
+ MESA_FORMAT_ARGB4444, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 4, /* RedBits */
+ 4, /* GreenBits */
+ 4, /* BlueBits */
+ 4, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2, /* TexelBytes */
+ _savage_texstore_a1114444, /* StoreTexImageFunc */
+ NULL, NULL, NULL, NULL, NULL, NULL /* FetchTexel* filled in by
+ * savageDDInitTextureFuncs */
+};
+static struct gl_texture_format _savage_texformat_a1118888 = {
+ MESA_FORMAT_ARGB8888, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 8, /* RedBits */
+ 8, /* GreenBits */
+ 8, /* BlueBits */
+ 8, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 4, /* TexelBytes */
+ _savage_texstore_a1118888, /* StoreTexImageFunc */
+ NULL, NULL, NULL, NULL, NULL, NULL /* FetchTexel* filled in by
+ * savageDDInitTextureFuncs */
+};
+
+static GLboolean
+_savage_texstore_a1114444 (GLcontext *ctx, GLuint dims,
+ GLenum baseInternalFormat,
+ const struct gl_texture_format *dstFormat,
+ GLvoid *dstAddr,
+ GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
+ GLint dstRowStride, GLint dstImageStride,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *srcAddr,
+ const struct gl_pixelstore_attrib *srcPacking)
+{
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ baseInternalFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+
+ ASSERT(dstFormat == &_savage_texformat_a1114444);
+ ASSERT(baseInternalFormat == GL_ALPHA);
+
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLushort *dstUI = (GLushort *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ dstUI[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[0]),
+ 255, 255, 255 );
+ src += 1;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+
+ return GL_TRUE;
+}
+static GLboolean
+_savage_texstore_a1118888 (GLcontext *ctx, GLuint dims,
+ GLenum baseInternalFormat,
+ const struct gl_texture_format *dstFormat,
+ GLvoid *dstAddr,
+ GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
+ GLint dstRowStride, GLint dstImageStride,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *srcAddr,
+ const struct gl_pixelstore_attrib *srcPacking)
+{
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ baseInternalFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+
+ ASSERT(dstFormat == &_savage_texformat_a1118888);
+ ASSERT(baseInternalFormat == GL_ALPHA);
+
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLuint *dstUI = (GLuint *) dstRow;
+ for (col = 0; col < srcWidth; col++) {
+ dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[0]),
+ 255, 255, 255 );
+ src += 1;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+
+ return GL_TRUE;
+}
+
+/* Called by the _mesa_store_teximage[123]d() functions. */
+static const struct gl_texture_format *
+savageChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ const GLboolean do32bpt =
+ ( imesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_32 );
+ const GLboolean force16bpt =
+ ( imesa->texture_depth == DRI_CONF_TEXTURE_DEPTH_FORCE_16 );
+ const GLboolean isSavage4 = (imesa->savageScreen->chipset >= S3_SAVAGE4);
+ (void) format;
+
+ switch ( internalFormat ) {
+ case 4:
+ case GL_RGBA:
+ case GL_COMPRESSED_RGBA:
+ switch ( type ) {
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return &_mesa_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return &_mesa_texformat_argb1555;
+ default:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+ }
+
+ case 3:
+ case GL_RGB:
+ case GL_COMPRESSED_RGB:
+ switch ( type ) {
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return &_mesa_texformat_argb4444;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return &_mesa_texformat_argb1555;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ return &_mesa_texformat_rgb565;
+ default:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+ }
+
+ case GL_RGBA8:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return !force16bpt ?
+ &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+
+ case GL_RGB10_A2:
+ return !force16bpt ?
+ &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555;
+
+ case GL_RGBA4:
+ case GL_RGBA2:
+ return &_mesa_texformat_argb4444;
+
+ case GL_RGB5_A1:
+ return &_mesa_texformat_argb1555;
+
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ return !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+
+ case GL_RGB5:
+ case GL_RGB4:
+ case GL_R3_G3_B2:
+ return &_mesa_texformat_rgb565;
+
+ case GL_ALPHA:
+ case GL_COMPRESSED_ALPHA:
+ return isSavage4 ? &_mesa_texformat_a8 : (
+ do32bpt ? &_savage_texformat_a1118888 : &_savage_texformat_a1114444);
+ case GL_ALPHA4:
+ return isSavage4 ? &_mesa_texformat_a8 : &_savage_texformat_a1114444;
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ return isSavage4 ? &_mesa_texformat_a8 : (
+ !force16bpt ? &_savage_texformat_a1118888 : &_savage_texformat_a1114444);
+
+ case 1:
+ case GL_LUMINANCE:
+ case GL_COMPRESSED_LUMINANCE:
+ /* no alpha, but use argb1555 in 16bit case to get pure grey values */
+ return isSavage4 ? &_mesa_texformat_l8 : (
+ do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555);
+ case GL_LUMINANCE4:
+ return isSavage4 ? &_mesa_texformat_l8 : &_mesa_texformat_argb1555;
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ return isSavage4 ? &_mesa_texformat_l8 : (
+ !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb1555);
+
+ case 2:
+ case GL_LUMINANCE_ALPHA:
+ case GL_COMPRESSED_LUMINANCE_ALPHA:
+ /* Savage4 has a al44 texture format. But it's not supported by Mesa. */
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+ case GL_LUMINANCE4_ALPHA4:
+ case GL_LUMINANCE6_ALPHA2:
+ return &_mesa_texformat_argb4444;
+ case GL_LUMINANCE8_ALPHA8:
+ case GL_LUMINANCE12_ALPHA4:
+ case GL_LUMINANCE12_ALPHA12:
+ case GL_LUMINANCE16_ALPHA16:
+ return !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+#if 0
+ /* TFT_I8 produces garbage on ProSavageDDR and subsequent texture
+ * disable keeps rendering garbage. Disabled for now. */
+ case GL_INTENSITY:
+ case GL_COMPRESSED_INTENSITY:
+ return isSavage4 ? &_mesa_texformat_i8 : (
+ do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444);
+ case GL_INTENSITY4:
+ return isSavage4 ? &_mesa_texformat_i8 : &_mesa_texformat_argb4444;
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ return isSavage4 ? &_mesa_texformat_i8 : (
+ !force16bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444);
+#else
+ case GL_INTENSITY:
+ case GL_COMPRESSED_INTENSITY:
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+ case GL_INTENSITY4:
+ return &_mesa_texformat_argb4444;
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ return !force16bpt ? &_mesa_texformat_argb8888 :
+ &_mesa_texformat_argb4444;
+#endif
+
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgb_dxt1;
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgba_dxt1;
+
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ return &_mesa_texformat_rgba_dxt3;
+
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ if (!isSavage4)
+ /* Not the best choice but Savage3D/MX/IX don't support DXT3 or DXT5. */
+ return &_mesa_texformat_rgba_dxt1;
+ /* fall through */
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ return &_mesa_texformat_rgba_dxt5;
+
+/*
+ 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:
+ return &_mesa_texformat_ci8;
+*/
+ default:
+ _mesa_problem(ctx, "unexpected texture format in %s", __FUNCTION__);
+ return NULL;
+ }
+}
+
+static void savageSetTexImages( savageContextPtr imesa,
+ const struct gl_texture_object *tObj )
+{
+ savageTexObjPtr t = (savageTexObjPtr) tObj->DriverData;
+ struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ GLuint offset, i, textureFormat, tileIndex, size;
+ GLint firstLevel, lastLevel;
+
+ assert(t);
+ assert(image);
+
+ switch (image->TexFormat->MesaFormat) {
+ case MESA_FORMAT_ARGB8888:
+ textureFormat = TFT_ARGB8888;
+ t->texelBytes = tileIndex = 4;
+ break;
+ case MESA_FORMAT_ARGB1555:
+ textureFormat = TFT_ARGB1555;
+ t->texelBytes = tileIndex = 2;
+ break;
+ case MESA_FORMAT_ARGB4444:
+ textureFormat = TFT_ARGB4444;
+ t->texelBytes = tileIndex = 2;
+ break;
+ case MESA_FORMAT_RGB565:
+ textureFormat = TFT_RGB565;
+ t->texelBytes = tileIndex = 2;
+ break;
+ case MESA_FORMAT_L8:
+ textureFormat = TFT_L8;
+ t->texelBytes = tileIndex = 1;
+ break;
+ case MESA_FORMAT_I8:
+ textureFormat = TFT_I8;
+ t->texelBytes = tileIndex = 1;
+ break;
+ case MESA_FORMAT_A8:
+ textureFormat = TFT_A8;
+ t->texelBytes = tileIndex = 1;
+ break;
+ case MESA_FORMAT_RGB_DXT1:
+ textureFormat = TFT_S3TC4Bit;
+ tileIndex = TILE_INDEX_DXT1;
+ t->texelBytes = 8;
+ break;
+ case MESA_FORMAT_RGBA_DXT1:
+ textureFormat = TFT_S3TC4Bit;
+ tileIndex = TILE_INDEX_DXT1;
+ t->texelBytes = 8;
+ break;
+ case MESA_FORMAT_RGBA_DXT3:
+ textureFormat = TFT_S3TC4A4Bit;
+ tileIndex = TILE_INDEX_DXTn;
+ t->texelBytes = 16;
+ break;
+ case MESA_FORMAT_RGBA_DXT5:
+ textureFormat = TFT_S3TC4CA4Bit;
+ tileIndex = TILE_INDEX_DXTn;
+ t->texelBytes = 16;
+ break;
+ default:
+ _mesa_problem(imesa->glCtx, "Bad texture format in %s", __FUNCTION__);
+ return;
+ }
+ t->hwFormat = textureFormat;
+
+ /* Select tiling format depending on the chipset and texture format */
+ if (imesa->savageScreen->chipset <= S3_SAVAGE4)
+ t->tileInfo = &tileInfo_s3d_s4[tileIndex];
+ else
+ t->tileInfo = &tileInfo_pro[tileIndex];
+
+ /* Compute which mipmap levels we really want to send to the hardware.
+ */
+ driCalculateTextureFirstLastLevel( &t->base );
+ firstLevel = t->base.firstLevel;
+ lastLevel = t->base.lastLevel;
+
+ /* Figure out the size now (and count the levels). Upload won't be
+ * done until later. If the number of tiles changes, it means that
+ * this function is called for the first time on this tex object or
+ * the image or the destination color format changed. So all tiles
+ * are marked as dirty.
+ */
+ offset = 0;
+ size = 1;
+ for ( i = firstLevel ; i <= lastLevel && tObj->Image[0][i] ; i++ ) {
+ GLuint nTiles;
+ nTiles = savageTexImageTiles (image->Width2, image->Height2, t->tileInfo);
+ if (t->image[i].nTiles != nTiles) {
+ GLuint words = (nTiles + 31) / 32;
+ if (t->image[i].nTiles != 0) {
+ free(t->image[i].dirtyTiles);
+ }
+ t->image[i].dirtyTiles = malloc(words*sizeof(GLuint));
+ memset(t->image[i].dirtyTiles, ~0, words*sizeof(GLuint));
+ }
+ t->image[i].nTiles = nTiles;
+
+ t->image[i].offset = offset;
+
+ image = tObj->Image[0][i];
+ if (t->texelBytes >= 8)
+ size = savageCompressedTexImageSize (image->Width2, image->Height2,
+ t->texelBytes);
+ else
+ size = savageTexImageSize (image->Width2, image->Height2,
+ t->texelBytes);
+ offset += size;
+ }
+
+ t->base.lastLevel = i-1;
+ t->base.totalSize = offset;
+ /* the last three mipmap levels don't add to the offset. They are packed
+ * into 64 pixels. */
+ if (size == 0)
+ t->base.totalSize += (t->texelBytes >= 8 ? 4 : 64) * t->texelBytes;
+ /* 2k-aligned (really needed?) */
+ t->base.totalSize = (t->base.totalSize + 2047UL) & ~2047UL;
+}
+
+void savageDestroyTexObj(savageContextPtr imesa, savageTexObjPtr t)
+{
+ GLuint i;
+
+ /* Free dirty tiles bit vectors */
+ for (i = 0; i < SAVAGE_TEX_MAXLEVELS; ++i) {
+ if (t->image[i].nTiles)
+ free (t->image[i].dirtyTiles);
+ }
+
+ /* See if it was the driver's current object.
+ */
+ if ( imesa != NULL )
+ {
+ for ( i = 0 ; i < imesa->glCtx->Const.MaxTextureUnits ; i++ )
+ {
+ if ( &t->base == imesa->CurrentTexObj[ i ] ) {
+ assert( t->base.bound & (1 << i) );
+ imesa->CurrentTexObj[ i ] = NULL;
+ }
+ }
+ }
+}
+
+/* Upload a texture's images to one of the texture heaps. May have to
+ * eject our own and/or other client's texture objects to make room
+ * for the upload.
+ */
+static void savageUploadTexImages( savageContextPtr imesa, savageTexObjPtr t )
+{
+ const GLint numLevels = t->base.lastLevel - t->base.firstLevel + 1;
+ GLuint i;
+
+ assert(t);
+
+ LOCK_HARDWARE(imesa);
+
+ /* Do we need to eject LRU texture objects?
+ */
+ if (!t->base.memBlock) {
+ GLint heap;
+ GLuint ofs;
+
+ heap = driAllocateTexture(imesa->textureHeaps, imesa->lastTexHeap,
+ (driTextureObject *)t);
+ if (heap == -1) {
+ UNLOCK_HARDWARE(imesa);
+ return;
+ }
+
+ ofs = t->base.memBlock->ofs;
+ t->setup.physAddr = imesa->savageScreen->textureOffset[heap] + ofs;
+ t->bufAddr = (GLubyte *)imesa->savageScreen->texVirtual[heap] + ofs;
+ imesa->dirty |= SAVAGE_UPLOAD_GLOBAL; /* FIXME: really needed? */
+ }
+
+ /* Let the world know we've used this memory recently.
+ */
+ driUpdateTextureLRU( &t->base );
+ UNLOCK_HARDWARE(imesa);
+
+ if (t->base.dirty_images[0] || t->dirtySubImages) {
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_TEX)
+ fprintf(stderr, "Texture upload: |");
+
+ /* Heap timestamps are only reliable with Savage DRM 2.3.x or
+ * later. Earlier versions had only 16 bit time stamps which
+ * would wrap too frequently. */
+ if (imesa->savageScreen->driScrnPriv->drmMinor >= 3) {
+ unsigned int heap = t->base.heap->heapId;
+ LOCK_HARDWARE(imesa);
+ savageWaitEvent (imesa, imesa->textureHeaps[heap]->timestamp);
+ } else {
+ savageFlushVertices (imesa);
+ LOCK_HARDWARE(imesa);
+ savageFlushCmdBufLocked (imesa, GL_FALSE);
+ WAIT_IDLE_EMPTY_LOCKED(imesa);
+ }
+
+ for (i = 0 ; i < numLevels ; i++) {
+ const GLint j = t->base.firstLevel + i; /* the texObj's level */
+ if (t->base.dirty_images[0] & (1 << j)) {
+ savageMarkAllTiles(t, j);
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_TEX)
+ fprintf (stderr, "*");
+ } else if (SAVAGE_DEBUG & DEBUG_VERBOSE_TEX) {
+ if (t->dirtySubImages & (1 << j))
+ fprintf (stderr, ".");
+ else
+ fprintf (stderr, " ");
+ }
+ if ((t->base.dirty_images[0] | t->dirtySubImages) & (1 << j))
+ savageUploadTexLevel( t, j );
+ }
+
+ UNLOCK_HARDWARE(imesa);
+ t->base.dirty_images[0] = 0;
+ t->dirtySubImages = 0;
+
+ if (SAVAGE_DEBUG & DEBUG_VERBOSE_TEX)
+ fprintf(stderr, "|\n");
+ }
+}
+
+
+static void
+savage4_set_wrap_mode( savageContextPtr imesa, unsigned unit,
+ GLenum s_mode, GLenum t_mode )
+{
+ switch( s_mode ) {
+ case GL_REPEAT:
+ imesa->regs.s4.texCtrl[ unit ].ni.uMode = TAM_Wrap;
+ break;
+ case GL_CLAMP:
+ case GL_CLAMP_TO_EDGE:
+ imesa->regs.s4.texCtrl[ unit ].ni.uMode = TAM_Clamp;
+ break;
+ case GL_MIRRORED_REPEAT:
+ imesa->regs.s4.texCtrl[ unit ].ni.uMode = TAM_Mirror;
+ break;
+ }
+
+ switch( t_mode ) {
+ case GL_REPEAT:
+ imesa->regs.s4.texCtrl[ unit ].ni.vMode = TAM_Wrap;
+ break;
+ case GL_CLAMP:
+ case GL_CLAMP_TO_EDGE:
+ imesa->regs.s4.texCtrl[ unit ].ni.vMode = TAM_Clamp;
+ break;
+ case GL_MIRRORED_REPEAT:
+ imesa->regs.s4.texCtrl[ unit ].ni.vMode = TAM_Mirror;
+ break;
+ }
+}
+
+
+/**
+ * Sets the hardware bits for the specified GL texture filter modes.
+ *
+ * \todo
+ * Does the Savage4 have the ability to select the magnification filter?
+ */
+static void
+savage4_set_filter_mode( savageContextPtr imesa, unsigned unit,
+ GLenum minFilter, GLenum magFilter )
+{
+ (void) magFilter;
+
+ switch (minFilter) {
+ case GL_NEAREST:
+ imesa->regs.s4.texCtrl[ unit ].ni.filterMode = TFM_Point;
+ imesa->regs.s4.texCtrl[ unit ].ni.mipmapEnable = GL_FALSE;
+ break;
+
+ case GL_LINEAR:
+ imesa->regs.s4.texCtrl[ unit ].ni.filterMode = TFM_Bilin;
+ imesa->regs.s4.texCtrl[ unit ].ni.mipmapEnable = GL_FALSE;
+ break;
+
+ case GL_NEAREST_MIPMAP_NEAREST:
+ imesa->regs.s4.texCtrl[ unit ].ni.filterMode = TFM_Point;
+ imesa->regs.s4.texCtrl[ unit ].ni.mipmapEnable = GL_TRUE;
+ break;
+
+ case GL_LINEAR_MIPMAP_NEAREST:
+ imesa->regs.s4.texCtrl[ unit ].ni.filterMode = TFM_Bilin;
+ imesa->regs.s4.texCtrl[ unit ].ni.mipmapEnable = GL_TRUE;
+ break;
+
+ case GL_NEAREST_MIPMAP_LINEAR:
+ case GL_LINEAR_MIPMAP_LINEAR:
+ imesa->regs.s4.texCtrl[ unit ].ni.filterMode = TFM_Trilin;
+ imesa->regs.s4.texCtrl[ unit ].ni.mipmapEnable = GL_TRUE;
+ break;
+ }
+}
+
+
+static void savageUpdateTex0State_s4( GLcontext *ctx )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ struct gl_texture_object *tObj;
+ struct gl_texture_image *image;
+ savageTexObjPtr t;
+ GLuint format;
+
+ /* disable */
+ imesa->regs.s4.texDescr.ni.tex0En = GL_FALSE;
+ imesa->regs.s4.texBlendCtrl[0].ui = TBC_NoTexMap;
+ imesa->regs.s4.texCtrl[0].ui = 0x20f040;
+ if (ctx->Texture.Unit[0]._ReallyEnabled == 0)
+ return;
+
+ tObj = ctx->Texture.Unit[0]._Current;
+ if ((ctx->Texture.Unit[0]._ReallyEnabled & ~(TEXTURE_1D_BIT|TEXTURE_2D_BIT))
+ || tObj->Image[0][tObj->BaseLevel]->Border > 0) {
+ /* 3D texturing enabled, or texture border - fallback */
+ FALLBACK (ctx, SAVAGE_FALLBACK_TEXTURE, GL_TRUE);
+ return;
+ }
+
+ /* Do 2D texture setup */
+
+ t = tObj->DriverData;
+ if (!t) {
+ t = savageAllocTexObj( tObj );
+ if (!t)
+ return;
+ }
+
+ imesa->CurrentTexObj[0] = &t->base;
+ t->base.bound |= 1;
+
+ if (t->base.dirty_images[0] || t->dirtySubImages) {
+ savageSetTexImages(imesa, tObj);
+ savageUploadTexImages(imesa, t);
+ }
+
+ driUpdateTextureLRU( &t->base );
+
+ format = tObj->Image[0][tObj->BaseLevel]->Format;
+
+ switch (ctx->Texture.Unit[0].EnvMode) {
+ case GL_REPLACE:
+ imesa->regs.s4.texCtrl[0].ni.clrArg1Invert = GL_FALSE;
+ switch(format)
+ {
+ case GL_LUMINANCE:
+ case GL_RGB:
+ imesa->regs.s4.texBlendCtrl[0].ui = TBC_Decal;
+ break;
+
+ case GL_LUMINANCE_ALPHA:
+ case GL_RGBA:
+ case GL_INTENSITY:
+ imesa->regs.s4.texBlendCtrl[0].ui = TBC_Copy;
+ break;
+
+ case GL_ALPHA:
+ imesa->regs.s4.texBlendCtrl[0].ui = TBC_CopyAlpha;
+ break;
+ }
+ __HWEnvCombineSingleUnitScale(imesa, 0, 0,
+ &imesa->regs.s4.texBlendCtrl[0]);
+ break;
+
+ case GL_DECAL:
+ imesa->regs.s4.texCtrl[0].ni.clrArg1Invert = GL_FALSE;
+ switch (format)
+ {
+ case GL_RGB:
+ case GL_LUMINANCE:
+ imesa->regs.s4.texBlendCtrl[0].ui = TBC_Decal;
+ break;
+
+ case GL_RGBA:
+ case GL_INTENSITY:
+ case GL_LUMINANCE_ALPHA:
+ imesa->regs.s4.texBlendCtrl[0].ui = TBC_DecalAlpha;
+ break;
+
+ /*
+ GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_ALPHA, GL_INTENSITY
+ are undefined with GL_DECAL
+ */
+
+ case GL_ALPHA:
+ imesa->regs.s4.texBlendCtrl[0].ui = TBC_CopyAlpha;
+ break;
+ }
+ __HWEnvCombineSingleUnitScale(imesa, 0, 0,
+ &imesa->regs.s4.texBlendCtrl[0]);
+ break;
+
+ case GL_MODULATE:
+ imesa->regs.s4.texCtrl[0].ni.clrArg1Invert = GL_FALSE;
+ imesa->regs.s4.texBlendCtrl[0].ui = TBC_ModulAlpha;
+ __HWEnvCombineSingleUnitScale(imesa, 0, 0,
+ &imesa->regs.s4.texBlendCtrl[0]);
+ break;
+
+ case GL_BLEND:
+ imesa->regs.s4.texBlendColor.ui = imesa->texEnvColor;
+
+ switch (format)
+ {
+ case GL_ALPHA:
+ imesa->regs.s4.texBlendCtrl[0].ui = TBC_ModulAlpha;
+ imesa->regs.s4.texCtrl[0].ni.clrArg1Invert = GL_FALSE;
+ break;
+
+ case GL_LUMINANCE:
+ case GL_RGB:
+ imesa->regs.s4.texBlendCtrl[0].ui = TBC_Blend0;
+ imesa->regs.s4.texDescr.ni.tex1En = GL_TRUE;
+ imesa->regs.s4.texDescr.ni.texBLoopEn = GL_TRUE;
+ imesa->regs.s4.texDescr.ni.tex1Width =
+ imesa->regs.s4.texDescr.ni.tex0Width;
+ imesa->regs.s4.texDescr.ni.tex1Height =
+ imesa->regs.s4.texDescr.ni.tex0Height;
+ imesa->regs.s4.texDescr.ni.tex1Fmt =
+ imesa->regs.s4.texDescr.ni.tex0Fmt;
+
+ imesa->regs.s4.texAddr[1].ui = imesa->regs.s4.texAddr[0].ui;
+ imesa->regs.s4.texBlendCtrl[1].ui = TBC_Blend1;
+
+ imesa->regs.s4.texCtrl[0].ni.clrArg1Invert = GL_TRUE;
+ imesa->bTexEn1 = GL_TRUE;
+ break;
+
+ case GL_LUMINANCE_ALPHA:
+ case GL_RGBA:
+ imesa->regs.s4.texBlendCtrl[0].ui = TBC_BlendAlpha0;
+ imesa->regs.s4.texDescr.ni.tex1En = GL_TRUE;
+ imesa->regs.s4.texDescr.ni.texBLoopEn = GL_TRUE;
+ imesa->regs.s4.texDescr.ni.tex1Width =
+ imesa->regs.s4.texDescr.ni.tex0Width;
+ imesa->regs.s4.texDescr.ni.tex1Height =
+ imesa->regs.s4.texDescr.ni.tex0Height;
+ imesa->regs.s4.texDescr.ni.tex1Fmt =
+ imesa->regs.s4.texDescr.ni.tex0Fmt;
+
+ imesa->regs.s4.texAddr[1].ui = imesa->regs.s4.texAddr[0].ui;
+ imesa->regs.s4.texBlendCtrl[1].ui = TBC_BlendAlpha1;
+
+ imesa->regs.s4.texCtrl[0].ni.clrArg1Invert = GL_TRUE;
+ imesa->bTexEn1 = GL_TRUE;
+ break;
+
+ case GL_INTENSITY:
+ imesa->regs.s4.texBlendCtrl[0].ui = TBC_BlendInt0;
+ imesa->regs.s4.texDescr.ni.tex1En = GL_TRUE;
+ imesa->regs.s4.texDescr.ni.texBLoopEn = GL_TRUE;
+ imesa->regs.s4.texDescr.ni.tex1Width =
+ imesa->regs.s4.texDescr.ni.tex0Width;
+ imesa->regs.s4.texDescr.ni.tex1Height =
+ imesa->regs.s4.texDescr.ni.tex0Height;
+ imesa->regs.s4.texDescr.ni.tex1Fmt =
+ imesa->regs.s4.texDescr.ni.tex0Fmt;
+
+ imesa->regs.s4.texAddr[1].ui = imesa->regs.s4.texAddr[0].ui;
+ imesa->regs.s4.texBlendCtrl[1].ui = TBC_BlendInt1;
+
+ imesa->regs.s4.texCtrl[0].ni.clrArg1Invert = GL_TRUE;
+ imesa->regs.s4.texCtrl[0].ni.alphaArg1Invert = GL_TRUE;
+ imesa->bTexEn1 = GL_TRUE;
+ break;
+ }
+ __HWEnvCombineSingleUnitScale(imesa, 0, 0,
+ &imesa->regs.s4.texBlendCtrl[0]);
+ break;
+
+ case GL_ADD:
+ imesa->regs.s4.texCtrl[0].ni.clrArg1Invert = GL_FALSE;
+ switch (format)
+ {
+ case GL_ALPHA:
+ imesa->regs.s4.texBlendCtrl[0].ui = TBC_ModulAlpha;
+ break;
+
+ case GL_LUMINANCE:
+ case GL_RGB:
+ imesa->regs.s4.texBlendCtrl[0].ui = TBC_Add;
+ break;
+
+ case GL_LUMINANCE_ALPHA:
+ case GL_RGBA:
+ imesa->regs.s4.texBlendCtrl[0].ui = TBC_Add;
+ break;
+
+ case GL_INTENSITY:
+ imesa->regs.s4.texBlendCtrl[0].ui = TBC_AddAlpha;
+ break;
+ }
+ __HWEnvCombineSingleUnitScale(imesa, 0, 0,
+ &imesa->regs.s4.texBlendCtrl[0]);
+ break;
+
+#if GL_ARB_texture_env_combine
+ case GL_COMBINE_ARB:
+ __HWParseTexEnvCombine(imesa, 0, &imesa->regs.s4.texCtrl[0],
+ &imesa->regs.s4.texBlendCtrl[0]);
+ break;
+#endif
+
+ default:
+ fprintf(stderr, "unknown tex env mode");
+ exit(1);
+ break;
+ }
+
+ savage4_set_wrap_mode( imesa, 0, t->setup.sWrapMode, t->setup.tWrapMode );
+ savage4_set_filter_mode( imesa, 0, t->setup.minFilter, t->setup.magFilter );
+
+ if((ctx->Texture.Unit[0].LodBias !=0.0F) ||
+ (imesa->regs.s4.texCtrl[0].ni.dBias != 0))
+ {
+ int bias = (int)(ctx->Texture.Unit[0].LodBias * 32.0) +
+ SAVAGE4_LOD_OFFSET;
+ if (bias < -256)
+ bias = -256;
+ else if (bias > 255)
+ bias = 255;
+ imesa->regs.s4.texCtrl[0].ni.dBias = bias & 0x1ff;
+ }
+
+ image = tObj->Image[0][tObj->BaseLevel];
+ imesa->regs.s4.texDescr.ni.tex0En = GL_TRUE;
+ imesa->regs.s4.texDescr.ni.tex0Width = image->WidthLog2;
+ imesa->regs.s4.texDescr.ni.tex0Height = image->HeightLog2;
+ imesa->regs.s4.texDescr.ni.tex0Fmt = t->hwFormat;
+ imesa->regs.s4.texCtrl[0].ni.dMax = t->base.lastLevel - t->base.firstLevel;
+
+ if (imesa->regs.s4.texDescr.ni.tex1En)
+ imesa->regs.s4.texDescr.ni.texBLoopEn = GL_TRUE;
+
+ imesa->regs.s4.texAddr[0].ui = (u_int32_t) t->setup.physAddr | 0x2;
+ if(t->base.heap->heapId == SAVAGE_AGP_HEAP)
+ imesa->regs.s4.texAddr[0].ui |= 0x1;
+
+ return;
+}
+static void savageUpdateTex1State_s4( GLcontext *ctx )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ struct gl_texture_object *tObj;
+ struct gl_texture_image *image;
+ savageTexObjPtr t;
+ GLuint format;
+
+ /* disable */
+ if(imesa->bTexEn1)
+ {
+ imesa->bTexEn1 = GL_FALSE;
+ return;
+ }
+
+ imesa->regs.s4.texDescr.ni.tex1En = GL_FALSE;
+ imesa->regs.s4.texBlendCtrl[1].ui = TBC_NoTexMap1;
+ imesa->regs.s4.texCtrl[1].ui = 0x20f040;
+ imesa->regs.s4.texDescr.ni.texBLoopEn = GL_FALSE;
+ if (ctx->Texture.Unit[1]._ReallyEnabled == 0)
+ return;
+
+ tObj = ctx->Texture.Unit[1]._Current;
+
+ if ((ctx->Texture.Unit[1]._ReallyEnabled & ~(TEXTURE_1D_BIT|TEXTURE_2D_BIT))
+ || tObj->Image[0][tObj->BaseLevel]->Border > 0) {
+ /* 3D texturing enabled, or texture border - fallback */
+ FALLBACK (ctx, SAVAGE_FALLBACK_TEXTURE, GL_TRUE);
+ return;
+ }
+
+ /* Do 2D texture setup */
+
+ t = tObj->DriverData;
+ if (!t) {
+ t = savageAllocTexObj( tObj );
+ if (!t)
+ return;
+ }
+
+ imesa->CurrentTexObj[1] = &t->base;
+
+ t->base.bound |= 2;
+
+ if (t->base.dirty_images[0] || t->dirtySubImages) {
+ savageSetTexImages(imesa, tObj);
+ savageUploadTexImages(imesa, t);
+ }
+
+ driUpdateTextureLRU( &t->base );
+
+ format = tObj->Image[0][tObj->BaseLevel]->Format;
+
+ switch (ctx->Texture.Unit[1].EnvMode) {
+ case GL_REPLACE:
+ imesa->regs.s4.texCtrl[1].ni.clrArg1Invert = GL_FALSE;
+ switch (format)
+ {
+ case GL_LUMINANCE:
+ case GL_RGB:
+ imesa->regs.s4.texBlendCtrl[1].ui = TBC_Decal;
+ break;
+
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ case GL_RGBA:
+ imesa->regs.s4.texBlendCtrl[1].ui = TBC_Copy;
+ break;
+
+ case GL_ALPHA:
+ imesa->regs.s4.texBlendCtrl[1].ui = TBC_CopyAlpha1;
+ break;
+ }
+ __HWEnvCombineSingleUnitScale(imesa, 0, 1, &imesa->regs.s4.texBlendCtrl);
+ break;
+ case GL_MODULATE:
+ imesa->regs.s4.texCtrl[1].ni.clrArg1Invert = GL_FALSE;
+ imesa->regs.s4.texBlendCtrl[1].ui = TBC_ModulAlpha1;
+ __HWEnvCombineSingleUnitScale(imesa, 0, 1, &imesa->regs.s4.texBlendCtrl);
+ break;
+
+ case GL_ADD:
+ imesa->regs.s4.texCtrl[1].ni.clrArg1Invert = GL_FALSE;
+ switch (format)
+ {
+ case GL_ALPHA:
+ imesa->regs.s4.texBlendCtrl[1].ui = TBC_ModulAlpha1;
+ break;
+
+ case GL_LUMINANCE:
+ case GL_RGB:
+ imesa->regs.s4.texBlendCtrl[1].ui = TBC_Add1;
+ break;
+
+ case GL_LUMINANCE_ALPHA:
+ case GL_RGBA:
+ imesa->regs.s4.texBlendCtrl[1].ui = TBC_Add1;
+ break;
+
+ case GL_INTENSITY:
+ imesa->regs.s4.texBlendCtrl[1].ui = TBC_AddAlpha1;
+ break;
+ }
+ __HWEnvCombineSingleUnitScale(imesa, 0, 1, &imesa->regs.s4.texBlendCtrl);
+ break;
+
+#if GL_ARB_texture_env_combine
+ case GL_COMBINE_ARB:
+ __HWParseTexEnvCombine(imesa, 1, &texCtrl, &imesa->regs.s4.texBlendCtrl);
+ break;
+#endif
+
+ case GL_DECAL:
+ imesa->regs.s4.texCtrl[1].ni.clrArg1Invert = GL_FALSE;
+
+ switch (format)
+ {
+ case GL_LUMINANCE:
+ case GL_RGB:
+ imesa->regs.s4.texBlendCtrl[1].ui = TBC_Decal1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ case GL_RGBA:
+ imesa->regs.s4.texBlendCtrl[1].ui = TBC_DecalAlpha1;
+ break;
+
+ /*
+ // GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_ALPHA, GL_INTENSITY
+ // are undefined with GL_DECAL
+ */
+ case GL_ALPHA:
+ imesa->regs.s4.texBlendCtrl[1].ui = TBC_CopyAlpha1;
+ break;
+ }
+ __HWEnvCombineSingleUnitScale(imesa, 0, 1, &imesa->regs.s4.texBlendCtrl);
+ break;
+
+ case GL_BLEND:
+ if (format == GL_LUMINANCE)
+ {
+ /*
+ // This is a hack for GLQuake, invert.
+ */
+ imesa->regs.s4.texCtrl[1].ni.clrArg1Invert = GL_TRUE;
+ imesa->regs.s4.texBlendCtrl[1].ui = 0;
+ }
+ __HWEnvCombineSingleUnitScale(imesa, 0, 1, &imesa->regs.s4.texBlendCtrl);
+ break;
+
+ default:
+ fprintf(stderr, "unknown tex 1 env mode\n");
+ exit(1);
+ break;
+ }
+
+ savage4_set_wrap_mode( imesa, 1, t->setup.sWrapMode, t->setup.tWrapMode );
+ savage4_set_filter_mode( imesa, 1, t->setup.minFilter, t->setup.magFilter );
+
+ if((ctx->Texture.Unit[1].LodBias !=0.0F) ||
+ (imesa->regs.s4.texCtrl[1].ni.dBias != 0))
+ {
+ int bias = (int)(ctx->Texture.Unit[1].LodBias * 32.0) +
+ SAVAGE4_LOD_OFFSET;
+ if (bias < -256)
+ bias = -256;
+ else if (bias > 255)
+ bias = 255;
+ imesa->regs.s4.texCtrl[1].ni.dBias = bias & 0x1ff;
+ }
+
+ image = tObj->Image[0][tObj->BaseLevel];
+ imesa->regs.s4.texDescr.ni.tex1En = GL_TRUE;
+ imesa->regs.s4.texDescr.ni.tex1Width = image->WidthLog2;
+ imesa->regs.s4.texDescr.ni.tex1Height = image->HeightLog2;
+ imesa->regs.s4.texDescr.ni.tex1Fmt = t->hwFormat;
+ imesa->regs.s4.texCtrl[1].ni.dMax = t->base.lastLevel - t->base.firstLevel;
+ imesa->regs.s4.texDescr.ni.texBLoopEn = GL_TRUE;
+
+ imesa->regs.s4.texAddr[1].ui = (u_int32_t) t->setup.physAddr | 2;
+ if(t->base.heap->heapId == SAVAGE_AGP_HEAP)
+ imesa->regs.s4.texAddr[1].ui |= 0x1;
+}
+static void savageUpdateTexState_s3d( GLcontext *ctx )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ struct gl_texture_object *tObj;
+ struct gl_texture_image *image;
+ savageTexObjPtr t;
+ GLuint format;
+
+ /* disable */
+ imesa->regs.s3d.texCtrl.ui = 0;
+ imesa->regs.s3d.texCtrl.ni.texEn = GL_FALSE;
+ imesa->regs.s3d.texCtrl.ni.dBias = 0x08;
+ imesa->regs.s3d.texCtrl.ni.texXprEn = GL_TRUE;
+ if (ctx->Texture.Unit[0]._ReallyEnabled == 0)
+ return;
+
+ tObj = ctx->Texture.Unit[0]._Current;
+ if ((ctx->Texture.Unit[0]._ReallyEnabled & ~(TEXTURE_1D_BIT|TEXTURE_2D_BIT))
+ || tObj->Image[0][tObj->BaseLevel]->Border > 0) {
+ /* 3D texturing enabled, or texture border - fallback */
+ FALLBACK (ctx, SAVAGE_FALLBACK_TEXTURE, GL_TRUE);
+ return;
+ }
+
+ /* Do 2D texture setup */
+ t = tObj->DriverData;
+ if (!t) {
+ t = savageAllocTexObj( tObj );
+ if (!t)
+ return;
+ }
+
+ imesa->CurrentTexObj[0] = &t->base;
+ t->base.bound |= 1;
+
+ if (t->base.dirty_images[0] || t->dirtySubImages) {
+ savageSetTexImages(imesa, tObj);
+ savageUploadTexImages(imesa, t);
+ }
+
+ driUpdateTextureLRU( &t->base );
+
+ format = tObj->Image[0][tObj->BaseLevel]->Format;
+
+ /* FIXME: copied from utah-glx, probably needs some tuning */
+ switch (ctx->Texture.Unit[0].EnvMode) {
+ case GL_DECAL:
+ imesa->regs.s3d.drawCtrl.ni.texBlendCtrl = SAVAGETBC_DECALALPHA_S3D;
+ break;
+ case GL_REPLACE:
+ switch (format) {
+ case GL_ALPHA: /* FIXME */
+ imesa->regs.s3d.drawCtrl.ni.texBlendCtrl = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ case GL_RGBA:
+ imesa->regs.s3d.drawCtrl.ni.texBlendCtrl = 4;
+ break;
+ case GL_RGB:
+ case GL_LUMINANCE:
+ imesa->regs.s3d.drawCtrl.ni.texBlendCtrl = SAVAGETBC_DECAL_S3D;
+ break;
+ case GL_INTENSITY:
+ imesa->regs.s3d.drawCtrl.ni.texBlendCtrl = SAVAGETBC_COPY_S3D;
+ }
+ break;
+ case GL_BLEND: /* hardware can't do GL_BLEND */
+ FALLBACK (ctx, SAVAGE_FALLBACK_TEXTURE, GL_TRUE);
+ return;
+ case GL_MODULATE:
+ imesa->regs.s3d.drawCtrl.ni.texBlendCtrl = SAVAGETBC_MODULATEALPHA_S3D;
+ break;
+ default:
+ fprintf(stderr, "unknown tex env mode\n");
+ /*exit(1);*/
+ break;
+ }
+
+ /* The Savage3D can't handle different wrapping modes in s and t.
+ * If they are not the same, fall back to software. */
+ if (t->setup.sWrapMode != t->setup.tWrapMode) {
+ FALLBACK (ctx, SAVAGE_FALLBACK_TEXTURE, GL_TRUE);
+ return;
+ }
+ imesa->regs.s3d.texCtrl.ni.uWrapEn = 0;
+ imesa->regs.s3d.texCtrl.ni.vWrapEn = 0;
+ imesa->regs.s3d.texCtrl.ni.wrapMode =
+ (t->setup.sWrapMode == GL_REPEAT) ? TAM_Wrap : TAM_Clamp;
+
+ switch (t->setup.minFilter) {
+ case GL_NEAREST:
+ imesa->regs.s3d.texCtrl.ni.filterMode = TFM_Point;
+ imesa->regs.s3d.texCtrl.ni.mipmapDisable = GL_TRUE;
+ break;
+
+ case GL_LINEAR:
+ imesa->regs.s3d.texCtrl.ni.filterMode = TFM_Bilin;
+ imesa->regs.s3d.texCtrl.ni.mipmapDisable = GL_TRUE;
+ break;
+
+ case GL_NEAREST_MIPMAP_NEAREST:
+ imesa->regs.s3d.texCtrl.ni.filterMode = TFM_Point;
+ imesa->regs.s3d.texCtrl.ni.mipmapDisable = GL_FALSE;
+ break;
+
+ case GL_LINEAR_MIPMAP_NEAREST:
+ imesa->regs.s3d.texCtrl.ni.filterMode = TFM_Bilin;
+ imesa->regs.s3d.texCtrl.ni.mipmapDisable = GL_FALSE;
+ break;
+
+ case GL_NEAREST_MIPMAP_LINEAR:
+ case GL_LINEAR_MIPMAP_LINEAR:
+ imesa->regs.s3d.texCtrl.ni.filterMode = TFM_Trilin;
+ imesa->regs.s3d.texCtrl.ni.mipmapDisable = GL_FALSE;
+ break;
+ }
+
+ /* There is no way to specify a maximum mipmap level. We may have to
+ disable mipmapping completely. */
+ /*
+ if (t->max_level < t->image[0].image->WidthLog2 ||
+ t->max_level < t->image[0].image->HeightLog2) {
+ texCtrl.ni.mipmapEnable = GL_TRUE;
+ if (texCtrl.ni.filterMode == TFM_Trilin)
+ texCtrl.ni.filterMode = TFM_Bilin;
+ texCtrl.ni.filterMode = TFM_Point;
+ }
+ */
+
+ if((ctx->Texture.Unit[0].LodBias !=0.0F) ||
+ (imesa->regs.s3d.texCtrl.ni.dBias != 0))
+ {
+ int bias = (int)(ctx->Texture.Unit[0].LodBias * 16.0);
+ if (bias < -256)
+ bias = -256;
+ else if (bias > 255)
+ bias = 255;
+ imesa->regs.s3d.texCtrl.ni.dBias = bias & 0x1ff;
+ }
+
+ image = tObj->Image[0][tObj->BaseLevel];
+ imesa->regs.s3d.texCtrl.ni.texEn = GL_TRUE;
+ imesa->regs.s3d.texDescr.ni.texWidth = image->WidthLog2;
+ imesa->regs.s3d.texDescr.ni.texHeight = image->HeightLog2;
+ assert (t->hwFormat <= 7);
+ imesa->regs.s3d.texDescr.ni.texFmt = t->hwFormat;
+
+ imesa->regs.s3d.texAddr.ui = (u_int32_t) t->setup.physAddr | 2;
+ if(t->base.heap->heapId == SAVAGE_AGP_HEAP)
+ imesa->regs.s3d.texAddr.ui |= 0x1;
+}
+
+
+static void savageTimestampTextures( savageContextPtr imesa )
+{
+ /* Timestamp current texture objects for texture heap aging.
+ * Only useful with long-lived 32-bit event tags available
+ * with Savage DRM 2.3.x or later. */
+ if ((imesa->CurrentTexObj[0] || imesa->CurrentTexObj[1]) &&
+ imesa->savageScreen->driScrnPriv->drmMinor >= 3) {
+ unsigned int e;
+ FLUSH_BATCH(imesa);
+ e = savageEmitEvent(imesa, SAVAGE_WAIT_3D);
+ if (imesa->CurrentTexObj[0])
+ imesa->CurrentTexObj[0]->timestamp = e;
+ if (imesa->CurrentTexObj[1])
+ imesa->CurrentTexObj[1]->timestamp = e;
+ }
+}
+
+
+static void savageUpdateTextureState_s4( GLcontext *ctx )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+
+ /* When a texture is about to change or be disabled, timestamp the
+ * old texture(s). We'll have to wait for this time stamp before
+ * uploading anything to the same texture heap.
+ */
+ if ((imesa->CurrentTexObj[0] && ctx->Texture.Unit[0]._ReallyEnabled &&
+ ctx->Texture.Unit[0]._Current->DriverData != imesa->CurrentTexObj[0]) ||
+ (imesa->CurrentTexObj[1] && ctx->Texture.Unit[1]._ReallyEnabled &&
+ ctx->Texture.Unit[1]._Current->DriverData != imesa->CurrentTexObj[1]) ||
+ (imesa->CurrentTexObj[0] && !ctx->Texture.Unit[0]._ReallyEnabled) ||
+ (imesa->CurrentTexObj[1] && !ctx->Texture.Unit[1]._ReallyEnabled))
+ savageTimestampTextures(imesa);
+
+ if (imesa->CurrentTexObj[0]) imesa->CurrentTexObj[0]->bound &= ~1;
+ if (imesa->CurrentTexObj[1]) imesa->CurrentTexObj[1]->bound &= ~2;
+ imesa->CurrentTexObj[0] = 0;
+ imesa->CurrentTexObj[1] = 0;
+ savageUpdateTex0State_s4( ctx );
+ savageUpdateTex1State_s4( ctx );
+ imesa->dirty |= (SAVAGE_UPLOAD_TEX0 |
+ SAVAGE_UPLOAD_TEX1);
+}
+static void savageUpdateTextureState_s3d( GLcontext *ctx )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+
+ /* When a texture is about to change or be disabled, timestamp the
+ * old texture(s). We'll have to wait for this time stamp before
+ * uploading anything to the same texture heap.
+ */
+ if ((imesa->CurrentTexObj[0] && ctx->Texture.Unit[0]._ReallyEnabled &&
+ ctx->Texture.Unit[0]._Current->DriverData != imesa->CurrentTexObj[0]) ||
+ (imesa->CurrentTexObj[0] && !ctx->Texture.Unit[0]._ReallyEnabled))
+ savageTimestampTextures(imesa);
+
+ if (imesa->CurrentTexObj[0]) imesa->CurrentTexObj[0]->bound &= ~1;
+ imesa->CurrentTexObj[0] = 0;
+ savageUpdateTexState_s3d( ctx );
+ imesa->dirty |= (SAVAGE_UPLOAD_TEX0);
+}
+void savageUpdateTextureState( GLcontext *ctx)
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
+ FALLBACK (ctx, SAVAGE_FALLBACK_TEXTURE, GL_FALSE);
+ FALLBACK(ctx, SAVAGE_FALLBACK_PROJ_TEXTURE, GL_FALSE);
+ if (imesa->savageScreen->chipset >= S3_SAVAGE4)
+ savageUpdateTextureState_s4 (ctx);
+ else
+ savageUpdateTextureState_s3d (ctx);
+}
+
+
+
+/*****************************************
+ * DRIVER functions
+ *****************************************/
+
+static void savageTexEnv( GLcontext *ctx, GLenum target,
+ GLenum pname, const GLfloat *param )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
+
+ if (pname == GL_TEXTURE_ENV_MODE) {
+
+ imesa->new_state |= SAVAGE_NEW_TEXTURE;
+
+ } else if (pname == GL_TEXTURE_ENV_COLOR) {
+
+ struct gl_texture_unit *texUnit =
+ &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ const GLfloat *fc = texUnit->EnvColor;
+ GLuint r, g, b, a;
+ CLAMPED_FLOAT_TO_UBYTE(r, fc[0]);
+ CLAMPED_FLOAT_TO_UBYTE(g, fc[1]);
+ CLAMPED_FLOAT_TO_UBYTE(b, fc[2]);
+ CLAMPED_FLOAT_TO_UBYTE(a, fc[3]);
+
+ imesa->texEnvColor = ((a << 24) | (r << 16) |
+ (g << 8) | (b << 0));
+
+
+ }
+}
+
+/* Update the heap's time stamp, so the new image is not uploaded
+ * while the old one is still in use. If the texture that is going to
+ * be changed is currently bound, we need to timestamp the texture
+ * first. */
+static void savageTexImageChanged (savageTexObjPtr t) {
+ if (t->base.heap) {
+ if (t->base.bound)
+ savageTimestampTextures(
+ (savageContextPtr)t->base.heap->driverContext);
+ if (t->base.timestamp > t->base.heap->timestamp)
+ t->base.heap->timestamp = t->base.timestamp;
+ }
+}
+
+static void savageTexImage1D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ savageTexObjPtr t = (savageTexObjPtr) texObj->DriverData;
+ if (t) {
+ savageTexImageChanged (t);
+ } else {
+ t = savageAllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
+ return;
+ }
+ }
+ _mesa_store_teximage1d( ctx, target, level, internalFormat,
+ width, border, format, type,
+ pixels, packing, texObj, texImage );
+ t->base.dirty_images[0] |= (1 << level);
+ SAVAGE_CONTEXT(ctx)->new_state |= SAVAGE_NEW_TEXTURE;
+}
+
+static void savageTexSubImage1D( 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 )
+{
+ savageTexObjPtr t = (savageTexObjPtr) texObj->DriverData;
+ assert( t ); /* this _should_ be true */
+ if (t) {
+ savageTexImageChanged (t);
+ savageMarkDirtyTiles(t, level, texImage->Width2, 1,
+ xoffset, 0, width, 1);
+ } else {
+ t = savageAllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
+ return;
+ }
+ t->base.dirty_images[0] |= (1 << level);
+ }
+ _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
+ format, type, pixels, packing, texObj,
+ texImage);
+ t->dirtySubImages |= (1 << level);
+ SAVAGE_CONTEXT(ctx)->new_state |= SAVAGE_NEW_TEXTURE;
+}
+
+static void savageTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ savageTexObjPtr t = (savageTexObjPtr) texObj->DriverData;
+ if (t) {
+ savageTexImageChanged (t);
+ } else {
+ t = savageAllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ }
+ _mesa_store_teximage2d( ctx, target, level, internalFormat,
+ width, height, border, format, type,
+ pixels, packing, texObj, texImage );
+ t->base.dirty_images[0] |= (1 << level);
+ SAVAGE_CONTEXT(ctx)->new_state |= SAVAGE_NEW_TEXTURE;
+}
+
+static void savageTexSubImage2D( 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 )
+{
+ savageTexObjPtr t = (savageTexObjPtr) texObj->DriverData;
+ assert( t ); /* this _should_ be true */
+ if (t) {
+ savageTexImageChanged (t);
+ savageMarkDirtyTiles(t, level, texImage->Width2, texImage->Height2,
+ xoffset, yoffset, width, height);
+ } else {
+ t = savageAllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
+ return;
+ }
+ t->base.dirty_images[0] |= (1 << level);
+ }
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
+ t->dirtySubImages |= (1 << level);
+ SAVAGE_CONTEXT(ctx)->new_state |= SAVAGE_NEW_TEXTURE;
+}
+
+static void
+savageCompressedTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ savageTexObjPtr t = (savageTexObjPtr) texObj->DriverData;
+ if (t) {
+ savageTexImageChanged (t);
+ } else {
+ t = savageAllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
+ return;
+ }
+ }
+ _mesa_store_compressed_teximage2d( ctx, target, level, internalFormat,
+ width, height, border, imageSize,
+ data, texObj, texImage );
+ t->base.dirty_images[0] |= (1 << level);
+ SAVAGE_CONTEXT(ctx)->new_state |= SAVAGE_NEW_TEXTURE;
+}
+
+static void
+savageCompressedTexSubImage2D( GLcontext *ctx,
+ GLenum target,
+ GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLsizei imageSize,
+ const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ savageTexObjPtr t = (savageTexObjPtr) texObj->DriverData;
+ assert( t ); /* this _should_ be true */
+ if (t) {
+ savageTexImageChanged (t);
+ savageMarkDirtyTiles(t, level, texImage->Width2, texImage->Height2,
+ xoffset, yoffset, width, height);
+ } else {
+ t = savageAllocTexObj(texObj);
+ if (!t) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
+ return;
+ }
+ t->base.dirty_images[0] |= (1 << level);
+ }
+ _mesa_store_compressed_texsubimage2d(ctx, target, level, xoffset, yoffset,
+ width, height, format, imageSize,
+ data, texObj, texImage);
+ t->dirtySubImages |= (1 << level);
+ SAVAGE_CONTEXT(ctx)->new_state |= SAVAGE_NEW_TEXTURE;
+}
+
+static void savageTexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat *params )
+{
+ savageTexObjPtr t = (savageTexObjPtr) tObj->DriverData;
+ savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
+
+ if (!t || (target != GL_TEXTURE_1D && target != GL_TEXTURE_2D))
+ return;
+
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ case GL_TEXTURE_MAG_FILTER:
+ savageSetTexFilter(t,tObj->MinFilter,tObj->MagFilter);
+ break;
+
+ case GL_TEXTURE_WRAP_S:
+ case GL_TEXTURE_WRAP_T:
+ savageSetTexWrapping(t,tObj->WrapS,tObj->WrapT);
+ break;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ savageSetTexBorderColor(t,tObj->_BorderChan);
+ break;
+
+ default:
+ return;
+ }
+
+ imesa->new_state |= SAVAGE_NEW_TEXTURE;
+}
+
+static void savageBindTexture( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
+
+ assert( (target != GL_TEXTURE_1D && target != GL_TEXTURE_2D) ||
+ (tObj->DriverData != NULL) );
+
+ imesa->new_state |= SAVAGE_NEW_TEXTURE;
+}
+
+static void savageDeleteTexture( GLcontext *ctx, struct gl_texture_object *tObj )
+{
+ driTextureObject *t = (driTextureObject *)tObj->DriverData;
+ savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
+
+ if (t) {
+ if (t->bound)
+ savageTimestampTextures(imesa);
+
+ driDestroyTextureObject(t);
+ }
+ /* Free mipmap images and the texture object itself */
+ _mesa_delete_texture_object(ctx, tObj);
+}
+
+
+static struct gl_texture_object *
+savageNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+{
+ struct gl_texture_object *obj;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ savageAllocTexObj( obj );
+
+ return obj;
+}
+
+void savageDDInitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->TexEnv = savageTexEnv;
+ functions->ChooseTextureFormat = savageChooseTextureFormat;
+ functions->TexImage1D = savageTexImage1D;
+ functions->TexSubImage1D = savageTexSubImage1D;
+ functions->TexImage2D = savageTexImage2D;
+ functions->TexSubImage2D = savageTexSubImage2D;
+ functions->CompressedTexImage2D = savageCompressedTexImage2D;
+ functions->CompressedTexSubImage2D = savageCompressedTexSubImage2D;
+ functions->BindTexture = savageBindTexture;
+ functions->NewTextureObject = savageNewTextureObject;
+ functions->DeleteTexture = savageDeleteTexture;
+ functions->IsTextureResident = driIsTextureResident;
+ functions->TexParameter = savageTexParameter;
+
+ /* Texel fetching with our custom texture formats works just like
+ * the standard argb formats. */
+ _savage_texformat_a1114444.FetchTexel1D = _mesa_texformat_argb4444.FetchTexel1D;
+ _savage_texformat_a1114444.FetchTexel2D = _mesa_texformat_argb4444.FetchTexel2D;
+ _savage_texformat_a1114444.FetchTexel3D = _mesa_texformat_argb4444.FetchTexel3D;
+ _savage_texformat_a1114444.FetchTexel1Df= _mesa_texformat_argb4444.FetchTexel1Df;
+ _savage_texformat_a1114444.FetchTexel2Df= _mesa_texformat_argb4444.FetchTexel2Df;
+ _savage_texformat_a1114444.FetchTexel3Df= _mesa_texformat_argb4444.FetchTexel3Df;
+
+ _savage_texformat_a1118888.FetchTexel1D = _mesa_texformat_argb8888.FetchTexel1D;
+ _savage_texformat_a1118888.FetchTexel2D = _mesa_texformat_argb8888.FetchTexel2D;
+ _savage_texformat_a1118888.FetchTexel3D = _mesa_texformat_argb8888.FetchTexel3D;
+ _savage_texformat_a1118888.FetchTexel1Df= _mesa_texformat_argb8888.FetchTexel1Df;
+ _savage_texformat_a1118888.FetchTexel2Df= _mesa_texformat_argb8888.FetchTexel2Df;
+ _savage_texformat_a1118888.FetchTexel3Df= _mesa_texformat_argb8888.FetchTexel3Df;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagetex.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagetex.h
new file mode 100644
index 000000000..f1ee72241
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagetex.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+#ifndef SAVAGETEX_INC
+#define SAVAGETEX_INC
+
+#include "mtypes.h"
+
+#include "savagecontext.h"
+#include "texmem.h"
+
+#define SAVAGE_TEX_MAXLEVELS 12
+
+/** \brief Texture tiling information */
+typedef struct savage_tileinfo_t {
+ GLuint width, height; /**< tile width and height */
+ GLuint wInSub, hInSub; /**< tile width and height in subtiles */
+ GLuint subWidth, subHeight; /**< subtile width and height */
+ GLuint tinyOffset[2]; /**< internal offsets size 1 and 2 images */
+} savageTileInfo, *savageTileInfoPtr;
+
+typedef struct {
+ GLuint offset;
+ GLuint nTiles;
+ GLuint *dirtyTiles; /* bit vector of dirty tiles (still unused) */
+} savageTexImage;
+
+typedef struct {
+ driTextureObject base;
+
+ GLubyte *bufAddr;
+
+ GLuint age;
+ savageTexImage image[SAVAGE_TEX_MAXLEVELS];
+ GLuint dirtySubImages;
+
+ struct {
+ GLuint sWrapMode, tWrapMode;
+ GLuint minFilter, magFilter;
+ GLuint physAddr;
+ } setup;
+
+ GLuint hwFormat;
+ GLuint texelBytes;
+ const savageTileInfo *tileInfo;
+} savageTexObj, *savageTexObjPtr;
+
+#define SAVAGE_NO_PALETTE 0x0
+#define SAVAGE_USE_PALETTE 0x1
+#define SAVAGE_UPDATE_PALETTE 0x2
+#define SAVAGE_FALLBACK_PALETTE 0x4
+#define __HWEnvCombineSingleUnitScale(imesa, flag0, flag1, TexBlendCtrl)
+#define __HWParseTexEnvCombine(imesa, flag0, TexCtrl, TexBlendCtrl)
+
+
+void savageUpdateTextureState( GLcontext *ctx );
+void savageDDInitTextureFuncs( struct dd_function_table *functions );
+
+void savageDestroyTexObj( savageContextPtr imesa, savageTexObjPtr t );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagetris.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagetris.c
new file mode 100644
index 000000000..184704013
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagetris.c
@@ -0,0 +1,1297 @@
+/* $XFree86$ */ /* -*- c-basic-offset: 3 -*- */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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
+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, VA LINUX SYSTEMS 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:
+ * Keith Whitwell <keithw@valinux.com>
+ * Felix Kuehling <fxkuehl@gmx.de>
+ *
+ */
+
+#include <stdio.h>
+#include <math.h>
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "colormac.h"
+#include "macros.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
+#include "savagetris.h"
+#include "savagestate.h"
+#include "savagetex.h"
+#include "savageioctl.h"
+#include "savage_bci.h"
+
+static void savageRasterPrimitive( GLcontext *ctx, GLuint prim );
+static void savageRenderPrimitive( GLcontext *ctx, GLenum prim );
+
+
+static GLenum reduced_prim[GL_POLYGON+1] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES
+};
+
+
+/***********************************************************************
+ * Emit primitives *
+ ***********************************************************************/
+
+#if defined (USE_X86_ASM)
+#define EMIT_VERT( j, vb, vertex_size, start, v ) \
+do { int __tmp; \
+ vb += start; \
+ __asm__ __volatile__( "rep ; movsl" \
+ : "=%c" (j), "=D" (vb), "=S" (__tmp) \
+ : "0" (vertex_size-start), \
+ "D" ((long)vb), \
+ "S" ((long)&(v)->ui[start])); \
+} while (0)
+#else
+#define EMIT_VERT( j, vb, vertex_size, start, v ) \
+do { \
+ for ( j = start ; j < vertex_size ; j++ ) \
+ vb[j] = (v)->ui[j]; \
+ vb += vertex_size; \
+} while (0)
+#endif
+
+static void __inline__ savage_draw_triangle (savageContextPtr imesa,
+ savageVertexPtr v0,
+ savageVertexPtr v1,
+ savageVertexPtr v2) {
+ GLuint vertsize = imesa->HwVertexSize;
+ u_int32_t *vb = savageAllocVtxBuf (imesa, 3*vertsize);
+ GLuint j;
+
+ EMIT_VERT (j, vb, vertsize, 0, v0);
+ EMIT_VERT (j, vb, vertsize, 0, v1);
+ EMIT_VERT (j, vb, vertsize, 0, v2);
+}
+
+static void __inline__ savage_draw_quad (savageContextPtr imesa,
+ savageVertexPtr v0,
+ savageVertexPtr v1,
+ savageVertexPtr v2,
+ savageVertexPtr v3) {
+ GLuint vertsize = imesa->HwVertexSize;
+ u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize);
+ GLuint j;
+
+ EMIT_VERT (j, vb, vertsize, 0, v0);
+ EMIT_VERT (j, vb, vertsize, 0, v1);
+ EMIT_VERT (j, vb, vertsize, 0, v3);
+ EMIT_VERT (j, vb, vertsize, 0, v1);
+ EMIT_VERT (j, vb, vertsize, 0, v2);
+ EMIT_VERT (j, vb, vertsize, 0, v3);
+}
+
+static __inline__ void savage_draw_point (savageContextPtr imesa,
+ savageVertexPtr tmp) {
+ GLuint vertsize = imesa->HwVertexSize;
+ u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize);
+ const GLfloat x = tmp->v.x;
+ const GLfloat y = tmp->v.y;
+ const GLfloat sz = imesa->glCtx->Point._Size * .5;
+ GLuint j;
+
+ *(float *)&vb[0] = x - sz;
+ *(float *)&vb[1] = y - sz;
+ EMIT_VERT (j, vb, vertsize, 2, tmp);
+
+ *(float *)&vb[0] = x + sz;
+ *(float *)&vb[1] = y - sz;
+ EMIT_VERT (j, vb, vertsize, 2, tmp);
+
+ *(float *)&vb[0] = x + sz;
+ *(float *)&vb[1] = y + sz;
+ EMIT_VERT (j, vb, vertsize, 2, tmp);
+
+ *(float *)&vb[0] = x + sz;
+ *(float *)&vb[1] = y + sz;
+ EMIT_VERT (j, vb, vertsize, 2, tmp);
+
+ *(float *)&vb[0] = x - sz;
+ *(float *)&vb[1] = y + sz;
+ EMIT_VERT (j, vb, vertsize, 2, tmp);
+
+ *(float *)&vb[0] = x - sz;
+ *(float *)&vb[1] = y - sz;
+ EMIT_VERT (j, vb, vertsize, 2, tmp);
+}
+
+static __inline__ void savage_draw_line (savageContextPtr imesa,
+ savageVertexPtr v0,
+ savageVertexPtr v1 ) {
+ GLuint vertsize = imesa->HwVertexSize;
+ u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize);
+ GLfloat width = imesa->glCtx->Line._Width;
+ GLfloat dx, dy, ix, iy;
+ GLuint j;
+
+ dx = v0->v.x - v1->v.x;
+ dy = v0->v.y - v1->v.y;
+
+ ix = width * .5; iy = 0;
+ if (dx * dx > dy * dy) {
+ iy = ix; ix = 0;
+ }
+
+ *(float *)&vb[0] = v0->v.x - ix;
+ *(float *)&vb[1] = v0->v.y - iy;
+ EMIT_VERT (j, vb, vertsize, 2, v0);
+
+ *(float *)&vb[0] = v1->v.x + ix;
+ *(float *)&vb[1] = v1->v.y + iy;
+ EMIT_VERT (j, vb, vertsize, 2, v1);
+
+ *(float *)&vb[0] = v0->v.x + ix;
+ *(float *)&vb[1] = v0->v.y + iy;
+ EMIT_VERT (j, vb, vertsize, 2, v0);
+
+ *(float *)&vb[0] = v0->v.x - ix;
+ *(float *)&vb[1] = v0->v.y - iy;
+ EMIT_VERT (j, vb, vertsize, 2, v0);
+
+ *(float *)&vb[0] = v1->v.x - ix;
+ *(float *)&vb[1] = v1->v.y - iy;
+ EMIT_VERT (j, vb, vertsize, 2, v1);
+
+ *(float *)&vb[0] = v1->v.x + ix;
+ *(float *)&vb[1] = v1->v.y + iy;
+ EMIT_VERT (j, vb, vertsize, 2, v1);
+}
+
+/* Fallback drawing functions for the ptex hack. Code duplication
+ * (especially lines and points) isn't beautiful, but I didn't feel
+ * like inventing yet another template. :-/
+ */
+#define PTEX_VERTEX( j, tmp, vertex_size, start, v) \
+do { \
+ GLfloat rhw = 1.0 / v->f[vertex_size]; \
+ for ( j = start ; j < vertex_size ; j++ ) \
+ tmp.f[j] = v->f[j]; \
+ tmp.f[3] *= v->f[vertex_size]; \
+ tmp.f[vertex_size-2] *= rhw; \
+ tmp.f[vertex_size-1] *= rhw; \
+} while (0)
+
+static void __inline__ savage_ptex_tri (savageContextPtr imesa,
+ savageVertexPtr v0,
+ savageVertexPtr v1,
+ savageVertexPtr v2) {
+ GLuint vertsize = imesa->HwVertexSize;
+ u_int32_t *vb = savageAllocVtxBuf (imesa, 3*vertsize);
+ savageVertex tmp;
+ GLuint j;
+
+ PTEX_VERTEX (j, tmp, vertsize, 0, v0); EMIT_VERT (j, vb, vertsize, 0, &tmp);
+ PTEX_VERTEX (j, tmp, vertsize, 0, v1); EMIT_VERT (j, vb, vertsize, 0, &tmp);
+ PTEX_VERTEX (j, tmp, vertsize, 0, v2); EMIT_VERT (j, vb, vertsize, 0, &tmp);
+}
+
+static __inline__ void savage_ptex_line (savageContextPtr imesa,
+ savageVertexPtr v0,
+ savageVertexPtr v1 ) {
+ GLuint vertsize = imesa->HwVertexSize;
+ u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize);
+ GLfloat width = imesa->glCtx->Line._Width;
+ GLfloat dx, dy, ix, iy;
+ savageVertex tmp0, tmp1;
+ GLuint j;
+
+ PTEX_VERTEX (j, tmp0, vertsize, 2, v0);
+ PTEX_VERTEX (j, tmp1, vertsize, 2, v1);
+
+ dx = v0->v.x - v1->v.x;
+ dy = v0->v.y - v1->v.y;
+
+ ix = width * .5; iy = 0;
+ if (dx * dx > dy * dy) {
+ iy = ix; ix = 0;
+ }
+
+ *(float *)&vb[0] = v0->v.x - ix;
+ *(float *)&vb[1] = v0->v.y - iy;
+ EMIT_VERT (j, vb, vertsize, 2, &tmp0);
+
+ *(float *)&vb[0] = v1->v.x + ix;
+ *(float *)&vb[1] = v1->v.y + iy;
+ EMIT_VERT (j, vb, vertsize, 2, &tmp1);
+
+ *(float *)&vb[0] = v0->v.x + ix;
+ *(float *)&vb[1] = v0->v.y + iy;
+ EMIT_VERT (j, vb, vertsize, 2, &tmp0);
+
+ *(float *)&vb[0] = v0->v.x - ix;
+ *(float *)&vb[1] = v0->v.y - iy;
+ EMIT_VERT (j, vb, vertsize, 2, &tmp0);
+
+ *(float *)&vb[0] = v1->v.x - ix;
+ *(float *)&vb[1] = v1->v.y - iy;
+ EMIT_VERT (j, vb, vertsize, 2, &tmp1);
+
+ *(float *)&vb[0] = v1->v.x + ix;
+ *(float *)&vb[1] = v1->v.y + iy;
+ EMIT_VERT (j, vb, vertsize, 2, &tmp1);
+}
+
+static __inline__ void savage_ptex_point (savageContextPtr imesa,
+ savageVertexPtr v0) {
+ GLuint vertsize = imesa->HwVertexSize;
+ u_int32_t *vb = savageAllocVtxBuf (imesa, 6*vertsize);
+ const GLfloat x = v0->v.x;
+ const GLfloat y = v0->v.y;
+ const GLfloat sz = imesa->glCtx->Point._Size * .5;
+ savageVertex tmp;
+ GLuint j;
+
+ PTEX_VERTEX (j, tmp, vertsize, 2, v0);
+
+ *(float *)&vb[0] = x - sz;
+ *(float *)&vb[1] = y - sz;
+ EMIT_VERT (j, vb, vertsize, 2, &tmp);
+
+ *(float *)&vb[0] = x + sz;
+ *(float *)&vb[1] = y - sz;
+ EMIT_VERT (j, vb, vertsize, 2, &tmp);
+
+ *(float *)&vb[0] = x + sz;
+ *(float *)&vb[1] = y + sz;
+ EMIT_VERT (j, vb, vertsize, 2, &tmp);
+
+ *(float *)&vb[0] = x + sz;
+ *(float *)&vb[1] = y + sz;
+ EMIT_VERT (j, vb, vertsize, 2, &tmp);
+
+ *(float *)&vb[0] = x - sz;
+ *(float *)&vb[1] = y + sz;
+ EMIT_VERT (j, vb, vertsize, 2, &tmp);
+
+ *(float *)&vb[0] = x - sz;
+ *(float *)&vb[1] = y - sz;
+ EMIT_VERT (j, vb, vertsize, 2, &tmp);
+}
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ if (DO_FALLBACK) \
+ imesa->draw_tri( imesa, a, b, c ); \
+ else \
+ savage_draw_triangle( imesa, a, b, c ); \
+} while (0)
+
+#define QUAD( a, b, c, d ) \
+do { \
+ if (DO_FALLBACK) { \
+ imesa->draw_tri( imesa, a, b, d ); \
+ imesa->draw_tri( imesa, b, c, d ); \
+ } else \
+ savage_draw_quad( imesa, a, b, c, d ); \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ if (DO_FALLBACK) \
+ imesa->draw_line( imesa, v0, v1 ); \
+ else \
+ savage_draw_line( imesa, v0, v1 ); \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ if (DO_FALLBACK) \
+ imesa->draw_point( imesa, v0 ); \
+ else \
+ savage_draw_point( imesa, v0 ); \
+} while (0)
+
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define SAVAGE_OFFSET_BIT 0x1
+#define SAVAGE_TWOSIDE_BIT 0x2
+#define SAVAGE_UNFILLED_BIT 0x4
+#define SAVAGE_FALLBACK_BIT 0x8
+#define SAVAGE_MAX_TRIFUNC 0x10
+
+
+static struct {
+ tnl_points_func points;
+ tnl_line_func line;
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
+} rast_tab[SAVAGE_MAX_TRIFUNC];
+
+
+#define DO_FALLBACK (IND & SAVAGE_FALLBACK_BIT)
+#define DO_OFFSET (IND & SAVAGE_OFFSET_BIT)
+#define DO_UNFILLED (IND & SAVAGE_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & SAVAGE_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 1
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX savageVertex
+#define TAB rast_tab
+
+#define DEPTH_SCALE imesa->depth_scale
+#define REVERSE_DEPTH 1
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a > 0)
+#define GET_VERTEX(e) (imesa->verts + (e * imesa->vertex_size * sizeof(int)))
+
+#define VERT_SET_RGBA( v, c ) \
+do { \
+ savage_color_t *color = (savage_color_t *)&((v)->ub4[coloroffset]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \
+} while (0)
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
+
+#define VERT_SET_SPEC( v, c ) \
+do { \
+ if (specoffset) { \
+ savage_color_t *spec = (savage_color_t *)&((v)->ub4[specoffset]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(spec->red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(spec->green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(spec->blue, (c)[2]); \
+ } \
+} while (0)
+#define VERT_COPY_SPEC( v0, v1 ) \
+ if (specoffset) COPY_3V(v0->ub4[specoffset], v1->ub4[specoffset])
+#define VERT_SAVE_SPEC( idx ) \
+ if (specoffset) spec[idx] = v[idx]->ui[specoffset]
+#define VERT_RESTORE_SPEC( idx ) \
+ if (specoffset) v[idx]->ui[specoffset] = spec[idx]
+
+#define LOCAL_VARS(n) \
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx); \
+ GLuint color[n], spec[n]; \
+ GLuint coloroffset = \
+ ((imesa->skip & SAVAGE_SKIP_W) ? 3 : 4); \
+ GLboolean specoffset = \
+ ((imesa->skip & SAVAGE_SKIP_C1) ? 0 : coloroffset+1); \
+ (void) color; (void) spec; (void) coloroffset; (void) specoffset;
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+#define RASTERIZE(x) if (imesa->raster_primitive != reduced_prim[x]) \
+ savageRasterPrimitive( ctx, x )
+#define RENDER_PRIMITIVE imesa->render_primitive
+#define IND SAVAGE_FALLBACK_BIT
+#define TAG(x) x
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
+
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SAVAGE_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SAVAGE_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SAVAGE_TWOSIDE_BIT|SAVAGE_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SAVAGE_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SAVAGE_OFFSET_BIT|SAVAGE_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SAVAGE_TWOSIDE_BIT|SAVAGE_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SAVAGE_TWOSIDE_BIT|SAVAGE_OFFSET_BIT|SAVAGE_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SAVAGE_FALLBACK_BIT)
+#define TAG(x) x##_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SAVAGE_OFFSET_BIT|SAVAGE_FALLBACK_BIT)
+#define TAG(x) x##_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SAVAGE_TWOSIDE_BIT|SAVAGE_FALLBACK_BIT)
+#define TAG(x) x##_twoside_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SAVAGE_TWOSIDE_BIT|SAVAGE_OFFSET_BIT|SAVAGE_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SAVAGE_UNFILLED_BIT|SAVAGE_FALLBACK_BIT)
+#define TAG(x) x##_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SAVAGE_OFFSET_BIT|SAVAGE_UNFILLED_BIT|SAVAGE_FALLBACK_BIT)
+#define TAG(x) x##_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SAVAGE_TWOSIDE_BIT|SAVAGE_UNFILLED_BIT|SAVAGE_FALLBACK_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SAVAGE_TWOSIDE_BIT|SAVAGE_OFFSET_BIT|SAVAGE_UNFILLED_BIT| \
+ SAVAGE_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+static void init_rast_tab( void )
+{
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+ init_fallback();
+ init_offset_fallback();
+ init_twoside_fallback();
+ init_twoside_offset_fallback();
+ init_unfilled_fallback();
+ init_offset_unfilled_fallback();
+ init_twoside_unfilled_fallback();
+ init_twoside_offset_unfilled_fallback();
+}
+
+
+
+/***********************************************************************
+ * Rasterization fallback helpers *
+ ***********************************************************************/
+
+
+/* This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+static void
+savage_fallback_tri( savageContextPtr imesa,
+ savageVertexPtr v0,
+ savageVertexPtr v1,
+ savageVertexPtr v2 )
+{
+ GLcontext *ctx = imesa->glCtx;
+ SWvertex v[3];
+ FLUSH_BATCH(imesa);
+ WAIT_IDLE_EMPTY(imesa);
+ _swsetup_Translate( ctx, v0, &v[0] );
+ _swsetup_Translate( ctx, v1, &v[1] );
+ _swsetup_Translate( ctx, v2, &v[2] );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+}
+
+
+static void
+savage_fallback_line( savageContextPtr imesa,
+ savageVertexPtr v0,
+ savageVertexPtr v1 )
+{
+ GLcontext *ctx = imesa->glCtx;
+ SWvertex v[2];
+ FLUSH_BATCH(imesa);
+ WAIT_IDLE_EMPTY(imesa);
+ _swsetup_Translate( ctx, v0, &v[0] );
+ _swsetup_Translate( ctx, v1, &v[1] );
+ _swrast_Line( ctx, &v[0], &v[1] );
+}
+
+
+static void
+savage_fallback_point( savageContextPtr imesa,
+ savageVertexPtr v0 )
+{
+ GLcontext *ctx = imesa->glCtx;
+ SWvertex v[1];
+ FLUSH_BATCH(imesa);
+ WAIT_IDLE_EMPTY(imesa);
+ _swsetup_Translate( ctx, v0, &v[0] );
+ _swrast_Point( ctx, &v[0] );
+}
+
+
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+#define VERT(x) (savageVertexPtr)(savageVerts + (x * vertsize * sizeof(int)))
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ savage_draw_point( imesa, VERT(start) )
+#define RENDER_LINE( v0, v1 ) \
+ savage_draw_line( imesa, VERT(v0), VERT(v1) )
+#define RENDER_TRI( v0, v1, v2 ) \
+ savage_draw_triangle( imesa, VERT(v0), VERT(v1), VERT(v2) )
+#define RENDER_QUAD( v0, v1, v2, v3 ) \
+ savage_draw_quad( imesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
+#define INIT(x) do { \
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__); \
+ savageRenderPrimitive( ctx, x ); \
+ /*SAVAGE_CONTEXT(ctx)->render_primitive = x;*/ \
+} while (0)
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx); \
+ const GLuint vertsize = imesa->vertex_size; \
+ const char *savageVerts = (char *)imesa->verts; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ (void) elt;
+#define RESET_STIPPLE
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) (x)
+#define TAG(x) savage_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+#undef ELT
+#undef TAG
+#define TAG(x) savage_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl/t_vb_rendertmp.h"
+
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+static void savageRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+ }
+}
+
+static void savageRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Line( ctx, ii, jj );
+}
+/*
+static void savageFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ r128ContextPtr rmesa = R128_CONTEXT( ctx );
+ GLuint vertsize = rmesa->vertex_size;
+ GLuint *vb = r128AllocDmaLow( rmesa, (n-2) * 3 * 4 * vertsize );
+ GLubyte *r128verts = (GLubyte *)rmesa->verts;
+ const GLuint shift = rmesa->vertex_stride_shift;
+ const GLuint *start = (const GLuint *)VERT(elts[0]);
+ int i,j;
+
+ rmesa->num_verts += (n-2) * 3;
+
+ for (i = 2 ; i < n ; i++) {
+ COPY_DWORDS( j, vb, vertsize, (r128VertexPtr) start );
+ COPY_DWORDS( j, vb, vertsize, (r128VertexPtr) VERT(elts[i-1]) );
+ COPY_DWORDS( j, vb, vertsize, (r128VertexPtr) VERT(elts[i]) );
+ }
+}
+*/
+
+
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+#define _SAVAGE_NEW_RENDER_STATE (_DD_NEW_LINE_STIPPLE | \
+ _DD_NEW_LINE_SMOOTH | \
+ _DD_NEW_POINT_SMOOTH | \
+ _DD_NEW_TRI_STIPPLE | \
+ _DD_NEW_TRI_SMOOTH | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET) \
+
+/* original driver didn't have DD_POINT_SMOOTH. really needed? */
+#define POINT_FALLBACK (DD_POINT_SMOOTH)
+#define LINE_FALLBACK (DD_LINE_STIPPLE|DD_LINE_SMOOTH)
+#define TRI_FALLBACK (DD_TRI_STIPPLE|DD_TRI_SMOOTH)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)
+#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
+
+
+static void savageChooseRenderState(GLcontext *ctx)
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ /* Hook in fallback functions for the ptex hack. Do this first, so
+ * that a real fallback will overwrite them with the respective
+ * savage_fallback_... function.
+ */
+ if (imesa->ptexHack) {
+ /* Do textures make sense with points? */
+ imesa->draw_point = savage_ptex_point;
+ imesa->draw_line = savage_ptex_line;
+ imesa->draw_tri = savage_ptex_tri;
+ index |= SAVAGE_FALLBACK_BIT;
+ } else {
+ imesa->draw_point = savage_draw_point;
+ imesa->draw_line = savage_draw_line;
+ imesa->draw_tri = savage_draw_triangle;
+ }
+
+ if (flags & (ANY_RASTER_FLAGS|ANY_FALLBACK_FLAGS)) {
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= SAVAGE_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= SAVAGE_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= SAVAGE_UNFILLED_BIT;
+ }
+
+ /* Hook in fallbacks for specific primitives.
+ */
+ if (flags & ANY_FALLBACK_FLAGS) {
+ if (flags & POINT_FALLBACK) imesa->draw_point = savage_fallback_point;
+ if (flags & LINE_FALLBACK) imesa->draw_line = savage_fallback_line;
+ if (flags & TRI_FALLBACK) imesa->draw_tri = savage_fallback_tri;
+ index |= SAVAGE_FALLBACK_BIT;
+ if (SAVAGE_DEBUG & DEBUG_FALLBACKS) {
+ fprintf (stderr, "Per-primitive fallback, TriangleCaps=0x%x\n",
+ ctx->_TriangleCaps);
+ }
+ }
+ }
+
+ if (index != imesa->RenderIndex) {
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = savage_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = savage_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = rast_tab[index].line;
+ tnl->Driver.Render.ClippedPolygon = savageRenderClippedPoly/*r128FastRenderClippedPoly*/;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = savageRenderClippedLine;
+ tnl->Driver.Render.ClippedPolygon = savageRenderClippedPoly;
+ }
+
+ imesa->RenderIndex = index;
+ }
+}
+
+/**********************************************************************/
+/* Validate state at pipeline start */
+/**********************************************************************/
+
+static void savageRunPipeline( GLcontext *ctx )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+
+ if (imesa->no_rast)
+ FALLBACK(ctx, SAVAGE_FALLBACK_NORAST, GL_TRUE);
+
+ if (imesa->new_state)
+ savageDDUpdateHwState( ctx );
+
+ if (!imesa->Fallback) {
+ if (imesa->new_gl_state & _SAVAGE_NEW_RENDER_STATE)
+ savageChooseRenderState( ctx );
+
+ /* choose the correct primitive type for tnl rendering */
+ if (imesa->savageScreen->chipset < S3_SAVAGE4 &&
+ (ctx->_TriangleCaps & DD_FLATSHADE)) {
+ if (imesa->HwPrim != SAVAGE_PRIM_TRILIST_201)
+ savageFlushVertices(imesa);
+ imesa->HwPrim = SAVAGE_PRIM_TRILIST_201;
+ } else {
+ if (imesa->HwPrim != SAVAGE_PRIM_TRILIST)
+ savageFlushVertices(imesa);
+ imesa->HwPrim = SAVAGE_PRIM_TRILIST;
+ }
+
+ imesa->new_gl_state = 0;
+ }
+
+ _tnl_run_pipeline( ctx );
+
+ if (imesa->no_rast)
+ FALLBACK(ctx, SAVAGE_FALLBACK_NORAST, GL_FALSE);
+}
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+/* 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 savageRasterPrimitive( GLcontext *ctx, GLuint prim )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT( ctx );
+
+ /* Update culling */
+ if (imesa->raster_primitive != prim) {
+ imesa->raster_primitive = prim;
+ imesa->new_state |= SAVAGE_NEW_CULL;
+ savageDDUpdateHwState (ctx);
+ }
+
+#if 0
+ if (ctx->Polygon.StippleFlag && mmesa->haveHwStipple)
+ {
+ mmesa->dirty |= MGA_UPLOAD_CONTEXT;
+ mmesa->setup.dwgctl &= ~(0xf<<20);
+ if (mmesa->raster_primitive == GL_TRIANGLES)
+ mmesa->setup.dwgctl |= mmesa->poly_stipple;
+ }
+#endif
+}
+
+static void savageRenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ GLuint rprim = reduced_prim[prim];
+
+ imesa->render_primitive = prim;
+
+ if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ return;
+
+ if (imesa->raster_primitive != rprim) {
+ savageRasterPrimitive( ctx, rprim );
+ }
+}
+
+/* Check if projective texture coordinates are used and if we can fake
+ * them. Fallback to swrast we can't. Returns GL_TRUE if projective
+ * texture coordinates must be faked, GL_FALSE otherwise.
+ */
+static GLboolean savageCheckPTexHack( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint index = tnl->render_inputs;
+
+ if (index & _TNL_BIT_TEX(0) && VB->TexCoordPtr[0]->size == 4) {
+ if ((index & _TNL_BITS_TEX_ANY) == _TNL_BIT_TEX(0))
+ return GL_TRUE; /* apply ptex hack */
+ else
+ FALLBACK(ctx, SAVAGE_FALLBACK_PROJ_TEXTURE, GL_TRUE);
+ }
+ if ((index & _TNL_BIT_TEX(1)) && VB->TexCoordPtr[1]->size == 4)
+ FALLBACK(ctx, SAVAGE_FALLBACK_PROJ_TEXTURE, GL_TRUE);
+
+ return GL_FALSE; /* don't apply ptex hack */
+}
+
+
+#define DO_EMIT_ATTR( ATTR, STYLE ) \
+do { \
+ imesa->vertex_attrs[imesa->vertex_attr_count].attrib = (ATTR); \
+ imesa->vertex_attrs[imesa->vertex_attr_count].format = (STYLE); \
+ imesa->vertex_attr_count++; \
+} while (0)
+
+#define NEED_ATTR( INDEX, SKIP ) \
+do { \
+ setupIndex |= (INDEX); \
+ skip &= ~(SKIP); \
+} while (0)
+
+#define EMIT_ATTR( ATTR, STYLE, INDEX, SKIP ) \
+do { \
+ NEED_ATTR( INDEX, SKIP ); \
+ DO_EMIT_ATTR( ATTR, STYLE ); \
+} while (0)
+
+#define EMIT_PAD( N ) \
+do { \
+ imesa->vertex_attrs[imesa->vertex_attr_count].attrib = 0; \
+ imesa->vertex_attrs[imesa->vertex_attr_count].format = EMIT_PAD; \
+ imesa->vertex_attrs[imesa->vertex_attr_count].offset = (N); \
+ imesa->vertex_attr_count++; \
+} while (0)
+
+#define SAVAGE_EMIT_XYZ 0x0001
+#define SAVAGE_EMIT_W 0x0002
+#define SAVAGE_EMIT_C0 0x0004
+#define SAVAGE_EMIT_C1 0x0008
+#define SAVAGE_EMIT_FOG 0x0010
+#define SAVAGE_EMIT_S0 0x0020
+#define SAVAGE_EMIT_T0 0x0040
+#define SAVAGE_EMIT_Q0 0x0080
+#define SAVAGE_EMIT_ST0 0x0060
+#define SAVAGE_EMIT_STQ0 0x00e0
+#define SAVAGE_EMIT_S1 0x0100
+#define SAVAGE_EMIT_T1 0x0200
+#define SAVAGE_EMIT_ST1 0x0300
+
+
+static __inline__ GLuint savageChooseVertexFormat_s3d( GLcontext *ctx )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint index = tnl->render_inputs;
+ GLuint setupIndex = SAVAGE_EMIT_XYZ;
+ GLubyte skip;
+
+ imesa->vertex_attr_count = 0;
+
+ skip = SAVAGE_SKIP_ALL_S3D;
+ skip &= ~SAVAGE_SKIP_Z; /* all mesa vertices have a z coordinate */
+
+ /* EMIT_ATTR's must be in order as they tell t_vertex.c how to
+ * build up a hardware vertex.
+ */
+ if ((index & _TNL_BITS_TEX_ANY) || !(ctx->_TriangleCaps & DD_FLATSHADE))
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, SAVAGE_EMIT_W, SAVAGE_SKIP_W );
+ else {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, 0, 0 );
+ EMIT_PAD( 4 );
+ skip &= ~SAVAGE_SKIP_W;
+ }
+
+ /* t_context.c always includes a diffuse color */
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, SAVAGE_EMIT_C0, SAVAGE_SKIP_C0 );
+
+ if ((index & _TNL_BIT_COLOR1))
+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, SAVAGE_EMIT_C1, SAVAGE_SKIP_C1 );
+ else
+ EMIT_PAD( 3 );
+ if ((index & _TNL_BIT_FOG))
+ EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, SAVAGE_EMIT_FOG, SAVAGE_SKIP_C1 );
+ else
+ EMIT_PAD( 1 );
+ skip &= ~SAVAGE_SKIP_C1;
+
+ if (index & _TNL_BIT_TEX(0)) {
+ if (imesa->ptexHack)
+ EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_3F_XYW, SAVAGE_EMIT_STQ0, SAVAGE_SKIP_ST0);
+ else if (VB->TexCoordPtr[0]->size == 4)
+ assert (0); /* should be caught by savageCheckPTexHack */
+ else if (VB->TexCoordPtr[0]->size >= 2)
+ /* The chromium menu emits some 3D tex coords even though no
+ * 3D texture is enabled. Ignore the 3rd coordinate. */
+ EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F, SAVAGE_EMIT_ST0, SAVAGE_SKIP_ST0 );
+ else if (VB->TexCoordPtr[0]->size == 1) {
+ EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_1F, SAVAGE_EMIT_S0, SAVAGE_SKIP_S0 );
+ EMIT_PAD( 4 );
+ } else
+ EMIT_PAD( 8 );
+ } else
+ EMIT_PAD( 8 );
+ skip &= ~SAVAGE_SKIP_ST0;
+
+ assert (skip == 0);
+ imesa->skip = skip;
+ return setupIndex;
+}
+
+
+static __inline__ GLuint savageChooseVertexFormat_s4( GLcontext *ctx )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint index = tnl->render_inputs;
+ GLuint setupIndex = SAVAGE_EMIT_XYZ;
+ GLubyte skip;
+ GLuint size, mask;
+
+ skip = SAVAGE_SKIP_ALL_S4;
+ skip &= ~SAVAGE_SKIP_Z; /* all mesa vertices have a z coordinate */
+
+ if ((index & _TNL_BITS_TEX_ANY) || !(ctx->_TriangleCaps & DD_FLATSHADE))
+ NEED_ATTR( SAVAGE_EMIT_W, SAVAGE_SKIP_W );
+
+ /* t_context.c always includes a diffuse color */
+ NEED_ATTR( SAVAGE_EMIT_C0, SAVAGE_SKIP_C0 );
+
+ if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) {
+ if ((index & _TNL_BIT_COLOR1))
+ NEED_ATTR( SAVAGE_EMIT_C1, SAVAGE_SKIP_C1 );
+ if ((index & _TNL_BIT_FOG))
+ NEED_ATTR( SAVAGE_EMIT_FOG, SAVAGE_SKIP_C1 );
+ }
+
+ if (index & _TNL_BIT_TEX(0)) {
+ if (imesa->ptexHack)
+ NEED_ATTR( SAVAGE_EMIT_STQ0, SAVAGE_SKIP_ST0);
+ else if (VB->TexCoordPtr[0]->size == 4)
+ assert (0); /* should be caught by savageCheckPTexHack */
+ else if (VB->TexCoordPtr[0]->size >= 2)
+ /* The chromium menu emits some 3D tex coords even though no
+ * 3D texture is enabled. Ignore the 3rd coordinate. */
+ NEED_ATTR( SAVAGE_EMIT_ST0, SAVAGE_SKIP_ST0 );
+ else
+ NEED_ATTR( SAVAGE_EMIT_S0, SAVAGE_SKIP_S0 );
+ }
+ if (index & _TNL_BIT_TEX(1)) {
+ if (VB->TexCoordPtr[1]->size == 4)
+ /* projective textures are not supported by the hardware */
+ assert (0); /* should be caught by savageCheckPTexHack */
+ else if (VB->TexCoordPtr[1]->size >= 2)
+ NEED_ATTR( SAVAGE_EMIT_ST1, SAVAGE_SKIP_ST1 );
+ else
+ NEED_ATTR( SAVAGE_EMIT_S1, SAVAGE_SKIP_S1 );
+ }
+
+ /* if nothing changed we can skip the rest */
+ if (setupIndex == imesa->SetupIndex && imesa->vertex_size != 0)
+ return setupIndex;
+
+ if (imesa->enable_vdma) {
+ mask = SAVAGE_SKIP_W;
+ size = 10 - (skip & 1) - (skip >> 1 & 1) -
+ (skip >> 2 & 1) - (skip >> 3 & 1) - (skip >> 4 & 1) -
+ (skip >> 5 & 1) - (skip >> 6 & 1) - (skip >> 7 & 1);
+
+ while (size < 8) {
+ if (skip & mask) {
+ skip &= ~mask;
+ size++;
+ }
+ mask <<= 1;
+ }
+ }
+
+ imesa->vertex_attr_count = 0;
+
+ if (skip & SAVAGE_SKIP_W)
+ DO_EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT );
+ else if (setupIndex & SAVAGE_EMIT_W)
+ DO_EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT );
+ else {
+ DO_EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT );
+ EMIT_PAD( 4 );
+ }
+
+ DO_EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA );
+
+ if (!(skip & SAVAGE_SKIP_C1)) {
+ if (!(setupIndex & (SAVAGE_EMIT_C1|SAVAGE_EMIT_FOG)))
+ EMIT_PAD( 4 );
+ else {
+ if (setupIndex & SAVAGE_EMIT_C1)
+ DO_EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR );
+ else
+ EMIT_PAD( 3 );
+ if (setupIndex & SAVAGE_EMIT_FOG)
+ DO_EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F );
+ else
+ EMIT_PAD( 1 );
+ }
+ }
+
+ if ((skip & SAVAGE_SKIP_ST0) != SAVAGE_SKIP_ST0) {
+ if ((setupIndex & SAVAGE_EMIT_STQ0) == SAVAGE_EMIT_STQ0)
+ DO_EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_3F_XYW );
+ else if ((setupIndex & SAVAGE_EMIT_ST0) == SAVAGE_EMIT_ST0)
+ DO_EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F );
+ else if ((setupIndex & SAVAGE_EMIT_ST0) == SAVAGE_EMIT_S0) {
+ DO_EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_1F );
+ if (!(skip & SAVAGE_SKIP_T0)) EMIT_PAD( 4 );
+ } else {
+ if (!(skip & SAVAGE_SKIP_S0)) EMIT_PAD( 4 );
+ if (!(skip & SAVAGE_SKIP_T0)) EMIT_PAD( 4 );
+ }
+ }
+
+ if ((skip & SAVAGE_SKIP_ST1) != SAVAGE_SKIP_ST1) {
+ if ((setupIndex & SAVAGE_EMIT_ST1) == SAVAGE_EMIT_ST1)
+ DO_EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_2F );
+ else if ((setupIndex & SAVAGE_EMIT_ST1) == SAVAGE_EMIT_S1) {
+ DO_EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_1F );
+ if (!(skip & SAVAGE_SKIP_T1)) EMIT_PAD( 4 );
+ } else {
+ if (!(skip & SAVAGE_SKIP_S1)) EMIT_PAD( 4 );
+ if (!(skip & SAVAGE_SKIP_T1)) EMIT_PAD( 4 );
+ }
+ }
+
+ imesa->skip = skip;
+ return setupIndex;
+}
+
+
+static void savageRenderStart( GLcontext *ctx )
+{
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint setupIndex = SAVAGE_EMIT_XYZ;
+ GLboolean ptexHack;
+
+ /* Check if we need to apply the ptex hack. Choose a new render
+ * state if necessary. (Note: this can't be done in
+ * savageRunPipeline, since the number of vertex coordinates can
+ * change in the pipeline. texmat or texgen or both?) */
+ ptexHack = savageCheckPTexHack( ctx );
+ if (ptexHack != imesa->ptexHack) {
+ imesa->ptexHack = ptexHack;
+ savageChooseRenderState (ctx);
+ }
+ /* Handle fallback cases identified in savageCheckPTexHack. */
+ if (SAVAGE_CONTEXT(ctx)->Fallback) {
+ tnl->Driver.Render.Start(ctx);
+ return;
+ }
+
+ /* Important:
+ */
+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
+
+ if (imesa->savageScreen->chipset < S3_SAVAGE4) {
+ setupIndex = savageChooseVertexFormat_s3d(ctx);
+ } else {
+ setupIndex = savageChooseVertexFormat_s4(ctx);
+ }
+
+ /* Need to change the vertex emit code if the SetupIndex changed or
+ * is set for the first time (indicated by vertex_size == 0). */
+ if (setupIndex != imesa->SetupIndex || imesa->vertex_size == 0) {
+ GLuint hwVertexSize;
+ imesa->vertex_size =
+ _tnl_install_attrs( ctx,
+ imesa->vertex_attrs,
+ imesa->vertex_attr_count,
+ imesa->hw_viewport, 0 );
+ imesa->vertex_size >>= 2;
+ imesa->SetupIndex = setupIndex;
+
+ hwVertexSize = imesa->vertex_size;
+ if (setupIndex & SAVAGE_EMIT_Q0) {
+ /* The vertex setup code emits homogenous texture
+ * coordinates. They are converted to normal 2D coords by
+ * savage_ptex_tri/line/point. Now we have two different
+ * vertex sizes. Functions that emit vertices to the hardware
+ * need to use HwVertexSize, anything that manipulates the
+ * vertices generated by t_vertex uses vertex_size. */
+ hwVertexSize--;
+ assert (imesa->ptexHack);
+ } else
+ assert (!imesa->ptexHack);
+
+ if (hwVertexSize != imesa->HwVertexSize) {
+ /* Changing the vertex size: flush vertex and command buffer and
+ * discard the DMA buffer, if we were using one. */
+ savageFlushVertices(imesa);
+ savageFlushCmdBuf(imesa, GL_TRUE);
+ if (hwVertexSize == 8 && imesa->enable_vdma) {
+ if (SAVAGE_DEBUG & DEBUG_DMA)
+ fprintf (stderr, "Using DMA, skip=0x%02x\n", imesa->skip);
+ /* we can use vertex dma */
+ imesa->vtxBuf = &imesa->dmaVtxBuf;
+ } else {
+ if (SAVAGE_DEBUG & DEBUG_DMA)
+ fprintf (stderr, "Not using DMA, skip=0x%02x\n", imesa->skip);
+ imesa->vtxBuf = &imesa->clientVtxBuf;
+ }
+ imesa->HwVertexSize = hwVertexSize;
+ }
+ }
+}
+
+static void savageRenderFinish( GLcontext *ctx )
+{
+ /* Flush the last primitive now, before any state is changed. */
+ savageFlushVertices(SAVAGE_CONTEXT(ctx));
+
+ if (SAVAGE_CONTEXT(ctx)->RenderIndex & SAVAGE_FALLBACK_BIT)
+ _swrast_flush( ctx );
+}
+
+
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+
+static const char * const fallbackStrings[] = {
+ "Texture mode",
+ "Draw buffer",
+ "Read buffer",
+ "Color mask",
+ "Specular",
+ "LogicOp",
+ "glEnable(GL_STENCIL) without hw stencil buffer",
+ "glRenderMode(selection or feedback)",
+ "glBlendEquation",
+ "Hardware rasterization disabled",
+ "Projective texture",
+};
+
+void savageFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ savageContextPtr imesa = SAVAGE_CONTEXT(ctx);
+ GLuint oldfallback = imesa->Fallback;
+ GLuint index;
+ for (index = 0; (1 << index) < bit; ++index);
+
+ if (mode) {
+ imesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ /* the first fallback */
+ _swsetup_Wakeup( ctx );
+ imesa->RenderIndex = ~0;
+ }
+ if (!(oldfallback & bit) && (SAVAGE_DEBUG & DEBUG_FALLBACKS))
+ fprintf (stderr, "Savage begin fallback: 0x%x %s\n",
+ bit, fallbackStrings[index]);
+ }
+ else {
+ imesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ /* the last fallback */
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = savageRenderStart;
+ tnl->Driver.Render.PrimitiveNotify = savageRenderPrimitive;
+ tnl->Driver.Render.Finish = savageRenderFinish;
+
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+
+ _tnl_invalidate_vertex_state( ctx, ~0 );
+ _tnl_invalidate_vertices( ctx, ~0 );
+ _tnl_install_attrs( ctx,
+ imesa->vertex_attrs,
+ imesa->vertex_attr_count,
+ imesa->hw_viewport, 0 );
+
+ imesa->new_gl_state |= _SAVAGE_NEW_RENDER_STATE;
+ }
+ if ((oldfallback & bit) && (SAVAGE_DEBUG & DEBUG_FALLBACKS))
+ fprintf (stderr, "Savage end fallback: 0x%x %s\n",
+ bit, fallbackStrings[index]);
+ }
+}
+
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+void savageInitTriFuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+ }
+
+ tnl->Driver.RunPipeline = savageRunPipeline;
+ tnl->Driver.Render.Start = savageRenderStart;
+ tnl->Driver.Render.Finish = savageRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = savageRenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+
+ _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
+ (6 + 2*ctx->Const.MaxTextureUnits) * sizeof(GLfloat) );
+
+ SAVAGE_CONTEXT(ctx)->verts = (char *)tnl->clipspace.vertex_buf;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagetris.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagetris.h
new file mode 100644
index 000000000..00803e7ff
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/savagetris.h
@@ -0,0 +1,49 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tris.h,v 1.4 2001/01/08 01:07:24 martin Exp $ */
+/**************************************************************************
+
+Copyright 2000, 2001 ATI Technologies Inc., Ontario, Canada, and
+ VA Linux Systems Inc., Fremont, 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
+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, VA LINUX SYSTEMS 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:
+ * Keith Whitwell <keithw@valinux.com>
+ * Felix Kuehling <fxkuehl@gmx.de>
+ *
+ */
+
+#ifndef __R128_TRIS_H__
+#define __R128_TRIS_H__
+
+#include "mtypes.h"
+
+extern void savageInitTriFuncs( GLcontext *ctx );
+
+
+extern void savageFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
+#define FALLBACK( ctx, bit, mode ) savageFallback( ctx, bit, mode )
+
+
+#endif /* __R128_TRIS_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/server/savage_dri.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/server/savage_dri.h
new file mode 100644
index 000000000..214d9851a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/savage/server/savage_dri.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+#ifndef __SAVAGE_DRI_H__
+#define __SAVAGE_DRI_H__
+
+#include "drm.h"
+
+typedef struct {
+ int chipset;
+ int width;
+ int height;
+ int mem;
+ int cpp;
+ int zpp;
+
+ int agpMode; /* 0 for PCI cards */
+
+ unsigned int sarea_priv_offset;
+
+ unsigned int bufferSize; /* size of DMA buffers */
+
+ unsigned int frontbufferSize;
+ unsigned int frontOffset;
+
+ unsigned int backbufferSize;
+ unsigned int backOffset;
+
+ unsigned int depthbufferSize;
+ unsigned int depthOffset;
+
+ unsigned int textureOffset;
+ unsigned int textureSize;
+ int logTextureGranularity;
+
+ /* Linear aperture */
+ drm_handle_t apertureHandle;
+ unsigned int apertureSize;
+ unsigned int aperturePitch; /* in byte */
+
+ /* Status page (probably not needed, but no harm, read-only) */
+ drm_handle_t statusHandle;
+ unsigned int statusSize;
+
+ /* AGP textures */
+ drm_handle_t agpTextureHandle;
+ unsigned int agpTextureSize;
+ int logAgpTextureGranularity;
+
+ /* Not sure about this one */
+ drm_handle_t xvmcSurfHandle; /* ? */
+} SAVAGEDRIRec, *SAVAGEDRIPtr;
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/Makefile
new file mode 100644
index 000000000..32c64bdbf
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/Makefile
@@ -0,0 +1,35 @@
+# src/mesa/drivers/dri/sis/Makefile
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = sis_dri.so
+
+
+# Not yet
+# MINIGLX_SOURCES = server/sis_dri.c
+
+DRIVER_SOURCES = \
+ sis_alloc.c \
+ sis_clear.c \
+ sis_context.c \
+ sis_dd.c \
+ sis_fog.c \
+ sis_lock.c \
+ sis_screen.c \
+ sis_span.c \
+ sis_state.c \
+ sis_stencil.c \
+ sis_tex.c \
+ sis_texstate.c \
+ sis_tris.c
+
+C_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+include ../Makefile.template
+
+symlinks:
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/server/sis_common.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/server/sis_common.h
new file mode 100644
index 000000000..cbddf0c73
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/server/sis_common.h
@@ -0,0 +1,63 @@
+/* * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_common.h,v 1.1 2003/08/29 08:52:12 twini Exp $ */
+/*
+ * Common header definitions for SiS 2D/3D/DRM suite
+ *
+ * Copyright (C) 2003 Eric Anholt
+ *
+ * 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 the copyright holder not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The copyright holder makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDER 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.
+ *
+ * Author:
+ * Eric Anholt <anholt@FreeBSD.org>
+ *
+ */
+
+#ifndef _SIS_COMMON_H_
+#define _SIS_COMMON_H_
+
+#define DRM_SIS_FB_ALLOC 0x04
+#define DRM_SIS_FB_FREE 0x05
+#define DRM_SIS_FLIP 0x08
+#define DRM_SIS_FLIP_INIT 0x09
+#define DRM_SIS_FLIP_FINAL 0x10
+#define DRM_SIS_AGP_INIT 0x13
+#define DRM_SIS_AGP_ALLOC 0x14
+#define DRM_SIS_AGP_FREE 0x15
+#define DRM_SIS_FB_INIT 0x16
+
+typedef struct {
+ int context;
+ unsigned long offset;
+ unsigned long size;
+ void *free;
+} drm_sis_mem_t;
+
+typedef struct {
+ unsigned long offset, size;
+} drm_sis_agp_t;
+
+typedef struct {
+ unsigned long offset, size;
+} drm_sis_fb_t;
+
+typedef struct {
+ unsigned int left, right;
+} drm_sis_flip_t;
+
+#endif /* _SIS_COMMON_H_ */
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/server/sis_dri.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/server/sis_dri.h
new file mode 100644
index 000000000..a05662430
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/server/sis_dri.h
@@ -0,0 +1,85 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dri.h,v 1.9 2003/08/29 08:50:54 twini Exp $ */
+
+/* modified from tdfx_dri.h */
+
+#ifndef _SIS_DRI_
+#define _SIS_DRI_
+
+#include "xf86drm.h"
+#include "drm.h"
+
+#define SIS_MAX_DRAWABLES 256
+#define SISIOMAPSIZE (64*1024)
+
+typedef struct {
+ int CtxOwner;
+ int QueueLength;
+ unsigned int AGPCmdBufNext;
+ unsigned int FrameCount;
+#ifdef SIS315DRI
+ /* For 315 series */
+ unsigned long sharedWPoffset;
+#endif
+#if 0
+ unsigned char *AGPCmdBufBase;
+ unsigned long AGPCmdBufAddr;
+ unsigned long AGPCmdBufOffset;
+ unsigned int AGPCmdBufSize;
+ unsigned long AGPCmdBufNext;
+#endif
+} SISSAREAPriv, *SISSAREAPrivPtr;
+
+#define AGPVtxBufNext AGPCmdBufNext
+
+#define SIS_FRONT 0
+#define SIS_BACK 1
+#define SIS_DEPTH 2
+
+typedef struct {
+ drm_handle_t handle;
+ drmSize size;
+} sisRegion, *sisRegionPtr;
+
+typedef struct {
+ sisRegion regs, agp;
+ int deviceID;
+ int width;
+ int height;
+ int mem; /* unused in Mesa 3 DRI */
+ int bytesPerPixel;
+ int priv1; /* unused in Mesa 3 DRI */
+ int priv2; /* unused in Mesa 3 DRI */
+ int fbOffset; /* unused in Mesa 3 DRI */
+ int backOffset; /* unused in Mesa 3 DRI */
+ int depthOffset; /* unused in Mesa 3 DRI */
+ int textureOffset; /* unused in Mesa 3 DRI */
+ int textureSize; /* unused in Mesa 3 DRI */
+ unsigned int AGPCmdBufOffset;
+ unsigned int AGPCmdBufSize;
+ int irqEnabled; /* unused in Mesa 3 DRI */
+ unsigned int scrnX, scrnY; /* unused in Mesa 3 DRI */
+} SISDRIRec, *SISDRIPtr;
+
+#define AGPVtxBufOffset AGPCmdBufOffset
+#define AGPVtxBufSize AGPCmdBufSize
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} SISConfigPrivRec, *SISConfigPrivPtr;
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} SISDRIContextRec, *SISDRIContextPtr;
+
+#ifdef XFree86Server
+
+#include "screenint.h"
+
+Bool SISDRIScreenInit(ScreenPtr pScreen);
+void SISDRICloseScreen(ScreenPtr pScreen);
+Bool SISDRIFinishScreenInit(ScreenPtr pScreen);
+
+#endif
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_alloc.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_alloc.c
new file mode 100644
index 000000000..b808daae3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_alloc.c
@@ -0,0 +1,243 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP 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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_alloc.c,v 1.7 2001/01/08 01:07:29 martin Exp $ */
+
+/*
+ * Authors:
+ * Sung-Ching Lin <sclin@sis.com.tw>
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#include "sis_context.h"
+#include "sis_alloc.h"
+
+#include "sis_common.h"
+
+#include <unistd.h>
+
+#define Z_BUFFER_HW_ALIGNMENT 16
+#define Z_BUFFER_HW_PLUS (16 + 4)
+
+/* 3D engine uses 2, and bitblt uses 4 */
+#define DRAW_BUFFER_HW_ALIGNMENT 16
+#define DRAW_BUFFER_HW_PLUS (16 + 4)
+
+#define ALIGNMENT(value, align) (((value) + (align) - 1) / (align) * (align))
+
+static int _total_video_memory_used = 0;
+static int _total_video_memory_count = 0;
+
+void *
+sisAllocFB( sisContextPtr smesa, GLuint size, void **handle )
+{
+ drm_sis_mem_t fb;
+
+ _total_video_memory_used += size;
+
+ fb.context = smesa->hHWContext;
+ fb.size = size;
+ if (drmCommandWriteRead( smesa->driFd, DRM_SIS_FB_ALLOC, &fb,
+ sizeof(drm_sis_mem_t) ) || fb.offset == 0)
+ {
+ return NULL;
+ }
+ *handle = (void *)fb.free;
+
+ if (SIS_VERBOSE & VERBOSE_SIS_MEMORY) {
+ fprintf(stderr, "sisAllocFB: size=%d, offset=%lu, pid=%d, count=%d\n",
+ size, fb.offset, (GLint)getpid(),
+ ++_total_video_memory_count);
+ }
+
+ return (void *)(smesa->FbBase + fb.offset);
+}
+
+void
+sisFreeFB( sisContextPtr smesa, void *handle )
+{
+ drm_sis_mem_t fb;
+
+ if (SIS_VERBOSE & VERBOSE_SIS_MEMORY) {
+ fprintf(stderr, "sisFreeFB: free=%p, pid=%d, count=%d\n",
+ handle, (GLint)getpid(), --_total_video_memory_count);
+ }
+
+ fb.context = smesa->hHWContext;
+ fb.free = handle;
+ drmCommandWrite( smesa->driFd, DRM_SIS_FB_FREE, &fb, sizeof(drm_sis_mem_t) );
+}
+
+void *
+sisAllocAGP( sisContextPtr smesa, GLuint size, void **handle )
+{
+ drm_sis_mem_t agp;
+
+ if (smesa->AGPSize == 0)
+ return NULL;
+
+ agp.context = smesa->hHWContext;
+ agp.size = size;
+ if (drmCommandWriteRead( smesa->driFd, DRM_SIS_AGP_ALLOC, &agp,
+ sizeof(drm_sis_mem_t) ) || agp.offset == 0)
+ {
+ return NULL;
+ }
+ *handle = (void *)agp.free;
+
+ if (SIS_VERBOSE & VERBOSE_SIS_MEMORY) {
+ fprintf(stderr, "sisAllocAGP: size=%u, offset=%lu, pid=%d, count=%d\n",
+ size, agp.offset, (GLint)getpid(),
+ ++_total_video_memory_count);
+ }
+
+ return (void *)(smesa->AGPBase + agp.offset);
+}
+
+void
+sisFreeAGP( sisContextPtr smesa, void *handle )
+{
+ drm_sis_mem_t agp;
+
+ if (SIS_VERBOSE & VERBOSE_SIS_MEMORY) {
+ fprintf(stderr, "sisFreeAGP: free=%p, pid=%d, count=%d\n",
+ handle, (GLint)getpid(), --_total_video_memory_count);
+ }
+
+ agp.context = smesa->hHWContext;
+ agp.free = handle;
+ drmCommandWrite( smesa->driFd, DRM_SIS_AGP_FREE, &agp,
+ sizeof(drm_sis_mem_t) );
+}
+
+void
+sisAllocZStencilBuffer( sisContextPtr smesa )
+{
+ GLuint z_depth;
+ GLuint totalBytes;
+ int width2;
+
+ GLubyte *addr;
+
+ z_depth = ( smesa->glCtx->Visual.depthBits +
+ smesa->glCtx->Visual.stencilBits ) / 8;
+
+ width2 = ALIGNMENT( smesa->width * z_depth, 4 );
+
+ totalBytes = smesa->height * width2 + Z_BUFFER_HW_PLUS;
+
+ addr = sisAllocFB( smesa, totalBytes, &smesa->zbFree );
+ if (addr == NULL)
+ sis_fatal_error("Failure to allocate Z buffer.\n");
+
+ if (SIS_VERBOSE & VERBOSE_SIS_BUFFER) {
+ fprintf(stderr, "sis_alloc_z_stencil_buffer: addr=%p\n", addr);
+ }
+
+ addr = (GLubyte *)ALIGNMENT( (unsigned long)addr, Z_BUFFER_HW_ALIGNMENT );
+
+ smesa->depthbuffer = (void *) addr;
+ smesa->depthPitch = width2;
+ smesa->depthOffset = (unsigned long)addr - (unsigned long)smesa->FbBase;
+
+ /* set pZClearPacket */
+ memset( &smesa->zClearPacket, 0, sizeof(ENGPACKET) );
+
+ smesa->zClearPacket.dwSrcPitch = (z_depth == 2) ? 0x80000000 : 0xf0000000;
+ smesa->zClearPacket.dwDestBaseAddr = (unsigned long)(addr -
+ (unsigned long)smesa->FbBase);
+ smesa->zClearPacket.wDestPitch = width2;
+ smesa->zClearPacket.stdwDestPos.wY = 0;
+ smesa->zClearPacket.stdwDestPos.wX = 0;
+
+ smesa->zClearPacket.wDestHeight = smesa->virtualY;
+ smesa->zClearPacket.stdwDim.wWidth = (GLshort)width2 / z_depth;
+ smesa->zClearPacket.stdwDim.wHeight = (GLshort)smesa->height;
+ smesa->zClearPacket.stdwCmd.cRop = 0xf0;
+
+ if (smesa->blockWrite)
+ smesa->zClearPacket.stdwCmd.cCmd0 = CMD0_PAT_FG_COLOR;
+ else
+ smesa->zClearPacket.stdwCmd.cCmd0 = 0;
+ smesa->zClearPacket.stdwCmd.cCmd1 = CMD1_DIR_X_INC | CMD1_DIR_Y_INC;
+}
+
+void
+sisFreeZStencilBuffer( sisContextPtr smesa )
+{
+ sisFreeFB( smesa, smesa->zbFree );
+ smesa->zbFree = NULL;
+ smesa->depthbuffer = NULL;
+}
+
+void
+sisAllocBackbuffer( sisContextPtr smesa )
+{
+ GLuint depth = smesa->bytesPerPixel;
+ GLuint size, width2;
+
+ char *addr;
+
+ width2 = (depth == 2) ? ALIGNMENT (smesa->width, 2) : smesa->width;
+ size = width2 * smesa->height * depth + DRAW_BUFFER_HW_PLUS;
+
+ /* Fixme: unique context alloc/free back-buffer? */
+ addr = sisAllocFB( smesa, size, &smesa->bbFree );
+ if (addr == NULL)
+ sis_fatal_error("Failure to allocate back buffer.\n");
+
+ addr = (char *)ALIGNMENT( (unsigned long)addr, DRAW_BUFFER_HW_ALIGNMENT );
+
+ smesa->backbuffer = addr;
+ smesa->backOffset = (unsigned long)(addr - (unsigned long)smesa->FbBase);
+ smesa->backPitch = width2 * depth;
+
+ memset ( &smesa->cbClearPacket, 0, sizeof(ENGPACKET) );
+
+ smesa->cbClearPacket.dwSrcPitch = (depth == 2) ? 0x80000000 : 0xf0000000;
+ smesa->cbClearPacket.dwDestBaseAddr = smesa->backOffset;
+ smesa->cbClearPacket.wDestPitch = smesa->backPitch;
+ smesa->cbClearPacket.stdwDestPos.wY = 0;
+ smesa->cbClearPacket.stdwDestPos.wX = 0;
+
+ smesa->cbClearPacket.wDestHeight = smesa->virtualY;
+ smesa->cbClearPacket.stdwDim.wWidth = (GLshort) width2;
+ smesa->cbClearPacket.stdwDim.wHeight = (GLshort) smesa->height;
+ smesa->cbClearPacket.stdwCmd.cRop = 0xf0;
+
+ if (smesa->blockWrite)
+ smesa->cbClearPacket.stdwCmd.cCmd0 = (GLbyte)(CMD0_PAT_FG_COLOR);
+ else
+ smesa->cbClearPacket.stdwCmd.cCmd0 = 0;
+ smesa->cbClearPacket.stdwCmd.cCmd1 = CMD1_DIR_X_INC | CMD1_DIR_Y_INC;
+}
+
+void
+sisFreeBackbuffer( sisContextPtr smesa )
+{
+ sisFreeFB( smesa, smesa->bbFree );
+ smesa->backbuffer = NULL;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_alloc.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_alloc.h
new file mode 100644
index 000000000..e76fc53fe
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_alloc.h
@@ -0,0 +1,44 @@
+/**************************************************************************
+
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT 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.
+
+**************************************************************************/
+/* $XFree86$ */
+
+/*
+ * Authors:
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+enum {
+ VIDEO_TYPE,
+ AGP_TYPE
+};
+
+void sisAllocZStencilBuffer( sisContextPtr smesa );
+void sisFreeZStencilBuffer( sisContextPtr smesa );
+void sisAllocBackbuffer( sisContextPtr smesa );
+void sisFreeBackbuffer ( sisContextPtr smesa );
+void *sisAllocFB( sisContextPtr smesa, GLuint size, void **handle );
+void sisFreeFB( sisContextPtr smesa, void *handle );
+void *sisAllocAGP( sisContextPtr smesa, GLuint size, void **handle );
+void sisFreeAGP( sisContextPtr smesa, void *handle );
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_clear.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_clear.c
new file mode 100644
index 000000000..7b68aadc7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_clear.c
@@ -0,0 +1,451 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP 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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_clear.c,v 1.5 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ * Sung-Ching Lin <sclin@sis.com.tw>
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#include "sis_context.h"
+#include "sis_state.h"
+#include "sis_lock.h"
+
+#include "swrast/swrast.h"
+#include "macros.h"
+
+static GLbitfield sis_3D_Clear( GLcontext * ctx, GLbitfield mask,
+ GLint x, GLint y, GLint width,
+ GLint height );
+static void sis_clear_color_buffer( GLcontext *ctx, GLenum mask, GLint x,
+ GLint y, GLint width, GLint height );
+static void sis_clear_z_stencil_buffer( GLcontext * ctx,
+ GLbitfield mask, GLint x,
+ GLint y, GLint width,
+ GLint height );
+
+static void
+set_color_pattern( sisContextPtr smesa, GLubyte red, GLubyte green,
+ GLubyte blue, GLubyte alpha )
+{
+ /* XXX only RGB565 and ARGB8888 */
+ switch (smesa->colorFormat)
+ {
+ case DST_FORMAT_ARGB_8888:
+ smesa->clearColorPattern = (alpha << 24) +
+ (red << 16) + (green << 8) + (blue);
+ break;
+ case DST_FORMAT_RGB_565:
+ smesa->clearColorPattern = ((red >> 3) << 11) +
+ ((green >> 2) << 5) + (blue >> 3);
+ smesa->clearColorPattern |= smesa->clearColorPattern << 16;
+ break;
+ default:
+ sis_fatal_error("Bad dst color format\n");
+ }
+}
+
+void
+sisUpdateZStencilPattern( sisContextPtr smesa, GLclampd z, GLint stencil )
+{
+ GLuint zPattern;
+
+ switch (smesa->zFormat)
+ {
+ case SiS_ZFORMAT_Z16:
+ CLAMPED_FLOAT_TO_USHORT(zPattern, z);
+ zPattern |= zPattern << 16;
+ break;
+ case SiS_ZFORMAT_S8Z24:
+ zPattern = FLOAT_TO_UINT(z) >> 8;
+ zPattern |= stencil << 24;
+ break;
+ case SiS_ZFORMAT_Z32:
+ zPattern = FLOAT_TO_UINT(z);
+ break;
+ default:
+ sis_fatal_error("Bad Z format\n");
+ }
+ smesa->clearZStencilPattern = zPattern;
+}
+
+void
+sisDDClear( GLcontext * ctx, GLbitfield mask, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ GLint x1, y1, width1, height1;
+
+ if (all) {
+ GLframebuffer *buffer = ctx->DrawBuffer;
+
+ x1 = 0;
+ y1 = 0;
+ width1 = buffer->Width;
+ height1 = buffer->Height;
+ } else {
+ x1 = x;
+ y1 = Y_FLIP(y+height-1);
+ width1 = width;
+ height1 = height;
+ }
+ /* XXX: Scissoring */
+
+ /* Mask out any non-existent buffers */
+ if (ctx->Visual.depthBits == 0 || !ctx->Depth.Mask)
+ mask &= ~BUFFER_BIT_DEPTH;
+ if (ctx->Visual.stencilBits == 0)
+ mask &= ~BUFFER_BIT_STENCIL;
+
+ LOCK_HARDWARE();
+
+ /* The 3d clear code is use for masked clears because apparently the SiS
+ * 300-series can't do write masks for 2d blits. 3d isn't used in general
+ * because it's slower, even in the case of clearing multiple buffers.
+ */
+ /* XXX: Appears to be broken with stencil. */
+ if ((smesa->current.hwCapEnable2 & (MASK_AlphaMaskWriteEnable |
+ MASK_ColorMaskWriteEnable) &&
+ (mask & (BUFFER_BIT_BACK_LEFT | BUFFER_BIT_FRONT_LEFT)) != 0) ||
+ (ctx->Stencil.WriteMask[0] < 0xff && (mask & BUFFER_BIT_STENCIL) != 0) )
+ {
+ mask = sis_3D_Clear( ctx, mask, x1, y1, width1, height1 );
+ }
+
+ if ( mask & BUFFER_BIT_FRONT_LEFT || mask & BUFFER_BIT_BACK_LEFT) {
+ sis_clear_color_buffer( ctx, mask, x1, y1, width1, height1 );
+ mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT);
+ }
+
+ if (mask & (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)) {
+ if (smesa->depthbuffer != NULL)
+ sis_clear_z_stencil_buffer( ctx, mask, x1, y1, width1, height1 );
+ mask &= ~(BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL);
+ }
+
+ UNLOCK_HARDWARE();
+
+ if (mask != 0)
+ _swrast_Clear( ctx, mask, all, x1, y1, width, height );
+}
+
+
+void
+sisDDClearColor( GLcontext * ctx, const GLfloat color[4] )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ GLubyte c[4];
+
+ CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
+
+ set_color_pattern( smesa, c[0], c[1], c[2], c[3] );
+}
+
+void
+sisDDClearDepth( GLcontext * ctx, GLclampd d )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ sisUpdateZStencilPattern( smesa, d, ctx->Stencil.Clear );
+}
+
+void
+sisDDClearStencil( GLcontext * ctx, GLint s )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ sisUpdateZStencilPattern( smesa, ctx->Depth.Clear, s );
+}
+
+static GLbitfield
+sis_3D_Clear( GLcontext * ctx, GLbitfield mask,
+ GLint x, GLint y, GLint width, GLint height )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ __GLSiSHardware *current = &smesa->current;
+
+ float left, top, right, bottom, zClearVal;
+ GLboolean bClrColor, bClrDepth, bClrStencil;
+ GLint dwPrimitiveSet;
+ GLint dwEnable1 = 0, dwEnable2 = MASK_ColorMaskWriteEnable;
+ GLint dwDepthMask = 0, dwSten1 = 0, dwSten2 = 0;
+ GLint dirtyflags = GFLAG_ENABLESETTING | GFLAG_ENABLESETTING2 |
+ GFLAG_CLIPPING | GFLAG_DESTSETTING;
+ int count;
+ drm_clip_rect_t *pExtents;
+
+ bClrColor = (mask & (BUFFER_BIT_BACK_LEFT | BUFFER_BIT_FRONT_LEFT)) != 0;
+ bClrDepth = (mask & BUFFER_BIT_DEPTH) != 0;
+ bClrStencil = (mask & BUFFER_BIT_STENCIL) != 0;
+
+ if (smesa->GlobalFlag & GFLAG_RENDER_STATES)
+ sis_update_render_state( smesa );
+
+ if (bClrStencil) {
+ dwSten1 = STENCIL_FORMAT_8 | SiS_STENCIL_ALWAYS |
+ (ctx->Stencil.Clear << 8) | 0xff;
+ dwSten2 = SiS_SFAIL_REPLACE | SiS_SPASS_ZFAIL_REPLACE |
+ SiS_SPASS_ZPASS_REPLACE;
+ dwEnable1 = MASK_ZWriteEnable | MASK_StencilWriteEnable |
+ MASK_StencilTestEnable;
+ dwEnable2 |= MASK_ZMaskWriteEnable;
+ dwDepthMask |= ctx->Stencil.WriteMask[0] << 24;
+ } else if (bClrDepth) {
+ dwEnable1 = MASK_ZWriteEnable;
+ dwEnable2 |= MASK_ZMaskWriteEnable;
+ }
+
+ if (bClrDepth) {
+ zClearVal = ctx->Depth.Clear;
+ if (ctx->Visual.depthBits != 32)
+ dwDepthMask |= 0x00ffffff;
+ else
+ dwDepthMask = 0xffffffff;
+ } else
+ zClearVal = 0.0;
+
+ mWait3DCmdQueue(9);
+ MMIO(REG_3D_TEnable, dwEnable1);
+ MMIO(REG_3D_TEnable2, dwEnable2);
+ if (bClrDepth || bClrStencil) {
+ MMIO(REG_3D_ZSet, (current->hwZ & ~MASK_ZTestMode) | SiS_Z_COMP_ALWAYS);
+ dirtyflags |= GFLAG_ZSETTING;
+ }
+ if (bClrColor) {
+ MMIO(REG_3D_DstSet, (current->hwDstSet & ~MASK_ROP2) | LOP_COPY);
+ } else {
+ MMIO(REG_3D_DstAlphaWriteMask, 0L);
+ }
+ if (bClrStencil) {
+ MMIO(REG_3D_StencilSet, dwSten1);
+ MMIO(REG_3D_StencilSet2, dwSten2);
+ dirtyflags |= GFLAG_STENCILSETTING;
+ }
+
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
+ pExtents = smesa->driDrawable->pClipRects;
+ count = smesa->driDrawable->numClipRects;
+ } else {
+ pExtents = NULL;
+ count = 1;
+ }
+
+ while(count--) {
+ left = x;
+ right = x + width;
+ top = y;
+ bottom = y + height;
+
+ if (pExtents != NULL) {
+ GLuint x1, y1, x2, y2;
+
+ x1 = pExtents->x1 - smesa->driDrawable->x;
+ y1 = pExtents->y1 - smesa->driDrawable->y;
+ x2 = pExtents->x2 - smesa->driDrawable->x - 1;
+ y2 = pExtents->y2 - smesa->driDrawable->y - 1;
+
+ left = (left > x1) ? left : x1;
+ right = (right > x2) ? x2 : right;
+ top = (top > y1) ? top : y1;
+ bottom = (bottom > y2) ? y2 : bottom;
+ pExtents++;
+ if (left > right || top > bottom)
+ continue;
+ }
+
+ mWait3DCmdQueue(20);
+
+ MMIO(REG_3D_ClipTopBottom, ((GLint)top << 13) | (GLint)bottom);
+ MMIO(REG_3D_ClipLeftRight, ((GLint)left << 13) | (GLint)right);
+
+ /* the first triangle */
+ dwPrimitiveSet = OP_3D_TRIANGLE_DRAW | OP_3D_FIRE_TSARGBc |
+ SHADE_FLAT_VertexC;
+ MMIO(REG_3D_PrimitiveSet, dwPrimitiveSet);
+
+ MMIO(REG_3D_TSZa, *(GLint *) &zClearVal);
+ MMIO(REG_3D_TSXa, *(GLint *) &right);
+ MMIO(REG_3D_TSYa, *(GLint *) &top);
+ MMIO(REG_3D_TSARGBa, smesa->clearColorPattern);
+
+ MMIO(REG_3D_TSZb, *(GLint *) &zClearVal);
+ MMIO(REG_3D_TSXb, *(GLint *) &left);
+ MMIO(REG_3D_TSYb, *(GLint *) &top);
+ MMIO(REG_3D_TSARGBb, smesa->clearColorPattern);
+
+ MMIO(REG_3D_TSZc, *(GLint *) &zClearVal);
+ MMIO(REG_3D_TSXc, *(GLint *) &left);
+ MMIO(REG_3D_TSYc, *(GLint *) &bottom);
+ MMIO(REG_3D_TSARGBc, smesa->clearColorPattern);
+
+ /* second triangle */
+ dwPrimitiveSet = OP_3D_TRIANGLE_DRAW | OP_3D_FIRE_TSARGBb |
+ SHADE_FLAT_VertexB;
+ MMIO(REG_3D_PrimitiveSet, dwPrimitiveSet);
+
+ MMIO(REG_3D_TSZb, *(GLint *) &zClearVal);
+ MMIO(REG_3D_TSXb, *(GLint *) &right);
+ MMIO(REG_3D_TSYb, *(GLint *) &bottom);
+ MMIO(REG_3D_TSARGBb, smesa->clearColorPattern);
+ }
+
+ mEndPrimitive();
+
+ /* If BUFFER_BIT_FRONT_LEFT is set, we've only cleared the front buffer so far */
+ if ((mask & BUFFER_BIT_FRONT_LEFT) != 0 && (mask & BUFFER_BIT_BACK_LEFT) != 0)
+ sis_3D_Clear( ctx, BUFFER_BIT_BACK_LEFT, x, y, width, height );
+
+ smesa->GlobalFlag |= dirtyflags;
+
+ return mask & ~(BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL | BUFFER_BIT_BACK_LEFT |
+ BUFFER_BIT_FRONT_LEFT);
+}
+
+static void
+sis_bitblt_clear_cmd( sisContextPtr smesa, ENGPACKET * pkt )
+{
+ GLint *lpdwDest, *lpdwSrc;
+ int i;
+
+ lpdwSrc = (GLint *) pkt + 1;
+ lpdwDest = (GLint *) (GET_IOBase (smesa) + REG_SRC_ADDR) + 1;
+
+ mWait3DCmdQueue (10);
+
+ *lpdwDest++ = *lpdwSrc++;
+ lpdwSrc++;
+ lpdwDest++;
+ for (i = 3; i < 8; i++) {
+ *lpdwDest++ = *lpdwSrc++;
+ }
+
+ MMIO(REG_CMD0, *(GLint *) & pkt->stdwCmd);
+ MMIO(REG_CommandQueue, -1);
+}
+
+static void
+sis_clear_color_buffer( GLcontext *ctx, GLenum mask, GLint x, GLint y,
+ GLint width, GLint height )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ int count;
+ GLuint depth = smesa->bytesPerPixel;
+ drm_clip_rect_t *pExtents = NULL;
+ GLint xx, yy;
+ GLint x0, y0, width0, height0;
+
+ ENGPACKET stEngPacket;
+
+ /* Clear back buffer */
+ if (mask & BUFFER_BIT_BACK_LEFT) {
+ smesa->cbClearPacket.stdwDestPos.wY = y;
+ smesa->cbClearPacket.stdwDestPos.wX = x;
+ smesa->cbClearPacket.stdwDim.wWidth = (GLshort) width;
+ smesa->cbClearPacket.stdwDim.wHeight = (GLshort) height;
+ smesa->cbClearPacket.dwFgRopColor = smesa->clearColorPattern;
+
+ sis_bitblt_clear_cmd( smesa, &smesa->cbClearPacket );
+ }
+
+ if ((mask & BUFFER_BIT_FRONT_LEFT) == 0)
+ return;
+
+ /* Clear front buffer */
+ x0 = x;
+ y0 = y;
+ width0 = width;
+ height0 = height;
+
+ pExtents = smesa->driDrawable->pClipRects;
+ count = smesa->driDrawable->numClipRects;
+
+ memset( &stEngPacket, 0, sizeof (ENGPACKET) );
+
+ stEngPacket.dwSrcPitch = (depth == 2) ? 0x80000000 : 0xc0000000;
+ stEngPacket.dwDestBaseAddr = smesa->frontOffset;
+ stEngPacket.wDestPitch = smesa->frontPitch;
+ /* TODO: set maximum value? */
+ stEngPacket.wDestHeight = smesa->virtualY;
+ stEngPacket.stdwCmd.cRop = 0xf0;
+ stEngPacket.dwFgRopColor = smesa->clearColorPattern;
+
+ /* for SGRAM Block Write Enable */
+ if (smesa->blockWrite)
+ stEngPacket.stdwCmd.cCmd0 = CMD0_PAT_FG_COLOR;
+ else
+ stEngPacket.stdwCmd.cCmd0 = 0;
+ stEngPacket.stdwCmd.cCmd1 = CMD1_DIR_X_INC | CMD1_DIR_Y_INC;
+
+ while (count--) {
+ GLint x2 = pExtents->x1 - smesa->driDrawable->x;
+ GLint y2 = pExtents->y1 - smesa->driDrawable->y;
+ GLint xx2 = pExtents->x2 - smesa->driDrawable->x;
+ GLint yy2 = pExtents->y2 - smesa->driDrawable->y;
+
+ x = (x0 > x2) ? x0 : x2;
+ y = (y0 > y2) ? y0 : y2;
+ xx = ((x0 + width0) > (xx2)) ? xx2 : x0 + width0;
+ yy = ((y0 + height0) > (yy2)) ? yy2 : y0 + height0;
+ width = xx - x;
+ height = yy - y;
+ pExtents++;
+
+ if (width <= 0 || height <= 0)
+ continue;
+
+ stEngPacket.stdwDestPos.wY = y;
+ stEngPacket.stdwDestPos.wX = x;
+ stEngPacket.stdwDim.wWidth = (GLshort)width;
+ stEngPacket.stdwDim.wHeight = (GLshort)height;
+
+ sis_bitblt_clear_cmd( smesa, &stEngPacket );
+ }
+}
+
+static void
+sis_clear_z_stencil_buffer( GLcontext * ctx, GLbitfield mask,
+ GLint x, GLint y, GLint width, GLint height )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ /* TODO: consider alignment of width, height? */
+ smesa->zClearPacket.stdwDestPos.wY = y;
+ smesa->zClearPacket.stdwDestPos.wX = x;
+ smesa->zClearPacket.stdwDim.wWidth = (GLshort) width;
+ smesa->zClearPacket.stdwDim.wHeight = (GLshort) height;
+ smesa->zClearPacket.dwFgRopColor = smesa->clearZStencilPattern;
+
+ sis_bitblt_clear_cmd( smesa, &smesa->zClearPacket );
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_common2.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_common2.h
new file mode 100644
index 000000000..c52abd5e5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_common2.h
@@ -0,0 +1,140 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+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 SILICON INTEGRATED SYSTEMS CORP 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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_common.h,v 1.5 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ * Sung-Ching Lin <sclin@sis.com.tw>
+ */
+
+#ifndef _sis_common_h_
+#define _sis_common_h_
+
+#if 0
+#define free(x)
+#define calloc(x,y) sis_debug_malloc((x)*(y))
+extern void *sis_debug_malloc(int x);
+#endif
+
+#if defined(SIS_DUMP)
+#include "sis_debug.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+typedef struct _Box
+{
+ short x1, y1, x2, y2;
+}
+BoxRec;
+#define NullBox ((BoxPtr)0)
+typedef struct _Box *BoxPtr;
+
+/* BitBlt Commands */
+#define CMD0_DD_ENABLE 0x06
+#define CMD0_SRC_VIDEO 0x00
+#define CMD0_SRC_CPU 0x10
+#define CMD0_PAT_FG_COLOR 0x00
+#define CMD1_DIR_X_DEC 0x00
+#define CMD1_DIR_X_INC 0x01
+#define CMD1_DIR_Y_DEC 0x00
+#define CMD1_DIR_Y_INC 0x02
+#define REG_SRC_ADDR 0x8200
+#define REG_CMD0 0x823c
+
+typedef struct
+{
+ GLshort wSrcPitch;
+ GLshort wDestPitch;
+}
+_PITCH;
+typedef struct
+{
+ GLshort wWidth;
+ GLshort wHeight;
+}
+_DIM;
+typedef struct
+{
+ GLshort wY;
+ GLshort wX;
+}
+_POS;
+
+typedef struct
+{
+ GLubyte cCmd0;
+ GLubyte cRop;
+ GLubyte cCmd1;
+ GLubyte cReserved;
+}
+_CMD;
+
+typedef struct
+{
+ GLshort wStatus0;
+ GLbyte cStatus0_GLbyte3;
+ GLbyte cStatus0_GLbyte4;
+}
+_CMDQUESTATUS;
+
+typedef struct
+{
+ GLint dwSrcBaseAddr;
+ GLint dwSrcPitch;
+ _POS stdwSrcPos;
+ _POS stdwDestPos;
+ GLint dwDestBaseAddr;
+ GLshort wDestPitch;
+ GLshort wDestHeight;
+ _DIM stdwDim;
+ GLint dwFgRopColor;
+ GLint dwBgRopColor;
+ GLint dwSrcHiCKey;
+ GLint dwSrcLoCKey;
+ GLint dwMaskA;
+ GLint dwMaskB;
+ GLint dwClipA;
+ GLint dwClipB;
+ _CMD stdwCmd;
+ _CMDQUESTATUS stdwCmdQueStatus;
+}
+ENGPACKET, *LPENGPACKET;
+
+/* Hardware Info */
+#include "sis_reg.h"
+
+/* HW capability */
+#define SIS_MAX_TEXTURE_SIZE 2048
+#define SIS_MAX_TEXTURES 2
+
+#define SIS_MAX_FRAME_LENGTH 3
+
+GLint doFPtoFixedNoRound( GLfloat dwInValue, int nFraction );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_context.c
new file mode 100644
index 000000000..cfb7700af
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_context.c
@@ -0,0 +1,523 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP 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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_ctx.c,v 1.3 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ * Sung-Ching Lin <sclin@sis.com.tw>
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#include "sis_dri.h"
+
+#include "sis_context.h"
+#include "sis_state.h"
+#include "sis_dd.h"
+#include "sis_span.h"
+#include "sis_stencil.h"
+#include "sis_tex.h"
+#include "sis_tris.h"
+#include "sis_alloc.h"
+
+#include "imports.h"
+#include "matrix.h"
+#include "extensions.h"
+#include "utils.h"
+
+#include "drivers/common/driverfuncs.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+
+#define need_GL_ARB_multisample
+#include "extension_helper.h"
+
+int GlobalCurrentHwcx = -1;
+int GlobalHwcxCountBase = 1;
+int GlobalCmdQueueLen = 0;
+
+struct dri_extension card_extensions[] =
+{
+ { "GL_ARB_multisample", GL_ARB_multisample_functions },
+ { "GL_ARB_multitexture", NULL },
+ { "GL_EXT_texture_lod_bias", NULL },
+ { "GL_NV_blend_square", NULL },
+ { NULL, NULL }
+};
+
+void
+WaitEngIdle (sisContextPtr smesa)
+{
+ GLuint engineState;
+
+ do {
+ engineState = MMIO_READ(REG_CommandQueue);
+ } while ((engineState & SiS_EngIdle) != SiS_EngIdle);
+}
+
+void
+Wait2DEngIdle (sisContextPtr smesa)
+{
+ GLuint engineState;
+
+ do {
+ engineState = MMIO_READ(REG_CommandQueue);
+ } while ((engineState & SiS_EngIdle2d) != SiS_EngIdle2d);
+}
+
+/* To be called from mWait3DCmdQueue. Separate function for profiling
+ * purposes, and speed doesn't matter because we're spinning anyway.
+ */
+void
+WaitingFor3dIdle(sisContextPtr smesa, int wLen)
+{
+ while (*(smesa->CurrentQueueLenPtr) < wLen) {
+ *(smesa->CurrentQueueLenPtr) =
+ (MMIO_READ(REG_CommandQueue) & MASK_QueueLen) - 20;
+ }
+}
+
+GLboolean
+sisCreateContext( const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate )
+{
+ GLcontext *ctx, *shareCtx;
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ sisContextPtr smesa;
+ sisScreenPtr sisScreen;
+ int i;
+ struct dd_function_table functions;
+
+ smesa = (sisContextPtr)CALLOC( sizeof(*smesa) );
+ if (smesa == NULL)
+ return GL_FALSE;
+
+ /* Init default driver functions then plug in our SIS-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions(&functions);
+ sisInitDriverFuncs(&functions);
+ sisInitTextureFuncs(&functions);
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((sisContextPtr)sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+ smesa->glCtx = _mesa_create_context( glVisual, shareCtx,
+ &functions, (void *) smesa);
+ if (!smesa->glCtx) {
+ FREE(smesa);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = smesa;
+ ctx = smesa->glCtx;
+
+ sisScreen = smesa->sisScreen = (sisScreenPtr)(sPriv->private);
+
+ smesa->driContext = driContextPriv;
+ smesa->driScreen = sPriv;
+ smesa->driDrawable = NULL;
+ smesa->hHWContext = driContextPriv->hHWContext;
+ smesa->driHwLock = &sPriv->pSAREA->lock;
+ smesa->driFd = sPriv->fd;
+
+ smesa->virtualX = sisScreen->screenX;
+ smesa->virtualY = sisScreen->screenY;
+ smesa->bytesPerPixel = sisScreen->cpp;
+ smesa->IOBase = sisScreen->mmio.map;
+ smesa->Chipset = sisScreen->deviceID;
+ smesa->irqEnabled = sisScreen->irqEnabled;
+
+ smesa->FbBase = sPriv->pFB;
+ smesa->displayWidth = sPriv->fbWidth;
+ smesa->frontPitch = sPriv->fbStride;
+
+ smesa->sarea = (SISSAREAPriv *)((char *)sPriv->pSAREA +
+ sisScreen->sarea_priv_offset);
+
+#if defined(SIS_DUMP)
+ IOBase4Debug = GET_IOBase (smesa);
+#endif
+
+ /* support ARGB8888 and RGB565 */
+ switch (smesa->bytesPerPixel)
+ {
+ case 4:
+ smesa->redMask = 0x00ff0000;
+ smesa->greenMask = 0x0000ff00;
+ smesa->blueMask = 0x000000ff;
+ smesa->alphaMask = 0xff000000;
+ smesa->colorFormat = DST_FORMAT_ARGB_8888;
+ break;
+ case 2:
+ smesa->redMask = 0xf800;
+ smesa->greenMask = 0x07e0;
+ smesa->blueMask = 0x001f;
+ smesa->alphaMask = 0;
+ smesa->colorFormat = DST_FORMAT_RGB_565;
+ break;
+ default:
+ sis_fatal_error("Bad bytesPerPixel.\n");
+ }
+
+ /* Parse configuration files */
+ driParseConfigFiles (&smesa->optionCache, &sisScreen->optionCache,
+ sisScreen->driScreen->myNum, "sis");
+
+ /* TODO: index mode */
+
+ smesa->CurrentQueueLenPtr = &(smesa->sarea->QueueLength);
+ smesa->FrameCountPtr = &(smesa->sarea->FrameCount);
+
+ /* set AGP */
+ smesa->AGPSize = sisScreen->agp.size;
+ smesa->AGPBase = sisScreen->agp.map;
+ smesa->AGPAddr = sisScreen->agp.handle;
+
+ /* Create AGP command buffer */
+ if (smesa->AGPSize != 0 &&
+ !driQueryOptionb(&smesa->optionCache, "agp_disable"))
+ {
+ smesa->vb = sisAllocAGP(smesa, 64 * 1024, &smesa->vb_agp_handle);
+ if (smesa->vb != NULL) {
+ smesa->using_agp = GL_TRUE;
+ smesa->vb_cur = smesa->vb;
+ smesa->vb_last = smesa->vb;
+ smesa->vb_end = smesa->vb + 64 * 1024;
+ smesa->vb_agp_offset = ((long)smesa->vb - (long)smesa->AGPBase +
+ (long)smesa->AGPAddr);
+ }
+ }
+ if (!smesa->using_agp) {
+ smesa->vb = malloc(64 * 1024);
+ if (smesa->vb == NULL) {
+ FREE(smesa);
+ return GL_FALSE;
+ }
+ smesa->vb_cur = smesa->vb;
+ smesa->vb_last = smesa->vb;
+ smesa->vb_end = smesa->vb + 64 * 1024;
+ }
+
+ smesa->GlobalFlag = 0L;
+
+ smesa->Fallback = 0;
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+
+ _swrast_allow_pixel_fog( ctx, GL_TRUE );
+ _swrast_allow_vertex_fog( ctx, GL_FALSE );
+ _tnl_allow_pixel_fog( ctx, GL_TRUE );
+ _tnl_allow_vertex_fog( ctx, GL_FALSE );
+
+ /* XXX these should really go right after _mesa_init_driver_functions() */
+ sisDDInitStateFuncs( ctx );
+ sisDDInitState( smesa ); /* Initializes smesa->zFormat, important */
+ sisInitTriFuncs( ctx );
+ sisDDInitSpanFuncs( ctx );
+ sisDDInitStencilFuncs( ctx );
+
+ driInitExtensions( ctx, card_extensions, GL_FALSE );
+
+ /* TODO */
+ /* smesa->blockWrite = SGRAMbw = IsBlockWrite (); */
+ smesa->blockWrite = GL_FALSE;
+
+ for (i = 0; i < SIS_MAX_TEXTURES; i++) {
+ smesa->TexStates[i] = 0;
+ smesa->PrevTexFormat[i] = 0;
+ }
+
+ return GL_TRUE;
+}
+
+void
+sisDestroyContext ( __DRIcontextPrivate *driContextPriv )
+{
+ sisContextPtr smesa = (sisContextPtr)driContextPriv->driverPrivate;
+
+ assert( smesa != NULL );
+
+ if ( smesa != NULL ) {
+ _swsetup_DestroyContext( smesa->glCtx );
+ _tnl_DestroyContext( smesa->glCtx );
+ _ac_DestroyContext( smesa->glCtx );
+ _swrast_DestroyContext( smesa->glCtx );
+
+ if (smesa->using_agp)
+ sisFreeAGP(smesa, smesa->vb_agp_handle);
+
+ /* free the Mesa context */
+ /* XXX: Is the next line needed? The DriverCtx (smesa) reference is
+ * needed for sisDDDeleteTexture, since it needs to call the FB/AGP free
+ * function.
+ */
+ /* smesa->glCtx->DriverCtx = NULL; */
+ _mesa_destroy_context(smesa->glCtx);
+ }
+
+ FREE( smesa );
+}
+
+GLboolean
+sisMakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv )
+{
+ if ( driContextPriv ) {
+ GET_CURRENT_CONTEXT(ctx);
+ sisContextPtr oldSisCtx = ctx ? SIS_CONTEXT(ctx) : NULL;
+ sisContextPtr newSisCtx = (sisContextPtr) driContextPriv->driverPrivate;
+
+ if ( newSisCtx != oldSisCtx) {
+ newSisCtx->GlobalFlag = GFLAG_ALL;
+ }
+
+ newSisCtx->driDrawable = driDrawPriv;
+
+ _mesa_make_current( newSisCtx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
+
+ sisUpdateBufferSize( newSisCtx );
+ sisUpdateClipping( newSisCtx->glCtx );
+ } else {
+ _mesa_make_current( NULL, NULL, NULL );
+ }
+
+ return GL_TRUE;
+}
+
+GLboolean
+sisUnbindContext( __DRIcontextPrivate *driContextPriv )
+{
+ return GL_TRUE;
+}
+
+void
+sis_update_render_state( sisContextPtr smesa )
+{
+ __GLSiSHardware *prev = &smesa->prev;
+
+ mWait3DCmdQueue (45);
+
+ if (smesa->GlobalFlag & GFLAG_ENABLESETTING) {
+ if (!smesa->clearTexCache) {
+ MMIO(REG_3D_TEnable, prev->hwCapEnable);
+ } else {
+ MMIO(REG_3D_TEnable, prev->hwCapEnable | MASK_TextureCacheClear);
+ MMIO(REG_3D_TEnable, prev->hwCapEnable);
+ smesa->clearTexCache = GL_FALSE;
+ }
+ }
+
+ if (smesa->GlobalFlag & GFLAG_ENABLESETTING2)
+ MMIO(REG_3D_TEnable2, prev->hwCapEnable2);
+
+ /* Z Setting */
+ if (smesa->GlobalFlag & GFLAG_ZSETTING)
+ {
+ MMIO(REG_3D_ZSet, prev->hwZ);
+ MMIO(REG_3D_ZStWriteMask, prev->hwZMask);
+ MMIO(REG_3D_ZAddress, prev->hwOffsetZ);
+ }
+
+ /* Alpha Setting */
+ if (smesa->GlobalFlag & GFLAG_ALPHASETTING)
+ MMIO(REG_3D_AlphaSet, prev->hwAlpha);
+
+ if (smesa->GlobalFlag & GFLAG_DESTSETTING) {
+ MMIO(REG_3D_DstSet, prev->hwDstSet);
+ MMIO(REG_3D_DstAlphaWriteMask, prev->hwDstMask);
+ MMIO(REG_3D_DstAddress, prev->hwOffsetDest);
+ }
+
+ /* Line Setting */
+#if 0
+ if (smesa->GlobalFlag & GFLAG_LINESETTING)
+ MMIO(REG_3D_LinePattern, prev->hwLinePattern);
+#endif
+
+ /* Fog Setting */
+ if (smesa->GlobalFlag & GFLAG_FOGSETTING)
+ {
+ MMIO(REG_3D_FogSet, prev->hwFog);
+ MMIO(REG_3D_FogInverseDistance, prev->hwFogInverse);
+ MMIO(REG_3D_FogFarDistance, prev->hwFogFar);
+ MMIO(REG_3D_FogFactorDensity, prev->hwFogDensity);
+ }
+
+ /* Stencil Setting */
+ if (smesa->GlobalFlag & GFLAG_STENCILSETTING) {
+ MMIO(REG_3D_StencilSet, prev->hwStSetting);
+ MMIO(REG_3D_StencilSet2, prev->hwStSetting2);
+ }
+
+ /* Miscellaneous Setting */
+ if (smesa->GlobalFlag & GFLAG_DSTBLEND)
+ MMIO(REG_3D_DstBlendMode, prev->hwDstSrcBlend);
+ if (smesa->GlobalFlag & GFLAG_CLIPPING) {
+ MMIO(REG_3D_ClipTopBottom, prev->clipTopBottom);
+ MMIO(REG_3D_ClipLeftRight, prev->clipLeftRight);
+ }
+
+ smesa->GlobalFlag &= ~GFLAG_RENDER_STATES;
+}
+
+void
+sis_update_texture_state (sisContextPtr smesa)
+{
+ __GLSiSHardware *prev = &smesa->prev;
+
+ mWait3DCmdQueue (55);
+ if (smesa->clearTexCache || (smesa->GlobalFlag & GFLAG_TEXTUREADDRESS)) {
+ MMIO(REG_3D_TEnable, prev->hwCapEnable | MASK_TextureCacheClear);
+ MMIO(REG_3D_TEnable, prev->hwCapEnable);
+ smesa->clearTexCache = GL_FALSE;
+ }
+
+ /* Texture Setting */
+ if (smesa->GlobalFlag & CFLAG_TEXTURERESET)
+ MMIO(REG_3D_TextureSet, prev->texture[0].hwTextureSet);
+
+ if (smesa->GlobalFlag & GFLAG_TEXTUREMIPMAP)
+ MMIO(REG_3D_TextureMip, prev->texture[0].hwTextureMip);
+
+ /*
+ MMIO(REG_3D_TextureTransparencyColorHigh, prev->texture[0].hwTextureClrHigh);
+ MMIO(REG_3D_TextureTransparencyColorLow, prev->texture[0].hwTextureClrLow);
+ */
+
+ if (smesa->GlobalFlag & GFLAG_TEXBORDERCOLOR)
+ MMIO(REG_3D_TextureBorderColor, prev->texture[0].hwTextureBorderColor);
+
+ if (smesa->GlobalFlag & GFLAG_TEXTUREADDRESS) {
+ switch ((prev->texture[0].hwTextureSet & MASK_TextureLevel) >> 8)
+ {
+ case 11:
+ MMIO(REG_3D_TextureAddress11, prev->texture[0].texOffset11);
+ case 10:
+ MMIO(REG_3D_TextureAddress10, prev->texture[0].texOffset10);
+ MMIO(REG_3D_TexturePitch10, prev->texture[0].texPitch10);
+ case 9:
+ MMIO(REG_3D_TextureAddress9, prev->texture[0].texOffset9);
+ case 8:
+ MMIO(REG_3D_TextureAddress8, prev->texture[0].texOffset8);
+ MMIO(REG_3D_TexturePitch8, prev->texture[0].texPitch89);
+ case 7:
+ MMIO(REG_3D_TextureAddress7, prev->texture[0].texOffset7);
+ case 6:
+ MMIO(REG_3D_TextureAddress6, prev->texture[0].texOffset6);
+ MMIO(REG_3D_TexturePitch6, prev->texture[0].texPitch67);
+ case 5:
+ MMIO(REG_3D_TextureAddress5, prev->texture[0].texOffset5);
+ case 4:
+ MMIO(REG_3D_TextureAddress4, prev->texture[0].texOffset4);
+ MMIO(REG_3D_TexturePitch4, prev->texture[0].texPitch45);
+ case 3:
+ MMIO(REG_3D_TextureAddress3, prev->texture[0].texOffset3);
+ case 2:
+ MMIO(REG_3D_TextureAddress2, prev->texture[0].texOffset2);
+ MMIO(REG_3D_TexturePitch2, prev->texture[0].texPitch23);
+ case 1:
+ MMIO(REG_3D_TextureAddress1, prev->texture[0].texOffset1);
+ case 0:
+ MMIO(REG_3D_TextureAddress0, prev->texture[0].texOffset0);
+ MMIO(REG_3D_TexturePitch0, prev->texture[0].texPitch01);
+ }
+ }
+ if (smesa->GlobalFlag & CFLAG_TEXTURERESET_1)
+ MMIO(REG_3D_Texture1Set, prev->texture[1].hwTextureSet);
+ if (smesa->GlobalFlag & GFLAG_TEXTUREMIPMAP_1)
+ MMIO(REG_3D_Texture1Mip, prev->texture[1].hwTextureMip);
+
+ if (smesa->GlobalFlag & GFLAG_TEXBORDERCOLOR_1) {
+ MMIO(REG_3D_Texture1BorderColor,
+ prev->texture[1].hwTextureBorderColor);
+ }
+ if (smesa->GlobalFlag & GFLAG_TEXTUREADDRESS_1) {
+ switch ((prev->texture[1].hwTextureSet & MASK_TextureLevel) >> 8)
+ {
+ case 11:
+ MMIO(REG_3D_Texture1Address11, prev->texture[1].texOffset11);
+ case 10:
+ MMIO(REG_3D_Texture1Address10, prev->texture[1].texOffset10);
+ MMIO(REG_3D_Texture1Pitch10, prev->texture[1].texPitch10);
+ case 9:
+ MMIO(REG_3D_Texture1Address9, prev->texture[1].texOffset9);
+ case 8:
+ MMIO(REG_3D_Texture1Address8, prev->texture[1].texOffset8);
+ MMIO(REG_3D_Texture1Pitch8, prev->texture[1].texPitch89);
+ case 7:
+ MMIO(REG_3D_Texture1Address7, prev->texture[1].texOffset7);
+ case 6:
+ MMIO(REG_3D_Texture1Address6, prev->texture[1].texOffset6);
+ MMIO(REG_3D_Texture1Pitch6, prev->texture[1].texPitch67);
+ case 5:
+ MMIO(REG_3D_Texture1Address5, prev->texture[1].texOffset5);
+ case 4:
+ MMIO(REG_3D_Texture1Address4, prev->texture[1].texOffset4);
+ MMIO(REG_3D_Texture1Pitch4, prev->texture[1].texPitch45);
+ case 3:
+ MMIO(REG_3D_Texture1Address3, prev->texture[1].texOffset3);
+ case 2:
+ MMIO(REG_3D_Texture1Address2, prev->texture[1].texOffset2);
+ MMIO(REG_3D_Texture1Pitch2, prev->texture[1].texPitch23);
+ case 1:
+ MMIO(REG_3D_Texture1Address1, prev->texture[1].texOffset1);
+ case 0:
+ MMIO(REG_3D_Texture1Address0, prev->texture[1].texOffset0);
+ MMIO(REG_3D_Texture1Pitch0, prev->texture[1].texPitch01);
+ }
+ }
+
+ /* texture environment */
+ if (smesa->GlobalFlag & GFLAG_TEXTUREENV) {
+ MMIO(REG_3D_TextureBlendFactor, prev->hwTexEnvColor);
+ MMIO(REG_3D_TextureColorBlendSet0, prev->hwTexBlendColor0);
+ MMIO(REG_3D_TextureAlphaBlendSet0, prev->hwTexBlendAlpha0);
+ }
+ if (smesa->GlobalFlag & GFLAG_TEXTUREENV_1) {
+ MMIO(REG_3D_TextureBlendFactor, prev->hwTexEnvColor);
+ MMIO(REG_3D_TextureColorBlendSet1, prev->hwTexBlendColor1);
+ MMIO(REG_3D_TextureAlphaBlendSet1, prev->hwTexBlendAlpha1);
+ }
+
+ smesa->GlobalFlag &= ~GFLAG_TEXTURE_STATES;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_context.h
new file mode 100644
index 000000000..367540222
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_context.h
@@ -0,0 +1,440 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP 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.
+
+**************************************************************************/
+/* $XFree86$ */
+
+/*
+ * Authors:
+ * Sung-Ching Lin <sclin@sis.com.tw>
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#ifndef _sis_ctx_h_
+#define _sis_ctx_h_
+
+#include "context.h"
+#include "dri_util.h"
+#include "drm.h"
+#include "drm_sarea.h"
+#include "xmlconfig.h"
+#include "tnl/t_vertex.h"
+
+#include "sis_screen.h"
+#include "sis_common2.h"
+#include "sis_dri.h"
+
+/* for GLboolean */
+#include <GL/gl.h>
+
+#define PCI_CHIP_SIS300 0x0300
+#define PCI_CHIP_SIS630 0x6300
+#define PCI_CHIP_SIS540 0x5300
+
+#define NEW_TEXTURING 0x1
+#define NEW_TEXTURE_ENV 0x2
+
+/* Flags for software fallback cases:
+ */
+#define SIS_FALLBACK_TEXTURE 0x0001
+#define SIS_FALLBACK_TEXTURE0 0x0002
+#define SIS_FALLBACK_TEXTURE1 0x0004
+#define SIS_FALLBACK_TEXENV0 0x0008
+#define SIS_FALLBACK_TEXENV1 0x0010
+#define SIS_FALLBACK_DRAW_BUFFER 0x0020
+#define SIS_FALLBACK_STENCIL 0x0040
+#define SIS_FALLBACK_FORCE 0x8000
+
+/* Flags for hardware state that needs to be updated */
+#define GFLAG_ENABLESETTING 0x00000001
+#define GFLAG_ENABLESETTING2 0x00000002
+#define GFLAG_ZSETTING 0x00000004
+#define GFLAG_ALPHASETTING 0x00000008
+#define GFLAG_DESTSETTING 0x00000010
+#define GFLAG_LINESETTING 0x00000020
+#define GFLAG_STENCILSETTING 0x00000040
+#define GFLAG_FOGSETTING 0x00000080
+#define GFLAG_DSTBLEND 0x00000100
+#define GFLAG_CLIPPING 0x00000200
+#define CFLAG_TEXTURERESET 0x00000400
+#define GFLAG_TEXTUREMIPMAP 0x00000800
+#define GFLAG_TEXBORDERCOLOR 0x00001000
+#define GFLAG_TEXTUREADDRESS 0x00002000
+#define GFLAG_TEXTUREENV 0x00004000
+#define CFLAG_TEXTURERESET_1 0x00008000
+#define GFLAG_TEXTUREMIPMAP_1 0x00010000
+#define GFLAG_TEXBORDERCOLOR_1 0x00020000
+#define GFLAG_TEXTUREADDRESS_1 0x00040000
+#define GFLAG_TEXTUREENV_1 0x00080000
+#define GFLAG_ALL 0x000fffff
+
+#define GFLAG_TEXTURE_STATES (CFLAG_TEXTURERESET | GFLAG_TEXTUREMIPMAP | \
+ GFLAG_TEXBORDERCOLOR | GFLAG_TEXTUREADDRESS | \
+ CFLAG_TEXTURERESET_1 | GFLAG_TEXTUREMIPMAP_1 | \
+ GFLAG_TEXBORDERCOLOR_1 | \
+ GFLAG_TEXTUREADDRESS_1 | \
+ GFLAG_TEXTUREENV | GFLAG_TEXTUREENV_1)
+
+
+#define GFLAG_RENDER_STATES (GFLAG_ENABLESETTING | GFLAG_ENABLESETTING2 | \
+ GFLAG_ZSETTING | GFLAG_ALPHASETTING | \
+ GFLAG_DESTSETTING | GFLAG_FOGSETTING | \
+ GFLAG_STENCILSETTING | GFLAG_DSTBLEND | \
+ GFLAG_CLIPPING)
+
+/* Use the templated vertex format:
+ */
+#define TAG(x) sis##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+/* Subpixel offsets for window coordinates (triangles):
+ */
+#define SUBPIXEL_X (-0.5F)
+#define SUBPIXEL_Y (-0.5F)
+
+#define SIS_MAX_TEXTURE_LEVELS 11
+
+typedef struct {
+ GLubyte *Data; /* Pointer to texture in offscreen */
+ GLuint memType; /* VIDEO_TYPE or AGP_TYPE */
+ void *handle; /* Handle for sisFree*() */
+ GLuint pitch;
+ GLuint size;
+} sisTexImage;
+
+typedef struct sis_tex_obj {
+ sisTexImage image[SIS_MAX_TEXTURE_LEVELS]; /* Image data for each mipmap
+ * level */
+ GLenum format; /* One of GL_ALPHA, GL_INTENSITY, GL_LUMINANCE,
+ * GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA */
+ GLint hwformat; /* One of the TEXEL_ defines */
+ GLint numImages; /* Number of images loaded into .image */
+} sisTexObj, *sisTexObjPtr;
+
+/*
+ ** Device dependent context state
+ */
+typedef struct __GLSiSTextureRec
+{
+ GLint hwTextureSet;
+ GLint hwTextureMip;
+ GLint hwTextureClrHigh;
+ GLint hwTextureClrLow;
+ GLint hwTextureBorderColor;
+
+ GLint texOffset0;
+ GLint texOffset1;
+ GLint texOffset2;
+ GLint texOffset3;
+ GLint texOffset4;
+ GLint texOffset5;
+ GLint texOffset6;
+ GLint texOffset7;
+ GLint texOffset8;
+ GLint texOffset9;
+ GLint texOffset10;
+ GLint texOffset11;
+
+ GLint texPitch01;
+ GLint texPitch23;
+ GLint texPitch45;
+ GLint texPitch67;
+ GLint texPitch89;
+ GLint texPitch10;
+} __GLSiSTexture;
+
+typedef struct __GLSiSHardwareRec
+{
+ GLint hwCapEnable, hwCapEnable2; /* Enable Setting */
+
+ GLint hwOffsetZ, hwZ; /* Z Setting */
+
+ GLint hwZBias, hwZMask; /* Z Setting */
+
+ GLint hwAlpha; /* Alpha Setting */
+
+ GLint hwDstSet, hwDstMask; /* Destination Setting */
+
+ GLint hwOffsetDest; /* Destination Setting */
+
+ GLint hwLinePattern; /* Line Setting */
+
+ GLint hwFog; /* Fog Setting */
+
+ GLint hwFogFar, hwFogInverse; /* Fog Distance setting */
+
+ GLint hwFogDensity; /* Fog factor & density */
+
+ GLint hwStSetting, hwStSetting2; /* Stencil Setting */
+
+ GLint hwStOffset; /* Stencil Setting */
+
+ GLint hwDstSrcBlend; /* Blending mode Setting */
+
+ GLint clipTopBottom; /* Clip for Top & Bottom */
+
+ GLint clipLeftRight; /* Clip for Left & Right */
+
+ struct __GLSiSTextureRec texture[2];
+
+ GLint hwTexEnvColor; /* Texture Blending Setting */
+
+ GLint hwTexBlendColor0;
+ GLint hwTexBlendColor1;
+ GLint hwTexBlendAlpha0;
+ GLint hwTexBlendAlpha1;
+
+}
+__GLSiSHardware;
+
+typedef struct sis_context sisContextRec;
+typedef struct sis_context *sisContextPtr;
+
+typedef void (*sis_quad_func)( sisContextPtr,
+ sisVertex *,
+ sisVertex *,
+ sisVertex *,
+ sisVertex * );
+
+typedef void (*sis_tri_func)( sisContextPtr,
+ sisVertex *,
+ sisVertex *,
+ sisVertex * );
+
+typedef void (*sis_line_func)( sisContextPtr,
+ sisVertex *,
+ sisVertex * );
+
+typedef void (*sis_point_func)( sisContextPtr,
+ sisVertex * );
+
+/* Device dependent context state */
+
+struct sis_context
+{
+ /* This must be first in this structure */
+ GLcontext *glCtx;
+
+ /* Vertex state */
+ GLuint vertex_size;
+ struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
+ GLuint vertex_attr_count;
+ char *verts; /* points to tnl->clipspace.vertex_buf */
+
+ /* Vertex buffer (in system memory or AGP) state. */
+ unsigned char *vb; /* Beginning of vertex buffer */
+ unsigned char *vb_cur; /* Current write location in vertex buffer */
+ unsigned char *vb_last; /* Last written location in vertex buffer */
+ unsigned char *vb_end; /* End of vertex buffer */
+ void *vb_agp_handle;
+ GLuint vb_agp_offset;
+ GLboolean using_agp;
+
+ GLuint NewGLState;
+ GLuint Fallback;
+ GLuint RenderIndex;
+ GLfloat hw_viewport[16];
+ GLfloat depth_scale;
+
+ unsigned int virtualX, virtualY;
+ unsigned int bytesPerPixel;
+ unsigned char *IOBase;
+ unsigned char *FbBase;
+ unsigned int displayWidth;
+ unsigned int frontOffset;
+ unsigned int frontPitch;
+
+ /* HW RGBA layout */
+ unsigned int redMask, greenMask, blueMask, alphaMask;
+ unsigned int colorFormat;
+
+ /* Z format */
+ unsigned int zFormat;
+
+ /* Clear patterns, 4 bytes */
+ unsigned int clearColorPattern;
+ unsigned int clearZStencilPattern;
+
+ /* Fallback rasterization functions
+ */
+ sis_point_func draw_point;
+ sis_line_func draw_line;
+ sis_tri_func draw_tri;
+ sis_quad_func draw_quad;
+
+ GLuint hw_primitive;
+ GLenum raster_primitive;
+ GLenum render_primitive;
+
+ /* DRM fd */
+ int driFd;
+
+ /* AGP Memory */
+ unsigned int AGPSize;
+ unsigned char *AGPBase;
+ unsigned int AGPAddr;
+
+ /* register 0x89F4 */
+ GLint AGPParseSet;
+
+ /* register 0x89F8 */
+ GLint dwPrimitiveSet;
+
+ __GLSiSHardware prev, current;
+
+ int Chipset;
+
+ GLint drawableID;
+
+ /* SGRAM block write */
+ GLboolean blockWrite;
+
+ GLint GlobalFlag;
+ GLuint last_tcl_state;
+
+ /* Stereo */
+ GLboolean useStereo;
+ GLboolean stereoEnabled;
+ int stereo_drawIndex;
+ int stereo_drawSide;
+ GLboolean irqEnabled;
+
+ GLboolean clearTexCache;
+
+ GLuint TexStates[SIS_MAX_TEXTURES];
+ GLuint PrevTexFormat[SIS_MAX_TEXTURES];
+
+ int *CurrentQueueLenPtr;
+ unsigned int *FrameCountPtr;
+
+ /* Front/back/depth buffer info */
+ GLuint width, height; /* size of buffers */
+ GLint bottom; /* used for FLIP macro */
+ GLvoid *backbuffer;
+ unsigned int backOffset;
+ unsigned int backPitch;
+ GLvoid *depthbuffer;
+ unsigned int depthOffset;
+ unsigned int depthPitch;
+ void *zbFree, *bbFree; /* Cookies for freeing buffers */
+ ENGPACKET zClearPacket, cbClearPacket;
+
+ /* Drawable, cliprect and scissor information
+ */
+ GLint drawOffset, drawPitch;
+ GLint readOffset, readPitch;
+
+ /* Mirrors of some DRI state
+ */
+ __DRIcontextPrivate *driContext; /* DRI context */
+ __DRIscreenPrivate *driScreen; /* DRI screen */
+ __DRIdrawablePrivate *driDrawable; /* DRI drawable bound to this ctx */
+
+ unsigned int lastStamp; /* mirror driDrawable->lastStamp */
+
+ drm_context_t hHWContext;
+ drm_hw_lock_t *driHwLock;
+
+ sisScreenPtr sisScreen; /* Screen private DRI data */
+ SISSAREAPrivPtr sarea; /* Private SAREA data */
+
+ /* Configuration cache */
+ driOptionCache optionCache;
+};
+
+#define SIS_CONTEXT(ctx) ((sisContextPtr)(ctx->DriverCtx))
+
+/* Macros */
+#define GET_IOBase(x) ((x)->IOBase)
+
+#define Y_FLIP(Y) (smesa->bottom - (Y))
+
+#define SISPACKCOLOR565( r, g, b ) \
+ ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
+
+#define SISPACKCOLOR8888( r, g, b, a ) \
+ (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
+
+#define SIS_VERBOSE 0
+
+
+#define MMIO(reg, value) \
+{\
+ *(volatile GLint *)(smesa->IOBase + (reg)) = value; \
+}
+
+#define MMIO_READ(reg) *(volatile GLint *)(smesa->IOBase + (reg))
+#define MMIO_READf(reg) *(volatile GLfloat *)(smesa->IOBase + (reg))
+
+#define mEndPrimitive() \
+{ \
+ *(volatile GLubyte *)(smesa->IOBase + REG_3D_EndPrimitiveList) = 0xff; \
+ *(volatile GLuint *)(smesa->IOBase + 0x8b60) = 0xffffffff; \
+}
+
+#define sis_fatal_error(msg) \
+do { \
+ fprintf(stderr, "[%s:%d]: %s", __FILE__, __LINE__, msg); \
+ exit(-1); \
+} while (0)
+
+/* Lock required */
+#define mWait3DCmdQueue(wLen) \
+/* Update the mirrored queue pointer if it doesn't indicate enough space */ \
+if (*(smesa->CurrentQueueLenPtr) < (wLen)) { \
+ *(smesa->CurrentQueueLenPtr) = \
+ (*(GLint *)(GET_IOBase(smesa) + REG_CommandQueue) & MASK_QueueLen) - 20; \
+ /* Spin and wait if the queue is actually too full */ \
+ if (*(smesa->CurrentQueueLenPtr) < (wLen)) \
+ WaitingFor3dIdle(smesa, wLen); \
+ *(smesa->CurrentQueueLenPtr) -= wLen; \
+}
+
+enum _sis_verbose {
+ VERBOSE_SIS_BUFFER = 0x1,
+ VERBOSE_SIS_MEMORY = 0x2
+};
+
+extern GLboolean sisCreateContext( const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate );
+extern void sisDestroyContext( __DRIcontextPrivate * );
+
+extern GLboolean sisMakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv );
+
+extern GLboolean sisUnbindContext( __DRIcontextPrivate *driContextPriv );
+
+void WaitEngIdle (sisContextPtr smesa);
+void Wait2DEngIdle (sisContextPtr smesa);
+void WaitingFor3dIdle(sisContextPtr smesa, int wLen);
+
+/* update to hw */
+extern void sis_update_texture_state( sisContextPtr smesa );
+extern void sis_update_render_state( sisContextPtr smesa );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_dd.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_dd.c
new file mode 100644
index 000000000..2617980cc
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_dd.c
@@ -0,0 +1,181 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP 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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_ctx.c,v 1.3 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ * Sung-Ching Lin <sclin@sis.com.tw>
+ * Eric Anholt <anholt@FreeBSD.org>
+ *
+ */
+
+#include "sis_context.h"
+#include "sis_dd.h"
+#include "sis_lock.h"
+#include "sis_alloc.h"
+#include "sis_state.h"
+#include "sis_tris.h"
+
+#include "swrast/swrast.h"
+#include "framebuffer.h"
+
+#include "utils.h"
+
+#define DRIVER_DATE "20051019"
+
+/* Return the width and height of the given buffer.
+ */
+static void
+sisGetBufferSize( GLframebuffer *buffer,
+ GLuint *width, GLuint *height )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ LOCK_HARDWARE();
+ *width = smesa->driDrawable->w;
+ *height = smesa->driDrawable->h;
+ UNLOCK_HARDWARE();
+}
+
+/* Return various strings for glGetString().
+ */
+static const GLubyte *
+sisGetString( GLcontext *ctx, GLenum name )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ static char buffer[128];
+ unsigned offset;
+ GLuint agp_mode = (smesa->AGPSize > 0);
+
+ switch ( name )
+ {
+ case GL_VENDOR:
+ return (GLubyte *)"Eric Anholt";
+
+ case GL_RENDERER:
+ offset = driGetRendererString( buffer, "SiS", DRIVER_DATE, agp_mode );
+
+ return (GLubyte *)buffer;
+
+ default:
+ return NULL;
+ }
+}
+
+/* Send all commands to the hardware.
+ */
+static void
+sisFlush( GLcontext *ctx )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ SIS_FIREVERTICES(smesa);
+}
+
+/* Make sure all commands have been sent to the hardware and have
+ * completed processing.
+ */
+static void
+sisFinish( GLcontext *ctx )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ SIS_FIREVERTICES(smesa);
+ LOCK_HARDWARE();
+ WaitEngIdle( smesa );
+ UNLOCK_HARDWARE();
+}
+
+void
+sisUpdateBufferSize( sisContextPtr smesa )
+{
+ __GLSiSHardware *current = &smesa->current;
+ __GLSiSHardware *prev = &smesa->prev;
+ GLuint z_depth;
+
+ /* XXX Should get the base offset of the frontbuffer from the X Server */
+ smesa->frontOffset = smesa->driDrawable->x * smesa->bytesPerPixel +
+ smesa->driDrawable->y * smesa->frontPitch;
+
+ if ( smesa->width == smesa->driDrawable->w &&
+ smesa->height == smesa->driDrawable->h )
+ {
+ return;
+ }
+
+ smesa->width = smesa->driDrawable->w;
+ smesa->height = smesa->driDrawable->h;
+ smesa->bottom = smesa->height - 1;
+
+ if ( smesa->backbuffer )
+ sisFreeBackbuffer( smesa );
+ if ( smesa->depthbuffer )
+ sisFreeZStencilBuffer( smesa );
+
+ if ( smesa->glCtx->Visual.depthBits > 0 )
+ sisAllocZStencilBuffer( smesa );
+ if ( smesa->glCtx->Visual.doubleBufferMode )
+ sisAllocBackbuffer( smesa );
+
+ switch (smesa->zFormat)
+ {
+ case SiS_ZFORMAT_Z16:
+ z_depth = 2;
+ break;
+ case SiS_ZFORMAT_Z32:
+ case SiS_ZFORMAT_S8Z24:
+ z_depth = 4;
+ break;
+ default:
+ sis_fatal_error("Bad Z format\n");
+ }
+
+ current->hwZ &= ~MASK_ZBufferPitch;
+ current->hwZ |= smesa->width * z_depth >> 2;
+ current->hwOffsetZ = smesa->depthOffset >> 2;
+
+ if ((current->hwOffsetZ != prev->hwOffsetZ) || (current->hwZ != prev->hwZ)) {
+ prev->hwOffsetZ = current->hwOffsetZ;
+ prev->hwZ = current->hwZ;
+ smesa->GlobalFlag |= GFLAG_ZSETTING;
+ }
+
+ sisUpdateClipping( smesa->glCtx );
+}
+
+/* Initialize the driver's misc functions.
+ */
+void
+sisInitDriverFuncs( struct dd_function_table *functions )
+{
+ functions->GetBufferSize = sisGetBufferSize;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
+ functions->GetString = sisGetString;
+ functions->Finish = sisFinish;
+ functions->Flush = sisFlush;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_dd.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_dd.h
new file mode 100644
index 000000000..da76596e9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_dd.h
@@ -0,0 +1,39 @@
+/**************************************************************************
+
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT 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.
+
+**************************************************************************/
+/* $XFree86$ */
+
+/*
+ * Authors:
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#ifndef __SIS_DD_H__
+#define __SIS_DD_H__
+
+extern void sisUpdateBufferSize( sisContextPtr smesa );
+
+extern void sisInitDriverFuncs( struct dd_function_table *functions );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_debug.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_debug.c
new file mode 100644
index 000000000..99cb09c25
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_debug.c
@@ -0,0 +1,156 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+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 SILICON INTEGRATED SYSTEMS CORP 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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_debug.c,v 1.5 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ * Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
+/*
+ * dump HW states, set environment variable SIS_DEBUG
+ * to enable these functions
+ */
+
+#include <fcntl.h>
+#include <assert.h>
+
+#include "sis_context.h"
+
+/* for SiS 300/630/540 */
+#define MMIOLength (0x8FFF-0x8800+1)
+#define MMIO3DOffset (0x8800)
+#define FILE_NAME "300.dump"
+
+char *IOBase4Debug = 0;
+
+char *prevLockFile = NULL;
+int prevLockLine = 0;
+
+GLint _empty[0x10000];
+
+void
+dump_agp (void *addr, int dword_count)
+{
+ if (!getenv ("SIS_DEBUG"))
+ return;
+
+ {
+ int i;
+ FILE *file = fopen ("300agp.dump", "w");
+
+ if (file)
+ {
+ for (i = 0; i < dword_count; i++)
+ {
+ fprintf (file, "%f\n", *(float *) addr);
+ ((unsigned char *) addr) += 4;
+ }
+ fclose (file);
+ }
+ }
+}
+
+void
+d2f_once (GLcontext * ctx)
+{
+ XMesaContext xmesa = (XMesaContext) ctx->DriverCtx;
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ static int serialNumber = -1;
+
+ if (serialNumber == smesa->serialNumber)
+ return;
+ else
+ serialNumber = smesa->serialNumber;
+
+ d2f();
+}
+
+void
+d2f (void)
+{
+ if (!getenv ("SIS_DEBUG"))
+ return;
+
+ /* dump 0x8800 - 0x8AFF */
+ {
+ int fh;
+ int rval;
+ void *addr = IOBase4Debug + MMIO3DOffset;
+
+ assert (IOBase4Debug);
+
+ if ((fh = open (FILE_NAME, O_WRONLY | O_CREAT, S_IREAD | S_IWRITE)) != -1)
+ {
+ rval = write (fh, addr, MMIOLength);
+ assert (rval != -1);
+ close (fh);
+ }
+ }
+}
+
+/* dump to HW */
+void
+d2h (char *file_name)
+{
+ int fh;
+ int rval;
+ void *addr[MMIOLength];
+
+ if (!getenv ("SIS_DEBUG"))
+ return;
+
+ if ((fh = open (file_name, O_CREAT, S_IREAD | S_IWRITE)) != -1)
+ {
+ rval = read (fh, addr, MMIOLength);
+ assert (rval != -1);
+ close (fh);
+ }
+ memcpy (IOBase4Debug + MMIO3DOffset, addr, MMIOLength);
+
+}
+
+/* dump video memory to file */
+void
+dvidmem (unsigned char *addr, int size)
+{
+ int fh;
+ int rval;
+ static char *file_name = "vidmem.dump";
+
+ if (!getenv ("SIS_DEBUG"))
+ return;
+
+ if ((fh = open (file_name, O_WRONLY | O_CREAT, S_IREAD | S_IWRITE)) != -1)
+ {
+ rval = write (fh, addr, size);
+ assert (rval != -1);
+ close (fh);
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_debug.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_debug.h
new file mode 100644
index 000000000..5e2b30912
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_debug.h
@@ -0,0 +1,45 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+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 SILICON INTEGRATED SYSTEMS CORP 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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_debug.h,v 1.3 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ * Sung-Ching Lin <sclin@sis.com.tw>
+ *
+ */
+
+#ifndef _sis_debug_h_
+#define _sis_debug_h_
+
+void dump_agp (void *addr, int dword_count);
+void d2f (void);
+void d2f_once (GLcontext * ctx);
+void d2h (char *file_name);
+void dvidmem (unsigned char *addr, int size);
+extern char *IOBase4Debug;
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_fog.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_fog.c
new file mode 100644
index 000000000..e1230f6b4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_fog.c
@@ -0,0 +1,190 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP 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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_fog.c,v 1.3 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ * Sung-Ching Lin <sclin@sis.com.tw>
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#include "sis_context.h"
+#include "sis_state.h"
+#include "swrast/swrast.h"
+
+#include "macros.h"
+
+static GLint convertFtToFogFt( GLfloat dwInValue );
+
+void
+sisDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *params )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ __GLSiSHardware *prev = &smesa->prev;
+ __GLSiSHardware *current = &smesa->current;
+
+ float fArg;
+ GLint fogColor;
+
+ switch (pname)
+ {
+ case GL_FOG_MODE:
+ current->hwFog &= ~MASK_FogMode;
+ switch (ctx->Fog.Mode)
+ {
+ case GL_LINEAR:
+ current->hwFog |= FOGMODE_LINEAR;
+ break;
+ case GL_EXP:
+ current->hwFog |= FOGMODE_EXP;
+ break;
+ case GL_EXP2:
+ current->hwFog |= FOGMODE_EXP2;
+ break;
+ }
+ if (current->hwFog != prev->hwFog) {
+ prev->hwFog = current->hwFog;
+ smesa->GlobalFlag |= GFLAG_FOGSETTING;
+ }
+ break;
+ case GL_FOG_DENSITY:
+ current->hwFogDensity = convertFtToFogFt( ctx->Fog.Density );
+ if (current->hwFogDensity != prev->hwFogDensity) {
+ prev->hwFogDensity = current->hwFogDensity;
+ smesa->GlobalFlag |= GFLAG_FOGSETTING;
+ }
+ break;
+ case GL_FOG_START:
+ case GL_FOG_END:
+ fArg = 1.0 / (ctx->Fog.End - ctx->Fog.Start);
+ current->hwFogInverse = doFPtoFixedNoRound( fArg, 10 );
+ if (pname == GL_FOG_END)
+ {
+ if (smesa->Chipset == PCI_CHIP_SIS300)
+ current->hwFogFar = doFPtoFixedNoRound( ctx->Fog.End, 10 );
+ else
+ current->hwFogFar = doFPtoFixedNoRound( ctx->Fog.End, 6 );
+ }
+ if (current->hwFogFar != prev->hwFogFar ||
+ current->hwFogInverse != prev->hwFogInverse)
+ {
+ prev->hwFogFar = current->hwFogFar;
+ prev->hwFogInverse = current->hwFogInverse;
+ smesa->GlobalFlag |= GFLAG_FOGSETTING;
+ }
+ break;
+ case GL_FOG_INDEX:
+ /* TODO */
+ break;
+ case GL_FOG_COLOR:
+ fogColor = FLOAT_TO_UBYTE( ctx->Fog.Color[0] ) << 16;
+ fogColor |= FLOAT_TO_UBYTE( ctx->Fog.Color[1] ) << 8;
+ fogColor |= FLOAT_TO_UBYTE( ctx->Fog.Color[2] );
+ current->hwFog &= 0xff000000;
+ current->hwFog |= fogColor;
+ if (current->hwFog != prev->hwFog) {
+ prev->hwFog = current->hwFog;
+ smesa->GlobalFlag |= GFLAG_FOGSETTING;
+ }
+ break;
+ }
+}
+
+GLint
+doFPtoFixedNoRound( GLfloat dwInValue, int nFraction )
+{
+ GLint dwMantissa;
+ int nTemp;
+ union { int i; float f; } u;
+ GLint val;
+
+ u.f = dwInValue;
+ val = u.i;
+
+ if (val == 0)
+ return 0;
+ nTemp = (int) (val & 0x7F800000) >> 23;
+ nTemp = nTemp - 127 + nFraction - 23;
+ dwMantissa = (val & 0x007FFFFF) | 0x00800000;
+
+ if (nTemp < -25)
+ return 0;
+ if (nTemp > 0)
+ dwMantissa <<= nTemp;
+ else {
+ nTemp = -nTemp;
+ dwMantissa >>= nTemp;
+ }
+ if (val & 0x80000000)
+ dwMantissa = ~dwMantissa + 1;
+ return dwMantissa;
+}
+
+/* s[8].23->s[7].10 */
+static GLint
+convertFtToFogFt( GLfloat dwInValue )
+{
+ GLint dwMantissa, dwExp;
+ GLint dwRet;
+ union { int i; float f; } u;
+ GLint val;
+
+ u.f = dwInValue;
+ val = u.i;
+
+ if (val == 0)
+ return 0;
+
+ /* ----- Standard float Format: s[8].23 -----
+ * ----- = (-1)^S * 2^(E - 127) * (1 + M / 2^23) -----
+ * ----- = (-1)^S * 2^((E-63) - 64) * (1 + (M/2^13) / 2^10) -----
+ * ----- Density float Format: s[7].10 -----
+ * ----- New Exponential = E - 63 -----
+ * ----- New Mantissa = M / 2^13 -----
+ * ----- -----
+ */
+
+ dwExp = (val & 0x7F800000) >> 23;
+ dwExp -= 63;
+
+ if (dwExp < 0)
+ return 0;
+
+ if (dwExp <= 0x7F)
+ dwMantissa = (val & 0x007FFFFF) >> (23 - 10);
+ else {
+ /* ----- To Return +Max(or -Max) ----- */
+ dwExp = 0x7F;
+ dwMantissa = 0x3FF;
+ }
+
+ dwRet = (val & 0x80000000) >> (31 - 17); /* Shift Sign Bit */
+
+ dwRet |= (dwExp << 10) | dwMantissa;
+
+ return dwRet;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_lock.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_lock.c
new file mode 100644
index 000000000..f598e52d9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_lock.c
@@ -0,0 +1,76 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT 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:
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#include "context.h"
+#include "sis_context.h"
+#include "sis_lock.h"
+#include "sis_dd.h"
+#include "sis_state.h"
+
+/* 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.
+ */
+void
+sisGetLock( sisContextPtr smesa, GLuint flags )
+{
+ __DRIdrawablePrivate *dPriv = smesa->driDrawable;
+ __DRIscreenPrivate *sPriv = smesa->driScreen;
+ SISSAREAPrivPtr sarea = smesa->sarea;
+
+ drmGetLock( smesa->driFd, smesa->hHWContext, flags );
+
+ /* 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.
+ */
+ DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
+
+ if ( smesa->lastStamp != dPriv->lastStamp ) {
+ sisUpdateBufferSize( smesa );
+ sisUpdateClipping( smesa->glCtx );
+ sisDDDrawBuffer( smesa->glCtx, smesa->glCtx->Color.DrawBuffer[0] );
+ smesa->lastStamp = dPriv->lastStamp;
+ }
+
+ if ( sarea->CtxOwner != smesa->hHWContext ) {
+ sarea->CtxOwner = smesa->hHWContext;
+ smesa->GlobalFlag = GFLAG_ALL;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_lock.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_lock.h
new file mode 100644
index 000000000..fef993196
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_lock.h
@@ -0,0 +1,87 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP 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.
+
+**************************************************************************/
+/* $XFree86$ */
+
+/*
+ * Authors:
+ * Sung-Ching Lin <sclin@sis.com.tw>
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#ifndef __SIS_LOCK_H
+#define __SIS_LOCK_H
+
+extern void sisGetLock( sisContextPtr smesa, GLuint flags );
+
+#ifdef DEBUG_LOCKING
+extern char *prevLockFile;
+extern int prevLockLine;
+#define DEBUG_LOCK() \
+ do { \
+ prevLockFile=(__FILE__); \
+ prevLockLine=(__LINE__); \
+ } while (0)
+#define DEBUG_RESET() \
+ do { \
+ prevLockFile=NULL; \
+ prevLockLine=0; \
+ } while (0)
+#define DEBUG_CHECK_LOCK() \
+ do { \
+ if(prevLockFile){ \
+ fprintf(stderr, "LOCK SET : %s:%d\n", __FILE__, __LINE__); \
+ } \
+ } while (0)
+#else
+#define DEBUG_LOCK()
+#define DEBUG_RESET()
+#define DEBUG_CHECK_LOCK()
+#endif
+
+/* Lock the hardware using the global current context */
+#define LOCK_HARDWARE() \
+ do { \
+ char __ret=0; \
+ mEndPrimitive(); \
+ DEBUG_CHECK_LOCK(); \
+ DRM_CAS( smesa->driHwLock, smesa->hHWContext, \
+ (DRM_LOCK_HELD | smesa->hHWContext), __ret ); \
+ if ( __ret != 0 ) \
+ sisGetLock( smesa, 0 ); \
+ DEBUG_LOCK(); \
+ } while (0)
+
+/* Unlock the hardware using the global current context */
+#define UNLOCK_HARDWARE() \
+ do { \
+ mEndPrimitive(); \
+ DRM_UNLOCK(smesa->driFd, smesa->driHwLock, \
+ smesa->hHWContext); \
+ DEBUG_RESET(); \
+ } while (0)
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_reg.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_reg.h
new file mode 100644
index 000000000..76014ff3e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_reg.h
@@ -0,0 +1,868 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP 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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_reg.h,v 1.3 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ * Sung-Ching Lin <sclin@sis.com.tw>
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#ifndef _sis_reg_h_
+#define _sis_reg_h_
+
+/*
+ * Define All the Register Address of 6327
+ */
+
+#define REG_CommandQueue 0x8240
+
+#define REG_3D_TSFSa 0x8800
+#define REG_3D_TSZa 0x8804
+#define REG_3D_TSXa 0x8808
+#define REG_3D_TSYa 0x880C
+#define REG_3D_TSARGBa 0x8810
+#define REG_3D_TSWGa 0x8814
+#define REG_3D_TSUAa 0x8818
+#define REG_3D_TSVAa 0x881C
+#define REG_3D_TSUBa 0x8820
+#define REG_3D_TSVBa 0x8824
+#define REG_3D_TSUCa 0x8828
+#define REG_3D_TSVCa 0x882C
+
+#define REG_3D_TSFSb 0x8830
+#define REG_3D_TSZb 0x8834
+#define REG_3D_TSXb 0x8838
+#define REG_3D_TSYb 0x883C
+#define REG_3D_TSARGBb 0x8840
+#define REG_3D_TSWGb 0x8844
+#define REG_3D_TSUAb 0x8848
+#define REG_3D_TSVAb 0x884C
+#define REG_3D_TSUBb 0x8850
+#define REG_3D_TSVBb 0x8854
+#define REG_3D_TSUCb 0x8858
+#define REG_3D_TSVCb 0x885C
+
+#define REG_3D_TSFSc 0x8860
+#define REG_3D_TSZc 0x8864
+#define REG_3D_TSXc 0x8868
+#define REG_3D_TSYc 0x886C
+#define REG_3D_TSARGBc 0x8870
+#define REG_3D_TSWGc 0x8874
+#define REG_3D_TSUAc 0x8878
+#define REG_3D_TSVAc 0x887C
+#define REG_3D_TSUBc 0x8880
+#define REG_3D_TSVBc 0x8884
+#define REG_3D_TSUCc 0x8888
+#define REG_3D_TSVCc 0x888C
+
+/*
+ * REG_3D_AGPCmdSetting (89e4h-89f7)
+ */
+#define REG_3D_AGPCmBase 0x89E4
+#define REG_3D_AGPRmDwNum 0x89E8
+#define REG_3D_AGPTtDwNum 0x89EC
+#define REG_3D_AGPCmFire 0x89F0
+
+#define REG_3D_ParsingSet 0x89F4
+#define REG_3D_PrimitiveSet 0x89F8
+#define REG_3D_ShadeMode 0x89F8
+#define REG_3D_EngineFire 0x89FC
+#define REG_3D_EngineStatus 0x89FC
+#define REG_3D_TEnable 0x8A00
+#define REG_3D_TEnable2 0x8A04
+
+#define REG_3D_ZSet 0x8A08
+#define REG_3D_ZBias 0x8A0C
+#define REG_3D_ZStWriteMask 0x8A10
+
+#define REG_3D_ZAddress 0x8A14
+#define REG_3D_AlphaSet 0x8A18
+#define REG_3D_AlphaAddress 0x8A1C
+#define REG_3D_DstSet 0x8A20
+#define REG_3D_DstAlphaWriteMask 0x8A24
+
+#define REG_3D_DstAddress 0x8A28
+
+#define REG_3D_LinePattern 0x8A2C
+
+#define REG_3D_FogSet 0x8A30
+
+#define REG_3D_FogFarDistance 0x8A34
+#define REG_3D_FogInverseDistance 0x8A38
+#define REG_3D_FogFactorDensity 0x8A3C
+
+#define REG_3D_StencilSet 0x8A44
+#define REG_3D_StencilSet2 0x8A48
+#define REG_3D_StencilAddress 0x8A4C
+
+#define REG_3D_DstBlendMode 0x8A50
+#define REG_3D_SrcBlendMode 0x8A50
+#define REG_3D_ClipTopBottom 0x8A54
+#define REG_3D_ClipLeftRight 0x8A58
+
+#define REG_3D_Brightness 0x8A5C
+
+#define REG_3D_BumpMapSet 0x8A68
+#define REG_3D_BumpMapAddress 0x8A6C
+#define REG_3D_BumpMapPitch 0x8A70
+#define REG_3D_BumpMapMatrix0 0x8A74
+#define REG_3D_BumpMapMatrix1 0x8A78
+
+/*
+ * Define the Texture Register Address of 6326
+ */
+#define REG_3D_TextureSet 0x8A7C
+#define REG_3D_TextureWidthHeight 0x8A7C
+#define REG_3D_TextureMip 0x8A80
+
+#define REG_3D_TextureTransparencyColorHigh 0x8A84
+#define REG_3D_TextureTransparencyColorLow 0x8A88
+#define REG_3D_TextureBorderColor 0x8A8C
+#define REG_3D_TextureAddress0 0x8A90
+#define REG_3D_TextureAddress1 0x8A94
+#define REG_3D_TextureAddress2 0x8A98
+#define REG_3D_TextureAddress3 0x8A9C
+#define REG_3D_TextureAddress4 0x8AA0
+#define REG_3D_TextureAddress5 0x8AA4
+#define REG_3D_TextureAddress6 0x8AA8
+#define REG_3D_TextureAddress7 0x8AAC
+#define REG_3D_TextureAddress8 0x8AB0
+#define REG_3D_TextureAddress9 0x8AB4
+#define REG_3D_TextureAddress10 0x8AB8
+#define REG_3D_TextureAddress11 0x8ABC
+#define REG_3D_TexturePitch0 0x8AC0
+#define REG_3D_TexturePitch1 0x8AC0
+#define REG_3D_TexturePitch2 0x8AC4
+#define REG_3D_TexturePitch3 0x8AC4
+#define REG_3D_TexturePitch4 0x8AC8
+#define REG_3D_TexturePitch5 0x8AC8
+#define REG_3D_TexturePitch6 0x8ACC
+#define REG_3D_TexturePitch7 0x8ACC
+#define REG_3D_TexturePitch8 0x8AD0
+#define REG_3D_TexturePitch9 0x8AD0
+#define REG_3D_TexturePitch10 0x8AD4
+
+#define REG_3D_Texture1Set 0x8ADC
+#define REG_3D_Texture1WidthHeight 0x8ADC
+#define REG_3D_Texture1Mip 0x8AE0
+
+#define REG_3D_Texture1TransparencyColorHigh 0x8AE4
+#define REG_3D_Texture1TransparencyColorLow 0x8AE8
+#define REG_3D_Texture1BorderColor 0x8AEC
+#define REG_3D_Texture1Address0 0x8AF0
+#define REG_3D_Texture1Address1 0x8AF4
+#define REG_3D_Texture1Address2 0x8AF8
+#define REG_3D_Texture1Address3 0x8AFC
+#define REG_3D_Texture1Address4 0x8B00
+#define REG_3D_Texture1Address5 0x8B04
+#define REG_3D_Texture1Address6 0x8B08
+#define REG_3D_Texture1Address7 0x8B0C
+#define REG_3D_Texture1Address8 0x8B10
+#define REG_3D_Texture1Address9 0x8B14
+#define REG_3D_Texture1Address10 0x8B18
+#define REG_3D_Texture1Address11 0x8B1C
+#define REG_3D_Texture1Pitch0 0x8B20
+#define REG_3D_Texture1Pitch1 0x8B20
+#define REG_3D_Texture1Pitch2 0x8B24
+#define REG_3D_Texture1Pitch3 0x8B24
+#define REG_3D_Texture1Pitch4 0x8B28
+#define REG_3D_Texture1Pitch5 0x8B28
+#define REG_3D_Texture1Pitch6 0x8B2C
+#define REG_3D_Texture1Pitch7 0x8B2C
+#define REG_3D_Texture1Pitch8 0x8B30
+#define REG_3D_Texture1Pitch9 0x8B30
+#define REG_3D_Texture1Pitch10 0x8B34
+
+#define REG_3D_TextureBlendFactor 0x8B3C
+#define REG_3D_TextureColorBlendSet0 0x8B40
+#define REG_3D_TextureColorBlendSet1 0x8B44
+#define REG_3D_TextureAlphaBlendSet0 0x8B48
+#define REG_3D_TextureAlphaBlendSet1 0x8B4C
+/*
+ * Define the End of Primitive List of 6326
+ */
+#define REG_3D_EndPrimitiveList 0X8B50
+
+
+/*
+ * Define the Stipple Register Address of 6326
+ */
+#define REG_3D_Stipple0 0X8B60
+
+#define REG_3D_TexturePalette 0x8C00
+
+/*
+ * REG_CommandQueue -- (8240h-8243h)
+ */
+#define MASK_QueueLen 0x0000ffff
+#define SiS_EngIdle2d 0x80000000
+#define SiS_EngIdle 0xe0000000
+#define MASK_EngState 0xf0000000
+
+/*
+ * REG_3D_ParsingSet -- Define Parsing Mask (89F4h-89F7h)
+ */
+#define MASK_VertexDWSize 0xf0000000
+#define MASK_VertexDataFormat 0x0fff0000
+/* Because the original MASK_PsVertex_* names of these bits appared to be
+ * wrong, new names SiS_PS_* based off of the 4.3.0 driver and research are
+ * below.
+ */
+#define SiS_PS_HAS_XYZ 0x08000000
+#define SiS_PS_HAS_W 0x04000000
+#define SiS_PS_HAS_SPECULAR 0x02000000 /* XXX ? */
+#define SiS_PS_HAS_DIFFUSE 0x01000000
+#define SiS_PS_HAS_UV0 0x00400000
+#define SiS_PS_HAS_UV1 0x00200000
+#define MASK_PsVertex_HAS_RHW 0x08000000
+#define MASK_PsVertex_HAS_NORMALXYZ 0x04000000
+#define MASK_PsVertex_HAS_DIFFUSE 0x02000000
+#define MASK_PsVertex_HAS_SPECULAR 0x01000000
+#define MASK_PsUVSet 0x00ff0000
+#define MASK_PsVertex_HAS_1SetUV 0x00800000
+#define MASK_PsVertex_HAS_2SetUV 0x00c00000
+#define MASK_PsVertex_HAS_3SetUV 0x00e00000
+#define MASK_PsVertex_HAS_UVSet1 0x00800000
+#define MASK_PsVertex_HAS_UVSet2 0x00400000
+#define MASK_PsVertex_HAS_UVSet3 0x00200000
+#define MASK_PsCullDirection_CCW 0x00008000
+#define MASK_PsShadingMode 0x00007000
+/* XXX Shading modes just a guess, but seem to work*/
+#define MASK_PsShadingFlatA 0x00001000
+#define MASK_PsShadingFlatB 0x00002000
+#define MASK_PsShadingFlatC 0x00003000
+#define MASK_PsShadingSmooth 0x00004000
+#define MASK_PsTextureFrom 0x000003f0
+#define MASK_PsTexture0FromA 0x00000000
+#define MASK_PsTexture1FromA 0x00000000
+#define MASK_PsTexture1FromB 0x00000040
+#define MASK_PsBumpTextureFromA 0x00000000
+#define MASK_PsBumpTextureFromB 0x00000010
+#define MASK_PsBumpTextureFromC 0x00000020
+#define MASK_PsDataType 0x0000000f
+#define MASK_PsPointList 0x00000000
+#define MASK_PsLineList 0x00000004
+#define MASK_PsLineStrip 0x00000005
+#define MASK_PsTriangleList 0x00000008
+#define MASK_PsTriangleStrip 0x00000009
+#define MASK_PsTriangleFan 0x0000000a
+
+/*
+ * REG_3D_PrimitiveSet -- Define Fire Primitive Mask (89F8h-89FBh)
+ */
+#define MASK_DrawPrimitiveCommand 0x00000007
+#define MASK_SetFirePosition 0x00001F00
+#define MASK_BumpTextureFrom 0x00030000
+#define MASK_Texture1From 0x000C0000
+#define MASK_Texture0From 0x00300000
+#define MASK_ShadingMode 0x07000000
+#define MASK_CullDirection 0x08000000
+
+#define OP_3D_POINT_DRAW 0x00000000
+#define OP_3D_LINE_DRAW 0x00000001
+#define OP_3D_TRIANGLE_DRAW 0x00000002
+
+#define OP_3D_DIRECTION_RIGHT 0x00000000
+#define OP_3D_DIRECTION_LEFT 0x00000100
+#define OP_3D_DIRECTION_HORIZONTAL 0x00000000
+#define OP_3D_DIRECTION_VERTICAL 0x00000100
+
+#define OP_3D_FIRE_TFIRE 0x00000000
+#define OP_3D_FIRE_TSARGBa 0x00000100
+#define OP_3D_FIRE_TSWa 0x00000200
+#define OP_3D_FIRE_TSVAa 0x00000300
+#define OP_3D_FIRE_TSVBa 0x00000400
+#define OP_3D_FIRE_TSVCa 0x00000500
+
+#define OP_3D_FIRE_TSARGBb 0x00000900
+#define OP_3D_FIRE_TSWb 0x00000a00
+#define OP_3D_FIRE_TSVAb 0x00000b00
+#define OP_3D_FIRE_TSVBb 0x00000c00
+#define OP_3D_FIRE_TSVCb 0x00000d00
+
+#define OP_3D_FIRE_TSARGBc 0x00001100
+#define OP_3D_FIRE_TSWc 0x00001200
+#define OP_3D_FIRE_TSVAc 0x00001300
+#define OP_3D_FIRE_TSVBc 0x00001400
+#define OP_3D_FIRE_TSVCc 0x00001500
+
+#define OP_3D_Texture0FromA 0x00000000
+#define OP_3D_Texture0FromB 0x00100000
+#define OP_3D_Texture0FromC 0x00200000
+#define OP_3D_Texture1FromA 0x00000000
+#define OP_3D_Texture1FromB 0x00040000
+#define OP_3D_Texture1FromC 0x00080000
+#define OP_3D_TextureBumpFromA 0x00000000
+#define OP_3D_TextureBumpFromB 0x00010000
+#define OP_3D_TextureBumpFromC 0x00020000
+
+#define OP_3D_CullDirection_CCW 0x08000000
+
+#define SHADE_FLAT_VertexA 0x01000000
+#define SHADE_FLAT_VertexB 0x02000000
+#define SHADE_FLAT_VertexC 0x03000000
+#define SHADE_GOURAUD 0x04000000
+
+/*
+ * Define Command Queue Length Mask (89FCh-89FF)
+ */
+#define MASK_CmdQueueLen 0x0FFF0000
+
+/*
+ * REG_3D_TEnable -- Define Capility Enable Mask (8A00h-8A03h)
+ */
+#define MASK_DitherEnable 0x00000001
+#define MASK_BlendEnable 0x00000002
+#define MASK_FogTestEnable 0x00000004
+#define MASK_FogEnable 0x00000008
+#define MASK_SpecularEnable 0x00000010
+#define MASK_FogPerspectiveEnable 0x00000020
+#define MASK_TextureCacheClear 0x00000040
+#define MASK_TextureCacheEnable 0x00000080
+#define MASK_BumpMapEnable 0x00000100
+#define MASK_TexturePerspectiveEnable 0x00000200
+#define MASK_TextureEnable 0x00000400
+#define MASK_CullEnable 0x00000800
+#define MASK_TextureNumUsed 0x0000F000
+#define MASK_AlphaBufferEnable 0x00010000
+#define MASK_AlphaTestEnable 0x00020000
+#define MASK_AlphaWriteEnable 0x00040000
+#define MASK_ZTestEnable 0x00080000
+#define MASK_ZWriteEnable 0x00100000
+#define MASK_StencilBufferEnable 0x00200000
+#define MASK_StencilTestEnable 0x00400000
+#define MASK_StencilWriteEnable 0x00800000
+#define MASK_Texture0TransparencyEnable 0x01000000
+#define MASK_Texture1TransparencyEnable 0x02000000
+#define MASK_TextureAWrapUCorrection 0x04000000
+#define MASK_TextureAWrapVCorrection 0x08000000
+#define MASK_TextureBWrapUCorrection 0x10000000
+#define MASK_TextureBWrapVCorrection 0x20000000
+#define MASK_TextureCWrapUCorrection 0x40000000
+#define MASK_TextureCWrapVCorrection 0x80000000
+
+/*
+ * REG_3D_TEnable2 -- Define Capility Enable Mask2 (8A04h-8A07h)
+ */
+#define MASK_Texture0BlockTextureEnable 0x00000001
+#define MASK_Texture1BlockTextureEnable 0x00000002
+#define MASK_Texture0AnisotropicEnable 0x00000010
+#define MASK_Texture1AnisotropicEnable 0x00000020
+#define MASK_TextureMipmapBiasEnable 0x00000040
+#define MASK_LinePatternEnable 0x00000100
+#define MASK_StippleAlphaEnable 0x00000200
+#define MASK_StippleEnable 0x00000400
+#define MASK_AntiAliasEnable 0x00000800
+#define MASK_ZMaskWriteEnable 0x00001000
+#define MASK_StencilMaskWriteEnable 0x00002000
+#define MASK_AlphaMaskWriteEnable 0x00004000
+#define MASK_ColorMaskWriteEnable 0x00008000
+#define MASK_ZCacheClear 0x00010000
+#define MASK_ZCacheEnable 0x00020000
+#define MASK_StencilCacheClear 0x00040000
+#define MASK_StencilCacheEnable 0x00080000
+#define MASK_AlphaCacheClear 0x00100000
+#define MASK_AlphaCacheEnable 0x00200000
+#define MASK_ColorCacheClear 0x00400000
+#define MASK_ColorCacheEnable 0x00800000
+
+/*
+ * REG_3D_ZSet -- Define Z Buffer Setting Mask (8A08h-8A0Bh)
+ */
+#define MASK_ZBufferPitch 0x00000FFF
+#define MASK_ZTestMode 0x00070000
+#define MASK_ZBufferInSystem 0x00080000
+#define MASK_ZBufferFormat 0x01F00000
+
+#define SiS_Z_COMP_NEVER 0x00000000
+#define SiS_Z_COMP_S_LT_B 0x00010000
+#define SiS_Z_COMP_S_EQ_B 0x00020000
+#define SiS_Z_COMP_S_LE_B 0x00030000
+#define SiS_Z_COMP_S_GT_B 0x00040000
+#define SiS_Z_COMP_S_NE_B 0x00050000
+#define SiS_Z_COMP_S_GE_B 0x00060000
+#define SiS_Z_COMP_ALWAYS 0x00070000
+
+#define SiS_ZFORMAT_Z16 0x00000000
+#define SiS_ZFORMAT_Z16_INT 0x00100000
+#define SiS_ZFORMAT_S1Z15 0x00400000
+#define SiS_ZFORMAT_S1Z15_INT 0x00500000
+#define SiS_ZFORMAT_Z32 0x00800000
+#define SiS_ZFORMAT_S1Z31 0x00C00000
+#define SiS_ZFORMAT_S2Z30 0x00D00000
+#define SiS_ZFORMAT_S4Z28 0x00E00000
+#define SiS_ZFORMAT_S8Z24 0x00F00000
+#define SiS_ZFORMAT_FZ30 0x01800000
+#define SiS_ZFORMAT_FS1Z30 0x01C00000
+#define SiS_ZFORMAT_FS2Z30 0x01D00000
+
+/*
+ * REG_3D_ZBias -- Define Z Buffer Setting Mask (8A0Ch-8A0Fh)
+ */
+#define MASK_ZBias 0xFFFFFFFF
+
+/*
+ * REG_3D_ZStWriteMask -- Define Z and Stencil Buffer Mask (8A10h-8A13h)
+ */
+#define MASK_ZWriteMask 0x00FFFFFF
+
+/*
+ * REG_3D_ZAddress -- Define Z Buffer Base Address(8A14h-8A17h)
+ */
+#define MASK_ZAddress 0xFFFFFFFF
+
+/*
+ * REG_3D_AlphaSet -- Define Alpha Buffer Setting Mask (8A18h-8A1Bh)
+ */
+#define MASK_AlphaBufferPitch 0x000003FF
+#define MASK_AlphaRefValue 0x00FF0000
+#define MASK_AlphaTestMode 0x07000000
+#define MASK_AlphaBufferInSystem 0x08000000
+#define MASK_AlphaBufferFormat 0x30000000
+
+#define SiS_ALPHA_NEVER 0x00000000
+#define SiS_ALPHA_LESS 0x01000000
+#define SiS_ALPHA_EQUAL 0x02000000
+#define SiS_ALPHA_LEQUAL 0x03000000
+#define SiS_ALPHA_GREATER 0x04000000
+#define SiS_ALPHA_NOTEQUAL 0x05000000
+#define SiS_ALPHA_GEQUAL 0x06000000
+#define SiS_ALPHA_ALWAYS 0x07000000
+
+/*
+ * REG_3D_AlphaAddress -- Define Alpha Buffer Base Address(8A1Ch-8A1Fh)
+ */
+#define MASK_AlphaAddress 0xFFFFFFFF
+
+/*
+ * REG_3D_DstSet -- Define Destination Buffer Setting Mask (8A20h-8A23h)
+ */
+#define MASK_DstBufferPitch 0x00000FFF
+#define MASK_DstBufferFormat 0x000F0000
+#define MASK_DstBufferBitDepth 0x00300000
+#define MASK_DstBufferRgbOrder 0x00400000
+#define MASK_DstBufferInSystem 0x00800000
+#define MASK_Dst7BitFormat 0x007F0000
+#define MASK_ROP2 0x0F000000
+
+#define DST_FORMAT_RGB_555 0x00100000
+#define DST_FORMAT_RGB_565 0x00110000
+#define DST_FORMAT_ARGB_1555 0x00120000
+#define DST_FORMAT_ARGB_4444 0x00130000
+#define DST_FORMAT_ARGB_1888 0x00300000
+#define DST_FORMAT_ARGB_2888 0x00310000
+#define DST_FORMAT_ARGB_4888 0x00320000
+#define DST_FORMAT_ARGB_8888 0x00330000
+#define DST_FORMAT_ARGB_0888 0x00340000
+
+#define DST_FORMAT_BGR_555 0x00500000
+#define DST_FORMAT_BGR_565 0x00510000
+#define DST_FORMAT_ABGR_1555 0x00520000
+#define DST_FORMAT_ABGR_4444 0x00530000
+#define DST_FORMAT_ABGR_1888 0x00700000
+#define DST_FORMAT_ABGR_2888 0x00710000
+#define DST_FORMAT_ABGR_4888 0x00720000
+#define DST_FORMAT_ABGR_8888 0x00730000
+#define DST_FORMAT_ABGR_0888 0x00740000
+
+#define LOP_CLEAR 0x00000000
+#define LOP_NOR 0x01000000
+#define LOP_AND_INVERTED 0x02000000
+#define LOP_COPY_INVERTED 0x03000000
+#define LOP_AND_REVERSE 0x04000000
+#define LOP_INVERT 0x05000000
+#define LOP_XOR 0x06000000
+#define LOP_NAND 0x07000000
+#define LOP_AND 0x08000000
+#define LOP_EQUIV 0x09000000
+#define LOP_NOOP 0x0a000000
+#define LOP_OR_INVERTED 0x0b000000
+#define LOP_COPY 0x0c000000
+#define LOP_OR_REVERSE 0x0d000000
+#define LOP_OR 0x0e000000
+#define LOP_SET 0x0f000000
+
+/*
+ * REG_3D_DstAlphaWriteMask -- Define Destination/Alpha Buffer Write Mask (8A24h-8A27h)
+ */
+#define MASK_ColorWriteMask 0x00FFFFFF
+#define MASK_AlphaWriteMask 0xFF000000
+
+/*
+ * REG_3D_DstAddress -- Define Destination Buffer Base Address(8A1Ch-8A1Fh)
+ */
+#define MASK_DstAddress 0xFFFFFFFF
+
+/*
+ * REG_3D_LinePattern -- Define Line Pattern (8A2Ch-8A2Fh)
+ */
+#define MASK_LinePatternRepeatFactor 0x00007FFF
+#define MASK_LinePatternLastPixelFlag 0x00008000
+#define MASK_LinePattern 0xFFFF0000
+
+/*
+ * REG_3D_FogSet -- Define Fog Mask (8A30h-8A33h)
+ */
+#define MASK_FogColor 0x00FFFFFF
+#define MASK_FogMode 0x07000000
+#define MASK_FogZLookup 0x08000000
+
+#define FOGMODE_CHEAP 0x04000000
+#define FOGMODE_LINEAR 0x05000000
+#define FOGMODE_EXP 0x06000000
+#define FOGMODE_EXP2 0x07000000
+
+/*
+ * REG_3D_FogStartEnd -- Define Fog Start End Setting (0x8A34 - 0x8A37)
+ */
+#define MASK_FogFarDistance 0x0007FFFF
+
+/*
+ * REG_3D_FogStartEnd -- Define Fog End Setting (0x8A38 - 0x8A3B)
+ */
+#define MASK_FogInvFarDistance 0x0007FFFF
+
+/*
+ * REG_3D_FogFactorDensity (0x8A3C - 0x8A3F)
+ */
+#define MASK_FogDensity 0x0003FFFF
+#define MASK_FogFactor 0xFF000000
+
+/*
+ * REG_3D_StencilSet -- Define stencil test (8A44h-8A47h)
+ */
+#define MASK_StencilValueMask 0x000000ff
+#define MASK_StencilRefMask 0x0000ff00
+#define MASK_StencilTestMode 0x07000000
+#define MASK_StencilBufferInSystem 0x08000000
+#define MASK_StencilFormat 0x30000000
+
+#define SiS_STENCIL_NEVER 0x00000000
+#define SiS_STENCIL_LESS 0x01000000
+#define SiS_STENCIL_EQUAL 0x02000000
+#define SiS_STENCIL_LEQUAL 0x03000000
+#define SiS_STENCIL_GREATER 0x04000000
+#define SiS_STENCIL_NOTEQUAL 0x05000000
+#define SiS_STENCIL_GEQUAL 0x06000000
+#define SiS_STENCIL_ALWAYS 0x07000000
+
+#define STENCIL_FORMAT_1 0x00000000
+#define STENCIL_FORMAT_2 0x10000000
+#define STENCIL_FORMAT_4 0x20000000
+#define STENCIL_FORMAT_8 0x30000000
+
+/*
+ * REG_3D_StencilSet2 -- Define stencil test (8A4h-8A47h)
+ */
+#define MASK_StencilBufferPitch 0x00000FFF
+#define MASK_StencilZPassOp 0x00007000
+#define MASK_StencilZFailOp 0x00070000
+#define MASK_StencilFailOp 0x00700000
+#define MASK_StencilWriteMask 0xFF000000
+
+#define SiS_SFAIL_KEEP 0x00000000
+#define SiS_SFAIL_ZERO 0x00100000
+#define SiS_SFAIL_REPLACE 0x00200000
+#define SiS_SFAIL_INVERT 0x00500000
+#define SiS_SFAIL_INCR 0x00600000
+#define SiS_SFAIL_DECR 0x00700000
+
+#define SiS_SPASS_ZFAIL_KEEP 0x00000000
+#define SiS_SPASS_ZFAIL_ZERO 0x00010000
+#define SiS_SPASS_ZFAIL_REPLACE 0x00020000
+#define SiS_SPASS_ZFAIL_INVERT 0x00050000
+#define SiS_SPASS_ZFAIL_INCR 0x00060000
+#define SiS_SPASS_ZFAIL_DECR 0x00070000
+
+#define SiS_SPASS_ZPASS_KEEP 0x00000000
+#define SiS_SPASS_ZPASS_ZERO 0x00001000
+#define SiS_SPASS_ZPASS_REPLACE 0x00002000
+#define SiS_SPASS_ZPASS_INVERT 0x00005000
+#define SiS_SPASS_ZPASS_INCR 0x00006000
+#define SiS_SPASS_ZPASS_DECR 0x00007000
+
+/*
+ * REG_3D_DstBlendMode (0x8A50 - 0x8A53)
+ */
+#define MASK_SrcBlendMode 0x0000000F
+#define MASK_DstBlendMode 0x000000F0
+
+#define SiS_D_ZERO 0x00000000
+#define SiS_D_ONE 0x00000010
+#define SiS_D_SRC_COLOR 0x00000020
+#define SiS_D_ONE_MINUS_SRC_COLOR 0x00000030
+#define SiS_D_SRC_ALPHA 0x00000040
+#define SiS_D_ONE_MINUS_SRC_ALPHA 0x00000050
+#define SiS_D_DST_ALPHA 0x00000060
+#define SiS_D_ONE_MINUS_DST_ALPHA 0x00000070
+#define SiS_D_DST_COLOR 0x00000080
+#define SiS_D_ONE_MINUS_DST_COLOR 0x00000090
+#define SiS_D_SRC_ALPHA_SAT 0x000000a0
+
+#define SiS_S_ZERO 0x00000000
+#define SiS_S_ONE 0x00000001
+#define SiS_S_SRC_COLOR 0x00000002
+#define SiS_S_ONE_MINUS_SRC_COLOR 0x00000003
+#define SiS_S_SRC_ALPHA 0x00000004
+#define SiS_S_ONE_MINUS_SRC_ALPHA 0x00000005
+#define SiS_S_DST_ALPHA 0x00000006
+#define SiS_S_ONE_MINUS_DST_ALPHA 0x00000007
+#define SiS_S_DST_COLOR 0x00000008
+#define SiS_S_ONE_MINUS_DST_COLOR 0x00000009
+#define SiS_S_SRC_ALPHA_SATURATE 0x0000000a
+#define SiS_S_BOTH_SRC_ALPHA 0x0000000b
+#define SiS_S_BOTH_ONE_MINUS_SRC_ALPHA 0x0000000c
+
+/*
+ * REG_3D_ClipTopBottom (0x8A54 - 0x8A57)
+ */
+#define MASK_BottomClip 0x00001FFF
+#define MASK_TopClip 0x03FFE000
+
+/*
+ * REG_3D_ClipLeftRight (0x8A58 - 0x8A5B)
+ */
+#define MASK_RightClip 0x00001FFF
+#define MASK_LeftClip 0x03FFE000
+
+/*
+ * REG_3D_TextureSet (0x8A7C - 0x8A7F)
+ * REG_3D_Texture1Set (0x8ADC - 0x8ADF)
+ */
+#define MASK_TextureHeight 0x0000000F
+#define MASK_TextureWidth 0x000000F0
+#define MASK_TextureLevel 0x00000F00
+#define MASK_TextureSignYUVFormat 0x00001000
+#define MASK_TextureMappingMode 0x00FF0000
+#define MASK_TextureWrapU 0x00010000
+#define MASK_TextureWrapV 0x00020000
+#define MASK_TextureMirrorU 0x00040000
+#define MASK_TextureMirrorV 0x00080000
+#define MASK_TextureClampU 0x00100000
+#define MASK_TextureClampV 0x00200000
+#define MASK_TextureBorderU 0x00400000
+#define MASK_TextureBorderV 0x00800000
+#define MASK_TextureFormat 0xFF000000
+#define MASK_TextureBitDepth 0x70000000
+#define MASK_TextureRgbOrder 0x80000000
+
+#define TEXEL_INDEX1 0x00000000
+#define TEXEL_INDEX2 0x01000000
+#define TEXEL_INDEX4 0x02000000
+#define TEXEL_INDEX8 0x03000000
+
+#define TEXEL_INDEX1WithAlpha 0x04000000
+#define TEXEL_INDEX2WithAlpha 0x05000000
+#define TEXEL_INDEX4WithAlpha 0x06000000
+#define TEXEL_INDEX8WithAlpha 0x07000000
+
+#define TEXEL_I1 0x10000000
+#define TEXEL_I2 0x11000000
+#define TEXEL_I4 0x12000000
+#define TEXEL_I8 0x13000000
+
+#define TEXEL_DXT1 0x19000000
+#define TEXEL_DXT2 0x1A000000
+#define TEXEL_DXT3 0x1B000000
+
+#define TEXEL_YUV422 0x20000000
+#define TEXEL_YVU422 0x21000000
+#define TEXEL_UVY422 0x22000000
+#define TEXEL_VUY422 0x23000000
+#define TEXEL_YUV411 0x24000000
+
+#define TEXEL_L1 0x30000000
+#define TEXEL_L2 0x31000000
+#define TEXEL_L4 0x32000000
+#define TEXEL_L8 0x33000000
+
+#define TEXEL_AL11 0x34000000
+#define TEXEL_AL44 0x35000000
+#define TEXEL_AL26 0x37000000
+#define TEXEL_AL88 0x38000000
+
+#define TEXEL_A1 0x40000000
+#define TEXEL_A2 0x41000000
+#define TEXEL_A4 0x42000000
+#define TEXEL_A8 0x43000000
+
+#define TEXEL_RGB_332_8 0x50000000
+#define TEXEL_RGB_233_8 0x51000000
+#define TEXEL_RGB_232_8 0x52000000
+#define TEXEL_ARGB_1232_8 0x53000000
+#define TEXEL_ARGB_2222_8 0x54000000
+
+#define TEXEL_RGB_555_16 0x60000000
+#define TEXEL_RGB_565_16 0x61000000
+#define TEXEL_ARGB_1555_16 0x62000000
+#define TEXEL_ARGB_4444_16 0x63000000
+
+#define TEXEL_ARGB_1888_32 0x70000000
+#define TEXEL_ARGB_2888_32 0x71000000
+#define TEXEL_ARGB_4888_32 0x72000000
+#define TEXEL_ARGB_8888_32 0x73000000
+#define TEXEL_ARGB_0888_32 0x74000000
+
+#define TEXEL_BGR_332_8 0xD0000000
+#define TEXEL_BGR_233_8 0xD1000000
+#define TEXEL_BGR_232_8 0xD2000000
+#define TEXEL_ABGR_1232_8 0xD3000000
+#define TEXEL_ABGR_2222_8 0xD4000000
+
+#define TEXEL_BGR_555_16 0xE0000000
+#define TEXEL_BGR_565_16 0xE1000000
+#define TEXEL_ABGR_1555_16 0xE2000000
+#define TEXEL_ABGR_4444_16 0xE3000000
+
+#define TEXEL_ABGR_1888_32 0xF0000000
+#define TEXEL_ABGR_2888_32 0xF1000000
+#define TEXEL_ABGR_4888_32 0xF2000000
+#define TEXEL_ABGR_8888_32 0xF3000000
+#define TEXEL_ABGR_0888_32 0xF4000000
+
+#define TEXEL_VU88 0x00000000
+#define TEXEL_LVU655 0x00800000
+#define TEXEL_LVU888 0x01000000
+#define TEXEL_UV88 0x02000000
+#define TEXEL_LUV655 0x02800000
+#define TEXEL_LUV888 0x03000000
+
+/*
+ * REG_3D_TextureMip (0x8A80 - 0x8A83)
+ * REG_3D_Texture1Mip (0x8AE0 - 0x8AE3)
+ */
+#define MASK_TextureAnisotropyRatio 0x0000000F
+#define MASK_TextureMipmapLodBias 0x00003FF0
+#define MASK_TextureFilterMin 0x0001C000
+#define MASK_TextureFilterMag 0x00020000
+#define MASK_TextureFilter 0x0003C000
+#define MASK_TextureLevelInSystem 0x3FFC0000
+#define MASK_TextureLevel0InSystem 0x00040000
+#define MASK_TextureBlockLength 0xF0000000
+
+#define TEXTURE_FILTER_NEAREST 0x00000000
+#define TEXTURE_FILTER_LINEAR 0x00004000
+#define TEXTURE_FILTER_NEAREST_MIP_NEAREST 0x00008000
+#define TEXTURE_FILTER_NEAREST_MIP_LINEAR 0x00010000
+#define TEXTURE_FILTER_LINEAR_MIP_NEAREST 0x0000c000
+#define TEXTURE_FILTER_LINEAR_MIP_LINEAR 0x00014000
+
+/*
+ * REG_3D_TextureTransparencyColorHigh (0x8A84 - 0x8A87)
+ * REG_3D_Texture1TransparencyColorHigh (0x8AE4 - 0x8AE7)
+ */
+#define MASK_TextureTransparencyColorHighB 0x000000FF
+#define MASK_TextureTransparencyColorHighG 0x0000FF00
+#define MASK_TextureTransparencyColorHighR 0x00FF0000
+#define MASK_TextureAlphaTransparencyMode 0x08000000
+
+/*
+ * REG_3D_TextureTransparencyColorLow (0x8A88 - 0x8A8B)
+ * REG_3D_Texture1TransparencyColorLow (0x8AE8 - 0x8AEB)
+ */
+#define MASK_TextureTransparencyColorLowB 0x000000FF
+#define MASK_TextureTransparencyColorLowG 0x0000FF00
+#define MASK_TextureTransparencyColorLowR 0x00FF0000
+#define MASK_TextureBlockHeight 0x07000000
+#define MASK_TextureBlockWidth 0x70000000
+
+/*
+ * REG_3D_TextureTransparencyColorLow (0x8A8C - 0x8A8F)
+ * REG_3D_Texture1TransparencyColorLow (0x8AEC - 0x8AEF)
+ */
+#define MASK_TextureBorderColorB 0x000000FF
+#define MASK_TextureBorderColorG 0x0000FF00
+#define MASK_TextureBorderColorR 0x00FF0000
+#define MASK_TextureBorderColorA 0xFF000000
+
+/*
+ * REG_3D_TexturePitch0-10 (0x8AC0 - 0x8AD7)
+ * REG_3D_Texture1Pitch0-10 (0x8B20 - 0x8B37)
+ */
+#define MASK_TexturePitchOdd 0x000003FF
+#define MASK_TexturePitchEven 0x03FF0000
+#define SHIFT_TexturePitchEven 16
+
+/*
+ * REG_3D_TextureColorBlendSet0 (0x8B40 - 0x8B43)
+ * REG_3D_TextureColorBlendSet1 (0x8B44 - 0x8B46)
+ * REG_3D_TextureAlphaBlendSet0 (0x8B40 - 0x8B43)
+ * REG_3D_TextureAlphaBlendSet1 (0x8B44 - 0x8B46)
+ */
+#define STAGE0_C_CF 0xa1485000
+#define STAGE0_C_CS 0xc1485000
+#define STAGE0_C_CFCS 0xa1705000
+#define STAGE0_C_CFOMAS_CSAS 0xc534c001
+#define STAGE0_C_CFOMCS_CCCS 0x4530c001
+
+#define STAGE0_A_AF 0x63230000
+#define STAGE0_A_AS 0xc3230000
+#define STAGE0_A_AFAS 0x63c30000
+#define STAGE0_A_AFOMAS_ACAS 0x46c60001
+
+#define STAGE1_C_CF 0xa1485000
+#define STAGE1_C_CS 0xe1485000
+#define STAGE1_C_CFCS 0xa1785000
+#define STAGE1_C_CFOMAS_CSAS 0xe5394001
+#define STAGE1_C_CFOMCS_CCCS 0x45394001
+
+#define STAGE1_A_AF 0xa3230000
+#define STAGE1_A_AS 0xe3230000
+#define STAGE1_A_AFAS 0xa3e30000
+#define STAGE1_A_AFOMAS_ACAS 0x4aea0001
+
+/* What registers are these associated with? */
+#define MASK_BMMemoryInSystem 0x00000080
+#define MASK_BMHeight 0x00000F00
+#define MASK_BMWidth 0x0000F000
+#define MASK_BMFilter 0x00010000
+#define MASK_BMMappingMode 0x007E0000
+#define MASK_BMFormat 0x07800000
+#define MASK_BMTxBumpmap 0x08000000
+
+#define MASK_BMAddress 0xFFFFFFFC
+
+#define MASK_BMOffset 0xFF800000
+#define MASK_BMScale 0x007FE000
+#define MASK_BMPitch 0x00001FFF
+
+#define MASK_BMMatrix00 0x000007FF
+#define MASK_BMMatrix01 0x07FF0000
+#define MASK_BMMatrix10 0x000007FF
+#define MASK_BMMatrix11 0x07FF0000
+
+#define MASK_TextureRealInSystem 0x00000001
+#define MASK_TextureDowngrade 0x00000002
+
+#define ALPHA_BUFFER_FORMAT_1 0x00000000
+#define ALPHA_BUFFER_FORMAT_2 0x10000000
+#define ALPHA_BUFFER_FORMAT_4 0x20000000
+#define ALPHA_BUFFER_FORMAT_8 0x30000000
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_screen.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_screen.c
new file mode 100644
index 000000000..cc6afda1f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_screen.c
@@ -0,0 +1,468 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT 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:
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#include "dri_util.h"
+
+#include "context.h"
+#include "utils.h"
+#include "imports.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+
+#include "sis_context.h"
+#include "sis_dri.h"
+#include "sis_lock.h"
+#include "sis_span.h"
+
+#include "xmlpool.h"
+
+#include "GL/internal/dri_interface.h"
+
+PUBLIC const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_OPT_BEGIN(agp_disable,bool,false)
+ DRI_CONF_DESC(en,"Disable AGP vertex dispatch")
+ DRI_CONF_OPT_END
+ DRI_CONF_OPT_BEGIN(fallback_force,bool,false)
+ DRI_CONF_DESC(en,"Force software fallback")
+ DRI_CONF_OPT_END
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+static const GLuint __driNConfigOptions = 2;
+
+extern const struct dri_extension card_extensions[];
+
+static __GLcontextModes *
+sisFillInModes(int bpp)
+{
+ __GLcontextModes *modes;
+ __GLcontextModes *m;
+ unsigned num_modes;
+ unsigned depth_buffer_factor;
+ unsigned back_buffer_factor;
+ GLenum fb_format;
+ GLenum fb_type;
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML
+ };
+ u_int8_t depth_bits_array[4];
+ u_int8_t stencil_bits_array[4];
+
+ depth_bits_array[0] = 0;
+ stencil_bits_array[0] = 0;
+ depth_bits_array[1] = 16;
+ stencil_bits_array[1] = 0;
+ depth_bits_array[2] = 24;
+ stencil_bits_array[2] = 8;
+ depth_bits_array[3] = 32;
+ stencil_bits_array[3] = 0;
+
+ depth_buffer_factor = 4;
+ back_buffer_factor = 2;
+
+ /* Last 4 is for GLX_TRUE_COLOR & GLX_DIRECT_COLOR, with/without accum */
+ num_modes = depth_buffer_factor * back_buffer_factor * 4;
+
+ if (bpp == 16) {
+ fb_format = GL_RGB;
+ fb_type = GL_UNSIGNED_SHORT_5_6_5;
+ } else {
+ fb_format = GL_BGRA;
+ fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ }
+
+ modes = (*dri_interface->createContextModes)(num_modes, sizeof(__GLcontextModes));
+ m = modes;
+ if (!driFillInModes(&m, fb_format, fb_type, depth_bits_array,
+ stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_TRUE_COLOR)) {
+ fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__);
+ return NULL;
+ }
+
+ if (!driFillInModes(&m, fb_format, fb_type, depth_bits_array,
+ stencil_bits_array, depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_DIRECT_COLOR)) {
+ fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__, __LINE__);
+ return NULL;
+ }
+
+ return modes;
+}
+
+
+/* Create the device specific screen private data struct.
+ */
+static sisScreenPtr
+sisCreateScreen( __DRIscreenPrivate *sPriv )
+{
+ sisScreenPtr sisScreen;
+ SISDRIPtr sisDRIPriv = (SISDRIPtr)sPriv->pDevPriv;
+
+ if (sPriv->devPrivSize != sizeof(SISDRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(SISDRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
+
+ /* Allocate the private area */
+ sisScreen = (sisScreenPtr)CALLOC( sizeof(*sisScreen) );
+ if ( sisScreen == NULL )
+ return NULL;
+
+ sisScreen->screenX = sisDRIPriv->width;
+ sisScreen->screenY = sisDRIPriv->height;
+ sisScreen->cpp = sisDRIPriv->bytesPerPixel;
+ sisScreen->irqEnabled = sisDRIPriv->bytesPerPixel;
+ sisScreen->deviceID = sisDRIPriv->deviceID;
+ sisScreen->AGPCmdBufOffset = sisDRIPriv->AGPCmdBufOffset;
+ sisScreen->AGPCmdBufSize = sisDRIPriv->AGPCmdBufSize;
+ sisScreen->sarea_priv_offset = sizeof(drm_sarea_t);
+
+ sisScreen->mmio.handle = sisDRIPriv->regs.handle;
+ sisScreen->mmio.size = sisDRIPriv->regs.size;
+ if ( drmMap( sPriv->fd, sisScreen->mmio.handle, sisScreen->mmio.size,
+ &sisScreen->mmio.map ) )
+ {
+ FREE( sisScreen );
+ return NULL;
+ }
+
+ if (sisDRIPriv->agp.size) {
+ sisScreen->agp.handle = sisDRIPriv->agp.handle;
+ sisScreen->agp.size = sisDRIPriv->agp.size;
+ if ( drmMap( sPriv->fd, sisScreen->agp.handle, sisScreen->agp.size,
+ &sisScreen->agp.map ) )
+ {
+ sisScreen->agp.size = 0;
+ }
+ }
+
+ sisScreen->driScreen = sPriv;
+
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo(&sisScreen->optionCache,
+ __driConfigOptions, __driNConfigOptions);
+
+ return sisScreen;
+}
+
+/* Destroy the device specific screen private data struct.
+ */
+static void
+sisDestroyScreen( __DRIscreenPrivate *sPriv )
+{
+ sisScreenPtr sisScreen = (sisScreenPtr)sPriv->private;
+
+ if ( sisScreen == NULL )
+ return;
+
+ if (sisScreen->agp.size != 0)
+ drmUnmap( sisScreen->agp.map, sisScreen->agp.size );
+ drmUnmap( sisScreen->mmio.map, sisScreen->mmio.size );
+
+ FREE( sisScreen );
+ sPriv->private = NULL;
+}
+
+
+/* Create and initialize the Mesa and driver specific pixmap buffer
+ * data.
+ */
+static GLboolean
+sisCreateBuffer( __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ sisScreenPtr screen = (sisScreenPtr) driScrnPriv->private;
+ struct gl_framebuffer *fb;
+
+ if (isPixmap)
+ return GL_FALSE; /* not implemented */
+
+#if 0
+ driDrawPriv->driverPrivate = (void *)_mesa_create_framebuffer(
+ mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ mesaVis->alphaBits > 0 ); /* XXX */
+#else
+ fb = _mesa_create_framebuffer(mesaVis);
+
+ /* XXX double-check the Offset/Pitch parameters! */
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ 0, driScrnPriv->fbStride);
+ sisSetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ 0, driScrnPriv->fbStride);
+ sisSetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ 0, driScrnPriv->fbStride);
+ sisSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ 0, driScrnPriv->fbStride);
+ sisSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 32) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT32, screen->cpp,
+ 0, driScrnPriv->fbStride);
+ sisSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ /* no h/w stencil?
+ if (mesaVis->stencilBits > 0) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT);
+ sisSetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+ */
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+
+ return (driDrawPriv->driverPrivate != NULL);
+}
+
+
+static void
+sisDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+__inline__ static void
+sis_bitblt_copy_cmd (sisContextPtr smesa, ENGPACKET * pkt)
+{
+ GLint *lpdwDest, *lpdwSrc;
+ int i;
+
+ lpdwSrc = (GLint *) pkt;
+ lpdwDest = (GLint *) (GET_IOBase (smesa) + REG_SRC_ADDR);
+
+ mWait3DCmdQueue (10);
+
+ for (i = 0; i < 7; i++)
+ *lpdwDest++ = *lpdwSrc++;
+
+ MMIO(REG_CMD0, *(GLint *)&pkt->stdwCmd);
+ MMIO(REG_CommandQueue, -1);
+}
+
+static void sisCopyBuffer( __DRIdrawablePrivate *dPriv )
+{
+ sisContextPtr smesa = (sisContextPtr)dPriv->driContextPriv->driverPrivate;
+ int i;
+ ENGPACKET stEngPacket;
+
+ memset(&stEngPacket, 0, sizeof(ENGPACKET));
+
+ while ((*smesa->FrameCountPtr) - MMIO_READ(0x8a2c) > SIS_MAX_FRAME_LENGTH)
+ ;
+
+ LOCK_HARDWARE();
+
+ stEngPacket.dwSrcBaseAddr = smesa->backOffset;
+ stEngPacket.dwSrcPitch = smesa->backPitch |
+ ((smesa->bytesPerPixel == 2) ? 0x80000000 : 0xc0000000);
+ stEngPacket.dwDestBaseAddr = 0;
+ stEngPacket.wDestPitch = smesa->frontPitch;
+ /* TODO: set maximum value? */
+ stEngPacket.wDestHeight = smesa->virtualY;
+
+ stEngPacket.stdwCmd.cRop = 0xcc;
+
+ if (smesa->blockWrite)
+ stEngPacket.stdwCmd.cCmd0 = CMD0_PAT_FG_COLOR;
+ else
+ stEngPacket.stdwCmd.cCmd0 = 0;
+ stEngPacket.stdwCmd.cCmd1 = CMD1_DIR_X_INC | CMD1_DIR_Y_INC;
+
+ for (i = 0; i < dPriv->numClipRects; i++) {
+ drm_clip_rect_t *box = &dPriv->pClipRects[i];
+ stEngPacket.stdwSrcPos.wY = box->y1 - dPriv->y;
+ stEngPacket.stdwSrcPos.wX = box->x1 - dPriv->x;
+ stEngPacket.stdwDestPos.wY = box->y1;
+ stEngPacket.stdwDestPos.wX = box->x1;
+
+ stEngPacket.stdwDim.wWidth = (GLshort) box->x2 - box->x1;
+ stEngPacket.stdwDim.wHeight = (GLshort) box->y2 - box->y1;
+ sis_bitblt_copy_cmd( smesa, &stEngPacket );
+ }
+
+ *(GLint *)(smesa->IOBase+0x8a2c) = *smesa->FrameCountPtr;
+ (*smesa->FrameCountPtr)++;
+
+ UNLOCK_HARDWARE ();
+}
+
+
+/* Copy the back color buffer to the front color buffer */
+static void
+sisSwapBuffers(__DRIdrawablePrivate *dPriv)
+{
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ sisContextPtr smesa = (sisContextPtr) dPriv->driContextPriv->driverPrivate;
+ GLcontext *ctx = smesa->glCtx;
+
+ if (ctx->Visual.doubleBufferMode) {
+ _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
+ sisCopyBuffer( dPriv );
+ }
+ } else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__);
+ }
+}
+
+
+/* Initialize the driver specific screen private data.
+ */
+static GLboolean
+sisInitDriver( __DRIscreenPrivate *sPriv )
+{
+ sPriv->private = (void *) sisCreateScreen( sPriv );
+
+ if ( !sPriv->private ) {
+ sisDestroyScreen( sPriv );
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+static struct __DriverAPIRec sisAPI = {
+ .InitDriver = sisInitDriver,
+ .DestroyScreen = sisDestroyScreen,
+ .CreateContext = sisCreateContext,
+ .DestroyContext = sisDestroyContext,
+ .CreateBuffer = sisCreateBuffer,
+ .DestroyBuffer = sisDestroyBuffer,
+ .SwapBuffers = sisSwapBuffers,
+ .MakeCurrent = sisMakeCurrent,
+ .UnbindContext = sisUnbindContext,
+ .GetSwapInfo = NULL,
+ .GetMSC = NULL,
+ .WaitForMSC = NULL,
+ .WaitForSBC = NULL,
+ .SwapBuffersMSC = NULL
+
+};
+
+
+/**
+ * This is the bootstrap function for the driver. libGL supplies all of the
+ * requisite information about the system, and the driver initializes itself.
+ * This routine also fills in the linked list pointed to by \c driver_modes
+ * with the \c __GLcontextModes that the driver can support for windows or
+ * pbuffers.
+ *
+ * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
+ * failure.
+ */
+PUBLIC
+void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn,
+ __DRIscreen *psc,
+ const __GLcontextModes *modes,
+ const __DRIversion *ddx_version,
+ const __DRIversion *dri_version,
+ const __DRIversion *drm_version,
+ const __DRIframebuffer *frame_buffer,
+ drmAddress pSAREA, int fd,
+ int internal_api_version,
+ const __DRIinterfaceMethods * interface,
+ __GLcontextModes **driver_modes )
+
+{
+ __DRIscreenPrivate *psp;
+ static const __DRIversion ddx_expected = {0, 8, 0};
+ static const __DRIversion dri_expected = {4, 0, 0};
+ static const __DRIversion drm_expected = {1, 0, 0};
+
+ dri_interface = interface;
+
+ if (!driCheckDriDdxDrmVersions2("SiS", dri_version, &dri_expected,
+ ddx_version, &ddx_expected,
+ drm_version, &drm_expected)) {
+ return NULL;
+ }
+
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &sisAPI);
+ if (psp != NULL) {
+ SISDRIPtr dri_priv = (SISDRIPtr)psp->pDevPriv;
+ *driver_modes = sisFillInModes(dri_priv->bytesPerPixel * 8);
+
+ /* Calling driInitExtensions here, with a NULL context pointer, does not actually
+ * enable the extensions. It just makes sure that all the dispatch offsets for all
+ * the extensions that *might* be enables are known. This is needed because the
+ * dispatch offsets need to be known when _mesa_context_create is called, but we can't
+ * enable the extensions until we have a context pointer.
+ *
+ * Hello chicken. Hello egg. How are you two today?
+ */
+ driInitExtensions( NULL, card_extensions, GL_FALSE );
+ }
+
+ return (void *)psp;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_screen.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_screen.h
new file mode 100644
index 000000000..068c0410d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_screen.h
@@ -0,0 +1,62 @@
+/**************************************************************************
+
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT 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.
+
+**************************************************************************/
+/* $XFree86$ */
+
+/*
+ * Authors:
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#ifndef __SIS_SCREEN_H
+#define __SIS_SCREEN_H
+
+typedef struct {
+ drm_handle_t handle; /* Handle to the DRM region */
+ drmSize size; /* Size of the DRM region */
+ drmAddress map; /* Mapping of the DRM region */
+} sisRegionRec2, *sisRegionPtr2;
+
+typedef struct {
+ sisRegionRec2 mmio;
+ sisRegionRec2 agp;
+
+ unsigned int AGPCmdBufOffset;
+ unsigned int AGPCmdBufSize;
+
+ int deviceID;
+ int irqEnabled;
+
+ int cpp;
+ unsigned int screenX, screenY;
+
+ __DRIscreenPrivate *driScreen;
+ unsigned int sarea_priv_offset;
+
+ /* Configuration cache with default values for all contexts */
+ driOptionCache optionCache;
+
+} sisScreenRec, *sisScreenPtr;
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_span.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_span.c
new file mode 100644
index 000000000..f0cf771d6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_span.c
@@ -0,0 +1,237 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP 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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_span.c,v 1.5 2001/03/21 16:14:26 dawes Exp $ */
+
+/*
+ * Authors:
+ * Sung-Ching Lin <sclin@sis.com.tw>
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#include "sis_context.h"
+#include "sis_span.h"
+#include "sis_lock.h"
+#include "sis_tris.h"
+
+#include "swrast/swrast.h"
+
+#define DBG 0
+
+#define LOCAL_VARS \
+ sisContextPtr smesa = SIS_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = smesa->driDrawable; \
+ GLuint pitch = smesa->drawPitch; \
+ char *buf = (char *)(smesa->FbBase + smesa->drawOffset); \
+ char *read_buf = (char *)(smesa->FbBase + smesa->readOffset); \
+ GLuint p; \
+ (void) read_buf; (void) buf; (void) p
+
+#define LOCAL_DEPTH_VARS \
+ sisContextPtr smesa = SIS_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = smesa->driDrawable; \
+ char *buf = smesa->depthbuffer; \
+
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
+
+#define HW_LOCK() do {} while(0);
+
+#define HW_UNLOCK() do {} while(0);
+
+/* RGB565 */
+#define SPANTMP_PIXEL_FMT GL_RGB
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
+
+#define TAG(x) sis##x##_RGB565
+#define TAG2(x,y) sis##x##_RGB565##y
+#include "spantmp2.h"
+
+
+/* ARGB8888 */
+/* FIXME the old code always read back alpha as 0xff, i.e. fully opaque.
+ Was there a reason to do so ? If so that'll won't work with that template... */
+#define SPANTMP_PIXEL_FMT GL_BGRA
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
+
+#define TAG(x) sis##x##_ARGB8888
+#define TAG2(x,y) sis##x##_ARGB8888##y
+#include "spantmp2.h"
+
+
+/* 16 bit depthbuffer functions.
+ */
+#define WRITE_DEPTH( _x, _y, d ) \
+ *(GLushort *)(buf + (_x)*2 + (_y)*smesa->depthPitch) = d;
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLushort *)(buf + (_x)*2 + (_y)*smesa->depthPitch);
+
+#define TAG(x) sis##x##_16
+#include "depthtmp.h"
+
+
+/* 32 bit depthbuffer functions.
+ */
+#define WRITE_DEPTH( _x, _y, d ) \
+ *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) = d;
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch);
+
+#define TAG(x) sis##x##_32
+#include "depthtmp.h"
+
+
+/* 8/24 bit interleaved depth/stencil functions
+ */
+#define WRITE_DEPTH( _x, _y, d ) { \
+ GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch); \
+ tmp &= 0xff000000; \
+ tmp |= (d & 0x00ffffff); \
+ *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) = tmp; \
+}
+
+#define READ_DEPTH( d, _x, _y ) { \
+ d = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) & 0x00ffffff; \
+}
+
+#define TAG(x) sis##x##_24_8
+#include "depthtmp.h"
+
+#define WRITE_STENCIL( _x, _y, d ) { \
+ GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch); \
+ tmp &= 0x00ffffff; \
+ tmp |= (d << 24); \
+ *(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) = tmp; \
+}
+
+#define READ_STENCIL( d, _x, _y ) \
+ d = (*(GLuint *)(buf + (_x)*4 + (_y)*smesa->depthPitch) & 0xff000000) >> 24;
+
+#define TAG(x) sis##x##_24_8
+#include "stenciltmp.h"
+
+/*
+ * This function is called to specify which buffer to read and write
+ * for software rasterization (swrast) fallbacks. This doesn't necessarily
+ * correspond to glDrawBuffer() or glReadBuffer() calls.
+ */
+static void sisDDSetBuffer( GLcontext *ctx,
+ GLframebuffer *colorBuffer,
+ GLuint bufferBit )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ switch ( bufferBit ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ smesa->drawOffset = smesa->readOffset = smesa->frontOffset;
+ smesa->drawPitch = smesa->readPitch = smesa->frontPitch;
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ smesa->drawOffset = smesa->readOffset = smesa->backOffset;
+ smesa->drawPitch = smesa->readPitch = smesa->backPitch;
+ break;
+ default:
+ break;
+ }
+}
+
+void sisSpanRenderStart( GLcontext *ctx )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ SIS_FIREVERTICES(smesa);
+ LOCK_HARDWARE();
+ WaitEngIdle( smesa );
+}
+
+void sisSpanRenderFinish( GLcontext *ctx )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ _swrast_flush( ctx );
+ UNLOCK_HARDWARE();
+}
+
+void
+sisDDInitSpanFuncs( GLcontext *ctx )
+{
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetBuffer = sisDDSetBuffer;
+ swdd->SpanRenderStart = sisSpanRenderStart;
+ swdd->SpanRenderFinish = sisSpanRenderFinish;
+}
+
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+sisSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ sisInitPointers_RGB565( &drb->Base );
+ }
+ else {
+ sisInitPointers_ARGB8888( &drb->Base );
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = sisReadDepthSpan_16;
+ drb->Base.GetValues = sisReadDepthPixels_16;
+ drb->Base.PutRow = sisWriteDepthSpan_16;
+ drb->Base.PutMonoRow = sisWriteMonoDepthSpan_16;
+ drb->Base.PutValues = sisWriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = sisReadDepthSpan_24_8;
+ drb->Base.GetValues = sisReadDepthPixels_24_8;
+ drb->Base.PutRow = sisWriteDepthSpan_24_8;
+ drb->Base.PutMonoRow = sisWriteMonoDepthSpan_24_8;
+ drb->Base.PutValues = sisWriteDepthPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
+ drb->Base.GetRow = sisReadDepthSpan_32;
+ drb->Base.GetValues = sisReadDepthPixels_32;
+ drb->Base.PutRow = sisWriteDepthSpan_32;
+ drb->Base.PutMonoRow = sisWriteMonoDepthSpan_32;
+ drb->Base.PutValues = sisWriteDepthPixels_32;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = sisReadStencilSpan_24_8;
+ drb->Base.GetValues = sisReadStencilPixels_24_8;
+ drb->Base.PutRow = sisWriteStencilSpan_24_8;
+ drb->Base.PutMonoRow = sisWriteMonoStencilSpan_24_8;
+ drb->Base.PutValues = sisWriteStencilPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_span.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_span.h
new file mode 100644
index 000000000..7c73bc6d3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_span.h
@@ -0,0 +1,46 @@
+/**************************************************************************
+
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT 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.
+
+**************************************************************************/
+/* $XFree86$ */
+
+/*
+ * Authors:
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#ifndef __SIS_SPAN_H__
+#define __SIS_SPAN_H__
+
+#include "drirenderbuffer.h"
+
+
+extern void sisSpanRenderStart( GLcontext *ctx );
+extern void sisSpanRenderFinish( GLcontext *ctx );
+
+extern void sisDDInitSpanFuncs( GLcontext *ctx );
+
+extern void
+sisSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_state.c
new file mode 100644
index 000000000..db58e9090
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_state.c
@@ -0,0 +1,853 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP 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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_ctx.c,v 1.3 2000/09/26 15:56:48 tsi Exp $ */
+
+/*
+ * Authors:
+ * Sung-Ching Lin <sclin@sis.com.tw>
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#include "sis_context.h"
+#include "sis_state.h"
+#include "sis_tris.h"
+#include "sis_lock.h"
+#include "sis_tex.h"
+
+#include "context.h"
+#include "buffers.h"
+#include "enums.h"
+#include "colormac.h"
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "tnl/t_pipeline.h"
+
+/* =============================================================
+ * Alpha blending
+ */
+
+static void
+sisDDAlphaFunc( GLcontext * ctx, GLenum func, GLfloat ref )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ GLubyte refbyte;
+
+ __GLSiSHardware *prev = &smesa->prev;
+ __GLSiSHardware *current = &smesa->current;
+
+ CLAMPED_FLOAT_TO_UBYTE(refbyte, ref);
+ current->hwAlpha = refbyte << 16;
+
+ /* Alpha Test function */
+ switch (func)
+ {
+ case GL_NEVER:
+ current->hwAlpha |= SiS_ALPHA_NEVER;
+ break;
+ case GL_LESS:
+ current->hwAlpha |= SiS_ALPHA_LESS;
+ break;
+ case GL_EQUAL:
+ current->hwAlpha |= SiS_ALPHA_EQUAL;
+ break;
+ case GL_LEQUAL:
+ current->hwAlpha |= SiS_ALPHA_LEQUAL;
+ break;
+ case GL_GREATER:
+ current->hwAlpha |= SiS_ALPHA_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ current->hwAlpha |= SiS_ALPHA_NOTEQUAL;
+ break;
+ case GL_GEQUAL:
+ current->hwAlpha |= SiS_ALPHA_GEQUAL;
+ break;
+ case GL_ALWAYS:
+ current->hwAlpha |= SiS_ALPHA_ALWAYS;
+ break;
+ }
+
+ prev->hwAlpha = current->hwAlpha;
+ smesa->GlobalFlag |= GFLAG_ALPHASETTING;
+}
+
+static void
+sisDDBlendFuncSeparate( GLcontext *ctx,
+ GLenum sfactorRGB, GLenum dfactorRGB,
+ GLenum sfactorA, GLenum dfactorA )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ __GLSiSHardware *prev = &smesa->prev;
+ __GLSiSHardware *current = &smesa->current;
+
+ current->hwDstSrcBlend = 0;
+
+ switch (dfactorRGB)
+ {
+ case GL_ZERO:
+ current->hwDstSrcBlend |= SiS_D_ZERO;
+ break;
+ case GL_ONE:
+ current->hwDstSrcBlend |= SiS_D_ONE;
+ break;
+ case GL_SRC_COLOR:
+ current->hwDstSrcBlend |= SiS_D_SRC_COLOR;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ current->hwDstSrcBlend |= SiS_D_ONE_MINUS_SRC_COLOR;
+ break;
+ case GL_SRC_ALPHA:
+ current->hwDstSrcBlend |= SiS_D_SRC_ALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ current->hwDstSrcBlend |= SiS_D_ONE_MINUS_SRC_ALPHA;
+ break;
+ case GL_DST_COLOR:
+ current->hwDstSrcBlend |= SiS_D_DST_COLOR;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ current->hwDstSrcBlend |= SiS_D_ONE_MINUS_DST_COLOR;
+ break;
+ case GL_DST_ALPHA:
+ current->hwDstSrcBlend |= SiS_D_DST_ALPHA;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ current->hwDstSrcBlend |= SiS_D_ONE_MINUS_DST_ALPHA;
+ break;
+ default:
+ fprintf(stderr, "Unknown dst blend function 0x%x\n", dfactorRGB);
+ break;
+ }
+
+ switch (sfactorRGB)
+ {
+ case GL_ZERO:
+ current->hwDstSrcBlend |= SiS_S_ZERO;
+ break;
+ case GL_ONE:
+ current->hwDstSrcBlend |= SiS_S_ONE;
+ break;
+ case GL_SRC_COLOR:
+ current->hwDstSrcBlend |= SiS_S_SRC_COLOR;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ current->hwDstSrcBlend |= SiS_S_ONE_MINUS_SRC_COLOR;
+ break;
+ case GL_SRC_ALPHA:
+ current->hwDstSrcBlend |= SiS_S_SRC_ALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ current->hwDstSrcBlend |= SiS_S_ONE_MINUS_SRC_ALPHA;
+ break;
+ case GL_DST_COLOR:
+ current->hwDstSrcBlend |= SiS_S_DST_COLOR;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ current->hwDstSrcBlend |= SiS_S_ONE_MINUS_DST_COLOR;
+ break;
+ case GL_DST_ALPHA:
+ current->hwDstSrcBlend |= SiS_S_DST_ALPHA;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ current->hwDstSrcBlend |= SiS_S_ONE_MINUS_DST_ALPHA;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ current->hwDstSrcBlend |= SiS_S_SRC_ALPHA_SATURATE;
+ break;
+ default:
+ fprintf(stderr, "Unknown src blend function 0x%x\n", sfactorRGB);
+ break;
+ }
+
+ if (current->hwDstSrcBlend != prev->hwDstSrcBlend) {
+ prev->hwDstSrcBlend = current->hwDstSrcBlend;
+ smesa->GlobalFlag |= GFLAG_DSTBLEND;
+ }
+}
+
+/* =============================================================
+ * Depth testing
+ */
+
+static void
+sisDDDepthFunc( GLcontext * ctx, GLenum func )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ __GLSiSHardware *prev = &smesa->prev;
+ __GLSiSHardware *current = &smesa->current;
+
+ current->hwZ &= ~MASK_ZTestMode;
+ switch (func)
+ {
+ case GL_LESS:
+ current->hwZ |= SiS_Z_COMP_S_LT_B;
+ break;
+ case GL_GEQUAL:
+ current->hwZ |= SiS_Z_COMP_S_GE_B;
+ break;
+ case GL_LEQUAL:
+ current->hwZ |= SiS_Z_COMP_S_LE_B;
+ break;
+ case GL_GREATER:
+ current->hwZ |= SiS_Z_COMP_S_GT_B;
+ break;
+ case GL_NOTEQUAL:
+ current->hwZ |= SiS_Z_COMP_S_NE_B;
+ break;
+ case GL_EQUAL:
+ current->hwZ |= SiS_Z_COMP_S_EQ_B;
+ break;
+ case GL_ALWAYS:
+ current->hwZ |= SiS_Z_COMP_ALWAYS;
+ break;
+ case GL_NEVER:
+ current->hwZ |= SiS_Z_COMP_NEVER;
+ break;
+ }
+
+ if (current->hwZ != prev->hwZ) {
+ prev->hwZ = current->hwZ;
+ smesa->GlobalFlag |= GFLAG_ZSETTING;
+ }
+}
+
+void
+sisDDDepthMask( GLcontext * ctx, GLboolean flag )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ __GLSiSHardware *prev = &smesa->prev;
+ __GLSiSHardware *current = &smesa->current;
+
+ if (!ctx->Depth.Test)
+ flag = GL_FALSE;
+
+ if (ctx->Visual.stencilBits) {
+ if (flag || (ctx->Stencil.WriteMask[0] != 0)) {
+ current->hwCapEnable |= MASK_ZWriteEnable;
+ if (flag && (ctx->Stencil.WriteMask[0] == 0xff)) {
+ current->hwCapEnable2 &= ~MASK_ZMaskWriteEnable;
+ } else {
+ current->hwCapEnable2 |= MASK_ZMaskWriteEnable;
+ current->hwZMask = (ctx->Stencil.WriteMask[0] << 24) |
+ ((flag) ? 0x00ffffff : 0);
+
+ if (current->hwZMask ^ prev->hwZMask) {
+ prev->hwZMask = current->hwZMask;
+ smesa->GlobalFlag |= GFLAG_ZSETTING;
+ }
+ }
+ } else {
+ current->hwCapEnable &= ~MASK_ZWriteEnable;
+ }
+ } else {
+ if (flag) {
+ current->hwCapEnable |= MASK_ZWriteEnable;
+ current->hwCapEnable2 &= ~MASK_ZMaskWriteEnable;
+ } else {
+ current->hwCapEnable &= ~MASK_ZWriteEnable;
+ }
+ }
+}
+
+/* =============================================================
+ * Clipping
+ */
+
+void
+sisUpdateClipping( GLcontext *ctx )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ __GLSiSHardware *prev = &smesa->prev;
+ __GLSiSHardware *current = &smesa->current;
+
+ GLint x1, y1, x2, y2;
+
+ x1 = 0;
+ y1 = 0;
+ x2 = smesa->width - 1;
+ y2 = smesa->height - 1;
+
+ if (ctx->Scissor.Enabled) {
+ if (ctx->Scissor.X > x1)
+ x1 = ctx->Scissor.X;
+ if (ctx->Scissor.Y > y1)
+ y1 = ctx->Scissor.Y;
+ if (ctx->Scissor.X + ctx->Scissor.Width - 1 < x2)
+ x2 = ctx->Scissor.X + ctx->Scissor.Width - 1;
+ if (ctx->Scissor.Y + ctx->Scissor.Height - 1 < y2)
+ y2 = ctx->Scissor.Y + ctx->Scissor.Height - 1;
+ }
+
+ y1 = Y_FLIP(y1);
+ y2 = Y_FLIP(y2);
+
+ current->clipTopBottom = (y2 << 13) | y1;
+ current->clipLeftRight = (x1 << 13) | x2;
+
+ if ((current->clipTopBottom ^ prev->clipTopBottom) ||
+ (current->clipLeftRight ^ prev->clipLeftRight))
+ {
+ prev->clipTopBottom = current->clipTopBottom;
+ prev->clipLeftRight = current->clipLeftRight;
+ smesa->GlobalFlag |= GFLAG_CLIPPING;
+ }
+}
+
+static void
+sisDDScissor( GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h )
+{
+ if (ctx->Scissor.Enabled)
+ sisUpdateClipping( ctx );
+}
+
+/* =============================================================
+ * Culling
+ */
+
+static void
+sisUpdateCull( GLcontext *ctx )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ GLint cullflag, frontface;
+
+ cullflag = ctx->Polygon.CullFaceMode;
+ frontface = ctx->Polygon.FrontFace;
+
+ smesa->AGPParseSet &= ~(MASK_PsCullDirection_CCW);
+ smesa->dwPrimitiveSet &= ~(MASK_CullDirection);
+
+ if((cullflag == GL_FRONT && frontface == GL_CCW) ||
+ (cullflag == GL_BACK && frontface == GL_CW))
+ {
+ smesa->AGPParseSet |= MASK_PsCullDirection_CCW;
+ smesa->dwPrimitiveSet |= OP_3D_CullDirection_CCW;
+ }
+}
+
+
+static void
+sisDDCullFace( GLcontext *ctx, GLenum mode )
+{
+ sisUpdateCull( ctx );
+}
+
+static void
+sisDDFrontFace( GLcontext *ctx, GLenum mode )
+{
+ sisUpdateCull( ctx );
+}
+
+/* =============================================================
+ * Masks
+ */
+
+static void sisDDColorMask( GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ __GLSiSHardware *prev = &smesa->prev;
+ __GLSiSHardware *current = &smesa->current;
+
+ if (r && g && b && ((ctx->Visual.alphaBits == 0) || a)) {
+ current->hwCapEnable2 &= ~(MASK_AlphaMaskWriteEnable |
+ MASK_ColorMaskWriteEnable);
+ } else {
+ current->hwCapEnable2 |= (MASK_AlphaMaskWriteEnable |
+ MASK_ColorMaskWriteEnable);
+
+ current->hwDstMask = (r) ? smesa->redMask : 0 |
+ (g) ? smesa->greenMask : 0 |
+ (b) ? smesa->blueMask : 0 |
+ (a) ? smesa->alphaMask : 0;
+ }
+
+ if (current->hwDstMask != prev->hwDstMask) {
+ prev->hwDstMask = current->hwDstMask;
+ smesa->GlobalFlag |= GFLAG_DESTSETTING;
+ }
+}
+
+/* =============================================================
+ * Rendering attributes
+ */
+
+static void sisDDShadeModel( GLcontext *ctx, GLenum mode )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ /* Signal to sisRasterPrimitive to recalculate dwPrimitiveSet */
+ smesa->hw_primitive = -1;
+}
+
+/* =============================================================
+ * Window position
+ */
+
+/* =============================================================
+ * Viewport
+ */
+
+static void sisCalcViewport( GLcontext *ctx )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat *m = smesa->hw_viewport;
+
+ /* See also sis_translate_vertex.
+ */
+ m[MAT_SX] = v[MAT_SX];
+ m[MAT_TX] = v[MAT_TX] + SUBPIXEL_X;
+ m[MAT_SY] = - v[MAT_SY];
+ m[MAT_TY] = - v[MAT_TY] + smesa->driDrawable->h + SUBPIXEL_Y;
+ m[MAT_SZ] = v[MAT_SZ] * smesa->depth_scale;
+ m[MAT_TZ] = v[MAT_TZ] * smesa->depth_scale;
+}
+
+static void sisDDViewport( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
+ sisCalcViewport( ctx );
+}
+
+static void sisDDDepthRange( GLcontext *ctx,
+ GLclampd nearval, GLclampd farval )
+{
+ sisCalcViewport( ctx );
+}
+
+/* =============================================================
+ * Miscellaneous
+ */
+
+static void
+sisDDLogicOpCode( GLcontext *ctx, GLenum opcode )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ __GLSiSHardware *prev = &smesa->prev;
+ __GLSiSHardware *current = &smesa->current;
+
+ current->hwDstSet &= ~MASK_ROP2;
+ switch (opcode)
+ {
+ case GL_CLEAR:
+ current->hwDstSet |= LOP_CLEAR;
+ break;
+ case GL_SET:
+ current->hwDstSet |= LOP_SET;
+ break;
+ case GL_COPY:
+ current->hwDstSet |= LOP_COPY;
+ break;
+ case GL_COPY_INVERTED:
+ current->hwDstSet |= LOP_COPY_INVERTED;
+ break;
+ case GL_NOOP:
+ current->hwDstSet |= LOP_NOOP;
+ break;
+ case GL_INVERT:
+ current->hwDstSet |= LOP_INVERT;
+ break;
+ case GL_AND:
+ current->hwDstSet |= LOP_AND;
+ break;
+ case GL_NAND:
+ current->hwDstSet |= LOP_NAND;
+ break;
+ case GL_OR:
+ current->hwDstSet |= LOP_OR;
+ break;
+ case GL_NOR:
+ current->hwDstSet |= LOP_NOR;
+ break;
+ case GL_XOR:
+ current->hwDstSet |= LOP_XOR;
+ break;
+ case GL_EQUIV:
+ current->hwDstSet |= LOP_EQUIV;
+ break;
+ case GL_AND_REVERSE:
+ current->hwDstSet |= LOP_AND_REVERSE;
+ break;
+ case GL_AND_INVERTED:
+ current->hwDstSet |= LOP_AND_INVERTED;
+ break;
+ case GL_OR_REVERSE:
+ current->hwDstSet |= LOP_OR_REVERSE;
+ break;
+ case GL_OR_INVERTED:
+ current->hwDstSet |= LOP_OR_INVERTED;
+ break;
+ }
+
+ if (current->hwDstSet ^ prev->hwDstSet) {
+ prev->hwDstSet = current->hwDstSet;
+ smesa->GlobalFlag |= GFLAG_DESTSETTING;
+ }
+}
+
+void sisDDDrawBuffer( GLcontext *ctx, GLenum mode )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ __GLSiSHardware *prev = &smesa->prev;
+ __GLSiSHardware *current = &smesa->current;
+
+ /*
+ * _DrawDestMask is easier to cope with than <mode>.
+ */
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ case BUFFER_BIT_BACK_LEFT:
+ FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ break;
+ default:
+ /* GL_NONE or GL_FRONT_AND_BACK or stereo left&right, etc */
+ FALLBACK( smesa, SIS_FALLBACK_DRAW_BUFFER, GL_TRUE );
+ return;
+ }
+
+ /* We want to update the s/w rast state too so that sisDDSetBuffer()
+ * gets called.
+ */
+ _swrast_DrawBuffer(ctx, mode);
+
+ current->hwOffsetDest = (smesa->drawOffset) >> 1;
+ current->hwDstSet &= ~MASK_DstBufferPitch;
+ current->hwDstSet |= smesa->drawPitch >> 2;
+
+ if (current->hwDstSet != prev->hwDstSet) {
+ prev->hwDstSet = current->hwDstSet;
+ smesa->GlobalFlag |= GFLAG_DESTSETTING;
+ }
+
+ if (current->hwOffsetDest != prev->hwOffsetDest) {
+ prev->hwOffsetDest = current->hwOffsetDest;
+ smesa->GlobalFlag |= GFLAG_DESTSETTING;
+ }
+}
+
+/* =============================================================
+ * Polygon stipple
+ */
+
+/* =============================================================
+ * Render mode
+ */
+
+/* =============================================================
+ * State enable/disable
+ */
+
+static void
+sisDDEnable( GLcontext * ctx, GLenum cap, GLboolean state )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ __GLSiSHardware *current = &smesa->current;
+
+ switch (cap)
+ {
+ case GL_ALPHA_TEST:
+ if (state)
+ current->hwCapEnable |= MASK_AlphaTestEnable;
+ else
+ current->hwCapEnable &= ~MASK_AlphaTestEnable;
+ break;
+ case GL_BLEND:
+ /* TODO: */
+ if (state)
+ /* if (state & !ctx->Color.ColorLogicOpEnabled) */
+ current->hwCapEnable |= MASK_BlendEnable;
+ else
+ current->hwCapEnable &= ~MASK_BlendEnable;
+ break;
+ case GL_CULL_FACE:
+ if (state)
+ current->hwCapEnable |= MASK_CullEnable;
+ else
+ current->hwCapEnable &= ~MASK_CullEnable;
+ break;
+ case GL_DEPTH_TEST:
+ if (state && smesa->depthbuffer)
+ current->hwCapEnable |= MASK_ZTestEnable;
+ else
+ current->hwCapEnable &= ~MASK_ZTestEnable;
+ sisDDDepthMask( ctx, ctx->Depth.Mask );
+ break;
+ case GL_DITHER:
+ if (state)
+ current->hwCapEnable |= MASK_DitherEnable;
+ else
+ current->hwCapEnable &= ~MASK_DitherEnable;
+ break;
+ case GL_FOG:
+ if (state)
+ current->hwCapEnable |= MASK_FogEnable;
+ else
+ current->hwCapEnable &= ~MASK_FogEnable;
+ break;
+ case GL_COLOR_LOGIC_OP:
+ if (state)
+ sisDDLogicOpCode( ctx, ctx->Color.LogicOp );
+ else
+ sisDDLogicOpCode( ctx, GL_COPY );
+ break;
+ case GL_SCISSOR_TEST:
+ sisUpdateClipping( ctx );
+ break;
+ case GL_STENCIL_TEST:
+ if (state) {
+ if (smesa->zFormat != SiS_ZFORMAT_S8Z24)
+ FALLBACK(smesa, SIS_FALLBACK_STENCIL, 1);
+ else
+ current->hwCapEnable |= (MASK_StencilTestEnable |
+ MASK_StencilWriteEnable);
+ } else {
+ FALLBACK(smesa, SIS_FALLBACK_STENCIL, 0);
+ current->hwCapEnable &= ~(MASK_StencilTestEnable |
+ MASK_StencilWriteEnable);
+ }
+ break;
+ }
+}
+
+
+/* =============================================================
+ * State initialization, management
+ */
+
+/* Called before beginning of rendering. */
+void
+sisUpdateHWState( GLcontext *ctx )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ __GLSiSHardware *prev = &smesa->prev;
+ __GLSiSHardware *current = &smesa->current;
+
+ /* enable setting 1 */
+ if (current->hwCapEnable ^ prev->hwCapEnable) {
+ prev->hwCapEnable = current->hwCapEnable;
+ smesa->GlobalFlag |= GFLAG_ENABLESETTING;
+ }
+
+ /* enable setting 2 */
+ if (current->hwCapEnable2 ^ prev->hwCapEnable2) {
+ prev->hwCapEnable2 = current->hwCapEnable2;
+ smesa->GlobalFlag |= GFLAG_ENABLESETTING2;
+ }
+
+ if (smesa->GlobalFlag & GFLAG_RENDER_STATES)
+ sis_update_render_state( smesa );
+
+ if (smesa->GlobalFlag & GFLAG_TEXTURE_STATES)
+ sis_update_texture_state( smesa );
+}
+
+static void
+sisDDInvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ smesa->NewGLState |= new_state;
+}
+
+/* Initialize the context's hardware state.
+ */
+void sisDDInitState( sisContextPtr smesa )
+{
+ __GLSiSHardware *current = &smesa->current;
+ __GLSiSHardware *prev = &(smesa->prev);
+ GLcontext *ctx = smesa->glCtx;
+
+ /* add Texture Perspective Enable */
+ prev->hwCapEnable = MASK_FogPerspectiveEnable | MASK_TextureCacheEnable |
+ MASK_TexturePerspectiveEnable | MASK_DitherEnable;
+ /*| MASK_SpecularEnable*/
+
+ /*
+ prev->hwCapEnable2 = 0x00aa0080;
+ */
+ /* if multi-texture enabled, disable Z pre-test */
+ prev->hwCapEnable2 = MASK_TextureMipmapBiasEnable;
+
+ /* Z test mode is LESS */
+ prev->hwZ = SiS_Z_COMP_S_LT_B;
+
+ /* Depth mask */
+ prev->hwZMask = 0xffffffff;
+
+ /* Alpha test mode is ALWAYS, alpha ref value is 0 */
+ prev->hwAlpha = SiS_ALPHA_ALWAYS;
+
+ /* ROP2 is COPYPEN */
+ prev->hwDstSet = LOP_COPY;
+
+ /* color mask */
+ prev->hwDstMask = 0xffffffff;
+
+ /* LinePattern is 0, Repeat Factor is 0 */
+ prev->hwLinePattern = 0x00008000;
+
+ /* Src blend is BLEND_ONE, Dst blend is D3DBLEND_ZERO */
+ prev->hwDstSrcBlend = SiS_S_ONE | SiS_D_ZERO;
+
+ /* Stenciling disabled, function ALWAYS, ref value zero, mask all ones */
+ prev->hwStSetting = STENCIL_FORMAT_8 | SiS_STENCIL_ALWAYS | 0xff;
+ /* Op is KEEP for all three operations */
+ prev->hwStSetting2 = SiS_SFAIL_KEEP | SiS_SPASS_ZFAIL_KEEP |
+ SiS_SPASS_ZPASS_KEEP;
+
+ /* Texture mapping mode is Tile */
+#if 0
+ prev->texture[0].hwTextureSet = 0x00030000;
+#endif
+ /* Magnified & minified texture filter is NEAREST */
+#if 0
+ prev->texture[0].hwTextureMip = 0;
+#endif
+
+ /* Texture Blending setting -- use fragment color/alpha*/
+ prev->hwTexBlendColor0 = STAGE0_C_CF;
+ prev->hwTexBlendColor1 = STAGE1_C_CF;
+ prev->hwTexBlendAlpha0 = STAGE0_A_AF;
+ prev->hwTexBlendAlpha1 = STAGE1_A_AF;
+
+ switch (smesa->bytesPerPixel)
+ {
+ case 2:
+ prev->hwDstSet |= DST_FORMAT_RGB_565;
+ break;
+ case 4:
+ prev->hwDstSet |= DST_FORMAT_ARGB_8888;
+ break;
+ }
+
+ switch (ctx->Visual.depthBits)
+ {
+ case 0:
+ prev->hwCapEnable &= ~MASK_ZWriteEnable;
+ case 16:
+ smesa->zFormat = SiS_ZFORMAT_Z16;
+ prev->hwCapEnable |= MASK_ZWriteEnable;
+ smesa->depth_scale = 1.0 / (GLfloat)0xffff;
+ break;
+ case 32:
+ smesa->zFormat = SiS_ZFORMAT_Z32;
+ prev->hwCapEnable |= MASK_ZWriteEnable;
+ smesa->depth_scale = 1.0 / (GLfloat)0xffffffff;
+ break;
+ case 24:
+ assert (ctx->Visual.stencilBits);
+ smesa->zFormat = SiS_ZFORMAT_S8Z24;
+ prev->hwCapEnable |= MASK_StencilBufferEnable;
+ prev->hwCapEnable |= MASK_ZWriteEnable;
+ smesa->depth_scale = 1.0 / (GLfloat)0xffffff;
+ break;
+ }
+
+ prev->hwZ |= smesa->zFormat;
+
+ /* TODO: need to clear cache? */
+ smesa->clearTexCache = GL_TRUE;
+
+ smesa->clearColorPattern = 0;
+
+ smesa->AGPParseSet = MASK_PsTexture1FromB | MASK_PsBumpTextureFromC;
+ smesa->dwPrimitiveSet = OP_3D_Texture1FromB | OP_3D_TextureBumpFromC;
+
+ sisUpdateZStencilPattern( smesa, 1.0, 0 );
+ sisUpdateCull( ctx );
+
+ memcpy( current, prev, sizeof (__GLSiSHardware) );
+
+ /* Set initial fog settings. Start and end are the same case. */
+ sisDDFogfv( ctx, GL_FOG_DENSITY, &ctx->Fog.Density );
+ sisDDFogfv( ctx, GL_FOG_END, &ctx->Fog.End );
+ sisDDFogfv( ctx, GL_FOG_MODE, NULL );
+}
+
+/* Initialize the driver's state functions.
+ */
+void sisDDInitStateFuncs( GLcontext *ctx )
+{
+ ctx->Driver.UpdateState = sisDDInvalidateState;
+
+ ctx->Driver.Clear = sisDDClear;
+ ctx->Driver.ClearColor = sisDDClearColor;
+ ctx->Driver.ClearDepth = sisDDClearDepth;
+ ctx->Driver.ClearStencil = sisDDClearStencil;
+
+ ctx->Driver.AlphaFunc = sisDDAlphaFunc;
+ ctx->Driver.BlendFuncSeparate = sisDDBlendFuncSeparate;
+ ctx->Driver.ColorMask = sisDDColorMask;
+ ctx->Driver.CullFace = sisDDCullFace;
+ ctx->Driver.DepthMask = sisDDDepthMask;
+ ctx->Driver.DepthFunc = sisDDDepthFunc;
+ ctx->Driver.DepthRange = sisDDDepthRange;
+ ctx->Driver.DrawBuffer = sisDDDrawBuffer;
+ ctx->Driver.Enable = sisDDEnable;
+ ctx->Driver.FrontFace = sisDDFrontFace;
+ ctx->Driver.Fogfv = sisDDFogfv;
+ ctx->Driver.Hint = NULL;
+ ctx->Driver.Lightfv = NULL;
+ ctx->Driver.LogicOpcode = sisDDLogicOpCode;
+ ctx->Driver.PolygonMode = NULL;
+ ctx->Driver.PolygonStipple = NULL;
+ ctx->Driver.ReadBuffer = NULL;
+ ctx->Driver.RenderMode = NULL;
+ ctx->Driver.Scissor = sisDDScissor;
+ ctx->Driver.ShadeModel = sisDDShadeModel;
+ ctx->Driver.Viewport = sisDDViewport;
+
+ /* Pixel path fallbacks. */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_state.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_state.h
new file mode 100644
index 000000000..770ba478a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_state.h
@@ -0,0 +1,54 @@
+/**************************************************************************
+
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT 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.
+
+**************************************************************************/
+/* $XFree86$ */
+
+/*
+ * Authors:
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#ifndef __SIS_STATE_H__
+#define __SIS_STATE_H__
+
+#include "sis_context.h"
+
+extern void sisDDInitState( sisContextPtr smesa );
+extern void sisDDInitStateFuncs( GLcontext *ctx );
+
+extern void sisDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height );
+extern void sisDDClearColor( GLcontext * ctx, const GLfloat color[4] );
+extern void sisDDClearDepth( GLcontext * ctx, GLclampd d );
+extern void sisDDClearStencil( GLcontext * ctx, GLint s );
+extern void sisDDFogfv( GLcontext * ctx, GLenum pname, const GLfloat * params );
+extern void sisDDDepthMask( GLcontext * ctx, GLboolean flag );
+
+extern void sisUpdateClipping( GLcontext * gc );
+extern void sisUpdateZStencilPattern( sisContextPtr smesa, GLclampd z,
+ int stencil );
+extern void sisDDDrawBuffer( GLcontext *ctx, GLenum mode );
+extern void sisUpdateHWState( GLcontext *ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_stencil.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_stencil.c
new file mode 100644
index 000000000..a31d49ca2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_stencil.c
@@ -0,0 +1,185 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP 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.
+
+**************************************************************************/
+/* $XFree86: xc/lib/GL/mesa/src/drv/sis/sis_stencil.c,v 1.3 2000/09/26 15:56:49 tsi Exp $ */
+
+/*
+ * Authors:
+ * Sung-Ching Lin <sclin@sis.com.tw>
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#include "sis_context.h"
+#include "sis_state.h"
+#include "sis_stencil.h"
+
+static void
+sisDDStencilFunc( GLcontext * ctx, GLenum func, GLint ref, GLuint mask )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ __GLSiSHardware *prev = &smesa->prev;
+ __GLSiSHardware *current = &smesa->current;
+
+ /* set reference */
+ current->hwStSetting = STENCIL_FORMAT_8 | (ctx->Stencil.Ref[0] << 8) |
+ ctx->Stencil.ValueMask[0];
+
+ switch (func)
+ {
+ case GL_NEVER:
+ current->hwStSetting |= SiS_STENCIL_NEVER;
+ break;
+ case GL_LESS:
+ current->hwStSetting |= SiS_STENCIL_LESS;
+ break;
+ case GL_EQUAL:
+ current->hwStSetting |= SiS_STENCIL_EQUAL;
+ break;
+ case GL_LEQUAL:
+ current->hwStSetting |= SiS_STENCIL_LEQUAL;
+ break;
+ case GL_GREATER:
+ current->hwStSetting |= SiS_STENCIL_GREATER;
+ break;
+ case GL_NOTEQUAL:
+ current->hwStSetting |= SiS_STENCIL_NOTEQUAL;
+ break;
+ case GL_GEQUAL:
+ current->hwStSetting |= SiS_STENCIL_GEQUAL;
+ break;
+ case GL_ALWAYS:
+ current->hwStSetting |= SiS_STENCIL_ALWAYS;
+ break;
+ }
+
+ if (current->hwStSetting != prev->hwStSetting)
+ {
+ prev->hwStSetting = current->hwStSetting;
+
+ smesa->GlobalFlag |= GFLAG_STENCILSETTING;
+ }
+}
+
+static void
+sisDDStencilMask( GLcontext * ctx, GLuint mask )
+{
+ if (!ctx->Visual.stencilBits)
+ return;
+
+ /* set Z buffer Write Enable */
+ sisDDDepthMask (ctx, ctx->Depth.Mask);
+}
+
+static void
+sisDDStencilOp( GLcontext * ctx, GLenum fail, GLenum zfail, GLenum zpass )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ __GLSiSHardware *prev = &smesa->prev;
+ __GLSiSHardware *current = &smesa->current;
+
+ current->hwStSetting2 &= ~(MASK_StencilZPassOp | MASK_StencilZFailOp |
+ MASK_StencilFailOp);
+
+ switch (fail)
+ {
+ case GL_KEEP:
+ current->hwStSetting2 |= SiS_SFAIL_KEEP;
+ break;
+ case GL_ZERO:
+ current->hwStSetting2 |= SiS_SFAIL_ZERO;
+ break;
+ case GL_REPLACE:
+ current->hwStSetting2 |= SiS_SFAIL_REPLACE;
+ break;
+ case GL_INVERT:
+ current->hwStSetting2 |= SiS_SFAIL_INVERT;
+ break;
+ case GL_INCR:
+ current->hwStSetting2 |= SiS_SFAIL_INCR;
+ break;
+ case GL_DECR:
+ current->hwStSetting2 |= SiS_SFAIL_DECR;
+ break;
+ }
+
+ switch (zfail)
+ {
+ case GL_KEEP:
+ current->hwStSetting2 |= SiS_SPASS_ZFAIL_KEEP;
+ break;
+ case GL_ZERO:
+ current->hwStSetting2 |= SiS_SPASS_ZFAIL_ZERO;
+ break;
+ case GL_REPLACE:
+ current->hwStSetting2 |= SiS_SPASS_ZFAIL_REPLACE;
+ break;
+ case GL_INVERT:
+ current->hwStSetting2 |= SiS_SPASS_ZFAIL_INVERT;
+ break;
+ case GL_INCR:
+ current->hwStSetting2 |= SiS_SPASS_ZFAIL_INCR;
+ break;
+ case GL_DECR:
+ current->hwStSetting2 |= SiS_SPASS_ZFAIL_DECR;
+ break;
+ }
+
+ switch (zpass)
+ {
+ case GL_KEEP:
+ current->hwStSetting2 |= SiS_SPASS_ZPASS_KEEP;
+ break;
+ case GL_ZERO:
+ current->hwStSetting2 |= SiS_SPASS_ZPASS_ZERO;
+ break;
+ case GL_REPLACE:
+ current->hwStSetting2 |= SiS_SPASS_ZPASS_REPLACE;
+ break;
+ case GL_INVERT:
+ current->hwStSetting2 |= SiS_SPASS_ZPASS_INVERT;
+ break;
+ case GL_INCR:
+ current->hwStSetting2 |= SiS_SPASS_ZPASS_INCR;
+ break;
+ case GL_DECR:
+ current->hwStSetting2 |= SiS_SPASS_ZPASS_DECR;
+ break;
+ }
+
+ if (current->hwStSetting2 != prev->hwStSetting2)
+ {
+ prev->hwStSetting2 = current->hwStSetting2;
+ smesa->GlobalFlag |= GFLAG_STENCILSETTING;
+ }
+}
+
+void
+sisDDInitStencilFuncs( GLcontext *ctx )
+{
+ ctx->Driver.StencilFunc = sisDDStencilFunc;
+ ctx->Driver.StencilMask = sisDDStencilMask;
+ ctx->Driver.StencilOp = sisDDStencilOp;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_stencil.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_stencil.h
new file mode 100644
index 000000000..4a36c98f3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_stencil.h
@@ -0,0 +1,37 @@
+/**************************************************************************
+
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT 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.
+
+**************************************************************************/
+/* $XFree86$ */
+
+/*
+ * Authors:
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#ifndef __SIS_STENCIL_H__
+#define __SIS_STENCIL_H__
+
+extern void sisDDInitStencilFuncs( GLcontext *ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tex.c
new file mode 100644
index 000000000..5fa8256f1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tex.c
@@ -0,0 +1,484 @@
+/**************************************************************************
+
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT 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.
+
+**************************************************************************/
+/* $XFree86$ */
+
+/*
+ * Authors:
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#include "sis_context.h"
+#include "sis_alloc.h"
+#include "sis_tex.h"
+
+#include "swrast/swrast.h"
+#include "imports.h"
+#include "texformat.h"
+#include "texstore.h"
+#include "teximage.h"
+#include "texobj.h"
+
+#define ALIGN(value, align) (GLubyte *)((long)(value + align - 1) & ~(align - 1))
+
+#define TEXTURE_HW_ALIGNMENT 4
+#define TEXTURE_HW_PLUS (4 + 4)
+
+static sisTexObjPtr
+sisAllocTexObj( struct gl_texture_object *texObj )
+{
+ sisTexObjPtr t;
+
+ t = (sisTexObjPtr) CALLOC_STRUCT( sis_tex_obj );
+ texObj->DriverData = t;
+ return t;
+}
+
+static void
+sisAllocTexImage( sisContextPtr smesa, sisTexObjPtr t, int level,
+ const struct gl_texture_image *image )
+{
+ char *addr;
+ int size, texel_size;
+
+ if (t->format == 0) {
+ t->format = image->Format;
+ switch (t->format)
+ {
+ case GL_RGBA:
+ t->hwformat = TEXEL_ARGB_8888_32;
+ break;
+ case GL_INTENSITY:
+ t->hwformat = TEXEL_I8;
+ break;
+ case GL_ALPHA:
+ t->hwformat = TEXEL_A8;
+ break;
+ case GL_LUMINANCE:
+ t->hwformat = TEXEL_L8;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ t->hwformat = TEXEL_AL88;
+ break;
+ case GL_RGB:
+ t->hwformat = TEXEL_ARGB_0888_32;
+ break;
+ default:
+ sis_fatal_error("Bad texture format.\n");
+ }
+ }
+ assert(t->format == image->Format);
+
+ texel_size = image->TexFormat->TexelBytes;
+ size = image->Width * image->Height * texel_size + TEXTURE_HW_PLUS;
+
+ addr = sisAllocFB( smesa, size, &t->image[level].handle );
+ if (addr == NULL) {
+ addr = sisAllocAGP( smesa, size, &t->image[level].handle );
+ if (addr == NULL)
+ sis_fatal_error("Failure to allocate texture memory.\n");
+ t->image[level].memType = AGP_TYPE;
+ }
+ else
+ t->image[level].memType = VIDEO_TYPE;
+
+ t->image[level].Data = ALIGN(addr, TEXTURE_HW_ALIGNMENT);
+ t->image[level].pitch = image->Width * texel_size;
+ t->image[level].size = image->Width * image->Height * texel_size;
+ t->numImages++;
+}
+
+static void
+sisFreeTexImage( sisContextPtr smesa, sisTexObjPtr t, int level )
+{
+ if (t->image[level].Data == NULL)
+ return;
+
+ switch (t->image[level].memType)
+ {
+ case VIDEO_TYPE:
+ sisFreeFB( smesa, t->image[level].handle );
+ break;
+ case AGP_TYPE:
+ sisFreeAGP( smesa, t->image[level].handle );
+ break;
+ }
+ t->image[level].Data = NULL;
+ t->image[level].handle = NULL;
+ /* If there are no textures loaded any more, reset the hw format so the
+ * object can be reused for new formats
+ */
+ t->numImages--;
+ if (t->numImages == 0) {
+ t->format = 0;
+ t->hwformat = 0;
+ }
+}
+
+static void
+sisTexEnv( GLcontext *ctx, GLenum target, GLenum pname, const GLfloat *param )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV;
+}
+
+static void
+sisTexParameter( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj, GLenum pname,
+ const GLfloat *params )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING;
+}
+
+static void
+sisBindTexture( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ sisTexObjPtr t;
+
+ if ( target == GL_TEXTURE_2D || target == GL_TEXTURE_1D ) {
+ if ( texObj->DriverData == NULL ) {
+ sisAllocTexObj( texObj );
+ }
+ }
+
+ t = texObj->DriverData;
+ if (!t)
+ return;
+
+ if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != t->format) {
+ smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV;
+ smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = t->format;
+ }
+ smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING;
+}
+
+static void
+sisDeleteTexture( GLcontext * ctx, struct gl_texture_object *texObj )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ sisTexObjPtr t;
+ int i;
+
+ smesa->clearTexCache = GL_TRUE;
+
+ t = texObj->DriverData;
+ if (t == NULL) {
+ /*
+ * this shows the texture is default object and never be a
+ * argument of sisTexImage*
+ */
+ return;
+ }
+ for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
+ sisFreeTexImage( smesa, t, i );
+ }
+
+ FREE(t);
+ texObj->DriverData = NULL;
+ /* Free mipmap images and the texture object itself */
+ _mesa_delete_texture_object(ctx, texObj);
+}
+
+static GLboolean sisIsTextureResident( GLcontext * ctx,
+ struct gl_texture_object *texObj )
+{
+ return (texObj->DriverData != NULL);
+}
+
+static const struct gl_texture_format *
+sisChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type )
+{
+ /* XXX 16-bit internal texture formats? */
+ switch ( internalFormat ) {
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ return &_mesa_texformat_a8;
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ return &_mesa_texformat_l8;
+ 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:
+ return &_mesa_texformat_al88;
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ return &_mesa_texformat_i8;
+ case GL_R3_G3_B2:
+ case GL_RGB4:
+ case GL_RGB5:
+ case 3:
+ case GL_RGB:
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ return &_mesa_texformat_argb8888 /*_mesa_texformat_rgb888*/; /* XXX */
+ case GL_RGBA2:
+ case GL_RGBA4:
+ case GL_RGB5_A1:
+ case 4:
+ case GL_RGBA:
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return &_mesa_texformat_argb8888;
+ default:
+ _mesa_problem(ctx, "unexpected format in tdfxDDChooseTextureFormat: %d",
+ internalFormat);
+ return NULL;
+ }
+}
+
+static void sisTexImage1D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ sisTexObjPtr t;
+
+ if ( texObj->DriverData == NULL )
+ sisAllocTexObj( texObj );
+ t = texObj->DriverData;
+
+ /* Note, this will call sisChooseTextureFormat */
+ _mesa_store_teximage1d( ctx, target, level, internalFormat,
+ width, border, format, type,
+ pixels, packing, texObj, texImage );
+
+ /* Allocate offscreen space for the texture */
+ sisFreeTexImage(smesa, t, level);
+ sisAllocTexImage(smesa, t, level, texImage);
+
+ /* Upload the texture */
+ memcpy(t->image[level].Data, texImage->Data, t->image[level].size);
+
+ if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != t->format)
+ {
+ smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV;
+ smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = t->format;
+ }
+ smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING;
+}
+
+
+static void sisTexSubImage1D( 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 )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ sisTexObjPtr t;
+ GLuint copySize;
+ GLint texelBytes;
+ const char *src;
+ GLubyte *dst;
+
+ if ( texObj->DriverData == NULL )
+ sisAllocTexObj( texObj );
+ t = texObj->DriverData;
+
+ _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
+ format, type, pixels, packing, texObj,
+ texImage);
+
+ /* Allocate offscreen space for the texture */
+ sisFreeTexImage(smesa, t, level);
+ sisAllocTexImage(smesa, t, level, texImage);
+
+ /* Upload the texture */
+ texelBytes = texImage->TexFormat->TexelBytes;
+
+ copySize = width * texelBytes;
+ src = (char *)texImage->Data + xoffset * texelBytes;
+ dst = t->image[level].Data + xoffset * texelBytes;
+
+ memcpy( dst, src, copySize );
+
+ smesa->clearTexCache = GL_TRUE;
+
+ if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != t->format)
+ {
+ smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV;
+ smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = t->format;
+ }
+ smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING;
+}
+
+static void sisTexImage2D( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ sisTexObjPtr t;
+
+ if ( texObj->DriverData == NULL )
+ sisAllocTexObj( texObj );
+ t = texObj->DriverData;
+
+ /* Note, this will call sisChooseTextureFormat */
+ _mesa_store_teximage2d(ctx, target, level, internalFormat,
+ width, height, border, format, type, pixels,
+ &ctx->Unpack, texObj, texImage);
+
+ /* Allocate offscreen space for the texture */
+ sisFreeTexImage(smesa, t, level);
+ sisAllocTexImage(smesa, t, level, texImage);
+
+ /* Upload the texture */
+ memcpy(t->image[level].Data, texImage->Data, t->image[level].size);
+
+ if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != t->format)
+ {
+ smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV;
+ smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = t->format;
+ }
+ smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING;
+}
+
+static void sisTexSubImage2D( 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 )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ sisTexObjPtr t;
+ GLuint copySize;
+ GLint texelBytes;
+ const char *src;
+ GLubyte *dst;
+ int j;
+ GLuint soffset;
+
+ if ( texObj->DriverData == NULL )
+ sisAllocTexObj( texObj );
+ t = texObj->DriverData;
+
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
+
+ /* Allocate offscreen space for the texture */
+ sisFreeTexImage(smesa, t, level);
+ sisAllocTexImage(smesa, t, level, texImage);
+
+ /* Upload the texture */
+ texelBytes = texImage->TexFormat->TexelBytes;
+
+ copySize = width * texelBytes;
+ src = (char *)texImage->Data + (xoffset + yoffset * texImage->Width) *
+ texelBytes;
+ dst = t->image[level].Data + (xoffset + yoffset * texImage->Width) *
+ texelBytes;
+ soffset = texImage->Width * texelBytes;
+
+ for (j = yoffset; j < yoffset + height; j++) {
+ memcpy( dst, src, copySize );
+ src += soffset;
+ dst += soffset;
+ }
+
+ smesa->clearTexCache = GL_TRUE;
+
+ if (smesa->PrevTexFormat[ctx->Texture.CurrentUnit] != t->format)
+ {
+ smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURE_ENV;
+ smesa->PrevTexFormat[ctx->Texture.CurrentUnit] = t->format;
+ }
+ smesa->TexStates[ctx->Texture.CurrentUnit] |= NEW_TEXTURING;
+}
+
+
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
+ * Note: this function will be called during context creation to
+ * allocate the default texture objects.
+ * Note: we could use containment here to 'derive' the driver-specific
+ * texture object from the core mesa gl_texture_object. Not done at this time.
+ */
+static struct gl_texture_object *
+sisNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+{
+ struct gl_texture_object *obj;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ return obj;
+}
+
+
+void sisInitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->TexEnv = sisTexEnv;
+ functions->ChooseTextureFormat = sisChooseTextureFormat;
+ functions->TexImage1D = sisTexImage1D;
+ functions->TexSubImage1D = sisTexSubImage1D;
+ functions->TexImage2D = sisTexImage2D;
+ functions->TexSubImage2D = sisTexSubImage2D;
+ functions->TexParameter = sisTexParameter;
+ functions->BindTexture = sisBindTexture;
+ functions->NewTextureObject = sisNewTextureObject;
+ functions->DeleteTexture = sisDeleteTexture;
+ functions->IsTextureResident = sisIsTextureResident;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tex.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tex.h
new file mode 100644
index 000000000..8ddc7c469
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tex.h
@@ -0,0 +1,38 @@
+/**************************************************************************
+
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT 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.
+
+**************************************************************************/
+/* $XFree86$ */
+
+/*
+ * Authors:
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#ifndef __SIS_TEX_H__
+#define __SIS_TEX_H__
+
+extern void sisInitTextureFuncs( struct dd_function_table *table );
+extern void sisUpdateTextureState( GLcontext *ctx );
+
+#endif /* __SIS_TEX_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_texstate.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_texstate.c
new file mode 100644
index 000000000..a18ad06bd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_texstate.c
@@ -0,0 +1,672 @@
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP 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.
+
+**************************************************************************/
+/* $XFree86$ */
+
+/*
+ * Authors:
+ * Sung-Ching Lin <sclin@sis.com.tw>
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "macros.h"
+#include "texformat.h"
+
+#include "sis_context.h"
+#include "sis_state.h"
+#include "sis_tex.h"
+#include "sis_tris.h"
+#include "sis_alloc.h"
+
+static GLint TransferTexturePitch (GLint dwPitch);
+
+/* Handle texenv stuff, called from validate_texture (renderstart) */
+static void
+sis_set_texture_env0( GLcontext *ctx, struct gl_texture_object *texObj,
+ int unit )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ __GLSiSHardware *prev = &smesa->prev;
+ __GLSiSHardware *current = &smesa->current;
+
+ struct gl_texture_unit *texture_unit = &ctx->Texture.Unit[unit];
+
+ sisTexObjPtr t = texObj->DriverData;
+
+ switch (texture_unit->EnvMode)
+ {
+ case GL_REPLACE:
+ FALLBACK(smesa, SIS_FALLBACK_TEXENV0, 0);
+ switch (t->format)
+ {
+ case GL_ALPHA:
+ current->hwTexBlendColor0 = STAGE0_C_CF;
+ current->hwTexBlendAlpha0 = STAGE0_A_AS;
+ break;
+ case GL_LUMINANCE:
+ case GL_RGB:
+ current->hwTexBlendColor0 = STAGE0_C_CS;
+ current->hwTexBlendAlpha0 = STAGE0_A_AF;
+ break;
+ case GL_INTENSITY:
+ case GL_LUMINANCE_ALPHA:
+ case GL_RGBA:
+ current->hwTexBlendColor0 = STAGE0_C_CS;
+ current->hwTexBlendAlpha0 = STAGE0_A_AS;
+ break;
+ }
+ break;
+
+ case GL_MODULATE:
+ FALLBACK(smesa, SIS_FALLBACK_TEXENV0, 0);
+ switch (t->format)
+ {
+ case GL_ALPHA:
+ current->hwTexBlendColor0 = STAGE0_C_CF;
+ current->hwTexBlendAlpha0 = STAGE0_A_AFAS;
+ break;
+ case GL_LUMINANCE:
+ case GL_RGB:
+ current->hwTexBlendColor0 = STAGE0_C_CFCS;
+ current->hwTexBlendAlpha0 = STAGE0_A_AF;
+ break;
+ case GL_INTENSITY:
+ case GL_LUMINANCE_ALPHA:
+ case GL_RGBA:
+ current->hwTexBlendColor0 = STAGE0_C_CFCS;
+ current->hwTexBlendAlpha0 = STAGE0_A_AFAS;
+ break;
+ }
+ break;
+
+ case GL_DECAL:
+ FALLBACK(smesa, SIS_FALLBACK_TEXENV0, 0);
+ switch (t->format)
+ {
+ case GL_RGB:
+ current->hwTexBlendColor0 = STAGE0_C_CS;
+ current->hwTexBlendAlpha0 = STAGE0_A_AF;
+ break;
+ case GL_RGBA:
+ current->hwTexBlendColor0 = STAGE0_C_CFOMAS_CSAS;
+ current->hwTexBlendAlpha0 = STAGE0_A_AF;
+ break;
+ }
+ break;
+
+ case GL_BLEND:
+ FALLBACK(smesa, SIS_FALLBACK_TEXENV0, 1);
+#if 0 /* XXX Blending broken */
+ current->hwTexEnvColor =
+ ((GLint) (texture_unit->EnvColor[3])) << 24 |
+ ((GLint) (texture_unit->EnvColor[0])) << 16 |
+ ((GLint) (texture_unit->EnvColor[1])) << 8 |
+ ((GLint) (texture_unit->EnvColor[2]));
+ switch (t->format)
+ {
+ case GL_ALPHA:
+ current->hwTexBlendColor0 = STAGE0_C_CF;
+ current->hwTexBlendAlpha0 = STAGE0_A_AFAS;
+ break;
+ case GL_LUMINANCE:
+ case GL_RGB:
+ current->hwTexBlendColor0 = STAGE0_C_CFOMCS_CCCS;
+ current->hwTexBlendAlpha0 = STAGE0_A_AF;
+ break;
+ case GL_INTENSITY:
+ current->hwTexBlendColor0 = STAGE0_C_CFOMCS_CCCS;
+ current->hwTexBlendAlpha0 = STAGE0_A_AFOMAS_ACAS;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ case GL_RGBA:
+ current->hwTexBlendColor0 = STAGE0_C_CFOMCS_CCCS;
+ current->hwTexBlendAlpha0 = STAGE0_A_AFAS;
+ break;
+ }
+ break;
+#endif
+ }
+
+ if ((current->hwTexBlendColor0 != prev->hwTexBlendColor0) ||
+ (current->hwTexBlendAlpha0 != prev->hwTexBlendAlpha0) ||
+ (current->hwTexEnvColor != prev->hwTexEnvColor))
+ {
+ prev->hwTexEnvColor = current->hwTexEnvColor;
+ prev->hwTexBlendColor0 = current->hwTexBlendColor0;
+ prev->hwTexBlendAlpha0 = current->hwTexBlendAlpha0;
+ smesa->GlobalFlag |= GFLAG_TEXTUREENV;
+ }
+}
+
+/* Handle texenv stuff, called from validate_texture (renderstart) */
+static void
+sis_set_texture_env1( GLcontext *ctx, struct gl_texture_object *texObj,
+ int unit)
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ __GLSiSHardware *prev = &smesa->prev;
+ __GLSiSHardware *current = &smesa->current;
+
+ struct gl_texture_unit *texture_unit = &ctx->Texture.Unit[unit];
+
+ sisTexObjPtr t = texObj->DriverData;
+
+ switch (texture_unit->EnvMode)
+ {
+ case GL_REPLACE:
+ FALLBACK(smesa, SIS_FALLBACK_TEXENV1, 0);
+ switch (t->format)
+ {
+ case GL_ALPHA:
+ current->hwTexBlendColor1 = STAGE1_C_CF;
+ current->hwTexBlendAlpha1 = STAGE1_A_AS;
+ break;
+ case GL_LUMINANCE:
+ case GL_RGB:
+ current->hwTexBlendColor1 = STAGE1_C_CS;
+ current->hwTexBlendAlpha1 = STAGE1_A_AF;
+ break;
+ case GL_INTENSITY:
+ case GL_LUMINANCE_ALPHA:
+ case GL_RGBA:
+ current->hwTexBlendColor1 = STAGE1_C_CS;
+ current->hwTexBlendAlpha1 = STAGE1_A_AS;
+ break;
+ }
+ break;
+
+ case GL_MODULATE:
+ FALLBACK(smesa, SIS_FALLBACK_TEXENV1, 0);
+ switch (t->format)
+ {
+ case GL_ALPHA:
+ current->hwTexBlendColor1 = STAGE1_C_CF;
+ current->hwTexBlendAlpha1 = STAGE1_A_AFAS;
+ break;
+ case GL_LUMINANCE:
+ case GL_RGB:
+ current->hwTexBlendColor1 = STAGE1_C_CFCS;
+ current->hwTexBlendAlpha1 = STAGE1_A_AF;
+ break;
+ case GL_INTENSITY:
+ case GL_LUMINANCE_ALPHA:
+ case GL_RGBA:
+ current->hwTexBlendColor1 = STAGE1_C_CFCS;
+ current->hwTexBlendAlpha1 = STAGE1_A_AFAS;
+ break;
+ }
+ break;
+
+ case GL_DECAL:
+ FALLBACK(smesa, SIS_FALLBACK_TEXENV1, 0);
+ switch (t->format)
+ {
+ case GL_RGB:
+ current->hwTexBlendColor1 = STAGE1_C_CS;
+ current->hwTexBlendAlpha1 = STAGE1_A_AF;
+ break;
+ case GL_RGBA:
+ current->hwTexBlendColor1 = STAGE1_C_CFOMAS_CSAS;
+ current->hwTexBlendAlpha1 = STAGE1_A_AF;
+ break;
+ }
+ break;
+
+ case GL_BLEND:
+ FALLBACK(smesa, SIS_FALLBACK_TEXENV1, 1);
+#if 0 /* XXX Blending broken */
+ current->hwTexEnvColor =
+ ((GLint) (texture_unit->EnvColor[3])) << 24 |
+ ((GLint) (texture_unit->EnvColor[0])) << 16 |
+ ((GLint) (texture_unit->EnvColor[1])) << 8 |
+ ((GLint) (texture_unit->EnvColor[2]));
+ switch (t->format)
+ {
+ case GL_ALPHA:
+ current->hwTexBlendColor1 = STAGE1_C_CF;
+ current->hwTexBlendAlpha1 = STAGE1_A_AFAS;
+ break;
+ case GL_LUMINANCE:
+ case GL_RGB:
+ current->hwTexBlendColor1 = STAGE1_C_CFOMCS_CCCS;
+ current->hwTexBlendAlpha1 = STAGE1_A_AF;
+ break;
+ case GL_INTENSITY:
+ current->hwTexBlendColor1 = STAGE1_C_CFOMCS_CCCS;
+ current->hwTexBlendAlpha1 = STAGE1_A_AFOMAS_ACAS;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ case GL_RGBA:
+ current->hwTexBlendColor1 = STAGE1_C_CFOMCS_CCCS;
+ current->hwTexBlendAlpha1 = STAGE1_A_AFAS;
+ break;
+ }
+ break;
+#endif
+ }
+
+ if ((current->hwTexBlendColor1 != prev->hwTexBlendColor1) ||
+ (current->hwTexBlendAlpha1 != prev->hwTexBlendAlpha1) ||
+ (current->hwTexEnvColor != prev->hwTexEnvColor))
+ {
+ prev->hwTexBlendColor1 = current->hwTexBlendColor1;
+ prev->hwTexBlendAlpha1 = current->hwTexBlendAlpha1;
+ prev->hwTexEnvColor = current->hwTexEnvColor;
+ smesa->GlobalFlag |= GFLAG_TEXTUREENV_1;
+ }
+}
+
+/* Returns 0 if a software fallback is necessary */
+static GLboolean
+sis_set_texobj_parm( GLcontext *ctx, struct gl_texture_object *texObj,
+ int hw_unit )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ int ok = 1;
+
+ __GLSiSHardware *prev = &smesa->prev;
+ __GLSiSHardware *current = &smesa->current;
+
+ sisTexObjPtr t = texObj->DriverData;
+
+ GLint firstLevel, lastLevel;
+ GLint i;
+
+ current->texture[hw_unit].hwTextureMip = 0UL;
+ current->texture[hw_unit].hwTextureSet = t->hwformat;
+
+ if ((texObj->MinFilter == GL_NEAREST) || (texObj->MinFilter == GL_LINEAR)) {
+ firstLevel = lastLevel = texObj->BaseLevel;
+ } else {
+ /* Compute which mipmap levels we really want to send to the hardware.
+ * This depends on the base image size, GL_TEXTURE_MIN_LOD,
+ * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL and GL_TEXTURE_MAX_LEVEL.
+ * Yes, this looks overly complicated, but it's all needed.
+ */
+
+ firstLevel = texObj->BaseLevel + (GLint)(texObj->MinLod + 0.5);
+ firstLevel = MAX2(firstLevel, texObj->BaseLevel);
+ lastLevel = texObj->BaseLevel + (GLint)(texObj->MaxLod + 0.5);
+ lastLevel = MAX2(lastLevel, texObj->BaseLevel);
+ lastLevel = MIN2(lastLevel, texObj->BaseLevel +
+ texObj->Image[0][texObj->BaseLevel]->MaxLog2);
+ lastLevel = MIN2(lastLevel, texObj->MaxLevel);
+ lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
+ }
+
+ current->texture[hw_unit].hwTextureSet |= (lastLevel << 8);
+
+ switch (texObj->MagFilter)
+ {
+ case GL_NEAREST:
+ current->texture[hw_unit].hwTextureMip |= TEXTURE_FILTER_NEAREST;
+ break;
+ case GL_LINEAR:
+ current->texture[hw_unit].hwTextureMip |= (TEXTURE_FILTER_LINEAR << 3);
+ break;
+ }
+
+ {
+ GLint b;
+
+ /* The mipmap lod biasing is based on experiment. It seems there's a
+ * limit of around +4/-4 to the bias value; we're being conservative.
+ */
+ b = (GLint) (ctx->Texture.Unit[hw_unit].LodBias * 32.0);
+ if (b > 127)
+ b = 127;
+ else if (b < -128)
+ b = -128;
+
+ current->texture[hw_unit].hwTextureMip |= ((b << 4) &
+ MASK_TextureMipmapLodBias);
+ }
+
+ switch (texObj->MinFilter)
+ {
+ case GL_NEAREST:
+ current->texture[hw_unit].hwTextureMip |= TEXTURE_FILTER_NEAREST;
+ break;
+ case GL_LINEAR:
+ current->texture[hw_unit].hwTextureMip |= TEXTURE_FILTER_LINEAR;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ current->texture[hw_unit].hwTextureMip |=
+ TEXTURE_FILTER_NEAREST_MIP_NEAREST;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ current->texture[hw_unit].hwTextureMip |=
+ TEXTURE_FILTER_NEAREST_MIP_LINEAR;
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ current->texture[hw_unit].hwTextureMip |=
+ TEXTURE_FILTER_LINEAR_MIP_NEAREST;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ current->texture[hw_unit].hwTextureMip |=
+ TEXTURE_FILTER_LINEAR_MIP_LINEAR;
+ break;
+ }
+
+ switch (texObj->WrapS)
+ {
+ case GL_REPEAT:
+ current->texture[hw_unit].hwTextureSet |= MASK_TextureWrapU;
+ break;
+ case GL_CLAMP:
+ current->texture[hw_unit].hwTextureSet |= MASK_TextureClampU;
+ break;
+ case GL_CLAMP_TO_EDGE:
+ /*
+ * ?? not support yet
+ */
+ ok = 0;
+ break;
+ }
+
+ switch (texObj->WrapT)
+ {
+ case GL_REPEAT:
+ current->texture[hw_unit].hwTextureSet |= MASK_TextureWrapV;
+ break;
+ case GL_CLAMP:
+ current->texture[hw_unit].hwTextureSet |= MASK_TextureClampV;
+ break;
+ case GL_CLAMP_TO_EDGE:
+ /*
+ * ?? not support yet
+ */
+ ok = 0;
+ break;
+ }
+
+/*
+ if (current->texture[hw_unit].hwTextureSet & MASK_TextureClampU) {
+ current->texture[hw_unit].hwTextureSet &= ~MASK_TextureClampU;
+ current->texture[hw_unit].hwTextureSet |= MASK_TextureBorderU;
+ }
+
+ if (current->texture[hw_unit].hwTextureSet & MASK_TextureClampV) {
+ current->texture[hw_unit].hwTextureSet &= ~MASK_TextureClampV;
+ current->texture[hw_unit].hwTextureSet |= MASK_TextureBorderV;
+ }
+*/
+ current->texture[hw_unit].hwTextureBorderColor =
+ ((GLuint) texObj->BorderColor[3] << 24) +
+ ((GLuint) texObj->BorderColor[0] << 16) +
+ ((GLuint) texObj->BorderColor[1] << 8) +
+ ((GLuint) texObj->BorderColor[2]);
+
+ if (current->texture[hw_unit].hwTextureBorderColor !=
+ prev->texture[hw_unit].hwTextureBorderColor)
+ {
+ prev->texture[hw_unit].hwTextureBorderColor =
+ current->texture[hw_unit].hwTextureBorderColor;
+ if (hw_unit == 1)
+ smesa->GlobalFlag |= GFLAG_TEXBORDERCOLOR_1;
+ else
+ smesa->GlobalFlag |= GFLAG_TEXBORDERCOLOR;
+ }
+
+ current->texture[hw_unit].hwTextureSet |=
+ texObj->Image[0][firstLevel]->WidthLog2 << 4;
+ current->texture[hw_unit].hwTextureSet |=
+ texObj->Image[0][firstLevel]->HeightLog2;
+
+ if (hw_unit == 0)
+ smesa->GlobalFlag |= GFLAG_TEXTUREADDRESS;
+ else
+ smesa->GlobalFlag |= GFLAG_TEXTUREADDRESS_1;
+
+ for (i = firstLevel; i <= lastLevel; i++)
+ {
+ GLuint texOffset = 0;
+ GLuint texPitch = TransferTexturePitch( t->image[i].pitch );
+
+ switch (t->image[i].memType)
+ {
+ case VIDEO_TYPE:
+ texOffset = ((unsigned long)t->image[i].Data - (unsigned long)smesa->FbBase);
+ break;
+ case AGP_TYPE:
+ texOffset = ((unsigned long)t->image[i].Data - (unsigned long)smesa->AGPBase) +
+ (unsigned long) smesa->AGPAddr;
+ current->texture[hw_unit].hwTextureMip |=
+ (MASK_TextureLevel0InSystem << i);
+ break;
+ }
+
+ switch (i)
+ {
+ case 0:
+ prev->texture[hw_unit].texOffset0 = texOffset;
+ prev->texture[hw_unit].texPitch01 = texPitch << 16;
+ break;
+ case 1:
+ prev->texture[hw_unit].texOffset1 = texOffset;
+ prev->texture[hw_unit].texPitch01 |= texPitch;
+ break;
+ case 2:
+ prev->texture[hw_unit].texOffset2 = texOffset;
+ prev->texture[hw_unit].texPitch23 = texPitch << 16;
+ break;
+ case 3:
+ prev->texture[hw_unit].texOffset3 = texOffset;
+ prev->texture[hw_unit].texPitch23 |= texPitch;
+ break;
+ case 4:
+ prev->texture[hw_unit].texOffset4 = texOffset;
+ prev->texture[hw_unit].texPitch45 = texPitch << 16;
+ break;
+ case 5:
+ prev->texture[hw_unit].texOffset5 = texOffset;
+ prev->texture[hw_unit].texPitch45 |= texPitch;
+ break;
+ case 6:
+ prev->texture[hw_unit].texOffset6 = texOffset;
+ prev->texture[hw_unit].texPitch67 = texPitch << 16;
+ break;
+ case 7:
+ prev->texture[hw_unit].texOffset7 = texOffset;
+ prev->texture[hw_unit].texPitch67 |= texPitch;
+ break;
+ case 8:
+ prev->texture[hw_unit].texOffset8 = texOffset;
+ prev->texture[hw_unit].texPitch89 = texPitch << 16;
+ break;
+ case 9:
+ prev->texture[hw_unit].texOffset9 = texOffset;
+ prev->texture[hw_unit].texPitch89 |= texPitch;
+ break;
+ case 10:
+ prev->texture[hw_unit].texOffset10 = texOffset;
+ prev->texture[hw_unit].texPitch10 = texPitch << 16;
+ break;
+ case 11:
+ prev->texture[hw_unit].texOffset11 = texOffset;
+ prev->texture[hw_unit].texPitch10 |= texPitch;
+ break;
+ }
+ }
+
+ if (current->texture[hw_unit].hwTextureSet !=
+ prev->texture[hw_unit].hwTextureSet)
+ {
+ prev->texture[hw_unit].hwTextureSet =
+ current->texture[hw_unit].hwTextureSet;
+ if (hw_unit == 1)
+ smesa->GlobalFlag |= CFLAG_TEXTURERESET_1;
+ else
+ smesa->GlobalFlag |= CFLAG_TEXTURERESET;
+ }
+ if (current->texture[hw_unit].hwTextureMip !=
+ prev->texture[hw_unit].hwTextureMip)
+ {
+ prev->texture[hw_unit].hwTextureMip =
+ current->texture[hw_unit].hwTextureMip;
+ if (hw_unit == 1)
+ smesa->GlobalFlag |= GFLAG_TEXTUREMIPMAP_1;
+ else
+ smesa->GlobalFlag |= GFLAG_TEXTUREMIPMAP;
+ }
+
+ return ok;
+}
+
+/* Disable a texture unit, called from validate_texture */
+static void
+sis_reset_texture_env (GLcontext *ctx, int hw_unit)
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ __GLSiSHardware *prev = &smesa->prev;
+ __GLSiSHardware *current = &smesa->current;
+
+ if (hw_unit == 1)
+ {
+ current->hwTexBlendColor1 = STAGE1_C_CF;
+ current->hwTexBlendAlpha1 = STAGE1_A_AF;
+
+ if ((current->hwTexBlendColor1 != prev->hwTexBlendColor1) ||
+ (current->hwTexBlendAlpha1 != prev->hwTexBlendAlpha1) ||
+ (current->hwTexEnvColor != prev->hwTexEnvColor))
+ {
+ prev->hwTexBlendColor1 = current->hwTexBlendColor1;
+ prev->hwTexBlendAlpha1 = current->hwTexBlendAlpha1;
+ prev->hwTexEnvColor = current->hwTexEnvColor;
+ smesa->GlobalFlag |= GFLAG_TEXTUREENV_1;
+ }
+ } else {
+ current->hwTexBlendColor0 = STAGE0_C_CF;
+ current->hwTexBlendAlpha0 = STAGE0_A_AF;
+
+ if ((current->hwTexBlendColor0 != prev->hwTexBlendColor0) ||
+ (current->hwTexBlendAlpha0 != prev->hwTexBlendAlpha0) ||
+ (current->hwTexEnvColor != prev->hwTexEnvColor))
+ {
+ prev->hwTexBlendColor0 = current->hwTexBlendColor0;
+ prev->hwTexBlendAlpha0 = current->hwTexBlendAlpha0;
+ prev->hwTexEnvColor = current->hwTexEnvColor;
+ smesa->GlobalFlag |= GFLAG_TEXTUREENV;
+ }
+ }
+}
+
+static void updateTextureUnit( GLcontext *ctx, int unit )
+{
+ sisContextPtr smesa = SIS_CONTEXT( ctx );
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *texObj = texUnit->_Current;
+ GLint fallbackbit;
+
+ if (unit == 0)
+ fallbackbit = SIS_FALLBACK_TEXTURE0;
+ else
+ fallbackbit = SIS_FALLBACK_TEXTURE1;
+
+ if (texUnit->_ReallyEnabled & (TEXTURE_1D_BIT | TEXTURE_2D_BIT)) {
+ if (smesa->TexStates[unit] & NEW_TEXTURING) {
+ GLboolean ok;
+
+ ok = sis_set_texobj_parm (ctx, texObj, unit);
+ FALLBACK( smesa, fallbackbit, !ok );
+ }
+ if (smesa->TexStates[unit] & NEW_TEXTURE_ENV) {
+ if (unit == 0)
+ sis_set_texture_env0( ctx, texObj, unit );
+ else
+ sis_set_texture_env1( ctx, texObj, unit );
+ }
+ smesa->TexStates[unit] = 0;
+ } else if ( texUnit->_ReallyEnabled ) {
+ /* fallback */
+ FALLBACK( smesa, fallbackbit, 1 );
+ } else {
+ sis_reset_texture_env( ctx, unit );
+ FALLBACK( smesa, fallbackbit, 0 );
+ }
+}
+
+
+void sisUpdateTextureState( GLcontext *ctx )
+{
+ sisContextPtr smesa = SIS_CONTEXT( ctx );
+ int i;
+ __GLSiSHardware *current = &smesa->current;
+
+#if 1
+ /* TODO : if unmark these, error in multitexture */ /* XXX */
+ for (i = 0; i < SIS_MAX_TEXTURES; i++)
+ smesa->TexStates[i] |= (NEW_TEXTURING | NEW_TEXTURE_ENV);
+#endif
+
+ updateTextureUnit( ctx, 0 );
+ updateTextureUnit( ctx, 1 );
+
+ /* XXX Issues with the 2nd unit but not the first being enabled? */
+ if ( ctx->Texture.Unit[0]._ReallyEnabled &
+ (TEXTURE_1D_BIT | TEXTURE_2D_BIT) ||
+ ctx->Texture.Unit[1]._ReallyEnabled &
+ (TEXTURE_1D_BIT | TEXTURE_2D_BIT) )
+ {
+ current->hwCapEnable |= MASK_TextureEnable;
+ current->hwCapEnable &= ~MASK_TextureNumUsed;
+ if (ctx->Texture.Unit[1]._ReallyEnabled)
+ current->hwCapEnable |= 0x00002000;
+ else
+ current->hwCapEnable |= 0x00001000;
+ } else {
+ current->hwCapEnable &= ~MASK_TextureEnable;
+ }
+}
+
+static GLint
+BitScanForward( GLshort w )
+{
+ GLint i;
+
+ for (i = 0; i < 16; i++) {
+ if (w & (1 << i))
+ break;
+ }
+ return i;
+}
+
+static GLint
+TransferTexturePitch( GLint dwPitch )
+{
+ GLint dwRet, i;
+
+ i = BitScanForward( (GLshort)dwPitch );
+ dwRet = dwPitch >> i;
+ dwRet |= i << 9;
+ return dwRet;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tris.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tris.c
new file mode 100644
index 000000000..fb0fd1ac0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tris.c
@@ -0,0 +1,1071 @@
+/* $XFree86*/ /* -*- c-basic-offset: 3 -*- */
+/**************************************************************************
+
+Copyright 2000 Silicon Integrated Systems Corp, Inc., HsinChu, Taiwan.
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT OR SILICON INTEGRATED SYSTEMS CORP 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:
+ * Sung-Ching Lin <sclin@sis.com.tw>
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "colormac.h"
+#include "macros.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
+#include "sis_context.h"
+#include "sis_tris.h"
+#include "sis_state.h"
+#include "sis_lock.h"
+#include "sis_span.h"
+#include "sis_alloc.h"
+#include "sis_tex.h"
+
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ OP_3D_POINT_DRAW, /* GL_POINTS */
+ OP_3D_LINE_DRAW, /* GL_LINES */
+ OP_3D_LINE_DRAW, /* GL_LINE_LOOP */
+ OP_3D_LINE_DRAW, /* GL_LINE_STRIP */
+ OP_3D_TRIANGLE_DRAW, /* GL_TRIANGLES */
+ OP_3D_TRIANGLE_DRAW, /* GL_TRIANGLE_STRIP */
+ OP_3D_TRIANGLE_DRAW, /* GL_TRIANGLE_FAN */
+ OP_3D_TRIANGLE_DRAW, /* GL_QUADS */
+ OP_3D_TRIANGLE_DRAW, /* GL_QUAD_STRIP */
+ OP_3D_TRIANGLE_DRAW /* GL_POLYGON */
+};
+
+static const GLuint hw_prim_mmio_fire[OP_3D_TRIANGLE_DRAW+1] = {
+ OP_3D_FIRE_TSARGBa,
+ OP_3D_FIRE_TSARGBb,
+ OP_3D_FIRE_TSARGBc
+};
+
+static const GLuint hw_prim_mmio_shade[OP_3D_TRIANGLE_DRAW+1] = {
+ SHADE_FLAT_VertexA,
+ SHADE_FLAT_VertexB,
+ SHADE_FLAT_VertexC
+};
+
+static const GLuint hw_prim_agp_type[OP_3D_TRIANGLE_DRAW+1] = {
+ MASK_PsPointList,
+ MASK_PsLineList,
+ MASK_PsTriangleList
+};
+
+static const GLuint hw_prim_agp_shade[OP_3D_TRIANGLE_DRAW+1] = {
+ MASK_PsShadingFlatA,
+ MASK_PsShadingFlatB,
+ MASK_PsShadingFlatC
+};
+
+static void sisRasterPrimitive( GLcontext *ctx, GLuint hwprim );
+static void sisRenderPrimitive( GLcontext *ctx, GLenum prim );
+
+/***********************************************************************
+ * Emit primitives as inline vertices *
+ ***********************************************************************/
+
+#define HAVE_QUADS 0
+#define HAVE_LINES 1
+#define HAVE_POINTS 1
+#define CTX_ARG sisContextPtr smesa
+#define GET_VERTEX_DWORDS() smesa->vertex_size
+#define ALLOC_VERTS( n, size ) sisAllocDmaLow( smesa, n * size * sizeof(int) )
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ sisContextPtr smesa = SIS_CONTEXT(ctx); \
+ const char *vertptr = smesa->verts;
+#define VERT(x) (sisVertex *)(vertptr + (x * vertsize * sizeof(int)))
+#define VERTEX sisVertex
+#undef TAG
+#define TAG(x) sis_##x
+#include "tnl_dd/t_dd_triemit.h"
+#undef TAG
+#undef LOCAL_VARS
+
+/***********************************************************************
+ * Dispatch vertices to hardware through MMIO *
+ ***********************************************************************/
+
+/* The ARGB write of the last vertex of the primitive fires the 3d engine, so
+ * save it until the end.
+ */
+#define SIS_MMIO_WRITE_VERTEX(_v, i, lastvert) \
+do { \
+ GLuint __color, __i = 0; \
+ MMIO(REG_3D_TSXa+(i)*0x30, _v->ui[__i++]); \
+ MMIO(REG_3D_TSYa+(i)*0x30, _v->ui[__i++]); \
+ MMIO(REG_3D_TSZa+(i)*0x30, _v->ui[__i++]); \
+ if (SIS_STATES & VERT_W) \
+ MMIO(REG_3D_TSWGa+(i)*0x30, _v->ui[__i++]); \
+ __color = _v->ui[__i++]; \
+ if (SIS_STATES & VERT_SPEC) \
+ MMIO(REG_3D_TSFSa+(i)*0x30, _v->ui[__i++]); \
+ if (SIS_STATES & VERT_UV0) { \
+ MMIO(REG_3D_TSUAa+(i)*0x30, _v->ui[__i++]); \
+ MMIO(REG_3D_TSVAa+(i)*0x30, _v->ui[__i++]); \
+ } \
+ if (SIS_STATES & VERT_UV1) { \
+ MMIO(REG_3D_TSUBa+(i)*0x30, _v->ui[__i++]); \
+ MMIO(REG_3D_TSVBa+(i)*0x30, _v->ui[__i++]); \
+ } \
+ if (lastvert || (SIS_STATES & VERT_SMOOTH)) \
+ MMIO(REG_3D_TSARGBa+(i)*0x30, __color); \
+} while (0)
+
+#define MMIO_VERT_REG_COUNT 10
+
+#define VERT_SMOOTH 0x01
+#define VERT_W 0x02
+#define VERT_SPEC 0x04
+#define VERT_UV0 0x08
+#define VERT_UV1 0x10
+
+typedef void (*mmio_draw_func)(sisContextPtr smesa, char *verts);
+static mmio_draw_func sis_tri_func_mmio[32];
+static mmio_draw_func sis_line_func_mmio[32];
+static mmio_draw_func sis_point_func_mmio[32];
+
+#define SIS_STATES (0)
+#define TAG(x) x##_none
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SMOOTH)
+#define TAG(x) x##_g
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_W)
+#define TAG(x) x##_w
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SMOOTH | VERT_W)
+#define TAG(x) x##_gw
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SPEC)
+#define TAG(x) x##_s
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SMOOTH | VERT_SPEC)
+#define TAG(x) x##_gs
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_W | VERT_SPEC)
+#define TAG(x) x##_ws
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_SPEC)
+#define TAG(x) x##_gws
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_UV0)
+#define TAG(x) x##_t0
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SMOOTH | VERT_UV0)
+#define TAG(x) x##_gt0
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_W | VERT_UV0)
+#define TAG(x) x##_wt0
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_UV0)
+#define TAG(x) x##_gwt0
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SPEC | VERT_UV0)
+#define TAG(x) x##_st0
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SMOOTH | VERT_SPEC | VERT_UV0)
+#define TAG(x) x##_gst0
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_W | VERT_SPEC | VERT_UV0)
+#define TAG(x) x##_wst0
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_SPEC | VERT_UV0)
+#define TAG(x) x##_gwst0
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_UV1)
+#define TAG(x) x##_t1
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SMOOTH | VERT_UV1)
+#define TAG(x) x##_gt1
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_W | VERT_UV1)
+#define TAG(x) x##_wt1
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_UV1)
+#define TAG(x) x##_gwt1
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SPEC | VERT_UV1)
+#define TAG(x) x##_st1
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SMOOTH | VERT_SPEC | VERT_UV1)
+#define TAG(x) x##_gst1
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_W | VERT_SPEC | VERT_UV1)
+#define TAG(x) x##_wst1
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_SPEC | VERT_UV1)
+#define TAG(x) x##_gwst1
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_UV0 | VERT_UV1)
+#define TAG(x) x##_t0t1
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SMOOTH | VERT_UV0 | VERT_UV1)
+#define TAG(x) x##_gt0t1
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_W | VERT_UV0 | VERT_UV1)
+#define TAG(x) x##_wt0t1
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_UV0 | VERT_UV1)
+#define TAG(x) x##_gwt0t1
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SPEC | VERT_UV0 | VERT_UV1)
+#define TAG(x) x##_st0t1
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SMOOTH | VERT_SPEC | VERT_UV0 | VERT_UV1)
+#define TAG(x) x##_gst0t1
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_W | VERT_SPEC | VERT_UV0 | VERT_UV1)
+#define TAG(x) x##_wst0t1
+#include "sis_tritmp.h"
+
+#define SIS_STATES (VERT_SMOOTH | VERT_W | VERT_SPEC | VERT_UV0 | VERT_UV1)
+#define TAG(x) x##_gwst0t1
+#include "sis_tritmp.h"
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ if (DO_FALLBACK) \
+ smesa->draw_tri( smesa, a, b, c ); \
+ else \
+ sis_triangle( smesa, a, b, c ); \
+} while (0)
+
+#define QUAD( a, b, c, d ) \
+do { \
+ if (DO_FALLBACK) { \
+ smesa->draw_tri( smesa, a, b, d ); \
+ smesa->draw_tri( smesa, b, c, d ); \
+ } else \
+ sis_quad( smesa, a, b, c, d ); \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ if (DO_FALLBACK) \
+ smesa->draw_line( smesa, v0, v1 ); \
+ else \
+ sis_line( smesa, v0, v1 ); \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ if (DO_FALLBACK) \
+ smesa->draw_point( smesa, v0 ); \
+ else \
+ sis_point( smesa, v0 ); \
+} while (0)
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define SIS_OFFSET_BIT 0x01
+#define SIS_TWOSIDE_BIT 0x02
+#define SIS_UNFILLED_BIT 0x04
+#define SIS_FALLBACK_BIT 0x08
+#define SIS_MAX_TRIFUNC 0x10
+
+
+static struct {
+ tnl_points_func points;
+ tnl_line_func line;
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
+} rast_tab[SIS_MAX_TRIFUNC];
+
+
+#define DO_FALLBACK (IND & SIS_FALLBACK_BIT)
+#define DO_OFFSET (IND & SIS_OFFSET_BIT)
+#define DO_UNFILLED (IND & SIS_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & SIS_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 1
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX sisVertex
+#define TAB rast_tab
+
+#define DEPTH_SCALE smesa->depth_scale
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a > 0)
+#define GET_VERTEX(e) (smesa->verts + (e * smesa->vertex_size * sizeof(int)))
+
+#define VERT_SET_RGBA( v, c ) \
+do { \
+ sis_color_t *color = (sis_color_t *)&((v)->ui[coloroffset]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \
+} while (0)
+
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+
+#define VERT_SET_SPEC( v0, c ) \
+do { \
+ if (havespec) { \
+ UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.blue, (c)[2]); \
+ } \
+} while (0)
+#define VERT_COPY_SPEC( v0, v1 ) \
+do { \
+ if (havespec) { \
+ v0->v.specular.red = v1->v.specular.red; \
+ v0->v.specular.green = v1->v.specular.green; \
+ v0->v.specular.blue = v1->v.specular.blue; \
+ } \
+} while (0)
+
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
+#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[5]
+#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx]
+
+#define LOCAL_VARS(n) \
+ sisContextPtr smesa = SIS_CONTEXT(ctx); \
+ GLuint color[n], spec[n]; \
+ GLuint coloroffset = (smesa->vertex_size == 4 ? 3 : 4); \
+ GLboolean havespec = (smesa->vertex_size == 4 ? 0 : 1); \
+ (void) color; (void) spec; (void) coloroffset; (void) havespec;
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+#define RASTERIZE(x) if (smesa->hw_primitive != hw_prim[x]) \
+ sisRasterPrimitive( ctx, hw_prim[x] )
+#define RENDER_PRIMITIVE smesa->render_primitive
+#define IND SIS_FALLBACK_BIT
+#define TAG(x) x
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
+
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SIS_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SIS_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SIS_TWOSIDE_BIT|SIS_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SIS_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SIS_OFFSET_BIT|SIS_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SIS_TWOSIDE_BIT|SIS_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SIS_TWOSIDE_BIT|SIS_OFFSET_BIT|SIS_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SIS_FALLBACK_BIT)
+#define TAG(x) x##_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SIS_OFFSET_BIT|SIS_FALLBACK_BIT)
+#define TAG(x) x##_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SIS_TWOSIDE_BIT|SIS_FALLBACK_BIT)
+#define TAG(x) x##_twoside_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SIS_TWOSIDE_BIT|SIS_OFFSET_BIT|SIS_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SIS_UNFILLED_BIT|SIS_FALLBACK_BIT)
+#define TAG(x) x##_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SIS_OFFSET_BIT|SIS_UNFILLED_BIT|SIS_FALLBACK_BIT)
+#define TAG(x) x##_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SIS_TWOSIDE_BIT|SIS_UNFILLED_BIT|SIS_FALLBACK_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (SIS_TWOSIDE_BIT|SIS_OFFSET_BIT|SIS_UNFILLED_BIT| \
+ SIS_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+static void init_rast_tab( void )
+{
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+ init_fallback();
+ init_offset_fallback();
+ init_twoside_fallback();
+ init_twoside_offset_fallback();
+ init_unfilled_fallback();
+ init_offset_unfilled_fallback();
+ init_twoside_unfilled_fallback();
+ init_twoside_offset_unfilled_fallback();
+}
+
+
+
+/***********************************************************************
+ * Rasterization fallback helpers *
+ ***********************************************************************/
+
+
+/* This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+
+static void
+sis_fallback_tri( sisContextPtr smesa,
+ sisVertex *v0,
+ sisVertex *v1,
+ sisVertex *v2 )
+{
+ GLcontext *ctx = smesa->glCtx;
+ SWvertex v[3];
+ _swsetup_Translate( ctx, v0, &v[0] );
+ _swsetup_Translate( ctx, v1, &v[1] );
+ _swsetup_Translate( ctx, v2, &v[2] );
+ sisSpanRenderStart( ctx );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+ sisSpanRenderFinish( ctx );
+ _swrast_flush( ctx );
+}
+
+
+static void
+sis_fallback_line( sisContextPtr smesa,
+ sisVertex *v0,
+ sisVertex *v1 )
+{
+ GLcontext *ctx = smesa->glCtx;
+ SWvertex v[2];
+ _swsetup_Translate( ctx, v0, &v[0] );
+ _swsetup_Translate( ctx, v1, &v[1] );
+ sisSpanRenderStart( ctx );
+ _swrast_Line( ctx, &v[0], &v[1] );
+ sisSpanRenderFinish( ctx );
+ _swrast_flush( ctx );
+}
+
+
+static void
+sis_fallback_point( sisContextPtr smesa,
+ sisVertex *v0 )
+{
+ GLcontext *ctx = smesa->glCtx;
+ SWvertex v[1];
+ _swsetup_Translate( ctx, v0, &v[0] );
+ sisSpanRenderStart( ctx );
+ _swrast_Point( ctx, &v[0] );
+ sisSpanRenderFinish( ctx );
+ _swrast_flush( ctx );
+}
+
+
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+#define IND 0
+#define V(x) (sisVertex *)(vertptr + (x * vertsize * sizeof(int)))
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ POINT( V(ELT(start)) )
+#define RENDER_LINE( v0, v1 ) LINE( V(v0), V(v1) )
+#define RENDER_TRI( v0, v1, v2 ) TRI( V(v0), V(v1), V(v2) )
+#define RENDER_QUAD( v0, v1, v2, v3 ) QUAD( V(v0), V(v1), V(v2), V(v3) )
+#define INIT(x) sisRenderPrimitive( ctx, x )
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ sisContextPtr smesa = SIS_CONTEXT(ctx); \
+ const GLuint vertsize = smesa->vertex_size; \
+ const char *vertptr = (char *)smesa->verts; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ (void) elt;
+#define RESET_STIPPLE
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) (x)
+#define TAG(x) sis_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+#undef ELT
+#undef TAG
+#define TAG(x) sis_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl/t_vb_rendertmp.h"
+
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+#define POINT_FALLBACK (DD_POINT_SMOOTH)
+#define LINE_FALLBACK (DD_LINE_STIPPLE|DD_LINE_SMOOTH)
+#define TRI_FALLBACK (DD_TRI_STIPPLE|DD_TRI_SMOOTH)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)
+#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
+#define _SIS_NEW_RENDER_STATE (ANY_RASTER_FLAGS | ANY_FALLBACK_FLAGS)
+
+static void sisChooseRenderState(GLcontext *ctx)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ sisContextPtr smesa = SIS_CONTEXT( ctx );
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ if (flags & (ANY_RASTER_FLAGS|ANY_FALLBACK_FLAGS)) {
+
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= SIS_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= SIS_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= SIS_UNFILLED_BIT;
+ }
+
+ smesa->draw_point = sis_point;
+ smesa->draw_line = sis_line;
+ smesa->draw_tri = sis_triangle;
+ /* Hook in fallbacks for specific primitives.
+ */
+ if (flags & ANY_FALLBACK_FLAGS) {
+ if (flags & POINT_FALLBACK)
+ smesa->draw_point = sis_fallback_point;
+ if (flags & LINE_FALLBACK)
+ smesa->draw_line = sis_fallback_line;
+ if (flags & TRI_FALLBACK)
+ smesa->draw_tri = sis_fallback_tri;
+ index |= SIS_FALLBACK_BIT;
+ }
+ }
+
+ if (index != smesa->RenderIndex) {
+ smesa->RenderIndex = index;
+
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.ClippedLine = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = sis_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = sis_render_tab_elts;
+ tnl->Driver.Render.ClippedPolygon = sis_fast_clipped_poly;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon;
+ }
+ }
+}
+
+/**********************************************************************/
+/* Multipass rendering for front buffering */
+/**********************************************************************/
+static GLboolean multipass_cliprect( GLcontext *ctx, GLuint pass )
+{
+ sisContextPtr smesa = SIS_CONTEXT( ctx );
+
+ if (pass >= smesa->driDrawable->numClipRects) {
+ return GL_FALSE;
+ } else {
+ GLint x1, y1, x2, y2;
+
+ x1 = smesa->driDrawable->pClipRects[pass].x1 - smesa->driDrawable->x;
+ y1 = smesa->driDrawable->pClipRects[pass].y1 - smesa->driDrawable->y;
+ x2 = smesa->driDrawable->pClipRects[pass].x2 - smesa->driDrawable->x;
+ y2 = smesa->driDrawable->pClipRects[pass].y2 - smesa->driDrawable->y;
+
+ if (ctx->Scissor.Enabled) {
+ GLint scisy1 = Y_FLIP(ctx->Scissor.Y + ctx->Scissor.Height - 1);
+ GLint scisy2 = Y_FLIP(ctx->Scissor.Y);
+
+ if (ctx->Scissor.X > x1)
+ x1 = ctx->Scissor.X;
+ if (scisy1 > y1)
+ y1 = scisy1;
+ if (ctx->Scissor.X + ctx->Scissor.Width - 1 < x2)
+ x2 = ctx->Scissor.X + ctx->Scissor.Width - 1;
+ if (scisy2 < y2)
+ y2 = scisy2;
+ }
+
+ MMIO(REG_3D_ClipTopBottom, y1 << 13 | y2);
+ MMIO(REG_3D_ClipLeftRight, x1 << 13 | x2);
+ /* Mark that we clobbered these registers */
+ smesa->GlobalFlag |= GFLAG_CLIPPING;
+ return GL_TRUE;
+ }
+}
+
+
+
+/**********************************************************************/
+/* Validate state at pipeline start */
+/**********************************************************************/
+
+static void sisRunPipeline( GLcontext *ctx )
+{
+ sisContextPtr smesa = SIS_CONTEXT( ctx );
+
+ if (!smesa->Fallback && smesa->NewGLState) {
+ if (smesa->NewGLState & _NEW_TEXTURE) {
+ SIS_FIREVERTICES(smesa);
+ sisUpdateTextureState(ctx);
+ }
+
+ if (smesa->NewGLState & _SIS_NEW_RENDER_STATE)
+ sisChooseRenderState( ctx );
+
+ smesa->NewGLState = 0;
+ }
+
+ _tnl_run_pipeline( ctx );
+
+ /* XXX: If we put flushing in sis_state.c and friends, we can avoid this.
+ * Is it worth it?
+ */
+ SIS_FIREVERTICES(smesa);
+}
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+/* 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.
+ */
+
+static void sisRasterPrimitive( GLcontext *ctx, GLuint hwprim )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ if (smesa->hw_primitive != hwprim) {
+ SIS_FIREVERTICES(smesa);
+ smesa->hw_primitive = hwprim;
+ smesa->AGPParseSet &= ~(MASK_PsDataType | MASK_PsShadingMode);
+ smesa->dwPrimitiveSet &= ~(MASK_DrawPrimitiveCommand |
+ MASK_SetFirePosition | MASK_ShadingMode);
+ smesa->AGPParseSet |= hw_prim_agp_type[hwprim];
+ smesa->dwPrimitiveSet |= hwprim | hw_prim_mmio_fire[hwprim];
+ if (ctx->Light.ShadeModel == GL_FLAT) {
+ smesa->AGPParseSet |= hw_prim_agp_shade[hwprim];
+ smesa->dwPrimitiveSet |= hw_prim_mmio_shade[hwprim];
+ } else {
+ smesa->AGPParseSet |= MASK_PsShadingSmooth;
+ smesa->dwPrimitiveSet |= SHADE_GOURAUD;
+ }
+ }
+}
+
+static void sisRenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+
+ smesa->render_primitive = prim;
+
+ if (prim >= GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ return;
+ sisRasterPrimitive( ctx, hw_prim[prim] );
+}
+
+#define EMIT_ATTR( ATTR, STYLE) \
+do { \
+ smesa->vertex_attrs[smesa->vertex_attr_count].attrib = (ATTR); \
+ smesa->vertex_attrs[smesa->vertex_attr_count].format = (STYLE); \
+ smesa->vertex_attr_count++; \
+} while (0)
+
+#define EMIT_PAD( N ) \
+do { \
+ smesa->vertex_attrs[smesa->vertex_attr_count].attrib = 0; \
+ smesa->vertex_attrs[smesa->vertex_attr_count].format = EMIT_PAD; \
+ smesa->vertex_attrs[smesa->vertex_attr_count].offset = (N); \
+ smesa->vertex_attr_count++; \
+} while (0)
+
+#define SIS_TCL_STATE_BITS \
+ (_TNL_BITS_TEX_ANY | _TNL_BIT_COLOR1 | _TNL_BIT_FOG)
+
+static void sisRenderStart( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint index = tnl->render_inputs;
+ GLuint AGPParseSet = smesa->AGPParseSet;
+ GLboolean tex_fallback = GL_FALSE;
+
+ if (ctx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT &&
+ smesa->driDrawable->numClipRects != 0)
+ {
+ multipass_cliprect(ctx, 0);
+ if (smesa->driDrawable->numClipRects > 1)
+ tnl->Driver.Render.Multipass = multipass_cliprect;
+ else
+ tnl->Driver.Render.Multipass = NULL;
+ } else {
+ tnl->Driver.Render.Multipass = NULL;
+ }
+
+ /* Important:
+ */
+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
+ smesa->vertex_attr_count = 0;
+
+ /* EMIT_ATTR's must be in order as they tell t_vertex.c how to build up a
+ * hardware vertex.
+ */
+
+ AGPParseSet &= ~(MASK_VertexDWSize | MASK_VertexDataFormat);
+ AGPParseSet |= SiS_PS_HAS_XYZ | SiS_PS_HAS_DIFFUSE;
+ if (index & _TNL_BITS_TEX_ANY) {
+ EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_4F_VIEWPORT);
+ AGPParseSet |= SiS_PS_HAS_W;
+ } else {
+ EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_3F_VIEWPORT);
+ }
+
+ EMIT_ATTR(_TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA);
+
+ if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) {
+ AGPParseSet |= SiS_PS_HAS_SPECULAR;
+
+ if (index & _TNL_BIT_COLOR1) {
+ EMIT_ATTR(_TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR);
+ } else {
+ EMIT_PAD(3);
+ }
+
+ if (index & _TNL_BIT_FOG)
+ EMIT_ATTR(_TNL_ATTRIB_FOG, EMIT_1UB_1F);
+ else
+ EMIT_PAD(1);
+ }
+
+ /* projective textures are not supported by the hardware */
+ if (index & _TNL_BIT_TEX(0)) {
+ if (VB->TexCoordPtr[0]->size > 2)
+ tex_fallback = GL_TRUE;
+ EMIT_ATTR(_TNL_ATTRIB_TEX0, EMIT_2F);
+ AGPParseSet |= SiS_PS_HAS_UV0;
+ }
+ if (index & _TNL_BIT_TEX(1)) {
+ if (VB->TexCoordPtr[1]->size > 2)
+ tex_fallback = GL_TRUE;
+ EMIT_ATTR(_TNL_ATTRIB_TEX1, EMIT_2F);
+ AGPParseSet |= SiS_PS_HAS_UV1;
+ }
+ FALLBACK(smesa, SIS_FALLBACK_TEXTURE, tex_fallback);
+
+ if (smesa->last_tcl_state != index) {
+ smesa->AGPParseSet = AGPParseSet;
+
+ smesa->vertex_size = _tnl_install_attrs( ctx, smesa->vertex_attrs,
+ smesa->vertex_attr_count, smesa->hw_viewport, 0 );
+
+ smesa->vertex_size >>= 2;
+ smesa->AGPParseSet |= smesa->vertex_size << 28;
+ }
+}
+
+static void sisRenderFinish( GLcontext *ctx )
+{
+}
+
+/**********************************************************************/
+/* AGP/PCI vertex submission */
+/**********************************************************************/
+
+void
+sisFlushPrimsLocked(sisContextPtr smesa)
+{
+ if (smesa->vb_cur == smesa->vb_last)
+ return;
+
+ sisUpdateHWState(smesa->glCtx);
+
+ if (smesa->using_agp) {
+ mWait3DCmdQueue(8);
+ mEndPrimitive();
+ MMIO(REG_3D_AGPCmBase, (smesa->vb_last - smesa->vb) +
+ smesa->vb_agp_offset);
+ MMIO(REG_3D_AGPTtDwNum, ((smesa->vb_cur - smesa->vb_last) / 4) |
+ 0x50000000);
+ MMIO(REG_3D_ParsingSet, smesa->AGPParseSet);
+ MMIO(REG_3D_AGPCmFire, (GLint)(-1));
+ mEndPrimitive();
+ } else {
+ int mmio_index = 0, incr = 0;
+ void (*sis_emit_func)(sisContextPtr smesa, char *verts) = NULL;
+
+ if (smesa->AGPParseSet & MASK_PsShadingSmooth)
+ mmio_index |= VERT_SMOOTH;
+ if (smesa->AGPParseSet & SiS_PS_HAS_SPECULAR)
+ mmio_index |= VERT_SPEC;
+ if (smesa->AGPParseSet & SiS_PS_HAS_W)
+ mmio_index |= VERT_W;
+ if (smesa->AGPParseSet & SiS_PS_HAS_UV0)
+ mmio_index |= VERT_UV0;
+ if (smesa->AGPParseSet & SiS_PS_HAS_UV1)
+ mmio_index |= VERT_UV1;
+
+ switch (smesa->AGPParseSet & MASK_PsDataType) {
+ case MASK_PsPointList:
+ incr = smesa->vertex_size * 4;
+ sis_emit_func = sis_point_func_mmio[mmio_index];
+ break;
+ case MASK_PsLineList:
+ incr = smesa->vertex_size * 4 * 2;
+ sis_emit_func = sis_line_func_mmio[mmio_index];
+ break;
+ case MASK_PsTriangleList:
+ incr = smesa->vertex_size * 4 * 3;
+ sis_emit_func = sis_tri_func_mmio[mmio_index];
+ break;
+ }
+
+ mWait3DCmdQueue(1);
+ MMIO(REG_3D_PrimitiveSet, smesa->dwPrimitiveSet);
+ while (smesa->vb_last < smesa->vb_cur) {
+ sis_emit_func(smesa, smesa->vb_last);
+ smesa->vb_last += incr;
+ }
+ mWait3DCmdQueue(1);
+ mEndPrimitive();
+
+ /* With PCI, we can just start writing to the start of the VB again. */
+ smesa->vb_cur = smesa->vb;
+ }
+ smesa->vb_last = smesa->vb_cur;
+}
+
+void sisFlushPrims(sisContextPtr smesa)
+{
+ LOCK_HARDWARE();
+ sisFlushPrimsLocked(smesa);
+ UNLOCK_HARDWARE();
+}
+
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+
+void sisFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ GLuint oldfallback = smesa->Fallback;
+
+ if (mode) {
+ smesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ SIS_FIREVERTICES(smesa);
+ _swsetup_Wakeup( ctx );
+ smesa->RenderIndex = ~0;
+ }
+ }
+ else {
+ smesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = sisRenderStart;
+ tnl->Driver.Render.PrimitiveNotify = sisRenderPrimitive;
+ tnl->Driver.Render.Finish = sisRenderFinish;
+
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+
+ _tnl_invalidate_vertex_state( ctx, ~0 );
+ _tnl_invalidate_vertices( ctx, ~0 );
+ _tnl_install_attrs( ctx,
+ smesa->vertex_attrs,
+ smesa->vertex_attr_count,
+ smesa->hw_viewport, 0 );
+
+ smesa->NewGLState |= _SIS_NEW_RENDER_STATE;
+ }
+ }
+}
+
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+void sisInitTriFuncs( GLcontext *ctx )
+{
+ sisContextPtr smesa = SIS_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+
+ sis_vert_init_none();
+ sis_vert_init_g();
+ sis_vert_init_w();
+ sis_vert_init_gw();
+ sis_vert_init_s();
+ sis_vert_init_gs();
+ sis_vert_init_ws();
+ sis_vert_init_gws();
+ sis_vert_init_t0();
+ sis_vert_init_gt0();
+ sis_vert_init_wt0();
+ sis_vert_init_gwt0();
+ sis_vert_init_st0();
+ sis_vert_init_gst0();
+ sis_vert_init_wst0();
+ sis_vert_init_gwst0();
+ sis_vert_init_t1();
+ sis_vert_init_gt1();
+ sis_vert_init_wt1();
+ sis_vert_init_gwt1();
+ sis_vert_init_st1();
+ sis_vert_init_gst1();
+ sis_vert_init_wst1();
+ sis_vert_init_gwst1();
+ sis_vert_init_t0t1();
+ sis_vert_init_gt0t1();
+ sis_vert_init_wt0t1();
+ sis_vert_init_gwt0t1();
+ sis_vert_init_st0t1();
+ sis_vert_init_gst0t1();
+ sis_vert_init_wst0t1();
+ sis_vert_init_gwst0t1();
+ }
+
+ if (driQueryOptionb(&smesa->optionCache, "fallback_force"))
+ sisFallback(ctx, SIS_FALLBACK_FORCE, 1);
+ else
+ sisFallback(ctx, SIS_FALLBACK_FORCE, 0);
+
+ smesa->RenderIndex = ~0;
+ smesa->NewGLState |= _SIS_NEW_RENDER_STATE;
+
+ tnl->Driver.RunPipeline = sisRunPipeline;
+ tnl->Driver.Render.Start = sisRenderStart;
+ tnl->Driver.Render.Finish = sisRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = sisRenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+
+ _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
+ (6 + 2*ctx->Const.MaxTextureUnits) * sizeof(GLfloat) );
+
+ smesa->verts = (char *)tnl->clipspace.vertex_buf;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tris.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tris.h
new file mode 100644
index 000000000..5e07acc21
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tris.h
@@ -0,0 +1,71 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/r128/r128_tris.h,v 1.8 2002/10/30 12:51:43 alanh Exp $ */
+/**************************************************************************
+
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT 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:
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+#ifndef __SIS_TRIS_H__
+#define __SIS_TRIS_H__
+
+#include "sis_lock.h"
+#include "mtypes.h"
+
+extern void sisInitTriFuncs( GLcontext *ctx );
+extern void sisFlushPrims( sisContextPtr smesa );
+extern void sisFlushPrimsLocked( sisContextPtr smesa );
+extern void sisFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
+
+#define FALLBACK( smesa, bit, mode ) sisFallback( smesa->glCtx, bit, mode )
+
+#define SIS_FIREVERTICES(smesa) \
+do { \
+ if (smesa->vb_cur != smesa->vb_last) \
+ sisFlushPrims(smesa); \
+} while (0)
+
+static __inline GLuint *sisAllocDmaLow(sisContextPtr smesa, int bytes)
+{
+ GLuint *start;
+
+ if (smesa->vb_cur + bytes >= smesa->vb_end) {
+ LOCK_HARDWARE();
+ sisFlushPrimsLocked(smesa);
+ if (smesa->using_agp) {
+ WaitEngIdle(smesa);
+ smesa->vb_cur = smesa->vb;
+ smesa->vb_last = smesa->vb_cur;
+ }
+ UNLOCK_HARDWARE();
+ }
+
+ start = (GLuint *)smesa->vb_cur;
+ smesa->vb_cur += bytes;
+ return start;
+}
+
+#endif /* __SIS_TRIS_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tritmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tritmp.h
new file mode 100644
index 000000000..bd2ecd1c4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/sis/sis_tritmp.h
@@ -0,0 +1,70 @@
+/* $XFree86*/ /* -*- c-basic-offset: 3 -*- */
+/**************************************************************************
+
+Copyright 2003 Eric Anholt
+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
+ERIC ANHOLT 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:
+ * Eric Anholt <anholt@FreeBSD.org>
+ */
+
+static void TAG(sis_draw_tri_mmio)(sisContextPtr smesa, char *verts)
+{
+ sisVertexPtr v0 = (sisVertexPtr)verts;
+ sisVertexPtr v1 = (sisVertexPtr)(verts + smesa->vertex_size * 4);
+ sisVertexPtr v2 = (sisVertexPtr)(verts + smesa->vertex_size * 4 * 2);
+
+ mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 3);
+ SIS_MMIO_WRITE_VERTEX(v0, 0, 0);
+ SIS_MMIO_WRITE_VERTEX(v1, 1, 0);
+ SIS_MMIO_WRITE_VERTEX(v2, 2, 1);
+}
+
+static void TAG(sis_draw_line_mmio)(sisContextPtr smesa, char *verts)
+{
+ sisVertexPtr v0 = (sisVertexPtr)verts;
+ sisVertexPtr v1 = (sisVertexPtr)(verts + smesa->vertex_size * 4);
+
+ mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 2);
+ SIS_MMIO_WRITE_VERTEX(v0, 0, 0);
+ SIS_MMIO_WRITE_VERTEX(v1, 1, 1);
+}
+
+static void TAG(sis_draw_point_mmio)(sisContextPtr smesa, char *verts)
+{
+ sisVertexPtr v0 = (sisVertexPtr)verts;
+
+ mWait3DCmdQueue (MMIO_VERT_REG_COUNT * 1);
+ SIS_MMIO_WRITE_VERTEX(v0, 1, 1);
+}
+
+static __inline void TAG(sis_vert_init)( void )
+{
+ sis_tri_func_mmio[SIS_STATES] = TAG(sis_draw_tri_mmio);
+ sis_line_func_mmio[SIS_STATES] = TAG(sis_draw_line_mmio);
+ sis_point_func_mmio[SIS_STATES] = TAG(sis_draw_point_mmio);
+}
+
+#undef TAG
+#undef SIS_STATES
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/BUGS b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/BUGS
new file mode 100644
index 000000000..b15f6a91e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/BUGS
@@ -0,0 +1,64 @@
+REMOVE THIS FILE BEFORE MERGING WITH TRUNK
+------------------------------------------
+
+OUTSTANDING BUGS
+
+demos/reflect - reading back Z on Voodoo3, image offset to right
+ Fixed in latest Glide.
+
+Q3 - some polygons drawn as vertical strips, similar to bug that was
+ seen in demos/fire. Voodoo3 only. May be related to glDepthMask
+ or glColorMask.
+
+book/fog - not fogging
+ Fog in orthograph mode still not implemented. Checking with
+ 3dfx engineers for ideas.
+
+Q3 demo crashes after changing display settings
+ but the full Q3 game version seems OK.
+
+
+
+MORE OUTSTANDING BUGS
+
+private context was NULL! causing immediate failure of any glx prog. cant
+reproduce after restarting the X server. putting it down as halluc.
+
+texture object image was NULL, causing segmentation failure. happens with
+prboom. ive put a check in tdfx_texstate.c but this isn't a fix.
+
+prboom, wall textures near first chainsaw aren't bound properly. sideways
+movements causes the wall textures to move with you. prboom busted?
+
+16bpp mode, quake3, windowed, q3dm1, floor under rocketlauncher bands. it
+looks like multitexturing gone wrong. i'll disable a tmu and test.
+
+sof, polygons appear at wrong x,y,z positions, intermittent, have not yet
+found reliable way of reproducing. culling? sometimes polys disappear.
+
+descent3 is all black in 16bpp mode - FIXED (palette problems)
+
+smeared pixels in quake3 - FIXED (texture memory overlapped FB)
+
+
+
+PERFORMANCE COMPARISON (Brian / Alan)
+
+ V3/16 is Voodoo3 in 16bpp on a P3/500
+ V5/16 is Voodoo5 in 16bpp on a P3/600
+ V5/32 is Voodoo5 in 32bpp on a P3/600
+ V5A/16 is Voodoo5 in 16bpp on an Alpha AXP/600
+ V5A/32 is Voodoo5 in 32bpp on an Alpha AXP/600
+
+ tdfx-2-1-branch tdfx-3-0-0-branch
+demo V3/16 V5/16 V5/32 V3/16 V5/16 V5/32 V5A/16 V5A/32
+------------------------------------------------------------------------
+gloss 257 183 174 320 308 177 313 167
+fire 42 39 52 41
+fire (no help) 98 80 50 106 113 73 124 80
+tunnel 61 50 70 58
+tunnel (no help) 167 142 57 138 152 113 171 122
+gears 663 554 540 881 1232 776 1484 830
+teapot 20 21 37 36
+teapot (no help) 22 14 14 24 30 30 43 42
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/Makefile
new file mode 100644
index 000000000..092c580fe
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/Makefile
@@ -0,0 +1,37 @@
+# src/mesa/drivers/dri/tdfx/Makefile
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = tdfx_dri.so
+
+# not yet
+# MINIGLX_SOURCES = server/tdfx_dri.c
+
+DRIVER_SOURCES = \
+ tdfx_context.c \
+ tdfx_dd.c \
+ tdfx_lock.c \
+ tdfx_pixels.c \
+ tdfx_render.c \
+ tdfx_screen.c \
+ tdfx_span.c \
+ tdfx_state.c \
+ tdfx_tex.c \
+ tdfx_texman.c \
+ tdfx_texstate.c \
+ tdfx_tris.c \
+ tdfx_vb.c
+
+C_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(DRIVER_SOURCES)
+
+
+ASM_SOURCES =
+
+include ../Makefile.template
+
+symlinks:
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fastpath.S b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fastpath.S
new file mode 100644
index 000000000..0f4cc4508
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fastpath.S
@@ -0,0 +1,84 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/X86/fx_3dnow_fastpath.S,v 1.2 2000/09/26 15:56:51 tsi Exp $ */
+
+#include "../../X86/assyntax.h"
+
+#define SETUP_RGBA 0x1
+#define SETUP_TMU0 0x2
+#define SETUP_TMU1 0x4
+
+
+/* Pack either rgba or texture into the remaining half of a 32 byte vertex.
+ */
+#define CLIP_R 24
+#define CLIP_G 16
+#define CLIP_B 20
+#define CLIP_A 28 /* defined inf fxdrv.h */
+
+#define CLIP_S0 16
+#define CLIP_T0 20
+#define CLIP_S1 24
+#define CLIP_T1 28
+
+#define SIZE 4
+#define TYPE (0)
+#define TAG(x) x
+#include "fx_3dnow_fasttmp.h"
+
+#define SIZE 8
+#define TYPE (SETUP_RGBA)
+#define TAG(x) x##_RGBA
+#include "fx_3dnow_fasttmp.h"
+
+#define SIZE 6
+#define TYPE (SETUP_TMU0)
+#define TAG(x) x##_TMU0
+#include "fx_3dnow_fasttmp.h"
+
+#define SIZE 8
+#define TYPE (SETUP_TMU0|SETUP_TMU1)
+#define TAG(x) x##_TMU0_TMU1
+#include "fx_3dnow_fasttmp.h"
+
+#undef CLIP_S1
+#undef CLIP_T1
+#define CLIP_S1 16
+#define CLIP_T1 20
+
+#define SIZE 6
+#define TYPE (SETUP_TMU1)
+#define TAG(x) x##_TMU1
+#include "fx_3dnow_fasttmp.h"
+
+/* These three need to use a full 64 byte clip-space vertex.
+ */
+#undef CLIP_S0
+#undef CLIP_T0
+#undef CLIP_S1
+#undef CLIP_T1
+
+#define CLIP_S0 32
+#define CLIP_T0 36
+#define CLIP_S1 40
+#define CLIP_T1 44
+
+#define SIZE 10
+#define TYPE (SETUP_RGBA|SETUP_TMU0)
+#define TAG(x) x##_RGBA_TMU0
+#include "fx_3dnow_fasttmp.h"
+
+#define SIZE 12
+#define TYPE (SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
+#define TAG(x) x##_RGBA_TMU0_TMU1
+#include "fx_3dnow_fasttmp.h"
+
+#undef CLIP_S1
+#undef CLIP_T1
+#define CLIP_S1 32
+#define CLIP_T1 36
+
+#define SIZE 10
+#define TYPE (SETUP_RGBA|SETUP_TMU1)
+#define TAG(x) x##_RGBA_TMU1
+#include "fx_3dnow_fasttmp.h"
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fasttmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fasttmp.h
new file mode 100644
index 000000000..9ec4935d7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/X86/fx_3dnow_fasttmp.h
@@ -0,0 +1,314 @@
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/X86/fx_3dnow_fasttmp.h,v 1.2 2000/09/26 15:56:51 tsi Exp $ */
+
+#if !defined(NASM_ASSEMBLER) && !defined(MASM_ASSEMBLER)
+#define TAGLLBL(a) TAG(.L##a)
+#else
+#define TAGLLBL(a) TAG(a)
+#endif
+
+#if !GLIDE3
+
+#define GR_VERTEX_X_OFFSET 0
+#define GR_VERTEX_Y_OFFSET 4
+#define GR_VERTEX_Z_OFFSET 8
+#define GR_VERTEX_R_OFFSET 12
+#define GR_VERTEX_G_OFFSET 16
+#define GR_VERTEX_B_OFFSET 20
+#define GR_VERTEX_OOZ_OFFSET 24
+#define GR_VERTEX_A_OFFSET 28
+#define GR_VERTEX_OOW_OFFSET 32
+
+#else /* GLIDE3 */
+
+#define GR_VERTEX_X_OFFSET 0
+#define GR_VERTEX_Y_OFFSET 4
+#define GR_VERTEX_OOZ_OFFSET 8
+#define GR_VERTEX_OOW_OFFSET 12
+#define GR_VERTEX_R_OFFSET 16
+#define GR_VERTEX_G_OFFSET 20
+#define GR_VERTEX_B_OFFSET 24
+#define GR_VERTEX_A_OFFSET 28
+#define GR_VERTEX_Z_OFFSET 32
+
+#endif /* GLIDE3 */
+
+#define GR_VERTEX_SOW_TMU0_OFFSET 36
+#define GR_VERTEX_TOW_TMU0_OFFSET 40
+#define GR_VERTEX_OOW_TMU0_OFFSET 44
+#define GR_VERTEX_SOW_TMU1_OFFSET 48
+#define GR_VERTEX_TOW_TMU1_OFFSET 52
+#define GR_VERTEX_OOW_TMU1_OFFSET 56
+
+
+
+
+/*#define MAT_SX 0 /* accessed by REGIND !! */
+#define MAT_SY 20
+#define MAT_SZ 40
+#define MAT_TX 48
+#define MAT_TY 52
+#define MAT_TZ 56
+
+
+
+
+/* Do viewport map, device scale and perspective projection.
+ *
+ * void project_verts( GLfloat *first,
+ * GLfloat *last,
+ * const GLfloat *m,
+ * GLuint stride )
+ *
+ *
+ * Rearrange fxVertices to look like grVertices.
+ */
+
+GLOBL GLNAME( TAG(fx_3dnow_project_vertices) )
+GLNAME( TAG(fx_3dnow_project_vertices) ):
+
+ PUSH_L ( EBP )
+
+ MOV_L ( REGOFF(8, ESP), ECX ) /* first_vert */
+ MOV_L ( REGOFF(12, ESP), EDX ) /* last_vert */
+
+ CMP_L ( ECX, EDX )
+ JE ( TAGLLBL(FXPV_end) )
+
+ FEMMS
+
+ PREFETCH ( REGIND(ECX) ) /* fetch the first vertex */
+
+ MOV_L ( REGOFF(16, ESP), EBP ) /* matrix */
+ MOV_L ( REGOFF(20, ESP), EAX ) /* stride */
+
+ MOVD ( REGOFF(MAT_TX, EBP), MM6 ) /* | tx */
+ PUNPCKLDQ ( REGOFF(MAT_TY, EBP), MM6 ) /* ty | tx */
+
+#if !defined(FX_V2)
+ MOV_L ( CONST(0x49400000), REGOFF(-8, ESP) ) /* snapper */
+ MOV_L ( CONST(0x49400000), REGOFF(-4, ESP) ) /* snapper */
+#endif
+
+ MOVQ ( REGOFF(-8, ESP), MM4 ) /* snapper | snapper */
+ PFADD ( MM4, MM6 ) /* ty+snapper | tx+snapper */
+
+ MOVD ( REGIND(EBP), MM5 )
+ PUNPCKLDQ ( REGOFF(MAT_SY, EBP), MM5 ) /* vsy | vsx */
+
+ MOVD ( REGOFF(MAT_SZ, EBP), MM1 ) /* | vsz */
+
+
+ALIGNTEXT32
+TAGLLBL(FXPV_loop_start):
+
+ PREFETCH ( REGOFF(64, ECX) ) /* fetch the next-ish vertex */
+
+
+ MOVD ( REGOFF(12, ECX), MM0 ) /* | f[3] */
+ PFRCP ( MM0, MM0 ) /* oow = 1/f[3] */
+
+ MOVD ( REGOFF(12, ECX), MM7 ) /* | f[3] */
+ PFRCPIT1 ( MM0, MM7 )
+ PFRCPIT2 ( MM0, MM7 ) /* oow | oow */
+
+ PUNPCKLDQ ( MM7, MM7 )
+
+
+#if (TYPE & SETUP_RGBA)
+ MOVD ( REGOFF(CLIP_R, ECX ), MM0 ) /* f[RCOORD] = f[CLIP_R]; */
+ MOVD ( MM0, REGOFF(GR_VERTEX_R_OFFSET, ECX) )
+#endif
+
+#if (TYPE & SETUP_TMU1)
+ MOVQ ( REGOFF(CLIP_S1, ECX), MM0 ) /* f[S1COORD] = f[CLIP_S1] * oow */
+ PFMUL ( MM7, MM0 ) /* f[T1COORD] = f[CLIP_T1] * oow */
+ MOVQ ( MM0, REGOFF(GR_VERTEX_SOW_TMU1_OFFSET, ECX) )
+#endif
+
+
+#if (TYPE & SETUP_TMU0)
+ MOVQ ( REGOFF(CLIP_S0, ECX), MM0 ) /* f[S0COORD] = f[CLIP_S0] * oow */
+ PFMUL ( MM7, MM0 ) /* f[T0COORD] = f[CLIP_T0] * oow */
+ MOVQ ( MM0, REGOFF(GR_VERTEX_SOW_TMU0_OFFSET, ECX) )
+#endif
+
+
+
+
+
+/* DO_SETUP_XYZ */
+
+ MOVQ ( REGIND(ECX), MM2 ) /* f[1] | f[0] */
+ PFMUL ( MM7, MM2 ) /* f[1] * oow | f[0] * oow */
+
+ MOVD ( REGOFF(8, ECX), MM3 ) /* | f[2] */
+ PFMUL ( MM7, MM3 ) /* | f[2] * oow */
+
+ MOVD ( REGOFF(MAT_TZ, EBP), MM0 ) /* | vtz */
+ PFMUL ( MM1, MM3 ) /* | f[2] *= vsz */
+
+ PFADD ( MM0, MM3 ) /* | f[2] += vtz */
+ PFMUL ( MM5, MM2 ) /* f[1] *= vsy | f[0] *= vsx */
+
+ PFADD ( MM6, MM2 ) /* f[1] += vty | f[0] += vtx */
+
+#if !defined(FX_V2)
+ PFSUB ( MM4, MM2 ) /* f[0,1] -= snapper */
+#endif
+
+ MOVQ ( MM2, REGOFF(GR_VERTEX_X_OFFSET, ECX) )
+ MOVD ( MM3, REGOFF(GR_VERTEX_OOZ_OFFSET, ECX) )
+
+
+/* end of DO_SETUP_XYZ */
+
+ MOVD ( MM7, REGOFF(GR_VERTEX_OOW_OFFSET, ECX) ) /* f[OOWCOORD] = oow */
+ ADD_L ( EAX, ECX ) /* f += stride */
+
+ CMP_L ( ECX, EDX ) /* stall??? */
+ JA ( TAGLLBL(FXPV_loop_start) )
+
+TAGLLBL(FXPV_end):
+ FEMMS
+ POP_L ( EBP )
+ RET
+
+
+
+
+
+
+
+/* void project_verts( GLfloat *first,
+ * GLfloat *last,
+ * const GLfloat *m,
+ * GLuint stride,
+ * const GLubyte *mask )
+ *
+ */
+
+GLOBL GLNAME( TAG(fx_3dnow_project_clipped_vertices) )
+GLNAME( TAG(fx_3dnow_project_clipped_vertices) ):
+
+ PUSH_L ( EBP )
+
+ MOV_L ( REGOFF(8, ESP), ECX ) /* first FXDRIVER(VB)->verts*/
+ MOV_L ( REGOFF(12, ESP), EDX ) /* last FXDRIVER(VB)->last_vert */
+
+ FEMMS
+
+ PUSH_L ( EDI )
+ PUSH_L ( ESI )
+
+ PREFETCH ( REGIND(ECX) ) /* fetch the first vertex */
+
+ MOV_L ( REGOFF(24, ESP), EBP ) /* mat ctx->Viewport.WindowMap.M */
+ MOV_L ( REGOFF(28, ESP), EAX ) /* stride */
+ MOV_L ( REGOFF(32, ESP), ESI ) /* VB->ClipMask */
+
+ MOVD ( REGOFF(MAT_TX, EBP), MM6 ) /* | tx */
+ PUNPCKLDQ ( REGOFF(MAT_TY, EBP), MM6 ) /* ty | tx */
+
+#if !defined(FX_V2)
+ MOV_L ( CONST(0x49400000), REGOFF(-8, ESP) ) /* snapper */
+ MOV_L ( CONST(0x49400000), REGOFF(-4, ESP) ) /* snapper */
+#endif
+
+ MOVQ ( REGOFF(-8, ESP), MM4 ) /* snapper | snapper */
+ PFADD ( MM4, MM6 ) /* ty+snapper | tx+snapper */
+
+ MOVD ( REGIND(EBP), MM5 )
+ PUNPCKLDQ ( REGOFF(MAT_SY, EBP), MM5 ) /* vsy | vsx */
+
+ MOVD ( REGOFF(MAT_SZ, EBP), MM1 ) /* | vsz */
+
+
+
+ALIGNTEXT32
+TAGLLBL(FXPCV_loop_start):
+
+ PREFETCH ( REGOFF(64, ECX) ) /* fetch the next-ish vertex */
+
+ CMP_B ( CONST(0), REGIND(ESI) )
+ JNE ( TAGLLBL(FXPCV_skip) )
+
+ MOVD ( REGOFF(12, ECX), MM0) /* | f[3] */
+ PFRCP ( MM0, MM0 ) /* oow = 1/f[3] */
+
+ MOVD ( REGOFF(12, ECX), MM7) /* | f[3] */
+ PFRCPIT1 ( MM0, MM7 )
+ PFRCPIT2 ( MM0, MM7 ) /* oow | oow */
+
+ PUNPCKLDQ ( MM7, MM7 )
+
+
+#if (TYPE & SETUP_RGBA)
+ MOVD ( REGOFF(CLIP_R, ECX ), MM0 ) /* f[RCOORD] = f[CLIP_R]; */
+ MOVD ( MM0, REGOFF(GR_VERTEX_R_OFFSET, ECX) )
+#endif
+
+#if (TYPE & SETUP_TMU1)
+ MOVQ ( REGOFF(CLIP_S1, ECX), MM0 ) /* f[S1COORD] = f[CLIP_S1] * oow */
+ PFMUL ( MM7, MM0 ) /* f[T1COORD] = f[CLIP_T1] * oow */
+ MOVQ ( MM0, REGOFF(GR_VERTEX_SOW_TMU1_OFFSET, ECX) )
+#endif
+
+
+#if (TYPE & SETUP_TMU0)
+ MOVQ ( REGOFF(CLIP_S0, ECX), MM0 ) /* f[S0COORD] = f[CLIP_S0] * oow */
+ PFMUL ( MM7, MM0 ) /* f[T0COORD] = f[CLIP_T0] * oow */
+ MOVQ ( MM0, REGOFF(GR_VERTEX_SOW_TMU0_OFFSET, ECX) )
+#endif
+
+
+
+
+/* DO_SETUP_XYZ */
+
+ MOVQ ( REGIND(ECX), MM2 ) /* f[1] | f[0] */
+ PFMUL ( MM7, MM2 ) /* f[1] * oow | f[0] * oow */
+
+ MOVD ( REGOFF(8, ECX), MM3 ) /* | f[2] */
+ PFMUL ( MM7, MM3 ) /* | f[2] * oow */
+
+ MOVD ( REGOFF(MAT_TZ, EBP), MM0 ) /* | vtz */
+ PFMUL ( MM1, MM3 ) /* | f[2] *= vsz */
+
+ PFADD ( MM0, MM3 ) /* | f[2] += vtz */
+ PFMUL ( MM5, MM2 ) /* f[1] *= vsy | f[0] *= vsx */
+
+ PFADD ( MM6, MM2 ) /* f[1] += vty | f[0] += vtx */
+
+#if !defined(FX_V2)
+ PFSUB ( MM4, MM2 ) /* f[0,1] -= snapper */
+#endif
+
+ MOVQ ( MM2, REGOFF(GR_VERTEX_X_OFFSET, ECX) )
+ MOVD ( MM3, REGOFF(GR_VERTEX_OOZ_OFFSET, ECX) )
+
+
+/* end of DO_SETUP_XYZ */
+
+ MOVD ( MM7, REGOFF(GR_VERTEX_OOW_OFFSET, ECX) ) /* f[OOWCOORD] = oow */
+
+TAGLLBL(FXPCV_skip):
+ ADD_L ( EAX, ECX ) /* f += stride */
+
+ INC_L ( ESI ) /* next ClipMask */
+ CMP_L ( ECX, EDX )
+ JA ( TAGLLBL(FXPCV_loop_start) )
+
+ POP_L ( ESI )
+ POP_L ( EDI )
+
+TAGLLBL(FXPCV_end):
+ FEMMS
+ POP_L ( EBP )
+ RET
+
+
+
+#undef TYPE
+#undef TAG
+#undef SIZE
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/dri_glide.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/dri_glide.h
new file mode 100644
index 000000000..52a53f7dd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/dri_glide.h
@@ -0,0 +1,60 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/dri_glide.h,v 1.1 2001/03/21 16:14:26 dawes Exp $ */
+
+/*
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#ifndef __DRI_GLIDE_H__
+#define __DRI_GLIDE_H__
+
+#include <glide.h>
+#include "dri_mesaint.h"
+
+/*
+ * This is the private interface between Glide and the DRI.
+ */
+extern void grDRIOpen( char *pFB, char *pRegs, int deviceID,
+ int width, int height,
+ int mem, int cpp, int stride,
+ int fifoOffset, int fifoSize,
+ int fbOffset, int backOffset, int depthOffset,
+ int textureOffset, int textureSize,
+ volatile int *fifoPtr, volatile int *fifoRead );
+extern void grDRIPosition( int x, int y, int w, int h,
+ int numClip, drm_clip_rect_t *pClip );
+extern void grDRILostContext( void );
+extern void grDRIImportFifo( int fifoPtr, int fifoRead );
+extern void grDRIInvalidateAll( void );
+extern void grDRIResetSAREA( void );
+extern void grDRIBufferSwap( FxU32 swapInterval );
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/server/tdfx_dri.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/server/tdfx_dri.c
new file mode 100644
index 000000000..63fe875f5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/server/tdfx_dri.c
@@ -0,0 +1,471 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+/* Authors:
+ * Keith Whitwell
+ * Daniel Borca
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include "driver.h"
+#include "drm.h"
+#include "imports.h"
+
+#include "dri_util.h"
+
+#include "tdfx_context.h"
+#include "tdfx_dri.h"
+#include "xf86drm.h"
+
+
+#define TILE_WIDTH 128
+#define TILE_HEIGHT 32
+
+#define CMDFIFO_PAGES 64
+
+
+static int
+calcBufferStride (int xres, int tiled, int cpp)
+{
+ int strideInTiles;
+
+ if (tiled) {
+ /* Calculate tile width stuff */
+ strideInTiles = (xres+TILE_WIDTH-1)/TILE_WIDTH;
+
+ return strideInTiles*cpp*TILE_WIDTH;
+ } else {
+ return xres*cpp;
+ }
+} /* calcBufferStride */
+
+
+static int
+calcBufferHeightInTiles (int yres)
+{
+ int heightInTiles; /* Height of buffer in tiles */
+
+ /* Calculate tile height stuff */
+ heightInTiles = yres >> 5;
+
+ if (yres & (TILE_HEIGHT - 1))
+ heightInTiles++;
+
+ return heightInTiles;
+
+} /* calcBufferHeightInTiles */
+
+
+static int
+calcBufferSize (int xres, int yres, int tiled, int cpp)
+{
+ int stride, height, bufSize;
+
+ if (tiled) {
+ stride = calcBufferStride(xres, tiled, cpp);
+ height = TILE_HEIGHT * calcBufferHeightInTiles(yres);
+ } else {
+ stride = xres*cpp;
+ height = yres;
+ }
+
+ bufSize = stride * height;
+
+ return bufSize;
+} /* calcBufferSize */
+
+
+static void allocateMemory (const DRIDriverContext *ctx, TDFXDRIPtr pTDFX)
+{
+ int memRemaining, fifoSize, screenSizeInTiles;
+ int fbSize;
+ char *str;
+ int pixmapCacheLinesMin;
+ int cursorOffset, cursorSize;
+
+ pTDFX->stride = calcBufferStride(pTDFX->width, !0, pTDFX->cpp);
+
+ /* enough to do DVD */
+ pixmapCacheLinesMin = ((720*480*pTDFX->cpp) +
+ pTDFX->stride - 1)/pTDFX->stride;
+
+ if (pTDFX->deviceID > PCI_CHIP_VOODOO3) {
+ if ((pixmapCacheLinesMin + pTDFX->height) > 4095)
+ pixmapCacheLinesMin = 4095 - pTDFX->height;
+ } else {
+ if ((pixmapCacheLinesMin + pTDFX->height) > 2047)
+ pixmapCacheLinesMin = 2047 - pTDFX->height;
+ }
+
+ if (pTDFX->cpp!=3) {
+ screenSizeInTiles=calcBufferSize(pTDFX->width, pTDFX->height,
+ !0, pTDFX->cpp);
+ }
+ else {
+ /* cpp==3 needs to bump up to 4 */
+ screenSizeInTiles=calcBufferSize(pTDFX->width, pTDFX->height,
+ !0, 4);
+ }
+
+ /*
+ * Layout is:
+ * cursor, fifo, fb, tex, bb, db
+ */
+
+ fbSize = (pTDFX->height + pixmapCacheLinesMin) * pTDFX->stride;
+
+ memRemaining=(pTDFX->mem - 1) &~ 0xFFF;
+ /* Note that a page is 4096 bytes, and a */
+ /* tile is 32 x 128 = 4096 bytes. So, */
+ /* page and tile boundaries are the same */
+ /* Place the depth offset first, forcing */
+ /* it to be on an *odd* page boundary. */
+ pTDFX->depthOffset = (memRemaining - screenSizeInTiles) &~ 0xFFF;
+ if ((pTDFX->depthOffset & (0x1 << 12)) == 0) {
+ pTDFX->depthOffset -= (0x1 << 12);
+ }
+ /* Now, place the back buffer, forcing it */
+ /* to be on an *even* page boundary. */
+ pTDFX->backOffset = (pTDFX->depthOffset - screenSizeInTiles) &~ 0xFFF;
+ if (pTDFX->backOffset & (0x1 << 12)) {
+ pTDFX->backOffset -= (0x1 << 12);
+ }
+ /* Give the cmd fifo at least */
+ /* CMDFIFO_PAGES pages, but no more than */
+ /* 64. NOTE: Don't go higher than 64, as */
+ /* there is suspect code in Glide3 ! */
+ fifoSize = ((64 <= CMDFIFO_PAGES) ? 64 : CMDFIFO_PAGES) << 12;
+
+ /* We give 4096 bytes to the cursor */
+ cursorSize = 0/*4096*/;
+ cursorOffset = 0;
+
+ pTDFX->fifoOffset = cursorOffset + cursorSize;
+ pTDFX->fifoSize = fifoSize;
+ /* Now, place the front buffer, forcing */
+ /* it to be on a page boundary too, just */
+ /* for giggles. */
+ pTDFX->fbOffset = pTDFX->fifoOffset + pTDFX->fifoSize;
+ pTDFX->textureOffset = pTDFX->fbOffset + fbSize;
+ if (pTDFX->depthOffset <= pTDFX->textureOffset ||
+ pTDFX->backOffset <= pTDFX->textureOffset) {
+ /*
+ * pTDFX->textureSize < 0 means that the DRI is disabled. pTDFX->backOffset
+ * is used to calculate the maximum amount of memory available for
+ * 2D offscreen use. With DRI disabled, set this to the top of memory.
+ */
+
+ pTDFX->textureSize = -1;
+ pTDFX->backOffset = pTDFX->mem;
+ pTDFX->depthOffset = -1;
+ fprintf(stderr,
+ "Not enough video memory available for textures and depth buffer\n"
+ "\tand/or back buffer. Disabling DRI. To use DRI try lower\n"
+ "\tresolution modes and/or a smaller virtual screen size\n");
+ } else {
+ pTDFX->textureSize = pTDFX->backOffset - pTDFX->textureOffset;
+ }
+}
+
+
+static int createScreen (DRIDriverContext *ctx, TDFXDRIPtr pTDFX)
+{
+ int err;
+
+ {
+ int width_bytes = (ctx->shared.virtualWidth * ctx->cpp);
+ int maxy = ctx->shared.fbSize / width_bytes;
+
+
+ if (maxy <= ctx->shared.virtualHeight * 3) {
+ fprintf(stderr,
+ "Static buffer allocation failed -- "
+ "need at least %d kB video memory (have %d kB)\n",
+ (ctx->shared.virtualWidth * ctx->shared.virtualHeight *
+ ctx->cpp * 3 + 1023) / 1024,
+ ctx->shared.fbSize / 1024);
+ return 0;
+ }
+ }
+
+ ctx->shared.SAREASize = SAREA_MAX;
+ pTDFX->regsSize = ctx->MMIOSize;
+
+ /* Note that drmOpen will try to load the kernel module, if needed. */
+ ctx->drmFD = drmOpen("tdfx", NULL );
+ if (ctx->drmFD < 0) {
+ fprintf(stderr, "[drm] drmOpen failed\n");
+ return 0;
+ }
+
+ if ((err = drmSetBusid(ctx->drmFD, ctx->pciBusID)) < 0) {
+ fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n",
+ ctx->drmFD, ctx->pciBusID, strerror(-err));
+ return 0;
+ }
+
+ if (drmAddMap( ctx->drmFD,
+ 0,
+ ctx->shared.SAREASize,
+ DRM_SHM,
+ DRM_CONTAINS_LOCK,
+ &ctx->shared.hSAREA) < 0)
+ {
+ fprintf(stderr, "[drm] drmAddMap failed\n");
+ return 0;
+ }
+ fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n",
+ ctx->shared.SAREASize, ctx->shared.hSAREA);
+
+ if (drmMap( ctx->drmFD,
+ ctx->shared.hSAREA,
+ ctx->shared.SAREASize,
+ (drmAddressPtr)(&ctx->pSAREA)) < 0)
+ {
+ fprintf(stderr, "[drm] drmMap failed\n");
+ return 0;
+ }
+ memset(ctx->pSAREA, 0, ctx->shared.SAREASize);
+ fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n",
+ ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize);
+
+ /* Need to AddMap the framebuffer and mmio regions here:
+ */
+ if (drmAddMap( ctx->drmFD,
+ (drm_handle_t)ctx->FBStart,
+ ctx->FBSize,
+ DRM_FRAME_BUFFER,
+#ifndef _EMBEDDED
+ 0,
+#else
+ DRM_READ_ONLY,
+#endif
+ &ctx->shared.hFrameBuffer) < 0)
+ {
+ fprintf(stderr, "[drm] drmAddMap framebuffer failed\n");
+ return 0;
+ }
+
+ fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n",
+ ctx->shared.hFrameBuffer);
+
+
+ if (drmAddMap(ctx->drmFD,
+ ctx->MMIOStart,
+ ctx->MMIOSize,
+ DRM_REGISTERS,
+ DRM_READ_ONLY,
+ &pTDFX->regs) < 0) {
+ fprintf(stderr, "[drm] drmAddMap mmio failed\n");
+ return 0;
+ }
+ fprintf(stderr,
+ "[drm] register handle = 0x%08lx\n", pTDFX->regs);
+
+
+ /* Create a 'server' context so we can grab the lock for
+ * initialization ioctls.
+ */
+ if ((err = drmCreateContext(ctx->drmFD, &ctx->serverContext)) != 0) {
+ fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err);
+ return 0;
+ }
+
+ DRM_LOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext, 0);
+
+ /* Initialize the kernel data structures */
+
+ /* Initialize kernel gart memory manager */
+ allocateMemory(ctx, pTDFX);
+
+ /* Initialize the SAREA private data structure */
+
+
+ /* Quick hack to clear the front & back buffers. Could also use
+ * the clear ioctl to do this, but would need to setup hw state
+ * first.
+ */
+
+
+ /* This is the struct passed to tdfx_dri.so for its initialization */
+ ctx->driverClientMsg = malloc(sizeof(TDFXDRIRec));
+ ctx->driverClientMsgSize = sizeof(TDFXDRIRec);
+ memcpy(ctx->driverClientMsg, pTDFX, ctx->driverClientMsgSize);
+ pTDFX = (TDFXDRIPtr)ctx->driverClientMsg;
+
+ /* Don't release the lock now - let the VT switch handler do it. */
+
+ return 1;
+}
+
+
+/**
+ * \brief Validate the fbdev mode.
+ *
+ * \param ctx display handle.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Saves some registers and returns 1.
+ *
+ * \sa tdfxValidateMode().
+ */
+static int tdfxValidateMode( const DRIDriverContext *ctx )
+{
+ return 1;
+}
+
+
+/**
+ * \brief Examine mode returned by fbdev.
+ *
+ * \param ctx display handle.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Restores registers that fbdev has clobbered and returns 1.
+ *
+ * \sa tdfxValidateMode().
+ */
+static int tdfxPostValidateMode( const DRIDriverContext *ctx )
+{
+ return 1;
+}
+
+
+/**
+ * \brief Initialize the framebuffer device mode
+ *
+ * \param ctx display handle.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Before exiting clears the framebuffer memory accessing it directly.
+ */
+static int tdfxInitFBDev( DRIDriverContext *ctx )
+{
+ TDFXDRIPtr pTDFX = calloc(1, sizeof(TDFXDRIRec));
+
+ {
+ int dummy = ctx->shared.virtualWidth;
+
+ switch (ctx->bpp / 8) {
+ case 1: dummy = (ctx->shared.virtualWidth + 127) & ~127; break;
+ case 2: dummy = (ctx->shared.virtualWidth + 31) & ~31; break;
+ case 3:
+ case 4: dummy = (ctx->shared.virtualWidth + 15) & ~15; break;
+ }
+
+ ctx->shared.virtualWidth = dummy;
+ }
+
+ ctx->driverPrivate = (void *)pTDFX;
+
+ pTDFX->deviceID = ctx->chipset;
+ pTDFX->width = ctx->shared.virtualWidth;
+ pTDFX->height = ctx->shared.virtualHeight;
+ pTDFX->cpp = ctx->cpp;
+ pTDFX->mem = ctx->FBSize; /* ->shared.fbSize? mem probe? */
+ pTDFX->sarea_priv_offset = sizeof(drm_sarea_t);
+
+ if (!createScreen(ctx, pTDFX))
+ return 0;
+
+ return 1;
+}
+
+
+/**
+ * \brief The screen is being closed, so clean up any state and free any
+ * resources used by the DRI.
+ *
+ * \param ctx display handle.
+ *
+ * Unmaps the SAREA, closes the DRM device file descriptor and frees the driver
+ * private data.
+ */
+static void tdfxHaltFBDev( DRIDriverContext *ctx )
+{
+ drmUnmap( ctx->pSAREA, ctx->shared.SAREASize );
+ drmClose(ctx->drmFD);
+
+ if (ctx->driverPrivate) {
+ free(ctx->driverPrivate);
+ ctx->driverPrivate = 0;
+ }
+}
+
+
+/**
+ * \brief Shutdown the drawing engine.
+ *
+ * \param ctx display handle
+ *
+ * Turns off the 3D engine & restores the graphics card
+ * to a state that fbdev understands.
+ */
+static int tdfxEngineShutdown( const DRIDriverContext *ctx )
+{
+ fprintf(stderr, "%s: not implemented\n", __FUNCTION__);
+ return 1;
+}
+
+
+/**
+ * \brief Restore the drawing engine.
+ *
+ * \param ctx display handle
+ *
+ * Resets the graphics card and sets initial values for several registers of
+ * the card's drawing engine.
+ *
+ * Turns on 3dfx
+ */
+static int tdfxEngineRestore( const DRIDriverContext *ctx )
+{
+ fprintf(stderr, "%s: not implemented\n", __FUNCTION__);
+ return 1;
+}
+
+
+/**
+ * \brief Exported driver interface for Mini GLX.
+ *
+ * \sa DRIDriverRec.
+ */
+struct DRIDriverRec __driDriver = {
+ tdfxValidateMode,
+ tdfxPostValidateMode,
+ tdfxInitFBDev,
+ tdfxHaltFBDev,
+ tdfxEngineShutdown,
+ tdfxEngineRestore,
+ 0
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/server/tdfx_dri.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/server/tdfx_dri.h
new file mode 100644
index 000000000..acd0b9ae5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/server/tdfx_dri.h
@@ -0,0 +1,28 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.h,v 1.5 2001/03/21 17:02:26 dawes Exp $ */
+
+#ifndef _TDFX_DRI_
+#define _TDFX_DRI_
+
+#include "xf86drm.h"
+#include "drm.h"
+
+typedef struct {
+ drm_handle_t regs;
+ drmSize regsSize;
+ int deviceID;
+ int width;
+ int height;
+ int mem;
+ int cpp;
+ int stride;
+ int fifoOffset;
+ int fifoSize;
+ int fbOffset;
+ int backOffset;
+ int depthOffset;
+ int textureOffset;
+ int textureSize;
+ unsigned int sarea_priv_offset;
+} TDFXDRIRec, *TDFXDRIPtr;
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.c
new file mode 100644
index 000000000..412a2791d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.c
@@ -0,0 +1,1028 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.c,v 1.12 2003/05/08 09:25:35 herrb Exp $ */
+
+/*
+ * New fixes:
+ * Daniel Borca <dborca@users.sourceforge.net>, 19 Jul 2004
+ *
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ *
+ */
+
+#include <dlfcn.h>
+#include "tdfx_context.h"
+#include "tdfx_dd.h"
+#include "tdfx_state.h"
+#include "tdfx_vb.h"
+#include "tdfx_tex.h"
+#include "tdfx_tris.h"
+#include "tdfx_render.h"
+#include "tdfx_span.h"
+#include "tdfx_texman.h"
+#include "extensions.h"
+#include "hash.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+
+#include "drivers/common/driverfuncs.h"
+
+#include "utils.h"
+
+#define need_GL_ARB_multisample
+/* #define need_GL_ARB_point_parameters */
+#define need_GL_ARB_texture_compression
+#define need_GL_ARB_vertex_buffer_object
+/* #define need_GL_ARB_vertex_program */
+#define need_GL_EXT_blend_equation_separate
+#define need_GL_EXT_blend_func_separate
+#define need_GL_EXT_blend_minmax
+#define need_GL_EXT_fog_coord
+#define need_GL_EXT_multi_draw_arrays
+#define need_GL_EXT_paletted_texture
+/* #define need_GL_EXT_secondary_color */
+#define need_GL_IBM_multimode_draw_arrays
+/* #define need_GL_MESA_program_debug */
+/* #define need_GL_NV_vertex_program */
+#include "extension_helper.h"
+
+
+/**
+ * Common extension strings exported by all cards
+ */
+const struct dri_extension card_extensions[] =
+{
+ { "GL_ARB_multisample", GL_ARB_multisample_functions },
+ { "GL_ARB_texture_mirrored_repeat", NULL },
+ { "GL_ARB_vertex_buffer_object", GL_ARB_vertex_buffer_object_functions },
+
+ { "GL_EXT_blend_func_separate", GL_EXT_blend_func_separate_functions },
+ { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions },
+ { "GL_EXT_multi_draw_arrays", GL_EXT_multi_draw_arrays_functions },
+ { "GL_EXT_paletted_texture", GL_EXT_paletted_texture_functions },
+ { "GL_EXT_shared_texture_palette", NULL },
+ { "GL_EXT_stencil_wrap", NULL },
+ { "GL_EXT_texture_env_add", NULL },
+ { "GL_EXT_texture_lod_bias", NULL },
+ { "GL_HP_occlusion_test", NULL },
+ { "GL_IBM_multimode_draw_arrays", GL_IBM_multimode_draw_arrays_functions },
+
+#ifdef need_GL_ARB_point_parameters
+ { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions },
+ { "GL_ARB_point_sprite", NULL },
+#endif
+#ifdef need_GL_EXT_secondary_color
+ { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions },
+#endif
+#ifdef need_GL_ARB_vertex_program
+ { "GL_ARB_vertex_program", GL_ARB_vertex_program_functions }
+#endif
+#ifdef need_GL_NV_vertex_program
+ { "GL_NV_vertex_program", GL_NV_vertex_program_functions }
+ { "GL_NV_vertex_program1_1", NULL },
+#endif
+#ifdef need_GL_MESA_program_debug
+ { "GL_MESA_program_debug", GL_MESA_program_debug_functions },
+#endif
+ { NULL, NULL }
+};
+
+/**
+ * Extension strings exported only by Naplam (e.g., Voodoo4 & Voodoo5) cards.
+ */
+const struct dri_extension napalm_extensions[] =
+{
+ { "GL_ARB_texture_compression", GL_ARB_texture_compression_functions },
+ { "GL_ARB_texture_env_combine", NULL },
+ { "GL_EXT_blend_equation_separate", GL_EXT_blend_equation_separate_functions },
+ { "GL_EXT_blend_subtract", GL_EXT_blend_minmax_functions },
+ { "GL_EXT_texture_compression_s3tc", NULL },
+ { "GL_EXT_texture_env_combine", NULL },
+
+ { "GL_3DFX_texture_compression_FXT1", NULL },
+ { "GL_NV_blend_square", NULL },
+ { "GL_S3_s3tc", NULL },
+ { NULL, NULL }
+};
+
+/*
+ * Enable/Disable the extensions for this context.
+ */
+static void tdfxDDInitExtensions( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ driInitExtensions( ctx, card_extensions, GL_FALSE );
+
+ if ( fxMesa->haveTwoTMUs ) {
+ _mesa_enable_extension( ctx, "GL_ARB_multitexture" );
+ }
+
+ if ( TDFX_IS_NAPALM( fxMesa ) ) {
+ driInitExtensions( ctx, napalm_extensions, GL_FALSE );
+ } else {
+ _mesa_enable_extension( ctx, "GL_SGIS_generate_mipmap" );
+ }
+}
+
+
+
+static const struct tnl_pipeline_stage *tdfx_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ &_tnl_point_attenuation_stage,
+#if 0
+#if defined(FEATURE_NV_vertex_program) || defined(FEATURE_ARB_vertex_program)
+ &_tnl_arb_vertex_program_stage,
+ &_tnl_vertex_program_stage,
+#endif
+#endif
+ &_tnl_render_stage,
+ 0,
+};
+
+static const struct dri_debug_control debug_control[] =
+{
+ { "dri", DEBUG_VERBOSE_DRI },
+ { "sync", DEBUG_ALWAYS_SYNC },
+ { "api", DEBUG_VERBOSE_API },
+ { "fall", DEBUG_VERBOSE_FALL },
+ { NULL, 0 }
+};
+
+GLboolean tdfxCreateContext( const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate )
+{
+ tdfxContextPtr fxMesa;
+ GLcontext *ctx, *shareCtx;
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ tdfxScreenPrivate *fxScreen = (tdfxScreenPrivate *) sPriv->private;
+ TDFXSAREAPriv *saPriv = (TDFXSAREAPriv *) ((char *) sPriv->pSAREA +
+ sizeof(drm_sarea_t));
+ struct dd_function_table functions;
+
+ /* Allocate tdfx context */
+ fxMesa = (tdfxContextPtr) CALLOC( sizeof(tdfxContextRec) );
+ if (!fxMesa)
+ return GL_FALSE;
+
+ /* Init default driver functions then plug in our tdfx-specific functions
+ * (the texture functions are especially important)
+ */
+ _mesa_init_driver_functions(&functions);
+ tdfxDDInitDriverFuncs(mesaVis, &functions);
+ tdfxInitTextureFuncs(&functions);
+ tdfxInitRenderFuncs(&functions);
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((tdfxContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+
+ fxMesa->glCtx = _mesa_create_context(mesaVis, shareCtx,
+ &functions, (void *) fxMesa);
+ if (!fxMesa->glCtx) {
+ FREE(fxMesa);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = fxMesa;
+
+ /* Mirror some important DRI state
+ */
+ fxMesa->hHWContext = driContextPriv->hHWContext;
+ fxMesa->driHwLock = &sPriv->pSAREA->lock;
+ fxMesa->driFd = sPriv->fd;
+
+ fxMesa->driScreen = sPriv;
+ fxMesa->driContext = driContextPriv;
+ fxMesa->fxScreen = fxScreen;
+ fxMesa->sarea = saPriv;
+
+ /*JJJ - really?*/
+ fxMesa->haveHwAlpha = ( mesaVis->alphaBits &&
+ ((mesaVis->greenBits == 8) ||
+ (mesaVis->depthBits == 0)) );
+ fxMesa->haveHwStencil = ( TDFX_IS_NAPALM( fxMesa ) &&
+ mesaVis->stencilBits &&
+ mesaVis->depthBits == 24 );
+
+ fxMesa->screen_width = fxScreen->width;
+ fxMesa->screen_height = fxScreen->height;
+
+ fxMesa->new_gl_state = ~0;
+ fxMesa->new_state = ~0;
+ fxMesa->dirty = ~0;
+
+ /* Parse configuration files */
+ driParseConfigFiles (&fxMesa->optionCache, &fxScreen->optionCache,
+ fxMesa->driScreen->myNum, "tdfx");
+
+ /* NOTE: This must be here before any Glide calls! */
+ if (!tdfxInitGlide( fxMesa )) {
+ FREE(fxMesa);
+ return GL_FALSE;
+ }
+
+ fxMesa->Glide.grDRIOpen( (char*) sPriv->pFB, fxScreen->regs.map, fxScreen->deviceID,
+ fxScreen->width, fxScreen->height, fxScreen->mem, fxScreen->cpp,
+ fxScreen->stride, fxScreen->fifoOffset, fxScreen->fifoSize,
+ fxScreen->fbOffset, fxScreen->backOffset, fxScreen->depthOffset,
+ fxScreen->textureOffset, fxScreen->textureSize, &saPriv->fifoPtr,
+ &saPriv->fifoRead );
+
+ if ( getenv( "FX_GLIDE_SWAPINTERVAL" ) ) {
+ fxMesa->Glide.SwapInterval = atoi( getenv( "FX_GLIDE_SWAPINTERVAL" ) );
+ } else {
+ fxMesa->Glide.SwapInterval = 0;
+ }
+ if ( getenv( "FX_MAX_PENDING_SWAPS" ) ) {
+ fxMesa->Glide.MaxPendingSwaps = atoi( getenv( "FX_MAX_PENDING_SWAPS" ) );
+ } else {
+ fxMesa->Glide.MaxPendingSwaps = 2;
+ }
+
+ fxMesa->Glide.Initialized = GL_FALSE;
+ fxMesa->Glide.Board = 0;
+
+
+ if (getenv("FX_EMULATE_SINGLE_TMU")) {
+ fxMesa->haveTwoTMUs = GL_FALSE;
+ }
+ else {
+ if ( TDFX_IS_BANSHEE( fxMesa ) ) {
+ fxMesa->haveTwoTMUs = GL_FALSE;
+ } else {
+ fxMesa->haveTwoTMUs = GL_TRUE;
+ }
+ }
+
+ fxMesa->stats.swapBuffer = 0;
+ fxMesa->stats.reqTexUpload = 0;
+ fxMesa->stats.texUpload = 0;
+ fxMesa->stats.memTexUpload = 0;
+
+ fxMesa->tmuSrc = TDFX_TMU_NONE;
+
+ ctx = fxMesa->glCtx;
+ if ( TDFX_IS_NAPALM( fxMesa ) ) {
+ ctx->Const.MaxTextureLevels = 12;
+ } else {
+ ctx->Const.MaxTextureLevels = 9;
+ }
+ ctx->Const.MaxTextureUnits = TDFX_IS_BANSHEE( fxMesa ) ? 1 : 2;
+ ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;
+ ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;
+
+ /* No wide points.
+ */
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = 1.0;
+ ctx->Const.MaxPointSizeAA = 1.0;
+
+ /* Disable wide lines as we can't antialias them correctly in
+ * hardware.
+ */
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 1.0;
+ ctx->Const.MaxLineWidthAA = 1.0;
+ ctx->Const.LineWidthGranularity = 1.0;
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+
+ /* Install the customized pipeline:
+ */
+ _tnl_destroy_pipeline( ctx );
+ _tnl_install_pipeline( ctx, tdfx_pipeline );
+
+ /* Configure swrast and T&L to match hardware characteristics:
+ */
+ _swrast_allow_pixel_fog( ctx, GL_TRUE );
+ _swrast_allow_vertex_fog( ctx, GL_FALSE );
+ _tnl_allow_pixel_fog( ctx, GL_TRUE );
+ _tnl_allow_vertex_fog( ctx, GL_FALSE );
+
+ tdfxDDInitExtensions( ctx );
+ /* XXX these should really go right after _mesa_init_driver_functions() */
+ tdfxDDInitSpanFuncs( ctx );
+ tdfxDDInitStateFuncs( ctx );
+ tdfxDDInitTriFuncs( ctx );
+ tdfxInitVB( ctx );
+ tdfxInitState( fxMesa );
+
+#if DO_DEBUG
+ TDFX_DEBUG = driParseDebugString( getenv( "TDFX_DEBUG" ), debug_control );
+#endif
+
+ if (driQueryOptionb(&fxMesa->optionCache, "no_rast")) {
+ fprintf(stderr, "disabling 3D acceleration\n");
+ FALLBACK(fxMesa, TDFX_FALLBACK_DISABLE, 1);
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLboolean tdfxInitVertexFormats( tdfxContextPtr fxMesa )
+{
+ FxI32 result;
+ int i;
+
+ LOCK_HARDWARE( fxMesa );
+
+ fxMesa->Glide.grGet( GR_GLIDE_VERTEXLAYOUT_SIZE, sizeof(FxI32), &result );
+ for ( i = 0 ; i < TDFX_NUM_LAYOUTS ; i++ ) {
+ fxMesa->layout[i] = MALLOC( result );
+ if ( !fxMesa->layout[i] ) {
+ UNLOCK_HARDWARE( fxMesa );
+ return GL_FALSE;
+ }
+ }
+
+ /* Tiny vertex format - 16 bytes.
+ */
+ fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
+ fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_TINY] );
+
+ /* Non textured vertex format - 24 bytes (Need w for table fog)
+ */
+ fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
+ fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_NOTEX] );
+
+ /* Single textured vertex format - 32 bytes.
+ */
+ fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
+ fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_SINGLE] );
+
+ /* Multitextured vertex format - 40 bytes.
+ */
+ fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
+ fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_ST1, TDFX_ST1_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_MULTI] );
+
+ /* Projected texture vertex format - 36 bytes.
+ */
+ fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
+ fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_Q0, TDFX_Q0_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_PROJ1] );
+
+ /* Projected multitexture vertex format - 48 bytes.
+ */
+ fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
+ fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_Q0, TDFX_Q0_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_ST1, TDFX_ST1_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grVertexLayout( GR_PARAM_Q1, TDFX_Q1_OFFSET, GR_PARAM_ENABLE );
+ fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_PROJ2] );
+
+ UNLOCK_HARDWARE( fxMesa );
+
+ return GL_TRUE;
+}
+
+
+/*
+ * Initialize the state in an tdfxContextPtr struct.
+ */
+static GLboolean
+tdfxInitContext( __DRIdrawablePrivate *driDrawPriv, tdfxContextPtr fxMesa )
+{
+ /* KW: Would be nice to make one of these a member of the other.
+ */
+ FxI32 result[2];
+ const char *gext;
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
+ fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)fxMesa );
+ }
+
+#if DEBUG_LOCKING
+ fprintf(stderr, "Debug locking enabled\n");
+#endif
+
+ if ( fxMesa->Glide.Initialized )
+ return GL_TRUE;
+
+ 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.
+ */
+ DRM_LIGHT_LOCK( fxMesa->driFd, fxMesa->driHwLock, fxMesa->hHWContext );
+
+ fxMesa->Glide.grGlideInit();
+ fxMesa->Glide.grSstSelect( fxMesa->Glide.Board );
+
+ fxMesa->Glide.Context = fxMesa->Glide.grSstWinOpen( (FxU32) -1,
+ GR_RESOLUTION_NONE,
+ GR_REFRESH_NONE,
+ fxMesa->Glide.ColorFormat,
+ fxMesa->Glide.Origin,
+ 2, 1 );
+
+ fxMesa->Glide.grDRIResetSAREA();
+
+ DRM_UNLOCK( fxMesa->driFd, fxMesa->driHwLock, fxMesa->hHWContext );
+
+ if ( !fxMesa->Glide.Context )
+ return GL_FALSE;
+
+
+ /* Perform the Glide-dependant part of the context initialization.
+ */
+ FX_grColorMaskv( fxMesa->glCtx, true4 );
+
+ tdfxTMInit( fxMesa );
+
+ LOCK_HARDWARE( fxMesa );
+
+ /* JJJ - COMMAND_TRANSPORT, PALETTE6666 */
+ gext = fxMesa->Glide.grGetString( GR_EXTENSION );
+ fxMesa->Glide.HaveCombineExt = strstr(gext, "COMBINE") && !getenv("MESA_FX_IGNORE_CMBEXT");
+ fxMesa->Glide.HaveCommandTransportExt = GL_FALSE;
+ fxMesa->Glide.HaveFogCoordExt = GL_TRUE;
+ fxMesa->Glide.HavePixelExt = strstr(gext, "PIXEXT") && !getenv("MESA_FX_IGNORE_PIXEXT");
+ fxMesa->Glide.HaveTextureBufferExt = GL_TRUE;
+ fxMesa->Glide.HaveTexFmtExt = strstr(gext, "TEXFMT") && !getenv("MESA_FX_IGNORE_TEXFMT");
+ fxMesa->Glide.HaveTexUMAExt = strstr(gext, "TEXUMA") && !getenv("MESA_FX_IGNORE_TEXUMA");
+ fxMesa->Glide.HaveMirrorExt = strstr(gext, "TEXMIRROR") && !getenv("MESA_FX_IGNORE_MIREXT");
+ fxMesa->Glide.HaveTexus2 = GL_FALSE;
+
+ if ( fxMesa->glCtx->Visual.depthBits > 0 ) {
+ fxMesa->Glide.grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER);
+ } else {
+ fxMesa->Glide.grDepthBufferMode(GR_DEPTHBUFFER_DISABLE);
+ }
+
+ fxMesa->Glide.grLfbWriteColorFormat( GR_COLORFORMAT_ABGR );
+
+ fxMesa->Glide.grGet( GR_TEXTURE_ALIGN, sizeof(FxI32), result );
+ fxMesa->Glide.TextureAlign = result[0];
+
+ fxMesa->Glide.State = NULL;
+ fxMesa->Glide.grGet( GR_GLIDE_STATE_SIZE, sizeof(FxI32), result );
+ fxMesa->Glide.State = MALLOC( result[0] );
+
+ fxMesa->Fog.Table = NULL;
+ fxMesa->Glide.grGet( GR_FOG_TABLE_ENTRIES, sizeof(FxI32), result );
+ fxMesa->Fog.Table = MALLOC( result[0] * sizeof(GrFog_t) );
+
+ UNLOCK_HARDWARE( fxMesa );
+
+ if ( !fxMesa->Glide.State || !fxMesa->Fog.Table ) {
+ if ( fxMesa->Glide.State )
+ FREE( fxMesa->Glide.State );
+ if ( fxMesa->Fog.Table )
+ FREE( fxMesa->Fog.Table );
+ return GL_FALSE;
+ }
+
+ if ( !tdfxInitVertexFormats( fxMesa ) ) {
+ return GL_FALSE;
+ }
+
+ LOCK_HARDWARE( fxMesa );
+
+ fxMesa->Glide.grGlideGetState( fxMesa->Glide.State );
+
+ if ( getenv( "FX_GLIDE_INFO" ) ) {
+ printf( "GR_RENDERER = %s\n", (char *) fxMesa->Glide.grGetString( GR_RENDERER ) );
+ printf( "GR_VERSION = %s\n", (char *) fxMesa->Glide.grGetString( GR_VERSION ) );
+ printf( "GR_VENDOR = %s\n", (char *) fxMesa->Glide.grGetString( GR_VENDOR ) );
+ printf( "GR_HARDWARE = %s\n", (char *) fxMesa->Glide.grGetString( GR_HARDWARE ) );
+ printf( "GR_EXTENSION = %s\n", (char *) gext );
+ }
+
+ UNLOCK_HARDWARE( fxMesa );
+
+ fxMesa->numClipRects = 0;
+ fxMesa->pClipRects = NULL;
+ fxMesa->scissoredClipRects = GL_FALSE;
+
+ fxMesa->Glide.Initialized = GL_TRUE;
+
+ return GL_TRUE;
+}
+
+
+void
+tdfxDestroyContext( __DRIcontextPrivate *driContextPriv )
+{
+ tdfxContextPtr fxMesa = (tdfxContextPtr) driContextPriv->driverPrivate;
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
+ fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)fxMesa );
+ }
+
+ if ( fxMesa ) {
+ if (fxMesa->glCtx->Shared->RefCount == 1 && fxMesa->driDrawable) {
+ /* This share group is about to go away, free our private
+ * texture object data.
+ */
+ struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects;
+ GLuint id;
+ for (id = _mesa_HashFirstEntry(textures);
+ id;
+ id = _mesa_HashNextEntry(textures, id)) {
+ struct gl_texture_object *tObj
+ = (struct gl_texture_object *) _mesa_HashLookup(textures, id);
+ tdfxTMFreeTexture(fxMesa, tObj);
+ }
+ }
+
+ tdfxTMClose(fxMesa); /* free texture memory */
+
+ _swsetup_DestroyContext( fxMesa->glCtx );
+ _tnl_DestroyContext( fxMesa->glCtx );
+ _ac_DestroyContext( fxMesa->glCtx );
+ _swrast_DestroyContext( fxMesa->glCtx );
+
+ tdfxFreeVB( fxMesa->glCtx );
+
+ /* Free Mesa context */
+ fxMesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(fxMesa->glCtx);
+
+ /* free the tdfx context */
+ FREE( fxMesa );
+ }
+}
+
+
+GLboolean
+tdfxUnbindContext( __DRIcontextPrivate *driContextPriv )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
+ fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)driContextPriv );
+ }
+
+ if ( driContextPriv && (tdfxContextPtr) driContextPriv == fxMesa ) {
+ LOCK_HARDWARE(fxMesa);
+ fxMesa->Glide.grGlideGetState(fxMesa->Glide.State);
+ UNLOCK_HARDWARE(fxMesa);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
+tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv )
+{
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
+ fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)driContextPriv );
+ }
+
+ if ( driContextPriv ) {
+ tdfxContextPtr newFx = (tdfxContextPtr) driContextPriv->driverPrivate;
+ GLcontext *newCtx = newFx->glCtx;
+ GET_CURRENT_CONTEXT(curCtx);
+
+ if ( newFx->driDrawable != driDrawPriv ) {
+ newFx->driDrawable = driDrawPriv;
+ newFx->dirty = ~0;
+ }
+ else {
+ if (curCtx == newCtx) {
+ /* same drawable, same context -> no-op */
+ /* Need to call _mesa_make_current2() in order to make sure API
+ * dispatch is set correctly.
+ */
+ _mesa_make_current( newCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
+ return GL_TRUE;
+ }
+ /* [dBorca] tunnel2 requires this */
+ newFx->dirty = ~0;
+ }
+
+ if ( !newFx->Glide.Initialized ) {
+ if ( !tdfxInitContext( driDrawPriv, newFx ) )
+ return GL_FALSE;
+
+ LOCK_HARDWARE( newFx );
+
+ /* FIXME: Force loading of window information */
+ newFx->width = 0;
+ tdfxUpdateClipping(newCtx);
+ tdfxUploadClipping(newFx);
+
+ UNLOCK_HARDWARE( newFx );
+ } else {
+ LOCK_HARDWARE( newFx );
+
+ newFx->Glide.grSstSelect( newFx->Glide.Board );
+ newFx->Glide.grGlideSetState( newFx->Glide.State );
+
+ tdfxUpdateClipping(newCtx);
+ tdfxUploadClipping(newFx);
+
+ UNLOCK_HARDWARE( newFx );
+ }
+
+ _mesa_make_current( newCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
+ } else {
+ _mesa_make_current( NULL, NULL, NULL );
+ }
+
+ return GL_TRUE;
+}
+
+
+/*
+ * Enable this to trace calls to various Glide functions.
+ */
+/*#define DEBUG_TRAP*/
+#ifdef DEBUG_TRAP
+static void (*real_grDrawTriangle)( const void *a, const void *b, const void *c );
+static void (*real_grDrawPoint)( const void *a );
+static void (*real_grDrawVertexArray)(FxU32 mode, FxU32 Count, void *pointers);
+static void (*real_grDrawVertexArrayContiguous)(FxU32 mode, FxU32 Count,
+ void *pointers, FxU32 stride);
+static void (*real_grClipWindow)( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy );
+
+static void (*real_grVertexLayout)(FxU32 param, FxI32 offset, FxU32 mode);
+static void (*real_grGlideGetVertexLayout)( void *layout );
+static void (*real_grGlideSetVertexLayout)( const void *layout );
+
+static void (*real_grTexDownloadMipMapLevel)( GrChipID_t tmu,
+ FxU32 startAddress,
+ GrLOD_t thisLod,
+ GrLOD_t largeLod,
+ GrAspectRatio_t aspectRatio,
+ GrTextureFormat_t format,
+ FxU32 evenOdd,
+ void *data );
+
+
+static void debug_grDrawTriangle( const void *a, const void *b, const void *c )
+{
+ printf("%s\n", __FUNCTION__);
+ (*real_grDrawTriangle)(a, b, c);
+}
+
+static void debug_grDrawPoint( const void *a )
+{
+ const float *f = (const float *) a;
+ printf("%s %g %g\n", __FUNCTION__, f[0], f[1]);
+ (*real_grDrawPoint)(a);
+}
+
+static void debug_grDrawVertexArray(FxU32 mode, FxU32 Count, void *pointers)
+{
+ printf("%s count=%d\n", __FUNCTION__, (int) Count);
+ (*real_grDrawVertexArray)(mode, Count, pointers);
+}
+
+static void debug_grDrawVertexArrayContiguous(FxU32 mode, FxU32 Count,
+ void *pointers, FxU32 stride)
+{
+ printf("%s mode=0x%x count=%d\n", __FUNCTION__, (int) mode, (int) Count);
+ (*real_grDrawVertexArrayContiguous)(mode, Count, pointers, stride);
+}
+
+static void debug_grClipWindow( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy )
+{
+ printf("%s %d,%d .. %d,%d\n", __FUNCTION__,
+ (int) minx, (int) miny, (int) maxx, (int) maxy);
+ (*real_grClipWindow)(minx, miny, maxx, maxy);
+}
+
+static void debug_grVertexLayout(FxU32 param, FxI32 offset, FxU32 mode)
+{
+ (*real_grVertexLayout)(param, offset, mode);
+}
+
+static void debug_grGlideGetVertexLayout( void *layout )
+{
+ (*real_grGlideGetVertexLayout)(layout);
+}
+
+static void debug_grGlideSetVertexLayout( const void *layout )
+{
+ (*real_grGlideSetVertexLayout)(layout);
+}
+
+static void debug_grTexDownloadMipMapLevel( GrChipID_t tmu,
+ FxU32 startAddress,
+ GrLOD_t thisLod,
+ GrLOD_t largeLod,
+ GrAspectRatio_t aspectRatio,
+ GrTextureFormat_t format,
+ FxU32 evenOdd,
+ void *data )
+{
+ (*real_grTexDownloadMipMapLevel)(tmu, startAddress, thisLod, largeLod,
+ aspectRatio, format, evenOdd, data);
+}
+
+#endif
+
+
+/*
+ * Examine the context's deviceID to determine what kind of 3dfx hardware
+ * is installed. dlopen() the appropriate Glide library and initialize
+ * this context's Glide function pointers.
+ * Return: true/false = success/failure
+ */
+GLboolean tdfxInitGlide(tdfxContextPtr tmesa)
+{
+ static const char *defaultGlide = "libglide3.so";
+ const char *libName;
+ void *libHandle;
+
+ /*
+ * XXX this code which selects a Glide library filename given the
+ * deviceID may need to be cleaned up a bit.
+ * Non-Linux systems may have different filenames, for example.
+ */
+ switch (tmesa->fxScreen->deviceID) {
+ case PCI_CHIP_BANSHEE:
+ case PCI_CHIP_VOODOO3:
+ libName = "libglide3-v3.so";
+ break;
+ case PCI_CHIP_VOODOO5: /* same as PCI_CHIP_VOODOO4 */
+ libName = "libglide3-v5.so";
+ break;
+ default:
+ {
+ __driUtilMessage("unrecognized 3dfx deviceID: 0x%x",
+ tmesa->fxScreen->deviceID);
+ }
+ return GL_FALSE;
+ }
+
+ libHandle = dlopen(libName, RTLD_NOW);
+ if (!libHandle) {
+ /* The device-specific Glide library filename didn't work, try the
+ * old, generic libglide3.so library.
+ */
+ libHandle = dlopen(defaultGlide, RTLD_NOW);
+ if (!libHandle) {
+ __driUtilMessage(
+ "can't find Glide library, dlopen(%s) and dlopen(%s) both failed.",
+ libName, defaultGlide);
+ __driUtilMessage("dlerror() message: %s", dlerror());
+ return GL_FALSE;
+ }
+ libName = defaultGlide;
+ }
+
+ {
+ const char *env = getenv("LIBGL_DEBUG");
+ if (env && strstr(env, "verbose")) {
+ fprintf(stderr, "libGL: using Glide library %s\n", libName);
+ }
+ }
+
+#define GET_FUNCTION(PTR, NAME) \
+ tmesa->Glide.PTR = dlsym(libHandle, NAME); \
+ if (!tmesa->Glide.PTR) { \
+ __driUtilMessage("couldn't find Glide function %s in %s.", \
+ NAME, libName); \
+ }
+
+ GET_FUNCTION(grDrawPoint, "grDrawPoint");
+ GET_FUNCTION(grDrawLine, "grDrawLine");
+ GET_FUNCTION(grDrawTriangle, "grDrawTriangle");
+ GET_FUNCTION(grVertexLayout, "grVertexLayout");
+ GET_FUNCTION(grDrawVertexArray, "grDrawVertexArray");
+ GET_FUNCTION(grDrawVertexArrayContiguous, "grDrawVertexArrayContiguous");
+ GET_FUNCTION(grBufferClear, "grBufferClear");
+ /*GET_FUNCTION(grBufferSwap, "grBufferSwap");*/
+ GET_FUNCTION(grRenderBuffer, "grRenderBuffer");
+ GET_FUNCTION(grErrorSetCallback, "grErrorSetCallback");
+ GET_FUNCTION(grFinish, "grFinish");
+ GET_FUNCTION(grFlush, "grFlush");
+ GET_FUNCTION(grSstWinOpen, "grSstWinOpen");
+ GET_FUNCTION(grSstWinClose, "grSstWinClose");
+#if 0
+ /* Not in V3 lib, and not used anyway. */
+ GET_FUNCTION(grSetNumPendingBuffers, "grSetNumPendingBuffers");
+#endif
+ GET_FUNCTION(grSelectContext, "grSelectContext");
+ GET_FUNCTION(grSstOrigin, "grSstOrigin");
+ GET_FUNCTION(grSstSelect, "grSstSelect");
+ GET_FUNCTION(grAlphaBlendFunction, "grAlphaBlendFunction");
+ GET_FUNCTION(grAlphaCombine, "grAlphaCombine");
+ GET_FUNCTION(grAlphaControlsITRGBLighting, "grAlphaControlsITRGBLighting");
+ GET_FUNCTION(grAlphaTestFunction, "grAlphaTestFunction");
+ GET_FUNCTION(grAlphaTestReferenceValue, "grAlphaTestReferenceValue");
+ GET_FUNCTION(grChromakeyMode, "grChromakeyMode");
+ GET_FUNCTION(grChromakeyValue, "grChromakeyValue");
+ GET_FUNCTION(grClipWindow, "grClipWindow");
+ GET_FUNCTION(grColorCombine, "grColorCombine");
+ GET_FUNCTION(grColorMask, "grColorMask");
+ GET_FUNCTION(grCullMode, "grCullMode");
+ GET_FUNCTION(grConstantColorValue, "grConstantColorValue");
+ GET_FUNCTION(grDepthBiasLevel, "grDepthBiasLevel");
+ GET_FUNCTION(grDepthBufferFunction, "grDepthBufferFunction");
+ GET_FUNCTION(grDepthBufferMode, "grDepthBufferMode");
+ GET_FUNCTION(grDepthMask, "grDepthMask");
+ GET_FUNCTION(grDisableAllEffects, "grDisableAllEffects");
+ GET_FUNCTION(grDitherMode, "grDitherMode");
+ GET_FUNCTION(grFogColorValue, "grFogColorValue");
+ GET_FUNCTION(grFogMode, "grFogMode");
+ GET_FUNCTION(grFogTable, "grFogTable");
+ GET_FUNCTION(grLoadGammaTable, "grLoadGammaTable");
+ GET_FUNCTION(grSplash, "grSplash");
+ GET_FUNCTION(grGet, "grGet");
+ GET_FUNCTION(grGetString, "grGetString");
+ GET_FUNCTION(grQueryResolutions, "grQueryResolutions");
+ GET_FUNCTION(grReset, "grReset");
+ GET_FUNCTION(grGetProcAddress, "grGetProcAddress");
+ GET_FUNCTION(grEnable, "grEnable");
+ GET_FUNCTION(grDisable, "grDisable");
+ GET_FUNCTION(grCoordinateSpace, "grCoordinateSpace");
+ GET_FUNCTION(grDepthRange, "grDepthRange");
+ GET_FUNCTION(grStippleMode, "grStippleMode");
+ GET_FUNCTION(grStipplePattern, "grStipplePattern");
+ GET_FUNCTION(grViewport, "grViewport");
+ GET_FUNCTION(grTexCalcMemRequired, "grTexCalcMemRequired");
+ GET_FUNCTION(grTexTextureMemRequired, "grTexTextureMemRequired");
+ GET_FUNCTION(grTexMinAddress, "grTexMinAddress");
+ GET_FUNCTION(grTexMaxAddress, "grTexMaxAddress");
+ GET_FUNCTION(grTexNCCTable, "grTexNCCTable");
+ GET_FUNCTION(grTexSource, "grTexSource");
+ GET_FUNCTION(grTexClampMode, "grTexClampMode");
+ GET_FUNCTION(grTexCombine, "grTexCombine");
+ GET_FUNCTION(grTexDetailControl, "grTexDetailControl");
+ GET_FUNCTION(grTexFilterMode, "grTexFilterMode");
+ GET_FUNCTION(grTexLodBiasValue, "grTexLodBiasValue");
+ GET_FUNCTION(grTexDownloadMipMap, "grTexDownloadMipMap");
+ GET_FUNCTION(grTexDownloadMipMapLevel, "grTexDownloadMipMapLevel");
+ GET_FUNCTION(grTexDownloadMipMapLevelPartial, "grTexDownloadMipMapLevelPartial");
+ GET_FUNCTION(grTexDownloadTable, "grTexDownloadTable");
+ GET_FUNCTION(grTexDownloadTablePartial, "grTexDownloadTablePartial");
+ GET_FUNCTION(grTexMipMapMode, "grTexMipMapMode");
+ GET_FUNCTION(grTexMultibase, "grTexMultibase");
+ GET_FUNCTION(grTexMultibaseAddress, "grTexMultibaseAddress");
+ GET_FUNCTION(grLfbLock, "grLfbLock");
+ GET_FUNCTION(grLfbUnlock, "grLfbUnlock");
+ GET_FUNCTION(grLfbConstantAlpha, "grLfbConstantAlpha");
+ GET_FUNCTION(grLfbConstantDepth, "grLfbConstantDepth");
+ GET_FUNCTION(grLfbWriteColorSwizzle, "grLfbWriteColorSwizzle");
+ GET_FUNCTION(grLfbWriteColorFormat, "grLfbWriteColorFormat");
+ GET_FUNCTION(grLfbWriteRegion, "grLfbWriteRegion");
+ GET_FUNCTION(grLfbReadRegion, "grLfbReadRegion");
+ GET_FUNCTION(grGlideInit, "grGlideInit");
+ GET_FUNCTION(grGlideShutdown, "grGlideShutdown");
+ GET_FUNCTION(grGlideGetState, "grGlideGetState");
+ GET_FUNCTION(grGlideSetState, "grGlideSetState");
+ GET_FUNCTION(grGlideGetVertexLayout, "grGlideGetVertexLayout");
+ GET_FUNCTION(grGlideSetVertexLayout, "grGlideSetVertexLayout");
+
+ /* Glide utility functions */
+ GET_FUNCTION(guFogGenerateExp, "guFogGenerateExp");
+ GET_FUNCTION(guFogGenerateExp2, "guFogGenerateExp2");
+ GET_FUNCTION(guFogGenerateLinear, "guFogGenerateLinear");
+
+ /* DRI functions */
+ GET_FUNCTION(grDRIOpen, "grDRIOpen");
+ GET_FUNCTION(grDRIPosition, "grDRIPosition");
+ /*GET_FUNCTION(grDRILostContext, "grDRILostContext");*/
+ GET_FUNCTION(grDRIImportFifo, "grDRIImportFifo");
+ GET_FUNCTION(grDRIInvalidateAll, "grDRIInvalidateAll");
+ GET_FUNCTION(grDRIResetSAREA, "grDRIResetSAREA");
+ GET_FUNCTION(grDRIBufferSwap, "grDRIBufferSwap");
+
+ /*
+ * Extension functions:
+ * Just use dlysm() because we want a NULL pointer if the function is
+ * not found.
+ */
+ /* PIXEXT extension */
+ tmesa->Glide.grStencilFunc = dlsym(libHandle, "grStencilFunc");
+ tmesa->Glide.grStencilMask = dlsym(libHandle, "grStencilMask");
+ tmesa->Glide.grStencilOp = dlsym(libHandle, "grStencilOp");
+ tmesa->Glide.grBufferClearExt = dlsym(libHandle, "grBufferClearExt");
+ tmesa->Glide.grColorMaskExt = dlsym(libHandle, "grColorMaskExt");
+ /* COMBINE extension */
+ tmesa->Glide.grColorCombineExt = dlsym(libHandle, "grColorCombineExt");
+ tmesa->Glide.grTexColorCombineExt = dlsym(libHandle, "grTexColorCombineExt");
+ tmesa->Glide.grAlphaCombineExt = dlsym(libHandle, "grAlphaCombineExt");
+ tmesa->Glide.grTexAlphaCombineExt = dlsym(libHandle, "grTexAlphaCombineExt");
+ tmesa->Glide.grAlphaBlendFunctionExt = dlsym(libHandle, "grAlphaBlendFunctionExt");
+ tmesa->Glide.grConstantColorValueExt = dlsym(libHandle, "grConstantColorValueExt");
+ /* Texus 2 */
+ tmesa->Glide.txImgQuantize = dlsym(libHandle, "txImgQuantize");
+ tmesa->Glide.txImgDequantizeFXT1 = dlsym(libHandle, "_txImgDequantizeFXT1");
+ tmesa->Glide.txErrorSetCallback = dlsym(libHandle, "txErrorSetCallback");
+
+#ifdef DEBUG_TRAP
+ /* wrap the drawing functions so we can trap them */
+ real_grDrawTriangle = tmesa->Glide.grDrawTriangle;
+ tmesa->Glide.grDrawTriangle = debug_grDrawTriangle;
+
+ real_grDrawPoint = tmesa->Glide.grDrawPoint;
+ tmesa->Glide.grDrawPoint = debug_grDrawPoint;
+
+ real_grDrawVertexArray = tmesa->Glide.grDrawVertexArray;
+ tmesa->Glide.grDrawVertexArray = debug_grDrawVertexArray;
+
+ real_grDrawVertexArrayContiguous = tmesa->Glide.grDrawVertexArrayContiguous;
+ tmesa->Glide.grDrawVertexArrayContiguous = debug_grDrawVertexArrayContiguous;
+
+ real_grClipWindow = tmesa->Glide.grClipWindow;
+ tmesa->Glide.grClipWindow = debug_grClipWindow;
+
+ real_grVertexLayout = tmesa->Glide.grVertexLayout;
+ tmesa->Glide.grVertexLayout = debug_grVertexLayout;
+
+ real_grGlideGetVertexLayout = tmesa->Glide.grGlideGetVertexLayout;
+ tmesa->Glide.grGlideGetVertexLayout = debug_grGlideGetVertexLayout;
+
+ real_grGlideSetVertexLayout = tmesa->Glide.grGlideSetVertexLayout;
+ tmesa->Glide.grGlideSetVertexLayout = debug_grGlideSetVertexLayout;
+
+ real_grTexDownloadMipMapLevel = tmesa->Glide.grTexDownloadMipMapLevel;
+ tmesa->Glide.grTexDownloadMipMapLevel = debug_grTexDownloadMipMapLevel;
+
+#endif
+ return GL_TRUE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.h
new file mode 100644
index 000000000..b8349fec7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_context.h
@@ -0,0 +1,1007 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.h,v 1.5 2002/02/24 21:51:10 dawes Exp $ */
+
+/*
+ * New fixes:
+ * Daniel Borca <dborca@users.sourceforge.net>, 19 Jul 2004
+ *
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#ifndef __TDFX_CONTEXT_H__
+#define __TDFX_CONTEXT_H__
+
+#include <sys/time.h>
+#include "dri_util.h"
+#ifdef XFree86Server
+#include "GL/xf86glx.h"
+#else
+#include "glheader.h"
+#endif
+#if defined(__linux__)
+#include <signal.h>
+#endif
+
+#include "drm.h"
+#include "drm_sarea.h"
+#include "tdfx_glide.h"
+#include "xmlconfig.h"
+
+#include "clip.h"
+#include "context.h"
+#include "macros.h"
+#include "matrix.h"
+#include "imports.h"
+#include "mtypes.h"
+
+#include "tdfx_screen.h"
+
+
+
+
+#define TDFX_TMU0 GR_TMU0
+#define TDFX_TMU1 GR_TMU1
+#define TDFX_TMU_SPLIT 98
+#define TDFX_TMU_BOTH 99
+#define TDFX_TMU_NONE 100
+
+
+
+/* Flags for fxMesa->new_state
+ */
+#define TDFX_NEW_COLOR 0x0001
+#define TDFX_NEW_ALPHA 0x0002
+#define TDFX_NEW_DEPTH 0x0004
+#define TDFX_NEW_FOG 0x0008
+#define TDFX_NEW_STENCIL 0x0010
+#define TDFX_NEW_CLIP 0x0020
+#define TDFX_NEW_VIEWPORT 0x0040
+#define TDFX_NEW_CULL 0x0080
+#define TDFX_NEW_GLIDE 0x0100
+#define TDFX_NEW_TEXTURE 0x0200
+#define TDFX_NEW_CONTEXT 0x0400
+#define TDFX_NEW_LINE 0x0800
+#define TDFX_NEW_RENDER 0x1000
+#define TDFX_NEW_STIPPLE 0x2000
+#define TDFX_NEW_TEXTURE_BIND 0x4000 /* experimental */
+
+
+/* Flags for fxMesa->dirty
+ */
+#define TDFX_UPLOAD_COLOR_COMBINE 0x00000001
+#define TDFX_UPLOAD_ALPHA_COMBINE 0x00000002
+#define TDFX_UPLOAD_RENDER_BUFFER 0x00000004
+#define TDFX_UPLOAD_ALPHA_TEST 0x00000008
+#define TDFX_UPLOAD_ALPHA_REF 0x00000010
+#define TDFX_UPLOAD_BLEND_FUNC 0x00000020
+#define TDFX_UPLOAD_DEPTH_MODE 0x00000040
+#define TDFX_UPLOAD_DEPTH_BIAS 0x00000080
+#define TDFX_UPLOAD_DEPTH_FUNC 0x00000100
+#define TDFX_UPLOAD_DEPTH_MASK 0x00000200
+#define TDFX_UPLOAD_FOG_MODE 0x00000400
+#define TDFX_UPLOAD_FOG_COLOR 0x00000800
+#define TDFX_UPLOAD_FOG_TABLE 0x00001000
+#define TDFX_UPLOAD_CONSTANT_COLOR 0x00002000
+
+#define TDFX_UPLOAD_CLIP 0x00002000
+#define TDFX_UPLOAD_CULL 0x00004000
+#define TDFX_UPLOAD_VERTEX_LAYOUT 0x00008000
+#define TDFX_UPLOAD_COLOR_MASK 0x00010000
+#define TDFX_UPLOAD_DITHER 0x00040000
+#define TDFX_UPLOAD_STENCIL 0x00080000
+
+#define TDFX_UPLOAD_TEXTURE_SOURCE 0x00100000
+#define TDFX_UPLOAD_TEXTURE_PARAMS 0x00200000
+#define TDFX_UPLOAD_TEXTURE_PALETTE 0x00400000
+#define TDFX_UPLOAD_TEXTURE_ENV 0x00800000
+#define TDFX_UPLOAD_TEXTURE_IMAGES 0x01000000
+
+#define TDFX_UPLOAD_LINE 0x02000000
+
+#define TDFX_UPLOAD_STIPPLE 0x04000000
+
+/* Flags for software fallback cases */
+/* See correponding strings in tdfx_tris.c */
+#define TDFX_FALLBACK_TEXTURE_MAP 0x0001
+#define TDFX_FALLBACK_DRAW_BUFFER 0x0002
+#define TDFX_FALLBACK_SPECULAR 0x0004
+#define TDFX_FALLBACK_STENCIL 0x0008
+#define TDFX_FALLBACK_RENDER_MODE 0x0010
+#define TDFX_FALLBACK_LOGICOP 0x0020
+#define TDFX_FALLBACK_TEXTURE_ENV 0x0040
+#define TDFX_FALLBACK_TEXTURE_BORDER 0x0080
+#define TDFX_FALLBACK_COLORMASK 0x0100
+#define TDFX_FALLBACK_BLEND 0x0200
+#define TDFX_FALLBACK_LINE_STIPPLE 0x0400
+#define TDFX_FALLBACK_DISABLE 0x0800
+
+/* Different Glide vertex layouts
+ */
+#define TDFX_LAYOUT_TINY 0
+#define TDFX_LAYOUT_NOTEX 1
+#define TDFX_LAYOUT_SINGLE 2
+#define TDFX_LAYOUT_MULTI 3
+#define TDFX_LAYOUT_PROJ1 4
+#define TDFX_LAYOUT_PROJ2 5
+#define TDFX_NUM_LAYOUTS 6
+
+#define TDFX_XY_OFFSET 0
+#define TDFX_Z_OFFSET 8
+#define TDFX_Q_OFFSET 12
+#define TDFX_ARGB_OFFSET 16
+#define TDFX_FOG_OFFSET 20
+#define TDFX_ST0_OFFSET 24
+#define TDFX_ST1_OFFSET 32
+#define TDFX_Q0_OFFSET 40
+#define TDFX_Q1_OFFSET 44
+
+
+/* Flags for buffer clears
+ */
+#define TDFX_FRONT 0x1
+#define TDFX_BACK 0x2
+#define TDFX_DEPTH 0x4
+#define TDFX_STENCIL 0x8
+
+/*
+ * Subpixel offsets to adjust Mesa's (true) window coordinates to
+ * Glide coordinates. We need these to ensure precise rasterization.
+ * Otherwise, we'll fail a bunch of conformance tests.
+ */
+#define TRI_X_OFFSET ( 0.0F)
+#define TRI_Y_OFFSET ( 0.0F)
+#define LINE_X_OFFSET ( 0.0F)
+#define LINE_Y_OFFSET ( 0.125F)
+#define PNT_X_OFFSET ( 0.375F)
+#define PNT_Y_OFFSET ( 0.375F)
+
+
+#define TDFX_DEPTH_BIAS_SCALE 128
+
+/* Including xf86PciInfo.h causes a bunch of errors
+ */
+#ifndef PCI_CHIP_BANSHEE
+#define PCI_CHIP_BANSHEE 0x0003
+#define PCI_CHIP_VOODOO3 0x0005
+#define PCI_CHIP_VOODOO4 0x0009
+#define PCI_CHIP_VOODOO5 0x0009
+#endif
+
+#define TDFX_IS_BANSHEE( fxMesa ) \
+ ( fxMesa->fxScreen->deviceID == PCI_CHIP_BANSHEE )
+#define TDFX_IS_VOODOO3( fxMesa ) \
+ ( fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO3 )
+#define TDFX_IS_VOODOO4( fxMesa ) \
+ ( fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO4 )
+#define TDFX_IS_VOODOO5( fxMesa ) \
+ ( fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO5 )
+#define TDFX_IS_NAPALM( fxMesa ) \
+ ( (fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO4) || \
+ (fxMesa->fxScreen->deviceID == PCI_CHIP_VOODOO5) )
+
+
+#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) )
+
+/*
+ * The first two macros are to pack 8 bit color
+ * channel values into a 565 format.
+ */
+#define PACK_RGB16(R, G, B) \
+ ((((GLuint) (R) & 0xF8) << 8) | \
+ (((GLuint) (G) & 0xFC) << 3) | \
+ (((GLuint) (B) & 0xFF) >> 3))
+#define PACK_BGR16(R, G, B) \
+ ((((GLuint) (B) & 0xF8) << 8) | \
+ (((GLuint) (G) & 0xFC) << 3) | \
+ (((GLuint) (R) & 0xFF) >> 3))
+/*
+ * The second two macros pack 8 bit color channel values
+ * into 1555 values.
+ */
+#define PACK_RGBA16(R, G, B, A) \
+ (((((GLuint) (A) & 0xFF) > 0) << 15)| \
+ (((GLuint) (R) & 0xF8) << 7) | \
+ (((GLuint) (G) & 0xF8) << 2) | \
+ (((GLuint) (B) & 0xF8) >> 3))
+#define PACK_BGRA16(R, G, B, A) \
+ (((((GLuint) (A) & 0xFF) > 0) << 15)| \
+ (((GLuint) (B) & 0xF8) << 7) | \
+ (((GLuint) (G) & 0xF8) << 2) | \
+ (((GLuint) (R) & 0xF8) >> 3))
+
+/* Used in calls to grColorMaskv()...
+ */
+extern const GLboolean false4[4];
+extern const GLboolean true4[4];
+
+
+typedef struct tdfx_context tdfxContextRec;
+typedef struct tdfx_context *tdfxContextPtr;
+
+
+typedef struct {
+ volatile int fifoPtr;
+ volatile int fifoRead;
+ volatile int fifoOwner;
+ volatile int ctxOwner;
+ volatile int texOwner;
+}
+TDFXSAREAPriv;
+
+
+typedef struct {
+ GLuint swapBuffer;
+ GLuint reqTexUpload;
+ GLuint texUpload;
+ GLuint memTexUpload;
+ GLuint texSwaps;
+} tdfxStats;
+
+
+
+/*
+ * Memory range from startAddr to endAddr-1
+ */
+typedef struct mem_range {
+ struct mem_range *next;
+ FxU32 startAddr, endAddr;
+}
+tdfxMemRange;
+
+
+typedef struct {
+ GLsizei width, height; /* image size */
+ GLint wScale, hScale; /* scale factors */
+ GrTextureFormat_t glideFormat; /* Glide image format */
+}
+tdfxMipMapLevel;
+
+
+#define TDFX_NUM_TMU 2
+
+
+typedef struct tdfxTexInfo_t
+{
+ GLboolean isInTM;
+ GLboolean reloadImages; /* if true, resend images to Glide */
+ GLuint lastTimeUsed;
+ FxU32 whichTMU;
+
+ GrTexInfo info;
+ GrAspectRatio_t aspectRatio;
+ tdfxMemRange *tm[TDFX_NUM_TMU];
+
+ GLint minLevel, maxLevel;
+ GrTextureFilterMode_t minFilt;
+ GrTextureFilterMode_t magFilt;
+ GrTextureClampMode_t sClamp;
+ GrTextureClampMode_t tClamp;
+ FxBool LODblend;
+ GrMipMapMode_t mmMode;
+
+ GLfloat sScale, tScale; /* texcoord scale factor */
+
+ GrTexTable_t paltype;
+ GuTexPalette palette;
+
+ GLboolean padded;
+}
+tdfxTexInfo;
+
+
+#define TDFX_TEXTURE_DATA(mesaObj) ((tdfxTexInfo *)((mesaObj)->DriverData))
+
+#define TDFX_TEXIMAGE_DATA(mesaImg) ((tdfxMipMapLevel *)((mesaImg)->DriverData))
+
+
+
+/*
+ * This is state which may be shared by several tdfx contexts.
+ * It hangs off of Mesa's gl_shared_state object (ctx->Shared->DriverData).
+ */
+struct tdfxSharedState {
+ GLboolean umaTexMemory;
+ GLuint totalTexMem[TDFX_NUM_TMU]; /* constant */
+ GLuint freeTexMem[TDFX_NUM_TMU]; /* changes as we go */
+ tdfxMemRange *tmPool;
+ tdfxMemRange *tmFree[TDFX_NUM_TMU];
+};
+
+
+
+/* ================================================================
+ * The vertex structures.
+ */
+/* The size of this union is not of relevence:
+ */
+typedef struct tdfx_vertex_t {
+ GLfloat x, y, z; /* Coordinates in screen space */
+ GLfloat rhw; /* Reciprocal homogeneous w */
+ GLubyte color[4]; /* Diffuse color */
+ GLfloat fog;
+ GLfloat tu0, tv0; /* Texture 0 coordinates */
+ GLfloat tu1, tv1; /* Texture 1 coordinates */
+ GLfloat tq0, tq1; /* Texture 0/1 q coords */
+ unsigned char pspec[4]; /* B, G, R, A [0..255] */
+ float psize; /* point size */
+ long pad[16 - 14]; /* ensure 64b structure */
+} tdfxVertex, *tdfxVertexPtr;
+
+
+/* ================================================================
+ *
+ * We want to keep a mirror of the Glide function call parameters so we
+ * can avoid updating our state too often.
+ *
+ * Each of these broad groups will typically have a new state flag
+ * associated with it, and will be updated together. The individual
+ * Glide function calls each have a dirty flag and will only be called
+ * when absolutely necessary.
+ */
+
+/* for grTexSource() */
+struct tdfx_texsource {
+ FxU32 StartAddress;
+ FxU32 EvenOdd;
+ GrTexInfo *Info;
+};
+
+/* Texture object params */
+struct tdfx_texparams {
+ GrTextureClampMode_t sClamp;
+ GrTextureClampMode_t tClamp;
+ GrTextureFilterMode_t minFilt;
+ GrTextureFilterMode_t magFilt;
+ GrMipMapMode_t mmMode;
+ FxBool LODblend;
+ GLfloat LodBias;
+};
+
+/* for grTexDownloadTable() texture palettes */
+struct tdfx_texpalette {
+ GrTexTable_t Type;
+ void *Data;
+};
+
+/* for Voodoo3/Banshee's grColorCombine() and grAlphaCombine() */
+struct tdfx_combine {
+ GrCombineFunction_t Function; /* Combine function */
+ GrCombineFactor_t Factor; /* Combine scale factor */
+ GrCombineLocal_t Local; /* Local combine source */
+ GrCombineOther_t Other; /* Other combine source */
+ FxBool Invert; /* Combine result inversion flag */
+};
+
+/* for Voodoo3's grTexCombine() */
+struct tdfx_texcombine {
+ GrCombineFunction_t FunctionRGB;
+ GrCombineFactor_t FactorRGB;
+ GrCombineFunction_t FunctionAlpha;
+ GrCombineFactor_t FactorAlpha;
+ FxBool InvertRGB;
+ FxBool InvertAlpha;
+};
+
+
+/* for Voodoo5's grColorCombineExt() */
+struct tdfx_combine_color_ext {
+ GrCCUColor_t SourceA;
+ GrCombineMode_t ModeA;
+ GrCCUColor_t SourceB;
+ GrCombineMode_t ModeB;
+ GrCCUColor_t SourceC;
+ FxBool InvertC;
+ GrCCUColor_t SourceD;
+ FxBool InvertD;
+ FxU32 Shift;
+ FxBool Invert;
+};
+
+/* for Voodoo5's grAlphaCombineExt() */
+struct tdfx_combine_alpha_ext {
+ GrACUColor_t SourceA;
+ GrCombineMode_t ModeA;
+ GrACUColor_t SourceB;
+ GrCombineMode_t ModeB;
+ GrACUColor_t SourceC;
+ FxBool InvertC;
+ GrACUColor_t SourceD;
+ FxBool InvertD;
+ FxU32 Shift;
+ FxBool Invert;
+};
+
+/* for Voodoo5's grTexColorCombineExt() */
+struct tdfx_color_texenv {
+ GrTCCUColor_t SourceA;
+ GrCombineMode_t ModeA;
+ GrTCCUColor_t SourceB;
+ GrCombineMode_t ModeB;
+ GrTCCUColor_t SourceC;
+ FxBool InvertC;
+ GrTCCUColor_t SourceD;
+ FxBool InvertD;
+ FxU32 Shift;
+ FxBool Invert;
+};
+
+/* for Voodoo5's grTexAlphaCombineExt() */
+struct tdfx_alpha_texenv {
+ GrTACUColor_t SourceA;
+ GrCombineMode_t ModeA;
+ GrTACUColor_t SourceB;
+ GrCombineMode_t ModeB;
+ GrTACUColor_t SourceC;
+ FxBool InvertC;
+ GrTCCUColor_t SourceD;
+ FxBool InvertD;
+ FxU32 Shift;
+ FxBool Invert;
+};
+
+/* Voodoo5's texture combine environment */
+struct tdfx_texcombine_ext {
+ struct tdfx_alpha_texenv Alpha;
+ struct tdfx_color_texenv Color;
+ GrColor_t EnvColor;
+};
+
+/* Used to track changes between Glide's state and Mesa's */
+struct tdfx_texstate {
+ GLuint Enabled[2]; /* values ala ctx->Texture.Unit[i]._ReallyEnabled */
+ GLenum EnvMode[TDFX_NUM_TMU]; /* index is Glide index, not OpenGL */
+ GLenum TexFormat[TDFX_NUM_TMU]; /* index is Glide index, not OpenGL */
+};
+
+struct tdfx_color {
+ GrColor_t ClearColor; /* Buffer clear color value */
+ GrAlpha_t ClearAlpha; /* Buffer clear alpha value */
+ FxBool ColorMask[4]; /* Per-channel write enable flags */
+
+ GrColor_t MonoColor; /* Constant color value */
+
+ /* Alpha testing */
+ GrCmpFnc_t AlphaFunc; /* Alpha test function */
+ GrAlpha_t AlphaRef; /* Alpha ref value in range [0,255] */
+
+ /* Blending */
+ GrAlphaBlendFnc_t BlendSrcRGB; /* Blend source RGB factor */
+ GrAlphaBlendFnc_t BlendDstRGB; /* Blend destination RGB factor */
+ GrAlphaBlendOp_t BlendEqRGB; /* Blend source RGB op */
+ GrAlphaBlendFnc_t BlendSrcA; /* Blend source alpha factor */
+ GrAlphaBlendFnc_t BlendDstA; /* Blend destination alpha factor */
+ GrAlphaBlendOp_t BlendEqA; /* Blend source alpha op */
+
+ GrDitherMode_t Dither; /* Dither enable */
+};
+
+struct tdfx_depth {
+ GrDepthBufferMode_t Mode; /* Fixed-point Z or floating-point W */
+ FxI32 Bias; /* Polygon offset factor */
+ GrCmpFnc_t Func; /* Depth test function */
+ FxU32 Clear; /* Buffer clear value */
+ FxBool Mask; /* Write enable flag */
+};
+
+struct tdfx_stipple {
+ GrStippleMode_t Mode; /* Stipple enable/disable */
+ FxU32 Pattern; /* 8x4 Stipple Pattern */
+};
+
+struct tdfx_fog {
+ GrFogMode_t Mode; /* Glide fog mode */
+ GrColor_t Color; /* Fog color value */
+ GLenum TableMode; /* GL fog mode currently in table */
+ GrFog_t *Table; /* Fog value table */
+ FxFloat Density; /* Density >= 0 */
+ FxFloat Near; /* Start distance in eye coords */
+ FxFloat Far; /* End distance in eye coords */
+};
+
+struct tdfx_stencil {
+ GrCmpFnc_t Function; /* Stencil function */
+ GrStencil_t RefValue; /* Stencil reference value */
+ GrStencil_t ValueMask; /* Value mask */
+ GrStencil_t WriteMask; /* Write mask */
+ GrStencil_t FailFunc; /* Stencil fail function */
+ GrStencil_t ZFailFunc; /* Stencil pass, depth fail function */
+ GrStencil_t ZPassFunc; /* Stencil pass, depth pass function */
+ GrStencil_t Clear; /* Buffer clear value */
+};
+
+struct tdfx_scissor {
+ FxU32 minX, minY; /* Lower left corner */
+ FxU32 maxX, maxY; /* Upper right corner */
+};
+
+struct tdfx_viewport {
+ GrCoordinateSpaceMode_t Mode; /* Coordinate space */
+ FxI32 X, Y; /* Position */
+ FxI32 Width, Height; /* Size */
+ FxFloat Near, Far; /* Depth buffer range */
+};
+
+struct tdfx_glide {
+ void *State; /* Mirror of internal Glide state */
+ GrContext_t Context; /* Glide context identifier */
+ FxI32 Board; /* Current graphics subsystem */
+ GrColorFormat_t ColorFormat; /* Framebuffer format */
+ GrOriginLocation_t Origin; /* Location of screen space origin */
+
+ FxBool Initialized; /* Glide initialization done? */
+
+ FxI32 SwapInterval; /* SwapBuffers interval */
+ FxI32 MaxPendingSwaps; /* Maximum outstanding SwapBuffers */
+ FxI32 TextureAlign;
+
+ /* Extensions */
+ FxBool HaveCombineExt; /* COMBINE */
+ FxBool HaveCommandTransportExt; /* COMMAND_TRANSPORT */
+ FxBool HaveFogCoordExt; /* FOGCOORD */
+ FxBool HavePixelExt; /* PIXEXT */
+ FxBool HaveTextureBufferExt; /* TEXTUREBUFFER */
+ FxBool HaveTexFmtExt; /* TEXFMT */
+ FxBool HaveTexUMAExt; /* TEXUMA */
+ FxBool HaveMirrorExt; /* MIRROR */
+ FxBool HaveTexus2; /* Texus 2 - FXT1 */
+
+ /* Glide library function pointers */
+ void (*grDrawPoint)( const void *pt );
+ void (*grDrawLine)( const void *v1, const void *v2 );
+ void (*grDrawTriangle)( const void *a, const void *b, const void *c );
+ void (*grVertexLayout)(FxU32 param, FxI32 offset, FxU32 mode);
+ void (*grDrawVertexArray)(FxU32 mode, FxU32 Count, void *pointers);
+ void (*grDrawVertexArrayContiguous)(FxU32 mode, FxU32 Count,
+ void *pointers, FxU32 stride);
+ void (*grBufferClear)( GrColor_t color, GrAlpha_t alpha, FxU32 depth );
+ void (*grBufferSwap)( FxU32 swap_interval );
+ void (*grRenderBuffer)( GrBuffer_t buffer );
+ void (*grErrorSetCallback)( GrErrorCallbackFnc_t fnc );
+ void (*grFinish)(void);
+ void (*grFlush)(void);
+ GrContext_t (*grSstWinOpen)(FxU32 hWnd,
+ GrScreenResolution_t screen_resolution,
+ GrScreenRefresh_t refresh_rate,
+ GrColorFormat_t color_format,
+ GrOriginLocation_t origin_location,
+ int nColBuffers,
+ int nAuxBuffers);
+ void (*grSstWinClose)( GrContext_t context );
+/* Not used */
+#if 0
+ void (*grSetNumPendingBuffers)(FxI32 NumPendingBuffers);
+#endif
+ void (*grSelectContext)( GrContext_t context );
+ void (*grSstOrigin)(GrOriginLocation_t origin);
+ void (*grSstSelect)( int which_sst );
+ void (*grAlphaBlendFunction)(GrAlphaBlendFnc_t rgb_sf,
+ GrAlphaBlendFnc_t rgb_df,
+ GrAlphaBlendFnc_t alpha_sf,
+ GrAlphaBlendFnc_t alpha_df);
+ void (*grAlphaCombine)(GrCombineFunction_t function,
+ GrCombineFactor_t factor,
+ GrCombineLocal_t local, GrCombineOther_t other,
+ FxBool invert);
+ void (*grAlphaControlsITRGBLighting)( FxBool enable );
+ void (*grAlphaTestFunction)( GrCmpFnc_t function );
+ void (*grAlphaTestReferenceValue)( GrAlpha_t value );
+ void (*grChromakeyMode)( GrChromakeyMode_t mode );
+ void (*grChromakeyValue)( GrColor_t value );
+ void (*grClipWindow)( FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy );
+ void (*grColorCombine)( GrCombineFunction_t function,
+ GrCombineFactor_t factor,
+ GrCombineLocal_t local,
+ GrCombineOther_t other,
+ FxBool invert );
+ void (*grColorMask)( FxBool rgb, FxBool a );
+ void (*grCullMode)( GrCullMode_t mode );
+ void (*grConstantColorValue)( GrColor_t value );
+ void (*grDepthBiasLevel)( FxI32 level );
+ void (*grDepthBufferFunction)( GrCmpFnc_t function );
+ void (*grDepthBufferMode)( GrDepthBufferMode_t mode );
+ void (*grDepthMask)( FxBool mask );
+ void (*grDisableAllEffects)( void );
+ void (*grDitherMode)( GrDitherMode_t mode );
+ void (*grFogColorValue)( GrColor_t fogcolor );
+ void (*grFogMode)( GrFogMode_t mode );
+ void (*grFogTable)( const GrFog_t ft[] );
+ void (*grLoadGammaTable)( FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue);
+ void (*grSplash)(float x, float y, float width, float height, FxU32 frame);
+ FxU32 (*grGet)( FxU32 pname, FxU32 plength, FxI32 *params );
+ const char * (*grGetString)( FxU32 pname );
+ FxI32 (*grQueryResolutions)( const GrResolution *resTemplate,
+ GrResolution *output );
+ FxBool (*grReset)( FxU32 what );
+ GrProc (*grGetProcAddress)( char *procName );
+ void (*grEnable)( GrEnableMode_t mode );
+ void (*grDisable)( GrEnableMode_t mode );
+ void (*grCoordinateSpace)( GrCoordinateSpaceMode_t mode );
+ void (*grDepthRange)( FxFloat n, FxFloat f );
+ void (*grStippleMode)( GrStippleMode_t mode );
+ void (*grStipplePattern)( GrStipplePattern_t mode );
+ void (*grViewport)( FxI32 x, FxI32 y, FxI32 width, FxI32 height );
+ FxU32 (*grTexCalcMemRequired)(GrLOD_t lodmin, GrLOD_t lodmax,
+ GrAspectRatio_t aspect, GrTextureFormat_t fmt);
+ FxU32 (*grTexTextureMemRequired)( FxU32 evenOdd, GrTexInfo *info );
+ FxU32 (*grTexMinAddress)( GrChipID_t tmu );
+ FxU32 (*grTexMaxAddress)( GrChipID_t tmu );
+ void (*grTexNCCTable)( GrNCCTable_t table );
+ void (*grTexSource)( GrChipID_t tmu, FxU32 startAddress,
+ FxU32 evenOdd, GrTexInfo *info );
+ void (*grTexClampMode)( GrChipID_t tmu,
+ GrTextureClampMode_t s_clampmode,
+ GrTextureClampMode_t t_clampmode );
+ void (*grTexCombine)( GrChipID_t tmu,
+ GrCombineFunction_t rgb_function,
+ GrCombineFactor_t rgb_factor,
+ GrCombineFunction_t alpha_function,
+ GrCombineFactor_t alpha_factor,
+ FxBool rgb_invert,
+ FxBool alpha_invert);
+ void (*grTexDetailControl)( GrChipID_t tmu, int lod_bias,
+ FxU8 detail_scale, float detail_max );
+ void (*grTexFilterMode)( GrChipID_t tmu,
+ GrTextureFilterMode_t minfilter_mode,
+ GrTextureFilterMode_t magfilter_mode );
+ void (*grTexLodBiasValue)(GrChipID_t tmu, float bias );
+ void (*grTexDownloadMipMap)( GrChipID_t tmu, FxU32 startAddress,
+ FxU32 evenOdd, GrTexInfo *info );
+ void (*grTexDownloadMipMapLevel)( GrChipID_t tmu,
+ FxU32 startAddress,
+ GrLOD_t thisLod,
+ GrLOD_t largeLod,
+ GrAspectRatio_t aspectRatio,
+ GrTextureFormat_t format,
+ FxU32 evenOdd,
+ void *data );
+ FxBool (*grTexDownloadMipMapLevelPartial)( GrChipID_t tmu,
+ FxU32 startAddress,
+ GrLOD_t thisLod,
+ GrLOD_t largeLod,
+ GrAspectRatio_t aspectRatio,
+ GrTextureFormat_t format,
+ FxU32 evenOdd,
+ void *data,
+ int start,
+ int end );
+ void (*grTexDownloadTable)( GrTexTable_t type, void *data );
+ void (*grTexDownloadTablePartial)( GrTexTable_t type,
+ void *data, int start, int end );
+ void (*grTexMipMapMode)( GrChipID_t tmu, GrMipMapMode_t mode,
+ FxBool lodBlend );
+ void (*grTexMultibase)( GrChipID_t tmu, FxBool enable );
+ void (*grTexMultibaseAddress)( GrChipID_t tmu,
+ GrTexBaseRange_t range,
+ FxU32 startAddress,
+ FxU32 evenOdd,
+ GrTexInfo *info );
+ FxBool (*grLfbLock)( GrLock_t type, GrBuffer_t buffer,
+ GrLfbWriteMode_t writeMode,
+ GrOriginLocation_t origin, FxBool pixelPipeline,
+ GrLfbInfo_t *info );
+ FxBool (*grLfbUnlock)( GrLock_t type, GrBuffer_t buffer );
+ void (*grLfbConstantAlpha)( GrAlpha_t alpha );
+ void (*grLfbConstantDepth)( FxU32 depth );
+ void (*grLfbWriteColorSwizzle)(FxBool swizzleBytes, FxBool swapWords);
+ void (*grLfbWriteColorFormat)(GrColorFormat_t colorFormat);
+ FxBool (*grLfbWriteRegion)( GrBuffer_t dst_buffer,
+ FxU32 dst_x, FxU32 dst_y,
+ GrLfbSrcFmt_t src_format,
+ FxU32 src_width, FxU32 src_height,
+ FxBool pixelPipeline,
+ FxI32 src_stride, void *src_data );
+ FxBool (*grLfbReadRegion)( GrBuffer_t src_buffer,
+ FxU32 src_x, FxU32 src_y,
+ FxU32 src_width, FxU32 src_height,
+ FxU32 dst_stride, void *dst_data );
+ void (*grGlideInit)( void );
+ void (*grGlideShutdown)( void );
+ void (*grGlideGetState)( void *state );
+ void (*grGlideSetState)( const void *state );
+ void (*grGlideGetVertexLayout)( void *layout );
+ void (*grGlideSetVertexLayout)( const void *layout );
+ /* Glide utility functions */
+ void (*guFogGenerateExp)( GrFog_t *fogtable, float density );
+ void (*guFogGenerateExp2)( GrFog_t *fogtable, float density );
+ void (*guFogGenerateLinear)(GrFog_t *fogtable, float nearZ, float farZ );
+ /* DRI functions */
+ void (*grDRIOpen)( char *pFB, char *pRegs, int deviceID,
+ int width, int height,
+ int mem, int cpp, int stride,
+ int fifoOffset, int fifoSize,
+ int fbOffset, int backOffset, int depthOffset,
+ int textureOffset, int textureSize,
+ volatile int *fifoPtr, volatile int *fifoRead );
+ void (*grDRIPosition)( int x, int y, int w, int h,
+ int numClip, drm_clip_rect_t *pClip );
+ void (*grDRILostContext)( void );
+ void (*grDRIImportFifo)( int fifoPtr, int fifoRead );
+ void (*grDRIInvalidateAll)( void );
+ void (*grDRIResetSAREA)( void );
+ void (*grDRIBufferSwap)( FxU32 swapInterval );
+ /* Glide extensions */
+ /* PIXEXT extension */
+ void (*grStencilFunc)( GrCmpFnc_t func, GrStencil_t ref, GrStencil_t mask );
+ void (*grStencilMask)( GrStencil_t mask );
+ void (*grStencilOp)( GrStencilOp_t fail, GrStencilOp_t zfail,
+ GrStencilOp_t zpass );
+ void (*grBufferClearExt)( GrColor_t color, GrAlpha_t alpha,
+ FxU32 depth, GrStencil_t stencil );
+ void (*grColorMaskExt)( FxBool r, FxBool g, FxBool b, FxBool a );
+ /* COMBINE extension */
+ void (*grColorCombineExt)( GrCCUColor_t a, GrCombineMode_t a_mode,
+ GrCCUColor_t b, GrCombineMode_t b_mode,
+ GrCCUColor_t c, FxBool c_invert,
+ GrCCUColor_t d, FxBool d_invert,
+ FxU32 shift, FxBool invert );
+ void (*grTexColorCombineExt)( FxU32 tmu,
+ GrTCCUColor_t a, GrCombineMode_t a_mode,
+ GrTCCUColor_t b, GrCombineMode_t b_mode,
+ GrTCCUColor_t c, FxBool c_invert,
+ GrTCCUColor_t d, FxBool d_invert,
+ FxU32 shift, FxBool invert );
+ void (*grAlphaCombineExt)( GrACUColor_t a, GrCombineMode_t a_mode,
+ GrACUColor_t b, GrCombineMode_t b_mode,
+ GrACUColor_t c, FxBool c_invert,
+ GrACUColor_t d, FxBool d_invert,
+ FxU32 shift, FxBool invert );
+ void (*grTexAlphaCombineExt)( FxU32 tmu,
+ GrTACUColor_t a, GrCombineMode_t a_mode,
+ GrTACUColor_t b, GrCombineMode_t b_mode,
+ GrTACUColor_t c, FxBool c_invert,
+ GrTACUColor_t d, FxBool d_invert,
+ FxU32 shift, FxBool invert );
+ void (*grAlphaBlendFunctionExt)( GrAlphaBlendFnc_t rgb_sf,
+ GrAlphaBlendFnc_t rgb_df,
+ GrAlphaBlendOp_t rgb_op,
+ GrAlphaBlendFnc_t alpha_sf,
+ GrAlphaBlendFnc_t alpha_df,
+ GrAlphaBlendOp_t alpha_op );
+ void (*grConstantColorValueExt)( FxU32 tmu, GrColor_t value );
+ /* Texus 2 */
+ void (*txImgQuantize)( void *xxx_unknown_arguments );
+ void (*txImgDequantizeFXT1)( void *txMip, void *pxMip );
+ void (*txErrorSetCallback)( void *fnc );
+};
+
+typedef void (*tdfx_tri_func)( tdfxContextPtr, tdfxVertex *, tdfxVertex *,
+ tdfxVertex * );
+typedef void (*tdfx_line_func)( tdfxContextPtr, tdfxVertex *, tdfxVertex * );
+typedef void (*tdfx_point_func)( tdfxContextPtr, tdfxVertex * );
+
+struct tdfx_context {
+ /* Set once and never changed:
+ */
+ GLcontext *glCtx; /* The core Mesa context */
+
+ GLuint new_gl_state;
+ GLuint new_state;
+ GLuint dirty;
+
+ /* Mirror of hardware state, Glide parameters
+ */
+ GLuint tmu_source[TDFX_NUM_TMU];
+ struct tdfx_texsource TexSource[TDFX_NUM_TMU];
+ struct tdfx_texparams TexParams[TDFX_NUM_TMU];
+ struct tdfx_texpalette TexPalette;
+
+ /* Voodoo3 texture/color combine state */
+ struct tdfx_combine ColorCombine;
+ struct tdfx_combine AlphaCombine;
+ struct tdfx_texcombine TexCombine[TDFX_NUM_TMU];
+
+ /* Voodoo5 texture/color combine state */
+ struct tdfx_combine_color_ext ColorCombineExt;
+ struct tdfx_combine_alpha_ext AlphaCombineExt;
+ struct tdfx_texcombine_ext TexCombineExt[TDFX_NUM_TMU];
+
+ /* Tracks tex state difference between Glide and Mesa */
+ struct tdfx_texstate TexState;
+
+ GrBuffer_t DrawBuffer; /* Current draw buffer */
+ GrBuffer_t ReadBuffer; /* Current read buffer */
+
+ struct tdfx_color Color;
+ struct tdfx_depth Depth;
+ struct tdfx_fog Fog;
+ struct tdfx_stencil Stencil;
+ struct tdfx_scissor Scissor;
+ struct tdfx_viewport Viewport;
+ struct tdfx_stipple Stipple;
+
+ GrCullMode_t CullMode;
+
+ struct tdfx_glide Glide;
+
+ /* Fallback rasterization functions
+ */
+ tdfx_point_func draw_point;
+ tdfx_line_func draw_line;
+ tdfx_tri_func draw_triangle;
+
+
+ /* Variable-size Glide vertex formats
+ */
+ GLuint vertexFormat; /* the current format */
+ void *layout[TDFX_NUM_LAYOUTS];
+ tdfxVertex *verts;
+
+ GLfloat hw_viewport[16];
+
+ GLuint SetupIndex;
+ GLuint SetupNewInputs;
+ GLuint RenderIndex;
+ GLuint Fallback;
+ GLenum render_primitive; /* what GL thinks */
+ GLenum raster_primitive; /* what the hardware thinks */
+
+ GLfloat sScale0, tScale0;
+ GLfloat sScale1, tScale1;
+
+ GLuint texBindNumber;
+ GLint tmuSrc;
+
+ int screen_width;
+ int screen_height;
+
+ GLboolean haveTwoTMUs; /* True if we have 2 tmu's */
+ GLboolean haveHwAlpha;
+ GLboolean haveHwStencil;
+ GLboolean haveHwStipple;
+
+ GLint maxPendingSwapBuffers;
+
+ char rendererString[100];
+
+ /* stuff added for DRI */
+ __DRIscreenPrivate *driScreen;
+ __DRIcontextPrivate *driContext;
+ __DRIdrawablePrivate *driDrawable;
+ drm_context_t hHWContext;
+ drm_hw_lock_t *driHwLock;
+ int driFd;
+ tdfxScreenPrivate *fxScreen;
+ TDFXSAREAPriv *sarea;
+
+
+ /*
+ * Changes during execution:
+ */
+ int width, height; /* size of window */
+ int x_offset; /* distance from window left to screen left */
+ int y_offset; /* distance from window top to screen top */
+ int y_delta; /* distance from window bottom to screen bottom */
+
+ int numClipRects;
+ drm_clip_rect_t *pClipRects;
+ GLboolean scissoredClipRects; /* if true, pClipRects is private storage */
+
+ GuTexPalette glbPalette; /* global texture palette */
+
+ tdfxStats stats;
+
+ /* Configuration cache
+ */
+ driOptionCache optionCache;
+};
+
+#define TDFX_CONTEXT(ctx) ((tdfxContextPtr)((ctx)->DriverCtx))
+
+
+extern GLboolean
+tdfxCreateContext( const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate );
+
+extern void
+tdfxDestroyContext( __DRIcontextPrivate *driContextPriv );
+
+extern GLboolean
+tdfxUnbindContext( __DRIcontextPrivate *driContextPriv );
+
+extern GLboolean
+tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv );
+
+extern GLboolean
+tdfxInitGlide( tdfxContextPtr tmesa );
+
+extern void
+FX_grColorMaskv(GLcontext *ctx, const GLboolean rgba[4]);
+
+extern void
+FX_grColorMaskv_NoLock(GLcontext *ctx, const GLboolean rgba[4]);
+
+
+/* Color packing utilities
+ */
+#define TDFXPACKCOLOR332( r, g, b ) \
+ (((b) & 0xe0) | (((g) & 0xe0) >> 3) | (((r) & 0xc0) >> 6))
+
+#define TDFXPACKCOLOR1555( r, g, b, a ) \
+ ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
+ ((a) ? 0x8000 : 0))
+
+#define TDFXPACKCOLOR565( r, g, b ) \
+ ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
+
+#define TDFXPACKCOLOR888( r, g, b ) \
+ (((b) << 16) | ((g) << 8) | (r))
+
+#define TDFXPACKCOLOR8888( r, g, b, a ) \
+ (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
+
+#define TDFXPACKCOLOR4444( r, g, b, a ) \
+ ((((a) & 0xf0) << 8) | (((b) & 0xf0) << 4) | ((g) & 0xf0) | ((r) >> 4))
+
+static __inline__ GrColor_t tdfxPackColor( GLuint cpp,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a )
+{
+ switch ( cpp ) {
+ case 2:
+ return TDFXPACKCOLOR565( r, g, b );
+ case 4:
+ return TDFXPACKCOLOR8888( r, g, b, a );
+ default:
+ return 0;
+ }
+}
+
+#define DO_DEBUG 1
+#if DO_DEBUG
+extern int TDFX_DEBUG;
+#else
+#define TDFX_DEBUG 0
+#endif
+
+#define DEBUG_ALWAYS_SYNC 0x01
+#define DEBUG_VERBOSE_API 0x02
+#define DEBUG_VERBOSE_DRI 0x04
+#define DEBUG_VERBOSE_FALL 0x08
+
+/* conf */
+#define FX_COMPRESS_S3TC_AS_FXT1_HACK 1
+#define FX_TC_NAPALM 0
+
+#endif /* __TDFX_CONTEXT_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.c
new file mode 100644
index 000000000..02fbace5b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.c
@@ -0,0 +1,322 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_dd.c,v 1.10 2002/10/30 12:52:00 alanh Exp $ */
+
+/*
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ *
+ */
+
+#include "tdfx_context.h"
+#include "tdfx_dd.h"
+#include "tdfx_lock.h"
+#include "tdfx_vb.h"
+#include "tdfx_pixels.h"
+
+#include "context.h"
+#include "enums.h"
+#include "framebuffer.h"
+#include "swrast/swrast.h"
+#if defined(USE_X86_ASM)
+#include "x86/common_x86_asm.h"
+#endif
+
+
+#define TDFX_DATE "20040719"
+
+
+/* These are used in calls to FX_grColorMaskv() */
+const GLboolean false4[4] = { GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE };
+const GLboolean true4[4] = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE };
+
+
+
+/* KW: Put the word Mesa in the render string because quakeworld
+ * checks for this rather than doing a glGet(GL_MAX_TEXTURE_SIZE).
+ * Why?
+ */
+static const GLubyte *tdfxDDGetString( GLcontext *ctx, GLenum name )
+{
+ tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
+
+ switch ( name ) {
+ case GL_RENDERER:
+ {
+ /* The renderer string must be per-context state to handle
+ * multihead correctly.
+ */
+ char *buffer = fxMesa->rendererString;
+ char hardware[100];
+
+ LOCK_HARDWARE(fxMesa);
+ strcpy( hardware, fxMesa->Glide.grGetString(GR_HARDWARE) );
+ UNLOCK_HARDWARE(fxMesa);
+
+ strcpy( buffer, "Mesa DRI " );
+ strcat( buffer, TDFX_DATE );
+ strcat( buffer, " " );
+
+ if ( strcmp( hardware, "Voodoo3 (tm)" ) == 0 ) {
+ strcat( buffer, "Voodoo3" );
+ }
+ else if ( strcmp( hardware, "Voodoo Banshee (tm)" ) == 0 ) {
+ strcat( buffer, "VoodooBanshee" );
+ }
+ else if ( strcmp( hardware, "Voodoo4 (tm)" ) == 0 ) {
+ strcat( buffer, "Voodoo4" );
+ }
+ else if ( strcmp( hardware, "Voodoo5 (tm)" ) == 0 ) {
+ strcat( buffer, "Voodoo5" );
+ }
+ else {
+ /* unexpected result: replace spaces with hyphens */
+ int i;
+ for ( i = 0 ; hardware[i] && i < 60 ; i++ ) {
+ if ( hardware[i] == ' ' || hardware[i] == '\t' )
+ hardware[i] = '-';
+ }
+ strcat( buffer, hardware );
+ }
+
+ /* Append any CPU-specific information.
+ */
+#ifdef USE_X86_ASM
+ if ( _mesa_x86_cpu_features ) {
+ strncat( buffer, " x86", 4 );
+ }
+#endif
+#ifdef USE_MMX_ASM
+ if ( cpu_has_mmx ) {
+ strncat( buffer, "/MMX", 4 );
+ }
+#endif
+#ifdef USE_3DNOW_ASM
+ if ( cpu_has_3dnow ) {
+ strncat( buffer, "/3DNow!", 7 );
+ }
+#endif
+#ifdef USE_SSE_ASM
+ if ( cpu_has_xmm ) {
+ strncat( buffer, "/SSE", 4 );
+ }
+#endif
+ return (const GLubyte *) buffer;
+ }
+ case GL_VENDOR:
+ return (const GLubyte *)"VA Linux Systems, Inc.";
+ default:
+ return NULL;
+ }
+}
+
+
+/* Return uptodate buffer size information.
+ */
+static void tdfxDDGetBufferSize( GLframebuffer *buffer,
+ GLuint *width, GLuint *height )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ LOCK_HARDWARE( fxMesa );
+ *width = fxMesa->width;
+ *height = fxMesa->height;
+ UNLOCK_HARDWARE( fxMesa );
+}
+
+
+
+/*
+ * Return the current value of the occlusion test flag and
+ * reset the flag (hardware counters) to false.
+ */
+static GLboolean get_occlusion_result( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLboolean result;
+
+ LOCK_HARDWARE( fxMesa );
+ fxMesa->Glide.grFinish(); /* required to flush the FIFO - FB 21-01-2002 */
+
+ if (ctx->Depth.OcclusionTest) {
+ if (ctx->OcclusionResult) {
+ result = GL_TRUE; /* result of software rendering */
+ }
+ else {
+ FxI32 zfail, in;
+ fxMesa->Glide.grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL, 4, &zfail);
+ fxMesa->Glide.grGet(GR_STATS_PIXELS_IN, 4, &in);
+ /* Geometry is occluded if there is no input (in == 0) */
+ /* or if all pixels failed the depth test (zfail == in) */
+ /* The < 1 is there because I have empirically seen cases where */
+ /* zfail > in.... go figure. FB - 21-01-2002. */
+ result = ((in - zfail) < 1 || in == 0) ? GL_FALSE : GL_TRUE;
+ }
+ }
+ else {
+ result = ctx->OcclusionResultSaved;
+ }
+
+ /* reset results now */
+ fxMesa->Glide.grReset(GR_STATS_PIXELS);
+ ctx->OcclusionResult = GL_FALSE;
+ ctx->OcclusionResultSaved = GL_FALSE;
+
+ UNLOCK_HARDWARE( fxMesa );
+
+ return result;
+}
+
+
+/*
+ * We're only implementing this function to handle the
+ * GL_OCCLUSTION_TEST_RESULT_HP case. It's special because it
+ * has a side-effect: resetting the occlustion result flag.
+ */
+static GLboolean tdfxDDGetBooleanv( GLcontext *ctx, GLenum pname,
+ GLboolean *result )
+{
+ if ( pname == GL_OCCLUSION_TEST_RESULT_HP ) {
+ *result = get_occlusion_result( ctx );
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+}
+
+static GLboolean tdfxDDGetDoublev( GLcontext *ctx, GLenum pname,
+ GLdouble *result )
+{
+ if ( pname == GL_OCCLUSION_TEST_RESULT_HP ) {
+ *result = (GLdouble) get_occlusion_result( ctx );
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+}
+
+static GLboolean tdfxDDGetFloatv( GLcontext *ctx, GLenum pname,
+ GLfloat *result )
+{
+ if ( pname == GL_OCCLUSION_TEST_RESULT_HP ) {
+ *result = (GLfloat) get_occlusion_result( ctx );
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+}
+
+static GLboolean tdfxDDGetIntegerv( GLcontext *ctx, GLenum pname,
+ GLint *result )
+{
+ if ( pname == GL_OCCLUSION_TEST_RESULT_HP ) {
+ *result = (GLint) get_occlusion_result( ctx );
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+}
+
+
+
+#define VISUAL_EQUALS_RGBA(vis, r, g, b, a) \
+ ((vis->redBits == r) && \
+ (vis->greenBits == g) && \
+ (vis->blueBits == b) && \
+ (vis->alphaBits == a))
+
+void tdfxDDInitDriverFuncs( const __GLcontextModes *visual,
+ struct dd_function_table *functions )
+{
+ if ( MESA_VERBOSE & VERBOSE_DRIVER ) {
+ fprintf( stderr, "tdfx: %s()\n", __FUNCTION__ );
+ }
+
+ functions->GetString = tdfxDDGetString;
+ functions->GetBufferSize = tdfxDDGetBufferSize;
+ functions->ResizeBuffers = _mesa_resize_framebuffer;
+
+ /* Accelerated paths
+ */
+ if ( VISUAL_EQUALS_RGBA(visual, 8, 8, 8, 8) )
+ {
+ functions->DrawPixels = tdfx_drawpixels_R8G8B8A8;
+ functions->ReadPixels = tdfx_readpixels_R8G8B8A8;
+ }
+ else if ( VISUAL_EQUALS_RGBA(visual, 5, 6, 5, 0) )
+ {
+ functions->ReadPixels = tdfx_readpixels_R5G6B5;
+ }
+
+ functions->GetBooleanv = tdfxDDGetBooleanv;
+ functions->GetDoublev = tdfxDDGetDoublev;
+ functions->GetFloatv = tdfxDDGetFloatv;
+ functions->GetIntegerv = tdfxDDGetIntegerv;
+}
+
+
+/*
+ * These are here for lack of a better place.
+ */
+
+void
+FX_grColorMaskv(GLcontext *ctx, const GLboolean rgba[4])
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ LOCK_HARDWARE(fxMesa);
+ if (ctx->Visual.redBits == 8) {
+ /* 32bpp mode */
+ ASSERT( fxMesa->Glide.grColorMaskExt );
+ fxMesa->Glide.grColorMaskExt(rgba[RCOMP], rgba[GCOMP],
+ rgba[BCOMP], rgba[ACOMP]);
+ }
+ else {
+ /* 16 bpp mode */
+ /* we never have an alpha buffer */
+ fxMesa->Glide.grColorMask(rgba[RCOMP] || rgba[GCOMP] || rgba[BCOMP],
+ GL_FALSE);
+ }
+ UNLOCK_HARDWARE(fxMesa);
+}
+
+void
+FX_grColorMaskv_NoLock(GLcontext *ctx, const GLboolean rgba[4])
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ if (ctx->Visual.redBits == 8) {
+ /* 32bpp mode */
+ ASSERT( fxMesa->Glide.grColorMaskExt );
+ fxMesa->Glide.grColorMaskExt(rgba[RCOMP], rgba[GCOMP],
+ rgba[BCOMP], rgba[ACOMP]);
+ }
+ else {
+ /* 16 bpp mode */
+ /* we never have an alpha buffer */
+ fxMesa->Glide.grColorMask(rgba[RCOMP] || rgba[GCOMP] || rgba[BCOMP],
+ GL_FALSE);
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.h
new file mode 100644
index 000000000..5ceba9d5f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_dd.h
@@ -0,0 +1,45 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_dd.h,v 1.1 2001/03/21 16:14:27 dawes Exp $ */
+
+/*
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#ifndef __TDFX_DD_H__
+#define __TDFX_DD_H__
+
+#include "context.h"
+
+extern void tdfxDDInitDriverFuncs( const __GLcontextModes *visual,
+ struct dd_function_table *functions );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_glide.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_glide.h
new file mode 100644
index 000000000..f077aa678
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_glide.h
@@ -0,0 +1,606 @@
+/*
+ * This file defines macros and types necessary for accessing glide3.
+ */
+
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_glide.h,v 1.1 2002/02/22 21:45:03 dawes Exp $ */
+
+#ifndef NEWGLIDE_H
+#define NEWGLIDE_H
+
+#define FX_CALL
+
+typedef unsigned char FxU8;
+typedef signed char FxI8;
+typedef unsigned short FxU16;
+typedef signed short FxI16;
+#if defined(__alpha__) || defined (__LP64__)
+typedef signed int FxI32;
+typedef unsigned int FxU32;
+#else
+typedef signed long FxI32;
+typedef unsigned long FxU32;
+#endif
+typedef unsigned long AnyPtr;
+typedef int FxBool;
+typedef float FxFloat;
+typedef double FxDouble;
+
+typedef unsigned long FxColor_t;
+typedef struct
+{
+ float r, g, b, a;
+}
+FxColor4;
+
+typedef FxU32 GrColor_t;
+typedef FxU8 GrAlpha_t;
+typedef FxU32 GrMipMapId_t;
+typedef FxU32 GrStipplePattern_t;
+typedef FxU8 GrFog_t;
+typedef FxU32 GrContext_t;
+typedef int (FX_CALL * GrProc) (void);
+
+#define FXTRUE 1
+#define FXFALSE 0
+
+#define FXBIT(i) (1L << (i))
+
+#define GR_NULL_MIPMAP_HANDLE ((GrMipMapId_t) -1)
+
+#define GR_MIPMAPLEVELMASK_EVEN FXBIT(0)
+#define GR_MIPMAPLEVELMASK_ODD FXBIT(1)
+#define GR_MIPMAPLEVELMASK_BOTH (GR_MIPMAPLEVELMASK_EVEN | GR_MIPMAPLEVELMASK_ODD )
+
+typedef FxI32 GrChipID_t;
+#define GR_TMU0 0x0
+#define GR_TMU1 0x1
+#define GR_TMU2 0x2
+
+#define GR_FBI 0x0
+
+typedef FxI32 GrCombineFunction_t;
+#define GR_COMBINE_FUNCTION_ZERO 0x0
+#define GR_COMBINE_FUNCTION_NONE GR_COMBINE_FUNCTION_ZERO
+#define GR_COMBINE_FUNCTION_LOCAL 0x1
+#define GR_COMBINE_FUNCTION_LOCAL_ALPHA 0x2
+#define GR_COMBINE_FUNCTION_SCALE_OTHER 0x3
+#define GR_COMBINE_FUNCTION_BLEND_OTHER GR_COMBINE_FUNCTION_SCALE_OTHER
+#define GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL 0x4
+#define GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL_ALPHA 0x5
+#define GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL 0x6
+#define GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL 0x7
+#define GR_COMBINE_FUNCTION_BLEND GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL
+#define GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL_ALPHA 0x8
+#define GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL 0x9
+#define GR_COMBINE_FUNCTION_BLEND_LOCAL GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL
+#define GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL_ALPHA 0x10
+
+typedef FxI32 GrCombineFactor_t;
+#define GR_COMBINE_FACTOR_ZERO 0x0
+#define GR_COMBINE_FACTOR_NONE GR_COMBINE_FACTOR_ZERO
+#define GR_COMBINE_FACTOR_LOCAL 0x1
+#define GR_COMBINE_FACTOR_OTHER_ALPHA 0x2
+#define GR_COMBINE_FACTOR_LOCAL_ALPHA 0x3
+#define GR_COMBINE_FACTOR_TEXTURE_ALPHA 0x4
+#define GR_COMBINE_FACTOR_TEXTURE_RGB 0x5
+#define GR_COMBINE_FACTOR_DETAIL_FACTOR GR_COMBINE_FACTOR_TEXTURE_ALPHA
+#define GR_COMBINE_FACTOR_LOD_FRACTION 0x5
+#define GR_COMBINE_FACTOR_ONE 0x8
+#define GR_COMBINE_FACTOR_ONE_MINUS_LOCAL 0x9
+#define GR_COMBINE_FACTOR_ONE_MINUS_OTHER_ALPHA 0xa
+#define GR_COMBINE_FACTOR_ONE_MINUS_LOCAL_ALPHA 0xb
+#define GR_COMBINE_FACTOR_ONE_MINUS_TEXTURE_ALPHA 0xc
+#define GR_COMBINE_FACTOR_ONE_MINUS_DETAIL_FACTOR GR_COMBINE_FACTOR_ONE_MINUS_TEXTURE_ALPHA
+#define GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION 0xd
+
+typedef FxI32 GrCombineLocal_t;
+#define GR_COMBINE_LOCAL_ITERATED 0x0
+#define GR_COMBINE_LOCAL_CONSTANT 0x1
+#define GR_COMBINE_LOCAL_NONE GR_COMBINE_LOCAL_CONSTANT
+#define GR_COMBINE_LOCAL_DEPTH 0x2
+
+typedef FxI32 GrCombineOther_t;
+#define GR_COMBINE_OTHER_ITERATED 0x0
+#define GR_COMBINE_OTHER_TEXTURE 0x1
+#define GR_COMBINE_OTHER_CONSTANT 0x2
+#define GR_COMBINE_OTHER_NONE GR_COMBINE_OTHER_CONSTANT
+
+typedef FxI32 GrAlphaSource_t;
+#define GR_ALPHASOURCE_CC_ALPHA 0x0
+#define GR_ALPHASOURCE_ITERATED_ALPHA 0x1
+#define GR_ALPHASOURCE_TEXTURE_ALPHA 0x2
+#define GR_ALPHASOURCE_TEXTURE_ALPHA_TIMES_ITERATED_ALPHA 0x3
+
+typedef FxI32 GrColorCombineFnc_t;
+#define GR_COLORCOMBINE_ZERO 0x0
+#define GR_COLORCOMBINE_CCRGB 0x1
+#define GR_COLORCOMBINE_ITRGB 0x2
+#define GR_COLORCOMBINE_ITRGB_DELTA0 0x3
+#define GR_COLORCOMBINE_DECAL_TEXTURE 0x4
+#define GR_COLORCOMBINE_TEXTURE_TIMES_CCRGB 0x5
+#define GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB 0x6
+#define GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB_DELTA0 0x7
+#define GR_COLORCOMBINE_TEXTURE_TIMES_ITRGB_ADD_ALPHA 0x8
+#define GR_COLORCOMBINE_TEXTURE_TIMES_ALPHA 0x9
+#define GR_COLORCOMBINE_TEXTURE_TIMES_ALPHA_ADD_ITRGB 0xa
+#define GR_COLORCOMBINE_TEXTURE_ADD_ITRGB 0xb
+#define GR_COLORCOMBINE_TEXTURE_SUB_ITRGB 0xc
+#define GR_COLORCOMBINE_CCRGB_BLEND_ITRGB_ON_TEXALPHA 0xd
+#define GR_COLORCOMBINE_DIFF_SPEC_A 0xe
+#define GR_COLORCOMBINE_DIFF_SPEC_B 0xf
+#define GR_COLORCOMBINE_ONE 0x10
+
+typedef FxI32 GrAlphaBlendFnc_t;
+#define GR_BLEND_ZERO 0x0
+#define GR_BLEND_SRC_ALPHA 0x1
+#define GR_BLEND_SRC_COLOR 0x2
+#define GR_BLEND_DST_COLOR GR_BLEND_SRC_COLOR
+#define GR_BLEND_DST_ALPHA 0x3
+#define GR_BLEND_ONE 0x4
+#define GR_BLEND_ONE_MINUS_SRC_ALPHA 0x5
+#define GR_BLEND_ONE_MINUS_SRC_COLOR 0x6
+#define GR_BLEND_ONE_MINUS_DST_COLOR GR_BLEND_ONE_MINUS_SRC_COLOR
+#define GR_BLEND_ONE_MINUS_DST_ALPHA 0x7
+#define GR_BLEND_RESERVED_8 0x8
+#define GR_BLEND_RESERVED_9 0x9
+#define GR_BLEND_RESERVED_A 0xa
+#define GR_BLEND_RESERVED_B 0xb
+#define GR_BLEND_RESERVED_C 0xc
+#define GR_BLEND_RESERVED_D 0xd
+#define GR_BLEND_RESERVED_E 0xe
+#define GR_BLEND_ALPHA_SATURATE 0xf
+#define GR_BLEND_PREFOG_COLOR GR_BLEND_ALPHA_SATURATE
+#define GR_BLEND_SAME_COLOR_EXT 0x08
+#define GR_BLEND_ONE_MINUS_SAME_COLOR_EXT 0x09
+
+typedef FxI32 GrAspectRatio_t;
+#define GR_ASPECT_LOG2_8x1 3
+#define GR_ASPECT_LOG2_4x1 2
+#define GR_ASPECT_LOG2_2x1 1
+#define GR_ASPECT_LOG2_1x1 0
+#define GR_ASPECT_LOG2_1x2 -1
+#define GR_ASPECT_LOG2_1x4 -2
+#define GR_ASPECT_LOG2_1x8 -3
+
+typedef FxI32 GrBuffer_t;
+#define GR_BUFFER_FRONTBUFFER 0x0
+#define GR_BUFFER_BACKBUFFER 0x1
+#define GR_BUFFER_AUXBUFFER 0x2
+#define GR_BUFFER_DEPTHBUFFER 0x3
+#define GR_BUFFER_ALPHABUFFER 0x4
+#define GR_BUFFER_TRIPLEBUFFER 0x5
+
+typedef FxI32 GrChromakeyMode_t;
+#define GR_CHROMAKEY_DISABLE 0x0
+#define GR_CHROMAKEY_ENABLE 0x1
+
+typedef FxI32 GrChromaRangeMode_t;
+#define GR_CHROMARANGE_RGB_ALL_EXT 0x0
+
+#define GR_CHROMARANGE_DISABLE_EXT 0x00
+#define GR_CHROMARANGE_ENABLE_EXT 0x01
+
+typedef FxI32 GrTexChromakeyMode_t;
+#define GR_TEXCHROMA_DISABLE_EXT 0x0
+#define GR_TEXCHROMA_ENABLE_EXT 0x1
+
+#define GR_TEXCHROMARANGE_RGB_ALL_EXT 0x0
+
+typedef FxI32 GrCmpFnc_t;
+#define GR_CMP_NEVER 0x0
+#define GR_CMP_LESS 0x1
+#define GR_CMP_EQUAL 0x2
+#define GR_CMP_LEQUAL 0x3
+#define GR_CMP_GREATER 0x4
+#define GR_CMP_NOTEQUAL 0x5
+#define GR_CMP_GEQUAL 0x6
+#define GR_CMP_ALWAYS 0x7
+
+typedef FxI32 GrColorFormat_t;
+#define GR_COLORFORMAT_ARGB 0x0
+#define GR_COLORFORMAT_ABGR 0x1
+
+#define GR_COLORFORMAT_RGBA 0x2
+#define GR_COLORFORMAT_BGRA 0x3
+
+typedef FxI32 GrCullMode_t;
+#define GR_CULL_DISABLE 0x0
+#define GR_CULL_NEGATIVE 0x1
+#define GR_CULL_POSITIVE 0x2
+
+typedef FxI32 GrDepthBufferMode_t;
+#define GR_DEPTHBUFFER_DISABLE 0x0
+#define GR_DEPTHBUFFER_ZBUFFER 0x1
+#define GR_DEPTHBUFFER_WBUFFER 0x2
+#define GR_DEPTHBUFFER_ZBUFFER_COMPARE_TO_BIAS 0x3
+#define GR_DEPTHBUFFER_WBUFFER_COMPARE_TO_BIAS 0x4
+
+typedef FxI32 GrDitherMode_t;
+#define GR_DITHER_DISABLE 0x0
+#define GR_DITHER_2x2 0x1
+#define GR_DITHER_4x4 0x2
+
+typedef FxI32 GrStippleMode_t;
+#define GR_STIPPLE_DISABLE 0x0
+#define GR_STIPPLE_PATTERN 0x1
+#define GR_STIPPLE_ROTATE 0x2
+
+typedef FxI32 GrFogMode_t;
+#define GR_FOG_DISABLE 0x0
+#define GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT 0x1
+#define GR_FOG_WITH_TABLE_ON_Q 0x2
+#define GR_FOG_WITH_TABLE_ON_W GR_FOG_WITH_TABLE_ON_Q
+#define GR_FOG_WITH_ITERATED_Z 0x3
+#define GR_FOG_WITH_ITERATED_ALPHA_EXT 0x4
+#define GR_FOG_MULT2 0x100
+#define GR_FOG_ADD2 0x200
+
+typedef FxU32 GrLock_t;
+#define GR_LFB_READ_ONLY 0x00
+#define GR_LFB_WRITE_ONLY 0x01
+#define GR_LFB_IDLE 0x00
+#define GR_LFB_NOIDLE 0x10
+
+typedef FxI32 GrLfbBypassMode_t;
+#define GR_LFBBYPASS_DISABLE 0x0
+#define GR_LFBBYPASS_ENABLE 0x1
+
+typedef FxI32 GrLfbWriteMode_t;
+#define GR_LFBWRITEMODE_565 0x0
+#define GR_LFBWRITEMODE_555 0x1
+#define GR_LFBWRITEMODE_1555 0x2
+#define GR_LFBWRITEMODE_RESERVED1 0x3
+#define GR_LFBWRITEMODE_888 0x4
+#define GR_LFBWRITEMODE_8888 0x5
+#define GR_LFBWRITEMODE_RESERVED2 0x6
+#define GR_LFBWRITEMODE_RESERVED3 0x7
+#define GR_LFBWRITEMODE_RESERVED4 0x8
+#define GR_LFBWRITEMODE_RESERVED5 0x9
+#define GR_LFBWRITEMODE_RESERVED6 0xa
+#define GR_LFBWRITEMODE_RESERVED7 0xb
+#define GR_LFBWRITEMODE_565_DEPTH 0xc
+#define GR_LFBWRITEMODE_555_DEPTH 0xd
+#define GR_LFBWRITEMODE_1555_DEPTH 0xe
+#define GR_LFBWRITEMODE_ZA16 0xf
+#define GR_LFBWRITEMODE_ANY 0xFF
+
+typedef FxI32 GrOriginLocation_t;
+#define GR_ORIGIN_UPPER_LEFT 0x0
+#define GR_ORIGIN_LOWER_LEFT 0x1
+#define GR_ORIGIN_ANY 0xFF
+
+typedef struct
+{
+ int size;
+ void *lfbPtr;
+ FxU32 strideInBytes;
+ GrLfbWriteMode_t writeMode;
+ GrOriginLocation_t origin;
+}
+GrLfbInfo_t;
+
+typedef FxI32 GrLOD_t;
+#define GR_LOD_LOG2_2048 0xb
+#define GR_LOD_LOG2_1024 0xa
+#define GR_LOD_LOG2_512 0x9
+#define GR_LOD_LOG2_256 0x8
+#define GR_LOD_LOG2_128 0x7
+#define GR_LOD_LOG2_64 0x6
+#define GR_LOD_LOG2_32 0x5
+#define GR_LOD_LOG2_16 0x4
+#define GR_LOD_LOG2_8 0x3
+#define GR_LOD_LOG2_4 0x2
+#define GR_LOD_LOG2_2 0x1
+#define GR_LOD_LOG2_1 0x0
+
+typedef FxI32 GrMipMapMode_t;
+#define GR_MIPMAP_DISABLE 0x0
+#define GR_MIPMAP_NEAREST 0x1
+#define GR_MIPMAP_NEAREST_DITHER 0x2
+
+typedef FxI32 GrSmoothingMode_t;
+#define GR_SMOOTHING_DISABLE 0x0
+#define GR_SMOOTHING_ENABLE 0x1
+
+typedef FxI32 GrTextureClampMode_t;
+#define GR_TEXTURECLAMP_WRAP 0x0
+#define GR_TEXTURECLAMP_CLAMP 0x1
+#define GR_TEXTURECLAMP_MIRROR_EXT 0x2
+
+typedef FxI32 GrTextureCombineFnc_t;
+#define GR_TEXTURECOMBINE_ZERO 0x0
+#define GR_TEXTURECOMBINE_DECAL 0x1
+#define GR_TEXTURECOMBINE_OTHER 0x2
+#define GR_TEXTURECOMBINE_ADD 0x3
+#define GR_TEXTURECOMBINE_MULTIPLY 0x4
+#define GR_TEXTURECOMBINE_SUBTRACT 0x5
+#define GR_TEXTURECOMBINE_DETAIL 0x6
+#define GR_TEXTURECOMBINE_DETAIL_OTHER 0x7
+#define GR_TEXTURECOMBINE_TRILINEAR_ODD 0x8
+#define GR_TEXTURECOMBINE_TRILINEAR_EVEN 0x9
+#define GR_TEXTURECOMBINE_ONE 0xa
+
+typedef FxI32 GrTextureFilterMode_t;
+#define GR_TEXTUREFILTER_POINT_SAMPLED 0x0
+#define GR_TEXTUREFILTER_BILINEAR 0x1
+
+typedef FxI32 GrTextureFormat_t;
+#define GR_TEXFMT_8BIT 0x0
+#define GR_TEXFMT_RGB_332 GR_TEXFMT_8BIT
+#define GR_TEXFMT_YIQ_422 0x1
+#define GR_TEXFMT_ALPHA_8 0x2
+#define GR_TEXFMT_INTENSITY_8 0x3
+#define GR_TEXFMT_ALPHA_INTENSITY_44 0x4
+#define GR_TEXFMT_P_8 0x5
+#define GR_TEXFMT_RSVD0 0x6
+#define GR_TEXFMT_RSVD1 0x7
+#define GR_TEXFMT_16BIT 0x8
+#define GR_TEXFMT_ARGB_8332 GR_TEXFMT_16BIT
+#define GR_TEXFMT_AYIQ_8422 0x9
+#define GR_TEXFMT_RGB_565 0xa
+#define GR_TEXFMT_ARGB_1555 0xb
+#define GR_TEXFMT_ARGB_4444 0xc
+#define GR_TEXFMT_ALPHA_INTENSITY_88 0xd
+#define GR_TEXFMT_AP_88 0xe
+#define GR_TEXFMT_RSVD2 0xf
+#define GR_TEXFMT_ARGB_CMP_FXT1 0x11
+#define GR_TEXFMT_ARGB_8888 0x12
+#define GR_TEXFMT_YUYV_422 0x13
+#define GR_TEXFMT_UYVY_422 0x14
+#define GR_TEXFMT_AYUV_444 0x15
+#define GR_TEXFMT_ARGB_CMP_DXT1 0x16
+#define GR_TEXFMT_ARGB_CMP_DXT2 0x17
+#define GR_TEXFMT_ARGB_CMP_DXT3 0x18
+#define GR_TEXFMT_ARGB_CMP_DXT4 0x19
+#define GR_TEXFMT_ARGB_CMP_DXT5 0x1A
+
+typedef FxU32 GrTexTable_t;
+#define GR_TEXTABLE_NCC0 0x0
+#define GR_TEXTABLE_NCC1 0x1
+#define GR_TEXTABLE_PALETTE 0x2
+#define GR_TEXTABLE_PALETTE_6666_EXT 0x3
+
+typedef FxU32 GrNCCTable_t;
+#define GR_NCCTABLE_NCC0 0x0
+#define GR_NCCTABLE_NCC1 0x1
+
+typedef FxU32 GrTexBaseRange_t;
+#define GR_TEXBASE_256 0x3
+#define GR_TEXBASE_128 0x2
+#define GR_TEXBASE_64 0x1
+#define GR_TEXBASE_32_TO_1 0x0
+#define GR_TEXBASE_2048 0x7
+#define GR_TEXBASE_1024 0x6
+#define GR_TEXBASE_512 0x5
+#define GR_TEXBASE_256_TO_1 0x4
+
+typedef FxU32 GrEnableMode_t;
+#define GR_MODE_DISABLE 0x0
+#define GR_MODE_ENABLE 0x1
+
+#define GR_AA_ORDERED 0x01
+#define GR_ALLOW_MIPMAP_DITHER 0x02
+#define GR_PASSTHRU 0x03
+#define GR_SHAMELESS_PLUG 0x04
+#define GR_VIDEO_SMOOTHING 0x05
+
+typedef FxU32 GrCoordinateSpaceMode_t;
+#define GR_WINDOW_COORDS 0x00
+#define GR_CLIP_COORDS 0x01
+
+/* Parameters for strips */
+#define GR_PARAM_XY 0x01
+#define GR_PARAM_Z 0x02
+#define GR_PARAM_W 0x03
+#define GR_PARAM_Q 0x04
+#define GR_PARAM_FOG_EXT 0x05
+
+#define GR_PARAM_A 0x10
+
+#define GR_PARAM_RGB 0x20
+
+#define GR_PARAM_PARGB 0x30
+
+#define GR_PARAM_ST0 0x40
+#define GR_PARAM_ST1 GR_PARAM_ST0+1
+#define GR_PARAM_ST2 GR_PARAM_ST0+2
+
+#define GR_PARAM_Q0 0x50
+#define GR_PARAM_Q1 GR_PARAM_Q0+1
+#define GR_PARAM_Q2 GR_PARAM_Q0+2
+
+#define GR_PARAM_DISABLE 0x00
+#define GR_PARAM_ENABLE 0x01
+
+/* grDrawVertexArray/grDrawVertexArrayContiguous */
+#define GR_POINTS 0
+#define GR_LINE_STRIP 1
+#define GR_LINES 2
+#define GR_POLYGON 3
+#define GR_TRIANGLE_STRIP 4
+#define GR_TRIANGLE_FAN 5
+#define GR_TRIANGLES 6
+#define GR_TRIANGLE_STRIP_CONTINUE 7
+#define GR_TRIANGLE_FAN_CONTINUE 8
+
+/* grGet/grReset */
+#define GR_BITS_DEPTH 0x01
+#define GR_BITS_RGBA 0x02
+#define GR_FIFO_FULLNESS 0x03
+#define GR_FOG_TABLE_ENTRIES 0x04
+#define GR_GAMMA_TABLE_ENTRIES 0x05
+#define GR_GLIDE_STATE_SIZE 0x06
+#define GR_GLIDE_VERTEXLAYOUT_SIZE 0x07
+#define GR_IS_BUSY 0x08
+#define GR_LFB_PIXEL_PIPE 0x09
+#define GR_MAX_TEXTURE_SIZE 0x0a
+#define GR_MAX_TEXTURE_ASPECT_RATIO 0x0b
+#define GR_MEMORY_FB 0x0c
+#define GR_MEMORY_TMU 0x0d
+#define GR_MEMORY_UMA 0x0e
+#define GR_NUM_BOARDS 0x0f
+#define GR_NON_POWER_OF_TWO_TEXTURES 0x10
+#define GR_NUM_FB 0x11
+#define GR_NUM_SWAP_HISTORY_BUFFER 0x12
+#define GR_NUM_TMU 0x13
+#define GR_PENDING_BUFFERSWAPS 0x14
+#define GR_REVISION_FB 0x15
+#define GR_REVISION_TMU 0x16
+#define GR_STATS_LINES 0x17
+#define GR_STATS_PIXELS_AFUNC_FAIL 0x18
+#define GR_STATS_PIXELS_CHROMA_FAIL 0x19
+#define GR_STATS_PIXELS_DEPTHFUNC_FAIL 0x1a
+#define GR_STATS_PIXELS_IN 0x1b
+#define GR_STATS_PIXELS_OUT 0x1c
+#define GR_STATS_PIXELS 0x1d
+#define GR_STATS_POINTS 0x1e
+#define GR_STATS_TRIANGLES_IN 0x1f
+#define GR_STATS_TRIANGLES_OUT 0x20
+#define GR_STATS_TRIANGLES 0x21
+#define GR_SWAP_HISTORY 0x22
+#define GR_SUPPORTS_PASSTHRU 0x23
+#define GR_TEXTURE_ALIGN 0x24
+#define GR_VIDEO_POSITION 0x25
+#define GR_VIEWPORT 0x26
+#define GR_WDEPTH_MIN_MAX 0x27
+#define GR_ZDEPTH_MIN_MAX 0x28
+#define GR_VERTEX_PARAMETER 0x29
+#define GR_BITS_GAMMA 0x2a
+#define GR_GET_RESERVED_1 0x1000
+
+/* grGetString types */
+#define GR_EXTENSION 0xa0
+#define GR_HARDWARE 0xa1
+#define GR_RENDERER 0xa2
+#define GR_VENDOR 0xa3
+#define GR_VERSION 0xa4
+
+typedef FxI32 GrScreenRefresh_t;
+#define GR_REFRESH_NONE 0xff
+
+typedef FxI32 GrScreenResolution_t;
+#define GR_RESOLUTION_NONE 0xff
+
+typedef struct
+{
+ GrLOD_t smallLodLog2;
+ GrLOD_t largeLodLog2;
+ GrAspectRatio_t aspectRatioLog2;
+ GrTextureFormat_t format;
+ void *data;
+}
+GrTexInfo;
+
+typedef struct GrSstPerfStats_s
+{
+ FxU32 pixelsIn;
+ FxU32 chromaFail;
+ FxU32 zFuncFail;
+ FxU32 aFuncFail;
+ FxU32 pixelsOut;
+}
+GrSstPerfStats_t;
+
+typedef struct
+{
+ GrScreenResolution_t resolution;
+ GrScreenRefresh_t refresh;
+ int numColorBuffers;
+ int numAuxBuffers;
+}
+GrResolution;
+
+typedef GrResolution GlideResolution;
+#define GR_QUERY_ANY ((FxU32)(~0))
+
+typedef FxU32 GrLfbSrcFmt_t;
+#define GR_LFB_SRC_FMT_565 0x00
+#define GR_LFB_SRC_FMT_555 0x01
+#define GR_LFB_SRC_FMT_1555 0x02
+#define GR_LFB_SRC_FMT_888 0x04
+#define GR_LFB_SRC_FMT_8888 0x05
+#define GR_LFB_SRC_FMT_565_DEPTH 0x0c
+#define GR_LFB_SRC_FMT_555_DEPTH 0x0d
+#define GR_LFB_SRC_FMT_1555_DEPTH 0x0e
+#define GR_LFB_SRC_FMT_ZA16 0x0f
+#define GR_LFB_SRC_FMT_RLE16 0x80
+
+typedef FxU32 GrPixelFormat_t;
+#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
+
+#define GR_LFBWRITEMODE_Z32 0x0008
+
+typedef FxU32 GrAAMode_t;
+#define GR_AA_NONE 0x0000
+#define GR_AA_4SAMPLES 0x0001
+
+typedef FxU8 GrStencil_t;
+
+typedef FxU32 GrStencilOp_t;
+#define GR_STENCILOP_KEEP 0x00
+#define GR_STENCILOP_ZERO 0x01
+#define GR_STENCILOP_REPLACE 0x02
+#define GR_STENCILOP_INCR_CLAMP 0x03
+#define GR_STENCILOP_DECR_CLAMP 0x04
+#define GR_STENCILOP_INVERT 0x05
+#define GR_STENCILOP_INCR_WRAP 0x06
+#define GR_STENCILOP_DECR_WRAP 0x07
+
+#define GR_TEXTURE_UMA_EXT 0x06
+#define GR_STENCIL_MODE_EXT 0x07
+#define GR_OPENGL_MODE_EXT 0x08
+
+typedef FxU32 GrCCUColor_t;
+typedef FxU32 GrACUColor_t;
+typedef FxU32 GrTCCUColor_t;
+typedef FxU32 GrTACUColor_t;
+#define GR_CMBX_ZERO 0x00
+#define GR_CMBX_TEXTURE_ALPHA 0x01
+#define GR_CMBX_ALOCAL 0x02
+#define GR_CMBX_AOTHER 0x03
+#define GR_CMBX_B 0x04
+#define GR_CMBX_CONSTANT_ALPHA 0x05
+#define GR_CMBX_CONSTANT_COLOR 0x06
+#define GR_CMBX_DETAIL_FACTOR 0x07
+#define GR_CMBX_ITALPHA 0x08
+#define GR_CMBX_ITRGB 0x09
+#define GR_CMBX_LOCAL_TEXTURE_ALPHA 0x0a
+#define GR_CMBX_LOCAL_TEXTURE_RGB 0x0b
+#define GR_CMBX_LOD_FRAC 0x0c
+#define GR_CMBX_OTHER_TEXTURE_ALPHA 0x0d
+#define GR_CMBX_OTHER_TEXTURE_RGB 0x0e
+#define GR_CMBX_TEXTURE_RGB 0x0f
+#define GR_CMBX_TMU_CALPHA 0x10
+#define GR_CMBX_TMU_CCOLOR 0x11
+
+typedef FxU32 GrCombineMode_t;
+#define GR_FUNC_MODE_ZERO 0x00
+#define GR_FUNC_MODE_X 0x01
+#define GR_FUNC_MODE_ONE_MINUS_X 0x02
+#define GR_FUNC_MODE_NEGATIVE_X 0x03
+#define GR_FUNC_MODE_X_MINUS_HALF 0x04
+
+typedef FxU32 GrAlphaBlendOp_t;
+#define GR_BLEND_OP_ADD 0x00
+#define GR_BLEND_OP_SUB 0x01
+#define GR_BLEND_OP_REVSUB 0x02
+
+typedef struct
+{
+ FxU32 data[256];
+}
+GuTexPalette;
+
+typedef void (*GrErrorCallbackFnc_t) (const char *string, FxBool fatal);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.c
new file mode 100644
index 000000000..6bbfb8d3a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.c
@@ -0,0 +1,90 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.c,v 1.5 2002/12/16 16:19:00 dawes Exp $ */
+
+/*
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#include "tdfx_context.h"
+#include "tdfx_lock.h"
+#include "tdfx_state.h"
+#include "tdfx_render.h"
+#include "tdfx_texman.h"
+#include "tdfx_tris.h"
+
+
+void tdfxGetLock( tdfxContextPtr fxMesa )
+{
+ __DRIcontextPrivate *cPriv = fxMesa->driContext;
+ __DRIdrawablePrivate *dPriv = cPriv->driDrawablePriv;
+ __DRIscreenPrivate *sPriv = dPriv->driScreenPriv;
+ TDFXSAREAPriv *saPriv = (TDFXSAREAPriv *) (((char *) sPriv->pSAREA) +
+ fxMesa->fxScreen->sarea_priv_offset);
+ unsigned int stamp = dPriv->lastStamp;
+
+ drmGetLock( fxMesa->driFd, fxMesa->hHWContext, 0 );
+
+ /* This macro will update dPriv's cliprects if needed */
+ DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
+
+ if ( saPriv->fifoOwner != fxMesa->hHWContext ) {
+ fxMesa->Glide.grDRIImportFifo( saPriv->fifoPtr, saPriv->fifoRead );
+ }
+
+ if ( saPriv->ctxOwner != fxMesa->hHWContext ) {
+ /* This sequence looks a little odd. Glide mirrors the state, and
+ * when you get the state you are forcing the mirror to be up to
+ * date, and then getting a copy from the mirror. You can then force
+ * that state onto the hardware when you set the state.
+ */
+ void *state;
+ FxI32 stateSize;
+ fxMesa->Glide.grGet(GR_GLIDE_STATE_SIZE, 4, &stateSize);
+ state = malloc(stateSize);
+ fxMesa->Glide.grGlideGetState( state );
+ fxMesa->Glide.grGlideSetState( state );
+ free( state );
+ }
+
+#if 0
+ if ( saPriv->texOwner != fxMesa->hHWContext ) {
+ tdfxTMRestoreTextures_NoLock( fxMesa );
+ }
+#endif
+
+ if ( *dPriv->pStamp != stamp || saPriv->ctxOwner != fxMesa->hHWContext ) {
+ tdfxUpdateClipping(fxMesa->glCtx);
+ tdfxUploadClipping(fxMesa);
+ }
+
+ DEBUG_LOCK();
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.h
new file mode 100644
index 000000000..616e65b2a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_lock.h
@@ -0,0 +1,144 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_lock.h,v 1.3 2002/02/22 21:45:03 dawes Exp $ */
+
+/*
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#ifndef __TDFX_LOCK_H__
+#define __TDFX_LOCK_H__
+
+/* You can turn this on to find locking conflicts.
+ */
+#define DEBUG_LOCKING 0
+
+#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 /* DEBUG_LOCKING */
+
+
+extern void tdfxGetLock( tdfxContextPtr fxMesa );
+
+
+/* !!! 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 !!! */
+
+#define DRM_LIGHT_LOCK_RETURN(fd,lock,context,__ret) \
+ do { \
+ DRM_CAS(lock,context,DRM_LOCK_HELD|context,__ret); \
+ if (__ret) drmGetLock(fd,context,0); \
+ } while(0)
+
+#define LOCK_HARDWARE( fxMesa ) \
+ do { \
+ char __ret = 0; \
+ \
+ DEBUG_CHECK_LOCK(); \
+ DRM_CAS( fxMesa->driHwLock, fxMesa->hHWContext, \
+ DRM_LOCK_HELD | fxMesa->hHWContext, __ret ); \
+ if ( __ret ) { \
+ tdfxGetLock( fxMesa ); \
+ } \
+ DEBUG_LOCK(); \
+ } while (0)
+
+/* Unlock the hardware using the global current context */
+#define UNLOCK_HARDWARE( fxMesa ) \
+ do { \
+ DRM_UNLOCK( fxMesa->driFd, fxMesa->driHwLock, fxMesa->hHWContext ); \
+ DEBUG_RESET(); \
+ } while (0)
+
+/*
+ * This pair of macros makes a loop over the drawing operations
+ * so it is not self contained and doesn't have the nice single
+ * statement semantics of most macros.
+ */
+#define BEGIN_CLIP_LOOP(fxMesa) \
+ do { \
+ LOCK_HARDWARE( fxMesa ); \
+ BEGIN_CLIP_LOOP_LOCKED( fxMesa )
+
+#define BEGIN_CLIP_LOOP_LOCKED(fxMesa) \
+ do { \
+ int _nc = fxMesa->numClipRects; \
+ while (_nc--) { \
+ if (fxMesa->numClipRects > 1) { \
+ int _height = fxMesa->screen_height; \
+ fxMesa->Glide.grClipWindow(fxMesa->pClipRects[_nc].x1, \
+ _height - fxMesa->pClipRects[_nc].y2, \
+ fxMesa->pClipRects[_nc].x2, \
+ _height - fxMesa->pClipRects[_nc].y1); \
+ }
+
+
+#define END_CLIP_LOOP_LOCKED( fxMesa ) \
+ } \
+ } while (0)
+
+#define END_CLIP_LOOP( fxMesa ) \
+ END_CLIP_LOOP_LOCKED( fxMesa ); \
+ UNLOCK_HARDWARE( fxMesa ); \
+ } while (0)
+
+#endif /* __TDFX_LOCK_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.c
new file mode 100644
index 000000000..6592ecccf
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.c
@@ -0,0 +1,689 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.c,v 1.4 2002/02/22 21:45:03 dawes Exp $ */
+
+/*
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ * Nathan Hand <nhand@valinux.com>
+ *
+ */
+
+#include "tdfx_context.h"
+#include "tdfx_dd.h"
+#include "tdfx_lock.h"
+#include "tdfx_vb.h"
+#include "tdfx_pixels.h"
+#include "tdfx_render.h"
+
+#include "swrast/swrast.h"
+
+#include "image.h"
+
+
+#define FX_grLfbWriteRegion(fxMesa,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
+ do { \
+ LOCK_HARDWARE(fxMesa); \
+ fxMesa->Glide.grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,FXFALSE,src_stride,src_data); \
+ UNLOCK_HARDWARE(fxMesa); \
+ } while(0)
+
+
+#define FX_grLfbReadRegion(fxMesa,src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data) \
+ do { \
+ LOCK_HARDWARE(fxMesa); \
+ fxMesa->Glide.grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data); \
+ UNLOCK_HARDWARE(fxMesa); \
+ } while (0);
+
+
+#if 0
+static FxBool
+FX_grLfbLock(tdfxContextPtr fxMesa, GrLock_t type, GrBuffer_t buffer,
+ GrLfbWriteMode_t writeMode, GrOriginLocation_t origin,
+ FxBool pixelPipeline, GrLfbInfo_t * info)
+{
+ FxBool result;
+
+ LOCK_HARDWARE(fxMesa);
+ result = fxMesa->Glide.grLfbLock(type, buffer, writeMode, origin, pixelPipeline, info);
+ UNLOCK_HARDWARE(fxMesa);
+ return result;
+}
+#endif
+
+
+#define FX_grLfbUnlock(fxMesa, t, b) \
+ do { \
+ LOCK_HARDWARE(fxMesa); \
+ fxMesa->Glide.grLfbUnlock(t, b); \
+ UNLOCK_HARDWARE(fxMesa); \
+ } while (0)
+
+
+
+#if 0
+/* test if window coord (px,py) is visible */
+static GLboolean
+inClipRects(tdfxContextPtr fxMesa, int px, int py)
+{
+ int i;
+ for (i = 0; i < fxMesa->numClipRects; i++) {
+ if ((px >= fxMesa->pClipRects[i].x1) &&
+ (px < fxMesa->pClipRects[i].x2) &&
+ (py >= fxMesa->pClipRects[i].y1) &&
+ (py < fxMesa->pClipRects[i].y2)) return GL_TRUE;
+ }
+ return GL_FALSE;
+}
+#endif
+
+/* test if rectangle of pixels (px,py) (px+width,py+height) is visible */
+static GLboolean
+inClipRects_Region(tdfxContextPtr fxMesa, int x, int y, int width, int height)
+{
+ int i;
+ int x1, y1, x2, y2;
+ int xmin, xmax, ymin, ymax, pixelsleft;
+
+ y1 = y - height + 1; y2 = y;
+ x1 = x; x2 = x + width - 1;
+ pixelsleft = width * height;
+
+ for (i = 0; i < fxMesa->numClipRects; i++)
+ {
+ /* algorithm requires x1 < x2 and y1 < y2 */
+ if ((fxMesa->pClipRects[i].x1 < fxMesa->pClipRects[i].x2)) {
+ xmin = fxMesa->pClipRects[i].x1;
+ xmax = fxMesa->pClipRects[i].x2-1;
+ } else {
+ xmin = fxMesa->pClipRects[i].x2;
+ xmax = fxMesa->pClipRects[i].x1-1;
+ }
+ if ((fxMesa->pClipRects[i].y1 < fxMesa->pClipRects[i].y2)) {
+ ymin = fxMesa->pClipRects[i].y1;
+ ymax = fxMesa->pClipRects[i].y2-1;
+ } else {
+ ymin = fxMesa->pClipRects[i].y2;
+ ymax = fxMesa->pClipRects[i].y1-1;
+ }
+
+ /* reject trivial cases */
+ if (xmax < x1) continue;
+ if (ymax < y1) continue;
+ if (xmin > x2) continue;
+ if (ymin > y2) continue;
+
+ /* find the intersection */
+ if (xmin < x1) xmin = x1;
+ if (ymin < y1) ymin = y1;
+ if (xmax > x2) xmax = x2;
+ if (ymax > y2) ymax = y2;
+
+ pixelsleft -= (xmax-xmin+1) * (ymax-ymin+1);
+ }
+
+ return pixelsleft == 0;
+}
+
+#if 0
+GLboolean
+tdfx_bitmap_R5G6B5(GLcontext * ctx, GLint px, GLint py,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte * bitmap)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ TdfxU16 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 |
+ 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->bgrOrder) {
+ color = (TdfxU16)
+ (((TdfxU16) 0xf8 & b) << (11 - 3)) |
+ (((TdfxU16) 0xfc & g) << (5 - 3 + 1)) |
+ (((TdfxU16) 0xf8 & r) >> 3);
+ }
+ else
+ color = (TdfxU16)
+ (((TdfxU16) 0xf8 & r) << (11 - 3)) |
+ (((TdfxU16) 0xfc & g) << (5 - 3 + 1)) |
+ (((TdfxU16) 0xf8 & b) >> 3);
+ }
+
+ info.size = sizeof(info);
+ if (!TDFX_grLfbLock(fxMesa,
+ GR_LFB_WRITE_ONLY,
+ fxMesa->currentFB,
+ GR_LFBWRITEMODE_565,
+ GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+#ifndef TDFX_SILENT
+ fprintf(stderr, "tdfx Driver: error locking the linear frame buffer\n");
+#endif
+ return GL_TRUE;
+ }
+
+ {
+ const GLint winX = fxMesa->x_offset;
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ /* The dest stride depends on the hardware and whether we're drawing
+ * to the front or back buffer. This compile-time test seems to do
+ * the job for now.
+ */
+ const GLint dstStride = (fxMesa->glCtx->Color.DrawBuffer[0] == GL_FRONT)
+ ? (fxMesa->screen_width) : (info.strideInBytes / 2);
+ GLint row;
+ /* compute dest address of bottom-left pixel in bitmap */
+ GLushort *dst = (GLushort *) info.lfbPtr
+ + (winY - py) * dstStride + (winX + px);
+
+ for (row = 0; row < height; row++) {
+ const GLubyte *src =
+ (const GLubyte *) _mesa_image_address2d(finalUnpack,
+ bitmap, width, height,
+ GL_COLOR_INDEX,
+ GL_BITMAP, 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 (inClipRects(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 (inClipRects(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;
+ }
+ }
+
+ TDFX_grLfbUnlock(fxMesa, GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+ return GL_TRUE;
+}
+#endif
+
+#if 0
+GLboolean
+tdfx_bitmap_R8G8B8A8(GLcontext * ctx, GLint px, GLint py,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte * bitmap)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ 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 |
+ 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);
+ color = PACK_BGRA32(r, g, b, a);
+ }
+
+ info.size = sizeof(info);
+ if (!TDFX_grLfbLock(fxMesa, GR_LFB_WRITE_ONLY,
+ fxMesa->currentFB, GR_LFBWRITEMODE_8888,
+ GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+#ifndef TDFX_SILENT
+ fprintf(stderr, "tdfx Driver: error locking the linear frame buffer\n");
+#endif
+ return GL_TRUE;
+ }
+
+ {
+ 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[0] == 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_address2d(finalUnpack,
+ bitmap, width, height,
+ GL_COLOR_INDEX,
+ GL_BITMAP, 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 (inClipRects(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 (inClipRects(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;
+ }
+ }
+
+ TDFX_grLfbUnlock(fxMesa, GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+ return GL_TRUE;
+}
+#endif
+
+void
+tdfx_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 (format != GL_RGB ||
+ type != GL_UNSIGNED_SHORT_5_6_5 ||
+ (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT|
+ IMAGE_MAP_COLOR_BIT)))
+ {
+ _swrast_ReadPixels( ctx, x, y, width, height, format, type, packing,
+ dstImage );
+ return;
+ }
+
+ {
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GrLfbInfo_t info;
+
+ const GLint winX = fxMesa->x_offset;
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ const GLint scrX = winX + x;
+ const GLint scrY = winY - y;
+
+ LOCK_HARDWARE( fxMesa );
+ info.size = sizeof(info);
+ if (fxMesa->Glide.grLfbLock(GR_LFB_READ_ONLY,
+ fxMesa->ReadBuffer,
+ GR_LFBWRITEMODE_ANY,
+ GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+ const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer[0] ==
+ GL_FRONT) ? (fxMesa->screen_width) : (info.strideInBytes / 2);
+ const GLushort *src = (const GLushort *) info.lfbPtr
+ + scrY * srcStride + scrX;
+ GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing,
+ dstImage, width, height, format, type, 0, 0);
+ const GLint dstStride = _mesa_image_row_stride(packing,
+ width, format, type);
+
+ /* 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;
+ }
+
+ fxMesa->Glide.grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->ReadBuffer);
+ }
+ UNLOCK_HARDWARE( fxMesa );
+ return;
+ }
+}
+
+void
+tdfx_readpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ GLvoid * dstImage)
+{
+ if ((!(format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8) &&
+ !(format == GL_BGRA && type == GL_UNSIGNED_BYTE)) ||
+ (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT|
+ IMAGE_MAP_COLOR_BIT)))
+ {
+ _swrast_ReadPixels( ctx, x, y, width, height, format, type, packing,
+ dstImage );
+ return;
+ }
+
+
+ {
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GrLfbInfo_t info;
+
+ const GLint winX = fxMesa->x_offset;
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ const GLint scrX = winX + x;
+ const GLint scrY = winY - y;
+
+ LOCK_HARDWARE(fxMesa);
+ info.size = sizeof(info);
+ if (fxMesa->Glide.grLfbLock(GR_LFB_READ_ONLY,
+ fxMesa->ReadBuffer,
+ GR_LFBWRITEMODE_ANY,
+ GR_ORIGIN_UPPER_LEFT, FXFALSE, &info))
+ {
+ const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer[0] == GL_FRONT)
+ ? (fxMesa->screen_width) : (info.strideInBytes / 4);
+ const GLuint *src = (const GLuint *) info.lfbPtr
+ + scrY * srcStride + scrX;
+ const GLint dstStride =
+ _mesa_image_row_stride(packing, width, format, type);
+ GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing,
+ dstImage, width, height, format, type, 0, 0);
+ const GLint widthInBytes = width * 4;
+
+ {
+ GLint row;
+ for (row = 0; row < height; row++) {
+ MEMCPY(dst, src, widthInBytes);
+ dst += dstStride;
+ src -= srcStride;
+ }
+ }
+
+ fxMesa->Glide.grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->ReadBuffer);
+ }
+ UNLOCK_HARDWARE(fxMesa);
+ }
+}
+
+void
+tdfx_drawpixels_R8G8B8A8(GLcontext * ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid * pixels)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ if ((!(format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8) &&
+ !(format == GL_BGRA && type == GL_UNSIGNED_BYTE)) ||
+ ctx->Pixel.ZoomX != 1.0F ||
+ ctx->Pixel.ZoomY != 1.0F ||
+ (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT|
+ IMAGE_MAP_COLOR_BIT)) ||
+ ctx->Color.AlphaEnabled ||
+ ctx->Depth.Test ||
+ ctx->Fog.Enabled ||
+ ctx->Scissor.Enabled ||
+ ctx->Stencil.Enabled ||
+ !ctx->Color.ColorMask[0] ||
+ !ctx->Color.ColorMask[1] ||
+ !ctx->Color.ColorMask[2] ||
+ !ctx->Color.ColorMask[3] ||
+ ctx->Color.ColorLogicOpEnabled ||
+ ctx->Texture._EnabledUnits ||
+ ctx->Depth.OcclusionTest ||
+ fxMesa->Fallback)
+ {
+ _swrast_DrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels );
+ return;
+ }
+
+ {
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ GLboolean result = GL_FALSE;
+
+ const GLint winX = fxMesa->x_offset;
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ const GLint scrX = winX + x;
+ const GLint scrY = winY - y;
+
+ /* lock early to make sure cliprects are right */
+ LOCK_HARDWARE(fxMesa);
+
+ /* make sure hardware has latest blend funcs */
+ if (ctx->Color.BlendEnabled) {
+ fxMesa->dirty |= TDFX_UPLOAD_BLEND_FUNC;
+ tdfxEmitHwStateLocked( fxMesa );
+ }
+
+ /* look for clipmasks, giveup if region obscured */
+ if (fxMesa->glCtx->Color.DrawBuffer[0] == GL_FRONT) {
+ if (!inClipRects_Region(fxMesa, scrX, scrY, width, height)) {
+ UNLOCK_HARDWARE(fxMesa);
+ _swrast_DrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels );
+ return;
+ }
+ }
+
+ info.size = sizeof(info);
+ if (fxMesa->Glide.grLfbLock(GR_LFB_WRITE_ONLY,
+ fxMesa->DrawBuffer,
+ GR_LFBWRITEMODE_8888,
+ GR_ORIGIN_UPPER_LEFT, FXTRUE, &info))
+ {
+ const GLint dstStride = (fxMesa->glCtx->Color.DrawBuffer[0] == GL_FRONT)
+ ? (fxMesa->screen_width * 4) : (info.strideInBytes);
+ GLubyte *dst = (GLubyte *) info.lfbPtr
+ + scrY * dstStride + scrX * 4;
+ const GLint srcStride =
+ _mesa_image_row_stride(unpack, width, format, type);
+ const GLubyte *src = (GLubyte *) _mesa_image_address2d(unpack,
+ pixels, width, height, format, type, 0, 0);
+ const GLint widthInBytes = width * 4;
+
+ if ((format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8) ||
+ (format == GL_BGRA && type == GL_UNSIGNED_BYTE)) {
+ GLint row;
+ for (row = 0; row < height; row++) {
+ MEMCPY(dst, src, widthInBytes);
+ dst -= dstStride;
+ src += srcStride;
+ }
+ result = GL_TRUE;
+ }
+
+ fxMesa->Glide.grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->DrawBuffer);
+ }
+ UNLOCK_HARDWARE(fxMesa);
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.h
new file mode 100644
index 000000000..c38ce070c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_pixels.h
@@ -0,0 +1,77 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_pixels.h,v 1.2 2002/02/22 21:45:03 dawes Exp $ */
+
+/*
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ * Nathan Hand <nhand@valinux.com>
+ *
+ */
+
+#ifndef __TDFX_PIXELS_H__
+#define __TDFX_PIXELS_H__
+
+#include "context.h"
+
+extern void
+tdfx_bitmap_R5G6B5( GLcontext *ctx, GLint px, GLint py,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap );
+
+extern void
+tdfx_bitmap_R8G8B8A8( GLcontext *ctx, GLint px, GLint py,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap );
+
+extern void
+tdfx_readpixels_R5G6B5( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ GLvoid *dstImage );
+
+extern void
+tdfx_readpixels_R8G8B8A8( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ GLvoid *dstImage );
+
+extern void
+tdfx_drawpixels_R8G8B8A8( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.c
new file mode 100644
index 000000000..56f5f147e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.c
@@ -0,0 +1,808 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_render.c,v 1.4 2002/02/22 21:45:03 dawes Exp $ */
+
+/*
+ * New fixes:
+ * Daniel Borca <dborca@users.sourceforge.net>, 19 Jul 2004
+ *
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ *
+ */
+
+#include "tdfx_context.h"
+#include "tdfx_render.h"
+#include "tdfx_state.h"
+#include "tdfx_texman.h"
+#include "swrast/swrast.h"
+
+/* Clear the color and/or depth buffers.
+ */
+static void tdfxClear( GLcontext *ctx,
+ GLbitfield mask, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height )
+{
+ tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
+ GLbitfield softwareMask = mask & (BUFFER_BIT_ACCUM);
+ const GLuint stencil_size =
+ fxMesa->haveHwStencil ? fxMesa->glCtx->Visual.stencilBits : 0;
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s( %d, %d, %d, %d )\n",
+ __FUNCTION__, (int) x, (int) y, (int) width, (int) height );
+ }
+
+ /* Need this check to respond to glScissor and clipping updates */
+ if ((fxMesa->new_state & (TDFX_NEW_CLIP | TDFX_NEW_DEPTH)) ||
+ (fxMesa->dirty & TDFX_UPLOAD_COLOR_MASK)) {
+ tdfxDDUpdateHwState(ctx);
+ }
+
+ /* we can't clear accum buffers */
+ mask &= ~(BUFFER_BIT_ACCUM);
+
+ if (mask & BUFFER_BIT_STENCIL) {
+ if (!fxMesa->haveHwStencil || ctx->Stencil.WriteMask[0] != 0xff) {
+ /* Napalm seems to have trouble with stencil write masks != 0xff */
+ /* do stencil clear in software */
+ mask &= ~(BUFFER_BIT_STENCIL);
+ softwareMask |= BUFFER_BIT_STENCIL;
+ }
+ }
+
+ if (fxMesa->glCtx->Visual.redBits != 8) {
+ /* can only do color masking if running in 24/32bpp on Napalm */
+ if (ctx->Color.ColorMask[RCOMP] != ctx->Color.ColorMask[GCOMP] ||
+ ctx->Color.ColorMask[GCOMP] != ctx->Color.ColorMask[BCOMP]) {
+ softwareMask |= (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT));
+ mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT);
+ }
+ }
+
+ if (fxMesa->haveHwStencil) {
+ /*
+ * If we want to clear stencil, it must be enabled
+ * in the HW, even if the stencil test is not enabled
+ * in the OGL state.
+ */
+ LOCK_HARDWARE(fxMesa);
+ if (mask & BUFFER_BIT_STENCIL) {
+ fxMesa->Glide.grStencilMask(/*ctx->Stencil.WriteMask*/ 0xff);
+ /* set stencil ref value = desired clear value */
+ fxMesa->Glide.grStencilFunc(GR_CMP_ALWAYS,
+ fxMesa->Stencil.Clear, 0xff);
+ fxMesa->Glide.grStencilOp(GR_STENCILOP_REPLACE,
+ GR_STENCILOP_REPLACE, GR_STENCILOP_REPLACE);
+ fxMesa->Glide.grEnable(GR_STENCIL_MODE_EXT);
+ }
+ else {
+ fxMesa->Glide.grDisable(GR_STENCIL_MODE_EXT);
+ }
+ UNLOCK_HARDWARE(fxMesa);
+ }
+
+ /*
+ * This may be ugly, but it's needed in order to work around a number
+ * of Glide bugs.
+ */
+ BEGIN_CLIP_LOOP(fxMesa);
+ {
+ /*
+ * This could probably be done fancier but doing each possible case
+ * explicitly is less error prone.
+ */
+ switch (mask & ~BUFFER_BIT_STENCIL) {
+ case BUFFER_BIT_BACK_LEFT | BUFFER_BIT_DEPTH:
+ /* back buffer & depth */
+ FX_grColorMaskv_NoLock(ctx, true4); /* work around Voodoo3 bug */
+ fxMesa->Glide.grDepthMask(FXTRUE);
+ fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER);
+ if (stencil_size > 0) {
+ fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear,
+ (FxU32) ctx->Stencil.Clear);
+ }
+ else
+ fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear);
+ if (!ctx->Depth.Mask || !ctx->Depth.Test) {
+ fxMesa->Glide.grDepthMask(FXFALSE);
+ }
+ break;
+ case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_DEPTH:
+ /* XXX it appears that the depth buffer isn't cleared when
+ * glRenderBuffer(GR_BUFFER_FRONTBUFFER) is set.
+ * This is a work-around/
+ */
+ /* clear depth */
+ fxMesa->Glide.grDepthMask(FXTRUE);
+ fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER);
+ FX_grColorMaskv_NoLock(ctx, false4);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear,
+ (FxU32) ctx->Stencil.Clear);
+ else
+ fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear);
+ /* clear front */
+ FX_grColorMaskv_NoLock(ctx, true4);
+ fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear,
+ (FxU32) ctx->Stencil.Clear);
+ else
+ fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear);
+ if (!ctx->Depth.Mask || !ctx->Depth.Test) {
+ fxMesa->Glide.grDepthMask(FXFALSE);
+ }
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ /* back buffer only */
+ fxMesa->Glide.grDepthMask(FXFALSE);
+ fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear,
+ (FxU32) ctx->Stencil.Clear);
+ else
+ fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear);
+ if (ctx->Depth.Mask && ctx->Depth.Test) {
+ fxMesa->Glide.grDepthMask(FXTRUE);
+ }
+ break;
+ case BUFFER_BIT_FRONT_LEFT:
+ /* front buffer only */
+ fxMesa->Glide.grDepthMask(FXFALSE);
+ fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear,
+ (FxU32) ctx->Stencil.Clear);
+ else
+ fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear);
+ if (ctx->Depth.Mask && ctx->Depth.Test) {
+ fxMesa->Glide.grDepthMask(FXTRUE);
+ }
+ break;
+ case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT:
+ /* front and back */
+ fxMesa->Glide.grDepthMask(FXFALSE);
+ fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear,
+ (FxU32) ctx->Stencil.Clear);
+ else
+ fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear);
+ fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear,
+ (FxU32) ctx->Stencil.Clear);
+ else
+ fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear);
+ if (ctx->Depth.Mask && ctx->Depth.Test) {
+ fxMesa->Glide.grDepthMask(FXTRUE);
+ }
+ break;
+ case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT | BUFFER_BIT_DEPTH:
+ /* clear front */
+ fxMesa->Glide.grDepthMask(FXFALSE);
+ fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear,
+ (FxU32) ctx->Stencil.Clear);
+ else
+ fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear);
+ /* clear back and depth */
+ fxMesa->Glide.grDepthMask(FXTRUE);
+ fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear,
+ (FxU32) ctx->Stencil.Clear);
+ else
+ fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear);
+ if (!ctx->Depth.Mask || !ctx->Depth.Mask) {
+ fxMesa->Glide.grDepthMask(FXFALSE);
+ }
+ break;
+ case BUFFER_BIT_DEPTH:
+ /* just the depth buffer */
+ fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER);
+ FX_grColorMaskv_NoLock(ctx, false4);
+ fxMesa->Glide.grDepthMask(FXTRUE);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear,
+ (FxU32) ctx->Stencil.Clear);
+ else
+ fxMesa->Glide.grBufferClear(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear);
+ FX_grColorMaskv_NoLock(ctx, true4);
+ if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT)
+ fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER);
+ if (!ctx->Depth.Test || !ctx->Depth.Mask)
+ fxMesa->Glide.grDepthMask(FXFALSE);
+ break;
+ default:
+ /* clear no color buffers or depth buffer but might clear stencil */
+ if (stencil_size > 0 && (mask & BUFFER_BIT_STENCIL)) {
+ /* XXX need this RenderBuffer call to work around Glide bug */
+ fxMesa->Glide.grRenderBuffer(GR_BUFFER_BACKBUFFER);
+ fxMesa->Glide.grDepthMask(FXFALSE);
+ FX_grColorMaskv_NoLock(ctx, false4);
+ fxMesa->Glide.grBufferClearExt(fxMesa->Color.ClearColor,
+ fxMesa->Color.ClearAlpha,
+ fxMesa->Depth.Clear,
+ (FxU32) ctx->Stencil.Clear);
+ if (ctx->Depth.Mask && ctx->Depth.Test) {
+ fxMesa->Glide.grDepthMask(FXTRUE);
+ }
+ FX_grColorMaskv_NoLock(ctx, true4);
+ if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT)
+ fxMesa->Glide.grRenderBuffer(GR_BUFFER_FRONTBUFFER);
+ }
+ }
+ }
+ END_CLIP_LOOP(fxMesa);
+
+ if (fxMesa->haveHwStencil && (mask & BUFFER_BIT_STENCIL)) {
+ /* We changed the stencil state above. Signal that we need to
+ * upload it again.
+ */
+ fxMesa->dirty |= TDFX_UPLOAD_STENCIL;
+ }
+
+ if (softwareMask)
+ _swrast_Clear( ctx, softwareMask, all, x, y, width, height );
+}
+
+
+
+static void tdfxFinish( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ FLUSH_BATCH( fxMesa );
+
+ LOCK_HARDWARE( fxMesa );
+ fxMesa->Glide.grFinish();
+ UNLOCK_HARDWARE( fxMesa );
+}
+
+static void tdfxFlush( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ FLUSH_BATCH( fxMesa );
+
+ LOCK_HARDWARE( fxMesa );
+ fxMesa->Glide.grFlush();
+ UNLOCK_HARDWARE( fxMesa );
+}
+
+
+#if 0
+static const char *texSource(int k)
+{
+ switch (k) {
+ case GR_CMBX_ZERO:
+ return "GR_CMBX_ZERO";
+ case GR_CMBX_TEXTURE_ALPHA:
+ return "GR_CMBX_TEXTURE_ALPHA";
+ case GR_CMBX_ALOCAL:
+ return "GR_CMBX_ALOCAL";
+ case GR_CMBX_AOTHER:
+ return "GR_CMBX_AOTHER";
+ case GR_CMBX_B:
+ return "GR_CMBX_B";
+ case GR_CMBX_CONSTANT_ALPHA:
+ return "GR_CMBX_CONSTANT_ALPHA";
+ case GR_CMBX_CONSTANT_COLOR:
+ return "GR_CMBX_CONSTANT_COLOR";
+ case GR_CMBX_DETAIL_FACTOR:
+ return "GR_CMBX_DETAIL_FACTOR";
+ case GR_CMBX_ITALPHA:
+ return "GR_CMBX_ITALPHA";
+ case GR_CMBX_ITRGB:
+ return "GR_CMBX_ITRGB";
+ case GR_CMBX_LOCAL_TEXTURE_ALPHA:
+ return "GR_CMBX_LOCAL_TEXTURE_ALPHA";
+ case GR_CMBX_LOCAL_TEXTURE_RGB:
+ return "GR_CMBX_LOCAL_TEXTURE_RGB";
+ case GR_CMBX_LOD_FRAC:
+ return "GR_CMBX_LOD_FRAC";
+ case GR_CMBX_OTHER_TEXTURE_ALPHA:
+ return "GR_CMBX_OTHER_TEXTURE_ALPHA";
+ case GR_CMBX_OTHER_TEXTURE_RGB:
+ return "GR_CMBX_OTHER_TEXTURE_RGB";
+ case GR_CMBX_TEXTURE_RGB:
+ return "GR_CMBX_TEXTURE_RGB";
+ case GR_CMBX_TMU_CALPHA:
+ return "GR_CMBX_TMU_CALPHA";
+ case GR_CMBX_TMU_CCOLOR:
+ return "GR_CMBX_TMU_CCOLOR";
+ default:
+ return "";
+ }
+}
+#endif
+
+#if 0
+static const char *texMode(int k)
+{
+ switch (k) {
+ case GR_FUNC_MODE_ZERO:
+ return "GR_FUNC_MODE_ZERO";
+ case GR_FUNC_MODE_X:
+ return "GR_FUNC_MODE_X";
+ case GR_FUNC_MODE_ONE_MINUS_X:
+ return "GR_FUNC_MODE_ONE_MINUS_X";
+ case GR_FUNC_MODE_NEGATIVE_X:
+ return "GR_FUNC_MODE_NEGATIVE_X";
+ case GR_FUNC_MODE_X_MINUS_HALF:
+ return "GR_FUNC_MODE_X_MINUS_HALF";
+ default:
+ return "";
+ }
+}
+#endif
+
+#if 0
+static const char *texInvert(int k)
+{
+ return k ? "FXTRUE" : "FXFALSE";
+}
+#endif
+
+static void uploadTextureEnv( tdfxContextPtr fxMesa )
+{
+ if (TDFX_IS_NAPALM(fxMesa)) {
+ int unit;
+ for (unit = 0; unit < TDFX_NUM_TMU; unit++) {
+#if 0
+ printf("upload env %d\n", unit);
+ printf(" cSourceA = %s\t", texSource(fxMesa->TexCombineExt[unit].Color.SourceA));
+ printf(" cModeA = %s\n", texMode(fxMesa->TexCombineExt[unit].Color.ModeA));
+ printf(" cSourceB = %s\t", texSource(fxMesa->TexCombineExt[unit].Color.SourceB));
+ printf(" cModeB = %s\n", texMode(fxMesa->TexCombineExt[unit].Color.ModeB));
+ printf(" cSourceC = %s\t", texSource(fxMesa->TexCombineExt[unit].Color.SourceC));
+ printf(" cInvertC = %s\n", texInvert(fxMesa->TexCombineExt[unit].Color.InvertC));
+ printf(" cSourceD = %s\t", texSource(fxMesa->TexCombineExt[unit].Color.SourceD));
+ printf(" cInvertD = %s\n", texInvert(fxMesa->TexCombineExt[unit].Color.InvertD));
+ printf(" cShift = %d\t", fxMesa->TexCombineExt[unit].Color.Shift);
+ printf(" cInvert = %d\n", fxMesa->TexCombineExt[unit].Color.Invert);
+ printf(" aSourceA = %s\t", texSource(fxMesa->TexCombineExt[unit].Alpha.SourceA));
+ printf(" aModeA = %s\n", texMode(fxMesa->TexCombineExt[unit].Alpha.ModeA));
+ printf(" aSourceB = %s\t", texSource(fxMesa->TexCombineExt[unit].Alpha.SourceB));
+ printf(" aModeB = %s\n", texMode(fxMesa->TexCombineExt[unit].Alpha.ModeB));
+ printf(" aSourceC = %s\t", texSource(fxMesa->TexCombineExt[unit].Alpha.SourceC));
+ printf(" aInvertC = %s\n", texInvert(fxMesa->TexCombineExt[unit].Alpha.InvertC));
+ printf(" aSourceD = %s\t", texSource(fxMesa->TexCombineExt[unit].Alpha.SourceD));
+ printf(" aInvertD = %s\n", texInvert(fxMesa->TexCombineExt[unit].Alpha.InvertD));
+ printf(" aShift = %d\t", fxMesa->TexCombineExt[unit].Alpha.Shift);
+ printf(" aInvert = %d\n", fxMesa->TexCombineExt[unit].Alpha.Invert);
+ printf(" Color = 0x%08x\n", fxMesa->TexCombineExt[unit].EnvColor);
+#endif
+ fxMesa->Glide.grTexColorCombineExt(TDFX_TMU0 + unit,
+ fxMesa->TexCombineExt[unit].Color.SourceA,
+ fxMesa->TexCombineExt[unit].Color.ModeA,
+ fxMesa->TexCombineExt[unit].Color.SourceB,
+ fxMesa->TexCombineExt[unit].Color.ModeB,
+ fxMesa->TexCombineExt[unit].Color.SourceC,
+ fxMesa->TexCombineExt[unit].Color.InvertC,
+ fxMesa->TexCombineExt[unit].Color.SourceD,
+ fxMesa->TexCombineExt[unit].Color.InvertD,
+ fxMesa->TexCombineExt[unit].Color.Shift,
+ fxMesa->TexCombineExt[unit].Color.Invert);
+ fxMesa->Glide.grTexAlphaCombineExt(TDFX_TMU0 + unit,
+ fxMesa->TexCombineExt[unit].Alpha.SourceA,
+ fxMesa->TexCombineExt[unit].Alpha.ModeA,
+ fxMesa->TexCombineExt[unit].Alpha.SourceB,
+ fxMesa->TexCombineExt[unit].Alpha.ModeB,
+ fxMesa->TexCombineExt[unit].Alpha.SourceC,
+ fxMesa->TexCombineExt[unit].Alpha.InvertC,
+ fxMesa->TexCombineExt[unit].Alpha.SourceD,
+ fxMesa->TexCombineExt[unit].Alpha.InvertD,
+ fxMesa->TexCombineExt[unit].Alpha.Shift,
+ fxMesa->TexCombineExt[unit].Alpha.Invert);
+ fxMesa->Glide.grConstantColorValueExt(TDFX_TMU0 + unit,
+ fxMesa->TexCombineExt[unit].EnvColor);
+ }
+ }
+ else {
+ /* Voodoo3 */
+ int unit;
+ for (unit = 0; unit < TDFX_NUM_TMU; unit++) {
+ struct tdfx_texcombine *comb = &fxMesa->TexCombine[unit];
+ fxMesa->Glide.grTexCombine(TDFX_TMU0 + unit,
+ comb->FunctionRGB,
+ comb->FactorRGB,
+ comb->FunctionAlpha,
+ comb->FactorAlpha,
+ comb->InvertRGB,
+ comb->InvertAlpha);
+ }
+ }
+}
+
+
+static void uploadTextureParams( tdfxContextPtr fxMesa )
+{
+ int unit;
+ for (unit = 0; unit < TDFX_NUM_TMU; unit++) {
+ const struct tdfx_texparams *p = &fxMesa->TexParams[unit];
+ /*
+ printf("upload params %d\n", unit);
+ printf(" clamp %x %x\n", env->sClamp, env->tClamp);
+ printf(" filter %x %x\n", env->minFilt, env->magFilt);
+ printf(" mipmap %x %x\n", env->mmMode, env->LODblend);
+ printf(" lod bias %f\n", env->LodBias);
+ */
+ fxMesa->Glide.grTexClampMode(GR_TMU0 + unit, p->sClamp, p->tClamp);
+ fxMesa->Glide.grTexFilterMode(GR_TMU0 + unit, p->minFilt, p->magFilt);
+ fxMesa->Glide.grTexMipMapMode(GR_TMU0 + unit, p->mmMode, p->LODblend);
+ fxMesa->Glide.grTexLodBiasValue(GR_TMU0 + unit, CLAMP(p->LodBias, -8, 7.75));
+ }
+}
+
+
+static void uploadTextureSource( tdfxContextPtr fxMesa )
+{
+ int unit;
+ for (unit = 0; unit < TDFX_NUM_TMU; unit++) {
+ const struct tdfx_texsource *src = &fxMesa->TexSource[unit];
+ /*
+ printf("upload source %d @ %d %p\n", unit, src->StartAddress, src->Info);
+ */
+ if (src->Info) {
+ /*
+ printf(" smallLodLog2=%d largeLodLog2=%d ar=%d format=%d data=%p\n",
+ src->Info->smallLodLog2, src->Info->largeLodLog2,
+ src->Info->aspectRatioLog2, src->Info->format,
+ src->Info->data);
+ */
+ fxMesa->Glide.grTexSource(GR_TMU0 + unit,
+ src->StartAddress,
+ src->EvenOdd,
+ src->Info);
+ }
+ }
+}
+
+
+static void uploadTextureImages( tdfxContextPtr fxMesa )
+{
+ GLcontext *ctx = fxMesa->glCtx;
+ int unit;
+ for (unit = 0; unit < TDFX_NUM_TMU; unit++) {
+ if (ctx->Texture.Unit[unit]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) {
+ struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
+ if (ti && ti->reloadImages && ti->whichTMU != TDFX_TMU_NONE) {
+ /*
+ printf("download texture image on unit %d\n", unit);
+ */
+ tdfxTMDownloadTexture(fxMesa, tObj);
+ ti->reloadImages = GL_FALSE;
+ }
+ }
+ }
+}
+
+
+
+/*
+ * If scissoring is enabled, compute intersection of scissor region
+ * with all X clip rects, resulting in new cliprect list.
+ * If number of cliprects is zero or one, call grClipWindow to setup
+ * the clip region. Otherwise we'll call grClipWindow inside the
+ * BEGIN_CLIP_LOOP macro.
+ */
+void tdfxUploadClipping( tdfxContextPtr fxMesa )
+{
+ __DRIdrawablePrivate *dPriv = fxMesa->driDrawable;
+
+ assert(dPriv);
+
+ if (fxMesa->numClipRects == 0) {
+ /* all drawing clipped away */
+ fxMesa->Glide.grClipWindow(0, 0, 0, 0);
+ }
+ else if (fxMesa->numClipRects == 1) {
+ fxMesa->Glide.grClipWindow(fxMesa->pClipRects[0].x1,
+ fxMesa->screen_height - fxMesa->pClipRects[0].y2,
+ fxMesa->pClipRects[0].x2,
+ fxMesa->screen_height - fxMesa->pClipRects[0].y1);
+ }
+ /* else, we'll do a cliprect loop around all drawing */
+
+ fxMesa->Glide.grDRIPosition( dPriv->x, dPriv->y, dPriv->w, dPriv->h,
+ fxMesa->numClipRects, fxMesa->pClipRects );
+}
+
+
+void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa )
+{
+ if ( !fxMesa->dirty )
+ return;
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_COLOR_COMBINE ) {
+ if (TDFX_IS_NAPALM(fxMesa)) {
+ fxMesa->Glide.grColorCombineExt(fxMesa->ColorCombineExt.SourceA,
+ fxMesa->ColorCombineExt.ModeA,
+ fxMesa->ColorCombineExt.SourceB,
+ fxMesa->ColorCombineExt.ModeB,
+ fxMesa->ColorCombineExt.SourceC,
+ fxMesa->ColorCombineExt.InvertC,
+ fxMesa->ColorCombineExt.SourceD,
+ fxMesa->ColorCombineExt.InvertD,
+ fxMesa->ColorCombineExt.Shift,
+ fxMesa->ColorCombineExt.Invert);
+ }
+ else {
+ /* Voodoo 3 */
+ fxMesa->Glide.grColorCombine( fxMesa->ColorCombine.Function,
+ fxMesa->ColorCombine.Factor,
+ fxMesa->ColorCombine.Local,
+ fxMesa->ColorCombine.Other,
+ fxMesa->ColorCombine.Invert );
+ }
+ fxMesa->dirty &= ~TDFX_UPLOAD_COLOR_COMBINE;
+ }
+ if ( fxMesa->dirty & TDFX_UPLOAD_ALPHA_COMBINE ) {
+ if (TDFX_IS_NAPALM(fxMesa)) {
+ fxMesa->Glide.grAlphaCombineExt(fxMesa->AlphaCombineExt.SourceA,
+ fxMesa->AlphaCombineExt.ModeA,
+ fxMesa->AlphaCombineExt.SourceB,
+ fxMesa->AlphaCombineExt.ModeB,
+ fxMesa->AlphaCombineExt.SourceC,
+ fxMesa->AlphaCombineExt.InvertC,
+ fxMesa->AlphaCombineExt.SourceD,
+ fxMesa->AlphaCombineExt.InvertD,
+ fxMesa->AlphaCombineExt.Shift,
+ fxMesa->AlphaCombineExt.Invert);
+ }
+ else {
+ /* Voodoo 3 */
+ fxMesa->Glide.grAlphaCombine( fxMesa->AlphaCombine.Function,
+ fxMesa->AlphaCombine.Factor,
+ fxMesa->AlphaCombine.Local,
+ fxMesa->AlphaCombine.Other,
+ fxMesa->AlphaCombine.Invert );
+ }
+ fxMesa->dirty &= ~TDFX_UPLOAD_ALPHA_COMBINE;
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_RENDER_BUFFER ) {
+ fxMesa->Glide.grRenderBuffer( fxMesa->DrawBuffer );
+ fxMesa->dirty &= ~TDFX_UPLOAD_RENDER_BUFFER;
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_STIPPLE) {
+ fxMesa->Glide.grStipplePattern( fxMesa->Stipple.Pattern );
+ fxMesa->Glide.grStippleMode( fxMesa->Stipple.Mode );
+ fxMesa->dirty &= ~TDFX_UPLOAD_STIPPLE;
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_ALPHA_TEST ) {
+ fxMesa->Glide.grAlphaTestFunction( fxMesa->Color.AlphaFunc );
+ fxMesa->dirty &= ~TDFX_UPLOAD_ALPHA_TEST;
+ }
+ if ( fxMesa->dirty & TDFX_UPLOAD_ALPHA_REF ) {
+ fxMesa->Glide.grAlphaTestReferenceValue( fxMesa->Color.AlphaRef );
+ fxMesa->dirty &= ~TDFX_UPLOAD_ALPHA_REF;
+ }
+ if ( fxMesa->dirty & TDFX_UPLOAD_BLEND_FUNC ) {
+ if (fxMesa->Glide.grAlphaBlendFunctionExt) {
+ fxMesa->Glide.grAlphaBlendFunctionExt( fxMesa->Color.BlendSrcRGB,
+ fxMesa->Color.BlendDstRGB,
+ fxMesa->Color.BlendEqRGB,
+ fxMesa->Color.BlendSrcA,
+ fxMesa->Color.BlendDstA,
+ fxMesa->Color.BlendEqA );
+ }
+ else {
+ fxMesa->Glide.grAlphaBlendFunction( fxMesa->Color.BlendSrcRGB,
+ fxMesa->Color.BlendDstRGB,
+ fxMesa->Color.BlendSrcA,
+ fxMesa->Color.BlendDstA );
+ }
+ fxMesa->dirty &= ~TDFX_UPLOAD_BLEND_FUNC;
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_DEPTH_MODE ) {
+ fxMesa->Glide.grDepthBufferMode( fxMesa->Depth.Mode );
+ fxMesa->dirty &= ~TDFX_UPLOAD_DEPTH_MODE;
+ }
+ if ( fxMesa->dirty & TDFX_UPLOAD_DEPTH_BIAS ) {
+ fxMesa->Glide.grDepthBiasLevel( fxMesa->Depth.Bias );
+ fxMesa->dirty &= ~TDFX_UPLOAD_DEPTH_BIAS;
+ }
+ if ( fxMesa->dirty & TDFX_UPLOAD_DEPTH_FUNC ) {
+ fxMesa->Glide.grDepthBufferFunction( fxMesa->Depth.Func );
+ fxMesa->dirty &= ~TDFX_UPLOAD_DEPTH_FUNC;
+ }
+ if ( fxMesa->dirty & TDFX_UPLOAD_DEPTH_MASK ) {
+ fxMesa->Glide.grDepthMask( fxMesa->Depth.Mask );
+ fxMesa->dirty &= ~TDFX_UPLOAD_DEPTH_MASK;
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_DITHER) {
+ fxMesa->Glide.grDitherMode( fxMesa->Color.Dither );
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_FOG_MODE ) {
+ fxMesa->Glide.grFogMode( fxMesa->Fog.Mode );
+ fxMesa->dirty &= ~TDFX_UPLOAD_FOG_MODE;
+ }
+ if ( fxMesa->dirty & TDFX_UPLOAD_FOG_COLOR ) {
+ fxMesa->Glide.grFogColorValue( fxMesa->Fog.Color );
+ fxMesa->dirty &= ~TDFX_UPLOAD_FOG_COLOR;
+ }
+ if ( fxMesa->dirty & TDFX_UPLOAD_FOG_TABLE ) {
+ fxMesa->Glide.grFogTable( fxMesa->Fog.Table );
+ fxMesa->dirty &= ~TDFX_UPLOAD_FOG_TABLE;
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_CULL ) {
+ fxMesa->Glide.grCullMode( fxMesa->CullMode );
+ fxMesa->dirty &= ~TDFX_UPLOAD_CULL;
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_CLIP ) {
+ tdfxUploadClipping( fxMesa );
+ fxMesa->dirty &= ~TDFX_UPLOAD_CLIP;
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_COLOR_MASK ) {
+ if ( fxMesa->Glide.grColorMaskExt
+ && fxMesa->glCtx->Visual.redBits == 8) {
+ fxMesa->Glide.grColorMaskExt( fxMesa->Color.ColorMask[RCOMP],
+ fxMesa->Color.ColorMask[GCOMP],
+ fxMesa->Color.ColorMask[BCOMP],
+ fxMesa->Color.ColorMask[ACOMP] );
+ } else {
+ fxMesa->Glide.grColorMask( fxMesa->Color.ColorMask[RCOMP] ||
+ fxMesa->Color.ColorMask[GCOMP] ||
+ fxMesa->Color.ColorMask[BCOMP],
+ /*fxMesa->Color.ColorMask[ACOMP]*/GL_FALSE/*[dBorca] no-no*/ );
+ }
+ fxMesa->dirty &= ~TDFX_UPLOAD_COLOR_MASK;
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_CONSTANT_COLOR ) {
+ fxMesa->Glide.grConstantColorValue( fxMesa->Color.MonoColor );
+ fxMesa->dirty &= ~TDFX_UPLOAD_CONSTANT_COLOR;
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_LINE ) {
+ if (fxMesa->glCtx->Line.SmoothFlag && fxMesa->glCtx->Line.Width == 1.0)
+ fxMesa->Glide.grEnable(GR_AA_ORDERED);
+ else
+ fxMesa->Glide.grDisable(GR_AA_ORDERED);
+ fxMesa->dirty &= ~TDFX_UPLOAD_LINE;
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_STENCIL ) {
+ if (fxMesa->glCtx->Stencil.Enabled) {
+ fxMesa->Glide.grEnable(GR_STENCIL_MODE_EXT);
+ fxMesa->Glide.grStencilOp(fxMesa->Stencil.FailFunc,
+ fxMesa->Stencil.ZFailFunc,
+ fxMesa->Stencil.ZPassFunc);
+ fxMesa->Glide.grStencilFunc(fxMesa->Stencil.Function,
+ fxMesa->Stencil.RefValue,
+ fxMesa->Stencil.ValueMask);
+ fxMesa->Glide.grStencilMask(fxMesa->Stencil.WriteMask);
+ }
+ else {
+ fxMesa->Glide.grDisable(GR_STENCIL_MODE_EXT);
+ }
+ fxMesa->dirty &= ~TDFX_UPLOAD_STENCIL;
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_VERTEX_LAYOUT ) {
+ fxMesa->Glide.grGlideSetVertexLayout( fxMesa->layout[fxMesa->vertexFormat] );
+ /* [dborca] enable fogcoord */
+ fxMesa->Glide.grVertexLayout(GR_PARAM_FOG_EXT, TDFX_FOG_OFFSET,
+ fxMesa->Fog.Mode == GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT);
+ fxMesa->dirty &= ~TDFX_UPLOAD_VERTEX_LAYOUT;
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_TEXTURE_ENV ) {
+ uploadTextureEnv(fxMesa);
+ fxMesa->dirty &= ~TDFX_UPLOAD_TEXTURE_ENV;
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_TEXTURE_PARAMS ) {
+ uploadTextureParams(fxMesa);
+ fxMesa->dirty &= ~TDFX_UPLOAD_TEXTURE_PARAMS;
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_TEXTURE_PALETTE ) {
+ if (fxMesa->TexPalette.Data) {
+ fxMesa->Glide.grTexDownloadTable(fxMesa->TexPalette.Type, fxMesa->TexPalette.Data);
+ }
+ fxMesa->dirty &= ~TDFX_UPLOAD_TEXTURE_PALETTE;
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_TEXTURE_SOURCE ) {
+ uploadTextureSource(fxMesa);
+ fxMesa->dirty &= ~TDFX_UPLOAD_TEXTURE_SOURCE;
+ }
+
+ if ( fxMesa->dirty & TDFX_UPLOAD_TEXTURE_IMAGES ) {
+ uploadTextureImages(fxMesa);
+ fxMesa->dirty &= ~TDFX_UPLOAD_TEXTURE_IMAGES;
+ }
+
+ fxMesa->dirty = 0;
+}
+
+
+
+void tdfxInitRenderFuncs( struct dd_function_table *functions )
+{
+ functions->Clear = tdfxClear;
+ functions->Finish = tdfxFinish;
+ functions->Flush = tdfxFlush;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.h
new file mode 100644
index 000000000..09d0d9019
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_render.h
@@ -0,0 +1,50 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_render.h,v 1.1 2001/03/21 16:14:28 dawes Exp $ */
+
+/*
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#ifndef __TDFX_RENDER_H__
+#define __TDFX_RENDER_H__
+
+#include "tdfx_context.h"
+
+extern void tdfxInitRenderFuncs( struct dd_function_table *functions );
+
+extern void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa );
+
+extern void tdfxUploadClipping( tdfxContextPtr fxMesa );
+
+#define FLUSH_BATCH( fxMesa )
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.c
new file mode 100644
index 000000000..ab64f7986
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.c
@@ -0,0 +1,492 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.c,v 1.3 2002/02/22 21:45:03 dawes Exp $ */
+
+/*
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#include "tdfx_dri.h"
+#include "tdfx_context.h"
+#include "tdfx_lock.h"
+#include "tdfx_vb.h"
+#include "tdfx_span.h"
+#include "tdfx_tris.h"
+
+#include "framebuffer.h"
+#include "renderbuffer.h"
+#include "xmlpool.h"
+
+#include "utils.h"
+
+#ifdef DEBUG_LOCKING
+char *prevLockFile = 0;
+int prevLockLine = 0;
+#endif
+
+#ifndef TDFX_DEBUG
+int TDFX_DEBUG = 0;
+#endif
+
+PUBLIC const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_NO_RAST(false)
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+
+static const GLuint __driNConfigOptions = 1;
+
+extern const struct dri_extension card_extensions[];
+extern const struct dri_extension napalm_extensions[];
+
+static GLboolean
+tdfxCreateScreen( __DRIscreenPrivate *sPriv )
+{
+ tdfxScreenPrivate *fxScreen;
+ TDFXDRIPtr fxDRIPriv = (TDFXDRIPtr) sPriv->pDevPriv;
+
+ if (sPriv->devPrivSize != sizeof(TDFXDRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(TDFXDRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
+
+ /* Allocate the private area */
+ fxScreen = (tdfxScreenPrivate *) CALLOC( sizeof(tdfxScreenPrivate) );
+ if ( !fxScreen )
+ return GL_FALSE;
+
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo (&fxScreen->optionCache,
+ __driConfigOptions, __driNConfigOptions);
+
+ fxScreen->driScrnPriv = sPriv;
+ sPriv->private = (void *) fxScreen;
+
+ fxScreen->regs.handle = fxDRIPriv->regs;
+ fxScreen->regs.size = fxDRIPriv->regsSize;
+ fxScreen->deviceID = fxDRIPriv->deviceID;
+ fxScreen->width = fxDRIPriv->width;
+ fxScreen->height = fxDRIPriv->height;
+ fxScreen->mem = fxDRIPriv->mem;
+ fxScreen->cpp = fxDRIPriv->cpp;
+ fxScreen->stride = fxDRIPriv->stride;
+ fxScreen->fifoOffset = fxDRIPriv->fifoOffset;
+ fxScreen->fifoSize = fxDRIPriv->fifoSize;
+ fxScreen->fbOffset = fxDRIPriv->fbOffset;
+ fxScreen->backOffset = fxDRIPriv->backOffset;
+ fxScreen->depthOffset = fxDRIPriv->depthOffset;
+ fxScreen->textureOffset = fxDRIPriv->textureOffset;
+ fxScreen->textureSize = fxDRIPriv->textureSize;
+ fxScreen->sarea_priv_offset = fxDRIPriv->sarea_priv_offset;
+
+ if ( drmMap( sPriv->fd, fxScreen->regs.handle,
+ fxScreen->regs.size, &fxScreen->regs.map ) ) {
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+static void
+tdfxDestroyScreen( __DRIscreenPrivate *sPriv )
+{
+ tdfxScreenPrivate *fxScreen = (tdfxScreenPrivate *) sPriv->private;
+
+ if (!fxScreen)
+ return;
+
+ drmUnmap( fxScreen->regs.map, fxScreen->regs.size );
+
+ /* free all option information */
+ driDestroyOptionInfo (&fxScreen->optionCache);
+
+ FREE( fxScreen );
+ sPriv->private = NULL;
+}
+
+
+static GLboolean
+tdfxInitDriver( __DRIscreenPrivate *sPriv )
+{
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
+ fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)sPriv );
+ }
+
+ if ( !tdfxCreateScreen( sPriv ) ) {
+ tdfxDestroyScreen( sPriv );
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+tdfxCreateBuffer( __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ tdfxScreenPrivate *screen = (tdfxScreenPrivate *) driScrnPriv->private;
+
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+#if 0
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer( mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE /* software alpha channel? */ );
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->fbOffset, screen->width);
+ tdfxSetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->width);
+ tdfxSetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->width);
+ tdfxSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->width);
+ tdfxSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ if (mesaVis->stencilBits > 0) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->cpp,
+ screen->depthOffset, screen->width);
+ tdfxSetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ GL_FALSE, /*swStencil,*/
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+
+static void
+tdfxDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+
+static void
+tdfxSwapBuffers( __DRIdrawablePrivate *driDrawPriv )
+
+{
+ GET_CURRENT_CONTEXT(ctx);
+ tdfxContextPtr fxMesa = 0;
+ GLframebuffer *mesaBuffer;
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
+ fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)driDrawPriv );
+ }
+
+ mesaBuffer = (GLframebuffer *) driDrawPriv->driverPrivate;
+ if ( !mesaBuffer->Visual.doubleBufferMode )
+ return; /* can't swap a single-buffered window */
+
+ /* If the current context's drawable matches the given drawable
+ * we have to do a glFinish (per the GLX spec).
+ */
+ if ( ctx ) {
+ __DRIdrawablePrivate *curDrawPriv;
+ fxMesa = TDFX_CONTEXT(ctx);
+ curDrawPriv = fxMesa->driContext->driDrawablePriv;
+
+ if ( curDrawPriv == driDrawPriv ) {
+ /* swapping window bound to current context, flush first */
+ _mesa_notifySwapBuffers( ctx );
+ LOCK_HARDWARE( fxMesa );
+ }
+ else {
+ /* find the fxMesa context previously bound to the window */
+ fxMesa = (tdfxContextPtr) driDrawPriv->driContextPriv->driverPrivate;
+ if (!fxMesa)
+ return;
+ LOCK_HARDWARE( fxMesa );
+ fxMesa->Glide.grSstSelect( fxMesa->Glide.Board );
+ printf("SwapBuf SetState 1\n");
+ fxMesa->Glide.grGlideSetState(fxMesa->Glide.State );
+ }
+ }
+
+#ifdef STATS
+ {
+ int stalls;
+ static int prevStalls = 0;
+
+ stalls = fxMesa->Glide.grFifoGetStalls();
+
+ fprintf( stderr, "%s:\n", __FUNCTION__ );
+ if ( stalls != prevStalls ) {
+ fprintf( stderr, " %d stalls occurred\n",
+ stalls - prevStalls );
+ prevStalls = stalls;
+ }
+ if ( fxMesa && fxMesa->texSwaps ) {
+ fprintf( stderr, " %d texture swaps occurred\n",
+ fxMesa->texSwaps );
+ fxMesa->texSwaps = 0;
+ }
+ }
+#endif
+
+ if (fxMesa->scissoredClipRects) {
+ /* restore clip rects without scissor box */
+ fxMesa->Glide.grDRIPosition( driDrawPriv->x, driDrawPriv->y,
+ driDrawPriv->w, driDrawPriv->h,
+ driDrawPriv->numClipRects,
+ driDrawPriv->pClipRects );
+ }
+
+ fxMesa->Glide.grDRIBufferSwap( fxMesa->Glide.SwapInterval );
+
+ if (fxMesa->scissoredClipRects) {
+ /* restore clip rects WITH scissor box */
+ fxMesa->Glide.grDRIPosition( driDrawPriv->x, driDrawPriv->y,
+ driDrawPriv->w, driDrawPriv->h,
+ fxMesa->numClipRects, fxMesa->pClipRects );
+ }
+
+
+#if 0
+ {
+ FxI32 result;
+ do {
+ FxI32 result;
+ fxMesa->Glide.grGet(GR_PENDING_BUFFERSWAPS, 4, &result);
+ } while ( result > fxMesa->maxPendingSwapBuffers );
+ }
+#endif
+
+ fxMesa->stats.swapBuffer++;
+
+ if (ctx) {
+ if (ctx->DriverCtx != fxMesa) {
+ fxMesa = TDFX_CONTEXT(ctx);
+ fxMesa->Glide.grSstSelect( fxMesa->Glide.Board );
+ printf("SwapBuf SetState 2\n");
+ fxMesa->Glide.grGlideSetState(fxMesa->Glide.State );
+ }
+ UNLOCK_HARDWARE( fxMesa );
+ }
+}
+
+
+static const struct __DriverAPIRec tdfxAPI = {
+ .InitDriver = tdfxInitDriver,
+ .DestroyScreen = tdfxDestroyScreen,
+ .CreateContext = tdfxCreateContext,
+ .DestroyContext = tdfxDestroyContext,
+ .CreateBuffer = tdfxCreateBuffer,
+ .DestroyBuffer = tdfxDestroyBuffer,
+ .SwapBuffers = tdfxSwapBuffers,
+ .MakeCurrent = tdfxMakeCurrent,
+ .UnbindContext = tdfxUnbindContext,
+ .GetSwapInfo = NULL,
+ .GetMSC = NULL,
+ .WaitForMSC = NULL,
+ .WaitForSBC = NULL,
+ .SwapBuffersMSC = NULL
+};
+
+
+static __GLcontextModes *tdfxFillInModes(unsigned pixel_bits,
+ unsigned depth_bits,
+ unsigned stencil_bits,
+ GLboolean have_back_buffer)
+{
+ __GLcontextModes *modes;
+ __GLcontextModes *m;
+ unsigned num_modes;
+ unsigned vis[2] = { GLX_TRUE_COLOR, GLX_DIRECT_COLOR };
+ unsigned deep = (depth_bits > 17);
+ unsigned i, db, depth, accum, stencil;
+
+ /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
+ * enough to add support. Basically, if a context is created with an
+ * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
+ * will never be used.
+ */
+
+ num_modes = (depth_bits == 16) ? 32 : 16;
+
+ modes = (*dri_interface->createContextModes)(num_modes, sizeof(__GLcontextModes));
+ m = modes;
+
+ for (i = 0; i <= 1; i++) {
+ for (db = 0; db <= 1; db++) {
+ for (depth = 0; depth <= 1; depth++) {
+ for (accum = 0; accum <= 1; accum++) {
+ for (stencil = 0; stencil <= !deep; stencil++) {
+ if (deep) stencil = depth;
+ m->redBits = deep ? 8 : 5;
+ m->greenBits = deep ? 8 : 6;
+ m->blueBits = deep ? 8 : 5;
+ m->alphaBits = deep ? 8 : 0;
+ m->redMask = deep ?0xFF000000 :0x0000F800;
+ m->greenMask = deep ?0x00FF0000 :0x000007E0;
+ m->blueMask = deep ?0x0000FF00 :0x0000001F;
+ m->alphaMask = deep ? 0x000000FF : 0;
+ m->rgbBits = m->redBits + m->greenBits +
+ m->blueBits + m->alphaBits;
+ m->accumRedBits = accum ? 16 : 0;
+ m->accumGreenBits = accum ? 16 : 0;
+ m->accumBlueBits = accum ? 16 : 0;
+ m->accumAlphaBits = accum ? 16 : 0;
+ m->stencilBits = stencil ? 8 : 0;
+ m->depthBits = deep
+ ? (depth ? 24 : 0)
+ : (depth ? 0 : depth_bits);
+ m->visualType = vis[i];
+ m->renderType = GLX_RGBA_BIT;
+ m->drawableType = GLX_WINDOW_BIT;
+ m->rgbMode = GL_TRUE;
+ m->doubleBufferMode = db ? GL_TRUE : GL_FALSE;
+ if (db)
+ m->swapMethod = GLX_SWAP_UNDEFINED_OML;
+ m->visualRating = ((stencil && !deep) || accum)
+ ? GLX_SLOW_CONFIG
+ : GLX_NONE;
+ m = m->next;
+ if (deep) stencil = 0;
+ }
+ }
+ }
+ }
+ }
+
+ return modes;
+}
+
+/**
+ * This is the bootstrap function for the driver. libGL supplies all of the
+ * requisite information about the system, and the driver initializes itself.
+ * This routine also fills in the linked list pointed to by \c driver_modes
+ * with the \c __GLcontextModes that the driver can support for windows or
+ * pbuffers.
+ *
+ * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
+ * failure.
+ */
+PUBLIC
+void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn, __DRIscreen *psc,
+ const __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drmAddress pSAREA, int fd,
+ int internal_api_version,
+ const __DRIinterfaceMethods * interface,
+ __GLcontextModes ** driver_modes )
+{
+ __DRIscreenPrivate *psp;
+ static const __DRIversion ddx_expected = { 1, 1, 0 };
+ static const __DRIversion dri_expected = { 4, 0, 0 };
+ static const __DRIversion drm_expected = { 1, 0, 0 };
+
+ dri_interface = interface;
+
+ if ( ! driCheckDriDdxDrmVersions2( "tdfx",
+ dri_version, & dri_expected,
+ ddx_version, & ddx_expected,
+ drm_version, & drm_expected ) ) {
+ return NULL;
+ }
+
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &tdfxAPI);
+
+ if (psp != NULL) {
+ /* divined from tdfx_dri.c, sketchy */
+ TDFXDRIPtr dri_priv = (TDFXDRIPtr) psp->pDevPriv;
+ int bpp = (dri_priv->cpp > 2) ? 24 : 16;
+
+ /* XXX i wish it was like this */
+ /* bpp = dri_priv->bpp */
+
+ *driver_modes = tdfxFillInModes(bpp, (bpp == 16) ? 16 : 24,
+ (bpp == 16) ? 0 : 8,
+ (dri_priv->backOffset!=dri_priv->depthOffset));
+
+ /* Calling driInitExtensions here, with a NULL context pointer, does not actually
+ * enable the extensions. It just makes sure that all the dispatch offsets for all
+ * the extensions that *might* be enables are known. This is needed because the
+ * dispatch offsets need to be known when _mesa_context_create is called, but we can't
+ * enable the extensions until we have a context pointer.
+ *
+ * Hello chicken. Hello egg. How are you two today?
+ */
+ driInitExtensions( NULL, card_extensions, GL_FALSE );
+ driInitExtensions( NULL, napalm_extensions, GL_FALSE );
+ }
+
+ return (void *)psp;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.h
new file mode 100644
index 000000000..90be89a35
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_screen.h
@@ -0,0 +1,73 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_screen.h,v 1.2 2002/02/22 21:45:03 dawes Exp $ */
+
+/*
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+#ifndef __TDFX_SCREEN_H__
+#define __TDFX_SCREEN_H__
+
+typedef struct {
+ drm_handle_t handle;
+ drmSize size;
+ drmAddress map;
+} tdfxRegion, *tdfxRegionPtr;
+
+typedef struct {
+ tdfxRegion regs;
+
+ int deviceID;
+ int width;
+ int height;
+ int mem;
+ int cpp;
+ int stride;
+
+ int fifoOffset;
+ int fifoSize;
+
+ int fbOffset;
+ int backOffset;
+ int depthOffset;
+ int textureOffset;
+ int textureSize;
+
+ __DRIscreenPrivate *driScrnPriv;
+ unsigned int sarea_priv_offset;
+
+ /* Configuration cache with default values for all contexts */
+ driOptionCache optionCache;
+} tdfxScreenPrivate;
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.c
new file mode 100644
index 000000000..b00b7ad8d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.c
@@ -0,0 +1,1427 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_span.c,v 1.7 2002/10/30 12:52:00 alanh Exp $ */
+
+/*
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ * Keith Whitwell <keith@tungstengraphics.com>
+ *
+ */
+
+#include "tdfx_context.h"
+#include "tdfx_lock.h"
+#include "tdfx_span.h"
+#include "tdfx_render.h"
+#include "swrast/swrast.h"
+
+
+#define DBG 0
+
+
+#define LOCAL_VARS \
+ __DRIdrawablePrivate *dPriv = fxMesa->driDrawable; \
+ tdfxScreenPrivate *fxPriv = fxMesa->fxScreen; \
+ GLuint pitch = (fxMesa->glCtx->Color.DrawBuffer[0] == GL_FRONT) \
+ ? (fxMesa->screen_width * BYTESPERPIXEL) : \
+ (info.strideInBytes); \
+ GLuint height = fxMesa->height; \
+ char *buf = (char *)((char *)info.lfbPtr + \
+ dPriv->x * fxPriv->cpp + \
+ dPriv->y * pitch); \
+ GLuint p; \
+ (void) buf; (void) p;
+
+
+#define Y_FLIP(_y) (height - _y - 1)
+
+
+#define HW_WRITE_LOCK() \
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \
+ GrLfbInfo_t info; \
+ FLUSH_BATCH( fxMesa ); \
+ UNLOCK_HARDWARE( fxMesa ); \
+ LOCK_HARDWARE( fxMesa ); \
+ info.size = sizeof(GrLfbInfo_t); \
+ if ( fxMesa->Glide.grLfbLock( GR_LFB_WRITE_ONLY, \
+ fxMesa->DrawBuffer, LFB_MODE, \
+ GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) \
+ {
+
+#define HW_WRITE_UNLOCK() \
+ fxMesa->Glide.grLfbUnlock( GR_LFB_WRITE_ONLY, fxMesa->DrawBuffer );\
+ }
+
+
+#define HW_READ_LOCK() \
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \
+ GrLfbInfo_t info; \
+ FLUSH_BATCH( fxMesa ); \
+ UNLOCK_HARDWARE( fxMesa ); \
+ LOCK_HARDWARE( fxMesa ); \
+ info.size = sizeof(GrLfbInfo_t); \
+ if ( fxMesa->Glide.grLfbLock( GR_LFB_READ_ONLY, fxMesa->ReadBuffer, \
+ LFB_MODE, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) \
+ {
+
+#define HW_READ_UNLOCK() \
+ fxMesa->Glide.grLfbUnlock( GR_LFB_READ_ONLY, fxMesa->ReadBuffer );\
+ }
+
+
+#define HW_WRITE_CLIPLOOP() \
+ do { \
+ int _nc = fxMesa->numClipRects; \
+ while (_nc--) { \
+ int minx = fxMesa->pClipRects[_nc].x1 - fxMesa->x_offset; \
+ int miny = fxMesa->pClipRects[_nc].y1 - fxMesa->y_offset; \
+ int maxx = fxMesa->pClipRects[_nc].x2 - fxMesa->x_offset; \
+ int maxy = fxMesa->pClipRects[_nc].y2 - fxMesa->y_offset;
+
+#define HW_READ_CLIPLOOP() \
+ do { \
+ const __DRIdrawablePrivate *dPriv = fxMesa->driDrawable; \
+ drm_clip_rect_t *rect = dPriv->pClipRects; \
+ int _nc = dPriv->numClipRects; \
+ while (_nc--) { \
+ const int minx = rect->x1 - fxMesa->x_offset; \
+ const int miny = rect->y1 - fxMesa->y_offset; \
+ const int maxx = rect->x2 - fxMesa->x_offset; \
+ const int maxy = rect->y2 - fxMesa->y_offset; \
+ rect++;
+
+#define HW_ENDCLIPLOOP() \
+ } \
+ } while (0)
+
+
+
+#define LFB_MODE GR_LFBWRITEMODE_565
+
+
+/* 16 bit, RGB565 color spanline and pixel functions */ \
+
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = TDFXPACKCOLOR565( color[0], color[1], color[2] )
+
+
+#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 *)(buf + _x*2 + _y*pitch); \
+ rgba[0] = (((p >> 11) & 0x1f) * 255) / 31; \
+ rgba[1] = (((p >> 5) & 0x3f) * 255) / 63; \
+ rgba[2] = (((p >> 0) & 0x1f) * 255) / 31; \
+ rgba[3] = 0xff; \
+ } while (0)
+
+#define TAG(x) tdfx##x##_RGB565
+#define BYTESPERPIXEL 2
+#include "spantmp.h"
+#undef BYTESPERPIXEL
+
+
+/* 16 bit, BGR565 color spanline and pixel functions */ \
+#if 0
+
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)b & 0xf8) << 8) | \
+ (((int)g & 0xfc) << 3) | \
+ (((int)r & 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 << 3) & 0xf8; \
+ rgba[1] = (p >> 3) & 0xfc; \
+ rgba[2] = (p >> 8) & 0xf8; \
+ rgba[3] = 0xff; \
+ } while (0)
+
+#define TAG(x) tdfx##x##_BGR565
+#define BYTESPERPIXEL 2
+#include "spantmp.h"
+#undef BYTESPERPIXEL
+#endif
+
+
+#undef LFB_MODE
+#define LFB_MODE GR_LFBWRITEMODE_888
+
+
+/* 24 bit, RGB888 color spanline and pixel functions */
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = TDFXPACKCOLOR888( color[0], color[1], color[2] )
+
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ *(GLuint *)(buf + _x*3 + _y*pitch) = ((b << 0) | \
+ (g << 8) | \
+ (r << 16))
+
+#define WRITE_PIXEL( _x, _y, p ) \
+ *(GLuint *)(buf + _x*3 + _y*pitch) = p
+
+#define READ_RGBA( rgba, _x, _y ) \
+do { \
+ GLuint p = *(GLuint *)(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) tdfx##x##_RGB888
+#define BYTESPERPIXEL 4
+#include "spantmp.h"
+#undef BYTESPERPIXEL
+
+
+#undef LFB_MODE
+#define LFB_MODE GR_LFBWRITEMODE_8888
+
+
+/* 32 bit, ARGB8888 color spanline and pixel functions */
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = TDFXPACKCOLOR8888( color[0], color[1], color[2], color[3] )
+
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ *(GLuint *)(buf + _x*4 + _y*pitch) = ((b << 0) | \
+ (g << 8) | \
+ (r << 16) | \
+ (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 *)(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) tdfx##x##_ARGB8888
+#define BYTESPERPIXEL 4
+#include "spantmp.h"
+#undef BYTESPERPIXEL
+
+
+
+/* ================================================================
+ * Old span functions below...
+ */
+
+
+/*
+ * 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.
+ */
+static void
+generate_vismask(const tdfxContextPtr fxMesa, GLint x, GLint y, GLint n,
+ GLubyte vismask[])
+{
+ GLboolean initialized = GL_FALSE;
+ GLint i, j;
+
+ /* Ensure we clear the visual mask */
+ MEMSET(vismask, 0, n);
+
+ /* turn on flags for all visible pixels */
+ for (i = 0; i < fxMesa->numClipRects; i++) {
+ const drm_clip_rect_t *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;
+ }
+ }
+ }
+}
+
+/*
+ * Examine cliprects and determine if the given screen pixel is visible.
+ */
+static GLboolean
+visible_pixel(const tdfxContextPtr fxMesa, int scrX, int scrY)
+{
+ int i;
+ for (i = 0; i < fxMesa->numClipRects; i++) {
+ const drm_clip_rect_t *rect = &fxMesa->pClipRects[i];
+ if (scrX >= rect->x1 &&
+ scrX < rect->x2 &&
+ scrY >= rect->y1 && scrY < rect->y2) return GL_TRUE;
+ }
+ return GL_FALSE;
+}
+
+
+
+/*
+ * Depth buffer read/write functions.
+ */
+/*
+ * To read the frame buffer, we need to lock and unlock it. The
+ * four macros {READ,WRITE}_FB_SPAN_{LOCK,UNLOCK}
+ * do this for us.
+ *
+ * Note that the lock must be matched with an unlock. These
+ * macros include a spare curly brace, so they must
+ * be syntactically matched.
+ *
+ * Note, also, that you can't lock a buffer twice with different
+ * modes. That is to say, you can't lock a buffer in both read
+ * and write modes. The strideInBytes and LFB pointer will be
+ * the same with read and write locks, so you can use either.
+ * o The HW has different state for reads and writes, so
+ * locking it twice may give screwy results.
+ * o The DRM won't let you lock twice. It hangs. This is probably
+ * because of the LOCK_HARDWARE IN THE *_FB_SPAN_LOCK macros,
+ * and could be eliminated with nonlocking lock routines. But
+ * what's the point after all.
+ */
+#define READ_FB_SPAN_LOCK(fxMesa, info, target_buffer) \
+ UNLOCK_HARDWARE(fxMesa); \
+ LOCK_HARDWARE(fxMesa); \
+ (info).size=sizeof(info); \
+ if (fxMesa->Glide.grLfbLock(GR_LFB_READ_ONLY, \
+ target_buffer, \
+ GR_LFBWRITEMODE_ANY, \
+ GR_ORIGIN_UPPER_LEFT, \
+ FXFALSE, \
+ &(info))) {
+
+#define READ_FB_SPAN_UNLOCK(fxMesa, target_buffer) \
+ fxMesa->Glide.grLfbUnlock(GR_LFB_READ_ONLY, target_buffer); \
+ } else { \
+ fprintf(stderr, "tdfxDriver: Can't get %s (%d) read lock\n", \
+ (target_buffer == GR_BUFFER_BACKBUFFER) \
+ ? "back buffer" \
+ : ((target_buffer == GR_BUFFER_AUXBUFFER) \
+ ? "depth buffer" \
+ : "unknown buffer"), \
+ target_buffer); \
+ }
+
+#define WRITE_FB_SPAN_LOCK(fxMesa, info, target_buffer, write_mode) \
+ UNLOCK_HARDWARE(fxMesa); \
+ LOCK_HARDWARE(fxMesa); \
+ info.size=sizeof(info); \
+ if (fxMesa->Glide.grLfbLock(GR_LFB_WRITE_ONLY, \
+ target_buffer, \
+ write_mode, \
+ GR_ORIGIN_UPPER_LEFT, \
+ FXFALSE, \
+ &info)) {
+
+#define WRITE_FB_SPAN_UNLOCK(fxMesa, target_buffer) \
+ fxMesa->Glide.grLfbUnlock(GR_LFB_WRITE_ONLY, target_buffer); \
+ } else { \
+ fprintf(stderr, "tdfxDriver: Can't get %s (%d) write lock\n", \
+ (target_buffer == GR_BUFFER_BACKBUFFER) \
+ ? "back buffer" \
+ : ((target_buffer == GR_BUFFER_AUXBUFFER) \
+ ? "depth buffer" \
+ : "unknown buffer"), \
+ target_buffer); \
+ }
+
+/*
+ * Because the Linear Frame Buffer is not necessarily aligned
+ * with the depth buffer, we have to do some fiddling
+ * around to get the right addresses.
+ *
+ * Perhaps a picture is in order. The Linear Frame Buffer
+ * looks like this:
+ *
+ * |<----------------------info.strideInBytes------------->|
+ * |<-----physicalStrideInBytes------->|
+ * +-----------------------------------+xxxxxxxxxxxxxxxxxxx+
+ * | | |
+ * | Legal Memory | Forbidden Zone |
+ * | | |
+ * +-----------------------------------+xxxxxxxxxxxxxxxxxxx+
+ *
+ * You can only reliably read and write legal locations. Reads
+ * and writes from the Forbidden Zone will return undefined values,
+ * and may cause segmentation faults.
+ *
+ * Now, the depth buffer may not end up in a location such each
+ * scan line is an LFB line. For example, the depth buffer may
+ * look like this:
+ *
+ * wrapped ordinary.
+ * +-----------------------------------+xxxxxxxxxxxxxxxxxxx+
+ * |0000000000000000000000 | | back
+ * |1111111111111111111111 | | buffer
+ * |2222222222222222222222 | |
+ * |4096b align. padxx00000000000000000| Forbidden Zone | depth
+ * |0000 11111111111111111| | buffer
+ * |1111 22222222222222222| |
+ * |2222 | |
+ * +-----------------------------------+xxxxxxxxxxxxxxxxxxx+
+ * where each number is the scan line number. We know it will
+ * be aligned on 128 byte boundaries, at least. Aligning this
+ * on a scanline boundary causes the back and depth buffers to
+ * thrash in the SST1 cache. (Note that the back buffer is always
+ * allocated at the beginning of LFB memory, and so it is always
+ * properly aligned with the LFB stride.)
+ *
+ * We call the beginning of the line (which is the rightmost
+ * part of the depth line in the picture above) the *ordinary* part
+ * of the scanline, and the end of the line (which is the
+ * leftmost part, one line below) the *wrapped* part of the scanline.
+ * a.) We need to know what x value to subtract from the screen
+ * x coordinate to index into the wrapped part.
+ * b.) We also need to figure out if we need to read from the ordinary
+ * part scan line, or from the wrapped part of the scan line.
+ *
+ * [ad a]
+ * The first wrapped x coordinate is that coordinate such that
+ * depthBufferOffset&(info.strideInBytes) + x*elmentSize {*}
+ * > physicalStrideInBytes
+ * where depthBufferOffset is the LFB distance in bytes
+ * from the back buffer to the depth buffer. The expression
+ * depthBufferOffset&(info.strideInBytes)
+ * is then the offset (in bytes) from the beginining of (any)
+ * depth buffer line to first element in the line.
+ * Simplifying inequation {*} above we see that x is the smallest
+ * value such that
+ * x*elementSize > physicalStrideInBytes {**}
+ * - depthBufferOffset&(info.strideInBytes)
+ * Now, we know that both the summands on the right are multiples of
+ * 128, and elementSize <= 4, so if equality holds in {**}, x would
+ * be a multiple of 32. Thus we can set x to
+ * xwrapped = (physicalStrideInBytes
+ * - depthBufferOffset&(info.strideInBytes))/elementSize
+ * + 1
+ *
+ * [ad b]
+ * Question b is now simple. We read from the wrapped scan line if
+ * x is greater than xwrapped.
+ */
+#define TILE_WIDTH_IN_BYTES 128
+#define TILE_WIDTH_IN_ZOXELS(bpz) (TILE_WIDTH_IN_BYTES/(bpz))
+#define TILE_HEIGHT_IN_LINES 32
+typedef struct
+{
+ void *lfbPtr;
+ void *lfbWrapPtr;
+ FxU32 LFBStrideInElts;
+ GLint firstWrappedX;
+}
+LFBParameters;
+
+/*
+ * We need information about the back buffer. Note that
+ * this function *cannot be called* while the aux buffer
+ * is locked, or the caller will hang.
+ *
+ * Only Glide knows the LFB address of the back and depth
+ * offsets. The upper levels of Mesa know the depth offset,
+ * but that is not in LFB space, it is tiled memory space,
+ * and is not useable for us.
+ */
+static void
+GetBackBufferInfo(tdfxContextPtr fxMesa, GrLfbInfo_t * backBufferInfo)
+{
+ READ_FB_SPAN_LOCK(fxMesa, *backBufferInfo, GR_BUFFER_BACKBUFFER);
+ READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_BACKBUFFER);
+}
+
+static void
+GetFbParams(tdfxContextPtr fxMesa,
+ GrLfbInfo_t * info,
+ GrLfbInfo_t * backBufferInfo,
+ LFBParameters * ReadParamsp, FxU32 elementSize)
+{
+ FxU32 physicalStrideInBytes, bufferOffset;
+ FxU32 strideInBytes = info->strideInBytes;
+ char *lfbPtr = (char *) (info->lfbPtr); /* For arithmetic, use char * */
+
+ /*
+ * These two come directly from the info structure.
+ */
+ ReadParamsp->lfbPtr = (void *) lfbPtr;
+ ReadParamsp->LFBStrideInElts = strideInBytes / elementSize;
+ /*
+ * Now, calculate the value of firstWrappedX.
+ *
+ * The physical stride is the screen width in bytes rounded up to
+ * the next highest multiple of 128 bytes. Note that this fails
+ * when TILE_WIDTH_IN_BYTES is not a power of two.
+ *
+ * The buffer Offset is the distance between the beginning of
+ * the LFB space, which is the beginning of the back buffer,
+ * and the buffer we are gathering information about.
+ * We want to make this routine usable for operations on the
+ * back buffer, though we don't actually use it on the back
+ * buffer. Note, then, that if bufferOffset == 0, the firstWrappedX
+ * is in the forbidden zone, and is therefore never reached.
+ *
+ * Note that if
+ * physicalStrideInBytes
+ * < bufferOffset&(info->strideInBytes-1)
+ * the buffer begins in the forbidden zone. We assert for this.
+ */
+ bufferOffset = (FxU32)(lfbPtr - (char *) backBufferInfo->lfbPtr);
+ physicalStrideInBytes
+ = (fxMesa->screen_width * elementSize + TILE_WIDTH_IN_BYTES - 1)
+ & ~(TILE_WIDTH_IN_BYTES - 1);
+ assert(physicalStrideInBytes > (bufferOffset & (strideInBytes - 1)));
+ ReadParamsp->firstWrappedX
+ = (physicalStrideInBytes
+ - (bufferOffset & (strideInBytes - 1))) / elementSize;
+ /*
+ * This is the address of the next physical line.
+ */
+ ReadParamsp->lfbWrapPtr
+ = (void *) ((char *) backBufferInfo->lfbPtr
+ + (bufferOffset & ~(strideInBytes - 1))
+ + (TILE_HEIGHT_IN_LINES) * strideInBytes);
+}
+
+/*
+ * These macros fetch data from the frame buffer. The type is
+ * the type of data we want to fetch. It should match the type
+ * whose size was used with GetFbParams to fill in the structure
+ * in *ReadParamsp. We have a macro to read the ordinary
+ * part, a second macro to read the wrapped part, and one which
+ * will do either. When we are reading a span, we will know
+ * when the ordinary part ends, so there's no need to test for
+ * it. However, when reading and writing pixels, we don't
+ * necessarily know. I suppose it's a matter of taste whether
+ * it's better in the macro or in the call.
+ *
+ * Recall that x and y are screen coordinates.
+ */
+#define GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) \
+ (((type *)((ReadParamsp)->lfbPtr)) \
+ [(y) * ((ReadParamsp)->LFBStrideInElts) \
+ + (x)])
+#define GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y) \
+ (((type *)((ReadParamsp)->lfbWrapPtr)) \
+ [((y)) * ((ReadParamsp)->LFBStrideInElts) \
+ + ((x) - (ReadParamsp)->firstWrappedX)])
+#define GET_FB_DATA(ReadParamsp, type, x, y) \
+ (((x) < (ReadParamsp)->firstWrappedX) \
+ ? GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) \
+ : GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y))
+#define PUT_ORDINARY_FB_DATA(ReadParamsp, type, x, y, value) \
+ (GET_ORDINARY_FB_DATA(ReadParamsp, type, x, y) = (type)(value))
+#define PUT_WRAPPED_FB_DATA(ReadParamsp, type, x, y, value) \
+ (GET_WRAPPED_FB_DATA(ReadParamsp, type, x, y) = (type)(value))
+#define PUT_FB_DATA(ReadParamsp, type, x, y, value) \
+ do { \
+ if ((x) < (ReadParamsp)->firstWrappedX) \
+ PUT_ORDINARY_FB_DATA(ReadParamsp, type, x, y, value); \
+ else \
+ PUT_WRAPPED_FB_DATA(ReadParamsp, type, x, y, value); \
+ } while (0)
+
+
+static void
+tdfxDDWriteDepthSpan(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, const void *values,
+ const GLubyte mask[])
+{
+ const GLuint *depth = (const GLuint *) values;
+ tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
+ GLint bottom = fxMesa->y_offset + fxMesa->height - 1;
+ GLuint depth_size = fxMesa->glCtx->Visual.depthBits;
+ GLuint stencil_size = fxMesa->glCtx->Visual.stencilBits;
+ GrLfbInfo_t info;
+ GLubyte visMask[MAX_WIDTH];
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "tdfxmesa: tdfxDDWriteDepthSpan(...)\n");
+ }
+
+ assert((depth_size == 16) || (depth_size == 24) || (depth_size == 32));
+ /*
+ * Convert x and y to screen coordinates.
+ */
+ x += fxMesa->x_offset;
+ y = bottom - y;
+ if (mask) {
+ GLint i;
+ GLushort d16;
+ GrLfbInfo_t backBufferInfo;
+
+ switch (depth_size) {
+ case 16:
+ GetBackBufferInfo(fxMesa, &backBufferInfo);
+ /*
+ * Note that the _LOCK macro adds a curly brace,
+ * and the UNLOCK macro removes it.
+ */
+ WRITE_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER,
+ GR_LFBWRITEMODE_ANY);
+ generate_vismask(fxMesa, x, y, n, visMask);
+ {
+ LFBParameters ReadParams;
+ int wrappedPartStart;
+ GetFbParams(fxMesa, &info, &backBufferInfo,
+ &ReadParams, sizeof(GLushort));
+ if (ReadParams.firstWrappedX <= x) {
+ wrappedPartStart = 0;
+ }
+ else if (n <= (ReadParams.firstWrappedX - x)) {
+ wrappedPartStart = n;
+ }
+ else {
+ wrappedPartStart = (ReadParams.firstWrappedX - x);
+ }
+ for (i = 0; i < wrappedPartStart; i++) {
+ if (mask[i] && visMask[i]) {
+ d16 = depth[i];
+ PUT_ORDINARY_FB_DATA(&ReadParams, GLushort, x + i, y, d16);
+ }
+ }
+ for (; i < n; i++) {
+ if (mask[i] && visMask[i]) {
+ d16 = depth[i];
+ PUT_WRAPPED_FB_DATA(&ReadParams, GLushort, x + i, y, d16);
+ }
+ }
+ }
+ WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+ break;
+ case 24:
+ case 32:
+ GetBackBufferInfo(fxMesa, &backBufferInfo);
+ /*
+ * Note that the _LOCK macro adds a curly brace,
+ * and the UNLOCK macro removes it.
+ */
+ WRITE_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER,
+ GR_LFBWRITEMODE_ANY);
+ generate_vismask(fxMesa, x, y, n, visMask);
+ {
+ LFBParameters ReadParams;
+ int wrappedPartStart;
+ GetFbParams(fxMesa, &info, &backBufferInfo,
+ &ReadParams, sizeof(GLuint));
+ if (ReadParams.firstWrappedX <= x) {
+ wrappedPartStart = 0;
+ }
+ else if (n <= (ReadParams.firstWrappedX - x)) {
+ wrappedPartStart = n;
+ }
+ else {
+ wrappedPartStart = (ReadParams.firstWrappedX - x);
+ }
+ for (i = 0; i < wrappedPartStart; i++) {
+ GLuint d32;
+ if (mask[i] && visMask[i]) {
+ if (stencil_size > 0) {
+ d32 =
+ GET_ORDINARY_FB_DATA(&ReadParams, GLuint,
+ x + i, y);
+ d32 =
+ (d32 & 0xFF000000) | (depth[i] & 0x00FFFFFF);
+ }
+ else {
+ d32 = depth[i];
+ }
+ PUT_ORDINARY_FB_DATA(&ReadParams, GLuint, x + i, y, d32);
+ }
+ }
+ for (; i < n; i++) {
+ GLuint d32;
+ if (mask[i] && visMask[i]) {
+ if (stencil_size > 0) {
+ d32 =
+ GET_WRAPPED_FB_DATA(&ReadParams, GLuint,
+ x + i, y);
+ d32 =
+ (d32 & 0xFF000000) | (depth[i] & 0x00FFFFFF);
+ }
+ else {
+ d32 = depth[i];
+ }
+ PUT_WRAPPED_FB_DATA(&ReadParams, GLuint, x + i, y, d32);
+ }
+ }
+ }
+ WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+ break;
+ }
+ }
+ else {
+ GLint i;
+ GLuint d32;
+ GLushort d16;
+ GrLfbInfo_t backBufferInfo;
+
+ switch (depth_size) {
+ case 16:
+ GetBackBufferInfo(fxMesa, &backBufferInfo);
+ /*
+ * Note that the _LOCK macro adds a curly brace,
+ * and the UNLOCK macro removes it.
+ */
+ WRITE_FB_SPAN_LOCK(fxMesa, info,
+ GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY);
+ generate_vismask(fxMesa, x, y, n, visMask);
+ {
+ LFBParameters ReadParams;
+ GLuint wrappedPartStart;
+ GetFbParams(fxMesa, &info, &backBufferInfo,
+ &ReadParams, sizeof(GLushort));
+ if (ReadParams.firstWrappedX <= x) {
+ wrappedPartStart = 0;
+ }
+ else if (n <= (ReadParams.firstWrappedX - x)) {
+ wrappedPartStart = n;
+ }
+ else {
+ wrappedPartStart = (ReadParams.firstWrappedX - x);
+ }
+ for (i = 0; i < wrappedPartStart; i++) {
+ if (visMask[i]) {
+ d16 = depth[i];
+ PUT_ORDINARY_FB_DATA(&ReadParams,
+ GLushort,
+ x + i, y,
+ d16);
+ }
+ }
+ for (; i < n; i++) {
+ if (visMask[i]) {
+ d16 = depth[i];
+ PUT_WRAPPED_FB_DATA(&ReadParams,
+ GLushort,
+ x + i, y,
+ d16);
+ }
+ }
+ }
+ WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+ break;
+ case 24:
+ case 32:
+ GetBackBufferInfo(fxMesa, &backBufferInfo);
+ /*
+ * Note that the _LOCK macro adds a curly brace,
+ * and the UNLOCK macro removes it.
+ */
+ WRITE_FB_SPAN_LOCK(fxMesa, info,
+ GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY);
+ generate_vismask(fxMesa, x, y, n, visMask);
+ {
+ LFBParameters ReadParams;
+ GLuint wrappedPartStart;
+
+ GetFbParams(fxMesa, &info, &backBufferInfo,
+ &ReadParams, sizeof(GLuint));
+ if (ReadParams.firstWrappedX <= x) {
+ wrappedPartStart = 0;
+ }
+ else if (n <= (ReadParams.firstWrappedX - x)) {
+ wrappedPartStart = n;
+ }
+ else {
+ wrappedPartStart = (ReadParams.firstWrappedX - x);
+ }
+ for (i = 0; i < wrappedPartStart; i++) {
+ if (visMask[i]) {
+ if (stencil_size > 0) {
+ d32 = GET_ORDINARY_FB_DATA(&ReadParams, GLuint, x + i, y);
+ d32 =
+ (d32 & 0xFF000000) | (depth[i] & 0x00FFFFFF);
+ }
+ else {
+ d32 = depth[i];
+ }
+ PUT_ORDINARY_FB_DATA(&ReadParams, GLuint, x + i, y, d32);
+ }
+ }
+ for (; i < n; i++) {
+ if (visMask[i]) {
+ if (stencil_size > 0) {
+ d32 = GET_WRAPPED_FB_DATA(&ReadParams, GLuint, x + i, y);
+ d32 =
+ (d32 & 0xFF000000) | (depth[i] & 0x00FFFFFF);
+ }
+ else {
+ d32 = depth[i];
+ }
+ PUT_WRAPPED_FB_DATA(&ReadParams, GLuint, x + i, y, d32);
+ }
+ }
+ }
+ WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+ break;
+ }
+ }
+}
+
+static void
+tdfxDDWriteMonoDepthSpan(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, const void *value,
+ const GLubyte mask[])
+{
+ GLuint depthVal = *((GLuint *) value);
+ GLuint depths[MAX_WIDTH];
+ GLuint i;
+ for (i = 0; i < n; i++)
+ depths[i] = depthVal;
+ tdfxDDWriteDepthSpan(ctx, rb, n, x, y, depths, mask);
+}
+
+
+static void
+tdfxDDReadDepthSpan(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, void *values)
+{
+ GLuint *depth = (GLuint *) values;
+ tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
+ GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
+ GLuint i;
+ GLuint depth_size = fxMesa->glCtx->Visual.depthBits;
+ GrLfbInfo_t info;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "tdfxmesa: tdfxDDReadDepthSpan(...)\n");
+ }
+
+ /*
+ * Convert to screen coordinates.
+ */
+ x += fxMesa->x_offset;
+ y = bottom - y;
+ switch (depth_size) {
+ case 16:
+ {
+ LFBParameters ReadParams;
+ GrLfbInfo_t backBufferInfo;
+ int wrappedPartStart;
+ GetBackBufferInfo(fxMesa, &backBufferInfo);
+ /*
+ * Note that the _LOCK macro adds a curly brace,
+ * and the UNLOCK macro removes it.
+ */
+ READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER);
+ GetFbParams(fxMesa, &info, &backBufferInfo,
+ &ReadParams, sizeof(GLushort));
+ if (ReadParams.firstWrappedX <= x) {
+ wrappedPartStart = 0;
+ }
+ else if (n <= (ReadParams.firstWrappedX - x)) {
+ wrappedPartStart = n;
+ }
+ else {
+ wrappedPartStart = (ReadParams.firstWrappedX - x);
+ }
+ /*
+ * Read the line.
+ */
+ for (i = 0; i < wrappedPartStart; i++) {
+ depth[i] =
+ GET_ORDINARY_FB_DATA(&ReadParams, GLushort, x + i, y);
+ }
+ for (; i < n; i++) {
+ depth[i] = GET_WRAPPED_FB_DATA(&ReadParams, GLushort,
+ x + i, y);
+ }
+ READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+ break;
+ }
+ case 24:
+ case 32:
+ {
+ LFBParameters ReadParams;
+ GrLfbInfo_t backBufferInfo;
+ int wrappedPartStart;
+ GLuint stencil_size = fxMesa->glCtx->Visual.stencilBits;
+ GetBackBufferInfo(fxMesa, &backBufferInfo);
+ /*
+ * Note that the _LOCK macro adds a curly brace,
+ * and the UNLOCK macro removes it.
+ */
+ READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER);
+ GetFbParams(fxMesa, &info, &backBufferInfo,
+ &ReadParams, sizeof(GLuint));
+ if (ReadParams.firstWrappedX <= x) {
+ wrappedPartStart = 0;
+ }
+ else if (n <= (ReadParams.firstWrappedX - x)) {
+ wrappedPartStart = n;
+ }
+ else {
+ wrappedPartStart = (ReadParams.firstWrappedX - x);
+ }
+ /*
+ * Read the line.
+ */
+ for (i = 0; i < wrappedPartStart; i++) {
+ const GLuint mask =
+ (stencil_size > 0) ? 0x00FFFFFF : 0xFFFFFFFF;
+ depth[i] =
+ GET_ORDINARY_FB_DATA(&ReadParams, GLuint, x + i, y);
+ depth[i] &= mask;
+ }
+ for (; i < n; i++) {
+ const GLuint mask =
+ (stencil_size > 0) ? 0x00FFFFFF : 0xFFFFFFFF;
+ depth[i] = GET_WRAPPED_FB_DATA(&ReadParams, GLuint, x + i, y);
+ depth[i] &= mask;
+ }
+ READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+ break;
+ }
+ }
+}
+
+
+static void
+tdfxDDWriteDepthPixels(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ const void *values, const GLubyte mask[])
+{
+ const GLuint *depth = (const GLuint *) values;
+ tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
+ GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
+ GLuint i;
+ GLushort d16;
+ GLuint d32;
+ GLuint depth_size = fxMesa->glCtx->Visual.depthBits;
+ GLuint stencil_size = fxMesa->glCtx->Visual.stencilBits;
+ GrLfbInfo_t info;
+ int xpos;
+ int ypos;
+ GrLfbInfo_t backBufferInfo;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "tdfxmesa: tdfxDDWriteDepthPixels(...)\n");
+ }
+
+ switch (depth_size) {
+ case 16:
+ GetBackBufferInfo(fxMesa, &backBufferInfo);
+ /*
+ * Note that the _LOCK macro adds a curly brace,
+ * and the UNLOCK macro removes it.
+ */
+ WRITE_FB_SPAN_LOCK(fxMesa, info,
+ GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY);
+ {
+ LFBParameters ReadParams;
+ GetFbParams(fxMesa, &info, &backBufferInfo,
+ &ReadParams, sizeof(GLushort));
+ for (i = 0; i < n; i++) {
+ if (mask[i] && visible_pixel(fxMesa, x[i], y[i])) {
+ xpos = x[i] + fxMesa->x_offset;
+ ypos = bottom - y[i];
+ d16 = depth[i];
+ PUT_FB_DATA(&ReadParams, GLushort, xpos, ypos, d16);
+ }
+ }
+ }
+ WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+ break;
+ case 24:
+ case 32:
+ GetBackBufferInfo(fxMesa, &backBufferInfo);
+ /*
+ * Note that the _LOCK macro adds a curly brace,
+ * and the UNLOCK macro removes it.
+ */
+ WRITE_FB_SPAN_LOCK(fxMesa, info,
+ GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY);
+ {
+ LFBParameters ReadParams;
+ GetFbParams(fxMesa, &info, &backBufferInfo,
+ &ReadParams, sizeof(GLuint));
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ if (visible_pixel(fxMesa, x[i], y[i])) {
+ xpos = x[i] + fxMesa->x_offset;
+ ypos = bottom - y[i];
+ if (stencil_size > 0) {
+ d32 =
+ GET_FB_DATA(&ReadParams, GLuint, xpos, ypos);
+ d32 = (d32 & 0xFF000000) | (depth[i] & 0xFFFFFF);
+ }
+ else {
+ d32 = depth[i];
+ }
+ PUT_FB_DATA(&ReadParams, GLuint, xpos, ypos, d32);
+ }
+ }
+ }
+ }
+ WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+ break;
+ }
+}
+
+
+static void
+tdfxDDReadDepthPixels(GLcontext * ctx, struct gl_renderbuffer *rb, GLuint n,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLuint *depth = (GLuint *) values;
+ tdfxContextPtr fxMesa = (tdfxContextPtr) ctx->DriverCtx;
+ GLint bottom = fxMesa->height + fxMesa->y_offset - 1;
+ GLuint i;
+ GLuint depth_size = fxMesa->glCtx->Visual.depthBits;
+ GLushort d16;
+ int xpos;
+ int ypos;
+ GrLfbInfo_t info;
+ GLuint stencil_size;
+ GrLfbInfo_t backBufferInfo;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "tdfxmesa: tdfxDDReadDepthPixels(...)\n");
+ }
+
+ assert((depth_size == 16) || (depth_size == 24) || (depth_size == 32));
+ switch (depth_size) {
+ case 16:
+ GetBackBufferInfo(fxMesa, &backBufferInfo);
+ /*
+ * Note that the _LOCK macro adds a curly brace,
+ * and the UNLOCK macro removes it.
+ */
+ READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER);
+ {
+ LFBParameters ReadParams;
+ GetFbParams(fxMesa, &info, &backBufferInfo,
+ &ReadParams, sizeof(GLushort));
+ for (i = 0; i < n; i++) {
+ /*
+ * Convert to screen coordinates.
+ */
+ xpos = x[i] + fxMesa->x_offset;
+ ypos = bottom - y[i];
+ d16 = GET_FB_DATA(&ReadParams, GLushort, xpos, ypos);
+ depth[i] = d16;
+ }
+ }
+ READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+ break;
+ case 24:
+ case 32:
+ GetBackBufferInfo(fxMesa, &backBufferInfo);
+ /*
+ * Note that the _LOCK macro adds a curly brace,
+ * and the UNLOCK macro removes it.
+ */
+ READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER);
+ stencil_size = fxMesa->glCtx->Visual.stencilBits;
+ {
+ LFBParameters ReadParams;
+ GetFbParams(fxMesa, &info, &backBufferInfo,
+ &ReadParams, sizeof(GLuint));
+ for (i = 0; i < n; i++) {
+ GLuint d32;
+
+ /*
+ * Convert to screen coordinates.
+ */
+ xpos = x[i] + fxMesa->x_offset;
+ ypos = bottom - y[i];
+ d32 = GET_FB_DATA(&ReadParams, GLuint, xpos, ypos);
+ if (stencil_size > 0) {
+ d32 &= 0x00FFFFFF;
+ }
+ depth[i] = d32;
+ }
+ }
+ READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+ break;
+ default:
+ assert(0);
+ }
+}
+
+/*
+ * Stencil buffer read/write functions.
+ */
+#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, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *values, const GLubyte mask[])
+{
+ const GLubyte *stencil = (const GLubyte *) values;
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ GrLfbInfo_t backBufferInfo;
+
+ GetBackBufferInfo(fxMesa, &backBufferInfo);
+ /*
+ * Note that the _LOCK macro adds a curly brace,
+ * and the UNLOCK macro removes it.
+ */
+ WRITE_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY);
+ {
+ 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;
+ LFBParameters ReadParams;
+ GLubyte visMask[MAX_WIDTH];
+ GLuint i;
+ int wrappedPartStart;
+
+ GetFbParams(fxMesa, &info, &backBufferInfo, &ReadParams,
+ sizeof(GLuint));
+ if (ReadParams.firstWrappedX <= x) {
+ wrappedPartStart = 0;
+ }
+ else if (n <= (ReadParams.firstWrappedX - x)) {
+ wrappedPartStart = n;
+ }
+ else {
+ wrappedPartStart = (ReadParams.firstWrappedX - x);
+ }
+ generate_vismask(fxMesa, scrX, scrY, n, visMask);
+ for (i = 0; i < wrappedPartStart; i++) {
+ if (visMask[i] && (!mask || mask[i])) {
+ GLuint z = GET_ORDINARY_FB_DATA(&ReadParams, GLuint,
+ scrX + i, scrY) & 0x00FFFFFF;
+ z |= (stencil[i] & 0xFF) << 24;
+ PUT_ORDINARY_FB_DATA(&ReadParams, GLuint, scrX + i, scrY, z);
+ }
+ }
+ for (; i < n; i++) {
+ if (visMask[i] && (!mask || mask[i])) {
+ GLuint z = GET_WRAPPED_FB_DATA(&ReadParams, GLuint,
+ scrX + i, scrY) & 0x00FFFFFF;
+ z |= (stencil[i] & 0xFF) << 24;
+ PUT_WRAPPED_FB_DATA(&ReadParams, GLuint, scrX + i, scrY, z);
+ }
+ }
+ }
+ WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+}
+
+
+static void
+write_mono_stencil_span(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const void *value, const GLubyte mask[])
+{
+ GLbyte stencilVal = *((GLbyte *) value);
+ GLbyte stencils[MAX_WIDTH];
+ GLuint i;
+ for (i = 0; i < n; i++)
+ stencils[i] = stencilVal;
+ write_stencil_span(ctx, rb, n, x, y, stencils, mask);
+}
+
+
+static void
+read_stencil_span(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ void *values)
+{
+ GLubyte *stencil = (GLubyte *) values;
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ GrLfbInfo_t backBufferInfo;
+
+ GetBackBufferInfo(fxMesa, &backBufferInfo);
+ /*
+ * Note that the _LOCK macro adds a curly brace,
+ * and the UNLOCK macro removes it.
+ */
+ READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER);
+ {
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ const GLint winX = fxMesa->x_offset;
+ GLuint i;
+ LFBParameters ReadParams;
+ int wrappedPartStart;
+
+ /*
+ * Convert to screen coordinates.
+ */
+ x += winX;
+ y = winY - y;
+ GetFbParams(fxMesa, &info, &backBufferInfo, &ReadParams,
+ sizeof(GLuint));
+ if (ReadParams.firstWrappedX <= x) {
+ wrappedPartStart = 0;
+ }
+ else if (n <= (ReadParams.firstWrappedX - x)) {
+ wrappedPartStart = n;
+ }
+ else {
+ wrappedPartStart = (ReadParams.firstWrappedX - x);
+ }
+ for (i = 0; i < wrappedPartStart; i++) {
+ stencil[i] = (GET_ORDINARY_FB_DATA(&ReadParams, GLuint,
+ x + i, y) >> 24) & 0xFF;
+ }
+ for (; i < n; i++) {
+ stencil[i] = (GET_WRAPPED_FB_DATA(&ReadParams, GLuint,
+ x + i, y) >> 24) & 0xFF;
+ }
+ }
+ READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+}
+
+
+static void
+write_stencil_pixels(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ const void *values, const GLubyte mask[])
+{
+ const GLubyte *stencil = (const GLubyte *) values;
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ GrLfbInfo_t backBufferInfo;
+
+ GetBackBufferInfo(fxMesa, &backBufferInfo);
+ /*
+ * Note that the _LOCK macro adds a curly brace,
+ * and the UNLOCK macro removes it.
+ */
+ WRITE_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER, GR_LFBWRITEMODE_ANY);
+ {
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ const GLint winX = fxMesa->x_offset;
+ LFBParameters ReadParams;
+ GLuint i;
+
+ GetFbParams(fxMesa, &info, &backBufferInfo, &ReadParams,
+ sizeof(GLuint));
+ for (i = 0; i < n; i++) {
+ const GLint scrX = winX + x[i];
+ const GLint scrY = winY - y[i];
+ if ((!mask || mask[i]) && visible_pixel(fxMesa, scrX, scrY)) {
+ GLuint z =
+ GET_FB_DATA(&ReadParams, GLuint, scrX, scrY) & 0x00FFFFFF;
+ z |= (stencil[i] & 0xFF) << 24;
+ PUT_FB_DATA(&ReadParams, GLuint, scrX, scrY, z);
+ }
+ }
+ }
+ WRITE_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+}
+
+
+static void
+read_stencil_pixels(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[],
+ void *values)
+{
+ GLubyte *stencil = (GLubyte *) values;
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ GrLfbInfo_t backBufferInfo;
+
+ GetBackBufferInfo(fxMesa, &backBufferInfo);
+ /*
+ * Note that the _LOCK macro adds a curly brace,
+ * and the UNLOCK macro removes it.
+ */
+ READ_FB_SPAN_LOCK(fxMesa, info, GR_BUFFER_AUXBUFFER);
+ {
+ const GLint winY = fxMesa->y_offset + fxMesa->height - 1;
+ const GLint winX = fxMesa->x_offset;
+ GLuint i;
+ LFBParameters ReadParams;
+
+ GetFbParams(fxMesa, &info, &backBufferInfo, &ReadParams,
+ sizeof(GLuint));
+ for (i = 0; i < n; i++) {
+ const GLint scrX = winX + x[i];
+ const GLint scrY = winY - y[i];
+ stencil[i] =
+ (GET_FB_DATA(&ReadParams, GLuint, scrX, scrY) >> 24) & 0xFF;
+ }
+ }
+ READ_FB_SPAN_UNLOCK(fxMesa, GR_BUFFER_AUXBUFFER);
+}
+
+#define VISUAL_EQUALS_RGBA(vis, r, g, b, a) \
+ ((vis.redBits == r) && \
+ (vis.greenBits == g) && \
+ (vis.blueBits == b) && \
+ (vis.alphaBits == a))
+
+
+
+
+/**********************************************************************/
+/* Locking for swrast */
+/**********************************************************************/
+
+
+static void tdfxSpanRenderStart( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ LOCK_HARDWARE(fxMesa);
+}
+
+static void tdfxSpanRenderFinish( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ _swrast_flush( ctx );
+ UNLOCK_HARDWARE(fxMesa);
+}
+
+/* Set the buffer used for reading */
+static void tdfxDDSetBuffer( GLcontext *ctx,
+ GLframebuffer *buffer, GLuint bufferBit )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ (void) buffer;
+
+ switch ( bufferBit ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER;
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER;
+ break;
+ default:
+ break;
+ }
+}
+
+/**********************************************************************/
+/* Initialize swrast device driver */
+/**********************************************************************/
+
+void tdfxDDInitSpanFuncs( GLcontext *ctx )
+{
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );
+ swdd->SetBuffer = tdfxDDSetBuffer;
+ swdd->SpanRenderStart = tdfxSpanRenderStart;
+ swdd->SpanRenderFinish = tdfxSpanRenderFinish;
+}
+
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+tdfxSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ drb->Base.GetRow = tdfxReadRGBASpan_RGB565;
+ drb->Base.GetValues = tdfxReadRGBAPixels_RGB565;
+ drb->Base.PutRow = tdfxWriteRGBASpan_RGB565;
+ drb->Base.PutRowRGB = tdfxWriteRGBSpan_RGB565;
+ drb->Base.PutMonoRow = tdfxWriteMonoRGBASpan_RGB565;
+ drb->Base.PutValues = tdfxWriteRGBAPixels_RGB565;
+ drb->Base.PutMonoValues = tdfxWriteMonoRGBAPixels_RGB565;
+ }
+ else if (vis->redBits == 8 && vis->greenBits == 8
+ && vis->blueBits == 8 && vis->alphaBits == 0) {
+ drb->Base.GetRow = tdfxReadRGBASpan_RGB888;
+ drb->Base.GetValues = tdfxReadRGBAPixels_RGB888;
+ drb->Base.PutRow = tdfxWriteRGBASpan_RGB888;
+ drb->Base.PutRowRGB = tdfxWriteRGBSpan_RGB888;
+ drb->Base.PutMonoRow = tdfxWriteMonoRGBASpan_RGB888;
+ drb->Base.PutValues = tdfxWriteRGBAPixels_RGB888;
+ drb->Base.PutMonoValues = tdfxWriteMonoRGBAPixels_RGB888;
+ }
+ else if (vis->redBits == 8 && vis->greenBits == 8
+ && vis->blueBits == 8 && vis->alphaBits == 8) {
+ drb->Base.GetRow = tdfxReadRGBASpan_ARGB8888;
+ drb->Base.GetValues = tdfxReadRGBAPixels_ARGB8888;
+ drb->Base.PutRow = tdfxWriteRGBASpan_ARGB8888;
+ drb->Base.PutRowRGB = tdfxWriteRGBSpan_ARGB8888;
+ drb->Base.PutMonoRow = tdfxWriteMonoRGBASpan_ARGB8888;
+ drb->Base.PutValues = tdfxWriteRGBAPixels_ARGB8888;
+ drb->Base.PutMonoValues = tdfxWriteMonoRGBAPixels_ARGB8888;
+ }
+ else {
+ _mesa_problem(NULL, "problem in tdfxSetSpanFunctions");
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16 ||
+ drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = tdfxDDReadDepthSpan;
+ drb->Base.GetValues = tdfxDDReadDepthPixels;
+ drb->Base.PutRow = tdfxDDWriteDepthSpan;
+ drb->Base.PutMonoRow = tdfxDDWriteMonoDepthSpan;
+ drb->Base.PutValues = tdfxDDWriteDepthPixels;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = read_stencil_span;
+ drb->Base.GetValues = read_stencil_pixels;
+ drb->Base.PutRow = write_stencil_span;
+ drb->Base.PutMonoRow = write_mono_stencil_span;
+ drb->Base.PutValues = write_stencil_pixels;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.h
new file mode 100644
index 000000000..62044144f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_span.h
@@ -0,0 +1,49 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_span.h,v 1.1 2001/03/21 16:14:28 dawes Exp $ */
+
+/*
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ *
+ */
+
+#ifndef __TDFX_SPAN_H__
+#define __TDFX_SPAN_H__
+
+#include "context.h"
+#include "drirenderbuffer.h"
+
+extern void tdfxDDInitSpanFuncs( GLcontext *ctx );
+
+extern void
+tdfxSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.c
new file mode 100644
index 000000000..85d99bb05
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.c
@@ -0,0 +1,1449 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.c,v 1.7 2002/10/30 12:52:00 alanh Exp $ */
+
+/*
+ * New fixes:
+ * Daniel Borca <dborca@users.sourceforge.net>, 19 Jul 2004
+ *
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ * Keith Whitwell <keith@tungstengraphics.com> (port to 3.5)
+ *
+ */
+
+#include "mtypes.h"
+#include "buffers.h"
+#include "colormac.h"
+#include "texformat.h"
+#include "texstore.h"
+#include "teximage.h"
+
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "tdfx_context.h"
+#include "tdfx_state.h"
+#include "tdfx_vb.h"
+#include "tdfx_tex.h"
+#include "tdfx_texman.h"
+#include "tdfx_texstate.h"
+#include "tdfx_tris.h"
+#include "tdfx_render.h"
+
+
+
+/* =============================================================
+ * Alpha blending
+ */
+
+static void tdfxUpdateAlphaMode( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GrCmpFnc_t func;
+ GrAlphaBlendFnc_t srcRGB, dstRGB, srcA, dstA;
+ GrAlphaBlendOp_t eqRGB, eqA;
+ GrAlpha_t ref = (GLint) (ctx->Color.AlphaRef * 255.0);
+
+ GLboolean isNapalm = TDFX_IS_NAPALM(fxMesa);
+ GLboolean have32bpp = (ctx->Visual.greenBits == 8);
+ GLboolean haveAlpha = fxMesa->haveHwAlpha;
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s()\n", __FUNCTION__ );
+ }
+
+ if ( ctx->Color.AlphaEnabled ) {
+ func = ctx->Color.AlphaFunc - GL_NEVER + GR_CMP_NEVER;
+ } else {
+ func = GR_CMP_ALWAYS;
+ }
+
+ if ( ctx->Color.BlendEnabled
+ && (fxMesa->Fallback & TDFX_FALLBACK_BLEND) == 0 ) {
+ switch ( ctx->Color.BlendSrcRGB ) {
+ case GL_ZERO:
+ srcRGB = GR_BLEND_ZERO;
+ break;
+ case GL_ONE:
+ srcRGB = GR_BLEND_ONE;
+ break;
+ case GL_DST_COLOR:
+ srcRGB = GR_BLEND_DST_COLOR;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ srcRGB = GR_BLEND_ONE_MINUS_DST_COLOR;
+ break;
+ case GL_SRC_ALPHA:
+ srcRGB = GR_BLEND_SRC_ALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ srcRGB = GR_BLEND_ONE_MINUS_SRC_ALPHA;
+ break;
+ case GL_DST_ALPHA:
+ srcRGB = haveAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ srcRGB = haveAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ srcRGB = GR_BLEND_ALPHA_SATURATE;
+ break;
+ case GL_SRC_COLOR:
+ if (isNapalm) {
+ srcRGB = GR_BLEND_SAME_COLOR_EXT;
+ break;
+ }
+ case GL_ONE_MINUS_SRC_COLOR:
+ if (isNapalm) {
+ srcRGB = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT;
+ break;
+ }
+ default:
+ srcRGB = GR_BLEND_ONE;
+ }
+
+ switch ( ctx->Color.BlendSrcA ) {
+ case GL_ZERO:
+ srcA = GR_BLEND_ZERO;
+ break;
+ case GL_ONE:
+ srcA = GR_BLEND_ONE;
+ break;
+ case GL_SRC_COLOR:
+ case GL_SRC_ALPHA:
+ srcA = have32bpp ? GR_BLEND_SRC_ALPHA : GR_BLEND_ONE/*JJJ*/;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ srcA = have32bpp ? GR_BLEND_ONE_MINUS_SRC_ALPHA : GR_BLEND_ONE/*JJJ*/;
+ break;
+ case GL_DST_COLOR:
+ case GL_DST_ALPHA:
+ srcA = (have32bpp && haveAlpha) ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ case GL_ONE_MINUS_DST_ALPHA:
+ srcA = (have32bpp && haveAlpha) ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ srcA = GR_BLEND_ONE;
+ break;
+ default:
+ srcA = GR_BLEND_ONE;
+ }
+
+ switch ( ctx->Color.BlendDstRGB ) {
+ case GL_ZERO:
+ dstRGB = GR_BLEND_ZERO;
+ break;
+ case GL_ONE:
+ dstRGB = GR_BLEND_ONE;
+ break;
+ case GL_SRC_COLOR:
+ dstRGB = GR_BLEND_SRC_COLOR;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ dstRGB = GR_BLEND_ONE_MINUS_SRC_COLOR;
+ break;
+ case GL_SRC_ALPHA:
+ dstRGB = GR_BLEND_SRC_ALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ dstRGB = GR_BLEND_ONE_MINUS_SRC_ALPHA;
+ break;
+ case GL_DST_ALPHA:
+ dstRGB = haveAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ dstRGB = haveAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/;
+ break;
+ case GL_DST_COLOR:
+ if (isNapalm) {
+ dstRGB = GR_BLEND_SAME_COLOR_EXT;
+ break;
+ }
+ case GL_ONE_MINUS_DST_COLOR:
+ if (isNapalm) {
+ dstRGB = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT;
+ break;
+ }
+ default:
+ dstRGB = GR_BLEND_ZERO;
+ }
+
+ switch ( ctx->Color.BlendDstA ) {
+ case GL_ZERO:
+ dstA = GR_BLEND_ZERO;
+ break;
+ case GL_ONE:
+ dstA = GR_BLEND_ONE;
+ break;
+ case GL_SRC_COLOR:
+ case GL_SRC_ALPHA:
+ dstA = have32bpp ? GR_BLEND_SRC_ALPHA : GR_BLEND_ZERO/*JJJ*/;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ dstA = have32bpp ? GR_BLEND_ONE_MINUS_SRC_ALPHA : GR_BLEND_ZERO/*JJJ*/;
+ break;
+ case GL_DST_COLOR:
+ case GL_DST_ALPHA:
+ dstA = have32bpp ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ case GL_ONE_MINUS_DST_ALPHA:
+ dstA = have32bpp ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/;
+ break;
+ default:
+ dstA = GR_BLEND_ZERO;
+ }
+
+ switch ( ctx->Color.BlendEquationRGB ) {
+ case GL_FUNC_SUBTRACT:
+ eqRGB = GR_BLEND_OP_SUB;
+ break;
+ case GL_FUNC_REVERSE_SUBTRACT:
+ eqRGB = GR_BLEND_OP_REVSUB;
+ break;
+ case GL_FUNC_ADD:
+ default:
+ eqRGB = GR_BLEND_OP_ADD;
+ break;
+ }
+
+ switch ( ctx->Color.BlendEquationA ) {
+ case GL_FUNC_SUBTRACT:
+ eqA = GR_BLEND_OP_SUB;
+ break;
+ case GL_FUNC_REVERSE_SUBTRACT:
+ eqA = GR_BLEND_OP_REVSUB;
+ break;
+ case GL_FUNC_ADD:
+ default:
+ eqA = GR_BLEND_OP_ADD;
+ break;
+ }
+ } else {
+ /* blend disabled */
+ srcRGB = GR_BLEND_ONE;
+ dstRGB = GR_BLEND_ZERO;
+ eqRGB = GR_BLEND_OP_ADD;
+ srcA = GR_BLEND_ONE;
+ dstA = GR_BLEND_ZERO;
+ eqA = GR_BLEND_OP_ADD;
+ }
+
+ if ( fxMesa->Color.AlphaFunc != func ) {
+ fxMesa->Color.AlphaFunc = func;
+ fxMesa->dirty |= TDFX_UPLOAD_ALPHA_TEST;
+ }
+ if ( fxMesa->Color.AlphaRef != ref ) {
+ fxMesa->Color.AlphaRef = ref;
+ fxMesa->dirty |= TDFX_UPLOAD_ALPHA_REF;
+ }
+
+ if ( fxMesa->Color.BlendSrcRGB != srcRGB ||
+ fxMesa->Color.BlendDstRGB != dstRGB ||
+ fxMesa->Color.BlendEqRGB != eqRGB ||
+ fxMesa->Color.BlendSrcA != srcA ||
+ fxMesa->Color.BlendDstA != dstA ||
+ fxMesa->Color.BlendEqA != eqA )
+ {
+ fxMesa->Color.BlendSrcRGB = srcRGB;
+ fxMesa->Color.BlendDstRGB = dstRGB;
+ fxMesa->Color.BlendEqRGB = eqRGB;
+ fxMesa->Color.BlendSrcA = srcA;
+ fxMesa->Color.BlendDstA = dstA;
+ fxMesa->Color.BlendEqA = eqA;
+ fxMesa->dirty |= TDFX_UPLOAD_BLEND_FUNC;
+ }
+}
+
+static void tdfxDDAlphaFunc( GLcontext *ctx, GLenum func, GLfloat ref )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_ALPHA;
+}
+
+static void tdfxDDBlendEquationSeparate( GLcontext *ctx,
+ GLenum modeRGB, GLenum modeA )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+
+ assert( modeRGB == modeA );
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_ALPHA;
+}
+
+static void tdfxDDBlendFuncSeparate( GLcontext *ctx,
+ GLenum sfactorRGB, GLenum dfactorRGB,
+ GLenum sfactorA, GLenum dfactorA )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_ALPHA;
+
+ /*
+ * XXX - Voodoo5 seems to suffer from precision problems in some
+ * blend modes. To pass all the conformance tests we'd have to
+ * fall back to software for many modes. Revisit someday.
+ */
+}
+
+/* =============================================================
+ * Stipple
+ */
+
+void tdfxUpdateStipple( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+ GrStippleMode_t mode = GR_STIPPLE_DISABLE;
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s()\n", __FUNCTION__ );
+ }
+
+ FLUSH_BATCH( fxMesa );
+
+ if (ctx->Polygon.StippleFlag) {
+ mode = GR_STIPPLE_PATTERN;
+ }
+
+ if ( fxMesa->Stipple.Mode != mode ) {
+ fxMesa->Stipple.Mode = mode;
+ fxMesa->dirty |= TDFX_UPLOAD_STIPPLE;
+ }
+}
+
+
+/* =============================================================
+ * Depth testing
+ */
+
+static void tdfxUpdateZMode( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+ GrCmpFnc_t func;
+ FxI32 bias;
+ FxBool mask;
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_API )
+ fprintf( stderr, "%s()\n", __FUNCTION__ );
+
+
+ bias = (FxI32) (ctx->Polygon.OffsetUnits * TDFX_DEPTH_BIAS_SCALE);
+
+ if ( ctx->Depth.Test ) {
+ func = ctx->Depth.Func - GL_NEVER + GR_CMP_NEVER;
+ mask = ctx->Depth.Mask;
+ }
+ else {
+ /* depth testing disabled */
+ func = GR_CMP_ALWAYS; /* fragments always pass */
+ mask = FXFALSE; /* zbuffer is not touched */
+ }
+
+ fxMesa->Depth.Clear = (FxU32) (ctx->DrawBuffer->_DepthMaxF * ctx->Depth.Clear);
+
+ if ( fxMesa->Depth.Bias != bias ) {
+ fxMesa->Depth.Bias = bias;
+ fxMesa->dirty |= TDFX_UPLOAD_DEPTH_BIAS;
+ }
+ if ( fxMesa->Depth.Func != func ) {
+ fxMesa->Depth.Func = func;
+ fxMesa->dirty |= TDFX_UPLOAD_DEPTH_FUNC | TDFX_UPLOAD_DEPTH_MASK;
+ }
+ if ( fxMesa->Depth.Mask != mask ) {
+ fxMesa->Depth.Mask = mask;
+ fxMesa->dirty |= TDFX_UPLOAD_DEPTH_MASK;
+ }
+}
+
+static void tdfxDDDepthFunc( GLcontext *ctx, GLenum func )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_DEPTH;
+}
+
+static void tdfxDDDepthMask( GLcontext *ctx, GLboolean flag )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_DEPTH;
+}
+
+static void tdfxDDClearDepth( GLcontext *ctx, GLclampd d )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_DEPTH;
+}
+
+
+
+/* =============================================================
+ * Stencil
+ */
+
+
+/* Evaluate all stencil state and make the Glide calls.
+ */
+static GrStencil_t convertGLStencilOp( 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;
+ case GL_INCR_WRAP_EXT:
+ return GR_STENCILOP_INCR_WRAP;
+ case GL_DECR_WRAP_EXT:
+ return GR_STENCILOP_DECR_WRAP;
+ default:
+ _mesa_problem( NULL, "bad stencil op in convertGLStencilOp" );
+ }
+ return GR_STENCILOP_KEEP; /* never get, silence compiler warning */
+}
+
+
+static void tdfxUpdateStencil( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s()\n", __FUNCTION__ );
+ }
+
+ if (fxMesa->haveHwStencil) {
+ if (ctx->Stencil.Enabled) {
+ fxMesa->Stencil.Function = ctx->Stencil.Function[0] - GL_NEVER + GR_CMP_NEVER;
+ fxMesa->Stencil.RefValue = ctx->Stencil.Ref[0];
+ fxMesa->Stencil.ValueMask = ctx->Stencil.ValueMask[0];
+ fxMesa->Stencil.WriteMask = ctx->Stencil.WriteMask[0];
+ fxMesa->Stencil.FailFunc = convertGLStencilOp(ctx->Stencil.FailFunc[0]);
+ fxMesa->Stencil.ZFailFunc = convertGLStencilOp(ctx->Stencil.ZFailFunc[0]);
+ fxMesa->Stencil.ZPassFunc = convertGLStencilOp(ctx->Stencil.ZPassFunc[0]);
+ fxMesa->Stencil.Clear = ctx->Stencil.Clear & 0xff;
+ }
+ fxMesa->dirty |= TDFX_UPLOAD_STENCIL;
+ }
+}
+
+
+static void tdfxDDStencilFunc( GLcontext *ctx, GLenum func,
+ GLint ref, GLuint mask )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_STENCIL;
+}
+
+static void tdfxDDStencilMask( GLcontext *ctx, GLuint mask )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_STENCIL;
+}
+
+static void tdfxDDStencilOp( GLcontext *ctx, GLenum sfail,
+ GLenum zfail, GLenum zpass )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_STENCIL;
+}
+
+
+/* =============================================================
+ * Fog - orthographic fog still not working
+ */
+
+static void tdfxUpdateFogAttrib( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GrFogMode_t mode;
+ GrColor_t color;
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s()\n", __FUNCTION__ );
+ }
+
+ if ( ctx->Fog.Enabled ) {
+ if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) {
+ mode = GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT;
+ } else {
+ mode = GR_FOG_WITH_TABLE_ON_Q;
+ }
+ } else {
+ mode = GR_FOG_DISABLE;
+ }
+
+ color = TDFXPACKCOLOR888((GLubyte)(ctx->Fog.Color[0]*255.0F),
+ (GLubyte)(ctx->Fog.Color[1]*255.0F),
+ (GLubyte)(ctx->Fog.Color[2]*255.0F));
+
+ if ( fxMesa->Fog.Mode != mode ) {
+ fxMesa->Fog.Mode = mode;
+ fxMesa->dirty |= TDFX_UPLOAD_FOG_MODE;
+ fxMesa->dirty |= TDFX_UPLOAD_VERTEX_LAYOUT;/*JJJ*/
+ }
+ if ( fxMesa->Fog.Color != color ) {
+ fxMesa->Fog.Color = color;
+ fxMesa->dirty |= TDFX_UPLOAD_FOG_COLOR;
+ }
+ if ( fxMesa->Fog.TableMode != ctx->Fog.Mode ||
+ fxMesa->Fog.Density != ctx->Fog.Density ||
+ fxMesa->Fog.Near != ctx->Fog.Start ||
+ fxMesa->Fog.Far != ctx->Fog.End )
+ {
+ switch( ctx->Fog.Mode ) {
+ case GL_EXP:
+ fxMesa->Glide.guFogGenerateExp( fxMesa->Fog.Table, ctx->Fog.Density );
+ break;
+ case GL_EXP2:
+ fxMesa->Glide.guFogGenerateExp2( fxMesa->Fog.Table, ctx->Fog.Density);
+ break;
+ case GL_LINEAR:
+ fxMesa->Glide.guFogGenerateLinear( fxMesa->Fog.Table,
+ ctx->Fog.Start, ctx->Fog.End );
+ break;
+ }
+
+ fxMesa->Fog.TableMode = ctx->Fog.Mode;
+ fxMesa->Fog.Density = ctx->Fog.Density;
+ fxMesa->Fog.Near = ctx->Fog.Start;
+ fxMesa->Fog.Far = ctx->Fog.End;
+ fxMesa->dirty |= TDFX_UPLOAD_FOG_TABLE;
+ }
+}
+
+static void tdfxDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_FOG;
+
+ switch (pname) {
+ case GL_FOG_COORDINATE_SOURCE_EXT: {
+ GLenum p = (GLenum)*param;
+ if (p == GL_FOG_COORDINATE_EXT) {
+ _swrast_allow_vertex_fog(ctx, GL_TRUE);
+ _swrast_allow_pixel_fog(ctx, GL_FALSE);
+ _tnl_allow_vertex_fog( ctx, GL_TRUE);
+ _tnl_allow_pixel_fog( ctx, GL_FALSE);
+ } else {
+ _swrast_allow_vertex_fog(ctx, GL_FALSE);
+ _swrast_allow_pixel_fog(ctx, GL_TRUE);
+ _tnl_allow_vertex_fog( ctx, GL_FALSE);
+ _tnl_allow_pixel_fog( ctx, GL_TRUE);
+ }
+ break;
+ }
+ default:
+ ;
+ }
+}
+
+
+/* =============================================================
+ * Clipping
+ */
+
+static int intersect_rect( drm_clip_rect_t *out,
+ const drm_clip_rect_t *a,
+ const drm_clip_rect_t *b)
+{
+ *out = *a;
+ if (b->x1 > out->x1) out->x1 = b->x1;
+ if (b->y1 > out->y1) out->y1 = b->y1;
+ if (b->x2 < out->x2) out->x2 = b->x2;
+ if (b->y2 < out->y2) out->y2 = b->y2;
+ if (out->x1 >= out->x2) return 0;
+ if (out->y1 >= out->y2) return 0;
+ return 1;
+}
+
+
+/*
+ * Examine XF86 cliprect list and scissor state to recompute our
+ * cliprect list.
+ */
+void tdfxUpdateClipping( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = fxMesa->driDrawable;
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s()\n", __FUNCTION__ );
+ }
+
+ assert(ctx);
+ assert(fxMesa);
+ assert(dPriv);
+
+ if ( dPriv->x != fxMesa->x_offset || dPriv->y != fxMesa->y_offset ||
+ dPriv->w != fxMesa->width || dPriv->h != fxMesa->height ) {
+ fxMesa->x_offset = dPriv->x;
+ fxMesa->y_offset = dPriv->y;
+ fxMesa->width = dPriv->w;
+ fxMesa->height = dPriv->h;
+ fxMesa->y_delta =
+ fxMesa->screen_height - fxMesa->y_offset - fxMesa->height;
+ tdfxUpdateViewport( ctx );
+ }
+
+ if (fxMesa->scissoredClipRects && fxMesa->pClipRects) {
+ free(fxMesa->pClipRects);
+ }
+
+ if (ctx->Scissor.Enabled) {
+ /* intersect OpenGL scissor box with all cliprects to make a new
+ * list of cliprects.
+ */
+ drm_clip_rect_t scissor;
+ int x1 = ctx->Scissor.X + fxMesa->x_offset;
+ int y1 = fxMesa->screen_height - fxMesa->y_delta
+ - ctx->Scissor.Y - ctx->Scissor.Height;
+ int x2 = x1 + ctx->Scissor.Width;
+ int y2 = y1 + ctx->Scissor.Height;
+ scissor.x1 = MAX2(x1, 0);
+ scissor.y1 = MAX2(y1, 0);
+ scissor.x2 = MAX2(x2, 0);
+ scissor.y2 = MAX2(y2, 0);
+
+ assert(scissor.x2 >= scissor.x1);
+ assert(scissor.y2 >= scissor.y1);
+
+ fxMesa->pClipRects = malloc(dPriv->numClipRects
+ * sizeof(drm_clip_rect_t));
+ if (fxMesa->pClipRects) {
+ int i;
+ fxMesa->numClipRects = 0;
+ for (i = 0; i < dPriv->numClipRects; i++) {
+ if (intersect_rect(&fxMesa->pClipRects[fxMesa->numClipRects],
+ &scissor, &dPriv->pClipRects[i])) {
+ fxMesa->numClipRects++;
+ }
+ }
+ fxMesa->scissoredClipRects = GL_TRUE;
+ }
+ else {
+ /* out of memory, forgo scissor */
+ fxMesa->numClipRects = dPriv->numClipRects;
+ fxMesa->pClipRects = dPriv->pClipRects;
+ fxMesa->scissoredClipRects = GL_FALSE;
+ }
+ }
+ else {
+ fxMesa->numClipRects = dPriv->numClipRects;
+ fxMesa->pClipRects = dPriv->pClipRects;
+ fxMesa->scissoredClipRects = GL_FALSE;
+ }
+
+ fxMesa->dirty |= TDFX_UPLOAD_CLIP;
+}
+
+
+
+/* =============================================================
+ * Culling
+ */
+
+void tdfxUpdateCull( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GrCullMode_t mode = GR_CULL_DISABLE;
+
+ /* KW: don't need to check raster_primitive here as we don't
+ * attempt to draw lines or points with triangles.
+ */
+ if ( ctx->Polygon.CullFlag ) {
+ switch ( ctx->Polygon.CullFaceMode ) {
+ case GL_FRONT:
+ if ( ctx->Polygon.FrontFace == GL_CCW ) {
+ mode = GR_CULL_POSITIVE;
+ } else {
+ mode = GR_CULL_NEGATIVE;
+ }
+ break;
+
+ case GL_BACK:
+ if ( ctx->Polygon.FrontFace == GL_CCW ) {
+ mode = GR_CULL_NEGATIVE;
+ } else {
+ mode = GR_CULL_POSITIVE;
+ }
+ break;
+
+ case GL_FRONT_AND_BACK:
+ /* Handled as a fallback on triangles in tdfx_tris.c */
+ return;
+
+ default:
+ ASSERT(0);
+ break;
+ }
+ }
+
+ if ( fxMesa->CullMode != mode ) {
+ fxMesa->CullMode = mode;
+ fxMesa->dirty |= TDFX_UPLOAD_CULL;
+ }
+}
+
+static void tdfxDDCullFace( GLcontext *ctx, GLenum mode )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_CULL;
+}
+
+static void tdfxDDFrontFace( GLcontext *ctx, GLenum mode )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_CULL;
+}
+
+
+/* =============================================================
+ * Line drawing.
+ */
+
+static void tdfxUpdateLine( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s()\n", __FUNCTION__ );
+ }
+
+ FLUSH_BATCH( fxMesa );
+ fxMesa->dirty |= TDFX_UPLOAD_LINE;
+}
+
+
+static void tdfxDDLineWidth( GLcontext *ctx, GLfloat width )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_LINE;
+}
+
+
+/* =============================================================
+ * Color Attributes
+ */
+
+static void tdfxDDColorMask( GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ FLUSH_BATCH( fxMesa );
+
+ if ( fxMesa->Color.ColorMask[RCOMP] != r ||
+ fxMesa->Color.ColorMask[GCOMP] != g ||
+ fxMesa->Color.ColorMask[BCOMP] != b ||
+ fxMesa->Color.ColorMask[ACOMP] != a ) {
+ fxMesa->Color.ColorMask[RCOMP] = r;
+ fxMesa->Color.ColorMask[GCOMP] = g;
+ fxMesa->Color.ColorMask[BCOMP] = b;
+ fxMesa->Color.ColorMask[ACOMP] = a;
+ fxMesa->dirty |= TDFX_UPLOAD_COLOR_MASK;
+
+ if (ctx->Visual.redBits < 8) {
+ /* Can't do RGB colormasking in 16bpp mode. */
+ /* We can completely ignore the alpha mask. */
+ FALLBACK( fxMesa, TDFX_FALLBACK_COLORMASK, (r != g || g != b) );
+ }
+ }
+}
+
+
+static void tdfxDDClearColor( GLcontext *ctx,
+ const GLfloat color[4] )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLubyte c[4];
+ FLUSH_BATCH( fxMesa );
+ CLAMPED_FLOAT_TO_UBYTE(c[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(c[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(c[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(c[3], color[3]);
+ fxMesa->Color.ClearColor = TDFXPACKCOLOR888( c[0], c[1], c[2] );
+ fxMesa->Color.ClearAlpha = c[3];
+}
+
+
+/* =============================================================
+ * Light Model
+ */
+
+static void tdfxDDLightModelfv( GLcontext *ctx, GLenum pname,
+ const GLfloat *param )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ if ( pname == GL_LIGHT_MODEL_COLOR_CONTROL ) {
+ FALLBACK( fxMesa, TDFX_FALLBACK_SPECULAR,
+ (ctx->Light.Enabled &&
+ ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ));
+ }
+}
+
+static void tdfxDDShadeModel( GLcontext *ctx, GLenum mode )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ /* FIXME: Can we implement native flat shading? */
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+}
+
+
+/* =============================================================
+ * Scissor
+ */
+
+static void
+tdfxDDScissor(GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_CLIP;
+}
+
+/* =============================================================
+ * Render
+ */
+
+static void tdfxUpdateRenderAttrib( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ FLUSH_BATCH( fxMesa );
+ fxMesa->dirty |= TDFX_UPLOAD_RENDER_BUFFER;
+}
+
+/* =============================================================
+ * Viewport
+ */
+
+void tdfxUpdateViewport( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat *m = fxMesa->hw_viewport;
+
+ m[MAT_SX] = v[MAT_SX];
+ m[MAT_TX] = v[MAT_TX] + fxMesa->x_offset + TRI_X_OFFSET;
+ m[MAT_SY] = v[MAT_SY];
+ m[MAT_TY] = v[MAT_TY] + fxMesa->y_delta + TRI_Y_OFFSET;
+ m[MAT_SZ] = v[MAT_SZ];
+ m[MAT_TZ] = v[MAT_TZ];
+
+ fxMesa->SetupNewInputs |= VERT_BIT_POS;
+}
+
+
+static void tdfxDDViewport( GLcontext *ctx, GLint x, GLint y,
+ GLsizei w, GLsizei h )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_VIEWPORT;
+}
+
+
+static void tdfxDDDepthRange( GLcontext *ctx, GLclampd nearVal, GLclampd farVal )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_VIEWPORT;
+}
+
+
+/* =============================================================
+ * State enable/disable
+ */
+
+static void tdfxDDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+
+ switch ( cap ) {
+ case GL_ALPHA_TEST:
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_ALPHA;
+ break;
+
+ case GL_BLEND:
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_ALPHA;
+ FALLBACK( fxMesa, TDFX_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY)/*JJJ - more blending*/);
+ break;
+
+ case GL_CULL_FACE:
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_CULL;
+ break;
+
+ case GL_DEPTH_TEST:
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_DEPTH;
+ break;
+
+ case GL_DITHER:
+ FLUSH_BATCH( fxMesa );
+ if ( state ) {
+ fxMesa->Color.Dither = GR_DITHER_2x2;
+ } else {
+ fxMesa->Color.Dither = GR_DITHER_DISABLE;
+ }
+ fxMesa->dirty |= TDFX_UPLOAD_DITHER;
+ break;
+
+ case GL_FOG:
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_FOG;
+ break;
+
+ case GL_COLOR_LOGIC_OP:
+ FALLBACK( fxMesa, TDFX_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
+ break;
+
+ case GL_LIGHTING:
+ FALLBACK( fxMesa, TDFX_FALLBACK_SPECULAR,
+ (ctx->Light.Enabled &&
+ ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ));
+ break;
+
+ case GL_LINE_SMOOTH:
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_LINE;
+ break;
+
+ case GL_LINE_STIPPLE:
+ FALLBACK(fxMesa, TDFX_FALLBACK_LINE_STIPPLE, state);
+ break;
+
+ case GL_POLYGON_STIPPLE:
+ FLUSH_BATCH(fxMesa);
+ fxMesa->new_state |= TDFX_NEW_STIPPLE;
+ break;
+
+ case GL_SCISSOR_TEST:
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_CLIP;
+ break;
+
+ case GL_STENCIL_TEST:
+ FLUSH_BATCH( fxMesa );
+ FALLBACK( fxMesa, TDFX_FALLBACK_STENCIL, state && !fxMesa->haveHwStencil);
+ fxMesa->new_state |= TDFX_NEW_STENCIL;
+ break;
+
+ case GL_TEXTURE_3D:
+ FLUSH_BATCH( fxMesa );
+ FALLBACK( fxMesa, TDFX_FALLBACK_TEXTURE_MAP, state); /* wrong */
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+ break;
+
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ FLUSH_BATCH( fxMesa );
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+ break;
+
+ default:
+ return;
+ }
+}
+
+
+
+/* Set the buffer used for drawing */
+/* XXX support for separate read/draw buffers hasn't been tested */
+static void tdfxDDDrawBuffer( GLcontext *ctx, GLenum mode )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s()\n", __FUNCTION__ );
+ }
+
+ FLUSH_BATCH( fxMesa );
+
+ /*
+ * _ColorDrawBufferMask is easier to cope with than <mode>.
+ */
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER;
+ fxMesa->new_state |= TDFX_NEW_RENDER;
+ FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ fxMesa->DrawBuffer = fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER;
+ fxMesa->new_state |= TDFX_NEW_RENDER;
+ FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ break;
+ case 0:
+ FX_grColorMaskv( ctx, false4 );
+ FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ break;
+ default:
+ FALLBACK( fxMesa, TDFX_FALLBACK_DRAW_BUFFER, GL_TRUE );
+ break;
+ }
+
+ /* We want to update the s/w rast state too so that tdfxDDSetBuffer()
+ * gets called.
+ */
+ _swrast_DrawBuffer(ctx, mode);
+}
+
+
+static void tdfxDDReadBuffer( GLcontext *ctx, GLenum mode )
+{
+ /* XXX ??? */
+}
+
+
+/* =============================================================
+ * Polygon stipple
+ */
+
+static void tdfxDDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ const GLubyte *m = mask;
+ GLubyte q[4];
+ int i,j,k;
+ GLboolean allBitsSet;
+
+/* int active = (ctx->Polygon.StippleFlag && */
+/* fxMesa->reduced_prim == GL_TRIANGLES); */
+
+ FLUSH_BATCH(fxMesa);
+ fxMesa->Stipple.Pattern = 0xffffffff;
+ fxMesa->dirty |= TDFX_UPLOAD_STIPPLE;
+ fxMesa->new_state |= TDFX_NEW_STIPPLE;
+
+ /* Check if the stipple pattern is fully opaque. If so, use software
+ * rendering. This basically a trick to make sure the OpenGL conformance
+ * test passes.
+ */
+ allBitsSet = GL_TRUE;
+ for (i = 0; i < 32; i++) {
+ if (((GLuint *) mask)[i] != 0xffffffff) {
+ allBitsSet = GL_FALSE;
+ break;
+ }
+ }
+ if (allBitsSet) {
+ fxMesa->haveHwStipple = GL_FALSE;
+ return;
+ }
+
+ q[0] = mask[0];
+ q[1] = mask[4];
+ q[2] = mask[8];
+ q[3] = mask[12];
+
+ for (k = 0 ; k < 8 ; k++)
+ for (j = 0 ; j < 4; j++)
+ for (i = 0 ; i < 4 ; i++,m++) {
+ if (*m != q[j]) {
+ fxMesa->haveHwStipple = GL_FALSE;
+ return;
+ }
+ }
+
+ fxMesa->haveHwStipple = GL_TRUE;
+ fxMesa->Stipple.Pattern = ( (q[0] << 0) |
+ (q[1] << 8) |
+ (q[2] << 16) |
+ (q[3] << 24) );
+}
+
+
+
+static void tdfxDDRenderMode( GLcontext *ctx, GLenum mode )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ FALLBACK( fxMesa, TDFX_FALLBACK_RENDER_MODE, (mode != GL_RENDER) );
+}
+
+
+
+static void tdfxDDPrintState( const char *msg, GLuint flags )
+{
+ fprintf( stderr,
+ "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+ msg,
+ flags,
+ (flags & TDFX_NEW_COLOR) ? "color, " : "",
+ (flags & TDFX_NEW_ALPHA) ? "alpha, " : "",
+ (flags & TDFX_NEW_DEPTH) ? "depth, " : "",
+ (flags & TDFX_NEW_RENDER) ? "render, " : "",
+ (flags & TDFX_NEW_FOG) ? "fog, " : "",
+ (flags & TDFX_NEW_STENCIL) ? "stencil, " : "",
+ (flags & TDFX_NEW_STIPPLE) ? "stipple, " : "",
+ (flags & TDFX_NEW_CLIP) ? "clip, " : "",
+ (flags & TDFX_NEW_VIEWPORT) ? "viewport, " : "",
+ (flags & TDFX_NEW_CULL) ? "cull, " : "",
+ (flags & TDFX_NEW_GLIDE) ? "glide, " : "",
+ (flags & TDFX_NEW_TEXTURE) ? "texture, " : "",
+ (flags & TDFX_NEW_CONTEXT) ? "context, " : "");
+}
+
+
+
+void tdfxDDUpdateHwState( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ int new_state = fxMesa->new_state;
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
+ fprintf( stderr, "%s()\n", __FUNCTION__ );
+ }
+
+ if ( new_state )
+ {
+ FLUSH_BATCH( fxMesa );
+
+ fxMesa->new_state = 0;
+
+ if ( 0 )
+ tdfxDDPrintState( "tdfxUpdateHwState", new_state );
+
+ /* Update the various parts of the context's state.
+ */
+ if ( new_state & TDFX_NEW_ALPHA ) {
+ tdfxUpdateAlphaMode( ctx );
+ }
+
+ if ( new_state & TDFX_NEW_DEPTH )
+ tdfxUpdateZMode( ctx );
+
+ if ( new_state & TDFX_NEW_FOG )
+ tdfxUpdateFogAttrib( ctx );
+
+ if ( new_state & TDFX_NEW_CLIP )
+ tdfxUpdateClipping( ctx );
+
+ if ( new_state & TDFX_NEW_STIPPLE )
+ tdfxUpdateStipple( ctx );
+
+ if ( new_state & TDFX_NEW_CULL )
+ tdfxUpdateCull( ctx );
+
+ if ( new_state & TDFX_NEW_LINE )
+ tdfxUpdateLine( ctx );
+
+ if ( new_state & TDFX_NEW_VIEWPORT )
+ tdfxUpdateViewport( ctx );
+
+ if ( new_state & TDFX_NEW_RENDER )
+ tdfxUpdateRenderAttrib( ctx );
+
+ if ( new_state & TDFX_NEW_STENCIL )
+ tdfxUpdateStencil( ctx );
+
+ if ( new_state & TDFX_NEW_TEXTURE ) {
+ tdfxUpdateTextureState( ctx );
+ }
+ else if ( new_state & TDFX_NEW_TEXTURE_BIND ) {
+ tdfxUpdateTextureBinding( ctx );
+ }
+ }
+
+ if ( 0 ) {
+ FxI32 bias = (FxI32) (ctx->Polygon.OffsetUnits * TDFX_DEPTH_BIAS_SCALE);
+
+ if ( fxMesa->Depth.Bias != bias ) {
+ fxMesa->Depth.Bias = bias;
+ fxMesa->dirty |= TDFX_UPLOAD_DEPTH_BIAS;
+ }
+ }
+
+ if ( fxMesa->dirty ) {
+ LOCK_HARDWARE( fxMesa );
+ tdfxEmitHwStateLocked( fxMesa );
+ UNLOCK_HARDWARE( fxMesa );
+ }
+}
+
+
+static void tdfxDDInvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ TDFX_CONTEXT(ctx)->new_gl_state |= new_state;
+}
+
+
+
+/* Initialize the context's Glide state mirror. These values will be
+ * used as Glide function call parameters when the time comes.
+ */
+void tdfxInitState( tdfxContextPtr fxMesa )
+{
+ GLcontext *ctx = fxMesa->glCtx;
+ GLint i;
+
+ fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_NONE;
+ fxMesa->ColorCombine.Local = GR_COMBINE_LOCAL_ITERATED;
+ fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_NONE;
+ fxMesa->ColorCombine.Invert = FXFALSE;
+ fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE;
+ fxMesa->AlphaCombine.Local = GR_COMBINE_LOCAL_ITERATED;
+ fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE;
+ fxMesa->AlphaCombine.Invert = FXFALSE;
+
+ fxMesa->ColorCombineExt.SourceA = GR_CMBX_ITRGB;
+ fxMesa->ColorCombineExt.ModeA = GR_FUNC_MODE_X;
+ fxMesa->ColorCombineExt.SourceB = GR_CMBX_ZERO;
+ fxMesa->ColorCombineExt.ModeB = GR_FUNC_MODE_ZERO;
+ fxMesa->ColorCombineExt.SourceC = GR_CMBX_ZERO;
+ fxMesa->ColorCombineExt.InvertC = FXTRUE;
+ fxMesa->ColorCombineExt.SourceD = GR_CMBX_ZERO;
+ fxMesa->ColorCombineExt.InvertD = FXFALSE;
+ fxMesa->ColorCombineExt.Shift = 0;
+ fxMesa->ColorCombineExt.Invert = FXFALSE;
+ fxMesa->AlphaCombineExt.SourceA = GR_CMBX_ITALPHA;
+ fxMesa->AlphaCombineExt.ModeA = GR_FUNC_MODE_X;
+ fxMesa->AlphaCombineExt.SourceB = GR_CMBX_ZERO;
+ fxMesa->AlphaCombineExt.ModeB = GR_FUNC_MODE_ZERO;
+ fxMesa->AlphaCombineExt.SourceC = GR_CMBX_ZERO;
+ fxMesa->AlphaCombineExt.InvertC = FXTRUE;
+ fxMesa->AlphaCombineExt.SourceD = GR_CMBX_ZERO;
+ fxMesa->AlphaCombineExt.InvertD = FXFALSE;
+ fxMesa->AlphaCombineExt.Shift = 0;
+ fxMesa->AlphaCombineExt.Invert = FXFALSE;
+
+ fxMesa->sScale0 = fxMesa->tScale0 = 1.0;
+ fxMesa->sScale1 = fxMesa->tScale1 = 1.0;
+
+ fxMesa->TexPalette.Type = 0;
+ fxMesa->TexPalette.Data = NULL;
+
+ for ( i = 0 ; i < TDFX_NUM_TMU ; i++ ) {
+ fxMesa->TexSource[i].StartAddress = 0;
+ fxMesa->TexSource[i].EvenOdd = GR_MIPMAPLEVELMASK_EVEN;
+ fxMesa->TexSource[i].Info = NULL;
+
+ fxMesa->TexCombine[i].FunctionRGB = 0;
+ fxMesa->TexCombine[i].FactorRGB = 0;
+ fxMesa->TexCombine[i].FunctionAlpha = 0;
+ fxMesa->TexCombine[i].FactorAlpha = 0;
+ fxMesa->TexCombine[i].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[i].InvertAlpha = FXFALSE;
+
+ fxMesa->TexCombineExt[i].Alpha.SourceA = 0;
+ /* XXX more state to init here */
+ fxMesa->TexCombineExt[i].Color.SourceA = 0;
+ fxMesa->TexCombineExt[i].EnvColor = 0x0;
+
+ fxMesa->TexParams[i].sClamp = GR_TEXTURECLAMP_WRAP;
+ fxMesa->TexParams[i].tClamp = GR_TEXTURECLAMP_WRAP;
+ fxMesa->TexParams[i].minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ fxMesa->TexParams[i].magFilt = GR_TEXTUREFILTER_BILINEAR;
+ fxMesa->TexParams[i].mmMode = GR_MIPMAP_DISABLE;
+ fxMesa->TexParams[i].LODblend = FXFALSE;
+ fxMesa->TexParams[i].LodBias = 0.0;
+
+ fxMesa->TexState.EnvMode[i] = ~0;
+ fxMesa->TexState.TexFormat[i] = ~0;
+ fxMesa->TexState.Enabled[i] = 0;
+ }
+
+ if ( ctx->Visual.doubleBufferMode) {
+ fxMesa->DrawBuffer = GR_BUFFER_BACKBUFFER;
+ fxMesa->ReadBuffer = GR_BUFFER_BACKBUFFER;
+ } else {
+ fxMesa->DrawBuffer = GR_BUFFER_FRONTBUFFER;
+ fxMesa->ReadBuffer = GR_BUFFER_FRONTBUFFER;
+ }
+
+ fxMesa->Color.ClearColor = 0x00000000;
+ fxMesa->Color.ClearAlpha = 0x00;
+ fxMesa->Color.ColorMask[RCOMP] = FXTRUE;
+ fxMesa->Color.ColorMask[BCOMP] = FXTRUE;
+ fxMesa->Color.ColorMask[GCOMP] = FXTRUE;
+ fxMesa->Color.ColorMask[ACOMP] = FXTRUE;
+ fxMesa->Color.MonoColor = 0xffffffff;
+
+ fxMesa->Color.AlphaFunc = GR_CMP_ALWAYS;
+ fxMesa->Color.AlphaRef = 0x00;
+ fxMesa->Color.BlendSrcRGB = GR_BLEND_ONE;
+ fxMesa->Color.BlendDstRGB = GR_BLEND_ZERO;
+ fxMesa->Color.BlendSrcA = GR_BLEND_ONE;
+ fxMesa->Color.BlendSrcA = GR_BLEND_ZERO;
+
+ fxMesa->Color.Dither = GR_DITHER_2x2;
+
+ if ( fxMesa->glCtx->Visual.depthBits > 0 ) {
+ fxMesa->Depth.Mode = GR_DEPTHBUFFER_ZBUFFER;
+ } else {
+ fxMesa->Depth.Mode = GR_DEPTHBUFFER_DISABLE;
+ }
+ fxMesa->Depth.Bias = 0;
+ fxMesa->Depth.Func = GR_CMP_LESS;
+ fxMesa->Depth.Clear = 0; /* computed later */
+ fxMesa->Depth.Mask = FXTRUE;
+
+
+ fxMesa->Fog.Mode = GR_FOG_DISABLE;
+ fxMesa->Fog.Color = 0x00000000;
+ fxMesa->Fog.Table = NULL;
+ fxMesa->Fog.Density = 1.0;
+ fxMesa->Fog.Near = 1.0;
+ fxMesa->Fog.Far = 1.0;
+
+ fxMesa->Stencil.Function = GR_CMP_ALWAYS;
+ fxMesa->Stencil.RefValue = 0;
+ fxMesa->Stencil.ValueMask = 0xff;
+ fxMesa->Stencil.WriteMask = 0xff;
+ fxMesa->Stencil.FailFunc = 0;
+ fxMesa->Stencil.ZFailFunc = 0;
+ fxMesa->Stencil.ZPassFunc = 0;
+ fxMesa->Stencil.Clear = 0;
+
+ fxMesa->Stipple.Mode = GR_STIPPLE_DISABLE;
+ fxMesa->Stipple.Pattern = 0xffffffff;
+
+ fxMesa->Scissor.minX = 0;
+ fxMesa->Scissor.minY = 0;
+ fxMesa->Scissor.maxX = 0;
+ fxMesa->Scissor.maxY = 0;
+
+ fxMesa->Viewport.Mode = GR_WINDOW_COORDS;
+ fxMesa->Viewport.X = 0;
+ fxMesa->Viewport.Y = 0;
+ fxMesa->Viewport.Width = 0;
+ fxMesa->Viewport.Height = 0;
+ fxMesa->Viewport.Near = 0.0;
+ fxMesa->Viewport.Far = 0.0;
+
+ fxMesa->CullMode = GR_CULL_DISABLE;
+
+ fxMesa->Glide.ColorFormat = GR_COLORFORMAT_ABGR;
+ fxMesa->Glide.Origin = GR_ORIGIN_LOWER_LEFT;
+ fxMesa->Glide.Initialized = FXFALSE;
+}
+
+
+
+void tdfxDDInitStateFuncs( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ ctx->Driver.UpdateState = tdfxDDInvalidateState;
+
+
+ /* State notification callbacks:
+ */
+ ctx->Driver.ClearColor = tdfxDDClearColor;
+ ctx->Driver.DrawBuffer = tdfxDDDrawBuffer;
+ ctx->Driver.ReadBuffer = tdfxDDReadBuffer;
+
+ ctx->Driver.ColorMask = tdfxDDColorMask;
+
+ ctx->Driver.AlphaFunc = tdfxDDAlphaFunc;
+ ctx->Driver.BlendEquationSeparate = tdfxDDBlendEquationSeparate;
+ ctx->Driver.BlendFuncSeparate = tdfxDDBlendFuncSeparate;
+ ctx->Driver.ClearDepth = tdfxDDClearDepth;
+ ctx->Driver.CullFace = tdfxDDCullFace;
+ ctx->Driver.FrontFace = tdfxDDFrontFace;
+ ctx->Driver.DepthFunc = tdfxDDDepthFunc;
+ ctx->Driver.DepthMask = tdfxDDDepthMask;
+ ctx->Driver.DepthRange = tdfxDDDepthRange;
+ ctx->Driver.Enable = tdfxDDEnable;
+ ctx->Driver.Fogfv = tdfxDDFogfv;
+ ctx->Driver.LightModelfv = tdfxDDLightModelfv;
+ ctx->Driver.LineWidth = tdfxDDLineWidth;
+ ctx->Driver.PolygonStipple = tdfxDDPolygonStipple;
+ ctx->Driver.RenderMode = tdfxDDRenderMode;
+ ctx->Driver.Scissor = tdfxDDScissor;
+ ctx->Driver.ShadeModel = tdfxDDShadeModel;
+
+ if ( fxMesa->haveHwStencil ) {
+ ctx->Driver.StencilFunc = tdfxDDStencilFunc;
+ ctx->Driver.StencilMask = tdfxDDStencilMask;
+ ctx->Driver.StencilOp = tdfxDDStencilOp;
+ }
+
+ ctx->Driver.Viewport = tdfxDDViewport;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.h
new file mode 100644
index 000000000..b10c38f59
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_state.h
@@ -0,0 +1,61 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.h,v 1.2 2002/02/22 21:45:04 dawes Exp $ */
+
+/*
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ *
+ */
+
+#ifndef __TDFX_STATE_H__
+#define __TDFX_STATE_H__
+
+#include "context.h"
+#include "tdfx_context.h"
+
+extern void tdfxDDInitStateFuncs( GLcontext *ctx );
+
+extern void tdfxDDUpdateHwState( GLcontext *ctx );
+
+extern void tdfxInitState( tdfxContextPtr fxMesa );
+
+extern void tdfxUpdateClipping( GLcontext *ctx );
+
+
+extern void tdfxFallback( GLcontext *ctx, GLuint bit, GLboolean mode );
+#define FALLBACK( rmesa, bit, mode ) tdfxFallback( rmesa->glCtx, bit, mode )
+
+extern void tdfxUpdateCull( GLcontext *ctx );
+extern void tdfxUpdateStipple( GLcontext *ctx );
+extern void tdfxUpdateViewport( GLcontext *ctx );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.c
new file mode 100644
index 000000000..cf4de23b3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.c
@@ -0,0 +1,1914 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_tex.c,v 1.7 2002/11/05 17:46:10 tsi Exp $ */
+
+/*
+ * New fixes:
+ * Daniel Borca <dborca@users.sourceforge.net>, 19 Jul 2004
+ *
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ *
+ */
+
+
+#include "enums.h"
+#include "image.h"
+#include "texcompress.h"
+#include "texformat.h"
+#include "teximage.h"
+#include "texstore.h"
+#include "texobj.h"
+#include "tdfx_context.h"
+#include "tdfx_tex.h"
+#include "tdfx_texman.h"
+
+
+/* no borders! can't halve 1x1! (stride > width * comp) not allowed */
+void
+_mesa_halve2x2_teximage2d ( GLcontext *ctx,
+ struct gl_texture_image *texImage,
+ GLuint bytesPerPixel,
+ GLint srcWidth, GLint srcHeight,
+ const GLvoid *srcImage, GLvoid *dstImage )
+{
+ GLint i, j, k;
+ GLint dstWidth = srcWidth / 2;
+ GLint dstHeight = srcHeight / 2;
+ GLint srcRowStride = srcWidth * bytesPerPixel;
+ GLubyte *src = (GLubyte *)srcImage;
+ GLubyte *dst = dstImage;
+
+ GLuint bpt = 0;
+ GLubyte *_s = NULL;
+ GLubyte *_d = NULL;
+ GLenum _t = 0;
+
+ if (texImage->TexFormat->MesaFormat == MESA_FORMAT_RGB565) {
+ _t = GL_UNSIGNED_SHORT_5_6_5_REV;
+ bpt = bytesPerPixel;
+ } else if (texImage->TexFormat->MesaFormat == MESA_FORMAT_ARGB4444) {
+ _t = GL_UNSIGNED_SHORT_4_4_4_4_REV;
+ bpt = bytesPerPixel;
+ } else if (texImage->TexFormat->MesaFormat == MESA_FORMAT_ARGB1555) {
+ _t = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+ bpt = bytesPerPixel;
+ }
+ if (bpt) {
+ bytesPerPixel = 4;
+ srcRowStride = srcWidth * bytesPerPixel;
+ if (dstWidth == 0) {
+ dstWidth = 1;
+ }
+ if (dstHeight == 0) {
+ dstHeight = 1;
+ }
+ _s = src = MALLOC(srcRowStride * srcHeight);
+ _d = dst = MALLOC(dstWidth * bytesPerPixel * dstHeight);
+ _mesa_texstore_rgba8888(ctx, 2, GL_RGBA,
+ &_mesa_texformat_rgba8888_rev, src,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ srcRowStride, /* dstRowStride */
+ 0, /* dstImageStride */
+ srcWidth, srcHeight, 1,
+ texImage->Format, _t, srcImage, &ctx->DefaultPacking);
+ }
+
+ if (srcHeight == 1) {
+ for (i = 0; i < dstWidth; i++) {
+ for (k = 0; k < bytesPerPixel; k++) {
+ dst[0] = (src[0] + src[bytesPerPixel] + 1) / 2;
+ src++;
+ dst++;
+ }
+ src += bytesPerPixel;
+ }
+ } else if (srcWidth == 1) {
+ for (j = 0; j < dstHeight; j++) {
+ for (k = 0; k < bytesPerPixel; k++) {
+ dst[0] = (src[0] + src[srcRowStride] + 1) / 2;
+ src++;
+ dst++;
+ }
+ src += srcRowStride;
+ }
+ } else {
+ for (j = 0; j < dstHeight; j++) {
+ for (i = 0; i < dstWidth; i++) {
+ for (k = 0; k < bytesPerPixel; k++) {
+ dst[0] = (src[0] +
+ src[bytesPerPixel] +
+ src[srcRowStride] +
+ src[srcRowStride + bytesPerPixel] + 2) / 4;
+ src++;
+ dst++;
+ }
+ src += bytesPerPixel;
+ }
+ src += srcRowStride;
+ }
+ }
+
+ if (bpt) {
+ src = _s;
+ dst = _d;
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat, dstImage,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstWidth * bpt,
+ 0, /* dstImageStride */
+ dstWidth, dstHeight, 1,
+ GL_BGRA, CHAN_TYPE, dst, &ctx->DefaultPacking);
+ FREE(dst);
+ FREE(src);
+ }
+}
+
+
+static int
+logbase2(int n)
+{
+ GLint i = 1;
+ GLint log2 = 0;
+
+ if (n < 0) {
+ return -1;
+ }
+
+ while (n > i) {
+ i *= 2;
+ log2++;
+ }
+ if (i != n) {
+ return -1;
+ }
+ else {
+ return log2;
+ }
+}
+
+
+/*
+ * Compute various texture image parameters.
+ * Input: w, h - source texture width and height
+ * Output: lodlevel - Glide lod level token for the larger texture dimension
+ * aspectratio - Glide aspect ratio token
+ * sscale - S scale factor used during triangle setup
+ * tscale - T scale factor used during triangle setup
+ * wscale - OpenGL -> Glide image width scale factor
+ * hscale - OpenGL -> Glide image height scale factor
+ *
+ * Sample results:
+ * w h lodlevel aspectRatio
+ * 128 128 GR_LOD_LOG2_128 (=7) GR_ASPECT_LOG2_1x1 (=0)
+ * 64 64 GR_LOD_LOG2_64 (=6) GR_ASPECT_LOG2_1x1 (=0)
+ * 64 32 GR_LOD_LOG2_64 (=6) GR_ASPECT_LOG2_2x1 (=1)
+ * 32 64 GR_LOD_LOG2_64 (=6) GR_ASPECT_LOG2_1x2 (=-1)
+ * 32 32 GR_LOD_LOG2_32 (=5) GR_ASPECT_LOG2_1x1 (=0)
+ */
+static void
+tdfxTexGetInfo(const GLcontext *ctx, int w, int h,
+ GrLOD_t *lodlevel, GrAspectRatio_t *aspectratio,
+ float *sscale, float *tscale,
+ int *wscale, int *hscale)
+{
+ int logw, logh, ar, lod, ws, hs;
+ float s, t;
+
+ ASSERT(w >= 1);
+ ASSERT(h >= 1);
+
+ logw = logbase2(w);
+ logh = logbase2(h);
+ ar = logw - logh; /* aspect ratio = difference in log dimensions */
+ s = t = 256.0;
+ ws = hs = 1;
+
+ /* 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) {
+ ASSERT(w >= h);
+ lod = logw;
+ if (ar <= GR_ASPECT_LOG2_8x1) {
+ t = 256 >> ar;
+ }
+ else {
+ /* have to stretch image height */
+ t = 32.0;
+ hs = 1 << (ar - 3);
+ ar = GR_ASPECT_LOG2_8x1;
+ }
+ }
+ else {
+ ASSERT(w < h);
+ lod = logh;
+ if (ar >= GR_ASPECT_LOG2_1x8) {
+ s = 256 >> -ar;
+ }
+ else {
+ /* have to stretch image width */
+ s = 32.0;
+ ws = 1 << (-ar - 3);
+ ar = GR_ASPECT_LOG2_1x8;
+ }
+ }
+
+ if (lodlevel)
+ *lodlevel = (GrLOD_t) lod;
+ if (aspectratio)
+ *aspectratio = (GrAspectRatio_t) ar;
+ if (sscale)
+ *sscale = s;
+ if (tscale)
+ *tscale = t;
+ if (wscale)
+ *wscale = ws;
+ if (hscale)
+ *hscale = hs;
+}
+
+
+/*
+ * We need to call this when a texture object's minification filter
+ * or texture image sizes change.
+ */
+static void RevalidateTexture(GLcontext *ctx, struct gl_texture_object *tObj)
+{
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
+ GLint minl, maxl;
+
+ if (!ti)
+ return;
+
+ minl = maxl = tObj->BaseLevel;
+
+ if (tObj->Image[0][minl]) {
+ maxl = MIN2(tObj->MaxLevel, tObj->Image[0][minl]->MaxLog2);
+
+ /* compute largeLodLog2, aspect ratio and texcoord scale factors */
+ tdfxTexGetInfo(ctx, tObj->Image[0][minl]->Width, tObj->Image[0][minl]->Height,
+ &ti->info.largeLodLog2,
+ &ti->info.aspectRatioLog2,
+ &(ti->sScale), &(ti->tScale), NULL, NULL);
+ }
+
+ if (tObj->Image[0][maxl] && (tObj->MinFilter != GL_NEAREST) && (tObj->MinFilter != GL_LINEAR)) {
+ /* mipmapping: need to compute smallLodLog2 */
+ tdfxTexGetInfo(ctx, tObj->Image[0][maxl]->Width,
+ tObj->Image[0][maxl]->Height,
+ &ti->info.smallLodLog2, NULL,
+ NULL, NULL, NULL, NULL);
+ }
+ else {
+ /* not mipmapping: smallLodLog2 = largeLodLog2 */
+ ti->info.smallLodLog2 = ti->info.largeLodLog2;
+ maxl = minl;
+ }
+
+ ti->minLevel = minl;
+ ti->maxLevel = maxl;
+ ti->info.data = NULL;
+
+ /* this is necessary because of fxDDCompressedTexImage2D */
+ if (ti->padded) {
+ struct gl_texture_image *texImage = tObj->Image[0][minl];
+ tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ if (mml->wScale != 1 || mml->hScale != 1) {
+ ti->sScale /= mml->wScale;
+ ti->tScale /= mml->hScale;
+ }
+ }
+}
+
+
+static tdfxTexInfo *
+fxAllocTexObjData(tdfxContextPtr fxMesa)
+{
+ tdfxTexInfo *ti;
+
+ if (!(ti = CALLOC(sizeof(tdfxTexInfo)))) {
+ _mesa_problem(NULL, "tdfx driver: out of memory");
+ return NULL;
+ }
+
+ ti->isInTM = GL_FALSE;
+
+ ti->whichTMU = TDFX_TMU_NONE;
+
+ ti->tm[TDFX_TMU0] = NULL;
+ ti->tm[TDFX_TMU1] = NULL;
+
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ ti->magFilt = GR_TEXTUREFILTER_BILINEAR;
+
+ ti->sClamp = GR_TEXTURECLAMP_WRAP;
+ ti->tClamp = GR_TEXTURECLAMP_WRAP;
+
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->LODblend = FXFALSE;
+
+ return ti;
+}
+
+
+/*
+ * Called via glBindTexture.
+ */
+static void
+tdfxBindTexture(GLcontext * ctx, GLenum target,
+ struct gl_texture_object *tObj)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxTexInfo *ti;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDTexBind(%d,%p)\n", tObj->Name,
+ tObj->DriverData);
+ }
+
+ if ((target != GL_TEXTURE_1D) && (target != GL_TEXTURE_2D))
+ return;
+
+ if (!tObj->DriverData) {
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
+ }
+
+ ti = TDFX_TEXTURE_DATA(tObj);
+ ti->lastTimeUsed = fxMesa->texBindNumber++;
+
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+}
+
+
+/*
+ * Called via glTexEnv.
+ */
+static void
+tdfxTexEnv(GLcontext * ctx, GLenum target, GLenum pname,
+ const GLfloat * param)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
+ if (param)
+ fprintf(stderr, "fxmesa: texenv(%x,%x)\n", pname,
+ (GLint) (*param));
+ else
+ fprintf(stderr, "fxmesa: texenv(%x)\n", pname);
+ }
+
+ /* XXX this is a bit of a hack to force the Glide texture
+ * state to be updated.
+ */
+ fxMesa->TexState.EnvMode[ctx->Texture.CurrentUnit] = 0;
+
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+}
+
+
+/*
+ * Called via glTexParameter.
+ */
+static void
+tdfxTexParameter(GLcontext * ctx, GLenum target,
+ struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat * params)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLenum param = (GLenum) (GLint) params[0];
+ tdfxTexInfo *ti;
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: fxDDTexParam(%d,%p,%x,%x)\n", tObj->Name,
+ tObj->DriverData, pname, param);
+ }
+
+ if ((target != GL_TEXTURE_1D) && (target != GL_TEXTURE_2D))
+ return;
+
+ if (!tObj->DriverData)
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
+
+ ti = TDFX_TEXTURE_DATA(tObj);
+
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ switch (param) {
+ case GL_NEAREST:
+ ti->mmMode = GR_MIPMAP_DISABLE;
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ ti->LODblend = FXFALSE;
+ break;
+ case GL_LINEAR:
+ ti->mmMode = GR_MIPMAP_DISABLE;
+ ti->minFilt = GR_TEXTUREFILTER_BILINEAR;
+ ti->LODblend = FXFALSE;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ if (!fxMesa->Glide.HaveCombineExt) {
+ if (fxMesa->haveTwoTMUs) {
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->LODblend = FXTRUE;
+ }
+ else {
+ ti->mmMode = GR_MIPMAP_NEAREST_DITHER;
+ ti->LODblend = FXFALSE;
+ }
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ break;
+ }
+ /* XXX Voodoo3/Banshee mipmap blending seems to produce
+ * incorrectly filtered colors for the smallest mipmap levels.
+ * To work-around we fall-through here and use a different filter.
+ */
+ case GL_NEAREST_MIPMAP_NEAREST:
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ ti->LODblend = FXFALSE;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ if (!fxMesa->Glide.HaveCombineExt) {
+ if (fxMesa->haveTwoTMUs) {
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->LODblend = FXTRUE;
+ }
+ else {
+ ti->mmMode = GR_MIPMAP_NEAREST_DITHER;
+ ti->LODblend = FXFALSE;
+ }
+ ti->minFilt = GR_TEXTUREFILTER_BILINEAR;
+ break;
+ }
+ /* XXX Voodoo3/Banshee mipmap blending seems to produce
+ * incorrectly filtered colors for the smallest mipmap levels.
+ * To work-around we fall-through here and use a different filter.
+ */
+ case GL_LINEAR_MIPMAP_NEAREST:
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->minFilt = GR_TEXTUREFILTER_BILINEAR;
+ ti->LODblend = FXFALSE;
+ break;
+ default:
+ break;
+ }
+ ti->reloadImages = GL_TRUE;
+ RevalidateTexture(ctx, tObj);
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+ break;
+
+ case GL_TEXTURE_MAG_FILTER:
+ switch (param) {
+ case GL_NEAREST:
+ ti->magFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ break;
+ case GL_LINEAR:
+ ti->magFilt = GR_TEXTUREFILTER_BILINEAR;
+ break;
+ default:
+ break;
+ }
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+ break;
+
+ case GL_TEXTURE_WRAP_S:
+ switch (param) {
+ case GL_CLAMP_TO_BORDER:
+ case GL_CLAMP_TO_EDGE:
+ case GL_CLAMP:
+ ti->sClamp = GR_TEXTURECLAMP_CLAMP;
+ break;
+ case GL_REPEAT:
+ ti->sClamp = GR_TEXTURECLAMP_WRAP;
+ break;
+ case GL_MIRRORED_REPEAT:
+ ti->sClamp = GR_TEXTURECLAMP_MIRROR_EXT;
+ break;
+ default:
+ break;
+ }
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+ break;
+
+ case GL_TEXTURE_WRAP_T:
+ switch (param) {
+ case GL_CLAMP_TO_BORDER:
+ case GL_CLAMP_TO_EDGE:
+ case GL_CLAMP:
+ ti->tClamp = GR_TEXTURECLAMP_CLAMP;
+ break;
+ case GL_REPEAT:
+ ti->tClamp = GR_TEXTURECLAMP_WRAP;
+ break;
+ case GL_MIRRORED_REPEAT:
+ ti->tClamp = GR_TEXTURECLAMP_MIRROR_EXT;
+ break;
+ default:
+ break;
+ }
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+ break;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ /* TO DO */
+ break;
+ case GL_TEXTURE_MIN_LOD:
+ /* TO DO */
+ break;
+ case GL_TEXTURE_MAX_LOD:
+ /* TO DO */
+ break;
+ case GL_TEXTURE_BASE_LEVEL:
+ RevalidateTexture(ctx, tObj);
+ break;
+ case GL_TEXTURE_MAX_LEVEL:
+ RevalidateTexture(ctx, tObj);
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+/*
+ * Called via glDeleteTextures to delete a texture object.
+ * Here, we delete the Glide data associated with the texture.
+ */
+static void
+tdfxDeleteTexture(GLcontext * ctx, struct gl_texture_object *tObj)
+{
+ if (ctx && ctx->DriverCtx) {
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxTMFreeTexture(fxMesa, tObj);
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+ /* Free mipmap images and the texture object itself */
+ _mesa_delete_texture_object(ctx, tObj);
+ }
+}
+
+
+/*
+ * Return true if texture is resident, false otherwise.
+ */
+static GLboolean
+tdfxIsTextureResident(GLcontext *ctx, struct gl_texture_object *tObj)
+{
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
+ return (GLboolean) (ti && ti->isInTM);
+}
+
+
+
+/*
+ * Convert a gl_color_table texture palette to Glide's format.
+ */
+static GrTexTable_t
+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->Type == 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;
+ }
+ return GR_TEXTABLE_PALETTE_6666_EXT;
+ 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;
+ }
+ return GR_TEXTABLE_PALETTE;
+ 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;
+ }
+ return GR_TEXTABLE_PALETTE_6666_EXT;
+ 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;
+ }
+ return GR_TEXTABLE_PALETTE_6666_EXT;
+ 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;
+ }
+ return GR_TEXTABLE_PALETTE;
+ 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;
+ }
+ return GR_TEXTABLE_PALETTE_6666_EXT;
+ default:
+ /* XXX fixme: how can this happen? */
+ _mesa_error(NULL, GL_INVALID_ENUM, "convertPalette: table->Format == %s",
+ _mesa_lookup_enum_by_nr(table->Format));
+ return GR_TEXTABLE_PALETTE;
+ }
+}
+
+
+
+static void
+tdfxUpdateTexturePalette(GLcontext * ctx, struct gl_texture_object *tObj)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ if (tObj) {
+ /* per-texture palette */
+ tdfxTexInfo *ti;
+
+ /* This might be a proxy texture. */
+ if (!tObj->Palette.Table)
+ return;
+
+ if (!tObj->DriverData)
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
+ ti = TDFX_TEXTURE_DATA(tObj);
+ assert(ti);
+ ti->paltype = convertPalette(ti->palette.data, &tObj->Palette);
+ /*tdfxTexInvalidate(ctx, tObj);*/
+ }
+ else {
+ /* global texture palette */
+ fxMesa->TexPalette.Type = convertPalette(fxMesa->glbPalette.data, &ctx->Texture.Palette);
+ fxMesa->TexPalette.Data = &(fxMesa->glbPalette.data);
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
+ }
+ fxMesa->new_state |= TDFX_NEW_TEXTURE; /* XXX too heavy-handed */
+}
+
+
+/**********************************************************************/
+/**** NEW TEXTURE IMAGE FUNCTIONS ****/
+/**********************************************************************/
+
+#if 000
+static FxBool TexusFatalError = FXFALSE;
+static FxBool TexusError = FXFALSE;
+
+#define TX_DITHER_NONE 0x00000000
+
+static void
+fxTexusError(const char *string, FxBool fatal)
+{
+ _mesa_problem(NULL, string);
+ /*
+ * Just propagate the fatal value up.
+ */
+ TexusError = FXTRUE;
+ TexusFatalError = fatal;
+}
+#endif
+
+
+static const struct gl_texture_format *
+tdfxChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum srcFormat, GLenum srcType )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ const GLboolean allow32bpt = TDFX_IS_NAPALM(fxMesa);
+
+ switch (internalFormat) {
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ case GL_COMPRESSED_ALPHA:
+ return &_mesa_texformat_a8;
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ case GL_COMPRESSED_LUMINANCE:
+ return &_mesa_texformat_l8;
+ 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_COMPRESSED_LUMINANCE_ALPHA:
+ return &_mesa_texformat_al88;
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case GL_COMPRESSED_INTENSITY:
+ return &_mesa_texformat_i8;
+ case GL_R3_G3_B2:
+ case GL_RGB4:
+ case GL_RGB5:
+ return &_mesa_texformat_rgb565;
+ case GL_COMPRESSED_RGB:
+ /* intentional fall-through */
+ case 3:
+ case GL_RGB:
+ if ( srcFormat == GL_RGB && srcType == GL_UNSIGNED_SHORT_5_6_5 ) {
+ return &_mesa_texformat_rgb565;
+ }
+ /* intentional fall through */
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ return (allow32bpt) ? &_mesa_texformat_argb8888
+ : &_mesa_texformat_rgb565;
+ case GL_RGBA2:
+ case GL_RGBA4:
+ return &_mesa_texformat_argb4444;
+ case GL_COMPRESSED_RGBA:
+ /* intentional fall-through */
+ case 4:
+ case GL_RGBA:
+ if ( srcFormat == GL_BGRA ) {
+ if ( srcType == GL_UNSIGNED_INT_8_8_8_8_REV ) {
+ return &_mesa_texformat_argb8888;
+ }
+ else if ( srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
+ return &_mesa_texformat_argb4444;
+ }
+ else if ( srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
+ return &_mesa_texformat_argb1555;
+ }
+ }
+ /* intentional fall through */
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return allow32bpt ? &_mesa_texformat_argb8888
+ : &_mesa_texformat_argb4444;
+ case GL_RGB5_A1:
+ return &_mesa_texformat_argb1555;
+ 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:
+ return &_mesa_texformat_ci8;
+ /* GL_EXT_texture_compression_s3tc */
+ /* GL_S3_s3tc */
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ return &_mesa_texformat_rgb_dxt1;
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgba_dxt1;
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ return &_mesa_texformat_rgba_dxt3;
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ return &_mesa_texformat_rgba_dxt5;
+ /* GL_3DFX_texture_compression_FXT1 */
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ return &_mesa_texformat_rgb_fxt1;
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ return &_mesa_texformat_rgba_fxt1;
+ default:
+ _mesa_problem(ctx, "unexpected format in tdfxChooseTextureFormat");
+ return NULL;
+ }
+}
+
+
+/*
+ * Return the Glide format for the given mesa texture format.
+ */
+static GrTextureFormat_t
+fxGlideFormat(GLint mesaFormat)
+{
+ switch (mesaFormat) {
+ case MESA_FORMAT_I8:
+ return GR_TEXFMT_ALPHA_8;
+ case MESA_FORMAT_A8:
+ return GR_TEXFMT_ALPHA_8;
+ case MESA_FORMAT_L8:
+ return GR_TEXFMT_INTENSITY_8;
+ case MESA_FORMAT_CI8:
+ return GR_TEXFMT_P_8;
+ case MESA_FORMAT_AL88:
+ return GR_TEXFMT_ALPHA_INTENSITY_88;
+ case MESA_FORMAT_RGB565:
+ return GR_TEXFMT_RGB_565;
+ case MESA_FORMAT_ARGB4444:
+ return GR_TEXFMT_ARGB_4444;
+ case MESA_FORMAT_ARGB1555:
+ return GR_TEXFMT_ARGB_1555;
+ case MESA_FORMAT_ARGB8888:
+ return GR_TEXFMT_ARGB_8888;
+ case MESA_FORMAT_RGB_FXT1:
+ case MESA_FORMAT_RGBA_FXT1:
+ return GR_TEXFMT_ARGB_CMP_FXT1;
+ case MESA_FORMAT_RGB_DXT1:
+ case MESA_FORMAT_RGBA_DXT1:
+ return GR_TEXFMT_ARGB_CMP_DXT1;
+ case MESA_FORMAT_RGBA_DXT3:
+ return GR_TEXFMT_ARGB_CMP_DXT3;
+ case MESA_FORMAT_RGBA_DXT5:
+ return GR_TEXFMT_ARGB_CMP_DXT5;
+ default:
+ _mesa_problem(NULL, "Unexpected format in fxGlideFormat");
+ return 0;
+ }
+}
+
+
+/* Texel-fetch functions for software texturing and glGetTexImage().
+ * We should have been able to use some "standard" fetch functions (which
+ * may get defined in texutil.c) but we have to account for scaled texture
+ * images on tdfx hardware (the 8:1 aspect ratio limit).
+ * Hence, we need special functions here.
+ */
+extern void
+fxt1_decode_1 (const void *texture, int width,
+ int i, int j, unsigned char *rgba);
+
+static void
+fetch_intensity8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan * rgba)
+{
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ const GLubyte *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLubyte *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = *texel;
+ rgba[GCOMP] = *texel;
+ rgba[BCOMP] = *texel;
+ rgba[ACOMP] = *texel;
+}
+
+
+static void
+fetch_luminance8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan * rgba)
+{
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ const GLubyte *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLubyte *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = *texel;
+ rgba[GCOMP] = *texel;
+ rgba[BCOMP] = *texel;
+ rgba[ACOMP] = 255;
+}
+
+
+static void
+fetch_alpha8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan * rgba)
+{
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ const GLubyte *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLubyte *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = 255;
+ rgba[GCOMP] = 255;
+ rgba[BCOMP] = 255;
+ rgba[ACOMP] = *texel;
+}
+
+
+static void
+fetch_index8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan * indexOut)
+{
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ const GLubyte *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLubyte *) texImage->Data) + j * mml->width + i;
+ *indexOut = *texel;
+}
+
+
+static void
+fetch_luminance8_alpha8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan * rgba)
+{
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ const GLubyte *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLubyte *) texImage->Data) + (j * mml->width + i) * 2;
+ rgba[RCOMP] = texel[0];
+ rgba[GCOMP] = texel[0];
+ rgba[BCOMP] = texel[0];
+ rgba[ACOMP] = texel[1];
+}
+
+
+static void
+fetch_r5g6b5(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan * rgba)
+{
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ const GLushort *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLushort *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = (((*texel) >> 11) & 0x1f) * 255 / 31;
+ rgba[GCOMP] = (((*texel) >> 5) & 0x3f) * 255 / 63;
+ rgba[BCOMP] = (((*texel) >> 0) & 0x1f) * 255 / 31;
+ rgba[ACOMP] = 255;
+}
+
+
+static void
+fetch_r4g4b4a4(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan * rgba)
+{
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ const GLushort *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLushort *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = (((*texel) >> 12) & 0xf) * 255 / 15;
+ rgba[GCOMP] = (((*texel) >> 8) & 0xf) * 255 / 15;
+ rgba[BCOMP] = (((*texel) >> 4) & 0xf) * 255 / 15;
+ rgba[ACOMP] = (((*texel) >> 0) & 0xf) * 255 / 15;
+}
+
+
+static void
+fetch_r5g5b5a1(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan * rgba)
+{
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ const GLushort *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLushort *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = (((*texel) >> 11) & 0x1f) * 255 / 31;
+ rgba[GCOMP] = (((*texel) >> 6) & 0x1f) * 255 / 31;
+ rgba[BCOMP] = (((*texel) >> 1) & 0x1f) * 255 / 31;
+ rgba[ACOMP] = (((*texel) >> 0) & 0x01) * 255;
+}
+
+
+static void
+fetch_a8r8g8b8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan * rgba)
+{
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+ const GLuint *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLuint *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = (((*texel) >> 16) & 0xff);
+ rgba[GCOMP] = (((*texel) >> 8) & 0xff);
+ rgba[BCOMP] = (((*texel) ) & 0xff);
+ rgba[ACOMP] = (((*texel) >> 24) & 0xff);
+}
+
+
+static void
+fetch_rgb_fxt1(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ fxt1_decode_1(texImage->Data, mml->width, i, j, rgba);
+ rgba[ACOMP] = 255;
+}
+
+
+static void
+fetch_rgba_fxt1(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ fxt1_decode_1(texImage->Data, mml->width, i, j, rgba);
+}
+
+
+static void
+fetch_rgb_dxt1(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ _mesa_texformat_rgb_dxt1.FetchTexel2D(texImage, i, j, k, rgba);
+}
+
+
+static void
+fetch_rgba_dxt1(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ _mesa_texformat_rgba_dxt1.FetchTexel2D(texImage, i, j, k, rgba);
+}
+
+
+static void
+fetch_rgba_dxt3(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ _mesa_texformat_rgba_dxt3.FetchTexel2D(texImage, i, j, k, rgba);
+}
+
+
+static void
+fetch_rgba_dxt5(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tdfxMipMapLevel *mml = TDFX_TEXIMAGE_DATA(texImage);
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ _mesa_texformat_rgba_dxt5.FetchTexel2D(texImage, i, j, k, rgba);
+}
+
+
+static FetchTexelFuncC
+fxFetchFunction(GLint mesaFormat)
+{
+ switch (mesaFormat) {
+ case MESA_FORMAT_I8:
+ return &fetch_intensity8;
+ case MESA_FORMAT_A8:
+ return &fetch_alpha8;
+ case MESA_FORMAT_L8:
+ return &fetch_luminance8;
+ case MESA_FORMAT_CI8:
+ return &fetch_index8;
+ case MESA_FORMAT_AL88:
+ return &fetch_luminance8_alpha8;
+ case MESA_FORMAT_RGB565:
+ return &fetch_r5g6b5;
+ case MESA_FORMAT_ARGB4444:
+ return &fetch_r4g4b4a4;
+ case MESA_FORMAT_ARGB1555:
+ return &fetch_r5g5b5a1;
+ case MESA_FORMAT_ARGB8888:
+ return &fetch_a8r8g8b8;
+ case MESA_FORMAT_RGB_FXT1:
+ return &fetch_rgb_fxt1;
+ case MESA_FORMAT_RGBA_FXT1:
+ return &fetch_rgba_fxt1;
+ case MESA_FORMAT_RGB_DXT1:
+ return &fetch_rgb_dxt1;
+ case MESA_FORMAT_RGBA_DXT1:
+ return &fetch_rgba_dxt1;
+ case MESA_FORMAT_RGBA_DXT3:
+ return &fetch_rgba_dxt3;
+ case MESA_FORMAT_RGBA_DXT5:
+ return &fetch_rgba_dxt5;
+ default:
+ _mesa_problem(NULL, "Unexpected format in fxFetchFunction");
+ return NULL;
+ }
+}
+
+
+static GLboolean
+adjust2DRatio (GLcontext *ctx,
+ GLint xoffset, GLint yoffset,
+ GLint width, GLint height,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ tdfxMipMapLevel *mml,
+ struct gl_texture_image *texImage,
+ GLint texelBytes,
+ GLint dstRowStride)
+{
+ const GLint newWidth = width * mml->wScale;
+ const GLint newHeight = height * mml->hScale;
+ GLvoid *tempImage;
+
+ if (!texImage->IsCompressed) {
+ GLubyte *destAddr;
+ tempImage = MALLOC(width * height * texelBytes);
+ if (!tempImage) {
+ return GL_FALSE;
+ }
+
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat, tempImage,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ width * texelBytes, /* dstRowStride */
+ 0, /* dstImageStride */
+ width, height, 1,
+ format, type, pixels, packing);
+
+ /* now rescale */
+ /* compute address of dest subimage within the overal tex image */
+ destAddr = (GLubyte *) texImage->Data
+ + (yoffset * mml->hScale * mml->width
+ + xoffset * mml->wScale) * texelBytes;
+
+ _mesa_rescale_teximage2d(texelBytes,
+ width,
+ dstRowStride, /* dst stride */
+ width, height,
+ newWidth, newHeight,
+ tempImage, destAddr);
+ } else {
+ const GLint rawBytes = 4;
+ GLvoid *rawImage = MALLOC(width * height * rawBytes);
+ if (!rawImage) {
+ return GL_FALSE;
+ }
+ tempImage = MALLOC(newWidth * newHeight * rawBytes);
+ if (!tempImage) {
+ return GL_FALSE;
+ }
+ /* unpack image, apply transfer ops and store in rawImage */
+ _mesa_texstore_rgba8888(ctx, 2, GL_RGBA,
+ &_mesa_texformat_rgba8888_rev, rawImage,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ width * rawBytes, /* dstRowStride */
+ 0, /* dstImageStride */
+ width, height, 1,
+ format, type, pixels, packing);
+ _mesa_rescale_teximage2d(rawBytes,
+ width,
+ newWidth * rawBytes, /* dst stride */
+ width, height, /* src */
+ newWidth, newHeight, /* dst */
+ rawImage /*src*/, tempImage /*dst*/ );
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat, texImage->Data,
+ xoffset * mml->wScale, yoffset * mml->hScale, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ 0, /* dstImageStride */
+ newWidth, newHeight, 1,
+ GL_RGBA, CHAN_TYPE, tempImage, &ctx->DefaultPacking);
+ FREE(rawImage);
+ }
+
+ FREE(tempImage);
+
+ return GL_TRUE;
+}
+
+
+static void
+tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat, GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxTexInfo *ti;
+ tdfxMipMapLevel *mml;
+ GLint texelBytes, dstRowStride;
+
+ /*
+ printf("TexImage id=%d int 0x%x format 0x%x type 0x%x %dx%d\n",
+ texObj->Name, texImage->IntFormat, format, type,
+ texImage->Width, texImage->Height);
+ */
+
+ ti = TDFX_TEXTURE_DATA(texObj);
+ if (!ti) {
+ texObj->DriverData = fxAllocTexObjData(fxMesa);
+ if (!texObj->DriverData) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ ti = TDFX_TEXTURE_DATA(texObj);
+ }
+ assert(ti);
+
+ mml = TDFX_TEXIMAGE_DATA(texImage);
+ if (!mml) {
+ texImage->DriverData = CALLOC(sizeof(tdfxMipMapLevel));
+ if (!texImage->DriverData) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ mml = TDFX_TEXIMAGE_DATA(texImage);
+ }
+
+ /* Determine width and height scale factors for texture.
+ * Remember, Glide is limited to 8:1 aspect ratios.
+ */
+ tdfxTexGetInfo(ctx,
+ texImage->Width, texImage->Height,
+ NULL, /* lod level */
+ NULL, /* aspect ratio */
+ NULL, NULL, /* sscale, tscale */
+ &mml->wScale, &mml->hScale);
+
+ /* rescaled size: */
+ mml->width = width * mml->wScale;
+ mml->height = height * mml->hScale;
+
+#if FX_COMPRESS_S3TC_AS_FXT1_HACK
+ /* [koolsmoky] substitute FXT1 for DXTn and Legacy S3TC */
+ /* [dBorca] we should update texture's attribute, then,
+ * because if the application asks us to decompress, we
+ * have to know the REAL format! Also, DXT3/5 might not
+ * be correct, since it would mess with "compressedSize".
+ * Ditto for GL_RGBA[4]_S3TC, which is always mapped to DXT3.
+ */
+ if (texImage->IsCompressed) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ internalFormat = GL_COMPRESSED_RGB_FXT1_3DFX;
+ break;
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ internalFormat = GL_COMPRESSED_RGBA_FXT1_3DFX;
+ }
+ texImage->IntFormat = internalFormat;
+ }
+#endif
+#if FX_TC_NAPALM
+ if (fxMesa->type >= GR_SSTTYPE_Voodoo4) {
+ GLenum texNapalm = 0;
+ if (internalFormat == GL_COMPRESSED_RGB) {
+ texNapalm = GL_COMPRESSED_RGB_FXT1_3DFX;
+ } else if (internalFormat == GL_COMPRESSED_RGBA) {
+ texNapalm = GL_COMPRESSED_RGBA_FXT1_3DFX;
+ }
+ if (texNapalm) {
+ texImage->IntFormat = internalFormat = texNapalm;
+ texImage->IsCompressed = GL_TRUE;
+ }
+ }
+#endif
+
+ /* choose the texture format */
+ assert(ctx->Driver.ChooseTextureFormat);
+ texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
+ internalFormat, format, type);
+ assert(texImage->TexFormat);
+ mml->glideFormat = fxGlideFormat(texImage->TexFormat->MesaFormat);
+ ti->info.format = mml->glideFormat;
+ texImage->FetchTexelc = fxFetchFunction(texImage->TexFormat->MesaFormat);
+ texelBytes = texImage->TexFormat->TexelBytes;
+
+ if (texImage->IsCompressed) {
+ texImage->CompressedSize = _mesa_compressed_texture_size(ctx,
+ mml->width,
+ mml->height,
+ 1,
+ internalFormat);
+ dstRowStride = _mesa_compressed_row_stride(internalFormat, mml->width);
+ texImage->Data = _mesa_malloc(texImage->CompressedSize);
+ } else {
+ dstRowStride = mml->width * texelBytes;
+ texImage->Data = _mesa_malloc(mml->width * mml->height * texelBytes);
+ }
+ if (!texImage->Data) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+
+ if (pixels != NULL) {
+ if (mml->wScale != 1 || mml->hScale != 1) {
+ /* rescale image to overcome 1:8 aspect limitation */
+ if (!adjust2DRatio(ctx,
+ 0, 0,
+ width, height,
+ format, type, pixels,
+ packing,
+ mml,
+ texImage,
+ texelBytes,
+ dstRowStride)
+ ) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ }
+ else {
+ /* no rescaling needed */
+ /* unpack image, apply transfer ops and store in texImage->Data */
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat, texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ 0, /* dstImageStride */
+ width, height, 1,
+ format, type, pixels, packing);
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ GLint mipWidth, mipHeight;
+ tdfxMipMapLevel *mip;
+ struct gl_texture_image *mipImage;
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target);
+
+ assert(!texImage->IsCompressed);
+
+ while (level < texObj->MaxLevel && level < maxLevels - 1) {
+ mipWidth = width / 2;
+ if (!mipWidth) {
+ mipWidth = 1;
+ }
+ mipHeight = height / 2;
+ if (!mipHeight) {
+ mipHeight = 1;
+ }
+ if ((mipWidth == width) && (mipHeight == height)) {
+ break;
+ }
+ _mesa_TexImage2D(target, ++level, internalFormat,
+ mipWidth, mipHeight, border,
+ format, type,
+ NULL);
+ mipImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ mip = TDFX_TEXIMAGE_DATA(mipImage);
+ _mesa_halve2x2_teximage2d(ctx,
+ texImage,
+ texelBytes,
+ mml->width, mml->height,
+ texImage->Data, mipImage->Data);
+ texImage = mipImage;
+ mml = mip;
+ width = mipWidth;
+ height = mipHeight;
+ }
+ }
+ }
+
+ RevalidateTexture(ctx, texObj);
+
+ ti->reloadImages = GL_TRUE;
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+}
+
+
+static void
+tdfxTexSubImage2D(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 )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxTexInfo *ti;
+ tdfxMipMapLevel *mml;
+ GLint texelBytes, dstRowStride;
+
+ if (!texObj->DriverData) {
+ _mesa_problem(ctx, "problem in fxDDTexSubImage2D");
+ return;
+ }
+
+ ti = TDFX_TEXTURE_DATA(texObj);
+ assert(ti);
+ mml = TDFX_TEXIMAGE_DATA(texImage);
+ assert(mml);
+
+ assert(texImage->Data); /* must have an existing texture image! */
+ assert(texImage->Format);
+
+ texelBytes = texImage->TexFormat->TexelBytes;
+ if (texImage->IsCompressed) {
+ dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat, mml->width);
+ } else {
+ dstRowStride = mml->width * texelBytes;
+ }
+
+ if (mml->wScale != 1 || mml->hScale != 1) {
+ /* need to rescale subimage to match mipmap level's rescale factors */
+ if (!adjust2DRatio(ctx,
+ xoffset, yoffset,
+ width, height,
+ format, type, pixels,
+ packing,
+ mml,
+ texImage,
+ texelBytes,
+ dstRowStride)
+ ) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
+ return;
+ }
+ }
+ else {
+ /* no rescaling needed */
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat, texImage->Data,
+ xoffset, yoffset, 0,
+ dstRowStride,
+ 0, /* dstImageStride */
+ width, height, 1,
+ format, type, pixels, packing);
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ GLint mipWidth, mipHeight;
+ tdfxMipMapLevel *mip;
+ struct gl_texture_image *mipImage;
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target);
+
+ assert(!texImage->IsCompressed);
+
+ width = texImage->Width;
+ height = texImage->Height;
+ while (level < texObj->MaxLevel && level < maxLevels - 1) {
+ mipWidth = width / 2;
+ if (!mipWidth) {
+ mipWidth = 1;
+ }
+ mipHeight = height / 2;
+ if (!mipHeight) {
+ mipHeight = 1;
+ }
+ if ((mipWidth == width) && (mipHeight == height)) {
+ break;
+ }
+ ++level;
+ mipImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ mip = TDFX_TEXIMAGE_DATA(mipImage);
+ _mesa_halve2x2_teximage2d(ctx,
+ texImage,
+ texelBytes,
+ mml->width, mml->height,
+ texImage->Data, mipImage->Data);
+ texImage = mipImage;
+ mml = mip;
+ width = mipWidth;
+ height = mipHeight;
+ }
+ }
+
+ ti->reloadImages = GL_TRUE; /* signal the image needs to be reloaded */
+ fxMesa->new_state |= TDFX_NEW_TEXTURE; /* XXX this might be a bit much */
+}
+
+
+static void
+tdfxTexImage1D(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat, GLint width, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ tdfxTexImage2D(ctx, target, level,
+ internalFormat, width, 1, border,
+ format, type, pixels,
+ packing,
+ texObj,
+ texImage);
+}
+
+static void
+tdfxTexSubImage1D(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 )
+{
+ tdfxTexSubImage2D(ctx, target, level,
+ xoffset, 0,
+ width, 1,
+ format, type,
+ pixels,
+ packing,
+ texObj,
+ texImage);
+}
+
+/**********************************************************************/
+/**** COMPRESSED TEXTURE IMAGE FUNCTIONS ****/
+/**********************************************************************/
+
+static void
+tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
+ GLint level, GLint internalFormat,
+ GLsizei width, GLsizei height, GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxTexInfo *ti;
+ tdfxMipMapLevel *mml;
+
+ if (TDFX_DEBUG & DEBUG_VERBOSE_DRI) {
+ fprintf(stderr, "tdfxCompressedTexImage2D: id=%d int 0x%x %dx%d\n",
+ texObj->Name, internalFormat,
+ width, height);
+ }
+
+ if ((target != GL_TEXTURE_1D && target != GL_TEXTURE_2D) || texImage->Border > 0) {
+ _mesa_problem(NULL, "tdfx: unsupported texture in tdfxCompressedTexImg()\n");
+ return;
+ }
+
+ assert(texImage->IsCompressed);
+
+ ti = TDFX_TEXTURE_DATA(texObj);
+ if (!ti) {
+ texObj->DriverData = fxAllocTexObjData(fxMesa);
+ if (!texObj->DriverData) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
+ return;
+ }
+ ti = TDFX_TEXTURE_DATA(texObj);
+ }
+ assert(ti);
+
+ mml = TDFX_TEXIMAGE_DATA(texImage);
+ if (!mml) {
+ texImage->DriverData = CALLOC(sizeof(tdfxMipMapLevel));
+ if (!texImage->DriverData) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
+ return;
+ }
+ mml = TDFX_TEXIMAGE_DATA(texImage);
+ }
+
+ tdfxTexGetInfo(ctx, width, height, NULL, NULL, NULL, NULL,
+ &mml->wScale, &mml->hScale);
+
+ mml->width = width * mml->wScale;
+ mml->height = height * mml->hScale;
+
+
+ /* choose the texture format */
+ assert(ctx->Driver.ChooseTextureFormat);
+ texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
+ internalFormat, -1/*format*/, -1/*type*/);
+ assert(texImage->TexFormat);
+
+ /* Determine the appropriate Glide texel format,
+ * given the user's internal texture format hint.
+ */
+ mml->glideFormat = fxGlideFormat(texImage->TexFormat->MesaFormat);
+ ti->info.format = mml->glideFormat;
+ texImage->FetchTexelc = fxFetchFunction(texImage->TexFormat->MesaFormat);
+
+ /* allocate new storage for texture image, if needed */
+ if (!texImage->Data) {
+ texImage->CompressedSize = _mesa_compressed_texture_size(ctx,
+ mml->width,
+ mml->height,
+ 1,
+ internalFormat);
+ texImage->Data = _mesa_malloc(texImage->CompressedSize);
+ if (!texImage->Data) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
+ return;
+ }
+ }
+
+ /* save the texture data */
+ if (mml->wScale != 1 || mml->hScale != 1) {
+ /* [dBorca] Hack alert:
+ * now we're screwed. We can't decompress,
+ * unless we do it in HW (via textureBuffer).
+ * We still have some chances:
+ * 1) we got FXT1 textures - we CAN decompress, rescale for
+ * aspectratio, then compress back.
+ * 2) there is a chance that MIN("s", "t") won't be overflowed.
+ * Thus, we don't care about textureclamp and we could lower
+ * MIN("uscale", "vscale") below 32. We still have to have
+ * our data aligned inside a 8:1 rectangle.
+ * 3) just in case if MIN("s", "t") gets overflowed with GL_REPEAT,
+ * we replicate the data over the padded area.
+ * For now, we take 2) + 3) but texelfetchers will be wrong!
+ */
+ GLuint srcRowStride = _mesa_compressed_row_stride(internalFormat, width);
+
+ GLuint destRowStride = _mesa_compressed_row_stride(internalFormat,
+ mml->width);
+
+ _mesa_upscale_teximage2d(srcRowStride, (height+3) / 4,
+ destRowStride, (mml->height+3) / 4,
+ 1, data, srcRowStride,
+ texImage->Data);
+ ti->padded = GL_TRUE;
+ } else {
+ MEMCPY(texImage->Data, data, texImage->CompressedSize);
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ assert(!texImage->IsCompressed);
+ }
+
+ RevalidateTexture(ctx, texObj);
+
+ ti->reloadImages = GL_TRUE;
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+}
+
+
+static void
+tdfxCompressedTexSubImage2D( 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 )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxTexInfo *ti;
+ tdfxMipMapLevel *mml;
+ GLint destRowStride, srcRowStride;
+ GLint i, rows;
+ GLubyte *dest;
+
+ if (TDFX_DEBUG & DEBUG_VERBOSE_DRI) {
+ fprintf(stderr, "tdfxCompressedTexSubImage2D: id=%d\n", texObj->Name);
+ }
+
+ ti = TDFX_TEXTURE_DATA(texObj);
+ assert(ti);
+ mml = TDFX_TEXIMAGE_DATA(texImage);
+ assert(mml);
+
+ srcRowStride = _mesa_compressed_row_stride(texImage->IntFormat, width);
+
+ destRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
+ mml->width);
+ dest = _mesa_compressed_image_address(xoffset, yoffset, 0,
+ texImage->IntFormat,
+ mml->width,
+ (GLubyte*) texImage->Data);
+
+ rows = height / 4; /* [dBorca] hardcoded 4, but works for FXT1/DXTC */
+
+ for (i = 0; i < rows; i++) {
+ MEMCPY(dest, data, srcRowStride);
+ dest += destRowStride;
+ data = (GLvoid *)((GLuint)data + (GLuint)srcRowStride);
+ }
+
+ /* [dBorca] Hack alert:
+ * see fxDDCompressedTexImage2D for caveats
+ */
+ if (mml->wScale != 1 || mml->hScale != 1) {
+ srcRowStride = _mesa_compressed_row_stride(texImage->IntFormat, texImage->Width);
+
+ destRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
+ mml->width);
+ _mesa_upscale_teximage2d(srcRowStride, texImage->Height / 4,
+ destRowStride, mml->height / 4,
+ 1, texImage->Data, destRowStride,
+ texImage->Data);
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ assert(!texImage->IsCompressed);
+ }
+
+ RevalidateTexture(ctx, texObj);
+
+ ti->reloadImages = GL_TRUE;
+ fxMesa->new_state |= TDFX_NEW_TEXTURE;
+}
+
+
+#if 0
+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");
+ }
+}
+#endif
+
+
+GLboolean
+tdfxTestProxyTexImage(GLcontext *ctx, GLenum target,
+ GLint level, GLint internalFormat,
+ GLenum format, GLenum type,
+ GLint width, GLint height,
+ GLint depth, GLint border)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+
+ switch (target) {
+ case GL_PROXY_TEXTURE_1D:
+ /*JJJ wrong*/
+ case GL_PROXY_TEXTURE_2D:
+ {
+ struct gl_texture_object *tObj;
+ tdfxTexInfo *ti;
+ int memNeeded;
+
+ tObj = ctx->Texture.Proxy2D;
+ if (!tObj->DriverData)
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
+ ti = TDFX_TEXTURE_DATA(tObj);
+ assert(ti);
+
+ /* assign the parameters to test against */
+ tObj->Image[0][level]->Width = width;
+ tObj->Image[0][level]->Height = height;
+ tObj->Image[0][level]->Border = border;
+#if 0
+ tObj->Image[0][level]->IntFormat = internalFormat;
+#endif
+ if (level == 0) {
+ /* don't use mipmap levels > 0 */
+ tObj->MinFilter = tObj->MagFilter = GL_NEAREST;
+ }
+ else {
+ /* test with all mipmap levels */
+ tObj->MinFilter = GL_LINEAR_MIPMAP_LINEAR;
+ tObj->MagFilter = GL_NEAREST;
+ }
+ RevalidateTexture(ctx, tObj);
+
+ /*
+ printf("small lodlog2 0x%x\n", ti->info.smallLodLog2);
+ printf("large lodlog2 0x%x\n", ti->info.largeLodLog2);
+ printf("aspect ratio 0x%x\n", ti->info.aspectRatioLog2);
+ printf("glide format 0x%x\n", ti->info.format);
+ printf("data %p\n", ti->info.data);
+ printf("lodblend %d\n", (int) ti->LODblend);
+ */
+
+ /* determine where texture will reside */
+ if (ti->LODblend && !shared->umaTexMemory) {
+ /* XXX GR_MIPMAPLEVELMASK_BOTH might not be right, but works */
+ memNeeded = fxMesa->Glide.grTexTextureMemRequired(
+ GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
+ }
+ else {
+ /* XXX GR_MIPMAPLEVELMASK_BOTH might not be right, but works */
+ memNeeded = fxMesa->Glide.grTexTextureMemRequired(
+ GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
+ }
+ /*
+ printf("Proxy test %d > %d\n", memNeeded, shared->totalTexMem[0]);
+ */
+ if (memNeeded > shared->totalTexMem[0])
+ return GL_FALSE;
+ else
+ return GL_TRUE;
+ }
+ case GL_PROXY_TEXTURE_3D:
+ return GL_TRUE; /* software rendering */
+ default:
+ return GL_TRUE; /* never happens, silence compiler */
+ }
+}
+
+
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
+ * Note: this function will be called during context creation to
+ * allocate the default texture objects.
+ * Note: we could use containment here to 'derive' the driver-specific
+ * texture object from the core mesa gl_texture_object. Not done at this time.
+ */
+static struct gl_texture_object *
+tdfxNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+{
+ struct gl_texture_object *obj;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ return obj;
+}
+
+
+void tdfxInitTextureFuncs( struct dd_function_table *functions )
+{
+ functions->BindTexture = tdfxBindTexture;
+ functions->NewTextureObject = tdfxNewTextureObject;
+ functions->DeleteTexture = tdfxDeleteTexture;
+ functions->TexEnv = tdfxTexEnv;
+ functions->TexParameter = tdfxTexParameter;
+ functions->ChooseTextureFormat = tdfxChooseTextureFormat;
+ functions->TexImage1D = tdfxTexImage1D;
+ functions->TexSubImage1D = tdfxTexSubImage1D;
+ functions->TexImage2D = tdfxTexImage2D;
+ functions->TexSubImage2D = tdfxTexSubImage2D;
+ functions->IsTextureResident = tdfxIsTextureResident;
+ functions->CompressedTexImage2D = tdfxCompressedTexImage2D;
+ functions->CompressedTexSubImage2D = tdfxCompressedTexSubImage2D;
+ functions->UpdateTexturePalette = tdfxUpdateTexturePalette;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.h
new file mode 100644
index 000000000..f536c25a2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tex.h
@@ -0,0 +1,102 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_tex.h,v 1.2 2002/02/22 21:45:04 dawes Exp $ */
+
+/*
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ *
+ */
+
+#ifndef _TDFX_TEX_H_
+#define _TDFX_TEX_H_
+
+
+#define tdfxDDIsCompressedFormatMacro(internalFormat) \
+ (((internalFormat) == GL_COMPRESSED_RGB_FXT1_3DFX) || \
+ ((internalFormat) == GL_COMPRESSED_RGBA_FXT1_3DFX))
+#define tdfxDDIsCompressedGlideFormatMacro(internalFormat) \
+ ((internalFormat) == GR_TEXFMT_ARGB_CMP_FXT1)
+
+
+
+extern void
+tdfxTexValidate(GLcontext * ctx, struct gl_texture_object *tObj);
+
+
+#if 000 /* DEAD? */
+extern void
+fxDDTexUseGlobalPalette(GLcontext * ctx, GLboolean state);
+#endif
+
+extern GLboolean
+tdfxTestProxyTexImage(GLcontext *ctx, GLenum target,
+ GLint level, GLint internalFormat,
+ GLenum format, GLenum type,
+ GLint width, GLint height,
+ GLint depth, GLint border);
+
+extern GLvoid *
+tdfxDDGetTexImage(GLcontext * ctx, GLenum target, GLint level,
+ const struct gl_texture_object *texObj,
+ GLenum * formatOut, GLenum * typeOut,
+ GLboolean * freeImageOut);
+
+extern void
+tdfxDDGetCompressedTexImage( GLcontext *ctx, GLenum target,
+ GLint lod, void *image,
+ const struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage );
+
+extern GLint
+tdfxSpecificCompressedTexFormat(GLcontext *ctx,
+ GLint internalFormat,
+ GLint numDimensions);
+
+extern GLint
+tdfxBaseCompressedTexFormat(GLcontext *ctx,
+ GLint internalFormat);
+
+extern GLboolean
+tdfxDDIsCompressedFormat(GLcontext *ctx, GLint internalFormat);
+
+extern GLsizei
+tdfxDDCompressedImageSize(GLcontext *ctx,
+ GLenum intFormat,
+ GLuint numDimensions,
+ GLuint width,
+ GLuint height,
+ GLuint depth);
+
+
+extern void
+tdfxInitTextureFuncs( struct dd_function_table *functions );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.c
new file mode 100644
index 000000000..63cae17e4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.c
@@ -0,0 +1,994 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_texman.c,v 1.5 2002/02/22 21:45:04 dawes Exp $ */
+
+/*
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ *
+ */
+
+#include "tdfx_context.h"
+#include "tdfx_tex.h"
+#include "tdfx_texman.h"
+#include "hash.h"
+
+
+#define BAD_ADDRESS ((FxU32) -1)
+
+
+#if 0 /* DEBUG use */
+/*
+ * Verify the consistancy of the texture memory manager.
+ * This involves:
+ * Traversing all texture objects and computing total memory used.
+ * Traverse the free block list and computing total memory free.
+ * Compare the total free and total used amounts to the total memory size.
+ * Make various assertions about the results.
+ */
+static void
+VerifyFreeList(tdfxContextPtr fxMesa, FxU32 tmu)
+{
+ struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ tdfxMemRange *block;
+ int prevStart = -1, prevEnd = -1;
+ int totalFree = 0;
+ int numObj = 0, numRes = 0;
+ int totalUsed = 0;
+
+ for (block = shared->tmFree[tmu]; block; block = block->next) {
+ assert( block->endAddr > 0 );
+ assert( block->startAddr <= shared->totalTexMem[tmu] );
+ assert( block->endAddr <= shared->totalTexMem[tmu] );
+ assert( (int) block->startAddr > prevStart );
+ assert( (int) block->startAddr >= prevEnd );
+ prevStart = (int) block->startAddr;
+ prevEnd = (int) block->endAddr;
+ totalFree += (block->endAddr - block->startAddr);
+ }
+ assert(totalFree == shared->freeTexMem[tmu]);
+
+ {
+ struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects;
+ GLuint id;
+ for (id = _mesa_HashFirstEntry(textures);
+ id;
+ id = _mesa_HashNextEntry(textures, id)) {
+ struct gl_texture_object *tObj;
+ tObj = (struct gl_texture_object *) _mesa_HashLookup(textures, id);
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
+ if (ti) {
+ if (ti->isInTM) {
+ numRes++;
+ assert(ti->tm[0]);
+ if (ti->tm[tmu])
+ totalUsed += (ti->tm[tmu]->endAddr - ti->tm[tmu]->startAddr);
+ }
+ else {
+ assert(!ti->tm[0]);
+ }
+ }
+ }
+ }
+
+ printf("totalFree: %d totalUsed: %d totalMem: %d #objs=%d #res=%d\n",
+ shared->freeTexMem[tmu], totalUsed, shared->totalTexMem[tmu],
+ numObj, numRes);
+
+ assert(totalUsed + totalFree == shared->totalTexMem[tmu]);
+}
+
+
+static void
+dump_texmem(tdfxContextPtr fxMesa)
+{
+ struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ struct _mesa_HashTable *textures = mesaShared->TexObjects;
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ tdfxMemRange *r;
+ FxU32 prev;
+ GLuint id;
+
+ printf("DUMP Objects:\n");
+ for (id = _mesa_HashFirstEntry(textures);
+ id;
+ id = _mesa_HashNextEntry(textures, id)) {
+ struct gl_texture_object *obj
+ = (struct gl_texture_object *) _mesa_HashLookup(textures, id);
+ tdfxTexInfo *info = TDFX_TEXTURE_DATA(obj);
+
+ if (info && info->isInTM) {
+ printf("Obj %8p: %4d info = %p\n", obj, obj->Name, info);
+
+ printf(" isInTM=%d whichTMU=%d lastTimeUsed=%d\n",
+ info->isInTM, info->whichTMU, info->lastTimeUsed);
+ printf(" tm[0] = %p", info->tm[0]);
+ assert(info->tm[0]);
+ if (info->tm[0]) {
+ printf(" tm startAddr = %d endAddr = %d",
+ info->tm[0]->startAddr,
+ info->tm[0]->endAddr);
+ }
+ printf("\n");
+ printf(" tm[1] = %p", info->tm[1]);
+ if (info->tm[1]) {
+ printf(" tm startAddr = %d endAddr = %d",
+ info->tm[1]->startAddr,
+ info->tm[1]->endAddr);
+ }
+ printf("\n");
+ }
+ }
+
+ VerifyFreeList(fxMesa, 0);
+ VerifyFreeList(fxMesa, 1);
+
+ printf("Free memory unit 0: %d bytes\n", shared->freeTexMem[0]);
+ prev = 0;
+ for (r = shared->tmFree[0]; r; r = r->next) {
+ printf("%8p: start %8d end %8d size %8d gap %8d\n", r, r->startAddr, r->endAddr, r->endAddr - r->startAddr, r->startAddr - prev);
+ prev = r->endAddr;
+ }
+
+ printf("Free memory unit 1: %d bytes\n", shared->freeTexMem[1]);
+ prev = 0;
+ for (r = shared->tmFree[1]; r; r = r->next) {
+ printf("%8p: start %8d end %8d size %8d gap %8d\n", r, r->startAddr, r->endAddr, r->endAddr - r->startAddr, r->startAddr - prev);
+ prev = r->endAddr;
+ }
+
+}
+#endif
+
+
+
+#ifdef TEXSANITY
+static void
+fubar(void)
+{
+}
+
+/*
+ * Sanity Check
+ */
+static void
+sanity(tdfxContextPtr fxMesa)
+{
+ tdfxMemRange *tmp, *prev, *pos;
+
+ prev = 0;
+ tmp = fxMesa->tmFree[0];
+ while (tmp) {
+ if (!tmp->startAddr && !tmp->endAddr) {
+ fprintf(stderr, "Textures fubar\n");
+ fubar();
+ }
+ if (tmp->startAddr >= tmp->endAddr) {
+ fprintf(stderr, "Node fubar\n");
+ fubar();
+ }
+ if (prev && (prev->startAddr >= tmp->startAddr ||
+ prev->endAddr > tmp->startAddr)) {
+ fprintf(stderr, "Sorting fubar\n");
+ fubar();
+ }
+ prev = tmp;
+ tmp = tmp->next;
+ }
+ prev = 0;
+ tmp = fxMesa->tmFree[1];
+ while (tmp) {
+ if (!tmp->startAddr && !tmp->endAddr) {
+ fprintf(stderr, "Textures fubar\n");
+ fubar();
+ }
+ if (tmp->startAddr >= tmp->endAddr) {
+ fprintf(stderr, "Node fubar\n");
+ fubar();
+ }
+ if (prev && (prev->startAddr >= tmp->startAddr ||
+ prev->endAddr > tmp->startAddr)) {
+ fprintf(stderr, "Sorting fubar\n");
+ fubar();
+ }
+ prev = tmp;
+ tmp = tmp->next;
+ }
+}
+#endif
+
+
+
+
+
+/*
+ * Allocate and initialize a new MemRange struct.
+ * Try to allocate it from the pool of free MemRange nodes rather than malloc.
+ */
+static tdfxMemRange *
+NewRangeNode(tdfxContextPtr fxMesa, FxU32 start, FxU32 end)
+{
+ struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ tdfxMemRange *result;
+
+ _glthread_LOCK_MUTEX(mesaShared->Mutex);
+ if (shared && shared->tmPool) {
+ result = shared->tmPool;
+ shared->tmPool = shared->tmPool->next;
+ }
+ else {
+ result = MALLOC(sizeof(tdfxMemRange));
+
+ }
+ _glthread_UNLOCK_MUTEX(mesaShared->Mutex);
+
+ if (!result) {
+ /*fprintf(stderr, "fxDriver: out of memory!\n");*/
+ return NULL;
+ }
+
+ result->startAddr = start;
+ result->endAddr = end;
+ result->next = NULL;
+
+ return result;
+}
+
+
+/*
+ * Initialize texture memory.
+ * We take care of one or both TMU's here.
+ */
+void
+tdfxTMInit(tdfxContextPtr fxMesa)
+{
+ if (!fxMesa->glCtx->Shared->DriverData) {
+ const char *extensions;
+ struct tdfxSharedState *shared = CALLOC_STRUCT(tdfxSharedState);
+ if (!shared)
+ return;
+
+ LOCK_HARDWARE(fxMesa);
+ extensions = fxMesa->Glide.grGetString(GR_EXTENSION);
+ UNLOCK_HARDWARE(fxMesa);
+ if (strstr(extensions, "TEXUMA")) {
+ FxU32 start, end;
+ shared->umaTexMemory = GL_TRUE;
+ LOCK_HARDWARE(fxMesa);
+ fxMesa->Glide.grEnable(GR_TEXTURE_UMA_EXT);
+ start = fxMesa->Glide.grTexMinAddress(0);
+ end = fxMesa->Glide.grTexMaxAddress(0);
+ UNLOCK_HARDWARE(fxMesa);
+ shared->totalTexMem[0] = end - start;
+ shared->totalTexMem[1] = 0;
+ shared->freeTexMem[0] = end - start;
+ shared->freeTexMem[1] = 0;
+ shared->tmFree[0] = NewRangeNode(fxMesa, start, end);
+ shared->tmFree[1] = NULL;
+ /*printf("UMA tex memory: %d\n", (int) (end - start));*/
+ }
+ else {
+ const int numTMUs = fxMesa->haveTwoTMUs ? 2 : 1;
+ int tmu;
+ shared->umaTexMemory = GL_FALSE;
+ LOCK_HARDWARE(fxMesa);
+ for (tmu = 0; tmu < numTMUs; tmu++) {
+ FxU32 start = fxMesa->Glide.grTexMinAddress(tmu);
+ FxU32 end = fxMesa->Glide.grTexMaxAddress(tmu);
+ shared->totalTexMem[tmu] = end - start;
+ shared->freeTexMem[tmu] = end - start;
+ shared->tmFree[tmu] = NewRangeNode(fxMesa, start, end);
+ /*printf("Split tex memory: %d\n", (int) (end - start));*/
+ }
+ UNLOCK_HARDWARE(fxMesa);
+ }
+
+ shared->tmPool = NULL;
+ fxMesa->glCtx->Shared->DriverData = shared;
+ /*printf("Texture memory init UMA: %d\n", shared->umaTexMemory);*/
+ }
+}
+
+
+/*
+ * Clean-up texture memory before destroying context.
+ */
+void
+tdfxTMClose(tdfxContextPtr fxMesa)
+{
+ if (fxMesa->glCtx->Shared->RefCount == 1 && fxMesa->driDrawable) {
+ /* refcount will soon go to zero, free our 3dfx stuff */
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) fxMesa->glCtx->Shared->DriverData;
+
+ const int numTMUs = fxMesa->haveTwoTMUs ? 2 : 1;
+ int tmu;
+ tdfxMemRange *tmp, *next;
+
+ /* Deallocate the pool of free tdfxMemRange nodes */
+ tmp = shared->tmPool;
+ while (tmp) {
+ next = tmp->next;
+ FREE(tmp);
+ tmp = next;
+ }
+
+ /* Delete the texture memory block tdfxMemRange nodes */
+ for (tmu = 0; tmu < numTMUs; tmu++) {
+ tmp = shared->tmFree[tmu];
+ while (tmp) {
+ next = tmp->next;
+ FREE(tmp);
+ tmp = next;
+ }
+ }
+
+ FREE(shared);
+ fxMesa->glCtx->Shared->DriverData = NULL;
+ }
+}
+
+
+
+/*
+ * Delete a tdfxMemRange struct.
+ * We keep a linked list of free/available tdfxMemRange structs to
+ * avoid extra malloc/free calls.
+ */
+#if 0
+static void
+DeleteRangeNode_NoLock(struct TdfxSharedState *shared, tdfxMemRange *range)
+{
+ /* insert at head of list */
+ range->next = shared->tmPool;
+ shared->tmPool = range;
+}
+#endif
+
+#define DELETE_RANGE_NODE(shared, range) \
+ (range)->next = (shared)->tmPool; \
+ (shared)->tmPool = (range)
+
+
+
+/*
+ * When we've run out of texture memory we have to throw out an
+ * existing texture to make room for the new one. This function
+ * determins the texture to throw out.
+ */
+static struct gl_texture_object *
+FindOldestObject(tdfxContextPtr fxMesa, FxU32 tmu)
+{
+ const GLuint bindnumber = fxMesa->texBindNumber;
+ struct gl_texture_object *oldestObj, *lowestPriorityObj;
+ GLfloat lowestPriority;
+ GLuint oldestAge;
+ GLuint id;
+ struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects;
+
+ oldestObj = NULL;
+ oldestAge = 0;
+
+ lowestPriority = 1.0F;
+ lowestPriorityObj = NULL;
+
+ for (id = _mesa_HashFirstEntry(textures);
+ id;
+ id = _mesa_HashNextEntry(textures, id)) {
+ struct gl_texture_object *obj
+ = (struct gl_texture_object *) _mesa_HashLookup(textures, id);
+ tdfxTexInfo *info = TDFX_TEXTURE_DATA(obj);
+
+ if (info && info->isInTM &&
+ ((info->whichTMU == tmu) || (info->whichTMU == TDFX_TMU_BOTH) ||
+ (info->whichTMU == TDFX_TMU_SPLIT))) {
+ GLuint age, lasttime;
+
+ assert(info->tm[0]);
+ lasttime = info->lastTimeUsed;
+
+ if (lasttime > bindnumber)
+ age = bindnumber + (UINT_MAX - lasttime + 1); /* TO DO: check wrap around */
+ else
+ age = bindnumber - lasttime;
+
+ if (age >= oldestAge) {
+ oldestAge = age;
+ oldestObj = obj;
+ }
+
+ /* examine priority */
+ if (obj->Priority < lowestPriority) {
+ lowestPriority = obj->Priority;
+ lowestPriorityObj = obj;
+ }
+ }
+ }
+
+ if (lowestPriority < 1.0) {
+ ASSERT(lowestPriorityObj);
+ /*
+ printf("discard %d pri=%f\n", lowestPriorityObj->Name, lowestPriority);
+ */
+ return lowestPriorityObj;
+ }
+ else {
+ /*
+ printf("discard %d age=%d\n", oldestObj->Name, oldestAge);
+ */
+ return oldestObj;
+ }
+}
+
+
+#if 0
+static void
+FlushTexMemory(tdfxContextPtr fxMesa)
+{
+ struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects;
+ GLuint id;
+
+ for (id = _mesa_HashFirstEntry(textures);
+ id;
+ id = _mesa_HashNextEntry(textures, id)) {
+ struct gl_texture_object *obj
+ = (struct gl_texture_object *) _mesa_HashLookup(textures, id);
+ if (obj->RefCount < 2) {
+ /* don't flush currently bound textures */
+ tdfxTMMoveOutTM_NoLock(fxMesa, obj);
+ }
+ }
+}
+#endif
+
+
+/*
+ * Find the address (offset?) at which we can store a new texture.
+ * <tmu> is the texture unit.
+ * <size> is the texture size in bytes.
+ */
+static FxU32
+FindStartAddr(tdfxContextPtr fxMesa, FxU32 tmu, FxU32 size)
+{
+ struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ tdfxMemRange *prev, *block;
+ FxU32 result;
+#if 0
+ int discardedCount = 0;
+#define MAX_DISCARDS 10
+#endif
+
+ if (shared->umaTexMemory) {
+ assert(tmu == TDFX_TMU0);
+ }
+
+ _glthread_LOCK_MUTEX(mesaShared->Mutex);
+ while (1) {
+ prev = NULL;
+ block = shared->tmFree[tmu];
+ while (block) {
+ if (block->endAddr - block->startAddr >= size) {
+ /* The texture will fit here */
+ result = block->startAddr;
+ block->startAddr += size;
+ if (block->startAddr == block->endAddr) {
+ /* Remove this node since it's empty */
+ if (prev) {
+ prev->next = block->next;
+ }
+ else {
+ shared->tmFree[tmu] = block->next;
+ }
+ DELETE_RANGE_NODE(shared, block);
+ }
+ shared->freeTexMem[tmu] -= size;
+ _glthread_UNLOCK_MUTEX(mesaShared->Mutex);
+ return result;
+ }
+ prev = block;
+ block = block->next;
+ }
+ /* We failed to find a block large enough to accomodate <size> bytes.
+ * Find the oldest texObject and free it.
+ */
+#if 0
+ discardedCount++;
+ if (discardedCount > MAX_DISCARDS + 1) {
+ _mesa_problem(NULL, "%s: extreme texmem fragmentation", __FUNCTION__);
+ _glthread_UNLOCK_MUTEX(mesaShared->Mutex);
+ return BAD_ADDRESS;
+ }
+ else if (discardedCount > MAX_DISCARDS) {
+ /* texture memory is probably really fragmented, flush it */
+ FlushTexMemory(fxMesa);
+ }
+ else
+#endif
+ {
+ struct gl_texture_object *obj = FindOldestObject(fxMesa, tmu);
+ if (obj) {
+ tdfxTMMoveOutTM_NoLock(fxMesa, obj);
+ fxMesa->stats.texSwaps++;
+ }
+ else {
+ _mesa_problem(NULL, "%s: extreme texmem fragmentation", __FUNCTION__);
+ _glthread_UNLOCK_MUTEX(mesaShared->Mutex);
+ return BAD_ADDRESS;
+ }
+ }
+ }
+
+ /* never get here, but play it safe */
+ _glthread_UNLOCK_MUTEX(mesaShared->Mutex);
+ return BAD_ADDRESS;
+}
+
+
+/*
+ * Remove the given tdfxMemRange node from hardware texture memory.
+ */
+static void
+RemoveRange_NoLock(tdfxContextPtr fxMesa, FxU32 tmu, tdfxMemRange *range)
+{
+ struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ tdfxMemRange *block, *prev;
+
+ if (shared->umaTexMemory) {
+ assert(tmu == TDFX_TMU0);
+ }
+
+ if (!range)
+ return;
+
+ if (range->startAddr == range->endAddr) {
+ DELETE_RANGE_NODE(shared, range);
+ return;
+ }
+ shared->freeTexMem[tmu] += range->endAddr - range->startAddr;
+
+ /* find position in linked list to insert this tdfxMemRange node */
+ prev = NULL;
+ block = shared->tmFree[tmu];
+ while (block) {
+ assert(range->startAddr != block->startAddr);
+ if (range->startAddr > block->startAddr) {
+ prev = block;
+ block = block->next;
+ }
+ else {
+ break;
+ }
+ }
+
+ /* Insert the free block, combine with adjacent blocks when possible */
+ range->next = block;
+ if (block) {
+ if (range->endAddr == block->startAddr) {
+ /* Combine */
+ block->startAddr = range->startAddr;
+ DELETE_RANGE_NODE(shared, range);
+ range = block;
+ }
+ }
+ if (prev) {
+ if (prev->endAddr == range->startAddr) {
+ /* Combine */
+ prev->endAddr = range->endAddr;
+ prev->next = range->next;
+ DELETE_RANGE_NODE(shared, range);
+ }
+ else {
+ prev->next = range;
+ }
+ }
+ else {
+ shared->tmFree[tmu] = range;
+ }
+}
+
+
+#if 0 /* NOT USED */
+static void
+RemoveRange(tdfxContextPtr fxMesa, FxU32 tmu, tdfxMemRange *range)
+{
+ struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ _glthread_LOCK_MUTEX(mesaShared->Mutex);
+ RemoveRange_NoLock(fxMesa, tmu, range);
+ _glthread_UNLOCK_MUTEX(mesaShared->Mutex);
+}
+#endif
+
+
+/*
+ * Allocate space for a texture image.
+ * <tmu> is the texture unit
+ * <texmemsize> is the number of bytes to allocate
+ */
+static tdfxMemRange *
+AllocTexMem(tdfxContextPtr fxMesa, FxU32 tmu, FxU32 texmemsize)
+{
+ FxU32 startAddr;
+ startAddr = FindStartAddr(fxMesa, tmu, texmemsize);
+ if (startAddr == BAD_ADDRESS) {
+ _mesa_problem(fxMesa->glCtx, "%s returned NULL! tmu=%d texmemsize=%d",
+ __FUNCTION__, (int) tmu, (int) texmemsize);
+ return NULL;
+ }
+ else {
+ tdfxMemRange *range;
+ range = NewRangeNode(fxMesa, startAddr, startAddr + texmemsize);
+ return range;
+ }
+}
+
+
+/*
+ * Download (copy) the given texture data (all mipmap levels) into the
+ * Voodoo's texture memory.
+ * The texture memory must have already been allocated.
+ */
+void
+tdfxTMDownloadTexture(tdfxContextPtr fxMesa, struct gl_texture_object *tObj)
+{
+ tdfxTexInfo *ti;
+ GLint l;
+ FxU32 targetTMU;
+
+ assert(tObj);
+ ti = TDFX_TEXTURE_DATA(tObj);
+ assert(ti);
+ targetTMU = ti->whichTMU;
+
+ switch (targetTMU) {
+ case TDFX_TMU0:
+ case TDFX_TMU1:
+ if (ti->tm[targetTMU]) {
+ for (l = ti->minLevel; l <= ti->maxLevel
+ && tObj->Image[0][l]->Data; l++) {
+ GrLOD_t glideLod = ti->info.largeLodLog2 - l + tObj->BaseLevel;
+ fxMesa->Glide.grTexDownloadMipMapLevel(targetTMU,
+ ti->tm[targetTMU]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ tObj->Image[0][l]->Data);
+ }
+ }
+ break;
+ case TDFX_TMU_SPLIT:
+ if (ti->tm[TDFX_TMU0] && ti->tm[TDFX_TMU1]) {
+ for (l = ti->minLevel; l <= ti->maxLevel
+ && tObj->Image[0][l]->Data; l++) {
+ GrLOD_t glideLod = ti->info.largeLodLog2 - l + tObj->BaseLevel;
+ fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU0,
+ ti->tm[TDFX_TMU0]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_ODD,
+ tObj->Image[0][l]->Data);
+
+ fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU1,
+ ti->tm[TDFX_TMU1]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_EVEN,
+ tObj->Image[0][l]->Data);
+ }
+ }
+ break;
+ case TDFX_TMU_BOTH:
+ if (ti->tm[TDFX_TMU0] && ti->tm[TDFX_TMU1]) {
+ for (l = ti->minLevel; l <= ti->maxLevel
+ && tObj->Image[0][l]->Data; l++) {
+ GrLOD_t glideLod = ti->info.largeLodLog2 - l + tObj->BaseLevel;
+ fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU0,
+ ti->tm[TDFX_TMU0]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ tObj->Image[0][l]->Data);
+
+ fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU1,
+ ti->tm[TDFX_TMU1]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ tObj->Image[0][l]->Data);
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL, "%s: bad tmu (%d)", __FUNCTION__, (int)targetTMU);
+ return;
+ }
+}
+
+
+void
+tdfxTMReloadMipMapLevel(GLcontext *ctx, struct gl_texture_object *tObj,
+ GLint level)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
+ GrLOD_t glideLod;
+ FxU32 tmu;
+
+ tmu = ti->whichTMU;
+ glideLod = ti->info.largeLodLog2 - level + tObj->BaseLevel;
+ ASSERT(ti->isInTM);
+
+ LOCK_HARDWARE(fxMesa);
+
+ switch (tmu) {
+ case TDFX_TMU0:
+ case TDFX_TMU1:
+ fxMesa->Glide.grTexDownloadMipMapLevel(tmu,
+ ti->tm[tmu]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ tObj->Image[0][level]->Data);
+ break;
+ case TDFX_TMU_SPLIT:
+ fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU0,
+ ti->tm[GR_TMU0]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_ODD,
+ tObj->Image[0][level]->Data);
+
+ fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU1,
+ ti->tm[GR_TMU1]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_EVEN,
+ tObj->Image[0][level]->Data);
+ break;
+ case TDFX_TMU_BOTH:
+ fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU0,
+ ti->tm[GR_TMU0]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ tObj->Image[0][level]->Data);
+
+ fxMesa->Glide.grTexDownloadMipMapLevel(GR_TMU1,
+ ti->tm[GR_TMU1]->startAddr,
+ glideLod,
+ ti->info.largeLodLog2,
+ ti->info.aspectRatioLog2,
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ tObj->Image[0][level]->Data);
+ break;
+
+ default:
+ _mesa_problem(ctx, "%s: bad tmu (%d)", __FUNCTION__, (int)tmu);
+ break;
+ }
+ UNLOCK_HARDWARE(fxMesa);
+}
+
+
+/*
+ * Allocate space for the given texture in texture memory then
+ * download (copy) it into that space.
+ */
+void
+tdfxTMMoveInTM_NoLock( tdfxContextPtr fxMesa, struct gl_texture_object *tObj,
+ FxU32 targetTMU )
+{
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
+ FxU32 texmemsize;
+
+ fxMesa->stats.reqTexUpload++;
+
+ if (ti->isInTM) {
+ if (ti->whichTMU == targetTMU)
+ return;
+ if (targetTMU == TDFX_TMU_SPLIT || ti->whichTMU == TDFX_TMU_SPLIT) {
+ tdfxTMMoveOutTM_NoLock(fxMesa, tObj);
+ }
+ else {
+ if (ti->whichTMU == TDFX_TMU_BOTH)
+ return;
+ targetTMU = TDFX_TMU_BOTH;
+ }
+ }
+
+ ti->whichTMU = targetTMU;
+
+ switch (targetTMU) {
+ case TDFX_TMU0:
+ case TDFX_TMU1:
+ texmemsize = fxMesa->Glide.grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH,
+ &(ti->info));
+ ti->tm[targetTMU] = AllocTexMem(fxMesa, targetTMU, texmemsize);
+ break;
+ case TDFX_TMU_SPLIT:
+ texmemsize = fxMesa->Glide.grTexTextureMemRequired(GR_MIPMAPLEVELMASK_ODD,
+ &(ti->info));
+ ti->tm[TDFX_TMU0] = AllocTexMem(fxMesa, TDFX_TMU0, texmemsize);
+ if (ti->tm[TDFX_TMU0])
+ fxMesa->stats.memTexUpload += texmemsize;
+
+ texmemsize = fxMesa->Glide.grTexTextureMemRequired(GR_MIPMAPLEVELMASK_EVEN,
+ &(ti->info));
+ ti->tm[TDFX_TMU1] = AllocTexMem(fxMesa, TDFX_TMU1, texmemsize);
+ break;
+ case TDFX_TMU_BOTH:
+ texmemsize = fxMesa->Glide.grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH,
+ &(ti->info));
+ ti->tm[TDFX_TMU0] = AllocTexMem(fxMesa, TDFX_TMU0, texmemsize);
+ if (ti->tm[TDFX_TMU0])
+ fxMesa->stats.memTexUpload += texmemsize;
+
+ /*texmemsize = fxMesa->Glide.grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH,
+ &(ti->info));*/
+ ti->tm[TDFX_TMU1] = AllocTexMem(fxMesa, TDFX_TMU1, texmemsize);
+ break;
+ default:
+ _mesa_problem(NULL, "%s: bad tmu (%d)", __FUNCTION__, (int)targetTMU);
+ return;
+ }
+
+ ti->reloadImages = GL_TRUE;
+ ti->isInTM = GL_TRUE;
+
+ fxMesa->stats.texUpload++;
+}
+
+
+/*
+ * Move the given texture out of hardware texture memory.
+ * This deallocates the texture's memory space.
+ */
+void
+tdfxTMMoveOutTM_NoLock( tdfxContextPtr fxMesa, struct gl_texture_object *tObj )
+{
+ struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
+
+ if (MESA_VERBOSE & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxmesa: %s(%p (%d))\n", __FUNCTION__, (void *)tObj, tObj->Name);
+ }
+
+ /*
+ VerifyFreeList(fxMesa, 0);
+ VerifyFreeList(fxMesa, 1);
+ */
+
+ if (!ti || !ti->isInTM)
+ return;
+
+ switch (ti->whichTMU) {
+ case TDFX_TMU0:
+ case TDFX_TMU1:
+ RemoveRange_NoLock(fxMesa, ti->whichTMU, ti->tm[ti->whichTMU]);
+ break;
+ case TDFX_TMU_SPLIT:
+ case TDFX_TMU_BOTH:
+ assert(!shared->umaTexMemory);
+ RemoveRange_NoLock(fxMesa, TDFX_TMU0, ti->tm[TDFX_TMU0]);
+ RemoveRange_NoLock(fxMesa, TDFX_TMU1, ti->tm[TDFX_TMU1]);
+ break;
+ default:
+ _mesa_problem(NULL, "%s: bad tmu (%d)", __FUNCTION__, (int)ti->whichTMU);
+ return;
+ }
+
+ ti->isInTM = GL_FALSE;
+ ti->tm[0] = NULL;
+ ti->tm[1] = NULL;
+ ti->whichTMU = TDFX_TMU_NONE;
+
+ /*
+ VerifyFreeList(fxMesa, 0);
+ VerifyFreeList(fxMesa, 1);
+ */
+}
+
+
+/*
+ * Called via glDeleteTexture to delete a texture object.
+ */
+void
+tdfxTMFreeTexture(tdfxContextPtr fxMesa, struct gl_texture_object *tObj)
+{
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
+ if (ti) {
+ tdfxTMMoveOutTM(fxMesa, tObj);
+ FREE(ti);
+ tObj->DriverData = NULL;
+ }
+ /*
+ VerifyFreeList(fxMesa, 0);
+ VerifyFreeList(fxMesa, 1);
+ */
+}
+
+
+
+/*
+ * After a context switch this function will be called to restore
+ * texture memory for the new context.
+ */
+void tdfxTMRestoreTextures_NoLock( tdfxContextPtr fxMesa )
+{
+ GLcontext *ctx = fxMesa->glCtx;
+ struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects;
+ GLuint id;
+
+ for (id = _mesa_HashFirstEntry(textures);
+ id;
+ id = _mesa_HashNextEntry(textures, id)) {
+ struct gl_texture_object *tObj
+ = (struct gl_texture_object *) _mesa_HashLookup(textures, id);
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA( tObj );
+ if ( ti && ti->isInTM ) {
+ int i;
+ for ( i = 0 ; i < MAX_TEXTURE_UNITS ; i++ ) {
+ if ( ctx->Texture.Unit[i]._Current == tObj ) {
+ tdfxTMDownloadTexture( fxMesa, tObj );
+ break;
+ }
+ }
+ if ( i == MAX_TEXTURE_UNITS ) {
+ tdfxTMMoveOutTM_NoLock( fxMesa, tObj );
+ }
+ }
+ }
+ /*
+ VerifyFreeList(fxMesa, 0);
+ VerifyFreeList(fxMesa, 1);
+ */
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.h
new file mode 100644
index 000000000..739d4e142
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texman.h
@@ -0,0 +1,84 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_texman.h,v 1.2 2002/02/22 21:45:04 dawes Exp $ */
+
+/*
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ *
+ */
+
+#ifndef __TDFX_TEXMAN_H__
+#define __TDFX_TEXMAN_H__
+
+
+#include "tdfx_lock.h"
+
+
+extern void tdfxTMInit( tdfxContextPtr fxMesa );
+
+extern void tdfxTMClose( tdfxContextPtr fxMesa );
+
+extern void tdfxTMDownloadTexture(tdfxContextPtr fxMesa,
+ struct gl_texture_object *tObj);
+
+extern void tdfxTMReloadMipMapLevel( GLcontext *ctx,
+ struct gl_texture_object *tObj,
+ GLint level );
+
+extern void tdfxTMMoveInTM_NoLock( tdfxContextPtr fxMesa,
+ struct gl_texture_object *tObj,
+ FxU32 targetTMU );
+
+extern void tdfxTMMoveOutTM_NoLock( tdfxContextPtr fxMesa,
+ struct gl_texture_object *tObj );
+
+extern void tdfxTMFreeTexture( tdfxContextPtr fxMesa,
+ struct gl_texture_object *tObj );
+
+extern void tdfxTMRestoreTextures_NoLock( tdfxContextPtr fxMesa );
+
+
+#define tdfxTMMoveInTM( fxMesa, tObj, targetTMU ) \
+ do { \
+ LOCK_HARDWARE( fxMesa ); \
+ tdfxTMMoveInTM_NoLock( fxMesa, tObj, targetTMU ); \
+ UNLOCK_HARDWARE( fxMesa ); \
+ } while (0)
+
+#define tdfxTMMoveOutTM( fxMesa, tObj ) \
+ do { \
+ LOCK_HARDWARE( fxMesa ); \
+ tdfxTMMoveOutTM_NoLock( fxMesa, tObj ); \
+ UNLOCK_HARDWARE( fxMesa ); \
+ } while (0)
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.c
new file mode 100644
index 000000000..7059b56e3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.c
@@ -0,0 +1,2209 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.c,v 1.2 2002/02/22 21:45:04 dawes Exp $ */
+
+/*
+ * New fixes:
+ * Daniel Borca <dborca@users.sourceforge.net>, 19 Jul 2004
+ *
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ *
+ */
+
+#include "tdfx_state.h"
+#include "tdfx_tex.h"
+#include "tdfx_texman.h"
+#include "tdfx_texstate.h"
+
+
+/* =============================================================
+ * Texture
+ */
+
+/*
+ * These macros are used below when handling COMBINE_EXT.
+ */
+#define TEXENV_OPERAND_INVERTED(operand) \
+ (((operand) == GL_ONE_MINUS_SRC_ALPHA) \
+ || ((operand) == GL_ONE_MINUS_SRC_COLOR))
+#define TEXENV_OPERAND_ALPHA(operand) \
+ (((operand) == GL_SRC_ALPHA) || ((operand) == GL_ONE_MINUS_SRC_ALPHA))
+#define TEXENV_SETUP_ARG_A(param, source, operand, iteratedAlpha) \
+ switch (source) { \
+ case GL_TEXTURE: \
+ param = GR_CMBX_LOCAL_TEXTURE_ALPHA; \
+ break; \
+ case GL_CONSTANT_EXT: \
+ param = GR_CMBX_TMU_CALPHA; \
+ break; \
+ case GL_PRIMARY_COLOR_EXT: \
+ param = GR_CMBX_ITALPHA; \
+ break; \
+ case GL_PREVIOUS_EXT: \
+ param = iteratedAlpha; \
+ break; \
+ default: \
+ /* \
+ * This is here just to keep from getting \
+ * compiler warnings. \
+ */ \
+ param = GR_CMBX_ZERO; \
+ break; \
+ }
+
+#define TEXENV_SETUP_ARG_RGB(param, source, operand, iteratedColor, iteratedAlpha) \
+ if (!TEXENV_OPERAND_ALPHA(operand)) { \
+ switch (source) { \
+ case GL_TEXTURE: \
+ param = GR_CMBX_LOCAL_TEXTURE_RGB; \
+ break; \
+ case GL_CONSTANT_EXT: \
+ param = GR_CMBX_TMU_CCOLOR; \
+ break; \
+ case GL_PRIMARY_COLOR_EXT: \
+ param = GR_CMBX_ITRGB; \
+ break; \
+ case GL_PREVIOUS_EXT: \
+ param = iteratedColor; \
+ break; \
+ default: \
+ /* \
+ * This is here just to keep from getting \
+ * compiler warnings. \
+ */ \
+ param = GR_CMBX_ZERO; \
+ break; \
+ } \
+ } else { \
+ switch (source) { \
+ case GL_TEXTURE: \
+ param = GR_CMBX_LOCAL_TEXTURE_ALPHA; \
+ break; \
+ case GL_CONSTANT_EXT: \
+ param = GR_CMBX_TMU_CALPHA; \
+ break; \
+ case GL_PRIMARY_COLOR_EXT: \
+ param = GR_CMBX_ITALPHA; \
+ break; \
+ case GL_PREVIOUS_EXT: \
+ param = iteratedAlpha; \
+ break; \
+ default: \
+ /* \
+ * This is here just to keep from getting \
+ * compiler warnings. \
+ */ \
+ param = GR_CMBX_ZERO; \
+ break; \
+ } \
+ }
+
+#define TEXENV_SETUP_MODE_RGB(param, operand) \
+ switch (operand) { \
+ case GL_SRC_COLOR: \
+ case GL_SRC_ALPHA: \
+ param = GR_FUNC_MODE_X; \
+ break; \
+ case GL_ONE_MINUS_SRC_ALPHA: \
+ case GL_ONE_MINUS_SRC_COLOR: \
+ param = GR_FUNC_MODE_ONE_MINUS_X; \
+ break; \
+ default: \
+ param = GR_FUNC_MODE_ZERO; \
+ break; \
+ }
+
+#define TEXENV_SETUP_MODE_A(param, operand) \
+ switch (operand) { \
+ case GL_SRC_ALPHA: \
+ param = GR_FUNC_MODE_X; \
+ break; \
+ case GL_ONE_MINUS_SRC_ALPHA: \
+ param = GR_FUNC_MODE_ONE_MINUS_X; \
+ break; \
+ default: \
+ param = GR_FUNC_MODE_ZERO; \
+ break; \
+ }
+
+
+
+/*
+ * Setup a texture environment on Voodoo5.
+ * Return GL_TRUE for success, GL_FALSE for failure.
+ * If we fail, we'll have to use software rendering.
+ */
+static GLboolean
+SetupTexEnvNapalm(GLcontext *ctx, GLboolean useIteratedRGBA,
+ const struct gl_texture_unit *texUnit, GLenum baseFormat,
+ struct tdfx_texcombine_ext *env)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GrTCCUColor_t incomingRGB, incomingAlpha;
+ const GLenum envMode = texUnit->EnvMode;
+
+ if (useIteratedRGBA) {
+ incomingRGB = GR_CMBX_ITRGB;
+ incomingAlpha = GR_CMBX_ITALPHA;
+ }
+ else {
+ incomingRGB = GR_CMBX_OTHER_TEXTURE_RGB;
+ incomingAlpha = GR_CMBX_OTHER_TEXTURE_ALPHA;
+ }
+
+ /* invariant: */
+ env->Color.Shift = 0;
+ env->Color.Invert = FXFALSE;
+ env->Alpha.Shift = 0;
+ env->Alpha.Invert = FXFALSE;
+
+ switch (envMode) {
+ case GL_REPLACE:
+ /* -- Setup RGB combiner */
+ if (baseFormat == GL_ALPHA) {
+ /* Rv = Rf */
+ env->Color.SourceA = incomingRGB;
+ }
+ else {
+ /* Rv = Rt */
+ env->Color.SourceA = GR_CMBX_LOCAL_TEXTURE_RGB;
+ }
+ env->Color.ModeA = GR_FUNC_MODE_X;
+ env->Color.SourceB = GR_CMBX_ZERO;
+ env->Color.ModeB = GR_FUNC_MODE_ZERO;
+ env->Color.SourceC = GR_CMBX_ZERO;
+ env->Color.InvertC = FXTRUE;
+ env->Color.SourceD = GR_CMBX_ZERO;
+ env->Color.InvertD = FXFALSE;
+ /* -- Setup Alpha combiner */
+ if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) {
+ /* Av = Af */
+ env->Alpha.SourceD = incomingAlpha;
+ }
+ else {
+ /* Av = At */
+ env->Alpha.SourceD = GR_CMBX_LOCAL_TEXTURE_ALPHA;
+ }
+ env->Alpha.SourceA = GR_CMBX_ITALPHA;
+ env->Alpha.ModeA = GR_FUNC_MODE_ZERO;
+ env->Alpha.SourceB = GR_CMBX_ITALPHA;
+ env->Alpha.ModeB = GR_FUNC_MODE_ZERO;
+ env->Alpha.SourceC = GR_CMBX_ZERO;
+ env->Alpha.InvertC = FXFALSE;
+ env->Alpha.InvertD = FXFALSE;
+ break;
+
+ case GL_MODULATE:
+ /* -- Setup RGB combiner */
+ if (baseFormat == GL_ALPHA) {
+ /* Rv = Rf */
+ env->Color.SourceC = GR_CMBX_ZERO;
+ env->Color.InvertC = FXTRUE;
+ }
+ else {
+ /* Result = Frag * Tex */
+ env->Color.SourceC = GR_CMBX_LOCAL_TEXTURE_RGB;
+ env->Color.InvertC = FXFALSE;
+ }
+ env->Color.SourceA = incomingRGB;
+ env->Color.ModeA = GR_FUNC_MODE_X;
+ env->Color.SourceB = GR_CMBX_ZERO;
+ env->Color.ModeB = GR_FUNC_MODE_ZERO;
+ env->Color.SourceD = GR_CMBX_ZERO;
+ env->Color.InvertD = FXFALSE;
+ /* -- Setup Alpha combiner */
+ if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) {
+ /* Av = Af */
+ env->Alpha.SourceA = incomingAlpha;
+ env->Alpha.SourceC = GR_CMBX_ZERO;
+ env->Alpha.InvertC = FXTRUE;
+ }
+ else {
+ /* Av = Af * At */
+ env->Alpha.SourceA = GR_CMBX_LOCAL_TEXTURE_ALPHA;
+ env->Alpha.SourceC = incomingAlpha;
+ env->Alpha.InvertC = FXFALSE;
+ }
+ env->Alpha.ModeA = GR_FUNC_MODE_X;
+ env->Alpha.SourceB = GR_CMBX_ITALPHA;
+ env->Alpha.ModeB = GR_FUNC_MODE_ZERO;
+ env->Alpha.SourceD = GR_CMBX_ZERO;
+ env->Alpha.InvertD = FXFALSE;
+ break;
+
+ case GL_DECAL:
+ /* -- Setup RGB combiner */
+ if (baseFormat == GL_RGB) {
+ /* Rv = Rt */
+ env->Color.SourceB = GR_CMBX_ZERO;
+ env->Color.ModeB = GR_FUNC_MODE_X;
+ env->Color.SourceC = GR_CMBX_ZERO;
+ env->Color.InvertC = FXTRUE;
+ env->Color.SourceD = GR_CMBX_ZERO;
+ env->Color.InvertD = FXFALSE;
+ }
+ else {
+ /* Rv = Rf * (1 - At) + Rt * At */
+ env->Color.SourceB = incomingRGB;
+ env->Color.ModeB = GR_FUNC_MODE_NEGATIVE_X;
+ env->Color.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA;
+ env->Color.InvertC = FXFALSE;
+ env->Color.SourceD = GR_CMBX_B;
+ env->Color.InvertD = FXFALSE;
+ }
+ env->Color.SourceA = GR_CMBX_LOCAL_TEXTURE_RGB;
+ env->Color.ModeA = GR_FUNC_MODE_X;
+ /* -- Setup Alpha combiner */
+ /* Av = Af */
+ env->Alpha.SourceA = incomingAlpha;
+ env->Alpha.ModeA = GR_FUNC_MODE_X;
+ env->Alpha.SourceB = GR_CMBX_ITALPHA;
+ env->Alpha.ModeB = GR_FUNC_MODE_ZERO;
+ env->Alpha.SourceC = GR_CMBX_ZERO;
+ env->Alpha.InvertC = FXTRUE;
+ env->Alpha.SourceD = GR_CMBX_ZERO;
+ env->Alpha.InvertD = FXFALSE;
+ break;
+
+ case GL_BLEND:
+ /* -- Setup RGB combiner */
+ if (baseFormat == GL_ALPHA) {
+ /* Rv = Rf */
+ env->Color.SourceA = incomingRGB;
+ env->Color.ModeA = GR_FUNC_MODE_X;
+ env->Color.SourceB = GR_CMBX_ZERO;
+ env->Color.ModeB = GR_FUNC_MODE_ZERO;
+ env->Color.SourceC = GR_CMBX_ZERO;
+ env->Color.InvertC = FXTRUE;
+ env->Color.SourceD = GR_CMBX_ZERO;
+ env->Color.InvertD = FXFALSE;
+ }
+ else {
+ /* Rv = Rf * (1 - Rt) + Rc * Rt */
+ env->Color.SourceA = GR_CMBX_TMU_CCOLOR;
+ env->Color.ModeA = GR_FUNC_MODE_X;
+ env->Color.SourceB = incomingRGB;
+ env->Color.ModeB = GR_FUNC_MODE_NEGATIVE_X;
+ env->Color.SourceC = GR_CMBX_LOCAL_TEXTURE_RGB;
+ env->Color.InvertC = FXFALSE;
+ env->Color.SourceD = GR_CMBX_B;
+ env->Color.InvertD = FXFALSE;
+ }
+ /* -- Setup Alpha combiner */
+ if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) {
+ /* Av = Af */
+ env->Alpha.SourceA = incomingAlpha;
+ env->Alpha.ModeA = GR_FUNC_MODE_X;
+ env->Alpha.SourceB = GR_CMBX_ZERO;
+ env->Alpha.ModeB = GR_FUNC_MODE_ZERO;
+ env->Alpha.SourceC = GR_CMBX_ZERO;
+ env->Alpha.InvertC = FXTRUE;
+ env->Alpha.SourceD = GR_CMBX_ZERO;
+ env->Alpha.InvertD = FXFALSE;
+ }
+ else if (baseFormat == GL_INTENSITY) {
+ /* Av = Af * (1 - It) + Ac * It */
+ env->Alpha.SourceA = GR_CMBX_TMU_CALPHA;
+ env->Alpha.ModeA = GR_FUNC_MODE_X;
+ env->Alpha.SourceB = incomingAlpha;
+ env->Alpha.ModeB = GR_FUNC_MODE_NEGATIVE_X;
+ env->Alpha.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA;
+ env->Alpha.InvertC = FXFALSE;
+ env->Alpha.SourceD = GR_CMBX_B;
+ env->Alpha.InvertD = FXFALSE;
+ }
+ else {
+ /* Av = Af * At */
+ env->Alpha.SourceA = GR_CMBX_LOCAL_TEXTURE_ALPHA;
+ env->Alpha.ModeA = GR_FUNC_MODE_X;
+ env->Alpha.SourceB = GR_CMBX_ITALPHA;
+ env->Alpha.ModeB = GR_FUNC_MODE_ZERO;
+ env->Alpha.SourceC = incomingAlpha;
+ env->Alpha.InvertC = FXFALSE;
+ env->Alpha.SourceD = GR_CMBX_ZERO;
+ env->Alpha.InvertD = FXFALSE;
+ }
+ /* Also have to set up the tex env constant color */
+ env->EnvColor = PACK_RGBA32(texUnit->EnvColor[0] * 255.0F,
+ texUnit->EnvColor[1] * 255.0F,
+ texUnit->EnvColor[2] * 255.0F,
+ texUnit->EnvColor[3] * 255.0F);
+ break;
+ case GL_ADD:
+ /* -- Setup RGB combiner */
+ if (baseFormat == GL_ALPHA) {
+ /* Rv = Rf */
+ env->Color.SourceB = GR_CMBX_ZERO;
+ env->Color.ModeB = GR_FUNC_MODE_ZERO;
+ }
+ else {
+ /* Rv = Rf + Tt */
+ env->Color.SourceB = GR_CMBX_LOCAL_TEXTURE_RGB;
+ env->Color.ModeB = GR_FUNC_MODE_X;
+ }
+ env->Color.SourceA = incomingRGB;
+ env->Color.ModeA = GR_FUNC_MODE_X;
+ env->Color.SourceC = GR_CMBX_ZERO;
+ env->Color.InvertC = FXTRUE;
+ env->Color.SourceD = GR_CMBX_ZERO;
+ env->Color.InvertD = FXFALSE;
+ /* -- Setup Alpha combiner */
+ if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) {
+ /* Av = Af */
+ env->Alpha.SourceA = incomingAlpha;
+ env->Alpha.SourceB = GR_CMBX_ITALPHA;
+ env->Alpha.ModeB = GR_FUNC_MODE_ZERO;
+ env->Alpha.SourceC = GR_CMBX_ZERO;
+ env->Alpha.InvertC = FXTRUE;
+
+ }
+ else if (baseFormat == GL_INTENSITY) {
+ /* Av = Af + It */
+ env->Alpha.SourceA = incomingAlpha;
+ env->Alpha.SourceB = GR_CMBX_LOCAL_TEXTURE_ALPHA;
+ env->Alpha.ModeB = GR_FUNC_MODE_X;
+ env->Alpha.SourceC = GR_CMBX_ZERO;
+ env->Alpha.InvertC = FXTRUE;
+ }
+ else {
+ /* Av = Af * At */
+ env->Alpha.SourceA = GR_CMBX_LOCAL_TEXTURE_ALPHA;
+ env->Alpha.SourceB = GR_CMBX_ITALPHA;
+ env->Alpha.ModeB = GR_FUNC_MODE_ZERO;
+ env->Alpha.SourceC = incomingAlpha;
+ env->Alpha.InvertC = FXFALSE;
+ }
+ env->Alpha.ModeA = GR_FUNC_MODE_X;
+ env->Alpha.SourceD = GR_CMBX_ZERO;
+ env->Alpha.InvertD = FXFALSE;
+ break;
+
+ case GL_COMBINE_EXT:
+ {
+ FxU32 A_RGB, B_RGB, C_RGB, D_RGB;
+ FxU32 Amode_RGB, Bmode_RGB;
+ FxBool Cinv_RGB, Dinv_RGB, Ginv_RGB;
+ FxU32 Shift_RGB;
+ FxU32 A_A, B_A, C_A, D_A;
+ FxU32 Amode_A, Bmode_A;
+ FxBool Cinv_A, Dinv_A, Ginv_A;
+ FxU32 Shift_A;
+
+ /*
+ *
+ * In the formulas below, we write:
+ * o "1(x)" for the identity function applied to x,
+ * so 1(x) = x.
+ * o "0(x)" for the constant function 0, so
+ * 0(x) = 0 for all values of x.
+ *
+ * Calculate the color combination.
+ */
+ Shift_RGB = texUnit->Combine.ScaleShiftRGB;
+ Shift_A = texUnit->Combine.ScaleShiftA;
+ switch (texUnit->Combine.ModeRGB) {
+ case GL_REPLACE:
+ /*
+ * The formula is: Arg0
+ * We implement this by the formula:
+ * (Arg0 + 0(0))*(1-0) + 0
+ */
+ TEXENV_SETUP_ARG_RGB(A_RGB,
+ texUnit->Combine.SourceRGB[0],
+ texUnit->Combine.OperandRGB[0],
+ incomingRGB, incomingAlpha);
+ TEXENV_SETUP_MODE_RGB(Amode_RGB,
+ texUnit->Combine.OperandRGB[0]);
+ B_RGB = C_RGB = D_RGB = GR_CMBX_ZERO;
+ Bmode_RGB = GR_FUNC_MODE_ZERO;
+ Cinv_RGB = FXTRUE;
+ Dinv_RGB = Ginv_RGB = FXFALSE;
+ break;
+ case GL_MODULATE:
+ /*
+ * The formula is: Arg0 * Arg1
+ *
+ * We implement this by the formula
+ * (Arg0 + 0(0)) * Arg1 + 0(0)
+ */
+ TEXENV_SETUP_ARG_RGB(A_RGB,
+ texUnit->Combine.SourceRGB[0],
+ texUnit->Combine.OperandRGB[0],
+ incomingRGB, incomingAlpha);
+ TEXENV_SETUP_MODE_RGB(Amode_RGB,
+ texUnit->Combine.OperandRGB[0]);
+ B_RGB = GR_CMBX_ZERO;
+ Bmode_RGB = GR_CMBX_ZERO;
+ TEXENV_SETUP_ARG_RGB(C_RGB,
+ texUnit->Combine.SourceRGB[1],
+ texUnit->Combine.OperandRGB[1],
+ incomingRGB, incomingAlpha);
+ Cinv_RGB = TEXENV_OPERAND_INVERTED
+ (texUnit->Combine.OperandRGB[1]);
+ D_RGB = GR_CMBX_ZERO;
+ Dinv_RGB = Ginv_RGB = FXFALSE;
+ break;
+ case GL_ADD:
+ /*
+ * The formula is Arg0 + Arg1
+ */
+ TEXENV_SETUP_ARG_RGB(A_RGB,
+ texUnit->Combine.SourceRGB[0],
+ texUnit->Combine.OperandRGB[0],
+ incomingRGB, incomingAlpha);
+ TEXENV_SETUP_MODE_RGB(Amode_RGB,
+ texUnit->Combine.OperandRGB[0]);
+ TEXENV_SETUP_ARG_RGB(B_RGB,
+ texUnit->Combine.SourceRGB[1],
+ texUnit->Combine.OperandRGB[1],
+ incomingRGB, incomingAlpha);
+ TEXENV_SETUP_MODE_RGB(Bmode_RGB,
+ texUnit->Combine.OperandRGB[1]);
+ C_RGB = D_RGB = GR_CMBX_ZERO;
+ Cinv_RGB = FXTRUE;
+ Dinv_RGB = Ginv_RGB = FXFALSE;
+ break;
+ case GL_ADD_SIGNED_EXT:
+ /*
+ * The formula is: Arg0 + Arg1 - 0.5.
+ * We compute this by calculating:
+ * (Arg0 - 1/2) + Arg1 if op0 is SRC_{COLOR,ALPHA}
+ * Arg0 + (Arg1 - 1/2) if op1 is SRC_{COLOR,ALPHA}
+ * If both op0 and op1 are ONE_MINUS_SRC_{COLOR,ALPHA}
+ * we cannot implement the formula properly.
+ */
+ TEXENV_SETUP_ARG_RGB(A_RGB,
+ texUnit->Combine.SourceRGB[0],
+ texUnit->Combine.OperandRGB[0],
+ incomingRGB, incomingAlpha);
+ TEXENV_SETUP_ARG_RGB(B_RGB,
+ texUnit->Combine.SourceRGB[1],
+ texUnit->Combine.OperandRGB[1],
+ incomingRGB, incomingAlpha);
+ if (!TEXENV_OPERAND_INVERTED(texUnit->Combine.OperandRGB[0])) {
+ /*
+ * A is not inverted. So, choose it.
+ */
+ Amode_RGB = GR_FUNC_MODE_X_MINUS_HALF;
+ if (!TEXENV_OPERAND_INVERTED
+ (texUnit->Combine.OperandRGB[1])) {
+ Bmode_RGB = GR_FUNC_MODE_X;
+ }
+ else {
+ Bmode_RGB = GR_FUNC_MODE_ONE_MINUS_X;
+ }
+ }
+ else {
+ /*
+ * A is inverted, so try to subtract 1/2
+ * from B.
+ */
+ Amode_RGB = GR_FUNC_MODE_ONE_MINUS_X;
+ if (!TEXENV_OPERAND_INVERTED
+ (texUnit->Combine.OperandRGB[1])) {
+ Bmode_RGB = GR_FUNC_MODE_X_MINUS_HALF;
+ }
+ else {
+ /*
+ * Both are inverted. This is the case
+ * we cannot handle properly. We just
+ * choose to not add the - 1/2.
+ */
+ Bmode_RGB = GR_FUNC_MODE_ONE_MINUS_X;
+ return GL_FALSE;
+ }
+ }
+ C_RGB = D_RGB = GR_CMBX_ZERO;
+ Cinv_RGB = FXTRUE;
+ Dinv_RGB = Ginv_RGB = FXFALSE;
+ break;
+ case GL_INTERPOLATE_EXT:
+ /*
+ * The formula is: Arg0 * Arg2 + Arg1 * (1 - Arg2).
+ * We compute this by the formula:
+ * (Arg0 - Arg1) * Arg2 + Arg1
+ * == Arg0 * Arg2 - Arg1 * Arg2 + Arg1
+ * == Arg0 * Arg2 + Arg1 * (1 - Arg2)
+ * However, if both Arg1 is ONE_MINUS_X, the HW does
+ * not support it properly.
+ */
+ TEXENV_SETUP_ARG_RGB(A_RGB,
+ texUnit->Combine.SourceRGB[0],
+ texUnit->Combine.OperandRGB[0],
+ incomingRGB, incomingAlpha);
+ TEXENV_SETUP_MODE_RGB(Amode_RGB,
+ texUnit->Combine.OperandRGB[0]);
+ TEXENV_SETUP_ARG_RGB(B_RGB,
+ texUnit->Combine.SourceRGB[1],
+ texUnit->Combine.OperandRGB[1],
+ incomingRGB, incomingAlpha);
+ if (TEXENV_OPERAND_INVERTED(texUnit->Combine.OperandRGB[1])) {
+ /*
+ * This case is wrong.
+ */
+ Bmode_RGB = GR_FUNC_MODE_NEGATIVE_X;
+ return GL_FALSE;
+ }
+ else {
+ Bmode_RGB = GR_FUNC_MODE_NEGATIVE_X;
+ }
+ /*
+ * The Source/Operand for the C value must
+ * specify some kind of alpha value.
+ */
+ TEXENV_SETUP_ARG_A(C_RGB,
+ texUnit->Combine.SourceRGB[2],
+ texUnit->Combine.OperandRGB[2],
+ incomingAlpha);
+ Cinv_RGB = FXFALSE;
+ D_RGB = GR_CMBX_B;
+ Dinv_RGB = Ginv_RGB = FXFALSE;
+ break;
+ default:
+ /*
+ * This is here mostly to keep from getting
+ * a compiler warning about these not being set.
+ * However, this should set all the texture values
+ * to zero.
+ */
+ A_RGB = B_RGB = C_RGB = D_RGB = GR_CMBX_ZERO;
+ Amode_RGB = Bmode_RGB = GR_FUNC_MODE_X;
+ Cinv_RGB = Dinv_RGB = Ginv_RGB = FXFALSE;
+ break;
+ }
+ /*
+ * Calculate the alpha combination.
+ */
+ switch (texUnit->Combine.ModeA) {
+ case GL_REPLACE:
+ /*
+ * The formula is: Arg0
+ * We implement this by the formula:
+ * (Arg0 + 0(0))*(1-0) + 0
+ */
+ TEXENV_SETUP_ARG_A(A_A,
+ texUnit->Combine.SourceA[0],
+ texUnit->Combine.OperandA[0],
+ incomingAlpha);
+ TEXENV_SETUP_MODE_A(Amode_A,
+ texUnit->Combine.OperandA[0]);
+ B_A = GR_CMBX_ITALPHA;
+ Bmode_A = GR_FUNC_MODE_ZERO;
+ C_A = D_A = GR_CMBX_ZERO;
+ Cinv_A = FXTRUE;
+ Dinv_A = Ginv_A = FXFALSE;
+ break;
+ case GL_MODULATE:
+ /*
+ * The formula is: Arg0 * Arg1
+ *
+ * We implement this by the formula
+ * (Arg0 + 0(0)) * Arg1 + 0(0)
+ */
+ TEXENV_SETUP_ARG_A(A_A,
+ texUnit->Combine.SourceA[0],
+ texUnit->Combine.OperandA[0],
+ incomingAlpha);
+ TEXENV_SETUP_MODE_A(Amode_A,
+ texUnit->Combine.OperandA[0]);
+ B_A = GR_CMBX_ZERO;
+ Bmode_A = GR_CMBX_ZERO;
+ TEXENV_SETUP_ARG_A(C_A,
+ texUnit->Combine.SourceA[1],
+ texUnit->Combine.OperandA[1],
+ incomingAlpha);
+ Cinv_A = TEXENV_OPERAND_INVERTED
+ (texUnit->Combine.OperandA[1]);
+ D_A = GR_CMBX_ZERO;
+ Dinv_A = Ginv_A = FXFALSE;
+ break;
+ case GL_ADD:
+ /*
+ * The formula is Arg0 + Arg1
+ */
+ TEXENV_SETUP_ARG_A(A_A,
+ texUnit->Combine.SourceA[0],
+ texUnit->Combine.OperandA[0],
+ incomingAlpha);
+ TEXENV_SETUP_MODE_A(Amode_A,
+ texUnit->Combine.OperandA[0]);
+ TEXENV_SETUP_ARG_A(B_A,
+ texUnit->Combine.SourceA[1],
+ texUnit->Combine.OperandA[1],
+ incomingAlpha);
+ TEXENV_SETUP_MODE_A(Bmode_A,
+ texUnit->Combine.OperandA[1]);
+ C_A = D_A = GR_CMBX_ZERO;
+ Cinv_A = FXTRUE;
+ Dinv_A = Ginv_A = FXFALSE;
+ break;
+ case GL_ADD_SIGNED_EXT:
+ /*
+ * The formula is: Arg0 + Arg1 - 0.5.
+ * We compute this by calculating:
+ * (Arg0 - 1/2) + Arg1 if op0 is SRC_{COLOR,ALPHA}
+ * Arg0 + (Arg1 - 1/2) if op1 is SRC_{COLOR,ALPHA}
+ * If both op0 and op1 are ONE_MINUS_SRC_{COLOR,ALPHA}
+ * we cannot implement the formula properly.
+ */
+ TEXENV_SETUP_ARG_A(A_A,
+ texUnit->Combine.SourceA[0],
+ texUnit->Combine.OperandA[0],
+ incomingAlpha);
+ TEXENV_SETUP_ARG_A(B_A,
+ texUnit->Combine.SourceA[1],
+ texUnit->Combine.OperandA[1],
+ incomingAlpha);
+ if (!TEXENV_OPERAND_INVERTED(texUnit->Combine.OperandA[0])) {
+ /*
+ * A is not inverted. So, choose it.
+ */
+ Amode_A = GR_FUNC_MODE_X_MINUS_HALF;
+ if (!TEXENV_OPERAND_INVERTED
+ (texUnit->Combine.OperandA[1])) {
+ Bmode_A = GR_FUNC_MODE_X;
+ } else {
+ Bmode_A = GR_FUNC_MODE_ONE_MINUS_X;
+ }
+ } else {
+ /*
+ * A is inverted, so try to subtract 1/2
+ * from B.
+ */
+ Amode_A = GR_FUNC_MODE_ONE_MINUS_X;
+ if (!TEXENV_OPERAND_INVERTED
+ (texUnit->Combine.OperandA[1])) {
+ Bmode_A = GR_FUNC_MODE_X_MINUS_HALF;
+ } else {
+ /*
+ * Both are inverted. This is the case
+ * we cannot handle properly. We just
+ * choose to not add the - 1/2.
+ */
+ Bmode_A = GR_FUNC_MODE_ONE_MINUS_X;
+ return GL_FALSE;
+ }
+ }
+ C_A = D_A = GR_CMBX_ZERO;
+ Cinv_A = FXTRUE;
+ Dinv_A = Ginv_A = FXFALSE;
+ break;
+ case GL_INTERPOLATE_EXT:
+ /*
+ * The formula is: Arg0 * Arg2 + Arg1 * (1 - Arg2).
+ * We compute this by the formula:
+ * (Arg0 - Arg1) * Arg2 + Arg1
+ * == Arg0 * Arg2 - Arg1 * Arg2 + Arg1
+ * == Arg0 * Arg2 + Arg1 * (1 - Arg2)
+ * However, if both Arg1 is ONE_MINUS_X, the HW does
+ * not support it properly.
+ */
+ TEXENV_SETUP_ARG_A(A_A,
+ texUnit->Combine.SourceA[0],
+ texUnit->Combine.OperandA[0],
+ incomingAlpha);
+ TEXENV_SETUP_MODE_A(Amode_A,
+ texUnit->Combine.OperandA[0]);
+ TEXENV_SETUP_ARG_A(B_A,
+ texUnit->Combine.SourceA[1],
+ texUnit->Combine.OperandA[1],
+ incomingAlpha);
+ if (!TEXENV_OPERAND_INVERTED(texUnit->Combine.OperandA[1])) {
+ Bmode_A = GR_FUNC_MODE_NEGATIVE_X;
+ }
+ else {
+ /*
+ * This case is wrong.
+ */
+ Bmode_A = GR_FUNC_MODE_NEGATIVE_X;
+ return GL_FALSE;
+ }
+ /*
+ * The Source/Operand for the C value must
+ * specify some kind of alpha value.
+ */
+ TEXENV_SETUP_ARG_A(C_A,
+ texUnit->Combine.SourceA[2],
+ texUnit->Combine.OperandA[2],
+ incomingAlpha);
+ Cinv_A = FXFALSE;
+ D_A = GR_CMBX_B;
+ Dinv_A = Ginv_A = FXFALSE;
+ break;
+ default:
+ /*
+ * This is here mostly to keep from getting
+ * a compiler warning about these not being set.
+ * However, this should set all the alpha values
+ * to one.
+ */
+ A_A = B_A = C_A = D_A = GR_CMBX_ZERO;
+ Amode_A = Bmode_A = GR_FUNC_MODE_X;
+ Cinv_A = Dinv_A = FXFALSE;
+ Ginv_A = FXTRUE;
+ break;
+ }
+ /*
+ * Save the parameters.
+ */
+ env->Color.SourceA = A_RGB;
+ env->Color.ModeA = Amode_RGB;
+ env->Color.SourceB = B_RGB;
+ env->Color.ModeB = Bmode_RGB;
+ env->Color.SourceC = C_RGB;
+ env->Color.InvertC = Cinv_RGB;
+ env->Color.SourceD = D_RGB;
+ env->Color.InvertD = Dinv_RGB;
+ env->Color.Shift = Shift_RGB;
+ env->Color.Invert = Ginv_RGB;
+ env->Alpha.SourceA = A_A;
+ env->Alpha.ModeA = Amode_A;
+ env->Alpha.SourceB = B_A;
+ env->Alpha.ModeB = Bmode_A;
+ env->Alpha.SourceC = C_A;
+ env->Alpha.InvertC = Cinv_A;
+ env->Alpha.SourceD = D_A;
+ env->Alpha.InvertD = Dinv_A;
+ env->Alpha.Shift = Shift_A;
+ env->Alpha.Invert = Ginv_A;
+ env->EnvColor = PACK_RGBA32(texUnit->EnvColor[0] * 255.0F,
+ texUnit->EnvColor[1] * 255.0F,
+ texUnit->EnvColor[2] * 255.0F,
+ texUnit->EnvColor[3] * 255.0F);
+ }
+ break;
+
+ default:
+ _mesa_problem(ctx, "%s: Bad envMode", __FUNCTION__);
+ }
+
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_ENV;
+
+ fxMesa->ColorCombineExt.SourceA = GR_CMBX_TEXTURE_RGB;
+ fxMesa->ColorCombineExt.ModeA = GR_FUNC_MODE_X,
+ fxMesa->ColorCombineExt.SourceB = GR_CMBX_ZERO;
+ fxMesa->ColorCombineExt.ModeB = GR_FUNC_MODE_X;
+ fxMesa->ColorCombineExt.SourceC = GR_CMBX_ZERO;
+ fxMesa->ColorCombineExt.InvertC = FXTRUE;
+ fxMesa->ColorCombineExt.SourceD = GR_CMBX_ZERO;
+ fxMesa->ColorCombineExt.InvertD = FXFALSE;
+ fxMesa->ColorCombineExt.Shift = 0;
+ fxMesa->ColorCombineExt.Invert = FXFALSE;
+ fxMesa->dirty |= TDFX_UPLOAD_COLOR_COMBINE;
+ fxMesa->AlphaCombineExt.SourceA = GR_CMBX_TEXTURE_ALPHA;
+ fxMesa->AlphaCombineExt.ModeA = GR_FUNC_MODE_X;
+ fxMesa->AlphaCombineExt.SourceB = GR_CMBX_ZERO;
+ fxMesa->AlphaCombineExt.ModeB = GR_FUNC_MODE_X;
+ fxMesa->AlphaCombineExt.SourceC = GR_CMBX_ZERO;
+ fxMesa->AlphaCombineExt.InvertC = FXTRUE;
+ fxMesa->AlphaCombineExt.SourceD = GR_CMBX_ZERO;
+ fxMesa->AlphaCombineExt.InvertD = FXFALSE;
+ fxMesa->AlphaCombineExt.Shift = 0;
+ fxMesa->AlphaCombineExt.Invert = FXFALSE;
+ fxMesa->dirty |= TDFX_UPLOAD_ALPHA_COMBINE;
+ return GL_TRUE; /* success */
+}
+
+
+
+/*
+ * Setup the Voodoo3 texture environment for a single texture unit.
+ * Return GL_TRUE for success, GL_FALSE for failure.
+ * If failure, we'll use software rendering.
+ */
+static GLboolean
+SetupSingleTexEnvVoodoo3(GLcontext *ctx, int unit,
+ GLenum envMode, GLenum baseFormat)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GrCombineLocal_t localc, locala;
+ struct tdfx_combine alphaComb, colorComb;
+
+ if (1 /*iteratedRGBA*/)
+ localc = locala = GR_COMBINE_LOCAL_ITERATED;
+ else
+ localc = locala = GR_COMBINE_LOCAL_CONSTANT;
+
+ switch (envMode) {
+ case GL_DECAL:
+ alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ alphaComb.Factor = GR_COMBINE_FACTOR_NONE;
+ alphaComb.Local = locala;
+ alphaComb.Other = GR_COMBINE_OTHER_NONE;
+ alphaComb.Invert = FXFALSE;
+ colorComb.Function = GR_COMBINE_FUNCTION_BLEND;
+ colorComb.Factor = GR_COMBINE_FACTOR_TEXTURE_ALPHA;
+ colorComb.Local = localc;
+ colorComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ colorComb.Invert = FXFALSE;
+ break;
+ case GL_MODULATE:
+ alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL;
+ alphaComb.Local = locala;
+ alphaComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ alphaComb.Invert = FXFALSE;
+ if (baseFormat == GL_ALPHA) {
+ colorComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ colorComb.Factor = GR_COMBINE_FACTOR_NONE;
+ colorComb.Local = localc;
+ colorComb.Other = GR_COMBINE_OTHER_NONE;
+ colorComb.Invert = FXFALSE;
+ }
+ else {
+ colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ colorComb.Factor = GR_COMBINE_FACTOR_LOCAL;
+ colorComb.Local = localc;
+ colorComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ colorComb.Invert = FXFALSE;
+ }
+ break;
+
+ case GL_BLEND:
+ /*
+ * XXX we can't do real GL_BLEND mode. These settings assume that
+ * the TexEnv color is black and incoming fragment color is white.
+ */
+ if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) {
+ /* Av = Af */
+ alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ alphaComb.Factor = GR_COMBINE_FACTOR_NONE;
+ alphaComb.Local = locala;
+ alphaComb.Other = GR_COMBINE_OTHER_NONE;
+ alphaComb.Invert = FXFALSE;
+ }
+ else if (baseFormat == GL_INTENSITY) {
+ /* Av = Af * (1 - It) + Ac * It */
+ alphaComb.Function = GR_COMBINE_FUNCTION_BLEND;
+ alphaComb.Factor = GR_COMBINE_FACTOR_TEXTURE_ALPHA;
+ alphaComb.Local = locala;
+ alphaComb.Other = GR_COMBINE_OTHER_CONSTANT;
+ alphaComb.Invert = FXFALSE;
+ }
+ else {
+ /* Av = Af * At */
+ alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL;
+ alphaComb.Local = locala;
+ alphaComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ alphaComb.Invert = FXFALSE;
+ }
+ if (baseFormat == GL_ALPHA) {
+ colorComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ colorComb.Factor = GR_COMBINE_FACTOR_NONE;
+ colorComb.Local = localc;
+ colorComb.Other = GR_COMBINE_OTHER_NONE;
+ colorComb.Invert = FXFALSE;
+ }
+ else {
+ colorComb.Function = GR_COMBINE_FUNCTION_BLEND;
+ colorComb.Factor = GR_COMBINE_FACTOR_TEXTURE_RGB;
+ colorComb.Local = localc;
+ colorComb.Other = GR_COMBINE_OTHER_CONSTANT;
+ colorComb.Invert = FXTRUE;
+ }
+ fxMesa->Color.MonoColor = PACK_RGBA32(
+ ctx->Texture.Unit[unit].EnvColor[0] * 255.0f,
+ ctx->Texture.Unit[unit].EnvColor[1] * 255.0f,
+ ctx->Texture.Unit[unit].EnvColor[2] * 255.0f,
+ ctx->Texture.Unit[unit].EnvColor[3] * 255.0f);
+ fxMesa->dirty |= TDFX_UPLOAD_CONSTANT_COLOR;
+ break;
+
+ case GL_REPLACE:
+ if ((baseFormat == GL_RGB) || (baseFormat == GL_LUMINANCE)) {
+ alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ alphaComb.Factor = GR_COMBINE_FACTOR_NONE;
+ alphaComb.Local = locala;
+ alphaComb.Other = GR_COMBINE_OTHER_NONE;
+ alphaComb.Invert = FXFALSE;
+ }
+ else {
+ alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ alphaComb.Factor = GR_COMBINE_FACTOR_ONE;
+ alphaComb.Local = locala;
+ alphaComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ alphaComb.Invert = FXFALSE;
+ }
+ if (baseFormat == GL_ALPHA) {
+ colorComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ colorComb.Factor = GR_COMBINE_FACTOR_NONE;
+ colorComb.Local = localc;
+ colorComb.Other = GR_COMBINE_OTHER_NONE;
+ colorComb.Invert = FXFALSE;
+ }
+ else {
+ colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ colorComb.Factor = GR_COMBINE_FACTOR_ONE;
+ colorComb.Local = localc;
+ colorComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ colorComb.Invert = FXFALSE;
+ }
+ break;
+
+ case GL_ADD:
+ if (baseFormat == GL_ALPHA ||
+ baseFormat == GL_LUMINANCE_ALPHA ||
+ baseFormat == GL_RGBA) {
+ /* product of texel and fragment alpha */
+ alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL;
+ alphaComb.Local = locala;
+ alphaComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ alphaComb.Invert = FXFALSE;
+ }
+ else if (baseFormat == GL_LUMINANCE || baseFormat == GL_RGB) {
+ /* fragment alpha is unchanged */
+ alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ alphaComb.Factor = GR_COMBINE_FACTOR_NONE;
+ alphaComb.Local = locala;
+ alphaComb.Other = GR_COMBINE_OTHER_NONE;
+ alphaComb.Invert = FXFALSE;
+ }
+ else {
+ ASSERT(baseFormat == GL_INTENSITY);
+ /* sum of texel and fragment alpha */
+ alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
+ alphaComb.Factor = GR_COMBINE_FACTOR_ONE;
+ alphaComb.Local = locala;
+ alphaComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ alphaComb.Invert = FXFALSE;
+ }
+ if (baseFormat == GL_ALPHA) {
+ /* rgb unchanged */
+ colorComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ colorComb.Factor = GR_COMBINE_FACTOR_NONE;
+ colorComb.Local = localc;
+ colorComb.Other = GR_COMBINE_OTHER_NONE;
+ colorComb.Invert = FXFALSE;
+ }
+ else {
+ /* sum of texel and fragment rgb */
+ colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
+ colorComb.Factor = GR_COMBINE_FACTOR_ONE;
+ colorComb.Local = localc;
+ colorComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ colorComb.Invert = FXFALSE;
+ }
+ break;
+
+ default:
+ _mesa_problem(ctx, "bad texture env mode in %s", __FUNCTION__);
+ }
+
+ if (colorComb.Function != fxMesa->ColorCombine.Function ||
+ colorComb.Factor != fxMesa->ColorCombine.Factor ||
+ colorComb.Local != fxMesa->ColorCombine.Local ||
+ colorComb.Other != fxMesa->ColorCombine.Other ||
+ colorComb.Invert != fxMesa->ColorCombine.Invert) {
+ fxMesa->ColorCombine = colorComb;
+ fxMesa->dirty |= TDFX_UPLOAD_COLOR_COMBINE;
+ }
+
+ if (alphaComb.Function != fxMesa->AlphaCombine.Function ||
+ alphaComb.Factor != fxMesa->AlphaCombine.Factor ||
+ alphaComb.Local != fxMesa->AlphaCombine.Local ||
+ alphaComb.Other != fxMesa->AlphaCombine.Other ||
+ alphaComb.Invert != fxMesa->AlphaCombine.Invert) {
+ fxMesa->AlphaCombine = alphaComb;
+ fxMesa->dirty |= TDFX_UPLOAD_ALPHA_COMBINE;
+ }
+ return GL_TRUE;
+}
+
+
+/*
+ * Setup the Voodoo3 texture environment for dual texture units.
+ * Return GL_TRUE for success, GL_FALSE for failure.
+ * If failure, we'll use software rendering.
+ */
+static GLboolean
+SetupDoubleTexEnvVoodoo3(GLcontext *ctx, int tmu0,
+ GLenum envMode0, GLenum baseFormat0,
+ GLenum envMode1, GLenum baseFormat1)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ const GrCombineLocal_t locala = GR_COMBINE_LOCAL_ITERATED;
+ const GrCombineLocal_t localc = GR_COMBINE_LOCAL_ITERATED;
+ const int tmu1 = 1 - tmu0;
+
+ if (envMode0 == GL_MODULATE && envMode1 == GL_MODULATE) {
+ GLboolean isalpha[TDFX_NUM_TMU];
+
+ isalpha[tmu0] = (baseFormat0 == GL_ALPHA);
+ isalpha[tmu1] = (baseFormat1 == GL_ALPHA);
+
+ if (isalpha[TDFX_TMU1]) {
+ fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO;
+ fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].InvertRGB = FXTRUE;
+ fxMesa->TexCombine[1].InvertAlpha = FXFALSE;
+ }
+ else {
+ fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[1].InvertAlpha = FXFALSE;
+ }
+ if (isalpha[TDFX_TMU0]) {
+ fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE;
+ fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_LOCAL;
+ fxMesa->TexCombine[0].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
+ }
+ else {
+ fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_LOCAL;
+ fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_LOCAL;
+ fxMesa->TexCombine[0].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
+ }
+ fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_LOCAL;
+ fxMesa->ColorCombine.Local = localc;
+ fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE;
+ fxMesa->ColorCombine.Invert = FXFALSE;
+ fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_LOCAL;
+ fxMesa->AlphaCombine.Local = locala;
+ fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE;
+ fxMesa->AlphaCombine.Invert = FXFALSE;
+ }
+ else if (envMode0 == GL_REPLACE && envMode1 == GL_BLEND) { /* Quake */
+ if (tmu0 == TDFX_TMU1) {
+ fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].InvertRGB = FXTRUE;
+ fxMesa->TexCombine[1].InvertAlpha = FXFALSE;
+ fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_LOCAL;
+ fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_LOCAL;
+ fxMesa->TexCombine[0].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
+ }
+ else {
+ fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[1].InvertAlpha = FXFALSE;
+ fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE_MINUS_LOCAL;
+ fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE_MINUS_LOCAL;
+ fxMesa->TexCombine[0].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
+ }
+ fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_ONE;
+ fxMesa->ColorCombine.Local = localc;
+ fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE;
+ fxMesa->ColorCombine.Invert = FXFALSE;
+ fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE;
+ fxMesa->AlphaCombine.Local = locala;
+ fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE;
+ fxMesa->AlphaCombine.Invert = FXFALSE;
+ }
+ else if (envMode0 == GL_REPLACE && envMode1 == GL_MODULATE) {
+ /* Quake 2/3 */
+ if (tmu1 == TDFX_TMU1) {
+ fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_ZERO;
+ fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[1].InvertAlpha = FXTRUE;
+ fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_LOCAL;
+ fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_LOCAL;
+ fxMesa->TexCombine[0].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
+ }
+ else {
+ fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[1].InvertAlpha = FXFALSE;
+ fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_LOCAL;
+ fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE;
+ fxMesa->TexCombine[0].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
+ }
+
+ fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_ONE;
+ fxMesa->ColorCombine.Local = localc;
+ fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE;
+ fxMesa->ColorCombine.Invert = FXFALSE;
+ if (baseFormat0 == GL_RGB) {
+ fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE;
+ fxMesa->AlphaCombine.Local = locala;
+ fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE;
+ fxMesa->AlphaCombine.Invert = FXFALSE;
+ }
+ else {
+ fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_ONE;
+ fxMesa->AlphaCombine.Local = locala;
+ fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE;
+ fxMesa->AlphaCombine.Invert = FXFALSE;
+ }
+ }
+ else if (envMode0 == GL_MODULATE && envMode1 == GL_ADD) {
+ /* Quake 3 sky */
+ GLboolean isalpha[TDFX_NUM_TMU];
+
+ isalpha[tmu0] = (baseFormat0 == GL_ALPHA);
+ isalpha[tmu1] = (baseFormat1 == GL_ALPHA);
+
+ if (isalpha[TDFX_TMU1]) {
+ fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO;
+ fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].InvertRGB = FXTRUE;
+ fxMesa->TexCombine[1].InvertAlpha = FXFALSE;
+ }
+ else {
+ fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[1].InvertAlpha = FXFALSE;
+ }
+ if (isalpha[TDFX_TMU0]) {
+ fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE;
+ fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
+ fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE;
+ fxMesa->TexCombine[0].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
+ }
+ else {
+ fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
+ fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE;
+ fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
+ fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE;
+ fxMesa->TexCombine[0].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
+ }
+ fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_LOCAL;
+ fxMesa->ColorCombine.Local = localc;
+ fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE;
+ fxMesa->ColorCombine.Invert = FXFALSE;
+ fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_LOCAL;
+ fxMesa->AlphaCombine.Local = locala;
+ fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE;
+ fxMesa->AlphaCombine.Invert = FXFALSE;
+ }
+ else if (envMode0 == GL_REPLACE && envMode1 == GL_ADD) {
+ /* Vulpine sky */
+ GLboolean isalpha[TDFX_NUM_TMU];
+
+ isalpha[tmu0] = (baseFormat0 == GL_ALPHA);
+ isalpha[tmu1] = (baseFormat1 == GL_ALPHA);
+
+ if (isalpha[TDFX_TMU1]) {
+ fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO;
+ fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].InvertRGB = FXTRUE;
+ fxMesa->TexCombine[1].InvertAlpha = FXFALSE;
+ } else {
+ fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[1].InvertAlpha = FXFALSE;
+ }
+
+ if (isalpha[TDFX_TMU0]) {
+ fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE;
+ fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
+ fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE;
+ fxMesa->TexCombine[0].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
+ } else {
+ fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
+ fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE;
+ fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
+ fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE;
+ fxMesa->TexCombine[0].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
+ }
+
+ fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_ONE;
+ fxMesa->ColorCombine.Local = localc;
+ fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE;
+ fxMesa->ColorCombine.Invert = FXFALSE;
+ fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_ONE;
+ fxMesa->AlphaCombine.Local = locala;
+ fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE;
+ fxMesa->AlphaCombine.Invert = FXFALSE;
+ }
+ else if (envMode1 == GL_REPLACE) {
+ /* Homeworld2 */
+
+ fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO;
+ fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_ZERO;
+ fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[1].InvertAlpha = FXFALSE;
+
+ fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[0].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
+
+ if ((baseFormat0 == GL_RGB) && (baseFormat0 == GL_LUMINANCE)) {
+ fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE;
+ fxMesa->AlphaCombine.Local = locala;
+ fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE;
+ fxMesa->AlphaCombine.Invert = FXFALSE;
+ } else {
+ fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_ONE;
+ fxMesa->AlphaCombine.Local = locala;
+ fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE;
+ fxMesa->AlphaCombine.Invert = FXFALSE;
+ }
+ if (baseFormat0 == GL_ALPHA) {
+ fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_NONE;
+ fxMesa->ColorCombine.Local = localc;
+ fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_NONE;
+ fxMesa->ColorCombine.Invert = FXFALSE;
+ } else {
+ fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_ONE;
+ fxMesa->ColorCombine.Local = localc;
+ fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE;
+ fxMesa->ColorCombine.Invert = FXFALSE;
+ }
+ }
+ else {
+ _mesa_problem(ctx, "%s: Unexpected dual texture mode encountered", __FUNCTION__);
+ return GL_FALSE;
+ }
+
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_ENV;
+ fxMesa->dirty |= TDFX_UPLOAD_COLOR_COMBINE;
+ fxMesa->dirty |= TDFX_UPLOAD_ALPHA_COMBINE;
+ return GL_TRUE;
+}
+
+
+/*
+ * This function makes sure that the correct mipmap levels are loaded
+ * in the right places in memory and then makes the Glide calls to
+ * setup the texture source pointers.
+ */
+static void
+setupSingleTMU(tdfxContextPtr fxMesa, struct gl_texture_object *tObj)
+{
+ struct tdfxSharedState *shared = (struct tdfxSharedState *) fxMesa->glCtx->Shared->DriverData;
+ tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
+ const GLcontext *ctx = fxMesa->glCtx;
+
+ /* Make sure we're not loaded incorrectly */
+ if (ti->isInTM && !shared->umaTexMemory) {
+ /* if doing filtering between mipmap levels, alternate mipmap levels
+ * must be in alternate TMUs.
+ */
+ if (ti->LODblend) {
+ if (ti->whichTMU != TDFX_TMU_SPLIT)
+ tdfxTMMoveOutTM_NoLock(fxMesa, tObj);
+ }
+ else {
+ if (ti->whichTMU == TDFX_TMU_SPLIT)
+ tdfxTMMoveOutTM_NoLock(fxMesa, tObj);
+ }
+ }
+
+ /* Make sure we're loaded correctly */
+ if (!ti->isInTM) {
+ /* Have to download the texture */
+ if (shared->umaTexMemory) {
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0);
+ }
+ else {
+ /* Voodoo3 (split texture memory) */
+ if (ti->LODblend) {
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU_SPLIT);
+ }
+ else {
+#if 0
+ /* XXX putting textures into the second memory bank when the
+ * first bank is full is not working at this time.
+ */
+ if (fxMesa->haveTwoTMUs) {
+ GLint memReq = fxMesa->Glide.grTexTextureMemRequired(
+ GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
+ if (shared->freeTexMem[TDFX_TMU0] > memReq) {
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0);
+ }
+ else {
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU1);
+ }
+ }
+ else
+#endif
+ {
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj, TDFX_TMU0);
+ }
+ }
+ }
+ }
+
+ if (ti->LODblend && ti->whichTMU == TDFX_TMU_SPLIT) {
+ /* mipmap levels split between texture banks */
+ GLint u;
+
+ if (ti->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) {
+ fxMesa->TexPalette.Type = ti->paltype;
+ fxMesa->TexPalette.Data = &(ti->palette);
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
+ }
+
+ for (u = 0; u < 2; u++) {
+ fxMesa->TexParams[u].sClamp = ti->sClamp;
+ fxMesa->TexParams[u].tClamp = ti->tClamp;
+ fxMesa->TexParams[u].minFilt = ti->minFilt;
+ fxMesa->TexParams[u].magFilt = ti->magFilt;
+ fxMesa->TexParams[u].mmMode = ti->mmMode;
+ fxMesa->TexParams[u].LODblend = ti->LODblend;
+ fxMesa->TexParams[u].LodBias = ctx->Texture.Unit[u].LodBias;
+ }
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS;
+
+ fxMesa->TexSource[0].StartAddress = ti->tm[TDFX_TMU0]->startAddr;
+ fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_ODD;
+ fxMesa->TexSource[0].Info = &(ti->info);
+ fxMesa->TexSource[1].StartAddress = ti->tm[TDFX_TMU1]->startAddr;
+ fxMesa->TexSource[1].EvenOdd = GR_MIPMAPLEVELMASK_EVEN;
+ fxMesa->TexSource[1].Info = &(ti->info);
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE;
+ }
+ else {
+ FxU32 tmu;
+
+ if (ti->whichTMU == TDFX_TMU_BOTH)
+ tmu = TDFX_TMU0;
+ else
+ tmu = ti->whichTMU;
+
+ if (shared->umaTexMemory) {
+ assert(ti->whichTMU == TDFX_TMU0);
+ assert(tmu == TDFX_TMU0);
+ }
+
+ if (ti->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) {
+ fxMesa->TexPalette.Type = ti->paltype;
+ fxMesa->TexPalette.Data = &(ti->palette);
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
+ }
+
+ /* KW: The alternative is to do the download to the other tmu. If
+ * we get to this point, I think it means we are thrashing the
+ * texture memory, so perhaps it's not a good idea.
+ */
+
+ if (fxMesa->TexParams[tmu].sClamp != ti->sClamp ||
+ fxMesa->TexParams[tmu].tClamp != ti->tClamp ||
+ fxMesa->TexParams[tmu].minFilt != ti->minFilt ||
+ fxMesa->TexParams[tmu].magFilt != ti->magFilt ||
+ fxMesa->TexParams[tmu].mmMode != ti->mmMode ||
+ fxMesa->TexParams[tmu].LODblend != FXFALSE ||
+ fxMesa->TexParams[tmu].LodBias != ctx->Texture.Unit[tmu].LodBias) {
+ fxMesa->TexParams[tmu].sClamp = ti->sClamp;
+ fxMesa->TexParams[tmu].tClamp = ti->tClamp;
+ fxMesa->TexParams[tmu].minFilt = ti->minFilt;
+ fxMesa->TexParams[tmu].magFilt = ti->magFilt;
+ fxMesa->TexParams[tmu].mmMode = ti->mmMode;
+ fxMesa->TexParams[tmu].LODblend = FXFALSE;
+ fxMesa->TexParams[tmu].LodBias = ctx->Texture.Unit[tmu].LodBias;
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS;
+ }
+
+ /* Glide texture source info */
+ fxMesa->TexSource[0].Info = NULL;
+ fxMesa->TexSource[1].Info = NULL;
+ if (ti->tm[tmu]) {
+ fxMesa->TexSource[tmu].StartAddress = ti->tm[tmu]->startAddr;
+ fxMesa->TexSource[tmu].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
+ fxMesa->TexSource[tmu].Info = &(ti->info);
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE;
+ }
+ }
+
+ fxMesa->sScale0 = ti->sScale;
+ fxMesa->tScale0 = ti->tScale;
+}
+
+static void
+selectSingleTMUSrc(tdfxContextPtr fxMesa, GLint tmu, FxBool LODblend)
+{
+ if (LODblend) {
+ fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND;
+ fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION;
+ fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND;
+ fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION;
+ fxMesa->TexCombine[0].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
+
+ if (fxMesa->haveTwoTMUs) {
+ const struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ const struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ int tmu;
+
+ if (shared->umaTexMemory)
+ tmu = GR_TMU0;
+ else
+ tmu = GR_TMU1;
+
+ fxMesa->TexCombine[tmu].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[tmu].FactorRGB = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[tmu].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[tmu].FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[tmu].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[tmu].InvertAlpha = FXFALSE;
+ }
+ fxMesa->tmuSrc = TDFX_TMU_SPLIT;
+ }
+ else {
+ if (tmu != TDFX_TMU1) {
+ fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[0].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
+ if (fxMesa->haveTwoTMUs) {
+ fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO;
+ fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_ZERO;
+ fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[1].InvertAlpha = FXFALSE;
+ }
+ fxMesa->tmuSrc = TDFX_TMU0;
+ }
+ else {
+ fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ fxMesa->TexCombine[1].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[1].InvertAlpha = FXFALSE;
+ /* GR_COMBINE_FUNCTION_SCALE_OTHER doesn't work ?!? */
+ fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_BLEND;
+ fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE;
+ fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_BLEND;
+ fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE;
+ fxMesa->TexCombine[0].InvertRGB = FXFALSE;
+ fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
+ fxMesa->tmuSrc = TDFX_TMU1;
+ }
+ }
+
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_ENV;
+}
+
+#if 0
+static void print_state(tdfxContextPtr fxMesa)
+{
+ GLcontext *ctx = fxMesa->glCtx;
+ struct gl_texture_object *tObj0 = ctx->Texture.Unit[0]._Current;
+ struct gl_texture_object *tObj1 = ctx->Texture.Unit[1]._Current;
+ GLenum base0 = tObj0->Image[0][tObj0->BaseLevel] ? tObj0->Image[0][tObj0->BaseLevel]->Format : 99;
+ GLenum base1 = tObj1->Image[0][tObj1->BaseLevel] ? tObj1->Image[0][tObj1->BaseLevel]->Format : 99;
+
+ printf("Unit 0: Enabled: GL=%d Gr=%d\n", ctx->Texture.Unit[0]._ReallyEnabled,
+ fxMesa->TexState.Enabled[0]);
+ printf(" EnvMode: GL=0x%x Gr=0x%x\n", ctx->Texture.Unit[0].EnvMode,
+ fxMesa->TexState.EnvMode[0]);
+ printf(" BaseFmt: GL=0x%x Gr=0x%x\n", base0, fxMesa->TexState.TexFormat[0]);
+
+
+ printf("Unit 1: Enabled: GL=%d Gr=%d\n", ctx->Texture.Unit[1]._ReallyEnabled,
+ fxMesa->TexState.Enabled[1]);
+ printf(" EnvMode: GL=0x%x Gr:0x%x\n", ctx->Texture.Unit[1].EnvMode,
+ fxMesa->TexState.EnvMode[1]);
+ printf(" BaseFmt: GL=0x%x Gr:0x%x\n", base1, fxMesa->TexState.TexFormat[1]);
+}
+#endif
+
+/*
+ * When we're only using a single texture unit, we always use the 0th
+ * Glide/hardware unit, regardless if it's GL_TEXTURE0_ARB or GL_TEXTURE1_ARB
+ * that's enalbed.
+ * Input: ctx - the context
+ * unit - the OpenGL texture unit to use.
+ */
+static void setupTextureSingleTMU(GLcontext * ctx, GLuint unit)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxTexInfo *ti;
+ struct gl_texture_object *tObj;
+ int tmu;
+ GLenum envMode, baseFormat;
+
+ tObj = ctx->Texture.Unit[unit]._Current;
+ if (tObj->Image[0][tObj->BaseLevel]->Border > 0) {
+ FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_BORDER, GL_TRUE);
+ return;
+ }
+
+ setupSingleTMU(fxMesa, tObj);
+
+ ti = TDFX_TEXTURE_DATA(tObj);
+ if (ti->whichTMU == TDFX_TMU_BOTH)
+ tmu = TDFX_TMU0;
+ else
+ tmu = ti->whichTMU;
+
+ if (fxMesa->tmuSrc != tmu) {
+ selectSingleTMUSrc(fxMesa, tmu, ti->LODblend);
+ }
+
+ if (ti->reloadImages)
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_IMAGES;
+
+ /* Check if we really need to update the texenv state */
+ envMode = ctx->Texture.Unit[unit].EnvMode;
+ baseFormat = tObj->Image[0][tObj->BaseLevel]->Format;
+
+ if (TDFX_IS_NAPALM(fxMesa)) {
+ /* see if we really need to update the unit */
+ if (1/*fxMesa->TexState.Enabled[unit] != ctx->Texture.Unit[unit]._ReallyEnabled ||
+ envMode != fxMesa->TexState.EnvMode[0] ||
+ envMode == GL_COMBINE_EXT ||
+ baseFormat != fxMesa->TexState.TexFormat[0]*/) {
+ struct tdfx_texcombine_ext *otherEnv;
+ if (!SetupTexEnvNapalm(ctx, GL_TRUE,
+ &ctx->Texture.Unit[unit], baseFormat,
+ &fxMesa->TexCombineExt[0])) {
+ /* software fallback */
+ FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE);
+ }
+ /* disable other unit */
+ otherEnv = &fxMesa->TexCombineExt[1];
+ otherEnv->Color.SourceA = GR_CMBX_ZERO;
+ otherEnv->Color.ModeA = GR_FUNC_MODE_ZERO;
+ otherEnv->Color.SourceB = GR_CMBX_ZERO;
+ otherEnv->Color.ModeB = GR_FUNC_MODE_ZERO;
+ otherEnv->Color.SourceC = GR_CMBX_ZERO;
+ otherEnv->Color.InvertC = FXFALSE;
+ otherEnv->Color.SourceD = GR_CMBX_ZERO;
+ otherEnv->Color.InvertD = FXFALSE;
+ otherEnv->Color.Shift = 0;
+ otherEnv->Color.Invert = FXFALSE;
+ otherEnv->Alpha.SourceA = GR_CMBX_ITALPHA;
+ otherEnv->Alpha.ModeA = GR_FUNC_MODE_ZERO;
+ otherEnv->Alpha.SourceB = GR_CMBX_ITALPHA;
+ otherEnv->Alpha.ModeB = GR_FUNC_MODE_ZERO;
+ otherEnv->Alpha.SourceC = GR_CMBX_ZERO;
+ otherEnv->Alpha.InvertC = FXFALSE;
+ otherEnv->Alpha.SourceD = GR_CMBX_ZERO;
+ otherEnv->Alpha.InvertD = FXFALSE;
+ otherEnv->Alpha.Shift = 0;
+ otherEnv->Alpha.Invert = FXFALSE;
+
+#if 0/*JJJ*/
+ fxMesa->TexState.Enabled[unit] = ctx->Texture.Unit[unit]._ReallyEnabled;
+ fxMesa->TexState.EnvMode[0] = envMode;
+ fxMesa->TexState.TexFormat[0] = baseFormat;
+ fxMesa->TexState.EnvMode[1] = 0;
+ fxMesa->TexState.TexFormat[1] = 0;
+#endif
+ }
+ }
+ else {
+ /* Voodoo3 */
+
+ /* see if we really need to update the unit */
+ if (1/*fxMesa->TexState.Enabled[unit] != ctx->Texture.Unit[unit]._ReallyEnabled ||
+ envMode != fxMesa->TexState.EnvMode[0] ||
+ envMode == GL_COMBINE_EXT ||
+ baseFormat != fxMesa->TexState.TexFormat[0]*/) {
+ if (!SetupSingleTexEnvVoodoo3(ctx, unit, envMode, baseFormat)) {
+ /* software fallback */
+ FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE);
+ }
+#if 0/*JJJ*/
+ fxMesa->TexState.Enabled[unit] = ctx->Texture.Unit[unit]._ReallyEnabled;
+ fxMesa->TexState.EnvMode[0] = envMode;
+ fxMesa->TexState.TexFormat[0] = baseFormat;
+ fxMesa->TexState.EnvMode[1] = 0;
+ fxMesa->TexState.TexFormat[1] = 0;
+#endif
+ }
+ }
+}
+
+
+static void
+setupDoubleTMU(tdfxContextPtr fxMesa,
+ struct gl_texture_object *tObj0,
+ struct gl_texture_object *tObj1)
+{
+#define T0_NOT_IN_TMU 0x01
+#define T1_NOT_IN_TMU 0x02
+#define T0_IN_TMU0 0x04
+#define T1_IN_TMU0 0x08
+#define T0_IN_TMU1 0x10
+#define T1_IN_TMU1 0x20
+
+ const struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ const struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+ const GLcontext *ctx = fxMesa->glCtx;
+ tdfxTexInfo *ti0 = TDFX_TEXTURE_DATA(tObj0);
+ tdfxTexInfo *ti1 = TDFX_TEXTURE_DATA(tObj1);
+ GLuint tstate = 0;
+ int tmu0 = 0, tmu1 = 1;
+
+ if (shared->umaTexMemory) {
+ if (!ti0->isInTM) {
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU0);
+ assert(ti0->isInTM);
+ }
+ if (!ti1->isInTM) {
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU0);
+ assert(ti1->isInTM);
+ }
+ }
+ else {
+ /* We shouldn't need to do this. There is something wrong with
+ multitexturing when the TMUs are swapped. So, we're forcing
+ them to always be loaded correctly. !!! */
+ if (ti0->whichTMU == TDFX_TMU1)
+ tdfxTMMoveOutTM_NoLock(fxMesa, tObj0);
+ if (ti1->whichTMU == TDFX_TMU0)
+ tdfxTMMoveOutTM_NoLock(fxMesa, tObj1);
+
+ if (ti0->isInTM) {
+ switch (ti0->whichTMU) {
+ case TDFX_TMU0:
+ tstate |= T0_IN_TMU0;
+ break;
+ case TDFX_TMU1:
+ tstate |= T0_IN_TMU1;
+ break;
+ case TDFX_TMU_BOTH:
+ tstate |= T0_IN_TMU0 | T0_IN_TMU1;
+ break;
+ case TDFX_TMU_SPLIT:
+ tstate |= T0_NOT_IN_TMU;
+ break;
+ }
+ }
+ else
+ tstate |= T0_NOT_IN_TMU;
+
+ if (ti1->isInTM) {
+ switch (ti1->whichTMU) {
+ case TDFX_TMU0:
+ tstate |= T1_IN_TMU0;
+ break;
+ case TDFX_TMU1:
+ tstate |= T1_IN_TMU1;
+ break;
+ case TDFX_TMU_BOTH:
+ tstate |= T1_IN_TMU0 | T1_IN_TMU1;
+ break;
+ case TDFX_TMU_SPLIT:
+ tstate |= T1_NOT_IN_TMU;
+ break;
+ }
+ }
+ else
+ tstate |= T1_NOT_IN_TMU;
+
+ /* Move texture maps into TMUs */
+
+ if (!(((tstate & T0_IN_TMU0) && (tstate & T1_IN_TMU1)) ||
+ ((tstate & T0_IN_TMU1) && (tstate & T1_IN_TMU0)))) {
+ if (tObj0 == tObj1) {
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU_BOTH);
+ }
+ else {
+ /* Find the minimal way to correct the situation */
+ if ((tstate & T0_IN_TMU0) || (tstate & T1_IN_TMU1)) {
+ /* We have one in the standard order, setup the other */
+ if (tstate & T0_IN_TMU0) {
+ /* T0 is in TMU0, put T1 in TMU1 */
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU1);
+ }
+ else {
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU0);
+ }
+ /* tmu0 and tmu1 are setup */
+ }
+ else if ((tstate & T0_IN_TMU1) || (tstate & T1_IN_TMU0)) {
+ /* we have one in the reverse order, setup the other */
+ if (tstate & T1_IN_TMU0) {
+ /* T1 is in TMU0, put T0 in TMU1 */
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU1);
+ }
+ else {
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU0);
+ }
+ tmu0 = 1;
+ tmu1 = 0;
+ }
+ else { /* Nothing is loaded */
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj0, TDFX_TMU0);
+ tdfxTMMoveInTM_NoLock(fxMesa, tObj1, TDFX_TMU1);
+ /* tmu0 and tmu1 are setup */
+ }
+ }
+ }
+ }
+
+ ti0->lastTimeUsed = fxMesa->texBindNumber;
+ ti1->lastTimeUsed = fxMesa->texBindNumber;
+
+
+ if (!ctx->Texture.SharedPalette) {
+ if (ti0->info.format == GR_TEXFMT_P_8) {
+ fxMesa->TexPalette.Type = ti0->paltype;
+ fxMesa->TexPalette.Data = &(ti0->palette);
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
+ }
+ else if (ti1->info.format == GR_TEXFMT_P_8) {
+ fxMesa->TexPalette.Type = ti1->paltype;
+ fxMesa->TexPalette.Data = &(ti1->palette);
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
+ }
+ else {
+ fxMesa->TexPalette.Data = NULL;
+ }
+ }
+
+ /*
+ * Setup Unit 0
+ */
+ assert(ti0->isInTM);
+ assert(ti0->tm[tmu0]);
+ fxMesa->TexSource[tmu0].StartAddress = ti0->tm[tmu0]->startAddr;
+ fxMesa->TexSource[tmu0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
+ fxMesa->TexSource[tmu0].Info = &(ti0->info);
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE;
+
+ if (fxMesa->TexParams[tmu0].sClamp != ti0->sClamp ||
+ fxMesa->TexParams[tmu0].tClamp != ti0->tClamp ||
+ fxMesa->TexParams[tmu0].minFilt != ti0->minFilt ||
+ fxMesa->TexParams[tmu0].magFilt != ti0->magFilt ||
+ fxMesa->TexParams[tmu0].mmMode != ti0->mmMode ||
+ fxMesa->TexParams[tmu0].LODblend != FXFALSE ||
+ fxMesa->TexParams[tmu0].LodBias != ctx->Texture.Unit[tmu0].LodBias) {
+ fxMesa->TexParams[tmu0].sClamp = ti0->sClamp;
+ fxMesa->TexParams[tmu0].tClamp = ti0->tClamp;
+ fxMesa->TexParams[tmu0].minFilt = ti0->minFilt;
+ fxMesa->TexParams[tmu0].magFilt = ti0->magFilt;
+ fxMesa->TexParams[tmu0].mmMode = ti0->mmMode;
+ fxMesa->TexParams[tmu0].LODblend = FXFALSE;
+ fxMesa->TexParams[tmu0].LodBias = ctx->Texture.Unit[tmu0].LodBias;
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS;
+ }
+
+ /*
+ * Setup Unit 1
+ */
+ if (shared->umaTexMemory) {
+ ASSERT(ti1->isInTM);
+ ASSERT(ti1->tm[0]);
+ fxMesa->TexSource[tmu1].StartAddress = ti1->tm[0]->startAddr;
+ fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
+ fxMesa->TexSource[tmu1].Info = &(ti1->info);
+ }
+ else {
+ ASSERT(ti1->isInTM);
+ ASSERT(ti1->tm[tmu1]);
+ fxMesa->TexSource[tmu1].StartAddress = ti1->tm[tmu1]->startAddr;
+ fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
+ fxMesa->TexSource[tmu1].Info = &(ti1->info);
+ }
+
+ if (fxMesa->TexParams[tmu1].sClamp != ti1->sClamp ||
+ fxMesa->TexParams[tmu1].tClamp != ti1->tClamp ||
+ fxMesa->TexParams[tmu1].minFilt != ti1->minFilt ||
+ fxMesa->TexParams[tmu1].magFilt != ti1->magFilt ||
+ fxMesa->TexParams[tmu1].mmMode != ti1->mmMode ||
+ fxMesa->TexParams[tmu1].LODblend != FXFALSE ||
+ fxMesa->TexParams[tmu1].LodBias != ctx->Texture.Unit[tmu1].LodBias) {
+ fxMesa->TexParams[tmu1].sClamp = ti1->sClamp;
+ fxMesa->TexParams[tmu1].tClamp = ti1->tClamp;
+ fxMesa->TexParams[tmu1].minFilt = ti1->minFilt;
+ fxMesa->TexParams[tmu1].magFilt = ti1->magFilt;
+ fxMesa->TexParams[tmu1].mmMode = ti1->mmMode;
+ fxMesa->TexParams[tmu1].LODblend = FXFALSE;
+ fxMesa->TexParams[tmu1].LodBias = ctx->Texture.Unit[tmu1].LodBias;
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PARAMS;
+ }
+
+ fxMesa->sScale0 = ti0->sScale;
+ fxMesa->tScale0 = ti0->tScale;
+ fxMesa->sScale1 = ti1->sScale;
+ fxMesa->tScale1 = ti1->tScale;
+
+#undef T0_NOT_IN_TMU
+#undef T1_NOT_IN_TMU
+#undef T0_IN_TMU0
+#undef T1_IN_TMU0
+#undef T0_IN_TMU1
+#undef T1_IN_TMU1
+}
+
+static void setupTextureDoubleTMU(GLcontext * ctx)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ struct gl_texture_object *tObj0 = ctx->Texture.Unit[1]._Current;
+ struct gl_texture_object *tObj1 = ctx->Texture.Unit[0]._Current;
+ tdfxTexInfo *ti0 = TDFX_TEXTURE_DATA(tObj0);
+ tdfxTexInfo *ti1 = TDFX_TEXTURE_DATA(tObj1);
+ struct gl_texture_image *baseImage0 = tObj0->Image[0][tObj0->BaseLevel];
+ struct gl_texture_image *baseImage1 = tObj1->Image[0][tObj1->BaseLevel];
+#if 0/*JJJ*/
+ const GLenum envMode0 = ctx->Texture.Unit[0].EnvMode;
+ const GLenum envMode1 = ctx->Texture.Unit[1].EnvMode;
+#endif
+
+ if (baseImage0->Border > 0 || baseImage1->Border > 0) {
+ FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_BORDER, GL_TRUE);
+ return;
+ }
+
+ setupDoubleTMU(fxMesa, tObj0, tObj1);
+
+ if (ti0->reloadImages || ti1->reloadImages)
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_IMAGES;
+
+ fxMesa->tmuSrc = TDFX_TMU_BOTH;
+
+ if (TDFX_IS_NAPALM(fxMesa)) {
+ /* Remember, Glide has its texture units numbered in backward
+ * order compared to OpenGL.
+ */
+ GLboolean hw1 = GL_TRUE, hw2 = GL_TRUE;
+
+ /* check if we really need to update glide unit 1 */
+ if (1/*fxMesa->TexState.Enabled[0] != ctx->Texture.Unit[0]._ReallyEnabled ||
+ envMode0 != fxMesa->TexState.EnvMode[1] ||
+ envMode0 == GL_COMBINE_EXT ||
+ baseImage0->Format != fxMesa->TexState.TexFormat[1] ||
+ (fxMesa->Fallback & TDFX_FALLBACK_TEXTURE_ENV)*/) {
+ hw1 = SetupTexEnvNapalm(ctx, GL_TRUE, &ctx->Texture.Unit[0],
+ baseImage0->Format, &fxMesa->TexCombineExt[1]);
+#if 0/*JJJ*/
+ fxMesa->TexState.EnvMode[1] = envMode0;
+ fxMesa->TexState.TexFormat[1] = baseImage0->Format;
+ fxMesa->TexState.Enabled[0] = ctx->Texture.Unit[0]._ReallyEnabled;
+#endif
+ }
+
+ /* check if we really need to update glide unit 0 */
+ if (1/*fxMesa->TexState.Enabled[1] != ctx->Texture.Unit[1]._ReallyEnabled ||
+ envMode1 != fxMesa->TexState.EnvMode[0] ||
+ envMode1 == GL_COMBINE_EXT ||
+ baseImage1->Format != fxMesa->TexState.TexFormat[0] ||
+ (fxMesa->Fallback & TDFX_FALLBACK_TEXTURE_ENV)*/) {
+ hw2 = SetupTexEnvNapalm(ctx, GL_FALSE, &ctx->Texture.Unit[1],
+ baseImage1->Format, &fxMesa->TexCombineExt[0]);
+#if 0/*JJJ*/
+ fxMesa->TexState.EnvMode[0] = envMode1;
+ fxMesa->TexState.TexFormat[0] = baseImage1->Format;
+ fxMesa->TexState.Enabled[1] = ctx->Texture.Unit[1]._ReallyEnabled;
+#endif
+ }
+
+
+ if (!hw1 || !hw2) {
+ FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE);
+ }
+ }
+ else {
+ int unit0, unit1;
+ if ((ti0->whichTMU == TDFX_TMU1) || (ti1->whichTMU == TDFX_TMU0))
+ unit0 = 1;
+ else
+ unit0 = 0;
+ unit1 = 1 - unit0;
+
+ if (1/*fxMesa->TexState.Enabled[0] != ctx->Texture.Unit[0]._ReallyEnabled ||
+ fxMesa->TexState.Enabled[1] != ctx->Texture.Unit[1]._ReallyEnabled ||
+ envMode0 != fxMesa->TexState.EnvMode[unit0] ||
+ envMode0 == GL_COMBINE_EXT ||
+ envMode1 != fxMesa->TexState.EnvMode[unit1] ||
+ envMode1 == GL_COMBINE_EXT ||
+ baseImage0->Format != fxMesa->TexState.TexFormat[unit0] ||
+ baseImage1->Format != fxMesa->TexState.TexFormat[unit1] ||
+ (fxMesa->Fallback & TDFX_FALLBACK_TEXTURE_ENV)*/) {
+
+ if (!SetupDoubleTexEnvVoodoo3(ctx, unit0,
+ ctx->Texture.Unit[0].EnvMode, baseImage0->Format,
+ ctx->Texture.Unit[1].EnvMode, baseImage1->Format)) {
+ FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE);
+ }
+
+#if 0/*JJJ*/
+ fxMesa->TexState.EnvMode[unit0] = envMode0;
+ fxMesa->TexState.TexFormat[unit0] = baseImage0->Format;
+ fxMesa->TexState.EnvMode[unit1] = envMode1;
+ fxMesa->TexState.TexFormat[unit1] = baseImage1->Format;
+ fxMesa->TexState.Enabled[0] = ctx->Texture.Unit[0]._ReallyEnabled;
+ fxMesa->TexState.Enabled[1] = ctx->Texture.Unit[1]._ReallyEnabled;
+#endif
+ }
+ }
+}
+
+
+void
+tdfxUpdateTextureState( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_BORDER, GL_FALSE);
+ FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_FALSE);
+
+ if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT) &&
+ ctx->Texture.Unit[1]._ReallyEnabled == 0) {
+ LOCK_HARDWARE( fxMesa ); /* XXX remove locking eventually */
+ setupTextureSingleTMU(ctx, 0);
+ UNLOCK_HARDWARE( fxMesa );
+ }
+ else if (ctx->Texture.Unit[0]._ReallyEnabled == 0 &&
+ ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) {
+ LOCK_HARDWARE( fxMesa );
+ setupTextureSingleTMU(ctx, 1);
+ UNLOCK_HARDWARE( fxMesa );
+ }
+ else if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT) &&
+ ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) {
+ LOCK_HARDWARE( fxMesa );
+ setupTextureDoubleTMU(ctx);
+ UNLOCK_HARDWARE( fxMesa );
+ }
+ else {
+ /* disable hardware texturing */
+ if (TDFX_IS_NAPALM(fxMesa)) {
+ fxMesa->ColorCombineExt.SourceA = GR_CMBX_ITRGB;
+ fxMesa->ColorCombineExt.ModeA = GR_FUNC_MODE_X;
+ fxMesa->ColorCombineExt.SourceB = GR_CMBX_ZERO;
+ fxMesa->ColorCombineExt.ModeB = GR_FUNC_MODE_ZERO;
+ fxMesa->ColorCombineExt.SourceC = GR_CMBX_ZERO;
+ fxMesa->ColorCombineExt.InvertC = FXTRUE;
+ fxMesa->ColorCombineExt.SourceD = GR_CMBX_ZERO;
+ fxMesa->ColorCombineExt.InvertD = FXFALSE;
+ fxMesa->ColorCombineExt.Shift = 0;
+ fxMesa->ColorCombineExt.Invert = FXFALSE;
+ fxMesa->AlphaCombineExt.SourceA = GR_CMBX_ITALPHA;
+ fxMesa->AlphaCombineExt.ModeA = GR_FUNC_MODE_X;
+ fxMesa->AlphaCombineExt.SourceB = GR_CMBX_ZERO;
+ fxMesa->AlphaCombineExt.ModeB = GR_FUNC_MODE_ZERO;
+ fxMesa->AlphaCombineExt.SourceC = GR_CMBX_ZERO;
+ fxMesa->AlphaCombineExt.InvertC = FXTRUE;
+ fxMesa->AlphaCombineExt.SourceD = GR_CMBX_ZERO;
+ fxMesa->AlphaCombineExt.InvertD = FXFALSE;
+ fxMesa->AlphaCombineExt.Shift = 0;
+ fxMesa->AlphaCombineExt.Invert = FXFALSE;
+ }
+ else {
+ /* Voodoo 3*/
+ fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_NONE;
+ fxMesa->ColorCombine.Local = GR_COMBINE_LOCAL_ITERATED;
+ fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_NONE;
+ fxMesa->ColorCombine.Invert = FXFALSE;
+ fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL;
+ fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE;
+ fxMesa->AlphaCombine.Local = GR_COMBINE_LOCAL_ITERATED;
+ fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE;
+ fxMesa->AlphaCombine.Invert = FXFALSE;
+ }
+
+ fxMesa->TexState.Enabled[0] = 0;
+ fxMesa->TexState.Enabled[1] = 0;
+ fxMesa->TexState.EnvMode[0] = 0;
+ fxMesa->TexState.EnvMode[1] = 0;
+
+ fxMesa->dirty |= TDFX_UPLOAD_COLOR_COMBINE;
+ fxMesa->dirty |= TDFX_UPLOAD_ALPHA_COMBINE;
+
+ if (ctx->Texture.Unit[0]._ReallyEnabled != 0 ||
+ ctx->Texture.Unit[1]._ReallyEnabled != 0) {
+ /* software texture (cube map, rect tex, etc */
+ FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE);
+ }
+ }
+}
+
+
+
+/*
+ * This is a special case of texture state update.
+ * It's used when we've simply bound a new texture to a texture
+ * unit and the new texture has the exact same attributes as the
+ * previously bound texture.
+ * This is very common in Quake3.
+ */
+void
+tdfxUpdateTextureBinding( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ struct gl_texture_object *tObj0 = ctx->Texture.Unit[0]._Current;
+ struct gl_texture_object *tObj1 = ctx->Texture.Unit[1]._Current;
+ tdfxTexInfo *ti0 = TDFX_TEXTURE_DATA(tObj0);
+ tdfxTexInfo *ti1 = TDFX_TEXTURE_DATA(tObj1);
+
+ const struct gl_shared_state *mesaShared = fxMesa->glCtx->Shared;
+ const struct tdfxSharedState *shared = (struct tdfxSharedState *) mesaShared->DriverData;
+
+ if (ti0) {
+ fxMesa->sScale0 = ti0->sScale;
+ fxMesa->tScale0 = ti0->tScale;
+ if (ti0->info.format == GR_TEXFMT_P_8) {
+ fxMesa->TexPalette.Type = ti0->paltype;
+ fxMesa->TexPalette.Data = &(ti0->palette);
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
+ }
+ else if (ti1 && ti1->info.format == GR_TEXFMT_P_8) {
+ fxMesa->TexPalette.Type = ti1->paltype;
+ fxMesa->TexPalette.Data = &(ti1->palette);
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
+ }
+ }
+ if (ti1) {
+ fxMesa->sScale1 = ti1->sScale;
+ fxMesa->tScale1 = ti1->tScale;
+ }
+
+ if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT) &&
+ ctx->Texture.Unit[0]._ReallyEnabled == 0) {
+ /* Only unit 0 2D enabled */
+ if (shared->umaTexMemory) {
+ fxMesa->TexSource[0].StartAddress = ti0->tm[0]->startAddr;
+ fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
+ fxMesa->TexSource[0].Info = &(ti0->info);
+ }
+ else {
+ if (ti0->LODblend && ti0->whichTMU == TDFX_TMU_SPLIT) {
+ fxMesa->TexSource[0].StartAddress = ti0->tm[TDFX_TMU0]->startAddr;
+ fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_ODD;
+ fxMesa->TexSource[0].Info = &(ti0->info);
+ fxMesa->TexSource[1].StartAddress = ti0->tm[TDFX_TMU1]->startAddr;
+ fxMesa->TexSource[1].EvenOdd = GR_MIPMAPLEVELMASK_EVEN;
+ fxMesa->TexSource[1].Info = &(ti0->info);
+ }
+ else {
+ FxU32 tmu;
+ if (ti0->whichTMU == TDFX_TMU_BOTH)
+ tmu = TDFX_TMU0;
+ else
+ tmu = ti0->whichTMU;
+ fxMesa->TexSource[0].Info = NULL;
+ fxMesa->TexSource[1].Info = NULL;
+ if (ti0->tm[tmu]) {
+ fxMesa->TexSource[tmu].StartAddress = ti0->tm[tmu]->startAddr;
+ fxMesa->TexSource[tmu].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
+ fxMesa->TexSource[tmu].Info = &(ti0->info);
+ }
+ }
+ }
+ }
+ else if (ctx->Texture.Unit[0]._ReallyEnabled == 0 &&
+ ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) {
+ /* Only unit 1 2D enabled */
+ if (shared->umaTexMemory) {
+ fxMesa->TexSource[0].StartAddress = ti1->tm[0]->startAddr;
+ fxMesa->TexSource[0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
+ fxMesa->TexSource[0].Info = &(ti1->info);
+ }
+ }
+ else if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT) &&
+ ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) {
+ /* Both 2D enabled */
+ if (shared->umaTexMemory) {
+ const FxU32 tmu0 = 0, tmu1 = 1;
+ fxMesa->TexSource[tmu0].StartAddress = ti0->tm[0]->startAddr;
+ fxMesa->TexSource[tmu0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
+ fxMesa->TexSource[tmu0].Info = &(ti0->info);
+
+ fxMesa->TexSource[tmu1].StartAddress = ti1->tm[0]->startAddr;
+ fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
+ fxMesa->TexSource[tmu1].Info = &(ti1->info);
+ }
+ else {
+ const FxU32 tmu0 = 0, tmu1 = 1;
+ fxMesa->TexSource[tmu0].StartAddress = ti0->tm[tmu0]->startAddr;
+ fxMesa->TexSource[tmu0].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
+ fxMesa->TexSource[tmu0].Info = &(ti0->info);
+
+ fxMesa->TexSource[tmu1].StartAddress = ti1->tm[tmu1]->startAddr;
+ fxMesa->TexSource[tmu1].EvenOdd = GR_MIPMAPLEVELMASK_BOTH;
+ fxMesa->TexSource[tmu1].Info = &(ti1->info);
+ }
+ }
+
+
+ fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_SOURCE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.h
new file mode 100644
index 000000000..234ed4439
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_texstate.h
@@ -0,0 +1,44 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.h,v 1.1 2002/02/22 21:45:04 dawes Exp $ */
+
+/*
+ * Original rewrite:
+ * Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Brian Paul <brianp@valinux.com>
+ *
+ */
+
+#ifndef __TDFX_TEXSTATE_H__
+#define __TDFX_TEXSTATE_H__
+
+extern void tdfxUpdateTextureState( GLcontext *ctx );
+extern void tdfxUpdateTextureBinding( GLcontext *ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.c
new file mode 100644
index 000000000..ac8daf474
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.c
@@ -0,0 +1,1293 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.c,v 1.4 2002/10/30 12:52:01 alanh Exp $ */
+
+/* New fixes:
+ * Daniel Borca <dborca@users.sourceforge.net>, 19 Jul 2004
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "colormac.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "swrast_setup/ss_context.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
+#include "tdfx_tris.h"
+#include "tdfx_state.h"
+#include "tdfx_vb.h"
+#include "tdfx_lock.h"
+#include "tdfx_render.h"
+
+
+static void tdfxRasterPrimitive( GLcontext *ctx, GLenum prim );
+static void tdfxRenderPrimitive( GLcontext *ctx, GLenum prim );
+
+static GLenum reduced_prim[GL_POLYGON+1] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES
+};
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ if (DO_FALLBACK) \
+ fxMesa->draw_triangle( fxMesa, a, b, c ); \
+ else \
+ fxMesa->Glide.grDrawTriangle( a, b, c ); \
+} while (0) \
+
+#define QUAD( a, b, c, d ) \
+do { \
+ if (DO_FALLBACK) { \
+ fxMesa->draw_triangle( fxMesa, a, b, d ); \
+ fxMesa->draw_triangle( fxMesa, b, c, d ); \
+ } else { \
+ tdfxVertex *_v_[4]; \
+ _v_[0] = d; \
+ _v_[1] = a; \
+ _v_[2] = b; \
+ _v_[3] = c; \
+ fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_);\
+ /*fxMesa->Glide.grDrawTriangle( a, b, d );*/\
+ /*fxMesa->Glide.grDrawTriangle( b, c, d );*/\
+ } \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ if (DO_FALLBACK) \
+ fxMesa->draw_line( fxMesa, v0, v1 ); \
+ else { \
+ v0->x += LINE_X_OFFSET - TRI_X_OFFSET; \
+ v0->y += LINE_Y_OFFSET - TRI_Y_OFFSET; \
+ v1->x += LINE_X_OFFSET - TRI_X_OFFSET; \
+ v1->y += LINE_Y_OFFSET - TRI_Y_OFFSET; \
+ fxMesa->Glide.grDrawLine( v0, v1 ); \
+ v0->x -= LINE_X_OFFSET - TRI_X_OFFSET; \
+ v0->y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \
+ v1->x -= LINE_X_OFFSET - TRI_X_OFFSET; \
+ v1->y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \
+ } \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ if (DO_FALLBACK) \
+ fxMesa->draw_point( fxMesa, v0 ); \
+ else { \
+ v0->x += PNT_X_OFFSET - TRI_X_OFFSET; \
+ v0->y += PNT_Y_OFFSET - TRI_Y_OFFSET; \
+ fxMesa->Glide.grDrawPoint( v0 ); \
+ v0->x -= PNT_X_OFFSET - TRI_X_OFFSET; \
+ v0->y -= PNT_Y_OFFSET - TRI_Y_OFFSET; \
+ } \
+} while (0)
+
+
+/***********************************************************************
+ * Fallback to swrast for basic primitives *
+ ***********************************************************************/
+
+/* Build an SWvertex from a hardware vertex.
+ *
+ * This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+static void
+tdfx_translate_vertex( GLcontext *ctx, const tdfxVertex *src, SWvertex *dst)
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ if (fxMesa->vertexFormat == TDFX_LAYOUT_TINY) {
+ dst->win[0] = src->x - fxMesa->x_offset;
+ dst->win[1] = src->y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset);
+ dst->win[2] = src->z;
+ dst->win[3] = 1.0;
+
+ dst->color[0] = src->color[2];
+ dst->color[1] = src->color[1];
+ dst->color[2] = src->color[0];
+ dst->color[3] = src->color[3];
+ }
+ else {
+ GLfloat w = 1.0 / src->rhw;
+
+ dst->win[0] = src->x - fxMesa->x_offset;
+ dst->win[1] = src->y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset);
+ dst->win[2] = src->z;
+ dst->win[3] = src->rhw;
+
+ dst->color[0] = src->color[2];
+ dst->color[1] = src->color[1];
+ dst->color[2] = src->color[0];
+ dst->color[3] = src->color[3];
+
+ dst->texcoord[0][0] = 1.0 / fxMesa->sScale0 * w * src->tu0;
+ dst->texcoord[0][1] = 1.0 / fxMesa->tScale0 * w * src->tv0;
+ if (fxMesa->vertexFormat == TDFX_LAYOUT_PROJ1 || fxMesa->vertexFormat == TDFX_LAYOUT_PROJ2) {
+ dst->texcoord[0][3] = w * src->tq0;
+ } else {
+ dst->texcoord[0][3] = 1.0;
+ }
+
+ if (fxMesa->SetupIndex & TDFX_TEX1_BIT) {
+ dst->texcoord[1][0] = 1.0 / fxMesa->sScale1 * w * src->tu1;
+ dst->texcoord[1][1] = 1.0 / fxMesa->tScale1 * w * src->tv1;
+ if (fxMesa->vertexFormat == TDFX_LAYOUT_PROJ2) {
+ dst->texcoord[1][3] = w * src->tq1;
+ } else {
+ dst->texcoord[1][3] = 1.0;
+ }
+ }
+ }
+
+ dst->pointSize = ctx->Point._Size;
+}
+
+
+static void
+tdfx_fallback_tri( tdfxContextPtr fxMesa,
+ tdfxVertex *v0,
+ tdfxVertex *v1,
+ tdfxVertex *v2 )
+{
+ GLcontext *ctx = fxMesa->glCtx;
+ SWvertex v[3];
+ tdfx_translate_vertex( ctx, v0, &v[0] );
+ tdfx_translate_vertex( ctx, v1, &v[1] );
+ tdfx_translate_vertex( ctx, v2, &v[2] );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+}
+
+
+static void
+tdfx_fallback_line( tdfxContextPtr fxMesa,
+ tdfxVertex *v0,
+ tdfxVertex *v1 )
+{
+ GLcontext *ctx = fxMesa->glCtx;
+ SWvertex v[2];
+ tdfx_translate_vertex( ctx, v0, &v[0] );
+ tdfx_translate_vertex( ctx, v1, &v[1] );
+ _swrast_Line( ctx, &v[0], &v[1] );
+}
+
+
+static void
+tdfx_fallback_point( tdfxContextPtr fxMesa,
+ tdfxVertex *v0 )
+{
+ GLcontext *ctx = fxMesa->glCtx;
+ SWvertex v[1];
+ tdfx_translate_vertex( ctx, v0, &v[0] );
+ _swrast_Point( ctx, &v[0] );
+}
+
+/***********************************************************************
+ * Functions to draw basic primitives *
+ ***********************************************************************/
+
+static void tdfx_print_vertex( GLcontext *ctx, const tdfxVertex *v )
+{
+ tdfxContextPtr tmesa = TDFX_CONTEXT( ctx );
+
+ fprintf(stderr, "vertex at %p\n", (void *)v);
+
+ if (tmesa->vertexFormat == TDFX_LAYOUT_TINY) {
+ fprintf(stderr, "x %f y %f z %f\n", v->x, v->y, v->z);
+ }
+ else {
+ fprintf(stderr, "x %f y %f z %f oow %f\n",
+ v->x, v->y, v->z, v->rhw);
+ }
+ fprintf(stderr, "r %d g %d b %d a %d\n",
+ v->color[0],
+ v->color[1],
+ v->color[2],
+ v->color[3]);
+
+ fprintf(stderr, "\n");
+}
+
+#define DO_FALLBACK 0
+
+/* Need to do clip loop at each triangle when mixing swrast and hw
+ * rendering. These functions are only used when mixed-mode rendering
+ * is occurring.
+ */
+static void tdfx_draw_triangle( tdfxContextPtr fxMesa,
+ tdfxVertexPtr v0,
+ tdfxVertexPtr v1,
+ tdfxVertexPtr v2 )
+{
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+/* tdfx_print_vertex( fxMesa->glCtx, v0 ); */
+/* tdfx_print_vertex( fxMesa->glCtx, v1 ); */
+/* tdfx_print_vertex( fxMesa->glCtx, v2 ); */
+ BEGIN_CLIP_LOOP_LOCKED(fxMesa) {
+ TRI( v0, v1, v2 );
+ } END_CLIP_LOOP_LOCKED(fxMesa);
+}
+
+static void tdfx_draw_line( tdfxContextPtr fxMesa,
+ tdfxVertexPtr v0,
+ tdfxVertexPtr v1 )
+{
+ /* No support for wide lines (avoid wide/aa line fallback).
+ */
+ BEGIN_CLIP_LOOP_LOCKED(fxMesa) {
+ LINE(v0, v1);
+ } END_CLIP_LOOP_LOCKED(fxMesa);
+}
+
+static void tdfx_draw_point( tdfxContextPtr fxMesa,
+ tdfxVertexPtr v0 )
+{
+ /* No support for wide points.
+ */
+ BEGIN_CLIP_LOOP_LOCKED(fxMesa) {
+ POINT( v0 );
+ } END_CLIP_LOOP_LOCKED(fxMesa);
+}
+
+#undef DO_FALLBACK
+
+
+#define TDFX_UNFILLED_BIT 0x1
+#define TDFX_OFFSET_BIT 0x2
+#define TDFX_TWOSIDE_BIT 0x4
+#define TDFX_FLAT_BIT 0x8
+#define TDFX_FALLBACK_BIT 0x10
+#define TDFX_MAX_TRIFUNC 0x20
+
+static struct {
+ tnl_points_func points;
+ tnl_line_func line;
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
+} rast_tab[TDFX_MAX_TRIFUNC];
+
+#define DO_FALLBACK (IND & TDFX_FALLBACK_BIT)
+#define DO_OFFSET (IND & TDFX_OFFSET_BIT)
+#define DO_UNFILLED (IND & TDFX_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & TDFX_TWOSIDE_BIT)
+#define DO_FLAT (IND & TDFX_FLAT_BIT)
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 0
+#define HAVE_HW_FLATSHADE 0
+#define HAVE_BACK_COLORS 0
+#define VERTEX tdfxVertex
+#define TAB rast_tab
+
+#define DEPTH_SCALE 1.0
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->x
+#define VERT_Y(_v) _v->y
+#define VERT_Z(_v) _v->z
+#define AREA_IS_CCW( a ) (a < 0)
+#define GET_VERTEX(e) (fxMesa->verts + (e))
+
+#define VERT_SET_RGBA( dst, f ) \
+do { \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst->color[2], f[0]);\
+ UNCLAMPED_FLOAT_TO_UBYTE(dst->color[1], f[1]);\
+ UNCLAMPED_FLOAT_TO_UBYTE(dst->color[0], f[2]);\
+ UNCLAMPED_FLOAT_TO_UBYTE(dst->color[3], f[3]);\
+} while (0)
+
+#define VERT_COPY_RGBA( v0, v1 ) \
+ *(GLuint *)&v0->color = *(GLuint *)&v1->color
+
+#define VERT_SAVE_RGBA( idx ) \
+ *(GLuint *)&color[idx] = *(GLuint *)&v[idx]->color
+
+#define VERT_RESTORE_RGBA( idx ) \
+ *(GLuint *)&v[idx]->color = *(GLuint *)&color[idx]
+
+#define LOCAL_VARS(n) \
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \
+ GLubyte color[n][4]; \
+ (void) color;
+
+
+
+/***********************************************************************
+ * Functions to draw basic unfilled primitives *
+ ***********************************************************************/
+
+#define RASTERIZE(x) if (fxMesa->raster_primitive != reduced_prim[x]) \
+ tdfxRasterPrimitive( ctx, reduced_prim[x] )
+#define RENDER_PRIMITIVE fxMesa->render_primitive
+#define IND TDFX_FALLBACK_BIT
+#define TAG(x) x
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+/***********************************************************************
+ * Functions to draw GL primitives *
+ ***********************************************************************/
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_FALLBACK_BIT)
+#define TAG(x) x##_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_OFFSET_BIT|TDFX_FALLBACK_BIT)
+#define TAG(x) x##_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_FALLBACK_BIT)
+#define TAG(x) x##_twoside_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT)
+#define TAG(x) x##_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT)
+#define TAG(x) x##_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT| \
+ TDFX_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+/* Tdfx doesn't support provoking-vertex flat-shading?
+ */
+#define IND (TDFX_FLAT_BIT)
+#define TAG(x) x##_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_OFFSET_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_offset_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_twoside_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_UNFILLED_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_offset_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_UNFILLED_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_twoside_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_OFFSET_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_offset_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_twoside_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_offset_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_UNFILLED_BIT|TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TDFX_TWOSIDE_BIT|TDFX_OFFSET_BIT|TDFX_UNFILLED_BIT| \
+ TDFX_FALLBACK_BIT|TDFX_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+static void init_rast_tab( void )
+{
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+ init_fallback();
+ init_offset_fallback();
+ init_twoside_fallback();
+ init_twoside_offset_fallback();
+ init_unfilled_fallback();
+ init_offset_unfilled_fallback();
+ init_twoside_unfilled_fallback();
+ init_twoside_offset_unfilled_fallback();
+
+ init_flat();
+ init_offset_flat();
+ init_twoside_flat();
+ init_twoside_offset_flat();
+ init_unfilled_flat();
+ init_offset_unfilled_flat();
+ init_twoside_unfilled_flat();
+ init_twoside_offset_unfilled_flat();
+ init_fallback_flat();
+ init_offset_fallback_flat();
+ init_twoside_fallback_flat();
+ init_twoside_offset_fallback_flat();
+ init_unfilled_fallback_flat();
+ init_offset_unfilled_fallback_flat();
+ init_twoside_unfilled_fallback_flat();
+ init_twoside_offset_unfilled_fallback_flat();
+}
+
+
+/**********************************************************************/
+/* Render whole begin/end objects */
+/**********************************************************************/
+
+
+/* Accelerate vertex buffer rendering when renderindex == 0 and
+ * there is no clipping.
+ */
+#define INIT(x) tdfxRenderPrimitive( ctx, x )
+
+static void tdfx_render_vb_points( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxVertex *fxVB = fxMesa->verts;
+ GLint i;
+ (void) flags;
+
+ INIT(GL_POINTS);
+
+ /* Adjust point coords */
+ for (i = start; i < count; i++) {
+ fxVB[i].x += PNT_X_OFFSET - TRI_X_OFFSET;
+ fxVB[i].y += PNT_Y_OFFSET - TRI_Y_OFFSET;
+ }
+
+ fxMesa->Glide.grDrawVertexArrayContiguous( GR_POINTS, count-start,
+ fxVB + start, sizeof(tdfxVertex));
+ /* restore point coords */
+ for (i = start; i < count; i++) {
+ fxVB[i].x -= PNT_X_OFFSET - TRI_X_OFFSET;
+ fxVB[i].y -= PNT_Y_OFFSET - TRI_Y_OFFSET;
+ }
+}
+
+static void tdfx_render_vb_line_strip( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxVertex *fxVB = fxMesa->verts;
+ GLint i;
+ (void) flags;
+
+ INIT(GL_LINE_STRIP);
+
+ /* adjust line coords */
+ for (i = start; i < count; i++) {
+ fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET;
+ fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET;
+ }
+
+ fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINE_STRIP, count-start,
+ fxVB + start, sizeof(tdfxVertex) );
+
+ /* restore line coords */
+ for (i = start; i < count; i++) {
+ fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET;
+ fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
+ }
+}
+
+static void tdfx_render_vb_line_loop( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxVertex *fxVB = fxMesa->verts;
+ GLint i;
+ GLint j = start;
+ (void) flags;
+
+ INIT(GL_LINE_LOOP);
+
+ if (!(flags & PRIM_BEGIN)) {
+ j++;
+ }
+
+ /* adjust line coords */
+ for (i = start; i < count; i++) {
+ fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET;
+ fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET;
+ }
+
+ fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINE_STRIP, count-j,
+ fxVB + j, sizeof(tdfxVertex));
+
+ if (flags & PRIM_END)
+ fxMesa->Glide.grDrawLine( fxVB + (count - 1),
+ fxVB + start );
+
+ /* restore line coords */
+ for (i = start; i < count; i++) {
+ fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET;
+ fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
+ }
+}
+
+static void tdfx_render_vb_lines( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxVertex *fxVB = fxMesa->verts;
+ GLint i;
+ (void) flags;
+
+ INIT(GL_LINES);
+
+ /* adjust line coords */
+ for (i = start; i < count; i++) {
+ fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET;
+ fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET;
+ }
+
+ fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINES, count-start,
+ fxVB + start, sizeof(tdfxVertex));
+
+ /* restore line coords */
+ for (i = start; i < count; i++) {
+ fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET;
+ fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
+ }
+}
+
+static void tdfx_render_vb_triangles( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxVertex *fxVB = fxMesa->verts;
+ (void) flags;
+
+ INIT(GL_TRIANGLES);
+
+#if 0
+ /* [dBorca]
+ * apparently, this causes troubles with some programs (GLExcess);
+ * might be a bug in Glide... However, "grDrawVertexArrayContiguous"
+ * eventually calls "grDrawTriangle" for GR_TRIANGLES, so we're better
+ * off doing it by hand...
+ */
+ fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLES, count-start,
+ fxVB + start, sizeof(tdfxVertex));
+#else
+ {
+ GLuint j;
+ for (j=start+2; j<count; j+=3) {
+ fxMesa->Glide.grDrawTriangle(fxVB + (j-2), fxVB + (j-1), fxVB + j);
+ }
+ }
+#endif
+}
+
+
+static void tdfx_render_vb_tri_strip( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxVertex *fxVB = fxMesa->verts;
+ int mode;
+ (void) flags;
+
+ INIT(GL_TRIANGLE_STRIP);
+
+/* fprintf(stderr, "%s/%d\n", __FUNCTION__, 1<<shift); */
+/* if(!prevLockLine) abort(); */
+
+ mode = GR_TRIANGLE_STRIP;
+
+ fxMesa->Glide.grDrawVertexArrayContiguous( mode, count-start,
+ fxVB + start, sizeof(tdfxVertex));
+}
+
+
+static void tdfx_render_vb_tri_fan( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxVertex *fxVB = fxMesa->verts;
+ (void) flags;
+
+ INIT(GL_TRIANGLE_FAN);
+
+ fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLE_FAN, count-start,
+ fxVB + start, sizeof(tdfxVertex) );
+}
+
+static void tdfx_render_vb_quads( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxVertex *fxVB = fxMesa->verts;
+ GLuint i;
+ (void) flags;
+
+ INIT(GL_QUADS);
+
+ for (i = start + 3 ; i < count ; i += 4 ) {
+#define VERT(x) (fxVB + (x))
+ tdfxVertex *_v_[4];
+ _v_[0] = VERT(i);
+ _v_[1] = VERT(i-3);
+ _v_[2] = VERT(i-2);
+ _v_[3] = VERT(i-1);
+ fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_);
+ /*fxMesa->Glide.grDrawTriangle( VERT(i-3), VERT(i-2), VERT(i) );*/
+ /*fxMesa->Glide.grDrawTriangle( VERT(i-2), VERT(i-1), VERT(i) );*/
+#undef VERT
+ }
+}
+
+static void tdfx_render_vb_quad_strip( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxVertex *fxVB = fxMesa->verts;
+ (void) flags;
+
+ INIT(GL_QUAD_STRIP);
+
+ count -= (count-start)&1;
+
+ fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLE_STRIP,
+ count-start, fxVB + start, sizeof(tdfxVertex));
+}
+
+static void tdfx_render_vb_poly( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ tdfxVertex *fxVB = fxMesa->verts;
+ (void) flags;
+
+ INIT(GL_POLYGON);
+
+ fxMesa->Glide.grDrawVertexArrayContiguous( GR_POLYGON, count-start,
+ fxVB + start, sizeof(tdfxVertex));
+}
+
+static void tdfx_render_vb_noop( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ (void) (ctx && start && count && flags);
+}
+
+static void (*tdfx_render_tab_verts[GL_POLYGON+2])(GLcontext *,
+ GLuint,
+ GLuint,
+ GLuint) =
+{
+ tdfx_render_vb_points,
+ tdfx_render_vb_lines,
+ tdfx_render_vb_line_loop,
+ tdfx_render_vb_line_strip,
+ tdfx_render_vb_triangles,
+ tdfx_render_vb_tri_strip,
+ tdfx_render_vb_tri_fan,
+ tdfx_render_vb_quads,
+ tdfx_render_vb_quad_strip,
+ tdfx_render_vb_poly,
+ tdfx_render_vb_noop,
+};
+#undef INIT
+
+
+/**********************************************************************/
+/* Render whole (indexed) begin/end objects */
+/**********************************************************************/
+
+
+#define VERT(x) (tdfxVertex *)(vertptr + (x))
+
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ fxMesa->Glide.grDrawPoint( VERT(ELT(start)) );
+
+#define RENDER_LINE( v0, v1 ) \
+ fxMesa->Glide.grDrawLine( VERT(v0), VERT(v1) )
+
+#define RENDER_TRI( v0, v1, v2 ) \
+ fxMesa->Glide.grDrawTriangle( VERT(v0), VERT(v1), VERT(v2) )
+
+#define RENDER_QUAD( v0, v1, v2, v3 ) \
+ do { \
+ tdfxVertex *_v_[4]; \
+ _v_[0] = VERT(v3); \
+ _v_[1] = VERT(v0); \
+ _v_[2] = VERT(v1); \
+ _v_[3] = VERT(v2); \
+ fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_);\
+ /*fxMesa->Glide.grDrawTriangle( VERT(v0), VERT(v1), VERT(v3) );*/\
+ /*fxMesa->Glide.grDrawTriangle( VERT(v1), VERT(v2), VERT(v3) );*/\
+ } while (0)
+
+#define INIT(x) tdfxRenderPrimitive( ctx, x )
+
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \
+ tdfxVertex *vertptr = fxMesa->verts; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ (void) elt;
+
+#define RESET_STIPPLE
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+
+/* Elts, no clipping.
+ */
+#undef ELT
+#undef TAG
+#define TAG(x) tdfx_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl_dd/t_dd_rendertmp.h"
+
+/* Verts, no clipping.
+ */
+#undef ELT
+#undef TAG
+#define TAG(x) tdfx_##x##_verts
+#define ELT(x) x
+/*#include "tnl_dd/t_dd_rendertmp.h"*/
+
+
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+
+
+static void tdfxRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint prim = fxMesa->render_primitive;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+ }
+
+ /* Restore the render primitive
+ */
+ if (prim != GL_POLYGON)
+ tnl->Driver.Render.PrimitiveNotify( ctx, prim );
+}
+
+static void tdfxRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Line( ctx, ii, jj );
+}
+
+static void tdfxFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ int i;
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+ tdfxVertex *vertptr = fxMesa->verts;
+ if (n == 3) {
+ fxMesa->Glide.grDrawTriangle( VERT(elts[0]), VERT(elts[1]), VERT(elts[2]) );
+ } else if (n <= 32) {
+ tdfxVertex *newvptr[32];
+ for (i = 0 ; i < n ; i++) {
+ newvptr[i] = VERT(elts[i]);
+ }
+ fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, n, newvptr);
+ } else {
+ const tdfxVertex *start = VERT(elts[0]);
+ for (i = 2 ; i < n ; i++) {
+ fxMesa->Glide.grDrawTriangle( start, VERT(elts[i-1]), VERT(elts[i]) );
+ }
+ }
+}
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+
+#define POINT_FALLBACK (DD_POINT_SMOOTH)
+#define LINE_FALLBACK (DD_LINE_STIPPLE)
+#define TRI_FALLBACK (DD_TRI_SMOOTH)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK|DD_TRI_STIPPLE)
+#define ANY_RASTER_FLAGS (DD_FLATSHADE|DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET| \
+ DD_TRI_UNFILLED)
+
+
+/* All state referenced below:
+ */
+#define _TDFX_NEW_RENDERSTATE (_DD_NEW_POINT_SMOOTH | \
+ _DD_NEW_LINE_STIPPLE | \
+ _DD_NEW_TRI_SMOOTH | \
+ _DD_NEW_FLATSHADE | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET | \
+ _DD_NEW_TRI_STIPPLE | \
+ _NEW_POLYGONSTIPPLE)
+
+
+static void tdfxChooseRenderState(GLcontext *ctx)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ if (0) {
+ fxMesa->draw_point = tdfx_draw_point;
+ fxMesa->draw_line = tdfx_draw_line;
+ fxMesa->draw_triangle = tdfx_draw_triangle;
+ index |= TDFX_FALLBACK_BIT;
+ }
+
+ if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) {
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= TDFX_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= TDFX_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= TDFX_UNFILLED_BIT;
+ if (flags & DD_FLATSHADE) index |= TDFX_FLAT_BIT;
+ }
+
+ fxMesa->draw_point = tdfx_draw_point;
+ fxMesa->draw_line = tdfx_draw_line;
+ fxMesa->draw_triangle = tdfx_draw_triangle;
+
+ /* Hook in fallbacks for specific primitives.
+ *
+ * DD_TRI_UNFILLED is here because the unfilled_tri functions use
+ * fxMesa->draw_tri *always*, and thus can't use the multipass
+ * approach to cliprects.
+ *
+ */
+ if (flags & (POINT_FALLBACK|
+ LINE_FALLBACK|
+ TRI_FALLBACK|
+ DD_TRI_STIPPLE|
+ DD_TRI_UNFILLED))
+ {
+ if (flags & POINT_FALLBACK)
+ fxMesa->draw_point = tdfx_fallback_point;
+
+ if (flags & LINE_FALLBACK)
+ fxMesa->draw_line = tdfx_fallback_line;
+
+ if (flags & TRI_FALLBACK)
+ fxMesa->draw_triangle = tdfx_fallback_tri;
+
+ if ((flags & DD_TRI_STIPPLE) && !fxMesa->haveHwStipple)
+ fxMesa->draw_triangle = tdfx_fallback_tri;
+
+ index |= TDFX_FALLBACK_BIT;
+ }
+ }
+
+ if (fxMesa->RenderIndex != index) {
+ fxMesa->RenderIndex = index;
+
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = tdfx_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = tdfx_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */
+ tnl->Driver.Render.ClippedPolygon = tdfxFastRenderClippedPoly;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = tdfxRenderClippedLine;
+ tnl->Driver.Render.ClippedPolygon = tdfxRenderClippedPoly;
+ }
+ }
+}
+
+/**********************************************************************/
+/* Use multipass rendering for cliprects */
+/**********************************************************************/
+
+
+
+/* TODO: Benchmark this.
+ * TODO: Use single back-buffer cliprect where possible.
+ * NOTE: <pass> starts at 1, not zero!
+ */
+static GLboolean multipass_cliprect( GLcontext *ctx, GLuint pass )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ if (pass >= fxMesa->numClipRects)
+ return GL_FALSE;
+ else {
+ fxMesa->Glide.grClipWindow(fxMesa->pClipRects[pass].x1,
+ fxMesa->screen_height - fxMesa->pClipRects[pass].y2,
+ fxMesa->pClipRects[pass].x2,
+ fxMesa->screen_height - fxMesa->pClipRects[pass].y1);
+
+ return GL_TRUE;
+ }
+}
+
+
+/**********************************************************************/
+/* Runtime render state and callbacks */
+/**********************************************************************/
+
+static void tdfxRunPipeline( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ if (fxMesa->new_state) {
+ tdfxDDUpdateHwState( ctx );
+ }
+
+ if (!fxMesa->Fallback && fxMesa->new_gl_state) {
+ if (fxMesa->new_gl_state & _TDFX_NEW_RASTERSETUP)
+ tdfxChooseVertexState( ctx );
+
+ if (fxMesa->new_gl_state & _TDFX_NEW_RENDERSTATE)
+ tdfxChooseRenderState( ctx );
+
+ fxMesa->new_gl_state = 0;
+ }
+
+ _tnl_run_pipeline( ctx );
+}
+
+
+static void tdfxRenderStart( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ tdfxCheckTexSizes( ctx );
+
+ LOCK_HARDWARE(fxMesa);
+
+ /* Make sure vertex format changes get uploaded before we start
+ * sending triangles.
+ */
+ if (fxMesa->dirty) {
+ tdfxEmitHwStateLocked( fxMesa );
+ }
+
+ if (fxMesa->numClipRects && !(fxMesa->RenderIndex & TDFX_FALLBACK_BIT)) {
+ fxMesa->Glide.grClipWindow(fxMesa->pClipRects[0].x1,
+ fxMesa->screen_height - fxMesa->pClipRects[0].y2,
+ fxMesa->pClipRects[0].x2,
+ fxMesa->screen_height - fxMesa->pClipRects[0].y1);
+ if (fxMesa->numClipRects > 1)
+ tnl->Driver.Render.Multipass = multipass_cliprect;
+ else
+ tnl->Driver.Render.Multipass = NULL;
+ }
+ else
+ tnl->Driver.Render.Multipass = NULL;
+}
+
+
+
+/* Always called between RenderStart and RenderFinish --> We already
+ * hold the lock.
+ */
+static void tdfxRasterPrimitive( GLcontext *ctx, GLenum prim )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+
+ FLUSH_BATCH( fxMesa );
+
+ fxMesa->raster_primitive = prim;
+
+ tdfxUpdateCull(ctx);
+ if ( fxMesa->dirty & TDFX_UPLOAD_CULL ) {
+ fxMesa->Glide.grCullMode( fxMesa->CullMode );
+ fxMesa->dirty &= ~TDFX_UPLOAD_CULL;
+ }
+
+ tdfxUpdateStipple(ctx);
+ if ( fxMesa->dirty & TDFX_UPLOAD_STIPPLE ) {
+ fxMesa->Glide.grStipplePattern ( fxMesa->Stipple.Pattern );
+ fxMesa->Glide.grStippleMode ( fxMesa->Stipple.Mode );
+ fxMesa->dirty &= ~TDFX_UPLOAD_STIPPLE;
+ }
+}
+
+
+
+/* Determine the rasterized primitive when not drawing unfilled
+ * polygons.
+ *
+ * Used only for the default render stage which always decomposes
+ * primitives to trianges/lines/points. For the accelerated stage,
+ * which renders strips as strips, the equivalent calculations are
+ * performed in tdfx_render.c.
+ */
+static void tdfxRenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLuint rprim = reduced_prim[prim];
+
+ fxMesa->render_primitive = prim;
+
+ if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ return;
+
+ if (fxMesa->raster_primitive != rprim) {
+ tdfxRasterPrimitive( ctx, rprim );
+ }
+}
+
+static void tdfxRenderFinish( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+
+ if (fxMesa->RenderIndex & TDFX_FALLBACK_BIT)
+ _swrast_flush( ctx );
+
+ UNLOCK_HARDWARE(fxMesa);
+}
+
+
+/**********************************************************************/
+/* Manage total rasterization fallbacks */
+/**********************************************************************/
+
+static char *fallbackStrings[] = {
+ "3D/Rect/Cube Texture map",
+ "glDrawBuffer(GL_FRONT_AND_BACK)",
+ "Separate specular color",
+ "glEnable/Disable(GL_STENCIL_TEST)",
+ "glRenderMode(selection or feedback)",
+ "glLogicOp()",
+ "Texture env mode",
+ "Texture border",
+ "glColorMask",
+ "blend mode",
+ "line stipple",
+ "Rasterization disable"
+};
+
+
+static char *getFallbackString(GLuint bit)
+{
+ int i = 0;
+ while (bit > 1) {
+ i++;
+ bit >>= 1;
+ }
+ return fallbackStrings[i];
+}
+
+
+void tdfxFallback( GLcontext *ctx, GLuint bit, GLboolean mode )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLuint oldfallback = fxMesa->Fallback;
+
+ if (mode) {
+ fxMesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ /*printf("Go to software rendering, bit = 0x%x\n", bit);*/
+ FLUSH_BATCH(fxMesa);
+ _swsetup_Wakeup( ctx );
+ fxMesa->RenderIndex = ~0;
+ if (TDFX_DEBUG & DEBUG_VERBOSE_FALL) {
+ fprintf(stderr, "Tdfx begin software fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ }
+ }
+ else {
+ fxMesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ /*printf("Go to hardware rendering, bit = 0x%x\n", bit);*/
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = tdfxRenderStart;
+ tnl->Driver.Render.PrimitiveNotify = tdfxRenderPrimitive;
+ tnl->Driver.Render.Finish = tdfxRenderFinish;
+ tnl->Driver.Render.BuildVertices = tdfxBuildVertices;
+ fxMesa->new_gl_state |= (_TDFX_NEW_RENDERSTATE|
+ _TDFX_NEW_RASTERSETUP);
+ if (TDFX_DEBUG & DEBUG_VERBOSE_FALL) {
+ fprintf(stderr, "Tdfx end software fallback: 0x%x %s\n",
+ bit, getFallbackString(bit));
+ }
+ }
+ }
+}
+
+
+void tdfxDDInitTriFuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+ }
+
+ fxMesa->RenderIndex = ~0;
+
+ tnl->Driver.RunPipeline = tdfxRunPipeline;
+ tnl->Driver.Render.Start = tdfxRenderStart;
+ tnl->Driver.Render.Finish = tdfxRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = tdfxRenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = tdfxBuildVertices;
+ tnl->Driver.Render.Multipass = NULL;
+
+ (void) tdfx_print_vertex;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.h
new file mode 100644
index 000000000..57e5d9b0a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_tris.h
@@ -0,0 +1,42 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, 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
+ * VA LINUX SYSTEMS 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 <keith@tungstengraphics.com>
+ *
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.h,v 1.5 2002/10/30 12:52:01 alanh Exp $ */
+
+#ifndef TDFX_TRIS_INC
+#define TDFX_TRIS_INC
+
+#include "mtypes.h"
+
+extern void tdfxDDInitTriFuncs( GLcontext *ctx );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.c
new file mode 100644
index 000000000..0580135d1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.c
@@ -0,0 +1,353 @@
+/*
+ * GLX Hardware Device Driver for Intel i810
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * 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
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_vb.c,v 1.3 2002/10/30 12:52:01 alanh Exp $ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "imports.h"
+#include "macros.h"
+#include "colormac.h"
+
+#include "math/m_translate.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "tdfx_context.h"
+#include "tdfx_vb.h"
+#include "tdfx_tris.h"
+#include "tdfx_state.h"
+#include "tdfx_render.h"
+
+static void copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+ tdfxVertex *dst = fxMesa->verts + edst;
+ tdfxVertex *src = fxMesa->verts + esrc;
+ *(GLuint *)&dst->color = *(GLuint *)&src->color;
+}
+
+static struct {
+ void (*emit)( GLcontext *, GLuint, GLuint, void * );
+ tnl_interp_func interp;
+ tnl_copy_pv_func copy_pv;
+ GLboolean (*check_tex_sizes)( GLcontext *ctx );
+ GLuint vertex_format;
+} setup_tab[TDFX_MAX_SETUP];
+
+
+
+
+#define GET_COLOR(ptr, idx) ((ptr)->data[idx])
+
+
+static void interp_extras( GLcontext *ctx,
+ GLfloat t,
+ GLuint dst, GLuint out, GLuint in,
+ GLboolean force_boundary )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ /*fprintf(stderr, "%s\n", __FUNCTION__);*/
+
+ if (VB->ColorPtr[1]) {
+ INTERP_4F( t,
+ GET_COLOR(VB->ColorPtr[1], dst),
+ GET_COLOR(VB->ColorPtr[1], out),
+ GET_COLOR(VB->ColorPtr[1], in) );
+ }
+
+ if (VB->EdgeFlag) {
+ VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
+ }
+
+ setup_tab[TDFX_CONTEXT(ctx)->SetupIndex].interp(ctx, t, dst, out, in,
+ force_boundary);
+}
+
+static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ if (VB->ColorPtr[1]) {
+ COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst),
+ GET_COLOR(VB->ColorPtr[1], src) );
+ }
+
+ setup_tab[TDFX_CONTEXT(ctx)->SetupIndex].copy_pv(ctx, dst, src);
+}
+
+
+
+#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT)
+#define TAG(x) x##_wg
+#include "tdfx_vbtmp.h"
+
+/* Special for tdfx: fog requires w
+ */
+#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT)
+#define TAG(x) x##_wg_fog
+#include "tdfx_vbtmp.h"
+
+#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT)
+#define TAG(x) x##_wgt0
+#include "tdfx_vbtmp.h"
+
+#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT)
+#define TAG(x) x##_wgt0t1
+#include "tdfx_vbtmp.h"
+
+#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_PTEX_BIT)
+#define TAG(x) x##_wgpt0
+#include "tdfx_vbtmp.h"
+
+#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT|\
+ TDFX_PTEX_BIT)
+#define TAG(x) x##_wgpt0t1
+#include "tdfx_vbtmp.h"
+
+#define IND (TDFX_RGBA_BIT)
+#define TAG(x) x##_g
+#include "tdfx_vbtmp.h"
+
+#define IND (TDFX_TEX0_BIT)
+#define TAG(x) x##_t0
+#include "tdfx_vbtmp.h"
+
+#define IND (TDFX_TEX0_BIT|TDFX_TEX1_BIT)
+#define TAG(x) x##_t0t1
+#include "tdfx_vbtmp.h"
+
+#define IND (TDFX_RGBA_BIT|TDFX_TEX0_BIT)
+#define TAG(x) x##_gt0
+#include "tdfx_vbtmp.h"
+
+#define IND (TDFX_RGBA_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT)
+#define TAG(x) x##_gt0t1
+#include "tdfx_vbtmp.h"
+
+
+/* fogc { */
+#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_FOGC_BIT)
+#define TAG(x) x##_wgf
+#include "tdfx_vbtmp.h"
+
+#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_FOGC_BIT)
+#define TAG(x) x##_wgt0f
+#include "tdfx_vbtmp.h"
+
+#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT|TDFX_FOGC_BIT)
+#define TAG(x) x##_wgt0t1f
+#include "tdfx_vbtmp.h"
+
+#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_PTEX_BIT|TDFX_FOGC_BIT)
+#define TAG(x) x##_wgpt0f
+#include "tdfx_vbtmp.h"
+
+#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT|\
+ TDFX_PTEX_BIT|TDFX_FOGC_BIT)
+#define TAG(x) x##_wgpt0t1f
+#include "tdfx_vbtmp.h"
+/* fogc } */
+
+
+static void init_setup_tab( void )
+{
+ init_wg();
+ init_wg_fog();
+ init_wgt0();
+ init_wgt0t1();
+ init_wgpt0();
+ init_wgpt0t1();
+
+ init_g();
+ init_t0();
+ init_t0t1();
+ init_gt0();
+ init_gt0t1();
+
+ /* fogcoord */
+ init_wgf();
+ init_wgt0f();
+ init_wgt0t1f();
+ init_wgpt0f();
+ init_wgpt0t1f();
+}
+
+
+void tdfxPrintSetupFlags(char *msg, GLuint flags )
+{
+ fprintf(stderr, "%s(%x): %s%s%s%s%s%s\n",
+ msg,
+ (int)flags,
+ (flags & TDFX_XYZ_BIT) ? " xyz," : "",
+ (flags & TDFX_W_BIT) ? " w," : "",
+ (flags & TDFX_RGBA_BIT) ? " rgba," : "",
+ (flags & TDFX_TEX0_BIT) ? " tex-0," : "",
+ (flags & TDFX_TEX1_BIT) ? " tex-1," : "",
+ (flags & TDFX_FOGC_BIT) ? " fogc," : "");
+}
+
+
+
+void tdfxCheckTexSizes( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+
+ if (!setup_tab[fxMesa->SetupIndex].check_tex_sizes(ctx)) {
+ GLuint ind = fxMesa->SetupIndex |= (TDFX_PTEX_BIT|TDFX_RGBA_BIT);
+
+ /* Tdfx handles projective textures nicely; just have to change
+ * up to the new vertex format.
+ */
+ if (setup_tab[ind].vertex_format != fxMesa->vertexFormat) {
+ FLUSH_BATCH(fxMesa);
+ fxMesa->dirty |= TDFX_UPLOAD_VERTEX_LAYOUT;
+ fxMesa->vertexFormat = setup_tab[ind].vertex_format;
+
+ /* This is required as we have just changed the vertex
+ * format, so the interp and copy routines must also change.
+ * In the unfilled and twosided cases we are using the
+ * swrast_setup ones anyway, so leave them in place.
+ */
+ if (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ tnl->Driver.Render.Interp = setup_tab[fxMesa->SetupIndex].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[fxMesa->SetupIndex].copy_pv;
+ }
+ }
+ }
+}
+
+
+void tdfxBuildVertices( GLcontext *ctx, GLuint start, GLuint end,
+ GLuint newinputs )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+ tdfxVertex *v = fxMesa->verts + start;
+
+ newinputs |= fxMesa->SetupNewInputs;
+ fxMesa->SetupNewInputs = 0;
+
+ if (!newinputs)
+ return;
+
+ if (newinputs & VERT_BIT_POS) {
+ setup_tab[fxMesa->SetupIndex].emit( ctx, start, end, v );
+ } else {
+ GLuint ind = 0;
+
+ if (newinputs & VERT_BIT_COLOR0)
+ ind |= TDFX_RGBA_BIT;
+
+ if (newinputs & VERT_BIT_FOG)
+ ind |= TDFX_FOGC_BIT;
+
+ if (newinputs & VERT_BIT_TEX0)
+ ind |= TDFX_TEX0_BIT;
+
+ if (newinputs & VERT_BIT_TEX1)
+ ind |= TDFX_TEX0_BIT|TDFX_TEX1_BIT;
+
+ if (fxMesa->SetupIndex & TDFX_PTEX_BIT)
+ ind = ~0;
+
+ ind &= fxMesa->SetupIndex;
+
+ if (ind) {
+ setup_tab[ind].emit( ctx, start, end, v );
+ }
+ }
+}
+
+
+void tdfxChooseVertexState( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+ GLuint ind = TDFX_XYZ_BIT|TDFX_RGBA_BIT;
+
+ fxMesa->tmu_source[0] = 0;
+ fxMesa->tmu_source[1] = 1;
+
+ if (ctx->Texture._EnabledUnits & 0x2) {
+ if (ctx->Texture._EnabledUnits & 0x1) {
+ ind |= TDFX_TEX1_BIT;
+ }
+ ind |= TDFX_W_BIT|TDFX_TEX0_BIT;
+ fxMesa->tmu_source[0] = 1;
+ fxMesa->tmu_source[1] = 0;
+ } else if (ctx->Texture._EnabledUnits & 0x1) {
+ /* unit 0 enabled */
+ ind |= TDFX_W_BIT|TDFX_TEX0_BIT;
+ } else if (fxMesa->Fog.Mode != GR_FOG_DISABLE) {
+ ind |= TDFX_W_BIT;
+ }
+
+ if (fxMesa->Fog.Mode == GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT) {
+ ind |= TDFX_FOGC_BIT;
+ }
+
+ fxMesa->SetupIndex = ind;
+
+ if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
+ tnl->Driver.Render.Interp = interp_extras;
+ tnl->Driver.Render.CopyPV = copy_pv_extras;
+ } else {
+ tnl->Driver.Render.Interp = setup_tab[ind].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
+ }
+
+ if (setup_tab[ind].vertex_format != fxMesa->vertexFormat) {
+ FLUSH_BATCH(fxMesa);
+ fxMesa->dirty |= TDFX_UPLOAD_VERTEX_LAYOUT;
+ fxMesa->vertexFormat = setup_tab[ind].vertex_format;
+ }
+}
+
+
+
+void tdfxInitVB( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ GLuint size = TNL_CONTEXT(ctx)->vb.Size;
+ static int firsttime = 1;
+ if (firsttime) {
+ init_setup_tab();
+ firsttime = 0;
+ }
+
+ fxMesa->verts = ALIGN_MALLOC(size * sizeof(tdfxVertex), 32);
+ fxMesa->vertexFormat = TDFX_LAYOUT_TINY;
+ fxMesa->SetupIndex = TDFX_XYZ_BIT|TDFX_RGBA_BIT;
+}
+
+
+void tdfxFreeVB( GLcontext *ctx )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ if (fxMesa->verts) {
+ ALIGN_FREE(fxMesa->verts);
+ fxMesa->verts = 0;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.h
new file mode 100644
index 000000000..7b7cd9065
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vb.h
@@ -0,0 +1,69 @@
+/*
+ * GLX Hardware Device Driver for Intel tdfx
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * 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
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ *
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_vb.h,v 1.2 2002/02/22 21:45:04 dawes Exp $ */
+
+#ifndef TDFXVB_INC
+#define TDFXVB_INC
+
+#include "mtypes.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "math/m_xform.h"
+
+#define TDFX_XYZ_BIT 0x1
+#define TDFX_W_BIT 0x2
+#define TDFX_RGBA_BIT 0x4
+#define TDFX_TEX1_BIT 0x8
+#define TDFX_TEX0_BIT 0x10
+#define TDFX_PTEX_BIT 0x20
+#define TDFX_FOGC_BIT 0x40
+#define TDFX_MAX_SETUP 0x80
+
+#define _TDFX_NEW_RASTERSETUP (_NEW_TEXTURE | \
+ _DD_NEW_SEPARATE_SPECULAR | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _NEW_FOG)
+
+
+extern void tdfxValidateBuildProjVerts(GLcontext *ctx,
+ GLuint start, GLuint count,
+ GLuint newinputs );
+
+extern void tdfxPrintSetupFlags(char *msg, GLuint flags );
+
+extern void tdfxInitVB( GLcontext *ctx );
+
+extern void tdfxFreeVB( GLcontext *ctx );
+
+extern void tdfxCheckTexSizes( GLcontext *ctx );
+
+extern void tdfxChooseVertexState( GLcontext *ctx );
+
+extern void tdfxBuildVertices( GLcontext *ctx, GLuint start, GLuint end,
+ GLuint newinputs );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h
new file mode 100644
index 000000000..9b780761f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h
@@ -0,0 +1,266 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 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.
+ */
+
+/* Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Daniel Borca <dborca@users.sourceforge.net>
+ */
+
+
+#define VIEWPORT_X(dst,x) dst = s[0] * x + s[12]
+#define VIEWPORT_Y(dst,y) dst = s[5] * y + s[13]
+#define VIEWPORT_Z(dst,z) dst = s[10] * z + s[14]
+
+
+static void TAG(emit)( GLcontext *ctx,
+ GLuint start, GLuint end,
+ void *dest )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLuint tmu0_source = fxMesa->tmu_source[0];
+ GLuint tmu1_source = fxMesa->tmu_source[1];
+ GLfloat (*tc0)[4], (*tc1)[4];
+ GLfloat (*col)[4];
+ GLuint tc0_stride, tc1_stride, col_stride;
+ GLuint tc0_size, tc1_size, col_size;
+ GLfloat (*proj)[4] = VB->NdcPtr->data;
+ GLuint proj_stride = VB->NdcPtr->stride;
+ GLfloat (*fog)[4];
+ GLuint fog_stride;
+ tdfxVertex *v = (tdfxVertex *)dest;
+ GLfloat u0scale,v0scale,u1scale,v1scale;
+ const GLubyte *mask = VB->ClipMask;
+ const GLfloat *s = fxMesa->hw_viewport;
+ int i;
+
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ if (IND & TDFX_TEX0_BIT) {
+ tc0_stride = VB->TexCoordPtr[tmu0_source]->stride;
+ tc0 = VB->TexCoordPtr[tmu0_source]->data;
+ u0scale = fxMesa->sScale0;
+ v0scale = fxMesa->tScale0;
+ if (IND & TDFX_PTEX_BIT)
+ tc0_size = VB->TexCoordPtr[tmu0_source]->size;
+ }
+
+ if (IND & TDFX_TEX1_BIT) {
+ tc1 = VB->TexCoordPtr[tmu1_source]->data;
+ tc1_stride = VB->TexCoordPtr[tmu1_source]->stride;
+ u1scale = fxMesa->sScale1;
+ v1scale = fxMesa->tScale1;
+ if (IND & TDFX_PTEX_BIT)
+ tc1_size = VB->TexCoordPtr[tmu1_source]->size;
+ }
+
+ if (IND & TDFX_RGBA_BIT) {
+ col = VB->ColorPtr[0]->data;
+ col_stride = VB->ColorPtr[0]->stride;
+ col_size = VB->ColorPtr[0]->size;
+ }
+
+ if (IND & TDFX_FOGC_BIT) {
+ fog = VB->FogCoordPtr->data;
+ fog_stride = VB->FogCoordPtr->stride;
+ }
+
+ {
+ /* May have nonstandard strides:
+ */
+ if (start) {
+ proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_stride);
+ if (IND & TDFX_TEX0_BIT)
+ tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + start * tc0_stride);
+ if (IND & TDFX_TEX1_BIT)
+ tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride);
+ if (IND & TDFX_RGBA_BIT)
+ STRIDE_4F(col, start * col_stride);
+ if (IND & TDFX_FOGC_BIT)
+ STRIDE_4F(fog, start * fog_stride);
+ }
+
+ for (i=start; i < end; i++, v++) {
+ if (IND & TDFX_XYZ_BIT) {
+ if (mask[i] == 0) {
+ /* unclipped */
+ VIEWPORT_X(v->x, proj[0][0]);
+ VIEWPORT_Y(v->y, proj[0][1]);
+ VIEWPORT_Z(v->z, proj[0][2]);
+ v->rhw = proj[0][3];
+ } else {
+ /* clipped */
+ v->rhw = 1.0;
+ }
+ proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride);
+ }
+ if (IND & TDFX_RGBA_BIT) {
+ UNCLAMPED_FLOAT_TO_UBYTE(v->color[0], col[0][2]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v->color[1], col[0][1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v->color[2], col[0][0]);
+ if (col_size == 4) {
+ UNCLAMPED_FLOAT_TO_UBYTE(v->color[3], col[0][3]);
+ } else {
+ v->color[3] = 255;
+ }
+ STRIDE_4F(col, col_stride);
+ }
+ if (IND & TDFX_FOGC_BIT) {
+ v->fog = CLAMP(fog[0][0], 0.0f, 1.0f);
+ STRIDE_4F(fog, fog_stride);
+ }
+ if (IND & TDFX_TEX0_BIT) {
+ GLfloat w = v->rhw;
+ v->tu0 = tc0[0][0] * u0scale * w;
+ v->tv0 = tc0[0][1] * v0scale * w;
+ if (IND & TDFX_PTEX_BIT) {
+ v->tq0 = w;
+ if (tc0_size == 4)
+ v->tq0 = tc0[0][3] * w;
+ }
+ tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride);
+ }
+ if (IND & TDFX_TEX1_BIT) {
+ GLfloat w = v->rhw;
+ v->tu1 = tc1[0][0] * u1scale * w;
+ v->tv1 = tc1[0][1] * v1scale * w;
+ if (IND & TDFX_PTEX_BIT) {
+ v->tq1 = w;
+ if (tc1_size == 4)
+ v->tq1 = tc1[0][3] * w;
+ }
+ tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + tc1_stride);
+ }
+ }
+ }
+}
+
+
+static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
+{
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ if (IND & TDFX_PTEX_BIT)
+ return GL_TRUE;
+
+ if (IND & TDFX_TEX0_BIT) {
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ if (IND & TDFX_TEX1_BIT) {
+ if (VB->TexCoordPtr[0] == 0)
+ VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
+
+ if (VB->TexCoordPtr[1]->size == 4)
+ return GL_FALSE;
+ }
+
+ if (VB->TexCoordPtr[0]->size == 4)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+static void TAG(interp)( GLcontext *ctx,
+ GLfloat t,
+ GLuint edst, GLuint eout, GLuint ein,
+ GLboolean force_boundary )
+{
+ tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ const GLfloat *dstclip = VB->ClipPtr->data[edst];
+ const GLfloat oow = (dstclip[3] == 0.0F) ? 1.0F : (1.0F / dstclip[3]);
+ const GLfloat *s = fxMesa->hw_viewport;
+ tdfxVertex *dst = fxMesa->verts + edst;
+ const tdfxVertex *out = fxMesa->verts + eout;
+ const tdfxVertex *in = fxMesa->verts + ein;
+ const GLfloat wout = oow / out->rhw;
+ const GLfloat win = oow / in->rhw;
+
+ VIEWPORT_X(dst->x, dstclip[0] * oow);
+ VIEWPORT_Y(dst->y, dstclip[1] * oow);
+ VIEWPORT_Z(dst->z, dstclip[2] * oow);
+ dst->rhw = oow;
+
+ INTERP_UB( t, dst->color[0], out->color[0], in->color[0] );
+ INTERP_UB( t, dst->color[1], out->color[1], in->color[1] );
+ INTERP_UB( t, dst->color[2], out->color[2], in->color[2] );
+ INTERP_UB( t, dst->color[3], out->color[3], in->color[3] );
+
+ if (IND & TDFX_FOGC_BIT) {
+ INTERP_F( t, dst->fog, out->fog, in->fog );
+ }
+
+ if (IND & TDFX_TEX0_BIT) {
+ INTERP_F( t, dst->tu0, out->tu0 * wout, in->tu0 * win );
+ INTERP_F( t, dst->tv0, out->tv0 * wout, in->tv0 * win );
+ if (IND & TDFX_PTEX_BIT) {
+ INTERP_F( t, dst->tq0, out->tq0 * wout, in->tq0 * win );
+ }
+ }
+ if (IND & TDFX_TEX1_BIT) {
+ INTERP_F( t, dst->tu1, out->tu1 * wout, in->tu1 * win );
+ INTERP_F( t, dst->tv1, out->tv1 * wout, in->tv1 * win );
+ if (IND & TDFX_PTEX_BIT) {
+ INTERP_F( t, dst->tq1, out->tq1 * wout, in->tq1 * win );
+ }
+ }
+}
+
+
+static void TAG(init)( void )
+{
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ setup_tab[IND].emit = TAG(emit);
+ setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes);
+ setup_tab[IND].interp = TAG(interp);
+ setup_tab[IND].copy_pv = copy_pv;
+
+ if (IND & TDFX_TEX1_BIT) {
+ if (IND & TDFX_PTEX_BIT) {
+ setup_tab[IND].vertex_format = TDFX_LAYOUT_PROJ2;
+ }
+ else {
+ setup_tab[IND].vertex_format = TDFX_LAYOUT_MULTI;
+ }
+ }
+ else if (IND & TDFX_TEX0_BIT) {
+ if (IND & TDFX_PTEX_BIT) {
+ setup_tab[IND].vertex_format = TDFX_LAYOUT_PROJ1;
+ } else {
+ setup_tab[IND].vertex_format = TDFX_LAYOUT_SINGLE;
+ }
+ }
+ else if (IND & TDFX_W_BIT) {
+ setup_tab[IND].vertex_format = TDFX_LAYOUT_NOTEX;
+ } else {
+ setup_tab[IND].vertex_format = TDFX_LAYOUT_TINY;
+ }
+}
+
+
+#undef IND
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/Makefile
new file mode 100644
index 000000000..9ee24c504
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/Makefile
@@ -0,0 +1,26 @@
+# src/mesa/drivers/dri/trident/Makefile
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = trident_dri.so
+
+# Not yet
+# MINIGLX_SOURCES = server/trident_dri.c
+
+DRIVER_SOURCES = \
+ trident_context.c \
+ trident_state.c \
+ trident_vb.c \
+ trident_dd.c \
+ trident_tris.c
+
+C_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+include ../Makefile.template
+
+symlinks:
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_context.c
new file mode 100644
index 000000000..b44c6205c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_context.c
@@ -0,0 +1,472 @@
+/*
+ * Copyright 2002 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>
+ *
+ * Trident CyberBladeXP driver.
+ *
+ */
+#include "trident_dri.h"
+#include "trident_context.h"
+#include "trident_lock.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_pipeline.h"
+
+#include "context.h"
+#include "simple_list.h"
+#include "matrix.h"
+#include "extensions.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+#if defined(USE_X86_ASM)
+#include "x86/common_x86_asm.h"
+#endif
+#include "simple_list.h"
+#include "mm.h"
+#include "drirenderbuffer.h"
+
+#include "drivers/common/driverfuncs.h"
+#include "dri_util.h"
+
+static const struct tnl_pipeline_stage *trident_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ &_tnl_render_stage,
+ 0,
+};
+
+
+GLboolean tridentCreateContext( const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate)
+{
+ GLcontext *ctx, *shareCtx;
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ tridentContextPtr tmesa;
+ tridentScreenPtr tridentscrn;
+ struct dd_function_table functions;
+#if 0
+ drm_trident_sarea_t *saPriv=(drm_trident_sarea_t *)(((char*)sPriv->pSAREA)+
+ sizeof(XF86DRISAREARec));
+#endif
+
+ tmesa = (tridentContextPtr) CALLOC( sizeof(*tmesa) );
+ if ( !tmesa ) return GL_FALSE;
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((tridentContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+
+ _mesa_init_driver_functions(&functions);
+
+ tmesa->glCtx =
+ _mesa_create_context(glVisual, shareCtx, &functions, (void *)tmesa);
+
+ if (!tmesa->glCtx) {
+ FREE(tmesa);
+ return GL_FALSE;
+ }
+
+ tmesa->driContext = driContextPriv;
+ tmesa->driScreen = sPriv;
+ tmesa->driDrawable = NULL; /* Set by XMesaMakeCurrent */
+
+ tmesa->hHWContext = driContextPriv->hHWContext;
+ tmesa->driHwLock = (drmLock *)&sPriv->pSAREA->lock;
+ tmesa->driFd = sPriv->fd;
+#if 0
+ tmesa->sarea = saPriv;
+#endif
+
+ tridentscrn = tmesa->tridentScreen = (tridentScreenPtr)(sPriv->private);
+
+ ctx = tmesa->glCtx;
+
+ ctx->Const.MaxTextureLevels = 13; /* 4K by 4K? Is that right? */
+ ctx->Const.MaxTextureUnits = 1; /* Permedia 3 */
+
+ ctx->Const.MinLineWidth = 0.0;
+ ctx->Const.MaxLineWidth = 255.0;
+
+ ctx->Const.MinLineWidthAA = 0.0;
+ ctx->Const.MaxLineWidthAA = 65536.0;
+
+ ctx->Const.MinPointSize = 0.0;
+ ctx->Const.MaxPointSize = 255.0;
+
+ ctx->Const.MinPointSizeAA = 0.5; /* 4x4 quality mode */
+ ctx->Const.MaxPointSizeAA = 16.0;
+ ctx->Const.PointSizeGranularity = 0.25;
+
+#if 0
+ tmesa->texHeap = mmInit( 0, tmesa->tridentScreen->textureSize );
+
+ make_empty_list(&tmesa->TexObjList);
+ make_empty_list(&tmesa->SwappedOut);
+
+ tmesa->CurrentTexObj[0] = 0;
+ tmesa->CurrentTexObj[1] = 0; /* Permedia 3, second texture */
+
+ tmesa->RenderIndex = ~0;
+#endif
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext( ctx );
+ _ac_CreateContext( ctx );
+ _tnl_CreateContext( ctx );
+ _swsetup_CreateContext( ctx );
+
+ /* Install the customized pipeline:
+ */
+ _tnl_destroy_pipeline( ctx );
+ _tnl_install_pipeline( ctx, trident_pipeline );
+
+ /* Configure swrast to match hardware characteristics:
+ */
+ _swrast_allow_pixel_fog( ctx, GL_FALSE );
+ _swrast_allow_vertex_fog( ctx, GL_TRUE );
+
+ tridentInitVB( ctx );
+ tridentDDInitExtensions( ctx );
+ tridentDDInitDriverFuncs( ctx );
+ tridentDDInitStateFuncs( ctx );
+#if 0
+ tridentDDInitSpanFuncs( ctx );
+ tridentDDInitTextureFuncs( ctx );
+#endif
+ tridentDDInitTriFuncs( ctx );
+ tridentDDInitState( tmesa );
+
+ driContextPriv->driverPrivate = (void *)tmesa;
+
+ UNLOCK_HARDWARE(tmesa);
+
+ return GL_TRUE;
+}
+
+static void
+tridentDestroyContext(__DRIcontextPrivate *driContextPriv)
+{
+ tridentContextPtr tmesa = (tridentContextPtr)driContextPriv->driverPrivate;
+
+ if (tmesa) {
+ _swsetup_DestroyContext( tmesa->glCtx );
+ _tnl_DestroyContext( tmesa->glCtx );
+ _ac_DestroyContext( tmesa->glCtx );
+ _swrast_DestroyContext( tmesa->glCtx );
+
+ /* free the Mesa context */
+ tmesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(tmesa->glCtx);
+
+ _mesa_free(tmesa);
+ driContextPriv->driverPrivate = NULL;
+ }
+}
+
+
+static GLboolean
+tridentCreateBuffer( __DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap )
+{
+ tridentScreenPtr screen = (tridentScreenPtr) driScrnPriv->private;
+
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+#if 0
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ mesaVis->alphaBits > 0
+ );
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->frontOffset, screen->frontPitch);
+ /*
+ tridentSetSpanFunctions(frontRb, mesaVis);
+ */
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->cpp,
+ screen->backOffset, screen->backPitch);
+ /*
+ tridentSetSpanFunctions(backRb, mesaVis);
+ */
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ /*
+ tridentSetSpanFunctions(depthRb, mesaVis);
+ */
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->cpp,
+ screen->depthOffset, screen->depthPitch);
+ /*
+ tridentSetSpanFunctions(depthRb, mesaVis);
+ */
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ /* no h/w stencil?
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT);
+ tridentSetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+ */
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ mesaVis->stencilBits > 0,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+
+static void
+tridentDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+}
+
+static void
+tridentSwapBuffers(__DRIdrawablePrivate *drawablePrivate)
+{
+ __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
+
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ tridentContextPtr tmesa;
+ GLcontext *ctx;
+ tmesa = (tridentContextPtr) dPriv->driContextPriv->driverPrivate;
+ ctx = tmesa->glCtx;
+ if (ctx->Visual.doubleBufferMode) {
+ _mesa_notifySwapBuffers( ctx ); /* flush pending rendering comands */
+ tridentCopyBuffer( dPriv );
+ }
+ }
+ else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ _mesa_problem(NULL, "tridentSwapBuffers: drawable has no context!\n");
+ }
+}
+
+static GLboolean
+tridentMakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
+{
+ if (driContextPriv) {
+ GET_CURRENT_CONTEXT(ctx);
+ tridentContextPtr oldCtx = ctx ? TRIDENT_CONTEXT(ctx) : NULL;
+ tridentContextPtr newCtx = (tridentContextPtr) driContextPriv->driverPrivate;
+
+ if ( newCtx != oldCtx ) {
+ newCtx->dirty = ~0;
+ }
+
+ if (newCtx->driDrawable != driDrawPriv) {
+ newCtx->driDrawable = driDrawPriv;
+#if 0
+ tridentUpdateWindow ( newCtx->glCtx );
+ tridentUpdateViewportOffset( newCtx->glCtx );
+#endif
+ }
+
+ newCtx->drawOffset = newCtx->tridentScreen->backOffset;
+ newCtx->drawPitch = newCtx->tridentScreen->backPitch;
+
+ _mesa_make_current( newCtx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate );
+
+ if (!newCtx->glCtx->Viewport.Width) {
+ _mesa_set_viewport(newCtx->glCtx, 0, 0,
+ driDrawPriv->w, driDrawPriv->h);
+ }
+ } else {
+ _mesa_make_current( NULL, NULL, NULL );
+ }
+ return GL_TRUE;
+}
+
+
+static GLboolean
+tridentUnbindContext( __DRIcontextPrivate *driContextPriv )
+{
+ return GL_TRUE;
+}
+
+
+tridentScreenPtr tridentCreateScreen( __DRIscreenPrivate *sPriv )
+{
+ TRIDENTDRIPtr tDRIPriv = (TRIDENTDRIPtr)sPriv->pDevPriv;
+ tridentScreenPtr tridentScreen;
+
+ if (sPriv->devPrivSize != sizeof(TRIDENTDRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(TRIDENTDRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
+
+ /* Allocate the private area */
+ tridentScreen = (tridentScreenPtr) CALLOC( sizeof(*tridentScreen) );
+ if ( !tridentScreen ) return NULL;
+
+ tridentScreen->driScreen = sPriv;
+
+ tridentScreen->frontOffset = tDRIPriv->frontOffset;
+ tridentScreen->backOffset = tDRIPriv->backOffset;
+ tridentScreen->depthOffset = tDRIPriv->depthOffset;
+ tridentScreen->frontPitch = tDRIPriv->frontPitch;
+ tridentScreen->backPitch = tDRIPriv->backPitch;
+ tridentScreen->depthPitch = tDRIPriv->depthPitch;
+ tridentScreen->width = tDRIPriv->width;
+ tridentScreen->height = tDRIPriv->height;
+
+printf("%d %d\n",tridentScreen->width,tridentScreen->height);
+printf("%d %d\n",tridentScreen->frontPitch,tridentScreen->backPitch);
+printf("offset 0x%x 0x%x\n",tridentScreen->backOffset,tridentScreen->depthOffset);
+
+ tridentScreen->mmio.handle = tDRIPriv->regs;
+ tridentScreen->mmio.size = 0x20000;
+
+ if (drmMap(sPriv->fd,
+ tridentScreen->mmio.handle, tridentScreen->mmio.size,
+ (drmAddressPtr)&tridentScreen->mmio.map)) {
+ FREE(tridentScreen);
+ return GL_FALSE;
+ }
+printf("MAPPED at %p\n", tridentScreen->mmio.map);
+
+ return tridentScreen;
+}
+
+/* Destroy the device specific screen private data struct.
+ */
+void tridentDestroyScreen( __DRIscreenPrivate *sPriv )
+{
+ tridentScreenPtr tridentScreen = (tridentScreenPtr)sPriv->private;
+
+ FREE(tridentScreen);
+}
+static GLboolean
+tridentInitDriver(__DRIscreenPrivate *sPriv)
+{
+ sPriv->private = (void *) tridentCreateScreen( sPriv );
+
+ if (!sPriv->private) {
+ tridentDestroyScreen( sPriv );
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+static struct __DriverAPIRec tridentAPI = {
+ tridentInitDriver,
+ tridentDestroyScreen,
+ tridentCreateContext,
+ tridentDestroyContext,
+ tridentCreateBuffer,
+ tridentDestroyBuffer,
+ tridentSwapBuffers,
+ tridentMakeCurrent,
+ tridentUnbindContext,
+};
+
+
+PUBLIC void *__driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn,
+ __DRIscreen *psc,
+ const __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drmAddress pSAREA, int fd,
+ int internal_api_version,
+ const __DRIinterfaceMethods * interface,
+ __GLcontextModes ** driver_modes )
+{
+ __DRIscreenPrivate *psp;
+ static const __DRIversion ddx_expected = { 4, 0, 0 };
+ static const __DRIversion dri_expected = { 3, 1, 0 };
+ static const __DRIversion drm_expected = { 1, 0, 0 };
+
+ dri_interface = interface;
+
+ if ( ! driCheckDriDdxDrmVersions2( "Trident",
+ dri_version, & dri_expected,
+ ddx_version, & ddx_expected,
+ drm_version, & drm_expected ) ) {
+ return NULL;
+ }
+
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &tridentAPI);
+
+ if ( psp != NULL ) {
+#if 0
+ TRIDENTDRIPtr dri_priv = (TRIDENTDRIPtr) psp->pDevPriv;
+ *driver_modes = tridentFillInModes( dri_priv->bytesPerPixel * 8,
+ GL_TRUE );
+#endif
+ }
+ return (void *) psp;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_context.h
new file mode 100644
index 000000000..7ebb5f204
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_context.h
@@ -0,0 +1,242 @@
+/*
+ * Copyright 2002 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>
+ *
+ * Trident CyberBladeXP driver.
+ *
+ */
+#ifndef _TRIDENT_CONTEXT_H_
+#define _TRIDENT_CONTEXT_H_
+
+#include "dri_util.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "drm.h"
+#include "mm.h"
+
+#define SUBPIXEL_X (0.0F)
+#define SUBPIXEL_Y (0.125F)
+
+#define _TRIDENT_NEW_VERTEX (_NEW_TEXTURE | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE)
+
+#define TRIDENT_FALLBACK_TEXTURE 0x01
+#define TRIDENT_FALLBACK_DRAW_BUFFER 0x02
+
+#define TRIDENT_NEW_CLIP 0x01
+
+#define TRIDENT_UPLOAD_COMMAND_D 0x00000001
+#define TRIDENT_UPLOAD_CONTEXT 0x04000000
+#define TRIDENT_UPLOAD_CLIPRECTS 0x80000000
+
+#define TAG(x) trident##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+/* these require that base be dword-aligned */
+static inline void MMIO_OUT32(unsigned char *base, unsigned int offset,
+ unsigned int val)
+{
+ unsigned int *addr = (unsigned int *)(base + offset);
+ *addr = val;
+}
+
+static inline unsigned int MMIO_IN32(unsigned char *base, unsigned int offset)
+{
+ unsigned int *addr = (unsigned int *)(base + offset);
+ return *addr;
+}
+
+#define MMIO_OUT8(base, offset, val) *((base) + (offset)) = (val)
+#define MMIO_IN8(base, offset) *((base) + (offset))
+
+struct trident_context;
+typedef struct trident_context tridentContextRec;
+typedef struct trident_context *tridentContextPtr;
+
+typedef void (*trident_quad_func)( tridentContextPtr,
+ const tridentVertex *,
+ const tridentVertex *,
+ const tridentVertex *,
+ const tridentVertex * );
+typedef void (*trident_tri_func)( tridentContextPtr,
+ const tridentVertex *,
+ const tridentVertex *,
+ const tridentVertex * );
+typedef void (*trident_line_func)( tridentContextPtr,
+ const tridentVertex *,
+ const tridentVertex * );
+typedef void (*trident_point_func)( tridentContextPtr,
+ const tridentVertex * );
+
+typedef struct {
+ drm_handle_t handle; /* Handle to the DRM region */
+ drmSize size; /* Size of the DRM region */
+ unsigned char *map; /* Mapping of the DRM region */
+} tridentRegionRec, *tridentRegionPtr;
+
+typedef struct {
+ __DRIscreenPrivate *driScreen; /* Back pointer to DRI screen */
+
+ drmBufMapPtr buffers;
+
+ unsigned int frontOffset;
+ unsigned int frontPitch;
+ unsigned int backOffset;
+ unsigned int backPitch;
+ unsigned int depthOffset;
+ unsigned int depthPitch;
+ unsigned int width;
+ unsigned int height;
+ unsigned int cpp;
+
+#if 0
+ unsigned int sarea_priv_offset;
+#endif
+
+ tridentRegionRec mmio;
+} tridentScreenRec, *tridentScreenPtr;
+
+/**
+ * tridentRenderbuffer, derived from Mesa's gl_renderbuffer
+ */
+typedef struct {
+ struct gl_renderbuffer Base;
+ /* XXX per-window info should go here */
+ int foo, bar;
+} tridentRenderbuffer;
+
+
+struct trident_context {
+ GLcontext *glCtx; /* Mesa context */
+
+ __DRIcontextPrivate *driContext;
+ __DRIscreenPrivate *driScreen;
+ __DRIdrawablePrivate *driDrawable;
+
+ GLuint new_gl_state;
+ GLuint new_state;
+ GLuint dirty;
+
+#if 0
+ drm_trident_sarea_t *sarea;
+#endif
+
+ /* Temporaries for translating away float colors:
+ */
+ struct gl_client_array UbyteColor;
+ struct gl_client_array UbyteSecondaryColor;
+
+ /* Mirrors of some DRI state
+ */
+ int lastStamp; /* mirror driDrawable->lastStamp */
+
+ drm_context_t hHWContext;
+ drmLock *driHwLock;
+ int driFd;
+
+ tridentScreenPtr tridentScreen; /* Screen private DRI data */
+
+ /* Visual, drawable, cliprect and scissor information
+ */
+ GLenum DrawBuffer;
+ GLint drawOffset, drawPitch;
+ GLint drawX, drawY; /* origin of drawable in draw buffer */
+ GLint readOffset, readPitch;
+
+ GLuint numClipRects; /* Cliprects for the draw buffer */
+ drm_clip_rect_t *pClipRects;
+
+ GLint scissor;
+ drm_clip_rect_t ScissorRect; /* Current software scissor */
+
+ GLuint Fallback;
+ GLuint RenderIndex;
+ GLuint SetupNewInputs;
+ GLuint SetupIndex;
+ GLfloat hw_viewport[16];
+ GLfloat depth_scale;
+ GLuint vertex_format;
+ GLuint vertex_size;
+ GLuint vertex_stride_shift;
+ char *verts;
+
+ GLint tmu_source[2];
+
+ GLuint hw_primitive;
+ GLenum render_primitive;
+
+ trident_point_func draw_point;
+ trident_line_func draw_line;
+ trident_tri_func draw_tri;
+ trident_quad_func draw_quad;
+
+#if 0
+ gammaTextureObjectPtr CurrentTexObj[2];
+ struct gamma_texture_object_t TexObjList;
+ struct gamma_texture_object_t SwappedOut;
+ GLenum TexEnvImageFmt[2];
+
+ memHeap_t *texHeap;
+
+ int lastSwap;
+ int texAge;
+ int ctxAge;
+ int dirtyAge;
+ int lastStamp;
+#endif
+
+ /* Chip state */
+
+ int commandD;
+
+ /* Context State */
+
+ int ClearColor;
+};
+
+void tridentDDInitExtensions( GLcontext *ctx );
+void tridentDDInitDriverFuncs( GLcontext *ctx );
+void tridentDDInitSpanFuncs( GLcontext *ctx );
+void tridentDDInitState( tridentContextPtr tmesa );
+void tridentInitHW( tridentContextPtr tmesa );
+void tridentDDInitStateFuncs( GLcontext *ctx );
+void tridentDDInitTextureFuncs( GLcontext *ctx );
+void tridentDDInitTriFuncs( GLcontext *ctx );
+
+extern void tridentBuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs );
+extern void tridentInitVB( GLcontext *ctx );
+extern void tridentCopyBuffer( const __DRIdrawablePrivate *dPriv );
+extern void tridentFallback( tridentContextPtr tmesa, GLuint bit,
+ GLboolean mode );
+extern void tridentCheckTexSizes( GLcontext *ctx );
+extern void tridentChooseVertexState( GLcontext *ctx );
+extern void tridentDDUpdateHWState( GLcontext *ctx );
+extern void tridentUploadHwStateLocked( tridentContextPtr tmesa );
+
+#define TRIDENT_CONTEXT(ctx) ((tridentContextPtr)(ctx->DriverCtx))
+
+#endif /* _TRIDENT_CONTEXT_H_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_dd.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_dd.c
new file mode 100644
index 000000000..8c3af2001
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_dd.c
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2002 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>
+ *
+ * Trident CyberBladeXP driver.
+ *
+ */
+#include "trident_context.h"
+#include "trident_lock.h"
+#if defined(USE_X86_ASM)
+#include "x86/common_x86_asm.h"
+#endif
+
+#include "swrast/swrast.h"
+#include "context.h"
+#include "framebuffer.h"
+
+#define TRIDENT_DATE "20041223"
+
+/* Return the width and height of the current color buffer.
+ */
+static void tridentDDGetBufferSize( GLframebuffer *framebuffer,
+ GLuint *width, GLuint *height )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+
+ LOCK_HARDWARE(tmesa);
+ *width = tmesa->driDrawable->w;
+ *height = tmesa->driDrawable->h;
+ UNLOCK_HARDWARE(tmesa);
+}
+
+
+/* Return various strings for glGetString().
+ */
+static const GLubyte *tridentDDGetString( GLcontext *ctx, GLenum name )
+{
+ static char buffer[128];
+
+ switch ( name ) {
+ case GL_VENDOR:
+ return (GLubyte *)"Alan Hourihane";
+
+ case GL_RENDERER:
+ sprintf( buffer, "Mesa DRI Trident " TRIDENT_DATE );
+
+ /* Append any CPU-specific information.
+ */
+#ifdef USE_X86_ASM
+ if ( _mesa_x86_cpu_features ) {
+ strncat( buffer, " x86", 4 );
+ }
+#ifdef USE_MMX_ASM
+ if ( cpu_has_mmx ) {
+ strncat( buffer, "/MMX", 4 );
+ }
+#endif
+#ifdef USE_3DNOW_ASM
+ if ( cpu_has_3dnow ) {
+ strncat( buffer, "/3DNow!", 7 );
+ }
+#endif
+#ifdef USE_SSE_ASM
+ if ( cpu_has_xmm ) {
+ strncat( buffer, "/SSE", 4 );
+ }
+#endif
+#endif
+ return (GLubyte *)buffer;
+
+ default:
+ return NULL;
+ }
+}
+
+/* Enable the extensions supported by this driver.
+ */
+void tridentDDInitExtensions( GLcontext *ctx )
+{
+ /* None... */
+}
+
+/* Initialize the driver's misc functions.
+ */
+void tridentDDInitDriverFuncs( GLcontext *ctx )
+{
+ ctx->Driver.GetBufferSize = tridentDDGetBufferSize;
+ ctx->Driver.GetString = tridentDDGetString;
+
+ ctx->Driver.Error = NULL;
+
+ /* Pixel path fallbacks
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.ResizeBuffers = _mesa_resize_framebuffer;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_dri.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_dri.h
new file mode 100644
index 000000000..c1ce3c468
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_dri.h
@@ -0,0 +1,28 @@
+#ifndef _TRIDENT_DRI_
+#define _TRIDENT_DRI_
+
+#include "xf86drm.h"
+
+typedef struct {
+ drm_handle_t regs;
+ drmSize regsSize;
+ drmAddress regsMap;
+ int deviceID;
+ int width;
+ int height;
+ int mem;
+ int frontOffset;
+ int frontPitch;
+ int backOffset;
+ int backPitch;
+ int depthOffset;
+ int depthPitch;
+ int cpp;
+#if 0
+ int textureOffset;
+ int textureSize;
+#endif
+ unsigned int sarea_priv_offset;
+} TRIDENTDRIRec, *TRIDENTDRIPtr;
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_lock.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_lock.h
new file mode 100644
index 000000000..ee0819f5c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_lock.h
@@ -0,0 +1,11 @@
+/* XXX tridentGetLock doesn't exist... */
+
+#define LOCK_HARDWARE(tmesa) \
+ do { \
+ char __ret = 0; \
+ DRM_CAS(tmesa->driHwLock, tmesa->hHWContext, \
+ DRM_LOCK_HELD | tmesa->hHWContext, __ret); \
+ } while (0)
+
+#define UNLOCK_HARDWARE(tmesa) \
+ DRM_UNLOCK(tmesa->driFd, tmesa->driHwLock, tmesa->hHWContext)
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_state.c
new file mode 100644
index 000000000..76b2a8ef3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_state.c
@@ -0,0 +1,555 @@
+/*
+ * Copyright 2002 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>
+ *
+ * Trident CyberBladeXP driver.
+ *
+ */
+#include "trident_context.h"
+#include "trident_lock.h"
+#include "array_cache/acache.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "framebuffer.h"
+
+#define TRIDENTPACKCOLOR332(r, g, b) \
+ (((r) & 0xe0) | (((g) & 0xe0) >> 3) | (((b) & 0xc0) >> 6))
+
+#define TRIDENTPACKCOLOR1555(r, g, b, a) \
+ ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
+ ((a) ? 0x8000 : 0))
+
+#define TRIDENTPACKCOLOR565(r, g, b) \
+ ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
+
+#define TRIDENTPACKCOLOR888(r, g, b) \
+ (((r) << 16) | ((g) << 8) | (b))
+
+#define TRIDENTPACKCOLOR8888(r, g, b, a) \
+ (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
+
+#define TRIDENTPACKCOLOR4444(r, g, b, a) \
+ ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
+
+static __inline__ GLuint tridentPackColor( GLuint cpp,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a )
+{
+ switch ( cpp ) {
+ case 2:
+ return TRIDENTPACKCOLOR565( r, g, b );
+ case 4:
+ return TRIDENTPACKCOLOR8888( r, g, b, a );
+ default:
+ return 0;
+ }
+}
+
+void tridentUploadHwStateLocked( tridentContextPtr tmesa )
+{
+ unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
+#if 0
+ ATISAREAPrivPtr sarea = tmesa->sarea;
+ trident_context_regs_t *regs = &(sarea->ContextState);
+#endif
+
+ if ( tmesa->dirty & TRIDENT_UPLOAD_COMMAND_D ) {
+ MMIO_OUT32(MMIO, 0x00281C, tmesa->commandD );
+ tmesa->dirty &= ~TRIDENT_UPLOAD_COMMAND_D;
+ }
+
+ if ( tmesa->dirty & TRIDENT_UPLOAD_CLIPRECTS ) {
+ /* XXX FIX ME ! */
+ MMIO_OUT32(MMIO, 0x002C80 , 0x20008000 | tmesa->tridentScreen->height );
+ MMIO_OUT32(MMIO, 0x002C84 , 0x20000000 | tmesa->tridentScreen->width );
+ tmesa->dirty &= ~TRIDENT_UPLOAD_CLIPRECTS;
+ }
+
+ tmesa->dirty = 0;
+}
+
+/* Copy the back color buffer to the front color buffer.
+ */
+void tridentCopyBuffer( const __DRIdrawablePrivate *dPriv )
+{
+ unsigned char *MMIO;
+ tridentContextPtr tmesa;
+ GLint nbox, i;
+ int busy;
+ drm_clip_rect_t *pbox;
+
+ assert(dPriv);
+ assert(dPriv->driContextPriv);
+ assert(dPriv->driContextPriv->driverPrivate);
+
+ tmesa = (tridentContextPtr) dPriv->driContextPriv->driverPrivate;
+ MMIO = tmesa->tridentScreen->mmio.map;
+
+ LOCK_HARDWARE( tmesa );
+
+ /* use front buffer cliprects */
+ nbox = dPriv->numClipRects;
+ pbox = dPriv->pClipRects;
+
+ for ( i = 0 ; i < nbox ; i++ ) {
+#if 0
+ GLint nr = MIN2( i + MACH64_NR_SAREA_CLIPRECTS , nbox );
+ drm_clip_rect_t *b = tmesa->sarea->boxes;
+ GLint n = 0;
+
+ for ( ; i < nr ; i++ ) {
+ *b++ = pbox[i];
+ n++;
+ }
+ tmesa->sarea->nbox = n;
+#endif
+
+ MMIO_OUT32(MMIO, 0x2150, tmesa->tridentScreen->frontPitch << 20 | tmesa->tridentScreen->frontOffset>>4);
+ MMIO_OUT32(MMIO, 0x2154, tmesa->tridentScreen->backPitch << 20 | tmesa->tridentScreen->backOffset>>4);
+ MMIO_OUT8(MMIO, 0x2127, 0xCC); /* Copy Rop */
+ MMIO_OUT32(MMIO, 0x2128, 0x4); /* scr2scr */
+ MMIO_OUT32(MMIO, 0x2138, (pbox->x1 << 16) | pbox->y1);
+ MMIO_OUT32(MMIO, 0x213C, (pbox->x1 << 16) | pbox->y1);
+ MMIO_OUT32(MMIO, 0x2140, (pbox->x2 - pbox->x1) << 16 | (pbox->y2 - pbox->y1) );
+ MMIO_OUT8(MMIO, 0x2124, 0x01); /* BLT */
+#define GE_BUSY 0x80
+ for (;;) {
+ busy = MMIO_IN8(MMIO, 0x2120);
+ if ( !(busy & GE_BUSY) )
+ break;
+ }
+ }
+
+ UNLOCK_HARDWARE( tmesa );
+
+#if 0
+ tmesa->dirty |= (MACH64_UPLOAD_CONTEXT |
+ MACH64_UPLOAD_MISC |
+ MACH64_UPLOAD_CLIPRECTS);
+#endif
+}
+
+
+static void tridentDDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch )
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+ unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
+ int busy;
+ GLuint flags = 0;
+ GLint i;
+
+#define DRM_TRIDENT_FRONT 0x01
+#define DRM_TRIDENT_BACK 0x02
+#define DRM_TRIDENT_DEPTH 0x04
+
+ if ( tmesa->new_state )
+ tridentDDUpdateHWState( ctx );
+
+ if ( mask & BUFFER_BIT_FRONT_LEFT ) {
+ flags |= DRM_TRIDENT_FRONT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
+ }
+
+ if ( mask & BUFFER_BIT_BACK_LEFT ) {
+ flags |= DRM_TRIDENT_BACK;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
+ }
+
+ if ( ( mask & BUFFER_BIT_DEPTH ) && ctx->Depth.Mask ) {
+ flags |= DRM_TRIDENT_DEPTH;
+ mask &= ~BUFFER_BIT_DEPTH;
+ }
+
+ LOCK_HARDWARE(tmesa);
+
+ if ( flags ) {
+
+ cx += tmesa->drawX;
+ cy += tmesa->drawY;
+
+ /* HACK!!!
+ */
+ if ( tmesa->dirty & ~TRIDENT_UPLOAD_CLIPRECTS ) {
+ tridentUploadHwStateLocked( tmesa );
+ }
+
+ for ( i = 0 ; i < tmesa->numClipRects ; i++ ) {
+#if 0
+ int nr = MIN2( i + TRIDENT_NR_SAREA_CLIPRECTS, tmesa->numClipRects );
+ drm_clip_rect_t *box = tmesa->pClipRects;
+ drm_clip_rect_t *b = tmesa->sarea->boxes;
+ GLint n = 0;
+
+ if ( !all ) {
+ for ( ; i < nr ; i++ ) {
+ GLint x = box[i].x1;
+ GLint y = box[i].y1;
+ GLint w = box[i].x2 - x;
+ GLint h = box[i].y2 - y;
+
+ 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 ) continue;
+ if ( h <= 0 ) continue;
+
+ b->x1 = x;
+ b->y1 = y;
+ b->x2 = x + w;
+ b->y2 = y + h;
+ b++;
+ n++;
+ }
+ } else {
+ for ( ; i < nr ; i++ ) {
+ *b++ = box[i];
+ n++;
+ }
+ }
+
+ tmesa->sarea->nbox = n;
+#endif
+
+if (flags & DRM_TRIDENT_BACK) {
+ MMIO_OUT32(MMIO, 0x2150, tmesa->tridentScreen->backPitch << 20 | tmesa->tridentScreen->backOffset>>4);
+ MMIO_OUT8(MMIO, 0x2127, 0xF0); /* Pat Rop */
+ MMIO_OUT32(MMIO, 0x2158, tmesa->ClearColor);
+ MMIO_OUT32(MMIO, 0x2128, 0x4000); /* solidfill */
+ MMIO_OUT32(MMIO, 0x2138, cx << 16 | cy);
+ MMIO_OUT32(MMIO, 0x2140, cw << 16 | ch);
+ MMIO_OUT8(MMIO, 0x2124, 0x01); /* BLT */
+#define GE_BUSY 0x80
+ for (;;) {
+ busy = MMIO_IN8(MMIO, 0x2120);
+ if ( !(busy & GE_BUSY) )
+ break;
+ }
+}
+if (flags & DRM_TRIDENT_DEPTH) {
+ MMIO_OUT32(MMIO, 0x2150, tmesa->tridentScreen->depthPitch << 20 | tmesa->tridentScreen->depthOffset>>4);
+ MMIO_OUT8(MMIO, 0x2127, 0xF0); /* Pat Rop */
+ MMIO_OUT32(MMIO, 0x2158, tmesa->ClearColor);
+ MMIO_OUT32(MMIO, 0x2128, 0x4000); /* solidfill */
+ MMIO_OUT32(MMIO, 0x2138, cx << 16 | cy);
+ MMIO_OUT32(MMIO, 0x2140, cw << 16 | ch);
+ MMIO_OUT8(MMIO, 0x2124, 0x01); /* BLT */
+#define GE_BUSY 0x80
+ for (;;) {
+ busy = MMIO_IN8(MMIO, 0x2120);
+ if ( !(busy & GE_BUSY) )
+ break;
+ }
+}
+ MMIO_OUT32(MMIO, 0x2150, tmesa->tridentScreen->frontPitch << 20 | tmesa->tridentScreen->frontOffset>>4);
+if (flags & DRM_TRIDENT_FRONT) {
+ MMIO_OUT8(MMIO, 0x2127, 0xF0); /* Pat Rop */
+ MMIO_OUT32(MMIO, 0x2158, tmesa->ClearColor);
+ MMIO_OUT32(MMIO, 0x2128, 0x4000); /* solidfill */
+ MMIO_OUT32(MMIO, 0x2138, cx << 16 | cy);
+ MMIO_OUT32(MMIO, 0x2140, cw << 16 | ch);
+ MMIO_OUT8(MMIO, 0x2124, 0x01); /* BLT */
+#define GE_BUSY 0x80
+ for (;;) {
+ busy = MMIO_IN8(MMIO, 0x2120);
+ if ( !(busy & GE_BUSY) )
+ break;
+ }
+}
+
+ }
+
+#if 0
+ tmesa->dirty |= (TRIDENT_UPLOAD_CONTEXT |
+ TRIDENT_UPLOAD_MISC |
+ TRIDENT_UPLOAD_CLIPRECTS);
+#endif
+ }
+
+ UNLOCK_HARDWARE(tmesa);
+
+ if ( mask )
+ _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
+}
+
+static void tridentDDShadeModel( GLcontext *ctx, GLenum mode )
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+ GLuint s = tmesa->commandD;
+
+#define TRIDENT_FLAT_SHADE 0x000000E0
+#define TRIDENT_FLAT_SHADE_VERTEX_C 0x00000060
+#define TRIDENT_FLAT_SHADE_GOURAUD 0x00000080
+
+ s &= ~TRIDENT_FLAT_SHADE;
+
+ switch ( mode ) {
+ case GL_FLAT:
+ s |= TRIDENT_FLAT_SHADE_VERTEX_C;
+ break;
+ case GL_SMOOTH:
+ s |= TRIDENT_FLAT_SHADE_GOURAUD;
+ break;
+ default:
+ return;
+ }
+
+ if ( tmesa->commandD != s ) {
+ tmesa->commandD = s;
+
+ tmesa->dirty |= TRIDENT_UPLOAD_COMMAND_D;
+ }
+}
+
+void tridentCalcViewport( GLcontext *ctx )
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat *m = tmesa->hw_viewport;
+
+ /* See also trident_translate_vertex.
+ */
+ m[MAT_SX] = v[MAT_SX];
+ m[MAT_TX] = v[MAT_TX] + tmesa->drawX + SUBPIXEL_X;
+ m[MAT_SY] = - v[MAT_SY];
+ m[MAT_TY] = - v[MAT_TY] + tmesa->driDrawable->h + tmesa->drawY + SUBPIXEL_Y;
+#if 0
+ m[MAT_SZ] = v[MAT_SZ] * tmesa->depth_scale;
+ m[MAT_TZ] = v[MAT_TZ] * tmesa->depth_scale;
+#else
+ m[MAT_SZ] = v[MAT_SZ];
+ m[MAT_TZ] = v[MAT_TZ];
+#endif
+
+ tmesa->SetupNewInputs = ~0;
+}
+
+static void tridentDDViewport( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ tridentCalcViewport( ctx );
+}
+
+static void tridentDDDepthRange( GLcontext *ctx,
+ GLclampd nearval, GLclampd farval )
+{
+ tridentCalcViewport( ctx );
+}
+
+void tridentSetCliprects( tridentContextPtr tmesa, GLenum mode )
+{
+ __DRIdrawablePrivate *dPriv = tmesa->driDrawable;
+
+ switch ( mode ) {
+ case GL_FRONT_LEFT:
+ if (dPriv->numClipRects == 0) {
+ static drm_clip_rect_t zeroareacliprect = {0,0,0,0};
+ tmesa->numClipRects = 1;
+ tmesa->pClipRects = &zeroareacliprect;
+ } else {
+ tmesa->numClipRects = dPriv->numClipRects;
+ tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pClipRects;
+ }
+ tmesa->drawX = dPriv->x;
+ tmesa->drawY = dPriv->y;
+ break;
+ case GL_BACK_LEFT:
+ if ( dPriv->numBackClipRects == 0 ) {
+ if (dPriv->numClipRects == 0) {
+ static drm_clip_rect_t zeroareacliprect = {0,0,0,0};
+ tmesa->numClipRects = 1;
+ tmesa->pClipRects = &zeroareacliprect;
+ } else {
+ tmesa->numClipRects = dPriv->numClipRects;
+ tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pClipRects;
+ tmesa->drawX = dPriv->x;
+ tmesa->drawY = dPriv->y;
+ }
+ }
+ else {
+ tmesa->numClipRects = dPriv->numBackClipRects;
+ tmesa->pClipRects = (drm_clip_rect_t *)dPriv->pBackClipRects;
+ tmesa->drawX = dPriv->backX;
+ tmesa->drawY = dPriv->backY;
+ }
+ break;
+ default:
+ return;
+ }
+
+#if 0
+ tmesa->dirty |= TRIDENT_UPLOAD_CLIPRECTS;
+#endif
+}
+
+#if 0
+static GLboolean tridentDDSetDrawBuffer( GLcontext *ctx, GLenum mode )
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+ int found = GL_TRUE;
+
+ if ( tmesa->DrawBuffer != mode ) {
+ tmesa->DrawBuffer = mode;
+
+ switch ( mode ) {
+ case GL_FRONT_LEFT:
+ tridentFallback( tmesa, TRIDENT_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ tmesa->drawOffset = tmesa->tridentScreen->frontOffset;
+ tmesa->drawPitch = tmesa->tridentScreen->frontPitch;
+ tridentSetCliprects( tmesa, GL_FRONT_LEFT );
+ break;
+ case GL_BACK_LEFT:
+ tridentFallback( tmesa, TRIDENT_FALLBACK_DRAW_BUFFER, GL_FALSE );
+ tmesa->drawOffset = tmesa->tridentScreen->backOffset;
+ tmesa->drawPitch = tmesa->tridentScreen->backPitch;
+ tridentSetCliprects( tmesa, GL_BACK_LEFT );
+ break;
+ default:
+ tridentFallback( tmesa, TRIDENT_FALLBACK_DRAW_BUFFER, GL_TRUE );
+ found = GL_FALSE;
+ break;
+ }
+
+#if 0
+ tmesa->setup.dst_off_pitch = (((tmesa->drawPitch/8) << 22) |
+ (tmesa->drawOffset >> 3));
+
+ tmesa->dirty |= MACH64_UPLOAD_DST_OFF_PITCH | MACH64_UPLOAD_CONTEXT;
+#endif
+
+ }
+
+ return found;
+}
+
+static void tridentDDClearColor( GLcontext *ctx,
+ const GLchan color[4] )
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+
+ tmesa->ClearColor = tridentPackColor( tmesa->tridentScreen->cpp,
+ color[0], color[1],
+ color[2], color[3] );
+}
+#endif
+
+void tridentDDUpdateState( GLcontext *ctx, GLuint new_state )
+{
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ TRIDENT_CONTEXT(ctx)->new_gl_state |= new_state;
+}
+
+
+/* Initialize the context's hardware state.
+ */
+void tridentDDInitState( tridentContextPtr tmesa )
+{
+ tmesa->new_state = 0;
+
+ switch ( tmesa->glCtx->Visual.depthBits ) {
+ case 16:
+ tmesa->depth_scale = 1.0 / (GLfloat)0xffff;
+ break;
+ case 24:
+ tmesa->depth_scale = 1.0 / (GLfloat)0xffffff;
+ break;
+ }
+}
+
+void tridentDDUpdateHWState( GLcontext *ctx )
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+ int new_state = tmesa->new_state;
+
+ if ( new_state )
+ {
+ tmesa->new_state = 0;
+
+#if 0
+ /* Update the various parts of the context's state.
+ */
+ if ( new_state & GAMMA_NEW_ALPHA )
+ tridentUpdateAlphaMode( ctx );
+
+ if ( new_state & GAMMA_NEW_DEPTH )
+ tridentUpdateZMode( ctx );
+
+ if ( new_state & GAMMA_NEW_FOG )
+ gammaUpdateFogAttrib( ctx );
+
+ if ( new_state & GAMMA_NEW_CLIP )
+ gammaUpdateClipping( ctx );
+
+ if ( new_state & GAMMA_NEW_POLYGON )
+ gammaUpdatePolygon( ctx );
+
+ if ( new_state & GAMMA_NEW_CULL )
+ gammaUpdateCull( ctx );
+
+ if ( new_state & GAMMA_NEW_MASKS )
+ gammaUpdateMasks( ctx );
+
+ if ( new_state & GAMMA_NEW_STIPPLE )
+ gammaUpdateStipple( ctx );
+#endif
+ }
+
+ /* HACK ! */
+
+#if 0
+ gammaEmitHwState( tmesa );
+#endif
+}
+
+/* Initialize the driver's state functions.
+ */
+void tridentDDInitStateFuncs( GLcontext *ctx )
+{
+ ctx->Driver.UpdateState = tridentDDUpdateState;
+
+ ctx->Driver.Clear = tridentDDClear;
+ ctx->Driver.DepthRange = tridentDDDepthRange;
+ ctx->Driver.ShadeModel = tridentDDShadeModel;
+ ctx->Driver.Viewport = tridentDDViewport;
+
+ /* Pixel path fallbacks.
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.ResizeBuffers = _mesa_resize_framebuffer;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_tris.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_tris.c
new file mode 100644
index 000000000..ee85ab482
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_tris.c
@@ -0,0 +1,1125 @@
+/*
+ * Copyright 2002 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>
+ *
+ * Trident CyberBladeXP driver.
+ *
+ */
+
+#include "trident_context.h"
+#include "trident_lock.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+
+static int first = 1;
+
+typedef struct reg {
+ int addr;
+ int data;
+} RegData;
+
+RegData initRegData[]={
+ {0x2804, 0x19980824},
+ {0x2F70, 0x46455858},
+ {0x2F74, 0x41584998},
+ {0x2F00, 0x00000000},
+ {0x2F04, 0x80000800},
+ {0x2F08, 0x00550200},
+ {0x2F40, 0x00000001},
+ {0x2F40, 0x00000001},
+ {0x2F44, 0x00830097},
+ {0x2F48, 0x0087009F},
+ {0x2F4C, 0x00BF0003},
+ {0x2F50, 0xF00B6C1B},
+ {0x2C04, 0x00000000},
+ {0x2D00, 0x00000080},
+ {0x2D00, 0x00000000},
+ {0x2DD4, 0x00100000},
+ {0x2DD4, 0x00100010},
+ {0x2DD8, 0x00100000},
+ {0x2DD8, 0x00100010},
+ {0x2C88, 0xFFFFFFFF},
+ {0x2C94 , 0xFFFFFFFF},
+ {0x281C, 0x00008000},
+ {0x2C80, 0x00000000},
+ {0x2C80, 0x00000000},
+ {0x2C80 , 0x00008000},
+ {0x2C00 , 0x00000000},
+ {0x2C04 , 0x00000000},
+ {0x2C08 , 0x00000000},
+ {0x2C0C , 0x00000000},
+ {0x2C10 , 0x00000000},
+ {0x2C14 , 0x00000000},
+ {0x2C18 , 0x00000000},
+ {0x2C1C , 0x00000000},
+ {0x2C20 , 0x00000000},
+ {0x2C24 , 0x00000000},
+ {0x2C2C , 0x00000000},
+ {0x2C30 , 0x00000000},
+ {0x2C34 , 0x00000000},
+ {0x2C38 , 0x00000000},
+ {0x2C3C , 0x00000000},
+ {0x2C40 , 0x00000000},
+ {0x2C44 , 0x00000000},
+ {0x2C48 , 0x00000000},
+ {0x2C4C , 0x00000000},
+ {0x2C50 , 0x00000000},
+ {0x2C54 , 0x00000000},
+ {0x2C58 , 0x00000000},
+ {0x2C5C , 0x00000000},
+ {0x2C60 , 0x00000000},
+ {0x2C64 , 0x00000000},
+ {0x2C68 , 0x00000000},
+ {0x2C6C , 0x00000000},
+ {0x2C70 , 0x00000000},
+ {0x2C74 , 0x00000000},
+ {0x2C78 , 0x00000000},
+ {0x2C7C , 0x00000000},
+ {0x2C80 , 0x00008000},
+ {0x2C84 , 0x00000000},
+ {0x2C88 , 0xFFFFFFFF},
+ {0x2C8C , 0x00000000},
+ {0x2C90 , 0x00000000},
+ {0x2C94 , 0xFFFFFFFF},
+ {0x2C98 , 0x00000000},
+ {0x2C9C , 0x00000000},
+ {0x2CA0 , 0x00000000},
+ {0x2CA4 , 0x00000000},
+ {0x2CA8 , 0x00000000},
+ {0x2CAC , 0x00000000},
+ {0x2CB0 , 0x00000000},
+ {0x2CB4 , 0x00000000},
+ {0x2CB8 , 0x00000000},
+ {0x2CBC , 0x00000000},
+ {0x2CC0 , 0x00000000},
+ {0x2CC4 , 0x00000000},
+ {0x2CC8 , 0x00000000},
+ {0x2CCC , 0x00000000},
+ {0x2CD0 , 0x00000000},
+ {0x2CD4 , 0x00000000},
+ {0x2CD8 , 0x00000000},
+ {0x2CDC , 0x00000000},
+ {0x2CE0 , 0x00000000},
+ {0x2CE4 , 0x00000000},
+ {0x2CE8 , 0x00000000},
+ {0x2CEC , 0x00000000},
+ {0x2CF0 , 0x00000000},
+ {0x2CF4 , 0x00000000},
+ {0x2CF8 , 0x00000000},
+ {0x2CFC , 0x00000000},
+ {0x2D00 , 0x00000000},
+ {0x2D04 , 0x00000000},
+ {0x2D08 , 0x00000000},
+ {0x2D0C , 0x00000000},
+ {0x2D10 , 0x00000000},
+ {0x2D14 , 0x00000000},
+ {0x2D18 , 0x00000000},
+ {0x2D1C , 0x00000000},
+ {0x2D20 , 0x00000000},
+ {0x2D24 , 0x00000000},
+ {0x2D28 , 0x00000000},
+ {0x2D2C , 0x00000000},
+ {0x2D30 , 0x00000000},
+ {0x2D34 , 0x00000000},
+ {0x2D38 , 0x00000000},
+ {0x2D3C , 0x00000000},
+ {0x2D40 , 0x00000000},
+ {0x2D44 , 0x00000000},
+ {0x2D48 , 0x00000000},
+ {0x2D4C , 0x00000000},
+ {0x2D50 , 0x00000000},
+ {0x2D54 , 0x00000000},
+ {0x2D58 , 0x00000000},
+ {0x2D5C , 0x00000000},
+ {0x2D60 , 0x00000000},
+ {0x2D64 , 0x00000000},
+ {0x2D68 , 0x00000000},
+ {0x2D6C , 0x00000000},
+ {0x2D70 , 0x00000000},
+ {0x2D74 , 0x00000000},
+ {0x2D78 , 0x00000000},
+ {0x2D7C , 0x00000000},
+ {0x2D80 , 0x00000000},
+ {0x2D84 , 0x00000000},
+ {0x2D88 , 0x00000000},
+ {0x2D8C , 0x00000000},
+ {0x2D90 , 0x00000000},
+ {0x2D94 , 0x00000000},
+ {0x2D98 , 0x00000000},
+ {0x2D9C , 0x00000000},
+ {0x2DA0 , 0x00000000},
+ {0x2DA4 , 0x00000000},
+ {0x2DA8 , 0x00000000},
+ {0x2DAC , 0x00000000},
+ {0x2DB0 , 0x00000000},
+ {0x2DB4 , 0x00000000},
+ {0x2DB8 , 0x00000000},
+ {0x2DBC , 0x00000000},
+ {0x2DC0 , 0x00000000},
+ {0x2DC4 , 0x00000000},
+ {0x2DC8 , 0x00000000},
+ {0x2DCC , 0x00000000},
+ {0x2DD0 , 0x00000000},
+ {0x2DD4 , 0x00100010},
+ {0x2DD8 , 0x00100010},
+ {0x2DDC , 0x00000000},
+ {0x2DE0 , 0x00000000},
+ {0x2DE4 , 0x00000000},
+ {0x2DE8 , 0x00000000},
+ {0x2DEC , 0x00000000},
+ {0x2DF0 , 0x00000000},
+ {0x2DF4 , 0x00000000},
+ {0x2DF8 , 0x00000000},
+ {0x2DFC , 0x00000000},
+ {0x2E00 , 0x00000000},
+ {0x2E04 , 0x00000000},
+ {0x2E08 , 0x00000000},
+ {0x2E0C , 0x00000000},
+ {0x2E10 , 0x00000000},
+ {0x2E14 , 0x00000000},
+ {0x2E18 , 0x00000000},
+ {0x2E1C , 0x00000000},
+ {0x2E20 , 0x00000000},
+ {0x2E24 , 0x00000000},
+ {0x2E28 , 0x00000000},
+ {0x2E2C , 0x00000000},
+ {0x2E30 , 0x00000000},
+ {0x2E34 , 0x00000000},
+ {0x2E38 , 0x00000000},
+ {0x2E3C , 0x00000000},
+ {0x2E40 , 0x00000000},
+ {0x2E44 , 0x00000000},
+ {0x2E48 , 0x00000000},
+ {0x2E4C , 0x00000000},
+ {0x2E50 , 0x00000000},
+ {0x2E54 , 0x00000000},
+ {0x2E58 , 0x00000000},
+ {0x2E5C , 0x00000000},
+ {0x2E60 , 0x00000000},
+ {0x2E64 , 0x00000000},
+ {0x2E68 , 0x00000000},
+ {0x2E6C , 0x00000000},
+ {0x2E70 , 0x00000000},
+ {0x2E74 , 0x00000000},
+ {0x2E78 , 0x00000000},
+ {0x2E7C , 0x00000000},
+ {0x2E80 , 0x00000000},
+ {0x2E84 , 0x00000000},
+ {0x2E88 , 0x00000000},
+ {0x2E8C , 0x00000000},
+ {0x2E90 , 0x00000000},
+ {0x2E94 , 0x00000000},
+ {0x2E98 , 0x00000000},
+ {0x2E9C , 0x00000000},
+ {0x2EA0 , 0x00000000},
+ {0x2EA4 , 0x00000000},
+ {0x2EA8 , 0x00000000},
+ {0x2EAC , 0x00000000},
+ {0x2EB0 , 0x00000000},
+ {0x2EB4 , 0x00000000},
+ {0x2EB8 , 0x00000000},
+ {0x2EBC , 0x00000000},
+ {0x2EC0 , 0x00000000},
+ {0x2EC4 , 0x00000000},
+ {0x2EC8 , 0x00000000},
+ {0x2ECC , 0x00000000},
+ {0x2ED0 , 0x00000000},
+ {0x2ED4 , 0x00000000},
+ {0x2ED8 , 0x00000000},
+ {0x2EDC , 0x00000000},
+ {0x2EE0 , 0x00000000},
+ {0x2EE4 ,0x00000000},
+ {0x2EE8 ,0x00000000},
+ {0x2EEC , 0x00000000},
+ {0x2EF0 , 0x00000000},
+ {0x2EF4 , 0x00000000},
+ {0x2EF8 , 0x00000000},
+ {0x2EFC , 0x00000000},
+ /*{0x2F60 , 0x00000000},*/
+};
+
+int initRegDataNum=sizeof(initRegData)/sizeof(RegData);
+
+typedef union {
+ unsigned int i;
+ float f;
+} dmaBufRec, *dmaBuf;
+
+void Init3D( tridentContextPtr tmesa )
+{
+ unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
+ int i;
+
+ for(i=0;i<initRegDataNum;++i)
+ MMIO_OUT32(MMIO, initRegData[i].addr, initRegData[i].data);
+}
+
+int DrawTriangle( tridentContextPtr tmesa)
+{
+ unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
+ dmaBufRec clr;
+
+printf("DRAW TRI\n");
+ Init3D(tmesa);
+
+printf("ENGINE STATUS 0x%x\n",MMIO_IN32(MMIO, 0x2800));
+ MMIO_OUT32(MMIO, 0x002800, 0x00000000 );
+#if 0
+ MMIO_OUT32(MMIO, 0x002368 , MMIO_IN32(MMIO,0x002368)|1 );
+#endif
+
+ MMIO_OUT32(MMIO, 0x002C00 , 0x00000014 );
+#if 0
+ MMIO_OUT32(MMIO, 0x002C04 , 0x0A8004C0 );
+#else
+ MMIO_OUT32(MMIO, 0x002C04 , 0x0A8000C0 );
+#endif
+
+#if 0
+ MMIO_OUT32(MMIO, 0x002C08 , 0x00000000 );
+ MMIO_OUT32(MMIO, 0x002C0C , 0xFFCCCCCC );
+ MMIO_OUT32(MMIO, 0x002C10 , 0x3F800000 );
+ MMIO_OUT32(MMIO, 0x002C14 , 0x3D0D3DCB );
+ MMIO_OUT32(MMIO, 0x002C2C , 0x70000000 );
+ MMIO_OUT32(MMIO, 0x002C24 , 0x00202C00 );
+ MMIO_OUT32(MMIO, 0x002C28 , 0xE0002500 );
+ MMIO_OUT32(MMIO, 0x002C30 , 0x00000000 );
+ MMIO_OUT32(MMIO, 0x002C34 , 0xE0000000 );
+ MMIO_OUT32(MMIO, 0x002C38 , 0x00000000 );
+#endif
+
+ MMIO_OUT32(MMIO, 0x002C50 , 0x00000000 );
+ MMIO_OUT32(MMIO, 0x002C54 , 0x0C320C80 );
+ MMIO_OUT32(MMIO, 0x002C50 , 0x00000000 );
+ MMIO_OUT32(MMIO, 0x002C54 , 0x0C320C80 );
+ MMIO_OUT32(MMIO, 0x002C80 , 0x20008258 );
+ MMIO_OUT32(MMIO, 0x002C84 , 0x20000320 );
+ MMIO_OUT32(MMIO, 0x002C94 , 0xFFFFFFFF );
+
+#if 0
+ MMIO_OUT32(MMIO, 0x002D00 , 0x00009009 );
+ MMIO_OUT32(MMIO, 0x002D38 , 0x00000000 );
+ MMIO_OUT32(MMIO, 0x002D94 , 0x20002000 );
+ MMIO_OUT32(MMIO, 0x002D50 , 0xf0000000 );
+ MMIO_OUT32(MMIO, 0x002D80 , 0x24002000 );
+ MMIO_OUT32(MMIO, 0x002D98 , 0x81000000 );
+ MMIO_OUT32(MMIO, 0x002DB0 , 0x81000000 );
+ MMIO_OUT32(MMIO, 0x002DC8 , 0x808000FF );
+ MMIO_OUT32(MMIO, 0x002DD4 , 0x02000200 );
+ MMIO_OUT32(MMIO, 0x002DD8 , 0x02000200 );
+ MMIO_OUT32(MMIO, 0x002D30 , 0x02092400 );
+ MMIO_OUT32(MMIO, 0x002D04 , 0x00102120 );
+ MMIO_OUT32(MMIO, 0x002D08 , 0xFFFFFFFF );
+ MMIO_OUT32(MMIO, 0x002D0C , 0xF00010D0 );
+ MMIO_OUT32(MMIO, 0x002D10 , 0xC0000400 );
+#endif
+
+ MMIO_OUT32(MMIO, 0x002814, 0x00000000 );
+#if 0
+ MMIO_OUT32(MMIO, 0x002818 , 0x00036C20 );
+#else
+ MMIO_OUT32(MMIO, 0x002818 , 0x00036020 );
+#endif
+ MMIO_OUT32(MMIO, 0x00281C , 0x00098081 );
+
+printf("first TRI\n");
+ clr.f = 5.0;
+ MMIO_OUT32(MMIO, 0x002820 , clr.i );
+ clr.f = 595.0;
+ MMIO_OUT32(MMIO, 0x002824 , clr.i );
+ clr.f = 1.0;
+ MMIO_OUT32(MMIO, 0x002828 , clr.i );
+ MMIO_OUT32(MMIO, 0x00282C , 0x00FF00 );
+#if 0
+ clr.f = 0.0;
+ MMIO_OUT32(MMIO, 0x002830 , clr.i );
+ clr.f = 1.0;
+ MMIO_OUT32(MMIO, 0x002834 , clr.i );
+#endif
+
+ clr.f = 5.0;
+ MMIO_OUT32(MMIO, 0x002820 , clr.i );
+ clr.f = 5.0;
+ MMIO_OUT32(MMIO, 0x002824 , clr.i );
+ clr.f = 1.0;
+ MMIO_OUT32(MMIO, 0x002828 , clr.i );
+ MMIO_OUT32(MMIO, 0x00282C , 0xFF0000 );
+#if 0
+ clr.f = 0.0;
+ MMIO_OUT32(MMIO, 0x002830 , clr.i );
+ clr.f = 0.0;
+ MMIO_OUT32(MMIO, 0x002834 , clr.i );
+#endif
+
+ clr.f = 395.0;
+printf("0x%x\n",clr.i);
+ MMIO_OUT32(MMIO, 0x002820 , clr.i );
+ clr.f = 5.0;
+ MMIO_OUT32(MMIO, 0x002824 , clr.i );
+ clr.f = 1.0;
+ MMIO_OUT32(MMIO, 0x002828 , clr.i );
+ MMIO_OUT32(MMIO, 0x00282C , 0xFF );
+#if 0
+ clr.f = 1.0;
+ MMIO_OUT32(MMIO, 0x002830 , clr.i );
+ clr.f = 0.0;
+ MMIO_OUT32(MMIO, 0x002834 , clr.i );
+#endif
+
+printf("sec TRI\n");
+ MMIO_OUT32(MMIO, 0x00281C , 0x00093980 );
+ clr.f = 395.0;
+ MMIO_OUT32(MMIO, 0x002820 , clr.i );
+ clr.f = 595.0;
+ MMIO_OUT32(MMIO, 0x002824 , clr.i );
+ clr.f = 1.0;
+ MMIO_OUT32(MMIO, 0x002828 , clr.i );
+ MMIO_OUT32(MMIO, 0x00282C , 0x00FF00 );
+#if 0
+ clr.f = 1.0;
+ MMIO_OUT32(MMIO, 0x002830 , clr.i );
+ clr.f = 1.0;
+ MMIO_OUT32(MMIO, 0x002834 , clr.i );
+#endif
+
+#if 0
+ MMIO_OUT32(MMIO, 0x002368 , MMIO_IN32(MMIO,0x002368)&0xfffffffe );
+#endif
+
+printf("fin TRI\n");
+
+ return 0;
+}
+
+static INLINE void trident_draw_point(tridentContextPtr tmesa,
+ const tridentVertex *v0 )
+{
+ unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
+ (void) MMIO;
+}
+
+static INLINE void trident_draw_line( tridentContextPtr tmesa,
+ const tridentVertex *v0,
+ const tridentVertex *v1 )
+{
+ unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
+ (void) MMIO;
+}
+
+static INLINE void trident_draw_triangle( tridentContextPtr tmesa,
+ const tridentVertex *v0,
+ const tridentVertex *v1,
+ const tridentVertex *v2 )
+{
+}
+
+static INLINE void trident_draw_quad( tridentContextPtr tmesa,
+ const tridentVertex *v0,
+ const tridentVertex *v1,
+ const tridentVertex *v2,
+ const tridentVertex *v3 )
+{
+ GLuint vertsize = tmesa->vertex_size;
+ GLint coloridx = (vertsize > 4) ? 4 : 3;
+ unsigned char *MMIO = tmesa->tridentScreen->mmio.map;
+ int clr;
+ float *ftmp = (float *)(&clr);
+
+ if (tmesa->dirty)
+ tridentUploadHwStateLocked( tmesa );
+#if 0
+ DrawTriangle(tmesa);
+ exit(0);
+#else
+#if 1
+ if (first) {
+ Init3D(tmesa);
+#if 0
+ DrawTriangle(tmesa);
+#endif
+ first = 0;
+ }
+#endif
+
+ LOCK_HARDWARE( tmesa );
+
+ MMIO_OUT32(MMIO, 0x002C00 , 0x00000010 );
+ MMIO_OUT32(MMIO, 0x002C04 , 0x029C00C0 );
+
+ /* Z buffer */
+ MMIO_OUT32(MMIO, 0x002C24 , 0x00100000 /*| (tmesa->tridentScreen->depthOffset)*/ );
+ MMIO_OUT32(MMIO, 0x002C28 , 0xE0000000 | (tmesa->tridentScreen->depthPitch * 4) );
+
+ /* front buffer */
+ MMIO_OUT32(MMIO, 0x002C50 , 0x00000000 | (tmesa->drawOffset) );
+ MMIO_OUT32(MMIO, 0x002C54 , 0x0C320000 | (tmesa->drawPitch * 4) );
+
+ /* clipper */
+ MMIO_OUT32(MMIO, 0x002C80 , 0x20008000 | tmesa->tridentScreen->height );
+ MMIO_OUT32(MMIO, 0x002C84 , 0x20000000 | tmesa->tridentScreen->width );
+
+ /* writemask */
+ MMIO_OUT32(MMIO, 0x002C94 , 0xFFFFFFFF );
+
+if (vertsize == 4) {
+ MMIO_OUT32(MMIO, 0x002818 , 0x0003A020 );
+ MMIO_OUT32(MMIO, 0x00281C , 0x00098021 );
+
+ *ftmp = v0->v.x;
+ MMIO_OUT32(MMIO, 0x002820 , clr );
+ *ftmp = v0->v.y;
+ MMIO_OUT32(MMIO, 0x002824 , clr );
+ *ftmp = v0->v.z;
+ MMIO_OUT32(MMIO, 0x002828 , clr );
+#if 0
+ *ftmp = v0->v.w;
+ MMIO_OUT32(MMIO, 0x00282C , clr );
+#endif
+ MMIO_OUT32(MMIO, 0x00282C , v0->ui[coloridx] );
+
+ *ftmp = v1->v.x;
+ MMIO_OUT32(MMIO, 0x002820 , clr );
+ *ftmp = v1->v.y;
+ MMIO_OUT32(MMIO, 0x002824 , clr );
+ *ftmp = v1->v.z;
+ MMIO_OUT32(MMIO, 0x002828 , clr );
+#if 0
+ *ftmp = v1->v.w;
+ MMIO_OUT32(MMIO, 0x00282C , clr );
+#endif
+ MMIO_OUT32(MMIO, 0x00282C , v1->ui[coloridx] );
+
+ *ftmp = v2->v.x;
+ MMIO_OUT32(MMIO, 0x002820 , clr );
+ *ftmp = v2->v.y;
+ MMIO_OUT32(MMIO, 0x002824 , clr );
+ *ftmp = v2->v.z;
+ MMIO_OUT32(MMIO, 0x002828 , clr );
+#if 0
+ *ftmp = v2->v.w;
+ MMIO_OUT32(MMIO, 0x00282C , clr );
+#endif
+ MMIO_OUT32(MMIO, 0x00282C , v2->ui[coloridx] );
+
+ MMIO_OUT32(MMIO, 0x00281C , 0x00093020 );
+ *ftmp = v3->v.x;
+ MMIO_OUT32(MMIO, 0x002820 , clr );
+ *ftmp = v3->v.y;
+ MMIO_OUT32(MMIO, 0x002824 , clr );
+ *ftmp = v3->v.z;
+ MMIO_OUT32(MMIO, 0x002828 , clr );
+#if 0
+ *ftmp = v3->v.w;
+ MMIO_OUT32(MMIO, 0x00282C , clr );
+#endif
+ MMIO_OUT32(MMIO, 0x00282C , v3->ui[coloridx] );
+
+}
+#endif
+
+ UNLOCK_HARDWARE( tmesa );
+}
+/***********************************************************************
+ * Rasterization fallback helpers *
+ ***********************************************************************/
+
+
+/* This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+#if 0
+static void
+trident_fallback_quad( tridentContextPtr tmesa,
+ const tridentVertex *v0,
+ const tridentVertex *v1,
+ const tridentVertex *v2,
+ const tridentVertex *v3 )
+{
+ GLcontext *ctx = tmesa->glCtx;
+ SWvertex v[4];
+ trident_translate_vertex( ctx, v0, &v[0] );
+ trident_translate_vertex( ctx, v1, &v[1] );
+ trident_translate_vertex( ctx, v2, &v[2] );
+ trident_translate_vertex( ctx, v3, &v[3] );
+ _swrast_Quad( ctx, &v[0], &v[1], &v[2], &v[3] );
+}
+#endif
+
+/* XXX hack to get the prototype defined in time... */
+void trident_translate_vertex(GLcontext *ctx, const tridentVertex *src,
+ SWvertex *dst);
+
+static void
+trident_fallback_tri( tridentContextPtr tmesa,
+ const tridentVertex *v0,
+ const tridentVertex *v1,
+ const tridentVertex *v2 )
+{
+ GLcontext *ctx = tmesa->glCtx;
+ SWvertex v[3];
+ trident_translate_vertex( ctx, v0, &v[0] );
+ trident_translate_vertex( ctx, v1, &v[1] );
+ trident_translate_vertex( ctx, v2, &v[2] );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+}
+
+static void
+trident_fallback_line( tridentContextPtr tmesa,
+ const tridentVertex *v0,
+ const tridentVertex *v1 )
+{
+ GLcontext *ctx = tmesa->glCtx;
+ SWvertex v[2];
+ trident_translate_vertex( ctx, v0, &v[0] );
+ trident_translate_vertex( ctx, v1, &v[1] );
+ _swrast_Line( ctx, &v[0], &v[1] );
+}
+
+
+static void
+trident_fallback_point( tridentContextPtr tmesa,
+ const tridentVertex *v0 )
+{
+ GLcontext *ctx = tmesa->glCtx;
+ SWvertex v[1];
+ trident_translate_vertex( ctx, v0, &v[0] );
+ _swrast_Point( ctx, &v[0] );
+}
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ if (DO_FALLBACK) \
+ tmesa->draw_tri( tmesa, a, b, c ); \
+ else \
+ trident_draw_triangle( tmesa, a, b, c ); \
+} while (0)
+
+#define QUAD( a, b, c, d ) \
+do { \
+ if (DO_FALLBACK) { \
+ tmesa->draw_tri( tmesa, a, b, d ); \
+ tmesa->draw_tri( tmesa, b, c, d ); \
+ } else \
+ trident_draw_quad( tmesa, a, b, c, d ); \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ if (DO_FALLBACK) \
+ tmesa->draw_line( tmesa, v0, v1 ); \
+ else \
+ trident_draw_line( tmesa, v0, v1 ); \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ if (DO_FALLBACK) \
+ tmesa->draw_point( tmesa, v0 ); \
+ else \
+ trident_draw_point( tmesa, v0 ); \
+} while (0)
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define TRIDENT_OFFSET_BIT 0x01
+#define TRIDENT_TWOSIDE_BIT 0x02
+#define TRIDENT_UNFILLED_BIT 0x04
+#define TRIDENT_FALLBACK_BIT 0x08
+#define TRIDENT_MAX_TRIFUNC 0x10
+
+
+static struct {
+ tnl_points_func points;
+ tnl_line_func line;
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
+} rast_tab[TRIDENT_MAX_TRIFUNC];
+
+
+#define DO_FALLBACK (IND & TRIDENT_FALLBACK_BIT)
+#define DO_OFFSET (IND & TRIDENT_OFFSET_BIT)
+#define DO_UNFILLED (IND & TRIDENT_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & TRIDENT_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 1
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX tridentVertex
+#define TAB rast_tab
+
+#define DEPTH_SCALE 1.0
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW( a ) (a > 0)
+#define GET_VERTEX(e) (tmesa->verts + (e<<tmesa->vertex_stride_shift))
+
+#define TRIDENT_COLOR( dst, src ) \
+do { \
+ dst[0] = src[2]; \
+ dst[1] = src[1]; \
+ dst[2] = src[0]; \
+ dst[3] = src[3]; \
+} while (0)
+
+#define TRIDENT_SPEC( dst, src ) \
+do { \
+ dst[0] = src[2]; \
+ dst[1] = src[1]; \
+ dst[2] = src[0]; \
+} while (0)
+
+#define VERT_SET_RGBA( v, c ) TRIDENT_COLOR( v->ub4[coloroffset], c )
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
+
+#define VERT_SET_SPEC( v, c ) if (havespec) TRIDENT_SPEC( v->ub4[5], c )
+#define VERT_COPY_SPEC( v0, v1 ) if (havespec) COPY_3V(v0->ub4[5], v1->ub4[5])
+#define VERT_SAVE_SPEC( idx ) if (havespec) spec[idx] = v[idx]->ui[5]
+#define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx]
+
+#define LOCAL_VARS(n) \
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); \
+ GLuint color[n], spec[n]; \
+ GLuint coloroffset = (tmesa->vertex_size == 4 ? 3 : 4); \
+ GLboolean havespec = (tmesa->vertex_size == 4 ? 0 : 1); \
+ (void) color; (void) spec; (void) coloroffset; (void) havespec;
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+#if 0
+static const GLuint hw_prim[GL_POLYGON+1] = {
+ B_PrimType_Points,
+ B_PrimType_Lines,
+ B_PrimType_Lines,
+ B_PrimType_Lines,
+ B_PrimType_Triangles,
+ B_PrimType_Triangles,
+ B_PrimType_Triangles,
+ B_PrimType_Triangles,
+ B_PrimType_Triangles,
+ B_PrimType_Triangles
+};
+#endif
+
+static void tridentResetLineStipple( GLcontext *ctx );
+#if 0
+static void tridentRasterPrimitive( GLcontext *ctx, GLuint hwprim );
+#endif
+static void tridentRenderPrimitive( GLcontext *ctx, GLenum prim );
+
+#define RASTERIZE(x) /*if (tmesa->hw_primitive != hw_prim[x]) \
+ tridentRasterPrimitive( ctx, hw_prim[x] ) */
+#define RENDER_PRIMITIVE tmesa->render_primitive
+#define TAG(x) x
+#define IND TRIDENT_FALLBACK_BIT
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TRIDENT_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TRIDENT_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TRIDENT_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TRIDENT_OFFSET_BIT|TRIDENT_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_OFFSET_BIT|TRIDENT_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TRIDENT_FALLBACK_BIT)
+#define TAG(x) x##_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TRIDENT_OFFSET_BIT|TRIDENT_FALLBACK_BIT)
+#define TAG(x) x##_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_FALLBACK_BIT)
+#define TAG(x) x##_twoside_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_OFFSET_BIT|TRIDENT_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TRIDENT_UNFILLED_BIT|TRIDENT_FALLBACK_BIT)
+#define TAG(x) x##_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TRIDENT_OFFSET_BIT|TRIDENT_UNFILLED_BIT|TRIDENT_FALLBACK_BIT)
+#define TAG(x) x##_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_UNFILLED_BIT|TRIDENT_FALLBACK_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (TRIDENT_TWOSIDE_BIT|TRIDENT_OFFSET_BIT|TRIDENT_UNFILLED_BIT|TRIDENT_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+static void init_rast_tab( void )
+{
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+ init_fallback();
+ init_offset_fallback();
+ init_twoside_fallback();
+ init_twoside_offset_fallback();
+ init_unfilled_fallback();
+ init_offset_unfilled_fallback();
+ init_twoside_unfilled_fallback();
+ init_twoside_offset_unfilled_fallback();
+}
+
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+
+#define VERT(x) (tridentVertex *)(tridentverts + (x << shift))
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ trident_draw_point( tmesa, VERT(start) )
+#define RENDER_LINE( v0, v1 ) \
+ trident_draw_line( tmesa, VERT(v0), VERT(v1) )
+#define RENDER_TRI( v0, v1, v2 ) \
+ trident_draw_triangle( tmesa, VERT(v0), VERT(v1), VERT(v2) )
+#define RENDER_QUAD( v0, v1, v2, v3 ) \
+ trident_draw_quad( tmesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
+#define INIT(x) tridentRenderPrimitive( ctx, x );
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx); \
+ const GLuint shift = tmesa->vertex_stride_shift; \
+ const char *tridentverts = (char *)tmesa->verts; \
+ const GLboolean stipple = ctx->Line.StippleFlag; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ (void) elt;
+#define RESET_STIPPLE if ( stipple ) tridentResetLineStipple( ctx );
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) (x)
+#define TAG(x) trident_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+#undef ELT
+#undef TAG
+#define TAG(x) trident_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl/t_vb_rendertmp.h"
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+static void tridentRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint prim = tmesa->render_primitive;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+ }
+
+ /* Restore the render primitive
+ */
+ if (prim != GL_POLYGON)
+ tnl->Driver.Render.PrimitiveNotify( ctx, prim );
+}
+
+static void tridentRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Line( ctx, ii, jj );
+}
+
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+#define _TRIDENT_NEW_RENDER_STATE (_DD_NEW_LINE_STIPPLE | \
+ _DD_NEW_LINE_SMOOTH | \
+ _DD_NEW_POINT_SMOOTH | \
+ _DD_NEW_TRI_SMOOTH | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET) \
+
+
+#define POINT_FALLBACK (DD_POINT_SMOOTH)
+#define LINE_FALLBACK (DD_LINE_STIPPLE|DD_LINE_SMOOTH)
+#define TRI_FALLBACK (DD_TRI_SMOOTH)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)
+#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
+
+
+static void tridentChooseRenderState(GLcontext *ctx)
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ if (flags & (ANY_RASTER_FLAGS|ANY_FALLBACK_FLAGS)) {
+ tmesa->draw_point = trident_draw_point;
+ tmesa->draw_line = trident_draw_line;
+ tmesa->draw_tri = trident_draw_triangle;
+
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= TRIDENT_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= TRIDENT_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= TRIDENT_UNFILLED_BIT;
+ }
+
+ /* Hook in fallbacks for specific primitives.
+ */
+ if (flags & (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)) {
+ if (flags & POINT_FALLBACK) tmesa->draw_point = trident_fallback_point;
+ if (flags & LINE_FALLBACK) tmesa->draw_line = trident_fallback_line;
+ if (flags & TRI_FALLBACK) tmesa->draw_tri = trident_fallback_tri;
+ index |= TRIDENT_FALLBACK_BIT;
+ }
+ }
+
+ if (tmesa->RenderIndex != index) {
+ tmesa->RenderIndex = index;
+
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (tmesa->RenderIndex == 0) {
+ tnl->Driver.Render.PrimTabVerts = trident_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = trident_render_tab_elts;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ }
+ tnl->Driver.Render.ClippedLine = tridentRenderClippedLine;
+ tnl->Driver.Render.ClippedPolygon = tridentRenderClippedPoly;
+ }
+}
+
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+
+
+/* Determine the rasterized primitive when not drawing unfilled
+ * polygons.
+ *
+ * Used only for the default render stage which always decomposes
+ * primitives to trianges/lines/points. For the accelerated stage,
+ * which renders strips as strips, the equivalent calculations are
+ * performed in tridentrender.c.
+ */
+#if 0
+static void tridentRasterPrimitive( GLcontext *ctx, GLuint hwprim )
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+ if (tmesa->hw_primitive != hwprim)
+ tmesa->hw_primitive = hwprim;
+}
+#endif
+
+static void tridentRenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+ tmesa->render_primitive = prim;
+}
+
+static void tridentRunPipeline( GLcontext *ctx )
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+
+ if ( tmesa->new_state )
+ tridentDDUpdateHWState( ctx );
+
+ if (tmesa->new_gl_state) {
+#if 0
+ if (tmesa->new_gl_state & _NEW_TEXTURE)
+ tridentUpdateTextureState( ctx );
+#endif
+
+ if (!tmesa->Fallback) {
+ if (tmesa->new_gl_state & _TRIDENT_NEW_VERTEX)
+ tridentChooseVertexState( ctx );
+
+ if (tmesa->new_gl_state & _TRIDENT_NEW_RENDER_STATE)
+ tridentChooseRenderState( ctx );
+ }
+
+ tmesa->new_gl_state = 0;
+ }
+
+ _tnl_run_pipeline( ctx );
+}
+
+static void tridentRenderStart( GLcontext *ctx )
+{
+ /* Check for projective texturing. Make sure all texcoord
+ * pointers point to something. (fix in mesa?)
+ */
+ tridentCheckTexSizes( ctx );
+}
+
+static void tridentRenderFinish( GLcontext *ctx )
+{
+ if (0)
+ _swrast_flush( ctx ); /* never needed */
+}
+
+static void tridentResetLineStipple( GLcontext *ctx )
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+ (void) tmesa;
+
+ /* Reset the hardware stipple counter.
+ */
+}
+
+
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+
+
+void tridentFallback( tridentContextPtr tmesa, GLuint bit, GLboolean mode )
+{
+ GLcontext *ctx = tmesa->glCtx;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldfallback = tmesa->Fallback;
+
+ _tnl_need_projected_coords( ctx, GL_FALSE );
+
+ if (mode) {
+ tmesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ _swsetup_Wakeup( ctx );
+ tmesa->RenderIndex = ~0;
+ }
+ }
+ else {
+ tmesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = tridentRenderStart;
+ tnl->Driver.Render.PrimitiveNotify = tridentRenderPrimitive;
+ tnl->Driver.Render.Finish = tridentRenderFinish;
+ tnl->Driver.Render.BuildVertices = tridentBuildVertices;
+ tnl->Driver.Render.ResetLineStipple = tridentResetLineStipple;
+ tmesa->new_gl_state |= (_TRIDENT_NEW_RENDER_STATE|
+ _TRIDENT_NEW_VERTEX);
+ }
+ }
+}
+
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+
+void tridentDDInitTriFuncs( GLcontext *ctx )
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+ }
+
+ tmesa->RenderIndex = ~0;
+
+ tnl->Driver.RunPipeline = tridentRunPipeline;
+ tnl->Driver.Render.Start = tridentRenderStart;
+ tnl->Driver.Render.Finish = tridentRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = tridentRenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = tridentResetLineStipple;
+ tnl->Driver.Render.BuildVertices = tridentBuildVertices;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_vb.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_vb.c
new file mode 100644
index 000000000..77e4d9b76
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/trident/trident_vb.c
@@ -0,0 +1,434 @@
+/*
+ * Copyright 2002 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>
+ *
+ * Trident CyberBladeXP driver.
+ *
+ */
+#include "glheader.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "colormac.h"
+
+#include "swrast_setup/swrast_setup.h"
+#include "swrast/swrast.h"
+#include "tnl/t_context.h"
+#include "tnl/tnl.h"
+
+#include "trident_context.h"
+
+#define TRIDENT_TEX1_BIT 0x1
+#define TRIDENT_TEX0_BIT 0x2
+#define TRIDENT_RGBA_BIT 0x4
+#define TRIDENT_SPEC_BIT 0x8
+#define TRIDENT_FOG_BIT 0x10
+#define TRIDENT_XYZW_BIT 0x20
+#define TRIDENT_PTEX_BIT 0x40
+#define TRIDENT_MAX_SETUP 0x80
+
+static struct {
+ void (*emit)( GLcontext *, GLuint, GLuint, void *, GLuint );
+ tnl_interp_func interp;
+ tnl_copy_pv_func copy_pv;
+ GLboolean (*check_tex_sizes)( GLcontext *ctx );
+ GLuint vertex_size;
+ GLuint vertex_stride_shift;
+ GLuint vertex_format;
+} setup_tab[TRIDENT_MAX_SETUP];
+
+#define TINY_VERTEX_FORMAT 1
+#define NOTEX_VERTEX_FORMAT 2
+#define TEX0_VERTEX_FORMAT 3
+#define TEX1_VERTEX_FORMAT 4
+#define PROJ_TEX1_VERTEX_FORMAT 5
+#define TEX2_VERTEX_FORMAT 6
+#define TEX3_VERTEX_FORMAT 7
+#define PROJ_TEX3_VERTEX_FORMAT 8
+
+#define DO_XYZW (IND & TRIDENT_XYZW_BIT)
+#define DO_RGBA (IND & TRIDENT_RGBA_BIT)
+#define DO_SPEC (IND & TRIDENT_SPEC_BIT)
+#define DO_FOG (IND & TRIDENT_FOG_BIT)
+#define DO_TEX0 (IND & TRIDENT_TEX0_BIT)
+#define DO_TEX1 (IND & TRIDENT_TEX1_BIT)
+#define DO_TEX2 0
+#define DO_TEX3 0
+#define DO_PTEX (IND & TRIDENT_PTEX_BIT)
+
+#define VERTEX tridentVertex
+#define VERTEX_COLOR trident_color_t
+#define LOCALVARS tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+#define GET_VIEWPORT_MAT() tmesa->hw_viewport
+#define GET_TEXSOURCE(n) tmesa->tmu_source[n]
+#define GET_VERTEX_FORMAT() tmesa->vertex_format
+#define GET_VERTEX_SIZE() tmesa->vertex_size
+#define GET_VERTEX_STORE() tmesa->verts
+#define GET_VERTEX_STRIDE_SHIFT() tmesa->vertex_stride_shift
+#define GET_UBYTE_COLOR_STORE() &tmesa->UbyteColor
+#define GET_UBYTE_SPEC_COLOR_STORE() &tmesa->UbyteSecondaryColor
+
+#define HAVE_HW_VIEWPORT 0
+#define HAVE_HW_DIVIDE 0
+#define HAVE_RGBA_COLOR 0
+#define HAVE_TINY_VERTICES 1
+#define HAVE_NOTEX_VERTICES 1
+#define HAVE_TEX0_VERTICES 1
+#define HAVE_TEX1_VERTICES 1
+#define HAVE_TEX2_VERTICES 0
+#define HAVE_TEX3_VERTICES 0
+#define HAVE_PTEX_VERTICES 0
+
+#define UNVIEWPORT_VARS \
+ const GLfloat dx = - tmesa->drawX - SUBPIXEL_X; \
+ const GLfloat dy = (tmesa->driDrawable->h + \
+ tmesa->drawY + SUBPIXEL_Y); \
+ const GLfloat sz = 1.0 / tmesa->depth_scale
+
+#define UNVIEWPORT_X(x) x + dx;
+#define UNVIEWPORT_Y(y) - y + dy;
+#define UNVIEWPORT_Z(z) z * sz;
+
+#define PTEX_FALLBACK() tridentFallback(TRIDENT_CONTEXT(ctx), TRIDENT_FALLBACK_TEXTURE, 1)
+
+#define IMPORT_FLOAT_COLORS trident_import_float_colors
+#define IMPORT_FLOAT_SPEC_COLORS trident_import_float_spec_colors
+
+#define INTERP_VERTEX setup_tab[tmesa->SetupIndex].interp
+#define COPY_PV_VERTEX setup_tab[tmesa->SetupIndex].copy_pv
+
+/***********************************************************************
+ * Generate pv-copying and translation functions *
+ ***********************************************************************/
+
+#define TAG(x) trident_##x
+#include "tnl_dd/t_dd_vb.c"
+
+/***********************************************************************
+ * Generate vertex emit and interp functions *
+ ***********************************************************************/
+
+#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT)
+#define TAG(x) x##_wg
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT)
+#define TAG(x) x##_wgs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT)
+#define TAG(x) x##_wgt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
+#define TAG(x) x##_wgt0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT|TRIDENT_PTEX_BIT)
+#define TAG(x) x##_wgpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT)
+#define TAG(x) x##_wgst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
+#define TAG(x) x##_wgst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_PTEX_BIT)
+#define TAG(x) x##_wgspt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT)
+#define TAG(x) x##_wgf
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT)
+#define TAG(x) x##_wgfs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT)
+#define TAG(x) x##_wgft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
+#define TAG(x) x##_wgft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT|TRIDENT_PTEX_BIT)
+#define TAG(x) x##_wgfpt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT)
+#define TAG(x) x##_wgfst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
+#define TAG(x) x##_wgfst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_PTEX_BIT)
+#define TAG(x) x##_wgfspt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_TEX0_BIT)
+#define TAG(x) x##_t0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
+#define TAG(x) x##_t0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_FOG_BIT)
+#define TAG(x) x##_f
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT)
+#define TAG(x) x##_ft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
+#define TAG(x) x##_ft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_RGBA_BIT)
+#define TAG(x) x##_g
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT)
+#define TAG(x) x##_gs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT)
+#define TAG(x) x##_gt0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_RGBA_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
+#define TAG(x) x##_gt0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT)
+#define TAG(x) x##_gst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_RGBA_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
+#define TAG(x) x##_gst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT)
+#define TAG(x) x##_gf
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT)
+#define TAG(x) x##_gfs
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT)
+#define TAG(x) x##_gft0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
+#define TAG(x) x##_gft0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT)
+#define TAG(x) x##_gfst0
+#include "tnl_dd/t_dd_vbtmp.h"
+
+#define IND (TRIDENT_RGBA_BIT|TRIDENT_FOG_BIT|TRIDENT_SPEC_BIT|TRIDENT_TEX0_BIT|TRIDENT_TEX1_BIT)
+#define TAG(x) x##_gfst0t1
+#include "tnl_dd/t_dd_vbtmp.h"
+
+static void init_setup_tab( void )
+{
+ init_wg();
+ init_wgs();
+ init_wgt0();
+ init_wgt0t1();
+ init_wgpt0();
+ init_wgst0();
+ init_wgst0t1();
+ init_wgspt0();
+ init_wgf();
+ init_wgfs();
+ init_wgft0();
+ init_wgft0t1();
+ init_wgfpt0();
+ init_wgfst0();
+ init_wgfst0t1();
+ init_wgfspt0();
+ init_t0();
+ init_t0t1();
+ init_f();
+ init_ft0();
+ init_ft0t1();
+ init_g();
+ init_gs();
+ init_gt0();
+ init_gt0t1();
+ init_gst0();
+ init_gst0t1();
+ init_gf();
+ init_gfs();
+ init_gft0();
+ init_gft0t1();
+ init_gfst0();
+ init_gfst0t1();
+}
+
+void tridentBuildVertices( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint newinputs )
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT( ctx );
+ GLubyte *v = ((GLubyte *)tmesa->verts + (start<<tmesa->vertex_stride_shift));
+ GLuint stride = 1<<tmesa->vertex_stride_shift;
+
+ newinputs |= tmesa->SetupNewInputs;
+ tmesa->SetupNewInputs = 0;
+
+ if (!newinputs)
+ return;
+
+ if (newinputs & VERT_BIT_POS) {
+ setup_tab[tmesa->SetupIndex].emit( ctx, start, count, v, stride );
+ } else {
+ GLuint ind = 0;
+
+ if (newinputs & VERT_BIT_COLOR0)
+ ind |= TRIDENT_RGBA_BIT;
+
+ if (newinputs & VERT_BIT_COLOR1)
+ ind |= TRIDENT_SPEC_BIT;
+
+ if (newinputs & VERT_BIT_TEX0)
+ ind |= TRIDENT_TEX0_BIT;
+
+ if (newinputs & VERT_BIT_TEX1)
+ ind |= TRIDENT_TEX1_BIT;
+
+ if (newinputs & VERT_BIT_FOG)
+ ind |= TRIDENT_FOG_BIT;
+
+ if (tmesa->SetupIndex & TRIDENT_PTEX_BIT)
+ ind = ~0;
+
+ ind &= tmesa->SetupIndex;
+
+ if (ind) {
+ setup_tab[ind].emit( ctx, start, count, v, stride );
+ }
+ }
+}
+
+void tridentCheckTexSizes( GLcontext *ctx )
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT( ctx );
+
+ if (!setup_tab[tmesa->SetupIndex].check_tex_sizes(ctx)) {
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ /* Invalidate stored verts
+ */
+ tmesa->SetupNewInputs = ~0;
+ tmesa->SetupIndex |= TRIDENT_PTEX_BIT;
+
+ if (!tmesa->Fallback &&
+ !(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ tnl->Driver.Render.Interp = setup_tab[tmesa->SetupIndex].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[tmesa->SetupIndex].copy_pv;
+ }
+ }
+}
+
+void tridentChooseVertexState( GLcontext *ctx )
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint ind = TRIDENT_XYZW_BIT|TRIDENT_RGBA_BIT;
+
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ ind |= TRIDENT_SPEC_BIT;
+
+ if (ctx->Fog.Enabled)
+ ind |= TRIDENT_FOG_BIT;
+
+ if (ctx->Texture.Unit[0]._ReallyEnabled) {
+ ind |= TRIDENT_TEX0_BIT;
+ if (ctx->Texture.Unit[1]._ReallyEnabled) {
+ ind |= TRIDENT_TEX1_BIT;
+ }
+ }
+
+ tmesa->SetupIndex = ind;
+
+ if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
+ tnl->Driver.Render.Interp = trident_interp_extras;
+ tnl->Driver.Render.CopyPV = trident_copy_pv_extras;
+ } else {
+ tnl->Driver.Render.Interp = setup_tab[ind].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
+ }
+
+ if (setup_tab[ind].vertex_format != tmesa->vertex_format) {
+ tmesa->vertex_format = setup_tab[ind].vertex_format;
+ tmesa->vertex_size = setup_tab[ind].vertex_size;
+ tmesa->vertex_stride_shift = setup_tab[ind].vertex_stride_shift;
+ }
+}
+
+void tridentInitVB( GLcontext *ctx )
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+ GLuint size = TNL_CONTEXT(ctx)->vb.Size;
+
+ tmesa->verts = (char *)ALIGN_MALLOC( size * 16 * 4, 32 );
+
+ {
+ static int firsttime = 1;
+ if (firsttime) {
+ init_setup_tab();
+ firsttime = 0;
+ }
+ }
+}
+
+void tridentFreeVB( GLcontext *ctx )
+{
+ tridentContextPtr tmesa = TRIDENT_CONTEXT(ctx);
+
+ if (tmesa->verts) {
+ ALIGN_FREE(tmesa->verts);
+ tmesa->verts = 0;
+ }
+
+ if (tmesa->UbyteSecondaryColor.Ptr) {
+ ALIGN_FREE((void *)tmesa->UbyteSecondaryColor.Ptr);
+ tmesa->UbyteSecondaryColor.Ptr = 0;
+ }
+
+ if (tmesa->UbyteColor.Ptr) {
+ ALIGN_FREE((void *)tmesa->UbyteColor.Ptr);
+ tmesa->UbyteColor.Ptr = 0;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/Makefile
new file mode 100644
index 000000000..5fe00c1bd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/Makefile
@@ -0,0 +1,32 @@
+# src/mesa/drivers/dri/unichrome/Makefile
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = unichrome_dri.so
+
+MINIGLX_SOURCES = server/via_dri.c
+
+DRIVER_SOURCES = \
+ via_context.c \
+ via_fb.c \
+ via_tex.c \
+ via_ioctl.c \
+ via_memcpy.c \
+ via_render.c \
+ via_screen.c \
+ via_span.c \
+ via_state.c \
+ via_texcombine.c \
+ via_tris.c
+
+C_SOURCES = \
+ $(COMMON_SOURCES) \
+ $(DRIVER_SOURCES)
+
+ASM_SOURCES =
+
+
+include ../Makefile.template
+
+symlinks:
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via.h
new file mode 100644
index 000000000..2cfe6631e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via.h
@@ -0,0 +1,11 @@
+#ifndef __VIA_H__
+#define __VIA_H__
+
+typedef struct VIAInfo
+{
+ size_t registerSize;
+ void * registerHandle;
+ void * data;
+} * VIAInfoPtr;
+
+#endif /* __VIA_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_dri.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_dri.c
new file mode 100644
index 000000000..d7217d205
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_dri.c
@@ -0,0 +1,1252 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_dri.c,v 1.4 2003/09/24 02:43:30 dawes Exp $ */
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include "driver.h"
+#include "drm.h"
+#include "imports.h"
+
+#include "dri_util.h"
+
+#include "via_context.h"
+#include "via_dri.h"
+#include "via_driver.h"
+#include "via_common.h"
+#include "xf86drm.h"
+
+static void VIAEnableMMIO(DRIDriverContext * ctx);
+static void VIADisableMMIO(DRIDriverContext * ctx);
+static void VIADisableExtendedFIFO(DRIDriverContext *ctx);
+static void VIAEnableExtendedFIFO(DRIDriverContext *ctx);
+static void VIAInitialize2DEngine(DRIDriverContext *ctx);
+static void VIAInitialize3DEngine(DRIDriverContext *ctx);
+
+static int VIADRIScreenInit(DRIDriverContext * ctx);
+static void VIADRICloseScreen(DRIDriverContext * ctx);
+static int VIADRIFinishScreenInit(DRIDriverContext * ctx);
+
+/* _SOLO : missing macros normally defined by X code */
+#define xf86DrvMsg(a, b, ...) fprintf(stderr, __VA_ARGS__)
+#define MMIO_IN8(base, addr) ((*(((volatile u_int8_t*)base)+(addr)))+0)
+#define MMIO_OUT8(base, addr, val) ((*(((volatile u_int8_t*)base)+(addr)))=((u_int8_t)val))
+#define MMIO_OUT16(base, addr, val) ((*(volatile u_int16_t*)(((u_int8_t*)base)+(addr)))=((u_int16_t)val))
+
+#define VIDEO 0
+#define AGP 1
+#define AGP_PAGE_SIZE 4096
+#define AGP_PAGES 8192
+#define AGP_SIZE (AGP_PAGE_SIZE * AGP_PAGES)
+#define AGP_CMDBUF_PAGES 512
+#define AGP_CMDBUF_SIZE (AGP_PAGE_SIZE * AGP_CMDBUF_PAGES)
+
+static char VIAKernelDriverName[] = "via";
+static char VIAClientDriverName[] = "unichrome";
+
+static int VIADRIAgpInit(const DRIDriverContext *ctx, VIAPtr pVia);
+static int VIADRIPciInit(DRIDriverContext * ctx, VIAPtr pVia);
+static int VIADRIFBInit(DRIDriverContext * ctx, VIAPtr pVia);
+static int VIADRIKernelInit(DRIDriverContext * ctx, VIAPtr pVia);
+static int VIADRIMapInit(DRIDriverContext * ctx, VIAPtr pVia);
+
+static void VIADRIIrqInit( DRIDriverContext *ctx )
+{
+ VIAPtr pVia = VIAPTR(ctx);
+ VIADRIPtr pVIADRI = pVia->devPrivate;
+
+ pVIADRI->irqEnabled = drmGetInterruptFromBusID(pVia->drmFD,
+ ctx->pciBus,
+ ctx->pciDevice,
+ ctx->pciFunc);
+
+ if ((drmCtlInstHandler(pVia->drmFD, pVIADRI->irqEnabled))) {
+ xf86DrvMsg(pScreen->myNum, X_WARNING,
+ "[drm] Failure adding irq handler. "
+ "Falling back to irq-free operation.\n");
+ pVIADRI->irqEnabled = 0;
+ }
+
+ if (pVIADRI->irqEnabled)
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] Irq handler installed, using IRQ %d.\n",
+ pVIADRI->irqEnabled);
+}
+
+static void VIADRIIrqExit( DRIDriverContext *ctx ) {
+ VIAPtr pVia = VIAPTR(ctx);
+ VIADRIPtr pVIADRI = pVia->devPrivate;
+
+ if (pVIADRI->irqEnabled) {
+ if (drmCtlUninstHandler(pVia->drmFD)) {
+ xf86DrvMsg(pScreen-myNum, X_INFO,"[drm] Irq handler uninstalled.\n");
+ } else {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] Could not uninstall irq handler.\n");
+ }
+ }
+}
+
+static void VIADRIRingBufferCleanup(DRIDriverContext *ctx)
+{
+ VIAPtr pVia = VIAPTR(ctx);
+ VIADRIPtr pVIADRI = pVia->devPrivate;
+ drm_via_dma_init_t ringBufInit;
+
+ if (pVIADRI->ringBufActive) {
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] Cleaning up DMA ring-buffer.\n");
+ ringBufInit.func = VIA_CLEANUP_DMA;
+ if (drmCommandWrite(pVia->drmFD, DRM_VIA_DMA_INIT, &ringBufInit,
+ sizeof(ringBufInit))) {
+ xf86DrvMsg(pScreen->myNum, X_WARNING,
+ "[drm] Failed to clean up DMA ring-buffer: %d\n", errno);
+ }
+ pVIADRI->ringBufActive = 0;
+ }
+}
+
+static int VIADRIRingBufferInit(DRIDriverContext *ctx)
+{
+ VIAPtr pVia = VIAPTR(ctx);
+ VIADRIPtr pVIADRI = pVia->devPrivate;
+ drm_via_dma_init_t ringBufInit;
+ drmVersionPtr drmVer;
+
+ pVIADRI->ringBufActive = 0;
+
+ if (NULL == (drmVer = drmGetVersion(pVia->drmFD))) {
+ return GL_FALSE;
+ }
+
+ if (((drmVer->version_major <= 1) && (drmVer->version_minor <= 3))) {
+ return GL_FALSE;
+ }
+
+ /*
+ * Info frome code-snippet on DRI-DEVEL list; Erdi Chen.
+ */
+
+ switch (pVia->ChipId) {
+ case PCI_CHIP_VT3259:
+ ringBufInit.reg_pause_addr = 0x40c;
+ break;
+ default:
+ ringBufInit.reg_pause_addr = 0x418;
+ break;
+ }
+
+ ringBufInit.offset = pVia->agpSize;
+ ringBufInit.size = AGP_CMDBUF_SIZE;
+ ringBufInit.func = VIA_INIT_DMA;
+ if (drmCommandWrite(pVia->drmFD, DRM_VIA_DMA_INIT, &ringBufInit,
+ sizeof(ringBufInit))) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] Failed to initialize DMA ring-buffer: %d\n", errno);
+ return GL_FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] Initialized AGP ring-buffer, size 0x%lx at AGP offset 0x%lx.\n",
+ ringBufInit.size, ringBufInit.offset);
+
+ pVIADRI->ringBufActive = 1;
+ return GL_TRUE;
+}
+
+static int VIADRIAgpInit(const DRIDriverContext *ctx, VIAPtr pVia)
+{
+ unsigned long agp_phys;
+ drmAddress agpaddr;
+ VIADRIPtr pVIADRI;
+ pVIADRI = pVia->devPrivate;
+ pVia->agpSize = 0;
+
+ if (drmAgpAcquire(pVia->drmFD) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpAcquire failed %d\n", errno);
+ return GL_FALSE;
+ }
+
+ if (drmAgpEnable(pVia->drmFD, drmAgpGetMode(pVia->drmFD)&~0x0) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpEnable failed\n");
+ return GL_FALSE;
+ }
+
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] drmAgpEnabled succeeded\n");
+
+ if (drmAgpAlloc(pVia->drmFD, AGP_SIZE, 0, &agp_phys, &pVia->agpHandle) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] drmAgpAlloc failed\n");
+ drmAgpRelease(pVia->drmFD);
+ return GL_FALSE;
+ }
+
+ if (drmAgpBind(pVia->drmFD, pVia->agpHandle, 0) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] drmAgpBind failed\n");
+ drmAgpFree(pVia->drmFD, pVia->agpHandle);
+ drmAgpRelease(pVia->drmFD);
+
+ return GL_FALSE;
+ }
+
+ /*
+ * Place the ring-buffer last in the AGP region, and restrict the
+ * public map not to include the buffer for security reasons.
+ */
+
+ pVia->agpSize = AGP_SIZE - AGP_CMDBUF_SIZE;
+ pVia->agpAddr = drmAgpBase(pVia->drmFD);
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] agpAddr = 0x%08lx\n",pVia->agpAddr);
+
+ pVIADRI->agp.size = pVia->agpSize;
+ if (drmAddMap(pVia->drmFD, (drm_handle_t)0,
+ pVIADRI->agp.size, DRM_AGP, 0,
+ &pVIADRI->agp.handle) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] Failed to map public agp area\n");
+ pVIADRI->agp.size = 0;
+ return GL_FALSE;
+ }
+ /* Map AGP from kernel to Xserver - Not really needed */
+ drmMap(pVia->drmFD, pVIADRI->agp.handle,pVIADRI->agp.size, &agpaddr);
+
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] agpAddr = 0x%08lx\n", pVia->agpAddr);
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] agpSize = 0x%08lx\n", pVia->agpSize);
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] agp physical addr = 0x%08lx\n", agp_phys);
+
+ {
+ drm_via_agp_t agp;
+ agp.offset = 0;
+ agp.size = AGP_SIZE-AGP_CMDBUF_SIZE;
+ if (drmCommandWrite(pVia->drmFD, DRM_VIA_AGP_INIT, &agp,
+ sizeof(drm_via_agp_t)) < 0) {
+ drmUnmap(&agpaddr,pVia->agpSize);
+ drmRmMap(pVia->drmFD,pVIADRI->agp.handle);
+ drmAgpUnbind(pVia->drmFD, pVia->agpHandle);
+ drmAgpFree(pVia->drmFD, pVia->agpHandle);
+ drmAgpRelease(pVia->drmFD);
+ return GL_FALSE;
+ }
+ }
+
+ return GL_TRUE;
+}
+
+static int VIADRIFBInit(DRIDriverContext * ctx, VIAPtr pVia)
+{
+ int FBSize = pVia->FBFreeEnd-pVia->FBFreeStart;
+ int FBOffset = pVia->FBFreeStart;
+ VIADRIPtr pVIADRI = pVia->devPrivate;
+ pVIADRI->fbOffset = FBOffset;
+ pVIADRI->fbSize = pVia->videoRambytes;
+
+ {
+ drm_via_fb_t fb;
+ fb.offset = FBOffset;
+ fb.size = FBSize;
+
+ if (drmCommandWrite(pVia->drmFD, DRM_VIA_FB_INIT, &fb,
+ sizeof(drm_via_fb_t)) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] failed to init frame buffer area\n");
+ return GL_FALSE;
+ } else {
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] FBFreeStart= 0x%08x FBFreeEnd= 0x%08x "
+ "FBSize= 0x%08x\n",
+ pVia->FBFreeStart, pVia->FBFreeEnd, FBSize);
+ return GL_TRUE;
+ }
+ }
+}
+
+static int VIADRIPciInit(DRIDriverContext * ctx, VIAPtr pVia)
+{
+ return GL_TRUE;
+}
+
+static int VIADRIScreenInit(DRIDriverContext * ctx)
+{
+ VIAPtr pVia = VIAPTR(ctx);
+ VIADRIPtr pVIADRI;
+ int err;
+
+#if 0
+ ctx->shared.SAREASize = ((sizeof(drm_sarea_t) + 0xfff) & 0x1000);
+#else
+ if (sizeof(drm_sarea_t)+sizeof(drm_via_sarea_t) > SAREA_MAX) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Data does not fit in SAREA\n");
+ return GL_FALSE;
+ }
+ ctx->shared.SAREASize = SAREA_MAX;
+#endif
+
+ ctx->drmFD = drmOpen(VIAKernelDriverName, NULL);
+ if (ctx->drmFD < 0) {
+ fprintf(stderr, "[drm] drmOpen failed\n");
+ return 0;
+ }
+ pVia->drmFD = ctx->drmFD;
+
+ err = drmSetBusid(ctx->drmFD, ctx->pciBusID);
+ if (err < 0) {
+ fprintf(stderr, "[drm] drmSetBusid failed (%d, %s), %s\n",
+ ctx->drmFD, ctx->pciBusID, strerror(-err));
+ return 0;
+ }
+
+ err = drmAddMap(ctx->drmFD, 0, ctx->shared.SAREASize, DRM_SHM,
+ DRM_CONTAINS_LOCK, &ctx->shared.hSAREA);
+ if (err < 0) {
+ fprintf(stderr, "[drm] drmAddMap failed\n");
+ return 0;
+ }
+ fprintf(stderr, "[drm] added %d byte SAREA at 0x%08lx\n",
+ ctx->shared.SAREASize, ctx->shared.hSAREA);
+
+ if (drmMap(ctx->drmFD,
+ ctx->shared.hSAREA,
+ ctx->shared.SAREASize,
+ (drmAddressPtr)(&ctx->pSAREA)) < 0)
+ {
+ fprintf(stderr, "[drm] drmMap failed\n");
+ return 0;
+ }
+ memset(ctx->pSAREA, 0, ctx->shared.SAREASize);
+ fprintf(stderr, "[drm] mapped SAREA 0x%08lx to %p, size %d\n",
+ ctx->shared.hSAREA, ctx->pSAREA, ctx->shared.SAREASize);
+
+ /* Need to AddMap the framebuffer and mmio regions here:
+ */
+ if (drmAddMap(ctx->drmFD,
+ (drm_handle_t)ctx->FBStart,
+ ctx->FBSize,
+ DRM_FRAME_BUFFER,
+#ifndef _EMBEDDED
+ 0,
+#else
+ DRM_READ_ONLY,
+#endif
+ &ctx->shared.hFrameBuffer) < 0)
+ {
+ fprintf(stderr, "[drm] drmAddMap framebuffer failed\n");
+ return 0;
+ }
+
+ fprintf(stderr, "[drm] framebuffer handle = 0x%08lx\n",
+ ctx->shared.hFrameBuffer);
+
+ pVIADRI = (VIADRIPtr) CALLOC(sizeof(VIADRIRec));
+ if (!pVIADRI) {
+ drmClose(ctx->drmFD);
+ return GL_FALSE;
+ }
+ pVia->devPrivate = pVIADRI;
+ ctx->driverClientMsg = pVIADRI;
+ ctx->driverClientMsgSize = sizeof(*pVIADRI);
+
+ /* DRIScreenInit doesn't add all the common mappings. Add additional mappings here. */
+ if (!VIADRIMapInit(ctx, pVia)) {
+ VIADRICloseScreen(ctx);
+ return GL_FALSE;
+ }
+
+ pVIADRI->regs.size = VIA_MMIO_REGSIZE;
+ pVIADRI->regs.handle = pVia->registerHandle;
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] mmio Registers = 0x%08lx\n",
+ pVIADRI->regs.handle);
+
+ if (drmMap(pVia->drmFD,
+ pVIADRI->regs.handle,
+ pVIADRI->regs.size,
+ (drmAddress *)&pVia->MapBase) != 0)
+ {
+ VIADRICloseScreen(ctx);
+ return GL_FALSE;
+ }
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[dri] mmio mapped.\n" );
+
+ VIAEnableMMIO(ctx);
+
+ /* Get video memory clock. */
+ VGAOUT8(0x3D4, 0x3D);
+ pVia->MemClk = (VGAIN8(0x3D5) & 0xF0) >> 4;
+ xf86DrvMsg(0, X_INFO, "[dri] MemClk (0x%x)\n", pVia->MemClk);
+
+ /* 3D rendering has noise if not enabled. */
+ VIAEnableExtendedFIFO(ctx);
+
+ VIAInitialize2DEngine(ctx);
+
+ /* Must disable MMIO or 3D won't work. */
+ VIADisableMMIO(ctx);
+
+ VIAInitialize3DEngine(ctx);
+
+ pVia->IsPCI = !VIADRIAgpInit(ctx, pVia);
+
+ if (pVia->IsPCI) {
+ VIADRIPciInit(ctx, pVia);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[dri] use pci.\n" );
+ }
+ else
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[dri] use agp.\n" );
+
+ if (!(VIADRIFBInit(ctx, pVia))) {
+ VIADRICloseScreen(ctx);
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[dri] frame buffer initialize fail .\n" );
+ return GL_FALSE;
+ }
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[dri] frame buffer initialized.\n" );
+
+ return VIADRIFinishScreenInit(ctx);
+}
+
+static void
+VIADRICloseScreen(DRIDriverContext * ctx)
+{
+ VIAPtr pVia = VIAPTR(ctx);
+ VIADRIPtr pVIADRI=(VIADRIPtr)pVia->devPrivate;
+
+ VIADRIRingBufferCleanup(ctx);
+
+ if (pVia->MapBase) {
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Unmapping MMIO registers\n");
+ drmUnmap(pVia->MapBase, pVIADRI->regs.size);
+ }
+
+ if (pVia->agpSize) {
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Freeing agp memory\n");
+ drmAgpFree(pVia->drmFD, pVia->agpHandle);
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Releasing agp module\n");
+ drmAgpRelease(pVia->drmFD);
+ }
+
+#if 0
+ if (pVia->DRIIrqEnable)
+#endif
+ VIADRIIrqExit(ctx);
+}
+
+static int
+VIADRIFinishScreenInit(DRIDriverContext * ctx)
+{
+ VIAPtr pVia = VIAPTR(ctx);
+ VIADRIPtr pVIADRI;
+ int err;
+
+ err = drmCreateContext(ctx->drmFD, &ctx->serverContext);
+ if (err != 0) {
+ fprintf(stderr, "%s: drmCreateContext failed %d\n", __FUNCTION__, err);
+ return GL_FALSE;
+ }
+
+ DRM_LOCK(ctx->drmFD, ctx->pSAREA, ctx->serverContext, 0);
+
+
+ if (!VIADRIKernelInit(ctx, pVia)) {
+ VIADRICloseScreen(ctx);
+ return GL_FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[dri] kernel data initialized.\n");
+
+ /* set SAREA value */
+ {
+ drm_via_sarea_t *saPriv;
+
+ saPriv=(drm_via_sarea_t*)(((char*)ctx->pSAREA) +
+ sizeof(drm_sarea_t));
+ assert(saPriv);
+ memset(saPriv, 0, sizeof(*saPriv));
+ saPriv->ctxOwner = -1;
+ }
+ pVIADRI=(VIADRIPtr)pVia->devPrivate;
+ pVIADRI->deviceID=pVia->Chipset;
+ pVIADRI->width=ctx->shared.virtualWidth;
+ pVIADRI->height=ctx->shared.virtualHeight;
+ pVIADRI->mem=ctx->shared.fbSize;
+ pVIADRI->bytesPerPixel= (ctx->bpp+7) / 8;
+ pVIADRI->sarea_priv_offset = sizeof(drm_sarea_t);
+ /* TODO */
+ pVIADRI->scrnX=pVIADRI->width;
+ pVIADRI->scrnY=pVIADRI->height;
+
+ /* Initialize IRQ */
+#if 0
+ if (pVia->DRIIrqEnable)
+#endif
+ VIADRIIrqInit(ctx);
+
+ pVIADRI->ringBufActive = 0;
+ VIADRIRingBufferInit(ctx);
+
+ return GL_TRUE;
+}
+
+/* Initialize the kernel data structures. */
+static int VIADRIKernelInit(DRIDriverContext * ctx, VIAPtr pVia)
+{
+ drm_via_init_t drmInfo;
+ memset(&drmInfo, 0, sizeof(drm_via_init_t));
+ drmInfo.sarea_priv_offset = sizeof(drm_sarea_t);
+ drmInfo.func = VIA_INIT_MAP;
+ drmInfo.fb_offset = pVia->FrameBufferBase;
+ drmInfo.mmio_offset = pVia->registerHandle;
+ if (pVia->IsPCI)
+ drmInfo.agpAddr = (u_int32_t)NULL;
+ else
+ drmInfo.agpAddr = (u_int32_t)pVia->agpAddr;
+
+ if ((drmCommandWrite(pVia->drmFD, DRM_VIA_MAP_INIT,&drmInfo,
+ sizeof(drm_via_init_t))) < 0)
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+/* Add a map for the MMIO registers */
+static int VIADRIMapInit(DRIDriverContext * ctx, VIAPtr pVia)
+{
+ int flags = 0;
+
+ if (drmAddMap(pVia->drmFD, pVia->MmioBase, VIA_MMIO_REGSIZE,
+ DRM_REGISTERS, flags, &pVia->registerHandle) < 0) {
+ return GL_FALSE;
+ }
+
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] register handle = 0x%08lx\n", pVia->registerHandle);
+
+ return GL_TRUE;
+}
+
+static int viaValidateMode(const DRIDriverContext *ctx)
+{
+ VIAPtr pVia = VIAPTR(ctx);
+
+ return 1;
+}
+
+static int viaPostValidateMode(const DRIDriverContext *ctx)
+{
+ VIAPtr pVia = VIAPTR(ctx);
+
+ return 1;
+}
+
+static void VIAEnableMMIO(DRIDriverContext * ctx)
+{
+ /*vgaHWPtr hwp = VGAHWPTR(ctx);*/
+ VIAPtr pVia = VIAPTR(ctx);
+ unsigned char val;
+
+#if 0
+ if (xf86IsPrimaryPci(pVia->PciInfo)) {
+ /* If we are primary card, we still use std vga port. If we use
+ * MMIO, system will hang in vgaHWSave when our card used in
+ * PLE and KLE (integrated Trident MVP4)
+ */
+ vgaHWSetStdFuncs(hwp);
+ }
+ else {
+ vgaHWSetMmioFuncs(hwp, pVia->MapBase, 0x8000);
+ }
+#endif
+
+ val = VGAIN8(0x3c3);
+ VGAOUT8(0x3c3, val | 0x01);
+ val = VGAIN8(0x3cc);
+ VGAOUT8(0x3c2, val | 0x01);
+
+ /* Unlock Extended IO Space */
+ VGAOUT8(0x3c4, 0x10);
+ VGAOUT8(0x3c5, 0x01);
+
+ /* Enable MMIO */
+ if(!pVia->IsSecondary) {
+ VGAOUT8(0x3c4, 0x1a);
+ val = VGAIN8(0x3c5);
+#ifdef DEBUG
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "primary val = %x\n", val);
+#endif
+ VGAOUT8(0x3c5, val | 0x68);
+ }
+ else {
+ VGAOUT8(0x3c4, 0x1a);
+ val = VGAIN8(0x3c5);
+#ifdef DEBUG
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "secondary val = %x\n", val);
+#endif
+ VGAOUT8(0x3c5, val | 0x38);
+ }
+
+ /* Unlock CRTC registers */
+ VGAOUT8(0x3d4, 0x47);
+ VGAOUT8(0x3d5, 0x00);
+
+ return;
+}
+
+static void VIADisableMMIO(DRIDriverContext * ctx)
+{
+ VIAPtr pVia = VIAPTR(ctx);
+ unsigned char val;
+
+ VGAOUT8(0x3c4, 0x1a);
+ val = VGAIN8(0x3c5);
+ VGAOUT8(0x3c5, val & 0x97);
+
+ return;
+}
+
+static void VIADisableExtendedFIFO(DRIDriverContext *ctx)
+{
+ VIAPtr pVia = VIAPTR(ctx);
+ u_int32_t dwGE230, dwGE298;
+
+ /* Cause of exit XWindow will dump back register value, others chipset no
+ * need to set extended fifo value */
+ if (pVia->Chipset == VIA_CLE266 && pVia->ChipRev < 15 &&
+ (ctx->shared.virtualWidth > 1024 || pVia->HasSecondary)) {
+ /* Turn off Extend FIFO */
+ /* 0x298[29] */
+ dwGE298 = VIAGETREG(0x298);
+ VIASETREG(0x298, dwGE298 | 0x20000000);
+ /* 0x230[21] */
+ dwGE230 = VIAGETREG(0x230);
+ VIASETREG(0x230, dwGE230 & ~0x00200000);
+ /* 0x298[29] */
+ dwGE298 = VIAGETREG(0x298);
+ VIASETREG(0x298, dwGE298 & ~0x20000000);
+ }
+}
+
+static void VIAEnableExtendedFIFO(DRIDriverContext *ctx)
+{
+ VIAPtr pVia = VIAPTR(ctx);
+ u_int8_t bRegTemp;
+ u_int32_t dwGE230, dwGE298;
+
+ switch (pVia->Chipset) {
+ case VIA_CLE266:
+ if (pVia->ChipRev > 14) { /* For 3123Cx */
+ if (pVia->HasSecondary) { /* SAMM or DuoView case */
+ if (ctx->shared.virtualWidth >= 1024)
+ {
+ /* 3c5.16[0:5] */
+ VGAOUT8(0x3C4, 0x16);
+ bRegTemp = VGAIN8(0x3C5);
+ bRegTemp &= ~0x3F;
+ bRegTemp |= 0x1C;
+ VGAOUT8(0x3C5, bRegTemp);
+ /* 3c5.17[0:6] */
+ VGAOUT8(0x3C4, 0x17);
+ bRegTemp = VGAIN8(0x3C5);
+ bRegTemp &= ~0x7F;
+ bRegTemp |= 0x3F;
+ VGAOUT8(0x3C5, bRegTemp);
+ pVia->EnableExtendedFIFO = GL_TRUE;
+ }
+ }
+ else /* Single view or Simultaneoue case */
+ {
+ if (ctx->shared.virtualWidth > 1024)
+ {
+ /* 3c5.16[0:5] */
+ VGAOUT8(0x3C4, 0x16);
+ bRegTemp = VGAIN8(0x3C5);
+ bRegTemp &= ~0x3F;
+ bRegTemp |= 0x17;
+ VGAOUT8(0x3C5, bRegTemp);
+ /* 3c5.17[0:6] */
+ VGAOUT8(0x3C4, 0x17);
+ bRegTemp = VGAIN8(0x3C5);
+ bRegTemp &= ~0x7F;
+ bRegTemp |= 0x2F;
+ VGAOUT8(0x3C5, bRegTemp);
+ pVia->EnableExtendedFIFO = GL_TRUE;
+ }
+ }
+ /* 3c5.18[0:5] */
+ VGAOUT8(0x3C4, 0x18);
+ bRegTemp = VGAIN8(0x3C5);
+ bRegTemp &= ~0x3F;
+ bRegTemp |= 0x17;
+ bRegTemp |= 0x40; /* force the preq always higher than treq */
+ VGAOUT8(0x3C5, bRegTemp);
+ }
+ else { /* for 3123Ax */
+ if (ctx->shared.virtualWidth > 1024 || pVia->HasSecondary) {
+ /* Turn on Extend FIFO */
+ /* 0x298[29] */
+ dwGE298 = VIAGETREG(0x298);
+ VIASETREG(0x298, dwGE298 | 0x20000000);
+ /* 0x230[21] */
+ dwGE230 = VIAGETREG(0x230);
+ VIASETREG(0x230, dwGE230 | 0x00200000);
+ /* 0x298[29] */
+ dwGE298 = VIAGETREG(0x298);
+ VIASETREG(0x298, dwGE298 & ~0x20000000);
+
+ /* 3c5.16[0:5] */
+ VGAOUT8(0x3C4, 0x16);
+ bRegTemp = VGAIN8(0x3C5);
+ bRegTemp &= ~0x3F;
+ bRegTemp |= 0x17;
+ /* bRegTemp |= 0x10; */
+ VGAOUT8(0x3C5, bRegTemp);
+ /* 3c5.17[0:6] */
+ VGAOUT8(0x3C4, 0x17);
+ bRegTemp = VGAIN8(0x3C5);
+ bRegTemp &= ~0x7F;
+ bRegTemp |= 0x2F;
+ /*bRegTemp |= 0x1F;*/
+ VGAOUT8(0x3C5, bRegTemp);
+ /* 3c5.18[0:5] */
+ VGAOUT8(0x3C4, 0x18);
+ bRegTemp = VGAIN8(0x3C5);
+ bRegTemp &= ~0x3F;
+ bRegTemp |= 0x17;
+ bRegTemp |= 0x40; /* force the preq always higher than treq */
+ VGAOUT8(0x3C5, bRegTemp);
+ pVia->EnableExtendedFIFO = GL_TRUE;
+ }
+ }
+ break;
+ case VIA_KM400:
+ if (pVia->HasSecondary) { /* SAMM or DuoView case */
+ if ((ctx->shared.virtualWidth >= 1600) &&
+ (pVia->MemClk <= VIA_MEM_DDR200)) {
+ /* enable CRT extendded FIFO */
+ VGAOUT8(0x3C4, 0x17);
+ VGAOUT8(0x3C5, 0x1C);
+ /* revise second display queue depth and read threshold */
+ VGAOUT8(0x3C4, 0x16);
+ bRegTemp = VGAIN8(0x3C5);
+ bRegTemp &= ~0x3F;
+ bRegTemp = (bRegTemp) | (0x09);
+ VGAOUT8(0x3C5, bRegTemp);
+ }
+ else {
+ /* enable CRT extendded FIFO */
+ VGAOUT8(0x3C4, 0x17);
+ VGAOUT8(0x3C5,0x3F);
+ /* revise second display queue depth and read threshold */
+ VGAOUT8(0x3C4, 0x16);
+ bRegTemp = VGAIN8(0x3C5);
+ bRegTemp &= ~0x3F;
+ bRegTemp = (bRegTemp) | (0x1C);
+ VGAOUT8(0x3C5, bRegTemp);
+ }
+ /* 3c5.18[0:5] */
+ VGAOUT8(0x3C4, 0x18);
+ bRegTemp = VGAIN8(0x3C5);
+ bRegTemp &= ~0x3F;
+ bRegTemp |= 0x17;
+ bRegTemp |= 0x40; /* force the preq always higher than treq */
+ VGAOUT8(0x3C5, bRegTemp);
+ pVia->EnableExtendedFIFO = GL_TRUE;
+ }
+ else {
+ if ( (ctx->shared.virtualWidth > 1024) && (ctx->shared.virtualWidth <= 1280) )
+ {
+ /* enable CRT extendded FIFO */
+ VGAOUT8(0x3C4, 0x17);
+ VGAOUT8(0x3C5, 0x3F);
+ /* revise second display queue depth and read threshold */
+ VGAOUT8(0x3C4, 0x16);
+ bRegTemp = VGAIN8(0x3C5);
+ bRegTemp &= ~0x3F;
+ bRegTemp = (bRegTemp) | (0x17);
+ VGAOUT8(0x3C5, bRegTemp);
+ pVia->EnableExtendedFIFO = GL_TRUE;
+ }
+ else if ((ctx->shared.virtualWidth > 1280))
+ {
+ /* enable CRT extendded FIFO */
+ VGAOUT8(0x3C4, 0x17);
+ VGAOUT8(0x3C5, 0x3F);
+ /* revise second display queue depth and read threshold */
+ VGAOUT8(0x3C4, 0x16);
+ bRegTemp = VGAIN8(0x3C5);
+ bRegTemp &= ~0x3F;
+ bRegTemp = (bRegTemp) | (0x1C);
+ VGAOUT8(0x3C5, bRegTemp);
+ pVia->EnableExtendedFIFO = GL_TRUE;
+ }
+ else
+ {
+ /* enable CRT extendded FIFO */
+ VGAOUT8(0x3C4, 0x17);
+ VGAOUT8(0x3C5, 0x3F);
+ /* revise second display queue depth and read threshold */
+ VGAOUT8(0x3C4, 0x16);
+ bRegTemp = VGAIN8(0x3C5);
+ bRegTemp &= ~0x3F;
+ bRegTemp = (bRegTemp) | (0x10);
+ VGAOUT8(0x3C5, bRegTemp);
+ }
+ /* 3c5.18[0:5] */
+ VGAOUT8(0x3C4, 0x18);
+ bRegTemp = VGAIN8(0x3C5);
+ bRegTemp &= ~0x3F;
+ bRegTemp |= 0x17;
+ bRegTemp |= 0x40; /* force the preq always higher than treq */
+ VGAOUT8(0x3C5, bRegTemp);
+ }
+ break;
+ case VIA_K8M800:
+ /*=* R1 Display FIFO depth (384 /8 -1 -> 0xbf) SR17[7:0] (8bits) *=*/
+ VGAOUT8(0x3c4, 0x17);
+ VGAOUT8(0x3c5, 0xbf);
+
+ /*=* R2 Display fetch datum threshold value (328/4 -> 0x52)
+ SR16[5:0], SR16[7] (7bits) *=*/
+ VGAOUT8(0x3c4, 0x16);
+ bRegTemp = VGAIN8(0x3c5) & ~0xBF;
+ bRegTemp |= (0x52 & 0x3F);
+ bRegTemp |= ((0x52 & 0x40) << 1);
+ VGAOUT8(0x3c5, bRegTemp);
+
+ /*=* R3 Switch to the highest agent threshold value (74 -> 0x4a)
+ SR18[5:0], SR18[7] (7bits) *=*/
+ VGAOUT8(0x3c4, 0x18);
+ bRegTemp = VGAIN8(0x3c5) & ~0xBF;
+ bRegTemp |= (0x4a & 0x3F);
+ bRegTemp |= ((0x4a & 0x40) << 1);
+ VGAOUT8(0x3c5, bRegTemp);
+#if 0
+ /*=* R4 Fetch Number for a scan line (unit: 8 bytes)
+ SR1C[7:0], SR1D[1:0] (10bits) *=*/
+ wRegTemp = (pBIOSInfo->offsetWidthByQWord >> 1) + 4;
+ VGAOUT8(0x3c4, 0x1c);
+ VGAOUT8(0x3c5, (u_int8_t)(wRegTemp & 0xFF));
+ VGAOUT8(0x3c4, 0x1d);
+ bRegTemp = VGAIN8(0x3c5) & ~0x03;
+ VGAOUT8(0x3c5, bRegTemp | ((wRegTemp & 0x300) >> 8));
+#endif
+ if (ctx->shared.virtualWidth >= 1400 && ctx->bpp == 32)
+ {
+ /*=* Max. length for a request SR22[4:0] (64/4 -> 0x10) *=*/
+ VGAOUT8(0x3c4, 0x22);
+ bRegTemp = VGAIN8(0x3c5) & ~0x1F;
+ VGAOUT8(0x3c5, bRegTemp | 0x10);
+ }
+ else
+ {
+ /*=* Max. length for a request SR22[4:0]
+ (128/4 -> over flow 0x0) *=*/
+ VGAOUT8(0x3c4, 0x22);
+ bRegTemp = VGAIN8(0x3c5) & ~0x1F;
+ VGAOUT8(0x3c5, bRegTemp);
+ }
+ break;
+ case VIA_PM800:
+ /*=* R1 Display FIFO depth (96-1 -> 0x5f) SR17[7:0] (8bits) *=*/
+ VGAOUT8(0x3c4, 0x17);
+ VGAOUT8(0x3c5, 0x5f);
+
+ /*=* R2 Display fetch datum threshold value (32 -> 0x20)
+ SR16[5:0], SR16[7] (7bits) *=*/
+ VGAOUT8(0x3c4, 0x16);
+ bRegTemp = VGAIN8(0x3c5) & ~0xBF;
+ bRegTemp |= (0x20 & 0x3F);
+ bRegTemp |= ((0x20 & 0x40) << 1);
+ VGAOUT8(0x3c5, bRegTemp);
+
+ /*=* R3 Switch to the highest agent threshold value (16 -> 0x10)
+ SR18[5:0], SR18[7] (7bits) *=*/
+ VGAOUT8(0x3c4, 0x18);
+ bRegTemp = VGAIN8(0x3c5) & ~0xBF;
+ bRegTemp |= (0x10 & 0x3F);
+ bRegTemp |= ((0x10 & 0x40) << 1);
+ VGAOUT8(0x3c5, bRegTemp);
+#if 0
+ /*=* R4 Fetch Number for a scan line (unit: 8 bytes)
+ SR1C[7:0], SR1D[1:0] (10bits) *=*/
+ wRegTemp = (pBIOSInfo->offsetWidthByQWord >> 1) + 4;
+ VGAOUT8(0x3c4, 0x1c);
+ VGAOUT8(0x3c5, (u_int8_t)(wRegTemp & 0xFF));
+ VGAOUT8(0x3c4, 0x1d);
+ bRegTemp = VGAIN8(0x3c5) & ~0x03;
+ VGAOUT8(0x3c5, bRegTemp | ((wRegTemp & 0x300) >> 8));
+#endif
+ if (ctx->shared.virtualWidth >= 1400 && ctx->bpp == 32)
+ {
+ /*=* Max. length for a request SR22[4:0] (64/4 -> 0x10) *=*/
+ VGAOUT8(0x3c4, 0x22);
+ bRegTemp = VGAIN8(0x3c5) & ~0x1F;
+ VGAOUT8(0x3c5, bRegTemp | 0x10);
+ }
+ else
+ {
+ /*=* Max. length for a request SR22[4:0] (0x1F) *=*/
+ VGAOUT8(0x3c4, 0x22);
+ bRegTemp = VGAIN8(0x3c5) & ~0x1F;
+ VGAOUT8(0x3c5, bRegTemp | 0x1F);
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+static void VIAInitialize2DEngine(DRIDriverContext *ctx)
+{
+ VIAPtr pVia = VIAPTR(ctx);
+ u_int32_t dwVQStartAddr, dwVQEndAddr;
+ u_int32_t dwVQLen, dwVQStartL, dwVQEndL, dwVQStartEndH;
+ u_int32_t dwGEMode;
+
+ /* init 2D engine regs to reset 2D engine */
+ VIASETREG(0x04, 0x0);
+ VIASETREG(0x08, 0x0);
+ VIASETREG(0x0c, 0x0);
+ VIASETREG(0x10, 0x0);
+ VIASETREG(0x14, 0x0);
+ VIASETREG(0x18, 0x0);
+ VIASETREG(0x1c, 0x0);
+ VIASETREG(0x20, 0x0);
+ VIASETREG(0x24, 0x0);
+ VIASETREG(0x28, 0x0);
+ VIASETREG(0x2c, 0x0);
+ VIASETREG(0x30, 0x0);
+ VIASETREG(0x34, 0x0);
+ VIASETREG(0x38, 0x0);
+ VIASETREG(0x3c, 0x0);
+ VIASETREG(0x40, 0x0);
+
+ VIADisableMMIO(ctx);
+
+ /* Init AGP and VQ regs */
+ VIASETREG(0x43c, 0x00100000);
+ VIASETREG(0x440, 0x00000000);
+ VIASETREG(0x440, 0x00333004);
+ VIASETREG(0x440, 0x60000000);
+ VIASETREG(0x440, 0x61000000);
+ VIASETREG(0x440, 0x62000000);
+ VIASETREG(0x440, 0x63000000);
+ VIASETREG(0x440, 0x64000000);
+ VIASETREG(0x440, 0x7D000000);
+
+ VIASETREG(0x43c, 0xfe020000);
+ VIASETREG(0x440, 0x00000000);
+
+ if (pVia->VQStart != 0) {
+ /* Enable VQ */
+ dwVQStartAddr = pVia->VQStart;
+ dwVQEndAddr = pVia->VQEnd;
+ dwVQStartL = 0x50000000 | (dwVQStartAddr & 0xFFFFFF);
+ dwVQEndL = 0x51000000 | (dwVQEndAddr & 0xFFFFFF);
+ dwVQStartEndH = 0x52000000 | ((dwVQStartAddr & 0xFF000000) >> 24) |
+ ((dwVQEndAddr & 0xFF000000) >> 16);
+ dwVQLen = 0x53000000 | (VIA_VQ_SIZE >> 3);
+
+ VIASETREG(0x43c, 0x00fe0000);
+ VIASETREG(0x440, 0x080003fe);
+ VIASETREG(0x440, 0x0a00027c);
+ VIASETREG(0x440, 0x0b000260);
+ VIASETREG(0x440, 0x0c000274);
+ VIASETREG(0x440, 0x0d000264);
+ VIASETREG(0x440, 0x0e000000);
+ VIASETREG(0x440, 0x0f000020);
+ VIASETREG(0x440, 0x1000027e);
+ VIASETREG(0x440, 0x110002fe);
+ VIASETREG(0x440, 0x200f0060);
+
+ VIASETREG(0x440, 0x00000006);
+ VIASETREG(0x440, 0x40008c0f);
+ VIASETREG(0x440, 0x44000000);
+ VIASETREG(0x440, 0x45080c04);
+ VIASETREG(0x440, 0x46800408);
+
+ VIASETREG(0x440, dwVQStartEndH);
+ VIASETREG(0x440, dwVQStartL);
+ VIASETREG(0x440, dwVQEndL);
+ VIASETREG(0x440, dwVQLen);
+ }
+ else {
+ /* Diable VQ */
+ VIASETREG(0x43c, 0x00fe0000);
+ VIASETREG(0x440, 0x00000004);
+ VIASETREG(0x440, 0x40008c0f);
+ VIASETREG(0x440, 0x44000000);
+ VIASETREG(0x440, 0x45080c04);
+ VIASETREG(0x440, 0x46800408);
+ }
+
+ dwGEMode = 0;
+
+ switch (ctx->bpp) {
+ case 16:
+ dwGEMode |= VIA_GEM_16bpp;
+ break;
+ case 32:
+ dwGEMode |= VIA_GEM_32bpp;
+ break;
+ default:
+ dwGEMode |= VIA_GEM_8bpp;
+ break;
+ }
+
+#if 0
+ switch (ctx->shared.virtualWidth) {
+ case 800:
+ dwGEMode |= VIA_GEM_800;
+ break;
+ case 1024:
+ dwGEMode |= VIA_GEM_1024;
+ break;
+ case 1280:
+ dwGEMode |= VIA_GEM_1280;
+ break;
+ case 1600:
+ dwGEMode |= VIA_GEM_1600;
+ break;
+ case 2048:
+ dwGEMode |= VIA_GEM_2048;
+ break;
+ default:
+ dwGEMode |= VIA_GEM_640;
+ break;
+ }
+#endif
+
+ VIAEnableMMIO(ctx);
+
+ /* Set BPP and Pitch */
+ VIASETREG(VIA_REG_GEMODE, dwGEMode);
+
+ /* Set Src and Dst base address and pitch, pitch is qword */
+ VIASETREG(VIA_REG_SRCBASE, 0x0);
+ VIASETREG(VIA_REG_DSTBASE, 0x0);
+ VIASETREG(VIA_REG_PITCH, VIA_PITCH_ENABLE |
+ ((ctx->shared.virtualWidth * ctx->bpp >> 3) >> 3) |
+ (((ctx->shared.virtualWidth * ctx->bpp >> 3) >> 3) << 16));
+}
+
+static int b3DRegsInitialized = 0;
+
+static void VIAInitialize3DEngine(DRIDriverContext *ctx)
+{
+ VIAPtr pVia = VIAPTR(ctx);
+ int i;
+
+ if (!b3DRegsInitialized)
+ {
+
+ VIASETREG(0x43C, 0x00010000);
+
+ for (i = 0; i <= 0x7D; i++)
+ {
+ VIASETREG(0x440, (u_int32_t) i << 24);
+ }
+
+ VIASETREG(0x43C, 0x00020000);
+
+ for (i = 0; i <= 0x94; i++)
+ {
+ VIASETREG(0x440, (u_int32_t) i << 24);
+ }
+
+ VIASETREG(0x440, 0x82400000);
+
+ VIASETREG(0x43C, 0x01020000);
+
+
+ for (i = 0; i <= 0x94; i++)
+ {
+ VIASETREG(0x440, (u_int32_t) i << 24);
+ }
+
+ VIASETREG(0x440, 0x82400000);
+ VIASETREG(0x43C, 0xfe020000);
+
+ for (i = 0; i <= 0x03; i++)
+ {
+ VIASETREG(0x440, (u_int32_t) i << 24);
+ }
+
+ VIASETREG(0x43C, 0x00030000);
+
+ for (i = 0; i <= 0xff; i++)
+ {
+ VIASETREG(0x440, 0);
+ }
+ VIASETREG(0x43C, 0x00100000);
+ VIASETREG(0x440, 0x00333004);
+ VIASETREG(0x440, 0x10000002);
+ VIASETREG(0x440, 0x60000000);
+ VIASETREG(0x440, 0x61000000);
+ VIASETREG(0x440, 0x62000000);
+ VIASETREG(0x440, 0x63000000);
+ VIASETREG(0x440, 0x64000000);
+
+ VIASETREG(0x43C, 0x00fe0000);
+
+ if (pVia->ChipRev >= 3 )
+ VIASETREG(0x440,0x40008c0f);
+ else
+ VIASETREG(0x440,0x4000800f);
+
+ VIASETREG(0x440,0x44000000);
+ VIASETREG(0x440,0x45080C04);
+ VIASETREG(0x440,0x46800408);
+ VIASETREG(0x440,0x50000000);
+ VIASETREG(0x440,0x51000000);
+ VIASETREG(0x440,0x52000000);
+ VIASETREG(0x440,0x53000000);
+
+ b3DRegsInitialized = 1;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "3D Engine has been initialized.\n");
+ }
+
+ VIASETREG(0x43C,0x00fe0000);
+ VIASETREG(0x440,0x08000001);
+ VIASETREG(0x440,0x0A000183);
+ VIASETREG(0x440,0x0B00019F);
+ VIASETREG(0x440,0x0C00018B);
+ VIASETREG(0x440,0x0D00019B);
+ VIASETREG(0x440,0x0E000000);
+ VIASETREG(0x440,0x0F000000);
+ VIASETREG(0x440,0x10000000);
+ VIASETREG(0x440,0x11000000);
+ VIASETREG(0x440,0x20000000);
+}
+
+static int
+WaitIdleCLE266(VIAPtr pVia)
+{
+ int loop = 0;
+
+ /*mem_barrier();*/
+
+ while (!(VIAGETREG(VIA_REG_STATUS) & VIA_VR_QUEUE_BUSY) && (loop++ < MAXLOOP))
+ ;
+
+ while ((VIAGETREG(VIA_REG_STATUS) &
+ (VIA_CMD_RGTR_BUSY | VIA_2D_ENG_BUSY | VIA_3D_ENG_BUSY)) &&
+ (loop++ < MAXLOOP))
+ ;
+
+ return loop >= MAXLOOP;
+}
+
+static int viaInitFBDev(DRIDriverContext *ctx)
+{
+ VIAPtr pVia = CALLOC(sizeof(*pVia));
+
+ ctx->driverPrivate = (void *)pVia;
+
+ switch (ctx->chipset) {
+ case PCI_CHIP_CLE3122:
+ case PCI_CHIP_CLE3022:
+ pVia->Chipset = VIA_CLE266;
+ break;
+ case PCI_CHIP_VT7205:
+ case PCI_CHIP_VT3205:
+ pVia->Chipset = VIA_KM400;
+ break;
+ case PCI_CHIP_VT3204:
+ pVia->Chipset = VIA_K8M800;
+ break;
+ case PCI_CHIP_VT3259:
+ pVia->Chipset = VIA_PM800;
+ break;
+ default:
+ xf86DrvMsg(0, X_ERROR, "VIA: Unknown device ID (0x%x)\n", ctx->chipset);
+ }
+
+ /* _SOLO TODO XXX need to read ChipRev too */
+ pVia->ChipRev = 0;
+
+ pVia->videoRambytes = ctx->shared.fbSize;
+ pVia->MmioBase = ctx->MMIOStart;
+ pVia->FrameBufferBase = ctx->FBStart & 0xfc000000;
+
+ pVia->FBFreeStart = ctx->shared.virtualWidth * ctx->cpp *
+ ctx->shared.virtualHeight;
+
+#if 1
+ /* Alloc a second framebuffer for the second head */
+ pVia->FBFreeStart += ctx->shared.virtualWidth * ctx->cpp *
+ ctx->shared.virtualHeight;
+#endif
+
+ pVia->VQStart = pVia->FBFreeStart;
+ pVia->VQEnd = pVia->FBFreeStart + VIA_VQ_SIZE - 1;
+
+ pVia->FBFreeStart += VIA_VQ_SIZE;
+
+ pVia->FBFreeEnd = pVia->videoRambytes;
+
+ if (!VIADRIScreenInit(ctx))
+ return 0;
+
+ return 1;
+}
+
+static void viaHaltFBDev(DRIDriverContext *ctx)
+{
+ drmUnmap( ctx->pSAREA, ctx->shared.SAREASize );
+ drmClose(ctx->drmFD);
+
+ if (ctx->driverPrivate) {
+ free(ctx->driverPrivate);
+ ctx->driverPrivate = 0;
+ }
+}
+
+static int viaEngineShutdown(const DRIDriverContext *ctx)
+{
+ return 1;
+}
+
+static int viaEngineRestore(const DRIDriverContext *ctx)
+{
+ return 1;
+}
+
+const struct DRIDriverRec __driDriver =
+{
+ viaValidateMode,
+ viaPostValidateMode,
+ viaInitFBDev,
+ viaHaltFBDev,
+ viaEngineShutdown,
+ viaEngineRestore,
+ 0,
+};
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_dri.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_dri.h
new file mode 100644
index 000000000..b47397d57
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_dri.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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.
+ */
+/*
+ * Keep this file in perfect sync between the ddx and dri drivers.
+ * At least bump the VIA_DRIDDX_VERSION defines appropriately.
+ *
+ */
+#ifndef _VIA_DRI_H_
+#define _VIA_DRI_H_ 1
+
+#define VIA_MAX_DRAWABLES 256
+
+#define VIA_DRIDDX_VERSION_MAJOR 5
+#define VIA_DRIDDX_VERSION_MINOR 0
+#define VIA_DRIDDX_VERSION_PATCH 0
+
+#ifndef XFree86Server
+typedef int Bool;
+#endif
+
+typedef struct {
+ drm_handle_t handle;
+ drmSize size;
+} viaRegion, *viaRegionPtr;
+
+typedef struct {
+ viaRegion regs, agp;
+ int deviceID;
+ int width;
+ int height;
+ int mem;
+ int bytesPerPixel;
+ int priv1;
+ int priv2;
+ int fbOffset;
+ int fbSize;
+ Bool drixinerama;
+ int backOffset;
+ int depthOffset;
+ int textureOffset;
+ int textureSize;
+ int irqEnabled;
+ unsigned int scrnX, scrnY;
+ int sarea_priv_offset;
+ int ringBufActive;
+ unsigned int reg_pause_addr;
+} VIADRIRec, *VIADRIPtr;
+
+typedef struct {
+ int dummy;
+} VIAConfigPrivRec, *VIAConfigPrivPtr;
+
+typedef struct {
+ int dummy;
+} VIADRIContextRec, *VIADRIContextPtr;
+
+#endif /* _VIA_DRI_H_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_driver.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_driver.h
new file mode 100644
index 000000000..997b2e41a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_driver.h
@@ -0,0 +1,309 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_driver.h,v 1.7 2003/11/06 18:38:11 tsi Exp $ */
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+#ifndef _VIA_DRIVER_H
+#define _VIA_DRIVER_H
+
+#if 0 /* DEBUG is use in VIA DRI code as a flag */
+/* #define DEBUG_PRINT */
+#ifdef DEBUG_PRINT
+#define DEBUG(x) x
+#else
+#define DEBUG(x)
+#endif
+#endif
+
+#if 0
+#include "vgaHW.h"
+#include "xf86.h"
+#include "xf86Resources.h"
+#include "xf86_ansic.h"
+#include "xf86Pci.h"
+#include "xf86PciInfo.h"
+#include "xf86_OSproc.h"
+#include "compiler.h"
+#include "xf86Cursor.h"
+#include "mipointer.h"
+#include "micmap.h"
+
+#define USE_FB
+#ifdef USE_FB
+#include "fb.h"
+#else
+#include "cfb.h"
+#include "cfb16.h"
+#include "cfb32.h"
+#endif
+
+#include "xf86cmap.h"
+#include "vbe.h"
+#include "xaa.h"
+
+#include "via_regs.h"
+#include "via_bios.h"
+#include "via_gpioi2c.h"
+#include "via_priv.h"
+#include "ginfo.h"
+
+#ifdef XF86DRI
+#define _XF86DRI_SERVER_
+#include "sarea.h"
+#include "dri.h"
+#include "GL/glxint.h"
+#include "via_dri.h"
+#endif
+#else
+#include "via_regs.h"
+
+#include "GL/internal/dri_interface.h"
+#include "via_dri.h"
+#endif
+
+/* _SOLO : copied from via_bios.h */
+/* System Memory CLK */
+#define VIA_MEM_SDR66 0x00
+#define VIA_MEM_SDR100 0x01
+#define VIA_MEM_SDR133 0x02
+#define VIA_MEM_DDR200 0x03
+#define VIA_MEM_DDR266 0x04
+#define VIA_MEM_DDR333 0x05
+#define VIA_MEM_DDR400 0x06
+
+#define DRIVER_NAME "via"
+#define DRIVER_VERSION "4.1.0"
+#define VERSION_MAJOR 4
+#define VERSION_MINOR 1
+#define PATCHLEVEL 41
+#define VIA_VERSION ((VERSION_MAJOR<<24) | (VERSION_MINOR<<16) | PATCHLEVEL)
+
+#define VGAIN8(addr) MMIO_IN8(pVia->MapBase+0x8000, addr)
+#define VGAIN16(addr) MMIO_IN16(pVia->MapBase+0x8000, addr)
+#define VGAIN(addr) MMIO_IN32(pVia->MapBase+0x8000, addr)
+
+#define VGAOUT8(addr, val) MMIO_OUT8(pVia->MapBase+0x8000, addr, val)
+#define VGAOUT16(addr, val) MMIO_OUT16(pVia->MapBase+0x8000, addr, val)
+#define VGAOUT(addr, val) MMIO_OUT32(pVia->MapBase+0x8000, addr, val)
+
+#define INREG(addr) MMIO_IN32(pVia->MapBase, addr)
+#define OUTREG(addr, val) MMIO_OUT32(pVia->MapBase, addr, val)
+#define INREG16(addr) MMIO_IN16(pVia->MapBase, addr)
+#define OUTREG16(addr, val) MMIO_OUT16(pVia->MapBase, addr, val)
+
+#define VIA_PIXMAP_CACHE_SIZE (256 * 1024)
+#define VIA_CURSOR_SIZE (4 * 1024)
+#define VIA_VQ_SIZE (256 * 1024)
+
+typedef struct {
+ unsigned int mode, refresh, resMode;
+ int countWidthByQWord;
+ int offsetWidthByQWord;
+ unsigned char SR08, SR0A, SR0F;
+
+ /* extended Sequencer registers */
+ unsigned char SR10, SR11, SR12, SR13,SR14,SR15,SR16;
+ unsigned char SR17, SR18, SR19, SR1A,SR1B,SR1C,SR1D,SR1E;
+ unsigned char SR1F, SR20, SR21, SR22,SR23,SR24,SR25,SR26;
+ unsigned char SR27, SR28, SR29, SR2A,SR2B,SR2C,SR2D,SR2E;
+ unsigned char SR2F, SR30, SR31, SR32,SR33,SR34,SR40,SR41;
+ unsigned char SR42, SR43, SR44, SR45,SR46,SR47;
+
+ unsigned char Clock;
+
+ /* extended CRTC registers */
+ unsigned char CR13, CR30, CR31, CR32, CR33, CR34, CR35, CR36;
+ unsigned char CR37, CR38, CR39, CR3A, CR40, CR41, CR42, CR43;
+ unsigned char CR44, CR45, CR46, CR47, CR48, CR49, CR4A;
+ unsigned char CRTCRegs[83];
+ unsigned char TVRegs[0xCF];
+ unsigned char TVRegs2[0xCF];
+/* unsigned char LCDRegs[0x40];*/
+
+} VIARegRec, *VIARegPtr;
+
+
+typedef struct _VIA {
+ VIARegRec SavedReg;
+ VIARegRec ModeReg;
+#if 0
+ xf86CursorInfoPtr CursorInfoRec;
+ int stateMode;
+ VIAModeInfoPtr VIAModeList;
+#endif
+ int ModeStructInit;
+ int Bpp, Bpl, ScissB;
+ unsigned PlaneMask;
+
+ unsigned long videoRambytes;
+ int videoRamKbytes;
+ int FBFreeStart;
+ int FBFreeEnd;
+ int CursorStart;
+ int VQStart;
+ int VQEnd;
+
+ /* These are physical addresses. */
+ unsigned long FrameBufferBase;
+ unsigned long MmioBase;
+
+ /* These are linear addresses. */
+ unsigned char* MapBase;
+ unsigned char* VidMapBase;
+ unsigned char* BltBase;
+ unsigned char* MapBaseDense;
+ unsigned char* FBBase;
+ unsigned char* FBStart;
+
+ int PrimaryVidMapped;
+ int dacSpeedBpp;
+ int minClock, maxClock;
+ int MCLK, REFCLK, LCDclk;
+ double refclk_fact;
+
+ /* Here are all the Options */
+ int VQEnable;
+ int pci_burst;
+ int NoPCIRetry;
+ int hwcursor;
+ int NoAccel;
+ int shadowFB;
+ int NoDDCValue;
+ int rotate;
+
+#if 0
+ CloseScreenProcPtr CloseScreen;
+ pciVideoPtr PciInfo;
+ PCITAG PciTag;
+#endif
+ int Chipset;
+ int ChipId;
+ int ChipRev;
+ /*vbeInfoPtr pVbe;*/
+ int EntityIndex;
+
+ /* Support for shadowFB and rotation */
+ unsigned char* ShadowPtr;
+ int ShadowPitch;
+ void (*PointerMoved)(int index, int x, int y);
+
+ /* Support for XAA acceleration */
+#if 0
+ XAAInfoRecPtr AccelInfoRec;
+ xRectangle Rect;
+#endif
+ u_int32_t SavedCmd;
+ u_int32_t SavedFgColor;
+ u_int32_t SavedBgColor;
+ u_int32_t SavedPattern0;
+ u_int32_t SavedPattern1;
+ u_int32_t SavedPatternAddr;
+
+#if 0
+ /* Support for Int10 processing */
+ xf86Int10InfoPtr pInt10;
+
+ /* BIOS Info Ptr */
+ VIABIOSInfoPtr pBIOSInfo;
+ VGABIOSVERPtr pBIOSVer;
+#endif
+
+ /* Support for DGA */
+ int numDGAModes;
+ /*DGAModePtr DGAModes;*/
+ int DGAactive;
+ int DGAViewportStatus;
+
+ /* The various wait handlers. */
+ int (*myWaitIdle)(struct _VIA*);
+
+#if 0
+ /* I2C & DDC */
+ I2CBusPtr I2C_Port1;
+ I2CBusPtr I2C_Port2;
+ xf86MonPtr DDC1;
+ xf86MonPtr DDC2;
+#endif
+
+ /* MHS */
+ int IsSecondary;
+ int HasSecondary;
+
+#if 0
+ /* Capture information */
+ VIACAPINFO CapInfo[2]; /* 2 capture information */
+#endif
+
+/*
+ u_int32_t Cap0_Deinterlace;
+ u_int32_t Cap1_Deinterlace;
+
+ int Cap0_FieldSwap;
+ int NoCap0_HFilter;
+ int Capture_OverScanOff;
+ int NoMPEGHQV_VFilter;
+*/
+#ifdef XF86DRI
+ int directRenderingEnabled;
+ DRIInfoPtr pDRIInfo;
+ int drmFD;
+ int numVisualConfigs;
+ __GLXvisualConfig* pVisualConfigs;
+ VIAConfigPrivPtr pVisualConfigsPriv;
+ unsigned long agpHandle;
+ unsigned long registerHandle;
+ u_int32_t agpAddr;
+ unsigned char *agpBase;
+ unsigned int agpSize;
+ int IsPCI;
+ int drixinerama;
+#else
+ int drmFD;
+ unsigned long agpHandle;
+ unsigned long registerHandle;
+ unsigned long agpAddr;
+ unsigned char *agpBase;
+ unsigned int agpSize;
+ int IsPCI;
+#endif
+
+ int V4LEnabled;
+ u_int16_t ActiveDevice; /* if SAMM, non-equal pBIOSInfo->ActiveDevice */
+ unsigned char *CursorImage;
+ u_int32_t CursorFG;
+ u_int32_t CursorBG;
+ u_int32_t CursorMC;
+
+ unsigned char MemClk;
+ int EnableExtendedFIFO;
+ VIADRIPtr devPrivate;
+} VIARec, *VIAPtr;
+
+
+/* Shortcuts. These depend on a local symbol "pVia". */
+
+#define WaitIdle() pVia->myWaitIdle(pVia)
+#define VIAPTR(p) ((VIAPtr)((p)->driverPrivate))
+
+#endif /* _VIA_DRIVER_H */
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_priv.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_priv.h
new file mode 100644
index 000000000..587531b37
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_priv.h
@@ -0,0 +1,70 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/via/via_priv.h,v 1.3 2003/08/27 15:16:12 tsi Exp $ */
+
+#ifndef _VIA_PRIV_H_
+#define _VIA_PRIV_H_ 1
+
+//#include "ddmpeg.h"
+#include "via_common.h"
+
+#define MEM_BLOCKS 4
+
+typedef struct {
+ unsigned long base; /* Offset into fb */
+ int pool; /* Pool we drew from */
+ int drm_fd; /* Fd in DRM mode */
+ drm_via_mem_t drm; /* DRM management object */
+ int slot; /* Pool 3 slot */
+ void *pVia; /* VIA driver pointer */
+ //FBLinearPtr linear; /* X linear pool info ptr */
+} VIAMem;
+
+typedef VIAMem *VIAMemPtr;
+
+
+
+#if 0
+typedef struct {
+ unsigned long gdwVideoFlagTV1;
+ unsigned long gdwVideoFlagSW;
+ unsigned long gdwVideoFlagMPEG;
+ unsigned long gdwAlphaEnabled; /* For Alpha blending use*/
+
+ VIAMem SWOVMem;
+ VIAMem HQVMem;
+ VIAMem SWfbMem;
+
+ DDPIXELFORMAT DPFsrc;
+ DDUPDATEOVERLAY UpdateOverlayBackup; /* For HQVcontrol func use
+ // To save MPEG updateoverlay info.*/
+
+/* device struct */
+ SWDEVICE SWDevice;
+ SUBDEVICE SUBDevice;
+ MPGDEVICE MPGDevice;
+ OVERLAYRECORD overlayRecordV1;
+ OVERLAYRECORD overlayRecordV3;
+
+ BoxRec AvailFBArea;
+ FBLinearPtr SWOVlinear;
+
+ int MPEG_ON;
+ int SWVideo_ON;
+
+/*To solve the bandwidth issue */
+ unsigned long gdwUseExtendedFIFO;
+
+/* For panning mode use */
+ int panning_old_x;
+ int panning_old_y;
+ int panning_x;
+ int panning_y;
+
+/*To solve the bandwidth issue */
+ unsigned char Save_3C4_16;
+ unsigned char Save_3C4_17;
+ unsigned char Save_3C4_18;
+
+} swovRec, *swovPtr;
+#endif
+
+#endif /* _VIA_PRIV_H_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_regs.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_regs.h
new file mode 100644
index 000000000..5c5eecbe8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/server/via_regs.h
@@ -0,0 +1,197 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+/*************************************************************************
+ *
+ * File: via_regs.c
+ * Content: The defines of Via registers
+ *
+ ************************************************************************/
+
+#ifndef _VIA_REGS_H
+#define _VIA_REGS_H
+
+#include "via_driver.h"
+
+/*#define VIA_SERIES(chip) (chip == VIA_CLE266)*/
+
+#define PCI_VIA_VENDOR_ID 0x1106
+
+#define PCI_CHIP_CLE3122 0x3122
+#define PCI_CHIP_CLE3022 0x3022
+#define PCI_CHIP_VT3205 0x3205
+#define PCI_CHIP_VT7205 0x7205
+#define PCI_CHIP_VT3204 0x3108
+#define PCI_CHIP_VT3259 0x3118
+
+
+#define BIOS_BSIZE 1024
+#define BIOS_BASE 0xc0000
+
+
+#define VIA_MMIO_REGSIZE 0x9000
+#define VIA_MMIO_REGBASE 0x0
+#define VIA_MMIO_VGABASE 0x8000
+#define VIA_MMIO_BLTBASE 0x200000
+#define VIA_MMIO_BLTSIZE 0x10000
+
+
+/* defines for VIA 2D registers */
+#define VIA_REG_GECMD 0x000
+#define VIA_REG_GEMODE 0x004
+#define VIA_REG_GESTATUS 0x004 /* as same as VIA_REG_GEMODE */
+#define VIA_REG_SRCPOS 0x008
+#define VIA_REG_DSTPOS 0x00C
+#define VIA_REG_LINE_K1K2 0x008
+#define VIA_REG_LINE_XY 0x00C
+#define VIA_REG_DIMENSION 0x010 /* width and height */
+#define VIA_REG_PATADDR 0x014
+#define VIA_REG_FGCOLOR 0x018
+#define VIA_REG_DSTCOLORKEY 0x018 /* as same as VIA_REG_FG */
+#define VIA_REG_BGCOLOR 0x01C
+#define VIA_REG_SRCCOLORKEY 0x01C /* as same as VIA_REG_BG */
+#define VIA_REG_CLIPTL 0x020 /* top and left of clipping */
+#define VIA_REG_CLIPBR 0x024 /* bottom and right of clipping */
+#define VIA_REG_OFFSET 0x028
+#define VIA_REG_LINE_ERROR 0x028
+#define VIA_REG_KEYCONTROL 0x02C /* color key control */
+#define VIA_REG_SRCBASE 0x030
+#define VIA_REG_DSTBASE 0x034
+#define VIA_REG_PITCH 0x038 /* pitch of src and dst */
+#define VIA_REG_MONOPAT0 0x03C
+#define VIA_REG_MONOPAT1 0x040
+#define VIA_REG_COLORPAT 0x100 /* from 0x100 to 0x1ff */
+
+
+
+/* defines for VIA video registers */
+#define VIA_REG_INTERRUPT 0x200
+#define VIA_REG_CRTCSTART 0x214
+
+
+/* defines for VIA HW cursor registers */
+#define VIA_REG_CURSOR_MODE 0x2D0
+#define VIA_REG_CURSOR_POS 0x2D4
+#define VIA_REG_CURSOR_ORG 0x2D8
+#define VIA_REG_CURSOR_BG 0x2DC
+#define VIA_REG_CURSOR_FG 0x2E0
+
+
+/* defines for VIA 3D registers */
+#define VIA_REG_STATUS 0x400
+#define VIA_REG_TRANSET 0x43C
+#define VIA_REG_TRANSPACE 0x440
+
+/* VIA_REG_STATUS(0x400): Engine Status */
+#define VIA_CMD_RGTR_BUSY 0x00000080 /* Command Regulator is busy */
+#define VIA_2D_ENG_BUSY 0x00000001 /* 2D Engine is busy */
+#define VIA_3D_ENG_BUSY 0x00000002 /* 3D Engine is busy */
+#define VIA_VR_QUEUE_BUSY 0x00020000 /* Virtual Queue is busy */
+
+
+/* VIA_REG_GECMD(0x00): 2D Engine Command */
+#define VIA_GEC_NOOP 0x00000000
+#define VIA_GEC_BLT 0x00000001
+#define VIA_GEC_LINE 0x00000005
+
+#define VIA_GEC_SRC_XY 0x00000000
+#define VIA_GEC_SRC_LINEAR 0x00000010
+#define VIA_GEC_DST_XY 0x00000000
+#define VIA_GEC_DST_LINRAT 0x00000020
+
+#define VIA_GEC_SRC_FB 0x00000000
+#define VIA_GEC_SRC_SYS 0x00000040
+#define VIA_GEC_DST_FB 0x00000000
+#define VIA_GEC_DST_SYS 0x00000080
+
+#define VIA_GEC_SRC_MONO 0x00000100 /* source is mono */
+#define VIA_GEC_PAT_MONO 0x00000200 /* pattern is mono */
+
+#define VIA_GEC_MSRC_OPAQUE 0x00000000 /* mono src is opaque */
+#define VIA_GEC_MSRC_TRANS 0x00000400 /* mono src is transparent */
+
+#define VIA_GEC_PAT_FB 0x00000000 /* pattern is in frame buffer */
+#define VIA_GEC_PAT_REG 0x00000800 /* pattern is from reg setting */
+
+#define VIA_GEC_CLIP_DISABLE 0x00000000
+#define VIA_GEC_CLIP_ENABLE 0x00001000
+
+#define VIA_GEC_FIXCOLOR_PAT 0x00002000
+
+#define VIA_GEC_INCX 0x00000000
+#define VIA_GEC_DECY 0x00004000
+#define VIA_GEC_INCY 0x00000000
+#define VIA_GEC_DECX 0x00008000
+
+#define VIA_GEC_MPAT_OPAQUE 0x00000000 /* mono pattern is opaque */
+#define VIA_GEC_MPAT_TRANS 0x00010000 /* mono pattern is transparent */
+
+#define VIA_GEC_MONO_UNPACK 0x00000000
+#define VIA_GEC_MONO_PACK 0x00020000
+#define VIA_GEC_MONO_DWORD 0x00000000
+#define VIA_GEC_MONO_WORD 0x00040000
+#define VIA_GEC_MONO_BYTE 0x00080000
+
+#define VIA_GEC_LASTPIXEL_ON 0x00000000
+#define VIA_GEC_LASTPIXEL_OFF 0x00100000
+#define VIA_GEC_X_MAJOR 0x00000000
+#define VIA_GEC_Y_MAJOR 0x00200000
+#define VIA_GEC_QUICK_START 0x00800000
+
+
+/* VIA_REG_GEMODE(0x04): GE mode */
+#define VIA_GEM_8bpp 0x00000000
+#define VIA_GEM_16bpp 0x00000100
+#define VIA_GEM_32bpp 0x00000300
+
+#define VIA_GEM_640 0x00000000 /* 640*480 */
+#define VIA_GEM_800 0x00000400 /* 800*600 */
+#define VIA_GEM_1024 0x00000800 /* 1024*768 */
+#define VIA_GEM_1280 0x00000C00 /* 1280*1024 */
+#define VIA_GEM_1600 0x00001000 /* 1600*1200 */
+#define VIA_GEM_2048 0x00001400 /* 2048*1536 */
+
+/* VIA_REG_PITCH(0x38): Pitch Setting */
+#define VIA_PITCH_ENABLE 0x80000000
+
+
+#define MAXLOOP 0xffffff
+
+
+#define VerticalRetraceWait() \
+{ \
+ VGAOUT8(vgaCRIndex, 0x17); \
+ if (VGAIN8(vgaCRReg) & 0x80) { \
+ while ((VGAIN8(vgaIOBase + 0x0a) & 0x08) == 0x00) ; \
+ while ((VGAIN8(vgaIOBase + 0x0a) & 0x08) == 0x08) ; \
+ while ((VGAIN8(vgaIOBase + 0x0a) & 0x08) == 0x00) ; \
+ } \
+}
+
+
+#define VIASETREG(addr, data) *(volatile unsigned int *)(pVia->MapBase + (addr)) = (data)
+#define VIAGETREG(addr) *(volatile unsigned int *)(pVia->MapBase + (addr))
+
+
+#endif /* _VIA_REGS_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_3d_reg.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_3d_reg.h
new file mode 100644
index 000000000..77b24dc61
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_3d_reg.h
@@ -0,0 +1,1652 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+#ifndef VIA_3D_REG_H
+#define VIA_3D_REG_H
+#define HC_REG_BASE 0x0400
+
+#define HC_ParaN_MASK 0xffffffff
+#define HC_Para_MASK 0x00ffffff
+#define HC_SubA_MASK 0xff000000
+#define HC_SubA_SHIFT 24
+/* Transmission Setting
+ */
+#define HC_REG_TRANS_SET 0x003c
+#define HC_ParaSubType_MASK 0xff000000
+#define HC_ParaType_MASK 0x00ff0000
+#define HC_ParaOS_MASK 0x0000ff00
+#define HC_ParaAdr_MASK 0x000000ff
+#define HC_ParaSubType_SHIFT 24
+#define HC_ParaType_SHIFT 16
+#define HC_ParaOS_SHIFT 8
+#define HC_ParaAdr_SHIFT 0
+
+#define HC_ParaType_CmdVdata 0x0000
+#define HC_ParaType_NotTex 0x0001
+#define HC_ParaType_Tex 0x0002
+#define HC_ParaType_Palette 0x0003
+#define HC_ParaType_PreCR 0x0010
+#define HC_ParaType_Auto 0x00fe
+
+/* Transmission Space
+ */
+#define HC_REG_Hpara0 0x0040
+#define HC_REG_HpataAF 0x02fc
+
+/* Read
+ */
+#define HC_REG_HREngSt 0x0000
+#define HC_REG_HRFIFOempty 0x0004
+#define HC_REG_HRFIFOfull 0x0008
+#define HC_REG_HRErr 0x000c
+#define HC_REG_FIFOstatus 0x0010
+/* HC_REG_HREngSt 0x0000
+ */
+#define HC_HDASZC_MASK 0x00010000
+#define HC_HSGEMI_MASK 0x0000f000
+#define HC_HLGEMISt_MASK 0x00000f00
+#define HC_HCRSt_MASK 0x00000080
+#define HC_HSE0St_MASK 0x00000040
+#define HC_HSE1St_MASK 0x00000020
+#define HC_HPESt_MASK 0x00000010
+#define HC_HXESt_MASK 0x00000008
+#define HC_HBESt_MASK 0x00000004
+#define HC_HE2St_MASK 0x00000002
+#define HC_HE3St_MASK 0x00000001
+/* HC_REG_HRFIFOempty 0x0004
+ */
+#define HC_HRZDempty_MASK 0x00000010
+#define HC_HRTXAempty_MASK 0x00000008
+#define HC_HRTXDempty_MASK 0x00000004
+#define HC_HWZDempty_MASK 0x00000002
+#define HC_HWCDempty_MASK 0x00000001
+/* HC_REG_HRFIFOfull 0x0008
+ */
+#define HC_HRZDfull_MASK 0x00000010
+#define HC_HRTXAfull_MASK 0x00000008
+#define HC_HRTXDfull_MASK 0x00000004
+#define HC_HWZDfull_MASK 0x00000002
+#define HC_HWCDfull_MASK 0x00000001
+/* HC_REG_HRErr 0x000c
+ */
+#define HC_HAGPCMErr_MASK 0x80000000
+#define HC_HAGPCMErrC_MASK 0x70000000
+/* HC_REG_FIFOstatus 0x0010
+ */
+#define HC_HRFIFOATall_MASK 0x80000000
+#define HC_HRFIFOATbusy_MASK 0x40000000
+#define HC_HRATFGMDo_MASK 0x00000100
+#define HC_HRATFGMDi_MASK 0x00000080
+#define HC_HRATFRZD_MASK 0x00000040
+#define HC_HRATFRTXA_MASK 0x00000020
+#define HC_HRATFRTXD_MASK 0x00000010
+#define HC_HRATFWZD_MASK 0x00000008
+#define HC_HRATFWCD_MASK 0x00000004
+#define HC_HRATTXTAG_MASK 0x00000002
+#define HC_HRATTXCH_MASK 0x00000001
+
+/* AGP Command Setting
+ */
+#define HC_SubA_HAGPBstL 0x0060
+#define HC_SubA_HAGPBendL 0x0061
+#define HC_SubA_HAGPCMNT 0x0062
+#define HC_SubA_HAGPBpL 0x0063
+#define HC_SubA_HAGPBpH 0x0064
+/* HC_SubA_HAGPCMNT 0x0062
+ */
+#define HC_HAGPCMNT_MASK 0x00800000
+#define HC_HCmdErrClr_MASK 0x00400000
+#define HC_HAGPBendH_MASK 0x0000ff00
+#define HC_HAGPBstH_MASK 0x000000ff
+#define HC_HAGPBendH_SHIFT 8
+#define HC_HAGPBstH_SHIFT 0
+/* HC_SubA_HAGPBpL 0x0063
+ */
+#define HC_HAGPBpL_MASK 0x00fffffc
+#define HC_HAGPBpID_MASK 0x00000003
+#define HC_HAGPBpID_PAUSE 0x00000000
+#define HC_HAGPBpID_JUMP 0x00000001
+#define HC_HAGPBpID_STOP 0x00000002
+/* HC_SubA_HAGPBpH 0x0064
+ */
+#define HC_HAGPBpH_MASK 0x00ffffff
+
+/* Miscellaneous Settings
+ */
+#define HC_SubA_HClipTB 0x0070
+#define HC_SubA_HClipLR 0x0071
+#define HC_SubA_HFPClipTL 0x0072
+#define HC_SubA_HFPClipBL 0x0073
+#define HC_SubA_HFPClipLL 0x0074
+#define HC_SubA_HFPClipRL 0x0075
+#define HC_SubA_HFPClipTBH 0x0076
+#define HC_SubA_HFPClipLRH 0x0077
+#define HC_SubA_HLP 0x0078
+#define HC_SubA_HLPRF 0x0079
+#define HC_SubA_HSolidCL 0x007a
+#define HC_SubA_HPixGC 0x007b
+#define HC_SubA_HSPXYOS 0x007c
+#define HC_SubA_HVertexCNT 0x007d
+
+#define HC_HClipT_MASK 0x00fff000
+#define HC_HClipT_SHIFT 12
+#define HC_HClipB_MASK 0x00000fff
+#define HC_HClipB_SHIFT 0
+#define HC_HClipL_MASK 0x00fff000
+#define HC_HClipL_SHIFT 12
+#define HC_HClipR_MASK 0x00000fff
+#define HC_HClipR_SHIFT 0
+#define HC_HFPClipBH_MASK 0x0000ff00
+#define HC_HFPClipBH_SHIFT 8
+#define HC_HFPClipTH_MASK 0x000000ff
+#define HC_HFPClipTH_SHIFT 0
+#define HC_HFPClipRH_MASK 0x0000ff00
+#define HC_HFPClipRH_SHIFT 8
+#define HC_HFPClipLH_MASK 0x000000ff
+#define HC_HFPClipLH_SHIFT 0
+#define HC_HSolidCH_MASK 0x000000ff
+#define HC_HPixGC_MASK 0x00800000
+#define HC_HSPXOS_MASK 0x00fff000
+#define HC_HSPXOS_SHIFT 12
+#define HC_HSPYOS_MASK 0x00000fff
+
+/* Command
+ * Command A
+ */
+#define HC_HCmdHeader_MASK 0xfe000000 /*0xffe00000*/
+#define HC_HE3Fire_MASK 0x00100000
+#define HC_HPMType_MASK 0x000f0000
+#define HC_HEFlag_MASK 0x0000e000
+#define HC_HShading_MASK 0x00001c00
+#define HC_HPMValidN_MASK 0x00000200
+#define HC_HPLEND_MASK 0x00000100
+#define HC_HVCycle_MASK 0x000000ff
+#define HC_HVCycle_Style_MASK 0x000000c0
+#define HC_HVCycle_ChgA_MASK 0x00000030
+#define HC_HVCycle_ChgB_MASK 0x0000000c
+#define HC_HVCycle_ChgC_MASK 0x00000003
+#define HC_HPMType_Point 0x00000000
+#define HC_HPMType_Line 0x00010000
+#define HC_HPMType_Tri 0x00020000
+#define HC_HPMType_TriWF 0x00040000
+#define HC_HEFlag_NoAA 0x00000000
+#define HC_HEFlag_ab 0x00008000
+#define HC_HEFlag_bc 0x00004000
+#define HC_HEFlag_ca 0x00002000
+#define HC_HShading_Solid 0x00000000
+#define HC_HShading_FlatA 0x00000400
+#define HC_HShading_FlatB 0x00000800
+#define HC_HShading_FlatC 0x00000c00
+#define HC_HShading_Gouraud 0x00001000
+#define HC_HVCycle_Full 0x00000000
+#define HC_HVCycle_AFP 0x00000040
+#define HC_HVCycle_One 0x000000c0
+#define HC_HVCycle_NewA 0x00000000
+#define HC_HVCycle_AA 0x00000010
+#define HC_HVCycle_AB 0x00000020
+#define HC_HVCycle_AC 0x00000030
+#define HC_HVCycle_NewB 0x00000000
+#define HC_HVCycle_BA 0x00000004
+#define HC_HVCycle_BB 0x00000008
+#define HC_HVCycle_BC 0x0000000c
+#define HC_HVCycle_NewC 0x00000000
+#define HC_HVCycle_CA 0x00000001
+#define HC_HVCycle_CB 0x00000002
+#define HC_HVCycle_CC 0x00000003
+
+/* Command B
+ */
+#define HC_HLPrst_MASK 0x00010000
+#define HC_HLLastP_MASK 0x00008000
+#define HC_HVPMSK_MASK 0x00007f80
+#define HC_HBFace_MASK 0x00000040
+#define HC_H2nd1VT_MASK 0x0000003f
+#define HC_HVPMSK_X 0x00004000
+#define HC_HVPMSK_Y 0x00002000
+#define HC_HVPMSK_Z 0x00001000
+#define HC_HVPMSK_W 0x00000800
+#define HC_HVPMSK_Cd 0x00000400
+#define HC_HVPMSK_Cs 0x00000200
+#define HC_HVPMSK_S 0x00000100
+#define HC_HVPMSK_T 0x00000080
+
+/* Enable Setting
+ */
+#define HC_SubA_HEnable 0x0000
+#define HC_HenTXEnvMap_MASK 0x00200000
+#define HC_HenVertexCNT_MASK 0x00100000
+#define HC_HenCPUDAZ_MASK 0x00080000
+#define HC_HenDASZWC_MASK 0x00040000
+#define HC_HenFBCull_MASK 0x00020000
+#define HC_HenCW_MASK 0x00010000
+#define HC_HenAA_MASK 0x00008000
+#define HC_HenST_MASK 0x00004000
+#define HC_HenZT_MASK 0x00002000
+#define HC_HenZW_MASK 0x00001000
+#define HC_HenAT_MASK 0x00000800
+#define HC_HenAW_MASK 0x00000400
+#define HC_HenSP_MASK 0x00000200
+#define HC_HenLP_MASK 0x00000100
+#define HC_HenTXCH_MASK 0x00000080
+#define HC_HenTXMP_MASK 0x00000040
+#define HC_HenTXPP_MASK 0x00000020
+#define HC_HenTXTR_MASK 0x00000010
+#define HC_HenCS_MASK 0x00000008
+#define HC_HenFOG_MASK 0x00000004
+#define HC_HenABL_MASK 0x00000002
+#define HC_HenDT_MASK 0x00000001
+
+/* Z Setting
+ */
+#define HC_SubA_HZWBBasL 0x0010
+#define HC_SubA_HZWBBasH 0x0011
+#define HC_SubA_HZWBType 0x0012
+#define HC_SubA_HZBiasL 0x0013
+#define HC_SubA_HZWBend 0x0014
+#define HC_SubA_HZWTMD 0x0015
+#define HC_SubA_HZWCDL 0x0016
+#define HC_SubA_HZWCTAGnum 0x0017
+#define HC_SubA_HZCYNum 0x0018
+#define HC_SubA_HZWCFire 0x0019
+/* HC_SubA_HZWBType
+ */
+#define HC_HZWBType_MASK 0x00800000
+#define HC_HZBiasedWB_MASK 0x00400000
+#define HC_HZONEasFF_MASK 0x00200000
+#define HC_HZOONEasFF_MASK 0x00100000
+#define HC_HZWBFM_MASK 0x00030000
+#define HC_HZWBLoc_MASK 0x0000c000
+#define HC_HZWBPit_MASK 0x00003fff
+#define HC_HZWBFM_16 0x00000000
+#define HC_HZWBFM_32 0x00020000
+#define HC_HZWBFM_24 0x00030000
+#define HC_HZWBLoc_Local 0x00000000
+#define HC_HZWBLoc_SyS 0x00004000
+/* HC_SubA_HZWBend
+ */
+#define HC_HZWBend_MASK 0x00ffe000
+#define HC_HZBiasH_MASK 0x000000ff
+#define HC_HZWBend_SHIFT 10
+/* HC_SubA_HZWTMD
+ */
+#define HC_HZWTMD_MASK 0x00070000
+#define HC_HEBEBias_MASK 0x00007f00
+#define HC_HZNF_MASK 0x000000ff
+#define HC_HZWTMD_NeverPass 0x00000000
+#define HC_HZWTMD_LT 0x00010000
+#define HC_HZWTMD_EQ 0x00020000
+#define HC_HZWTMD_LE 0x00030000
+#define HC_HZWTMD_GT 0x00040000
+#define HC_HZWTMD_NE 0x00050000
+#define HC_HZWTMD_GE 0x00060000
+#define HC_HZWTMD_AllPass 0x00070000
+#define HC_HEBEBias_SHIFT 8
+/* HC_SubA_HZWCDL 0x0016
+ */
+#define HC_HZWCDL_MASK 0x00ffffff
+/* HC_SubA_HZWCTAGnum 0x0017
+ */
+#define HC_HZWCTAGnum_MASK 0x00ff0000
+#define HC_HZWCTAGnum_SHIFT 16
+#define HC_HZWCDH_MASK 0x000000ff
+#define HC_HZWCDH_SHIFT 0
+/* HC_SubA_HZCYNum 0x0018
+ */
+#define HC_HZCYNum_MASK 0x00030000
+#define HC_HZCYNum_SHIFT 16
+#define HC_HZWCQWnum_MASK 0x00003fff
+#define HC_HZWCQWnum_SHIFT 0
+/* HC_SubA_HZWCFire 0x0019
+ */
+#define HC_ZWCFire_MASK 0x00010000
+#define HC_HZWCQWnumLast_MASK 0x00003fff
+#define HC_HZWCQWnumLast_SHIFT 0
+
+/* Stencil Setting
+ */
+#define HC_SubA_HSTREF 0x0023
+#define HC_SubA_HSTMD 0x0024
+/* HC_SubA_HSBFM
+ */
+#define HC_HSBFM_MASK 0x00030000
+#define HC_HSBLoc_MASK 0x0000c000
+#define HC_HSBPit_MASK 0x00003fff
+/* HC_SubA_HSTREF
+ */
+#define HC_HSTREF_MASK 0x00ff0000
+#define HC_HSTOPMSK_MASK 0x0000ff00
+#define HC_HSTBMSK_MASK 0x000000ff
+#define HC_HSTREF_SHIFT 16
+#define HC_HSTOPMSK_SHIFT 8
+/* HC_SubA_HSTMD
+ */
+#define HC_HSTMD_MASK 0x00070000
+#define HC_HSTOPSF_MASK 0x000001c0
+#define HC_HSTOPSPZF_MASK 0x00000038
+#define HC_HSTOPSPZP_MASK 0x00000007
+#define HC_HSTMD_NeverPass 0x00000000
+#define HC_HSTMD_LT 0x00010000
+#define HC_HSTMD_EQ 0x00020000
+#define HC_HSTMD_LE 0x00030000
+#define HC_HSTMD_GT 0x00040000
+#define HC_HSTMD_NE 0x00050000
+#define HC_HSTMD_GE 0x00060000
+#define HC_HSTMD_AllPass 0x00070000
+#define HC_HSTOPSF_KEEP 0x00000000
+#define HC_HSTOPSF_ZERO 0x00000040
+#define HC_HSTOPSF_REPLACE 0x00000080
+#define HC_HSTOPSF_INCRSAT 0x000000c0
+#define HC_HSTOPSF_DECRSAT 0x00000100
+#define HC_HSTOPSF_INVERT 0x00000140
+#define HC_HSTOPSF_INCR 0x00000180
+#define HC_HSTOPSF_DECR 0x000001c0
+#define HC_HSTOPSPZF_KEEP 0x00000000
+#define HC_HSTOPSPZF_ZERO 0x00000008
+#define HC_HSTOPSPZF_REPLACE 0x00000010
+#define HC_HSTOPSPZF_INCRSAT 0x00000018
+#define HC_HSTOPSPZF_DECRSAT 0x00000020
+#define HC_HSTOPSPZF_INVERT 0x00000028
+#define HC_HSTOPSPZF_INCR 0x00000030
+#define HC_HSTOPSPZF_DECR 0x00000038
+#define HC_HSTOPSPZP_KEEP 0x00000000
+#define HC_HSTOPSPZP_ZERO 0x00000001
+#define HC_HSTOPSPZP_REPLACE 0x00000002
+#define HC_HSTOPSPZP_INCRSAT 0x00000003
+#define HC_HSTOPSPZP_DECRSAT 0x00000004
+#define HC_HSTOPSPZP_INVERT 0x00000005
+#define HC_HSTOPSPZP_INCR 0x00000006
+#define HC_HSTOPSPZP_DECR 0x00000007
+
+/* Alpha Setting
+ */
+#define HC_SubA_HABBasL 0x0030
+#define HC_SubA_HABBasH 0x0031
+#define HC_SubA_HABFM 0x0032
+#define HC_SubA_HATMD 0x0033
+#define HC_SubA_HABLCsat 0x0034
+#define HC_SubA_HABLCop 0x0035
+#define HC_SubA_HABLAsat 0x0036
+#define HC_SubA_HABLAop 0x0037
+#define HC_SubA_HABLRCa 0x0038
+#define HC_SubA_HABLRFCa 0x0039
+#define HC_SubA_HABLRCbias 0x003a
+#define HC_SubA_HABLRCb 0x003b
+#define HC_SubA_HABLRFCb 0x003c
+#define HC_SubA_HABLRAa 0x003d
+#define HC_SubA_HABLRAb 0x003e
+/* HC_SubA_HABFM
+ */
+#define HC_HABFM_MASK 0x00030000
+#define HC_HABLoc_MASK 0x0000c000
+#define HC_HABPit_MASK 0x000007ff
+/* HC_SubA_HATMD
+ */
+#define HC_HATMD_MASK 0x00000700
+#define HC_HATREF_MASK 0x000000ff
+#define HC_HATMD_NeverPass 0x00000000
+#define HC_HATMD_LT 0x00000100
+#define HC_HATMD_EQ 0x00000200
+#define HC_HATMD_LE 0x00000300
+#define HC_HATMD_GT 0x00000400
+#define HC_HATMD_NE 0x00000500
+#define HC_HATMD_GE 0x00000600
+#define HC_HATMD_AllPass 0x00000700
+/* HC_SubA_HABLCsat
+ */
+#define HC_HABLCsat_MASK 0x00010000
+#define HC_HABLCa_MASK 0x0000fc00
+#define HC_HABLCa_C_MASK 0x0000c000
+#define HC_HABLCa_OPC_MASK 0x00003c00
+#define HC_HABLFCa_MASK 0x000003f0
+#define HC_HABLFCa_C_MASK 0x00000300
+#define HC_HABLFCa_OPC_MASK 0x000000f0
+#define HC_HABLCbias_MASK 0x0000000f
+#define HC_HABLCbias_C_MASK 0x00000008
+#define HC_HABLCbias_OPC_MASK 0x00000007
+/*-- Define the input color.
+ */
+#define HC_XC_Csrc 0x00000000
+#define HC_XC_Cdst 0x00000001
+#define HC_XC_Asrc 0x00000002
+#define HC_XC_Adst 0x00000003
+#define HC_XC_Fog 0x00000004
+#define HC_XC_HABLRC 0x00000005
+#define HC_XC_minSrcDst 0x00000006
+#define HC_XC_maxSrcDst 0x00000007
+#define HC_XC_mimAsrcInvAdst 0x00000008
+#define HC_XC_OPC 0x00000000
+#define HC_XC_InvOPC 0x00000010
+#define HC_XC_OPCp5 0x00000020
+/*-- Define the input Alpha
+ */
+#define HC_XA_OPA 0x00000000
+#define HC_XA_InvOPA 0x00000010
+#define HC_XA_OPAp5 0x00000020
+#define HC_XA_0 0x00000000
+#define HC_XA_Asrc 0x00000001
+#define HC_XA_Adst 0x00000002
+#define HC_XA_Fog 0x00000003
+#define HC_XA_minAsrcFog 0x00000004
+#define HC_XA_minAsrcAdst 0x00000005
+#define HC_XA_maxAsrcFog 0x00000006
+#define HC_XA_maxAsrcAdst 0x00000007
+#define HC_XA_HABLRA 0x00000008
+#define HC_XA_minAsrcInvAdst 0x00000008
+#define HC_XA_HABLFRA 0x00000009
+/*--
+ */
+#define HC_HABLCa_OPC (HC_XC_OPC << 10)
+#define HC_HABLCa_InvOPC (HC_XC_InvOPC << 10)
+#define HC_HABLCa_OPCp5 (HC_XC_OPCp5 << 10)
+#define HC_HABLCa_Csrc (HC_XC_Csrc << 10)
+#define HC_HABLCa_Cdst (HC_XC_Cdst << 10)
+#define HC_HABLCa_Asrc (HC_XC_Asrc << 10)
+#define HC_HABLCa_Adst (HC_XC_Adst << 10)
+#define HC_HABLCa_Fog (HC_XC_Fog << 10)
+#define HC_HABLCa_HABLRCa (HC_XC_HABLRC << 10)
+#define HC_HABLCa_minSrcDst (HC_XC_minSrcDst << 10)
+#define HC_HABLCa_maxSrcDst (HC_XC_maxSrcDst << 10)
+#define HC_HABLFCa_OPC (HC_XC_OPC << 4)
+#define HC_HABLFCa_InvOPC (HC_XC_InvOPC << 4)
+#define HC_HABLFCa_OPCp5 (HC_XC_OPCp5 << 4)
+#define HC_HABLFCa_Csrc (HC_XC_Csrc << 4)
+#define HC_HABLFCa_Cdst (HC_XC_Cdst << 4)
+#define HC_HABLFCa_Asrc (HC_XC_Asrc << 4)
+#define HC_HABLFCa_Adst (HC_XC_Adst << 4)
+#define HC_HABLFCa_Fog (HC_XC_Fog << 4)
+#define HC_HABLFCa_HABLRCa (HC_XC_HABLRC << 4)
+#define HC_HABLFCa_minSrcDst (HC_XC_minSrcDst << 4)
+#define HC_HABLFCa_maxSrcDst (HC_XC_maxSrcDst << 4)
+#define HC_HABLFCa_mimAsrcInvAdst (HC_XC_mimAsrcInvAdst << 4)
+#define HC_HABLCbias_HABLRCbias 0x00000000
+#define HC_HABLCbias_Asrc 0x00000001
+#define HC_HABLCbias_Adst 0x00000002
+#define HC_HABLCbias_Fog 0x00000003
+#define HC_HABLCbias_Cin 0x00000004
+/* HC_SubA_HABLCop 0x0035
+ */
+#define HC_HABLdot_MASK 0x00010000
+#define HC_HABLCop_MASK 0x00004000
+#define HC_HABLCb_MASK 0x00003f00
+#define HC_HABLCb_C_MASK 0x00003000
+#define HC_HABLCb_OPC_MASK 0x00000f00
+#define HC_HABLFCb_MASK 0x000000fc
+#define HC_HABLFCb_C_MASK 0x000000c0
+#define HC_HABLFCb_OPC_MASK 0x0000003c
+#define HC_HABLCshift_MASK 0x00000003
+#define HC_HABLCb_OPC (HC_XC_OPC << 8)
+#define HC_HABLCb_InvOPC (HC_XC_InvOPC << 8)
+#define HC_HABLCb_OPCp5 (HC_XC_OPCp5 << 8)
+#define HC_HABLCb_Csrc (HC_XC_Csrc << 8)
+#define HC_HABLCb_Cdst (HC_XC_Cdst << 8)
+#define HC_HABLCb_Asrc (HC_XC_Asrc << 8)
+#define HC_HABLCb_Adst (HC_XC_Adst << 8)
+#define HC_HABLCb_Fog (HC_XC_Fog << 8)
+#define HC_HABLCb_HABLRCa (HC_XC_HABLRC << 8)
+#define HC_HABLCb_minSrcDst (HC_XC_minSrcDst << 8)
+#define HC_HABLCb_maxSrcDst (HC_XC_maxSrcDst << 8)
+#define HC_HABLFCb_OPC (HC_XC_OPC << 2)
+#define HC_HABLFCb_InvOPC (HC_XC_InvOPC << 2)
+#define HC_HABLFCb_OPCp5 (HC_XC_OPCp5 << 2)
+#define HC_HABLFCb_Csrc (HC_XC_Csrc << 2)
+#define HC_HABLFCb_Cdst (HC_XC_Cdst << 2)
+#define HC_HABLFCb_Asrc (HC_XC_Asrc << 2)
+#define HC_HABLFCb_Adst (HC_XC_Adst << 2)
+#define HC_HABLFCb_Fog (HC_XC_Fog << 2)
+#define HC_HABLFCb_HABLRCb (HC_XC_HABLRC << 2)
+#define HC_HABLFCb_minSrcDst (HC_XC_minSrcDst << 2)
+#define HC_HABLFCb_maxSrcDst (HC_XC_maxSrcDst << 2)
+#define HC_HABLFCb_mimAsrcInvAdst (HC_XC_mimAsrcInvAdst << 2)
+/* HC_SubA_HABLAsat 0x0036
+ */
+#define HC_HABLAsat_MASK 0x00010000
+#define HC_HABLAa_MASK 0x0000fc00
+#define HC_HABLAa_A_MASK 0x0000c000
+#define HC_HABLAa_OPA_MASK 0x00003c00
+#define HC_HABLFAa_MASK 0x000003f0
+#define HC_HABLFAa_A_MASK 0x00000300
+#define HC_HABLFAa_OPA_MASK 0x000000f0
+#define HC_HABLAbias_MASK 0x0000000f
+#define HC_HABLAbias_A_MASK 0x00000008
+#define HC_HABLAbias_OPA_MASK 0x00000007
+#define HC_HABLAa_OPA (HC_XA_OPA << 10)
+#define HC_HABLAa_InvOPA (HC_XA_InvOPA << 10)
+#define HC_HABLAa_OPAp5 (HC_XA_OPAp5 << 10)
+#define HC_HABLAa_0 (HC_XA_0 << 10)
+#define HC_HABLAa_Asrc (HC_XA_Asrc << 10)
+#define HC_HABLAa_Adst (HC_XA_Adst << 10)
+#define HC_HABLAa_Fog (HC_XA_Fog << 10)
+#define HC_HABLAa_minAsrcFog (HC_XA_minAsrcFog << 10)
+#define HC_HABLAa_minAsrcAdst (HC_XA_minAsrcAdst << 10)
+#define HC_HABLAa_maxAsrcFog (HC_XA_maxAsrcFog << 10)
+#define HC_HABLAa_maxAsrcAdst (HC_XA_maxAsrcAdst << 10)
+#define HC_HABLAa_HABLRA (HC_XA_HABLRA << 10)
+#define HC_HABLFAa_OPA (HC_XA_OPA << 4)
+#define HC_HABLFAa_InvOPA (HC_XA_InvOPA << 4)
+#define HC_HABLFAa_OPAp5 (HC_XA_OPAp5 << 4)
+#define HC_HABLFAa_0 (HC_XA_0 << 4)
+#define HC_HABLFAa_Asrc (HC_XA_Asrc << 4)
+#define HC_HABLFAa_Adst (HC_XA_Adst << 4)
+#define HC_HABLFAa_Fog (HC_XA_Fog << 4)
+#define HC_HABLFAa_minAsrcFog (HC_XA_minAsrcFog << 4)
+#define HC_HABLFAa_minAsrcAdst (HC_XA_minAsrcAdst << 4)
+#define HC_HABLFAa_maxAsrcFog (HC_XA_maxAsrcFog << 4)
+#define HC_HABLFAa_maxAsrcAdst (HC_XA_maxAsrcAdst << 4)
+#define HC_HABLFAa_minAsrcInvAdst (HC_XA_minAsrcInvAdst << 4)
+#define HC_HABLFAa_HABLFRA (HC_XA_HABLFRA << 4)
+#define HC_HABLAbias_HABLRAbias 0x00000000
+#define HC_HABLAbias_Asrc 0x00000001
+#define HC_HABLAbias_Adst 0x00000002
+#define HC_HABLAbias_Fog 0x00000003
+#define HC_HABLAbias_Aaa 0x00000004
+/* HC_SubA_HABLAop 0x0037
+ */
+#define HC_HABLAop_MASK 0x00004000
+#define HC_HABLAb_MASK 0x00003f00
+#define HC_HABLAb_OPA_MASK 0x00000f00
+#define HC_HABLFAb_MASK 0x000000fc
+#define HC_HABLFAb_OPA_MASK 0x0000003c
+#define HC_HABLAshift_MASK 0x00000003
+#define HC_HABLAb_OPA (HC_XA_OPA << 8)
+#define HC_HABLAb_InvOPA (HC_XA_InvOPA << 8)
+#define HC_HABLAb_OPAp5 (HC_XA_OPAp5 << 8)
+#define HC_HABLAb_0 (HC_XA_0 << 8)
+#define HC_HABLAb_Asrc (HC_XA_Asrc << 8)
+#define HC_HABLAb_Adst (HC_XA_Adst << 8)
+#define HC_HABLAb_Fog (HC_XA_Fog << 8)
+#define HC_HABLAb_minAsrcFog (HC_XA_minAsrcFog << 8)
+#define HC_HABLAb_minAsrcAdst (HC_XA_minAsrcAdst << 8)
+#define HC_HABLAb_maxAsrcFog (HC_XA_maxAsrcFog << 8)
+#define HC_HABLAb_maxAsrcAdst (HC_XA_maxAsrcAdst << 8)
+#define HC_HABLAb_HABLRA (HC_XA_HABLRA << 8)
+#define HC_HABLFAb_OPA (HC_XA_OPA << 2)
+#define HC_HABLFAb_InvOPA (HC_XA_InvOPA << 2)
+#define HC_HABLFAb_OPAp5 (HC_XA_OPAp5 << 2)
+#define HC_HABLFAb_0 (HC_XA_0 << 2)
+#define HC_HABLFAb_Asrc (HC_XA_Asrc << 2)
+#define HC_HABLFAb_Adst (HC_XA_Adst << 2)
+#define HC_HABLFAb_Fog (HC_XA_Fog << 2)
+#define HC_HABLFAb_minAsrcFog (HC_XA_minAsrcFog << 2)
+#define HC_HABLFAb_minAsrcAdst (HC_XA_minAsrcAdst << 2)
+#define HC_HABLFAb_maxAsrcFog (HC_XA_maxAsrcFog << 2)
+#define HC_HABLFAb_maxAsrcAdst (HC_XA_maxAsrcAdst << 2)
+#define HC_HABLFAb_minAsrcInvAdst (HC_XA_minAsrcInvAdst << 2)
+#define HC_HABLFAb_HABLFRA (HC_XA_HABLFRA << 2)
+/* HC_SubA_HABLRAa 0x003d
+ */
+#define HC_HABLRAa_MASK 0x00ff0000
+#define HC_HABLRFAa_MASK 0x0000ff00
+#define HC_HABLRAbias_MASK 0x000000ff
+#define HC_HABLRAa_SHIFT 16
+#define HC_HABLRFAa_SHIFT 8
+/* HC_SubA_HABLRAb 0x003e
+ */
+#define HC_HABLRAb_MASK 0x0000ff00
+#define HC_HABLRFAb_MASK 0x000000ff
+#define HC_HABLRAb_SHIFT 8
+
+/* Destination Setting
+ */
+#define HC_SubA_HDBBasL 0x0040
+#define HC_SubA_HDBBasH 0x0041
+#define HC_SubA_HDBFM 0x0042
+#define HC_SubA_HFBBMSKL 0x0043
+#define HC_SubA_HROP 0x0044
+/* HC_SubA_HDBFM 0x0042
+ */
+#define HC_HDBFM_MASK 0x001f0000
+#define HC_HDBLoc_MASK 0x0000c000
+#define HC_HDBPit_MASK 0x00003fff
+#define HC_HDBFM_RGB555 0x00000000
+#define HC_HDBFM_RGB565 0x00010000
+#define HC_HDBFM_ARGB4444 0x00020000
+#define HC_HDBFM_ARGB1555 0x00030000
+#define HC_HDBFM_BGR555 0x00040000
+#define HC_HDBFM_BGR565 0x00050000
+#define HC_HDBFM_ABGR4444 0x00060000
+#define HC_HDBFM_ABGR1555 0x00070000
+#define HC_HDBFM_ARGB0888 0x00080000
+#define HC_HDBFM_ARGB8888 0x00090000
+#define HC_HDBFM_ABGR0888 0x000a0000
+#define HC_HDBFM_ABGR8888 0x000b0000
+#define HC_HDBLoc_Local 0x00000000
+#define HC_HDBLoc_Sys 0x00004000
+/* HC_SubA_HROP 0x0044
+ */
+#define HC_HROP_MASK 0x00000f00
+#define HC_HFBBMSKH_MASK 0x000000ff
+#define HC_HROP_BLACK 0x00000000
+#define HC_HROP_DPon 0x00000100
+#define HC_HROP_DPna 0x00000200
+#define HC_HROP_Pn 0x00000300
+#define HC_HROP_PDna 0x00000400
+#define HC_HROP_Dn 0x00000500
+#define HC_HROP_DPx 0x00000600
+#define HC_HROP_DPan 0x00000700
+#define HC_HROP_DPa 0x00000800
+#define HC_HROP_DPxn 0x00000900
+#define HC_HROP_D 0x00000a00
+#define HC_HROP_DPno 0x00000b00
+#define HC_HROP_P 0x00000c00
+#define HC_HROP_PDno 0x00000d00
+#define HC_HROP_DPo 0x00000e00
+#define HC_HROP_WHITE 0x00000f00
+
+/* Fog Setting
+ */
+#define HC_SubA_HFogLF 0x0050
+#define HC_SubA_HFogCL 0x0051
+#define HC_SubA_HFogCH 0x0052
+#define HC_SubA_HFogStL 0x0053
+#define HC_SubA_HFogStH 0x0054
+#define HC_SubA_HFogOOdMF 0x0055
+#define HC_SubA_HFogOOdEF 0x0056
+#define HC_SubA_HFogEndL 0x0057
+#define HC_SubA_HFogDenst 0x0058
+/* HC_SubA_FogLF 0x0050
+ */
+#define HC_FogLF_MASK 0x00000010
+#define HC_FogEq_MASK 0x00000008
+#define HC_FogMD_MASK 0x00000007
+#define HC_FogMD_LocalFog 0x00000000
+#define HC_FogMD_LinearFog 0x00000002
+#define HC_FogMD_ExponentialFog 0x00000004
+#define HC_FogMD_Exponential2Fog 0x00000005
+/* #define HC_FogMD_FogTable 0x00000003 */
+
+/* HC_SubA_HFogDenst 0x0058
+ */
+#define HC_FogDenst_MASK 0x001fff00
+#define HC_FogEndL_MASK 0x000000ff
+
+/* Texture subtype definitions
+ */
+#define HC_SubType_Tex0 0x00000000
+#define HC_SubType_Tex1 0x00000001
+#define HC_SubType_TexGeneral 0x000000fe
+
+/* Attribute of texture n
+ */
+#define HC_SubA_HTXnL0BasL 0x0000
+#define HC_SubA_HTXnL1BasL 0x0001
+#define HC_SubA_HTXnL2BasL 0x0002
+#define HC_SubA_HTXnL3BasL 0x0003
+#define HC_SubA_HTXnL4BasL 0x0004
+#define HC_SubA_HTXnL5BasL 0x0005
+#define HC_SubA_HTXnL6BasL 0x0006
+#define HC_SubA_HTXnL7BasL 0x0007
+#define HC_SubA_HTXnL8BasL 0x0008
+#define HC_SubA_HTXnL9BasL 0x0009
+#define HC_SubA_HTXnLaBasL 0x000a
+#define HC_SubA_HTXnLbBasL 0x000b
+#define HC_SubA_HTXnLcBasL 0x000c
+#define HC_SubA_HTXnLdBasL 0x000d
+#define HC_SubA_HTXnLeBasL 0x000e
+#define HC_SubA_HTXnLfBasL 0x000f
+#define HC_SubA_HTXnL10BasL 0x0010
+#define HC_SubA_HTXnL11BasL 0x0011
+#define HC_SubA_HTXnL012BasH 0x0020
+#define HC_SubA_HTXnL345BasH 0x0021
+#define HC_SubA_HTXnL678BasH 0x0022
+#define HC_SubA_HTXnL9abBasH 0x0023
+#define HC_SubA_HTXnLcdeBasH 0x0024
+#define HC_SubA_HTXnLf1011BasH 0x0025
+#define HC_SubA_HTXnL0Pit 0x002b
+#define HC_SubA_HTXnL1Pit 0x002c
+#define HC_SubA_HTXnL2Pit 0x002d
+#define HC_SubA_HTXnL3Pit 0x002e
+#define HC_SubA_HTXnL4Pit 0x002f
+#define HC_SubA_HTXnL5Pit 0x0030
+#define HC_SubA_HTXnL6Pit 0x0031
+#define HC_SubA_HTXnL7Pit 0x0032
+#define HC_SubA_HTXnL8Pit 0x0033
+#define HC_SubA_HTXnL9Pit 0x0034
+#define HC_SubA_HTXnLaPit 0x0035
+#define HC_SubA_HTXnLbPit 0x0036
+#define HC_SubA_HTXnLcPit 0x0037
+#define HC_SubA_HTXnLdPit 0x0038
+#define HC_SubA_HTXnLePit 0x0039
+#define HC_SubA_HTXnLfPit 0x003a
+#define HC_SubA_HTXnL10Pit 0x003b
+#define HC_SubA_HTXnL11Pit 0x003c
+#define HC_SubA_HTXnL0_5WE 0x004b
+#define HC_SubA_HTXnL6_bWE 0x004c
+#define HC_SubA_HTXnLc_11WE 0x004d
+#define HC_SubA_HTXnL0_5HE 0x0051
+#define HC_SubA_HTXnL6_bHE 0x0052
+#define HC_SubA_HTXnLc_11HE 0x0053
+#define HC_SubA_HTXnL0OS 0x0077
+#define HC_SubA_HTXnTB 0x0078
+#define HC_SubA_HTXnMPMD 0x0079
+#define HC_SubA_HTXnCLODu 0x007a
+#define HC_SubA_HTXnFM 0x007b
+#define HC_SubA_HTXnTRCH 0x007c
+#define HC_SubA_HTXnTRCL 0x007d
+#define HC_SubA_HTXnTBC 0x007e
+#define HC_SubA_HTXnTRAH 0x007f
+#define HC_SubA_HTXnTBLCsat 0x0080
+#define HC_SubA_HTXnTBLCop 0x0081
+#define HC_SubA_HTXnTBLMPfog 0x0082
+#define HC_SubA_HTXnTBLAsat 0x0083
+#define HC_SubA_HTXnTBLRCa 0x0085
+#define HC_SubA_HTXnTBLRCb 0x0086
+#define HC_SubA_HTXnTBLRCc 0x0087
+#define HC_SubA_HTXnTBLRCbias 0x0088
+#define HC_SubA_HTXnTBLRAa 0x0089
+#define HC_SubA_HTXnTBLRFog 0x008a
+#define HC_SubA_HTXnBumpM00 0x0090
+#define HC_SubA_HTXnBumpM01 0x0091
+#define HC_SubA_HTXnBumpM10 0x0092
+#define HC_SubA_HTXnBumpM11 0x0093
+#define HC_SubA_HTXnLScale 0x0094
+#define HC_SubA_HTXSMD 0x0000
+/* HC_SubA_HTXnL012BasH 0x0020
+ */
+#define HC_HTXnL0BasH_MASK 0x000000ff
+#define HC_HTXnL1BasH_MASK 0x0000ff00
+#define HC_HTXnL2BasH_MASK 0x00ff0000
+#define HC_HTXnL1BasH_SHIFT 8
+#define HC_HTXnL2BasH_SHIFT 16
+/* HC_SubA_HTXnL345BasH 0x0021
+ */
+#define HC_HTXnL3BasH_MASK 0x000000ff
+#define HC_HTXnL4BasH_MASK 0x0000ff00
+#define HC_HTXnL5BasH_MASK 0x00ff0000
+#define HC_HTXnL4BasH_SHIFT 8
+#define HC_HTXnL5BasH_SHIFT 16
+/* HC_SubA_HTXnL678BasH 0x0022
+ */
+#define HC_HTXnL6BasH_MASK 0x000000ff
+#define HC_HTXnL7BasH_MASK 0x0000ff00
+#define HC_HTXnL8BasH_MASK 0x00ff0000
+#define HC_HTXnL7BasH_SHIFT 8
+#define HC_HTXnL8BasH_SHIFT 16
+/* HC_SubA_HTXnL9abBasH 0x0023
+ */
+#define HC_HTXnL9BasH_MASK 0x000000ff
+#define HC_HTXnLaBasH_MASK 0x0000ff00
+#define HC_HTXnLbBasH_MASK 0x00ff0000
+#define HC_HTXnLaBasH_SHIFT 8
+#define HC_HTXnLbBasH_SHIFT 16
+/* HC_SubA_HTXnLcdeBasH 0x0024
+ */
+#define HC_HTXnLcBasH_MASK 0x000000ff
+#define HC_HTXnLdBasH_MASK 0x0000ff00
+#define HC_HTXnLeBasH_MASK 0x00ff0000
+#define HC_HTXnLdBasH_SHIFT 8
+#define HC_HTXnLeBasH_SHIFT 16
+/* HC_SubA_HTXnLcdeBasH 0x0025
+ */
+#define HC_HTXnLfBasH_MASK 0x000000ff
+#define HC_HTXnL10BasH_MASK 0x0000ff00
+#define HC_HTXnL11BasH_MASK 0x00ff0000
+#define HC_HTXnL10BasH_SHIFT 8
+#define HC_HTXnL11BasH_SHIFT 16
+/* HC_SubA_HTXnL0Pit 0x002b
+ */
+#define HC_HTXnLnPit_MASK 0x00003fff
+#define HC_HTXnEnPit_MASK 0x00080000
+#define HC_HTXnLnPitE_MASK 0x00f00000
+#define HC_HTXnLnPitE_SHIFT 20
+/* HC_SubA_HTXnL0_5WE 0x004b
+ */
+#define HC_HTXnL0WE_MASK 0x0000000f
+#define HC_HTXnL1WE_MASK 0x000000f0
+#define HC_HTXnL2WE_MASK 0x00000f00
+#define HC_HTXnL3WE_MASK 0x0000f000
+#define HC_HTXnL4WE_MASK 0x000f0000
+#define HC_HTXnL5WE_MASK 0x00f00000
+#define HC_HTXnL1WE_SHIFT 4
+#define HC_HTXnL2WE_SHIFT 8
+#define HC_HTXnL3WE_SHIFT 12
+#define HC_HTXnL4WE_SHIFT 16
+#define HC_HTXnL5WE_SHIFT 20
+/* HC_SubA_HTXnL6_bWE 0x004c
+ */
+#define HC_HTXnL6WE_MASK 0x0000000f
+#define HC_HTXnL7WE_MASK 0x000000f0
+#define HC_HTXnL8WE_MASK 0x00000f00
+#define HC_HTXnL9WE_MASK 0x0000f000
+#define HC_HTXnLaWE_MASK 0x000f0000
+#define HC_HTXnLbWE_MASK 0x00f00000
+#define HC_HTXnL7WE_SHIFT 4
+#define HC_HTXnL8WE_SHIFT 8
+#define HC_HTXnL9WE_SHIFT 12
+#define HC_HTXnLaWE_SHIFT 16
+#define HC_HTXnLbWE_SHIFT 20
+/* HC_SubA_HTXnLc_11WE 0x004d
+ */
+#define HC_HTXnLcWE_MASK 0x0000000f
+#define HC_HTXnLdWE_MASK 0x000000f0
+#define HC_HTXnLeWE_MASK 0x00000f00
+#define HC_HTXnLfWE_MASK 0x0000f000
+#define HC_HTXnL10WE_MASK 0x000f0000
+#define HC_HTXnL11WE_MASK 0x00f00000
+#define HC_HTXnLdWE_SHIFT 4
+#define HC_HTXnLeWE_SHIFT 8
+#define HC_HTXnLfWE_SHIFT 12
+#define HC_HTXnL10WE_SHIFT 16
+#define HC_HTXnL11WE_SHIFT 20
+/* HC_SubA_HTXnL0_5HE 0x0051
+ */
+#define HC_HTXnL0HE_MASK 0x0000000f
+#define HC_HTXnL1HE_MASK 0x000000f0
+#define HC_HTXnL2HE_MASK 0x00000f00
+#define HC_HTXnL3HE_MASK 0x0000f000
+#define HC_HTXnL4HE_MASK 0x000f0000
+#define HC_HTXnL5HE_MASK 0x00f00000
+#define HC_HTXnL1HE_SHIFT 4
+#define HC_HTXnL2HE_SHIFT 8
+#define HC_HTXnL3HE_SHIFT 12
+#define HC_HTXnL4HE_SHIFT 16
+#define HC_HTXnL5HE_SHIFT 20
+/* HC_SubA_HTXnL6_bHE 0x0052
+ */
+#define HC_HTXnL6HE_MASK 0x0000000f
+#define HC_HTXnL7HE_MASK 0x000000f0
+#define HC_HTXnL8HE_MASK 0x00000f00
+#define HC_HTXnL9HE_MASK 0x0000f000
+#define HC_HTXnLaHE_MASK 0x000f0000
+#define HC_HTXnLbHE_MASK 0x00f00000
+#define HC_HTXnL7HE_SHIFT 4
+#define HC_HTXnL8HE_SHIFT 8
+#define HC_HTXnL9HE_SHIFT 12
+#define HC_HTXnLaHE_SHIFT 16
+#define HC_HTXnLbHE_SHIFT 20
+/* HC_SubA_HTXnLc_11HE 0x0053
+ */
+#define HC_HTXnLcHE_MASK 0x0000000f
+#define HC_HTXnLdHE_MASK 0x000000f0
+#define HC_HTXnLeHE_MASK 0x00000f00
+#define HC_HTXnLfHE_MASK 0x0000f000
+#define HC_HTXnL10HE_MASK 0x000f0000
+#define HC_HTXnL11HE_MASK 0x00f00000
+#define HC_HTXnLdHE_SHIFT 4
+#define HC_HTXnLeHE_SHIFT 8
+#define HC_HTXnLfHE_SHIFT 12
+#define HC_HTXnL10HE_SHIFT 16
+#define HC_HTXnL11HE_SHIFT 20
+/* HC_SubA_HTXnL0OS 0x0077
+ */
+#define HC_HTXnL0OS_MASK 0x003ff000
+#define HC_HTXnLVmax_MASK 0x00000fc0
+#define HC_HTXnLVmin_MASK 0x0000003f
+#define HC_HTXnL0OS_SHIFT 12
+#define HC_HTXnLVmax_SHIFT 6
+/* HC_SubA_HTXnTB 0x0078
+ */
+#define HC_HTXnTB_MASK 0x00f00000
+#define HC_HTXnFLSe_MASK 0x0000e000
+#define HC_HTXnFLSs_MASK 0x00001c00
+#define HC_HTXnFLTe_MASK 0x00000380
+#define HC_HTXnFLTs_MASK 0x00000070
+#define HC_HTXnFLDs_MASK 0x0000000f
+#define HC_HTXnTB_NoTB 0x00000000
+#define HC_HTXnTB_TBC_S 0x00100000
+#define HC_HTXnTB_TBC_T 0x00200000
+#define HC_HTXnTB_TB_S 0x00400000
+#define HC_HTXnTB_TB_T 0x00800000
+
+/* The "S" in FLS? means the S texture coordinate, and a "T" means the T
+ * texture coordinage. The "e" in FL?e means the magnification ("enlarge")
+ * mode, and the "s" in FL?s means the minification ("shrink") mode.
+ *
+ * The "D" in FLD? means the intermipmap level mode. That means that the
+ * GL_*_MIPMAP_LINEAR modes get FLDs_Linear, and the GL_*_MIPMAP_NEAREST modes
+ * get FLDs_Nearest.
+ */
+#define HC_HTXnFLSe_Nearest 0x00000000
+#define HC_HTXnFLSe_Linear 0x00002000
+#define HC_HTXnFLSe_NonLinear 0x00004000
+#define HC_HTXnFLSe_Sharp 0x00008000
+#define HC_HTXnFLSe_Flat_Gaussian_Cubic 0x0000c000
+#define HC_HTXnFLSs_Nearest 0x00000000
+#define HC_HTXnFLSs_Linear 0x00000400
+#define HC_HTXnFLSs_NonLinear 0x00000800
+#define HC_HTXnFLSs_Flat_Gaussian_Cubic 0x00001800
+#define HC_HTXnFLTe_Nearest 0x00000000
+#define HC_HTXnFLTe_Linear 0x00000080
+#define HC_HTXnFLTe_NonLinear 0x00000100
+#define HC_HTXnFLTe_Sharp 0x00000180
+#define HC_HTXnFLTe_Flat_Gaussian_Cubic 0x00000300
+#define HC_HTXnFLTs_Nearest 0x00000000
+#define HC_HTXnFLTs_Linear 0x00000010
+#define HC_HTXnFLTs_NonLinear 0x00000020
+#define HC_HTXnFLTs_Flat_Gaussian_Cubic 0x00000060
+#define HC_HTXnFLDs_Tex0 0x00000000
+#define HC_HTXnFLDs_Nearest 0x00000001
+#define HC_HTXnFLDs_Linear 0x00000002
+#define HC_HTXnFLDs_NonLinear 0x00000003
+#define HC_HTXnFLDs_Dither 0x00000004
+#define HC_HTXnFLDs_ConstLOD 0x00000005
+#define HC_HTXnFLDs_Ani 0x00000006
+#define HC_HTXnFLDs_AniDither 0x00000007
+
+/* HC_SubA_HTXnMPMD 0x0079
+ */
+#define HC_HTXnMPMD_SMASK 0x00070000
+#define HC_HTXnMPMD_TMASK 0x00380000
+#define HC_HTXnLODDTf_MASK 0x00000007
+#define HC_HTXnXY2ST_MASK 0x00000008
+#define HC_HTXnMPMD_Tsingle 0x00000000
+#define HC_HTXnMPMD_Tclamp 0x00080000
+#define HC_HTXnMPMD_Trepeat 0x00100000
+#define HC_HTXnMPMD_Tmirror 0x00180000
+#define HC_HTXnMPMD_Twrap 0x00200000
+#define HC_HTXnMPMD_Ssingle 0x00000000
+#define HC_HTXnMPMD_Sclamp 0x00010000
+#define HC_HTXnMPMD_Srepeat 0x00020000
+#define HC_HTXnMPMD_Smirror 0x00030000
+#define HC_HTXnMPMD_Swrap 0x00040000
+/* HC_SubA_HTXnCLODu 0x007a
+ */
+#define HC_HTXnCLODu_MASK 0x000ffc00
+#define HC_HTXnCLODd_MASK 0x000003ff
+#define HC_HTXnCLODu_SHIFT 10
+/* HC_SubA_HTXnFM 0x007b
+ */
+#define HC_HTXnFM_MASK 0x00ff0000
+#define HC_HTXnLoc_MASK 0x00000003
+#define HC_HTXnFM_INDEX 0x00000000 /* 0 << 19 */
+#define HC_HTXnFM_Intensity 0x00080000 /* 1 << 19 */
+#define HC_HTXnFM_Lum 0x00100000 /* 2 << 19 */
+#define HC_HTXnFM_Alpha 0x00180000 /* 3 << 19 */
+#define HC_HTXnFM_DX 0x00280000 /* 5 << 19 */
+#define HC_HTXnFM_BUMPMAP 0x00380000 /* 7 << 19 */
+#define HC_HTXnFM_ARGB16 0x00880000 /* 17 << 19 */
+#define HC_HTXnFM_ARGB32 0x00980000 /* 19 << 19 */
+#define HC_HTXnFM_ABGR16 0x00a80000 /* 21 << 19 */
+#define HC_HTXnFM_ABGR32 0x00b80000 /* 23 << 19 */
+#define HC_HTXnFM_RGBA16 0x00c80000 /* 25 << 19 */
+#define HC_HTXnFM_RGBA32 0x00d80000 /* 27 << 19 */
+#define HC_HTXnFM_BGRA16 0x00e80000 /* 29 << 19 */
+#define HC_HTXnFM_BGRA32 0x00f80000 /* 31 << 19 */
+#define HC_HTXnFM_Index1 (HC_HTXnFM_INDEX | 0x00000000)
+#define HC_HTXnFM_Index2 (HC_HTXnFM_INDEX | 0x00010000)
+#define HC_HTXnFM_Index4 (HC_HTXnFM_INDEX | 0x00020000)
+#define HC_HTXnFM_Index8 (HC_HTXnFM_INDEX | 0x00030000)
+#define HC_HTXnFM_T1 (HC_HTXnFM_Intensity | 0x00000000)
+#define HC_HTXnFM_T2 (HC_HTXnFM_Intensity | 0x00010000)
+#define HC_HTXnFM_T4 (HC_HTXnFM_Intensity | 0x00020000)
+#define HC_HTXnFM_T8 (HC_HTXnFM_Intensity | 0x00030000)
+#define HC_HTXnFM_L1 (HC_HTXnFM_Lum | 0x00000000)
+#define HC_HTXnFM_L2 (HC_HTXnFM_Lum | 0x00010000)
+#define HC_HTXnFM_L4 (HC_HTXnFM_Lum | 0x00020000)
+#define HC_HTXnFM_L8 (HC_HTXnFM_Lum | 0x00030000)
+#define HC_HTXnFM_AL44 (HC_HTXnFM_Lum | 0x00040000)
+#define HC_HTXnFM_AL88 (HC_HTXnFM_Lum | 0x00050000)
+#define HC_HTXnFM_A1 (HC_HTXnFM_Alpha | 0x00000000)
+#define HC_HTXnFM_A2 (HC_HTXnFM_Alpha | 0x00010000)
+#define HC_HTXnFM_A4 (HC_HTXnFM_Alpha | 0x00020000)
+#define HC_HTXnFM_A8 (HC_HTXnFM_Alpha | 0x00030000)
+#define HC_HTXnFM_DX1 (HC_HTXnFM_DX | 0x00010000)
+#define HC_HTXnFM_DX23 (HC_HTXnFM_DX | 0x00020000)
+#define HC_HTXnFM_DX45 (HC_HTXnFM_DX | 0x00030000)
+#define HC_HTXnFM_RGB555 (HC_HTXnFM_ARGB16 | 0x00000000)
+#define HC_HTXnFM_RGB565 (HC_HTXnFM_ARGB16 | 0x00010000)
+#define HC_HTXnFM_ARGB1555 (HC_HTXnFM_ARGB16 | 0x00020000)
+#define HC_HTXnFM_ARGB4444 (HC_HTXnFM_ARGB16 | 0x00030000)
+#define HC_HTXnFM_ARGB0888 (HC_HTXnFM_ARGB32 | 0x00000000)
+#define HC_HTXnFM_ARGB8888 (HC_HTXnFM_ARGB32 | 0x00010000)
+#define HC_HTXnFM_BGR555 (HC_HTXnFM_ABGR16 | 0x00000000)
+#define HC_HTXnFM_BGR565 (HC_HTXnFM_ABGR16 | 0x00010000)
+#define HC_HTXnFM_ABGR1555 (HC_HTXnFM_ABGR16 | 0x00020000)
+#define HC_HTXnFM_ABGR4444 (HC_HTXnFM_ABGR16 | 0x00030000)
+#define HC_HTXnFM_ABGR0888 (HC_HTXnFM_ABGR32 | 0x00000000)
+#define HC_HTXnFM_ABGR8888 (HC_HTXnFM_ABGR32 | 0x00010000)
+#define HC_HTXnFM_RGBA5550 (HC_HTXnFM_RGBA16 | 0x00000000)
+#define HC_HTXnFM_RGBA5551 (HC_HTXnFM_RGBA16 | 0x00020000)
+#define HC_HTXnFM_RGBA4444 (HC_HTXnFM_RGBA16 | 0x00030000)
+#define HC_HTXnFM_RGBA8880 (HC_HTXnFM_RGBA32 | 0x00000000)
+#define HC_HTXnFM_RGBA8888 (HC_HTXnFM_RGBA32 | 0x00010000)
+#define HC_HTXnFM_BGRA5550 (HC_HTXnFM_BGRA16 | 0x00000000)
+#define HC_HTXnFM_BGRA5551 (HC_HTXnFM_BGRA16 | 0x00020000)
+#define HC_HTXnFM_BGRA4444 (HC_HTXnFM_BGRA16 | 0x00030000)
+#define HC_HTXnFM_BGRA8880 (HC_HTXnFM_BGRA32 | 0x00000000)
+#define HC_HTXnFM_BGRA8888 (HC_HTXnFM_BGRA32 | 0x00010000)
+#define HC_HTXnFM_VU88 (HC_HTXnFM_BUMPMAP | 0x00000000)
+#define HC_HTXnFM_LVU655 (HC_HTXnFM_BUMPMAP | 0x00010000)
+#define HC_HTXnFM_LVU888 (HC_HTXnFM_BUMPMAP | 0x00020000)
+#define HC_HTXnLoc_Local 0x00000000
+#define HC_HTXnLoc_Sys 0x00000002
+#define HC_HTXnLoc_AGP 0x00000003
+/* HC_SubA_HTXnTRAH 0x007f
+ */
+#define HC_HTXnTRAH_MASK 0x00ff0000
+#define HC_HTXnTRAL_MASK 0x0000ff00
+#define HC_HTXnTBA_MASK 0x000000ff
+#define HC_HTXnTRAH_SHIFT 16
+#define HC_HTXnTRAL_SHIFT 8
+
+/*-- Define the input texture, for below
+ */
+#define HC_XTC_TOPC 0x00000000
+#define HC_XTC_InvTOPC 0x00000010
+#define HC_XTC_TOPCp5 0x00000020
+#define HC_XTC_Cbias 0x00000000
+#define HC_XTC_InvCbias 0x00000010
+#define HC_XTC_0 0x00000000
+#define HC_XTC_Dif 0x00000001
+#define HC_XTC_Spec 0x00000002
+#define HC_XTC_Tex 0x00000003
+#define HC_XTC_Cur 0x00000004
+#define HC_XTC_Adif 0x00000005
+#define HC_XTC_Fog 0x00000006
+#define HC_XTC_Atex 0x00000007
+#define HC_XTC_Acur 0x00000008
+#define HC_XTC_HTXnTBLRC 0x00000009
+#define HC_XTC_Ctexnext 0x0000000a
+/** HC_SubA_HTXnTBLCsat 0x0080
+ */
+#define HC_HTXnTBLCsat_MASK 0x00800000
+#define HC_HTXnTBLCa_MASK 0x000fc000
+#define HC_HTXnTBLCb_MASK 0x00001f80
+#define HC_HTXnTBLCc_MASK 0x0000003f
+#define HC_HTXnTBLCa_TOPC (HC_XTC_TOPC << 14)
+#define HC_HTXnTBLCa_InvTOPC (HC_XTC_InvTOPC << 14)
+#define HC_HTXnTBLCa_TOPCp5 (HC_XTC_TOPCp5 << 14)
+#define HC_HTXnTBLCa_0 (HC_XTC_0 << 14)
+#define HC_HTXnTBLCa_Dif (HC_XTC_Dif << 14)
+#define HC_HTXnTBLCa_Spec (HC_XTC_Spec << 14)
+#define HC_HTXnTBLCa_Tex (HC_XTC_Tex << 14)
+#define HC_HTXnTBLCa_Cur (HC_XTC_Cur << 14)
+#define HC_HTXnTBLCa_Adif (HC_XTC_Adif << 14)
+#define HC_HTXnTBLCa_Fog (HC_XTC_Fog << 14)
+#define HC_HTXnTBLCa_Atex (HC_XTC_Atex << 14)
+#define HC_HTXnTBLCa_Acur (HC_XTC_Acur << 14)
+#define HC_HTXnTBLCa_HTXnTBLRC (HC_XTC_HTXnTBLRC << 14)
+#define HC_HTXnTBLCa_Ctexnext (HC_XTC_Ctexnext << 14)
+#define HC_HTXnTBLCb_TOPC (HC_XTC_TOPC << 7)
+#define HC_HTXnTBLCb_InvTOPC (HC_XTC_InvTOPC << 7)
+#define HC_HTXnTBLCb_TOPCp5 (HC_XTC_TOPCp5 << 7)
+#define HC_HTXnTBLCb_0 (HC_XTC_0 << 7)
+#define HC_HTXnTBLCb_Dif (HC_XTC_Dif << 7)
+#define HC_HTXnTBLCb_Spec (HC_XTC_Spec << 7)
+#define HC_HTXnTBLCb_Tex (HC_XTC_Tex << 7)
+#define HC_HTXnTBLCb_Cur (HC_XTC_Cur << 7)
+#define HC_HTXnTBLCb_Adif (HC_XTC_Adif << 7)
+#define HC_HTXnTBLCb_Fog (HC_XTC_Fog << 7)
+#define HC_HTXnTBLCb_Atex (HC_XTC_Atex << 7)
+#define HC_HTXnTBLCb_Acur (HC_XTC_Acur << 7)
+#define HC_HTXnTBLCb_HTXnTBLRC (HC_XTC_HTXnTBLRC << 7)
+#define HC_HTXnTBLCb_Ctexnext (HC_XTC_Ctexnext << 7)
+#define HC_HTXnTBLCc_TOPC (HC_XTC_TOPC << 0)
+#define HC_HTXnTBLCc_InvTOPC (HC_XTC_InvTOPC << 0)
+#define HC_HTXnTBLCc_TOPCp5 (HC_XTC_TOPCp5 << 0)
+#define HC_HTXnTBLCc_0 (HC_XTC_0 << 0)
+#define HC_HTXnTBLCc_Dif (HC_XTC_Dif << 0)
+#define HC_HTXnTBLCc_Spec (HC_XTC_Spec << 0)
+#define HC_HTXnTBLCc_Tex (HC_XTC_Tex << 0)
+#define HC_HTXnTBLCc_Cur (HC_XTC_Cur << 0)
+#define HC_HTXnTBLCc_Adif (HC_XTC_Adif << 0)
+#define HC_HTXnTBLCc_Fog (HC_XTC_Fog << 0)
+#define HC_HTXnTBLCc_Atex (HC_XTC_Atex << 0)
+#define HC_HTXnTBLCc_Acur (HC_XTC_Acur << 0)
+#define HC_HTXnTBLCc_HTXnTBLRC (HC_XTC_HTXnTBLRC << 0)
+#define HC_HTXnTBLCc_Ctexnext (HC_XTC_Ctexnext << 0)
+/* HC_SubA_HTXnTBLCop 0x0081
+ */
+#define HC_HTXnTBLdot_MASK 0x00c00000
+#define HC_HTXnTBLCop_MASK 0x00380000
+#define HC_HTXnTBLCbias_MASK 0x0007c000
+#define HC_HTXnTBLCshift_MASK 0x00001800
+#define HC_HTXnTBLAop_MASK 0x00000380
+#define HC_HTXnTBLAbias_MASK 0x00000078
+#define HC_HTXnTBLAshift_MASK 0x00000003
+#define HC_HTXnTBLDOT3 0x00800000
+#define HC_HTXnTBLDOT4 0x00c00000
+#define HC_HTXnTBLCop_Add 0x00000000
+#define HC_HTXnTBLCop_Sub 0x00080000
+#define HC_HTXnTBLCop_Min 0x00100000
+#define HC_HTXnTBLCop_Max 0x00180000
+#define HC_HTXnTBLCop_Mask 0x00200000
+#define HC_HTXnTBLCbias_Cbias (HC_XTC_Cbias << 14)
+#define HC_HTXnTBLCbias_InvCbias (HC_XTC_InvCbias << 14)
+#define HC_HTXnTBLCbias_0 (HC_XTC_0 << 14)
+#define HC_HTXnTBLCbias_Dif (HC_XTC_Dif << 14)
+#define HC_HTXnTBLCbias_Spec (HC_XTC_Spec << 14)
+#define HC_HTXnTBLCbias_Tex (HC_XTC_Tex << 14)
+#define HC_HTXnTBLCbias_Cur (HC_XTC_Cur << 14)
+#define HC_HTXnTBLCbias_Adif (HC_XTC_Adif << 14)
+#define HC_HTXnTBLCbias_Fog (HC_XTC_Fog << 14)
+#define HC_HTXnTBLCbias_Atex (HC_XTC_Atex << 14)
+#define HC_HTXnTBLCbias_Acur (HC_XTC_Acur << 14)
+#define HC_HTXnTBLCbias_HTXnTBLRC (HC_XTC_HTXnTBLRC << 14)
+#define HC_HTXnTBLCshift_1 0x00000000
+#define HC_HTXnTBLCshift_2 0x00000800
+#define HC_HTXnTBLCshift_No 0x00001000
+#define HC_HTXnTBLCshift_DotP 0x00001800
+#define HC_HTXnTBLAop_Add 0x00000000
+#define HC_HTXnTBLAop_Sub 0x00000080
+#define HC_HTXnTBLAop_Min 0x00000100
+#define HC_HTXnTBLAop_Max 0x00000180
+#define HC_HTXnTBLAop_Mask 0x00000200
+#define HC_HTXnTBLAbias_Inv 0x00000040
+#define HC_HTXnTBLAbias_Adif 0x00000000
+#define HC_HTXnTBLAbias_Fog 0x00000008
+#define HC_HTXnTBLAbias_Acur 0x00000010
+#define HC_HTXnTBLAbias_HTXnTBLRAbias 0x00000018
+#define HC_HTXnTBLAbias_Atex 0x00000020
+#define HC_HTXnTBLAshift_1 0x00000000
+#define HC_HTXnTBLAshift_2 0x00000001
+#define HC_HTXnTBLAshift_No 0x00000002
+#define HC_HTXnTBLAshift_DotP 0x00000003
+/* HC_SubA_HTXnTBLMPFog 0x0082
+ */
+#define HC_HTXnTBLMPfog_MASK 0x00e00000
+#define HC_HTXnTBLMPfog_0 0x00000000
+#define HC_HTXnTBLMPfog_Adif 0x00200000
+#define HC_HTXnTBLMPfog_Fog 0x00400000
+#define HC_HTXnTBLMPfog_Atex 0x00600000
+#define HC_HTXnTBLMPfog_Acur 0x00800000
+#define HC_HTXnTBLMPfog_GHTXnTBLRFog 0x00a00000
+/* HC_SubA_HTXnTBLAsat 0x0083
+ *-- Define the texture alpha input.
+ */
+#define HC_XTA_TOPA 0x00000000
+#define HC_XTA_InvTOPA 0x00000008
+#define HC_XTA_TOPAp5 0x00000010
+#define HC_XTA_Adif 0x00000000
+#define HC_XTA_Fog 0x00000001
+#define HC_XTA_Acur 0x00000002
+#define HC_XTA_HTXnTBLRA 0x00000003
+#define HC_XTA_Atex 0x00000004
+#define HC_XTA_Atexnext 0x00000005
+/*--
+ */
+#define HC_HTXnTBLAsat_MASK 0x00800000
+#define HC_HTXnTBLAMB_MASK 0x00700000
+#define HC_HTXnTBLAa_MASK 0x0007c000
+#define HC_HTXnTBLAb_MASK 0x00000f80
+#define HC_HTXnTBLAc_MASK 0x0000001f
+#define HC_HTXnTBLAMB_SHIFT 20
+#define HC_HTXnTBLAa_TOPA (HC_XTA_TOPA << 14)
+#define HC_HTXnTBLAa_InvTOPA (HC_XTA_InvTOPA << 14)
+#define HC_HTXnTBLAa_TOPAp5 (HC_XTA_TOPAp5 << 14)
+#define HC_HTXnTBLAa_Adif (HC_XTA_Adif << 14)
+#define HC_HTXnTBLAa_Fog (HC_XTA_Fog << 14)
+#define HC_HTXnTBLAa_Acur (HC_XTA_Acur << 14)
+#define HC_HTXnTBLAa_HTXnTBLRA (HC_XTA_HTXnTBLRA << 14)
+#define HC_HTXnTBLAa_Atex (HC_XTA_Atex << 14)
+#define HC_HTXnTBLAa_Atexnext (HC_XTA_Atexnext << 14)
+#define HC_HTXnTBLAb_TOPA (HC_XTA_TOPA << 7)
+#define HC_HTXnTBLAb_InvTOPA (HC_XTA_InvTOPA << 7)
+#define HC_HTXnTBLAb_TOPAp5 (HC_XTA_TOPAp5 << 7)
+#define HC_HTXnTBLAb_Adif (HC_XTA_Adif << 7)
+#define HC_HTXnTBLAb_Fog (HC_XTA_Fog << 7)
+#define HC_HTXnTBLAb_Acur (HC_XTA_Acur << 7)
+#define HC_HTXnTBLAb_HTXnTBLRA (HC_XTA_HTXnTBLRA << 7)
+#define HC_HTXnTBLAb_Atex (HC_XTA_Atex << 7)
+#define HC_HTXnTBLAb_Atexnext (HC_XTA_Atexnext << 7)
+#define HC_HTXnTBLAc_TOPA (HC_XTA_TOPA << 0)
+#define HC_HTXnTBLAc_InvTOPA (HC_XTA_InvTOPA << 0)
+#define HC_HTXnTBLAc_TOPAp5 (HC_XTA_TOPAp5 << 0)
+#define HC_HTXnTBLAc_Adif (HC_XTA_Adif << 0)
+#define HC_HTXnTBLAc_Fog (HC_XTA_Fog << 0)
+#define HC_HTXnTBLAc_Acur (HC_XTA_Acur << 0)
+#define HC_HTXnTBLAc_HTXnTBLRA (HC_XTA_HTXnTBLRA << 0)
+#define HC_HTXnTBLAc_Atex (HC_XTA_Atex << 0)
+#define HC_HTXnTBLAc_Atexnext (HC_XTA_Atexnext << 0)
+/* HC_SubA_HTXnTBLRAa 0x0089
+ */
+#define HC_HTXnTBLRAa_MASK 0x00ff0000
+#define HC_HTXnTBLRAb_MASK 0x0000ff00
+#define HC_HTXnTBLRAc_MASK 0x000000ff
+#define HC_HTXnTBLRAa_SHIFT 16
+#define HC_HTXnTBLRAb_SHIFT 8
+#define HC_HTXnTBLRAc_SHIFT 0
+/* HC_SubA_HTXnTBLRFog 0x008a
+ */
+#define HC_HTXnTBLRFog_MASK 0x0000ff00
+#define HC_HTXnTBLRAbias_MASK 0x000000ff
+#define HC_HTXnTBLRFog_SHIFT 8
+#define HC_HTXnTBLRAbias_SHIFT 0
+/* HC_SubA_HTXnLScale 0x0094
+ */
+#define HC_HTXnLScale_MASK 0x0007fc00
+#define HC_HTXnLOff_MASK 0x000001ff
+#define HC_HTXnLScale_SHIFT 10
+/* HC_SubA_HTXSMD 0x0000
+ */
+#define HC_HTXSMD_MASK 0x00000080
+#define HC_HTXTMD_MASK 0x00000040
+#define HC_HTXNum_MASK 0x00000038
+#define HC_HTXTRMD_MASK 0x00000006
+#define HC_HTXCHCLR_MASK 0x00000001
+#define HC_HTXNum_SHIFT 3
+
+/* Texture Palette n
+ */
+#define HC_SubType_TexPalette0 0x00000000
+#define HC_SubType_TexPalette1 0x00000001
+#define HC_SubType_FogTable 0x00000010
+#define HC_SubType_Stipple 0x00000014
+/* HC_SubA_TexPalette0 0x0000
+ */
+#define HC_HTPnA_MASK 0xff000000
+#define HC_HTPnR_MASK 0x00ff0000
+#define HC_HTPnG_MASK 0x0000ff00
+#define HC_HTPnB_MASK 0x000000ff
+/* HC_SubA_FogTable 0x0010
+ */
+#define HC_HFPn3_MASK 0xff000000
+#define HC_HFPn2_MASK 0x00ff0000
+#define HC_HFPn1_MASK 0x0000ff00
+#define HC_HFPn_MASK 0x000000ff
+#define HC_HFPn3_SHIFT 24
+#define HC_HFPn2_SHIFT 16
+#define HC_HFPn1_SHIFT 8
+
+/* Auto Testing & Security
+ */
+#define HC_SubA_HenFIFOAT 0x0000
+#define HC_SubA_HFBDrawFirst 0x0004
+#define HC_SubA_HFBBasL 0x0005
+#define HC_SubA_HFBDst 0x0006
+/* HC_SubA_HenFIFOAT 0x0000
+ */
+#define HC_HenFIFOAT_MASK 0x00000020
+#define HC_HenGEMILock_MASK 0x00000010
+#define HC_HenFBASwap_MASK 0x00000008
+#define HC_HenOT_MASK 0x00000004
+#define HC_HenCMDQ_MASK 0x00000002
+#define HC_HenTXCTSU_MASK 0x00000001
+/* HC_SubA_HFBDrawFirst 0x0004
+ */
+#define HC_HFBDrawFirst_MASK 0x00000800
+#define HC_HFBQueue_MASK 0x00000400
+#define HC_HFBLock_MASK 0x00000200
+#define HC_HEOF_MASK 0x00000100
+#define HC_HFBBasH_MASK 0x000000ff
+
+/* GEMI Setting
+ */
+#define HC_SubA_HTArbRCM 0x0008
+#define HC_SubA_HTArbRZ 0x000a
+#define HC_SubA_HTArbWZ 0x000b
+#define HC_SubA_HTArbRTX 0x000c
+#define HC_SubA_HTArbRCW 0x000d
+#define HC_SubA_HTArbE2 0x000e
+#define HC_SubA_HArbRQCM 0x0010
+#define HC_SubA_HArbWQCM 0x0011
+#define HC_SubA_HGEMITout 0x0020
+#define HC_SubA_HFthRTXD 0x0040
+#define HC_SubA_HFthRTXA 0x0044
+#define HC_SubA_HCMDQstL 0x0050
+#define HC_SubA_HCMDQendL 0x0051
+#define HC_SubA_HCMDQLen 0x0052
+/* HC_SubA_HTArbRCM 0x0008
+ */
+#define HC_HTArbRCM_MASK 0x0000ffff
+/* HC_SubA_HTArbRZ 0x000a
+ */
+#define HC_HTArbRZ_MASK 0x0000ffff
+/* HC_SubA_HTArbWZ 0x000b
+ */
+#define HC_HTArbWZ_MASK 0x0000ffff
+/* HC_SubA_HTArbRTX 0x000c
+ */
+#define HC_HTArbRTX_MASK 0x0000ffff
+/* HC_SubA_HTArbRCW 0x000d
+ */
+#define HC_HTArbRCW_MASK 0x0000ffff
+/* HC_SubA_HTArbE2 0x000e
+ */
+#define HC_HTArbE2_MASK 0x0000ffff
+/* HC_SubA_HArbRQCM 0x0010
+ */
+#define HC_HTArbRQCM_MASK 0x0000ffff
+/* HC_SubA_HArbWQCM 0x0011
+ */
+#define HC_HArbWQCM_MASK 0x0000ffff
+/* HC_SubA_HGEMITout 0x0020
+ */
+#define HC_HGEMITout_MASK 0x000f0000
+#define HC_HNPArbZC_MASK 0x0000ffff
+#define HC_HGEMITout_SHIFT 16
+/* HC_SubA_HFthRTXD 0x0040
+ */
+#define HC_HFthRTXD_MASK 0x00ff0000
+#define HC_HFthRZD_MASK 0x0000ff00
+#define HC_HFthWZD_MASK 0x000000ff
+#define HC_HFthRTXD_SHIFT 16
+#define HC_HFthRZD_SHIFT 8
+/* HC_SubA_HFthRTXA 0x0044
+ */
+#define HC_HFthRTXA_MASK 0x000000ff
+
+/******************************************************************************
+** Define the Halcyon Internal register access constants. For simulator only.
+******************************************************************************/
+#define HC_SIMA_HAGPBstL 0x0000
+#define HC_SIMA_HAGPBendL 0x0001
+#define HC_SIMA_HAGPCMNT 0x0002
+#define HC_SIMA_HAGPBpL 0x0003
+#define HC_SIMA_HAGPBpH 0x0004
+#define HC_SIMA_HClipTB 0x0005
+#define HC_SIMA_HClipLR 0x0006
+#define HC_SIMA_HFPClipTL 0x0007
+#define HC_SIMA_HFPClipBL 0x0008
+#define HC_SIMA_HFPClipLL 0x0009
+#define HC_SIMA_HFPClipRL 0x000a
+#define HC_SIMA_HFPClipTBH 0x000b
+#define HC_SIMA_HFPClipLRH 0x000c
+#define HC_SIMA_HLP 0x000d
+#define HC_SIMA_HLPRF 0x000e
+#define HC_SIMA_HSolidCL 0x000f
+#define HC_SIMA_HPixGC 0x0010
+#define HC_SIMA_HSPXYOS 0x0011
+#define HC_SIMA_HCmdA 0x0012
+#define HC_SIMA_HCmdB 0x0013
+#define HC_SIMA_HEnable 0x0014
+#define HC_SIMA_HZWBBasL 0x0015
+#define HC_SIMA_HZWBBasH 0x0016
+#define HC_SIMA_HZWBType 0x0017
+#define HC_SIMA_HZBiasL 0x0018
+#define HC_SIMA_HZWBend 0x0019
+#define HC_SIMA_HZWTMD 0x001a
+#define HC_SIMA_HZWCDL 0x001b
+#define HC_SIMA_HZWCTAGnum 0x001c
+#define HC_SIMA_HZCYNum 0x001d
+#define HC_SIMA_HZWCFire 0x001e
+/* #define HC_SIMA_HSBBasL 0x001d */
+/* #define HC_SIMA_HSBBasH 0x001e */
+/* #define HC_SIMA_HSBFM 0x001f */
+#define HC_SIMA_HSTREF 0x0020
+#define HC_SIMA_HSTMD 0x0021
+#define HC_SIMA_HABBasL 0x0022
+#define HC_SIMA_HABBasH 0x0023
+#define HC_SIMA_HABFM 0x0024
+#define HC_SIMA_HATMD 0x0025
+#define HC_SIMA_HABLCsat 0x0026
+#define HC_SIMA_HABLCop 0x0027
+#define HC_SIMA_HABLAsat 0x0028
+#define HC_SIMA_HABLAop 0x0029
+#define HC_SIMA_HABLRCa 0x002a
+#define HC_SIMA_HABLRFCa 0x002b
+#define HC_SIMA_HABLRCbias 0x002c
+#define HC_SIMA_HABLRCb 0x002d
+#define HC_SIMA_HABLRFCb 0x002e
+#define HC_SIMA_HABLRAa 0x002f
+#define HC_SIMA_HABLRAb 0x0030
+#define HC_SIMA_HDBBasL 0x0031
+#define HC_SIMA_HDBBasH 0x0032
+#define HC_SIMA_HDBFM 0x0033
+#define HC_SIMA_HFBBMSKL 0x0034
+#define HC_SIMA_HROP 0x0035
+#define HC_SIMA_HFogLF 0x0036
+#define HC_SIMA_HFogCL 0x0037
+#define HC_SIMA_HFogCH 0x0038
+#define HC_SIMA_HFogStL 0x0039
+#define HC_SIMA_HFogStH 0x003a
+#define HC_SIMA_HFogOOdMF 0x003b
+#define HC_SIMA_HFogOOdEF 0x003c
+#define HC_SIMA_HFogEndL 0x003d
+#define HC_SIMA_HFogDenst 0x003e
+/*---- start of texture 0 setting ----
+ */
+#define HC_SIMA_HTX0L0BasL 0x0040
+#define HC_SIMA_HTX0L1BasL 0x0041
+#define HC_SIMA_HTX0L2BasL 0x0042
+#define HC_SIMA_HTX0L3BasL 0x0043
+#define HC_SIMA_HTX0L4BasL 0x0044
+#define HC_SIMA_HTX0L5BasL 0x0045
+#define HC_SIMA_HTX0L6BasL 0x0046
+#define HC_SIMA_HTX0L7BasL 0x0047
+#define HC_SIMA_HTX0L8BasL 0x0048
+#define HC_SIMA_HTX0L9BasL 0x0049
+#define HC_SIMA_HTX0LaBasL 0x004a
+#define HC_SIMA_HTX0LbBasL 0x004b
+#define HC_SIMA_HTX0LcBasL 0x004c
+#define HC_SIMA_HTX0LdBasL 0x004d
+#define HC_SIMA_HTX0LeBasL 0x004e
+#define HC_SIMA_HTX0LfBasL 0x004f
+#define HC_SIMA_HTX0L10BasL 0x0050
+#define HC_SIMA_HTX0L11BasL 0x0051
+#define HC_SIMA_HTX0L012BasH 0x0052
+#define HC_SIMA_HTX0L345BasH 0x0053
+#define HC_SIMA_HTX0L678BasH 0x0054
+#define HC_SIMA_HTX0L9abBasH 0x0055
+#define HC_SIMA_HTX0LcdeBasH 0x0056
+#define HC_SIMA_HTX0Lf1011BasH 0x0057
+#define HC_SIMA_HTX0L0Pit 0x0058
+#define HC_SIMA_HTX0L1Pit 0x0059
+#define HC_SIMA_HTX0L2Pit 0x005a
+#define HC_SIMA_HTX0L3Pit 0x005b
+#define HC_SIMA_HTX0L4Pit 0x005c
+#define HC_SIMA_HTX0L5Pit 0x005d
+#define HC_SIMA_HTX0L6Pit 0x005e
+#define HC_SIMA_HTX0L7Pit 0x005f
+#define HC_SIMA_HTX0L8Pit 0x0060
+#define HC_SIMA_HTX0L9Pit 0x0061
+#define HC_SIMA_HTX0LaPit 0x0062
+#define HC_SIMA_HTX0LbPit 0x0063
+#define HC_SIMA_HTX0LcPit 0x0064
+#define HC_SIMA_HTX0LdPit 0x0065
+#define HC_SIMA_HTX0LePit 0x0066
+#define HC_SIMA_HTX0LfPit 0x0067
+#define HC_SIMA_HTX0L10Pit 0x0068
+#define HC_SIMA_HTX0L11Pit 0x0069
+#define HC_SIMA_HTX0L0_5WE 0x006a
+#define HC_SIMA_HTX0L6_bWE 0x006b
+#define HC_SIMA_HTX0Lc_11WE 0x006c
+#define HC_SIMA_HTX0L0_5HE 0x006d
+#define HC_SIMA_HTX0L6_bHE 0x006e
+#define HC_SIMA_HTX0Lc_11HE 0x006f
+#define HC_SIMA_HTX0L0OS 0x0070
+#define HC_SIMA_HTX0TB 0x0071
+#define HC_SIMA_HTX0MPMD 0x0072
+#define HC_SIMA_HTX0CLODu 0x0073
+#define HC_SIMA_HTX0FM 0x0074
+#define HC_SIMA_HTX0TRCH 0x0075
+#define HC_SIMA_HTX0TRCL 0x0076
+#define HC_SIMA_HTX0TBC 0x0077
+#define HC_SIMA_HTX0TRAH 0x0078
+#define HC_SIMA_HTX0TBLCsat 0x0079
+#define HC_SIMA_HTX0TBLCop 0x007a
+#define HC_SIMA_HTX0TBLMPfog 0x007b
+#define HC_SIMA_HTX0TBLAsat 0x007c
+#define HC_SIMA_HTX0TBLRCa 0x007d
+#define HC_SIMA_HTX0TBLRCb 0x007e
+#define HC_SIMA_HTX0TBLRCc 0x007f
+#define HC_SIMA_HTX0TBLRCbias 0x0080
+#define HC_SIMA_HTX0TBLRAa 0x0081
+#define HC_SIMA_HTX0TBLRFog 0x0082
+#define HC_SIMA_HTX0BumpM00 0x0083
+#define HC_SIMA_HTX0BumpM01 0x0084
+#define HC_SIMA_HTX0BumpM10 0x0085
+#define HC_SIMA_HTX0BumpM11 0x0086
+#define HC_SIMA_HTX0LScale 0x0087
+/*---- end of texture 0 setting ---- 0x008f
+ */
+#define HC_SIMA_TX0TX1_OFF 0x0050
+/*---- start of texture 1 setting ----
+ */
+#define HC_SIMA_HTX1L0BasL (HC_SIMA_HTX0L0BasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L1BasL (HC_SIMA_HTX0L1BasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L2BasL (HC_SIMA_HTX0L2BasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L3BasL (HC_SIMA_HTX0L3BasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L4BasL (HC_SIMA_HTX0L4BasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L5BasL (HC_SIMA_HTX0L5BasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L6BasL (HC_SIMA_HTX0L6BasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L7BasL (HC_SIMA_HTX0L7BasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L8BasL (HC_SIMA_HTX0L8BasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L9BasL (HC_SIMA_HTX0L9BasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1LaBasL (HC_SIMA_HTX0LaBasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1LbBasL (HC_SIMA_HTX0LbBasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1LcBasL (HC_SIMA_HTX0LcBasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1LdBasL (HC_SIMA_HTX0LdBasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1LeBasL (HC_SIMA_HTX0LeBasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1LfBasL (HC_SIMA_HTX0LfBasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L10BasL (HC_SIMA_HTX0L10BasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L11BasL (HC_SIMA_HTX0L11BasL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L012BasH (HC_SIMA_HTX0L012BasH + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L345BasH (HC_SIMA_HTX0L345BasH + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L678BasH (HC_SIMA_HTX0L678BasH + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L9abBasH (HC_SIMA_HTX0L9abBasH + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1LcdeBasH (HC_SIMA_HTX0LcdeBasH + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1Lf1011BasH (HC_SIMA_HTX0Lf1011BasH + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L0Pit (HC_SIMA_HTX0L0Pit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L1Pit (HC_SIMA_HTX0L1Pit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L2Pit (HC_SIMA_HTX0L2Pit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L3Pit (HC_SIMA_HTX0L3Pit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L4Pit (HC_SIMA_HTX0L4Pit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L5Pit (HC_SIMA_HTX0L5Pit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L6Pit (HC_SIMA_HTX0L6Pit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L7Pit (HC_SIMA_HTX0L7Pit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L8Pit (HC_SIMA_HTX0L8Pit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L9Pit (HC_SIMA_HTX0L9Pit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1LaPit (HC_SIMA_HTX0LaPit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1LbPit (HC_SIMA_HTX0LbPit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1LcPit (HC_SIMA_HTX0LcPit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1LdPit (HC_SIMA_HTX0LdPit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1LePit (HC_SIMA_HTX0LePit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1LfPit (HC_SIMA_HTX0LfPit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L10Pit (HC_SIMA_HTX0L10Pit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L11Pit (HC_SIMA_HTX0L11Pit + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L0_5WE (HC_SIMA_HTX0L0_5WE + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L6_bWE (HC_SIMA_HTX0L6_bWE + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1Lc_11WE (HC_SIMA_HTX0Lc_11WE + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L0_5HE (HC_SIMA_HTX0L0_5HE + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L6_bHE (HC_SIMA_HTX0L6_bHE + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1Lc_11HE (HC_SIMA_HTX0Lc_11HE + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1L0OS (HC_SIMA_HTX0L0OS + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1TB (HC_SIMA_HTX0TB + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1MPMD (HC_SIMA_HTX0MPMD + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1CLODu (HC_SIMA_HTX0CLODu + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1FM (HC_SIMA_HTX0FM + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1TRCH (HC_SIMA_HTX0TRCH + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1TRCL (HC_SIMA_HTX0TRCL + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1TBC (HC_SIMA_HTX0TBC + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1TRAH (HC_SIMA_HTX0TRAH + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1LTC (HC_SIMA_HTX0LTC + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1LTA (HC_SIMA_HTX0LTA + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1TBLCsat (HC_SIMA_HTX0TBLCsat + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1TBLCop (HC_SIMA_HTX0TBLCop + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1TBLMPfog (HC_SIMA_HTX0TBLMPfog + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1TBLAsat (HC_SIMA_HTX0TBLAsat + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1TBLRCa (HC_SIMA_HTX0TBLRCa + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1TBLRCb (HC_SIMA_HTX0TBLRCb + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1TBLRCc (HC_SIMA_HTX0TBLRCc + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1TBLRCbias (HC_SIMA_HTX0TBLRCbias + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1TBLRAa (HC_SIMA_HTX0TBLRAa + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1TBLRFog (HC_SIMA_HTX0TBLRFog + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1BumpM00 (HC_SIMA_HTX0BumpM00 + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1BumpM01 (HC_SIMA_HTX0BumpM01 + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1BumpM10 (HC_SIMA_HTX0BumpM10 + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1BumpM11 (HC_SIMA_HTX0BumpM11 + HC_SIMA_TX0TX1_OFF)
+#define HC_SIMA_HTX1LScale (HC_SIMA_HTX0LScale + HC_SIMA_TX0TX1_OFF)
+/*---- end of texture 1 setting ---- 0xaf
+ */
+#define HC_SIMA_HTXSMD 0x00b0
+#define HC_SIMA_HenFIFOAT 0x00b1
+#define HC_SIMA_HFBDrawFirst 0x00b2
+#define HC_SIMA_HFBBasL 0x00b3
+#define HC_SIMA_HTArbRCM 0x00b4
+#define HC_SIMA_HTArbRZ 0x00b5
+#define HC_SIMA_HTArbWZ 0x00b6
+#define HC_SIMA_HTArbRTX 0x00b7
+#define HC_SIMA_HTArbRCW 0x00b8
+#define HC_SIMA_HTArbE2 0x00b9
+#define HC_SIMA_HGEMITout 0x00ba
+#define HC_SIMA_HFthRTXD 0x00bb
+#define HC_SIMA_HFthRTXA 0x00bc
+/* Define the texture palette 0
+ */
+#define HC_SIMA_HTP0 0x0100
+#define HC_SIMA_HTP1 0x0200
+#define HC_SIMA_FOGTABLE 0x0300
+#define HC_SIMA_STIPPLE 0x0400
+#define HC_SIMA_HE3Fire 0x0440
+#define HC_SIMA_TRANS_SET 0x0441
+#define HC_SIMA_HREngSt 0x0442
+#define HC_SIMA_HRFIFOempty 0x0443
+#define HC_SIMA_HRFIFOfull 0x0444
+#define HC_SIMA_HRErr 0x0445
+#define HC_SIMA_FIFOstatus 0x0446
+
+/******************************************************************************
+** Define the AGP command header.
+******************************************************************************/
+#define HC_ACMD_MASK 0xfe000000
+#define HC_ACMD_SUB_MASK 0x0c000000
+#define HC_ACMD_HCmdA 0xee000000
+#define HC_ACMD_HCmdB 0xec000000
+#define HC_ACMD_HCmdC 0xea000000
+#define HC_ACMD_H1 0xf0000000
+#define HC_ACMD_H2 0xf2000000
+#define HC_ACMD_H3 0xf4000000
+#define HC_ACMD_H4 0xf6000000
+
+#define HC_ACMD_H1IO_MASK 0x000001ff
+#define HC_ACMD_H2IO1_MASK 0x001ff000
+#define HC_ACMD_H2IO2_MASK 0x000001ff
+#define HC_ACMD_H2IO1_SHIFT 12
+#define HC_ACMD_H2IO2_SHIFT 0
+#define HC_ACMD_H3IO_MASK 0x000001ff
+#define HC_ACMD_H3COUNT_MASK 0x01fff000
+#define HC_ACMD_H3COUNT_SHIFT 12
+#define HC_ACMD_H4ID_MASK 0x000001ff
+#define HC_ACMD_H4COUNT_MASK 0x01fffe00
+#define HC_ACMD_H4COUNT_SHIFT 9
+
+/********************************************************************************
+** Define Header
+********************************************************************************/
+#define HC_HEADER2 0xF210F110
+
+/********************************************************************************
+** Define Dummy Value
+********************************************************************************/
+#define HC_DUMMY 0xCCCCCCCC
+/********************************************************************************
+** Define for DMA use
+********************************************************************************/
+#define HALCYON_HEADER2 0XF210F110
+#define HALCYON_FIRECMD 0XEE100000
+#define HALCYON_FIREMASK 0XFFF00000
+#define HALCYON_CMDB 0XEC000000
+#define HALCYON_CMDBMASK 0XFFFE0000
+#define HALCYON_SUB_ADDR0 0X00000000
+#define HALCYON_HEADER1MASK 0XFFFFFF00
+#define HALCYON_HEADER1 0XF0000000
+#define HC_SubA_HAGPBstL 0x0060
+#define HC_SubA_HAGPBendL 0x0061
+#define HC_SubA_HAGPCMNT 0x0062
+#define HC_SubA_HAGPBpL 0x0063
+#define HC_SubA_HAGPBpH 0x0064
+#define HC_HAGPCMNT_MASK 0x00800000
+#define HC_HCmdErrClr_MASK 0x00400000
+#define HC_HAGPBendH_MASK 0x0000ff00
+#define HC_HAGPBstH_MASK 0x000000ff
+#define HC_HAGPBendH_SHIFT 8
+#define HC_HAGPBstH_SHIFT 0
+#define HC_HAGPBpL_MASK 0x00fffffc
+#define HC_HAGPBpID_MASK 0x00000003
+#define HC_HAGPBpID_PAUSE 0x00000000
+#define HC_HAGPBpID_JUMP 0x00000001
+#define HC_HAGPBpID_STOP 0x00000002
+#define HC_HAGPBpH_MASK 0x00ffffff
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_context.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_context.c
new file mode 100644
index 000000000..4c18eba9b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_context.c
@@ -0,0 +1,782 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+/**
+ * \file via_context.c
+ *
+ * \author John Sheng (presumably of either VIA Technologies or S3 Graphics)
+ * \author Others at VIA Technologies?
+ * \author Others at S3 Graphics?
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "matrix.h"
+#include "state.h"
+#include "simple_list.h"
+#include "extensions.h"
+#include "framebuffer.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "array_cache/acache.h"
+
+#include "tnl/t_pipeline.h"
+
+#include "drivers/common/driverfuncs.h"
+
+#include "via_screen.h"
+#include "via_dri.h"
+
+#include "via_state.h"
+#include "via_tex.h"
+#include "via_span.h"
+#include "via_tris.h"
+#include "via_ioctl.h"
+#include "via_fb.h"
+
+#include <stdio.h>
+#include "macros.h"
+
+#define need_GL_ARB_multisample
+#define need_GL_ARB_point_parameters
+#define need_GL_EXT_fog_coord
+#define need_GL_EXT_secondary_color
+#include "extension_helper.h"
+
+#define DRIVER_DATE "20050526"
+
+#include "vblank.h"
+#include "utils.h"
+
+GLuint VIA_DEBUG = 0;
+
+/**
+ * Return various strings for \c glGetString.
+ *
+ * \sa glGetString
+ */
+static const GLubyte *viaGetString(GLcontext *ctx, GLenum name)
+{
+ static char buffer[128];
+ unsigned offset;
+
+
+ switch (name) {
+ case GL_VENDOR:
+ return (GLubyte *)"VIA Technology";
+
+ case GL_RENDERER: {
+ static const char * const chipset_names[] = {
+ "UniChrome",
+ "CastleRock (CLE266)",
+ "UniChrome (KM400)",
+ "UniChrome (K8M800)",
+ "UniChrome (PM8x0/CN400)",
+ };
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ unsigned id = vmesa->viaScreen->deviceID;
+
+ offset = driGetRendererString( buffer,
+ chipset_names[(id > VIA_PM800) ? 0 : id],
+ DRIVER_DATE, 0 );
+ return (GLubyte *)buffer;
+ }
+
+ default:
+ return NULL;
+ }
+}
+
+
+/**
+ * Calculate a width that satisfies the hardware's alignment requirements.
+ * On the Unichrome hardware, each scanline must be aligned to a multiple of
+ * 16 pixels.
+ *
+ * \param width Minimum buffer width, in pixels.
+ *
+ * \returns A pixel width that meets the alignment requirements.
+ */
+static __inline__ unsigned
+buffer_align( unsigned width )
+{
+ return (width + 0x0f) & ~0x0f;
+}
+
+
+/**
+ * Calculate the framebuffer parameters for all buffers (front, back, depth,
+ * and stencil) associated with the specified context.
+ *
+ * \warning
+ * This function also calls \c AllocateBuffer to actually allocate the
+ * buffers.
+ *
+ * \sa AllocateBuffer
+ */
+static GLboolean
+calculate_buffer_parameters( struct via_context *vmesa )
+{
+ const unsigned shift = vmesa->viaScreen->bitsPerPixel / 16;
+ const unsigned extra = 32;
+ unsigned w;
+ unsigned h;
+
+ /* Allocate front-buffer */
+ if (vmesa->drawType == GLX_PBUFFER_BIT) {
+ w = vmesa->driDrawable->w;
+ h = vmesa->driDrawable->h;
+
+ vmesa->front.bpp = vmesa->viaScreen->bitsPerPixel;
+ vmesa->front.pitch = buffer_align( w ) << shift;
+ vmesa->front.size = vmesa->front.pitch * h;
+
+ if (vmesa->front.map)
+ via_free_draw_buffer(vmesa, &vmesa->front);
+ if (!via_alloc_draw_buffer(vmesa, &vmesa->front))
+ return GL_FALSE;
+
+ } else {
+ w = vmesa->viaScreen->width;
+ h = vmesa->viaScreen->height;
+
+ vmesa->front.bpp = vmesa->viaScreen->bitsPerPixel;
+ vmesa->front.pitch = buffer_align( w ) << shift;
+ vmesa->front.size = vmesa->front.pitch * h;
+ if (getenv("ALTERNATE_SCREEN"))
+ vmesa->front.offset = vmesa->front.size;
+ else
+ vmesa->front.offset = 0;
+ vmesa->front.map = (char *) vmesa->driScreen->pFB;
+ }
+
+
+ /* Allocate back-buffer */
+ if (vmesa->hasBack) {
+ vmesa->back.bpp = vmesa->viaScreen->bitsPerPixel;
+ vmesa->back.pitch = (buffer_align( vmesa->driDrawable->w ) << shift);
+ vmesa->back.pitch += extra;
+ vmesa->back.pitch = MIN2(vmesa->back.pitch, vmesa->front.pitch);
+ vmesa->back.size = vmesa->back.pitch * vmesa->driDrawable->h;
+ if (vmesa->back.map)
+ via_free_draw_buffer(vmesa, &vmesa->back);
+ if (!via_alloc_draw_buffer(vmesa, &vmesa->back))
+ return GL_FALSE;
+ }
+ else {
+ if (vmesa->back.map)
+ via_free_draw_buffer(vmesa, &vmesa->back);
+ (void) memset( &vmesa->back, 0, sizeof( vmesa->back ) );
+ }
+
+
+ /* Allocate depth-buffer */
+ if ( vmesa->hasStencil || vmesa->hasDepth ) {
+ vmesa->depth.bpp = vmesa->depthBits;
+ if (vmesa->depth.bpp == 24)
+ vmesa->depth.bpp = 32;
+
+ vmesa->depth.pitch = (buffer_align( vmesa->driDrawable->w ) *
+ (vmesa->depth.bpp/8)) + extra;
+ vmesa->depth.size = vmesa->depth.pitch * vmesa->driDrawable->h;
+
+ if (vmesa->depth.map)
+ via_free_draw_buffer(vmesa, &vmesa->depth);
+ if (!via_alloc_draw_buffer(vmesa, &vmesa->depth)) {
+ return GL_FALSE;
+ }
+ }
+ else {
+ if (vmesa->depth.map)
+ via_free_draw_buffer(vmesa, &vmesa->depth);
+ (void) memset( & vmesa->depth, 0, sizeof( vmesa->depth ) );
+ }
+
+ if( vmesa->viaScreen->width == vmesa->driDrawable->w &&
+ vmesa->viaScreen->height == vmesa->driDrawable->h ) {
+ vmesa->doPageFlip = vmesa->allowPageFlip;
+ assert(vmesa->back.pitch == vmesa->front.pitch);
+ }
+ else
+ vmesa->doPageFlip = GL_FALSE;
+
+ return GL_TRUE;
+}
+
+
+void viaReAllocateBuffers(GLcontext *ctx, GLframebuffer *drawbuffer,
+ GLuint width, GLuint height)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+
+#if 0
+ _swrast_alloc_buffers( drawbuffer );
+#else
+ _mesa_resize_framebuffer(ctx, drawbuffer, width, height);
+#endif
+
+ calculate_buffer_parameters( vmesa );
+}
+
+static void viaBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ *width = vmesa->driDrawable->w;
+ *height = vmesa->driDrawable->h;
+}
+
+/* Extension strings exported by the Unichrome driver.
+ */
+const struct dri_extension card_extensions[] =
+{
+ { "GL_ARB_multisample", GL_ARB_multisample_functions },
+ { "GL_ARB_multitexture", NULL },
+ { "GL_ARB_point_parameters", GL_ARB_point_parameters_functions },
+ { "GL_ARB_texture_env_add", NULL },
+ { "GL_ARB_texture_env_combine", NULL },
+/* { "GL_ARB_texture_env_dot3", NULL }, */
+ { "GL_ARB_texture_mirrored_repeat", NULL },
+ { "GL_EXT_fog_coord", GL_EXT_fog_coord_functions },
+ { "GL_EXT_secondary_color", GL_EXT_secondary_color_functions },
+ { "GL_EXT_stencil_wrap", NULL },
+ { "GL_EXT_texture_env_combine", NULL },
+/* { "GL_EXT_texture_env_dot3", NULL }, */
+ { "GL_EXT_texture_lod_bias", NULL },
+ { "GL_NV_blend_square", NULL },
+ { NULL, NULL }
+};
+
+extern const struct tnl_pipeline_stage _via_fastrender_stage;
+extern const struct tnl_pipeline_stage _via_render_stage;
+
+static const struct tnl_pipeline_stage *via_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ /* REMOVE: point attenuation stage */
+#if 1
+ &_via_fastrender_stage, /* ADD: unclipped rastersetup-to-dma */
+#endif
+ &_tnl_render_stage,
+ 0,
+};
+
+
+static const struct dri_debug_control debug_control[] =
+{
+ { "fall", DEBUG_FALLBACKS },
+ { "tex", DEBUG_TEXTURE },
+ { "ioctl", DEBUG_IOCTL },
+ { "prim", DEBUG_PRIMS },
+ { "vert", DEBUG_VERTS },
+ { "state", DEBUG_STATE },
+ { "verb", DEBUG_VERBOSE },
+ { "dri", DEBUG_DRI },
+ { "dma", DEBUG_DMA },
+ { "san", DEBUG_SANITY },
+ { "sync", DEBUG_SYNC },
+ { "sleep", DEBUG_SLEEP },
+ { "pix", DEBUG_PIXEL },
+ { "2d", DEBUG_2D },
+ { NULL, 0 }
+};
+
+
+static GLboolean
+AllocateDmaBuffer(struct via_context *vmesa)
+{
+ if (vmesa->dma)
+ via_free_dma_buffer(vmesa);
+
+ if (!via_alloc_dma_buffer(vmesa))
+ return GL_FALSE;
+
+ vmesa->dmaLow = 0;
+ vmesa->dmaCliprectAddr = ~0;
+ return GL_TRUE;
+}
+
+static void
+FreeBuffer(struct via_context *vmesa)
+{
+ if (vmesa->front.map && vmesa->drawType == GLX_PBUFFER_BIT)
+ via_free_draw_buffer(vmesa, &vmesa->front);
+
+ if (vmesa->back.map)
+ via_free_draw_buffer(vmesa, &vmesa->back);
+
+ if (vmesa->depth.map)
+ via_free_draw_buffer(vmesa, &vmesa->depth);
+
+ if (vmesa->breadcrumb.map)
+ via_free_draw_buffer(vmesa, &vmesa->breadcrumb);
+
+ if (vmesa->dma)
+ via_free_dma_buffer(vmesa);
+}
+
+
+GLboolean
+viaCreateContext(const __GLcontextModes *visual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate)
+{
+ GLcontext *ctx, *shareCtx;
+ struct via_context *vmesa;
+ __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ viaScreenPrivate *viaScreen = (viaScreenPrivate *)sPriv->private;
+ drm_via_sarea_t *saPriv = (drm_via_sarea_t *)
+ (((GLubyte *)sPriv->pSAREA) + viaScreen->sareaPrivOffset);
+ struct dd_function_table functions;
+
+ /* Allocate via context */
+ vmesa = (struct via_context *) CALLOC_STRUCT(via_context);
+ if (!vmesa) {
+ return GL_FALSE;
+ }
+
+ /* Parse configuration files.
+ */
+ driParseConfigFiles (&vmesa->optionCache, &viaScreen->optionCache,
+ sPriv->myNum, "via");
+
+ /* pick back buffer */
+ vmesa->hasBack = visual->doubleBufferMode;
+
+ switch(visual->depthBits) {
+ case 0:
+ vmesa->hasDepth = GL_FALSE;
+ vmesa->depthBits = 0;
+ vmesa->depth_max = 1.0;
+ break;
+ case 16:
+ vmesa->hasDepth = GL_TRUE;
+ vmesa->depthBits = visual->depthBits;
+ vmesa->have_hw_stencil = GL_FALSE;
+ vmesa->depth_max = (GLfloat)0xffff;
+ vmesa->depth_clear_mask = 0xf << 28;
+ vmesa->ClearDepth = 0xffff;
+ vmesa->polygon_offset_scale = 1.0 / vmesa->depth_max;
+ break;
+ case 24:
+ vmesa->hasDepth = GL_TRUE;
+ vmesa->depthBits = visual->depthBits;
+ vmesa->depth_max = (GLfloat) 0xffffff;
+ vmesa->depth_clear_mask = 0xe << 28;
+ vmesa->ClearDepth = 0xffffff00;
+
+ assert(visual->haveStencilBuffer);
+ assert(visual->stencilBits == 8);
+
+ vmesa->have_hw_stencil = GL_TRUE;
+ vmesa->stencilBits = visual->stencilBits;
+ vmesa->stencil_clear_mask = 0x1 << 28;
+ vmesa->polygon_offset_scale = 2.0 / vmesa->depth_max;
+ break;
+ case 32:
+ vmesa->hasDepth = GL_TRUE;
+ vmesa->depthBits = visual->depthBits;
+ assert(!visual->haveStencilBuffer);
+ vmesa->have_hw_stencil = GL_FALSE;
+ vmesa->depth_max = (GLfloat)0xffffffff;
+ vmesa->depth_clear_mask = 0xf << 28;
+ vmesa->ClearDepth = 0xffffffff;
+ vmesa->polygon_offset_scale = 2.0 / vmesa->depth_max;
+ break;
+ default:
+ assert(0);
+ break;
+ }
+
+ make_empty_list(&vmesa->freed_tex_buffers);
+ make_empty_list(&vmesa->tex_image_list[VIA_MEM_VIDEO]);
+ make_empty_list(&vmesa->tex_image_list[VIA_MEM_AGP]);
+ make_empty_list(&vmesa->tex_image_list[VIA_MEM_SYSTEM]);
+
+ _mesa_init_driver_functions(&functions);
+ viaInitTextureFuncs(&functions);
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((struct via_context *) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+
+ vmesa->glCtx = _mesa_create_context(visual, shareCtx, &functions,
+ (void*) vmesa);
+
+ vmesa->shareCtx = shareCtx;
+
+ if (!vmesa->glCtx) {
+ FREE(vmesa);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = vmesa;
+
+ ctx = vmesa->glCtx;
+
+ ctx->Const.MaxTextureLevels = 10;
+ ctx->Const.MaxTextureUnits = 2;
+ ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits;
+ ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits;
+
+ ctx->Const.MinLineWidth = 1.0;
+ ctx->Const.MinLineWidthAA = 1.0;
+ ctx->Const.MaxLineWidth = 1.0;
+ ctx->Const.MaxLineWidthAA = 1.0;
+ ctx->Const.LineWidthGranularity = 1.0;
+
+ ctx->Const.MinPointSize = 1.0;
+ ctx->Const.MinPointSizeAA = 1.0;
+ ctx->Const.MaxPointSize = 1.0;
+ ctx->Const.MaxPointSizeAA = 1.0;
+ ctx->Const.PointSizeGranularity = 1.0;
+
+ ctx->Driver.GetBufferSize = viaBufferSize;
+/* ctx->Driver.ResizeBuffers = _swrast_alloc_buffers; *//* FIXME ?? */
+ ctx->Driver.GetString = viaGetString;
+
+ ctx->DriverCtx = (void *)vmesa;
+ vmesa->glCtx = ctx;
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext(ctx);
+ _ac_CreateContext(ctx);
+ _tnl_CreateContext(ctx);
+ _swsetup_CreateContext(ctx);
+
+ /* Install the customized pipeline:
+ */
+ _tnl_destroy_pipeline(ctx);
+ _tnl_install_pipeline(ctx, via_pipeline);
+
+ /* Configure swrast and T&L to match hardware characteristics:
+ */
+ _swrast_allow_pixel_fog(ctx, GL_FALSE);
+ _swrast_allow_vertex_fog(ctx, GL_TRUE);
+ _tnl_allow_pixel_fog(ctx, GL_FALSE);
+ _tnl_allow_vertex_fog(ctx, GL_TRUE);
+
+/* vmesa->display = dpy; */
+ vmesa->display = sPriv->display;
+
+ vmesa->hHWContext = driContextPriv->hHWContext;
+ vmesa->driFd = sPriv->fd;
+ vmesa->driHwLock = &sPriv->pSAREA->lock;
+
+ vmesa->viaScreen = viaScreen;
+ vmesa->driScreen = sPriv;
+ vmesa->sarea = saPriv;
+
+ vmesa->renderIndex = ~0;
+ vmesa->setupIndex = ~0;
+ vmesa->hwPrimitive = GL_POLYGON+1;
+
+ /* KW: Hardwire this. Was previously set bogusly in
+ * viaCreateBuffer. Needs work before PBUFFER can be used:
+ */
+ vmesa->drawType = GLX_WINDOW_BIT;
+
+
+ _math_matrix_ctr(&vmesa->ViewportMatrix);
+
+ /* Do this early, before VIA_FLUSH_DMA can be called:
+ */
+ if (!AllocateDmaBuffer(vmesa)) {
+ fprintf(stderr ,"AllocateDmaBuffer fail\n");
+ FreeBuffer(vmesa);
+ FREE(vmesa);
+ return GL_FALSE;
+ }
+
+ /* Allocate a small piece of fb memory for synchronization:
+ */
+ vmesa->breadcrumb.bpp = 32;
+ vmesa->breadcrumb.pitch = buffer_align( 64 ) << 2;
+ vmesa->breadcrumb.size = vmesa->breadcrumb.pitch;
+
+ if (!via_alloc_draw_buffer(vmesa, &vmesa->breadcrumb)) {
+ fprintf(stderr ,"AllocateDmaBuffer fail\n");
+ FreeBuffer(vmesa);
+ FREE(vmesa);
+ return GL_FALSE;
+ }
+
+ driInitExtensions( ctx, card_extensions, GL_TRUE );
+ viaInitStateFuncs(ctx);
+ viaInitTriFuncs(ctx);
+ viaInitSpanFuncs(ctx);
+ viaInitIoctlFuncs(ctx);
+ viaInitState(ctx);
+
+ if (getenv("VIA_DEBUG"))
+ VIA_DEBUG = driParseDebugString( getenv( "VIA_DEBUG" ),
+ debug_control );
+
+ if (getenv("VIA_NO_RAST"))
+ FALLBACK(vmesa, VIA_FALLBACK_USER_DISABLE, 1);
+
+ /* I don't understand why this isn't working:
+ */
+ vmesa->vblank_flags =
+ vmesa->viaScreen->irqEnabled ?
+ driGetDefaultVBlankFlags(&vmesa->optionCache) : VBLANK_FLAG_NO_IRQ;
+
+ /* Hack this up in its place:
+ */
+ vmesa->vblank_flags = (getenv("VIA_VSYNC") ?
+ VBLANK_FLAG_SYNC : VBLANK_FLAG_NO_IRQ);
+
+ if (getenv("VIA_PAGEFLIP"))
+ vmesa->allowPageFlip = 1;
+
+ (*dri_interface->getUST)( &vmesa->swap_ust );
+
+
+ vmesa->regMMIOBase = (GLuint *)((unsigned long)viaScreen->reg);
+ vmesa->pnGEMode = (GLuint *)((unsigned long)viaScreen->reg + 0x4);
+ vmesa->regEngineStatus = (GLuint *)((unsigned long)viaScreen->reg + 0x400);
+ vmesa->regTranSet = (GLuint *)((unsigned long)viaScreen->reg + 0x43C);
+ vmesa->regTranSpace = (GLuint *)((unsigned long)viaScreen->reg + 0x440);
+ vmesa->agpBase = viaScreen->agpBase;
+
+
+ return GL_TRUE;
+}
+
+void
+viaDestroyContext(__DRIcontextPrivate *driContextPriv)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct via_context *vmesa =
+ (struct via_context *)driContextPriv->driverPrivate;
+ struct via_context *current = ctx ? VIA_CONTEXT(ctx) : NULL;
+ assert(vmesa); /* should never be null */
+
+ /* check if we're deleting the currently bound context */
+ if (vmesa == current) {
+ VIA_FLUSH_DMA(vmesa);
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ if (vmesa) {
+ viaWaitIdle(vmesa, GL_FALSE);
+ if (vmesa->doPageFlip) {
+ LOCK_HARDWARE(vmesa);
+ if (vmesa->pfCurrentOffset != 0) {
+ fprintf(stderr, "%s - reset pf\n", __FUNCTION__);
+ viaResetPageFlippingLocked(vmesa);
+ }
+ UNLOCK_HARDWARE(vmesa);
+ }
+
+ _swsetup_DestroyContext(vmesa->glCtx);
+ _tnl_DestroyContext(vmesa->glCtx);
+ _ac_DestroyContext(vmesa->glCtx);
+ _swrast_DestroyContext(vmesa->glCtx);
+ /* free the Mesa context */
+ _mesa_destroy_context(vmesa->glCtx);
+ /* release our data */
+ FreeBuffer(vmesa);
+
+ assert (is_empty_list(&vmesa->tex_image_list[VIA_MEM_AGP]));
+ assert (is_empty_list(&vmesa->tex_image_list[VIA_MEM_VIDEO]));
+ assert (is_empty_list(&vmesa->tex_image_list[VIA_MEM_SYSTEM]));
+ assert (is_empty_list(&vmesa->freed_tex_buffers));
+
+ FREE(vmesa);
+ }
+}
+
+
+void viaXMesaWindowMoved(struct via_context *vmesa)
+{
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+ GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3;
+
+ if (!dPriv)
+ return;
+
+ switch (vmesa->glCtx->DrawBuffer->_ColorDrawBufferMask[0]) {
+ case BUFFER_BIT_BACK_LEFT:
+ if (dPriv->numBackClipRects == 0) {
+ vmesa->numClipRects = dPriv->numClipRects;
+ vmesa->pClipRects = dPriv->pClipRects;
+ }
+ else {
+ vmesa->numClipRects = dPriv->numBackClipRects;
+ vmesa->pClipRects = dPriv->pBackClipRects;
+ }
+ break;
+ case BUFFER_BIT_FRONT_LEFT:
+ vmesa->numClipRects = dPriv->numClipRects;
+ vmesa->pClipRects = dPriv->pClipRects;
+ break;
+ default:
+ vmesa->numClipRects = 0;
+ break;
+ }
+
+ if (vmesa->drawW != dPriv->w ||
+ vmesa->drawH != dPriv->h)
+ calculate_buffer_parameters( vmesa );
+
+ vmesa->drawXoff = (GLuint)(((dPriv->x * bytePerPixel) & 0x1f) /
+ bytePerPixel);
+ vmesa->drawX = dPriv->x - vmesa->drawXoff;
+ vmesa->drawY = dPriv->y;
+ vmesa->drawW = dPriv->w;
+ vmesa->drawH = dPriv->h;
+
+ vmesa->front.orig = (vmesa->front.offset +
+ vmesa->drawY * vmesa->front.pitch +
+ vmesa->drawX * bytePerPixel);
+
+ vmesa->front.origMap = (vmesa->front.map +
+ vmesa->drawY * vmesa->front.pitch +
+ vmesa->drawX * bytePerPixel);
+
+ vmesa->back.orig = vmesa->back.offset;
+ vmesa->depth.orig = vmesa->depth.offset;
+ vmesa->back.origMap = vmesa->back.map;
+ vmesa->depth.origMap = vmesa->depth.map;
+
+ viaCalcViewport(vmesa->glCtx);
+}
+
+GLboolean
+viaUnbindContext(__DRIcontextPrivate *driContextPriv)
+{
+ return GL_TRUE;
+}
+
+GLboolean
+viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
+{
+ if (VIA_DEBUG & DEBUG_DRI) {
+ fprintf(stderr, "driContextPriv = %016lx\n", (unsigned long)driContextPriv);
+ fprintf(stderr, "driDrawPriv = %016lx\n", (unsigned long)driDrawPriv);
+ fprintf(stderr, "driReadPriv = %016lx\n", (unsigned long)driReadPriv);
+ }
+
+ if (driContextPriv) {
+ struct via_context *vmesa =
+ (struct via_context *)driContextPriv->driverPrivate;
+ GLcontext *ctx = vmesa->glCtx;
+
+ if ( vmesa->driDrawable != driDrawPriv ) {
+ driDrawableInitVBlank( driDrawPriv, vmesa->vblank_flags );
+ vmesa->driDrawable = driDrawPriv;
+ if ( ! calculate_buffer_parameters( vmesa ) ) {
+ return GL_FALSE;
+ }
+ }
+
+ _mesa_make_current(vmesa->glCtx,
+ (GLframebuffer *)driDrawPriv->driverPrivate,
+ (GLframebuffer *)driReadPriv->driverPrivate);
+
+
+ ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] );
+
+ viaXMesaWindowMoved(vmesa);
+ ctx->Driver.Scissor(vmesa->glCtx,
+ vmesa->glCtx->Scissor.X,
+ vmesa->glCtx->Scissor.Y,
+ vmesa->glCtx->Scissor.Width,
+ vmesa->glCtx->Scissor.Height);
+ }
+ else {
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ return GL_TRUE;
+}
+
+void viaGetLock(struct via_context *vmesa, GLuint flags)
+{
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+ __DRIscreenPrivate *sPriv = vmesa->driScreen;
+
+ drmGetLock(vmesa->driFd, vmesa->hHWContext, flags);
+
+ DRI_VALIDATE_DRAWABLE_INFO( sPriv, dPriv );
+
+ if (vmesa->sarea->ctxOwner != vmesa->hHWContext) {
+ vmesa->sarea->ctxOwner = vmesa->hHWContext;
+ vmesa->newEmitState = ~0;
+ }
+
+ if (vmesa->lastStamp != dPriv->lastStamp) {
+ viaXMesaWindowMoved(vmesa);
+ vmesa->newEmitState = ~0;
+ vmesa->lastStamp = dPriv->lastStamp;
+ }
+
+ if (vmesa->doPageFlip &&
+ vmesa->pfCurrentOffset != vmesa->sarea->pfCurrentOffset) {
+ fprintf(stderr, "%s - reset pf\n", __FUNCTION__);
+ viaResetPageFlippingLocked(vmesa);
+ }
+}
+
+
+void
+viaSwapBuffers(__DRIdrawablePrivate *drawablePrivate)
+{
+ __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *)drawablePrivate;
+
+ if (dPriv &&
+ dPriv->driContextPriv &&
+ dPriv->driContextPriv->driverPrivate) {
+ struct via_context *vmesa =
+ (struct via_context *)dPriv->driContextPriv->driverPrivate;
+ GLcontext *ctx = vmesa->glCtx;
+
+ _mesa_notifySwapBuffers(ctx);
+
+ if (ctx->Visual.doubleBufferMode) {
+ if (vmesa->doPageFlip) {
+ viaPageFlip(dPriv);
+ }
+ else {
+ viaCopyBuffer(dPriv);
+ }
+ }
+ else
+ VIA_FLUSH_DMA(vmesa);
+ }
+ else {
+ _mesa_problem(NULL, "viaSwapBuffers: drawable has no context!\n");
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_context.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_context.h
new file mode 100644
index 000000000..e51ec48af
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_context.h
@@ -0,0 +1,412 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+#ifndef _VIACONTEXT_H
+#define _VIACONTEXT_H
+
+#include "dri_util.h"
+
+#include "mtypes.h"
+#include "drm.h"
+#include "mm.h"
+#include "tnl/t_vertex.h"
+
+#include "via_screen.h"
+#include "via_tex.h"
+#include "via_drm.h"
+
+struct via_context;
+
+/* Chip tags. These are used to group the adapters into
+ * related families.
+ */
+enum VIACHIPTAGS {
+ VIA_UNKNOWN = 0,
+ VIA_CLE266,
+ VIA_KM400,
+ VIA_K8M800,
+ VIA_PM800,
+ VIA_LAST
+};
+
+#define VIA_FALLBACK_TEXTURE 0x1
+#define VIA_FALLBACK_DRAW_BUFFER 0x2
+#define VIA_FALLBACK_READ_BUFFER 0x4
+#define VIA_FALLBACK_COLORMASK 0x8
+#define VIA_FALLBACK_SPECULAR 0x20
+#define VIA_FALLBACK_LOGICOP 0x40
+#define VIA_FALLBACK_RENDERMODE 0x80
+#define VIA_FALLBACK_STENCIL 0x100
+#define VIA_FALLBACK_BLEND_EQ 0x200
+#define VIA_FALLBACK_BLEND_FUNC 0x400
+#define VIA_FALLBACK_USER_DISABLE 0x800
+#define VIA_FALLBACK_PROJ_TEXTURE 0x1000
+#define VIA_FALLBACK_POLY_STIPPLE 0x2000
+
+#define VIA_DMA_BUFSIZ 4096
+#define VIA_DMA_HIGHWATER (VIA_DMA_BUFSIZ - 128)
+
+#define VIA_NO_CLIPRECTS 0x1
+
+
+/* Use the templated vertex formats:
+ */
+#define TAG(x) via##x
+#include "tnl_dd/t_dd_vertex.h"
+#undef TAG
+
+typedef void (*via_tri_func)(struct via_context *, viaVertex *, viaVertex *,
+ viaVertex *);
+typedef void (*via_line_func)(struct via_context *, viaVertex *, viaVertex *);
+typedef void (*via_point_func)(struct via_context *, viaVertex *);
+
+struct via_buffer {
+ drm_handle_t handle;
+ drmSize size;
+ unsigned long offset;
+ unsigned long index;
+ GLuint pitch;
+ GLuint bpp;
+ char *map;
+ GLuint orig; /* The drawing origin,
+ * at (drawX,drawY) in screen space.
+ */
+ char *origMap;
+};
+
+
+#define VIA_MAX_TEXLEVELS 10
+
+struct via_tex_buffer {
+ struct via_tex_buffer *next, *prev;
+ struct via_texture_image *image;
+ unsigned long index;
+ unsigned long offset;
+ GLuint size;
+ GLuint memType;
+ unsigned char *bufAddr;
+ GLuint texBase;
+ GLuint lastUsed;
+};
+
+
+
+struct via_texture_image {
+ struct gl_texture_image image;
+ struct via_tex_buffer *texMem;
+ GLint pitchLog2;
+};
+
+struct via_texture_object {
+ struct gl_texture_object obj; /* The "parent" object */
+
+ GLuint texelBytes;
+ GLuint memType;
+
+ GLuint regTexFM;
+ GLuint regTexWidthLog2[2];
+ GLuint regTexHeightLog2[2];
+ GLuint regTexBaseH[4];
+ struct {
+ GLuint baseL;
+ GLuint pitchLog2;
+ } regTexBaseAndPitch[12];
+
+ GLint firstLevel, lastLevel; /* upload tObj->Image[first .. lastLevel] */
+};
+
+
+
+struct via_context {
+ GLint refcount;
+ GLcontext *glCtx;
+ GLcontext *shareCtx;
+
+ struct via_buffer front;
+ struct via_buffer back;
+ struct via_buffer depth;
+ struct via_buffer breadcrumb;
+
+ GLboolean hasBack;
+ GLboolean hasDepth;
+ GLboolean hasStencil;
+ GLboolean hasAccum;
+ GLuint depthBits;
+ GLuint stencilBits;
+
+ GLboolean have_hw_stencil;
+ GLuint ClearDepth;
+ GLuint depth_clear_mask;
+ GLuint stencil_clear_mask;
+ GLfloat depth_max;
+ GLfloat polygon_offset_scale;
+
+ GLubyte *dma;
+ viaRegion tex;
+
+ /* Bit flag to keep 0track of fallbacks.
+ */
+ GLuint Fallback;
+
+ /* State for via_tris.c.
+ */
+ GLuint newState; /* _NEW_* flags */
+ GLuint newEmitState; /* _NEW_* flags */
+ GLuint newRenderState; /* _NEW_* flags */
+
+ struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
+ GLuint vertex_attr_count;
+
+ GLuint setupIndex;
+ GLuint renderIndex;
+ GLmatrix ViewportMatrix;
+ GLenum renderPrimitive;
+ GLenum hwPrimitive;
+ GLenum hwShadeModel;
+ unsigned char *verts;
+
+ /* drmBufPtr dma_buffer;
+ */
+ GLuint dmaLow;
+ GLuint dmaCliprectAddr;
+ GLuint dmaLastPrim;
+ GLboolean useAgp;
+
+
+ /* Fallback rasterization functions
+ */
+ via_point_func drawPoint;
+ via_line_func drawLine;
+ via_tri_func drawTri;
+
+ /* Hardware register
+ */
+ GLuint regCmdA_End;
+ GLuint regCmdB;
+
+ GLuint regEnable;
+ GLuint regHFBBMSKL;
+ GLuint regHROP;
+
+ GLuint regHZWTMD;
+ GLuint regHSTREF;
+ GLuint regHSTMD;
+
+ GLuint regHATMD;
+ GLuint regHABLCsat;
+ GLuint regHABLCop;
+ GLuint regHABLAsat;
+ GLuint regHABLAop;
+ GLuint regHABLRCa;
+ GLuint regHABLRFCa;
+ GLuint regHABLRCbias;
+ GLuint regHABLRCb;
+ GLuint regHABLRFCb;
+ GLuint regHABLRAa;
+ GLuint regHABLRAb;
+ GLuint regHFogLF;
+ GLuint regHFogCL;
+ GLuint regHFogCH;
+
+ GLuint regHLP;
+ GLuint regHLPRF;
+
+ GLuint regHTXnCLOD[2];
+ GLuint regHTXnTB[2];
+ GLuint regHTXnMPMD[2];
+ GLuint regHTXnTBLCsat[2];
+ GLuint regHTXnTBLCop[2];
+ GLuint regHTXnTBLMPfog[2];
+ GLuint regHTXnTBLAsat[2];
+ GLuint regHTXnTBLRCb[2];
+ GLuint regHTXnTBLRAa[2];
+ GLuint regHTXnTBLRFog[2];
+ GLuint regHTXnTBLRCa[2];
+ GLuint regHTXnTBLRCc[2];
+ GLuint regHTXnTBLRCbias[2];
+ GLuint regHTXnTBC[2];
+ GLuint regHTXnTRAH[2];
+
+ int vertexSize;
+ int hwVertexSize;
+ GLboolean ptexHack;
+ int coloroffset;
+ int specoffset;
+
+ GLint lastStamp;
+
+ GLuint ClearColor;
+ GLuint ClearMask;
+
+ /* DRI stuff
+ */
+ GLboolean doPageFlip;
+
+ struct via_buffer *drawBuffer;
+ struct via_buffer *readBuffer;
+
+ int drawX; /* origin of drawable in draw buffer */
+ int drawY;
+ int drawW;
+ int drawH;
+
+ int drawXoff; /* drawX is 32byte aligned - this is
+ * the delta to the real origin, in
+ * pixel units.
+ */
+
+ GLuint numClipRects; /* cliprects for that buffer */
+ drm_clip_rect_t *pClipRects;
+
+ GLboolean scissor;
+ drm_clip_rect_t drawRect;
+ drm_clip_rect_t scissorRect;
+
+ drm_context_t hHWContext;
+ drm_hw_lock_t *driHwLock;
+ int driFd;
+ __DRInativeDisplay *display;
+
+ __DRIdrawablePrivate *driDrawable;
+ __DRIscreenPrivate *driScreen;
+ viaScreenPrivate *viaScreen;
+ drm_via_sarea_t *sarea;
+ volatile GLuint* regMMIOBase;
+ volatile GLuint* pnGEMode;
+ volatile GLuint* regEngineStatus;
+ volatile GLuint* regTranSet;
+ volatile GLuint* regTranSpace;
+ GLuint agpBase;
+ GLuint drawType;
+
+ GLuint nDoneFirstFlip;
+ GLuint agpFullCount;
+
+ GLboolean clearTexCache;
+ GLboolean thrashing;
+
+ /* Configuration cache
+ */
+ driOptionCache optionCache;
+
+ GLuint vblank_flags;
+ GLuint vbl_seq;
+
+ int64_t swap_ust;
+ int64_t swap_missed_ust;
+
+ GLuint swap_count;
+ GLuint swap_missed_count;
+
+
+ GLuint pfCurrentOffset;
+ GLboolean allowPageFlip;
+
+ GLuint lastBreadcrumbRead;
+ GLuint lastBreadcrumbWrite;
+ GLuint lastSwap[2];
+ GLuint lastDma;
+
+ GLuint total_alloc[VIA_MEM_SYSTEM+1];
+
+ struct via_tex_buffer tex_image_list[VIA_MEM_SYSTEM+1];
+ struct via_tex_buffer freed_tex_buffers;
+
+};
+
+
+
+#define VIA_CONTEXT(ctx) ((struct via_context *)(ctx->DriverCtx))
+
+
+
+/* Lock the hardware and validate our state.
+ */
+#define LOCK_HARDWARE(vmesa) \
+ do { \
+ char __ret = 0; \
+ DRM_CAS(vmesa->driHwLock, vmesa->hHWContext, \
+ (DRM_LOCK_HELD|vmesa->hHWContext), __ret); \
+ if (__ret) \
+ viaGetLock(vmesa, 0); \
+ } while (0)
+
+
+/* Release the kernel lock.
+ */
+#define UNLOCK_HARDWARE(vmesa) \
+ DRM_UNLOCK(vmesa->driFd, vmesa->driHwLock, vmesa->hHWContext);
+
+
+
+extern GLuint VIA_DEBUG;
+
+#define DEBUG_TEXTURE 0x1
+#define DEBUG_STATE 0x2
+#define DEBUG_IOCTL 0x4
+#define DEBUG_PRIMS 0x8
+#define DEBUG_VERTS 0x10
+#define DEBUG_FALLBACKS 0x20
+#define DEBUG_VERBOSE 0x40
+#define DEBUG_DRI 0x80
+#define DEBUG_DMA 0x100
+#define DEBUG_SANITY 0x200
+#define DEBUG_SYNC 0x400
+#define DEBUG_SLEEP 0x800
+#define DEBUG_PIXEL 0x1000
+#define DEBUG_2D 0x2000
+
+
+extern void viaGetLock(struct via_context *vmesa, GLuint flags);
+extern void viaLock(struct via_context *vmesa, GLuint flags);
+extern void viaUnLock(struct via_context *vmesa, GLuint flags);
+extern void viaEmitHwStateLocked(struct via_context *vmesa);
+extern void viaEmitScissorValues(struct via_context *vmesa, int box_nr, int emit);
+extern void viaXMesaSetBackClipRects(struct via_context *vmesa);
+extern void viaXMesaSetFrontClipRects(struct via_context *vmesa);
+extern void viaReAllocateBuffers(GLcontext *ctx, GLframebuffer *drawbuffer, GLuint width, GLuint height);
+extern void viaXMesaWindowMoved(struct via_context *vmesa);
+
+extern GLboolean viaTexCombineState(struct via_context *vmesa,
+ const struct gl_tex_env_combine_state * combine,
+ unsigned unit );
+
+/* Via hw already adjusted for GL pixel centers:
+ */
+#define SUBPIXEL_X 0
+#define SUBPIXEL_Y 0
+
+/* TODO XXX _SOLO temp defines to make code compilable */
+#ifndef GLX_PBUFFER_BIT
+#define GLX_PBUFFER_BIT 0x00000004
+#endif
+#ifndef GLX_WINDOW_BIT
+#define GLX_WINDOW_BIT 0x00000001
+#endif
+#ifndef VERT_BIT_CLIP
+#define VERT_BIT_CLIP 0x1000000
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_drmclient.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_drmclient.h
new file mode 100644
index 000000000..7beff9a9d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_drmclient.h
@@ -0,0 +1,29 @@
+/*
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+#ifndef _VIA_DRMCLIENT_H_
+#define _VIA_DRMCLIENT_H_
+
+#define VIA_DMA_BUF_ORDER 12
+#define VIA_DMA_BUF_SZ (1 << VIA_DMA_BUF_ORDER)
+#define VIA_DMA_BUF_NR 256
+
+#endif /* _VIA_DRMCLIENT_H_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_fb.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_fb.c
new file mode 100644
index 000000000..faa669073
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_fb.c
@@ -0,0 +1,243 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+#include <assert.h>
+
+#include "via_context.h"
+#include "via_ioctl.h"
+#include "via_fb.h"
+#include "xf86drm.h"
+#include "imports.h"
+#include "simple_list.h"
+#include <sys/ioctl.h>
+
+GLboolean
+via_alloc_draw_buffer(struct via_context *vmesa, struct via_buffer *buf)
+{
+ drm_via_mem_t mem;
+ mem.context = vmesa->hHWContext;
+ mem.size = buf->size;
+ mem.type = VIA_MEM_VIDEO;
+ mem.offset = 0;
+ mem.index = 0;
+
+ if (ioctl(vmesa->driFd, DRM_IOCTL_VIA_ALLOCMEM, &mem))
+ return GL_FALSE;
+
+
+ buf->offset = mem.offset;
+ buf->map = (char *)vmesa->driScreen->pFB + mem.offset;
+ buf->index = mem.index;
+ return GL_TRUE;
+}
+
+void
+via_free_draw_buffer(struct via_context *vmesa, struct via_buffer *buf)
+{
+ drm_via_mem_t mem;
+
+ if (!vmesa) return;
+
+ mem.context = vmesa->hHWContext;
+ mem.index = buf->index;
+ mem.type = VIA_MEM_VIDEO;
+ mem.offset = buf->offset;
+ mem.size = buf->size;
+
+ ioctl(vmesa->driFd, DRM_IOCTL_VIA_FREEMEM, &mem);
+ buf->map = NULL;
+}
+
+
+GLboolean
+via_alloc_dma_buffer(struct via_context *vmesa)
+{
+ drm_via_dma_init_t init;
+
+ vmesa->dma = (GLubyte *) malloc(VIA_DMA_BUFSIZ);
+
+ /*
+ * Check whether AGP DMA has been initialized.
+ */
+ memset(&init, 0, sizeof(init));
+ init.func = VIA_DMA_INITIALIZED;
+
+ vmesa->useAgp =
+ ( 0 == drmCommandWrite(vmesa->driFd, DRM_VIA_DMA_INIT,
+ &init, sizeof(init)));
+ if (VIA_DEBUG & DEBUG_DMA) {
+ if (vmesa->useAgp)
+ fprintf(stderr, "unichrome_dri.so: Using AGP.\n");
+ else
+ fprintf(stderr, "unichrome_dri.so: Using PCI.\n");
+ }
+
+ return ((vmesa->dma) ? GL_TRUE : GL_FALSE);
+}
+
+void
+via_free_dma_buffer(struct via_context *vmesa)
+{
+ if (!vmesa) return;
+ free(vmesa->dma);
+ vmesa->dma = 0;
+}
+
+
+/* These functions now allocate and free the via_tex_buffer struct as well:
+ */
+struct via_tex_buffer *
+via_alloc_texture(struct via_context *vmesa,
+ GLuint size,
+ GLuint memType)
+{
+ struct via_tex_buffer *t = CALLOC_STRUCT(via_tex_buffer);
+
+ if (!t)
+ goto cleanup;
+
+ t->size = size;
+ t->memType = memType;
+ insert_at_tail(&vmesa->tex_image_list[memType], t);
+
+ if (t->memType == VIA_MEM_AGP ||
+ t->memType == VIA_MEM_VIDEO) {
+ drm_via_mem_t fb;
+
+ fb.context = vmesa->hHWContext;
+ fb.size = t->size;
+ fb.type = t->memType;
+ fb.offset = 0;
+ fb.index = 0;
+
+ if (ioctl(vmesa->driFd, DRM_IOCTL_VIA_ALLOCMEM, &fb) != 0 ||
+ fb.index == 0)
+ goto cleanup;
+
+ if (0)
+ fprintf(stderr, "offset %lx index %lx\n", fb.offset, fb.index);
+
+ t->offset = fb.offset;
+ t->index = fb.index;
+
+ if (t->memType == VIA_MEM_AGP) {
+ t->bufAddr = (GLubyte *)((unsigned long)vmesa->viaScreen->agpLinearStart +
+ fb.offset);
+ t->texBase = vmesa->agpBase + fb.offset;
+ }
+ else {
+ t->bufAddr = (GLubyte *)((unsigned long)vmesa->driScreen->pFB + fb.offset);
+ t->texBase = fb.offset;
+ }
+
+ vmesa->total_alloc[t->memType] += t->size;
+ return t;
+ }
+ else if (t->memType == VIA_MEM_SYSTEM) {
+
+ t->bufAddr = _mesa_malloc(t->size);
+ if (!t->bufAddr)
+ goto cleanup;
+
+ vmesa->total_alloc[t->memType] += t->size;
+ return t;
+ }
+
+ cleanup:
+ if (t) {
+ remove_from_list(t);
+ FREE(t);
+ }
+
+ return NULL;
+}
+
+
+static void
+via_do_free_texture(struct via_context *vmesa, struct via_tex_buffer *t)
+{
+ drm_via_mem_t fb;
+
+ remove_from_list( t );
+
+ vmesa->total_alloc[t->memType] -= t->size;
+
+ fb.context = vmesa->hHWContext;
+ fb.index = t->index;
+ fb.offset = t->offset;
+ fb.type = t->memType;
+ fb.size = t->size;
+
+ if (ioctl(vmesa->driFd, DRM_IOCTL_VIA_FREEMEM, &fb)) {
+ fprintf(stderr, "via_free_texture fail\n");
+ }
+
+ FREE(t);
+}
+
+
+/* Release textures which were potentially still being referenced by
+ * hardware at the time when they were originally freed.
+ */
+void
+via_release_pending_textures( struct via_context *vmesa )
+{
+ struct via_tex_buffer *s, *tmp;
+
+ foreach_s( s, tmp, &vmesa->freed_tex_buffers ) {
+ if (!VIA_GEQ_WRAP(s->lastUsed, vmesa->lastBreadcrumbRead)) {
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: release tex sz %d lastUsed %x\n",
+ __FUNCTION__, s->size, s->lastUsed);
+ via_do_free_texture(vmesa, s);
+ }
+ }
+}
+
+
+
+void
+via_free_texture(struct via_context *vmesa, struct via_tex_buffer *t)
+{
+ if (!t) {
+ return;
+ }
+ else if (t->memType == VIA_MEM_SYSTEM) {
+ remove_from_list(t);
+ vmesa->total_alloc[t->memType] -= t->size;
+ _mesa_free(t->bufAddr);
+ _mesa_free(t);
+ }
+ else if (t->index && viaCheckBreadcrumb(vmesa, t->lastUsed)) {
+ via_do_free_texture( vmesa, t );
+ }
+ else {
+ /* Close current breadcrumb so that we can free this eventually:
+ */
+ if (t->lastUsed == vmesa->lastBreadcrumbWrite)
+ viaEmitBreadcrumb(vmesa);
+
+ move_to_tail( &vmesa->freed_tex_buffers, t );
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_fb.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_fb.h
new file mode 100644
index 000000000..7ee153f47
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_fb.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+#ifndef _VIAFB_INC
+#define _VIAFB_INC
+
+#include "via_context.h"
+
+extern GLboolean via_alloc_draw_buffer(struct via_context *vmesa, struct via_buffer *buf);
+extern GLboolean via_alloc_dma_buffer(struct via_context *vmesa);
+
+struct via_tex_buffer *
+via_alloc_texture(struct via_context *vmesa,
+ GLuint size,
+ GLuint memType);
+
+extern void via_free_draw_buffer(struct via_context *vmesa, struct via_buffer *buf);
+extern void via_free_dma_buffer(struct via_context *vmesa);
+extern void via_free_texture(struct via_context *vmesa, struct via_tex_buffer *t);
+void via_release_pending_textures( struct via_context *vmesa );
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_ioctl.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_ioctl.c
new file mode 100644
index 000000000..e84f4294a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_ioctl.c
@@ -0,0 +1,970 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+#include <stdio.h>
+#include <unistd.h>
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "dd.h"
+#include "swrast/swrast.h"
+
+#include "mm.h"
+#include "via_context.h"
+#include "via_tris.h"
+#include "via_ioctl.h"
+#include "via_state.h"
+#include "via_fb.h"
+#include "via_3d_reg.h"
+
+#include "vblank.h"
+#include "drm.h"
+#include "xf86drm.h"
+#include <sys/ioctl.h>
+#include <errno.h>
+
+
+#define VIA_REG_STATUS 0x400
+#define VIA_REG_GEMODE 0x004
+#define VIA_REG_SRCBASE 0x030
+#define VIA_REG_DSTBASE 0x034
+#define VIA_REG_PITCH 0x038
+#define VIA_REG_SRCCOLORKEY 0x01C
+#define VIA_REG_KEYCONTROL 0x02C
+#define VIA_REG_SRCPOS 0x008
+#define VIA_REG_DSTPOS 0x00C
+#define VIA_REG_GECMD 0x000
+#define VIA_REG_DIMENSION 0x010 /* width and height */
+#define VIA_REG_FGCOLOR 0x018
+
+#define VIA_GEM_8bpp 0x00000000
+#define VIA_GEM_16bpp 0x00000100
+#define VIA_GEM_32bpp 0x00000300
+#define VIA_GEC_BLT 0x00000001
+#define VIA_PITCH_ENABLE 0x80000000
+#define VIA_GEC_INCX 0x00000000
+#define VIA_GEC_DECY 0x00004000
+#define VIA_GEC_INCY 0x00000000
+#define VIA_GEC_DECX 0x00008000
+#define VIA_GEC_FIXCOLOR_PAT 0x00002000
+
+
+#define VIA_BLIT_CLEAR 0x00
+#define VIA_BLIT_COPY 0xCC
+#define VIA_BLIT_FILL 0xF0
+#define VIA_BLIT_SET 0xFF
+
+static void dump_dma( struct via_context *vmesa )
+{
+ GLuint i;
+ GLuint *data = (GLuint *)vmesa->dma;
+ for (i = 0; i < vmesa->dmaLow; i += 16) {
+ fprintf(stderr, "%04x: ", i);
+ fprintf(stderr, "%08x ", *data++);
+ fprintf(stderr, "%08x ", *data++);
+ fprintf(stderr, "%08x ", *data++);
+ fprintf(stderr, "%08x\n", *data++);
+ }
+ fprintf(stderr, "******************************************\n");
+}
+
+
+void viaCheckDma(struct via_context *vmesa, GLuint bytes)
+{
+ VIA_FINISH_PRIM( vmesa );
+ if (vmesa->dmaLow + bytes > VIA_DMA_HIGHWATER) {
+ viaFlushDma(vmesa);
+ }
+}
+
+
+
+#define SetReg2DAGP(nReg, nData) do { \
+ OUT_RING( ((nReg) >> 2) | 0xF0000000 ); \
+ OUT_RING( nData ); \
+} while (0)
+
+
+static void viaBlit(struct via_context *vmesa, GLuint bpp,
+ GLuint srcBase, GLuint srcPitch,
+ GLuint dstBase, GLuint dstPitch,
+ GLuint w, GLuint h,
+ GLuint blitMode,
+ GLuint color, GLuint nMask )
+{
+
+ GLuint dwGEMode, srcX, dstX, cmd;
+ RING_VARS;
+
+ if (VIA_DEBUG & DEBUG_2D)
+ fprintf(stderr,
+ "%s bpp %d src %x/%x dst %x/%x w %d h %d "
+ " mode: %x color: 0x%08x mask 0x%08x\n",
+ __FUNCTION__, bpp, srcBase, srcPitch, dstBase,
+ dstPitch, w,h, blitMode, color, nMask);
+
+
+ if (!w || !h)
+ return;
+
+ switch (bpp) {
+ case 16:
+ dwGEMode = VIA_GEM_16bpp;
+ srcX = (srcBase & 0x1f) >> 1;
+ dstX = (dstBase & 0x1f) >> 1;
+ break;
+ case 32:
+ dwGEMode = VIA_GEM_32bpp;
+ srcX = (srcBase & 0x1f) >> 2;
+ dstX = (dstBase & 0x1f) >> 2;
+ break;
+ default:
+ return;
+ }
+
+ switch(blitMode) {
+ case VIA_BLIT_FILL:
+ cmd = VIA_GEC_BLT | VIA_GEC_FIXCOLOR_PAT | (VIA_BLIT_FILL << 24);
+ break;
+ case VIA_BLIT_COPY:
+ cmd = VIA_GEC_BLT | (VIA_BLIT_COPY << 24);
+ break;
+ default:
+ return;
+ }
+
+ BEGIN_RING(22);
+ SetReg2DAGP( VIA_REG_GEMODE, dwGEMode);
+ SetReg2DAGP( VIA_REG_FGCOLOR, color);
+ SetReg2DAGP( 0x2C, nMask);
+ SetReg2DAGP( VIA_REG_SRCBASE, (srcBase & ~0x1f) >> 3);
+ SetReg2DAGP( VIA_REG_DSTBASE, (dstBase & ~0x1f) >> 3);
+ SetReg2DAGP( VIA_REG_PITCH, VIA_PITCH_ENABLE |
+ (srcPitch >> 3) | ((dstPitch >> 3) << 16));
+ SetReg2DAGP( VIA_REG_SRCPOS, srcX);
+ SetReg2DAGP( VIA_REG_DSTPOS, dstX);
+ SetReg2DAGP( VIA_REG_DIMENSION, (((h - 1) << 16) | (w - 1)));
+ SetReg2DAGP( VIA_REG_GECMD, cmd);
+ SetReg2DAGP( 0x2C, 0x00000000);
+ ADVANCE_RING();
+}
+
+static void viaFillBuffer(struct via_context *vmesa,
+ struct via_buffer *buffer,
+ drm_clip_rect_t *pbox,
+ int nboxes,
+ GLuint pixel,
+ GLuint mask)
+{
+ GLuint bytePerPixel = buffer->bpp >> 3;
+ GLuint i;
+
+ for (i = 0; i < nboxes ; i++) {
+ int x = pbox[i].x1 - vmesa->drawX;
+ int y = pbox[i].y1 - vmesa->drawY;
+ int w = pbox[i].x2 - pbox[i].x1;
+ int h = pbox[i].y2 - pbox[i].y1;
+
+ int offset = (buffer->orig +
+ y * buffer->pitch +
+ x * bytePerPixel);
+
+ viaBlit(vmesa,
+ buffer->bpp,
+ offset, buffer->pitch,
+ offset, buffer->pitch,
+ w, h,
+ VIA_BLIT_FILL, pixel, mask);
+ }
+}
+
+
+
+static void viaClear(GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint cx, GLint cy, GLint cw, GLint ch)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable;
+ int flag = 0;
+ GLuint i = 0;
+ GLuint clear_depth_mask = 0xf << 28;
+ GLuint clear_depth = 0;
+
+ VIA_FLUSH_DMA(vmesa);
+
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
+ flag |= VIA_FRONT;
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
+ }
+
+ if (mask & BUFFER_BIT_BACK_LEFT) {
+ flag |= VIA_BACK;
+ mask &= ~BUFFER_BIT_BACK_LEFT;
+ }
+
+ if (mask & BUFFER_BIT_DEPTH) {
+ flag |= VIA_DEPTH;
+ clear_depth = (GLuint)(ctx->Depth.Clear * vmesa->ClearDepth);
+ clear_depth_mask &= ~vmesa->depth_clear_mask;
+ mask &= ~BUFFER_BIT_DEPTH;
+ }
+
+ if (mask & BUFFER_BIT_STENCIL) {
+ if (vmesa->have_hw_stencil) {
+ if (ctx->Stencil.WriteMask[0] == 0xff) {
+ flag |= VIA_DEPTH;
+ clear_depth &= ~0xff;
+ clear_depth |= (ctx->Stencil.Clear & 0xff);
+ clear_depth_mask &= ~vmesa->stencil_clear_mask;
+ mask &= ~BUFFER_BIT_STENCIL;
+ }
+ else {
+ if (VIA_DEBUG & DEBUG_2D)
+ fprintf(stderr, "Clear stencil writemask %x\n",
+ ctx->Stencil.WriteMask[0]);
+ }
+ }
+ }
+
+ /* 16bpp doesn't support masked clears */
+ if (vmesa->viaScreen->bytesPerPixel == 2 &&
+ vmesa->ClearMask & 0xf0000000) {
+ if (flag & VIA_FRONT)
+ mask |= BUFFER_BIT_FRONT_LEFT;
+ if (flag & VIA_BACK)
+ mask |= BUFFER_BIT_BACK_LEFT;
+ flag &= ~(VIA_FRONT | VIA_BACK);
+ }
+
+ if (flag) {
+ drm_clip_rect_t *boxes, *tmp_boxes = 0;
+ int nr = 0;
+
+ LOCK_HARDWARE(vmesa);
+
+ /* flip top to bottom */
+ cy = dPriv->h - cy - ch;
+ cx += vmesa->drawX + vmesa->drawXoff;
+ cy += vmesa->drawY;
+
+ if (!all) {
+ drm_clip_rect_t *b = vmesa->pClipRects;
+
+ boxes = tmp_boxes =
+ (drm_clip_rect_t *)malloc(vmesa->numClipRects *
+ sizeof(drm_clip_rect_t));
+ if (!boxes) {
+ UNLOCK_HARDWARE(vmesa);
+ return;
+ }
+
+ for (; i < vmesa->numClipRects; i++) {
+ GLint x = b[i].x1;
+ GLint y = b[i].y1;
+ GLint w = b[i].x2 - x;
+ GLint h = b[i].y2 - y;
+
+ 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) continue;
+ if (h <= 0) continue;
+
+ boxes[nr].x1 = x;
+ boxes[nr].y1 = y;
+ boxes[nr].x2 = x + w;
+ boxes[nr].y2 = y + h;
+ nr++;
+ }
+ }
+ else {
+ boxes = vmesa->pClipRects;
+ nr = vmesa->numClipRects;
+ }
+
+ if (flag & VIA_FRONT) {
+ viaFillBuffer(vmesa, &vmesa->front, boxes, nr, vmesa->ClearColor,
+ vmesa->ClearMask);
+ }
+
+ if (flag & VIA_BACK) {
+ viaFillBuffer(vmesa, &vmesa->back, boxes, nr, vmesa->ClearColor,
+ vmesa->ClearMask);
+ }
+
+ if (flag & VIA_DEPTH) {
+ viaFillBuffer(vmesa, &vmesa->depth, boxes, nr, clear_depth,
+ clear_depth_mask);
+ }
+
+ viaFlushDmaLocked(vmesa, VIA_NO_CLIPRECTS);
+ UNLOCK_HARDWARE(vmesa);
+
+ if (tmp_boxes)
+ free(tmp_boxes);
+ }
+
+ if (mask)
+ _swrast_Clear(ctx, mask, all, cx, cy, cw, ch);
+}
+
+
+
+
+static void viaDoSwapBuffers(struct via_context *vmesa,
+ drm_clip_rect_t *b,
+ GLuint nbox)
+{
+ GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3;
+ struct via_buffer *front = &vmesa->front;
+ struct via_buffer *back = &vmesa->back;
+ GLuint i;
+
+ for (i = 0; i < nbox; i++, b++) {
+ GLint x = b->x1 - vmesa->drawX;
+ GLint y = b->y1 - vmesa->drawY;
+ GLint w = b->x2 - b->x1;
+ GLint h = b->y2 - b->y1;
+
+ GLuint src = back->orig + y * back->pitch + x * bytePerPixel;
+ GLuint dest = front->orig + y * front->pitch + x * bytePerPixel;
+
+ viaBlit(vmesa,
+ bytePerPixel << 3,
+ src, back->pitch,
+ dest, front->pitch,
+ w, h,
+ VIA_BLIT_COPY, 0, 0);
+ }
+
+ viaFlushDmaLocked(vmesa, VIA_NO_CLIPRECTS); /* redundant */
+}
+
+
+static void viaEmitBreadcrumbLocked( struct via_context *vmesa )
+{
+ struct via_buffer *buffer = &vmesa->breadcrumb;
+ GLuint value = vmesa->lastBreadcrumbWrite + 1;
+
+ if (VIA_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s %d\n", __FUNCTION__, value);
+
+ assert(!vmesa->dmaLow);
+
+ viaBlit(vmesa,
+ buffer->bpp,
+ buffer->offset, buffer->pitch,
+ buffer->offset, buffer->pitch,
+ 1, 1,
+ VIA_BLIT_FILL, value, 0);
+
+ viaFlushDmaLocked(vmesa, VIA_NO_CLIPRECTS); /* often redundant */
+ vmesa->lastBreadcrumbWrite = value;
+}
+
+void viaEmitBreadcrumb( struct via_context *vmesa )
+{
+ LOCK_HARDWARE(vmesa);
+ if (vmesa->dmaLow)
+ viaFlushDmaLocked(vmesa, 0);
+
+ viaEmitBreadcrumbLocked( vmesa );
+ UNLOCK_HARDWARE(vmesa);
+}
+
+static GLboolean viaCheckIdle( struct via_context *vmesa )
+{
+ if ((vmesa->regEngineStatus[0] & 0xFFFEFFFF) == 0x00020000) {
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+}
+
+
+GLboolean viaCheckBreadcrumb( struct via_context *vmesa, GLuint value )
+{
+ GLuint *buf = (GLuint *)vmesa->breadcrumb.map;
+ vmesa->lastBreadcrumbRead = *buf;
+
+ if (VIA_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s %d < %d: %d\n", __FUNCTION__, value,
+ vmesa->lastBreadcrumbRead,
+ !VIA_GEQ_WRAP(value, vmesa->lastBreadcrumbRead));
+
+ return !VIA_GEQ_WRAP(value, vmesa->lastBreadcrumbRead);
+}
+
+static void viaWaitBreadcrumb( struct via_context *vmesa, GLuint value )
+{
+ if (VIA_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s %d\n", __FUNCTION__, value);
+
+ assert(!VIA_GEQ_WRAP(value, vmesa->lastBreadcrumbWrite));
+
+ while (!viaCheckBreadcrumb( vmesa, value )) {
+ viaSwapOutWork( vmesa );
+ via_release_pending_textures( vmesa );
+ }
+}
+
+
+void viaWaitIdle( struct via_context *vmesa, GLboolean light )
+{
+ VIA_FLUSH_DMA(vmesa);
+
+ if (VIA_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s lastDma %d lastBreadcrumbWrite %d\n",
+ __FUNCTION__, vmesa->lastDma, vmesa->lastBreadcrumbWrite);
+
+ /* Need to emit a new breadcrumb?
+ */
+ if (vmesa->lastDma == vmesa->lastBreadcrumbWrite) {
+ LOCK_HARDWARE(vmesa);
+ viaEmitBreadcrumbLocked( vmesa );
+ UNLOCK_HARDWARE(vmesa);
+ }
+
+ /* Need to wait?
+ */
+ if (VIA_GEQ_WRAP(vmesa->lastDma, vmesa->lastBreadcrumbRead))
+ viaWaitBreadcrumb( vmesa, vmesa->lastDma );
+
+ if (light) return;
+
+ LOCK_HARDWARE(vmesa);
+ while(!viaCheckIdle(vmesa))
+ ;
+ UNLOCK_HARDWARE(vmesa);
+ via_release_pending_textures(vmesa);
+}
+
+
+void viaWaitIdleLocked( struct via_context *vmesa, GLboolean light )
+{
+ if (vmesa->dmaLow)
+ viaFlushDmaLocked(vmesa, 0);
+
+ if (VIA_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s lastDma %d lastBreadcrumbWrite %d\n",
+ __FUNCTION__, vmesa->lastDma, vmesa->lastBreadcrumbWrite);
+
+ /* Need to emit a new breadcrumb?
+ */
+ if (vmesa->lastDma == vmesa->lastBreadcrumbWrite) {
+ viaEmitBreadcrumbLocked( vmesa );
+ }
+
+ /* Need to wait?
+ */
+ if (vmesa->lastDma >= vmesa->lastBreadcrumbRead)
+ viaWaitBreadcrumb( vmesa, vmesa->lastDma );
+
+ if (light) return;
+
+ while(!viaCheckIdle(vmesa))
+ ;
+
+ via_release_pending_textures(vmesa);
+}
+
+
+
+/* Wait for command stream to be processed *and* the next vblank to
+ * occur. Equivalent to calling WAIT_IDLE() and then WaitVBlank,
+ * except that WAIT_IDLE() will spin the CPU polling, while this is
+ * IRQ driven.
+ */
+static void viaWaitIdleVBlank( const __DRIdrawablePrivate *dPriv,
+ struct via_context *vmesa,
+ GLuint value )
+{
+ GLboolean missed_target;
+
+ VIA_FLUSH_DMA(vmesa);
+
+ if (!value)
+ return;
+
+ do {
+ if (value < vmesa->lastBreadcrumbRead ||
+ vmesa->thrashing)
+ viaSwapOutWork(vmesa);
+
+ driWaitForVBlank( dPriv, & vmesa->vbl_seq,
+ vmesa->vblank_flags, & missed_target );
+ if ( missed_target ) {
+ vmesa->swap_missed_count++;
+ (*dri_interface->getUST)( &vmesa->swap_missed_ust );
+ }
+ }
+ while (!viaCheckBreadcrumb(vmesa, value));
+
+ vmesa->thrashing = 0; /* reset flag on swap */
+ vmesa->swap_count++;
+ via_release_pending_textures( vmesa );
+}
+
+
+
+static void viaDoPageFlipLocked(struct via_context *vmesa, GLuint offset)
+{
+ RING_VARS;
+
+ if (VIA_DEBUG & DEBUG_2D)
+ fprintf(stderr, "%s %x\n", __FUNCTION__, offset);
+
+ if (!vmesa->nDoneFirstFlip) {
+ vmesa->nDoneFirstFlip = GL_TRUE;
+ BEGIN_RING(4);
+ OUT_RING(HALCYON_HEADER2);
+ OUT_RING(0x00fe0000);
+ OUT_RING(0x0000000e);
+ OUT_RING(0x0000000e);
+ ADVANCE_RING();
+ }
+
+ BEGIN_RING(4);
+ OUT_RING( HALCYON_HEADER2 );
+ OUT_RING( 0x00fe0000 );
+ OUT_RING((HC_SubA_HFBBasL << 24) | (offset & 0xFFFFF8) | 0x2);
+ OUT_RING((HC_SubA_HFBDrawFirst << 24) |
+ ((offset & 0xFF000000) >> 24) | 0x0100);
+ ADVANCE_RING();
+
+ vmesa->pfCurrentOffset = vmesa->sarea->pfCurrentOffset = offset;
+
+ viaFlushDmaLocked(vmesa, VIA_NO_CLIPRECTS); /* often redundant */
+}
+
+void viaResetPageFlippingLocked(struct via_context *vmesa)
+{
+ if (VIA_DEBUG & DEBUG_2D)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ viaDoPageFlipLocked( vmesa, 0 );
+
+ if (vmesa->front.offset != 0) {
+ struct via_buffer buffer_tmp;
+ memcpy(&buffer_tmp, &vmesa->back, sizeof(struct via_buffer));
+ memcpy(&vmesa->back, &vmesa->front, sizeof(struct via_buffer));
+ memcpy(&vmesa->front, &buffer_tmp, sizeof(struct via_buffer));
+ }
+
+ assert(vmesa->front.offset == 0);
+ vmesa->doPageFlip = vmesa->allowPageFlip = 0;
+}
+
+
+/*
+ * Copy the back buffer to the front buffer.
+ */
+void viaCopyBuffer(const __DRIdrawablePrivate *dPriv)
+{
+ struct via_context *vmesa =
+ (struct via_context *)dPriv->driContextPriv->driverPrivate;
+
+ if (VIA_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr,
+ "%s: lastSwap[1] %d lastSwap[0] %d lastWrite %d lastRead %d\n",
+ __FUNCTION__,
+ vmesa->lastSwap[1],
+ vmesa->lastSwap[0],
+ vmesa->lastBreadcrumbWrite,
+ vmesa->lastBreadcrumbRead);
+
+ VIA_FLUSH_DMA(vmesa);
+
+ if (vmesa->vblank_flags == VBLANK_FLAG_SYNC &&
+ vmesa->lastBreadcrumbWrite > 1)
+ viaWaitIdleVBlank(dPriv, vmesa, vmesa->lastBreadcrumbWrite-1);
+ else
+ viaWaitIdleVBlank(dPriv, vmesa, vmesa->lastSwap[1]);
+
+ LOCK_HARDWARE(vmesa);
+
+ /* Catch and cleanup situation where we were pageflipping but have
+ * stopped.
+ */
+ if (dPriv->numClipRects && vmesa->sarea->pfCurrentOffset != 0) {
+ viaResetPageFlippingLocked(vmesa);
+ UNLOCK_HARDWARE(vmesa);
+ return;
+ }
+
+ viaDoSwapBuffers(vmesa, dPriv->pClipRects, dPriv->numClipRects);
+ vmesa->lastSwap[1] = vmesa->lastSwap[0];
+ vmesa->lastSwap[0] = vmesa->lastBreadcrumbWrite;
+ viaEmitBreadcrumbLocked(vmesa);
+ UNLOCK_HARDWARE(vmesa);
+
+ (*dri_interface->getUST)( &vmesa->swap_ust );
+}
+
+
+void viaPageFlip(const __DRIdrawablePrivate *dPriv)
+{
+ struct via_context *vmesa =
+ (struct via_context *)dPriv->driContextPriv->driverPrivate;
+ struct via_buffer buffer_tmp;
+
+ VIA_FLUSH_DMA(vmesa);
+ if (vmesa->vblank_flags == VBLANK_FLAG_SYNC &&
+ vmesa->lastBreadcrumbWrite > 1)
+ viaWaitIdleVBlank(dPriv, vmesa, vmesa->lastBreadcrumbWrite - 1);
+ else
+ viaWaitIdleVBlank(dPriv, vmesa, vmesa->lastSwap[0]);
+
+ LOCK_HARDWARE(vmesa);
+ viaDoPageFlipLocked(vmesa, vmesa->back.offset);
+ vmesa->lastSwap[1] = vmesa->lastSwap[0];
+ vmesa->lastSwap[0] = vmesa->lastBreadcrumbWrite;
+ viaEmitBreadcrumbLocked(vmesa);
+ UNLOCK_HARDWARE(vmesa);
+
+ (*dri_interface->getUST)( &vmesa->swap_ust );
+
+
+ /* KW: FIXME: When buffers are freed, could free frontbuffer by
+ * accident:
+ */
+ memcpy(&buffer_tmp, &vmesa->back, sizeof(struct via_buffer));
+ memcpy(&vmesa->back, &vmesa->front, sizeof(struct via_buffer));
+ memcpy(&vmesa->front, &buffer_tmp, sizeof(struct via_buffer));
+}
+
+
+
+
+#define VIA_CMDBUF_MAX_LAG 50000
+
+static int fire_buffer(struct via_context *vmesa)
+{
+ drm_via_cmdbuffer_t bufI;
+ int ret;
+
+ bufI.buf = (char *)vmesa->dma;
+ bufI.size = vmesa->dmaLow;
+
+ if (vmesa->useAgp) {
+ drm_via_cmdbuf_size_t bSiz;
+
+ /* Do the CMDBUF_SIZE ioctl:
+ */
+ bSiz.func = VIA_CMDBUF_LAG;
+ bSiz.wait = 1;
+ bSiz.size = VIA_CMDBUF_MAX_LAG;
+ do {
+ ret = drmCommandWriteRead(vmesa->driFd, DRM_VIA_CMDBUF_SIZE,
+ &bSiz, sizeof(bSiz));
+ } while (ret == -EAGAIN);
+ if (ret) {
+ UNLOCK_HARDWARE(vmesa);
+ fprintf(stderr, "%s: DRM_VIA_CMDBUF_SIZE returned %d\n",
+ __FUNCTION__, ret);
+ abort();
+ return ret;
+ }
+
+ /* Actually fire the buffer:
+ */
+ do {
+ ret = drmCommandWrite(vmesa->driFd, DRM_VIA_CMDBUFFER,
+ &bufI, sizeof(bufI));
+ } while (ret == -EAGAIN);
+ if (ret) {
+ UNLOCK_HARDWARE(vmesa);
+ fprintf(stderr, "%s: DRM_VIA_CMDBUFFER returned %d\n",
+ __FUNCTION__, ret);
+ abort();
+ /* If this fails, the original code fell back to the PCI path.
+ */
+ }
+ else
+ return 0;
+
+ /* Fall through to PCI handling?!?
+ */
+ viaWaitIdleLocked(vmesa, GL_FALSE);
+ }
+
+ ret = drmCommandWrite(vmesa->driFd, DRM_VIA_PCICMD, &bufI, sizeof(bufI));
+ if (ret) {
+ UNLOCK_HARDWARE(vmesa);
+ dump_dma(vmesa);
+ fprintf(stderr, "%s: DRM_VIA_PCICMD returned %d\n", __FUNCTION__, ret);
+ abort();
+ }
+
+ return ret;
+}
+
+
+/* Inserts the surface addresss and active cliprects one at a time
+ * into the head of the DMA buffer being flushed. Fires the buffer
+ * for each cliprect.
+ */
+static void via_emit_cliprect(struct via_context *vmesa,
+ drm_clip_rect_t *b)
+{
+ struct via_buffer *buffer = vmesa->drawBuffer;
+ GLuint *vb = (GLuint *)(vmesa->dma + vmesa->dmaCliprectAddr);
+
+ GLuint format = (vmesa->viaScreen->bitsPerPixel == 0x20
+ ? HC_HDBFM_ARGB8888
+ : HC_HDBFM_RGB565);
+
+ GLuint pitch = buffer->pitch;
+ GLuint offset = buffer->orig;
+
+ if (0)
+ fprintf(stderr, "emit cliprect for box %d,%d %d,%d\n",
+ b->x1, b->y1, b->x2, b->y2);
+
+ vb[0] = HC_HEADER2;
+ vb[1] = (HC_ParaType_NotTex << 16);
+
+ if (vmesa->driDrawable->w == 0 || vmesa->driDrawable->h == 0) {
+ vb[2] = (HC_SubA_HClipTB << 24) | 0x0;
+ vb[3] = (HC_SubA_HClipLR << 24) | 0x0;
+ }
+ else {
+ vb[2] = (HC_SubA_HClipTB << 24) | (b->y1 << 12) | b->y2;
+ vb[3] = (HC_SubA_HClipLR << 24) | (b->x1 << 12) | b->x2;
+ }
+
+ vb[4] = (HC_SubA_HDBBasL << 24) | (offset & 0xFFFFFF);
+ vb[5] = (HC_SubA_HDBBasH << 24) | ((offset & 0xFF000000) >> 24);
+
+ vb[6] = (HC_SubA_HSPXYOS << 24) | ((31-vmesa->drawXoff) << HC_HSPXOS_SHIFT);
+ vb[7] = (HC_SubA_HDBFM << 24) | HC_HDBLoc_Local | format | pitch;
+}
+
+
+
+static int intersect_rect(drm_clip_rect_t *out,
+ drm_clip_rect_t *a,
+ drm_clip_rect_t *b)
+{
+ *out = *a;
+
+ if (0)
+ fprintf(stderr, "intersect %d,%d %d,%d and %d,%d %d,%d\n",
+ a->x1, a->y1, a->x2, a->y2,
+ b->x1, b->y1, b->x2, b->y2);
+
+ if (b->x1 > out->x1) out->x1 = b->x1;
+ if (b->x2 < out->x2) out->x2 = b->x2;
+ if (out->x1 >= out->x2) return 0;
+
+ if (b->y1 > out->y1) out->y1 = b->y1;
+ if (b->y2 < out->y2) out->y2 = b->y2;
+ if (out->y1 >= out->y2) return 0;
+
+ return 1;
+}
+
+void viaFlushDmaLocked(struct via_context *vmesa, GLuint flags)
+{
+ int i;
+ RING_VARS;
+
+ if (VIA_DEBUG & (DEBUG_IOCTL|DEBUG_DMA))
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (*(GLuint *)vmesa->driHwLock != (DRM_LOCK_HELD|vmesa->hHWContext) &&
+ *(GLuint *)vmesa->driHwLock !=
+ (DRM_LOCK_HELD|DRM_LOCK_CONT|vmesa->hHWContext)) {
+ fprintf(stderr, "%s called without lock held\n", __FUNCTION__);
+ abort();
+ }
+
+ if (vmesa->dmaLow == 0) {
+ return;
+ }
+
+ assert(vmesa->dmaLastPrim == 0);
+
+ /* viaFinishPrimitive can add up to 8 bytes beyond VIA_DMA_HIGHWATER:
+ */
+ if (vmesa->dmaLow > VIA_DMA_HIGHWATER + 8) {
+ fprintf(stderr, "buffer overflow in Flush Prims = %d\n",vmesa->dmaLow);
+ abort();
+ }
+
+ switch (vmesa->dmaLow & 0x1F) {
+ case 8:
+ BEGIN_RING_NOCHECK( 6 );
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( (HC_ParaType_NotTex << 16) );
+ OUT_RING( HC_DUMMY );
+ OUT_RING( HC_DUMMY );
+ OUT_RING( HC_DUMMY );
+ OUT_RING( HC_DUMMY );
+ ADVANCE_RING();
+ break;
+ case 16:
+ BEGIN_RING_NOCHECK( 4 );
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( (HC_ParaType_NotTex << 16) );
+ OUT_RING( HC_DUMMY );
+ OUT_RING( HC_DUMMY );
+ ADVANCE_RING();
+ break;
+ case 24:
+ BEGIN_RING_NOCHECK( 10 );
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( (HC_ParaType_NotTex << 16) );
+ OUT_RING( HC_DUMMY );
+ OUT_RING( HC_DUMMY );
+ OUT_RING( HC_DUMMY );
+ OUT_RING( HC_DUMMY );
+ OUT_RING( HC_DUMMY );
+ OUT_RING( HC_DUMMY );
+ OUT_RING( HC_DUMMY );
+ OUT_RING( HC_DUMMY );
+ ADVANCE_RING();
+ break;
+ case 0:
+ break;
+ default:
+ if (VIA_DEBUG & DEBUG_IOCTL)
+ fprintf(stderr, "%s: unaligned value for vmesa->dmaLow: %x\n",
+ __FUNCTION__, vmesa->dmaLow);
+ }
+
+ vmesa->lastDma = vmesa->lastBreadcrumbWrite;
+
+ if (VIA_DEBUG & DEBUG_DMA)
+ dump_dma( vmesa );
+
+ if (flags & VIA_NO_CLIPRECTS) {
+ if (0) fprintf(stderr, "%s VIA_NO_CLIPRECTS\n", __FUNCTION__);
+ assert(vmesa->dmaCliprectAddr == ~0);
+ fire_buffer( vmesa );
+ }
+ else if (vmesa->dmaCliprectAddr == ~0) {
+ /* Contains only state. Could just dump the packet?
+ */
+ if (0) fprintf(stderr, "%s: no dmaCliprectAddr\n", __FUNCTION__);
+ if (0) fire_buffer( vmesa );
+ }
+ else if (vmesa->numClipRects) {
+ drm_clip_rect_t *pbox = vmesa->pClipRects;
+
+ for (i = 0; i < vmesa->numClipRects; i++) {
+ drm_clip_rect_t b;
+
+ b.x1 = pbox[i].x1 - (vmesa->drawX + vmesa->drawXoff);
+ b.x2 = pbox[i].x2 - (vmesa->drawX + vmesa->drawXoff);
+ b.y1 = pbox[i].y1 - vmesa->drawY;
+ b.y2 = pbox[i].y2 - vmesa->drawY;
+
+ if (vmesa->scissor &&
+ !intersect_rect(&b, &b, &vmesa->scissorRect))
+ continue;
+
+ b.x1 += vmesa->drawXoff;
+ b.x2 += vmesa->drawXoff;
+
+ via_emit_cliprect(vmesa, &b);
+
+ if (fire_buffer(vmesa) != 0) {
+ dump_dma( vmesa );
+ goto done;
+ }
+ }
+ } else {
+ if (0) fprintf(stderr, "%s: no cliprects\n", __FUNCTION__);
+ UNLOCK_HARDWARE(vmesa);
+ sched_yield();
+ LOCK_HARDWARE(vmesa);
+ }
+
+ done:
+ /* Reset vmesa vars:
+ */
+ vmesa->dmaLow = 0;
+ vmesa->dmaCliprectAddr = ~0;
+ vmesa->newEmitState = ~0;
+}
+
+void viaWrapPrimitive( struct via_context *vmesa )
+{
+ GLenum renderPrimitive = vmesa->renderPrimitive;
+ GLenum hwPrimitive = vmesa->hwPrimitive;
+
+ if (VIA_DEBUG & DEBUG_PRIMS) fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (vmesa->dmaLastPrim)
+ viaFinishPrimitive( vmesa );
+
+ viaFlushDma(vmesa);
+
+ if (renderPrimitive != GL_POLYGON + 1)
+ viaRasterPrimitive( vmesa->glCtx,
+ renderPrimitive,
+ hwPrimitive );
+
+}
+
+void viaFlushDma(struct via_context *vmesa)
+{
+ if (vmesa->dmaLow) {
+ assert(!vmesa->dmaLastPrim);
+
+ LOCK_HARDWARE(vmesa);
+ viaFlushDmaLocked(vmesa, 0);
+ UNLOCK_HARDWARE(vmesa);
+ }
+}
+
+static void viaFlush(GLcontext *ctx)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ VIA_FLUSH_DMA(vmesa);
+}
+
+static void viaFinish(GLcontext *ctx)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ VIA_FLUSH_DMA(vmesa);
+ viaWaitIdle(vmesa, GL_FALSE);
+}
+
+static void viaClearStencil(GLcontext *ctx, int s)
+{
+ return;
+}
+
+void viaInitIoctlFuncs(GLcontext *ctx)
+{
+ ctx->Driver.Flush = viaFlush;
+ ctx->Driver.Clear = viaClear;
+ ctx->Driver.Finish = viaFinish;
+ ctx->Driver.ClearStencil = viaClearStencil;
+}
+
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_ioctl.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_ioctl.h
new file mode 100644
index 000000000..d5d95aa8f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_ioctl.h
@@ -0,0 +1,135 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+#ifndef _VIAIOCTL_H
+#define _VIAIOCTL_H
+
+#include "via_context.h"
+
+
+void viaFinishPrimitive(struct via_context *vmesa);
+void viaFlushDma(struct via_context *vmesa);
+void viaFlushDmaLocked(struct via_context *vmesa, GLuint flags);
+
+void viaInitIoctlFuncs(GLcontext *ctx);
+void viaCopyBuffer(const __DRIdrawablePrivate *dpriv);
+void viaPageFlip(const __DRIdrawablePrivate *dpriv);
+void viaCheckDma(struct via_context *vmesa, GLuint bytes);
+void viaResetPageFlippingLocked(struct via_context *vmesa);
+void viaWaitIdle(struct via_context *vmesa, GLboolean light);
+void viaWaitIdleLocked(struct via_context *vmesa, GLboolean light);
+
+GLboolean viaCheckBreadcrumb( struct via_context *vmesa, GLuint value );
+void viaEmitBreadcrumb( struct via_context *vmesa );
+
+
+#define VIA_FINISH_PRIM(vmesa) do { \
+ if (vmesa->dmaLastPrim) \
+ viaFinishPrimitive( vmesa ); \
+} while (0)
+
+#define VIA_FLUSH_DMA(vmesa) do { \
+ VIA_FINISH_PRIM(vmesa); \
+ if (vmesa->dmaLow) \
+ viaFlushDma(vmesa); \
+} while (0)
+
+
+void viaWrapPrimitive( struct via_context *vmesa );
+
+static __inline__ GLuint *viaAllocDma(struct via_context *vmesa, int bytes)
+{
+ if (vmesa->dmaLow + bytes > VIA_DMA_HIGHWATER) {
+ viaFlushDma(vmesa);
+ }
+
+ {
+ GLuint *start = (GLuint *)(vmesa->dma + vmesa->dmaLow);
+ vmesa->dmaLow += bytes;
+ return start;
+ }
+}
+
+
+static GLuint __inline__ *viaExtendPrimitive(struct via_context *vmesa, int bytes)
+{
+ if (vmesa->dmaLow + bytes > VIA_DMA_HIGHWATER) {
+ viaWrapPrimitive(vmesa);
+ }
+
+ {
+ GLuint *start = (GLuint *)(vmesa->dma + vmesa->dmaLow);
+ vmesa->dmaLow += bytes;
+ return start;
+ }
+}
+
+
+
+
+#define RING_VARS GLuint *_vb = 0, _nr, _x;
+
+#define BEGIN_RING(n) do { \
+ if (_vb != 0) abort(); \
+ _vb = viaAllocDma(vmesa, (n) * sizeof(GLuint)); \
+ _nr = (n); \
+ _x = 0; \
+} while (0)
+
+#define BEGIN_RING_NOCHECK(n) do { \
+ if (_vb != 0) abort(); \
+ _vb = (GLuint *)(vmesa->dma + vmesa->dmaLow); \
+ vmesa->dmaLow += (n) * sizeof(GLuint); \
+ _nr = (n); \
+ _x = 0; \
+} while (0)
+
+#define OUT_RING(n) _vb[_x++] = (n)
+
+#define ADVANCE_RING() do { \
+ if (_x != _nr) abort(); \
+ _vb = 0; \
+} while (0)
+
+#define ADVANCE_RING_VARIABLE() do { \
+ if (_x > _nr) abort(); \
+ vmesa->dmaLow -= (_nr - _x) * sizeof(GLuint); \
+ _vb = 0; \
+} while (0)
+
+
+#define QWORD_PAD_RING() do { \
+ if (vmesa->dmaLow & 0x4) { \
+ BEGIN_RING(1); \
+ OUT_RING(HC_DUMMY); \
+ ADVANCE_RING(); \
+ } \
+} while (0)
+
+#define VIA_GEQ_WRAP(left, right) \
+ (((left) - (right)) < ( 1 << 23))
+
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_memcpy.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_memcpy.c
new file mode 100644
index 000000000..d7b05bcaa
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_memcpy.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2004 Thomas Hellstrom, All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE CODE SUPPLIER(S) 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.
+ */
+
+/* Thomas' orginal gutted for mesa by Keith Whitwell
+ */
+
+#include "via_tex.h"
+
+#if defined( USE_SSE_ASM )
+
+#define SSE_PREFETCH " prefetchnta "
+#define FENCE __asm__ __volatile__ ("sfence":::"memory");
+
+
+#define PREFETCH1(arch_prefetch,from) \
+ __asm__ __volatile__ ( \
+ "1: " arch_prefetch "(%0)\n" \
+ arch_prefetch "32(%0)\n" \
+ arch_prefetch "64(%0)\n" \
+ arch_prefetch "96(%0)\n" \
+ arch_prefetch "128(%0)\n" \
+ arch_prefetch "160(%0)\n" \
+ arch_prefetch "192(%0)\n" \
+ arch_prefetch "256(%0)\n" \
+ arch_prefetch "288(%0)\n" \
+ "2:\n" \
+ : : "r" (from) );
+
+
+
+#define small_memcpy(to,from,n) \
+ { \
+ __asm__ __volatile__( \
+ "movl %2,%%ecx\n\t" \
+ "sarl $2,%%ecx\n\t" \
+ "rep ; movsl\n\t" \
+ "testb $2,%b2\n\t" \
+ "je 1f\n\t" \
+ "movsw\n" \
+ "1:\ttestb $1,%b2\n\t" \
+ "je 2f\n\t" \
+ "movsb\n" \
+ "2:" \
+ :"=&D" (to), "=&S" (from) \
+ :"q" (n),"0" ((long) to),"1" ((long) from) \
+ : "%ecx","memory"); \
+ }
+
+
+#define SSE_CPY(prefetch,from,to,dummy,lcnt) \
+ if ((unsigned long) from & 15) { \
+ __asm__ __volatile__ ( \
+ "1:\n" \
+ prefetch "320(%1)\n" \
+ " movups (%1), %%xmm0\n" \
+ " movups 16(%1), %%xmm1\n" \
+ " movntps %%xmm0, (%0)\n" \
+ " movntps %%xmm1, 16(%0)\n" \
+ prefetch "352(%1)\n" \
+ " movups 32(%1), %%xmm2\n" \
+ " movups 48(%1), %%xmm3\n" \
+ " movntps %%xmm2, 32(%0)\n" \
+ " movntps %%xmm3, 48(%0)\n" \
+ " addl $64,%0\n" \
+ " addl $64,%1\n" \
+ " decl %2\n" \
+ " jne 1b\n" \
+ :"=&D"(to), "=&S"(from), "=&r"(dummy) \
+ :"0" (to), "1" (from), "2" (lcnt): "memory"); \
+ } else { \
+ __asm__ __volatile__ ( \
+ "2:\n" \
+ prefetch "320(%1)\n" \
+ " movaps (%1), %%xmm0\n" \
+ " movaps 16(%1), %%xmm1\n" \
+ " movntps %%xmm0, (%0)\n" \
+ " movntps %%xmm1, 16(%0)\n" \
+ prefetch "352(%1)\n" \
+ " movaps 32(%1), %%xmm2\n" \
+ " movaps 48(%1), %%xmm3\n" \
+ " movntps %%xmm2, 32(%0)\n" \
+ " movntps %%xmm3, 48(%0)\n" \
+ " addl $64,%0\n" \
+ " addl $64,%1\n" \
+ " decl %2\n" \
+ " jne 2b\n" \
+ :"=&D"(to), "=&S"(from), "=&r"(dummy) \
+ :"0" (to), "1" (from), "2" (lcnt): "memory"); \
+ }
+
+
+
+/*
+ */
+void via_sse_memcpy(void *to,
+ const void *from,
+ size_t sz)
+
+{
+ int dummy;
+ int lcnt = sz >> 6;
+ int rest = sz & 63;
+
+ PREFETCH1(SSE_PREFETCH,from);
+
+ if (lcnt > 5) {
+ lcnt -= 5;
+ SSE_CPY(SSE_PREFETCH,from,to,dummy,lcnt);
+ lcnt = 5;
+ }
+ if (lcnt) {
+ SSE_CPY("#",from,to,dummy,lcnt);
+ }
+ if (rest) small_memcpy(to, from, rest);
+ FENCE;
+}
+
+#endif /* defined( USE_SSE_ASM ) */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_render.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_render.c
new file mode 100644
index 000000000..387473ef5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_render.c
@@ -0,0 +1,131 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * dma buffers. Use strip/fan hardware acceleration where possible.
+ *
+ */
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "mtypes.h"
+
+#include "tnl/t_context.h"
+
+#include "via_context.h"
+#include "via_tris.h"
+#include "via_state.h"
+#include "via_ioctl.h"
+
+/*
+ * Render unclipped vertex buffers by emitting vertices directly to
+ * dma buffers. Use strip/fan hardware primitives where possible.
+ * Try to simulate missing primitives with indexed vertices.
+ */
+#define HAVE_POINTS 1
+#define HAVE_LINES 1
+#define HAVE_LINE_STRIPS 1
+#define HAVE_LINE_LOOP 1
+#define HAVE_TRIANGLES 1
+#define HAVE_TRI_STRIPS 1
+#define HAVE_TRI_STRIP_1 0
+#define HAVE_TRI_FANS 1
+#define HAVE_POLYGONS 1
+#define HAVE_QUADS 0
+#define HAVE_QUAD_STRIPS 0
+
+#define HAVE_ELTS 0
+
+#define LOCAL_VARS struct via_context *vmesa = VIA_CONTEXT(ctx)
+#define INIT(prim) do { \
+ viaRasterPrimitive(ctx, prim, prim); \
+} while (0)
+#define GET_CURRENT_VB_MAX_VERTS() \
+ ((VIA_DMA_BUF_SZ - (512 + (int)vmesa->dmaLow)) / (vmesa->vertexSize * 4))
+#define GET_SUBSEQUENT_VB_MAX_VERTS() \
+ (VIA_DMA_BUF_SZ - 512) / (vmesa->vertexSize * 4)
+
+#define ALLOC_VERTS( nr ) \
+ viaExtendPrimitive( vmesa, (nr) * vmesa->vertexSize * 4)
+
+#define EMIT_VERTS(ctx, j, nr, buf) \
+ _tnl_emit_vertices_to_buffer(ctx, j, (j)+(nr), buf )
+
+#define FLUSH() VIA_FINISH_PRIM( vmesa )
+
+#define TAG(x) via_fast##x
+#include "tnl_dd/t_dd_dmatmp.h"
+#undef TAG
+#undef LOCAL_VARS
+#undef INIT
+
+/**********************************************************************/
+/* Fast Render pipeline stage */
+/**********************************************************************/
+static GLboolean via_run_fastrender(GLcontext *ctx,
+ struct tnl_pipeline_stage *stage)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint i;
+
+
+ tnl->Driver.Render.Start(ctx);
+
+ if (VB->ClipOrMask ||
+ vmesa->renderIndex != 0 ||
+ !via_fastvalidate_render( ctx, VB )) {
+ tnl->Driver.Render.Finish(ctx);
+ return GL_TRUE;
+ }
+
+ tnl->clipspace.new_inputs |= VERT_BIT_POS;
+
+ for (i = 0; i < VB->PrimitiveCount; ++i) {
+ GLuint mode = VB->Primitive[i].mode;
+ GLuint start = VB->Primitive[i].start;
+ GLuint length = VB->Primitive[i].count;
+ if (length)
+ via_fastrender_tab_verts[mode & PRIM_MODE_MASK](ctx, start, start+length, mode);
+ }
+
+ tnl->Driver.Render.Finish(ctx);
+
+ return GL_FALSE; /* finished the pipe */
+}
+
+const struct tnl_pipeline_stage _via_fastrender_stage =
+{
+ "via fast render",
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ via_run_fastrender /* run */
+};
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_screen.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_screen.c
new file mode 100644
index 000000000..267eeffc8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_screen.c
@@ -0,0 +1,491 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+#include <stdio.h>
+
+#include "utils.h"
+#include "dri_util.h"
+#include "glheader.h"
+#include "context.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+#include "matrix.h"
+#include "simple_list.h"
+#include "vblank.h"
+
+#include "via_state.h"
+#include "via_tex.h"
+#include "via_span.h"
+#include "via_tris.h"
+#include "via_ioctl.h"
+#include "via_screen.h"
+#include "via_fb.h"
+#include "via_dri.h"
+
+#include "GL/internal/dri_interface.h"
+
+/* Radeon configuration
+ */
+#include "xmlpool.h"
+
+const char __driConfigOptions[] =
+DRI_CONF_BEGIN
+ DRI_CONF_SECTION_PERFORMANCE
+ DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
+ DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_0)
+ DRI_CONF_SECTION_END
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_NO_RAST(false)
+ DRI_CONF_SECTION_END
+DRI_CONF_END;
+static const GLuint __driNConfigOptions = 3;
+
+extern const struct dri_extension card_extensions[];
+
+static int getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo );
+
+static drmBufMapPtr via_create_empty_buffers(void)
+{
+ drmBufMapPtr retval;
+
+ retval = (drmBufMapPtr)MALLOC(sizeof(drmBufMap));
+ if (retval == NULL) return NULL;
+ memset(retval, 0, sizeof(drmBufMap));
+
+ retval->list = (drmBufPtr)MALLOC(sizeof(drmBuf) * VIA_DMA_BUF_NR);
+ if (retval->list == NULL) {
+ FREE(retval);
+ return NULL;
+ }
+ memset(retval->list, 0, sizeof(drmBuf) * VIA_DMA_BUF_NR);
+ return retval;
+}
+
+static void via_free_empty_buffers( drmBufMapPtr bufs )
+{
+ if (bufs && bufs->list)
+ FREE(bufs->list);
+
+ if (bufs)
+ FREE(bufs);
+}
+
+
+static GLboolean
+viaInitDriver(__DRIscreenPrivate *sPriv)
+{
+ viaScreenPrivate *viaScreen;
+ VIADRIPtr gDRIPriv = (VIADRIPtr)sPriv->pDevPriv;
+ PFNGLXSCRENABLEEXTENSIONPROC glx_enable_extension =
+ (PFNGLXSCRENABLEEXTENSIONPROC) (*dri_interface->getProcAddress("glxEnableExtension"));
+ void * const psc = sPriv->psc->screenConfigs;
+
+ if (sPriv->devPrivSize != sizeof(VIADRIRec)) {
+ fprintf(stderr,"\nERROR! sizeof(VIADRIRec) does not match passed size from device driver\n");
+ return GL_FALSE;
+ }
+
+ /* Allocate the private area */
+ viaScreen = (viaScreenPrivate *) CALLOC(sizeof(viaScreenPrivate));
+ if (!viaScreen) {
+ __driUtilMessage("viaInitDriver: alloc viaScreenPrivate struct failed");
+ return GL_FALSE;
+ }
+
+ /* parse information in __driConfigOptions */
+ driParseOptionInfo (&viaScreen->optionCache,
+ __driConfigOptions, __driNConfigOptions);
+
+
+ viaScreen->driScrnPriv = sPriv;
+ sPriv->private = (void *)viaScreen;
+
+ viaScreen->deviceID = gDRIPriv->deviceID;
+ viaScreen->width = gDRIPriv->width;
+ viaScreen->height = gDRIPriv->height;
+ viaScreen->mem = gDRIPriv->mem;
+ viaScreen->bitsPerPixel = gDRIPriv->bytesPerPixel * 8;
+ viaScreen->bytesPerPixel = gDRIPriv->bytesPerPixel;
+ viaScreen->fbOffset = 0;
+ viaScreen->fbSize = gDRIPriv->fbSize;
+ viaScreen->irqEnabled = gDRIPriv->irqEnabled;
+ viaScreen->irqEnabled = 1;
+
+ if (VIA_DEBUG & DEBUG_DRI) {
+ fprintf(stderr, "deviceID = %08x\n", viaScreen->deviceID);
+ fprintf(stderr, "width = %08x\n", viaScreen->width);
+ fprintf(stderr, "height = %08x\n", viaScreen->height);
+ fprintf(stderr, "cpp = %08x\n", viaScreen->cpp);
+ fprintf(stderr, "fbOffset = %08x\n", viaScreen->fbOffset);
+ }
+
+ viaScreen->bufs = via_create_empty_buffers();
+ if (viaScreen->bufs == NULL) {
+ __driUtilMessage("viaInitDriver: via_create_empty_buffers() failed");
+ FREE(viaScreen);
+ return GL_FALSE;
+ }
+
+ if (drmMap(sPriv->fd,
+ gDRIPriv->regs.handle,
+ gDRIPriv->regs.size,
+ (drmAddress *)&viaScreen->reg) != 0) {
+ FREE(viaScreen);
+ sPriv->private = NULL;
+ __driUtilMessage("viaInitDriver: drmMap regs failed");
+ return GL_FALSE;
+ }
+
+ if (gDRIPriv->agp.size) {
+ if (drmMap(sPriv->fd,
+ gDRIPriv->agp.handle,
+ gDRIPriv->agp.size,
+ (drmAddress *)&viaScreen->agpLinearStart) != 0) {
+ drmUnmap(viaScreen->reg, gDRIPriv->regs.size);
+ FREE(viaScreen);
+ sPriv->private = NULL;
+ __driUtilMessage("viaInitDriver: drmMap agp failed");
+ return GL_FALSE;
+ }
+
+ /*
+ * FIXME: This is an invalid assumption that works until handle is
+ * changed to mean something else than the 32-bit physical AGP address.
+ */
+
+ viaScreen->agpBase = gDRIPriv->agp.handle;
+ } else
+ viaScreen->agpLinearStart = 0;
+
+ viaScreen->sareaPrivOffset = gDRIPriv->sarea_priv_offset;
+
+ if ( glx_enable_extension != NULL ) {
+ if ( viaScreen->irqEnabled ) {
+ (*glx_enable_extension)( psc, "GLX_SGI_swap_control" );
+ (*glx_enable_extension)( psc, "GLX_SGI_video_sync" );
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_control" );
+ }
+
+ (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
+ }
+
+ return GL_TRUE;
+}
+
+static void
+viaDestroyScreen(__DRIscreenPrivate *sPriv)
+{
+ viaScreenPrivate *viaScreen = (viaScreenPrivate *)sPriv->private;
+ VIADRIPtr gDRIPriv = (VIADRIPtr)sPriv->pDevPriv;
+
+ drmUnmap(viaScreen->reg, gDRIPriv->regs.size);
+ if (gDRIPriv->agp.size)
+ drmUnmap(viaScreen->agpLinearStart, gDRIPriv->agp.size);
+
+ via_free_empty_buffers(viaScreen->bufs);
+
+ FREE(viaScreen);
+ sPriv->private = NULL;
+}
+
+
+static GLboolean
+viaCreateBuffer(__DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap)
+{
+ viaScreenPrivate *screen = (viaScreenPrivate *) driScrnPriv->private;
+
+ GLboolean swStencil = (mesaVis->stencilBits > 0 &&
+ mesaVis->depthBits != 24);
+
+
+ if (isPixmap) {
+ /* KW: This needs work, disabled for now:
+ */
+#if 0
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE /* s/w alpha planes */);
+
+ return (driDrawPriv->driverPrivate != NULL);
+#endif
+ return GL_FALSE;
+ }
+ else {
+#if 0
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer(mesaVis,
+ GL_FALSE, /* software depth buffer? */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE /* s/w alpha planes */);
+#else
+ struct gl_framebuffer *fb = _mesa_create_framebuffer(mesaVis);
+
+ /* XXX check/fix the offset/pitch parameters! */
+ {
+ driRenderbuffer *frontRb
+ = driNewRenderbuffer(GL_RGBA, screen->bytesPerPixel,
+ 0, screen->width);
+ viaSetSpanFunctions(frontRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &frontRb->Base);
+ }
+
+ if (mesaVis->doubleBufferMode) {
+ driRenderbuffer *backRb
+ = driNewRenderbuffer(GL_RGBA, screen->bytesPerPixel,
+ 0, screen->width);
+ viaSetSpanFunctions(backRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &backRb->Base);
+ }
+
+ if (mesaVis->depthBits == 16) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT16, screen->bytesPerPixel,
+ 0, screen->width);
+ viaSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 24) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT24, screen->bytesPerPixel,
+ 0, screen->width);
+ viaSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+ else if (mesaVis->depthBits == 32) {
+ driRenderbuffer *depthRb
+ = driNewRenderbuffer(GL_DEPTH_COMPONENT32, screen->bytesPerPixel,
+ 0, screen->width);
+ viaSetSpanFunctions(depthRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
+ }
+
+ if (mesaVis->stencilBits > 0 && !swStencil) {
+ driRenderbuffer *stencilRb
+ = driNewRenderbuffer(GL_STENCIL_INDEX8_EXT, screen->bytesPerPixel,
+ 0, screen->width);
+ viaSetSpanFunctions(stencilRb, mesaVis);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &stencilRb->Base);
+ }
+
+ _mesa_add_soft_renderbuffers(fb,
+ GL_FALSE, /* color */
+ GL_FALSE, /* depth */
+ swStencil,
+ mesaVis->accumRedBits > 0,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */);
+ driDrawPriv->driverPrivate = (void *) fb;
+#endif
+ return (driDrawPriv->driverPrivate != NULL);
+ }
+}
+
+
+static void
+viaDestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *)(driDrawPriv->driverPrivate));
+}
+
+
+
+static struct __DriverAPIRec viaAPI = {
+ .InitDriver = viaInitDriver,
+ .DestroyScreen = viaDestroyScreen,
+ .CreateContext = viaCreateContext,
+ .DestroyContext = viaDestroyContext,
+ .CreateBuffer = viaCreateBuffer,
+ .DestroyBuffer = viaDestroyBuffer,
+ .SwapBuffers = viaSwapBuffers,
+ .MakeCurrent = viaMakeCurrent,
+ .UnbindContext = viaUnbindContext,
+ .GetSwapInfo = getSwapInfo,
+ .GetMSC = driGetMSC32,
+ .WaitForMSC = driWaitForMSC32,
+ .WaitForSBC = NULL,
+ .SwapBuffersMSC = NULL
+};
+
+
+static __GLcontextModes *
+viaFillInModes( unsigned pixel_bits, GLboolean have_back_buffer )
+{
+ __GLcontextModes * modes;
+ __GLcontextModes * m;
+ unsigned num_modes;
+ const unsigned back_buffer_factor = (have_back_buffer) ? 2 : 1;
+ GLenum fb_format;
+ GLenum fb_type;
+
+ /* Right now GLX_SWAP_COPY_OML isn't supported, but it would be easy
+ * enough to add support. Basically, if a context is created with an
+ * fbconfig where the swap method is GLX_SWAP_COPY_OML, pageflipping
+ * will never be used.
+ */
+ static const GLenum back_buffer_modes[] = {
+ GLX_NONE, GLX_SWAP_UNDEFINED_OML /*, GLX_SWAP_COPY_OML */
+ };
+
+ /* The 32-bit depth-buffer mode isn't supported yet, so don't actually
+ * enable it.
+ */
+ static const u_int8_t depth_bits_array[4] = { 0, 16, 24, 32 };
+ static const u_int8_t stencil_bits_array[4] = { 0, 0, 8, 0 };
+ const unsigned depth_buffer_factor = 3;
+
+
+ num_modes = depth_buffer_factor * back_buffer_factor * 4;
+
+ if ( pixel_bits == 16 ) {
+ fb_format = GL_RGB;
+ fb_type = GL_UNSIGNED_SHORT_5_6_5;
+ }
+ else {
+ fb_format = GL_BGRA;
+ fb_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+ }
+
+ modes = (*dri_interface->createContextModes)( num_modes, sizeof( __GLcontextModes ) );
+ m = modes;
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array,
+ depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_TRUE_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+
+ if ( ! driFillInModes( & m, fb_format, fb_type,
+ depth_bits_array, stencil_bits_array,
+ depth_buffer_factor,
+ back_buffer_modes, back_buffer_factor,
+ GLX_DIRECT_COLOR ) ) {
+ fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
+ __func__, __LINE__ );
+ return NULL;
+ }
+
+ return modes;
+}
+
+
+/**
+ * This is the bootstrap function for the driver. libGL supplies all of the
+ * requisite information about the system, and the driver initializes itself.
+ * This routine also fills in the linked list pointed to by \c driver_modes
+ * with the \c __GLcontextModes that the driver can support for windows or
+ * pbuffers.
+ *
+ * \return A pointer to a \c __DRIscreenPrivate on success, or \c NULL on
+ * failure.
+ */
+PUBLIC
+void * __driCreateNewScreen_20050727( __DRInativeDisplay *dpy, int scrn,
+ __DRIscreen *psc,
+ const __GLcontextModes * modes,
+ const __DRIversion * ddx_version,
+ const __DRIversion * dri_version,
+ const __DRIversion * drm_version,
+ const __DRIframebuffer * frame_buffer,
+ drmAddress pSAREA, int fd,
+ int internal_api_version,
+ const __DRIinterfaceMethods * interface,
+ __GLcontextModes ** driver_modes )
+
+{
+ __DRIscreenPrivate *psp;
+ static const __DRIversion ddx_expected = { VIA_DRIDDX_VERSION_MAJOR,
+ VIA_DRIDDX_VERSION_MINOR,
+ VIA_DRIDDX_VERSION_PATCH };
+ static const __DRIversion dri_expected = { 4, 0, 0 };
+ static const __DRIversion drm_expected = { 2, 3, 0 };
+
+ dri_interface = interface;
+
+ if ( ! driCheckDriDdxDrmVersions2( "Unichrome",
+ dri_version, & dri_expected,
+ ddx_version, & ddx_expected,
+ drm_version, & drm_expected ) ) {
+ return NULL;
+ }
+
+ psp = __driUtilCreateNewScreen(dpy, scrn, psc, NULL,
+ ddx_version, dri_version, drm_version,
+ frame_buffer, pSAREA, fd,
+ internal_api_version, &viaAPI);
+ if ( psp != NULL ) {
+ VIADRIPtr dri_priv = (VIADRIPtr) psp->pDevPriv;
+ *driver_modes = viaFillInModes( dri_priv->bytesPerPixel * 8,
+ GL_TRUE );
+
+ /* Calling driInitExtensions here, with a NULL context pointer, does not actually
+ * enable the extensions. It just makes sure that all the dispatch offsets for all
+ * the extensions that *might* be enables are known. This is needed because the
+ * dispatch offsets need to be known when _mesa_context_create is called, but we can't
+ * enable the extensions until we have a context pointer.
+ *
+ * Hello chicken. Hello egg. How are you two today?
+ */
+ driInitExtensions( NULL, card_extensions, GL_FALSE );
+ }
+
+ fprintf(stderr, "%s - succeeded\n", __FUNCTION__);
+ return (void *) psp;
+}
+
+
+/**
+ * Get information about previous buffer swaps.
+ */
+static int
+getSwapInfo( __DRIdrawablePrivate *dPriv, __DRIswapInfo * sInfo )
+{
+ struct via_context *vmesa;
+
+ if ( (dPriv == NULL) || (dPriv->driContextPriv == NULL)
+ || (dPriv->driContextPriv->driverPrivate == NULL)
+ || (sInfo == NULL) ) {
+ return -1;
+ }
+
+ vmesa = (struct via_context *) dPriv->driContextPriv->driverPrivate;
+ sInfo->swap_count = vmesa->swap_count;
+ sInfo->swap_ust = vmesa->swap_ust;
+ sInfo->swap_missed_count = vmesa->swap_missed_count;
+
+ sInfo->swap_missed_usage = (sInfo->swap_missed_count != 0)
+ ? driCalculateSwapUsage( dPriv, 0, vmesa->swap_missed_ust )
+ : 0.0;
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_screen.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_screen.h
new file mode 100644
index 000000000..84aa5aef8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_screen.h
@@ -0,0 +1,95 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+#ifndef _VIAINIT_H
+#define _VIAINIT_H
+
+#include <sys/time.h>
+#include "dri_util.h"
+#include "via_dri.h"
+#include "xmlconfig.h"
+
+typedef struct {
+ viaRegion regs;
+ viaRegion agp;
+ int deviceID;
+ int width;
+ int height;
+ int mem;
+
+ int cpp;
+ int bitsPerPixel;
+ int bytesPerPixel;
+ int fbFormat;
+ int fbOffset;
+ int fbSize;
+
+ int fbStride;
+
+ int backOffset;
+ int depthOffset;
+
+ int backPitch;
+ int backPitchBits;
+
+ int textureOffset;
+ int textureSize;
+ int logTextureGranularity;
+
+ drmAddress reg;
+ drmAddress agpLinearStart;
+ GLuint agpBase;
+
+ __DRIscreenPrivate *driScrnPriv;
+ drmBufMapPtr bufs;
+ unsigned int sareaPrivOffset;
+ /*=* John Sheng [2003.12.9] Tuxracer & VQ *=*/
+ int VQEnable;
+ int irqEnabled;
+
+ /* Configuration cache with default values for all contexts */
+ driOptionCache optionCache;
+} viaScreenPrivate;
+
+
+extern GLboolean
+viaCreateContext(const __GLcontextModes *mesaVis,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate);
+
+extern void
+viaDestroyContext(__DRIcontextPrivate *driContextPriv);
+
+extern GLboolean
+viaUnbindContext(__DRIcontextPrivate *driContextPriv);
+
+extern GLboolean
+viaMakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv);
+
+extern void
+viaSwapBuffers(__DRIdrawablePrivate *drawablePrivate);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_span.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_span.c
new file mode 100644
index 000000000..40772f480
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_span.c
@@ -0,0 +1,289 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "colormac.h"
+#include "via_context.h"
+#include "via_span.h"
+#include "via_ioctl.h"
+#include "swrast/swrast.h"
+
+#define DBG 0
+
+#define Y_FLIP(_y) (height - _y - 1)
+
+#define HW_LOCK()
+
+#define HW_UNLOCK()
+
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ struct via_context *vmesa = VIA_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
+ GLuint draw_pitch = vmesa->drawBuffer->pitch; \
+ GLuint read_pitch = vmesa->readBuffer->pitch; \
+ GLuint height = dPriv->h; \
+ GLint p = 0; \
+ char *buf = (char *)(vmesa->drawBuffer->origMap + vmesa->drawXoff * vmesa->viaScreen->bytesPerPixel); \
+ char *read_buf = (char *)(vmesa->readBuffer->origMap + vmesa->drawXoff * vmesa->viaScreen->bytesPerPixel); \
+ (void) (read_pitch && draw_pitch && buf && read_buf && p);
+
+/* ================================================================
+ * Color buffer
+ */
+
+/* 16 bit, RGB565 color spanline and pixel functions
+ */
+#define GET_SRC_PTR(_x, _y) (read_buf + (_x) * 2 + (_y) * read_pitch)
+#define GET_DST_PTR(_x, _y) ( buf + (_x) * 2 + (_y) * draw_pitch)
+#define SPANTMP_PIXEL_FMT GL_RGB
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_SHORT_5_6_5
+
+#define TAG(x) via##x##_565
+#define TAG2(x,y) via##x##_565##y
+#include "spantmp2.h"
+
+
+/* 32 bit, ARGB8888 color spanline and pixel functions
+ */
+#define GET_SRC_PTR(_x, _y) (read_buf + (_x) * 4 + (_y) * read_pitch)
+#define GET_DST_PTR(_x, _y) ( buf + (_x) * 4 + (_y) * draw_pitch)
+#define SPANTMP_PIXEL_FMT GL_BGRA
+#define SPANTMP_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
+
+#define TAG(x) via##x##_8888
+#define TAG2(x,y) via##x##_8888##y
+#include "spantmp2.h"
+
+
+/* 16 bit depthbuffer functions.
+ */
+#define LOCAL_DEPTH_VARS \
+ struct via_context *vmesa = VIA_CONTEXT(ctx); \
+ __DRIdrawablePrivate *dPriv = vmesa->driDrawable; \
+ GLuint depth_pitch = vmesa->depth.pitch; \
+ GLuint height = dPriv->h; \
+ char *buf = (char *)(vmesa->depth.map + (vmesa->drawXoff * vmesa->depth.bpp/8))
+
+#define LOCAL_STENCIL_VARS LOCAL_DEPTH_VARS
+
+
+#define WRITE_DEPTH(_x, _y, d) \
+ *(GLushort *)(buf + (_x) * 2 + (_y) * depth_pitch) = d;
+
+#define READ_DEPTH(d, _x, _y) \
+ d = *(volatile GLushort *)(buf + (_x) * 2 + (_y) * depth_pitch);
+
+#define TAG(x) via##x##_16
+#include "depthtmp.h"
+
+/* 32 bit depthbuffer functions.
+ */
+#define WRITE_DEPTH(_x, _y, d) \
+ *(GLuint *)(buf + (_x) * 4 + (_y) * depth_pitch) = d;
+
+#define READ_DEPTH(d, _x, _y) \
+ d = *(volatile GLuint *)(buf + (_x) * 4 + (_y) * depth_pitch);
+
+#define TAG(x) via##x##_32
+#include "depthtmp.h"
+
+
+
+/* 24/8 bit interleaved depth/stencil functions
+ */
+#define WRITE_DEPTH( _x, _y, d ) { \
+ GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch); \
+ tmp &= 0x000000ff; \
+ tmp |= ((d)<<8); \
+ *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch) = tmp; \
+}
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = (*(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch)) >> 8;
+
+
+#define TAG(x) via##x##_24_8
+#include "depthtmp.h"
+
+#define WRITE_STENCIL( _x, _y, d ) { \
+ GLuint tmp = *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch); \
+ tmp &= 0xffffff00; \
+ tmp |= (d); \
+ *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch) = tmp; \
+}
+
+#define READ_STENCIL( d, _x, _y ) \
+ d = *(GLuint *)(buf + (_x)*4 + (_y)*depth_pitch) & 0xff;
+
+#define TAG(x) via##x##_24_8
+#include "stenciltmp.h"
+
+
+
+static void viaSetBuffer(GLcontext *ctx, GLframebuffer *colorBuffer,
+ GLuint bufferBit)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+
+ if (bufferBit == BUFFER_BIT_FRONT_LEFT) {
+ vmesa->drawBuffer = vmesa->readBuffer = &vmesa->front;
+ }
+ else if (bufferBit == BUFFER_BIT_BACK_LEFT) {
+ vmesa->drawBuffer = vmesa->readBuffer = &vmesa->back;
+ }
+ else {
+ ASSERT(0);
+ }
+}
+
+/* Move locking out to get reasonable span performance.
+ */
+void viaSpanRenderStart( GLcontext *ctx )
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ viaWaitIdle(vmesa, GL_FALSE);
+ LOCK_HARDWARE(vmesa);
+}
+
+void viaSpanRenderFinish( GLcontext *ctx )
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ _swrast_flush( ctx );
+ UNLOCK_HARDWARE( vmesa );
+}
+
+void viaInitSpanFuncs(GLcontext *ctx)
+{
+#if 0
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+#endif
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference(ctx);
+
+ swdd->SetBuffer = viaSetBuffer;
+#if 0
+ if (vmesa->viaScreen->bitsPerPixel == 16) {
+ viaInitPointers_565( swdd );
+ }
+ else if (vmesa->viaScreen->bitsPerPixel == 32) {
+ viaInitPointers_8888( swdd );
+ }
+ else {
+ assert(0);
+ }
+#endif
+#if 0
+ if (vmesa->glCtx->Visual.depthBits == 16) {
+ swdd->ReadDepthSpan = viaReadDepthSpan_16;
+ swdd->WriteDepthSpan = viaWriteDepthSpan_16;
+ swdd->WriteMonoDepthSpan = viaWriteMonoDepthSpan_16;
+ swdd->ReadDepthPixels = viaReadDepthPixels_16;
+ swdd->WriteDepthPixels = viaWriteDepthPixels_16;
+ }
+ else if (vmesa->glCtx->Visual.depthBits == 24) {
+ swdd->ReadDepthSpan = viaReadDepthSpan_24_8;
+ swdd->WriteDepthSpan = viaWriteDepthSpan_24_8;
+ swdd->WriteMonoDepthSpan = viaWriteMonoDepthSpan_24_8;
+ swdd->ReadDepthPixels = viaReadDepthPixels_24_8;
+ swdd->WriteDepthPixels = viaWriteDepthPixels_24_8;
+
+ swdd->WriteStencilSpan = viaWriteStencilSpan_24_8;
+ swdd->ReadStencilSpan = viaReadStencilSpan_24_8;
+ swdd->WriteStencilPixels = viaWriteStencilPixels_24_8;
+ swdd->ReadStencilPixels = viaReadStencilPixels_24_8;
+ }
+ else if (vmesa->glCtx->Visual.depthBits == 32) {
+ swdd->ReadDepthSpan = viaReadDepthSpan_32;
+ swdd->WriteDepthSpan = viaWriteDepthSpan_32;
+ swdd->WriteMonoDepthSpan = viaWriteMonoDepthSpan_32;
+ swdd->ReadDepthPixels = viaReadDepthPixels_32;
+ swdd->WriteDepthPixels = viaWriteDepthPixels_32;
+ }
+#endif
+
+ swdd->SpanRenderStart = viaSpanRenderStart;
+ swdd->SpanRenderFinish = viaSpanRenderFinish;
+
+#if 0
+ swdd->WriteCI8Span = NULL;
+ swdd->WriteCI32Span = NULL;
+ swdd->WriteMonoCISpan = NULL;
+ swdd->WriteCI32Pixels = NULL;
+ swdd->WriteMonoCIPixels = NULL;
+ swdd->ReadCI32Span = NULL;
+ swdd->ReadCI32Pixels = NULL;
+#endif
+}
+
+
+
+/**
+ * Plug in the Get/Put routines for the given driRenderbuffer.
+ */
+void
+viaSetSpanFunctions(driRenderbuffer *drb, const GLvisual *vis)
+{
+ if (drb->Base.InternalFormat == GL_RGBA) {
+ if (vis->redBits == 5 && vis->greenBits == 6 && vis->blueBits == 5) {
+ viaInitPointers_565(&drb->Base);
+ }
+ else {
+ viaInitPointers_8888(&drb->Base);
+ }
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT16) {
+ drb->Base.GetRow = viaReadDepthSpan_16;
+ drb->Base.GetValues = viaReadDepthPixels_16;
+ drb->Base.PutRow = viaWriteDepthSpan_16;
+ drb->Base.PutMonoRow = viaWriteMonoDepthSpan_16;
+ drb->Base.PutValues = viaWriteDepthPixels_16;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT24) {
+ drb->Base.GetRow = viaReadDepthSpan_24_8;
+ drb->Base.GetValues = viaReadDepthPixels_24_8;
+ drb->Base.PutRow = viaWriteDepthSpan_24_8;
+ drb->Base.PutMonoRow = viaWriteMonoDepthSpan_24_8;
+ drb->Base.PutValues = viaWriteDepthPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_DEPTH_COMPONENT32) {
+ drb->Base.GetRow = viaReadDepthSpan_32;
+ drb->Base.GetValues = viaReadDepthPixels_32;
+ drb->Base.PutRow = viaWriteDepthSpan_32;
+ drb->Base.PutMonoRow = viaWriteMonoDepthSpan_32;
+ drb->Base.PutValues = viaWriteDepthPixels_32;
+ drb->Base.PutMonoValues = NULL;
+ }
+ else if (drb->Base.InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ drb->Base.GetRow = viaReadStencilSpan_24_8;
+ drb->Base.GetValues = viaReadStencilPixels_24_8;
+ drb->Base.PutRow = viaWriteStencilSpan_24_8;
+ drb->Base.PutMonoRow = viaWriteMonoStencilSpan_24_8;
+ drb->Base.PutValues = viaWriteStencilPixels_24_8;
+ drb->Base.PutMonoValues = NULL;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_span.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_span.h
new file mode 100644
index 000000000..c3bd24b0e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_span.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+#ifndef _VIA_SPAN_H
+#define _VIA_SPAN_H
+
+#include "drirenderbuffer.h"
+
+extern void viaInitSpanFuncs(GLcontext *ctx);
+extern void viaSpanRenderStart( GLcontext *ctx );
+extern void viaSpanRenderFinish( GLcontext *ctx );
+
+extern void
+viaSetSpanFunctions(driRenderbuffer *rb, const GLvisual *vis);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_state.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_state.c
new file mode 100644
index 000000000..4037d14ff
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_state.c
@@ -0,0 +1,1550 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+#include <stdio.h>
+
+#include "glheader.h"
+#include "buffers.h"
+#include "context.h"
+#include "macros.h"
+#include "colormac.h"
+#include "enums.h"
+#include "dd.h"
+
+#include "mm.h"
+#include "via_context.h"
+#include "via_state.h"
+#include "via_tex.h"
+#include "via_tris.h"
+#include "via_ioctl.h"
+#include "via_3d_reg.h"
+
+#include "swrast/swrast.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "tnl/t_pipeline.h"
+
+
+static GLuint ROP[16] = {
+ HC_HROP_BLACK, /* GL_CLEAR 0 */
+ HC_HROP_DPa, /* GL_AND s & d */
+ HC_HROP_PDna, /* GL_AND_REVERSE s & ~d */
+ HC_HROP_P, /* GL_COPY s */
+ HC_HROP_DPna, /* GL_AND_INVERTED ~s & d */
+ HC_HROP_D, /* GL_NOOP d */
+ HC_HROP_DPx, /* GL_XOR s ^ d */
+ HC_HROP_DPo, /* GL_OR s | d */
+ HC_HROP_DPon, /* GL_NOR ~(s | d) */
+ HC_HROP_DPxn, /* GL_EQUIV ~(s ^ d) */
+ HC_HROP_Dn, /* GL_INVERT ~d */
+ HC_HROP_PDno, /* GL_OR_REVERSE s | ~d */
+ HC_HROP_Pn, /* GL_COPY_INVERTED ~s */
+ HC_HROP_DPno, /* GL_OR_INVERTED ~s | d */
+ HC_HROP_DPan, /* GL_NAND ~(s & d) */
+ HC_HROP_WHITE /* GL_SET 1 */
+};
+
+/*
+ * Compute the 'S5.5' lod bias factor from the floating point OpenGL bias.
+ */
+static GLuint viaComputeLodBias(GLfloat bias)
+{
+ int b = (int) (bias * 32.0);
+ if (b > 511)
+ b = 511;
+ else if (b < -512)
+ b = -512;
+ return (GLuint) b;
+}
+
+void viaEmitState(struct via_context *vmesa)
+{
+ GLcontext *ctx = vmesa->glCtx;
+ GLuint i = 0;
+ GLuint j = 0;
+ RING_VARS;
+
+ viaCheckDma(vmesa, 0x110);
+
+ BEGIN_RING(5);
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( (HC_ParaType_NotTex << 16) );
+ OUT_RING( ((HC_SubA_HEnable << 24) | vmesa->regEnable) );
+ OUT_RING( ((HC_SubA_HFBBMSKL << 24) | vmesa->regHFBBMSKL) );
+ OUT_RING( ((HC_SubA_HROP << 24) | vmesa->regHROP) );
+ ADVANCE_RING();
+
+ if (vmesa->have_hw_stencil) {
+ GLuint pitch, format, offset;
+
+ format = HC_HZWBFM_24;
+ offset = vmesa->depth.offset;
+ pitch = vmesa->depth.pitch;
+
+ BEGIN_RING(6);
+ OUT_RING( (HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF) );
+ OUT_RING( (HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24) );
+ OUT_RING( (HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK |
+ format | pitch );
+ OUT_RING( (HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD );
+ OUT_RING( (HC_SubA_HSTREF << 24) | vmesa->regHSTREF );
+ OUT_RING( (HC_SubA_HSTMD << 24) | vmesa->regHSTMD );
+ ADVANCE_RING();
+ }
+ else if (vmesa->hasDepth) {
+ GLuint pitch, format, offset;
+
+ if (vmesa->depthBits == 16) {
+ format = HC_HZWBFM_16;
+ }
+ else {
+ format = HC_HZWBFM_32;
+ }
+
+
+ offset = vmesa->depth.offset;
+ pitch = vmesa->depth.pitch;
+
+ BEGIN_RING(4);
+ OUT_RING( (HC_SubA_HZWBBasL << 24) | (offset & 0xFFFFFF) );
+ OUT_RING( (HC_SubA_HZWBBasH << 24) | ((offset & 0xFF000000) >> 24) );
+ OUT_RING( (HC_SubA_HZWBType << 24) | HC_HDBLoc_Local | HC_HZONEasFF_MASK |
+ format | pitch );
+ OUT_RING( (HC_SubA_HZWTMD << 24) | vmesa->regHZWTMD );
+ ADVANCE_RING();
+ }
+
+ if (ctx->Color.AlphaEnabled) {
+ BEGIN_RING(1);
+ OUT_RING( (HC_SubA_HATMD << 24) | vmesa->regHATMD );
+ ADVANCE_RING();
+ i++;
+ }
+
+ if (ctx->Color.BlendEnabled) {
+ BEGIN_RING(11);
+ OUT_RING( (HC_SubA_HABLCsat << 24) | vmesa->regHABLCsat );
+ OUT_RING( (HC_SubA_HABLCop << 24) | vmesa->regHABLCop );
+ OUT_RING( (HC_SubA_HABLAsat << 24) | vmesa->regHABLAsat );
+ OUT_RING( (HC_SubA_HABLAop << 24) | vmesa->regHABLAop );
+ OUT_RING( (HC_SubA_HABLRCa << 24) | vmesa->regHABLRCa );
+ OUT_RING( (HC_SubA_HABLRFCa << 24) | vmesa->regHABLRFCa );
+ OUT_RING( (HC_SubA_HABLRCbias << 24) | vmesa->regHABLRCbias );
+ OUT_RING( (HC_SubA_HABLRCb << 24) | vmesa->regHABLRCb );
+ OUT_RING( (HC_SubA_HABLRFCb << 24) | vmesa->regHABLRFCb );
+ OUT_RING( (HC_SubA_HABLRAa << 24) | vmesa->regHABLRAa );
+ OUT_RING( (HC_SubA_HABLRAb << 24) | vmesa->regHABLRAb );
+ ADVANCE_RING();
+ }
+
+ if (ctx->Fog.Enabled) {
+ BEGIN_RING(3);
+ OUT_RING( (HC_SubA_HFogLF << 24) | vmesa->regHFogLF );
+ OUT_RING( (HC_SubA_HFogCL << 24) | vmesa->regHFogCL );
+ OUT_RING( (HC_SubA_HFogCH << 24) | vmesa->regHFogCH );
+ ADVANCE_RING();
+ }
+
+ if (ctx->Line.StippleFlag) {
+ BEGIN_RING(2);
+ OUT_RING( (HC_SubA_HLP << 24) | ctx->Line.StipplePattern );
+ OUT_RING( (HC_SubA_HLPRF << 24) | ctx->Line.StippleFactor );
+ ADVANCE_RING();
+ }
+
+ BEGIN_RING(1);
+ OUT_RING( (HC_SubA_HPixGC << 24) | 0x0 );
+ ADVANCE_RING();
+
+ QWORD_PAD_RING();
+
+
+ if (ctx->Texture._EnabledUnits) {
+
+ struct gl_texture_unit *texUnit0 = &ctx->Texture.Unit[0];
+ struct gl_texture_unit *texUnit1 = &ctx->Texture.Unit[1];
+
+ {
+ GLuint nDummyValue = 0;
+
+ BEGIN_RING( 8 );
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( (HC_ParaType_Tex << 16) | (HC_SubType_TexGeneral << 24) );
+
+ if (texUnit0->Enabled && texUnit1->Enabled) {
+ nDummyValue = (HC_SubA_HTXSMD << 24) | (1 << 3);
+ }
+ else {
+ nDummyValue = (HC_SubA_HTXSMD << 24) | 0;
+ }
+
+ if (vmesa->clearTexCache) {
+ vmesa->clearTexCache = 0;
+ OUT_RING( nDummyValue | HC_HTXCHCLR_MASK );
+ OUT_RING( nDummyValue );
+ }
+ else {
+ OUT_RING( nDummyValue );
+ OUT_RING( nDummyValue );
+ }
+
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( HC_ParaType_NotTex << 16 );
+ OUT_RING( (HC_SubA_HEnable << 24) | vmesa->regEnable );
+ OUT_RING( (HC_SubA_HEnable << 24) | vmesa->regEnable );
+ ADVANCE_RING();
+ }
+
+ if (texUnit0->Enabled) {
+ struct gl_texture_object *texObj = texUnit0->_Current;
+ struct via_texture_object *t = (struct via_texture_object *)texObj;
+ GLuint numLevels = t->lastLevel - t->firstLevel + 1;
+ if (VIA_DEBUG & DEBUG_STATE) {
+ fprintf(stderr, "texture0 enabled\n");
+ }
+ if (numLevels == 8) {
+ BEGIN_RING(27);
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( (HC_ParaType_Tex << 16) | (0 << 24) );
+ OUT_RING( t->regTexFM );
+ OUT_RING( (HC_SubA_HTXnL0OS << 24) |
+ ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel );
+ OUT_RING( t->regTexWidthLog2[0] );
+ OUT_RING( t->regTexWidthLog2[1] );
+ OUT_RING( t->regTexHeightLog2[0] );
+ OUT_RING( t->regTexHeightLog2[1] );
+ OUT_RING( t->regTexBaseH[0] );
+ OUT_RING( t->regTexBaseH[1] );
+ OUT_RING( t->regTexBaseH[2] );
+ OUT_RING( t->regTexBaseAndPitch[0].baseL );
+ OUT_RING( t->regTexBaseAndPitch[0].pitchLog2 );
+ OUT_RING( t->regTexBaseAndPitch[1].baseL );
+ OUT_RING( t->regTexBaseAndPitch[1].pitchLog2 );
+ OUT_RING( t->regTexBaseAndPitch[2].baseL );
+ OUT_RING( t->regTexBaseAndPitch[2].pitchLog2 );
+ OUT_RING( t->regTexBaseAndPitch[3].baseL );
+ OUT_RING( t->regTexBaseAndPitch[3].pitchLog2 );
+ OUT_RING( t->regTexBaseAndPitch[4].baseL );
+ OUT_RING( t->regTexBaseAndPitch[4].pitchLog2 );
+ OUT_RING( t->regTexBaseAndPitch[5].baseL );
+ OUT_RING( t->regTexBaseAndPitch[5].pitchLog2 );
+ OUT_RING( t->regTexBaseAndPitch[6].baseL );
+ OUT_RING( t->regTexBaseAndPitch[6].pitchLog2 );
+ OUT_RING( t->regTexBaseAndPitch[7].baseL );
+ OUT_RING( t->regTexBaseAndPitch[7].pitchLog2 );
+ ADVANCE_RING();
+ }
+ else if (numLevels > 1) {
+
+ BEGIN_RING(12 + numLevels * 2);
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( (HC_ParaType_Tex << 16) | (0 << 24) );
+ OUT_RING( t->regTexFM );
+ OUT_RING( (HC_SubA_HTXnL0OS << 24) |
+ ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel );
+ OUT_RING( t->regTexWidthLog2[0] );
+ OUT_RING( t->regTexHeightLog2[0] );
+
+ if (numLevels > 6) {
+ OUT_RING( t->regTexWidthLog2[1] );
+ OUT_RING( t->regTexHeightLog2[1] );
+ }
+
+ OUT_RING( t->regTexBaseH[0] );
+
+ if (numLevels > 3) {
+ OUT_RING( t->regTexBaseH[1] );
+ }
+ if (numLevels > 6) {
+ OUT_RING( t->regTexBaseH[2] );
+ }
+ if (numLevels > 9) {
+ OUT_RING( t->regTexBaseH[3] );
+ }
+
+ for (j = 0; j < numLevels; j++) {
+ OUT_RING( t->regTexBaseAndPitch[j].baseL );
+ OUT_RING( t->regTexBaseAndPitch[j].pitchLog2 );
+ }
+
+ ADVANCE_RING_VARIABLE();
+ }
+ else {
+
+ BEGIN_RING(9);
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( (HC_ParaType_Tex << 16) | (0 << 24) );
+ OUT_RING( t->regTexFM );
+ OUT_RING( (HC_SubA_HTXnL0OS << 24) |
+ ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel );
+ OUT_RING( t->regTexWidthLog2[0] );
+ OUT_RING( t->regTexHeightLog2[0] );
+ OUT_RING( t->regTexBaseH[0] );
+ OUT_RING( t->regTexBaseAndPitch[0].baseL );
+ OUT_RING( t->regTexBaseAndPitch[0].pitchLog2 );
+ ADVANCE_RING();
+ }
+
+ BEGIN_RING(14);
+ OUT_RING( (HC_SubA_HTXnTB << 24) | vmesa->regHTXnTB[0] );
+ OUT_RING( (HC_SubA_HTXnMPMD << 24) | vmesa->regHTXnMPMD[0] );
+ OUT_RING( (HC_SubA_HTXnTBLCsat << 24) | vmesa->regHTXnTBLCsat[0] );
+ OUT_RING( (HC_SubA_HTXnTBLCop << 24) | vmesa->regHTXnTBLCop[0] );
+ OUT_RING( (HC_SubA_HTXnTBLMPfog << 24) | vmesa->regHTXnTBLMPfog[0] );
+ OUT_RING( (HC_SubA_HTXnTBLAsat << 24) | vmesa->regHTXnTBLAsat[0] );
+ OUT_RING( (HC_SubA_HTXnTBLRCb << 24) | vmesa->regHTXnTBLRCb[0] );
+ OUT_RING( (HC_SubA_HTXnTBLRAa << 24) | vmesa->regHTXnTBLRAa[0] );
+ OUT_RING( (HC_SubA_HTXnTBLRFog << 24) | vmesa->regHTXnTBLRFog[0] );
+ OUT_RING( (HC_SubA_HTXnTBLRCa << 24) | vmesa->regHTXnTBLRCa[0] );
+ OUT_RING( (HC_SubA_HTXnTBLRCc << 24) | vmesa->regHTXnTBLRCc[0] );
+ OUT_RING( (HC_SubA_HTXnTBLRCbias << 24) | vmesa->regHTXnTBLRCbias[0] );
+ OUT_RING( (HC_SubA_HTXnTBC << 24) | vmesa->regHTXnTBC[0] );
+ OUT_RING( (HC_SubA_HTXnTRAH << 24) | vmesa->regHTXnTRAH[0] );
+/* OUT_RING( (HC_SubA_HTXnCLODu << 24) | vmesa->regHTXnCLOD[0] ); */
+ ADVANCE_RING();
+
+ /* KW: This test never succeeds:
+ */
+ if (t->regTexFM == HC_HTXnFM_Index8) {
+ struct gl_color_table *table = &texObj->Palette;
+ GLfloat *tableF = (GLfloat *)table->Table;
+
+ BEGIN_RING(2 + table->Size);
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( (HC_ParaType_Palette << 16) | (0 << 24) );
+ for (j = 0; j < table->Size; j++)
+ OUT_RING( tableF[j] );
+ ADVANCE_RING();
+
+ }
+
+ QWORD_PAD_RING();
+ }
+
+ if (texUnit1->Enabled) {
+ struct gl_texture_object *texObj = texUnit1->_Current;
+ struct via_texture_object *t = (struct via_texture_object *)texObj;
+ GLuint numLevels = t->lastLevel - t->firstLevel + 1;
+ int texunit = (texUnit0->Enabled ? 1 : 0);
+ if (VIA_DEBUG & DEBUG_STATE) {
+ fprintf(stderr, "texture1 enabled\n");
+ }
+ if (numLevels == 8) {
+ BEGIN_RING(27);
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( (HC_ParaType_Tex << 16) | (texunit << 24) );
+ OUT_RING( t->regTexFM );
+ OUT_RING( (HC_SubA_HTXnL0OS << 24) |
+ ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel );
+ OUT_RING( t->regTexWidthLog2[0] );
+ OUT_RING( t->regTexWidthLog2[1] );
+ OUT_RING( t->regTexHeightLog2[0] );
+ OUT_RING( t->regTexHeightLog2[1] );
+ OUT_RING( t->regTexBaseH[0] );
+ OUT_RING( t->regTexBaseH[1] );
+ OUT_RING( t->regTexBaseH[2] );
+ OUT_RING( t->regTexBaseAndPitch[0].baseL );
+ OUT_RING( t->regTexBaseAndPitch[0].pitchLog2 );
+ OUT_RING( t->regTexBaseAndPitch[1].baseL );
+ OUT_RING( t->regTexBaseAndPitch[1].pitchLog2 );
+ OUT_RING( t->regTexBaseAndPitch[2].baseL );
+ OUT_RING( t->regTexBaseAndPitch[2].pitchLog2 );
+ OUT_RING( t->regTexBaseAndPitch[3].baseL );
+ OUT_RING( t->regTexBaseAndPitch[3].pitchLog2 );
+ OUT_RING( t->regTexBaseAndPitch[4].baseL );
+ OUT_RING( t->regTexBaseAndPitch[4].pitchLog2 );
+ OUT_RING( t->regTexBaseAndPitch[5].baseL );
+ OUT_RING( t->regTexBaseAndPitch[5].pitchLog2 );
+ OUT_RING( t->regTexBaseAndPitch[6].baseL );
+ OUT_RING( t->regTexBaseAndPitch[6].pitchLog2 );
+ OUT_RING( t->regTexBaseAndPitch[7].baseL );
+ OUT_RING( t->regTexBaseAndPitch[7].pitchLog2 );
+ ADVANCE_RING();
+ }
+ else if (numLevels > 1) {
+ BEGIN_RING(12 + numLevels * 2);
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( (HC_ParaType_Tex << 16) | (texunit << 24) );
+ OUT_RING( t->regTexFM );
+ OUT_RING( (HC_SubA_HTXnL0OS << 24) |
+ ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel );
+ OUT_RING( t->regTexWidthLog2[0] );
+ OUT_RING( t->regTexHeightLog2[0] );
+
+ if (numLevels > 6) {
+ OUT_RING( t->regTexWidthLog2[1] );
+ OUT_RING( t->regTexHeightLog2[1] );
+ i += 2;
+ }
+
+ OUT_RING( t->regTexBaseH[0] );
+
+ if (numLevels > 3) {
+ OUT_RING( t->regTexBaseH[1] );
+ }
+ if (numLevels > 6) {
+ OUT_RING( t->regTexBaseH[2] );
+ }
+ if (numLevels > 9) {
+ OUT_RING( t->regTexBaseH[3] );
+ }
+
+ for (j = 0; j < numLevels; j++) {
+ OUT_RING( t->regTexBaseAndPitch[j].baseL );
+ OUT_RING( t->regTexBaseAndPitch[j].pitchLog2 );
+ }
+ ADVANCE_RING_VARIABLE();
+ }
+ else {
+ BEGIN_RING(9);
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( (HC_ParaType_Tex << 16) | (texunit << 24) );
+ OUT_RING( t->regTexFM );
+ OUT_RING( (HC_SubA_HTXnL0OS << 24) |
+ ((t->lastLevel) << HC_HTXnLVmax_SHIFT) | t->firstLevel );
+ OUT_RING( t->regTexWidthLog2[0] );
+ OUT_RING( t->regTexHeightLog2[0] );
+ OUT_RING( t->regTexBaseH[0] );
+ OUT_RING( t->regTexBaseAndPitch[0].baseL );
+ OUT_RING( t->regTexBaseAndPitch[0].pitchLog2 );
+ ADVANCE_RING();
+ }
+
+ BEGIN_RING(14);
+ OUT_RING( (HC_SubA_HTXnTB << 24) | vmesa->regHTXnTB[1] );
+ OUT_RING( (HC_SubA_HTXnMPMD << 24) | vmesa->regHTXnMPMD[1] );
+ OUT_RING( (HC_SubA_HTXnTBLCsat << 24) | vmesa->regHTXnTBLCsat[1] );
+ OUT_RING( (HC_SubA_HTXnTBLCop << 24) | vmesa->regHTXnTBLCop[1] );
+ OUT_RING( (HC_SubA_HTXnTBLMPfog << 24) | vmesa->regHTXnTBLMPfog[1] );
+ OUT_RING( (HC_SubA_HTXnTBLAsat << 24) | vmesa->regHTXnTBLAsat[1] );
+ OUT_RING( (HC_SubA_HTXnTBLRCb << 24) | vmesa->regHTXnTBLRCb[1] );
+ OUT_RING( (HC_SubA_HTXnTBLRAa << 24) | vmesa->regHTXnTBLRAa[1] );
+ OUT_RING( (HC_SubA_HTXnTBLRFog << 24) | vmesa->regHTXnTBLRFog[1] );
+ OUT_RING( (HC_SubA_HTXnTBLRCa << 24) | vmesa->regHTXnTBLRCa[1] );
+ OUT_RING( (HC_SubA_HTXnTBLRCc << 24) | vmesa->regHTXnTBLRCc[1] );
+ OUT_RING( (HC_SubA_HTXnTBLRCbias << 24) | vmesa->regHTXnTBLRCbias[1] );
+ OUT_RING( (HC_SubA_HTXnTBC << 24) | vmesa->regHTXnTBC[1] );
+ OUT_RING( (HC_SubA_HTXnTRAH << 24) | vmesa->regHTXnTRAH[1] );
+/* OUT_RING( (HC_SubA_HTXnCLODu << 24) | vmesa->regHTXnCLOD[1] ); */
+ ADVANCE_RING();
+
+ /* KW: This test never succeeds:
+ */
+ if (t->regTexFM == HC_HTXnFM_Index8) {
+ struct gl_color_table *table = &texObj->Palette;
+ GLfloat *tableF = (GLfloat *)table->Table;
+
+ BEGIN_RING(2 + table->Size);
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( (HC_ParaType_Palette << 16) | (texunit << 24) );
+ for (j = 0; j < table->Size; j++) {
+ OUT_RING( tableF[j] );
+ }
+ ADVANCE_RING();
+ }
+
+ QWORD_PAD_RING();
+ }
+ }
+
+#if 0
+ /* Polygon stipple is broken - for certain stipple values,
+ * eg. 0xf0f0f0f0, the hardware will refuse to accept the stipple.
+ * Coincidentally, conform generates just such a stipple.
+ */
+ if (ctx->Polygon.StippleFlag) {
+ GLuint *stipple = &ctx->PolygonStipple[0];
+ GLint i;
+
+ BEGIN_RING(38);
+ OUT_RING( HC_HEADER2 );
+
+ OUT_RING( ((HC_ParaType_Palette << 16) | (HC_SubType_Stipple << 24)) );
+ for (i = 31; i >= 0; i--) {
+ GLint j;
+ GLuint k = 0;
+
+ /* Need to flip bits left to right:
+ */
+ for (j = 0 ; j < 32; j++)
+ if (stipple[i] & (1<<j))
+ k |= 1 << (31-j);
+
+ OUT_RING( k );
+ }
+
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( (HC_ParaType_NotTex << 16) );
+ OUT_RING( (HC_SubA_HSPXYOS << 24) |
+ (((32- vmesa->drawXoff) & 0x1f) << HC_HSPXOS_SHIFT));
+ OUT_RING( (HC_SubA_HSPXYOS << 24) |
+ (((32 - vmesa->drawXoff) & 0x1f) << HC_HSPXOS_SHIFT));
+
+ ADVANCE_RING();
+ }
+#endif
+
+ vmesa->newEmitState = 0;
+}
+
+
+static __inline__ GLuint viaPackColor(GLuint bpp,
+ GLubyte r, GLubyte g,
+ GLubyte b, GLubyte a)
+{
+ switch (bpp) {
+ case 16:
+ return PACK_COLOR_565(r, g, b);
+ case 32:
+ return PACK_COLOR_8888(a, r, g, b);
+ default:
+ assert(0);
+ return 0;
+ }
+}
+
+static void viaBlendEquationSeparate(GLcontext *ctx,
+ GLenum rgbMode,
+ GLenum aMode)
+{
+ if (VIA_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s in\n", __FUNCTION__);
+
+ /* GL_EXT_blend_equation_separate not supported */
+ ASSERT(rgbMode == aMode);
+
+ /* Can only do GL_ADD equation in hardware */
+ FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_BLEND_EQ,
+ rgbMode != GL_FUNC_ADD_EXT);
+
+ /* BlendEquation sets ColorLogicOpEnabled in an unexpected
+ * manner.
+ */
+ FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_LOGICOP,
+ (ctx->Color.ColorLogicOpEnabled &&
+ ctx->Color.LogicOp != GL_COPY));
+}
+
+static void viaBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ GLboolean fallback = GL_FALSE;
+ if (VIA_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s in\n", __FUNCTION__);
+
+ switch (ctx->Color.BlendSrcRGB) {
+ case GL_SRC_ALPHA_SATURATE:
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ fallback = GL_TRUE;
+ break;
+ default:
+ break;
+ }
+
+ switch (ctx->Color.BlendDstRGB) {
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ fallback = GL_TRUE;
+ break;
+ default:
+ break;
+ }
+
+ FALLBACK(vmesa, VIA_FALLBACK_BLEND_FUNC, fallback);
+}
+
+/* Shouldn't be called as the extension is disabled.
+ */
+static void viaBlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB,
+ GLenum dfactorRGB, GLenum sfactorA,
+ GLenum dfactorA)
+{
+ if (dfactorRGB != dfactorA || sfactorRGB != sfactorA) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glBlendEquation (disabled)");
+ }
+
+ viaBlendFunc(ctx, sfactorRGB, dfactorRGB);
+}
+
+
+
+
+/* =============================================================
+ * Hardware clipping
+ */
+static void viaScissor(GLcontext *ctx, GLint x, GLint y,
+ GLsizei w, GLsizei h)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+
+ if (!vmesa->driDrawable)
+ return;
+
+ if (VIA_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s %d,%d %dx%d, drawH %d\n", __FUNCTION__,
+ x,y,w,h, vmesa->driDrawable->h);
+
+ if (vmesa->scissor) {
+ VIA_FLUSH_DMA(vmesa); /* don't pipeline cliprect changes */
+ }
+
+ vmesa->scissorRect.x1 = x;
+ vmesa->scissorRect.y1 = vmesa->driDrawable->h - y - h;
+ vmesa->scissorRect.x2 = x + w;
+ vmesa->scissorRect.y2 = vmesa->driDrawable->h - y;
+}
+
+static void viaEnable(GLcontext *ctx, GLenum cap, GLboolean state)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+
+ switch (cap) {
+ case GL_SCISSOR_TEST:
+ VIA_FLUSH_DMA(vmesa);
+ vmesa->scissor = state;
+ break;
+ default:
+ break;
+ }
+}
+
+
+
+/* Fallback to swrast for select and feedback.
+ */
+static void viaRenderMode(GLcontext *ctx, GLenum mode)
+{
+ FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_RENDERMODE, (mode != GL_RENDER));
+}
+
+
+static void viaDrawBuffer(GLcontext *ctx, GLenum mode)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+
+ if (VIA_DEBUG & (DEBUG_DRI|DEBUG_STATE))
+ fprintf(stderr, "%s in\n", __FUNCTION__);
+
+ if (!ctx->DrawBuffer)
+ return;
+
+ switch ( ctx->DrawBuffer->_ColorDrawBufferMask[0] ) {
+ case BUFFER_BIT_FRONT_LEFT:
+ VIA_FLUSH_DMA(vmesa);
+ vmesa->drawBuffer = vmesa->readBuffer = &vmesa->front;
+ FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_FALSE);
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ VIA_FLUSH_DMA(vmesa);
+ vmesa->drawBuffer = vmesa->readBuffer = &vmesa->back;
+ FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_FALSE);
+ break;
+ default:
+ FALLBACK(vmesa, VIA_FALLBACK_DRAW_BUFFER, GL_TRUE);
+ return;
+ }
+
+
+ viaXMesaWindowMoved(vmesa);
+
+ /* We want to update the s/w rast state too so that viaSetBuffer()
+ * gets called.
+ */
+ _swrast_DrawBuffer(ctx, mode);
+}
+
+static void viaClearColor(GLcontext *ctx, const GLfloat color[4])
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ GLubyte pcolor[4];
+ CLAMPED_FLOAT_TO_UBYTE(pcolor[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(pcolor[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(pcolor[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(pcolor[3], color[3]);
+ vmesa->ClearColor = viaPackColor(vmesa->viaScreen->bitsPerPixel,
+ pcolor[0], pcolor[1],
+ pcolor[2], pcolor[3]);
+}
+
+#define WRITEMASK_ALPHA_SHIFT 31
+#define WRITEMASK_RED_SHIFT 30
+#define WRITEMASK_GREEN_SHIFT 29
+#define WRITEMASK_BLUE_SHIFT 28
+
+static void viaColorMask(GLcontext *ctx,
+ GLboolean r, GLboolean g,
+ GLboolean b, GLboolean a)
+{
+ struct via_context *vmesa = VIA_CONTEXT( ctx );
+
+ if (VIA_DEBUG & DEBUG_STATE)
+ fprintf(stderr, "%s r(%d) g(%d) b(%d) a(%d)\n", __FUNCTION__, r, g, b, a);
+
+ vmesa->ClearMask = (((!r) << WRITEMASK_RED_SHIFT) |
+ ((!g) << WRITEMASK_GREEN_SHIFT) |
+ ((!b) << WRITEMASK_BLUE_SHIFT) |
+ ((!a) << WRITEMASK_ALPHA_SHIFT));
+}
+
+
+/* =============================================================
+ */
+
+
+/* Using drawXoff like this is incorrect outside of locked regions.
+ * This hardware just isn't capable of private back buffers without
+ * glitches and/or a hefty locking scheme.
+ */
+void viaCalcViewport(GLcontext *ctx)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ const GLfloat *v = ctx->Viewport._WindowMap.m;
+ GLfloat *m = vmesa->ViewportMatrix.m;
+
+ /* See also via_translate_vertex.
+ */
+ m[MAT_SX] = v[MAT_SX];
+ m[MAT_TX] = v[MAT_TX] + SUBPIXEL_X + vmesa->drawXoff;
+ m[MAT_SY] = - v[MAT_SY];
+ m[MAT_TY] = - v[MAT_TY] + vmesa->driDrawable->h + SUBPIXEL_Y;
+ m[MAT_SZ] = v[MAT_SZ] * (1.0 / vmesa->depth_max);
+ m[MAT_TZ] = v[MAT_TZ] * (1.0 / vmesa->depth_max);
+}
+
+static void viaViewport(GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height)
+{
+ /* update size of Mesa/software ancillary buffers */
+ _mesa_ResizeBuffersMESA();
+ viaCalcViewport(ctx);
+}
+
+static void viaDepthRange(GLcontext *ctx,
+ GLclampd nearval, GLclampd farval)
+{
+ viaCalcViewport(ctx);
+}
+
+void viaInitState(GLcontext *ctx)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+
+ vmesa->regCmdB = HC_ACMD_HCmdB;
+ vmesa->regEnable = HC_HenCW_MASK;
+
+ /* Mesa should do this for us:
+ */
+
+ ctx->Driver.BlendEquationSeparate( ctx,
+ ctx->Color.BlendEquationRGB,
+ ctx->Color.BlendEquationA);
+
+ ctx->Driver.BlendFuncSeparate( ctx,
+ ctx->Color.BlendSrcRGB,
+ ctx->Color.BlendDstRGB,
+ ctx->Color.BlendSrcA,
+ ctx->Color.BlendDstA);
+
+ ctx->Driver.Scissor( ctx, ctx->Scissor.X, ctx->Scissor.Y,
+ ctx->Scissor.Width, ctx->Scissor.Height );
+
+ ctx->Driver.DrawBuffer( ctx, ctx->Color.DrawBuffer[0] );
+}
+
+/**
+ * Convert S and T texture coordinate wrap modes to hardware bits.
+ */
+static u_int32_t
+get_wrap_mode( GLenum sWrap, GLenum tWrap )
+{
+ u_int32_t v = 0;
+
+
+ switch( sWrap ) {
+ case GL_REPEAT:
+ v |= HC_HTXnMPMD_Srepeat;
+ break;
+ case GL_CLAMP:
+ case GL_CLAMP_TO_EDGE:
+ v |= HC_HTXnMPMD_Sclamp;
+ break;
+ case GL_MIRRORED_REPEAT:
+ v |= HC_HTXnMPMD_Smirror;
+ break;
+ }
+
+ switch( tWrap ) {
+ case GL_REPEAT:
+ v |= HC_HTXnMPMD_Trepeat;
+ break;
+ case GL_CLAMP:
+ case GL_CLAMP_TO_EDGE:
+ v |= HC_HTXnMPMD_Tclamp;
+ break;
+ case GL_MIRRORED_REPEAT:
+ v |= HC_HTXnMPMD_Tmirror;
+ break;
+ }
+
+ return v;
+}
+
+static u_int32_t
+get_minmag_filter( GLenum min, GLenum mag )
+{
+ u_int32_t v = 0;
+
+ switch (min) {
+ case GL_NEAREST:
+ v = HC_HTXnFLSs_Nearest |
+ HC_HTXnFLTs_Nearest;
+ break;
+ case GL_LINEAR:
+ v = HC_HTXnFLSs_Linear |
+ HC_HTXnFLTs_Linear;
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ v = HC_HTXnFLSs_Nearest |
+ HC_HTXnFLTs_Nearest;
+ v |= HC_HTXnFLDs_Nearest;
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ v = HC_HTXnFLSs_Linear |
+ HC_HTXnFLTs_Linear;
+ v |= HC_HTXnFLDs_Nearest;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ v = HC_HTXnFLSs_Nearest |
+ HC_HTXnFLTs_Nearest;
+ v |= HC_HTXnFLDs_Linear;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ v = HC_HTXnFLSs_Linear |
+ HC_HTXnFLTs_Linear;
+ v |= HC_HTXnFLDs_Linear;
+ break;
+ default:
+ break;
+ }
+
+ switch (mag) {
+ case GL_LINEAR:
+ v |= HC_HTXnFLSe_Linear |
+ HC_HTXnFLTe_Linear;
+ break;
+ case GL_NEAREST:
+ v |= HC_HTXnFLSe_Nearest |
+ HC_HTXnFLTe_Nearest;
+ break;
+ default:
+ break;
+ }
+
+ return v;
+}
+
+
+static GLboolean viaChooseTextureState(GLcontext *ctx)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit0 = &ctx->Texture.Unit[0];
+ struct gl_texture_unit *texUnit1 = &ctx->Texture.Unit[1];
+
+ if (texUnit0->_ReallyEnabled || texUnit1->_ReallyEnabled) {
+ vmesa->regEnable |= HC_HenTXMP_MASK | HC_HenTXCH_MASK | HC_HenTXPP_MASK;
+
+ if (texUnit0->_ReallyEnabled) {
+ struct gl_texture_object *texObj = texUnit0->_Current;
+
+ vmesa->regHTXnTB[0] = get_minmag_filter( texObj->MinFilter,
+ texObj->MagFilter );
+
+ vmesa->regHTXnMPMD[0] &= ~(HC_HTXnMPMD_SMASK | HC_HTXnMPMD_TMASK);
+ vmesa->regHTXnMPMD[0] |= get_wrap_mode( texObj->WrapS,
+ texObj->WrapT );
+
+ vmesa->regHTXnTB[0] &= ~(HC_HTXnTB_TBC_S | HC_HTXnTB_TBC_T);
+ if (texObj->Image[0][texObj->BaseLevel]->Border > 0) {
+ vmesa->regHTXnTB[0] |= (HC_HTXnTB_TBC_S | HC_HTXnTB_TBC_T);
+ vmesa->regHTXnTBC[0] =
+ PACK_COLOR_888(FLOAT_TO_UBYTE(texObj->BorderColor[0]),
+ FLOAT_TO_UBYTE(texObj->BorderColor[1]),
+ FLOAT_TO_UBYTE(texObj->BorderColor[2]));
+ vmesa->regHTXnTRAH[0] = FLOAT_TO_UBYTE(texObj->BorderColor[3]);
+ }
+
+ if (texUnit0->LodBias != 0.0f) {
+ GLuint b = viaComputeLodBias(texUnit0->LodBias);
+ vmesa->regHTXnTB[0] &= ~HC_HTXnFLDs_MASK;
+ vmesa->regHTXnTB[0] |= HC_HTXnFLDs_ConstLOD;
+ vmesa->regHTXnCLOD[0] = (b&0x1f) | (((~b)&0x1f)<<10); /* FIXME */
+ }
+
+ if (!viaTexCombineState( vmesa, texUnit0->_CurrentCombine, 0 )) {
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "viaTexCombineState failed for unit 0\n");
+ return GL_FALSE;
+ }
+ }
+
+ if (texUnit1->_ReallyEnabled) {
+ struct gl_texture_object *texObj = texUnit1->_Current;
+
+ vmesa->regHTXnTB[1] = get_minmag_filter( texObj->MinFilter,
+ texObj->MagFilter );
+ vmesa->regHTXnMPMD[1] &= ~(HC_HTXnMPMD_SMASK | HC_HTXnMPMD_TMASK);
+ vmesa->regHTXnMPMD[1] |= get_wrap_mode( texObj->WrapS,
+ texObj->WrapT );
+
+ vmesa->regHTXnTB[1] &= ~(HC_HTXnTB_TBC_S | HC_HTXnTB_TBC_T);
+ if (texObj->Image[0][texObj->BaseLevel]->Border > 0) {
+ vmesa->regHTXnTB[1] |= (HC_HTXnTB_TBC_S | HC_HTXnTB_TBC_T);
+ vmesa->regHTXnTBC[1] =
+ PACK_COLOR_888(FLOAT_TO_UBYTE(texObj->BorderColor[0]),
+ FLOAT_TO_UBYTE(texObj->BorderColor[1]),
+ FLOAT_TO_UBYTE(texObj->BorderColor[2]));
+ vmesa->regHTXnTRAH[1] = FLOAT_TO_UBYTE(texObj->BorderColor[3]);
+ }
+
+
+ if (texUnit1->LodBias != 0.0f) {
+ GLuint b = viaComputeLodBias(texUnit1->LodBias);
+ vmesa->regHTXnTB[1] &= ~HC_HTXnFLDs_MASK;
+ vmesa->regHTXnTB[1] |= HC_HTXnFLDs_ConstLOD;
+ vmesa->regHTXnCLOD[1] = (b&0x1f) | (((~b)&0x1f)<<10); /* FIXME */
+ }
+
+ if (!viaTexCombineState( vmesa, texUnit1->_CurrentCombine, 1 )) {
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "viaTexCombineState failed for unit 1\n");
+ return GL_FALSE;
+ }
+ }
+ }
+ else {
+ vmesa->regEnable &= ~(HC_HenTXMP_MASK | HC_HenTXCH_MASK |
+ HC_HenTXPP_MASK);
+ }
+
+ return GL_TRUE;
+}
+
+static void viaChooseColorState(GLcontext *ctx)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ GLenum s = ctx->Color.BlendSrcRGB;
+ GLenum d = ctx->Color.BlendDstRGB;
+
+ /* The HW's blending equation is:
+ * (Ca * FCa + Cbias + Cb * FCb) << Cshift
+ */
+
+ if (ctx->Color.BlendEnabled) {
+ vmesa->regEnable |= HC_HenABL_MASK;
+ /* Ca -- always from source color.
+ */
+ vmesa->regHABLCsat = HC_HABLCsat_MASK | HC_HABLCa_OPC | HC_HABLCa_Csrc;
+ /* Aa -- always from source alpha.
+ */
+ vmesa->regHABLAsat = HC_HABLAsat_MASK | HC_HABLAa_OPA | HC_HABLAa_Asrc;
+ /* FCa -- depend on following condition.
+ * FAa -- depend on following condition.
+ */
+ switch (s) {
+ case GL_ZERO:
+ /* (0, 0, 0, 0)
+ */
+ vmesa->regHABLCsat |= HC_HABLFCa_OPC | HC_HABLFCa_HABLRCa;
+ vmesa->regHABLAsat |= HC_HABLFAa_OPA | HC_HABLFAa_HABLFRA;
+ vmesa->regHABLRFCa = 0x0;
+ vmesa->regHABLRAa = 0x0;
+ break;
+ case GL_ONE:
+ /* (1, 1, 1, 1)
+ */
+ vmesa->regHABLCsat |= HC_HABLFCa_InvOPC | HC_HABLFCa_HABLRCa;
+ vmesa->regHABLAsat |= HC_HABLFAa_InvOPA | HC_HABLFAa_HABLFRA;
+ vmesa->regHABLRFCa = 0x0;
+ vmesa->regHABLRAa = 0x0;
+ break;
+ case GL_SRC_COLOR:
+ /* (Rs, Gs, Bs, As)
+ */
+ vmesa->regHABLCsat |= HC_HABLFCa_OPC | HC_HABLFCa_Csrc;
+ vmesa->regHABLAsat |= HC_HABLFAa_OPA | HC_HABLFAa_Asrc;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ /* (1, 1, 1, 1) - (Rs, Gs, Bs, As)
+ */
+ vmesa->regHABLCsat |= HC_HABLFCa_InvOPC | HC_HABLFCa_Csrc;
+ vmesa->regHABLAsat |= HC_HABLFAa_InvOPA | HC_HABLFAa_Asrc;
+ break;
+ case GL_DST_COLOR:
+ /* (Rd, Gd, Bd, Ad)
+ */
+ vmesa->regHABLCsat |= HC_HABLFCa_OPC | HC_HABLFCa_Cdst;
+ vmesa->regHABLAsat |= HC_HABLFAa_OPA | HC_HABLFAa_Adst;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ /* (1, 1, 1, 1) - (Rd, Gd, Bd, Ad)
+ */
+ vmesa->regHABLCsat |= HC_HABLFCa_InvOPC | HC_HABLFCa_Cdst;
+ vmesa->regHABLAsat |= HC_HABLFAa_InvOPA | HC_HABLFAa_Adst;
+ break;
+ case GL_SRC_ALPHA:
+ /* (As, As, As, As)
+ */
+ vmesa->regHABLCsat |= HC_HABLFCa_OPC | HC_HABLFCa_Asrc;
+ vmesa->regHABLAsat |= HC_HABLFAa_OPA | HC_HABLFAa_Asrc;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ /* (1, 1, 1, 1) - (As, As, As, As)
+ */
+ vmesa->regHABLCsat |= HC_HABLFCa_InvOPC | HC_HABLFCa_Asrc;
+ vmesa->regHABLAsat |= HC_HABLFAa_InvOPA | HC_HABLFAa_Asrc;
+ break;
+ case GL_DST_ALPHA:
+ {
+ if (vmesa->viaScreen->bitsPerPixel == 16) {
+ /* (1, 1, 1, 1)
+ */
+ vmesa->regHABLCsat |= (HC_HABLFCa_InvOPC |
+ HC_HABLFCa_HABLRCa);
+ vmesa->regHABLAsat |= (HC_HABLFAa_InvOPA |
+ HC_HABLFAa_HABLFRA);
+ vmesa->regHABLRFCa = 0x0;
+ vmesa->regHABLRAa = 0x0;
+ }
+ else {
+ /* (Ad, Ad, Ad, Ad)
+ */
+ vmesa->regHABLCsat |= HC_HABLFCa_OPC | HC_HABLFCa_Adst;
+ vmesa->regHABLAsat |= HC_HABLFAa_OPA | HC_HABLFAa_Adst;
+ }
+ }
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ {
+ if (vmesa->viaScreen->bitsPerPixel == 16) {
+ /* (1, 1, 1, 1) - (1, 1, 1, 1) = (0, 0, 0, 0)
+ */
+ vmesa->regHABLCsat |= HC_HABLFCa_OPC | HC_HABLFCa_HABLRCa;
+ vmesa->regHABLAsat |= HC_HABLFAa_OPA | HC_HABLFAa_HABLFRA;
+ vmesa->regHABLRFCa = 0x0;
+ vmesa->regHABLRAa = 0x0;
+ }
+ else {
+ /* (1, 1, 1, 1) - (Ad, Ad, Ad, Ad)
+ */
+ vmesa->regHABLCsat |= HC_HABLFCa_InvOPC | HC_HABLFCa_Adst;
+ vmesa->regHABLAsat |= HC_HABLFAa_InvOPA | HC_HABLFAa_Adst;
+ }
+ }
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ {
+ if (vmesa->viaScreen->bitsPerPixel == 16) {
+ /* (f, f, f, 1), f = min(As, 1 - Ad) = min(As, 1 - 1) = 0
+ * So (f, f, f, 1) = (0, 0, 0, 1)
+ */
+ vmesa->regHABLCsat |= HC_HABLFCa_OPC | HC_HABLFCa_HABLRCa;
+ vmesa->regHABLAsat |= (HC_HABLFAa_InvOPA |
+ HC_HABLFAa_HABLFRA);
+ vmesa->regHABLRFCa = 0x0;
+ vmesa->regHABLRAa = 0x0;
+ }
+ else {
+ /* (f, f, f, 1), f = min(As, 1 - Ad)
+ */
+ vmesa->regHABLCsat |= (HC_HABLFCa_OPC |
+ HC_HABLFCa_mimAsrcInvAdst);
+ vmesa->regHABLAsat |= (HC_HABLFAa_InvOPA |
+ HC_HABLFAa_HABLFRA);
+ vmesa->regHABLRFCa = 0x0;
+ vmesa->regHABLRAa = 0x0;
+ }
+ }
+ break;
+ }
+
+ /* Op is add.
+ */
+
+ /* bias is 0.
+ */
+ vmesa->regHABLCsat |= HC_HABLCbias_HABLRCbias;
+ vmesa->regHABLAsat |= HC_HABLAbias_HABLRAbias;
+
+ /* Cb -- always from destination color.
+ */
+ vmesa->regHABLCop = HC_HABLCb_OPC | HC_HABLCb_Cdst;
+ /* Ab -- always from destination alpha.
+ */
+ vmesa->regHABLAop = HC_HABLAb_OPA | HC_HABLAb_Adst;
+ /* FCb -- depend on following condition.
+ */
+ switch (d) {
+ case GL_ZERO:
+ /* (0, 0, 0, 0)
+ */
+ vmesa->regHABLCop |= HC_HABLFCb_OPC | HC_HABLFCb_HABLRCb;
+ vmesa->regHABLAop |= HC_HABLFAb_OPA | HC_HABLFAb_HABLFRA;
+ vmesa->regHABLRFCb = 0x0;
+ vmesa->regHABLRAb = 0x0;
+ break;
+ case GL_ONE:
+ /* (1, 1, 1, 1)
+ */
+ vmesa->regHABLCop |= HC_HABLFCb_InvOPC | HC_HABLFCb_HABLRCb;
+ vmesa->regHABLAop |= HC_HABLFAb_InvOPA | HC_HABLFAb_HABLFRA;
+ vmesa->regHABLRFCb = 0x0;
+ vmesa->regHABLRAb = 0x0;
+ break;
+ case GL_SRC_COLOR:
+ /* (Rs, Gs, Bs, As)
+ */
+ vmesa->regHABLCop |= HC_HABLFCb_OPC | HC_HABLFCb_Csrc;
+ vmesa->regHABLAop |= HC_HABLFAb_OPA | HC_HABLFAb_Asrc;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ /* (1, 1, 1, 1) - (Rs, Gs, Bs, As)
+ */
+ vmesa->regHABLCop |= HC_HABLFCb_InvOPC | HC_HABLFCb_Csrc;
+ vmesa->regHABLAop |= HC_HABLFAb_InvOPA | HC_HABLFAb_Asrc;
+ break;
+ case GL_DST_COLOR:
+ /* (Rd, Gd, Bd, Ad)
+ */
+ vmesa->regHABLCop |= HC_HABLFCb_OPC | HC_HABLFCb_Cdst;
+ vmesa->regHABLAop |= HC_HABLFAb_OPA | HC_HABLFAb_Adst;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ /* (1, 1, 1, 1) - (Rd, Gd, Bd, Ad)
+ */
+ vmesa->regHABLCop |= HC_HABLFCb_InvOPC | HC_HABLFCb_Cdst;
+ vmesa->regHABLAop |= HC_HABLFAb_InvOPA | HC_HABLFAb_Adst;
+ break;
+ case GL_SRC_ALPHA:
+ /* (As, As, As, As)
+ */
+ vmesa->regHABLCop |= HC_HABLFCb_OPC | HC_HABLFCb_Asrc;
+ vmesa->regHABLAop |= HC_HABLFAb_OPA | HC_HABLFAb_Asrc;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ /* (1, 1, 1, 1) - (As, As, As, As)
+ */
+ vmesa->regHABLCop |= HC_HABLFCb_InvOPC | HC_HABLFCb_Asrc;
+ vmesa->regHABLAop |= HC_HABLFAb_InvOPA | HC_HABLFAb_Asrc;
+ break;
+ case GL_DST_ALPHA:
+ {
+ if (vmesa->viaScreen->bitsPerPixel == 16) {
+ /* (1, 1, 1, 1)
+ */
+ vmesa->regHABLCop |= HC_HABLFCb_InvOPC | HC_HABLFCb_HABLRCb;
+ vmesa->regHABLAop |= HC_HABLFAb_InvOPA | HC_HABLFAb_HABLFRA;
+ vmesa->regHABLRFCb = 0x0;
+ vmesa->regHABLRAb = 0x0;
+ }
+ else {
+ /* (Ad, Ad, Ad, Ad)
+ */
+ vmesa->regHABLCop |= HC_HABLFCb_OPC | HC_HABLFCb_Adst;
+ vmesa->regHABLAop |= HC_HABLFAb_OPA | HC_HABLFAb_Adst;
+ }
+ }
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ {
+ if (vmesa->viaScreen->bitsPerPixel == 16) {
+ /* (1, 1, 1, 1) - (1, 1, 1, 1) = (0, 0, 0, 0)
+ */
+ vmesa->regHABLCop |= HC_HABLFCb_OPC | HC_HABLFCb_HABLRCb;
+ vmesa->regHABLAop |= HC_HABLFAb_OPA | HC_HABLFAb_HABLFRA;
+ vmesa->regHABLRFCb = 0x0;
+ vmesa->regHABLRAb = 0x0;
+ }
+ else {
+ /* (1, 1, 1, 1) - (Ad, Ad, Ad, Ad)
+ */
+ vmesa->regHABLCop |= HC_HABLFCb_InvOPC | HC_HABLFCb_Adst;
+ vmesa->regHABLAop |= HC_HABLFAb_InvOPA | HC_HABLFAb_Adst;
+ }
+ }
+ break;
+ default:
+ vmesa->regHABLCop |= HC_HABLFCb_OPC | HC_HABLFCb_HABLRCb;
+ vmesa->regHABLAop |= HC_HABLFAb_OPA | HC_HABLFAb_HABLFRA;
+ vmesa->regHABLRFCb = 0x0;
+ vmesa->regHABLRAb = 0x0;
+ break;
+ }
+
+ if (vmesa->viaScreen->bitsPerPixel <= 16)
+ vmesa->regEnable &= ~HC_HenDT_MASK;
+
+ }
+ else {
+ vmesa->regEnable &= (~HC_HenABL_MASK);
+ }
+
+ if (ctx->Color.AlphaEnabled) {
+ vmesa->regEnable |= HC_HenAT_MASK;
+ vmesa->regHATMD = FLOAT_TO_UBYTE(ctx->Color.AlphaRef) |
+ ((ctx->Color.AlphaFunc - GL_NEVER) << 8);
+ }
+ else {
+ vmesa->regEnable &= (~HC_HenAT_MASK);
+ }
+
+ if (ctx->Color.DitherFlag && (vmesa->viaScreen->bitsPerPixel < 32)) {
+ if (ctx->Color.BlendEnabled) {
+ vmesa->regEnable &= ~HC_HenDT_MASK;
+ }
+ else {
+ vmesa->regEnable |= HC_HenDT_MASK;
+ }
+ }
+
+
+ vmesa->regEnable &= ~HC_HenDT_MASK;
+
+ if (ctx->Color.ColorLogicOpEnabled)
+ vmesa->regHROP = ROP[ctx->Color.LogicOp & 0xF];
+ else
+ vmesa->regHROP = HC_HROP_P;
+
+ vmesa->regHFBBMSKL = PACK_COLOR_888(ctx->Color.ColorMask[0],
+ ctx->Color.ColorMask[1],
+ ctx->Color.ColorMask[2]);
+ vmesa->regHROP |= ctx->Color.ColorMask[3];
+
+ if (ctx->Color.ColorMask[3])
+ vmesa->regEnable |= HC_HenAW_MASK;
+ else
+ vmesa->regEnable &= ~HC_HenAW_MASK;
+}
+
+static void viaChooseFogState(GLcontext *ctx)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+
+ if (ctx->Fog.Enabled) {
+ GLubyte r, g, b, a;
+
+ vmesa->regEnable |= HC_HenFOG_MASK;
+
+ /* Use fog equation 0 (OpenGL's default) & local fog.
+ */
+ vmesa->regHFogLF = 0x0;
+
+ r = (GLubyte)(ctx->Fog.Color[0] * 255.0F);
+ g = (GLubyte)(ctx->Fog.Color[1] * 255.0F);
+ b = (GLubyte)(ctx->Fog.Color[2] * 255.0F);
+ a = (GLubyte)(ctx->Fog.Color[3] * 255.0F);
+ vmesa->regHFogCL = (r << 16) | (g << 8) | b;
+ vmesa->regHFogCH = a;
+ }
+ else {
+ vmesa->regEnable &= ~HC_HenFOG_MASK;
+ }
+}
+
+static void viaChooseDepthState(GLcontext *ctx)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ if (ctx->Depth.Test) {
+ vmesa->regEnable |= HC_HenZT_MASK;
+ if (ctx->Depth.Mask)
+ vmesa->regEnable |= HC_HenZW_MASK;
+ else
+ vmesa->regEnable &= (~HC_HenZW_MASK);
+ vmesa->regHZWTMD = (ctx->Depth.Func - GL_NEVER) << 16;
+
+ }
+ else {
+ vmesa->regEnable &= ~HC_HenZT_MASK;
+
+ /*=* [DBG] racer : can't display cars in car selection menu *=*/
+ /*if (ctx->Depth.Mask)
+ vmesa->regEnable |= HC_HenZW_MASK;
+ else
+ vmesa->regEnable &= (~HC_HenZW_MASK);*/
+ vmesa->regEnable &= (~HC_HenZW_MASK);
+ }
+}
+
+static void viaChooseLineState(GLcontext *ctx)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+
+ if (ctx->Line.StippleFlag) {
+ vmesa->regEnable |= HC_HenLP_MASK;
+ vmesa->regHLP = ctx->Line.StipplePattern;
+ vmesa->regHLPRF = ctx->Line.StippleFactor;
+ }
+ else {
+ vmesa->regEnable &= ~HC_HenLP_MASK;
+ }
+}
+
+static void viaChoosePolygonState(GLcontext *ctx)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+
+#if 0
+ /* Polygon stipple is broken - see via_state.c
+ */
+ if (ctx->Polygon.StippleFlag) {
+ vmesa->regEnable |= HC_HenSP_MASK;
+ }
+ else {
+ vmesa->regEnable &= ~HC_HenSP_MASK;
+ }
+#else
+ FALLBACK(vmesa, VIA_FALLBACK_POLY_STIPPLE,
+ ctx->Polygon.StippleFlag);
+#endif
+
+ if (ctx->Polygon.CullFlag) {
+ vmesa->regEnable |= HC_HenFBCull_MASK;
+ }
+ else {
+ vmesa->regEnable &= ~HC_HenFBCull_MASK;
+ }
+}
+
+static void viaChooseStencilState(GLcontext *ctx)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+
+ if (ctx->Stencil.Enabled) {
+ GLuint temp;
+
+ vmesa->regEnable |= HC_HenST_MASK;
+ temp = (ctx->Stencil.Ref[0] & 0xFF) << HC_HSTREF_SHIFT;
+ temp |= 0xFF << HC_HSTOPMSK_SHIFT;
+ temp |= (ctx->Stencil.ValueMask[0] & 0xFF);
+ vmesa->regHSTREF = temp;
+
+ temp = (ctx->Stencil.Function[0] - GL_NEVER) << 16;
+
+ switch (ctx->Stencil.FailFunc[0]) {
+ case GL_KEEP:
+ temp |= HC_HSTOPSF_KEEP;
+ break;
+ case GL_ZERO:
+ temp |= HC_HSTOPSF_ZERO;
+ break;
+ case GL_REPLACE:
+ temp |= HC_HSTOPSF_REPLACE;
+ break;
+ case GL_INVERT:
+ temp |= HC_HSTOPSF_INVERT;
+ break;
+ case GL_INCR:
+ temp |= HC_HSTOPSF_INCR;
+ break;
+ case GL_DECR:
+ temp |= HC_HSTOPSF_DECR;
+ break;
+ }
+
+ switch (ctx->Stencil.ZFailFunc[0]) {
+ case GL_KEEP:
+ temp |= HC_HSTOPSPZF_KEEP;
+ break;
+ case GL_ZERO:
+ temp |= HC_HSTOPSPZF_ZERO;
+ break;
+ case GL_REPLACE:
+ temp |= HC_HSTOPSPZF_REPLACE;
+ break;
+ case GL_INVERT:
+ temp |= HC_HSTOPSPZF_INVERT;
+ break;
+ case GL_INCR:
+ temp |= HC_HSTOPSPZF_INCR;
+ break;
+ case GL_DECR:
+ temp |= HC_HSTOPSPZF_DECR;
+ break;
+ }
+
+ switch (ctx->Stencil.ZPassFunc[0]) {
+ case GL_KEEP:
+ temp |= HC_HSTOPSPZP_KEEP;
+ break;
+ case GL_ZERO:
+ temp |= HC_HSTOPSPZP_ZERO;
+ break;
+ case GL_REPLACE:
+ temp |= HC_HSTOPSPZP_REPLACE;
+ break;
+ case GL_INVERT:
+ temp |= HC_HSTOPSPZP_INVERT;
+ break;
+ case GL_INCR:
+ temp |= HC_HSTOPSPZP_INCR;
+ break;
+ case GL_DECR:
+ temp |= HC_HSTOPSPZP_DECR;
+ break;
+ }
+ vmesa->regHSTMD = temp;
+ }
+ else {
+ vmesa->regEnable &= ~HC_HenST_MASK;
+ }
+}
+
+
+
+static void viaChooseTriangle(GLcontext *ctx)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+
+ if (ctx->Polygon.CullFlag == GL_TRUE) {
+ switch (ctx->Polygon.CullFaceMode) {
+ case GL_FRONT:
+ if (ctx->Polygon.FrontFace == GL_CCW)
+ vmesa->regCmdB |= HC_HBFace_MASK;
+ else
+ vmesa->regCmdB &= ~HC_HBFace_MASK;
+ break;
+ case GL_BACK:
+ if (ctx->Polygon.FrontFace == GL_CW)
+ vmesa->regCmdB |= HC_HBFace_MASK;
+ else
+ vmesa->regCmdB &= ~HC_HBFace_MASK;
+ break;
+ case GL_FRONT_AND_BACK:
+ return;
+ }
+ }
+}
+
+void viaValidateState( GLcontext *ctx )
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+
+ if (vmesa->newState & _NEW_TEXTURE) {
+ GLboolean ok = (viaChooseTextureState(ctx) &&
+ viaUpdateTextureState(ctx));
+
+ FALLBACK(vmesa, VIA_FALLBACK_TEXTURE, !ok);
+ }
+
+ if (vmesa->newState & _NEW_COLOR)
+ viaChooseColorState(ctx);
+
+ if (vmesa->newState & _NEW_DEPTH)
+ viaChooseDepthState(ctx);
+
+ if (vmesa->newState & _NEW_FOG)
+ viaChooseFogState(ctx);
+
+ if (vmesa->newState & _NEW_LINE)
+ viaChooseLineState(ctx);
+
+ if (vmesa->newState & (_NEW_POLYGON | _NEW_POLYGONSTIPPLE)) {
+ viaChoosePolygonState(ctx);
+ viaChooseTriangle(ctx);
+ }
+
+ if ((vmesa->newState & _NEW_STENCIL) && vmesa->have_hw_stencil)
+ viaChooseStencilState(ctx);
+
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ vmesa->regEnable |= HC_HenCS_MASK;
+ else
+ vmesa->regEnable &= ~HC_HenCS_MASK;
+
+ if (ctx->Point.SmoothFlag ||
+ ctx->Line.SmoothFlag ||
+ ctx->Polygon.SmoothFlag)
+ vmesa->regEnable |= HC_HenAA_MASK;
+ else
+ vmesa->regEnable &= ~HC_HenAA_MASK;
+
+ vmesa->newEmitState |= vmesa->newState;
+ vmesa->newState = 0;
+}
+
+static void viaInvalidateState(GLcontext *ctx, GLuint newState)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+
+ VIA_FINISH_PRIM( vmesa );
+ vmesa->newState |= newState;
+
+ _swrast_InvalidateState(ctx, newState);
+ _swsetup_InvalidateState(ctx, newState);
+ _ac_InvalidateState(ctx, newState);
+ _tnl_InvalidateState(ctx, newState);
+}
+
+void viaInitStateFuncs(GLcontext *ctx)
+{
+ /* Callbacks for internal Mesa events.
+ */
+ ctx->Driver.UpdateState = viaInvalidateState;
+
+ /* API callbacks
+ */
+ ctx->Driver.BlendEquationSeparate = viaBlendEquationSeparate;
+ ctx->Driver.BlendFuncSeparate = viaBlendFuncSeparate;
+ ctx->Driver.ClearColor = viaClearColor;
+ ctx->Driver.ColorMask = viaColorMask;
+ ctx->Driver.DrawBuffer = viaDrawBuffer;
+ ctx->Driver.RenderMode = viaRenderMode;
+ ctx->Driver.Scissor = viaScissor;
+ ctx->Driver.DepthRange = viaDepthRange;
+ ctx->Driver.Viewport = viaViewport;
+ ctx->Driver.Enable = viaEnable;
+
+ /* Pixel path fallbacks.
+ */
+ ctx->Driver.Accum = _swrast_Accum;
+ ctx->Driver.Bitmap = _swrast_Bitmap;
+ ctx->Driver.CopyPixels = _swrast_CopyPixels;
+ ctx->Driver.DrawPixels = _swrast_DrawPixels;
+ ctx->Driver.ReadPixels = _swrast_ReadPixels;
+ ctx->Driver.ResizeBuffers = viaReAllocateBuffers;
+
+ /* Swrast hooks for imaging extensions:
+ */
+ ctx->Driver.CopyColorTable = _swrast_CopyColorTable;
+ ctx->Driver.CopyColorSubTable = _swrast_CopyColorSubTable;
+ ctx->Driver.CopyConvolutionFilter1D = _swrast_CopyConvolutionFilter1D;
+ ctx->Driver.CopyConvolutionFilter2D = _swrast_CopyConvolutionFilter2D;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_state.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_state.h
new file mode 100644
index 000000000..065ec57d3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_state.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+#ifndef _VIA_STATE_H
+#define _VIA_STATE_H
+
+#include "via_context.h"
+
+extern void viaInitState(GLcontext *ctx);
+extern void viaInitStateFuncs(GLcontext *ctx);
+extern void viaCalcViewport(GLcontext *ctx);
+extern void viaValidateState(GLcontext *ctx);
+extern void viaEmitState(struct via_context *vmesa);
+
+extern void viaFallback(struct via_context *vmesa, GLuint bit, GLboolean mode);
+#define FALLBACK(vmesa, bit, mode) viaFallback(vmesa, bit, mode)
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_tex.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_tex.c
new file mode 100644
index 000000000..c308339f2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_tex.c
@@ -0,0 +1,970 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "glheader.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "enums.h"
+#include "colortab.h"
+#include "convolve.h"
+#include "context.h"
+#include "simple_list.h"
+#include "texcompress.h"
+#include "texformat.h"
+#include "texobj.h"
+#include "texstore.h"
+
+#include "mm.h"
+#include "via_context.h"
+#include "via_fb.h"
+#include "via_tex.h"
+#include "via_state.h"
+#include "via_ioctl.h"
+#include "via_3d_reg.h"
+
+static const struct gl_texture_format *
+viaChooseTexFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type )
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ const GLboolean do32bpt = ( vmesa->viaScreen->bitsPerPixel == 32
+/* && vmesa->viaScreen->textureSize > 4*1024*1024 */
+ );
+
+
+ switch ( internalFormat ) {
+ case 4:
+ case GL_RGBA:
+ case GL_COMPRESSED_RGBA:
+ if ( format == GL_BGRA ) {
+ if ( type == GL_UNSIGNED_INT_8_8_8_8_REV ||
+ type == GL_UNSIGNED_BYTE ) {
+ return &_mesa_texformat_argb8888;
+ }
+ else if ( type == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
+ return &_mesa_texformat_argb4444;
+ }
+ else if ( type == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
+ return &_mesa_texformat_argb1555;
+ }
+ }
+ else if ( type == GL_UNSIGNED_BYTE ||
+ type == GL_UNSIGNED_INT_8_8_8_8_REV ||
+ type == GL_UNSIGNED_INT_8_8_8_8 ) {
+ return &_mesa_texformat_argb8888;
+ }
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+
+ case 3:
+ case GL_RGB:
+ case GL_COMPRESSED_RGB:
+ if ( format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5 ) {
+ return &_mesa_texformat_rgb565;
+ }
+ else if ( type == GL_UNSIGNED_BYTE ) {
+ return &_mesa_texformat_argb8888;
+ }
+ return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return &_mesa_texformat_argb8888;
+
+ case GL_RGBA4:
+ case GL_RGBA2:
+ return &_mesa_texformat_argb4444;
+
+ case GL_RGB5_A1:
+ return &_mesa_texformat_argb1555;
+
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ return &_mesa_texformat_argb8888;
+
+ case GL_RGB5:
+ case GL_RGB4:
+ case GL_R3_G3_B2:
+ return &_mesa_texformat_rgb565;
+
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ case GL_COMPRESSED_ALPHA:
+ return &_mesa_texformat_a8;
+
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ case GL_COMPRESSED_LUMINANCE:
+ return &_mesa_texformat_l8;
+
+ 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_COMPRESSED_LUMINANCE_ALPHA:
+ return &_mesa_texformat_al88;
+
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case GL_COMPRESSED_INTENSITY:
+ return &_mesa_texformat_i8;
+
+ case GL_YCBCR_MESA:
+ if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
+ type == GL_UNSIGNED_BYTE)
+ return &_mesa_texformat_ycbcr;
+ else
+ return &_mesa_texformat_ycbcr_rev;
+
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ return &_mesa_texformat_rgb_fxt1;
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ return &_mesa_texformat_rgba_fxt1;
+
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgb_dxt1;
+
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgba_dxt1;
+
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ return &_mesa_texformat_rgba_dxt3;
+
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ return &_mesa_texformat_rgba_dxt5;
+
+ 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:
+ return &_mesa_texformat_ci8;
+
+ default:
+ fprintf(stderr, "unexpected texture format %s in %s\n",
+ _mesa_lookup_enum_by_nr(internalFormat),
+ __FUNCTION__);
+ return NULL;
+ }
+
+ return NULL; /* never get here */
+}
+
+static int logbase2(int n)
+{
+ GLint i = 1;
+ GLint log2 = 0;
+
+ while (n > i) {
+ i *= 2;
+ log2++;
+ }
+
+ return log2;
+}
+
+static const char *get_memtype_name( GLint memType )
+{
+ static const char *names[] = {
+ "VIA_MEM_VIDEO",
+ "VIA_MEM_AGP",
+ "VIA_MEM_SYSTEM",
+ "VIA_MEM_MIXED",
+ "VIA_MEM_UNKNOWN"
+ };
+
+ return names[memType];
+}
+
+
+static GLboolean viaMoveTexBuffers( struct via_context *vmesa,
+ struct via_tex_buffer **buffers,
+ GLuint nr,
+ GLint newMemType )
+{
+ struct via_tex_buffer *newTexBuf[VIA_MAX_TEXLEVELS];
+ GLint i;
+
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s to %s\n",
+ __FUNCTION__,
+ get_memtype_name(newMemType));
+
+ memset(newTexBuf, 0, sizeof(newTexBuf));
+
+ /* First do all the allocations (or fail):
+ */
+ for (i = 0; i < nr; i++) {
+ if (buffers[i]->memType != newMemType) {
+
+ /* Don't allow uploads in a thrash state. Should try and
+ * catch this earlier.
+ */
+ if (vmesa->thrashing && newMemType != VIA_MEM_SYSTEM)
+ goto cleanup;
+
+ newTexBuf[i] = via_alloc_texture(vmesa,
+ buffers[i]->size,
+ newMemType);
+ if (!newTexBuf[i])
+ goto cleanup;
+ }
+ }
+
+
+ /* Now copy all the image data and free the old texture memory.
+ */
+ for (i = 0; i < nr; i++) {
+ if (newTexBuf[i]) {
+ memcpy(newTexBuf[i]->bufAddr,
+ buffers[i]->bufAddr,
+ buffers[i]->size);
+
+ newTexBuf[i]->image = buffers[i]->image;
+ newTexBuf[i]->image->texMem = newTexBuf[i];
+ newTexBuf[i]->image->image.Data = newTexBuf[i]->bufAddr;
+ via_free_texture(vmesa, buffers[i]);
+ }
+ }
+
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s - success\n", __FUNCTION__);
+
+ return GL_TRUE;
+
+ cleanup:
+ /* Release any allocations made prior to failure:
+ */
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s - failed\n", __FUNCTION__);
+
+ for (i = 0; i < nr; i++) {
+ if (newTexBuf[i]) {
+ via_free_texture(vmesa, newTexBuf[i]);
+ }
+ }
+
+ return GL_FALSE;
+}
+
+
+static GLboolean viaMoveTexObject( struct via_context *vmesa,
+ struct via_texture_object *viaObj,
+ GLint newMemType )
+{
+ struct via_texture_image **viaImage =
+ (struct via_texture_image **)&viaObj->obj.Image[0][0];
+ struct via_tex_buffer *buffers[VIA_MAX_TEXLEVELS];
+ GLuint i, nr = 0;
+
+ for (i = viaObj->firstLevel; i <= viaObj->lastLevel; i++)
+ buffers[nr++] = viaImage[i]->texMem;
+
+ if (viaMoveTexBuffers( vmesa, &buffers[0], nr, newMemType )) {
+ viaObj->memType = newMemType;
+ return GL_TRUE;
+ }
+
+ return GL_FALSE;
+}
+
+
+
+static GLboolean viaSwapInTexObject( struct via_context *vmesa,
+ struct via_texture_object *viaObj )
+{
+ const struct via_texture_image *baseImage =
+ (struct via_texture_image *)viaObj->obj.Image[0][viaObj->obj.BaseLevel];
+
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (baseImage->texMem->memType != VIA_MEM_SYSTEM)
+ return viaMoveTexObject( vmesa, viaObj, baseImage->texMem->memType );
+
+ return (viaMoveTexObject( vmesa, viaObj, VIA_MEM_AGP ) ||
+ viaMoveTexObject( vmesa, viaObj, VIA_MEM_VIDEO ));
+}
+
+
+/* This seems crude, but it asks a fairly pertinent question and gives
+ * an accurate answer:
+ */
+static GLboolean viaIsTexMemLow( struct via_context *vmesa,
+ GLuint heap )
+{
+ struct via_tex_buffer *buf = via_alloc_texture(vmesa, 512 * 1024, heap );
+ if (!buf)
+ return GL_TRUE;
+
+ via_free_texture(vmesa, buf);
+ return GL_FALSE;
+}
+
+
+/* Speculatively move texture images which haven't been used in a
+ * while back to system memory.
+ *
+ * TODO: only do this when texture memory is low.
+ *
+ * TODO: use dma.
+ *
+ * TODO: keep the fb/agp version hanging around and use the local
+ * version as backing store, so re-upload might be avoided.
+ *
+ * TODO: do this properly in the kernel...
+ */
+GLboolean viaSwapOutWork( struct via_context *vmesa )
+{
+ struct via_tex_buffer *s, *tmp;
+ GLuint done = 0;
+ GLuint heap, target;
+
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s VID %d AGP %d SYS %d\n", __FUNCTION__,
+ vmesa->total_alloc[VIA_MEM_VIDEO],
+ vmesa->total_alloc[VIA_MEM_AGP],
+ vmesa->total_alloc[VIA_MEM_SYSTEM]);
+
+
+ for (heap = VIA_MEM_VIDEO; heap <= VIA_MEM_AGP; heap++) {
+ GLuint nr = 0, sz = 0;
+
+ if (vmesa->thrashing) {
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "Heap %d: trash flag\n", heap);
+ target = 1*1024*1024;
+ }
+ else if (viaIsTexMemLow(vmesa, heap)) {
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "Heap %d: low memory\n", heap);
+ target = 64*1024;
+ }
+ else {
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "Heap %d: nothing to do\n", heap);
+ continue;
+ }
+
+ foreach_s( s, tmp, &vmesa->tex_image_list[heap] ) {
+ if (s->lastUsed < vmesa->lastSwap[1]) {
+ struct via_texture_object *viaObj =
+ (struct via_texture_object *) s->image->image.TexObject;
+
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr,
+ "back copy tex sz %d, lastUsed %d lastSwap %d\n",
+ s->size, s->lastUsed, vmesa->lastSwap[1]);
+
+ if (viaMoveTexBuffers( vmesa, &s, 1, VIA_MEM_SYSTEM )) {
+ viaObj->memType = VIA_MEM_MIXED;
+ done += s->size;
+ }
+ else {
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "Failed to back copy texture!\n");
+ sz += s->size;
+ }
+ }
+ else {
+ nr ++;
+ sz += s->size;
+ }
+
+ if (done > target) {
+ vmesa->thrashing = GL_FALSE; /* might not get set otherwise? */
+ return GL_TRUE;
+ }
+ }
+
+ assert(sz == vmesa->total_alloc[heap]);
+
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "Heap %d: nr %d tot sz %d\n", heap, nr, sz);
+ }
+
+
+ return done != 0;
+}
+
+
+
+/* Basically, just collect the image dimensions and addresses for each
+ * image and update the texture object state accordingly.
+ */
+static GLboolean viaSetTexImages(GLcontext *ctx,
+ struct gl_texture_object *texObj)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ struct via_texture_object *viaObj = (struct via_texture_object *)texObj;
+ const struct via_texture_image *baseImage =
+ (struct via_texture_image *)texObj->Image[0][texObj->BaseLevel];
+ GLint firstLevel, lastLevel, numLevels;
+ GLuint texFormat;
+ GLint w, h, p;
+ GLint i, j = 0, k = 0, l = 0, m = 0;
+ GLuint texBase;
+ GLuint basH = 0;
+ GLuint widthExp = 0;
+ GLuint heightExp = 0;
+
+ switch (baseImage->image.TexFormat->MesaFormat) {
+ case MESA_FORMAT_ARGB8888:
+ texFormat = HC_HTXnFM_ARGB8888;
+ break;
+ case MESA_FORMAT_ARGB4444:
+ texFormat = HC_HTXnFM_ARGB4444;
+ break;
+ case MESA_FORMAT_RGB565:
+ texFormat = HC_HTXnFM_RGB565;
+ break;
+ case MESA_FORMAT_ARGB1555:
+ texFormat = HC_HTXnFM_ARGB1555;
+ break;
+ case MESA_FORMAT_RGB888:
+ texFormat = HC_HTXnFM_ARGB0888;
+ break;
+ case MESA_FORMAT_L8:
+ texFormat = HC_HTXnFM_L8;
+ break;
+ case MESA_FORMAT_I8:
+ texFormat = HC_HTXnFM_T8;
+ break;
+ case MESA_FORMAT_CI8:
+ texFormat = HC_HTXnFM_Index8;
+ break;
+ case MESA_FORMAT_AL88:
+ texFormat = HC_HTXnFM_AL88;
+ break;
+ case MESA_FORMAT_A8:
+ texFormat = HC_HTXnFM_A8;
+ break;
+ default:
+ _mesa_problem(vmesa->glCtx, "Bad texture format in viaSetTexImages");
+ return GL_FALSE;
+ }
+
+ /* Compute which mipmap levels we really want to send to the hardware.
+ * This depends on the base image size, GL_TEXTURE_MIN_LOD,
+ * GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
+ * Yes, this looks overly complicated, but it's all needed.
+ */
+ if (texObj->MinFilter == GL_LINEAR || texObj->MinFilter == GL_NEAREST) {
+ firstLevel = lastLevel = texObj->BaseLevel;
+ }
+ else {
+ firstLevel = texObj->BaseLevel + (GLint)(texObj->MinLod + 0.5);
+ firstLevel = MAX2(firstLevel, texObj->BaseLevel);
+ lastLevel = texObj->BaseLevel + (GLint)(texObj->MaxLod + 0.5);
+ lastLevel = MAX2(lastLevel, texObj->BaseLevel);
+ lastLevel = MIN2(lastLevel, texObj->BaseLevel + baseImage->image.MaxLog2);
+ lastLevel = MIN2(lastLevel, texObj->MaxLevel);
+ lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
+ }
+
+ numLevels = lastLevel - firstLevel + 1;
+
+ /* save these values, check if they effect the residency of the
+ * texture:
+ */
+ if (viaObj->firstLevel != firstLevel ||
+ viaObj->lastLevel != lastLevel) {
+ viaObj->firstLevel = firstLevel;
+ viaObj->lastLevel = lastLevel;
+ viaObj->memType = VIA_MEM_MIXED;
+ }
+
+ if (VIA_DEBUG & DEBUG_TEXTURE & 0)
+ fprintf(stderr, "%s, current memType: %s\n",
+ __FUNCTION__,
+ get_memtype_name(viaObj->memType));
+
+
+ if (viaObj->memType == VIA_MEM_MIXED ||
+ viaObj->memType == VIA_MEM_SYSTEM) {
+ if (!viaSwapInTexObject(vmesa, viaObj)) {
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ if (!vmesa->thrashing)
+ fprintf(stderr, "Thrashing flag set for frame %d\n",
+ vmesa->swap_count);
+ vmesa->thrashing = GL_TRUE;
+ return GL_FALSE;
+ }
+ }
+
+ if (viaObj->memType == VIA_MEM_AGP)
+ viaObj->regTexFM = (HC_SubA_HTXnFM << 24) | HC_HTXnLoc_AGP | texFormat;
+ else
+ viaObj->regTexFM = (HC_SubA_HTXnFM << 24) | HC_HTXnLoc_Local | texFormat;
+
+
+ for (i = 0; i < numLevels; i++) {
+ struct via_texture_image *viaImage =
+ (struct via_texture_image *)texObj->Image[0][firstLevel + i];
+
+ w = viaImage->image.WidthLog2;
+ h = viaImage->image.HeightLog2;
+ p = viaImage->pitchLog2;
+
+ assert(viaImage->texMem->memType == viaObj->memType);
+
+ texBase = viaImage->texMem->texBase;
+ if (!texBase) {
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s: no texBase[%d]\n", __FUNCTION__, i);
+ return GL_FALSE;
+ }
+
+ /* Image has to remain resident until the coming fence is retired.
+ */
+ move_to_head( &vmesa->tex_image_list[viaImage->texMem->memType],
+ viaImage->texMem );
+ viaImage->texMem->lastUsed = vmesa->lastBreadcrumbWrite;
+
+
+ viaObj->regTexBaseAndPitch[i].baseL =
+ ((HC_SubA_HTXnL0BasL + i) << 24) | (texBase & 0xFFFFFF);
+
+ viaObj->regTexBaseAndPitch[i].pitchLog2 =
+ ((HC_SubA_HTXnL0Pit + i) << 24) | (p << 20);
+
+
+ /* The base high bytes for each 3 levels are packed
+ * together into one register:
+ */
+ j = i / 3;
+ k = 3 - (i % 3);
+ basH |= ((texBase & 0xFF000000) >> (k << 3));
+ if (k == 1) {
+ viaObj->regTexBaseH[j] = ((j + HC_SubA_HTXnL012BasH) << 24) | basH;
+ basH = 0;
+ }
+
+ /* Likewise, sets of 6 log2width and log2height values are
+ * packed into individual registers:
+ */
+ l = i / 6;
+ m = i % 6;
+ widthExp |= (((GLuint)w & 0xF) << (m << 2));
+ heightExp |= (((GLuint)h & 0xF) << (m << 2));
+ if (m == 5) {
+ viaObj->regTexWidthLog2[l] =
+ (l + HC_SubA_HTXnL0_5WE) << 24 | widthExp;
+ viaObj->regTexHeightLog2[l] =
+ (l + HC_SubA_HTXnL0_5HE) << 24 | heightExp;
+ widthExp = 0;
+ heightExp = 0;
+ }
+ if (w) w--;
+ if (h) h--;
+ if (p) p--;
+ }
+
+ if (k != 1) {
+ viaObj->regTexBaseH[j] = ((j + HC_SubA_HTXnL012BasH) << 24) | basH;
+ }
+ if (m != 5) {
+ viaObj->regTexWidthLog2[l] = (l + HC_SubA_HTXnL0_5WE) << 24 | widthExp;
+ viaObj->regTexHeightLog2[l] = (l + HC_SubA_HTXnL0_5HE) << 24 | heightExp;
+ }
+
+ return GL_TRUE;
+}
+
+
+GLboolean viaUpdateTextureState( GLcontext *ctx )
+{
+ struct gl_texture_unit *texUnit = ctx->Texture.Unit;
+ GLuint i;
+
+ for (i = 0; i < 2; i++) {
+ if (texUnit[i]._ReallyEnabled == TEXTURE_2D_BIT ||
+ texUnit[i]._ReallyEnabled == TEXTURE_1D_BIT) {
+
+ if (!viaSetTexImages(ctx, texUnit[i]._Current))
+ return GL_FALSE;
+ }
+ else if (texUnit[i]._ReallyEnabled) {
+ return GL_FALSE;
+ }
+ }
+
+ return GL_TRUE;
+}
+
+
+
+
+
+
+
+
+static void viaTexImage(GLcontext *ctx,
+ GLint dims,
+ GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ GLint postConvWidth = width;
+ GLint postConvHeight = height;
+ GLint texelBytes, sizeInBytes;
+ struct via_texture_object *viaObj = (struct via_texture_object *)texObj;
+ struct via_texture_image *viaImage = (struct via_texture_image *)texImage;
+ int heaps[3], nheaps, i;
+
+ if (!is_empty_list(&vmesa->freed_tex_buffers)) {
+ viaCheckBreadcrumb(vmesa, 0);
+ via_release_pending_textures(vmesa);
+ }
+
+ if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) {
+ _mesa_adjust_image_for_convolution(ctx, dims, &postConvWidth,
+ &postConvHeight);
+ }
+
+ /* choose the texture format */
+ texImage->TexFormat = viaChooseTexFormat(ctx, internalFormat,
+ format, type);
+
+ assert(texImage->TexFormat);
+
+ if (dims == 1) {
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel1D;
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel1Df;
+ }
+ else {
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel2D;
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df;
+ }
+ texelBytes = texImage->TexFormat->TexelBytes;
+
+
+ /* Minimum pitch of 32 bytes */
+ if (postConvWidth * texelBytes < 32) {
+ postConvWidth = 32 / texelBytes;
+ texImage->RowStride = postConvWidth;
+ }
+
+ assert(texImage->RowStride == postConvWidth);
+ viaImage->pitchLog2 = logbase2(postConvWidth * texelBytes);
+
+ /* allocate memory */
+ if (texImage->IsCompressed)
+ sizeInBytes = texImage->CompressedSize;
+ else
+ sizeInBytes = postConvWidth * postConvHeight * texelBytes;
+
+
+ /* Attempt to allocate texture memory directly, otherwise use main
+ * memory and this texture will always be a fallback. FIXME!
+ *
+ * TODO: make room in agp if this fails.
+ * TODO: use fb ram for textures as well.
+ */
+
+
+ switch (viaObj->memType) {
+ case VIA_MEM_UNKNOWN:
+ heaps[0] = VIA_MEM_AGP;
+ heaps[1] = VIA_MEM_VIDEO;
+ heaps[2] = VIA_MEM_SYSTEM;
+ nheaps = 3;
+ break;
+ case VIA_MEM_AGP:
+ case VIA_MEM_VIDEO:
+ heaps[0] = viaObj->memType;
+ heaps[1] = VIA_MEM_SYSTEM;
+ nheaps = 2;
+ break;
+ case VIA_MEM_MIXED:
+ case VIA_MEM_SYSTEM:
+ default:
+ heaps[0] = VIA_MEM_SYSTEM;
+ nheaps = 1;
+ break;
+ }
+
+ for (i = 0; i < nheaps && !viaImage->texMem; i++) {
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "try %s (obj %s)\n", get_memtype_name(heaps[i]),
+ get_memtype_name(viaObj->memType));
+ viaImage->texMem = via_alloc_texture(vmesa, sizeInBytes, heaps[i]);
+ }
+
+ if (!viaImage->texMem) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
+ return;
+ }
+
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "upload %d bytes to %s\n", sizeInBytes,
+ get_memtype_name(viaImage->texMem->memType));
+
+ viaImage->texMem->image = viaImage;
+ texImage->Data = viaImage->texMem->bufAddr;
+
+ if (viaObj->memType == VIA_MEM_UNKNOWN)
+ viaObj->memType = viaImage->texMem->memType;
+ else if (viaObj->memType != viaImage->texMem->memType)
+ viaObj->memType = VIA_MEM_MIXED;
+
+ if (VIA_DEBUG & DEBUG_TEXTURE)
+ fprintf(stderr, "%s, obj %s, image : %s\n",
+ __FUNCTION__,
+ get_memtype_name(viaObj->memType),
+ get_memtype_name(viaImage->texMem->memType));
+
+ vmesa->clearTexCache = 1;
+
+ pixels = _mesa_validate_pbo_teximage(ctx, dims, width, height, 1,
+ format, type,
+ pixels, packing, "glTexImage");
+ if (!pixels) {
+ /* Note: we check for a NULL image pointer here, _after_ we allocated
+ * memory for the texture. That's what the GL spec calls for.
+ */
+ return;
+ }
+ else {
+ GLint dstRowStride, dstImageStride = 0;
+ GLboolean success;
+ if (texImage->IsCompressed) {
+ dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,width);
+ }
+ else {
+ dstRowStride = postConvWidth * texImage->TexFormat->TexelBytes;
+ }
+ ASSERT(texImage->TexFormat->StoreImage);
+ success = texImage->TexFormat->StoreImage(ctx, dims, texImage->Format,
+ texImage->TexFormat,
+ texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride, dstImageStride,
+ width, height, 1,
+ format, type, pixels, packing);
+ if (!success) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
+ }
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target,
+ &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
+ texObj);
+ }
+
+ _mesa_unmap_teximage_pbo(ctx, packing);
+}
+
+static void viaTexImage2D(GLcontext *ctx,
+ GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ viaTexImage( ctx, 2, target, level,
+ internalFormat, width, height, border,
+ format, type, pixels,
+ packing, texObj, texImage );
+}
+
+static void viaTexSubImage2D(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)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+
+ viaWaitIdle(vmesa, GL_TRUE);
+ vmesa->clearTexCache = 1;
+
+ _mesa_store_texsubimage2d(ctx, target, level, xoffset, yoffset, width,
+ height, format, type, pixels, packing, texObj,
+ texImage);
+}
+
+static void viaTexImage1D(GLcontext *ctx,
+ GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ viaTexImage( ctx, 1, target, level,
+ internalFormat, width, 1, border,
+ format, type, pixels,
+ packing, texObj, texImage );
+}
+
+static void viaTexSubImage1D(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)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+
+ viaWaitIdle(vmesa, GL_TRUE);
+ vmesa->clearTexCache = 1;
+
+ _mesa_store_texsubimage1d(ctx, target, level, xoffset, width,
+ format, type, pixels, packing, texObj,
+ texImage);
+}
+
+
+
+static GLboolean viaIsTextureResident(GLcontext *ctx,
+ struct gl_texture_object *texObj)
+{
+ struct via_texture_object *viaObj =
+ (struct via_texture_object *)texObj;
+
+ return (viaObj->memType == VIA_MEM_AGP ||
+ viaObj->memType == VIA_MEM_VIDEO);
+}
+
+
+
+static struct gl_texture_image *viaNewTextureImage( GLcontext *ctx )
+{
+ (void) ctx;
+ return (struct gl_texture_image *)CALLOC_STRUCT(via_texture_image);
+}
+
+
+static struct gl_texture_object *viaNewTextureObject( GLcontext *ctx,
+ GLuint name,
+ GLenum target )
+{
+ struct via_texture_object *obj = CALLOC_STRUCT(via_texture_object);
+
+ _mesa_initialize_texture_object(&obj->obj, name, target);
+ (void) ctx;
+
+ obj->memType = VIA_MEM_UNKNOWN;
+
+ return &obj->obj;
+}
+
+
+static void viaFreeTextureImageData( GLcontext *ctx,
+ struct gl_texture_image *texImage )
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ struct via_texture_image *image = (struct via_texture_image *)texImage;
+
+ if (image->texMem) {
+ via_free_texture(vmesa, image->texMem);
+ image->texMem = NULL;
+ }
+
+ texImage->Data = NULL;
+}
+
+
+
+
+void viaInitTextureFuncs(struct dd_function_table * functions)
+{
+ functions->ChooseTextureFormat = viaChooseTexFormat;
+ functions->TexImage1D = viaTexImage1D;
+ functions->TexImage2D = viaTexImage2D;
+ functions->TexSubImage1D = viaTexSubImage1D;
+ functions->TexSubImage2D = viaTexSubImage2D;
+
+ functions->NewTextureObject = viaNewTextureObject;
+ functions->NewTextureImage = viaNewTextureImage;
+ functions->DeleteTexture = _mesa_delete_texture_object;
+ functions->FreeTexImageData = viaFreeTextureImageData;
+
+#if 0 && defined( USE_SSE_ASM )
+ /*
+ * XXX this code is disabled for now because the via_sse_memcpy()
+ * routine causes segfaults with flightgear.
+ * See Mesa3d-dev mail list messages from 7/15/2005 for details.
+ * Note that this function is currently disabled in via_tris.c too.
+ */
+ if (getenv("VIA_NO_SSE"))
+ functions->TextureMemCpy = _mesa_memcpy;
+ else
+ functions->TextureMemCpy = via_sse_memcpy;
+#else
+ functions->TextureMemCpy = _mesa_memcpy;
+#endif
+
+ functions->UpdateTexturePalette = 0;
+ functions->IsTextureResident = viaIsTextureResident;
+}
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_tex.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_tex.h
new file mode 100644
index 000000000..73cfa91ad
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_tex.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+
+#ifndef _VIATEX_H
+#define _VIATEX_H
+
+#include "mtypes.h"
+
+struct via_context;
+
+GLboolean viaUpdateTextureState(GLcontext *ctx);
+void viaInitTextureFuncs(struct dd_function_table * functions);
+GLboolean viaSwapOutWork( struct via_context *vmesa );
+
+#if defined( USE_SSE_ASM )
+void via_sse_memcpy( void *to, const void *from, size_t sz );
+#endif /* defined( USE_SSE_ASM ) */
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_texcombine.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_texcombine.c
new file mode 100644
index 000000000..d604457bf
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_texcombine.c
@@ -0,0 +1,424 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file via_texcombine.c
+ * Calculate texture combine hardware state.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include <stdio.h>
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "colormac.h"
+#include "enums.h"
+
+#include "via_context.h"
+#include "via_state.h"
+#include "via_tex.h"
+#include "via_3d_reg.h"
+
+
+#define VIA_USE_ALPHA (HC_XTC_Adif - HC_XTC_Dif)
+
+#define INPUT_A_SHIFT 14
+#define INPUT_B_SHIFT 7
+#define INPUT_C_SHIFT 0
+#define INPUT_CBias_SHIFT 14
+
+#define CONST_ONE (HC_XTC_0 | HC_XTC_InvTOPC)
+
+static const unsigned color_operand_modifier[4] = {
+ 0,
+ HC_XTC_InvTOPC,
+ VIA_USE_ALPHA,
+ VIA_USE_ALPHA | HC_XTC_InvTOPC,
+};
+
+static const unsigned alpha_operand_modifier[2] = {
+ 0, HC_XTA_InvTOPA
+};
+
+static const unsigned bias_alpha_operand_modifier[2] = {
+ 0, HC_HTXnTBLAbias_Inv
+};
+
+
+static const unsigned c_shift_table[3] = {
+ HC_HTXnTBLCshift_No, HC_HTXnTBLCshift_1, HC_HTXnTBLCshift_2
+};
+
+static const unsigned a_shift_table[3] = {
+ HC_HTXnTBLAshift_No, HC_HTXnTBLAshift_1, HC_HTXnTBLAshift_2
+};
+
+
+/**
+ * Calculate the hardware state for the specified texture combine mode
+ *
+ * \bug
+ * All forms of DOT3 bumpmapping are completely untested, and are most
+ * likely wrong. KW: Looks like it will never be quite right as the
+ * hardware seems to experience overflow in color calculation at the
+ * 4x shift levels, which need to be programed for DOT3. Maybe newer
+ * hardware fixes these issues.
+ *
+ * \bug
+ * KW: needs attention to the case where texunit 1 is enabled but
+ * texunit 0 is not.
+ */
+GLboolean
+viaTexCombineState( struct via_context *vmesa,
+ const struct gl_tex_env_combine_state * combine,
+ unsigned unit )
+{
+ unsigned color_arg[3];
+ unsigned alpha_arg[3];
+ unsigned bias_alpha_arg[3];
+ unsigned color = HC_HTXnTBLCsat_MASK;
+ unsigned alpha = HC_HTXnTBLAsat_MASK;
+ unsigned bias = 0;
+ unsigned op = 0;
+ unsigned a_shift = combine->ScaleShiftA;
+ unsigned c_shift = combine->ScaleShiftRGB;
+ unsigned i;
+ unsigned constant_color[3];
+ unsigned ordered_constant_color[4];
+ unsigned constant_alpha[3];
+ unsigned bias_alpha = 0;
+ unsigned abc_alpha = 0;
+ const struct gl_texture_unit * texUnit =
+ &vmesa->glCtx->Texture.Unit[unit];
+ unsigned env_color[4];
+
+ /* It seems that the color clamping can be overwhelmed at the 4x
+ * scale settings, necessitating this fallback:
+ */
+ if (c_shift == 2 || a_shift == 2) {
+ return GL_FALSE;
+ }
+
+ CLAMPED_FLOAT_TO_UBYTE(env_color[0], texUnit->EnvColor[0]);
+ CLAMPED_FLOAT_TO_UBYTE(env_color[1], texUnit->EnvColor[1]);
+ CLAMPED_FLOAT_TO_UBYTE(env_color[2], texUnit->EnvColor[2]);
+ CLAMPED_FLOAT_TO_UBYTE(env_color[3], texUnit->EnvColor[3]);
+
+ (void) memset( constant_color, 0, sizeof( constant_color ) );
+ (void) memset( ordered_constant_color, 0, sizeof( ordered_constant_color ) );
+ (void) memset( constant_alpha, 0, sizeof( constant_alpha ) );
+
+ for ( i = 0 ; i < combine->_NumArgsRGB ; i++ ) {
+ const GLint op = combine->OperandRGB[i] - GL_SRC_COLOR;
+
+ switch ( combine->SourceRGB[i] ) {
+ case GL_TEXTURE:
+ color_arg[i] = HC_XTC_Tex;
+ color_arg[i] += color_operand_modifier[op];
+ break;
+ case GL_CONSTANT:
+ color_arg[i] = HC_XTC_HTXnTBLRC;
+
+ switch( op ) {
+ case 0: /* GL_SRC_COLOR */
+ constant_color[i] = ((env_color[0] << 16) |
+ (env_color[1] << 8) |
+ env_color[2]);
+ break;
+ case 1: /* GL_ONE_MINUS_SRC_COLOR */
+ constant_color[i] = ~((env_color[0] << 16) |
+ (env_color[1] << 8) |
+ env_color[2]) & 0x00ffffff;
+ break;
+ case 2: /* GL_SRC_ALPHA */
+ constant_color[i] = ((env_color[3] << 16) |
+ (env_color[3] << 8) |
+ env_color[3]);
+ break;
+ case 3: /* GL_ONE_MINUS_SRC_ALPHA */
+ constant_color[i] = ~((env_color[3] << 16) |
+ (env_color[3] << 8) |
+ env_color[3]) & 0x00ffffff;
+ break;
+ }
+ break;
+ case GL_PRIMARY_COLOR:
+ color_arg[i] = HC_XTC_Dif;
+ color_arg[i] += color_operand_modifier[op];
+ break;
+ case GL_PREVIOUS:
+ color_arg[i] = (unit == 0) ? HC_XTC_Dif : HC_XTC_Cur;
+ color_arg[i] += color_operand_modifier[op];
+ break;
+ }
+ }
+
+
+ /* On the Unichrome, all combine operations take on some form of:
+ *
+ * (xA * (xB op xC) + xBias) << xShift
+ *
+ * 'op' can be selected as add, subtract, min, max, or mask. The min, max
+ * and mask modes are currently unused. With the exception of DOT3, all
+ * standard GL_COMBINE modes can be implemented simply by selecting the
+ * correct inputs for A, B, C, and Bias and the correct operation for op.
+ *
+ * NOTE: xBias (when read from the constant registers) is signed,
+ * and scaled to fit -255..255 in 8 bits, ie 0x1 == 2.
+ */
+
+ switch( combine->ModeRGB ) {
+ /* Ca = 1.0, Cb = arg0, Cc = 0, Cbias = 0
+ */
+ case GL_REPLACE:
+ color |= ((CONST_ONE << INPUT_A_SHIFT) |
+ (color_arg[0] << INPUT_B_SHIFT));
+
+ ordered_constant_color[1] = constant_color[0];
+ break;
+
+ /* Ca = arg[0], Cb = arg[1], Cc = 0, Cbias = 0
+ */
+ case GL_MODULATE:
+ color |= ((color_arg[0] << INPUT_A_SHIFT) |
+ (color_arg[1] << INPUT_B_SHIFT));
+
+ ordered_constant_color[0] = constant_color[0];
+ ordered_constant_color[1] = constant_color[1];
+ break;
+
+ /* Ca = 1.0, Cb = arg[0], Cc = arg[1], Cbias = 0
+ */
+ case GL_ADD:
+ case GL_SUBTRACT:
+ if ( combine->ModeRGB == GL_SUBTRACT ) {
+ op |= HC_HTXnTBLCop_Sub;
+ }
+
+ color |= ((CONST_ONE << INPUT_A_SHIFT) |
+ (color_arg[0] << INPUT_B_SHIFT) |
+ (color_arg[1] << INPUT_C_SHIFT));
+
+ ordered_constant_color[1] = constant_color[0];
+ ordered_constant_color[2] = constant_color[1];
+ break;
+
+ /* Ca = 1.0, Cb = arg[0], Cc = arg[1], Cbias = -0.5
+ */
+ case GL_ADD_SIGNED:
+ color |= ((CONST_ONE << INPUT_A_SHIFT) |
+ (color_arg[0] << INPUT_B_SHIFT) |
+ (color_arg[1] << INPUT_C_SHIFT));
+
+ bias |= HC_HTXnTBLCbias_HTXnTBLRC;
+
+ ordered_constant_color[1] = constant_color[0];
+ ordered_constant_color[2] = constant_color[1];
+ ordered_constant_color[3] = 0x00bfbfbf; /* -.5 */
+ break;
+
+ /* Ca = arg[2], Cb = arg[0], Cc = arg[1], Cbias = arg[1]
+ */
+ case GL_INTERPOLATE:
+ op |= HC_HTXnTBLCop_Sub;
+
+ color |= ((color_arg[2] << INPUT_A_SHIFT) |
+ (color_arg[0] << INPUT_B_SHIFT) |
+ (color_arg[1] << INPUT_C_SHIFT));
+
+ bias |= (color_arg[1] << INPUT_CBias_SHIFT);
+
+ ordered_constant_color[0] = constant_color[2];
+ ordered_constant_color[1] = constant_color[0];
+ ordered_constant_color[2] = constant_color[1];
+ ordered_constant_color[3] = (constant_color[1] >> 1) & 0x7f7f7f;
+ break;
+
+#if 0
+ /* At this point this code is completely untested. It appears that the
+ * Unichrome has the same limitation as the Radeon R100. The only
+ * supported post-scale when doing DOT3 bumpmapping is 1x.
+ */
+ case GL_DOT3_RGB_EXT:
+ case GL_DOT3_RGBA_EXT:
+ case GL_DOT3_RGB:
+ case GL_DOT3_RGBA:
+ c_shift = 2;
+ a_shift = 2;
+ color |= ((color_arg[0] << INPUT_A_SHIFT) |
+ (color_arg[1] << INPUT_B_SHIFT));
+ op |= HC_HTXnTBLDOT4;
+ break;
+#endif
+
+ default:
+ assert(0);
+ break;
+ }
+
+
+
+
+ /* The alpha blend stage has the annoying quirk of not having a
+ * hard-wired 0 input, like the color stage. As a result, we have
+ * to program the constant register with 0 and use that as our
+ * 0 input.
+ *
+ * (xA * (xB op xC) + xBias) << xShift
+ *
+ */
+
+ for ( i = 0 ; i < combine->_NumArgsA ; i++ ) {
+ const GLint op = combine->OperandA[i] - GL_SRC_ALPHA;
+
+ switch ( combine->SourceA[i] ) {
+ case GL_TEXTURE:
+ alpha_arg[i] = HC_XTA_Atex;
+ alpha_arg[i] += alpha_operand_modifier[op];
+ bias_alpha_arg[i] = HC_HTXnTBLAbias_Atex;
+ bias_alpha_arg[i] += bias_alpha_operand_modifier[op];
+ break;
+ case GL_CONSTANT:
+ alpha_arg[i] = HC_XTA_HTXnTBLRA;
+ bias_alpha_arg[i] = HC_HTXnTBLAbias_HTXnTBLRAbias;
+ constant_alpha[i] = (op == 0) ? env_color[3] : (~env_color[3] & 0xff);
+ break;
+ case GL_PRIMARY_COLOR:
+ alpha_arg[i] = HC_XTA_Adif;
+ alpha_arg[i] += alpha_operand_modifier[op];
+ bias_alpha_arg[i] = HC_HTXnTBLAbias_Adif;
+ bias_alpha_arg[i] += bias_alpha_operand_modifier[op];
+ break;
+ case GL_PREVIOUS:
+ alpha_arg[i] = (unit == 0) ? HC_XTA_Adif : HC_XTA_Acur;
+ alpha_arg[i] += alpha_operand_modifier[op];
+ bias_alpha_arg[i] = (unit == 0 ?
+ HC_HTXnTBLAbias_Adif :
+ HC_HTXnTBLAbias_Acur);
+ bias_alpha_arg[i] += bias_alpha_operand_modifier[op];
+ break;
+ }
+ }
+
+ switch( combine->ModeA ) {
+ /* Aa = 0, Ab = 0, Ac = 0, Abias = arg0
+ */
+ case GL_REPLACE:
+ alpha |= ((HC_XTA_HTXnTBLRA << INPUT_A_SHIFT) |
+ (HC_XTA_HTXnTBLRA << INPUT_B_SHIFT) |
+ (HC_XTA_HTXnTBLRA << INPUT_C_SHIFT));
+ abc_alpha = 0;
+
+ bias |= bias_alpha_arg[0];
+ bias_alpha = constant_alpha[0] >> 1;
+ break;
+
+ /* Aa = arg[0], Ab = arg[1], Ac = 0, Abias = 0
+ */
+ case GL_MODULATE:
+ alpha |= ((alpha_arg[1] << INPUT_A_SHIFT) |
+ (alpha_arg[0] << INPUT_B_SHIFT) |
+ (HC_XTA_HTXnTBLRA << INPUT_C_SHIFT));
+
+ abc_alpha = ((constant_alpha[1] << HC_HTXnTBLRAa_SHIFT) |
+ (constant_alpha[0] << HC_HTXnTBLRAb_SHIFT) |
+ (0 << HC_HTXnTBLRAc_SHIFT));
+
+ bias |= HC_HTXnTBLAbias_HTXnTBLRAbias;
+ bias_alpha = 0;
+ break;
+
+ /* Aa = 1.0, Ab = arg[0], Ac = arg[1], Abias = 0
+ */
+ case GL_ADD:
+ case GL_SUBTRACT:
+ if ( combine->ModeA == GL_SUBTRACT ) {
+ op |= HC_HTXnTBLAop_Sub;
+ }
+
+ alpha |= ((HC_XTA_HTXnTBLRA << INPUT_A_SHIFT) |
+ (alpha_arg[0] << INPUT_B_SHIFT) |
+ (alpha_arg[1] << INPUT_C_SHIFT));
+
+ abc_alpha = ((0xff << HC_HTXnTBLRAa_SHIFT) |
+ (constant_alpha[0] << HC_HTXnTBLRAb_SHIFT) |
+ (constant_alpha[1] << HC_HTXnTBLRAc_SHIFT));
+
+ bias |= HC_HTXnTBLAbias_HTXnTBLRAbias;
+ bias_alpha = 0;
+ break;
+
+ /* Aa = 1.0, Ab = arg[0], Ac = arg[1], Abias = -0.5
+ */
+ case GL_ADD_SIGNED:
+ alpha |= ((HC_XTA_HTXnTBLRA << INPUT_A_SHIFT) |
+ (alpha_arg[0] << INPUT_B_SHIFT) |
+ (alpha_arg[1] << INPUT_C_SHIFT));
+ abc_alpha = ((0xff << HC_HTXnTBLRAa_SHIFT) |
+ (constant_alpha[0] << HC_HTXnTBLRAb_SHIFT) |
+ (constant_alpha[1] << HC_HTXnTBLRAc_SHIFT));
+
+ bias |= HC_HTXnTBLAbias_HTXnTBLRAbias;
+ bias_alpha = 0xbf;
+ break;
+
+ /* Aa = arg[2], Ab = arg[0], Ac = arg[1], Abias = arg[1]
+ */
+ case GL_INTERPOLATE:
+ op |= HC_HTXnTBLAop_Sub;
+
+ alpha |= ((alpha_arg[2] << INPUT_A_SHIFT) |
+ (alpha_arg[0] << INPUT_B_SHIFT) |
+ (alpha_arg[1] << INPUT_C_SHIFT));
+ abc_alpha = ((constant_alpha[2] << HC_HTXnTBLRAa_SHIFT) |
+ (constant_alpha[0] << HC_HTXnTBLRAb_SHIFT) |
+ (constant_alpha[1] << HC_HTXnTBLRAc_SHIFT));
+
+ bias |= bias_alpha_arg[1];
+ bias_alpha = constant_alpha[1] >> 1;
+ break;
+ }
+
+
+ op |= c_shift_table[ c_shift ] | a_shift_table[ a_shift ];
+
+
+ vmesa->regHTXnTBLMPfog[unit] = HC_HTXnTBLMPfog_Fog;
+
+ vmesa->regHTXnTBLCsat[unit] = color;
+ vmesa->regHTXnTBLAsat[unit] = alpha;
+ vmesa->regHTXnTBLCop[unit] = op | bias;
+ vmesa->regHTXnTBLRAa[unit] = abc_alpha;
+ vmesa->regHTXnTBLRFog[unit] = bias_alpha;
+
+ vmesa->regHTXnTBLRCa[unit] = ordered_constant_color[0];
+ vmesa->regHTXnTBLRCb[unit] = ordered_constant_color[1];
+ vmesa->regHTXnTBLRCc[unit] = ordered_constant_color[2];
+ vmesa->regHTXnTBLRCbias[unit] = ordered_constant_color[3];
+
+ return GL_TRUE;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_tris.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_tris.c
new file mode 100644
index 000000000..9cb88ae23
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_tris.c
@@ -0,0 +1,1190 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+#include <stdio.h>
+#include <math.h>
+
+#include "glheader.h"
+#include "context.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "colormac.h"
+#include "enums.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
+#include "via_context.h"
+#include "via_tris.h"
+#include "via_state.h"
+#include "via_span.h"
+#include "via_ioctl.h"
+#include "via_3d_reg.h"
+#include "via_tex.h"
+
+/***********************************************************************
+ * Emit primitives as inline vertices *
+ ***********************************************************************/
+#define LINE_FALLBACK (0)
+#define POINT_FALLBACK (0)
+#define TRI_FALLBACK (0)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK)
+#define ANY_RASTER_FLAGS (DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET|DD_TRI_UNFILLED)
+
+
+#if 0
+#define COPY_DWORDS(vb, vertsize, v) \
+do { \
+ via_sse_memcpy(vb, v, vertsize * 4); \
+ vb += vertsize; \
+} while (0)
+#else
+#if defined( USE_X86_ASM )
+#define COPY_DWORDS(vb, vertsize, v) \
+ do { \
+ int j; \
+ int __tmp; \
+ __asm__ __volatile__("rep ; movsl" \
+ : "=%c" (j), "=D" (vb), "=S" (__tmp) \
+ : "0" (vertsize), \
+ "D" ((long)vb), \
+ "S" ((long)v)); \
+ } while (0)
+#else
+#define COPY_DWORDS(vb, vertsize, v) \
+ do { \
+ int j; \
+ for (j = 0; j < vertsize; j++) \
+ vb[j] = ((GLuint *)v)[j]; \
+ vb += vertsize; \
+ } while (0)
+#endif
+#endif
+
+static void via_draw_triangle(struct via_context *vmesa,
+ viaVertexPtr v0,
+ viaVertexPtr v1,
+ viaVertexPtr v2)
+{
+ GLuint vertsize = vmesa->vertexSize;
+ GLuint *vb = viaExtendPrimitive(vmesa, 3 * 4 * vertsize);
+
+ COPY_DWORDS(vb, vertsize, v0);
+ COPY_DWORDS(vb, vertsize, v1);
+ COPY_DWORDS(vb, vertsize, v2);
+}
+
+
+static void via_draw_quad(struct via_context *vmesa,
+ viaVertexPtr v0,
+ viaVertexPtr v1,
+ viaVertexPtr v2,
+ viaVertexPtr v3)
+{
+ GLuint vertsize = vmesa->vertexSize;
+ GLuint *vb = viaExtendPrimitive(vmesa, 6 * 4 * vertsize);
+
+ COPY_DWORDS(vb, vertsize, v0);
+ COPY_DWORDS(vb, vertsize, v1);
+ COPY_DWORDS(vb, vertsize, v3);
+ COPY_DWORDS(vb, vertsize, v1);
+ COPY_DWORDS(vb, vertsize, v2);
+ COPY_DWORDS(vb, vertsize, v3);
+}
+
+static void via_draw_line(struct via_context *vmesa,
+ viaVertexPtr v0,
+ viaVertexPtr v1)
+{
+ GLuint vertsize = vmesa->vertexSize;
+ GLuint *vb = viaExtendPrimitive(vmesa, 2 * 4 * vertsize);
+ COPY_DWORDS(vb, vertsize, v0);
+ COPY_DWORDS(vb, vertsize, v1);
+}
+
+
+static void via_draw_point(struct via_context *vmesa,
+ viaVertexPtr v0)
+{
+ GLuint vertsize = vmesa->vertexSize;
+ GLuint *vb = viaExtendPrimitive(vmesa, 4 * vertsize);
+ COPY_DWORDS(vb, vertsize, v0);
+}
+
+
+/* Fallback drawing functions for the ptex hack.
+ */
+#define PTEX_VERTEX( tmp, vertex_size, v) \
+do { \
+ GLuint j; \
+ GLfloat rhw = 1.0 / v->f[vertex_size]; \
+ for ( j = 0 ; j < vertex_size ; j++ ) \
+ tmp.f[j] = v->f[j]; \
+ tmp.f[3] *= v->f[vertex_size]; \
+ tmp.f[vertex_size-2] *= rhw; \
+ tmp.f[vertex_size-1] *= rhw; \
+} while (0)
+
+static void via_ptex_tri (struct via_context *vmesa,
+ viaVertexPtr v0,
+ viaVertexPtr v1,
+ viaVertexPtr v2)
+{
+ GLuint vertsize = vmesa->hwVertexSize;
+ GLuint *vb = viaExtendPrimitive(vmesa, 3*4*vertsize);
+ viaVertex tmp;
+
+ PTEX_VERTEX(tmp, vertsize, v0); COPY_DWORDS(vb, vertsize, &tmp);
+ PTEX_VERTEX(tmp, vertsize, v1); COPY_DWORDS(vb, vertsize, &tmp);
+ PTEX_VERTEX(tmp, vertsize, v2); COPY_DWORDS(vb, vertsize, &tmp);
+}
+
+static void via_ptex_line (struct via_context *vmesa,
+ viaVertexPtr v0,
+ viaVertexPtr v1)
+{
+ GLuint vertsize = vmesa->hwVertexSize;
+ GLuint *vb = viaExtendPrimitive(vmesa, 2*4*vertsize);
+ viaVertex tmp;
+
+ PTEX_VERTEX(tmp, vertsize, v0); COPY_DWORDS(vb, vertsize, &tmp);
+ PTEX_VERTEX(tmp, vertsize, v1); COPY_DWORDS(vb, vertsize, &tmp);
+}
+
+static void via_ptex_point (struct via_context *vmesa,
+ viaVertexPtr v0)
+{
+ GLuint vertsize = vmesa->hwVertexSize;
+ GLuint *vb = viaExtendPrimitive(vmesa, 1*4*vertsize);
+ viaVertex tmp;
+
+ PTEX_VERTEX(tmp, vertsize, v0); COPY_DWORDS(vb, vertsize, &tmp);
+}
+
+
+
+
+
+/***********************************************************************
+ * Macros for via_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI(a, b, c) \
+ do { \
+ if (DO_FALLBACK) \
+ vmesa->drawTri(vmesa, a, b, c); \
+ else \
+ via_draw_triangle(vmesa, a, b, c); \
+ } while (0)
+
+#define QUAD(a, b, c, d) \
+ do { \
+ if (DO_FALLBACK) { \
+ vmesa->drawTri(vmesa, a, b, d); \
+ vmesa->drawTri(vmesa, b, c, d); \
+ } \
+ else \
+ via_draw_quad(vmesa, a, b, c, d); \
+ } while (0)
+
+#define LINE(v0, v1) \
+ do { \
+ if (DO_FALLBACK) \
+ vmesa->drawLine(vmesa, v0, v1); \
+ else \
+ via_draw_line(vmesa, v0, v1); \
+ } while (0)
+
+#define POINT(v0) \
+ do { \
+ if (DO_FALLBACK) \
+ vmesa->drawPoint(vmesa, v0); \
+ else \
+ via_draw_point(vmesa, v0); \
+ } while (0)
+
+
+/***********************************************************************
+ * Build render functions from dd templates *
+ ***********************************************************************/
+
+#define VIA_OFFSET_BIT 0x01
+#define VIA_TWOSIDE_BIT 0x02
+#define VIA_UNFILLED_BIT 0x04
+#define VIA_FALLBACK_BIT 0x08
+#define VIA_MAX_TRIFUNC 0x10
+
+
+static struct {
+ tnl_points_func points;
+ tnl_line_func line;
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
+} rast_tab[VIA_MAX_TRIFUNC + 1];
+
+
+#define DO_FALLBACK (IND & VIA_FALLBACK_BIT)
+#define DO_OFFSET (IND & VIA_OFFSET_BIT)
+#define DO_UNFILLED (IND & VIA_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & VIA_TWOSIDE_BIT)
+#define DO_FLAT 0
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 1
+#define HAVE_BACK_COLORS 0
+#define HAVE_HW_FLATSHADE 1
+#define VERTEX viaVertex
+#define TAB rast_tab
+
+/* Only used to pull back colors into vertices (ie, we know color is
+ * floating point).
+ */
+#define VIA_COLOR(dst, src) \
+ do { \
+ dst[0] = src[2]; \
+ dst[1] = src[1]; \
+ dst[2] = src[0]; \
+ dst[3] = src[3]; \
+ } while (0)
+
+#define VIA_SPEC(dst, src) \
+ do { \
+ dst[0] = src[2]; \
+ dst[1] = src[1]; \
+ dst[2] = src[0]; \
+ } while (0)
+
+
+#define DEPTH_SCALE vmesa->polygon_offset_scale
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->v.x
+#define VERT_Y(_v) _v->v.y
+#define VERT_Z(_v) _v->v.z
+#define AREA_IS_CCW(a) (a > 0)
+#define GET_VERTEX(e) (vmesa->verts + (e * vmesa->vertexSize * sizeof(int)))
+
+#define VERT_SET_RGBA( v, c ) \
+do { \
+ via_color_t *color = (via_color_t *)&((v)->ui[coloroffset]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]); \
+} while (0)
+
+#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+
+#define VERT_SET_SPEC( v, c ) \
+do { \
+ if (specoffset) { \
+ via_color_t *color = (via_color_t *)&((v)->ui[specoffset]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]); \
+ } \
+} while (0)
+#define VERT_COPY_SPEC( v0, v1 ) \
+do { \
+ if (specoffset) { \
+ v0->ub4[specoffset][0] = v1->ub4[specoffset][0]; \
+ v0->ub4[specoffset][1] = v1->ub4[specoffset][1]; \
+ v0->ub4[specoffset][2] = v1->ub4[specoffset][2]; \
+ } \
+} while (0)
+
+
+#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
+#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
+#define VERT_SAVE_SPEC( idx ) if (specoffset) spec[idx] = v[idx]->ui[specoffset]
+#define VERT_RESTORE_SPEC( idx ) if (specoffset) v[idx]->ui[specoffset] = spec[idx]
+
+
+#define LOCAL_VARS(n) \
+ struct via_context *vmesa = VIA_CONTEXT(ctx); \
+ GLuint color[n], spec[n]; \
+ GLuint coloroffset = vmesa->coloroffset; \
+ GLuint specoffset = vmesa->specoffset; \
+ (void)color; (void)spec; (void)coloroffset; (void)specoffset;
+
+
+/***********************************************************************
+ * Helpers for rendering unfilled primitives *
+ ***********************************************************************/
+
+static const GLenum hwPrim[GL_POLYGON + 2] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_POLYGON+1
+};
+
+
+#define RASTERIZE(x) viaRasterPrimitive( ctx, x, hwPrim[x] )
+#define RENDER_PRIMITIVE vmesa->renderPrimitive
+#define TAG(x) x
+#define IND VIA_FALLBACK_BIT
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+#undef RASTERIZE
+
+/***********************************************************************
+ * Generate GL render functions *
+ ***********************************************************************/
+#define RASTERIZE(x)
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (VIA_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (VIA_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (VIA_TWOSIDE_BIT|VIA_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (VIA_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (VIA_OFFSET_BIT|VIA_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (VIA_TWOSIDE_BIT|VIA_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (VIA_TWOSIDE_BIT|VIA_OFFSET_BIT|VIA_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (VIA_FALLBACK_BIT)
+#define TAG(x) x##_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (VIA_OFFSET_BIT|VIA_FALLBACK_BIT)
+#define TAG(x) x##_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (VIA_TWOSIDE_BIT|VIA_FALLBACK_BIT)
+#define TAG(x) x##_twoside_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (VIA_TWOSIDE_BIT|VIA_OFFSET_BIT|VIA_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (VIA_UNFILLED_BIT|VIA_FALLBACK_BIT)
+#define TAG(x) x##_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (VIA_OFFSET_BIT|VIA_UNFILLED_BIT|VIA_FALLBACK_BIT)
+#define TAG(x) x##_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (VIA_TWOSIDE_BIT|VIA_UNFILLED_BIT|VIA_FALLBACK_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (VIA_TWOSIDE_BIT|VIA_OFFSET_BIT|VIA_UNFILLED_BIT| \
+ VIA_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+/* Catchall case for flat, separate specular triangles (via has flat
+ * diffuse shading, but always does specular color with gouraud).
+ */
+#undef DO_FALLBACK
+#undef DO_OFFSET
+#undef DO_UNFILLED
+#undef DO_TWOSIDE
+#undef DO_FLAT
+#define DO_FALLBACK (0)
+#define DO_OFFSET (ctx->_TriangleCaps & DD_TRI_OFFSET)
+#define DO_UNFILLED (ctx->_TriangleCaps & DD_TRI_UNFILLED)
+#define DO_TWOSIDE (ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE)
+#define DO_FLAT 1
+#define TAG(x) x##_flat_specular
+#define IND VIA_MAX_TRIFUNC
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+static void init_rast_tab(void)
+{
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+ init_fallback();
+ init_offset_fallback();
+ init_twoside_fallback();
+ init_twoside_offset_fallback();
+ init_unfilled_fallback();
+ init_offset_unfilled_fallback();
+ init_twoside_unfilled_fallback();
+ init_twoside_offset_unfilled_fallback();
+
+ init_flat_specular(); /* special! */
+}
+
+
+/***********************************************************************
+ * Rasterization fallback helpers *
+ ***********************************************************************/
+
+
+/* This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+static void
+via_fallback_tri(struct via_context *vmesa,
+ viaVertex *v0,
+ viaVertex *v1,
+ viaVertex *v2)
+{
+ GLcontext *ctx = vmesa->glCtx;
+ SWvertex v[3];
+ _swsetup_Translate(ctx, v0, &v[0]);
+ _swsetup_Translate(ctx, v1, &v[1]);
+ _swsetup_Translate(ctx, v2, &v[2]);
+ viaSpanRenderStart( ctx );
+ _swrast_Triangle(ctx, &v[0], &v[1], &v[2]);
+ viaSpanRenderFinish( ctx );
+}
+
+
+static void
+via_fallback_line(struct via_context *vmesa,
+ viaVertex *v0,
+ viaVertex *v1)
+{
+ GLcontext *ctx = vmesa->glCtx;
+ SWvertex v[2];
+ _swsetup_Translate(ctx, v0, &v[0]);
+ _swsetup_Translate(ctx, v1, &v[1]);
+ viaSpanRenderStart( ctx );
+ _swrast_Line(ctx, &v[0], &v[1]);
+ viaSpanRenderFinish( ctx );
+}
+
+
+static void
+via_fallback_point(struct via_context *vmesa,
+ viaVertex *v0)
+{
+ GLcontext *ctx = vmesa->glCtx;
+ SWvertex v[1];
+ _swsetup_Translate(ctx, v0, &v[0]);
+ viaSpanRenderStart( ctx );
+ _swrast_Point(ctx, &v[0]);
+ viaSpanRenderFinish( ctx );
+}
+
+static void viaResetLineStipple( GLcontext *ctx )
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ vmesa->regCmdB |= HC_HLPrst_MASK;
+}
+
+/**********************************************************************/
+/* Render unclipped begin/end objects */
+/**********************************************************************/
+#define IND 0
+#define V(x) (viaVertex *)(vertptr + ((x) * vertsize * sizeof(int)))
+#define RENDER_POINTS(start, count) \
+ for (; start < count; start++) POINT(V(ELT(start)));
+#define RENDER_LINE(v0, v1) LINE(V(v0), V(v1))
+#define RENDER_TRI( v0, v1, v2) TRI( V(v0), V(v1), V(v2))
+#define RENDER_QUAD(v0, v1, v2, v3) QUAD(V(v0), V(v1), V(v2), V(v3))
+#define INIT(x) viaRasterPrimitive(ctx, x, hwPrim[x])
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ struct via_context *vmesa = VIA_CONTEXT(ctx); \
+ GLubyte *vertptr = (GLubyte *)vmesa->verts; \
+ const GLuint vertsize = vmesa->vertexSize; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ const GLboolean stipple = ctx->Line.StippleFlag; \
+ (void) elt; (void) stipple;
+#define RESET_STIPPLE if ( stipple ) viaResetLineStipple( ctx );
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+#define ELT(x) x
+#define TAG(x) via_##x##_verts
+#include "tnl/t_vb_rendertmp.h"
+#undef ELT
+#undef TAG
+#define TAG(x) via_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl/t_vb_rendertmp.h"
+#undef ELT
+#undef TAG
+#undef NEED_EDGEFLAG_SETUP
+#undef EDGEFLAG_GET
+#undef EDGEFLAG_SET
+#undef RESET_OCCLUSION
+
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+
+
+static void viaRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
+ GLuint n)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLuint prim = VIA_CONTEXT(ctx)->renderPrimitive;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON](ctx, 0, n,
+ PRIM_BEGIN|PRIM_END);
+ VB->Elts = tmp;
+ }
+
+ /* Restore the render primitive
+ */
+ if (prim != GL_POLYGON &&
+ prim != GL_POLYGON + 1)
+ tnl->Driver.Render.PrimitiveNotify( ctx, prim );
+}
+
+static void viaRenderClippedLine(GLcontext *ctx, GLuint ii, GLuint jj)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Line(ctx, ii, jj);
+}
+
+static void viaFastRenderClippedPoly(GLcontext *ctx, const GLuint *elts,
+ GLuint n)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ GLuint vertsize = vmesa->vertexSize;
+ GLuint *vb = viaExtendPrimitive(vmesa, (n - 2) * 3 * 4 * vertsize);
+ GLubyte *vertptr = (GLubyte *)vmesa->verts;
+ const GLuint *start = (const GLuint *)V(elts[0]);
+ int i;
+
+ for (i = 2; i < n; i++) {
+ COPY_DWORDS(vb, vertsize, V(elts[i - 1]));
+ COPY_DWORDS(vb, vertsize, V(elts[i]));
+ COPY_DWORDS(vb, vertsize, start);
+ }
+}
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+
+
+
+#define _VIA_NEW_VERTEX (_NEW_TEXTURE | \
+ _DD_NEW_SEPARATE_SPECULAR | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _NEW_FOG)
+
+#define _VIA_NEW_RENDERSTATE (_DD_NEW_LINE_STIPPLE | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE | \
+ _DD_NEW_TRI_OFFSET | \
+ _DD_NEW_TRI_STIPPLE | \
+ _NEW_POLYGONSTIPPLE)
+
+
+static void viaChooseRenderState(GLcontext *ctx)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ if (vmesa->ptexHack) {
+ vmesa->drawPoint = via_ptex_point;
+ vmesa->drawLine = via_ptex_line;
+ vmesa->drawTri = via_ptex_tri;
+ index |= VIA_FALLBACK_BIT;
+ }
+ else {
+ vmesa->drawPoint = via_draw_point;
+ vmesa->drawLine = via_draw_line;
+ vmesa->drawTri = via_draw_triangle;
+ }
+
+ if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= VIA_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= VIA_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= VIA_UNFILLED_BIT;
+ if (flags & ANY_FALLBACK_FLAGS) index |= VIA_FALLBACK_BIT;
+
+ /* Hook in fallbacks for specific primitives.
+ */
+ if (flags & POINT_FALLBACK)
+ vmesa->drawPoint = via_fallback_point;
+
+ if (flags & LINE_FALLBACK)
+ vmesa->drawLine = via_fallback_line;
+
+ if (flags & TRI_FALLBACK)
+ vmesa->drawTri = via_fallback_tri;
+ }
+
+
+ if ((flags & DD_SEPARATE_SPECULAR) &&
+ ctx->Light.ShadeModel == GL_FLAT) {
+ index = VIA_MAX_TRIFUNC; /* flat specular */
+ }
+
+ if (vmesa->renderIndex != index) {
+ vmesa->renderIndex = index;
+
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = via_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = via_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = line; /* from tritmp.h */
+ tnl->Driver.Render.ClippedPolygon = viaFastRenderClippedPoly;
+ }
+ else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedLine = viaRenderClippedLine;
+ tnl->Driver.Render.ClippedPolygon = viaRenderClippedPoly;
+ }
+ }
+}
+
+
+#define VIA_EMIT_TEX1 0x01
+#define VIA_EMIT_TEX0 0x02
+#define VIA_EMIT_PTEX0 0x04
+#define VIA_EMIT_RGBA 0x08
+#define VIA_EMIT_SPEC 0x10
+#define VIA_EMIT_FOG 0x20
+#define VIA_EMIT_W 0x40
+
+#define EMIT_ATTR( ATTR, STYLE, INDEX, REGB ) \
+do { \
+ vmesa->vertex_attrs[vmesa->vertex_attr_count].attrib = (ATTR); \
+ vmesa->vertex_attrs[vmesa->vertex_attr_count].format = (STYLE); \
+ vmesa->vertex_attr_count++; \
+ setupIndex |= (INDEX); \
+ regCmdB |= (REGB); \
+} while (0)
+
+#define EMIT_PAD( N ) \
+do { \
+ vmesa->vertex_attrs[vmesa->vertex_attr_count].attrib = 0; \
+ vmesa->vertex_attrs[vmesa->vertex_attr_count].format = EMIT_PAD; \
+ vmesa->vertex_attrs[vmesa->vertex_attr_count].offset = (N); \
+ vmesa->vertex_attr_count++; \
+} while (0)
+
+
+
+static void viaChooseVertexState( GLcontext *ctx )
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint index = tnl->render_inputs;
+ GLuint regCmdB = HC_HVPMSK_X | HC_HVPMSK_Y | HC_HVPMSK_Z;
+ GLuint setupIndex = 0;
+
+ vmesa->vertex_attr_count = 0;
+
+ /* EMIT_ATTR's must be in order as they tell t_vertex.c how to
+ * build up a hardware vertex.
+ */
+ if (index & (_TNL_BITS_TEX_ANY|_TNL_BIT_FOG)) {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, VIA_EMIT_W, HC_HVPMSK_W );
+ vmesa->coloroffset = 4;
+ }
+ else {
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, 0, 0 );
+ vmesa->coloroffset = 3;
+ }
+
+ /* t_context.c always includes a diffuse color */
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, VIA_EMIT_RGBA,
+ HC_HVPMSK_Cd );
+
+ vmesa->specoffset = 0;
+ if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) {
+ if ((index & _TNL_BIT_COLOR1)) {
+ vmesa->specoffset = vmesa->coloroffset + 1;
+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, VIA_EMIT_SPEC,
+ HC_HVPMSK_Cs );
+ }
+ else
+ EMIT_PAD( 3 );
+
+ if ((index & _TNL_BIT_FOG))
+ EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, VIA_EMIT_FOG, HC_HVPMSK_Cs );
+ else
+ EMIT_PAD( 1 );
+ }
+
+ if (index & _TNL_BIT_TEX(0)) {
+ if (vmesa->ptexHack)
+ EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_3F_XYW, VIA_EMIT_PTEX0,
+ (HC_HVPMSK_S | HC_HVPMSK_T) );
+ else
+ EMIT_ATTR( _TNL_ATTRIB_TEX0, EMIT_2F, VIA_EMIT_TEX0,
+ (HC_HVPMSK_S | HC_HVPMSK_T) );
+ }
+
+ if (index & _TNL_BIT_TEX(1)) {
+ EMIT_ATTR( _TNL_ATTRIB_TEX1, EMIT_2F, VIA_EMIT_TEX1,
+ (HC_HVPMSK_S | HC_HVPMSK_T) );
+ }
+
+ if (setupIndex != vmesa->setupIndex) {
+ vmesa->vertexSize = _tnl_install_attrs( ctx,
+ vmesa->vertex_attrs,
+ vmesa->vertex_attr_count,
+ vmesa->ViewportMatrix.m, 0 );
+ vmesa->vertexSize >>= 2;
+ vmesa->setupIndex = setupIndex;
+ vmesa->regCmdB &= ~HC_HVPMSK_MASK;
+ vmesa->regCmdB |= regCmdB;
+
+ if (vmesa->ptexHack)
+ vmesa->hwVertexSize = vmesa->vertexSize - 1;
+ else
+ vmesa->hwVertexSize = vmesa->vertexSize;
+ }
+}
+
+
+
+
+/* Check if projective texture coordinates are used and if we can fake
+ * them. Fallback to swrast if we can't. Returns GL_TRUE if projective
+ * texture coordinates must be faked, GL_FALSE otherwise.
+ */
+static GLboolean viaCheckPTexHack( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint index = tnl->render_inputs;
+ GLboolean fallback = GL_FALSE;
+ GLboolean ptexHack = GL_FALSE;
+
+ if (index & _TNL_BIT_TEX(0) && VB->TexCoordPtr[0]->size == 4) {
+ if ((index & _TNL_BITS_TEX_ANY) == _TNL_BIT_TEX(0))
+ ptexHack = GL_TRUE;
+ else
+ fallback = GL_TRUE;
+ }
+ if ((index & _TNL_BIT_TEX(1)) && VB->TexCoordPtr[1]->size == 4)
+ fallback = GL_TRUE;
+
+ FALLBACK(VIA_CONTEXT(ctx), VIA_FALLBACK_PROJ_TEXTURE, fallback);
+ return ptexHack;
+}
+
+
+
+
+/**********************************************************************/
+/* High level hooks for t_vb_render.c */
+/**********************************************************************/
+
+
+static void viaRenderStart(GLcontext *ctx)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ {
+ GLboolean ptexHack = viaCheckPTexHack( ctx );
+ if (ptexHack != vmesa->ptexHack) {
+ vmesa->ptexHack = ptexHack;
+ vmesa->newRenderState |= _VIA_NEW_RENDERSTATE;
+ }
+ }
+
+ if (vmesa->newState) {
+ vmesa->newRenderState |= vmesa->newState;
+ viaValidateState( ctx );
+ }
+
+ if (vmesa->Fallback) {
+ tnl->Driver.Render.Start(ctx);
+ return;
+ }
+
+ if (vmesa->newRenderState) {
+ viaChooseVertexState(ctx);
+ viaChooseRenderState(ctx);
+ vmesa->newRenderState = 0;
+ }
+
+ /* Important:
+ */
+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
+}
+
+static void viaRenderFinish(GLcontext *ctx)
+{
+ VIA_FINISH_PRIM(VIA_CONTEXT(ctx));
+}
+
+
+/* System to flush dma and emit state changes based on the rasterized
+ * primitive.
+ */
+void viaRasterPrimitive(GLcontext *ctx,
+ GLenum glprim,
+ GLenum hwprim)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ GLuint regCmdB;
+ RING_VARS;
+
+ if (VIA_DEBUG & DEBUG_PRIMS)
+ fprintf(stderr, "%s: %s/%s/%s\n",
+ __FUNCTION__, _mesa_lookup_enum_by_nr(glprim),
+ _mesa_lookup_enum_by_nr(hwprim),
+ _mesa_lookup_enum_by_nr(ctx->Light.ShadeModel));
+
+ assert (!vmesa->newState);
+
+ vmesa->renderPrimitive = glprim;
+
+ if (hwprim != vmesa->hwPrimitive ||
+ ctx->Light.ShadeModel != vmesa->hwShadeModel) {
+
+ VIA_FINISH_PRIM(vmesa);
+
+ /* Ensure no wrapping inside this function */
+ viaCheckDma( vmesa, 1024 );
+
+ if (vmesa->newEmitState) {
+ viaEmitState(vmesa);
+ }
+
+ vmesa->regCmdA_End = HC_ACMD_HCmdA;
+
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ vmesa->regCmdA_End |= HC_HShading_Gouraud;
+ }
+
+ vmesa->hwShadeModel = ctx->Light.ShadeModel;
+ regCmdB = vmesa->regCmdB;
+
+ switch (hwprim) {
+ case GL_POINTS:
+ vmesa->regCmdA_End |= HC_HPMType_Point | HC_HVCycle_Full;
+ vmesa->regCmdA_End |= HC_HShading_Gouraud; /* always Gouraud
+ shade points?!? */
+ break;
+ case GL_LINES:
+ vmesa->regCmdA_End |= HC_HPMType_Line | HC_HVCycle_Full;
+ regCmdB |= HC_HLPrst_MASK;
+ if (ctx->Light.ShadeModel == GL_FLAT)
+ vmesa->regCmdA_End |= HC_HShading_FlatB;
+ break;
+ case GL_LINE_LOOP:
+ case GL_LINE_STRIP:
+ vmesa->regCmdA_End |= HC_HPMType_Line | HC_HVCycle_AFP |
+ HC_HVCycle_AB | HC_HVCycle_NewB;
+ regCmdB |= HC_HVCycle_AB | HC_HVCycle_NewB | HC_HLPrst_MASK;
+ if (ctx->Light.ShadeModel == GL_FLAT)
+ vmesa->regCmdA_End |= HC_HShading_FlatB;
+ break;
+ case GL_TRIANGLES:
+ vmesa->regCmdA_End |= HC_HPMType_Tri | HC_HVCycle_Full;
+ if (ctx->Light.ShadeModel == GL_FLAT)
+ vmesa->regCmdA_End |= HC_HShading_FlatC;
+ break;
+ case GL_TRIANGLE_STRIP:
+ vmesa->regCmdA_End |= HC_HPMType_Tri | HC_HVCycle_AFP |
+ HC_HVCycle_AC | HC_HVCycle_BB | HC_HVCycle_NewC;
+ regCmdB |= HC_HVCycle_AA | HC_HVCycle_BC | HC_HVCycle_NewC;
+ if (ctx->Light.ShadeModel == GL_FLAT)
+ vmesa->regCmdA_End |= HC_HShading_FlatC;
+ break;
+ case GL_TRIANGLE_FAN:
+ vmesa->regCmdA_End |= HC_HPMType_Tri | HC_HVCycle_AFP |
+ HC_HVCycle_AA | HC_HVCycle_BC | HC_HVCycle_NewC;
+ regCmdB |= HC_HVCycle_AA | HC_HVCycle_BC | HC_HVCycle_NewC;
+ if (ctx->Light.ShadeModel == GL_FLAT)
+ vmesa->regCmdA_End |= HC_HShading_FlatC;
+ break;
+ case GL_QUADS:
+ abort();
+ return;
+ case GL_QUAD_STRIP:
+ abort();
+ return;
+ case GL_POLYGON:
+ vmesa->regCmdA_End |= HC_HPMType_Tri | HC_HVCycle_AFP |
+ HC_HVCycle_AA | HC_HVCycle_BC | HC_HVCycle_NewC;
+ regCmdB |= HC_HVCycle_AA | HC_HVCycle_BC | HC_HVCycle_NewC;
+ if (ctx->Light.ShadeModel == GL_FLAT)
+ vmesa->regCmdA_End |= HC_HShading_FlatC;
+ break;
+ default:
+ abort();
+ return;
+ }
+
+/* assert((vmesa->dmaLow & 0x4) == 0); */
+
+ if (vmesa->dmaCliprectAddr == ~0) {
+ if (VIA_DEBUG & DEBUG_DMA)
+ fprintf(stderr, "reserve cliprect space at %x\n", vmesa->dmaLow);
+ vmesa->dmaCliprectAddr = vmesa->dmaLow;
+ BEGIN_RING(8);
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( (HC_ParaType_NotTex << 16) );
+ OUT_RING( 0xCCCCCCCC );
+ OUT_RING( 0xCCCCCCCC );
+ OUT_RING( 0xCCCCCCCC );
+ OUT_RING( 0xCCCCCCCC );
+ OUT_RING( 0xCCCCCCCC );
+ OUT_RING( 0xCCCCCCCC );
+ ADVANCE_RING();
+ }
+
+ assert(vmesa->dmaLastPrim == 0);
+
+ BEGIN_RING(8);
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( (HC_ParaType_NotTex << 16) );
+ OUT_RING( 0xCCCCCCCC );
+ OUT_RING( 0xDDDDDDDD );
+
+ OUT_RING( HC_HEADER2 );
+ OUT_RING( (HC_ParaType_CmdVdata << 16) );
+ OUT_RING( regCmdB );
+ OUT_RING( vmesa->regCmdA_End );
+ ADVANCE_RING();
+
+ vmesa->hwPrimitive = hwprim;
+ vmesa->dmaLastPrim = vmesa->dmaLow;
+ }
+ else {
+ assert(!vmesa->newEmitState);
+ }
+}
+
+/* Callback for mesa:
+ */
+static void viaRenderPrimitive( GLcontext *ctx, GLuint prim )
+{
+ viaRasterPrimitive( ctx, prim, hwPrim[prim] );
+}
+
+
+void viaFinishPrimitive(struct via_context *vmesa)
+{
+ if (VIA_DEBUG & (DEBUG_DMA|DEBUG_PRIMS))
+ fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (!vmesa->dmaLastPrim || vmesa->dmaCliprectAddr == ~0) {
+ assert(0);
+ }
+ else if (vmesa->dmaLow != vmesa->dmaLastPrim) {
+ GLuint cmdA = (vmesa->regCmdA_End | HC_HPLEND_MASK |
+ HC_HPMValidN_MASK | HC_HE3Fire_MASK);
+ RING_VARS;
+
+ vmesa->dmaLastPrim = 0;
+
+ /* KW: modified 0x1 to 0x4 below:
+ */
+ if ((vmesa->dmaLow & 0x4) || !vmesa->useAgp) {
+ BEGIN_RING_NOCHECK( 1 );
+ OUT_RING( cmdA );
+ ADVANCE_RING();
+ }
+ else {
+ BEGIN_RING_NOCHECK( 2 );
+ OUT_RING( cmdA );
+ OUT_RING( cmdA );
+ ADVANCE_RING();
+ }
+
+ if (vmesa->dmaLow > VIA_DMA_HIGHWATER)
+ viaFlushDma( vmesa );
+ }
+ else {
+ if (VIA_DEBUG & (DEBUG_DMA|DEBUG_PRIMS))
+ fprintf(stderr, "remove empty primitive\n");
+
+ /* Remove the primitive header:
+ */
+ vmesa->dmaLastPrim = 0;
+ vmesa->dmaLow -= 8 * sizeof(GLuint);
+
+ /* Maybe remove the cliprect as well:
+ */
+ if (vmesa->dmaCliprectAddr == vmesa->dmaLow - 8 * sizeof(GLuint)) {
+ vmesa->dmaLow -= 8 * sizeof(GLuint);
+ vmesa->dmaCliprectAddr = ~0;
+ }
+ }
+
+ vmesa->renderPrimitive = GL_POLYGON + 1;
+ vmesa->hwPrimitive = GL_POLYGON + 1;
+ vmesa->dmaLastPrim = 0;
+}
+
+
+/**********************************************************************/
+/* Transition to/from hardware rasterization. */
+/**********************************************************************/
+
+
+void viaFallback(struct via_context *vmesa, GLuint bit, GLboolean mode)
+{
+ GLcontext *ctx = vmesa->glCtx;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldfallback = vmesa->Fallback;
+
+ if (mode) {
+ vmesa->Fallback |= bit;
+ if (oldfallback == 0) {
+ VIA_FLUSH_DMA(vmesa);
+
+ if (VIA_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "ENTER FALLBACK %x\n", bit);
+
+ _swsetup_Wakeup(ctx);
+ vmesa->renderIndex = ~0;
+ }
+ }
+ else {
+ vmesa->Fallback &= ~bit;
+ if (oldfallback == bit) {
+ _swrast_flush( ctx );
+
+ if (VIA_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "LEAVE FALLBACK %x\n", bit);
+
+ tnl->Driver.Render.Start = viaRenderStart;
+ tnl->Driver.Render.PrimitiveNotify = viaRenderPrimitive;
+ tnl->Driver.Render.Finish = viaRenderFinish;
+
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+ tnl->Driver.Render.ResetLineStipple = viaResetLineStipple;
+
+ _tnl_invalidate_vertex_state( ctx, ~0 );
+ _tnl_invalidate_vertices( ctx, ~0 );
+ _tnl_install_attrs( ctx,
+ vmesa->vertex_attrs,
+ vmesa->vertex_attr_count,
+ vmesa->ViewportMatrix.m, 0 );
+
+ vmesa->newState |= (_VIA_NEW_RENDERSTATE|_VIA_NEW_VERTEX);
+ }
+ }
+}
+
+static void viaRunPipeline( GLcontext *ctx )
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+
+ if (vmesa->newState) {
+ vmesa->newRenderState |= vmesa->newState;
+ viaValidateState( ctx );
+ }
+
+ _tnl_run_pipeline( ctx );
+}
+
+
+/**********************************************************************/
+/* Initialization. */
+/**********************************************************************/
+
+
+void viaInitTriFuncs(GLcontext *ctx)
+{
+ struct via_context *vmesa = VIA_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+ }
+
+ tnl->Driver.RunPipeline = viaRunPipeline;
+ tnl->Driver.Render.Start = viaRenderStart;
+ tnl->Driver.Render.Finish = viaRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = viaRenderPrimitive;
+ tnl->Driver.Render.ResetLineStipple = viaResetLineStipple;
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.Interp = _tnl_interp;
+
+ _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
+ (6 + 2*ctx->Const.MaxTextureUnits) * sizeof(GLfloat) );
+
+ vmesa->verts = (GLubyte *)tnl->clipspace.vertex_buf;
+
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_tris.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_tris.h
new file mode 100644
index 000000000..b4f0880a7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/unichrome/via_tris.h
@@ -0,0 +1,35 @@
+/*
+ * Copyright 1998-2003 VIA Technologies, Inc. All Rights Reserved.
+ * Copyright 2001-2003 S3 Graphics, Inc. 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
+ * VIA, S3 GRAPHICS, 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.
+ */
+
+#ifndef _VIATRIS_H
+#define _VIATRIS_H
+
+#include "mtypes.h"
+
+extern void viaPrintRenderState(const char *msg, GLuint state);
+extern void viaInitTriFuncs(GLcontext *ctx);
+extern void viaRasterPrimitive(GLcontext *ctx, GLenum rPrim, GLuint hwPrim);
+extern void viaRasterPrimitiveFinish(GLcontext *ctx);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/x11/Makefile b/nx-X11/extras/Mesa/src/mesa/drivers/dri/x11/Makefile
new file mode 100644
index 000000000..c7dd15209
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/x11/Makefile
@@ -0,0 +1,89 @@
+# src/mesa/drivers/dri/x11/Makefile
+
+TOP = ../../../../..
+include $(TOP)/configs/current
+
+LIBNAME = x11_dri.so
+
+DRIVER_SOURCES = x11_dri.c \
+ $(TOP)/src/mesa/drivers/common/driverfuncs.c \
+ ../common/dri_util.c \
+ ../../x11/xm_api.c \
+ ../../x11/xm_dd.c \
+ ../../x11/xm_line.c \
+ ../../x11/xm_span.c \
+ ../../x11/xm_tri.c
+
+C_SOURCES = \
+ $(DRIVER_SOURCES) \
+ $(DRI_SOURCES)
+
+
+# Include directories
+INCLUDE_DIRS = \
+ -I. \
+ -I../common \
+ -I../../x11 \
+ -I../dri_client \
+ -I../dri_client/imports \
+ -Iserver \
+ -I$(TOP)/include \
+ -I$(DRM_SOURCE_PATH)/shared-core \
+ -I$(TOP)/src/mesa \
+ -I$(TOP)/src/mesa/main \
+ -I$(TOP)/src/mesa/glapi \
+ -I$(TOP)/src/mesa/math \
+ -I$(TOP)/src/mesa/transform \
+ -I$(TOP)/src/mesa/shader \
+ -I$(TOP)/src/mesa/swrast \
+ -I$(TOP)/src/mesa/swrast_setup
+
+# Core Mesa objects
+MESA_MODULES = $(TOP)/src/mesa/mesa.a
+
+# Libraries that the driver shared lib depends on
+LIB_DEPS = -lm -lpthread -lc
+# LIB_DEPS = -lGL -lm -lpthread -lc
+
+
+ASM_SOURCES =
+
+OBJECTS = $(C_SOURCES:.c=.o) \
+ $(ASM_SOURCES:.S=.o)
+
+
+##### RULES #####
+
+.c.o:
+ $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(DEFINES) $< -o $@
+
+.S.o:
+ $(CC) -c $(INCLUDE_DIRS) $(CFLAGS) $(DEFINES) $< -o $@
+
+
+##### TARGETS #####
+
+default: depend $(LIB_DIR)/$(LIBNAME)
+
+
+$(LIB_DIR)/$(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(WINOBJ) Makefile
+ CC="$(CC)" CXX="$(CXX)" $(TOP)/bin/mklib -o $(LIBNAME) -noprefix -install $(LIB_DIR) \
+ $(OBJECTS) $(WINLIB) $(LIB_DEPS) $(WINOBJ) $(MESA_MODULES)
+
+
+depend: $(C_SOURCES) $(ASM_SOURCES)
+ touch depend
+ $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDE_DIRS) $(C_SOURCES) $(ASM_SOURCES) \
+ > /dev/null
+
+
+# Emacs tags
+tags:
+ etags `find . -name \*.[ch]` `find ../include`
+
+
+clean:
+ -rm -f *.o server/*.o
+
+
+include depend
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/x11/x11_dri.c b/nx-X11/extras/Mesa/src/mesa/drivers/dri/x11/x11_dri.c
new file mode 100644
index 000000000..f414b7e42
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/x11/x11_dri.c
@@ -0,0 +1,487 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 0.1
+ *
+ * Copyright (C) 1999-2002 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.
+ */
+
+
+/* Minimal swrast-based DRI-loadable driver.
+ *
+ * Derived from fb_dri.c, the difference being that one works for
+ * framebuffers without X, whereas this points Mesa at an X surface
+ * to draw on.
+ *
+ * This is basically just a wrapper around src/mesa/drivers/x11 to make it
+ * look like a DRI driver.
+ */
+
+#define GLX_DIRECT_RENDERING
+
+#include <assert.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/shm.h>
+#include <sys/stat.h>
+#include <linux/kd.h>
+#include <linux/vt.h>
+
+#include "dri_util.h"
+
+#include "GL/xmesa.h"
+#include "xmesaP.h"
+
+#include "mtypes.h"
+#include "context.h"
+#include "extensions.h"
+#include "imports.h"
+#include "matrix.h"
+#include "texformat.h"
+#include "texstore.h"
+#include "teximage.h"
+#include "array_cache/acache.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
+#include "x11_dri.h"
+
+typedef struct {
+ GLcontext *glCtx; /* Mesa context */
+
+ struct {
+ __DRIcontextPrivate *context;
+ __DRIscreenPrivate *screen;
+ __DRIdrawablePrivate *drawable; /* drawable bound to this ctx */
+ } dri;
+} x11Context, *x11ContextPtr;
+
+#define X11_CONTEXT(ctx) ((x11ContextPtr)(ctx->DriverCtx))
+
+static const GLubyte *
+get_string(GLcontext *ctx, GLenum pname)
+{
+ (void) ctx;
+ switch (pname) {
+ case GL_RENDERER:
+ return (const GLubyte *) "Mesa X11 hack";
+ default:
+ return NULL;
+ }
+}
+
+static void
+update_state(GLcontext *ctx, GLuint new_state)
+{
+ /* not much to do here - pass it on */
+ _swrast_InvalidateState(ctx, new_state);
+ _swsetup_InvalidateState(ctx, new_state);
+ _ac_InvalidateState(ctx, new_state);
+ _tnl_InvalidateState(ctx, new_state);
+}
+
+/**
+ * Called by ctx->Driver.GetBufferSize from in core Mesa to query the
+ * current framebuffer size.
+ */
+static void
+get_buffer_size(GLframebuffer *buffer, GLuint *width, GLuint *height)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ x11ContextPtr x11mesa = X11_CONTEXT(ctx);
+
+ *width = x11mesa->dri.drawable->w;
+ *height = x11mesa->dri.drawable->h;
+}
+
+static void
+init_core_functions(struct dd_function_table *functions)
+{
+ functions->GetString = get_string;
+ functions->UpdateState = update_state;
+ functions->ResizeBuffers = _swrast_alloc_buffers;
+ functions->GetBufferSize = get_buffer_size;
+
+ functions->Clear = _swrast_Clear; /* could accelerate with blits */
+}
+
+/* Initialize the driver specific screen private data.
+ */
+static GLboolean
+x11InitDriver(__DRIscreenPrivate *sPriv)
+{
+ sPriv->private = NULL;
+ return GL_TRUE;
+}
+
+static void
+x11DestroyScreen(__DRIscreenPrivate *sPriv)
+{
+}
+
+/* placeholders, disables rendering */
+static void
+nullwrite(void *a, int b, int c, int d, void *e, void *f)
+{
+}
+
+static void
+set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
+{
+}
+
+/* Create the device specific context. */
+static GLboolean
+x11CreateContext(const __GLcontextModes *glVisual,
+ __DRIcontextPrivate *driContextPriv,
+ void *sharedContextPrivate)
+{
+ x11ContextPtr x11mesa;
+ GLcontext *ctx, *shareCtx;
+ struct dd_function_table functions;
+
+ assert(glVisual);
+ assert(driContextPriv);
+
+ /* Allocate the Fb context */
+ x11mesa = (x11ContextPtr) CALLOC(sizeof(*x11mesa));
+ if (!x11mesa)
+ return GL_FALSE;
+
+ /* Init default driver functions then plug in our own functions */
+ _mesa_init_driver_functions(&functions);
+ init_core_functions(&functions);
+
+ /* Allocate the Mesa context */
+ if (sharedContextPrivate)
+ shareCtx = ((x11ContextPtr) sharedContextPrivate)->glCtx;
+ else
+ shareCtx = NULL;
+
+ ctx = x11mesa->glCtx = _mesa_create_context(glVisual, shareCtx,
+ &functions, (void *) x11mesa);
+ if (!x11mesa->glCtx) {
+ FREE(x11mesa);
+ return GL_FALSE;
+ }
+ driContextPriv->driverPrivate = x11mesa;
+
+ /* Create module contexts */
+ _swrast_CreateContext(ctx);
+ _ac_CreateContext(ctx);
+ _tnl_CreateContext(ctx);
+ _swsetup_CreateContext(ctx);
+ _swsetup_Wakeup(ctx);
+
+ /* swrast init */
+ {
+ struct swrast_device_driver *swdd;
+ swdd = _swrast_GetDeviceDriverReference(ctx);
+ swdd->SetBuffer = set_buffer;
+ if (!glVisual->rgbMode) {
+ swdd->WriteCI32Span =
+ swdd->WriteCI32Span =
+ swdd->WriteCI8Span =
+ swdd->WriteMonoCISpan =
+ swdd->WriteCI32Pixels =
+ swdd->WriteMonoCIPixels =
+ swdd->ReadCI32Span =
+ swdd->ReadCI32Pixels = nullwrite;
+ }
+ else if (glVisual->rgbBits == 24 &&
+ glVisual->alphaBits == 0) {
+ swdd->WriteRGBASpan =
+ swdd->WriteRGBSpan =
+ swdd->WriteMonoRGBASpan =
+ swdd->WriteRGBAPixels =
+ swdd->WriteMonoRGBAPixels =
+ swdd->ReadRGBASpan =
+ swdd->ReadRGBAPixels = nullwrite;
+ }
+ else if (glVisual->rgbBits == 32 &&
+ glVisual->alphaBits == 8) {
+ swdd->WriteRGBASpan =
+ swdd->WriteRGBSpan =
+ swdd->WriteMonoRGBASpan =
+ swdd->WriteRGBAPixels =
+ swdd->WriteMonoRGBAPixels =
+ swdd->ReadRGBASpan =
+ swdd->ReadRGBAPixels = nullwrite;
+ }
+ else if (glVisual->rgbBits == 16 &&
+ glVisual->alphaBits == 0) {
+ swdd->WriteRGBASpan =
+ swdd->WriteRGBSpan =
+ swdd->WriteMonoRGBASpan =
+ swdd->WriteRGBAPixels =
+ swdd->WriteMonoRGBAPixels =
+ swdd->ReadRGBASpan =
+ swdd->ReadRGBAPixels = nullwrite;
+ }
+ else if (glVisual->rgbBits == 15 &&
+ glVisual->alphaBits == 0) {
+ swdd->WriteRGBASpan =
+ swdd->WriteRGBSpan =
+ swdd->WriteMonoRGBASpan =
+ swdd->WriteRGBAPixels =
+ swdd->WriteMonoRGBAPixels =
+ swdd->ReadRGBASpan =
+ swdd->ReadRGBAPixels = nullwrite;
+ }
+ else {
+ _mesa_printf("bad pixelformat rgb %d alpha %d\n",
+ glVisual->rgbBits,
+ glVisual->alphaBits );
+ }
+ }
+
+ /* use default TCL pipeline */
+ {
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.RunPipeline = _tnl_run_pipeline;
+ }
+
+ _mesa_enable_sw_extensions(ctx);
+
+ return GL_TRUE;
+}
+
+
+static void
+x11DestroyContext(__DRIcontextPrivate *driContextPriv)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ x11ContextPtr x11mesa = (x11ContextPtr) driContextPriv->driverPrivate;
+ x11ContextPtr current = ctx ? X11_CONTEXT(ctx) : NULL;
+
+ /* check if we're deleting the currently bound context */
+ if (x11mesa == current) {
+ _mesa_make_current2(NULL, NULL, NULL);
+ }
+
+ /* Free x11 context resources */
+ if (x11mesa) {
+ _swsetup_DestroyContext(x11mesa->glCtx);
+ _tnl_DestroyContext(x11mesa->glCtx);
+ _ac_DestroyContext(x11mesa->glCtx);
+ _swrast_DestroyContext(x11mesa->glCtx);
+
+ /* free the Mesa context */
+ x11mesa->glCtx->DriverCtx = NULL;
+ _mesa_destroy_context(x11mesa->glCtx);
+
+ FREE(x11mesa);
+ }
+}
+
+
+/* Create and initialize the Mesa and driver specific pixmap buffer
+ * data.
+ */
+static GLboolean
+x11CreateBuffer(__DRIscreenPrivate *driScrnPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ const __GLcontextModes *mesaVis,
+ GLboolean isPixmap)
+{
+ if (isPixmap) {
+ return GL_FALSE; /* not implemented */
+ }
+ else {
+ const GLboolean swDepth = mesaVis->depthBits > 0;
+ const GLboolean swAlpha = mesaVis->alphaBits > 0;
+ const GLboolean swAccum = mesaVis->accumRedBits > 0;
+ const GLboolean swStencil = mesaVis->stencilBits > 0;
+ driDrawPriv->driverPrivate = (void *)
+ _mesa_create_framebuffer(mesaVis,
+ swDepth,
+ swStencil,
+ swAccum,
+ swAlpha);
+
+ if (!driDrawPriv->driverPrivate)
+ return 0;
+
+ /* Replace the framebuffer back buffer with a malloc'ed one --
+ * big speedup.
+ */
+/*
+ if (driDrawPriv->backBuffer)
+ driDrawPriv->backBuffer = malloc(driDrawPriv->currentPitch * driDrawPriv->h);
+*/
+
+ return 1;
+ }
+}
+
+
+static void
+x11DestroyBuffer(__DRIdrawablePrivate *driDrawPriv)
+{
+ _mesa_destroy_framebuffer((GLframebuffer *) (driDrawPriv->driverPrivate));
+/* free(driDrawPriv->backBuffer); */
+}
+
+
+
+/* If the backbuffer is on a videocard, this is extraordinarily slow!
+ */
+static void
+x11SwapBuffers(__DRIdrawablePrivate *dPriv)
+{
+
+ if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+ x11ContextPtr x11mesa;
+ GLcontext *ctx;
+ x11mesa = (x11ContextPtr) dPriv->driContextPriv->driverPrivate;
+ ctx = x11mesa->glCtx;
+ if (ctx->Visual.doubleBufferMode) {
+ int i;
+ int offset = 0;
+ char *tmp /*= malloc(dPriv->currentPitch) */ ;
+
+ _mesa_notifySwapBuffers(ctx); /* flush pending rendering comands */
+
+/*
+ ASSERT(dPriv->frontBuffer);
+ ASSERT(dPriv->backBuffer);
+
+ for (i = 0 ; i < dPriv->h ; i++ ) {
+ memcpy(tmp, (char *)dPriv->frontBuffer + offset, dPriv->currentPitch);
+ memcpy((char *)dPriv->backBuffer + offset, tmp, dPriv->currentPitch);
+ offset += dPriv->currentPitch;
+ }
+
+ free(tmp);
+*/
+ }
+ }
+ else {
+ /* XXX this shouldn't be an error but we can't handle it for now */
+ _mesa_problem(NULL, "x11SwapBuffers: drawable has no context!\n");
+ }
+}
+
+
+/* Force the context `c' to be the current context and associate with it
+ * buffer `b'.
+ */
+static GLboolean
+x11MakeCurrent(__DRIcontextPrivate *driContextPriv,
+ __DRIdrawablePrivate *driDrawPriv,
+ __DRIdrawablePrivate *driReadPriv)
+{
+ if (driContextPriv) {
+ x11ContextPtr newFbCtx =
+ (x11ContextPtr) driContextPriv->driverPrivate;
+
+ newFbCtx->dri.drawable = driDrawPriv;
+
+ _mesa_make_current2(newFbCtx->glCtx,
+ (GLframebuffer *) driDrawPriv->driverPrivate,
+ (GLframebuffer *) driReadPriv->driverPrivate);
+ } else {
+ _mesa_make_current(0, 0);
+ }
+
+ return GL_TRUE;
+}
+
+
+/* Force the context `c' to be unbound from its buffer.
+ */
+static GLboolean
+x11UnbindContext(__DRIcontextPrivate *driContextPriv)
+{
+ return GL_TRUE;
+}
+
+static struct __DriverAPIRec x11API = {
+ x11InitDriver,
+ x11DestroyScreen,
+ x11CreateContext,
+ x11DestroyContext,
+ x11CreateBuffer,
+ x11DestroyBuffer,
+ x11SwapBuffers,
+ x11MakeCurrent,
+ x11UnbindContext
+};
+
+/*
+ * This is the bootstrap function for the driver.
+ * The __driCreateScreen name is the symbol that libGL.so fetches.
+ * Return: pointer to a __DRIscreenPrivate.
+ */
+void *
+__driCreateScreen(Display *dpy, int scrn, __DRIscreen *psc,
+ int numConfigs, __GLXvisualConfig *config)
+{
+ __DRIscreenPrivate *psp;
+ psp = __driUtilCreateScreen(dpy, scrn, psc, numConfigs, config, &x11API);
+ return (void *) psp;
+}
+
+/**
+ * \brief Establish the set of modes available for the display.
+ *
+ * \param ctx display handle.
+ * \param numModes will receive the number of supported modes.
+ * \param modes will point to the list of supported modes.
+ *
+ * \return one on success, or zero on failure.
+ *
+ * Allocates a single visual and fills it with information according to the
+ * display bit depth. Supports only 16 and 32 bpp bit depths, aborting
+ * otherwise.
+ */
+const __GLcontextModes __glModes[] = {
+ /* 32 bit, RGBA Depth=24 Stencil=8 */
+ {.rgbMode = GL_TRUE, .colorIndexMode = GL_FALSE, .doubleBufferMode = GL_TRUE, .stereoMode = GL_FALSE,
+ .haveAccumBuffer = GL_FALSE, .haveDepthBuffer = GL_TRUE, .haveStencilBuffer = GL_TRUE,
+ .redBits = 8, .greenBits = 8, .blueBits = 8, .alphaBits = 8,
+ .redMask = 0xff0000, .greenMask = 0xff00, .blueMask = 0xff, .alphaMask = 0xff000000,
+ .rgbBits = 32, .indexBits = 0,
+ .accumRedBits = 0, .accumGreenBits = 0, .accumBlueBits = 0, .accumAlphaBits = 0,
+ .depthBits = 24, .stencilBits = 8,
+ .numAuxBuffers= 0, .level = 0, .pixmapMode = GL_FALSE, },
+
+ /* 16 bit, RGB Depth=16 */
+ {.rgbMode = GL_TRUE, .colorIndexMode = GL_FALSE, .doubleBufferMode = GL_TRUE, .stereoMode = GL_FALSE,
+ .haveAccumBuffer = GL_FALSE, .haveDepthBuffer = GL_TRUE, .haveStencilBuffer = GL_FALSE,
+ .redBits = 5, .greenBits = 6, .blueBits = 5, .alphaBits = 0,
+ .redMask = 0xf800, .greenMask = 0x07e0, .blueMask = 0x001f, .alphaMask = 0x0,
+ .rgbBits = 16, .indexBits = 0,
+ .accumRedBits = 0, .accumGreenBits = 0, .accumBlueBits = 0, .accumAlphaBits = 0,
+ .depthBits = 16, .stencilBits = 0,
+ .numAuxBuffers= 0, .level = 0, .pixmapMode = GL_FALSE, },
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/dri/x11/x11_dri.h b/nx-X11/extras/Mesa/src/mesa/drivers/dri/x11/x11_dri.h
new file mode 100644
index 000000000..fd1e64f45
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/dri/x11/x11_dri.h
@@ -0,0 +1,12 @@
+typedef struct {
+
+ void *frontBuffer;
+ void *backBuffer;
+ void *currentBuffer;
+ int currentPitch;
+
+ int depthCpp;
+ void *depthBuffer;
+ int depthPitch;
+
+} x11ScreenPrivate;
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/fbdev/glfbdev.c b/nx-X11/extras/Mesa/src/mesa/drivers/fbdev/glfbdev.c
new file mode 100644
index 000000000..c8d9375b6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/fbdev/glfbdev.c
@@ -0,0 +1,861 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+/*
+ * OpenGL (Mesa) interface for fbdev.
+ * For info about fbdev:
+ * http://www.tldp.org/HOWTO/Framebuffer-HOWTO.html
+ *
+ * known VGA modes
+ * Colours 640x400 640x480 800x600 1024x768 1152x864 1280x1024 1600x1200
+ * --------+--------------------------------------------------------------
+ * 4 bits | ? ? 0x302 ? ? ? ?
+ * 8 bits | 0x300 0x301 0x303 0x305 0x161 0x307 0x31C
+ * 15 bits | ? 0x310 0x313 0x316 0x162 0x319 0x31D
+ * 16 bits | ? 0x311 0x314 0x317 0x163 0x31A 0x31E
+ * 24 bits | ? 0x312 0x315 0x318 ? 0x31B 0x31F
+ * 32 bits | ? ? ? ? 0x164 ?
+ */
+#ifdef USE_GLFBDEV_DRIVER
+
+#include "glheader.h"
+#include <linux/fb.h>
+#include "GL/glfbdev.h"
+#include "buffers.h"
+#include "context.h"
+#include "extensions.h"
+#include "fbobject.h"
+#include "framebuffer.h"
+#include "imports.h"
+#include "renderbuffer.h"
+#include "texformat.h"
+#include "teximage.h"
+#include "texstore.h"
+#include "array_cache/acache.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
+
+#define PF_B8G8R8 1
+#define PF_B8G8R8A8 2
+#define PF_B5G6R5 3
+#define PF_B5G5R5 4
+#define PF_CI8 5
+
+
+/*
+ * Derived from Mesa's GLvisual class.
+ */
+struct GLFBDevVisualRec {
+ GLvisual glvisual; /* base class */
+ struct fb_fix_screeninfo fix;
+ struct fb_var_screeninfo var;
+ int pixelFormat;
+};
+
+/*
+ * Derived from Mesa's GLframebuffer class.
+ */
+struct GLFBDevBufferRec {
+ GLframebuffer glframebuffer; /* base class */
+ GLFBDevVisualPtr visual;
+ struct fb_fix_screeninfo fix;
+ struct fb_var_screeninfo var;
+ size_t size; /* color buffer size in bytes */
+ GLuint bytesPerPixel;
+};
+
+/*
+ * Derived from Mesa's GLcontext class.
+ */
+struct GLFBDevContextRec {
+ GLcontext glcontext; /* base class */
+ GLFBDevVisualPtr visual;
+ GLFBDevBufferPtr drawBuffer;
+ GLFBDevBufferPtr readBuffer;
+ GLFBDevBufferPtr curBuffer;
+};
+
+/*
+ * Derived from Mesa's gl_renderbuffer class.
+ */
+struct GLFBDevRenderbufferRec {
+ struct gl_renderbuffer Base;
+ GLubyte *bottom; /* pointer to last row */
+ GLuint rowStride; /* in bytes */
+ GLboolean mallocedBuffer;
+};
+
+
+
+#define GLFBDEV_CONTEXT(CTX) ((GLFBDevContextPtr) (CTX))
+#define GLFBDEV_BUFFER(BUF) ((GLFBDevBufferPtr) (BUF))
+
+
+/**********************************************************************/
+/* Internal device driver functions */
+/**********************************************************************/
+
+
+static const GLubyte *
+get_string(GLcontext *ctx, GLenum pname)
+{
+ (void) ctx;
+ switch (pname) {
+ case GL_RENDERER:
+ return (const GLubyte *) "Mesa glfbdev";
+ default:
+ return NULL;
+ }
+}
+
+
+static void
+update_state( GLcontext *ctx, GLuint new_state )
+{
+ /* not much to do here - pass it on */
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+}
+
+
+static void
+get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
+{
+ const GLFBDevBufferPtr fbdevbuffer = GLFBDEV_BUFFER(buffer);
+ *width = fbdevbuffer->var.xres_virtual;
+ *height = fbdevbuffer->var.yres_virtual;
+}
+
+
+static void
+viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
+
+
+/* specifies the buffer for swrast span rendering/reading */
+static void
+set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
+{
+ /* this is a no-op when using the new gl_renderbuffer span functions. */
+}
+
+
+/*
+ * Generate code for span functions.
+ */
+
+/* 24-bit BGR */
+#define NAME(PREFIX) PREFIX##_B8G8R8
+#define FORMAT GL_RGBA8
+#define SPAN_VARS \
+ struct GLFBDevRenderbufferRec *frb = (struct GLFBDevRenderbufferRec *) rb;
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLubyte *P = frb->bottom - (Y) * frb->rowStride + (X) * 3
+#define INC_PIXEL_PTR(P) P += 3
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = VALUE[BCOMP]; \
+ DST[1] = VALUE[GCOMP]; \
+ DST[2] = VALUE[RCOMP]
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = SRC[2]; \
+ DST[GCOMP] = SRC[1]; \
+ DST[BCOMP] = SRC[0]; \
+ DST[ACOMP] = CHAN_MAX
+
+#include "swrast/s_spantemp2.h"
+
+
+/* 32-bit BGRA */
+#define NAME(PREFIX) PREFIX##_B8G8R8A8
+#define FORMAT GL_RGBA8
+#define SPAN_VARS \
+ struct GLFBDevRenderbufferRec *frb = (struct GLFBDevRenderbufferRec *) rb;
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLubyte *P = frb->bottom - (Y) * frb->rowStride + (X) * 4
+#define INC_PIXEL_PTR(P) P += 4
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = VALUE[BCOMP]; \
+ DST[1] = VALUE[GCOMP]; \
+ DST[2] = VALUE[RCOMP]; \
+ DST[3] = VALUE[ACOMP]
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = SRC[2]; \
+ DST[GCOMP] = SRC[1]; \
+ DST[BCOMP] = SRC[0]; \
+ DST[ACOMP] = SRC[3]
+
+#include "swrast/s_spantemp2.h"
+
+
+/* 16-bit BGR (XXX implement dithering someday) */
+#define NAME(PREFIX) PREFIX##_B5G6R5
+#define FORMAT GL_RGBA8
+#define SPAN_VARS \
+ struct GLFBDevRenderbufferRec *frb = (struct GLFBDevRenderbufferRec *) rb;
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLushort *P = (GLushort *) (frb->bottom - (Y) * frb->rowStride + (X) * 2)
+#define INC_PIXEL_PTR(P) P += 1
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = ( (((VALUE[RCOMP]) & 0xf8) << 8) | (((VALUE[GCOMP]) & 0xfc) << 3) | ((VALUE[BCOMP]) >> 3) )
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = ( (((SRC[0]) >> 8) & 0xf8) | (((SRC[0]) >> 11) & 0x7) ); \
+ DST[GCOMP] = ( (((SRC[0]) >> 3) & 0xfc) | (((SRC[0]) >> 5) & 0x3) ); \
+ DST[BCOMP] = ( (((SRC[0]) << 3) & 0xf8) | (((SRC[0]) ) & 0x7) ); \
+ DST[ACOMP] = CHAN_MAX
+
+#include "swrast/s_spantemp2.h"
+
+
+/* 15-bit BGR (XXX implement dithering someday) */
+#define NAME(PREFIX) PREFIX##_B5G5R5
+#define FORMAT GL_RGBA8
+#define SPAN_VARS \
+ struct GLFBDevRenderbufferRec *frb = (struct GLFBDevRenderbufferRec *) rb;
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLushort *P = (GLushort *) (frb->bottom - (Y) * frb->rowStride + (X) * 2)
+#define INC_PIXEL_PTR(P) P += 1
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = ( (((VALUE[RCOMP]) & 0xf8) << 7) | (((VALUE[GCOMP]) & 0xf8) << 2) | ((VALUE[BCOMP]) >> 3) )
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = ( (((SRC[0]) >> 7) & 0xf8) | (((SRC[0]) >> 10) & 0x7) ); \
+ DST[GCOMP] = ( (((SRC[0]) >> 2) & 0xf8) | (((SRC[0]) >> 5) & 0x7) ); \
+ DST[BCOMP] = ( (((SRC[0]) << 3) & 0xf8) | (((SRC[0]) ) & 0x7) ); \
+ DST[ACOMP] = CHAN_MAX
+
+#include "swrast/s_spantemp2.h"
+
+
+/* 8-bit color index */
+#define NAME(PREFIX) PREFIX##_CI8
+#define FORMAT GL_COLOR_INDEX8_EXT
+#define SPAN_VARS \
+ struct GLFBDevRenderbufferRec *frb = (struct GLFBDevRenderbufferRec *) rb;
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLubyte *P = frb->bottom - (Y) * frb->rowStride + (X)
+#define INC_PIXEL_PTR(P) P += 1
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ *DST = VALUE[0]
+#define FETCH_PIXEL(DST, SRC) \
+ DST = SRC[0]
+
+#include "swrast/s_spantemp2.h"
+
+
+
+
+/**********************************************************************/
+/* Public API functions */
+/**********************************************************************/
+
+
+const char *
+glFBDevGetString( int str )
+{
+ switch (str) {
+ case GLFBDEV_VENDOR:
+ return "Mesa Project";
+ case GLFBDEV_VERSION:
+ return "1.0.0";
+ default:
+ return NULL;
+ }
+}
+
+
+const GLFBDevProc
+glFBDevGetProcAddress( const char *procName )
+{
+ struct name_address {
+ const char *name;
+ const GLFBDevProc func;
+ };
+ static const struct name_address functions[] = {
+ { "glFBDevGetString", (GLFBDevProc) glFBDevGetString },
+ { "glFBDevGetProcAddress", (GLFBDevProc) glFBDevGetProcAddress },
+ { "glFBDevCreateVisual", (GLFBDevProc) glFBDevCreateVisual },
+ { "glFBDevDestroyVisual", (GLFBDevProc) glFBDevDestroyVisual },
+ { "glFBDevGetVisualAttrib", (GLFBDevProc) glFBDevGetVisualAttrib },
+ { "glFBDevCreateBuffer", (GLFBDevProc) glFBDevCreateBuffer },
+ { "glFBDevDestroyBuffer", (GLFBDevProc) glFBDevDestroyBuffer },
+ { "glFBDevGetBufferAttrib", (GLFBDevProc) glFBDevGetBufferAttrib },
+ { "glFBDevGetCurrentDrawBuffer", (GLFBDevProc) glFBDevGetCurrentDrawBuffer },
+ { "glFBDevGetCurrentReadBuffer", (GLFBDevProc) glFBDevGetCurrentReadBuffer },
+ { "glFBDevSwapBuffers", (GLFBDevProc) glFBDevSwapBuffers },
+ { "glFBDevCreateContext", (GLFBDevProc) glFBDevCreateContext },
+ { "glFBDevDestroyContext", (GLFBDevProc) glFBDevDestroyContext },
+ { "glFBDevGetContextAttrib", (GLFBDevProc) glFBDevGetContextAttrib },
+ { "glFBDevGetCurrentContext", (GLFBDevProc) glFBDevGetCurrentContext },
+ { "glFBDevMakeCurrent", (GLFBDevProc) glFBDevMakeCurrent },
+ { NULL, NULL }
+ };
+ const struct name_address *entry;
+ for (entry = functions; entry->name; entry++) {
+ if (_mesa_strcmp(entry->name, procName) == 0) {
+ return entry->func;
+ }
+ }
+ return _glapi_get_proc_address(procName);
+}
+
+
+GLFBDevVisualPtr
+glFBDevCreateVisual( const struct fb_fix_screeninfo *fixInfo,
+ const struct fb_var_screeninfo *varInfo,
+ const int *attribs )
+{
+ GLFBDevVisualPtr vis;
+ const int *attrib;
+ GLboolean rgbFlag = GL_TRUE, dbFlag = GL_FALSE, stereoFlag = GL_FALSE;
+ GLint redBits = 0, greenBits = 0, blueBits = 0, alphaBits = 0;
+ GLint indexBits = 0, depthBits = 0, stencilBits = 0;
+ GLint accumRedBits = 0, accumGreenBits = 0;
+ GLint accumBlueBits = 0, accumAlphaBits = 0;
+ GLint numSamples = 0;
+
+ ASSERT(fixInfo);
+ ASSERT(varInfo);
+
+ vis = CALLOC_STRUCT(GLFBDevVisualRec);
+ if (!vis)
+ return NULL;
+
+ vis->fix = *fixInfo; /* struct assignment */
+ vis->var = *varInfo; /* struct assignment */
+
+ for (attrib = attribs; attrib && *attrib != GLFBDEV_NONE; attrib++) {
+ switch (*attrib) {
+ case GLFBDEV_DOUBLE_BUFFER:
+ dbFlag = GL_TRUE;
+ break;
+ case GLFBDEV_COLOR_INDEX:
+ rgbFlag = GL_FALSE;
+ break;
+ case GLFBDEV_DEPTH_SIZE:
+ depthBits = attrib[1];
+ attrib++;
+ break;
+ case GLFBDEV_STENCIL_SIZE:
+ stencilBits = attrib[1];
+ attrib++;
+ break;
+ case GLFBDEV_ACCUM_SIZE:
+ accumRedBits = accumGreenBits = accumBlueBits = accumAlphaBits
+ = attrib[1];
+ attrib++;
+ break;
+ case GLFBDEV_LEVEL:
+ /* ignored for now */
+ break;
+ default:
+ /* unexpected token */
+ _mesa_free(vis);
+ return NULL;
+ }
+ }
+
+ if (rgbFlag) {
+ redBits = varInfo->red.length;
+ greenBits = varInfo->green.length;
+ blueBits = varInfo->blue.length;
+ alphaBits = varInfo->transp.length;
+
+ if ((fixInfo->visual == FB_VISUAL_TRUECOLOR ||
+ fixInfo->visual == FB_VISUAL_DIRECTCOLOR)
+ && varInfo->bits_per_pixel == 24
+ && varInfo->red.offset == 16
+ && varInfo->green.offset == 8
+ && varInfo->blue.offset == 0) {
+ vis->pixelFormat = PF_B8G8R8;
+ }
+ else if ((fixInfo->visual == FB_VISUAL_TRUECOLOR ||
+ fixInfo->visual == FB_VISUAL_DIRECTCOLOR)
+ && varInfo->bits_per_pixel == 32
+ && varInfo->red.offset == 16
+ && varInfo->green.offset == 8
+ && varInfo->blue.offset == 0
+ && varInfo->transp.offset == 24) {
+ vis->pixelFormat = PF_B8G8R8A8;
+ }
+ else if ((fixInfo->visual == FB_VISUAL_TRUECOLOR ||
+ fixInfo->visual == FB_VISUAL_DIRECTCOLOR)
+ && varInfo->bits_per_pixel == 16
+ && varInfo->red.offset == 11
+ && varInfo->green.offset == 5
+ && varInfo->blue.offset == 0) {
+ vis->pixelFormat = PF_B5G6R5;
+ }
+ else if ((fixInfo->visual == FB_VISUAL_TRUECOLOR ||
+ fixInfo->visual == FB_VISUAL_DIRECTCOLOR)
+ && varInfo->bits_per_pixel == 16
+ && varInfo->red.offset == 10
+ && varInfo->green.offset == 5
+ && varInfo->blue.offset == 0) {
+ vis->pixelFormat = PF_B5G5R5;
+ }
+ else {
+ _mesa_problem(NULL, "Unsupported fbdev RGB visual/bitdepth!\n");
+ /*
+ printf("fixInfo->visual = 0x%x\n", fixInfo->visual);
+ printf("varInfo->bits_per_pixel = %d\n", varInfo->bits_per_pixel);
+ printf("varInfo->red.offset = %d\n", varInfo->red.offset);
+ printf("varInfo->green.offset = %d\n", varInfo->green.offset);
+ printf("varInfo->blue.offset = %d\n", varInfo->blue.offset);
+ */
+ _mesa_free(vis);
+ return NULL;
+ }
+ }
+ else {
+ indexBits = varInfo->bits_per_pixel;
+ if ((fixInfo->visual == FB_VISUAL_PSEUDOCOLOR ||
+ fixInfo->visual == FB_VISUAL_STATIC_PSEUDOCOLOR)
+ && varInfo->bits_per_pixel == 8) {
+ vis->pixelFormat = PF_CI8;
+ }
+ else {
+ _mesa_problem(NULL, "Unsupported fbdev CI visual/bitdepth!\n");
+ _mesa_free(vis);
+ return NULL;
+ }
+ }
+
+ if (!_mesa_initialize_visual(&vis->glvisual, rgbFlag, dbFlag, stereoFlag,
+ redBits, greenBits, blueBits, alphaBits,
+ indexBits, depthBits, stencilBits,
+ accumRedBits, accumGreenBits,
+ accumBlueBits, accumAlphaBits,
+ numSamples)) {
+ /* something was invalid */
+ _mesa_free(vis);
+ return NULL;
+ }
+
+ return vis;
+}
+
+
+void
+glFBDevDestroyVisual( GLFBDevVisualPtr visual )
+{
+ if (visual)
+ _mesa_free(visual);
+}
+
+
+int
+glFBDevGetVisualAttrib( const GLFBDevVisualPtr visual, int attrib)
+{
+ /* XXX unfinished */
+ (void) visual;
+ (void) attrib;
+ return -1;
+}
+
+
+static void
+delete_renderbuffer(struct gl_renderbuffer *rb)
+{
+ struct GLFBDevRenderbufferRec *frb = (struct GLFBDevRenderbufferRec *) rb;
+ if (frb->mallocedBuffer) {
+ _mesa_free(frb->Base.Data);
+ }
+ _mesa_free(frb);
+}
+
+
+static GLboolean
+renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ /* no-op: the renderbuffer storage is allocated just once when it's
+ * created. Never resized or reallocated.
+ */
+ return GL_TRUE;
+}
+
+
+static struct GLFBDevRenderbufferRec *
+new_glfbdev_renderbuffer(void *bufferStart, int pixelFormat)
+{
+ struct GLFBDevRenderbufferRec *rb = CALLOC_STRUCT(GLFBDevRenderbufferRec);
+ if (rb) {
+ GLuint name = 0;
+ _mesa_init_renderbuffer(&rb->Base, name);
+
+ rb->Base.Delete = delete_renderbuffer;
+ rb->Base.AllocStorage = renderbuffer_storage;
+
+ if (pixelFormat == PF_B8G8R8) {
+ rb->Base.GetRow = get_row_B8G8R8;
+ rb->Base.GetValues = get_values_B8G8R8;
+ rb->Base.PutRow = put_row_B8G8R8;
+ rb->Base.PutMonoRow = put_mono_row_B8G8R8;
+ rb->Base.PutValues = put_values_B8G8R8;
+ rb->Base.PutMonoValues = put_mono_values_B8G8R8;
+ }
+ else if (pixelFormat == PF_B8G8R8A8) {
+ rb->Base.GetRow = get_row_B8G8R8A8;
+ rb->Base.GetValues = get_values_B8G8R8A8;
+ rb->Base.PutRow = put_row_B8G8R8A8;
+ rb->Base.PutMonoRow = put_mono_row_B8G8R8A8;
+ rb->Base.PutValues = put_values_B8G8R8A8;
+ rb->Base.PutMonoValues = put_mono_values_B8G8R8A8;
+ }
+ else if (pixelFormat == PF_B5G6R5) {
+ rb->Base.GetRow = get_row_B5G6R5;
+ rb->Base.GetValues = get_values_B5G6R5;
+ rb->Base.PutRow = put_row_B5G6R5;
+ rb->Base.PutMonoRow = put_mono_row_B5G6R5;
+ rb->Base.PutValues = put_values_B5G6R5;
+ rb->Base.PutMonoValues = put_mono_values_B5G6R5;
+ }
+ else if (pixelFormat == PF_B5G5R5) {
+ rb->Base.GetRow = get_row_B5G5R5;
+ rb->Base.GetValues = get_values_B5G5R5;
+ rb->Base.PutRow = put_row_B5G5R5;
+ rb->Base.PutMonoRow = put_mono_row_B5G5R5;
+ rb->Base.PutValues = put_values_B5G5R5;
+ rb->Base.PutMonoValues = put_mono_values_B5G5R5;
+ }
+ else if (pixelFormat == PF_CI8) {
+ rb->Base.GetRow = get_row_CI8;
+ rb->Base.GetValues = get_values_CI8;
+ rb->Base.PutRow = put_row_CI8;
+ rb->Base.PutMonoRow = put_mono_row_CI8;
+ rb->Base.PutValues = put_values_CI8;
+ rb->Base.PutMonoValues = put_mono_values_CI8;
+ }
+
+ if (pixelFormat == PF_CI8) {
+ rb->Base.InternalFormat = GL_COLOR_INDEX8_EXT;
+ rb->Base._BaseFormat = GL_COLOR_INDEX;
+ }
+ else {
+ rb->Base.InternalFormat = GL_RGBA;
+ rb->Base._BaseFormat = GL_RGBA;
+ }
+ rb->Base.DataType = GL_UNSIGNED_BYTE;
+ rb->Base.Data = bufferStart;
+ }
+ return rb;
+}
+
+
+GLFBDevBufferPtr
+glFBDevCreateBuffer( const struct fb_fix_screeninfo *fixInfo,
+ const struct fb_var_screeninfo *varInfo,
+ const GLFBDevVisualPtr visual,
+ void *frontBuffer, void *backBuffer, size_t size )
+{
+ struct GLFBDevRenderbufferRec *frontrb, *backrb;
+ GLFBDevBufferPtr buf;
+
+ ASSERT(visual);
+ ASSERT(frontBuffer);
+ ASSERT(size > 0);
+
+ if (visual->fix.visual != fixInfo->visual ||
+ visual->fix.type != fixInfo->type ||
+ visual->var.bits_per_pixel != varInfo->bits_per_pixel ||
+ visual->var.grayscale != varInfo->grayscale ||
+ visual->var.red.offset != varInfo->red.offset ||
+ visual->var.green.offset != varInfo->green.offset ||
+ visual->var.blue.offset != varInfo->blue.offset ||
+ visual->var.transp.offset != varInfo->transp.offset) {
+ /* visual mismatch! */
+ return NULL;
+ }
+
+ buf = CALLOC_STRUCT(GLFBDevBufferRec);
+ if (!buf)
+ return NULL;
+
+ /* basic framebuffer setup */
+ _mesa_initialize_framebuffer(&buf->glframebuffer, &visual->glvisual);
+ /* add front renderbuffer */
+ frontrb = new_glfbdev_renderbuffer(frontBuffer, visual->pixelFormat);
+ _mesa_add_renderbuffer(&buf->glframebuffer, BUFFER_FRONT_LEFT,
+ &frontrb->Base);
+ /* add back renderbuffer */
+ if (visual->glvisual.doubleBufferMode) {
+ backrb = new_glfbdev_renderbuffer(backBuffer, visual->pixelFormat);
+ _mesa_add_renderbuffer(&buf->glframebuffer, BUFFER_BACK_LEFT,
+ &backrb->Base);
+ }
+ /* add software renderbuffers */
+ _mesa_add_soft_renderbuffers(&buf->glframebuffer,
+ GL_FALSE, /* color */
+ visual->glvisual.haveDepthBuffer,
+ visual->glvisual.haveStencilBuffer,
+ visual->glvisual.haveAccumBuffer,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux bufs */);
+
+
+
+ buf->fix = *fixInfo; /* struct assignment */
+ buf->var = *varInfo; /* struct assignment */
+ buf->visual = visual; /* ptr assignment */
+ buf->size = size;
+ buf->bytesPerPixel = visual->var.bits_per_pixel / 8;
+ frontrb->rowStride = visual->var.xres_virtual * buf->bytesPerPixel;
+ frontrb->bottom = (GLubyte *) frontrb->Base.Data
+ + (visual->var.yres_virtual - 1) * frontrb->rowStride;
+
+ if (visual->glvisual.doubleBufferMode) {
+ if (!backBuffer) {
+ /* malloc a back buffer */
+ backrb->Base.Data = _mesa_malloc(size);
+ if (!backrb->Base.Data) {
+ _mesa_free_framebuffer_data(&buf->glframebuffer);
+ _mesa_free(buf);
+ return NULL;
+ }
+ backrb->mallocedBuffer = GL_TRUE;
+ }
+ backrb->rowStride = frontrb->rowStride;
+ backrb->bottom = (GLubyte *) backrb->Base.Data
+ + (visual->var.yres_virtual - 1) * backrb->rowStride;
+ }
+ else {
+ backrb->bottom = NULL;
+ backrb->rowStride = 0;
+ }
+
+ return buf;
+}
+
+
+void
+glFBDevDestroyBuffer( GLFBDevBufferPtr buffer )
+{
+ if (buffer) {
+ /* check if destroying the current buffer */
+ GLFBDevBufferPtr curDraw = glFBDevGetCurrentDrawBuffer();
+ GLFBDevBufferPtr curRead = glFBDevGetCurrentReadBuffer();
+ if (buffer == curDraw || buffer == curRead) {
+ glFBDevMakeCurrent( NULL, NULL, NULL);
+ }
+ /* free the software depth, stencil, accum buffers */
+ _mesa_free_framebuffer_data(&buffer->glframebuffer);
+ _mesa_free(buffer);
+ }
+}
+
+
+int
+glFBDevGetBufferAttrib( const GLFBDevBufferPtr buffer, int attrib)
+{
+ (void) buffer;
+ (void) attrib;
+ return -1;
+}
+
+
+GLFBDevBufferPtr
+glFBDevGetCurrentDrawBuffer( void )
+{
+ GLFBDevContextPtr fbdevctx = glFBDevGetCurrentContext();
+ if (fbdevctx)
+ return fbdevctx->drawBuffer;
+ else
+ return NULL;
+}
+
+
+GLFBDevBufferPtr
+glFBDevGetCurrentReadBuffer( void )
+{
+ GLFBDevContextPtr fbdevctx = glFBDevGetCurrentContext();
+ if (fbdevctx)
+ return fbdevctx->readBuffer;
+ else
+ return NULL;
+}
+
+
+void
+glFBDevSwapBuffers( GLFBDevBufferPtr buffer )
+{
+ GLFBDevContextPtr fbdevctx = glFBDevGetCurrentContext();
+ struct GLFBDevRenderbufferRec *frontrb = (struct GLFBDevRenderbufferRec *)
+ buffer->glframebuffer.Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
+ struct GLFBDevRenderbufferRec *backrb = (struct GLFBDevRenderbufferRec *)
+ buffer->glframebuffer.Attachment[BUFFER_BACK_LEFT].Renderbuffer;
+
+ if (!buffer || !buffer->visual->glvisual.doubleBufferMode)
+ return;
+
+ /* check if swapping currently bound buffer */
+ if (fbdevctx->drawBuffer == buffer) {
+ /* flush pending rendering */
+ _mesa_notifySwapBuffers(&fbdevctx->glcontext);
+ }
+
+ ASSERT(frontrb->Base.Data);
+ ASSERT(backrb->Base.Data);
+ _mesa_memcpy(frontrb->Base.Data, backrb->Base.Data, buffer->size);
+}
+
+
+GLFBDevContextPtr
+glFBDevCreateContext( const GLFBDevVisualPtr visual, GLFBDevContextPtr share )
+{
+ GLFBDevContextPtr ctx;
+ GLcontext *glctx;
+ struct dd_function_table functions;
+
+ ASSERT(visual);
+
+ ctx = CALLOC_STRUCT(GLFBDevContextRec);
+ if (!ctx)
+ return NULL;
+
+ /* build table of device driver functions */
+ _mesa_init_driver_functions(&functions);
+ functions.GetString = get_string;
+ functions.UpdateState = update_state;
+ functions.GetBufferSize = get_buffer_size;
+ functions.Viewport = viewport;
+
+ if (!_mesa_initialize_context(&ctx->glcontext, &visual->glvisual,
+ share ? &share->glcontext : NULL,
+ &functions, (void *) ctx)) {
+ _mesa_free(ctx);
+ return NULL;
+ }
+
+ ctx->visual = visual;
+
+ /* Create module contexts */
+ glctx = (GLcontext *) &ctx->glcontext;
+ _swrast_CreateContext( glctx );
+ _ac_CreateContext( glctx );
+ _tnl_CreateContext( glctx );
+ _swsetup_CreateContext( glctx );
+ _swsetup_Wakeup( glctx );
+
+ /* swrast init */
+ {
+ struct swrast_device_driver *swdd;
+ swdd = _swrast_GetDeviceDriverReference( glctx );
+ swdd->SetBuffer = set_buffer;
+
+ /* no longer used */
+ swdd->WriteRGBASpan = NULL;
+ swdd->WriteRGBSpan = NULL;
+ swdd->WriteMonoRGBASpan = NULL;
+ swdd->WriteRGBAPixels = NULL;
+ swdd->WriteMonoRGBAPixels = NULL;
+ swdd->ReadRGBASpan = NULL;
+ swdd->ReadRGBAPixels = NULL;
+ }
+
+ /* use default TCL pipeline */
+ {
+ TNLcontext *tnl = TNL_CONTEXT(glctx);
+ tnl->Driver.RunPipeline = _tnl_run_pipeline;
+ }
+
+ _mesa_enable_sw_extensions(glctx);
+
+ return ctx;
+}
+
+
+void
+glFBDevDestroyContext( GLFBDevContextPtr context )
+{
+ GLFBDevContextPtr fbdevctx = glFBDevGetCurrentContext();
+
+ if (context) {
+ if (fbdevctx == context) {
+ /* destroying current context */
+ _mesa_make_current(NULL, NULL, NULL);
+ _mesa_notifyDestroy(&context->glcontext);
+ }
+ _mesa_free_context_data(&context->glcontext);
+ _mesa_free(context);
+ }
+}
+
+
+int
+glFBDevGetContextAttrib( const GLFBDevContextPtr context, int attrib)
+{
+ (void) context;
+ (void) attrib;
+ return -1;
+}
+
+
+GLFBDevContextPtr
+glFBDevGetCurrentContext( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ return (GLFBDevContextPtr) ctx;
+}
+
+
+int
+glFBDevMakeCurrent( GLFBDevContextPtr context,
+ GLFBDevBufferPtr drawBuffer,
+ GLFBDevBufferPtr readBuffer )
+{
+ if (context && drawBuffer && readBuffer) {
+ /* Make sure the context's visual and the buffers' visuals match.
+ * XXX we might do this by comparing specific fields like bits_per_pixel,
+ * visual, etc. in the future.
+ */
+ if (context->visual != drawBuffer->visual ||
+ context->visual != readBuffer->visual) {
+ return 0;
+ }
+ _mesa_make_current( &context->glcontext,
+ &drawBuffer->glframebuffer,
+ &readBuffer->glframebuffer );
+ context->drawBuffer = drawBuffer;
+ context->readBuffer = readBuffer;
+ context->curBuffer = drawBuffer;
+ }
+ else {
+ /* unbind */
+ _mesa_make_current( NULL, NULL, NULL );
+ }
+
+ return 1;
+}
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxapi.c b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxapi.c
new file mode 100644
index 000000000..e535e739b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxapi.c
@@ -0,0 +1,951 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.0
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/* Authors:
+ * David Bucciarelli
+ * Brian Paul
+ * Daryll Strauss
+ * Keith Whitwell
+ * Daniel Borca
+ * Hiroshi Morii
+ */
+
+
+/* fxapi.c - public interface to FX/Mesa functions (fxmesa.h) */
+
+
+#ifdef HAVE_CONFIG_H
+#include "conf.h"
+#endif
+
+#if defined(FX)
+#include "fxdrv.h"
+
+#include "drivers/common/driverfuncs.h"
+#include "framebuffer.h"
+
+#ifndef TDFX_DEBUG
+int TDFX_DEBUG = (0
+/* | VERBOSE_VARRAY */
+/* | VERBOSE_TEXTURE */
+/* | VERBOSE_IMMEDIATE */
+/* | VERBOSE_PIPELINE */
+/* | VERBOSE_DRIVER */
+/* | VERBOSE_STATE */
+/* | VERBOSE_API */
+/* | VERBOSE_DISPLAY_LIST */
+/* | VERBOSE_LIGHTING */
+/* | VERBOSE_PRIMS */
+/* | VERBOSE_VERTS */
+ );
+#endif
+
+static fxMesaContext fxMesaCurrentCtx = NULL;
+
+/*
+ * Status of 3Dfx hardware initialization
+ */
+
+static int glbGlideInitialized = 0;
+static int glb3DfxPresent = 0;
+static int glbTotNumCtx = 0;
+
+static GrHwConfiguration glbHWConfig;
+static int glbCurrentBoard = 0;
+
+
+#if defined(__WIN32__)
+static int
+cleangraphics(void)
+{
+ glbTotNumCtx = 1;
+ fxMesaDestroyContext(fxMesaCurrentCtx);
+
+ return 0;
+}
+#elif defined(__linux__)
+static void
+cleangraphics(void)
+{
+ glbTotNumCtx = 1;
+ fxMesaDestroyContext(fxMesaCurrentCtx);
+}
+
+static void
+cleangraphics_handler(int s)
+{
+ fprintf(stderr, "fxmesa: ERROR: received a not handled signal %d\n", s);
+
+ cleangraphics();
+/* abort(); */
+ exit(1);
+}
+#endif
+
+
+/*
+ * Query 3Dfx hardware presence/kind
+ */
+static GLboolean GLAPIENTRY fxQueryHardware (void)
+{
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxQueryHardware()\n");
+ }
+
+ if (!glbGlideInitialized) {
+ grGlideInit();
+ glb3DfxPresent = FX_grSstQueryHardware(&glbHWConfig);
+
+ glbGlideInitialized = 1;
+
+#if defined(__WIN32__)
+ _onexit((_onexit_t) cleangraphics);
+#elif defined(__linux__)
+ /* Only register handler if environment variable is not defined. */
+ if (!getenv("MESA_FX_NO_SIGNALS")) {
+ atexit(cleangraphics);
+ }
+#endif
+ }
+
+ return glb3DfxPresent;
+}
+
+
+/*
+ * Select the Voodoo board to use when creating
+ * a new context.
+ */
+GLint GLAPIENTRY fxMesaSelectCurrentBoard (int n)
+{
+ fxQueryHardware();
+
+ if ((n < 0) || (n >= glbHWConfig.num_sst))
+ return -1;
+
+ return glbHWConfig.SSTs[glbCurrentBoard = n].type;
+}
+
+
+fxMesaContext GLAPIENTRY fxMesaGetCurrentContext (void)
+{
+ return fxMesaCurrentCtx;
+}
+
+
+void GLAPIENTRY fxGetScreenGeometry (GLint *w, GLint *h)
+{
+ GLint width = 0;
+ GLint height = 0;
+
+ if (fxMesaCurrentCtx != NULL) {
+ width = fxMesaCurrentCtx->screen_width;
+ height = fxMesaCurrentCtx->screen_height;
+ }
+
+ if (w != NULL) {
+ *w = width;
+ }
+ if (h != NULL) {
+ *h = height;
+ }
+}
+
+
+/*
+ * 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;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ int i;
+
+ fprintf(stderr, "gl3DfxSetPaletteEXT(...)\n");
+
+ for (i = 0; i < 256; i++) {
+ fprintf(stderr, "\t%x\n", pal[i]);
+ }
+ }
+
+ if (fxMesa) {
+ fxMesa->haveGlobalPaletteTexture = 1;
+
+ grTexDownloadTable(GR_TEXTABLE_PALETTE, (GuTexPalette *) pal);
+ }
+}
+
+
+static GrScreenResolution_t fxBestResolution (int width, int height)
+{
+ static int resolutions[][3] = {
+ { GR_RESOLUTION_320x200, 320, 200 },
+ { GR_RESOLUTION_320x240, 320, 240 },
+ { GR_RESOLUTION_400x256, 400, 256 },
+ { GR_RESOLUTION_512x384, 512, 384 },
+ { GR_RESOLUTION_640x200, 640, 200 },
+ { GR_RESOLUTION_640x350, 640, 350 },
+ { GR_RESOLUTION_640x400, 640, 400 },
+ { GR_RESOLUTION_640x480, 640, 480 },
+ { GR_RESOLUTION_800x600, 800, 600 },
+ { GR_RESOLUTION_960x720, 960, 720 },
+ { GR_RESOLUTION_856x480, 856, 480 },
+ { GR_RESOLUTION_512x256, 512, 256 },
+ { GR_RESOLUTION_1024x768, 1024, 768 },
+ { GR_RESOLUTION_1280x1024, 1280, 1024 },
+ { GR_RESOLUTION_1600x1200, 1600, 1200 },
+ { GR_RESOLUTION_400x300, 400, 300 },
+ { GR_RESOLUTION_1152x864, 1152, 864 },
+ { GR_RESOLUTION_1280x960, 1280, 960 },
+ { GR_RESOLUTION_1600x1024, 1600, 1024 },
+ { GR_RESOLUTION_1792x1344, 1792, 1344 },
+ { GR_RESOLUTION_1856x1392, 1856, 1392 },
+ { GR_RESOLUTION_1920x1440, 1920, 1440 },
+ { GR_RESOLUTION_2048x1536, 2048, 1536 },
+ { GR_RESOLUTION_2048x2048, 2048, 2048 }
+ };
+
+ int i, size;
+ int lastvalidres = GR_RESOLUTION_640x480;
+ int min = 2048 * 2048; /* max is GR_RESOLUTION_2048x2048 */
+ GrResolution resTemplate = {
+ GR_QUERY_ANY,
+ GR_QUERY_ANY,
+ 2 /*GR_QUERY_ANY */,
+ GR_QUERY_ANY
+ };
+ GrResolution *presSupported;
+
+ fxQueryHardware();
+
+ size = grQueryResolutions(&resTemplate, NULL);
+ presSupported = malloc(size);
+
+ size /= sizeof(GrResolution);
+ grQueryResolutions(&resTemplate, presSupported);
+
+ for (i = 0; i < size; i++) {
+ int r = presSupported[i].resolution;
+ if ((width <= resolutions[r][1]) && (height <= resolutions[r][2])) {
+ if (min > (resolutions[r][1] * resolutions[r][2])) {
+ min = resolutions[r][1] * resolutions[r][2];
+ lastvalidres = r;
+ }
+ }
+ }
+
+ free(presSupported);
+
+ return resolutions[lastvalidres][0];
+}
+
+
+fxMesaContext GLAPIENTRY
+fxMesaCreateBestContext(GLuint win, GLint width, GLint height,
+ const GLint attribList[])
+{
+ int res = fxBestResolution(width, height);
+
+ if (res == -1) {
+ return NULL;
+ }
+
+ return fxMesaCreateContext(win, res, GR_REFRESH_60Hz, attribList);
+}
+
+
+/*
+ * Create a new FX/Mesa context and return a handle to it.
+ */
+fxMesaContext GLAPIENTRY
+fxMesaCreateContext(GLuint win,
+ GrScreenResolution_t res,
+ GrScreenRefresh_t ref, const GLint attribList[])
+{
+ fxMesaContext fxMesa = NULL;
+ GLcontext *ctx = NULL, *shareCtx = NULL;
+ struct dd_function_table functions;
+
+ int i;
+ const char *str;
+ int sliaa, numSLI, samplesPerChip;
+ struct SstCard_St *voodoo;
+ struct tdfx_glide *Glide;
+
+ GLboolean aux;
+ GLboolean doubleBuffer;
+ GLuint colDepth;
+ GLuint depthSize, alphaSize, stencilSize, accumSize;
+ GLuint redBits, greenBits, blueBits, alphaBits;
+ GrPixelFormat_t pixFmt;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxMesaCreateContext(...)\n");
+ }
+
+ /* Okay, first process the user flags */
+ aux = GL_FALSE;
+ doubleBuffer = GL_FALSE;
+ colDepth = 16;
+ depthSize = alphaSize = stencilSize = accumSize = 0;
+
+ i = 0;
+ while (attribList[i] != FXMESA_NONE) {
+ switch (attribList[i]) {
+ case FXMESA_COLORDEPTH:
+ colDepth = attribList[++i];
+ break;
+ case FXMESA_DOUBLEBUFFER:
+ doubleBuffer = GL_TRUE;
+ break;
+ case FXMESA_ALPHA_SIZE:
+ if ((alphaSize = attribList[++i])) {
+ aux = GL_TRUE;
+ }
+ break;
+ case FXMESA_DEPTH_SIZE:
+ if ((depthSize = attribList[++i])) {
+ aux = GL_TRUE;
+ }
+ break;
+ case FXMESA_STENCIL_SIZE:
+ stencilSize = attribList[++i];
+ break;
+ case FXMESA_ACCUM_SIZE:
+ accumSize = attribList[++i];
+ break;
+ /* XXX ugly hack here for sharing display lists */
+ case FXMESA_SHARE_CONTEXT:
+ shareCtx = (GLcontext *)attribList[++i];
+ break;
+ default:
+ fprintf(stderr, "fxMesaCreateContext: ERROR: wrong parameter (%d) passed\n", attribList[i]);
+ return NULL;
+ }
+ i++;
+ }
+
+ if (!fxQueryHardware()) {
+ str = "no Voodoo hardware!";
+ goto errorhandler;
+ }
+
+ grSstSelect(glbCurrentBoard);
+ /*grEnable(GR_OPENGL_MODE_EXT);*/ /* [koolsmoky] */
+ voodoo = &glbHWConfig.SSTs[glbCurrentBoard];
+
+ fxMesa = (fxMesaContext)CALLOC_STRUCT(tfxMesaContext);
+ if (!fxMesa) {
+ str = "private context";
+ goto errorhandler;
+ }
+
+ if (getenv("MESA_FX_INFO")) {
+ fxMesa->verbose = GL_TRUE;
+ }
+
+ fxMesa->type = voodoo->type;
+ fxMesa->HavePalExt = voodoo->HavePalExt && !getenv("MESA_FX_IGNORE_PALEXT");
+ fxMesa->HavePixExt = voodoo->HavePixExt && !getenv("MESA_FX_IGNORE_PIXEXT");
+ fxMesa->HaveTexFmt = voodoo->HaveTexFmt && !getenv("MESA_FX_IGNORE_TEXFMT");
+ fxMesa->HaveCmbExt = voodoo->HaveCmbExt && !getenv("MESA_FX_IGNORE_CMBEXT");
+ fxMesa->HaveMirExt = voodoo->HaveMirExt && !getenv("MESA_FX_IGNORE_MIREXT");
+ fxMesa->HaveTexUma = voodoo->HaveTexUma && !getenv("MESA_FX_IGNORE_TEXUMA");
+ fxMesa->Glide = glbHWConfig.Glide;
+ Glide = &fxMesa->Glide;
+ fxMesa->HaveTexus2 = Glide->txImgQuantize &&
+ Glide->txMipQuantize &&
+ Glide->txPalToNcc && !getenv("MESA_FX_IGNORE_TEXUS2");
+
+ /* Determine if we need vertex swapping, RGB order and SLI/AA */
+ sliaa = 0;
+ switch (fxMesa->type) {
+ case GR_SSTTYPE_VOODOO:
+ case GR_SSTTYPE_SST96:
+ case GR_SSTTYPE_Banshee:
+ fxMesa->bgrOrder = GL_TRUE;
+ fxMesa->snapVertices = (getenv("MESA_FX_NOSNAP") == NULL);
+ break;
+ case GR_SSTTYPE_Voodoo2:
+ fxMesa->bgrOrder = GL_TRUE;
+ fxMesa->snapVertices = GL_FALSE;
+ break;
+ case GR_SSTTYPE_Voodoo4:
+ case GR_SSTTYPE_Voodoo5:
+ /* number of SLI units and AA Samples per chip */
+ if ((str = Glide->grGetRegistryOrEnvironmentStringExt("SSTH3_SLI_AA_CONFIGURATION")) != NULL) {
+ sliaa = atoi(str);
+ }
+ case GR_SSTTYPE_Voodoo3:
+ default:
+ fxMesa->bgrOrder = GL_FALSE;
+ fxMesa->snapVertices = GL_FALSE;
+ break;
+ }
+ /* XXX todo - Add the old SLI/AA settings for Napalm. */
+ switch(voodoo->numChips) {
+ case 4: /* 4 chips */
+ switch(sliaa) {
+ case 8: /* 8 Sample AA */
+ numSLI = 1;
+ samplesPerChip = 2;
+ break;
+ case 7: /* 4 Sample AA */
+ numSLI = 1;
+ samplesPerChip = 1;
+ break;
+ case 6: /* 2 Sample AA */
+ numSLI = 2;
+ samplesPerChip = 1;
+ break;
+ default:
+ numSLI = 4;
+ samplesPerChip = 1;
+ }
+ break;
+ case 2: /* 2 chips */
+ switch(sliaa) {
+ case 4: /* 4 Sample AA */
+ numSLI = 1;
+ samplesPerChip = 2;
+ break;
+ case 3: /* 2 Sample AA */
+ numSLI = 1;
+ samplesPerChip = 1;
+ break;
+ default:
+ numSLI = 2;
+ samplesPerChip = 1;
+ }
+ break;
+ default: /* 1 chip */
+ switch(sliaa) {
+ case 1: /* 2 Sample AA */
+ numSLI = 1;
+ samplesPerChip = 2;
+ break;
+ default:
+ numSLI = 1;
+ samplesPerChip = 1;
+ }
+ }
+
+ fxMesa->fsaa = samplesPerChip * voodoo->numChips / numSLI; /* 1:noFSAA, 2:2xFSAA, 4:4xFSAA, 8:8xFSAA */
+
+ switch (fxMesa->colDepth = colDepth) {
+ case 15:
+ redBits = 5;
+ greenBits = 5;
+ blueBits = 5;
+ alphaBits = depthSize ? 1 : 8;
+ switch(fxMesa->fsaa) {
+ case 8:
+ pixFmt = GR_PIXFMT_AA_8_ARGB_1555;
+ break;
+ case 4:
+ pixFmt = GR_PIXFMT_AA_4_ARGB_1555;
+ break;
+ case 2:
+ pixFmt = GR_PIXFMT_AA_2_ARGB_1555;
+ break;
+ default:
+ pixFmt = GR_PIXFMT_ARGB_1555;
+ }
+ break;
+ case 16:
+ redBits = 5;
+ greenBits = 6;
+ blueBits = 5;
+ alphaBits = depthSize ? 0 : 8;
+ switch(fxMesa->fsaa) {
+ case 8:
+ pixFmt = GR_PIXFMT_AA_8_RGB_565;
+ break;
+ case 4:
+ pixFmt = GR_PIXFMT_AA_4_RGB_565;
+ break;
+ case 2:
+ pixFmt = GR_PIXFMT_AA_2_RGB_565;
+ break;
+ default:
+ pixFmt = GR_PIXFMT_RGB_565;
+ }
+ break;
+ case 24:
+ fxMesa->colDepth = 32;
+ case 32:
+ redBits = 8;
+ greenBits = 8;
+ blueBits = 8;
+ alphaBits = 8;
+ switch(fxMesa->fsaa) {
+ case 8:
+ pixFmt = GR_PIXFMT_AA_8_ARGB_8888;
+ break;
+ case 4:
+ pixFmt = GR_PIXFMT_AA_4_ARGB_8888;
+ break;
+ case 2:
+ pixFmt = GR_PIXFMT_AA_2_ARGB_8888;
+ break;
+ default:
+ pixFmt = GR_PIXFMT_ARGB_8888;
+ }
+ break;
+ default:
+ str = "pixelFormat";
+ goto errorhandler;
+ }
+
+ /* Tips:
+ * 1. we don't bother setting/checking AUX for stencil, because we'll decide
+ * later whether we have HW stencil, based on depth buffer (thus AUX is
+ * properly set)
+ * 2. when both DEPTH and ALPHA are enabled, depth should win. However, it is
+ * not clear whether 15bpp and 32bpp require AUX alpha buffer. Furthermore,
+ * alpha buffering is required only if destination alpha is used in alpha
+ * blending; alpha blending modes that do not use destination alpha can be
+ * used w/o alpha buffer.
+ * 3. `alphaBits' is what we can provide
+ * `alphaSize' is what app requests
+ * if we cannot provide enough bits for alpha buffer, we should fallback to
+ * SW alpha. However, setting `alphaBits' to `alphaSize' might confuse some
+ * of the span functions...
+ */
+
+ fxMesa->haveHwAlpha = GL_FALSE;
+ if (alphaSize && (alphaSize <= alphaBits)) {
+ alphaSize = alphaBits;
+ fxMesa->haveHwAlpha = GL_TRUE;
+ }
+
+ fxMesa->haveHwStencil = (fxMesa->HavePixExt && stencilSize && depthSize == 24);
+
+ fxMesa->haveZBuffer = depthSize > 0;
+ fxMesa->haveDoubleBuffer = doubleBuffer;
+ fxMesa->haveGlobalPaletteTexture = GL_FALSE;
+ fxMesa->board = glbCurrentBoard;
+
+ fxMesa->haveTwoTMUs = (voodoo->nTexelfx > 1);
+
+ if ((str = Glide->grGetRegistryOrEnvironmentStringExt("FX_GLIDE_NUM_TMU"))) {
+ if (atoi(str) <= 1) {
+ fxMesa->haveTwoTMUs = GL_FALSE;
+ }
+ }
+
+ if ((str = Glide->grGetRegistryOrEnvironmentStringExt("FX_GLIDE_SWAPPENDINGCOUNT"))) {
+ fxMesa->maxPendingSwapBuffers = atoi(str);
+ if (fxMesa->maxPendingSwapBuffers > 6) {
+ fxMesa->maxPendingSwapBuffers = 6;
+ } else if (fxMesa->maxPendingSwapBuffers < 0) {
+ fxMesa->maxPendingSwapBuffers = 0;
+ }
+ } else {
+ fxMesa->maxPendingSwapBuffers = 2;
+ }
+
+ if ((str = Glide->grGetRegistryOrEnvironmentStringExt("FX_GLIDE_SWAPINTERVAL"))) {
+ fxMesa->swapInterval = atoi(str);
+ } else {
+ fxMesa->swapInterval = 0;
+ }
+
+ BEGIN_BOARD_LOCK();
+ if (fxMesa->HavePixExt) {
+ fxMesa->glideContext = Glide->grSstWinOpenExt((FxU32)win, res, ref,
+ GR_COLORFORMAT_ABGR, GR_ORIGIN_LOWER_LEFT,
+ pixFmt,
+ 2, aux);
+ } else if (pixFmt == GR_PIXFMT_RGB_565) {
+ fxMesa->glideContext = grSstWinOpen((FxU32)win, res, ref,
+ GR_COLORFORMAT_ABGR, GR_ORIGIN_LOWER_LEFT,
+ 2, aux);
+ } else {
+ fxMesa->glideContext = 0;
+ }
+ END_BOARD_LOCK();
+ if (!fxMesa->glideContext) {
+ str = "grSstWinOpen";
+ goto errorhandler;
+ }
+
+ /* screen */
+ fxMesa->screen_width = FX_grSstScreenWidth();
+ fxMesa->screen_height = FX_grSstScreenHeight();
+
+ /* window inside screen */
+ fxMesa->width = fxMesa->screen_width;
+ fxMesa->height = fxMesa->screen_height;
+
+ /* scissor inside window */
+ fxMesa->clipMinX = 0;
+ fxMesa->clipMaxX = fxMesa->width;
+ fxMesa->clipMinY = 0;
+ fxMesa->clipMaxY = fxMesa->height;
+
+ if (fxMesa->verbose) {
+ FxI32 tmuRam, fbRam;
+
+ /* Not that it matters, but tmuRam and fbRam change after grSstWinOpen. */
+ tmuRam = voodoo->tmuConfig[GR_TMU0].tmuRam;
+ fbRam = voodoo->fbRam;
+ BEGIN_BOARD_LOCK();
+ grGet(GR_MEMORY_TMU, 4, &tmuRam);
+ grGet(GR_MEMORY_FB, 4, &fbRam);
+ END_BOARD_LOCK();
+
+ fprintf(stderr, "Voodoo Using Glide %s\n", grGetString(GR_VERSION));
+ fprintf(stderr, "Voodoo Board: %d/%d, %s, %d GPU\n",
+ fxMesa->board + 1,
+ glbHWConfig.num_sst,
+ grGetString(GR_HARDWARE),
+ voodoo->numChips);
+ fprintf(stderr, "Voodoo Memory: FB = %ld, TM = %d x %ld\n",
+ fbRam,
+ voodoo->nTexelfx,
+ tmuRam);
+ fprintf(stderr, "Voodoo Screen: %dx%d:%d %s, %svertex snapping\n",
+ fxMesa->screen_width,
+ fxMesa->screen_height,
+ colDepth,
+ fxMesa->bgrOrder ? "BGR" : "RGB",
+ fxMesa->snapVertices ? "" : "no ");
+ }
+
+ sprintf(fxMesa->rendererString, "Mesa %s v0.63 %s%s",
+ grGetString(GR_RENDERER),
+ grGetString(GR_HARDWARE),
+ ((fxMesa->type < GR_SSTTYPE_Voodoo4) && (voodoo->numChips > 1)) ? " SLI" : "");
+
+ fxMesa->glVis = _mesa_create_visual(GL_TRUE, /* RGB mode */
+ doubleBuffer,
+ GL_FALSE, /* stereo */
+ redBits, /* RGBA.R bits */
+ greenBits, /* RGBA.G bits */
+ blueBits, /* RGBA.B bits */
+ alphaSize, /* RGBA.A bits */
+ 0, /* index bits */
+ depthSize, /* depth_size */
+ stencilSize, /* stencil_size */
+ accumSize,
+ accumSize,
+ accumSize,
+ alphaSize ? accumSize : 0,
+ 1);
+ if (!fxMesa->glVis) {
+ str = "_mesa_create_visual";
+ goto errorhandler;
+ }
+
+ _mesa_init_driver_functions(&functions);
+ ctx = fxMesa->glCtx = _mesa_create_context(fxMesa->glVis, shareCtx,
+ &functions, (void *) fxMesa);
+ if (!ctx) {
+ str = "_mesa_create_context";
+ goto errorhandler;
+ }
+
+
+ if (!fxDDInitFxMesaContext(fxMesa)) {
+ str = "fxDDInitFxMesaContext";
+ goto errorhandler;
+ }
+
+
+ fxMesa->glBuffer = _mesa_create_framebuffer(fxMesa->glVis);
+#if 0
+/* XXX this is a complete mess :(
+ * _mesa_add_soft_renderbuffers
+ * driNewRenderbuffer
+ */
+ GL_FALSE, /* no software depth */
+ stencilSize && !fxMesa->haveHwStencil,
+ fxMesa->glVis->accumRedBits > 0,
+ alphaSize && !fxMesa->haveHwAlpha);
+#endif
+ if (!fxMesa->glBuffer) {
+ str = "_mesa_create_framebuffer";
+ goto errorhandler;
+ }
+
+ glbTotNumCtx++;
+
+ /* install signal handlers */
+#if defined(__linux__)
+ /* Only install if environment var. is not set. */
+ if (!getenv("MESA_FX_NO_SIGNALS")) {
+ signal(SIGINT, cleangraphics_handler);
+ signal(SIGHUP, cleangraphics_handler);
+ signal(SIGPIPE, cleangraphics_handler);
+ signal(SIGFPE, cleangraphics_handler);
+ signal(SIGBUS, cleangraphics_handler);
+ signal(SIGILL, cleangraphics_handler);
+ signal(SIGSEGV, cleangraphics_handler);
+ signal(SIGTERM, cleangraphics_handler);
+ }
+#endif
+
+ return fxMesa;
+
+errorhandler:
+ if (fxMesa) {
+ if (fxMesa->glideContext) {
+ grSstWinClose(fxMesa->glideContext);
+ fxMesa->glideContext = 0;
+ }
+
+ if (fxMesa->state) {
+ FREE(fxMesa->state);
+ }
+ if (fxMesa->fogTable) {
+ FREE(fxMesa->fogTable);
+ }
+ if (fxMesa->glBuffer) {
+ _mesa_destroy_framebuffer(fxMesa->glBuffer);
+ }
+ if (fxMesa->glVis) {
+ _mesa_destroy_visual(fxMesa->glVis);
+ }
+ if (fxMesa->glCtx) {
+ _mesa_destroy_context(fxMesa->glCtx);
+ }
+ FREE(fxMesa);
+ }
+
+ fprintf(stderr, "fxMesaCreateContext: ERROR: %s\n", str);
+ return NULL;
+}
+
+
+/*
+ * Function to set the new window size in the context (mainly for the Voodoo Rush)
+ */
+void GLAPIENTRY
+fxMesaUpdateScreenSize(fxMesaContext fxMesa)
+{
+ fxMesa->width = FX_grSstScreenWidth();
+ fxMesa->height = FX_grSstScreenHeight();
+}
+
+
+/*
+ * Destroy the given FX/Mesa context.
+ */
+void GLAPIENTRY
+fxMesaDestroyContext(fxMesaContext fxMesa)
+{
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxMesaDestroyContext(...)\n");
+ }
+
+ if (!fxMesa)
+ return;
+
+ if (fxMesa->verbose) {
+ fprintf(stderr, "Misc Stats:\n");
+ fprintf(stderr, " # swap buffer: %u\n", fxMesa->stats.swapBuffer);
+
+ if (!fxMesa->stats.swapBuffer)
+ fxMesa->stats.swapBuffer = 1;
+
+ fprintf(stderr, "Textures Stats:\n");
+ fprintf(stderr, " Free texture memory on TMU0: %d\n",
+ fxMesa->freeTexMem[FX_TMU0]);
+ if (fxMesa->haveTwoTMUs)
+ fprintf(stderr, " Free texture memory on TMU1: %d\n",
+ fxMesa->freeTexMem[FX_TMU1]);
+ fprintf(stderr, " # request to TMM to upload a texture objects: %u\n",
+ fxMesa->stats.reqTexUpload);
+ fprintf(stderr,
+ " # request to TMM to upload a texture objects per swapbuffer: %.2f\n",
+ fxMesa->stats.reqTexUpload / (float) fxMesa->stats.swapBuffer);
+ fprintf(stderr, " # texture objects uploaded: %u\n",
+ fxMesa->stats.texUpload);
+ fprintf(stderr, " # texture objects uploaded per swapbuffer: %.2f\n",
+ fxMesa->stats.texUpload / (float) fxMesa->stats.swapBuffer);
+ fprintf(stderr, " # MBs uploaded to texture memory: %.2f\n",
+ fxMesa->stats.memTexUpload / (float) (1 << 20));
+ fprintf(stderr,
+ " # MBs uploaded to texture memory per swapbuffer: %.2f\n",
+ (fxMesa->stats.memTexUpload /
+ (float) fxMesa->stats.swapBuffer) / (float) (1 << 20));
+ }
+
+ glbTotNumCtx--;
+
+ if (!glbTotNumCtx && getenv("MESA_FX_INFO")) {
+ GrSstPerfStats_t st;
+
+ FX_grSstPerfStats(&st);
+
+ fprintf(stderr, "Pixels Stats:\n");
+ fprintf(stderr, " # pixels processed (minus buffer clears): %u\n",
+ (unsigned) st.pixelsIn);
+ fprintf(stderr, " # pixels not drawn due to chroma key test failure: %u\n",
+ (unsigned) st.chromaFail);
+ fprintf(stderr, " # pixels not drawn due to depth test failure: %u\n",
+ (unsigned) st.zFuncFail);
+ fprintf(stderr,
+ " # pixels not drawn due to alpha test failure: %u\n",
+ (unsigned) st.aFuncFail);
+ fprintf(stderr, " # pixels drawn (including buffer clears and LFB writes): %u\n",
+ (unsigned) st.pixelsOut);
+ }
+
+ /* close the hardware first,
+ * so we can debug atexit problems (memory leaks, etc).
+ */
+ grSstWinClose(fxMesa->glideContext);
+ fxCloseHardware();
+
+ fxDDDestroyFxMesaContext(fxMesa); /* must be before _mesa_destroy_context */
+ _mesa_destroy_visual(fxMesa->glVis);
+ _mesa_destroy_context(fxMesa->glCtx);
+ _mesa_destroy_framebuffer(fxMesa->glBuffer);
+ fxTMClose(fxMesa); /* must be after _mesa_destroy_context */
+
+ FREE(fxMesa);
+
+ if (fxMesa == fxMesaCurrentCtx)
+ fxMesaCurrentCtx = NULL;
+}
+
+
+/*
+ * Make the specified FX/Mesa context the current one.
+ */
+void GLAPIENTRY
+fxMesaMakeCurrent(fxMesaContext fxMesa)
+{
+ if (!fxMesa) {
+ _mesa_make_current(NULL, NULL, NULL);
+ fxMesaCurrentCtx = NULL;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxMesaMakeCurrent(NULL)\n");
+ }
+
+ return;
+ }
+
+ /* if this context is already the current one, we can return early */
+ if (fxMesaCurrentCtx == fxMesa
+ && fxMesaCurrentCtx->glCtx == _mesa_get_current_context()) {
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxMesaMakeCurrent(NOP)\n");
+ }
+
+ return;
+ }
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxMesaMakeCurrent(...)\n");
+ }
+
+ if (fxMesaCurrentCtx)
+ grGlideGetState((GrState *) fxMesaCurrentCtx->state);
+
+ fxMesaCurrentCtx = fxMesa;
+
+ grSstSelect(fxMesa->board);
+ grGlideSetState((GrState *) fxMesa->state);
+
+ _mesa_make_current(fxMesa->glCtx, fxMesa->glBuffer, fxMesa->glBuffer);
+
+ fxSetupDDPointers(fxMesa->glCtx);
+}
+
+
+/*
+ * Swap front/back buffers for current context if double buffered.
+ */
+void GLAPIENTRY
+fxMesaSwapBuffers(void)
+{
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxMesaSwapBuffers()\n");
+ }
+
+ if (fxMesaCurrentCtx) {
+ _mesa_notifySwapBuffers(fxMesaCurrentCtx->glCtx);
+
+ if (fxMesaCurrentCtx->haveDoubleBuffer) {
+
+ grBufferSwap(fxMesaCurrentCtx->swapInterval);
+
+#if 0
+ /*
+ * Don't allow swap buffer commands to build up!
+ */
+ while (FX_grGetInteger(GR_PENDING_BUFFERSWAPS) >
+ fxMesaCurrentCtx->maxPendingSwapBuffers)
+ /* The driver is able to sleep when waiting for the completation
+ of multiple swapbuffer operations instead of wasting
+ CPU time (NOTE: you must uncomment the following line in the
+ in order to enable this option) */
+ /* usleep(10000); */
+ ;
+#endif
+
+ fxMesaCurrentCtx->stats.swapBuffer++;
+ }
+ }
+}
+
+
+/*
+ * Shutdown Glide library
+ */
+void GLAPIENTRY
+fxCloseHardware(void)
+{
+ if (glbGlideInitialized) {
+ if (glbTotNumCtx == 0) {
+ grGlideShutdown();
+ glbGlideInitialized = 0;
+ }
+ }
+}
+
+
+#else
+
+
+/*
+ * 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;
+}
+
+#endif /* FX */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxdd.c b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxdd.c
new file mode 100644
index 000000000..4e9df208b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxdd.c
@@ -0,0 +1,2197 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+/* Authors:
+ * David Bucciarelli
+ * Brian Paul
+ * Daryll Strauss
+ * Keith Whitwell
+ * Daniel Borca
+ * Hiroshi Morii
+ */
+
+/* fxdd.c - 3Dfx VooDoo Mesa device driver functions */
+
+
+#ifdef HAVE_CONFIG_H
+#include "conf.h"
+#endif
+
+#if defined(FX)
+
+#include "image.h"
+#include "mtypes.h"
+#include "fxdrv.h"
+#include "buffers.h"
+#include "enums.h"
+#include "extensions.h"
+#include "macros.h"
+#include "texstore.h"
+#include "teximage.h"
+#include "swrast/swrast.h"
+#include "swrast/s_context.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+#include "array_cache/acache.h"
+
+
+
+/* lookup table for scaling 4 bit colors up to 8 bits */
+GLuint FX_rgb_scale_4[16] = {
+ 0, 17, 34, 51, 68, 85, 102, 119,
+ 136, 153, 170, 187, 204, 221, 238, 255
+};
+
+/* lookup table for scaling 5 bit colors up to 8 bits */
+GLuint FX_rgb_scale_5[32] = {
+ 0, 8, 16, 25, 33, 41, 49, 58,
+ 66, 74, 82, 90, 99, 107, 115, 123,
+ 132, 140, 148, 156, 165, 173, 181, 189,
+ 197, 206, 214, 222, 230, 239, 247, 255
+};
+
+/* lookup table for scaling 6 bit colors up to 8 bits */
+GLuint FX_rgb_scale_6[64] = {
+ 0, 4, 8, 12, 16, 20, 24, 28,
+ 32, 36, 40, 45, 49, 53, 57, 61,
+ 65, 69, 73, 77, 81, 85, 89, 93,
+ 97, 101, 105, 109, 113, 117, 121, 125,
+ 130, 134, 138, 142, 146, 150, 154, 158,
+ 162, 166, 170, 174, 178, 182, 186, 190,
+ 194, 198, 202, 206, 210, 215, 219, 223,
+ 227, 231, 235, 239, 243, 247, 251, 255
+};
+
+
+/*
+ * Disable color by masking out R, G, B, A
+ */
+static void fxDisableColor (fxMesaContext fxMesa)
+{
+ if (fxMesa->colDepth == 32) {
+ /* 32bpp mode */
+ fxMesa->Glide.grColorMaskExt(FXFALSE, FXFALSE, FXFALSE, FXFALSE);
+ } else {
+ /* 15/16 bpp mode */
+ grColorMask(FXFALSE, FXFALSE);
+ }
+}
+
+
+/**********************************************************************/
+/***** Miscellaneous functions *****/
+/**********************************************************************/
+
+/* Return buffer size information */
+static void
+fxDDGetBufferSize(GLframebuffer *buffer, GLuint *width, GLuint *height)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (ctx && FX_CONTEXT(ctx)) {
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxDDGetBufferSize(...)\n");
+ }
+
+ *width = fxMesa->width;
+ *height = fxMesa->height;
+ }
+}
+
+
+static void
+fxDDViewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ /* poll for window size change and realloc software Z/stencil/etc if needed */
+ _mesa_ResizeBuffersMESA();
+}
+
+
+/* Implements glClearColor() */
+static void
+fxDDClearColor(GLcontext * ctx, const GLfloat color[4])
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLubyte col[4];
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxDDClearColor(%f, %f, %f, %f)\n",
+ color[0], color[1], color[2], color[3]);
+ }
+
+ CLAMPED_FLOAT_TO_UBYTE(col[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(col[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(col[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(col[3], color[3]);
+
+ fxMesa->clearC = FXCOLOR4(col);
+ fxMesa->clearA = col[3];
+}
+
+
+/* Clear the color and/or depth buffers */
+static void fxDDClear( GLcontext *ctx,
+ GLbitfield mask, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLbitfield softwareMask = mask & (BUFFER_BIT_ACCUM);
+ const GLuint stencil_size = fxMesa->haveHwStencil ? ctx->Visual.stencilBits : 0;
+ const FxU32 clearD = (FxU32) (ctx->DrawBuffer->_DepthMaxF * ctx->Depth.Clear);
+ const FxU8 clearS = (FxU8) (ctx->Stencil.Clear & 0xff);
+
+ if ( TDFX_DEBUG & MESA_VERBOSE ) {
+ fprintf( stderr, "fxDDClear( %d, %d, %d, %d )\n",
+ (int) x, (int) y, (int) width, (int) height );
+ }
+
+ /* we can't clear accum buffers nor stereo */
+ mask &= ~(BUFFER_BIT_ACCUM | BUFFER_BIT_FRONT_RIGHT | BUFFER_BIT_BACK_RIGHT);
+
+ /* Need this check to respond to certain HW updates */
+ if (fxMesa->new_state & (FX_NEW_SCISSOR | FX_NEW_COLOR_MASK)) {
+ fxSetupScissor(ctx);
+ fxSetupColorMask(ctx);
+ fxMesa->new_state &= ~(FX_NEW_SCISSOR | FX_NEW_COLOR_MASK);
+ }
+
+ /*
+ * As per GL spec, color masking should be obeyed when clearing
+ */
+ if (ctx->Visual.greenBits != 8) {
+ /* can only do color masking if running in 24/32bpp on Napalm */
+ if (ctx->Color.ColorMask[RCOMP] != ctx->Color.ColorMask[GCOMP] ||
+ ctx->Color.ColorMask[GCOMP] != ctx->Color.ColorMask[BCOMP]) {
+ softwareMask |= (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT));
+ mask &= ~(BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT);
+ }
+ }
+
+ if (fxMesa->haveHwStencil) {
+ /*
+ * If we want to clear stencil, it must be enabled
+ * in the HW, even if the stencil test is not enabled
+ * in the OGL state.
+ */
+ BEGIN_BOARD_LOCK();
+ if (mask & BUFFER_BIT_STENCIL) {
+ fxMesa->Glide.grStencilMaskExt(fxMesa->unitsState.stencilWriteMask);
+ /* set stencil ref value = desired clear value */
+ fxMesa->Glide.grStencilFuncExt(GR_CMP_ALWAYS, clearS, 0xff);
+ fxMesa->Glide.grStencilOpExt(GR_STENCILOP_REPLACE,
+ GR_STENCILOP_REPLACE, GR_STENCILOP_REPLACE);
+ grEnable(GR_STENCIL_MODE_EXT);
+ }
+ else {
+ grDisable(GR_STENCIL_MODE_EXT);
+ }
+ END_BOARD_LOCK();
+ } else if (mask & BUFFER_BIT_STENCIL) {
+ softwareMask |= (mask & (BUFFER_BIT_STENCIL));
+ mask &= ~(BUFFER_BIT_STENCIL);
+ }
+
+ /*
+ * This may be ugly, but it's needed in order to work around a number
+ * of Glide bugs.
+ */
+ BEGIN_CLIP_LOOP();
+ {
+ /*
+ * This could probably be done fancier but doing each possible case
+ * explicitly is less error prone.
+ */
+ switch (mask & ~BUFFER_BIT_STENCIL) {
+ case BUFFER_BIT_BACK_LEFT | BUFFER_BIT_DEPTH:
+ /* back buffer & depth */
+ grDepthMask(FXTRUE);
+ grRenderBuffer(GR_BUFFER_BACKBUFFER);
+ if (stencil_size > 0) {
+ fxMesa->Glide.grBufferClearExt(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD, clearS);
+ }
+ else
+ grBufferClear(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD);
+ break;
+ case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_DEPTH:
+ /* XXX it appears that the depth buffer isn't cleared when
+ * glRenderBuffer(GR_BUFFER_FRONTBUFFER) is set.
+ * This is a work-around/
+ */
+ /* clear depth */
+ grDepthMask(FXTRUE);
+ fxDisableColor(fxMesa);
+ grRenderBuffer(GR_BUFFER_BACKBUFFER);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD, clearS);
+ else
+ grBufferClear(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD);
+ fxSetupColorMask(ctx);
+ grDepthMask(FXFALSE);
+ /* clear front */
+ grRenderBuffer(GR_BUFFER_FRONTBUFFER);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD, clearS);
+ else
+ grBufferClear(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD);
+ break;
+ case BUFFER_BIT_BACK_LEFT:
+ /* back buffer only */
+ grDepthMask(FXFALSE);
+ grRenderBuffer(GR_BUFFER_BACKBUFFER);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD, clearS);
+ else
+ grBufferClear(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD);
+ break;
+ case BUFFER_BIT_FRONT_LEFT:
+ /* front buffer only */
+ grDepthMask(FXFALSE);
+ grRenderBuffer(GR_BUFFER_FRONTBUFFER);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD, clearS);
+ else
+ grBufferClear(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD);
+ break;
+ case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT:
+ /* front and back */
+ grDepthMask(FXFALSE);
+ grRenderBuffer(GR_BUFFER_BACKBUFFER);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD, clearS);
+ else
+ grBufferClear(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD);
+ grRenderBuffer(GR_BUFFER_FRONTBUFFER);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD, clearS);
+ else
+ grBufferClear(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD);
+ break;
+ case BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT | BUFFER_BIT_DEPTH:
+ /* clear back and depth */
+ grDepthMask(FXTRUE);
+ grRenderBuffer(GR_BUFFER_BACKBUFFER);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD, clearS);
+ else
+ grBufferClear(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD);
+ /* clear front */
+ grDepthMask(FXFALSE);
+ grRenderBuffer(GR_BUFFER_FRONTBUFFER);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD, clearS);
+ else
+ grBufferClear(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD);
+ break;
+ case BUFFER_BIT_DEPTH:
+ /* just the depth buffer */
+ grDepthMask(FXTRUE);
+ fxDisableColor(fxMesa);
+ grRenderBuffer(GR_BUFFER_BACKBUFFER);
+ if (stencil_size > 0)
+ fxMesa->Glide.grBufferClearExt(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD, clearS);
+ else
+ grBufferClear(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD);
+ fxSetupColorMask(ctx);
+ break;
+ default:
+ /* clear no color buffers or depth buffer but might clear stencil */
+ if ((stencil_size > 0) && (mask & BUFFER_BIT_STENCIL)) {
+ /* XXX need this RenderBuffer call to work around Glide bug */
+ grDepthMask(FXFALSE);
+ grRenderBuffer(GR_BUFFER_BACKBUFFER);
+ fxDisableColor(fxMesa);
+ fxMesa->Glide.grBufferClearExt(fxMesa->clearC,
+ fxMesa->clearA,
+ clearD, clearS);
+ fxSetupColorMask(ctx);
+ }
+ }
+ }
+ END_CLIP_LOOP();
+
+ if (fxMesa->haveHwStencil) {
+ /* We changed the stencil state above. Restore it! */
+ fxSetupStencil(ctx);
+ }
+ fxSetupDepthTest(ctx);
+ grRenderBuffer(fxMesa->currentFB);
+
+ if (softwareMask)
+ _swrast_Clear( ctx, softwareMask, all, x, y, width, height );
+}
+
+
+/* Set the buffer used for drawing */
+/* XXX support for separate read/draw buffers hasn't been tested */
+/* XXX GL_NONE disables color, but fails to correctly maintain state */
+static void
+fxDDSetDrawBuffer(GLcontext * ctx, GLenum mode)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxDDSetDrawBuffer(%x)\n", (int)mode);
+ }
+
+ if (mode == GL_FRONT_LEFT) {
+ fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
+ grRenderBuffer(fxMesa->currentFB);
+ }
+ else if (mode == GL_BACK_LEFT) {
+ fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
+ grRenderBuffer(fxMesa->currentFB);
+ }
+ else if (mode == GL_NONE) {
+ fxDisableColor(fxMesa);
+ }
+ else {
+ /* we'll need a software fallback */
+ /* XXX not implemented */
+ }
+
+ /* update s/w fallback state */
+ _swrast_DrawBuffer(ctx, mode);
+}
+
+
+static void
+fxDDDrawBitmap2 (GLcontext *ctx, GLint px, GLint py,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ GrLfbWriteMode_t mode;
+ FxU16 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 (swrast->_RasterMask & (ALPHATEST_BIT |
+ /*BLEND_BIT |*/ /* blending ok, through pixpipe */
+ DEPTH_BIT | /* could be done with RGB:DEPTH */
+ FOG_BIT | /* could be done with RGB:DEPTH */
+ LOGIC_OP_BIT |
+ /*CLIP_BIT |*/ /* clipping ok, below */
+ STENCIL_BIT |
+ MASKING_BIT |
+ MULTI_DRAW_BIT |
+ OCCLUSION_BIT | /* nope! at least not yet */
+ TEXTURE_BIT |
+ FRAGPROG_BIT)) {
+ _swrast_Bitmap(ctx, px, py, width, height, unpack, bitmap);
+ return;
+ }
+
+ /* make sure the pixelpipe is configured correctly */
+ fxSetupFXUnits(ctx);
+
+ /* FIXME! _RasterMask & CLIP_BIT gets set if we're out of Viewport, also! */
+ 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;
+ }
+ else {
+ finalUnpack = unpack;
+ }
+
+ /* compute pixel value */
+ {
+ GLint r = (GLint) (ctx->Current.RasterColor[RCOMP] * 255.0f);
+ GLint g = (GLint) (ctx->Current.RasterColor[GCOMP] * 255.0f);
+ GLint b = (GLint) (ctx->Current.RasterColor[BCOMP] * 255.0f);
+ GLint a = (GLint) (ctx->Current.RasterColor[ACOMP] * 255.0f);
+ if (fxMesa->colDepth == 15) {
+ color = TDFXPACKCOLOR1555(b, g, r, a);
+ mode = GR_LFBWRITEMODE_1555;
+ } else {
+ color = fxMesa->bgrOrder ? TDFXPACKCOLOR565(r, g, b) : TDFXPACKCOLOR565(b, g, r);
+ mode = GR_LFBWRITEMODE_565;
+ }
+ }
+
+ info.size = sizeof(info);
+ if (!grLfbLock(GR_LFB_WRITE_ONLY,
+ fxMesa->currentFB,
+ mode,
+ GR_ORIGIN_LOWER_LEFT, FXTRUE, &info)) {
+ _swrast_Bitmap(ctx, px, py, width, height, finalUnpack, bitmap);
+ return;
+ }
+
+ {
+ const GLint winX = 0;
+ const GLint winY = 0;
+ /* The dest stride depends on the hardware and whether we're drawing
+ * to the front or back buffer. This compile-time test seems to do
+ * the job for now.
+ */
+ const GLint dstStride = info.strideInBytes / 2; /* stride in GLushorts */
+
+ GLint row;
+ /* compute dest address of bottom-left pixel in bitmap */
+ GLushort *dst = (GLushort *) info.lfbPtr
+ + (winY + py) * dstStride + (winX + px);
+
+ for (row = 0; row < height; row++) {
+ const GLubyte *src =
+ (const GLubyte *) _mesa_image_address2d(finalUnpack,
+ bitmap, width, height,
+ GL_COLOR_INDEX, GL_BITMAP,
+ 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) {
+ 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) {
+ dst[col] = color;
+ }
+ if (mask == 1U) {
+ src++;
+ mask = 128U;
+ }
+ else {
+ mask = mask >> 1;
+ }
+ }
+ if (mask != 128)
+ src++;
+ }
+ dst += dstStride;
+ }
+ }
+
+ grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+}
+
+static void
+fxDDDrawBitmap4 (GLcontext *ctx, GLint px, GLint py,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ FxU32 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 ((swrast->_RasterMask & (/*ALPHATEST_BIT |*/
+ /*BLEND_BIT |*/ /* blending ok, through pixpipe */
+ DEPTH_BIT | /* could be done with RGB:DEPTH */
+ FOG_BIT | /* could be done with RGB:DEPTH */
+ LOGIC_OP_BIT |
+ /*CLIP_BIT |*/ /* clipping ok, below */
+ STENCIL_BIT |
+ /*MASKING_BIT |*/ /* masking ok, we're in 32bpp */
+ MULTI_DRAW_BIT |
+ OCCLUSION_BIT | /* nope! at least not yet */
+ TEXTURE_BIT |
+ FRAGPROG_BIT))
+ ) {
+ _swrast_Bitmap(ctx, px, py, width, height, unpack, bitmap);
+ return;
+ }
+
+ /* make sure the pixelpipe is configured correctly */
+ fxSetupFXUnits(ctx);
+
+ /* FIXME! _RasterMask & CLIP_BIT gets set if we're out of Viewport, also! */
+ 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;
+ }
+ else {
+ finalUnpack = unpack;
+ }
+
+ /* compute pixel value */
+ {
+ GLint r = (GLint) (ctx->Current.RasterColor[RCOMP] * 255.0f);
+ GLint g = (GLint) (ctx->Current.RasterColor[GCOMP] * 255.0f);
+ GLint b = (GLint) (ctx->Current.RasterColor[BCOMP] * 255.0f);
+ GLint a = (GLint) (ctx->Current.RasterColor[ACOMP] * 255.0f);
+ color = TDFXPACKCOLOR8888(b, g, r, a);
+ }
+
+ info.size = sizeof(info);
+ if (!grLfbLock(GR_LFB_WRITE_ONLY,
+ fxMesa->currentFB,
+ GR_LFBWRITEMODE_8888,
+ GR_ORIGIN_LOWER_LEFT, FXTRUE, &info)) {
+ _swrast_Bitmap(ctx, px, py, width, height, finalUnpack, bitmap);
+ return;
+ }
+
+ {
+ const GLint winX = 0;
+ const GLint winY = 0;
+ /* The dest stride depends on the hardware and whether we're drawing
+ * to the front or back buffer. This compile-time test seems to do
+ * the job for now.
+ */
+ const GLint dstStride = info.strideInBytes / 4; /* stride in GLuints */
+
+ GLint row;
+ /* compute dest address of bottom-left pixel in bitmap */
+ GLuint *dst = (GLuint *) info.lfbPtr
+ + (winY + py) * dstStride + (winX + px);
+
+ for (row = 0; row < height; row++) {
+ const GLubyte *src =
+ (const GLubyte *) _mesa_image_address2d(finalUnpack,
+ bitmap, width, height,
+ GL_COLOR_INDEX, GL_BITMAP,
+ 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) {
+ 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) {
+ dst[col] = color;
+ }
+ if (mask == 1U) {
+ src++;
+ mask = 128U;
+ }
+ else {
+ mask = mask >> 1;
+ }
+ }
+ if (mask != 128)
+ src++;
+ }
+ dst += dstStride;
+ }
+ }
+
+ grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+}
+
+
+static void
+fxDDReadPixels565 (GLcontext * ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ GLvoid *dstImage)
+{
+ if (ctx->_ImageTransferState/* & (IMAGE_SCALE_BIAS_BIT|IMAGE_MAP_COLOR_BIT)*/) {
+ _swrast_ReadPixels(ctx, x, y, width, height, format, type,
+ packing, dstImage);
+ return;
+ }
+ else {
+ 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 = 0;
+ const GLint winY = fxMesa->height - 1;
+ const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
+ const GLushort *src = (const GLushort *) info.lfbPtr
+ + (winY - y) * srcStride + (winX + x);
+ GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dstImage,
+ width, height, format,
+ type, 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];
+ *d++ = FX_rgb_scale_5[(pixel >> 11) & 0x1f];
+ *d++ = FX_rgb_scale_6[(pixel >> 5) & 0x3f];
+ *d++ = FX_rgb_scale_5[ pixel & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 27) & 0x1f];
+ *d++ = FX_rgb_scale_6[(pixel >> 21) & 0x3f];
+ *d++ = FX_rgb_scale_5[(pixel >> 16) & 0x1f];
+ }
+ if (extraPixel) {
+ GLushort pixel = src[width - 1];
+ *d++ = FX_rgb_scale_5[(pixel >> 11) & 0x1f];
+ *d++ = FX_rgb_scale_6[(pixel >> 5) & 0x3f];
+ *d++ = FX_rgb_scale_5[ pixel & 0x1f];
+ }
+ dst += dstStride;
+ src -= srcStride;
+ }
+ }
+ 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];
+ *d++ = FX_rgb_scale_5[(pixel >> 11) & 0x1f];
+ *d++ = FX_rgb_scale_6[(pixel >> 5) & 0x3f];
+ *d++ = FX_rgb_scale_5[ pixel & 0x1f];
+ *d++ = 255;
+ *d++ = FX_rgb_scale_5[(pixel >> 27) & 0x1f];
+ *d++ = FX_rgb_scale_6[(pixel >> 21) & 0x3f];
+ *d++ = FX_rgb_scale_5[(pixel >> 16) & 0x1f];
+ *d++ = 255;
+ }
+ if (extraPixel) {
+ const GLushort pixel = src[width - 1];
+ *d++ = FX_rgb_scale_5[(pixel >> 11) & 0x1f];
+ *d++ = FX_rgb_scale_6[(pixel >> 5) & 0x3f];
+ *d++ = FX_rgb_scale_5[ pixel & 0x1f];
+ *d++ = 255;
+ }
+ dst += dstStride;
+ src -= srcStride;
+ }
+ }
+ 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;
+ }
+ }
+ else {
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ END_BOARD_LOCK();
+ _swrast_ReadPixels(ctx, x, y, width, height, format, type,
+ packing, dstImage);
+ return;
+ }
+
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ }
+ END_BOARD_LOCK();
+ }
+}
+
+static void
+fxDDReadPixels555 (GLcontext * ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ GLvoid *dstImage)
+{
+ if (ctx->_ImageTransferState/* & (IMAGE_SCALE_BIAS_BIT|IMAGE_MAP_COLOR_BIT)*/) {
+ _swrast_ReadPixels(ctx, x, y, width, height, format, type,
+ packing, dstImage);
+ return;
+ }
+ else {
+ 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 = 0;
+ const GLint winY = fxMesa->height - 1;
+ const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */
+ const GLushort *src = (const GLushort *) info.lfbPtr
+ + (winY - y) * srcStride + (winX + x);
+ GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dstImage,
+ width, height, format,
+ type, 0, 0);
+ GLint dstStride =
+ _mesa_image_row_stride(packing, width, format, type);
+
+ if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
+ /* convert 5R5G5B 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];
+ *d++ = FX_rgb_scale_5[(pixel >> 10) & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 5) & 0x1f];
+ *d++ = FX_rgb_scale_5[ pixel & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 26) & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 21) & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 16) & 0x1f];
+ }
+ if (extraPixel) {
+ GLushort pixel = src[width - 1];
+ *d++ = FX_rgb_scale_5[(pixel >> 10) & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 5) & 0x1f];
+ *d++ = FX_rgb_scale_5[ pixel & 0x1f];
+ }
+ dst += dstStride;
+ src -= srcStride;
+ }
+ }
+ 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];
+ *d++ = FX_rgb_scale_5[(pixel >> 10) & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 5) & 0x1f];
+ *d++ = FX_rgb_scale_5[ pixel & 0x1f];
+ *d++ = (pixel & 0x8000) ? 255 : 0;
+ *d++ = FX_rgb_scale_5[(pixel >> 26) & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 21) & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 16) & 0x1f];
+ *d++ = (pixel & 0x80000000) ? 255 : 0;
+ }
+ if (extraPixel) {
+ const GLushort pixel = src[width - 1];
+ *d++ = FX_rgb_scale_5[(pixel >> 10) & 0x1f];
+ *d++ = FX_rgb_scale_5[(pixel >> 5) & 0x1f];
+ *d++ = FX_rgb_scale_5[ pixel & 0x1f];
+ *d++ = (pixel & 0x8000) ? 255 : 0;
+ }
+ dst += dstStride;
+ src -= srcStride;
+ }
+ }
+ else if (format == GL_BGRA && type == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
+ /* directly memcpy 5R5G5B 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;
+ }
+ }
+ else {
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ END_BOARD_LOCK();
+ _swrast_ReadPixels(ctx, x, y, width, height, format, type,
+ packing, dstImage);
+ return;
+ }
+
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ }
+ END_BOARD_LOCK();
+ }
+}
+
+static void
+fxDDReadPixels8888 (GLcontext * ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ GLvoid *dstImage)
+{
+ if (ctx->_ImageTransferState/* & (IMAGE_SCALE_BIAS_BIT|IMAGE_MAP_COLOR_BIT)*/) {
+ _swrast_ReadPixels(ctx, x, y, width, height, format, type,
+ packing, dstImage);
+ return;
+ }
+ else {
+ 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 = 0;
+ const GLint winY = fxMesa->height - 1;
+ const GLint srcStride = info.strideInBytes / 4; /* stride in GLuints */
+ const GLuint *src = (const GLuint *) info.lfbPtr
+ + (winY - y) * srcStride + (winX + x);
+ GLubyte *dst = (GLubyte *) _mesa_image_address2d(packing, dstImage,
+ width, height, format,
+ type, 0, 0);
+ GLint dstStride =
+ _mesa_image_row_stride(packing, width, format, type);
+
+ if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
+ /* convert 8A8R8G8B into 8R8G8B */
+ GLint row, col;
+ for (row = 0; row < height; row++) {
+ GLubyte *d = dst;
+ for (col = 0; col < width; col++) {
+ const GLuint pixel = ((const GLuint *) src)[col];
+ *d++ = pixel >> 16;
+ *d++ = pixel >> 8;
+ *d++ = pixel;
+ }
+ dst += dstStride;
+ src -= srcStride;
+ }
+ }
+ else if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
+ /* 8A8R8G8B pixels into client's buffer */
+ GLint row, col;
+ for (row = 0; row < height; row++) {
+ GLubyte *d = dst;
+ for (col = 0; col < width; col++) {
+ const GLuint pixel = ((const GLuint *) src)[col];
+ *d++ = pixel >> 16;
+ *d++ = pixel >> 8;
+ *d++ = pixel;
+ *d++ = pixel >> 24;
+ }
+ dst += dstStride;
+ src -= srcStride;
+ }
+ }
+ else if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) {
+ /* convert 8A8R8G8B into 5R6G5B */
+ GLint row, col;
+ for (row = 0; row < height; row++) {
+ GLushort *d = (GLushort *)dst;
+ for (col = 0; col < width; col++) {
+ const GLuint pixel = ((const GLuint *) src)[col];
+ *d++ = (((pixel >> 16) & 0xf8) << 8) |
+ (((pixel >> 8) & 0xfc) << 3) |
+ ((pixel & 0xf8) >> 3);
+ }
+ dst += dstStride;
+ src -= srcStride;
+ }
+ }
+ else {
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ END_BOARD_LOCK();
+ _swrast_ReadPixels(ctx, x, y, width, height, format, type,
+ packing, dstImage);
+ return;
+ }
+
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ }
+ END_BOARD_LOCK();
+ }
+}
+
+
+static void
+fxDDDrawPixels555 (GLcontext * ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid * pixels)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ const struct gl_pixelstore_attrib *finalUnpack;
+ struct gl_pixelstore_attrib scissoredUnpack;
+
+ if (ctx->Pixel.ZoomX != 1.0F ||
+ ctx->Pixel.ZoomY != 1.0F ||
+ (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT|
+ IMAGE_MAP_COLOR_BIT)) ||
+ (swrast->_RasterMask & (ALPHATEST_BIT |
+ /*BLEND_BIT |*/ /* blending ok, through pixpipe */
+ DEPTH_BIT | /* could be done with RGB:DEPTH */
+ FOG_BIT | /* could be done with RGB:DEPTH */
+ LOGIC_OP_BIT |
+ /*CLIP_BIT |*/ /* clipping ok, below */
+ STENCIL_BIT |
+ MASKING_BIT |
+ MULTI_DRAW_BIT |
+ OCCLUSION_BIT | /* nope! at least not yet */
+ TEXTURE_BIT |
+ FRAGPROG_BIT)) ||
+ fxMesa->fallback)
+ {
+ _swrast_DrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels );
+ return;
+ }
+
+ /* make sure the pixelpipe is configured correctly */
+ fxSetupFXUnits(ctx);
+
+ /* FIXME! _RasterMask & CLIP_BIT gets set if we're out of Viewport, also! */
+ 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 (x < ctx->Scissor.X) {
+ scissoredUnpack.SkipPixels += (ctx->Scissor.X - x);
+ width -= (ctx->Scissor.X - x);
+ x = ctx->Scissor.X;
+ }
+ /* clip right */
+ if (x + width >= ctx->Scissor.X + ctx->Scissor.Width) {
+ width -= (x + width - (ctx->Scissor.X + ctx->Scissor.Width));
+ }
+ /* clip bottom */
+ if (y < ctx->Scissor.Y) {
+ scissoredUnpack.SkipRows += (ctx->Scissor.Y - y);
+ height -= (ctx->Scissor.Y - y);
+ y = ctx->Scissor.Y;
+ }
+ /* clip top */
+ if (y + height >= ctx->Scissor.Y + ctx->Scissor.Height) {
+ height -= (y + height - (ctx->Scissor.Y + ctx->Scissor.Height));
+ }
+
+ if (width <= 0 || height <= 0)
+ return;
+ }
+ else {
+ finalUnpack = unpack;
+ }
+
+ info.size = sizeof(info);
+ if (!grLfbLock(GR_LFB_WRITE_ONLY,
+ fxMesa->currentFB,
+ GR_LFBWRITEMODE_1555,
+ GR_ORIGIN_LOWER_LEFT, FXTRUE, &info)) {
+ _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels);
+ return;
+ }
+
+ {
+ const GLint winX = 0;
+ const GLint winY = 0;
+
+ const GLint dstStride = info.strideInBytes / 2; /* stride in GLushorts */
+ GLushort *dst = (GLushort *) info.lfbPtr + (winY + y) * dstStride + (winX + x);
+
+ if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
+ GLint row;
+ for (row = 0; row < height; row++) {
+ GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
+ pixels, width, height, format, type, row, 0);
+ GLint col;
+ for (col = 0; col < width; col++) {
+ dst[col] = TDFXPACKCOLOR1555(src[2], src[1], src[0], src[3]);
+ src += 4;
+ }
+ dst += dstStride;
+ }
+ }
+ else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
+ GLint row;
+ for (row = 0; row < height; row++) {
+ GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
+ pixels, width, height, format, type, row, 0);
+ GLint col;
+ for (col = 0; col < width; col++) {
+ dst[col] = TDFXPACKCOLOR1555(src[2], src[1], src[0], 255);
+ src += 3;
+ }
+ dst += dstStride;
+ }
+ }
+ else {
+ grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+ _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels);
+ return;
+ }
+
+ }
+
+ grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+}
+
+
+static void
+fxDDDrawPixels565 (GLcontext * ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid * pixels)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ const struct gl_pixelstore_attrib *finalUnpack;
+ struct gl_pixelstore_attrib scissoredUnpack;
+
+ if (ctx->Pixel.ZoomX != 1.0F ||
+ ctx->Pixel.ZoomY != 1.0F ||
+ (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT|
+ IMAGE_MAP_COLOR_BIT)) ||
+ (swrast->_RasterMask & (ALPHATEST_BIT |
+ /*BLEND_BIT |*/ /* blending ok, through pixpipe */
+ DEPTH_BIT | /* could be done with RGB:DEPTH */
+ FOG_BIT | /* could be done with RGB:DEPTH */
+ LOGIC_OP_BIT |
+ /*CLIP_BIT |*/ /* clipping ok, below */
+ STENCIL_BIT |
+ MASKING_BIT |
+ MULTI_DRAW_BIT |
+ OCCLUSION_BIT | /* nope! at least not yet */
+ TEXTURE_BIT |
+ FRAGPROG_BIT)) ||
+ fxMesa->fallback)
+ {
+ _swrast_DrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels );
+ return;
+ }
+
+ /* make sure the pixelpipe is configured correctly */
+ fxSetupFXUnits(ctx);
+
+ /* FIXME! _RasterMask & CLIP_BIT gets set if we're out of Viewport, also! */
+ 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 (x < ctx->Scissor.X) {
+ scissoredUnpack.SkipPixels += (ctx->Scissor.X - x);
+ width -= (ctx->Scissor.X - x);
+ x = ctx->Scissor.X;
+ }
+ /* clip right */
+ if (x + width >= ctx->Scissor.X + ctx->Scissor.Width) {
+ width -= (x + width - (ctx->Scissor.X + ctx->Scissor.Width));
+ }
+ /* clip bottom */
+ if (y < ctx->Scissor.Y) {
+ scissoredUnpack.SkipRows += (ctx->Scissor.Y - y);
+ height -= (ctx->Scissor.Y - y);
+ y = ctx->Scissor.Y;
+ }
+ /* clip top */
+ if (y + height >= ctx->Scissor.Y + ctx->Scissor.Height) {
+ height -= (y + height - (ctx->Scissor.Y + ctx->Scissor.Height));
+ }
+
+ if (width <= 0 || height <= 0)
+ return;
+ }
+ else {
+ finalUnpack = unpack;
+ }
+
+ info.size = sizeof(info);
+ if (!grLfbLock(GR_LFB_WRITE_ONLY,
+ fxMesa->currentFB,
+ GR_LFBWRITEMODE_565,
+ GR_ORIGIN_LOWER_LEFT, FXTRUE, &info)) {
+ _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels);
+ return;
+ }
+
+ {
+ const GLint winX = 0;
+ const GLint winY = 0;
+
+ const GLint dstStride = info.strideInBytes / 2; /* stride in GLushorts */
+ GLushort *dst = (GLushort *) info.lfbPtr + (winY + y) * dstStride + (winX + x);
+
+ if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
+ GLint row;
+ for (row = 0; row < height; row++) {
+ GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
+ pixels, width, height, format, type, row, 0);
+ GLint col;
+ for (col = 0; col < width; col++) {
+ dst[col] = TDFXPACKCOLOR565(src[2], src[1], src[0]);
+ src += 4;
+ }
+ dst += dstStride;
+ }
+ }
+ else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
+ GLint row;
+ for (row = 0; row < height; row++) {
+ GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
+ pixels, width, height, format, type, row, 0);
+ GLint col;
+ for (col = 0; col < width; col++) {
+ dst[col] = TDFXPACKCOLOR565(src[2], src[1], src[0]);
+ src += 3;
+ }
+ dst += dstStride;
+ }
+ }
+ else {
+ grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+ _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels);
+ return;
+ }
+
+ }
+
+ grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+}
+
+
+static void
+fxDDDrawPixels565_rev (GLcontext * ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid * pixels)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ const struct gl_pixelstore_attrib *finalUnpack;
+ struct gl_pixelstore_attrib scissoredUnpack;
+
+ if (ctx->Pixel.ZoomX != 1.0F ||
+ ctx->Pixel.ZoomY != 1.0F ||
+ (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT|
+ IMAGE_MAP_COLOR_BIT)) ||
+ (swrast->_RasterMask & (ALPHATEST_BIT |
+ /*BLEND_BIT |*/ /* blending ok, through pixpipe */
+ DEPTH_BIT | /* could be done with RGB:DEPTH */
+ FOG_BIT | /* could be done with RGB:DEPTH */
+ LOGIC_OP_BIT |
+ /*CLIP_BIT |*/ /* clipping ok, below */
+ STENCIL_BIT |
+ MASKING_BIT |
+ MULTI_DRAW_BIT |
+ OCCLUSION_BIT | /* nope! at least not yet */
+ TEXTURE_BIT |
+ FRAGPROG_BIT)) ||
+ fxMesa->fallback)
+ {
+ _swrast_DrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels );
+ return;
+ }
+
+ /* make sure the pixelpipe is configured correctly */
+ fxSetupFXUnits(ctx);
+
+ /* FIXME! _RasterMask & CLIP_BIT gets set if we're out of Viewport, also! */
+ 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 (x < ctx->Scissor.X) {
+ scissoredUnpack.SkipPixels += (ctx->Scissor.X - x);
+ width -= (ctx->Scissor.X - x);
+ x = ctx->Scissor.X;
+ }
+ /* clip right */
+ if (x + width >= ctx->Scissor.X + ctx->Scissor.Width) {
+ width -= (x + width - (ctx->Scissor.X + ctx->Scissor.Width));
+ }
+ /* clip bottom */
+ if (y < ctx->Scissor.Y) {
+ scissoredUnpack.SkipRows += (ctx->Scissor.Y - y);
+ height -= (ctx->Scissor.Y - y);
+ y = ctx->Scissor.Y;
+ }
+ /* clip top */
+ if (y + height >= ctx->Scissor.Y + ctx->Scissor.Height) {
+ height -= (y + height - (ctx->Scissor.Y + ctx->Scissor.Height));
+ }
+
+ if (width <= 0 || height <= 0)
+ return;
+ }
+ else {
+ finalUnpack = unpack;
+ }
+
+ info.size = sizeof(info);
+ if (!grLfbLock(GR_LFB_WRITE_ONLY,
+ fxMesa->currentFB,
+ GR_LFBWRITEMODE_565,
+ GR_ORIGIN_LOWER_LEFT, FXTRUE, &info)) {
+ _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels);
+ return;
+ }
+
+ {
+ const GLint winX = 0;
+ const GLint winY = 0;
+
+ const GLint dstStride = info.strideInBytes / 2; /* stride in GLushorts */
+ GLushort *dst = (GLushort *) info.lfbPtr + (winY + y) * dstStride + (winX + x);
+
+ if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
+ GLint row;
+ for (row = 0; row < height; row++) {
+ GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
+ pixels, width, height, format, type, row, 0);
+ GLint col;
+ for (col = 0; col < width; col++) {
+ dst[col] = TDFXPACKCOLOR565(src[0], src[1], src[2]);
+ src += 4;
+ }
+ dst += dstStride;
+ }
+ }
+ else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
+ GLint row;
+ for (row = 0; row < height; row++) {
+ GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
+ pixels, width, height, format, type, row, 0);
+ GLint col;
+ for (col = 0; col < width; col++) {
+ dst[col] = TDFXPACKCOLOR565(src[0], src[1], src[2]);
+ src += 3;
+ }
+ dst += dstStride;
+ }
+ }
+ else {
+ grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+ _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels);
+ return;
+ }
+
+ }
+
+ grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+}
+
+
+static void
+fxDDDrawPixels8888 (GLcontext * ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid * pixels)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ const struct gl_pixelstore_attrib *finalUnpack;
+ struct gl_pixelstore_attrib scissoredUnpack;
+
+ if (ctx->Pixel.ZoomX != 1.0F ||
+ ctx->Pixel.ZoomY != 1.0F ||
+ (ctx->_ImageTransferState & (IMAGE_SCALE_BIAS_BIT|
+ IMAGE_MAP_COLOR_BIT)) ||
+ (swrast->_RasterMask & (/*ALPHATEST_BIT |*/
+ /*BLEND_BIT |*/ /* blending ok, through pixpipe */
+ DEPTH_BIT | /* could be done with RGB:DEPTH */
+ FOG_BIT | /* could be done with RGB:DEPTH */
+ LOGIC_OP_BIT |
+ /*CLIP_BIT |*/ /* clipping ok, below */
+ STENCIL_BIT |
+ /*MASKING_BIT |*/ /* masking ok, we're in 32bpp */
+ MULTI_DRAW_BIT |
+ OCCLUSION_BIT | /* nope! at least not yet */
+ TEXTURE_BIT |
+ FRAGPROG_BIT)) ||
+ fxMesa->fallback)
+ {
+ _swrast_DrawPixels( ctx, x, y, width, height, format, type,
+ unpack, pixels );
+ return;
+ }
+
+ /* make sure the pixelpipe is configured correctly */
+ fxSetupFXUnits(ctx);
+
+ /* FIXME! _RasterMask & CLIP_BIT gets set if we're out of Viewport, also! */
+ 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 (x < ctx->Scissor.X) {
+ scissoredUnpack.SkipPixels += (ctx->Scissor.X - x);
+ width -= (ctx->Scissor.X - x);
+ x = ctx->Scissor.X;
+ }
+ /* clip right */
+ if (x + width >= ctx->Scissor.X + ctx->Scissor.Width) {
+ width -= (x + width - (ctx->Scissor.X + ctx->Scissor.Width));
+ }
+ /* clip bottom */
+ if (y < ctx->Scissor.Y) {
+ scissoredUnpack.SkipRows += (ctx->Scissor.Y - y);
+ height -= (ctx->Scissor.Y - y);
+ y = ctx->Scissor.Y;
+ }
+ /* clip top */
+ if (y + height >= ctx->Scissor.Y + ctx->Scissor.Height) {
+ height -= (y + height - (ctx->Scissor.Y + ctx->Scissor.Height));
+ }
+
+ if (width <= 0 || height <= 0)
+ return;
+ }
+ else {
+ finalUnpack = unpack;
+ }
+
+ info.size = sizeof(info);
+ if (!grLfbLock(GR_LFB_WRITE_ONLY,
+ fxMesa->currentFB,
+ GR_LFBWRITEMODE_8888,
+ GR_ORIGIN_LOWER_LEFT, FXTRUE, &info)) {
+ _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels);
+ return;
+ }
+
+ {
+ const GLint winX = 0;
+ const GLint winY = 0;
+
+ const GLint dstStride = info.strideInBytes / 4; /* stride in GLuints */
+ GLuint *dst = (GLuint *) info.lfbPtr + (winY + y) * dstStride + (winX + x);
+
+ if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
+ /* directly memcpy 8A8R8G8B pixels to screen */
+ const GLint widthInBytes = width * 4;
+ GLint row;
+ for (row = 0; row < height; row++) {
+ GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
+ pixels, width, height, format, type, row, 0);
+ MEMCPY(dst, src, widthInBytes);
+ dst += dstStride;
+ }
+ }
+ else if (format == GL_RGB && type == GL_UNSIGNED_BYTE) {
+ GLint row;
+ for (row = 0; row < height; row++) {
+ GLubyte *src = (GLubyte *) _mesa_image_address2d(finalUnpack,
+ pixels, width, height, format, type, row, 0);
+ GLint col;
+ for (col = 0; col < width; col++) {
+ dst[col] = TDFXPACKCOLOR8888(src[2], src[1], src[0], 255);
+ src += 3;
+ }
+ dst += dstStride;
+ }
+ }
+ else {
+ grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+ _swrast_DrawPixels(ctx, x, y, width, height, format, type, finalUnpack, pixels);
+ return;
+ }
+
+ }
+
+ grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB);
+}
+
+
+static void
+fxDDFinish(GLcontext * ctx)
+{
+ grFlush();
+}
+
+
+
+
+
+/* KW: Put the word Mesa in the render string because quakeworld
+ * checks for this rather than doing a glGet(GL_MAX_TEXTURE_SIZE).
+ * Why?
+ */
+static const GLubyte *
+fxDDGetString(GLcontext * ctx, GLenum name)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ switch (name) {
+ case GL_RENDERER:
+ return (GLubyte *)fxMesa->rendererString;
+#if __WIN32__ /* hack to advertise vanilla extension names */
+ case GL_EXTENSIONS:
+ if (ctx->Extensions.String == NULL) {
+ GLubyte *ext = _mesa_make_extension_string(ctx);
+ if (ext != NULL) {
+ ctx->Extensions.String = _mesa_malloc(strlen((char *)ext) + 256);
+ if (ctx->Extensions.String != NULL) {
+ strcpy((char *)ctx->Extensions.String, (char *)ext);
+ /* put any additional extension names here */
+#if 0
+ strcat((char *)ctx->Extensions.String, " 3DFX_set_global_palette");
+#endif
+#if __WIN32__
+ strcat((char *)ctx->Extensions.String, " WGL_3DFX_gamma_control");
+ strcat((char *)ctx->Extensions.String, " WGL_EXT_swap_control");
+ strcat((char *)ctx->Extensions.String, " WGL_EXT_extensions_string WGL_ARB_extensions_string");
+#endif
+ /* put any additional extension names here */
+ _mesa_free(ext);
+ } else {
+ ctx->Extensions.String = ext;
+ }
+ }
+ }
+ return ctx->Extensions.String;
+#endif
+ default:
+ return NULL;
+ }
+}
+
+static const struct tnl_pipeline_stage *fx_pipeline[] = {
+ &_tnl_vertex_transform_stage, /* XXX todo - Add the fastpath here */
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ &_tnl_point_attenuation_stage,
+#if defined(FEATURE_NV_vertex_program) || defined(FEATURE_ARB_vertex_program)
+ &_tnl_arb_vertex_program_stage,
+ &_tnl_vertex_program_stage,
+#endif
+ &_tnl_render_stage,
+ 0,
+};
+
+
+
+
+int
+fxDDInitFxMesaContext(fxMesaContext fxMesa)
+{
+ GLcontext *ctx = fxMesa->glCtx;
+
+ FX_setupGrVertexLayout();
+
+ fxMesa->color = 0xffffffff;
+ fxMesa->clearC = 0;
+ fxMesa->clearA = 0;
+
+ fxMesa->stats.swapBuffer = 0;
+ fxMesa->stats.reqTexUpload = 0;
+ fxMesa->stats.texUpload = 0;
+ fxMesa->stats.memTexUpload = 0;
+
+ fxMesa->tmuSrc = FX_TMU_NONE;
+ fxMesa->lastUnitsMode = FX_UM_NONE;
+ fxTMInit(fxMesa);
+
+ /* FX units setup */
+
+ fxMesa->unitsState.alphaTestEnabled = GL_FALSE;
+ fxMesa->unitsState.alphaTestFunc = GL_ALWAYS;
+ fxMesa->unitsState.alphaTestRefValue = 0.0;
+
+ fxMesa->unitsState.blendEnabled = GL_FALSE;
+ fxMesa->unitsState.blendSrcFuncRGB = GR_BLEND_ONE;
+ fxMesa->unitsState.blendDstFuncRGB = GR_BLEND_ZERO;
+ fxMesa->unitsState.blendSrcFuncAlpha = GR_BLEND_ONE;
+ fxMesa->unitsState.blendDstFuncAlpha = GR_BLEND_ZERO;
+ fxMesa->unitsState.blendEqRGB = GR_BLEND_OP_ADD;
+ fxMesa->unitsState.blendEqAlpha = GR_BLEND_OP_ADD;
+
+ fxMesa->unitsState.depthTestEnabled = GL_FALSE;
+ fxMesa->unitsState.depthMask = GL_TRUE;
+ fxMesa->unitsState.depthTestFunc = GL_LESS;
+ fxMesa->unitsState.depthBias = 0;
+
+ fxMesa->unitsState.stencilWriteMask = 0xff;
+
+ if (fxMesa->colDepth == 32) {
+ /* 32bpp */
+ fxMesa->Glide.grColorMaskExt(FXTRUE, FXTRUE, FXTRUE, fxMesa->haveHwAlpha);
+ } else {
+ /* 15/16 bpp mode */
+ grColorMask(FXTRUE, fxMesa->haveHwAlpha);
+ }
+
+ fxMesa->currentFB = fxMesa->haveDoubleBuffer ? GR_BUFFER_BACKBUFFER : GR_BUFFER_FRONTBUFFER;
+ grRenderBuffer(fxMesa->currentFB);
+
+ fxMesa->state = MALLOC(FX_grGetInteger(GR_GLIDE_STATE_SIZE));
+ fxMesa->fogTable = (GrFog_t *) MALLOC(FX_grGetInteger(GR_FOG_TABLE_ENTRIES) *
+ sizeof(GrFog_t));
+
+ if (!fxMesa->state || !fxMesa->fogTable) {
+ if (fxMesa->state)
+ FREE(fxMesa->state);
+ if (fxMesa->fogTable)
+ FREE(fxMesa->fogTable);
+ return 0;
+ }
+
+ if (fxMesa->haveZBuffer) {
+ grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER);
+ }
+
+ if (!fxMesa->bgrOrder) {
+ grLfbWriteColorFormat(GR_COLORFORMAT_ABGR);
+ }
+
+ if (fxMesa->Glide.grSetNumPendingBuffers != NULL) {
+ fxMesa->Glide.grSetNumPendingBuffers(fxMesa->maxPendingSwapBuffers);
+ }
+
+ fxMesa->textureAlign = FX_grGetInteger(GR_TEXTURE_ALIGN);
+ /* [koolsmoky] */
+ {
+ char *env;
+ int textureLevels = 0;
+ int textureSize = FX_grGetInteger(GR_MAX_TEXTURE_SIZE);
+ do {
+ textureLevels++;
+ } while ((textureSize >>= 0x1) & 0x7ff);
+ ctx->Const.MaxTextureLevels = textureLevels;
+ ctx->Const.MaxTextureLodBias = /*textureLevels - 1*/8; /* Glide bug */
+#if FX_RESCALE_BIG_TEXURES_HACK
+ fxMesa->textureMaxLod = textureLevels - 1;
+ if ((env = getenv("MESA_FX_MAXLOD")) != NULL) {
+ int maxLevels = atoi(env) + 1;
+ if ((maxLevels <= MAX_TEXTURE_LEVELS) && (maxLevels > textureLevels)) {
+ ctx->Const.MaxTextureLevels = maxLevels;
+ }
+ }
+#endif
+ }
+ ctx->Const.MaxTextureCoordUnits =
+ ctx->Const.MaxTextureImageUnits = fxMesa->haveTwoTMUs ? 2 : 1;
+ ctx->Const.MaxTextureUnits = MAX2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits);
+
+ fxMesa->new_state = _NEW_ALL;
+ if (!fxMesa->haveHwStencil) {
+ /* don't touch stencil if there is none */
+ fxMesa->new_state &= ~FX_NEW_STENCIL;
+ }
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ _swrast_CreateContext(ctx);
+ _ac_CreateContext(ctx);
+ _tnl_CreateContext(ctx);
+ _swsetup_CreateContext(ctx);
+
+ /* Install customized pipeline */
+ _tnl_destroy_pipeline(ctx);
+ _tnl_install_pipeline(ctx, fx_pipeline);
+
+ fxAllocVB(ctx);
+
+ fxSetupDDPointers(ctx);
+ fxDDInitTriFuncs(ctx);
+
+ /* Tell the software rasterizer to use pixel fog always.
+ */
+ _swrast_allow_vertex_fog(ctx, GL_FALSE);
+ _swrast_allow_pixel_fog(ctx, GL_TRUE);
+ _tnl_allow_vertex_fog( ctx, GL_FALSE );
+ _tnl_allow_pixel_fog( ctx, GL_TRUE );
+
+ /* Tell tnl not to calculate or use vertex fog factors. (Needed to
+ * tell render stage not to clip fog coords).
+ */
+/* _tnl_calculate_vertex_fog( ctx, GL_FALSE ); */
+
+ fxDDInitExtensions(ctx);
+
+#if 0
+ /* do we want dither? It just looks bad... */
+ grEnable(GR_ALLOW_MIPMAP_DITHER);
+#endif
+ grGlideGetState((GrState *) fxMesa->state);
+
+ return 1;
+}
+
+/* Undo the above.
+ */
+void
+fxDDDestroyFxMesaContext(fxMesaContext fxMesa)
+{
+ _swsetup_DestroyContext(fxMesa->glCtx);
+ _tnl_DestroyContext(fxMesa->glCtx);
+ _ac_DestroyContext(fxMesa->glCtx);
+ _swrast_DestroyContext(fxMesa->glCtx);
+
+ if (fxMesa->state)
+ FREE(fxMesa->state);
+ if (fxMesa->fogTable)
+ FREE(fxMesa->fogTable);
+ fxFreeVB(fxMesa->glCtx);
+}
+
+
+
+
+void
+fxDDInitExtensions(GLcontext * ctx)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+#if 1 /* multipass ColorSum stage */
+ _mesa_enable_extension(ctx, "GL_EXT_secondary_color");
+#endif
+
+ _mesa_enable_extension(ctx, "GL_ARB_point_sprite");
+ _mesa_enable_extension(ctx, "GL_EXT_point_parameters");
+ _mesa_enable_extension(ctx, "GL_EXT_paletted_texture");
+ _mesa_enable_extension(ctx, "GL_EXT_texture_lod_bias");
+ _mesa_enable_extension(ctx, "GL_EXT_shared_texture_palette");
+ _mesa_enable_extension(ctx, "GL_EXT_blend_func_separate");
+ _mesa_enable_extension(ctx, "GL_EXT_texture_env_add");
+ _mesa_enable_extension(ctx, "GL_EXT_stencil_wrap");
+ _mesa_enable_extension(ctx, "GL_EXT_stencil_two_side");
+
+ if (fxMesa->haveTwoTMUs) {
+ _mesa_enable_extension(ctx, "GL_ARB_multitexture");
+ }
+
+ if (fxMesa->type >= GR_SSTTYPE_Voodoo4) {
+ _mesa_enable_extension(ctx, "GL_ARB_texture_compression");
+ _mesa_enable_extension(ctx, "GL_3DFX_texture_compression_FXT1");
+ _mesa_enable_extension(ctx, "GL_EXT_texture_compression_s3tc");
+ _mesa_enable_extension(ctx, "GL_S3_s3tc");
+ _mesa_enable_extension(ctx, "GL_NV_blend_square");
+ } else {
+ /* [dBorca]
+ * We should enable generic texture compression functions,
+ * but some poorly written apps automatically assume S3TC.
+ * Binding NCC to GL_COMPRESSED_RGB[A] is an unnecessary hassle,
+ * since it's slow and ugly (better with palette textures, then).
+ * Moreover, NCC is not an OpenGL standard, so we can't use
+ * precompressed textures. Last, but not least, NCC runs amok
+ * when multitexturing on a Voodoo3 and up (see POINTCAST vs UMA).
+ * Note: this is also a problem with palette textures, but
+ * faking multitex by multipass is evil...
+ * Implementing NCC requires three stages:
+ * fxDDChooseTextureFormat:
+ * bind GL_COMPRESSED_RGB[A] to _mesa_texformat_argb8888,
+ * so we can quantize properly, at a later time
+ * fxDDTexImage:
+ * if GL_COMPRESSED_RGB
+ * use _mesa_texformat_l8 to get 1bpt and set GR_TEXFMT_YIQ_422
+ * if GL_COMPRESSED_RGBA
+ * use _mesa_texformat_al88 to get 2bpt and set GR_TEXFMT_AYIQ_8422
+ * txMipQuantize(...);
+ * if (level == 0) {
+ * txPalToNcc((GuNccTable *)(&(ti->palette)), pxMip.pal);
+ * }
+ * fxSetupSingleTMU_NoLock/fxSetupDoubleTMU_NoLock:
+ * grTexDownloadTable(GR_TEXTABLE_NCC0, &(ti->palette));
+ */
+ /*_mesa_enable_extension(ctx, "GL_ARB_texture_compression");*/
+ _mesa_enable_extension(ctx, "GL_SGIS_generate_mipmap");
+ }
+
+ if (fxMesa->HaveCmbExt) {
+ _mesa_enable_extension(ctx, "GL_ARB_texture_env_combine");
+ _mesa_enable_extension(ctx, "GL_EXT_texture_env_combine");
+ }
+
+ if (fxMesa->HavePixExt) {
+ _mesa_enable_extension(ctx, "GL_EXT_blend_subtract");
+ _mesa_enable_extension(ctx, "GL_EXT_blend_equation_separate");
+ }
+
+ if (fxMesa->HaveMirExt) {
+ _mesa_enable_extension(ctx, "GL_ARB_texture_mirrored_repeat");
+ }
+
+ if (fxMesa->type >= GR_SSTTYPE_Voodoo2) {
+ _mesa_enable_extension(ctx, "GL_EXT_fog_coord");
+ }
+
+ /* core-level extensions */
+ _mesa_enable_extension(ctx, "GL_EXT_multi_draw_arrays");
+ _mesa_enable_extension(ctx, "GL_IBM_multimode_draw_arrays");
+ _mesa_enable_extension(ctx, "GL_ARB_vertex_buffer_object");
+ /* dangerous */
+ if (getenv("MESA_FX_ALLOW_VP")) {
+ _mesa_enable_extension(ctx, "GL_ARB_vertex_program");
+ _mesa_enable_extension(ctx, "GL_NV_vertex_program");
+ _mesa_enable_extension(ctx, "GL_NV_vertex_program1_1");
+ _mesa_enable_extension(ctx, "GL_MESA_program_debug");
+ }
+#if 0
+ /* this requires _tnl_vertex_cull_stage in the pipeline */
+ _mesa_enable_extension(ctx, "EXT_cull_vertex");
+#endif
+}
+
+
+/************************************************************************/
+/************************************************************************/
+/************************************************************************/
+
+/* Check if the hardware supports the current context
+ *
+ * Performs similar work to fxDDChooseRenderState() - should be merged.
+ */
+GLuint
+fx_check_IsInHardware(GLcontext * ctx)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ if (ctx->RenderMode != GL_RENDER) {
+ return FX_FALLBACK_RENDER_MODE;
+ }
+
+ if (ctx->Stencil.Enabled && !fxMesa->haveHwStencil) {
+ return FX_FALLBACK_STENCIL;
+ }
+
+ if (ctx->DrawBuffer->_ColorDrawBufferMask[0] != BUFFER_BIT_FRONT_LEFT &&
+ ctx->DrawBuffer->_ColorDrawBufferMask[0] != BUFFER_BIT_BACK_LEFT) {
+ return FX_FALLBACK_DRAW_BUFFER;
+ }
+
+ if (ctx->Color.BlendEnabled) {
+ if (ctx->Color.BlendEquationRGB != GL_FUNC_ADD) {
+ if (!fxMesa->HavePixExt ||
+ ((ctx->Color.BlendEquationRGB != GL_FUNC_SUBTRACT) &&
+ (ctx->Color.BlendEquationRGB != GL_FUNC_REVERSE_SUBTRACT))) {
+ return FX_FALLBACK_BLEND;
+ }
+ }
+
+ if (ctx->Color.BlendEquationA != GL_FUNC_ADD) {
+ if (!fxMesa->HavePixExt ||
+ ((ctx->Color.BlendEquationA != GL_FUNC_SUBTRACT) &&
+ (ctx->Color.BlendEquationA != GL_FUNC_REVERSE_SUBTRACT))) {
+ return FX_FALLBACK_BLEND;
+ }
+ }
+
+#if 0
+ /* [dBorca]
+ * We fail the spec here, unless certain blending modes:
+ * RGB: (GL_ONE + GL_*) or (GL_ZERO + GL_*) or ...
+ */
+ if (NEED_SECONDARY_COLOR(ctx)) {
+ if ((ctx->Color.BlendEquationRGB != GL_FUNC_ADD) &&
+ (ctx->Color.BlendSrcRGB != GL_ONE)) {
+ /* Can't use multipass to blend ColorSum stage */
+ return FX_FALLBACK_SPECULAR;
+ }
+ }
+#endif
+ }
+
+ /* [dBorca]
+ * We could avoid this for certain `sfactor/dfactor'
+ * I do not think that is even worthwhile to check
+ * because if someone is using blending they use more
+ * interesting settings and also it would add more
+ * state tracking to a lot of the code.
+ */
+ if (ctx->Color.ColorLogicOpEnabled && (ctx->Color.LogicOp != GL_COPY)) {
+ return FX_FALLBACK_LOGICOP;
+ }
+
+ if ((fxMesa->colDepth != 32) &&
+ ((ctx->Color.ColorMask[RCOMP] != ctx->Color.ColorMask[GCOMP]) ||
+ (ctx->Color.ColorMask[GCOMP] != ctx->Color.ColorMask[BCOMP]))) {
+ return FX_FALLBACK_COLORMASK;
+ }
+
+ /* Unsupported texture/multitexture cases */
+
+ /* we can only do 1D/2D textures */
+ if (ctx->Texture.Unit[0]._ReallyEnabled & ~(TEXTURE_1D_BIT|TEXTURE_2D_BIT))
+ return FX_FALLBACK_TEXTURE_MAP;
+
+ if (fxMesa->haveTwoTMUs) {
+ if (ctx->Texture.Unit[1]._ReallyEnabled & ~(TEXTURE_1D_BIT|TEXTURE_2D_BIT))
+ return FX_FALLBACK_TEXTURE_MAP;
+
+ if (ctx->Texture.Unit[0]._ReallyEnabled) {
+ if (fxMesa->type < GR_SSTTYPE_Voodoo2)
+ if (ctx->Texture.Unit[0].EnvMode == GL_BLEND &&
+ (ctx->Texture.Unit[1]._ReallyEnabled ||
+ 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 FX_FALLBACK_TEXTURE_ENV;
+ }
+ if (ctx->Texture.Unit[0]._Current->Image[0][0]->Border > 0)
+ return FX_FALLBACK_TEXTURE_BORDER;
+ }
+
+ if (ctx->Texture.Unit[1]._ReallyEnabled) {
+ if (fxMesa->type < GR_SSTTYPE_Voodoo2)
+ if (ctx->Texture.Unit[1].EnvMode == GL_BLEND)
+ return FX_FALLBACK_TEXTURE_ENV;
+ if (ctx->Texture.Unit[1]._Current->Image[0][0]->Border > 0)
+ return FX_FALLBACK_TEXTURE_BORDER;
+ }
+
+ if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE))
+ fprintf(stderr, "fx_check_IsInHardware: envmode is %s/%s\n",
+ _mesa_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode),
+ _mesa_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode));
+
+ /* KW: This was wrong (I think) and I changed it... which doesn't mean
+ * it is now correct...
+ * BP: The old condition just seemed to test if both texture units
+ * were enabled. That's easy!
+ */
+ if (ctx->Texture._EnabledUnits == 0x3) {
+#if 0
+ /* Can't use multipass to blend a multitextured triangle - fall
+ * back to software.
+ */
+ if (!fxMesa->haveTwoTMUs && ctx->Color.BlendEnabled) {
+ return FX_FALLBACK_TEXTURE_MULTI;
+ }
+#endif
+
+ if (!fxMesa->HaveCmbExt &&
+ (ctx->Texture.Unit[0].EnvMode != ctx->Texture.Unit[1].EnvMode) &&
+ (ctx->Texture.Unit[0].EnvMode != GL_MODULATE) &&
+ (ctx->Texture.Unit[0].EnvMode != GL_REPLACE)) { /* q2, seems ok... */
+ if (TDFX_DEBUG & VERBOSE_DRIVER)
+ fprintf(stderr, "fx_check_IsInHardware: unsupported multitex env mode\n");
+ return FX_FALLBACK_TEXTURE_MULTI;
+ }
+ }
+ }
+ else {
+ /* we have just one texture unit */
+ if (ctx->Texture._EnabledUnits > 0x1) {
+ return FX_FALLBACK_TEXTURE_MULTI;
+ }
+
+ if (fxMesa->type < GR_SSTTYPE_Voodoo2)
+ if (ctx->Texture.Unit[0]._ReallyEnabled &&
+ (ctx->Texture.Unit[0].EnvMode == GL_BLEND)) {
+ return FX_FALLBACK_TEXTURE_ENV;
+ }
+ }
+
+ return 0;
+}
+
+
+
+static void
+fxDDUpdateDDPointers(GLcontext * ctx, GLuint new_state)
+{
+ /* TNLcontext *tnl = TNL_CONTEXT(ctx); */
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxDDUpdateDDPointers(%08x)\n", new_state);
+ }
+
+ _swrast_InvalidateState(ctx, new_state);
+ _ac_InvalidateState(ctx, new_state);
+ _tnl_InvalidateState(ctx, new_state);
+ _swsetup_InvalidateState(ctx, new_state);
+
+ fxMesa->new_gl_state |= new_state;
+}
+
+
+
+
+void
+fxSetupDDPointers(GLcontext * ctx)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ /* TNLcontext *tnl = TNL_CONTEXT(ctx); */
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSetupDDPointers()\n");
+ }
+
+ ctx->Driver.UpdateState = fxDDUpdateDDPointers;
+ ctx->Driver.GetString = fxDDGetString;
+ ctx->Driver.ClearIndex = NULL;
+ ctx->Driver.ClearColor = fxDDClearColor;
+ ctx->Driver.Clear = fxDDClear;
+ ctx->Driver.DrawBuffer = fxDDSetDrawBuffer;
+ ctx->Driver.GetBufferSize = fxDDGetBufferSize;
+ ctx->Driver.Viewport = fxDDViewport;
+ switch (fxMesa->colDepth) {
+ case 15:
+ ctx->Driver.DrawPixels = fxDDDrawPixels555;
+ ctx->Driver.ReadPixels = fxDDReadPixels555;
+ ctx->Driver.Bitmap = fxDDDrawBitmap2;
+ break;
+ case 16:
+ ctx->Driver.DrawPixels = !fxMesa->bgrOrder ? fxDDDrawPixels565 : fxDDDrawPixels565_rev;
+ ctx->Driver.ReadPixels = fxDDReadPixels565;
+ ctx->Driver.Bitmap = fxDDDrawBitmap2;
+ break;
+ case 32:
+ ctx->Driver.DrawPixels = fxDDDrawPixels8888;
+ ctx->Driver.ReadPixels = fxDDReadPixels8888;
+ ctx->Driver.Bitmap = fxDDDrawBitmap4;
+ break;
+ }
+ ctx->Driver.Finish = fxDDFinish;
+ ctx->Driver.Flush = NULL;
+ ctx->Driver.ChooseTextureFormat = fxDDChooseTextureFormat;
+ ctx->Driver.TexImage1D = fxDDTexImage1D;
+ ctx->Driver.TexImage2D = fxDDTexImage2D;
+ ctx->Driver.TexSubImage1D = fxDDTexSubImage1D;
+ ctx->Driver.TexSubImage2D = fxDDTexSubImage2D;
+ ctx->Driver.CompressedTexImage2D = fxDDCompressedTexImage2D;
+ ctx->Driver.CompressedTexSubImage2D = fxDDCompressedTexSubImage2D;
+ ctx->Driver.TestProxyTexImage = fxDDTestProxyTexImage;
+ ctx->Driver.TexEnv = fxDDTexEnv;
+ ctx->Driver.TexParameter = fxDDTexParam;
+ ctx->Driver.BindTexture = fxDDTexBind;
+ ctx->Driver.DeleteTexture = fxDDTexDel;
+ ctx->Driver.IsTextureResident = fxDDIsTextureResident;
+ ctx->Driver.UpdateTexturePalette = fxDDTexPalette;
+ ctx->Driver.AlphaFunc = fxDDAlphaFunc;
+ ctx->Driver.BlendFuncSeparate = fxDDBlendFuncSeparate;
+ ctx->Driver.BlendEquationSeparate = fxDDBlendEquationSeparate;
+ ctx->Driver.DepthFunc = fxDDDepthFunc;
+ ctx->Driver.DepthMask = fxDDDepthMask;
+ ctx->Driver.ColorMask = fxDDColorMask;
+ ctx->Driver.Fogfv = fxDDFogfv;
+ ctx->Driver.Scissor = fxDDScissor;
+ ctx->Driver.FrontFace = fxDDFrontFace;
+ ctx->Driver.CullFace = fxDDCullFace;
+ ctx->Driver.ShadeModel = fxDDShadeModel;
+ ctx->Driver.Enable = fxDDEnable;
+ if (fxMesa->haveHwStencil) {
+ ctx->Driver.StencilFunc = fxDDStencilFunc;
+ ctx->Driver.StencilMask = fxDDStencilMask;
+ ctx->Driver.StencilOp = fxDDStencilOp;
+ }
+
+ fxSetupDDSpanPointers(ctx);
+ fxDDUpdateDDPointers(ctx, ~0);
+}
+
+
+#else
+
+
+/*
+ * Need this to provide at least one external definition.
+ */
+
+extern int gl_fx_dummy_function_dd(void);
+int
+gl_fx_dummy_function_dd(void)
+{
+ return 0;
+}
+
+#endif /* FX */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxddspan.c b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxddspan.c
new file mode 100644
index 000000000..79abbefc2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxddspan.c
@@ -0,0 +1,663 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.0
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/* Authors:
+ * David Bucciarelli
+ * Brian Paul
+ * Daryll Strauss
+ * Keith Whitwell
+ * Daniel Borca
+ * Hiroshi Morii
+ */
+
+
+/* fxdd.c - 3Dfx VooDoo Mesa span and pixel functions */
+
+
+#ifdef HAVE_CONFIG_H
+#include "conf.h"
+#endif
+
+#if defined(FX)
+
+#include "fxdrv.h"
+#include "fxglidew.h"
+#include "swrast/swrast.h"
+
+
+/************************************************************************/
+/***** Span functions *****/
+/************************************************************************/
+
+#define DBG 0
+
+
+#define LOCAL_VARS \
+ GLuint pitch = info.strideInBytes; \
+ GLuint height = fxMesa->height; \
+ char *buf = (char *)((char *)info.lfbPtr + 0 /* x, y offset */); \
+ GLuint p; \
+ (void) buf; (void) p;
+
+#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), n1 -= (minx-_x1), _x1 = minx;\
+ if ( _x1 + _n1 >= maxx ) n1 -= (_x1 + n1 - maxx); \
+ }
+
+#define Y_FLIP(_y) (height - _y - 1)
+
+#define HW_WRITE_LOCK() \
+ fxMesaContext fxMesa = FX_CONTEXT(ctx); \
+ GrLfbInfo_t info; \
+ info.size = sizeof(GrLfbInfo_t); \
+ if ( grLfbLock( GR_LFB_WRITE_ONLY, \
+ fxMesa->currentFB, LFB_MODE, \
+ GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
+
+#define HW_WRITE_UNLOCK() \
+ grLfbUnlock( GR_LFB_WRITE_ONLY, fxMesa->currentFB ); \
+ }
+
+#define HW_READ_LOCK() \
+ fxMesaContext fxMesa = FX_CONTEXT(ctx); \
+ GrLfbInfo_t info; \
+ info.size = sizeof(GrLfbInfo_t); \
+ if ( grLfbLock( GR_LFB_READ_ONLY, fxMesa->currentFB, \
+ LFB_MODE, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
+
+#define HW_READ_UNLOCK() \
+ grLfbUnlock( GR_LFB_READ_ONLY, fxMesa->currentFB ); \
+ }
+
+#define HW_WRITE_CLIPLOOP() \
+ do { \
+ /* remember, we need to flip the scissor, too */ \
+ /* is it better to do it inside fxDDScissor? */ \
+ const int minx = fxMesa->clipMinX; \
+ const int maxy = Y_FLIP(fxMesa->clipMinY); \
+ const int maxx = fxMesa->clipMaxX; \
+ const int miny = Y_FLIP(fxMesa->clipMaxY);
+
+#define HW_READ_CLIPLOOP() \
+ do { \
+ /* remember, we need to flip the scissor, too */ \
+ /* is it better to do it inside fxDDScissor? */ \
+ const int minx = fxMesa->clipMinX; \
+ const int maxy = Y_FLIP(fxMesa->clipMinY); \
+ const int maxx = fxMesa->clipMaxX; \
+ const int miny = Y_FLIP(fxMesa->clipMaxY);
+
+#define HW_ENDCLIPLOOP() \
+ } while (0)
+
+
+/* 16 bit, ARGB1555 color spanline and pixel functions */
+
+#undef LFB_MODE
+#define LFB_MODE GR_LFBWRITEMODE_1555
+
+#undef BYTESPERPIXEL
+#define BYTESPERPIXEL 2
+
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = TDFXPACKCOLOR1555( color[RCOMP], color[GCOMP], color[BCOMP], color[ACOMP] )
+
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = \
+ TDFXPACKCOLOR1555( r, g, b, a )
+
+#define WRITE_PIXEL( _x, _y, p ) \
+ *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = p
+
+#define READ_RGBA( rgba, _x, _y ) \
+ do { \
+ GLushort p = *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch); \
+ rgba[0] = FX_rgb_scale_5[(p >> 10) & 0x1F]; \
+ rgba[1] = FX_rgb_scale_5[(p >> 5) & 0x1F]; \
+ rgba[2] = FX_rgb_scale_5[ p & 0x1F]; \
+ rgba[3] = (p & 0x8000) ? 255 : 0; \
+ } while (0)
+
+#define TAG(x) tdfx##x##_ARGB1555
+#include "../dri/common/spantmp.h"
+
+
+/* 16 bit, RGB565 color spanline and pixel functions */
+/* [dBorca] Hack alert:
+ * This is wrong. The alpha value is lost, even when we provide
+ * HW alpha (565 w/o depth buffering). To really update alpha buffer,
+ * we would need to do the 565 writings via 8888 colorformat and rely
+ * on the Voodoo to perform color scaling. In which case our 565 span
+ * would look nicer! But this violates FSAA rules...
+ */
+
+#undef LFB_MODE
+#define LFB_MODE GR_LFBWRITEMODE_565
+
+#undef BYTESPERPIXEL
+#define BYTESPERPIXEL 2
+
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = TDFXPACKCOLOR565( color[RCOMP], color[GCOMP], color[BCOMP] )
+
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = \
+ TDFXPACKCOLOR565( r, g, b )
+
+#define WRITE_PIXEL( _x, _y, p ) \
+ *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = p
+
+#define READ_RGBA( rgba, _x, _y ) \
+ do { \
+ GLushort p = *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch); \
+ rgba[0] = FX_rgb_scale_5[(p >> 11) & 0x1F]; \
+ rgba[1] = FX_rgb_scale_6[(p >> 5) & 0x3F]; \
+ rgba[2] = FX_rgb_scale_5[ p & 0x1F]; \
+ rgba[3] = 0xff; \
+ } while (0)
+
+#define TAG(x) tdfx##x##_RGB565
+#include "../dri/common/spantmp.h"
+
+
+/* 32 bit, ARGB8888 color spanline and pixel functions */
+
+#undef LFB_MODE
+#define LFB_MODE GR_LFBWRITEMODE_8888
+
+#undef BYTESPERPIXEL
+#define BYTESPERPIXEL 4
+
+#undef INIT_MONO_PIXEL
+#define INIT_MONO_PIXEL(p, color) \
+ p = TDFXPACKCOLOR8888( color[RCOMP], color[GCOMP], color[BCOMP], color[ACOMP] )
+
+#define WRITE_RGBA( _x, _y, r, g, b, a ) \
+ *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = \
+ TDFXPACKCOLOR8888( r, g, b, a )
+
+#define WRITE_PIXEL( _x, _y, p ) \
+ *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = p
+
+#define READ_RGBA( rgba, _x, _y ) \
+ do { \
+ GLuint p = *(GLuint *)(buf + _x*BYTESPERPIXEL + _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) tdfx##x##_ARGB8888
+#include "../dri/common/spantmp.h"
+
+
+/************************************************************************/
+/***** Depth functions *****/
+/************************************************************************/
+
+#define DBG 0
+
+#undef HW_WRITE_LOCK
+#undef HW_WRITE_UNLOCK
+#undef HW_READ_LOCK
+#undef HW_READ_UNLOCK
+
+#define HW_CLIPLOOP HW_WRITE_CLIPLOOP
+
+#define LOCAL_DEPTH_VARS \
+ GLuint pitch = info.strideInBytes; \
+ GLuint height = fxMesa->height; \
+ char *buf = (char *)((char *)info.lfbPtr + 0 /* x, y offset */); \
+ (void) buf;
+
+#define HW_WRITE_LOCK() \
+ fxMesaContext fxMesa = FX_CONTEXT(ctx); \
+ GrLfbInfo_t info; \
+ info.size = sizeof(GrLfbInfo_t); \
+ if ( grLfbLock( GR_LFB_WRITE_ONLY, \
+ GR_BUFFER_AUXBUFFER, LFB_MODE, \
+ GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
+
+#define HW_WRITE_UNLOCK() \
+ grLfbUnlock( GR_LFB_WRITE_ONLY, GR_BUFFER_AUXBUFFER); \
+ }
+
+#define HW_READ_LOCK() \
+ fxMesaContext fxMesa = FX_CONTEXT(ctx); \
+ GrLfbInfo_t info; \
+ info.size = sizeof(GrLfbInfo_t); \
+ if ( grLfbLock( GR_LFB_READ_ONLY, GR_BUFFER_AUXBUFFER, \
+ LFB_MODE, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info ) ) {
+
+#define HW_READ_UNLOCK() \
+ grLfbUnlock( GR_LFB_READ_ONLY, GR_BUFFER_AUXBUFFER); \
+ }
+
+
+/* 16 bit, depth spanline and pixel functions */
+
+#undef LFB_MODE
+#define LFB_MODE GR_LFBWRITEMODE_ZA16
+
+#undef BYTESPERPIXEL
+#define BYTESPERPIXEL 2
+
+#define WRITE_DEPTH( _x, _y, d ) \
+ *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = *(GLushort *)(buf + _x*BYTESPERPIXEL + _y*pitch)
+
+#define TAG(x) tdfx##x##_Z16
+#include "../dri/common/depthtmp.h"
+
+
+/* 24 bit, depth spanline and pixel functions (for use w/ stencil) */
+/* [dBorca] Hack alert:
+ * This is evil. The incoming Mesa's 24bit depth value
+ * is shifted left 8 bits, to obtain a full 32bit value,
+ * which will be thrown into the framebuffer. We rely on
+ * the fact that Voodoo hardware transforms a 32bit value
+ * into 24bit value automatically and, MOST IMPORTANT, won't
+ * alter the upper 8bits of the value already existing in the
+ * framebuffer (where stencil resides).
+ */
+
+#undef LFB_MODE
+#define LFB_MODE GR_LFBWRITEMODE_Z32
+
+#undef BYTESPERPIXEL
+#define BYTESPERPIXEL 4
+
+#define WRITE_DEPTH( _x, _y, d ) \
+ *(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch) = d << 8
+
+#define READ_DEPTH( d, _x, _y ) \
+ d = (*(GLuint *)(buf + _x*BYTESPERPIXEL + _y*pitch)) & 0xffffff
+
+#define TAG(x) tdfx##x##_Z24
+#include "../dri/common/depthtmp.h"
+
+
+/* 32 bit, depth spanline and pixel functions (for use w/o stencil) */
+/* [dBorca] Hack alert:
+ * This is more evil. We make Mesa run in 32bit depth, but
+ * tha Voodoo HW can only handle 24bit depth. Well, exploiting
+ * the pixel pipeline, we can achieve 24:8 format for greater
+ * precision...
+ * If anyone tells me how to really store 32bit values into the
+ * depth buffer, I'll write the *_Z32 routines. Howver, bear in
+ * mind that means running without stencil!
+ */
+
+/************************************************************************/
+/***** Span functions (optimized) *****/
+/************************************************************************/
+
+/*
+ * Read a span of 15-bit RGB pixels. Note, we don't worry about cliprects
+ * since OpenGL says obscured pixels have undefined values.
+ */
+static void fxReadRGBASpan_ARGB1555 (const GLcontext * ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n,
+ GLint x, GLint y,
+ GLubyte rgba[][4])
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ info.size = sizeof(GrLfbInfo_t);
+ if (grLfbLock(GR_LFB_READ_ONLY, fxMesa->currentFB,
+ GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+ const GLint winX = 0;
+ const GLint winY = fxMesa->height - 1;
+ const GLushort *data16 = (const GLushort *)((const GLubyte *)info.lfbPtr +
+ (winY - y) * info.strideInBytes +
+ (winX + x) * 2);
+ 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];
+ rgba[i][0] = FX_rgb_scale_5[(pixel >> 10) & 0x1F];
+ rgba[i][1] = FX_rgb_scale_5[(pixel >> 5) & 0x1F];
+ rgba[i][2] = FX_rgb_scale_5[ pixel & 0x1F];
+ rgba[i][3] = (pixel & 0x8000) ? 255 : 0;
+ rgba[i+1][0] = FX_rgb_scale_5[(pixel >> 26) & 0x1F];
+ rgba[i+1][1] = FX_rgb_scale_5[(pixel >> 21) & 0x1F];
+ rgba[i+1][2] = FX_rgb_scale_5[(pixel >> 16) & 0x1F];
+ rgba[i+1][3] = (pixel & 0x80000000) ? 255 : 0;
+ }
+ if (extraPixel) {
+ GLushort pixel = data16[n];
+ rgba[n][0] = FX_rgb_scale_5[(pixel >> 10) & 0x1F];
+ rgba[n][1] = FX_rgb_scale_5[(pixel >> 5) & 0x1F];
+ rgba[n][2] = FX_rgb_scale_5[ pixel & 0x1F];
+ rgba[n][3] = (pixel & 0x8000) ? 255 : 0;
+ }
+
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ }
+}
+
+/*
+ * 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 fxReadRGBASpan_RGB565 (const GLcontext * ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n,
+ GLint x, GLint y,
+ GLubyte rgba[][4])
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrLfbInfo_t info;
+ info.size = sizeof(GrLfbInfo_t);
+ if (grLfbLock(GR_LFB_READ_ONLY, fxMesa->currentFB,
+ GR_LFBWRITEMODE_ANY, GR_ORIGIN_UPPER_LEFT, FXFALSE, &info)) {
+ const GLint winX = 0;
+ const GLint winY = fxMesa->height - 1;
+ const GLushort *data16 = (const GLushort *)((const GLubyte *)info.lfbPtr +
+ (winY - y) * info.strideInBytes +
+ (winX + x) * 2);
+ 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];
+ rgba[i][0] = FX_rgb_scale_5[(pixel >> 11) & 0x1F];
+ rgba[i][1] = FX_rgb_scale_6[(pixel >> 5) & 0x3F];
+ rgba[i][2] = FX_rgb_scale_5[ pixel & 0x1F];
+ rgba[i][3] = 255;
+ rgba[i+1][0] = FX_rgb_scale_5[(pixel >> 27) & 0x1F];
+ rgba[i+1][1] = FX_rgb_scale_6[(pixel >> 21) & 0x3F];
+ rgba[i+1][2] = FX_rgb_scale_5[(pixel >> 16) & 0x1F];
+ rgba[i+1][3] = 255;
+ }
+ if (extraPixel) {
+ GLushort pixel = data16[n];
+ rgba[n][0] = FX_rgb_scale_5[(pixel >> 11) & 0x1F];
+ rgba[n][1] = FX_rgb_scale_6[(pixel >> 5) & 0x3F];
+ rgba[n][2] = FX_rgb_scale_5[ pixel & 0x1F];
+ rgba[n][3] = 255;
+ }
+
+ grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB);
+ }
+}
+
+/*
+ * Read a span of 32-bit RGB pixels. Note, we don't worry about cliprects
+ * since OpenGL says obscured pixels have undefined values.
+ */
+static void fxReadRGBASpan_ARGB8888 (const GLcontext * ctx,
+ struct gl_renderbuffer *rb,
+ GLuint n,
+ GLint x, GLint y,
+ GLubyte rgba[][4])
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLuint i;
+ grLfbReadRegion(fxMesa->currentFB, x, fxMesa->height - 1 - y, n, 1, n * 4, rgba);
+ for (i = 0; i < n; i++) {
+ GLubyte c = rgba[i][0];
+ rgba[i][0] = rgba[i][2];
+ rgba[i][2] = c;
+ }
+}
+
+
+/************************************************************************/
+/***** Depth functions (optimized) *****/
+/************************************************************************/
+
+static void
+fxReadDepthSpan_Z16(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLdepth depth[])
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLint bottom = fxMesa->height - 1;
+ GLushort depth16[MAX_WIDTH];
+ GLuint i;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxReadDepthSpan_Z16(...)\n");
+ }
+
+ grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth16);
+ for (i = 0; i < n; i++) {
+ depth[i] = depth16[i];
+ }
+}
+
+
+static void
+fxReadDepthSpan_Z24(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLdepth depth[])
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLint bottom = fxMesa->height - 1;
+ GLuint i;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxReadDepthSpan_Z24(...)\n");
+ }
+
+ grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth);
+ for (i = 0; i < n; i++) {
+ depth[i] &= 0xffffff;
+ }
+}
+
+
+/************************************************************************/
+/***** Stencil functions (optimized) *****/
+/************************************************************************/
+
+static void
+fxWriteStencilSpan (GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y,
+ const GLstencil stencil[], const GLubyte mask[])
+{
+ /*
+ * XXX todo
+ */
+}
+
+static void
+fxReadStencilSpan(GLcontext * ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLstencil stencil[])
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLint bottom = fxMesa->height - 1;
+ GLuint zs32[MAX_WIDTH];
+ GLuint i;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxReadStencilSpan(...)\n");
+ }
+
+ grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, zs32);
+ for (i = 0; i < n; i++) {
+ stencil[i] = zs32[i] >> 24;
+ }
+}
+
+static void
+fxWriteStencilPixels (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
+ const GLint x[], const GLint y[],
+ const GLstencil stencil[],
+ const GLubyte mask[])
+{
+ /*
+ * XXX todo
+ */
+}
+
+static void
+fxReadStencilPixels (GLcontext *ctx, struct gl_renderbuffer *rb, GLuint n,
+ const GLint x[], const GLint y[],
+ GLstencil stencil[])
+{
+ /*
+ * XXX todo
+ */
+}
+
+
+
+/*
+ * This function is called to specify which buffer to read and write
+ * for software rasterization (swrast) fallbacks. This doesn't necessarily
+ * correspond to glDrawBuffer() or glReadBuffer() calls.
+ */
+static void
+fxDDSetBuffer(GLcontext * ctx, GLframebuffer * buffer, GLuint bufferBit)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ (void) buffer;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxDDSetBuffer(%x)\n", (int)bufferBit);
+ }
+
+ if (bufferBit == BUFFER_BIT_FRONT_LEFT) {
+ fxMesa->currentFB = GR_BUFFER_FRONTBUFFER;
+ grRenderBuffer(fxMesa->currentFB);
+ }
+ else if (bufferBit == BUFFER_BIT_BACK_LEFT) {
+ fxMesa->currentFB = GR_BUFFER_BACKBUFFER;
+ grRenderBuffer(fxMesa->currentFB);
+ }
+}
+
+
+/************************************************************************/
+
+
+
+void
+fxSetupDDSpanPointers(GLcontext * ctx)
+{
+ struct swrast_device_driver *swdd = _swrast_GetDeviceDriverReference( ctx );
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ swdd->SetBuffer = fxDDSetBuffer;
+
+ switch (fxMesa->colDepth) {
+ case 15:
+ swdd->WriteRGBASpan = tdfxWriteRGBASpan_ARGB1555;
+ swdd->WriteRGBSpan = tdfxWriteRGBSpan_ARGB1555;
+ swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_ARGB1555;
+ swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_ARGB1555;
+ swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_ARGB1555;
+ swdd->ReadRGBASpan = /*td*/fxReadRGBASpan_ARGB1555;
+ swdd->ReadRGBAPixels = tdfxReadRGBAPixels_ARGB1555;
+
+ swdd->WriteDepthSpan = tdfxWriteDepthSpan_Z16;
+ swdd->WriteDepthPixels = tdfxWriteDepthPixels_Z16;
+ swdd->ReadDepthSpan = /*td*/fxReadDepthSpan_Z16;
+ swdd->ReadDepthPixels = tdfxReadDepthPixels_Z16;
+ break;
+ case 16:
+ swdd->WriteRGBASpan = tdfxWriteRGBASpan_RGB565;
+ swdd->WriteRGBSpan = tdfxWriteRGBSpan_RGB565;
+ swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_RGB565;
+ swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_RGB565;
+ swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_RGB565;
+ swdd->ReadRGBASpan = /*td*/fxReadRGBASpan_RGB565;
+ swdd->ReadRGBAPixels = tdfxReadRGBAPixels_RGB565;
+
+ swdd->WriteDepthSpan = tdfxWriteDepthSpan_Z16;
+ swdd->WriteDepthPixels = tdfxWriteDepthPixels_Z16;
+ swdd->ReadDepthSpan = /*td*/fxReadDepthSpan_Z16;
+ swdd->ReadDepthPixels = tdfxReadDepthPixels_Z16;
+ break;
+ case 32:
+ swdd->WriteRGBASpan = tdfxWriteRGBASpan_ARGB8888;
+ swdd->WriteRGBSpan = tdfxWriteRGBSpan_ARGB8888;
+ swdd->WriteRGBAPixels = tdfxWriteRGBAPixels_ARGB8888;
+ swdd->WriteMonoRGBASpan = tdfxWriteMonoRGBASpan_ARGB8888;
+ swdd->WriteMonoRGBAPixels = tdfxWriteMonoRGBAPixels_ARGB8888;
+ swdd->ReadRGBASpan = /*td*/fxReadRGBASpan_ARGB8888;
+ swdd->ReadRGBAPixels = tdfxReadRGBAPixels_ARGB8888;
+
+ swdd->WriteDepthSpan = tdfxWriteDepthSpan_Z24;
+ swdd->WriteDepthPixels = tdfxWriteDepthPixels_Z24;
+ swdd->ReadDepthSpan = /*td*/fxReadDepthSpan_Z24;
+ swdd->ReadDepthPixels = tdfxReadDepthPixels_Z24;
+ break;
+ }
+
+ if (fxMesa->haveHwStencil) {
+ swdd->WriteStencilSpan = fxWriteStencilSpan;
+ swdd->ReadStencilSpan = fxReadStencilSpan;
+ swdd->WriteStencilPixels = fxWriteStencilPixels;
+ swdd->ReadStencilPixels = fxReadStencilPixels;
+ }
+#if 0
+ swdd->WriteCI8Span = NULL;
+ swdd->WriteCI32Span = NULL;
+ swdd->WriteMonoCISpan = NULL;
+ swdd->WriteCI32Pixels = NULL;
+ swdd->WriteMonoCIPixels = NULL;
+ swdd->ReadCI32Span = NULL;
+ swdd->ReadCI32Pixels = NULL;
+
+ swdd->SpanRenderStart = tdfxSpanRenderStart; /* BEGIN_BOARD_LOCK */
+ swdd->SpanRenderFinish = tdfxSpanRenderFinish; /* END_BOARD_LOCK */
+#endif
+}
+
+
+#else
+
+
+/*
+ * Need this to provide at least one external definition.
+ */
+
+extern int gl_fx_dummy_function_span(void);
+int
+gl_fx_dummy_function_span(void)
+{
+ return 0;
+}
+
+#endif /* FX */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxddtex.c b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxddtex.c
new file mode 100644
index 000000000..f3f12c4cc
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxddtex.c
@@ -0,0 +1,1849 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.0
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/* Authors:
+ * David Bucciarelli
+ * Brian Paul
+ * Daryll Strauss
+ * Keith Whitwell
+ * Daniel Borca
+ * Hiroshi Morii
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include "conf.h"
+#endif
+
+#if defined(FX)
+
+#include "fxdrv.h"
+#include "enums.h"
+#include "image.h"
+#include "teximage.h"
+#include "texformat.h"
+#include "texcompress.h"
+#include "texobj.h"
+#include "texstore.h"
+
+
+/* no borders! can't halve 1x1! (stride > width * comp) not allowed */
+static void
+_mesa_halve2x2_teximage2d ( GLcontext *ctx,
+ struct gl_texture_image *texImage,
+ GLuint bytesPerPixel,
+ GLint srcWidth, GLint srcHeight,
+ const GLvoid *srcImage, GLvoid *dstImage )
+{
+ GLint i, j, k;
+ GLint dstWidth = srcWidth / 2;
+ GLint dstHeight = srcHeight / 2;
+ GLint srcRowStride = srcWidth * bytesPerPixel;
+ GLubyte *src = (GLubyte *)srcImage;
+ GLubyte *dst = dstImage;
+
+ GLuint bpt = 0;
+ GLubyte *_s = NULL;
+ GLubyte *_d = NULL;
+ GLenum _t = 0;
+
+ if (texImage->TexFormat->MesaFormat == MESA_FORMAT_RGB565) {
+ _t = GL_UNSIGNED_SHORT_5_6_5_REV;
+ bpt = bytesPerPixel;
+ } else if (texImage->TexFormat->MesaFormat == MESA_FORMAT_ARGB4444) {
+ _t = GL_UNSIGNED_SHORT_4_4_4_4_REV;
+ bpt = bytesPerPixel;
+ } else if (texImage->TexFormat->MesaFormat == MESA_FORMAT_ARGB1555) {
+ _t = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+ bpt = bytesPerPixel;
+ }
+ if (bpt) {
+ bytesPerPixel = 4;
+ srcRowStride = srcWidth * bytesPerPixel;
+ if (dstWidth == 0) {
+ dstWidth = 1;
+ }
+ if (dstHeight == 0) {
+ dstHeight = 1;
+ }
+ _s = src = MALLOC(srcRowStride * srcHeight);
+ _d = dst = MALLOC(dstWidth * bytesPerPixel * dstHeight);
+ _mesa_texstore_rgba8888(ctx, 2, GL_RGBA,
+ &_mesa_texformat_rgba8888_rev, src,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ srcRowStride, /* dstRowStride */
+ 0, /* dstImageStride */
+ srcWidth, srcHeight, 1,
+ texImage->Format, _t, srcImage, &ctx->DefaultPacking);
+ }
+
+ if (srcHeight == 1) {
+ for (i = 0; i < dstWidth; i++) {
+ for (k = 0; k < bytesPerPixel; k++) {
+ dst[0] = (src[0] + src[bytesPerPixel] + 1) / 2;
+ src++;
+ dst++;
+ }
+ src += bytesPerPixel;
+ }
+ } else if (srcWidth == 1) {
+ for (j = 0; j < dstHeight; j++) {
+ for (k = 0; k < bytesPerPixel; k++) {
+ dst[0] = (src[0] + src[srcRowStride] + 1) / 2;
+ src++;
+ dst++;
+ }
+ src += srcRowStride;
+ }
+ } else {
+ for (j = 0; j < dstHeight; j++) {
+ for (i = 0; i < dstWidth; i++) {
+ for (k = 0; k < bytesPerPixel; k++) {
+ dst[0] = (src[0] +
+ src[bytesPerPixel] +
+ src[srcRowStride] +
+ src[srcRowStride + bytesPerPixel] + 2) / 4;
+ src++;
+ dst++;
+ }
+ src += bytesPerPixel;
+ }
+ src += srcRowStride;
+ }
+ }
+
+ if (bpt) {
+ src = _s;
+ dst = _d;
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat, dstImage,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstWidth * bpt,
+ 0, /* dstImageStride */
+ dstWidth, dstHeight, 1,
+ GL_BGRA, CHAN_TYPE, dst, &ctx->DefaultPacking);
+ FREE(dst);
+ FREE(src);
+ }
+}
+
+
+void
+fxPrintTextureData(tfxTexInfo * ti)
+{
+ fprintf(stderr, "Texture Data:\n");
+ if (ti->tObj) {
+ fprintf(stderr, "\tName: %d\n", ti->tObj->Name);
+ fprintf(stderr, "\tBaseLevel: %d\n", ti->tObj->BaseLevel);
+ fprintf(stderr, "\tSize: %d x %d\n",
+ ti->tObj->Image[0][ti->tObj->BaseLevel]->Width,
+ ti->tObj->Image[0][ti->tObj->BaseLevel]->Height);
+ }
+ else
+ fprintf(stderr, "\tName: UNNAMED\n");
+ fprintf(stderr, "\tLast used: %d\n", ti->lastTimeUsed);
+ 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", (unsigned) ti->tm[0]->startAddr,
+ (unsigned) ti->tm[0]->endAddr);
+ if (ti->tm[1])
+ 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 max %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, "\t%s\n",
+ (ti->fixedPalette) ? "Fixed palette" : "Non fixed palette");
+ fprintf(stderr, "\t%s\n", (ti->validated) ? "Validated" : "Not validated");
+}
+
+
+/************************************************************************/
+/*************************** Texture Mapping ****************************/
+/************************************************************************/
+
+static void
+fxTexInvalidate(GLcontext * ctx, struct gl_texture_object *tObj)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxTexInfo *ti;
+
+ 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;
+}
+
+static tfxTexInfo *
+fxAllocTexObjData(fxMesaContext fxMesa)
+{
+ tfxTexInfo *ti;
+
+ if (!(ti = CALLOC(sizeof(tfxTexInfo)))) {
+ fprintf(stderr, "fxAllocTexObjData: ERROR: out of memory !\n");
+ fxCloseHardware();
+ exit(-1);
+ }
+
+ ti->validated = GL_FALSE;
+ ti->isInTM = GL_FALSE;
+
+ ti->whichTMU = FX_TMU_NONE;
+
+ ti->tm[FX_TMU0] = NULL;
+ ti->tm[FX_TMU1] = NULL;
+
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ ti->maxFilt = GR_TEXTUREFILTER_BILINEAR;
+
+ ti->sClamp = GR_TEXTURECLAMP_WRAP;
+ ti->tClamp = GR_TEXTURECLAMP_WRAP;
+
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->LODblend = FXFALSE;
+
+ return ti;
+}
+
+void
+fxDDTexBind(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxTexInfo *ti;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxDDTexBind(%d, %x)\n", tObj->Name, (GLuint)tObj->DriverData);
+ }
+
+ if ((target != GL_TEXTURE_1D) && (target != GL_TEXTURE_2D))
+ return;
+
+ if (!tObj->DriverData) {
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
+ }
+ ti = fxTMGetTexInfo(tObj);
+
+ fxMesa->texBindNumber++;
+ ti->lastTimeUsed = fxMesa->texBindNumber;
+
+ fxMesa->new_state |= FX_NEW_TEXTURING;
+}
+
+void
+fxDDTexEnv(GLcontext * ctx, GLenum target, GLenum pname,
+ const GLfloat * param)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ if (param)
+ fprintf(stderr, "fxDDTexEnv(%x, %x)\n", pname, (GLint) (*param));
+ else
+ fprintf(stderr, "fxDDTexEnv(%x)\n", pname);
+ }
+
+ /* apply any lod biasing right now */
+ if (pname == GL_TEXTURE_LOD_BIAS_EXT) {
+ GLfloat bias = *param;
+ CLAMP_SELF(bias, -ctx->Const.MaxTextureLodBias,
+ ctx->Const.MaxTextureLodBias - 0.25);
+
+ grTexLodBiasValue(GR_TMU0, bias);
+
+ if (fxMesa->haveTwoTMUs) {
+ grTexLodBiasValue(GR_TMU1, bias);
+ }
+
+ }
+
+ fxMesa->new_state |= FX_NEW_TEXTURING;
+}
+
+void
+fxDDTexParam(GLcontext * ctx, GLenum target, struct gl_texture_object *tObj,
+ GLenum pname, const GLfloat * params)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLenum param = (GLenum) (GLint) params[0];
+ tfxTexInfo *ti;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxDDTexParam(%d, %x, %s, %s)\n",
+ tObj->Name, (GLuint) tObj->DriverData,
+ _mesa_lookup_enum_by_nr(pname),
+ _mesa_lookup_enum_by_nr(param));
+ }
+
+ if ((target != GL_TEXTURE_1D) && (target != GL_TEXTURE_2D))
+ return;
+
+ if (!tObj->DriverData)
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
+ ti = fxTMGetTexInfo(tObj);
+
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ switch (param) {
+ case GL_NEAREST:
+ ti->mmMode = GR_MIPMAP_DISABLE;
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ ti->LODblend = FXFALSE;
+ break;
+ case GL_LINEAR:
+ ti->mmMode = GR_MIPMAP_DISABLE;
+ ti->minFilt = GR_TEXTUREFILTER_BILINEAR;
+ ti->LODblend = FXFALSE;
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ /* [dBorca]
+ * currently Napalm can't do single-pass trilinear,
+ * because the way its combiners are set. So we fall back
+ * to GL_NEAREST_MIPMAP_NEAREST. We'll let true trilinear
+ * enabled for V2, V3.
+ */
+ if (!fxMesa->HaveCmbExt) {
+ if (fxMesa->haveTwoTMUs) {
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->LODblend = FXTRUE;
+ } else {
+ ti->mmMode = GR_MIPMAP_NEAREST_DITHER;
+ ti->LODblend = FXFALSE;
+ }
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ break;
+ }
+ case GL_NEAREST_MIPMAP_NEAREST:
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->minFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ ti->LODblend = FXFALSE;
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ /* [dBorca]
+ * currently Napalm can't do single-pass trilinear,
+ * because the way its combiners are set. So we fall back
+ * to GL_LINEAR_MIPMAP_NEAREST. We'll let true trilinear
+ * enabled for V2, V3.
+ */
+ if (!fxMesa->HaveCmbExt) {
+ if (fxMesa->haveTwoTMUs) {
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->LODblend = FXTRUE;
+ } else {
+ ti->mmMode = GR_MIPMAP_NEAREST_DITHER;
+ ti->LODblend = FXFALSE;
+ }
+ ti->minFilt = GR_TEXTUREFILTER_BILINEAR;
+ break;
+ }
+ case GL_LINEAR_MIPMAP_NEAREST:
+ ti->mmMode = GR_MIPMAP_NEAREST;
+ ti->minFilt = GR_TEXTUREFILTER_BILINEAR;
+ ti->LODblend = FXFALSE;
+ break;
+ default:
+ break;
+ }
+ fxTexInvalidate(ctx, tObj);
+ break;
+
+ case GL_TEXTURE_MAG_FILTER:
+ switch (param) {
+ case GL_NEAREST:
+ ti->maxFilt = GR_TEXTUREFILTER_POINT_SAMPLED;
+ break;
+ case GL_LINEAR:
+ ti->maxFilt = GR_TEXTUREFILTER_BILINEAR;
+ break;
+ default:
+ break;
+ }
+ fxMesa->new_state |= FX_NEW_TEXTURING;
+ break;
+
+ case GL_TEXTURE_WRAP_S:
+ switch (param) {
+ case GL_MIRRORED_REPEAT:
+ ti->sClamp = GR_TEXTURECLAMP_MIRROR_EXT;
+ break;
+ case GL_CLAMP_TO_BORDER: /* no-no, but don't REPEAT, either */
+ case GL_CLAMP_TO_EDGE: /* CLAMP discarding border */
+ case GL_CLAMP:
+ ti->sClamp = GR_TEXTURECLAMP_CLAMP;
+ break;
+ case GL_REPEAT:
+ ti->sClamp = GR_TEXTURECLAMP_WRAP;
+ break;
+ default:
+ break;
+ }
+ fxMesa->new_state |= FX_NEW_TEXTURING;
+ break;
+
+ case GL_TEXTURE_WRAP_T:
+ switch (param) {
+ case GL_MIRRORED_REPEAT:
+ ti->tClamp = GR_TEXTURECLAMP_MIRROR_EXT;
+ break;
+ case GL_CLAMP_TO_BORDER: /* no-no, but don't REPEAT, either */
+ case GL_CLAMP_TO_EDGE: /* CLAMP discarding border */
+ case GL_CLAMP:
+ ti->tClamp = GR_TEXTURECLAMP_CLAMP;
+ break;
+ case GL_REPEAT:
+ ti->tClamp = GR_TEXTURECLAMP_WRAP;
+ break;
+ default:
+ break;
+ }
+ fxMesa->new_state |= FX_NEW_TEXTURING;
+ break;
+
+ case GL_TEXTURE_BORDER_COLOR:
+ /* TO DO */
+ break;
+
+ case GL_TEXTURE_MIN_LOD:
+ /* TO DO */
+ break;
+ case GL_TEXTURE_MAX_LOD:
+ /* TO DO */
+ break;
+ case GL_TEXTURE_BASE_LEVEL:
+ fxTexInvalidate(ctx, tObj);
+ break;
+ case GL_TEXTURE_MAX_LEVEL:
+ fxTexInvalidate(ctx, tObj);
+ break;
+
+ default:
+ break;
+ }
+}
+
+void
+fxDDTexDel(GLcontext * ctx, struct gl_texture_object *tObj)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxDDTexDel(%d, %p)\n", tObj->Name, (void *) ti);
+ }
+
+ if (!ti)
+ return;
+
+ fxTMFreeTexture(fxMesa, tObj);
+
+ FREE(ti);
+ tObj->DriverData = NULL;
+
+ /* Free mipmap images and the texture object itself */
+ _mesa_delete_texture_object(ctx, tObj);
+}
+
+
+/**
+ * Allocate a new texture object.
+ * Called via ctx->Driver.NewTextureObject.
+ * Note: this function will be called during context creation to
+ * allocate the default texture objects.
+ */
+struct gl_texture_object *
+fxDDNewTextureObject( GLcontext *ctx, GLuint name, GLenum target )
+{
+ struct gl_texture_object *obj;
+ obj = _mesa_new_texture_object(ctx, name, target);
+ return obj;
+}
+
+
+/*
+ * Return true if texture is resident, false otherwise.
+ */
+GLboolean
+fxDDIsTextureResident(GLcontext *ctx, struct gl_texture_object *tObj)
+{
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+ return (ti && ti->isInTM);
+}
+
+
+
+/*
+ * Convert a gl_color_table texture palette to Glide's format.
+ */
+static GrTexTable_t
+convertPalette(const fxMesaContext fxMesa, 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->Type == 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;
+ }
+ return fxMesa->HavePalExt ? GR_TEXTABLE_PALETTE_6666_EXT : GR_TEXTABLE_PALETTE;
+ 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;
+ }
+ return GR_TEXTABLE_PALETTE;
+ 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;
+ }
+ return fxMesa->HavePalExt ? GR_TEXTABLE_PALETTE_6666_EXT : GR_TEXTABLE_PALETTE;
+ 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;
+ }
+ return fxMesa->HavePalExt ? GR_TEXTABLE_PALETTE_6666_EXT : GR_TEXTABLE_PALETTE;
+ default:
+ 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;
+ }
+ return GR_TEXTABLE_PALETTE;
+ 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;
+ }
+ return fxMesa->HavePalExt ? GR_TEXTABLE_PALETTE_6666_EXT : GR_TEXTABLE_PALETTE;
+ }
+}
+
+
+void
+fxDDTexPalette(GLcontext * ctx, struct gl_texture_object *tObj)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ if (tObj) {
+ /* per-texture palette */
+ tfxTexInfo *ti;
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxDDTexPalette(%d, %x)\n",
+ tObj->Name, (GLuint) tObj->DriverData);
+ }
+ /* This might be a proxy texture. */
+ if (!tObj->Palette.Table)
+ return;
+ if (!tObj->DriverData)
+ tObj->DriverData = fxAllocTexObjData(fxMesa);
+ ti = fxTMGetTexInfo(tObj);
+ ti->paltype = convertPalette(fxMesa, ti->palette.data, &tObj->Palette);
+ fxTexInvalidate(ctx, tObj);
+ }
+ else {
+ /* global texture palette */
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxDDTexPalette(global)\n");
+ }
+ fxMesa->glbPalType = convertPalette(fxMesa, fxMesa->glbPalette.data, &ctx->Texture.Palette);
+ fxMesa->new_state |= FX_NEW_TEXTURING;
+
+ grTexDownloadTable(fxMesa->glbPalType, &(fxMesa->glbPalette));
+ }
+}
+
+
+void
+fxDDTexUseGlbPalette(GLcontext * ctx, GLboolean state)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxDDTexUseGlbPalette(%d)\n", state);
+ }
+
+ fxMesa->haveGlobalPaletteTexture = state;
+ fxMesa->new_state |= FX_NEW_TEXTURING;
+}
+
+
+static int
+logbase2(int n)
+{
+ GLint i = 1;
+ GLint log2 = 0;
+
+ if (n < 0) {
+ return -1;
+ }
+
+ while (n > i) {
+ i *= 2;
+ log2++;
+ }
+ if (i != n) {
+ return -1;
+ }
+ else {
+ return log2;
+ }
+}
+
+
+/* fxTexGetInfo
+ * w, h - source texture width and height
+ * lodlevel - Glide lod level token for the larger texture dimension
+ * ar - Glide aspect ratio token
+ * sscale - S scale factor used during triangle setup
+ * tscale - T scale factor used during triangle setup
+ * wscale - OpenGL -> Glide image width scale factor
+ * hscale - OpenGL -> Glide image height scale factor
+ */
+int
+fxTexGetInfo(int w, int h, GrLOD_t * lodlevel, GrAspectRatio_t * ar,
+ float *sscale, float *tscale,
+ int *wscale, int *hscale)
+{
+ int logw, logh, ws, hs;
+ GrLOD_t l;
+ GrAspectRatio_t aspectratio;
+ float s, t;
+
+ logw = logbase2(w);
+ logh = logbase2(h);
+
+ l = MAX2(logw, logh);
+ aspectratio = logw - logh;
+ ws = hs = 1;
+ s = t = 256.0f;
+
+ /* hardware only allows a maximum aspect ratio of 8x1, so handle
+ * |aspectratio| > 3 by scaling the image and using an 8x1 aspect
+ * ratio
+ */
+ switch (aspectratio) {
+ case 0:
+ break;
+ case 1:
+ t = 128.0f;
+ break;
+ case 2:
+ t = 64.0f;
+ break;
+ case 3:
+ t = 32.0f;
+ break;
+ case -1:
+ s = 128.0f;
+ break;
+ case -2:
+ s = 64.0f;
+ break;
+ case -3:
+ s = 32.0f;
+ break;
+ default:
+ if (aspectratio > 3) {
+ t = 32.0f;
+ hs = 1 << (aspectratio - 3);
+ aspectratio = GR_ASPECT_LOG2_8x1;
+ } else /*if (aspectratio < -3)*/ {
+ s = 32.0f;
+ ws = 1 << (-aspectratio - 3);
+ aspectratio = GR_ASPECT_LOG2_1x8;
+ }
+ }
+
+ if (lodlevel)
+ (*lodlevel) = l;
+
+ if (ar)
+ (*ar) = aspectratio;
+
+ if (sscale)
+ (*sscale) = s;
+
+ if (tscale)
+ (*tscale) = t;
+
+ if (wscale)
+ (*wscale) = ws;
+
+ if (hscale)
+ (*hscale) = hs;
+
+
+ return 1;
+}
+
+static GLboolean
+fxIsTexSupported(GLenum target, GLint internalFormat,
+ const struct gl_texture_image *image)
+{
+ if ((target != GL_TEXTURE_1D) && (target != GL_TEXTURE_2D))
+ return GL_FALSE;
+
+#if 0
+ if (!fxTexGetInfo(image->Width, image->Height, NULL, NULL, NULL, NULL, NULL, NULL))
+ return GL_FALSE;
+#endif
+
+ if (image->Border > 0)
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
+
+/**********************************************************************/
+/**** NEW TEXTURE IMAGE FUNCTIONS ****/
+/**********************************************************************/
+extern void
+fxt1_decode_1 (const void *texture, int width,
+ int i, int j, unsigned char *rgba);
+
+/* Texel-fetch functions for software texturing and glGetTexImage().
+ * We should have been able to use some "standard" fetch functions (which
+ * may get defined in texutil.c) but we have to account for scaled texture
+ * images on tdfx hardware (the 8:1 aspect ratio limit).
+ * Hence, we need special functions here.
+ */
+
+static void
+fetch_intensity8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+ const GLubyte *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLubyte *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = *texel;
+ rgba[GCOMP] = *texel;
+ rgba[BCOMP] = *texel;
+ rgba[ACOMP] = *texel;
+}
+
+
+static void
+fetch_luminance8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+ const GLubyte *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLubyte *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = *texel;
+ rgba[GCOMP] = *texel;
+ rgba[BCOMP] = *texel;
+ rgba[ACOMP] = 255;
+}
+
+
+static void
+fetch_alpha8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+ const GLubyte *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLubyte *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = 255;
+ rgba[GCOMP] = 255;
+ rgba[BCOMP] = 255;
+ rgba[ACOMP] = *texel;
+}
+
+
+static void
+fetch_index8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *indexOut)
+{
+ const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+ const GLubyte *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLubyte *) texImage->Data) + j * mml->width + i;
+ *indexOut = *texel;
+}
+
+
+static void
+fetch_luminance8_alpha8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+ const GLubyte *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLubyte *) texImage->Data) + (j * mml->width + i) * 2;
+ rgba[RCOMP] = texel[0];
+ rgba[GCOMP] = texel[0];
+ rgba[BCOMP] = texel[0];
+ rgba[ACOMP] = texel[1];
+}
+
+
+static void
+fetch_r5g6b5(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+ const GLushort *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLushort *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = FX_rgb_scale_5[(*texel >> 11) & 0x1F];
+ rgba[GCOMP] = FX_rgb_scale_6[(*texel >> 5) & 0x3F];
+ rgba[BCOMP] = FX_rgb_scale_5[ *texel & 0x1F];
+ rgba[ACOMP] = 255;
+}
+
+
+static void
+fetch_r4g4b4a4(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+ const GLushort *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLushort *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = FX_rgb_scale_4[(*texel >> 8) & 0xF];
+ rgba[GCOMP] = FX_rgb_scale_4[(*texel >> 4) & 0xF];
+ rgba[BCOMP] = FX_rgb_scale_4[ *texel & 0xF];
+ rgba[ACOMP] = FX_rgb_scale_4[(*texel >> 12) & 0xF];
+}
+
+
+static void
+fetch_r5g5b5a1(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+ const GLushort *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLushort *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = FX_rgb_scale_5[(*texel >> 10) & 0x1F];
+ rgba[GCOMP] = FX_rgb_scale_5[(*texel >> 5) & 0x1F];
+ rgba[BCOMP] = FX_rgb_scale_5[ *texel & 0x1F];
+ rgba[ACOMP] = (*texel >> 15) * 255;
+}
+
+
+static void
+fetch_a8r8g8b8(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+ const GLuint *texel;
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ texel = ((GLuint *) texImage->Data) + j * mml->width + i;
+ rgba[RCOMP] = (((*texel) >> 16) & 0xff);
+ rgba[GCOMP] = (((*texel) >> 8) & 0xff);
+ rgba[BCOMP] = (((*texel) ) & 0xff);
+ rgba[ACOMP] = (((*texel) >> 24) & 0xff);
+}
+
+
+static void
+fetch_rgb_fxt1(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ fxt1_decode_1(texImage->Data, mml->width, i, j, rgba);
+ rgba[ACOMP] = 255;
+}
+
+
+static void
+fetch_rgba_fxt1(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ fxt1_decode_1(texImage->Data, mml->width, i, j, rgba);
+}
+
+
+static void
+fetch_rgb_dxt1(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ _mesa_texformat_rgb_dxt1.FetchTexel2D(texImage, i, j, k, rgba);
+}
+
+
+static void
+fetch_rgba_dxt1(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ _mesa_texformat_rgba_dxt1.FetchTexel2D(texImage, i, j, k, rgba);
+}
+
+
+static void
+fetch_rgba_dxt3(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ _mesa_texformat_rgba_dxt3.FetchTexel2D(texImage, i, j, k, rgba);
+}
+
+
+static void
+fetch_rgba_dxt5(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *rgba)
+{
+ const tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+
+ i = i * mml->wScale;
+ j = j * mml->hScale;
+
+ _mesa_texformat_rgba_dxt5.FetchTexel2D(texImage, i, j, k, rgba);
+}
+
+
+#if 0 /* break glass in case of emergency */
+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)
+ fprintf(stderr, "%02x %02x ", data[0], data[1]);
+ else if (c == 3)
+ fprintf(stderr, "%02x %02x %02x ", data[0], data[1], data[2]);
+ data += c;
+ }
+ fprintf(stderr, "\n");
+ }
+}
+#endif
+
+
+const struct gl_texture_format *
+fxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum srcFormat, GLenum srcType )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLboolean allow32bpt = fxMesa->HaveTexFmt;
+
+ if (TDFX_DEBUG & VERBOSE_TEXTURE) {
+ fprintf(stderr, "fxDDChooseTextureFormat(...)\n");
+ }
+
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGB:
+ /* intentional fall through */
+ case 3:
+ case GL_RGB:
+ if ( srcFormat == GL_RGB && srcType == GL_UNSIGNED_SHORT_5_6_5 ) {
+ return &_mesa_texformat_rgb565;
+ }
+ /* intentional fall through */
+ case GL_RGB8:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ return (allow32bpt) ? &_mesa_texformat_argb8888
+ : &_mesa_texformat_rgb565;
+ case GL_RGBA2:
+ case GL_RGBA4:
+ return &_mesa_texformat_argb4444;
+ case GL_COMPRESSED_RGBA:
+ /* intentional fall through */
+ case 4:
+ case GL_RGBA:
+ if ( srcFormat == GL_BGRA ) {
+ if ( srcType == GL_UNSIGNED_INT_8_8_8_8_REV ) {
+ return &_mesa_texformat_argb8888;
+ }
+ else if ( srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV ) {
+ return &_mesa_texformat_argb4444;
+ }
+ else if ( srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV ) {
+ return &_mesa_texformat_argb1555;
+ }
+ }
+ /* intentional fall through */
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return (allow32bpt) ? &_mesa_texformat_argb8888
+ : &_mesa_texformat_argb4444;
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case GL_COMPRESSED_INTENSITY:
+ return &_mesa_texformat_i8;
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE8:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ case GL_COMPRESSED_LUMINANCE:
+ return &_mesa_texformat_l8;
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ case GL_COMPRESSED_ALPHA:
+ return &_mesa_texformat_a8;
+ 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:
+ return &_mesa_texformat_ci8;
+ 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_COMPRESSED_LUMINANCE_ALPHA:
+ return &_mesa_texformat_al88;
+ case GL_R3_G3_B2:
+ case GL_RGB4:
+ case GL_RGB5:
+ return &_mesa_texformat_rgb565;
+ case GL_RGB5_A1:
+ return &_mesa_texformat_argb1555;
+ /* GL_EXT_texture_compression_s3tc */
+ /* GL_S3_s3tc */
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ return &_mesa_texformat_rgb_dxt1;
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgba_dxt1;
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ return &_mesa_texformat_rgba_dxt3;
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ return &_mesa_texformat_rgba_dxt5;
+ /* GL_3DFX_texture_compression_FXT1 */
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ return &_mesa_texformat_rgb_fxt1;
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ return &_mesa_texformat_rgba_fxt1;
+ default:
+ _mesa_problem(NULL, "unexpected format in fxDDChooseTextureFormat");
+ return NULL;
+ }
+}
+
+
+static GrTextureFormat_t
+fxGlideFormat(GLint mesaFormat)
+{
+ switch (mesaFormat) {
+ case MESA_FORMAT_I8:
+ return GR_TEXFMT_ALPHA_8;
+ case MESA_FORMAT_A8:
+ return GR_TEXFMT_ALPHA_8;
+ case MESA_FORMAT_L8:
+ return GR_TEXFMT_INTENSITY_8;
+ case MESA_FORMAT_CI8:
+ return GR_TEXFMT_P_8;
+ case MESA_FORMAT_AL88:
+ return GR_TEXFMT_ALPHA_INTENSITY_88;
+ case MESA_FORMAT_RGB565:
+ return GR_TEXFMT_RGB_565;
+ case MESA_FORMAT_ARGB4444:
+ return GR_TEXFMT_ARGB_4444;
+ case MESA_FORMAT_ARGB1555:
+ return GR_TEXFMT_ARGB_1555;
+ case MESA_FORMAT_ARGB8888:
+ return GR_TEXFMT_ARGB_8888;
+ case MESA_FORMAT_RGB_FXT1:
+ case MESA_FORMAT_RGBA_FXT1:
+ return GR_TEXFMT_ARGB_CMP_FXT1;
+ case MESA_FORMAT_RGB_DXT1:
+ case MESA_FORMAT_RGBA_DXT1:
+ return GR_TEXFMT_ARGB_CMP_DXT1;
+ case MESA_FORMAT_RGBA_DXT3:
+ return GR_TEXFMT_ARGB_CMP_DXT3;
+ case MESA_FORMAT_RGBA_DXT5:
+ return GR_TEXFMT_ARGB_CMP_DXT5;
+ default:
+ _mesa_problem(NULL, "Unexpected format in fxGlideFormat");
+ return 0;
+ }
+}
+
+
+static FetchTexelFuncC
+fxFetchFunction(GLint mesaFormat)
+{
+ switch (mesaFormat) {
+ case MESA_FORMAT_I8:
+ return &fetch_intensity8;
+ case MESA_FORMAT_A8:
+ return &fetch_alpha8;
+ case MESA_FORMAT_L8:
+ return &fetch_luminance8;
+ case MESA_FORMAT_CI8:
+ return &fetch_index8;
+ case MESA_FORMAT_AL88:
+ return &fetch_luminance8_alpha8;
+ case MESA_FORMAT_RGB565:
+ return &fetch_r5g6b5;
+ case MESA_FORMAT_ARGB4444:
+ return &fetch_r4g4b4a4;
+ case MESA_FORMAT_ARGB1555:
+ return &fetch_r5g5b5a1;
+ case MESA_FORMAT_ARGB8888:
+ return &fetch_a8r8g8b8;
+ case MESA_FORMAT_RGB_FXT1:
+ return &fetch_rgb_fxt1;
+ case MESA_FORMAT_RGBA_FXT1:
+ return &fetch_rgba_fxt1;
+ case MESA_FORMAT_RGB_DXT1:
+ return &fetch_rgb_dxt1;
+ case MESA_FORMAT_RGBA_DXT1:
+ return &fetch_rgba_dxt1;
+ case MESA_FORMAT_RGBA_DXT3:
+ return &fetch_rgba_dxt3;
+ case MESA_FORMAT_RGBA_DXT5:
+ return &fetch_rgba_dxt5;
+ default:
+ _mesa_problem(NULL, "Unexpected format in fxFetchFunction");
+ return NULL;
+ }
+}
+
+
+static GLboolean
+adjust2DRatio (GLcontext *ctx,
+ GLint xoffset, GLint yoffset,
+ GLint width, GLint height,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ tfxMipMapLevel *mml,
+ struct gl_texture_image *texImage,
+ GLint texelBytes,
+ GLint dstRowStride)
+{
+ const GLint newWidth = width * mml->wScale;
+ const GLint newHeight = height * mml->hScale;
+ GLvoid *tempImage;
+
+ if (!texImage->IsCompressed) {
+ GLubyte *destAddr;
+ tempImage = MALLOC(width * height * texelBytes);
+ if (!tempImage) {
+ return GL_FALSE;
+ }
+
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat, tempImage,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ width * texelBytes, /* dstRowStride */
+ 0, /* dstImageStride */
+ width, height, 1,
+ format, type, pixels, packing);
+
+ /* now rescale */
+ /* compute address of dest subimage within the overal tex image */
+ destAddr = (GLubyte *) texImage->Data
+ + (yoffset * mml->hScale * mml->width
+ + xoffset * mml->wScale) * texelBytes;
+
+ _mesa_rescale_teximage2d(texelBytes,
+ width,
+ dstRowStride, /* dst stride */
+ width, height,
+ newWidth, newHeight,
+ tempImage, destAddr);
+ } else {
+ const GLint rawBytes = 4;
+ GLvoid *rawImage = MALLOC(width * height * rawBytes);
+ if (!rawImage) {
+ return GL_FALSE;
+ }
+ tempImage = MALLOC(newWidth * newHeight * rawBytes);
+ if (!tempImage) {
+ return GL_FALSE;
+ }
+ /* unpack image, apply transfer ops and store in rawImage */
+ _mesa_texstore_rgba8888(ctx, 2, GL_RGBA,
+ &_mesa_texformat_rgba8888_rev, rawImage,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ width * rawBytes, /* dstRowStride */
+ 0, /* dstImageStride */
+ width, height, 1,
+ format, type, pixels, packing);
+ _mesa_rescale_teximage2d(rawBytes,
+ width,
+ newWidth * rawBytes, /* dst stride */
+ width, height, /* src */
+ newWidth, newHeight, /* dst */
+ rawImage /*src*/, tempImage /*dst*/ );
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat, texImage->Data,
+ xoffset * mml->wScale, yoffset * mml->hScale, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ 0, /* dstImageStride */
+ newWidth, newHeight, 1,
+ GL_RGBA, CHAN_TYPE, tempImage, &ctx->DefaultPacking);
+ FREE(rawImage);
+ }
+
+ FREE(tempImage);
+
+ return GL_TRUE;
+}
+
+
+void
+fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
+ GLint internalFormat, GLint width, GLint height, GLint border,
+ 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 = FX_CONTEXT(ctx);
+ tfxTexInfo *ti;
+ tfxMipMapLevel *mml;
+ GLint texelBytes, dstRowStride;
+
+ if (TDFX_DEBUG & VERBOSE_TEXTURE) {
+ fprintf(stderr, "fxDDTexImage2D: id=%d int 0x%x format 0x%x type 0x%x %dx%d\n",
+ texObj->Name, texImage->IntFormat, format, type,
+ texImage->Width, texImage->Height);
+ }
+
+ if (!fxIsTexSupported(target, internalFormat, texImage)) {
+ _mesa_problem(NULL, "fx Driver: unsupported texture in fxDDTexImg()\n");
+ return;
+ }
+
+ if (!texObj->DriverData) {
+ texObj->DriverData = fxAllocTexObjData(fxMesa);
+ if (!texObj->DriverData) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ }
+ ti = fxTMGetTexInfo(texObj);
+
+ if (!texImage->DriverData) {
+ texImage->DriverData = CALLOC(sizeof(tfxMipMapLevel));
+ if (!texImage->DriverData) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ }
+ mml = FX_MIPMAP_DATA(texImage);
+
+ fxTexGetInfo(width, height, NULL, NULL, NULL, NULL,
+ &mml->wScale, &mml->hScale);
+
+ mml->width = width * mml->wScale;
+ mml->height = height * mml->hScale;
+
+#if FX_COMPRESS_S3TC_AS_FXT1_HACK
+ /* [koolsmoky] substitute FXT1 for DXTn and Legacy S3TC */
+ if (!ctx->Mesa_DXTn && texImage->IsCompressed) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ internalFormat = GL_COMPRESSED_RGB_FXT1_3DFX;
+ break;
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ internalFormat = GL_COMPRESSED_RGBA_FXT1_3DFX;
+ }
+ texImage->IntFormat = internalFormat;
+ }
+#endif
+#if FX_TC_NAPALM
+ if (fxMesa->type >= GR_SSTTYPE_Voodoo4) {
+ GLenum texNapalm = 0;
+ if (internalFormat == GL_COMPRESSED_RGB) {
+ texNapalm = GL_COMPRESSED_RGB_FXT1_3DFX;
+ } else if (internalFormat == GL_COMPRESSED_RGBA) {
+ texNapalm = GL_COMPRESSED_RGBA_FXT1_3DFX;
+ }
+ if (texNapalm) {
+ texImage->IntFormat = internalFormat = texNapalm;
+ texImage->IsCompressed = GL_TRUE;
+ }
+ }
+#endif
+
+ /* choose the texture format */
+ assert(ctx->Driver.ChooseTextureFormat);
+ texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
+ internalFormat, format, type);
+ assert(texImage->TexFormat);
+ texelBytes = texImage->TexFormat->TexelBytes;
+ /*if (!fxMesa->HaveTexFmt) assert(texelBytes == 1 || texelBytes == 2);*/
+
+ mml->glideFormat = fxGlideFormat(texImage->TexFormat->MesaFormat);
+
+ /* allocate mipmap buffer */
+ assert(!texImage->Data);
+ if (texImage->IsCompressed) {
+ texImage->CompressedSize = _mesa_compressed_texture_size(ctx,
+ mml->width,
+ mml->height,
+ 1,
+ internalFormat);
+ dstRowStride = _mesa_compressed_row_stride(internalFormat, mml->width);
+ texImage->Data = _mesa_malloc(texImage->CompressedSize);
+ } else {
+ dstRowStride = mml->width * texelBytes;
+ texImage->Data = _mesa_malloc(mml->width * mml->height * texelBytes);
+ }
+ if (!texImage->Data) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+
+ if (pixels != NULL) {
+ if (mml->wScale != 1 || mml->hScale != 1) {
+ /* rescale image to overcome 1:8 aspect limitation */
+ if (!adjust2DRatio(ctx,
+ 0, 0,
+ width, height,
+ format, type, pixels,
+ packing,
+ mml,
+ texImage,
+ texelBytes,
+ dstRowStride)
+ ) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ }
+ else {
+ /* no rescaling needed */
+ /* unpack image, apply transfer ops and store in texImage->Data */
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat, texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ 0, /* dstImageStride */
+ width, height, 1,
+ format, type, pixels, packing);
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ GLint mipWidth, mipHeight;
+ tfxMipMapLevel *mip;
+ struct gl_texture_image *mipImage;
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target);
+
+ assert(!texImage->IsCompressed);
+
+ while (level < texObj->MaxLevel && level < maxLevels - 1) {
+ mipWidth = width / 2;
+ if (!mipWidth) {
+ mipWidth = 1;
+ }
+ mipHeight = height / 2;
+ if (!mipHeight) {
+ mipHeight = 1;
+ }
+ if ((mipWidth == width) && (mipHeight == height)) {
+ break;
+ }
+ _mesa_TexImage2D(target, ++level, internalFormat,
+ mipWidth, mipHeight, border,
+ format, type,
+ NULL);
+ mipImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ mip = FX_MIPMAP_DATA(mipImage);
+ _mesa_halve2x2_teximage2d(ctx,
+ texImage,
+ texelBytes,
+ mml->width, mml->height,
+ texImage->Data, mipImage->Data);
+ texImage = mipImage;
+ mml = mip;
+ width = mipWidth;
+ height = mipHeight;
+ }
+ }
+ }
+
+ ti->info.format = mml->glideFormat;
+ texImage->FetchTexelc = fxFetchFunction(texImage->TexFormat->MesaFormat);
+
+ fxTexInvalidate(ctx, texObj);
+}
+
+
+void
+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 = FX_CONTEXT(ctx);
+ tfxTexInfo *ti;
+ tfxMipMapLevel *mml;
+ GLint texelBytes, dstRowStride;
+
+ if (TDFX_DEBUG & VERBOSE_TEXTURE) {
+ fprintf(stderr, "fxDDTexSubImage2D: id=%d\n", texObj->Name);
+ }
+
+ if (!texObj->DriverData) {
+ _mesa_problem(ctx, "problem in fxDDTexSubImage2D");
+ return;
+ }
+
+ ti = fxTMGetTexInfo(texObj);
+ assert(ti);
+ mml = FX_MIPMAP_DATA(texImage);
+ assert(mml);
+
+ assert(texImage->Data); /* must have an existing texture image! */
+ assert(texImage->Format);
+
+ texelBytes = texImage->TexFormat->TexelBytes;
+ if (texImage->IsCompressed) {
+ dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat, mml->width);
+ } else {
+ dstRowStride = mml->width * texelBytes;
+ }
+
+ if (mml->wScale != 1 || mml->hScale != 1) {
+ /* need to rescale subimage to match mipmap level's rescale factors */
+ if (!adjust2DRatio(ctx,
+ xoffset, yoffset,
+ width, height,
+ format, type, pixels,
+ packing,
+ mml,
+ texImage,
+ texelBytes,
+ dstRowStride)
+ ) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
+ return;
+ }
+ }
+ else {
+ /* no rescaling needed */
+ texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat, (GLubyte *) texImage->Data,
+ xoffset, yoffset, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ 0, /* dstImageStride */
+ width, height, 1,
+ format, type, pixels, packing);
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ GLint mipWidth, mipHeight;
+ tfxMipMapLevel *mip;
+ struct gl_texture_image *mipImage;
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target);
+
+ assert(!texImage->IsCompressed);
+
+ width = texImage->Width;
+ height = texImage->Height;
+ while (level < texObj->MaxLevel && level < maxLevels - 1) {
+ mipWidth = width / 2;
+ if (!mipWidth) {
+ mipWidth = 1;
+ }
+ mipHeight = height / 2;
+ if (!mipHeight) {
+ mipHeight = 1;
+ }
+ if ((mipWidth == width) && (mipHeight == height)) {
+ break;
+ }
+ ++level;
+ mipImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ mip = FX_MIPMAP_DATA(mipImage);
+ _mesa_halve2x2_teximage2d(ctx,
+ texImage,
+ texelBytes,
+ mml->width, mml->height,
+ texImage->Data, mipImage->Data);
+ texImage = mipImage;
+ mml = mip;
+ width = mipWidth;
+ height = mipHeight;
+ }
+ }
+
+ if (ti->validated && ti->isInTM && !texObj->GenerateMipmap)
+ fxTMReloadMipMapLevel(fxMesa, texObj, level);
+ else
+ fxTexInvalidate(ctx, texObj);
+}
+
+
+void
+fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target,
+ GLint level, GLint internalFormat,
+ GLsizei width, GLsizei height, GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxTexInfo *ti;
+ tfxMipMapLevel *mml;
+
+ if (TDFX_DEBUG & VERBOSE_TEXTURE) {
+ fprintf(stderr, "fxDDCompressedTexImage2D: id=%d int 0x%x %dx%d\n",
+ texObj->Name, internalFormat,
+ width, height);
+ }
+
+ assert(texImage->IsCompressed);
+
+ if (!fxIsTexSupported(target, internalFormat, texImage)) {
+ _mesa_problem(NULL, "fx Driver: unsupported texture in fxDDCompressedTexImg()\n");
+ return;
+ }
+
+ if (!texObj->DriverData) {
+ texObj->DriverData = fxAllocTexObjData(fxMesa);
+ if (!texObj->DriverData) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
+ return;
+ }
+ }
+ ti = fxTMGetTexInfo(texObj);
+
+ if (!texImage->DriverData) {
+ texImage->DriverData = CALLOC(sizeof(tfxMipMapLevel));
+ if (!texImage->DriverData) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
+ return;
+ }
+ }
+ mml = FX_MIPMAP_DATA(texImage);
+
+ fxTexGetInfo(width, height, NULL, NULL, NULL, NULL,
+ &mml->wScale, &mml->hScale);
+
+ mml->width = width * mml->wScale;
+ mml->height = height * mml->hScale;
+
+
+ /* choose the texture format */
+ assert(ctx->Driver.ChooseTextureFormat);
+ texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
+ internalFormat, -1/*format*/, -1/*type*/);
+ assert(texImage->TexFormat);
+
+ /* Determine the appropriate Glide texel format,
+ * given the user's internal texture format hint.
+ */
+ mml->glideFormat = fxGlideFormat(texImage->TexFormat->MesaFormat);
+
+ /* allocate new storage for texture image, if needed */
+ if (!texImage->Data) {
+ texImage->CompressedSize = _mesa_compressed_texture_size(ctx,
+ mml->width,
+ mml->height,
+ 1,
+ internalFormat);
+ texImage->Data = _mesa_malloc(texImage->CompressedSize);
+ if (!texImage->Data) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
+ return;
+ }
+ }
+
+ /* save the texture data */
+ if (mml->wScale != 1 || mml->hScale != 1) {
+ /* [dBorca] Hack alert:
+ * now we're screwed. We can't decompress,
+ * unless we do it in HW (via textureBuffer).
+ * We still have some chances:
+ * 1) we got FXT1 textures - we CAN decompress, rescale for
+ * aspectratio, then compress back.
+ * 2) there is a chance that MIN("s", "t") won't be overflowed.
+ * Thus, we don't care about textureclamp and we could lower
+ * MIN("uscale", "vscale") below 32. We still have to have
+ * our data aligned inside a 8:1 rectangle.
+ * 3) just in case if MIN("s", "t") gets overflowed with GL_REPEAT,
+ * we replicate the data over the padded area.
+ * For now, we take 2) + 3) but texelfetchers will be wrong!
+ */
+ GLuint srcRowStride = _mesa_compressed_row_stride(internalFormat, width);
+
+ GLuint destRowStride = _mesa_compressed_row_stride(internalFormat,
+ mml->width);
+
+ _mesa_upscale_teximage2d(srcRowStride, (height+3) / 4,
+ destRowStride, (mml->height+3) / 4,
+ 1, data, srcRowStride,
+ texImage->Data);
+ ti->padded = GL_TRUE;
+ } else {
+ MEMCPY(texImage->Data, data, texImage->CompressedSize);
+ }
+
+ ti->info.format = mml->glideFormat;
+ texImage->FetchTexelc = fxFetchFunction(texImage->TexFormat->MesaFormat);
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ assert(!texImage->IsCompressed);
+ }
+
+ fxTexInvalidate(ctx, texObj);
+}
+
+
+void
+fxDDCompressedTexSubImage2D( 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 )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxTexInfo *ti;
+ tfxMipMapLevel *mml;
+ GLint destRowStride, srcRowStride;
+ GLint i, rows;
+ GLubyte *dest;
+
+ if (TDFX_DEBUG & VERBOSE_TEXTURE) {
+ fprintf(stderr, "fxDDCompressedTexSubImage2D: id=%d\n", texObj->Name);
+ }
+
+ ti = fxTMGetTexInfo(texObj);
+ assert(ti);
+ mml = FX_MIPMAP_DATA(texImage);
+ assert(mml);
+
+ srcRowStride = _mesa_compressed_row_stride(texImage->IntFormat, width);
+
+ destRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
+ mml->width);
+ dest = _mesa_compressed_image_address(xoffset, yoffset, 0,
+ texImage->IntFormat,
+ mml->width,
+ (GLubyte*) texImage->Data);
+
+ rows = height / 4; /* hardcoded 4, but works for FXT1/DXTC */
+
+ for (i = 0; i < rows; i++) {
+ MEMCPY(dest, data, srcRowStride);
+ dest += destRowStride;
+ data = (GLvoid *)((GLuint)data + (GLuint)srcRowStride);
+ }
+
+ /* [dBorca] Hack alert:
+ * see fxDDCompressedTexImage2D for caveats
+ */
+ if (mml->wScale != 1 || mml->hScale != 1) {
+ srcRowStride = _mesa_compressed_row_stride(texImage->IntFormat, texImage->Width);
+
+ destRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
+ mml->width);
+ _mesa_upscale_teximage2d(srcRowStride, texImage->Height / 4,
+ destRowStride, mml->height / 4,
+ 1, texImage->Data, destRowStride,
+ texImage->Data);
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ assert(!texImage->IsCompressed);
+ }
+
+ if (ti->validated && ti->isInTM)
+ fxTMReloadMipMapLevel(fxMesa, texObj, level);
+ else
+ fxTexInvalidate(ctx, texObj);
+}
+
+
+void
+fxDDTexImage1D (GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat, GLint width, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ fxDDTexImage2D(ctx, target, level,
+ internalFormat, width, 1, border,
+ format, type, pixels,
+ packing,
+ texObj,
+ texImage);
+}
+
+
+void
+fxDDTexSubImage1D(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)
+{
+ fxDDTexSubImage2D(ctx, target, level,
+ xoffset, 0, width, 1,
+ format, type, pixels,
+ packing,
+ texObj,
+ texImage);
+}
+
+
+GLboolean
+fxDDTestProxyTexImage (GLcontext *ctx, GLenum target,
+ GLint level, GLint internalFormat,
+ GLenum format, GLenum type,
+ GLint width, GLint height,
+ GLint depth, GLint border)
+{
+ /* XXX todo - maybe through fxTexValidate() */
+ return _mesa_test_proxy_teximage(ctx, target,
+ level, internalFormat,
+ format, type,
+ width, height,
+ depth, border);
+}
+
+
+#else /* FX */
+
+/*
+ * Need this to provide at least one external definition.
+ */
+
+extern int gl_fx_dummy_function_ddtex(void);
+int
+gl_fx_dummy_function_ddtex(void)
+{
+ return 0;
+}
+
+#endif /* FX */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxdrv.h b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxdrv.h
new file mode 100644
index 000000000..ca3bdc99b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxdrv.h
@@ -0,0 +1,771 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.0
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/* Authors:
+ * David Bucciarelli
+ * Brian Paul
+ * Daryll Strauss
+ * Keith Whitwell
+ * Daniel Borca
+ * Hiroshi Morii
+ */
+
+/* fxsetup.c - 3Dfx VooDoo rendering mode setup functions */
+
+
+#ifndef FXDRV_H
+#define FXDRV_H
+
+/* If you comment out this define, a variable takes its place, letting
+ * you turn debugging on/off from the debugger.
+ */
+
+#include "glheader.h"
+
+
+#if defined(__linux__)
+#include <signal.h>
+#endif
+
+#include "context.h"
+#include "imports.h"
+#include "macros.h"
+#include "matrix.h"
+#include "mtypes.h"
+
+#include "GL/fxmesa.h"
+#include "fxglidew.h"
+
+#include "math/m_vector.h"
+
+
+/* Define some shorter names for these things.
+ */
+#define XCOORD GR_VERTEX_X_OFFSET
+#define YCOORD GR_VERTEX_Y_OFFSET
+#define ZCOORD GR_VERTEX_OOZ_OFFSET
+#define OOWCOORD GR_VERTEX_OOW_OFFSET
+
+#define S0COORD GR_VERTEX_SOW_TMU0_OFFSET
+#define T0COORD GR_VERTEX_TOW_TMU0_OFFSET
+#define S1COORD GR_VERTEX_SOW_TMU1_OFFSET
+#define T1COORD GR_VERTEX_TOW_TMU1_OFFSET
+
+
+
+#ifdef __i386__
+#define FXCOLOR4( c ) (* (int *)c)
+#else
+#define FXCOLOR4( c ) ( \
+ ( ((unsigned int)(c[3]))<<24 ) | \
+ ( ((unsigned int)(c[2]))<<16 ) | \
+ ( ((unsigned int)(c[1]))<<8 ) | \
+ ( (unsigned int)(c[0])) )
+#endif
+
+#define TDFXPACKCOLOR1555( r, g, b, a ) \
+ ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
+ ((a) ? 0x8000 : 0))
+#define TDFXPACKCOLOR565( r, g, b ) \
+ ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
+#define TDFXPACKCOLOR8888( r, g, b, a ) \
+ (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
+
+
+
+/* fastpath flags first
+ */
+#define SETUP_TMU0 0x1
+#define SETUP_TMU1 0x2
+#define SETUP_RGBA 0x4
+#define SETUP_SNAP 0x8
+#define SETUP_XYZW 0x10
+#define SETUP_PTEX 0x20
+#define SETUP_PSIZ 0x40
+#define SETUP_SPEC 0x80
+#define SETUP_FOGC 0x100
+#define MAX_SETUP 0x200
+
+
+#define FX_NUM_TMU 2
+
+#define FX_TMU0 GR_TMU0
+#define FX_TMU1 GR_TMU1
+#define FX_TMU_SPLIT 98
+#define FX_TMU_BOTH 99
+#define FX_TMU_NONE 100
+
+/* Used for fxMesa->lastUnitsMode */
+
+#define FX_UM_NONE 0x00000000
+
+#define FX_UM_E0_REPLACE 0x00000001
+#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_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_E_ENVMODE 0x000003ff
+
+#define FX_UM_E0_ALPHA 0x00001000
+#define FX_UM_E0_LUMINANCE 0x00002000
+#define FX_UM_E0_LUMINANCE_ALPHA 0x00004000
+#define FX_UM_E0_INTENSITY 0x00008000
+#define FX_UM_E0_RGB 0x00010000
+#define FX_UM_E0_RGBA 0x00020000
+
+#define FX_UM_E1_ALPHA 0x00040000
+#define FX_UM_E1_LUMINANCE 0x00080000
+#define FX_UM_E1_LUMINANCE_ALPHA 0x00100000
+#define FX_UM_E1_INTENSITY 0x00200000
+#define FX_UM_E1_RGB 0x00400000
+#define FX_UM_E1_RGBA 0x00800000
+
+#define FX_UM_E_IFMT 0x00fff000
+
+#define FX_UM_COLOR_ITERATED 0x01000000
+#define FX_UM_COLOR_CONSTANT 0x02000000
+#define FX_UM_ALPHA_ITERATED 0x04000000
+#define FX_UM_ALPHA_CONSTANT 0x08000000
+
+
+/* for Voodoo3/Banshee's grColorCombine() and grAlphaCombine() */
+struct tdfx_combine {
+ GrCombineFunction_t Function; /* Combine function */
+ GrCombineFactor_t Factor; /* Combine scale factor */
+ GrCombineLocal_t Local; /* Local combine source */
+ GrCombineOther_t Other; /* Other combine source */
+ FxBool Invert; /* Combine result inversion flag */
+};
+
+/* for Voodoo3's grTexCombine() */
+struct tdfx_texcombine {
+ GrCombineFunction_t FunctionRGB;
+ GrCombineFactor_t FactorRGB;
+ GrCombineFunction_t FunctionAlpha;
+ GrCombineFactor_t FactorAlpha;
+ FxBool InvertRGB;
+ FxBool InvertAlpha;
+};
+
+
+/* for Voodoo5's grColorCombineExt() */
+struct tdfx_combine_color_ext {
+ GrCCUColor_t SourceA;
+ GrCombineMode_t ModeA;
+ GrCCUColor_t SourceB;
+ GrCombineMode_t ModeB;
+ GrCCUColor_t SourceC;
+ FxBool InvertC;
+ GrCCUColor_t SourceD;
+ FxBool InvertD;
+ FxU32 Shift;
+ FxBool Invert;
+};
+
+/* for Voodoo5's grAlphaCombineExt() */
+struct tdfx_combine_alpha_ext {
+ GrACUColor_t SourceA;
+ GrCombineMode_t ModeA;
+ GrACUColor_t SourceB;
+ GrCombineMode_t ModeB;
+ GrACUColor_t SourceC;
+ FxBool InvertC;
+ GrACUColor_t SourceD;
+ FxBool InvertD;
+ FxU32 Shift;
+ FxBool Invert;
+};
+
+/* for Voodoo5's grTexColorCombineExt() */
+struct tdfx_color_texenv {
+ GrTCCUColor_t SourceA;
+ GrCombineMode_t ModeA;
+ GrTCCUColor_t SourceB;
+ GrCombineMode_t ModeB;
+ GrTCCUColor_t SourceC;
+ FxBool InvertC;
+ GrTCCUColor_t SourceD;
+ FxBool InvertD;
+ FxU32 Shift;
+ FxBool Invert;
+};
+
+/* for Voodoo5's grTexAlphaCombineExt() */
+struct tdfx_alpha_texenv {
+ GrTACUColor_t SourceA;
+ GrCombineMode_t ModeA;
+ GrTACUColor_t SourceB;
+ GrCombineMode_t ModeB;
+ GrTACUColor_t SourceC;
+ FxBool InvertC;
+ GrTCCUColor_t SourceD;
+ FxBool InvertD;
+ FxU32 Shift;
+ FxBool Invert;
+};
+
+/* Voodoo5's texture combine environment */
+struct tdfx_texcombine_ext {
+ struct tdfx_alpha_texenv Alpha;
+ struct tdfx_color_texenv Color;
+ GrColor_t EnvColor;
+};
+
+
+/*
+ Memory range from startAddr to endAddr-1
+*/
+typedef struct MemRange_t
+{
+ struct MemRange_t *next;
+ FxU32 startAddr, endAddr;
+}
+MemRange;
+
+typedef struct
+{
+ GLsizei width, height; /* image size */
+ GLint wScale, hScale; /* image scale factor */
+ GrTextureFormat_t glideFormat; /* Glide image format */
+}
+tfxMipMapLevel;
+
+/*
+ * TDFX-specific texture object data. This hangs off of the
+ * struct gl_texture_object DriverData pointer.
+ */
+typedef struct tfxTexInfo_t
+{
+ struct tfxTexInfo_t *next;
+ struct gl_texture_object *tObj;
+
+ GLuint lastTimeUsed;
+ FxU32 whichTMU;
+ GLboolean isInTM;
+
+ MemRange *tm[FX_NUM_TMU];
+
+ GLint minLevel, maxLevel;
+ GLint baseLevelInternalFormat;
+
+ GrTexInfo info;
+
+ GrTextureFilterMode_t minFilt;
+ GrTextureFilterMode_t maxFilt;
+ FxBool LODblend;
+
+ GrTextureClampMode_t sClamp;
+ GrTextureClampMode_t tClamp;
+
+ GrMipMapMode_t mmMode;
+
+ GLfloat sScale, tScale;
+
+ GrTexTable_t paltype;
+ GuTexPalette palette;
+
+ GLboolean fixedPalette;
+ GLboolean validated;
+
+ GLboolean padded;
+}
+tfxTexInfo;
+
+typedef struct
+{
+ GLuint swapBuffer;
+ GLuint reqTexUpload;
+ GLuint texUpload;
+ GLuint memTexUpload;
+}
+tfxStats;
+
+
+
+typedef struct
+{
+ /* Alpha test */
+
+ GLboolean alphaTestEnabled;
+ GrCmpFnc_t alphaTestFunc;
+ GLfloat alphaTestRefValue;
+
+ /* Blend function */
+
+ GLboolean blendEnabled;
+ GrAlphaBlendFnc_t blendSrcFuncRGB;
+ GrAlphaBlendFnc_t blendDstFuncRGB;
+ GrAlphaBlendFnc_t blendSrcFuncAlpha;
+ GrAlphaBlendFnc_t blendDstFuncAlpha;
+ GrAlphaBlendOp_t blendEqRGB;
+ GrAlphaBlendOp_t blendEqAlpha;
+
+ /* Depth test */
+
+ GLboolean depthTestEnabled;
+ GLboolean depthMask;
+ GrCmpFnc_t depthTestFunc;
+ FxI32 depthBias;
+
+ /* Stencil */
+
+ GLboolean stencilEnabled;
+ GrCmpFnc_t stencilFunction; /* Stencil function */
+ GrStencil_t stencilRefValue; /* Stencil reference value */
+ GrStencil_t stencilValueMask; /* Value mask */
+ GrStencil_t stencilWriteMask; /* Write mask */
+ GrCmpFnc_t stencilFailFunc; /* Stencil fail function */
+ GrCmpFnc_t stencilZFailFunc; /* Stencil pass, depth fail function */
+ GrCmpFnc_t stencilZPassFunc; /* Stencil pass, depth pass function */
+ GrStencil_t stencilClear; /* Buffer clear value */
+}
+tfxUnitsState;
+
+
+
+
+/* Flags for fxMesa->new_state
+ */
+#define FX_NEW_TEXTURING 0x1
+#define FX_NEW_BLEND 0x2
+#define FX_NEW_ALPHA 0x4
+#define FX_NEW_DEPTH 0x8
+#define FX_NEW_FOG 0x10
+#define FX_NEW_SCISSOR 0x20
+#define FX_NEW_COLOR_MASK 0x40
+#define FX_NEW_CULL 0x80
+#define FX_NEW_STENCIL 0x100
+
+
+#define FX_CONTEXT(ctx) ((fxMesaContext)((ctx)->DriverCtx))
+
+#define FX_TEXTURE_DATA(texUnit) fxTMGetTexInfo((texUnit)->_Current)
+
+#define fxTMGetTexInfo(o) ((tfxTexInfo*)((o)->DriverData))
+
+#define FX_MIPMAP_DATA(img) ((tfxMipMapLevel *) (img)->DriverData)
+
+#define BEGIN_BOARD_LOCK()
+#define END_BOARD_LOCK()
+#define BEGIN_CLIP_LOOP()
+#define END_CLIP_LOOP()
+
+
+
+
+/* Covers the state referenced by IsInHardware:
+ */
+#define _FX_NEW_IS_IN_HARDWARE (_NEW_TEXTURE| \
+ _NEW_HINT| \
+ _NEW_STENCIL| \
+ _NEW_BUFFERS| \
+ _NEW_COLOR| \
+ _NEW_LIGHT)
+
+/* Covers the state referenced by fxDDChooseRenderState
+ */
+#define _FX_NEW_RENDERSTATE (_FX_NEW_IS_IN_HARDWARE | \
+ _DD_NEW_FLATSHADE | \
+ _DD_NEW_TRI_LIGHT_TWOSIDE| \
+ _DD_NEW_TRI_OFFSET | \
+ _DD_NEW_TRI_UNFILLED | \
+ _DD_NEW_TRI_SMOOTH | \
+ _DD_NEW_TRI_STIPPLE | \
+ _DD_NEW_LINE_SMOOTH | \
+ _DD_NEW_LINE_STIPPLE | \
+ _DD_NEW_LINE_WIDTH | \
+ _DD_NEW_POINT_SMOOTH | \
+ _DD_NEW_POINT_SIZE | \
+ _NEW_LINE)
+
+
+/* Covers the state referenced by fxDDChooseSetupFunction.
+ */
+#define _FX_NEW_SETUP_FUNCTION (_NEW_LIGHT| \
+ _NEW_FOG| \
+ _NEW_TEXTURE| \
+ _NEW_COLOR) \
+
+
+/* lookup table for scaling y bit colors up to 8 bits */
+extern GLuint FX_rgb_scale_4[16];
+extern GLuint FX_rgb_scale_5[32];
+extern GLuint FX_rgb_scale_6[64];
+
+typedef void (*fx_tri_func) (fxMesaContext, GrVertex *, GrVertex *, GrVertex *);
+typedef void (*fx_line_func) (fxMesaContext, GrVertex *, GrVertex *);
+typedef void (*fx_point_func) (fxMesaContext, GrVertex *);
+
+struct tfxMesaContext
+{
+ GrTexTable_t glbPalType;
+ GuTexPalette glbPalette;
+
+ GLcontext *glCtx; /* the core Mesa context */
+ GLvisual *glVis; /* describes the color buffer */
+ GLframebuffer *glBuffer; /* the ancillary buffers */
+
+ GLint board; /* the board used for this context */
+ GLint width, height; /* size of color buffer */
+
+ GrBuffer_t currentFB;
+
+ GLboolean bgrOrder;
+ GrColor_t color;
+ GrColor_t clearC;
+ GrAlpha_t clearA;
+ GLuint constColor;
+ GrCullMode_t cullMode;
+
+ tfxUnitsState unitsState;
+ tfxUnitsState restoreUnitsState; /* saved during multipass */
+ GLboolean multipass; /* true when drawing intermediate pass */
+
+ GLuint new_state;
+ GLuint new_gl_state;
+
+ /* Texture Memory Manager Data
+ */
+ GLuint texBindNumber;
+ GLint tmuSrc;
+ GLuint lastUnitsMode;
+ GLuint freeTexMem[FX_NUM_TMU];
+ MemRange *tmPool;
+ MemRange *tmFree[FX_NUM_TMU];
+
+ GLenum fogTableMode;
+ GLfloat fogDensity;
+ GLfloat fogStart, fogEnd;
+ GrFog_t *fogTable;
+ GLint textureAlign;
+ GLint textureMaxLod;
+
+ /* Vertex building and storage:
+ */
+ GLuint tmu_source[FX_NUM_TMU];
+ GLuint SetupIndex;
+ GLuint stw_hint_state; /* for grHints */
+ GrVertex *verts;
+ GLboolean snapVertices; /* needed for older Voodoo hardware */
+
+ /* Rasterization:
+ */
+ GLuint render_index;
+ GLuint fallback;
+ GLenum render_primitive;
+ GLenum raster_primitive;
+
+ /* Current rasterization functions
+ */
+ fx_point_func draw_point;
+ fx_line_func draw_line;
+ fx_tri_func draw_tri;
+
+
+ /* Keep texture scales somewhere handy:
+ */
+ GLfloat s0scale;
+ GLfloat s1scale;
+ GLfloat t0scale;
+ GLfloat t1scale;
+
+ GLfloat inv_s0scale;
+ GLfloat inv_s1scale;
+ GLfloat inv_t0scale;
+ GLfloat inv_t1scale;
+
+ /* Glide stuff
+ */
+ tfxStats stats;
+ void *state;
+
+ /* Options */
+
+ GLboolean verbose;
+ GLboolean haveTwoTMUs; /* True if we really have 2 tmu's */
+ GLboolean haveHwAlpha;
+ GLboolean haveHwStencil;
+ GLboolean haveZBuffer;
+ GLboolean haveDoubleBuffer;
+ GLboolean haveGlobalPaletteTexture;
+ GLint swapInterval;
+ GLint maxPendingSwapBuffers;
+
+ GrContext_t glideContext;
+
+ int screen_width;
+ int screen_height;
+ int clipMinX;
+ int clipMaxX;
+ int clipMinY;
+ int clipMaxY;
+
+ int colDepth;
+ GLboolean fsaa;
+
+ /* Glide (per card) capabilities. These get mirrored
+ * from `glbHWConfig' when creating a new context...
+ */
+ GrSstType type;
+ FxBool HavePalExt; /* PALETTE6666 */
+ FxBool HavePixExt; /* PIXEXT */
+ FxBool HaveTexFmt; /* TEXFMT */
+ FxBool HaveCmbExt; /* COMBINE */
+ FxBool HaveMirExt; /* TEXMIRROR */
+ FxBool HaveTexUma; /* TEXUMA */
+ FxBool HaveTexus2; /* Texus 2 - FXT1 */
+ struct tdfx_glide Glide;
+ char rendererString[64];
+};
+
+
+extern void fxSetupFXUnits(GLcontext *);
+extern void fxSetupDDPointers(GLcontext *);
+
+/* fxvb.c:
+ */
+extern void fxAllocVB(GLcontext * ctx);
+extern void fxFreeVB(GLcontext * ctx);
+extern void fxPrintSetupFlags(char *msg, GLuint flags );
+extern void fxCheckTexSizes( GLcontext *ctx );
+extern void fxBuildVertices( GLcontext *ctx, GLuint start, GLuint end,
+ GLuint newinputs );
+extern void fxChooseVertexState( GLcontext *ctx );
+
+
+
+
+
+
+/* fxtrifuncs:
+ */
+extern void fxDDInitTriFuncs(GLcontext *);
+extern void fxDDChooseRenderState(GLcontext * ctx);
+
+
+extern void fxUpdateDDSpanPointers(GLcontext *);
+extern void fxSetupDDSpanPointers(GLcontext *);
+
+extern void fxPrintTextureData(tfxTexInfo * ti);
+
+extern const struct gl_texture_format *
+fxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum srcFormat, GLenum srcType );
+extern void fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
+ GLint internalFormat, GLint width, GLint height,
+ GLint border, GLenum format, GLenum type,
+ const GLvoid * pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+extern void 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 void fxDDCompressedTexImage2D(GLcontext *ctx, GLenum target,
+ GLint level, GLint internalFormat,
+ GLsizei width, GLsizei height, GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+extern void fxDDCompressedTexSubImage2D(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);
+extern void fxDDTexImage1D(GLcontext * ctx, GLenum target, GLint level,
+ GLint internalFormat, GLint width,
+ GLint border, GLenum format, GLenum type,
+ const GLvoid * pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+extern void fxDDTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
+ GLint xoffset, GLint width,
+ GLenum format, GLenum type,
+ const GLvoid * pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+extern GLboolean fxDDTestProxyTexImage (GLcontext *ctx, GLenum target,
+ GLint level, GLint internalFormat,
+ GLenum format, GLenum type,
+ GLint width, GLint height,
+ GLint depth, GLint border);
+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 struct gl_texture_object *fxDDNewTextureObject( GLcontext *ctx, GLuint name, GLenum target );
+extern void fxDDTexDel(GLcontext *, struct gl_texture_object *);
+extern GLboolean fxDDIsTextureResident(GLcontext *, struct gl_texture_object *);
+extern void fxDDTexPalette(GLcontext *, struct gl_texture_object *);
+extern void fxDDTexUseGlbPalette(GLcontext *, GLboolean);
+
+extern void fxDDEnable(GLcontext *, GLenum, GLboolean);
+extern void fxDDAlphaFunc(GLcontext *, GLenum, GLfloat);
+extern void fxDDBlendFuncSeparate(GLcontext *, GLenum, GLenum, GLenum, GLenum);
+extern void fxDDBlendEquationSeparate(GLcontext *, GLenum, GLenum);
+extern void fxDDDepthMask(GLcontext *, GLboolean);
+extern void fxDDDepthFunc(GLcontext *, GLenum);
+extern void fxDDStencilFunc (GLcontext *ctx, GLenum func, GLint ref, GLuint mask);
+extern void fxDDStencilMask (GLcontext *ctx, GLuint mask);
+extern void fxDDStencilOp (GLcontext *ctx, GLenum sfail, GLenum zfail, GLenum zpass);
+
+extern void fxDDInitExtensions(GLcontext * ctx);
+
+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
+extern void fxTMFreeTexture(fxMesaContext, struct gl_texture_object *);
+extern void fxTMReloadMipMapLevel(fxMesaContext, struct gl_texture_object *,
+ GLint);
+extern void fxTMReloadSubMipMapLevel(fxMesaContext,
+ struct gl_texture_object *, GLint, GLint,
+ GLint);
+extern int fxTMCheckStartAddr (fxMesaContext fxMesa, GLint tmu, tfxTexInfo *ti);
+
+extern void fxTexGetFormat(GLcontext *, GLenum, GrTextureFormat_t *, GLint *); /* [koolsmoky] */
+
+extern int fxTexGetInfo(int, int, GrLOD_t *, GrAspectRatio_t *,
+ float *, float *, int *, int *);
+
+extern void fxDDScissor(GLcontext * ctx,
+ GLint x, GLint y, GLsizei w, GLsizei h);
+extern void fxDDFogfv(GLcontext * ctx, GLenum pname, const GLfloat * params);
+extern void fxDDColorMask(GLcontext * ctx,
+ GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+
+extern void fxDDWriteDepthSpan(GLcontext * ctx, GLuint n, GLint x, GLint y,
+ const GLdepth depth[], const GLubyte mask[]);
+
+extern void fxDDReadDepthSpan(GLcontext * ctx, GLuint n, GLint x, GLint y,
+ GLdepth depth[]);
+
+extern void fxDDWriteDepthPixels(GLcontext * ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ const GLdepth depth[], const GLubyte mask[]);
+
+extern void fxDDReadDepthPixels(GLcontext * ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ GLdepth depth[]);
+
+extern void fxDDShadeModel(GLcontext * ctx, GLenum mode);
+
+extern void fxDDCullFace(GLcontext * ctx, GLenum mode);
+extern void fxDDFrontFace(GLcontext * ctx, GLenum mode);
+
+extern void fxPrintRenderState(const char *msg, GLuint state);
+extern void fxPrintHintState(const char *msg, GLuint state);
+
+extern int fxDDInitFxMesaContext(fxMesaContext fxMesa);
+extern void fxDDDestroyFxMesaContext(fxMesaContext fxMesa);
+
+
+extern void fxSetScissorValues(GLcontext * ctx);
+extern void fxTMMoveInTM_NoLock(fxMesaContext fxMesa,
+ struct gl_texture_object *tObj, GLint where);
+
+extern void fxCheckIsInHardware(GLcontext *ctx);
+
+/* fxsetup:
+ * semi-private functions
+ */
+void fxSetupCull (GLcontext * ctx);
+void fxSetupScissor (GLcontext * ctx);
+void fxSetupColorMask (GLcontext * ctx);
+void fxSetupBlend (GLcontext *ctx);
+void fxSetupDepthTest (GLcontext *ctx);
+void fxSetupTexture (GLcontext *ctx);
+void fxSetupStencil (GLcontext *ctx);
+void fxSetupStencilFace (GLcontext *ctx, GLint face);
+
+/* Flags for software fallback cases */
+#define FX_FALLBACK_TEXTURE_MAP 0x0001
+#define FX_FALLBACK_DRAW_BUFFER 0x0002
+#define FX_FALLBACK_SPECULAR 0x0004
+#define FX_FALLBACK_STENCIL 0x0008
+#define FX_FALLBACK_RENDER_MODE 0x0010
+#define FX_FALLBACK_LOGICOP 0x0020
+#define FX_FALLBACK_TEXTURE_ENV 0x0040
+#define FX_FALLBACK_TEXTURE_BORDER 0x0080
+#define FX_FALLBACK_COLORMASK 0x0100
+#define FX_FALLBACK_BLEND 0x0200
+#define FX_FALLBACK_TEXTURE_MULTI 0x0400
+
+extern GLuint fx_check_IsInHardware(GLcontext *ctx);
+
+/***
+ *** CNORM: clamp float to [0,1] and map to float in [0,255]
+ ***/
+#if defined(USE_IEEE) && !defined(DEBUG)
+#define IEEE_0996 0x3f7f0000 /* 0.996 or so */
+#define CNORM(N, F) \
+ do { \
+ fi_type __tmp; \
+ __tmp.f = (F); \
+ if (__tmp.i < 0) \
+ N = 0; \
+ else if (__tmp.i >= IEEE_0996) \
+ N = 255.0f; \
+ else { \
+ N = (F) * 255.0f; \
+ } \
+ } while (0)
+#else
+#define CNORM(n, f) \
+ n = (CLAMP((f), 0.0F, 1.0F) * 255.0F)
+#endif
+
+/* run-time debugging */
+#ifndef FX_DEBUG
+#define FX_DEBUG 0
+#endif
+#if FX_DEBUG
+extern int TDFX_DEBUG;
+#else
+#define TDFX_DEBUG 0
+#endif
+
+/* dirty hacks */
+#define FX_RESCALE_BIG_TEXURES_HACK 1
+#define FX_COMPRESS_S3TC_AS_FXT1_HACK 1
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxg.c b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxg.c
new file mode 100644
index 000000000..afb9441ad
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxg.c
@@ -0,0 +1,2309 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.0.1
+ *
+ * Copyright (C) 1999-2003 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/FX device driver. Interface to Glide3.
+ *
+ * Copyright (c) 2003 - Daniel Borca
+ * Email : dborca@users.sourceforge.net
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#ifdef FX
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <assert.h>
+
+#define FX_TRAP_GLIDE_internal
+#include "fxg.h"
+
+
+
+/****************************************************************************\
+* logging *
+\****************************************************************************/
+#if FX_TRAP_GLIDE
+#define TRAP_LOG trp_printf
+#ifdef __GNUC__
+__attribute__ ((format(printf, 1, 2)))
+#endif /* __GNUC__ */
+int trp_printf (const char *format, ...)
+{
+ va_list arg;
+ int n;
+ FILE *trap_file;
+ va_start(arg, format);
+ trap_file = fopen("trap.log", "a");
+ if (trap_file == NULL) {
+ trap_file = stderr;
+ }
+ n = vfprintf(trap_file, format, arg);
+ fclose(trap_file);
+ va_end(arg);
+ return n;
+}
+#else /* FX_TRAP_GLIDE */
+#ifdef __GNUC__
+#define TRAP_LOG(format, ...) do {} while (0)
+#else /* __GNUC__ */
+#define TRAP_LOG 0 && (unsigned long)
+#endif /* __GNUC__ */
+#endif /* FX_TRAP_GLIDE */
+
+
+
+#if FX_TRAP_GLIDE
+/****************************************************************************\
+* helpers *
+\****************************************************************************/
+
+#define GOT "\t"
+
+const char *TRP_BOOL (FxBool b)
+{
+ return b ? "FXTRUE" : "FXFALSE";
+}
+
+#define TRAP_CASE_STRING(name) case name: return #name
+#define TRAP_NODEFAULT default: assert(0)
+
+const char *TRP_PARAM (FxU32 mode)
+{
+ switch (mode) {
+ TRAP_CASE_STRING(GR_PARAM_DISABLE);
+ TRAP_CASE_STRING(GR_PARAM_ENABLE);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_VTX (FxU32 param)
+{
+ switch (param) {
+ TRAP_CASE_STRING(GR_PARAM_XY);
+ TRAP_CASE_STRING(GR_PARAM_Z);
+ TRAP_CASE_STRING(GR_PARAM_W);
+ TRAP_CASE_STRING(GR_PARAM_Q);
+ TRAP_CASE_STRING(GR_PARAM_FOG_EXT);
+ TRAP_CASE_STRING(GR_PARAM_A);
+ TRAP_CASE_STRING(GR_PARAM_RGB);
+ TRAP_CASE_STRING(GR_PARAM_PARGB);
+ TRAP_CASE_STRING(GR_PARAM_ST0);
+ TRAP_CASE_STRING(GR_PARAM_ST1);
+ TRAP_CASE_STRING(GR_PARAM_ST2);
+ TRAP_CASE_STRING(GR_PARAM_Q0);
+ TRAP_CASE_STRING(GR_PARAM_Q1);
+ TRAP_CASE_STRING(GR_PARAM_Q2);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_ARRAY (FxU32 mode)
+{
+ switch (mode) {
+ TRAP_CASE_STRING(GR_POINTS);
+ TRAP_CASE_STRING(GR_LINE_STRIP);
+ TRAP_CASE_STRING(GR_LINES);
+ TRAP_CASE_STRING(GR_POLYGON);
+ TRAP_CASE_STRING(GR_TRIANGLE_STRIP);
+ TRAP_CASE_STRING(GR_TRIANGLE_FAN);
+ TRAP_CASE_STRING(GR_TRIANGLES);
+ TRAP_CASE_STRING(GR_TRIANGLE_STRIP_CONTINUE);
+ TRAP_CASE_STRING(GR_TRIANGLE_FAN_CONTINUE);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_BUFFER (GrBuffer_t buffer)
+{
+ switch (buffer) {
+ TRAP_CASE_STRING(GR_BUFFER_FRONTBUFFER);
+ TRAP_CASE_STRING(GR_BUFFER_BACKBUFFER);
+ TRAP_CASE_STRING(GR_BUFFER_AUXBUFFER);
+ TRAP_CASE_STRING(GR_BUFFER_DEPTHBUFFER);
+ TRAP_CASE_STRING(GR_BUFFER_ALPHABUFFER);
+ TRAP_CASE_STRING(GR_BUFFER_TRIPLEBUFFER);
+ TRAP_CASE_STRING(GR_BUFFER_TEXTUREBUFFER_EXT);
+ TRAP_CASE_STRING(GR_BUFFER_TEXTUREAUXBUFFER_EXT);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_ORIGIN (GrOriginLocation_t origin_location)
+{
+ switch (origin_location) {
+ TRAP_CASE_STRING(GR_ORIGIN_UPPER_LEFT);
+ TRAP_CASE_STRING(GR_ORIGIN_LOWER_LEFT);
+ TRAP_CASE_STRING(GR_ORIGIN_ANY);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_REFRESH (GrScreenRefresh_t refresh_rate)
+{
+ switch (refresh_rate) {
+ TRAP_CASE_STRING(GR_REFRESH_60Hz);
+ TRAP_CASE_STRING(GR_REFRESH_70Hz);
+ TRAP_CASE_STRING(GR_REFRESH_72Hz);
+ TRAP_CASE_STRING(GR_REFRESH_75Hz);
+ TRAP_CASE_STRING(GR_REFRESH_80Hz);
+ TRAP_CASE_STRING(GR_REFRESH_90Hz);
+ TRAP_CASE_STRING(GR_REFRESH_100Hz);
+ TRAP_CASE_STRING(GR_REFRESH_85Hz);
+ TRAP_CASE_STRING(GR_REFRESH_120Hz);
+ TRAP_CASE_STRING(GR_REFRESH_NONE);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_COLFMT (GrColorFormat_t color_format)
+{
+ switch (color_format) {
+ TRAP_CASE_STRING(GR_COLORFORMAT_ARGB);
+ TRAP_CASE_STRING(GR_COLORFORMAT_ABGR);
+ TRAP_CASE_STRING(GR_COLORFORMAT_RGBA);
+ TRAP_CASE_STRING(GR_COLORFORMAT_BGRA);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_RESOLUTION (GrScreenResolution_t screen_resolution)
+{
+ switch (screen_resolution) {
+ TRAP_CASE_STRING(GR_RESOLUTION_320x200);
+ TRAP_CASE_STRING(GR_RESOLUTION_320x240);
+ TRAP_CASE_STRING(GR_RESOLUTION_400x256);
+ TRAP_CASE_STRING(GR_RESOLUTION_512x384);
+ TRAP_CASE_STRING(GR_RESOLUTION_640x200);
+ TRAP_CASE_STRING(GR_RESOLUTION_640x350);
+ TRAP_CASE_STRING(GR_RESOLUTION_640x400);
+ TRAP_CASE_STRING(GR_RESOLUTION_640x480);
+ TRAP_CASE_STRING(GR_RESOLUTION_800x600);
+ TRAP_CASE_STRING(GR_RESOLUTION_960x720);
+ TRAP_CASE_STRING(GR_RESOLUTION_856x480);
+ TRAP_CASE_STRING(GR_RESOLUTION_512x256);
+ TRAP_CASE_STRING(GR_RESOLUTION_1024x768);
+ TRAP_CASE_STRING(GR_RESOLUTION_1280x1024);
+ TRAP_CASE_STRING(GR_RESOLUTION_1600x1200);
+ TRAP_CASE_STRING(GR_RESOLUTION_400x300);
+ TRAP_CASE_STRING(GR_RESOLUTION_1152x864);
+ TRAP_CASE_STRING(GR_RESOLUTION_1280x960);
+ TRAP_CASE_STRING(GR_RESOLUTION_1600x1024);
+ TRAP_CASE_STRING(GR_RESOLUTION_1792x1344);
+ TRAP_CASE_STRING(GR_RESOLUTION_1856x1392);
+ TRAP_CASE_STRING(GR_RESOLUTION_1920x1440);
+ TRAP_CASE_STRING(GR_RESOLUTION_2048x1536);
+ TRAP_CASE_STRING(GR_RESOLUTION_2048x2048);
+ TRAP_CASE_STRING(GR_RESOLUTION_NONE);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_BLEND (GrAlphaBlendFnc_t func)
+{
+ switch (func) {
+ TRAP_CASE_STRING(GR_BLEND_ZERO);
+ TRAP_CASE_STRING(GR_BLEND_SRC_ALPHA);
+ TRAP_CASE_STRING(GR_BLEND_SRC_COLOR);
+ /*TRAP_CASE_STRING(GR_BLEND_DST_COLOR); ==GR_BLEND_SRC_COLOR*/
+ TRAP_CASE_STRING(GR_BLEND_DST_ALPHA);
+ TRAP_CASE_STRING(GR_BLEND_ONE);
+ TRAP_CASE_STRING(GR_BLEND_ONE_MINUS_SRC_ALPHA);
+ TRAP_CASE_STRING(GR_BLEND_ONE_MINUS_SRC_COLOR);
+ /*TRAP_CASE_STRING(GR_BLEND_ONE_MINUS_DST_COLOR); ==GR_BLEND_ONE_MINUS_SRC_COLOR*/
+ TRAP_CASE_STRING(GR_BLEND_ONE_MINUS_DST_ALPHA);
+ TRAP_CASE_STRING(GR_BLEND_SAME_COLOR_EXT);
+ /*TRAP_CASE_STRING(GR_BLEND_RESERVED_8); ==GR_BLEND_SAME_COLOR_EXT*/
+ TRAP_CASE_STRING(GR_BLEND_ONE_MINUS_SAME_COLOR_EXT);
+ /*TRAP_CASE_STRING(GR_BLEND_RESERVED_9); ==GR_BLEND_ONE_MINUS_SAME_COLOR_EXT*/
+ TRAP_CASE_STRING(GR_BLEND_RESERVED_A);
+ TRAP_CASE_STRING(GR_BLEND_RESERVED_B);
+ TRAP_CASE_STRING(GR_BLEND_RESERVED_C);
+ TRAP_CASE_STRING(GR_BLEND_RESERVED_D);
+ TRAP_CASE_STRING(GR_BLEND_RESERVED_E);
+ TRAP_CASE_STRING(GR_BLEND_ALPHA_SATURATE);
+ /*TRAP_CASE_STRING(GR_BLEND_PREFOG_COLOR); ==GR_BLEND_ALPHA_SATURATE*/
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_CMBFUNC (GrCombineFunction_t cfunc)
+{
+ switch (cfunc) {
+ TRAP_CASE_STRING(GR_COMBINE_FUNCTION_ZERO);
+ /*TRAP_CASE_STRING(GR_COMBINE_FUNCTION_NONE); ==GR_COMBINE_FUNCTION_ZERO*/
+ TRAP_CASE_STRING(GR_COMBINE_FUNCTION_LOCAL);
+ TRAP_CASE_STRING(GR_COMBINE_FUNCTION_LOCAL_ALPHA);
+ TRAP_CASE_STRING(GR_COMBINE_FUNCTION_SCALE_OTHER);
+ /*TRAP_CASE_STRING(GR_COMBINE_FUNCTION_BLEND_OTHER); ==GR_COMBINE_FUNCTION_SCALE_OTHER*/
+ TRAP_CASE_STRING(GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL);
+ TRAP_CASE_STRING(GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL_ALPHA);
+ TRAP_CASE_STRING(GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL);
+ TRAP_CASE_STRING(GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL);
+ /*TRAP_CASE_STRING(GR_COMBINE_FUNCTION_BLEND); ==GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL*/
+ TRAP_CASE_STRING(GR_COMBINE_FUNCTION_SCALE_OTHER_MINUS_LOCAL_ADD_LOCAL_ALPHA);
+ TRAP_CASE_STRING(GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL);
+ /*TRAP_CASE_STRING(GR_COMBINE_FUNCTION_BLEND_LOCAL); ==GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL*/
+ TRAP_CASE_STRING(GR_COMBINE_FUNCTION_SCALE_MINUS_LOCAL_ADD_LOCAL_ALPHA);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_CMBFACT (GrCombineFactor_t cfactor)
+{
+ switch (cfactor) {
+ TRAP_CASE_STRING(GR_COMBINE_FACTOR_ZERO);
+ /*TRAP_CASE_STRING(GR_COMBINE_FACTOR_NONE); ==GR_COMBINE_FACTOR_ZERO*/
+ TRAP_CASE_STRING(GR_COMBINE_FACTOR_LOCAL);
+ TRAP_CASE_STRING(GR_COMBINE_FACTOR_OTHER_ALPHA);
+ TRAP_CASE_STRING(GR_COMBINE_FACTOR_LOCAL_ALPHA);
+ TRAP_CASE_STRING(GR_COMBINE_FACTOR_TEXTURE_ALPHA);
+ TRAP_CASE_STRING(GR_COMBINE_FACTOR_TEXTURE_RGB);
+ /*TRAP_CASE_STRING(GR_COMBINE_FACTOR_DETAIL_FACTOR); ==GR_COMBINE_FACTOR_TEXTURE_ALPHA*/
+ /*TRAP_CASE_STRING(GR_COMBINE_FACTOR_LOD_FRACTION); ==GR_COMBINE_FACTOR_TEXTURE_RGB ???*/
+ TRAP_CASE_STRING(GR_COMBINE_FACTOR_ONE);
+ TRAP_CASE_STRING(GR_COMBINE_FACTOR_ONE_MINUS_LOCAL);
+ TRAP_CASE_STRING(GR_COMBINE_FACTOR_ONE_MINUS_OTHER_ALPHA);
+ TRAP_CASE_STRING(GR_COMBINE_FACTOR_ONE_MINUS_LOCAL_ALPHA);
+ TRAP_CASE_STRING(GR_COMBINE_FACTOR_ONE_MINUS_TEXTURE_ALPHA);
+ /*TRAP_CASE_STRING(GR_COMBINE_FACTOR_ONE_MINUS_DETAIL_FACTOR); ==GR_COMBINE_FACTOR_ONE_MINUS_TEXTURE_ALPHA*/
+ TRAP_CASE_STRING(GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_CMBLOCAL (GrCombineLocal_t clocal)
+{
+ switch (clocal) {
+ TRAP_CASE_STRING(GR_COMBINE_LOCAL_ITERATED);
+ TRAP_CASE_STRING(GR_COMBINE_LOCAL_CONSTANT);
+ /*TRAP_CASE_STRING(GR_COMBINE_LOCAL_NONE); ==GR_COMBINE_LOCAL_CONSTANT*/
+ TRAP_CASE_STRING(GR_COMBINE_LOCAL_DEPTH);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_CMBOTHER (GrCombineOther_t cother)
+{
+ switch (cother) {
+ TRAP_CASE_STRING(GR_COMBINE_OTHER_ITERATED);
+ TRAP_CASE_STRING(GR_COMBINE_OTHER_TEXTURE);
+ TRAP_CASE_STRING(GR_COMBINE_OTHER_CONSTANT);
+ /*TRAP_CASE_STRING(GR_COMBINE_OTHER_NONE); ==GR_COMBINE_OTHER_CONSTANT*/
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_CMPFUNC (GrCmpFnc_t function)
+{
+ switch (function) {
+ TRAP_CASE_STRING(GR_CMP_NEVER);
+ TRAP_CASE_STRING(GR_CMP_LESS);
+ TRAP_CASE_STRING(GR_CMP_EQUAL);
+ TRAP_CASE_STRING(GR_CMP_LEQUAL);
+ TRAP_CASE_STRING(GR_CMP_GREATER);
+ TRAP_CASE_STRING(GR_CMP_NOTEQUAL);
+ TRAP_CASE_STRING(GR_CMP_GEQUAL);
+ TRAP_CASE_STRING(GR_CMP_ALWAYS);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_CKMODE (GrChromakeyMode_t mode)
+{
+ switch (mode) {
+ TRAP_CASE_STRING(GR_CHROMAKEY_DISABLE);
+ TRAP_CASE_STRING(GR_CHROMAKEY_ENABLE);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_CULLMODE (GrCullMode_t mode)
+{
+ switch (mode) {
+ TRAP_CASE_STRING(GR_CULL_DISABLE);
+ TRAP_CASE_STRING(GR_CULL_NEGATIVE);
+ TRAP_CASE_STRING(GR_CULL_POSITIVE);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_DEPTHMODE (GrDepthBufferMode_t mode)
+{
+ switch (mode) {
+ TRAP_CASE_STRING(GR_DEPTHBUFFER_DISABLE);
+ TRAP_CASE_STRING(GR_DEPTHBUFFER_ZBUFFER);
+ TRAP_CASE_STRING(GR_DEPTHBUFFER_WBUFFER);
+ TRAP_CASE_STRING(GR_DEPTHBUFFER_ZBUFFER_COMPARE_TO_BIAS);
+ TRAP_CASE_STRING(GR_DEPTHBUFFER_WBUFFER_COMPARE_TO_BIAS);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_DITHERMODE (GrDitherMode_t mode)
+{
+ switch (mode) {
+ TRAP_CASE_STRING(GR_DITHER_DISABLE);
+ TRAP_CASE_STRING(GR_DITHER_2x2);
+ TRAP_CASE_STRING(GR_DITHER_4x4);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_FOGMODE (GrFogMode_t mode)
+{
+ switch (mode) {
+ TRAP_CASE_STRING(GR_FOG_DISABLE);
+ TRAP_CASE_STRING(GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT);
+ TRAP_CASE_STRING(GR_FOG_WITH_TABLE_ON_Q);
+ /*TRAP_CASE_STRING(GR_FOG_WITH_TABLE_ON_W); ==GR_FOG_WITH_TABLE_ON_Q*/
+ TRAP_CASE_STRING(GR_FOG_WITH_ITERATED_Z);
+ TRAP_CASE_STRING(GR_FOG_WITH_ITERATED_ALPHA_EXT);
+ TRAP_CASE_STRING(GR_FOG_MULT2);
+ TRAP_CASE_STRING(GR_FOG_ADD2);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_GETNAME (FxU32 pname)
+{
+ switch (pname) {
+ TRAP_CASE_STRING(GR_BITS_DEPTH);
+ TRAP_CASE_STRING(GR_BITS_RGBA);
+ TRAP_CASE_STRING(GR_FIFO_FULLNESS);
+ TRAP_CASE_STRING(GR_FOG_TABLE_ENTRIES);
+ TRAP_CASE_STRING(GR_GAMMA_TABLE_ENTRIES);
+ TRAP_CASE_STRING(GR_GLIDE_STATE_SIZE);
+ TRAP_CASE_STRING(GR_GLIDE_VERTEXLAYOUT_SIZE);
+ TRAP_CASE_STRING(GR_IS_BUSY);
+ TRAP_CASE_STRING(GR_LFB_PIXEL_PIPE);
+ TRAP_CASE_STRING(GR_MAX_TEXTURE_SIZE);
+ TRAP_CASE_STRING(GR_MAX_TEXTURE_ASPECT_RATIO);
+ TRAP_CASE_STRING(GR_MEMORY_FB);
+ TRAP_CASE_STRING(GR_MEMORY_TMU);
+ TRAP_CASE_STRING(GR_MEMORY_UMA);
+ TRAP_CASE_STRING(GR_NUM_BOARDS);
+ TRAP_CASE_STRING(GR_NON_POWER_OF_TWO_TEXTURES);
+ TRAP_CASE_STRING(GR_NUM_FB);
+ TRAP_CASE_STRING(GR_NUM_SWAP_HISTORY_BUFFER);
+ TRAP_CASE_STRING(GR_NUM_TMU);
+ TRAP_CASE_STRING(GR_PENDING_BUFFERSWAPS);
+ TRAP_CASE_STRING(GR_REVISION_FB);
+ TRAP_CASE_STRING(GR_REVISION_TMU);
+ TRAP_CASE_STRING(GR_STATS_LINES);
+ TRAP_CASE_STRING(GR_STATS_PIXELS_AFUNC_FAIL);
+ TRAP_CASE_STRING(GR_STATS_PIXELS_CHROMA_FAIL);
+ TRAP_CASE_STRING(GR_STATS_PIXELS_DEPTHFUNC_FAIL);
+ TRAP_CASE_STRING(GR_STATS_PIXELS_IN);
+ TRAP_CASE_STRING(GR_STATS_PIXELS_OUT);
+ TRAP_CASE_STRING(GR_STATS_PIXELS);
+ TRAP_CASE_STRING(GR_STATS_POINTS);
+ TRAP_CASE_STRING(GR_STATS_TRIANGLES_IN);
+ TRAP_CASE_STRING(GR_STATS_TRIANGLES_OUT);
+ TRAP_CASE_STRING(GR_STATS_TRIANGLES);
+ TRAP_CASE_STRING(GR_SWAP_HISTORY);
+ TRAP_CASE_STRING(GR_SUPPORTS_PASSTHRU);
+ TRAP_CASE_STRING(GR_TEXTURE_ALIGN);
+ TRAP_CASE_STRING(GR_VIDEO_POSITION);
+ TRAP_CASE_STRING(GR_VIEWPORT);
+ TRAP_CASE_STRING(GR_WDEPTH_MIN_MAX);
+ TRAP_CASE_STRING(GR_ZDEPTH_MIN_MAX);
+ TRAP_CASE_STRING(GR_VERTEX_PARAMETER);
+ TRAP_CASE_STRING(GR_BITS_GAMMA);
+ TRAP_CASE_STRING(GR_GET_RESERVED_1);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_GETSTRING (FxU32 pname)
+{
+ switch (pname) {
+ TRAP_CASE_STRING(GR_EXTENSION);
+ TRAP_CASE_STRING(GR_HARDWARE);
+ TRAP_CASE_STRING(GR_RENDERER);
+ TRAP_CASE_STRING(GR_VENDOR);
+ TRAP_CASE_STRING(GR_VERSION);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_ENABLE (GrEnableMode_t mode)
+{
+ switch (mode) {
+ TRAP_CASE_STRING(GR_AA_ORDERED);
+ TRAP_CASE_STRING(GR_ALLOW_MIPMAP_DITHER);
+ TRAP_CASE_STRING(GR_PASSTHRU);
+ TRAP_CASE_STRING(GR_SHAMELESS_PLUG);
+ TRAP_CASE_STRING(GR_VIDEO_SMOOTHING);
+ TRAP_CASE_STRING(GR_TEXTURE_UMA_EXT);
+ TRAP_CASE_STRING(GR_STENCIL_MODE_EXT);
+ TRAP_CASE_STRING(GR_OPENGL_MODE_EXT);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_COORD (GrCoordinateSpaceMode_t mode)
+{
+ switch (mode) {
+ TRAP_CASE_STRING(GR_WINDOW_COORDS);
+ TRAP_CASE_STRING(GR_CLIP_COORDS);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_STIPPLEMODE (GrStippleMode_t mode)
+{
+ switch (mode) {
+ TRAP_CASE_STRING(GR_STIPPLE_DISABLE);
+ TRAP_CASE_STRING(GR_STIPPLE_PATTERN);
+ TRAP_CASE_STRING(GR_STIPPLE_ROTATE);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_LODLEVEL (GrLOD_t lod)
+{
+ switch (lod) {
+ TRAP_CASE_STRING(GR_LOD_LOG2_2048);
+ TRAP_CASE_STRING(GR_LOD_LOG2_1024);
+ TRAP_CASE_STRING(GR_LOD_LOG2_512);
+ TRAP_CASE_STRING(GR_LOD_LOG2_256);
+ TRAP_CASE_STRING(GR_LOD_LOG2_128);
+ TRAP_CASE_STRING(GR_LOD_LOG2_64);
+ TRAP_CASE_STRING(GR_LOD_LOG2_32);
+ TRAP_CASE_STRING(GR_LOD_LOG2_16);
+ TRAP_CASE_STRING(GR_LOD_LOG2_8);
+ TRAP_CASE_STRING(GR_LOD_LOG2_4);
+ TRAP_CASE_STRING(GR_LOD_LOG2_2);
+ TRAP_CASE_STRING(GR_LOD_LOG2_1);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_ASPECTRATIO (GrAspectRatio_t aspect)
+{
+ switch (aspect) {
+ TRAP_CASE_STRING(GR_ASPECT_LOG2_8x1);
+ TRAP_CASE_STRING(GR_ASPECT_LOG2_4x1);
+ TRAP_CASE_STRING(GR_ASPECT_LOG2_2x1);
+ TRAP_CASE_STRING(GR_ASPECT_LOG2_1x1);
+ TRAP_CASE_STRING(GR_ASPECT_LOG2_1x2);
+ TRAP_CASE_STRING(GR_ASPECT_LOG2_1x4);
+ TRAP_CASE_STRING(GR_ASPECT_LOG2_1x8);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_TEXFMT (GrTextureFormat_t fmt)
+{
+ switch (fmt) {
+ TRAP_CASE_STRING(GR_TEXFMT_8BIT);
+ /*TRAP_CASE_STRING(GR_TEXFMT_RGB_332); ==GR_TEXFMT_8BIT*/
+ TRAP_CASE_STRING(GR_TEXFMT_YIQ_422);
+ TRAP_CASE_STRING(GR_TEXFMT_ALPHA_8);
+ TRAP_CASE_STRING(GR_TEXFMT_INTENSITY_8);
+ TRAP_CASE_STRING(GR_TEXFMT_ALPHA_INTENSITY_44);
+ TRAP_CASE_STRING(GR_TEXFMT_P_8);
+ TRAP_CASE_STRING(GR_TEXFMT_RSVD0);
+ /*TRAP_CASE_STRING(GR_TEXFMT_P_8_6666); ==GR_TEXFMT_RSVD0*/
+ /*TRAP_CASE_STRING(GR_TEXFMT_P_8_6666_EXT); ==GR_TEXFMT_RSVD0*/
+ TRAP_CASE_STRING(GR_TEXFMT_RSVD1);
+ TRAP_CASE_STRING(GR_TEXFMT_16BIT);
+ /*TRAP_CASE_STRING(GR_TEXFMT_ARGB_8332); ==GR_TEXFMT_16BIT*/
+ TRAP_CASE_STRING(GR_TEXFMT_AYIQ_8422);
+ TRAP_CASE_STRING(GR_TEXFMT_RGB_565);
+ TRAP_CASE_STRING(GR_TEXFMT_ARGB_1555);
+ TRAP_CASE_STRING(GR_TEXFMT_ARGB_4444);
+ TRAP_CASE_STRING(GR_TEXFMT_ALPHA_INTENSITY_88);
+ TRAP_CASE_STRING(GR_TEXFMT_AP_88);
+ TRAP_CASE_STRING(GR_TEXFMT_RSVD2);
+ /*TRAP_CASE_STRING(GR_TEXFMT_RSVD4); ==GR_TEXFMT_RSVD2*/
+ TRAP_CASE_STRING(GR_TEXFMT_ARGB_CMP_FXT1);
+ TRAP_CASE_STRING(GR_TEXFMT_ARGB_8888);
+ TRAP_CASE_STRING(GR_TEXFMT_YUYV_422);
+ TRAP_CASE_STRING(GR_TEXFMT_UYVY_422);
+ TRAP_CASE_STRING(GR_TEXFMT_AYUV_444);
+ TRAP_CASE_STRING(GR_TEXFMT_ARGB_CMP_DXT1);
+ TRAP_CASE_STRING(GR_TEXFMT_ARGB_CMP_DXT2);
+ TRAP_CASE_STRING(GR_TEXFMT_ARGB_CMP_DXT3);
+ TRAP_CASE_STRING(GR_TEXFMT_ARGB_CMP_DXT4);
+ TRAP_CASE_STRING(GR_TEXFMT_ARGB_CMP_DXT5);
+ TRAP_CASE_STRING(GR_TEXTFMT_RGB_888);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_EVENODD (FxU32 evenOdd)
+{
+ switch (evenOdd) {
+ TRAP_CASE_STRING(GR_MIPMAPLEVELMASK_EVEN);
+ TRAP_CASE_STRING(GR_MIPMAPLEVELMASK_ODD);
+ TRAP_CASE_STRING(GR_MIPMAPLEVELMASK_BOTH);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_NCC (GrNCCTable_t table)
+{
+ switch (table) {
+ TRAP_CASE_STRING(GR_NCCTABLE_NCC0);
+ TRAP_CASE_STRING(GR_NCCTABLE_NCC1);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_CLAMPMODE (GrTextureClampMode_t clampmode)
+{
+ switch (clampmode) {
+ TRAP_CASE_STRING(GR_TEXTURECLAMP_WRAP);
+ TRAP_CASE_STRING(GR_TEXTURECLAMP_CLAMP);
+ TRAP_CASE_STRING(GR_TEXTURECLAMP_MIRROR_EXT);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_TEXFILTER (GrTextureFilterMode_t filter_mode)
+{
+ switch (filter_mode) {
+ TRAP_CASE_STRING(GR_TEXTUREFILTER_POINT_SAMPLED);
+ TRAP_CASE_STRING(GR_TEXTUREFILTER_BILINEAR);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_TABLE (GrTexTable_t type)
+{
+ switch (type) {
+ TRAP_CASE_STRING(GR_TEXTABLE_NCC0);
+ TRAP_CASE_STRING(GR_TEXTABLE_NCC1);
+ TRAP_CASE_STRING(GR_TEXTABLE_PALETTE);
+ TRAP_CASE_STRING(GR_TEXTABLE_PALETTE_6666_EXT);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_MIPMODE (GrMipMapMode_t mode)
+{
+ switch (mode) {
+ TRAP_CASE_STRING(GR_MIPMAP_DISABLE);
+ TRAP_CASE_STRING(GR_MIPMAP_NEAREST);
+ TRAP_CASE_STRING(GR_MIPMAP_NEAREST_DITHER);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_TEXBASERANGE (GrTexBaseRange_t range)
+{
+ switch (range) {
+ TRAP_CASE_STRING(GR_TEXBASE_2048);
+ TRAP_CASE_STRING(GR_TEXBASE_1024);
+ TRAP_CASE_STRING(GR_TEXBASE_512);
+ TRAP_CASE_STRING(GR_TEXBASE_256_TO_1);
+ TRAP_CASE_STRING(GR_TEXBASE_256);
+ TRAP_CASE_STRING(GR_TEXBASE_128);
+ TRAP_CASE_STRING(GR_TEXBASE_64);
+ TRAP_CASE_STRING(GR_TEXBASE_32_TO_1);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_LOCKTYPE (GrLock_t type)
+{
+ switch (type) {
+ TRAP_CASE_STRING(GR_LFB_READ_ONLY);
+ TRAP_CASE_STRING(GR_LFB_WRITE_ONLY);
+ /*TRAP_CASE_STRING(GR_LFB_IDLE); ==GR_LFB_READ_ONLY*/
+ TRAP_CASE_STRING(GR_LFB_NOIDLE);
+ TRAP_CASE_STRING(GR_LFB_WRITE_ONLY_EXPLICIT_EXT);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_WRITEMODE (GrLfbWriteMode_t writeMode)
+{
+ switch (writeMode) {
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_565);
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_555);
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_1555);
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_RESERVED1);
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_888);
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_8888);
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_RESERVED2);
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_RESERVED3);
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_Z32);
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_RESERVED5);
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_RESERVED6);
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_RESERVED7);
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_565_DEPTH);
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_555_DEPTH);
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_1555_DEPTH);
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_ZA16);
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_ANY);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_SRCFMT (GrLfbSrcFmt_t src_format)
+{
+ switch (src_format) {
+ TRAP_CASE_STRING(GR_LFB_SRC_FMT_565);
+ TRAP_CASE_STRING(GR_LFB_SRC_FMT_555);
+ TRAP_CASE_STRING(GR_LFB_SRC_FMT_1555);
+ TRAP_CASE_STRING(GR_LFB_SRC_FMT_888);
+ TRAP_CASE_STRING(GR_LFB_SRC_FMT_8888);
+ TRAP_CASE_STRING(GR_LFB_SRC_FMT_565_DEPTH);
+ TRAP_CASE_STRING(GR_LFB_SRC_FMT_555_DEPTH);
+ TRAP_CASE_STRING(GR_LFB_SRC_FMT_1555_DEPTH);
+ TRAP_CASE_STRING(GR_LFB_SRC_FMT_ZA16);
+ TRAP_CASE_STRING(GR_LFB_SRC_FMT_RLE16);
+ TRAP_CASE_STRING(GR_LFBWRITEMODE_Z32); /*???*/
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_CRMODE (GrChromaRangeMode_t mode)
+{
+ switch (mode) {
+ TRAP_CASE_STRING(GR_CHROMARANGE_DISABLE_EXT);
+ /*TRAP_CASE_STRING(GR_CHROMARANGE_RGB_ALL_EXT); ==GR_CHROMARANGE_DISABLE_EXT*/
+ TRAP_CASE_STRING(GR_CHROMARANGE_ENABLE_EXT);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_PIXFMT (GrPixelFormat_t pixelformat)
+{
+ switch (pixelformat) {
+ TRAP_CASE_STRING(GR_PIXFMT_I_8);
+ TRAP_CASE_STRING(GR_PIXFMT_AI_88);
+ TRAP_CASE_STRING(GR_PIXFMT_RGB_565);
+ TRAP_CASE_STRING(GR_PIXFMT_ARGB_1555);
+ TRAP_CASE_STRING(GR_PIXFMT_ARGB_8888);
+ TRAP_CASE_STRING(GR_PIXFMT_AA_2_RGB_565);
+ TRAP_CASE_STRING(GR_PIXFMT_AA_2_ARGB_1555);
+ TRAP_CASE_STRING(GR_PIXFMT_AA_2_ARGB_8888);
+ TRAP_CASE_STRING(GR_PIXFMT_AA_4_RGB_565);
+ TRAP_CASE_STRING(GR_PIXFMT_AA_4_ARGB_1555);
+ TRAP_CASE_STRING(GR_PIXFMT_AA_4_ARGB_8888);
+ TRAP_CASE_STRING(GR_PIXFMT_AA_8_RGB_565);
+ TRAP_CASE_STRING(GR_PIXFMT_AA_8_ARGB_1555);
+ TRAP_CASE_STRING(GR_PIXFMT_AA_8_ARGB_8888);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_STENCILOP (GrStencilOp_t op)
+{
+ switch (op) {
+ TRAP_CASE_STRING(GR_STENCILOP_KEEP);
+ TRAP_CASE_STRING(GR_STENCILOP_ZERO);
+ TRAP_CASE_STRING(GR_STENCILOP_REPLACE);
+ TRAP_CASE_STRING(GR_STENCILOP_INCR_CLAMP);
+ TRAP_CASE_STRING(GR_STENCILOP_DECR_CLAMP);
+ TRAP_CASE_STRING(GR_STENCILOP_INVERT);
+ TRAP_CASE_STRING(GR_STENCILOP_INCR_WRAP);
+ TRAP_CASE_STRING(GR_STENCILOP_DECR_WRAP);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_BLENDOP (GrAlphaBlendOp_t op)
+{
+ switch (op) {
+ TRAP_CASE_STRING(GR_BLEND_OP_ADD);
+ TRAP_CASE_STRING(GR_BLEND_OP_SUB);
+ TRAP_CASE_STRING(GR_BLEND_OP_REVSUB);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_CU (GrCCUColor_t a)
+{
+ switch (a) {
+ TRAP_CASE_STRING(GR_CMBX_ZERO);
+ TRAP_CASE_STRING(GR_CMBX_TEXTURE_ALPHA);
+ TRAP_CASE_STRING(GR_CMBX_ALOCAL);
+ TRAP_CASE_STRING(GR_CMBX_AOTHER);
+ TRAP_CASE_STRING(GR_CMBX_B);
+ TRAP_CASE_STRING(GR_CMBX_CONSTANT_ALPHA);
+ TRAP_CASE_STRING(GR_CMBX_CONSTANT_COLOR);
+ TRAP_CASE_STRING(GR_CMBX_DETAIL_FACTOR);
+ TRAP_CASE_STRING(GR_CMBX_ITALPHA);
+ TRAP_CASE_STRING(GR_CMBX_ITRGB);
+ TRAP_CASE_STRING(GR_CMBX_LOCAL_TEXTURE_ALPHA);
+ TRAP_CASE_STRING(GR_CMBX_LOCAL_TEXTURE_RGB);
+ TRAP_CASE_STRING(GR_CMBX_LOD_FRAC);
+ TRAP_CASE_STRING(GR_CMBX_OTHER_TEXTURE_ALPHA);
+ TRAP_CASE_STRING(GR_CMBX_OTHER_TEXTURE_RGB);
+ TRAP_CASE_STRING(GR_CMBX_TEXTURE_RGB);
+ TRAP_CASE_STRING(GR_CMBX_TMU_CALPHA);
+ TRAP_CASE_STRING(GR_CMBX_TMU_CCOLOR);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_CMBMODE (GrCombineMode_t a_mode)
+{
+ switch (a_mode) {
+ TRAP_CASE_STRING(GR_FUNC_MODE_ZERO);
+ TRAP_CASE_STRING(GR_FUNC_MODE_X);
+ TRAP_CASE_STRING(GR_FUNC_MODE_ONE_MINUS_X);
+ TRAP_CASE_STRING(GR_FUNC_MODE_NEGATIVE_X);
+ TRAP_CASE_STRING(GR_FUNC_MODE_X_MINUS_HALF);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_TMU (GrChipID_t tmu)
+{
+ switch (tmu) {
+ TRAP_CASE_STRING(GR_TMU0);
+ TRAP_CASE_STRING(GR_TMU1);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_TXDITHER (FxU32 dither)
+{
+ switch (dither) {
+ TRAP_CASE_STRING(TX_DITHER_NONE);
+ TRAP_CASE_STRING(TX_DITHER_4x4);
+ TRAP_CASE_STRING(TX_DITHER_ERR);
+ TRAP_NODEFAULT;
+ }
+}
+
+const char *TRP_TXCOMPRESS (FxU32 compress)
+{
+ switch (compress) {
+ TRAP_CASE_STRING(TX_COMPRESSION_STATISTICAL);
+ TRAP_CASE_STRING(TX_COMPRESSION_HEURISTIC);
+ TRAP_NODEFAULT;
+ }
+}
+
+
+
+/****************************************************************************\
+* REAL POINTERS *
+\****************************************************************************/
+
+/*
+** glide extensions
+*/
+void (FX_CALL *real_grSetNumPendingBuffers) (FxI32 NumPendingBuffers);
+char * (FX_CALL *real_grGetRegistryOrEnvironmentStringExt) (char *theEntry);
+void (FX_CALL *real_grGetGammaTableExt) (FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue);
+void (FX_CALL *real_grChromaRangeModeExt) (GrChromakeyMode_t mode);
+void (FX_CALL *real_grChromaRangeExt) (GrColor_t color, GrColor_t range, GrChromaRangeMode_t match_mode);
+void (FX_CALL *real_grTexChromaModeExt) (GrChipID_t tmu, GrChromakeyMode_t mode);
+void (FX_CALL *real_grTexChromaRangeExt) (GrChipID_t tmu, GrColor_t min, GrColor_t max, GrTexChromakeyMode_t mode);
+
+/* pointcast */
+void (FX_CALL *real_grTexDownloadTableExt) (GrChipID_t tmu, GrTexTable_t type, void *data);
+void (FX_CALL *real_grTexDownloadTablePartialExt) (GrChipID_t tmu, GrTexTable_t type, void *data, int start, int end);
+void (FX_CALL *real_grTexNCCTableExt) (GrChipID_t tmu, GrNCCTable_t table);
+
+/* tbext */
+void (FX_CALL *real_grTextureBufferExt) (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLOD, GrLOD_t largeLOD, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 odd_even_mask);
+void (FX_CALL *real_grTextureAuxBufferExt) (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLOD, GrLOD_t largeLOD, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 odd_even_mask);
+void (FX_CALL *real_grAuxBufferExt) (GrBuffer_t buffer);
+
+/* napalm */
+GrContext_t (FX_CALL *real_grSstWinOpenExt) (FxU32 hWnd, GrScreenResolution_t resolution, GrScreenRefresh_t refresh, GrColorFormat_t format, GrOriginLocation_t origin, GrPixelFormat_t pixelformat, int nColBuffers, int nAuxBuffers);
+void (FX_CALL *real_grStencilFuncExt) (GrCmpFnc_t fnc, GrStencil_t ref, GrStencil_t mask);
+void (FX_CALL *real_grStencilMaskExt) (GrStencil_t value);
+void (FX_CALL *real_grStencilOpExt) (GrStencilOp_t stencil_fail, GrStencilOp_t depth_fail, GrStencilOp_t depth_pass);
+void (FX_CALL *real_grLfbConstantStencilExt) (GrStencil_t value);
+void (FX_CALL *real_grBufferClearExt) (GrColor_t color, GrAlpha_t alpha, FxU32 depth, GrStencil_t stencil);
+void (FX_CALL *real_grColorCombineExt) (GrCCUColor_t a, GrCombineMode_t a_mode, GrCCUColor_t b, GrCombineMode_t b_mode, GrCCUColor_t c, FxBool c_invert, GrCCUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert);
+void (FX_CALL *real_grAlphaCombineExt) (GrACUColor_t a, GrCombineMode_t a_mode, GrACUColor_t b, GrCombineMode_t b_mode, GrACUColor_t c, FxBool c_invert, GrACUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert);
+void (FX_CALL *real_grTexColorCombineExt) (GrChipID_t tmu, GrTCCUColor_t a, GrCombineMode_t a_mode, GrTCCUColor_t b, GrCombineMode_t b_mode, GrTCCUColor_t c, FxBool c_invert, GrTCCUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert);
+void (FX_CALL *real_grTexAlphaCombineExt) (GrChipID_t tmu, GrTACUColor_t a, GrCombineMode_t a_mode, GrTACUColor_t b, GrCombineMode_t b_mode, GrTACUColor_t c, FxBool c_invert, GrTACUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert);
+void (FX_CALL *real_grConstantColorValueExt) (GrChipID_t tmu, GrColor_t value);
+void (FX_CALL *real_grColorMaskExt) (FxBool r, FxBool g, FxBool b, FxBool a);
+void (FX_CALL *real_grAlphaBlendFunctionExt) (GrAlphaBlendFnc_t rgb_sf, GrAlphaBlendFnc_t rgb_df, GrAlphaBlendOp_t rgb_op, GrAlphaBlendFnc_t alpha_sf, GrAlphaBlendFnc_t alpha_df, GrAlphaBlendOp_t alpha_op);
+void (FX_CALL *real_grTBufferWriteMaskExt) (FxU32 tmask);
+
+/*
+** texus
+*/
+void (FX_CALL *real_txImgQuantize) (char *dst, char *src, int w, int h, FxU32 format, FxU32 dither);
+void (FX_CALL *real_txMipQuantize) (TxMip *pxMip, TxMip *txMip, int fmt, FxU32 d, FxU32 comp);
+void (FX_CALL *real_txPalToNcc) (GuNccTable *ncc_table, const FxU32 *pal);
+
+
+
+/****************************************************************************\
+* DEBUG HOOKS *
+\****************************************************************************/
+
+/*
+** rendering functions
+*/
+void FX_CALL trap_grDrawPoint (const void *pt)
+{
+#define FN_NAME "grDrawPoint"
+ TRAP_LOG("%s(%p)\n", FN_NAME, pt);
+ grDrawPoint(pt);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grDrawLine (const void *v1,
+ const void *v2)
+{
+#define FN_NAME "grDrawLine"
+ TRAP_LOG("%s(%p, %p)\n", FN_NAME, v1, v2);
+ grDrawLine(v1, v2);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grDrawTriangle (const void *a,
+ const void *b,
+ const void *c)
+{
+#define FN_NAME "grDrawTriangle"
+ TRAP_LOG("%s(%p, %p, %p)\n", FN_NAME, a, b, c);
+ grDrawTriangle(a, b, c);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grVertexLayout (FxU32 param,
+ FxI32 offset,
+ FxU32 mode)
+{
+#define FN_NAME "grVertexLayout"
+ TRAP_LOG("%s(%s, %ld, %s)\n", FN_NAME, TRP_VTX(param), offset, TRP_PARAM(mode));
+ grVertexLayout(param, offset, mode);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grDrawVertexArray (FxU32 mode,
+ FxU32 Count,
+ void *pointers)
+{
+#define FN_NAME "grDrawVertexArray"
+ TRAP_LOG("%s(%s, %lu, %p)\n", FN_NAME, TRP_ARRAY(mode), Count, pointers);
+ grDrawVertexArray(mode, Count, pointers);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grDrawVertexArrayContiguous (FxU32 mode,
+ FxU32 Count,
+ void *pointers,
+ FxU32 stride)
+{
+#define FN_NAME "grDrawVertexArrayContiguous"
+ TRAP_LOG("%s(%s, %lu, %p, %lu)\n", FN_NAME, TRP_ARRAY(mode), Count, pointers, stride);
+ grDrawVertexArrayContiguous(mode, Count, pointers, stride);
+#undef FN_NAME
+}
+
+/*
+** Antialiasing Functions
+*/
+void FX_CALL trap_grAADrawTriangle (const void *a,
+ const void *b,
+ const void *c,
+ FxBool ab_antialias,
+ FxBool bc_antialias,
+ FxBool ca_antialias)
+{
+#define FN_NAME "grAADrawTriangle"
+ TRAP_LOG("%s(%p, %p, %p, %s, %s, %s)\n", FN_NAME, a, b, c, TRP_BOOL(ab_antialias), TRP_BOOL(bc_antialias), TRP_BOOL(ca_antialias));
+ grAADrawTriangle(a, b, c, ab_antialias, bc_antialias, ca_antialias);
+#undef FN_NAME
+}
+
+/*
+** buffer management
+*/
+void FX_CALL trap_grBufferClear (GrColor_t color,
+ GrAlpha_t alpha,
+ FxU32 depth)
+{
+#define FN_NAME "grBufferClear"
+ TRAP_LOG("%s(%08lx, %02x, %08lx)\n", FN_NAME, color, alpha, depth);
+ grBufferClear(color, alpha, depth);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grBufferSwap (FxU32 swap_interval)
+{
+#define FN_NAME "grBufferSwap"
+ TRAP_LOG("%s(%lu)\n", FN_NAME, swap_interval);
+ grBufferSwap(swap_interval);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grRenderBuffer (GrBuffer_t buffer)
+{
+#define FN_NAME "grRenderBuffer"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_BUFFER(buffer));
+ grRenderBuffer(buffer);
+#undef FN_NAME
+}
+
+/*
+** error management
+*/
+void FX_CALL trap_grErrorSetCallback (GrErrorCallbackFnc_t fnc)
+{
+#define FN_NAME "grErrorSetCallback"
+ TRAP_LOG("%s(%p)\n", FN_NAME, (void *)fnc);
+ grErrorSetCallback(fnc);
+#undef FN_NAME
+}
+
+/*
+** SST routines
+*/
+void FX_CALL trap_grFinish (void)
+{
+#define FN_NAME "grFinish"
+ TRAP_LOG("%s()\n", FN_NAME);
+ grFinish();
+#undef FN_NAME
+}
+
+void FX_CALL trap_grFlush (void)
+{
+#define FN_NAME "grFlush"
+ TRAP_LOG("%s()\n", FN_NAME);
+ grFlush();
+#undef FN_NAME
+}
+
+GrContext_t FX_CALL trap_grSstWinOpen (FxU32 hWnd,
+ GrScreenResolution_t screen_resolution,
+ GrScreenRefresh_t refresh_rate,
+ GrColorFormat_t color_format,
+ GrOriginLocation_t origin_location,
+ int nColBuffers,
+ int nAuxBuffers)
+{
+#define FN_NAME "grSstWinOpen"
+ GrContext_t rv;
+ TRAP_LOG("%s(%08lx, %s, %s, %s, %s, %d, %d)\n", FN_NAME, hWnd, TRP_RESOLUTION(screen_resolution), TRP_REFRESH(refresh_rate), TRP_COLFMT(color_format), TRP_ORIGIN(origin_location), nColBuffers, nAuxBuffers);
+ rv = grSstWinOpen(hWnd, screen_resolution, refresh_rate, color_format, origin_location, nColBuffers, nAuxBuffers);
+ TRAP_LOG(GOT "%p\n", (void *)rv);
+ return rv;
+#undef FN_NAME
+}
+
+FxBool FX_CALL trap_grSstWinClose (GrContext_t context)
+{
+#define FN_NAME "grSstWinClose"
+ FxBool rv;
+ TRAP_LOG("%s(%p)\n", FN_NAME, (void *)context);
+ rv = grSstWinClose(context);
+ TRAP_LOG(GOT "%s\n", TRP_BOOL(rv));
+ return rv;
+#undef FN_NAME
+}
+
+FxBool FX_CALL trap_grSelectContext (GrContext_t context)
+{
+#define FN_NAME "grSelectContext"
+ FxBool rv;
+ TRAP_LOG("%s(%p)\n", FN_NAME, (void *)context);
+ rv = grSelectContext(context);
+ TRAP_LOG(GOT "%s\n", TRP_BOOL(rv));
+ return rv;
+#undef FN_NAME
+}
+
+void FX_CALL trap_grSstOrigin (GrOriginLocation_t origin)
+{
+#define FN_NAME "grSstOrigin"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_ORIGIN(origin));
+ grSstOrigin(origin);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grSstSelect (int which_sst)
+{
+#define FN_NAME "grSstSelect"
+ TRAP_LOG("%s(%d)\n", FN_NAME, which_sst);
+ grSstSelect(which_sst);
+#undef FN_NAME
+}
+
+/*
+** Glide configuration and special effect maintenance functions
+*/
+void FX_CALL trap_grAlphaBlendFunction (GrAlphaBlendFnc_t rgb_sf,
+ GrAlphaBlendFnc_t rgb_df,
+ GrAlphaBlendFnc_t alpha_sf,
+ GrAlphaBlendFnc_t alpha_df)
+{
+#define FN_NAME "grAlphaBlendFunction"
+ TRAP_LOG("%s(%s, %s, %s, %s)\n", FN_NAME, TRP_BLEND(rgb_sf), TRP_BLEND(rgb_df), TRP_BLEND(alpha_sf), TRP_BLEND(alpha_df));
+ grAlphaBlendFunction(rgb_sf, rgb_df, alpha_sf, alpha_df);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grAlphaCombine (GrCombineFunction_t function,
+ GrCombineFactor_t factor,
+ GrCombineLocal_t local,
+ GrCombineOther_t other,
+ FxBool invert)
+{
+#define FN_NAME "grAlphaCombine"
+ TRAP_LOG("%s(%s, %s, %s, %s, %s)\n", FN_NAME, TRP_CMBFUNC(function), TRP_CMBFACT(factor), TRP_CMBLOCAL(local), TRP_CMBOTHER(other), TRP_BOOL(invert));
+ grAlphaCombine(function, factor, local, other, invert);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grAlphaControlsITRGBLighting (FxBool enable)
+{
+#define FN_NAME "grAlphaControlsITRGBLighting"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_BOOL(enable));
+ grAlphaControlsITRGBLighting(enable);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grAlphaTestFunction (GrCmpFnc_t function)
+{
+#define FN_NAME "grAlphaTestFunction"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_CMPFUNC(function));
+ grAlphaTestFunction(function);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grAlphaTestReferenceValue (GrAlpha_t value)
+{
+#define FN_NAME "grAlphaTestReferenceValue"
+ TRAP_LOG("%s(%02x)\n", FN_NAME, value);
+ grAlphaTestReferenceValue(value);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grChromakeyMode (GrChromakeyMode_t mode)
+{
+#define FN_NAME "grChromakeyMode"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_CKMODE(mode));
+ grChromakeyMode(mode);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grChromakeyValue (GrColor_t value)
+{
+#define FN_NAME "grChromakeyValue"
+ TRAP_LOG("%s(%08lx)\n", FN_NAME, value);
+ grChromakeyValue(value);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grClipWindow (FxU32 minx,
+ FxU32 miny,
+ FxU32 maxx,
+ FxU32 maxy)
+{
+#define FN_NAME "grClipWindow"
+ TRAP_LOG("%s(%lu, %lu, %lu, %lu)\n", FN_NAME, minx, miny, maxx, maxy);
+ grClipWindow(minx, miny, maxx, maxy);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grColorCombine (GrCombineFunction_t function,
+ GrCombineFactor_t factor,
+ GrCombineLocal_t local,
+ GrCombineOther_t other,
+ FxBool invert)
+{
+#define FN_NAME "grColorCombine"
+ TRAP_LOG("%s(%s, %s, %s, %s, %s)\n", FN_NAME, TRP_CMBFUNC(function), TRP_CMBFACT(factor), TRP_CMBLOCAL(local), TRP_CMBOTHER(other), TRP_BOOL(invert));
+ grColorCombine(function, factor, local, other, invert);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grColorMask (FxBool rgb,
+ FxBool a)
+{
+#define FN_NAME "grColorMask"
+ TRAP_LOG("%s(%s, %s)\n", FN_NAME, TRP_BOOL(rgb), TRP_BOOL(a));
+ grColorMask(rgb, a);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grCullMode (GrCullMode_t mode)
+{
+#define FN_NAME "grCullMode"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_CULLMODE(mode));
+ grCullMode(mode);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grConstantColorValue (GrColor_t value)
+{
+#define FN_NAME "grConstantColorValue"
+ TRAP_LOG("%s(%08lx)\n", FN_NAME, value);
+ grConstantColorValue(value);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grDepthBiasLevel (FxI32 level)
+{
+#define FN_NAME "grDepthBiasLevel"
+ TRAP_LOG("%s(%ld)\n", FN_NAME, level);
+ grDepthBiasLevel(level);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grDepthBufferFunction (GrCmpFnc_t function)
+{
+#define FN_NAME "grDepthBufferFunction"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_CMPFUNC(function));
+ grDepthBufferFunction(function);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grDepthBufferMode (GrDepthBufferMode_t mode)
+{
+#define FN_NAME "grDepthBufferMode"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_DEPTHMODE(mode));
+ grDepthBufferMode(mode);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grDepthMask (FxBool mask)
+{
+#define FN_NAME "grDepthMask"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_BOOL(mask));
+ grDepthMask(mask);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grDisableAllEffects (void)
+{
+#define FN_NAME "grDisableAllEffects"
+ TRAP_LOG("%s()\n", FN_NAME);
+ grDisableAllEffects();
+#undef FN_NAME
+}
+
+void FX_CALL trap_grDitherMode (GrDitherMode_t mode)
+{
+#define FN_NAME "grDitherMode"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_DITHERMODE(mode));
+ grDitherMode(mode);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grFogColorValue (GrColor_t fogcolor)
+{
+#define FN_NAME "grFogColorValue"
+ TRAP_LOG("%s(%08lx)\n", FN_NAME, fogcolor);
+ grFogColorValue(fogcolor);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grFogMode (GrFogMode_t mode)
+{
+#define FN_NAME "grFogMode"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_FOGMODE(mode));
+ grFogMode(mode);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grFogTable (const GrFog_t ft[])
+{
+#define FN_NAME "grFogTable"
+ TRAP_LOG("%s(%p)\n", FN_NAME, ft);
+ grFogTable(ft);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grLoadGammaTable (FxU32 nentries,
+ FxU32 *red,
+ FxU32 *green,
+ FxU32 *blue)
+{
+#define FN_NAME "grLoadGammaTable"
+ TRAP_LOG("%s(%lu, %p, %p, %p)\n", FN_NAME, nentries, (void *)red, (void *)green, (void *)blue);
+ grLoadGammaTable(nentries, red, green, blue);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grSplash (float x,
+ float y,
+ float width,
+ float height,
+ FxU32 frame)
+{
+#define FN_NAME "grSplash"
+ TRAP_LOG("%s(%f, %f, %f, %f, %lu)\n", FN_NAME, x, y, width, height, frame);
+ grSplash(x, y, width, height, frame);
+#undef FN_NAME
+}
+
+FxU32 FX_CALL trap_grGet (FxU32 pname,
+ FxU32 plength,
+ FxI32 *params)
+{
+#define FN_NAME "grGet"
+ FxU32 rv, i;
+ TRAP_LOG("%s(%s, %lu, %p)\n", FN_NAME, TRP_GETNAME(pname), plength, (void *)params);
+ rv = grGet(pname, plength, params);
+ TRAP_LOG(GOT "[");
+ for (i = 0; i < (rv/sizeof(FxI32)); i++) {
+ TRAP_LOG("%s%ld", i ? ", " : "", params[i]);
+ }
+ TRAP_LOG("]\n");
+ return rv;
+#undef FN_NAME
+}
+
+const char *FX_CALL trap_grGetString (FxU32 pname)
+{
+#define FN_NAME "grGetString"
+ const char *rv;
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_GETSTRING(pname));
+ rv = grGetString(pname);
+ if (rv) {
+ TRAP_LOG(GOT "\"%s\"\n", rv);
+ } else {
+ TRAP_LOG(GOT "NULL\n");
+ }
+ return rv;
+#undef FN_NAME
+}
+
+FxI32 FX_CALL trap_grQueryResolutions (const GrResolution *resTemplate,
+ GrResolution *output)
+{
+#define FN_NAME "grQueryResolutions"
+ FxI32 rv;
+ TRAP_LOG("%s(%p, %p)\n", FN_NAME, (void *)resTemplate, (void *)output);
+ rv = grQueryResolutions(resTemplate, output);
+ TRAP_LOG(GOT "%ld\n", rv);
+ return rv;
+#undef FN_NAME
+}
+
+FxBool FX_CALL trap_grReset (FxU32 what)
+{
+#define FN_NAME "grReset"
+ FxBool rv;
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_GETNAME(what));
+ rv = grReset(what);
+ TRAP_LOG(GOT "%s\n", TRP_BOOL(rv));
+ return rv;
+#undef FN_NAME
+}
+
+GrProc FX_CALL trap_grGetProcAddress (char *procName)
+{
+#define FN_NAME "grGetProcAddress"
+ GrProc rv;
+ TRAP_LOG("%s(%s)\n", FN_NAME, procName);
+ rv = grGetProcAddress(procName);
+ TRAP_LOG(GOT "%p\n", (void *)rv);
+ return rv;
+#undef FN_NAME
+}
+
+void FX_CALL trap_grEnable (GrEnableMode_t mode)
+{
+#define FN_NAME "grEnable"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_ENABLE(mode));
+ grEnable(mode);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grDisable (GrEnableMode_t mode)
+{
+#define FN_NAME "grDisable"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_ENABLE(mode));
+ grDisable(mode);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grCoordinateSpace (GrCoordinateSpaceMode_t mode)
+{
+#define FN_NAME "grCoordinateSpace"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_COORD(mode));
+ grCoordinateSpace(mode);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grDepthRange (FxFloat n,
+ FxFloat f)
+{
+#define FN_NAME "grDepthRange"
+ TRAP_LOG("%s(%f, %f)\n", FN_NAME, n, f);
+ grDepthRange(n, f);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grStippleMode (GrStippleMode_t mode)
+{
+#define FN_NAME "grStippleMode"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_STIPPLEMODE(mode));
+ grStippleMode(mode); /* some Glide libs don't have it; not used anyway */
+#undef FN_NAME
+}
+
+void FX_CALL trap_grStipplePattern (GrStipplePattern_t mode)
+{
+#define FN_NAME "grStipplePattern"
+ TRAP_LOG("%s(%08lx)\n", FN_NAME, mode);
+ grStipplePattern(mode); /* some Glide libs don't have it; not used anyway */
+#undef FN_NAME
+}
+
+void FX_CALL trap_grViewport (FxI32 x,
+ FxI32 y,
+ FxI32 width,
+ FxI32 height)
+{
+#define FN_NAME "grViewport"
+ TRAP_LOG("%s(%ld, %ld, %ld, %ld)\n", FN_NAME, x, y, width, height);
+ grViewport(x, y, width, height);
+#undef FN_NAME
+}
+
+/*
+** texture mapping control functions
+*/
+FxU32 FX_CALL trap_grTexCalcMemRequired (GrLOD_t lodmin,
+ GrLOD_t lodmax,
+ GrAspectRatio_t aspect,
+ GrTextureFormat_t fmt)
+{
+#define FN_NAME "grTexCalcMemRequired"
+ FxU32 rv;
+ TRAP_LOG("%s(%s, %s, %s, %s)\n", FN_NAME, TRP_LODLEVEL(lodmin), TRP_LODLEVEL(lodmax), TRP_ASPECTRATIO(aspect), TRP_TEXFMT(fmt));
+ rv = grTexCalcMemRequired(lodmin, lodmax, aspect, fmt);
+ TRAP_LOG(GOT "%lu\n", rv);
+ return rv;
+#undef FN_NAME
+}
+
+FxU32 FX_CALL trap_grTexTextureMemRequired (FxU32 evenOdd,
+ GrTexInfo *info)
+{
+#define FN_NAME "grTexTextureMemRequired"
+ FxU32 rv;
+ TRAP_LOG("%s(%s, %p)\n", FN_NAME, TRP_EVENODD(evenOdd), (void *)info);
+ rv = grTexTextureMemRequired(evenOdd, info);
+ TRAP_LOG(GOT "%lu\n", rv);
+ return rv;
+#undef FN_NAME
+}
+
+FxU32 FX_CALL trap_grTexMinAddress (GrChipID_t tmu)
+{
+#define FN_NAME "grTexMinAddress"
+ FxU32 rv;
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_TMU(tmu));
+ rv = grTexMinAddress(tmu);
+ TRAP_LOG(GOT "%lu\n", rv);
+ return rv;
+#undef FN_NAME
+}
+
+FxU32 FX_CALL trap_grTexMaxAddress (GrChipID_t tmu)
+{
+#define FN_NAME "grTexMaxAddress"
+ FxU32 rv;
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_TMU(tmu));
+ rv = grTexMaxAddress(tmu);
+ TRAP_LOG(GOT "%lu\n", rv);
+ return rv;
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexNCCTable (GrNCCTable_t table)
+{
+#define FN_NAME "grTexNCCTable"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_NCC(table));
+ grTexNCCTable(table);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexSource (GrChipID_t tmu,
+ FxU32 startAddress,
+ FxU32 evenOdd,
+ GrTexInfo *info)
+{
+#define FN_NAME "grTexSource"
+ TRAP_LOG("%s(%s, %08lx, %s, %p)\n", FN_NAME, TRP_TMU(tmu), startAddress, TRP_EVENODD(evenOdd), (void *)info);
+ grTexSource(tmu, startAddress, evenOdd, info);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexClampMode (GrChipID_t tmu,
+ GrTextureClampMode_t s_clampmode,
+ GrTextureClampMode_t t_clampmode)
+{
+#define FN_NAME "grTexClampMode"
+ TRAP_LOG("%s(%s, %s, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_CLAMPMODE(s_clampmode), TRP_CLAMPMODE(t_clampmode));
+ grTexClampMode(tmu, s_clampmode, t_clampmode);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexCombine (GrChipID_t tmu,
+ GrCombineFunction_t rgb_function,
+ GrCombineFactor_t rgb_factor,
+ GrCombineFunction_t alpha_function,
+ GrCombineFactor_t alpha_factor,
+ FxBool rgb_invert,
+ FxBool alpha_invert)
+{
+#define FN_NAME "grTexCombine"
+ TRAP_LOG("%s(%s, %s, %s, %s, %s, %s, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_CMBFUNC(rgb_function), TRP_CMBFACT(rgb_factor), TRP_CMBFUNC(alpha_function), TRP_CMBFACT(alpha_factor), TRP_BOOL(rgb_invert), TRP_BOOL(alpha_invert));
+ grTexCombine(tmu, rgb_function, rgb_factor, alpha_function, alpha_factor, rgb_invert, alpha_invert);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexDetailControl (GrChipID_t tmu,
+ int lod_bias,
+ FxU8 detail_scale,
+ float detail_max)
+{
+#define FN_NAME "grTexDetailControl"
+ TRAP_LOG("%s(%s, %u, %d, %f)\n", FN_NAME, TRP_TMU(tmu), lod_bias, detail_scale, detail_max);
+ grTexDetailControl(tmu, lod_bias, detail_scale, detail_max);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexFilterMode (GrChipID_t tmu,
+ GrTextureFilterMode_t minfilter_mode,
+ GrTextureFilterMode_t magfilter_mode)
+{
+#define FN_NAME "grTexFilterMode"
+ TRAP_LOG("%s(%s, %s, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_TEXFILTER(minfilter_mode), TRP_TEXFILTER(magfilter_mode));
+ grTexFilterMode(tmu, minfilter_mode, magfilter_mode);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexLodBiasValue (GrChipID_t tmu,
+ float bias)
+{
+#define FN_NAME "grTexLodBiasValue"
+ TRAP_LOG("%s(%s, %f)\n", FN_NAME, TRP_TMU(tmu), bias);
+ grTexLodBiasValue(tmu, bias);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexDownloadMipMap (GrChipID_t tmu,
+ FxU32 startAddress,
+ FxU32 evenOdd,
+ GrTexInfo *info)
+{
+#define FN_NAME "grTexDownloadMipMap"
+ TRAP_LOG("%s(%s, %08lx, %s, %p)\n", FN_NAME, TRP_TMU(tmu), startAddress, TRP_EVENODD(evenOdd), (void *)info);
+ grTexDownloadMipMap(tmu, startAddress, evenOdd, info);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexDownloadMipMapLevel (GrChipID_t tmu,
+ FxU32 startAddress,
+ GrLOD_t thisLod,
+ GrLOD_t largeLod,
+ GrAspectRatio_t aspectRatio,
+ GrTextureFormat_t format,
+ FxU32 evenOdd,
+ void *data)
+{
+#define FN_NAME "grTexDownloadMipMapLevel"
+ TRAP_LOG("%s(%s, %08lx, %s, %s, %s, %s, %s, %p)\n", FN_NAME, TRP_TMU(tmu), startAddress, TRP_LODLEVEL(thisLod), TRP_LODLEVEL(largeLod), TRP_ASPECTRATIO(aspectRatio), TRP_TEXFMT(format), TRP_EVENODD(evenOdd), data);
+ grTexDownloadMipMapLevel(tmu, startAddress, thisLod, largeLod, aspectRatio, format, evenOdd, data);
+#undef FN_NAME
+}
+
+FxBool FX_CALL trap_grTexDownloadMipMapLevelPartial (GrChipID_t tmu,
+ FxU32 startAddress,
+ GrLOD_t thisLod,
+ GrLOD_t largeLod,
+ GrAspectRatio_t aspectRatio,
+ GrTextureFormat_t format,
+ FxU32 evenOdd,
+ void *data,
+ int start,
+ int end)
+{
+#define FN_NAME "grTexDownloadMipMapLevelPartial"
+ FxBool rv;
+ TRAP_LOG("%s(%s, %08lx, %s, %s, %s, %s, %s, %p, %d, %d)\n", FN_NAME, TRP_TMU(tmu), startAddress, TRP_LODLEVEL(thisLod), TRP_LODLEVEL(largeLod), TRP_ASPECTRATIO(aspectRatio), TRP_TEXFMT(format), TRP_EVENODD(evenOdd), data, start, end);
+ rv = grTexDownloadMipMapLevelPartial(tmu, startAddress, thisLod, largeLod, aspectRatio, format, evenOdd, data, start, end);
+ TRAP_LOG(GOT "%s\n", TRP_BOOL(rv));
+ return rv;
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexDownloadTable (GrTexTable_t type,
+ void *data)
+{
+#define FN_NAME "grTexDownloadTable"
+ TRAP_LOG("%s(%s, %p)\n", FN_NAME, TRP_TABLE(type), data);
+ grTexDownloadTable(type, data);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexDownloadTablePartial (GrTexTable_t type,
+ void *data,
+ int start,
+ int end)
+{
+#define FN_NAME "grTexDownloadTablePartial"
+ TRAP_LOG("%s(%s, %p, %d, %d)\n", FN_NAME, TRP_TABLE(type), data, start, end);
+ grTexDownloadTablePartial(type, data, start, end);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexMipMapMode (GrChipID_t tmu,
+ GrMipMapMode_t mode,
+ FxBool lodBlend)
+{
+#define FN_NAME "grTexMipMapMode"
+ TRAP_LOG("%s(%s, %s, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_MIPMODE(mode), TRP_BOOL(lodBlend));
+ grTexMipMapMode(tmu, mode, lodBlend);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexMultibase (GrChipID_t tmu,
+ FxBool enable)
+{
+#define FN_NAME "grTexMultibase"
+ TRAP_LOG("%s(%s, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_BOOL(enable));
+ grTexMultibase(tmu, enable);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexMultibaseAddress (GrChipID_t tmu,
+ GrTexBaseRange_t range,
+ FxU32 startAddress,
+ FxU32 evenOdd,
+ GrTexInfo *info)
+{
+#define FN_NAME "grTexMultibaseAddress"
+ TRAP_LOG("%s(%s, %s, %08lx, %s, %p)\n", FN_NAME, TRP_TMU(tmu), TRP_TEXBASERANGE(range), startAddress, TRP_EVENODD(evenOdd), (void *)info);
+ grTexMultibaseAddress(tmu, range, startAddress, evenOdd, info);
+#undef FN_NAME
+}
+
+/*
+** linear frame buffer functions
+*/
+FxBool FX_CALL trap_grLfbLock (GrLock_t type,
+ GrBuffer_t buffer,
+ GrLfbWriteMode_t writeMode,
+ GrOriginLocation_t origin,
+ FxBool pixelPipeline,
+ GrLfbInfo_t *info)
+{
+#define FN_NAME "grLfbLock"
+ FxBool rv;
+ TRAP_LOG("%s(%s, %s, %s, %s, %s, %p)\n", FN_NAME, TRP_LOCKTYPE(type), TRP_BUFFER(buffer), TRP_WRITEMODE(writeMode), TRP_ORIGIN(origin), TRP_BOOL(pixelPipeline), (void *)info);
+ rv = grLfbLock(type, buffer, writeMode, origin, pixelPipeline, info);
+ TRAP_LOG(GOT "%s\n", TRP_BOOL(rv));
+ return rv;
+#undef FN_NAME
+}
+
+FxBool FX_CALL trap_grLfbUnlock (GrLock_t type,
+ GrBuffer_t buffer)
+{
+#define FN_NAME "grLfbUnlock"
+ FxBool rv;
+ TRAP_LOG("%s(%s, %s)\n", FN_NAME, TRP_LOCKTYPE(type), TRP_BUFFER(buffer));
+ rv = grLfbUnlock(type, buffer);
+ TRAP_LOG(GOT "%s\n", TRP_BOOL(rv));
+ return rv;
+#undef FN_NAME
+}
+
+void FX_CALL trap_grLfbConstantAlpha (GrAlpha_t alpha)
+{
+#define FN_NAME "grLfbConstantAlpha"
+ TRAP_LOG("%s(%02x)\n", FN_NAME, alpha);
+ grLfbConstantAlpha(alpha);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grLfbConstantDepth (FxU32 depth)
+{
+#define FN_NAME "grLfbConstantDepth"
+ TRAP_LOG("%s(%08lx)\n", FN_NAME, depth);
+ grLfbConstantDepth(depth);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grLfbWriteColorSwizzle (FxBool swizzleBytes,
+ FxBool swapWords)
+{
+#define FN_NAME "grLfbWriteColorSwizzle"
+ TRAP_LOG("%s(%s, %s)\n", FN_NAME, TRP_BOOL(swizzleBytes), TRP_BOOL(swapWords));
+ grLfbWriteColorSwizzle(swizzleBytes, swapWords);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grLfbWriteColorFormat (GrColorFormat_t colorFormat)
+{
+#define FN_NAME "grLfbWriteColorFormat"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_COLFMT(colorFormat));
+ grLfbWriteColorFormat(colorFormat);
+#undef FN_NAME
+}
+
+FxBool FX_CALL trap_grLfbWriteRegion (GrBuffer_t dst_buffer,
+ FxU32 dst_x,
+ FxU32 dst_y,
+ GrLfbSrcFmt_t src_format,
+ FxU32 src_width,
+ FxU32 src_height,
+ FxBool pixelPipeline,
+ FxI32 src_stride,
+ void *src_data)
+{
+#define FN_NAME "grLfbWriteRegion"
+ FxBool rv;
+ TRAP_LOG("%s(%s, %lu, %lu, %s, %lu, %lu, %s, %ld, %p)\n", FN_NAME, TRP_BUFFER(dst_buffer), dst_x, dst_y, TRP_SRCFMT(src_format), src_width, src_height, TRP_BOOL(pixelPipeline), src_stride, src_data);
+ rv = grLfbWriteRegion(dst_buffer, dst_x, dst_y, src_format, src_width, src_height, pixelPipeline, src_stride, src_data);
+ TRAP_LOG(GOT "%s\n", TRP_BOOL(rv));
+ return rv;
+#undef FN_NAME
+}
+
+FxBool FX_CALL trap_grLfbReadRegion (GrBuffer_t src_buffer,
+ FxU32 src_x,
+ FxU32 src_y,
+ FxU32 src_width,
+ FxU32 src_height,
+ FxU32 dst_stride,
+ void *dst_data)
+{
+#define FN_NAME "grLfbReadRegion"
+ FxBool rv;
+ TRAP_LOG("%s(%s, %lu, %lu, %lu, %lu, %ld, %p)\n", FN_NAME, TRP_BUFFER(src_buffer), src_x, src_y, src_width, src_height, dst_stride, dst_data);
+ rv = grLfbReadRegion(src_buffer, src_x, src_y, src_width, src_height, dst_stride, dst_data);
+ TRAP_LOG(GOT "%s\n", TRP_BOOL(rv));
+ return rv;
+#undef FN_NAME
+}
+
+/*
+** glide management functions
+*/
+void FX_CALL trap_grGlideInit (void)
+{
+#define FN_NAME "grGlideInit"
+ TRAP_LOG("%s()\n", FN_NAME);
+ grGlideInit();
+#undef FN_NAME
+}
+
+void FX_CALL trap_grGlideShutdown (void)
+{
+#define FN_NAME "grGlideShutdown"
+ TRAP_LOG("%s()\n", FN_NAME);
+ grGlideShutdown();
+#undef FN_NAME
+}
+
+void FX_CALL trap_grGlideGetState (void *state)
+{
+#define FN_NAME "grGlideGetState"
+ TRAP_LOG("%s(%p)\n", FN_NAME, state);
+ grGlideGetState(state);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grGlideSetState (const void *state)
+{
+#define FN_NAME "grGlideSetState"
+ TRAP_LOG("%s(%p)\n", FN_NAME, state);
+ grGlideSetState(state);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grGlideGetVertexLayout (void *layout)
+{
+#define FN_NAME "grGlideGetVertexLayout"
+ TRAP_LOG("%s(%p)\n", FN_NAME, layout);
+ grGlideGetVertexLayout(layout);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grGlideSetVertexLayout (const void *layout)
+{
+#define FN_NAME "grGlideSetVertexLayout"
+ TRAP_LOG("%s(%p)\n", FN_NAME, layout);
+ grGlideSetVertexLayout(layout);
+#undef FN_NAME
+}
+
+/*
+** glide utility functions
+*/
+void FX_CALL trap_guGammaCorrectionRGB (FxFloat red,
+ FxFloat green,
+ FxFloat blue)
+{
+#define FN_NAME "guGammaCorrectionRGB"
+ TRAP_LOG("%s(%f, %f, %f)\n", FN_NAME, red, green, blue);
+ guGammaCorrectionRGB(red, green, blue);
+#undef FN_NAME
+}
+
+float FX_CALL trap_guFogTableIndexToW (int i)
+{
+#define FN_NAME "guFogTableIndexToW"
+ float rv;
+ TRAP_LOG("%s(%d)\n", FN_NAME, i);
+ rv = guFogTableIndexToW(i);
+ TRAP_LOG(GOT "%f\n", rv);
+ return rv;
+#undef FN_NAME
+}
+
+void FX_CALL trap_guFogGenerateExp (GrFog_t *fogtable,
+ float density)
+{
+#define FN_NAME "guFogGenerateExp"
+ TRAP_LOG("%s(%p, %f)\n", FN_NAME, fogtable, density);
+ guFogGenerateExp(fogtable, density);
+#undef FN_NAME
+}
+
+void FX_CALL trap_guFogGenerateExp2 (GrFog_t *fogtable,
+ float density)
+{
+#define FN_NAME "guFogGenerateExp2"
+ TRAP_LOG("%s(%p, %f)\n", FN_NAME, fogtable, density);
+ guFogGenerateExp2(fogtable, density);
+#undef FN_NAME
+}
+
+void FX_CALL trap_guFogGenerateLinear (GrFog_t *fogtable,
+ float nearZ,
+ float farZ)
+{
+#define FN_NAME "guFogGenerateLinear"
+ TRAP_LOG("%s(%p, %f, %f)\n", FN_NAME, fogtable, nearZ, farZ);
+ guFogGenerateLinear(fogtable, nearZ, farZ);
+#undef FN_NAME
+}
+
+/*
+** glide extensions
+*/
+void FX_CALL trap_grSetNumPendingBuffers (FxI32 NumPendingBuffers)
+{
+#define FN_NAME "grSetNumPendingBuffers"
+ TRAP_LOG("%s(%ld)\n", FN_NAME, NumPendingBuffers);
+ assert(real_grSetNumPendingBuffers);
+ (*real_grSetNumPendingBuffers)(NumPendingBuffers);
+#undef FN_NAME
+}
+
+char *FX_CALL trap_grGetRegistryOrEnvironmentStringExt (char *theEntry)
+{
+#define FN_NAME "grGetRegistryOrEnvironmentStringExt"
+ char *rv;
+ TRAP_LOG("%s(\"%s\")\n", FN_NAME, theEntry);
+ assert(real_grGetRegistryOrEnvironmentStringExt);
+ rv = (*real_grGetRegistryOrEnvironmentStringExt)(theEntry);
+ if (rv) {
+ TRAP_LOG(GOT "\"%s\"\n", rv);
+ } else {
+ TRAP_LOG(GOT "NULL\n");
+ }
+ return rv;
+#undef FN_NAME
+}
+
+void FX_CALL trap_grGetGammaTableExt (FxU32 nentries,
+ FxU32 *red,
+ FxU32 *green,
+ FxU32 *blue)
+{
+#define FN_NAME "grGetGammaTableExt"
+ TRAP_LOG("%s(%lu, %p, %p, %p)\n", FN_NAME, nentries, (void *)red, (void *)green, (void *)blue);
+ assert(real_grGetGammaTableExt);
+ (*real_grGetGammaTableExt)(nentries, red, green, blue);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grChromaRangeModeExt (GrChromakeyMode_t mode)
+{
+#define FN_NAME "grChromaRangeModeExt"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_CKMODE(mode));
+ assert(real_grChromaRangeModeExt);
+ (*real_grChromaRangeModeExt)(mode);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grChromaRangeExt (GrColor_t color,
+ GrColor_t range,
+ GrChromaRangeMode_t match_mode)
+{
+#define FN_NAME "grChromaRangeExt"
+ TRAP_LOG("%s(%08lx, %08lx, %s)\n", FN_NAME, color, range, TRP_CRMODE(match_mode));
+ assert(real_grChromaRangeExt);
+ (*real_grChromaRangeExt)(color, range, match_mode);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexChromaModeExt (GrChipID_t tmu,
+ GrChromakeyMode_t mode)
+{
+#define FN_NAME "grTexChromaModeExt"
+ TRAP_LOG("%s(%s, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_CKMODE(mode));
+ assert(real_grTexChromaModeExt);
+ (*real_grTexChromaModeExt)(tmu, mode);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexChromaRangeExt (GrChipID_t tmu,
+ GrColor_t min,
+ GrColor_t max,
+ GrTexChromakeyMode_t mode)
+{
+#define FN_NAME "grTexChromaRangeExt"
+ TRAP_LOG("%s(%s, %08lx, %08lx, %s)\n", FN_NAME, TRP_TMU(tmu), min, max, TRP_CRMODE(mode));
+ assert(real_grTexChromaRangeExt);
+ (*real_grTexChromaRangeExt)(tmu, min, max, mode);
+#undef FN_NAME
+}
+
+ /* pointcast */
+void FX_CALL trap_grTexDownloadTableExt (GrChipID_t tmu,
+ GrTexTable_t type,
+ void *data)
+{
+#define FN_NAME "grTexDownloadTableExt"
+ TRAP_LOG("%s(%s, %s, %p)\n", FN_NAME, TRP_TMU(tmu), TRP_TABLE(type), data);
+ assert(real_grTexDownloadTableExt);
+ (*real_grTexDownloadTableExt)(tmu, type, data);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexDownloadTablePartialExt (GrChipID_t tmu,
+ GrTexTable_t type,
+ void *data,
+ int start,
+ int end)
+{
+#define FN_NAME "grTexDownloadTablePartialExt"
+ TRAP_LOG("%s(%s, %s, %p, %d, %d)\n", FN_NAME, TRP_TMU(tmu), TRP_TABLE(type), data, start, end);
+ assert(real_grTexDownloadTablePartialExt);
+ (*real_grTexDownloadTablePartialExt)(tmu, type, data, start, end);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexNCCTableExt (GrChipID_t tmu,
+ GrNCCTable_t table)
+{
+#define FN_NAME "grTexNCCTableExt"
+ TRAP_LOG("%s(%s, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_NCC(table));
+ assert(real_grTexNCCTableExt);
+ (*real_grTexNCCTableExt)(tmu, table);
+#undef FN_NAME
+}
+
+ /* tbext */
+void FX_CALL trap_grTextureBufferExt (GrChipID_t tmu,
+ FxU32 startAddress,
+ GrLOD_t thisLOD,
+ GrLOD_t largeLOD,
+ GrAspectRatio_t aspectRatio,
+ GrTextureFormat_t format,
+ FxU32 odd_even_mask)
+{
+#define FN_NAME "grTextureBufferExt"
+ TRAP_LOG("%s(%s, %08lx, %s, %s, %s, %s, %s)\n", FN_NAME, TRP_TMU(tmu), startAddress, TRP_LODLEVEL(thisLOD), TRP_LODLEVEL(largeLOD), TRP_ASPECTRATIO(aspectRatio), TRP_TEXFMT(format), TRP_EVENODD(odd_even_mask));
+ assert(real_grTextureBufferExt);
+ (*real_grTextureBufferExt)(tmu, startAddress, thisLOD, largeLOD, aspectRatio, format, odd_even_mask);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTextureAuxBufferExt (GrChipID_t tmu,
+ FxU32 startAddress,
+ GrLOD_t thisLOD,
+ GrLOD_t largeLOD,
+ GrAspectRatio_t aspectRatio,
+ GrTextureFormat_t format,
+ FxU32 odd_even_mask)
+{
+#define FN_NAME "grTextureAuxBufferExt"
+ TRAP_LOG("%s(%s, %08lx, %s, %s, %s, %s, %s)\n", FN_NAME, TRP_TMU(tmu), startAddress, TRP_LODLEVEL(thisLOD), TRP_LODLEVEL(largeLOD), TRP_ASPECTRATIO(aspectRatio), TRP_TEXFMT(format), TRP_EVENODD(odd_even_mask));
+ assert(real_grTextureAuxBufferExt);
+ (*real_grTextureAuxBufferExt)(tmu, startAddress, thisLOD, largeLOD, aspectRatio, format, odd_even_mask);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grAuxBufferExt (GrBuffer_t buffer)
+{
+#define FN_NAME "grAuxBufferExt"
+ TRAP_LOG("%s(%s)\n", FN_NAME, TRP_BUFFER(buffer));
+ assert(real_grAuxBufferExt);
+ (*real_grAuxBufferExt)(buffer);
+#undef FN_NAME
+}
+
+ /* napalm */
+GrContext_t FX_CALL trap_grSstWinOpenExt (FxU32 hWnd,
+ GrScreenResolution_t resolution,
+ GrScreenRefresh_t refresh,
+ GrColorFormat_t format,
+ GrOriginLocation_t origin,
+ GrPixelFormat_t pixelformat,
+ int nColBuffers,
+ int nAuxBuffers)
+{
+#define FN_NAME "grSstWinOpenExt"
+ GrContext_t rv;
+ TRAP_LOG("%s(%08lx, %s, %s, %s, %s, %s, %d, %d)\n", FN_NAME, hWnd, TRP_RESOLUTION(resolution), TRP_REFRESH(refresh), TRP_COLFMT(format), TRP_ORIGIN(origin), TRP_PIXFMT(pixelformat), nColBuffers, nAuxBuffers);
+ assert(real_grSstWinOpenExt);
+ rv = (*real_grSstWinOpenExt)(hWnd, resolution, refresh, format, origin, pixelformat, nColBuffers, nAuxBuffers);
+ TRAP_LOG(GOT "%p\n", (void *)rv);
+ return rv;
+#undef FN_NAME
+}
+
+void FX_CALL trap_grStencilFuncExt (GrCmpFnc_t fnc,
+ GrStencil_t ref,
+ GrStencil_t mask)
+{
+#define FN_NAME "grStencilFuncExt"
+ TRAP_LOG("%s(%s, %02x, %02x)\n", FN_NAME, TRP_CMPFUNC(fnc), ref, mask);
+ assert(real_grStencilFuncExt);
+ (*real_grStencilFuncExt)(fnc, ref, mask);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grStencilMaskExt (GrStencil_t value)
+{
+#define FN_NAME "grStencilMaskExt"
+ TRAP_LOG("%s(%02x)\n", FN_NAME, value);
+ assert(real_grStencilMaskExt);
+ (*real_grStencilMaskExt)(value);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grStencilOpExt (GrStencilOp_t stencil_fail,
+ GrStencilOp_t depth_fail,
+ GrStencilOp_t depth_pass)
+{
+#define FN_NAME "grStencilOpExt"
+ TRAP_LOG("%s(%s, %s, %s)\n", FN_NAME, TRP_STENCILOP(stencil_fail), TRP_STENCILOP(depth_fail), TRP_STENCILOP(depth_pass));
+ assert(real_grStencilOpExt);
+ (*real_grStencilOpExt)(stencil_fail, depth_fail, depth_pass);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grLfbConstantStencilExt (GrStencil_t value)
+{
+#define FN_NAME "grLfbConstantStencilExt"
+ TRAP_LOG("%s(%02x)\n", FN_NAME, value);
+ assert(real_grLfbConstantStencilExt);
+ (*real_grLfbConstantStencilExt)(value);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grBufferClearExt (GrColor_t color,
+ GrAlpha_t alpha,
+ FxU32 depth,
+ GrStencil_t stencil)
+{
+#define FN_NAME "grBufferClearExt"
+ TRAP_LOG("%s(%08lx, %02x, %08lx, %02x)\n", FN_NAME, color, alpha, depth, stencil);
+ assert(real_grBufferClearExt);
+ (*real_grBufferClearExt)(color, alpha, depth, stencil);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grColorCombineExt (GrCCUColor_t a,
+ GrCombineMode_t a_mode,
+ GrCCUColor_t b,
+ GrCombineMode_t b_mode,
+ GrCCUColor_t c,
+ FxBool c_invert,
+ GrCCUColor_t d,
+ FxBool d_invert,
+ FxU32 shift,
+ FxBool invert)
+{
+#define FN_NAME "grColorCombineExt"
+ TRAP_LOG("%s(%s, %s, %s, %s, %s, %s, %s, %s, %lu, %s)\n", FN_NAME, TRP_CU(a), TRP_CMBMODE(a_mode), TRP_CU(b), TRP_CMBMODE(b_mode), TRP_CU(c), TRP_BOOL(c_invert), TRP_CU(d), TRP_BOOL(d_invert), shift, TRP_BOOL(invert));
+ assert(real_grColorCombineExt);
+ (*real_grColorCombineExt)(a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grAlphaCombineExt (GrACUColor_t a,
+ GrCombineMode_t a_mode,
+ GrACUColor_t b,
+ GrCombineMode_t b_mode,
+ GrACUColor_t c,
+ FxBool c_invert,
+ GrACUColor_t d,
+ FxBool d_invert,
+ FxU32 shift,
+ FxBool invert)
+{
+#define FN_NAME "grAlphaCombineExt"
+ TRAP_LOG("%s(%s, %s, %s, %s, %s, %s, %s, %s, %lu, %s)\n", FN_NAME, TRP_CU(a), TRP_CMBMODE(a_mode), TRP_CU(b), TRP_CMBMODE(b_mode), TRP_CU(c), TRP_BOOL(c_invert), TRP_CU(d), TRP_BOOL(d_invert), shift, TRP_BOOL(invert));
+ assert(real_grAlphaCombineExt);
+ (*real_grAlphaCombineExt)(a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexColorCombineExt (GrChipID_t tmu,
+ GrTCCUColor_t a,
+ GrCombineMode_t a_mode,
+ GrTCCUColor_t b,
+ GrCombineMode_t b_mode,
+ GrTCCUColor_t c,
+ FxBool c_invert,
+ GrTCCUColor_t d,
+ FxBool d_invert,
+ FxU32 shift,
+ FxBool invert)
+{
+#define FN_NAME "grTexColorCombineExt"
+ TRAP_LOG("%s(%s, %s, %s, %s, %s, %s, %s, %s, %s, %lu, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_CU(a), TRP_CMBMODE(a_mode), TRP_CU(b), TRP_CMBMODE(b_mode), TRP_CU(c), TRP_BOOL(c_invert), TRP_CU(d), TRP_BOOL(d_invert), shift, TRP_BOOL(invert));
+ assert(real_grTexColorCombineExt);
+ (*real_grTexColorCombineExt)(tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTexAlphaCombineExt (GrChipID_t tmu,
+ GrTACUColor_t a,
+ GrCombineMode_t a_mode,
+ GrTACUColor_t b,
+ GrCombineMode_t b_mode,
+ GrTACUColor_t c,
+ FxBool c_invert,
+ GrTACUColor_t d,
+ FxBool d_invert,
+ FxU32 shift,
+ FxBool invert)
+{
+#define FN_NAME "grTexAlphaCombineExt"
+ TRAP_LOG("%s(%s, %s, %s, %s, %s, %s, %s, %s, %s, %lu, %s)\n", FN_NAME, TRP_TMU(tmu), TRP_CU(a), TRP_CMBMODE(a_mode), TRP_CU(b), TRP_CMBMODE(b_mode), TRP_CU(c), TRP_BOOL(c_invert), TRP_CU(d), TRP_BOOL(d_invert), shift, TRP_BOOL(invert));
+ assert(real_grTexAlphaCombineExt);
+ (*real_grTexAlphaCombineExt)(tmu, a, a_mode, b, b_mode, c, c_invert, d, d_invert, shift, invert);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grConstantColorValueExt (GrChipID_t tmu,
+ GrColor_t value)
+{
+#define FN_NAME "grConstantColorValueExt"
+ TRAP_LOG("%s(%s, %08lx)\n", FN_NAME, TRP_TMU(tmu), value);
+ assert(real_grConstantColorValueExt);
+ (*real_grConstantColorValueExt)(tmu, value);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grColorMaskExt (FxBool r,
+ FxBool g,
+ FxBool b,
+ FxBool a)
+{
+#define FN_NAME "grColorMaskExt"
+ TRAP_LOG("%s(%s, %s, %s, %s)\n", FN_NAME, TRP_BOOL(r), TRP_BOOL(g), TRP_BOOL(b), TRP_BOOL(a));
+ assert(real_grColorMaskExt);
+ (*real_grColorMaskExt)(r, g, b, a);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grAlphaBlendFunctionExt (GrAlphaBlendFnc_t rgb_sf,
+ GrAlphaBlendFnc_t rgb_df,
+ GrAlphaBlendOp_t rgb_op,
+ GrAlphaBlendFnc_t alpha_sf,
+ GrAlphaBlendFnc_t alpha_df,
+ GrAlphaBlendOp_t alpha_op)
+{
+#define FN_NAME "grAlphaBlendFunctionExt"
+ TRAP_LOG("%s(%s, %s, %s, %s, %s, %s)\n", FN_NAME, TRP_BLEND(rgb_sf), TRP_BLEND(rgb_df), TRP_BLENDOP(rgb_op), TRP_BLEND(alpha_sf), TRP_BLEND(alpha_df), TRP_BLENDOP(alpha_op));
+ assert(real_grAlphaBlendFunctionExt);
+ (*real_grAlphaBlendFunctionExt)(rgb_sf, rgb_df, rgb_op, alpha_sf, alpha_df, alpha_op);
+#undef FN_NAME
+}
+
+void FX_CALL trap_grTBufferWriteMaskExt (FxU32 tmask)
+{
+#define FN_NAME "grTBufferWriteMaskExt"
+ TRAP_LOG("%s(%08lx)\n", FN_NAME, tmask);
+ assert(real_grTBufferWriteMaskExt);
+ (*real_grTBufferWriteMaskExt)(tmask);
+#undef FN_NAME
+}
+
+/*
+** texus functions
+*/
+void FX_CALL trap_txImgQuantize (char *dst,
+ char *src,
+ int w,
+ int h,
+ FxU32 format,
+ FxU32 dither)
+{
+#define FN_NAME "txImgQuantize"
+ TRAP_LOG("%s(%p, %p, %d, %d, %s, %s)\n", FN_NAME, dst, src, w, h, TRP_TEXFMT(format), TRP_TXDITHER(dither));
+ assert(real_txImgQuantize);
+ (*real_txImgQuantize)(dst, src, w, h, format, dither);
+#undef FN_NAME
+}
+
+void FX_CALL trap_txMipQuantize (TxMip *pxMip,
+ TxMip *txMip,
+ int fmt,
+ FxU32 d,
+ FxU32 comp)
+{
+#define FN_NAME "txMipQuantize"
+ TRAP_LOG("%s(%p, %p, %s, %s, %s)\n", FN_NAME, (void *)pxMip, (void *)txMip, TRP_TEXFMT(fmt), TRP_TXDITHER(d), TRP_TXCOMPRESS(comp));
+ assert(real_txMipQuantize);
+ (*real_txMipQuantize)(pxMip, txMip, fmt, d, comp);
+#undef FN_NAME
+}
+
+void FX_CALL trap_txPalToNcc (GuNccTable *ncc_table,
+ const FxU32 *pal)
+{
+#define FN_NAME "txPalToNcc"
+ TRAP_LOG("%s(%p, %p)\n", FN_NAME, (void *)ncc_table, (void *)pal);
+ assert(real_txPalToNcc);
+ (*real_txPalToNcc)(ncc_table, pal);
+#undef FN_NAME
+}
+#endif
+
+
+
+/****************************************************************************\
+* housekeeping (fake pointers) *
+\****************************************************************************/
+char *FX_CALL fake_grGetRegistryOrEnvironmentStringExt (char *theEntry)
+{
+ return getenv(theEntry);
+}
+
+void FX_CALL fake_grTexDownloadTableExt (GrChipID_t tmu,
+ GrTexTable_t type,
+ void *data)
+{
+ (void)tmu;
+ grTexDownloadTable(type, data);
+}
+
+void FX_CALL fake_grTexDownloadTablePartialExt (GrChipID_t tmu,
+ GrTexTable_t type,
+ void *data,
+ int start,
+ int end)
+{
+ (void)tmu;
+ grTexDownloadTablePartial(type, data, start, end);
+}
+
+void FX_CALL fake_grTexNCCTableExt (GrChipID_t tmu,
+ GrNCCTable_t table)
+{
+ (void)tmu;
+ grTexNCCTable(table);
+}
+
+
+
+/****************************************************************************\
+* interface *
+\****************************************************************************/
+void tdfx_hook_glide (struct tdfx_glide *Glide, int pointcast)
+{
+/* GET_EXT_ADDR: get function pointer
+ * GET_EXT_FAKE: get function pointer if possible, else use a fake function
+ * GET_EXT_NULL: get function pointer if possible, else leave NULL pointer
+ */
+#if FX_TRAP_GLIDE
+#define GET_EXT_ADDR(name) *(GrProc *)&real_##name = grGetProcAddress(#name), Glide->name = trap_##name
+#define GET_EXT_FAKE(name) GET_EXT_ADDR(name); if (real_##name == NULL) real_##name = fake_##name
+#define GET_EXT_NULL(name) GET_EXT_ADDR(name); if (real_##name == NULL) Glide->name = NULL
+#else /* FX_TRAP_GLIDE */
+#define GET_EXT_ADDR(name) *(GrProc *)&Glide->name = grGetProcAddress(#name)
+#define GET_EXT_FAKE(name) GET_EXT_ADDR(name); if (Glide->name == NULL) Glide->name = fake_##name
+#define GET_EXT_NULL(name) GET_EXT_ADDR(name)
+#endif /* FX_TRAP_GLIDE */
+
+ /*
+ ** glide extensions
+ */
+ GET_EXT_NULL(grSetNumPendingBuffers);
+ GET_EXT_FAKE(grGetRegistryOrEnvironmentStringExt);
+ GET_EXT_ADDR(grGetGammaTableExt);
+ GET_EXT_ADDR(grChromaRangeModeExt);
+ GET_EXT_ADDR(grChromaRangeExt);
+ GET_EXT_ADDR(grTexChromaModeExt);
+ GET_EXT_ADDR(grTexChromaRangeExt);
+ /* pointcast */
+ if (pointcast) {
+ GET_EXT_FAKE(grTexDownloadTableExt);
+ GET_EXT_FAKE(grTexDownloadTablePartialExt);
+ GET_EXT_FAKE(grTexNCCTableExt);
+ } else {
+ Glide->grTexDownloadTableExt = fake_grTexDownloadTableExt;
+ Glide->grTexDownloadTablePartialExt = fake_grTexDownloadTablePartialExt;
+ Glide->grTexNCCTableExt = fake_grTexNCCTableExt;
+ }
+ /* tbext */
+ GET_EXT_ADDR(grTextureBufferExt);
+ GET_EXT_ADDR(grTextureAuxBufferExt);
+ GET_EXT_ADDR(grAuxBufferExt);
+ /* napalm */
+ GET_EXT_ADDR(grSstWinOpenExt);
+ GET_EXT_ADDR(grStencilFuncExt);
+ GET_EXT_ADDR(grStencilMaskExt);
+ GET_EXT_ADDR(grStencilOpExt);
+ GET_EXT_ADDR(grLfbConstantStencilExt);
+ GET_EXT_ADDR(grBufferClearExt);
+ GET_EXT_ADDR(grColorCombineExt);
+ GET_EXT_ADDR(grAlphaCombineExt);
+ GET_EXT_ADDR(grTexColorCombineExt);
+ GET_EXT_ADDR(grTexAlphaCombineExt);
+ GET_EXT_ADDR(grConstantColorValueExt);
+ GET_EXT_ADDR(grColorMaskExt);
+ GET_EXT_ADDR(grAlphaBlendFunctionExt);
+ GET_EXT_ADDR(grTBufferWriteMaskExt);
+
+ /*
+ ** texus
+ */
+ GET_EXT_NULL(txImgQuantize);
+ GET_EXT_NULL(txMipQuantize);
+ GET_EXT_NULL(txPalToNcc);
+
+#undef GET_EXT_ADDR
+}
+
+#endif /* FX */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxg.h b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxg.h
new file mode 100644
index 000000000..e71201116
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxg.h
@@ -0,0 +1,382 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.0.1
+ *
+ * Copyright (C) 1999-2003 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/FX device driver. Interface to Glide3.
+ *
+ * Copyright (c) 2003 - Daniel Borca
+ * Email : dborca@users.sourceforge.net
+ * Web : http://www.geocities.com/dborca
+ */
+
+
+#ifndef TDFX_GLIDE_H_included
+#define TDFX_GLIDE_H_included
+
+#include <glide.h>
+#include <g3ext.h>
+
+#ifndef FX_TRAP_GLIDE
+#define FX_TRAP_GLIDE 0
+#endif
+
+#if FX_TRAP_GLIDE
+/*
+** rendering functions
+*/
+void FX_CALL trap_grDrawPoint (const void *pt);
+void FX_CALL trap_grDrawLine (const void *v1, const void *v2);
+void FX_CALL trap_grDrawTriangle (const void *a, const void *b, const void *c);
+void FX_CALL trap_grVertexLayout (FxU32 param, FxI32 offset, FxU32 mode);
+void FX_CALL trap_grDrawVertexArray (FxU32 mode, FxU32 Count, void *pointers);
+void FX_CALL trap_grDrawVertexArrayContiguous (FxU32 mode, FxU32 Count, void *pointers, FxU32 stride);
+
+/*
+** Antialiasing Functions
+*/
+void FX_CALL trap_grAADrawTriangle (const void *a, const void *b, const void *c, FxBool ab_antialias, FxBool bc_antialias, FxBool ca_antialias);
+
+/*
+** buffer management
+*/
+void FX_CALL trap_grBufferClear (GrColor_t color, GrAlpha_t alpha, FxU32 depth);
+void FX_CALL trap_grBufferSwap (FxU32 swap_interval);
+void FX_CALL trap_grRenderBuffer (GrBuffer_t buffer);
+
+/*
+** error management
+*/
+void FX_CALL trap_grErrorSetCallback (GrErrorCallbackFnc_t fnc);
+
+/*
+** SST routines
+*/
+void FX_CALL trap_grFinish (void);
+void FX_CALL trap_grFlush (void);
+GrContext_t FX_CALL trap_grSstWinOpen (FxU32 hWnd, GrScreenResolution_t screen_resolution, GrScreenRefresh_t refresh_rate, GrColorFormat_t color_format, GrOriginLocation_t origin_location, int nColBuffers, int nAuxBuffers);
+FxBool FX_CALL trap_grSstWinClose (GrContext_t context);
+FxBool FX_CALL trap_grSelectContext (GrContext_t context);
+void FX_CALL trap_grSstOrigin (GrOriginLocation_t origin);
+void FX_CALL trap_grSstSelect (int which_sst);
+
+/*
+** Glide configuration and special effect maintenance functions
+*/
+void FX_CALL trap_grAlphaBlendFunction (GrAlphaBlendFnc_t rgb_sf, GrAlphaBlendFnc_t rgb_df, GrAlphaBlendFnc_t alpha_sf, GrAlphaBlendFnc_t alpha_df);
+void FX_CALL trap_grAlphaCombine (GrCombineFunction_t function, GrCombineFactor_t factor, GrCombineLocal_t local, GrCombineOther_t other, FxBool invert);
+void FX_CALL trap_grAlphaControlsITRGBLighting (FxBool enable);
+void FX_CALL trap_grAlphaTestFunction (GrCmpFnc_t function);
+void FX_CALL trap_grAlphaTestReferenceValue (GrAlpha_t value);
+void FX_CALL trap_grChromakeyMode (GrChromakeyMode_t mode);
+void FX_CALL trap_grChromakeyValue (GrColor_t value);
+void FX_CALL trap_grClipWindow (FxU32 minx, FxU32 miny, FxU32 maxx, FxU32 maxy);
+void FX_CALL trap_grColorCombine (GrCombineFunction_t function, GrCombineFactor_t factor, GrCombineLocal_t local, GrCombineOther_t other, FxBool invert);
+void FX_CALL trap_grColorMask (FxBool rgb, FxBool a);
+void FX_CALL trap_grCullMode (GrCullMode_t mode);
+void FX_CALL trap_grConstantColorValue (GrColor_t value);
+void FX_CALL trap_grDepthBiasLevel (FxI32 level);
+void FX_CALL trap_grDepthBufferFunction (GrCmpFnc_t function);
+void FX_CALL trap_grDepthBufferMode (GrDepthBufferMode_t mode);
+void FX_CALL trap_grDepthMask (FxBool mask);
+void FX_CALL trap_grDisableAllEffects (void);
+void FX_CALL trap_grDitherMode (GrDitherMode_t mode);
+void FX_CALL trap_grFogColorValue (GrColor_t fogcolor);
+void FX_CALL trap_grFogMode (GrFogMode_t mode);
+void FX_CALL trap_grFogTable (const GrFog_t ft[]);
+void FX_CALL trap_grLoadGammaTable (FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue);
+void FX_CALL trap_grSplash (float x, float y, float width, float height, FxU32 frame);
+FxU32 FX_CALL trap_grGet (FxU32 pname, FxU32 plength, FxI32 *params);
+const char * FX_CALL trap_grGetString (FxU32 pname);
+FxI32 FX_CALL trap_grQueryResolutions (const GrResolution *resTemplate, GrResolution *output);
+FxBool FX_CALL trap_grReset (FxU32 what);
+GrProc FX_CALL trap_grGetProcAddress (char *procName);
+void FX_CALL trap_grEnable (GrEnableMode_t mode);
+void FX_CALL trap_grDisable (GrEnableMode_t mode);
+void FX_CALL trap_grCoordinateSpace (GrCoordinateSpaceMode_t mode);
+void FX_CALL trap_grDepthRange (FxFloat n, FxFloat f);
+void FX_CALL trap_grStippleMode (GrStippleMode_t mode);
+void FX_CALL trap_grStipplePattern (GrStipplePattern_t mode);
+void FX_CALL trap_grViewport (FxI32 x, FxI32 y, FxI32 width, FxI32 height);
+
+/*
+** texture mapping control functions
+*/
+FxU32 FX_CALL trap_grTexCalcMemRequired (GrLOD_t lodmin, GrLOD_t lodmax, GrAspectRatio_t aspect, GrTextureFormat_t fmt);
+FxU32 FX_CALL trap_grTexTextureMemRequired (FxU32 evenOdd, GrTexInfo *info);
+FxU32 FX_CALL trap_grTexMinAddress (GrChipID_t tmu);
+FxU32 FX_CALL trap_grTexMaxAddress (GrChipID_t tmu);
+void FX_CALL trap_grTexNCCTable (GrNCCTable_t table);
+void FX_CALL trap_grTexSource (GrChipID_t tmu, FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info);
+void FX_CALL trap_grTexClampMode (GrChipID_t tmu, GrTextureClampMode_t s_clampmode, GrTextureClampMode_t t_clampmode);
+void FX_CALL trap_grTexCombine (GrChipID_t tmu, GrCombineFunction_t rgb_function, GrCombineFactor_t rgb_factor, GrCombineFunction_t alpha_function, GrCombineFactor_t alpha_factor, FxBool rgb_invert, FxBool alpha_invert);
+void FX_CALL trap_grTexDetailControl (GrChipID_t tmu, int lod_bias, FxU8 detail_scale, float detail_max);
+void FX_CALL trap_grTexFilterMode (GrChipID_t tmu, GrTextureFilterMode_t minfilter_mode, GrTextureFilterMode_t magfilter_mode);
+void FX_CALL trap_grTexLodBiasValue (GrChipID_t tmu, float bias);
+void FX_CALL trap_grTexDownloadMipMap (GrChipID_t tmu, FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info);
+void FX_CALL trap_grTexDownloadMipMapLevel (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLod, GrLOD_t largeLod, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 evenOdd, void *data);
+FxBool FX_CALL trap_grTexDownloadMipMapLevelPartial (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLod, GrLOD_t largeLod, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 evenOdd, void *data, int start, int end);
+void FX_CALL trap_grTexDownloadTable (GrTexTable_t type, void *data);
+void FX_CALL trap_grTexDownloadTablePartial (GrTexTable_t type, void *data, int start, int end);
+void FX_CALL trap_grTexMipMapMode (GrChipID_t tmu, GrMipMapMode_t mode, FxBool lodBlend);
+void FX_CALL trap_grTexMultibase (GrChipID_t tmu, FxBool enable);
+void FX_CALL trap_grTexMultibaseAddress (GrChipID_t tmu, GrTexBaseRange_t range, FxU32 startAddress, FxU32 evenOdd, GrTexInfo *info);
+
+/*
+** linear frame buffer functions
+*/
+FxBool FX_CALL trap_grLfbLock (GrLock_t type, GrBuffer_t buffer, GrLfbWriteMode_t writeMode, GrOriginLocation_t origin, FxBool pixelPipeline, GrLfbInfo_t *info);
+FxBool FX_CALL trap_grLfbUnlock (GrLock_t type, GrBuffer_t buffer);
+void FX_CALL trap_grLfbConstantAlpha (GrAlpha_t alpha);
+void FX_CALL trap_grLfbConstantDepth (FxU32 depth);
+void FX_CALL trap_grLfbWriteColorSwizzle (FxBool swizzleBytes, FxBool swapWords);
+void FX_CALL trap_grLfbWriteColorFormat (GrColorFormat_t colorFormat);
+FxBool FX_CALL trap_grLfbWriteRegion (GrBuffer_t dst_buffer, FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format, FxU32 src_width, FxU32 src_height, FxBool pixelPipeline, FxI32 src_stride, void *src_data);
+FxBool FX_CALL trap_grLfbReadRegion (GrBuffer_t src_buffer, FxU32 src_x, FxU32 src_y, FxU32 src_width, FxU32 src_height, FxU32 dst_stride, void *dst_data);
+
+/*
+** glide management functions
+*/
+void FX_CALL trap_grGlideInit (void);
+void FX_CALL trap_grGlideShutdown (void);
+void FX_CALL trap_grGlideGetState (void *state);
+void FX_CALL trap_grGlideSetState (const void *state);
+void FX_CALL trap_grGlideGetVertexLayout (void *layout);
+void FX_CALL trap_grGlideSetVertexLayout (const void *layout);
+
+/*
+** glide utility functions
+*/
+void FX_CALL trap_guGammaCorrectionRGB (FxFloat red, FxFloat green, FxFloat blue);
+float FX_CALL trap_guFogTableIndexToW (int i);
+void FX_CALL trap_guFogGenerateExp (GrFog_t *fogtable, float density);
+void FX_CALL trap_guFogGenerateExp2 (GrFog_t *fogtable, float density);
+void FX_CALL trap_guFogGenerateLinear (GrFog_t *fogtable, float nearZ, float farZ);
+
+#ifndef FX_TRAP_GLIDE_internal
+/*
+** rendering functions
+*/
+#define grDrawPoint trap_grDrawPoint
+#define grDrawLine trap_grDrawLine
+#define grDrawTriangle trap_grDrawTriangle
+#define grVertexLayout trap_grVertexLayout
+#define grDrawVertexArray trap_grDrawVertexArray
+#define grDrawVertexArrayContiguous trap_grDrawVertexArrayContiguous
+
+/*
+** Antialiasing Functions
+*/
+#define grAADrawTriangle trap_grAADrawTriangle
+
+/*
+** buffer management
+*/
+#define grBufferClear trap_grBufferClear
+#define grBufferSwap trap_grBufferSwap
+#define grRenderBuffer trap_grRenderBuffer
+
+/*
+** error management
+*/
+#define grErrorSetCallback trap_grErrorSetCallback
+
+/*
+** SST routines
+*/
+#define grFinish trap_grFinish
+#define grFlush trap_grFlush
+#define grSstWinOpen trap_grSstWinOpen
+#define grSstWinClose trap_grSstWinClose
+#define grSelectContext trap_grSelectContext
+#define grSstOrigin trap_grSstOrigin
+#define grSstSelect trap_grSstSelect
+
+/*
+** Glide configuration and special effect maintenance functions
+*/
+#define grAlphaBlendFunction trap_grAlphaBlendFunction
+#define grAlphaCombine trap_grAlphaCombine
+#define grAlphaControlsITRGBLighting trap_grAlphaControlsITRGBLighting
+#define grAlphaTestFunction trap_grAlphaTestFunction
+#define grAlphaTestReferenceValue trap_grAlphaTestReferenceValue
+#define grChromakeyMode trap_grChromakeyMode
+#define grChromakeyValue trap_grChromakeyValue
+#define grClipWindow trap_grClipWindow
+#define grColorCombine trap_grColorCombine
+#define grColorMask trap_grColorMask
+#define grCullMode trap_grCullMode
+#define grConstantColorValue trap_grConstantColorValue
+#define grDepthBiasLevel trap_grDepthBiasLevel
+#define grDepthBufferFunction trap_grDepthBufferFunction
+#define grDepthBufferMode trap_grDepthBufferMode
+#define grDepthMask trap_grDepthMask
+#define grDisableAllEffects trap_grDisableAllEffects
+#define grDitherMode trap_grDitherMode
+#define grFogColorValue trap_grFogColorValue
+#define grFogMode trap_grFogMode
+#define grFogTable trap_grFogTable
+#define grLoadGammaTable trap_grLoadGammaTable
+#define grSplash trap_grSplash
+#define grGet trap_grGet
+#define grGetString trap_grGetString
+#define grQueryResolutions trap_grQueryResolutions
+#define grReset trap_grReset
+#define grGetProcAddress trap_grGetProcAddress
+#define grEnable trap_grEnable
+#define grDisable trap_grDisable
+#define grCoordinateSpace trap_grCoordinateSpace
+#define grDepthRange trap_grDepthRange
+#define grStippleMode trap_grStippleMode
+#define grStipplePattern trap_grStipplePattern
+#define grViewport trap_grViewport
+
+/*
+** texture mapping control functions
+*/
+#define grTexCalcMemRequired trap_grTexCalcMemRequired
+#define grTexTextureMemRequired trap_grTexTextureMemRequired
+#define grTexMinAddress trap_grTexMinAddress
+#define grTexMaxAddress trap_grTexMaxAddress
+#define grTexNCCTable trap_grTexNCCTable
+#define grTexSource trap_grTexSource
+#define grTexClampMode trap_grTexClampMode
+#define grTexCombine trap_grTexCombine
+#define grTexDetailControl trap_grTexDetailControl
+#define grTexFilterMode trap_grTexFilterMode
+#define grTexLodBiasValue trap_grTexLodBiasValue
+#define grTexDownloadMipMap trap_grTexDownloadMipMap
+#define grTexDownloadMipMapLevel trap_grTexDownloadMipMapLevel
+#define grTexDownloadMipMapLevelPartial trap_grTexDownloadMipMapLevelPartial
+#define grTexDownloadTable trap_grTexDownloadTable
+#define grTexDownloadTablePartial trap_grTexDownloadTablePartial
+#define grTexMipMapMode trap_grTexMipMapMode
+#define grTexMultibase trap_grTexMultibase
+#define grTexMultibaseAddress trap_grTexMultibaseAddress
+
+/*
+** linear frame buffer functions
+*/
+#define grLfbLock trap_grLfbLock
+#define grLfbUnlock trap_grLfbUnlock
+#define grLfbConstantAlpha trap_grLfbConstantAlpha
+#define grLfbConstantDepth trap_grLfbConstantDepth
+#define grLfbWriteColorSwizzle trap_grLfbWriteColorSwizzle
+#define grLfbWriteColorFormat trap_grLfbWriteColorFormat
+#define grLfbWriteRegion trap_grLfbWriteRegion
+#define grLfbReadRegion trap_grLfbReadRegion
+
+/*
+** glide management functions
+*/
+#define grGlideInit trap_grGlideInit
+#define grGlideShutdown trap_grGlideShutdown
+#define grGlideGetState trap_grGlideGetState
+#define grGlideSetState trap_grGlideSetState
+#define grGlideGetVertexLayout trap_grGlideGetVertexLayout
+#define grGlideSetVertexLayout trap_grGlideSetVertexLayout
+
+/*
+** glide utility functions
+*/
+#define guGammaCorrectionRGB trap_guGammaCorrectionRGB
+#define guFogTableIndexToW trap_guFogTableIndexToW
+#define guFogGenerateExp trap_guFogGenerateExp
+#define guFogGenerateExp2 trap_guFogGenerateExp2
+#define guFogGenerateLinear trap_guFogGenerateLinear
+#endif /* FX_TRAP_GLIDE_internal */
+#endif /* FX_TRAP_GLIDE */
+
+
+
+/* <texus.h> */
+#define TX_MAX_LEVEL 16
+typedef struct _TxMip {
+ int format;
+ int width;
+ int height;
+ int depth;
+ int size;
+ void *data[TX_MAX_LEVEL];
+ FxU32 pal[256];
+} TxMip;
+
+#define TX_DITHER_NONE 0x00000000
+#define TX_DITHER_4x4 0x00000001
+#define TX_DITHER_ERR 0x00000002
+
+#define TX_COMPRESSION_STATISTICAL 0x00000000
+#define TX_COMPRESSION_HEURISTIC 0x00000010
+/* <texus.h> */
+
+
+
+struct tdfx_glide {
+ /*
+ ** glide extensions
+ */
+ void (FX_CALL *grSetNumPendingBuffers) (FxI32 NumPendingBuffers);
+ char * (FX_CALL *grGetRegistryOrEnvironmentStringExt) (char *theEntry);
+ void (FX_CALL *grGetGammaTableExt) (FxU32 nentries, FxU32 *red, FxU32 *green, FxU32 *blue);
+ void (FX_CALL *grChromaRangeModeExt) (GrChromakeyMode_t mode);
+ void (FX_CALL *grChromaRangeExt) (GrColor_t color, GrColor_t range, GrChromaRangeMode_t match_mode);
+ void (FX_CALL *grTexChromaModeExt) (GrChipID_t tmu, GrChromakeyMode_t mode);
+ void (FX_CALL *grTexChromaRangeExt) (GrChipID_t tmu, GrColor_t min, GrColor_t max, GrTexChromakeyMode_t mode);
+
+ /* pointcast */
+ void (FX_CALL *grTexDownloadTableExt) (GrChipID_t tmu, GrTexTable_t type, void *data);
+ void (FX_CALL *grTexDownloadTablePartialExt) (GrChipID_t tmu, GrTexTable_t type, void *data, int start, int end);
+ void (FX_CALL *grTexNCCTableExt) (GrChipID_t tmu, GrNCCTable_t table);
+
+ /* tbext */
+ void (FX_CALL *grTextureBufferExt) (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLOD, GrLOD_t largeLOD, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 odd_even_mask);
+ void (FX_CALL *grTextureAuxBufferExt) (GrChipID_t tmu, FxU32 startAddress, GrLOD_t thisLOD, GrLOD_t largeLOD, GrAspectRatio_t aspectRatio, GrTextureFormat_t format, FxU32 odd_even_mask);
+ void (FX_CALL *grAuxBufferExt) (GrBuffer_t buffer);
+
+ /* napalm */
+ GrContext_t (FX_CALL *grSstWinOpenExt) (FxU32 hWnd, GrScreenResolution_t resolution, GrScreenRefresh_t refresh, GrColorFormat_t format, GrOriginLocation_t origin, GrPixelFormat_t pixelformat, int nColBuffers, int nAuxBuffers);
+ void (FX_CALL *grStencilFuncExt) (GrCmpFnc_t fnc, GrStencil_t ref, GrStencil_t mask);
+ void (FX_CALL *grStencilMaskExt) (GrStencil_t value);
+ void (FX_CALL *grStencilOpExt) (GrStencilOp_t stencil_fail, GrStencilOp_t depth_fail, GrStencilOp_t depth_pass);
+ void (FX_CALL *grLfbConstantStencilExt) (GrStencil_t value);
+ void (FX_CALL *grBufferClearExt) (GrColor_t color, GrAlpha_t alpha, FxU32 depth, GrStencil_t stencil);
+ void (FX_CALL *grColorCombineExt) (GrCCUColor_t a, GrCombineMode_t a_mode, GrCCUColor_t b, GrCombineMode_t b_mode, GrCCUColor_t c, FxBool c_invert, GrCCUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert);
+ void (FX_CALL *grAlphaCombineExt) (GrACUColor_t a, GrCombineMode_t a_mode, GrACUColor_t b, GrCombineMode_t b_mode, GrACUColor_t c, FxBool c_invert, GrACUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert);
+ void (FX_CALL *grTexColorCombineExt) (GrChipID_t tmu, GrTCCUColor_t a, GrCombineMode_t a_mode, GrTCCUColor_t b, GrCombineMode_t b_mode, GrTCCUColor_t c, FxBool c_invert, GrTCCUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert);
+ void (FX_CALL *grTexAlphaCombineExt) (GrChipID_t tmu, GrTACUColor_t a, GrCombineMode_t a_mode, GrTACUColor_t b, GrCombineMode_t b_mode, GrTACUColor_t c, FxBool c_invert, GrTACUColor_t d, FxBool d_invert, FxU32 shift, FxBool invert);
+ void (FX_CALL *grConstantColorValueExt) (GrChipID_t tmu, GrColor_t value);
+ void (FX_CALL *grColorMaskExt) (FxBool r, FxBool g, FxBool b, FxBool a);
+ void (FX_CALL *grAlphaBlendFunctionExt) (GrAlphaBlendFnc_t rgb_sf, GrAlphaBlendFnc_t rgb_df, GrAlphaBlendOp_t rgb_op, GrAlphaBlendFnc_t alpha_sf, GrAlphaBlendFnc_t alpha_df, GrAlphaBlendOp_t alpha_op);
+ void (FX_CALL *grTBufferWriteMaskExt) (FxU32 tmask);
+
+ /*
+ ** Texus2 functions
+ */
+ void (FX_CALL *txImgQuantize) (char *dst, char *src, int w, int h, FxU32 format, FxU32 dither);
+ void (FX_CALL *txMipQuantize) (TxMip *pxMip, TxMip *txMip, int fmt, FxU32 d, FxU32 comp);
+ void (FX_CALL *txPalToNcc) (GuNccTable *ncc_table, const FxU32 *pal);
+};
+
+void tdfx_hook_glide (struct tdfx_glide *Glide, int pointcast);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxglidew.c b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxglidew.c
new file mode 100644
index 000000000..1fedf2ab9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxglidew.c
@@ -0,0 +1,269 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.0
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/* Authors:
+ * David Bucciarelli
+ * Brian Paul
+ * Daryll Strauss
+ * Keith Whitwell
+ * Daniel Borca
+ * Hiroshi Morii
+ */
+
+/* fxsetup.c - 3Dfx VooDoo rendering mode setup functions */
+
+
+#ifdef HAVE_CONFIG_H
+#include "conf.h"
+#endif
+
+#if defined(FX)
+#include "fxglidew.h"
+#include "fxdrv.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+FxI32
+FX_grGetInteger_NoLock(FxU32 pname)
+{
+ FxI32 result;
+
+ if (grGet(pname, 4, &result)) {
+ return result;
+ }
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "FX_grGetInteger_NoLock: wrong parameter (%lx)\n", pname);
+ }
+ return -1;
+}
+
+FxBool
+FX_grSstControl(FxU32 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? */
+}
+
+
+int
+FX_grSstScreenWidth()
+{
+ FxI32 result[4];
+
+ BEGIN_BOARD_LOCK();
+ grGet(GR_VIEWPORT, sizeof(FxI32) * 4, result);
+ END_BOARD_LOCK();
+
+ return result[2];
+}
+
+int
+FX_grSstScreenHeight()
+{
+ FxI32 result[4];
+
+ BEGIN_BOARD_LOCK();
+ grGet(GR_VIEWPORT, sizeof(FxI32) * 4, result);
+ END_BOARD_LOCK();
+
+ return result[3];
+}
+
+void
+FX_grSstPerfStats(GrSstPerfStats_t * st)
+{
+ 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_setupGrVertexLayout(void)
+{
+ BEGIN_BOARD_LOCK();
+ grReset(GR_VERTEX_PARAMETER);
+
+ grCoordinateSpace(GR_WINDOW_COORDS);
+ grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
+#if FX_PACKEDCOLOR
+ grVertexLayout(GR_PARAM_PARGB, GR_VERTEX_PARGB_OFFSET << 2, GR_PARAM_ENABLE);
+#else /* !FX_PACKEDCOLOR */
+ grVertexLayout(GR_PARAM_RGB, GR_VERTEX_RGB_OFFSET << 2, GR_PARAM_ENABLE);
+ grVertexLayout(GR_PARAM_A, GR_VERTEX_A_OFFSET << 2, GR_PARAM_ENABLE);
+#endif /* !FX_PACKEDCOLOR */
+ grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
+ grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
+ grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2,
+ GR_PARAM_ENABLE);
+ grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2,
+ GR_PARAM_DISABLE);
+ grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2,
+ GR_PARAM_DISABLE);
+ grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2,
+ GR_PARAM_DISABLE);
+ END_BOARD_LOCK();
+}
+
+void
+FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask)
+{
+ switch (hintType) {
+ case GR_HINT_STWHINT:
+ {
+ if (hintMask & GR_STWHINT_W_DIFF_TMU0)
+ grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2,
+ GR_PARAM_ENABLE);
+ else
+ grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2,
+ GR_PARAM_DISABLE);
+
+ if (hintMask & GR_STWHINT_ST_DIFF_TMU1)
+ grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2,
+ GR_PARAM_ENABLE);
+ else
+ grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2,
+ GR_PARAM_DISABLE);
+
+ if (hintMask & GR_STWHINT_W_DIFF_TMU1)
+ grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2,
+ GR_PARAM_ENABLE);
+ else
+ grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2,
+ GR_PARAM_DISABLE);
+
+ }
+ }
+}
+
+/*
+ * Glide3 doesn't have the grSstQueryHardware function anymore.
+ * Instead, we call grGet() and fill in the data structures ourselves.
+ */
+int
+FX_grSstQueryHardware(GrHwConfiguration * config)
+{
+ int i, j;
+ int numFB;
+
+ BEGIN_BOARD_LOCK();
+
+ grGet(GR_NUM_BOARDS, 4, (void *) &(config->num_sst));
+ if (config->num_sst == 0)
+ return 0;
+
+ for (i = 0; i < config->num_sst; i++) {
+ FxI32 result;
+ const char *extension;
+
+ grSstSelect(i);
+
+ extension = grGetString(GR_HARDWARE);
+ if (strstr(extension, "Rush")) {
+ config->SSTs[i].type = GR_SSTTYPE_SST96;
+ } else if (strstr(extension, "Voodoo2")) {
+ config->SSTs[i].type = GR_SSTTYPE_Voodoo2;
+ } else if (strstr(extension, "Voodoo Banshee")) {
+ config->SSTs[i].type = GR_SSTTYPE_Banshee;
+ } else if (strstr(extension, "Voodoo3")) {
+ config->SSTs[i].type = GR_SSTTYPE_Voodoo3;
+ } else if (strstr(extension, "Voodoo4")) {
+ config->SSTs[i].type = GR_SSTTYPE_Voodoo4;
+ } else if (strstr(extension, "Voodoo5")) {
+ config->SSTs[i].type = GR_SSTTYPE_Voodoo5;
+ } else {
+ config->SSTs[i].type = GR_SSTTYPE_VOODOO;
+ }
+
+ grGet(GR_MEMORY_FB, 4, &result);
+ config->SSTs[i].fbRam = result / (1024 * 1024);
+
+ grGet(GR_NUM_TMU, 4, &result);
+ config->SSTs[i].nTexelfx = result;
+
+ grGet(GR_REVISION_FB, 4, &result);
+ config->SSTs[i].fbiRev = result;
+
+ for (j = 0; j < config->SSTs[i].nTexelfx; j++) {
+ grGet(GR_MEMORY_TMU, 4, &result);
+ config->SSTs[i].tmuConfig[j].tmuRam = result / (1024 * 1024);
+ grGet(GR_REVISION_TMU, 4, &result);
+ config->SSTs[i].tmuConfig[j].tmuRev = result;
+ }
+
+ extension = grGetString(GR_EXTENSION);
+ config->SSTs[i].HavePalExt = (strstr(extension, " PALETTE6666 ") != NULL);
+ config->SSTs[i].HavePixExt = (strstr(extension, " PIXEXT ") != NULL);
+ config->SSTs[i].HaveTexFmt = (strstr(extension, " TEXFMT ") != NULL);
+ config->SSTs[i].HaveCmbExt = (strstr(extension, " COMBINE ") != NULL);
+ config->SSTs[i].HaveMirExt = (strstr(extension, " TEXMIRROR ") != NULL);
+ config->SSTs[i].HaveTexUma = (strstr(extension, " TEXUMA ") != NULL);
+
+ /* number of Voodoo chips */
+ grGet(GR_NUM_FB, 4, (void *) &numFB);
+ config->SSTs[i].numChips = numFB;
+
+ }
+
+ tdfx_hook_glide(&config->Glide, getenv("MESA_FX_POINTCAST") != NULL);
+
+ END_BOARD_LOCK();
+ return 1;
+}
+
+
+
+#else
+
+/*
+ * Need this to provide at least one external definition.
+ */
+
+extern int gl_fx_dummy_function_glidew(void);
+int
+gl_fx_dummy_function_glidew(void)
+{
+ return 0;
+}
+
+#endif /* FX */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxglidew.h b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxglidew.h
new file mode 100644
index 000000000..a19d0b58c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxglidew.h
@@ -0,0 +1,228 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.0
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/* Authors:
+ * David Bucciarelli
+ * Brian Paul
+ * Daryll Strauss
+ * Keith Whitwell
+ * Daniel Borca
+ * Hiroshi Morii
+ */
+
+
+#ifndef __FX_GLIDE_WARPER__
+#define __FX_GLIDE_WARPER__
+
+
+#include "fxg.h"
+
+#ifndef FX_PACKEDCOLOR
+#define FX_PACKEDCOLOR 1
+#endif
+
+#define MAX_NUM_SST 4
+
+enum {
+ GR_SSTTYPE_VOODOO = 0,
+ GR_SSTTYPE_SST96 = 1,
+ GR_SSTTYPE_AT3D = 2,
+ GR_SSTTYPE_Voodoo2 = 3,
+ GR_SSTTYPE_Banshee = 4,
+ GR_SSTTYPE_Voodoo3 = 5,
+ GR_SSTTYPE_Voodoo4 = 6,
+ GR_SSTTYPE_Voodoo5 = 7
+};
+
+#define GrState void
+
+typedef int GrSstType;
+
+typedef struct GrTMUConfig_St {
+ int tmuRev; /* Rev of Texelfx chip */
+ int tmuRam; /* 1, 2, or 4 MB */
+} GrTMUConfig_t;
+
+typedef struct {
+ int num_sst; /* # of HW units in the system */
+ struct SstCard_St {
+ GrSstType type; /* Which hardware is it? */
+ int fbRam; /* 1, 2, or 4 MB */
+ int fbiRev; /* Rev of Pixelfx chip */
+ int nTexelfx; /* How many texelFX chips are there? */
+ int numChips; /* Number of Voodoo chips */
+ GrTMUConfig_t tmuConfig[GLIDE_NUM_TMU]; /* Configuration of the Texelfx chips */
+ /* Glide3 extensions */
+ FxBool HavePalExt; /* PALETTE6666 */
+ FxBool HavePixExt; /* PIXEXT */
+ FxBool HaveTexFmt; /* TEXFMT */
+ FxBool HaveCmbExt; /* COMBINE */
+ FxBool HaveMirExt; /* TEXMIRROR */
+ FxBool HaveTexUma; /* TEXUMA */
+ }
+ SSTs[MAX_NUM_SST]; /* configuration for each board */
+ struct tdfx_glide Glide;
+} GrHwConfiguration;
+
+
+
+typedef FxU32 GrHint_t;
+#define GR_HINTTYPE_MIN 0
+#define GR_HINT_STWHINT 0
+
+typedef FxU32 GrSTWHint_t;
+#define GR_STWHINT_W_DIFF_FBI FXBIT(0)
+#define GR_STWHINT_W_DIFF_TMU0 FXBIT(1)
+#define GR_STWHINT_ST_DIFF_TMU0 FXBIT(2)
+#define GR_STWHINT_W_DIFF_TMU1 FXBIT(3)
+#define GR_STWHINT_ST_DIFF_TMU1 FXBIT(4)
+#define GR_STWHINT_W_DIFF_TMU2 FXBIT(5)
+#define GR_STWHINT_ST_DIFF_TMU2 FXBIT(6)
+
+#define GR_CONTROL_ACTIVATE 1
+#define GR_CONTROL_DEACTIVATE 0
+
+
+
+/*
+** move the vertex layout defintion to application
+*/
+typedef struct {
+ float sow; /* s texture ordinate (s over w) */
+ float tow; /* t texture ordinate (t over w) */
+ float oow; /* 1/w (used mipmapping - really 0xfff/w) */
+} GrTmuVertex;
+
+#if FX_PACKEDCOLOR
+typedef struct {
+ float x, y; /* X and Y in screen space */
+ float ooz; /* 65535/Z (used for Z-buffering) */
+ float oow; /* 1/W (used for W-buffering, texturing) */
+ unsigned char pargb[4]; /* B, G, R, A [0..255] */
+ GrTmuVertex tmuvtx[GLIDE_NUM_TMU];
+ float fog; /* fog coordinate */
+ unsigned char pspec[4]; /* B, G, R, A [0..255] */
+ float psize; /* point size */
+ long pad[16 - 14]; /* ensure 64b structure */
+} GrVertex;
+
+#define GR_VERTEX_X_OFFSET 0
+#define GR_VERTEX_Y_OFFSET 1
+#define GR_VERTEX_OOZ_OFFSET 2
+#define GR_VERTEX_OOW_OFFSET 3
+#define GR_VERTEX_PARGB_OFFSET 4
+#define GR_VERTEX_SOW_TMU0_OFFSET 5
+#define GR_VERTEX_TOW_TMU0_OFFSET 6
+#define GR_VERTEX_OOW_TMU0_OFFSET 7
+#define GR_VERTEX_SOW_TMU1_OFFSET 8
+#define GR_VERTEX_TOW_TMU1_OFFSET 9
+#define GR_VERTEX_OOW_TMU1_OFFSET 10
+#define GR_VERTEX_FOG_OFFSET 11
+#define GR_VERTEX_PSPEC_OFFSET 12
+#else /* !FX_PACKEDCOLOR */
+typedef struct {
+ float x, y; /* X and Y in screen space */
+ float ooz; /* 65535/Z (used for Z-buffering) */
+ float oow; /* 1/W (used for W-buffering, texturing) */
+ float r, g, b, a; /* R, G, B, A [0..255] */
+ GrTmuVertex tmuvtx[GLIDE_NUM_TMU];
+ float fog; /* fog coordinate */
+ float r1, g1, b1; /* R, G, B [0..255] */
+ float psize; /* point size */
+ long pad[20 - 19]; /* ensure multiple of 16 */
+} GrVertex;
+
+#define GR_VERTEX_X_OFFSET 0
+#define GR_VERTEX_Y_OFFSET 1
+#define GR_VERTEX_OOZ_OFFSET 2
+#define GR_VERTEX_OOW_OFFSET 3
+#define GR_VERTEX_RGB_OFFSET 4
+#define GR_VERTEX_A_OFFSET 7
+#define GR_VERTEX_SOW_TMU0_OFFSET 8
+#define GR_VERTEX_TOW_TMU0_OFFSET 9
+#define GR_VERTEX_OOW_TMU0_OFFSET 10
+#define GR_VERTEX_SOW_TMU1_OFFSET 11
+#define GR_VERTEX_TOW_TMU1_OFFSET 12
+#define GR_VERTEX_OOW_TMU1_OFFSET 13
+#define GR_VERTEX_FOG_OFFSET 14
+#define GR_VERTEX_SPEC_OFFSET 15
+#endif /* !FX_PACKEDCOLOR */
+
+
+
+/*
+ * For Lod/LodLog2 conversion.
+ */
+#define FX_largeLodLog2(info) (info).largeLodLog2
+#define FX_aspectRatioLog2(info) (info).aspectRatioLog2
+#define FX_smallLodLog2(info) (info).smallLodLog2
+#define FX_lodToValue(val) ((int)(GR_LOD_LOG2_256-val))
+#define FX_largeLodValue(info) ((int)(GR_LOD_LOG2_256-(info).largeLodLog2))
+#define FX_smallLodValue(info) ((int)(GR_LOD_LOG2_256-(info).smallLodLog2))
+#define FX_valueToLod(val) ((GrLOD_t)(GR_LOD_LOG2_256-val))
+
+
+
+/*
+ * Query
+ */
+extern int FX_grSstScreenWidth(void);
+extern int FX_grSstScreenHeight(void);
+extern void FX_grSstPerfStats(GrSstPerfStats_t *st);
+extern int FX_grSstQueryHardware(GrHwConfiguration *config);
+#define FX_grGetInteger FX_grGetInteger_NoLock
+extern FxI32 FX_grGetInteger_NoLock(FxU32 pname);
+
+
+
+/*
+ * GrHints
+ */
+#define FX_grHints FX_grHints_NoLock
+extern void FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask);
+
+
+
+/*
+ * Needed for Glide3 only, to set up Glide2 compatible vertex layout.
+ */
+extern void FX_setupGrVertexLayout(void);
+
+
+
+/*
+ * grSstControl stuff
+ */
+extern FxBool FX_grSstControl(FxU32 code);
+
+#define FX_grBufferClear(c, a, d) \
+ do { \
+ BEGIN_CLIP_LOOP(); \
+ grBufferClear(c, a, d); \
+ END_CLIP_LOOP(); \
+ } while (0)
+
+
+
+#endif /* __FX_GLIDE_WARPER__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxsetup.c b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxsetup.c
new file mode 100644
index 000000000..360a42f7e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxsetup.c
@@ -0,0 +1,2217 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.0
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/* Authors:
+ * David Bucciarelli
+ * Brian Paul
+ * Daryll Strauss
+ * Keith Whitwell
+ * Daniel Borca
+ * Hiroshi Morii
+ */
+
+/* fxsetup.c - 3Dfx VooDoo rendering mode setup functions */
+
+
+#ifdef HAVE_CONFIG_H
+#include "conf.h"
+#endif
+
+#if defined(FX)
+
+#include "fxdrv.h"
+#include "enums.h"
+#include "tnl.h"
+#include "tnl/t_context.h"
+#include "swrast.h"
+#include "texstore.h"
+
+
+static void
+fxTexValidate(GLcontext * ctx, struct gl_texture_object *tObj)
+{
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+ GLint minl, maxl;
+
+ if (ti->validated) {
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxTexValidate(NOP)\n");
+ }
+ return;
+ }
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxTexValidate(%p (%d))\n", (void *)tObj, tObj->Name);
+ }
+
+ ti->tObj = tObj;
+ minl = ti->minLevel = tObj->BaseLevel;
+ maxl = ti->maxLevel = MIN2(tObj->MaxLevel, tObj->Image[0][0]->MaxLog2);
+
+#if FX_RESCALE_BIG_TEXURES_HACK
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ /* [dBorca]
+ * Fake textures larger than HW supports:
+ * 1) we have mipmaps. Then we just push up to the first supported
+ * LOD. A possible drawback is that Mesa will ignore the skipped
+ * LODs on further texture handling.
+ * Will this interfere with GL_TEXTURE_[MIN|BASE]_LEVEL? How?
+ * 2) we don't have mipmaps. We need to rescale the big LOD in place.
+ * The above approach is somehow dumb! we might have rescaled
+ * once in TexImage2D to accomodate aspect ratio, and now we
+ * are rescaling again. The thing is, in TexImage2D we don't
+ * know whether we'll hit 1) or 2) by the time of validation.
+ */
+ if ((tObj->MinFilter == GL_NEAREST) || (tObj->MinFilter == GL_LINEAR)) {
+ /* no mipmaps! */
+ struct gl_texture_image *texImage = tObj->Image[0][minl];
+ tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+ GLint _w, _h, maxSize = 1 << fxMesa->textureMaxLod;
+ if ((mml->width > maxSize) || (mml->height > maxSize)) {
+ /* need to rescale */
+ GLint texelBytes = texImage->TexFormat->TexelBytes;
+ GLvoid *texImage_Data = texImage->Data;
+ _w = MIN2(texImage->Width, maxSize);
+ _h = MIN2(texImage->Height, maxSize);
+ if (TDFX_DEBUG & VERBOSE_TEXTURE) {
+ fprintf(stderr, "fxTexValidate: rescaling %d x %d -> %d x %d\n",
+ texImage->Width, texImage->Height, _w, _h);
+ }
+ /* we should leave these as is and... (!) */
+ texImage->Width = _w;
+ texImage->Height = _h;
+ fxTexGetInfo(_w, _h, NULL, NULL, NULL, NULL,
+ &(mml->wScale), &(mml->hScale));
+ _w *= mml->wScale;
+ _h *= mml->hScale;
+ texImage->Data = _mesa_malloc(_w * _h * texelBytes);
+ _mesa_rescale_teximage2d(texelBytes,
+ mml->width,
+ _w * texelBytes, /* dst stride */
+ mml->width, mml->height, /* src */
+ _w, _h, /* dst */
+ texImage_Data /*src*/, texImage->Data /*dst*/ );
+ _mesa_free(texImage_Data);
+ mml->width = _w;
+ mml->height = _h;
+ /* (!) ... and set mml->wScale = _w / texImage->Width */
+ }
+ } else {
+ /* mipmapping */
+ if (maxl - minl > fxMesa->textureMaxLod) {
+ /* skip a certain number of LODs */
+ minl += maxl - fxMesa->textureMaxLod;
+ if (TDFX_DEBUG & VERBOSE_TEXTURE) {
+ fprintf(stderr, "fxTexValidate: skipping %d LODs\n", minl - ti->minLevel);
+ }
+ ti->minLevel = tObj->BaseLevel = minl;
+ }
+ }
+}
+#endif
+
+ fxTexGetInfo(tObj->Image[0][minl]->Width, tObj->Image[0][minl]->Height,
+ &(FX_largeLodLog2(ti->info)), &(FX_aspectRatioLog2(ti->info)),
+ &(ti->sScale), &(ti->tScale),
+ NULL, NULL);
+
+ if ((tObj->MinFilter != GL_NEAREST) && (tObj->MinFilter != GL_LINEAR))
+ fxTexGetInfo(tObj->Image[0][maxl]->Width, tObj->Image[0][maxl]->Height,
+ &(FX_smallLodLog2(ti->info)), NULL,
+ NULL, NULL, NULL, NULL);
+ else
+ FX_smallLodLog2(ti->info) = FX_largeLodLog2(ti->info);
+
+ /* [dBorca] this is necessary because of fxDDCompressedTexImage2D */
+ if (ti->padded) {
+ struct gl_texture_image *texImage = tObj->Image[0][minl];
+ tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+ if (mml->wScale != 1 || mml->hScale != 1) {
+ ti->sScale /= mml->wScale;
+ ti->tScale /= mml->hScale;
+ }
+ }
+
+ ti->baseLevelInternalFormat = tObj->Image[0][minl]->Format;
+
+ ti->validated = GL_TRUE;
+
+ ti->info.data = NULL;
+}
+
+static void
+fxPrintUnitsMode(const char *msg, GLuint mode)
+{
+ fprintf(stderr,
+ "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+ msg,
+ mode,
+ (mode & FX_UM_E0_REPLACE) ? "E0_REPLACE, " : "",
+ (mode & FX_UM_E0_MODULATE) ? "E0_MODULATE, " : "",
+ (mode & FX_UM_E0_DECAL) ? "E0_DECAL, " : "",
+ (mode & FX_UM_E0_BLEND) ? "E0_BLEND, " : "",
+ (mode & FX_UM_E1_REPLACE) ? "E1_REPLACE, " : "",
+ (mode & FX_UM_E1_MODULATE) ? "E1_MODULATE, " : "",
+ (mode & FX_UM_E1_DECAL) ? "E1_DECAL, " : "",
+ (mode & FX_UM_E1_BLEND) ? "E1_BLEND, " : "",
+ (mode & FX_UM_E0_ALPHA) ? "E0_ALPHA, " : "",
+ (mode & FX_UM_E0_LUMINANCE) ? "E0_LUMINANCE, " : "",
+ (mode & FX_UM_E0_LUMINANCE_ALPHA) ? "E0_LUMINANCE_ALPHA, " : "",
+ (mode & FX_UM_E0_INTENSITY) ? "E0_INTENSITY, " : "",
+ (mode & FX_UM_E0_RGB) ? "E0_RGB, " : "",
+ (mode & FX_UM_E0_RGBA) ? "E0_RGBA, " : "",
+ (mode & FX_UM_E1_ALPHA) ? "E1_ALPHA, " : "",
+ (mode & FX_UM_E1_LUMINANCE) ? "E1_LUMINANCE, " : "",
+ (mode & FX_UM_E1_LUMINANCE_ALPHA) ? "E1_LUMINANCE_ALPHA, " : "",
+ (mode & FX_UM_E1_INTENSITY) ? "E1_INTENSITY, " : "",
+ (mode & FX_UM_E1_RGB) ? "E1_RGB, " : "",
+ (mode & FX_UM_E1_RGBA) ? "E1_RGBA, " : "",
+ (mode & FX_UM_COLOR_ITERATED) ? "COLOR_ITERATED, " : "",
+ (mode & FX_UM_COLOR_CONSTANT) ? "COLOR_CONSTANT, " : "",
+ (mode & FX_UM_ALPHA_ITERATED) ? "ALPHA_ITERATED, " : "",
+ (mode & FX_UM_ALPHA_CONSTANT) ? "ALPHA_CONSTANT, " : "");
+}
+
+static GLuint
+fxGetTexSetConfiguration(GLcontext * ctx,
+ struct gl_texture_object *tObj0,
+ struct gl_texture_object *tObj1)
+{
+ GLuint unitsmode = 0;
+ GLuint envmode = 0;
+ GLuint ifmt = 0;
+
+ if ((ctx->Light.ShadeModel == GL_SMOOTH) || 1 ||
+ (ctx->Point.SmoothFlag) ||
+ (ctx->Line.SmoothFlag) ||
+ (ctx->Polygon.SmoothFlag)) unitsmode |= FX_UM_ALPHA_ITERATED;
+ else
+ unitsmode |= FX_UM_ALPHA_CONSTANT;
+
+ 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
+ */
+ if (tObj0) {
+ tfxTexInfo *ti0 = fxTMGetTexInfo(tObj0);
+
+ switch (ti0->baseLevelInternalFormat) {
+ case GL_ALPHA:
+ ifmt |= FX_UM_E0_ALPHA;
+ break;
+ case GL_LUMINANCE:
+ ifmt |= FX_UM_E0_LUMINANCE;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ ifmt |= FX_UM_E0_LUMINANCE_ALPHA;
+ break;
+ case GL_INTENSITY:
+ ifmt |= FX_UM_E0_INTENSITY;
+ break;
+ case GL_RGB:
+ ifmt |= FX_UM_E0_RGB;
+ break;
+ case GL_RGBA:
+ ifmt |= FX_UM_E0_RGBA;
+ break;
+ }
+
+ switch (ctx->Texture.Unit[0].EnvMode) {
+ case GL_DECAL:
+ envmode |= FX_UM_E0_DECAL;
+ break;
+ case GL_MODULATE:
+ envmode |= FX_UM_E0_MODULATE;
+ break;
+ case GL_REPLACE:
+ envmode |= FX_UM_E0_REPLACE;
+ break;
+ case GL_BLEND:
+ envmode |= FX_UM_E0_BLEND;
+ break;
+ case GL_ADD:
+ envmode |= FX_UM_E0_ADD;
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+ }
+
+ if (tObj1) {
+ tfxTexInfo *ti1 = fxTMGetTexInfo(tObj1);
+
+ switch (ti1->baseLevelInternalFormat) {
+ case GL_ALPHA:
+ ifmt |= FX_UM_E1_ALPHA;
+ break;
+ case GL_LUMINANCE:
+ ifmt |= FX_UM_E1_LUMINANCE;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ ifmt |= FX_UM_E1_LUMINANCE_ALPHA;
+ break;
+ case GL_INTENSITY:
+ ifmt |= FX_UM_E1_INTENSITY;
+ break;
+ case GL_RGB:
+ ifmt |= FX_UM_E1_RGB;
+ break;
+ case GL_RGBA:
+ ifmt |= FX_UM_E1_RGBA;
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+
+ switch (ctx->Texture.Unit[1].EnvMode) {
+ case GL_DECAL:
+ envmode |= FX_UM_E1_DECAL;
+ break;
+ case GL_MODULATE:
+ envmode |= FX_UM_E1_MODULATE;
+ break;
+ case GL_REPLACE:
+ envmode |= FX_UM_E1_REPLACE;
+ break;
+ case GL_BLEND:
+ envmode |= FX_UM_E1_BLEND;
+ break;
+ case GL_ADD:
+ envmode |= FX_UM_E1_ADD;
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+ }
+
+ unitsmode |= (ifmt | envmode);
+
+ if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE))
+ fxPrintUnitsMode("fxGetTexSetConfiguration", unitsmode);
+
+ return unitsmode;
+}
+
+/************************************************************************/
+/************************* Rendering Mode SetUp *************************/
+/************************************************************************/
+
+/************************* Single Texture Set ***************************/
+
+static void
+fxSetupSingleTMU_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj)
+{
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+ int tmu;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSetupSingleTMU_NoLock(%p (%d))\n", (void *)tObj, tObj->Name);
+ }
+
+ ti->lastTimeUsed = fxMesa->texBindNumber;
+
+ /* Make sure we're not loaded incorrectly */
+ if (ti->isInTM) {
+ if (ti->LODblend) {
+ if (ti->whichTMU != FX_TMU_SPLIT)
+ fxTMMoveOutTM(fxMesa, tObj);
+ }
+ else {
+ if (ti->whichTMU == FX_TMU_SPLIT)
+ fxTMMoveOutTM(fxMesa, tObj);
+ }
+ }
+
+ /* Make sure we're loaded correctly */
+ if (!ti->isInTM) {
+ if (ti->LODblend)
+ fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU_SPLIT);
+ else {
+ if (fxMesa->haveTwoTMUs) {
+ if (fxTMCheckStartAddr(fxMesa, FX_TMU0, ti)) {
+ fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU0);
+ }
+ else {
+ fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU1);
+ }
+ }
+ else
+ fxTMMoveInTM_NoLock(fxMesa, tObj, FX_TMU0);
+ }
+ }
+
+ if (ti->LODblend && ti->whichTMU == FX_TMU_SPLIT) {
+ /* broadcast */
+ if ((ti->info.format == GR_TEXFMT_P_8)
+ && (!fxMesa->haveGlobalPaletteTexture)) {
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSetupSingleTMU_NoLock: uploading texture palette\n");
+ }
+ grTexDownloadTable(ti->paltype, &(ti->palette));
+ }
+
+ grTexClampMode(GR_TMU0, ti->sClamp, ti->tClamp);
+ grTexClampMode(GR_TMU1, ti->sClamp, ti->tClamp);
+ grTexFilterMode(GR_TMU0, ti->minFilt, ti->maxFilt);
+ grTexFilterMode(GR_TMU1, ti->minFilt, ti->maxFilt);
+ grTexMipMapMode(GR_TMU0, ti->mmMode, ti->LODblend);
+ grTexMipMapMode(GR_TMU1, ti->mmMode, ti->LODblend);
+
+ grTexSource(GR_TMU0, ti->tm[FX_TMU0]->startAddr,
+ GR_MIPMAPLEVELMASK_ODD, &(ti->info));
+ grTexSource(GR_TMU1, ti->tm[FX_TMU1]->startAddr,
+ GR_MIPMAPLEVELMASK_EVEN, &(ti->info));
+ }
+ else {
+ if (ti->whichTMU == FX_TMU_BOTH)
+ tmu = FX_TMU0;
+ else
+ tmu = ti->whichTMU;
+
+ /* pointcast */
+ if ((ti->info.format == GR_TEXFMT_P_8)
+ && (!fxMesa->haveGlobalPaletteTexture)) {
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSetupSingleTMU_NoLock: uploading texture palette\n");
+ }
+ fxMesa->Glide.grTexDownloadTableExt(tmu, ti->paltype, &(ti->palette));
+ }
+
+ /* KW: The alternative is to do the download to the other tmu. If
+ * we get to this point, I think it means we are thrashing the
+ * texture memory, so perhaps it's not a good idea.
+ */
+ if (ti->LODblend && (TDFX_DEBUG & VERBOSE_DRIVER)) {
+ fprintf(stderr, "fxSetupSingleTMU_NoLock: not blending texture - only one tmu\n");
+ }
+
+ grTexClampMode(tmu, ti->sClamp, ti->tClamp);
+ grTexFilterMode(tmu, ti->minFilt, ti->maxFilt);
+ grTexMipMapMode(tmu, ti->mmMode, FXFALSE);
+
+ grTexSource(tmu, ti->tm[tmu]->startAddr, GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
+ }
+}
+
+static void
+fxSelectSingleTMUSrc_NoLock(fxMesaContext fxMesa, GLint tmu, FxBool LODblend)
+{
+ struct tdfx_texcombine tex0, tex1;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSelectSingleTMUSrc_NoLock(%d, %d)\n", tmu, LODblend);
+ }
+
+ tex0.InvertRGB = FXFALSE;
+ tex0.InvertAlpha = FXFALSE;
+ tex1.InvertRGB = FXFALSE;
+ tex1.InvertAlpha = FXFALSE;
+
+ if (LODblend) {
+ tex0.FunctionRGB = GR_COMBINE_FUNCTION_BLEND;
+ tex0.FactorRGB = GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION;
+ tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND;
+ tex0.FactorAlpha = GR_COMBINE_FACTOR_ONE_MINUS_LOD_FRACTION;
+
+ tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorRGB = GR_COMBINE_FACTOR_NONE;
+ tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE;
+
+ fxMesa->tmuSrc = FX_TMU_SPLIT;
+ }
+ else {
+ if (tmu != FX_TMU1) {
+ tex0.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ tex0.FactorRGB = GR_COMBINE_FACTOR_NONE;
+ tex0.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ tex0.FactorAlpha = GR_COMBINE_FACTOR_NONE;
+
+ tex1.FunctionRGB = GR_COMBINE_FUNCTION_ZERO;
+ tex1.FactorRGB = GR_COMBINE_FACTOR_NONE;
+ tex1.FunctionAlpha = GR_COMBINE_FUNCTION_ZERO;
+ tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE;
+
+ fxMesa->tmuSrc = FX_TMU0;
+ }
+ else {
+ tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorRGB = GR_COMBINE_FACTOR_NONE;
+ tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE;
+
+ /* correct values to set TMU0 in passthrough mode */
+ tex0.FunctionRGB = GR_COMBINE_FUNCTION_BLEND;
+ tex0.FactorRGB = GR_COMBINE_FACTOR_ONE;
+ tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND;
+ tex0.FactorAlpha = GR_COMBINE_FACTOR_ONE;
+
+ fxMesa->tmuSrc = FX_TMU1;
+ }
+ }
+
+ grTexCombine(GR_TMU0,
+ tex0.FunctionRGB,
+ tex0.FactorRGB,
+ tex0.FunctionAlpha,
+ tex0.FactorAlpha,
+ tex0.InvertRGB,
+ tex0.InvertAlpha);
+ if (fxMesa->haveTwoTMUs) {
+ grTexCombine(GR_TMU1,
+ tex1.FunctionRGB,
+ tex1.FactorRGB,
+ tex1.FunctionAlpha,
+ tex1.FactorAlpha,
+ tex1.InvertRGB,
+ tex1.InvertAlpha);
+ }
+}
+
+static void
+fxSetupTextureSingleTMU_NoLock(GLcontext * ctx, GLuint textureset)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ struct tdfx_combine alphaComb, colorComb;
+ GrCombineLocal_t localc, locala;
+ GLuint unitsmode;
+ GLint ifmt;
+ tfxTexInfo *ti;
+ struct gl_texture_object *tObj = ctx->Texture.Unit[textureset]._Current;
+ int tmu;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSetupTextureSingleTMU_NoLock(%d)\n", textureset);
+ }
+
+ ti = fxTMGetTexInfo(tObj);
+
+ fxTexValidate(ctx, tObj);
+
+ fxSetupSingleTMU_NoLock(fxMesa, tObj);
+
+ if (ti->whichTMU == FX_TMU_BOTH)
+ tmu = FX_TMU0;
+ else
+ tmu = ti->whichTMU;
+ if (fxMesa->tmuSrc != tmu)
+ fxSelectSingleTMUSrc_NoLock(fxMesa, tmu, ti->LODblend);
+
+ if (textureset == 0 || !fxMesa->haveTwoTMUs)
+ unitsmode = fxGetTexSetConfiguration(ctx, tObj, NULL);
+ 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);
+
+ ifmt = ti->baseLevelInternalFormat;
+
+ if (unitsmode & FX_UM_ALPHA_ITERATED)
+ locala = GR_COMBINE_LOCAL_ITERATED;
+ else
+ locala = GR_COMBINE_LOCAL_CONSTANT;
+
+ if (unitsmode & FX_UM_COLOR_ITERATED)
+ localc = GR_COMBINE_LOCAL_ITERATED;
+ else
+ localc = GR_COMBINE_LOCAL_CONSTANT;
+
+ if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE))
+ fprintf(stderr, "fxSetupTextureSingleTMU_NoLock: envmode is %s\n",
+ _mesa_lookup_enum_by_nr(ctx->Texture.Unit[textureset].EnvMode));
+
+ alphaComb.Local = locala;
+ alphaComb.Invert = FXFALSE;
+ colorComb.Local = localc;
+ colorComb.Invert = FXFALSE;
+
+ switch (ctx->Texture.Unit[textureset].EnvMode) {
+ case GL_DECAL:
+ alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ alphaComb.Factor = GR_COMBINE_FACTOR_NONE;
+ alphaComb.Other = GR_COMBINE_OTHER_NONE;
+
+ colorComb.Function = GR_COMBINE_FUNCTION_BLEND;
+ colorComb.Factor = GR_COMBINE_FACTOR_TEXTURE_ALPHA;
+ colorComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ break;
+ case GL_MODULATE:
+ alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL;
+ alphaComb.Other = GR_COMBINE_OTHER_TEXTURE;
+
+ if (ifmt == GL_ALPHA) {
+ colorComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ colorComb.Factor = GR_COMBINE_FACTOR_NONE;
+ colorComb.Other = GR_COMBINE_OTHER_NONE;
+ } else {
+ colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ colorComb.Factor = GR_COMBINE_FACTOR_LOCAL;
+ colorComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ }
+ break;
+ case GL_BLEND:
+ if (ifmt == GL_LUMINANCE || ifmt == GL_RGB) {
+ /* Av = Af */
+ alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ alphaComb.Factor = GR_COMBINE_FACTOR_NONE;
+ alphaComb.Other = GR_COMBINE_OTHER_NONE;
+ }
+ else if (ifmt == GL_INTENSITY) {
+ /* Av = Af * (1 - It) + Ac * It */
+ alphaComb.Function = GR_COMBINE_FUNCTION_BLEND;
+ alphaComb.Factor = GR_COMBINE_FACTOR_TEXTURE_ALPHA;
+ alphaComb.Other = GR_COMBINE_OTHER_CONSTANT;
+ }
+ else {
+ /* Av = Af * At */
+ alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL;
+ alphaComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ }
+
+ if (ifmt == GL_ALPHA) {
+ colorComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ colorComb.Factor = GR_COMBINE_FACTOR_NONE;
+ colorComb.Other = GR_COMBINE_OTHER_NONE;
+ } else {
+ if (fxMesa->type >= GR_SSTTYPE_Voodoo2) {
+ colorComb.Function = GR_COMBINE_FUNCTION_BLEND;
+ colorComb.Factor = GR_COMBINE_FACTOR_TEXTURE_RGB;
+ colorComb.Other = GR_COMBINE_OTHER_CONSTANT;
+ } else if (ifmt == GL_INTENSITY) {
+ /* just a hack: RGB == ALPHA */
+ colorComb.Function = GR_COMBINE_FUNCTION_BLEND;
+ colorComb.Factor = GR_COMBINE_FACTOR_TEXTURE_ALPHA;
+ colorComb.Other = GR_COMBINE_OTHER_CONSTANT;
+ } else {
+ /* Only Voodoo^2 can GL_BLEND (GR_COMBINE_FACTOR_TEXTURE_RGB)
+ * These settings assume that the TexEnv color is black and
+ * incoming fragment color is white.
+ */
+ colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ colorComb.Factor = GR_COMBINE_FACTOR_ONE;
+ colorComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ colorComb.Invert = FXTRUE;
+ _mesa_problem(NULL, "can't GL_BLEND with SST1");
+ }
+ }
+
+ grConstantColorValue(
+ (((GLuint)(ctx->Texture.Unit[textureset].EnvColor[0] * 255.0f)) ) |
+ (((GLuint)(ctx->Texture.Unit[textureset].EnvColor[1] * 255.0f)) << 8) |
+ (((GLuint)(ctx->Texture.Unit[textureset].EnvColor[2] * 255.0f)) << 16) |
+ (((GLuint)(ctx->Texture.Unit[textureset].EnvColor[3] * 255.0f)) << 24));
+ break;
+ case GL_REPLACE:
+ if ((ifmt == GL_RGB) || (ifmt == GL_LUMINANCE)) {
+ alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ alphaComb.Factor = GR_COMBINE_FACTOR_NONE;
+ alphaComb.Other = GR_COMBINE_OTHER_NONE;
+ } else {
+ alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ alphaComb.Factor = GR_COMBINE_FACTOR_ONE;
+ alphaComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ }
+
+ if (ifmt == GL_ALPHA) {
+ colorComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ colorComb.Factor = GR_COMBINE_FACTOR_NONE;
+ colorComb.Other = GR_COMBINE_OTHER_NONE;
+ } else {
+ colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ colorComb.Factor = GR_COMBINE_FACTOR_ONE;
+ colorComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ }
+ break;
+ case GL_ADD:
+ if (ifmt == GL_ALPHA ||
+ ifmt == GL_LUMINANCE_ALPHA ||
+ ifmt == GL_RGBA) {
+ /* product of texel and fragment alpha */
+ alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL;
+ alphaComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ }
+ else if (ifmt == GL_LUMINANCE || ifmt == GL_RGB) {
+ /* fragment alpha is unchanged */
+ alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ alphaComb.Factor = GR_COMBINE_FACTOR_NONE;
+ alphaComb.Other = GR_COMBINE_OTHER_NONE;
+ }
+ else {
+ /* sum of texel and fragment alpha */
+ alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
+ alphaComb.Factor = GR_COMBINE_FACTOR_ONE;
+ alphaComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ }
+
+ if (ifmt == GL_ALPHA) {
+ /* rgb unchanged */
+ colorComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ colorComb.Factor = GR_COMBINE_FACTOR_NONE;
+ colorComb.Other = GR_COMBINE_OTHER_NONE;
+ }
+ else {
+ /* sum of texel and fragment rgb */
+ colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
+ colorComb.Factor = GR_COMBINE_FACTOR_ONE;
+ colorComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ }
+ break;
+ default:
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSetupTextureSingleTMU_NoLock: %x Texture.EnvMode not yet supported\n",
+ ctx->Texture.Unit[textureset].EnvMode);
+ }
+ return;
+ }
+
+ grAlphaCombine(alphaComb.Function,
+ alphaComb.Factor,
+ alphaComb.Local,
+ alphaComb.Other,
+ alphaComb.Invert);
+ grColorCombine(colorComb.Function,
+ colorComb.Factor,
+ colorComb.Local,
+ colorComb.Other,
+ colorComb.Invert);
+}
+
+#if 00
+static void
+fxSetupTextureSingleTMU(GLcontext * ctx, GLuint textureset)
+{
+ BEGIN_BOARD_LOCK();
+ fxSetupTextureSingleTMU_NoLock(ctx, textureset);
+ END_BOARD_LOCK();
+}
+#endif
+
+
+/************************* Double Texture Set ***************************/
+
+static void
+fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa,
+ struct gl_texture_object *tObj0,
+ struct gl_texture_object *tObj1)
+{
+#define T0_NOT_IN_TMU 0x01
+#define T1_NOT_IN_TMU 0x02
+#define T0_IN_TMU0 0x04
+#define T1_IN_TMU0 0x08
+#define T0_IN_TMU1 0x10
+#define T1_IN_TMU1 0x20
+
+ tfxTexInfo *ti0 = fxTMGetTexInfo(tObj0);
+ tfxTexInfo *ti1 = fxTMGetTexInfo(tObj1);
+ GLuint tstate = 0;
+ int tmu0 = 0, tmu1 = 1;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSetupDoubleTMU_NoLock(...)\n");
+ }
+
+ /* We shouldn't need to do this. There is something wrong with
+ mutlitexturing when the TMUs are swapped. So, we're forcing
+ them to always be loaded correctly. !!! */
+ if (ti0->whichTMU == FX_TMU1)
+ fxTMMoveOutTM_NoLock(fxMesa, tObj0);
+ if (ti1->whichTMU == FX_TMU0)
+ fxTMMoveOutTM_NoLock(fxMesa, tObj1);
+
+ if (ti0->isInTM) {
+ switch (ti0->whichTMU) {
+ case FX_TMU0:
+ tstate |= T0_IN_TMU0;
+ break;
+ case FX_TMU1:
+ tstate |= T0_IN_TMU1;
+ break;
+ case FX_TMU_BOTH:
+ tstate |= T0_IN_TMU0 | T0_IN_TMU1;
+ break;
+ case FX_TMU_SPLIT:
+ tstate |= T0_NOT_IN_TMU;
+ break;
+ }
+ }
+ else
+ tstate |= T0_NOT_IN_TMU;
+
+ if (ti1->isInTM) {
+ switch (ti1->whichTMU) {
+ case FX_TMU0:
+ tstate |= T1_IN_TMU0;
+ break;
+ case FX_TMU1:
+ tstate |= T1_IN_TMU1;
+ break;
+ case FX_TMU_BOTH:
+ tstate |= T1_IN_TMU0 | T1_IN_TMU1;
+ break;
+ case FX_TMU_SPLIT:
+ tstate |= T1_NOT_IN_TMU;
+ break;
+ }
+ }
+ else
+ tstate |= T1_NOT_IN_TMU;
+
+ ti0->lastTimeUsed = fxMesa->texBindNumber;
+ ti1->lastTimeUsed = fxMesa->texBindNumber;
+
+ /* Move texture maps into TMUs */
+
+ if (!(((tstate & T0_IN_TMU0) && (tstate & T1_IN_TMU1)) ||
+ ((tstate & T0_IN_TMU1) && (tstate & T1_IN_TMU0)))) {
+ if (tObj0 == tObj1)
+ fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU_BOTH);
+ else {
+ /* Find the minimal way to correct the situation */
+ if ((tstate & T0_IN_TMU0) || (tstate & T1_IN_TMU1)) {
+ /* We have one in the standard order, setup the other */
+ if (tstate & T0_IN_TMU0) { /* T0 is in TMU0, put T1 in TMU1 */
+ fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1);
+ }
+ else {
+ fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0);
+ }
+ /* tmu0 and tmu1 are setup */
+ }
+ else if ((tstate & T0_IN_TMU1) || (tstate & T1_IN_TMU0)) {
+ /* we have one in the reverse order, setup the other */
+ if (tstate & T1_IN_TMU0) { /* T1 is in TMU0, put T0 in TMU1 */
+ fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU1);
+ }
+ else {
+ fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU0);
+ }
+ tmu0 = 1;
+ tmu1 = 0;
+ }
+ else { /* Nothing is loaded */
+ fxTMMoveInTM_NoLock(fxMesa, tObj0, FX_TMU0);
+ fxTMMoveInTM_NoLock(fxMesa, tObj1, FX_TMU1);
+ /* tmu0 and tmu1 are setup */
+ }
+ }
+ }
+
+ /* [dBorca] Hack alert:
+ * we put these in reverse order, so that if we can't
+ * do _REAL_ pointcast, the TMU0 table gets broadcasted
+ */
+ if (!fxMesa->haveGlobalPaletteTexture) {
+ /* pointcast */
+ if (ti1->info.format == GR_TEXFMT_P_8) {
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSetupDoubleTMU_NoLock: uploading texture palette for TMU1\n");
+ }
+ fxMesa->Glide.grTexDownloadTableExt(ti1->whichTMU, ti1->paltype, &(ti1->palette));
+ }
+ if (ti0->info.format == GR_TEXFMT_P_8) {
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSetupDoubleTMU_NoLock: uploading texture palette for TMU0\n");
+ }
+ fxMesa->Glide.grTexDownloadTableExt(ti0->whichTMU, ti0->paltype, &(ti0->palette));
+ }
+ }
+
+ grTexSource(tmu0, ti0->tm[tmu0]->startAddr,
+ GR_MIPMAPLEVELMASK_BOTH, &(ti0->info));
+ grTexClampMode(tmu0, ti0->sClamp, ti0->tClamp);
+ grTexFilterMode(tmu0, ti0->minFilt, ti0->maxFilt);
+ grTexMipMapMode(tmu0, ti0->mmMode, FXFALSE);
+
+ grTexSource(tmu1, ti1->tm[tmu1]->startAddr,
+ GR_MIPMAPLEVELMASK_BOTH, &(ti1->info));
+ grTexClampMode(tmu1, ti1->sClamp, ti1->tClamp);
+ grTexFilterMode(tmu1, ti1->minFilt, ti1->maxFilt);
+ grTexMipMapMode(tmu1, ti1->mmMode, FXFALSE);
+
+#undef T0_NOT_IN_TMU
+#undef T1_NOT_IN_TMU
+#undef T0_IN_TMU0
+#undef T1_IN_TMU0
+#undef T0_IN_TMU1
+#undef T1_IN_TMU1
+}
+
+static void
+fxSetupTextureDoubleTMU_NoLock(GLcontext * ctx)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ struct tdfx_combine alphaComb, colorComb;
+ struct tdfx_texcombine tex0, tex1;
+ GrCombineLocal_t localc, locala;
+ tfxTexInfo *ti0, *ti1;
+ struct gl_texture_object *tObj0 = ctx->Texture.Unit[1]._Current;
+ struct gl_texture_object *tObj1 = ctx->Texture.Unit[0]._Current;
+ GLuint envmode, ifmt, unitsmode;
+ int tmu0 = 0, tmu1 = 1;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSetupTextureDoubleTMU_NoLock(...)\n");
+ }
+
+ ti0 = fxTMGetTexInfo(tObj0);
+ fxTexValidate(ctx, tObj0);
+
+ ti1 = fxTMGetTexInfo(tObj1);
+ fxTexValidate(ctx, tObj1);
+
+ fxSetupDoubleTMU_NoLock(fxMesa, tObj0, tObj1);
+
+ 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);
+
+ envmode = unitsmode & FX_UM_E_ENVMODE;
+ ifmt = unitsmode & FX_UM_E_IFMT;
+
+ if (unitsmode & FX_UM_ALPHA_ITERATED)
+ locala = GR_COMBINE_LOCAL_ITERATED;
+ else
+ locala = GR_COMBINE_LOCAL_CONSTANT;
+
+ if (unitsmode & FX_UM_COLOR_ITERATED)
+ localc = GR_COMBINE_LOCAL_ITERATED;
+ else
+ localc = GR_COMBINE_LOCAL_CONSTANT;
+
+
+ if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE))
+ fprintf(stderr, "fxSetupTextureDoubleTMU_NoLock: envmode is %s/%s\n",
+ _mesa_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode),
+ _mesa_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode));
+
+
+ if ((ti0->whichTMU == FX_TMU1) || (ti1->whichTMU == FX_TMU0)) {
+ tmu0 = 1;
+ tmu1 = 0;
+ }
+ fxMesa->tmuSrc = FX_TMU_BOTH;
+
+ tex0.InvertRGB = FXFALSE;
+ tex0.InvertAlpha = FXFALSE;
+ tex1.InvertRGB = FXFALSE;
+ tex1.InvertAlpha = FXFALSE;
+ alphaComb.Local = locala;
+ alphaComb.Invert = FXFALSE;
+ colorComb.Local = localc;
+ colorComb.Invert = FXFALSE;
+
+ switch (envmode) {
+ case (FX_UM_E0_MODULATE | FX_UM_E1_MODULATE):
+ {
+ GLboolean isalpha[FX_NUM_TMU];
+
+ isalpha[tmu0] = (ti0->baseLevelInternalFormat == GL_ALPHA);
+ isalpha[tmu1] = (ti1->baseLevelInternalFormat == GL_ALPHA);
+
+ if (isalpha[FX_TMU1]) {
+ tex1.FunctionRGB = GR_COMBINE_FUNCTION_ZERO;
+ tex1.FactorRGB = GR_COMBINE_FACTOR_NONE;
+ tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ tex1.InvertRGB = FXTRUE;
+ } else {
+ tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorRGB = GR_COMBINE_FACTOR_NONE;
+ tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ }
+
+ if (isalpha[FX_TMU0]) {
+ tex0.FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ tex0.FactorRGB = GR_COMBINE_FACTOR_ONE;
+ tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ tex0.FactorAlpha = GR_COMBINE_FACTOR_LOCAL;
+ } else {
+ tex0.FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ tex0.FactorRGB = GR_COMBINE_FACTOR_LOCAL;
+ tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ tex0.FactorAlpha = GR_COMBINE_FACTOR_LOCAL;
+ }
+
+ colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ colorComb.Factor = GR_COMBINE_FACTOR_LOCAL;
+ colorComb.Other = GR_COMBINE_OTHER_TEXTURE;
+
+ alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL;
+ alphaComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ break;
+ }
+ case (FX_UM_E0_REPLACE | FX_UM_E1_BLEND): /* Only for GLQuake */
+ if (tmu0 == FX_TMU1) {
+ tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorRGB = GR_COMBINE_FACTOR_NONE;
+ tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ tex1.InvertRGB = FXTRUE;
+
+ tex0.FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ tex0.FactorRGB = GR_COMBINE_FACTOR_LOCAL;
+ tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ tex0.FactorAlpha = GR_COMBINE_FACTOR_LOCAL;
+ }
+ else {
+ tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorRGB = GR_COMBINE_FACTOR_NONE;
+ tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE;
+
+ tex0.FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ tex0.FactorRGB = GR_COMBINE_FACTOR_ONE_MINUS_LOCAL;
+ tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ tex0.FactorAlpha = GR_COMBINE_FACTOR_ONE_MINUS_LOCAL;
+ }
+
+ alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ alphaComb.Factor = GR_COMBINE_FACTOR_NONE;
+ alphaComb.Other = GR_COMBINE_OTHER_NONE;
+
+ colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ colorComb.Factor = GR_COMBINE_FACTOR_ONE;
+ colorComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ break;
+ case (FX_UM_E0_REPLACE | FX_UM_E1_MODULATE): /* Quake 2 and 3 */
+ if (tmu1 == FX_TMU1) {
+ tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorRGB = GR_COMBINE_FACTOR_NONE;
+ tex1.FunctionAlpha = GR_COMBINE_FUNCTION_ZERO;
+ tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ tex1.InvertAlpha = FXTRUE;
+
+ tex0.FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ tex0.FactorRGB = GR_COMBINE_FACTOR_LOCAL;
+ tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ tex0.FactorAlpha = GR_COMBINE_FACTOR_LOCAL;
+ }
+ else {
+ tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorRGB = GR_COMBINE_FACTOR_NONE;
+ tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE;
+
+ tex0.FunctionRGB = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ tex0.FactorRGB = GR_COMBINE_FACTOR_LOCAL;
+ tex0.FunctionAlpha = GR_COMBINE_FUNCTION_BLEND_OTHER;
+ tex0.FactorAlpha = GR_COMBINE_FACTOR_ONE;
+ }
+
+ if (ti0->baseLevelInternalFormat == GL_RGB) {
+ alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ alphaComb.Factor = GR_COMBINE_FACTOR_NONE;
+ alphaComb.Other = GR_COMBINE_OTHER_NONE;
+ } else {
+ alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ alphaComb.Factor = GR_COMBINE_FACTOR_ONE;
+ alphaComb.Other = GR_COMBINE_OTHER_NONE;
+ }
+
+ colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ colorComb.Factor = GR_COMBINE_FACTOR_ONE;
+ colorComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ break;
+
+
+ case (FX_UM_E0_MODULATE | FX_UM_E1_ADD): /* Quake 3 Sky */
+ {
+ GLboolean isalpha[FX_NUM_TMU];
+
+ isalpha[tmu0] = (ti0->baseLevelInternalFormat == GL_ALPHA);
+ isalpha[tmu1] = (ti1->baseLevelInternalFormat == GL_ALPHA);
+
+ if (isalpha[FX_TMU1]) {
+ tex1.FunctionRGB = GR_COMBINE_FUNCTION_ZERO;
+ tex1.FactorRGB = GR_COMBINE_FACTOR_NONE;
+ tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ tex1.InvertRGB = FXTRUE;
+ } else {
+ tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorRGB = GR_COMBINE_FACTOR_NONE;
+ tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ }
+
+ if (isalpha[FX_TMU0]) {
+ tex0.FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ tex0.FactorRGB = GR_COMBINE_FACTOR_ONE;
+ tex0.FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
+ tex0.FactorAlpha = GR_COMBINE_FACTOR_ONE;
+ } else {
+ tex0.FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
+ tex0.FactorRGB = GR_COMBINE_FACTOR_ONE;
+ tex0.FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
+ tex0.FactorAlpha = GR_COMBINE_FACTOR_ONE;
+ }
+
+ colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ colorComb.Factor = GR_COMBINE_FACTOR_LOCAL;
+ colorComb.Other = GR_COMBINE_OTHER_TEXTURE;
+
+ alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ alphaComb.Factor = GR_COMBINE_FACTOR_LOCAL;
+ alphaComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ break;
+ }
+
+ case (FX_UM_E0_REPLACE | FX_UM_E1_ADD): /* Vulpine Sky */
+ {
+ GLboolean isalpha[FX_NUM_TMU];
+
+ isalpha[tmu0] = (ti0->baseLevelInternalFormat == GL_ALPHA);
+ isalpha[tmu1] = (ti1->baseLevelInternalFormat == GL_ALPHA);
+
+ if (isalpha[FX_TMU1]) {
+ tex1.FunctionRGB = GR_COMBINE_FUNCTION_ZERO;
+ tex1.FactorRGB = GR_COMBINE_FACTOR_NONE;
+ tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ tex1.InvertRGB = FXTRUE;
+ } else {
+ tex1.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorRGB = GR_COMBINE_FACTOR_NONE;
+ tex1.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE;
+ }
+
+ if (isalpha[FX_TMU0]) {
+ tex0.FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ tex0.FactorRGB = GR_COMBINE_FACTOR_ONE;
+ tex0.FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
+ tex0.FactorAlpha = GR_COMBINE_FACTOR_ONE;
+ } else {
+ tex0.FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
+ tex0.FactorRGB = GR_COMBINE_FACTOR_ONE;
+ tex0.FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
+ tex0.FactorAlpha = GR_COMBINE_FACTOR_ONE;
+ }
+
+ colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ colorComb.Factor = GR_COMBINE_FACTOR_ONE;
+ colorComb.Other = GR_COMBINE_OTHER_TEXTURE;
+
+ alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ alphaComb.Factor = GR_COMBINE_FACTOR_ONE;
+ alphaComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ break;
+ }
+
+ case (FX_UM_E0_MODULATE | FX_UM_E1_REPLACE): /* Homeworld2 */
+ {
+ tex1.FunctionRGB = GR_COMBINE_FUNCTION_ZERO;
+ tex1.FactorRGB = GR_COMBINE_FACTOR_NONE;
+ tex1.FunctionAlpha = GR_COMBINE_FUNCTION_ZERO;
+ tex1.FactorAlpha = GR_COMBINE_FACTOR_NONE;
+
+ tex0.FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
+ tex0.FactorRGB = GR_COMBINE_FACTOR_NONE;
+ tex0.FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
+ tex0.FactorAlpha = GR_COMBINE_FACTOR_NONE;
+
+ if (ifmt & (FX_UM_E0_RGB | FX_UM_E0_LUMINANCE)) {
+ alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ alphaComb.Factor = GR_COMBINE_FACTOR_NONE;
+ alphaComb.Other = GR_COMBINE_OTHER_NONE;
+ } else {
+ alphaComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ alphaComb.Factor = GR_COMBINE_FACTOR_ONE;
+ alphaComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ }
+
+ if (ifmt & FX_UM_E0_ALPHA) {
+ colorComb.Function = GR_COMBINE_FUNCTION_LOCAL;
+ colorComb.Factor = GR_COMBINE_FACTOR_NONE;
+ colorComb.Other = GR_COMBINE_OTHER_NONE;
+ } else {
+ colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
+ colorComb.Factor = GR_COMBINE_FACTOR_ONE;
+ colorComb.Other = GR_COMBINE_OTHER_TEXTURE;
+ }
+ break;
+ }
+ default:
+ fprintf(stderr, "fxSetupTextureDoubleTMU_NoLock: Unexpected dual texture mode encountered\n");
+ return;
+ }
+
+ grAlphaCombine(alphaComb.Function,
+ alphaComb.Factor,
+ alphaComb.Local,
+ alphaComb.Other,
+ alphaComb.Invert);
+ grColorCombine(colorComb.Function,
+ colorComb.Factor,
+ colorComb.Local,
+ colorComb.Other,
+ colorComb.Invert);
+ grTexCombine(GR_TMU0,
+ tex0.FunctionRGB,
+ tex0.FactorRGB,
+ tex0.FunctionAlpha,
+ tex0.FactorAlpha,
+ tex0.InvertRGB,
+ tex0.InvertAlpha);
+ grTexCombine(GR_TMU1,
+ tex1.FunctionRGB,
+ tex1.FactorRGB,
+ tex1.FunctionAlpha,
+ tex1.FactorAlpha,
+ tex1.InvertRGB,
+ tex1.InvertAlpha);
+}
+
+/************************* No Texture ***************************/
+
+static void
+fxSetupTextureNone_NoLock(GLcontext * ctx)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrCombineLocal_t localc, locala;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSetupTextureNone_NoLock(...)\n");
+ }
+
+ if ((ctx->Light.ShadeModel == GL_SMOOTH) || 1 ||
+ (ctx->Point.SmoothFlag) ||
+ (ctx->Line.SmoothFlag) ||
+ (ctx->Polygon.SmoothFlag)) locala = GR_COMBINE_LOCAL_ITERATED;
+ else
+ locala = GR_COMBINE_LOCAL_CONSTANT;
+
+ if (ctx->Light.ShadeModel == GL_SMOOTH || 1)
+ localc = GR_COMBINE_LOCAL_ITERATED;
+ else
+ localc = GR_COMBINE_LOCAL_CONSTANT;
+
+ grAlphaCombine(GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ locala,
+ GR_COMBINE_OTHER_NONE,
+ FXFALSE);
+
+ grColorCombine(GR_COMBINE_FUNCTION_LOCAL,
+ GR_COMBINE_FACTOR_NONE,
+ localc,
+ GR_COMBINE_OTHER_NONE,
+ FXFALSE);
+
+ fxMesa->lastUnitsMode = FX_UM_NONE;
+}
+
+#include "fxsetup.h"
+
+/************************************************************************/
+/************************** Texture Mode SetUp **************************/
+/************************************************************************/
+
+static void
+fxSetupTexture_NoLock(GLcontext * ctx)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSetupTexture_NoLock(...)\n");
+ }
+
+ if (fxMesa->HaveCmbExt) {
+ /* Texture Combine, Color Combine and Alpha Combine. */
+ if ((ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) &&
+ (ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) &&
+ fxMesa->haveTwoTMUs) {
+ fxSetupTextureDoubleTMUNapalm_NoLock(ctx);
+ }
+ else if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) {
+ fxSetupTextureSingleTMUNapalm_NoLock(ctx, 0);
+ }
+ else if (ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) {
+ fxSetupTextureSingleTMUNapalm_NoLock(ctx, 1);
+ }
+ else {
+ fxSetupTextureNoneNapalm_NoLock(ctx);
+ }
+ } else {
+ /* Texture Combine, Color Combine and Alpha Combine. */
+ if ((ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) &&
+ (ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) &&
+ fxMesa->haveTwoTMUs) {
+ fxSetupTextureDoubleTMU_NoLock(ctx);
+ }
+ else if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) {
+ fxSetupTextureSingleTMU_NoLock(ctx, 0);
+ }
+ else if (ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) {
+ fxSetupTextureSingleTMU_NoLock(ctx, 1);
+ }
+ else {
+ fxSetupTextureNone_NoLock(ctx);
+ }
+ }
+}
+
+void
+fxSetupTexture(GLcontext * ctx)
+{
+ BEGIN_BOARD_LOCK();
+ fxSetupTexture_NoLock(ctx);
+ END_BOARD_LOCK();
+}
+
+/************************************************************************/
+/**************************** Blend SetUp *******************************/
+/************************************************************************/
+
+void
+fxDDBlendFuncSeparate(GLcontext * ctx, GLenum sfactor, GLenum dfactor, GLenum asfactor, GLenum adfactor)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
+ GLboolean isNapalm = (fxMesa->type >= GR_SSTTYPE_Voodoo4);
+ GLboolean have32bpp = (fxMesa->colDepth == 32);
+ GLboolean haveAlpha = fxMesa->haveHwAlpha;
+ GrAlphaBlendFnc_t sfact, dfact, asfact, adfact;
+
+ /*
+ * 15/16 BPP alpha channel alpha blending modes
+ * 0x0 AZERO Zero
+ * 0x4 AONE One
+ *
+ * 32 BPP alpha channel alpha blending modes
+ * 0x0 AZERO Zero
+ * 0x1 ASRC_ALPHA Source alpha
+ * 0x3 ADST_ALPHA Destination alpha
+ * 0x4 AONE One
+ * 0x5 AOMSRC_ALPHA 1 - Source alpha
+ * 0x7 AOMDST_ALPHA 1 - Destination alpha
+ *
+ * If we don't have HW alpha buffer:
+ * DST_ALPHA == 1
+ * ONE_MINUS_DST_ALPHA == 0
+ * Unsupported modes are:
+ * 1 if used as src blending factor
+ * 0 if used as dst blending factor
+ */
+
+ switch (sfactor) {
+ case GL_ZERO:
+ sfact = GR_BLEND_ZERO;
+ break;
+ case GL_ONE:
+ sfact = GR_BLEND_ONE;
+ break;
+ case GL_DST_COLOR:
+ sfact = GR_BLEND_DST_COLOR;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ sfact = GR_BLEND_ONE_MINUS_DST_COLOR;
+ break;
+ case GL_SRC_ALPHA:
+ sfact = GR_BLEND_SRC_ALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ sfact = GR_BLEND_ONE_MINUS_SRC_ALPHA;
+ break;
+ case GL_DST_ALPHA:
+ sfact = haveAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*bad*/;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ sfact = haveAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*bad*/;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ sfact = GR_BLEND_ALPHA_SATURATE;
+ break;
+ case GL_SRC_COLOR:
+ if (isNapalm) {
+ sfact = GR_BLEND_SAME_COLOR_EXT;
+ break;
+ }
+ case GL_ONE_MINUS_SRC_COLOR:
+ if (isNapalm) {
+ sfact = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT;
+ break;
+ }
+ default:
+ sfact = GR_BLEND_ONE;
+ break;
+ }
+
+ switch (asfactor) {
+ case GL_ZERO:
+ asfact = GR_BLEND_ZERO;
+ break;
+ case GL_ONE:
+ asfact = GR_BLEND_ONE;
+ break;
+ case GL_SRC_COLOR:
+ case GL_SRC_ALPHA:
+ asfact = have32bpp ? GR_BLEND_SRC_ALPHA : GR_BLEND_ONE/*bad*/;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ asfact = have32bpp ? GR_BLEND_ONE_MINUS_SRC_ALPHA : GR_BLEND_ONE/*bad*/;
+ break;
+ case GL_DST_COLOR:
+ case GL_DST_ALPHA:
+ asfact = (have32bpp && haveAlpha) ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*bad*/;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ case GL_ONE_MINUS_DST_ALPHA:
+ asfact = (have32bpp && haveAlpha) ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*bad*/;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ asfact = GR_BLEND_ONE;
+ break;
+ default:
+ asfact = GR_BLEND_ONE;
+ break;
+ }
+
+ switch (dfactor) {
+ case GL_ZERO:
+ dfact = GR_BLEND_ZERO;
+ break;
+ case GL_ONE:
+ dfact = GR_BLEND_ONE;
+ break;
+ case GL_SRC_COLOR:
+ dfact = GR_BLEND_SRC_COLOR;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ dfact = GR_BLEND_ONE_MINUS_SRC_COLOR;
+ break;
+ case GL_SRC_ALPHA:
+ dfact = GR_BLEND_SRC_ALPHA;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ dfact = GR_BLEND_ONE_MINUS_SRC_ALPHA;
+ break;
+ case GL_DST_ALPHA:
+ dfact = haveAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*bad*/;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ dfact = haveAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*bad*/;
+ break;
+ case GL_DST_COLOR:
+ if (isNapalm) {
+ dfact = GR_BLEND_SAME_COLOR_EXT;
+ break;
+ }
+ case GL_ONE_MINUS_DST_COLOR:
+ if (isNapalm) {
+ dfact = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT;
+ break;
+ }
+ default:
+ dfact = GR_BLEND_ZERO;
+ break;
+ }
+
+ switch (adfactor) {
+ case GL_ZERO:
+ adfact = GR_BLEND_ZERO;
+ break;
+ case GL_ONE:
+ adfact = GR_BLEND_ONE;
+ break;
+ case GL_SRC_COLOR:
+ case GL_SRC_ALPHA:
+ adfact = have32bpp ? GR_BLEND_SRC_ALPHA : GR_BLEND_ZERO/*bad*/;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ adfact = have32bpp ? GR_BLEND_ONE_MINUS_SRC_ALPHA : GR_BLEND_ZERO/*bad*/;
+ break;
+ case GL_DST_COLOR:
+ case GL_DST_ALPHA:
+ adfact = (have32bpp && haveAlpha) ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*bad*/;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ case GL_ONE_MINUS_DST_ALPHA:
+ adfact = (have32bpp && haveAlpha) ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*bad*/;
+ break;
+ default:
+ adfact = GR_BLEND_ZERO;
+ break;
+ }
+
+ if ((sfact != us->blendSrcFuncRGB) || (asfact != us->blendSrcFuncAlpha)) {
+ us->blendSrcFuncRGB = sfact;
+ us->blendSrcFuncAlpha = asfact;
+ fxMesa->new_state |= FX_NEW_BLEND;
+ }
+
+ if ((dfact != us->blendDstFuncRGB) || (adfact != us->blendDstFuncAlpha)) {
+ us->blendDstFuncRGB = dfact;
+ us->blendDstFuncAlpha = adfact;
+ fxMesa->new_state |= FX_NEW_BLEND;
+ }
+}
+
+void
+fxDDBlendEquationSeparate(GLcontext * ctx, GLenum modeRGB, GLenum modeA)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
+ GrAlphaBlendOp_t q;
+
+ switch (modeRGB) {
+ case GL_FUNC_ADD:
+ q = GR_BLEND_OP_ADD;
+ break;
+ case GL_FUNC_SUBTRACT:
+ q = GR_BLEND_OP_SUB;
+ break;
+ case GL_FUNC_REVERSE_SUBTRACT:
+ q = GR_BLEND_OP_REVSUB;
+ break;
+ default:
+ q = us->blendEqRGB;
+ }
+ if (q != us->blendEqRGB) {
+ us->blendEqRGB = q;
+ fxMesa->new_state |= FX_NEW_BLEND;
+ }
+
+ switch (modeA) {
+ case GL_FUNC_ADD:
+ q = GR_BLEND_OP_ADD;
+ break;
+ case GL_FUNC_SUBTRACT:
+ q = GR_BLEND_OP_SUB;
+ break;
+ case GL_FUNC_REVERSE_SUBTRACT:
+ q = GR_BLEND_OP_REVSUB;
+ break;
+ default:
+ q = us->blendEqAlpha;
+ }
+ if (q != us->blendEqAlpha) {
+ us->blendEqAlpha = q;
+ fxMesa->new_state |= FX_NEW_BLEND;
+ }
+}
+
+void
+fxSetupBlend(GLcontext * ctx)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
+
+ if (fxMesa->HavePixExt) {
+ if (us->blendEnabled) {
+ fxMesa->Glide.grAlphaBlendFunctionExt(us->blendSrcFuncRGB, us->blendDstFuncRGB,
+ us->blendEqRGB,
+ us->blendSrcFuncAlpha, us->blendDstFuncAlpha,
+ us->blendEqAlpha);
+ } else {
+ fxMesa->Glide.grAlphaBlendFunctionExt(GR_BLEND_ONE, GR_BLEND_ZERO,
+ GR_BLEND_OP_ADD,
+ GR_BLEND_ONE, GR_BLEND_ZERO,
+ GR_BLEND_OP_ADD);
+ }
+ } else {
+ if (us->blendEnabled) {
+ grAlphaBlendFunction(us->blendSrcFuncRGB, us->blendDstFuncRGB,
+ us->blendSrcFuncAlpha, us->blendDstFuncAlpha);
+ } else {
+ grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO,
+ GR_BLEND_ONE, GR_BLEND_ZERO);
+ }
+ }
+}
+
+/************************************************************************/
+/************************** Alpha Test SetUp ****************************/
+/************************************************************************/
+
+void
+fxDDAlphaFunc(GLcontext * ctx, GLenum func, GLfloat ref)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
+
+ if (
+ (us->alphaTestFunc != func)
+ ||
+ (us->alphaTestRefValue != ref)
+ ) {
+ us->alphaTestFunc = func;
+ us->alphaTestRefValue = ref;
+ fxMesa->new_state |= FX_NEW_ALPHA;
+ }
+}
+
+static void
+fxSetupAlphaTest(GLcontext * ctx)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
+
+ if (us->alphaTestEnabled) {
+ GrAlpha_t ref = (GLint) (us->alphaTestRefValue * 255.0);
+ grAlphaTestFunction(us->alphaTestFunc - GL_NEVER + GR_CMP_NEVER);
+ grAlphaTestReferenceValue(ref);
+ }
+ else
+ grAlphaTestFunction(GR_CMP_ALWAYS);
+}
+
+/************************************************************************/
+/************************** Depth Test SetUp ****************************/
+/************************************************************************/
+
+void
+fxDDDepthFunc(GLcontext * ctx, GLenum func)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
+
+ if (us->depthTestFunc != func) {
+ us->depthTestFunc = func;
+ fxMesa->new_state |= FX_NEW_DEPTH;
+ }
+}
+
+void
+fxDDDepthMask(GLcontext * ctx, GLboolean flag)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
+
+ if (flag != us->depthMask) {
+ us->depthMask = flag;
+ fxMesa->new_state |= FX_NEW_DEPTH;
+ }
+}
+
+void
+fxSetupDepthTest(GLcontext * ctx)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
+
+ if (us->depthTestEnabled) {
+ grDepthBufferFunction(us->depthTestFunc - GL_NEVER + GR_CMP_NEVER);
+ grDepthMask(us->depthMask);
+ }
+ else {
+ grDepthBufferFunction(GR_CMP_ALWAYS);
+ grDepthMask(FXFALSE);
+ }
+}
+
+/************************************************************************/
+/************************** Stencil SetUp *******************************/
+/************************************************************************/
+
+static GrStencil_t convertGLStencilOp( 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;
+ case GL_INCR_WRAP_EXT:
+ return GR_STENCILOP_INCR_WRAP;
+ case GL_DECR_WRAP_EXT:
+ return GR_STENCILOP_DECR_WRAP;
+ default:
+ _mesa_problem( NULL, "bad stencil op in convertGLStencilOp" );
+ }
+ return GR_STENCILOP_KEEP; /* never get, silence compiler warning */
+}
+
+void
+fxDDStencilFunc (GLcontext *ctx, GLenum func, GLint ref, GLuint mask)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
+
+ if (ctx->Stencil.ActiveFace) {
+ return;
+ }
+
+ if (
+ (us->stencilFunction != func)
+ ||
+ (us->stencilRefValue != ref)
+ ||
+ (us->stencilValueMask != mask)
+ ) {
+ us->stencilFunction = func;
+ us->stencilRefValue = ref;
+ us->stencilValueMask = mask;
+ fxMesa->new_state |= FX_NEW_STENCIL;
+ }
+}
+
+void
+fxDDStencilMask (GLcontext *ctx, GLuint mask)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
+
+ if (ctx->Stencil.ActiveFace) {
+ return;
+ }
+
+ if (us->stencilWriteMask != mask) {
+ us->stencilWriteMask = mask;
+ fxMesa->new_state |= FX_NEW_STENCIL;
+ }
+}
+
+void
+fxDDStencilOp (GLcontext *ctx, GLenum sfail, GLenum zfail, GLenum zpass)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
+
+ if (ctx->Stencil.ActiveFace) {
+ return;
+ }
+
+ if (
+ (us->stencilFailFunc != sfail)
+ ||
+ (us->stencilZFailFunc != zfail)
+ ||
+ (us->stencilZPassFunc != zpass)
+ ) {
+ us->stencilFailFunc = sfail;
+ us->stencilZFailFunc = zfail;
+ us->stencilZPassFunc = zpass;
+ fxMesa->new_state |= FX_NEW_STENCIL;
+ }
+}
+
+void
+fxSetupStencil (GLcontext * ctx)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
+
+ if (us->stencilEnabled) {
+ GrCmpFnc_t stencilFailFunc = GR_STENCILOP_KEEP;
+ GrCmpFnc_t stencilZFailFunc = GR_STENCILOP_KEEP;
+ GrCmpFnc_t stencilZPassFunc = GR_STENCILOP_KEEP;
+ if (!fxMesa->multipass) {
+ stencilFailFunc = convertGLStencilOp(us->stencilFailFunc);
+ stencilZFailFunc = convertGLStencilOp(us->stencilZFailFunc);
+ stencilZPassFunc = convertGLStencilOp(us->stencilZPassFunc);
+ }
+ grEnable(GR_STENCIL_MODE_EXT);
+ fxMesa->Glide.grStencilOpExt(stencilFailFunc,
+ stencilZFailFunc,
+ stencilZPassFunc);
+ fxMesa->Glide.grStencilFuncExt(us->stencilFunction - GL_NEVER + GR_CMP_NEVER,
+ us->stencilRefValue,
+ us->stencilValueMask);
+ fxMesa->Glide.grStencilMaskExt(us->stencilWriteMask);
+ } else {
+ grDisable(GR_STENCIL_MODE_EXT);
+ }
+}
+
+void
+fxSetupStencilFace (GLcontext * ctx, GLint face)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
+
+ if (us->stencilEnabled) {
+ GrCmpFnc_t stencilFailFunc = GR_STENCILOP_KEEP;
+ GrCmpFnc_t stencilZFailFunc = GR_STENCILOP_KEEP;
+ GrCmpFnc_t stencilZPassFunc = GR_STENCILOP_KEEP;
+ if (!fxMesa->multipass) {
+ stencilFailFunc = convertGLStencilOp(ctx->Stencil.FailFunc[face]);
+ stencilZFailFunc = convertGLStencilOp(ctx->Stencil.ZFailFunc[face]);
+ stencilZPassFunc = convertGLStencilOp(ctx->Stencil.ZPassFunc[face]);
+ }
+ grEnable(GR_STENCIL_MODE_EXT);
+ fxMesa->Glide.grStencilOpExt(stencilFailFunc,
+ stencilZFailFunc,
+ stencilZPassFunc);
+ fxMesa->Glide.grStencilFuncExt(ctx->Stencil.Function[face] - GL_NEVER + GR_CMP_NEVER,
+ ctx->Stencil.Ref[face],
+ ctx->Stencil.ValueMask[face]);
+ fxMesa->Glide.grStencilMaskExt(ctx->Stencil.WriteMask[face]);
+ } else {
+ grDisable(GR_STENCIL_MODE_EXT);
+ }
+}
+
+/************************************************************************/
+/**************************** Color Mask SetUp **************************/
+/************************************************************************/
+
+void
+fxDDColorMask(GLcontext * ctx,
+ GLboolean r, GLboolean g, GLboolean b, GLboolean a)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ fxMesa->new_state |= FX_NEW_COLOR_MASK;
+ (void) r;
+ (void) g;
+ (void) b;
+ (void) a;
+}
+
+void
+fxSetupColorMask(GLcontext * ctx)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ if (fxMesa->colDepth == 32) {
+ /* 32bpp mode */
+ fxMesa->Glide.grColorMaskExt(ctx->Color.ColorMask[RCOMP],
+ ctx->Color.ColorMask[GCOMP],
+ ctx->Color.ColorMask[BCOMP],
+ ctx->Color.ColorMask[ACOMP] && fxMesa->haveHwAlpha);
+ }
+ else {
+ /* 15/16 bpp mode */
+ grColorMask(ctx->Color.ColorMask[RCOMP] |
+ ctx->Color.ColorMask[GCOMP] |
+ ctx->Color.ColorMask[BCOMP],
+ ctx->Color.ColorMask[ACOMP] && fxMesa->haveHwAlpha);
+ }
+}
+
+
+
+
+/************************************************************************/
+/**************************** Fog Mode SetUp ****************************/
+/************************************************************************/
+
+/*
+ * This is called during state update in order to update the Glide fog state.
+ */
+static void
+fxSetupFog(GLcontext * ctx)
+{
+ if (ctx->Fog.Enabled /*&& ctx->FogMode==FOG_FRAGMENT */ ) {
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ /* update fog color */
+ GLubyte col[4];
+ col[0] = (unsigned int) (255 * ctx->Fog.Color[0]);
+ col[1] = (unsigned int) (255 * ctx->Fog.Color[1]);
+ col[2] = (unsigned int) (255 * ctx->Fog.Color[2]);
+ col[3] = (unsigned int) (255 * ctx->Fog.Color[3]);
+ grFogColorValue(FXCOLOR4(col));
+
+ if (fxMesa->fogTableMode != ctx->Fog.Mode ||
+ fxMesa->fogDensity != ctx->Fog.Density ||
+ fxMesa->fogStart != ctx->Fog.Start ||
+ fxMesa->fogEnd != ctx->Fog.End) {
+ /* reload the fog table */
+ switch (ctx->Fog.Mode) {
+ case GL_LINEAR:
+ guFogGenerateLinear(fxMesa->fogTable, ctx->Fog.Start,
+ ctx->Fog.End);
+ if (fxMesa->fogTable[0] > 63) {
+ /* [dBorca] Hack alert:
+ * As per Glide3 Programming Guide:
+ * The difference between consecutive fog values
+ * must be less than 64.
+ */
+ fxMesa->fogTable[0] = 63;
+ }
+ break;
+ case GL_EXP:
+ guFogGenerateExp(fxMesa->fogTable, ctx->Fog.Density);
+ break;
+ case GL_EXP2:
+ guFogGenerateExp2(fxMesa->fogTable, ctx->Fog.Density);
+ break;
+ default:
+ ;
+ }
+ fxMesa->fogTableMode = ctx->Fog.Mode;
+ fxMesa->fogDensity = ctx->Fog.Density;
+ fxMesa->fogStart = ctx->Fog.Start;
+ fxMesa->fogEnd = ctx->Fog.End;
+ }
+
+ grFogTable(fxMesa->fogTable);
+ if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) {
+ grVertexLayout(GR_PARAM_FOG_EXT, GR_VERTEX_FOG_OFFSET << 2,
+ GR_PARAM_ENABLE);
+ grFogMode(GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT);
+ } else {
+ grVertexLayout(GR_PARAM_FOG_EXT, GR_VERTEX_FOG_OFFSET << 2,
+ GR_PARAM_DISABLE);
+ grFogMode(GR_FOG_WITH_TABLE_ON_Q);
+ }
+ }
+ else {
+ grFogMode(GR_FOG_DISABLE);
+ }
+}
+
+void
+fxDDFogfv(GLcontext * ctx, GLenum pname, const GLfloat * params)
+{
+ FX_CONTEXT(ctx)->new_state |= FX_NEW_FOG;
+ switch (pname) {
+ case GL_FOG_COORDINATE_SOURCE_EXT: {
+ GLenum p = (GLenum)*params;
+ if (p == GL_FOG_COORDINATE_EXT) {
+ _swrast_allow_vertex_fog(ctx, GL_TRUE);
+ _swrast_allow_pixel_fog(ctx, GL_FALSE);
+ _tnl_allow_vertex_fog( ctx, GL_TRUE);
+ _tnl_allow_pixel_fog( ctx, GL_FALSE);
+ } else {
+ _swrast_allow_vertex_fog(ctx, GL_FALSE);
+ _swrast_allow_pixel_fog(ctx, GL_TRUE);
+ _tnl_allow_vertex_fog( ctx, GL_FALSE);
+ _tnl_allow_pixel_fog( ctx, GL_TRUE);
+ }
+ break;
+ }
+ default:
+ ;
+ }
+}
+
+/************************************************************************/
+/************************** Scissor Test SetUp **************************/
+/************************************************************************/
+
+/* This routine is used in managing the lock state, and therefore can't lock */
+void
+fxSetScissorValues(GLcontext * ctx)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ int xmin, xmax;
+ int ymin, ymax;
+
+ if (ctx->Scissor.Enabled) {
+ xmin = ctx->Scissor.X;
+ xmax = ctx->Scissor.X + ctx->Scissor.Width;
+ ymin = ctx->Scissor.Y;
+ ymax = ctx->Scissor.Y + ctx->Scissor.Height;
+
+ if (xmin < 0)
+ xmin = 0;
+ if (xmax > fxMesa->width)
+ xmax = fxMesa->width;
+ if (ymin < fxMesa->screen_height - fxMesa->height)
+ ymin = fxMesa->screen_height - fxMesa->height;
+ if (ymax > fxMesa->screen_height - 0)
+ ymax = fxMesa->screen_height - 0;
+ }
+ else {
+ xmin = 0;
+ ymin = 0;
+ xmax = fxMesa->width;
+ ymax = fxMesa->height;
+ }
+
+ fxMesa->clipMinX = xmin;
+ fxMesa->clipMinY = ymin;
+ fxMesa->clipMaxX = xmax;
+ fxMesa->clipMaxY = ymax;
+ grClipWindow(xmin, ymin, xmax, ymax);
+}
+
+void
+fxSetupScissor(GLcontext * ctx)
+{
+ BEGIN_BOARD_LOCK();
+ fxSetScissorValues(ctx);
+ END_BOARD_LOCK();
+}
+
+void
+fxDDScissor(GLcontext * ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+ FX_CONTEXT(ctx)->new_state |= FX_NEW_SCISSOR;
+}
+
+/************************************************************************/
+/*************************** Cull mode setup ****************************/
+/************************************************************************/
+
+
+void
+fxDDCullFace(GLcontext * ctx, GLenum mode)
+{
+ (void) mode;
+ FX_CONTEXT(ctx)->new_state |= FX_NEW_CULL;
+}
+
+void
+fxDDFrontFace(GLcontext * ctx, GLenum mode)
+{
+ (void) mode;
+ FX_CONTEXT(ctx)->new_state |= FX_NEW_CULL;
+}
+
+
+void
+fxSetupCull(GLcontext * ctx)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrCullMode_t mode = GR_CULL_DISABLE;
+
+ if (ctx->Polygon.CullFlag && (fxMesa->raster_primitive == GL_TRIANGLES)) {
+ switch (ctx->Polygon.CullFaceMode) {
+ case GL_BACK:
+ if (ctx->Polygon.FrontFace == GL_CCW)
+ mode = GR_CULL_NEGATIVE;
+ else
+ mode = GR_CULL_POSITIVE;
+ break;
+ case GL_FRONT:
+ if (ctx->Polygon.FrontFace == GL_CCW)
+ mode = GR_CULL_POSITIVE;
+ else
+ mode = GR_CULL_NEGATIVE;
+ break;
+ case GL_FRONT_AND_BACK:
+ /* Handled as a fallback on triangles in tdfx_tris.c */
+ return;
+ default:
+ ASSERT(0);
+ break;
+ }
+ }
+
+ if (fxMesa->cullMode != mode) {
+ fxMesa->cullMode = mode;
+ grCullMode(mode);
+ }
+}
+
+
+/************************************************************************/
+/****************************** DD Enable ******************************/
+/************************************************************************/
+
+void
+fxDDEnable(GLcontext * ctx, GLenum cap, GLboolean state)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "%s(%s)\n", state ? "fxDDEnable" : "fxDDDisable",
+ _mesa_lookup_enum_by_nr(cap));
+ }
+
+ switch (cap) {
+ case GL_ALPHA_TEST:
+ if (state != us->alphaTestEnabled) {
+ us->alphaTestEnabled = state;
+ fxMesa->new_state |= FX_NEW_ALPHA;
+ }
+ break;
+ case GL_BLEND:
+ if (state != us->blendEnabled) {
+ us->blendEnabled = state;
+ fxMesa->new_state |= FX_NEW_BLEND;
+ }
+ break;
+ case GL_DEPTH_TEST:
+ if (state != us->depthTestEnabled) {
+ us->depthTestEnabled = state;
+ fxMesa->new_state |= FX_NEW_DEPTH;
+ }
+ break;
+ case GL_STENCIL_TEST:
+ if (fxMesa->haveHwStencil && state != us->stencilEnabled) {
+ us->stencilEnabled = state;
+ fxMesa->new_state |= FX_NEW_STENCIL;
+ }
+ break;
+ case GL_DITHER:
+ if (state) {
+ grDitherMode(GR_DITHER_4x4);
+ }
+ else {
+ grDitherMode(GR_DITHER_DISABLE);
+ }
+ break;
+ case GL_SCISSOR_TEST:
+ fxMesa->new_state |= FX_NEW_SCISSOR;
+ break;
+ case GL_SHARED_TEXTURE_PALETTE_EXT:
+ fxDDTexUseGlbPalette(ctx, state);
+ break;
+ case GL_FOG:
+ fxMesa->new_state |= FX_NEW_FOG;
+ break;
+ case GL_CULL_FACE:
+ fxMesa->new_state |= FX_NEW_CULL;
+ break;
+ case GL_LINE_SMOOTH:
+ case GL_LINE_STIPPLE:
+ case GL_POINT_SMOOTH:
+ case GL_POLYGON_SMOOTH:
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ fxMesa->new_state |= FX_NEW_TEXTURING;
+ break;
+ default:
+ ; /* XXX no-op? */
+ }
+}
+
+
+
+
+/************************************************************************/
+/************************** Changes to units state **********************/
+/************************************************************************/
+
+
+/* All units setup is handled under texture setup.
+ */
+void
+fxDDShadeModel(GLcontext * ctx, GLenum mode)
+{
+ FX_CONTEXT(ctx)->new_state |= FX_NEW_TEXTURING;
+}
+
+
+
+/************************************************************************/
+/****************************** Units SetUp *****************************/
+/************************************************************************/
+static void
+fx_print_state_flags(const char *msg, GLuint flags)
+{
+ fprintf(stderr,
+ "%s: (0x%x) %s%s%s%s%s%s%s%s\n",
+ msg,
+ flags,
+ (flags & FX_NEW_TEXTURING) ? "texture, " : "",
+ (flags & FX_NEW_BLEND) ? "blend, " : "",
+ (flags & FX_NEW_ALPHA) ? "alpha, " : "",
+ (flags & FX_NEW_FOG) ? "fog, " : "",
+ (flags & FX_NEW_SCISSOR) ? "scissor, " : "",
+ (flags & FX_NEW_COLOR_MASK) ? "colormask, " : "",
+ (flags & FX_NEW_CULL) ? "cull, " : "",
+ (flags & FX_NEW_STENCIL) ? "stencil, " : "");
+}
+
+void
+fxSetupFXUnits(GLcontext * ctx)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLuint newstate = fxMesa->new_state;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER)
+ fx_print_state_flags("fxSetupFXUnits", newstate);
+
+ if (newstate) {
+ if (newstate & FX_NEW_TEXTURING)
+ fxSetupTexture(ctx);
+
+ if (newstate & FX_NEW_BLEND)
+ fxSetupBlend(ctx);
+
+ if (newstate & FX_NEW_ALPHA)
+ fxSetupAlphaTest(ctx);
+
+ if (newstate & FX_NEW_DEPTH)
+ fxSetupDepthTest(ctx);
+
+ if (newstate & FX_NEW_STENCIL)
+ fxSetupStencil(ctx);
+
+ if (newstate & FX_NEW_FOG)
+ fxSetupFog(ctx);
+
+ if (newstate & FX_NEW_SCISSOR)
+ fxSetupScissor(ctx);
+
+ if (newstate & FX_NEW_COLOR_MASK)
+ fxSetupColorMask(ctx);
+
+ if (newstate & FX_NEW_CULL)
+ fxSetupCull(ctx);
+
+ fxMesa->new_state = 0;
+ }
+}
+
+
+
+#else
+
+
+/*
+ * Need this to provide at least one external definition.
+ */
+
+extern int gl_fx_dummy_function_setup(void);
+int
+gl_fx_dummy_function_setup(void)
+{
+ return 0;
+}
+
+#endif /* FX */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxsetup.h b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxsetup.h
new file mode 100644
index 000000000..9d337d4b0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxsetup.h
@@ -0,0 +1,850 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.0
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/* Authors:
+ * David Bucciarelli
+ * Brian Paul
+ * Daryll Strauss
+ * Keith Whitwell
+ * Daniel Borca
+ * Hiroshi Morii
+ */
+
+/* fxsetup.c - 3Dfx VooDoo rendering mode setup functions */
+/* This code belongs to fxsetup.c, but I didn't want to clutter
+ * the original code with Napalm specifics, in order to keep things
+ * clear -- especially for backward compatibility. I should have
+ * put it into another .c file, but I didn't want to export so many
+ * things...
+ * The point is, Napalm uses a different technique for texture env.
+ * SST1 Single texturing:
+ * setup standard grTexCombine
+ * fiddle with grColorCombine/grAlphaCombine
+ * SST1 Multi texturing:
+ * fiddle with grTexCombine/grColorCombine/grAlphaCombine
+ * Napalm Single texturing:
+ * setup standard grColorCombineExt/grAlphaCombineExt
+ * fiddle with grTexColorCombine/grTexAlphaCombine
+ * Napalm Multi texturing:
+ * setup standard grColorCombineExt/grAlphaCombineExt
+ * fiddle with grTexColorCombine/grTexAlphaCombine
+ */
+
+/*
+ * These macros are used below when handling COMBINE_EXT.
+ */
+#define TEXENV_OPERAND_INVERTED(operand) \
+ (((operand) == GL_ONE_MINUS_SRC_ALPHA) \
+ || ((operand) == GL_ONE_MINUS_SRC_COLOR))
+#define TEXENV_OPERAND_ALPHA(operand) \
+ (((operand) == GL_SRC_ALPHA) || ((operand) == GL_ONE_MINUS_SRC_ALPHA))
+#define TEXENV_SETUP_ARG_A(param, source, operand, iteratedAlpha) \
+ switch (source) { \
+ case GL_TEXTURE: \
+ param = GR_CMBX_LOCAL_TEXTURE_ALPHA; \
+ break; \
+ case GL_CONSTANT_EXT: \
+ param = GR_CMBX_TMU_CALPHA; \
+ break; \
+ case GL_PRIMARY_COLOR_EXT: \
+ param = GR_CMBX_ITALPHA; \
+ break; \
+ case GL_PREVIOUS_EXT: \
+ param = iteratedAlpha; \
+ break; \
+ default: \
+ /* \
+ * This is here just to keep from getting \
+ * compiler warnings. \
+ */ \
+ param = GR_CMBX_ZERO; \
+ break; \
+ }
+
+#define TEXENV_SETUP_ARG_RGB(param, source, operand, iteratedColor, iteratedAlpha) \
+ if (!TEXENV_OPERAND_ALPHA(operand)) { \
+ switch (source) { \
+ case GL_TEXTURE: \
+ param = GR_CMBX_LOCAL_TEXTURE_RGB; \
+ break; \
+ case GL_CONSTANT_EXT: \
+ param = GR_CMBX_TMU_CCOLOR; \
+ break; \
+ case GL_PRIMARY_COLOR_EXT: \
+ param = GR_CMBX_ITRGB; \
+ break; \
+ case GL_PREVIOUS_EXT: \
+ param = iteratedColor; \
+ break; \
+ default: \
+ /* \
+ * This is here just to keep from getting \
+ * compiler warnings. \
+ */ \
+ param = GR_CMBX_ZERO; \
+ break; \
+ } \
+ } else { \
+ switch (source) { \
+ case GL_TEXTURE: \
+ param = GR_CMBX_LOCAL_TEXTURE_ALPHA; \
+ break; \
+ case GL_CONSTANT_EXT: \
+ param = GR_CMBX_TMU_CALPHA; \
+ break; \
+ case GL_PRIMARY_COLOR_EXT: \
+ param = GR_CMBX_ITALPHA; \
+ break; \
+ case GL_PREVIOUS_EXT: \
+ param = iteratedAlpha; \
+ break; \
+ default: \
+ /* \
+ * This is here just to keep from getting \
+ * compiler warnings. \
+ */ \
+ param = GR_CMBX_ZERO; \
+ break; \
+ } \
+ }
+
+#define TEXENV_SETUP_MODE_RGB(param, operand) \
+ switch (operand) { \
+ case GL_SRC_COLOR: \
+ case GL_SRC_ALPHA: \
+ param = GR_FUNC_MODE_X; \
+ break; \
+ case GL_ONE_MINUS_SRC_ALPHA: \
+ case GL_ONE_MINUS_SRC_COLOR: \
+ param = GR_FUNC_MODE_ONE_MINUS_X; \
+ break; \
+ default: \
+ param = GR_FUNC_MODE_ZERO; \
+ break; \
+ }
+
+#define TEXENV_SETUP_MODE_A(param, operand) \
+ switch (operand) { \
+ case GL_SRC_ALPHA: \
+ param = GR_FUNC_MODE_X; \
+ break; \
+ case GL_ONE_MINUS_SRC_ALPHA: \
+ param = GR_FUNC_MODE_ONE_MINUS_X; \
+ break; \
+ default: \
+ param = GR_FUNC_MODE_ZERO; \
+ break; \
+ }
+
+static void
+fxSetupTextureEnvNapalm_NoLock(GLcontext * ctx, GLuint textureset, GLuint tmu, GLboolean iterated)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[textureset];
+ struct tdfx_combine_alpha_ext alphaComb;
+ struct tdfx_combine_color_ext colorComb;
+ const GLfloat *envColor = texUnit->EnvColor;
+ GrCombineLocal_t localc, locala; /* fragmentColor/Alpha */
+ GLint ifmt;
+ tfxTexInfo *ti;
+ struct gl_texture_object *tObj = texUnit->_Current;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSetupTextureEnvNapalm_NoLock(unit %u, TMU %u, iterated %d)\n",
+ textureset, tmu, iterated);
+ }
+
+ ti = fxTMGetTexInfo(tObj);
+
+ ifmt = ti->baseLevelInternalFormat;
+
+ if (iterated) {
+ /* we don't have upstream TMU */
+ locala = GR_CMBX_ITALPHA;
+ localc = GR_CMBX_ITRGB;
+ } else {
+ /* we have upstream TMU */
+ locala = GR_CMBX_OTHER_TEXTURE_ALPHA;
+ localc = GR_CMBX_OTHER_TEXTURE_RGB;
+ }
+
+ alphaComb.InvertD = FXFALSE;
+ alphaComb.Shift = 0;
+ alphaComb.Invert = FXFALSE;
+ colorComb.InvertD = FXFALSE;
+ colorComb.Shift = 0;
+ colorComb.Invert = FXFALSE;
+
+ switch (texUnit->EnvMode) {
+ case GL_DECAL:
+ alphaComb.SourceA = locala;
+ alphaComb.ModeA = GR_FUNC_MODE_X;
+ alphaComb.SourceB = GR_CMBX_ZERO;
+ alphaComb.ModeB = GR_FUNC_MODE_X;
+ alphaComb.SourceC = GR_CMBX_ZERO;
+ alphaComb.InvertC = FXTRUE;
+ alphaComb.SourceD = GR_CMBX_ZERO;
+
+ colorComb.SourceA = GR_CMBX_LOCAL_TEXTURE_RGB;
+ colorComb.ModeA = GR_FUNC_MODE_X;
+ colorComb.SourceB = localc;
+ colorComb.ModeB = GR_FUNC_MODE_NEGATIVE_X;
+ colorComb.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA;
+ colorComb.InvertC = FXFALSE;
+ colorComb.SourceD = GR_CMBX_B;
+ break;
+ case GL_MODULATE:
+ if (ifmt == GL_LUMINANCE || ifmt == GL_RGB) {
+ alphaComb.SourceA = locala;
+ alphaComb.ModeA = GR_FUNC_MODE_X;
+ alphaComb.SourceB = GR_CMBX_ZERO;
+ alphaComb.ModeB = GR_FUNC_MODE_X;
+ alphaComb.SourceC = GR_CMBX_ZERO;
+ alphaComb.InvertC = FXTRUE;
+ alphaComb.SourceD = GR_CMBX_ZERO;
+ } else {
+ alphaComb.SourceA = locala;
+ alphaComb.ModeA = GR_FUNC_MODE_X;
+ alphaComb.SourceB = GR_CMBX_ZERO;
+ alphaComb.ModeB = GR_FUNC_MODE_X;
+ alphaComb.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA;
+ alphaComb.InvertC = FXFALSE;
+ alphaComb.SourceD = GR_CMBX_ZERO;
+ }
+
+ if (ifmt == GL_ALPHA) {
+ colorComb.SourceA = localc;
+ colorComb.ModeA = GR_FUNC_MODE_X;
+ colorComb.SourceB = GR_CMBX_ZERO;
+ colorComb.ModeB = GR_FUNC_MODE_X;
+ colorComb.SourceC = GR_CMBX_ZERO;
+ colorComb.InvertC = FXTRUE;
+ colorComb.SourceD = GR_CMBX_ZERO;
+ } else {
+ colorComb.SourceA = localc;
+ colorComb.ModeA = GR_FUNC_MODE_X;
+ colorComb.SourceB = GR_CMBX_ZERO;
+ colorComb.ModeB = GR_FUNC_MODE_X;
+ colorComb.SourceC = GR_CMBX_LOCAL_TEXTURE_RGB;
+ colorComb.InvertC = FXFALSE;
+ colorComb.SourceD = GR_CMBX_ZERO;
+ }
+ break;
+ case GL_BLEND:
+ if (ifmt == GL_INTENSITY) {
+ alphaComb.SourceA = GR_CMBX_TMU_CALPHA;
+ alphaComb.ModeA = GR_FUNC_MODE_X;
+ alphaComb.SourceB = locala;
+ alphaComb.ModeB = GR_FUNC_MODE_X;
+ alphaComb.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA;
+ alphaComb.InvertC = FXFALSE;
+ alphaComb.SourceD = GR_CMBX_ZERO;
+ } else {
+ alphaComb.SourceA = locala;
+ alphaComb.ModeA = GR_FUNC_MODE_X;
+ alphaComb.SourceB = GR_CMBX_ZERO;
+ alphaComb.ModeB = GR_FUNC_MODE_X;
+ alphaComb.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA;
+ alphaComb.InvertC = FXFALSE;
+ alphaComb.SourceD = GR_CMBX_ZERO;
+ }
+
+ if (ifmt == GL_ALPHA) {
+ colorComb.SourceA = localc;
+ colorComb.ModeA = GR_FUNC_MODE_X;
+ colorComb.SourceB = GR_CMBX_ZERO;
+ colorComb.ModeB = GR_FUNC_MODE_X;
+ colorComb.SourceC = GR_CMBX_ZERO;
+ colorComb.InvertC = FXTRUE;
+ colorComb.SourceD = GR_CMBX_ZERO;
+ } else {
+ colorComb.SourceA = GR_CMBX_TMU_CCOLOR;
+ colorComb.ModeA = GR_FUNC_MODE_X;
+ colorComb.SourceB = localc;
+ colorComb.ModeB = GR_FUNC_MODE_NEGATIVE_X;
+ colorComb.SourceC = GR_CMBX_LOCAL_TEXTURE_RGB;
+ colorComb.InvertC = FXFALSE;
+ colorComb.SourceD = GR_CMBX_B;
+ }
+
+ fxMesa->Glide.grConstantColorValueExt(tmu,
+ (((GLuint)(envColor[0] * 255.0f)) ) |
+ (((GLuint)(envColor[1] * 255.0f)) << 8) |
+ (((GLuint)(envColor[2] * 255.0f)) << 16) |
+ (((GLuint)(envColor[3] * 255.0f)) << 24));
+ break;
+ case GL_REPLACE:
+ if (ifmt == GL_LUMINANCE || ifmt == GL_RGB) {
+ alphaComb.SourceA = locala;
+ alphaComb.ModeA = GR_FUNC_MODE_X;
+ alphaComb.SourceB = GR_CMBX_ZERO;
+ alphaComb.ModeB = GR_FUNC_MODE_X;
+ alphaComb.SourceC = GR_CMBX_ZERO;
+ alphaComb.InvertC = FXTRUE;
+ alphaComb.SourceD = GR_CMBX_ZERO;
+ } else {
+ alphaComb.SourceA = GR_CMBX_LOCAL_TEXTURE_ALPHA;
+ alphaComb.ModeA = GR_FUNC_MODE_X;
+ alphaComb.SourceB = GR_CMBX_ZERO;
+ alphaComb.ModeB = GR_FUNC_MODE_X;
+ alphaComb.SourceC = GR_CMBX_ZERO;
+ alphaComb.InvertC = FXTRUE;
+ alphaComb.SourceD = GR_CMBX_ZERO;
+ }
+
+ if (ifmt == GL_ALPHA) {
+ colorComb.SourceA = localc;
+ colorComb.ModeA = GR_FUNC_MODE_X;
+ colorComb.SourceB = GR_CMBX_ZERO;
+ colorComb.ModeB = GR_FUNC_MODE_X;
+ colorComb.SourceC = GR_CMBX_ZERO;
+ colorComb.InvertC = FXTRUE;
+ colorComb.SourceD = GR_CMBX_ZERO;
+ } else {
+ colorComb.SourceA = GR_CMBX_LOCAL_TEXTURE_RGB;
+ colorComb.ModeA = GR_FUNC_MODE_X;
+ colorComb.SourceB = GR_CMBX_ZERO;
+ colorComb.ModeB = GR_FUNC_MODE_X;
+ colorComb.SourceC = GR_CMBX_ZERO;
+ colorComb.InvertC = FXTRUE;
+ colorComb.SourceD = GR_CMBX_ZERO;
+ }
+ break;
+ case GL_ADD:
+ if (ifmt == GL_LUMINANCE || ifmt == GL_RGB) {
+ alphaComb.SourceA = locala;
+ alphaComb.ModeA = GR_FUNC_MODE_X;
+ alphaComb.SourceB = GR_CMBX_ZERO;
+ alphaComb.ModeB = GR_FUNC_MODE_X;
+ alphaComb.SourceC = GR_CMBX_ZERO;
+ alphaComb.InvertC = FXTRUE;
+ alphaComb.SourceD = GR_CMBX_ZERO;
+ } else if (ifmt == GL_INTENSITY) {
+ alphaComb.SourceA = locala;
+ alphaComb.ModeA = GR_FUNC_MODE_X;
+ alphaComb.SourceB = GR_CMBX_LOCAL_TEXTURE_ALPHA;
+ alphaComb.ModeB = GR_FUNC_MODE_X;
+ alphaComb.SourceC = GR_CMBX_ZERO;
+ alphaComb.InvertC = FXTRUE;
+ alphaComb.SourceD = GR_CMBX_ZERO;
+ } else {
+ alphaComb.SourceA = locala;
+ alphaComb.ModeA = GR_FUNC_MODE_X;
+ alphaComb.SourceB = GR_CMBX_ZERO;
+ alphaComb.ModeB = GR_FUNC_MODE_X;
+ alphaComb.SourceC = GR_CMBX_LOCAL_TEXTURE_ALPHA;
+ alphaComb.InvertC = FXFALSE;
+ alphaComb.SourceD = GR_CMBX_ZERO;
+ }
+
+ if (ifmt == GL_ALPHA) {
+ colorComb.SourceA = localc;
+ colorComb.ModeA = GR_FUNC_MODE_X;
+ colorComb.SourceB = GR_CMBX_ZERO;
+ colorComb.ModeB = GR_FUNC_MODE_X;
+ colorComb.SourceC = GR_CMBX_ZERO;
+ colorComb.InvertC = FXTRUE;
+ colorComb.SourceD = GR_CMBX_ZERO;
+ } else {
+ colorComb.SourceA = localc;
+ colorComb.ModeA = GR_FUNC_MODE_X;
+ colorComb.SourceB = GR_CMBX_LOCAL_TEXTURE_RGB;
+ colorComb.ModeB = GR_FUNC_MODE_X;
+ colorComb.SourceC = GR_CMBX_ZERO;
+ colorComb.InvertC = FXTRUE;
+ colorComb.SourceD = GR_CMBX_ZERO;
+ }
+ break;
+ /* COMBINE_EXT */
+ case GL_COMBINE_EXT:
+ /* XXX todo - INCOMPLETE!!! */
+ if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) {
+#if 1
+ fprintf(stderr, "COMBINE_EXT: %s + %s\n",
+ _mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB),
+ _mesa_lookup_enum_by_nr(texUnit->Combine.ModeA));
+#else
+ fprintf(stderr, "Texture Unit %d\n", textureset);
+ fprintf(stderr, " GL_TEXTURE_ENV_MODE = %s\n", _mesa_lookup_enum_by_nr(texUnit->EnvMode));
+ fprintf(stderr, " GL_COMBINE_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB));
+ fprintf(stderr, " GL_COMBINE_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeA));
+ fprintf(stderr, " GL_SOURCE0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[0]));
+ fprintf(stderr, " GL_SOURCE1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[1]));
+ fprintf(stderr, " GL_SOURCE2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[2]));
+ fprintf(stderr, " GL_SOURCE0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[0]));
+ fprintf(stderr, " GL_SOURCE1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[1]));
+ fprintf(stderr, " GL_SOURCE2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[2]));
+ fprintf(stderr, " GL_OPERAND0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[0]));
+ fprintf(stderr, " GL_OPERAND1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[1]));
+ fprintf(stderr, " GL_OPERAND2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[2]));
+ fprintf(stderr, " GL_OPERAND0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[0]));
+ fprintf(stderr, " GL_OPERAND1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[1]));
+ fprintf(stderr, " GL_OPERAND2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[2]));
+ fprintf(stderr, " GL_RGB_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftRGB);
+ fprintf(stderr, " GL_ALPHA_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftA);
+ fprintf(stderr, " GL_TEXTURE_ENV_COLOR = (%f, %f, %f, %f)\n", envColor[0], envColor[1], envColor[2], envColor[3]);
+#endif
+ }
+
+ alphaComb.Shift = texUnit->Combine.ScaleShiftA;
+ colorComb.Shift = texUnit->Combine.ScaleShiftRGB;
+
+ switch (texUnit->Combine.ModeRGB) {
+ case GL_MODULATE:
+ /* Arg0 * Arg1 == (A + 0) * C + 0 */
+ TEXENV_SETUP_ARG_RGB(colorComb.SourceA,
+ texUnit->Combine.SourceRGB[0],
+ texUnit->Combine.OperandRGB[0],
+ localc, locala);
+ TEXENV_SETUP_MODE_RGB(colorComb.ModeA,
+ texUnit->Combine.OperandRGB[0]);
+ colorComb.SourceB = GR_CMBX_ZERO;
+ colorComb.ModeB = GR_FUNC_MODE_ZERO;
+ TEXENV_SETUP_ARG_RGB(colorComb.SourceC,
+ texUnit->Combine.SourceRGB[1],
+ texUnit->Combine.OperandRGB[1],
+ localc, locala);
+ colorComb.InvertC = TEXENV_OPERAND_INVERTED(
+ texUnit->Combine.OperandRGB[1]);
+ colorComb.SourceD = GR_CMBX_ZERO;
+ break;
+ case GL_REPLACE:
+ /* Arg0 == (A + 0) * 1 + 0 */
+ TEXENV_SETUP_ARG_RGB(colorComb.SourceA,
+ texUnit->Combine.SourceRGB[0],
+ texUnit->Combine.OperandRGB[0],
+ localc, locala);
+ TEXENV_SETUP_MODE_RGB(colorComb.ModeA,
+ texUnit->Combine.OperandRGB[0]);
+ colorComb.SourceB = GR_CMBX_ZERO;
+ colorComb.ModeB = GR_FUNC_MODE_ZERO;
+ colorComb.SourceC = GR_CMBX_ZERO;
+ colorComb.InvertC = FXTRUE;
+ colorComb.SourceD = GR_CMBX_ZERO;
+ break;
+ case GL_ADD:
+ /* Arg0 + Arg1 = (A + B) * 1 + 0 */
+ TEXENV_SETUP_ARG_RGB(colorComb.SourceA,
+ texUnit->Combine.SourceRGB[0],
+ texUnit->Combine.OperandRGB[0],
+ localc, locala);
+ TEXENV_SETUP_MODE_RGB(colorComb.ModeA,
+ texUnit->Combine.OperandRGB[0]);
+ TEXENV_SETUP_ARG_RGB(colorComb.SourceB,
+ texUnit->Combine.SourceRGB[1],
+ texUnit->Combine.OperandRGB[1],
+ localc, locala);
+ TEXENV_SETUP_MODE_RGB(colorComb.ModeB,
+ texUnit->Combine.OperandRGB[1]);
+ colorComb.SourceC = GR_CMBX_ZERO;
+ colorComb.InvertC = FXTRUE;
+ colorComb.SourceD = GR_CMBX_ZERO;
+ break;
+ case GL_INTERPOLATE_EXT:
+ /* Arg0 * Arg2 + Arg1 * (1 - Arg2) ==
+ * (Arg0 - Arg1) * Arg2 + Arg1 == (A - B) * C + D
+ */
+ TEXENV_SETUP_ARG_RGB(colorComb.SourceA,
+ texUnit->Combine.SourceRGB[0],
+ texUnit->Combine.OperandRGB[0],
+ localc, locala);
+ TEXENV_SETUP_MODE_RGB(colorComb.ModeA,
+ texUnit->Combine.OperandRGB[0]);
+ TEXENV_SETUP_ARG_RGB(colorComb.SourceB,
+ texUnit->Combine.SourceRGB[1],
+ texUnit->Combine.OperandRGB[1],
+ localc, locala);
+ if (TEXENV_OPERAND_INVERTED(texUnit->Combine.OperandRGB[1])) {
+ /* Hack alert!!! This case is wrong!!! */
+ fprintf(stderr, "COMBINE_EXT_color: WRONG!!!\n");
+ colorComb.ModeB = GR_FUNC_MODE_NEGATIVE_X;
+ } else {
+ colorComb.ModeB = GR_FUNC_MODE_NEGATIVE_X;
+ }
+ /*
+ * The Source/Operand for the C value must
+ * specify some kind of alpha value.
+ */
+ TEXENV_SETUP_ARG_A(colorComb.SourceC,
+ texUnit->Combine.SourceRGB[2],
+ texUnit->Combine.OperandRGB[2],
+ locala);
+ colorComb.InvertC = FXFALSE;
+ colorComb.SourceD = GR_CMBX_B;
+ break;
+ default:
+ fprintf(stderr, "COMBINE_EXT_color: %s\n",
+ _mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB));
+ }
+
+ switch (texUnit->Combine.ModeA) {
+ case GL_MODULATE:
+ /* Arg0 * Arg1 == (A + 0) * C + 0 */
+ TEXENV_SETUP_ARG_A(alphaComb.SourceA,
+ texUnit->Combine.SourceA[0],
+ texUnit->Combine.OperandA[0],
+ locala);
+ TEXENV_SETUP_MODE_A(alphaComb.ModeA,
+ texUnit->Combine.OperandA[0]);
+ alphaComb.SourceB = GR_CMBX_ZERO;
+ alphaComb.ModeB = GR_FUNC_MODE_ZERO;
+ TEXENV_SETUP_ARG_A(alphaComb.SourceC,
+ texUnit->Combine.SourceA[1],
+ texUnit->Combine.OperandA[1],
+ locala);
+ alphaComb.InvertC = TEXENV_OPERAND_INVERTED(
+ texUnit->Combine.OperandA[1]);
+ alphaComb.SourceD = GR_CMBX_ZERO;
+ break;
+ case GL_REPLACE:
+ /* Arg0 == (A + 0) * 1 + 0 */
+ TEXENV_SETUP_ARG_A(alphaComb.SourceA,
+ texUnit->Combine.SourceA[0],
+ texUnit->Combine.OperandA[0],
+ locala);
+ TEXENV_SETUP_MODE_A(alphaComb.ModeA,
+ texUnit->Combine.OperandA[0]);
+ alphaComb.SourceB = GR_CMBX_ZERO;
+ alphaComb.ModeB = GR_FUNC_MODE_ZERO;
+ alphaComb.SourceC = GR_CMBX_ZERO;
+ alphaComb.InvertC = FXTRUE;
+ alphaComb.SourceD = GR_CMBX_ZERO;
+ break;
+ case GL_ADD:
+ /* Arg0 + Arg1 = (A + B) * 1 + 0 */
+ TEXENV_SETUP_ARG_A(alphaComb.SourceA,
+ texUnit->Combine.SourceA[0],
+ texUnit->Combine.OperandA[0],
+ locala);
+ TEXENV_SETUP_MODE_A(alphaComb.ModeA,
+ texUnit->Combine.OperandA[0]);
+ TEXENV_SETUP_ARG_A(alphaComb.SourceB,
+ texUnit->Combine.SourceA[1],
+ texUnit->Combine.OperandA[1],
+ locala);
+ TEXENV_SETUP_MODE_A(alphaComb.ModeB,
+ texUnit->Combine.OperandA[1]);
+ alphaComb.SourceC = GR_CMBX_ZERO;
+ alphaComb.InvertC = FXTRUE;
+ alphaComb.SourceD = GR_CMBX_ZERO;
+ break;
+ default:
+ fprintf(stderr, "COMBINE_EXT_alpha: %s\n",
+ _mesa_lookup_enum_by_nr(texUnit->Combine.ModeA));
+ }
+
+ fxMesa->Glide.grConstantColorValueExt(tmu,
+ (((GLuint)(envColor[0] * 255.0f)) ) |
+ (((GLuint)(envColor[1] * 255.0f)) << 8) |
+ (((GLuint)(envColor[2] * 255.0f)) << 16) |
+ (((GLuint)(envColor[3] * 255.0f)) << 24));
+ break;
+
+ default:
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSetupTextureEnvNapalm_NoLock: %x Texture.EnvMode not yet supported\n",
+ texUnit->EnvMode);
+ }
+ return;
+ }
+
+ /* On Napalm we simply put the color combine unit into passthrough mode
+ * and do everything we need with the texture combine units. */
+ fxMesa->Glide.grColorCombineExt(GR_CMBX_TEXTURE_RGB,
+ GR_FUNC_MODE_X,
+ GR_CMBX_ZERO,
+ GR_FUNC_MODE_X,
+ GR_CMBX_ZERO,
+ FXTRUE,
+ GR_CMBX_ZERO,
+ FXFALSE,
+ 0,
+ FXFALSE);
+ fxMesa->Glide.grAlphaCombineExt(GR_CMBX_TEXTURE_ALPHA,
+ GR_FUNC_MODE_X,
+ GR_CMBX_ZERO,
+ GR_FUNC_MODE_X,
+ GR_CMBX_ZERO,
+ FXTRUE,
+ GR_CMBX_ZERO,
+ FXFALSE,
+ 0,
+ FXFALSE);
+
+ fxMesa->Glide.grTexAlphaCombineExt(tmu,
+ alphaComb.SourceA,
+ alphaComb.ModeA,
+ alphaComb.SourceB,
+ alphaComb.ModeB,
+ alphaComb.SourceC,
+ alphaComb.InvertC,
+ alphaComb.SourceD,
+ alphaComb.InvertD,
+ alphaComb.Shift,
+ alphaComb.Invert);
+ fxMesa->Glide.grTexColorCombineExt(tmu,
+ colorComb.SourceA,
+ colorComb.ModeA,
+ colorComb.SourceB,
+ colorComb.ModeB,
+ colorComb.SourceC,
+ colorComb.InvertC,
+ colorComb.SourceD,
+ colorComb.InvertD,
+ colorComb.Shift,
+ colorComb.Invert);
+}
+
+
+/************************* Single Texture Set ***************************/
+
+static void
+fxSelectSingleTMUSrcNapalm_NoLock(fxMesaContext fxMesa, GLint tmu, FxBool LODblend)
+{
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSelectSingleTMUSrcNapalm_NoLock(%d, %d)\n", tmu, LODblend);
+ }
+
+ if (LODblend) {
+ /* XXX todo - GR_CMBX_LOD_FRAC? */
+ fxMesa->tmuSrc = FX_TMU_SPLIT;
+ }
+ else {
+ if (tmu != FX_TMU1) {
+ /* disable tex1 */
+ if (fxMesa->haveTwoTMUs) {
+ fxMesa->Glide.grTexAlphaCombineExt(FX_TMU1,
+ GR_CMBX_ZERO,
+ GR_FUNC_MODE_ZERO,
+ GR_CMBX_ZERO,
+ GR_FUNC_MODE_ZERO,
+ GR_CMBX_ZERO,
+ FXTRUE,
+ GR_CMBX_ZERO,
+ FXFALSE,
+ 0,
+ FXFALSE);
+ fxMesa->Glide.grTexColorCombineExt(FX_TMU1,
+ GR_CMBX_ZERO,
+ GR_FUNC_MODE_ZERO,
+ GR_CMBX_ZERO,
+ GR_FUNC_MODE_ZERO,
+ GR_CMBX_ZERO,
+ FXTRUE,
+ GR_CMBX_ZERO,
+ FXFALSE,
+ 0,
+ FXFALSE);
+ }
+
+ fxMesa->tmuSrc = FX_TMU0;
+ }
+ else {
+#if 1
+ grTexCombine(GR_TMU0,
+ GR_COMBINE_FUNCTION_BLEND,
+ GR_COMBINE_FACTOR_ONE,
+ GR_COMBINE_FUNCTION_BLEND,
+ GR_COMBINE_FACTOR_ONE,
+ FXFALSE,
+ FXFALSE);
+#else
+ /* [dBorca] why, oh why? doesn't work! stupid Glide? */
+ fxMesa->Glide.grTexAlphaCombineExt(FX_TMU0,
+ GR_CMBX_OTHER_TEXTURE_ALPHA,
+ GR_FUNC_MODE_X,
+ GR_CMBX_ZERO,
+ GR_FUNC_MODE_X,
+ GR_CMBX_ZERO,
+ FXTRUE,
+ GR_CMBX_ZERO,
+ FXFALSE,
+ 0,
+ FXFALSE);
+ fxMesa->Glide.grTexColorCombineExt(FX_TMU0,
+ GR_CMBX_OTHER_TEXTURE_RGB,
+ GR_FUNC_MODE_X,
+ GR_CMBX_ZERO,
+ GR_FUNC_MODE_X,
+ GR_CMBX_ZERO,
+ FXTRUE,
+ GR_CMBX_ZERO,
+ FXFALSE,
+ 0,
+ FXFALSE);
+#endif
+
+ fxMesa->tmuSrc = FX_TMU1;
+ }
+ }
+}
+
+static void
+fxSetupTextureSingleTMUNapalm_NoLock(GLcontext * ctx, GLuint textureset)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLuint unitsmode;
+ tfxTexInfo *ti;
+ struct gl_texture_object *tObj = ctx->Texture.Unit[textureset]._Current;
+ int tmu;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSetupTextureSingleTMUNapalm_NoLock(%d)\n", textureset);
+ }
+
+ ti = fxTMGetTexInfo(tObj);
+
+ fxTexValidate(ctx, tObj);
+
+ fxSetupSingleTMU_NoLock(fxMesa, tObj);
+
+ if (ti->whichTMU == FX_TMU_BOTH)
+ tmu = FX_TMU0;
+ else
+ tmu = ti->whichTMU;
+ if (fxMesa->tmuSrc != tmu)
+ fxSelectSingleTMUSrcNapalm_NoLock(fxMesa, tmu, ti->LODblend);
+
+ if (textureset == 0 || !fxMesa->haveTwoTMUs)
+ unitsmode = fxGetTexSetConfiguration(ctx, tObj, NULL);
+ 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);
+
+ if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE))
+ fprintf(stderr, "fxSetupTextureSingleTMUNapalm_NoLock: envmode is %s\n",
+ _mesa_lookup_enum_by_nr(ctx->Texture.Unit[textureset].EnvMode));
+
+ /* [dBorca] Hack alert:
+ * what if we're in split mode? (LODBlend)
+ * also should we update BOTH TMUs in FX_TMU_BOTH mode?
+ */
+ fxSetupTextureEnvNapalm_NoLock(ctx, textureset, tmu, GL_TRUE);
+}
+
+
+/************************* Double Texture Set ***************************/
+
+static void
+fxSetupTextureDoubleTMUNapalm_NoLock(GLcontext * ctx)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxTexInfo *ti0, *ti1;
+ struct gl_texture_object *tObj0 = ctx->Texture.Unit[1]._Current;
+ struct gl_texture_object *tObj1 = ctx->Texture.Unit[0]._Current;
+ GLuint unitsmode;
+ int tmu0 = 0, tmu1 = 1;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSetupTextureDoubleTMUNapalm_NoLock(...)\n");
+ }
+
+ ti0 = fxTMGetTexInfo(tObj0);
+ fxTexValidate(ctx, tObj0);
+
+ ti1 = fxTMGetTexInfo(tObj1);
+ fxTexValidate(ctx, tObj1);
+
+ fxSetupDoubleTMU_NoLock(fxMesa, tObj0, tObj1);
+
+ 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);
+
+ if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE))
+ fprintf(stderr, "fxSetupTextureDoubleTMUNapalm_NoLock: envmode is %s/%s\n",
+ _mesa_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode),
+ _mesa_lookup_enum_by_nr(ctx->Texture.Unit[1].EnvMode));
+
+
+ if ((ti0->whichTMU == FX_TMU1) || (ti1->whichTMU == FX_TMU0)) {
+ tmu0 = 1;
+ tmu1 = 0;
+ }
+ fxMesa->tmuSrc = FX_TMU_BOTH;
+
+ /* OpenGL vs Glide texture pipeline */
+ fxSetupTextureEnvNapalm_NoLock(ctx, 0, 1, GL_TRUE);
+ fxSetupTextureEnvNapalm_NoLock(ctx, 1, 0, GL_FALSE);
+}
+
+/************************* No Texture ***************************/
+
+static void
+fxSetupTextureNoneNapalm_NoLock(GLcontext * ctx)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxSetupTextureNoneNapalm_NoLock(...)\n");
+ }
+
+ /* the combiner formula is: (A + B) * C + D
+ **
+ ** a = tc_otherselect
+ ** a_mode = tc_invert_other
+ ** b = tc_localselect
+ ** b_mode = tc_invert_local
+ ** c = (tc_mselect, tc_mselect_7)
+ ** d = (tc_add_clocal, tc_add_alocal)
+ ** shift = tc_outshift
+ ** invert = tc_invert_output
+ */
+
+ fxMesa->Glide.grColorCombineExt(GR_CMBX_ITRGB,
+ GR_FUNC_MODE_X,
+ GR_CMBX_ZERO,
+ GR_FUNC_MODE_ZERO,
+ GR_CMBX_ZERO,
+ FXTRUE,
+ GR_CMBX_ZERO,
+ FXFALSE,
+ 0,
+ FXFALSE);
+ fxMesa->Glide.grAlphaCombineExt(GR_CMBX_ITALPHA,
+ GR_FUNC_MODE_X,
+ GR_CMBX_ZERO,
+ GR_FUNC_MODE_ZERO,
+ GR_CMBX_ZERO,
+ FXTRUE,
+ GR_CMBX_ZERO,
+ FXFALSE,
+ 0,
+ FXFALSE);
+
+ fxMesa->lastUnitsMode = FX_UM_NONE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxtexman.c b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxtexman.c
new file mode 100644
index 000000000..940c8fd0b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxtexman.c
@@ -0,0 +1,874 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.0
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/* Authors:
+ * David Bucciarelli
+ * Brian Paul
+ * Daryll Strauss
+ * Keith Whitwell
+ * Daniel Borca
+ * Hiroshi Morii
+ */
+
+/* fxtexman.c - 3Dfx VooDoo texture memory functions */
+
+
+#ifdef HAVE_CONFIG_H
+#include "conf.h"
+#endif
+
+#if defined(FX)
+
+#include "hash.h"
+#include "fxdrv.h"
+
+int texSwaps = 0;
+static FxU32 texBoundMask;
+
+#define FX_2MB_SPLIT 0x200000
+
+static struct gl_texture_object *fxTMFindOldestObject(fxMesaContext fxMesa,
+ int tmu);
+
+
+#ifdef TEXSANITY
+static void
+fubar()
+{
+}
+
+ /* Sanity Check */
+static void
+sanity(fxMesaContext fxMesa)
+{
+ MemRange *tmp, *prev, *pos;
+
+ prev = 0;
+ tmp = fxMesa->tmFree[0];
+ while (tmp) {
+ if (!tmp->startAddr && !tmp->endAddr) {
+ fprintf(stderr, "Textures fubar\n");
+ fubar();
+ }
+ if (tmp->startAddr >= tmp->endAddr) {
+ fprintf(stderr, "Node fubar\n");
+ fubar();
+ }
+ if (prev && (prev->startAddr >= tmp->startAddr ||
+ prev->endAddr > tmp->startAddr)) {
+ fprintf(stderr, "Sorting fubar\n");
+ fubar();
+ }
+ prev = tmp;
+ tmp = tmp->next;
+ }
+ prev = 0;
+ tmp = fxMesa->tmFree[1];
+ while (tmp) {
+ if (!tmp->startAddr && !tmp->endAddr) {
+ fprintf(stderr, "Textures fubar\n");
+ fubar();
+ }
+ if (tmp->startAddr >= tmp->endAddr) {
+ fprintf(stderr, "Node fubar\n");
+ fubar();
+ }
+ if (prev && (prev->startAddr >= tmp->startAddr ||
+ prev->endAddr > tmp->startAddr)) {
+ fprintf(stderr, "Sorting fubar\n");
+ fubar();
+ }
+ prev = tmp;
+ tmp = tmp->next;
+ }
+}
+#endif
+
+static MemRange *
+fxTMNewRangeNode(fxMesaContext fxMesa, FxU32 start, FxU32 end)
+{
+ MemRange *result = 0;
+
+ if (fxMesa->tmPool) {
+ result = fxMesa->tmPool;
+ fxMesa->tmPool = fxMesa->tmPool->next;
+ }
+ else {
+ if (!(result = MALLOC(sizeof(MemRange)))) {
+ fprintf(stderr, "fxTMNewRangeNode: ERROR: out of memory!\n");
+ fxCloseHardware();
+ exit(-1);
+ }
+ }
+ result->startAddr = start;
+ result->endAddr = end;
+ return result;
+}
+
+#if 1
+#define fxTMDeleteRangeNode(fxMesa, range) \
+ do { \
+ range->next = fxMesa->tmPool; \
+ fxMesa->tmPool = range; \
+ } while (0);
+#else
+static void
+fxTMDeleteRangeNode(fxMesaContext fxMesa, MemRange * range)
+{
+ range->next = fxMesa->tmPool;
+ fxMesa->tmPool = range;
+}
+#endif
+
+static void
+fxTMUInit(fxMesaContext fxMesa, int tmu)
+{
+ MemRange *tmn, *last;
+ FxU32 start, end, blockstart, blockend, chunk;
+
+ start = grTexMinAddress(tmu);
+ end = grTexMaxAddress(tmu);
+
+ chunk = (fxMesa->type >= GR_SSTTYPE_Banshee) ? (end - start) : FX_2MB_SPLIT;
+
+ if (fxMesa->verbose) {
+ fprintf(stderr, "Voodoo TMU%d configuration:\n", tmu);
+ }
+
+ fxMesa->freeTexMem[tmu] = end - start;
+ fxMesa->tmFree[tmu] = NULL;
+
+ last = 0;
+ blockstart = start;
+ while (blockstart < end) {
+ if (blockstart + chunk > end)
+ blockend = end;
+ else
+ blockend = blockstart + chunk;
+
+ if (fxMesa->verbose)
+ fprintf(stderr, "Voodoo %08u-%08u\n",
+ (unsigned int) blockstart, (unsigned int) blockend);
+
+ tmn = fxTMNewRangeNode(fxMesa, blockstart, blockend);
+ tmn->next = NULL;
+
+
+ if (last)
+ last->next = tmn;
+ else
+ fxMesa->tmFree[tmu] = tmn;
+ last = tmn;
+
+ blockstart += chunk;
+ }
+}
+
+static int
+fxTMFindStartAddr(fxMesaContext fxMesa, GLint tmu, int size)
+{
+ MemRange *prev, *tmp;
+ int result;
+ struct gl_texture_object *obj;
+
+ if (fxMesa->HaveTexUma) {
+ tmu = FX_TMU0;
+ }
+
+ while (1) {
+ prev = 0;
+ tmp = fxMesa->tmFree[tmu];
+ while (tmp) {
+ if (tmp->endAddr - tmp->startAddr >= size) { /* Fits here */
+ result = tmp->startAddr;
+ tmp->startAddr += size;
+ if (tmp->startAddr == tmp->endAddr) { /* Empty */
+ if (prev) {
+ prev->next = tmp->next;
+ }
+ else {
+ fxMesa->tmFree[tmu] = tmp->next;
+ }
+ fxTMDeleteRangeNode(fxMesa, tmp);
+ }
+ fxMesa->freeTexMem[tmu] -= size;
+ return result;
+ }
+ prev = tmp;
+ tmp = tmp->next;
+ }
+ /* No free space. Discard oldest */
+ if (TDFX_DEBUG & VERBOSE_TEXTURE) {
+ fprintf(stderr, "fxTMFindStartAddr: No free space. Discard oldest\n");
+ }
+ obj = fxTMFindOldestObject(fxMesa, tmu);
+ if (!obj) {
+ fprintf(stderr, "fxTMFindStartAddr: ERROR: No space for texture\n");
+ return -1;
+ }
+ fxTMMoveOutTM(fxMesa, obj);
+ texSwaps++;
+ }
+}
+
+int fxTMCheckStartAddr (fxMesaContext fxMesa, GLint tmu, tfxTexInfo *ti)
+{
+ MemRange *tmp;
+ int size;
+
+ if (fxMesa->HaveTexUma) {
+ return FXTRUE;
+ }
+
+ size = grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
+
+ tmp = fxMesa->tmFree[tmu];
+ while (tmp) {
+ if (tmp->endAddr - tmp->startAddr >= size) { /* Fits here */
+ return FXTRUE;
+ }
+ tmp = tmp->next;
+ }
+
+ return FXFALSE;
+}
+
+static void
+fxTMRemoveRange(fxMesaContext fxMesa, GLint tmu, MemRange * range)
+{
+ MemRange *tmp, *prev;
+
+ if (fxMesa->HaveTexUma) {
+ tmu = FX_TMU0;
+ }
+
+ if (range->startAddr == range->endAddr) {
+ fxTMDeleteRangeNode(fxMesa, range);
+ return;
+ }
+ fxMesa->freeTexMem[tmu] += range->endAddr - range->startAddr;
+ prev = 0;
+ tmp = fxMesa->tmFree[tmu];
+ while (tmp) {
+ if (range->startAddr > tmp->startAddr) {
+ prev = tmp;
+ tmp = tmp->next;
+ }
+ else
+ break;
+ }
+ /* When we create the regions, we make a split at the 2MB boundary.
+ Now we have to make sure we don't join those 2MB boundary regions
+ back together again. */
+ range->next = tmp;
+ if (tmp) {
+ if (range->endAddr == tmp->startAddr
+ && tmp->startAddr & texBoundMask) {
+ /* Combine */
+ tmp->startAddr = range->startAddr;
+ fxTMDeleteRangeNode(fxMesa, range);
+ range = tmp;
+ }
+ }
+ if (prev) {
+ if (prev->endAddr == range->startAddr
+ && range->startAddr & texBoundMask) {
+ /* Combine */
+ prev->endAddr = range->endAddr;
+ prev->next = range->next;
+ fxTMDeleteRangeNode(fxMesa, range);
+ }
+ else
+ prev->next = range;
+ }
+ else {
+ fxMesa->tmFree[tmu] = range;
+ }
+}
+
+static struct gl_texture_object *
+fxTMFindOldestObject(fxMesaContext fxMesa, int tmu)
+{
+ GLuint age, old, lasttime, bindnumber;
+ GLfloat lowestPriority;
+ struct gl_texture_object *obj, *lowestPriorityObj;
+ struct _mesa_HashTable *textures = fxMesa->glCtx->Shared->TexObjects;
+ GLuint id;
+
+ if (!_mesa_HashFirstEntry(textures))
+ return 0;
+
+ obj = NULL;
+ old = 0;
+
+ lowestPriorityObj = NULL;
+ lowestPriority = 1.0F;
+
+ bindnumber = fxMesa->texBindNumber;
+
+ for (id = _mesa_HashFirstEntry(textures);
+ id;
+ id = _mesa_HashNextEntry(textures, id)) {
+ struct gl_texture_object *tmp
+ = (struct gl_texture_object *) _mesa_HashLookup(textures, id);
+ tfxTexInfo *info = fxTMGetTexInfo(tmp);
+
+ if (info && info->isInTM &&
+ ((info->whichTMU == tmu) ||
+ (info->whichTMU == FX_TMU_BOTH) ||
+ (info->whichTMU == FX_TMU_SPLIT) ||
+ fxMesa->HaveTexUma
+ )
+ ) {
+ lasttime = info->lastTimeUsed;
+
+ if (lasttime > bindnumber)
+ age = bindnumber + (UINT_MAX - lasttime + 1); /* TO DO: check wrap around */
+ else
+ age = bindnumber - lasttime;
+
+ if (age >= old) {
+ old = age;
+ obj = tmp;
+ }
+
+ /* examine priority */
+ if (tmp->Priority < lowestPriority) {
+ lowestPriority = tmp->Priority;
+ lowestPriorityObj = tmp;
+ }
+ }
+ }
+
+ if (lowestPriorityObj != NULL) {
+ if (TDFX_DEBUG & VERBOSE_TEXTURE) {
+ fprintf(stderr, "fxTMFindOldestObject: %d pri=%f\n", lowestPriorityObj->Name, lowestPriority);
+ }
+ return lowestPriorityObj;
+ }
+ else {
+ if (TDFX_DEBUG & VERBOSE_TEXTURE) {
+ if (obj != NULL) {
+ fprintf(stderr, "fxTMFindOldestObject: %d age=%d\n", obj->Name, old);
+ }
+ }
+ return obj;
+ }
+}
+
+static MemRange *
+fxTMAddObj(fxMesaContext fxMesa,
+ struct gl_texture_object *tObj, GLint tmu, int texmemsize)
+{
+ FxI32 startAddr;
+ MemRange *range;
+
+ startAddr = fxTMFindStartAddr(fxMesa, tmu, texmemsize);
+ if (startAddr < 0)
+ return 0;
+ range = fxTMNewRangeNode(fxMesa, startAddr, startAddr + texmemsize);
+ return range;
+}
+
+/* External Functions */
+
+void
+fxTMMoveInTM_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj,
+ GLint where)
+{
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+ int i, l;
+ int texmemsize;
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxTMMoveInTM_NoLock(%d)\n", tObj->Name);
+ }
+
+ fxMesa->stats.reqTexUpload++;
+
+ if (!ti->validated) {
+ fprintf(stderr, "fxTMMoveInTM_NoLock: INTERNAL ERROR: not validated\n");
+ fxCloseHardware();
+ exit(-1);
+ }
+
+ if (ti->isInTM) {
+ if (ti->whichTMU == where)
+ return;
+ if (where == FX_TMU_SPLIT || ti->whichTMU == FX_TMU_SPLIT)
+ fxTMMoveOutTM_NoLock(fxMesa, tObj);
+ else {
+ if (ti->whichTMU == FX_TMU_BOTH)
+ return;
+ where = FX_TMU_BOTH;
+ }
+ }
+
+ if (TDFX_DEBUG & (VERBOSE_DRIVER | VERBOSE_TEXTURE)) {
+ fprintf(stderr, "fxTMMoveInTM_NoLock: downloading %p (%d) in texture memory in %d\n",
+ (void *)tObj, tObj->Name, where);
+ }
+
+ ti->whichTMU = (FxU32) where;
+
+ switch (where) {
+ case FX_TMU0:
+ case FX_TMU1:
+ texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
+ ti->tm[where] = fxTMAddObj(fxMesa, tObj, where, texmemsize);
+ fxMesa->stats.memTexUpload += texmemsize;
+
+ for (i = FX_largeLodValue(ti->info), l = ti->minLevel;
+ i <= FX_smallLodValue(ti->info); i++, l++) {
+ struct gl_texture_image *texImage = tObj->Image[0][l];
+ grTexDownloadMipMapLevel(where,
+ ti->tm[where]->startAddr,
+ FX_valueToLod(i),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ texImage->Data);
+ }
+ break;
+ case FX_TMU_SPLIT:
+ texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_ODD, &(ti->info));
+ ti->tm[FX_TMU0] = fxTMAddObj(fxMesa, tObj, FX_TMU0, texmemsize);
+ fxMesa->stats.memTexUpload += texmemsize;
+
+ texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_EVEN, &(ti->info));
+ ti->tm[FX_TMU1] = fxTMAddObj(fxMesa, tObj, FX_TMU1, texmemsize);
+ fxMesa->stats.memTexUpload += texmemsize;
+
+ for (i = FX_largeLodValue(ti->info), l = ti->minLevel;
+ i <= FX_smallLodValue(ti->info); i++, l++) {
+ struct gl_texture_image *texImage = tObj->Image[0][l];
+
+ grTexDownloadMipMapLevel(GR_TMU0,
+ ti->tm[FX_TMU0]->startAddr,
+ FX_valueToLod(i),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_ODD,
+ texImage->Data);
+
+ grTexDownloadMipMapLevel(GR_TMU1,
+ ti->tm[FX_TMU1]->startAddr,
+ FX_valueToLod(i),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_EVEN,
+ texImage->Data);
+ }
+ break;
+ case FX_TMU_BOTH:
+ texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &(ti->info));
+ ti->tm[FX_TMU0] = fxTMAddObj(fxMesa, tObj, FX_TMU0, texmemsize);
+ fxMesa->stats.memTexUpload += texmemsize;
+
+ /*texmemsize = (int)grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH, &(ti->info));*/
+ ti->tm[FX_TMU1] = fxTMAddObj(fxMesa, tObj, FX_TMU1, texmemsize);
+ fxMesa->stats.memTexUpload += texmemsize;
+
+ for (i = FX_largeLodValue(ti->info), l = ti->minLevel;
+ i <= FX_smallLodValue(ti->info); i++, l++) {
+ struct gl_texture_image *texImage = tObj->Image[0][l];
+ grTexDownloadMipMapLevel(GR_TMU0,
+ ti->tm[FX_TMU0]->startAddr,
+ FX_valueToLod(i),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ texImage->Data);
+
+ grTexDownloadMipMapLevel(GR_TMU1,
+ ti->tm[FX_TMU1]->startAddr,
+ FX_valueToLod(i),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH,
+ texImage->Data);
+ }
+ break;
+ default:
+ fprintf(stderr, "fxTMMoveInTM_NoLock: INTERNAL ERROR: wrong tmu (%d)\n", where);
+ fxCloseHardware();
+ exit(-1);
+ }
+
+ fxMesa->stats.texUpload++;
+
+ ti->isInTM = GL_TRUE;
+}
+
+
+void
+fxTMMoveInTM(fxMesaContext fxMesa, struct gl_texture_object *tObj,
+ GLint where)
+{
+ BEGIN_BOARD_LOCK();
+ fxTMMoveInTM_NoLock(fxMesa, tObj, where);
+ END_BOARD_LOCK();
+}
+
+
+void
+fxTMReloadMipMapLevel(fxMesaContext fxMesa, struct gl_texture_object *tObj,
+ GLint level)
+{
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+ GrLOD_t lodlevel;
+ GLint tmu;
+ struct gl_texture_image *texImage = tObj->Image[0][level];
+ tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+
+ if (TDFX_DEBUG & VERBOSE_TEXTURE) {
+ fprintf(stderr, "fxTMReloadMipMapLevel(%p (%d), %d)\n", (void *)tObj, tObj->Name, level);
+ }
+
+ assert(mml);
+ assert(mml->width > 0);
+ assert(mml->height > 0);
+ assert(mml->glideFormat > 0);
+ assert(ti->isInTM);
+
+ if (!ti->validated) {
+ fprintf(stderr, "fxTMReloadMipMapLevel: INTERNAL ERROR: not validated\n");
+ fxCloseHardware();
+ exit(-1);
+ }
+
+ tmu = (int) ti->whichTMU;
+ fxMesa->stats.reqTexUpload++;
+ fxMesa->stats.texUpload++;
+
+ lodlevel = ti->info.largeLodLog2 - (level - ti->minLevel);
+
+ switch (tmu) {
+ case FX_TMU0:
+ case FX_TMU1:
+ grTexDownloadMipMapLevel(tmu,
+ ti->tm[tmu]->startAddr,
+ lodlevel,
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH, texImage->Data);
+ break;
+ case FX_TMU_SPLIT:
+ grTexDownloadMipMapLevel(GR_TMU0,
+ ti->tm[GR_TMU0]->startAddr,
+ lodlevel,
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_ODD, texImage->Data);
+
+ grTexDownloadMipMapLevel(GR_TMU1,
+ ti->tm[GR_TMU1]->startAddr,
+ lodlevel,
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_EVEN, texImage->Data);
+ break;
+ case FX_TMU_BOTH:
+ grTexDownloadMipMapLevel(GR_TMU0,
+ ti->tm[GR_TMU0]->startAddr,
+ lodlevel,
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH, texImage->Data);
+
+ grTexDownloadMipMapLevel(GR_TMU1,
+ ti->tm[GR_TMU1]->startAddr,
+ lodlevel,
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH, texImage->Data);
+ break;
+
+ default:
+ fprintf(stderr, "fxTMReloadMipMapLevel: INTERNAL ERROR: wrong tmu (%d)\n", tmu);
+ fxCloseHardware();
+ exit(-1);
+ }
+}
+
+void
+fxTMReloadSubMipMapLevel(fxMesaContext fxMesa,
+ struct gl_texture_object *tObj,
+ GLint level, GLint yoffset, GLint height)
+{
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+ GrLOD_t lodlevel;
+ unsigned short *data;
+ GLint tmu;
+ struct gl_texture_image *texImage = tObj->Image[0][level];
+ tfxMipMapLevel *mml = FX_MIPMAP_DATA(texImage);
+
+ assert(mml);
+
+ if (!ti->validated) {
+ fprintf(stderr, "fxTMReloadSubMipMapLevel: INTERNAL ERROR: not validated\n");
+ fxCloseHardware();
+ exit(-1);
+ }
+
+ tmu = (int) ti->whichTMU;
+ fxTMMoveInTM(fxMesa, tObj, tmu);
+
+ fxTexGetInfo(mml->width, mml->height,
+ &lodlevel, 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 = (GLushort *) texImage->Data + ((yoffset * mml->width) >> 1);
+ else
+ data = (GLushort *) texImage->Data + yoffset * mml->width;
+
+ switch (tmu) {
+ case FX_TMU0:
+ case FX_TMU1:
+ grTexDownloadMipMapLevelPartial(tmu,
+ ti->tm[tmu]->startAddr,
+ FX_valueToLod(FX_lodToValue(lodlevel)
+ + level),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH, data,
+ yoffset, yoffset + height - 1);
+ break;
+ case FX_TMU_SPLIT:
+ grTexDownloadMipMapLevelPartial(GR_TMU0,
+ ti->tm[FX_TMU0]->startAddr,
+ FX_valueToLod(FX_lodToValue(lodlevel)
+ + level),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_ODD, data,
+ yoffset, yoffset + height - 1);
+
+ grTexDownloadMipMapLevelPartial(GR_TMU1,
+ ti->tm[FX_TMU1]->startAddr,
+ FX_valueToLod(FX_lodToValue(lodlevel)
+ + level),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_EVEN, data,
+ yoffset, yoffset + height - 1);
+ break;
+ case FX_TMU_BOTH:
+ grTexDownloadMipMapLevelPartial(GR_TMU0,
+ ti->tm[FX_TMU0]->startAddr,
+ FX_valueToLod(FX_lodToValue(lodlevel)
+ + level),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH, data,
+ yoffset, yoffset + height - 1);
+
+ grTexDownloadMipMapLevelPartial(GR_TMU1,
+ ti->tm[FX_TMU1]->startAddr,
+ FX_valueToLod(FX_lodToValue(lodlevel)
+ + level),
+ FX_largeLodLog2(ti->info),
+ FX_aspectRatioLog2(ti->info),
+ ti->info.format,
+ GR_MIPMAPLEVELMASK_BOTH, data,
+ yoffset, yoffset + height - 1);
+ break;
+ default:
+ fprintf(stderr, "fxTMReloadSubMipMapLevel: INTERNAL ERROR: wrong tmu (%d)\n", tmu);
+ fxCloseHardware();
+ exit(-1);
+ }
+}
+
+void
+fxTMMoveOutTM(fxMesaContext fxMesa, struct gl_texture_object *tObj)
+{
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+
+ if (TDFX_DEBUG & VERBOSE_DRIVER) {
+ fprintf(stderr, "fxTMMoveOutTM(%p (%d))\n", (void *)tObj, tObj->Name);
+ }
+
+ if (!ti->isInTM)
+ return;
+
+ switch (ti->whichTMU) {
+ case FX_TMU0:
+ case FX_TMU1:
+ fxTMRemoveRange(fxMesa, (int) ti->whichTMU, ti->tm[ti->whichTMU]);
+ break;
+ case FX_TMU_SPLIT:
+ case FX_TMU_BOTH:
+ fxTMRemoveRange(fxMesa, FX_TMU0, ti->tm[FX_TMU0]);
+ fxTMRemoveRange(fxMesa, FX_TMU1, ti->tm[FX_TMU1]);
+ break;
+ default:
+ fprintf(stderr, "fxTMMoveOutTM: INTERNAL ERROR: bad TMU (%ld)\n", ti->whichTMU);
+ fxCloseHardware();
+ exit(-1);
+ }
+
+ ti->isInTM = GL_FALSE;
+ ti->whichTMU = FX_TMU_NONE;
+}
+
+void
+fxTMFreeTexture(fxMesaContext fxMesa, struct gl_texture_object *tObj)
+{
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+ int i;
+
+ if (TDFX_DEBUG & VERBOSE_TEXTURE) {
+ fprintf(stderr, "fxTMFreeTexture(%p (%d))\n", (void *)tObj, tObj->Name);
+ }
+
+ fxTMMoveOutTM(fxMesa, tObj);
+
+ for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
+ struct gl_texture_image *texImage = tObj->Image[0][i];
+ if (texImage) {
+ if (texImage->DriverData) {
+ FREE(texImage->DriverData);
+ texImage->DriverData = NULL;
+ }
+ }
+ }
+ switch (ti->whichTMU) {
+ case FX_TMU0:
+ case FX_TMU1:
+ fxTMDeleteRangeNode(fxMesa, ti->tm[ti->whichTMU]);
+ break;
+ case FX_TMU_SPLIT:
+ case FX_TMU_BOTH:
+ fxTMDeleteRangeNode(fxMesa, ti->tm[FX_TMU0]);
+ fxTMDeleteRangeNode(fxMesa, ti->tm[FX_TMU1]);
+ break;
+ }
+}
+
+void
+fxTMInit(fxMesaContext fxMesa)
+{
+ fxMesa->texBindNumber = 0;
+ fxMesa->tmPool = 0;
+
+ if (fxMesa->HaveTexUma) {
+ grEnable(GR_TEXTURE_UMA_EXT);
+ }
+
+ fxTMUInit(fxMesa, FX_TMU0);
+
+ if (!fxMesa->HaveTexUma && fxMesa->haveTwoTMUs)
+ fxTMUInit(fxMesa, FX_TMU1);
+
+ texBoundMask = (fxMesa->type >= GR_SSTTYPE_Banshee) ? -1 : (FX_2MB_SPLIT - 1);
+}
+
+void
+fxTMClose(fxMesaContext fxMesa)
+{
+ MemRange *tmp, *next;
+
+ tmp = fxMesa->tmPool;
+ while (tmp) {
+ next = tmp->next;
+ FREE(tmp);
+ tmp = next;
+ }
+ tmp = fxMesa->tmFree[FX_TMU0];
+ while (tmp) {
+ next = tmp->next;
+ FREE(tmp);
+ tmp = next;
+ }
+ if (fxMesa->haveTwoTMUs) {
+ tmp = fxMesa->tmFree[FX_TMU1];
+ while (tmp) {
+ next = tmp->next;
+ FREE(tmp);
+ tmp = next;
+ }
+ }
+}
+
+void
+fxTMRestoreTextures_NoLock(fxMesaContext ctx)
+{
+ struct _mesa_HashTable *textures = ctx->glCtx->Shared->TexObjects;
+ GLuint id;
+
+ for (id = _mesa_HashFirstEntry(textures);
+ id;
+ id = _mesa_HashNextEntry(textures, id)) {
+ struct gl_texture_object *tObj
+ = (struct gl_texture_object *) _mesa_HashLookup(textures, id);
+ tfxTexInfo *ti = fxTMGetTexInfo(tObj);
+ if (ti && ti->isInTM) {
+ int i;
+ for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
+ if (ctx->glCtx->Texture.Unit[i]._Current == tObj) {
+ /* Force the texture onto the board, as it could be in use */
+ int where = ti->whichTMU;
+ fxTMMoveOutTM_NoLock(ctx, tObj);
+ fxTMMoveInTM_NoLock(ctx, tObj, where);
+ break;
+ }
+ }
+ if (i == MAX_TEXTURE_UNITS) /* Mark the texture as off the board */
+ fxTMMoveOutTM_NoLock(ctx, tObj);
+ }
+ }
+}
+
+#else
+
+
+/*
+ * Need this to provide at least one external definition.
+ */
+
+extern int gl_fx_dummy_function_texman(void);
+int
+gl_fx_dummy_function_texman(void)
+{
+ return 0;
+}
+
+#endif /* FX */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxtris.c b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxtris.c
new file mode 100644
index 000000000..180637565
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxtris.c
@@ -0,0 +1,1834 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.0
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/* Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Daniel Borca <dborca@users.sourceforge.net>
+ */
+
+#include "glheader.h"
+
+#ifdef FX
+
+#include "imports.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "colormac.h"
+#include "nvfragprog.h"
+
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+
+#include "fxdrv.h"
+
+
+static GLboolean fxMultipass_ColorSum (GLcontext *ctx, GLuint pass);
+
+
+/*
+ * Subpixel offsets to adjust Mesa's (true) window coordinates to
+ * Glide coordinates. We need these to ensure precise rasterization.
+ * Otherwise, we'll fail a bunch of conformance tests.
+ */
+#define TRI_X_OFFSET ( 0.0F)
+#define TRI_Y_OFFSET ( 0.0F)
+#define LINE_X_OFFSET ( 0.0F)
+#define LINE_Y_OFFSET ( 0.125F)
+#define PNT_X_OFFSET ( 0.375F)
+#define PNT_Y_OFFSET ( 0.375F)
+
+static void fxRasterPrimitive( GLcontext *ctx, GLenum prim );
+static void fxRenderPrimitive( GLcontext *ctx, GLenum prim );
+
+static GLenum reduced_prim[GL_POLYGON+1] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES
+};
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ if (DO_FALLBACK) \
+ fxMesa->draw_tri( fxMesa, a, b, c ); \
+ else \
+ grDrawTriangle( a, b, c ); \
+} while (0) \
+
+#define QUAD( a, b, c, d ) \
+do { \
+ if (DO_FALLBACK) { \
+ fxMesa->draw_tri( fxMesa, a, b, d ); \
+ fxMesa->draw_tri( fxMesa, b, c, d ); \
+ } else { \
+ GrVertex *_v_[4]; \
+ _v_[0] = d; \
+ _v_[1] = a; \
+ _v_[2] = b; \
+ _v_[3] = c; \
+ grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_);\
+ /*grDrawTriangle( a, b, d );*/ \
+ /*grDrawTriangle( b, c, d );*/ \
+ } \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ if (DO_FALLBACK) \
+ fxMesa->draw_line( fxMesa, v0, v1 ); \
+ else { \
+ v0->x += LINE_X_OFFSET - TRI_X_OFFSET; \
+ v0->y += LINE_Y_OFFSET - TRI_Y_OFFSET; \
+ v1->x += LINE_X_OFFSET - TRI_X_OFFSET; \
+ v1->y += LINE_Y_OFFSET - TRI_Y_OFFSET; \
+ grDrawLine( v0, v1 ); \
+ v0->x -= LINE_X_OFFSET - TRI_X_OFFSET; \
+ v0->y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \
+ v1->x -= LINE_X_OFFSET - TRI_X_OFFSET; \
+ v1->y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \
+ } \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ if (DO_FALLBACK) \
+ fxMesa->draw_point( fxMesa, v0 ); \
+ else { \
+ v0->x += PNT_X_OFFSET - TRI_X_OFFSET; \
+ v0->y += PNT_Y_OFFSET - TRI_Y_OFFSET; \
+ grDrawPoint( v0 ); \
+ v0->x -= PNT_X_OFFSET - TRI_X_OFFSET; \
+ v0->y -= PNT_Y_OFFSET - TRI_Y_OFFSET; \
+ } \
+} while (0)
+
+
+/***********************************************************************
+ * Fallback to swrast for basic primitives *
+ ***********************************************************************/
+
+/* Build an SWvertex from a hardware vertex.
+ *
+ * This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+static void
+fx_translate_vertex( GLcontext *ctx, const GrVertex *src, SWvertex *dst)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLuint ts0 = fxMesa->tmu_source[0];
+ GLuint ts1 = fxMesa->tmu_source[1];
+ GLfloat w = 1.0F / src->oow;
+
+ dst->win[0] = src->x;
+ dst->win[1] = src->y;
+ dst->win[2] = src->ooz;
+ dst->win[3] = src->oow;
+
+#if FX_PACKEDCOLOR
+ dst->color[0] = src->pargb[2];
+ dst->color[1] = src->pargb[1];
+ dst->color[2] = src->pargb[0];
+ dst->color[3] = src->pargb[3];
+
+ dst->specular[0] = src->pspec[2];
+ dst->specular[1] = src->pspec[1];
+ dst->specular[2] = src->pspec[0];
+#else /* !FX_PACKEDCOLOR */
+ dst->color[0] = src->r;
+ dst->color[1] = src->g;
+ dst->color[2] = src->b;
+ dst->color[3] = src->a;
+
+ dst->specular[0] = src->r1;
+ dst->specular[1] = src->g1;
+ dst->specular[2] = src->g1;
+#endif /* !FX_PACKEDCOLOR */
+
+ dst->texcoord[ts0][0] = fxMesa->inv_s0scale * src->tmuvtx[0].sow * w;
+ dst->texcoord[ts0][1] = fxMesa->inv_t0scale * src->tmuvtx[0].tow * w;
+
+ if (fxMesa->stw_hint_state & GR_STWHINT_W_DIFF_TMU0)
+ dst->texcoord[ts0][3] = src->tmuvtx[0].oow * w;
+ else
+ dst->texcoord[ts0][3] = 1.0F;
+
+ if (fxMesa->SetupIndex & SETUP_TMU1) {
+ dst->texcoord[ts1][0] = fxMesa->inv_s1scale * src->tmuvtx[1].sow * w;
+ dst->texcoord[ts1][1] = fxMesa->inv_t1scale * src->tmuvtx[1].tow * w;
+
+ if (fxMesa->stw_hint_state & GR_STWHINT_W_DIFF_TMU1)
+ dst->texcoord[ts1][3] = src->tmuvtx[1].oow * w;
+ else
+ dst->texcoord[ts1][3] = 1.0F;
+ }
+
+ dst->pointSize = src->psize;
+}
+
+
+static void
+fx_fallback_tri( fxMesaContext fxMesa,
+ GrVertex *v0,
+ GrVertex *v1,
+ GrVertex *v2 )
+{
+ GLcontext *ctx = fxMesa->glCtx;
+ SWvertex v[3];
+
+ fx_translate_vertex( ctx, v0, &v[0] );
+ fx_translate_vertex( ctx, v1, &v[1] );
+ fx_translate_vertex( ctx, v2, &v[2] );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+}
+
+
+static void
+fx_fallback_line( fxMesaContext fxMesa,
+ GrVertex *v0,
+ GrVertex *v1 )
+{
+ GLcontext *ctx = fxMesa->glCtx;
+ SWvertex v[2];
+ fx_translate_vertex( ctx, v0, &v[0] );
+ fx_translate_vertex( ctx, v1, &v[1] );
+ _swrast_Line( ctx, &v[0], &v[1] );
+}
+
+
+static void
+fx_fallback_point( fxMesaContext fxMesa,
+ GrVertex *v0 )
+{
+ GLcontext *ctx = fxMesa->glCtx;
+ SWvertex v[1];
+ fx_translate_vertex( ctx, v0, &v[0] );
+ _swrast_Point( ctx, &v[0] );
+}
+
+/***********************************************************************
+ * Functions to draw basic primitives *
+ ***********************************************************************/
+
+static void fx_print_vertex( GLcontext *ctx, const GrVertex *v )
+{
+ fprintf(stderr, "fx_print_vertex:\n");
+
+ fprintf(stderr, "\tvertex at %p\n", (void *) v);
+
+ fprintf(stderr, "\tx %f y %f z %f oow %f\n", v->x, v->y, v->ooz, v->oow);
+#if FX_PACKEDCOLOR
+ fprintf(stderr, "\tr %d g %d b %d a %d\n", v->pargb[2], v->pargb[1], v->pargb[0], v->pargb[3]);
+#else /* !FX_PACKEDCOLOR */
+ fprintf(stderr, "\tr %f g %f b %f a %f\n", v->r, v->g, v->b, v->a);
+#endif /* !FX_PACKEDCOLOR */
+
+ fprintf(stderr, "\n");
+}
+
+#define DO_FALLBACK 0
+
+/* Need to do clip loop at each triangle when mixing swrast and hw
+ * rendering. These functions are only used when mixed-mode rendering
+ * is occurring.
+ */
+static void fx_draw_triangle( fxMesaContext fxMesa,
+ GrVertex *v0,
+ GrVertex *v1,
+ GrVertex *v2 )
+{
+ BEGIN_CLIP_LOOP();
+ TRI( v0, v1, v2 );
+ END_CLIP_LOOP();
+}
+
+static void fx_draw_line( fxMesaContext fxMesa,
+ GrVertex *v0,
+ GrVertex *v1 )
+{
+ /* No support for wide lines (avoid wide/aa line fallback).
+ */
+ BEGIN_CLIP_LOOP();
+ LINE(v0, v1);
+ END_CLIP_LOOP();
+}
+
+static void fx_draw_point( fxMesaContext fxMesa,
+ GrVertex *v0 )
+{
+ /* No support for wide points.
+ */
+ BEGIN_CLIP_LOOP();
+ POINT( v0 );
+ END_CLIP_LOOP();
+}
+
+#ifndef M_2PI
+#define M_2PI 6.28318530717958647692528676655901
+#endif
+#define __GL_COSF cos
+#define __GL_SINF sin
+static void fx_draw_point_sprite ( fxMesaContext fxMesa,
+ GrVertex *v0, GLfloat psize )
+{
+ const GLcontext *ctx = fxMesa->glCtx;
+
+ GLfloat radius;
+ GrVertex _v_[4];
+ GLuint ts0 = fxMesa->tmu_source[0];
+ GLuint ts1 = fxMesa->tmu_source[1];
+ GLfloat w = v0->oow;
+ GLfloat u0scale = fxMesa->s0scale * w;
+ GLfloat v0scale = fxMesa->t0scale * w;
+ GLfloat u1scale = fxMesa->s1scale * w;
+ GLfloat v1scale = fxMesa->t1scale * w;
+
+ radius = psize / 2.0F;
+ _v_[0] = *v0;
+ _v_[1] = *v0;
+ _v_[2] = *v0;
+ _v_[3] = *v0;
+ /* CLIP_LOOP ?!? */
+ /* point coverage? */
+ /* we don't care about culling here (see fxSetupCull) */
+
+ if (ctx->Point.SpriteOrigin == GL_UPPER_LEFT) {
+ _v_[0].x -= radius;
+ _v_[0].y += radius;
+ _v_[1].x += radius;
+ _v_[1].y += radius;
+ _v_[2].x += radius;
+ _v_[2].y -= radius;
+ _v_[3].x -= radius;
+ _v_[3].y -= radius;
+ } else {
+ _v_[0].x -= radius;
+ _v_[0].y -= radius;
+ _v_[1].x += radius;
+ _v_[1].y -= radius;
+ _v_[2].x += radius;
+ _v_[2].y += radius;
+ _v_[3].x -= radius;
+ _v_[3].y += radius;
+ }
+
+ if (ctx->Point.CoordReplace[ts0]) {
+ _v_[0].tmuvtx[0].sow = 0;
+ _v_[0].tmuvtx[0].tow = 0;
+ _v_[1].tmuvtx[0].sow = u0scale;
+ _v_[1].tmuvtx[0].tow = 0;
+ _v_[2].tmuvtx[0].sow = u0scale;
+ _v_[2].tmuvtx[0].tow = v0scale;
+ _v_[3].tmuvtx[0].sow = 0;
+ _v_[3].tmuvtx[0].tow = v0scale;
+ }
+ if (ctx->Point.CoordReplace[ts1]) {
+ _v_[0].tmuvtx[1].sow = 0;
+ _v_[0].tmuvtx[1].tow = 0;
+ _v_[1].tmuvtx[1].sow = u1scale;
+ _v_[1].tmuvtx[1].tow = 0;
+ _v_[2].tmuvtx[1].sow = u1scale;
+ _v_[2].tmuvtx[1].tow = v1scale;
+ _v_[3].tmuvtx[1].sow = 0;
+ _v_[3].tmuvtx[1].tow = v1scale;
+ }
+
+ grDrawVertexArrayContiguous(GR_TRIANGLE_FAN, 4, _v_, sizeof(GrVertex));
+}
+
+static void fx_draw_point_wide ( fxMesaContext fxMesa,
+ GrVertex *v0 )
+{
+ GLint i, n;
+ GLfloat ang, radius, oon;
+ GrVertex vtxB, vtxC;
+ GrVertex *_v_[3];
+
+ const GLcontext *ctx = fxMesa->glCtx;
+ const GLfloat psize = (ctx->_TriangleCaps & DD_POINT_ATTEN)
+ ? CLAMP(v0->psize, ctx->Point.MinSize, ctx->Point.MaxSize)
+ : ctx->Point._Size; /* clamped */
+
+ if (ctx->Point.PointSprite) {
+ fx_draw_point_sprite(fxMesa, v0, psize);
+ return;
+ }
+
+ _v_[0] = v0;
+ _v_[1] = &vtxB;
+ _v_[2] = &vtxC;
+
+ radius = psize / 2.0F;
+ n = IROUND(psize * 2); /* radius x 4 */
+ if (n < 4) n = 4;
+ oon = 1.0F / (GLfloat)n;
+
+ /* CLIP_LOOP ?!? */
+ /* point coverage? */
+ /* we don't care about culling here (see fxSetupCull) */
+
+ vtxB = *v0;
+ vtxC = *v0;
+
+ vtxB.x += radius;
+ ang = M_2PI * oon;
+ vtxC.x += radius * __GL_COSF(ang);
+ vtxC.y += radius * __GL_SINF(ang);
+ grDrawVertexArray(GR_TRIANGLE_FAN, 3, _v_);
+ for (i = 2; i <= n; i++) {
+ ang = M_2PI * i * oon;
+ vtxC.x = v0->x + radius * __GL_COSF(ang);
+ vtxC.y = v0->y + radius * __GL_SINF(ang);
+ grDrawVertexArray(GR_TRIANGLE_FAN_CONTINUE, 1, &_v_[2]);
+ }
+}
+
+static void fx_render_pw_verts( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrVertex *fxVB = fxMesa->verts;
+ (void) flags;
+
+ fxRenderPrimitive( ctx, GL_POINTS );
+
+ for ( ; start < count ; start++)
+ fx_draw_point_wide(fxMesa, fxVB + start);
+}
+
+static void fx_render_pw_elts ( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrVertex *fxVB = fxMesa->verts;
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;
+ (void) flags;
+
+ fxRenderPrimitive( ctx, GL_POINTS );
+
+ for ( ; start < count ; start++)
+ fx_draw_point_wide(fxMesa, fxVB + elt[start]);
+}
+
+static void fx_draw_point_wide_aa ( fxMesaContext fxMesa,
+ GrVertex *v0 )
+{
+ GLint i, n;
+ GLfloat ang, radius, oon;
+ GrVertex vtxB, vtxC;
+
+ const GLcontext *ctx = fxMesa->glCtx;
+ const GLfloat psize = (ctx->_TriangleCaps & DD_POINT_ATTEN)
+ ? CLAMP(v0->psize, ctx->Point.MinSize, ctx->Point.MaxSize)
+ : ctx->Point._Size; /* clamped */
+
+ if (ctx->Point.PointSprite) {
+ fx_draw_point_sprite(fxMesa, v0, psize);
+ return;
+ }
+
+ radius = psize / 2.0F;
+ n = IROUND(psize * 2); /* radius x 4 */
+ if (n < 4) n = 4;
+ oon = 1.0F / (GLfloat)n;
+
+ /* CLIP_LOOP ?!? */
+ /* point coverage? */
+ /* we don't care about culling here (see fxSetupCull) */
+
+ vtxB = *v0;
+ vtxC = *v0;
+
+ vtxB.x += radius;
+ for (i = 1; i <= n; i++) {
+ ang = M_2PI * i * oon;
+ vtxC.x = v0->x + radius * __GL_COSF(ang);
+ vtxC.y = v0->y + radius * __GL_SINF(ang);
+ grAADrawTriangle( v0, &vtxB, &vtxC, FXFALSE, FXTRUE, FXFALSE);
+ /*grDrawTriangle( v0, &vtxB, &vtxC);*/
+ vtxB.x = vtxC.x;
+ vtxB.y = vtxC.y;
+ }
+}
+#undef __GLCOSF
+#undef __GLSINF
+#undef M_2PI
+
+#undef DO_FALLBACK
+
+
+#define FX_UNFILLED_BIT 0x1
+#define FX_OFFSET_BIT 0x2
+#define FX_TWOSIDE_BIT 0x4
+#define FX_FLAT_BIT 0x8
+#define FX_TWOSTENCIL_BIT 0x10
+#define FX_FALLBACK_BIT 0x20
+#define FX_MAX_TRIFUNC 0x40
+
+static struct {
+ tnl_points_func points;
+ tnl_line_func line;
+ tnl_triangle_func triangle;
+ tnl_quad_func quad;
+} rast_tab[FX_MAX_TRIFUNC];
+
+#define DO_FALLBACK (IND & FX_FALLBACK_BIT)
+#define DO_OFFSET (IND & FX_OFFSET_BIT)
+#define DO_UNFILLED (IND & FX_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & FX_TWOSIDE_BIT)
+#define DO_FLAT (IND & FX_FLAT_BIT)
+#define DO_TWOSTENCIL (IND & FX_TWOSTENCIL_BIT)
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 1
+#define HAVE_HW_FLATSHADE 0
+#define HAVE_BACK_COLORS 0
+#define VERTEX GrVertex
+#define TAB rast_tab
+
+#define DEPTH_SCALE 1.0
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->x
+#define VERT_Y(_v) _v->y
+#define VERT_Z(_v) _v->ooz
+#define AREA_IS_CCW( a ) IS_NEGATIVE( a )
+#define GET_VERTEX(e) (fxMesa->verts + e)
+
+
+#if FX_PACKEDCOLOR
+#define VERT_SET_RGBA( dst, f ) \
+do { \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst->pargb[2], f[0]);\
+ UNCLAMPED_FLOAT_TO_UBYTE(dst->pargb[1], f[1]);\
+ UNCLAMPED_FLOAT_TO_UBYTE(dst->pargb[0], f[2]);\
+ UNCLAMPED_FLOAT_TO_UBYTE(dst->pargb[3], f[3]);\
+} while (0)
+
+#define VERT_COPY_RGBA( v0, v1 ) \
+ *(GLuint *)&v0->pargb = *(GLuint *)&v1->pargb
+
+#define VERT_SAVE_RGBA( idx ) \
+ *(GLuint *)&color[idx] = *(GLuint *)&v[idx]->pargb
+
+#define VERT_RESTORE_RGBA( idx ) \
+ *(GLuint *)&v[idx]->pargb = *(GLuint *)&color[idx]
+
+
+#define VERT_SET_SPEC( dst, f ) \
+do { \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst->pspec[2], f[0]);\
+ UNCLAMPED_FLOAT_TO_UBYTE(dst->pspec[1], f[1]);\
+ UNCLAMPED_FLOAT_TO_UBYTE(dst->pspec[0], f[2]);\
+} while (0)
+
+#define VERT_COPY_SPEC( v0, v1 ) \
+ *(GLuint *)&v0->pspec = *(GLuint *)&v1->pspec
+
+#define VERT_SAVE_SPEC( idx ) \
+ *(GLuint *)&spec[idx] = *(GLuint *)&v[idx]->pspec
+
+#define VERT_RESTORE_SPEC( idx ) \
+ *(GLuint *)&v[idx]->pspec = *(GLuint *)&spec[idx]
+
+
+#define LOCAL_VARS(n) \
+ fxMesaContext fxMesa = FX_CONTEXT(ctx); \
+ GLubyte color[n][4], spec[n][4]; \
+ (void) color; (void) spec;
+#else /* !FX_PACKEDCOLOR */
+#define VERT_SET_RGBA( dst, f ) \
+do { \
+ CNORM(dst->r, f[0]); \
+ CNORM(dst->g, f[1]); \
+ CNORM(dst->b, f[2]); \
+ CNORM(dst->a, f[3]); \
+} while (0)
+
+#define VERT_COPY_RGBA( v0, v1 ) \
+do { \
+ COPY_FLOAT(v0->r, v1->r); \
+ COPY_FLOAT(v0->g, v1->g); \
+ COPY_FLOAT(v0->b, v1->b); \
+ COPY_FLOAT(v0->a, v1->a); \
+} while (0)
+
+#define VERT_SAVE_RGBA( idx ) \
+do { \
+ COPY_FLOAT(color[idx][0], v[idx]->r); \
+ COPY_FLOAT(color[idx][1], v[idx]->g); \
+ COPY_FLOAT(color[idx][2], v[idx]->b); \
+ COPY_FLOAT(color[idx][3], v[idx]->a); \
+} while (0)
+
+#define VERT_RESTORE_RGBA( idx ) \
+do { \
+ COPY_FLOAT(v[idx]->r, color[idx][0]); \
+ COPY_FLOAT(v[idx]->g, color[idx][1]); \
+ COPY_FLOAT(v[idx]->b, color[idx][2]); \
+ COPY_FLOAT(v[idx]->a, color[idx][3]); \
+} while (0)
+
+
+#define VERT_SET_SPEC( dst, f ) \
+do { \
+ CNORM(dst->r1, f[0]); \
+ CNORM(dst->g1, f[1]); \
+ CNORM(dst->b1, f[2]); \
+} while (0)
+
+#define VERT_COPY_SPEC( v0, v1 ) \
+do { \
+ COPY_FLOAT(v0->r1, v1->r1); \
+ COPY_FLOAT(v0->g1, v1->g1); \
+ COPY_FLOAT(v0->b1, v1->b1); \
+} while (0)
+
+#define VERT_SAVE_SPEC( idx ) \
+do { \
+ COPY_FLOAT(spec[idx][0], v[idx]->r1); \
+ COPY_FLOAT(spec[idx][1], v[idx]->g1); \
+ COPY_FLOAT(spec[idx][2], v[idx]->b1); \
+} while (0)
+
+#define VERT_RESTORE_SPEC( idx ) \
+do { \
+ COPY_FLOAT(v[idx]->r1, spec[idx][0]); \
+ COPY_FLOAT(v[idx]->g1, spec[idx][1]); \
+ COPY_FLOAT(v[idx]->b1, spec[idx][2]); \
+} while (0)
+
+
+#define LOCAL_VARS(n) \
+ fxMesaContext fxMesa = FX_CONTEXT(ctx); \
+ GLfloat color[n][4], spec[n][4]; \
+ (void) color; (void) spec;
+#endif /* !FX_PACKEDCOLOR */
+
+
+/***********************************************************************
+ * Twoside stencil *
+ ***********************************************************************/
+#define SETUP_STENCIL(f) if (f) fxSetupStencilFace(ctx, f)
+#define UNSET_STENCIL(f) if (f) fxSetupStencil(ctx)
+
+
+/***********************************************************************
+ * Functions to draw basic unfilled primitives *
+ ***********************************************************************/
+
+#define RASTERIZE(x) if (fxMesa->raster_primitive != reduced_prim[x]) \
+ fxRasterPrimitive( ctx, reduced_prim[x] )
+#define RENDER_PRIMITIVE fxMesa->render_primitive
+#define IND FX_FALLBACK_BIT
+#define TAG(x) x
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+/***********************************************************************
+ * Functions to draw GL primitives *
+ ***********************************************************************/
+
+#define IND (0)
+#define TAG(x) x
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT)
+#define TAG(x) x##_twoside_offset
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_FALLBACK_BIT)
+#define TAG(x) x##_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_OFFSET_BIT|FX_FALLBACK_BIT)
+#define TAG(x) x##_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_FALLBACK_BIT)
+#define TAG(x) x##_twoside_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_UNFILLED_BIT|FX_FALLBACK_BIT)
+#define TAG(x) x##_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT)
+#define TAG(x) x##_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT| \
+ FX_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+/* Fx doesn't support provoking-vertex flat-shading?
+ */
+#define IND (FX_FLAT_BIT)
+#define TAG(x) x##_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_OFFSET_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_offset_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_twoside_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_UNFILLED_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_offset_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_twoside_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_FALLBACK_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_offset_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_twoside_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_offset_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT| \
+ FX_FALLBACK_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+/* 2-sided stencil begin */
+#define IND (FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_OFFSET_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_offset_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_twoside_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_twoside_offset_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_UNFILLED_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_unfilled_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_offset_unfilled_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_twoside_unfilled_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_FALLBACK_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_fallback_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_offset_fallback_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_FALLBACK_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_twoside_fallback_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_twoside_offset_fallback_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_unfilled_fallback_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_offset_unfilled_fallback_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT| \
+ FX_FALLBACK_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+
+/* Fx doesn't support provoking-vertex flat-shading?
+ */
+#define IND (FX_FLAT_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_flat_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_OFFSET_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_offset_flat_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_twoside_flat_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_twoside_offset_flat_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_UNFILLED_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_unfilled_flat_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_offset_unfilled_flat_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_twoside_unfilled_flat_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_flat_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_FALLBACK_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_fallback_flat_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_offset_fallback_flat_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_twoside_fallback_flat_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_twoside_offset_fallback_flat_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_unfilled_fallback_flat_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_offset_unfilled_fallback_flat_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback_flat_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT| \
+ FX_FALLBACK_BIT|FX_FLAT_BIT|FX_TWOSTENCIL_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback_flat_twostencil
+#include "tnl_dd/t_dd_tritmp.h"
+/* 2-sided stencil end */
+
+
+static void init_rast_tab( void )
+{
+ init();
+ init_offset();
+ init_twoside();
+ init_twoside_offset();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
+ init_fallback();
+ init_offset_fallback();
+ init_twoside_fallback();
+ init_twoside_offset_fallback();
+ init_unfilled_fallback();
+ init_offset_unfilled_fallback();
+ init_twoside_unfilled_fallback();
+ init_twoside_offset_unfilled_fallback();
+
+ init_flat();
+ init_offset_flat();
+ init_twoside_flat();
+ init_twoside_offset_flat();
+ init_unfilled_flat();
+ init_offset_unfilled_flat();
+ init_twoside_unfilled_flat();
+ init_twoside_offset_unfilled_flat();
+ init_fallback_flat();
+ init_offset_fallback_flat();
+ init_twoside_fallback_flat();
+ init_twoside_offset_fallback_flat();
+ init_unfilled_fallback_flat();
+ init_offset_unfilled_fallback_flat();
+ init_twoside_unfilled_fallback_flat();
+ init_twoside_offset_unfilled_fallback_flat();
+
+ /* 2-sided stencil begin */
+ init_twostencil();
+ init_offset_twostencil();
+ init_twoside_twostencil();
+ init_twoside_offset_twostencil();
+ init_unfilled_twostencil();
+ init_offset_unfilled_twostencil();
+ init_twoside_unfilled_twostencil();
+ init_twoside_offset_unfilled_twostencil();
+ init_fallback_twostencil();
+ init_offset_fallback_twostencil();
+ init_twoside_fallback_twostencil();
+ init_twoside_offset_fallback_twostencil();
+ init_unfilled_fallback_twostencil();
+ init_offset_unfilled_fallback_twostencil();
+ init_twoside_unfilled_fallback_twostencil();
+ init_twoside_offset_unfilled_fallback_twostencil();
+
+ init_flat_twostencil();
+ init_offset_flat_twostencil();
+ init_twoside_flat_twostencil();
+ init_twoside_offset_flat_twostencil();
+ init_unfilled_flat_twostencil();
+ init_offset_unfilled_flat_twostencil();
+ init_twoside_unfilled_flat_twostencil();
+ init_twoside_offset_unfilled_flat_twostencil();
+ init_fallback_flat_twostencil();
+ init_offset_fallback_flat_twostencil();
+ init_twoside_fallback_flat_twostencil();
+ init_twoside_offset_fallback_flat_twostencil();
+ init_unfilled_fallback_flat_twostencil();
+ init_offset_unfilled_fallback_flat_twostencil();
+ init_twoside_unfilled_fallback_flat_twostencil();
+ init_twoside_offset_unfilled_fallback_flat_twostencil();
+ /* 2-sided stencil end */
+}
+
+
+/**********************************************************************/
+/* Render whole begin/end objects */
+/**********************************************************************/
+
+
+/* Accelerate vertex buffer rendering when renderindex == 0 and
+ * there is no clipping.
+ */
+#define INIT(x) fxRenderPrimitive( ctx, x )
+
+static void fx_render_vb_points( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrVertex *fxVB = fxMesa->verts;
+ GLint i;
+ (void) flags;
+
+ if (TDFX_DEBUG & VERBOSE_VARRAY) {
+ fprintf(stderr, "fx_render_vb_points\n");
+ }
+
+ INIT(GL_POINTS);
+
+ /* Adjust point coords */
+ for (i = start; i < count; i++) {
+ fxVB[i].x += PNT_X_OFFSET - TRI_X_OFFSET;
+ fxVB[i].y += PNT_Y_OFFSET - TRI_Y_OFFSET;
+ }
+
+ grDrawVertexArrayContiguous( GR_POINTS, count-start,
+ fxVB + start, sizeof(GrVertex));
+ /* restore point coords */
+ for (i = start; i < count; i++) {
+ fxVB[i].x -= PNT_X_OFFSET - TRI_X_OFFSET;
+ fxVB[i].y -= PNT_Y_OFFSET - TRI_Y_OFFSET;
+ }
+}
+
+static void fx_render_vb_line_strip( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrVertex *fxVB = fxMesa->verts;
+ GLint i;
+ (void) flags;
+
+ if (TDFX_DEBUG & VERBOSE_VARRAY) {
+ fprintf(stderr, "fx_render_vb_line_strip\n");
+ }
+
+ INIT(GL_LINE_STRIP);
+
+ /* adjust line coords */
+ for (i = start; i < count; i++) {
+ fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET;
+ fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET;
+ }
+
+ grDrawVertexArrayContiguous( GR_LINE_STRIP, count-start,
+ fxVB + start, sizeof(GrVertex));
+
+ /* restore line coords */
+ for (i = start; i < count; i++) {
+ fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET;
+ fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
+ }
+}
+
+static void fx_render_vb_line_loop( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrVertex *fxVB = fxMesa->verts;
+ GLint i;
+ GLint j = start;
+ (void) flags;
+
+ if (TDFX_DEBUG & VERBOSE_VARRAY) {
+ fprintf(stderr, "fx_render_vb_line_loop\n");
+ }
+
+ INIT(GL_LINE_LOOP);
+
+ if (!(flags & PRIM_BEGIN)) {
+ j++;
+ }
+
+ /* adjust line coords */
+ for (i = start; i < count; i++) {
+ fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET;
+ fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET;
+ }
+
+ grDrawVertexArrayContiguous( GR_LINE_STRIP, count-j,
+ fxVB + j, sizeof(GrVertex));
+
+ if (flags & PRIM_END)
+ grDrawLine( fxVB + (count - 1),
+ fxVB + start );
+
+ /* restore line coords */
+ for (i = start; i < count; i++) {
+ fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET;
+ fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
+ }
+}
+
+static void fx_render_vb_lines( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrVertex *fxVB = fxMesa->verts;
+ GLint i;
+ (void) flags;
+
+ if (TDFX_DEBUG & VERBOSE_VARRAY) {
+ fprintf(stderr, "fx_render_vb_lines\n");
+ }
+
+ INIT(GL_LINES);
+
+ /* adjust line coords */
+ for (i = start; i < count; i++) {
+ fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET;
+ fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET;
+ }
+
+ grDrawVertexArrayContiguous( GR_LINES, count-start,
+ fxVB + start, sizeof(GrVertex));
+
+ /* restore line coords */
+ for (i = start; i < count; i++) {
+ fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET;
+ fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
+ }
+}
+
+static void fx_render_vb_triangles( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrVertex *fxVB = fxMesa->verts;
+ GLuint j;
+ (void) flags;
+
+ if (TDFX_DEBUG & VERBOSE_VARRAY) {
+ fprintf(stderr, "fx_render_vb_triangles\n");
+ }
+
+ INIT(GL_TRIANGLES);
+
+ for (j=start+2; j<count; j+=3) {
+ grDrawTriangle(fxVB + (j-2), fxVB + (j-1), fxVB + j);
+ }
+}
+
+
+static void fx_render_vb_tri_strip( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrVertex *fxVB = fxMesa->verts;
+ (void) flags;
+
+ if (TDFX_DEBUG & VERBOSE_VARRAY) {
+ fprintf(stderr, "fx_render_vb_tri_strip\n");
+ }
+
+ INIT(GL_TRIANGLE_STRIP);
+
+ /* no GR_TRIANGLE_STRIP_CONTINUE?!? */
+
+ grDrawVertexArrayContiguous( GR_TRIANGLE_STRIP, count-start,
+ fxVB + start, sizeof(GrVertex));
+}
+
+
+static void fx_render_vb_tri_fan( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrVertex *fxVB = fxMesa->verts;
+ (void) flags;
+
+ if (TDFX_DEBUG & VERBOSE_VARRAY) {
+ fprintf(stderr, "fx_render_vb_tri_fan\n");
+ }
+
+ INIT(GL_TRIANGLE_FAN);
+
+ grDrawVertexArrayContiguous( GR_TRIANGLE_FAN, count-start,
+ fxVB + start, sizeof(GrVertex) );
+}
+
+static void fx_render_vb_quads( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrVertex *fxVB = fxMesa->verts;
+ GLuint i;
+ (void) flags;
+
+ if (TDFX_DEBUG & VERBOSE_VARRAY) {
+ fprintf(stderr, "fx_render_vb_quads\n");
+ }
+
+ INIT(GL_QUADS);
+
+ for (i = start + 3 ; i < count ; i += 4 ) {
+#define VERT(x) (fxVB + (x))
+ GrVertex *_v_[4];
+ _v_[0] = VERT(i);
+ _v_[1] = VERT(i-3);
+ _v_[2] = VERT(i-2);
+ _v_[3] = VERT(i-1);
+ grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_);
+ /*grDrawTriangle( VERT(i-3), VERT(i-2), VERT(i) );*/
+ /*grDrawTriangle( VERT(i-2), VERT(i-1), VERT(i) );*/
+#undef VERT
+ }
+}
+
+static void fx_render_vb_quad_strip( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrVertex *fxVB = fxMesa->verts;
+ (void) flags;
+
+ if (TDFX_DEBUG & VERBOSE_VARRAY) {
+ fprintf(stderr, "fx_render_vb_quad_strip\n");
+ }
+
+ INIT(GL_QUAD_STRIP);
+
+ count -= (count-start)&1;
+
+ grDrawVertexArrayContiguous( GR_TRIANGLE_STRIP,
+ count-start, fxVB + start, sizeof(GrVertex));
+}
+
+static void fx_render_vb_poly( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GrVertex *fxVB = fxMesa->verts;
+ (void) flags;
+
+ if (TDFX_DEBUG & VERBOSE_VARRAY) {
+ fprintf(stderr, "fx_render_vb_poly\n");
+ }
+
+ INIT(GL_POLYGON);
+
+ grDrawVertexArrayContiguous( GR_POLYGON, count-start,
+ fxVB + start, sizeof(GrVertex));
+}
+
+static void fx_render_vb_noop( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ (void) (ctx && start && count && flags);
+}
+
+static void (*fx_render_tab_verts[GL_POLYGON+2])(GLcontext *,
+ GLuint,
+ GLuint,
+ GLuint) =
+{
+ fx_render_vb_points,
+ fx_render_vb_lines,
+ fx_render_vb_line_loop,
+ fx_render_vb_line_strip,
+ fx_render_vb_triangles,
+ fx_render_vb_tri_strip,
+ fx_render_vb_tri_fan,
+ fx_render_vb_quads,
+ fx_render_vb_quad_strip,
+ fx_render_vb_poly,
+ fx_render_vb_noop,
+};
+#undef INIT
+
+
+/**********************************************************************/
+/* Render whole (indexed) begin/end objects */
+/**********************************************************************/
+
+
+#define VERT(x) (vertptr + x)
+
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ grDrawPoint( VERT(ELT(start)) );
+
+#define RENDER_LINE( v0, v1 ) \
+ grDrawLine( VERT(v0), VERT(v1) )
+
+#define RENDER_TRI( v0, v1, v2 ) \
+ grDrawTriangle( VERT(v0), VERT(v1), VERT(v2) )
+
+#define RENDER_QUAD( v0, v1, v2, v3 ) \
+ do { \
+ GrVertex *_v_[4]; \
+ _v_[0] = VERT(v3);\
+ _v_[1] = VERT(v0);\
+ _v_[2] = VERT(v1);\
+ _v_[3] = VERT(v2);\
+ grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_);\
+ /*grDrawTriangle( VERT(v0), VERT(v1), VERT(v3) );*/\
+ /*grDrawTriangle( VERT(v1), VERT(v2), VERT(v3) );*/\
+ } while (0)
+
+#define INIT(x) fxRenderPrimitive( ctx, x )
+
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ fxMesaContext fxMesa = FX_CONTEXT(ctx); \
+ GrVertex *vertptr = fxMesa->verts; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ (void) elt;
+
+#define RESET_STIPPLE
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
+
+/* Elts, no clipping.
+ */
+#undef ELT
+#undef TAG
+#define TAG(x) fx_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl_dd/t_dd_rendertmp.h"
+
+/* Verts, no clipping.
+ */
+#undef ELT
+#undef TAG
+#define TAG(x) fx_##x##_verts
+#define ELT(x) x
+/*#include "tnl_dd/t_dd_rendertmp.h"*/ /* we have fx_render_vb_* now */
+
+
+
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
+
+
+
+static void fxRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint prim = fxMesa->render_primitive;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n,
+ PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+ }
+
+ /* Restore the render primitive
+ */
+ if (prim != GL_POLYGON)
+ tnl->Driver.Render.PrimitiveNotify( ctx, prim );
+}
+
+
+static void fxFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ int i;
+ fxMesaContext fxMesa = FX_CONTEXT( ctx );
+ GrVertex *vertptr = fxMesa->verts;
+ if (n == 3) {
+ grDrawTriangle( VERT(elts[0]), VERT(elts[1]), VERT(elts[2]) );
+ } else if (n <= 32) {
+ GrVertex *newvptr[32];
+ for (i = 0 ; i < n ; i++) {
+ newvptr[i] = VERT(elts[i]);
+ }
+ grDrawVertexArray(GR_TRIANGLE_FAN, n, newvptr);
+ } else {
+ const GrVertex *start = VERT(elts[0]);
+ for (i = 2 ; i < n ; i++) {
+ grDrawTriangle( start, VERT(elts[i-1]), VERT(elts[i]) );
+ }
+ }
+}
+
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+
+
+#define POINT_FALLBACK (DD_POINT_SMOOTH)
+#define LINE_FALLBACK (DD_LINE_STIPPLE)
+#define TRI_FALLBACK (DD_TRI_SMOOTH | DD_TRI_STIPPLE)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK | LINE_FALLBACK | TRI_FALLBACK)
+#define ANY_RASTER_FLAGS (DD_FLATSHADE | DD_TRI_LIGHT_TWOSIDE | DD_TRI_OFFSET \
+ | DD_TRI_UNFILLED | DD_TRI_TWOSTENCIL)
+
+
+
+void fxDDChooseRenderState(GLcontext *ctx)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
+
+ if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) {
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_TWOSTENCIL) index |= FX_TWOSTENCIL_BIT;
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= FX_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= FX_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= FX_UNFILLED_BIT;
+ if (flags & DD_FLATSHADE) index |= FX_FLAT_BIT;
+ }
+
+ fxMesa->draw_point = fx_draw_point;
+ fxMesa->draw_line = fx_draw_line;
+ fxMesa->draw_tri = fx_draw_triangle;
+
+ /* Hook in fallbacks for specific primitives. */
+ if (flags & (POINT_FALLBACK|
+ LINE_FALLBACK|
+ TRI_FALLBACK))
+ {
+ if (fxMesa->verbose) {
+ fprintf(stderr, "Voodoo ! fallback (%x), raster (%x)\n",
+ flags & ANY_FALLBACK_FLAGS, flags & ANY_RASTER_FLAGS);
+ }
+
+ if (flags & POINT_FALLBACK)
+ fxMesa->draw_point = fx_fallback_point;
+
+ if (flags & LINE_FALLBACK)
+ fxMesa->draw_line = fx_fallback_line;
+
+ if (flags & TRI_FALLBACK)
+ fxMesa->draw_tri = fx_fallback_tri;
+
+ index |= FX_FALLBACK_BIT;
+ }
+ }
+
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.ClippedLine = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = fx_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = fx_render_tab_elts;
+ tnl->Driver.Render.ClippedPolygon = fxFastRenderClippedPoly;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedPolygon = fxRenderClippedPoly;
+ }
+
+ fxMesa->render_index = index;
+
+ /* [dBorca] Hack alert: more a trick than a real plug-in!!! */
+ if (flags & (DD_POINT_SIZE | DD_POINT_ATTEN)) {
+ /* We need to set the point primitive to go through "rast_tab",
+ * to make sure "POINT" calls "fxMesa->draw_point" instead of
+ * "grDrawPoint". We can achieve this by using FX_FALLBACK_BIT
+ * (not really a total rasterization fallback, so we don't alter
+ * "fxMesa->render_index"). If we get here with DD_POINT_SMOOTH,
+ * we're done, cos we've already set _tnl_render_tab_{verts|elts}
+ * above. Otherwise, the T&L engine can optimize point rendering
+ * by using fx_render_tab_{verts|elts} hence the extra work.
+ */
+ if (flags & DD_POINT_SMOOTH) {
+ fxMesa->draw_point = fx_draw_point_wide_aa;
+ } else {
+ fxMesa->draw_point = fx_draw_point_wide;
+ fx_render_tab_verts[0] = fx_render_pw_verts;
+ fx_render_tab_elts[0] = fx_render_pw_elts;
+ }
+ tnl->Driver.Render.Points = rast_tab[index|FX_FALLBACK_BIT].points;
+ } else {
+ fx_render_tab_verts[0] = fx_render_vb_points;
+ fx_render_tab_elts[0] = fx_render_points_elts;
+ }
+}
+
+
+/**********************************************************************/
+/* Runtime render state and callbacks */
+/**********************************************************************/
+
+static void fxRunPipeline( GLcontext *ctx )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLuint new_gl_state = fxMesa->new_gl_state;
+
+ if (TDFX_DEBUG & VERBOSE_PIPELINE) {
+ fprintf(stderr, "fxRunPipeline()\n");
+ }
+
+#if 0
+ /* Recalculate fog table on projection matrix changes. This used to
+ * be triggered by the NearFar callback.
+ */
+ if (new_gl_state & _NEW_PROJECTION)
+ fxMesa->new_state |= FX_NEW_FOG;
+#endif
+
+ if (new_gl_state & _FX_NEW_IS_IN_HARDWARE)
+ fxCheckIsInHardware(ctx);
+
+ if (fxMesa->new_state)
+ fxSetupFXUnits(ctx);
+
+ if (!fxMesa->fallback) {
+ if (new_gl_state & _FX_NEW_RENDERSTATE)
+ fxDDChooseRenderState(ctx);
+
+ if (new_gl_state & _FX_NEW_SETUP_FUNCTION)
+ fxChooseVertexState(ctx);
+ }
+
+ if (new_gl_state & _NEW_TEXTURE) {
+ struct gl_texture_unit *t0 = &ctx->Texture.Unit[fxMesa->tmu_source[0]];
+ struct gl_texture_unit *t1 = &ctx->Texture.Unit[fxMesa->tmu_source[1]];
+
+ if (t0->_Current && FX_TEXTURE_DATA(t0)) {
+ fxMesa->s0scale = FX_TEXTURE_DATA(t0)->sScale;
+ fxMesa->t0scale = FX_TEXTURE_DATA(t0)->tScale;
+ fxMesa->inv_s0scale = 1.0F / fxMesa->s0scale;
+ fxMesa->inv_t0scale = 1.0F / fxMesa->t0scale;
+ }
+
+ if (t1->_Current && FX_TEXTURE_DATA(t1)) {
+ fxMesa->s1scale = FX_TEXTURE_DATA(t1)->sScale;
+ fxMesa->t1scale = FX_TEXTURE_DATA(t1)->tScale;
+ fxMesa->inv_s1scale = 1.0F / fxMesa->s1scale;
+ fxMesa->inv_t1scale = 1.0F / fxMesa->t1scale;
+ }
+ }
+
+ fxMesa->new_gl_state = 0;
+
+ _tnl_run_pipeline( ctx );
+}
+
+
+
+/* Always called between RenderStart and RenderFinish --> We already
+ * hold the lock.
+ */
+static void fxRasterPrimitive( GLcontext *ctx, GLenum prim )
+{
+ fxMesaContext fxMesa = FX_CONTEXT( ctx );
+
+ fxMesa->raster_primitive = prim;
+
+ fxSetupCull(ctx);
+}
+
+
+
+/* Determine the rasterized primitive when not drawing unfilled
+ * polygons.
+ */
+static void fxRenderPrimitive( GLcontext *ctx, GLenum prim )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLuint rprim = reduced_prim[prim];
+
+ fxMesa->render_primitive = prim;
+
+ if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ return;
+
+ if (fxMesa->raster_primitive != rprim) {
+ fxRasterPrimitive( ctx, rprim );
+ }
+}
+
+static void fxRenderFinish( GLcontext *ctx )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+
+ if (fxMesa->render_index & FX_FALLBACK_BIT)
+ _swrast_flush( ctx );
+}
+
+
+
+/**********************************************************************/
+/* Manage total rasterization fallbacks */
+/**********************************************************************/
+
+static char *fallbackStrings[] = {
+ "3D/Rect/Cube Texture map",
+ "glDrawBuffer(GL_FRONT_AND_BACK)",
+ "Separate specular color",
+ "glEnable/Disable(GL_STENCIL_TEST)",
+ "glRenderMode(selection or feedback)",
+ "glLogicOp()",
+ "Texture env mode",
+ "Texture border",
+ "glColorMask",
+ "blend mode",
+ "multitex"
+};
+
+
+static char *getFallbackString(GLuint bit)
+{
+ int i = 0;
+ while (bit > 1) {
+ i++;
+ bit >>= 1;
+ }
+ return fallbackStrings[i];
+}
+
+
+void fxCheckIsInHardware( GLcontext *ctx )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldfallback = fxMesa->fallback;
+ GLuint newfallback = fxMesa->fallback = fx_check_IsInHardware( ctx );
+
+ if (newfallback) {
+ if (oldfallback == 0) {
+ if (fxMesa->verbose) {
+ fprintf(stderr, "Voodoo ! enter SW 0x%08x %s\n", newfallback, getFallbackString(newfallback));
+ }
+ _swsetup_Wakeup( ctx );
+ }
+ }
+ else {
+ if (oldfallback) {
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = fxCheckTexSizes;
+ tnl->Driver.Render.Finish = fxRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = fxRenderPrimitive;
+ tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon;
+ tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine;
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = fxBuildVertices;
+ fxChooseVertexState(ctx);
+ fxDDChooseRenderState(ctx);
+ if (fxMesa->verbose) {
+ fprintf(stderr, "Voodoo ! leave SW 0x%08x %s\n", oldfallback, getFallbackString(oldfallback));
+ }
+ }
+ tnl->Driver.Render.Multipass = NULL;
+ if (HAVE_SPEC && NEED_SECONDARY_COLOR(ctx)) {
+ tnl->Driver.Render.Multipass = fxMultipass_ColorSum;
+ /* obey stencil, but do not change it */
+ fxMesa->multipass = GL_TRUE;
+ if (fxMesa->unitsState.stencilEnabled) {
+ fxMesa->new_state |= FX_NEW_STENCIL;
+ }
+ }
+ }
+}
+
+void fxDDInitTriFuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ static int firsttime = 1;
+
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+ }
+
+ tnl->Driver.RunPipeline = fxRunPipeline;
+ tnl->Driver.Render.Start = fxCheckTexSizes;
+ tnl->Driver.Render.Finish = fxRenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = fxRenderPrimitive;
+ tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon;
+ tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine;
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = fxBuildVertices;
+ tnl->Driver.Render.Multipass = NULL;
+
+ (void) fx_print_vertex;
+}
+
+
+/* [dBorca] Hack alert:
+ * doesn't work with blending.
+ */
+static GLboolean
+fxMultipass_ColorSum (GLcontext *ctx, GLuint pass)
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ tfxUnitsState *us = &fxMesa->unitsState;
+
+ static int t0 = 0;
+ static int t1 = 0;
+
+ switch (pass) {
+ case 1: /* first pass: the TEXTURED triangles are drawn */
+ /* set stencil's real values */
+ fxMesa->multipass = GL_FALSE;
+ if (us->stencilEnabled) {
+ fxSetupStencil(ctx);
+ }
+ /* save per-pass data */
+ fxMesa->restoreUnitsState = *us;
+ /* turn off texturing */
+ t0 = ctx->Texture.Unit[0]._ReallyEnabled;
+ t1 = ctx->Texture.Unit[1]._ReallyEnabled;
+ ctx->Texture.Unit[0]._ReallyEnabled = 0;
+ ctx->Texture.Unit[1]._ReallyEnabled = 0;
+ /* SUM the colors */
+ fxDDBlendEquationSeparate(ctx, GL_FUNC_ADD, GL_FUNC_ADD);
+ fxDDBlendFuncSeparate(ctx, GL_ONE, GL_ONE, GL_ZERO, GL_ONE);
+ fxDDEnable(ctx, GL_BLEND, GL_TRUE);
+ /* make sure we draw only where we want to */
+ if (us->depthTestEnabled) {
+ switch (us->depthTestFunc) {
+ default:
+ fxDDDepthFunc(ctx, GL_EQUAL);
+ case GL_NEVER:
+ case GL_ALWAYS:
+ ;
+ }
+ fxDDDepthMask(ctx, GL_FALSE);
+ }
+ /* switch to secondary colors */
+#if FX_PACKEDCOLOR
+ grVertexLayout(GR_PARAM_PARGB, GR_VERTEX_PSPEC_OFFSET << 2, GR_PARAM_ENABLE);
+#else /* !FX_PACKEDCOLOR */
+ grVertexLayout(GR_PARAM_RGB, GR_VERTEX_SPEC_OFFSET << 2, GR_PARAM_ENABLE);
+#endif /* !FX_PACKEDCOLOR */
+ /* don't advertise new state */
+ fxMesa->new_state = 0;
+ break;
+ case 2: /* 2nd pass (last): the secondary color is summed over texture */
+ /* restore original state */
+ *us = fxMesa->restoreUnitsState;
+ /* restore texturing */
+ ctx->Texture.Unit[0]._ReallyEnabled = t0;
+ ctx->Texture.Unit[1]._ReallyEnabled = t1;
+ /* revert to primary colors */
+#if FX_PACKEDCOLOR
+ grVertexLayout(GR_PARAM_PARGB, GR_VERTEX_PARGB_OFFSET << 2, GR_PARAM_ENABLE);
+#else /* !FX_PACKEDCOLOR */
+ grVertexLayout(GR_PARAM_RGB, GR_VERTEX_RGB_OFFSET << 2, GR_PARAM_ENABLE);
+#endif /* !FX_PACKEDCOLOR */
+ break;
+ default:
+ assert(0); /* NOTREACHED */
+ }
+
+ /* update HW state */
+ fxSetupBlend(ctx);
+ fxSetupDepthTest(ctx);
+ fxSetupTexture(ctx);
+
+ return (pass == 1);
+}
+
+
+#else
+
+
+/*
+ * Need this to provide at least one external definition.
+ */
+
+extern int gl_fx_dummy_function_tris(void);
+int
+gl_fx_dummy_function_tris(void)
+{
+ return 0;
+}
+
+#endif /* FX */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxvb.c b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxvb.c
new file mode 100644
index 000000000..34ada61f4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxvb.c
@@ -0,0 +1,838 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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 <keith@tungstengraphics.com>
+ * Daniel Borca <dborca@users.sourceforge.net>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "conf.h"
+#endif
+
+#ifdef FX
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "imports.h"
+#include "macros.h"
+#include "colormac.h"
+
+#include "math/m_translate.h"
+#include "swrast_setup/swrast_setup.h"
+
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+
+#include "fxdrv.h"
+
+
+static void copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc )
+{
+ fxMesaContext fxMesa = FX_CONTEXT( ctx );
+ GrVertex *dst = fxMesa->verts + edst;
+ GrVertex *src = fxMesa->verts + esrc;
+
+#if FX_PACKEDCOLOR
+ *(GLuint *)&dst->pargb = *(GLuint *)&src->pargb;
+#else /* !FX_PACKEDCOLOR */
+ COPY_FLOAT(dst->r, src->r);
+ COPY_FLOAT(dst->g, src->g);
+ COPY_FLOAT(dst->b, src->b);
+ COPY_FLOAT(dst->a, src->a);
+#endif /* !FX_PACKEDCOLOR */
+}
+
+static void copy_pv2( GLcontext *ctx, GLuint edst, GLuint esrc )
+{
+ fxMesaContext fxMesa = FX_CONTEXT( ctx );
+ GrVertex *dst = fxMesa->verts + edst;
+ GrVertex *src = fxMesa->verts + esrc;
+
+#if FX_PACKEDCOLOR
+ *(GLuint *)&dst->pargb = *(GLuint *)&src->pargb;
+ *(GLuint *)&dst->pspec = *(GLuint *)&src->pspec;
+#else /* !FX_PACKEDCOLOR */
+ COPY_FLOAT(dst->r, src->r);
+ COPY_FLOAT(dst->g, src->g);
+ COPY_FLOAT(dst->b, src->b);
+ COPY_FLOAT(dst->a, src->a);
+ COPY_FLOAT(dst->r1, src->r1);
+ COPY_FLOAT(dst->g1, src->g1);
+ COPY_FLOAT(dst->b1, src->b1);
+#endif /* !FX_PACKEDCOLOR */
+}
+
+static struct {
+ void (*emit) (GLcontext *ctx, GLuint start, GLuint end, void *dest);
+ tnl_copy_pv_func copy_pv;
+ tnl_interp_func interp;
+ GLboolean (*check_tex_sizes) (GLcontext *ctx);
+ GLuint vertex_format;
+} setup_tab[MAX_SETUP];
+
+
+#define GET_COLOR(ptr, idx) ((ptr)->data[idx])
+
+
+static void interp_extras( GLcontext *ctx,
+ GLfloat t,
+ GLuint dst, GLuint out, GLuint in,
+ GLboolean force_boundary )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ if (VB->ColorPtr[1]) {
+ /* If stride is zero, ColorPtr[1] is constant across the VB, so
+ * there is no point interpolating between two values as they will
+ * be identical. This case is handled in t_dd_tritmp.h
+ */
+ if (VB->ColorPtr[1]->stride) {
+ assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat));
+ INTERP_4F( t,
+ GET_COLOR(VB->ColorPtr[1], dst),
+ GET_COLOR(VB->ColorPtr[1], out),
+ GET_COLOR(VB->ColorPtr[1], in) );
+ }
+
+ if (VB->SecondaryColorPtr[1]) {
+ INTERP_3F( t,
+ GET_COLOR(VB->SecondaryColorPtr[1], dst),
+ GET_COLOR(VB->SecondaryColorPtr[1], out),
+ GET_COLOR(VB->SecondaryColorPtr[1], in) );
+ }
+ }
+
+ if (VB->EdgeFlag) {
+ VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
+ }
+
+ setup_tab[FX_CONTEXT(ctx)->SetupIndex].interp(ctx, t, dst, out, in,
+ force_boundary);
+}
+
+static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ if (VB->ColorPtr[1]) {
+ COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst),
+ GET_COLOR(VB->ColorPtr[1], src) );
+
+ if (VB->SecondaryColorPtr[1]) {
+ COPY_3FV( GET_COLOR(VB->SecondaryColorPtr[1], dst),
+ GET_COLOR(VB->SecondaryColorPtr[1], src) );
+ }
+ }
+
+ setup_tab[FX_CONTEXT(ctx)->SetupIndex].copy_pv(ctx, dst, src);
+}
+
+
+#define IND (SETUP_XYZW|SETUP_RGBA)
+#define TAG(x) x##_wg
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0)
+#define TAG(x) x##_wgt0
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
+#define TAG(x) x##_wgt0t1
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX)
+#define TAG(x) x##_wgpt0
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
+ SETUP_PTEX)
+#define TAG(x) x##_wgpt0t1
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_PSIZ)
+#define TAG(x) x##_wga
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ)
+#define TAG(x) x##_wgt0a
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ)
+#define TAG(x) x##_wgt0t1a
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ)
+#define TAG(x) x##_wgpt0a
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
+ SETUP_PTEX|SETUP_PSIZ)
+#define TAG(x) x##_wgpt0t1a
+#include "fxvbtmp.h"
+
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC)
+#define TAG(x) x##_2wg
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
+#define TAG(x) x##_2wgt0
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1)
+#define TAG(x) x##_2wgt0t1
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX)
+#define TAG(x) x##_2wgpt0
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
+ SETUP_PTEX)
+#define TAG(x) x##_2wgpt0t1
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ)
+#define TAG(x) x##_2wga
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ)
+#define TAG(x) x##_2wgt0a
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ)
+#define TAG(x) x##_2wgt0t1a
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ)
+#define TAG(x) x##_2wgpt0a
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
+ SETUP_PTEX|SETUP_PSIZ)
+#define TAG(x) x##_2wgpt0t1a
+#include "fxvbtmp.h"
+
+/* fog { */
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_FOGC)
+#define TAG(x) x##_wgf
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_FOGC)
+#define TAG(x) x##_wgt0f
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_FOGC)
+#define TAG(x) x##_wgt0t1f
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_FOGC)
+#define TAG(x) x##_wgpt0f
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
+ SETUP_PTEX|SETUP_FOGC)
+#define TAG(x) x##_wgpt0t1f
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_wgaf
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_wgt0af
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_wgt0t1af
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_wgpt0af
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
+ SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_wgpt0t1af
+#include "fxvbtmp.h"
+
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_FOGC)
+#define TAG(x) x##_2wgf
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_FOGC)
+#define TAG(x) x##_2wgt0f
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_FOGC)
+#define TAG(x) x##_2wgt0t1f
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_FOGC)
+#define TAG(x) x##_2wgpt0f
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
+ SETUP_PTEX|SETUP_FOGC)
+#define TAG(x) x##_2wgpt0t1f
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_2wgaf
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_2wgt0af
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_2wgt0t1af
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_2wgpt0af
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
+ SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_2wgpt0t1af
+#include "fxvbtmp.h"
+/* fog } */
+
+
+/* Snapping for voodoo-1
+ */
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA)
+#define TAG(x) x##_wsg
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0)
+#define TAG(x) x##_wsgt0
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
+ SETUP_TMU1)
+#define TAG(x) x##_wsgt0t1
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
+ SETUP_PTEX)
+#define TAG(x) x##_wsgpt0
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
+ SETUP_TMU1|SETUP_PTEX)
+#define TAG(x) x##_wsgpt0t1
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_PSIZ)
+#define TAG(x) x##_wsga
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ)
+#define TAG(x) x##_wsgt0a
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
+ SETUP_TMU1|SETUP_PSIZ)
+#define TAG(x) x##_wsgt0t1a
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
+ SETUP_PTEX|SETUP_PSIZ)
+#define TAG(x) x##_wsgpt0a
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
+ SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ)
+#define TAG(x) x##_wsgpt0t1a
+#include "fxvbtmp.h"
+
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC)
+#define TAG(x) x##_2wsg
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
+#define TAG(x) x##_2wsgt0
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
+ SETUP_TMU1)
+#define TAG(x) x##_2wsgt0t1
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
+ SETUP_PTEX)
+#define TAG(x) x##_2wsgpt0
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
+ SETUP_TMU1|SETUP_PTEX)
+#define TAG(x) x##_2wsgpt0t1
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ)
+#define TAG(x) x##_2wsga
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ)
+#define TAG(x) x##_2wsgt0a
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
+ SETUP_TMU1|SETUP_PSIZ)
+#define TAG(x) x##_2wsgt0t1a
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
+ SETUP_PTEX|SETUP_PSIZ)
+#define TAG(x) x##_2wsgpt0a
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
+ SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ)
+#define TAG(x) x##_2wsgpt0t1a
+#include "fxvbtmp.h"
+
+/* fog { */
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_FOGC)
+#define TAG(x) x##_wsgf
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_FOGC)
+#define TAG(x) x##_wsgt0f
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
+ SETUP_TMU1|SETUP_FOGC)
+#define TAG(x) x##_wsgt0t1f
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
+ SETUP_PTEX|SETUP_FOGC)
+#define TAG(x) x##_wsgpt0f
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
+ SETUP_TMU1|SETUP_PTEX|SETUP_FOGC)
+#define TAG(x) x##_wsgpt0t1f
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_wsgaf
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_wsgt0af
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
+ SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_wsgt0t1af
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
+ SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_wsgpt0af
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
+ SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_wsgpt0t1af
+#include "fxvbtmp.h"
+
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_FOGC)
+#define TAG(x) x##_2wsgf
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_FOGC)
+#define TAG(x) x##_2wsgt0f
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
+ SETUP_TMU1|SETUP_FOGC)
+#define TAG(x) x##_2wsgt0t1f
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
+ SETUP_PTEX|SETUP_FOGC)
+#define TAG(x) x##_2wsgpt0f
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
+ SETUP_TMU1|SETUP_PTEX|SETUP_FOGC)
+#define TAG(x) x##_2wsgpt0t1f
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_2wsgaf
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_2wsgt0af
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
+ SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_2wsgt0t1af
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
+ SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_2wsgpt0af
+#include "fxvbtmp.h"
+
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
+ SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
+#define TAG(x) x##_2wsgpt0t1af
+#include "fxvbtmp.h"
+/* fog } */
+
+
+/* Vertex repair (multipass rendering)
+ */
+#define IND (SETUP_RGBA)
+#define TAG(x) x##_g
+#include "fxvbtmp.h"
+
+#define IND (SETUP_TMU0)
+#define TAG(x) x##_t0
+#include "fxvbtmp.h"
+
+#define IND (SETUP_TMU0|SETUP_TMU1)
+#define TAG(x) x##_t0t1
+#include "fxvbtmp.h"
+
+#define IND (SETUP_RGBA|SETUP_TMU0)
+#define TAG(x) x##_gt0
+#include "fxvbtmp.h"
+
+#define IND (SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
+#define TAG(x) x##_gt0t1
+#include "fxvbtmp.h"
+
+
+#define IND (SETUP_RGBA|SETUP_SPEC)
+#define TAG(x) x##_2g
+#include "fxvbtmp.h"
+
+#define IND (SETUP_TMU0|SETUP_SPEC)
+#define TAG(x) x##_2t0
+#include "fxvbtmp.h"
+
+#define IND (SETUP_TMU0|SETUP_SPEC|SETUP_TMU1)
+#define TAG(x) x##_2t0t1
+#include "fxvbtmp.h"
+
+#define IND (SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
+#define TAG(x) x##_2gt0
+#include "fxvbtmp.h"
+
+#define IND (SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1)
+#define TAG(x) x##_2gt0t1
+#include "fxvbtmp.h"
+
+
+
+static void init_setup_tab( void )
+{
+ init_wg();
+ init_wgt0();
+ init_wgt0t1();
+ init_wgpt0();
+ init_wgpt0t1();
+ init_wga();
+ init_wgt0a();
+ init_wgt0t1a();
+ init_wgpt0a();
+ init_wgpt0t1a();
+ init_2wg();
+ init_2wgt0();
+ init_2wgt0t1();
+ init_2wgpt0();
+ init_2wgpt0t1();
+ init_2wga();
+ init_2wgt0a();
+ init_2wgt0t1a();
+ init_2wgpt0a();
+ init_2wgpt0t1a();
+ init_wgf();
+ init_wgt0f();
+ init_wgt0t1f();
+ init_wgpt0f();
+ init_wgpt0t1f();
+ init_wgaf();
+ init_wgt0af();
+ init_wgt0t1af();
+ init_wgpt0af();
+ init_wgpt0t1af();
+ init_2wgf();
+ init_2wgt0f();
+ init_2wgt0t1f();
+ init_2wgpt0f();
+ init_2wgpt0t1f();
+ init_2wgaf();
+ init_2wgt0af();
+ init_2wgt0t1af();
+ init_2wgpt0af();
+ init_2wgpt0t1af();
+
+ init_wsg();
+ init_wsgt0();
+ init_wsgt0t1();
+ init_wsgpt0();
+ init_wsgpt0t1();
+ init_wsga();
+ init_wsgt0a();
+ init_wsgt0t1a();
+ init_wsgpt0a();
+ init_wsgpt0t1a();
+ init_2wsg();
+ init_2wsgt0();
+ init_2wsgt0t1();
+ init_2wsgpt0();
+ init_2wsgpt0t1();
+ init_2wsga();
+ init_2wsgt0a();
+ init_2wsgt0t1a();
+ init_2wsgpt0a();
+ init_2wsgpt0t1a();
+ init_wsgf();
+ init_wsgt0f();
+ init_wsgt0t1f();
+ init_wsgpt0f();
+ init_wsgpt0t1f();
+ init_wsgaf();
+ init_wsgt0af();
+ init_wsgt0t1af();
+ init_wsgpt0af();
+ init_wsgpt0t1af();
+ init_2wsgf();
+ init_2wsgt0f();
+ init_2wsgt0t1f();
+ init_2wsgpt0f();
+ init_2wsgpt0t1f();
+ init_2wsgaf();
+ init_2wsgt0af();
+ init_2wsgt0t1af();
+ init_2wsgpt0af();
+ init_2wsgpt0t1af();
+
+ init_g();
+ init_t0();
+ init_t0t1();
+ init_gt0();
+ init_gt0t1();
+ init_2g();
+ init_2t0();
+ init_2t0t1();
+ init_2gt0();
+ init_2gt0t1();
+}
+
+
+void fxPrintSetupFlags(char *msg, GLuint flags )
+{
+ fprintf(stderr, "%s(%x): %s%s%s%s%s%s%s%s\n",
+ msg,
+ (int)flags,
+ (flags & SETUP_XYZW) ? " xyzw," : "",
+ (flags & SETUP_SNAP) ? " snap," : "",
+ (flags & SETUP_RGBA) ? " rgba," : "",
+ (flags & SETUP_TMU0) ? " tex-0," : "",
+ (flags & SETUP_TMU1) ? " tex-1," : "",
+ (flags & SETUP_PSIZ) ? " psiz," : "",
+ (flags & SETUP_SPEC) ? " spec," : "",
+ (flags & SETUP_FOGC) ? " fog," : "");
+}
+
+
+
+void fxCheckTexSizes( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ fxMesaContext fxMesa = FX_CONTEXT( ctx );
+
+ if (!setup_tab[fxMesa->SetupIndex].check_tex_sizes(ctx)) {
+ GLuint ind = fxMesa->SetupIndex |= (SETUP_PTEX|SETUP_RGBA);
+
+ /* Tdfx handles projective textures nicely; just have to change
+ * up to the new vertex format.
+ */
+ if (setup_tab[ind].vertex_format != fxMesa->stw_hint_state) {
+
+ fxMesa->stw_hint_state = setup_tab[ind].vertex_format;
+ FX_grHints(GR_HINT_STWHINT, fxMesa->stw_hint_state);
+
+ /* This is required as we have just changed the vertex
+ * format, so the interp routines must also change.
+ * In the unfilled and twosided cases we are using the
+ * Extras ones anyway, so leave them in place.
+ */
+ if (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ tnl->Driver.Render.Interp = setup_tab[fxMesa->SetupIndex].interp;
+ }
+ }
+ }
+}
+
+
+void fxBuildVertices( GLcontext *ctx, GLuint start, GLuint end,
+ GLuint newinputs )
+{
+ fxMesaContext fxMesa = FX_CONTEXT( ctx );
+ GrVertex *v = (fxMesa->verts + start);
+
+ if (!newinputs)
+ return;
+
+ if (newinputs & VERT_BIT_POS) {
+ setup_tab[fxMesa->SetupIndex].emit( ctx, start, end, v );
+ } else {
+ GLuint ind = 0;
+
+ if (newinputs & VERT_BIT_COLOR0)
+ ind |= SETUP_RGBA;
+
+ if (newinputs & VERT_BIT_COLOR1)
+ ind |= SETUP_SPEC;
+
+ if (newinputs & VERT_BIT_FOG)
+ ind |= SETUP_FOGC;
+
+ if (newinputs & VERT_BIT_TEX0)
+ ind |= SETUP_TMU0;
+
+ if (newinputs & VERT_BIT_TEX1)
+ ind |= SETUP_TMU0|SETUP_TMU1;
+
+ if (fxMesa->SetupIndex & SETUP_PTEX)
+ ind = ~0;
+
+ ind &= fxMesa->SetupIndex;
+
+ if (ind) {
+ setup_tab[ind].emit( ctx, start, end, v );
+ }
+ }
+}
+
+
+void fxChooseVertexState( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ fxMesaContext fxMesa = FX_CONTEXT( ctx );
+ GLuint ind = SETUP_XYZW|SETUP_RGBA;
+
+ if (fxMesa->snapVertices)
+ ind |= SETUP_SNAP;
+
+ fxMesa->tmu_source[0] = 0;
+ fxMesa->tmu_source[1] = 1;
+
+ if (ctx->Texture._EnabledUnits & 0x2) {
+ if (ctx->Texture._EnabledUnits & 0x1) {
+ ind |= SETUP_TMU1;
+ }
+ ind |= SETUP_TMU0;
+ fxMesa->tmu_source[0] = 1;
+ fxMesa->tmu_source[1] = 0;
+ }
+ else if (ctx->Texture._EnabledUnits & 0x1) {
+ ind |= SETUP_TMU0;
+ }
+
+ if (ctx->_TriangleCaps & DD_POINT_ATTEN) {
+ ind |= SETUP_PSIZ;
+ }
+
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
+ ind |= SETUP_SPEC;
+ }
+
+ if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) {
+ ind |= SETUP_FOGC;
+ }
+
+ fxMesa->SetupIndex = ind;
+
+ if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
+ tnl->Driver.Render.Interp = interp_extras;
+ tnl->Driver.Render.CopyPV = copy_pv_extras;
+ } else {
+ tnl->Driver.Render.Interp = setup_tab[ind].interp;
+ tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
+ }
+
+ if (setup_tab[ind].vertex_format != fxMesa->stw_hint_state) {
+ fxMesa->stw_hint_state = setup_tab[ind].vertex_format;
+ FX_grHints(GR_HINT_STWHINT, fxMesa->stw_hint_state);
+ }
+}
+
+
+
+void fxAllocVB( GLcontext *ctx )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLuint size = TNL_CONTEXT(ctx)->vb.Size;
+ static int firsttime = 1;
+ if (firsttime) {
+ init_setup_tab();
+ firsttime = 0;
+ }
+
+ fxMesa->verts = (GrVertex *)ALIGN_MALLOC(size * sizeof(GrVertex), 32);
+ fxMesa->SetupIndex = SETUP_XYZW|SETUP_RGBA;
+}
+
+
+void fxFreeVB( GLcontext *ctx )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ if (fxMesa->verts) {
+ ALIGN_FREE(fxMesa->verts);
+ fxMesa->verts = 0;
+ }
+}
+#else
+
+
+/*
+ * Need this to provide at least one external definition.
+ */
+
+extern int gl_fx_dummy_function_vb(void);
+int
+gl_fx_dummy_function_vb(void)
+{
+ return 0;
+}
+
+#endif /* FX */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxvbtmp.h b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxvbtmp.h
new file mode 100644
index 000000000..f7970c78e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/glide/fxvbtmp.h
@@ -0,0 +1,369 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 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.
+ */
+
+/* Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Daniel Borca <dborca@users.sourceforge.net>
+ */
+
+
+#define VIEWPORT_X(dst,x) dst = s[0] * x + s[12]
+#define VIEWPORT_Y(dst,y) dst = s[5] * y + s[13]
+#define VIEWPORT_Z(dst,z) dst = s[10] * z + s[14]
+
+static void TAG(emit)( GLcontext *ctx,
+ GLuint start, GLuint end,
+ void *dest )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLuint tmu0_source = fxMesa->tmu_source[0];
+ GLuint tmu1_source = fxMesa->tmu_source[1];
+ GLfloat (*tc0)[4], (*tc1)[4];
+ GLfloat (*col)[4], (*spec)[4];
+ GLuint tc0_stride, tc1_stride, col_stride, spec_stride;
+ GLuint tc0_size, tc1_size, col_size;
+ GLfloat (*proj)[4] = VB->NdcPtr->data;
+ GLuint proj_stride = VB->NdcPtr->stride;
+ GLfloat (*psize)[4];
+ GLuint psize_stride;
+ GLfloat (*fog)[4];
+ GLuint fog_stride;
+ GrVertex *v = (GrVertex *)dest;
+ GLfloat u0scale,v0scale,u1scale,v1scale;
+ const GLubyte *mask = VB->ClipMask;
+ const GLfloat *const s = ctx->Viewport._WindowMap.m;
+ int i;
+
+ if (IND & SETUP_PSIZ) {
+ psize = VB->PointSizePtr->data;
+ psize_stride = VB->PointSizePtr->stride;
+ }
+
+ if (IND & SETUP_TMU0) {
+ tc0 = VB->TexCoordPtr[tmu0_source]->data;
+ tc0_stride = VB->TexCoordPtr[tmu0_source]->stride;
+ u0scale = fxMesa->s0scale;
+ v0scale = fxMesa->t0scale;
+ if (IND & SETUP_PTEX)
+ tc0_size = VB->TexCoordPtr[tmu0_source]->size;
+ }
+
+ if (IND & SETUP_TMU1) {
+ tc1 = VB->TexCoordPtr[tmu1_source]->data;
+ tc1_stride = VB->TexCoordPtr[tmu1_source]->stride;
+ u1scale = fxMesa->s1scale; /* wrong if tmu1_source == 0, possible? */
+ v1scale = fxMesa->t1scale;
+ if (IND & SETUP_PTEX)
+ tc1_size = VB->TexCoordPtr[tmu1_source]->size;
+ }
+
+ if (IND & SETUP_RGBA) {
+ col = VB->ColorPtr[0]->data;
+ col_stride = VB->ColorPtr[0]->stride;
+ col_size = VB->ColorPtr[0]->size;
+ }
+
+ if (IND & SETUP_SPEC) {
+ spec = VB->SecondaryColorPtr[0]->data;
+ spec_stride = VB->SecondaryColorPtr[0]->stride;
+ }
+
+ if (IND & SETUP_FOGC) {
+ fog = VB->FogCoordPtr->data;
+ fog_stride = VB->FogCoordPtr->stride;
+ }
+
+ if (start) {
+ proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_stride);
+ if (IND & SETUP_PSIZ)
+ psize = (GLfloat (*)[4])((GLubyte *)psize + start * psize_stride);
+ if (IND & SETUP_TMU0)
+ tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + start * tc0_stride);
+ if (IND & SETUP_TMU1)
+ tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride);
+ if (IND & SETUP_RGBA)
+ STRIDE_4F(col, start * col_stride);
+ if (IND & SETUP_SPEC)
+ STRIDE_4F(spec, start * spec_stride);
+ if (IND & SETUP_FOGC)
+ fog = (GLfloat (*)[4])((GLubyte *)fog + start * fog_stride);
+ }
+
+ for (i=start; i < end; i++, v++) {
+ if (IND & SETUP_PSIZ) {
+ v->psize = psize[0][0];
+ psize = (GLfloat (*)[4])((GLubyte *)psize + psize_stride);
+ }
+
+ if (IND & SETUP_XYZW) {
+ if (mask[i] == 0) {
+ /* unclipped */
+ VIEWPORT_X(v->x, proj[0][0]);
+ VIEWPORT_Y(v->y, proj[0][1]);
+ VIEWPORT_Z(v->ooz, proj[0][2]);
+ v->oow = proj[0][3];
+
+ if (IND & SETUP_SNAP) {
+#if defined(USE_IEEE)
+ const float snapper = (3L << 18);
+ v->x += snapper;
+ v->x -= snapper;
+ v->y += snapper;
+ v->y -= snapper;
+#else
+ v->x = ((int) (v->x * 16.0f)) * (1.0f / 16.0f);
+ v->y = ((int) (v->y * 16.0f)) * (1.0f / 16.0f);
+#endif
+ }
+ } else {
+ /* clipped */
+ v->oow = 1.0;
+ }
+
+ proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride);
+ }
+ if (IND & SETUP_RGBA) {
+#if FX_PACKEDCOLOR
+ UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[2], col[0][0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[1], col[0][1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[0], col[0][2]);
+ if (col_size == 4) {
+ UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[3], col[0][3]);
+ } else {
+ v->pargb[3] = 255;
+ }
+#else /* !FX_PACKEDCOLOR */
+ CNORM(v->r, col[0][0]);
+ CNORM(v->g, col[0][1]);
+ CNORM(v->b, col[0][2]);
+ if (col_size == 4) {
+ CNORM(v->a, col[0][3]);
+ } else {
+ v->a = 255.0f;
+ }
+#endif /* !FX_PACKEDCOLOR */
+ STRIDE_4F(col, col_stride);
+ }
+ if (IND & SETUP_SPEC) {
+#if FX_PACKEDCOLOR
+ UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[2], spec[0][0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[1], spec[0][1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[0], spec[0][2]);
+#else /* !FX_PACKEDCOLOR */
+ CNORM(v->r1, spec[0][0]);
+ CNORM(v->g1, spec[0][1]);
+ CNORM(v->b1, spec[0][2]);
+#endif /* !FX_PACKEDCOLOR */
+ STRIDE_4F(spec, spec_stride);
+ }
+ if (IND & SETUP_FOGC) {
+ v->fog = CLAMP(fog[0][0], 0.0f, 1.0f);
+ fog = (GLfloat (*)[4])((GLubyte *)fog + fog_stride);
+ }
+ if (IND & SETUP_TMU0) {
+ GLfloat w = v->oow;
+ v->tmuvtx[0].sow = tc0[0][0] * u0scale * w;
+ v->tmuvtx[0].tow = tc0[0][1] * v0scale * w;
+ if (IND & SETUP_PTEX) {
+ v->tmuvtx[0].oow = w;
+ if (tc0_size == 4)
+ v->tmuvtx[0].oow *= tc0[0][3];
+ }
+ tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride);
+ }
+ if (IND & SETUP_TMU1) {
+ GLfloat w = v->oow;
+ v->tmuvtx[1].sow = tc1[0][0] * u1scale * w;
+ v->tmuvtx[1].tow = tc1[0][1] * v1scale * w;
+ if (IND & SETUP_PTEX) {
+ v->tmuvtx[1].oow = w;
+ if (tc1_size == 4)
+ v->tmuvtx[1].oow *= tc1[0][3];
+ }
+ tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + tc1_stride);
+ }
+ }
+}
+
+#if (IND & SETUP_XYZW) && (IND & SETUP_RGBA)
+
+static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
+{
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ if (IND & SETUP_PTEX)
+ return GL_TRUE;
+
+ if (IND & SETUP_TMU0) {
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ if (IND & SETUP_TMU1) {
+ if (VB->TexCoordPtr[0] == 0)
+ VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
+
+ if (VB->TexCoordPtr[1]->size == 4)
+ return GL_FALSE;
+ }
+
+ if (VB->TexCoordPtr[0] && VB->TexCoordPtr[0]->size == 4)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+static void TAG(interp)( GLcontext *ctx,
+ GLfloat t,
+ GLuint edst, GLuint eout, GLuint ein,
+ GLboolean force_boundary )
+{
+ fxMesaContext fxMesa = FX_CONTEXT( ctx );
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ const GLfloat *dstclip = VB->ClipPtr->data[edst];
+ const GLfloat oow = (dstclip[3] == 0.0F) ? 1.0F : (1.0F / dstclip[3]);
+ const GLfloat *const s = ctx->Viewport._WindowMap.m;
+ GrVertex *fxverts = fxMesa->verts;
+ GrVertex *dst = (GrVertex *) (fxverts + edst);
+ const GrVertex *out = (const GrVertex *) (fxverts + eout);
+ const GrVertex *in = (const GrVertex *) (fxverts + ein);
+ const GLfloat wout = oow / out->oow;
+ const GLfloat win = oow / in->oow;
+
+ VIEWPORT_X(dst->x, dstclip[0] * oow);
+ VIEWPORT_Y(dst->y, dstclip[1] * oow);
+ VIEWPORT_Z(dst->ooz, dstclip[2] * oow);
+ dst->oow = oow;
+
+ if (IND & SETUP_SNAP) {
+#if defined(USE_IEEE)
+ const float snapper = (3L << 18);
+ dst->x += snapper;
+ dst->x -= snapper;
+ dst->y += snapper;
+ dst->y -= snapper;
+#else
+ dst->x = ((int) (dst->x * 16.0f)) * (1.0f / 16.0f);
+ dst->y = ((int) (dst->y * 16.0f)) * (1.0f / 16.0f);
+#endif
+ }
+
+
+#if FX_PACKEDCOLOR
+ INTERP_UB( t, dst->pargb[0], out->pargb[0], in->pargb[0] );
+ INTERP_UB( t, dst->pargb[1], out->pargb[1], in->pargb[1] );
+ INTERP_UB( t, dst->pargb[2], out->pargb[2], in->pargb[2] );
+ INTERP_UB( t, dst->pargb[3], out->pargb[3], in->pargb[3] );
+#else /* !FX_PACKEDCOLOR */
+ INTERP_F( t, dst->r, out->r, in->r );
+ INTERP_F( t, dst->g, out->g, in->g );
+ INTERP_F( t, dst->b, out->b, in->b );
+ INTERP_F( t, dst->a, out->a, in->a );
+#endif /* !FX_PACKEDCOLOR */
+
+ if (IND & SETUP_SPEC) {
+#if FX_PACKEDCOLOR
+ INTERP_UB( t, dst->pspec[0], out->pspec[0], in->pspec[0] );
+ INTERP_UB( t, dst->pspec[1], out->pspec[1], in->pspec[1] );
+ INTERP_UB( t, dst->pspec[2], out->pspec[2], in->pspec[2] );
+#else /* !FX_PACKEDCOLOR */
+ INTERP_F( t, dst->r1, out->r1, in->r1 );
+ INTERP_F( t, dst->g1, out->g1, in->g1 );
+ INTERP_F( t, dst->b1, out->b1, in->b1 );
+#endif /* !FX_PACKEDCOLOR */
+ }
+
+ if (IND & SETUP_FOGC) {
+ INTERP_F( t, dst->fog, out->fog, in->fog );
+ }
+
+ if (IND & SETUP_TMU0) {
+ INTERP_F( t,
+ dst->tmuvtx[0].sow,
+ out->tmuvtx[0].sow * wout,
+ in->tmuvtx[0].sow * win );
+ INTERP_F( t,
+ dst->tmuvtx[0].tow,
+ out->tmuvtx[0].tow * wout,
+ in->tmuvtx[0].tow * win );
+ if (IND & SETUP_PTEX) {
+ INTERP_F( t,
+ dst->tmuvtx[0].oow,
+ out->tmuvtx[0].oow * wout,
+ in->tmuvtx[0].oow * win );
+ }
+ }
+
+ if (IND & SETUP_TMU1) {
+ INTERP_F( t,
+ dst->tmuvtx[1].sow,
+ out->tmuvtx[1].sow * wout,
+ in->tmuvtx[1].sow * win );
+ INTERP_F( t,
+ dst->tmuvtx[1].tow,
+ out->tmuvtx[1].tow * wout,
+ in->tmuvtx[1].tow * win );
+ if (IND & SETUP_PTEX) {
+ INTERP_F( t,
+ dst->tmuvtx[1].oow,
+ out->tmuvtx[1].oow * wout,
+ in->tmuvtx[1].oow * win );
+ }
+ }
+}
+#endif
+
+
+static void TAG(init)( void )
+{
+ setup_tab[IND].emit = TAG(emit);
+
+ if (IND & SETUP_SPEC) {
+ setup_tab[IND].copy_pv = copy_pv2;
+ } else {
+ setup_tab[IND].copy_pv = copy_pv;
+ }
+
+#if ((IND & SETUP_XYZW) && (IND & SETUP_RGBA))
+ setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes);
+ setup_tab[IND].interp = TAG(interp);
+
+ setup_tab[IND].vertex_format = 0;
+ if (IND & SETUP_PTEX) {
+ setup_tab[IND].vertex_format |= GR_STWHINT_W_DIFF_TMU0;
+ }
+
+#if (IND & SETUP_TMU1)
+ setup_tab[IND].vertex_format |= GR_STWHINT_ST_DIFF_TMU1;
+ if (IND & SETUP_PTEX) {
+ setup_tab[IND].vertex_format |= GR_STWHINT_W_DIFF_TMU1;
+ }
+#endif
+
+#endif
+}
+
+
+#undef IND
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/osmesa/Makefile.win b/nx-X11/extras/Mesa/src/mesa/drivers/osmesa/Makefile.win
new file mode 100644
index 000000000..36d520e65
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/osmesa/Makefile.win
@@ -0,0 +1,39 @@
+# Makefile for Win32
+
+!include <win32.mak>
+
+TOP = ..\..
+
+OSMESA_SRCS = osmesa.c
+OSMESA_OBJS = osmesa.obj
+
+ASM_SRCS =
+CORE_SRCS =
+DRIVER_SRCS = $(OSMESA_SRCS)
+
+SRCS = $(OSMESA_SRCS)
+
+all : osmesadll
+
+!include "$(TOP)/mesawin32.mak"
+
+osmesadll: $(OSMESADLL)
+
+CFLAGS = $(cvarsdll) $(CFLAGS) -D_OPENGL32_ -DBUILD_GL32 -I$(TOP)/src
+LFLAGS = $(dlllflags) $(lcommon) $(LFLAGS)
+
+OBJS = $(ASM_SRCS:.S=.obj) $(CORE_SRCS:.c=.obj) $(DRIVER_SRCS:.c=.obj)
+LIBS = $(guilibsdll) $(TOP)/lib/$(MESALIB)
+
+$(OSMESADLL) : $(OBJS) osmesa.def
+ $(link) $(LFLAGS) -def:osmesa.def -out:$(OSMESADLL) $(OBJS) $(LIBS)
+ @echo "copying OSMesa library to library directory..."
+ -copy $(OSMESALIB) $(TOP)\lib
+ @echo "copying OSMesa dll to library directory..."
+ -copy $(OSMESADLL) $(TOP)\lib
+
+install : $(OSMESADLL)
+ @echo "copying OSMesa library to system library directory..."
+ -copy $(OSMESALIB) $(LIBINSTALL)
+ @echo "copying OSMesa dll to system library directory..."
+ -copy $(OSMESADLL) $(DLLINSTALL)
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/osmesa/descrip.mms b/nx-X11/extras/Mesa/src/mesa/drivers/osmesa/descrip.mms
new file mode 100644
index 000000000..64dc041f9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/osmesa/descrip.mms
@@ -0,0 +1,41 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+# Last revision : 16 June 2003
+
+.first
+ define gl [----.include.gl]
+ define math [--.math]
+ define tnl [--.tnl]
+ define swrast [--.swrast]
+ define swrast_setup [--.swrast_setup]
+ define array_cache [--.array_cache]
+ define drivers [-]
+
+.include [----]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [----.include],[--.main],[--.glapi]
+LIBDIR = [----.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)
+
+SOURCES = osmesa.c
+
+OBJECTS = osmesa.obj
+
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+ @ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
+
+clean :
+ purge
+ delete *.obj;*
+
+osmesa.obj : osmesa.c
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/osmesa/osmesa.c b/nx-X11/extras/Mesa/src/mesa/drivers/osmesa/osmesa.c
new file mode 100644
index 000000000..8a85b5ecf
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/osmesa/osmesa.c
@@ -0,0 +1,1333 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/*
+ * 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 _mesa_make_current() and _mesa_get_current_context()
+ * functions. Those functions are thread-safe.
+ */
+
+
+#include "glheader.h"
+#include "GL/osmesa.h"
+#include "context.h"
+#include "extensions.h"
+#include "framebuffer.h"
+#include "fbobject.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "renderbuffer.h"
+#include "array_cache/acache.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "swrast/s_context.h"
+#include "swrast/s_depth.h"
+#include "swrast/s_lines.h"
+#include "swrast/s_triangle.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
+
+
+/*
+ * 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 mesa; /* 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 */
+ 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, aInd;/* index offsets for RGBA formats */
+ GLchan *rowaddr[MAX_HEIGHT]; /* address of first pixel in each image row */
+ GLboolean yup; /* TRUE -> Y increases upward */
+ /* FALSE -> Y increases downward */
+};
+
+
+/* Just cast, since we're using structure containment */
+#define OSMESA_CONTEXT(ctx) ((OSMesaContext) (ctx->DriverCtx))
+
+
+
+/**********************************************************************/
+/*** Private Device Driver Functions ***/
+/**********************************************************************/
+
+
+static const GLubyte *
+get_string( GLcontext *ctx, GLenum name )
+{
+ (void) ctx;
+ switch (name) {
+ case GL_RENDERER:
+#if CHAN_BITS == 32
+ return (const GLubyte *) "Mesa OffScreen32";
+#elif CHAN_BITS == 16
+ return (const GLubyte *) "Mesa OffScreen16";
+#else
+ return (const GLubyte *) "Mesa OffScreen";
+#endif
+ default:
+ return NULL;
+ }
+}
+
+
+static void
+osmesa_update_state( GLcontext *ctx, GLuint new_state )
+{
+ /* easy - just propogate */
+ _swrast_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+}
+
+
+static void
+set_buffer( GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit )
+{
+ /* separate read buffer not supported */
+ ASSERT(buffer == ctx->DrawBuffer);
+ ASSERT(bufferBit == BUFFER_BIT_FRONT_LEFT);
+}
+
+
+/*
+ * Just return the current buffer size.
+ * There's no window to track the size of.
+ */
+static void
+get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
+{
+ /* don't use GET_CURRENT_CONTEXT(ctx) here - it's a problem on Windows */
+ GLcontext *ctx = (GLcontext *) _glapi_get_context();
+ (void) buffer;
+ if (ctx) {
+ OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
+ *width = osmesa->width;
+ *height = osmesa->height;
+ }
+}
+
+
+/**********************************************************************/
+/***** Read/write spans/arrays of pixels *****/
+/**********************************************************************/
+
+/* RGBA */
+#define NAME(PREFIX) PREFIX##_RGBA
+#define FORMAT GL_RGBA
+#define SPAN_VARS \
+ const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLchan *P = osmesa->rowaddr[Y] + 4 * (X)
+#define INC_PIXEL_PTR(P) P += 4
+#if CHAN_TYPE == GL_FLOAT
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = MAX2((VALUE[RCOMP]), 0.0F); \
+ DST[1] = MAX2((VALUE[GCOMP]), 0.0F); \
+ DST[2] = MAX2((VALUE[BCOMP]), 0.0F); \
+ DST[3] = CLAMP((VALUE[ACOMP]), 0.0F, CHAN_MAXF)
+#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
+ DST[0] = MAX2((VALUE[RCOMP]), 0.0F); \
+ DST[1] = MAX2((VALUE[GCOMP]), 0.0F); \
+ DST[2] = MAX2((VALUE[BCOMP]), 0.0F); \
+ DST[3] = CHAN_MAXF
+#else
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = VALUE[RCOMP]; \
+ DST[1] = VALUE[GCOMP]; \
+ DST[2] = VALUE[BCOMP]; \
+ DST[3] = VALUE[ACOMP]
+#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
+ DST[0] = VALUE[RCOMP]; \
+ DST[1] = VALUE[GCOMP]; \
+ DST[2] = VALUE[BCOMP]; \
+ DST[3] = CHAN_MAX
+#endif
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = SRC[0]; \
+ DST[GCOMP] = SRC[1]; \
+ DST[BCOMP] = SRC[2]; \
+ DST[ACOMP] = SRC[3]
+#include "swrast/s_spantemp.h"
+
+/* BGRA */
+#define NAME(PREFIX) PREFIX##_BGRA
+#define FORMAT GL_RGBA
+#define SPAN_VARS \
+ const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLchan *P = osmesa->rowaddr[Y] + 4 * (X)
+#define INC_PIXEL_PTR(P) P += 4
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[2] = VALUE[RCOMP]; \
+ DST[1] = VALUE[GCOMP]; \
+ DST[0] = VALUE[BCOMP]; \
+ DST[3] = VALUE[ACOMP]
+#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
+ DST[2] = VALUE[RCOMP]; \
+ DST[1] = VALUE[GCOMP]; \
+ DST[0] = VALUE[BCOMP]; \
+ DST[3] = CHAN_MAX
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = SRC[2]; \
+ DST[GCOMP] = SRC[1]; \
+ DST[BCOMP] = SRC[0]; \
+ DST[ACOMP] = SRC[3]
+#include "swrast/s_spantemp.h"
+
+/* ARGB */
+#define NAME(PREFIX) PREFIX##_ARGB
+#define FORMAT GL_RGBA
+#define SPAN_VARS \
+ const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLchan *P = osmesa->rowaddr[Y] + 4 * (X)
+#define INC_PIXEL_PTR(P) P += 4
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[1] = VALUE[RCOMP]; \
+ DST[2] = VALUE[GCOMP]; \
+ DST[3] = VALUE[BCOMP]; \
+ DST[0] = VALUE[ACOMP]
+#define STORE_PIXEL_RGB(DST, X, Y, VALUE) \
+ DST[1] = VALUE[RCOMP]; \
+ DST[2] = VALUE[GCOMP]; \
+ DST[3] = VALUE[BCOMP]; \
+ DST[0] = CHAN_MAX
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = SRC[1]; \
+ DST[GCOMP] = SRC[2]; \
+ DST[BCOMP] = SRC[3]; \
+ DST[ACOMP] = SRC[0]
+#include "swrast/s_spantemp.h"
+
+/* RGB */
+#define NAME(PREFIX) PREFIX##_RGB
+#define FORMAT GL_RGBA
+#define SPAN_VARS \
+ const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLchan *P = osmesa->rowaddr[Y] + 4 * (X)
+#define INC_PIXEL_PTR(P) P += 3
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[0] = VALUE[RCOMP]; \
+ DST[1] = VALUE[GCOMP]; \
+ DST[2] = VALUE[BCOMP]
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = SRC[0]; \
+ DST[GCOMP] = SRC[1]; \
+ DST[BCOMP] = SRC[2]; \
+ DST[ACOMP] = CHAN_MAX
+#include "swrast/s_spantemp.h"
+
+/* BGR */
+#define NAME(PREFIX) PREFIX##_BGR
+#define FORMAT GL_RGBA
+#define SPAN_VARS \
+ const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLchan *P = osmesa->rowaddr[Y] + 4 * (X)
+#define INC_PIXEL_PTR(P) P += 3
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ DST[2] = VALUE[RCOMP]; \
+ DST[1] = VALUE[GCOMP]; \
+ DST[0] = VALUE[BCOMP]
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = SRC[2]; \
+ DST[GCOMP] = SRC[1]; \
+ DST[BCOMP] = SRC[0]; \
+ DST[ACOMP] = CHAN_MAX
+#include "swrast/s_spantemp.h"
+
+/* 16-bit BGR */
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+#define NAME(PREFIX) PREFIX##_RGB_565
+#define FORMAT GL_RGBA
+#define SPAN_VARS \
+ const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLushort *P = (GLushort *) osmesa->rowaddr[Y] + (X)
+#define INC_PIXEL_PTR(P) P += 1
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ *DST = ( (((VALUE[RCOMP]) & 0xf8) << 8) | (((VALUE[GCOMP]) & 0xfc) << 3) | ((VALUE[BCOMP]) >> 3) )
+#define FETCH_PIXEL(DST, SRC) \
+ DST[RCOMP] = ( (((*SRC) >> 8) & 0xf8) | (((*SRC) >> 11) & 0x7) ); \
+ DST[GCOMP] = ( (((*SRC) >> 3) & 0xfc) | (((*SRC) >> 5) & 0x3) ); \
+ DST[BCOMP] = ( (((*SRC) << 3) & 0xf8) | (((*SRC) ) & 0x7) ); \
+ DST[ACOMP] = CHAN_MAX
+#include "swrast/s_spantemp.h"
+#endif /* CHAN_TYPE == GL_UNSIGNED_BYTE */
+
+/* color index */
+#define NAME(PREFIX) PREFIX##_CI
+#define FORMAT GL_COLOR_INDEX8_EXT
+#define SPAN_VARS \
+ const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
+#define INIT_PIXEL_PTR(P, X, Y) \
+ GLubyte *P = osmesa->rowaddr[Y] + (X)
+#define INC_PIXEL_PTR(P) P += 1
+#define STORE_PIXEL(DST, X, Y, VALUE) \
+ *DST = VALUE[0]
+#define FETCH_PIXEL(DST, SRC) \
+ DST = SRC[0]
+#include "swrast/s_spantemp.h"
+
+
+
+
+/**********************************************************************/
+/***** Optimized line rendering *****/
+/**********************************************************************/
+
+
+#if CHAN_TYPE == GL_FLOAT
+#define PACK_RGBA(DST, R, G, B, A) \
+do { \
+ (DST)[0] = MAX2( R, 0.0F ); \
+ (DST)[1] = MAX2( G, 0.0F ); \
+ (DST)[2] = MAX2( B, 0.0F ); \
+ (DST)[3] = CLAMP(A, 0.0F, CHAN_MAXF);\
+} while (0)
+#else
+#define PACK_RGBA(DST, R, G, B, A) \
+do { \
+ (DST)[osmesa->rInd] = R; \
+ (DST)[osmesa->gInd] = G; \
+ (DST)[osmesa->bInd] = B; \
+ (DST)[osmesa->aInd] = A; \
+} while (0)
+#endif
+
+#define PACK_RGB(DST, R, G, B) \
+do { \
+ (DST)[0] = R; \
+ (DST)[1] = G; \
+ (DST)[2] = B; \
+} while (0)
+
+#define PACK_BGR(DST, R, G, B) \
+do { \
+ (DST)[0] = B; \
+ (DST)[1] = G; \
+ (DST)[2] = R; \
+} while (0)
+
+#define PACK_RGB_565(DST, R, G, B) \
+do { \
+ (DST) = (((int) (R) << 8) & 0xf800) | (((int) (G) << 3) & 0x7e0) | ((int) (B) >> 3);\
+} while (0)
+
+#define UNPACK_RED(P) ( (P)[osmesa->rInd] )
+#define UNPACK_GREEN(P) ( (P)[osmesa->gInd] )
+#define UNPACK_BLUE(P) ( (P)[osmesa->bInd] )
+#define UNPACK_ALPHA(P) ( (P)[osmesa->aInd] )
+
+#define PIXELADDR1(X,Y) (osmesa->rowaddr[Y] + (X))
+#define PIXELADDR2(X,Y) (osmesa->rowaddr[Y] + 2 * (X))
+#define PIXELADDR3(X,Y) (osmesa->rowaddr[Y] + 3 * (X))
+#define PIXELADDR4(X,Y) (osmesa->rowaddr[Y] + 4 * (X))
+
+
+/*
+ * Draw a flat-shaded, RGB line into an osmesa buffer.
+ */
+#define NAME flat_rgba_line
+#define CLIP_HACK 1
+#define SETUP_CODE \
+ const OSMesaContext osmesa = OSMESA_CONTEXT(ctx); \
+ const GLchan *color = vert1->color;
+
+#define PLOT(X, Y) \
+do { \
+ GLchan *p = PIXELADDR4(X, Y); \
+ PACK_RGBA(p, color[0], color[1], color[2], color[3]); \
+} while (0)
+
+#ifdef WIN32
+#include "..\swrast\s_linetemp.h"
+#else
+#include "swrast/s_linetemp.h"
+#endif
+
+
+
+/*
+ * Draw a flat-shaded, Z-less, RGB line into an osmesa buffer.
+ */
+#define NAME flat_rgba_z_line
+#define CLIP_HACK 1
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define SETUP_CODE \
+ const OSMesaContext osmesa = OSMESA_CONTEXT(ctx); \
+ const GLchan *color = vert1->color;
+
+#define PLOT(X, Y) \
+do { \
+ if (Z < *zPtr) { \
+ GLchan *p = PIXELADDR4(X, Y); \
+ PACK_RGBA(p, color[RCOMP], color[GCOMP], \
+ color[BCOMP], color[ACOMP]); \
+ *zPtr = Z; \
+ } \
+} while (0)
+
+#ifdef WIN32
+#include "..\swrast\s_linetemp.h"
+#else
+#include "swrast/s_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 swrast_line_func
+osmesa_choose_line_function( GLcontext *ctx )
+{
+ const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
+ const SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ if (CHAN_BITS != 8) return NULL;
+ if (ctx->RenderMode != GL_RENDER) return NULL;
+ if (ctx->Line.SmoothFlag) return NULL;
+ if (ctx->Texture._EnabledUnits) return NULL;
+ if (ctx->Light.ShadeModel != GL_FLAT) return NULL;
+ if (ctx->Line.Width != 1.0F) return NULL;
+ if (ctx->Line.StippleFlag) return NULL;
+ if (ctx->Line.SmoothFlag) return NULL;
+ if (osmesa->format != OSMESA_RGBA &&
+ osmesa->format != OSMESA_BGRA &&
+ osmesa->format != OSMESA_ARGB) return NULL;
+
+ if (swrast->_RasterMask==DEPTH_BIT
+ && ctx->Depth.Func==GL_LESS
+ && ctx->Depth.Mask==GL_TRUE
+ && ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS) {
+ return (swrast_line_func) flat_rgba_z_line;
+ }
+
+ if (swrast->_RasterMask == 0) {
+ return (swrast_line_func) flat_rgba_line;
+ }
+
+ return (swrast_line_func) NULL;
+}
+
+
+/**********************************************************************/
+/***** Optimized triangle rendering *****/
+/**********************************************************************/
+
+
+/*
+ * Smooth-shaded, z-less triangle, RGBA color.
+ */
+#define NAME smooth_rgba_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define INTERP_ALPHA 1
+#define SETUP_CODE \
+ const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLchan *img = PIXELADDR4(span.x, span.y); \
+ for (i = 0; i < span.end; i++, img += 4) { \
+ const GLdepth z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ PACK_RGBA(img, FixedToChan(span.red), \
+ FixedToChan(span.green), FixedToChan(span.blue), \
+ FixedToChan(span.alpha)); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.alpha += span.alphaStep; \
+ span.z += span.zStep; \
+ }
+#ifdef WIN32
+#include "..\swrast\s_tritemp.h"
+#else
+#include "swrast/s_tritemp.h"
+#endif
+
+
+
+/*
+ * Flat-shaded, z-less triangle, RGBA color.
+ */
+#define NAME flat_rgba_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define SETUP_CODE \
+ const OSMesaContext osmesa = OSMESA_CONTEXT(ctx); \
+ GLuint pixel; \
+ PACK_RGBA((GLchan *) &pixel, v2->color[0], v2->color[1], \
+ v2->color[2], v2->color[3]);
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLuint *img = (GLuint *) PIXELADDR4(span.x, span.y); \
+ for (i = 0; i < span.end; i++) { \
+ const GLdepth z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ img[i] = pixel; \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+#ifdef WIN32
+#include "..\swrast\s_tritemp.h"
+#else
+#include "swrast/s_tritemp.h"
+#endif
+
+
+
+/*
+ * Return pointer to an accelerated triangle function if possible.
+ */
+static swrast_tri_func
+osmesa_choose_triangle_function( GLcontext *ctx )
+{
+ const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
+ const SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ if (CHAN_BITS != 8) return (swrast_tri_func) NULL;
+ if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL;
+ if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL;
+ if (ctx->Polygon.StippleFlag) return (swrast_tri_func) NULL;
+ if (ctx->Texture._EnabledUnits) return (swrast_tri_func) NULL;
+ if (osmesa->format != OSMESA_RGBA &&
+ osmesa->format != OSMESA_BGRA &&
+ osmesa->format != OSMESA_ARGB) return (swrast_tri_func) NULL;
+ if (ctx->Polygon.CullFlag &&
+ ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
+ return (swrast_tri_func) NULL;
+
+ if (swrast->_RasterMask == DEPTH_BIT &&
+ ctx->Depth.Func == GL_LESS &&
+ ctx->Depth.Mask == GL_TRUE &&
+ ctx->Visual.depthBits == DEFAULT_SOFTWARE_DEPTH_BITS) {
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ return (swrast_tri_func) smooth_rgba_z_triangle;
+ }
+ else {
+ return (swrast_tri_func) flat_rgba_z_triangle;
+ }
+ }
+ return (swrast_tri_func) NULL;
+}
+
+
+
+/* Override for the swrast triangle-selection function. Try to use one
+ * of our internal triangle functions, otherwise fall back to the
+ * standard swrast functions.
+ */
+static void
+osmesa_choose_triangle( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ swrast->Triangle = osmesa_choose_triangle_function( ctx );
+ if (!swrast->Triangle)
+ _swrast_choose_triangle( ctx );
+}
+
+static void
+osmesa_choose_line( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ swrast->Line = osmesa_choose_line_function( ctx );
+ if (!swrast->Line)
+ _swrast_choose_line( ctx );
+}
+
+
+#define OSMESA_NEW_LINE (_NEW_LINE | \
+ _NEW_TEXTURE | \
+ _NEW_LIGHT | \
+ _NEW_DEPTH | \
+ _NEW_RENDERMODE | \
+ _SWRAST_NEW_RASTERMASK)
+
+#define OSMESA_NEW_TRIANGLE (_NEW_POLYGON | \
+ _NEW_TEXTURE | \
+ _NEW_LIGHT | \
+ _NEW_DEPTH | \
+ _NEW_RENDERMODE | \
+ _SWRAST_NEW_RASTERMASK)
+
+
+/**
+ * Don't use _mesa_delete_renderbuffer since we can't free rb->Data.
+ */
+static void
+osmesa_delete_renderbuffer(struct gl_renderbuffer *rb)
+{
+ _mesa_free(rb);
+}
+
+
+/**
+ * Allocate renderbuffer storage. We don't actually allocate any storage
+ * since we're using a user-provided buffer.
+ * Just set up all the gl_renderbuffer methods.
+ */
+static GLboolean
+osmesa_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
+
+ if (osmesa->format == OSMESA_RGBA) {
+ rb->GetRow = get_row_RGBA;
+ rb->GetValues = get_values_RGBA;
+ rb->PutRow = put_row_RGBA;
+ rb->PutRowRGB = put_row_rgb_RGBA;
+ rb->PutMonoRow = put_mono_row_RGBA;
+ rb->PutValues = put_values_RGBA;
+ rb->PutMonoValues = put_mono_values_RGBA;
+ }
+ else if (osmesa->format == OSMESA_BGRA) {
+ rb->GetRow = get_row_BGRA;
+ rb->GetValues = get_values_BGRA;
+ rb->PutRow = put_row_BGRA;
+ rb->PutRowRGB = put_row_rgb_BGRA;
+ rb->PutMonoRow = put_mono_row_BGRA;
+ rb->PutValues = put_values_BGRA;
+ rb->PutMonoValues = put_mono_values_BGRA;
+ }
+ else if (osmesa->format == OSMESA_ARGB) {
+ rb->GetRow = get_row_ARGB;
+ rb->GetValues = get_values_ARGB;
+ rb->PutRow = put_row_ARGB;
+ rb->PutRowRGB = put_row_rgb_ARGB;
+ rb->PutMonoRow = put_mono_row_ARGB;
+ rb->PutValues = put_values_ARGB;
+ rb->PutMonoValues = put_mono_values_ARGB;
+ }
+ else if (osmesa->format == OSMESA_RGB) {
+ rb->GetRow = get_row_RGB;
+ rb->GetValues = get_values_RGB;
+ rb->PutRow = put_row_RGB;
+ rb->PutRowRGB = put_row_rgb_RGB;
+ rb->PutMonoRow = put_mono_row_RGB;
+ rb->PutValues = put_values_RGB;
+ rb->PutMonoValues = put_mono_values_RGB;
+ }
+ else if (osmesa->format == OSMESA_BGR) {
+ rb->GetRow = get_row_BGR;
+ rb->GetValues = get_values_BGR;
+ rb->PutRow = put_row_BGR;
+ rb->PutRowRGB = put_row_rgb_BGR;
+ rb->PutMonoRow = put_mono_row_BGR;
+ rb->PutValues = put_values_BGR;
+ rb->PutMonoValues = put_mono_values_BGR;
+ }
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ else if (osmesa->format == OSMESA_RGB_565) {
+ rb->GetRow = get_row_RGB_565;
+ rb->GetValues = get_values_RGB_565;
+ rb->PutRow = put_row_RGB_565;
+ rb->PutRow = put_row_rgb_RGB_565;
+ rb->PutMonoRow = put_mono_row_RGB_565;
+ rb->PutValues = put_values_RGB_565;
+ rb->PutMonoValues = put_mono_values_RGB_565;
+ }
+#endif
+ else if (osmesa->format == OSMESA_COLOR_INDEX) {
+ rb->GetRow = get_row_CI;
+ rb->GetValues = get_values_CI;
+ rb->PutRow = put_row_CI;
+ rb->PutMonoRow = put_mono_row_CI;
+ rb->PutValues = put_values_CI;
+ rb->PutMonoValues = put_mono_values_CI;
+ }
+ else {
+ _mesa_problem(ctx, "bad pixel format in osmesa renderbuffer_storage");
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Allocate a new renderbuffer tpo describe the user-provided color buffer.
+ */
+static struct gl_renderbuffer *
+new_osmesa_renderbuffer(GLenum format)
+{
+ struct gl_renderbuffer *rb = CALLOC_STRUCT(gl_renderbuffer);
+ if (rb) {
+ const GLuint name = 0;
+ _mesa_init_renderbuffer(rb, name);
+
+ rb->Delete = osmesa_delete_renderbuffer;
+ rb->AllocStorage = osmesa_renderbuffer_storage;
+
+ if (format == OSMESA_COLOR_INDEX) {
+ rb->_BaseFormat = GL_COLOR_INDEX;
+ rb->InternalFormat = GL_COLOR_INDEX;
+ rb->DataType = GL_UNSIGNED_BYTE;
+ }
+ else {
+ rb->_BaseFormat = GL_RGBA;
+ rb->InternalFormat = GL_RGBA;
+ rb->DataType = CHAN_TYPE;
+ }
+ }
+ return rb;
+}
+
+
+
+/**********************************************************************/
+/***** 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
+ */
+GLAPI OSMesaContext GLAPIENTRY
+OSMesaCreateContext( GLenum format, OSMesaContext sharelist )
+{
+ const GLint accumBits = (format == OSMESA_COLOR_INDEX) ? 0 : 16;
+ return OSMesaCreateContextExt(format, DEFAULT_SOFTWARE_DEPTH_BITS,
+ 8, accumBits, sharelist);
+}
+
+
+
+/*
+ * New in Mesa 3.5
+ *
+ * Create context and specify size of ancillary buffers.
+ */
+GLAPI OSMesaContext GLAPIENTRY
+OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
+ GLint accumBits, OSMesaContext sharelist )
+{
+ OSMesaContext osmesa;
+ struct dd_function_table functions;
+ GLint rshift, gshift, bshift, ashift;
+ GLint rind, gind, bind, aind;
+ GLint indexBits = 0, redBits = 0, greenBits = 0, blueBits = 0, alphaBits =0;
+ GLboolean rgbmode;
+ const GLuint i4 = 1;
+ const GLubyte *i1 = (GLubyte *) &i4;
+ const GLint little_endian = *i1;
+
+ rind = gind = bind = aind = 0;
+ if (format==OSMESA_COLOR_INDEX) {
+ indexBits = 8;
+ rshift = gshift = bshift = ashift = 0;
+ rgbmode = GL_FALSE;
+ }
+ else if (format==OSMESA_RGBA) {
+ indexBits = 0;
+ redBits = CHAN_BITS;
+ greenBits = CHAN_BITS;
+ blueBits = CHAN_BITS;
+ alphaBits = CHAN_BITS;
+ rind = 0;
+ gind = 1;
+ bind = 2;
+ aind = 3;
+ 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;
+ redBits = CHAN_BITS;
+ greenBits = CHAN_BITS;
+ blueBits = CHAN_BITS;
+ alphaBits = CHAN_BITS;
+ bind = 0;
+ gind = 1;
+ rind = 2;
+ aind = 3;
+ if (little_endian) {
+ bshift = 0;
+ gshift = 8;
+ rshift = 16;
+ ashift = 24;
+ }
+ else {
+ bshift = 24;
+ gshift = 16;
+ rshift = 8;
+ ashift = 0;
+ }
+ rgbmode = GL_TRUE;
+ }
+ else if (format==OSMESA_ARGB) {
+ indexBits = 0;
+ redBits = CHAN_BITS;
+ greenBits = CHAN_BITS;
+ blueBits = CHAN_BITS;
+ alphaBits = CHAN_BITS;
+ aind = 0;
+ rind = 1;
+ gind = 2;
+ bind = 3;
+ if (little_endian) {
+ ashift = 0;
+ rshift = 8;
+ gshift = 16;
+ bshift = 24;
+ }
+ else {
+ ashift = 24;
+ rshift = 16;
+ gshift = 8;
+ bshift = 0;
+ }
+ rgbmode = GL_TRUE;
+ }
+ else if (format==OSMESA_RGB) {
+ indexBits = 0;
+ redBits = CHAN_BITS;
+ greenBits = CHAN_BITS;
+ blueBits = CHAN_BITS;
+ alphaBits = 0;
+ bshift = 0;
+ gshift = 8;
+ rshift = 16;
+ ashift = 24;
+ rind = 0;
+ gind = 1;
+ bind = 2;
+ rgbmode = GL_TRUE;
+ }
+ else if (format==OSMESA_BGR) {
+ indexBits = 0;
+ redBits = CHAN_BITS;
+ greenBits = CHAN_BITS;
+ blueBits = CHAN_BITS;
+ alphaBits = 0;
+ bshift = 0;
+ gshift = 8;
+ rshift = 16;
+ ashift = 24;
+ rind = 2;
+ gind = 1;
+ bind = 0;
+ rgbmode = GL_TRUE;
+ }
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ else if (format==OSMESA_RGB_565) {
+ indexBits = 0;
+ redBits = 5;
+ greenBits = 6;
+ blueBits = 5;
+ alphaBits = 0;
+ rshift = 11;
+ gshift = 5;
+ bshift = 0;
+ ashift = 0;
+ rind = 0; /* not used */
+ gind = 0;
+ bind = 0;
+ rgbmode = GL_TRUE;
+ }
+#endif
+ else {
+ return NULL;
+ }
+
+ osmesa = (OSMesaContext) CALLOC_STRUCT(osmesa_context);
+ if (osmesa) {
+ osmesa->gl_visual = _mesa_create_visual( rgbmode,
+ GL_FALSE, /* double buffer */
+ GL_FALSE, /* stereo */
+ redBits,
+ greenBits,
+ blueBits,
+ alphaBits,
+ indexBits,
+ depthBits,
+ stencilBits,
+ accumBits,
+ accumBits,
+ accumBits,
+ alphaBits ? accumBits : 0,
+ 1 /* num samples */
+ );
+ if (!osmesa->gl_visual) {
+ FREE(osmesa);
+ return NULL;
+ }
+
+ /* Initialize device driver function table */
+ _mesa_init_driver_functions(&functions);
+ /* override with our functions */
+ functions.GetString = get_string;
+ functions.UpdateState = osmesa_update_state;
+ functions.GetBufferSize = get_buffer_size;
+
+ if (!_mesa_initialize_context(&osmesa->mesa,
+ osmesa->gl_visual,
+ sharelist ? &sharelist->mesa
+ : (GLcontext *) NULL,
+ &functions, (void *) osmesa)) {
+ _mesa_destroy_visual( osmesa->gl_visual );
+ FREE(osmesa);
+ return NULL;
+ }
+
+ _mesa_enable_sw_extensions(&(osmesa->mesa));
+ _mesa_enable_1_3_extensions(&(osmesa->mesa));
+ _mesa_enable_1_4_extensions(&(osmesa->mesa));
+ _mesa_enable_1_5_extensions(&(osmesa->mesa));
+
+ osmesa->gl_buffer = _mesa_create_framebuffer(osmesa->gl_visual);
+ if (!osmesa->gl_buffer) {
+ _mesa_destroy_visual( osmesa->gl_visual );
+ _mesa_free_context_data( &osmesa->mesa );
+ FREE(osmesa);
+ return NULL;
+ }
+
+ /* create front color buffer in user-provided memory (no back buffer) */
+ _mesa_add_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT,
+ new_osmesa_renderbuffer(format));
+ _mesa_add_soft_renderbuffers(osmesa->gl_buffer,
+ GL_FALSE, /* color */
+ osmesa->gl_visual->haveDepthBuffer,
+ osmesa->gl_visual->haveStencilBuffer,
+ osmesa->gl_visual->haveAccumBuffer,
+ GL_FALSE, /* alpha */
+ GL_FALSE /* aux */ );
+
+ osmesa->format = format;
+ osmesa->buffer = NULL;
+ osmesa->width = 0;
+ osmesa->height = 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;
+ osmesa->aInd = aind;
+
+ /* Initialize the software rasterizer and helper modules. */
+ {
+ GLcontext *ctx = &osmesa->mesa;
+ SWcontext *swrast;
+ struct swrast_device_driver *swdd;
+ TNLcontext *tnl;
+
+ if (!_swrast_CreateContext( ctx ) ||
+ !_ac_CreateContext( ctx ) ||
+ !_tnl_CreateContext( ctx ) ||
+ !_swsetup_CreateContext( ctx )) {
+ _mesa_destroy_visual(osmesa->gl_visual);
+ _mesa_free_context_data(ctx);
+ _mesa_free(osmesa);
+ return NULL;
+ }
+
+ _swsetup_Wakeup( ctx );
+
+ /* use default TCL pipeline */
+ tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.RunPipeline = _tnl_run_pipeline;
+
+ swdd = _swrast_GetDeviceDriverReference( ctx );
+ swdd->SetBuffer = set_buffer;
+
+ /* Extend the software rasterizer with our optimized line and triangle
+ * drawing functions.
+ */
+ swrast = SWRAST_CONTEXT( ctx );
+ swrast->choose_line = osmesa_choose_line;
+ swrast->choose_triangle = osmesa_choose_triangle;
+ swrast->invalidate_line |= OSMESA_NEW_LINE;
+ swrast->invalidate_triangle |= OSMESA_NEW_TRIANGLE;
+ }
+ }
+ return osmesa;
+}
+
+
+/*
+ * Destroy an Off-Screen Mesa rendering context.
+ *
+ * Input: ctx - the context to destroy
+ */
+GLAPI void GLAPIENTRY
+OSMesaDestroyContext( OSMesaContext ctx )
+{
+ if (ctx) {
+ _swsetup_DestroyContext( &ctx->mesa );
+ _tnl_DestroyContext( &ctx->mesa );
+ _ac_DestroyContext( &ctx->mesa );
+ _swrast_DestroyContext( &ctx->mesa );
+
+ _mesa_destroy_visual( ctx->gl_visual );
+ _mesa_destroy_framebuffer( ctx->gl_buffer );
+ _mesa_free_context_data( &ctx->mesa );
+ FREE( ctx );
+ }
+}
+
+
+/*
+ * Recompute the values of the context's rowaddr array.
+ */
+static void
+compute_row_addresses( OSMesaContext ctx )
+{
+ GLint bytesPerPixel, bytesPerRow, i;
+ GLubyte *origin = (GLubyte *) ctx->buffer;
+
+ if (ctx->format == OSMESA_COLOR_INDEX) {
+ /* CI mode */
+ bytesPerPixel = 1 * sizeof(GLchan);
+ }
+ else if ((ctx->format == OSMESA_RGB) || (ctx->format == OSMESA_BGR)) {
+ /* RGB mode */
+ bytesPerPixel = 3 * sizeof(GLchan);
+ }
+ else if (ctx->format == OSMESA_RGB_565) {
+ /* 5/6/5 RGB pixel in 16 bits */
+ bytesPerPixel = 2;
+ }
+ else {
+ /* RGBA mode */
+ bytesPerPixel = 4 * sizeof(GLchan);
+ }
+
+ bytesPerRow = ctx->rowlength * bytesPerPixel;
+
+ if (ctx->yup) {
+ /* Y=0 is bottom line of window */
+ for (i = 0; i < MAX_HEIGHT; i++) {
+ ctx->rowaddr[i] = (GLchan *) ((GLubyte *) origin + i * bytesPerRow);
+ }
+ }
+ else {
+ /* Y=0 is top line of window */
+ for (i = 0; i < MAX_HEIGHT; i++) {
+ GLint j = ctx->height - i - 1;
+ ctx->rowaddr[i] = (GLchan *) ((GLubyte *) origin + j * bytesPerRow);
+ }
+ }
+}
+
+
+/*
+ * 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).
+ *
+ * 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
+ * Normally, only GL_UNSIGNED_BYTE and GL_UNSIGNED_SHORT_5_6_5
+ * are supported. But if Mesa's been compiled with CHAN_BITS==16
+ * then type must be GL_UNSIGNED_SHORT. And if Mesa's been build
+ * with CHAN_BITS==32 then type must be GL_FLOAT.
+ * 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, invalid type, 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 )
+{
+ if (!ctx || !buffer ||
+ width < 1 || height < 1 ||
+ width > MAX_WIDTH || height > MAX_HEIGHT) {
+ return GL_FALSE;
+ }
+
+ if (ctx->format == OSMESA_RGB_565) {
+ if (type != GL_UNSIGNED_SHORT_5_6_5)
+ return GL_FALSE;
+ }
+ else if (type != CHAN_TYPE) {
+ return GL_FALSE;
+ }
+
+ /* Need to set these before calling _mesa_make_current() since the first
+ * time the context is bound, _mesa_make_current() will call our
+ * get_buffer_size() function to initialize the viewport. These are the
+ * values returned by get_buffer_size():
+ */
+ ctx->buffer = buffer;
+ ctx->width = width;
+ ctx->height = height;
+
+ osmesa_update_state( &ctx->mesa, 0 );
+ _mesa_make_current( &ctx->mesa, ctx->gl_buffer, ctx->gl_buffer );
+
+ if (ctx->userRowLength)
+ ctx->rowlength = ctx->userRowLength;
+ else
+ ctx->rowlength = width;
+
+ compute_row_addresses( ctx );
+
+ /* this will make ensure we recognize the new buffer size */
+ _mesa_resize_framebuffer(&ctx->mesa, ctx->gl_buffer, width, height);
+
+ /* Added by Gerk Huisma: */
+ _tnl_MakeCurrent( &ctx->mesa, ctx->mesa.DrawBuffer,
+ ctx->mesa.ReadBuffer );
+
+ return GL_TRUE;
+}
+
+
+
+GLAPI OSMesaContext GLAPIENTRY
+OSMesaGetCurrentContext( void )
+{
+ GLcontext *ctx = _mesa_get_current_context();
+ if (ctx)
+ return (OSMesaContext) ctx;
+ else
+ return NULL;
+}
+
+
+
+GLAPI void GLAPIENTRY
+OSMesaPixelStore( GLint pname, GLint value )
+{
+ OSMesaContext osmesa = OSMesaGetCurrentContext();
+
+ switch (pname) {
+ case OSMESA_ROW_LENGTH:
+ if (value<0) {
+ _mesa_error( &osmesa->mesa, GL_INVALID_VALUE,
+ "OSMesaPixelStore(value)" );
+ return;
+ }
+ osmesa->userRowLength = value;
+ osmesa->rowlength = value ? value : osmesa->width;
+ break;
+ case OSMESA_Y_UP:
+ osmesa->yup = value ? GL_TRUE : GL_FALSE;
+ break;
+ default:
+ _mesa_error( &osmesa->mesa, GL_INVALID_ENUM, "OSMesaPixelStore(pname)" );
+ return;
+ }
+
+ compute_row_addresses( osmesa );
+}
+
+
+GLAPI void GLAPIENTRY
+OSMesaGetIntegerv( GLint pname, GLint *value )
+{
+ OSMesaContext osmesa = OSMesaGetCurrentContext();
+
+ switch (pname) {
+ case OSMESA_WIDTH:
+ *value = osmesa->width;
+ return;
+ case OSMESA_HEIGHT:
+ *value = osmesa->height;
+ return;
+ case OSMESA_FORMAT:
+ *value = osmesa->format;
+ return;
+ case OSMESA_TYPE:
+ *value = CHAN_TYPE;
+ return;
+ case OSMESA_ROW_LENGTH:
+ *value = osmesa->userRowLength;
+ return;
+ case OSMESA_Y_UP:
+ *value = osmesa->yup;
+ return;
+ case OSMESA_MAX_WIDTH:
+ *value = MAX_WIDTH;
+ return;
+ case OSMESA_MAX_HEIGHT:
+ *value = MAX_HEIGHT;
+ return;
+ default:
+ _mesa_error(&osmesa->mesa, 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.
+ */
+GLAPI GLboolean GLAPIENTRY
+OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint *height,
+ GLint *bytesPerValue, void **buffer )
+{
+ struct gl_renderbuffer *rb = NULL;
+
+ if (c->gl_buffer)
+ rb = c->gl_buffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+
+ if (!rb || !rb->Data) {
+ /*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;
+ if (c->gl_visual->depthBits <= 16)
+ *bytesPerValue = sizeof(GLushort);
+ else
+ *bytesPerValue = sizeof(GLuint);
+ *buffer = rb->Data;
+ 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.
+ */
+GLAPI 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;
+ }
+}
+
+
+struct name_function
+{
+ const char *Name;
+ OSMESAproc Function;
+};
+
+static struct name_function functions[] = {
+ { "OSMesaCreateContext", (OSMESAproc) OSMesaCreateContext },
+ { "OSMesaCreateContextExt", (OSMESAproc) OSMesaCreateContextExt },
+ { "OSMesaDestroyContext", (OSMESAproc) OSMesaDestroyContext },
+ { "OSMesaMakeCurrent", (OSMESAproc) OSMesaMakeCurrent },
+ { "OSMesaGetCurrentContext", (OSMESAproc) OSMesaGetCurrentContext },
+ { "OSMesaPixelsStore", (OSMESAproc) OSMesaPixelStore },
+ { "OSMesaGetIntegerv", (OSMESAproc) OSMesaGetIntegerv },
+ { "OSMesaGetDepthBuffer", (OSMESAproc) OSMesaGetDepthBuffer },
+ { "OSMesaGetColorBuffer", (OSMESAproc) OSMesaGetColorBuffer },
+ { "OSMesaGetProcAddress", (OSMESAproc) OSMesaGetProcAddress },
+ { NULL, NULL }
+};
+
+
+GLAPI OSMESAproc GLAPIENTRY
+OSMesaGetProcAddress( const char *funcName )
+{
+ int i;
+ for (i = 0; functions[i].Name; i++) {
+ if (_mesa_strcmp(functions[i].Name, funcName) == 0)
+ return functions[i].Function;
+ }
+ return _glapi_get_proc_address(funcName);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/osmesa/osmesa.def b/nx-X11/extras/Mesa/src/mesa/drivers/osmesa/osmesa.def
new file mode 100644
index 000000000..a92a30f35
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/osmesa/osmesa.def
@@ -0,0 +1,13 @@
+DESCRIPTION 'Mesa OSMesa lib for Win32'
+VERSION 4.1
+
+EXPORTS
+ OSMesaCreateContext
+ OSMesaCreateContextExt
+ OSMesaDestroyContext
+ OSMesaMakeCurrent
+ OSMesaGetCurrentContext
+ OSMesaPixelStore
+ OSMesaGetIntegerv
+ OSMesaGetDepthBuffer
+ OSMesaGetColorBuffer
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/x11/descrip.mms b/nx-X11/extras/Mesa/src/mesa/drivers/x11/descrip.mms
new file mode 100644
index 000000000..69d14e36c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/x11/descrip.mms
@@ -0,0 +1,51 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+# Last revision : 16 June 2003
+
+.first
+ define gl [----.include.gl]
+ define math [--.math]
+ define tnl [--.tnl]
+ define swrast [--.swrast]
+ define swrast_setup [--.swrast_setup]
+ define array_cache [--.array_cache]
+ define drivers [-]
+
+.include [----]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [----.include],[--.main],[--.glapi]
+LIBDIR = [----.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)
+
+SOURCES = fakeglx.c glxapi.c xfonts.c xm_api.c xm_dd.c xm_line.c xm_span.c\
+ xm_tri.c xm_buffer.c
+
+OBJECTS =fakeglx.obj,glxapi.obj,xfonts.obj,xm_api.obj,xm_dd.obj,xm_line.obj,\
+ xm_span.obj,xm_tri.obj,xm_buffer.obj
+
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+ @ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
+
+clean :
+ purge
+ delete *.obj;*
+
+fakeglx.obj : fakeglx.c
+glxapi.obj : glxapi.c
+xfonts.obj : xfonts.c
+xm_api.obj : xm_api.c
+xm_buffer.obj : xm_buffer.c
+xm_dd.obj : xm_dd.c
+xm_line.obj : xm_line.c
+xm_span.obj : xm_span.c
+xm_tri.obj : xm_tri.c
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/x11/fakeglx.c b/nx-X11/extras/Mesa/src/mesa/drivers/x11/fakeglx.c
new file mode 100644
index 000000000..d3213e708
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/x11/fakeglx.c
@@ -0,0 +1,2886 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/*
+ * This is an emulation of the GLX API which allows Mesa/GLX-based programs
+ * to run on X servers which do not have the real GLX extension.
+ *
+ * Thanks to the contributors:
+ *
+ * Initial version: Philip Brown (phil@bolthole.com)
+ * Better glXGetConfig() support: Armin Liebchen (liebchen@asylum.cs.utah.edu)
+ * Further visual-handling refinements: Wolfram Gloger
+ * (wmglo@Dent.MED.Uni-Muenchen.DE).
+ *
+ * Notes:
+ * Don't be fooled, stereo isn't supported yet.
+ */
+
+
+
+#include "glxheader.h"
+#include "glxapi.h"
+#include "GL/xmesa.h"
+#include "context.h"
+#include "config.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "version.h"
+#include "xfonts.h"
+#include "xmesaP.h"
+
+#ifdef __VMS
+#define _mesa_sprintf sprintf
+#endif
+
+/* This indicates the client-side GLX API and GLX encoder version. */
+#define CLIENT_MAJOR_VERSION 1
+#define CLIENT_MINOR_VERSION 4 /* but don't have 1.3's pbuffers, etc yet */
+
+/* This indicates the server-side GLX decoder version.
+ * GLX 1.4 indicates OpenGL 1.3 support
+ */
+#define SERVER_MAJOR_VERSION 1
+#define SERVER_MINOR_VERSION 4
+
+/* This is appended onto the glXGetClient/ServerString version strings. */
+#define MESA_GLX_VERSION "Mesa " MESA_VERSION_STRING
+
+/* Who implemented this GLX? */
+#define VENDOR "Brian Paul"
+
+#define EXTENSIONS \
+ "GLX_MESA_set_3dfx_mode " \
+ "GLX_MESA_copy_sub_buffer " \
+ "GLX_MESA_pixmap_colormap " \
+ "GLX_MESA_release_buffers " \
+ "GLX_ARB_get_proc_address " \
+ "GLX_EXT_visual_info " \
+ "GLX_EXT_visual_rating " \
+ "GLX_SGI_video_sync " \
+ "GLX_SGIX_fbconfig " \
+ "GLX_SGIX_pbuffer "
+
+/*
+ * Our fake GLX context will contain a "real" GLX context and an XMesa context.
+ *
+ * Note that a pointer to a __GLXcontext is a pointer to a fake_glx_context,
+ * and vice versa.
+ *
+ * We really just need this structure in order to make the libGL functions
+ * glXGetCurrentContext(), glXGetCurrentDrawable() and glXGetCurrentDisplay()
+ * work correctly.
+ */
+struct fake_glx_context {
+ __GLXcontext glxContext; /* this MUST be first! */
+ XMesaContext xmesaContext;
+};
+
+
+
+/**********************************************************************/
+/*** GLX Visual Code ***/
+/**********************************************************************/
+
+#define DONT_CARE -1
+
+
+static XMesaVisual *VisualTable = NULL;
+static int NumVisuals = 0;
+
+
+/*
+ * This struct and some code fragments borrowed
+ * from Mark Kilgard's GLUT library.
+ */
+typedef struct _OverlayInfo {
+ /* Avoid 64-bit portability problems by being careful to use
+ longs due to the way XGetWindowProperty is specified. Note
+ that these parameters are passed as CARD32s over X
+ protocol. */
+ unsigned long overlay_visual;
+ long transparent_type;
+ long value;
+ long layer;
+} OverlayInfo;
+
+
+
+/* Macro to handle c_class vs class field name in XVisualInfo struct */
+#if defined(__cplusplus) || defined(c_plusplus)
+#define CLASS c_class
+#else
+#define CLASS class
+#endif
+
+
+
+/*
+ * Test if the given XVisualInfo is usable for Mesa rendering.
+ */
+static GLboolean
+is_usable_visual( XVisualInfo *vinfo )
+{
+ switch (vinfo->CLASS) {
+ case StaticGray:
+ case GrayScale:
+ /* Any StaticGray/GrayScale visual works in RGB or CI mode */
+ return GL_TRUE;
+ case StaticColor:
+ case PseudoColor:
+ /* Any StaticColor/PseudoColor visual of at least 4 bits */
+ if (vinfo->depth>=4) {
+ return GL_TRUE;
+ }
+ else {
+ return GL_FALSE;
+ }
+ case TrueColor:
+ case DirectColor:
+ /* Any depth of TrueColor or DirectColor works in RGB mode */
+ return GL_TRUE;
+ default:
+ /* This should never happen */
+ return GL_FALSE;
+ }
+}
+
+
+
+/**
+ * Get an array OverlayInfo records for specified screen.
+ * \param dpy the display
+ * \param screen screen number
+ * \param numOverlays returns numver of OverlayInfo records
+ * \return pointer to OverlayInfo array, free with XFree()
+ */
+static OverlayInfo *
+GetOverlayInfo(Display *dpy, int screen, int *numOverlays)
+{
+ Atom overlayVisualsAtom;
+ Atom actualType;
+ Status status;
+ unsigned char *ovInfo;
+ unsigned long sizeData, bytesLeft;
+ int actualFormat;
+
+ /*
+ * The SERVER_OVERLAY_VISUALS property on the root window contains
+ * a list of overlay visuals. Get that list now.
+ */
+ overlayVisualsAtom = XInternAtom(dpy,"SERVER_OVERLAY_VISUALS", True);
+ if (overlayVisualsAtom == None) {
+ return 0;
+ }
+
+ status = XGetWindowProperty(dpy, RootWindow(dpy, screen),
+ overlayVisualsAtom, 0L, (long) 10000, False,
+ overlayVisualsAtom, &actualType, &actualFormat,
+ &sizeData, &bytesLeft,
+ &ovInfo);
+
+ if (status != Success || actualType != overlayVisualsAtom ||
+ actualFormat != 32 || sizeData < 4) {
+ /* something went wrong */
+ XFree((void *) ovInfo);
+ *numOverlays = 0;
+ return NULL;
+ }
+
+ *numOverlays = sizeData / 4;
+ return (OverlayInfo *) ovInfo;
+}
+
+
+
+/**
+ * Return the level (overlay, normal, underlay) of a given XVisualInfo.
+ * Input: dpy - the X display
+ * vinfo - the XVisualInfo to test
+ * Return: level of the visual:
+ * 0 = normal planes
+ * >0 = overlay planes
+ * <0 = underlay planes
+ */
+static int
+level_of_visual( Display *dpy, XVisualInfo *vinfo )
+{
+ OverlayInfo *overlay_info;
+ int numOverlaysPerScreen, i;
+
+ overlay_info = GetOverlayInfo(dpy, vinfo->screen, &numOverlaysPerScreen);
+ if (!overlay_info) {
+ return 0;
+ }
+
+ /* search the overlay visual list for the visual ID of interest */
+ for (i = 0; i < numOverlaysPerScreen; i++) {
+ const OverlayInfo *ov = overlay_info + i;
+ if (ov->overlay_visual == vinfo->visualid) {
+ /* found the visual */
+ if (/*ov->transparent_type==1 &&*/ ov->layer!=0) {
+ int level = ov->layer;
+ XFree((void *) overlay_info);
+ return level;
+ }
+ else {
+ XFree((void *) overlay_info);
+ return 0;
+ }
+ }
+ }
+
+ /* The visual ID was not found in the overlay list. */
+ XFree((void *) overlay_info);
+ return 0;
+}
+
+
+
+
+/*
+ * Given an XVisualInfo and RGB, Double, and Depth buffer flags, save the
+ * configuration in our list of GLX visuals.
+ */
+static XMesaVisual
+save_glx_visual( Display *dpy, XVisualInfo *vinfo,
+ GLboolean rgbFlag, GLboolean alphaFlag, GLboolean dbFlag,
+ GLboolean stereoFlag,
+ GLint depth_size, GLint stencil_size,
+ GLint accumRedSize, GLint accumGreenSize,
+ GLint accumBlueSize, GLint accumAlphaSize,
+ GLint level, GLint numAuxBuffers )
+{
+ GLboolean ximageFlag = GL_TRUE;
+ XMesaVisual xmvis;
+ GLint i;
+ GLboolean comparePointers;
+
+ if (dbFlag) {
+ /* Check if the MESA_BACK_BUFFER env var is set */
+ char *backbuffer = _mesa_getenv("MESA_BACK_BUFFER");
+ if (backbuffer) {
+ if (backbuffer[0]=='p' || backbuffer[0]=='P') {
+ ximageFlag = GL_FALSE;
+ }
+ else if (backbuffer[0]=='x' || backbuffer[0]=='X') {
+ ximageFlag = GL_TRUE;
+ }
+ else {
+ _mesa_warning(NULL, "Mesa: invalid value for MESA_BACK_BUFFER environment variable, using an XImage.");
+ }
+ }
+ }
+
+ /* Comparing IDs uses less memory but sometimes fails. */
+ /* XXX revisit this after 3.0 is finished. */
+ if (_mesa_getenv("MESA_GLX_VISUAL_HACK"))
+ comparePointers = GL_TRUE;
+ else
+ comparePointers = GL_FALSE;
+
+ /* Force the visual to have an alpha channel */
+ if (rgbFlag && _mesa_getenv("MESA_GLX_FORCE_ALPHA"))
+ alphaFlag = GL_TRUE;
+
+ /* First check if a matching visual is already in the list */
+ for (i=0; i<NumVisuals; i++) {
+ XMesaVisual v = VisualTable[i];
+ if (v->display == dpy
+ && v->mesa_visual.level == level
+ && v->mesa_visual.numAuxBuffers == numAuxBuffers
+ && v->ximage_flag == ximageFlag
+ && v->mesa_visual.rgbMode == rgbFlag
+ && v->mesa_visual.doubleBufferMode == dbFlag
+ && v->mesa_visual.stereoMode == stereoFlag
+ && (v->mesa_visual.alphaBits > 0) == alphaFlag
+ && (v->mesa_visual.depthBits >= depth_size || depth_size == 0)
+ && (v->mesa_visual.stencilBits >= stencil_size || stencil_size == 0)
+ && (v->mesa_visual.accumRedBits >= accumRedSize || accumRedSize == 0)
+ && (v->mesa_visual.accumGreenBits >= accumGreenSize || accumGreenSize == 0)
+ && (v->mesa_visual.accumBlueBits >= accumBlueSize || accumBlueSize == 0)
+ && (v->mesa_visual.accumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) {
+ /* now either compare XVisualInfo pointers or visual IDs */
+ if ((!comparePointers && v->visinfo->visualid == vinfo->visualid)
+ || (comparePointers && v->vishandle == vinfo)) {
+ return v;
+ }
+ }
+ }
+
+ /* Create a new visual and add it to the list. */
+
+ xmvis = XMesaCreateVisual( dpy, vinfo, rgbFlag, alphaFlag, dbFlag,
+ stereoFlag, ximageFlag,
+ depth_size, stencil_size,
+ accumRedSize, accumBlueSize,
+ accumBlueSize, accumAlphaSize, 0, level,
+ GLX_NONE_EXT );
+ if (xmvis) {
+ /* Save a copy of the pointer now so we can find this visual again
+ * if we need to search for it in find_glx_visual().
+ */
+ xmvis->vishandle = vinfo;
+ /* Allocate more space for additional visual */
+ VisualTable = _mesa_realloc( VisualTable,
+ sizeof(XMesaVisual) * NumVisuals,
+ sizeof(XMesaVisual) * (NumVisuals + 1));
+ /* add xmvis to the list */
+ VisualTable[NumVisuals] = xmvis;
+ NumVisuals++;
+ /* XXX minor hack, because XMesaCreateVisual doesn't support an
+ * aux buffers parameter.
+ */
+ xmvis->mesa_visual.numAuxBuffers = numAuxBuffers;
+ }
+ return xmvis;
+}
+
+
+/**
+ * Return the default number of bits for the Z buffer.
+ * If defined, use the MESA_GLX_DEPTH_BITS env var value.
+ * Otherwise, use the DEFAULT_SOFTWARE_DEPTH_BITS constant.
+ * XXX probably do the same thing for stencil, accum, etc.
+ */
+static GLint
+default_depth_bits(void)
+{
+ int zBits;
+ const char *zEnv = _mesa_getenv("MESA_GLX_DEPTH_BITS");
+ if (zEnv)
+ zBits = _mesa_atoi(zEnv);
+ else
+ zBits = DEFAULT_SOFTWARE_DEPTH_BITS;
+ return zBits;
+}
+
+
+
+/*
+ * 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 )
+{
+ int vislevel;
+ GLint zBits = default_depth_bits();
+
+ vislevel = level_of_visual( dpy, visinfo );
+ if (vislevel) {
+ /* Configure this visual as a CI, single-buffered overlay */
+ return save_glx_visual( dpy, visinfo,
+ GL_FALSE, /* rgb */
+ GL_FALSE, /* alpha */
+ GL_FALSE, /* double */
+ GL_FALSE, /* stereo */
+ 0, /* depth bits */
+ 0, /* stencil bits */
+ 0,0,0,0, /* accum bits */
+ vislevel, /* level */
+ 0 /* numAux */
+ );
+ }
+ else if (is_usable_visual( visinfo )) {
+ if (_mesa_getenv("MESA_GLX_FORCE_CI")) {
+ /* Configure this visual as a COLOR INDEX visual. */
+ return save_glx_visual( dpy, visinfo,
+ GL_FALSE, /* rgb */
+ GL_FALSE, /* alpha */
+ GL_TRUE, /* double */
+ GL_FALSE, /* stereo */
+ zBits,
+ STENCIL_BITS,
+ 0, 0, 0, 0, /* accum bits */
+ 0, /* level */
+ 0 /* numAux */
+ );
+ }
+ else {
+ /* Configure this visual as RGB, double-buffered, depth-buffered. */
+ /* This is surely wrong for some people's needs but what else */
+ /* can be done? They should use glXChooseVisual(). */
+ return save_glx_visual( dpy, visinfo,
+ GL_TRUE, /* rgb */
+ GL_FALSE, /* alpha */
+ GL_TRUE, /* double */
+ GL_FALSE, /* stereo */
+ zBits,
+ STENCIL_BITS,
+ ACCUM_BITS, /* r */
+ ACCUM_BITS, /* g */
+ ACCUM_BITS, /* b */
+ ACCUM_BITS, /* a */
+ 0, /* level */
+ 0 /* numAux */
+ );
+ }
+ }
+ else {
+ _mesa_warning(NULL, "Mesa: error in glXCreateContext: bad visual\n");
+ return NULL;
+ }
+}
+
+
+
+/*
+ * Find the GLX visual associated with an XVisualInfo.
+ */
+static XMesaVisual
+find_glx_visual( Display *dpy, XVisualInfo *vinfo )
+{
+ int i;
+
+ /* try to match visual id */
+ for (i=0;i<NumVisuals;i++) {
+ if (VisualTable[i]->display==dpy
+ && VisualTable[i]->visinfo->visualid == vinfo->visualid) {
+ return VisualTable[i];
+ }
+ }
+
+ /* if that fails, try to match pointers */
+ for (i=0;i<NumVisuals;i++) {
+ if (VisualTable[i]->display==dpy && VisualTable[i]->vishandle==vinfo) {
+ return VisualTable[i];
+ }
+ }
+
+ return NULL;
+}
+
+
+
+/**
+ * Return the transparent pixel value for a GLX visual.
+ * Input: glxvis - the glx_visual
+ * Return: a pixel value or -1 if no transparent pixel
+ */
+static int
+transparent_pixel( XMesaVisual glxvis )
+{
+ Display *dpy = glxvis->display;
+ XVisualInfo *vinfo = glxvis->visinfo;
+ OverlayInfo *overlay_info;
+ int numOverlaysPerScreen, i;
+
+ overlay_info = GetOverlayInfo(dpy, vinfo->screen, &numOverlaysPerScreen);
+ if (!overlay_info) {
+ return -1;
+ }
+
+ for (i = 0; i < numOverlaysPerScreen; i++) {
+ const OverlayInfo *ov = overlay_info + i;
+ if (ov->overlay_visual == vinfo->visualid) {
+ /* found it! */
+ if (ov->transparent_type == 0) {
+ /* type 0 indicates no transparency */
+ XFree((void *) overlay_info);
+ return -1;
+ }
+ else {
+ /* ov->value is the transparent pixel */
+ XFree((void *) overlay_info);
+ return ov->value;
+ }
+ }
+ }
+
+ /* The visual ID was not found in the overlay list. */
+ XFree((void *) overlay_info);
+ return -1;
+}
+
+
+
+/**
+ * Try to get an X visual which matches the given arguments.
+ */
+static XVisualInfo *
+get_visual( Display *dpy, int scr, unsigned int depth, int xclass )
+{
+ XVisualInfo temp, *vis;
+ long mask;
+ int n;
+ unsigned int default_depth;
+ int default_class;
+
+ mask = VisualScreenMask | VisualDepthMask | VisualClassMask;
+ temp.screen = scr;
+ temp.depth = depth;
+ temp.CLASS = xclass;
+
+ default_depth = DefaultDepth(dpy,scr);
+ default_class = DefaultVisual(dpy,scr)->CLASS;
+
+ if (depth==default_depth && xclass==default_class) {
+ /* try to get root window's visual */
+ temp.visualid = DefaultVisual(dpy,scr)->visualid;
+ mask |= VisualIDMask;
+ }
+
+ vis = XGetVisualInfo( dpy, mask, &temp, &n );
+
+ /* In case bits/pixel > 24, make sure color channels are still <=8 bits.
+ * An SGI Infinite Reality system, for example, can have 30bpp pixels:
+ * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel.
+ */
+ if (vis && depth > 24 && (xclass==TrueColor || xclass==DirectColor)) {
+ 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 {
+ XFree((void *) vis);
+ return NULL;
+ }
+ }
+
+ return vis;
+}
+
+
+
+/*
+ * Retrieve the value of the given environment variable and find
+ * the X visual which matches it.
+ * Input: dpy - the display
+ * screen - the screen number
+ * varname - the name of the environment variable
+ * Return: an XVisualInfo pointer to NULL if error.
+ */
+static XVisualInfo *
+get_env_visual(Display *dpy, int scr, const char *varname)
+{
+ char value[100], type[100];
+ int depth, xclass = -1;
+ XVisualInfo *vis;
+
+ if (!_mesa_getenv( varname )) {
+ return NULL;
+ }
+
+ _mesa_strncpy( value, _mesa_getenv(varname), 100 );
+ value[99] = 0;
+
+ sscanf( value, "%s %d", type, &depth );
+
+ if (_mesa_strcmp(type,"TrueColor")==0) xclass = TrueColor;
+ else if (_mesa_strcmp(type,"DirectColor")==0) xclass = DirectColor;
+ else if (_mesa_strcmp(type,"PseudoColor")==0) xclass = PseudoColor;
+ else if (_mesa_strcmp(type,"StaticColor")==0) xclass = StaticColor;
+ else if (_mesa_strcmp(type,"GrayScale")==0) xclass = GrayScale;
+ else if (_mesa_strcmp(type,"StaticGray")==0) xclass = StaticGray;
+
+ if (xclass>-1 && depth>0) {
+ vis = get_visual( dpy, scr, depth, xclass );
+ if (vis) {
+ return vis;
+ }
+ }
+
+ _mesa_warning(NULL, "GLX unable to find visual class=%s, depth=%d.",
+ type, depth);
+
+ return NULL;
+}
+
+
+
+/*
+ * Select an X visual which satisfies the RGBA/CI flag and minimum depth.
+ * Input: dpy, screen - X display and screen number
+ * rgba - GL_TRUE = RGBA mode, GL_FALSE = CI mode
+ * min_depth - minimum visual depth
+ * preferred_class - preferred GLX visual class or DONT_CARE
+ * Return: pointer to an XVisualInfo or NULL.
+ */
+static XVisualInfo *
+choose_x_visual( Display *dpy, int screen, GLboolean rgba, int min_depth,
+ int preferred_class )
+{
+ XVisualInfo *vis;
+ int xclass, visclass = 0;
+ int depth;
+
+ if (rgba) {
+ Atom hp_cr_maps = XInternAtom(dpy, "_HP_RGB_SMOOTH_MAP_LIST", True);
+ /* First see if the MESA_RGB_VISUAL env var is defined */
+ vis = get_env_visual( dpy, screen, "MESA_RGB_VISUAL" );
+ if (vis) {
+ return vis;
+ }
+ /* Otherwise, search for a suitable visual */
+ if (preferred_class==DONT_CARE) {
+ for (xclass=0;xclass<6;xclass++) {
+ switch (xclass) {
+ case 0: visclass = TrueColor; break;
+ case 1: visclass = DirectColor; break;
+ case 2: visclass = PseudoColor; break;
+ case 3: visclass = StaticColor; break;
+ case 4: visclass = GrayScale; break;
+ case 5: visclass = StaticGray; break;
+ }
+ if (min_depth==0) {
+ /* start with shallowest */
+ for (depth=0;depth<=32;depth++) {
+ if (visclass==TrueColor && depth==8 && !hp_cr_maps) {
+ /* Special case: try to get 8-bit PseudoColor before */
+ /* 8-bit TrueColor */
+ vis = get_visual( dpy, screen, 8, PseudoColor );
+ if (vis) {
+ return vis;
+ }
+ }
+ vis = get_visual( dpy, screen, depth, visclass );
+ if (vis) {
+ return vis;
+ }
+ }
+ }
+ else {
+ /* start with deepest */
+ for (depth=32;depth>=min_depth;depth--) {
+ if (visclass==TrueColor && depth==8 && !hp_cr_maps) {
+ /* Special case: try to get 8-bit PseudoColor before */
+ /* 8-bit TrueColor */
+ vis = get_visual( dpy, screen, 8, PseudoColor );
+ if (vis) {
+ return vis;
+ }
+ }
+ vis = get_visual( dpy, screen, depth, visclass );
+ if (vis) {
+ return vis;
+ }
+ }
+ }
+ }
+ }
+ else {
+ /* search for a specific visual class */
+ switch (preferred_class) {
+ case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break;
+ case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break;
+ case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break;
+ case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break;
+ case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break;
+ case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break;
+ default: return NULL;
+ }
+ if (min_depth==0) {
+ /* start with shallowest */
+ for (depth=0;depth<=32;depth++) {
+ vis = get_visual( dpy, screen, depth, visclass );
+ if (vis) {
+ return vis;
+ }
+ }
+ }
+ else {
+ /* start with deepest */
+ for (depth=32;depth>=min_depth;depth--) {
+ vis = get_visual( dpy, screen, depth, visclass );
+ if (vis) {
+ return vis;
+ }
+ }
+ }
+ }
+ }
+ else {
+ /* First see if the MESA_CI_VISUAL env var is defined */
+ vis = get_env_visual( dpy, screen, "MESA_CI_VISUAL" );
+ if (vis) {
+ return vis;
+ }
+ /* Otherwise, search for a suitable visual, starting with shallowest */
+ if (preferred_class==DONT_CARE) {
+ for (xclass=0;xclass<4;xclass++) {
+ switch (xclass) {
+ case 0: visclass = PseudoColor; break;
+ case 1: visclass = StaticColor; break;
+ case 2: visclass = GrayScale; break;
+ case 3: visclass = StaticGray; break;
+ }
+ /* try 8-bit up through 16-bit */
+ for (depth=8;depth<=16;depth++) {
+ vis = get_visual( dpy, screen, depth, visclass );
+ if (vis) {
+ return vis;
+ }
+ }
+ /* try min_depth up to 8-bit */
+ for (depth=min_depth;depth<8;depth++) {
+ vis = get_visual( dpy, screen, depth, visclass );
+ if (vis) {
+ return vis;
+ }
+ }
+ }
+ }
+ else {
+ /* search for a specific visual class */
+ switch (preferred_class) {
+ case GLX_TRUE_COLOR_EXT: visclass = TrueColor; break;
+ case GLX_DIRECT_COLOR_EXT: visclass = DirectColor; break;
+ case GLX_PSEUDO_COLOR_EXT: visclass = PseudoColor; break;
+ case GLX_STATIC_COLOR_EXT: visclass = StaticColor; break;
+ case GLX_GRAY_SCALE_EXT: visclass = GrayScale; break;
+ case GLX_STATIC_GRAY_EXT: visclass = StaticGray; break;
+ default: return NULL;
+ }
+ /* try 8-bit up through 16-bit */
+ for (depth=8;depth<=16;depth++) {
+ vis = get_visual( dpy, screen, depth, visclass );
+ if (vis) {
+ return vis;
+ }
+ }
+ /* try min_depth up to 8-bit */
+ for (depth=min_depth;depth<8;depth++) {
+ vis = get_visual( dpy, screen, depth, visclass );
+ if (vis) {
+ return vis;
+ }
+ }
+ }
+ }
+
+ /* didn't find a visual */
+ return NULL;
+}
+
+
+
+/*
+ * Find the deepest X over/underlay visual of at least min_depth.
+ * Input: dpy, screen - X display and screen number
+ * level - the over/underlay level
+ * trans_type - transparent pixel type: GLX_NONE_EXT,
+ * GLX_TRANSPARENT_RGB_EXT, GLX_TRANSPARENT_INDEX_EXT,
+ * or DONT_CARE
+ * trans_value - transparent pixel value or DONT_CARE
+ * min_depth - minimum visual depth
+ * preferred_class - preferred GLX visual class or DONT_CARE
+ * Return: pointer to an XVisualInfo or NULL.
+ */
+static XVisualInfo *
+choose_x_overlay_visual( Display *dpy, int scr, GLboolean rgbFlag,
+ int level, int trans_type, int trans_value,
+ int min_depth, int preferred_class )
+{
+ OverlayInfo *overlay_info;
+ int numOverlaysPerScreen;
+ int i;
+ XVisualInfo *deepvis;
+ int deepest;
+
+ /*DEBUG int tt, tv; */
+
+ switch (preferred_class) {
+ case GLX_TRUE_COLOR_EXT: preferred_class = TrueColor; break;
+ case GLX_DIRECT_COLOR_EXT: preferred_class = DirectColor; break;
+ case GLX_PSEUDO_COLOR_EXT: preferred_class = PseudoColor; break;
+ case GLX_STATIC_COLOR_EXT: preferred_class = StaticColor; break;
+ case GLX_GRAY_SCALE_EXT: preferred_class = GrayScale; break;
+ case GLX_STATIC_GRAY_EXT: preferred_class = StaticGray; break;
+ default: preferred_class = DONT_CARE;
+ }
+
+ overlay_info = GetOverlayInfo(dpy, scr, &numOverlaysPerScreen);
+ if (!overlay_info) {
+ return NULL;
+ }
+
+ /* Search for the deepest overlay which satisifies all criteria. */
+ deepest = min_depth;
+ deepvis = NULL;
+
+ for (i = 0; i < numOverlaysPerScreen; i++) {
+ const OverlayInfo *ov = overlay_info + i;
+ XVisualInfo *vislist, vistemplate;
+ int count;
+
+ if (ov->layer!=level) {
+ /* failed overlay level criteria */
+ continue;
+ }
+ if (!(trans_type==DONT_CARE
+ || (trans_type==GLX_TRANSPARENT_INDEX_EXT
+ && ov->transparent_type>0)
+ || (trans_type==GLX_NONE_EXT && ov->transparent_type==0))) {
+ /* failed transparent pixel type criteria */
+ continue;
+ }
+ if (trans_value!=DONT_CARE && trans_value!=ov->value) {
+ /* failed transparent pixel value criteria */
+ continue;
+ }
+
+ /* get XVisualInfo and check the depth */
+ vistemplate.visualid = ov->overlay_visual;
+ vistemplate.screen = scr;
+ vislist = XGetVisualInfo( dpy, VisualIDMask | VisualScreenMask,
+ &vistemplate, &count );
+
+ if (count!=1) {
+ /* something went wrong */
+ continue;
+ }
+ if (preferred_class!=DONT_CARE && preferred_class!=vislist->CLASS) {
+ /* wrong visual class */
+ continue;
+ }
+
+ /* if RGB was requested, make sure we have True/DirectColor */
+ if (rgbFlag && vislist->CLASS != TrueColor
+ && vislist->CLASS != DirectColor)
+ continue;
+
+ /* if CI was requested, make sure we have a color indexed visual */
+ if (!rgbFlag
+ && (vislist->CLASS == TrueColor || vislist->CLASS == DirectColor))
+ continue;
+
+ if (deepvis==NULL || vislist->depth > deepest) {
+ /* YES! found a satisfactory visual */
+ if (deepvis) {
+ XFree( deepvis );
+ }
+ deepest = vislist->depth;
+ deepvis = vislist;
+ /* DEBUG tt = ov->transparent_type;*/
+ /* DEBUG tv = ov->value; */
+ }
+ }
+
+/*DEBUG
+ if (deepvis) {
+ printf("chose 0x%x: layer=%d depth=%d trans_type=%d trans_value=%d\n",
+ deepvis->visualid, level, deepvis->depth, tt, tv );
+ }
+*/
+ return deepvis;
+}
+
+
+/**********************************************************************/
+/*** Begin Fake GLX API Functions ***/
+/**********************************************************************/
+
+
+/**
+ * Helper used by glXChooseVisual and glXChooseFBConfig.
+ * The fbConfig parameter must be GL_FALSE for the former and GL_TRUE for
+ * the later.
+ * In either case, the attribute list is terminated with the value 'None'.
+ */
+static XMesaVisual
+choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig )
+{
+ const GLboolean rgbModeDefault = fbConfig;
+ const int *parselist;
+ XVisualInfo *vis;
+ int min_ci = 0;
+ int min_red=0, min_green=0, min_blue=0;
+ GLboolean rgb_flag = rgbModeDefault;
+ GLboolean alpha_flag = GL_FALSE;
+ GLboolean double_flag = GL_FALSE;
+ GLboolean stereo_flag = GL_FALSE;
+ GLint depth_size = 0;
+ GLint stencil_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;
+ XMesaVisual xmvis = NULL;
+ int desiredVisualID = -1;
+ int numAux = 0;
+
+ parselist = list;
+
+ while (*parselist) {
+
+ switch (*parselist) {
+ case GLX_USE_GL:
+ if (fbConfig) {
+ /* invalid token */
+ return NULL;
+ }
+ else {
+ /* skip */
+ parselist++;
+ }
+ break;
+ case GLX_BUFFER_SIZE:
+ parselist++;
+ min_ci = *parselist++;
+ break;
+ case GLX_LEVEL:
+ parselist++;
+ level = *parselist++;
+ break;
+ case GLX_RGBA:
+ if (fbConfig) {
+ /* invalid token */
+ return NULL;
+ }
+ else {
+ rgb_flag = GL_TRUE;
+ parselist++;
+ }
+ break;
+ case GLX_DOUBLEBUFFER:
+ parselist++;
+ if (fbConfig) {
+ double_flag = *parselist++;
+ }
+ else {
+ double_flag = GL_TRUE;
+ }
+ break;
+ case GLX_STEREO:
+ parselist++;
+ if (fbConfig) {
+ stereo_flag = *parselist++;
+ }
+ else {
+ stereo_flag = GL_TRUE;
+ }
+ return NULL; /* stereo not supported */
+ case GLX_AUX_BUFFERS:
+ parselist++;
+ numAux = *parselist++;
+ if (numAux > MAX_AUX_BUFFERS)
+ return NULL;
+ break;
+ case GLX_RED_SIZE:
+ parselist++;
+ min_red = *parselist++;
+ break;
+ case GLX_GREEN_SIZE:
+ parselist++;
+ min_green = *parselist++;
+ break;
+ case GLX_BLUE_SIZE:
+ parselist++;
+ min_blue = *parselist++;
+ break;
+ case GLX_ALPHA_SIZE:
+ parselist++;
+ {
+ GLint size = *parselist++;
+ alpha_flag = size>0 ? 1 : 0;
+ }
+ break;
+ case GLX_DEPTH_SIZE:
+ parselist++;
+ depth_size = *parselist++;
+ break;
+ case GLX_STENCIL_SIZE:
+ parselist++;
+ 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++;
+ accumAlphaSize = MAX2( accumAlphaSize, size );
+ }
+ break;
+
+ /*
+ * GLX_EXT_visual_info extension
+ */
+ case GLX_X_VISUAL_TYPE_EXT:
+ parselist++;
+ visual_type = *parselist++;
+ break;
+ case GLX_TRANSPARENT_TYPE_EXT:
+ parselist++;
+ trans_type = *parselist++;
+ break;
+ case GLX_TRANSPARENT_INDEX_VALUE_EXT:
+ parselist++;
+ trans_value = *parselist++;
+ break;
+ case GLX_TRANSPARENT_RED_VALUE_EXT:
+ case GLX_TRANSPARENT_GREEN_VALUE_EXT:
+ case GLX_TRANSPARENT_BLUE_VALUE_EXT:
+ case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
+ /* ignore */
+ parselist++;
+ parselist++;
+ break;
+
+ /*
+ * GLX_EXT_visual_info extension
+ */
+ case GLX_VISUAL_CAVEAT_EXT:
+ parselist++;
+ caveat = *parselist++; /* ignored for now */
+ break;
+
+ /*
+ * GLX_ARB_multisample
+ */
+ case GLX_SAMPLE_BUFFERS_ARB:
+ /* ms not supported */
+ return NULL;
+ case GLX_SAMPLES_ARB:
+ /* ms not supported */
+ return NULL;
+
+ /*
+ * FBConfig attribs.
+ */
+ case GLX_RENDER_TYPE:
+ if (!fbConfig)
+ return NULL;
+ parselist++;
+ if (*parselist == GLX_RGBA_BIT) {
+ rgb_flag = GL_TRUE;
+ }
+ else if (*parselist == GLX_COLOR_INDEX_BIT) {
+ rgb_flag = GL_FALSE;
+ }
+ else if (*parselist == 0) {
+ rgb_flag = GL_TRUE;
+ }
+ parselist++;
+ break;
+ case GLX_DRAWABLE_TYPE:
+ if (!fbConfig)
+ return NULL;
+ parselist++;
+ if (*parselist & ~(GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT)) {
+ return NULL; /* bad bit */
+ }
+ parselist++;
+ break;
+ case GLX_FBCONFIG_ID:
+ if (!fbConfig)
+ return NULL;
+ parselist++;
+ desiredVisualID = *parselist++;
+ break;
+ case GLX_X_RENDERABLE:
+ if (!fbConfig)
+ return NULL;
+ parselist += 2;
+ /* ignore */
+ break;
+
+ case None:
+ /* end of list */
+ break;
+
+ default:
+ /* undefined attribute */
+ _mesa_warning(NULL, "unexpected attrib 0x%x in choose_visual()",
+ *parselist);
+ return NULL;
+ }
+ }
+
+ (void) caveat;
+
+ /*
+ * Since we're only simulating the GLX extension this function will never
+ * find any real GL visuals. Instead, all we can do is try to find an RGB
+ * or CI visual of appropriate depth. Other requested attributes such as
+ * double buffering, depth buffer, etc. will be associated with the X
+ * visual and stored in the VisualTable[].
+ */
+ if (desiredVisualID != -1) {
+ /* try to get a specific visual, by visualID */
+ XVisualInfo temp;
+ int n;
+ temp.visualid = desiredVisualID;
+ temp.screen = screen;
+ vis = XGetVisualInfo(dpy, VisualIDMask | VisualScreenMask, &temp, &n);
+ if (vis) {
+ /* give the visual some useful GLX attributes */
+ double_flag = GL_TRUE;
+ if (vis->depth > 8)
+ rgb_flag = GL_TRUE;
+ depth_size = default_depth_bits();
+ stencil_size = STENCIL_BITS;
+ /* XXX accum??? */
+ }
+ }
+ else if (level==0) {
+ /* normal color planes */
+ if (rgb_flag) {
+ /* Get an RGB visual */
+ int min_rgb = min_red + min_green + min_blue;
+ if (min_rgb>1 && min_rgb<8) {
+ /* a special case to be sure we can get a monochrome visual */
+ min_rgb = 1;
+ }
+ vis = choose_x_visual( dpy, screen, rgb_flag, min_rgb, visual_type );
+ }
+ else {
+ /* Get a color index visual */
+ vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type );
+ accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0;
+ }
+ }
+ else {
+ /* over/underlay planes */
+ if (rgb_flag) {
+ /* rgba overlay */
+ int min_rgb = min_red + min_green + min_blue;
+ if (min_rgb>1 && min_rgb<8) {
+ /* a special case to be sure we can get a monochrome visual */
+ min_rgb = 1;
+ }
+ vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
+ trans_type, trans_value, min_rgb, visual_type );
+ }
+ else {
+ /* color index overlay */
+ vis = choose_x_overlay_visual( dpy, screen, rgb_flag, level,
+ trans_type, trans_value, min_ci, visual_type );
+ }
+ }
+
+ 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. Instead, we
+ * return 16 to maintain performance with earlier versions of Mesa.
+ */
+ if (depth_size > 24)
+ depth_size = 31; /* 32 causes int overflow problems */
+ else if (depth_size > 16)
+ depth_size = 24;
+ else if (depth_size > 0) {
+ depth_size = default_depth_bits();
+ }
+
+ /* we only support one size of stencil and accum buffers. */
+ if (stencil_size > 0)
+ stencil_size = STENCIL_BITS;
+ if (accumRedSize > 0 || accumGreenSize > 0 || accumBlueSize > 0 ||
+ accumAlphaSize > 0) {
+ accumRedSize = ACCUM_BITS;
+ accumGreenSize = ACCUM_BITS;
+ accumBlueSize = ACCUM_BITS;
+ accumAlphaSize = alpha_flag ? ACCUM_BITS : 0;
+ }
+
+ xmvis = save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag,
+ stereo_flag, depth_size, stencil_size,
+ accumRedSize, accumGreenSize,
+ accumBlueSize, accumAlphaSize, level, numAux );
+ }
+
+ return xmvis;
+}
+
+
+static XVisualInfo *
+Fake_glXChooseVisual( Display *dpy, int screen, int *list )
+{
+ XMesaVisual xmvis = choose_visual(dpy, screen, list, GL_FALSE);
+ if (xmvis) {
+#if 0
+ return xmvis->vishandle;
+#else
+ /* create a new vishandle - the cached one may be stale */
+ xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo));
+ if (xmvis->vishandle) {
+ _mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));
+ }
+ return xmvis->vishandle;
+#endif
+ }
+ else
+ return NULL;
+}
+
+
+static GLXContext
+Fake_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
+ GLXContext share_list, Bool direct )
+{
+ XMesaVisual xmvis;
+ struct fake_glx_context *glxCtx;
+ struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list;
+
+ if (!dpy || !visinfo)
+ return 0;
+
+ glxCtx = CALLOC_STRUCT(fake_glx_context);
+ if (!glxCtx)
+ return 0;
+
+ /* deallocate unused windows/buffers */
+ XMesaGarbageCollect();
+
+ xmvis = find_glx_visual( dpy, visinfo );
+ if (!xmvis) {
+ /* This visual wasn't found with glXChooseVisual() */
+ xmvis = create_glx_visual( dpy, visinfo );
+ if (!xmvis) {
+ /* unusable visual */
+ FREE(glxCtx);
+ return NULL;
+ }
+ }
+
+ glxCtx->xmesaContext = XMesaCreateContext(xmvis,
+ shareCtx ? shareCtx->xmesaContext : NULL);
+ if (!glxCtx->xmesaContext) {
+ FREE(glxCtx);
+ return NULL;
+ }
+
+ glxCtx->xmesaContext->direct = GL_FALSE;
+ glxCtx->glxContext.isDirect = GL_FALSE;
+ glxCtx->glxContext.currentDpy = dpy;
+ glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */
+
+ assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
+
+ return (GLXContext) glxCtx;
+}
+
+
+/* XXX these may have to be removed due to thread-safety issues. */
+static GLXContext MakeCurrent_PrevContext = 0;
+static GLXDrawable MakeCurrent_PrevDrawable = 0;
+static GLXDrawable MakeCurrent_PrevReadable = 0;
+static XMesaBuffer MakeCurrent_PrevDrawBuffer = 0;
+static XMesaBuffer MakeCurrent_PrevReadBuffer = 0;
+
+
+/* GLX 1.3 and later */
+static Bool
+Fake_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
+ GLXDrawable read, GLXContext ctx )
+{
+ struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
+
+ if (ctx && draw && read) {
+ XMesaBuffer drawBuffer, readBuffer;
+ XMesaContext xmctx = glxCtx->xmesaContext;
+
+ /* Find the XMesaBuffer which corresponds to the GLXDrawable 'draw' */
+ if (ctx == MakeCurrent_PrevContext
+ && draw == MakeCurrent_PrevDrawable) {
+ drawBuffer = MakeCurrent_PrevDrawBuffer;
+ }
+ else {
+ drawBuffer = XMesaFindBuffer( dpy, draw );
+ }
+ if (!drawBuffer) {
+ /* drawable must be a new window! */
+ drawBuffer = XMesaCreateWindowBuffer2( xmctx->xm_visual, draw, xmctx);
+ if (!drawBuffer) {
+ /* Out of memory, or context/drawable depth mismatch */
+ return False;
+ }
+ }
+
+ /* Find the XMesaBuffer which corresponds to the GLXDrawable 'read' */
+ if (ctx == MakeCurrent_PrevContext
+ && read == MakeCurrent_PrevReadable) {
+ readBuffer = MakeCurrent_PrevReadBuffer;
+ }
+ else {
+ readBuffer = XMesaFindBuffer( dpy, read );
+ }
+ if (!readBuffer) {
+ /* drawable must be a new window! */
+ readBuffer = XMesaCreateWindowBuffer2(glxCtx->xmesaContext->xm_visual,
+ read, xmctx);
+ if (!readBuffer) {
+ /* Out of memory, or context/drawable depth mismatch */
+ return False;
+ }
+ }
+
+ MakeCurrent_PrevContext = ctx;
+ MakeCurrent_PrevDrawable = draw;
+ MakeCurrent_PrevReadable = read;
+ MakeCurrent_PrevDrawBuffer = drawBuffer;
+ MakeCurrent_PrevReadBuffer = readBuffer;
+
+ /* Now make current! */
+ if (XMesaMakeCurrent2(xmctx, drawBuffer, readBuffer)) {
+ ((__GLXcontext *) ctx)->currentDpy = dpy;
+ ((__GLXcontext *) ctx)->currentDrawable = draw;
+ ((__GLXcontext *) ctx)->currentReadable = read;
+ return True;
+ }
+ else {
+ return False;
+ }
+ }
+ else if (!ctx && !draw && !read) {
+ /* release current context w/out assigning new one. */
+ XMesaMakeCurrent( NULL, NULL );
+ MakeCurrent_PrevContext = 0;
+ MakeCurrent_PrevDrawable = 0;
+ MakeCurrent_PrevReadable = 0;
+ MakeCurrent_PrevDrawBuffer = 0;
+ MakeCurrent_PrevReadBuffer = 0;
+ return True;
+ }
+ else {
+ /* The args must either all be non-zero or all zero.
+ * This is an error.
+ */
+ return False;
+ }
+}
+
+
+static Bool
+Fake_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx )
+{
+ return Fake_glXMakeContextCurrent( dpy, drawable, drawable, ctx );
+}
+
+
+static GLXPixmap
+Fake_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap )
+{
+ XMesaVisual v;
+ XMesaBuffer b;
+
+ v = find_glx_visual( dpy, visinfo );
+ if (!v) {
+ v = create_glx_visual( dpy, visinfo );
+ if (!v) {
+ /* unusable visual */
+ return 0;
+ }
+ }
+
+ b = XMesaCreatePixmapBuffer( v, pixmap, 0 );
+ if (!b) {
+ return 0;
+ }
+ return b->frontxrb->pixmap;
+}
+
+
+/*** GLX_MESA_pixmap_colormap ***/
+
+static GLXPixmap
+Fake_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
+ Pixmap pixmap, Colormap cmap )
+{
+ XMesaVisual v;
+ XMesaBuffer b;
+
+ v = find_glx_visual( dpy, visinfo );
+ if (!v) {
+ v = create_glx_visual( dpy, visinfo );
+ if (!v) {
+ /* unusable visual */
+ return 0;
+ }
+ }
+
+ b = XMesaCreatePixmapBuffer( v, pixmap, cmap );
+ if (!b) {
+ return 0;
+ }
+ return b->frontxrb->pixmap;
+}
+
+
+static void
+Fake_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap )
+{
+ XMesaBuffer b = XMesaFindBuffer(dpy, pixmap);
+ if (b) {
+ XMesaDestroyBuffer(b);
+ }
+ else if (_mesa_getenv("MESA_DEBUG")) {
+ _mesa_warning(NULL, "Mesa: glXDestroyGLXPixmap: invalid pixmap\n");
+ }
+}
+
+
+static void
+Fake_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
+ unsigned long mask )
+{
+ struct fake_glx_context *fakeSrc = (struct fake_glx_context *) src;
+ struct fake_glx_context *fakeDst = (struct fake_glx_context *) dst;
+ XMesaContext xm_src = fakeSrc->xmesaContext;
+ XMesaContext xm_dst = fakeDst->xmesaContext;
+ (void) dpy;
+ _mesa_copy_context( &(xm_src->mesa), &(xm_dst->mesa), (GLuint) mask );
+}
+
+
+static Bool
+Fake_glXQueryExtension( Display *dpy, int *errorb, int *event )
+{
+ /* Mesa's GLX isn't really an X extension but we try to act like one. */
+ (void) dpy;
+ (void) errorb;
+ (void) event;
+ return True;
+}
+
+
+extern void _kw_ungrab_all( Display *dpy );
+void _kw_ungrab_all( Display *dpy )
+{
+ XUngrabPointer( dpy, CurrentTime );
+ XUngrabKeyboard( dpy, CurrentTime );
+}
+
+
+static void
+Fake_glXDestroyContext( Display *dpy, GLXContext ctx )
+{
+ struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
+ (void) dpy;
+ MakeCurrent_PrevContext = 0;
+ MakeCurrent_PrevDrawable = 0;
+ MakeCurrent_PrevReadable = 0;
+ MakeCurrent_PrevDrawBuffer = 0;
+ MakeCurrent_PrevReadBuffer = 0;
+ XMesaDestroyContext( glxCtx->xmesaContext );
+ XMesaGarbageCollect();
+}
+
+
+static Bool
+Fake_glXIsDirect( Display *dpy, GLXContext ctx )
+{
+ struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
+ (void) dpy;
+ return glxCtx->xmesaContext->direct;
+}
+
+
+
+static void
+Fake_glXSwapBuffers( Display *dpy, GLXDrawable drawable )
+{
+ XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
+
+ if (buffer) {
+ XMesaSwapBuffers(buffer);
+ }
+ else if (_mesa_getenv("MESA_DEBUG")) {
+ _mesa_warning(NULL, "glXSwapBuffers: invalid drawable 0x%x\n",
+ (int) drawable);
+ }
+}
+
+
+
+/*** GLX_MESA_copy_sub_buffer ***/
+
+static void
+Fake_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
+ int x, int y, int width, int height )
+{
+ XMesaBuffer buffer = XMesaFindBuffer( dpy, drawable );
+ if (buffer) {
+ XMesaCopySubBuffer(buffer, x, y, width, height);
+ }
+ else if (_mesa_getenv("MESA_DEBUG")) {
+ _mesa_warning(NULL, "Mesa: glXCopySubBufferMESA: invalid drawable\n");
+ }
+}
+
+
+static Bool
+Fake_glXQueryVersion( Display *dpy, int *maj, int *min )
+{
+ (void) dpy;
+ /* Return GLX version, not Mesa version */
+ assert(CLIENT_MAJOR_VERSION == SERVER_MAJOR_VERSION);
+ *maj = CLIENT_MAJOR_VERSION;
+ *min = MIN2( CLIENT_MINOR_VERSION, SERVER_MINOR_VERSION );
+ return True;
+}
+
+
+/*
+ * Query the GLX attributes of the given XVisualInfo.
+ */
+static int
+get_config( XMesaVisual xmvis, int attrib, int *value, GLboolean fbconfig )
+{
+ ASSERT(xmvis);
+ switch(attrib) {
+ case GLX_USE_GL:
+ if (fbconfig)
+ return GLX_BAD_ATTRIBUTE;
+ *value = (int) True;
+ return 0;
+ case GLX_BUFFER_SIZE:
+ *value = xmvis->visinfo->depth;
+ return 0;
+ case GLX_LEVEL:
+ *value = xmvis->mesa_visual.level;
+ return 0;
+ case GLX_RGBA:
+ if (fbconfig)
+ return GLX_BAD_ATTRIBUTE;
+ if (xmvis->mesa_visual.rgbMode) {
+ *value = True;
+ }
+ else {
+ *value = False;
+ }
+ return 0;
+ case GLX_DOUBLEBUFFER:
+ *value = (int) xmvis->mesa_visual.doubleBufferMode;
+ return 0;
+ case GLX_STEREO:
+ *value = (int) xmvis->mesa_visual.stereoMode;
+ return 0;
+ case GLX_AUX_BUFFERS:
+ *value = xmvis->mesa_visual.numAuxBuffers;
+ return 0;
+ case GLX_RED_SIZE:
+ *value = xmvis->mesa_visual.redBits;
+ return 0;
+ case GLX_GREEN_SIZE:
+ *value = xmvis->mesa_visual.greenBits;
+ return 0;
+ case GLX_BLUE_SIZE:
+ *value = xmvis->mesa_visual.blueBits;
+ return 0;
+ case GLX_ALPHA_SIZE:
+ *value = xmvis->mesa_visual.alphaBits;
+ return 0;
+ case GLX_DEPTH_SIZE:
+ *value = xmvis->mesa_visual.depthBits;
+ return 0;
+ case GLX_STENCIL_SIZE:
+ *value = xmvis->mesa_visual.stencilBits;
+ return 0;
+ case GLX_ACCUM_RED_SIZE:
+ *value = xmvis->mesa_visual.accumRedBits;
+ return 0;
+ case GLX_ACCUM_GREEN_SIZE:
+ *value = xmvis->mesa_visual.accumGreenBits;
+ return 0;
+ case GLX_ACCUM_BLUE_SIZE:
+ *value = xmvis->mesa_visual.accumBlueBits;
+ return 0;
+ case GLX_ACCUM_ALPHA_SIZE:
+ *value = xmvis->mesa_visual.accumAlphaBits;
+ return 0;
+
+ /*
+ * GLX_EXT_visual_info extension
+ */
+ case GLX_X_VISUAL_TYPE_EXT:
+ switch (xmvis->visinfo->CLASS) {
+ case StaticGray: *value = GLX_STATIC_GRAY_EXT; return 0;
+ case GrayScale: *value = GLX_GRAY_SCALE_EXT; return 0;
+ case StaticColor: *value = GLX_STATIC_GRAY_EXT; return 0;
+ case PseudoColor: *value = GLX_PSEUDO_COLOR_EXT; return 0;
+ case TrueColor: *value = GLX_TRUE_COLOR_EXT; return 0;
+ case DirectColor: *value = GLX_DIRECT_COLOR_EXT; return 0;
+ }
+ return 0;
+ case GLX_TRANSPARENT_TYPE_EXT:
+ if (xmvis->mesa_visual.level==0) {
+ /* normal planes */
+ *value = GLX_NONE_EXT;
+ }
+ else if (xmvis->mesa_visual.level>0) {
+ /* overlay */
+ if (xmvis->mesa_visual.rgbMode) {
+ *value = GLX_TRANSPARENT_RGB_EXT;
+ }
+ else {
+ *value = GLX_TRANSPARENT_INDEX_EXT;
+ }
+ }
+ else if (xmvis->mesa_visual.level<0) {
+ /* underlay */
+ *value = GLX_NONE_EXT;
+ }
+ return 0;
+ case GLX_TRANSPARENT_INDEX_VALUE_EXT:
+ {
+ int pixel = transparent_pixel( xmvis );
+ if (pixel>=0) {
+ *value = pixel;
+ }
+ /* else undefined */
+ }
+ return 0;
+ case GLX_TRANSPARENT_RED_VALUE_EXT:
+ /* undefined */
+ return 0;
+ case GLX_TRANSPARENT_GREEN_VALUE_EXT:
+ /* undefined */
+ return 0;
+ case GLX_TRANSPARENT_BLUE_VALUE_EXT:
+ /* undefined */
+ return 0;
+ case GLX_TRANSPARENT_ALPHA_VALUE_EXT:
+ /* undefined */
+ return 0;
+
+ /*
+ * GLX_EXT_visual_info extension
+ */
+ case GLX_VISUAL_CAVEAT_EXT:
+ /* test for zero, just in case */
+ if (xmvis->mesa_visual.visualRating > 0)
+ *value = xmvis->mesa_visual.visualRating;
+ else
+ *value = GLX_NONE_EXT;
+ return 0;
+
+ /*
+ * GLX_ARB_multisample
+ */
+ case GLX_SAMPLE_BUFFERS_ARB:
+ *value = 0;
+ return 0;
+ case GLX_SAMPLES_ARB:
+ *value = 0;
+ return 0;
+
+ /*
+ * For FBConfigs:
+ */
+ case GLX_SCREEN_EXT:
+ if (!fbconfig)
+ return GLX_BAD_ATTRIBUTE;
+ *value = xmvis->visinfo->screen;
+ break;
+ case GLX_DRAWABLE_TYPE: /*SGIX too */
+ if (!fbconfig)
+ return GLX_BAD_ATTRIBUTE;
+ *value = GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT;
+ break;
+ case GLX_RENDER_TYPE_SGIX:
+ if (!fbconfig)
+ return GLX_BAD_ATTRIBUTE;
+ if (xmvis->mesa_visual.rgbMode)
+ *value = GLX_RGBA_BIT;
+ else
+ *value = GLX_COLOR_INDEX_BIT;
+ break;
+ case GLX_X_RENDERABLE_SGIX:
+ if (!fbconfig)
+ return GLX_BAD_ATTRIBUTE;
+ *value = True; /* XXX really? */
+ break;
+ case GLX_FBCONFIG_ID_SGIX:
+ if (!fbconfig)
+ return GLX_BAD_ATTRIBUTE;
+ *value = xmvis->visinfo->visualid;
+ break;
+ case GLX_MAX_PBUFFER_WIDTH:
+ if (!fbconfig)
+ return GLX_BAD_ATTRIBUTE;
+ /* XXX or MAX_WIDTH? */
+ *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen);
+ break;
+ case GLX_MAX_PBUFFER_HEIGHT:
+ if (!fbconfig)
+ return GLX_BAD_ATTRIBUTE;
+ *value = DisplayHeight(xmvis->display, xmvis->visinfo->screen);
+ break;
+ case GLX_MAX_PBUFFER_PIXELS:
+ if (!fbconfig)
+ return GLX_BAD_ATTRIBUTE;
+ *value = DisplayWidth(xmvis->display, xmvis->visinfo->screen) *
+ DisplayHeight(xmvis->display, xmvis->visinfo->screen);
+ break;
+ case GLX_VISUAL_ID:
+ if (!fbconfig)
+ return GLX_BAD_ATTRIBUTE;
+ *value = xmvis->visinfo->visualid;
+ break;
+
+ default:
+ return GLX_BAD_ATTRIBUTE;
+ }
+ return Success;
+}
+
+
+static int
+Fake_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
+ int attrib, int *value )
+{
+ XMesaVisual xmvis;
+ int k;
+ if (!dpy || !visinfo)
+ return GLX_BAD_ATTRIBUTE;
+
+ xmvis = find_glx_visual( dpy, visinfo );
+ if (!xmvis) {
+ /* this visual wasn't obtained with glXChooseVisual */
+ xmvis = create_glx_visual( dpy, visinfo );
+ if (!xmvis) {
+ /* this visual can't be used for GL rendering */
+ if (attrib==GLX_USE_GL) {
+ *value = (int) False;
+ return 0;
+ }
+ else {
+ return GLX_BAD_VISUAL;
+ }
+ }
+ }
+
+ k = get_config(xmvis, attrib, value, GL_FALSE);
+ return k;
+}
+
+
+static void
+Fake_glXWaitGL( void )
+{
+ XMesaContext xmesa = XMesaGetCurrentContext();
+ XMesaFlush( xmesa );
+}
+
+
+
+static void
+Fake_glXWaitX( void )
+{
+ XMesaContext xmesa = XMesaGetCurrentContext();
+ XMesaFlush( xmesa );
+}
+
+
+static const char *
+get_extensions( void )
+{
+#ifdef FX
+ const char *fx = _mesa_getenv("MESA_GLX_FX");
+ if (fx && fx[0] != 'd') {
+ return EXTENSIONS;
+ }
+#endif
+ return EXTENSIONS + 23; /* skip "GLX_MESA_set_3dfx_mode" */
+}
+
+
+
+/* GLX 1.1 and later */
+static const char *
+Fake_glXQueryExtensionsString( Display *dpy, int screen )
+{
+ (void) dpy;
+ (void) screen;
+ return get_extensions();
+}
+
+
+
+/* GLX 1.1 and later */
+static const char *
+Fake_glXQueryServerString( Display *dpy, int screen, int name )
+{
+ static char version[1000];
+ _mesa_sprintf(version, "%d.%d %s",
+ SERVER_MAJOR_VERSION, SERVER_MINOR_VERSION, MESA_GLX_VERSION);
+
+ (void) dpy;
+ (void) screen;
+
+ switch (name) {
+ case GLX_EXTENSIONS:
+ return get_extensions();
+ case GLX_VENDOR:
+ return VENDOR;
+ case GLX_VERSION:
+ return version;
+ default:
+ return NULL;
+ }
+}
+
+
+
+/* GLX 1.1 and later */
+static const char *
+Fake_glXGetClientString( Display *dpy, int name )
+{
+ static char version[1000];
+ _mesa_sprintf(version, "%d.%d %s", CLIENT_MAJOR_VERSION,
+ CLIENT_MINOR_VERSION, MESA_GLX_VERSION);
+
+ (void) dpy;
+
+ switch (name) {
+ case GLX_EXTENSIONS:
+ return get_extensions();
+ case GLX_VENDOR:
+ return VENDOR;
+ case GLX_VERSION:
+ return version;
+ default:
+ return NULL;
+ }
+}
+
+
+
+/*
+ * GLX 1.3 and later
+ */
+
+
+static int
+Fake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
+ int attribute, int *value )
+{
+ XMesaVisual v = (XMesaVisual) config;
+ (void) dpy;
+ (void) config;
+
+ if (!dpy || !config || !value)
+ return -1;
+
+ return get_config(v, attribute, value, GL_TRUE);
+}
+
+
+static GLXFBConfig *
+Fake_glXGetFBConfigs( Display *dpy, int screen, int *nelements )
+{
+ XVisualInfo *visuals, visTemplate;
+ const long visMask = VisualScreenMask;
+ int i;
+
+ /* Get list of all X visuals */
+ visTemplate.screen = screen;
+ visuals = XGetVisualInfo(dpy, visMask, &visTemplate, nelements);
+ if (*nelements > 0) {
+ XMesaVisual *results;
+ results = (XMesaVisual *) _mesa_malloc(*nelements * sizeof(XMesaVisual));
+ if (!results) {
+ *nelements = 0;
+ return NULL;
+ }
+ for (i = 0; i < *nelements; i++) {
+ results[i] = create_glx_visual(dpy, visuals + i);
+ }
+ return (GLXFBConfig *) results;
+ }
+ return NULL;
+}
+
+
+static GLXFBConfig *
+Fake_glXChooseFBConfig( Display *dpy, int screen,
+ const int *attribList, int *nitems )
+{
+ XMesaVisual xmvis;
+
+ if (!attribList || !attribList[0]) {
+ /* return list of all configs (per GLX_SGIX_fbconfig spec) */
+ return Fake_glXGetFBConfigs(dpy, screen, nitems);
+ }
+
+ xmvis = choose_visual(dpy, screen, attribList, GL_TRUE);
+ if (xmvis) {
+ GLXFBConfig *config = (GLXFBConfig *) _mesa_malloc(sizeof(XMesaVisual));
+ if (!config) {
+ *nitems = 0;
+ return NULL;
+ }
+ *nitems = 1;
+ config[0] = (GLXFBConfig) xmvis;
+ return (GLXFBConfig *) config;
+ }
+ else {
+ *nitems = 0;
+ return NULL;
+ }
+}
+
+
+static XVisualInfo *
+Fake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config )
+{
+ if (dpy && config) {
+ XMesaVisual xmvis = (XMesaVisual) config;
+#if 0
+ return xmvis->vishandle;
+#else
+ /* create a new vishandle - the cached one may be stale */
+ xmvis->vishandle = (XVisualInfo *) _mesa_malloc(sizeof(XVisualInfo));
+ if (xmvis->vishandle) {
+ _mesa_memcpy(xmvis->vishandle, xmvis->visinfo, sizeof(XVisualInfo));
+ }
+ return xmvis->vishandle;
+#endif
+ }
+ else {
+ return NULL;
+ }
+}
+
+
+static GLXWindow
+Fake_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
+ const int *attribList )
+{
+ XMesaVisual xmvis = (XMesaVisual) config;
+ XMesaBuffer xmbuf;
+ if (!xmvis)
+ return 0;
+
+ xmbuf = XMesaCreateWindowBuffer2(xmvis, win, NULL);
+ if (!xmbuf)
+ return 0;
+
+ (void) dpy;
+ (void) attribList; /* Ignored in GLX 1.3 */
+
+ return win; /* A hack for now */
+}
+
+
+static void
+Fake_glXDestroyWindow( Display *dpy, GLXWindow window )
+{
+ XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable) window);
+ if (b)
+ XMesaDestroyBuffer(b);
+ /* don't destroy X window */
+}
+
+
+/* XXX untested */
+static GLXPixmap
+Fake_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
+ const int *attribList )
+{
+ XMesaVisual v = (XMesaVisual) config;
+ XMesaBuffer b;
+
+ (void) dpy;
+ (void) config;
+ (void) pixmap;
+ (void) attribList; /* Ignored in GLX 1.3 */
+
+ if (!dpy || !config || !pixmap)
+ return 0;
+
+ b = XMesaCreatePixmapBuffer( v, pixmap, 0 );
+ if (!b) {
+ return 0;
+ }
+
+ return pixmap;
+}
+
+
+static void
+Fake_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap )
+{
+ XMesaBuffer b = XMesaFindBuffer(dpy, (XMesaDrawable)pixmap);
+ if (b)
+ XMesaDestroyBuffer(b);
+ /* don't destroy X pixmap */
+}
+
+
+static GLXPbuffer
+Fake_glXCreatePbuffer( Display *dpy, GLXFBConfig config,
+ const int *attribList )
+{
+ XMesaVisual xmvis = (XMesaVisual) config;
+ XMesaBuffer xmbuf;
+ const int *attrib;
+ int width = 0, height = 0;
+ GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE;
+
+ (void) dpy;
+
+ for (attrib = attribList; *attrib; attrib++) {
+ switch (*attrib) {
+ case GLX_PBUFFER_WIDTH:
+ attrib++;
+ width = *attrib;
+ break;
+ case GLX_PBUFFER_HEIGHT:
+ attrib++;
+ height = *attrib;
+ break;
+ case GLX_PRESERVED_CONTENTS:
+ attrib++;
+ preserveContents = *attrib; /* ignored */
+ break;
+ case GLX_LARGEST_PBUFFER:
+ attrib++;
+ useLargest = *attrib; /* ignored */
+ break;
+ default:
+ return 0;
+ }
+ }
+
+ /* not used at this time */
+ (void) useLargest;
+ (void) preserveContents;
+
+ if (width == 0 || height == 0)
+ return 0;
+
+ xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height);
+ /* A GLXPbuffer handle must be an X Drawable because that's what
+ * glXMakeCurrent takes.
+ */
+ if (xmbuf)
+ return (GLXPbuffer) xmbuf->frontxrb->pixmap;
+ else
+ return 0;
+}
+
+
+static void
+Fake_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf )
+{
+ XMesaBuffer b = XMesaFindBuffer(dpy, pbuf);
+ if (b) {
+ XMesaDestroyBuffer(b);
+ }
+}
+
+
+static void
+Fake_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
+ unsigned int *value )
+{
+ XMesaBuffer xmbuf = XMesaFindBuffer(dpy, draw);
+ if (!xmbuf)
+ return;
+
+ switch (attribute) {
+ case GLX_WIDTH:
+ *value = xmbuf->mesa_buffer.Width;
+ break;
+ case GLX_HEIGHT:
+ *value = xmbuf->mesa_buffer.Height;
+ break;
+ case GLX_PRESERVED_CONTENTS:
+ *value = True;
+ break;
+ case GLX_LARGEST_PBUFFER:
+ *value = xmbuf->mesa_buffer.Width * xmbuf->mesa_buffer.Height;
+ break;
+ case GLX_FBCONFIG_ID:
+ *value = xmbuf->xm_visual->visinfo->visualid;
+ return;
+ default:
+ return; /* GLX_BAD_ATTRIBUTE? */
+ }
+}
+
+
+static GLXContext
+Fake_glXCreateNewContext( Display *dpy, GLXFBConfig config,
+ int renderType, GLXContext shareList, Bool direct )
+{
+ struct fake_glx_context *glxCtx;
+ struct fake_glx_context *shareCtx = (struct fake_glx_context *) shareList;
+ XMesaVisual xmvis = (XMesaVisual) config;
+
+ if (!dpy || !config ||
+ (renderType != GLX_RGBA_TYPE && renderType != GLX_COLOR_INDEX_TYPE))
+ return 0;
+
+ glxCtx = CALLOC_STRUCT(fake_glx_context);
+ if (!glxCtx)
+ return 0;
+
+ /* deallocate unused windows/buffers */
+ XMesaGarbageCollect();
+
+ glxCtx->xmesaContext = XMesaCreateContext(xmvis,
+ shareCtx ? shareCtx->xmesaContext : NULL);
+ if (!glxCtx->xmesaContext) {
+ FREE(glxCtx);
+ return NULL;
+ }
+
+ glxCtx->xmesaContext->direct = GL_FALSE;
+ glxCtx->glxContext.isDirect = GL_FALSE;
+ glxCtx->glxContext.currentDpy = dpy;
+ glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */
+
+ assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
+
+ return (GLXContext) glxCtx;
+}
+
+
+static int
+Fake_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value )
+{
+ struct fake_glx_context *glxCtx = (struct fake_glx_context *) ctx;
+ XMesaContext xmctx = glxCtx->xmesaContext;
+
+ (void) dpy;
+ (void) ctx;
+
+ switch (attribute) {
+ case GLX_FBCONFIG_ID:
+ *value = xmctx->xm_visual->visinfo->visualid;
+ break;
+ case GLX_RENDER_TYPE:
+ if (xmctx->xm_visual->mesa_visual.rgbMode)
+ *value = GLX_RGBA_BIT;
+ else
+ *value = GLX_COLOR_INDEX_BIT;
+ break;
+ case GLX_SCREEN:
+ *value = 0;
+ return Success;
+ default:
+ return GLX_BAD_ATTRIBUTE;
+ }
+ return 0;
+}
+
+
+static void
+Fake_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask )
+{
+ XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
+ if (xmbuf)
+ xmbuf->selectedEvents = mask;
+}
+
+
+static void
+Fake_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
+ unsigned long *mask )
+{
+ XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
+ if (xmbuf)
+ *mask = xmbuf->selectedEvents;
+ else
+ *mask = 0;
+}
+
+
+
+/*** GLX_SGI_swap_control ***/
+
+static int
+Fake_glXSwapIntervalSGI(int interval)
+{
+ (void) interval;
+ return 0;
+}
+
+
+
+/*** GLX_SGI_video_sync ***/
+
+static int
+Fake_glXGetVideoSyncSGI(unsigned int *count)
+{
+ (void) count;
+ return 0;
+}
+
+static int
+Fake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
+{
+ (void) divisor;
+ (void) remainder;
+ (void) count;
+ return 0;
+}
+
+
+
+/*** GLX_SGI_make_current_read ***/
+
+static Bool
+Fake_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
+{
+ return Fake_glXMakeContextCurrent( dpy, draw, read, ctx );
+}
+
+/* not used
+static GLXDrawable
+Fake_glXGetCurrentReadDrawableSGI(void)
+{
+ return 0;
+}
+*/
+
+
+/*** GLX_SGIX_video_source ***/
+#if defined(_VL_H)
+
+static GLXVideoSourceSGIX
+Fake_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
+{
+ (void) dpy;
+ (void) screen;
+ (void) server;
+ (void) path;
+ (void) nodeClass;
+ (void) drainNode;
+ return 0;
+}
+
+static void
+Fake_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
+{
+ (void) dpy;
+ (void) src;
+}
+
+#endif
+
+
+/*** GLX_EXT_import_context ***/
+
+static void
+Fake_glXFreeContextEXT(Display *dpy, GLXContext context)
+{
+ (void) dpy;
+ (void) context;
+}
+
+static GLXContextID
+Fake_glXGetContextIDEXT(const GLXContext context)
+{
+ (void) context;
+ return 0;
+}
+
+static GLXContext
+Fake_glXImportContextEXT(Display *dpy, GLXContextID contextID)
+{
+ (void) dpy;
+ (void) contextID;
+ return 0;
+}
+
+static int
+Fake_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value)
+{
+ (void) dpy;
+ (void) context;
+ (void) attribute;
+ (void) value;
+ return 0;
+}
+
+
+
+/*** GLX_SGIX_fbconfig ***/
+
+static int
+Fake_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
+{
+ return Fake_glXGetFBConfigAttrib(dpy, config, attribute, value);
+}
+
+static GLXFBConfigSGIX *
+Fake_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements)
+{
+ return (GLXFBConfig *) Fake_glXChooseFBConfig(dpy, screen, attrib_list, nelements);
+}
+
+
+static GLXPixmap
+Fake_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
+{
+ XMesaVisual xmvis = (XMesaVisual) config;
+ XMesaBuffer xmbuf = XMesaCreatePixmapBuffer(xmvis, pixmap, 0);
+ return xmbuf->frontxrb->pixmap; /* need to return an X ID */
+}
+
+
+static GLXContext
+Fake_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
+{
+ XMesaVisual xmvis = (XMesaVisual) config;
+ struct fake_glx_context *glxCtx;
+ struct fake_glx_context *shareCtx = (struct fake_glx_context *) share_list;
+
+ glxCtx = CALLOC_STRUCT(fake_glx_context);
+ if (!glxCtx)
+ return 0;
+
+ /* deallocate unused windows/buffers */
+ XMesaGarbageCollect();
+
+ glxCtx->xmesaContext = XMesaCreateContext(xmvis,
+ shareCtx ? shareCtx->xmesaContext : NULL);
+ if (!glxCtx->xmesaContext) {
+ FREE(glxCtx);
+ return NULL;
+ }
+
+ glxCtx->xmesaContext->direct = GL_FALSE;
+ glxCtx->glxContext.isDirect = GL_FALSE;
+ glxCtx->glxContext.currentDpy = dpy;
+ glxCtx->glxContext.xid = (XID) glxCtx; /* self pointer */
+
+ assert((void *) glxCtx == (void *) &(glxCtx->glxContext));
+
+ return (GLXContext) glxCtx;
+}
+
+
+static XVisualInfo *
+Fake_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config)
+{
+ return Fake_glXGetVisualFromFBConfig(dpy, config);
+}
+
+
+static GLXFBConfigSGIX
+Fake_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
+{
+ XMesaVisual xmvis = find_glx_visual(dpy, vis);
+ if (!xmvis) {
+ /* This visual wasn't found with glXChooseVisual() */
+ xmvis = create_glx_visual(dpy, vis);
+ }
+
+ return (GLXFBConfigSGIX) xmvis;
+}
+
+
+
+/*** GLX_SGIX_pbuffer ***/
+
+static GLXPbufferSGIX
+Fake_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config,
+ unsigned int width, unsigned int height,
+ int *attribList)
+{
+ XMesaVisual xmvis = (XMesaVisual) config;
+ XMesaBuffer xmbuf;
+ const int *attrib;
+ GLboolean useLargest = GL_FALSE, preserveContents = GL_FALSE;
+
+ (void) dpy;
+
+ for (attrib = attribList; attrib && *attrib; attrib++) {
+ switch (*attrib) {
+ case GLX_PRESERVED_CONTENTS_SGIX:
+ attrib++;
+ preserveContents = *attrib; /* ignored */
+ break;
+ case GLX_LARGEST_PBUFFER_SGIX:
+ attrib++;
+ useLargest = *attrib; /* ignored */
+ break;
+ default:
+ return 0;
+ }
+ }
+
+ /* not used at this time */
+ (void) useLargest;
+ (void) preserveContents;
+
+ xmbuf = XMesaCreatePBuffer( xmvis, 0, width, height);
+ /* A GLXPbuffer handle must be an X Drawable because that's what
+ * glXMakeCurrent takes.
+ */
+ return (GLXPbuffer) xmbuf->frontxrb->pixmap;
+}
+
+
+static void
+Fake_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf)
+{
+ XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf);
+ if (xmbuf) {
+ XMesaDestroyBuffer(xmbuf);
+ }
+}
+
+
+static int
+Fake_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
+{
+ const XMesaBuffer xmbuf = XMesaFindBuffer(dpy, pbuf);
+
+ if (!xmbuf) {
+ /* Generate GLXBadPbufferSGIX for bad pbuffer */
+ return 0;
+ }
+
+ switch (attribute) {
+ case GLX_PRESERVED_CONTENTS_SGIX:
+ *value = True;
+ break;
+ case GLX_LARGEST_PBUFFER_SGIX:
+ *value = xmbuf->mesa_buffer.Width * xmbuf->mesa_buffer.Height;
+ break;
+ case GLX_WIDTH_SGIX:
+ *value = xmbuf->mesa_buffer.Width;
+ break;
+ case GLX_HEIGHT_SGIX:
+ *value = xmbuf->mesa_buffer.Height;
+ break;
+ case GLX_EVENT_MASK_SGIX:
+ *value = 0; /* XXX might be wrong */
+ break;
+ default:
+ *value = 0;
+ }
+ return 0;
+}
+
+
+static void
+Fake_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask)
+{
+ XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
+ if (xmbuf) {
+ /* Note: we'll never generate clobber events */
+ xmbuf->selectedEvents = mask;
+ }
+}
+
+
+static void
+Fake_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask)
+{
+ XMesaBuffer xmbuf = XMesaFindBuffer(dpy, drawable);
+ if (xmbuf) {
+ *mask = xmbuf->selectedEvents;
+ }
+ else {
+ *mask = 0;
+ }
+}
+
+
+
+/*** GLX_SGI_cushion ***/
+
+static void
+Fake_glXCushionSGI(Display *dpy, Window win, float cushion)
+{
+ (void) dpy;
+ (void) win;
+ (void) cushion;
+}
+
+
+
+/*** GLX_SGIX_video_resize ***/
+
+static int
+Fake_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) window;
+ return 0;
+}
+
+static int
+Fake_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) x;
+ (void) y;
+ (void) w;
+ (void) h;
+ return 0;
+}
+
+static int
+Fake_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) x;
+ (void) y;
+ (void) w;
+ (void) h;
+ return 0;
+}
+
+static int
+Fake_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) dx;
+ (void) dy;
+ (void) dw;
+ (void) dh;
+ return 0;
+}
+
+static int
+Fake_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype)
+{
+ (void) dpy;
+ (void) screen;
+ (void) channel;
+ (void) synctype;
+ return 0;
+}
+
+
+
+/*** GLX_SGIX_dmbuffer **/
+
+#if defined(_DM_BUFFER_H_)
+static Bool
+Fake_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
+{
+ (void) dpy;
+ (void) pbuffer;
+ (void) params;
+ (void) dmbuffer;
+ return False;
+}
+#endif
+
+
+/*** GLX_SGIX_swap_group ***/
+
+static void
+Fake_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member)
+{
+ (void) dpy;
+ (void) drawable;
+ (void) member;
+}
+
+
+
+/*** GLX_SGIX_swap_barrier ***/
+
+static void
+Fake_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier)
+{
+ (void) dpy;
+ (void) drawable;
+ (void) barrier;
+}
+
+static Bool
+Fake_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
+{
+ (void) dpy;
+ (void) screen;
+ (void) max;
+ return False;
+}
+
+
+
+/*** GLX_SUN_get_transparent_index ***/
+
+static Status
+Fake_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent)
+{
+ (void) dpy;
+ (void) overlay;
+ (void) underlay;
+ (void) pTransparent;
+ return 0;
+}
+
+
+
+/*** GLX_MESA_release_buffers ***/
+
+/*
+ * Release the depth, stencil, accum buffers attached to a GLXDrawable
+ * (a window or pixmap) prior to destroying the GLXDrawable.
+ */
+static Bool
+Fake_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d )
+{
+ XMesaBuffer b = XMesaFindBuffer(dpy, d);
+ if (b) {
+ XMesaDestroyBuffer(b);
+ return True;
+ }
+ return False;
+}
+
+
+
+/*** GLX_MESA_set_3dfx_mode ***/
+
+static Bool
+Fake_glXSet3DfxModeMESA( int mode )
+{
+ return XMesaSetFXmode( mode );
+}
+
+
+
+/*** GLX_NV_vertex_array range ***/
+static void *
+Fake_glXAllocateMemoryNV( GLsizei size,
+ GLfloat readFrequency,
+ GLfloat writeFrequency,
+ GLfloat priority )
+{
+ (void) size;
+ (void) readFrequency;
+ (void) writeFrequency;
+ (void) priority;
+ return NULL;
+}
+
+
+static void
+Fake_glXFreeMemoryNV( GLvoid *pointer )
+{
+ (void) pointer;
+}
+
+
+/*** GLX_MESA_agp_offset ***/
+
+static GLuint
+Fake_glXGetAGPOffsetMESA( const GLvoid *pointer )
+{
+ (void) pointer;
+ return ~0;
+}
+
+
+/* silence warning */
+extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
+
+
+/**
+ * Create a new GLX API dispatch table with its function pointers
+ * initialized to point to Mesa's "fake" GLX API functions.
+ * Note: there's a similar function (_real_GetGLXDispatchTable) that
+ * returns a new dispatch table with all pointers initalized to point
+ * to "real" GLX functions (which understand GLX wire protocol, etc).
+ */
+struct _glxapi_table *
+_mesa_GetGLXDispatchTable(void)
+{
+ static struct _glxapi_table glx;
+
+ /* be sure our dispatch table size <= libGL's table */
+ {
+ GLuint size = sizeof(struct _glxapi_table) / sizeof(void *);
+ (void) size;
+ assert(_glxapi_get_dispatch_table_size() >= size);
+ }
+
+ /* initialize the whole table to no-ops */
+ _glxapi_set_no_op_table(&glx);
+
+ /* now initialize the table with the functions I implement */
+ glx.ChooseVisual = Fake_glXChooseVisual;
+ glx.CopyContext = Fake_glXCopyContext;
+ glx.CreateContext = Fake_glXCreateContext;
+ glx.CreateGLXPixmap = Fake_glXCreateGLXPixmap;
+ glx.DestroyContext = Fake_glXDestroyContext;
+ glx.DestroyGLXPixmap = Fake_glXDestroyGLXPixmap;
+ glx.GetConfig = Fake_glXGetConfig;
+ /*glx.GetCurrentContext = Fake_glXGetCurrentContext;*/
+ /*glx.GetCurrentDrawable = Fake_glXGetCurrentDrawable;*/
+ glx.IsDirect = Fake_glXIsDirect;
+ glx.MakeCurrent = Fake_glXMakeCurrent;
+ glx.QueryExtension = Fake_glXQueryExtension;
+ glx.QueryVersion = Fake_glXQueryVersion;
+ glx.SwapBuffers = Fake_glXSwapBuffers;
+ glx.UseXFont = Fake_glXUseXFont;
+ glx.WaitGL = Fake_glXWaitGL;
+ glx.WaitX = Fake_glXWaitX;
+
+ /*** GLX_VERSION_1_1 ***/
+ glx.GetClientString = Fake_glXGetClientString;
+ glx.QueryExtensionsString = Fake_glXQueryExtensionsString;
+ glx.QueryServerString = Fake_glXQueryServerString;
+
+ /*** GLX_VERSION_1_2 ***/
+ /*glx.GetCurrentDisplay = Fake_glXGetCurrentDisplay;*/
+
+ /*** GLX_VERSION_1_3 ***/
+ glx.ChooseFBConfig = Fake_glXChooseFBConfig;
+ glx.CreateNewContext = Fake_glXCreateNewContext;
+ glx.CreatePbuffer = Fake_glXCreatePbuffer;
+ glx.CreatePixmap = Fake_glXCreatePixmap;
+ glx.CreateWindow = Fake_glXCreateWindow;
+ glx.DestroyPbuffer = Fake_glXDestroyPbuffer;
+ glx.DestroyPixmap = Fake_glXDestroyPixmap;
+ 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;
+ glx.QueryContext = Fake_glXQueryContext;
+ glx.QueryDrawable = Fake_glXQueryDrawable;
+ glx.SelectEvent = Fake_glXSelectEvent;
+
+ /*** GLX_SGI_swap_control ***/
+ glx.SwapIntervalSGI = Fake_glXSwapIntervalSGI;
+
+ /*** GLX_SGI_video_sync ***/
+ glx.GetVideoSyncSGI = Fake_glXGetVideoSyncSGI;
+ glx.WaitVideoSyncSGI = Fake_glXWaitVideoSyncSGI;
+
+ /*** GLX_SGI_make_current_read ***/
+ glx.MakeCurrentReadSGI = Fake_glXMakeCurrentReadSGI;
+ /*glx.GetCurrentReadDrawableSGI = Fake_glXGetCurrentReadDrawableSGI;*/
+
+/*** GLX_SGIX_video_source ***/
+#if defined(_VL_H)
+ glx.CreateGLXVideoSourceSGIX = Fake_glXCreateGLXVideoSourceSGIX;
+ glx.DestroyGLXVideoSourceSGIX = Fake_glXDestroyGLXVideoSourceSGIX;
+#endif
+
+ /*** GLX_EXT_import_context ***/
+ glx.FreeContextEXT = Fake_glXFreeContextEXT;
+ glx.GetContextIDEXT = Fake_glXGetContextIDEXT;
+ /*glx.GetCurrentDisplayEXT = Fake_glXGetCurrentDisplayEXT;*/
+ glx.ImportContextEXT = Fake_glXImportContextEXT;
+ glx.QueryContextInfoEXT = Fake_glXQueryContextInfoEXT;
+
+ /*** GLX_SGIX_fbconfig ***/
+ glx.GetFBConfigAttribSGIX = Fake_glXGetFBConfigAttribSGIX;
+ glx.ChooseFBConfigSGIX = Fake_glXChooseFBConfigSGIX;
+ glx.CreateGLXPixmapWithConfigSGIX = Fake_glXCreateGLXPixmapWithConfigSGIX;
+ glx.CreateContextWithConfigSGIX = Fake_glXCreateContextWithConfigSGIX;
+ glx.GetVisualFromFBConfigSGIX = Fake_glXGetVisualFromFBConfigSGIX;
+ glx.GetFBConfigFromVisualSGIX = Fake_glXGetFBConfigFromVisualSGIX;
+
+ /*** GLX_SGIX_pbuffer ***/
+ glx.CreateGLXPbufferSGIX = Fake_glXCreateGLXPbufferSGIX;
+ glx.DestroyGLXPbufferSGIX = Fake_glXDestroyGLXPbufferSGIX;
+ glx.QueryGLXPbufferSGIX = Fake_glXQueryGLXPbufferSGIX;
+ glx.SelectEventSGIX = Fake_glXSelectEventSGIX;
+ glx.GetSelectedEventSGIX = Fake_glXGetSelectedEventSGIX;
+
+ /*** GLX_SGI_cushion ***/
+ glx.CushionSGI = Fake_glXCushionSGI;
+
+ /*** GLX_SGIX_video_resize ***/
+ glx.BindChannelToWindowSGIX = Fake_glXBindChannelToWindowSGIX;
+ glx.ChannelRectSGIX = Fake_glXChannelRectSGIX;
+ glx.QueryChannelRectSGIX = Fake_glXQueryChannelRectSGIX;
+ glx.QueryChannelDeltasSGIX = Fake_glXQueryChannelDeltasSGIX;
+ glx.ChannelRectSyncSGIX = Fake_glXChannelRectSyncSGIX;
+
+ /*** GLX_SGIX_dmbuffer **/
+#if defined(_DM_BUFFER_H_)
+ glx.AssociateDMPbufferSGIX = NULL;
+#endif
+
+ /*** GLX_SGIX_swap_group ***/
+ glx.JoinSwapGroupSGIX = Fake_glXJoinSwapGroupSGIX;
+
+ /*** GLX_SGIX_swap_barrier ***/
+ glx.BindSwapBarrierSGIX = Fake_glXBindSwapBarrierSGIX;
+ glx.QueryMaxSwapBarriersSGIX = Fake_glXQueryMaxSwapBarriersSGIX;
+
+ /*** GLX_SUN_get_transparent_index ***/
+ glx.GetTransparentIndexSUN = Fake_glXGetTransparentIndexSUN;
+
+ /*** GLX_MESA_copy_sub_buffer ***/
+ glx.CopySubBufferMESA = Fake_glXCopySubBufferMESA;
+
+ /*** GLX_MESA_release_buffers ***/
+ glx.ReleaseBuffersMESA = Fake_glXReleaseBuffersMESA;
+
+ /*** GLX_MESA_pixmap_colormap ***/
+ glx.CreateGLXPixmapMESA = Fake_glXCreateGLXPixmapMESA;
+
+ /*** GLX_MESA_set_3dfx_mode ***/
+ glx.Set3DfxModeMESA = Fake_glXSet3DfxModeMESA;
+
+ /*** GLX_NV_vertex_array_range ***/
+ glx.AllocateMemoryNV = Fake_glXAllocateMemoryNV;
+ glx.FreeMemoryNV = Fake_glXFreeMemoryNV;
+
+ /*** GLX_MESA_agp_offset ***/
+ glx.GetAGPOffsetMESA = Fake_glXGetAGPOffsetMESA;
+
+ return &glx;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/x11/glxapi.c b/nx-X11/extras/Mesa/src/mesa/drivers/x11/glxapi.c
new file mode 100644
index 000000000..69af99730
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/x11/glxapi.c
@@ -0,0 +1,1348 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/*
+ * This is the GLX API dispatcher. Calls to the glX* functions are
+ * either routed to the real GLX encoders or to Mesa's pseudo-GLX functions.
+ * See the glxapi.h file for more details.
+ */
+
+
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "glheader.h"
+#include "glapi.h"
+#include "glxapi.h"
+
+
+extern struct _glxapi_table *_real_GetGLXDispatchTable(void);
+extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void);
+
+
+struct display_dispatch {
+ Display *Dpy;
+ struct _glxapi_table *Table;
+ struct display_dispatch *Next;
+};
+
+static struct display_dispatch *DispatchList = NULL;
+
+
+/* Display -> Dispatch caching */
+static Display *prevDisplay = NULL;
+static struct _glxapi_table *prevTable = NULL;
+
+
+static struct _glxapi_table *
+get_dispatch(Display *dpy)
+{
+ if (!dpy)
+ return NULL;
+
+ /* search list of display/dispatch pairs for this display */
+ {
+ const struct display_dispatch *d = DispatchList;
+ while (d) {
+ if (d->Dpy == dpy) {
+ prevDisplay = dpy;
+ prevTable = d->Table;
+ return d->Table; /* done! */
+ }
+ d = d->Next;
+ }
+ }
+
+ /* A new display, determine if we should use real GLX
+ * or Mesa's pseudo-GLX.
+ */
+ {
+ struct _glxapi_table *t = _mesa_GetGLXDispatchTable();
+
+ if (t) {
+ struct display_dispatch *d;
+ d = (struct display_dispatch *) malloc(sizeof(struct display_dispatch));
+ if (d) {
+ d->Dpy = dpy;
+ d->Table = t;
+ /* insert at head of list */
+ d->Next = DispatchList;
+ DispatchList = d;
+ /* update cache */
+ prevDisplay = dpy;
+ prevTable = t;
+ return t;
+ }
+ }
+ }
+
+ /* If we get here that means we can't use real GLX on this display
+ * and the Mesa pseudo-GLX software renderer wasn't compiled in.
+ * Or, we ran out of memory!
+ */
+ return NULL;
+}
+
+
+#define GET_DISPATCH(DPY, TABLE) \
+ if (DPY == prevDisplay) { \
+ TABLE = prevTable; \
+ } \
+ else if (!DPY) { \
+ TABLE = NULL; \
+ } \
+ else { \
+ TABLE = get_dispatch(DPY); \
+ }
+
+
+
+
+/* Set by glXMakeCurrent() and glXMakeContextCurrent() only */
+static GLXContext CurrentContext = 0;
+#define __glXGetCurrentContext() CurrentContext;
+
+
+/*
+ * GLX API entrypoints
+ */
+
+/*** GLX_VERSION_1_0 ***/
+
+XVisualInfo PUBLIC *
+glXChooseVisual(Display *dpy, int screen, int *list)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return NULL;
+ return (t->ChooseVisual)(dpy, screen, list);
+}
+
+
+void PUBLIC
+glXCopyContext(Display *dpy, GLXContext src, GLXContext dst, unsigned long mask)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->CopyContext)(dpy, src, dst, mask);
+}
+
+
+GLXContext PUBLIC
+glXCreateContext(Display *dpy, XVisualInfo *visinfo, GLXContext shareList, Bool direct)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->CreateContext)(dpy, visinfo, shareList, direct);
+}
+
+
+GLXPixmap PUBLIC
+glXCreateGLXPixmap(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->CreateGLXPixmap)(dpy, visinfo, pixmap);
+}
+
+
+void PUBLIC
+glXDestroyContext(Display *dpy, GLXContext ctx)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->DestroyContext)(dpy, ctx);
+}
+
+
+void PUBLIC
+glXDestroyGLXPixmap(Display *dpy, GLXPixmap pixmap)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->DestroyGLXPixmap)(dpy, pixmap);
+}
+
+
+int PUBLIC
+glXGetConfig(Display *dpy, XVisualInfo *visinfo, int attrib, int *value)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return GLX_NO_EXTENSION;
+ return (t->GetConfig)(dpy, visinfo, attrib, value);
+}
+
+
+GLXContext PUBLIC
+glXGetCurrentContext(void)
+{
+ return CurrentContext;
+}
+
+
+GLXDrawable PUBLIC
+glXGetCurrentDrawable(void)
+{
+ __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
+ return gc ? gc->currentDrawable : 0;
+}
+
+
+Bool PUBLIC
+glXIsDirect(Display *dpy, GLXContext ctx)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return False;
+ return (t->IsDirect)(dpy, ctx);
+}
+
+
+Bool PUBLIC
+glXMakeCurrent(Display *dpy, GLXDrawable drawable, GLXContext ctx)
+{
+ Bool b;
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t) {
+ return False;
+ }
+ b = (*t->MakeCurrent)(dpy, drawable, ctx);
+ if (b) {
+ CurrentContext = ctx;
+ }
+ return b;
+}
+
+
+Bool PUBLIC
+glXQueryExtension(Display *dpy, int *errorb, int *event)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return False;
+ return (t->QueryExtension)(dpy, errorb, event);
+}
+
+
+Bool PUBLIC
+glXQueryVersion(Display *dpy, int *maj, int *min)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return False;
+ return (t->QueryVersion)(dpy, maj, min);
+}
+
+
+void PUBLIC
+glXSwapBuffers(Display *dpy, GLXDrawable drawable)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->SwapBuffers)(dpy, drawable);
+}
+
+
+void PUBLIC
+glXUseXFont(Font font, int first, int count, int listBase)
+{
+ struct _glxapi_table *t;
+ Display *dpy = glXGetCurrentDisplay();
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->UseXFont)(font, first, count, listBase);
+}
+
+
+void PUBLIC
+glXWaitGL(void)
+{
+ struct _glxapi_table *t;
+ Display *dpy = glXGetCurrentDisplay();
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->WaitGL)();
+}
+
+
+void PUBLIC
+glXWaitX(void)
+{
+ struct _glxapi_table *t;
+ Display *dpy = glXGetCurrentDisplay();
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->WaitX)();
+}
+
+
+
+/*** GLX_VERSION_1_1 ***/
+
+const char PUBLIC *
+glXGetClientString(Display *dpy, int name)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return NULL;
+ return (t->GetClientString)(dpy, name);
+}
+
+
+const char PUBLIC *
+glXQueryExtensionsString(Display *dpy, int screen)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return NULL;
+ return (t->QueryExtensionsString)(dpy, screen);
+}
+
+
+const char PUBLIC *
+glXQueryServerString(Display *dpy, int screen, int name)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return NULL;
+ return (t->QueryServerString)(dpy, screen, name);
+}
+
+
+/*** GLX_VERSION_1_2 ***/
+
+Display PUBLIC *
+glXGetCurrentDisplay(void)
+{
+ /* Same code as in libGL's glxext.c */
+ __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
+ if (NULL == gc) return NULL;
+ return gc->currentDpy;
+}
+
+
+
+/*** GLX_VERSION_1_3 ***/
+
+GLXFBConfig PUBLIC *
+glXChooseFBConfig(Display *dpy, int screen, const int *attribList, int *nitems)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->ChooseFBConfig)(dpy, screen, attribList, nitems);
+}
+
+
+GLXContext PUBLIC
+glXCreateNewContext(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->CreateNewContext)(dpy, config, renderType, shareList, direct);
+}
+
+
+GLXPbuffer PUBLIC
+glXCreatePbuffer(Display *dpy, GLXFBConfig config, const int *attribList)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->CreatePbuffer)(dpy, config, attribList);
+}
+
+
+GLXPixmap PUBLIC
+glXCreatePixmap(Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attribList)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->CreatePixmap)(dpy, config, pixmap, attribList);
+}
+
+
+GLXWindow PUBLIC
+glXCreateWindow(Display *dpy, GLXFBConfig config, Window win, const int *attribList)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->CreateWindow)(dpy, config, win, attribList);
+}
+
+
+void PUBLIC
+glXDestroyPbuffer(Display *dpy, GLXPbuffer pbuf)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->DestroyPbuffer)(dpy, pbuf);
+}
+
+
+void PUBLIC
+glXDestroyPixmap(Display *dpy, GLXPixmap pixmap)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->DestroyPixmap)(dpy, pixmap);
+}
+
+
+void PUBLIC
+glXDestroyWindow(Display *dpy, GLXWindow window)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->DestroyWindow)(dpy, window);
+}
+
+
+GLXDrawable PUBLIC
+glXGetCurrentReadDrawable(void)
+{
+ __GLXcontext *gc = (__GLXcontext *) glXGetCurrentContext();
+ return gc ? gc->currentReadable : 0;
+}
+
+
+int PUBLIC
+glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config, int attribute, int *value)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return GLX_NO_EXTENSION;
+ return (t->GetFBConfigAttrib)(dpy, config, attribute, value);
+}
+
+
+GLXFBConfig PUBLIC *
+glXGetFBConfigs(Display *dpy, int screen, int *nelements)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->GetFBConfigs)(dpy, screen, nelements);
+}
+
+void PUBLIC
+glXGetSelectedEvent(Display *dpy, GLXDrawable drawable, unsigned long *mask)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->GetSelectedEvent)(dpy, drawable, mask);
+}
+
+
+XVisualInfo PUBLIC *
+glXGetVisualFromFBConfig(Display *dpy, GLXFBConfig config)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return NULL;
+ return (t->GetVisualFromFBConfig)(dpy, config);
+}
+
+
+Bool PUBLIC
+glXMakeContextCurrent(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
+{
+ Bool b;
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return False;
+ b = (t->MakeContextCurrent)(dpy, draw, read, ctx);
+ if (b) {
+ CurrentContext = ctx;
+ }
+ return b;
+}
+
+
+int PUBLIC
+glXQueryContext(Display *dpy, GLXContext ctx, int attribute, int *value)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ assert(t);
+ if (!t)
+ return 0; /* XXX correct? */
+ return (t->QueryContext)(dpy, ctx, attribute, value);
+}
+
+
+void PUBLIC
+glXQueryDrawable(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->QueryDrawable)(dpy, draw, attribute, value);
+}
+
+
+void PUBLIC
+glXSelectEvent(Display *dpy, GLXDrawable drawable, unsigned long mask)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->SelectEvent)(dpy, drawable, mask);
+}
+
+
+
+/*** GLX_SGI_swap_control ***/
+
+int PUBLIC
+glXSwapIntervalSGI(int interval)
+{
+ struct _glxapi_table *t;
+ Display *dpy = glXGetCurrentDisplay();
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->SwapIntervalSGI)(interval);
+}
+
+
+
+/*** GLX_SGI_video_sync ***/
+
+int PUBLIC
+glXGetVideoSyncSGI(unsigned int *count)
+{
+ struct _glxapi_table *t;
+ Display *dpy = glXGetCurrentDisplay();
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->GetVideoSyncSGI)(count);
+}
+
+int PUBLIC
+glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count)
+{
+ struct _glxapi_table *t;
+ Display *dpy = glXGetCurrentDisplay();
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->WaitVideoSyncSGI)(divisor, remainder, count);
+}
+
+
+
+/*** GLX_SGI_make_current_read ***/
+
+Bool PUBLIC
+glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->MakeCurrentReadSGI)(dpy, draw, read, ctx);
+}
+
+GLXDrawable PUBLIC
+glXGetCurrentReadDrawableSGI(void)
+{
+ return glXGetCurrentReadDrawable();
+}
+
+
+#if defined(_VL_H)
+
+GLXVideoSourceSGIX PUBLIC
+glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->CreateGLXVideoSourceSGIX)(dpy, screen, server, path, nodeClass, drainNode);
+}
+
+void PUBLIC
+glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->DestroyGLXVideoSourceSGIX)(dpy, src);
+}
+
+#endif
+
+
+/*** GLX_EXT_import_context ***/
+
+void PUBLIC
+glXFreeContextEXT(Display *dpy, GLXContext context)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->FreeContextEXT)(dpy, context);
+}
+
+GLXContextID PUBLIC
+glXGetContextIDEXT(const GLXContext context)
+{
+ return ((__GLXcontext *) context)->xid;
+}
+
+Display PUBLIC *
+glXGetCurrentDisplayEXT(void)
+{
+ return glXGetCurrentDisplay();
+}
+
+GLXContext PUBLIC
+glXImportContextEXT(Display *dpy, GLXContextID contextID)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->ImportContextEXT)(dpy, contextID);
+}
+
+int PUBLIC
+glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute,int *value)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0; /* XXX ok? */
+ return (t->QueryContextInfoEXT)(dpy, context, attribute, value);
+}
+
+
+
+/*** GLX_SGIX_fbconfig ***/
+
+int PUBLIC
+glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->GetFBConfigAttribSGIX)(dpy, config, attribute, value);
+}
+
+GLXFBConfigSGIX PUBLIC *
+glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->ChooseFBConfigSGIX)(dpy, screen, attrib_list, nelements);
+}
+
+GLXPixmap PUBLIC
+glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->CreateGLXPixmapWithConfigSGIX)(dpy, config, pixmap);
+}
+
+GLXContext PUBLIC
+glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->CreateContextWithConfigSGIX)(dpy, config, render_type, share_list, direct);
+}
+
+XVisualInfo PUBLIC *
+glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->GetVisualFromFBConfigSGIX)(dpy, config);
+}
+
+GLXFBConfigSGIX PUBLIC
+glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->GetFBConfigFromVisualSGIX)(dpy, vis);
+}
+
+
+
+/*** GLX_SGIX_pbuffer ***/
+
+GLXPbufferSGIX PUBLIC
+glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->CreateGLXPbufferSGIX)(dpy, config, width, height, attrib_list);
+}
+
+void PUBLIC
+glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->DestroyGLXPbufferSGIX)(dpy, pbuf);
+}
+
+int PUBLIC
+glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->QueryGLXPbufferSGIX)(dpy, pbuf, attribute, value);
+}
+
+void PUBLIC
+glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->SelectEventSGIX)(dpy, drawable, mask);
+}
+
+void PUBLIC
+glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->GetSelectedEventSGIX)(dpy, drawable, mask);
+}
+
+
+
+/*** GLX_SGI_cushion ***/
+
+void PUBLIC
+glXCushionSGI(Display *dpy, Window win, float cushion)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->CushionSGI)(dpy, win, cushion);
+}
+
+
+
+/*** GLX_SGIX_video_resize ***/
+
+int PUBLIC
+glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->BindChannelToWindowSGIX)(dpy, screen, channel, window);
+}
+
+int PUBLIC
+glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->ChannelRectSGIX)(dpy, screen, channel, x, y, w, h);
+}
+
+int PUBLIC
+glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->QueryChannelRectSGIX)(dpy, screen, channel, x, y, w, h);
+}
+
+int PUBLIC
+glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->QueryChannelDeltasSGIX)(dpy, screen, channel, dx, dy, dw, dh);
+}
+
+int PUBLIC
+glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->ChannelRectSyncSGIX)(dpy, screen, channel, synctype);
+}
+
+
+
+#if defined(_DM_BUFFER_H_)
+
+Bool PUBLIC
+glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return False;
+ return (t->AssociateDMPbufferSGIX)(dpy, pbuffer, params, dmbuffer);
+}
+
+#endif
+
+
+/*** GLX_SGIX_swap_group ***/
+
+void PUBLIC
+glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (*t->JoinSwapGroupSGIX)(dpy, drawable, member);
+}
+
+
+/*** GLX_SGIX_swap_barrier ***/
+
+void PUBLIC
+glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (*t->BindSwapBarrierSGIX)(dpy, drawable, barrier);
+}
+
+Bool PUBLIC
+glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return False;
+ return (*t->QueryMaxSwapBarriersSGIX)(dpy, screen, max);
+}
+
+
+
+/*** GLX_SUN_get_transparent_index ***/
+
+Status PUBLIC
+glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return False;
+ return (*t->GetTransparentIndexSUN)(dpy, overlay, underlay, pTransparent);
+}
+
+
+
+/*** GLX_MESA_copy_sub_buffer ***/
+
+void PUBLIC
+glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable, int x, int y, int width, int height)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->CopySubBufferMESA)(dpy, drawable, x, y, width, height);
+}
+
+
+
+/*** GLX_MESA_release_buffers ***/
+
+Bool PUBLIC
+glXReleaseBuffersMESA(Display *dpy, Window w)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return False;
+ return (t->ReleaseBuffersMESA)(dpy, w);
+}
+
+
+
+/*** GLX_MESA_pixmap_colormap ***/
+
+GLXPixmap PUBLIC
+glXCreateGLXPixmapMESA(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap, Colormap cmap)
+{
+ struct _glxapi_table *t;
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return 0;
+ return (t->CreateGLXPixmapMESA)(dpy, visinfo, pixmap, cmap);
+}
+
+
+
+/*** GLX_MESA_set_3dfx_mode ***/
+
+Bool PUBLIC
+glXSet3DfxModeMESA(int mode)
+{
+ struct _glxapi_table *t;
+ Display *dpy = glXGetCurrentDisplay();
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return False;
+ return (t->Set3DfxModeMESA)(mode);
+}
+
+
+
+/*** GLX_NV_vertex_array_range ***/
+
+void PUBLIC *
+glXAllocateMemoryNV( GLsizei size,
+ GLfloat readFrequency,
+ GLfloat writeFrequency,
+ GLfloat priority )
+{
+ struct _glxapi_table *t;
+ Display *dpy = glXGetCurrentDisplay();
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return NULL;
+ return (t->AllocateMemoryNV)(size, readFrequency, writeFrequency, priority);
+}
+
+
+void PUBLIC
+glXFreeMemoryNV( GLvoid *pointer )
+{
+ struct _glxapi_table *t;
+ Display *dpy = glXGetCurrentDisplay();
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return;
+ (t->FreeMemoryNV)(pointer);
+}
+
+
+
+
+/*** GLX_MESA_agp_offset */
+
+GLuint PUBLIC
+glXGetAGPOffsetMESA( const GLvoid *pointer )
+{
+ struct _glxapi_table *t;
+ Display *dpy = glXGetCurrentDisplay();
+ GET_DISPATCH(dpy, t);
+ if (!t)
+ return ~0;
+ return (t->GetAGPOffsetMESA)(pointer);
+}
+
+
+/*** GLX_MESA_allocate_memory */
+
+void *
+glXAllocateMemoryMESA(Display *dpy, int scrn, size_t size,
+ float readfreq, float writefreq, float priority)
+{
+ /* dummy */
+ return NULL;
+}
+
+void
+glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer)
+{
+ /* dummy */
+}
+
+
+GLuint
+glXGetMemoryOffsetMESA(Display *dpy, int scrn, const void *pointer)
+{
+ /* dummy */
+ return 0;
+}
+
+
+
+/**********************************************************************/
+/* GLX API management functions */
+/**********************************************************************/
+
+
+const char *
+_glxapi_get_version(void)
+{
+ return "1.3";
+}
+
+
+/*
+ * Return array of extension strings.
+ */
+const char **
+_glxapi_get_extensions(void)
+{
+ static const char *extensions[] = {
+#ifdef GLX_EXT_import_context
+ "GLX_EXT_import_context",
+#endif
+#ifdef GLX_SGI_video_sync
+ "GLX_SGI_video_sync",
+#endif
+#ifdef GLX_MESA_copy_sub_buffer
+ "GLX_MESA_copy_sub_buffer",
+#endif
+#ifdef GLX_MESA_release_buffers
+ "GLX_MESA_release_buffers",
+#endif
+#ifdef GLX_MESA_pixmap_colormap
+ "GLX_MESA_pixmap_colormap",
+#endif
+#ifdef GLX_MESA_set_3dfx_mode
+ "GLX_MESA_set_3dfx_mode",
+#endif
+#ifdef GLX_SGIX_fbconfig
+ "GLX_SGIX_fbconfig",
+#endif
+#ifdef GLX_SGIX_pbuffer
+ "GLX_SGIX_pbuffer",
+#endif
+ NULL
+ };
+ return extensions;
+}
+
+
+/*
+ * Return size of the GLX dispatch table, in entries, not bytes.
+ */
+GLuint
+_glxapi_get_dispatch_table_size(void)
+{
+ return sizeof(struct _glxapi_table) / sizeof(void *);
+}
+
+
+static int
+generic_no_op_func(void)
+{
+ return 0;
+}
+
+
+/*
+ * Initialize all functions in given dispatch table to be no-ops
+ */
+void
+_glxapi_set_no_op_table(struct _glxapi_table *t)
+{
+ typedef int (*nop_func)(void);
+ nop_func *dispatch = (nop_func *) t;
+ GLuint n = _glxapi_get_dispatch_table_size();
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dispatch[i] = generic_no_op_func;
+ }
+}
+
+
+struct name_address_pair {
+ const char *Name;
+ __GLXextFuncPtr Address;
+};
+
+static struct name_address_pair GLX_functions[] = {
+ /*** GLX_VERSION_1_0 ***/
+ { "glXChooseVisual", (__GLXextFuncPtr) glXChooseVisual },
+ { "glXCopyContext", (__GLXextFuncPtr) glXCopyContext },
+ { "glXCreateContext", (__GLXextFuncPtr) glXCreateContext },
+ { "glXCreateGLXPixmap", (__GLXextFuncPtr) glXCreateGLXPixmap },
+ { "glXDestroyContext", (__GLXextFuncPtr) glXDestroyContext },
+ { "glXDestroyGLXPixmap", (__GLXextFuncPtr) glXDestroyGLXPixmap },
+ { "glXGetConfig", (__GLXextFuncPtr) glXGetConfig },
+ { "glXGetCurrentContext", (__GLXextFuncPtr) glXGetCurrentContext },
+ { "glXGetCurrentDrawable", (__GLXextFuncPtr) glXGetCurrentDrawable },
+ { "glXIsDirect", (__GLXextFuncPtr) glXIsDirect },
+ { "glXMakeCurrent", (__GLXextFuncPtr) glXMakeCurrent },
+ { "glXQueryExtension", (__GLXextFuncPtr) glXQueryExtension },
+ { "glXQueryVersion", (__GLXextFuncPtr) glXQueryVersion },
+ { "glXSwapBuffers", (__GLXextFuncPtr) glXSwapBuffers },
+ { "glXUseXFont", (__GLXextFuncPtr) glXUseXFont },
+ { "glXWaitGL", (__GLXextFuncPtr) glXWaitGL },
+ { "glXWaitX", (__GLXextFuncPtr) glXWaitX },
+
+ /*** GLX_VERSION_1_1 ***/
+ { "glXGetClientString", (__GLXextFuncPtr) glXGetClientString },
+ { "glXQueryExtensionsString", (__GLXextFuncPtr) glXQueryExtensionsString },
+ { "glXQueryServerString", (__GLXextFuncPtr) glXQueryServerString },
+
+ /*** GLX_VERSION_1_2 ***/
+ { "glXGetCurrentDisplay", (__GLXextFuncPtr) glXGetCurrentDisplay },
+
+ /*** GLX_VERSION_1_3 ***/
+ { "glXChooseFBConfig", (__GLXextFuncPtr) glXChooseFBConfig },
+ { "glXCreateNewContext", (__GLXextFuncPtr) glXCreateNewContext },
+ { "glXCreatePbuffer", (__GLXextFuncPtr) glXCreatePbuffer },
+ { "glXCreatePixmap", (__GLXextFuncPtr) glXCreatePixmap },
+ { "glXCreateWindow", (__GLXextFuncPtr) glXCreateWindow },
+ { "glXDestroyPbuffer", (__GLXextFuncPtr) glXDestroyPbuffer },
+ { "glXDestroyPixmap", (__GLXextFuncPtr) glXDestroyPixmap },
+ { "glXDestroyWindow", (__GLXextFuncPtr) glXDestroyWindow },
+ { "glXGetCurrentReadDrawable", (__GLXextFuncPtr) glXGetCurrentReadDrawable },
+ { "glXGetFBConfigAttrib", (__GLXextFuncPtr) glXGetFBConfigAttrib },
+ { "glXGetFBConfigs", (__GLXextFuncPtr) glXGetFBConfigs },
+ { "glXGetSelectedEvent", (__GLXextFuncPtr) glXGetSelectedEvent },
+ { "glXGetVisualFromFBConfig", (__GLXextFuncPtr) glXGetVisualFromFBConfig },
+ { "glXMakeContextCurrent", (__GLXextFuncPtr) glXMakeContextCurrent },
+ { "glXQueryContext", (__GLXextFuncPtr) glXQueryContext },
+ { "glXQueryDrawable", (__GLXextFuncPtr) glXQueryDrawable },
+ { "glXSelectEvent", (__GLXextFuncPtr) glXSelectEvent },
+
+ /*** GLX_VERSION_1_4 ***/
+ { "glXGetProcAddress", (__GLXextFuncPtr) glXGetProcAddress },
+
+ /*** GLX_SGI_swap_control ***/
+ { "glXSwapIntervalSGI", (__GLXextFuncPtr) glXSwapIntervalSGI },
+
+ /*** GLX_SGI_video_sync ***/
+ { "glXGetVideoSyncSGI", (__GLXextFuncPtr) glXGetVideoSyncSGI },
+ { "glXWaitVideoSyncSGI", (__GLXextFuncPtr) glXWaitVideoSyncSGI },
+
+ /*** GLX_SGI_make_current_read ***/
+ { "glXMakeCurrentReadSGI", (__GLXextFuncPtr) glXMakeCurrentReadSGI },
+ { "glXGetCurrentReadDrawableSGI", (__GLXextFuncPtr) glXGetCurrentReadDrawableSGI },
+
+ /*** GLX_SGIX_video_source ***/
+#if defined(_VL_H)
+ { "glXCreateGLXVideoSourceSGIX", (__GLXextFuncPtr) glXCreateGLXVideoSourceSGIX },
+ { "glXDestroyGLXVideoSourceSGIX", (__GLXextFuncPtr) glXDestroyGLXVideoSourceSGIX },
+#endif
+
+ /*** GLX_EXT_import_context ***/
+ { "glXFreeContextEXT", (__GLXextFuncPtr) glXFreeContextEXT },
+ { "glXGetContextIDEXT", (__GLXextFuncPtr) glXGetContextIDEXT },
+ { "glXGetCurrentDisplayEXT", (__GLXextFuncPtr) glXGetCurrentDisplayEXT },
+ { "glXImportContextEXT", (__GLXextFuncPtr) glXImportContextEXT },
+ { "glXQueryContextInfoEXT", (__GLXextFuncPtr) glXQueryContextInfoEXT },
+
+ /*** GLX_SGIX_fbconfig ***/
+ { "glXGetFBConfigAttribSGIX", (__GLXextFuncPtr) glXGetFBConfigAttribSGIX },
+ { "glXChooseFBConfigSGIX", (__GLXextFuncPtr) glXChooseFBConfigSGIX },
+ { "glXCreateGLXPixmapWithConfigSGIX", (__GLXextFuncPtr) glXCreateGLXPixmapWithConfigSGIX },
+ { "glXCreateContextWithConfigSGIX", (__GLXextFuncPtr) glXCreateContextWithConfigSGIX },
+ { "glXGetVisualFromFBConfigSGIX", (__GLXextFuncPtr) glXGetVisualFromFBConfigSGIX },
+ { "glXGetFBConfigFromVisualSGIX", (__GLXextFuncPtr) glXGetFBConfigFromVisualSGIX },
+
+ /*** GLX_SGIX_pbuffer ***/
+ { "glXCreateGLXPbufferSGIX", (__GLXextFuncPtr) glXCreateGLXPbufferSGIX },
+ { "glXDestroyGLXPbufferSGIX", (__GLXextFuncPtr) glXDestroyGLXPbufferSGIX },
+ { "glXQueryGLXPbufferSGIX", (__GLXextFuncPtr) glXQueryGLXPbufferSGIX },
+ { "glXSelectEventSGIX", (__GLXextFuncPtr) glXSelectEventSGIX },
+ { "glXGetSelectedEventSGIX", (__GLXextFuncPtr) glXGetSelectedEventSGIX },
+
+ /*** GLX_SGI_cushion ***/
+ { "glXCushionSGI", (__GLXextFuncPtr) glXCushionSGI },
+
+ /*** GLX_SGIX_video_resize ***/
+ { "glXBindChannelToWindowSGIX", (__GLXextFuncPtr) glXBindChannelToWindowSGIX },
+ { "glXChannelRectSGIX", (__GLXextFuncPtr) glXChannelRectSGIX },
+ { "glXQueryChannelRectSGIX", (__GLXextFuncPtr) glXQueryChannelRectSGIX },
+ { "glXQueryChannelDeltasSGIX", (__GLXextFuncPtr) glXQueryChannelDeltasSGIX },
+ { "glXChannelRectSyncSGIX", (__GLXextFuncPtr) glXChannelRectSyncSGIX },
+
+ /*** GLX_SGIX_dmbuffer **/
+#if defined(_DM_BUFFER_H_)
+ { "glXAssociateDMPbufferSGIX", (__GLXextFuncPtr) glXAssociateDMPbufferSGIX },
+#endif
+
+ /*** GLX_SGIX_swap_group ***/
+ { "glXJoinSwapGroupSGIX", (__GLXextFuncPtr) glXJoinSwapGroupSGIX },
+
+ /*** GLX_SGIX_swap_barrier ***/
+ { "glXBindSwapBarrierSGIX", (__GLXextFuncPtr) glXBindSwapBarrierSGIX },
+ { "glXQueryMaxSwapBarriersSGIX", (__GLXextFuncPtr) glXQueryMaxSwapBarriersSGIX },
+
+ /*** GLX_SUN_get_transparent_index ***/
+ { "glXGetTransparentIndexSUN", (__GLXextFuncPtr) glXGetTransparentIndexSUN },
+
+ /*** GLX_MESA_copy_sub_buffer ***/
+ { "glXCopySubBufferMESA", (__GLXextFuncPtr) glXCopySubBufferMESA },
+
+ /*** GLX_MESA_pixmap_colormap ***/
+ { "glXCreateGLXPixmapMESA", (__GLXextFuncPtr) glXCreateGLXPixmapMESA },
+
+ /*** GLX_MESA_release_buffers ***/
+ { "glXReleaseBuffersMESA", (__GLXextFuncPtr) glXReleaseBuffersMESA },
+
+ /*** GLX_MESA_set_3dfx_mode ***/
+ { "glXSet3DfxModeMESA", (__GLXextFuncPtr) glXSet3DfxModeMESA },
+
+ /*** GLX_ARB_get_proc_address ***/
+ { "glXGetProcAddressARB", (__GLXextFuncPtr) glXGetProcAddressARB },
+
+ /*** GLX_NV_vertex_array_range ***/
+ { "glXAllocateMemoryNV", (__GLXextFuncPtr) glXAllocateMemoryNV },
+ { "glXFreeMemoryNV", (__GLXextFuncPtr) glXFreeMemoryNV },
+
+ /*** GLX_MESA_agp_offset ***/
+ { "glXGetAGPOffsetMESA", (__GLXextFuncPtr) glXGetAGPOffsetMESA },
+
+ /*** GLX_MESA_allocate_memory ***/
+ { "glXAllocateMemoryMESA", (__GLXextFuncPtr) glXAllocateMemoryMESA },
+ { "glXFreeMemoryMESA", (__GLXextFuncPtr) glXFreeMemoryMESA },
+ { "glXGetMemoryOffsetMESA", (__GLXextFuncPtr) glXGetMemoryOffsetMESA },
+
+ { NULL, NULL } /* end of list */
+};
+
+
+
+/*
+ * Return address of named glX function, or NULL if not found.
+ */
+__GLXextFuncPtr
+_glxapi_get_proc_address(const char *funcName)
+{
+ GLuint i;
+ for (i = 0; GLX_functions[i].Name; i++) {
+ if (strcmp(GLX_functions[i].Name, funcName) == 0)
+ return GLX_functions[i].Address;
+ }
+ return NULL;
+}
+
+
+
+/*
+ * This function does not get dispatched through the dispatch table
+ * since it's really a "meta" function.
+ */
+__GLXextFuncPtr
+glXGetProcAddressARB(const GLubyte *procName)
+{
+ __GLXextFuncPtr f;
+
+ f = _glxapi_get_proc_address((const char *) procName);
+ if (f) {
+ return f;
+ }
+
+ f = (__GLXextFuncPtr) _glapi_get_proc_address((const char *) procName);
+ return f;
+}
+
+
+/* GLX 1.4 */
+void (*glXGetProcAddress(const GLubyte *procName))()
+{
+ return glXGetProcAddressARB(procName);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/x11/glxapi.h b/nx-X11/extras/Mesa/src/mesa/drivers/x11/glxapi.h
new file mode 100644
index 000000000..3187534c9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/x11/glxapi.h
@@ -0,0 +1,223 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef _glxapi_h_
+#define _glxapi_h_
+
+
+#define GLX_GLXEXT_PROTOTYPES
+#include "GL/glx.h"
+
+
+/* The GLX API dispatcher (i.e. this code) is being built into stand-alone
+ * Mesa. We don't know anything about XFree86 or real GLX so we define a
+ * minimal __GLXContextRec here so some of the functions in this file can
+ * work properly.
+ */
+typedef struct __GLXcontextRec {
+ Display *currentDpy;
+ GLboolean isDirect;
+ GLXDrawable currentDrawable;
+ GLXDrawable currentReadable;
+ XID xid;
+} __GLXcontext;
+
+
+/*
+ * Almost all the GLX API functions get routed through this dispatch table.
+ * The exceptions are the glXGetCurrentXXX() functions.
+ *
+ * This dispatch table allows multiple GLX client-side modules to coexist.
+ * Specifically, a real GLX library (like SGI's or the Utah GLX) and Mesa's
+ * pseudo-GLX can be present at the same time. The former being used on
+ * GLX-enabled X servers and the later on non-GLX X servers.
+ *
+ * Red Hat has been using this since Red Hat Linux 7.0 (I think).
+ * This'll be a standard feature in XFree86 4.3. It basically allows one
+ * libGL to do both DRI-rendering and "fake GLX" rendering to X displays
+ * that lack the GLX extension.
+ */
+struct _glxapi_table {
+ /*** GLX_VERSION_1_0 ***/
+ XVisualInfo *(*ChooseVisual)(Display *dpy, int screen, int *list);
+ void (*CopyContext)(Display *dpy, GLXContext src, GLXContext dst, unsigned long mask);
+ GLXContext (*CreateContext)(Display *dpy, XVisualInfo *visinfo, GLXContext shareList, Bool direct);
+ GLXPixmap (*CreateGLXPixmap)(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap);
+ void (*DestroyContext)(Display *dpy, GLXContext ctx);
+ void (*DestroyGLXPixmap)(Display *dpy, GLXPixmap pixmap);
+ int (*GetConfig)(Display *dpy, XVisualInfo *visinfo, int attrib, int *value);
+ /*GLXContext (*GetCurrentContext)(void);*/
+ /*GLXDrawable (*GetCurrentDrawable)(void);*/
+ Bool (*IsDirect)(Display *dpy, GLXContext ctx);
+ Bool (*MakeCurrent)(Display *dpy, GLXDrawable drawable, GLXContext ctx);
+ Bool (*QueryExtension)(Display *dpy, int *errorb, int *event);
+ Bool (*QueryVersion)(Display *dpy, int *maj, int *min);
+ void (*SwapBuffers)(Display *dpy, GLXDrawable drawable);
+ void (*UseXFont)(Font font, int first, int count, int listBase);
+ void (*WaitGL)(void);
+ void (*WaitX)(void);
+
+ /*** GLX_VERSION_1_1 ***/
+ const char *(*GetClientString)(Display *dpy, int name);
+ const char *(*QueryExtensionsString)(Display *dpy, int screen);
+ const char *(*QueryServerString)(Display *dpy, int screen, int name);
+
+ /*** GLX_VERSION_1_2 ***/
+ /*Display *(*GetCurrentDisplay)(void);*/
+
+ /*** GLX_VERSION_1_3 ***/
+ GLXFBConfig *(*ChooseFBConfig)(Display *dpy, int screen, const int *attribList, int *nitems);
+ GLXContext (*CreateNewContext)(Display *dpy, GLXFBConfig config, int renderType, GLXContext shareList, Bool direct);
+ GLXPbuffer (*CreatePbuffer)(Display *dpy, GLXFBConfig config, const int *attribList);
+ GLXPixmap (*CreatePixmap)(Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attribList);
+ GLXWindow (*CreateWindow)(Display *dpy, GLXFBConfig config, Window win, const int *attribList);
+ void (*DestroyPbuffer)(Display *dpy, GLXPbuffer pbuf);
+ void (*DestroyPixmap)(Display *dpy, GLXPixmap pixmap);
+ void (*DestroyWindow)(Display *dpy, GLXWindow window);
+ /*GLXDrawable (*GetCurrentReadDrawable)(void);*/
+ int (*GetFBConfigAttrib)(Display *dpy, GLXFBConfig config, int attribute, int *value);
+ GLXFBConfig *(*GetFBConfigs)(Display *dpy, int screen, int *nelements);
+ void (*GetSelectedEvent)(Display *dpy, GLXDrawable drawable, unsigned long *mask);
+ XVisualInfo *(*GetVisualFromFBConfig)(Display *dpy, GLXFBConfig config);
+ Bool (*MakeContextCurrent)(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
+ int (*QueryContext)(Display *dpy, GLXContext ctx, int attribute, int *value);
+ void (*QueryDrawable)(Display *dpy, GLXDrawable draw, int attribute, unsigned int *value);
+ void (*SelectEvent)(Display *dpy, GLXDrawable drawable, unsigned long mask);
+
+ /*** GLX_SGI_swap_control ***/
+ int (*SwapIntervalSGI)(int);
+
+ /*** GLX_SGI_video_sync ***/
+ int (*GetVideoSyncSGI)(unsigned int *count);
+ int (*WaitVideoSyncSGI)(int divisor, int remainder, unsigned int *count);
+
+ /*** GLX_SGI_make_current_read ***/
+ Bool (*MakeCurrentReadSGI)(Display *, GLXDrawable, GLXDrawable, GLXContext);
+ /*GLXDrawable (*GetCurrentReadDrawableSGI)(void);*/
+
+ /*** GLX_SGIX_video_source (needs video library) ***/
+#if defined(_VL_H_)
+ GLXVideoSourceSGIX (*CreateGLXVideoSourceSGIX)(Display *, int, VLServer, VLPath, int, VLNode);
+ void (*DestroyGLXVideoSourceSGIX)(Display *, GLXVideoSourceSGIX);
+#else
+ void *CreateGLXVideoSourceSGIX;
+ void *DestroyGLXVideoSourceSGIX;
+#endif
+
+ /*** GLX_EXT_import_context ***/
+ void (*FreeContextEXT)(Display *dpy, GLXContext context);
+ GLXContextID (*GetContextIDEXT)(const GLXContext context);
+ /*Display *(*GetCurrentDisplayEXT)(void);*/
+ GLXContext (*ImportContextEXT)(Display *dpy, GLXContextID contextID);
+ int (*QueryContextInfoEXT)(Display *dpy, GLXContext context, int attribute,int *value);
+
+ /*** GLX_SGIX_fbconfig ***/
+ int (*GetFBConfigAttribSGIX)(Display *, GLXFBConfigSGIX, int, int *);
+ GLXFBConfigSGIX * (*ChooseFBConfigSGIX)(Display *, int, int *, int *);
+ GLXPixmap (*CreateGLXPixmapWithConfigSGIX)(Display *, GLXFBConfigSGIX, Pixmap);
+ GLXContext (*CreateContextWithConfigSGIX)(Display *, GLXFBConfigSGIX, int, GLXContext, Bool);
+ XVisualInfo * (*GetVisualFromFBConfigSGIX)(Display *, GLXFBConfigSGIX);
+ GLXFBConfigSGIX (*GetFBConfigFromVisualSGIX)(Display *, XVisualInfo *);
+
+ /*** GLX_SGIX_pbuffer ***/
+ GLXPbufferSGIX (*CreateGLXPbufferSGIX)(Display *, GLXFBConfigSGIX, unsigned int, unsigned int, int *);
+ void (*DestroyGLXPbufferSGIX)(Display *, GLXPbufferSGIX);
+ int (*QueryGLXPbufferSGIX)(Display *, GLXPbufferSGIX, int, unsigned int *);
+ void (*SelectEventSGIX)(Display *, GLXDrawable, unsigned long);
+ void (*GetSelectedEventSGIX)(Display *, GLXDrawable, unsigned long *);
+
+ /*** GLX_SGI_cushion ***/
+ void (*CushionSGI)(Display *, Window, float);
+
+ /*** GLX_SGIX_video_resize ***/
+ int (*BindChannelToWindowSGIX)(Display *, int, int, Window);
+ int (*ChannelRectSGIX)(Display *, int, int, int, int, int, int);
+ int (*QueryChannelRectSGIX)(Display *, int, int, int *, int *, int *, int *);
+ int (*QueryChannelDeltasSGIX)(Display *, int, int, int *, int *, int *, int *);
+ int (*ChannelRectSyncSGIX)(Display *, int, int, GLenum);
+
+ /*** GLX_SGIX_dmbuffer (needs dmedia library) ***/
+#if defined (_DM_BUFFER_H_)
+ Bool (*AssociateDMPbufferSGIX)(Display *, GLXPbufferSGIX, DMparams *, DMbuffer);
+#else
+ void *AssociciateDMPbufferSGIX;
+#endif
+
+ /*** GLX_SGIX_swap_group ***/
+ void (*JoinSwapGroupSGIX)(Display *, GLXDrawable, GLXDrawable);
+
+ /*** GLX_SGIX_swap_barrier ***/
+ void (*BindSwapBarrierSGIX)(Display *, GLXDrawable, int);
+ Bool (*QueryMaxSwapBarriersSGIX)(Display *, int, int *);
+
+ /*** GLX_SUN_get_transparent_index ***/
+ Status (*GetTransparentIndexSUN)(Display *, Window, Window, long *);
+
+ /*** GLX_MESA_copy_sub_buffer ***/
+ void (*CopySubBufferMESA)(Display *dpy, GLXDrawable drawable, int x, int y, int width, int height);
+
+ /*** GLX_MESA_release_buffers ***/
+ Bool (*ReleaseBuffersMESA)(Display *dpy, Window w);
+
+ /*** GLX_MESA_pixmap_colormap ***/
+ GLXPixmap (*CreateGLXPixmapMESA)(Display *dpy, XVisualInfo *visinfo, Pixmap pixmap, Colormap cmap);
+
+ /*** GLX_MESA_set_3dfx_mode ***/
+ Bool (*Set3DfxModeMESA)(int mode);
+
+ /*** GLX_NV_vertex_array_range ***/
+ void * (*AllocateMemoryNV)( GLsizei size,
+ GLfloat readFrequency,
+ GLfloat writeFrequency,
+ GLfloat priority );
+ void (*FreeMemoryNV)( GLvoid *pointer );
+
+ /*** GLX_MESA_agp_offset ***/
+ GLuint (*GetAGPOffsetMESA)( const GLvoid *pointer );
+};
+
+
+
+extern const char *
+_glxapi_get_version(void);
+
+
+extern const char **
+_glxapi_get_extensions(void);
+
+
+extern GLuint
+_glxapi_get_dispatch_table_size(void);
+
+
+extern void
+_glxapi_set_no_op_table(struct _glxapi_table *t);
+
+
+extern __GLXextFuncPtr
+_glxapi_get_proc_address(const char *funcName);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/x11/glxheader.h b/nx-X11/extras/Mesa/src/mesa/drivers/x11/glxheader.h
new file mode 100644
index 000000000..2533d5044
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/x11/glxheader.h
@@ -0,0 +1,64 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef GLX_HEADER_H
+#define GLX_HEADER_H
+
+#ifdef __VMS
+#include <GL/vms_x_fix.h>
+#endif
+
+#include "glheader.h"
+
+#ifdef XFree86Server
+
+# include "resource.h"
+# include "windowstr.h"
+# include "gcstruct.h"
+# include "GL/xf86glx.h"
+# include "xf86glx_util.h"
+
+#else
+
+# include <X11/Xlib.h>
+# include <X11/Xutil.h>
+# ifdef USE_XSHM /* was SHM */
+# include <sys/ipc.h>
+# include <sys/shm.h>
+# include <X11/extensions/XShm.h>
+# endif
+# include <GL/glx.h>
+
+#endif
+
+
+
+/* this silences a compiler warning on several systems */
+struct timespec;
+struct itimerspec;
+
+
+#endif /*GLX_HEADER*/
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/x11/realglx.c b/nx-X11/extras/Mesa/src/mesa/drivers/x11/realglx.c
new file mode 100644
index 000000000..30adb7465
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/x11/realglx.c
@@ -0,0 +1,180 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2002 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.
+ */
+
+
+#include <assert.h>
+#include <GL/glx.h>
+#include "realglx.h"
+#include "glxapi.h"
+
+
+struct _glxapi_table *
+_real_GetGLXDispatchTable(void)
+{
+ static struct _glxapi_table glx;
+
+ /* be sure our dispatch table size <= libGL's table */
+ {
+ GLuint size = sizeof(struct _glxapi_table) / sizeof(void *);
+ (void) size;
+ assert(_glxapi_get_dispatch_table_size() >= size);
+ }
+
+ /* initialize the whole table to no-ops */
+ _glxapi_set_no_op_table(&glx);
+
+ /* now initialize the table with the functions I implement */
+
+ /*** GLX_VERSION_1_0 ***/
+ glx.ChooseVisual = _real_glXChooseVisual;
+ glx.CopyContext = _real_glXCopyContext;
+ glx.CreateContext = _real_glXCreateContext;
+ glx.CreateGLXPixmap = _real_glXCreateGLXPixmap;
+ glx.DestroyContext = _real_glXDestroyContext;
+ glx.DestroyGLXPixmap = _real_glXDestroyGLXPixmap;
+ glx.GetConfig = _real_glXGetConfig;
+ /*glx.GetCurrentContext = _real_glXGetCurrentContext;*/
+ /*glx.GetCurrentDrawable = _real_glXGetCurrentDrawable;*/
+ glx.IsDirect = _real_glXIsDirect;
+ glx.MakeCurrent = _real_glXMakeCurrent;
+ glx.QueryExtension = _real_glXQueryExtension;
+ glx.QueryVersion = _real_glXQueryVersion;
+ glx.SwapBuffers = _real_glXSwapBuffers;
+ glx.UseXFont = _real_glXUseXFont;
+ glx.WaitGL = _real_glXWaitGL;
+ glx.WaitX = _real_glXWaitX;
+
+ /*** GLX_VERSION_1_1 ***/
+ glx.GetClientString = _real_glXGetClientString;
+ glx.QueryExtensionsString = _real_glXQueryExtensionsString;
+ glx.QueryServerString = _real_glXQueryServerString;
+
+ /*** GLX_VERSION_1_2 ***/
+ /*glx.GetCurrentDisplay = _real_glXGetCurrentDisplay;*/
+
+ /*** GLX_VERSION_1_3 ***/
+ glx.ChooseFBConfig = _real_glXChooseFBConfig;
+ glx.CreateNewContext = _real_glXCreateNewContext;
+ glx.CreatePbuffer = _real_glXCreatePbuffer;
+ glx.CreatePixmap = _real_glXCreatePixmap;
+ glx.CreateWindow = _real_glXCreateWindow;
+ glx.DestroyPbuffer = _real_glXDestroyPbuffer;
+ glx.DestroyPixmap = _real_glXDestroyPixmap;
+ glx.DestroyWindow = _real_glXDestroyWindow;
+ /*glx.GetCurrentReadDrawable = _real_glXGetCurrentReadDrawable;*/
+ glx.GetFBConfigAttrib = _real_glXGetFBConfigAttrib;
+ glx.GetFBConfigs = _real_glXGetFBConfigs;
+ glx.GetSelectedEvent = _real_glXGetSelectedEvent;
+ glx.GetVisualFromFBConfig = _real_glXGetVisualFromFBConfig;
+ glx.MakeContextCurrent = _real_glXMakeContextCurrent;
+ glx.QueryContext = _real_glXQueryContext;
+ glx.QueryDrawable = _real_glXQueryDrawable;
+ glx.SelectEvent = _real_glXSelectEvent;
+
+ /*** GLX_SGI_swap_control ***/
+ glx.SwapIntervalSGI = _real_glXSwapIntervalSGI;
+
+ /*** GLX_SGI_video_sync ***/
+ glx.GetVideoSyncSGI = _real_glXGetVideoSyncSGI;
+ glx.WaitVideoSyncSGI = _real_glXWaitVideoSyncSGI;
+
+ /*** GLX_SGI_make_current_read ***/
+ glx.MakeCurrentReadSGI = _real_glXMakeCurrentReadSGI;
+ /*glx.GetCurrentReadDrawableSGI = _real_glXGetCurrentReadDrawableSGI;*/
+
+#if defined(_VL_H)
+ /*** GLX_SGIX_video_source ***/
+ glx.CreateGLXVideoSourceSGIX = _real_glXCreateGLXVideoSourceSGIX;
+ glx.DestroyGLXVideoSourceSGIX = _real_glXDestroyGLXVideoSourceSGIX;
+#endif
+
+ /*** GLX_EXT_import_context ***/
+ glx.FreeContextEXT = _real_glXFreeContextEXT;
+ /*glx.GetContextIDEXT = _real_glXGetContextIDEXT;*/
+ /*glx.GetCurrentDisplayEXT = _real_glXGetCurrentDisplayEXT;*/
+ glx.ImportContextEXT = _real_glXImportContextEXT;
+ glx.QueryContextInfoEXT = _real_glXQueryContextInfoEXT;
+
+ /*** GLX_SGIX_fbconfig ***/
+ glx.GetFBConfigAttribSGIX = _real_glXGetFBConfigAttribSGIX;
+ glx.ChooseFBConfigSGIX = _real_glXChooseFBConfigSGIX;
+ glx.CreateGLXPixmapWithConfigSGIX = _real_glXCreateGLXPixmapWithConfigSGIX;
+ glx.CreateContextWithConfigSGIX = _real_glXCreateContextWithConfigSGIX;
+ glx.GetVisualFromFBConfigSGIX = _real_glXGetVisualFromFBConfigSGIX;
+ glx.GetFBConfigFromVisualSGIX = _real_glXGetFBConfigFromVisualSGIX;
+
+ /*** GLX_SGIX_pbuffer ***/
+ glx.CreateGLXPbufferSGIX = _real_glXCreateGLXPbufferSGIX;
+ glx.DestroyGLXPbufferSGIX = _real_glXDestroyGLXPbufferSGIX;
+ glx.QueryGLXPbufferSGIX = _real_glXQueryGLXPbufferSGIX;
+ glx.SelectEventSGIX = _real_glXSelectEventSGIX;
+ glx.GetSelectedEventSGIX = _real_glXGetSelectedEventSGIX;
+
+ /*** GLX_SGI_cushion ***/
+ glx.CushionSGI = _real_glXCushionSGI;
+
+ /*** GLX_SGIX_video_resize ***/
+ glx.BindChannelToWindowSGIX = _real_glXBindChannelToWindowSGIX;
+ glx.ChannelRectSGIX = _real_glXChannelRectSGIX;
+ glx.QueryChannelRectSGIX = _real_glXQueryChannelRectSGIX;
+ glx.QueryChannelDeltasSGIX = _real_glXQueryChannelDeltasSGIX;
+ glx.ChannelRectSyncSGIX = _real_glXChannelRectSyncSGIX;
+
+#if defined(_DM_BUFFER_H_)
+ /*** (GLX_SGIX_dmbuffer ***/
+ glx.AssociateDMPbufferSGIX = NULL;
+#endif
+
+ /*** GLX_SGIX_swap_group ***/
+ glx.JoinSwapGroupSGIX = _real_glXJoinSwapGroupSGIX;
+
+ /*** GLX_SGIX_swap_barrier ***/
+ glx.BindSwapBarrierSGIX = _real_glXBindSwapBarrierSGIX;
+ glx.QueryMaxSwapBarriersSGIX = _real_glXQueryMaxSwapBarriersSGIX;
+
+ /*** GLX_SUN_get_transparent_index ***/
+ glx.GetTransparentIndexSUN = _real_glXGetTransparentIndexSUN;
+
+ /*** GLX_MESA_copy_sub_buffer ***/
+ glx.CopySubBufferMESA = _real_glXCopySubBufferMESA;
+
+ /*** GLX_MESA_release_buffers ***/
+ glx.ReleaseBuffersMESA = _real_glXReleaseBuffersMESA;
+
+ /*** GLX_MESA_pixmap_colormap ***/
+ glx.CreateGLXPixmapMESA = _real_glXCreateGLXPixmapMESA;
+
+ /*** GLX_MESA_set_3dfx_mode ***/
+ glx.Set3DfxModeMESA = _real_glXSet3DfxModeMESA;
+
+ /*** GLX_NV_vertex_array_range ***/
+ glx.AllocateMemoryNV = _real_glXAllocateMemoryNV;
+ glx.FreeMemoryNV = _real_glXFreeMemoryNV;
+
+ /*** GLX_MESA_agp_offset ***/
+ glx.GetAGPOffsetMESA = _real_glXGetAGPOffsetMESA;
+
+ return &glx;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/x11/realglx.h b/nx-X11/extras/Mesa/src/mesa/drivers/x11/realglx.h
new file mode 100644
index 000000000..150129db6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/x11/realglx.h
@@ -0,0 +1,326 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef REALGLX_H
+#define REALGLX_H
+
+
+extern struct _glxapi_table *
+_real_GetGLXDispatchTable(void);
+
+
+/*
+ * Basically just need these to prevent compiler warnings.
+ */
+
+
+extern XVisualInfo *
+_real_glXChooseVisual( Display *dpy, int screen, int *list );
+
+extern GLXContext
+_real_glXCreateContext( Display *dpy, XVisualInfo *visinfo,
+ GLXContext share_list, Bool direct );
+
+extern GLXPixmap
+_real_glXCreateGLXPixmap( Display *dpy, XVisualInfo *visinfo, Pixmap pixmap );
+
+extern GLXPixmap
+_real_glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visinfo,
+ Pixmap pixmap, Colormap cmap );
+
+extern void
+_real_glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap );
+
+extern void
+_real_glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
+ unsigned long mask );
+
+extern Bool
+_real_glXMakeCurrent( Display *dpy, GLXDrawable drawable, GLXContext ctx );
+
+extern Bool
+_real_glXQueryExtension( Display *dpy, int *errorb, int *event );
+
+extern void
+_real_glXDestroyContext( Display *dpy, GLXContext ctx );
+
+extern Bool
+_real_glXIsDirect( Display *dpy, GLXContext ctx );
+
+extern void
+_real_glXSwapBuffers( Display *dpy, GLXDrawable drawable );
+
+extern void
+_real_glXUseXFont( Font font, int first, int count, int listbase );
+
+extern Bool
+_real_glXQueryVersion( Display *dpy, int *maj, int *min );
+
+extern int
+_real_glXGetConfig( Display *dpy, XVisualInfo *visinfo,
+ int attrib, int *value );
+
+extern void
+_real_glXWaitGL( void );
+
+
+extern void
+_real_glXWaitX( void );
+
+/* GLX 1.1 and later */
+extern const char *
+_real_glXQueryExtensionsString( Display *dpy, int screen );
+
+/* GLX 1.1 and later */
+extern const char *
+_real_glXQueryServerString( Display *dpy, int screen, int name );
+
+/* GLX 1.1 and later */
+extern const char *
+_real_glXGetClientString( Display *dpy, int name );
+
+
+/*
+ * GLX 1.3 and later
+ */
+
+extern GLXFBConfig *
+_real_glXChooseFBConfig( Display *dpy, int screen,
+ const int *attribList, int *nitems );
+
+extern int
+_real_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
+ int attribute, int *value );
+
+extern GLXFBConfig *
+_real_glXGetFBConfigs( Display *dpy, int screen, int *nelements );
+
+extern XVisualInfo *
+_real_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config );
+
+extern GLXWindow
+_real_glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
+ const int *attribList );
+
+extern void
+_real_glXDestroyWindow( Display *dpy, GLXWindow window );
+
+extern GLXPixmap
+_real_glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
+ const int *attribList );
+
+extern void
+_real_glXDestroyPixmap( Display *dpy, GLXPixmap pixmap );
+
+extern GLXPbuffer
+_real_glXCreatePbuffer( Display *dpy, GLXFBConfig config,
+ const int *attribList );
+
+extern void
+_real_glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf );
+
+extern void
+_real_glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
+ unsigned int *value );
+
+extern GLXContext
+_real_glXCreateNewContext( Display *dpy, GLXFBConfig config,
+ int renderType, GLXContext shareList, Bool direct );
+
+
+extern Bool
+_real_glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
+ GLXDrawable read, GLXContext ctx );
+
+extern int
+_real_glXQueryContext( Display *dpy, GLXContext ctx, int attribute, int *value );
+
+extern void
+_real_glXSelectEvent( Display *dpy, GLXDrawable drawable, unsigned long mask );
+
+extern void
+_real_glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
+ unsigned long *mask );
+
+#ifdef GLX_SGI_swap_control
+extern int
+_real_glXSwapIntervalSGI(int interval);
+#endif
+
+
+#ifdef GLX_SGI_video_sync
+extern int
+_real_glXGetVideoSyncSGI(unsigned int *count);
+
+extern int
+_real_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count);
+#endif
+
+
+#ifdef GLX_SGI_make_current_read
+extern Bool
+_real_glXMakeCurrentReadSGI(Display *dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx);
+
+extern GLXDrawable
+_real_glXGetCurrentReadDrawableSGI(void);
+#endif
+
+#if defined(_VL_H) && defined(GLX_SGIX_video_source)
+extern GLXVideoSourceSGIX
+_real_glXCreateGLXVideoSourceSGIX(Display *dpy, int screen, VLServer server, VLPath path, int nodeClass, VLNode drainNode);
+
+extern void
+_real_glXDestroyGLXVideoSourceSGIX(Display *dpy, GLXVideoSourceSGIX src);
+#endif
+
+#ifdef GLX_EXT_import_context
+extern void
+_real_glXFreeContextEXT(Display *dpy, GLXContext context);
+
+extern GLXContextID
+_real_glXGetContextIDEXT(const GLXContext context);
+
+extern Display *
+_real_glXGetCurrentDisplayEXT(void);
+
+extern GLXContext
+_real_glXImportContextEXT(Display *dpy, GLXContextID contextID);
+
+extern int
+_real_glXQueryContextInfoEXT(Display *dpy, GLXContext context, int attribute, int *value);
+#endif
+
+#ifdef GLX_SGIX_fbconfig
+extern int
+_real_glXGetFBConfigAttribSGIX(Display *dpy, GLXFBConfigSGIX config, int attribute, int *value);
+
+extern GLXFBConfigSGIX *
+_real_glXChooseFBConfigSGIX(Display *dpy, int screen, int *attrib_list, int *nelements);
+
+extern GLXPixmap
+_real_glXCreateGLXPixmapWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, Pixmap pixmap);
+
+extern GLXContext
+_real_glXCreateContextWithConfigSGIX(Display *dpy, GLXFBConfigSGIX config, int render_type, GLXContext share_list, Bool direct);
+
+extern XVisualInfo *
+_real_glXGetVisualFromFBConfigSGIX(Display *dpy, GLXFBConfigSGIX config);
+
+extern GLXFBConfigSGIX
+_real_glXGetFBConfigFromVisualSGIX(Display *dpy, XVisualInfo *vis);
+#endif
+
+#ifdef GLX_SGIX_pbuffer
+extern GLXPbufferSGIX
+_real_glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config, unsigned int width, unsigned int height, int *attrib_list);
+
+extern void
+_real_glXDestroyGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf);
+
+extern int
+_real_glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuf, int attribute, unsigned int *value);
+
+extern void
+_real_glXSelectEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long mask);
+
+extern void
+_real_glXGetSelectedEventSGIX(Display *dpy, GLXDrawable drawable, unsigned long *mask);
+#endif
+
+#ifdef GLX_SGI_cushion
+extern void
+_real_glXCushionSGI(Display *dpy, Window win, float cushion);
+#endif
+
+#ifdef GLX_SGIX_video_resize
+extern int
+_real_glXBindChannelToWindowSGIX(Display *dpy, int screen, int channel , Window window);
+
+extern int
+_real_glXChannelRectSGIX(Display *dpy, int screen, int channel, int x, int y, int w, int h);
+
+extern int
+_real_glXQueryChannelRectSGIX(Display *dpy, int screen, int channel, int *x, int *y, int *w, int *h);
+
+extern int
+_real_glXQueryChannelDeltasSGIX(Display *dpy, int screen, int channel, int *dx, int *dy, int *dw, int *dh);
+
+extern int
+_real_glXChannelRectSyncSGIX(Display *dpy, int screen, int channel, GLenum synctype);
+#endif
+
+#if defined(_DM_BUFFER_H_) && defined(GLX_SGIX_dmbuffer)
+extern Bool
+_real_glXAssociateDMPbufferSGIX(Display *dpy, GLXPbufferSGIX pbuffer, DMparams *params, DMbuffer dmbuffer);
+#endif
+
+#ifdef GLX_SGIX_swap_group
+extern void
+_real_glXJoinSwapGroupSGIX(Display *dpy, GLXDrawable drawable, GLXDrawable member);
+#endif
+
+#ifdef GLX_SGIX_swap_barrier
+extern void
+_real_glXBindSwapBarrierSGIX(Display *dpy, GLXDrawable drawable, int barrier);
+
+extern Bool
+_real_glXQueryMaxSwapBarriersSGIX(Display *dpy, int screen, int *max);
+#endif
+
+#ifdef GLX_SUN_get_transparent_index
+extern Status
+_real_glXGetTransparentIndexSUN(Display *dpy, Window overlay, Window underlay, long *pTransparent);
+#endif
+
+#ifdef GLX_MESA_release_buffers
+extern Bool
+_real_glXReleaseBuffersMESA( Display *dpy, GLXDrawable d );
+#endif
+
+#ifdef GLX_MESA_set_3dfx_mode
+extern Bool
+_real_glXSet3DfxModeMESA( int mode );
+#endif
+
+#ifdef GLX_NV_vertex_array_range
+extern void *
+_real_glXAllocateMemoryNV(GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
+extern void
+_real_glXFreeMemoryNV(GLvoid *pointer);
+#endif
+
+#ifdef GLX_MESA_agp_offset
+extern GLuint
+_real_glXGetAGPOffsetMESA(const GLvoid *pointer);
+#endif
+
+#ifdef GLX_MESA_copy_sub_buffer
+extern void
+_real_glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
+ int x, int y, int width, int height );
+#endif
+
+#endif /* REALGLX_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/x11/xfonts.c b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xfonts.c
new file mode 100644
index 000000000..d72c600bd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xfonts.c
@@ -0,0 +1,377 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * 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.
+ */
+
+
+/* xfonts.c -- glXUseXFont() for Mesa written by
+ * Copyright (C) 1995 Thorsten.Ohl @ Physik.TH-Darmstadt.de
+ */
+
+#ifdef __VMS
+#include <GL/vms_x_fix.h>
+#endif
+
+#include "glxheader.h"
+#include "context.h"
+#include "imports.h"
+#include "xfonts.h"
+
+
+/* Some debugging info. */
+
+#ifdef DEBUG
+#undef _R
+#undef _G
+#undef _B
+#include <ctype.h>
+
+int debug_xfonts = 0;
+
+static void
+dump_char_struct(XCharStruct * ch, char *prefix)
+{
+ printf("%slbearing = %d, rbearing = %d, width = %d\n",
+ prefix, ch->lbearing, ch->rbearing, ch->width);
+ printf("%sascent = %d, descent = %d, attributes = %u\n",
+ prefix, ch->ascent, ch->descent, (unsigned int) ch->attributes);
+}
+
+static void
+dump_font_struct(XFontStruct * font)
+{
+ printf("ascent = %d, descent = %d\n", font->ascent, font->descent);
+ printf("char_or_byte2 = (%u,%u)\n",
+ font->min_char_or_byte2, font->max_char_or_byte2);
+ printf("byte1 = (%u,%u)\n", font->min_byte1, font->max_byte1);
+ printf("all_chars_exist = %s\n", font->all_chars_exist ? "True" : "False");
+ printf("default_char = %c (\\%03o)\n",
+ (char) (isprint(font->default_char) ? font->default_char : ' '),
+ font->default_char);
+ dump_char_struct(&font->min_bounds, "min> ");
+ dump_char_struct(&font->max_bounds, "max> ");
+#if 0
+ for (c = font->min_char_or_byte2; c <= font->max_char_or_byte2; c++) {
+ char prefix[8];
+ sprintf(prefix, "%d> ", c);
+ dump_char_struct(&font->per_char[c], prefix);
+ }
+#endif
+}
+
+static void
+dump_bitmap(unsigned int width, unsigned int height, GLubyte * bitmap)
+{
+ unsigned int x, y;
+
+ printf(" ");
+ for (x = 0; x < 8 * width; x++)
+ printf("%o", 7 - (x % 8));
+ putchar('\n');
+ for (y = 0; y < height; y++) {
+ printf("%3o:", y);
+ for (x = 0; x < 8 * width; x++)
+ putchar((bitmap[width * (height - y - 1) + x / 8] & (1 << (7 - (x %
+ 8))))
+ ? '*' : '.');
+ printf(" ");
+ for (x = 0; x < width; x++)
+ printf("0x%02x, ", bitmap[width * (height - y - 1) + x]);
+ putchar('\n');
+ }
+}
+#endif /* DEBUG */
+
+
+/* Implementation. */
+
+/* Fill a BITMAP with a character C from thew current font
+ in the graphics context GC. WIDTH is the width in bytes
+ and HEIGHT is the height in bits.
+
+ Note that the generated bitmaps must be used with
+
+ glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE);
+ glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE);
+ glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
+ glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
+ glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
+ glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+
+ Possible optimizations:
+
+ * use only one reusable pixmap with the maximum dimensions.
+ * draw the entire font into a single pixmap (careful with
+ proportional fonts!).
+*/
+
+
+/*
+ * Generate OpenGL-compatible bitmap.
+ */
+static void
+fill_bitmap(Display * dpy, Window win, GC gc,
+ unsigned int width, unsigned int height,
+ int x0, int y0, unsigned int c, GLubyte * bitmap)
+{
+ XImage *image;
+ unsigned int x, y;
+ Pixmap pixmap;
+ XChar2b char2b;
+
+ pixmap = XCreatePixmap(dpy, win, 8 * width, height, 1);
+ XSetForeground(dpy, gc, 0);
+ XFillRectangle(dpy, pixmap, gc, 0, 0, 8 * width, height);
+ XSetForeground(dpy, gc, 1);
+
+ char2b.byte1 = (c >> 8) & 0xff;
+ char2b.byte2 = (c & 0xff);
+
+ XDrawString16(dpy, pixmap, gc, x0, y0, &char2b, 1);
+
+ image = XGetImage(dpy, pixmap, 0, 0, 8 * width, height, 1, XYPixmap);
+ if (image) {
+ /* Fill the bitmap (X11 and OpenGL are upside down wrt each other). */
+ for (y = 0; y < height; y++)
+ for (x = 0; x < 8 * width; x++)
+ if (XGetPixel(image, x, y))
+ bitmap[width * (height - y - 1) + x / 8] |=
+ (1 << (7 - (x % 8)));
+ XDestroyImage(image);
+ }
+
+ XFreePixmap(dpy, pixmap);
+}
+
+/*
+ * determine if a given glyph is valid and return the
+ * corresponding XCharStruct.
+ */
+static XCharStruct *
+isvalid(XFontStruct * fs, unsigned int which)
+{
+ unsigned int rows, pages;
+ unsigned int byte1 = 0, byte2 = 0;
+ int i, valid = 1;
+
+ rows = fs->max_byte1 - fs->min_byte1 + 1;
+ pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
+
+ if (rows == 1) {
+ /* "linear" fonts */
+ if ((fs->min_char_or_byte2 > which) || (fs->max_char_or_byte2 < which))
+ valid = 0;
+ }
+ else {
+ /* "matrix" fonts */
+ byte2 = which & 0xff;
+ byte1 = which >> 8;
+ if ((fs->min_char_or_byte2 > byte2) ||
+ (fs->max_char_or_byte2 < byte2) ||
+ (fs->min_byte1 > byte1) || (fs->max_byte1 < byte1))
+ valid = 0;
+ }
+
+ if (valid) {
+ if (fs->per_char) {
+ if (rows == 1) {
+ /* "linear" fonts */
+ return (fs->per_char + (which - fs->min_char_or_byte2));
+ }
+ else {
+ /* "matrix" fonts */
+ i = ((byte1 - fs->min_byte1) * pages) +
+ (byte2 - fs->min_char_or_byte2);
+ return (fs->per_char + i);
+ }
+ }
+ else {
+ return (&fs->min_bounds);
+ }
+ }
+ return (NULL);
+}
+
+
+void
+Fake_glXUseXFont(Font font, int first, int count, int listbase)
+{
+ Display *dpy;
+ Window win;
+ Pixmap pixmap;
+ GC gc;
+ XGCValues values;
+ unsigned long valuemask;
+ XFontStruct *fs;
+ GLint swapbytes, lsbfirst, rowlength;
+ GLint skiprows, skippixels, alignment;
+ unsigned int max_width, max_height, max_bm_width, max_bm_height;
+ GLubyte *bm;
+ int i;
+
+ dpy = glXGetCurrentDisplay();
+ if (!dpy)
+ return; /* I guess glXMakeCurrent wasn't called */
+ win = RootWindow(dpy, DefaultScreen(dpy));
+
+ fs = XQueryFont(dpy, font);
+ if (!fs) {
+ _mesa_error(NULL, GL_INVALID_VALUE,
+ "Couldn't get font structure information");
+ return;
+ }
+
+ /* Allocate a bitmap that can fit all characters. */
+ max_width = fs->max_bounds.rbearing - fs->min_bounds.lbearing;
+ max_height = fs->max_bounds.ascent + fs->max_bounds.descent;
+ max_bm_width = (max_width + 7) / 8;
+ max_bm_height = max_height;
+
+ bm = (GLubyte *) MALLOC((max_bm_width * max_bm_height) * sizeof(GLubyte));
+ if (!bm) {
+ XFreeFontInfo(NULL, fs, 1);
+ _mesa_error(NULL, GL_OUT_OF_MEMORY,
+ "Couldn't allocate bitmap in glXUseXFont()");
+ return;
+ }
+
+#if 0
+ /* get the page info */
+ pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
+ firstchar = (fs->min_byte1 << 8) + fs->min_char_or_byte2;
+ lastchar = (fs->max_byte1 << 8) + fs->max_char_or_byte2;
+ rows = fs->max_byte1 - fs->min_byte1 + 1;
+ unsigned int first_char, last_char, pages, rows;
+#endif
+
+ /* Save the current packing mode for bitmaps. */
+ glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
+ glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
+ glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
+ glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
+ glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
+ glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
+
+ /* Enforce a standard packing mode which is compatible with
+ fill_bitmap() from above. This is actually the default mode,
+ except for the (non)alignment. */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ pixmap = XCreatePixmap(dpy, win, 10, 10, 1);
+ values.foreground = BlackPixel(dpy, DefaultScreen(dpy));
+ values.background = WhitePixel(dpy, DefaultScreen(dpy));
+ values.font = fs->fid;
+ valuemask = GCForeground | GCBackground | GCFont;
+ gc = XCreateGC(dpy, pixmap, valuemask, &values);
+ XFreePixmap(dpy, pixmap);
+
+#ifdef DEBUG
+ if (debug_xfonts)
+ dump_font_struct(fs);
+#endif
+
+ for (i = 0; i < count; i++) {
+ unsigned int width, height, bm_width, bm_height;
+ GLfloat x0, y0, dx, dy;
+ XCharStruct *ch;
+ int x, y;
+ unsigned int c = first + i;
+ int list = listbase + i;
+ int valid;
+
+ /* check on index validity and get the bounds */
+ ch = isvalid(fs, c);
+ if (!ch) {
+ ch = &fs->max_bounds;
+ valid = 0;
+ }
+ else {
+ valid = 1;
+ }
+
+#ifdef DEBUG
+ if (debug_xfonts) {
+ char s[7];
+ sprintf(s, isprint(c) ? "%c> " : "\\%03o> ", c);
+ dump_char_struct(ch, s);
+ }
+#endif
+
+ /* glBitmap()' parameters:
+ straight from the glXUseXFont(3) manpage. */
+ width = ch->rbearing - ch->lbearing;
+ height = ch->ascent + ch->descent;
+ x0 = -ch->lbearing;
+ y0 = ch->descent - 0; /* XXX used to subtract 1 here */
+ /* but that caused a conformace failure */
+ dx = ch->width;
+ dy = 0;
+
+ /* X11's starting point. */
+ x = -ch->lbearing;
+ y = ch->ascent;
+
+ /* Round the width to a multiple of eight. We will use this also
+ for the pixmap for capturing the X11 font. This is slightly
+ inefficient, but it makes the OpenGL part real easy. */
+ bm_width = (width + 7) / 8;
+ bm_height = height;
+
+ glNewList(list, GL_COMPILE);
+ if (valid && (bm_width > 0) && (bm_height > 0)) {
+
+ MEMSET(bm, '\0', bm_width * bm_height);
+ fill_bitmap(dpy, win, gc, bm_width, bm_height, x, y, c, bm);
+
+ glBitmap(width, height, x0, y0, dx, dy, bm);
+#ifdef DEBUG
+ if (debug_xfonts) {
+ printf("width/height = %u/%u\n", width, height);
+ printf("bm_width/bm_height = %u/%u\n", bm_width, bm_height);
+ dump_bitmap(bm_width, bm_height, bm);
+ }
+#endif
+ }
+ else {
+ glBitmap(0, 0, 0.0, 0.0, dx, dy, NULL);
+ }
+ glEndList();
+ }
+
+ FREE(bm);
+ XFreeFontInfo(NULL, fs, 1);
+ XFreeGC(dpy, gc);
+
+ /* Restore saved packing modes. */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/x11/xfonts.h b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xfonts.h
new file mode 100644
index 000000000..e36f42f81
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xfonts.h
@@ -0,0 +1,41 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * 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.
+ */
+
+
+#ifndef XFONTS_H
+#define XFONTS_H
+
+#ifdef __VMS
+#include <GL/vms_x_fix.h>
+#endif
+
+#include <X11/Xlib.h>
+
+
+extern void Fake_glXUseXFont( Font font, int first, int count, int listbase );
+
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_api.c b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_api.c
new file mode 100644
index 000000000..6ed2be564
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_api.c
@@ -0,0 +1,2675 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * This file contains the implementations of all the XMesa* functions.
+ *
+ *
+ * NOTES:
+ *
+ * The window coordinate system origin (0,0) is in the lower-left corner
+ * of the window. X11's window coordinate origin is in the upper-left
+ * corner of the window. Therefore, most drawing functions in this
+ * file have to flip Y coordinates.
+ *
+ * Define USE_XSHM in the Makefile with -DUSE_XSHM if you want to compile
+ * in support for the MIT Shared Memory extension. If enabled, when you
+ * use an Ximage for the back buffer in double buffered mode, the "swap"
+ * operation will be faster. You must also link with -lXext.
+ *
+ * Byte swapping: If the Mesa host and the X display use a different
+ * byte order then there's some trickiness to be aware of when using
+ * XImages. The byte ordering used for the XImage is that of the X
+ * display, not the Mesa host.
+ * The color-to-pixel encoding for True/DirectColor must be done
+ * according to the display's visual red_mask, green_mask, and blue_mask.
+ * If XPutPixel is used to put a pixel into an XImage then XPutPixel will
+ * do byte swapping if needed. If one wants to directly "poke" the pixel
+ * into the XImage's buffer then the pixel must be byte swapped first. In
+ * Mesa, when byte swapping is needed we use the PF_TRUECOLOR pixel format
+ * and use XPutPixel everywhere except in the implementation of
+ * glClear(GL_COLOR_BUFFER_BIT). We want this function to be fast so
+ * instead of using XPutPixel we "poke" our values after byte-swapping
+ * the clear pixel value if needed.
+ *
+ */
+
+#ifdef __CYGWIN__
+#undef WIN32
+#undef __WIN32__
+#endif
+
+#include "glxheader.h"
+#include "GL/xmesa.h"
+#include "xmesaP.h"
+#include "context.h"
+#include "extensions.h"
+#include "framebuffer.h"
+#include "glthread.h"
+#include "imports.h"
+#include "matrix.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "renderbuffer.h"
+#include "texformat.h"
+#include "texobj.h"
+#include "texstore.h"
+#include "swrast/swrast.h"
+#include "swrast_setup/swrast_setup.h"
+#include "array_cache/acache.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+#include "drivers/common/driverfuncs.h"
+
+#ifdef XFree86Server
+#include <GL/glxtokens.h>
+#endif
+
+/*
+ * Global X driver lock
+ */
+_glthread_Mutex _xmesa_lock;
+
+
+
+/*
+ * Lookup tables for HPCR pixel format:
+ */
+static short hpcr_rgbTbl[3][256] = {
+{
+ 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23,
+ 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31,
+ 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
+112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
+128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
+144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
+160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
+176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
+192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
+208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
+224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239
+},
+{
+ 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23,
+ 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31,
+ 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
+112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
+128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
+144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
+160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
+176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
+192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
+208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223,
+224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239
+},
+{
+ 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 39,
+ 40, 40, 41, 41, 42, 42, 43, 43, 44, 44, 45, 45, 46, 46, 47, 47,
+ 48, 48, 49, 49, 50, 50, 51, 51, 52, 52, 53, 53, 54, 54, 55, 55,
+ 56, 56, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 62, 62, 63, 63,
+ 64, 64, 65, 65, 66, 66, 67, 67, 68, 68, 69, 69, 70, 70, 71, 71,
+ 72, 72, 73, 73, 74, 74, 75, 75, 76, 76, 77, 77, 78, 78, 79, 79,
+ 80, 80, 81, 81, 82, 82, 83, 83, 84, 84, 85, 85, 86, 86, 87, 87,
+ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
+112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
+128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
+144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
+160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175,
+176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191,
+192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
+208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223
+}
+};
+
+
+
+/**********************************************************************/
+/***** X Utility Functions *****/
+/**********************************************************************/
+
+
+/*
+ * Return the host's byte order as LSBFirst or MSBFirst ala X.
+ */
+#ifndef XFree86Server
+static int host_byte_order( void )
+{
+ int i = 1;
+ char *cptr = (char *) &i;
+ return (*cptr==1) ? LSBFirst : MSBFirst;
+}
+#endif
+
+
+/*
+ * Error handling.
+ */
+#ifndef XFree86Server
+static volatile int mesaXErrorFlag = 0;
+
+static int mesaHandleXError( XMesaDisplay *dpy, XErrorEvent *event )
+{
+ (void) dpy;
+ (void) event;
+ mesaXErrorFlag = 1;
+ return 0;
+}
+#endif
+
+
+/*
+ * Check if the X Shared Memory extension is available.
+ * Return: 0 = not available
+ * 1 = shared XImage support available
+ * 2 = shared Pixmap support available also
+ */
+#ifndef XFree86Server
+static int check_for_xshm( XMesaDisplay *display )
+{
+#ifdef USE_XSHM
+ int major, minor, ignore;
+ Bool pixmaps;
+
+ if (XQueryExtension( display, "MIT-SHM", &ignore, &ignore, &ignore )) {
+ if (XShmQueryVersion( display, &major, &minor, &pixmaps )==True) {
+ return (pixmaps==True) ? 2 : 1;
+ }
+ else {
+ return 0;
+ }
+ }
+ else {
+ return 0;
+ }
+#else
+ /* Can't compile XSHM support */
+ return 0;
+#endif
+}
+#endif
+
+
+/*
+ * Apply gamma correction to an intensity value in [0..max]. Return the
+ * new intensity value.
+ */
+static GLint gamma_adjust( GLfloat gamma, GLint value, GLint max )
+{
+ if (gamma == 1.0) {
+ return value;
+ }
+ else {
+ double x = (double) value / (double) max;
+ return IROUND_POS((GLfloat) max * _mesa_pow(x, 1.0F/gamma));
+ }
+}
+
+
+
+/*
+ * Return the true number of bits per pixel for XImages.
+ * For example, if we request a 24-bit deep visual we may actually need/get
+ * 32bpp XImages. This function returns the appropriate bpp.
+ * Input: dpy - the X display
+ * visinfo - desribes the visual to be used for XImages
+ * Return: true number of bits per pixel for XImages
+ */
+#ifdef XFree86Server
+
+static int bits_per_pixel( XMesaVisual xmv )
+{
+ const int depth = xmv->nplanes;
+ int i;
+ for (i = 0; i < screenInfo.numPixmapFormats; i++) {
+ if (screenInfo.formats[i].depth == depth)
+ return screenInfo.formats[i].bitsPerPixel;
+ }
+ return depth; /* should never get here, but this should be safe */
+}
+
+#else
+
+static int bits_per_pixel( XMesaVisual xmv )
+{
+ XMesaDisplay *dpy = xmv->display;
+ XMesaVisualInfo visinfo = xmv->visinfo;
+ XMesaImage *img;
+ int bitsPerPixel;
+ /* Create a temporary XImage */
+ img = XCreateImage( dpy, visinfo->visual, visinfo->depth,
+ ZPixmap, 0, /*format, offset*/
+ (char*) MALLOC(8), /*data*/
+ 1, 1, /*width, height*/
+ 32, /*bitmap_pad*/
+ 0 /*bytes_per_line*/
+ );
+ assert(img);
+ /* grab the bits/pixel value */
+ bitsPerPixel = img->bits_per_pixel;
+ /* free the XImage */
+ _mesa_free( img->data );
+ img->data = NULL;
+ XMesaDestroyImage( img );
+ return bitsPerPixel;
+}
+#endif
+
+
+
+/*
+ * Determine if a given X window ID is valid (window exists).
+ * Do this by calling XGetWindowAttributes() for the window and
+ * checking if we catch an X error.
+ * Input: dpy - the display
+ * win - the window to check for existance
+ * Return: GL_TRUE - window exists
+ * GL_FALSE - window doesn't exist
+ */
+#ifndef XFree86Server
+static GLboolean WindowExistsFlag;
+
+static int window_exists_err_handler( XMesaDisplay* dpy, XErrorEvent* xerr )
+{
+ (void) dpy;
+ if (xerr->error_code == BadWindow) {
+ WindowExistsFlag = GL_FALSE;
+ }
+ return 0;
+}
+
+static GLboolean window_exists( XMesaDisplay *dpy, Window win )
+{
+ XWindowAttributes wa;
+ int (*old_handler)( XMesaDisplay*, XErrorEvent* );
+ WindowExistsFlag = GL_TRUE;
+ old_handler = XSetErrorHandler(window_exists_err_handler);
+ XGetWindowAttributes( dpy, win, &wa ); /* dummy request */
+ XSetErrorHandler(old_handler);
+ return WindowExistsFlag;
+}
+#endif
+
+
+
+/**********************************************************************/
+/***** Linked list of XMesaBuffers *****/
+/**********************************************************************/
+
+static XMesaBuffer XMesaBufferList = NULL;
+
+
+/**
+ * Allocate a new XMesaBuffer, initialize basic fields and add to
+ * the list of all buffers.
+ */
+static XMesaBuffer
+alloc_xmesa_buffer(XMesaVisual vis, BufferType type, XMesaColormap cmap)
+{
+ XMesaBuffer b = (XMesaBuffer) CALLOC_STRUCT(xmesa_buffer);
+ if (b) {
+ GLboolean swAlpha;
+
+ b->display = vis->display;
+ b->xm_visual = vis;
+ b->type = type;
+ b->cmap = cmap;
+
+ _mesa_initialize_framebuffer(&b->mesa_buffer, &vis->mesa_visual);
+
+ /* determine back buffer implementation */
+ if (vis->mesa_visual.doubleBufferMode) {
+ if (vis->ximage_flag) {
+ b->db_state = BACK_XIMAGE;
+ }
+ else {
+ b->db_state = BACK_PIXMAP;
+ }
+ }
+ else {
+ b->db_state = 0;
+ }
+
+ /* Allocate the framebuffer's renderbuffers */
+ assert(!b->mesa_buffer.Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
+ assert(!b->mesa_buffer.Attachment[BUFFER_BACK_LEFT].Renderbuffer);
+
+ /* front renderbuffer */
+ b->frontxrb = xmesa_new_renderbuffer(NULL, 0, vis->mesa_visual.rgbMode);
+ _mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_FRONT_LEFT,
+ &b->frontxrb->Base);
+
+ /* back renderbuffer */
+ if (vis->mesa_visual.doubleBufferMode) {
+ b->backxrb =xmesa_new_renderbuffer(NULL, 0, vis->mesa_visual.rgbMode);
+ _mesa_add_renderbuffer(&b->mesa_buffer, BUFFER_BACK_LEFT,
+ &b->backxrb->Base);
+ }
+
+ /* determine if we need software alpha planes */
+ if (vis->mesa_visual.alphaBits > 0
+ && vis->undithered_pf != PF_8A8B8G8R
+ && vis->undithered_pf != PF_8A8R8G8B) {
+ /* Visual has alpha, but pixel format doesn't support it.
+ * We'll use an alpha renderbuffer wrapper.
+ */
+ swAlpha = GL_TRUE;
+ }
+ else {
+ swAlpha = GL_FALSE;
+ }
+
+ _mesa_add_soft_renderbuffers(&b->mesa_buffer,
+ GL_FALSE, /* color */
+ vis->mesa_visual.haveDepthBuffer,
+ vis->mesa_visual.haveStencilBuffer,
+ vis->mesa_visual.haveAccumBuffer,
+ swAlpha,
+ vis->mesa_visual.numAuxBuffers > 0 );
+
+ /* insert into linked list */
+ b->Next = XMesaBufferList;
+ XMesaBufferList = b;
+ }
+ return b;
+}
+
+
+/*
+ * Find an XMesaBuffer by matching X display and colormap but NOT matching
+ * the notThis buffer.
+ */
+static XMesaBuffer find_xmesa_buffer(XMesaDisplay *dpy,
+ XMesaColormap cmap,
+ XMesaBuffer notThis)
+{
+ XMesaBuffer b;
+ for (b=XMesaBufferList; b; b=b->Next) {
+ if (b->display==dpy && b->cmap==cmap && b!=notThis) {
+ return b;
+ }
+ }
+ return NULL;
+}
+
+
+/*
+ * Free an XMesaBuffer, remove from linked list, perhaps free X colormap
+ * entries.
+ */
+static void free_xmesa_buffer(int client, XMesaBuffer buffer)
+{
+ XMesaBuffer prev = NULL, b;
+ (void) client;
+ for (b=XMesaBufferList; b; b=b->Next) {
+ if (b==buffer) {
+ /* unlink bufer from list */
+ if (prev)
+ prev->Next = buffer->Next;
+ else
+ XMesaBufferList = buffer->Next;
+ /* Check to free X colors */
+ if (buffer->num_alloced>0) {
+ /* If no other buffer uses this X colormap then free the colors. */
+ if (!find_xmesa_buffer(buffer->display, buffer->cmap, buffer)) {
+#ifdef XFree86Server
+ (void)FreeColors(buffer->cmap, client,
+ buffer->num_alloced, buffer->alloced_colors,
+ 0);
+#else
+ XFreeColors(buffer->display, buffer->cmap,
+ buffer->alloced_colors, buffer->num_alloced, 0);
+#endif
+ }
+ }
+
+ _mesa_free_framebuffer_data(&buffer->mesa_buffer);
+ _mesa_free(buffer);
+
+ return;
+ }
+ /* continue search */
+ prev = b;
+ }
+ /* buffer not found in XMesaBufferList */
+ _mesa_problem(NULL,"free_xmesa_buffer() - buffer not found\n");
+}
+
+
+/* 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));
+ MEMCPY(dst->pixel_to_r, src->pixel_to_r, sizeof(src->pixel_to_r));
+ MEMCPY(dst->pixel_to_g, src->pixel_to_g, sizeof(src->pixel_to_g));
+ MEMCPY(dst->pixel_to_b, src->pixel_to_b, sizeof(src->pixel_to_b));
+ dst->num_alloced = src->num_alloced;
+ MEMCPY(dst->alloced_colors, src->alloced_colors,
+ sizeof(src->alloced_colors));
+}
+
+
+
+/**********************************************************************/
+/***** Misc Private Functions *****/
+/**********************************************************************/
+
+
+/*
+ * 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;
+}
+
+
+
+/**
+ * Allocate a shared memory XImage back buffer for the given XMesaBuffer.
+ * Return: GL_TRUE if success, GL_FALSE if error
+ */
+#ifndef XFree86Server
+static GLboolean
+alloc_shm_back_buffer(XMesaBuffer b, GLuint width, GLuint height)
+{
+#ifdef USE_XSHM
+ /*
+ * We have to do a _lot_ of error checking here to be sure we can
+ * really use the XSHM extension. It seems different servers trigger
+ * errors at different points if the extension won't work. Therefore
+ * we have to be very careful...
+ */
+ GC gc;
+ int (*old_handler)( XMesaDisplay *, XErrorEvent * );
+
+ if (width == 0 || height == 0) {
+ /* this will be true the first time we're called on 'b' */
+ return GL_FALSE;
+ }
+
+ b->backxrb->ximage = XShmCreateImage(b->xm_visual->display,
+ b->xm_visual->visinfo->visual,
+ b->xm_visual->visinfo->depth,
+ ZPixmap, NULL, &b->shminfo,
+ width, height);
+ if (b->backxrb->ximage == NULL) {
+ _mesa_warning(NULL, "alloc_back_buffer: Shared memory error (XShmCreateImage), disabling.");
+ b->shm = 0;
+ return GL_FALSE;
+ }
+
+ b->shminfo.shmid = shmget( IPC_PRIVATE, b->backxrb->ximage->bytes_per_line
+ * b->backxrb->ximage->height, IPC_CREAT|0777 );
+ if (b->shminfo.shmid < 0) {
+ _mesa_warning(NULL, "shmget failed while allocating back buffer");
+ XDestroyImage( b->backxrb->ximage );
+ b->backxrb->ximage = NULL;
+ _mesa_warning(NULL, "alloc_back_buffer: Shared memory error (shmget), disabling.");
+ b->shm = 0;
+ return GL_FALSE;
+ }
+
+ b->shminfo.shmaddr = b->backxrb->ximage->data
+ = (char*)shmat( b->shminfo.shmid, 0, 0 );
+ if (b->shminfo.shmaddr == (char *) -1) {
+ _mesa_warning(NULL, "shmat() failed while allocating back buffer");
+ XDestroyImage( b->backxrb->ximage );
+ shmctl( b->shminfo.shmid, IPC_RMID, 0 );
+ b->backxrb->ximage = NULL;
+ _mesa_warning(NULL, "alloc_back_buffer: Shared memory error (shmat), disabling.");
+ b->shm = 0;
+ return GL_FALSE;
+ }
+
+ b->shminfo.readOnly = False;
+ mesaXErrorFlag = 0;
+ old_handler = XSetErrorHandler( mesaHandleXError );
+ /* This may trigger the X protocol error we're ready to catch: */
+ XShmAttach( b->xm_visual->display, &b->shminfo );
+ XSync( b->xm_visual->display, False );
+
+ if (mesaXErrorFlag) {
+ /* we are on a remote display, this error is normal, don't print it */
+ XFlush( b->xm_visual->display );
+ mesaXErrorFlag = 0;
+ XDestroyImage( b->backxrb->ximage );
+ shmdt( b->shminfo.shmaddr );
+ shmctl( b->shminfo.shmid, IPC_RMID, 0 );
+ b->backxrb->ximage = NULL;
+ b->shm = 0;
+ (void) XSetErrorHandler( old_handler );
+ return GL_FALSE;
+ }
+
+ shmctl( b->shminfo.shmid, IPC_RMID, 0 ); /* nobody else needs it */
+
+ /* Finally, try an XShmPutImage to be really sure the extension works */
+ gc = XCreateGC( b->xm_visual->display, b->frontxrb->drawable, 0, NULL );
+ XShmPutImage( b->xm_visual->display, b->frontxrb->drawable, gc,
+ b->backxrb->ximage, 0, 0, 0, 0, 1, 1 /*one pixel*/, False );
+ XSync( b->xm_visual->display, False );
+ XFreeGC( b->xm_visual->display, gc );
+ (void) XSetErrorHandler( old_handler );
+ if (mesaXErrorFlag) {
+ XFlush( b->xm_visual->display );
+ mesaXErrorFlag = 0;
+ XDestroyImage( b->backxrb->ximage );
+ shmdt( b->shminfo.shmaddr );
+ shmctl( b->shminfo.shmid, IPC_RMID, 0 );
+ b->backxrb->ximage = NULL;
+ b->shm = 0;
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+#else
+ /* Can't compile XSHM support */
+ return GL_FALSE;
+#endif
+}
+#endif
+
+
+
+
+/*
+ * Setup an off-screen pixmap or Ximage to use as the back buffer.
+ * Input: b - the X/Mesa buffer
+ */
+void
+xmesa_alloc_back_buffer( XMesaBuffer b, GLuint width, GLuint height )
+{
+ if (width == 0 || height == 0)
+ return;
+
+ if (b->db_state == BACK_XIMAGE) {
+ /* Deallocate the old backxrb->ximage, if any */
+ if (b->backxrb->ximage) {
+#if defined(USE_XSHM) && !defined(XFree86Server)
+ if (b->shm) {
+ XShmDetach( b->xm_visual->display, &b->shminfo );
+ XDestroyImage( b->backxrb->ximage );
+ shmdt( b->shminfo.shmaddr );
+ }
+ else
+#endif
+ XMesaDestroyImage( b->backxrb->ximage );
+ b->backxrb->ximage = NULL;
+ }
+
+ /* Allocate new back buffer */
+#ifdef XFree86Server
+ {
+ /* Allocate a regular XImage for the back buffer. */
+ b->backxrb->ximage = XMesaCreateImage(b->xm_visual->BitsPerPixel,
+ width, height, NULL);
+#else
+ if (b->shm == 0 || !alloc_shm_back_buffer(b, width, height)) {
+ /* Allocate a regular XImage for the back buffer. */
+ b->backxrb->ximage = XCreateImage( b->xm_visual->display,
+ b->xm_visual->visinfo->visual,
+ GET_VISUAL_DEPTH(b->xm_visual),
+ ZPixmap, 0, /* format, offset */
+ NULL,
+ width, height,
+ 8, 0 ); /* pad, bytes_per_line */
+#endif
+ if (!b->backxrb->ximage) {
+ _mesa_warning(NULL, "alloc_back_buffer: XCreateImage failed.");
+ }
+ b->backxrb->ximage->data = (char *) MALLOC( b->backxrb->ximage->height
+ * b->backxrb->ximage->bytes_per_line );
+ if (!b->backxrb->ximage->data) {
+ _mesa_warning(NULL, "alloc_back_buffer: MALLOC failed.");
+ XMesaDestroyImage( b->backxrb->ximage );
+ b->backxrb->ximage = NULL;
+ }
+ /* this call just updates the width/origin fields in the xrb */
+ b->backxrb->Base.AllocStorage(NULL, &b->backxrb->Base,
+ b->backxrb->Base.InternalFormat,
+ b->backxrb->ximage->width,
+ b->backxrb->ximage->height);
+ }
+ b->backxrb->pixmap = None;
+ }
+ else if (b->db_state==BACK_PIXMAP) {
+ if (!width)
+ width = 1;
+ if (!height)
+ height = 1;
+
+ /* Free the old back pixmap */
+ if (b->backxrb->pixmap) {
+ XMesaFreePixmap( b->xm_visual->display, b->backxrb->pixmap );
+ }
+ /* Allocate new back pixmap */
+ b->backxrb->pixmap = XMesaCreatePixmap( b->xm_visual->display,
+ b->frontxrb->drawable,
+ width, height,
+ GET_VISUAL_DEPTH(b->xm_visual) );
+ b->backxrb->ximage = NULL;
+ }
+}
+
+
+
+/*
+ * A replacement for XAllocColor. This function should never
+ * fail to allocate a color. When XAllocColor fails, we return
+ * the nearest matching color. If we have to allocate many colors
+ * this function isn't too efficient; the XQueryColors() could be
+ * done just once.
+ * Written by Michael Pichler, Brian Paul, Mark Kilgard
+ * Input: dpy - X display
+ * cmap - X colormap
+ * cmapSize - size of colormap
+ * In/Out: color - the XColor struct
+ * Output: exact - 1=exact color match, 0=closest match
+ * alloced - 1=XAlloc worked, 0=XAlloc failed
+ */
+static void
+noFaultXAllocColor( int client,
+ XMesaDisplay *dpy,
+ XMesaColormap cmap,
+ int cmapSize,
+ XMesaColor *color,
+ int *exact, int *alloced )
+{
+#ifdef XFree86Server
+ Pixel *ppixIn;
+ xrgb *ctable;
+#else
+ /* we'll try to cache ctable for better remote display performance */
+ static Display *prevDisplay = NULL;
+ static XMesaColormap prevCmap = 0;
+ static int prevCmapSize = 0;
+ static XMesaColor *ctable = NULL;
+#endif
+ XMesaColor subColor;
+ int i, bestmatch;
+ double mindist; /* 3*2^16^2 exceeds long int precision. */
+
+ (void) client;
+
+ /* First try just using XAllocColor. */
+#ifdef XFree86Server
+ if (AllocColor(cmap,
+ &color->red, &color->green, &color->blue,
+ &color->pixel,
+ client) == Success) {
+#else
+ if (XAllocColor(dpy, cmap, color)) {
+#endif
+ *exact = 1;
+ *alloced = 1;
+ return;
+ }
+
+ /* Alloc failed, search for closest match */
+
+ /* Retrieve color table entries. */
+ /* XXX alloca candidate. */
+#ifdef XFree86Server
+ ppixIn = (Pixel *) MALLOC(cmapSize * sizeof(Pixel));
+ ctable = (xrgb *) MALLOC(cmapSize * sizeof(xrgb));
+ for (i = 0; i < cmapSize; i++) {
+ ppixIn[i] = i;
+ }
+ QueryColors(cmap, cmapSize, ppixIn, ctable);
+#else
+ if (prevDisplay != dpy || prevCmap != cmap
+ || prevCmapSize != cmapSize || !ctable) {
+ /* free previously cached color table */
+ if (ctable)
+ _mesa_free(ctable);
+ /* Get the color table from X */
+ ctable = (XMesaColor *) MALLOC(cmapSize * sizeof(XMesaColor));
+ assert(ctable);
+ for (i = 0; i < cmapSize; i++) {
+ ctable[i].pixel = i;
+ }
+ XQueryColors(dpy, cmap, ctable, cmapSize);
+ prevDisplay = dpy;
+ prevCmap = cmap;
+ prevCmapSize = cmapSize;
+ }
+#endif
+
+ /* Find best match. */
+ bestmatch = -1;
+ mindist = 0.0;
+ for (i = 0; i < cmapSize; i++) {
+ double dr = 0.30 * ((double) color->red - (double) ctable[i].red);
+ double dg = 0.59 * ((double) color->green - (double) ctable[i].green);
+ double db = 0.11 * ((double) color->blue - (double) ctable[i].blue);
+ double dist = dr * dr + dg * dg + db * db;
+ if (bestmatch < 0 || dist < mindist) {
+ bestmatch = i;
+ mindist = dist;
+ }
+ }
+
+ /* Return result. */
+ subColor.red = ctable[bestmatch].red;
+ subColor.green = ctable[bestmatch].green;
+ subColor.blue = ctable[bestmatch].blue;
+ /* Try to allocate the closest match color. This should only
+ * fail if the cell is read/write. Otherwise, we're incrementing
+ * the cell's reference count.
+ */
+#ifdef XFree86Server
+ if (AllocColor(cmap,
+ &subColor.red, &subColor.green, &subColor.blue,
+ &subColor.pixel,
+ client) == Success) {
+#else
+ if (XAllocColor(dpy, cmap, &subColor)) {
+#endif
+ *alloced = 1;
+ }
+ else {
+ /* do this to work around a problem reported by Frank Ortega */
+ subColor.pixel = (unsigned long) bestmatch;
+ subColor.red = ctable[bestmatch].red;
+ subColor.green = ctable[bestmatch].green;
+ subColor.blue = ctable[bestmatch].blue;
+ subColor.flags = DoRed | DoGreen | DoBlue;
+ *alloced = 0;
+ }
+#ifdef XFree86Server
+ _mesa_free(ppixIn);
+ _mesa_free(ctable);
+#else
+ /* don't free table, save it for next time */
+#endif
+
+ *color = subColor;
+ *exact = 0;
+}
+
+
+
+
+/*
+ * Do setup for PF_GRAYSCALE pixel format.
+ * Note that buffer may be NULL.
+ */
+static GLboolean setup_grayscale( int client, XMesaVisual v,
+ XMesaBuffer buffer, XMesaColormap cmap )
+{
+ if (GET_VISUAL_DEPTH(v)<4 || GET_VISUAL_DEPTH(v)>16) {
+ return GL_FALSE;
+ }
+
+ if (buffer) {
+ XMesaBuffer prevBuffer;
+
+ if (!cmap) {
+ return GL_FALSE;
+ }
+
+ prevBuffer = find_xmesa_buffer(v->display, cmap, buffer);
+ if (prevBuffer &&
+ (buffer->xm_visual->mesa_visual.rgbMode ==
+ prevBuffer->xm_visual->mesa_visual.rgbMode)) {
+ /* Copy colormap stuff from previous XMesaBuffer which uses same
+ * X colormap. Do this to avoid time spent in noFaultXAllocColor.
+ */
+ copy_colortable_info(buffer, prevBuffer);
+ }
+ else {
+ /* Allocate 256 shades of gray */
+ int gray;
+ int colorsfailed = 0;
+ for (gray=0;gray<256;gray++) {
+ GLint r = gamma_adjust( v->RedGamma, gray, 255 );
+ GLint g = gamma_adjust( v->GreenGamma, gray, 255 );
+ GLint b = gamma_adjust( v->BlueGamma, gray, 255 );
+ int exact, alloced;
+ XMesaColor xcol;
+ xcol.red = (r << 8) | r;
+ xcol.green = (g << 8) | g;
+ xcol.blue = (b << 8) | b;
+ noFaultXAllocColor( client, v->display,
+ cmap, GET_COLORMAP_SIZE(v),
+ &xcol, &exact, &alloced );
+ if (!exact) {
+ colorsfailed++;
+ }
+ if (alloced) {
+ assert(buffer->num_alloced<256);
+ buffer->alloced_colors[buffer->num_alloced] = xcol.pixel;
+ buffer->num_alloced++;
+ }
+
+ /*OLD
+ assert(gray < 576);
+ buffer->color_table[gray*3+0] = xcol.pixel;
+ buffer->color_table[gray*3+1] = xcol.pixel;
+ buffer->color_table[gray*3+2] = xcol.pixel;
+ assert(xcol.pixel < 65536);
+ buffer->pixel_to_r[xcol.pixel] = gray * 30 / 100;
+ buffer->pixel_to_g[xcol.pixel] = gray * 59 / 100;
+ buffer->pixel_to_b[xcol.pixel] = gray * 11 / 100;
+ */
+ buffer->color_table[gray] = xcol.pixel;
+ assert(xcol.pixel < 65536);
+ buffer->pixel_to_r[xcol.pixel] = gray;
+ buffer->pixel_to_g[xcol.pixel] = gray;
+ buffer->pixel_to_b[xcol.pixel] = gray;
+ }
+
+ if (colorsfailed && _mesa_getenv("MESA_DEBUG")) {
+ _mesa_warning(NULL,
+ "Note: %d out of 256 needed colors do not match exactly.\n",
+ colorsfailed );
+ }
+ }
+ }
+
+ v->dithered_pf = PF_Grayscale;
+ v->undithered_pf = PF_Grayscale;
+ return GL_TRUE;
+}
+
+
+
+/*
+ * Setup RGB rendering for a window with a PseudoColor, StaticColor,
+ * or 8-bit TrueColor visual visual. We try to allocate a palette of 225
+ * colors (5 red, 9 green, 5 blue) and dither to approximate a 24-bit RGB
+ * color. While this function was originally designed just for 8-bit
+ * visuals, it has also proven to work from 4-bit up to 16-bit visuals.
+ * Dithering code contributed by Bob Mercier.
+ */
+static GLboolean setup_dithered_color( int client, XMesaVisual v,
+ XMesaBuffer buffer, XMesaColormap cmap )
+{
+ if (GET_VISUAL_DEPTH(v)<4 || GET_VISUAL_DEPTH(v)>16) {
+ return GL_FALSE;
+ }
+
+ if (buffer) {
+ XMesaBuffer prevBuffer;
+
+ if (!cmap) {
+ return GL_FALSE;
+ }
+
+ prevBuffer = find_xmesa_buffer(v->display, cmap, buffer);
+ if (prevBuffer &&
+ (buffer->xm_visual->mesa_visual.rgbMode ==
+ prevBuffer->xm_visual->mesa_visual.rgbMode)) {
+ /* Copy colormap stuff from previous, matching XMesaBuffer.
+ * Do this to avoid time spent in noFaultXAllocColor.
+ */
+ copy_colortable_info(buffer, prevBuffer);
+ }
+ else {
+ /* Allocate X colors and initialize color_table[], red_table[], etc */
+ int r, g, b, i;
+ int colorsfailed = 0;
+ for (r = 0; r < DITH_R; r++) {
+ for (g = 0; g < DITH_G; g++) {
+ for (b = 0; b < DITH_B; b++) {
+ XMesaColor xcol;
+ int exact, alloced;
+ xcol.red =gamma_adjust(v->RedGamma, r*65535/(DITH_R-1),65535);
+ xcol.green=gamma_adjust(v->GreenGamma, g*65535/(DITH_G-1),65535);
+ xcol.blue =gamma_adjust(v->BlueGamma, b*65535/(DITH_B-1),65535);
+ noFaultXAllocColor( client, v->display,
+ cmap, GET_COLORMAP_SIZE(v),
+ &xcol, &exact, &alloced );
+ if (!exact) {
+ colorsfailed++;
+ }
+ if (alloced) {
+ assert(buffer->num_alloced<256);
+ buffer->alloced_colors[buffer->num_alloced] = xcol.pixel;
+ buffer->num_alloced++;
+ }
+ i = DITH_MIX( r, g, b );
+ assert(i < 576);
+ buffer->color_table[i] = xcol.pixel;
+ assert(xcol.pixel < 65536);
+ buffer->pixel_to_r[xcol.pixel] = r * 255 / (DITH_R-1);
+ buffer->pixel_to_g[xcol.pixel] = g * 255 / (DITH_G-1);
+ buffer->pixel_to_b[xcol.pixel] = b * 255 / (DITH_B-1);
+ }
+ }
+ }
+
+ if (colorsfailed && _mesa_getenv("MESA_DEBUG")) {
+ _mesa_warning(NULL,
+ "Note: %d out of %d needed colors do not match exactly.\n",
+ colorsfailed, DITH_R * DITH_G * DITH_B );
+ }
+ }
+ }
+
+ v->dithered_pf = PF_Dither;
+ v->undithered_pf = PF_Lookup;
+ return GL_TRUE;
+}
+
+
+/*
+ * Setup for Hewlett Packard Color Recovery 8-bit TrueColor mode.
+ * HPCR simulates 24-bit color fidelity with an 8-bit frame buffer.
+ * Special dithering tables have to be initialized.
+ */
+static void setup_8bit_hpcr( XMesaVisual v )
+{
+ /* HP Color Recovery contributed by: Alex De Bruyn (ad@lms.be)
+ * To work properly, the atom _HP_RGB_SMOOTH_MAP_LIST must be defined
+ * on the root window AND the colormap obtainable by XGetRGBColormaps
+ * for that atom must be set on the window. (see also tkInitWindow)
+ * If that colormap is not set, the output will look stripy.
+ */
+
+ /* Setup color tables with gamma correction */
+ int i;
+ double g;
+
+ g = 1.0 / v->RedGamma;
+ for (i=0; i<256; i++) {
+ GLint red = IROUND_POS(255.0 * _mesa_pow( hpcr_rgbTbl[0][i]/255.0, g ));
+ v->hpcr_rgbTbl[0][i] = CLAMP( red, 16, 239 );
+ }
+
+ g = 1.0 / v->GreenGamma;
+ for (i=0; i<256; i++) {
+ GLint green = IROUND_POS(255.0 * _mesa_pow( hpcr_rgbTbl[1][i]/255.0, g ));
+ v->hpcr_rgbTbl[1][i] = CLAMP( green, 16, 239 );
+ }
+
+ g = 1.0 / v->BlueGamma;
+ for (i=0; i<256; i++) {
+ GLint blue = IROUND_POS(255.0 * _mesa_pow( hpcr_rgbTbl[2][i]/255.0, g ));
+ v->hpcr_rgbTbl[2][i] = CLAMP( blue, 32, 223 );
+ }
+ v->undithered_pf = PF_HPCR; /* can't really disable dithering for now */
+ v->dithered_pf = PF_HPCR;
+
+ /* which method should I use to clear */
+ /* GL_FALSE: keep the ordinary method */
+ /* GL_TRUE : clear with dither pattern */
+ v->hpcr_clear_flag = _mesa_getenv("MESA_HPCR_CLEAR") ? GL_TRUE : GL_FALSE;
+
+ if (v->hpcr_clear_flag) {
+ v->hpcr_clear_pixmap = XMesaCreatePixmap(v->display,
+ DefaultRootWindow(v->display),
+ 16, 2, 8);
+#ifndef XFree86Server
+ v->hpcr_clear_ximage = XGetImage(v->display, v->hpcr_clear_pixmap,
+ 0, 0, 16, 2, AllPlanes, ZPixmap);
+#endif
+ }
+}
+
+
+/*
+ * Setup RGB rendering for a window with a True/DirectColor visual.
+ */
+static void setup_truecolor( XMesaVisual v, XMesaBuffer buffer,
+ XMesaColormap cmap )
+{
+ unsigned long rmask, gmask, bmask;
+ (void) buffer;
+ (void) cmap;
+
+ /* Compute red multiplier (mask) and bit shift */
+ v->rshift = 0;
+ rmask = GET_REDMASK(v);
+ while ((rmask & 1)==0) {
+ v->rshift++;
+ rmask = rmask >> 1;
+ }
+
+ /* Compute green multiplier (mask) and bit shift */
+ v->gshift = 0;
+ gmask = GET_GREENMASK(v);
+ while ((gmask & 1)==0) {
+ v->gshift++;
+ gmask = gmask >> 1;
+ }
+
+ /* Compute blue multiplier (mask) and bit shift */
+ v->bshift = 0;
+ bmask = GET_BLUEMASK(v);
+ while ((bmask & 1)==0) {
+ v->bshift++;
+ bmask = bmask >> 1;
+ }
+
+ /*
+ * Compute component-to-pixel lookup tables and dithering kernel
+ */
+ {
+ static GLubyte kernel[16] = {
+ 0*16, 8*16, 2*16, 10*16,
+ 12*16, 4*16, 14*16, 6*16,
+ 3*16, 11*16, 1*16, 9*16,
+ 15*16, 7*16, 13*16, 5*16,
+ };
+ GLint rBits = bitcount(rmask);
+ GLint gBits = bitcount(gmask);
+ GLint bBits = bitcount(bmask);
+ GLint maxBits;
+ GLuint i;
+
+ /* convert pixel components in [0,_mask] to RGB values in [0,255] */
+ for (i=0; i<=rmask; i++)
+ v->PixelToR[i] = (unsigned char) ((i * 255) / rmask);
+ for (i=0; i<=gmask; i++)
+ v->PixelToG[i] = (unsigned char) ((i * 255) / gmask);
+ for (i=0; i<=bmask; i++)
+ v->PixelToB[i] = (unsigned char) ((i * 255) / bmask);
+
+ /* convert RGB values from [0,255] to pixel components */
+
+ for (i=0;i<256;i++) {
+ GLint r = gamma_adjust(v->RedGamma, i, 255);
+ GLint g = gamma_adjust(v->GreenGamma, i, 255);
+ GLint b = gamma_adjust(v->BlueGamma, i, 255);
+ v->RtoPixel[i] = (r >> (8-rBits)) << v->rshift;
+ v->GtoPixel[i] = (g >> (8-gBits)) << v->gshift;
+ v->BtoPixel[i] = (b >> (8-bBits)) << v->bshift;
+ }
+ /* overflow protection */
+ for (i=256;i<512;i++) {
+ v->RtoPixel[i] = v->RtoPixel[255];
+ v->GtoPixel[i] = v->GtoPixel[255];
+ v->BtoPixel[i] = v->BtoPixel[255];
+ }
+
+ /* setup dithering kernel */
+ maxBits = rBits;
+ if (gBits > maxBits) maxBits = gBits;
+ if (bBits > maxBits) maxBits = bBits;
+ for (i=0;i<16;i++) {
+ v->Kernel[i] = kernel[i] >> maxBits;
+ }
+
+ v->undithered_pf = PF_Truecolor;
+ v->dithered_pf = (GET_VISUAL_DEPTH(v)<24) ? PF_Dither_True : PF_Truecolor;
+ }
+
+ /*
+ * Now check for TrueColor visuals which we can optimize.
+ */
+ if ( GET_REDMASK(v) ==0x0000ff
+ && GET_GREENMASK(v)==0x00ff00
+ && GET_BLUEMASK(v) ==0xff0000
+ && CHECK_BYTE_ORDER(v)
+ && v->BitsPerPixel==32
+ && sizeof(GLuint)==4
+ && v->RedGamma==1.0 && v->GreenGamma==1.0 && v->BlueGamma==1.0) {
+ /* common 32 bpp config used on SGI, Sun */
+ v->undithered_pf = v->dithered_pf = PF_8A8B8G8R;
+ }
+ else if (GET_REDMASK(v) ==0xff0000
+ && GET_GREENMASK(v)==0x00ff00
+ && GET_BLUEMASK(v) ==0x0000ff
+ && CHECK_BYTE_ORDER(v)
+ && v->BitsPerPixel==32
+ && sizeof(GLuint)==4
+ && v->RedGamma==1.0 && v->GreenGamma==1.0 && v->BlueGamma==1.0) {
+ /* common 32 bpp config used on Linux, HP, IBM */
+ if (GET_VISUAL_DEPTH(v)==32)
+ v->undithered_pf = v->dithered_pf = PF_8A8R8G8B;
+ else
+ v->undithered_pf = v->dithered_pf = PF_8R8G8B;
+ }
+ else if (GET_REDMASK(v) ==0xff0000
+ && GET_GREENMASK(v)==0x00ff00
+ && GET_BLUEMASK(v) ==0x0000ff
+ && CHECK_BYTE_ORDER(v)
+ && v->BitsPerPixel==24
+ && sizeof(GLuint)==4
+ && v->RedGamma==1.0 && v->GreenGamma==1.0 && v->BlueGamma==1.0) {
+ /* common packed 24 bpp config used on Linux */
+ v->undithered_pf = v->dithered_pf = PF_8R8G8B24;
+ }
+ else if (GET_REDMASK(v) ==0xf800
+ && GET_GREENMASK(v)==0x07e0
+ && GET_BLUEMASK(v) ==0x001f
+ && CHECK_BYTE_ORDER(v)
+ && v->BitsPerPixel==16
+ && sizeof(GLushort)==2
+ && v->RedGamma==1.0 && v->GreenGamma==1.0 && v->BlueGamma==1.0) {
+ /* 5-6-5 color weight on common PC VGA boards */
+ v->undithered_pf = PF_5R6G5B;
+ v->dithered_pf = PF_Dither_5R6G5B;
+ }
+ else if (GET_REDMASK(v) ==0xe0
+ && GET_GREENMASK(v)==0x1c
+ && GET_BLUEMASK(v) ==0x03
+ && CHECK_FOR_HPCR(v)) {
+ setup_8bit_hpcr( v );
+ }
+}
+
+
+
+/*
+ * Setup RGB rendering for a window with a monochrome visual.
+ */
+static void setup_monochrome( XMesaVisual v, XMesaBuffer b )
+{
+ (void) b;
+ v->dithered_pf = v->undithered_pf = PF_1Bit;
+ /* if black=1 then we must flip pixel values */
+ v->bitFlip = (GET_BLACK_PIXEL(v) != 0);
+}
+
+
+
+/*
+ * When a context is "made current" for the first time, we can finally
+ * finish initializing the context's visual and buffer information.
+ * Input: v - the XMesaVisual to initialize
+ * b - the XMesaBuffer to initialize (may be NULL)
+ * rgb_flag - TRUE = RGBA mode, FALSE = color index mode
+ * window - the window/pixmap we're rendering into
+ * cmap - the colormap associated with the window/pixmap
+ * Return: GL_TRUE=success, GL_FALSE=failure
+ */
+static GLboolean initialize_visual_and_buffer( int client,
+ XMesaVisual v,
+ XMesaBuffer b,
+ GLboolean rgb_flag,
+ XMesaDrawable window,
+ XMesaColormap cmap )
+{
+ struct xmesa_renderbuffer *front_xrb, *back_xrb;
+#ifndef XFree86Server
+ XGCValues gcvalues;
+#endif
+
+ if (b) {
+ assert(b->xm_visual == v);
+ }
+
+ if (b) {
+ front_xrb = b->frontxrb;
+ back_xrb = b->backxrb;
+ }
+ else {
+ front_xrb = back_xrb = NULL;
+ }
+
+ /* Save true bits/pixel */
+ v->BitsPerPixel = bits_per_pixel(v);
+ assert(v->BitsPerPixel > 0);
+
+
+ if (rgb_flag==GL_FALSE) {
+ /* COLOR-INDEXED WINDOW:
+ * Even if the visual is TrueColor or DirectColor we treat it as
+ * being color indexed. This is weird but might be useful to someone.
+ */
+ v->dithered_pf = v->undithered_pf = PF_Index;
+ v->mesa_visual.indexBits = GET_VISUAL_DEPTH(v);
+ }
+ else {
+ /* RGB WINDOW:
+ * We support RGB rendering into almost any kind of visual.
+ */
+ const int xclass = v->mesa_visual.visualType;
+ if (xclass==GLX_TRUE_COLOR || xclass==GLX_DIRECT_COLOR) {
+ setup_truecolor( v, b, cmap );
+ }
+ else if (xclass==GLX_STATIC_GRAY && GET_VISUAL_DEPTH(v)==1) {
+ setup_monochrome( v, b );
+ }
+ else if (xclass==GLX_GRAY_SCALE || xclass==GLX_STATIC_GRAY) {
+ if (!setup_grayscale( client, v, b, cmap )) {
+ return GL_FALSE;
+ }
+ }
+ else if ((xclass==GLX_PSEUDO_COLOR || xclass==GLX_STATIC_COLOR)
+ && GET_VISUAL_DEPTH(v)>=4 && GET_VISUAL_DEPTH(v)<=16) {
+ if (!setup_dithered_color( client, v, b, cmap )) {
+ return GL_FALSE;
+ }
+ }
+ else {
+ _mesa_warning(NULL, "XMesa: RGB mode rendering not supported in given visual.");
+ return GL_FALSE;
+ }
+ v->mesa_visual.indexBits = 0;
+
+ if (_mesa_getenv("MESA_NO_DITHER")) {
+ v->dithered_pf = v->undithered_pf;
+ }
+ }
+
+
+ /*
+ * If MESA_INFO env var is set print out some debugging info
+ * which can help Brian figure out what's going on when a user
+ * reports bugs.
+ */
+ if (_mesa_getenv("MESA_INFO")) {
+ _mesa_printf("X/Mesa visual = %p\n", (void *) v);
+ _mesa_printf("X/Mesa dithered pf = %u\n", v->dithered_pf);
+ _mesa_printf("X/Mesa undithered pf = %u\n", v->undithered_pf);
+ _mesa_printf("X/Mesa level = %d\n", v->mesa_visual.level);
+ _mesa_printf("X/Mesa depth = %d\n", GET_VISUAL_DEPTH(v));
+ _mesa_printf("X/Mesa bits per pixel = %d\n", v->BitsPerPixel);
+ }
+
+ if (b && window) {
+ /* Do window-specific initializations */
+
+ b->frontxrb->drawable = window;
+ b->frontxrb->pixmap = (XMesaPixmap) window;
+
+ /* Setup for single/double buffering */
+ if (v->mesa_visual.doubleBufferMode) {
+ /* Double buffered */
+#ifndef XFree86Server
+ b->shm = check_for_xshm( v->display );
+#endif
+ xmesa_alloc_back_buffer(b, b->mesa_buffer.Width, b->mesa_buffer.Height);
+ }
+
+ /* X11 graphics contexts */
+#ifdef XFree86Server
+ b->gc = CreateScratchGC(v->display, window->depth);
+#else
+ b->gc = XCreateGC( v->display, window, 0, NULL );
+#endif
+ XMesaSetFunction( v->display, b->gc, GXcopy );
+
+ /* cleargc - for glClear() */
+#ifdef XFree86Server
+ b->cleargc = CreateScratchGC(v->display, window->depth);
+#else
+ b->cleargc = XCreateGC( v->display, window, 0, NULL );
+#endif
+ XMesaSetFunction( v->display, b->cleargc, GXcopy );
+
+ /*
+ * Don't generate Graphics Expose/NoExpose events in swapbuffers().
+ * Patch contributed by Michael Pichler May 15, 1995.
+ */
+#ifdef XFree86Server
+ b->swapgc = CreateScratchGC(v->display, window->depth);
+ {
+ CARD32 v[1];
+ v[0] = FALSE;
+ dixChangeGC(NullClient, b->swapgc, GCGraphicsExposures, v, NULL);
+ }
+#else
+ gcvalues.graphics_exposures = False;
+ b->swapgc = XCreateGC( v->display, window,
+ GCGraphicsExposures, &gcvalues);
+#endif
+ XMesaSetFunction( v->display, b->swapgc, GXcopy );
+ /*
+ * Set fill style and tile pixmap once for all for HPCR stuff
+ * (instead of doing it each time in clear_color_HPCR_pixmap())
+ * Initialize whole stuff
+ * Patch contributed by Jacques Leroy March 8, 1998.
+ */
+ if (v->hpcr_clear_flag && back_xrb->pixmap) {
+ int i;
+ for (i=0; i<16; i++)
+ {
+ XMesaPutPixel(v->hpcr_clear_ximage, i, 0, 0);
+ XMesaPutPixel(v->hpcr_clear_ximage, i, 1, 0);
+ }
+ XMesaPutImage(b->display, (XMesaDrawable)v->hpcr_clear_pixmap,
+ b->cleargc, v->hpcr_clear_ximage, 0, 0, 0, 0, 16, 2);
+ XMesaSetFillStyle( v->display, b->cleargc, FillTiled);
+ XMesaSetTile( v->display, b->cleargc, v->hpcr_clear_pixmap );
+ }
+
+ /* Initialize the row buffer XImage for use in write_color_span() */
+#ifdef XFree86Server
+ b->rowimage = XMesaCreateImage(GET_VISUAL_DEPTH(v), MAX_WIDTH, 1,
+ (char *)MALLOC(MAX_WIDTH*4));
+#else
+ b->rowimage = XCreateImage( v->display,
+ v->visinfo->visual,
+ v->visinfo->depth,
+ ZPixmap, 0, /*format, offset*/
+ (char*) MALLOC(MAX_WIDTH*4), /*data*/
+ MAX_WIDTH, 1, /*width, height*/
+ 32, /*bitmap_pad*/
+ 0 /*bytes_per_line*/ );
+#endif
+ if (!b->rowimage)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+
+/*
+ * Convert an RGBA color to a pixel value.
+ */
+unsigned long
+xmesa_color_to_pixel(GLcontext *ctx,
+ GLubyte r, GLubyte g, GLubyte b, GLubyte a,
+ GLuint pixelFormat)
+{
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ switch (pixelFormat) {
+ case PF_Index:
+ return 0;
+ case PF_Truecolor:
+ {
+ unsigned long p;
+ PACK_TRUECOLOR( p, r, g, b );
+ return p;
+ }
+ case PF_8A8B8G8R:
+ return PACK_8A8B8G8R( r, g, b, a );
+ case PF_8A8R8G8B:
+ return PACK_8A8R8G8B( r, g, b, a );
+ case PF_8R8G8B:
+ /* fall through */
+ case PF_8R8G8B24:
+ return PACK_8R8G8B( r, g, b );
+ case PF_5R6G5B:
+ return PACK_5R6G5B( r, g, b );
+ case PF_Dither:
+ {
+ DITHER_SETUP;
+ return DITHER( 1, 0, r, g, b );
+ }
+ case PF_1Bit:
+ /* 382 = (3*255)/2 */
+ return ((r+g+b) > 382) ^ xmesa->xm_visual->bitFlip;
+ case PF_HPCR:
+ return DITHER_HPCR(1, 1, r, g, b);
+ case PF_Lookup:
+ {
+ LOOKUP_SETUP;
+ return LOOKUP( r, g, b );
+ }
+ case PF_Grayscale:
+ return GRAY_RGB( r, g, b );
+ case PF_Dither_True:
+ /* fall through */
+ case PF_Dither_5R6G5B:
+ {
+ unsigned long p;
+ PACK_TRUEDITHER(p, 1, 0, r, g, b);
+ return p;
+ }
+ default:
+ _mesa_problem(ctx, "Bad pixel format in xmesa_color_to_pixel");
+ }
+ return 0;
+}
+
+
+#define NUM_VISUAL_TYPES 6
+
+/**
+ * Convert an X visual type to a GLX visual type.
+ *
+ * \param visualType X visual type (i.e., \c TrueColor, \c StaticGray, etc.)
+ * to be converted.
+ * \return If \c visualType is a valid X visual type, a GLX visual type will
+ * be returned. Otherwise \c GLX_NONE will be returned.
+ *
+ * \note
+ * This code was lifted directly from lib/GL/glx/glcontextmodes.c in the
+ * DRI CVS tree.
+ */
+static GLint
+xmesa_convert_from_x_visual_type( int visualType )
+{
+ static const int glx_visual_types[ NUM_VISUAL_TYPES ] = {
+ GLX_STATIC_GRAY, GLX_GRAY_SCALE,
+ GLX_STATIC_COLOR, GLX_PSEUDO_COLOR,
+ GLX_TRUE_COLOR, GLX_DIRECT_COLOR
+ };
+
+ return ( (unsigned) visualType < NUM_VISUAL_TYPES )
+ ? glx_visual_types[ visualType ] : GLX_NONE;
+}
+
+
+/**********************************************************************/
+/***** Public Functions *****/
+/**********************************************************************/
+
+
+/*
+ * Create a new X/Mesa visual.
+ * 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
+ * Return; a new XMesaVisual or 0 if error.
+ */
+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_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;
+ GLint red_bits, green_bits, blue_bits, alpha_bits;
+
+ /* For debugging only */
+ if (_mesa_getenv("MESA_XSYNC")) {
+ /* This makes debugging X easier.
+ * In your debugger, set a breakpoint on _XError to stop when an
+ * X protocol error is generated.
+ */
+#ifdef XFree86Server
+ /* NOT_NEEDED */
+#else
+ XSynchronize( display, 1 );
+#endif
+ }
+
+ v = (XMesaVisual) CALLOC_STRUCT(xmesa_visual);
+ if (!v) {
+ return NULL;
+ }
+
+ /*
+ * In the X server, NULL is passed in for the display. It will have
+ * to be set before using this visual. See XMesaSetVisualDisplay()
+ * below.
+ */
+ v->display = display;
+
+ /* Save a copy of the XVisualInfo struct because the user may X_mesa_free()
+ * the struct but we may need some of the information contained in it
+ * at a later time.
+ */
+#ifndef XFree86Server
+ v->visinfo = (XVisualInfo *) MALLOC(sizeof(*visinfo));
+ if(!v->visinfo) {
+ _mesa_free(v);
+ return NULL;
+ }
+ MEMCPY(v->visinfo, visinfo, sizeof(*visinfo));
+#endif
+
+ /* check for MESA_GAMMA environment variable */
+ gamma = _mesa_getenv("MESA_GAMMA");
+ if (gamma) {
+ v->RedGamma = v->GreenGamma = v->BlueGamma = 0.0;
+ sscanf( gamma, "%f %f %f", &v->RedGamma, &v->GreenGamma, &v->BlueGamma );
+ if (v->RedGamma<=0.0) v->RedGamma = 1.0;
+ if (v->GreenGamma<=0.0) v->GreenGamma = v->RedGamma;
+ if (v->BlueGamma<=0.0) v->BlueGamma = v->RedGamma;
+ }
+ else {
+ v->RedGamma = v->GreenGamma = v->BlueGamma = 1.0;
+ }
+
+ v->ximage_flag = ximage_flag;
+
+#ifdef XFree86Server
+ /* We could calculate these values by ourselves. nplanes is either the sum
+ * of the red, green, and blue bits or the number index bits.
+ * ColormapEntries is either (1U << index_bits) or
+ * (1U << max(redBits, greenBits, blueBits)).
+ */
+ v->nplanes = visinfo->nplanes;
+ v->ColormapEntries = visinfo->ColormapEntries;
+
+ v->mesa_visual.redMask = visinfo->redMask;
+ v->mesa_visual.greenMask = visinfo->greenMask;
+ v->mesa_visual.blueMask = visinfo->blueMask;
+ v->mesa_visual.visualID = visinfo->vid;
+ v->mesa_visual.screen = 0; /* FIXME: What should be done here? */
+#else
+ v->mesa_visual.redMask = visinfo->red_mask;
+ v->mesa_visual.greenMask = visinfo->green_mask;
+ v->mesa_visual.blueMask = visinfo->blue_mask;
+ v->mesa_visual.visualID = visinfo->visualid;
+ v->mesa_visual.screen = visinfo->screen;
+#endif
+
+#if defined(XFree86Server) || !(defined(__cplusplus) || defined(c_plusplus))
+ v->mesa_visual.visualType = xmesa_convert_from_x_visual_type(visinfo->class);
+#else
+ v->mesa_visual.visualType = xmesa_convert_from_x_visual_type(visinfo->c_class);
+#endif
+
+ v->mesa_visual.visualRating = visualCaveat;
+
+ (void) initialize_visual_and_buffer( 0, v, NULL, rgb_flag, 0, 0 );
+
+ {
+ const int xclass = v->mesa_visual.visualType;
+ if (xclass==GLX_TRUE_COLOR || xclass==GLX_DIRECT_COLOR) {
+ red_bits = bitcount(GET_REDMASK(v));
+ green_bits = bitcount(GET_GREENMASK(v));
+ blue_bits = bitcount(GET_BLUEMASK(v));
+ alpha_bits = 0;
+ }
+ else {
+ /* this is an approximation */
+ int depth;
+ depth = GET_VISUAL_DEPTH(v);
+ red_bits = depth / 3;
+ depth -= red_bits;
+ green_bits = depth / 2;
+ depth -= green_bits;
+ blue_bits = depth;
+ alpha_bits = 0;
+ assert( red_bits + green_bits + blue_bits == GET_VISUAL_DEPTH(v) );
+ }
+ }
+
+ if (alpha_flag && alpha_bits == 0)
+ alpha_bits = 8;
+
+ _mesa_initialize_visual( &v->mesa_visual,
+ rgb_flag, db_flag, stereo_flag,
+ red_bits, green_bits,
+ blue_bits, alpha_bits,
+ v->mesa_visual.indexBits,
+ depth_size,
+ stencil_size,
+ accum_red_size, accum_green_size,
+ accum_blue_size, accum_alpha_size,
+ 0 );
+
+ /* XXX minor hack */
+ v->mesa_visual.level = level;
+ return v;
+}
+
+
+void XMesaSetVisualDisplay( XMesaDisplay *dpy, XMesaVisual v )
+{
+ v->display = dpy;
+}
+
+
+void XMesaDestroyVisual( XMesaVisual v )
+{
+#ifndef XFree86Server
+ _mesa_free(v->visinfo);
+#endif
+ _mesa_free(v);
+}
+
+
+
+/**
+ * Create a new XMesaContext.
+ * \param v the XMesaVisual
+ * \param share_list another XMesaContext with which to share display
+ * lists or NULL if no sharing is wanted.
+ * \return an XMesaContext or NULL if error.
+ */
+XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list )
+{
+ static GLboolean firstTime = GL_TRUE;
+ XMesaContext c;
+ GLcontext *mesaCtx;
+ struct dd_function_table functions;
+ TNLcontext *tnl;
+
+ if (firstTime) {
+ _glthread_INIT_MUTEX(_xmesa_lock);
+ firstTime = GL_FALSE;
+ }
+
+ /* Note: the XMesaContext contains a Mesa GLcontext struct (inheritance) */
+ c = (XMesaContext) CALLOC_STRUCT(xmesa_context);
+ if (!c)
+ return NULL;
+
+ mesaCtx = &(c->mesa);
+
+ /* initialize with default driver functions, then plug in XMesa funcs */
+ _mesa_init_driver_functions(&functions);
+ xmesa_init_driver_functions(v, &functions);
+ if (!_mesa_initialize_context(mesaCtx, &v->mesa_visual,
+ share_list ? &(share_list->mesa) : (GLcontext *) NULL,
+ &functions, (void *) c)) {
+ _mesa_free(c);
+ return NULL;
+ }
+
+ _mesa_enable_sw_extensions(mesaCtx);
+ _mesa_enable_1_3_extensions(mesaCtx);
+ _mesa_enable_1_4_extensions(mesaCtx);
+ _mesa_enable_1_5_extensions(mesaCtx);
+ _mesa_enable_2_0_extensions(mesaCtx);
+#if SWTC
+ if (c->Mesa_DXTn) {
+ _mesa_enable_extension(c, "GL_EXT_texture_compression_s3tc");
+ _mesa_enable_extension(c, "GL_S3_s3tc");
+ }
+ _mesa_enable_extension(c, "GL_3DFX_texture_compression_FXT1");
+#endif
+
+ /* finish up xmesa context initializations */
+ c->swapbytes = CHECK_BYTE_ORDER(v) ? GL_FALSE : GL_TRUE;
+ c->xm_visual = v;
+ c->xm_buffer = NULL; /* set later by XMesaMakeCurrent */
+ c->display = v->display;
+ c->pixelformat = v->dithered_pf; /* Dithering is enabled by default */
+
+ /* Initialize the software rasterizer and helper modules.
+ */
+ if (!_swrast_CreateContext( mesaCtx ) ||
+ !_ac_CreateContext( mesaCtx ) ||
+ !_tnl_CreateContext( mesaCtx ) ||
+ !_swsetup_CreateContext( mesaCtx )) {
+ _mesa_free_context_data(&c->mesa);
+ _mesa_free(c);
+ return NULL;
+ }
+
+ /* tnl setup */
+ tnl = TNL_CONTEXT(mesaCtx);
+ tnl->Driver.RunPipeline = _tnl_run_pipeline;
+ /* swrast setup */
+ xmesa_register_swrast_functions( mesaCtx );
+ _swsetup_Wakeup(mesaCtx);
+
+ return c;
+}
+
+
+
+void XMesaDestroyContext( XMesaContext c )
+{
+ GLcontext *mesaCtx = &c->mesa;
+#ifdef FX
+ XMesaBuffer xmbuf = XMESA_BUFFER(mesaCtx->DrawBuffer);
+
+ if (xmbuf && xmbuf->FXctx)
+ fxMesaDestroyContext(xmbuf->FXctx);
+#endif
+ _swsetup_DestroyContext( mesaCtx );
+ _swrast_DestroyContext( mesaCtx );
+ _tnl_DestroyContext( mesaCtx );
+ _ac_DestroyContext( mesaCtx );
+ _mesa_free_context_data( mesaCtx );
+ _mesa_free( c );
+}
+
+
+
+/*
+ * XXX this isn't a public function! It's a hack for the 3Dfx driver.
+ * Create a new XMesaBuffer from an X window.
+ * Input: v - the XMesaVisual
+ * w - the window
+ * c - the context
+ * Return: new XMesaBuffer or NULL if error
+ */
+XMesaBuffer
+XMesaCreateWindowBuffer2(XMesaVisual v, XMesaWindow w, XMesaContext c)
+{
+#ifndef XFree86Server
+ XWindowAttributes attr;
+#endif
+#ifdef FX
+ char *fxEnvVar;
+#endif
+ int client = 0;
+ XMesaBuffer b;
+ XMesaColormap cmap;
+
+ assert(v);
+ (void) c;
+
+ /* Check that window depth matches visual depth */
+#ifdef XFree86Server
+ client = CLIENT_ID(((XMesaDrawable)w)->id);
+
+ if (GET_VISUAL_DEPTH(v) != ((XMesaDrawable)w)->depth) {
+ _mesa_warning(NULL, "XMesaCreateWindowBuffer: depth mismatch between visual (%d) and window (%d)!\n",
+ GET_VISUAL_DEPTH(v), ((XMesaDrawable) w)->depth);
+ return NULL;
+ }
+#else
+ XGetWindowAttributes( v->display, w, &attr );
+
+ if (GET_VISUAL_DEPTH(v) != attr.depth) {
+ _mesa_warning(NULL, "XMesaCreateWindowBuffer: depth mismatch between visual (%d) and window (%d)!\n",
+ GET_VISUAL_DEPTH(v), attr.depth);
+ return NULL;
+ }
+#endif
+
+ /* Find colormap */
+#ifdef XFree86Server
+ cmap = (ColormapPtr)LookupIDByType(wColormap(w), RT_COLORMAP);
+#else
+ if (attr.colormap) {
+ cmap = attr.colormap;
+ }
+ else {
+ _mesa_warning(NULL, "Window %u has no colormap!\n", (unsigned int) w);
+ /* this is weird, a window w/out a colormap!? */
+ /* OK, let's just allocate a new one and hope for the best */
+ cmap = XCreateColormap(v->display, w, attr.visual, AllocNone);
+ }
+#endif
+
+ b = alloc_xmesa_buffer(v, WINDOW, cmap);
+ if (!b) {
+ return NULL;
+ }
+
+ if (!initialize_visual_and_buffer( client, v, b, v->mesa_visual.rgbMode,
+ (XMesaDrawable)w, cmap )) {
+ free_xmesa_buffer(client, b);
+ return NULL;
+ }
+
+#ifdef FX
+ fxEnvVar = _mesa_getenv("MESA_GLX_FX");
+ if (fxEnvVar) {
+ if (fxEnvVar[0]!='d') {
+ int attribs[100];
+ int numAttribs = 0;
+ int hw;
+ if (v->mesa_visual.depthBits > 0) {
+ attribs[numAttribs++] = FXMESA_DEPTH_SIZE;
+ attribs[numAttribs++] = v->mesa_visual.depthBits;
+ }
+ if (v->mesa_visual.doubleBufferMode) {
+ attribs[numAttribs++] = FXMESA_DOUBLEBUFFER;
+ }
+ if (v->mesa_visual.accumRedBits > 0) {
+ attribs[numAttribs++] = FXMESA_ACCUM_SIZE;
+ attribs[numAttribs++] = v->mesa_visual.accumRedBits;
+ }
+ if (v->mesa_visual.stencilBits > 0) {
+ attribs[numAttribs++] = FXMESA_STENCIL_SIZE;
+ attribs[numAttribs++] = v->mesa_visual.stencilBits;
+ }
+ if (v->mesa_visual.alphaBits > 0) {
+ attribs[numAttribs++] = FXMESA_ALPHA_SIZE;
+ attribs[numAttribs++] = v->mesa_visual.alphaBits;
+ }
+ if (1) {
+ attribs[numAttribs++] = FXMESA_SHARE_CONTEXT;
+ attribs[numAttribs++] = (int) &(c->mesa);
+ }
+ attribs[numAttribs++] = FXMESA_NONE;
+
+ /* [dBorca] we should take an envvar for `fxMesaSelectCurrentBoard'!!! */
+ hw = fxMesaSelectCurrentBoard(0);
+
+ /* if these fail, there's a new bug somewhere */
+ ASSERT(b->mesa_buffer.Width > 0);
+ ASSERT(b->mesa_buffer.Height > 0);
+
+ if ((hw == GR_SSTTYPE_VOODOO) || (hw == GR_SSTTYPE_Voodoo2)) {
+ b->FXctx = fxMesaCreateBestContext(0, b->mesa_buffer.Width,
+ b->mesa_buffer.Height, attribs);
+ if ((v->undithered_pf!=PF_Index) && (b->backxrb->ximage)) {
+ b->FXisHackUsable = b->FXctx ? GL_TRUE : GL_FALSE;
+ if (b->FXctx && (fxEnvVar[0]=='w' || fxEnvVar[0]=='W')) {
+ b->FXwindowHack = GL_TRUE;
+ FX_grSstControl(GR_CONTROL_DEACTIVATE);
+ }
+ else {
+ b->FXwindowHack = GL_FALSE;
+ }
+ }
+ }
+ else {
+ if (fxEnvVar[0]=='w' || fxEnvVar[0]=='W')
+ b->FXctx = fxMesaCreateContext(w, GR_RESOLUTION_NONE,
+ GR_REFRESH_75Hz, attribs);
+ else
+ b->FXctx = fxMesaCreateBestContext(0, b->mesa_buffer.Width,
+ b->mesa_buffer.Height, attribs);
+ b->FXisHackUsable = GL_FALSE;
+ b->FXwindowHack = GL_FALSE;
+ }
+ /*
+ fprintf(stderr,
+ "voodoo %d, wid %d height %d hack: usable %d active %d\n",
+ hw, b->mesa_buffer.Width, b->mesa_buffer.Height,
+ b->FXisHackUsable, b->FXwindowHack);
+ */
+ }
+ }
+ else {
+ _mesa_warning(NULL, "WARNING: This Mesa Library includes the Glide driver but\n");
+ _mesa_warning(NULL, " you have not defined the MESA_GLX_FX env. var.\n");
+ _mesa_warning(NULL, " (check the README.3DFX file for more information).\n\n");
+ _mesa_warning(NULL, " you can disable this message with a 'export MESA_GLX_FX=disable'.\n");
+ }
+#endif
+
+ return b;
+}
+
+
+XMesaBuffer
+XMesaCreateWindowBuffer(XMesaVisual v, XMesaWindow w)
+{
+ return XMesaCreateWindowBuffer2( v, w, NULL );
+}
+
+
+/**
+ * Create a new XMesaBuffer from an X pixmap.
+ *
+ * \param v the XMesaVisual
+ * \param p the pixmap
+ * \param cmap the colormap, may be 0 if using a \c GLX_TRUE_COLOR or
+ * \c GLX_DIRECT_COLOR visual for the pixmap
+ * \returns new XMesaBuffer or NULL if error
+ */
+XMesaBuffer
+XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, XMesaColormap cmap)
+{
+ int client = 0;
+ XMesaBuffer b;
+
+ assert(v);
+
+ b = alloc_xmesa_buffer(v, PIXMAP, cmap);
+ if (!b) {
+ return NULL;
+ }
+
+#ifdef XFree86Server
+ client = CLIENT_ID(((XMesaDrawable)p)->id);
+#endif
+
+ if (!initialize_visual_and_buffer(client, v, b, v->mesa_visual.rgbMode,
+ (XMesaDrawable)p, cmap)) {
+ free_xmesa_buffer(client, b);
+ return NULL;
+ }
+
+ return b;
+}
+
+
+
+XMesaBuffer
+XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap,
+ unsigned int width, unsigned int height)
+{
+#ifdef XFree86Server
+ return 0;
+#else
+ int client = 0;
+ XMesaWindow root;
+ XMesaDrawable drawable; /* X Pixmap Drawable */
+ XMesaBuffer b;
+
+ b = alloc_xmesa_buffer(v, PBUFFER, cmap);
+ if (!b) {
+ return NULL;
+ }
+
+ /* allocate pixmap for front buffer */
+ root = RootWindow( v->display, v->visinfo->screen );
+ drawable = XCreatePixmap( v->display, root, width, height, v->visinfo->depth );
+
+ if (!initialize_visual_and_buffer(client, v, b, v->mesa_visual.rgbMode,
+ drawable, cmap)) {
+ free_xmesa_buffer(client, b);
+ return NULL;
+ }
+
+ return b;
+#endif
+}
+
+
+
+/*
+ * Deallocate an XMesaBuffer structure and all related info.
+ */
+void XMesaDestroyBuffer( XMesaBuffer b )
+{
+ int client = 0;
+
+#ifdef XFree86Server
+ if (b->frontxrb->drawable)
+ client = CLIENT_ID(b->frontxrb->drawable->id);
+#endif
+
+ if (b->gc) XMesaFreeGC( b->xm_visual->display, b->gc );
+ if (b->cleargc) XMesaFreeGC( b->xm_visual->display, b->cleargc );
+ if (b->swapgc) XMesaFreeGC( b->xm_visual->display, b->swapgc );
+
+ if (b->xm_visual->mesa_visual.doubleBufferMode)
+ {
+ if (b->backxrb->ximage) {
+#if defined(USE_XSHM) && !defined(XFree86Server)
+ if (b->shm) {
+ XShmDetach( b->xm_visual->display, &b->shminfo );
+ XDestroyImage( b->backxrb->ximage );
+ shmdt( b->shminfo.shmaddr );
+ }
+ else
+#endif
+ XMesaDestroyImage( b->backxrb->ximage );
+ }
+ if (b->backxrb->pixmap) {
+ XMesaFreePixmap( b->xm_visual->display,
+ (XMesaPixmap) b->backxrb->pixmap );
+ if (b->xm_visual->hpcr_clear_flag) {
+ XMesaFreePixmap( b->xm_visual->display,
+ b->xm_visual->hpcr_clear_pixmap );
+ XMesaDestroyImage( b->xm_visual->hpcr_clear_ximage );
+ }
+ }
+ }
+ if (b->rowimage) {
+ _mesa_free( b->rowimage->data );
+ b->rowimage->data = NULL;
+ XMesaDestroyImage( b->rowimage );
+ }
+
+ free_xmesa_buffer(client, b);
+}
+
+
+
+/*
+ * Bind buffer b to context c and make c the current rendering context.
+ */
+GLboolean XMesaMakeCurrent( XMesaContext c, XMesaBuffer b )
+{
+ return XMesaMakeCurrent2( c, b, b );
+}
+
+
+/*
+ * Bind buffer b to context c and make c the current rendering context.
+ */
+GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer,
+ XMesaBuffer readBuffer )
+{
+ if (c) {
+ if (!drawBuffer || !readBuffer)
+ return GL_FALSE; /* must specify buffers! */
+
+#ifdef FX
+ if (drawBuffer->FXctx) {
+ fxMesaMakeCurrent(drawBuffer->FXctx);
+
+ c->xm_buffer = drawBuffer;
+
+ return GL_TRUE;
+ }
+#endif
+ if (&(c->mesa) == _mesa_get_current_context()
+ && c->mesa.DrawBuffer == &drawBuffer->mesa_buffer
+ && c->mesa.ReadBuffer == &readBuffer->mesa_buffer
+ && ((XMesaBuffer) c->mesa.DrawBuffer)->wasCurrent) {
+ /* same context and buffer, do nothing */
+ return GL_TRUE;
+ }
+
+ c->xm_buffer = drawBuffer;
+
+ _mesa_make_current(&(c->mesa),
+ &drawBuffer->mesa_buffer,
+ &readBuffer->mesa_buffer);
+
+ if (c->xm_visual->mesa_visual.rgbMode) {
+ /*
+ * Must recompute and set these pixel values because colormap
+ * can be different for different windows.
+ */
+ c->clearpixel = xmesa_color_to_pixel( &c->mesa,
+ c->clearcolor[0],
+ c->clearcolor[1],
+ c->clearcolor[2],
+ c->clearcolor[3],
+ c->xm_visual->undithered_pf);
+ XMesaSetForeground(c->display, drawBuffer->cleargc, c->clearpixel);
+ }
+
+ /* Solution to Stephane Rehel's problem with glXReleaseBuffersMESA(): */
+ drawBuffer->wasCurrent = GL_TRUE;
+ }
+ else {
+ /* Detach */
+ _mesa_make_current( NULL, NULL, NULL );
+ }
+ return GL_TRUE;
+}
+
+
+/*
+ * Unbind the context c from its buffer.
+ */
+GLboolean XMesaUnbindContext( XMesaContext c )
+{
+ /* A no-op for XFree86 integration purposes */
+ return GL_TRUE;
+}
+
+
+XMesaContext XMesaGetCurrentContext( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (ctx) {
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ return xmesa;
+ }
+ else {
+ return 0;
+ }
+}
+
+
+XMesaBuffer XMesaGetCurrentBuffer( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (ctx) {
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ return xmbuf;
+ }
+ else {
+ return 0;
+ }
+}
+
+
+/* New in Mesa 3.1 */
+XMesaBuffer XMesaGetCurrentReadBuffer( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (ctx) {
+ return (XMesaBuffer) (ctx->ReadBuffer);
+ }
+ else {
+ return 0;
+ }
+}
+
+
+GLboolean XMesaForceCurrent(XMesaContext c)
+{
+ if (c) {
+ if (&(c->mesa) != _mesa_get_current_context()) {
+ _mesa_make_current(&c->mesa, c->mesa.DrawBuffer, c->mesa.ReadBuffer);
+ }
+ }
+ else {
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean XMesaLoseCurrent(XMesaContext c)
+{
+ (void) c;
+ _mesa_make_current(NULL, NULL, NULL);
+ return GL_TRUE;
+}
+
+
+/*
+ * Switch 3Dfx support hack between window and full-screen mode.
+ */
+GLboolean XMesaSetFXmode( GLint mode )
+{
+#ifdef FX
+ const char *fx = _mesa_getenv("MESA_GLX_FX");
+ if (fx && fx[0] != 'd') {
+ GET_CURRENT_CONTEXT(ctx);
+ GrHwConfiguration hw;
+ if (!FX_grSstQueryHardware(&hw)) {
+ /*fprintf(stderr, "!grSstQueryHardware\n");*/
+ return GL_FALSE;
+ }
+ if (hw.num_sst < 1) {
+ /*fprintf(stderr, "hw.num_sst < 1\n");*/
+ return GL_FALSE;
+ }
+ if (ctx) {
+ /* [dBorca] Hack alert:
+ * oh, this is sooo wrong: ctx above is
+ * really an fxMesaContext, not an XMesaContext
+ */
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ if (mode == XMESA_FX_WINDOW) {
+ if (xmbuf->FXisHackUsable) {
+ FX_grSstControl(GR_CONTROL_DEACTIVATE);
+ xmbuf->FXwindowHack = GL_TRUE;
+ return GL_TRUE;
+ }
+ }
+ else if (mode == XMESA_FX_FULLSCREEN) {
+ FX_grSstControl(GR_CONTROL_ACTIVATE);
+ xmbuf->FXwindowHack = GL_FALSE;
+ return GL_TRUE;
+ }
+ else {
+ /* Error: Bad mode value */
+ }
+ }
+ }
+ /*fprintf(stderr, "fallthrough\n");*/
+#else
+ (void) mode;
+#endif
+ return GL_FALSE;
+}
+
+
+
+#ifdef FX
+/*
+ * Read image from VooDoo frame buffer into X/Mesa's back XImage.
+ */
+static void FXgetImage( XMesaBuffer b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ static unsigned short pixbuf[MAX_WIDTH];
+ GLuint x, y;
+ int xpos, ypos;
+ XMesaWindow root;
+ unsigned int bw, depth, width, height;
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+
+#ifdef XFree86Server
+ x = b->frontxrb->pixmap->x;
+ y = b->frontxrb->pixmap->y;
+ width = b->frontxrb->pixmap->width;
+ height = b->frontxrb->pixmap->height;
+ depth = b->frontxrb->pixmap->depth;
+#else
+ XGetGeometry( b->xm_visual->display, b->frontxrb->pixmap,
+ &root, &xpos, &ypos, &width, &height, &bw, &depth);
+#endif
+ if (b->mesa_buffer.Width != width || b->mesa_buffer.Height != height) {
+ b->mesa_buffer.Width = MIN2((int)width, b->FXctx->width);
+ b->mesa_buffer.Height = MIN2((int)height, b->FXctx->height);
+ if (b->mesa_buffer.Width & 1)
+ b->mesa_buffer.Width--; /* prevent odd width */
+ xmesa_alloc_back_buffer(b, b->mesa_buffer.Width, b->mesa_buffer.Height);
+ }
+
+ /* [dBorca] we're always in the right GR_COLORFORMAT... aren't we? */
+ /* grLfbWriteColorFormat(GR_COLORFORMAT_ARGB); */
+ if (b->xm_visual->undithered_pf==PF_5R6G5B) {
+ /* Special case: 16bpp RGB */
+ grLfbReadRegion( GR_BUFFER_FRONTBUFFER, /* src buffer */
+ 0, b->FXctx->height - b->mesa_buffer.Height, /*pos*/
+ b->mesa_buffer.Width, b->mesa_buffer.Height, /* size */
+ b->mesa_buffer.Width * sizeof(GLushort), /* stride */
+ b->backxrb->ximage->data); /* dest buffer */
+ }
+ else if (b->xm_visual->dithered_pf==PF_Dither
+ && GET_VISUAL_DEPTH(b->xm_visual)==8) {
+ /* Special case: 8bpp RGB */
+ for (y=0;y<b->mesa_buffer.Height;y++) {
+ GLubyte *ptr = (GLubyte*) b->backxrb->ximage->data
+ + b->backxrb->ximage->bytes_per_line * y;
+ XDITHER_SETUP(y);
+
+ /* read row from 3Dfx frame buffer */
+ grLfbReadRegion( GR_BUFFER_FRONTBUFFER,
+ 0, b->FXctx->height-(b->mesa_buffer.Height-y),
+ b->mesa_buffer.Width, 1,
+ 0,
+ pixbuf );
+
+ /* write to XImage back buffer */
+ for (x=0;x<b->mesa_buffer.Width;x++) {
+ GLubyte r = (pixbuf[x] & 0xf800) >> 8;
+ GLubyte g = (pixbuf[x] & 0x07e0) >> 3;
+ GLubyte b = (pixbuf[x] & 0x001f) << 3;
+ *ptr++ = XDITHER( x, r, g, b);
+ }
+ }
+ }
+ else {
+ /* General case: slow! */
+ for (y=0;y<b->mesa_buffer.Height;y++) {
+ /* read row from 3Dfx frame buffer */
+ grLfbReadRegion( GR_BUFFER_FRONTBUFFER,
+ 0, b->FXctx->height-(b->mesa_buffer.Height-y),
+ b->mesa_buffer.Width, 1,
+ 0,
+ pixbuf );
+
+ /* write to XImage back buffer */
+ for (x=0;x<b->mesa_buffer.Width;x++) {
+ XMesaPutPixel(b->backxrb->ximage,x,y,
+ xmesa_color_to_pixel(ctx,
+ (pixbuf[x] & 0xf800) >> 8,
+ (pixbuf[x] & 0x07e0) >> 3,
+ (pixbuf[x] & 0x001f) << 3,
+ 0xff,
+ b->xm_visual->undithered_pf));
+ }
+ }
+ }
+ /* grLfbWriteColorFormat(GR_COLORFORMAT_ABGR); */
+}
+#endif
+
+
+/*
+ * Copy the back buffer to the front buffer. If there's no back buffer
+ * this is a no-op.
+ */
+void XMesaSwapBuffers( XMesaBuffer b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ /* If we're swapping the buffer associated with the current context
+ * we have to flush any pending rendering commands first.
+ */
+ if (ctx && ctx->DrawBuffer == &(b->mesa_buffer))
+ _mesa_notifySwapBuffers(ctx);
+
+ if (b->db_state) {
+#ifdef FX
+ if (b->FXctx) {
+ fxMesaSwapBuffers();
+
+ if (b->FXwindowHack)
+ FXgetImage(b);
+ else
+ return;
+ }
+#endif
+ if (b->backxrb->ximage) {
+ /* Copy Ximage from host's memory to server's window */
+#if defined(USE_XSHM) && !defined(XFree86Server)
+ if (b->shm) {
+ /*_glthread_LOCK_MUTEX(_xmesa_lock);*/
+ XShmPutImage( b->xm_visual->display, b->frontxrb->drawable,
+ b->swapgc,
+ b->backxrb->ximage, 0, 0,
+ 0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height,
+ False );
+ /*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
+ }
+ else
+#endif
+ {
+ /*_glthread_LOCK_MUTEX(_xmesa_lock);*/
+ XMesaPutImage( b->xm_visual->display, b->frontxrb->drawable,
+ b->swapgc,
+ b->backxrb->ximage, 0, 0,
+ 0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height );
+ /*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
+ }
+ }
+ else {
+ /* Copy pixmap to window on server */
+ /*_glthread_LOCK_MUTEX(_xmesa_lock);*/
+ XMesaCopyArea( b->xm_visual->display,
+ b->backxrb->pixmap, /* source drawable */
+ b->frontxrb->drawable, /* dest. drawable */
+ b->swapgc,
+ 0, 0, b->mesa_buffer.Width, b->mesa_buffer.Height,
+ 0, 0 /* dest region */
+ );
+ /*_glthread_UNLOCK_MUTEX(_xmesa_lock);*/
+ }
+ }
+#if !defined(XFree86Server)
+ XSync( b->xm_visual->display, False );
+#endif
+}
+
+
+
+/*
+ * Copy sub-region of back buffer to front buffer
+ */
+void XMesaCopySubBuffer( XMesaBuffer b, int x, int y, int width, int height )
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ /* If we're swapping the buffer associated with the current context
+ * we have to flush any pending rendering commands first.
+ */
+ if (ctx && ctx->DrawBuffer == &(b->mesa_buffer))
+ _mesa_notifySwapBuffers(ctx);
+
+ if (b->db_state) {
+ int yTop = b->mesa_buffer.Height - y - height;
+#ifdef FX
+ if (b->FXctx) {
+ fxMesaSwapBuffers();
+ if (b->FXwindowHack)
+ FXgetImage(b);
+ else
+ return;
+ }
+#endif
+ if (b->backxrb->ximage) {
+ /* Copy Ximage from host's memory to server's window */
+#if defined(USE_XSHM) && !defined(XFree86Server)
+ if (b->shm) {
+ /* XXX assuming width and height aren't too large! */
+ XShmPutImage( b->xm_visual->display, b->frontxrb->drawable,
+ b->swapgc,
+ b->backxrb->ximage, x, yTop,
+ x, yTop, width, height, False );
+ /* wait for finished event??? */
+ }
+ else
+#endif
+ {
+ /* XXX assuming width and height aren't too large! */
+ XMesaPutImage( b->xm_visual->display, b->frontxrb->drawable,
+ b->swapgc,
+ b->backxrb->ximage, x, yTop,
+ x, yTop, width, height );
+ }
+ }
+ else {
+ /* Copy pixmap to window on server */
+ XMesaCopyArea( b->xm_visual->display,
+ b->backxrb->pixmap, /* source drawable */
+ b->frontxrb->drawable, /* dest. drawable */
+ b->swapgc,
+ x, yTop, width, height, /* source region */
+ x, yTop /* dest region */
+ );
+ }
+ }
+}
+
+
+/*
+ * Return a pointer to the XMesa backbuffer Pixmap or XImage. This function
+ * is a way to get "under the hood" of X/Mesa so one can manipulate the
+ * back buffer directly.
+ * Output: pixmap - pointer to back buffer's Pixmap, or 0
+ * ximage - pointer to back buffer's XImage, or NULL
+ * Return: GL_TRUE = context is double buffered
+ * GL_FALSE = context is single buffered
+ */
+#ifndef XFree86Server
+GLboolean XMesaGetBackBuffer( XMesaBuffer b,
+ XMesaPixmap *pixmap,
+ XMesaImage **ximage )
+{
+ if (b->db_state) {
+ if (pixmap) *pixmap = b->backxrb->pixmap;
+ if (ximage) *ximage = b->backxrb->ximage;
+ return GL_TRUE;
+ }
+ else {
+ *pixmap = 0;
+ *ximage = NULL;
+ return GL_FALSE;
+ }
+}
+#endif /* XFree86Server */
+
+
+/*
+ * Return the depth buffer associated with an XMesaBuffer.
+ * Input: b - the XMesa buffer handle
+ * 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 XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height,
+ GLint *bytesPerValue, void **buffer )
+{
+ struct gl_renderbuffer *rb
+ = b->mesa_buffer.Attachment[BUFFER_DEPTH].Renderbuffer;
+ if (!rb || !rb->Data) {
+ *width = 0;
+ *height = 0;
+ *bytesPerValue = 0;
+ *buffer = 0;
+ return GL_FALSE;
+ }
+ else {
+ *width = b->mesa_buffer.Width;
+ *height = b->mesa_buffer.Height;
+ *bytesPerValue = b->mesa_buffer.Visual.depthBits <= 16
+ ? sizeof(GLushort) : sizeof(GLuint);
+ *buffer = rb->Data;
+ return GL_TRUE;
+ }
+}
+
+
+void XMesaFlush( XMesaContext c )
+{
+ if (c && c->xm_visual) {
+#ifdef XFree86Server
+ /* NOT_NEEDED */
+#else
+ XSync( c->xm_visual->display, False );
+#endif
+ }
+}
+
+
+
+const char *XMesaGetString( XMesaContext c, int name )
+{
+ (void) c;
+ if (name==XMESA_VERSION) {
+ return "5.0";
+ }
+ else if (name==XMESA_EXTENSIONS) {
+ return "";
+ }
+ else {
+ return NULL;
+ }
+}
+
+
+
+XMesaBuffer XMesaFindBuffer( XMesaDisplay *dpy, XMesaDrawable d )
+{
+ XMesaBuffer b;
+ for (b=XMesaBufferList; b; b=b->Next) {
+ if (b->frontxrb->drawable == d && b->display == dpy) {
+ return b;
+ }
+ }
+ return NULL;
+}
+
+
+
+/*
+ * Look for XMesaBuffers whose X window has been destroyed.
+ * Deallocate any such XMesaBuffers.
+ */
+void XMesaGarbageCollect( void )
+{
+ XMesaBuffer b, next;
+ for (b=XMesaBufferList; b; b=next) {
+ next = b->Next;
+ if (b->display && b->frontxrb->drawable && b->type == WINDOW) {
+#ifdef XFree86Server
+ /* NOT_NEEDED */
+#else
+ XSync(b->display, False);
+ if (!window_exists( b->display, b->frontxrb->drawable )) {
+ /* found a dead window, free the ancillary info */
+ XMesaDestroyBuffer( b );
+ }
+#endif
+ }
+ }
+}
+
+
+void XMesaReset( void )
+{
+ while (XMesaBufferList)
+ XMesaDestroyBuffer(XMesaBufferList);
+
+ XMesaBufferList = NULL;
+}
+
+
+unsigned long XMesaDitherColor( XMesaContext xmesa, GLint x, GLint y,
+ GLfloat red, GLfloat green,
+ GLfloat blue, GLfloat alpha )
+{
+ GLcontext *ctx = &xmesa->mesa;
+ GLint r = (GLint) (red * 255.0F);
+ GLint g = (GLint) (green * 255.0F);
+ GLint b = (GLint) (blue * 255.0F);
+ GLint a = (GLint) (alpha * 255.0F);
+
+ switch (xmesa->pixelformat) {
+ case PF_Index:
+ return 0;
+ case PF_Truecolor:
+ {
+ unsigned long p;
+ PACK_TRUECOLOR( p, r, g, b );
+ return p;
+ }
+ case PF_8A8B8G8R:
+ return PACK_8A8B8G8R( r, g, b, a );
+ case PF_8A8R8G8B:
+ return PACK_8A8R8G8B( r, g, b, a );
+ case PF_8R8G8B:
+ return PACK_8R8G8B( r, g, b );
+ case PF_5R6G5B:
+ return PACK_5R6G5B( r, g, b );
+ case PF_Dither:
+ {
+ DITHER_SETUP;
+ return DITHER( x, y, r, g, b );
+ }
+ case PF_1Bit:
+ /* 382 = (3*255)/2 */
+ return ((r+g+b) > 382) ^ xmesa->xm_visual->bitFlip;
+ case PF_HPCR:
+ return DITHER_HPCR(x, y, r, g, b);
+ case PF_Lookup:
+ {
+ LOOKUP_SETUP;
+ return LOOKUP( r, g, b );
+ }
+ case PF_Grayscale:
+ return GRAY_RGB( r, g, b );
+ case PF_Dither_5R6G5B:
+ /* fall through */
+ case PF_Dither_True:
+ {
+ unsigned long p;
+ PACK_TRUEDITHER(p, x, y, r, g, b);
+ return p;
+ }
+ default:
+ _mesa_problem(NULL, "Bad pixel format in XMesaDitherColor");
+ }
+ return 0;
+}
+
+
+/*
+ * This is typically called when the window size changes and we need
+ * to reallocate the buffer's back/depth/stencil/accum buffers.
+ */
+void XMesaResizeBuffers( XMesaBuffer b )
+{
+#ifdef XFree86Server
+ GLuint winwidth, winheight;
+ GET_CURRENT_CONTEXT(ctx);
+
+ winwidth = MIN2(b->frontxrb->drawable->width, MAX_WIDTH);
+ winheight = MIN2(b->frontxrb->drawable->height, MAX_HEIGHT);
+
+ xmesa_resize_buffers(ctx, &(b->mesa_buffer), winwidth, winheight);
+#else
+ Window root;
+ int xpos, ypos;
+ unsigned int width, height, bw, depth;
+ GET_CURRENT_CONTEXT(ctx);
+ XGetGeometry( b->xm_visual->display, b->frontxrb->pixmap,
+ &root, &xpos, &ypos, &width, &height, &bw, &depth);
+ xmesa_resize_buffers(ctx, &(b->mesa_buffer), width, height);
+#endif
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_buffer.c b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_buffer.c
new file mode 100644
index 000000000..593ac2bb1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_buffer.c
@@ -0,0 +1,115 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glxheader.h"
+#include "GL/xmesa.h"
+#include "xmesaP.h"
+#include "imports.h"
+#include "renderbuffer.h"
+
+
+static void
+xmesa_delete_renderbuffer(struct gl_renderbuffer *rb)
+{
+ /* XXX Note: the ximage or Pixmap attached to this renderbuffer
+ * should probably get freed here, but that's currently done in
+ * XMesaDestroyBuffer().
+ */
+ _mesa_free(rb);
+}
+
+
+/**
+ * Reallocate renderbuffer storage.
+ * This is called when the window's resized. It'll get called once for
+ * the front color renderbuffer and again for the back color renderbuffer.
+ */
+static GLboolean
+xmesa_alloc_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+
+ if (xrb->ximage) {
+ /* Needed by PIXELADDR1 macro */
+ xrb->width1 = xrb->ximage->bytes_per_line;
+ xrb->origin1 = (GLubyte *) xrb->ximage->data + xrb->width1 * (height - 1);
+
+ /* Needed by PIXELADDR2 macro */
+ xrb->width2 = xrb->ximage->bytes_per_line / 2;
+ xrb->origin2 = (GLushort *) xrb->ximage->data + xrb->width2 * (height - 1);
+
+ /* Needed by PIXELADDR3 macro */
+ xrb->width3 = xrb->ximage->bytes_per_line;
+ xrb->origin3 = (GLubyte *) xrb->ximage->data + xrb->width3 * (height - 1);
+
+ /* Needed by PIXELADDR4 macro */
+ xrb->width4 = xrb->ximage->width;
+ xrb->origin4 = (GLuint *) xrb->ximage->data + xrb->width4 * (height - 1);
+ }
+ else {
+ assert(xrb->pixmap);
+ }
+
+ /* for the FLIP macro: */
+ xrb->bottom = height - 1;
+
+ rb->Width = width;
+ rb->Height = height;
+ rb->InternalFormat = internalFormat;
+
+ return GL_TRUE;
+}
+
+
+struct xmesa_renderbuffer *
+xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, GLboolean rgbMode)
+{
+ struct xmesa_renderbuffer *xrb = CALLOC_STRUCT(xmesa_renderbuffer);
+ if (xrb) {
+ GLuint name = 0;
+ _mesa_init_renderbuffer(&xrb->Base, name);
+
+ xrb->Base.Delete = xmesa_delete_renderbuffer;
+ xrb->Base.AllocStorage = xmesa_alloc_storage;
+
+ if (rgbMode) {
+ xrb->Base.InternalFormat = GL_RGBA;
+ xrb->Base._BaseFormat = GL_RGBA;
+ xrb->Base.DataType = GL_UNSIGNED_BYTE;
+ }
+ else {
+ xrb->Base.InternalFormat = GL_COLOR_INDEX;
+ xrb->Base._BaseFormat = GL_COLOR_INDEX;
+ xrb->Base.DataType = GL_UNSIGNED_INT;
+ }
+ xrb->Base.ComponentSizes[0] = 0; /* XXX fix? */
+ }
+ return xrb;
+}
+
+
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_dd.c b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_dd.c
new file mode 100644
index 000000000..bc16a7bd4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_dd.c
@@ -0,0 +1,1201 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+#include "glxheader.h"
+#include "bufferobj.h"
+#include "buffers.h"
+#include "context.h"
+#include "colormac.h"
+#include "depth.h"
+#include "drawpix.h"
+#include "extensions.h"
+#include "framebuffer.h"
+#include "macros.h"
+#include "image.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "state.h"
+#include "texobj.h"
+#include "teximage.h"
+#include "texstore.h"
+#include "texformat.h"
+#include "xmesaP.h"
+#include "array_cache/acache.h"
+#include "swrast/swrast.h"
+#include "swrast/s_context.h"
+#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+
+#ifdef XFree86Server
+#include <GL/glxtokens.h>
+#endif
+
+
+
+/*
+ * Dithering kernels and lookup tables.
+ */
+
+const int xmesa_kernel8[DITH_DY * DITH_DX] = {
+ 0 * MAXC, 8 * MAXC, 2 * MAXC, 10 * MAXC,
+ 12 * MAXC, 4 * MAXC, 14 * MAXC, 6 * MAXC,
+ 3 * MAXC, 11 * MAXC, 1 * MAXC, 9 * MAXC,
+ 15 * MAXC, 7 * MAXC, 13 * MAXC, 5 * MAXC,
+};
+
+const short xmesa_HPCR_DRGB[3][2][16] = {
+ {
+ { 16, -4, 1,-11, 14, -6, 3, -9, 15, -5, 2,-10, 13, -7, 4, -8},
+ {-15, 5, 0, 12,-13, 7, -2, 10,-14, 6, -1, 11,-12, 8, -3, 9}
+ },
+ {
+ {-11, 15, -7, 3, -8, 14, -4, 2,-10, 16, -6, 4, -9, 13, -5, 1},
+ { 12,-14, 8, -2, 9,-13, 5, -1, 11,-15, 7, -3, 10,-12, 6, 0}
+ },
+ {
+ { 6,-18, 26,-14, 2,-22, 30,-10, 8,-16, 28,-12, 4,-20, 32, -8},
+ { -4, 20,-24, 16, 0, 24,-28, 12, -6, 18,-26, 14, -2, 22,-30, 10}
+ }
+};
+
+const int xmesa_kernel1[16] = {
+ 0*47, 9*47, 4*47, 12*47, /* 47 = (255*3)/16 */
+ 6*47, 2*47, 14*47, 8*47,
+ 10*47, 1*47, 5*47, 11*47,
+ 7*47, 13*47, 3*47, 15*47
+};
+
+
+/*
+ * Return the size (width, height) of the X window for the given GLframebuffer.
+ * Output: width - width of buffer in pixels.
+ * height - height of buffer in pixels.
+ */
+static void
+get_buffer_size( GLframebuffer *buffer, GLuint *width, GLuint *height )
+{
+ /* We can do this cast because the first field in the XMesaBuffer
+ * struct is a GLframebuffer struct. If this weren't true, we'd
+ * need a pointer from the GLframebuffer to the XMesaBuffer.
+ */
+ const XMesaBuffer xmBuffer = (XMesaBuffer) buffer;
+ unsigned int winwidth, winheight;
+#ifdef XFree86Server
+ /* XFree86 GLX renderer */
+ winwidth = MIN2(xmBuffer->frontxrb->drawable->width, MAX_WIDTH);
+ winheight = MIN2(xmBuffer->frontxrb->drawable->height, MAX_HEIGHT);
+#else
+ Window root;
+ int winx, winy;
+ unsigned int bw, d;
+
+ _glthread_LOCK_MUTEX(_xmesa_lock);
+ XSync(xmBuffer->xm_visual->display, 0); /* added for Chromium */
+ XGetGeometry( xmBuffer->xm_visual->display, xmBuffer->frontxrb->pixmap, &root,
+ &winx, &winy, &winwidth, &winheight, &bw, &d );
+ _glthread_UNLOCK_MUTEX(_xmesa_lock);
+#endif
+
+ *width = winwidth;
+ *height = winheight;
+}
+
+
+static void
+finish_or_flush( GLcontext *ctx )
+{
+#ifdef XFree86Server
+ /* NOT_NEEDED */
+#else
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ if (xmesa) {
+ _glthread_LOCK_MUTEX(_xmesa_lock);
+ XSync( xmesa->display, False );
+ _glthread_UNLOCK_MUTEX(_xmesa_lock);
+ }
+#endif
+}
+
+
+static void
+clear_index( GLcontext *ctx, GLuint index )
+{
+ if (ctx->DrawBuffer->Name == 0) {
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ xmesa->clearpixel = (unsigned long) index;
+ XMesaSetForeground( xmesa->display, xmbuf->cleargc, (unsigned long) index );
+ }
+}
+
+
+static void
+clear_color( GLcontext *ctx, const GLfloat color[4] )
+{
+ if (ctx->DrawBuffer->Name == 0) {
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]);
+ xmesa->clearpixel = xmesa_color_to_pixel( ctx,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2],
+ xmesa->clearcolor[3],
+ xmesa->xm_visual->undithered_pf );
+ _glthread_LOCK_MUTEX(_xmesa_lock);
+ XMesaSetForeground( xmesa->display, xmbuf->cleargc,
+ xmesa->clearpixel );
+ _glthread_UNLOCK_MUTEX(_xmesa_lock);
+ }
+}
+
+
+
+/* Set index mask ala glIndexMask */
+static void
+index_mask( GLcontext *ctx, GLuint mask )
+{
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ /* not sure this conditional is really needed */
+ if (xmbuf->backxrb && xmbuf->backxrb->pixmap) {
+ unsigned long m;
+ if (mask==0xffffffff) {
+ m = ((unsigned long)~0L);
+ }
+ else {
+ m = (unsigned long) mask;
+ }
+ XMesaSetPlaneMask( xmesa->display, xmbuf->cleargc, m );
+ XMesaSetPlaneMask( xmesa->display, xmbuf->gc, m );
+ }
+}
+
+
+/* Implements glColorMask() */
+static void
+color_mask(GLcontext *ctx,
+ GLboolean rmask, GLboolean gmask, GLboolean bmask, GLboolean amask)
+{
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ const int xclass = xmesa->xm_visual->mesa_visual.visualType;
+ (void) amask;
+
+ if (xclass == GLX_TRUE_COLOR || xclass == GLX_DIRECT_COLOR) {
+ unsigned long m;
+ if (rmask && gmask && bmask) {
+ m = ((unsigned long)~0L);
+ }
+ else {
+ m = 0;
+ if (rmask) m |= GET_REDMASK(xmesa->xm_visual);
+ if (gmask) m |= GET_GREENMASK(xmesa->xm_visual);
+ if (bmask) m |= GET_BLUEMASK(xmesa->xm_visual);
+ }
+ XMesaSetPlaneMask( xmesa->display, xmbuf->cleargc, m );
+ XMesaSetPlaneMask( xmesa->display, xmbuf->gc, m );
+ }
+}
+
+
+
+/**********************************************************************/
+/*** glClear implementations ***/
+/**********************************************************************/
+
+
+/**
+ * Clear the front or back color buffer, if it's implemented with a pixmap.
+ */
+static void
+clear_pixmap(GLcontext *ctx, struct xmesa_renderbuffer *xrb, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height)
+{
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+
+ assert(xmbuf);
+ assert(xrb->pixmap);
+ assert(xmesa);
+ assert(xmesa->display);
+ assert(xrb->pixmap);
+ assert(xmbuf->cleargc);
+
+ if (all) {
+ XMesaFillRectangle( xmesa->display, xrb->pixmap, xmbuf->cleargc,
+ 0, 0, xrb->Base.Width + 1, xrb->Base.Height + 1 );
+ }
+ else {
+ XMesaFillRectangle( xmesa->display, xrb->pixmap, xmbuf->cleargc,
+ x, xrb->Base.Height - y - height,
+ width, height );
+ }
+}
+
+
+static void
+clear_8bit_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height )
+{
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+
+ if (all) {
+ const size_t n = xrb->ximage->bytes_per_line * xrb->Base.Height;
+ MEMSET( xrb->ximage->data, xmesa->clearpixel, n );
+ }
+ else {
+ GLint i;
+ for (i=0;i<height;i++) {
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x, y + i);
+ MEMSET( ptr, xmesa->clearpixel, width );
+ }
+ }
+}
+
+
+static void
+clear_HPCR_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height )
+{
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+
+ if (all) {
+ GLint i, c16 = (xrb->ximage->bytes_per_line>>4)<<4;
+ GLubyte *ptr = (GLubyte *) xrb->ximage->data;
+ for (i = 0; i < xrb->Base.Height; i++) {
+ GLint j;
+ GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
+ if (i&1) {
+ sptr += 16;
+ }
+ for (j=0; j<c16; j+=16) {
+ ptr[0] = sptr[0];
+ ptr[1] = sptr[1];
+ ptr[2] = sptr[2];
+ ptr[3] = sptr[3];
+ ptr[4] = sptr[4];
+ ptr[5] = sptr[5];
+ ptr[6] = sptr[6];
+ ptr[7] = sptr[7];
+ ptr[8] = sptr[8];
+ ptr[9] = sptr[9];
+ ptr[10] = sptr[10];
+ ptr[11] = sptr[11];
+ ptr[12] = sptr[12];
+ ptr[13] = sptr[13];
+ ptr[14] = sptr[14];
+ ptr[15] = sptr[15];
+ ptr += 16;
+ }
+ for (; j < xrb->ximage->bytes_per_line; j++) {
+ *ptr = sptr[j&15];
+ ptr++;
+ }
+ }
+ }
+ else {
+ GLint i;
+ for (i=y; i<y+height; i++) {
+ GLubyte *ptr = PIXEL_ADDR1( xrb, x, i );
+ int j;
+ const GLubyte *sptr = xmesa->xm_visual->hpcr_clear_ximage_pattern[0];
+ if (i&1) {
+ sptr += 16;
+ }
+ for (j=x; j<x+width; j++) {
+ *ptr = sptr[j&15];
+ ptr++;
+ }
+ }
+ }
+}
+
+
+static void
+clear_16bit_ximage( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height)
+{
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ register GLuint pixel = (GLuint) xmesa->clearpixel;
+
+ if (xmesa->swapbytes) {
+ pixel = ((pixel >> 8) & 0x00ff) | ((pixel << 8) & 0xff00);
+ }
+
+ if (all) {
+ GLuint *ptr4 = (GLuint *) xrb->ximage->data;
+ if ((pixel & 0xff) == ((pixel >> 8) & 0xff)) {
+ /* low and high bytes are equal so use memset() */
+ const GLuint n = xrb->ximage->bytes_per_line * xrb->Base.Height;
+ MEMSET( ptr4, pixel & 0xff, n );
+ }
+ else {
+ const GLuint n = xrb->ximage->bytes_per_line * xrb->Base.Height / 4;
+ GLuint i;
+ pixel = pixel | (pixel<<16);
+ for (i = 0; i < n; i++) {
+ ptr4[i] = pixel;
+ }
+ ptr4 += n;
+ /* might be one last GLushort to set */
+ if ((xrb->ximage->bytes_per_line * xrb->Base.Height) & 0x2)
+ *(GLushort *)ptr4 = pixel & 0xffff;
+ }
+ }
+ else {
+ GLint i, j;
+ for (j=0;j<height;j++) {
+ GLushort *ptr2 = PIXEL_ADDR2(xrb, x, y + j);
+ for (i=0;i<width;i++) {
+ *ptr2++ = pixel;
+ }
+ }
+ }
+}
+
+
+/* Optimized code provided by Nozomi Ytow <noz@xfree86.org> */
+static void
+clear_24bit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height)
+{
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ const GLubyte r = xmesa->clearcolor[0];
+ const GLubyte g = xmesa->clearcolor[1];
+ const GLubyte b = xmesa->clearcolor[2];
+
+ if (all) {
+ if (r == g && g == b) {
+ /* same value for all three components (gray) */
+ const GLint w3 = xrb->Base.Width * 3;
+ const GLint h = xrb->Base.Height;
+ GLint i;
+ for (i = 0; i < h; i++) {
+ bgr_t *ptr3 = PIXEL_ADDR3(xrb, 0, i);
+ MEMSET(ptr3, r, w3);
+ }
+ }
+ else {
+ /* the usual case */
+ const GLint w = xrb->Base.Width;
+ const GLint h = xrb->Base.Height;
+ GLint i, j;
+ for (i = 0; i < h; i++) {
+ bgr_t *ptr3 = PIXEL_ADDR3(xrb, 0, i);
+ for (j = 0; j < w; j++) {
+ ptr3->r = r;
+ ptr3->g = g;
+ ptr3->b = b;
+ ptr3++;
+ }
+ }
+ }
+ }
+ else {
+ /* only clear subrect of color buffer */
+ if (r == g && g == b) {
+ /* same value for all three components (gray) */
+ GLint j;
+ for (j=0;j<height;j++) {
+ bgr_t *ptr3 = PIXEL_ADDR3(xrb, x, y + j);
+ MEMSET(ptr3, r, 3 * width);
+ }
+ }
+ else {
+ /* non-gray clear color */
+ GLint i, j;
+ for (j = 0; j < height; j++) {
+ bgr_t *ptr3 = PIXEL_ADDR3(xrb, x, y + j);
+ for (i = 0; i < width; i++) {
+ ptr3->r = r;
+ ptr3->g = g;
+ ptr3->b = b;
+ ptr3++;
+ }
+ }
+ }
+ }
+}
+
+
+static void
+clear_32bit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height)
+{
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ register GLuint pixel = (GLuint) xmesa->clearpixel;
+
+ if (xmesa->swapbytes) {
+ pixel = ((pixel >> 24) & 0x000000ff)
+ | ((pixel >> 8) & 0x0000ff00)
+ | ((pixel << 8) & 0x00ff0000)
+ | ((pixel << 24) & 0xff000000);
+ }
+
+ if (all) {
+ const GLuint n = xrb->Base.Width * xrb->Base.Height;
+ GLuint *ptr4 = (GLuint *) xrb->ximage->data;
+ if (pixel == 0) {
+ _mesa_memset(ptr4, pixel, 4 * n);
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < n; i++)
+ ptr4[i] = pixel;
+ }
+ }
+ else {
+ GLint i, j;
+ for (j = 0; j < height; j++) {
+ GLuint *ptr4 = PIXEL_ADDR4(xrb, x, y + j);
+ for (i = 0; i < width; i++) {
+ ptr4[i] = pixel;
+ }
+ }
+ }
+}
+
+
+static void
+clear_nbit_ximage(GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height)
+{
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaImage *img = xrb->ximage;
+ GLint i, j;
+
+ /* We can ignore 'all' here - x, y, width, height are always right */
+ (void) all;
+
+ /* TODO: optimize this */
+ y = YFLIP(xrb, y);
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width; i++) {
+ XMesaPutPixel(img, x+i, y-j, xmesa->clearpixel);
+ }
+ }
+}
+
+
+
+static void
+clear_buffers( GLcontext *ctx, GLbitfield mask,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height )
+{
+ if (ctx->DrawBuffer->Name == 0) {
+ /* this is a window system framebuffer */
+ const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask;
+ XMesaBuffer b = (XMesaBuffer) ctx->DrawBuffer;
+
+ /* we can't handle color or index masking */
+ if (*colorMask == 0xffffffff && ctx->Color.IndexMask == 0xffffffff) {
+ if (mask & BUFFER_BIT_FRONT_LEFT) {
+ /* clear front color buffer */
+ if (b->frontxrb == (struct xmesa_renderbuffer *)
+ ctx->DrawBuffer->Attachment[BUFFER_FRONT_LEFT].Renderbuffer) {
+ /* renderbuffer is not wrapped - great! */
+ b->frontxrb->clearFunc(ctx, b->frontxrb, all, x, y,
+ width, height);
+ mask &= ~BUFFER_BIT_FRONT_LEFT;
+ }
+ else {
+ /* we can't directly clear an alpha-wrapped color buffer */
+ }
+ }
+ if (mask & BUFFER_BIT_BACK_LEFT) {
+ /* clear back color buffer */
+ if (b->backxrb == (struct xmesa_renderbuffer *)
+ ctx->DrawBuffer->Attachment[BUFFER_BACK_LEFT].Renderbuffer) {
+ /* renderbuffer is not wrapped - great! */
+ b->backxrb->clearFunc(ctx, b->backxrb, all, x, y,
+ width, height);
+ mask &= ~BUFFER_BIT_BACK_LEFT;
+ }
+ }
+ }
+ }
+ if (mask)
+ _swrast_Clear( ctx, mask, all, x, y, width, height );
+}
+
+
+/**
+ * Called by ctx->Driver.ResizeBuffers()
+ * Resize the front/back colorbuffers to match the latest window size.
+ */
+void
+xmesa_resize_buffers(GLcontext *ctx, GLframebuffer *buffer,
+ GLuint width, GLuint height)
+{
+ /* We can do this cast because the first field in the XMesaBuffer
+ * struct is a GLframebuffer struct. If this weren't true, we'd
+ * need a pointer from the GLframebuffer to the XMesaBuffer.
+ */
+ XMesaBuffer xmBuffer = (XMesaBuffer) buffer;
+
+ xmesa_alloc_back_buffer(xmBuffer, width, height);
+
+ _mesa_resize_framebuffer(ctx, buffer, width, height);
+
+ if (ctx)
+ ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */
+}
+
+
+#ifndef XFree86Server
+/* XXX this was never tested in the Xserver environment */
+
+/**
+ * This function implements glDrawPixels() with an XPutImage call when
+ * drawing to the front buffer (X Window drawable).
+ * The image format must be GL_BGRA to match the PF_8R8G8B pixel format.
+ */
+static void
+xmesa_DrawPixels_8R8G8B( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels )
+{
+ struct xmesa_renderbuffer *xrb
+ = (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ const SWcontext *swrast = SWRAST_CONTEXT( ctx );
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ const XMesaGC gc = xmbuf->gc;
+
+ ASSERT(dpy);
+ ASSERT(gc);
+ ASSERT(xmesa->xm_visual->dithered_pf == PF_8R8G8B);
+ ASSERT(xmesa->xm_visual->undithered_pf == PF_8R8G8B);
+
+ if (swrast->NewState)
+ _swrast_validate_derived( ctx );
+
+ if (xrb->pixmap &&
+ format == GL_BGRA &&
+ type == GL_UNSIGNED_BYTE &&
+ (swrast->_RasterMask & ~CLIP_BIT) == 0 && /* no blend, z-test, etc */
+ ctx->_ImageTransferState == 0 && /* no color tables, scale/bias, etc */
+ ctx->Pixel.ZoomX == 1.0 && /* no zooming */
+ ctx->Pixel.ZoomY == 1.0) {
+ int dstX = x;
+ int dstY = y;
+ int w = width;
+ int h = height;
+ int srcX = unpack->SkipPixels;
+ int srcY = unpack->SkipRows;
+ int rowLength = unpack->RowLength ? unpack->RowLength : width;
+
+ if (unpack->BufferObj->Name) {
+ /* unpack from PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
+ format, type, pixels)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDrawPixels(invalid PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx,
+ GL_PIXEL_UNPACK_BUFFER_EXT,
+ GL_READ_ONLY_ARB,
+ unpack->BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDrawPixels(PBO is mapped)");
+ return;
+ }
+ pixels = ADD_POINTERS(buf, pixels);
+ }
+
+ if (_mesa_clip_drawpixels(ctx, &dstX, &dstY, &w, &h, &srcX, &srcY)) {
+ /* This is a little tricky since all coordinates up to now have
+ * been in the OpenGL bottom-to-top orientation. X is top-to-bottom
+ * so we have to carefully compute the Y coordinates/addresses here.
+ */
+ XMesaImage ximage;
+ MEMSET(&ximage, 0, sizeof(XMesaImage));
+ ximage.width = width;
+ ximage.height = height;
+ ximage.format = ZPixmap;
+ ximage.data = (char *) pixels
+ + ((srcY + h - 1) * rowLength + srcX) * 4;
+ ximage.byte_order = LSBFirst;
+ ximage.bitmap_unit = 32;
+ ximage.bitmap_bit_order = LSBFirst;
+ ximage.bitmap_pad = 32;
+ ximage.depth = 24;
+ ximage.bytes_per_line = -rowLength * 4; /* negative to flip image */
+ ximage.bits_per_pixel = 32;
+ /* it seems we don't need to set the ximage.red/green/blue_mask fields */
+ /* flip Y axis for dest position */
+ dstY = YFLIP(xrb, dstY) - h + 1;
+ XPutImage(dpy, xrb->pixmap, gc, &ximage, 0, 0, dstX, dstY, w, h);
+ }
+
+ if (unpack->BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ unpack->BufferObj);
+ }
+ }
+ else {
+ /* software fallback */
+ _swrast_DrawPixels(ctx, x, y, width, height,
+ format, type, unpack, pixels);
+ }
+}
+
+
+
+/**
+ * This function implements glDrawPixels() with an XPutImage call when
+ * drawing to the front buffer (X Window drawable). The image format
+ * must be GL_RGB and image type must be GL_UNSIGNED_SHORT_5_6_5 to
+ * match the PF_5R6G5B pixel format.
+ */
+static void
+xmesa_DrawPixels_5R6G5B( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels )
+{
+ struct xmesa_renderbuffer *xrb
+ = (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ const SWcontext *swrast = SWRAST_CONTEXT( ctx );
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+ const XMesaGC gc = xmbuf->gc;
+
+ ASSERT(dpy);
+ ASSERT(gc);
+ ASSERT(xmesa->xm_visual->undithered_pf == PF_5R6G5B);
+
+ if (swrast->NewState)
+ _swrast_validate_derived( ctx );
+
+ if (xrb->pixmap &&
+ format == GL_RGB &&
+ type == GL_UNSIGNED_SHORT_5_6_5 &&
+ !ctx->Color.DitherFlag && /* no dithering */
+ (swrast->_RasterMask & ~CLIP_BIT) == 0 && /* no blend, z-test, etc */
+ ctx->_ImageTransferState == 0 && /* no color tables, scale/bias, etc */
+ ctx->Pixel.ZoomX == 1.0 && /* no zooming */
+ ctx->Pixel.ZoomY == 1.0) {
+ int dstX = x;
+ int dstY = y;
+ int w = width;
+ int h = height;
+ int srcX = unpack->SkipPixels;
+ int srcY = unpack->SkipRows;
+ int rowLength = unpack->RowLength ? unpack->RowLength : width;
+
+ if (unpack->BufferObj->Name) {
+ /* unpack from PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
+ format, type, pixels)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDrawPixels(invalid PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx,
+ GL_PIXEL_UNPACK_BUFFER_EXT,
+ GL_READ_ONLY_ARB,
+ unpack->BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDrawPixels(PBO is mapped)");
+ return;
+ }
+ pixels = ADD_POINTERS(buf, pixels);
+ }
+
+ if (_mesa_clip_drawpixels(ctx, &dstX, &dstY, &w, &h, &srcX, &srcY)) {
+ /* This is a little tricky since all coordinates up to now have
+ * been in the OpenGL bottom-to-top orientation. X is top-to-bottom
+ * so we have to carefully compute the Y coordinates/addresses here.
+ */
+ XMesaImage ximage;
+ MEMSET(&ximage, 0, sizeof(XMesaImage));
+ ximage.width = width;
+ ximage.height = height;
+ ximage.format = ZPixmap;
+ ximage.data = (char *) pixels
+ + ((srcY + h - 1) * rowLength + srcX) * 2;
+ ximage.byte_order = LSBFirst;
+ ximage.bitmap_unit = 16;
+ ximage.bitmap_bit_order = LSBFirst;
+ ximage.bitmap_pad = 16;
+ ximage.depth = 16;
+ ximage.bytes_per_line = -rowLength * 2; /* negative to flip image */
+ ximage.bits_per_pixel = 16;
+ /* it seems we don't need to set the ximage.red/green/blue_mask fields */
+ /* flip Y axis for dest position */
+ dstY = YFLIP(xrb, dstY) - h + 1;
+ XPutImage(dpy, xrb->pixmap, gc, &ximage, 0, 0, dstX, dstY, w, h);
+ }
+
+ if (unpack->BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ unpack->BufferObj);
+ }
+ }
+ else {
+ /* software fallback */
+ _swrast_DrawPixels(ctx, x, y, width, height,
+ format, type, unpack, pixels);
+ }
+}
+
+
+
+/**
+ * Implement glCopyPixels for the front color buffer (or back buffer Pixmap)
+ * for the color buffer. Don't support zooming, pixel transfer, etc.
+ * We do support copying from one window to another, ala glXMakeCurrentRead.
+ */
+static void
+xmesa_CopyPixels( GLcontext *ctx,
+ GLint srcx, GLint srcy, GLsizei width, GLsizei height,
+ GLint destx, GLint desty, GLenum type )
+{
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ const SWcontext *swrast = SWRAST_CONTEXT( ctx );
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ const XMesaGC gc = ((XMesaBuffer) ctx->DrawBuffer)->gc;
+ struct xmesa_renderbuffer *srcXrb = (struct xmesa_renderbuffer *)
+ ctx->ReadBuffer->_ColorReadBuffer;
+ struct xmesa_renderbuffer *dstXrb = (struct xmesa_renderbuffer *)
+ ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+
+ ASSERT(dpy);
+ ASSERT(gc);
+
+ if (swrast->NewState)
+ _swrast_validate_derived( ctx );
+
+ if (ctx->Color.DrawBuffer[0] == GL_FRONT &&
+ ctx->Pixel.ReadBuffer == GL_FRONT &&
+ srcXrb->pixmap &&
+ dstXrb->pixmap &&
+ type == GL_COLOR &&
+ (swrast->_RasterMask & ~CLIP_BIT) == 0 && /* no blend, z-test, etc */
+ ctx->_ImageTransferState == 0 && /* no color tables, scale/bias, etc */
+ ctx->Pixel.ZoomX == 1.0 && /* no zooming */
+ ctx->Pixel.ZoomY == 1.0) {
+ /* Note: we don't do any special clipping work here. We could,
+ * but X will do it for us.
+ */
+ srcy = YFLIP(srcXrb, srcy) - height + 1;
+ desty = YFLIP(dstXrb, desty) - height + 1;
+ XCopyArea(dpy, srcXrb->pixmap, dstXrb->pixmap, gc,
+ srcx, srcy, width, height, destx, desty);
+ }
+ else {
+ _swrast_CopyPixels(ctx, srcx, srcy, width, height, destx, desty, type );
+ }
+}
+#endif /* XFree86Server */
+
+
+
+/*
+ * Every driver should implement a GetString function in order to
+ * return a meaningful GL_RENDERER string.
+ */
+static const GLubyte *
+get_string( GLcontext *ctx, GLenum name )
+{
+ (void) ctx;
+ switch (name) {
+ case GL_RENDERER:
+#ifdef XFree86Server
+ return (const GLubyte *) "Mesa GLX Indirect";
+#else
+ return (const GLubyte *) "Mesa X11";
+#endif
+ case GL_VENDOR:
+#ifdef XFree86Server
+ return (const GLubyte *) "Mesa project: www.mesa3d.org";
+#else
+ return NULL;
+#endif
+ default:
+ return NULL;
+ }
+}
+
+
+/*
+ * We implement the glEnable function only because we care about
+ * dither enable/disable.
+ */
+static void
+enable( GLcontext *ctx, GLenum pname, GLboolean state )
+{
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+
+ switch (pname) {
+ case GL_DITHER:
+ if (state)
+ xmesa->pixelformat = xmesa->xm_visual->dithered_pf;
+ else
+ xmesa->pixelformat = xmesa->xm_visual->undithered_pf;
+ break;
+ default:
+ ; /* silence compiler warning */
+ }
+}
+
+
+static void
+clear_color_HPCR_ximage( GLcontext *ctx, const GLfloat color[4] )
+{
+ int i;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]);
+
+ if (color[0] == 0.0 && color[1] == 0.0 && color[2] == 0.0) {
+ /* black is black */
+ MEMSET( xmesa->xm_visual->hpcr_clear_ximage_pattern, 0x0 ,
+ sizeof(xmesa->xm_visual->hpcr_clear_ximage_pattern));
+ }
+ else {
+ /* build clear pattern */
+ for (i=0; i<16; i++) {
+ xmesa->xm_visual->hpcr_clear_ximage_pattern[0][i] =
+ DITHER_HPCR(i, 0,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2]);
+ xmesa->xm_visual->hpcr_clear_ximage_pattern[1][i] =
+ DITHER_HPCR(i, 1,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2]);
+ }
+ }
+}
+
+
+static void
+clear_color_HPCR_pixmap( GLcontext *ctx, const GLfloat color[4] )
+{
+ int i;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[0], color[0]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[1], color[1]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[2], color[2]);
+ CLAMPED_FLOAT_TO_UBYTE(xmesa->clearcolor[3], color[3]);
+
+ if (color[0] == 0.0 && color[1] == 0.0 && color[2] == 0.0) {
+ /* black is black */
+ for (i=0; i<16; i++) {
+ XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0, 0);
+ XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 1, 0);
+ }
+ }
+ else {
+ for (i=0; i<16; i++) {
+ XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 0,
+ DITHER_HPCR(i, 0,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2]));
+ XMesaPutPixel(xmesa->xm_visual->hpcr_clear_ximage, i, 1,
+ DITHER_HPCR(i, 1,
+ xmesa->clearcolor[0],
+ xmesa->clearcolor[1],
+ xmesa->clearcolor[2]));
+ }
+ }
+ /* change tile pixmap content */
+ XMesaPutImage(xmesa->display,
+ (XMesaDrawable)xmesa->xm_visual->hpcr_clear_pixmap,
+ XMESA_BUFFER(ctx->DrawBuffer)->cleargc,
+ xmesa->xm_visual->hpcr_clear_ximage, 0, 0, 0, 0, 16, 2);
+}
+
+
+/**
+ * Called when the driver should update it's state, based on the new_state
+ * flags.
+ */
+void
+xmesa_update_state( GLcontext *ctx, GLuint new_state )
+{
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *front_xrb, *back_xrb;
+
+ /* Propagate statechange information to swrast and swrast_setup
+ * modules. The X11 driver has no internal GL-dependent state.
+ */
+ _swrast_InvalidateState( ctx, new_state );
+ _ac_InvalidateState( ctx, new_state );
+ _tnl_InvalidateState( ctx, new_state );
+ _swsetup_InvalidateState( ctx, new_state );
+
+ if (ctx->DrawBuffer->Name != 0)
+ return;
+
+ front_xrb = XMESA_BUFFER(ctx->DrawBuffer)->frontxrb;
+ if (front_xrb) {
+ /* XXX check for relevant new_state flags */
+ xmesa_set_renderbuffer_funcs(front_xrb, xmesa->pixelformat,
+ xmesa->xm_visual->BitsPerPixel);
+ /* setup pointers to front and back buffer clear functions */
+ front_xrb->clearFunc = clear_pixmap;
+ }
+
+ back_xrb = XMESA_BUFFER(ctx->DrawBuffer)->backxrb;
+ if (back_xrb) {
+ XMesaBuffer xmbuf = XMESA_BUFFER(ctx->DrawBuffer);
+
+ /* XXX check for relevant new_state flags */
+ xmesa_set_renderbuffer_funcs(back_xrb, xmesa->pixelformat,
+ xmesa->xm_visual->BitsPerPixel);
+
+ if (xmbuf->backxrb->pixmap) {
+ back_xrb->clearFunc = clear_pixmap;
+ }
+ else {
+ switch (xmesa->xm_visual->BitsPerPixel) {
+ case 8:
+ if (xmesa->xm_visual->hpcr_clear_flag) {
+ back_xrb->clearFunc = clear_HPCR_ximage;
+ }
+ else {
+ back_xrb->clearFunc = clear_8bit_ximage;
+ }
+ break;
+ case 16:
+ back_xrb->clearFunc = clear_16bit_ximage;
+ break;
+ case 24:
+ back_xrb->clearFunc = clear_24bit_ximage;
+ break;
+ case 32:
+ back_xrb->clearFunc = clear_32bit_ximage;
+ break;
+ default:
+ back_xrb->clearFunc = clear_nbit_ximage;
+ break;
+ }
+ }
+ }
+
+ if (xmesa->xm_visual->hpcr_clear_flag) {
+ /* this depends on whether we're drawing to the front or back buffer */
+ /* XXX FIX THIS! */
+#if 0
+ if (pixmap) {
+ ctx->Driver.ClearColor = clear_color_HPCR_pixmap;
+ }
+ else {
+ ctx->Driver.ClearColor = clear_color_HPCR_ximage;
+ }
+#else
+ (void) clear_color_HPCR_pixmap;
+ (void) clear_color_HPCR_ximage;
+#endif
+ }
+}
+
+
+
+/**
+ * Called via ctx->Driver.TestProxyTeximage(). Normally, we'd just use
+ * the _mesa_test_proxy_teximage() fallback function, but we're going to
+ * special-case the 3D texture case to allow textures up to 512x512x32
+ * texels.
+ */
+static GLboolean
+test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat, GLenum format, GLenum type,
+ GLint width, GLint height, GLint depth, GLint border)
+{
+ if (target == GL_PROXY_TEXTURE_3D) {
+ /* special case for 3D textures */
+ if (width * height * depth > 512 * 512 * 64 ||
+ width < 2 * border ||
+ (!ctx->Extensions.ARB_texture_non_power_of_two &&
+ _mesa_bitcount(width - 2 * border) != 1) ||
+ height < 2 * border ||
+ (!ctx->Extensions.ARB_texture_non_power_of_two &&
+ _mesa_bitcount(height - 2 * border) != 1) ||
+ depth < 2 * border ||
+ (!ctx->Extensions.ARB_texture_non_power_of_two &&
+ _mesa_bitcount(depth - 2 * border) != 1)) {
+ /* Bad size, or too many texels */
+ return GL_FALSE;
+ }
+ return GL_TRUE;
+ }
+ else {
+ /* use the fallback routine for 1D, 2D, cube and rect targets */
+ return _mesa_test_proxy_teximage(ctx, target, level, internalFormat,
+ format, type, width, height, depth,
+ border);
+ }
+}
+
+
+/**
+ * In SW, we don't really compress GL_COMPRESSED_RGB[A] textures!
+ */
+static const struct gl_texture_format *
+choose_tex_format( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type )
+{
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGB_ARB:
+ return &_mesa_texformat_rgb;
+ case GL_COMPRESSED_RGBA_ARB:
+ return &_mesa_texformat_rgba;
+ default:
+ return _mesa_choose_tex_format(ctx, internalFormat, format, type);
+ }
+}
+
+
+/**
+ * Called by glViewport.
+ * This is a good time for us to poll the current X window size and adjust
+ * our renderbuffers to match the current window size.
+ * Remember, we have no opportunity to respond to conventional
+ * X Resize/StructureNotify events since the X driver has no event loop.
+ * Thus, we poll.
+ * Note that this trick isn't fool-proof. If the application never calls
+ * glViewport, our notion of the current window size may be incorrect.
+ */
+static void
+xmesa_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
+{
+#if 1
+ struct gl_framebuffer *fb = ctx->WinSysDrawBuffer;
+ GLuint newWidth, newHeight;
+
+ get_buffer_size(fb, &newWidth, &newHeight);
+ if (newWidth != fb->Width || newHeight != fb->Height) {
+ xmesa_resize_buffers(ctx, fb, newWidth, newHeight);
+ }
+#else
+ /* This also works: */
+ _mesa_ResizeBuffersMESA();
+#endif
+}
+
+
+/**
+ * Initialize the device driver function table with the functions
+ * we implement in this driver.
+ */
+void
+xmesa_init_driver_functions( XMesaVisual xmvisual,
+ struct dd_function_table *driver )
+{
+ driver->GetString = get_string;
+ driver->UpdateState = xmesa_update_state;
+ driver->GetBufferSize = get_buffer_size;
+ driver->Flush = finish_or_flush;
+ driver->Finish = finish_or_flush;
+ driver->ClearIndex = clear_index;
+ driver->ClearColor = clear_color;
+ driver->IndexMask = index_mask;
+ driver->ColorMask = color_mask;
+ driver->Enable = enable;
+ driver->Clear = clear_buffers;
+ driver->ResizeBuffers = xmesa_resize_buffers;
+ driver->Viewport = xmesa_viewport;
+#ifndef XFree86Server
+ driver->CopyPixels = xmesa_CopyPixels;
+ if (xmvisual->undithered_pf == PF_8R8G8B &&
+ xmvisual->dithered_pf == PF_8R8G8B) {
+ driver->DrawPixels = xmesa_DrawPixels_8R8G8B;
+ }
+ else if (xmvisual->undithered_pf == PF_5R6G5B) {
+ driver->DrawPixels = xmesa_DrawPixels_5R6G5B;
+ }
+#endif
+ driver->TestProxyTexImage = test_proxy_teximage;
+#if SWTC
+ driver->ChooseTextureFormat = choose_tex_format;
+#else
+ (void) choose_tex_format;
+#endif
+}
+
+
+#define XMESA_NEW_POINT (_NEW_POINT | \
+ _NEW_RENDERMODE | \
+ _SWRAST_NEW_RASTERMASK)
+
+#define XMESA_NEW_LINE (_NEW_LINE | \
+ _NEW_TEXTURE | \
+ _NEW_LIGHT | \
+ _NEW_DEPTH | \
+ _NEW_RENDERMODE | \
+ _SWRAST_NEW_RASTERMASK)
+
+#define XMESA_NEW_TRIANGLE (_NEW_POLYGON | \
+ _NEW_TEXTURE | \
+ _NEW_LIGHT | \
+ _NEW_DEPTH | \
+ _NEW_RENDERMODE | \
+ _SWRAST_NEW_RASTERMASK)
+
+
+/* Extend the software rasterizer with our line/point/triangle
+ * functions.
+ */
+void xmesa_register_swrast_functions( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT( ctx );
+
+ swrast->choose_point = xmesa_choose_point;
+ swrast->choose_line = xmesa_choose_line;
+ swrast->choose_triangle = xmesa_choose_triangle;
+
+ swrast->invalidate_point |= XMESA_NEW_POINT;
+ swrast->invalidate_line |= XMESA_NEW_LINE;
+ swrast->invalidate_triangle |= XMESA_NEW_TRIANGLE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_line.c b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_line.c
new file mode 100644
index 000000000..d7c59739d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_line.c
@@ -0,0 +1,674 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/*
+ * This file contains "accelerated" point, line, and triangle functions.
+ * It should be fairly easy to write new special-purpose point, line or
+ * triangle functions and hook them into this module.
+ */
+
+
+#include "glxheader.h"
+#include "depth.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "xmesaP.h"
+
+/* Internal swrast includes:
+ */
+#include "swrast/s_depth.h"
+#include "swrast/s_points.h"
+#include "swrast/s_lines.h"
+#include "swrast/s_context.h"
+
+
+/**********************************************************************/
+/*** Point rendering ***/
+/**********************************************************************/
+
+
+/*
+ * Render an array of points into a pixmap, any pixel format.
+ */
+#if 000
+/* XXX don't use this, it doesn't dither correctly */
+static void draw_points_ANY_pixmap( GLcontext *ctx, const SWvertex *vert )
+{
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xmesa->xm_buffer->buffer;
+ XMesaGC gc = xmesa->xm_buffer->gc;
+
+ if (xmesa->xm_visual->mesa_visual.RGBAflag) {
+ register int x, y;
+ const GLubyte *color = vert->color;
+ unsigned long pixel = xmesa_color_to_pixel( xmesa,
+ color[0], color[1],
+ color[2], color[3],
+ xmesa->pixelformat);
+ XMesaSetForeground( dpy, gc, pixel );
+ x = (GLint) vert->win[0];
+ y = YFLIP( xrb, (GLint) vert->win[1] );
+ XMesaDrawPoint( dpy, buffer, gc, x, y);
+ }
+ else {
+ /* Color index mode */
+ register int x, y;
+ XMesaSetForeground( dpy, gc, vert->index );
+ x = (GLint) vert->win[0];
+ y = YFLIP( xrb, (GLint) vert->win[1] );
+ XMesaDrawPoint( dpy, buffer, gc, x, y);
+ }
+}
+#endif
+
+
+/* Override the swrast point-selection function. Try to use one of
+ * our internal point functions, otherwise fall back to the standard
+ * swrast functions.
+ */
+void xmesa_choose_point( GLcontext *ctx )
+{
+#if 0
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ if (ctx->RenderMode == GL_RENDER
+ && ctx->Point.Size == 1.0F && !ctx->Point.SmoothFlag
+ && swrast->_RasterMask == 0
+ && !ctx->Texture._EnabledUnits
+ && xmesa->xm_buffer->buffer != XIMAGE) {
+ swrast->Point = draw_points_ANY_pixmap;
+ }
+ else {
+ _swrast_choose_point( ctx );
+ }
+#else
+ _swrast_choose_point( ctx );
+#endif
+}
+
+
+
+/**********************************************************************/
+/*** Line rendering ***/
+/**********************************************************************/
+
+
+#define GET_XRB(XRB) struct xmesa_renderbuffer *XRB = \
+ (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped
+
+
+/*
+ * Draw a flat-shaded, PF_TRUECOLOR line into an XImage.
+ */
+#define NAME flat_TRUECOLOR_line
+#define SETUP_CODE \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
+ const GLubyte *color = vert1->color; \
+ unsigned long pixel; \
+ PACK_TRUECOLOR( pixel, color[0], color[1], color[2] );
+#define CLIP_HACK 1
+#define PLOT(X,Y) XMesaPutPixel(xrb->ximage, X, YFLIP(xrb, Y), pixel );
+#include "swrast/s_linetemp.h"
+
+
+
+/*
+ * Draw a flat-shaded, PF_8A8B8G8R line into an XImage.
+ */
+#define NAME flat_8A8B8G8R_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ const GLubyte *color = vert1->color; \
+ GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] );
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) *pixelPtr = pixel;
+#include "swrast/s_linetemp.h"
+
+
+
+/*
+ * Draw a flat-shaded, PF_8A8R8G8B line into an XImage.
+ */
+#define NAME flat_8A8R8G8B_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ const GLubyte *color = vert1->color; \
+ GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) *pixelPtr = pixel;
+#include "swrast/s_linetemp.h"
+
+
+
+/*
+ * Draw a flat-shaded, PF_8R8G8B line into an XImage.
+ */
+#define NAME flat_8R8G8B_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ const GLubyte *color = vert1->color; \
+ GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] );
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) *pixelPtr = pixel;
+#include "swrast/s_linetemp.h"
+
+
+
+/*
+ * Draw a flat-shaded, PF_8R8G8B24 line into an XImage.
+ */
+#define NAME flat_8R8G8B24_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ const GLubyte *color = vert1->color;
+#define PIXEL_TYPE bgr_t
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) { \
+ pixelPtr->r = color[RCOMP]; \
+ pixelPtr->g = color[GCOMP]; \
+ pixelPtr->b = color[BCOMP]; \
+}
+#include "swrast/s_linetemp.h"
+
+
+
+/*
+ * Draw a flat-shaded, PF_5R6G5B line into an XImage.
+ */
+#define NAME flat_5R6G5B_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ const GLubyte *color = vert1->color; \
+ GLushort pixel = PACK_5R6G5B( color[0], color[1], color[2] );
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) *pixelPtr = pixel;
+#include "swrast/s_linetemp.h"
+
+
+
+/*
+ * Draw a flat-shaded, PF_DITHER_5R6G5B line into an XImage.
+ */
+#define NAME flat_DITHER_5R6G5B_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ const GLubyte *color = vert1->color;
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) PACK_TRUEDITHER( *pixelPtr, X, Y, color[0], color[1], color[2] );
+#include "swrast/s_linetemp.h"
+
+
+
+
+/*
+ * Draw a flat-shaded, PF_DITHER 8-bit line into an XImage.
+ */
+#define NAME flat_DITHER8_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ const GLubyte *color = vert1->color; \
+ GLint r = color[0], g = color[1], b = color[2]; \
+ DITHER_SETUP;
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) *pixelPtr = DITHER(X,Y,r,g,b);
+#include "swrast/s_linetemp.h"
+
+
+
+/*
+ * Draw a flat-shaded, PF_LOOKUP 8-bit line into an XImage.
+ */
+#define NAME flat_LOOKUP8_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ const GLubyte *color = vert1->color; \
+ GLubyte pixel; \
+ LOOKUP_SETUP; \
+ pixel = (GLubyte) LOOKUP( color[0], color[1], color[2] );
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) *pixelPtr = pixel;
+#include "swrast/s_linetemp.h"
+
+
+
+/*
+ * Draw a flat-shaded, PF_HPCR line into an XImage.
+ */
+#define NAME flat_HPCR_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ const GLubyte *color = vert1->color; \
+ GLint r = color[0], g = color[1], b = color[2];
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) *pixelPtr = (GLubyte) DITHER_HPCR(X,Y,r,g,b);
+#include "swrast/s_linetemp.h"
+
+
+
+
+/*
+ * Draw a flat-shaded, Z-less, PF_TRUECOLOR line into an XImage.
+ */
+#define NAME flat_TRUECOLOR_z_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ const GLubyte *color = vert1->color; \
+ unsigned long pixel; \
+ PACK_TRUECOLOR( pixel, color[0], color[1], color[2] );
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define CLIP_HACK 1
+#define PLOT(X,Y) \
+ if (Z < *zPtr) { \
+ *zPtr = Z; \
+ XMesaPutPixel(xrb->ximage, X, YFLIP(xrb, Y), pixel); \
+ }
+#include "swrast/s_linetemp.h"
+
+
+
+/*
+ * Draw a flat-shaded, Z-less, PF_8A8B8G8R line into an XImage.
+ */
+#define NAME flat_8A8B8G8R_z_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ const GLubyte *color = vert1->color; \
+ 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 (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X,Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) \
+ if (Z < *zPtr) { \
+ *zPtr = Z; \
+ *pixelPtr = pixel; \
+ }
+#include "swrast/s_linetemp.h"
+
+
+
+/*
+ * Draw a flat-shaded, Z-less, PF_8A8R8G8B line into an XImage.
+ */
+#define NAME flat_8A8R8G8B_z_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ const GLubyte *color = vert1->color; \
+ 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 (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X,Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) \
+ if (Z < *zPtr) { \
+ *zPtr = Z; \
+ *pixelPtr = pixel; \
+ }
+#include "swrast/s_linetemp.h"
+
+
+
+/*
+ * Draw a flat-shaded, Z-less, PF_8R8G8B line into an XImage.
+ */
+#define NAME flat_8R8G8B_z_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ const GLubyte *color = vert1->color; \
+ 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 (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X,Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) \
+ if (Z < *zPtr) { \
+ *zPtr = Z; \
+ *pixelPtr = pixel; \
+ }
+#include "swrast/s_linetemp.h"
+
+
+
+/*
+ * Draw a flat-shaded, Z-less, PF_8R8G8B24 line into an XImage.
+ */
+#define NAME flat_8R8G8B24_z_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ const GLubyte *color = vert1->color;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_TYPE bgr_t
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X,Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) \
+ if (Z < *zPtr) { \
+ *zPtr = Z; \
+ pixelPtr->r = color[RCOMP]; \
+ pixelPtr->g = color[GCOMP]; \
+ pixelPtr->b = color[BCOMP]; \
+ }
+#include "swrast/s_linetemp.h"
+
+
+
+/*
+ * Draw a flat-shaded, Z-less, PF_5R6G5B line into an XImage.
+ */
+#define NAME flat_5R6G5B_z_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ const GLubyte *color = vert1->color; \
+ 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 (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X,Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) \
+ if (Z < *zPtr) { \
+ *zPtr = Z; \
+ *pixelPtr = pixel; \
+ }
+#include "swrast/s_linetemp.h"
+
+
+
+/*
+ * Draw a flat-shaded, Z-less, PF_DITHER_5R6G5B line into an XImage.
+ */
+#define NAME flat_DITHER_5R6G5B_z_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ const GLubyte *color = vert1->color;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X,Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) \
+ if (Z < *zPtr) { \
+ *zPtr = Z; \
+ PACK_TRUEDITHER(*pixelPtr, X, Y, color[0], color[1], color[2]); \
+ }
+#include "swrast/s_linetemp.h"
+
+
+
+/*
+ * Draw a flat-shaded, Z-less, PF_DITHER 8-bit line into an XImage.
+ */
+#define NAME flat_DITHER8_z_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ const GLubyte *color = vert1->color; \
+ GLint r = color[0], g = color[1], b = color[2]; \
+ DITHER_SETUP;
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) \
+ if (Z < *zPtr) { \
+ *zPtr = Z; \
+ *pixelPtr = (GLubyte) DITHER( X, Y, r, g, b); \
+ }
+#include "swrast/s_linetemp.h"
+
+
+
+/*
+ * Draw a flat-shaded, Z-less, PF_LOOKUP 8-bit line into an XImage.
+ */
+#define NAME flat_LOOKUP8_z_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ const GLubyte *color = vert1->color; \
+ GLubyte pixel; \
+ LOOKUP_SETUP; \
+ 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 (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) \
+ if (Z < *zPtr) { \
+ *zPtr = Z; \
+ *pixelPtr = pixel; \
+ }
+#include "swrast/s_linetemp.h"
+
+
+
+/*
+ * Draw a flat-shaded, Z-less, PF_HPCR line into an XImage.
+ */
+#define NAME flat_HPCR_z_line
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ const GLubyte *color = vert1->color; \
+ GLint r = color[0], g = color[1], b = color[2];
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X,Y)
+#define CLIP_HACK 1
+#define PLOT(X,Y) \
+ if (Z < *zPtr) { \
+ *zPtr = Z; \
+ *pixelPtr = (GLubyte) DITHER_HPCR( X, Y, r, g, b); \
+ }
+#include "swrast/s_linetemp.h"
+
+
+
+#ifndef XFree86Server
+/**
+ * Draw fast, XOR line with XDrawLine in front color buffer.
+ * WARNING: this isn't fully OpenGL conformant because different pixels
+ * will be hit versus using the other line functions.
+ * Don't use the code in X server GLcore module since we need a wrapper
+ * for the XSetLineAttributes() function call.
+ */
+static void
+xor_line(GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1)
+{
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaGC gc = xmesa->xm_buffer->gc;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *)
+ ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+ unsigned long pixel = xmesa_color_to_pixel(ctx,
+ vert1->color[0], vert1->color[1],
+ vert1->color[2], vert1->color[3],
+ xmesa->pixelformat);
+ int x0 = (int) vert0->win[0];
+ int y0 = YFLIP(xrb, (GLint) vert0->win[1]);
+ int x1 = (int) vert1->win[0];
+ int y1 = YFLIP(xrb, (GLint) vert1->win[1]);
+ XMesaSetForeground(dpy, gc, pixel);
+ XMesaSetFunction(dpy, gc, GXxor);
+ XSetLineAttributes(dpy, gc, (int) ctx->Line.Width,
+ LineSolid, CapButt, JoinMiter);
+ XDrawLine(dpy, xrb->pixmap, gc, x0, y0, x1, y1);
+ XMesaSetFunction(dpy, gc, GXcopy); /* this gc is used elsewhere */
+}
+#endif /* XFree86Server */
+
+
+static swrast_line_func get_line_func( GLcontext *ctx )
+{
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
+ GET_XRB(xrb);
+
+ if ((ctx->DrawBuffer->_ColorDrawBufferMask[0]
+ & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) == 0)
+ return (swrast_line_func) NULL;
+ if (ctx->RenderMode != GL_RENDER) return (swrast_line_func) NULL;
+ if (ctx->Line.SmoothFlag) return (swrast_line_func) NULL;
+ if (ctx->Texture._EnabledUnits) return (swrast_line_func) NULL;
+ if (ctx->Light.ShadeModel != GL_FLAT) return (swrast_line_func) NULL;
+ if (ctx->Line.StippleFlag) return (swrast_line_func) NULL;
+ if (swrast->_RasterMask & MULTI_DRAW_BIT) return (swrast_line_func) NULL;
+
+ if (xrb->ximage
+ && swrast->_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:
+ return flat_TRUECOLOR_z_line;
+ case PF_8A8B8G8R:
+ return flat_8A8B8G8R_z_line;
+ case PF_8A8R8G8B:
+ return flat_8A8R8G8B_z_line;
+ case PF_8R8G8B:
+ return flat_8R8G8B_z_line;
+ case PF_8R8G8B24:
+ return flat_8R8G8B24_z_line;
+ case PF_5R6G5B:
+ return flat_5R6G5B_z_line;
+ case PF_Dither_5R6G5B:
+ return flat_DITHER_5R6G5B_z_line;
+ case PF_Dither:
+ return (depth==8) ? flat_DITHER8_z_line : (swrast_line_func) NULL;
+ case PF_Lookup:
+ return (depth==8) ? flat_LOOKUP8_z_line : (swrast_line_func) NULL;
+ case PF_HPCR:
+ return flat_HPCR_z_line;
+ default:
+ return (swrast_line_func)NULL;
+ }
+ }
+ if (xrb->ximage
+ && swrast->_RasterMask==0
+ && ctx->Line.Width==1.0F) {
+ switch (xmesa->pixelformat) {
+ case PF_Truecolor:
+ return flat_TRUECOLOR_line;
+ case PF_8A8B8G8R:
+ return flat_8A8B8G8R_line;
+ case PF_8A8R8G8B:
+ return flat_8A8R8G8B_line;
+ case PF_8R8G8B:
+ return flat_8R8G8B_line;
+ case PF_8R8G8B24:
+ return flat_8R8G8B24_line;
+ case PF_5R6G5B:
+ return flat_5R6G5B_line;
+ case PF_Dither_5R6G5B:
+ return flat_DITHER_5R6G5B_line;
+ case PF_Dither:
+ return (depth==8) ? flat_DITHER8_line : (swrast_line_func) NULL;
+ case PF_Lookup:
+ return (depth==8) ? flat_LOOKUP8_line : (swrast_line_func) NULL;
+ case PF_HPCR:
+ return flat_HPCR_line;
+ default:
+ return (swrast_line_func)NULL;
+ }
+ }
+
+#ifndef XFree86Server
+ if (ctx->DrawBuffer->_NumColorDrawBuffers[0] == 1
+ && ctx->DrawBuffer->_ColorDrawBufferMask[0] == BUFFER_BIT_FRONT_LEFT
+ && swrast->_RasterMask == LOGIC_OP_BIT
+ && ctx->Color.LogicOp == GL_XOR
+ && !ctx->Line.StippleFlag
+ && !ctx->Line.SmoothFlag) {
+ return xor_line;
+ }
+#endif /* XFree86Server */
+
+ return (swrast_line_func) NULL;
+}
+
+
+/**
+ * Override for the swrast line-selection function. Try to use one
+ * of our internal line functions, otherwise fall back to the
+ * standard swrast functions.
+ */
+void
+xmesa_choose_line(GLcontext *ctx)
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ if (!(swrast->Line = get_line_func( ctx )))
+ _swrast_choose_line( ctx );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_span.c b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_span.c
new file mode 100644
index 000000000..664f365df
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_span.c
@@ -0,0 +1,4800 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+/* $XFree86: xc/extras/Mesa/src/X/xm_span.c,v 1.3 2002/02/27 21:07:54 tsi Exp $ */
+
+#include "glxheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "depth.h"
+#include "drawpix.h"
+#include "extensions.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "state.h"
+#include "xmesaP.h"
+
+#include "swrast/swrast.h"
+
+
+/*
+ * The following functions are used to trap XGetImage() calls which
+ * generate BadMatch errors if the drawable isn't mapped.
+ */
+
+#ifndef XFree86Server
+static int caught_xgetimage_error = 0;
+static int (*old_xerror_handler)( XMesaDisplay *dpy, XErrorEvent *ev );
+static unsigned long xgetimage_serial;
+
+/*
+ * This is the error handler which will be called if XGetImage fails.
+ */
+static int xgetimage_error_handler( XMesaDisplay *dpy, XErrorEvent *ev )
+{
+ if (ev->serial==xgetimage_serial && ev->error_code==BadMatch) {
+ /* caught the expected error */
+ caught_xgetimage_error = 0;
+ }
+ else {
+ /* call the original X error handler, if any. otherwise ignore */
+ if (old_xerror_handler) {
+ (*old_xerror_handler)( dpy, ev );
+ }
+ }
+ return 0;
+}
+
+
+/*
+ * Call this right before XGetImage to setup error trap.
+ */
+static void catch_xgetimage_errors( XMesaDisplay *dpy )
+{
+ xgetimage_serial = NextRequest( dpy );
+ old_xerror_handler = XSetErrorHandler( xgetimage_error_handler );
+ caught_xgetimage_error = 0;
+}
+
+
+/*
+ * Call this right after XGetImage to check if an error occured.
+ */
+static int check_xgetimage_errors( void )
+{
+ /* restore old handler */
+ (void) XSetErrorHandler( old_xerror_handler );
+ /* return 0=no error, 1=error caught */
+ return caught_xgetimage_error;
+}
+#endif
+
+
+/*
+ * Read a pixel from an X drawable.
+ */
+static unsigned long read_pixel( XMesaDisplay *dpy,
+ XMesaDrawable d, int x, int y )
+{
+ unsigned long p;
+#ifndef XFree86Server
+ XMesaImage *pixel = NULL;
+ int error;
+
+ catch_xgetimage_errors( dpy );
+ pixel = XGetImage( dpy, d, x, y, 1, 1, AllPlanes, ZPixmap );
+ error = check_xgetimage_errors();
+ if (pixel && !error) {
+ p = XMesaGetPixel( pixel, 0, 0 );
+ }
+ else {
+ p = 0;
+ }
+ if (pixel) {
+ XMesaDestroyImage( pixel );
+ }
+#else
+ (*dpy->GetImage)(d, x, y, 1, 1, ZPixmap, ~0L, (pointer)&p);
+#endif
+ return p;
+}
+
+
+
+/*
+ * The Mesa library needs to be able to draw pixels in a number of ways:
+ * 1. RGB vs Color Index
+ * 2. as horizontal spans (polygons, images) vs random locations (points,
+ * lines)
+ * 3. different color per-pixel or same color for all pixels
+ *
+ * Furthermore, the X driver needs to support rendering to 3 possible
+ * "buffers", usually one, but sometimes two at a time:
+ * 1. The front buffer as an X window
+ * 2. The back buffer as a Pixmap
+ * 3. The back buffer as an XImage
+ *
+ * Finally, if the back buffer is an XImage, we can avoid using XPutPixel and
+ * optimize common cases such as 24-bit and 8-bit modes.
+ *
+ * By multiplication, there's at least 48 possible combinations of the above.
+ *
+ * Below are implementations of the most commonly used combinations. They are
+ * accessed through function pointers which get initialized here and are used
+ * directly from the Mesa library. The 8 function pointers directly correspond
+ * to the first 3 cases listed above.
+ *
+ *
+ * The function naming convention is:
+ *
+ * [put|get]_[mono]_[row|values]_[format]_[pixmap|ximage]
+ *
+ * New functions optimized for specific cases can be added without too much
+ * trouble. An example might be the 24-bit TrueColor mode 8A8R8G8B which is
+ * found on IBM RS/6000 X servers.
+ */
+
+
+
+
+/**********************************************************************/
+/*** Write COLOR SPAN functions ***/
+/**********************************************************************/
+
+
+#define PUT_ROW_ARGS \
+ GLcontext *ctx, \
+ struct gl_renderbuffer *rb, \
+ GLuint n, GLint x, GLint y, \
+ const void *values, const GLubyte mask[]
+
+#define RGB_SPAN_ARGS \
+ GLcontext *ctx, \
+ struct gl_renderbuffer *rb, \
+ GLuint n, GLint x, GLint y, \
+ const void *values, const GLubyte mask[]
+
+
+/* NOTE: if mask==NULL, draw all pixels */
+
+
+/*
+ * Write a span of PF_TRUECOLOR pixels to a pixmap.
+ */
+static void put_row_TRUECOLOR_pixmap( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = XMESA_BUFFER(ctx->DrawBuffer)->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ unsigned long p;
+ PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ XMesaSetForeground( dpy, gc, p );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ for (i=0;i<n;i++) {
+ unsigned long p;
+ PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ XMesaPutPixel( rowimg, i, 0, p );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_TRUECOLOR pixels to a pixmap.
+ */
+static void put_row_rgb_TRUECOLOR_pixmap( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ unsigned long p;
+ PACK_TRUECOLOR( p, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
+ XMesaSetForeground( dpy, gc, p );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ for (i=0;i<n;i++) {
+ unsigned long p;
+ PACK_TRUECOLOR( p, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
+ XMesaPutPixel( rowimg, i, 0, p );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+/*
+ * Write a span of PF_TRUEDITHER pixels to a pixmap.
+ */
+static void put_row_TRUEDITHER_pixmap( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ unsigned long p;
+ PACK_TRUEDITHER(p, x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
+ XMesaSetForeground( dpy, gc, p );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ for (i=0;i<n;i++) {
+ unsigned long p;
+ PACK_TRUEDITHER(p, x+i, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
+ XMesaPutPixel( rowimg, i, 0, p );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_TRUEDITHER pixels to a pixmap (no alpha).
+ */
+static void put_row_rgb_TRUEDITHER_pixmap( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ unsigned long p;
+ PACK_TRUEDITHER(p, x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
+ XMesaSetForeground( dpy, gc, p );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ for (i=0;i<n;i++) {
+ unsigned long p;
+ PACK_TRUEDITHER(p, x+i, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
+ XMesaPutPixel( rowimg, i, 0, p );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_8A8B8G8R pixels to a pixmap.
+ */
+static void put_row_8A8B8G8R_pixmap( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc,
+ PACK_8A8B8G8R(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ register GLuint *ptr4 = (GLuint *) rowimg->data;
+ for (i=0;i<n;i++) {
+ *ptr4++ = PACK_8A8B8G8R( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_8A8B8G8R pixels to a pixmap (no alpha).
+ */
+static void put_row_rgb_8A8B8G8R_pixmap( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc,
+ PACK_8B8G8R(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ register GLuint *ptr4 = (GLuint *) rowimg->data;
+ for (i=0;i<n;i++) {
+ *ptr4++ = PACK_8B8G8R(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+/*
+ * Write a span of PF_8A8R8G8B pixels to a pixmap.
+ */
+static void put_row_8A8R8G8B_pixmap( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc,
+ PACK_8A8R8G8B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ register GLuint *ptr4 = (GLuint *) rowimg->data;
+ for (i=0;i<n;i++) {
+ *ptr4++ = PACK_8A8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_8A8R8G8B pixels to a pixmap (no alpha).
+ */
+static void put_row_rgb_8A8R8G8B_pixmap( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc,
+ PACK_8R8G8B(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ register GLuint *ptr4 = (GLuint *) rowimg->data;
+ for (i=0;i<n;i++) {
+ *ptr4++ = PACK_8R8G8B(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+/*
+ * Write a span of PF_8R8G8B pixels to a pixmap.
+ */
+static void put_row_8R8G8B_pixmap( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ register GLuint *ptr4 = (GLuint *) rowimg->data;
+ for (i=0;i<n;i++) {
+ *ptr4++ = PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_8R8G8B24 pixels to a pixmap.
+ */
+static void put_row_8R8G8B24_pixmap( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ register GLuint i;
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc,
+ PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ register GLuint *ptr4 = (GLuint *) rowimg->data;
+ register GLuint pixel;
+ static const GLuint shift[4] = {0, 8, 16, 24};
+ register GLuint i = 0;
+ int w = n;
+ while (w > 3) {
+ pixel = rgba[i][BCOMP] /* << shift[0]*/;
+ pixel |= rgba[i][GCOMP] << shift[1];
+ pixel |= rgba[i++][RCOMP] << shift[2];
+ pixel |= rgba[i][BCOMP] << shift[3];
+ *ptr4++ = pixel;
+
+ pixel = rgba[i][GCOMP] /* << shift[0]*/;
+ pixel |= rgba[i++][RCOMP] << shift[1];
+ pixel |= rgba[i][BCOMP] << shift[2];
+ pixel |= rgba[i][GCOMP] << shift[3];
+ *ptr4++ = pixel;
+
+ pixel = rgba[i++][RCOMP]/* << shift[0]*/;
+ pixel |= rgba[i][BCOMP] << shift[1];
+ pixel |= rgba[i][GCOMP] << shift[2];
+ pixel |= rgba[i++][RCOMP] << shift[3];
+ *ptr4++ = pixel;
+
+ w -= 4;
+ }
+ switch (w) {
+ case 3:
+ pixel = 0;
+ pixel |= rgba[i][BCOMP] /*<< shift[0]*/;
+ pixel |= rgba[i][GCOMP] << shift[1];
+ pixel |= rgba[i++][RCOMP] << shift[2];
+ pixel |= rgba[i][BCOMP] << shift[3];
+ *ptr4++ = pixel;
+ pixel = 0;
+ pixel |= rgba[i][GCOMP] /*<< shift[0]*/;
+ pixel |= rgba[i++][RCOMP] << shift[1];
+ pixel |= rgba[i][BCOMP] << shift[2];
+ pixel |= rgba[i][GCOMP] << shift[3];
+ *ptr4++ = pixel;
+ pixel = 0xffffff00 & *ptr4;
+ pixel |= rgba[i][RCOMP] /*<< shift[0]*/;
+ *ptr4 = pixel;
+ break;
+ case 2:
+ pixel = 0;
+ pixel |= rgba[i][BCOMP] /*<< shift[0]*/;
+ pixel |= rgba[i][GCOMP] << shift[1];
+ pixel |= rgba[i++][RCOMP] << shift[2];
+ pixel |= rgba[i][BCOMP] << shift[3];
+ *ptr4++ = pixel;
+ pixel = 0xffff0000 & *ptr4;
+ pixel |= rgba[i][GCOMP] /*<< shift[0]*/;
+ pixel |= rgba[i][RCOMP] << shift[1];
+ *ptr4 = pixel;
+ break;
+ case 1:
+ pixel = 0xff000000 & *ptr4;
+ pixel |= rgba[i][BCOMP] /*<< shift[0]*/;
+ pixel |= rgba[i][GCOMP] << shift[1];
+ pixel |= rgba[i][RCOMP] << shift[2];
+ *ptr4 = pixel;
+ break;
+ case 0:
+ break;
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_8R8G8B pixels to a pixmap (no alpha).
+ */
+static void put_row_rgb_8R8G8B_pixmap( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, PACK_8R8G8B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ));
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ register GLuint *ptr4 = (GLuint *) rowimg->data;
+ for (i=0;i<n;i++) {
+ *ptr4++ = PACK_8R8G8B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+/*
+ * Write a span of PF_8R8G8B24 pixels to a pixmap (no alpha).
+ */
+static void put_row_rgb_8R8G8B24_pixmap( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ register GLuint i;
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc,
+ PACK_8R8G8B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ));
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ register GLuint *ptr4 = (GLuint *) rowimg->data;
+ register GLuint pixel;
+ static const GLuint shift[4] = {0, 8, 16, 24};
+ unsigned w = n;
+ register GLuint i = 0;
+ while (w > 3) {
+ pixel = 0;
+ pixel |= rgb[i][BCOMP]/* << shift[0]*/;
+ pixel |= rgb[i][GCOMP] << shift[1];
+ pixel |= rgb[i++][RCOMP] << shift[2];
+ pixel |= rgb[i][BCOMP] <<shift[3];
+ *ptr4++ = pixel;
+
+ pixel = 0;
+ pixel |= rgb[i][GCOMP]/* << shift[0]*/;
+ pixel |= rgb[i++][RCOMP] << shift[1];
+ pixel |= rgb[i][BCOMP] << shift[2];
+ pixel |= rgb[i][GCOMP] << shift[3];
+ *ptr4++ = pixel;
+
+ pixel = 0;
+ pixel |= rgb[i++][RCOMP]/* << shift[0]*/;
+ pixel |= rgb[i][BCOMP] << shift[1];
+ pixel |= rgb[i][GCOMP] << shift[2];
+ pixel |= rgb[i++][RCOMP] << shift[3];
+ *ptr4++ = pixel;
+ w -= 4;
+ }
+ switch (w) {
+ case 3:
+ pixel = 0;
+ pixel |= rgb[i][BCOMP]/* << shift[0]*/;
+ pixel |= rgb[i][GCOMP] << shift[1];
+ pixel |= rgb[i++][RCOMP] << shift[2];
+ pixel |= rgb[i][BCOMP] << shift[3];
+ *ptr4++ = pixel;
+ pixel = 0;
+ pixel |= rgb[i][GCOMP]/* << shift[0]*/;
+ pixel |= rgb[i++][RCOMP] << shift[1];
+ pixel |= rgb[i][BCOMP] << shift[2];
+ pixel |= rgb[i][GCOMP] << shift[3];
+ *ptr4++ = pixel;
+ pixel = *ptr4;
+ pixel &= 0xffffff00;
+ pixel |= rgb[i++][RCOMP]/* << shift[0]*/;
+ *ptr4++ = pixel;
+ break;
+ case 2:
+ pixel = 0;
+ pixel |= rgb[i][BCOMP]/* << shift[0]*/;
+ pixel |= rgb[i][GCOMP] << shift[1];
+ pixel |= rgb[i++][RCOMP] << shift[2];
+ pixel |= rgb[i][BCOMP] << shift[3];
+ *ptr4++ = pixel;
+ pixel = *ptr4;
+ pixel &= 0xffff0000;
+ pixel |= rgb[i][GCOMP]/* << shift[0]*/;
+ pixel |= rgb[i++][RCOMP] << shift[1];
+ *ptr4++ = pixel;
+ break;
+ case 1:
+ pixel = *ptr4;
+ pixel &= 0xff000000;
+ pixel |= rgb[i][BCOMP]/* << shift[0]*/;
+ pixel |= rgb[i][GCOMP] << shift[1];
+ pixel |= rgb[i++][RCOMP] << shift[2];
+ *ptr4++ = pixel;
+ break;
+ case 0:
+ break;
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_5R6G5B pixels to a pixmap.
+ */
+static void put_row_5R6G5B_pixmap( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ register GLushort *ptr2 = (GLushort *) rowimg->data;
+ for (i=0;i<n;i++) {
+ ptr2[i] = PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_DITHER_5R6G5B pixels to a pixmap.
+ */
+static void put_row_DITHER_5R6G5B_pixmap( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ unsigned long p;
+ PACK_TRUEDITHER(p, x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
+ XMesaSetForeground( dpy, gc, p );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ register GLushort *ptr2 = (GLushort *) rowimg->data;
+ for (i=0;i<n;i++) {
+ PACK_TRUEDITHER( ptr2[i], x+i, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_5R6G5B pixels to a pixmap (no alpha).
+ */
+static void put_row_rgb_5R6G5B_pixmap( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, PACK_5R6G5B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ));
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ register GLushort *ptr2 = (GLushort *) rowimg->data;
+ for (i=0;i<n;i++) {
+ ptr2[i] = PACK_5R6G5B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_DITHER_5R6G5B pixels to a pixmap (no alpha).
+ */
+static void put_row_rgb_DITHER_5R6G5B_pixmap( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ unsigned long p;
+ PACK_TRUEDITHER(p, x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
+ XMesaSetForeground( dpy, gc, p );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ register GLushort *ptr2 = (GLushort *) rowimg->data;
+ for (i=0;i<n;i++) {
+ PACK_TRUEDITHER( ptr2[i], x+i, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_DITHER pixels to a pixmap.
+ */
+static void put_row_DITHER_pixmap( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ XDITHER_SETUP(y);
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, XDITHER(x, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ for (i=0;i<n;i++) {
+ XMesaPutPixel( rowimg, i, 0, XDITHER(x+i, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_DITHER pixels to a pixmap (no alpha).
+ */
+static void put_row_rgb_DITHER_pixmap( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ XDITHER_SETUP(y);
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, XDITHER(x, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ for (i=0;i<n;i++) {
+ XMesaPutPixel( rowimg, i, 0, XDITHER(x+i, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]) );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_1BIT pixels to a pixmap.
+ */
+static void put_row_1BIT_pixmap( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ SETUP_1BIT;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc,
+ DITHER_1BIT( x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ for (i=0;i<n;i++) {
+ XMesaPutPixel( rowimg, i, 0,
+ DITHER_1BIT( x+i, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_1BIT pixels to a pixmap (no alpha).
+ */
+static void put_row_rgb_1BIT_pixmap( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ SETUP_1BIT;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc,
+ DITHER_1BIT(x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ for (i=0;i<n;i++) {
+ XMesaPutPixel( rowimg, i, 0,
+ DITHER_1BIT(x+i, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]) );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_HPCR pixels to a pixmap.
+ */
+static void put_row_HPCR_pixmap( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc,
+ DITHER_HPCR( x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ register GLubyte *ptr = (GLubyte *) XMESA_BUFFER(ctx->DrawBuffer)->rowimage->data;
+ for (i=0;i<n;i++) {
+ ptr[i] = DITHER_HPCR( (x+i), y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_HPCR pixels to a pixmap (no alpha).
+ */
+static void put_row_rgb_HPCR_pixmap( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc,
+ DITHER_HPCR(x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ register GLubyte *ptr = (GLubyte *) XMESA_BUFFER(ctx->DrawBuffer)->rowimage->data;
+ for (i=0;i<n;i++) {
+ ptr[i] = DITHER_HPCR( (x+i), y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+/*
+ * Write a span of PF_LOOKUP pixels to a pixmap.
+ */
+static void put_row_LOOKUP_pixmap( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ LOOKUP_SETUP;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ for (i=0;i<n;i++) {
+ XMesaPutPixel( rowimg, i, 0, LOOKUP(rgba[i][RCOMP],rgba[i][GCOMP],rgba[i][BCOMP]) );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_LOOKUP pixels to a pixmap (no alpha).
+ */
+static void put_row_rgb_LOOKUP_pixmap( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ LOOKUP_SETUP;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, LOOKUP( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ for (i=0;i<n;i++) {
+ XMesaPutPixel( rowimg, i, 0, LOOKUP(rgb[i][RCOMP],rgb[i][GCOMP],rgb[i][BCOMP]) );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_GRAYSCALE pixels to a pixmap.
+ */
+static void put_row_GRAYSCALE_pixmap( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ for (i=0;i<n;i++) {
+ XMesaPutPixel( rowimg, i, 0, GRAY_RGB(rgba[i][RCOMP],rgba[i][GCOMP],rgba[i][BCOMP]) );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+
+/*
+ * Write a span of PF_GRAYSCALE pixels to a pixmap (no alpha).
+ */
+static void put_row_rgb_GRAYSCALE_pixmap( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, GRAY_RGB( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ XMesaImage *rowimg = XMESA_BUFFER(ctx->DrawBuffer)->rowimage;
+ for (i=0;i<n;i++) {
+ XMesaPutPixel( rowimg, i, 0, GRAY_RGB(rgb[i][RCOMP],rgb[i][GCOMP],rgb[i][BCOMP]) );
+ }
+ XMesaPutImage( dpy, buffer, gc, rowimg, 0, 0, x, y, n, 1 );
+ }
+}
+
+/*
+ * Write a span of PF_TRUECOLOR pixels to an XImage.
+ */
+static void put_row_TRUECOLOR_ximage( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ unsigned long p;
+ PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ XMesaPutPixel( img, x, y, p );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++,x++) {
+ unsigned long p;
+ PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ XMesaPutPixel( img, x, y, p );
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_TRUECOLOR pixels to an XImage (no alpha).
+ */
+static void put_row_rgb_TRUECOLOR_ximage( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ unsigned long p;
+ PACK_TRUECOLOR( p, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
+ XMesaPutPixel( img, x, y, p );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++,x++) {
+ unsigned long p;
+ PACK_TRUECOLOR( p, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
+ XMesaPutPixel( img, x, y, p );
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_TRUEDITHER pixels to an XImage.
+ */
+static void put_row_TRUEDITHER_ximage( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ unsigned long p;
+ PACK_TRUEDITHER(p, x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
+ XMesaPutPixel( img, x, y, p );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++,x++) {
+ unsigned long p;
+ PACK_TRUEDITHER(p, x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
+ XMesaPutPixel( img, x, y, p );
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_TRUEDITHER pixels to an XImage (no alpha).
+ */
+static void put_row_rgb_TRUEDITHER_ximage( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ unsigned long p;
+ PACK_TRUEDITHER(p, x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
+ XMesaPutPixel( img, x, y, p );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++,x++) {
+ unsigned long p;
+ PACK_TRUEDITHER(p, x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
+ XMesaPutPixel( img, x, y, p );
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_8A8B8G8R-format pixels to an ximage.
+ */
+static void put_row_8A8B8G8R_ximage( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
+ if (mask) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ ptr[i] = PACK_8A8B8G8R( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++) {
+ ptr[i] = PACK_8A8B8G8R( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_8A8B8G8R-format pixels to an ximage (no alpha).
+ */
+static void put_row_rgb_8A8B8G8R_ximage( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
+ if (mask) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ ptr[i] = PACK_8A8B8G8R( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP], 255 );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++) {
+ ptr[i] = PACK_8A8B8G8R( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP], 255 );
+ }
+ }
+}
+
+/*
+ * Write a span of PF_8A8R8G8B-format pixels to an ximage.
+ */
+static void put_row_8A8R8G8B_ximage( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
+ if (mask) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ ptr[i] = PACK_8A8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++) {
+ ptr[i] = PACK_8A8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_8A8R8G8B-format pixels to an ximage (no alpha).
+ */
+static void put_row_rgb_8A8R8G8B_ximage( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
+ if (mask) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ ptr[i] = PACK_8A8R8G8B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP], 255 );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++) {
+ ptr[i] = PACK_8A8R8G8B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP], 255 );
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_8R8G8B-format pixels to an ximage.
+ */
+static void put_row_8R8G8B_ximage( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
+ if (mask) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ ptr[i] = PACK_8R8G8B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ ptr[i] = PACK_8R8G8B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_8R8G8B24-format pixels to an ximage.
+ */
+static void put_row_8R8G8B24_ximage( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLubyte *ptr = (GLubyte *) PIXEL_ADDR3(xrb, x, y );
+ if (mask) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLuint *ptr4 = (GLuint *) ptr;
+ register GLuint pixel = *ptr4;
+ switch (3 & (int)(ptr - (GLubyte*)ptr4)) {
+ case 0:
+ pixel &= 0xff000000;
+ pixel |= rgba[i][BCOMP];
+ pixel |= rgba[i][GCOMP] << 8;
+ pixel |= rgba[i][RCOMP] << 16;
+ *ptr4 = pixel;
+ break;
+ case 3:
+ pixel &= 0x00ffffff;
+ pixel |= rgba[i][BCOMP] << 24;
+ *ptr4++ = pixel;
+ pixel = *ptr4 && 0xffff0000;
+ pixel |= rgba[i][GCOMP];
+ pixel |= rgba[i][RCOMP] << 8;
+ *ptr4 = pixel;
+ break;
+ case 2:
+ pixel &= 0x0000ffff;
+ pixel |= rgba[i][BCOMP] << 16;
+ pixel |= rgba[i][GCOMP] << 24;
+ *ptr4++ = pixel;
+ pixel = *ptr4 && 0xffffff00;
+ pixel |= rgba[i][RCOMP];
+ *ptr4 = pixel;
+ break;
+ case 1:
+ pixel &= 0x000000ff;
+ pixel |= rgba[i][BCOMP] << 8;
+ pixel |= rgba[i][GCOMP] << 16;
+ pixel |= rgba[i][RCOMP] << 24;
+ *ptr4 = pixel;
+ break;
+ }
+ }
+ ptr += 3;
+ }
+ }
+ else {
+ /* write all pixels */
+ int w = n;
+ GLuint *ptr4 = (GLuint *) ptr;
+ register GLuint pixel = *ptr4;
+ int index = (int)(ptr - (GLubyte *)ptr4);
+ register GLuint i = 0;
+ switch (index) {
+ case 0:
+ break;
+ case 1:
+ pixel &= 0x00ffffff;
+ pixel |= rgba[i][BCOMP] << 24;
+ *ptr4++ = pixel;
+ pixel = *ptr4 && 0xffff0000;
+ pixel |= rgba[i][GCOMP];
+ pixel |= rgba[i++][RCOMP] << 8;
+ *ptr4 = pixel;
+ if (0 == --w)
+ break;
+ case 2:
+ pixel &= 0x0000ffff;
+ pixel |= rgba[i][BCOMP] << 16;
+ pixel |= rgba[i][GCOMP] << 24;
+ *ptr4++ = pixel;
+ pixel = *ptr4 && 0xffffff00;
+ pixel |= rgba[i++][RCOMP];
+ *ptr4 = pixel;
+ if (0 == --w)
+ break;
+ case 3:
+ pixel &= 0x000000ff;
+ pixel |= rgba[i][BCOMP] << 8;
+ pixel |= rgba[i][GCOMP] << 16;
+ pixel |= rgba[i++][RCOMP] << 24;
+ *ptr4++ = pixel;
+ if (0 == --w)
+ break;
+ break;
+ }
+ while (w > 3) {
+ pixel = rgba[i][BCOMP];
+ pixel |= rgba[i][GCOMP] << 8;
+ pixel |= rgba[i++][RCOMP] << 16;
+ pixel |= rgba[i][BCOMP] << 24;
+ *ptr4++ = pixel;
+ pixel = rgba[i][GCOMP];
+ pixel |= rgba[i++][RCOMP] << 8;
+ pixel |= rgba[i][BCOMP] << 16;
+ pixel |= rgba[i][GCOMP] << 24;
+ *ptr4++ = pixel;
+ pixel = rgba[i++][RCOMP];
+ pixel |= rgba[i][BCOMP] << 8;
+ pixel |= rgba[i][GCOMP] << 16;
+ pixel |= rgba[i++][RCOMP] << 24;
+ *ptr4++ = pixel;
+ w -= 4;
+ }
+ switch (w) {
+ case 0:
+ break;
+ case 1:
+ pixel = *ptr4 & 0xff000000;
+ pixel |= rgba[i][BCOMP];
+ pixel |= rgba[i][GCOMP] << 8;
+ pixel |= rgba[i][RCOMP] << 16;
+ *ptr4 = pixel;
+ break;
+ case 2:
+ pixel = rgba[i][BCOMP];
+ pixel |= rgba[i][GCOMP] << 8;
+ pixel |= rgba[i++][RCOMP] << 16;
+ pixel |= rgba[i][BCOMP] << 24;
+ *ptr4++ = pixel;
+ pixel = *ptr4 & 0xffff0000;
+ pixel |= rgba[i][GCOMP];
+ pixel |= rgba[i][RCOMP] << 8;
+ *ptr4 = pixel;
+ break;
+ case 3:
+ pixel = rgba[i][BCOMP];
+ pixel |= rgba[i][GCOMP] << 8;
+ pixel |= rgba[i++][RCOMP] << 16;
+ pixel |= rgba[i][BCOMP] << 24;
+ *ptr4++ = pixel;
+ pixel = rgba[i][GCOMP];
+ pixel |= rgba[i++][RCOMP] << 8;
+ pixel |= rgba[i][BCOMP] << 16;
+ pixel |= rgba[i][GCOMP] << 24;
+ *ptr4++ = pixel;
+ pixel = *ptr4 & 0xffffff00;
+ pixel |= rgba[i][RCOMP];
+ *ptr4 = pixel;
+ break;
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_8R8G8B-format pixels to an ximage (no alpha).
+ */
+static void put_row_rgb_8R8G8B_ximage( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLuint *ptr = PIXEL_ADDR4(xrb, x, y);
+ if (mask) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ ptr[i] = PACK_8R8G8B(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++) {
+ ptr[i] = PACK_8R8G8B(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]);
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_8R8G8B24-format pixels to an ximage (no alpha).
+ */
+static void put_row_rgb_8R8G8B24_ximage( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLubyte *ptr = (GLubyte *) PIXEL_ADDR3(xrb, x, y);
+ if (mask) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ *ptr++ = rgb[i][BCOMP];
+ *ptr++ = rgb[i][GCOMP];
+ *ptr++ = rgb[i][RCOMP];
+ }
+ else {
+ ptr += 3;
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++) {
+ *ptr++ = rgb[i][BCOMP];
+ *ptr++ = rgb[i][GCOMP];
+ *ptr++ = rgb[i][RCOMP];
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_5R6G5B-format pixels to an ximage.
+ */
+static void put_row_5R6G5B_ximage( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLushort *ptr = PIXEL_ADDR2(xrb, x, y);
+ if (mask) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ ptr[i] = PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ }
+ }
+ 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(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
+ }
+}
+
+
+/*
+ * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage.
+ */
+static void put_row_DITHER_5R6G5B_ximage( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ register GLuint i;
+ register GLushort *ptr = PIXEL_ADDR2(xrb, x, y);
+ const GLint y2 = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ PACK_TRUEDITHER( ptr[i], x, y2, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ }
+ }
+ 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, y2, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ PACK_TRUEDITHER( p1, x+1, y2, rgba[i+1][RCOMP], rgba[i+1][GCOMP], rgba[i+1][BCOMP] );
+ *ptr32++ = (p1 << 16) | p0;
+ }
+ if (extraPixel) {
+ PACK_TRUEDITHER( ptr[n], x+n, y2, rgba[n][RCOMP], rgba[n][GCOMP], rgba[n][BCOMP]);
+ }
+#else
+ for (i = 0; i < n; i++, x++) {
+ PACK_TRUEDITHER( ptr[i], x, y2, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
+ }
+#endif
+ }
+}
+
+
+/*
+ * Write a span of PF_5R6G5B-format pixels to an ximage (no alpha).
+ */
+static void put_row_rgb_5R6G5B_ximage( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLushort *ptr = PIXEL_ADDR2(xrb, x, y);
+ if (mask) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ ptr[i] = PACK_5R6G5B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
+ }
+ }
+ }
+ 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
+ }
+}
+
+
+/*
+ * Write a span of PF_DITHER_5R6G5B-format pixels to an ximage (no alpha).
+ */
+static void put_row_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ register GLuint i;
+ register GLushort *ptr = PIXEL_ADDR2(xrb, x, y );
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ PACK_TRUEDITHER( ptr[i], x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
+ }
+ }
+ }
+ 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
+ }
+}
+
+
+/*
+ * Write a span of PF_DITHER pixels to an XImage.
+ */
+static void put_row_DITHER_ximage( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ int yy = YFLIP(xrb, y);
+ XDITHER_SETUP(yy);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x, yy, XDITHER( x, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++,x++) {
+ XMesaPutPixel( img, x, yy, XDITHER( x, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_DITHER pixels to an XImage (no alpha).
+ */
+static void put_row_rgb_DITHER_ximage( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ int yy = YFLIP(xrb, y);
+ XDITHER_SETUP(yy);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x, yy, XDITHER( x, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ) );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++,x++) {
+ XMesaPutPixel( img, x, yy, XDITHER( x, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ) );
+ }
+ }
+}
+
+
+
+/*
+ * Write a span of 8-bit PF_DITHER pixels to an XImage.
+ */
+static void put_row_DITHER8_ximage( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
+ XDITHER_SETUP(y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ ptr[i] = (GLubyte) XDITHER( x, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++,x++) {
+ ptr[i] = (GLubyte) XDITHER( x, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ }
+}
+
+
+static void put_row_rgb_DITHER8_ximage( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
+ XDITHER_SETUP(y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ ptr[i] = (GLubyte) XDITHER( x, rgb[i][0], rgb[i][1], rgb[i][2] );
+ }
+ }
+ }
+ else {
+ const GLubyte *data = (GLubyte *) rgb;
+ for (i=0;i<n;i++,x++) {
+ /*ptr[i] = XDITHER( x, rgb[i][0], rgb[i][1], rgb[i][2] );*/
+ ptr[i] = (GLubyte) XDITHER( x, data[i+i+i], data[i+i+i+1], data[i+i+i+2] );
+ }
+ }
+}
+
+
+
+/*
+ * Write a span of PF_1BIT pixels to an XImage.
+ */
+static void put_row_1BIT_ximage( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ SETUP_1BIT;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaPutPixel(img, x, y, DITHER_1BIT(x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]));
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++,x++) {
+ XMesaPutPixel( img, x, y, DITHER_1BIT(x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_1BIT pixels to an XImage (no alpha).
+ */
+static void put_row_rgb_1BIT_ximage( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ SETUP_1BIT;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaPutPixel(img, x, y, DITHER_1BIT(x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]));
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++,x++) {
+ XMesaPutPixel( img, x, y, DITHER_1BIT(x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]) );
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_HPCR pixels to an XImage.
+ */
+static void put_row_HPCR_ximage( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ register GLuint i;
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ ptr[i] = DITHER_HPCR( x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++,x++) {
+ ptr[i] = DITHER_HPCR( x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_HPCR pixels to an XImage (no alpha).
+ */
+static void put_row_rgb_HPCR_ximage( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ register GLuint i;
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ ptr[i] = DITHER_HPCR( x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++,x++) {
+ ptr[i] = DITHER_HPCR( x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_LOOKUP pixels to an XImage.
+ */
+static void put_row_LOOKUP_ximage( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ LOOKUP_SETUP;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x, y, LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++,x++) {
+ XMesaPutPixel( img, x, y, LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_LOOKUP pixels to an XImage (no alpha).
+ */
+static void put_row_rgb_LOOKUP_ximage( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ LOOKUP_SETUP;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x, y, LOOKUP( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ) );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++,x++) {
+ XMesaPutPixel( img, x, y, LOOKUP( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ) );
+ }
+ }
+}
+
+
+/*
+ * Write a span of 8-bit PF_LOOKUP pixels to an XImage.
+ */
+static void put_row_LOOKUP8_ximage( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
+ LOOKUP_SETUP;
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ ptr[i] = (GLubyte) LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++,x++) {
+ ptr[i] = (GLubyte) LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ }
+}
+
+
+static void put_row_rgb_LOOKUP8_ximage( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
+ LOOKUP_SETUP;
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ ptr[i] = (GLubyte) LOOKUP( rgb[i][0], rgb[i][1], rgb[i][2] );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ const GLubyte *data = (GLubyte *) rgb;
+ for (i=0;i<n;i++,x++) {
+ /*ptr[i] = LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );*/
+ ptr[i] = (GLubyte) LOOKUP( data[i+i+i], data[i+i+i+1], data[i+i+i+2] );
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_GRAYSCALE pixels to an XImage.
+ */
+static void put_row_GRAYSCALE_ximage( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x, y, GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++,x++) {
+ XMesaPutPixel( img, x, y, GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_GRAYSCALE pixels to an XImage (no alpha).
+ */
+static void put_row_rgb_GRAYSCALE_ximage( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x, y, GRAY_RGB( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ) );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++,x++) {
+ XMesaPutPixel( img, x, y, GRAY_RGB( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ) );
+ }
+ }
+}
+
+
+/*
+ * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage.
+ */
+static void put_row_GRAYSCALE8_ximage( PUT_ROW_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
+ if (mask) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ ptr[i] = (GLubyte) GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++) {
+ ptr[i] = (GLubyte) GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ }
+}
+
+
+/*
+ * Write a span of 8-bit PF_GRAYSCALE pixels to an XImage (no alpha).
+ */
+static void put_row_rgb_GRAYSCALE8_ximage( RGB_SPAN_ARGS )
+{
+ const GLubyte (*rgb)[3] = (const GLubyte (*)[3]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
+ if (mask) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ ptr[i] = (GLubyte) GRAY_RGB( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
+ }
+ }
+ }
+ else {
+ /* draw all pixels */
+ for (i=0;i<n;i++) {
+ ptr[i] = (GLubyte) GRAY_RGB( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] );
+ }
+ }
+}
+
+
+
+
+/**********************************************************************/
+/*** Write COLOR PIXEL functions ***/
+/**********************************************************************/
+
+
+#define PUT_VALUES_ARGS \
+ GLcontext *ctx, struct gl_renderbuffer *rb, \
+ GLuint n, const GLint x[], const GLint y[], \
+ const void *values, const GLubyte mask[]
+
+
+/*
+ * Write an array of PF_TRUECOLOR pixels to a pixmap.
+ */
+static void put_values_TRUECOLOR_pixmap( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ unsigned long p;
+ PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ XMesaSetForeground( dpy, gc, p );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_TRUEDITHER pixels to a pixmap.
+ */
+static void put_values_TRUEDITHER_pixmap( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ unsigned long p;
+ PACK_TRUEDITHER(p, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
+ XMesaSetForeground( dpy, gc, p );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_8A8B8G8R pixels to a pixmap.
+ */
+static void put_values_8A8B8G8R_pixmap( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc,
+ PACK_8A8B8G8R( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] ));
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+/*
+ * Write an array of PF_8A8R8G8B pixels to a pixmap.
+ */
+static void put_values_8A8R8G8B_pixmap( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc,
+ PACK_8A8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] ));
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+/*
+ * Write an array of PF_8R8G8B pixels to a pixmap.
+ */
+static void put_values_8R8G8B_pixmap( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_8R8G8B24 pixels to a pixmap.
+ */
+static void put_values_8R8G8B24_pixmap( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_5R6G5B pixels to a pixmap.
+ */
+static void put_values_5R6G5B_pixmap( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_DITHER_5R6G5B pixels to a pixmap.
+ */
+static void put_values_DITHER_5R6G5B_pixmap( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ unsigned long p;
+ PACK_TRUEDITHER(p, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ XMesaSetForeground( dpy, gc, p );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_DITHER pixels to a pixmap.
+ */
+static void put_values_DITHER_pixmap( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ DITHER_SETUP;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc,
+ DITHER(x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_1BIT pixels to a pixmap.
+ */
+static void put_values_1BIT_pixmap( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ SETUP_1BIT;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc,
+ DITHER_1BIT( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_HPCR pixels to a pixmap.
+ */
+static void put_values_HPCR_pixmap( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc,
+ DITHER_HPCR( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_LOOKUP pixels to a pixmap.
+ */
+static void put_values_LOOKUP_pixmap( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ LOOKUP_SETUP;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_GRAYSCALE pixels to a pixmap.
+ */
+static void put_values_GRAYSCALE_pixmap( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_TRUECOLOR pixels to an ximage.
+ */
+static void put_values_TRUECOLOR_ximage( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ unsigned long p;
+ PACK_TRUECOLOR( p, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), p );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_TRUEDITHER pixels to an XImage.
+ */
+static void put_values_TRUEDITHER_ximage( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ unsigned long p;
+ PACK_TRUEDITHER(p, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]);
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), p );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_8A8B8G8R pixels to an ximage.
+ */
+static void put_values_8A8B8G8R_ximage( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i] );
+ *ptr = PACK_8A8B8G8R( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
+ }
+ }
+}
+
+/*
+ * Write an array of PF_8A8R8G8B pixels to an ximage.
+ */
+static void put_values_8A8R8G8B_ximage( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i]);
+ *ptr = PACK_8A8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_8R8G8B pixels to an ximage.
+ */
+static void put_values_8R8G8B_ximage( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i]);
+ *ptr = PACK_8R8G8B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_8R8G8B24 pixels to an ximage.
+ */
+static void put_values_8R8G8B24_ximage( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ bgr_t *ptr = PIXEL_ADDR3(xrb, x[i], y[i] );
+ ptr->r = rgba[i][RCOMP];
+ ptr->g = rgba[i][GCOMP];
+ ptr->b = rgba[i][BCOMP];
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_5R6G5B pixels to an ximage.
+ */
+static void put_values_5R6G5B_ximage( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLushort *ptr = PIXEL_ADDR2(xrb, x[i], y[i] );
+ *ptr = PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_DITHER_5R6G5B pixels to an ximage.
+ */
+static void put_values_DITHER_5R6G5B_ximage( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLushort *ptr = PIXEL_ADDR2(xrb, x[i], y[i] );
+ PACK_TRUEDITHER( *ptr, x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_DITHER pixels to an XImage.
+ */
+static void put_values_DITHER_ximage( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ DITHER_SETUP;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]),
+ DITHER( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of 8-bit PF_DITHER pixels to an XImage.
+ */
+static void put_values_DITHER8_ximage( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ DITHER_SETUP;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
+ *ptr = (GLubyte) DITHER( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_1BIT pixels to an XImage.
+ */
+static void put_values_1BIT_ximage( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ SETUP_1BIT;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]),
+ DITHER_1BIT( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ));
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_HPCR pixels to an XImage.
+ */
+static void put_values_HPCR_ximage( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
+ *ptr = (GLubyte) DITHER_HPCR( x[i], y[i], rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_LOOKUP pixels to an XImage.
+ */
+static void put_values_LOOKUP_ximage( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ LOOKUP_SETUP;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), LOOKUP(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of 8-bit PF_LOOKUP pixels to an XImage.
+ */
+static void put_values_LOOKUP8_ximage( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ LOOKUP_SETUP;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
+ *ptr = (GLubyte) LOOKUP( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_GRAYSCALE pixels to an XImage.
+ */
+static void put_values_GRAYSCALE_ximage( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]),
+ GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of 8-bit PF_GRAYSCALE pixels to an XImage.
+ */
+static void put_values_GRAYSCALE8_ximage( PUT_VALUES_ARGS )
+{
+ const GLubyte (*rgba)[4] = (const GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i] );
+ *ptr = (GLubyte) GRAY_RGB( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] );
+ }
+ }
+}
+
+
+
+
+/**********************************************************************/
+/*** Write MONO COLOR SPAN functions ***/
+/**********************************************************************/
+
+#define PUT_MONO_ROW_ARGS \
+ GLcontext *ctx, struct gl_renderbuffer *rb, \
+ GLuint n, GLint x, GLint y, const void *value, \
+ const GLubyte mask[]
+
+
+
+/*
+ * Write a span of identical pixels to a pixmap.
+ */
+static void put_mono_row_pixmap( PUT_MONO_ROW_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ const unsigned long pixel = xmesa_color_to_pixel(ctx, color[RCOMP],
+ color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
+ register GLuint i;
+ XMesaSetForeground( xmesa->display, gc, pixel );
+ y = YFLIP(xrb, y);
+
+ /* New code contributed by Jeff Epler and cleaned up by Keith
+ * Whitwell.
+ */
+ for (i = 0; i < n; ) {
+ GLuint start = i;
+
+ /* Identify and emit contiguous rendered pixels
+ */
+ while (i < n && (!mask || mask[i]))
+ i++;
+
+ if (start < i)
+ XMesaFillRectangle( dpy, buffer, gc,
+ (int)(x+start), (int) y,
+ (int)(i-start), 1);
+
+ /* Eat up non-rendered pixels
+ */
+ while (i < n && !mask[i])
+ i++;
+ }
+}
+
+
+
+static void
+put_mono_row_ci_pixmap( PUT_MONO_ROW_ARGS )
+{
+ GLuint colorIndex = *((GLuint *) value);
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ XMesaSetForeground( xmesa->display, gc, colorIndex );
+ y = YFLIP(xrb, y);
+
+ for (i = 0 ; i < n ;) {
+ GLuint start = i;
+
+ /* Identify and emit contiguous rendered pixels
+ */
+ while (i < n && (!mask || mask[i]))
+ i++;
+
+ if (start < i)
+ XMesaFillRectangle( dpy, buffer, gc,
+ (int)(x+start), (int) y,
+ (int)(i-start), 1);
+
+ /* Eat up non-rendered pixels
+ */
+ while (i < n && !mask[i])
+ i++;
+ }
+}
+
+
+
+/*
+ * Write a span of PF_TRUEDITHER pixels to a pixmap.
+ */
+static void put_mono_row_TRUEDITHER_pixmap( PUT_MONO_ROW_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ register GLuint i;
+ int yy = YFLIP(xrb, y);
+ for (i=0;i<n;i++,x++) {
+ if (!mask || mask[i]) {
+ unsigned long p;
+ PACK_TRUEDITHER(p, x, yy, r, g, b);
+ XMesaSetForeground( dpy, gc, p );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) yy );
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_DITHER pixels to a pixmap.
+ */
+static void put_mono_row_DITHER_pixmap( PUT_MONO_ROW_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ register GLuint i;
+ int yy = YFLIP(xrb, y);
+ XDITHER_SETUP(yy);
+ for (i=0;i<n;i++,x++) {
+ if (!mask || mask[i]) {
+ XMesaSetForeground( dpy, gc, XDITHER( x, r, g, b ) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) yy );
+ }
+ }
+}
+
+
+/*
+ * Write a span of PF_1BIT pixels to a pixmap.
+ */
+static void put_mono_row_1BIT_pixmap( PUT_MONO_ROW_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ register GLuint i;
+ SETUP_1BIT;
+ y = YFLIP(xrb, y);
+ for (i=0;i<n;i++,x++) {
+ if (!mask || mask[i]) {
+ XMesaSetForeground( dpy, gc, DITHER_1BIT( x, y, r, g, b ) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+}
+
+
+/*
+ * Write a span of identical pixels to an XImage.
+ */
+static void put_mono_row_ximage( PUT_MONO_ROW_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ const unsigned long pixel = xmesa_color_to_pixel(ctx, color[RCOMP],
+ color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
+ y = YFLIP(xrb, y);
+ for (i=0;i<n;i++,x++) {
+ if (!mask || mask[i]) {
+ XMesaPutPixel( img, x, y, pixel );
+ }
+ }
+}
+
+
+static void
+put_mono_row_ci_ximage( PUT_MONO_ROW_ARGS )
+{
+ const GLuint colorIndex = *((GLuint *) value);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ for (i=0;i<n;i++,x++) {
+ if (!mask || mask[i]) {
+ XMesaPutPixel( img, x, y, colorIndex );
+ }
+ }
+}
+
+
+/*
+ * Write a span of identical PF_TRUEDITHER pixels to an XImage.
+ */
+static void put_mono_row_TRUEDITHER_ximage( PUT_MONO_ROW_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaImage *img = xrb->ximage;
+ const GLint r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ GLuint i;
+ y = YFLIP(xrb, y);
+ for (i=0;i<n;i++) {
+ if (!mask || mask[i]) {
+ unsigned long p;
+ PACK_TRUEDITHER( p, x+i, y, r, g, b);
+ XMesaPutPixel( img, x+i, y, p );
+ }
+ }
+}
+
+
+/*
+ * Write a span of identical 8A8B8G8R pixels to an XImage.
+ */
+static void put_mono_row_8A8B8G8R_ximage( PUT_MONO_ROW_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ GLuint i, *ptr;
+ const unsigned long pixel = xmesa_color_to_pixel(ctx, color[RCOMP],
+ color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
+ ptr = PIXEL_ADDR4(xrb, x, y );
+ for (i=0;i<n;i++) {
+ if (!mask || mask[i]) {
+ ptr[i] = pixel;
+ }
+ }
+}
+
+/*
+ * Write a span of identical 8A8R8G8B pixels to an XImage.
+ */
+static void put_mono_row_8A8R8G8B_ximage( PUT_MONO_ROW_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ GLuint i, *ptr;
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ const unsigned long pixel = xmesa_color_to_pixel(ctx, color[RCOMP],
+ color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
+ ptr = PIXEL_ADDR4(xrb, x, y );
+ for (i=0;i<n;i++) {
+ if (!mask || mask[i]) {
+ ptr[i] = pixel;
+ }
+ }
+}
+
+
+/*
+ * Write a span of identical 8R8G8B pixels to an XImage.
+ */
+static void put_mono_row_8R8G8B_ximage( PUT_MONO_ROW_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const GLuint pixel = PACK_8R8G8B(color[RCOMP], color[GCOMP], color[BCOMP]);
+ GLuint *ptr = PIXEL_ADDR4(xrb, x, y );
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (!mask || mask[i]) {
+ ptr[i] = pixel;
+ }
+ }
+}
+
+
+/*
+ * Write a span of identical 8R8G8B pixels to an XImage.
+ */
+static void put_mono_row_8R8G8B24_ximage( PUT_MONO_ROW_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const GLubyte r = color[RCOMP];
+ const GLubyte g = color[GCOMP];
+ const GLubyte b = color[BCOMP];
+ GLuint i;
+ bgr_t *ptr = PIXEL_ADDR3(xrb, x, y );
+ for (i=0;i<n;i++) {
+ if (!mask || mask[i]) {
+ ptr[i].r = r;
+ ptr[i].g = g;
+ ptr[i].b = b;
+ }
+ }
+}
+
+
+/*
+ * Write a span of identical DITHER pixels to an XImage.
+ */
+static void put_mono_row_DITHER_ximage( PUT_MONO_ROW_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ XMesaImage *img = xrb->ximage;
+ int yy = YFLIP(xrb, y);
+ register GLuint i;
+ XDITHER_SETUP(yy);
+ for (i=0;i<n;i++,x++) {
+ if (!mask || mask[i]) {
+ XMesaPutPixel( img, x, yy, XDITHER( x, r, g, b ) );
+ }
+ }
+}
+
+
+/*
+ * Write a span of identical 8-bit DITHER pixels to an XImage.
+ */
+static void put_mono_row_DITHER8_ximage( PUT_MONO_ROW_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
+ register GLuint i;
+ XDITHER_SETUP(y);
+ for (i=0;i<n;i++,x++) {
+ if (!mask || mask[i]) {
+ ptr[i] = (GLubyte) XDITHER( x, r, g, b );
+ }
+ }
+}
+
+
+/*
+ * Write a span of identical 8-bit LOOKUP pixels to an XImage.
+ */
+static void put_mono_row_LOOKUP8_ximage( PUT_MONO_ROW_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
+ GLubyte pixel;
+ LOOKUP_SETUP;
+ pixel = LOOKUP(color[RCOMP], color[GCOMP], color[BCOMP]);
+ for (i=0;i<n;i++) {
+ if (!mask || mask[i]) {
+ ptr[i] = pixel;
+ }
+ }
+}
+
+
+/*
+ * Write a span of identical PF_1BIT pixels to an XImage.
+ */
+static void put_mono_row_1BIT_ximage( PUT_MONO_ROW_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ SETUP_1BIT;
+ y = YFLIP(xrb, y);
+ for (i=0;i<n;i++,x++) {
+ if (!mask || mask[i]) {
+ XMesaPutPixel( img, x, y, DITHER_1BIT( x, y, r, g, b ) );
+ }
+ }
+}
+
+
+/*
+ * Write a span of identical HPCR pixels to an XImage.
+ */
+static void put_mono_row_HPCR_ximage( PUT_MONO_ROW_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ register GLubyte *ptr = PIXEL_ADDR1(xrb, x, y);
+ register GLuint i;
+ for (i=0;i<n;i++,x++) {
+ if (!mask || mask[i]) {
+ ptr[i] = DITHER_HPCR( x, y, r, g, b );
+ }
+ }
+}
+
+
+/*
+ * Write a span of identical 8-bit GRAYSCALE pixels to an XImage.
+ */
+static void put_mono_row_GRAYSCALE8_ximage( PUT_MONO_ROW_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const GLubyte p = GRAY_RGB(color[RCOMP], color[GCOMP], color[BCOMP]);
+ GLubyte *ptr = (GLubyte *) PIXEL_ADDR1(xrb, x, y);
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (!mask || mask[i]) {
+ ptr[i] = p;
+ }
+ }
+}
+
+
+
+/*
+ * Write a span of identical PF_DITHER_5R6G5B pixels to an XImage.
+ */
+static void put_mono_row_DITHER_5R6G5B_ximage( PUT_MONO_ROW_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ register GLushort *ptr = PIXEL_ADDR2(xrb, x, y );
+ const GLint r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ GLuint i;
+ y = YFLIP(xrb, y);
+ for (i=0;i<n;i++) {
+ if (!mask || mask[i]) {
+ PACK_TRUEDITHER(ptr[i], x+i, y, r, g, b);
+ }
+ }
+}
+
+
+
+/**********************************************************************/
+/*** Write MONO COLOR PIXELS functions ***/
+/**********************************************************************/
+
+#define PUT_MONO_VALUES_ARGS \
+ GLcontext *ctx, struct gl_renderbuffer *rb, \
+ GLuint n, const GLint x[], const GLint y[], \
+ const void *value, const GLubyte mask[]
+
+
+
+/*
+ * Write an array of identical pixels to a pixmap.
+ */
+static void put_mono_values_pixmap( PUT_MONO_VALUES_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ const unsigned long pixel = xmesa_color_to_pixel(ctx, color[RCOMP],
+ color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
+ XMesaSetForeground( xmesa->display, gc, pixel );
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaDrawPoint( dpy, buffer, gc,
+ (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+static void
+put_mono_values_ci_pixmap( PUT_MONO_VALUES_ARGS )
+{
+ const GLuint colorIndex = *((GLuint *) value);
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ XMesaSetForeground( xmesa->display, gc, colorIndex );
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaDrawPoint( dpy, buffer, gc,
+ (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_TRUEDITHER pixels to a pixmap.
+ */
+static void put_mono_values_TRUEDITHER_pixmap( PUT_MONO_VALUES_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ unsigned long p;
+ PACK_TRUEDITHER(p, x[i], y[i], r, g, b);
+ XMesaSetForeground( dpy, gc, p );
+ XMesaDrawPoint( dpy, buffer, gc,
+ (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_DITHER pixels to a pixmap.
+ */
+static void put_mono_values_DITHER_pixmap( PUT_MONO_VALUES_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ DITHER_SETUP;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, DITHER( x[i], y[i], r, g, b ) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of PF_1BIT pixels to a pixmap.
+ */
+static void put_mono_values_1BIT_pixmap( PUT_MONO_VALUES_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ SETUP_1BIT;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, DITHER_1BIT( x[i], y[i], r, g, b ) );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of identical pixels to an XImage.
+ */
+static void put_mono_values_ximage( PUT_MONO_VALUES_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ const unsigned long pixel = xmesa_color_to_pixel(ctx, color[RCOMP],
+ color[GCOMP], color[BCOMP], color[ACOMP], xmesa->pixelformat);
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), pixel );
+ }
+ }
+}
+
+
+static void
+put_mono_values_ci_ximage( PUT_MONO_VALUES_ARGS )
+{
+ const GLuint colorIndex = *((GLuint *) value);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), colorIndex );
+ }
+ }
+}
+
+
+/*
+ * Write an array of identical TRUEDITHER pixels to an XImage.
+ */
+static void put_mono_values_TRUEDITHER_ximage( PUT_MONO_VALUES_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ const int r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ unsigned long p;
+ PACK_TRUEDITHER(p, x[i], YFLIP(xrb, y[i]), r, g, b);
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), p );
+ }
+ }
+}
+
+
+
+/*
+ * Write an array of identical 8A8B8G8R pixels to an XImage
+ */
+static void put_mono_values_8A8B8G8R_ximage( PUT_MONO_VALUES_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const GLuint p = PACK_8A8B8G8R(color[RCOMP], color[GCOMP],
+ color[BCOMP], color[ACOMP]);
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i] );
+ *ptr = p;
+ }
+ }
+}
+
+/*
+ * Write an array of identical 8A8R8G8B pixels to an XImage
+ */
+static void put_mono_values_8A8R8G8B_ximage( PUT_MONO_VALUES_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const GLuint p = PACK_8A8R8G8B(color[RCOMP], color[GCOMP],
+ color[BCOMP], color[ACOMP]);
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i] );
+ *ptr = p;
+ }
+ }
+}
+
+/*
+ * Write an array of identical 8R8G8B pixels to an XImage.
+ */
+static void put_mono_values_8R8G8B_ximage( PUT_MONO_VALUES_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ const GLuint p = PACK_8R8G8B(color[RCOMP], color[GCOMP], color[BCOMP]);
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLuint *ptr = PIXEL_ADDR4(xrb, x[i], y[i] );
+ *ptr = p;
+ }
+ }
+}
+
+
+/*
+ * Write an array of identical 8R8G8B pixels to an XImage.
+ */
+static void put_mono_values_8R8G8B24_ximage( PUT_MONO_VALUES_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ bgr_t *ptr = PIXEL_ADDR3(xrb, x[i], y[i] );
+ ptr->r = r;
+ ptr->g = g;
+ ptr->b = b;
+ }
+ }
+}
+
+
+/*
+ * Write an array of identical PF_DITHER pixels to an XImage.
+ */
+static void put_mono_values_DITHER_ximage( PUT_MONO_VALUES_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ DITHER_SETUP;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]), DITHER( x[i], y[i], r, g, b ) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of identical 8-bit PF_DITHER pixels to an XImage.
+ */
+static void put_mono_values_DITHER8_ximage( PUT_MONO_VALUES_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ register GLuint i;
+ DITHER_SETUP;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
+ *ptr = (GLubyte) DITHER( x[i], y[i], r, g, b );
+ }
+ }
+}
+
+
+/*
+ * Write an array of identical 8-bit PF_LOOKUP pixels to an XImage.
+ */
+static void put_mono_values_LOOKUP8_ximage( PUT_MONO_VALUES_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ GLubyte pixel;
+ LOOKUP_SETUP;
+ pixel = LOOKUP(color[RCOMP], color[GCOMP], color[BCOMP]);
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
+ *ptr = pixel;
+ }
+ }
+}
+
+
+
+/*
+ * Write an array of identical PF_1BIT pixels to an XImage.
+ */
+static void put_mono_values_1BIT_ximage( PUT_MONO_VALUES_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ SETUP_1BIT;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x[i], YFLIP(xrb, y[i]),
+ DITHER_1BIT( x[i], y[i], r, g, b ));
+ }
+ }
+}
+
+
+/*
+ * Write an array of identical PF_HPCR pixels to an XImage.
+ */
+static void put_mono_values_HPCR_ximage( PUT_MONO_VALUES_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ const GLubyte r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
+ *ptr = DITHER_HPCR( x[i], y[i], r, g, b );
+ }
+ }
+}
+
+
+/*
+ * Write an array of identical 8-bit PF_GRAYSCALE pixels to an XImage.
+ */
+static void put_mono_values_GRAYSCALE8_ximage( PUT_MONO_VALUES_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ register GLuint i;
+ register GLubyte p = GRAY_RGB(color[RCOMP], color[GCOMP], color[BCOMP]);
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLubyte *ptr = PIXEL_ADDR1(xrb, x[i], y[i]);
+ *ptr = p;
+ }
+ }
+}
+
+
+/*
+ * Write an array of identical PF_DITHER_5R6G5B pixels to an XImage.
+ */
+static void put_mono_values_DITHER_5R6G5B_ximage( PUT_MONO_VALUES_ARGS )
+{
+ const GLubyte *color = (const GLubyte *) value;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ const int r = color[RCOMP], g = color[GCOMP], b = color[BCOMP];
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLushort *ptr = PIXEL_ADDR2(xrb, x[i], y[i] );
+ PACK_TRUEDITHER(*ptr, x[i], y[i], r, g, b);
+ }
+ }
+}
+
+
+
+/**********************************************************************/
+/*** Write INDEX SPAN functions ***/
+/**********************************************************************/
+
+/*
+ * Write a span of CI pixels to a Pixmap.
+ */
+static void put_row_ci_pixmap( PUT_ROW_ARGS )
+{
+ const GLuint *index = (GLuint *) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, (unsigned long) index[i] );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++,x++) {
+ XMesaSetForeground( dpy, gc, (unsigned long) index[i] );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x, (int) y );
+ }
+ }
+}
+
+
+/*
+ * Write a span of CI pixels to an XImage.
+ */
+static void put_row_ci_ximage( PUT_ROW_ARGS )
+{
+ const GLuint *index = (const GLuint *) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ y = YFLIP(xrb, y);
+ if (mask) {
+ for (i=0;i<n;i++,x++) {
+ if (mask[i]) {
+ XMesaPutPixel( img, x, y, (unsigned long) index[i] );
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++,x++) {
+ XMesaPutPixel( img, x, y, (unsigned long) index[i] );
+ }
+ }
+}
+
+
+/**********************************************************************/
+/*** Write INDEX PIXELS functions ***/
+/**********************************************************************/
+
+/*
+ * Write an array of CI pixels to a Pixmap.
+ */
+static void put_values_ci_pixmap( PUT_VALUES_ARGS )
+{
+ const GLuint *index = (const GLuint *) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaDrawable buffer = xrb->drawable;
+ XMesaGC gc = XMESA_BUFFER(ctx->DrawBuffer)->gc;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaSetForeground( dpy, gc, (unsigned long) index[i] );
+ XMesaDrawPoint( dpy, buffer, gc, (int) x[i], (int) YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+/*
+ * Write an array of CI pixels to an XImage.
+ */
+static void put_values_ci_ximage( PUT_VALUES_ARGS )
+{
+ const GLuint *index = (const GLuint *) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaImage *img = xrb->ximage;
+ register GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ XMesaPutPixel(img, x[i], YFLIP(xrb, y[i]), (unsigned long) index[i]);
+ }
+ }
+}
+
+
+
+
+/**********************************************************************/
+/***** Pixel reading *****/
+/**********************************************************************/
+
+#ifndef XFree86Server
+/**
+ * Do clip testing prior to calling XGetImage. If any of the region lies
+ * outside the screen's bounds, XGetImage will return NULL.
+ * We use XTranslateCoordinates() to check if that's the case and
+ * adjust the x, y and length parameters accordingly.
+ * \return -1 if span is totally clipped away,
+ * else return number of pixels to skip in the destination array.
+ */
+static int
+clip_for_xgetimage(GLcontext *ctx, GLuint *n, GLint *x, GLint *y)
+{
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaBuffer source = XMESA_BUFFER(ctx->DrawBuffer);
+ Window rootWin = RootWindow(xmesa->display, 0);
+ Window child;
+ GLint screenWidth = WidthOfScreen(DefaultScreenOfDisplay(xmesa->display));
+ GLint dx, dy;
+ if (source->type == PBUFFER || source->type == PIXMAP)
+ return 0;
+ XTranslateCoordinates(xmesa->display, source->frontxrb->pixmap, rootWin,
+ *x, *y, &dx, &dy, &child);
+ if (dx >= screenWidth) {
+ /* totally clipped on right */
+ return -1;
+ }
+ if (dx < 0) {
+ /* clipped on left */
+ GLint clip = -dx;
+ if (clip >= (GLint) *n)
+ return -1; /* totally clipped on left */
+ *x += clip;
+ *n -= clip;
+ dx = 0;
+ return clip;
+ }
+ if ((GLint) (dx + *n) > screenWidth) {
+ /* clipped on right */
+ GLint clip = dx + *n - screenWidth;
+ *n -= clip;
+ }
+ return 0;
+}
+#endif
+
+
+/*
+ * Read a horizontal span of color-index pixels.
+ */
+static void
+get_row_ci(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, void *values)
+{
+ GLuint *index = (GLuint *) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ GLuint i;
+
+ y = YFLIP(xrb, y);
+
+ if (xrb->pixmap) {
+#ifndef XFree86Server
+ XMesaImage *span = NULL;
+ int error;
+ int k = clip_for_xgetimage(ctx, &n, &x, &y);
+ if (k < 0)
+ return;
+ index += k;
+
+ catch_xgetimage_errors( xmesa->display );
+ span = XGetImage( xmesa->display, xrb->pixmap,
+ x, y, n, 1, AllPlanes, ZPixmap );
+ error = check_xgetimage_errors();
+ if (span && !error) {
+ for (i=0;i<n;i++) {
+ index[i] = (GLuint) XMesaGetPixel( span, i, 0 );
+ }
+ }
+ else {
+ /* return 0 pixels */
+ for (i=0;i<n;i++) {
+ index[i] = 0;
+ }
+ }
+ if (span) {
+ XMesaDestroyImage( span );
+ }
+#else
+ (*xmesa->display->GetImage)(xrb->drawable,
+ x, y, n, 1, ZPixmap,
+ ~0L, (pointer)index);
+#endif
+ }
+ else if (xrb->ximage) {
+ XMesaImage *img = xrb->ximage;
+ for (i=0;i<n;i++,x++) {
+ index[i] = (GLuint) XMesaGetPixel( img, x, y );
+ }
+ }
+}
+
+
+
+/*
+ * Read a horizontal span of color pixels.
+ */
+static void
+get_row_rgba(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, void *values)
+{
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ XMesaBuffer source = XMESA_BUFFER(ctx->DrawBuffer);
+
+ if (xrb->pixmap) {
+ /* Read from Pixmap or Window */
+ XMesaImage *span = NULL;
+ int error;
+#ifdef XFree86Server
+ 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)(xrb->drawable,
+ x, YFLIP(xrb, y), n, 1, ZPixmap,
+ ~0L, (pointer)span->data);
+#else
+ int k;
+ y = YFLIP(xrb, y);
+ k = clip_for_xgetimage(ctx, &n, &x, &y);
+ if (k < 0)
+ return;
+ rgba += k;
+ catch_xgetimage_errors( xmesa->display );
+ span = XGetImage( xmesa->display, xrb->pixmap,
+ x, y, n, 1, AllPlanes, ZPixmap );
+ error = check_xgetimage_errors();
+#endif
+ if (span && !error) {
+ switch (xmesa->pixelformat) {
+ case PF_Truecolor:
+ case PF_Dither_True:
+ {
+ 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);
+ 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 );
+ rgba[i][RCOMP] = pixelToR[(p & rMask) >> rShift];
+ rgba[i][GCOMP] = pixelToG[(p & gMask) >> gShift];
+ rgba[i][BCOMP] = pixelToB[(p & bMask) >> bShift];
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ 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:
+ {
+ const GLuint *ptr4 = (GLuint *) span->data;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ GLuint p4 = *ptr4++;
+ rgba[i][RCOMP] = (GLubyte) ( p4 & 0xff);
+ rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
+ rgba[i][BCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
+ rgba[i][ACOMP] = (GLubyte) ((p4 >> 24) & 0xff);
+ }
+ }
+ break;
+ case PF_8A8R8G8B:
+ {
+ const GLuint *ptr4 = (GLuint *) span->data;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ GLuint p4 = *ptr4++;
+ rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
+ rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
+ rgba[i][BCOMP] = (GLubyte) ( p4 & 0xff);
+ rgba[i][ACOMP] = (GLubyte) ((p4 >> 24) & 0xff);
+ }
+ }
+ break;
+ case PF_8R8G8B:
+ {
+ const GLuint *ptr4 = (GLuint *) span->data;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ GLuint p4 = *ptr4++;
+ rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
+ rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
+ rgba[i][BCOMP] = (GLubyte) ( p4 & 0xff);
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ break;
+ case PF_8R8G8B24:
+ {
+ 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;
+ rgba[i][BCOMP] = ptr3[i].b;
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ break;
+ case PF_HPCR:
+ {
+ GLubyte *ptr1 = (GLubyte *) span->data;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ GLubyte p = *ptr1++;
+ rgba[i][RCOMP] = p & 0xE0;
+ rgba[i][GCOMP] = (p & 0x1C) << 3;
+ rgba[i][BCOMP] = (p & 0x03) << 6;
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ break;
+ case PF_Dither:
+ case PF_Lookup:
+ case PF_Grayscale:
+ {
+ GLubyte *rTable = source->pixel_to_r;
+ GLubyte *gTable = source->pixel_to_g;
+ GLubyte *bTable = source->pixel_to_b;
+ if (GET_VISUAL_DEPTH(xmesa->xm_visual)==8) {
+ const GLubyte *ptr1 = (GLubyte *) span->data;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ unsigned long p = *ptr1++;
+ rgba[i][RCOMP] = rTable[p];
+ rgba[i][GCOMP] = gTable[p];
+ rgba[i][BCOMP] = bTable[p];
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ else {
+ GLuint i;
+ for (i=0;i<n;i++) {
+ unsigned long p = XMesaGetPixel( span, i, 0 );
+ rgba[i][RCOMP] = rTable[p];
+ rgba[i][GCOMP] = gTable[p];
+ rgba[i][BCOMP] = bTable[p];
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ }
+ break;
+ 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;
+ rgba[i][RCOMP] = (GLubyte) (p * 255);
+ rgba[i][GCOMP] = (GLubyte) (p * 255);
+ rgba[i][BCOMP] = (GLubyte) (p * 255);
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL,"Problem in DD.read_color_span (1)");
+ return;
+ }
+ }
+ 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;
+ }
+ }
+ if (span) {
+ XMesaDestroyImage( span );
+ }
+ }
+ else if (xrb->ximage) {
+ /* Read from XImage back buffer */
+ switch (xmesa->pixelformat) {
+ case PF_Truecolor:
+ case PF_Dither_True:
+ {
+ 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);
+ GLint rShift = xmesa->xm_visual->rshift;
+ GLint gShift = xmesa->xm_visual->gshift;
+ GLint bShift = xmesa->xm_visual->bshift;
+ XMesaImage *img = xrb->ximage;
+ GLuint i;
+ y = YFLIP(xrb, y);
+ for (i=0;i<n;i++) {
+ unsigned long p;
+ p = XMesaGetPixel( img, x+i, y );
+ rgba[i][RCOMP] = pixelToR[(p & rMask) >> rShift];
+ rgba[i][GCOMP] = pixelToG[(p & gMask) >> gShift];
+ rgba[i][BCOMP] = pixelToB[(p & bMask) >> bShift];
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ 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 = PIXEL_ADDR2(xrb, x, y);
+ GLuint i;
+#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */
+ const GLuint *ptr4 = (const GLuint *) ptr2;
+ 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:
+ {
+ const GLuint *ptr4 = PIXEL_ADDR4(xrb, x, y);
+ GLuint i;
+ for (i=0;i<n;i++) {
+ GLuint p4 = *ptr4++;
+ rgba[i][RCOMP] = (GLubyte) ( p4 & 0xff);
+ rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
+ rgba[i][BCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
+ rgba[i][ACOMP] = (GLint) ((p4 >> 24) & 0xff);
+ }
+ }
+ break;
+ case PF_8A8R8G8B:
+ {
+ const GLuint *ptr4 = PIXEL_ADDR4(xrb, x, y);
+ GLuint i;
+ for (i=0;i<n;i++) {
+ GLuint p4 = *ptr4++;
+ rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
+ rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
+ rgba[i][BCOMP] = (GLubyte) ( p4 & 0xff);
+ rgba[i][ACOMP] = (GLint) ((p4 >> 24) & 0xff);
+ }
+ }
+ break;
+ case PF_8R8G8B:
+ {
+ const GLuint *ptr4 = PIXEL_ADDR4(xrb, x, y);
+ GLuint i;
+ for (i=0;i<n;i++) {
+ GLuint p4 = *ptr4++;
+ rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
+ rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
+ rgba[i][BCOMP] = (GLubyte) ( p4 & 0xff);
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ break;
+ case PF_8R8G8B24:
+ {
+ const bgr_t *ptr3 = PIXEL_ADDR3(xrb, x, y);
+ GLuint i;
+ for (i=0;i<n;i++) {
+ rgba[i][RCOMP] = ptr3[i].r;
+ rgba[i][GCOMP] = ptr3[i].g;
+ rgba[i][BCOMP] = ptr3[i].b;
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ break;
+ case PF_HPCR:
+ {
+ const GLubyte *ptr1 = PIXEL_ADDR1(xrb, x, y);
+ GLuint i;
+ for (i=0;i<n;i++) {
+ GLubyte p = *ptr1++;
+ rgba[i][RCOMP] = p & 0xE0;
+ rgba[i][GCOMP] = (p & 0x1C) << 3;
+ rgba[i][BCOMP] = (p & 0x03) << 6;
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ break;
+ case PF_Dither:
+ case PF_Lookup:
+ case PF_Grayscale:
+ {
+ 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 = PIXEL_ADDR1(xrb, x, y);
+ GLuint i;
+ for (i=0;i<n;i++) {
+ unsigned long p = *ptr1++;
+ rgba[i][RCOMP] = rTable[p];
+ rgba[i][GCOMP] = gTable[p];
+ rgba[i][BCOMP] = bTable[p];
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ else {
+ XMesaImage *img = xrb->ximage;
+ GLuint i;
+ y = YFLIP(xrb, y);
+ for (i=0;i<n;i++,x++) {
+ unsigned long p = XMesaGetPixel( img, x, y );
+ rgba[i][RCOMP] = rTable[p];
+ rgba[i][GCOMP] = gTable[p];
+ rgba[i][BCOMP] = bTable[p];
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ }
+ break;
+ case PF_1Bit:
+ {
+ XMesaImage *img = xrb->ximage;
+ int bitFlip = xmesa->xm_visual->bitFlip;
+ GLuint i;
+ y = YFLIP(xrb, y);
+ for (i=0;i<n;i++,x++) {
+ unsigned long p;
+ p = XMesaGetPixel( img, x, y ) ^ bitFlip;
+ rgba[i][RCOMP] = (GLubyte) (p * 255);
+ rgba[i][GCOMP] = (GLubyte) (p * 255);
+ rgba[i][BCOMP] = (GLubyte) (p * 255);
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL,"Problem in DD.read_color_span (2)");
+ return;
+ }
+ }
+}
+
+
+
+/*
+ * Read an array of color index pixels.
+ */
+static void
+get_values_ci(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[], void *values)
+{
+ GLuint *indx = (GLuint *) values;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ GLuint i;
+ if (xrb->pixmap) {
+ for (i=0;i<n;i++) {
+ indx[i] = (GLuint) read_pixel( xmesa->display, xrb->drawable,
+ x[i], YFLIP(xrb, y[i]) );
+ }
+ }
+ else if (xrb->ximage) {
+ XMesaImage *img = xrb->ximage;
+ for (i=0;i<n;i++) {
+ indx[i] = (GLuint) XMesaGetPixel( img, x[i], YFLIP(xrb, y[i]) );
+ }
+ }
+}
+
+
+
+static void
+get_values_rgba(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, const GLint x[], const GLint y[], void *values)
+{
+ GLubyte (*rgba)[4] = (GLubyte (*)[4]) values;
+ struct xmesa_renderbuffer *xrb = (struct xmesa_renderbuffer *) rb;
+ const XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ XMesaDisplay *dpy = xmesa->xm_visual->display;
+ XMesaBuffer source = XMESA_BUFFER(ctx->DrawBuffer);
+ register GLuint i;
+
+ if (xrb->pixmap) {
+ XMesaDrawable buffer = xrb->drawable;
+ switch (xmesa->pixelformat) {
+ case PF_Truecolor:
+ case PF_Dither_True:
+ case PF_5R6G5B:
+ case PF_Dither_5R6G5B:
+ {
+ 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;
+ for (i=0;i<n;i++) {
+ unsigned long p = read_pixel( dpy, buffer,
+ x[i], YFLIP(xrb, y[i]) );
+ rgba[i][RCOMP] = pixelToR[(p & rMask) >> rShift];
+ rgba[i][GCOMP] = pixelToG[(p & gMask) >> gShift];
+ rgba[i][BCOMP] = pixelToB[(p & bMask) >> bShift];
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ break;
+ case PF_8A8B8G8R:
+ for (i=0;i<n;i++) {
+ unsigned long p = read_pixel( dpy, buffer,
+ x[i], YFLIP(xrb, y[i]) );
+ rgba[i][RCOMP] = (GLubyte) ( p & 0xff);
+ rgba[i][GCOMP] = (GLubyte) ((p >> 8) & 0xff);
+ rgba[i][BCOMP] = (GLubyte) ((p >> 16) & 0xff);
+ rgba[i][ACOMP] = (GLubyte) ((p >> 24) & 0xff);
+ }
+ break;
+ case PF_8A8R8G8B:
+ for (i=0;i<n;i++) {
+ unsigned long p = read_pixel( dpy, buffer,
+ x[i], YFLIP(xrb, y[i]) );
+ rgba[i][RCOMP] = (GLubyte) ((p >> 16) & 0xff);
+ rgba[i][GCOMP] = (GLubyte) ((p >> 8) & 0xff);
+ rgba[i][BCOMP] = (GLubyte) ( p & 0xff);
+ rgba[i][ACOMP] = (GLubyte) ((p >> 24) & 0xff);
+ }
+ break;
+ case PF_8R8G8B:
+ for (i=0;i<n;i++) {
+ unsigned long p = read_pixel( dpy, buffer,
+ x[i], YFLIP(xrb, y[i]) );
+ rgba[i][RCOMP] = (GLubyte) ((p >> 16) & 0xff);
+ rgba[i][GCOMP] = (GLubyte) ((p >> 8) & 0xff);
+ rgba[i][BCOMP] = (GLubyte) ( p & 0xff);
+ rgba[i][ACOMP] = 255;
+ }
+ break;
+ case PF_8R8G8B24:
+ for (i=0;i<n;i++) {
+ unsigned long p = read_pixel( dpy, buffer,
+ x[i], YFLIP(xrb, y[i]) );
+ rgba[i][RCOMP] = (GLubyte) ((p >> 16) & 0xff);
+ rgba[i][GCOMP] = (GLubyte) ((p >> 8) & 0xff);
+ rgba[i][BCOMP] = (GLubyte) ( p & 0xff);
+ rgba[i][ACOMP] = 255;
+ }
+ break;
+ case PF_HPCR:
+ for (i=0;i<n;i++) {
+ unsigned long p = read_pixel( dpy, buffer,
+ x[i], YFLIP(xrb, y[i]) );
+ rgba[i][RCOMP] = (GLubyte) ( p & 0xE0 );
+ rgba[i][GCOMP] = (GLubyte) ((p & 0x1C) << 3);
+ rgba[i][BCOMP] = (GLubyte) ((p & 0x03) << 6);
+ rgba[i][ACOMP] = (GLubyte) 255;
+ }
+ break;
+ case PF_Dither:
+ case PF_Lookup:
+ case PF_Grayscale:
+ {
+ GLubyte *rTable = source->pixel_to_r;
+ GLubyte *gTable = source->pixel_to_g;
+ GLubyte *bTable = source->pixel_to_b;
+ for (i=0;i<n;i++) {
+ unsigned long p = read_pixel( dpy, buffer,
+ x[i], YFLIP(xrb, y[i]) );
+ rgba[i][RCOMP] = rTable[p];
+ rgba[i][GCOMP] = gTable[p];
+ rgba[i][BCOMP] = bTable[p];
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ break;
+ case PF_1Bit:
+ {
+ int bitFlip = xmesa->xm_visual->bitFlip;
+ for (i=0;i<n;i++) {
+ unsigned long p = read_pixel( dpy, buffer,
+ x[i], YFLIP(xrb, y[i])) ^ bitFlip;
+ rgba[i][RCOMP] = (GLubyte) (p * 255);
+ rgba[i][GCOMP] = (GLubyte) (p * 255);
+ rgba[i][BCOMP] = (GLubyte) (p * 255);
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL,"Problem in DD.read_color_pixels (1)");
+ return;
+ }
+ }
+ else if (xrb->ximage) {
+ /* Read from XImage back buffer */
+ switch (xmesa->pixelformat) {
+ case PF_Truecolor:
+ case PF_Dither_True:
+ case PF_5R6G5B:
+ case PF_Dither_5R6G5B:
+ {
+ 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 = xrb->ximage;
+ for (i=0;i<n;i++) {
+ unsigned long p;
+ p = XMesaGetPixel( img, x[i], YFLIP(xrb, y[i]) );
+ rgba[i][RCOMP] = pixelToR[(p & rMask) >> rShift];
+ rgba[i][GCOMP] = pixelToG[(p & gMask) >> gShift];
+ rgba[i][BCOMP] = pixelToB[(p & bMask) >> bShift];
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ break;
+ case PF_8A8B8G8R:
+ for (i=0;i<n;i++) {
+ GLuint *ptr4 = PIXEL_ADDR4(xrb, x[i], y[i]);
+ GLuint p4 = *ptr4;
+ rgba[i][RCOMP] = (GLubyte) ( p4 & 0xff);
+ rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
+ rgba[i][BCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
+ rgba[i][ACOMP] = (GLubyte) ((p4 >> 24) & 0xff);
+ }
+ break;
+ case PF_8A8R8G8B:
+ for (i=0;i<n;i++) {
+ GLuint *ptr4 = PIXEL_ADDR4(xrb, x[i], y[i]);
+ GLuint p4 = *ptr4;
+ rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
+ rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
+ rgba[i][BCOMP] = (GLubyte) ( p4 & 0xff);
+ rgba[i][ACOMP] = (GLubyte) ((p4 >> 24) & 0xff);
+ }
+ break;
+ case PF_8R8G8B:
+ for (i=0;i<n;i++) {
+ GLuint *ptr4 = PIXEL_ADDR4(xrb, x[i], y[i]);
+ GLuint p4 = *ptr4;
+ rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff);
+ rgba[i][GCOMP] = (GLubyte) ((p4 >> 8) & 0xff);
+ rgba[i][BCOMP] = (GLubyte) ( p4 & 0xff);
+ rgba[i][ACOMP] = 255;
+ }
+ break;
+ case PF_8R8G8B24:
+ for (i=0;i<n;i++) {
+ bgr_t *ptr3 = PIXEL_ADDR3(xrb, x[i], y[i]);
+ rgba[i][RCOMP] = ptr3->r;
+ rgba[i][GCOMP] = ptr3->g;
+ rgba[i][BCOMP] = ptr3->b;
+ rgba[i][ACOMP] = 255;
+ }
+ break;
+ case PF_HPCR:
+ for (i=0;i<n;i++) {
+ GLubyte *ptr1 = PIXEL_ADDR1(xrb, x[i], y[i]);
+ GLubyte p = *ptr1;
+ rgba[i][RCOMP] = p & 0xE0;
+ rgba[i][GCOMP] = (p & 0x1C) << 3;
+ rgba[i][BCOMP] = (p & 0x03) << 6;
+ rgba[i][ACOMP] = 255;
+ }
+ break;
+ case PF_Dither:
+ case PF_Lookup:
+ case PF_Grayscale:
+ {
+ GLubyte *rTable = source->pixel_to_r;
+ GLubyte *gTable = source->pixel_to_g;
+ GLubyte *bTable = source->pixel_to_b;
+ XMesaImage *img = xrb->ximage;
+ for (i=0;i<n;i++) {
+ unsigned long p;
+ p = XMesaGetPixel( img, x[i], YFLIP(xrb, y[i]) );
+ rgba[i][RCOMP] = rTable[p];
+ rgba[i][GCOMP] = gTable[p];
+ rgba[i][BCOMP] = bTable[p];
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ break;
+ case PF_1Bit:
+ {
+ XMesaImage *img = xrb->ximage;
+ int bitFlip = xmesa->xm_visual->bitFlip;
+ for (i=0;i<n;i++) {
+ unsigned long p;
+ p = XMesaGetPixel( img, x[i], YFLIP(xrb, y[i]) ) ^ bitFlip;
+ rgba[i][RCOMP] = (GLubyte) (p * 255);
+ rgba[i][GCOMP] = (GLubyte) (p * 255);
+ rgba[i][BCOMP] = (GLubyte) (p * 255);
+ rgba[i][ACOMP] = 255;
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL,"Problem in DD.read_color_pixels (1)");
+ return;
+ }
+ }
+}
+
+
+/**
+ * Initialize the renderbuffer's PutRow, GetRow, etc. functions.
+ * This would generally only need to be called once when the renderbuffer
+ * is created. However, we can change pixel formats on the fly if dithering
+ * is enabled/disabled. Therefore, we may call this more often than that.
+ */
+void
+xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer *xrb,
+ enum pixel_format pixelformat, GLint depth)
+{
+ const GLboolean pixmap = xrb->pixmap ? GL_TRUE : GL_FALSE;
+
+ switch (pixelformat) {
+ case PF_Index:
+ ASSERT(xrb->Base.DataType == GL_UNSIGNED_INT);
+ if (pixmap) {
+ xrb->Base.PutRow = put_row_ci_pixmap;
+ xrb->Base.PutRowRGB = NULL;
+ xrb->Base.PutMonoRow = put_mono_row_ci_pixmap;
+ xrb->Base.PutValues = put_values_ci_pixmap;
+ xrb->Base.PutMonoValues = put_mono_values_ci_pixmap;
+ }
+ else {
+ xrb->Base.PutRow = put_row_ci_ximage;
+ xrb->Base.PutRowRGB = NULL;
+ xrb->Base.PutMonoRow = put_mono_row_ci_ximage;
+ xrb->Base.PutValues = put_values_ci_ximage;
+ xrb->Base.PutMonoValues = put_mono_values_ci_ximage;
+ }
+ break;
+ case PF_Truecolor:
+ if (pixmap) {
+ xrb->Base.PutRow = put_row_TRUECOLOR_pixmap;
+ xrb->Base.PutRowRGB = put_row_rgb_TRUECOLOR_pixmap;
+ xrb->Base.PutMonoRow = put_mono_row_pixmap;
+ xrb->Base.PutValues = put_values_TRUECOLOR_pixmap;
+ xrb->Base.PutMonoValues = put_mono_values_pixmap;
+ }
+ else {
+ xrb->Base.PutRow = put_row_TRUECOLOR_ximage;
+ xrb->Base.PutRowRGB = put_row_rgb_TRUECOLOR_ximage;
+ xrb->Base.PutMonoRow = put_mono_row_ximage;
+ xrb->Base.PutValues = put_values_TRUECOLOR_ximage;
+ xrb->Base.PutMonoValues = put_mono_values_ximage;
+ }
+ break;
+ case PF_Dither_True:
+ if (pixmap) {
+ xrb->Base.PutRow = put_row_TRUEDITHER_pixmap;
+ xrb->Base.PutRowRGB = put_row_rgb_TRUEDITHER_pixmap;
+ xrb->Base.PutMonoRow = put_mono_row_TRUEDITHER_pixmap;
+ xrb->Base.PutValues = put_values_TRUEDITHER_pixmap;
+ xrb->Base.PutMonoValues = put_mono_values_TRUEDITHER_pixmap;
+ }
+ else {
+ xrb->Base.PutRow = put_row_TRUEDITHER_ximage;
+ xrb->Base.PutRowRGB = put_row_rgb_TRUEDITHER_ximage;
+ xrb->Base.PutMonoRow = put_mono_row_TRUEDITHER_ximage;
+ xrb->Base.PutValues = put_values_TRUEDITHER_ximage;
+ xrb->Base.PutMonoValues = put_mono_values_TRUEDITHER_ximage;
+ }
+ break;
+ case PF_8A8B8G8R:
+ if (pixmap) {
+ xrb->Base.PutRow = put_row_8A8B8G8R_pixmap;
+ xrb->Base.PutRowRGB = put_row_rgb_8A8B8G8R_pixmap;
+ xrb->Base.PutMonoRow = put_mono_row_pixmap;
+ xrb->Base.PutValues = put_values_8A8B8G8R_pixmap;
+ xrb->Base.PutMonoValues = put_mono_values_pixmap;
+ }
+ else {
+ xrb->Base.PutRow = put_row_8A8B8G8R_ximage;
+ xrb->Base.PutRowRGB = put_row_rgb_8A8B8G8R_ximage;
+ xrb->Base.PutMonoRow = put_mono_row_8A8B8G8R_ximage;
+ xrb->Base.PutValues = put_values_8A8B8G8R_ximage;
+ xrb->Base.PutMonoValues = put_mono_values_8A8B8G8R_ximage;
+ }
+ break;
+ case PF_8A8R8G8B:
+ if (pixmap) {
+ xrb->Base.PutRow = put_row_8A8R8G8B_pixmap;
+ xrb->Base.PutRowRGB = put_row_rgb_8A8R8G8B_pixmap;
+ xrb->Base.PutMonoRow = put_mono_row_pixmap;
+ xrb->Base.PutValues = put_values_8A8R8G8B_pixmap;
+ xrb->Base.PutMonoValues = put_mono_values_pixmap;
+ }
+ else {
+ xrb->Base.PutRow = put_row_8A8R8G8B_ximage;
+ xrb->Base.PutRowRGB = put_row_rgb_8A8R8G8B_ximage;
+ xrb->Base.PutMonoRow = put_mono_row_8A8R8G8B_ximage;
+ xrb->Base.PutValues = put_values_8A8R8G8B_ximage;
+ xrb->Base.PutMonoValues = put_mono_values_8A8R8G8B_ximage;
+ }
+ break;
+ case PF_8R8G8B:
+ if (pixmap) {
+ xrb->Base.PutRow = put_row_8R8G8B_pixmap;
+ xrb->Base.PutRowRGB = put_row_rgb_8R8G8B_pixmap;
+ xrb->Base.PutMonoRow = put_mono_row_pixmap;
+ xrb->Base.PutValues = put_values_8R8G8B_pixmap;
+ xrb->Base.PutMonoValues = put_mono_values_pixmap;
+ }
+ else {
+ xrb->Base.PutRow = put_row_8R8G8B_ximage;
+ xrb->Base.PutRowRGB = put_row_rgb_8R8G8B_ximage;
+ xrb->Base.PutMonoRow = put_mono_row_8R8G8B_ximage;
+ xrb->Base.PutValues = put_values_8R8G8B_ximage;
+ xrb->Base.PutMonoValues = put_mono_values_8R8G8B_ximage;
+ }
+ break;
+ case PF_8R8G8B24:
+ if (pixmap) {
+ xrb->Base.PutRow = put_row_8R8G8B24_pixmap;
+ xrb->Base.PutRowRGB = put_row_rgb_8R8G8B24_pixmap;
+ xrb->Base.PutMonoRow = put_mono_row_pixmap;
+ xrb->Base.PutValues = put_values_8R8G8B24_pixmap;
+ xrb->Base.PutMonoValues = put_mono_values_pixmap;
+ }
+ else {
+ xrb->Base.PutRow = put_row_8R8G8B24_ximage;
+ xrb->Base.PutRowRGB = put_row_rgb_8R8G8B24_ximage;
+ xrb->Base.PutMonoRow = put_mono_row_8R8G8B24_ximage;
+ xrb->Base.PutValues = put_values_8R8G8B24_ximage;
+ xrb->Base.PutMonoValues = put_mono_values_8R8G8B24_ximage;
+ }
+ break;
+ case PF_5R6G5B:
+ if (pixmap) {
+ xrb->Base.PutRow = put_row_5R6G5B_pixmap;
+ xrb->Base.PutRowRGB = put_row_rgb_5R6G5B_pixmap;
+ xrb->Base.PutMonoRow = put_mono_row_pixmap;
+ xrb->Base.PutValues = put_values_5R6G5B_pixmap;
+ xrb->Base.PutMonoValues = put_mono_values_pixmap;
+ }
+ else {
+ xrb->Base.PutRow = put_row_5R6G5B_ximage;
+ xrb->Base.PutRowRGB = put_row_rgb_5R6G5B_ximage;
+ xrb->Base.PutMonoRow = put_mono_row_ximage;
+ xrb->Base.PutValues = put_values_5R6G5B_ximage;
+ xrb->Base.PutMonoValues = put_mono_values_ximage;
+ }
+ break;
+ case PF_Dither_5R6G5B:
+ if (pixmap) {
+ xrb->Base.PutRow = put_row_DITHER_5R6G5B_pixmap;
+ xrb->Base.PutRowRGB = put_row_rgb_DITHER_5R6G5B_pixmap;
+ xrb->Base.PutMonoRow = put_mono_row_TRUEDITHER_pixmap;
+ xrb->Base.PutValues = put_values_DITHER_5R6G5B_pixmap;
+ xrb->Base.PutMonoValues = put_mono_values_TRUEDITHER_pixmap;
+ }
+ else {
+ xrb->Base.PutRow = put_row_DITHER_5R6G5B_ximage;
+ xrb->Base.PutRowRGB = put_row_rgb_DITHER_5R6G5B_ximage;
+ xrb->Base.PutMonoRow = put_mono_row_DITHER_5R6G5B_ximage;
+ xrb->Base.PutValues = put_values_DITHER_5R6G5B_ximage;
+ xrb->Base.PutMonoValues = put_mono_values_DITHER_5R6G5B_ximage;
+ }
+ break;
+ case PF_Dither:
+ if (pixmap) {
+ xrb->Base.PutRow = put_row_DITHER_pixmap;
+ xrb->Base.PutRowRGB = put_row_rgb_DITHER_pixmap;
+ xrb->Base.PutMonoRow = put_mono_row_DITHER_pixmap;
+ xrb->Base.PutValues = put_values_DITHER_pixmap;
+ xrb->Base.PutMonoValues = put_mono_values_DITHER_pixmap;
+ }
+ else {
+ if (depth == 8) {
+ xrb->Base.PutRow = put_row_DITHER8_ximage;
+ xrb->Base.PutRowRGB = put_row_rgb_DITHER8_ximage;
+ xrb->Base.PutMonoRow = put_mono_row_DITHER8_ximage;
+ xrb->Base.PutValues = put_values_DITHER8_ximage;
+ xrb->Base.PutMonoValues = put_mono_values_DITHER8_ximage;
+ }
+ else {
+ xrb->Base.PutRow = put_row_DITHER_ximage;
+ xrb->Base.PutRowRGB = put_row_rgb_DITHER_ximage;
+ xrb->Base.PutMonoRow = put_mono_row_DITHER_ximage;
+ xrb->Base.PutValues = put_values_DITHER_ximage;
+ xrb->Base.PutMonoValues = put_mono_values_DITHER_ximage;
+ }
+ }
+ break;
+ case PF_1Bit:
+ if (pixmap) {
+ xrb->Base.PutRow = put_row_1BIT_pixmap;
+ xrb->Base.PutRowRGB = put_row_rgb_1BIT_pixmap;
+ xrb->Base.PutMonoRow = put_mono_row_1BIT_pixmap;
+ xrb->Base.PutValues = put_values_1BIT_pixmap;
+ xrb->Base.PutMonoValues = put_mono_values_1BIT_pixmap;
+ }
+ else {
+ xrb->Base.PutRow = put_row_1BIT_ximage;
+ xrb->Base.PutRowRGB = put_row_rgb_1BIT_ximage;
+ xrb->Base.PutMonoRow = put_mono_row_1BIT_ximage;
+ xrb->Base.PutValues = put_values_1BIT_ximage;
+ xrb->Base.PutMonoValues = put_mono_values_1BIT_ximage;
+ }
+ break;
+ case PF_HPCR:
+ if (pixmap) {
+ xrb->Base.PutRow = put_row_HPCR_pixmap;
+ xrb->Base.PutRowRGB = put_row_rgb_HPCR_pixmap;
+ xrb->Base.PutMonoRow = put_mono_row_pixmap;
+ xrb->Base.PutValues = put_values_HPCR_pixmap;
+ xrb->Base.PutMonoValues = put_mono_values_pixmap;
+ }
+ else {
+ xrb->Base.PutRow = put_row_HPCR_ximage;
+ xrb->Base.PutRowRGB = put_row_rgb_HPCR_ximage;
+ xrb->Base.PutMonoRow = put_mono_row_HPCR_ximage;
+ xrb->Base.PutValues = put_values_HPCR_ximage;
+ xrb->Base.PutMonoValues = put_mono_values_HPCR_ximage;
+ }
+ break;
+ case PF_Lookup:
+ if (pixmap) {
+ xrb->Base.PutRow = put_row_LOOKUP_pixmap;
+ xrb->Base.PutRowRGB = put_row_rgb_LOOKUP_pixmap;
+ xrb->Base.PutMonoRow = put_mono_row_pixmap;
+ xrb->Base.PutValues = put_values_LOOKUP_pixmap;
+ xrb->Base.PutMonoValues = put_mono_values_pixmap;
+ }
+ else {
+ if (depth==8) {
+ xrb->Base.PutRow = put_row_LOOKUP8_ximage;
+ xrb->Base.PutRowRGB = put_row_rgb_LOOKUP8_ximage;
+ xrb->Base.PutMonoRow = put_mono_row_LOOKUP8_ximage;
+ xrb->Base.PutValues = put_values_LOOKUP8_ximage;
+ xrb->Base.PutMonoValues = put_mono_values_LOOKUP8_ximage;
+ }
+ else {
+ xrb->Base.PutRow = put_row_LOOKUP_ximage;
+ xrb->Base.PutRowRGB = put_row_rgb_LOOKUP_ximage;
+ xrb->Base.PutMonoRow = put_mono_row_ximage;
+ xrb->Base.PutValues = put_values_LOOKUP_ximage;
+ xrb->Base.PutMonoValues = put_mono_values_ximage;
+ }
+ }
+ break;
+ case PF_Grayscale:
+ if (pixmap) {
+ xrb->Base.PutRow = put_row_GRAYSCALE_pixmap;
+ xrb->Base.PutRowRGB = put_row_rgb_GRAYSCALE_pixmap;
+ xrb->Base.PutMonoRow = put_mono_row_pixmap;
+ xrb->Base.PutValues = put_values_GRAYSCALE_pixmap;
+ xrb->Base.PutMonoValues = put_mono_values_pixmap;
+ }
+ else {
+ if (depth == 8) {
+ xrb->Base.PutRow = put_row_GRAYSCALE8_ximage;
+ xrb->Base.PutRowRGB = put_row_rgb_GRAYSCALE8_ximage;
+ xrb->Base.PutMonoRow = put_mono_row_GRAYSCALE8_ximage;
+ xrb->Base.PutValues = put_values_GRAYSCALE8_ximage;
+ xrb->Base.PutMonoValues = put_mono_values_GRAYSCALE8_ximage;
+ }
+ else {
+ xrb->Base.PutRow = put_row_GRAYSCALE_ximage;
+ xrb->Base.PutRowRGB = put_row_rgb_GRAYSCALE_ximage;
+ xrb->Base.PutMonoRow = put_mono_row_ximage;
+ xrb->Base.PutValues = put_values_GRAYSCALE_ximage;
+ xrb->Base.PutMonoValues = put_mono_values_ximage;
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL, "Bad pixel format in xmesa_update_state (1)");
+ return;
+ }
+
+
+ /* Get functions */
+ if (pixelformat == PF_Index) {
+ xrb->Base.GetRow = get_row_ci;
+ xrb->Base.GetValues = get_values_ci;
+ }
+ else {
+ xrb->Base.GetRow = get_row_rgba;
+ xrb->Base.GetValues = get_values_rgba;
+ }
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_tri.c b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_tri.c
new file mode 100644
index 000000000..87989f46f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xm_tri.c
@@ -0,0 +1,1623 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+/*
+ * This file contains "accelerated" triangle functions. It should be
+ * fairly easy to write new special-purpose triangle functions and hook
+ * them into this module.
+ */
+
+
+#include "glxheader.h"
+#include "depth.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "xmesaP.h"
+
+/* Internal swrast includes:
+ */
+#include "swrast/s_context.h"
+#include "swrast/s_depth.h"
+#include "swrast/s_triangle.h"
+
+
+#define GET_XRB(XRB) struct xmesa_renderbuffer *XRB = \
+ (struct xmesa_renderbuffer *) ctx->DrawBuffer->_ColorDrawBuffers[0][0]->Wrapped
+
+
+/**********************************************************************/
+/*** Triangle rendering ***/
+/**********************************************************************/
+
+
+/*
+ * XImage, smooth, depth-buffered, PF_TRUECOLOR triangle.
+ */
+#define NAME smooth_TRUECOLOR_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define SETUP_CODE \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
+
+#define RENDER_SPAN( span ) \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ GLuint i; \
+ for (i = 0; i < span.end; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ unsigned long p; \
+ PACK_TRUECOLOR(p, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ XMesaPutPixel(xrb->ximage, x, y, p); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+
+
+
+
+/*
+ * XImage, smooth, depth-buffered, PF_8A8B8G8R triangle.
+ */
+#define NAME smooth_8A8B8G8R_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = PACK_8B8G8R(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, depth-buffered, PF_8A8R8G8B triangle.
+ */
+#define NAME smooth_8A8R8G8B_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb);
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = PACK_8R8G8B(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, depth-buffered, PF_8R8G8B triangle.
+ */
+#define NAME smooth_8R8G8B_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb);
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = PACK_8R8G8B(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, depth-buffered, PF_8R8G8B24 triangle.
+ */
+#define NAME smooth_8R8G8B24_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
+#define PIXEL_TYPE bgr_t
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ PIXEL_TYPE *ptr = pRow + i; \
+ ptr->r = FixedToInt(span.red); \
+ ptr->g = FixedToInt(span.green); \
+ ptr->b = FixedToInt(span.blue); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, depth-buffered, PF_TRUEDITHER triangle.
+ */
+#define NAME smooth_TRUEDITHER_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define SETUP_CODE \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ unsigned long p; \
+ PACK_TRUEDITHER(p, x, y, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ XMesaPutPixel(xrb->ximage, x, y, p); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, depth-buffered, PF_5R6G5B triangle.
+ */
+#define NAME smooth_5R6G5B_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = PACK_5R6G5B(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, depth-buffered, PF_DITHER_5R6G5B triangle.
+ */
+#define NAME smooth_DITHER_5R6G5B_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ PACK_TRUEDITHER(pRow[i], x, y, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, depth-buffered, 8-bit, PF_DITHER8 triangle.
+ */
+#define NAME smooth_DITHER8_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ XDITHER_SETUP(y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = (PIXEL_TYPE) XDITHER(x, FixedToInt(span.red),\
+ FixedToInt(span.green), FixedToInt(span.blue) ); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, depth-buffered, PF_DITHER triangle.
+ */
+#define NAME smooth_DITHER_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ XDITHER_SETUP(y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ unsigned long p = XDITHER(x, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ XMesaPutPixel(img, x, y, p); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, depth-buffered, 8-bit PF_LOOKUP triangle.
+ */
+#define NAME smooth_LOOKUP8_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ LOOKUP_SETUP; \
+ for (i = 0; i < span.end; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = LOOKUP(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, depth-buffered, 8-bit PF_HPCR triangle.
+ */
+#define NAME smooth_HPCR_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = DITHER_HPCR(x, y, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue) ); \
+ zRow[i] = z; \
+ } \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, depth-buffered, PF_TRUECOLOR triangle.
+ */
+#define NAME flat_TRUECOLOR_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define SETUP_CODE \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage; \
+ unsigned long pixel; \
+ PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ XMesaPutPixel(img, x, y, pixel); \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, depth-buffered, PF_8A8B8G8R triangle.
+ */
+#define NAME flat_8A8B8G8R_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ GLuint p = PACK_8B8G8R( v2->color[0], v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = (PIXEL_TYPE) p; \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, depth-buffered, PF_8A8R8G8B triangle.
+ */
+#define NAME flat_8A8R8G8B_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ GLuint p = PACK_8R8G8B( v2->color[0], v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = (PIXEL_TYPE) p; \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, depth-buffered, PF_8R8G8B triangle.
+ */
+#define NAME flat_8R8G8B_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ GLuint p = PACK_8R8G8B( v2->color[0], v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = (PIXEL_TYPE) p; \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, depth-buffered, PF_8R8G8B24 triangle.
+ */
+#define NAME flat_8R8G8B24_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
+#define PIXEL_TYPE bgr_t
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ const GLubyte *color = v2->color;
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ PIXEL_TYPE *ptr = pRow + i; \
+ ptr->r = color[RCOMP]; \
+ ptr->g = color[GCOMP]; \
+ ptr->b = color[BCOMP]; \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, depth-buffered, PF_TRUEDITHER triangle.
+ */
+#define NAME flat_TRUEDITHER_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define SETUP_CODE \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ unsigned long p; \
+ PACK_TRUEDITHER(p, x, y, v2->color[0], \
+ v2->color[1], v2->color[2]); \
+ XMesaPutPixel(img, x, y, p); \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, depth-buffered, PF_5R6G5B triangle.
+ */
+#define NAME flat_5R6G5B_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ GLushort p = PACK_5R6G5B( v2->color[0], v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = (PIXEL_TYPE) p; \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, depth-buffered, PF_DITHER_5R6G5B triangle.
+ */
+#define NAME flat_DITHER_5R6G5B_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
+ const GLubyte *color = v2->color;
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ PACK_TRUEDITHER(pRow[i], x, y, color[RCOMP], \
+ color[GCOMP], color[BCOMP]); \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, depth-buffered, 8-bit PF_DITHER triangle.
+ */
+#define NAME flat_DITHER8_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ FLAT_DITHER_ROW_SETUP(YFLIP(xrb, y)); \
+ for (i = 0; i < span.end; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = (PIXEL_TYPE) FLAT_DITHER(x); \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, depth-buffered, PF_DITHER triangle.
+ */
+#define NAME flat_DITHER_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage; \
+ FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ FLAT_DITHER_ROW_SETUP(y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ unsigned long p = FLAT_DITHER(x); \
+ XMesaPutPixel(img, x, y, p); \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, depth-buffered, 8-bit PF_HPCR triangle.
+ */
+#define NAME flat_HPCR_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
+ GLubyte r = v2->color[0]; \
+ GLubyte g = v2->color[1]; \
+ GLubyte b = v2->color[2];
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = (PIXEL_TYPE) DITHER_HPCR(x, y, r, g, b); \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, depth-buffered, 8-bit PF_LOOKUP triangle.
+ */
+#define NAME flat_LOOKUP8_z_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ LOOKUP_SETUP; \
+ GLubyte r = v2->color[0]; \
+ GLubyte g = v2->color[1]; \
+ GLubyte b = v2->color[2]; \
+ GLubyte p = LOOKUP(r,g,b);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ const DEPTH_TYPE z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ pRow[i] = p; \
+ zRow[i] = z; \
+ } \
+ span.z += span.zStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, PF_TRUECOLOR triangle.
+ */
+#define NAME smooth_TRUECOLOR_triangle
+#define INTERP_RGB 1
+#define SETUP_CODE \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ unsigned long p; \
+ PACK_TRUECOLOR(p, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ XMesaPutPixel(img, x, y, p); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, PF_8A8B8G8R triangle.
+ */
+#define NAME smooth_8A8B8G8R_triangle
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ pRow[i] = PACK_8B8G8R(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue) ); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, PF_8A8R8G8B triangle.
+ */
+#define NAME smooth_8A8R8G8B_triangle
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ pRow[i] = PACK_8R8G8B(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue) ); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
+ */
+#define NAME smooth_8R8G8B_triangle
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ pRow[i] = PACK_8R8G8B(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue) ); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, PF_8R8G8B triangle.
+ */
+#define NAME smooth_8R8G8B24_triangle
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
+#define PIXEL_TYPE bgr_t
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ PIXEL_TYPE *pixel = pRow; \
+ for (i = 0; i < span.end; i++, pixel++) { \
+ pixel->r = FixedToInt(span.red); \
+ pixel->g = FixedToInt(span.green); \
+ pixel->b = FixedToInt(span.blue); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, PF_TRUEDITHER triangle.
+ */
+#define NAME smooth_TRUEDITHER_triangle
+#define INTERP_RGB 1
+#define SETUP_CODE \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ unsigned long p; \
+ PACK_TRUEDITHER(p, x, y, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ XMesaPutPixel(img, x, y, p ); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, PF_5R6G5B triangle.
+ */
+#define NAME smooth_5R6G5B_triangle
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ pRow[i] = (PIXEL_TYPE) PACK_5R6G5B(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
+ */
+#define NAME smooth_DITHER_5R6G5B_triangle
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ PACK_TRUEDITHER(pRow[i], x, y, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, 8-bit PF_DITHER triangle.
+ */
+#define NAME smooth_DITHER8_triangle
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ XDITHER_SETUP(y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ pRow[i] = (PIXEL_TYPE) XDITHER(x, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue) ); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, PF_DITHER triangle.
+ */
+#define NAME smooth_DITHER_triangle
+#define INTERP_RGB 1
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ XDITHER_SETUP(y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ unsigned long p = XDITHER(x, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue) ); \
+ XMesaPutPixel(img, x, y, p); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
+ */
+#define NAME smooth_LOOKUP8_triangle
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ LOOKUP_SETUP; \
+ for (i = 0; i < span.end; i++) { \
+ pRow[i] = LOOKUP(FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, smooth, NON-depth-buffered, 8-bit PF_HPCR triangle.
+ */
+#define NAME smooth_HPCR_triangle
+#define INTERP_RGB 1
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ pRow[i] = DITHER_HPCR(x, y, FixedToInt(span.red), \
+ FixedToInt(span.green), FixedToInt(span.blue)); \
+ span.red += span.redStep; \
+ span.green += span.greenStep; \
+ span.blue += span.blueStep; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, NON-depth-buffered, PF_TRUECOLOR triangle.
+ */
+#define NAME flat_TRUECOLOR_triangle
+#define SETUP_CODE \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage; \
+ unsigned long pixel; \
+ PACK_TRUECOLOR(pixel, v2->color[0], v2->color[1], v2->color[2]);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ XMesaPutPixel(img, x, y, pixel); \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, NON-depth-buffered, PF_8A8B8G8R triangle.
+ */
+#define NAME flat_8A8B8G8R_triangle
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ unsigned long p = PACK_8B8G8R( v2->color[0], \
+ v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ pRow[i] = (PIXEL_TYPE) p; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, NON-depth-buffered, PF_8A8R8G8B triangle.
+ */
+#define NAME flat_8A8R8G8B_triangle
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ unsigned long p = PACK_8R8G8B( v2->color[0], \
+ v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ pRow[i] = (PIXEL_TYPE) p; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, NON-depth-buffered, PF_8R8G8B triangle.
+ */
+#define NAME flat_8R8G8B_triangle
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR4(xrb, X, Y)
+#define PIXEL_TYPE GLuint
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ unsigned long p = PACK_8R8G8B( v2->color[0], \
+ v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ pRow[i] = (PIXEL_TYPE) p; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, NON-depth-buffered, PF_8R8G8B24 triangle.
+ */
+#define NAME flat_8R8G8B24_triangle
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR3(xrb, X, Y)
+#define PIXEL_TYPE bgr_t
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ const GLubyte *color = v2->color;
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ PIXEL_TYPE *pixel = pRow; \
+ for (i = 0; i < span.end; i++, pixel++) { \
+ pixel->r = color[RCOMP]; \
+ pixel->g = color[GCOMP]; \
+ pixel->b = color[BCOMP]; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, NON-depth-buffered, PF_TRUEDITHER triangle.
+ */
+#define NAME flat_TRUEDITHER_triangle
+#define SETUP_CODE \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage;
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ unsigned long p; \
+ PACK_TRUEDITHER(p, x, y, v2->color[0], \
+ v2->color[1], v2->color[2] ); \
+ XMesaPutPixel(img, x, y, p); \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, NON-depth-buffered, PF_5R6G5B triangle.
+ */
+#define NAME flat_5R6G5B_triangle
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ unsigned long p = PACK_5R6G5B( v2->color[0], \
+ v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ pRow[i] = (PIXEL_TYPE) p; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, NON-depth-buffered, PF_DITHER_5R6G5B triangle.
+ */
+#define NAME flat_DITHER_5R6G5B_triangle
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR2(xrb, X, Y)
+#define PIXEL_TYPE GLushort
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
+ const GLubyte *color = v2->color;
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ PACK_TRUEDITHER(pRow[i], x, y, color[RCOMP], \
+ color[GCOMP], color[BCOMP]); \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, NON-depth-buffered, 8-bit PF_DITHER triangle.
+ */
+#define NAME flat_DITHER8_triangle
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ FLAT_DITHER_ROW_SETUP(YFLIP(xrb, y)); \
+ for (i = 0; i < span.end; i++, x++) { \
+ pRow[i] = (PIXEL_TYPE) FLAT_DITHER(x); \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, NON-depth-buffered, PF_DITHER triangle.
+ */
+#define NAME flat_DITHER_triangle
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ XMesaImage *img = xrb->ximage; \
+ FLAT_DITHER_SETUP( v2->color[0], v2->color[1], v2->color[2] );
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ FLAT_DITHER_ROW_SETUP(y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ unsigned long p = FLAT_DITHER(x); \
+ XMesaPutPixel(img, x, y, p ); \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, NON-depth-buffered, 8-bit PF_HPCR triangle.
+ */
+#define NAME flat_HPCR_triangle
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ XMesaContext xmesa = XMESA_CONTEXT(ctx); \
+ GET_XRB(xrb); \
+ GLubyte r = v2->color[0]; \
+ GLubyte g = v2->color[1]; \
+ GLubyte b = v2->color[2];
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ GLint x = span.x, y = YFLIP(xrb, span.y); \
+ for (i = 0; i < span.end; i++, x++) { \
+ pRow[i] = (PIXEL_TYPE) DITHER_HPCR(x, y, r, g, b); \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+/*
+ * XImage, flat, NON-depth-buffered, 8-bit PF_LOOKUP triangle.
+ */
+#define NAME flat_LOOKUP8_triangle
+#define PIXEL_ADDRESS(X,Y) PIXEL_ADDR1(xrb, X, Y)
+#define PIXEL_TYPE GLubyte
+#define BYTES_PER_ROW (xrb->ximage->bytes_per_line)
+#define SETUP_CODE \
+ GET_XRB(xrb); \
+ LOOKUP_SETUP; \
+ GLubyte r = v2->color[0]; \
+ GLubyte g = v2->color[1]; \
+ GLubyte b = v2->color[2]; \
+ GLubyte p = LOOKUP(r,g,b);
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ for (i = 0; i < span.end; i++) { \
+ pRow[i] = (PIXEL_TYPE) p; \
+ }
+#include "swrast/s_tritemp.h"
+
+
+
+#ifdef DEBUG
+extern void _xmesa_print_triangle_func( swrast_tri_func triFunc );
+void _xmesa_print_triangle_func( swrast_tri_func triFunc )
+{
+ _mesa_printf("XMesa tri func = ");
+ if (triFunc ==smooth_TRUECOLOR_z_triangle)
+ _mesa_printf("smooth_TRUECOLOR_z_triangle\n");
+ else if (triFunc ==smooth_8A8B8G8R_z_triangle)
+ _mesa_printf("smooth_8A8B8G8R_z_triangle\n");
+ else if (triFunc ==smooth_8A8R8G8B_z_triangle)
+ _mesa_printf("smooth_8A8R8G8B_z_triangle\n");
+ else if (triFunc ==smooth_8R8G8B_z_triangle)
+ _mesa_printf("smooth_8R8G8B_z_triangle\n");
+ else if (triFunc ==smooth_8R8G8B24_z_triangle)
+ _mesa_printf("smooth_8R8G8B24_z_triangle\n");
+ else if (triFunc ==smooth_TRUEDITHER_z_triangle)
+ _mesa_printf("smooth_TRUEDITHER_z_triangle\n");
+ else if (triFunc ==smooth_5R6G5B_z_triangle)
+ _mesa_printf("smooth_5R6G5B_z_triangle\n");
+ else if (triFunc ==smooth_DITHER_5R6G5B_z_triangle)
+ _mesa_printf("smooth_DITHER_5R6G5B_z_triangle\n");
+ else if (triFunc ==smooth_HPCR_z_triangle)
+ _mesa_printf("smooth_HPCR_z_triangle\n");
+ else if (triFunc ==smooth_DITHER8_z_triangle)
+ _mesa_printf("smooth_DITHER8_z_triangle\n");
+ else if (triFunc ==smooth_LOOKUP8_z_triangle)
+ _mesa_printf("smooth_LOOKUP8_z_triangle\n");
+ else if (triFunc ==flat_TRUECOLOR_z_triangle)
+ _mesa_printf("flat_TRUECOLOR_z_triangle\n");
+ else if (triFunc ==flat_8A8B8G8R_z_triangle)
+ _mesa_printf("flat_8A8B8G8R_z_triangle\n");
+ else if (triFunc ==flat_8A8R8G8B_z_triangle)
+ _mesa_printf("flat_8A8R8G8B_z_triangle\n");
+ else if (triFunc ==flat_8R8G8B_z_triangle)
+ _mesa_printf("flat_8R8G8B_z_triangle\n");
+ else if (triFunc ==flat_8R8G8B24_z_triangle)
+ _mesa_printf("flat_8R8G8B24_z_triangle\n");
+ else if (triFunc ==flat_TRUEDITHER_z_triangle)
+ _mesa_printf("flat_TRUEDITHER_z_triangle\n");
+ else if (triFunc ==flat_5R6G5B_z_triangle)
+ _mesa_printf("flat_5R6G5B_z_triangle\n");
+ else if (triFunc ==flat_DITHER_5R6G5B_z_triangle)
+ _mesa_printf("flat_DITHER_5R6G5B_z_triangle\n");
+ else if (triFunc ==flat_HPCR_z_triangle)
+ _mesa_printf("flat_HPCR_z_triangle\n");
+ else if (triFunc ==flat_DITHER8_z_triangle)
+ _mesa_printf("flat_DITHER8_z_triangle\n");
+ else if (triFunc ==flat_LOOKUP8_z_triangle)
+ _mesa_printf("flat_LOOKUP8_z_triangle\n");
+ else if (triFunc ==smooth_TRUECOLOR_triangle)
+ _mesa_printf("smooth_TRUECOLOR_triangle\n");
+ else if (triFunc ==smooth_8A8B8G8R_triangle)
+ _mesa_printf("smooth_8A8B8G8R_triangle\n");
+ else if (triFunc ==smooth_8A8R8G8B_triangle)
+ _mesa_printf("smooth_8A8R8G8B_triangle\n");
+ else if (triFunc ==smooth_8R8G8B_triangle)
+ _mesa_printf("smooth_8R8G8B_triangle\n");
+ else if (triFunc ==smooth_8R8G8B24_triangle)
+ _mesa_printf("smooth_8R8G8B24_triangle\n");
+ else if (triFunc ==smooth_TRUEDITHER_triangle)
+ _mesa_printf("smooth_TRUEDITHER_triangle\n");
+ else if (triFunc ==smooth_5R6G5B_triangle)
+ _mesa_printf("smooth_5R6G5B_triangle\n");
+ else if (triFunc ==smooth_DITHER_5R6G5B_triangle)
+ _mesa_printf("smooth_DITHER_5R6G5B_triangle\n");
+ else if (triFunc ==smooth_HPCR_triangle)
+ _mesa_printf("smooth_HPCR_triangle\n");
+ else if (triFunc ==smooth_DITHER8_triangle)
+ _mesa_printf("smooth_DITHER8_triangle\n");
+ else if (triFunc ==smooth_LOOKUP8_triangle)
+ _mesa_printf("smooth_LOOKUP8_triangle\n");
+ else if (triFunc ==flat_TRUECOLOR_triangle)
+ _mesa_printf("flat_TRUECOLOR_triangle\n");
+ else if (triFunc ==flat_TRUEDITHER_triangle)
+ _mesa_printf("flat_TRUEDITHER_triangle\n");
+ else if (triFunc ==flat_8A8B8G8R_triangle)
+ _mesa_printf("flat_8A8B8G8R_triangle\n");
+ else if (triFunc ==flat_8A8R8G8B_triangle)
+ _mesa_printf("flat_8A8R8G8B_triangle\n");
+ else if (triFunc ==flat_8R8G8B_triangle)
+ _mesa_printf("flat_8R8G8B_triangle\n");
+ else if (triFunc ==flat_8R8G8B24_triangle)
+ _mesa_printf("flat_8R8G8B24_triangle\n");
+ else if (triFunc ==flat_5R6G5B_triangle)
+ _mesa_printf("flat_5R6G5B_triangle\n");
+ else if (triFunc ==flat_DITHER_5R6G5B_triangle)
+ _mesa_printf("flat_DITHER_5R6G5B_triangle\n");
+ else if (triFunc ==flat_HPCR_triangle)
+ _mesa_printf("flat_HPCR_triangle\n");
+ else if (triFunc ==flat_DITHER8_triangle)
+ _mesa_printf("flat_DITHER8_triangle\n");
+ else if (triFunc ==flat_LOOKUP8_triangle)
+ _mesa_printf("flat_LOOKUP8_triangle\n");
+ else
+ _mesa_printf("???\n");
+}
+#endif
+
+
+#ifdef DEBUG
+
+/* record the current triangle function name */
+static const char *triFuncName = NULL;
+
+#define USE(triFunc) \
+do { \
+ triFuncName = #triFunc; \
+ return triFunc; \
+} while (0)
+
+#else
+
+#define USE(triFunc) return triFunc
+
+#endif
+
+
+static swrast_tri_func get_triangle_func( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ XMesaContext xmesa = XMESA_CONTEXT(ctx);
+ int depth = GET_VISUAL_DEPTH(xmesa->xm_visual);
+ GET_XRB(xrb);
+
+#ifdef DEBUG
+ triFuncName = NULL;
+#endif
+
+ if ((ctx->DrawBuffer->_ColorDrawBufferMask[0]
+ & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT)) == 0)
+ return (swrast_tri_func) NULL;
+ if (ctx->RenderMode != GL_RENDER) return (swrast_tri_func) NULL;
+ if (ctx->Polygon.SmoothFlag) return (swrast_tri_func) NULL;
+ if (ctx->Texture._EnabledUnits) return (swrast_tri_func) NULL;
+ if (swrast->_RasterMask & MULTI_DRAW_BIT) return (swrast_tri_func) NULL;
+ if (ctx->Polygon.CullFlag &&
+ ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
+ return (swrast_tri_func) NULL;
+
+ if (xrb->ximage) {
+ if ( ctx->Light.ShadeModel==GL_SMOOTH
+ && swrast->_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:
+ USE(smooth_TRUECOLOR_z_triangle);
+ case PF_8A8B8G8R:
+ USE(smooth_8A8B8G8R_z_triangle);
+ case PF_8A8R8G8B:
+ USE(smooth_8A8R8G8B_z_triangle);
+ case PF_8R8G8B:
+ USE(smooth_8R8G8B_z_triangle);
+ case PF_8R8G8B24:
+ USE(smooth_8R8G8B24_z_triangle);
+ case PF_Dither_True:
+ USE(smooth_TRUEDITHER_z_triangle);
+ case PF_5R6G5B:
+ USE(smooth_5R6G5B_z_triangle);
+ case PF_Dither_5R6G5B:
+ USE(smooth_DITHER_5R6G5B_z_triangle);
+ case PF_HPCR:
+ USE(smooth_HPCR_z_triangle);
+ case PF_Dither:
+ if (depth == 8)
+ USE(smooth_DITHER8_z_triangle);
+ else
+ USE(smooth_DITHER_z_triangle);
+ case PF_Lookup:
+ if (depth == 8)
+ USE(smooth_LOOKUP8_z_triangle);
+ else
+ return (swrast_tri_func) NULL;
+ default:
+ return (swrast_tri_func) NULL;
+ }
+ }
+ if ( ctx->Light.ShadeModel==GL_FLAT
+ && swrast->_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:
+ USE(flat_TRUECOLOR_z_triangle);
+ case PF_8A8B8G8R:
+ USE(flat_8A8B8G8R_z_triangle);
+ case PF_8A8R8G8B:
+ USE(flat_8A8R8G8B_z_triangle);
+ case PF_8R8G8B:
+ USE(flat_8R8G8B_z_triangle);
+ case PF_8R8G8B24:
+ USE(flat_8R8G8B24_z_triangle);
+ case PF_Dither_True:
+ USE(flat_TRUEDITHER_z_triangle);
+ case PF_5R6G5B:
+ USE(flat_5R6G5B_z_triangle);
+ case PF_Dither_5R6G5B:
+ USE(flat_DITHER_5R6G5B_z_triangle);
+ case PF_HPCR:
+ USE(flat_HPCR_z_triangle);
+ case PF_Dither:
+ if (depth == 8)
+ USE(flat_DITHER8_z_triangle);
+ else
+ USE(flat_DITHER_z_triangle);
+ case PF_Lookup:
+ if (depth == 8)
+ USE(flat_LOOKUP8_z_triangle);
+ else
+ return (swrast_tri_func) NULL;
+ default:
+ return (swrast_tri_func) NULL;
+ }
+ }
+ if ( swrast->_RasterMask==0 /* no depth test */
+ && ctx->Light.ShadeModel==GL_SMOOTH
+ && ctx->Polygon.StippleFlag==GL_FALSE) {
+ switch (xmesa->pixelformat) {
+ case PF_Truecolor:
+ USE(smooth_TRUECOLOR_triangle);
+ case PF_8A8B8G8R:
+ USE(smooth_8A8B8G8R_triangle);
+ case PF_8A8R8G8B:
+ USE(smooth_8A8R8G8B_triangle);
+ case PF_8R8G8B:
+ USE(smooth_8R8G8B_triangle);
+ case PF_8R8G8B24:
+ USE(smooth_8R8G8B24_triangle);
+ case PF_Dither_True:
+ USE(smooth_TRUEDITHER_triangle);
+ case PF_5R6G5B:
+ USE(smooth_5R6G5B_triangle);
+ case PF_Dither_5R6G5B:
+ USE(smooth_DITHER_5R6G5B_triangle);
+ case PF_HPCR:
+ USE(smooth_HPCR_triangle);
+ case PF_Dither:
+ if (depth == 8)
+ USE(smooth_DITHER8_triangle);
+ else
+ USE(smooth_DITHER_triangle);
+ case PF_Lookup:
+ if (depth == 8)
+ USE(smooth_LOOKUP8_triangle);
+ else
+ return (swrast_tri_func) NULL;
+ default:
+ return (swrast_tri_func) NULL;
+ }
+ }
+
+ if ( swrast->_RasterMask==0 /* no depth test */
+ && ctx->Light.ShadeModel==GL_FLAT
+ && ctx->Polygon.StippleFlag==GL_FALSE) {
+ switch (xmesa->pixelformat) {
+ case PF_Truecolor:
+ USE(flat_TRUECOLOR_triangle);
+ case PF_Dither_True:
+ USE(flat_TRUEDITHER_triangle);
+ case PF_8A8B8G8R:
+ USE(flat_8A8B8G8R_triangle);
+ case PF_8A8R8G8B:
+ USE(flat_8A8R8G8B_triangle);
+ case PF_8R8G8B:
+ USE(flat_8R8G8B_triangle);
+ case PF_8R8G8B24:
+ USE(flat_8R8G8B24_triangle);
+ case PF_5R6G5B:
+ USE(flat_5R6G5B_triangle);
+ case PF_Dither_5R6G5B:
+ USE(flat_DITHER_5R6G5B_triangle);
+ case PF_HPCR:
+ USE(flat_HPCR_triangle);
+ case PF_Dither:
+ if (depth == 8)
+ USE(flat_DITHER8_triangle);
+ else
+ USE(flat_DITHER_triangle);
+ case PF_Lookup:
+ if (depth == 8)
+ USE(flat_LOOKUP8_triangle);
+ else
+ return (swrast_tri_func) NULL;
+ default:
+ return (swrast_tri_func) NULL;
+ }
+ }
+
+ return (swrast_tri_func) NULL;
+ }
+ else {
+ /* draw to pixmap */
+ return (swrast_tri_func) NULL;
+ }
+}
+
+
+/* Override for the swrast tri-selection function. Try to use one
+ * of our internal tri functions, otherwise fall back to the
+ * standard swrast functions.
+ */
+void xmesa_choose_triangle( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ if (!(swrast->Triangle = get_triangle_func( ctx )))
+ _swrast_choose_triangle( ctx );
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/drivers/x11/xmesaP.h b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xmesaP.h
new file mode 100644
index 000000000..26255ae56
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/drivers/x11/xmesaP.h
@@ -0,0 +1,555 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef XMESAP_H
+#define XMESAP_H
+
+
+#ifdef XFree86Server
+# include "GL/xf86glx.h"
+# include "xf86glx_util.h"
+#elif defined(USE_XSHM)
+# include <X11/extensions/XShm.h>
+#endif
+#include "GL/xmesa.h"
+#include "mtypes.h"
+#if defined(FX)
+#include "GL/fxmesa.h"
+#include "../glide/fxdrv.h"
+#endif
+
+
+extern _glthread_Mutex _xmesa_lock;
+
+
+/* for PF_8R8G8B24 pixel format */
+typedef struct {
+ GLubyte b;
+ GLubyte g;
+ GLubyte r;
+} bgr_t;
+
+
+struct xmesa_renderbuffer;
+
+
+/* Function pointer for clearing color buffers */
+typedef void (*ClearFunc)( GLcontext *ctx, struct xmesa_renderbuffer *xrb,
+ GLboolean all, GLint x, GLint y,
+ GLint width, GLint height );
+
+
+
+
+/** Framebuffer pixel formats */
+enum pixel_format {
+ PF_Index, /**< Color Index mode */
+ PF_Truecolor, /**< TrueColor or DirectColor, any depth */
+ PF_Dither_True, /**< TrueColor with dithering */
+ PF_8A8B8G8R, /**< 32-bit TrueColor: 8-A, 8-B, 8-G, 8-R */
+ PF_8R8G8B, /**< 32-bit TrueColor: 8-R, 8-G, 8-B bits */
+ PF_5R6G5B, /**< 16-bit TrueColor: 5-R, 6-G, 5-B bits */
+ PF_Dither, /**< Color-mapped RGB with dither */
+ PF_Lookup, /**< Color-mapped RGB without dither */
+ PF_HPCR, /**< HP Color Recovery (ad@lms.be 30/08/95) */
+ PF_1Bit, /**< monochrome dithering of RGB */
+ PF_Grayscale, /**< Grayscale or StaticGray */
+ PF_8R8G8B24, /**< 24-bit TrueColor: 8-R, 8-G, 8-B bits */
+ PF_Dither_5R6G5B, /**< 16-bit dithered TrueColor: 5-R, 6-G, 5-B */
+ PF_8A8R8G8B /**< 32-bit TrueColor: 8-A, 8-R, 8-G, 8-B */
+};
+
+
+/*
+ * "Derived" from GLvisual. Basically corresponds to an XVisualInfo.
+ */
+struct xmesa_visual {
+ GLvisual mesa_visual; /* Device independent visual parameters */
+ XMesaDisplay *display; /* The X11 display */
+#ifdef XFree86Server
+ GLint ColormapEntries;
+ GLint nplanes;
+#else
+ XMesaVisualInfo visinfo; /* X's visual info (pointer to private copy) */
+ XVisualInfo *vishandle; /* Only used in fakeglx.c */
+#endif
+ GLint BitsPerPixel; /* True bits per pixel for XImages */
+
+ GLboolean ximage_flag; /* Use XImage for back buffer (not pixmap)? */
+
+ enum pixel_format dithered_pf; /* Pixel format when dithering */
+ enum pixel_format undithered_pf;/* Pixel format when not dithering */
+
+ GLfloat RedGamma; /* Gamma values, 1.0 is default */
+ GLfloat GreenGamma;
+ GLfloat BlueGamma;
+
+ /* For PF_TRUECOLOR */
+ GLint rshift, gshift, bshift;/* Pixel color component shifts */
+ GLubyte Kernel[16]; /* Dither kernel */
+ unsigned long RtoPixel[512]; /* RGB to pixel conversion */
+ unsigned long GtoPixel[512];
+ unsigned long BtoPixel[512];
+ GLubyte PixelToR[256]; /* Pixel to RGB conversion */
+ GLubyte PixelToG[256];
+ GLubyte PixelToB[256];
+
+ /* For PF_HPCR */
+ short hpcr_rgbTbl[3][256];
+ GLboolean hpcr_clear_flag;
+ GLubyte hpcr_clear_ximage_pattern[2][16];
+ XMesaImage *hpcr_clear_ximage;
+ XMesaPixmap hpcr_clear_pixmap;
+
+ /* For PF_1BIT */
+ int bitFlip;
+};
+
+
+/*
+ * "Derived" from __GLcontextRec. Basically corresponds to a GLXContext.
+ */
+struct xmesa_context {
+ GLcontext mesa; /* the core library context (containment) */
+ XMesaVisual xm_visual; /* Describes the buffers */
+ XMesaBuffer xm_buffer; /* current span/point/line/triangle buffer */
+
+ XMesaDisplay *display; /* == xm_visual->display */
+ GLboolean swapbytes; /* Host byte order != display byte order? */
+ GLboolean direct; /* Direct rendering context? */
+
+ enum pixel_format pixelformat;
+
+ GLubyte clearcolor[4]; /* current clearing color */
+ unsigned long clearpixel; /* current clearing pixel value */
+};
+
+
+
+typedef enum {
+ WINDOW, /* An X window */
+ GLXWINDOW, /* GLX window */
+ PIXMAP, /* GLX pixmap */
+ PBUFFER /* GLX Pbuffer */
+} BufferType;
+
+
+/**
+ * An xmesa_renderbuffer represents the back or front color buffer.
+ * For the front color buffer:
+ * <drawable> is the X window
+ * For the back color buffer:
+ * Either <ximage> or <pixmap> will be used, never both.
+ * In any case, <drawable> always equals <pixmap>.
+ * For stand-alone Mesa, we could merge <drawable> and <pixmap> into one
+ * field. We don't do that for the server-side GLcore module because
+ * pixmaps and drawables are different and we'd need a bunch of casts.
+ */
+struct xmesa_renderbuffer
+{
+ struct gl_renderbuffer Base; /* Base class */
+
+ XMesaDrawable drawable; /* Usually the X window ID */
+ XMesaPixmap pixmap; /* Back color buffer */
+ XMesaImage *ximage; /* The back buffer, if not using a Pixmap */
+
+ GLubyte *origin1; /* used for PIXEL_ADDR1 macro */
+ GLint width1;
+ GLushort *origin2; /* used for PIXEL_ADDR2 macro */
+ GLint width2;
+ GLubyte *origin3; /* used for PIXEL_ADDR3 macro */
+ GLint width3;
+ GLuint *origin4; /* used for PIXEL_ADDR4 macro */
+ GLint width4;
+
+ GLint bottom; /* used for FLIP macro */
+
+ ClearFunc clearFunc;
+};
+
+
+/*
+ * "Derived" from GLframebuffer. Basically corresponds to a GLXDrawable.
+ */
+struct xmesa_buffer {
+ GLframebuffer mesa_buffer; /* depth, stencil, accum, etc buffers */
+ /* This MUST BE FIRST! */
+ GLboolean wasCurrent; /* was ever the current buffer? */
+ XMesaVisual xm_visual; /* the X/Mesa visual */
+
+ XMesaDisplay *display;
+ BufferType type; /* window, pixmap, pbuffer or glxwindow */
+
+ struct xmesa_renderbuffer *frontxrb; /* front color renderbuffer */
+ struct xmesa_renderbuffer *backxrb; /* back color renderbuffer */
+
+ XMesaColormap cmap; /* the X colormap */
+
+ unsigned long selectedEvents;/* for pbuffers only */
+
+ GLint db_state; /* 0 = single buffered */
+ /* BACK_PIXMAP = use Pixmap for back buffer */
+ /* BACK_XIMAGE = use XImage for back buffer */
+
+#ifndef XFree86Server
+ GLuint shm; /* X Shared Memory extension status: */
+ /* 0 = not available */
+ /* 1 = XImage support available */
+ /* 2 = Pixmap support available too */
+#ifdef USE_XSHM
+ XShmSegmentInfo shminfo;
+#endif
+#endif
+
+ XMesaImage *rowimage; /* Used for optimized span writing */
+ XMesaPixmap stipple_pixmap; /* For polygon stippling */
+ XMesaGC stipple_gc; /* For polygon stippling */
+
+ XMesaGC gc; /* scratch GC for span, line, tri drawing */
+ XMesaGC cleargc; /* GC for clearing the color buffer */
+ XMesaGC swapgc; /* GC for swapping the color buffers */
+
+ /* The following are here instead of in the XMesaVisual
+ * because they depend on the window's colormap.
+ */
+
+ /* For PF_DITHER, PF_LOOKUP, PF_GRAYSCALE */
+ unsigned long color_table[576]; /* RGB -> pixel value */
+
+ /* For PF_DITHER, PF_LOOKUP, PF_GRAYSCALE */
+ GLubyte pixel_to_r[65536]; /* pixel value -> red */
+ GLubyte pixel_to_g[65536]; /* pixel value -> green */
+ GLubyte pixel_to_b[65536]; /* pixel value -> blue */
+
+ /* Used to do XAllocColor/XFreeColors accounting: */
+ int num_alloced;
+#if defined(XFree86Server)
+ Pixel alloced_colors[256];
+#else
+ unsigned long alloced_colors[256];
+#endif
+
+#if defined( FX )
+ /* For 3Dfx Glide only */
+ GLboolean FXisHackUsable; /* Can we render into window? */
+ GLboolean FXwindowHack; /* Are we rendering into a window? */
+ fxMesaContext FXctx;
+#endif
+
+ struct xmesa_buffer *Next; /* Linked list pointer: */
+};
+
+
+/* Values for xmesa->db_state: */
+#define FRONT_PIXMAP 1
+#define BACK_PIXMAP 2
+#define BACK_XIMAGE 4
+
+
+/*
+ * If pixelformat==PF_TRUECOLOR:
+ */
+#define PACK_TRUECOLOR( PIXEL, R, G, B ) \
+ PIXEL = xmesa->xm_visual->RtoPixel[R] \
+ | xmesa->xm_visual->GtoPixel[G] \
+ | xmesa->xm_visual->BtoPixel[B]; \
+
+
+/*
+ * If pixelformat==PF_TRUEDITHER:
+ */
+#define PACK_TRUEDITHER( PIXEL, X, Y, R, G, B ) \
+{ \
+ int d = xmesa->xm_visual->Kernel[((X)&3) | (((Y)&3)<<2)]; \
+ PIXEL = xmesa->xm_visual->RtoPixel[(R)+d] \
+ | xmesa->xm_visual->GtoPixel[(G)+d] \
+ | xmesa->xm_visual->BtoPixel[(B)+d]; \
+}
+
+
+
+/*
+ * If pixelformat==PF_8A8B8G8R:
+ */
+#define PACK_8A8B8G8R( R, G, B, A ) \
+ ( ((A) << 24) | ((B) << 16) | ((G) << 8) | (R) )
+
+
+/*
+ * Like PACK_8A8B8G8R() but don't use alpha. This is usually an acceptable
+ * shortcut.
+ */
+#define PACK_8B8G8R( R, G, B ) ( ((B) << 16) | ((G) << 8) | (R) )
+
+
+
+/*
+ * If pixelformat==PF_8R8G8B:
+ */
+#define PACK_8R8G8B( R, G, B) ( ((R) << 16) | ((G) << 8) | (B) )
+
+
+/*
+ * If pixelformat==PF_5R6G5B:
+ */
+#define PACK_5R6G5B( R, G, B) ( (((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | ((B) >> 3) )
+
+
+/*
+ * If pixelformat==PF_8A8R8G8B:
+ */
+#define PACK_8A8R8G8B( R, G, B, A ) \
+ ( ((A) << 24) | ((R) << 16) | ((G) << 8) | (B) )
+
+
+
+/*
+ * If pixelformat==PF_DITHER:
+ *
+ * Improved 8-bit RGB dithering code contributed by Bob Mercier
+ * (mercier@hollywood.cinenet.net). Thanks Bob!
+ */
+#ifdef DITHER666
+# define DITH_R 6
+# define DITH_G 6
+# define DITH_B 6
+# define DITH_MIX(r,g,b) (((r) * DITH_G + (g)) * DITH_B + (b))
+#else
+# define DITH_R 5
+# define DITH_G 9
+# define DITH_B 5
+# define DITH_MIX(r,g,b) (((g) << 6) | ((b) << 3) | (r))
+#endif
+#define DITH_DX 4
+#define DITH_DY 4
+#define DITH_N (DITH_DX * DITH_DY)
+
+#define _dither(C, c, d) (((unsigned)((DITH_N * (C - 1) + 1) * c + d)) >> 12)
+
+#define MAXC 256
+extern const int xmesa_kernel8[DITH_DY * DITH_DX];
+
+/* Dither for random X,Y */
+#define DITHER_SETUP \
+ int __d; \
+ unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table;
+
+#define DITHER( X, Y, R, G, B ) \
+ (__d = xmesa_kernel8[(((Y)&3)<<2) | ((X)&3)], \
+ ctable[DITH_MIX(_dither(DITH_R, (R), __d), \
+ _dither(DITH_G, (G), __d), \
+ _dither(DITH_B, (B), __d))])
+
+/* Dither for random X, fixed Y */
+#define XDITHER_SETUP(Y) \
+ int __d; \
+ unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table; \
+ const int *kernel = &xmesa_kernel8[ ((Y)&3) << 2 ];
+
+#define XDITHER( X, R, G, B ) \
+ (__d = kernel[(X)&3], \
+ ctable[DITH_MIX(_dither(DITH_R, (R), __d), \
+ _dither(DITH_G, (G), __d), \
+ _dither(DITH_B, (B), __d))])
+
+
+
+/*
+ * Dithering for flat-shaded triangles. Precompute all 16 possible
+ * pixel values given the triangle's RGB color. Contributed by Martin Shenk.
+ */
+#define FLAT_DITHER_SETUP( R, G, B ) \
+ GLushort ditherValues[16]; \
+ { \
+ unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table; \
+ int msdr = (DITH_N*((DITH_R)-1)+1) * (R); \
+ int msdg = (DITH_N*((DITH_G)-1)+1) * (G); \
+ int msdb = (DITH_N*((DITH_B)-1)+1) * (B); \
+ int i; \
+ for (i=0;i<16;i++) { \
+ int k = xmesa_kernel8[i]; \
+ int j = DITH_MIX( (msdr+k)>>12, (msdg+k)>>12, (msdb+k)>>12 );\
+ ditherValues[i] = (GLushort) ctable[j]; \
+ } \
+ }
+
+#define FLAT_DITHER_ROW_SETUP(Y) \
+ GLushort *ditherRow = ditherValues + ( ((Y)&3) << 2);
+
+#define FLAT_DITHER(X) ditherRow[(X)&3]
+
+
+
+/*
+ * If pixelformat==PF_LOOKUP:
+ */
+#define _dither_lookup(C, c) (((unsigned)((DITH_N * (C - 1) + 1) * c)) >> 12)
+
+#define LOOKUP_SETUP \
+ unsigned long *ctable = XMESA_BUFFER(ctx->DrawBuffer)->color_table
+
+#define LOOKUP( R, G, B ) \
+ ctable[DITH_MIX(_dither_lookup(DITH_R, (R)), \
+ _dither_lookup(DITH_G, (G)), \
+ _dither_lookup(DITH_B, (B)))]
+
+
+
+/*
+ * If pixelformat==PF_HPCR:
+ *
+ * HP Color Recovery dithering (ad@lms.be 30/08/95)
+ * HP has on it's 8-bit 700-series computers, a feature called
+ * 'Color Recovery'. This allows near 24-bit output (so they say).
+ * It is enabled by selecting the 8-bit TrueColor visual AND
+ * corresponding colormap (see tkInitWindow) AND doing some special
+ * dither.
+ */
+extern const short xmesa_HPCR_DRGB[3][2][16];
+
+#define DITHER_HPCR( X, Y, R, G, B ) \
+ ( ((xmesa->xm_visual->hpcr_rgbTbl[0][R] + xmesa_HPCR_DRGB[0][(Y)&1][(X)&15]) & 0xE0) \
+ |(((xmesa->xm_visual->hpcr_rgbTbl[1][G] + xmesa_HPCR_DRGB[1][(Y)&1][(X)&15]) & 0xE0)>>3) \
+ | ((xmesa->xm_visual->hpcr_rgbTbl[2][B] + xmesa_HPCR_DRGB[2][(Y)&1][(X)&15])>>6) \
+ )
+
+
+
+/*
+ * If pixelformat==PF_1BIT:
+ */
+extern const int xmesa_kernel1[16];
+
+#define SETUP_1BIT int bitFlip = xmesa->xm_visual->bitFlip
+#define DITHER_1BIT( X, Y, R, G, B ) \
+ (( ((int)(R)+(int)(G)+(int)(B)) > xmesa_kernel1[(((Y)&3) << 2) | ((X)&3)] ) ^ bitFlip)
+
+
+
+/*
+ * If pixelformat==PF_GRAYSCALE:
+ */
+#define GRAY_RGB( R, G, B ) XMESA_BUFFER(ctx->DrawBuffer)->color_table[((R) + (G) + (B))/3]
+
+
+
+/*
+ * Converts a GL window Y coord to an X window Y coord:
+ */
+#define YFLIP(XRB, Y) ((XRB)->bottom - (Y))
+
+
+/*
+ * Return the address of a 1, 2 or 4-byte pixel in the buffer's XImage:
+ * X==0 is left, Y==0 is bottom.
+ */
+#define PIXEL_ADDR1(XRB, X, Y) \
+ ( (XRB)->origin1 - (Y) * (XRB)->width1 + (X) )
+
+#define PIXEL_ADDR2(XRB, X, Y) \
+ ( (XRB)->origin2 - (Y) * (XRB)->width2 + (X) )
+
+#define PIXEL_ADDR3(XRB, X, Y) \
+ ( (bgr_t *) ( (XRB)->origin3 - (Y) * (XRB)->width3 + 3 * (X) ))
+
+#define PIXEL_ADDR4(XRB, X, Y) \
+ ( (XRB)->origin4 - (Y) * (XRB)->width4 + (X) )
+
+
+
+
+/*
+ * Return pointer to XMesaContext corresponding to a Mesa GLcontext.
+ * Since we're using structure containment, it's just a cast!.
+ */
+#define XMESA_CONTEXT(MESACTX) ((XMesaContext) (MESACTX))
+
+/*
+ * Return pointer to XMesaBuffer corresponding to a Mesa GLframebuffer.
+ * Since we're using structure containment, it's just a cast!.
+ */
+#define XMESA_BUFFER(MESABUFF) ((XMesaBuffer) (MESABUFF))
+
+
+
+/*
+ * External functions:
+ */
+
+extern struct xmesa_renderbuffer *
+xmesa_new_renderbuffer(GLcontext *ctx, GLuint name, GLboolean rgbMode);
+
+extern unsigned long
+xmesa_color_to_pixel( GLcontext *ctx,
+ GLubyte r, GLubyte g, GLubyte b, GLubyte a,
+ GLuint pixelFormat );
+
+extern void
+xmesa_alloc_back_buffer(XMesaBuffer b, GLuint width, GLuint height);
+
+extern void xmesa_resize_buffers(GLcontext *ctx, GLframebuffer *buffer,
+ GLuint width, GLuint height);
+
+extern void xmesa_init_driver_functions( XMesaVisual xmvisual,
+ struct dd_function_table *driver );
+
+extern void xmesa_update_state( GLcontext *ctx, GLuint new_state );
+
+extern void
+xmesa_set_renderbuffer_funcs(struct xmesa_renderbuffer *xrb,
+ enum pixel_format pixelformat, GLint depth);
+
+
+/* Plugged into the software rasterizer. Try to use internal
+ * swrast-style point, line and triangle functions.
+ */
+extern void xmesa_choose_point( GLcontext *ctx );
+extern void xmesa_choose_line( GLcontext *ctx );
+extern void xmesa_choose_triangle( GLcontext *ctx );
+
+
+extern void xmesa_register_swrast_functions( GLcontext *ctx );
+
+
+
+/* XXX this is a hack to implement shared display lists with 3Dfx */
+extern XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v,
+ XMesaWindow w,
+ XMesaContext c );
+
+/*
+ * These are the extra routines required for integration with XFree86.
+ * None of these routines should be user visible. -KEM
+ */
+extern void XMesaSetVisualDisplay( XMesaDisplay *dpy, XMesaVisual v );
+extern GLboolean XMesaForceCurrent(XMesaContext c);
+extern GLboolean XMesaLoseCurrent(XMesaContext c);
+extern void XMesaReset( void );
+
+
+#define SWTC 0 /* SW texture compression */
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/.cvsignore b/nx-X11/extras/Mesa/src/mesa/glapi/.cvsignore
new file mode 100644
index 000000000..e706bc23c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/.cvsignore
@@ -0,0 +1,11 @@
+.cvsignore
+glX_proto_common.pyo
+glX_proto_common.pyc
+typeexpr.pyo
+typeexpr.pyc
+license.pyo
+license.pyc
+gl_XML.pyo
+gl_XML.pyc
+glX_XML.pyo
+glX_XML.pyc
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/EXT_framebuffer_object.xml b/nx-X11/extras/Mesa/src/mesa/glapi/EXT_framebuffer_object.xml
new file mode 100644
index 000000000..5057bdc8b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/EXT_framebuffer_object.xml
@@ -0,0 +1,188 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<OpenGLAPI>
+<category name="GL_EXT_framebuffer_object" number="310">
+ <enum name="FRAMEBUFFER_EXT" value="0x8D40"/>
+ <enum name="RENDERBUFFER_EXT" value="0x8D41"/>
+ <enum name="RENDERBUFFER_WIDTH_EXT" value="0x8D42"/>
+ <enum name="RENDERBUFFER_HEIGHT_EXT" value="0x8D43"/>
+ <enum name="RENDERBUFFER_INTERNAL_FORMAT_EXT" value="0x8D44"/>
+ <enum name="STENCIL_INDEX_EXT" value="0x8D45"/>
+ <enum name="STENCIL_INDEX1_EXT" value="0x8D46"/>
+ <enum name="STENCIL_INDEX4_EXT" value="0x8D47"/>
+ <enum name="STENCIL_INDEX8_EXT" value="0x8D48"/>
+ <enum name="STENCIL_INDEX16_EXT" value="0x8D49"/>
+
+ <enum name="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT" count="1" value="0x8CD0">
+ <size name="GetFramebufferAttachmentParameterivEXT" mode="get"/>
+ </enum>
+ <enum name="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT" count="1" value="0x8CD1">
+ <size name="GetFramebufferAttachmentParameterivEXT" mode="get"/>
+ </enum>
+ <enum name="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT" count="1" value="0x8CD2">
+ <size name="GetFramebufferAttachmentParameterivEXT" mode="get"/>
+ </enum>
+ <enum name="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT" count="1" value="0x8CD3">
+ <size name="GetFramebufferAttachmentParameterivEXT" mode="get"/>
+ </enum>
+ <enum name="FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT" count="1" value="0x8CD4">
+ <size name="GetFramebufferAttachmentParameterivEXT" mode="get"/>
+ </enum>
+
+ <enum name="COLOR_ATTACHMENT0_EXT" value="0x8CE0"/>
+ <enum name="COLOR_ATTACHMENT1_EXT" value="0x8CE1"/>
+ <enum name="COLOR_ATTACHMENT2_EXT" value="0x8CE2"/>
+ <enum name="COLOR_ATTACHMENT3_EXT" value="0x8CE3"/>
+ <enum name="COLOR_ATTACHMENT4_EXT" value="0x8CE4"/>
+ <enum name="COLOR_ATTACHMENT5_EXT" value="0x8CE5"/>
+ <enum name="COLOR_ATTACHMENT6_EXT" value="0x8CE6"/>
+ <enum name="COLOR_ATTACHMENT7_EXT" value="0x8CE7"/>
+ <enum name="COLOR_ATTACHMENT8_EXT" value="0x8CE8"/>
+ <enum name="COLOR_ATTACHMENT9_EXT" value="0x8CE9"/>
+ <enum name="COLOR_ATTACHMENT10_EXT" value="0x8CEA"/>
+ <enum name="COLOR_ATTACHMENT11_EXT" value="0x8CEB"/>
+ <enum name="COLOR_ATTACHMENT12_EXT" value="0x8CEC"/>
+ <enum name="COLOR_ATTACHMENT13_EXT" value="0x8CED"/>
+ <enum name="COLOR_ATTACHMENT14_EXT" value="0x8CEE"/>
+ <enum name="COLOR_ATTACHMENT15_EXT" value="0x8CEF"/>
+ <enum name="DEPTH_ATTACHMENT_EXT" value="0x8D00"/>
+ <enum name="STENCIL_ATTACHMENT_EXT" value="0x8D20"/>
+
+ <enum name="FRAMEBUFFER_COMPLETE_EXT" value="0x8CD5"/>
+ <enum name="FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT" value="0x8CD6"/>
+ <enum name="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT" value="0x8CD7"/>
+ <enum name="FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT" value="0x8CD8"/>
+ <enum name="FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT" value="0x8CD9"/>
+ <enum name="FRAMEBUFFER_INCOMPLETE_FORMATS_EXT" value="0x8CDA"/>
+ <enum name="FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT" value="0x8CDB"/>
+ <enum name="FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT" value="0x8CDC"/>
+ <enum name="FRAMEBUFFER_UNSUPPORTED_EXT" value="0x8CDD"/>
+ <enum name="FRAMEBUFFER_STATUS_ERROR_EXT" value="0x8CDE"/>
+
+ <enum name="FRAMEBUFFER_BINDING_EXT" value="0x8CA6"/>
+ <enum name="RENDERBUFFER_BINDING_EXT" value="0x8CA7"/>
+ <enum name="MAX_COLOR_ATTACHMENTS_EXT" value="0x8CDF"/>
+ <enum name="MAX_RENDERBUFFER_SIZE_EXT" value="0x84E8"/>
+
+ <enum name="INVALID_FRAMEBUFFER_OPERATION_EXT" value="0x0506"/>
+
+ <function name="IsRenderbufferEXT" offset="796">
+ <param name="renderbuffer" type="GLuint"/>
+ <return type="GLboolean"/>
+ <glx vendorpriv="1422"/>
+ </function>
+
+ <function name="BindRenderbufferEXT" offset="797">
+ <param name="target" type="GLenum"/>
+ <param name="renderbuffer" type="GLuint"/>
+ <glx rop="4316"/>
+ </function>
+
+ <function name="DeleteRenderbuffersEXT" offset="798">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="renderbuffers" type="const GLuint *" count="n"/>
+ <glx rop="4317"/>
+ </function>
+
+ <function name="GenRenderbuffersEXT" offset="799">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="renderbuffers" type="GLuint *" count="n" output="true"/>
+ <glx vendorpriv="1423" always_array="true"/>
+ </function>
+
+ <function name="RenderbufferStorageEXT" offset="800">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <glx rop="4318"/>
+ </function>
+
+ <function name="GetRenderbufferParameterivEXT" offset="801">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true"/>
+ <glx vendorpriv="1424"/>
+ </function>
+
+ <function name="IsFramebufferEXT" offset="802">
+ <param name="framebuffer" type="GLuint"/>
+ <return type="GLboolean"/>
+ <glx vendorpriv="1425"/>
+ </function>
+
+ <function name="BindFramebufferEXT" offset="803">
+ <param name="target" type="GLenum"/>
+ <param name="framebuffer" type="GLuint"/>
+ <glx rop="4319"/>
+ </function>
+
+ <function name="DeleteFramebuffersEXT" offset="804">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="framebuffers" type="const GLuint *" count="n"/>
+ <glx rop="4320"/>
+ </function>
+
+ <function name="GenFramebuffersEXT" offset="805">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="framebuffers" type="GLuint *" count="n" output="true"/>
+ <glx vendorpriv="1426" always_array="true"/>
+ </function>
+
+ <function name="CheckFramebufferStatusEXT" offset="806">
+ <param name="target" type="GLenum"/>
+ <return type="GLenum"/>
+ <glx vendorpriv="1427"/>
+ </function>
+
+ <function name="FramebufferTexture1DEXT" offset="807">
+ <param name="target" type="GLenum"/>
+ <param name="attachment" type="GLenum"/>
+ <param name="textarget" type="GLenum"/>
+ <param name="texture" type="GLuint"/>
+ <param name="level" type="GLint"/>
+ <glx rop="4321"/>
+ </function>
+
+ <function name="FramebufferTexture2DEXT" offset="808">
+ <param name="target" type="GLenum"/>
+ <param name="attachment" type="GLenum"/>
+ <param name="textarget" type="GLenum"/>
+ <param name="texture" type="GLuint"/>
+ <param name="level" type="GLint"/>
+ <glx rop="4322"/>
+ </function>
+
+ <function name="FramebufferTexture3DEXT" offset="809">
+ <param name="target" type="GLenum"/>
+ <param name="attachment" type="GLenum"/>
+ <param name="textarget" type="GLenum"/>
+ <param name="texture" type="GLuint"/>
+ <param name="level" type="GLint"/>
+ <param name="zoffset" type="GLint"/>
+ <glx rop="4323"/>
+ </function>
+
+ <function name="FramebufferRenderbufferEXT" offset="810">
+ <param name="target" type="GLenum"/>
+ <param name="attachment" type="GLenum"/>
+ <param name="renderbuffertarget" type="GLenum"/>
+ <param name="renderbuffer" type="GLuint"/>
+ <glx rop="4324"/>
+ </function>
+
+ <function name="GetFramebufferAttachmentParameterivEXT" offset="811">
+ <param name="target" type="GLenum"/>
+ <param name="attachment" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true"/>
+ <glx vendorpriv="1428"/>
+ </function>
+
+ <function name="GenerateMipmapEXT" offset="812">
+ <param name="target" type="GLenum"/>
+ <glx rop="4325"/>
+ </function>
+</category>
+</OpenGLAPI>
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/Makefile b/nx-X11/extras/Mesa/src/mesa/glapi/Makefile
new file mode 100644
index 000000000..fb5a22885
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/Makefile
@@ -0,0 +1,70 @@
+# This file isn't used during a normal compilation since we don't want to
+# require Python in order to compile Mesa.
+# Instead, when the Mesa developers update/change the API interface it's
+# up to him/her to re-run this makefile and check in the newly generated files.
+
+
+TOP = ../../..
+include $(TOP)/configs/current
+
+OUTPUTS = glprocs.h glapitemp.h glapioffsets.h glapitable.h dispatch.h \
+ ../main/enums.c \
+ ../x86/glapi_x86.S \
+ ../x86-64/glapi_x86-64.S \
+ ../drivers/dri/common/extension_helper.h \
+ ../../glx/x11/indirect.c \
+ ../../glx/x11/indirect.h \
+ ../../glx/x11/indirect_init.c \
+ ../../glx/x11/indirect_size.h \
+ ../../glx/x11/indirect_size.c
+
+COMMON = gl_XML.py license.py gl_API.xml typeexpr.py
+COMMON_GLX = $(COMMON) glX_XML.py glX_proto_common.py
+
+all: $(OUTPUTS)
+
+glprocs.h: $(COMMON) gl_procs.py
+ $(PYTHON2) $(PYTHON_FLAGS) gl_procs.py > glprocs.h
+
+glapitemp.h: $(COMMON) gl_apitemp.py
+ $(PYTHON2) $(PYTHON_FLAGS) gl_apitemp.py > glapitemp.h
+
+glapioffsets.h: $(COMMON) gl_offsets.py
+ $(PYTHON2) $(PYTHON_FLAGS) gl_offsets.py > glapioffsets.h
+
+glapitable.h: $(COMMON) gl_table.py
+ $(PYTHON2) $(PYTHON_FLAGS) gl_table.py > glapitable.h
+
+dispatch.h: $(COMMON) gl_table.py
+ $(PYTHON2) $(PYTHON_FLAGS) gl_table.py -m remap_table > dispatch.h
+
+../main/enums.c: $(COMMON) gl_enums.py
+ $(PYTHON2) $(PYTHON_FLAGS) gl_enums.py > ../main/enums.c
+
+../x86/glapi_x86.S: $(COMMON) gl_x86_asm.py
+ $(PYTHON2) $(PYTHON_FLAGS) gl_x86_asm.py > ../x86/glapi_x86.S
+
+../x86-64/glapi_x86-64.S: $(COMMON) gl_x86-64_asm.py
+ $(PYTHON2) $(PYTHON_FLAGS) gl_x86-64_asm.py > ../x86-64/glapi_x86-64.S
+
+../drivers/dri/common/extension_helper.h: $(COMMON) extension_helper.py
+ $(PYTHON2) $(PYTHON_FLAGS) extension_helper.py > ../drivers/dri/common/extension_helper.h
+
+../../glx/x11/indirect.c: $(COMMON_GLX) glX_proto_send.py
+ $(PYTHON2) $(PYTHON_FLAGS) glX_proto_send.py -m proto > ../../glx/x11/indirect.c
+
+../../glx/x11/indirect.h: $(COMMON_GLX) glX_proto_send.py
+ $(PYTHON2) $(PYTHON_FLAGS) glX_proto_send.py -m init_h > ../../glx/x11/indirect.h
+
+../../glx/x11/indirect_init.c: $(COMMON_GLX) glX_proto_send.py
+ $(PYTHON2) $(PYTHON_FLAGS) glX_proto_send.py -m init_c > ../../glx/x11/indirect_init.c
+
+../../glx/x11/indirect_size.h: $(COMMON_GLX) glX_proto_size.py
+ $(PYTHON2) $(PYTHON_FLAGS) glX_proto_size.py -m size_h --only-set -h _INDIRECT_SIZE_H_ > ../../glx/x11/indirect_size.h
+
+../../glx/x11/indirect_size.c: $(COMMON_GLX) glX_proto_size.py
+ $(PYTHON2) $(PYTHON_FLAGS) glX_proto_size.py -m size_c --only-set > ../../glx/x11/indirect_size.c
+
+clean:
+ rm -f *~ *.pyo
+ rm -f $(OUTPUTS)
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/descrip.mms b/nx-X11/extras/Mesa/src/mesa/glapi/descrip.mms
new file mode 100644
index 000000000..20573b9ac
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/descrip.mms
@@ -0,0 +1,37 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+# Last revision : 16 June 2003
+
+.first
+ define gl [---.include.gl]
+
+.include [---]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [---.include],[-.main]
+LIBDIR = [---.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)
+
+SOURCES = glapi.c glthread.c
+
+OBJECTS = glapi.obj,glthread.obj
+
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+ @ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
+
+clean :
+ purge
+ delete *.obj;*
+
+glapi.obj : glapi.c
+
+glthread.obj : glthread.c
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/dispatch.h b/nx-X11/extras/Mesa/src/mesa/glapi/dispatch.h
new file mode 100644
index 000000000..9a456b540
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/dispatch.h
@@ -0,0 +1,4151 @@
+/* DO NOT EDIT - This file generated automatically by gl_table.py (from Mesa) script */
+
+/*
+ * (C) Copyright IBM Corporation 2005
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#if !defined( _DISPATCH_H_ )
+# define _DISPATCH_H_
+
+/**
+ * \file dispatch.h
+ * Macros for handling GL dispatch tables.
+ *
+ * For each known GL function, there are 3 macros in this file. The first
+ * macro is named CALL_FuncName and is used to call that GL function using
+ * the specified dispatch table. The other 2 macros, called GET_FuncName
+ * can SET_FuncName, are used to get and set the dispatch pointer for the
+ * named function in the specified dispatch table.
+ */
+
+#define CALL_by_offset(disp, cast, offset, parameters) \
+ (*(cast (GET_by_offset(disp, offset)))) parameters
+#define GET_by_offset(disp, offset) \
+ (offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : NULL
+#define SET_by_offset(disp, offset, fn) \
+ do { \
+ if ( (offset) < 0 ) { \
+ /* fprintf( stderr, "[%s:%u] SET_by_offset(%p, %d, %s)!\n", */ \
+ /* __func__, __LINE__, disp, offset, # fn); */ \
+ /* abort(); */ \
+ } \
+ else { \
+ ( (_glapi_proc *) (disp) )[offset] = (_glapi_proc) fn; \
+ } \
+ } while(0)
+
+#define CALL_NewList(disp, parameters) (*((disp)->NewList)) parameters
+#define GET_NewList(disp) ((disp)->NewList)
+#define SET_NewList(disp, fn) ((disp)->NewList = fn)
+#define CALL_EndList(disp, parameters) (*((disp)->EndList)) parameters
+#define GET_EndList(disp) ((disp)->EndList)
+#define SET_EndList(disp, fn) ((disp)->EndList = fn)
+#define CALL_CallList(disp, parameters) (*((disp)->CallList)) parameters
+#define GET_CallList(disp) ((disp)->CallList)
+#define SET_CallList(disp, fn) ((disp)->CallList = fn)
+#define CALL_CallLists(disp, parameters) (*((disp)->CallLists)) parameters
+#define GET_CallLists(disp) ((disp)->CallLists)
+#define SET_CallLists(disp, fn) ((disp)->CallLists = fn)
+#define CALL_DeleteLists(disp, parameters) (*((disp)->DeleteLists)) parameters
+#define GET_DeleteLists(disp) ((disp)->DeleteLists)
+#define SET_DeleteLists(disp, fn) ((disp)->DeleteLists = fn)
+#define CALL_GenLists(disp, parameters) (*((disp)->GenLists)) parameters
+#define GET_GenLists(disp) ((disp)->GenLists)
+#define SET_GenLists(disp, fn) ((disp)->GenLists = fn)
+#define CALL_ListBase(disp, parameters) (*((disp)->ListBase)) parameters
+#define GET_ListBase(disp) ((disp)->ListBase)
+#define SET_ListBase(disp, fn) ((disp)->ListBase = fn)
+#define CALL_Begin(disp, parameters) (*((disp)->Begin)) parameters
+#define GET_Begin(disp) ((disp)->Begin)
+#define SET_Begin(disp, fn) ((disp)->Begin = fn)
+#define CALL_Bitmap(disp, parameters) (*((disp)->Bitmap)) parameters
+#define GET_Bitmap(disp) ((disp)->Bitmap)
+#define SET_Bitmap(disp, fn) ((disp)->Bitmap = fn)
+#define CALL_Color3b(disp, parameters) (*((disp)->Color3b)) parameters
+#define GET_Color3b(disp) ((disp)->Color3b)
+#define SET_Color3b(disp, fn) ((disp)->Color3b = fn)
+#define CALL_Color3bv(disp, parameters) (*((disp)->Color3bv)) parameters
+#define GET_Color3bv(disp) ((disp)->Color3bv)
+#define SET_Color3bv(disp, fn) ((disp)->Color3bv = fn)
+#define CALL_Color3d(disp, parameters) (*((disp)->Color3d)) parameters
+#define GET_Color3d(disp) ((disp)->Color3d)
+#define SET_Color3d(disp, fn) ((disp)->Color3d = fn)
+#define CALL_Color3dv(disp, parameters) (*((disp)->Color3dv)) parameters
+#define GET_Color3dv(disp) ((disp)->Color3dv)
+#define SET_Color3dv(disp, fn) ((disp)->Color3dv = fn)
+#define CALL_Color3f(disp, parameters) (*((disp)->Color3f)) parameters
+#define GET_Color3f(disp) ((disp)->Color3f)
+#define SET_Color3f(disp, fn) ((disp)->Color3f = fn)
+#define CALL_Color3fv(disp, parameters) (*((disp)->Color3fv)) parameters
+#define GET_Color3fv(disp) ((disp)->Color3fv)
+#define SET_Color3fv(disp, fn) ((disp)->Color3fv = fn)
+#define CALL_Color3i(disp, parameters) (*((disp)->Color3i)) parameters
+#define GET_Color3i(disp) ((disp)->Color3i)
+#define SET_Color3i(disp, fn) ((disp)->Color3i = fn)
+#define CALL_Color3iv(disp, parameters) (*((disp)->Color3iv)) parameters
+#define GET_Color3iv(disp) ((disp)->Color3iv)
+#define SET_Color3iv(disp, fn) ((disp)->Color3iv = fn)
+#define CALL_Color3s(disp, parameters) (*((disp)->Color3s)) parameters
+#define GET_Color3s(disp) ((disp)->Color3s)
+#define SET_Color3s(disp, fn) ((disp)->Color3s = fn)
+#define CALL_Color3sv(disp, parameters) (*((disp)->Color3sv)) parameters
+#define GET_Color3sv(disp) ((disp)->Color3sv)
+#define SET_Color3sv(disp, fn) ((disp)->Color3sv = fn)
+#define CALL_Color3ub(disp, parameters) (*((disp)->Color3ub)) parameters
+#define GET_Color3ub(disp) ((disp)->Color3ub)
+#define SET_Color3ub(disp, fn) ((disp)->Color3ub = fn)
+#define CALL_Color3ubv(disp, parameters) (*((disp)->Color3ubv)) parameters
+#define GET_Color3ubv(disp) ((disp)->Color3ubv)
+#define SET_Color3ubv(disp, fn) ((disp)->Color3ubv = fn)
+#define CALL_Color3ui(disp, parameters) (*((disp)->Color3ui)) parameters
+#define GET_Color3ui(disp) ((disp)->Color3ui)
+#define SET_Color3ui(disp, fn) ((disp)->Color3ui = fn)
+#define CALL_Color3uiv(disp, parameters) (*((disp)->Color3uiv)) parameters
+#define GET_Color3uiv(disp) ((disp)->Color3uiv)
+#define SET_Color3uiv(disp, fn) ((disp)->Color3uiv = fn)
+#define CALL_Color3us(disp, parameters) (*((disp)->Color3us)) parameters
+#define GET_Color3us(disp) ((disp)->Color3us)
+#define SET_Color3us(disp, fn) ((disp)->Color3us = fn)
+#define CALL_Color3usv(disp, parameters) (*((disp)->Color3usv)) parameters
+#define GET_Color3usv(disp) ((disp)->Color3usv)
+#define SET_Color3usv(disp, fn) ((disp)->Color3usv = fn)
+#define CALL_Color4b(disp, parameters) (*((disp)->Color4b)) parameters
+#define GET_Color4b(disp) ((disp)->Color4b)
+#define SET_Color4b(disp, fn) ((disp)->Color4b = fn)
+#define CALL_Color4bv(disp, parameters) (*((disp)->Color4bv)) parameters
+#define GET_Color4bv(disp) ((disp)->Color4bv)
+#define SET_Color4bv(disp, fn) ((disp)->Color4bv = fn)
+#define CALL_Color4d(disp, parameters) (*((disp)->Color4d)) parameters
+#define GET_Color4d(disp) ((disp)->Color4d)
+#define SET_Color4d(disp, fn) ((disp)->Color4d = fn)
+#define CALL_Color4dv(disp, parameters) (*((disp)->Color4dv)) parameters
+#define GET_Color4dv(disp) ((disp)->Color4dv)
+#define SET_Color4dv(disp, fn) ((disp)->Color4dv = fn)
+#define CALL_Color4f(disp, parameters) (*((disp)->Color4f)) parameters
+#define GET_Color4f(disp) ((disp)->Color4f)
+#define SET_Color4f(disp, fn) ((disp)->Color4f = fn)
+#define CALL_Color4fv(disp, parameters) (*((disp)->Color4fv)) parameters
+#define GET_Color4fv(disp) ((disp)->Color4fv)
+#define SET_Color4fv(disp, fn) ((disp)->Color4fv = fn)
+#define CALL_Color4i(disp, parameters) (*((disp)->Color4i)) parameters
+#define GET_Color4i(disp) ((disp)->Color4i)
+#define SET_Color4i(disp, fn) ((disp)->Color4i = fn)
+#define CALL_Color4iv(disp, parameters) (*((disp)->Color4iv)) parameters
+#define GET_Color4iv(disp) ((disp)->Color4iv)
+#define SET_Color4iv(disp, fn) ((disp)->Color4iv = fn)
+#define CALL_Color4s(disp, parameters) (*((disp)->Color4s)) parameters
+#define GET_Color4s(disp) ((disp)->Color4s)
+#define SET_Color4s(disp, fn) ((disp)->Color4s = fn)
+#define CALL_Color4sv(disp, parameters) (*((disp)->Color4sv)) parameters
+#define GET_Color4sv(disp) ((disp)->Color4sv)
+#define SET_Color4sv(disp, fn) ((disp)->Color4sv = fn)
+#define CALL_Color4ub(disp, parameters) (*((disp)->Color4ub)) parameters
+#define GET_Color4ub(disp) ((disp)->Color4ub)
+#define SET_Color4ub(disp, fn) ((disp)->Color4ub = fn)
+#define CALL_Color4ubv(disp, parameters) (*((disp)->Color4ubv)) parameters
+#define GET_Color4ubv(disp) ((disp)->Color4ubv)
+#define SET_Color4ubv(disp, fn) ((disp)->Color4ubv = fn)
+#define CALL_Color4ui(disp, parameters) (*((disp)->Color4ui)) parameters
+#define GET_Color4ui(disp) ((disp)->Color4ui)
+#define SET_Color4ui(disp, fn) ((disp)->Color4ui = fn)
+#define CALL_Color4uiv(disp, parameters) (*((disp)->Color4uiv)) parameters
+#define GET_Color4uiv(disp) ((disp)->Color4uiv)
+#define SET_Color4uiv(disp, fn) ((disp)->Color4uiv = fn)
+#define CALL_Color4us(disp, parameters) (*((disp)->Color4us)) parameters
+#define GET_Color4us(disp) ((disp)->Color4us)
+#define SET_Color4us(disp, fn) ((disp)->Color4us = fn)
+#define CALL_Color4usv(disp, parameters) (*((disp)->Color4usv)) parameters
+#define GET_Color4usv(disp) ((disp)->Color4usv)
+#define SET_Color4usv(disp, fn) ((disp)->Color4usv = fn)
+#define CALL_EdgeFlag(disp, parameters) (*((disp)->EdgeFlag)) parameters
+#define GET_EdgeFlag(disp) ((disp)->EdgeFlag)
+#define SET_EdgeFlag(disp, fn) ((disp)->EdgeFlag = fn)
+#define CALL_EdgeFlagv(disp, parameters) (*((disp)->EdgeFlagv)) parameters
+#define GET_EdgeFlagv(disp) ((disp)->EdgeFlagv)
+#define SET_EdgeFlagv(disp, fn) ((disp)->EdgeFlagv = fn)
+#define CALL_End(disp, parameters) (*((disp)->End)) parameters
+#define GET_End(disp) ((disp)->End)
+#define SET_End(disp, fn) ((disp)->End = fn)
+#define CALL_Indexd(disp, parameters) (*((disp)->Indexd)) parameters
+#define GET_Indexd(disp) ((disp)->Indexd)
+#define SET_Indexd(disp, fn) ((disp)->Indexd = fn)
+#define CALL_Indexdv(disp, parameters) (*((disp)->Indexdv)) parameters
+#define GET_Indexdv(disp) ((disp)->Indexdv)
+#define SET_Indexdv(disp, fn) ((disp)->Indexdv = fn)
+#define CALL_Indexf(disp, parameters) (*((disp)->Indexf)) parameters
+#define GET_Indexf(disp) ((disp)->Indexf)
+#define SET_Indexf(disp, fn) ((disp)->Indexf = fn)
+#define CALL_Indexfv(disp, parameters) (*((disp)->Indexfv)) parameters
+#define GET_Indexfv(disp) ((disp)->Indexfv)
+#define SET_Indexfv(disp, fn) ((disp)->Indexfv = fn)
+#define CALL_Indexi(disp, parameters) (*((disp)->Indexi)) parameters
+#define GET_Indexi(disp) ((disp)->Indexi)
+#define SET_Indexi(disp, fn) ((disp)->Indexi = fn)
+#define CALL_Indexiv(disp, parameters) (*((disp)->Indexiv)) parameters
+#define GET_Indexiv(disp) ((disp)->Indexiv)
+#define SET_Indexiv(disp, fn) ((disp)->Indexiv = fn)
+#define CALL_Indexs(disp, parameters) (*((disp)->Indexs)) parameters
+#define GET_Indexs(disp) ((disp)->Indexs)
+#define SET_Indexs(disp, fn) ((disp)->Indexs = fn)
+#define CALL_Indexsv(disp, parameters) (*((disp)->Indexsv)) parameters
+#define GET_Indexsv(disp) ((disp)->Indexsv)
+#define SET_Indexsv(disp, fn) ((disp)->Indexsv = fn)
+#define CALL_Normal3b(disp, parameters) (*((disp)->Normal3b)) parameters
+#define GET_Normal3b(disp) ((disp)->Normal3b)
+#define SET_Normal3b(disp, fn) ((disp)->Normal3b = fn)
+#define CALL_Normal3bv(disp, parameters) (*((disp)->Normal3bv)) parameters
+#define GET_Normal3bv(disp) ((disp)->Normal3bv)
+#define SET_Normal3bv(disp, fn) ((disp)->Normal3bv = fn)
+#define CALL_Normal3d(disp, parameters) (*((disp)->Normal3d)) parameters
+#define GET_Normal3d(disp) ((disp)->Normal3d)
+#define SET_Normal3d(disp, fn) ((disp)->Normal3d = fn)
+#define CALL_Normal3dv(disp, parameters) (*((disp)->Normal3dv)) parameters
+#define GET_Normal3dv(disp) ((disp)->Normal3dv)
+#define SET_Normal3dv(disp, fn) ((disp)->Normal3dv = fn)
+#define CALL_Normal3f(disp, parameters) (*((disp)->Normal3f)) parameters
+#define GET_Normal3f(disp) ((disp)->Normal3f)
+#define SET_Normal3f(disp, fn) ((disp)->Normal3f = fn)
+#define CALL_Normal3fv(disp, parameters) (*((disp)->Normal3fv)) parameters
+#define GET_Normal3fv(disp) ((disp)->Normal3fv)
+#define SET_Normal3fv(disp, fn) ((disp)->Normal3fv = fn)
+#define CALL_Normal3i(disp, parameters) (*((disp)->Normal3i)) parameters
+#define GET_Normal3i(disp) ((disp)->Normal3i)
+#define SET_Normal3i(disp, fn) ((disp)->Normal3i = fn)
+#define CALL_Normal3iv(disp, parameters) (*((disp)->Normal3iv)) parameters
+#define GET_Normal3iv(disp) ((disp)->Normal3iv)
+#define SET_Normal3iv(disp, fn) ((disp)->Normal3iv = fn)
+#define CALL_Normal3s(disp, parameters) (*((disp)->Normal3s)) parameters
+#define GET_Normal3s(disp) ((disp)->Normal3s)
+#define SET_Normal3s(disp, fn) ((disp)->Normal3s = fn)
+#define CALL_Normal3sv(disp, parameters) (*((disp)->Normal3sv)) parameters
+#define GET_Normal3sv(disp) ((disp)->Normal3sv)
+#define SET_Normal3sv(disp, fn) ((disp)->Normal3sv = fn)
+#define CALL_RasterPos2d(disp, parameters) (*((disp)->RasterPos2d)) parameters
+#define GET_RasterPos2d(disp) ((disp)->RasterPos2d)
+#define SET_RasterPos2d(disp, fn) ((disp)->RasterPos2d = fn)
+#define CALL_RasterPos2dv(disp, parameters) (*((disp)->RasterPos2dv)) parameters
+#define GET_RasterPos2dv(disp) ((disp)->RasterPos2dv)
+#define SET_RasterPos2dv(disp, fn) ((disp)->RasterPos2dv = fn)
+#define CALL_RasterPos2f(disp, parameters) (*((disp)->RasterPos2f)) parameters
+#define GET_RasterPos2f(disp) ((disp)->RasterPos2f)
+#define SET_RasterPos2f(disp, fn) ((disp)->RasterPos2f = fn)
+#define CALL_RasterPos2fv(disp, parameters) (*((disp)->RasterPos2fv)) parameters
+#define GET_RasterPos2fv(disp) ((disp)->RasterPos2fv)
+#define SET_RasterPos2fv(disp, fn) ((disp)->RasterPos2fv = fn)
+#define CALL_RasterPos2i(disp, parameters) (*((disp)->RasterPos2i)) parameters
+#define GET_RasterPos2i(disp) ((disp)->RasterPos2i)
+#define SET_RasterPos2i(disp, fn) ((disp)->RasterPos2i = fn)
+#define CALL_RasterPos2iv(disp, parameters) (*((disp)->RasterPos2iv)) parameters
+#define GET_RasterPos2iv(disp) ((disp)->RasterPos2iv)
+#define SET_RasterPos2iv(disp, fn) ((disp)->RasterPos2iv = fn)
+#define CALL_RasterPos2s(disp, parameters) (*((disp)->RasterPos2s)) parameters
+#define GET_RasterPos2s(disp) ((disp)->RasterPos2s)
+#define SET_RasterPos2s(disp, fn) ((disp)->RasterPos2s = fn)
+#define CALL_RasterPos2sv(disp, parameters) (*((disp)->RasterPos2sv)) parameters
+#define GET_RasterPos2sv(disp) ((disp)->RasterPos2sv)
+#define SET_RasterPos2sv(disp, fn) ((disp)->RasterPos2sv = fn)
+#define CALL_RasterPos3d(disp, parameters) (*((disp)->RasterPos3d)) parameters
+#define GET_RasterPos3d(disp) ((disp)->RasterPos3d)
+#define SET_RasterPos3d(disp, fn) ((disp)->RasterPos3d = fn)
+#define CALL_RasterPos3dv(disp, parameters) (*((disp)->RasterPos3dv)) parameters
+#define GET_RasterPos3dv(disp) ((disp)->RasterPos3dv)
+#define SET_RasterPos3dv(disp, fn) ((disp)->RasterPos3dv = fn)
+#define CALL_RasterPos3f(disp, parameters) (*((disp)->RasterPos3f)) parameters
+#define GET_RasterPos3f(disp) ((disp)->RasterPos3f)
+#define SET_RasterPos3f(disp, fn) ((disp)->RasterPos3f = fn)
+#define CALL_RasterPos3fv(disp, parameters) (*((disp)->RasterPos3fv)) parameters
+#define GET_RasterPos3fv(disp) ((disp)->RasterPos3fv)
+#define SET_RasterPos3fv(disp, fn) ((disp)->RasterPos3fv = fn)
+#define CALL_RasterPos3i(disp, parameters) (*((disp)->RasterPos3i)) parameters
+#define GET_RasterPos3i(disp) ((disp)->RasterPos3i)
+#define SET_RasterPos3i(disp, fn) ((disp)->RasterPos3i = fn)
+#define CALL_RasterPos3iv(disp, parameters) (*((disp)->RasterPos3iv)) parameters
+#define GET_RasterPos3iv(disp) ((disp)->RasterPos3iv)
+#define SET_RasterPos3iv(disp, fn) ((disp)->RasterPos3iv = fn)
+#define CALL_RasterPos3s(disp, parameters) (*((disp)->RasterPos3s)) parameters
+#define GET_RasterPos3s(disp) ((disp)->RasterPos3s)
+#define SET_RasterPos3s(disp, fn) ((disp)->RasterPos3s = fn)
+#define CALL_RasterPos3sv(disp, parameters) (*((disp)->RasterPos3sv)) parameters
+#define GET_RasterPos3sv(disp) ((disp)->RasterPos3sv)
+#define SET_RasterPos3sv(disp, fn) ((disp)->RasterPos3sv = fn)
+#define CALL_RasterPos4d(disp, parameters) (*((disp)->RasterPos4d)) parameters
+#define GET_RasterPos4d(disp) ((disp)->RasterPos4d)
+#define SET_RasterPos4d(disp, fn) ((disp)->RasterPos4d = fn)
+#define CALL_RasterPos4dv(disp, parameters) (*((disp)->RasterPos4dv)) parameters
+#define GET_RasterPos4dv(disp) ((disp)->RasterPos4dv)
+#define SET_RasterPos4dv(disp, fn) ((disp)->RasterPos4dv = fn)
+#define CALL_RasterPos4f(disp, parameters) (*((disp)->RasterPos4f)) parameters
+#define GET_RasterPos4f(disp) ((disp)->RasterPos4f)
+#define SET_RasterPos4f(disp, fn) ((disp)->RasterPos4f = fn)
+#define CALL_RasterPos4fv(disp, parameters) (*((disp)->RasterPos4fv)) parameters
+#define GET_RasterPos4fv(disp) ((disp)->RasterPos4fv)
+#define SET_RasterPos4fv(disp, fn) ((disp)->RasterPos4fv = fn)
+#define CALL_RasterPos4i(disp, parameters) (*((disp)->RasterPos4i)) parameters
+#define GET_RasterPos4i(disp) ((disp)->RasterPos4i)
+#define SET_RasterPos4i(disp, fn) ((disp)->RasterPos4i = fn)
+#define CALL_RasterPos4iv(disp, parameters) (*((disp)->RasterPos4iv)) parameters
+#define GET_RasterPos4iv(disp) ((disp)->RasterPos4iv)
+#define SET_RasterPos4iv(disp, fn) ((disp)->RasterPos4iv = fn)
+#define CALL_RasterPos4s(disp, parameters) (*((disp)->RasterPos4s)) parameters
+#define GET_RasterPos4s(disp) ((disp)->RasterPos4s)
+#define SET_RasterPos4s(disp, fn) ((disp)->RasterPos4s = fn)
+#define CALL_RasterPos4sv(disp, parameters) (*((disp)->RasterPos4sv)) parameters
+#define GET_RasterPos4sv(disp) ((disp)->RasterPos4sv)
+#define SET_RasterPos4sv(disp, fn) ((disp)->RasterPos4sv = fn)
+#define CALL_Rectd(disp, parameters) (*((disp)->Rectd)) parameters
+#define GET_Rectd(disp) ((disp)->Rectd)
+#define SET_Rectd(disp, fn) ((disp)->Rectd = fn)
+#define CALL_Rectdv(disp, parameters) (*((disp)->Rectdv)) parameters
+#define GET_Rectdv(disp) ((disp)->Rectdv)
+#define SET_Rectdv(disp, fn) ((disp)->Rectdv = fn)
+#define CALL_Rectf(disp, parameters) (*((disp)->Rectf)) parameters
+#define GET_Rectf(disp) ((disp)->Rectf)
+#define SET_Rectf(disp, fn) ((disp)->Rectf = fn)
+#define CALL_Rectfv(disp, parameters) (*((disp)->Rectfv)) parameters
+#define GET_Rectfv(disp) ((disp)->Rectfv)
+#define SET_Rectfv(disp, fn) ((disp)->Rectfv = fn)
+#define CALL_Recti(disp, parameters) (*((disp)->Recti)) parameters
+#define GET_Recti(disp) ((disp)->Recti)
+#define SET_Recti(disp, fn) ((disp)->Recti = fn)
+#define CALL_Rectiv(disp, parameters) (*((disp)->Rectiv)) parameters
+#define GET_Rectiv(disp) ((disp)->Rectiv)
+#define SET_Rectiv(disp, fn) ((disp)->Rectiv = fn)
+#define CALL_Rects(disp, parameters) (*((disp)->Rects)) parameters
+#define GET_Rects(disp) ((disp)->Rects)
+#define SET_Rects(disp, fn) ((disp)->Rects = fn)
+#define CALL_Rectsv(disp, parameters) (*((disp)->Rectsv)) parameters
+#define GET_Rectsv(disp) ((disp)->Rectsv)
+#define SET_Rectsv(disp, fn) ((disp)->Rectsv = fn)
+#define CALL_TexCoord1d(disp, parameters) (*((disp)->TexCoord1d)) parameters
+#define GET_TexCoord1d(disp) ((disp)->TexCoord1d)
+#define SET_TexCoord1d(disp, fn) ((disp)->TexCoord1d = fn)
+#define CALL_TexCoord1dv(disp, parameters) (*((disp)->TexCoord1dv)) parameters
+#define GET_TexCoord1dv(disp) ((disp)->TexCoord1dv)
+#define SET_TexCoord1dv(disp, fn) ((disp)->TexCoord1dv = fn)
+#define CALL_TexCoord1f(disp, parameters) (*((disp)->TexCoord1f)) parameters
+#define GET_TexCoord1f(disp) ((disp)->TexCoord1f)
+#define SET_TexCoord1f(disp, fn) ((disp)->TexCoord1f = fn)
+#define CALL_TexCoord1fv(disp, parameters) (*((disp)->TexCoord1fv)) parameters
+#define GET_TexCoord1fv(disp) ((disp)->TexCoord1fv)
+#define SET_TexCoord1fv(disp, fn) ((disp)->TexCoord1fv = fn)
+#define CALL_TexCoord1i(disp, parameters) (*((disp)->TexCoord1i)) parameters
+#define GET_TexCoord1i(disp) ((disp)->TexCoord1i)
+#define SET_TexCoord1i(disp, fn) ((disp)->TexCoord1i = fn)
+#define CALL_TexCoord1iv(disp, parameters) (*((disp)->TexCoord1iv)) parameters
+#define GET_TexCoord1iv(disp) ((disp)->TexCoord1iv)
+#define SET_TexCoord1iv(disp, fn) ((disp)->TexCoord1iv = fn)
+#define CALL_TexCoord1s(disp, parameters) (*((disp)->TexCoord1s)) parameters
+#define GET_TexCoord1s(disp) ((disp)->TexCoord1s)
+#define SET_TexCoord1s(disp, fn) ((disp)->TexCoord1s = fn)
+#define CALL_TexCoord1sv(disp, parameters) (*((disp)->TexCoord1sv)) parameters
+#define GET_TexCoord1sv(disp) ((disp)->TexCoord1sv)
+#define SET_TexCoord1sv(disp, fn) ((disp)->TexCoord1sv = fn)
+#define CALL_TexCoord2d(disp, parameters) (*((disp)->TexCoord2d)) parameters
+#define GET_TexCoord2d(disp) ((disp)->TexCoord2d)
+#define SET_TexCoord2d(disp, fn) ((disp)->TexCoord2d = fn)
+#define CALL_TexCoord2dv(disp, parameters) (*((disp)->TexCoord2dv)) parameters
+#define GET_TexCoord2dv(disp) ((disp)->TexCoord2dv)
+#define SET_TexCoord2dv(disp, fn) ((disp)->TexCoord2dv = fn)
+#define CALL_TexCoord2f(disp, parameters) (*((disp)->TexCoord2f)) parameters
+#define GET_TexCoord2f(disp) ((disp)->TexCoord2f)
+#define SET_TexCoord2f(disp, fn) ((disp)->TexCoord2f = fn)
+#define CALL_TexCoord2fv(disp, parameters) (*((disp)->TexCoord2fv)) parameters
+#define GET_TexCoord2fv(disp) ((disp)->TexCoord2fv)
+#define SET_TexCoord2fv(disp, fn) ((disp)->TexCoord2fv = fn)
+#define CALL_TexCoord2i(disp, parameters) (*((disp)->TexCoord2i)) parameters
+#define GET_TexCoord2i(disp) ((disp)->TexCoord2i)
+#define SET_TexCoord2i(disp, fn) ((disp)->TexCoord2i = fn)
+#define CALL_TexCoord2iv(disp, parameters) (*((disp)->TexCoord2iv)) parameters
+#define GET_TexCoord2iv(disp) ((disp)->TexCoord2iv)
+#define SET_TexCoord2iv(disp, fn) ((disp)->TexCoord2iv = fn)
+#define CALL_TexCoord2s(disp, parameters) (*((disp)->TexCoord2s)) parameters
+#define GET_TexCoord2s(disp) ((disp)->TexCoord2s)
+#define SET_TexCoord2s(disp, fn) ((disp)->TexCoord2s = fn)
+#define CALL_TexCoord2sv(disp, parameters) (*((disp)->TexCoord2sv)) parameters
+#define GET_TexCoord2sv(disp) ((disp)->TexCoord2sv)
+#define SET_TexCoord2sv(disp, fn) ((disp)->TexCoord2sv = fn)
+#define CALL_TexCoord3d(disp, parameters) (*((disp)->TexCoord3d)) parameters
+#define GET_TexCoord3d(disp) ((disp)->TexCoord3d)
+#define SET_TexCoord3d(disp, fn) ((disp)->TexCoord3d = fn)
+#define CALL_TexCoord3dv(disp, parameters) (*((disp)->TexCoord3dv)) parameters
+#define GET_TexCoord3dv(disp) ((disp)->TexCoord3dv)
+#define SET_TexCoord3dv(disp, fn) ((disp)->TexCoord3dv = fn)
+#define CALL_TexCoord3f(disp, parameters) (*((disp)->TexCoord3f)) parameters
+#define GET_TexCoord3f(disp) ((disp)->TexCoord3f)
+#define SET_TexCoord3f(disp, fn) ((disp)->TexCoord3f = fn)
+#define CALL_TexCoord3fv(disp, parameters) (*((disp)->TexCoord3fv)) parameters
+#define GET_TexCoord3fv(disp) ((disp)->TexCoord3fv)
+#define SET_TexCoord3fv(disp, fn) ((disp)->TexCoord3fv = fn)
+#define CALL_TexCoord3i(disp, parameters) (*((disp)->TexCoord3i)) parameters
+#define GET_TexCoord3i(disp) ((disp)->TexCoord3i)
+#define SET_TexCoord3i(disp, fn) ((disp)->TexCoord3i = fn)
+#define CALL_TexCoord3iv(disp, parameters) (*((disp)->TexCoord3iv)) parameters
+#define GET_TexCoord3iv(disp) ((disp)->TexCoord3iv)
+#define SET_TexCoord3iv(disp, fn) ((disp)->TexCoord3iv = fn)
+#define CALL_TexCoord3s(disp, parameters) (*((disp)->TexCoord3s)) parameters
+#define GET_TexCoord3s(disp) ((disp)->TexCoord3s)
+#define SET_TexCoord3s(disp, fn) ((disp)->TexCoord3s = fn)
+#define CALL_TexCoord3sv(disp, parameters) (*((disp)->TexCoord3sv)) parameters
+#define GET_TexCoord3sv(disp) ((disp)->TexCoord3sv)
+#define SET_TexCoord3sv(disp, fn) ((disp)->TexCoord3sv = fn)
+#define CALL_TexCoord4d(disp, parameters) (*((disp)->TexCoord4d)) parameters
+#define GET_TexCoord4d(disp) ((disp)->TexCoord4d)
+#define SET_TexCoord4d(disp, fn) ((disp)->TexCoord4d = fn)
+#define CALL_TexCoord4dv(disp, parameters) (*((disp)->TexCoord4dv)) parameters
+#define GET_TexCoord4dv(disp) ((disp)->TexCoord4dv)
+#define SET_TexCoord4dv(disp, fn) ((disp)->TexCoord4dv = fn)
+#define CALL_TexCoord4f(disp, parameters) (*((disp)->TexCoord4f)) parameters
+#define GET_TexCoord4f(disp) ((disp)->TexCoord4f)
+#define SET_TexCoord4f(disp, fn) ((disp)->TexCoord4f = fn)
+#define CALL_TexCoord4fv(disp, parameters) (*((disp)->TexCoord4fv)) parameters
+#define GET_TexCoord4fv(disp) ((disp)->TexCoord4fv)
+#define SET_TexCoord4fv(disp, fn) ((disp)->TexCoord4fv = fn)
+#define CALL_TexCoord4i(disp, parameters) (*((disp)->TexCoord4i)) parameters
+#define GET_TexCoord4i(disp) ((disp)->TexCoord4i)
+#define SET_TexCoord4i(disp, fn) ((disp)->TexCoord4i = fn)
+#define CALL_TexCoord4iv(disp, parameters) (*((disp)->TexCoord4iv)) parameters
+#define GET_TexCoord4iv(disp) ((disp)->TexCoord4iv)
+#define SET_TexCoord4iv(disp, fn) ((disp)->TexCoord4iv = fn)
+#define CALL_TexCoord4s(disp, parameters) (*((disp)->TexCoord4s)) parameters
+#define GET_TexCoord4s(disp) ((disp)->TexCoord4s)
+#define SET_TexCoord4s(disp, fn) ((disp)->TexCoord4s = fn)
+#define CALL_TexCoord4sv(disp, parameters) (*((disp)->TexCoord4sv)) parameters
+#define GET_TexCoord4sv(disp) ((disp)->TexCoord4sv)
+#define SET_TexCoord4sv(disp, fn) ((disp)->TexCoord4sv = fn)
+#define CALL_Vertex2d(disp, parameters) (*((disp)->Vertex2d)) parameters
+#define GET_Vertex2d(disp) ((disp)->Vertex2d)
+#define SET_Vertex2d(disp, fn) ((disp)->Vertex2d = fn)
+#define CALL_Vertex2dv(disp, parameters) (*((disp)->Vertex2dv)) parameters
+#define GET_Vertex2dv(disp) ((disp)->Vertex2dv)
+#define SET_Vertex2dv(disp, fn) ((disp)->Vertex2dv = fn)
+#define CALL_Vertex2f(disp, parameters) (*((disp)->Vertex2f)) parameters
+#define GET_Vertex2f(disp) ((disp)->Vertex2f)
+#define SET_Vertex2f(disp, fn) ((disp)->Vertex2f = fn)
+#define CALL_Vertex2fv(disp, parameters) (*((disp)->Vertex2fv)) parameters
+#define GET_Vertex2fv(disp) ((disp)->Vertex2fv)
+#define SET_Vertex2fv(disp, fn) ((disp)->Vertex2fv = fn)
+#define CALL_Vertex2i(disp, parameters) (*((disp)->Vertex2i)) parameters
+#define GET_Vertex2i(disp) ((disp)->Vertex2i)
+#define SET_Vertex2i(disp, fn) ((disp)->Vertex2i = fn)
+#define CALL_Vertex2iv(disp, parameters) (*((disp)->Vertex2iv)) parameters
+#define GET_Vertex2iv(disp) ((disp)->Vertex2iv)
+#define SET_Vertex2iv(disp, fn) ((disp)->Vertex2iv = fn)
+#define CALL_Vertex2s(disp, parameters) (*((disp)->Vertex2s)) parameters
+#define GET_Vertex2s(disp) ((disp)->Vertex2s)
+#define SET_Vertex2s(disp, fn) ((disp)->Vertex2s = fn)
+#define CALL_Vertex2sv(disp, parameters) (*((disp)->Vertex2sv)) parameters
+#define GET_Vertex2sv(disp) ((disp)->Vertex2sv)
+#define SET_Vertex2sv(disp, fn) ((disp)->Vertex2sv = fn)
+#define CALL_Vertex3d(disp, parameters) (*((disp)->Vertex3d)) parameters
+#define GET_Vertex3d(disp) ((disp)->Vertex3d)
+#define SET_Vertex3d(disp, fn) ((disp)->Vertex3d = fn)
+#define CALL_Vertex3dv(disp, parameters) (*((disp)->Vertex3dv)) parameters
+#define GET_Vertex3dv(disp) ((disp)->Vertex3dv)
+#define SET_Vertex3dv(disp, fn) ((disp)->Vertex3dv = fn)
+#define CALL_Vertex3f(disp, parameters) (*((disp)->Vertex3f)) parameters
+#define GET_Vertex3f(disp) ((disp)->Vertex3f)
+#define SET_Vertex3f(disp, fn) ((disp)->Vertex3f = fn)
+#define CALL_Vertex3fv(disp, parameters) (*((disp)->Vertex3fv)) parameters
+#define GET_Vertex3fv(disp) ((disp)->Vertex3fv)
+#define SET_Vertex3fv(disp, fn) ((disp)->Vertex3fv = fn)
+#define CALL_Vertex3i(disp, parameters) (*((disp)->Vertex3i)) parameters
+#define GET_Vertex3i(disp) ((disp)->Vertex3i)
+#define SET_Vertex3i(disp, fn) ((disp)->Vertex3i = fn)
+#define CALL_Vertex3iv(disp, parameters) (*((disp)->Vertex3iv)) parameters
+#define GET_Vertex3iv(disp) ((disp)->Vertex3iv)
+#define SET_Vertex3iv(disp, fn) ((disp)->Vertex3iv = fn)
+#define CALL_Vertex3s(disp, parameters) (*((disp)->Vertex3s)) parameters
+#define GET_Vertex3s(disp) ((disp)->Vertex3s)
+#define SET_Vertex3s(disp, fn) ((disp)->Vertex3s = fn)
+#define CALL_Vertex3sv(disp, parameters) (*((disp)->Vertex3sv)) parameters
+#define GET_Vertex3sv(disp) ((disp)->Vertex3sv)
+#define SET_Vertex3sv(disp, fn) ((disp)->Vertex3sv = fn)
+#define CALL_Vertex4d(disp, parameters) (*((disp)->Vertex4d)) parameters
+#define GET_Vertex4d(disp) ((disp)->Vertex4d)
+#define SET_Vertex4d(disp, fn) ((disp)->Vertex4d = fn)
+#define CALL_Vertex4dv(disp, parameters) (*((disp)->Vertex4dv)) parameters
+#define GET_Vertex4dv(disp) ((disp)->Vertex4dv)
+#define SET_Vertex4dv(disp, fn) ((disp)->Vertex4dv = fn)
+#define CALL_Vertex4f(disp, parameters) (*((disp)->Vertex4f)) parameters
+#define GET_Vertex4f(disp) ((disp)->Vertex4f)
+#define SET_Vertex4f(disp, fn) ((disp)->Vertex4f = fn)
+#define CALL_Vertex4fv(disp, parameters) (*((disp)->Vertex4fv)) parameters
+#define GET_Vertex4fv(disp) ((disp)->Vertex4fv)
+#define SET_Vertex4fv(disp, fn) ((disp)->Vertex4fv = fn)
+#define CALL_Vertex4i(disp, parameters) (*((disp)->Vertex4i)) parameters
+#define GET_Vertex4i(disp) ((disp)->Vertex4i)
+#define SET_Vertex4i(disp, fn) ((disp)->Vertex4i = fn)
+#define CALL_Vertex4iv(disp, parameters) (*((disp)->Vertex4iv)) parameters
+#define GET_Vertex4iv(disp) ((disp)->Vertex4iv)
+#define SET_Vertex4iv(disp, fn) ((disp)->Vertex4iv = fn)
+#define CALL_Vertex4s(disp, parameters) (*((disp)->Vertex4s)) parameters
+#define GET_Vertex4s(disp) ((disp)->Vertex4s)
+#define SET_Vertex4s(disp, fn) ((disp)->Vertex4s = fn)
+#define CALL_Vertex4sv(disp, parameters) (*((disp)->Vertex4sv)) parameters
+#define GET_Vertex4sv(disp) ((disp)->Vertex4sv)
+#define SET_Vertex4sv(disp, fn) ((disp)->Vertex4sv = fn)
+#define CALL_ClipPlane(disp, parameters) (*((disp)->ClipPlane)) parameters
+#define GET_ClipPlane(disp) ((disp)->ClipPlane)
+#define SET_ClipPlane(disp, fn) ((disp)->ClipPlane = fn)
+#define CALL_ColorMaterial(disp, parameters) (*((disp)->ColorMaterial)) parameters
+#define GET_ColorMaterial(disp) ((disp)->ColorMaterial)
+#define SET_ColorMaterial(disp, fn) ((disp)->ColorMaterial = fn)
+#define CALL_CullFace(disp, parameters) (*((disp)->CullFace)) parameters
+#define GET_CullFace(disp) ((disp)->CullFace)
+#define SET_CullFace(disp, fn) ((disp)->CullFace = fn)
+#define CALL_Fogf(disp, parameters) (*((disp)->Fogf)) parameters
+#define GET_Fogf(disp) ((disp)->Fogf)
+#define SET_Fogf(disp, fn) ((disp)->Fogf = fn)
+#define CALL_Fogfv(disp, parameters) (*((disp)->Fogfv)) parameters
+#define GET_Fogfv(disp) ((disp)->Fogfv)
+#define SET_Fogfv(disp, fn) ((disp)->Fogfv = fn)
+#define CALL_Fogi(disp, parameters) (*((disp)->Fogi)) parameters
+#define GET_Fogi(disp) ((disp)->Fogi)
+#define SET_Fogi(disp, fn) ((disp)->Fogi = fn)
+#define CALL_Fogiv(disp, parameters) (*((disp)->Fogiv)) parameters
+#define GET_Fogiv(disp) ((disp)->Fogiv)
+#define SET_Fogiv(disp, fn) ((disp)->Fogiv = fn)
+#define CALL_FrontFace(disp, parameters) (*((disp)->FrontFace)) parameters
+#define GET_FrontFace(disp) ((disp)->FrontFace)
+#define SET_FrontFace(disp, fn) ((disp)->FrontFace = fn)
+#define CALL_Hint(disp, parameters) (*((disp)->Hint)) parameters
+#define GET_Hint(disp) ((disp)->Hint)
+#define SET_Hint(disp, fn) ((disp)->Hint = fn)
+#define CALL_Lightf(disp, parameters) (*((disp)->Lightf)) parameters
+#define GET_Lightf(disp) ((disp)->Lightf)
+#define SET_Lightf(disp, fn) ((disp)->Lightf = fn)
+#define CALL_Lightfv(disp, parameters) (*((disp)->Lightfv)) parameters
+#define GET_Lightfv(disp) ((disp)->Lightfv)
+#define SET_Lightfv(disp, fn) ((disp)->Lightfv = fn)
+#define CALL_Lighti(disp, parameters) (*((disp)->Lighti)) parameters
+#define GET_Lighti(disp) ((disp)->Lighti)
+#define SET_Lighti(disp, fn) ((disp)->Lighti = fn)
+#define CALL_Lightiv(disp, parameters) (*((disp)->Lightiv)) parameters
+#define GET_Lightiv(disp) ((disp)->Lightiv)
+#define SET_Lightiv(disp, fn) ((disp)->Lightiv = fn)
+#define CALL_LightModelf(disp, parameters) (*((disp)->LightModelf)) parameters
+#define GET_LightModelf(disp) ((disp)->LightModelf)
+#define SET_LightModelf(disp, fn) ((disp)->LightModelf = fn)
+#define CALL_LightModelfv(disp, parameters) (*((disp)->LightModelfv)) parameters
+#define GET_LightModelfv(disp) ((disp)->LightModelfv)
+#define SET_LightModelfv(disp, fn) ((disp)->LightModelfv = fn)
+#define CALL_LightModeli(disp, parameters) (*((disp)->LightModeli)) parameters
+#define GET_LightModeli(disp) ((disp)->LightModeli)
+#define SET_LightModeli(disp, fn) ((disp)->LightModeli = fn)
+#define CALL_LightModeliv(disp, parameters) (*((disp)->LightModeliv)) parameters
+#define GET_LightModeliv(disp) ((disp)->LightModeliv)
+#define SET_LightModeliv(disp, fn) ((disp)->LightModeliv = fn)
+#define CALL_LineStipple(disp, parameters) (*((disp)->LineStipple)) parameters
+#define GET_LineStipple(disp) ((disp)->LineStipple)
+#define SET_LineStipple(disp, fn) ((disp)->LineStipple = fn)
+#define CALL_LineWidth(disp, parameters) (*((disp)->LineWidth)) parameters
+#define GET_LineWidth(disp) ((disp)->LineWidth)
+#define SET_LineWidth(disp, fn) ((disp)->LineWidth = fn)
+#define CALL_Materialf(disp, parameters) (*((disp)->Materialf)) parameters
+#define GET_Materialf(disp) ((disp)->Materialf)
+#define SET_Materialf(disp, fn) ((disp)->Materialf = fn)
+#define CALL_Materialfv(disp, parameters) (*((disp)->Materialfv)) parameters
+#define GET_Materialfv(disp) ((disp)->Materialfv)
+#define SET_Materialfv(disp, fn) ((disp)->Materialfv = fn)
+#define CALL_Materiali(disp, parameters) (*((disp)->Materiali)) parameters
+#define GET_Materiali(disp) ((disp)->Materiali)
+#define SET_Materiali(disp, fn) ((disp)->Materiali = fn)
+#define CALL_Materialiv(disp, parameters) (*((disp)->Materialiv)) parameters
+#define GET_Materialiv(disp) ((disp)->Materialiv)
+#define SET_Materialiv(disp, fn) ((disp)->Materialiv = fn)
+#define CALL_PointSize(disp, parameters) (*((disp)->PointSize)) parameters
+#define GET_PointSize(disp) ((disp)->PointSize)
+#define SET_PointSize(disp, fn) ((disp)->PointSize = fn)
+#define CALL_PolygonMode(disp, parameters) (*((disp)->PolygonMode)) parameters
+#define GET_PolygonMode(disp) ((disp)->PolygonMode)
+#define SET_PolygonMode(disp, fn) ((disp)->PolygonMode = fn)
+#define CALL_PolygonStipple(disp, parameters) (*((disp)->PolygonStipple)) parameters
+#define GET_PolygonStipple(disp) ((disp)->PolygonStipple)
+#define SET_PolygonStipple(disp, fn) ((disp)->PolygonStipple = fn)
+#define CALL_Scissor(disp, parameters) (*((disp)->Scissor)) parameters
+#define GET_Scissor(disp) ((disp)->Scissor)
+#define SET_Scissor(disp, fn) ((disp)->Scissor = fn)
+#define CALL_ShadeModel(disp, parameters) (*((disp)->ShadeModel)) parameters
+#define GET_ShadeModel(disp) ((disp)->ShadeModel)
+#define SET_ShadeModel(disp, fn) ((disp)->ShadeModel = fn)
+#define CALL_TexParameterf(disp, parameters) (*((disp)->TexParameterf)) parameters
+#define GET_TexParameterf(disp) ((disp)->TexParameterf)
+#define SET_TexParameterf(disp, fn) ((disp)->TexParameterf = fn)
+#define CALL_TexParameterfv(disp, parameters) (*((disp)->TexParameterfv)) parameters
+#define GET_TexParameterfv(disp) ((disp)->TexParameterfv)
+#define SET_TexParameterfv(disp, fn) ((disp)->TexParameterfv = fn)
+#define CALL_TexParameteri(disp, parameters) (*((disp)->TexParameteri)) parameters
+#define GET_TexParameteri(disp) ((disp)->TexParameteri)
+#define SET_TexParameteri(disp, fn) ((disp)->TexParameteri = fn)
+#define CALL_TexParameteriv(disp, parameters) (*((disp)->TexParameteriv)) parameters
+#define GET_TexParameteriv(disp) ((disp)->TexParameteriv)
+#define SET_TexParameteriv(disp, fn) ((disp)->TexParameteriv = fn)
+#define CALL_TexImage1D(disp, parameters) (*((disp)->TexImage1D)) parameters
+#define GET_TexImage1D(disp) ((disp)->TexImage1D)
+#define SET_TexImage1D(disp, fn) ((disp)->TexImage1D = fn)
+#define CALL_TexImage2D(disp, parameters) (*((disp)->TexImage2D)) parameters
+#define GET_TexImage2D(disp) ((disp)->TexImage2D)
+#define SET_TexImage2D(disp, fn) ((disp)->TexImage2D = fn)
+#define CALL_TexEnvf(disp, parameters) (*((disp)->TexEnvf)) parameters
+#define GET_TexEnvf(disp) ((disp)->TexEnvf)
+#define SET_TexEnvf(disp, fn) ((disp)->TexEnvf = fn)
+#define CALL_TexEnvfv(disp, parameters) (*((disp)->TexEnvfv)) parameters
+#define GET_TexEnvfv(disp) ((disp)->TexEnvfv)
+#define SET_TexEnvfv(disp, fn) ((disp)->TexEnvfv = fn)
+#define CALL_TexEnvi(disp, parameters) (*((disp)->TexEnvi)) parameters
+#define GET_TexEnvi(disp) ((disp)->TexEnvi)
+#define SET_TexEnvi(disp, fn) ((disp)->TexEnvi = fn)
+#define CALL_TexEnviv(disp, parameters) (*((disp)->TexEnviv)) parameters
+#define GET_TexEnviv(disp) ((disp)->TexEnviv)
+#define SET_TexEnviv(disp, fn) ((disp)->TexEnviv = fn)
+#define CALL_TexGend(disp, parameters) (*((disp)->TexGend)) parameters
+#define GET_TexGend(disp) ((disp)->TexGend)
+#define SET_TexGend(disp, fn) ((disp)->TexGend = fn)
+#define CALL_TexGendv(disp, parameters) (*((disp)->TexGendv)) parameters
+#define GET_TexGendv(disp) ((disp)->TexGendv)
+#define SET_TexGendv(disp, fn) ((disp)->TexGendv = fn)
+#define CALL_TexGenf(disp, parameters) (*((disp)->TexGenf)) parameters
+#define GET_TexGenf(disp) ((disp)->TexGenf)
+#define SET_TexGenf(disp, fn) ((disp)->TexGenf = fn)
+#define CALL_TexGenfv(disp, parameters) (*((disp)->TexGenfv)) parameters
+#define GET_TexGenfv(disp) ((disp)->TexGenfv)
+#define SET_TexGenfv(disp, fn) ((disp)->TexGenfv = fn)
+#define CALL_TexGeni(disp, parameters) (*((disp)->TexGeni)) parameters
+#define GET_TexGeni(disp) ((disp)->TexGeni)
+#define SET_TexGeni(disp, fn) ((disp)->TexGeni = fn)
+#define CALL_TexGeniv(disp, parameters) (*((disp)->TexGeniv)) parameters
+#define GET_TexGeniv(disp) ((disp)->TexGeniv)
+#define SET_TexGeniv(disp, fn) ((disp)->TexGeniv = fn)
+#define CALL_FeedbackBuffer(disp, parameters) (*((disp)->FeedbackBuffer)) parameters
+#define GET_FeedbackBuffer(disp) ((disp)->FeedbackBuffer)
+#define SET_FeedbackBuffer(disp, fn) ((disp)->FeedbackBuffer = fn)
+#define CALL_SelectBuffer(disp, parameters) (*((disp)->SelectBuffer)) parameters
+#define GET_SelectBuffer(disp) ((disp)->SelectBuffer)
+#define SET_SelectBuffer(disp, fn) ((disp)->SelectBuffer = fn)
+#define CALL_RenderMode(disp, parameters) (*((disp)->RenderMode)) parameters
+#define GET_RenderMode(disp) ((disp)->RenderMode)
+#define SET_RenderMode(disp, fn) ((disp)->RenderMode = fn)
+#define CALL_InitNames(disp, parameters) (*((disp)->InitNames)) parameters
+#define GET_InitNames(disp) ((disp)->InitNames)
+#define SET_InitNames(disp, fn) ((disp)->InitNames = fn)
+#define CALL_LoadName(disp, parameters) (*((disp)->LoadName)) parameters
+#define GET_LoadName(disp) ((disp)->LoadName)
+#define SET_LoadName(disp, fn) ((disp)->LoadName = fn)
+#define CALL_PassThrough(disp, parameters) (*((disp)->PassThrough)) parameters
+#define GET_PassThrough(disp) ((disp)->PassThrough)
+#define SET_PassThrough(disp, fn) ((disp)->PassThrough = fn)
+#define CALL_PopName(disp, parameters) (*((disp)->PopName)) parameters
+#define GET_PopName(disp) ((disp)->PopName)
+#define SET_PopName(disp, fn) ((disp)->PopName = fn)
+#define CALL_PushName(disp, parameters) (*((disp)->PushName)) parameters
+#define GET_PushName(disp) ((disp)->PushName)
+#define SET_PushName(disp, fn) ((disp)->PushName = fn)
+#define CALL_DrawBuffer(disp, parameters) (*((disp)->DrawBuffer)) parameters
+#define GET_DrawBuffer(disp) ((disp)->DrawBuffer)
+#define SET_DrawBuffer(disp, fn) ((disp)->DrawBuffer = fn)
+#define CALL_Clear(disp, parameters) (*((disp)->Clear)) parameters
+#define GET_Clear(disp) ((disp)->Clear)
+#define SET_Clear(disp, fn) ((disp)->Clear = fn)
+#define CALL_ClearAccum(disp, parameters) (*((disp)->ClearAccum)) parameters
+#define GET_ClearAccum(disp) ((disp)->ClearAccum)
+#define SET_ClearAccum(disp, fn) ((disp)->ClearAccum = fn)
+#define CALL_ClearIndex(disp, parameters) (*((disp)->ClearIndex)) parameters
+#define GET_ClearIndex(disp) ((disp)->ClearIndex)
+#define SET_ClearIndex(disp, fn) ((disp)->ClearIndex = fn)
+#define CALL_ClearColor(disp, parameters) (*((disp)->ClearColor)) parameters
+#define GET_ClearColor(disp) ((disp)->ClearColor)
+#define SET_ClearColor(disp, fn) ((disp)->ClearColor = fn)
+#define CALL_ClearStencil(disp, parameters) (*((disp)->ClearStencil)) parameters
+#define GET_ClearStencil(disp) ((disp)->ClearStencil)
+#define SET_ClearStencil(disp, fn) ((disp)->ClearStencil = fn)
+#define CALL_ClearDepth(disp, parameters) (*((disp)->ClearDepth)) parameters
+#define GET_ClearDepth(disp) ((disp)->ClearDepth)
+#define SET_ClearDepth(disp, fn) ((disp)->ClearDepth = fn)
+#define CALL_StencilMask(disp, parameters) (*((disp)->StencilMask)) parameters
+#define GET_StencilMask(disp) ((disp)->StencilMask)
+#define SET_StencilMask(disp, fn) ((disp)->StencilMask = fn)
+#define CALL_ColorMask(disp, parameters) (*((disp)->ColorMask)) parameters
+#define GET_ColorMask(disp) ((disp)->ColorMask)
+#define SET_ColorMask(disp, fn) ((disp)->ColorMask = fn)
+#define CALL_DepthMask(disp, parameters) (*((disp)->DepthMask)) parameters
+#define GET_DepthMask(disp) ((disp)->DepthMask)
+#define SET_DepthMask(disp, fn) ((disp)->DepthMask = fn)
+#define CALL_IndexMask(disp, parameters) (*((disp)->IndexMask)) parameters
+#define GET_IndexMask(disp) ((disp)->IndexMask)
+#define SET_IndexMask(disp, fn) ((disp)->IndexMask = fn)
+#define CALL_Accum(disp, parameters) (*((disp)->Accum)) parameters
+#define GET_Accum(disp) ((disp)->Accum)
+#define SET_Accum(disp, fn) ((disp)->Accum = fn)
+#define CALL_Disable(disp, parameters) (*((disp)->Disable)) parameters
+#define GET_Disable(disp) ((disp)->Disable)
+#define SET_Disable(disp, fn) ((disp)->Disable = fn)
+#define CALL_Enable(disp, parameters) (*((disp)->Enable)) parameters
+#define GET_Enable(disp) ((disp)->Enable)
+#define SET_Enable(disp, fn) ((disp)->Enable = fn)
+#define CALL_Finish(disp, parameters) (*((disp)->Finish)) parameters
+#define GET_Finish(disp) ((disp)->Finish)
+#define SET_Finish(disp, fn) ((disp)->Finish = fn)
+#define CALL_Flush(disp, parameters) (*((disp)->Flush)) parameters
+#define GET_Flush(disp) ((disp)->Flush)
+#define SET_Flush(disp, fn) ((disp)->Flush = fn)
+#define CALL_PopAttrib(disp, parameters) (*((disp)->PopAttrib)) parameters
+#define GET_PopAttrib(disp) ((disp)->PopAttrib)
+#define SET_PopAttrib(disp, fn) ((disp)->PopAttrib = fn)
+#define CALL_PushAttrib(disp, parameters) (*((disp)->PushAttrib)) parameters
+#define GET_PushAttrib(disp) ((disp)->PushAttrib)
+#define SET_PushAttrib(disp, fn) ((disp)->PushAttrib = fn)
+#define CALL_Map1d(disp, parameters) (*((disp)->Map1d)) parameters
+#define GET_Map1d(disp) ((disp)->Map1d)
+#define SET_Map1d(disp, fn) ((disp)->Map1d = fn)
+#define CALL_Map1f(disp, parameters) (*((disp)->Map1f)) parameters
+#define GET_Map1f(disp) ((disp)->Map1f)
+#define SET_Map1f(disp, fn) ((disp)->Map1f = fn)
+#define CALL_Map2d(disp, parameters) (*((disp)->Map2d)) parameters
+#define GET_Map2d(disp) ((disp)->Map2d)
+#define SET_Map2d(disp, fn) ((disp)->Map2d = fn)
+#define CALL_Map2f(disp, parameters) (*((disp)->Map2f)) parameters
+#define GET_Map2f(disp) ((disp)->Map2f)
+#define SET_Map2f(disp, fn) ((disp)->Map2f = fn)
+#define CALL_MapGrid1d(disp, parameters) (*((disp)->MapGrid1d)) parameters
+#define GET_MapGrid1d(disp) ((disp)->MapGrid1d)
+#define SET_MapGrid1d(disp, fn) ((disp)->MapGrid1d = fn)
+#define CALL_MapGrid1f(disp, parameters) (*((disp)->MapGrid1f)) parameters
+#define GET_MapGrid1f(disp) ((disp)->MapGrid1f)
+#define SET_MapGrid1f(disp, fn) ((disp)->MapGrid1f = fn)
+#define CALL_MapGrid2d(disp, parameters) (*((disp)->MapGrid2d)) parameters
+#define GET_MapGrid2d(disp) ((disp)->MapGrid2d)
+#define SET_MapGrid2d(disp, fn) ((disp)->MapGrid2d = fn)
+#define CALL_MapGrid2f(disp, parameters) (*((disp)->MapGrid2f)) parameters
+#define GET_MapGrid2f(disp) ((disp)->MapGrid2f)
+#define SET_MapGrid2f(disp, fn) ((disp)->MapGrid2f = fn)
+#define CALL_EvalCoord1d(disp, parameters) (*((disp)->EvalCoord1d)) parameters
+#define GET_EvalCoord1d(disp) ((disp)->EvalCoord1d)
+#define SET_EvalCoord1d(disp, fn) ((disp)->EvalCoord1d = fn)
+#define CALL_EvalCoord1dv(disp, parameters) (*((disp)->EvalCoord1dv)) parameters
+#define GET_EvalCoord1dv(disp) ((disp)->EvalCoord1dv)
+#define SET_EvalCoord1dv(disp, fn) ((disp)->EvalCoord1dv = fn)
+#define CALL_EvalCoord1f(disp, parameters) (*((disp)->EvalCoord1f)) parameters
+#define GET_EvalCoord1f(disp) ((disp)->EvalCoord1f)
+#define SET_EvalCoord1f(disp, fn) ((disp)->EvalCoord1f = fn)
+#define CALL_EvalCoord1fv(disp, parameters) (*((disp)->EvalCoord1fv)) parameters
+#define GET_EvalCoord1fv(disp) ((disp)->EvalCoord1fv)
+#define SET_EvalCoord1fv(disp, fn) ((disp)->EvalCoord1fv = fn)
+#define CALL_EvalCoord2d(disp, parameters) (*((disp)->EvalCoord2d)) parameters
+#define GET_EvalCoord2d(disp) ((disp)->EvalCoord2d)
+#define SET_EvalCoord2d(disp, fn) ((disp)->EvalCoord2d = fn)
+#define CALL_EvalCoord2dv(disp, parameters) (*((disp)->EvalCoord2dv)) parameters
+#define GET_EvalCoord2dv(disp) ((disp)->EvalCoord2dv)
+#define SET_EvalCoord2dv(disp, fn) ((disp)->EvalCoord2dv = fn)
+#define CALL_EvalCoord2f(disp, parameters) (*((disp)->EvalCoord2f)) parameters
+#define GET_EvalCoord2f(disp) ((disp)->EvalCoord2f)
+#define SET_EvalCoord2f(disp, fn) ((disp)->EvalCoord2f = fn)
+#define CALL_EvalCoord2fv(disp, parameters) (*((disp)->EvalCoord2fv)) parameters
+#define GET_EvalCoord2fv(disp) ((disp)->EvalCoord2fv)
+#define SET_EvalCoord2fv(disp, fn) ((disp)->EvalCoord2fv = fn)
+#define CALL_EvalMesh1(disp, parameters) (*((disp)->EvalMesh1)) parameters
+#define GET_EvalMesh1(disp) ((disp)->EvalMesh1)
+#define SET_EvalMesh1(disp, fn) ((disp)->EvalMesh1 = fn)
+#define CALL_EvalPoint1(disp, parameters) (*((disp)->EvalPoint1)) parameters
+#define GET_EvalPoint1(disp) ((disp)->EvalPoint1)
+#define SET_EvalPoint1(disp, fn) ((disp)->EvalPoint1 = fn)
+#define CALL_EvalMesh2(disp, parameters) (*((disp)->EvalMesh2)) parameters
+#define GET_EvalMesh2(disp) ((disp)->EvalMesh2)
+#define SET_EvalMesh2(disp, fn) ((disp)->EvalMesh2 = fn)
+#define CALL_EvalPoint2(disp, parameters) (*((disp)->EvalPoint2)) parameters
+#define GET_EvalPoint2(disp) ((disp)->EvalPoint2)
+#define SET_EvalPoint2(disp, fn) ((disp)->EvalPoint2 = fn)
+#define CALL_AlphaFunc(disp, parameters) (*((disp)->AlphaFunc)) parameters
+#define GET_AlphaFunc(disp) ((disp)->AlphaFunc)
+#define SET_AlphaFunc(disp, fn) ((disp)->AlphaFunc = fn)
+#define CALL_BlendFunc(disp, parameters) (*((disp)->BlendFunc)) parameters
+#define GET_BlendFunc(disp) ((disp)->BlendFunc)
+#define SET_BlendFunc(disp, fn) ((disp)->BlendFunc = fn)
+#define CALL_LogicOp(disp, parameters) (*((disp)->LogicOp)) parameters
+#define GET_LogicOp(disp) ((disp)->LogicOp)
+#define SET_LogicOp(disp, fn) ((disp)->LogicOp = fn)
+#define CALL_StencilFunc(disp, parameters) (*((disp)->StencilFunc)) parameters
+#define GET_StencilFunc(disp) ((disp)->StencilFunc)
+#define SET_StencilFunc(disp, fn) ((disp)->StencilFunc = fn)
+#define CALL_StencilOp(disp, parameters) (*((disp)->StencilOp)) parameters
+#define GET_StencilOp(disp) ((disp)->StencilOp)
+#define SET_StencilOp(disp, fn) ((disp)->StencilOp = fn)
+#define CALL_DepthFunc(disp, parameters) (*((disp)->DepthFunc)) parameters
+#define GET_DepthFunc(disp) ((disp)->DepthFunc)
+#define SET_DepthFunc(disp, fn) ((disp)->DepthFunc = fn)
+#define CALL_PixelZoom(disp, parameters) (*((disp)->PixelZoom)) parameters
+#define GET_PixelZoom(disp) ((disp)->PixelZoom)
+#define SET_PixelZoom(disp, fn) ((disp)->PixelZoom = fn)
+#define CALL_PixelTransferf(disp, parameters) (*((disp)->PixelTransferf)) parameters
+#define GET_PixelTransferf(disp) ((disp)->PixelTransferf)
+#define SET_PixelTransferf(disp, fn) ((disp)->PixelTransferf = fn)
+#define CALL_PixelTransferi(disp, parameters) (*((disp)->PixelTransferi)) parameters
+#define GET_PixelTransferi(disp) ((disp)->PixelTransferi)
+#define SET_PixelTransferi(disp, fn) ((disp)->PixelTransferi = fn)
+#define CALL_PixelStoref(disp, parameters) (*((disp)->PixelStoref)) parameters
+#define GET_PixelStoref(disp) ((disp)->PixelStoref)
+#define SET_PixelStoref(disp, fn) ((disp)->PixelStoref = fn)
+#define CALL_PixelStorei(disp, parameters) (*((disp)->PixelStorei)) parameters
+#define GET_PixelStorei(disp) ((disp)->PixelStorei)
+#define SET_PixelStorei(disp, fn) ((disp)->PixelStorei = fn)
+#define CALL_PixelMapfv(disp, parameters) (*((disp)->PixelMapfv)) parameters
+#define GET_PixelMapfv(disp) ((disp)->PixelMapfv)
+#define SET_PixelMapfv(disp, fn) ((disp)->PixelMapfv = fn)
+#define CALL_PixelMapuiv(disp, parameters) (*((disp)->PixelMapuiv)) parameters
+#define GET_PixelMapuiv(disp) ((disp)->PixelMapuiv)
+#define SET_PixelMapuiv(disp, fn) ((disp)->PixelMapuiv = fn)
+#define CALL_PixelMapusv(disp, parameters) (*((disp)->PixelMapusv)) parameters
+#define GET_PixelMapusv(disp) ((disp)->PixelMapusv)
+#define SET_PixelMapusv(disp, fn) ((disp)->PixelMapusv = fn)
+#define CALL_ReadBuffer(disp, parameters) (*((disp)->ReadBuffer)) parameters
+#define GET_ReadBuffer(disp) ((disp)->ReadBuffer)
+#define SET_ReadBuffer(disp, fn) ((disp)->ReadBuffer = fn)
+#define CALL_CopyPixels(disp, parameters) (*((disp)->CopyPixels)) parameters
+#define GET_CopyPixels(disp) ((disp)->CopyPixels)
+#define SET_CopyPixels(disp, fn) ((disp)->CopyPixels = fn)
+#define CALL_ReadPixels(disp, parameters) (*((disp)->ReadPixels)) parameters
+#define GET_ReadPixels(disp) ((disp)->ReadPixels)
+#define SET_ReadPixels(disp, fn) ((disp)->ReadPixels = fn)
+#define CALL_DrawPixels(disp, parameters) (*((disp)->DrawPixels)) parameters
+#define GET_DrawPixels(disp) ((disp)->DrawPixels)
+#define SET_DrawPixels(disp, fn) ((disp)->DrawPixels = fn)
+#define CALL_GetBooleanv(disp, parameters) (*((disp)->GetBooleanv)) parameters
+#define GET_GetBooleanv(disp) ((disp)->GetBooleanv)
+#define SET_GetBooleanv(disp, fn) ((disp)->GetBooleanv = fn)
+#define CALL_GetClipPlane(disp, parameters) (*((disp)->GetClipPlane)) parameters
+#define GET_GetClipPlane(disp) ((disp)->GetClipPlane)
+#define SET_GetClipPlane(disp, fn) ((disp)->GetClipPlane = fn)
+#define CALL_GetDoublev(disp, parameters) (*((disp)->GetDoublev)) parameters
+#define GET_GetDoublev(disp) ((disp)->GetDoublev)
+#define SET_GetDoublev(disp, fn) ((disp)->GetDoublev = fn)
+#define CALL_GetError(disp, parameters) (*((disp)->GetError)) parameters
+#define GET_GetError(disp) ((disp)->GetError)
+#define SET_GetError(disp, fn) ((disp)->GetError = fn)
+#define CALL_GetFloatv(disp, parameters) (*((disp)->GetFloatv)) parameters
+#define GET_GetFloatv(disp) ((disp)->GetFloatv)
+#define SET_GetFloatv(disp, fn) ((disp)->GetFloatv = fn)
+#define CALL_GetIntegerv(disp, parameters) (*((disp)->GetIntegerv)) parameters
+#define GET_GetIntegerv(disp) ((disp)->GetIntegerv)
+#define SET_GetIntegerv(disp, fn) ((disp)->GetIntegerv = fn)
+#define CALL_GetLightfv(disp, parameters) (*((disp)->GetLightfv)) parameters
+#define GET_GetLightfv(disp) ((disp)->GetLightfv)
+#define SET_GetLightfv(disp, fn) ((disp)->GetLightfv = fn)
+#define CALL_GetLightiv(disp, parameters) (*((disp)->GetLightiv)) parameters
+#define GET_GetLightiv(disp) ((disp)->GetLightiv)
+#define SET_GetLightiv(disp, fn) ((disp)->GetLightiv = fn)
+#define CALL_GetMapdv(disp, parameters) (*((disp)->GetMapdv)) parameters
+#define GET_GetMapdv(disp) ((disp)->GetMapdv)
+#define SET_GetMapdv(disp, fn) ((disp)->GetMapdv = fn)
+#define CALL_GetMapfv(disp, parameters) (*((disp)->GetMapfv)) parameters
+#define GET_GetMapfv(disp) ((disp)->GetMapfv)
+#define SET_GetMapfv(disp, fn) ((disp)->GetMapfv = fn)
+#define CALL_GetMapiv(disp, parameters) (*((disp)->GetMapiv)) parameters
+#define GET_GetMapiv(disp) ((disp)->GetMapiv)
+#define SET_GetMapiv(disp, fn) ((disp)->GetMapiv = fn)
+#define CALL_GetMaterialfv(disp, parameters) (*((disp)->GetMaterialfv)) parameters
+#define GET_GetMaterialfv(disp) ((disp)->GetMaterialfv)
+#define SET_GetMaterialfv(disp, fn) ((disp)->GetMaterialfv = fn)
+#define CALL_GetMaterialiv(disp, parameters) (*((disp)->GetMaterialiv)) parameters
+#define GET_GetMaterialiv(disp) ((disp)->GetMaterialiv)
+#define SET_GetMaterialiv(disp, fn) ((disp)->GetMaterialiv = fn)
+#define CALL_GetPixelMapfv(disp, parameters) (*((disp)->GetPixelMapfv)) parameters
+#define GET_GetPixelMapfv(disp) ((disp)->GetPixelMapfv)
+#define SET_GetPixelMapfv(disp, fn) ((disp)->GetPixelMapfv = fn)
+#define CALL_GetPixelMapuiv(disp, parameters) (*((disp)->GetPixelMapuiv)) parameters
+#define GET_GetPixelMapuiv(disp) ((disp)->GetPixelMapuiv)
+#define SET_GetPixelMapuiv(disp, fn) ((disp)->GetPixelMapuiv = fn)
+#define CALL_GetPixelMapusv(disp, parameters) (*((disp)->GetPixelMapusv)) parameters
+#define GET_GetPixelMapusv(disp) ((disp)->GetPixelMapusv)
+#define SET_GetPixelMapusv(disp, fn) ((disp)->GetPixelMapusv = fn)
+#define CALL_GetPolygonStipple(disp, parameters) (*((disp)->GetPolygonStipple)) parameters
+#define GET_GetPolygonStipple(disp) ((disp)->GetPolygonStipple)
+#define SET_GetPolygonStipple(disp, fn) ((disp)->GetPolygonStipple = fn)
+#define CALL_GetString(disp, parameters) (*((disp)->GetString)) parameters
+#define GET_GetString(disp) ((disp)->GetString)
+#define SET_GetString(disp, fn) ((disp)->GetString = fn)
+#define CALL_GetTexEnvfv(disp, parameters) (*((disp)->GetTexEnvfv)) parameters
+#define GET_GetTexEnvfv(disp) ((disp)->GetTexEnvfv)
+#define SET_GetTexEnvfv(disp, fn) ((disp)->GetTexEnvfv = fn)
+#define CALL_GetTexEnviv(disp, parameters) (*((disp)->GetTexEnviv)) parameters
+#define GET_GetTexEnviv(disp) ((disp)->GetTexEnviv)
+#define SET_GetTexEnviv(disp, fn) ((disp)->GetTexEnviv = fn)
+#define CALL_GetTexGendv(disp, parameters) (*((disp)->GetTexGendv)) parameters
+#define GET_GetTexGendv(disp) ((disp)->GetTexGendv)
+#define SET_GetTexGendv(disp, fn) ((disp)->GetTexGendv = fn)
+#define CALL_GetTexGenfv(disp, parameters) (*((disp)->GetTexGenfv)) parameters
+#define GET_GetTexGenfv(disp) ((disp)->GetTexGenfv)
+#define SET_GetTexGenfv(disp, fn) ((disp)->GetTexGenfv = fn)
+#define CALL_GetTexGeniv(disp, parameters) (*((disp)->GetTexGeniv)) parameters
+#define GET_GetTexGeniv(disp) ((disp)->GetTexGeniv)
+#define SET_GetTexGeniv(disp, fn) ((disp)->GetTexGeniv = fn)
+#define CALL_GetTexImage(disp, parameters) (*((disp)->GetTexImage)) parameters
+#define GET_GetTexImage(disp) ((disp)->GetTexImage)
+#define SET_GetTexImage(disp, fn) ((disp)->GetTexImage = fn)
+#define CALL_GetTexParameterfv(disp, parameters) (*((disp)->GetTexParameterfv)) parameters
+#define GET_GetTexParameterfv(disp) ((disp)->GetTexParameterfv)
+#define SET_GetTexParameterfv(disp, fn) ((disp)->GetTexParameterfv = fn)
+#define CALL_GetTexParameteriv(disp, parameters) (*((disp)->GetTexParameteriv)) parameters
+#define GET_GetTexParameteriv(disp) ((disp)->GetTexParameteriv)
+#define SET_GetTexParameteriv(disp, fn) ((disp)->GetTexParameteriv = fn)
+#define CALL_GetTexLevelParameterfv(disp, parameters) (*((disp)->GetTexLevelParameterfv)) parameters
+#define GET_GetTexLevelParameterfv(disp) ((disp)->GetTexLevelParameterfv)
+#define SET_GetTexLevelParameterfv(disp, fn) ((disp)->GetTexLevelParameterfv = fn)
+#define CALL_GetTexLevelParameteriv(disp, parameters) (*((disp)->GetTexLevelParameteriv)) parameters
+#define GET_GetTexLevelParameteriv(disp) ((disp)->GetTexLevelParameteriv)
+#define SET_GetTexLevelParameteriv(disp, fn) ((disp)->GetTexLevelParameteriv = fn)
+#define CALL_IsEnabled(disp, parameters) (*((disp)->IsEnabled)) parameters
+#define GET_IsEnabled(disp) ((disp)->IsEnabled)
+#define SET_IsEnabled(disp, fn) ((disp)->IsEnabled = fn)
+#define CALL_IsList(disp, parameters) (*((disp)->IsList)) parameters
+#define GET_IsList(disp) ((disp)->IsList)
+#define SET_IsList(disp, fn) ((disp)->IsList = fn)
+#define CALL_DepthRange(disp, parameters) (*((disp)->DepthRange)) parameters
+#define GET_DepthRange(disp) ((disp)->DepthRange)
+#define SET_DepthRange(disp, fn) ((disp)->DepthRange = fn)
+#define CALL_Frustum(disp, parameters) (*((disp)->Frustum)) parameters
+#define GET_Frustum(disp) ((disp)->Frustum)
+#define SET_Frustum(disp, fn) ((disp)->Frustum = fn)
+#define CALL_LoadIdentity(disp, parameters) (*((disp)->LoadIdentity)) parameters
+#define GET_LoadIdentity(disp) ((disp)->LoadIdentity)
+#define SET_LoadIdentity(disp, fn) ((disp)->LoadIdentity = fn)
+#define CALL_LoadMatrixf(disp, parameters) (*((disp)->LoadMatrixf)) parameters
+#define GET_LoadMatrixf(disp) ((disp)->LoadMatrixf)
+#define SET_LoadMatrixf(disp, fn) ((disp)->LoadMatrixf = fn)
+#define CALL_LoadMatrixd(disp, parameters) (*((disp)->LoadMatrixd)) parameters
+#define GET_LoadMatrixd(disp) ((disp)->LoadMatrixd)
+#define SET_LoadMatrixd(disp, fn) ((disp)->LoadMatrixd = fn)
+#define CALL_MatrixMode(disp, parameters) (*((disp)->MatrixMode)) parameters
+#define GET_MatrixMode(disp) ((disp)->MatrixMode)
+#define SET_MatrixMode(disp, fn) ((disp)->MatrixMode = fn)
+#define CALL_MultMatrixf(disp, parameters) (*((disp)->MultMatrixf)) parameters
+#define GET_MultMatrixf(disp) ((disp)->MultMatrixf)
+#define SET_MultMatrixf(disp, fn) ((disp)->MultMatrixf = fn)
+#define CALL_MultMatrixd(disp, parameters) (*((disp)->MultMatrixd)) parameters
+#define GET_MultMatrixd(disp) ((disp)->MultMatrixd)
+#define SET_MultMatrixd(disp, fn) ((disp)->MultMatrixd = fn)
+#define CALL_Ortho(disp, parameters) (*((disp)->Ortho)) parameters
+#define GET_Ortho(disp) ((disp)->Ortho)
+#define SET_Ortho(disp, fn) ((disp)->Ortho = fn)
+#define CALL_PopMatrix(disp, parameters) (*((disp)->PopMatrix)) parameters
+#define GET_PopMatrix(disp) ((disp)->PopMatrix)
+#define SET_PopMatrix(disp, fn) ((disp)->PopMatrix = fn)
+#define CALL_PushMatrix(disp, parameters) (*((disp)->PushMatrix)) parameters
+#define GET_PushMatrix(disp) ((disp)->PushMatrix)
+#define SET_PushMatrix(disp, fn) ((disp)->PushMatrix = fn)
+#define CALL_Rotated(disp, parameters) (*((disp)->Rotated)) parameters
+#define GET_Rotated(disp) ((disp)->Rotated)
+#define SET_Rotated(disp, fn) ((disp)->Rotated = fn)
+#define CALL_Rotatef(disp, parameters) (*((disp)->Rotatef)) parameters
+#define GET_Rotatef(disp) ((disp)->Rotatef)
+#define SET_Rotatef(disp, fn) ((disp)->Rotatef = fn)
+#define CALL_Scaled(disp, parameters) (*((disp)->Scaled)) parameters
+#define GET_Scaled(disp) ((disp)->Scaled)
+#define SET_Scaled(disp, fn) ((disp)->Scaled = fn)
+#define CALL_Scalef(disp, parameters) (*((disp)->Scalef)) parameters
+#define GET_Scalef(disp) ((disp)->Scalef)
+#define SET_Scalef(disp, fn) ((disp)->Scalef = fn)
+#define CALL_Translated(disp, parameters) (*((disp)->Translated)) parameters
+#define GET_Translated(disp) ((disp)->Translated)
+#define SET_Translated(disp, fn) ((disp)->Translated = fn)
+#define CALL_Translatef(disp, parameters) (*((disp)->Translatef)) parameters
+#define GET_Translatef(disp) ((disp)->Translatef)
+#define SET_Translatef(disp, fn) ((disp)->Translatef = fn)
+#define CALL_Viewport(disp, parameters) (*((disp)->Viewport)) parameters
+#define GET_Viewport(disp) ((disp)->Viewport)
+#define SET_Viewport(disp, fn) ((disp)->Viewport = fn)
+#define CALL_ArrayElement(disp, parameters) (*((disp)->ArrayElement)) parameters
+#define GET_ArrayElement(disp) ((disp)->ArrayElement)
+#define SET_ArrayElement(disp, fn) ((disp)->ArrayElement = fn)
+#define CALL_BindTexture(disp, parameters) (*((disp)->BindTexture)) parameters
+#define GET_BindTexture(disp) ((disp)->BindTexture)
+#define SET_BindTexture(disp, fn) ((disp)->BindTexture = fn)
+#define CALL_ColorPointer(disp, parameters) (*((disp)->ColorPointer)) parameters
+#define GET_ColorPointer(disp) ((disp)->ColorPointer)
+#define SET_ColorPointer(disp, fn) ((disp)->ColorPointer = fn)
+#define CALL_DisableClientState(disp, parameters) (*((disp)->DisableClientState)) parameters
+#define GET_DisableClientState(disp) ((disp)->DisableClientState)
+#define SET_DisableClientState(disp, fn) ((disp)->DisableClientState = fn)
+#define CALL_DrawArrays(disp, parameters) (*((disp)->DrawArrays)) parameters
+#define GET_DrawArrays(disp) ((disp)->DrawArrays)
+#define SET_DrawArrays(disp, fn) ((disp)->DrawArrays = fn)
+#define CALL_DrawElements(disp, parameters) (*((disp)->DrawElements)) parameters
+#define GET_DrawElements(disp) ((disp)->DrawElements)
+#define SET_DrawElements(disp, fn) ((disp)->DrawElements = fn)
+#define CALL_EdgeFlagPointer(disp, parameters) (*((disp)->EdgeFlagPointer)) parameters
+#define GET_EdgeFlagPointer(disp) ((disp)->EdgeFlagPointer)
+#define SET_EdgeFlagPointer(disp, fn) ((disp)->EdgeFlagPointer = fn)
+#define CALL_EnableClientState(disp, parameters) (*((disp)->EnableClientState)) parameters
+#define GET_EnableClientState(disp) ((disp)->EnableClientState)
+#define SET_EnableClientState(disp, fn) ((disp)->EnableClientState = fn)
+#define CALL_IndexPointer(disp, parameters) (*((disp)->IndexPointer)) parameters
+#define GET_IndexPointer(disp) ((disp)->IndexPointer)
+#define SET_IndexPointer(disp, fn) ((disp)->IndexPointer = fn)
+#define CALL_Indexub(disp, parameters) (*((disp)->Indexub)) parameters
+#define GET_Indexub(disp) ((disp)->Indexub)
+#define SET_Indexub(disp, fn) ((disp)->Indexub = fn)
+#define CALL_Indexubv(disp, parameters) (*((disp)->Indexubv)) parameters
+#define GET_Indexubv(disp) ((disp)->Indexubv)
+#define SET_Indexubv(disp, fn) ((disp)->Indexubv = fn)
+#define CALL_InterleavedArrays(disp, parameters) (*((disp)->InterleavedArrays)) parameters
+#define GET_InterleavedArrays(disp) ((disp)->InterleavedArrays)
+#define SET_InterleavedArrays(disp, fn) ((disp)->InterleavedArrays = fn)
+#define CALL_NormalPointer(disp, parameters) (*((disp)->NormalPointer)) parameters
+#define GET_NormalPointer(disp) ((disp)->NormalPointer)
+#define SET_NormalPointer(disp, fn) ((disp)->NormalPointer = fn)
+#define CALL_PolygonOffset(disp, parameters) (*((disp)->PolygonOffset)) parameters
+#define GET_PolygonOffset(disp) ((disp)->PolygonOffset)
+#define SET_PolygonOffset(disp, fn) ((disp)->PolygonOffset = fn)
+#define CALL_TexCoordPointer(disp, parameters) (*((disp)->TexCoordPointer)) parameters
+#define GET_TexCoordPointer(disp) ((disp)->TexCoordPointer)
+#define SET_TexCoordPointer(disp, fn) ((disp)->TexCoordPointer = fn)
+#define CALL_VertexPointer(disp, parameters) (*((disp)->VertexPointer)) parameters
+#define GET_VertexPointer(disp) ((disp)->VertexPointer)
+#define SET_VertexPointer(disp, fn) ((disp)->VertexPointer = fn)
+#define CALL_AreTexturesResident(disp, parameters) (*((disp)->AreTexturesResident)) parameters
+#define GET_AreTexturesResident(disp) ((disp)->AreTexturesResident)
+#define SET_AreTexturesResident(disp, fn) ((disp)->AreTexturesResident = fn)
+#define CALL_CopyTexImage1D(disp, parameters) (*((disp)->CopyTexImage1D)) parameters
+#define GET_CopyTexImage1D(disp) ((disp)->CopyTexImage1D)
+#define SET_CopyTexImage1D(disp, fn) ((disp)->CopyTexImage1D = fn)
+#define CALL_CopyTexImage2D(disp, parameters) (*((disp)->CopyTexImage2D)) parameters
+#define GET_CopyTexImage2D(disp) ((disp)->CopyTexImage2D)
+#define SET_CopyTexImage2D(disp, fn) ((disp)->CopyTexImage2D = fn)
+#define CALL_CopyTexSubImage1D(disp, parameters) (*((disp)->CopyTexSubImage1D)) parameters
+#define GET_CopyTexSubImage1D(disp) ((disp)->CopyTexSubImage1D)
+#define SET_CopyTexSubImage1D(disp, fn) ((disp)->CopyTexSubImage1D = fn)
+#define CALL_CopyTexSubImage2D(disp, parameters) (*((disp)->CopyTexSubImage2D)) parameters
+#define GET_CopyTexSubImage2D(disp) ((disp)->CopyTexSubImage2D)
+#define SET_CopyTexSubImage2D(disp, fn) ((disp)->CopyTexSubImage2D = fn)
+#define CALL_DeleteTextures(disp, parameters) (*((disp)->DeleteTextures)) parameters
+#define GET_DeleteTextures(disp) ((disp)->DeleteTextures)
+#define SET_DeleteTextures(disp, fn) ((disp)->DeleteTextures = fn)
+#define CALL_GenTextures(disp, parameters) (*((disp)->GenTextures)) parameters
+#define GET_GenTextures(disp) ((disp)->GenTextures)
+#define SET_GenTextures(disp, fn) ((disp)->GenTextures = fn)
+#define CALL_GetPointerv(disp, parameters) (*((disp)->GetPointerv)) parameters
+#define GET_GetPointerv(disp) ((disp)->GetPointerv)
+#define SET_GetPointerv(disp, fn) ((disp)->GetPointerv = fn)
+#define CALL_IsTexture(disp, parameters) (*((disp)->IsTexture)) parameters
+#define GET_IsTexture(disp) ((disp)->IsTexture)
+#define SET_IsTexture(disp, fn) ((disp)->IsTexture = fn)
+#define CALL_PrioritizeTextures(disp, parameters) (*((disp)->PrioritizeTextures)) parameters
+#define GET_PrioritizeTextures(disp) ((disp)->PrioritizeTextures)
+#define SET_PrioritizeTextures(disp, fn) ((disp)->PrioritizeTextures = fn)
+#define CALL_TexSubImage1D(disp, parameters) (*((disp)->TexSubImage1D)) parameters
+#define GET_TexSubImage1D(disp) ((disp)->TexSubImage1D)
+#define SET_TexSubImage1D(disp, fn) ((disp)->TexSubImage1D = fn)
+#define CALL_TexSubImage2D(disp, parameters) (*((disp)->TexSubImage2D)) parameters
+#define GET_TexSubImage2D(disp) ((disp)->TexSubImage2D)
+#define SET_TexSubImage2D(disp, fn) ((disp)->TexSubImage2D = fn)
+#define CALL_PopClientAttrib(disp, parameters) (*((disp)->PopClientAttrib)) parameters
+#define GET_PopClientAttrib(disp) ((disp)->PopClientAttrib)
+#define SET_PopClientAttrib(disp, fn) ((disp)->PopClientAttrib = fn)
+#define CALL_PushClientAttrib(disp, parameters) (*((disp)->PushClientAttrib)) parameters
+#define GET_PushClientAttrib(disp) ((disp)->PushClientAttrib)
+#define SET_PushClientAttrib(disp, fn) ((disp)->PushClientAttrib = fn)
+#define CALL_BlendColor(disp, parameters) (*((disp)->BlendColor)) parameters
+#define GET_BlendColor(disp) ((disp)->BlendColor)
+#define SET_BlendColor(disp, fn) ((disp)->BlendColor = fn)
+#define CALL_BlendEquation(disp, parameters) (*((disp)->BlendEquation)) parameters
+#define GET_BlendEquation(disp) ((disp)->BlendEquation)
+#define SET_BlendEquation(disp, fn) ((disp)->BlendEquation = fn)
+#define CALL_DrawRangeElements(disp, parameters) (*((disp)->DrawRangeElements)) parameters
+#define GET_DrawRangeElements(disp) ((disp)->DrawRangeElements)
+#define SET_DrawRangeElements(disp, fn) ((disp)->DrawRangeElements = fn)
+#define CALL_ColorTable(disp, parameters) (*((disp)->ColorTable)) parameters
+#define GET_ColorTable(disp) ((disp)->ColorTable)
+#define SET_ColorTable(disp, fn) ((disp)->ColorTable = fn)
+#define CALL_ColorTableParameterfv(disp, parameters) (*((disp)->ColorTableParameterfv)) parameters
+#define GET_ColorTableParameterfv(disp) ((disp)->ColorTableParameterfv)
+#define SET_ColorTableParameterfv(disp, fn) ((disp)->ColorTableParameterfv = fn)
+#define CALL_ColorTableParameteriv(disp, parameters) (*((disp)->ColorTableParameteriv)) parameters
+#define GET_ColorTableParameteriv(disp) ((disp)->ColorTableParameteriv)
+#define SET_ColorTableParameteriv(disp, fn) ((disp)->ColorTableParameteriv = fn)
+#define CALL_CopyColorTable(disp, parameters) (*((disp)->CopyColorTable)) parameters
+#define GET_CopyColorTable(disp) ((disp)->CopyColorTable)
+#define SET_CopyColorTable(disp, fn) ((disp)->CopyColorTable = fn)
+#define CALL_GetColorTable(disp, parameters) (*((disp)->GetColorTable)) parameters
+#define GET_GetColorTable(disp) ((disp)->GetColorTable)
+#define SET_GetColorTable(disp, fn) ((disp)->GetColorTable = fn)
+#define CALL_GetColorTableParameterfv(disp, parameters) (*((disp)->GetColorTableParameterfv)) parameters
+#define GET_GetColorTableParameterfv(disp) ((disp)->GetColorTableParameterfv)
+#define SET_GetColorTableParameterfv(disp, fn) ((disp)->GetColorTableParameterfv = fn)
+#define CALL_GetColorTableParameteriv(disp, parameters) (*((disp)->GetColorTableParameteriv)) parameters
+#define GET_GetColorTableParameteriv(disp) ((disp)->GetColorTableParameteriv)
+#define SET_GetColorTableParameteriv(disp, fn) ((disp)->GetColorTableParameteriv = fn)
+#define CALL_ColorSubTable(disp, parameters) (*((disp)->ColorSubTable)) parameters
+#define GET_ColorSubTable(disp) ((disp)->ColorSubTable)
+#define SET_ColorSubTable(disp, fn) ((disp)->ColorSubTable = fn)
+#define CALL_CopyColorSubTable(disp, parameters) (*((disp)->CopyColorSubTable)) parameters
+#define GET_CopyColorSubTable(disp) ((disp)->CopyColorSubTable)
+#define SET_CopyColorSubTable(disp, fn) ((disp)->CopyColorSubTable = fn)
+#define CALL_ConvolutionFilter1D(disp, parameters) (*((disp)->ConvolutionFilter1D)) parameters
+#define GET_ConvolutionFilter1D(disp) ((disp)->ConvolutionFilter1D)
+#define SET_ConvolutionFilter1D(disp, fn) ((disp)->ConvolutionFilter1D = fn)
+#define CALL_ConvolutionFilter2D(disp, parameters) (*((disp)->ConvolutionFilter2D)) parameters
+#define GET_ConvolutionFilter2D(disp) ((disp)->ConvolutionFilter2D)
+#define SET_ConvolutionFilter2D(disp, fn) ((disp)->ConvolutionFilter2D = fn)
+#define CALL_ConvolutionParameterf(disp, parameters) (*((disp)->ConvolutionParameterf)) parameters
+#define GET_ConvolutionParameterf(disp) ((disp)->ConvolutionParameterf)
+#define SET_ConvolutionParameterf(disp, fn) ((disp)->ConvolutionParameterf = fn)
+#define CALL_ConvolutionParameterfv(disp, parameters) (*((disp)->ConvolutionParameterfv)) parameters
+#define GET_ConvolutionParameterfv(disp) ((disp)->ConvolutionParameterfv)
+#define SET_ConvolutionParameterfv(disp, fn) ((disp)->ConvolutionParameterfv = fn)
+#define CALL_ConvolutionParameteri(disp, parameters) (*((disp)->ConvolutionParameteri)) parameters
+#define GET_ConvolutionParameteri(disp) ((disp)->ConvolutionParameteri)
+#define SET_ConvolutionParameteri(disp, fn) ((disp)->ConvolutionParameteri = fn)
+#define CALL_ConvolutionParameteriv(disp, parameters) (*((disp)->ConvolutionParameteriv)) parameters
+#define GET_ConvolutionParameteriv(disp) ((disp)->ConvolutionParameteriv)
+#define SET_ConvolutionParameteriv(disp, fn) ((disp)->ConvolutionParameteriv = fn)
+#define CALL_CopyConvolutionFilter1D(disp, parameters) (*((disp)->CopyConvolutionFilter1D)) parameters
+#define GET_CopyConvolutionFilter1D(disp) ((disp)->CopyConvolutionFilter1D)
+#define SET_CopyConvolutionFilter1D(disp, fn) ((disp)->CopyConvolutionFilter1D = fn)
+#define CALL_CopyConvolutionFilter2D(disp, parameters) (*((disp)->CopyConvolutionFilter2D)) parameters
+#define GET_CopyConvolutionFilter2D(disp) ((disp)->CopyConvolutionFilter2D)
+#define SET_CopyConvolutionFilter2D(disp, fn) ((disp)->CopyConvolutionFilter2D = fn)
+#define CALL_GetConvolutionFilter(disp, parameters) (*((disp)->GetConvolutionFilter)) parameters
+#define GET_GetConvolutionFilter(disp) ((disp)->GetConvolutionFilter)
+#define SET_GetConvolutionFilter(disp, fn) ((disp)->GetConvolutionFilter = fn)
+#define CALL_GetConvolutionParameterfv(disp, parameters) (*((disp)->GetConvolutionParameterfv)) parameters
+#define GET_GetConvolutionParameterfv(disp) ((disp)->GetConvolutionParameterfv)
+#define SET_GetConvolutionParameterfv(disp, fn) ((disp)->GetConvolutionParameterfv = fn)
+#define CALL_GetConvolutionParameteriv(disp, parameters) (*((disp)->GetConvolutionParameteriv)) parameters
+#define GET_GetConvolutionParameteriv(disp) ((disp)->GetConvolutionParameteriv)
+#define SET_GetConvolutionParameteriv(disp, fn) ((disp)->GetConvolutionParameteriv = fn)
+#define CALL_GetSeparableFilter(disp, parameters) (*((disp)->GetSeparableFilter)) parameters
+#define GET_GetSeparableFilter(disp) ((disp)->GetSeparableFilter)
+#define SET_GetSeparableFilter(disp, fn) ((disp)->GetSeparableFilter = fn)
+#define CALL_SeparableFilter2D(disp, parameters) (*((disp)->SeparableFilter2D)) parameters
+#define GET_SeparableFilter2D(disp) ((disp)->SeparableFilter2D)
+#define SET_SeparableFilter2D(disp, fn) ((disp)->SeparableFilter2D = fn)
+#define CALL_GetHistogram(disp, parameters) (*((disp)->GetHistogram)) parameters
+#define GET_GetHistogram(disp) ((disp)->GetHistogram)
+#define SET_GetHistogram(disp, fn) ((disp)->GetHistogram = fn)
+#define CALL_GetHistogramParameterfv(disp, parameters) (*((disp)->GetHistogramParameterfv)) parameters
+#define GET_GetHistogramParameterfv(disp) ((disp)->GetHistogramParameterfv)
+#define SET_GetHistogramParameterfv(disp, fn) ((disp)->GetHistogramParameterfv = fn)
+#define CALL_GetHistogramParameteriv(disp, parameters) (*((disp)->GetHistogramParameteriv)) parameters
+#define GET_GetHistogramParameteriv(disp) ((disp)->GetHistogramParameteriv)
+#define SET_GetHistogramParameteriv(disp, fn) ((disp)->GetHistogramParameteriv = fn)
+#define CALL_GetMinmax(disp, parameters) (*((disp)->GetMinmax)) parameters
+#define GET_GetMinmax(disp) ((disp)->GetMinmax)
+#define SET_GetMinmax(disp, fn) ((disp)->GetMinmax = fn)
+#define CALL_GetMinmaxParameterfv(disp, parameters) (*((disp)->GetMinmaxParameterfv)) parameters
+#define GET_GetMinmaxParameterfv(disp) ((disp)->GetMinmaxParameterfv)
+#define SET_GetMinmaxParameterfv(disp, fn) ((disp)->GetMinmaxParameterfv = fn)
+#define CALL_GetMinmaxParameteriv(disp, parameters) (*((disp)->GetMinmaxParameteriv)) parameters
+#define GET_GetMinmaxParameteriv(disp) ((disp)->GetMinmaxParameteriv)
+#define SET_GetMinmaxParameteriv(disp, fn) ((disp)->GetMinmaxParameteriv = fn)
+#define CALL_Histogram(disp, parameters) (*((disp)->Histogram)) parameters
+#define GET_Histogram(disp) ((disp)->Histogram)
+#define SET_Histogram(disp, fn) ((disp)->Histogram = fn)
+#define CALL_Minmax(disp, parameters) (*((disp)->Minmax)) parameters
+#define GET_Minmax(disp) ((disp)->Minmax)
+#define SET_Minmax(disp, fn) ((disp)->Minmax = fn)
+#define CALL_ResetHistogram(disp, parameters) (*((disp)->ResetHistogram)) parameters
+#define GET_ResetHistogram(disp) ((disp)->ResetHistogram)
+#define SET_ResetHistogram(disp, fn) ((disp)->ResetHistogram = fn)
+#define CALL_ResetMinmax(disp, parameters) (*((disp)->ResetMinmax)) parameters
+#define GET_ResetMinmax(disp) ((disp)->ResetMinmax)
+#define SET_ResetMinmax(disp, fn) ((disp)->ResetMinmax = fn)
+#define CALL_TexImage3D(disp, parameters) (*((disp)->TexImage3D)) parameters
+#define GET_TexImage3D(disp) ((disp)->TexImage3D)
+#define SET_TexImage3D(disp, fn) ((disp)->TexImage3D = fn)
+#define CALL_TexSubImage3D(disp, parameters) (*((disp)->TexSubImage3D)) parameters
+#define GET_TexSubImage3D(disp) ((disp)->TexSubImage3D)
+#define SET_TexSubImage3D(disp, fn) ((disp)->TexSubImage3D = fn)
+#define CALL_CopyTexSubImage3D(disp, parameters) (*((disp)->CopyTexSubImage3D)) parameters
+#define GET_CopyTexSubImage3D(disp) ((disp)->CopyTexSubImage3D)
+#define SET_CopyTexSubImage3D(disp, fn) ((disp)->CopyTexSubImage3D = fn)
+#define CALL_ActiveTextureARB(disp, parameters) (*((disp)->ActiveTextureARB)) parameters
+#define GET_ActiveTextureARB(disp) ((disp)->ActiveTextureARB)
+#define SET_ActiveTextureARB(disp, fn) ((disp)->ActiveTextureARB = fn)
+#define CALL_ClientActiveTextureARB(disp, parameters) (*((disp)->ClientActiveTextureARB)) parameters
+#define GET_ClientActiveTextureARB(disp) ((disp)->ClientActiveTextureARB)
+#define SET_ClientActiveTextureARB(disp, fn) ((disp)->ClientActiveTextureARB = fn)
+#define CALL_MultiTexCoord1dARB(disp, parameters) (*((disp)->MultiTexCoord1dARB)) parameters
+#define GET_MultiTexCoord1dARB(disp) ((disp)->MultiTexCoord1dARB)
+#define SET_MultiTexCoord1dARB(disp, fn) ((disp)->MultiTexCoord1dARB = fn)
+#define CALL_MultiTexCoord1dvARB(disp, parameters) (*((disp)->MultiTexCoord1dvARB)) parameters
+#define GET_MultiTexCoord1dvARB(disp) ((disp)->MultiTexCoord1dvARB)
+#define SET_MultiTexCoord1dvARB(disp, fn) ((disp)->MultiTexCoord1dvARB = fn)
+#define CALL_MultiTexCoord1fARB(disp, parameters) (*((disp)->MultiTexCoord1fARB)) parameters
+#define GET_MultiTexCoord1fARB(disp) ((disp)->MultiTexCoord1fARB)
+#define SET_MultiTexCoord1fARB(disp, fn) ((disp)->MultiTexCoord1fARB = fn)
+#define CALL_MultiTexCoord1fvARB(disp, parameters) (*((disp)->MultiTexCoord1fvARB)) parameters
+#define GET_MultiTexCoord1fvARB(disp) ((disp)->MultiTexCoord1fvARB)
+#define SET_MultiTexCoord1fvARB(disp, fn) ((disp)->MultiTexCoord1fvARB = fn)
+#define CALL_MultiTexCoord1iARB(disp, parameters) (*((disp)->MultiTexCoord1iARB)) parameters
+#define GET_MultiTexCoord1iARB(disp) ((disp)->MultiTexCoord1iARB)
+#define SET_MultiTexCoord1iARB(disp, fn) ((disp)->MultiTexCoord1iARB = fn)
+#define CALL_MultiTexCoord1ivARB(disp, parameters) (*((disp)->MultiTexCoord1ivARB)) parameters
+#define GET_MultiTexCoord1ivARB(disp) ((disp)->MultiTexCoord1ivARB)
+#define SET_MultiTexCoord1ivARB(disp, fn) ((disp)->MultiTexCoord1ivARB = fn)
+#define CALL_MultiTexCoord1sARB(disp, parameters) (*((disp)->MultiTexCoord1sARB)) parameters
+#define GET_MultiTexCoord1sARB(disp) ((disp)->MultiTexCoord1sARB)
+#define SET_MultiTexCoord1sARB(disp, fn) ((disp)->MultiTexCoord1sARB = fn)
+#define CALL_MultiTexCoord1svARB(disp, parameters) (*((disp)->MultiTexCoord1svARB)) parameters
+#define GET_MultiTexCoord1svARB(disp) ((disp)->MultiTexCoord1svARB)
+#define SET_MultiTexCoord1svARB(disp, fn) ((disp)->MultiTexCoord1svARB = fn)
+#define CALL_MultiTexCoord2dARB(disp, parameters) (*((disp)->MultiTexCoord2dARB)) parameters
+#define GET_MultiTexCoord2dARB(disp) ((disp)->MultiTexCoord2dARB)
+#define SET_MultiTexCoord2dARB(disp, fn) ((disp)->MultiTexCoord2dARB = fn)
+#define CALL_MultiTexCoord2dvARB(disp, parameters) (*((disp)->MultiTexCoord2dvARB)) parameters
+#define GET_MultiTexCoord2dvARB(disp) ((disp)->MultiTexCoord2dvARB)
+#define SET_MultiTexCoord2dvARB(disp, fn) ((disp)->MultiTexCoord2dvARB = fn)
+#define CALL_MultiTexCoord2fARB(disp, parameters) (*((disp)->MultiTexCoord2fARB)) parameters
+#define GET_MultiTexCoord2fARB(disp) ((disp)->MultiTexCoord2fARB)
+#define SET_MultiTexCoord2fARB(disp, fn) ((disp)->MultiTexCoord2fARB = fn)
+#define CALL_MultiTexCoord2fvARB(disp, parameters) (*((disp)->MultiTexCoord2fvARB)) parameters
+#define GET_MultiTexCoord2fvARB(disp) ((disp)->MultiTexCoord2fvARB)
+#define SET_MultiTexCoord2fvARB(disp, fn) ((disp)->MultiTexCoord2fvARB = fn)
+#define CALL_MultiTexCoord2iARB(disp, parameters) (*((disp)->MultiTexCoord2iARB)) parameters
+#define GET_MultiTexCoord2iARB(disp) ((disp)->MultiTexCoord2iARB)
+#define SET_MultiTexCoord2iARB(disp, fn) ((disp)->MultiTexCoord2iARB = fn)
+#define CALL_MultiTexCoord2ivARB(disp, parameters) (*((disp)->MultiTexCoord2ivARB)) parameters
+#define GET_MultiTexCoord2ivARB(disp) ((disp)->MultiTexCoord2ivARB)
+#define SET_MultiTexCoord2ivARB(disp, fn) ((disp)->MultiTexCoord2ivARB = fn)
+#define CALL_MultiTexCoord2sARB(disp, parameters) (*((disp)->MultiTexCoord2sARB)) parameters
+#define GET_MultiTexCoord2sARB(disp) ((disp)->MultiTexCoord2sARB)
+#define SET_MultiTexCoord2sARB(disp, fn) ((disp)->MultiTexCoord2sARB = fn)
+#define CALL_MultiTexCoord2svARB(disp, parameters) (*((disp)->MultiTexCoord2svARB)) parameters
+#define GET_MultiTexCoord2svARB(disp) ((disp)->MultiTexCoord2svARB)
+#define SET_MultiTexCoord2svARB(disp, fn) ((disp)->MultiTexCoord2svARB = fn)
+#define CALL_MultiTexCoord3dARB(disp, parameters) (*((disp)->MultiTexCoord3dARB)) parameters
+#define GET_MultiTexCoord3dARB(disp) ((disp)->MultiTexCoord3dARB)
+#define SET_MultiTexCoord3dARB(disp, fn) ((disp)->MultiTexCoord3dARB = fn)
+#define CALL_MultiTexCoord3dvARB(disp, parameters) (*((disp)->MultiTexCoord3dvARB)) parameters
+#define GET_MultiTexCoord3dvARB(disp) ((disp)->MultiTexCoord3dvARB)
+#define SET_MultiTexCoord3dvARB(disp, fn) ((disp)->MultiTexCoord3dvARB = fn)
+#define CALL_MultiTexCoord3fARB(disp, parameters) (*((disp)->MultiTexCoord3fARB)) parameters
+#define GET_MultiTexCoord3fARB(disp) ((disp)->MultiTexCoord3fARB)
+#define SET_MultiTexCoord3fARB(disp, fn) ((disp)->MultiTexCoord3fARB = fn)
+#define CALL_MultiTexCoord3fvARB(disp, parameters) (*((disp)->MultiTexCoord3fvARB)) parameters
+#define GET_MultiTexCoord3fvARB(disp) ((disp)->MultiTexCoord3fvARB)
+#define SET_MultiTexCoord3fvARB(disp, fn) ((disp)->MultiTexCoord3fvARB = fn)
+#define CALL_MultiTexCoord3iARB(disp, parameters) (*((disp)->MultiTexCoord3iARB)) parameters
+#define GET_MultiTexCoord3iARB(disp) ((disp)->MultiTexCoord3iARB)
+#define SET_MultiTexCoord3iARB(disp, fn) ((disp)->MultiTexCoord3iARB = fn)
+#define CALL_MultiTexCoord3ivARB(disp, parameters) (*((disp)->MultiTexCoord3ivARB)) parameters
+#define GET_MultiTexCoord3ivARB(disp) ((disp)->MultiTexCoord3ivARB)
+#define SET_MultiTexCoord3ivARB(disp, fn) ((disp)->MultiTexCoord3ivARB = fn)
+#define CALL_MultiTexCoord3sARB(disp, parameters) (*((disp)->MultiTexCoord3sARB)) parameters
+#define GET_MultiTexCoord3sARB(disp) ((disp)->MultiTexCoord3sARB)
+#define SET_MultiTexCoord3sARB(disp, fn) ((disp)->MultiTexCoord3sARB = fn)
+#define CALL_MultiTexCoord3svARB(disp, parameters) (*((disp)->MultiTexCoord3svARB)) parameters
+#define GET_MultiTexCoord3svARB(disp) ((disp)->MultiTexCoord3svARB)
+#define SET_MultiTexCoord3svARB(disp, fn) ((disp)->MultiTexCoord3svARB = fn)
+#define CALL_MultiTexCoord4dARB(disp, parameters) (*((disp)->MultiTexCoord4dARB)) parameters
+#define GET_MultiTexCoord4dARB(disp) ((disp)->MultiTexCoord4dARB)
+#define SET_MultiTexCoord4dARB(disp, fn) ((disp)->MultiTexCoord4dARB = fn)
+#define CALL_MultiTexCoord4dvARB(disp, parameters) (*((disp)->MultiTexCoord4dvARB)) parameters
+#define GET_MultiTexCoord4dvARB(disp) ((disp)->MultiTexCoord4dvARB)
+#define SET_MultiTexCoord4dvARB(disp, fn) ((disp)->MultiTexCoord4dvARB = fn)
+#define CALL_MultiTexCoord4fARB(disp, parameters) (*((disp)->MultiTexCoord4fARB)) parameters
+#define GET_MultiTexCoord4fARB(disp) ((disp)->MultiTexCoord4fARB)
+#define SET_MultiTexCoord4fARB(disp, fn) ((disp)->MultiTexCoord4fARB = fn)
+#define CALL_MultiTexCoord4fvARB(disp, parameters) (*((disp)->MultiTexCoord4fvARB)) parameters
+#define GET_MultiTexCoord4fvARB(disp) ((disp)->MultiTexCoord4fvARB)
+#define SET_MultiTexCoord4fvARB(disp, fn) ((disp)->MultiTexCoord4fvARB = fn)
+#define CALL_MultiTexCoord4iARB(disp, parameters) (*((disp)->MultiTexCoord4iARB)) parameters
+#define GET_MultiTexCoord4iARB(disp) ((disp)->MultiTexCoord4iARB)
+#define SET_MultiTexCoord4iARB(disp, fn) ((disp)->MultiTexCoord4iARB = fn)
+#define CALL_MultiTexCoord4ivARB(disp, parameters) (*((disp)->MultiTexCoord4ivARB)) parameters
+#define GET_MultiTexCoord4ivARB(disp) ((disp)->MultiTexCoord4ivARB)
+#define SET_MultiTexCoord4ivARB(disp, fn) ((disp)->MultiTexCoord4ivARB = fn)
+#define CALL_MultiTexCoord4sARB(disp, parameters) (*((disp)->MultiTexCoord4sARB)) parameters
+#define GET_MultiTexCoord4sARB(disp) ((disp)->MultiTexCoord4sARB)
+#define SET_MultiTexCoord4sARB(disp, fn) ((disp)->MultiTexCoord4sARB = fn)
+#define CALL_MultiTexCoord4svARB(disp, parameters) (*((disp)->MultiTexCoord4svARB)) parameters
+#define GET_MultiTexCoord4svARB(disp) ((disp)->MultiTexCoord4svARB)
+#define SET_MultiTexCoord4svARB(disp, fn) ((disp)->MultiTexCoord4svARB = fn)
+
+#if !defined(IN_DRI_DRIVER)
+
+#define CALL_LoadTransposeMatrixfARB(disp, parameters) (*((disp)->LoadTransposeMatrixfARB)) parameters
+#define GET_LoadTransposeMatrixfARB(disp) ((disp)->LoadTransposeMatrixfARB)
+#define SET_LoadTransposeMatrixfARB(disp, fn) ((disp)->LoadTransposeMatrixfARB = fn)
+#define CALL_LoadTransposeMatrixdARB(disp, parameters) (*((disp)->LoadTransposeMatrixdARB)) parameters
+#define GET_LoadTransposeMatrixdARB(disp) ((disp)->LoadTransposeMatrixdARB)
+#define SET_LoadTransposeMatrixdARB(disp, fn) ((disp)->LoadTransposeMatrixdARB = fn)
+#define CALL_MultTransposeMatrixfARB(disp, parameters) (*((disp)->MultTransposeMatrixfARB)) parameters
+#define GET_MultTransposeMatrixfARB(disp) ((disp)->MultTransposeMatrixfARB)
+#define SET_MultTransposeMatrixfARB(disp, fn) ((disp)->MultTransposeMatrixfARB = fn)
+#define CALL_MultTransposeMatrixdARB(disp, parameters) (*((disp)->MultTransposeMatrixdARB)) parameters
+#define GET_MultTransposeMatrixdARB(disp) ((disp)->MultTransposeMatrixdARB)
+#define SET_MultTransposeMatrixdARB(disp, fn) ((disp)->MultTransposeMatrixdARB = fn)
+#define CALL_SampleCoverageARB(disp, parameters) (*((disp)->SampleCoverageARB)) parameters
+#define GET_SampleCoverageARB(disp) ((disp)->SampleCoverageARB)
+#define SET_SampleCoverageARB(disp, fn) ((disp)->SampleCoverageARB = fn)
+#define CALL_DrawBuffersARB(disp, parameters) (*((disp)->DrawBuffersARB)) parameters
+#define GET_DrawBuffersARB(disp) ((disp)->DrawBuffersARB)
+#define SET_DrawBuffersARB(disp, fn) ((disp)->DrawBuffersARB = fn)
+#define CALL_PolygonOffsetEXT(disp, parameters) (*((disp)->PolygonOffsetEXT)) parameters
+#define GET_PolygonOffsetEXT(disp) ((disp)->PolygonOffsetEXT)
+#define SET_PolygonOffsetEXT(disp, fn) ((disp)->PolygonOffsetEXT = fn)
+#define CALL_GetTexFilterFuncSGIS(disp, parameters) (*((disp)->GetTexFilterFuncSGIS)) parameters
+#define GET_GetTexFilterFuncSGIS(disp) ((disp)->GetTexFilterFuncSGIS)
+#define SET_GetTexFilterFuncSGIS(disp, fn) ((disp)->GetTexFilterFuncSGIS = fn)
+#define CALL_TexFilterFuncSGIS(disp, parameters) (*((disp)->TexFilterFuncSGIS)) parameters
+#define GET_TexFilterFuncSGIS(disp) ((disp)->TexFilterFuncSGIS)
+#define SET_TexFilterFuncSGIS(disp, fn) ((disp)->TexFilterFuncSGIS = fn)
+#define CALL_GetHistogramEXT(disp, parameters) (*((disp)->GetHistogramEXT)) parameters
+#define GET_GetHistogramEXT(disp) ((disp)->GetHistogramEXT)
+#define SET_GetHistogramEXT(disp, fn) ((disp)->GetHistogramEXT = fn)
+#define CALL_GetHistogramParameterfvEXT(disp, parameters) (*((disp)->GetHistogramParameterfvEXT)) parameters
+#define GET_GetHistogramParameterfvEXT(disp) ((disp)->GetHistogramParameterfvEXT)
+#define SET_GetHistogramParameterfvEXT(disp, fn) ((disp)->GetHistogramParameterfvEXT = fn)
+#define CALL_GetHistogramParameterivEXT(disp, parameters) (*((disp)->GetHistogramParameterivEXT)) parameters
+#define GET_GetHistogramParameterivEXT(disp) ((disp)->GetHistogramParameterivEXT)
+#define SET_GetHistogramParameterivEXT(disp, fn) ((disp)->GetHistogramParameterivEXT = fn)
+#define CALL_GetMinmaxEXT(disp, parameters) (*((disp)->GetMinmaxEXT)) parameters
+#define GET_GetMinmaxEXT(disp) ((disp)->GetMinmaxEXT)
+#define SET_GetMinmaxEXT(disp, fn) ((disp)->GetMinmaxEXT = fn)
+#define CALL_GetMinmaxParameterfvEXT(disp, parameters) (*((disp)->GetMinmaxParameterfvEXT)) parameters
+#define GET_GetMinmaxParameterfvEXT(disp) ((disp)->GetMinmaxParameterfvEXT)
+#define SET_GetMinmaxParameterfvEXT(disp, fn) ((disp)->GetMinmaxParameterfvEXT = fn)
+#define CALL_GetMinmaxParameterivEXT(disp, parameters) (*((disp)->GetMinmaxParameterivEXT)) parameters
+#define GET_GetMinmaxParameterivEXT(disp) ((disp)->GetMinmaxParameterivEXT)
+#define SET_GetMinmaxParameterivEXT(disp, fn) ((disp)->GetMinmaxParameterivEXT = fn)
+#define CALL_GetConvolutionFilterEXT(disp, parameters) (*((disp)->GetConvolutionFilterEXT)) parameters
+#define GET_GetConvolutionFilterEXT(disp) ((disp)->GetConvolutionFilterEXT)
+#define SET_GetConvolutionFilterEXT(disp, fn) ((disp)->GetConvolutionFilterEXT = fn)
+#define CALL_GetConvolutionParameterfvEXT(disp, parameters) (*((disp)->GetConvolutionParameterfvEXT)) parameters
+#define GET_GetConvolutionParameterfvEXT(disp) ((disp)->GetConvolutionParameterfvEXT)
+#define SET_GetConvolutionParameterfvEXT(disp, fn) ((disp)->GetConvolutionParameterfvEXT = fn)
+#define CALL_GetConvolutionParameterivEXT(disp, parameters) (*((disp)->GetConvolutionParameterivEXT)) parameters
+#define GET_GetConvolutionParameterivEXT(disp) ((disp)->GetConvolutionParameterivEXT)
+#define SET_GetConvolutionParameterivEXT(disp, fn) ((disp)->GetConvolutionParameterivEXT = fn)
+#define CALL_GetSeparableFilterEXT(disp, parameters) (*((disp)->GetSeparableFilterEXT)) parameters
+#define GET_GetSeparableFilterEXT(disp) ((disp)->GetSeparableFilterEXT)
+#define SET_GetSeparableFilterEXT(disp, fn) ((disp)->GetSeparableFilterEXT = fn)
+#define CALL_GetColorTableSGI(disp, parameters) (*((disp)->GetColorTableSGI)) parameters
+#define GET_GetColorTableSGI(disp) ((disp)->GetColorTableSGI)
+#define SET_GetColorTableSGI(disp, fn) ((disp)->GetColorTableSGI = fn)
+#define CALL_GetColorTableParameterfvSGI(disp, parameters) (*((disp)->GetColorTableParameterfvSGI)) parameters
+#define GET_GetColorTableParameterfvSGI(disp) ((disp)->GetColorTableParameterfvSGI)
+#define SET_GetColorTableParameterfvSGI(disp, fn) ((disp)->GetColorTableParameterfvSGI = fn)
+#define CALL_GetColorTableParameterivSGI(disp, parameters) (*((disp)->GetColorTableParameterivSGI)) parameters
+#define GET_GetColorTableParameterivSGI(disp) ((disp)->GetColorTableParameterivSGI)
+#define SET_GetColorTableParameterivSGI(disp, fn) ((disp)->GetColorTableParameterivSGI = fn)
+#define CALL_PixelTexGenSGIX(disp, parameters) (*((disp)->PixelTexGenSGIX)) parameters
+#define GET_PixelTexGenSGIX(disp) ((disp)->PixelTexGenSGIX)
+#define SET_PixelTexGenSGIX(disp, fn) ((disp)->PixelTexGenSGIX = fn)
+#define CALL_PixelTexGenParameteriSGIS(disp, parameters) (*((disp)->PixelTexGenParameteriSGIS)) parameters
+#define GET_PixelTexGenParameteriSGIS(disp) ((disp)->PixelTexGenParameteriSGIS)
+#define SET_PixelTexGenParameteriSGIS(disp, fn) ((disp)->PixelTexGenParameteriSGIS = fn)
+#define CALL_PixelTexGenParameterivSGIS(disp, parameters) (*((disp)->PixelTexGenParameterivSGIS)) parameters
+#define GET_PixelTexGenParameterivSGIS(disp) ((disp)->PixelTexGenParameterivSGIS)
+#define SET_PixelTexGenParameterivSGIS(disp, fn) ((disp)->PixelTexGenParameterivSGIS = fn)
+#define CALL_PixelTexGenParameterfSGIS(disp, parameters) (*((disp)->PixelTexGenParameterfSGIS)) parameters
+#define GET_PixelTexGenParameterfSGIS(disp) ((disp)->PixelTexGenParameterfSGIS)
+#define SET_PixelTexGenParameterfSGIS(disp, fn) ((disp)->PixelTexGenParameterfSGIS = fn)
+#define CALL_PixelTexGenParameterfvSGIS(disp, parameters) (*((disp)->PixelTexGenParameterfvSGIS)) parameters
+#define GET_PixelTexGenParameterfvSGIS(disp) ((disp)->PixelTexGenParameterfvSGIS)
+#define SET_PixelTexGenParameterfvSGIS(disp, fn) ((disp)->PixelTexGenParameterfvSGIS = fn)
+#define CALL_GetPixelTexGenParameterivSGIS(disp, parameters) (*((disp)->GetPixelTexGenParameterivSGIS)) parameters
+#define GET_GetPixelTexGenParameterivSGIS(disp) ((disp)->GetPixelTexGenParameterivSGIS)
+#define SET_GetPixelTexGenParameterivSGIS(disp, fn) ((disp)->GetPixelTexGenParameterivSGIS = fn)
+#define CALL_GetPixelTexGenParameterfvSGIS(disp, parameters) (*((disp)->GetPixelTexGenParameterfvSGIS)) parameters
+#define GET_GetPixelTexGenParameterfvSGIS(disp) ((disp)->GetPixelTexGenParameterfvSGIS)
+#define SET_GetPixelTexGenParameterfvSGIS(disp, fn) ((disp)->GetPixelTexGenParameterfvSGIS = fn)
+#define CALL_TexImage4DSGIS(disp, parameters) (*((disp)->TexImage4DSGIS)) parameters
+#define GET_TexImage4DSGIS(disp) ((disp)->TexImage4DSGIS)
+#define SET_TexImage4DSGIS(disp, fn) ((disp)->TexImage4DSGIS = fn)
+#define CALL_TexSubImage4DSGIS(disp, parameters) (*((disp)->TexSubImage4DSGIS)) parameters
+#define GET_TexSubImage4DSGIS(disp) ((disp)->TexSubImage4DSGIS)
+#define SET_TexSubImage4DSGIS(disp, fn) ((disp)->TexSubImage4DSGIS = fn)
+#define CALL_AreTexturesResidentEXT(disp, parameters) (*((disp)->AreTexturesResidentEXT)) parameters
+#define GET_AreTexturesResidentEXT(disp) ((disp)->AreTexturesResidentEXT)
+#define SET_AreTexturesResidentEXT(disp, fn) ((disp)->AreTexturesResidentEXT = fn)
+#define CALL_GenTexturesEXT(disp, parameters) (*((disp)->GenTexturesEXT)) parameters
+#define GET_GenTexturesEXT(disp) ((disp)->GenTexturesEXT)
+#define SET_GenTexturesEXT(disp, fn) ((disp)->GenTexturesEXT = fn)
+#define CALL_IsTextureEXT(disp, parameters) (*((disp)->IsTextureEXT)) parameters
+#define GET_IsTextureEXT(disp) ((disp)->IsTextureEXT)
+#define SET_IsTextureEXT(disp, fn) ((disp)->IsTextureEXT = fn)
+#define CALL_DetailTexFuncSGIS(disp, parameters) (*((disp)->DetailTexFuncSGIS)) parameters
+#define GET_DetailTexFuncSGIS(disp) ((disp)->DetailTexFuncSGIS)
+#define SET_DetailTexFuncSGIS(disp, fn) ((disp)->DetailTexFuncSGIS = fn)
+#define CALL_GetDetailTexFuncSGIS(disp, parameters) (*((disp)->GetDetailTexFuncSGIS)) parameters
+#define GET_GetDetailTexFuncSGIS(disp) ((disp)->GetDetailTexFuncSGIS)
+#define SET_GetDetailTexFuncSGIS(disp, fn) ((disp)->GetDetailTexFuncSGIS = fn)
+#define CALL_SharpenTexFuncSGIS(disp, parameters) (*((disp)->SharpenTexFuncSGIS)) parameters
+#define GET_SharpenTexFuncSGIS(disp) ((disp)->SharpenTexFuncSGIS)
+#define SET_SharpenTexFuncSGIS(disp, fn) ((disp)->SharpenTexFuncSGIS = fn)
+#define CALL_GetSharpenTexFuncSGIS(disp, parameters) (*((disp)->GetSharpenTexFuncSGIS)) parameters
+#define GET_GetSharpenTexFuncSGIS(disp) ((disp)->GetSharpenTexFuncSGIS)
+#define SET_GetSharpenTexFuncSGIS(disp, fn) ((disp)->GetSharpenTexFuncSGIS = fn)
+#define CALL_SampleMaskSGIS(disp, parameters) (*((disp)->SampleMaskSGIS)) parameters
+#define GET_SampleMaskSGIS(disp) ((disp)->SampleMaskSGIS)
+#define SET_SampleMaskSGIS(disp, fn) ((disp)->SampleMaskSGIS = fn)
+#define CALL_SamplePatternSGIS(disp, parameters) (*((disp)->SamplePatternSGIS)) parameters
+#define GET_SamplePatternSGIS(disp) ((disp)->SamplePatternSGIS)
+#define SET_SamplePatternSGIS(disp, fn) ((disp)->SamplePatternSGIS = fn)
+#define CALL_ColorPointerEXT(disp, parameters) (*((disp)->ColorPointerEXT)) parameters
+#define GET_ColorPointerEXT(disp) ((disp)->ColorPointerEXT)
+#define SET_ColorPointerEXT(disp, fn) ((disp)->ColorPointerEXT = fn)
+#define CALL_EdgeFlagPointerEXT(disp, parameters) (*((disp)->EdgeFlagPointerEXT)) parameters
+#define GET_EdgeFlagPointerEXT(disp) ((disp)->EdgeFlagPointerEXT)
+#define SET_EdgeFlagPointerEXT(disp, fn) ((disp)->EdgeFlagPointerEXT = fn)
+#define CALL_IndexPointerEXT(disp, parameters) (*((disp)->IndexPointerEXT)) parameters
+#define GET_IndexPointerEXT(disp) ((disp)->IndexPointerEXT)
+#define SET_IndexPointerEXT(disp, fn) ((disp)->IndexPointerEXT = fn)
+#define CALL_NormalPointerEXT(disp, parameters) (*((disp)->NormalPointerEXT)) parameters
+#define GET_NormalPointerEXT(disp) ((disp)->NormalPointerEXT)
+#define SET_NormalPointerEXT(disp, fn) ((disp)->NormalPointerEXT = fn)
+#define CALL_TexCoordPointerEXT(disp, parameters) (*((disp)->TexCoordPointerEXT)) parameters
+#define GET_TexCoordPointerEXT(disp) ((disp)->TexCoordPointerEXT)
+#define SET_TexCoordPointerEXT(disp, fn) ((disp)->TexCoordPointerEXT = fn)
+#define CALL_VertexPointerEXT(disp, parameters) (*((disp)->VertexPointerEXT)) parameters
+#define GET_VertexPointerEXT(disp) ((disp)->VertexPointerEXT)
+#define SET_VertexPointerEXT(disp, fn) ((disp)->VertexPointerEXT = fn)
+#define CALL_SpriteParameterfSGIX(disp, parameters) (*((disp)->SpriteParameterfSGIX)) parameters
+#define GET_SpriteParameterfSGIX(disp) ((disp)->SpriteParameterfSGIX)
+#define SET_SpriteParameterfSGIX(disp, fn) ((disp)->SpriteParameterfSGIX = fn)
+#define CALL_SpriteParameterfvSGIX(disp, parameters) (*((disp)->SpriteParameterfvSGIX)) parameters
+#define GET_SpriteParameterfvSGIX(disp) ((disp)->SpriteParameterfvSGIX)
+#define SET_SpriteParameterfvSGIX(disp, fn) ((disp)->SpriteParameterfvSGIX = fn)
+#define CALL_SpriteParameteriSGIX(disp, parameters) (*((disp)->SpriteParameteriSGIX)) parameters
+#define GET_SpriteParameteriSGIX(disp) ((disp)->SpriteParameteriSGIX)
+#define SET_SpriteParameteriSGIX(disp, fn) ((disp)->SpriteParameteriSGIX = fn)
+#define CALL_SpriteParameterivSGIX(disp, parameters) (*((disp)->SpriteParameterivSGIX)) parameters
+#define GET_SpriteParameterivSGIX(disp) ((disp)->SpriteParameterivSGIX)
+#define SET_SpriteParameterivSGIX(disp, fn) ((disp)->SpriteParameterivSGIX = fn)
+#define CALL_PointParameterfEXT(disp, parameters) (*((disp)->PointParameterfEXT)) parameters
+#define GET_PointParameterfEXT(disp) ((disp)->PointParameterfEXT)
+#define SET_PointParameterfEXT(disp, fn) ((disp)->PointParameterfEXT = fn)
+#define CALL_PointParameterfvEXT(disp, parameters) (*((disp)->PointParameterfvEXT)) parameters
+#define GET_PointParameterfvEXT(disp) ((disp)->PointParameterfvEXT)
+#define SET_PointParameterfvEXT(disp, fn) ((disp)->PointParameterfvEXT = fn)
+#define CALL_GetInstrumentsSGIX(disp, parameters) (*((disp)->GetInstrumentsSGIX)) parameters
+#define GET_GetInstrumentsSGIX(disp) ((disp)->GetInstrumentsSGIX)
+#define SET_GetInstrumentsSGIX(disp, fn) ((disp)->GetInstrumentsSGIX = fn)
+#define CALL_InstrumentsBufferSGIX(disp, parameters) (*((disp)->InstrumentsBufferSGIX)) parameters
+#define GET_InstrumentsBufferSGIX(disp) ((disp)->InstrumentsBufferSGIX)
+#define SET_InstrumentsBufferSGIX(disp, fn) ((disp)->InstrumentsBufferSGIX = fn)
+#define CALL_PollInstrumentsSGIX(disp, parameters) (*((disp)->PollInstrumentsSGIX)) parameters
+#define GET_PollInstrumentsSGIX(disp) ((disp)->PollInstrumentsSGIX)
+#define SET_PollInstrumentsSGIX(disp, fn) ((disp)->PollInstrumentsSGIX = fn)
+#define CALL_ReadInstrumentsSGIX(disp, parameters) (*((disp)->ReadInstrumentsSGIX)) parameters
+#define GET_ReadInstrumentsSGIX(disp) ((disp)->ReadInstrumentsSGIX)
+#define SET_ReadInstrumentsSGIX(disp, fn) ((disp)->ReadInstrumentsSGIX = fn)
+#define CALL_StartInstrumentsSGIX(disp, parameters) (*((disp)->StartInstrumentsSGIX)) parameters
+#define GET_StartInstrumentsSGIX(disp) ((disp)->StartInstrumentsSGIX)
+#define SET_StartInstrumentsSGIX(disp, fn) ((disp)->StartInstrumentsSGIX = fn)
+#define CALL_StopInstrumentsSGIX(disp, parameters) (*((disp)->StopInstrumentsSGIX)) parameters
+#define GET_StopInstrumentsSGIX(disp) ((disp)->StopInstrumentsSGIX)
+#define SET_StopInstrumentsSGIX(disp, fn) ((disp)->StopInstrumentsSGIX = fn)
+#define CALL_FrameZoomSGIX(disp, parameters) (*((disp)->FrameZoomSGIX)) parameters
+#define GET_FrameZoomSGIX(disp) ((disp)->FrameZoomSGIX)
+#define SET_FrameZoomSGIX(disp, fn) ((disp)->FrameZoomSGIX = fn)
+#define CALL_TagSampleBufferSGIX(disp, parameters) (*((disp)->TagSampleBufferSGIX)) parameters
+#define GET_TagSampleBufferSGIX(disp) ((disp)->TagSampleBufferSGIX)
+#define SET_TagSampleBufferSGIX(disp, fn) ((disp)->TagSampleBufferSGIX = fn)
+#define CALL_ReferencePlaneSGIX(disp, parameters) (*((disp)->ReferencePlaneSGIX)) parameters
+#define GET_ReferencePlaneSGIX(disp) ((disp)->ReferencePlaneSGIX)
+#define SET_ReferencePlaneSGIX(disp, fn) ((disp)->ReferencePlaneSGIX = fn)
+#define CALL_FlushRasterSGIX(disp, parameters) (*((disp)->FlushRasterSGIX)) parameters
+#define GET_FlushRasterSGIX(disp) ((disp)->FlushRasterSGIX)
+#define SET_FlushRasterSGIX(disp, fn) ((disp)->FlushRasterSGIX = fn)
+#define CALL_GetListParameterfvSGIX(disp, parameters) (*((disp)->GetListParameterfvSGIX)) parameters
+#define GET_GetListParameterfvSGIX(disp) ((disp)->GetListParameterfvSGIX)
+#define SET_GetListParameterfvSGIX(disp, fn) ((disp)->GetListParameterfvSGIX = fn)
+#define CALL_GetListParameterivSGIX(disp, parameters) (*((disp)->GetListParameterivSGIX)) parameters
+#define GET_GetListParameterivSGIX(disp) ((disp)->GetListParameterivSGIX)
+#define SET_GetListParameterivSGIX(disp, fn) ((disp)->GetListParameterivSGIX = fn)
+#define CALL_ListParameterfSGIX(disp, parameters) (*((disp)->ListParameterfSGIX)) parameters
+#define GET_ListParameterfSGIX(disp) ((disp)->ListParameterfSGIX)
+#define SET_ListParameterfSGIX(disp, fn) ((disp)->ListParameterfSGIX = fn)
+#define CALL_ListParameterfvSGIX(disp, parameters) (*((disp)->ListParameterfvSGIX)) parameters
+#define GET_ListParameterfvSGIX(disp) ((disp)->ListParameterfvSGIX)
+#define SET_ListParameterfvSGIX(disp, fn) ((disp)->ListParameterfvSGIX = fn)
+#define CALL_ListParameteriSGIX(disp, parameters) (*((disp)->ListParameteriSGIX)) parameters
+#define GET_ListParameteriSGIX(disp) ((disp)->ListParameteriSGIX)
+#define SET_ListParameteriSGIX(disp, fn) ((disp)->ListParameteriSGIX = fn)
+#define CALL_ListParameterivSGIX(disp, parameters) (*((disp)->ListParameterivSGIX)) parameters
+#define GET_ListParameterivSGIX(disp) ((disp)->ListParameterivSGIX)
+#define SET_ListParameterivSGIX(disp, fn) ((disp)->ListParameterivSGIX = fn)
+#define CALL_FragmentColorMaterialSGIX(disp, parameters) (*((disp)->FragmentColorMaterialSGIX)) parameters
+#define GET_FragmentColorMaterialSGIX(disp) ((disp)->FragmentColorMaterialSGIX)
+#define SET_FragmentColorMaterialSGIX(disp, fn) ((disp)->FragmentColorMaterialSGIX = fn)
+#define CALL_FragmentLightfSGIX(disp, parameters) (*((disp)->FragmentLightfSGIX)) parameters
+#define GET_FragmentLightfSGIX(disp) ((disp)->FragmentLightfSGIX)
+#define SET_FragmentLightfSGIX(disp, fn) ((disp)->FragmentLightfSGIX = fn)
+#define CALL_FragmentLightfvSGIX(disp, parameters) (*((disp)->FragmentLightfvSGIX)) parameters
+#define GET_FragmentLightfvSGIX(disp) ((disp)->FragmentLightfvSGIX)
+#define SET_FragmentLightfvSGIX(disp, fn) ((disp)->FragmentLightfvSGIX = fn)
+#define CALL_FragmentLightiSGIX(disp, parameters) (*((disp)->FragmentLightiSGIX)) parameters
+#define GET_FragmentLightiSGIX(disp) ((disp)->FragmentLightiSGIX)
+#define SET_FragmentLightiSGIX(disp, fn) ((disp)->FragmentLightiSGIX = fn)
+#define CALL_FragmentLightivSGIX(disp, parameters) (*((disp)->FragmentLightivSGIX)) parameters
+#define GET_FragmentLightivSGIX(disp) ((disp)->FragmentLightivSGIX)
+#define SET_FragmentLightivSGIX(disp, fn) ((disp)->FragmentLightivSGIX = fn)
+#define CALL_FragmentLightModelfSGIX(disp, parameters) (*((disp)->FragmentLightModelfSGIX)) parameters
+#define GET_FragmentLightModelfSGIX(disp) ((disp)->FragmentLightModelfSGIX)
+#define SET_FragmentLightModelfSGIX(disp, fn) ((disp)->FragmentLightModelfSGIX = fn)
+#define CALL_FragmentLightModelfvSGIX(disp, parameters) (*((disp)->FragmentLightModelfvSGIX)) parameters
+#define GET_FragmentLightModelfvSGIX(disp) ((disp)->FragmentLightModelfvSGIX)
+#define SET_FragmentLightModelfvSGIX(disp, fn) ((disp)->FragmentLightModelfvSGIX = fn)
+#define CALL_FragmentLightModeliSGIX(disp, parameters) (*((disp)->FragmentLightModeliSGIX)) parameters
+#define GET_FragmentLightModeliSGIX(disp) ((disp)->FragmentLightModeliSGIX)
+#define SET_FragmentLightModeliSGIX(disp, fn) ((disp)->FragmentLightModeliSGIX = fn)
+#define CALL_FragmentLightModelivSGIX(disp, parameters) (*((disp)->FragmentLightModelivSGIX)) parameters
+#define GET_FragmentLightModelivSGIX(disp) ((disp)->FragmentLightModelivSGIX)
+#define SET_FragmentLightModelivSGIX(disp, fn) ((disp)->FragmentLightModelivSGIX = fn)
+#define CALL_FragmentMaterialfSGIX(disp, parameters) (*((disp)->FragmentMaterialfSGIX)) parameters
+#define GET_FragmentMaterialfSGIX(disp) ((disp)->FragmentMaterialfSGIX)
+#define SET_FragmentMaterialfSGIX(disp, fn) ((disp)->FragmentMaterialfSGIX = fn)
+#define CALL_FragmentMaterialfvSGIX(disp, parameters) (*((disp)->FragmentMaterialfvSGIX)) parameters
+#define GET_FragmentMaterialfvSGIX(disp) ((disp)->FragmentMaterialfvSGIX)
+#define SET_FragmentMaterialfvSGIX(disp, fn) ((disp)->FragmentMaterialfvSGIX = fn)
+#define CALL_FragmentMaterialiSGIX(disp, parameters) (*((disp)->FragmentMaterialiSGIX)) parameters
+#define GET_FragmentMaterialiSGIX(disp) ((disp)->FragmentMaterialiSGIX)
+#define SET_FragmentMaterialiSGIX(disp, fn) ((disp)->FragmentMaterialiSGIX = fn)
+#define CALL_FragmentMaterialivSGIX(disp, parameters) (*((disp)->FragmentMaterialivSGIX)) parameters
+#define GET_FragmentMaterialivSGIX(disp) ((disp)->FragmentMaterialivSGIX)
+#define SET_FragmentMaterialivSGIX(disp, fn) ((disp)->FragmentMaterialivSGIX = fn)
+#define CALL_GetFragmentLightfvSGIX(disp, parameters) (*((disp)->GetFragmentLightfvSGIX)) parameters
+#define GET_GetFragmentLightfvSGIX(disp) ((disp)->GetFragmentLightfvSGIX)
+#define SET_GetFragmentLightfvSGIX(disp, fn) ((disp)->GetFragmentLightfvSGIX = fn)
+#define CALL_GetFragmentLightivSGIX(disp, parameters) (*((disp)->GetFragmentLightivSGIX)) parameters
+#define GET_GetFragmentLightivSGIX(disp) ((disp)->GetFragmentLightivSGIX)
+#define SET_GetFragmentLightivSGIX(disp, fn) ((disp)->GetFragmentLightivSGIX = fn)
+#define CALL_GetFragmentMaterialfvSGIX(disp, parameters) (*((disp)->GetFragmentMaterialfvSGIX)) parameters
+#define GET_GetFragmentMaterialfvSGIX(disp) ((disp)->GetFragmentMaterialfvSGIX)
+#define SET_GetFragmentMaterialfvSGIX(disp, fn) ((disp)->GetFragmentMaterialfvSGIX = fn)
+#define CALL_GetFragmentMaterialivSGIX(disp, parameters) (*((disp)->GetFragmentMaterialivSGIX)) parameters
+#define GET_GetFragmentMaterialivSGIX(disp) ((disp)->GetFragmentMaterialivSGIX)
+#define SET_GetFragmentMaterialivSGIX(disp, fn) ((disp)->GetFragmentMaterialivSGIX = fn)
+#define CALL_LightEnviSGIX(disp, parameters) (*((disp)->LightEnviSGIX)) parameters
+#define GET_LightEnviSGIX(disp) ((disp)->LightEnviSGIX)
+#define SET_LightEnviSGIX(disp, fn) ((disp)->LightEnviSGIX = fn)
+#define CALL_VertexWeightfEXT(disp, parameters) (*((disp)->VertexWeightfEXT)) parameters
+#define GET_VertexWeightfEXT(disp) ((disp)->VertexWeightfEXT)
+#define SET_VertexWeightfEXT(disp, fn) ((disp)->VertexWeightfEXT = fn)
+#define CALL_VertexWeightfvEXT(disp, parameters) (*((disp)->VertexWeightfvEXT)) parameters
+#define GET_VertexWeightfvEXT(disp) ((disp)->VertexWeightfvEXT)
+#define SET_VertexWeightfvEXT(disp, fn) ((disp)->VertexWeightfvEXT = fn)
+#define CALL_VertexWeightPointerEXT(disp, parameters) (*((disp)->VertexWeightPointerEXT)) parameters
+#define GET_VertexWeightPointerEXT(disp) ((disp)->VertexWeightPointerEXT)
+#define SET_VertexWeightPointerEXT(disp, fn) ((disp)->VertexWeightPointerEXT = fn)
+#define CALL_FlushVertexArrayRangeNV(disp, parameters) (*((disp)->FlushVertexArrayRangeNV)) parameters
+#define GET_FlushVertexArrayRangeNV(disp) ((disp)->FlushVertexArrayRangeNV)
+#define SET_FlushVertexArrayRangeNV(disp, fn) ((disp)->FlushVertexArrayRangeNV = fn)
+#define CALL_VertexArrayRangeNV(disp, parameters) (*((disp)->VertexArrayRangeNV)) parameters
+#define GET_VertexArrayRangeNV(disp) ((disp)->VertexArrayRangeNV)
+#define SET_VertexArrayRangeNV(disp, fn) ((disp)->VertexArrayRangeNV = fn)
+#define CALL_CombinerParameterfvNV(disp, parameters) (*((disp)->CombinerParameterfvNV)) parameters
+#define GET_CombinerParameterfvNV(disp) ((disp)->CombinerParameterfvNV)
+#define SET_CombinerParameterfvNV(disp, fn) ((disp)->CombinerParameterfvNV = fn)
+#define CALL_CombinerParameterfNV(disp, parameters) (*((disp)->CombinerParameterfNV)) parameters
+#define GET_CombinerParameterfNV(disp) ((disp)->CombinerParameterfNV)
+#define SET_CombinerParameterfNV(disp, fn) ((disp)->CombinerParameterfNV = fn)
+#define CALL_CombinerParameterivNV(disp, parameters) (*((disp)->CombinerParameterivNV)) parameters
+#define GET_CombinerParameterivNV(disp) ((disp)->CombinerParameterivNV)
+#define SET_CombinerParameterivNV(disp, fn) ((disp)->CombinerParameterivNV = fn)
+#define CALL_CombinerParameteriNV(disp, parameters) (*((disp)->CombinerParameteriNV)) parameters
+#define GET_CombinerParameteriNV(disp) ((disp)->CombinerParameteriNV)
+#define SET_CombinerParameteriNV(disp, fn) ((disp)->CombinerParameteriNV = fn)
+#define CALL_CombinerInputNV(disp, parameters) (*((disp)->CombinerInputNV)) parameters
+#define GET_CombinerInputNV(disp) ((disp)->CombinerInputNV)
+#define SET_CombinerInputNV(disp, fn) ((disp)->CombinerInputNV = fn)
+#define CALL_CombinerOutputNV(disp, parameters) (*((disp)->CombinerOutputNV)) parameters
+#define GET_CombinerOutputNV(disp) ((disp)->CombinerOutputNV)
+#define SET_CombinerOutputNV(disp, fn) ((disp)->CombinerOutputNV = fn)
+#define CALL_FinalCombinerInputNV(disp, parameters) (*((disp)->FinalCombinerInputNV)) parameters
+#define GET_FinalCombinerInputNV(disp) ((disp)->FinalCombinerInputNV)
+#define SET_FinalCombinerInputNV(disp, fn) ((disp)->FinalCombinerInputNV = fn)
+#define CALL_GetCombinerInputParameterfvNV(disp, parameters) (*((disp)->GetCombinerInputParameterfvNV)) parameters
+#define GET_GetCombinerInputParameterfvNV(disp) ((disp)->GetCombinerInputParameterfvNV)
+#define SET_GetCombinerInputParameterfvNV(disp, fn) ((disp)->GetCombinerInputParameterfvNV = fn)
+#define CALL_GetCombinerInputParameterivNV(disp, parameters) (*((disp)->GetCombinerInputParameterivNV)) parameters
+#define GET_GetCombinerInputParameterivNV(disp) ((disp)->GetCombinerInputParameterivNV)
+#define SET_GetCombinerInputParameterivNV(disp, fn) ((disp)->GetCombinerInputParameterivNV = fn)
+#define CALL_GetCombinerOutputParameterfvNV(disp, parameters) (*((disp)->GetCombinerOutputParameterfvNV)) parameters
+#define GET_GetCombinerOutputParameterfvNV(disp) ((disp)->GetCombinerOutputParameterfvNV)
+#define SET_GetCombinerOutputParameterfvNV(disp, fn) ((disp)->GetCombinerOutputParameterfvNV = fn)
+#define CALL_GetCombinerOutputParameterivNV(disp, parameters) (*((disp)->GetCombinerOutputParameterivNV)) parameters
+#define GET_GetCombinerOutputParameterivNV(disp) ((disp)->GetCombinerOutputParameterivNV)
+#define SET_GetCombinerOutputParameterivNV(disp, fn) ((disp)->GetCombinerOutputParameterivNV = fn)
+#define CALL_GetFinalCombinerInputParameterfvNV(disp, parameters) (*((disp)->GetFinalCombinerInputParameterfvNV)) parameters
+#define GET_GetFinalCombinerInputParameterfvNV(disp) ((disp)->GetFinalCombinerInputParameterfvNV)
+#define SET_GetFinalCombinerInputParameterfvNV(disp, fn) ((disp)->GetFinalCombinerInputParameterfvNV = fn)
+#define CALL_GetFinalCombinerInputParameterivNV(disp, parameters) (*((disp)->GetFinalCombinerInputParameterivNV)) parameters
+#define GET_GetFinalCombinerInputParameterivNV(disp) ((disp)->GetFinalCombinerInputParameterivNV)
+#define SET_GetFinalCombinerInputParameterivNV(disp, fn) ((disp)->GetFinalCombinerInputParameterivNV = fn)
+#define CALL_ResizeBuffersMESA(disp, parameters) (*((disp)->ResizeBuffersMESA)) parameters
+#define GET_ResizeBuffersMESA(disp) ((disp)->ResizeBuffersMESA)
+#define SET_ResizeBuffersMESA(disp, fn) ((disp)->ResizeBuffersMESA = fn)
+#define CALL_WindowPos2dMESA(disp, parameters) (*((disp)->WindowPos2dMESA)) parameters
+#define GET_WindowPos2dMESA(disp) ((disp)->WindowPos2dMESA)
+#define SET_WindowPos2dMESA(disp, fn) ((disp)->WindowPos2dMESA = fn)
+#define CALL_WindowPos2dvMESA(disp, parameters) (*((disp)->WindowPos2dvMESA)) parameters
+#define GET_WindowPos2dvMESA(disp) ((disp)->WindowPos2dvMESA)
+#define SET_WindowPos2dvMESA(disp, fn) ((disp)->WindowPos2dvMESA = fn)
+#define CALL_WindowPos2fMESA(disp, parameters) (*((disp)->WindowPos2fMESA)) parameters
+#define GET_WindowPos2fMESA(disp) ((disp)->WindowPos2fMESA)
+#define SET_WindowPos2fMESA(disp, fn) ((disp)->WindowPos2fMESA = fn)
+#define CALL_WindowPos2fvMESA(disp, parameters) (*((disp)->WindowPos2fvMESA)) parameters
+#define GET_WindowPos2fvMESA(disp) ((disp)->WindowPos2fvMESA)
+#define SET_WindowPos2fvMESA(disp, fn) ((disp)->WindowPos2fvMESA = fn)
+#define CALL_WindowPos2iMESA(disp, parameters) (*((disp)->WindowPos2iMESA)) parameters
+#define GET_WindowPos2iMESA(disp) ((disp)->WindowPos2iMESA)
+#define SET_WindowPos2iMESA(disp, fn) ((disp)->WindowPos2iMESA = fn)
+#define CALL_WindowPos2ivMESA(disp, parameters) (*((disp)->WindowPos2ivMESA)) parameters
+#define GET_WindowPos2ivMESA(disp) ((disp)->WindowPos2ivMESA)
+#define SET_WindowPos2ivMESA(disp, fn) ((disp)->WindowPos2ivMESA = fn)
+#define CALL_WindowPos2sMESA(disp, parameters) (*((disp)->WindowPos2sMESA)) parameters
+#define GET_WindowPos2sMESA(disp) ((disp)->WindowPos2sMESA)
+#define SET_WindowPos2sMESA(disp, fn) ((disp)->WindowPos2sMESA = fn)
+#define CALL_WindowPos2svMESA(disp, parameters) (*((disp)->WindowPos2svMESA)) parameters
+#define GET_WindowPos2svMESA(disp) ((disp)->WindowPos2svMESA)
+#define SET_WindowPos2svMESA(disp, fn) ((disp)->WindowPos2svMESA = fn)
+#define CALL_WindowPos3dMESA(disp, parameters) (*((disp)->WindowPos3dMESA)) parameters
+#define GET_WindowPos3dMESA(disp) ((disp)->WindowPos3dMESA)
+#define SET_WindowPos3dMESA(disp, fn) ((disp)->WindowPos3dMESA = fn)
+#define CALL_WindowPos3dvMESA(disp, parameters) (*((disp)->WindowPos3dvMESA)) parameters
+#define GET_WindowPos3dvMESA(disp) ((disp)->WindowPos3dvMESA)
+#define SET_WindowPos3dvMESA(disp, fn) ((disp)->WindowPos3dvMESA = fn)
+#define CALL_WindowPos3fMESA(disp, parameters) (*((disp)->WindowPos3fMESA)) parameters
+#define GET_WindowPos3fMESA(disp) ((disp)->WindowPos3fMESA)
+#define SET_WindowPos3fMESA(disp, fn) ((disp)->WindowPos3fMESA = fn)
+#define CALL_WindowPos3fvMESA(disp, parameters) (*((disp)->WindowPos3fvMESA)) parameters
+#define GET_WindowPos3fvMESA(disp) ((disp)->WindowPos3fvMESA)
+#define SET_WindowPos3fvMESA(disp, fn) ((disp)->WindowPos3fvMESA = fn)
+#define CALL_WindowPos3iMESA(disp, parameters) (*((disp)->WindowPos3iMESA)) parameters
+#define GET_WindowPos3iMESA(disp) ((disp)->WindowPos3iMESA)
+#define SET_WindowPos3iMESA(disp, fn) ((disp)->WindowPos3iMESA = fn)
+#define CALL_WindowPos3ivMESA(disp, parameters) (*((disp)->WindowPos3ivMESA)) parameters
+#define GET_WindowPos3ivMESA(disp) ((disp)->WindowPos3ivMESA)
+#define SET_WindowPos3ivMESA(disp, fn) ((disp)->WindowPos3ivMESA = fn)
+#define CALL_WindowPos3sMESA(disp, parameters) (*((disp)->WindowPos3sMESA)) parameters
+#define GET_WindowPos3sMESA(disp) ((disp)->WindowPos3sMESA)
+#define SET_WindowPos3sMESA(disp, fn) ((disp)->WindowPos3sMESA = fn)
+#define CALL_WindowPos3svMESA(disp, parameters) (*((disp)->WindowPos3svMESA)) parameters
+#define GET_WindowPos3svMESA(disp) ((disp)->WindowPos3svMESA)
+#define SET_WindowPos3svMESA(disp, fn) ((disp)->WindowPos3svMESA = fn)
+#define CALL_WindowPos4dMESA(disp, parameters) (*((disp)->WindowPos4dMESA)) parameters
+#define GET_WindowPos4dMESA(disp) ((disp)->WindowPos4dMESA)
+#define SET_WindowPos4dMESA(disp, fn) ((disp)->WindowPos4dMESA = fn)
+#define CALL_WindowPos4dvMESA(disp, parameters) (*((disp)->WindowPos4dvMESA)) parameters
+#define GET_WindowPos4dvMESA(disp) ((disp)->WindowPos4dvMESA)
+#define SET_WindowPos4dvMESA(disp, fn) ((disp)->WindowPos4dvMESA = fn)
+#define CALL_WindowPos4fMESA(disp, parameters) (*((disp)->WindowPos4fMESA)) parameters
+#define GET_WindowPos4fMESA(disp) ((disp)->WindowPos4fMESA)
+#define SET_WindowPos4fMESA(disp, fn) ((disp)->WindowPos4fMESA = fn)
+#define CALL_WindowPos4fvMESA(disp, parameters) (*((disp)->WindowPos4fvMESA)) parameters
+#define GET_WindowPos4fvMESA(disp) ((disp)->WindowPos4fvMESA)
+#define SET_WindowPos4fvMESA(disp, fn) ((disp)->WindowPos4fvMESA = fn)
+#define CALL_WindowPos4iMESA(disp, parameters) (*((disp)->WindowPos4iMESA)) parameters
+#define GET_WindowPos4iMESA(disp) ((disp)->WindowPos4iMESA)
+#define SET_WindowPos4iMESA(disp, fn) ((disp)->WindowPos4iMESA = fn)
+#define CALL_WindowPos4ivMESA(disp, parameters) (*((disp)->WindowPos4ivMESA)) parameters
+#define GET_WindowPos4ivMESA(disp) ((disp)->WindowPos4ivMESA)
+#define SET_WindowPos4ivMESA(disp, fn) ((disp)->WindowPos4ivMESA = fn)
+#define CALL_WindowPos4sMESA(disp, parameters) (*((disp)->WindowPos4sMESA)) parameters
+#define GET_WindowPos4sMESA(disp) ((disp)->WindowPos4sMESA)
+#define SET_WindowPos4sMESA(disp, fn) ((disp)->WindowPos4sMESA = fn)
+#define CALL_WindowPos4svMESA(disp, parameters) (*((disp)->WindowPos4svMESA)) parameters
+#define GET_WindowPos4svMESA(disp) ((disp)->WindowPos4svMESA)
+#define SET_WindowPos4svMESA(disp, fn) ((disp)->WindowPos4svMESA = fn)
+#define CALL_BlendFuncSeparateEXT(disp, parameters) (*((disp)->BlendFuncSeparateEXT)) parameters
+#define GET_BlendFuncSeparateEXT(disp) ((disp)->BlendFuncSeparateEXT)
+#define SET_BlendFuncSeparateEXT(disp, fn) ((disp)->BlendFuncSeparateEXT = fn)
+#define CALL_IndexMaterialEXT(disp, parameters) (*((disp)->IndexMaterialEXT)) parameters
+#define GET_IndexMaterialEXT(disp) ((disp)->IndexMaterialEXT)
+#define SET_IndexMaterialEXT(disp, fn) ((disp)->IndexMaterialEXT = fn)
+#define CALL_IndexFuncEXT(disp, parameters) (*((disp)->IndexFuncEXT)) parameters
+#define GET_IndexFuncEXT(disp) ((disp)->IndexFuncEXT)
+#define SET_IndexFuncEXT(disp, fn) ((disp)->IndexFuncEXT = fn)
+#define CALL_LockArraysEXT(disp, parameters) (*((disp)->LockArraysEXT)) parameters
+#define GET_LockArraysEXT(disp) ((disp)->LockArraysEXT)
+#define SET_LockArraysEXT(disp, fn) ((disp)->LockArraysEXT = fn)
+#define CALL_UnlockArraysEXT(disp, parameters) (*((disp)->UnlockArraysEXT)) parameters
+#define GET_UnlockArraysEXT(disp) ((disp)->UnlockArraysEXT)
+#define SET_UnlockArraysEXT(disp, fn) ((disp)->UnlockArraysEXT = fn)
+#define CALL_CullParameterdvEXT(disp, parameters) (*((disp)->CullParameterdvEXT)) parameters
+#define GET_CullParameterdvEXT(disp) ((disp)->CullParameterdvEXT)
+#define SET_CullParameterdvEXT(disp, fn) ((disp)->CullParameterdvEXT = fn)
+#define CALL_CullParameterfvEXT(disp, parameters) (*((disp)->CullParameterfvEXT)) parameters
+#define GET_CullParameterfvEXT(disp) ((disp)->CullParameterfvEXT)
+#define SET_CullParameterfvEXT(disp, fn) ((disp)->CullParameterfvEXT = fn)
+#define CALL_HintPGI(disp, parameters) (*((disp)->HintPGI)) parameters
+#define GET_HintPGI(disp) ((disp)->HintPGI)
+#define SET_HintPGI(disp, fn) ((disp)->HintPGI = fn)
+#define CALL_FogCoordfEXT(disp, parameters) (*((disp)->FogCoordfEXT)) parameters
+#define GET_FogCoordfEXT(disp) ((disp)->FogCoordfEXT)
+#define SET_FogCoordfEXT(disp, fn) ((disp)->FogCoordfEXT = fn)
+#define CALL_FogCoordfvEXT(disp, parameters) (*((disp)->FogCoordfvEXT)) parameters
+#define GET_FogCoordfvEXT(disp) ((disp)->FogCoordfvEXT)
+#define SET_FogCoordfvEXT(disp, fn) ((disp)->FogCoordfvEXT = fn)
+#define CALL_FogCoorddEXT(disp, parameters) (*((disp)->FogCoorddEXT)) parameters
+#define GET_FogCoorddEXT(disp) ((disp)->FogCoorddEXT)
+#define SET_FogCoorddEXT(disp, fn) ((disp)->FogCoorddEXT = fn)
+#define CALL_FogCoorddvEXT(disp, parameters) (*((disp)->FogCoorddvEXT)) parameters
+#define GET_FogCoorddvEXT(disp) ((disp)->FogCoorddvEXT)
+#define SET_FogCoorddvEXT(disp, fn) ((disp)->FogCoorddvEXT = fn)
+#define CALL_FogCoordPointerEXT(disp, parameters) (*((disp)->FogCoordPointerEXT)) parameters
+#define GET_FogCoordPointerEXT(disp) ((disp)->FogCoordPointerEXT)
+#define SET_FogCoordPointerEXT(disp, fn) ((disp)->FogCoordPointerEXT = fn)
+#define CALL_GetColorTableEXT(disp, parameters) (*((disp)->GetColorTableEXT)) parameters
+#define GET_GetColorTableEXT(disp) ((disp)->GetColorTableEXT)
+#define SET_GetColorTableEXT(disp, fn) ((disp)->GetColorTableEXT = fn)
+#define CALL_GetColorTableParameterivEXT(disp, parameters) (*((disp)->GetColorTableParameterivEXT)) parameters
+#define GET_GetColorTableParameterivEXT(disp) ((disp)->GetColorTableParameterivEXT)
+#define SET_GetColorTableParameterivEXT(disp, fn) ((disp)->GetColorTableParameterivEXT = fn)
+#define CALL_GetColorTableParameterfvEXT(disp, parameters) (*((disp)->GetColorTableParameterfvEXT)) parameters
+#define GET_GetColorTableParameterfvEXT(disp) ((disp)->GetColorTableParameterfvEXT)
+#define SET_GetColorTableParameterfvEXT(disp, fn) ((disp)->GetColorTableParameterfvEXT = fn)
+#define CALL_TbufferMask3DFX(disp, parameters) (*((disp)->TbufferMask3DFX)) parameters
+#define GET_TbufferMask3DFX(disp) ((disp)->TbufferMask3DFX)
+#define SET_TbufferMask3DFX(disp, fn) ((disp)->TbufferMask3DFX = fn)
+#define CALL_CompressedTexImage3DARB(disp, parameters) (*((disp)->CompressedTexImage3DARB)) parameters
+#define GET_CompressedTexImage3DARB(disp) ((disp)->CompressedTexImage3DARB)
+#define SET_CompressedTexImage3DARB(disp, fn) ((disp)->CompressedTexImage3DARB = fn)
+#define CALL_CompressedTexImage2DARB(disp, parameters) (*((disp)->CompressedTexImage2DARB)) parameters
+#define GET_CompressedTexImage2DARB(disp) ((disp)->CompressedTexImage2DARB)
+#define SET_CompressedTexImage2DARB(disp, fn) ((disp)->CompressedTexImage2DARB = fn)
+#define CALL_CompressedTexImage1DARB(disp, parameters) (*((disp)->CompressedTexImage1DARB)) parameters
+#define GET_CompressedTexImage1DARB(disp) ((disp)->CompressedTexImage1DARB)
+#define SET_CompressedTexImage1DARB(disp, fn) ((disp)->CompressedTexImage1DARB = fn)
+#define CALL_CompressedTexSubImage3DARB(disp, parameters) (*((disp)->CompressedTexSubImage3DARB)) parameters
+#define GET_CompressedTexSubImage3DARB(disp) ((disp)->CompressedTexSubImage3DARB)
+#define SET_CompressedTexSubImage3DARB(disp, fn) ((disp)->CompressedTexSubImage3DARB = fn)
+#define CALL_CompressedTexSubImage2DARB(disp, parameters) (*((disp)->CompressedTexSubImage2DARB)) parameters
+#define GET_CompressedTexSubImage2DARB(disp) ((disp)->CompressedTexSubImage2DARB)
+#define SET_CompressedTexSubImage2DARB(disp, fn) ((disp)->CompressedTexSubImage2DARB = fn)
+#define CALL_CompressedTexSubImage1DARB(disp, parameters) (*((disp)->CompressedTexSubImage1DARB)) parameters
+#define GET_CompressedTexSubImage1DARB(disp) ((disp)->CompressedTexSubImage1DARB)
+#define SET_CompressedTexSubImage1DARB(disp, fn) ((disp)->CompressedTexSubImage1DARB = fn)
+#define CALL_GetCompressedTexImageARB(disp, parameters) (*((disp)->GetCompressedTexImageARB)) parameters
+#define GET_GetCompressedTexImageARB(disp) ((disp)->GetCompressedTexImageARB)
+#define SET_GetCompressedTexImageARB(disp, fn) ((disp)->GetCompressedTexImageARB = fn)
+#define CALL_SecondaryColor3bEXT(disp, parameters) (*((disp)->SecondaryColor3bEXT)) parameters
+#define GET_SecondaryColor3bEXT(disp) ((disp)->SecondaryColor3bEXT)
+#define SET_SecondaryColor3bEXT(disp, fn) ((disp)->SecondaryColor3bEXT = fn)
+#define CALL_SecondaryColor3bvEXT(disp, parameters) (*((disp)->SecondaryColor3bvEXT)) parameters
+#define GET_SecondaryColor3bvEXT(disp) ((disp)->SecondaryColor3bvEXT)
+#define SET_SecondaryColor3bvEXT(disp, fn) ((disp)->SecondaryColor3bvEXT = fn)
+#define CALL_SecondaryColor3dEXT(disp, parameters) (*((disp)->SecondaryColor3dEXT)) parameters
+#define GET_SecondaryColor3dEXT(disp) ((disp)->SecondaryColor3dEXT)
+#define SET_SecondaryColor3dEXT(disp, fn) ((disp)->SecondaryColor3dEXT = fn)
+#define CALL_SecondaryColor3dvEXT(disp, parameters) (*((disp)->SecondaryColor3dvEXT)) parameters
+#define GET_SecondaryColor3dvEXT(disp) ((disp)->SecondaryColor3dvEXT)
+#define SET_SecondaryColor3dvEXT(disp, fn) ((disp)->SecondaryColor3dvEXT = fn)
+#define CALL_SecondaryColor3fEXT(disp, parameters) (*((disp)->SecondaryColor3fEXT)) parameters
+#define GET_SecondaryColor3fEXT(disp) ((disp)->SecondaryColor3fEXT)
+#define SET_SecondaryColor3fEXT(disp, fn) ((disp)->SecondaryColor3fEXT = fn)
+#define CALL_SecondaryColor3fvEXT(disp, parameters) (*((disp)->SecondaryColor3fvEXT)) parameters
+#define GET_SecondaryColor3fvEXT(disp) ((disp)->SecondaryColor3fvEXT)
+#define SET_SecondaryColor3fvEXT(disp, fn) ((disp)->SecondaryColor3fvEXT = fn)
+#define CALL_SecondaryColor3iEXT(disp, parameters) (*((disp)->SecondaryColor3iEXT)) parameters
+#define GET_SecondaryColor3iEXT(disp) ((disp)->SecondaryColor3iEXT)
+#define SET_SecondaryColor3iEXT(disp, fn) ((disp)->SecondaryColor3iEXT = fn)
+#define CALL_SecondaryColor3ivEXT(disp, parameters) (*((disp)->SecondaryColor3ivEXT)) parameters
+#define GET_SecondaryColor3ivEXT(disp) ((disp)->SecondaryColor3ivEXT)
+#define SET_SecondaryColor3ivEXT(disp, fn) ((disp)->SecondaryColor3ivEXT = fn)
+#define CALL_SecondaryColor3sEXT(disp, parameters) (*((disp)->SecondaryColor3sEXT)) parameters
+#define GET_SecondaryColor3sEXT(disp) ((disp)->SecondaryColor3sEXT)
+#define SET_SecondaryColor3sEXT(disp, fn) ((disp)->SecondaryColor3sEXT = fn)
+#define CALL_SecondaryColor3svEXT(disp, parameters) (*((disp)->SecondaryColor3svEXT)) parameters
+#define GET_SecondaryColor3svEXT(disp) ((disp)->SecondaryColor3svEXT)
+#define SET_SecondaryColor3svEXT(disp, fn) ((disp)->SecondaryColor3svEXT = fn)
+#define CALL_SecondaryColor3ubEXT(disp, parameters) (*((disp)->SecondaryColor3ubEXT)) parameters
+#define GET_SecondaryColor3ubEXT(disp) ((disp)->SecondaryColor3ubEXT)
+#define SET_SecondaryColor3ubEXT(disp, fn) ((disp)->SecondaryColor3ubEXT = fn)
+#define CALL_SecondaryColor3ubvEXT(disp, parameters) (*((disp)->SecondaryColor3ubvEXT)) parameters
+#define GET_SecondaryColor3ubvEXT(disp) ((disp)->SecondaryColor3ubvEXT)
+#define SET_SecondaryColor3ubvEXT(disp, fn) ((disp)->SecondaryColor3ubvEXT = fn)
+#define CALL_SecondaryColor3uiEXT(disp, parameters) (*((disp)->SecondaryColor3uiEXT)) parameters
+#define GET_SecondaryColor3uiEXT(disp) ((disp)->SecondaryColor3uiEXT)
+#define SET_SecondaryColor3uiEXT(disp, fn) ((disp)->SecondaryColor3uiEXT = fn)
+#define CALL_SecondaryColor3uivEXT(disp, parameters) (*((disp)->SecondaryColor3uivEXT)) parameters
+#define GET_SecondaryColor3uivEXT(disp) ((disp)->SecondaryColor3uivEXT)
+#define SET_SecondaryColor3uivEXT(disp, fn) ((disp)->SecondaryColor3uivEXT = fn)
+#define CALL_SecondaryColor3usEXT(disp, parameters) (*((disp)->SecondaryColor3usEXT)) parameters
+#define GET_SecondaryColor3usEXT(disp) ((disp)->SecondaryColor3usEXT)
+#define SET_SecondaryColor3usEXT(disp, fn) ((disp)->SecondaryColor3usEXT = fn)
+#define CALL_SecondaryColor3usvEXT(disp, parameters) (*((disp)->SecondaryColor3usvEXT)) parameters
+#define GET_SecondaryColor3usvEXT(disp) ((disp)->SecondaryColor3usvEXT)
+#define SET_SecondaryColor3usvEXT(disp, fn) ((disp)->SecondaryColor3usvEXT = fn)
+#define CALL_SecondaryColorPointerEXT(disp, parameters) (*((disp)->SecondaryColorPointerEXT)) parameters
+#define GET_SecondaryColorPointerEXT(disp) ((disp)->SecondaryColorPointerEXT)
+#define SET_SecondaryColorPointerEXT(disp, fn) ((disp)->SecondaryColorPointerEXT = fn)
+#define CALL_AreProgramsResidentNV(disp, parameters) (*((disp)->AreProgramsResidentNV)) parameters
+#define GET_AreProgramsResidentNV(disp) ((disp)->AreProgramsResidentNV)
+#define SET_AreProgramsResidentNV(disp, fn) ((disp)->AreProgramsResidentNV = fn)
+#define CALL_BindProgramNV(disp, parameters) (*((disp)->BindProgramNV)) parameters
+#define GET_BindProgramNV(disp) ((disp)->BindProgramNV)
+#define SET_BindProgramNV(disp, fn) ((disp)->BindProgramNV = fn)
+#define CALL_DeleteProgramsNV(disp, parameters) (*((disp)->DeleteProgramsNV)) parameters
+#define GET_DeleteProgramsNV(disp) ((disp)->DeleteProgramsNV)
+#define SET_DeleteProgramsNV(disp, fn) ((disp)->DeleteProgramsNV = fn)
+#define CALL_ExecuteProgramNV(disp, parameters) (*((disp)->ExecuteProgramNV)) parameters
+#define GET_ExecuteProgramNV(disp) ((disp)->ExecuteProgramNV)
+#define SET_ExecuteProgramNV(disp, fn) ((disp)->ExecuteProgramNV = fn)
+#define CALL_GenProgramsNV(disp, parameters) (*((disp)->GenProgramsNV)) parameters
+#define GET_GenProgramsNV(disp) ((disp)->GenProgramsNV)
+#define SET_GenProgramsNV(disp, fn) ((disp)->GenProgramsNV = fn)
+#define CALL_GetProgramParameterdvNV(disp, parameters) (*((disp)->GetProgramParameterdvNV)) parameters
+#define GET_GetProgramParameterdvNV(disp) ((disp)->GetProgramParameterdvNV)
+#define SET_GetProgramParameterdvNV(disp, fn) ((disp)->GetProgramParameterdvNV = fn)
+#define CALL_GetProgramParameterfvNV(disp, parameters) (*((disp)->GetProgramParameterfvNV)) parameters
+#define GET_GetProgramParameterfvNV(disp) ((disp)->GetProgramParameterfvNV)
+#define SET_GetProgramParameterfvNV(disp, fn) ((disp)->GetProgramParameterfvNV = fn)
+#define CALL_GetProgramivNV(disp, parameters) (*((disp)->GetProgramivNV)) parameters
+#define GET_GetProgramivNV(disp) ((disp)->GetProgramivNV)
+#define SET_GetProgramivNV(disp, fn) ((disp)->GetProgramivNV = fn)
+#define CALL_GetProgramStringNV(disp, parameters) (*((disp)->GetProgramStringNV)) parameters
+#define GET_GetProgramStringNV(disp) ((disp)->GetProgramStringNV)
+#define SET_GetProgramStringNV(disp, fn) ((disp)->GetProgramStringNV = fn)
+#define CALL_GetTrackMatrixivNV(disp, parameters) (*((disp)->GetTrackMatrixivNV)) parameters
+#define GET_GetTrackMatrixivNV(disp) ((disp)->GetTrackMatrixivNV)
+#define SET_GetTrackMatrixivNV(disp, fn) ((disp)->GetTrackMatrixivNV = fn)
+#define CALL_GetVertexAttribdvARB(disp, parameters) (*((disp)->GetVertexAttribdvARB)) parameters
+#define GET_GetVertexAttribdvARB(disp) ((disp)->GetVertexAttribdvARB)
+#define SET_GetVertexAttribdvARB(disp, fn) ((disp)->GetVertexAttribdvARB = fn)
+#define CALL_GetVertexAttribfvARB(disp, parameters) (*((disp)->GetVertexAttribfvARB)) parameters
+#define GET_GetVertexAttribfvARB(disp) ((disp)->GetVertexAttribfvARB)
+#define SET_GetVertexAttribfvARB(disp, fn) ((disp)->GetVertexAttribfvARB = fn)
+#define CALL_GetVertexAttribivARB(disp, parameters) (*((disp)->GetVertexAttribivARB)) parameters
+#define GET_GetVertexAttribivARB(disp) ((disp)->GetVertexAttribivARB)
+#define SET_GetVertexAttribivARB(disp, fn) ((disp)->GetVertexAttribivARB = fn)
+#define CALL_GetVertexAttribPointervNV(disp, parameters) (*((disp)->GetVertexAttribPointervNV)) parameters
+#define GET_GetVertexAttribPointervNV(disp) ((disp)->GetVertexAttribPointervNV)
+#define SET_GetVertexAttribPointervNV(disp, fn) ((disp)->GetVertexAttribPointervNV = fn)
+#define CALL_IsProgramNV(disp, parameters) (*((disp)->IsProgramNV)) parameters
+#define GET_IsProgramNV(disp) ((disp)->IsProgramNV)
+#define SET_IsProgramNV(disp, fn) ((disp)->IsProgramNV = fn)
+#define CALL_LoadProgramNV(disp, parameters) (*((disp)->LoadProgramNV)) parameters
+#define GET_LoadProgramNV(disp) ((disp)->LoadProgramNV)
+#define SET_LoadProgramNV(disp, fn) ((disp)->LoadProgramNV = fn)
+#define CALL_ProgramParameter4dNV(disp, parameters) (*((disp)->ProgramParameter4dNV)) parameters
+#define GET_ProgramParameter4dNV(disp) ((disp)->ProgramParameter4dNV)
+#define SET_ProgramParameter4dNV(disp, fn) ((disp)->ProgramParameter4dNV = fn)
+#define CALL_ProgramParameter4dvNV(disp, parameters) (*((disp)->ProgramParameter4dvNV)) parameters
+#define GET_ProgramParameter4dvNV(disp) ((disp)->ProgramParameter4dvNV)
+#define SET_ProgramParameter4dvNV(disp, fn) ((disp)->ProgramParameter4dvNV = fn)
+#define CALL_ProgramParameter4fNV(disp, parameters) (*((disp)->ProgramParameter4fNV)) parameters
+#define GET_ProgramParameter4fNV(disp) ((disp)->ProgramParameter4fNV)
+#define SET_ProgramParameter4fNV(disp, fn) ((disp)->ProgramParameter4fNV = fn)
+#define CALL_ProgramParameter4fvNV(disp, parameters) (*((disp)->ProgramParameter4fvNV)) parameters
+#define GET_ProgramParameter4fvNV(disp) ((disp)->ProgramParameter4fvNV)
+#define SET_ProgramParameter4fvNV(disp, fn) ((disp)->ProgramParameter4fvNV = fn)
+#define CALL_ProgramParameters4dvNV(disp, parameters) (*((disp)->ProgramParameters4dvNV)) parameters
+#define GET_ProgramParameters4dvNV(disp) ((disp)->ProgramParameters4dvNV)
+#define SET_ProgramParameters4dvNV(disp, fn) ((disp)->ProgramParameters4dvNV = fn)
+#define CALL_ProgramParameters4fvNV(disp, parameters) (*((disp)->ProgramParameters4fvNV)) parameters
+#define GET_ProgramParameters4fvNV(disp) ((disp)->ProgramParameters4fvNV)
+#define SET_ProgramParameters4fvNV(disp, fn) ((disp)->ProgramParameters4fvNV = fn)
+#define CALL_RequestResidentProgramsNV(disp, parameters) (*((disp)->RequestResidentProgramsNV)) parameters
+#define GET_RequestResidentProgramsNV(disp) ((disp)->RequestResidentProgramsNV)
+#define SET_RequestResidentProgramsNV(disp, fn) ((disp)->RequestResidentProgramsNV = fn)
+#define CALL_TrackMatrixNV(disp, parameters) (*((disp)->TrackMatrixNV)) parameters
+#define GET_TrackMatrixNV(disp) ((disp)->TrackMatrixNV)
+#define SET_TrackMatrixNV(disp, fn) ((disp)->TrackMatrixNV = fn)
+#define CALL_VertexAttribPointerNV(disp, parameters) (*((disp)->VertexAttribPointerNV)) parameters
+#define GET_VertexAttribPointerNV(disp) ((disp)->VertexAttribPointerNV)
+#define SET_VertexAttribPointerNV(disp, fn) ((disp)->VertexAttribPointerNV = fn)
+#define CALL_VertexAttrib1dARB(disp, parameters) (*((disp)->VertexAttrib1dARB)) parameters
+#define GET_VertexAttrib1dARB(disp) ((disp)->VertexAttrib1dARB)
+#define SET_VertexAttrib1dARB(disp, fn) ((disp)->VertexAttrib1dARB = fn)
+#define CALL_VertexAttrib1dvARB(disp, parameters) (*((disp)->VertexAttrib1dvARB)) parameters
+#define GET_VertexAttrib1dvARB(disp) ((disp)->VertexAttrib1dvARB)
+#define SET_VertexAttrib1dvARB(disp, fn) ((disp)->VertexAttrib1dvARB = fn)
+#define CALL_VertexAttrib1fARB(disp, parameters) (*((disp)->VertexAttrib1fARB)) parameters
+#define GET_VertexAttrib1fARB(disp) ((disp)->VertexAttrib1fARB)
+#define SET_VertexAttrib1fARB(disp, fn) ((disp)->VertexAttrib1fARB = fn)
+#define CALL_VertexAttrib1fvARB(disp, parameters) (*((disp)->VertexAttrib1fvARB)) parameters
+#define GET_VertexAttrib1fvARB(disp) ((disp)->VertexAttrib1fvARB)
+#define SET_VertexAttrib1fvARB(disp, fn) ((disp)->VertexAttrib1fvARB = fn)
+#define CALL_VertexAttrib1sARB(disp, parameters) (*((disp)->VertexAttrib1sARB)) parameters
+#define GET_VertexAttrib1sARB(disp) ((disp)->VertexAttrib1sARB)
+#define SET_VertexAttrib1sARB(disp, fn) ((disp)->VertexAttrib1sARB = fn)
+#define CALL_VertexAttrib1svARB(disp, parameters) (*((disp)->VertexAttrib1svARB)) parameters
+#define GET_VertexAttrib1svARB(disp) ((disp)->VertexAttrib1svARB)
+#define SET_VertexAttrib1svARB(disp, fn) ((disp)->VertexAttrib1svARB = fn)
+#define CALL_VertexAttrib2dARB(disp, parameters) (*((disp)->VertexAttrib2dARB)) parameters
+#define GET_VertexAttrib2dARB(disp) ((disp)->VertexAttrib2dARB)
+#define SET_VertexAttrib2dARB(disp, fn) ((disp)->VertexAttrib2dARB = fn)
+#define CALL_VertexAttrib2dvARB(disp, parameters) (*((disp)->VertexAttrib2dvARB)) parameters
+#define GET_VertexAttrib2dvARB(disp) ((disp)->VertexAttrib2dvARB)
+#define SET_VertexAttrib2dvARB(disp, fn) ((disp)->VertexAttrib2dvARB = fn)
+#define CALL_VertexAttrib2fARB(disp, parameters) (*((disp)->VertexAttrib2fARB)) parameters
+#define GET_VertexAttrib2fARB(disp) ((disp)->VertexAttrib2fARB)
+#define SET_VertexAttrib2fARB(disp, fn) ((disp)->VertexAttrib2fARB = fn)
+#define CALL_VertexAttrib2fvARB(disp, parameters) (*((disp)->VertexAttrib2fvARB)) parameters
+#define GET_VertexAttrib2fvARB(disp) ((disp)->VertexAttrib2fvARB)
+#define SET_VertexAttrib2fvARB(disp, fn) ((disp)->VertexAttrib2fvARB = fn)
+#define CALL_VertexAttrib2sARB(disp, parameters) (*((disp)->VertexAttrib2sARB)) parameters
+#define GET_VertexAttrib2sARB(disp) ((disp)->VertexAttrib2sARB)
+#define SET_VertexAttrib2sARB(disp, fn) ((disp)->VertexAttrib2sARB = fn)
+#define CALL_VertexAttrib2svARB(disp, parameters) (*((disp)->VertexAttrib2svARB)) parameters
+#define GET_VertexAttrib2svARB(disp) ((disp)->VertexAttrib2svARB)
+#define SET_VertexAttrib2svARB(disp, fn) ((disp)->VertexAttrib2svARB = fn)
+#define CALL_VertexAttrib3dARB(disp, parameters) (*((disp)->VertexAttrib3dARB)) parameters
+#define GET_VertexAttrib3dARB(disp) ((disp)->VertexAttrib3dARB)
+#define SET_VertexAttrib3dARB(disp, fn) ((disp)->VertexAttrib3dARB = fn)
+#define CALL_VertexAttrib3dvARB(disp, parameters) (*((disp)->VertexAttrib3dvARB)) parameters
+#define GET_VertexAttrib3dvARB(disp) ((disp)->VertexAttrib3dvARB)
+#define SET_VertexAttrib3dvARB(disp, fn) ((disp)->VertexAttrib3dvARB = fn)
+#define CALL_VertexAttrib3fARB(disp, parameters) (*((disp)->VertexAttrib3fARB)) parameters
+#define GET_VertexAttrib3fARB(disp) ((disp)->VertexAttrib3fARB)
+#define SET_VertexAttrib3fARB(disp, fn) ((disp)->VertexAttrib3fARB = fn)
+#define CALL_VertexAttrib3fvARB(disp, parameters) (*((disp)->VertexAttrib3fvARB)) parameters
+#define GET_VertexAttrib3fvARB(disp) ((disp)->VertexAttrib3fvARB)
+#define SET_VertexAttrib3fvARB(disp, fn) ((disp)->VertexAttrib3fvARB = fn)
+#define CALL_VertexAttrib3sARB(disp, parameters) (*((disp)->VertexAttrib3sARB)) parameters
+#define GET_VertexAttrib3sARB(disp) ((disp)->VertexAttrib3sARB)
+#define SET_VertexAttrib3sARB(disp, fn) ((disp)->VertexAttrib3sARB = fn)
+#define CALL_VertexAttrib3svARB(disp, parameters) (*((disp)->VertexAttrib3svARB)) parameters
+#define GET_VertexAttrib3svARB(disp) ((disp)->VertexAttrib3svARB)
+#define SET_VertexAttrib3svARB(disp, fn) ((disp)->VertexAttrib3svARB = fn)
+#define CALL_VertexAttrib4dARB(disp, parameters) (*((disp)->VertexAttrib4dARB)) parameters
+#define GET_VertexAttrib4dARB(disp) ((disp)->VertexAttrib4dARB)
+#define SET_VertexAttrib4dARB(disp, fn) ((disp)->VertexAttrib4dARB = fn)
+#define CALL_VertexAttrib4dvARB(disp, parameters) (*((disp)->VertexAttrib4dvARB)) parameters
+#define GET_VertexAttrib4dvARB(disp) ((disp)->VertexAttrib4dvARB)
+#define SET_VertexAttrib4dvARB(disp, fn) ((disp)->VertexAttrib4dvARB = fn)
+#define CALL_VertexAttrib4fARB(disp, parameters) (*((disp)->VertexAttrib4fARB)) parameters
+#define GET_VertexAttrib4fARB(disp) ((disp)->VertexAttrib4fARB)
+#define SET_VertexAttrib4fARB(disp, fn) ((disp)->VertexAttrib4fARB = fn)
+#define CALL_VertexAttrib4fvARB(disp, parameters) (*((disp)->VertexAttrib4fvARB)) parameters
+#define GET_VertexAttrib4fvARB(disp) ((disp)->VertexAttrib4fvARB)
+#define SET_VertexAttrib4fvARB(disp, fn) ((disp)->VertexAttrib4fvARB = fn)
+#define CALL_VertexAttrib4sARB(disp, parameters) (*((disp)->VertexAttrib4sARB)) parameters
+#define GET_VertexAttrib4sARB(disp) ((disp)->VertexAttrib4sARB)
+#define SET_VertexAttrib4sARB(disp, fn) ((disp)->VertexAttrib4sARB = fn)
+#define CALL_VertexAttrib4svARB(disp, parameters) (*((disp)->VertexAttrib4svARB)) parameters
+#define GET_VertexAttrib4svARB(disp) ((disp)->VertexAttrib4svARB)
+#define SET_VertexAttrib4svARB(disp, fn) ((disp)->VertexAttrib4svARB = fn)
+#define CALL_VertexAttrib4NubARB(disp, parameters) (*((disp)->VertexAttrib4NubARB)) parameters
+#define GET_VertexAttrib4NubARB(disp) ((disp)->VertexAttrib4NubARB)
+#define SET_VertexAttrib4NubARB(disp, fn) ((disp)->VertexAttrib4NubARB = fn)
+#define CALL_VertexAttrib4NubvARB(disp, parameters) (*((disp)->VertexAttrib4NubvARB)) parameters
+#define GET_VertexAttrib4NubvARB(disp) ((disp)->VertexAttrib4NubvARB)
+#define SET_VertexAttrib4NubvARB(disp, fn) ((disp)->VertexAttrib4NubvARB = fn)
+#define CALL_VertexAttribs1dvNV(disp, parameters) (*((disp)->VertexAttribs1dvNV)) parameters
+#define GET_VertexAttribs1dvNV(disp) ((disp)->VertexAttribs1dvNV)
+#define SET_VertexAttribs1dvNV(disp, fn) ((disp)->VertexAttribs1dvNV = fn)
+#define CALL_VertexAttribs1fvNV(disp, parameters) (*((disp)->VertexAttribs1fvNV)) parameters
+#define GET_VertexAttribs1fvNV(disp) ((disp)->VertexAttribs1fvNV)
+#define SET_VertexAttribs1fvNV(disp, fn) ((disp)->VertexAttribs1fvNV = fn)
+#define CALL_VertexAttribs1svNV(disp, parameters) (*((disp)->VertexAttribs1svNV)) parameters
+#define GET_VertexAttribs1svNV(disp) ((disp)->VertexAttribs1svNV)
+#define SET_VertexAttribs1svNV(disp, fn) ((disp)->VertexAttribs1svNV = fn)
+#define CALL_VertexAttribs2dvNV(disp, parameters) (*((disp)->VertexAttribs2dvNV)) parameters
+#define GET_VertexAttribs2dvNV(disp) ((disp)->VertexAttribs2dvNV)
+#define SET_VertexAttribs2dvNV(disp, fn) ((disp)->VertexAttribs2dvNV = fn)
+#define CALL_VertexAttribs2fvNV(disp, parameters) (*((disp)->VertexAttribs2fvNV)) parameters
+#define GET_VertexAttribs2fvNV(disp) ((disp)->VertexAttribs2fvNV)
+#define SET_VertexAttribs2fvNV(disp, fn) ((disp)->VertexAttribs2fvNV = fn)
+#define CALL_VertexAttribs2svNV(disp, parameters) (*((disp)->VertexAttribs2svNV)) parameters
+#define GET_VertexAttribs2svNV(disp) ((disp)->VertexAttribs2svNV)
+#define SET_VertexAttribs2svNV(disp, fn) ((disp)->VertexAttribs2svNV = fn)
+#define CALL_VertexAttribs3dvNV(disp, parameters) (*((disp)->VertexAttribs3dvNV)) parameters
+#define GET_VertexAttribs3dvNV(disp) ((disp)->VertexAttribs3dvNV)
+#define SET_VertexAttribs3dvNV(disp, fn) ((disp)->VertexAttribs3dvNV = fn)
+#define CALL_VertexAttribs3fvNV(disp, parameters) (*((disp)->VertexAttribs3fvNV)) parameters
+#define GET_VertexAttribs3fvNV(disp) ((disp)->VertexAttribs3fvNV)
+#define SET_VertexAttribs3fvNV(disp, fn) ((disp)->VertexAttribs3fvNV = fn)
+#define CALL_VertexAttribs3svNV(disp, parameters) (*((disp)->VertexAttribs3svNV)) parameters
+#define GET_VertexAttribs3svNV(disp) ((disp)->VertexAttribs3svNV)
+#define SET_VertexAttribs3svNV(disp, fn) ((disp)->VertexAttribs3svNV = fn)
+#define CALL_VertexAttribs4dvNV(disp, parameters) (*((disp)->VertexAttribs4dvNV)) parameters
+#define GET_VertexAttribs4dvNV(disp) ((disp)->VertexAttribs4dvNV)
+#define SET_VertexAttribs4dvNV(disp, fn) ((disp)->VertexAttribs4dvNV = fn)
+#define CALL_VertexAttribs4fvNV(disp, parameters) (*((disp)->VertexAttribs4fvNV)) parameters
+#define GET_VertexAttribs4fvNV(disp) ((disp)->VertexAttribs4fvNV)
+#define SET_VertexAttribs4fvNV(disp, fn) ((disp)->VertexAttribs4fvNV = fn)
+#define CALL_VertexAttribs4svNV(disp, parameters) (*((disp)->VertexAttribs4svNV)) parameters
+#define GET_VertexAttribs4svNV(disp) ((disp)->VertexAttribs4svNV)
+#define SET_VertexAttribs4svNV(disp, fn) ((disp)->VertexAttribs4svNV = fn)
+#define CALL_VertexAttribs4ubvNV(disp, parameters) (*((disp)->VertexAttribs4ubvNV)) parameters
+#define GET_VertexAttribs4ubvNV(disp) ((disp)->VertexAttribs4ubvNV)
+#define SET_VertexAttribs4ubvNV(disp, fn) ((disp)->VertexAttribs4ubvNV = fn)
+#define CALL_PointParameteriNV(disp, parameters) (*((disp)->PointParameteriNV)) parameters
+#define GET_PointParameteriNV(disp) ((disp)->PointParameteriNV)
+#define SET_PointParameteriNV(disp, fn) ((disp)->PointParameteriNV = fn)
+#define CALL_PointParameterivNV(disp, parameters) (*((disp)->PointParameterivNV)) parameters
+#define GET_PointParameterivNV(disp) ((disp)->PointParameterivNV)
+#define SET_PointParameterivNV(disp, fn) ((disp)->PointParameterivNV = fn)
+#define CALL_MultiDrawArraysEXT(disp, parameters) (*((disp)->MultiDrawArraysEXT)) parameters
+#define GET_MultiDrawArraysEXT(disp) ((disp)->MultiDrawArraysEXT)
+#define SET_MultiDrawArraysEXT(disp, fn) ((disp)->MultiDrawArraysEXT = fn)
+#define CALL_MultiDrawElementsEXT(disp, parameters) (*((disp)->MultiDrawElementsEXT)) parameters
+#define GET_MultiDrawElementsEXT(disp) ((disp)->MultiDrawElementsEXT)
+#define SET_MultiDrawElementsEXT(disp, fn) ((disp)->MultiDrawElementsEXT = fn)
+#define CALL_ActiveStencilFaceEXT(disp, parameters) (*((disp)->ActiveStencilFaceEXT)) parameters
+#define GET_ActiveStencilFaceEXT(disp) ((disp)->ActiveStencilFaceEXT)
+#define SET_ActiveStencilFaceEXT(disp, fn) ((disp)->ActiveStencilFaceEXT = fn)
+#define CALL_DeleteFencesNV(disp, parameters) (*((disp)->DeleteFencesNV)) parameters
+#define GET_DeleteFencesNV(disp) ((disp)->DeleteFencesNV)
+#define SET_DeleteFencesNV(disp, fn) ((disp)->DeleteFencesNV = fn)
+#define CALL_GenFencesNV(disp, parameters) (*((disp)->GenFencesNV)) parameters
+#define GET_GenFencesNV(disp) ((disp)->GenFencesNV)
+#define SET_GenFencesNV(disp, fn) ((disp)->GenFencesNV = fn)
+#define CALL_IsFenceNV(disp, parameters) (*((disp)->IsFenceNV)) parameters
+#define GET_IsFenceNV(disp) ((disp)->IsFenceNV)
+#define SET_IsFenceNV(disp, fn) ((disp)->IsFenceNV = fn)
+#define CALL_TestFenceNV(disp, parameters) (*((disp)->TestFenceNV)) parameters
+#define GET_TestFenceNV(disp) ((disp)->TestFenceNV)
+#define SET_TestFenceNV(disp, fn) ((disp)->TestFenceNV = fn)
+#define CALL_GetFenceivNV(disp, parameters) (*((disp)->GetFenceivNV)) parameters
+#define GET_GetFenceivNV(disp) ((disp)->GetFenceivNV)
+#define SET_GetFenceivNV(disp, fn) ((disp)->GetFenceivNV = fn)
+#define CALL_FinishFenceNV(disp, parameters) (*((disp)->FinishFenceNV)) parameters
+#define GET_FinishFenceNV(disp) ((disp)->FinishFenceNV)
+#define SET_FinishFenceNV(disp, fn) ((disp)->FinishFenceNV = fn)
+#define CALL_SetFenceNV(disp, parameters) (*((disp)->SetFenceNV)) parameters
+#define GET_SetFenceNV(disp) ((disp)->SetFenceNV)
+#define SET_SetFenceNV(disp, fn) ((disp)->SetFenceNV = fn)
+#define CALL_VertexAttrib4bvARB(disp, parameters) (*((disp)->VertexAttrib4bvARB)) parameters
+#define GET_VertexAttrib4bvARB(disp) ((disp)->VertexAttrib4bvARB)
+#define SET_VertexAttrib4bvARB(disp, fn) ((disp)->VertexAttrib4bvARB = fn)
+#define CALL_VertexAttrib4ivARB(disp, parameters) (*((disp)->VertexAttrib4ivARB)) parameters
+#define GET_VertexAttrib4ivARB(disp) ((disp)->VertexAttrib4ivARB)
+#define SET_VertexAttrib4ivARB(disp, fn) ((disp)->VertexAttrib4ivARB = fn)
+#define CALL_VertexAttrib4ubvARB(disp, parameters) (*((disp)->VertexAttrib4ubvARB)) parameters
+#define GET_VertexAttrib4ubvARB(disp) ((disp)->VertexAttrib4ubvARB)
+#define SET_VertexAttrib4ubvARB(disp, fn) ((disp)->VertexAttrib4ubvARB = fn)
+#define CALL_VertexAttrib4usvARB(disp, parameters) (*((disp)->VertexAttrib4usvARB)) parameters
+#define GET_VertexAttrib4usvARB(disp) ((disp)->VertexAttrib4usvARB)
+#define SET_VertexAttrib4usvARB(disp, fn) ((disp)->VertexAttrib4usvARB = fn)
+#define CALL_VertexAttrib4uivARB(disp, parameters) (*((disp)->VertexAttrib4uivARB)) parameters
+#define GET_VertexAttrib4uivARB(disp) ((disp)->VertexAttrib4uivARB)
+#define SET_VertexAttrib4uivARB(disp, fn) ((disp)->VertexAttrib4uivARB = fn)
+#define CALL_VertexAttrib4NbvARB(disp, parameters) (*((disp)->VertexAttrib4NbvARB)) parameters
+#define GET_VertexAttrib4NbvARB(disp) ((disp)->VertexAttrib4NbvARB)
+#define SET_VertexAttrib4NbvARB(disp, fn) ((disp)->VertexAttrib4NbvARB = fn)
+#define CALL_VertexAttrib4NsvARB(disp, parameters) (*((disp)->VertexAttrib4NsvARB)) parameters
+#define GET_VertexAttrib4NsvARB(disp) ((disp)->VertexAttrib4NsvARB)
+#define SET_VertexAttrib4NsvARB(disp, fn) ((disp)->VertexAttrib4NsvARB = fn)
+#define CALL_VertexAttrib4NivARB(disp, parameters) (*((disp)->VertexAttrib4NivARB)) parameters
+#define GET_VertexAttrib4NivARB(disp) ((disp)->VertexAttrib4NivARB)
+#define SET_VertexAttrib4NivARB(disp, fn) ((disp)->VertexAttrib4NivARB = fn)
+#define CALL_VertexAttrib4NusvARB(disp, parameters) (*((disp)->VertexAttrib4NusvARB)) parameters
+#define GET_VertexAttrib4NusvARB(disp) ((disp)->VertexAttrib4NusvARB)
+#define SET_VertexAttrib4NusvARB(disp, fn) ((disp)->VertexAttrib4NusvARB = fn)
+#define CALL_VertexAttrib4NuivARB(disp, parameters) (*((disp)->VertexAttrib4NuivARB)) parameters
+#define GET_VertexAttrib4NuivARB(disp) ((disp)->VertexAttrib4NuivARB)
+#define SET_VertexAttrib4NuivARB(disp, fn) ((disp)->VertexAttrib4NuivARB = fn)
+#define CALL_VertexAttribPointerARB(disp, parameters) (*((disp)->VertexAttribPointerARB)) parameters
+#define GET_VertexAttribPointerARB(disp) ((disp)->VertexAttribPointerARB)
+#define SET_VertexAttribPointerARB(disp, fn) ((disp)->VertexAttribPointerARB = fn)
+#define CALL_EnableVertexAttribArrayARB(disp, parameters) (*((disp)->EnableVertexAttribArrayARB)) parameters
+#define GET_EnableVertexAttribArrayARB(disp) ((disp)->EnableVertexAttribArrayARB)
+#define SET_EnableVertexAttribArrayARB(disp, fn) ((disp)->EnableVertexAttribArrayARB = fn)
+#define CALL_DisableVertexAttribArrayARB(disp, parameters) (*((disp)->DisableVertexAttribArrayARB)) parameters
+#define GET_DisableVertexAttribArrayARB(disp) ((disp)->DisableVertexAttribArrayARB)
+#define SET_DisableVertexAttribArrayARB(disp, fn) ((disp)->DisableVertexAttribArrayARB = fn)
+#define CALL_ProgramStringARB(disp, parameters) (*((disp)->ProgramStringARB)) parameters
+#define GET_ProgramStringARB(disp) ((disp)->ProgramStringARB)
+#define SET_ProgramStringARB(disp, fn) ((disp)->ProgramStringARB = fn)
+#define CALL_ProgramEnvParameter4dARB(disp, parameters) (*((disp)->ProgramEnvParameter4dARB)) parameters
+#define GET_ProgramEnvParameter4dARB(disp) ((disp)->ProgramEnvParameter4dARB)
+#define SET_ProgramEnvParameter4dARB(disp, fn) ((disp)->ProgramEnvParameter4dARB = fn)
+#define CALL_ProgramEnvParameter4dvARB(disp, parameters) (*((disp)->ProgramEnvParameter4dvARB)) parameters
+#define GET_ProgramEnvParameter4dvARB(disp) ((disp)->ProgramEnvParameter4dvARB)
+#define SET_ProgramEnvParameter4dvARB(disp, fn) ((disp)->ProgramEnvParameter4dvARB = fn)
+#define CALL_ProgramEnvParameter4fARB(disp, parameters) (*((disp)->ProgramEnvParameter4fARB)) parameters
+#define GET_ProgramEnvParameter4fARB(disp) ((disp)->ProgramEnvParameter4fARB)
+#define SET_ProgramEnvParameter4fARB(disp, fn) ((disp)->ProgramEnvParameter4fARB = fn)
+#define CALL_ProgramEnvParameter4fvARB(disp, parameters) (*((disp)->ProgramEnvParameter4fvARB)) parameters
+#define GET_ProgramEnvParameter4fvARB(disp) ((disp)->ProgramEnvParameter4fvARB)
+#define SET_ProgramEnvParameter4fvARB(disp, fn) ((disp)->ProgramEnvParameter4fvARB = fn)
+#define CALL_ProgramLocalParameter4dARB(disp, parameters) (*((disp)->ProgramLocalParameter4dARB)) parameters
+#define GET_ProgramLocalParameter4dARB(disp) ((disp)->ProgramLocalParameter4dARB)
+#define SET_ProgramLocalParameter4dARB(disp, fn) ((disp)->ProgramLocalParameter4dARB = fn)
+#define CALL_ProgramLocalParameter4dvARB(disp, parameters) (*((disp)->ProgramLocalParameter4dvARB)) parameters
+#define GET_ProgramLocalParameter4dvARB(disp) ((disp)->ProgramLocalParameter4dvARB)
+#define SET_ProgramLocalParameter4dvARB(disp, fn) ((disp)->ProgramLocalParameter4dvARB = fn)
+#define CALL_ProgramLocalParameter4fARB(disp, parameters) (*((disp)->ProgramLocalParameter4fARB)) parameters
+#define GET_ProgramLocalParameter4fARB(disp) ((disp)->ProgramLocalParameter4fARB)
+#define SET_ProgramLocalParameter4fARB(disp, fn) ((disp)->ProgramLocalParameter4fARB = fn)
+#define CALL_ProgramLocalParameter4fvARB(disp, parameters) (*((disp)->ProgramLocalParameter4fvARB)) parameters
+#define GET_ProgramLocalParameter4fvARB(disp) ((disp)->ProgramLocalParameter4fvARB)
+#define SET_ProgramLocalParameter4fvARB(disp, fn) ((disp)->ProgramLocalParameter4fvARB = fn)
+#define CALL_GetProgramEnvParameterdvARB(disp, parameters) (*((disp)->GetProgramEnvParameterdvARB)) parameters
+#define GET_GetProgramEnvParameterdvARB(disp) ((disp)->GetProgramEnvParameterdvARB)
+#define SET_GetProgramEnvParameterdvARB(disp, fn) ((disp)->GetProgramEnvParameterdvARB = fn)
+#define CALL_GetProgramEnvParameterfvARB(disp, parameters) (*((disp)->GetProgramEnvParameterfvARB)) parameters
+#define GET_GetProgramEnvParameterfvARB(disp) ((disp)->GetProgramEnvParameterfvARB)
+#define SET_GetProgramEnvParameterfvARB(disp, fn) ((disp)->GetProgramEnvParameterfvARB = fn)
+#define CALL_GetProgramLocalParameterdvARB(disp, parameters) (*((disp)->GetProgramLocalParameterdvARB)) parameters
+#define GET_GetProgramLocalParameterdvARB(disp) ((disp)->GetProgramLocalParameterdvARB)
+#define SET_GetProgramLocalParameterdvARB(disp, fn) ((disp)->GetProgramLocalParameterdvARB = fn)
+#define CALL_GetProgramLocalParameterfvARB(disp, parameters) (*((disp)->GetProgramLocalParameterfvARB)) parameters
+#define GET_GetProgramLocalParameterfvARB(disp) ((disp)->GetProgramLocalParameterfvARB)
+#define SET_GetProgramLocalParameterfvARB(disp, fn) ((disp)->GetProgramLocalParameterfvARB = fn)
+#define CALL_GetProgramivARB(disp, parameters) (*((disp)->GetProgramivARB)) parameters
+#define GET_GetProgramivARB(disp) ((disp)->GetProgramivARB)
+#define SET_GetProgramivARB(disp, fn) ((disp)->GetProgramivARB = fn)
+#define CALL_GetProgramStringARB(disp, parameters) (*((disp)->GetProgramStringARB)) parameters
+#define GET_GetProgramStringARB(disp) ((disp)->GetProgramStringARB)
+#define SET_GetProgramStringARB(disp, fn) ((disp)->GetProgramStringARB = fn)
+#define CALL_ProgramNamedParameter4fNV(disp, parameters) (*((disp)->ProgramNamedParameter4fNV)) parameters
+#define GET_ProgramNamedParameter4fNV(disp) ((disp)->ProgramNamedParameter4fNV)
+#define SET_ProgramNamedParameter4fNV(disp, fn) ((disp)->ProgramNamedParameter4fNV = fn)
+#define CALL_ProgramNamedParameter4dNV(disp, parameters) (*((disp)->ProgramNamedParameter4dNV)) parameters
+#define GET_ProgramNamedParameter4dNV(disp) ((disp)->ProgramNamedParameter4dNV)
+#define SET_ProgramNamedParameter4dNV(disp, fn) ((disp)->ProgramNamedParameter4dNV = fn)
+#define CALL_ProgramNamedParameter4fvNV(disp, parameters) (*((disp)->ProgramNamedParameter4fvNV)) parameters
+#define GET_ProgramNamedParameter4fvNV(disp) ((disp)->ProgramNamedParameter4fvNV)
+#define SET_ProgramNamedParameter4fvNV(disp, fn) ((disp)->ProgramNamedParameter4fvNV = fn)
+#define CALL_ProgramNamedParameter4dvNV(disp, parameters) (*((disp)->ProgramNamedParameter4dvNV)) parameters
+#define GET_ProgramNamedParameter4dvNV(disp) ((disp)->ProgramNamedParameter4dvNV)
+#define SET_ProgramNamedParameter4dvNV(disp, fn) ((disp)->ProgramNamedParameter4dvNV = fn)
+#define CALL_GetProgramNamedParameterfvNV(disp, parameters) (*((disp)->GetProgramNamedParameterfvNV)) parameters
+#define GET_GetProgramNamedParameterfvNV(disp) ((disp)->GetProgramNamedParameterfvNV)
+#define SET_GetProgramNamedParameterfvNV(disp, fn) ((disp)->GetProgramNamedParameterfvNV = fn)
+#define CALL_GetProgramNamedParameterdvNV(disp, parameters) (*((disp)->GetProgramNamedParameterdvNV)) parameters
+#define GET_GetProgramNamedParameterdvNV(disp) ((disp)->GetProgramNamedParameterdvNV)
+#define SET_GetProgramNamedParameterdvNV(disp, fn) ((disp)->GetProgramNamedParameterdvNV = fn)
+#define CALL_BindBufferARB(disp, parameters) (*((disp)->BindBufferARB)) parameters
+#define GET_BindBufferARB(disp) ((disp)->BindBufferARB)
+#define SET_BindBufferARB(disp, fn) ((disp)->BindBufferARB = fn)
+#define CALL_BufferDataARB(disp, parameters) (*((disp)->BufferDataARB)) parameters
+#define GET_BufferDataARB(disp) ((disp)->BufferDataARB)
+#define SET_BufferDataARB(disp, fn) ((disp)->BufferDataARB = fn)
+#define CALL_BufferSubDataARB(disp, parameters) (*((disp)->BufferSubDataARB)) parameters
+#define GET_BufferSubDataARB(disp) ((disp)->BufferSubDataARB)
+#define SET_BufferSubDataARB(disp, fn) ((disp)->BufferSubDataARB = fn)
+#define CALL_DeleteBuffersARB(disp, parameters) (*((disp)->DeleteBuffersARB)) parameters
+#define GET_DeleteBuffersARB(disp) ((disp)->DeleteBuffersARB)
+#define SET_DeleteBuffersARB(disp, fn) ((disp)->DeleteBuffersARB = fn)
+#define CALL_GenBuffersARB(disp, parameters) (*((disp)->GenBuffersARB)) parameters
+#define GET_GenBuffersARB(disp) ((disp)->GenBuffersARB)
+#define SET_GenBuffersARB(disp, fn) ((disp)->GenBuffersARB = fn)
+#define CALL_GetBufferParameterivARB(disp, parameters) (*((disp)->GetBufferParameterivARB)) parameters
+#define GET_GetBufferParameterivARB(disp) ((disp)->GetBufferParameterivARB)
+#define SET_GetBufferParameterivARB(disp, fn) ((disp)->GetBufferParameterivARB = fn)
+#define CALL_GetBufferPointervARB(disp, parameters) (*((disp)->GetBufferPointervARB)) parameters
+#define GET_GetBufferPointervARB(disp) ((disp)->GetBufferPointervARB)
+#define SET_GetBufferPointervARB(disp, fn) ((disp)->GetBufferPointervARB = fn)
+#define CALL_GetBufferSubDataARB(disp, parameters) (*((disp)->GetBufferSubDataARB)) parameters
+#define GET_GetBufferSubDataARB(disp) ((disp)->GetBufferSubDataARB)
+#define SET_GetBufferSubDataARB(disp, fn) ((disp)->GetBufferSubDataARB = fn)
+#define CALL_IsBufferARB(disp, parameters) (*((disp)->IsBufferARB)) parameters
+#define GET_IsBufferARB(disp) ((disp)->IsBufferARB)
+#define SET_IsBufferARB(disp, fn) ((disp)->IsBufferARB = fn)
+#define CALL_MapBufferARB(disp, parameters) (*((disp)->MapBufferARB)) parameters
+#define GET_MapBufferARB(disp) ((disp)->MapBufferARB)
+#define SET_MapBufferARB(disp, fn) ((disp)->MapBufferARB = fn)
+#define CALL_UnmapBufferARB(disp, parameters) (*((disp)->UnmapBufferARB)) parameters
+#define GET_UnmapBufferARB(disp) ((disp)->UnmapBufferARB)
+#define SET_UnmapBufferARB(disp, fn) ((disp)->UnmapBufferARB = fn)
+#define CALL_DepthBoundsEXT(disp, parameters) (*((disp)->DepthBoundsEXT)) parameters
+#define GET_DepthBoundsEXT(disp) ((disp)->DepthBoundsEXT)
+#define SET_DepthBoundsEXT(disp, fn) ((disp)->DepthBoundsEXT = fn)
+#define CALL_GenQueriesARB(disp, parameters) (*((disp)->GenQueriesARB)) parameters
+#define GET_GenQueriesARB(disp) ((disp)->GenQueriesARB)
+#define SET_GenQueriesARB(disp, fn) ((disp)->GenQueriesARB = fn)
+#define CALL_DeleteQueriesARB(disp, parameters) (*((disp)->DeleteQueriesARB)) parameters
+#define GET_DeleteQueriesARB(disp) ((disp)->DeleteQueriesARB)
+#define SET_DeleteQueriesARB(disp, fn) ((disp)->DeleteQueriesARB = fn)
+#define CALL_IsQueryARB(disp, parameters) (*((disp)->IsQueryARB)) parameters
+#define GET_IsQueryARB(disp) ((disp)->IsQueryARB)
+#define SET_IsQueryARB(disp, fn) ((disp)->IsQueryARB = fn)
+#define CALL_BeginQueryARB(disp, parameters) (*((disp)->BeginQueryARB)) parameters
+#define GET_BeginQueryARB(disp) ((disp)->BeginQueryARB)
+#define SET_BeginQueryARB(disp, fn) ((disp)->BeginQueryARB = fn)
+#define CALL_EndQueryARB(disp, parameters) (*((disp)->EndQueryARB)) parameters
+#define GET_EndQueryARB(disp) ((disp)->EndQueryARB)
+#define SET_EndQueryARB(disp, fn) ((disp)->EndQueryARB = fn)
+#define CALL_GetQueryivARB(disp, parameters) (*((disp)->GetQueryivARB)) parameters
+#define GET_GetQueryivARB(disp) ((disp)->GetQueryivARB)
+#define SET_GetQueryivARB(disp, fn) ((disp)->GetQueryivARB = fn)
+#define CALL_GetQueryObjectivARB(disp, parameters) (*((disp)->GetQueryObjectivARB)) parameters
+#define GET_GetQueryObjectivARB(disp) ((disp)->GetQueryObjectivARB)
+#define SET_GetQueryObjectivARB(disp, fn) ((disp)->GetQueryObjectivARB = fn)
+#define CALL_GetQueryObjectuivARB(disp, parameters) (*((disp)->GetQueryObjectuivARB)) parameters
+#define GET_GetQueryObjectuivARB(disp) ((disp)->GetQueryObjectuivARB)
+#define SET_GetQueryObjectuivARB(disp, fn) ((disp)->GetQueryObjectuivARB = fn)
+#define CALL_MultiModeDrawArraysIBM(disp, parameters) (*((disp)->MultiModeDrawArraysIBM)) parameters
+#define GET_MultiModeDrawArraysIBM(disp) ((disp)->MultiModeDrawArraysIBM)
+#define SET_MultiModeDrawArraysIBM(disp, fn) ((disp)->MultiModeDrawArraysIBM = fn)
+#define CALL_MultiModeDrawElementsIBM(disp, parameters) (*((disp)->MultiModeDrawElementsIBM)) parameters
+#define GET_MultiModeDrawElementsIBM(disp) ((disp)->MultiModeDrawElementsIBM)
+#define SET_MultiModeDrawElementsIBM(disp, fn) ((disp)->MultiModeDrawElementsIBM = fn)
+#define CALL_BlendEquationSeparateEXT(disp, parameters) (*((disp)->BlendEquationSeparateEXT)) parameters
+#define GET_BlendEquationSeparateEXT(disp) ((disp)->BlendEquationSeparateEXT)
+#define SET_BlendEquationSeparateEXT(disp, fn) ((disp)->BlendEquationSeparateEXT = fn)
+#define CALL_DeleteObjectARB(disp, parameters) (*((disp)->DeleteObjectARB)) parameters
+#define GET_DeleteObjectARB(disp) ((disp)->DeleteObjectARB)
+#define SET_DeleteObjectARB(disp, fn) ((disp)->DeleteObjectARB = fn)
+#define CALL_GetHandleARB(disp, parameters) (*((disp)->GetHandleARB)) parameters
+#define GET_GetHandleARB(disp) ((disp)->GetHandleARB)
+#define SET_GetHandleARB(disp, fn) ((disp)->GetHandleARB = fn)
+#define CALL_DetachObjectARB(disp, parameters) (*((disp)->DetachObjectARB)) parameters
+#define GET_DetachObjectARB(disp) ((disp)->DetachObjectARB)
+#define SET_DetachObjectARB(disp, fn) ((disp)->DetachObjectARB = fn)
+#define CALL_CreateShaderObjectARB(disp, parameters) (*((disp)->CreateShaderObjectARB)) parameters
+#define GET_CreateShaderObjectARB(disp) ((disp)->CreateShaderObjectARB)
+#define SET_CreateShaderObjectARB(disp, fn) ((disp)->CreateShaderObjectARB = fn)
+#define CALL_ShaderSourceARB(disp, parameters) (*((disp)->ShaderSourceARB)) parameters
+#define GET_ShaderSourceARB(disp) ((disp)->ShaderSourceARB)
+#define SET_ShaderSourceARB(disp, fn) ((disp)->ShaderSourceARB = fn)
+#define CALL_CompileShaderARB(disp, parameters) (*((disp)->CompileShaderARB)) parameters
+#define GET_CompileShaderARB(disp) ((disp)->CompileShaderARB)
+#define SET_CompileShaderARB(disp, fn) ((disp)->CompileShaderARB = fn)
+#define CALL_CreateProgramObjectARB(disp, parameters) (*((disp)->CreateProgramObjectARB)) parameters
+#define GET_CreateProgramObjectARB(disp) ((disp)->CreateProgramObjectARB)
+#define SET_CreateProgramObjectARB(disp, fn) ((disp)->CreateProgramObjectARB = fn)
+#define CALL_AttachObjectARB(disp, parameters) (*((disp)->AttachObjectARB)) parameters
+#define GET_AttachObjectARB(disp) ((disp)->AttachObjectARB)
+#define SET_AttachObjectARB(disp, fn) ((disp)->AttachObjectARB = fn)
+#define CALL_LinkProgramARB(disp, parameters) (*((disp)->LinkProgramARB)) parameters
+#define GET_LinkProgramARB(disp) ((disp)->LinkProgramARB)
+#define SET_LinkProgramARB(disp, fn) ((disp)->LinkProgramARB = fn)
+#define CALL_UseProgramObjectARB(disp, parameters) (*((disp)->UseProgramObjectARB)) parameters
+#define GET_UseProgramObjectARB(disp) ((disp)->UseProgramObjectARB)
+#define SET_UseProgramObjectARB(disp, fn) ((disp)->UseProgramObjectARB = fn)
+#define CALL_ValidateProgramARB(disp, parameters) (*((disp)->ValidateProgramARB)) parameters
+#define GET_ValidateProgramARB(disp) ((disp)->ValidateProgramARB)
+#define SET_ValidateProgramARB(disp, fn) ((disp)->ValidateProgramARB = fn)
+#define CALL_Uniform1fARB(disp, parameters) (*((disp)->Uniform1fARB)) parameters
+#define GET_Uniform1fARB(disp) ((disp)->Uniform1fARB)
+#define SET_Uniform1fARB(disp, fn) ((disp)->Uniform1fARB = fn)
+#define CALL_Uniform2fARB(disp, parameters) (*((disp)->Uniform2fARB)) parameters
+#define GET_Uniform2fARB(disp) ((disp)->Uniform2fARB)
+#define SET_Uniform2fARB(disp, fn) ((disp)->Uniform2fARB = fn)
+#define CALL_Uniform3fARB(disp, parameters) (*((disp)->Uniform3fARB)) parameters
+#define GET_Uniform3fARB(disp) ((disp)->Uniform3fARB)
+#define SET_Uniform3fARB(disp, fn) ((disp)->Uniform3fARB = fn)
+#define CALL_Uniform4fARB(disp, parameters) (*((disp)->Uniform4fARB)) parameters
+#define GET_Uniform4fARB(disp) ((disp)->Uniform4fARB)
+#define SET_Uniform4fARB(disp, fn) ((disp)->Uniform4fARB = fn)
+#define CALL_Uniform1iARB(disp, parameters) (*((disp)->Uniform1iARB)) parameters
+#define GET_Uniform1iARB(disp) ((disp)->Uniform1iARB)
+#define SET_Uniform1iARB(disp, fn) ((disp)->Uniform1iARB = fn)
+#define CALL_Uniform2iARB(disp, parameters) (*((disp)->Uniform2iARB)) parameters
+#define GET_Uniform2iARB(disp) ((disp)->Uniform2iARB)
+#define SET_Uniform2iARB(disp, fn) ((disp)->Uniform2iARB = fn)
+#define CALL_Uniform3iARB(disp, parameters) (*((disp)->Uniform3iARB)) parameters
+#define GET_Uniform3iARB(disp) ((disp)->Uniform3iARB)
+#define SET_Uniform3iARB(disp, fn) ((disp)->Uniform3iARB = fn)
+#define CALL_Uniform4iARB(disp, parameters) (*((disp)->Uniform4iARB)) parameters
+#define GET_Uniform4iARB(disp) ((disp)->Uniform4iARB)
+#define SET_Uniform4iARB(disp, fn) ((disp)->Uniform4iARB = fn)
+#define CALL_Uniform1fvARB(disp, parameters) (*((disp)->Uniform1fvARB)) parameters
+#define GET_Uniform1fvARB(disp) ((disp)->Uniform1fvARB)
+#define SET_Uniform1fvARB(disp, fn) ((disp)->Uniform1fvARB = fn)
+#define CALL_Uniform2fvARB(disp, parameters) (*((disp)->Uniform2fvARB)) parameters
+#define GET_Uniform2fvARB(disp) ((disp)->Uniform2fvARB)
+#define SET_Uniform2fvARB(disp, fn) ((disp)->Uniform2fvARB = fn)
+#define CALL_Uniform3fvARB(disp, parameters) (*((disp)->Uniform3fvARB)) parameters
+#define GET_Uniform3fvARB(disp) ((disp)->Uniform3fvARB)
+#define SET_Uniform3fvARB(disp, fn) ((disp)->Uniform3fvARB = fn)
+#define CALL_Uniform4fvARB(disp, parameters) (*((disp)->Uniform4fvARB)) parameters
+#define GET_Uniform4fvARB(disp) ((disp)->Uniform4fvARB)
+#define SET_Uniform4fvARB(disp, fn) ((disp)->Uniform4fvARB = fn)
+#define CALL_Uniform1ivARB(disp, parameters) (*((disp)->Uniform1ivARB)) parameters
+#define GET_Uniform1ivARB(disp) ((disp)->Uniform1ivARB)
+#define SET_Uniform1ivARB(disp, fn) ((disp)->Uniform1ivARB = fn)
+#define CALL_Uniform2ivARB(disp, parameters) (*((disp)->Uniform2ivARB)) parameters
+#define GET_Uniform2ivARB(disp) ((disp)->Uniform2ivARB)
+#define SET_Uniform2ivARB(disp, fn) ((disp)->Uniform2ivARB = fn)
+#define CALL_Uniform3ivARB(disp, parameters) (*((disp)->Uniform3ivARB)) parameters
+#define GET_Uniform3ivARB(disp) ((disp)->Uniform3ivARB)
+#define SET_Uniform3ivARB(disp, fn) ((disp)->Uniform3ivARB = fn)
+#define CALL_Uniform4ivARB(disp, parameters) (*((disp)->Uniform4ivARB)) parameters
+#define GET_Uniform4ivARB(disp) ((disp)->Uniform4ivARB)
+#define SET_Uniform4ivARB(disp, fn) ((disp)->Uniform4ivARB = fn)
+#define CALL_UniformMatrix2fvARB(disp, parameters) (*((disp)->UniformMatrix2fvARB)) parameters
+#define GET_UniformMatrix2fvARB(disp) ((disp)->UniformMatrix2fvARB)
+#define SET_UniformMatrix2fvARB(disp, fn) ((disp)->UniformMatrix2fvARB = fn)
+#define CALL_UniformMatrix3fvARB(disp, parameters) (*((disp)->UniformMatrix3fvARB)) parameters
+#define GET_UniformMatrix3fvARB(disp) ((disp)->UniformMatrix3fvARB)
+#define SET_UniformMatrix3fvARB(disp, fn) ((disp)->UniformMatrix3fvARB = fn)
+#define CALL_UniformMatrix4fvARB(disp, parameters) (*((disp)->UniformMatrix4fvARB)) parameters
+#define GET_UniformMatrix4fvARB(disp) ((disp)->UniformMatrix4fvARB)
+#define SET_UniformMatrix4fvARB(disp, fn) ((disp)->UniformMatrix4fvARB = fn)
+#define CALL_GetObjectParameterfvARB(disp, parameters) (*((disp)->GetObjectParameterfvARB)) parameters
+#define GET_GetObjectParameterfvARB(disp) ((disp)->GetObjectParameterfvARB)
+#define SET_GetObjectParameterfvARB(disp, fn) ((disp)->GetObjectParameterfvARB = fn)
+#define CALL_GetObjectParameterivARB(disp, parameters) (*((disp)->GetObjectParameterivARB)) parameters
+#define GET_GetObjectParameterivARB(disp) ((disp)->GetObjectParameterivARB)
+#define SET_GetObjectParameterivARB(disp, fn) ((disp)->GetObjectParameterivARB = fn)
+#define CALL_GetInfoLogARB(disp, parameters) (*((disp)->GetInfoLogARB)) parameters
+#define GET_GetInfoLogARB(disp) ((disp)->GetInfoLogARB)
+#define SET_GetInfoLogARB(disp, fn) ((disp)->GetInfoLogARB = fn)
+#define CALL_GetAttachedObjectsARB(disp, parameters) (*((disp)->GetAttachedObjectsARB)) parameters
+#define GET_GetAttachedObjectsARB(disp) ((disp)->GetAttachedObjectsARB)
+#define SET_GetAttachedObjectsARB(disp, fn) ((disp)->GetAttachedObjectsARB = fn)
+#define CALL_GetUniformLocationARB(disp, parameters) (*((disp)->GetUniformLocationARB)) parameters
+#define GET_GetUniformLocationARB(disp) ((disp)->GetUniformLocationARB)
+#define SET_GetUniformLocationARB(disp, fn) ((disp)->GetUniformLocationARB = fn)
+#define CALL_GetActiveUniformARB(disp, parameters) (*((disp)->GetActiveUniformARB)) parameters
+#define GET_GetActiveUniformARB(disp) ((disp)->GetActiveUniformARB)
+#define SET_GetActiveUniformARB(disp, fn) ((disp)->GetActiveUniformARB = fn)
+#define CALL_GetUniformfvARB(disp, parameters) (*((disp)->GetUniformfvARB)) parameters
+#define GET_GetUniformfvARB(disp) ((disp)->GetUniformfvARB)
+#define SET_GetUniformfvARB(disp, fn) ((disp)->GetUniformfvARB = fn)
+#define CALL_GetUniformivARB(disp, parameters) (*((disp)->GetUniformivARB)) parameters
+#define GET_GetUniformivARB(disp) ((disp)->GetUniformivARB)
+#define SET_GetUniformivARB(disp, fn) ((disp)->GetUniformivARB = fn)
+#define CALL_GetShaderSourceARB(disp, parameters) (*((disp)->GetShaderSourceARB)) parameters
+#define GET_GetShaderSourceARB(disp) ((disp)->GetShaderSourceARB)
+#define SET_GetShaderSourceARB(disp, fn) ((disp)->GetShaderSourceARB = fn)
+#define CALL_BindAttribLocationARB(disp, parameters) (*((disp)->BindAttribLocationARB)) parameters
+#define GET_BindAttribLocationARB(disp) ((disp)->BindAttribLocationARB)
+#define SET_BindAttribLocationARB(disp, fn) ((disp)->BindAttribLocationARB = fn)
+#define CALL_GetActiveAttribARB(disp, parameters) (*((disp)->GetActiveAttribARB)) parameters
+#define GET_GetActiveAttribARB(disp) ((disp)->GetActiveAttribARB)
+#define SET_GetActiveAttribARB(disp, fn) ((disp)->GetActiveAttribARB = fn)
+#define CALL_GetAttribLocationARB(disp, parameters) (*((disp)->GetAttribLocationARB)) parameters
+#define GET_GetAttribLocationARB(disp) ((disp)->GetAttribLocationARB)
+#define SET_GetAttribLocationARB(disp, fn) ((disp)->GetAttribLocationARB = fn)
+#define CALL_GetVertexAttribdvNV(disp, parameters) (*((disp)->GetVertexAttribdvNV)) parameters
+#define GET_GetVertexAttribdvNV(disp) ((disp)->GetVertexAttribdvNV)
+#define SET_GetVertexAttribdvNV(disp, fn) ((disp)->GetVertexAttribdvNV = fn)
+#define CALL_GetVertexAttribfvNV(disp, parameters) (*((disp)->GetVertexAttribfvNV)) parameters
+#define GET_GetVertexAttribfvNV(disp) ((disp)->GetVertexAttribfvNV)
+#define SET_GetVertexAttribfvNV(disp, fn) ((disp)->GetVertexAttribfvNV = fn)
+#define CALL_GetVertexAttribivNV(disp, parameters) (*((disp)->GetVertexAttribivNV)) parameters
+#define GET_GetVertexAttribivNV(disp) ((disp)->GetVertexAttribivNV)
+#define SET_GetVertexAttribivNV(disp, fn) ((disp)->GetVertexAttribivNV = fn)
+#define CALL_VertexAttrib1dNV(disp, parameters) (*((disp)->VertexAttrib1dNV)) parameters
+#define GET_VertexAttrib1dNV(disp) ((disp)->VertexAttrib1dNV)
+#define SET_VertexAttrib1dNV(disp, fn) ((disp)->VertexAttrib1dNV = fn)
+#define CALL_VertexAttrib1dvNV(disp, parameters) (*((disp)->VertexAttrib1dvNV)) parameters
+#define GET_VertexAttrib1dvNV(disp) ((disp)->VertexAttrib1dvNV)
+#define SET_VertexAttrib1dvNV(disp, fn) ((disp)->VertexAttrib1dvNV = fn)
+#define CALL_VertexAttrib1fNV(disp, parameters) (*((disp)->VertexAttrib1fNV)) parameters
+#define GET_VertexAttrib1fNV(disp) ((disp)->VertexAttrib1fNV)
+#define SET_VertexAttrib1fNV(disp, fn) ((disp)->VertexAttrib1fNV = fn)
+#define CALL_VertexAttrib1fvNV(disp, parameters) (*((disp)->VertexAttrib1fvNV)) parameters
+#define GET_VertexAttrib1fvNV(disp) ((disp)->VertexAttrib1fvNV)
+#define SET_VertexAttrib1fvNV(disp, fn) ((disp)->VertexAttrib1fvNV = fn)
+#define CALL_VertexAttrib1sNV(disp, parameters) (*((disp)->VertexAttrib1sNV)) parameters
+#define GET_VertexAttrib1sNV(disp) ((disp)->VertexAttrib1sNV)
+#define SET_VertexAttrib1sNV(disp, fn) ((disp)->VertexAttrib1sNV = fn)
+#define CALL_VertexAttrib1svNV(disp, parameters) (*((disp)->VertexAttrib1svNV)) parameters
+#define GET_VertexAttrib1svNV(disp) ((disp)->VertexAttrib1svNV)
+#define SET_VertexAttrib1svNV(disp, fn) ((disp)->VertexAttrib1svNV = fn)
+#define CALL_VertexAttrib2dNV(disp, parameters) (*((disp)->VertexAttrib2dNV)) parameters
+#define GET_VertexAttrib2dNV(disp) ((disp)->VertexAttrib2dNV)
+#define SET_VertexAttrib2dNV(disp, fn) ((disp)->VertexAttrib2dNV = fn)
+#define CALL_VertexAttrib2dvNV(disp, parameters) (*((disp)->VertexAttrib2dvNV)) parameters
+#define GET_VertexAttrib2dvNV(disp) ((disp)->VertexAttrib2dvNV)
+#define SET_VertexAttrib2dvNV(disp, fn) ((disp)->VertexAttrib2dvNV = fn)
+#define CALL_VertexAttrib2fNV(disp, parameters) (*((disp)->VertexAttrib2fNV)) parameters
+#define GET_VertexAttrib2fNV(disp) ((disp)->VertexAttrib2fNV)
+#define SET_VertexAttrib2fNV(disp, fn) ((disp)->VertexAttrib2fNV = fn)
+#define CALL_VertexAttrib2fvNV(disp, parameters) (*((disp)->VertexAttrib2fvNV)) parameters
+#define GET_VertexAttrib2fvNV(disp) ((disp)->VertexAttrib2fvNV)
+#define SET_VertexAttrib2fvNV(disp, fn) ((disp)->VertexAttrib2fvNV = fn)
+#define CALL_VertexAttrib2sNV(disp, parameters) (*((disp)->VertexAttrib2sNV)) parameters
+#define GET_VertexAttrib2sNV(disp) ((disp)->VertexAttrib2sNV)
+#define SET_VertexAttrib2sNV(disp, fn) ((disp)->VertexAttrib2sNV = fn)
+#define CALL_VertexAttrib2svNV(disp, parameters) (*((disp)->VertexAttrib2svNV)) parameters
+#define GET_VertexAttrib2svNV(disp) ((disp)->VertexAttrib2svNV)
+#define SET_VertexAttrib2svNV(disp, fn) ((disp)->VertexAttrib2svNV = fn)
+#define CALL_VertexAttrib3dNV(disp, parameters) (*((disp)->VertexAttrib3dNV)) parameters
+#define GET_VertexAttrib3dNV(disp) ((disp)->VertexAttrib3dNV)
+#define SET_VertexAttrib3dNV(disp, fn) ((disp)->VertexAttrib3dNV = fn)
+#define CALL_VertexAttrib3dvNV(disp, parameters) (*((disp)->VertexAttrib3dvNV)) parameters
+#define GET_VertexAttrib3dvNV(disp) ((disp)->VertexAttrib3dvNV)
+#define SET_VertexAttrib3dvNV(disp, fn) ((disp)->VertexAttrib3dvNV = fn)
+#define CALL_VertexAttrib3fNV(disp, parameters) (*((disp)->VertexAttrib3fNV)) parameters
+#define GET_VertexAttrib3fNV(disp) ((disp)->VertexAttrib3fNV)
+#define SET_VertexAttrib3fNV(disp, fn) ((disp)->VertexAttrib3fNV = fn)
+#define CALL_VertexAttrib3fvNV(disp, parameters) (*((disp)->VertexAttrib3fvNV)) parameters
+#define GET_VertexAttrib3fvNV(disp) ((disp)->VertexAttrib3fvNV)
+#define SET_VertexAttrib3fvNV(disp, fn) ((disp)->VertexAttrib3fvNV = fn)
+#define CALL_VertexAttrib3sNV(disp, parameters) (*((disp)->VertexAttrib3sNV)) parameters
+#define GET_VertexAttrib3sNV(disp) ((disp)->VertexAttrib3sNV)
+#define SET_VertexAttrib3sNV(disp, fn) ((disp)->VertexAttrib3sNV = fn)
+#define CALL_VertexAttrib3svNV(disp, parameters) (*((disp)->VertexAttrib3svNV)) parameters
+#define GET_VertexAttrib3svNV(disp) ((disp)->VertexAttrib3svNV)
+#define SET_VertexAttrib3svNV(disp, fn) ((disp)->VertexAttrib3svNV = fn)
+#define CALL_VertexAttrib4dNV(disp, parameters) (*((disp)->VertexAttrib4dNV)) parameters
+#define GET_VertexAttrib4dNV(disp) ((disp)->VertexAttrib4dNV)
+#define SET_VertexAttrib4dNV(disp, fn) ((disp)->VertexAttrib4dNV = fn)
+#define CALL_VertexAttrib4dvNV(disp, parameters) (*((disp)->VertexAttrib4dvNV)) parameters
+#define GET_VertexAttrib4dvNV(disp) ((disp)->VertexAttrib4dvNV)
+#define SET_VertexAttrib4dvNV(disp, fn) ((disp)->VertexAttrib4dvNV = fn)
+#define CALL_VertexAttrib4fNV(disp, parameters) (*((disp)->VertexAttrib4fNV)) parameters
+#define GET_VertexAttrib4fNV(disp) ((disp)->VertexAttrib4fNV)
+#define SET_VertexAttrib4fNV(disp, fn) ((disp)->VertexAttrib4fNV = fn)
+#define CALL_VertexAttrib4fvNV(disp, parameters) (*((disp)->VertexAttrib4fvNV)) parameters
+#define GET_VertexAttrib4fvNV(disp) ((disp)->VertexAttrib4fvNV)
+#define SET_VertexAttrib4fvNV(disp, fn) ((disp)->VertexAttrib4fvNV = fn)
+#define CALL_VertexAttrib4sNV(disp, parameters) (*((disp)->VertexAttrib4sNV)) parameters
+#define GET_VertexAttrib4sNV(disp) ((disp)->VertexAttrib4sNV)
+#define SET_VertexAttrib4sNV(disp, fn) ((disp)->VertexAttrib4sNV = fn)
+#define CALL_VertexAttrib4svNV(disp, parameters) (*((disp)->VertexAttrib4svNV)) parameters
+#define GET_VertexAttrib4svNV(disp) ((disp)->VertexAttrib4svNV)
+#define SET_VertexAttrib4svNV(disp, fn) ((disp)->VertexAttrib4svNV = fn)
+#define CALL_VertexAttrib4ubNV(disp, parameters) (*((disp)->VertexAttrib4ubNV)) parameters
+#define GET_VertexAttrib4ubNV(disp) ((disp)->VertexAttrib4ubNV)
+#define SET_VertexAttrib4ubNV(disp, fn) ((disp)->VertexAttrib4ubNV = fn)
+#define CALL_VertexAttrib4ubvNV(disp, parameters) (*((disp)->VertexAttrib4ubvNV)) parameters
+#define GET_VertexAttrib4ubvNV(disp) ((disp)->VertexAttrib4ubvNV)
+#define SET_VertexAttrib4ubvNV(disp, fn) ((disp)->VertexAttrib4ubvNV = fn)
+#define CALL_GenFragmentShadersATI(disp, parameters) (*((disp)->GenFragmentShadersATI)) parameters
+#define GET_GenFragmentShadersATI(disp) ((disp)->GenFragmentShadersATI)
+#define SET_GenFragmentShadersATI(disp, fn) ((disp)->GenFragmentShadersATI = fn)
+#define CALL_BindFragmentShaderATI(disp, parameters) (*((disp)->BindFragmentShaderATI)) parameters
+#define GET_BindFragmentShaderATI(disp) ((disp)->BindFragmentShaderATI)
+#define SET_BindFragmentShaderATI(disp, fn) ((disp)->BindFragmentShaderATI = fn)
+#define CALL_DeleteFragmentShaderATI(disp, parameters) (*((disp)->DeleteFragmentShaderATI)) parameters
+#define GET_DeleteFragmentShaderATI(disp) ((disp)->DeleteFragmentShaderATI)
+#define SET_DeleteFragmentShaderATI(disp, fn) ((disp)->DeleteFragmentShaderATI = fn)
+#define CALL_BeginFragmentShaderATI(disp, parameters) (*((disp)->BeginFragmentShaderATI)) parameters
+#define GET_BeginFragmentShaderATI(disp) ((disp)->BeginFragmentShaderATI)
+#define SET_BeginFragmentShaderATI(disp, fn) ((disp)->BeginFragmentShaderATI = fn)
+#define CALL_EndFragmentShaderATI(disp, parameters) (*((disp)->EndFragmentShaderATI)) parameters
+#define GET_EndFragmentShaderATI(disp) ((disp)->EndFragmentShaderATI)
+#define SET_EndFragmentShaderATI(disp, fn) ((disp)->EndFragmentShaderATI = fn)
+#define CALL_PassTexCoordATI(disp, parameters) (*((disp)->PassTexCoordATI)) parameters
+#define GET_PassTexCoordATI(disp) ((disp)->PassTexCoordATI)
+#define SET_PassTexCoordATI(disp, fn) ((disp)->PassTexCoordATI = fn)
+#define CALL_SampleMapATI(disp, parameters) (*((disp)->SampleMapATI)) parameters
+#define GET_SampleMapATI(disp) ((disp)->SampleMapATI)
+#define SET_SampleMapATI(disp, fn) ((disp)->SampleMapATI = fn)
+#define CALL_ColorFragmentOp1ATI(disp, parameters) (*((disp)->ColorFragmentOp1ATI)) parameters
+#define GET_ColorFragmentOp1ATI(disp) ((disp)->ColorFragmentOp1ATI)
+#define SET_ColorFragmentOp1ATI(disp, fn) ((disp)->ColorFragmentOp1ATI = fn)
+#define CALL_ColorFragmentOp2ATI(disp, parameters) (*((disp)->ColorFragmentOp2ATI)) parameters
+#define GET_ColorFragmentOp2ATI(disp) ((disp)->ColorFragmentOp2ATI)
+#define SET_ColorFragmentOp2ATI(disp, fn) ((disp)->ColorFragmentOp2ATI = fn)
+#define CALL_ColorFragmentOp3ATI(disp, parameters) (*((disp)->ColorFragmentOp3ATI)) parameters
+#define GET_ColorFragmentOp3ATI(disp) ((disp)->ColorFragmentOp3ATI)
+#define SET_ColorFragmentOp3ATI(disp, fn) ((disp)->ColorFragmentOp3ATI = fn)
+#define CALL_AlphaFragmentOp1ATI(disp, parameters) (*((disp)->AlphaFragmentOp1ATI)) parameters
+#define GET_AlphaFragmentOp1ATI(disp) ((disp)->AlphaFragmentOp1ATI)
+#define SET_AlphaFragmentOp1ATI(disp, fn) ((disp)->AlphaFragmentOp1ATI = fn)
+#define CALL_AlphaFragmentOp2ATI(disp, parameters) (*((disp)->AlphaFragmentOp2ATI)) parameters
+#define GET_AlphaFragmentOp2ATI(disp) ((disp)->AlphaFragmentOp2ATI)
+#define SET_AlphaFragmentOp2ATI(disp, fn) ((disp)->AlphaFragmentOp2ATI = fn)
+#define CALL_AlphaFragmentOp3ATI(disp, parameters) (*((disp)->AlphaFragmentOp3ATI)) parameters
+#define GET_AlphaFragmentOp3ATI(disp) ((disp)->AlphaFragmentOp3ATI)
+#define SET_AlphaFragmentOp3ATI(disp, fn) ((disp)->AlphaFragmentOp3ATI = fn)
+#define CALL_SetFragmentShaderConstantATI(disp, parameters) (*((disp)->SetFragmentShaderConstantATI)) parameters
+#define GET_SetFragmentShaderConstantATI(disp) ((disp)->SetFragmentShaderConstantATI)
+#define SET_SetFragmentShaderConstantATI(disp, fn) ((disp)->SetFragmentShaderConstantATI = fn)
+#define CALL_IsRenderbufferEXT(disp, parameters) (*((disp)->IsRenderbufferEXT)) parameters
+#define GET_IsRenderbufferEXT(disp) ((disp)->IsRenderbufferEXT)
+#define SET_IsRenderbufferEXT(disp, fn) ((disp)->IsRenderbufferEXT = fn)
+#define CALL_BindRenderbufferEXT(disp, parameters) (*((disp)->BindRenderbufferEXT)) parameters
+#define GET_BindRenderbufferEXT(disp) ((disp)->BindRenderbufferEXT)
+#define SET_BindRenderbufferEXT(disp, fn) ((disp)->BindRenderbufferEXT = fn)
+#define CALL_DeleteRenderbuffersEXT(disp, parameters) (*((disp)->DeleteRenderbuffersEXT)) parameters
+#define GET_DeleteRenderbuffersEXT(disp) ((disp)->DeleteRenderbuffersEXT)
+#define SET_DeleteRenderbuffersEXT(disp, fn) ((disp)->DeleteRenderbuffersEXT = fn)
+#define CALL_GenRenderbuffersEXT(disp, parameters) (*((disp)->GenRenderbuffersEXT)) parameters
+#define GET_GenRenderbuffersEXT(disp) ((disp)->GenRenderbuffersEXT)
+#define SET_GenRenderbuffersEXT(disp, fn) ((disp)->GenRenderbuffersEXT = fn)
+#define CALL_RenderbufferStorageEXT(disp, parameters) (*((disp)->RenderbufferStorageEXT)) parameters
+#define GET_RenderbufferStorageEXT(disp) ((disp)->RenderbufferStorageEXT)
+#define SET_RenderbufferStorageEXT(disp, fn) ((disp)->RenderbufferStorageEXT = fn)
+#define CALL_GetRenderbufferParameterivEXT(disp, parameters) (*((disp)->GetRenderbufferParameterivEXT)) parameters
+#define GET_GetRenderbufferParameterivEXT(disp) ((disp)->GetRenderbufferParameterivEXT)
+#define SET_GetRenderbufferParameterivEXT(disp, fn) ((disp)->GetRenderbufferParameterivEXT = fn)
+#define CALL_IsFramebufferEXT(disp, parameters) (*((disp)->IsFramebufferEXT)) parameters
+#define GET_IsFramebufferEXT(disp) ((disp)->IsFramebufferEXT)
+#define SET_IsFramebufferEXT(disp, fn) ((disp)->IsFramebufferEXT = fn)
+#define CALL_BindFramebufferEXT(disp, parameters) (*((disp)->BindFramebufferEXT)) parameters
+#define GET_BindFramebufferEXT(disp) ((disp)->BindFramebufferEXT)
+#define SET_BindFramebufferEXT(disp, fn) ((disp)->BindFramebufferEXT = fn)
+#define CALL_DeleteFramebuffersEXT(disp, parameters) (*((disp)->DeleteFramebuffersEXT)) parameters
+#define GET_DeleteFramebuffersEXT(disp) ((disp)->DeleteFramebuffersEXT)
+#define SET_DeleteFramebuffersEXT(disp, fn) ((disp)->DeleteFramebuffersEXT = fn)
+#define CALL_GenFramebuffersEXT(disp, parameters) (*((disp)->GenFramebuffersEXT)) parameters
+#define GET_GenFramebuffersEXT(disp) ((disp)->GenFramebuffersEXT)
+#define SET_GenFramebuffersEXT(disp, fn) ((disp)->GenFramebuffersEXT = fn)
+#define CALL_CheckFramebufferStatusEXT(disp, parameters) (*((disp)->CheckFramebufferStatusEXT)) parameters
+#define GET_CheckFramebufferStatusEXT(disp) ((disp)->CheckFramebufferStatusEXT)
+#define SET_CheckFramebufferStatusEXT(disp, fn) ((disp)->CheckFramebufferStatusEXT = fn)
+#define CALL_FramebufferTexture1DEXT(disp, parameters) (*((disp)->FramebufferTexture1DEXT)) parameters
+#define GET_FramebufferTexture1DEXT(disp) ((disp)->FramebufferTexture1DEXT)
+#define SET_FramebufferTexture1DEXT(disp, fn) ((disp)->FramebufferTexture1DEXT = fn)
+#define CALL_FramebufferTexture2DEXT(disp, parameters) (*((disp)->FramebufferTexture2DEXT)) parameters
+#define GET_FramebufferTexture2DEXT(disp) ((disp)->FramebufferTexture2DEXT)
+#define SET_FramebufferTexture2DEXT(disp, fn) ((disp)->FramebufferTexture2DEXT = fn)
+#define CALL_FramebufferTexture3DEXT(disp, parameters) (*((disp)->FramebufferTexture3DEXT)) parameters
+#define GET_FramebufferTexture3DEXT(disp) ((disp)->FramebufferTexture3DEXT)
+#define SET_FramebufferTexture3DEXT(disp, fn) ((disp)->FramebufferTexture3DEXT = fn)
+#define CALL_FramebufferRenderbufferEXT(disp, parameters) (*((disp)->FramebufferRenderbufferEXT)) parameters
+#define GET_FramebufferRenderbufferEXT(disp) ((disp)->FramebufferRenderbufferEXT)
+#define SET_FramebufferRenderbufferEXT(disp, fn) ((disp)->FramebufferRenderbufferEXT = fn)
+#define CALL_GetFramebufferAttachmentParameterivEXT(disp, parameters) (*((disp)->GetFramebufferAttachmentParameterivEXT)) parameters
+#define GET_GetFramebufferAttachmentParameterivEXT(disp) ((disp)->GetFramebufferAttachmentParameterivEXT)
+#define SET_GetFramebufferAttachmentParameterivEXT(disp, fn) ((disp)->GetFramebufferAttachmentParameterivEXT = fn)
+#define CALL_GenerateMipmapEXT(disp, parameters) (*((disp)->GenerateMipmapEXT)) parameters
+#define GET_GenerateMipmapEXT(disp) ((disp)->GenerateMipmapEXT)
+#define SET_GenerateMipmapEXT(disp, fn) ((disp)->GenerateMipmapEXT = fn)
+#define CALL_StencilFuncSeparate(disp, parameters) (*((disp)->StencilFuncSeparate)) parameters
+#define GET_StencilFuncSeparate(disp) ((disp)->StencilFuncSeparate)
+#define SET_StencilFuncSeparate(disp, fn) ((disp)->StencilFuncSeparate = fn)
+#define CALL_StencilOpSeparate(disp, parameters) (*((disp)->StencilOpSeparate)) parameters
+#define GET_StencilOpSeparate(disp) ((disp)->StencilOpSeparate)
+#define SET_StencilOpSeparate(disp, fn) ((disp)->StencilOpSeparate = fn)
+#define CALL_StencilMaskSeparate(disp, parameters) (*((disp)->StencilMaskSeparate)) parameters
+#define GET_StencilMaskSeparate(disp) ((disp)->StencilMaskSeparate)
+#define SET_StencilMaskSeparate(disp, fn) ((disp)->StencilMaskSeparate = fn)
+
+#else
+
+#define driDispatchRemapTable_size 408
+extern int driDispatchRemapTable[ driDispatchRemapTable_size ];
+
+#define LoadTransposeMatrixfARB_remap_index 0
+#define LoadTransposeMatrixdARB_remap_index 1
+#define MultTransposeMatrixfARB_remap_index 2
+#define MultTransposeMatrixdARB_remap_index 3
+#define SampleCoverageARB_remap_index 4
+#define DrawBuffersARB_remap_index 5
+#define PolygonOffsetEXT_remap_index 6
+#define GetTexFilterFuncSGIS_remap_index 7
+#define TexFilterFuncSGIS_remap_index 8
+#define GetHistogramEXT_remap_index 9
+#define GetHistogramParameterfvEXT_remap_index 10
+#define GetHistogramParameterivEXT_remap_index 11
+#define GetMinmaxEXT_remap_index 12
+#define GetMinmaxParameterfvEXT_remap_index 13
+#define GetMinmaxParameterivEXT_remap_index 14
+#define GetConvolutionFilterEXT_remap_index 15
+#define GetConvolutionParameterfvEXT_remap_index 16
+#define GetConvolutionParameterivEXT_remap_index 17
+#define GetSeparableFilterEXT_remap_index 18
+#define GetColorTableSGI_remap_index 19
+#define GetColorTableParameterfvSGI_remap_index 20
+#define GetColorTableParameterivSGI_remap_index 21
+#define PixelTexGenSGIX_remap_index 22
+#define PixelTexGenParameteriSGIS_remap_index 23
+#define PixelTexGenParameterivSGIS_remap_index 24
+#define PixelTexGenParameterfSGIS_remap_index 25
+#define PixelTexGenParameterfvSGIS_remap_index 26
+#define GetPixelTexGenParameterivSGIS_remap_index 27
+#define GetPixelTexGenParameterfvSGIS_remap_index 28
+#define TexImage4DSGIS_remap_index 29
+#define TexSubImage4DSGIS_remap_index 30
+#define AreTexturesResidentEXT_remap_index 31
+#define GenTexturesEXT_remap_index 32
+#define IsTextureEXT_remap_index 33
+#define DetailTexFuncSGIS_remap_index 34
+#define GetDetailTexFuncSGIS_remap_index 35
+#define SharpenTexFuncSGIS_remap_index 36
+#define GetSharpenTexFuncSGIS_remap_index 37
+#define SampleMaskSGIS_remap_index 38
+#define SamplePatternSGIS_remap_index 39
+#define ColorPointerEXT_remap_index 40
+#define EdgeFlagPointerEXT_remap_index 41
+#define IndexPointerEXT_remap_index 42
+#define NormalPointerEXT_remap_index 43
+#define TexCoordPointerEXT_remap_index 44
+#define VertexPointerEXT_remap_index 45
+#define SpriteParameterfSGIX_remap_index 46
+#define SpriteParameterfvSGIX_remap_index 47
+#define SpriteParameteriSGIX_remap_index 48
+#define SpriteParameterivSGIX_remap_index 49
+#define PointParameterfEXT_remap_index 50
+#define PointParameterfvEXT_remap_index 51
+#define GetInstrumentsSGIX_remap_index 52
+#define InstrumentsBufferSGIX_remap_index 53
+#define PollInstrumentsSGIX_remap_index 54
+#define ReadInstrumentsSGIX_remap_index 55
+#define StartInstrumentsSGIX_remap_index 56
+#define StopInstrumentsSGIX_remap_index 57
+#define FrameZoomSGIX_remap_index 58
+#define TagSampleBufferSGIX_remap_index 59
+#define ReferencePlaneSGIX_remap_index 60
+#define FlushRasterSGIX_remap_index 61
+#define GetListParameterfvSGIX_remap_index 62
+#define GetListParameterivSGIX_remap_index 63
+#define ListParameterfSGIX_remap_index 64
+#define ListParameterfvSGIX_remap_index 65
+#define ListParameteriSGIX_remap_index 66
+#define ListParameterivSGIX_remap_index 67
+#define FragmentColorMaterialSGIX_remap_index 68
+#define FragmentLightfSGIX_remap_index 69
+#define FragmentLightfvSGIX_remap_index 70
+#define FragmentLightiSGIX_remap_index 71
+#define FragmentLightivSGIX_remap_index 72
+#define FragmentLightModelfSGIX_remap_index 73
+#define FragmentLightModelfvSGIX_remap_index 74
+#define FragmentLightModeliSGIX_remap_index 75
+#define FragmentLightModelivSGIX_remap_index 76
+#define FragmentMaterialfSGIX_remap_index 77
+#define FragmentMaterialfvSGIX_remap_index 78
+#define FragmentMaterialiSGIX_remap_index 79
+#define FragmentMaterialivSGIX_remap_index 80
+#define GetFragmentLightfvSGIX_remap_index 81
+#define GetFragmentLightivSGIX_remap_index 82
+#define GetFragmentMaterialfvSGIX_remap_index 83
+#define GetFragmentMaterialivSGIX_remap_index 84
+#define LightEnviSGIX_remap_index 85
+#define VertexWeightfEXT_remap_index 86
+#define VertexWeightfvEXT_remap_index 87
+#define VertexWeightPointerEXT_remap_index 88
+#define FlushVertexArrayRangeNV_remap_index 89
+#define VertexArrayRangeNV_remap_index 90
+#define CombinerParameterfvNV_remap_index 91
+#define CombinerParameterfNV_remap_index 92
+#define CombinerParameterivNV_remap_index 93
+#define CombinerParameteriNV_remap_index 94
+#define CombinerInputNV_remap_index 95
+#define CombinerOutputNV_remap_index 96
+#define FinalCombinerInputNV_remap_index 97
+#define GetCombinerInputParameterfvNV_remap_index 98
+#define GetCombinerInputParameterivNV_remap_index 99
+#define GetCombinerOutputParameterfvNV_remap_index 100
+#define GetCombinerOutputParameterivNV_remap_index 101
+#define GetFinalCombinerInputParameterfvNV_remap_index 102
+#define GetFinalCombinerInputParameterivNV_remap_index 103
+#define ResizeBuffersMESA_remap_index 104
+#define WindowPos2dMESA_remap_index 105
+#define WindowPos2dvMESA_remap_index 106
+#define WindowPos2fMESA_remap_index 107
+#define WindowPos2fvMESA_remap_index 108
+#define WindowPos2iMESA_remap_index 109
+#define WindowPos2ivMESA_remap_index 110
+#define WindowPos2sMESA_remap_index 111
+#define WindowPos2svMESA_remap_index 112
+#define WindowPos3dMESA_remap_index 113
+#define WindowPos3dvMESA_remap_index 114
+#define WindowPos3fMESA_remap_index 115
+#define WindowPos3fvMESA_remap_index 116
+#define WindowPos3iMESA_remap_index 117
+#define WindowPos3ivMESA_remap_index 118
+#define WindowPos3sMESA_remap_index 119
+#define WindowPos3svMESA_remap_index 120
+#define WindowPos4dMESA_remap_index 121
+#define WindowPos4dvMESA_remap_index 122
+#define WindowPos4fMESA_remap_index 123
+#define WindowPos4fvMESA_remap_index 124
+#define WindowPos4iMESA_remap_index 125
+#define WindowPos4ivMESA_remap_index 126
+#define WindowPos4sMESA_remap_index 127
+#define WindowPos4svMESA_remap_index 128
+#define BlendFuncSeparateEXT_remap_index 129
+#define IndexMaterialEXT_remap_index 130
+#define IndexFuncEXT_remap_index 131
+#define LockArraysEXT_remap_index 132
+#define UnlockArraysEXT_remap_index 133
+#define CullParameterdvEXT_remap_index 134
+#define CullParameterfvEXT_remap_index 135
+#define HintPGI_remap_index 136
+#define FogCoordfEXT_remap_index 137
+#define FogCoordfvEXT_remap_index 138
+#define FogCoorddEXT_remap_index 139
+#define FogCoorddvEXT_remap_index 140
+#define FogCoordPointerEXT_remap_index 141
+#define GetColorTableEXT_remap_index 142
+#define GetColorTableParameterivEXT_remap_index 143
+#define GetColorTableParameterfvEXT_remap_index 144
+#define TbufferMask3DFX_remap_index 145
+#define CompressedTexImage3DARB_remap_index 146
+#define CompressedTexImage2DARB_remap_index 147
+#define CompressedTexImage1DARB_remap_index 148
+#define CompressedTexSubImage3DARB_remap_index 149
+#define CompressedTexSubImage2DARB_remap_index 150
+#define CompressedTexSubImage1DARB_remap_index 151
+#define GetCompressedTexImageARB_remap_index 152
+#define SecondaryColor3bEXT_remap_index 153
+#define SecondaryColor3bvEXT_remap_index 154
+#define SecondaryColor3dEXT_remap_index 155
+#define SecondaryColor3dvEXT_remap_index 156
+#define SecondaryColor3fEXT_remap_index 157
+#define SecondaryColor3fvEXT_remap_index 158
+#define SecondaryColor3iEXT_remap_index 159
+#define SecondaryColor3ivEXT_remap_index 160
+#define SecondaryColor3sEXT_remap_index 161
+#define SecondaryColor3svEXT_remap_index 162
+#define SecondaryColor3ubEXT_remap_index 163
+#define SecondaryColor3ubvEXT_remap_index 164
+#define SecondaryColor3uiEXT_remap_index 165
+#define SecondaryColor3uivEXT_remap_index 166
+#define SecondaryColor3usEXT_remap_index 167
+#define SecondaryColor3usvEXT_remap_index 168
+#define SecondaryColorPointerEXT_remap_index 169
+#define AreProgramsResidentNV_remap_index 170
+#define BindProgramNV_remap_index 171
+#define DeleteProgramsNV_remap_index 172
+#define ExecuteProgramNV_remap_index 173
+#define GenProgramsNV_remap_index 174
+#define GetProgramParameterdvNV_remap_index 175
+#define GetProgramParameterfvNV_remap_index 176
+#define GetProgramivNV_remap_index 177
+#define GetProgramStringNV_remap_index 178
+#define GetTrackMatrixivNV_remap_index 179
+#define GetVertexAttribdvARB_remap_index 180
+#define GetVertexAttribfvARB_remap_index 181
+#define GetVertexAttribivARB_remap_index 182
+#define GetVertexAttribPointervNV_remap_index 183
+#define IsProgramNV_remap_index 184
+#define LoadProgramNV_remap_index 185
+#define ProgramParameter4dNV_remap_index 186
+#define ProgramParameter4dvNV_remap_index 187
+#define ProgramParameter4fNV_remap_index 188
+#define ProgramParameter4fvNV_remap_index 189
+#define ProgramParameters4dvNV_remap_index 190
+#define ProgramParameters4fvNV_remap_index 191
+#define RequestResidentProgramsNV_remap_index 192
+#define TrackMatrixNV_remap_index 193
+#define VertexAttribPointerNV_remap_index 194
+#define VertexAttrib1dARB_remap_index 195
+#define VertexAttrib1dvARB_remap_index 196
+#define VertexAttrib1fARB_remap_index 197
+#define VertexAttrib1fvARB_remap_index 198
+#define VertexAttrib1sARB_remap_index 199
+#define VertexAttrib1svARB_remap_index 200
+#define VertexAttrib2dARB_remap_index 201
+#define VertexAttrib2dvARB_remap_index 202
+#define VertexAttrib2fARB_remap_index 203
+#define VertexAttrib2fvARB_remap_index 204
+#define VertexAttrib2sARB_remap_index 205
+#define VertexAttrib2svARB_remap_index 206
+#define VertexAttrib3dARB_remap_index 207
+#define VertexAttrib3dvARB_remap_index 208
+#define VertexAttrib3fARB_remap_index 209
+#define VertexAttrib3fvARB_remap_index 210
+#define VertexAttrib3sARB_remap_index 211
+#define VertexAttrib3svARB_remap_index 212
+#define VertexAttrib4dARB_remap_index 213
+#define VertexAttrib4dvARB_remap_index 214
+#define VertexAttrib4fARB_remap_index 215
+#define VertexAttrib4fvARB_remap_index 216
+#define VertexAttrib4sARB_remap_index 217
+#define VertexAttrib4svARB_remap_index 218
+#define VertexAttrib4NubARB_remap_index 219
+#define VertexAttrib4NubvARB_remap_index 220
+#define VertexAttribs1dvNV_remap_index 221
+#define VertexAttribs1fvNV_remap_index 222
+#define VertexAttribs1svNV_remap_index 223
+#define VertexAttribs2dvNV_remap_index 224
+#define VertexAttribs2fvNV_remap_index 225
+#define VertexAttribs2svNV_remap_index 226
+#define VertexAttribs3dvNV_remap_index 227
+#define VertexAttribs3fvNV_remap_index 228
+#define VertexAttribs3svNV_remap_index 229
+#define VertexAttribs4dvNV_remap_index 230
+#define VertexAttribs4fvNV_remap_index 231
+#define VertexAttribs4svNV_remap_index 232
+#define VertexAttribs4ubvNV_remap_index 233
+#define PointParameteriNV_remap_index 234
+#define PointParameterivNV_remap_index 235
+#define MultiDrawArraysEXT_remap_index 236
+#define MultiDrawElementsEXT_remap_index 237
+#define ActiveStencilFaceEXT_remap_index 238
+#define DeleteFencesNV_remap_index 239
+#define GenFencesNV_remap_index 240
+#define IsFenceNV_remap_index 241
+#define TestFenceNV_remap_index 242
+#define GetFenceivNV_remap_index 243
+#define FinishFenceNV_remap_index 244
+#define SetFenceNV_remap_index 245
+#define VertexAttrib4bvARB_remap_index 246
+#define VertexAttrib4ivARB_remap_index 247
+#define VertexAttrib4ubvARB_remap_index 248
+#define VertexAttrib4usvARB_remap_index 249
+#define VertexAttrib4uivARB_remap_index 250
+#define VertexAttrib4NbvARB_remap_index 251
+#define VertexAttrib4NsvARB_remap_index 252
+#define VertexAttrib4NivARB_remap_index 253
+#define VertexAttrib4NusvARB_remap_index 254
+#define VertexAttrib4NuivARB_remap_index 255
+#define VertexAttribPointerARB_remap_index 256
+#define EnableVertexAttribArrayARB_remap_index 257
+#define DisableVertexAttribArrayARB_remap_index 258
+#define ProgramStringARB_remap_index 259
+#define ProgramEnvParameter4dARB_remap_index 260
+#define ProgramEnvParameter4dvARB_remap_index 261
+#define ProgramEnvParameter4fARB_remap_index 262
+#define ProgramEnvParameter4fvARB_remap_index 263
+#define ProgramLocalParameter4dARB_remap_index 264
+#define ProgramLocalParameter4dvARB_remap_index 265
+#define ProgramLocalParameter4fARB_remap_index 266
+#define ProgramLocalParameter4fvARB_remap_index 267
+#define GetProgramEnvParameterdvARB_remap_index 268
+#define GetProgramEnvParameterfvARB_remap_index 269
+#define GetProgramLocalParameterdvARB_remap_index 270
+#define GetProgramLocalParameterfvARB_remap_index 271
+#define GetProgramivARB_remap_index 272
+#define GetProgramStringARB_remap_index 273
+#define ProgramNamedParameter4fNV_remap_index 274
+#define ProgramNamedParameter4dNV_remap_index 275
+#define ProgramNamedParameter4fvNV_remap_index 276
+#define ProgramNamedParameter4dvNV_remap_index 277
+#define GetProgramNamedParameterfvNV_remap_index 278
+#define GetProgramNamedParameterdvNV_remap_index 279
+#define BindBufferARB_remap_index 280
+#define BufferDataARB_remap_index 281
+#define BufferSubDataARB_remap_index 282
+#define DeleteBuffersARB_remap_index 283
+#define GenBuffersARB_remap_index 284
+#define GetBufferParameterivARB_remap_index 285
+#define GetBufferPointervARB_remap_index 286
+#define GetBufferSubDataARB_remap_index 287
+#define IsBufferARB_remap_index 288
+#define MapBufferARB_remap_index 289
+#define UnmapBufferARB_remap_index 290
+#define DepthBoundsEXT_remap_index 291
+#define GenQueriesARB_remap_index 292
+#define DeleteQueriesARB_remap_index 293
+#define IsQueryARB_remap_index 294
+#define BeginQueryARB_remap_index 295
+#define EndQueryARB_remap_index 296
+#define GetQueryivARB_remap_index 297
+#define GetQueryObjectivARB_remap_index 298
+#define GetQueryObjectuivARB_remap_index 299
+#define MultiModeDrawArraysIBM_remap_index 300
+#define MultiModeDrawElementsIBM_remap_index 301
+#define BlendEquationSeparateEXT_remap_index 302
+#define DeleteObjectARB_remap_index 303
+#define GetHandleARB_remap_index 304
+#define DetachObjectARB_remap_index 305
+#define CreateShaderObjectARB_remap_index 306
+#define ShaderSourceARB_remap_index 307
+#define CompileShaderARB_remap_index 308
+#define CreateProgramObjectARB_remap_index 309
+#define AttachObjectARB_remap_index 310
+#define LinkProgramARB_remap_index 311
+#define UseProgramObjectARB_remap_index 312
+#define ValidateProgramARB_remap_index 313
+#define Uniform1fARB_remap_index 314
+#define Uniform2fARB_remap_index 315
+#define Uniform3fARB_remap_index 316
+#define Uniform4fARB_remap_index 317
+#define Uniform1iARB_remap_index 318
+#define Uniform2iARB_remap_index 319
+#define Uniform3iARB_remap_index 320
+#define Uniform4iARB_remap_index 321
+#define Uniform1fvARB_remap_index 322
+#define Uniform2fvARB_remap_index 323
+#define Uniform3fvARB_remap_index 324
+#define Uniform4fvARB_remap_index 325
+#define Uniform1ivARB_remap_index 326
+#define Uniform2ivARB_remap_index 327
+#define Uniform3ivARB_remap_index 328
+#define Uniform4ivARB_remap_index 329
+#define UniformMatrix2fvARB_remap_index 330
+#define UniformMatrix3fvARB_remap_index 331
+#define UniformMatrix4fvARB_remap_index 332
+#define GetObjectParameterfvARB_remap_index 333
+#define GetObjectParameterivARB_remap_index 334
+#define GetInfoLogARB_remap_index 335
+#define GetAttachedObjectsARB_remap_index 336
+#define GetUniformLocationARB_remap_index 337
+#define GetActiveUniformARB_remap_index 338
+#define GetUniformfvARB_remap_index 339
+#define GetUniformivARB_remap_index 340
+#define GetShaderSourceARB_remap_index 341
+#define BindAttribLocationARB_remap_index 342
+#define GetActiveAttribARB_remap_index 343
+#define GetAttribLocationARB_remap_index 344
+#define GetVertexAttribdvNV_remap_index 345
+#define GetVertexAttribfvNV_remap_index 346
+#define GetVertexAttribivNV_remap_index 347
+#define VertexAttrib1dNV_remap_index 348
+#define VertexAttrib1dvNV_remap_index 349
+#define VertexAttrib1fNV_remap_index 350
+#define VertexAttrib1fvNV_remap_index 351
+#define VertexAttrib1sNV_remap_index 352
+#define VertexAttrib1svNV_remap_index 353
+#define VertexAttrib2dNV_remap_index 354
+#define VertexAttrib2dvNV_remap_index 355
+#define VertexAttrib2fNV_remap_index 356
+#define VertexAttrib2fvNV_remap_index 357
+#define VertexAttrib2sNV_remap_index 358
+#define VertexAttrib2svNV_remap_index 359
+#define VertexAttrib3dNV_remap_index 360
+#define VertexAttrib3dvNV_remap_index 361
+#define VertexAttrib3fNV_remap_index 362
+#define VertexAttrib3fvNV_remap_index 363
+#define VertexAttrib3sNV_remap_index 364
+#define VertexAttrib3svNV_remap_index 365
+#define VertexAttrib4dNV_remap_index 366
+#define VertexAttrib4dvNV_remap_index 367
+#define VertexAttrib4fNV_remap_index 368
+#define VertexAttrib4fvNV_remap_index 369
+#define VertexAttrib4sNV_remap_index 370
+#define VertexAttrib4svNV_remap_index 371
+#define VertexAttrib4ubNV_remap_index 372
+#define VertexAttrib4ubvNV_remap_index 373
+#define GenFragmentShadersATI_remap_index 374
+#define BindFragmentShaderATI_remap_index 375
+#define DeleteFragmentShaderATI_remap_index 376
+#define BeginFragmentShaderATI_remap_index 377
+#define EndFragmentShaderATI_remap_index 378
+#define PassTexCoordATI_remap_index 379
+#define SampleMapATI_remap_index 380
+#define ColorFragmentOp1ATI_remap_index 381
+#define ColorFragmentOp2ATI_remap_index 382
+#define ColorFragmentOp3ATI_remap_index 383
+#define AlphaFragmentOp1ATI_remap_index 384
+#define AlphaFragmentOp2ATI_remap_index 385
+#define AlphaFragmentOp3ATI_remap_index 386
+#define SetFragmentShaderConstantATI_remap_index 387
+#define IsRenderbufferEXT_remap_index 388
+#define BindRenderbufferEXT_remap_index 389
+#define DeleteRenderbuffersEXT_remap_index 390
+#define GenRenderbuffersEXT_remap_index 391
+#define RenderbufferStorageEXT_remap_index 392
+#define GetRenderbufferParameterivEXT_remap_index 393
+#define IsFramebufferEXT_remap_index 394
+#define BindFramebufferEXT_remap_index 395
+#define DeleteFramebuffersEXT_remap_index 396
+#define GenFramebuffersEXT_remap_index 397
+#define CheckFramebufferStatusEXT_remap_index 398
+#define FramebufferTexture1DEXT_remap_index 399
+#define FramebufferTexture2DEXT_remap_index 400
+#define FramebufferTexture3DEXT_remap_index 401
+#define FramebufferRenderbufferEXT_remap_index 402
+#define GetFramebufferAttachmentParameterivEXT_remap_index 403
+#define GenerateMipmapEXT_remap_index 404
+#define StencilFuncSeparate_remap_index 405
+#define StencilOpSeparate_remap_index 406
+#define StencilMaskSeparate_remap_index 407
+
+#define CALL_LoadTransposeMatrixfARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[LoadTransposeMatrixfARB_remap_index], parameters)
+#define GET_LoadTransposeMatrixfARB(disp) GET_by_offset(disp, driDispatchRemapTable[LoadTransposeMatrixfARB_remap_index])
+#define SET_LoadTransposeMatrixfARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[LoadTransposeMatrixfARB_remap_index], fn)
+#define CALL_LoadTransposeMatrixdARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[LoadTransposeMatrixdARB_remap_index], parameters)
+#define GET_LoadTransposeMatrixdARB(disp) GET_by_offset(disp, driDispatchRemapTable[LoadTransposeMatrixdARB_remap_index])
+#define SET_LoadTransposeMatrixdARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[LoadTransposeMatrixdARB_remap_index], fn)
+#define CALL_MultTransposeMatrixfARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[MultTransposeMatrixfARB_remap_index], parameters)
+#define GET_MultTransposeMatrixfARB(disp) GET_by_offset(disp, driDispatchRemapTable[MultTransposeMatrixfARB_remap_index])
+#define SET_MultTransposeMatrixfARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultTransposeMatrixfARB_remap_index], fn)
+#define CALL_MultTransposeMatrixdARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[MultTransposeMatrixdARB_remap_index], parameters)
+#define GET_MultTransposeMatrixdARB(disp) GET_by_offset(disp, driDispatchRemapTable[MultTransposeMatrixdARB_remap_index])
+#define SET_MultTransposeMatrixdARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultTransposeMatrixdARB_remap_index], fn)
+#define CALL_SampleCoverageARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLclampf, GLboolean)), driDispatchRemapTable[SampleCoverageARB_remap_index], parameters)
+#define GET_SampleCoverageARB(disp) GET_by_offset(disp, driDispatchRemapTable[SampleCoverageARB_remap_index])
+#define SET_SampleCoverageARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SampleCoverageARB_remap_index], fn)
+#define CALL_DrawBuffersARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLenum *)), driDispatchRemapTable[DrawBuffersARB_remap_index], parameters)
+#define GET_DrawBuffersARB(disp) GET_by_offset(disp, driDispatchRemapTable[DrawBuffersARB_remap_index])
+#define SET_DrawBuffersARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DrawBuffersARB_remap_index], fn)
+#define CALL_PolygonOffsetEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat)), driDispatchRemapTable[PolygonOffsetEXT_remap_index], parameters)
+#define GET_PolygonOffsetEXT(disp) GET_by_offset(disp, driDispatchRemapTable[PolygonOffsetEXT_remap_index])
+#define SET_PolygonOffsetEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PolygonOffsetEXT_remap_index], fn)
+#define CALL_GetTexFilterFuncSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), driDispatchRemapTable[GetTexFilterFuncSGIS_remap_index], parameters)
+#define GET_GetTexFilterFuncSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[GetTexFilterFuncSGIS_remap_index])
+#define SET_GetTexFilterFuncSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetTexFilterFuncSGIS_remap_index], fn)
+#define CALL_TexFilterFuncSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLsizei, const GLfloat *)), driDispatchRemapTable[TexFilterFuncSGIS_remap_index], parameters)
+#define GET_TexFilterFuncSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[TexFilterFuncSGIS_remap_index])
+#define SET_TexFilterFuncSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TexFilterFuncSGIS_remap_index], fn)
+#define CALL_GetHistogramEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLboolean, GLenum, GLenum, GLvoid *)), driDispatchRemapTable[GetHistogramEXT_remap_index], parameters)
+#define GET_GetHistogramEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetHistogramEXT_remap_index])
+#define SET_GetHistogramEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetHistogramEXT_remap_index], fn)
+#define CALL_GetHistogramParameterfvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), driDispatchRemapTable[GetHistogramParameterfvEXT_remap_index], parameters)
+#define GET_GetHistogramParameterfvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetHistogramParameterfvEXT_remap_index])
+#define SET_GetHistogramParameterfvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetHistogramParameterfvEXT_remap_index], fn)
+#define CALL_GetHistogramParameterivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetHistogramParameterivEXT_remap_index], parameters)
+#define GET_GetHistogramParameterivEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetHistogramParameterivEXT_remap_index])
+#define SET_GetHistogramParameterivEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetHistogramParameterivEXT_remap_index], fn)
+#define CALL_GetMinmaxEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLboolean, GLenum, GLenum, GLvoid *)), driDispatchRemapTable[GetMinmaxEXT_remap_index], parameters)
+#define GET_GetMinmaxEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetMinmaxEXT_remap_index])
+#define SET_GetMinmaxEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetMinmaxEXT_remap_index], fn)
+#define CALL_GetMinmaxParameterfvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), driDispatchRemapTable[GetMinmaxParameterfvEXT_remap_index], parameters)
+#define GET_GetMinmaxParameterfvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetMinmaxParameterfvEXT_remap_index])
+#define SET_GetMinmaxParameterfvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetMinmaxParameterfvEXT_remap_index], fn)
+#define CALL_GetMinmaxParameterivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetMinmaxParameterivEXT_remap_index], parameters)
+#define GET_GetMinmaxParameterivEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetMinmaxParameterivEXT_remap_index])
+#define SET_GetMinmaxParameterivEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetMinmaxParameterivEXT_remap_index], fn)
+#define CALL_GetConvolutionFilterEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLvoid *)), driDispatchRemapTable[GetConvolutionFilterEXT_remap_index], parameters)
+#define GET_GetConvolutionFilterEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetConvolutionFilterEXT_remap_index])
+#define SET_GetConvolutionFilterEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetConvolutionFilterEXT_remap_index], fn)
+#define CALL_GetConvolutionParameterfvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), driDispatchRemapTable[GetConvolutionParameterfvEXT_remap_index], parameters)
+#define GET_GetConvolutionParameterfvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetConvolutionParameterfvEXT_remap_index])
+#define SET_GetConvolutionParameterfvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetConvolutionParameterfvEXT_remap_index], fn)
+#define CALL_GetConvolutionParameterivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetConvolutionParameterivEXT_remap_index], parameters)
+#define GET_GetConvolutionParameterivEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetConvolutionParameterivEXT_remap_index])
+#define SET_GetConvolutionParameterivEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetConvolutionParameterivEXT_remap_index], fn)
+#define CALL_GetSeparableFilterEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *)), driDispatchRemapTable[GetSeparableFilterEXT_remap_index], parameters)
+#define GET_GetSeparableFilterEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetSeparableFilterEXT_remap_index])
+#define SET_GetSeparableFilterEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetSeparableFilterEXT_remap_index], fn)
+#define CALL_GetColorTableSGI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLvoid *)), driDispatchRemapTable[GetColorTableSGI_remap_index], parameters)
+#define GET_GetColorTableSGI(disp) GET_by_offset(disp, driDispatchRemapTable[GetColorTableSGI_remap_index])
+#define SET_GetColorTableSGI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetColorTableSGI_remap_index], fn)
+#define CALL_GetColorTableParameterfvSGI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), driDispatchRemapTable[GetColorTableParameterfvSGI_remap_index], parameters)
+#define GET_GetColorTableParameterfvSGI(disp) GET_by_offset(disp, driDispatchRemapTable[GetColorTableParameterfvSGI_remap_index])
+#define SET_GetColorTableParameterfvSGI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetColorTableParameterfvSGI_remap_index], fn)
+#define CALL_GetColorTableParameterivSGI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetColorTableParameterivSGI_remap_index], parameters)
+#define GET_GetColorTableParameterivSGI(disp) GET_by_offset(disp, driDispatchRemapTable[GetColorTableParameterivSGI_remap_index])
+#define SET_GetColorTableParameterivSGI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetColorTableParameterivSGI_remap_index], fn)
+#define CALL_PixelTexGenSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[PixelTexGenSGIX_remap_index], parameters)
+#define GET_PixelTexGenSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[PixelTexGenSGIX_remap_index])
+#define SET_PixelTexGenSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PixelTexGenSGIX_remap_index], fn)
+#define CALL_PixelTexGenParameteriSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), driDispatchRemapTable[PixelTexGenParameteriSGIS_remap_index], parameters)
+#define GET_PixelTexGenParameteriSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameteriSGIS_remap_index])
+#define SET_PixelTexGenParameteriSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameteriSGIS_remap_index], fn)
+#define CALL_PixelTexGenParameterivSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), driDispatchRemapTable[PixelTexGenParameterivSGIS_remap_index], parameters)
+#define GET_PixelTexGenParameterivSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterivSGIS_remap_index])
+#define SET_PixelTexGenParameterivSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterivSGIS_remap_index], fn)
+#define CALL_PixelTexGenParameterfSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), driDispatchRemapTable[PixelTexGenParameterfSGIS_remap_index], parameters)
+#define GET_PixelTexGenParameterfSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterfSGIS_remap_index])
+#define SET_PixelTexGenParameterfSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterfSGIS_remap_index], fn)
+#define CALL_PixelTexGenParameterfvSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), driDispatchRemapTable[PixelTexGenParameterfvSGIS_remap_index], parameters)
+#define GET_PixelTexGenParameterfvSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterfvSGIS_remap_index])
+#define SET_PixelTexGenParameterfvSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PixelTexGenParameterfvSGIS_remap_index], fn)
+#define CALL_GetPixelTexGenParameterivSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint *)), driDispatchRemapTable[GetPixelTexGenParameterivSGIS_remap_index], parameters)
+#define GET_GetPixelTexGenParameterivSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[GetPixelTexGenParameterivSGIS_remap_index])
+#define SET_GetPixelTexGenParameterivSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetPixelTexGenParameterivSGIS_remap_index], fn)
+#define CALL_GetPixelTexGenParameterfvSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat *)), driDispatchRemapTable[GetPixelTexGenParameterfvSGIS_remap_index], parameters)
+#define GET_GetPixelTexGenParameterfvSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[GetPixelTexGenParameterfvSGIS_remap_index])
+#define SET_GetPixelTexGenParameterfvSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetPixelTexGenParameterfvSGIS_remap_index], fn)
+#define CALL_TexImage4DSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *)), driDispatchRemapTable[TexImage4DSGIS_remap_index], parameters)
+#define GET_TexImage4DSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[TexImage4DSGIS_remap_index])
+#define SET_TexImage4DSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TexImage4DSGIS_remap_index], fn)
+#define CALL_TexSubImage4DSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *)), driDispatchRemapTable[TexSubImage4DSGIS_remap_index], parameters)
+#define GET_TexSubImage4DSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[TexSubImage4DSGIS_remap_index])
+#define SET_TexSubImage4DSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TexSubImage4DSGIS_remap_index], fn)
+#define CALL_AreTexturesResidentEXT(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLsizei, const GLuint *, GLboolean *)), driDispatchRemapTable[AreTexturesResidentEXT_remap_index], parameters)
+#define GET_AreTexturesResidentEXT(disp) GET_by_offset(disp, driDispatchRemapTable[AreTexturesResidentEXT_remap_index])
+#define SET_AreTexturesResidentEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AreTexturesResidentEXT_remap_index], fn)
+#define CALL_GenTexturesEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenTexturesEXT_remap_index], parameters)
+#define GET_GenTexturesEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GenTexturesEXT_remap_index])
+#define SET_GenTexturesEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenTexturesEXT_remap_index], fn)
+#define CALL_IsTextureEXT(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsTextureEXT_remap_index], parameters)
+#define GET_IsTextureEXT(disp) GET_by_offset(disp, driDispatchRemapTable[IsTextureEXT_remap_index])
+#define SET_IsTextureEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsTextureEXT_remap_index], fn)
+#define CALL_DetailTexFuncSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, const GLfloat *)), driDispatchRemapTable[DetailTexFuncSGIS_remap_index], parameters)
+#define GET_DetailTexFuncSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[DetailTexFuncSGIS_remap_index])
+#define SET_DetailTexFuncSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DetailTexFuncSGIS_remap_index], fn)
+#define CALL_GetDetailTexFuncSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat *)), driDispatchRemapTable[GetDetailTexFuncSGIS_remap_index], parameters)
+#define GET_GetDetailTexFuncSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[GetDetailTexFuncSGIS_remap_index])
+#define SET_GetDetailTexFuncSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetDetailTexFuncSGIS_remap_index], fn)
+#define CALL_SharpenTexFuncSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, const GLfloat *)), driDispatchRemapTable[SharpenTexFuncSGIS_remap_index], parameters)
+#define GET_SharpenTexFuncSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[SharpenTexFuncSGIS_remap_index])
+#define SET_SharpenTexFuncSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SharpenTexFuncSGIS_remap_index], fn)
+#define CALL_GetSharpenTexFuncSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat *)), driDispatchRemapTable[GetSharpenTexFuncSGIS_remap_index], parameters)
+#define GET_GetSharpenTexFuncSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[GetSharpenTexFuncSGIS_remap_index])
+#define SET_GetSharpenTexFuncSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetSharpenTexFuncSGIS_remap_index], fn)
+#define CALL_SampleMaskSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLclampf, GLboolean)), driDispatchRemapTable[SampleMaskSGIS_remap_index], parameters)
+#define GET_SampleMaskSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[SampleMaskSGIS_remap_index])
+#define SET_SampleMaskSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SampleMaskSGIS_remap_index], fn)
+#define CALL_SamplePatternSGIS(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[SamplePatternSGIS_remap_index], parameters)
+#define GET_SamplePatternSGIS(disp) GET_by_offset(disp, driDispatchRemapTable[SamplePatternSGIS_remap_index])
+#define SET_SamplePatternSGIS(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SamplePatternSGIS_remap_index], fn)
+#define CALL_ColorPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *)), driDispatchRemapTable[ColorPointerEXT_remap_index], parameters)
+#define GET_ColorPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[ColorPointerEXT_remap_index])
+#define SET_ColorPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ColorPointerEXT_remap_index], fn)
+#define CALL_EdgeFlagPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLsizei, const GLboolean *)), driDispatchRemapTable[EdgeFlagPointerEXT_remap_index], parameters)
+#define GET_EdgeFlagPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[EdgeFlagPointerEXT_remap_index])
+#define SET_EdgeFlagPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[EdgeFlagPointerEXT_remap_index], fn)
+#define CALL_IndexPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLsizei, const GLvoid *)), driDispatchRemapTable[IndexPointerEXT_remap_index], parameters)
+#define GET_IndexPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[IndexPointerEXT_remap_index])
+#define SET_IndexPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IndexPointerEXT_remap_index], fn)
+#define CALL_NormalPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, GLsizei, const GLvoid *)), driDispatchRemapTable[NormalPointerEXT_remap_index], parameters)
+#define GET_NormalPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[NormalPointerEXT_remap_index])
+#define SET_NormalPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[NormalPointerEXT_remap_index], fn)
+#define CALL_TexCoordPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *)), driDispatchRemapTable[TexCoordPointerEXT_remap_index], parameters)
+#define GET_TexCoordPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[TexCoordPointerEXT_remap_index])
+#define SET_TexCoordPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TexCoordPointerEXT_remap_index], fn)
+#define CALL_VertexPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, GLsizei, const GLvoid *)), driDispatchRemapTable[VertexPointerEXT_remap_index], parameters)
+#define GET_VertexPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[VertexPointerEXT_remap_index])
+#define SET_VertexPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexPointerEXT_remap_index], fn)
+#define CALL_SpriteParameterfSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), driDispatchRemapTable[SpriteParameterfSGIX_remap_index], parameters)
+#define GET_SpriteParameterfSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[SpriteParameterfSGIX_remap_index])
+#define SET_SpriteParameterfSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SpriteParameterfSGIX_remap_index], fn)
+#define CALL_SpriteParameterfvSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), driDispatchRemapTable[SpriteParameterfvSGIX_remap_index], parameters)
+#define GET_SpriteParameterfvSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[SpriteParameterfvSGIX_remap_index])
+#define SET_SpriteParameterfvSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SpriteParameterfvSGIX_remap_index], fn)
+#define CALL_SpriteParameteriSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), driDispatchRemapTable[SpriteParameteriSGIX_remap_index], parameters)
+#define GET_SpriteParameteriSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[SpriteParameteriSGIX_remap_index])
+#define SET_SpriteParameteriSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SpriteParameteriSGIX_remap_index], fn)
+#define CALL_SpriteParameterivSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), driDispatchRemapTable[SpriteParameterivSGIX_remap_index], parameters)
+#define GET_SpriteParameterivSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[SpriteParameterivSGIX_remap_index])
+#define SET_SpriteParameterivSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SpriteParameterivSGIX_remap_index], fn)
+#define CALL_PointParameterfEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), driDispatchRemapTable[PointParameterfEXT_remap_index], parameters)
+#define GET_PointParameterfEXT(disp) GET_by_offset(disp, driDispatchRemapTable[PointParameterfEXT_remap_index])
+#define SET_PointParameterfEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PointParameterfEXT_remap_index], fn)
+#define CALL_PointParameterfvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), driDispatchRemapTable[PointParameterfvEXT_remap_index], parameters)
+#define GET_PointParameterfvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[PointParameterfvEXT_remap_index])
+#define SET_PointParameterfvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PointParameterfvEXT_remap_index], fn)
+#define CALL_GetInstrumentsSGIX(disp, parameters) CALL_by_offset(disp, (GLint (GLAPIENTRYP)(void)), driDispatchRemapTable[GetInstrumentsSGIX_remap_index], parameters)
+#define GET_GetInstrumentsSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[GetInstrumentsSGIX_remap_index])
+#define SET_GetInstrumentsSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetInstrumentsSGIX_remap_index], fn)
+#define CALL_InstrumentsBufferSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLint *)), driDispatchRemapTable[InstrumentsBufferSGIX_remap_index], parameters)
+#define GET_InstrumentsBufferSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[InstrumentsBufferSGIX_remap_index])
+#define SET_InstrumentsBufferSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[InstrumentsBufferSGIX_remap_index], fn)
+#define CALL_PollInstrumentsSGIX(disp, parameters) CALL_by_offset(disp, (GLint (GLAPIENTRYP)(GLint *)), driDispatchRemapTable[PollInstrumentsSGIX_remap_index], parameters)
+#define GET_PollInstrumentsSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[PollInstrumentsSGIX_remap_index])
+#define SET_PollInstrumentsSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PollInstrumentsSGIX_remap_index], fn)
+#define CALL_ReadInstrumentsSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint)), driDispatchRemapTable[ReadInstrumentsSGIX_remap_index], parameters)
+#define GET_ReadInstrumentsSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[ReadInstrumentsSGIX_remap_index])
+#define SET_ReadInstrumentsSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ReadInstrumentsSGIX_remap_index], fn)
+#define CALL_StartInstrumentsSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[StartInstrumentsSGIX_remap_index], parameters)
+#define GET_StartInstrumentsSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[StartInstrumentsSGIX_remap_index])
+#define SET_StartInstrumentsSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[StartInstrumentsSGIX_remap_index], fn)
+#define CALL_StopInstrumentsSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint)), driDispatchRemapTable[StopInstrumentsSGIX_remap_index], parameters)
+#define GET_StopInstrumentsSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[StopInstrumentsSGIX_remap_index])
+#define SET_StopInstrumentsSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[StopInstrumentsSGIX_remap_index], fn)
+#define CALL_FrameZoomSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint)), driDispatchRemapTable[FrameZoomSGIX_remap_index], parameters)
+#define GET_FrameZoomSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[FrameZoomSGIX_remap_index])
+#define SET_FrameZoomSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FrameZoomSGIX_remap_index], fn)
+#define CALL_TagSampleBufferSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[TagSampleBufferSGIX_remap_index], parameters)
+#define GET_TagSampleBufferSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[TagSampleBufferSGIX_remap_index])
+#define SET_TagSampleBufferSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TagSampleBufferSGIX_remap_index], fn)
+#define CALL_ReferencePlaneSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[ReferencePlaneSGIX_remap_index], parameters)
+#define GET_ReferencePlaneSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[ReferencePlaneSGIX_remap_index])
+#define SET_ReferencePlaneSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ReferencePlaneSGIX_remap_index], fn)
+#define CALL_FlushRasterSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[FlushRasterSGIX_remap_index], parameters)
+#define GET_FlushRasterSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[FlushRasterSGIX_remap_index])
+#define SET_FlushRasterSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FlushRasterSGIX_remap_index], fn)
+#define CALL_GetListParameterfvSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLfloat *)), driDispatchRemapTable[GetListParameterfvSGIX_remap_index], parameters)
+#define GET_GetListParameterfvSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[GetListParameterfvSGIX_remap_index])
+#define SET_GetListParameterfvSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetListParameterfvSGIX_remap_index], fn)
+#define CALL_GetListParameterivSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetListParameterivSGIX_remap_index], parameters)
+#define GET_GetListParameterivSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[GetListParameterivSGIX_remap_index])
+#define SET_GetListParameterivSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetListParameterivSGIX_remap_index], fn)
+#define CALL_ListParameterfSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLfloat)), driDispatchRemapTable[ListParameterfSGIX_remap_index], parameters)
+#define GET_ListParameterfSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[ListParameterfSGIX_remap_index])
+#define SET_ListParameterfSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ListParameterfSGIX_remap_index], fn)
+#define CALL_ListParameterfvSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, const GLfloat *)), driDispatchRemapTable[ListParameterfvSGIX_remap_index], parameters)
+#define GET_ListParameterfvSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[ListParameterfvSGIX_remap_index])
+#define SET_ListParameterfvSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ListParameterfvSGIX_remap_index], fn)
+#define CALL_ListParameteriSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint)), driDispatchRemapTable[ListParameteriSGIX_remap_index], parameters)
+#define GET_ListParameteriSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[ListParameteriSGIX_remap_index])
+#define SET_ListParameteriSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ListParameteriSGIX_remap_index], fn)
+#define CALL_ListParameterivSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, const GLint *)), driDispatchRemapTable[ListParameterivSGIX_remap_index], parameters)
+#define GET_ListParameterivSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[ListParameterivSGIX_remap_index])
+#define SET_ListParameterivSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ListParameterivSGIX_remap_index], fn)
+#define CALL_FragmentColorMaterialSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum)), driDispatchRemapTable[FragmentColorMaterialSGIX_remap_index], parameters)
+#define GET_FragmentColorMaterialSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[FragmentColorMaterialSGIX_remap_index])
+#define SET_FragmentColorMaterialSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FragmentColorMaterialSGIX_remap_index], fn)
+#define CALL_FragmentLightfSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat)), driDispatchRemapTable[FragmentLightfSGIX_remap_index], parameters)
+#define GET_FragmentLightfSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[FragmentLightfSGIX_remap_index])
+#define SET_FragmentLightfSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FragmentLightfSGIX_remap_index], fn)
+#define CALL_FragmentLightfvSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLfloat *)), driDispatchRemapTable[FragmentLightfvSGIX_remap_index], parameters)
+#define GET_FragmentLightfvSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[FragmentLightfvSGIX_remap_index])
+#define SET_FragmentLightfvSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FragmentLightfvSGIX_remap_index], fn)
+#define CALL_FragmentLightiSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint)), driDispatchRemapTable[FragmentLightiSGIX_remap_index], parameters)
+#define GET_FragmentLightiSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[FragmentLightiSGIX_remap_index])
+#define SET_FragmentLightiSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FragmentLightiSGIX_remap_index], fn)
+#define CALL_FragmentLightivSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLint *)), driDispatchRemapTable[FragmentLightivSGIX_remap_index], parameters)
+#define GET_FragmentLightivSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[FragmentLightivSGIX_remap_index])
+#define SET_FragmentLightivSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FragmentLightivSGIX_remap_index], fn)
+#define CALL_FragmentLightModelfSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), driDispatchRemapTable[FragmentLightModelfSGIX_remap_index], parameters)
+#define GET_FragmentLightModelfSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[FragmentLightModelfSGIX_remap_index])
+#define SET_FragmentLightModelfSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FragmentLightModelfSGIX_remap_index], fn)
+#define CALL_FragmentLightModelfvSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), driDispatchRemapTable[FragmentLightModelfvSGIX_remap_index], parameters)
+#define GET_FragmentLightModelfvSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[FragmentLightModelfvSGIX_remap_index])
+#define SET_FragmentLightModelfvSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FragmentLightModelfvSGIX_remap_index], fn)
+#define CALL_FragmentLightModeliSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), driDispatchRemapTable[FragmentLightModeliSGIX_remap_index], parameters)
+#define GET_FragmentLightModeliSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[FragmentLightModeliSGIX_remap_index])
+#define SET_FragmentLightModeliSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FragmentLightModeliSGIX_remap_index], fn)
+#define CALL_FragmentLightModelivSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), driDispatchRemapTable[FragmentLightModelivSGIX_remap_index], parameters)
+#define GET_FragmentLightModelivSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[FragmentLightModelivSGIX_remap_index])
+#define SET_FragmentLightModelivSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FragmentLightModelivSGIX_remap_index], fn)
+#define CALL_FragmentMaterialfSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat)), driDispatchRemapTable[FragmentMaterialfSGIX_remap_index], parameters)
+#define GET_FragmentMaterialfSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[FragmentMaterialfSGIX_remap_index])
+#define SET_FragmentMaterialfSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FragmentMaterialfSGIX_remap_index], fn)
+#define CALL_FragmentMaterialfvSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLfloat *)), driDispatchRemapTable[FragmentMaterialfvSGIX_remap_index], parameters)
+#define GET_FragmentMaterialfvSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[FragmentMaterialfvSGIX_remap_index])
+#define SET_FragmentMaterialfvSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FragmentMaterialfvSGIX_remap_index], fn)
+#define CALL_FragmentMaterialiSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint)), driDispatchRemapTable[FragmentMaterialiSGIX_remap_index], parameters)
+#define GET_FragmentMaterialiSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[FragmentMaterialiSGIX_remap_index])
+#define SET_FragmentMaterialiSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FragmentMaterialiSGIX_remap_index], fn)
+#define CALL_FragmentMaterialivSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, const GLint *)), driDispatchRemapTable[FragmentMaterialivSGIX_remap_index], parameters)
+#define GET_FragmentMaterialivSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[FragmentMaterialivSGIX_remap_index])
+#define SET_FragmentMaterialivSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FragmentMaterialivSGIX_remap_index], fn)
+#define CALL_GetFragmentLightfvSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), driDispatchRemapTable[GetFragmentLightfvSGIX_remap_index], parameters)
+#define GET_GetFragmentLightfvSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[GetFragmentLightfvSGIX_remap_index])
+#define SET_GetFragmentLightfvSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetFragmentLightfvSGIX_remap_index], fn)
+#define CALL_GetFragmentLightivSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetFragmentLightivSGIX_remap_index], parameters)
+#define GET_GetFragmentLightivSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[GetFragmentLightivSGIX_remap_index])
+#define SET_GetFragmentLightivSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetFragmentLightivSGIX_remap_index], fn)
+#define CALL_GetFragmentMaterialfvSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), driDispatchRemapTable[GetFragmentMaterialfvSGIX_remap_index], parameters)
+#define GET_GetFragmentMaterialfvSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[GetFragmentMaterialfvSGIX_remap_index])
+#define SET_GetFragmentMaterialfvSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetFragmentMaterialfvSGIX_remap_index], fn)
+#define CALL_GetFragmentMaterialivSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetFragmentMaterialivSGIX_remap_index], parameters)
+#define GET_GetFragmentMaterialivSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[GetFragmentMaterialivSGIX_remap_index])
+#define SET_GetFragmentMaterialivSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetFragmentMaterialivSGIX_remap_index], fn)
+#define CALL_LightEnviSGIX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), driDispatchRemapTable[LightEnviSGIX_remap_index], parameters)
+#define GET_LightEnviSGIX(disp) GET_by_offset(disp, driDispatchRemapTable[LightEnviSGIX_remap_index])
+#define SET_LightEnviSGIX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[LightEnviSGIX_remap_index], fn)
+#define CALL_VertexWeightfEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat)), driDispatchRemapTable[VertexWeightfEXT_remap_index], parameters)
+#define GET_VertexWeightfEXT(disp) GET_by_offset(disp, driDispatchRemapTable[VertexWeightfEXT_remap_index])
+#define SET_VertexWeightfEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexWeightfEXT_remap_index], fn)
+#define CALL_VertexWeightfvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[VertexWeightfvEXT_remap_index], parameters)
+#define GET_VertexWeightfvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[VertexWeightfvEXT_remap_index])
+#define SET_VertexWeightfvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexWeightfvEXT_remap_index], fn)
+#define CALL_VertexWeightPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[VertexWeightPointerEXT_remap_index], parameters)
+#define GET_VertexWeightPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[VertexWeightPointerEXT_remap_index])
+#define SET_VertexWeightPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexWeightPointerEXT_remap_index], fn)
+#define CALL_FlushVertexArrayRangeNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[FlushVertexArrayRangeNV_remap_index], parameters)
+#define GET_FlushVertexArrayRangeNV(disp) GET_by_offset(disp, driDispatchRemapTable[FlushVertexArrayRangeNV_remap_index])
+#define SET_FlushVertexArrayRangeNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FlushVertexArrayRangeNV_remap_index], fn)
+#define CALL_VertexArrayRangeNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLvoid *)), driDispatchRemapTable[VertexArrayRangeNV_remap_index], parameters)
+#define GET_VertexArrayRangeNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexArrayRangeNV_remap_index])
+#define SET_VertexArrayRangeNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexArrayRangeNV_remap_index], fn)
+#define CALL_CombinerParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLfloat *)), driDispatchRemapTable[CombinerParameterfvNV_remap_index], parameters)
+#define GET_CombinerParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerParameterfvNV_remap_index])
+#define SET_CombinerParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerParameterfvNV_remap_index], fn)
+#define CALL_CombinerParameterfNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat)), driDispatchRemapTable[CombinerParameterfNV_remap_index], parameters)
+#define GET_CombinerParameterfNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerParameterfNV_remap_index])
+#define SET_CombinerParameterfNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerParameterfNV_remap_index], fn)
+#define CALL_CombinerParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), driDispatchRemapTable[CombinerParameterivNV_remap_index], parameters)
+#define GET_CombinerParameterivNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerParameterivNV_remap_index])
+#define SET_CombinerParameterivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerParameterivNV_remap_index], fn)
+#define CALL_CombinerParameteriNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), driDispatchRemapTable[CombinerParameteriNV_remap_index], parameters)
+#define GET_CombinerParameteriNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerParameteriNV_remap_index])
+#define SET_CombinerParameteriNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerParameteriNV_remap_index], fn)
+#define CALL_CombinerInputNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum, GLenum, GLenum)), driDispatchRemapTable[CombinerInputNV_remap_index], parameters)
+#define GET_CombinerInputNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerInputNV_remap_index])
+#define SET_CombinerInputNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerInputNV_remap_index], fn)
+#define CALL_CombinerOutputNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean)), driDispatchRemapTable[CombinerOutputNV_remap_index], parameters)
+#define GET_CombinerOutputNV(disp) GET_by_offset(disp, driDispatchRemapTable[CombinerOutputNV_remap_index])
+#define SET_CombinerOutputNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CombinerOutputNV_remap_index], fn)
+#define CALL_FinalCombinerInputNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum)), driDispatchRemapTable[FinalCombinerInputNV_remap_index], parameters)
+#define GET_FinalCombinerInputNV(disp) GET_by_offset(disp, driDispatchRemapTable[FinalCombinerInputNV_remap_index])
+#define SET_FinalCombinerInputNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FinalCombinerInputNV_remap_index], fn)
+#define CALL_GetCombinerInputParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum, GLfloat *)), driDispatchRemapTable[GetCombinerInputParameterfvNV_remap_index], parameters)
+#define GET_GetCombinerInputParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetCombinerInputParameterfvNV_remap_index])
+#define SET_GetCombinerInputParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetCombinerInputParameterfvNV_remap_index], fn)
+#define CALL_GetCombinerInputParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum, GLint *)), driDispatchRemapTable[GetCombinerInputParameterivNV_remap_index], parameters)
+#define GET_GetCombinerInputParameterivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetCombinerInputParameterivNV_remap_index])
+#define SET_GetCombinerInputParameterivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetCombinerInputParameterivNV_remap_index], fn)
+#define CALL_GetCombinerOutputParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLfloat *)), driDispatchRemapTable[GetCombinerOutputParameterfvNV_remap_index], parameters)
+#define GET_GetCombinerOutputParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetCombinerOutputParameterfvNV_remap_index])
+#define SET_GetCombinerOutputParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetCombinerOutputParameterfvNV_remap_index], fn)
+#define CALL_GetCombinerOutputParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLint *)), driDispatchRemapTable[GetCombinerOutputParameterivNV_remap_index], parameters)
+#define GET_GetCombinerOutputParameterivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetCombinerOutputParameterivNV_remap_index])
+#define SET_GetCombinerOutputParameterivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetCombinerOutputParameterivNV_remap_index], fn)
+#define CALL_GetFinalCombinerInputParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), driDispatchRemapTable[GetFinalCombinerInputParameterfvNV_remap_index], parameters)
+#define GET_GetFinalCombinerInputParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetFinalCombinerInputParameterfvNV_remap_index])
+#define SET_GetFinalCombinerInputParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetFinalCombinerInputParameterfvNV_remap_index], fn)
+#define CALL_GetFinalCombinerInputParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetFinalCombinerInputParameterivNV_remap_index], parameters)
+#define GET_GetFinalCombinerInputParameterivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetFinalCombinerInputParameterivNV_remap_index])
+#define SET_GetFinalCombinerInputParameterivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetFinalCombinerInputParameterivNV_remap_index], fn)
+#define CALL_ResizeBuffersMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[ResizeBuffersMESA_remap_index], parameters)
+#define GET_ResizeBuffersMESA(disp) GET_by_offset(disp, driDispatchRemapTable[ResizeBuffersMESA_remap_index])
+#define SET_ResizeBuffersMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ResizeBuffersMESA_remap_index], fn)
+#define CALL_WindowPos2dMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble)), driDispatchRemapTable[WindowPos2dMESA_remap_index], parameters)
+#define GET_WindowPos2dMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2dMESA_remap_index])
+#define SET_WindowPos2dMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2dMESA_remap_index], fn)
+#define CALL_WindowPos2dvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[WindowPos2dvMESA_remap_index], parameters)
+#define GET_WindowPos2dvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2dvMESA_remap_index])
+#define SET_WindowPos2dvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2dvMESA_remap_index], fn)
+#define CALL_WindowPos2fMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat)), driDispatchRemapTable[WindowPos2fMESA_remap_index], parameters)
+#define GET_WindowPos2fMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2fMESA_remap_index])
+#define SET_WindowPos2fMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2fMESA_remap_index], fn)
+#define CALL_WindowPos2fvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[WindowPos2fvMESA_remap_index], parameters)
+#define GET_WindowPos2fvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2fvMESA_remap_index])
+#define SET_WindowPos2fvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2fvMESA_remap_index], fn)
+#define CALL_WindowPos2iMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint)), driDispatchRemapTable[WindowPos2iMESA_remap_index], parameters)
+#define GET_WindowPos2iMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2iMESA_remap_index])
+#define SET_WindowPos2iMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2iMESA_remap_index], fn)
+#define CALL_WindowPos2ivMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), driDispatchRemapTable[WindowPos2ivMESA_remap_index], parameters)
+#define GET_WindowPos2ivMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2ivMESA_remap_index])
+#define SET_WindowPos2ivMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2ivMESA_remap_index], fn)
+#define CALL_WindowPos2sMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort)), driDispatchRemapTable[WindowPos2sMESA_remap_index], parameters)
+#define GET_WindowPos2sMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2sMESA_remap_index])
+#define SET_WindowPos2sMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2sMESA_remap_index], fn)
+#define CALL_WindowPos2svMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), driDispatchRemapTable[WindowPos2svMESA_remap_index], parameters)
+#define GET_WindowPos2svMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos2svMESA_remap_index])
+#define SET_WindowPos2svMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos2svMESA_remap_index], fn)
+#define CALL_WindowPos3dMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[WindowPos3dMESA_remap_index], parameters)
+#define GET_WindowPos3dMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3dMESA_remap_index])
+#define SET_WindowPos3dMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3dMESA_remap_index], fn)
+#define CALL_WindowPos3dvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[WindowPos3dvMESA_remap_index], parameters)
+#define GET_WindowPos3dvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3dvMESA_remap_index])
+#define SET_WindowPos3dvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3dvMESA_remap_index], fn)
+#define CALL_WindowPos3fMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[WindowPos3fMESA_remap_index], parameters)
+#define GET_WindowPos3fMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3fMESA_remap_index])
+#define SET_WindowPos3fMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3fMESA_remap_index], fn)
+#define CALL_WindowPos3fvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[WindowPos3fvMESA_remap_index], parameters)
+#define GET_WindowPos3fvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3fvMESA_remap_index])
+#define SET_WindowPos3fvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3fvMESA_remap_index], fn)
+#define CALL_WindowPos3iMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint)), driDispatchRemapTable[WindowPos3iMESA_remap_index], parameters)
+#define GET_WindowPos3iMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3iMESA_remap_index])
+#define SET_WindowPos3iMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3iMESA_remap_index], fn)
+#define CALL_WindowPos3ivMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), driDispatchRemapTable[WindowPos3ivMESA_remap_index], parameters)
+#define GET_WindowPos3ivMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3ivMESA_remap_index])
+#define SET_WindowPos3ivMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3ivMESA_remap_index], fn)
+#define CALL_WindowPos3sMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort)), driDispatchRemapTable[WindowPos3sMESA_remap_index], parameters)
+#define GET_WindowPos3sMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3sMESA_remap_index])
+#define SET_WindowPos3sMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3sMESA_remap_index], fn)
+#define CALL_WindowPos3svMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), driDispatchRemapTable[WindowPos3svMESA_remap_index], parameters)
+#define GET_WindowPos3svMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos3svMESA_remap_index])
+#define SET_WindowPos3svMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos3svMESA_remap_index], fn)
+#define CALL_WindowPos4dMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[WindowPos4dMESA_remap_index], parameters)
+#define GET_WindowPos4dMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4dMESA_remap_index])
+#define SET_WindowPos4dMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4dMESA_remap_index], fn)
+#define CALL_WindowPos4dvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[WindowPos4dvMESA_remap_index], parameters)
+#define GET_WindowPos4dvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4dvMESA_remap_index])
+#define SET_WindowPos4dvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4dvMESA_remap_index], fn)
+#define CALL_WindowPos4fMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[WindowPos4fMESA_remap_index], parameters)
+#define GET_WindowPos4fMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4fMESA_remap_index])
+#define SET_WindowPos4fMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4fMESA_remap_index], fn)
+#define CALL_WindowPos4fvMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[WindowPos4fvMESA_remap_index], parameters)
+#define GET_WindowPos4fvMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4fvMESA_remap_index])
+#define SET_WindowPos4fvMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4fvMESA_remap_index], fn)
+#define CALL_WindowPos4iMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint)), driDispatchRemapTable[WindowPos4iMESA_remap_index], parameters)
+#define GET_WindowPos4iMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4iMESA_remap_index])
+#define SET_WindowPos4iMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4iMESA_remap_index], fn)
+#define CALL_WindowPos4ivMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), driDispatchRemapTable[WindowPos4ivMESA_remap_index], parameters)
+#define GET_WindowPos4ivMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4ivMESA_remap_index])
+#define SET_WindowPos4ivMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4ivMESA_remap_index], fn)
+#define CALL_WindowPos4sMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort, GLshort)), driDispatchRemapTable[WindowPos4sMESA_remap_index], parameters)
+#define GET_WindowPos4sMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4sMESA_remap_index])
+#define SET_WindowPos4sMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4sMESA_remap_index], fn)
+#define CALL_WindowPos4svMESA(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), driDispatchRemapTable[WindowPos4svMESA_remap_index], parameters)
+#define GET_WindowPos4svMESA(disp) GET_by_offset(disp, driDispatchRemapTable[WindowPos4svMESA_remap_index])
+#define SET_WindowPos4svMESA(disp, fn) SET_by_offset(disp, driDispatchRemapTable[WindowPos4svMESA_remap_index], fn)
+#define CALL_BlendFuncSeparateEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum)), driDispatchRemapTable[BlendFuncSeparateEXT_remap_index], parameters)
+#define GET_BlendFuncSeparateEXT(disp) GET_by_offset(disp, driDispatchRemapTable[BlendFuncSeparateEXT_remap_index])
+#define SET_BlendFuncSeparateEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BlendFuncSeparateEXT_remap_index], fn)
+#define CALL_IndexMaterialEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum)), driDispatchRemapTable[IndexMaterialEXT_remap_index], parameters)
+#define GET_IndexMaterialEXT(disp) GET_by_offset(disp, driDispatchRemapTable[IndexMaterialEXT_remap_index])
+#define SET_IndexMaterialEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IndexMaterialEXT_remap_index], fn)
+#define CALL_IndexFuncEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLclampf)), driDispatchRemapTable[IndexFuncEXT_remap_index], parameters)
+#define GET_IndexFuncEXT(disp) GET_by_offset(disp, driDispatchRemapTable[IndexFuncEXT_remap_index])
+#define SET_IndexFuncEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IndexFuncEXT_remap_index], fn)
+#define CALL_LockArraysEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei)), driDispatchRemapTable[LockArraysEXT_remap_index], parameters)
+#define GET_LockArraysEXT(disp) GET_by_offset(disp, driDispatchRemapTable[LockArraysEXT_remap_index])
+#define SET_LockArraysEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[LockArraysEXT_remap_index], fn)
+#define CALL_UnlockArraysEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[UnlockArraysEXT_remap_index], parameters)
+#define GET_UnlockArraysEXT(disp) GET_by_offset(disp, driDispatchRemapTable[UnlockArraysEXT_remap_index])
+#define SET_UnlockArraysEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UnlockArraysEXT_remap_index], fn)
+#define CALL_CullParameterdvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLdouble *)), driDispatchRemapTable[CullParameterdvEXT_remap_index], parameters)
+#define GET_CullParameterdvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[CullParameterdvEXT_remap_index])
+#define SET_CullParameterdvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CullParameterdvEXT_remap_index], fn)
+#define CALL_CullParameterfvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLfloat *)), driDispatchRemapTable[CullParameterfvEXT_remap_index], parameters)
+#define GET_CullParameterfvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[CullParameterfvEXT_remap_index])
+#define SET_CullParameterfvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CullParameterfvEXT_remap_index], fn)
+#define CALL_HintPGI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), driDispatchRemapTable[HintPGI_remap_index], parameters)
+#define GET_HintPGI(disp) GET_by_offset(disp, driDispatchRemapTable[HintPGI_remap_index])
+#define SET_HintPGI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[HintPGI_remap_index], fn)
+#define CALL_FogCoordfEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat)), driDispatchRemapTable[FogCoordfEXT_remap_index], parameters)
+#define GET_FogCoordfEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FogCoordfEXT_remap_index])
+#define SET_FogCoordfEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FogCoordfEXT_remap_index], fn)
+#define CALL_FogCoordfvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[FogCoordfvEXT_remap_index], parameters)
+#define GET_FogCoordfvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FogCoordfvEXT_remap_index])
+#define SET_FogCoordfvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FogCoordfvEXT_remap_index], fn)
+#define CALL_FogCoorddEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble)), driDispatchRemapTable[FogCoorddEXT_remap_index], parameters)
+#define GET_FogCoorddEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FogCoorddEXT_remap_index])
+#define SET_FogCoorddEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FogCoorddEXT_remap_index], fn)
+#define CALL_FogCoorddvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[FogCoorddvEXT_remap_index], parameters)
+#define GET_FogCoorddvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FogCoorddvEXT_remap_index])
+#define SET_FogCoorddvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FogCoorddvEXT_remap_index], fn)
+#define CALL_FogCoordPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[FogCoordPointerEXT_remap_index], parameters)
+#define GET_FogCoordPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FogCoordPointerEXT_remap_index])
+#define SET_FogCoordPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FogCoordPointerEXT_remap_index], fn)
+#define CALL_GetColorTableEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLvoid *)), driDispatchRemapTable[GetColorTableEXT_remap_index], parameters)
+#define GET_GetColorTableEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetColorTableEXT_remap_index])
+#define SET_GetColorTableEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetColorTableEXT_remap_index], fn)
+#define CALL_GetColorTableParameterivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetColorTableParameterivEXT_remap_index], parameters)
+#define GET_GetColorTableParameterivEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetColorTableParameterivEXT_remap_index])
+#define SET_GetColorTableParameterivEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetColorTableParameterivEXT_remap_index], fn)
+#define CALL_GetColorTableParameterfvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLfloat *)), driDispatchRemapTable[GetColorTableParameterfvEXT_remap_index], parameters)
+#define GET_GetColorTableParameterfvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetColorTableParameterfvEXT_remap_index])
+#define SET_GetColorTableParameterfvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetColorTableParameterfvEXT_remap_index], fn)
+#define CALL_TbufferMask3DFX(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[TbufferMask3DFX_remap_index], parameters)
+#define GET_TbufferMask3DFX(disp) GET_by_offset(disp, driDispatchRemapTable[TbufferMask3DFX_remap_index])
+#define SET_TbufferMask3DFX(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TbufferMask3DFX_remap_index], fn)
+#define CALL_CompressedTexImage3DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexImage3DARB_remap_index], parameters)
+#define GET_CompressedTexImage3DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexImage3DARB_remap_index])
+#define SET_CompressedTexImage3DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexImage3DARB_remap_index], fn)
+#define CALL_CompressedTexImage2DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexImage2DARB_remap_index], parameters)
+#define GET_CompressedTexImage2DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexImage2DARB_remap_index])
+#define SET_CompressedTexImage2DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexImage2DARB_remap_index], fn)
+#define CALL_CompressedTexImage1DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexImage1DARB_remap_index], parameters)
+#define GET_CompressedTexImage1DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexImage1DARB_remap_index])
+#define SET_CompressedTexImage1DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexImage1DARB_remap_index], fn)
+#define CALL_CompressedTexSubImage3DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexSubImage3DARB_remap_index], parameters)
+#define GET_CompressedTexSubImage3DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage3DARB_remap_index])
+#define SET_CompressedTexSubImage3DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage3DARB_remap_index], fn)
+#define CALL_CompressedTexSubImage2DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexSubImage2DARB_remap_index], parameters)
+#define GET_CompressedTexSubImage2DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage2DARB_remap_index])
+#define SET_CompressedTexSubImage2DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage2DARB_remap_index], fn)
+#define CALL_CompressedTexSubImage1DARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[CompressedTexSubImage1DARB_remap_index], parameters)
+#define GET_CompressedTexSubImage1DARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage1DARB_remap_index])
+#define SET_CompressedTexSubImage1DARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompressedTexSubImage1DARB_remap_index], fn)
+#define CALL_GetCompressedTexImageARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint, GLvoid *)), driDispatchRemapTable[GetCompressedTexImageARB_remap_index], parameters)
+#define GET_GetCompressedTexImageARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetCompressedTexImageARB_remap_index])
+#define SET_GetCompressedTexImageARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetCompressedTexImageARB_remap_index], fn)
+#define CALL_SecondaryColor3bEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLbyte, GLbyte, GLbyte)), driDispatchRemapTable[SecondaryColor3bEXT_remap_index], parameters)
+#define GET_SecondaryColor3bEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3bEXT_remap_index])
+#define SET_SecondaryColor3bEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3bEXT_remap_index], fn)
+#define CALL_SecondaryColor3bvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLbyte *)), driDispatchRemapTable[SecondaryColor3bvEXT_remap_index], parameters)
+#define GET_SecondaryColor3bvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3bvEXT_remap_index])
+#define SET_SecondaryColor3bvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3bvEXT_remap_index], fn)
+#define CALL_SecondaryColor3dEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[SecondaryColor3dEXT_remap_index], parameters)
+#define GET_SecondaryColor3dEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3dEXT_remap_index])
+#define SET_SecondaryColor3dEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3dEXT_remap_index], fn)
+#define CALL_SecondaryColor3dvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLdouble *)), driDispatchRemapTable[SecondaryColor3dvEXT_remap_index], parameters)
+#define GET_SecondaryColor3dvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3dvEXT_remap_index])
+#define SET_SecondaryColor3dvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3dvEXT_remap_index], fn)
+#define CALL_SecondaryColor3fEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[SecondaryColor3fEXT_remap_index], parameters)
+#define GET_SecondaryColor3fEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3fEXT_remap_index])
+#define SET_SecondaryColor3fEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3fEXT_remap_index], fn)
+#define CALL_SecondaryColor3fvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLfloat *)), driDispatchRemapTable[SecondaryColor3fvEXT_remap_index], parameters)
+#define GET_SecondaryColor3fvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3fvEXT_remap_index])
+#define SET_SecondaryColor3fvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3fvEXT_remap_index], fn)
+#define CALL_SecondaryColor3iEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint)), driDispatchRemapTable[SecondaryColor3iEXT_remap_index], parameters)
+#define GET_SecondaryColor3iEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3iEXT_remap_index])
+#define SET_SecondaryColor3iEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3iEXT_remap_index], fn)
+#define CALL_SecondaryColor3ivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLint *)), driDispatchRemapTable[SecondaryColor3ivEXT_remap_index], parameters)
+#define GET_SecondaryColor3ivEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ivEXT_remap_index])
+#define SET_SecondaryColor3ivEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ivEXT_remap_index], fn)
+#define CALL_SecondaryColor3sEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLshort, GLshort, GLshort)), driDispatchRemapTable[SecondaryColor3sEXT_remap_index], parameters)
+#define GET_SecondaryColor3sEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3sEXT_remap_index])
+#define SET_SecondaryColor3sEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3sEXT_remap_index], fn)
+#define CALL_SecondaryColor3svEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLshort *)), driDispatchRemapTable[SecondaryColor3svEXT_remap_index], parameters)
+#define GET_SecondaryColor3svEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3svEXT_remap_index])
+#define SET_SecondaryColor3svEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3svEXT_remap_index], fn)
+#define CALL_SecondaryColor3ubEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLubyte, GLubyte, GLubyte)), driDispatchRemapTable[SecondaryColor3ubEXT_remap_index], parameters)
+#define GET_SecondaryColor3ubEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ubEXT_remap_index])
+#define SET_SecondaryColor3ubEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ubEXT_remap_index], fn)
+#define CALL_SecondaryColor3ubvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLubyte *)), driDispatchRemapTable[SecondaryColor3ubvEXT_remap_index], parameters)
+#define GET_SecondaryColor3ubvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ubvEXT_remap_index])
+#define SET_SecondaryColor3ubvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3ubvEXT_remap_index], fn)
+#define CALL_SecondaryColor3uiEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLuint)), driDispatchRemapTable[SecondaryColor3uiEXT_remap_index], parameters)
+#define GET_SecondaryColor3uiEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3uiEXT_remap_index])
+#define SET_SecondaryColor3uiEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3uiEXT_remap_index], fn)
+#define CALL_SecondaryColor3uivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLuint *)), driDispatchRemapTable[SecondaryColor3uivEXT_remap_index], parameters)
+#define GET_SecondaryColor3uivEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3uivEXT_remap_index])
+#define SET_SecondaryColor3uivEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3uivEXT_remap_index], fn)
+#define CALL_SecondaryColor3usEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLushort, GLushort, GLushort)), driDispatchRemapTable[SecondaryColor3usEXT_remap_index], parameters)
+#define GET_SecondaryColor3usEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3usEXT_remap_index])
+#define SET_SecondaryColor3usEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3usEXT_remap_index], fn)
+#define CALL_SecondaryColor3usvEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLushort *)), driDispatchRemapTable[SecondaryColor3usvEXT_remap_index], parameters)
+#define GET_SecondaryColor3usvEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColor3usvEXT_remap_index])
+#define SET_SecondaryColor3usvEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColor3usvEXT_remap_index], fn)
+#define CALL_SecondaryColorPointerEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[SecondaryColorPointerEXT_remap_index], parameters)
+#define GET_SecondaryColorPointerEXT(disp) GET_by_offset(disp, driDispatchRemapTable[SecondaryColorPointerEXT_remap_index])
+#define SET_SecondaryColorPointerEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SecondaryColorPointerEXT_remap_index], fn)
+#define CALL_AreProgramsResidentNV(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLsizei, const GLuint *, GLboolean *)), driDispatchRemapTable[AreProgramsResidentNV_remap_index], parameters)
+#define GET_AreProgramsResidentNV(disp) GET_by_offset(disp, driDispatchRemapTable[AreProgramsResidentNV_remap_index])
+#define SET_AreProgramsResidentNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AreProgramsResidentNV_remap_index], fn)
+#define CALL_BindProgramNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[BindProgramNV_remap_index], parameters)
+#define GET_BindProgramNV(disp) GET_by_offset(disp, driDispatchRemapTable[BindProgramNV_remap_index])
+#define SET_BindProgramNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindProgramNV_remap_index], fn)
+#define CALL_DeleteProgramsNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteProgramsNV_remap_index], parameters)
+#define GET_DeleteProgramsNV(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteProgramsNV_remap_index])
+#define SET_DeleteProgramsNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteProgramsNV_remap_index], fn)
+#define CALL_ExecuteProgramNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLfloat *)), driDispatchRemapTable[ExecuteProgramNV_remap_index], parameters)
+#define GET_ExecuteProgramNV(disp) GET_by_offset(disp, driDispatchRemapTable[ExecuteProgramNV_remap_index])
+#define SET_ExecuteProgramNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ExecuteProgramNV_remap_index], fn)
+#define CALL_GenProgramsNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenProgramsNV_remap_index], parameters)
+#define GET_GenProgramsNV(disp) GET_by_offset(disp, driDispatchRemapTable[GenProgramsNV_remap_index])
+#define SET_GenProgramsNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenProgramsNV_remap_index], fn)
+#define CALL_GetProgramParameterdvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLenum, GLdouble *)), driDispatchRemapTable[GetProgramParameterdvNV_remap_index], parameters)
+#define GET_GetProgramParameterdvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramParameterdvNV_remap_index])
+#define SET_GetProgramParameterdvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramParameterdvNV_remap_index], fn)
+#define CALL_GetProgramParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLenum, GLfloat *)), driDispatchRemapTable[GetProgramParameterfvNV_remap_index], parameters)
+#define GET_GetProgramParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramParameterfvNV_remap_index])
+#define SET_GetProgramParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramParameterfvNV_remap_index], fn)
+#define CALL_GetProgramivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetProgramivNV_remap_index], parameters)
+#define GET_GetProgramivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramivNV_remap_index])
+#define SET_GetProgramivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramivNV_remap_index], fn)
+#define CALL_GetProgramStringNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLubyte *)), driDispatchRemapTable[GetProgramStringNV_remap_index], parameters)
+#define GET_GetProgramStringNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramStringNV_remap_index])
+#define SET_GetProgramStringNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramStringNV_remap_index], fn)
+#define CALL_GetTrackMatrixivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLenum, GLint *)), driDispatchRemapTable[GetTrackMatrixivNV_remap_index], parameters)
+#define GET_GetTrackMatrixivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetTrackMatrixivNV_remap_index])
+#define SET_GetTrackMatrixivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetTrackMatrixivNV_remap_index], fn)
+#define CALL_GetVertexAttribdvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLdouble *)), driDispatchRemapTable[GetVertexAttribdvARB_remap_index], parameters)
+#define GET_GetVertexAttribdvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribdvARB_remap_index])
+#define SET_GetVertexAttribdvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribdvARB_remap_index], fn)
+#define CALL_GetVertexAttribfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLfloat *)), driDispatchRemapTable[GetVertexAttribfvARB_remap_index], parameters)
+#define GET_GetVertexAttribfvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribfvARB_remap_index])
+#define SET_GetVertexAttribfvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribfvARB_remap_index], fn)
+#define CALL_GetVertexAttribivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetVertexAttribivARB_remap_index], parameters)
+#define GET_GetVertexAttribivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribivARB_remap_index])
+#define SET_GetVertexAttribivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribivARB_remap_index], fn)
+#define CALL_GetVertexAttribPointervNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLvoid **)), driDispatchRemapTable[GetVertexAttribPointervNV_remap_index], parameters)
+#define GET_GetVertexAttribPointervNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribPointervNV_remap_index])
+#define SET_GetVertexAttribPointervNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribPointervNV_remap_index], fn)
+#define CALL_IsProgramNV(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsProgramNV_remap_index], parameters)
+#define GET_IsProgramNV(disp) GET_by_offset(disp, driDispatchRemapTable[IsProgramNV_remap_index])
+#define SET_IsProgramNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsProgramNV_remap_index], fn)
+#define CALL_LoadProgramNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLsizei, const GLubyte *)), driDispatchRemapTable[LoadProgramNV_remap_index], parameters)
+#define GET_LoadProgramNV(disp) GET_by_offset(disp, driDispatchRemapTable[LoadProgramNV_remap_index])
+#define SET_LoadProgramNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[LoadProgramNV_remap_index], fn)
+#define CALL_ProgramParameter4dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[ProgramParameter4dNV_remap_index], parameters)
+#define GET_ProgramParameter4dNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramParameter4dNV_remap_index])
+#define SET_ProgramParameter4dNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramParameter4dNV_remap_index], fn)
+#define CALL_ProgramParameter4dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLdouble *)), driDispatchRemapTable[ProgramParameter4dvNV_remap_index], parameters)
+#define GET_ProgramParameter4dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramParameter4dvNV_remap_index])
+#define SET_ProgramParameter4dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramParameter4dvNV_remap_index], fn)
+#define CALL_ProgramParameter4fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[ProgramParameter4fNV_remap_index], parameters)
+#define GET_ProgramParameter4fNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramParameter4fNV_remap_index])
+#define SET_ProgramParameter4fNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramParameter4fNV_remap_index], fn)
+#define CALL_ProgramParameter4fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLfloat *)), driDispatchRemapTable[ProgramParameter4fvNV_remap_index], parameters)
+#define GET_ProgramParameter4fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramParameter4fvNV_remap_index])
+#define SET_ProgramParameter4fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramParameter4fvNV_remap_index], fn)
+#define CALL_ProgramParameters4dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, const GLdouble *)), driDispatchRemapTable[ProgramParameters4dvNV_remap_index], parameters)
+#define GET_ProgramParameters4dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramParameters4dvNV_remap_index])
+#define SET_ProgramParameters4dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramParameters4dvNV_remap_index], fn)
+#define CALL_ProgramParameters4fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, const GLfloat *)), driDispatchRemapTable[ProgramParameters4fvNV_remap_index], parameters)
+#define GET_ProgramParameters4fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramParameters4fvNV_remap_index])
+#define SET_ProgramParameters4fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramParameters4fvNV_remap_index], fn)
+#define CALL_RequestResidentProgramsNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[RequestResidentProgramsNV_remap_index], parameters)
+#define GET_RequestResidentProgramsNV(disp) GET_by_offset(disp, driDispatchRemapTable[RequestResidentProgramsNV_remap_index])
+#define SET_RequestResidentProgramsNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[RequestResidentProgramsNV_remap_index], fn)
+#define CALL_TrackMatrixNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLenum, GLenum)), driDispatchRemapTable[TrackMatrixNV_remap_index], parameters)
+#define GET_TrackMatrixNV(disp) GET_by_offset(disp, driDispatchRemapTable[TrackMatrixNV_remap_index])
+#define SET_TrackMatrixNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TrackMatrixNV_remap_index], fn)
+#define CALL_VertexAttribPointerNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLint, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[VertexAttribPointerNV_remap_index], parameters)
+#define GET_VertexAttribPointerNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribPointerNV_remap_index])
+#define SET_VertexAttribPointerNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribPointerNV_remap_index], fn)
+#define CALL_VertexAttrib1dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble)), driDispatchRemapTable[VertexAttrib1dARB_remap_index], parameters)
+#define GET_VertexAttrib1dARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dARB_remap_index])
+#define SET_VertexAttrib1dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dARB_remap_index], fn)
+#define CALL_VertexAttrib1dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib1dvARB_remap_index], parameters)
+#define GET_VertexAttrib1dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dvARB_remap_index])
+#define SET_VertexAttrib1dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dvARB_remap_index], fn)
+#define CALL_VertexAttrib1fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat)), driDispatchRemapTable[VertexAttrib1fARB_remap_index], parameters)
+#define GET_VertexAttrib1fARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fARB_remap_index])
+#define SET_VertexAttrib1fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fARB_remap_index], fn)
+#define CALL_VertexAttrib1fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib1fvARB_remap_index], parameters)
+#define GET_VertexAttrib1fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fvARB_remap_index])
+#define SET_VertexAttrib1fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fvARB_remap_index], fn)
+#define CALL_VertexAttrib1sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort)), driDispatchRemapTable[VertexAttrib1sARB_remap_index], parameters)
+#define GET_VertexAttrib1sARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1sARB_remap_index])
+#define SET_VertexAttrib1sARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1sARB_remap_index], fn)
+#define CALL_VertexAttrib1svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib1svARB_remap_index], parameters)
+#define GET_VertexAttrib1svARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1svARB_remap_index])
+#define SET_VertexAttrib1svARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1svARB_remap_index], fn)
+#define CALL_VertexAttrib2dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib2dARB_remap_index], parameters)
+#define GET_VertexAttrib2dARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dARB_remap_index])
+#define SET_VertexAttrib2dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dARB_remap_index], fn)
+#define CALL_VertexAttrib2dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib2dvARB_remap_index], parameters)
+#define GET_VertexAttrib2dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dvARB_remap_index])
+#define SET_VertexAttrib2dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dvARB_remap_index], fn)
+#define CALL_VertexAttrib2fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib2fARB_remap_index], parameters)
+#define GET_VertexAttrib2fARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fARB_remap_index])
+#define SET_VertexAttrib2fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fARB_remap_index], fn)
+#define CALL_VertexAttrib2fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib2fvARB_remap_index], parameters)
+#define GET_VertexAttrib2fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fvARB_remap_index])
+#define SET_VertexAttrib2fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fvARB_remap_index], fn)
+#define CALL_VertexAttrib2sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib2sARB_remap_index], parameters)
+#define GET_VertexAttrib2sARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2sARB_remap_index])
+#define SET_VertexAttrib2sARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2sARB_remap_index], fn)
+#define CALL_VertexAttrib2svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib2svARB_remap_index], parameters)
+#define GET_VertexAttrib2svARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2svARB_remap_index])
+#define SET_VertexAttrib2svARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2svARB_remap_index], fn)
+#define CALL_VertexAttrib3dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib3dARB_remap_index], parameters)
+#define GET_VertexAttrib3dARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dARB_remap_index])
+#define SET_VertexAttrib3dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dARB_remap_index], fn)
+#define CALL_VertexAttrib3dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib3dvARB_remap_index], parameters)
+#define GET_VertexAttrib3dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dvARB_remap_index])
+#define SET_VertexAttrib3dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dvARB_remap_index], fn)
+#define CALL_VertexAttrib3fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib3fARB_remap_index], parameters)
+#define GET_VertexAttrib3fARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fARB_remap_index])
+#define SET_VertexAttrib3fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fARB_remap_index], fn)
+#define CALL_VertexAttrib3fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib3fvARB_remap_index], parameters)
+#define GET_VertexAttrib3fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fvARB_remap_index])
+#define SET_VertexAttrib3fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fvARB_remap_index], fn)
+#define CALL_VertexAttrib3sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib3sARB_remap_index], parameters)
+#define GET_VertexAttrib3sARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3sARB_remap_index])
+#define SET_VertexAttrib3sARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3sARB_remap_index], fn)
+#define CALL_VertexAttrib3svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib3svARB_remap_index], parameters)
+#define GET_VertexAttrib3svARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3svARB_remap_index])
+#define SET_VertexAttrib3svARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3svARB_remap_index], fn)
+#define CALL_VertexAttrib4dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib4dARB_remap_index], parameters)
+#define GET_VertexAttrib4dARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dARB_remap_index])
+#define SET_VertexAttrib4dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dARB_remap_index], fn)
+#define CALL_VertexAttrib4dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib4dvARB_remap_index], parameters)
+#define GET_VertexAttrib4dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dvARB_remap_index])
+#define SET_VertexAttrib4dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dvARB_remap_index], fn)
+#define CALL_VertexAttrib4fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib4fARB_remap_index], parameters)
+#define GET_VertexAttrib4fARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fARB_remap_index])
+#define SET_VertexAttrib4fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fARB_remap_index], fn)
+#define CALL_VertexAttrib4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib4fvARB_remap_index], parameters)
+#define GET_VertexAttrib4fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fvARB_remap_index])
+#define SET_VertexAttrib4fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fvARB_remap_index], fn)
+#define CALL_VertexAttrib4sARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib4sARB_remap_index], parameters)
+#define GET_VertexAttrib4sARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4sARB_remap_index])
+#define SET_VertexAttrib4sARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4sARB_remap_index], fn)
+#define CALL_VertexAttrib4svARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib4svARB_remap_index], parameters)
+#define GET_VertexAttrib4svARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4svARB_remap_index])
+#define SET_VertexAttrib4svARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4svARB_remap_index], fn)
+#define CALL_VertexAttrib4NubARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte)), driDispatchRemapTable[VertexAttrib4NubARB_remap_index], parameters)
+#define GET_VertexAttrib4NubARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NubARB_remap_index])
+#define SET_VertexAttrib4NubARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NubARB_remap_index], fn)
+#define CALL_VertexAttrib4NubvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLubyte *)), driDispatchRemapTable[VertexAttrib4NubvARB_remap_index], parameters)
+#define GET_VertexAttrib4NubvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NubvARB_remap_index])
+#define SET_VertexAttrib4NubvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NubvARB_remap_index], fn)
+#define CALL_VertexAttribs1dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLdouble *)), driDispatchRemapTable[VertexAttribs1dvNV_remap_index], parameters)
+#define GET_VertexAttribs1dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs1dvNV_remap_index])
+#define SET_VertexAttribs1dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs1dvNV_remap_index], fn)
+#define CALL_VertexAttribs1fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLfloat *)), driDispatchRemapTable[VertexAttribs1fvNV_remap_index], parameters)
+#define GET_VertexAttribs1fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs1fvNV_remap_index])
+#define SET_VertexAttribs1fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs1fvNV_remap_index], fn)
+#define CALL_VertexAttribs1svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLshort *)), driDispatchRemapTable[VertexAttribs1svNV_remap_index], parameters)
+#define GET_VertexAttribs1svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs1svNV_remap_index])
+#define SET_VertexAttribs1svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs1svNV_remap_index], fn)
+#define CALL_VertexAttribs2dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLdouble *)), driDispatchRemapTable[VertexAttribs2dvNV_remap_index], parameters)
+#define GET_VertexAttribs2dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs2dvNV_remap_index])
+#define SET_VertexAttribs2dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs2dvNV_remap_index], fn)
+#define CALL_VertexAttribs2fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLfloat *)), driDispatchRemapTable[VertexAttribs2fvNV_remap_index], parameters)
+#define GET_VertexAttribs2fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs2fvNV_remap_index])
+#define SET_VertexAttribs2fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs2fvNV_remap_index], fn)
+#define CALL_VertexAttribs2svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLshort *)), driDispatchRemapTable[VertexAttribs2svNV_remap_index], parameters)
+#define GET_VertexAttribs2svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs2svNV_remap_index])
+#define SET_VertexAttribs2svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs2svNV_remap_index], fn)
+#define CALL_VertexAttribs3dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLdouble *)), driDispatchRemapTable[VertexAttribs3dvNV_remap_index], parameters)
+#define GET_VertexAttribs3dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs3dvNV_remap_index])
+#define SET_VertexAttribs3dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs3dvNV_remap_index], fn)
+#define CALL_VertexAttribs3fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLfloat *)), driDispatchRemapTable[VertexAttribs3fvNV_remap_index], parameters)
+#define GET_VertexAttribs3fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs3fvNV_remap_index])
+#define SET_VertexAttribs3fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs3fvNV_remap_index], fn)
+#define CALL_VertexAttribs3svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLshort *)), driDispatchRemapTable[VertexAttribs3svNV_remap_index], parameters)
+#define GET_VertexAttribs3svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs3svNV_remap_index])
+#define SET_VertexAttribs3svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs3svNV_remap_index], fn)
+#define CALL_VertexAttribs4dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLdouble *)), driDispatchRemapTable[VertexAttribs4dvNV_remap_index], parameters)
+#define GET_VertexAttribs4dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs4dvNV_remap_index])
+#define SET_VertexAttribs4dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs4dvNV_remap_index], fn)
+#define CALL_VertexAttribs4fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLfloat *)), driDispatchRemapTable[VertexAttribs4fvNV_remap_index], parameters)
+#define GET_VertexAttribs4fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs4fvNV_remap_index])
+#define SET_VertexAttribs4fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs4fvNV_remap_index], fn)
+#define CALL_VertexAttribs4svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLshort *)), driDispatchRemapTable[VertexAttribs4svNV_remap_index], parameters)
+#define GET_VertexAttribs4svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs4svNV_remap_index])
+#define SET_VertexAttribs4svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs4svNV_remap_index], fn)
+#define CALL_VertexAttribs4ubvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *)), driDispatchRemapTable[VertexAttribs4ubvNV_remap_index], parameters)
+#define GET_VertexAttribs4ubvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribs4ubvNV_remap_index])
+#define SET_VertexAttribs4ubvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribs4ubvNV_remap_index], fn)
+#define CALL_PointParameteriNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint)), driDispatchRemapTable[PointParameteriNV_remap_index], parameters)
+#define GET_PointParameteriNV(disp) GET_by_offset(disp, driDispatchRemapTable[PointParameteriNV_remap_index])
+#define SET_PointParameteriNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PointParameteriNV_remap_index], fn)
+#define CALL_PointParameterivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLint *)), driDispatchRemapTable[PointParameterivNV_remap_index], parameters)
+#define GET_PointParameterivNV(disp) GET_by_offset(disp, driDispatchRemapTable[PointParameterivNV_remap_index])
+#define SET_PointParameterivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PointParameterivNV_remap_index], fn)
+#define CALL_MultiDrawArraysEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLint *, GLsizei *, GLsizei)), driDispatchRemapTable[MultiDrawArraysEXT_remap_index], parameters)
+#define GET_MultiDrawArraysEXT(disp) GET_by_offset(disp, driDispatchRemapTable[MultiDrawArraysEXT_remap_index])
+#define SET_MultiDrawArraysEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultiDrawArraysEXT_remap_index], fn)
+#define CALL_MultiDrawElementsEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, const GLsizei *, GLenum, const GLvoid **, GLsizei)), driDispatchRemapTable[MultiDrawElementsEXT_remap_index], parameters)
+#define GET_MultiDrawElementsEXT(disp) GET_by_offset(disp, driDispatchRemapTable[MultiDrawElementsEXT_remap_index])
+#define SET_MultiDrawElementsEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultiDrawElementsEXT_remap_index], fn)
+#define CALL_ActiveStencilFaceEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[ActiveStencilFaceEXT_remap_index], parameters)
+#define GET_ActiveStencilFaceEXT(disp) GET_by_offset(disp, driDispatchRemapTable[ActiveStencilFaceEXT_remap_index])
+#define SET_ActiveStencilFaceEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ActiveStencilFaceEXT_remap_index], fn)
+#define CALL_DeleteFencesNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteFencesNV_remap_index], parameters)
+#define GET_DeleteFencesNV(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteFencesNV_remap_index])
+#define SET_DeleteFencesNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteFencesNV_remap_index], fn)
+#define CALL_GenFencesNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenFencesNV_remap_index], parameters)
+#define GET_GenFencesNV(disp) GET_by_offset(disp, driDispatchRemapTable[GenFencesNV_remap_index])
+#define SET_GenFencesNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenFencesNV_remap_index], fn)
+#define CALL_IsFenceNV(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsFenceNV_remap_index], parameters)
+#define GET_IsFenceNV(disp) GET_by_offset(disp, driDispatchRemapTable[IsFenceNV_remap_index])
+#define SET_IsFenceNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsFenceNV_remap_index], fn)
+#define CALL_TestFenceNV(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[TestFenceNV_remap_index], parameters)
+#define GET_TestFenceNV(disp) GET_by_offset(disp, driDispatchRemapTable[TestFenceNV_remap_index])
+#define SET_TestFenceNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[TestFenceNV_remap_index], fn)
+#define CALL_GetFenceivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetFenceivNV_remap_index], parameters)
+#define GET_GetFenceivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetFenceivNV_remap_index])
+#define SET_GetFenceivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetFenceivNV_remap_index], fn)
+#define CALL_FinishFenceNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[FinishFenceNV_remap_index], parameters)
+#define GET_FinishFenceNV(disp) GET_by_offset(disp, driDispatchRemapTable[FinishFenceNV_remap_index])
+#define SET_FinishFenceNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FinishFenceNV_remap_index], fn)
+#define CALL_SetFenceNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum)), driDispatchRemapTable[SetFenceNV_remap_index], parameters)
+#define GET_SetFenceNV(disp) GET_by_offset(disp, driDispatchRemapTable[SetFenceNV_remap_index])
+#define SET_SetFenceNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SetFenceNV_remap_index], fn)
+#define CALL_VertexAttrib4bvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLbyte *)), driDispatchRemapTable[VertexAttrib4bvARB_remap_index], parameters)
+#define GET_VertexAttrib4bvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4bvARB_remap_index])
+#define SET_VertexAttrib4bvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4bvARB_remap_index], fn)
+#define CALL_VertexAttrib4ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLint *)), driDispatchRemapTable[VertexAttrib4ivARB_remap_index], parameters)
+#define GET_VertexAttrib4ivARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ivARB_remap_index])
+#define SET_VertexAttrib4ivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ivARB_remap_index], fn)
+#define CALL_VertexAttrib4ubvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLubyte *)), driDispatchRemapTable[VertexAttrib4ubvARB_remap_index], parameters)
+#define GET_VertexAttrib4ubvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubvARB_remap_index])
+#define SET_VertexAttrib4ubvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubvARB_remap_index], fn)
+#define CALL_VertexAttrib4usvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLushort *)), driDispatchRemapTable[VertexAttrib4usvARB_remap_index], parameters)
+#define GET_VertexAttrib4usvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4usvARB_remap_index])
+#define SET_VertexAttrib4usvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4usvARB_remap_index], fn)
+#define CALL_VertexAttrib4uivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLuint *)), driDispatchRemapTable[VertexAttrib4uivARB_remap_index], parameters)
+#define GET_VertexAttrib4uivARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4uivARB_remap_index])
+#define SET_VertexAttrib4uivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4uivARB_remap_index], fn)
+#define CALL_VertexAttrib4NbvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLbyte *)), driDispatchRemapTable[VertexAttrib4NbvARB_remap_index], parameters)
+#define GET_VertexAttrib4NbvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NbvARB_remap_index])
+#define SET_VertexAttrib4NbvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NbvARB_remap_index], fn)
+#define CALL_VertexAttrib4NsvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib4NsvARB_remap_index], parameters)
+#define GET_VertexAttrib4NsvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NsvARB_remap_index])
+#define SET_VertexAttrib4NsvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NsvARB_remap_index], fn)
+#define CALL_VertexAttrib4NivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLint *)), driDispatchRemapTable[VertexAttrib4NivARB_remap_index], parameters)
+#define GET_VertexAttrib4NivARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NivARB_remap_index])
+#define SET_VertexAttrib4NivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NivARB_remap_index], fn)
+#define CALL_VertexAttrib4NusvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLushort *)), driDispatchRemapTable[VertexAttrib4NusvARB_remap_index], parameters)
+#define GET_VertexAttrib4NusvARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NusvARB_remap_index])
+#define SET_VertexAttrib4NusvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NusvARB_remap_index], fn)
+#define CALL_VertexAttrib4NuivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLuint *)), driDispatchRemapTable[VertexAttrib4NuivARB_remap_index], parameters)
+#define GET_VertexAttrib4NuivARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NuivARB_remap_index])
+#define SET_VertexAttrib4NuivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4NuivARB_remap_index], fn)
+#define CALL_VertexAttribPointerARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *)), driDispatchRemapTable[VertexAttribPointerARB_remap_index], parameters)
+#define GET_VertexAttribPointerARB(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttribPointerARB_remap_index])
+#define SET_VertexAttribPointerARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttribPointerARB_remap_index], fn)
+#define CALL_EnableVertexAttribArrayARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[EnableVertexAttribArrayARB_remap_index], parameters)
+#define GET_EnableVertexAttribArrayARB(disp) GET_by_offset(disp, driDispatchRemapTable[EnableVertexAttribArrayARB_remap_index])
+#define SET_EnableVertexAttribArrayARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[EnableVertexAttribArrayARB_remap_index], fn)
+#define CALL_DisableVertexAttribArrayARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[DisableVertexAttribArrayARB_remap_index], parameters)
+#define GET_DisableVertexAttribArrayARB(disp) GET_by_offset(disp, driDispatchRemapTable[DisableVertexAttribArrayARB_remap_index])
+#define SET_DisableVertexAttribArrayARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DisableVertexAttribArrayARB_remap_index], fn)
+#define CALL_ProgramStringARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLsizei, const GLvoid *)), driDispatchRemapTable[ProgramStringARB_remap_index], parameters)
+#define GET_ProgramStringARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramStringARB_remap_index])
+#define SET_ProgramStringARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramStringARB_remap_index], fn)
+#define CALL_ProgramEnvParameter4dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[ProgramEnvParameter4dARB_remap_index], parameters)
+#define GET_ProgramEnvParameter4dARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4dARB_remap_index])
+#define SET_ProgramEnvParameter4dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4dARB_remap_index], fn)
+#define CALL_ProgramEnvParameter4dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLdouble *)), driDispatchRemapTable[ProgramEnvParameter4dvARB_remap_index], parameters)
+#define GET_ProgramEnvParameter4dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4dvARB_remap_index])
+#define SET_ProgramEnvParameter4dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4dvARB_remap_index], fn)
+#define CALL_ProgramEnvParameter4fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[ProgramEnvParameter4fARB_remap_index], parameters)
+#define GET_ProgramEnvParameter4fARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4fARB_remap_index])
+#define SET_ProgramEnvParameter4fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4fARB_remap_index], fn)
+#define CALL_ProgramEnvParameter4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLfloat *)), driDispatchRemapTable[ProgramEnvParameter4fvARB_remap_index], parameters)
+#define GET_ProgramEnvParameter4fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4fvARB_remap_index])
+#define SET_ProgramEnvParameter4fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramEnvParameter4fvARB_remap_index], fn)
+#define CALL_ProgramLocalParameter4dARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[ProgramLocalParameter4dARB_remap_index], parameters)
+#define GET_ProgramLocalParameter4dARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4dARB_remap_index])
+#define SET_ProgramLocalParameter4dARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4dARB_remap_index], fn)
+#define CALL_ProgramLocalParameter4dvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLdouble *)), driDispatchRemapTable[ProgramLocalParameter4dvARB_remap_index], parameters)
+#define GET_ProgramLocalParameter4dvARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4dvARB_remap_index])
+#define SET_ProgramLocalParameter4dvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4dvARB_remap_index], fn)
+#define CALL_ProgramLocalParameter4fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[ProgramLocalParameter4fARB_remap_index], parameters)
+#define GET_ProgramLocalParameter4fARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4fARB_remap_index])
+#define SET_ProgramLocalParameter4fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4fARB_remap_index], fn)
+#define CALL_ProgramLocalParameter4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, const GLfloat *)), driDispatchRemapTable[ProgramLocalParameter4fvARB_remap_index], parameters)
+#define GET_ProgramLocalParameter4fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4fvARB_remap_index])
+#define SET_ProgramLocalParameter4fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramLocalParameter4fvARB_remap_index], fn)
+#define CALL_GetProgramEnvParameterdvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLdouble *)), driDispatchRemapTable[GetProgramEnvParameterdvARB_remap_index], parameters)
+#define GET_GetProgramEnvParameterdvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramEnvParameterdvARB_remap_index])
+#define SET_GetProgramEnvParameterdvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramEnvParameterdvARB_remap_index], fn)
+#define CALL_GetProgramEnvParameterfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLfloat *)), driDispatchRemapTable[GetProgramEnvParameterfvARB_remap_index], parameters)
+#define GET_GetProgramEnvParameterfvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramEnvParameterfvARB_remap_index])
+#define SET_GetProgramEnvParameterfvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramEnvParameterfvARB_remap_index], fn)
+#define CALL_GetProgramLocalParameterdvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLdouble *)), driDispatchRemapTable[GetProgramLocalParameterdvARB_remap_index], parameters)
+#define GET_GetProgramLocalParameterdvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramLocalParameterdvARB_remap_index])
+#define SET_GetProgramLocalParameterdvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramLocalParameterdvARB_remap_index], fn)
+#define CALL_GetProgramLocalParameterfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLfloat *)), driDispatchRemapTable[GetProgramLocalParameterfvARB_remap_index], parameters)
+#define GET_GetProgramLocalParameterfvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramLocalParameterfvARB_remap_index])
+#define SET_GetProgramLocalParameterfvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramLocalParameterfvARB_remap_index], fn)
+#define CALL_GetProgramivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetProgramivARB_remap_index], parameters)
+#define GET_GetProgramivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramivARB_remap_index])
+#define SET_GetProgramivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramivARB_remap_index], fn)
+#define CALL_GetProgramStringARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLvoid *)), driDispatchRemapTable[GetProgramStringARB_remap_index], parameters)
+#define GET_GetProgramStringARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramStringARB_remap_index])
+#define SET_GetProgramStringARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramStringARB_remap_index], fn)
+#define CALL_ProgramNamedParameter4fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[ProgramNamedParameter4fNV_remap_index], parameters)
+#define GET_ProgramNamedParameter4fNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4fNV_remap_index])
+#define SET_ProgramNamedParameter4fNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4fNV_remap_index], fn)
+#define CALL_ProgramNamedParameter4dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[ProgramNamedParameter4dNV_remap_index], parameters)
+#define GET_ProgramNamedParameter4dNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4dNV_remap_index])
+#define SET_ProgramNamedParameter4dNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4dNV_remap_index], fn)
+#define CALL_ProgramNamedParameter4fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, const GLfloat *)), driDispatchRemapTable[ProgramNamedParameter4fvNV_remap_index], parameters)
+#define GET_ProgramNamedParameter4fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4fvNV_remap_index])
+#define SET_ProgramNamedParameter4fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4fvNV_remap_index], fn)
+#define CALL_ProgramNamedParameter4dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, const GLdouble *)), driDispatchRemapTable[ProgramNamedParameter4dvNV_remap_index], parameters)
+#define GET_ProgramNamedParameter4dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4dvNV_remap_index])
+#define SET_ProgramNamedParameter4dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ProgramNamedParameter4dvNV_remap_index], fn)
+#define CALL_GetProgramNamedParameterfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, GLfloat *)), driDispatchRemapTable[GetProgramNamedParameterfvNV_remap_index], parameters)
+#define GET_GetProgramNamedParameterfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramNamedParameterfvNV_remap_index])
+#define SET_GetProgramNamedParameterfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramNamedParameterfvNV_remap_index], fn)
+#define CALL_GetProgramNamedParameterdvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLsizei, const GLubyte *, GLdouble *)), driDispatchRemapTable[GetProgramNamedParameterdvNV_remap_index], parameters)
+#define GET_GetProgramNamedParameterdvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetProgramNamedParameterdvNV_remap_index])
+#define SET_GetProgramNamedParameterdvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetProgramNamedParameterdvNV_remap_index], fn)
+#define CALL_BindBufferARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[BindBufferARB_remap_index], parameters)
+#define GET_BindBufferARB(disp) GET_by_offset(disp, driDispatchRemapTable[BindBufferARB_remap_index])
+#define SET_BindBufferARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindBufferARB_remap_index], fn)
+#define CALL_BufferDataARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLsizeiptrARB, const GLvoid *, GLenum)), driDispatchRemapTable[BufferDataARB_remap_index], parameters)
+#define GET_BufferDataARB(disp) GET_by_offset(disp, driDispatchRemapTable[BufferDataARB_remap_index])
+#define SET_BufferDataARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BufferDataARB_remap_index], fn)
+#define CALL_BufferSubDataARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *)), driDispatchRemapTable[BufferSubDataARB_remap_index], parameters)
+#define GET_BufferSubDataARB(disp) GET_by_offset(disp, driDispatchRemapTable[BufferSubDataARB_remap_index])
+#define SET_BufferSubDataARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BufferSubDataARB_remap_index], fn)
+#define CALL_DeleteBuffersARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteBuffersARB_remap_index], parameters)
+#define GET_DeleteBuffersARB(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteBuffersARB_remap_index])
+#define SET_DeleteBuffersARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteBuffersARB_remap_index], fn)
+#define CALL_GenBuffersARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenBuffersARB_remap_index], parameters)
+#define GET_GenBuffersARB(disp) GET_by_offset(disp, driDispatchRemapTable[GenBuffersARB_remap_index])
+#define SET_GenBuffersARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenBuffersARB_remap_index], fn)
+#define CALL_GetBufferParameterivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetBufferParameterivARB_remap_index], parameters)
+#define GET_GetBufferParameterivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetBufferParameterivARB_remap_index])
+#define SET_GetBufferParameterivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetBufferParameterivARB_remap_index], fn)
+#define CALL_GetBufferPointervARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLvoid **)), driDispatchRemapTable[GetBufferPointervARB_remap_index], parameters)
+#define GET_GetBufferPointervARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetBufferPointervARB_remap_index])
+#define SET_GetBufferPointervARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetBufferPointervARB_remap_index], fn)
+#define CALL_GetBufferSubDataARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *)), driDispatchRemapTable[GetBufferSubDataARB_remap_index], parameters)
+#define GET_GetBufferSubDataARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetBufferSubDataARB_remap_index])
+#define SET_GetBufferSubDataARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetBufferSubDataARB_remap_index], fn)
+#define CALL_IsBufferARB(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsBufferARB_remap_index], parameters)
+#define GET_IsBufferARB(disp) GET_by_offset(disp, driDispatchRemapTable[IsBufferARB_remap_index])
+#define SET_IsBufferARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsBufferARB_remap_index], fn)
+#define CALL_MapBufferARB(disp, parameters) CALL_by_offset(disp, (GLvoid * (GLAPIENTRYP)(GLenum, GLenum)), driDispatchRemapTable[MapBufferARB_remap_index], parameters)
+#define GET_MapBufferARB(disp) GET_by_offset(disp, driDispatchRemapTable[MapBufferARB_remap_index])
+#define SET_MapBufferARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MapBufferARB_remap_index], fn)
+#define CALL_UnmapBufferARB(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[UnmapBufferARB_remap_index], parameters)
+#define GET_UnmapBufferARB(disp) GET_by_offset(disp, driDispatchRemapTable[UnmapBufferARB_remap_index])
+#define SET_UnmapBufferARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UnmapBufferARB_remap_index], fn)
+#define CALL_DepthBoundsEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLclampd, GLclampd)), driDispatchRemapTable[DepthBoundsEXT_remap_index], parameters)
+#define GET_DepthBoundsEXT(disp) GET_by_offset(disp, driDispatchRemapTable[DepthBoundsEXT_remap_index])
+#define SET_DepthBoundsEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DepthBoundsEXT_remap_index], fn)
+#define CALL_GenQueriesARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenQueriesARB_remap_index], parameters)
+#define GET_GenQueriesARB(disp) GET_by_offset(disp, driDispatchRemapTable[GenQueriesARB_remap_index])
+#define SET_GenQueriesARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenQueriesARB_remap_index], fn)
+#define CALL_DeleteQueriesARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteQueriesARB_remap_index], parameters)
+#define GET_DeleteQueriesARB(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteQueriesARB_remap_index])
+#define SET_DeleteQueriesARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteQueriesARB_remap_index], fn)
+#define CALL_IsQueryARB(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsQueryARB_remap_index], parameters)
+#define GET_IsQueryARB(disp) GET_by_offset(disp, driDispatchRemapTable[IsQueryARB_remap_index])
+#define SET_IsQueryARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsQueryARB_remap_index], fn)
+#define CALL_BeginQueryARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[BeginQueryARB_remap_index], parameters)
+#define GET_BeginQueryARB(disp) GET_by_offset(disp, driDispatchRemapTable[BeginQueryARB_remap_index])
+#define SET_BeginQueryARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BeginQueryARB_remap_index], fn)
+#define CALL_EndQueryARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[EndQueryARB_remap_index], parameters)
+#define GET_EndQueryARB(disp) GET_by_offset(disp, driDispatchRemapTable[EndQueryARB_remap_index])
+#define SET_EndQueryARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[EndQueryARB_remap_index], fn)
+#define CALL_GetQueryivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetQueryivARB_remap_index], parameters)
+#define GET_GetQueryivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetQueryivARB_remap_index])
+#define SET_GetQueryivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetQueryivARB_remap_index], fn)
+#define CALL_GetQueryObjectivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetQueryObjectivARB_remap_index], parameters)
+#define GET_GetQueryObjectivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetQueryObjectivARB_remap_index])
+#define SET_GetQueryObjectivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetQueryObjectivARB_remap_index], fn)
+#define CALL_GetQueryObjectuivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLuint *)), driDispatchRemapTable[GetQueryObjectuivARB_remap_index], parameters)
+#define GET_GetQueryObjectuivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetQueryObjectuivARB_remap_index])
+#define SET_GetQueryObjectuivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetQueryObjectuivARB_remap_index], fn)
+#define CALL_MultiModeDrawArraysIBM(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint)), driDispatchRemapTable[MultiModeDrawArraysIBM_remap_index], parameters)
+#define GET_MultiModeDrawArraysIBM(disp) GET_by_offset(disp, driDispatchRemapTable[MultiModeDrawArraysIBM_remap_index])
+#define SET_MultiModeDrawArraysIBM(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultiModeDrawArraysIBM_remap_index], fn)
+#define CALL_MultiModeDrawElementsIBM(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(const GLenum *, const GLsizei *, GLenum, const GLvoid * const *, GLsizei, GLint)), driDispatchRemapTable[MultiModeDrawElementsIBM_remap_index], parameters)
+#define GET_MultiModeDrawElementsIBM(disp) GET_by_offset(disp, driDispatchRemapTable[MultiModeDrawElementsIBM_remap_index])
+#define SET_MultiModeDrawElementsIBM(disp, fn) SET_by_offset(disp, driDispatchRemapTable[MultiModeDrawElementsIBM_remap_index], fn)
+#define CALL_BlendEquationSeparateEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum)), driDispatchRemapTable[BlendEquationSeparateEXT_remap_index], parameters)
+#define GET_BlendEquationSeparateEXT(disp) GET_by_offset(disp, driDispatchRemapTable[BlendEquationSeparateEXT_remap_index])
+#define SET_BlendEquationSeparateEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BlendEquationSeparateEXT_remap_index], fn)
+#define CALL_DeleteObjectARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), driDispatchRemapTable[DeleteObjectARB_remap_index], parameters)
+#define GET_DeleteObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteObjectARB_remap_index])
+#define SET_DeleteObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteObjectARB_remap_index], fn)
+#define CALL_GetHandleARB(disp, parameters) CALL_by_offset(disp, (GLhandleARB (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[GetHandleARB_remap_index], parameters)
+#define GET_GetHandleARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetHandleARB_remap_index])
+#define SET_GetHandleARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetHandleARB_remap_index], fn)
+#define CALL_DetachObjectARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLhandleARB)), driDispatchRemapTable[DetachObjectARB_remap_index], parameters)
+#define GET_DetachObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[DetachObjectARB_remap_index])
+#define SET_DetachObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DetachObjectARB_remap_index], fn)
+#define CALL_CreateShaderObjectARB(disp, parameters) CALL_by_offset(disp, (GLhandleARB (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[CreateShaderObjectARB_remap_index], parameters)
+#define GET_CreateShaderObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[CreateShaderObjectARB_remap_index])
+#define SET_CreateShaderObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CreateShaderObjectARB_remap_index], fn)
+#define CALL_ShaderSourceARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLsizei, const GLcharARB **, const GLint *)), driDispatchRemapTable[ShaderSourceARB_remap_index], parameters)
+#define GET_ShaderSourceARB(disp) GET_by_offset(disp, driDispatchRemapTable[ShaderSourceARB_remap_index])
+#define SET_ShaderSourceARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ShaderSourceARB_remap_index], fn)
+#define CALL_CompileShaderARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), driDispatchRemapTable[CompileShaderARB_remap_index], parameters)
+#define GET_CompileShaderARB(disp) GET_by_offset(disp, driDispatchRemapTable[CompileShaderARB_remap_index])
+#define SET_CompileShaderARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CompileShaderARB_remap_index], fn)
+#define CALL_CreateProgramObjectARB(disp, parameters) CALL_by_offset(disp, (GLhandleARB (GLAPIENTRYP)(void)), driDispatchRemapTable[CreateProgramObjectARB_remap_index], parameters)
+#define GET_CreateProgramObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[CreateProgramObjectARB_remap_index])
+#define SET_CreateProgramObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CreateProgramObjectARB_remap_index], fn)
+#define CALL_AttachObjectARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLhandleARB)), driDispatchRemapTable[AttachObjectARB_remap_index], parameters)
+#define GET_AttachObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[AttachObjectARB_remap_index])
+#define SET_AttachObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AttachObjectARB_remap_index], fn)
+#define CALL_LinkProgramARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), driDispatchRemapTable[LinkProgramARB_remap_index], parameters)
+#define GET_LinkProgramARB(disp) GET_by_offset(disp, driDispatchRemapTable[LinkProgramARB_remap_index])
+#define SET_LinkProgramARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[LinkProgramARB_remap_index], fn)
+#define CALL_UseProgramObjectARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), driDispatchRemapTable[UseProgramObjectARB_remap_index], parameters)
+#define GET_UseProgramObjectARB(disp) GET_by_offset(disp, driDispatchRemapTable[UseProgramObjectARB_remap_index])
+#define SET_UseProgramObjectARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UseProgramObjectARB_remap_index], fn)
+#define CALL_ValidateProgramARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB)), driDispatchRemapTable[ValidateProgramARB_remap_index], parameters)
+#define GET_ValidateProgramARB(disp) GET_by_offset(disp, driDispatchRemapTable[ValidateProgramARB_remap_index])
+#define SET_ValidateProgramARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ValidateProgramARB_remap_index], fn)
+#define CALL_Uniform1fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat)), driDispatchRemapTable[Uniform1fARB_remap_index], parameters)
+#define GET_Uniform1fARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform1fARB_remap_index])
+#define SET_Uniform1fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform1fARB_remap_index], fn)
+#define CALL_Uniform2fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat, GLfloat)), driDispatchRemapTable[Uniform2fARB_remap_index], parameters)
+#define GET_Uniform2fARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform2fARB_remap_index])
+#define SET_Uniform2fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform2fARB_remap_index], fn)
+#define CALL_Uniform3fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[Uniform3fARB_remap_index], parameters)
+#define GET_Uniform3fARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform3fARB_remap_index])
+#define SET_Uniform3fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform3fARB_remap_index], fn)
+#define CALL_Uniform4fARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[Uniform4fARB_remap_index], parameters)
+#define GET_Uniform4fARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform4fARB_remap_index])
+#define SET_Uniform4fARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform4fARB_remap_index], fn)
+#define CALL_Uniform1iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint)), driDispatchRemapTable[Uniform1iARB_remap_index], parameters)
+#define GET_Uniform1iARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform1iARB_remap_index])
+#define SET_Uniform1iARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform1iARB_remap_index], fn)
+#define CALL_Uniform2iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint)), driDispatchRemapTable[Uniform2iARB_remap_index], parameters)
+#define GET_Uniform2iARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform2iARB_remap_index])
+#define SET_Uniform2iARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform2iARB_remap_index], fn)
+#define CALL_Uniform3iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint)), driDispatchRemapTable[Uniform3iARB_remap_index], parameters)
+#define GET_Uniform3iARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform3iARB_remap_index])
+#define SET_Uniform3iARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform3iARB_remap_index], fn)
+#define CALL_Uniform4iARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLint, GLint, GLint, GLint)), driDispatchRemapTable[Uniform4iARB_remap_index], parameters)
+#define GET_Uniform4iARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform4iARB_remap_index])
+#define SET_Uniform4iARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform4iARB_remap_index], fn)
+#define CALL_Uniform1fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLfloat *)), driDispatchRemapTable[Uniform1fvARB_remap_index], parameters)
+#define GET_Uniform1fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform1fvARB_remap_index])
+#define SET_Uniform1fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform1fvARB_remap_index], fn)
+#define CALL_Uniform2fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLfloat *)), driDispatchRemapTable[Uniform2fvARB_remap_index], parameters)
+#define GET_Uniform2fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform2fvARB_remap_index])
+#define SET_Uniform2fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform2fvARB_remap_index], fn)
+#define CALL_Uniform3fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLfloat *)), driDispatchRemapTable[Uniform3fvARB_remap_index], parameters)
+#define GET_Uniform3fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform3fvARB_remap_index])
+#define SET_Uniform3fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform3fvARB_remap_index], fn)
+#define CALL_Uniform4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLfloat *)), driDispatchRemapTable[Uniform4fvARB_remap_index], parameters)
+#define GET_Uniform4fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform4fvARB_remap_index])
+#define SET_Uniform4fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform4fvARB_remap_index], fn)
+#define CALL_Uniform1ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLint *)), driDispatchRemapTable[Uniform1ivARB_remap_index], parameters)
+#define GET_Uniform1ivARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform1ivARB_remap_index])
+#define SET_Uniform1ivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform1ivARB_remap_index], fn)
+#define CALL_Uniform2ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLint *)), driDispatchRemapTable[Uniform2ivARB_remap_index], parameters)
+#define GET_Uniform2ivARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform2ivARB_remap_index])
+#define SET_Uniform2ivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform2ivARB_remap_index], fn)
+#define CALL_Uniform3ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLint *)), driDispatchRemapTable[Uniform3ivARB_remap_index], parameters)
+#define GET_Uniform3ivARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform3ivARB_remap_index])
+#define SET_Uniform3ivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform3ivARB_remap_index], fn)
+#define CALL_Uniform4ivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, const GLint *)), driDispatchRemapTable[Uniform4ivARB_remap_index], parameters)
+#define GET_Uniform4ivARB(disp) GET_by_offset(disp, driDispatchRemapTable[Uniform4ivARB_remap_index])
+#define SET_Uniform4ivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[Uniform4ivARB_remap_index], fn)
+#define CALL_UniformMatrix2fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix2fvARB_remap_index], parameters)
+#define GET_UniformMatrix2fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix2fvARB_remap_index])
+#define SET_UniformMatrix2fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix2fvARB_remap_index], fn)
+#define CALL_UniformMatrix3fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix3fvARB_remap_index], parameters)
+#define GET_UniformMatrix3fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix3fvARB_remap_index])
+#define SET_UniformMatrix3fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix3fvARB_remap_index], fn)
+#define CALL_UniformMatrix4fvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLint, GLsizei, GLboolean, const GLfloat *)), driDispatchRemapTable[UniformMatrix4fvARB_remap_index], parameters)
+#define GET_UniformMatrix4fvARB(disp) GET_by_offset(disp, driDispatchRemapTable[UniformMatrix4fvARB_remap_index])
+#define SET_UniformMatrix4fvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[UniformMatrix4fvARB_remap_index], fn)
+#define CALL_GetObjectParameterfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLenum, GLfloat *)), driDispatchRemapTable[GetObjectParameterfvARB_remap_index], parameters)
+#define GET_GetObjectParameterfvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetObjectParameterfvARB_remap_index])
+#define SET_GetObjectParameterfvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetObjectParameterfvARB_remap_index], fn)
+#define CALL_GetObjectParameterivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLenum, GLint *)), driDispatchRemapTable[GetObjectParameterivARB_remap_index], parameters)
+#define GET_GetObjectParameterivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetObjectParameterivARB_remap_index])
+#define SET_GetObjectParameterivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetObjectParameterivARB_remap_index], fn)
+#define CALL_GetInfoLogARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *)), driDispatchRemapTable[GetInfoLogARB_remap_index], parameters)
+#define GET_GetInfoLogARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetInfoLogARB_remap_index])
+#define SET_GetInfoLogARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetInfoLogARB_remap_index], fn)
+#define CALL_GetAttachedObjectsARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLsizei, GLsizei *, GLhandleARB *)), driDispatchRemapTable[GetAttachedObjectsARB_remap_index], parameters)
+#define GET_GetAttachedObjectsARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetAttachedObjectsARB_remap_index])
+#define SET_GetAttachedObjectsARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetAttachedObjectsARB_remap_index], fn)
+#define CALL_GetUniformLocationARB(disp, parameters) CALL_by_offset(disp, (GLint (GLAPIENTRYP)(GLhandleARB, const GLcharARB *)), driDispatchRemapTable[GetUniformLocationARB_remap_index], parameters)
+#define GET_GetUniformLocationARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetUniformLocationARB_remap_index])
+#define SET_GetUniformLocationARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetUniformLocationARB_remap_index], fn)
+#define CALL_GetActiveUniformARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *)), driDispatchRemapTable[GetActiveUniformARB_remap_index], parameters)
+#define GET_GetActiveUniformARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetActiveUniformARB_remap_index])
+#define SET_GetActiveUniformARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetActiveUniformARB_remap_index], fn)
+#define CALL_GetUniformfvARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLint, GLfloat *)), driDispatchRemapTable[GetUniformfvARB_remap_index], parameters)
+#define GET_GetUniformfvARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetUniformfvARB_remap_index])
+#define SET_GetUniformfvARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetUniformfvARB_remap_index], fn)
+#define CALL_GetUniformivARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLint, GLint *)), driDispatchRemapTable[GetUniformivARB_remap_index], parameters)
+#define GET_GetUniformivARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetUniformivARB_remap_index])
+#define SET_GetUniformivARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetUniformivARB_remap_index], fn)
+#define CALL_GetShaderSourceARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLsizei, GLsizei *, GLcharARB *)), driDispatchRemapTable[GetShaderSourceARB_remap_index], parameters)
+#define GET_GetShaderSourceARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetShaderSourceARB_remap_index])
+#define SET_GetShaderSourceARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetShaderSourceARB_remap_index], fn)
+#define CALL_BindAttribLocationARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLuint, const GLcharARB *)), driDispatchRemapTable[BindAttribLocationARB_remap_index], parameters)
+#define GET_BindAttribLocationARB(disp) GET_by_offset(disp, driDispatchRemapTable[BindAttribLocationARB_remap_index])
+#define SET_BindAttribLocationARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindAttribLocationARB_remap_index], fn)
+#define CALL_GetActiveAttribARB(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *)), driDispatchRemapTable[GetActiveAttribARB_remap_index], parameters)
+#define GET_GetActiveAttribARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetActiveAttribARB_remap_index])
+#define SET_GetActiveAttribARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetActiveAttribARB_remap_index], fn)
+#define CALL_GetAttribLocationARB(disp, parameters) CALL_by_offset(disp, (GLint (GLAPIENTRYP)(GLhandleARB, const GLcharARB *)), driDispatchRemapTable[GetAttribLocationARB_remap_index], parameters)
+#define GET_GetAttribLocationARB(disp) GET_by_offset(disp, driDispatchRemapTable[GetAttribLocationARB_remap_index])
+#define SET_GetAttribLocationARB(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetAttribLocationARB_remap_index], fn)
+#define CALL_GetVertexAttribdvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLdouble *)), driDispatchRemapTable[GetVertexAttribdvNV_remap_index], parameters)
+#define GET_GetVertexAttribdvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribdvNV_remap_index])
+#define SET_GetVertexAttribdvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribdvNV_remap_index], fn)
+#define CALL_GetVertexAttribfvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLfloat *)), driDispatchRemapTable[GetVertexAttribfvNV_remap_index], parameters)
+#define GET_GetVertexAttribfvNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribfvNV_remap_index])
+#define SET_GetVertexAttribfvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribfvNV_remap_index], fn)
+#define CALL_GetVertexAttribivNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLenum, GLint *)), driDispatchRemapTable[GetVertexAttribivNV_remap_index], parameters)
+#define GET_GetVertexAttribivNV(disp) GET_by_offset(disp, driDispatchRemapTable[GetVertexAttribivNV_remap_index])
+#define SET_GetVertexAttribivNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetVertexAttribivNV_remap_index], fn)
+#define CALL_VertexAttrib1dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble)), driDispatchRemapTable[VertexAttrib1dNV_remap_index], parameters)
+#define GET_VertexAttrib1dNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dNV_remap_index])
+#define SET_VertexAttrib1dNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dNV_remap_index], fn)
+#define CALL_VertexAttrib1dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib1dvNV_remap_index], parameters)
+#define GET_VertexAttrib1dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dvNV_remap_index])
+#define SET_VertexAttrib1dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1dvNV_remap_index], fn)
+#define CALL_VertexAttrib1fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat)), driDispatchRemapTable[VertexAttrib1fNV_remap_index], parameters)
+#define GET_VertexAttrib1fNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fNV_remap_index])
+#define SET_VertexAttrib1fNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fNV_remap_index], fn)
+#define CALL_VertexAttrib1fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib1fvNV_remap_index], parameters)
+#define GET_VertexAttrib1fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fvNV_remap_index])
+#define SET_VertexAttrib1fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1fvNV_remap_index], fn)
+#define CALL_VertexAttrib1sNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort)), driDispatchRemapTable[VertexAttrib1sNV_remap_index], parameters)
+#define GET_VertexAttrib1sNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1sNV_remap_index])
+#define SET_VertexAttrib1sNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1sNV_remap_index], fn)
+#define CALL_VertexAttrib1svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib1svNV_remap_index], parameters)
+#define GET_VertexAttrib1svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib1svNV_remap_index])
+#define SET_VertexAttrib1svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib1svNV_remap_index], fn)
+#define CALL_VertexAttrib2dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib2dNV_remap_index], parameters)
+#define GET_VertexAttrib2dNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dNV_remap_index])
+#define SET_VertexAttrib2dNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dNV_remap_index], fn)
+#define CALL_VertexAttrib2dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib2dvNV_remap_index], parameters)
+#define GET_VertexAttrib2dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dvNV_remap_index])
+#define SET_VertexAttrib2dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2dvNV_remap_index], fn)
+#define CALL_VertexAttrib2fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib2fNV_remap_index], parameters)
+#define GET_VertexAttrib2fNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fNV_remap_index])
+#define SET_VertexAttrib2fNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fNV_remap_index], fn)
+#define CALL_VertexAttrib2fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib2fvNV_remap_index], parameters)
+#define GET_VertexAttrib2fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fvNV_remap_index])
+#define SET_VertexAttrib2fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2fvNV_remap_index], fn)
+#define CALL_VertexAttrib2sNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib2sNV_remap_index], parameters)
+#define GET_VertexAttrib2sNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2sNV_remap_index])
+#define SET_VertexAttrib2sNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2sNV_remap_index], fn)
+#define CALL_VertexAttrib2svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib2svNV_remap_index], parameters)
+#define GET_VertexAttrib2svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib2svNV_remap_index])
+#define SET_VertexAttrib2svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib2svNV_remap_index], fn)
+#define CALL_VertexAttrib3dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib3dNV_remap_index], parameters)
+#define GET_VertexAttrib3dNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dNV_remap_index])
+#define SET_VertexAttrib3dNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dNV_remap_index], fn)
+#define CALL_VertexAttrib3dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib3dvNV_remap_index], parameters)
+#define GET_VertexAttrib3dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dvNV_remap_index])
+#define SET_VertexAttrib3dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3dvNV_remap_index], fn)
+#define CALL_VertexAttrib3fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib3fNV_remap_index], parameters)
+#define GET_VertexAttrib3fNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fNV_remap_index])
+#define SET_VertexAttrib3fNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fNV_remap_index], fn)
+#define CALL_VertexAttrib3fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib3fvNV_remap_index], parameters)
+#define GET_VertexAttrib3fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fvNV_remap_index])
+#define SET_VertexAttrib3fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3fvNV_remap_index], fn)
+#define CALL_VertexAttrib3sNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib3sNV_remap_index], parameters)
+#define GET_VertexAttrib3sNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3sNV_remap_index])
+#define SET_VertexAttrib3sNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3sNV_remap_index], fn)
+#define CALL_VertexAttrib3svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib3svNV_remap_index], parameters)
+#define GET_VertexAttrib3svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib3svNV_remap_index])
+#define SET_VertexAttrib3svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib3svNV_remap_index], fn)
+#define CALL_VertexAttrib4dNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLdouble, GLdouble, GLdouble, GLdouble)), driDispatchRemapTable[VertexAttrib4dNV_remap_index], parameters)
+#define GET_VertexAttrib4dNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dNV_remap_index])
+#define SET_VertexAttrib4dNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dNV_remap_index], fn)
+#define CALL_VertexAttrib4dvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLdouble *)), driDispatchRemapTable[VertexAttrib4dvNV_remap_index], parameters)
+#define GET_VertexAttrib4dvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dvNV_remap_index])
+#define SET_VertexAttrib4dvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4dvNV_remap_index], fn)
+#define CALL_VertexAttrib4fNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat)), driDispatchRemapTable[VertexAttrib4fNV_remap_index], parameters)
+#define GET_VertexAttrib4fNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fNV_remap_index])
+#define SET_VertexAttrib4fNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fNV_remap_index], fn)
+#define CALL_VertexAttrib4fvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[VertexAttrib4fvNV_remap_index], parameters)
+#define GET_VertexAttrib4fvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fvNV_remap_index])
+#define SET_VertexAttrib4fvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4fvNV_remap_index], fn)
+#define CALL_VertexAttrib4sNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLshort, GLshort, GLshort, GLshort)), driDispatchRemapTable[VertexAttrib4sNV_remap_index], parameters)
+#define GET_VertexAttrib4sNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4sNV_remap_index])
+#define SET_VertexAttrib4sNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4sNV_remap_index], fn)
+#define CALL_VertexAttrib4svNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLshort *)), driDispatchRemapTable[VertexAttrib4svNV_remap_index], parameters)
+#define GET_VertexAttrib4svNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4svNV_remap_index])
+#define SET_VertexAttrib4svNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4svNV_remap_index], fn)
+#define CALL_VertexAttrib4ubNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLubyte, GLubyte, GLubyte, GLubyte)), driDispatchRemapTable[VertexAttrib4ubNV_remap_index], parameters)
+#define GET_VertexAttrib4ubNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubNV_remap_index])
+#define SET_VertexAttrib4ubNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubNV_remap_index], fn)
+#define CALL_VertexAttrib4ubvNV(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLubyte *)), driDispatchRemapTable[VertexAttrib4ubvNV_remap_index], parameters)
+#define GET_VertexAttrib4ubvNV(disp) GET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubvNV_remap_index])
+#define SET_VertexAttrib4ubvNV(disp, fn) SET_by_offset(disp, driDispatchRemapTable[VertexAttrib4ubvNV_remap_index], fn)
+#define CALL_GenFragmentShadersATI(disp, parameters) CALL_by_offset(disp, (GLuint (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[GenFragmentShadersATI_remap_index], parameters)
+#define GET_GenFragmentShadersATI(disp) GET_by_offset(disp, driDispatchRemapTable[GenFragmentShadersATI_remap_index])
+#define SET_GenFragmentShadersATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenFragmentShadersATI_remap_index], fn)
+#define CALL_BindFragmentShaderATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[BindFragmentShaderATI_remap_index], parameters)
+#define GET_BindFragmentShaderATI(disp) GET_by_offset(disp, driDispatchRemapTable[BindFragmentShaderATI_remap_index])
+#define SET_BindFragmentShaderATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindFragmentShaderATI_remap_index], fn)
+#define CALL_DeleteFragmentShaderATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[DeleteFragmentShaderATI_remap_index], parameters)
+#define GET_DeleteFragmentShaderATI(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteFragmentShaderATI_remap_index])
+#define SET_DeleteFragmentShaderATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteFragmentShaderATI_remap_index], fn)
+#define CALL_BeginFragmentShaderATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[BeginFragmentShaderATI_remap_index], parameters)
+#define GET_BeginFragmentShaderATI(disp) GET_by_offset(disp, driDispatchRemapTable[BeginFragmentShaderATI_remap_index])
+#define SET_BeginFragmentShaderATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BeginFragmentShaderATI_remap_index], fn)
+#define CALL_EndFragmentShaderATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(void)), driDispatchRemapTable[EndFragmentShaderATI_remap_index], parameters)
+#define GET_EndFragmentShaderATI(disp) GET_by_offset(disp, driDispatchRemapTable[EndFragmentShaderATI_remap_index])
+#define SET_EndFragmentShaderATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[EndFragmentShaderATI_remap_index], fn)
+#define CALL_PassTexCoordATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLenum)), driDispatchRemapTable[PassTexCoordATI_remap_index], parameters)
+#define GET_PassTexCoordATI(disp) GET_by_offset(disp, driDispatchRemapTable[PassTexCoordATI_remap_index])
+#define SET_PassTexCoordATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[PassTexCoordATI_remap_index], fn)
+#define CALL_SampleMapATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, GLuint, GLenum)), driDispatchRemapTable[SampleMapATI_remap_index], parameters)
+#define GET_SampleMapATI(disp) GET_by_offset(disp, driDispatchRemapTable[SampleMapATI_remap_index])
+#define SET_SampleMapATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SampleMapATI_remap_index], fn)
+#define CALL_ColorFragmentOp1ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[ColorFragmentOp1ATI_remap_index], parameters)
+#define GET_ColorFragmentOp1ATI(disp) GET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp1ATI_remap_index])
+#define SET_ColorFragmentOp1ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp1ATI_remap_index], fn)
+#define CALL_ColorFragmentOp2ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[ColorFragmentOp2ATI_remap_index], parameters)
+#define GET_ColorFragmentOp2ATI(disp) GET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp2ATI_remap_index])
+#define SET_ColorFragmentOp2ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp2ATI_remap_index], fn)
+#define CALL_ColorFragmentOp3ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[ColorFragmentOp3ATI_remap_index], parameters)
+#define GET_ColorFragmentOp3ATI(disp) GET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp3ATI_remap_index])
+#define SET_ColorFragmentOp3ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[ColorFragmentOp3ATI_remap_index], fn)
+#define CALL_AlphaFragmentOp1ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[AlphaFragmentOp1ATI_remap_index], parameters)
+#define GET_AlphaFragmentOp1ATI(disp) GET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp1ATI_remap_index])
+#define SET_AlphaFragmentOp1ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp1ATI_remap_index], fn)
+#define CALL_AlphaFragmentOp2ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[AlphaFragmentOp2ATI_remap_index], parameters)
+#define GET_AlphaFragmentOp2ATI(disp) GET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp2ATI_remap_index])
+#define SET_AlphaFragmentOp2ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp2ATI_remap_index], fn)
+#define CALL_AlphaFragmentOp3ATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint)), driDispatchRemapTable[AlphaFragmentOp3ATI_remap_index], parameters)
+#define GET_AlphaFragmentOp3ATI(disp) GET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp3ATI_remap_index])
+#define SET_AlphaFragmentOp3ATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[AlphaFragmentOp3ATI_remap_index], fn)
+#define CALL_SetFragmentShaderConstantATI(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLuint, const GLfloat *)), driDispatchRemapTable[SetFragmentShaderConstantATI_remap_index], parameters)
+#define GET_SetFragmentShaderConstantATI(disp) GET_by_offset(disp, driDispatchRemapTable[SetFragmentShaderConstantATI_remap_index])
+#define SET_SetFragmentShaderConstantATI(disp, fn) SET_by_offset(disp, driDispatchRemapTable[SetFragmentShaderConstantATI_remap_index], fn)
+#define CALL_IsRenderbufferEXT(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsRenderbufferEXT_remap_index], parameters)
+#define GET_IsRenderbufferEXT(disp) GET_by_offset(disp, driDispatchRemapTable[IsRenderbufferEXT_remap_index])
+#define SET_IsRenderbufferEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsRenderbufferEXT_remap_index], fn)
+#define CALL_BindRenderbufferEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[BindRenderbufferEXT_remap_index], parameters)
+#define GET_BindRenderbufferEXT(disp) GET_by_offset(disp, driDispatchRemapTable[BindRenderbufferEXT_remap_index])
+#define SET_BindRenderbufferEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindRenderbufferEXT_remap_index], fn)
+#define CALL_DeleteRenderbuffersEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteRenderbuffersEXT_remap_index], parameters)
+#define GET_DeleteRenderbuffersEXT(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteRenderbuffersEXT_remap_index])
+#define SET_DeleteRenderbuffersEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteRenderbuffersEXT_remap_index], fn)
+#define CALL_GenRenderbuffersEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenRenderbuffersEXT_remap_index], parameters)
+#define GET_GenRenderbuffersEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GenRenderbuffersEXT_remap_index])
+#define SET_GenRenderbuffersEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenRenderbuffersEXT_remap_index], fn)
+#define CALL_RenderbufferStorageEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLsizei, GLsizei)), driDispatchRemapTable[RenderbufferStorageEXT_remap_index], parameters)
+#define GET_RenderbufferStorageEXT(disp) GET_by_offset(disp, driDispatchRemapTable[RenderbufferStorageEXT_remap_index])
+#define SET_RenderbufferStorageEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[RenderbufferStorageEXT_remap_index], fn)
+#define CALL_GetRenderbufferParameterivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint *)), driDispatchRemapTable[GetRenderbufferParameterivEXT_remap_index], parameters)
+#define GET_GetRenderbufferParameterivEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetRenderbufferParameterivEXT_remap_index])
+#define SET_GetRenderbufferParameterivEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetRenderbufferParameterivEXT_remap_index], fn)
+#define CALL_IsFramebufferEXT(disp, parameters) CALL_by_offset(disp, (GLboolean (GLAPIENTRYP)(GLuint)), driDispatchRemapTable[IsFramebufferEXT_remap_index], parameters)
+#define GET_IsFramebufferEXT(disp) GET_by_offset(disp, driDispatchRemapTable[IsFramebufferEXT_remap_index])
+#define SET_IsFramebufferEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[IsFramebufferEXT_remap_index], fn)
+#define CALL_BindFramebufferEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[BindFramebufferEXT_remap_index], parameters)
+#define GET_BindFramebufferEXT(disp) GET_by_offset(disp, driDispatchRemapTable[BindFramebufferEXT_remap_index])
+#define SET_BindFramebufferEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[BindFramebufferEXT_remap_index], fn)
+#define CALL_DeleteFramebuffersEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, const GLuint *)), driDispatchRemapTable[DeleteFramebuffersEXT_remap_index], parameters)
+#define GET_DeleteFramebuffersEXT(disp) GET_by_offset(disp, driDispatchRemapTable[DeleteFramebuffersEXT_remap_index])
+#define SET_DeleteFramebuffersEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[DeleteFramebuffersEXT_remap_index], fn)
+#define CALL_GenFramebuffersEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLsizei, GLuint *)), driDispatchRemapTable[GenFramebuffersEXT_remap_index], parameters)
+#define GET_GenFramebuffersEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GenFramebuffersEXT_remap_index])
+#define SET_GenFramebuffersEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenFramebuffersEXT_remap_index], fn)
+#define CALL_CheckFramebufferStatusEXT(disp, parameters) CALL_by_offset(disp, (GLenum (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[CheckFramebufferStatusEXT_remap_index], parameters)
+#define GET_CheckFramebufferStatusEXT(disp) GET_by_offset(disp, driDispatchRemapTable[CheckFramebufferStatusEXT_remap_index])
+#define SET_CheckFramebufferStatusEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[CheckFramebufferStatusEXT_remap_index], fn)
+#define CALL_FramebufferTexture1DEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLuint, GLint)), driDispatchRemapTable[FramebufferTexture1DEXT_remap_index], parameters)
+#define GET_FramebufferTexture1DEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FramebufferTexture1DEXT_remap_index])
+#define SET_FramebufferTexture1DEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FramebufferTexture1DEXT_remap_index], fn)
+#define CALL_FramebufferTexture2DEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLuint, GLint)), driDispatchRemapTable[FramebufferTexture2DEXT_remap_index], parameters)
+#define GET_FramebufferTexture2DEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FramebufferTexture2DEXT_remap_index])
+#define SET_FramebufferTexture2DEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FramebufferTexture2DEXT_remap_index], fn)
+#define CALL_FramebufferTexture3DEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLuint, GLint, GLint)), driDispatchRemapTable[FramebufferTexture3DEXT_remap_index], parameters)
+#define GET_FramebufferTexture3DEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FramebufferTexture3DEXT_remap_index])
+#define SET_FramebufferTexture3DEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FramebufferTexture3DEXT_remap_index], fn)
+#define CALL_FramebufferRenderbufferEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLuint)), driDispatchRemapTable[FramebufferRenderbufferEXT_remap_index], parameters)
+#define GET_FramebufferRenderbufferEXT(disp) GET_by_offset(disp, driDispatchRemapTable[FramebufferRenderbufferEXT_remap_index])
+#define SET_FramebufferRenderbufferEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[FramebufferRenderbufferEXT_remap_index], fn)
+#define CALL_GetFramebufferAttachmentParameterivEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLint *)), driDispatchRemapTable[GetFramebufferAttachmentParameterivEXT_remap_index], parameters)
+#define GET_GetFramebufferAttachmentParameterivEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GetFramebufferAttachmentParameterivEXT_remap_index])
+#define SET_GetFramebufferAttachmentParameterivEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GetFramebufferAttachmentParameterivEXT_remap_index], fn)
+#define CALL_GenerateMipmapEXT(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum)), driDispatchRemapTable[GenerateMipmapEXT_remap_index], parameters)
+#define GET_GenerateMipmapEXT(disp) GET_by_offset(disp, driDispatchRemapTable[GenerateMipmapEXT_remap_index])
+#define SET_GenerateMipmapEXT(disp, fn) SET_by_offset(disp, driDispatchRemapTable[GenerateMipmapEXT_remap_index], fn)
+#define CALL_StencilFuncSeparate(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLint, GLuint)), driDispatchRemapTable[StencilFuncSeparate_remap_index], parameters)
+#define GET_StencilFuncSeparate(disp) GET_by_offset(disp, driDispatchRemapTable[StencilFuncSeparate_remap_index])
+#define SET_StencilFuncSeparate(disp, fn) SET_by_offset(disp, driDispatchRemapTable[StencilFuncSeparate_remap_index], fn)
+#define CALL_StencilOpSeparate(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLenum, GLenum, GLenum)), driDispatchRemapTable[StencilOpSeparate_remap_index], parameters)
+#define GET_StencilOpSeparate(disp) GET_by_offset(disp, driDispatchRemapTable[StencilOpSeparate_remap_index])
+#define SET_StencilOpSeparate(disp, fn) SET_by_offset(disp, driDispatchRemapTable[StencilOpSeparate_remap_index], fn)
+#define CALL_StencilMaskSeparate(disp, parameters) CALL_by_offset(disp, (void (GLAPIENTRYP)(GLenum, GLuint)), driDispatchRemapTable[StencilMaskSeparate_remap_index], parameters)
+#define GET_StencilMaskSeparate(disp) GET_by_offset(disp, driDispatchRemapTable[StencilMaskSeparate_remap_index])
+#define SET_StencilMaskSeparate(disp, fn) SET_by_offset(disp, driDispatchRemapTable[StencilMaskSeparate_remap_index], fn)
+
+#endif /* !defined(IN_DRI_DRIVER) */
+
+#endif /* !defined( _DISPATCH_H_ ) */
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/extension_helper.py b/nx-X11/extras/Mesa/src/mesa/glapi/extension_helper.py
new file mode 100644
index 000000000..a2a16a8b3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/extension_helper.py
@@ -0,0 +1,316 @@
+#!/usr/bin/env python
+
+# (C) Copyright IBM Corporation 2005
+# 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
+# IBM 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:
+# Ian Romanick <idr@us.ibm.com>
+
+import gl_XML
+import license
+import sys, getopt, string
+
+vtxfmt = [
+ "ArrayElement", \
+ "Color3f", \
+ "Color3fv", \
+ "Color4f", \
+ "Color4fv", \
+ "EdgeFlag", \
+ "EdgeFlagv", \
+ "EvalCoord1f", \
+ "EvalCoord1fv", \
+ "EvalCoord2f", \
+ "EvalCoord2fv", \
+ "EvalPoint1", \
+ "EvalPoint2", \
+ "FogCoordfEXT", \
+ "FogCoordfvEXT", \
+ "Indexf", \
+ "Indexfv", \
+ "Materialfv", \
+ "MultiTexCoord1fARB", \
+ "MultiTexCoord1fvARB", \
+ "MultiTexCoord2fARB", \
+ "MultiTexCoord2fvARB", \
+ "MultiTexCoord3fARB", \
+ "MultiTexCoord3fvARB", \
+ "MultiTexCoord4fARB", \
+ "MultiTexCoord4fvARB", \
+ "Normal3f", \
+ "Normal3fv", \
+ "SecondaryColor3fEXT", \
+ "SecondaryColor3fvEXT", \
+ "TexCoord1f", \
+ "TexCoord1fv", \
+ "TexCoord2f", \
+ "TexCoord2fv", \
+ "TexCoord3f", \
+ "TexCoord3fv", \
+ "TexCoord4f", \
+ "TexCoord4fv", \
+ "Vertex2f", \
+ "Vertex2fv", \
+ "Vertex3f", \
+ "Vertex3fv", \
+ "Vertex4f", \
+ "Vertex4fv", \
+ "CallList", \
+ "CallLists", \
+ "Begin", \
+ "End", \
+ "VertexAttrib1fNV", \
+ "VertexAttrib1fvNV", \
+ "VertexAttrib2fNV", \
+ "VertexAttrib2fvNV", \
+ "VertexAttrib3fNV", \
+ "VertexAttrib3fvNV", \
+ "VertexAttrib4fNV", \
+ "VertexAttrib4fvNV", \
+ "VertexAttrib1fARB", \
+ "VertexAttrib1fvARB", \
+ "VertexAttrib2fARB", \
+ "VertexAttrib2fvARB", \
+ "VertexAttrib3fARB", \
+ "VertexAttrib3fvARB", \
+ "VertexAttrib4fARB", \
+ "VertexAttrib4fvARB", \
+ "Rectf", \
+ "DrawArrays", \
+ "DrawElements", \
+ "DrawRangeElements", \
+ "EvalMesh1", \
+ "EvalMesh2", \
+]
+
+def all_entrypoints_in_abi(f, abi, api):
+ for n in f.entry_points:
+ [category, num] = api.get_category_for_name( n )
+ if category not in abi:
+ return 0
+
+ return 1
+
+
+def any_entrypoints_in_abi(f, abi, api):
+ for n in f.entry_points:
+ [category, num] = api.get_category_for_name( n )
+ if category in abi:
+ return 1
+
+ return 0
+
+
+def condition_for_function(f, abi, all_not_in_ABI):
+ """Create a C-preprocessor condition for the function.
+
+ There are two modes of operation. If all_not_in_ABI is set, a
+ condition is only created is all of the entry-point names for f are
+ not in the selected ABI. If all_not_in_ABI is not set, a condition
+ is created if any entryp-point name is not in the selected ABI.
+ """
+
+ condition = []
+ for n in f.entry_points:
+ [category, num] = api.get_category_for_name( n )
+ if category not in abi:
+ condition.append( 'defined(need_%s)' % (gl_XML.real_category_name( category )) )
+ elif all_not_in_ABI:
+ return []
+
+ return condition
+
+
+class PrintGlExtensionGlue(gl_XML.gl_print_base):
+ def __init__(self):
+ gl_XML.gl_print_base.__init__(self)
+
+ self.name = "extension_helper.py (from Mesa)"
+ self.license = license.bsd_license_template % ("(C) Copyright IBM Corporation 2005", "IBM")
+ return
+
+
+ def printRealHeader(self):
+ print '#include "utils.h"'
+ print '#include "dispatch.h"'
+ print ''
+ return
+
+
+ def printBody(self, api):
+ abi = [ "1.0", "1.1", "1.2", "GL_ARB_multitexture" ]
+
+ category_list = {}
+
+ print '#ifndef NULL'
+ print '# define NULL 0'
+ print '#endif'
+ print ''
+
+ for f in api.functionIterateAll():
+ condition = condition_for_function(f, abi, 0)
+ if len(condition):
+ print '#if %s' % (string.join(condition, " || "))
+ print 'static const char %s_names[] = ' % (f.name)
+
+ parameter_signature = ''
+ for p in f.parameterIterator():
+ # FIXME: This is a *really* ugly hack. :(
+
+ tn = p.type_expr.get_base_type_node()
+ if p.is_pointer():
+ parameter_signature += 'p'
+ elif tn.integer:
+ parameter_signature += 'i'
+ elif tn.size == 4:
+ parameter_signature += 'f'
+ else:
+ parameter_signature += 'd'
+
+ print ' "%s\\0" /* Parameter signature */' % (parameter_signature)
+
+ for n in f.entry_points:
+ print ' "gl%s\\0"' % (n)
+
+ [category, num] = api.get_category_for_name( n )
+ if category not in abi:
+ c = gl_XML.real_category_name(category)
+ if not category_list.has_key(c):
+ category_list[ c ] = []
+
+ category_list[ c ].append( f )
+
+ print ' "";'
+ print '#endif'
+ print ''
+
+ keys = category_list.keys()
+ keys.sort()
+
+ for category in keys:
+ print '#if defined(need_%s)' % (category)
+ print 'static const struct dri_extension_function %s_functions[] = {' % (category)
+
+ for f in category_list[ category ]:
+ if any_entrypoints_in_abi(f, abi, api):
+ index_name = "-1"
+ else:
+ index_name = "%s_remap_index" % (f.name)
+
+ print ' { %s_names, %s, %d },' % (f.name, index_name, f.offset)
+
+
+ print ' { NULL, 0, 0 }'
+ print '};'
+ print '#endif'
+ print ''
+
+ return
+
+
+class PrintInitDispatch(gl_XML.gl_print_base):
+ def __init__(self):
+ gl_XML.gl_print_base.__init__(self)
+
+ self.name = "extension_helper.py (from Mesa)"
+ self.license = license.bsd_license_template % ("(C) Copyright IBM Corporation 2005", "IBM")
+ return
+
+
+ def do_function_body(self, api, abi, vtxfmt_only):
+ last_condition_string = None
+ for f in api.functionIterateByOffset():
+ if (f.name in vtxfmt) and not vtxfmt_only:
+ continue
+
+ if (f.name not in vtxfmt) and vtxfmt_only:
+ continue
+
+ condition = condition_for_function(f, abi, 1)
+ condition_string = string.join(condition, " || ")
+
+ if condition_string != last_condition_string:
+ if last_condition_string:
+ print '#endif /* %s */' % (last_condition_string)
+
+ if condition_string:
+ print '#if %s' % (condition_string)
+
+ if vtxfmt_only:
+ print ' disp->%s = vfmt->%s;' % (f.name, f.name)
+ else:
+ print ' disp->%s = _mesa_%s;' % (f.name, f.name)
+
+ last_condition_string = condition_string
+
+ if last_condition_string:
+ print '#endif /* %s */' % (last_condition_string)
+
+
+
+ def printBody(self, api):
+ abi = [ "1.0", "1.1", "1.2", "GL_ARB_multitexture" ]
+
+ print 'void driver_init_exec_table(struct _glapi_table *disp)'
+ print '{'
+ self.do_function_body(api, abi, 0)
+ print '}'
+ print ''
+ print 'void driver_install_vtxfmt(struct _glapi_table *disp, const GLvertexformat *vfmt)'
+ print '{'
+ self.do_function_body(api, abi, 1)
+ print '}'
+
+ return
+
+
+def show_usage():
+ print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]
+ print " -m output_mode Output mode can be one of 'extensions' or 'exec_init'."
+ sys.exit(1)
+
+if __name__ == '__main__':
+ file_name = "gl_API.xml"
+
+ try:
+ (args, trail) = getopt.getopt(sys.argv[1:], "f:m:")
+ except Exception,e:
+ show_usage()
+
+ mode = "extensions"
+ for (arg,val) in args:
+ if arg == "-f":
+ file_name = val
+ if arg == '-m':
+ mode = val
+
+
+ api = gl_XML.parse_GL_API( file_name )
+
+ if mode == "extensions":
+ printer = PrintGlExtensionGlue()
+ elif mode == "exec_init":
+ printer = PrintInitDispatch()
+ else:
+ show_usage()
+
+ printer.Print( api )
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/glX_XML.py b/nx-X11/extras/Mesa/src/mesa/glapi/glX_XML.py
new file mode 100644
index 000000000..7cc9d8d66
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/glX_XML.py
@@ -0,0 +1,531 @@
+#!/usr/bin/env python
+
+# (C) Copyright IBM Corporation 2004, 2005
+# 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
+# IBM 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:
+# Ian Romanick <idr@us.ibm.com>
+
+import gl_XML
+import license
+import sys, getopt, string
+
+
+class glx_item_factory(gl_XML.gl_item_factory):
+ """Factory to create GLX protocol oriented objects derived from gl_item."""
+
+ def create_item(self, name, element, context):
+ if name == "function":
+ return glx_function(element, context)
+ elif name == "enum":
+ return glx_enum(element, context)
+ elif name == "api":
+ return glx_api(self)
+ else:
+ return gl_XML.gl_item_factory.create_item(self, name, element, context)
+
+
+class glx_enum(gl_XML.gl_enum):
+ def __init__(self, element, context):
+ gl_XML.gl_enum.__init__(self, element, context)
+
+ self.functions = {}
+
+ child = element.children
+ while child:
+ if child.type == "element" and child.name == "size":
+ n = child.nsProp( "name", None )
+ c = child.nsProp( "count", None )
+ m = child.nsProp( "mode", None )
+
+ if not c:
+ c = self.default_count
+ else:
+ c = int(c)
+
+ if m == "get":
+ mode = 0
+ else:
+ mode = 1
+
+ if not self.functions.has_key(n):
+ self.functions[ n ] = [c, mode]
+
+ child = child.next
+
+ return
+
+
+class glx_function(gl_XML.gl_function):
+ def __init__(self, element, context):
+ self.glx_rop = 0
+ self.glx_sop = 0
+ self.glx_vendorpriv = 0
+
+ # If this is set to true, it means that GLdouble parameters should be
+ # written to the GLX protocol packet in the order they appear in the
+ # prototype. This is different from the "classic" ordering. In the
+ # classic ordering GLdoubles are written to the protocol packet first,
+ # followed by non-doubles. NV_vertex_program was the first extension
+ # to break with this tradition.
+
+ self.glx_doubles_in_order = 0
+
+ self.vectorequiv = None
+ self.output = None
+ self.can_be_large = 0
+ self.reply_always_array = 0
+ self.dimensions_in_reply = 0
+ self.img_reset = None
+
+ self.server_handcode = 0
+ self.client_handcode = 0
+ self.ignore = 0
+
+ self.count_parameter_list = []
+ self.counter_list = []
+ self.parameters_by_name = {}
+ self.offsets_calculated = 0
+
+ gl_XML.gl_function.__init__(self, element, context)
+ return
+
+
+ def process_element(self, element):
+ gl_XML.gl_function.process_element(self, element)
+
+ self.vectorequiv = element.nsProp( "vectorequiv", None )
+
+
+ if element.nsProp( "name", None ) == self.name:
+ for param in self.parameters:
+ self.parameters_by_name[ param.name ] = param
+
+ if len(param.count_parameter_list):
+ self.count_parameter_list.extend( param.count_parameter_list )
+
+ if param.counter and param.counter not in self.counter_list:
+ self.counter_list.append(param.counter)
+
+
+ child = element.children
+ while child:
+ if child.type == "element":
+ if child.name == "glx":
+ rop = child.nsProp( 'rop', None )
+ sop = child.nsProp( 'sop', None )
+ vop = child.nsProp( 'vendorpriv', None )
+
+ if rop:
+ self.glx_rop = int(rop)
+ else:
+ self.glx_rop = 0
+
+ if sop:
+ self.glx_sop = int(sop)
+ else:
+ self.glx_sop = 0
+
+ if vop:
+ self.glx_vendorpriv = int(vop)
+ else:
+ self.glx_vendorpriv = 0
+
+ self.img_reset = child.nsProp( 'img_reset', None )
+
+ # The 'handcode' attribute can be one of 'true',
+ # 'false', 'client', or 'server'.
+
+ handcode = child.nsProp( 'handcode', None )
+ if handcode == "false":
+ self.server_handcode = 0
+ self.client_handcode = 0
+ elif handcode == "true":
+ self.server_handcode = 1
+ self.client_handcode = 1
+ elif handcode == "client":
+ self.server_handcode = 0
+ self.client_handcode = 1
+ elif handcode == "server":
+ self.server_handcode = 1
+ self.client_handcode = 0
+ else:
+ raise RuntimeError('Invalid handcode mode "%s" in function "%s".' % (handcode, self.name))
+
+ self.ignore = gl_XML.is_attr_true( child, 'ignore' )
+ self.can_be_large = gl_XML.is_attr_true( child, 'large' )
+ self.glx_doubles_in_order = gl_XML.is_attr_true( child, 'doubles_in_order' )
+ self.reply_always_array = gl_XML.is_attr_true( child, 'always_array' )
+ self.dimensions_in_reply = gl_XML.is_attr_true( child, 'dimensions_in_reply' )
+
+ child = child.next
+
+
+ # Do some validation of the GLX protocol information. As
+ # new tests are discovered, they should be added here.
+
+ for param in self.parameters:
+ if param.is_output and self.glx_rop != 0:
+ raise RuntimeError("Render / RenderLarge commands cannot have outputs (%s)." % (self.name))
+
+ return
+
+
+ def has_variable_size_request(self):
+ """Determine if the GLX request packet is variable sized.
+
+ The GLX request packet is variable sized in several common
+ situations.
+
+ 1. The function has a non-output parameter that is counted
+ by another parameter (e.g., the 'textures' parameter of
+ glDeleteTextures).
+
+ 2. The function has a non-output parameter whose count is
+ determined by another parameter that is an enum (e.g., the
+ 'params' parameter of glLightfv).
+
+ 3. The function has a non-output parameter that is an
+ image.
+
+ 4. The function must be hand-coded on the server.
+ """
+
+ if self.glx_rop == 0:
+ return 0
+
+ if self.server_handcode or self.images:
+ return 1
+
+ for param in self.parameters:
+ if not param.is_output:
+ if param.counter or len(param.count_parameter_list):
+ return 1
+
+ return 0
+
+
+ def variable_length_parameter(self):
+ for param in self.parameters:
+ if not param.is_output:
+ if param.counter or len(param.count_parameter_list):
+ return param
+
+ return None
+
+
+ def calculate_offsets(self):
+ if not self.offsets_calculated:
+ # Calculate the offset of the first function parameter
+ # in the GLX command packet. This byte offset is
+ # measured from the end of the Render / RenderLarge
+ # header. The offset for all non-pixel commends is
+ # zero. The offset for pixel commands depends on the
+ # number of dimensions of the pixel data.
+
+ if len(self.images) and not self.images[0].is_output:
+ [dim, junk, junk, junk, junk] = self.images[0].get_dimensions()
+
+ # The base size is the size of the pixel pack info
+ # header used by images with the specified number
+ # of dimensions.
+
+ if dim <= 2:
+ offset = 20
+ elif dim <= 4:
+ offset = 36
+ else:
+ raise RuntimeError('Invalid number of dimensions %u for parameter "%s" in function "%s".' % (dim, self.image.name, self.name))
+ else:
+ offset = 0
+
+ for param in self.parameterIterateGlxSend():
+ if param.img_null_flag:
+ offset += 4
+
+ if param.name != self.img_reset:
+ param.offset = offset
+ if not param.is_variable_length():
+ offset += param.size()
+
+ if self.pad_after( param ):
+ offset += 4
+
+
+ self.offsets_calculated = 1
+ return
+
+
+ def offset_of(self, param_name):
+ self.calculate_offsets()
+ return self.parameters_by_name[ param_name ].offset
+
+
+ def parameterIterateGlxSend(self, include_variable_parameters = 1):
+ """Create an iterator for parameters in GLX request order."""
+
+ # The parameter lists are usually quite short, so it's easier
+ # (i.e., less code) to just generate a new list with the
+ # required elements than it is to create a new iterator class.
+
+ temp = [ [], [], [] ]
+ for param in self.parameters:
+ if param.is_output: continue
+
+ if param.is_variable_length():
+ temp[2].append( param )
+ elif not self.glx_doubles_in_order and param.is_64_bit():
+ temp[0].append( param )
+ else:
+ temp[1].append( param )
+
+ parameters = temp[0]
+ parameters.extend( temp[1] )
+ if include_variable_parameters:
+ parameters.extend( temp[2] )
+ return parameters.__iter__()
+
+
+ def parameterIterateCounters(self):
+ temp = []
+ for name in self.counter_list:
+ temp.append( self.parameters_by_name[ name ] )
+
+ return temp.__iter__()
+
+
+ def parameterIterateOutputs(self):
+ temp = []
+ for p in self.parameters:
+ if p.is_output:
+ temp.append( p )
+
+ return temp
+
+
+ def command_fixed_length(self):
+ """Return the length, in bytes as an integer, of the
+ fixed-size portion of the command."""
+
+ if len(self.parameters) == 0:
+ return 0
+
+ self.calculate_offsets()
+
+ size = 0
+ for param in self.parameterIterateGlxSend(0):
+ if param.name != self.img_reset:
+ if size == 0:
+ size = param.offset + param.size()
+ else:
+ size += param.size()
+
+ if self.pad_after( param ):
+ size += 4
+
+ for param in self.images:
+ if param.img_null_flag or param.is_output:
+ size += 4
+
+ return size
+
+
+ def command_variable_length(self):
+ """Return the length, as a string, of the variable-sized
+ portion of the command."""
+
+ size_string = ""
+ for p in self.parameterIterateGlxSend():
+ if (not p.is_output) and (p.is_variable_length() or p.is_image()):
+ # FIXME Replace the 1 in the size_string call
+ # FIXME w/0 to eliminate some un-needed parnes
+ # FIXME This would already be done, but it
+ # FIXME adds some extra diffs to the generated
+ # FIXME code.
+
+ size_string = size_string + " + __GLX_PAD(%s)" % (p.size_string(1))
+
+ return size_string
+
+
+ def command_length(self):
+ size = self.command_fixed_length()
+
+ if self.glx_rop != 0:
+ size += 4
+
+ size = ((size + 3) & ~3)
+ return "%u%s" % (size, self.command_variable_length())
+
+
+ def opcode_real_value(self):
+ """Get the true numeric value of the GLX opcode
+
+ Behaves similarly to opcode_value, except for
+ X_GLXVendorPrivate and X_GLXVendorPrivateWithReply commands.
+ In these cases the value for the GLX opcode field (i.e.,
+ 16 for X_GLXVendorPrivate or 17 for
+ X_GLXVendorPrivateWithReply) is returned. For other 'single'
+ commands, the opcode for the command (e.g., 101 for
+ X_GLsop_NewList) is returned."""
+
+ if self.glx_vendorpriv != 0:
+ if self.needs_reply():
+ return 17
+ else:
+ return 16
+ else:
+ return self.opcode_value()
+
+
+ def opcode_value(self):
+ """Get the unique protocol opcode for the glXFunction"""
+
+ if (self.glx_rop == 0) and self.vectorequiv:
+ equiv = self.context.functions_by_name[ self.vectorequiv ]
+ self.glx_rop = equiv.glx_rop
+
+
+ if self.glx_rop != 0:
+ return self.glx_rop
+ elif self.glx_sop != 0:
+ return self.glx_sop
+ elif self.glx_vendorpriv != 0:
+ return self.glx_vendorpriv
+ else:
+ return -1
+
+
+ def opcode_rop_basename(self):
+ """Return either the name to be used for GLX protocol enum.
+
+ Returns either the name of the function or the name of the
+ name of the equivalent vector (e.g., glVertex3fv for
+ glVertex3f) function."""
+
+ if self.vectorequiv == None:
+ return self.name
+ else:
+ return self.vectorequiv
+
+
+ def opcode_name(self):
+ """Get the unique protocol enum name for the glXFunction"""
+
+ if (self.glx_rop == 0) and self.vectorequiv:
+ equiv = self.context.functions_by_name[ self.vectorequiv ]
+ self.glx_rop = equiv.glx_rop
+ self.glx_doubles_in_order = equiv.glx_doubles_in_order
+
+
+ if self.glx_rop != 0:
+ return "X_GLrop_%s" % (self.opcode_rop_basename())
+ elif self.glx_sop != 0:
+ return "X_GLsop_%s" % (self.name)
+ elif self.glx_vendorpriv != 0:
+ return "X_GLvop_%s" % (self.name)
+ else:
+ raise RuntimeError('Function "%s" has no opcode.' % (self.name))
+
+
+ def opcode_real_name(self):
+ """Get the true protocol enum name for the GLX opcode
+
+ Behaves similarly to opcode_name, except for
+ X_GLXVendorPrivate and X_GLXVendorPrivateWithReply commands.
+ In these cases the string 'X_GLXVendorPrivate' or
+ 'X_GLXVendorPrivateWithReply' is returned. For other
+ single or render commands 'X_GLsop' or 'X_GLrop' plus the
+ name of the function returned."""
+
+ if self.glx_vendorpriv != 0:
+ if self.needs_reply():
+ return "X_GLXVendorPrivateWithReply"
+ else:
+ return "X_GLXVendorPrivate"
+ else:
+ return self.opcode_name()
+
+
+ def needs_reply(self):
+ try:
+ x = self._needs_reply
+ except Exception, e:
+ x = 0
+ if self.return_type != 'void':
+ x = 1
+
+ for param in self.parameters:
+ if param.is_output:
+ x = 1
+ break
+
+ self._needs_reply = x
+
+ return x
+
+
+ def pad_after(self, p):
+ """Returns the name of the field inserted after the
+ specified field to pad out the command header."""
+
+ for image in self.images:
+ if image.img_pad_dimensions:
+ if not image.height:
+ if p.name == image.width:
+ return "height"
+ elif p.name == image.img_xoff:
+ return "yoffset"
+ elif not image.extent:
+ if p.name == image.depth:
+ # Should this be "size4d"?
+ return "extent"
+ elif p.name == image.img_zoff:
+ return "woffset"
+
+ return None
+
+
+class glx_function_iterator:
+ """Class to iterate over a list of glXFunctions"""
+
+ def __init__(self, context):
+ self.iterator = context.functionIterateByOffset()
+ return
+
+
+ def __iter__(self):
+ return self
+
+
+ def next(self):
+ f = self.iterator.next()
+ if f.ignore or not (f.glx_rop or f.glx_sop or f.glx_vendorpriv or f.vectorequiv or f.client_handcode):
+ return self.next()
+ else:
+ return f
+
+
+class glx_api(gl_XML.gl_api):
+ def functionIterateGlx(self):
+ return glx_function_iterator(self)
+
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/glX_doc.py b/nx-X11/extras/Mesa/src/mesa/glapi/glX_doc.py
new file mode 100644
index 000000000..e9fbbe6f1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/glX_doc.py
@@ -0,0 +1,280 @@
+#!/usr/bin/env python
+
+# (C) Copyright IBM Corporation 2004, 2005
+# 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
+# IBM 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:
+# Ian Romanick <idr@us.ibm.com>
+
+import gl_XML, glX_XML, glX_proto_common, license
+import sys, getopt
+
+
+class glx_doc_item_factory(glX_proto_common.glx_proto_item_factory):
+ """Factory to create GLX protocol documentation oriented objects derived from glItem."""
+
+ def create_item(self, name, element, context):
+ if name == "parameter":
+ return glx_doc_parameter(element, context)
+ else:
+ return glX_proto_common.glx_proto_item_factory.create_item(self, name, element, context)
+
+
+class glx_doc_parameter(gl_XML.gl_parameter):
+ def packet_type(self, type_dict):
+ """Get the type string for the packet header
+
+ GLX protocol documentation uses type names like CARD32,
+ FLOAT64, LISTofCARD8, and ENUM. This function converts the
+ type of the parameter to one of these names."""
+
+ list_of = ""
+ if self.is_array():
+ list_of = "LISTof"
+
+ t_name = self.get_base_type_string()
+ if not type_dict.has_key( t_name ):
+ type_name = "CARD8"
+ else:
+ type_name = type_dict[ t_name ]
+
+ return "%s%s" % (list_of, type_name)
+
+
+ def packet_size(self):
+ p = None
+ s = self.size()
+ if s == 0:
+ a_prod = "n"
+ b_prod = self.p_type.size
+
+ if not self.count_parameter_list and self.counter:
+ a_prod = self.counter
+ elif self.count_parameter_list and not self.counter or self.is_output:
+ pass
+ elif self.count_parameter_list and self.counter:
+ b_prod = self.counter
+ else:
+ raise RuntimeError("Parameter '%s' to function '%s' has size 0." % (self.name, self.context.name))
+
+ ss = "%s*%s" % (a_prod, b_prod)
+
+ return [ss, p]
+ else:
+ if s % 4 != 0:
+ p = "p"
+
+ return [str(s), p]
+
+class PrintGlxProtoText(gl_XML.gl_print_base):
+ def __init__(self):
+ gl_XML.gl_print_base.__init__(self)
+ self.license = ""
+
+
+ def printHeader(self):
+ return
+
+
+ def body_size(self, f):
+ # At some point, refactor this function and
+ # glXFunction::command_payload_length.
+
+ size = 0;
+ size_str = ""
+ pad_str = ""
+ plus = ""
+ for p in f.parameterIterateGlxSend():
+ [s, pad] = p.packet_size()
+ try:
+ size += int(s)
+ except Exception,e:
+ size_str += "%s%s" % (plus, s)
+ plus = "+"
+
+ if pad != None:
+ pad_str = pad
+
+ return [size, size_str, pad_str]
+
+
+ def print_render_header(self, f):
+ [size, size_str, pad_str] = self.body_size(f)
+ size += 4;
+
+ if size_str == "":
+ s = "%u" % ((size + 3) & ~3)
+ elif pad_str != "":
+ s = "%u+%s+%s" % (size, size_str, pad_str)
+ else:
+ s = "%u+%s" % (size, size_str)
+
+ print ' 2 %-15s rendering command length' % (s)
+ print ' 2 %-4u rendering command opcode' % (f.glx_rop)
+ return
+
+
+ def print_single_header(self, f):
+ [size, size_str, pad_str] = self.body_size(f)
+ size = ((size + 3) / 4) + 2;
+
+ if f.glx_vendorpriv != 0:
+ size += 1
+
+ print ' 1 CARD8 opcode (X assigned)'
+ print ' 1 %-4u GLX opcode (%s)' % (f.opcode_real_value(), f.opcode_real_name())
+
+ if size_str == "":
+ s = "%u" % (size)
+ elif pad_str != "":
+ s = "%u+((%s+%s)/4)" % (size, size_str, pad_str)
+ else:
+ s = "%u+((%s)/4)" % (size, size_str)
+
+ print ' 2 %-15s request length' % (s)
+
+ if f.glx_vendorpriv != 0:
+ print ' 4 %-4u vendor specific opcode' % (f.opcode_value())
+
+ print ' 4 GLX_CONTEXT_TAG context tag'
+
+ return
+
+
+ def print_reply(self, f):
+ print ' =>'
+ print ' 1 1 reply'
+ print ' 1 unused'
+ print ' 2 CARD16 sequence number'
+
+ if f.output == None:
+ print ' 4 0 reply length'
+ elif f.reply_always_array:
+ print ' 4 m reply length'
+ else:
+ print ' 4 m reply length, m = (n == 1 ? 0 : n)'
+
+
+ output = None
+ for x in f.parameterIterateOutputs():
+ output = x
+ break
+
+
+ unused = 24
+ if f.return_type != 'void':
+ print ' 4 %-15s return value' % (f.return_type)
+ unused -= 4
+ elif output != None:
+ print ' 4 unused'
+ unused -= 4
+
+ if output != None:
+ print ' 4 CARD32 n'
+ unused -= 4
+
+ if output != None:
+ if not f.reply_always_array:
+ print ''
+ print ' if (n = 1) this follows:'
+ print ''
+ print ' 4 CARD32 %s' % (output.name)
+ print ' %-2u unused' % (unused - 4)
+ print ''
+ print ' otherwise this follows:'
+ print ''
+
+ print ' %-2u unused' % (unused)
+
+ [s, pad] = output.packet_size()
+ print ' %-8s %-15s %s' % (s, output.packet_type( self.type_map ), output.name)
+ if pad != None:
+ try:
+ bytes = int(s)
+ bytes = 4 - (bytes & 3)
+ print ' %-8u %-15s unused' % (bytes, "")
+ except Exception,e:
+ print ' %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s)
+ else:
+ print ' %-2u unused' % (unused)
+
+
+ def print_body(self, f):
+ for p in f.parameterIterateGlxSend():
+ [s, pad] = p.packet_size()
+ print ' %-8s %-15s %s' % (s, p.packet_type( self.type_map ), p.name)
+ if pad != None:
+ try:
+ bytes = int(s)
+ bytes = 4 - (bytes & 3)
+ print ' %-8u %-15s unused' % (bytes, "")
+ except Exception,e:
+ print ' %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s)
+
+ def printBody(self, api):
+ self.type_map = {}
+ for t in api.typeIterate():
+ self.type_map[ "GL" + t.name ] = t.glx_name
+
+
+ # At some point this should be expanded to support pixel
+ # functions, but I'm not going to lose any sleep over it now.
+
+ for f in api.functionIterateByOffset():
+ if f.client_handcode or f.server_handcode or f.vectorequiv or len(f.get_images()):
+ continue
+
+
+ if f.glx_rop:
+ print ' %s' % (f.name)
+ self.print_render_header(f)
+ elif f.glx_sop or f.glx_vendorpriv:
+ print ' %s' % (f.name)
+ self.print_single_header(f)
+ else:
+ continue
+
+ self.print_body(f)
+
+ if f.needs_reply():
+ self.print_reply(f)
+
+ print ''
+ return
+
+
+if __name__ == '__main__':
+ file_name = "gl_API.xml"
+
+ try:
+ (args, trail) = getopt.getopt(sys.argv[1:], "f:")
+ except Exception,e:
+ show_usage()
+
+ for (arg,val) in args:
+ if arg == "-f":
+ file_name = val
+
+ api = gl_XML.parse_GL_API( file_name, glx_doc_item_factory() )
+
+ printer = PrintGlxProtoText()
+ printer.Print( api )
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/glX_proto_common.py b/nx-X11/extras/Mesa/src/mesa/glapi/glX_proto_common.py
new file mode 100644
index 000000000..744896357
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/glX_proto_common.py
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+
+# (C) Copyright IBM Corporation 2004, 2005
+# 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
+# IBM 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:
+# Ian Romanick <idr@us.ibm.com>
+
+import gl_XML, glX_XML
+import string
+
+
+class glx_proto_item_factory(glX_XML.glx_item_factory):
+ """Factory to create GLX protocol oriented objects derived from gl_item."""
+
+ def create_item(self, name, element, context):
+ if name == "type":
+ return glx_proto_type(element, context)
+ else:
+ return glX_XML.glx_item_factory.create_item(self, name, element, context)
+
+
+class glx_proto_type(gl_XML.gl_type):
+ def __init__(self, element, context):
+ gl_XML.gl_type.__init__(self, element, context)
+
+ self.glx_name = element.nsProp( "glx_name", None )
+ return
+
+
+class glx_print_proto(gl_XML.gl_print_base):
+ def size_call(self, func):
+ """Create C code to calculate 'compsize'.
+
+ Creates code to calculate 'compsize'. If the function does
+ not need 'compsize' to be calculated, None will be
+ returned."""
+
+ compsize = None
+
+ for param in func.parameterIterator():
+ if not param.is_output:
+ if param.is_image():
+ [dim, w, h, d, junk] = param.get_dimensions()
+
+ compsize = '__glImageSize(%s, %s, %s, %s, %s, %s)' % (w, h, d, param.img_format, param.img_type, param.img_target)
+ if not param.img_send_null:
+ compsize = '(%s != NULL) ? %s : 0' % (param.name, compsize)
+
+ return compsize
+
+ elif len(param.count_parameter_list):
+ parameters = string.join( param.count_parameter_list, "," )
+ compsize = "__gl%s_size(%s)" % (func.name, parameters)
+
+ return compsize
+
+ return None
+
+
+ def emit_packet_size_calculation(self, f, bias):
+ # compsize is only used in the command size calculation if
+ # the function has a non-output parameter that has a non-empty
+ # counter_parameter_list.
+
+ compsize = self.size_call(f)
+ if compsize:
+ print ' const GLuint compsize = %s;' % (compsize)
+
+ if bias:
+ print ' const GLuint cmdlen = %s - %u;' % (f.command_length(), bias)
+ else:
+ print ' const GLuint cmdlen = %s;' % (f.command_length())
+
+ #print ''
+ return compsize
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/glX_proto_send.py b/nx-X11/extras/Mesa/src/mesa/glapi/glX_proto_send.py
new file mode 100644
index 000000000..53a979591
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/glX_proto_send.py
@@ -0,0 +1,1044 @@
+#!/usr/bin/env python
+
+# (C) Copyright IBM Corporation 2004, 2005
+# 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
+# IBM 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:
+# Ian Romanick <idr@us.ibm.com>
+
+import gl_XML, glX_XML, glX_proto_common, license
+import sys, getopt, copy, string
+
+def hash_pixel_function(func):
+ """Generate a 'unique' key for a pixel function. The key is based on
+ the parameters written in the command packet. This includes any
+ padding that might be added for the original function and the 'NULL
+ image' flag."""
+
+
+ h = ""
+ hash_pre = ""
+ hash_suf = ""
+ for param in func.parameterIterateGlxSend():
+ if param.is_image():
+ [dim, junk, junk, junk, junk] = param.get_dimensions()
+
+ d = (dim + 1) & ~1
+ hash_pre = "%uD%uD_" % (d - 1, d)
+
+ if param.img_null_flag:
+ hash_suf = "_NF"
+
+ h += "%u" % (param.size())
+
+ if func.pad_after(param):
+ h += "4"
+
+
+ n = func.name.replace("%uD" % (dim), "")
+ n = "__glx_%s_%uD%uD" % (n, d - 1, d)
+
+ h = hash_pre + h + hash_suf
+ return [h, n]
+
+
+class glx_pixel_function_stub(glX_XML.glx_function):
+ """Dummy class used to generate pixel "utility" functions that are
+ shared by multiple dimension image functions. For example, these
+ objects are used to generate shared functions used to send GLX
+ protocol for TexImage1D and TexImage2D, TexSubImage1D and
+ TexSubImage2D, etc."""
+
+ def __init__(self, func, name):
+ # The parameters to the utility function are the same as the
+ # parameters to the real function except for the added "pad"
+ # parameters.
+
+ self.name = name
+ self.images = []
+ self.parameters = []
+ self.parameters_by_name = {}
+ for _p in func.parameterIterator():
+ p = copy.copy(_p)
+ self.parameters.append(p)
+ self.parameters_by_name[ p.name ] = p
+
+
+ if p.is_image():
+ self.images.append(p)
+ p.height = "height"
+
+ if p.img_yoff == None:
+ p.img_yoff = "yoffset"
+
+ if p.depth:
+ if p.extent == None:
+ p.extent = "extent"
+
+ if p.img_woff == None:
+ p.img_woff = "woffset"
+
+
+ pad_name = func.pad_after(p)
+ if pad_name:
+ pad = copy.copy(p)
+ pad.name = pad_name
+ self.parameters.append(pad)
+ self.parameters_by_name[ pad.name ] = pad
+
+
+ self.return_type = func.return_type
+
+ self.glx_rop = ~0
+ self.glx_sop = 0
+ self.glx_vendorpriv = 0
+
+ self.glx_doubles_in_order = func.glx_doubles_in_order
+
+ self.vectorequiv = None
+ self.output = None
+ self.can_be_large = func.can_be_large
+ self.reply_always_array = func.reply_always_array
+ self.dimensions_in_reply = func.dimensions_in_reply
+ self.img_reset = None
+
+ self.server_handcode = 0
+ self.client_handcode = 0
+ self.ignore = 0
+
+ self.count_parameter_list = func.count_parameter_list
+ self.counter_list = func.counter_list
+ self.offsets_calculated = 0
+ return
+
+
+class PrintGlxProtoStubs(glX_proto_common.glx_print_proto):
+ def __init__(self):
+ glX_proto_common.glx_print_proto.__init__(self)
+ self.name = "glX_proto_send.py (from Mesa)"
+ self.license = license.bsd_license_template % ( "(C) Copyright IBM Corporation 2004, 2005", "IBM")
+
+
+ self.last_category = ""
+ self.generic_sizes = [3, 4, 6, 8, 12, 16, 24, 32]
+ self.pixel_stubs = {}
+ self.debug = 0
+ return
+
+ def printRealHeader(self):
+ print ''
+ print '#include <GL/gl.h>'
+ print '#include "indirect.h"'
+ print '#include "glxclient.h"'
+ print '#include "indirect_size.h"'
+ print '#include <GL/glxproto.h>'
+ print '#ifdef USE_XCB'
+ print '#include <X11/xcl.h>'
+ print '#include <X11/XCB/xcb.h>'
+ print '#include <X11/XCB/glx.h>'
+ print '#endif /* USE_XCB */'
+
+ print ''
+ print '#define __GLX_PAD(n) (((n) + 3) & ~3)'
+ print ''
+ self.printFastcall()
+ self.printNoinline()
+ print ''
+ print '#if !defined __GNUC__ || __GNUC__ < 3'
+ print '# define __builtin_expect(x, y) x'
+ print '#endif'
+ print ''
+ print '/* If the size and opcode values are known at compile-time, this will, on'
+ print ' * x86 at least, emit them with a single instruction.'
+ print ' */'
+ print '#define emit_header(dest, op, size) \\'
+ print ' do { union { short s[2]; int i; } temp; \\'
+ print ' temp.s[0] = (size); temp.s[1] = (op); \\'
+ print ' *((int *)(dest)) = temp.i; } while(0)'
+ print ''
+ print """NOINLINE CARD32
+__glXReadReply( Display *dpy, size_t size, void * dest, GLboolean reply_is_always_array )
+{
+ xGLXSingleReply reply;
+
+ (void) _XReply(dpy, (xReply *) & reply, 0, False);
+ if (size != 0) {
+ if ((reply.length > 0) || reply_is_always_array) {
+ const GLint bytes = (reply_is_always_array)
+ ? (4 * reply.length) : (reply.size * size);
+ const GLint extra = 4 - (bytes & 3);
+
+ _XRead(dpy, dest, bytes);
+ if ( extra < 4 ) {
+ _XEatData(dpy, extra);
+ }
+ }
+ else {
+ (void) memcpy( dest, &(reply.pad3), size);
+ }
+ }
+
+ return reply.retval;
+}
+
+NOINLINE void
+__glXReadPixelReply( Display *dpy, __GLXcontext * gc, unsigned max_dim,
+ GLint width, GLint height, GLint depth, GLenum format, GLenum type,
+ void * dest, GLboolean dimensions_in_reply )
+{
+ xGLXSingleReply reply;
+ GLint size;
+
+ (void) _XReply(dpy, (xReply *) & reply, 0, False);
+
+ if ( dimensions_in_reply ) {
+ width = reply.pad3;
+ height = reply.pad4;
+ depth = reply.pad5;
+
+ if ((height == 0) || (max_dim < 2)) { height = 1; }
+ if ((depth == 0) || (max_dim < 3)) { depth = 1; }
+ }
+
+ size = reply.length * 4;
+ if (size != 0) {
+ void * buf = Xmalloc( size );
+
+ if ( buf == NULL ) {
+ _XEatData(dpy, size);
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ }
+ else {
+ const GLint extra = 4 - (size & 3);
+
+ _XRead(dpy, buf, size);
+ if ( extra < 4 ) {
+ _XEatData(dpy, extra);
+ }
+
+ __glEmptyImage(gc, 3, width, height, depth, format, type,
+ buf, dest);
+ Xfree(buf);
+ }
+ }
+}
+
+#define X_GLXSingle 0
+
+NOINLINE FASTCALL GLubyte *
+__glXSetupSingleRequest( __GLXcontext * gc, GLint sop, GLint cmdlen )
+{
+ xGLXSingleReq * req;
+ Display * const dpy = gc->currentDpy;
+
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ LockDisplay(dpy);
+ GetReqExtra(GLXSingle, cmdlen, req);
+ req->reqType = gc->majorOpcode;
+ req->contextTag = gc->currentContextTag;
+ req->glxCode = sop;
+ return (GLubyte *)(req) + sz_xGLXSingleReq;
+}
+
+NOINLINE FASTCALL GLubyte *
+__glXSetupVendorRequest( __GLXcontext * gc, GLint code, GLint vop, GLint cmdlen )
+{
+ xGLXVendorPrivateReq * req;
+ Display * const dpy = gc->currentDpy;
+
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ LockDisplay(dpy);
+ GetReqExtra(GLXVendorPrivate, cmdlen, req);
+ req->reqType = gc->majorOpcode;
+ req->glxCode = code;
+ req->vendorCode = vop;
+ req->contextTag = gc->currentContextTag;
+ return (GLubyte *)(req) + sz_xGLXVendorPrivateReq;
+}
+
+const GLuint __glXDefaultPixelStore[9] = { 0, 0, 0, 0, 0, 0, 0, 0, 1 };
+
+#define zero (__glXDefaultPixelStore+0)
+#define one (__glXDefaultPixelStore+8)
+#define default_pixel_store_1D (__glXDefaultPixelStore+4)
+#define default_pixel_store_1D_size 20
+#define default_pixel_store_2D (__glXDefaultPixelStore+4)
+#define default_pixel_store_2D_size 20
+#define default_pixel_store_3D (__glXDefaultPixelStore+0)
+#define default_pixel_store_3D_size 36
+#define default_pixel_store_4D (__glXDefaultPixelStore+0)
+#define default_pixel_store_4D_size 36
+"""
+
+ for size in self.generic_sizes:
+ self.print_generic_function(size)
+ return
+
+
+ def printBody(self, api):
+
+ self.pixel_stubs = {}
+ generated_stubs = []
+
+ for func in api.functionIterateGlx():
+ if func.client_handcode: continue
+
+ # If the function is a pixel function with a certain
+ # GLX protocol signature, create a fake stub function
+ # for it. For example, create a single stub function
+ # that is used to implement both glTexImage1D and
+ # glTexImage2D.
+
+ if func.glx_rop != 0:
+ do_it = 0
+ for image in func.get_images():
+ if image.img_pad_dimensions:
+ do_it = 1
+ break
+
+
+ if do_it:
+ [h, n] = hash_pixel_function(func)
+
+
+ self.pixel_stubs[ func.name ] = n
+ if h not in generated_stubs:
+ generated_stubs.append(h)
+
+ fake_func = glx_pixel_function_stub( func, n )
+ self.printFunction( fake_func )
+
+
+ self.printFunction( func )
+
+ return
+
+
+ def printFunction(self, func):
+ if func.glx_rop == ~0:
+ print 'static %s' % (func.return_type)
+ print '%s( unsigned opcode, unsigned dim, %s )' % (func.name, func.get_parameter_string())
+ else:
+ print '#define %s %d' % (func.opcode_name(), func.opcode_value())
+
+ print '%s' % (func.return_type)
+ print '__indirect_gl%s(%s)' % (func.name, func.get_parameter_string())
+
+
+ print '{'
+
+
+ if func.glx_rop != 0 or func.vectorequiv != None:
+ if len(func.images):
+ self.printPixelFunction(func)
+ else:
+ self.printRenderFunction(func)
+ elif func.glx_sop != 0 or func.glx_vendorpriv != 0:
+ self.printSingleFunction(func)
+ pass
+ else:
+ print "/* Missing GLX protocol for %s. */" % (func.name)
+
+ print '}'
+ print ''
+
+ return
+
+
+ def print_generic_function(self, n):
+ size = (n + 3) & ~3
+ print """static FASTCALL NOINLINE void
+generic_%u_byte( GLint rop, const void * ptr )
+{
+ __GLXcontext * const gc = __glXGetCurrentContext();
+ const GLuint cmdlen = %u;
+
+ emit_header(gc->pc, rop, cmdlen);
+ (void) memcpy((void *)(gc->pc + 4), ptr, %u);
+ gc->pc += cmdlen;
+ if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
+}
+""" % (n, size + 4, size)
+ return
+
+
+ def common_emit_one_arg(self, p, pc, indent, adjust, extra_offset):
+ if p.is_array():
+ src_ptr = p.name
+ else:
+ src_ptr = "&" + p.name
+
+ if not extra_offset:
+ print '%s (void) memcpy((void *)(%s + %u), (void *)(%s), %s);' \
+ % (indent, pc, p.offset + adjust, src_ptr, p.size_string() )
+ else:
+ print '%s (void) memcpy((void *)(%s + %u + %s), (void *)(%s), %s);' \
+ % (indent, pc, p.offset + adjust, extra_offset, src_ptr, p.size_string() )
+
+ def common_emit_args(self, f, pc, indent, adjust, skip_vla):
+ extra_offset = None
+
+ for p in f.parameterIterateGlxSend( not skip_vla ):
+ if p.name != f.img_reset:
+ self.common_emit_one_arg(p, pc, indent, adjust, extra_offset)
+
+ if p.is_variable_length():
+ temp = p.size_string()
+ if extra_offset:
+ extra_offset += " + %s" % (temp)
+ else:
+ extra_offset = temp
+
+ return
+
+
+ def pixel_emit_args(self, f, pc, indent, large):
+ """Emit the arguments for a pixel function. This differs from
+ common_emit_args in that pixel functions may require padding
+ be inserted (i.e., for the missing width field for
+ TexImage1D), and they may also require a 'NULL image' flag
+ be inserted before the image data."""
+
+ if large:
+ adjust = 8
+ else:
+ adjust = 4
+
+ for param in f.parameterIterateGlxSend():
+ if not param.is_image():
+ self.common_emit_one_arg(param, pc, indent, adjust, None)
+
+ if f.pad_after(param):
+ print '%s (void) memcpy((void *)(%s + %u), zero, 4);' % (indent, pc, (param.offset + param.size()) + adjust)
+
+ else:
+ [dim, width, height, depth, extent] = param.get_dimensions()
+ if f.glx_rop == ~0:
+ dim_str = "dim"
+ else:
+ dim_str = str(dim)
+
+ if param.img_null_flag:
+ if large:
+ print '%s (void) memcpy((void *)(%s + %u), zero, 4);' % (indent, pc, (param.offset - 4) + adjust)
+ else:
+ print '%s (void) memcpy((void *)(%s + %u), (void *)((%s == NULL) ? one : zero), 4);' % (indent, pc, (param.offset - 4) + adjust, param.name)
+
+
+ pixHeaderPtr = "%s + %u" % (pc, adjust)
+ pcPtr = "%s + %u" % (pc, param.offset + adjust)
+
+ if not large:
+ if param.img_send_null:
+ condition = '(compsize > 0) && (%s != NULL)' % (param.name)
+ else:
+ condition = 'compsize > 0'
+
+ print '%s if (%s) {' % (indent, condition)
+ print '%s (*gc->fillImage)(gc, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (indent, dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr)
+ print '%s }' % (indent)
+ print '%s else {' % (indent)
+ print '%s (void) memcpy( %s, default_pixel_store_%uD, default_pixel_store_%uD_size );' % (indent, pixHeaderPtr, dim, dim)
+ print '%s }' % (indent)
+ else:
+ print '%s __glXSendLargeImage(gc, compsize, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (indent, dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr)
+
+ return
+
+
+ def large_emit_begin(self, indent, f, op_name = None):
+ if not op_name:
+ op_name = f.opcode_real_name()
+
+ print '%s const GLint op = %s;' % (indent, op_name)
+ print '%s const GLuint cmdlenLarge = cmdlen + 4;' % (indent)
+ print '%s GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);' % (indent)
+ print '%s (void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);' % (indent)
+ print '%s (void) memcpy((void *)(pc + 4), (void *)(&op), 4);' % (indent)
+ return
+
+
+ def common_func_print_just_start(self, f):
+ print ' __GLXcontext * const gc = __glXGetCurrentContext();'
+
+ # The only reason that single and vendor private commands need
+ # a variable called 'dpy' is becuase they use the SyncHandle
+ # macro. For whatever brain-dead reason, that macro is hard-
+ # coded to use a variable called 'dpy' instead of taking a
+ # parameter.
+
+ # FIXME Simplify the logic related to skip_condition and
+ # FIXME condition_list in this function. Basically, remove
+ # FIXME skip_condition, and just append the "dpy != NULL" type
+ # FIXME condition to condition_list from the start. The only
+ # FIXME reason it's done in this confusing way now is to
+ # FIXME minimize the diffs in the generated code.
+
+ if not f.glx_rop:
+ for p in f.parameterIterateOutputs():
+ if p.is_image():
+ print ' const __GLXattribute * const state = gc->client_state_private;'
+ break
+
+ print ' Display * const dpy = gc->currentDpy;'
+ skip_condition = "dpy != NULL"
+ elif f.can_be_large:
+ skip_condition = "gc->currentDpy != NULL"
+ else:
+ skip_condition = None
+
+
+ if f.return_type != 'void':
+ print ' %s retval = (%s) 0;' % (f.return_type, f.return_type)
+
+
+ self.emit_packet_size_calculation(f, 0)
+
+ condition_list = []
+ for p in f.parameterIterateCounters():
+ condition_list.append( "%s >= 0" % (p.name) )
+
+ if skip_condition:
+ condition_list.append( skip_condition )
+
+ if len( condition_list ) > 0:
+ if len( condition_list ) > 1:
+ skip_condition = "(%s)" % (string.join( condition_list, ") && (" ))
+ else:
+ skip_condition = "%s" % (condition_list.pop(0))
+
+ print ' if (__builtin_expect(%s, 1)) {' % (skip_condition)
+ return 1
+ else:
+ return 0
+
+
+ def printSingleFunction(self, f):
+ self.common_func_print_just_start(f)
+
+ if self.debug:
+ print ' printf( "Enter %%s...\\n", "gl%s" );' % (f.name)
+
+ if f.glx_vendorpriv == 0:
+
+ # XCB specific:
+ print '#ifdef USE_XCB'
+ if self.debug:
+ print ' printf("\\tUsing XCB.\\n");'
+ print ' XCBConnection *c = XCBConnectionOfDisplay(dpy);'
+ print ' (void) __glXFlushRenderBuffer(gc, gc->pc);'
+ xcb_name = 'XCBGlx%s' % f.name
+
+ iparams=[]
+ extra_iparams = []
+ output = None
+ for p in f.parameterIterator():
+ if p.is_output:
+ output = p
+
+ if p.is_image():
+ if p.img_format != "GL_COLOR_INDEX" or p.img_type != "GL_BITMAP":
+ extra_iparams.append("state->storePack.swapEndian")
+ else:
+ extra_iparams.append("0")
+
+ # Hardcode this in. lsb_first param (apparently always GL_FALSE)
+ # also present in GetPolygonStipple, but taken care of above.
+ if xcb_name == "XCBGlxReadPixels":
+ extra_iparams.append("0")
+ else:
+ iparams.append(p.name)
+
+
+ xcb_request = '%s(%s)' % (xcb_name, ", ".join(["c", "gc->currentContextTag"] + iparams + extra_iparams))
+
+ if f.needs_reply():
+ print ' %sRep *reply = %sReply(c, %s, NULL);' % (xcb_name, xcb_name, xcb_request)
+ if output and f.reply_always_array:
+ print ' (void)memcpy(%s, %sData(reply), %sDataLength(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string())
+
+ elif output and not f.reply_always_array:
+ if not output.is_image():
+ print ' if (%sDataLength(reply) == 0)' % (xcb_name)
+ print ' (void)memcpy(%s, &reply->datum, sizeof(reply->datum));' % (output.name)
+ print ' else'
+ print ' (void)memcpy(%s, %sData(reply), %sDataLength(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string())
+
+
+ if f.return_type != 'void':
+ print ' retval = reply->ret_val;'
+ print ' free(reply);'
+ else:
+ print ' ' + xcb_request + ';'
+ print '#else'
+ # End of XCB specific.
+
+
+ if f.parameters != []:
+ pc_decl = "GLubyte const * pc ="
+ else:
+ pc_decl = "(void)"
+
+ if f.glx_vendorpriv != 0:
+ print ' %s __glXSetupVendorRequest(gc, %s, %s, cmdlen);' % (pc_decl, f.opcode_real_name(), f.opcode_name())
+ else:
+ print ' %s __glXSetupSingleRequest(gc, %s, cmdlen);' % (pc_decl, f.opcode_name())
+
+ self.common_emit_args(f, "pc", " ", 0, 0)
+
+ images = f.get_images()
+
+ for img in images:
+ if img.is_output:
+ o = f.command_fixed_length() - 4
+ print ' *(int32_t *)(pc + %u) = 0;' % (o)
+ if img.img_format != "GL_COLOR_INDEX" or img.img_type != "GL_BITMAP":
+ print ' * (int8_t *)(pc + %u) = state->storePack.swapEndian;' % (o)
+
+ if f.img_reset:
+ print ' * (int8_t *)(pc + %u) = %s;' % (o + 1, f.img_reset)
+
+
+ return_name = ''
+ if f.needs_reply():
+ if f.return_type != 'void':
+ return_name = " retval"
+ return_str = " retval = (%s)" % (f.return_type)
+ else:
+ return_str = " (void)"
+
+ got_reply = 0
+
+ for p in f.parameterIterateOutputs():
+ if p.is_image():
+ [dim, w, h, d, junk] = p.get_dimensions()
+ if f.dimensions_in_reply:
+ print " __glXReadPixelReply(dpy, gc, %u, 0, 0, 0, %s, %s, %s, GL_TRUE);" % (dim, p.img_format, p.img_type, p.name)
+ else:
+ print " __glXReadPixelReply(dpy, gc, %u, %s, %s, %s, %s, %s, %s, GL_FALSE);" % (dim, w, h, d, p.img_format, p.img_type, p.name)
+
+ got_reply = 1
+ else:
+ if f.reply_always_array:
+ aa = "GL_TRUE"
+ else:
+ aa = "GL_FALSE"
+
+ # gl_parameter.size() returns the size
+ # of the entire data item. If the
+ # item is a fixed-size array, this is
+ # the size of the whole array. This
+ # is not what __glXReadReply wants. It
+ # wants the size of a single data
+ # element in the reply packet.
+ # Dividing by the array size (1 for
+ # non-arrays) gives us this.
+
+ s = p.size() / p.get_element_count()
+ print " %s __glXReadReply(dpy, %s, %s, %s);" % (return_str, s, p.name, aa)
+ got_reply = 1
+
+
+ # If a reply wasn't read to fill an output parameter,
+ # read a NULL reply to get the return value.
+
+ if not got_reply:
+ print " %s __glXReadReply(dpy, 0, NULL, GL_FALSE);" % (return_str)
+
+
+ elif self.debug:
+ # Only emit the extra glFinish call for functions
+ # that don't already require a reply from the server.
+ print ' __indirect_glFinish();'
+
+ if self.debug:
+ print ' printf( "Exit %%s.\\n", "gl%s" );' % (f.name)
+
+
+ print ' UnlockDisplay(dpy); SyncHandle();'
+
+ if f.glx_vendorpriv == 0:
+ print '#endif /* USE_XCB */'
+
+ print ' }'
+ print ' return%s;' % (return_name)
+ return
+
+
+ def printPixelFunction(self, f):
+ if self.pixel_stubs.has_key( f.name ):
+ # Normally gl_function::get_parameter_string could be
+ # used. However, this call needs to have the missing
+ # dimensions (e.g., a fake height value for
+ # glTexImage1D) added in.
+
+ p_string = ""
+ for param in f.parameterIterateGlxSend():
+ p_string += ", " + param.name
+
+ if param.is_image():
+ [dim, junk, junk, junk, junk] = param.get_dimensions()
+
+ if f.pad_after(param):
+ p_string += ", 1"
+
+ print ' %s(%s, %u%s );' % (self.pixel_stubs[f.name] , f.opcode_name(), dim, p_string)
+ return
+
+
+ if self.common_func_print_just_start(f):
+ indent = " "
+ trailer = " }"
+ else:
+ indent = ""
+ trailer = None
+
+
+ if f.can_be_large:
+ print '%s if (cmdlen <= gc->maxSmallRenderCommandSize) {' % (indent)
+ print '%s if ( (gc->pc + cmdlen) > gc->bufEnd ) {' % (indent)
+ print '%s (void) __glXFlushRenderBuffer(gc, gc->pc);' % (indent)
+ print '%s }' % (indent)
+ indent += " "
+
+ if f.glx_rop == ~0:
+ opcode = "opcode"
+ else:
+ opcode = f.opcode_real_name()
+
+ print '%s emit_header(gc->pc, %s, cmdlen);' % (indent, opcode)
+
+ self.pixel_emit_args( f, "gc->pc", indent, 0 )
+ print '%s gc->pc += cmdlen;' % (indent)
+ print '%s if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }' % (indent)
+
+ if f.can_be_large:
+ print '%s}' % (indent)
+ print '%selse {' % (indent)
+
+ self.large_emit_begin(indent, f, opcode)
+ self.pixel_emit_args( f, "pc", indent, 1 )
+
+ print '%s}' % (indent)
+
+ if trailer: print trailer
+ return
+
+
+ def printRenderFunction(self, f):
+ # There is a class of GL functions that take a single pointer
+ # as a parameter. This pointer points to a fixed-size chunk
+ # of data, and the protocol for this functions is very
+ # regular. Since they are so regular and there are so many
+ # of them, special case them with generic functions. On
+ # x86, this saves about 26KB in the libGL.so binary.
+
+ if f.variable_length_parameter() == None and len(f.parameters) == 1:
+ p = f.parameters[0]
+ if p.is_pointer():
+ cmdlen = f.command_fixed_length()
+ if cmdlen in self.generic_sizes:
+ print ' generic_%u_byte( %s, %s );' % (cmdlen, f.opcode_real_name(), p.name)
+ return
+
+ if self.common_func_print_just_start(f):
+ indent = " "
+ trailer = " }"
+ else:
+ indent = ""
+ trailer = None
+
+ if self.debug:
+ print '%s printf( "Enter %%s...\\n", "gl%s" );' % (indent, f.name)
+
+ if f.can_be_large:
+ print '%s if (cmdlen <= gc->maxSmallRenderCommandSize) {' % (indent)
+ print '%s if ( (gc->pc + cmdlen) > gc->bufEnd ) {' % (indent)
+ print '%s (void) __glXFlushRenderBuffer(gc, gc->pc);' % (indent)
+ print '%s }' % (indent)
+ indent += " "
+
+ print '%s emit_header(gc->pc, %s, cmdlen);' % (indent, f.opcode_real_name())
+
+ self.common_emit_args(f, "gc->pc", indent, 4, 0)
+ print '%s gc->pc += cmdlen;' % (indent)
+ print '%s if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }' % (indent)
+
+ if f.can_be_large:
+ print '%s}' % (indent)
+ print '%selse {' % (indent)
+
+ self.large_emit_begin(indent, f)
+ self.common_emit_args(f, "pc", indent, 8, 1)
+
+ p = f.variable_length_parameter()
+ print '%s __glXSendLargeCommand(gc, pc, %u, %s, %s);' % (indent, p.offset + 8, p.name, p.size_string())
+ print '%s}' % (indent)
+
+ if self.debug:
+ print '%s __indirect_glFinish();' % (indent)
+ print '%s printf( "Exit %%s.\\n", "gl%s" );' % (indent, f.name)
+
+ if trailer: print trailer
+ return
+
+
+class PrintGlxProtoInit_c(gl_XML.gl_print_base):
+ def __init__(self):
+ gl_XML.gl_print_base.__init__(self)
+
+ self.name = "glX_proto_send.py (from Mesa)"
+ self.license = license.bsd_license_template % ( \
+"""Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+(C) Copyright IBM Corporation 2004""", "PRECISION INSIGHT, IBM")
+ return
+
+
+ def printRealHeader(self):
+ print """/**
+ * \\file indirect_init.c
+ * Initialize indirect rendering dispatch table.
+ *
+ * \\author Kevin E. Martin <kevin@precisioninsight.com>
+ * \\author Brian Paul <brian@precisioninsight.com>
+ * \\author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include "indirect_init.h"
+#include "indirect.h"
+#include "glapi.h"
+
+
+/**
+ * No-op function used to initialize functions that have no GLX protocol
+ * support.
+ */
+static int NoOp(void)
+{
+ return 0;
+}
+
+/**
+ * Create and initialize a new GL dispatch table. The table is initialized
+ * with GLX indirect rendering protocol functions.
+ */
+__GLapi * __glXNewIndirectAPI( void )
+{
+ __GLapi *glAPI;
+ GLuint entries;
+
+ entries = _glapi_get_dispatch_table_size();
+ glAPI = (__GLapi *) Xmalloc(entries * sizeof(void *));
+
+ /* first, set all entries to point to no-op functions */
+ {
+ int i;
+ void **dispatch = (void **) glAPI;
+ for (i = 0; i < entries; i++) {
+ dispatch[i] = (void *) NoOp;
+ }
+ }
+
+ /* now, initialize the entries we understand */"""
+
+ def printRealFooter(self):
+ print """
+ return glAPI;
+}
+"""
+ return
+
+
+ def printCategory(self, category_group, show_num):
+ cat_keys = category_group.keys()
+ cat_keys.sort()
+ for cat_num in cat_keys:
+ first = 1
+ for offset in category_group[ cat_num ]:
+ [cat_name, func_name] = category_group[ cat_num ][ offset ]
+
+ if first:
+ print ''
+ if show_num:
+ print ' /* % 3u. %s */' % (cat_num, cat_name)
+ else:
+ print ' /* %s */' % (cat_name)
+ print ''
+ first = 0
+
+ print ' glAPI->%s = __indirect_gl%s;' % (func_name, func_name)
+
+
+ def printBody(self, api):
+ core_categories = {}
+ arb_categories = {}
+ other_categories = {}
+ next_unnum = 1000
+
+ for func in api.functionIterateGlx():
+ [cat, num] = api.get_category_for_name( func.name )
+
+ # There are three groups of "categories" that we
+ # care about here. We want to separate the core GL
+ # version categories from extensions. We also want to
+ # separate the ARB extensions from the non-ARB
+ # extensions.
+ #
+ # This is done by first trying to convert the category
+ # name to a floating point number. All core GL
+ # versions are of the form "N.M" where both N and M
+ # are integers. If the cast to float fails, an
+ # exception will be thrown. Once down that path,
+ # we can look at the start of the extension string.
+ # If it begins with "GL_ARB_", it's an ARB extension.
+ #
+ # Once the categories are separated, the are ordered
+ # by number. The un-numbered non-ARB extensions
+ # (e.g., GL_INGR_blend_func_separate) are assigned
+ # arbitrary numbers starting at 1000.
+ #
+ # FIXME In order to maintain repeatability, the
+ # FIXME unnumbered extensions should be put in their
+ # FIXME own dictionary and ordered by name (since they
+ # FIXME have no number).
+
+ try:
+ num = float(cat)
+ if not core_categories.has_key( num ):
+ core_categories[ num ] = {}
+
+ core_categories[ num ][ func.offset ] = [cat, func.name]
+
+ except Exception, e:
+ if not num:
+ num = next_unnum
+ next_unnum += 1
+ else:
+ num = int(num)
+
+ if cat.startswith( "GL_ARB_" ):
+ if not arb_categories.has_key( num ):
+ arb_categories[ num ] = {}
+
+ arb_categories[ num ][ func.offset ] = [cat, func.name]
+ else:
+ if not other_categories.has_key( num ):
+ other_categories[ num ] = {}
+
+ other_categories[ num ][ func.offset ] = [cat, func.name]
+
+ self.printCategory( core_categories, 0 )
+ self.printCategory( arb_categories, 1 )
+ self.printCategory( other_categories, 1 )
+ return
+
+
+class PrintGlxProtoInit_h(gl_XML.gl_print_base):
+ def __init__(self):
+ gl_XML.gl_print_base.__init__(self)
+
+ self.name = "glX_proto_send.py (from Mesa)"
+ self.license = license.bsd_license_template % ( \
+"""Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+(C) Copyright IBM Corporation 2004""", "PRECISION INSIGHT, IBM")
+ self.header_tag = "_INDIRECT_H_"
+
+ self.last_category = ""
+ return
+
+
+ def printRealHeader(self):
+ print """/**
+ * \\file
+ * Prototypes for indirect rendering functions.
+ *
+ * \\author Kevin E. Martin <kevin@precisioninsight.com>
+ * \\author Ian Romanick <idr@us.ibm.com>
+ */
+"""
+ self.printVisibility( "HIDDEN", "hidden" )
+ self.printFastcall()
+ self.printNoinline()
+
+ print """
+#include "glxclient.h"
+
+extern HIDDEN NOINLINE CARD32 __glXReadReply( Display *dpy, size_t size,
+ void * dest, GLboolean reply_is_always_array );
+
+extern HIDDEN NOINLINE void __glXReadPixelReply( Display *dpy,
+ __GLXcontext * gc, unsigned max_dim, GLint width, GLint height,
+ GLint depth, GLenum format, GLenum type, void * dest,
+ GLboolean dimensions_in_reply );
+
+extern HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupSingleRequest(
+ __GLXcontext * gc, GLint sop, GLint cmdlen );
+
+extern HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupVendorRequest(
+ __GLXcontext * gc, GLint code, GLint vop, GLint cmdlen );
+"""
+
+
+ def printBody(self, api):
+ for func in api.functionIterateGlx():
+ print 'extern HIDDEN %s __indirect_gl%s(%s);' % (func.return_type, func.name, func.get_parameter_string())
+
+
+def show_usage():
+ print "Usage: %s [-f input_file_name] [-m output_mode] [-d]" % sys.argv[0]
+ print " -m output_mode Output mode can be one of 'proto', 'init_c' or 'init_h'."
+ print " -d Enable extra debug information in the generated code."
+ sys.exit(1)
+
+
+if __name__ == '__main__':
+ file_name = "gl_API.xml"
+
+ try:
+ (args, trail) = getopt.getopt(sys.argv[1:], "f:m:d")
+ except Exception,e:
+ show_usage()
+
+ debug = 0
+ mode = "proto"
+ for (arg,val) in args:
+ if arg == "-f":
+ file_name = val
+ elif arg == "-m":
+ mode = val
+ elif arg == "-d":
+ debug = 1
+
+ if mode == "proto":
+ printer = PrintGlxProtoStubs()
+ elif mode == "init_c":
+ printer = PrintGlxProtoInit_c()
+ elif mode == "init_h":
+ printer = PrintGlxProtoInit_h()
+ else:
+ show_usage()
+
+
+ printer.debug = debug
+ api = gl_XML.parse_GL_API( file_name, glX_XML.glx_item_factory() )
+
+ printer.Print( api )
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/glX_proto_size.py b/nx-X11/extras/Mesa/src/mesa/glapi/glX_proto_size.py
new file mode 100644
index 000000000..81a98423a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/glX_proto_size.py
@@ -0,0 +1,705 @@
+#!/usr/bin/env python
+
+# (C) Copyright IBM Corporation 2004, 2005
+# 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
+# IBM 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:
+# Ian Romanick <idr@us.ibm.com>
+
+import gl_XML, glX_XML
+import license
+import sys, getopt, copy, string
+
+
+class glx_enum_function:
+ def __init__(self, func_name, enum_dict):
+ self.name = func_name
+ self.mode = 1
+ self.sig = None
+
+ # "enums" is a set of lists. The element in the set is the
+ # value of the enum. The list is the list of names for that
+ # value. For example, [0x8126] = {"POINT_SIZE_MIN",
+ # "POINT_SIZE_MIN_ARB", "POINT_SIZE_MIN_EXT",
+ # "POINT_SIZE_MIN_SGIS"}.
+
+ self.enums = {}
+
+ # "count" is indexed by count values. Each element of count
+ # is a list of index to "enums" that have that number of
+ # associated data elements. For example, [4] =
+ # {GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR, GL_EMISSION,
+ # GL_AMBIENT_AND_DIFFUSE} (the enum names are used here,
+ # but the actual hexadecimal values would be in the array).
+
+ self.count = {}
+
+
+ # Fill self.count and self.enums using the dictionary of enums
+ # that was passed in. The generic Get functions (e.g.,
+ # GetBooleanv and friends) are handled specially here. In
+ # the data the generic Get functions are refered to as "Get".
+
+ if func_name in ["GetIntegerv", "GetBooleanv", "GetFloatv", "GetDoublev"]:
+ match_name = "Get"
+ else:
+ match_name = func_name
+
+ mode_set = 0
+ for enum_name in enum_dict:
+ e = enum_dict[ enum_name ]
+
+ if e.functions.has_key( match_name ):
+ [count, mode] = e.functions[ match_name ]
+
+ if mode_set and mode != self.mode:
+ raise RuntimeError("Not all enums for %s have the same mode." % (func_name))
+
+ self.mode = mode
+
+ if self.enums.has_key( e.value ):
+ if e.name not in self.enums[ e.value ]:
+ self.enums[ e.value ].append( e )
+ else:
+ if not self.count.has_key( count ):
+ self.count[ count ] = []
+
+ self.enums[ e.value ] = [ e ]
+ self.count[ count ].append( e.value )
+
+
+ return
+
+
+ def signature( self ):
+ if self.sig == None:
+ self.sig = ""
+ for i in self.count:
+ if i == None:
+ raise RuntimeError("i is None. WTF?")
+
+ self.count[i].sort()
+ for e in self.count[i]:
+ self.sig += "%04x,%d," % (e, i)
+
+ return self.sig
+
+
+ def is_set( self ):
+ return self.mode
+
+
+ def PrintUsingTable(self):
+ """Emit the body of the __gl*_size function using a pair
+ of look-up tables and a mask. The mask is calculated such
+ that (e & mask) is unique for all the valid values of e for
+ this function. The result of (e & mask) is used as an index
+ into the first look-up table. If it matches e, then the
+ same entry of the second table is returned. Otherwise zero
+ is returned.
+
+ It seems like this should cause better code to be generated.
+ However, on x86 at least, the resulting .o file is about 20%
+ larger then the switch-statment version. I am leaving this
+ code in because the results may be different on other
+ platforms (e.g., PowerPC or x86-64)."""
+
+ return 0
+ count = 0
+ for a in self.enums:
+ count += 1
+
+ if self.count.has_key(-1):
+ return 0
+
+ # Determine if there is some mask M, such that M = (2^N) - 1,
+ # that will generate unique values for all of the enums.
+
+ mask = 0
+ for i in [1, 2, 3, 4, 5, 6, 7, 8]:
+ mask = (1 << i) - 1
+
+ fail = 0;
+ for a in self.enums:
+ for b in self.enums:
+ if a != b:
+ if (a & mask) == (b & mask):
+ fail = 1;
+
+ if not fail:
+ break;
+ else:
+ mask = 0
+
+ if (mask != 0) and (mask < (2 * count)):
+ masked_enums = {}
+ masked_count = {}
+
+ for i in range(0, mask + 1):
+ masked_enums[i] = "0";
+ masked_count[i] = 0;
+
+ for c in self.count:
+ for e in self.count[c]:
+ i = e & mask
+ enum_obj = self.enums[e][0]
+ masked_enums[i] = '0x%04x /* %s */' % (e, enum_obj.name )
+ masked_count[i] = c
+
+
+ print ' static const GLushort a[%u] = {' % (mask + 1)
+ for e in masked_enums:
+ print ' %s, ' % (masked_enums[e])
+ print ' };'
+
+ print ' static const GLubyte b[%u] = {' % (mask + 1)
+ for c in masked_count:
+ print ' %u, ' % (masked_count[c])
+ print ' };'
+
+ print ' const unsigned idx = (e & 0x%02xU);' % (mask)
+ print ''
+ print ' return (e == a[idx]) ? (GLint) b[idx] : 0;'
+ return 1;
+ else:
+ return 0;
+
+
+ def PrintUsingSwitch(self, name):
+ """Emit the body of the __gl*_size function using a
+ switch-statement."""
+
+ print ' switch( e ) {'
+
+ for c in self.count:
+ for e in self.count[c]:
+ first = 1
+
+ # There may be multiple enums with the same
+ # value. This happens has extensions are
+ # promoted from vendor-specific or EXT to
+ # ARB and to the core. Emit the first one as
+ # a case label, and emit the others as
+ # commented-out case labels.
+
+ list = {}
+ for enum_obj in self.enums[e]:
+ list[ enum_obj.priority() ] = enum_obj.name
+
+ keys = list.keys()
+ keys.sort()
+ for k in keys:
+ j = list[k]
+ if first:
+ print ' case GL_%s:' % (j)
+ first = 0
+ else:
+ print '/* case GL_%s:*/' % (j)
+
+ if c == -1:
+ print ' return __gl%s_variable_size( e );' % (name)
+ else:
+ print ' return %u;' % (c)
+
+ print ' default: return 0;'
+ print ' }'
+
+
+ def Print(self, name):
+ print 'INTERNAL PURE FASTCALL GLint'
+ print '__gl%s_size( GLenum e )' % (name)
+ print '{'
+
+ if not self.PrintUsingTable():
+ self.PrintUsingSwitch(name)
+
+ print '}'
+ print ''
+
+
+class glx_server_enum_function(glx_enum_function):
+ def __init__(self, func, enum_dict):
+ glx_enum_function.__init__(self, func.name, enum_dict)
+
+ self.function = func
+ return
+
+
+ def signature( self ):
+ if self.sig == None:
+ sig = glx_enum_function.signature(self)
+
+ p = self.function.variable_length_parameter()
+ if p:
+ sig += "%u" % (p.size())
+
+ self.sig = sig
+
+ return self.sig;
+
+
+ def Print(self, name, printer):
+ f = self.function
+ printer.common_func_print_just_header( f )
+
+ fixup = []
+
+ foo = {}
+ for param_name in f.count_parameter_list:
+ o = f.offset_of( param_name )
+ foo[o] = param_name
+
+ for param_name in f.counter_list:
+ o = f.offset_of( param_name )
+ foo[o] = param_name
+
+ keys = foo.keys()
+ keys.sort()
+ for o in keys:
+ p = f.parameters_by_name[ foo[o] ]
+
+ printer.common_emit_one_arg(p, "pc", " ", 0)
+ fixup.append( p.name )
+
+
+ print ' GLsizei compsize;'
+ print ''
+
+ printer.common_emit_fixups(fixup)
+
+ print ''
+ print ' compsize = __gl%s_size(%s);' % (f.name, string.join(f.count_parameter_list, ","))
+ p = f.variable_length_parameter()
+ print ' return __GLX_PAD(%s);' % (p.size_string())
+
+ print '}'
+ print ''
+
+
+class PrintGlxSizeStubs_common(gl_XML.gl_print_base):
+ do_get = (1 << 0)
+ do_set = (1 << 1)
+
+ def __init__(self, which_functions):
+ gl_XML.gl_print_base.__init__(self)
+
+ self.name = "glX_proto_size.py (from Mesa)"
+ self.license = license.bsd_license_template % ( "(C) Copyright IBM Corporation 2004", "IBM")
+
+ self.emit_set = ((which_functions & PrintGlxSizeStubs_common.do_set) != 0)
+ self.emit_get = ((which_functions & PrintGlxSizeStubs_common.do_get) != 0)
+ return
+
+
+class PrintGlxSizeStubs_c(PrintGlxSizeStubs_common):
+ def printRealHeader(self):
+ print ''
+ print '#include <GL/gl.h>'
+ if self.emit_get:
+ print '#include "indirect_size_get.h"'
+
+ print '#include "indirect_size.h"'
+
+ print ''
+ self.printPure()
+ print ''
+ self.printFastcall()
+ print ''
+ self.printVisibility( "INTERNAL", "internal" )
+ print ''
+ print ''
+ print '#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__)'
+ print '# undef HAVE_ALIAS'
+ print '#endif'
+ print '#ifdef HAVE_ALIAS'
+ print '# define ALIAS2(from,to) \\'
+ print ' INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\'
+ print ' __attribute__ ((alias( # to )));'
+ print '# define ALIAS(from,to) ALIAS2( from, __gl ## to ## _size )'
+ print '#else'
+ print '# define ALIAS(from,to) \\'
+ print ' INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\'
+ print ' { return __gl ## to ## _size( e ); }'
+ print '#endif'
+ print ''
+ print ''
+
+
+ def printBody(self, api):
+ enum_sigs = {}
+ aliases = []
+
+ for func in api.functionIterateGlx():
+ ef = glx_enum_function( func.name, api.enums_by_name )
+ if len(ef.enums) == 0:
+ continue
+
+ if (ef.is_set() and self.emit_set) or (not ef.is_set() and self.emit_get):
+ sig = ef.signature()
+ if enum_sigs.has_key( sig ):
+ aliases.append( [func.name, enum_sigs[ sig ]] )
+ else:
+ enum_sigs[ sig ] = func.name
+ ef.Print( func.name )
+
+
+ for [alias_name, real_name] in aliases:
+ print 'ALIAS( %s, %s )' % (alias_name, real_name)
+
+
+
+class PrintGlxSizeStubs_h(PrintGlxSizeStubs_common):
+ def printRealHeader(self):
+ print """/**
+ * \\file
+ * Prototypes for functions used to determine the number of data elements in
+ * various GLX protocol messages.
+ *
+ * \\author Ian Romanick <idr@us.ibm.com>
+ */
+"""
+ self.printPure();
+ print ''
+ self.printFastcall();
+ print ''
+ self.printVisibility( "INTERNAL", "internal" );
+ print ''
+
+
+ def printBody(self, api):
+ for func in api.functionIterateGlx():
+ ef = glx_enum_function( func.name, api.enums_by_name )
+ if len(ef.enums) == 0:
+ continue
+
+ if (ef.is_set() and self.emit_set) or (not ef.is_set() and self.emit_get):
+ print 'extern INTERNAL PURE FASTCALL GLint __gl%s_size(GLenum);' % (func.name)
+
+
+class PrintGlxReqSize_common(gl_XML.gl_print_base):
+ """Common base class for PrintGlxSizeReq_h and PrintGlxSizeReq_h.
+
+ The main purpose of this common base class is to provide the infrastructure
+ for the derrived classes to iterate over the same set of functions.
+ """
+
+ def __init__(self):
+ gl_XML.gl_print_base.__init__(self)
+
+ self.name = "glX_proto_size.py (from Mesa)"
+ self.license = license.bsd_license_template % ( "(C) Copyright IBM Corporation 2005", "IBM")
+
+
+class PrintGlxReqSize_h(PrintGlxReqSize_common):
+ def __init__(self):
+ PrintGlxReqSize_common.__init__(self)
+ self.header_tag = "_INDIRECT_REQSIZE_H_"
+
+
+ def printRealHeader(self):
+ self.printVisibility("HIDDEN", "hidden")
+ print ''
+ self.printPure()
+ print ''
+
+
+ def printBody(self, api):
+ for func in api.functionIterateGlx():
+ if not func.ignore and func.has_variable_size_request():
+ print 'extern PURE HIDDEN int __glX%sReqSize(const GLbyte *pc, Bool swap);' % (func.name)
+
+
+class PrintGlxReqSize_c(PrintGlxReqSize_common):
+ """Create the server-side 'request size' functions.
+
+ Create the server-side functions that are used to determine what the
+ size of a varible length command should be. The server then uses
+ this value to determine if the incoming command packed it malformed.
+ """
+
+ def __init__(self):
+ PrintGlxReqSize_common.__init__(self)
+ self.counter_sigs = {}
+
+
+ def printRealHeader(self):
+ print ''
+ print '#include <GL/gl.h>'
+ print '#include "glxserver.h"'
+ print '#include "indirect_size.h"'
+ print '#include "indirect_reqsize.h"'
+ print ''
+ print '#if defined(linux)'
+ print '# include <byteswap.h>'
+ print '# define SWAP_32(v) do { (v) = bswap_32(v); } while(0)'
+ print '#else'
+ print '# include <X11/misc.h>'
+ print '# define SWAP_32(v) do { char tmp; swapl(&v, tmp); } while(0)'
+ print '#endif'
+
+ print ''
+ print '#define __GLX_PAD(x) (((x) + 3) & ~3)'
+ print ''
+ print '#if defined(__CYGWIN__) || defined(__MINGW32__)'
+ print '# undef HAVE_ALIAS'
+ print '#endif'
+ print '#ifdef HAVE_ALIAS'
+ print '# define ALIAS2(from,to) \\'
+ print ' GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap ) \\'
+ print ' __attribute__ ((alias( # to )));'
+ print '# define ALIAS(from,to) ALIAS2( from, __glX ## to ## ReqSize )'
+ print '#else'
+ print '# define ALIAS(from,to) \\'
+ print ' GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap ) \\'
+ print ' { return __glX ## to ## ReqSize( pc, swap ); }'
+ print '#endif'
+ print ''
+ print ''
+
+
+ def printBody(self, api):
+ aliases = []
+ enum_functions = {}
+ enum_sigs = {}
+
+ for func in api.functionIterateGlx():
+ if not func.has_variable_size_request(): continue
+
+ ef = glx_server_enum_function( func, api.enums_by_name )
+ if len(ef.enums) == 0: continue
+
+ sig = ef.signature()
+
+ if not enum_functions.has_key(func.name):
+ enum_functions[ func.name ] = sig
+
+ if not enum_sigs.has_key( sig ):
+ enum_sigs[ sig ] = ef
+
+
+
+ for func in api.functionIterateGlx():
+ # Even though server-handcode fuctions are on "the
+ # list", and prototypes are generated for them, there
+ # isn't enough information to generate a size
+ # function. If there was enough information, they
+ # probably wouldn't need to be handcoded in the first
+ # place!
+
+ if func.server_handcode: continue
+ if not func.has_variable_size_request(): continue
+
+ if enum_functions.has_key(func.name):
+ sig = enum_functions[func.name]
+ ef = enum_sigs[ sig ]
+
+ if ef.name != func.name:
+ aliases.append( [func.name, ef.name] )
+ else:
+ ef.Print( func.name, self )
+
+ elif func.images:
+ self.printPixelFunction(func)
+ elif func.has_variable_size_request():
+ a = self.printCountedFunction(func)
+ if a: aliases.append(a)
+
+
+ for [alias_name, real_name] in aliases:
+ print 'ALIAS( %s, %s )' % (alias_name, real_name)
+
+ return
+
+
+ def common_emit_fixups(self, fixup):
+ """Utility function to emit conditional byte-swaps."""
+
+ if fixup:
+ print ' if (swap) {'
+ for name in fixup:
+ print ' SWAP_32( %s );' % (name)
+ print ' }'
+
+ return
+
+
+ def common_emit_one_arg(self, p, pc, indent, adjust):
+ offset = p.offset
+ dst = p.string()
+ src = '(%s *)' % (p.type_string())
+ print '%s%-18s = *%11s(%s + %u);' % (indent, dst, src, pc, offset + adjust);
+ return
+
+
+ def common_func_print_just_header(self, f):
+ print 'int'
+ print '__glX%sReqSize( const GLbyte * pc, Bool swap )' % (f.name)
+ print '{'
+
+
+ def printPixelFunction(self, f):
+ self.common_func_print_just_header(f)
+
+ f.offset_of( f.parameters[0].name )
+ [dim, w, h, d, junk] = f.get_images()[0].get_dimensions()
+
+ print ' GLint row_length = * (GLint *)(pc + 4);'
+
+ if dim < 3:
+ fixup = ['row_length', 'skip_rows', 'alignment']
+ print ' GLint image_height = 0;'
+ print ' GLint skip_images = 0;'
+ print ' GLint skip_rows = * (GLint *)(pc + 8);'
+ print ' GLint alignment = * (GLint *)(pc + 16);'
+ else:
+ fixup = ['row_length', 'image_height', 'skip_rows', 'skip_images', 'alignment']
+ print ' GLint image_height = * (GLint *)(pc + 8);'
+ print ' GLint skip_rows = * (GLint *)(pc + 16);'
+ print ' GLint skip_images = * (GLint *)(pc + 20);'
+ print ' GLint alignment = * (GLint *)(pc + 32);'
+
+ img = f.images[0]
+ for p in f.parameterIterateGlxSend():
+ if p.name in [w, h, d, img.img_format, img.img_type, img.img_target]:
+ self.common_emit_one_arg( p, "pc", " ", 0 )
+ fixup.append( p.name )
+
+ print ''
+
+ self.common_emit_fixups(fixup)
+
+ print ''
+ print ' return __glXImageSize(%s, %s, %s, %s, %s, %s,' % (img.img_format, img.img_type, img.img_target, w, h, d )
+ print ' image_height, row_length, skip_images,'
+ print ' skip_rows, alignment);'
+ print '}'
+ print ''
+ return
+
+
+ def printCountedFunction(self, f):
+
+ sig = ""
+ offset = 0
+ fixup = []
+ params = []
+ plus = ''
+ size = ''
+ param_offsets = {}
+
+ # Calculate the offset of each counter parameter and the
+ # size string for the variable length parameter(s). While
+ # that is being done, calculate a unique signature for this
+ # function.
+
+ for p in f.parameterIterateGlxSend():
+ if p.is_counter:
+ fixup.append( p.name )
+ params.append( p )
+ elif p.counter:
+ s = p.size()
+ if s == 0: s = 1
+
+ sig += "(%u,%u)" % (f.offset_of(p.counter), s)
+ size += '%s%s' % (plus, p.size_string())
+ plus = ' + '
+
+
+ # If the calculated signature matches a function that has
+ # already be emitted, don't emit this function. Instead, add
+ # it to the list of function aliases.
+
+ if self.counter_sigs.has_key(sig):
+ n = self.counter_sigs[sig];
+ alias = [f.name, n]
+ else:
+ alias = None
+ self.counter_sigs[sig] = f.name
+
+ self.common_func_print_just_header(f)
+
+ for p in params:
+ self.common_emit_one_arg(p, "pc", " ", 0 )
+
+
+ print ''
+ self.common_emit_fixups(fixup)
+ print ''
+
+ print ' return __GLX_PAD(%s);' % (size)
+ print '}'
+ print ''
+
+ return alias
+
+
+def show_usage():
+ print "Usage: %s [-f input_file_name] -m output_mode [--only-get | --only-set] [--get-alias-set]" % sys.argv[0]
+ print " -m output_mode Output mode can be one of 'size_c' or 'size_h'."
+ print " --only-get Only emit 'get'-type functions."
+ print " --only-set Only emit 'set'-type functions."
+ print ""
+ print "By default, both 'get' and 'set'-type functions are emitted."
+ sys.exit(1)
+
+
+if __name__ == '__main__':
+ file_name = "gl_API.xml"
+
+ try:
+ (args, trail) = getopt.getopt(sys.argv[1:], "f:m:h:", ["only-get", "only-set", "header-tag"])
+ except Exception,e:
+ show_usage()
+
+ mode = None
+ header_tag = None
+ which_functions = PrintGlxSizeStubs_common.do_get | PrintGlxSizeStubs_common.do_set
+
+ for (arg,val) in args:
+ if arg == "-f":
+ file_name = val
+ elif arg == "-m":
+ mode = val
+ elif arg == "--only-get":
+ which_functions = PrintGlxSizeStubs_common.do_get
+ elif arg == "--only-set":
+ which_functions = PrintGlxSizeStubs_common.do_set
+ elif (arg == '-h') or (arg == "--header-tag"):
+ header_tag = val
+
+ if mode == "size_c":
+ printer = PrintGlxSizeStubs_c( which_functions )
+ elif mode == "size_h":
+ printer = PrintGlxSizeStubs_h( which_functions )
+ if header_tag:
+ printer.header_tag = header_tag
+ elif mode == "reqsize_c":
+ printer = PrintGlxReqSize_c()
+ elif mode == "reqsize_h":
+ printer = PrintGlxReqSize_h()
+ else:
+ show_usage()
+
+ api = gl_XML.parse_GL_API( file_name, glX_XML.glx_item_factory() )
+
+
+ printer.Print( api )
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/gl_API.dtd b/nx-X11/extras/Mesa/src/mesa/glapi/gl_API.dtd
new file mode 100644
index 000000000..ded487bc9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/gl_API.dtd
@@ -0,0 +1,134 @@
+<!ELEMENT OpenGLAPI (category?, xi:include?, OpenGLAPI?)+>
+<!ELEMENT category (type*, enum*, function*)*>
+<!ELEMENT type EMPTY>
+<!ELEMENT enum (size*)>
+<!ELEMENT size EMPTY>
+<!ELEMENT function (param*, return?, glx?)*>
+<!ELEMENT param EMPTY>
+<!ELEMENT return EMPTY>
+<!ELEMENT glx EMPTY>
+
+<!ELEMENT xi:include (xi:fallback)?>
+<!ATTLIST xi:include
+ xmlns:xi CDATA #FIXED "http://www.w3.org/2001/XInclude"
+ href CDATA #REQUIRED
+ parse (xml|text) "xml"
+ encoding CDATA #IMPLIED>
+<!ELEMENT xi:fallback ANY>
+<!ATTLIST xi:fallback
+ xmlns:xi CDATA #FIXED "http://www.w3.org/2001/XInclude">
+
+
+<!ATTLIST category name NMTOKEN #REQUIRED
+ number NMTOKEN #IMPLIED
+ window_system NMTOKEN #IMPLIED>
+<!ATTLIST type name NMTOKEN #REQUIRED
+ size NMTOKEN #REQUIRED
+ float (true | false) "false"
+ unsigned (true | false) "false"
+ glx_name NMTOKEN #IMPLIED>
+<!ATTLIST enum name NMTOKEN #REQUIRED
+ count CDATA #IMPLIED
+ value NMTOKEN #REQUIRED>
+<!ATTLIST function name NMTOKEN #REQUIRED
+ alias NMTOKEN #IMPLIED
+ offset CDATA #IMPLIED
+ vectorequiv NMTOKEN #IMPLIED>
+<!ATTLIST size name NMTOKEN #REQUIRED
+ count NMTOKEN #IMPLIED
+ mode (get | set) "set">
+<!ATTLIST param name NMTOKEN #REQUIRED
+ type CDATA #REQUIRED
+ count NMTOKEN #IMPLIED
+ counter (true | false) "false"
+ count_scale NMTOKEN "1"
+ output (true | false) "false"
+ img_width NMTOKEN #IMPLIED
+ img_height NMTOKEN #IMPLIED
+ img_depth NMTOKEN #IMPLIED
+ img_extent NMTOKEN #IMPLIED
+ img_xoff NMTOKEN #IMPLIED
+ img_yoff NMTOKEN #IMPLIED
+ img_zoff NMTOKEN #IMPLIED
+ img_woff NMTOKEN #IMPLIED
+ img_format NMTOKEN #IMPLIED
+ img_type NMTOKEN #IMPLIED
+ img_target NMTOKEN #IMPLIED
+ img_send_null (true | false) "false"
+ img_null_flag (true | false) "false"
+ img_pad_dimensions (true | false) "false"
+ variable_param NMTOKENS #IMPLIED>
+<!ATTLIST return type CDATA "void">
+<!ATTLIST glx rop NMTOKEN #IMPLIED
+ sop NMTOKEN #IMPLIED
+ vendorpriv NMTOKEN #IMPLIED
+ large (true | false) "false"
+ doubles_in_order (true | false) "false"
+ always_array (true | false) "false"
+ handcode (true | false | client | server) "false"
+ img_reset NMTOKEN #IMPLIED
+ dimensions_in_reply (true | false) "false"
+ ignore (true | false) "false">
+
+<!--
+The various attributes for param and glx have the meanings listed below.
+When adding new functions, please annote them correctly. In most cases this
+will just mean adding a '<glx ignore="true"/>' tag.
+
+param:
+ name - name of the parameter
+ type - fully qualified type (e.g., with "const", etc.)
+ count - for counted arrays (e.g., the 'lists' parameter to glCallLists),
+ the parameter or literal that represents the count. For functions
+ like glVertex3fv it will be a litteral, for others it will be one of
+ the parameters.
+ counter - this parameter is a counter that will be referenced by the
+ 'count' attribute in another parameter.
+ count_scale - literal value scale factor for the 'count' attribute.
+ See ProgramParameters4dvNV for an example.
+ output - this parameter is used to store the output of the function.
+ variable_param - name of parameter used to determine the number of
+ elements referenced by this parameter. This should be the name of a
+ single enum parameter. Most of the gl*Parameter[if]v functions use
+ this. Additionally, the enums that can be passed should be properly
+ annotated.
+ img_width / img_height / img_depth / img_extent - name of parameters
+ (or hardcoded integer) used for the dimensions of pixel data.
+ img_xoff / img_yoff / img_zoff / img_woff - name of parameters used
+ for x, y, z, and w offsets of pixel data.
+ img_format - name of parameter used as the pixel data format.
+ img_type - name of parameter used as the pixel data type.
+ img_target - name of parameter used as a texture target. Non-texture
+ pixel data should hardcode 0.
+ img_send_null - boolean flag to determine if blank pixel data should
+ be sent when a NULL pointer is passed. This is only used by
+ TexImage1D and TexImage2D.
+ img_null_flag - boolean flag to determine if an extra flag is used to
+ determine if a NULL pixel pointer was passed. This is used by
+ TexSubImage1D, TexSubImage2D, TexImage3D and others.
+ img_pad_dimensions - boolean flag to determine if dimension data and
+ offset data should be padded to the next even number of dimensions.
+ For example, this will insert an empty "height" field after the
+ "width" field in the protocol for TexImage1D.
+
+glx:
+ rop - Opcode value for "render" commands
+ sop - Opcode value for "single" commands
+ vendorpriv - Opcode value for vendor private (or vendor private with
+ reply) commands
+ large - set to "true" of the render command can use RenderLarge protocol.
+ doubles_in_order - older commands always put GLdouble data at the
+ start of the render packet. Newer commands (e.g.,
+ ProgramEnvParameter4dvARB) put the in the order that they appear
+ in the parameter list.
+ always_array - some single commands take reply data as an array or as
+ return value data (e.g., glGetLightfv). Other single commands take
+ reply data only as an array (e.g., glGetClipPlane).
+ handcode - some functions are just too complicated to generate
+ (e.g., glSeperableFilter2D) or operate only on client-side data
+ (e.g., glVertexPointer) and must be handcoded.
+ ignore - some functions have an entry in the dispatch table, but aren't
+ suitable for protocol implementation (e.g., glLockArraysEXT). This
+ also applies to functions that don't have any GLX protocol specified
+ (e.g., glGetFogFuncSGIS).
+-->
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/gl_API.xml b/nx-X11/extras/Mesa/src/mesa/glapi/gl_API.xml
new file mode 100644
index 000000000..4f9d8c474
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/gl_API.xml
@@ -0,0 +1,11485 @@
+<?xml version="1.0"?>
+<!DOCTYPE OpenGLAPI SYSTEM "gl_API.dtd">
+
+<OpenGLAPI>
+
+<!-- Core versions sorted by version number. -->
+
+<category name="1.0">
+ <enum name="FALSE" value="0x0"/>
+ <enum name="TRUE" value="0x1"/>
+ <enum name="ZERO" value="0x0"/>
+ <enum name="ONE" value="0x1"/>
+ <enum name="NONE" value="0x0"/>
+ <enum name="NO_ERROR" value="0x0"/>
+ <enum name="POINTS" value="0x0000"/>
+ <enum name="LINES" value="0x0001"/>
+ <enum name="LINE_LOOP" value="0x0002"/>
+ <enum name="LINE_STRIP" value="0x0003"/>
+ <enum name="TRIANGLES" value="0x0004"/>
+ <enum name="TRIANGLE_STRIP" value="0x0005"/>
+ <enum name="TRIANGLE_FAN" value="0x0006"/>
+ <enum name="QUADS" value="0x0007"/>
+ <enum name="QUAD_STRIP" value="0x0008"/>
+ <enum name="POLYGON" value="0x0009"/>
+ <enum name="ACCUM" value="0x0100"/>
+ <enum name="LOAD" value="0x0101"/>
+ <enum name="RETURN" value="0x0102"/>
+ <enum name="MULT" value="0x0103"/>
+ <enum name="ADD" value="0x0104"/>
+ <enum name="NEVER" value="0x0200"/>
+ <enum name="LESS" value="0x0201"/>
+ <enum name="EQUAL" value="0x0202"/>
+ <enum name="LEQUAL" value="0x0203"/>
+ <enum name="GREATER" value="0x0204"/>
+ <enum name="NOTEQUAL" value="0x0205"/>
+ <enum name="GEQUAL" value="0x0206"/>
+ <enum name="ALWAYS" value="0x0207"/>
+ <enum name="SRC_COLOR" value="0x0300"/>
+ <enum name="ONE_MINUS_SRC_COLOR" value="0x0301"/>
+ <enum name="SRC_ALPHA" value="0x0302"/>
+ <enum name="ONE_MINUS_SRC_ALPHA" value="0x0303"/>
+ <enum name="DST_ALPHA" value="0x0304"/>
+ <enum name="ONE_MINUS_DST_ALPHA" value="0x0305"/>
+ <enum name="DST_COLOR" value="0x0306"/>
+ <enum name="ONE_MINUS_DST_COLOR" value="0x0307"/>
+ <enum name="SRC_ALPHA_SATURATE" value="0x0308"/>
+ <enum name="FRONT_LEFT" value="0x0400"/>
+ <enum name="FRONT_RIGHT" value="0x0401"/>
+ <enum name="BACK_LEFT" value="0x0402"/>
+ <enum name="BACK_RIGHT" value="0x0403"/>
+ <enum name="FRONT" value="0x0404"/>
+ <enum name="BACK" value="0x0405"/>
+ <enum name="LEFT" value="0x0406"/>
+ <enum name="RIGHT" value="0x0407"/>
+ <enum name="FRONT_AND_BACK" value="0x0408"/>
+ <enum name="AUX0" value="0x0409"/>
+ <enum name="AUX1" value="0x040A"/>
+ <enum name="AUX2" value="0x040B"/>
+ <enum name="AUX3" value="0x040C"/>
+ <enum name="INVALID_VALUE" value="0x0501"/>
+ <enum name="INVALID_ENUM" value="0x0500"/>
+ <enum name="INVALID_OPERATION" value="0x0502"/>
+ <enum name="STACK_OVERFLOW" value="0x0503"/>
+ <enum name="STACK_UNDERFLOW" value="0x0504"/>
+ <enum name="OUT_OF_MEMORY" value="0x0505"/>
+ <enum name="2D" value="0x0600"/>
+ <enum name="3D" value="0x0601"/>
+ <enum name="3D_COLOR" value="0x0602"/>
+ <enum name="3D_COLOR_TEXTURE" value="0x0603"/>
+ <enum name="4D_COLOR_TEXTURE" value="0x0604"/>
+ <enum name="PASS_THROUGH_TOKEN" value="0x0700"/>
+ <enum name="POINT_TOKEN" value="0x0701"/>
+ <enum name="LINE_TOKEN" value="0x0702"/>
+ <enum name="POLYGON_TOKEN" value="0x0703"/>
+ <enum name="BITMAP_TOKEN" value="0x0704"/>
+ <enum name="DRAW_PIXEL_TOKEN" value="0x0705"/>
+ <enum name="COPY_PIXEL_TOKEN" value="0x0706"/>
+ <enum name="LINE_RESET_TOKEN" value="0x0707"/>
+ <enum name="EXP" value="0x0800"/>
+ <enum name="EXP2" value="0x0801"/>
+ <enum name="CW" value="0x0900"/>
+ <enum name="CCW" value="0x0901"/>
+ <enum name="COEFF" value="0x0A00"/>
+ <enum name="ORDER" value="0x0A01"/>
+ <enum name="DOMAIN" value="0x0A02"/>
+ <enum name="CURRENT_COLOR" count="4" value="0x0B00">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CURRENT_INDEX" count="1" value="0x0B01">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CURRENT_NORMAL" count="3" value="0x0B02">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CURRENT_TEXTURE_COORDS" count="4" value="0x0B03">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CURRENT_RASTER_COLOR" count="4" value="0x0B04">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CURRENT_RASTER_INDEX" count="1" value="0x0B05">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CURRENT_RASTER_TEXTURE_COORDS" count="4" value="0x0B06">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CURRENT_RASTER_POSITION" count="4" value="0x0B07">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CURRENT_RASTER_POSITION_VALID" count="1" value="0x0B08">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CURRENT_RASTER_DISTANCE" count="1" value="0x0B09">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POINT_SMOOTH" count="1" value="0x0B10">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POINT_SIZE" count="1" value="0x0B11">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POINT_SIZE_RANGE" count="2" value="0x0B12">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POINT_SIZE_GRANULARITY" count="1" value="0x0B13">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LINE_SMOOTH" count="1" value="0x0B20">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LINE_WIDTH" count="1" value="0x0B21">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LINE_WIDTH_RANGE" count="2" value="0x0B22">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LINE_WIDTH_GRANULARITY" count="1" value="0x0B23">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LINE_STIPPLE" count="1" value="0x0B24">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LINE_STIPPLE_PATTERN" count="1" value="0x0B25">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LINE_STIPPLE_REPEAT" count="1" value="0x0B26">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LIST_MODE" count="1" value="0x0B30">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_LIST_NESTING" count="1" value="0x0B31">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LIST_BASE" count="1" value="0x0B32">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LIST_INDEX" count="1" value="0x0B33">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POLYGON_MODE" count="2" value="0x0B40">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POLYGON_SMOOTH" count="1" value="0x0B41">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POLYGON_STIPPLE" count="1" value="0x0B42">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="EDGE_FLAG" count="1" value="0x0B43">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CULL_FACE" count="1" value="0x0B44">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CULL_FACE_MODE" count="1" value="0x0B45">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FRONT_FACE" count="1" value="0x0B46">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LIGHTING" count="1" value="0x0B50">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LIGHT_MODEL_LOCAL_VIEWER" count="1" value="0x0B51">
+ <size name="LightModelfv"/>
+ <size name="LightModeliv"/>
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LIGHT_MODEL_TWO_SIDE" count="1" value="0x0B52">
+ <size name="LightModelfv"/>
+ <size name="LightModeliv"/>
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LIGHT_MODEL_AMBIENT" count="4" value="0x0B53">
+ <size name="LightModelfv"/>
+ <size name="LightModeliv"/>
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SHADE_MODEL" count="1" value="0x0B54">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="COLOR_MATERIAL_FACE" count="1" value="0x0B55">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="COLOR_MATERIAL_PARAMETER" count="1" value="0x0B56">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="COLOR_MATERIAL" count="1" value="0x0B57">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FOG" count="1" value="0x0B60">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FOG_INDEX" count="1" value="0x0B61">
+ <size name="Fogfv"/>
+ <size name="Fogiv"/>
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FOG_DENSITY" count="1" value="0x0B62">
+ <size name="Fogfv"/>
+ <size name="Fogiv"/>
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FOG_START" count="1" value="0x0B63">
+ <size name="Fogfv"/>
+ <size name="Fogiv"/>
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FOG_END" count="1" value="0x0B64">
+ <size name="Fogfv"/>
+ <size name="Fogiv"/>
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FOG_MODE" count="1" value="0x0B65">
+ <size name="Fogfv"/>
+ <size name="Fogiv"/>
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FOG_COLOR" count="4" value="0x0B66">
+ <size name="Fogfv"/>
+ <size name="Fogiv"/>
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DEPTH_RANGE" count="2" value="0x0B70">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DEPTH_TEST" count="1" value="0x0B71">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DEPTH_WRITEMASK" count="1" value="0x0B72">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DEPTH_CLEAR_VALUE" count="1" value="0x0B73">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DEPTH_FUNC" count="1" value="0x0B74">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="ACCUM_CLEAR_VALUE" count="4" value="0x0B80">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="STENCIL_TEST" count="1" value="0x0B90">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="STENCIL_CLEAR_VALUE" count="1" value="0x0B91">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="STENCIL_FUNC" count="1" value="0x0B92">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="STENCIL_VALUE_MASK" count="1" value="0x0B93">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="STENCIL_FAIL" count="1" value="0x0B94">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="STENCIL_PASS_DEPTH_FAIL" count="1" value="0x0B95">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="STENCIL_PASS_DEPTH_PASS" count="1" value="0x0B96">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="STENCIL_REF" count="1" value="0x0B97">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="STENCIL_WRITEMASK" count="1" value="0x0B98">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MATRIX_MODE" count="1" value="0x0BA0">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="NORMALIZE" count="1" value="0x0BA1">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="VIEWPORT" count="4" value="0x0BA2">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW_STACK_DEPTH" count="1" value="0x0BA3">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PROJECTION_STACK_DEPTH" count="1" value="0x0BA4">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_STACK_DEPTH" count="1" value="0x0BA5">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW_MATRIX" count="16" value="0x0BA6">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PROJECTION_MATRIX" count="16" value="0x0BA7">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_MATRIX" count="16" value="0x0BA8">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="ATTRIB_STACK_DEPTH" count="1" value="0x0BB0">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CLIENT_ATTRIB_STACK_DEPTH" value="0x0BB1"/>
+ <enum name="ALPHA_TEST" count="1" value="0x0BC0">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="ALPHA_TEST_FUNC" count="1" value="0x0BC1">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="ALPHA_TEST_REF" count="1" value="0x0BC2">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DITHER" count="1" value="0x0BD0">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="BLEND_DST" count="1" value="0x0BE0">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="BLEND_SRC" count="1" value="0x0BE1">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="BLEND" count="1" value="0x0BE2">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LOGIC_OP_MODE" count="1" value="0x0BF0">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LOGIC_OP" count="1" value="0x0BF1">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="AUX_BUFFERS" count="1" value="0x0C00">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER" count="1" value="0x0C01">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="READ_BUFFER" count="1" value="0x0C02">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SCISSOR_BOX" count="4" value="0x0C10">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SCISSOR_TEST" count="1" value="0x0C11">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="INDEX_CLEAR_VALUE" count="1" value="0x0C20">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="INDEX_WRITEMASK" count="1" value="0x0C21">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="COLOR_CLEAR_VALUE" count="4" value="0x0C22">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="COLOR_WRITEMASK" count="4" value="0x0C23">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="INDEX_MODE" count="1" value="0x0C30">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="RGBA_MODE" count="1" value="0x0C31">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DOUBLEBUFFER" count="1" value="0x0C32">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="STEREO" count="1" value="0x0C33">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="RENDER_MODE" count="1" value="0x0C40">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PERSPECTIVE_CORRECTION_HINT" count="1" value="0x0C50">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POINT_SMOOTH_HINT" count="1" value="0x0C51">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LINE_SMOOTH_HINT" count="1" value="0x0C52">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POLYGON_SMOOTH_HINT" count="1" value="0x0C53">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FOG_HINT" count="1" value="0x0C54">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_GEN_S" count="1" value="0x0C60">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_GEN_T" count="1" value="0x0C61">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_GEN_R" count="1" value="0x0C62">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_GEN_Q" count="1" value="0x0C63">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PIXEL_MAP_I_TO_I" count="1" value="0x0C70">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PIXEL_MAP_S_TO_S" value="0x0C71"/>
+ <enum name="PIXEL_MAP_I_TO_R" value="0x0C72"/>
+ <enum name="PIXEL_MAP_I_TO_G" value="0x0C73"/>
+ <enum name="PIXEL_MAP_I_TO_B" value="0x0C74"/>
+ <enum name="PIXEL_MAP_I_TO_A" value="0x0C75"/>
+ <enum name="PIXEL_MAP_R_TO_R" value="0x0C76"/>
+ <enum name="PIXEL_MAP_G_TO_G" value="0x0C77"/>
+ <enum name="PIXEL_MAP_B_TO_B" value="0x0C78"/>
+ <enum name="PIXEL_MAP_A_TO_A" value="0x0C79"/>
+ <enum name="PIXEL_MAP_I_TO_I_SIZE" count="1" value="0x0CB0">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PIXEL_MAP_S_TO_S_SIZE" count="1" value="0x0CB1">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PIXEL_MAP_I_TO_R_SIZE" count="1" value="0x0CB2">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PIXEL_MAP_I_TO_G_SIZE" count="1" value="0x0CB3">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PIXEL_MAP_I_TO_B_SIZE" count="1" value="0x0CB4">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PIXEL_MAP_I_TO_A_SIZE" count="1" value="0x0CB5">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PIXEL_MAP_R_TO_R_SIZE" count="1" value="0x0CB6">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PIXEL_MAP_G_TO_G_SIZE" count="1" value="0x0CB7">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PIXEL_MAP_B_TO_B_SIZE" count="1" value="0x0CB8">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PIXEL_MAP_A_TO_A_SIZE" count="1" value="0x0CB9">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="UNPACK_SWAP_BYTES" count="1" value="0x0CF0">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="UNPACK_LSB_FIRST" count="1" value="0x0CF1">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="UNPACK_ROW_LENGTH" count="1" value="0x0CF2">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="UNPACK_SKIP_PIXELS" count="1" value="0x0CF4">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="UNPACK_SKIP_ROWS" count="1" value="0x0CF3">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="UNPACK_ALIGNMENT" count="1" value="0x0CF5">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PACK_SWAP_BYTES" count="1" value="0x0D00">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PACK_LSB_FIRST" count="1" value="0x0D01">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PACK_ROW_LENGTH" count="1" value="0x0D02">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PACK_SKIP_ROWS" count="1" value="0x0D03">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PACK_SKIP_PIXELS" count="1" value="0x0D04">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PACK_ALIGNMENT" count="1" value="0x0D05">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAP_COLOR" count="1" value="0x0D10">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAP_STENCIL" count="1" value="0x0D11">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="INDEX_SHIFT" count="1" value="0x0D12">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="INDEX_OFFSET" count="1" value="0x0D13">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="RED_SCALE" count="1" value="0x0D14">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="RED_BIAS" count="1" value="0x0D15">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="ZOOM_X" count="1" value="0x0D16">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="ZOOM_Y" count="1" value="0x0D17">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="GREEN_SCALE" count="1" value="0x0D18">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="GREEN_BIAS" count="1" value="0x0D19">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="BLUE_SCALE" count="1" value="0x0D1A">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="BLUE_BIAS" count="1" value="0x0D1B">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="ALPHA_SCALE" count="1" value="0x0D1C">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="ALPHA_BIAS" count="1" value="0x0D1D">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DEPTH_SCALE" count="1" value="0x0D1E">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DEPTH_BIAS" count="1" value="0x0D1F">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_EVAL_ORDER" count="1" value="0x0D30">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_LIGHTS" count="1" value="0x0D31">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_CLIP_PLANES" count="1" value="0x0D32">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_TEXTURE_SIZE" count="1" value="0x0D33">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_PIXEL_MAP_TABLE" count="1" value="0x0D34">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_ATTRIB_STACK_DEPTH" count="1" value="0x0D35">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_MODELVIEW_STACK_DEPTH" count="1" value="0x0D36">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_NAME_STACK_DEPTH" count="1" value="0x0D37">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_PROJECTION_STACK_DEPTH" count="1" value="0x0D38">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_TEXTURE_STACK_DEPTH" count="1" value="0x0D39">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_VIEWPORT_DIMS" count="2" value="0x0D3A">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_CLIENT_ATTRIB_STACK_DEPTH" value="0x0D3B"/>
+ <enum name="SUBPIXEL_BITS" count="1" value="0x0D50">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="INDEX_BITS" count="1" value="0x0D51">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="RED_BITS" count="1" value="0x0D52">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="GREEN_BITS" count="1" value="0x0D53">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="BLUE_BITS" count="1" value="0x0D54">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="ALPHA_BITS" count="1" value="0x0D55">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DEPTH_BITS" count="1" value="0x0D56">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="STENCIL_BITS" count="1" value="0x0D57">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="ACCUM_RED_BITS" count="1" value="0x0D58">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="ACCUM_GREEN_BITS" count="1" value="0x0D59">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="ACCUM_BLUE_BITS" count="1" value="0x0D5A">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="ACCUM_ALPHA_BITS" count="1" value="0x0D5B">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="NAME_STACK_DEPTH" count="1" value="0x0D70">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="AUTO_NORMAL" count="1" value="0x0D80">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAP1_COLOR_4" count="4" value="0x0D90">
+ <size name="Map1d"/>
+ <size name="Map1f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP1_INDEX" count="1" value="0x0D91">
+ <size name="Map1d"/>
+ <size name="Map1f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP1_NORMAL" count="3" value="0x0D92">
+ <size name="Map1d"/>
+ <size name="Map1f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP1_TEXTURE_COORD_1" count="1" value="0x0D93">
+ <size name="Map1d"/>
+ <size name="Map1f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP1_TEXTURE_COORD_2" count="2" value="0x0D94">
+ <size name="Map1d"/>
+ <size name="Map1f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP1_TEXTURE_COORD_3" count="3" value="0x0D95">
+ <size name="Map1d"/>
+ <size name="Map1f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP1_TEXTURE_COORD_4" count="4" value="0x0D96">
+ <size name="Map1d"/>
+ <size name="Map1f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP1_VERTEX_3" count="3" value="0x0D97">
+ <size name="Map1d"/>
+ <size name="Map1f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP1_VERTEX_4" count="4" value="0x0D98">
+ <size name="Map1d"/>
+ <size name="Map1f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP2_COLOR_4" count="4" value="0x0DB0">
+ <size name="Map2d"/>
+ <size name="Map2f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP2_INDEX" count="1" value="0x0DB1">
+ <size name="Map2d"/>
+ <size name="Map2f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP2_NORMAL" count="3" value="0x0DB2">
+ <size name="Map2d"/>
+ <size name="Map2f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP2_TEXTURE_COORD_1" count="1" value="0x0DB3">
+ <size name="Map2d"/>
+ <size name="Map2f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP2_TEXTURE_COORD_2" count="2" value="0x0DB4">
+ <size name="Map2d"/>
+ <size name="Map2f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP2_TEXTURE_COORD_3" count="3" value="0x0DB5">
+ <size name="Map2d"/>
+ <size name="Map2f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP2_TEXTURE_COORD_4" count="4" value="0x0DB6">
+ <size name="Map2d"/>
+ <size name="Map2f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP2_VERTEX_3" count="3" value="0x0DB7">
+ <size name="Map2d"/>
+ <size name="Map2f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP2_VERTEX_4" count="4" value="0x0DB8">
+ <size name="Map2d"/>
+ <size name="Map2f"/>
+ <size name="Get" count="1" mode="get"/>
+ </enum>
+ <enum name="MAP1_GRID_DOMAIN" count="2" value="0x0DD0">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAP1_GRID_SEGMENTS" count="1" value="0x0DD1">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAP2_GRID_DOMAIN" count="4" value="0x0DD2">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAP2_GRID_SEGMENTS" count="2" value="0x0DD3">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_1D" count="1" value="0x0DE0">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_2D" count="1" value="0x0DE1">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FEEDBACK_BUFFER_POINTER" value="0x0DF0"/>
+ <enum name="FEEDBACK_BUFFER_SIZE" value="0x0DF1"/>
+ <enum name="FEEDBACK_BUFFER_TYPE" value="0x0DF2"/>
+ <enum name="SELECTION_BUFFER_POINTER" value="0x0DF3"/>
+ <enum name="SELECTION_BUFFER_SIZE" value="0x0DF4"/>
+ <enum name="TEXTURE_WIDTH" count="1" value="0x1000">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_HEIGHT" count="1" value="0x1001">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_BORDER" count="1" value="0x1005">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_COMPONENTS" count="1" value="0x1003">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_BORDER_COLOR" count="4" value="0x1004">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="DONT_CARE" value="0x1100"/>
+ <enum name="FASTEST" value="0x1101"/>
+ <enum name="NICEST" value="0x1102"/>
+ <enum name="AMBIENT" count="4" value="0x1200">
+ <size name="Materialfv"/>
+ <size name="Materialiv"/>
+ <size name="Lightfv"/>
+ <size name="Lightiv"/>
+ <size name="GetMaterialfv" mode="get"/>
+ <size name="GetMaterialiv" mode="get"/>
+ <size name="GetLightfv" mode="get"/>
+ <size name="GetLightiv" mode="get"/>
+ </enum>
+ <enum name="DIFFUSE" count="4" value="0x1201">
+ <size name="Materialfv"/>
+ <size name="Materialiv"/>
+ <size name="Lightfv"/>
+ <size name="Lightiv"/>
+ <size name="GetMaterialfv" mode="get"/>
+ <size name="GetMaterialiv" mode="get"/>
+ <size name="GetLightfv" mode="get"/>
+ <size name="GetLightiv" mode="get"/>
+ </enum>
+ <enum name="SPECULAR" count="4" value="0x1202">
+ <size name="Materialfv"/>
+ <size name="Materialiv"/>
+ <size name="Lightfv"/>
+ <size name="Lightiv"/>
+ <size name="GetMaterialfv" mode="get"/>
+ <size name="GetMaterialiv" mode="get"/>
+ <size name="GetLightfv" mode="get"/>
+ <size name="GetLightiv" mode="get"/>
+ </enum>
+ <enum name="POSITION" count="4" value="0x1203">
+ <size name="Lightfv"/>
+ <size name="Lightiv"/>
+ <size name="GetLightfv" mode="get"/>
+ <size name="GetLightiv" mode="get"/>
+ </enum>
+ <enum name="SPOT_DIRECTION" count="3" value="0x1204">
+ <size name="Lightfv"/>
+ <size name="Lightiv"/>
+ <size name="GetLightfv" mode="get"/>
+ <size name="GetLightiv" mode="get"/>
+ </enum>
+ <enum name="SPOT_EXPONENT" count="1" value="0x1205">
+ <size name="Lightfv"/>
+ <size name="Lightiv"/>
+ <size name="GetLightfv" mode="get"/>
+ <size name="GetLightiv" mode="get"/>
+ </enum>
+ <enum name="SPOT_CUTOFF" count="1" value="0x1206">
+ <size name="Lightfv"/>
+ <size name="Lightiv"/>
+ <size name="GetLightfv" mode="get"/>
+ <size name="GetLightiv" mode="get"/>
+ </enum>
+ <enum name="CONSTANT_ATTENUATION" count="1" value="0x1207">
+ <size name="Lightfv"/>
+ <size name="Lightiv"/>
+ <size name="GetLightfv" mode="get"/>
+ <size name="GetLightiv" mode="get"/>
+ </enum>
+ <enum name="LINEAR_ATTENUATION" count="1" value="0x1208">
+ <size name="Lightfv"/>
+ <size name="Lightiv"/>
+ <size name="GetLightfv" mode="get"/>
+ <size name="GetLightiv" mode="get"/>
+ </enum>
+ <enum name="QUADRATIC_ATTENUATION" count="1" value="0x1209">
+ <size name="Lightfv"/>
+ <size name="Lightiv"/>
+ <size name="GetLightfv" mode="get"/>
+ <size name="GetLightiv" mode="get"/>
+ </enum>
+ <enum name="COMPILE" value="0x1300"/>
+ <enum name="COMPILE_AND_EXECUTE" value="0x1301"/>
+ <enum name="BYTE" count="1" value="0x1400">
+ <size name="CallLists"/>
+ </enum>
+ <enum name="UNSIGNED_BYTE" count="1" value="0x1401">
+ <size name="CallLists"/>
+ </enum>
+ <enum name="SHORT" count="2" value="0x1402">
+ <size name="CallLists"/>
+ </enum>
+ <enum name="UNSIGNED_SHORT" count="2" value="0x1403">
+ <size name="CallLists"/>
+ </enum>
+ <enum name="INT" count="4" value="0x1404">
+ <size name="CallLists"/>
+ </enum>
+ <enum name="UNSIGNED_INT" count="4" value="0x1405">
+ <size name="CallLists"/>
+ </enum>
+ <enum name="FLOAT" count="4" value="0x1406">
+ <size name="CallLists"/>
+ </enum>
+ <enum name="2_BYTES" count="2" value="0x1407">
+ <size name="CallLists"/>
+ </enum>
+ <enum name="3_BYTES" count="3" value="0x1408">
+ <size name="CallLists"/>
+ </enum>
+ <enum name="4_BYTES" count="4" value="0x1409">
+ <size name="CallLists"/>
+ </enum>
+ <enum name="CLEAR" value="0x1500"/>
+ <enum name="AND" value="0x1501"/>
+ <enum name="AND_REVERSE" value="0x1502"/>
+ <enum name="COPY" value="0x1503"/>
+ <enum name="AND_INVERTED" value="0x1504"/>
+ <enum name="NOOP" value="0x1505"/>
+ <enum name="XOR" value="0x1506"/>
+ <enum name="OR" value="0x1507"/>
+ <enum name="NOR" value="0x1508"/>
+ <enum name="EQUIV" value="0x1509"/>
+ <enum name="INVERT" value="0x150A"/>
+ <enum name="OR_REVERSE" value="0x150B"/>
+ <enum name="COPY_INVERTED" value="0x150C"/>
+ <enum name="OR_INVERTED" value="0x150D"/>
+ <enum name="NAND" value="0x150E"/>
+ <enum name="SET" value="0x150F"/>
+ <enum name="EMISSION" count="4" value="0x1600">
+ <size name="Materialfv"/>
+ <size name="Materialiv"/>
+ <size name="GetMaterialfv" mode="get"/>
+ <size name="GetMaterialiv" mode="get"/>
+ </enum>
+ <enum name="SHININESS" count="1" value="0x1601">
+ <size name="Materialfv"/>
+ <size name="Materialiv"/>
+ <size name="GetMaterialfv" mode="get"/>
+ <size name="GetMaterialiv" mode="get"/>
+ </enum>
+ <enum name="AMBIENT_AND_DIFFUSE" count="4" value="0x1602">
+ <size name="Materialfv"/>
+ <size name="Materialiv"/>
+ <size name="GetMaterialfv" mode="get"/>
+ <size name="GetMaterialiv" mode="get"/>
+ </enum>
+ <enum name="COLOR_INDEXES" count="3" value="0x1603">
+ <size name="Materialfv"/>
+ <size name="Materialiv"/>
+ <size name="GetMaterialfv" mode="get"/>
+ <size name="GetMaterialiv" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW" value="0x1700"/>
+ <enum name="PROJECTION" value="0x1701"/>
+ <enum name="TEXTURE" value="0x1702"/>
+ <enum name="COLOR" value="0x1800"/>
+ <enum name="DEPTH" value="0x1801"/>
+ <enum name="STENCIL" value="0x1802"/>
+ <enum name="COLOR_INDEX" value="0x1900"/>
+ <enum name="STENCIL_INDEX" value="0x1901"/>
+ <enum name="DEPTH_COMPONENT" value="0x1902"/>
+ <enum name="RED" value="0x1903"/>
+ <enum name="GREEN" value="0x1904"/>
+ <enum name="BLUE" value="0x1905"/>
+ <enum name="ALPHA" value="0x1906"/>
+ <enum name="RGBA" value="0x1908"/>
+ <enum name="RGB" value="0x1907"/>
+ <enum name="LUMINANCE" value="0x1909"/>
+ <enum name="LUMINANCE_ALPHA" value="0x190A"/>
+ <enum name="BITMAP" value="0x1A00"/>
+ <enum name="POINT" value="0x1B00"/>
+ <enum name="LINE" value="0x1B01"/>
+ <enum name="FILL" value="0x1B02"/>
+ <enum name="FEEDBACK" value="0x1C01"/>
+ <enum name="RENDER" value="0x1C00"/>
+ <enum name="SELECT" value="0x1C02"/>
+ <enum name="FLAT" value="0x1D00"/>
+ <enum name="SMOOTH" value="0x1D01"/>
+ <enum name="KEEP" value="0x1E00"/>
+ <enum name="REPLACE" value="0x1E01"/>
+ <enum name="INCR" value="0x1E02"/>
+ <enum name="DECR" value="0x1E03"/>
+ <enum name="VENDOR" value="0x1F00"/>
+ <enum name="RENDERER" value="0x1F01"/>
+ <enum name="VERSION" value="0x1F02"/>
+ <enum name="EXTENSIONS" value="0x1F03"/>
+ <enum name="S" value="0x2000"/>
+ <enum name="T" value="0x2001"/>
+ <enum name="R" value="0x2002"/>
+ <enum name="Q" value="0x2003"/>
+ <enum name="MODULATE" value="0x2100"/>
+ <enum name="DECAL" value="0x2101"/>
+ <enum name="TEXTURE_ENV_MODE" count="1" value="0x2200">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_ENV_COLOR" count="4" value="0x2201">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_ENV" value="0x2300"/>
+ <enum name="EYE_LINEAR" value="0x2400"/>
+ <enum name="OBJECT_LINEAR" value="0x2401"/>
+ <enum name="SPHERE_MAP" value="0x2402"/>
+ <enum name="TEXTURE_GEN_MODE" count="1" value="0x2500">
+ <size name="TexGendv"/>
+ <size name="TexGenfv"/>
+ <size name="TexGeniv"/>
+ <size name="GetTexGendv" mode="get"/>
+ <size name="GetTexGenfv" mode="get"/>
+ <size name="GetTexGeniv" mode="get"/>
+ </enum>
+ <enum name="OBJECT_PLANE" count="4" value="0x2501">
+ <size name="TexGendv"/>
+ <size name="TexGenfv"/>
+ <size name="TexGeniv"/>
+ <size name="GetTexGendv" mode="get"/>
+ <size name="GetTexGenfv" mode="get"/>
+ <size name="GetTexGeniv" mode="get"/>
+ </enum>
+ <enum name="EYE_PLANE" count="4" value="0x2502">
+ <size name="TexGendv"/>
+ <size name="TexGenfv"/>
+ <size name="TexGeniv"/>
+ <size name="GetTexGendv" mode="get"/>
+ <size name="GetTexGenfv" mode="get"/>
+ <size name="GetTexGeniv" mode="get"/>
+ </enum>
+ <enum name="NEAREST" value="0x2600"/>
+ <enum name="LINEAR" value="0x2601"/>
+ <enum name="NEAREST_MIPMAP_NEAREST" value="0x2700"/>
+ <enum name="LINEAR_MIPMAP_NEAREST" value="0x2701"/>
+ <enum name="NEAREST_MIPMAP_LINEAR" value="0x2702"/>
+ <enum name="LINEAR_MIPMAP_LINEAR" value="0x2703"/>
+ <enum name="TEXTURE_MAG_FILTER" count="1" value="0x2800">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_MIN_FILTER" count="1" value="0x2801">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_WRAP_S" count="1" value="0x2802">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_WRAP_T" count="1" value="0x2803">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="CLAMP" value="0x2900"/>
+ <enum name="REPEAT" value="0x2901"/>
+ <enum name="CLIP_PLANE0" count="1" value="0x3000">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CLIP_PLANE1" count="1" value="0x3001">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CLIP_PLANE2" count="1" value="0x3002">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CLIP_PLANE3" count="1" value="0x3003">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CLIP_PLANE4" count="1" value="0x3004">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CLIP_PLANE5" count="1" value="0x3005">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LIGHT0" count="1" value="0x4000">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LIGHT1" count="1" value="0x4001">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LIGHT2" count="1" value="0x4002">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LIGHT3" count="1" value="0x4003">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LIGHT4" count="1" value="0x4004">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LIGHT5" count="1" value="0x4005">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LIGHT6" count="1" value="0x4006">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="LIGHT7" count="1" value="0x4007">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CURRENT_BIT" value="0x00000001"/>
+ <enum name="POINT_BIT" value="0x00000002"/>
+ <enum name="LINE_BIT" value="0x00000004"/>
+ <enum name="POLYGON_BIT" value="0x00000008"/>
+ <enum name="POLYGON_STIPPLE_BIT" value="0x00000010"/>
+ <enum name="PIXEL_MODE_BIT" value="0x00000020"/>
+ <enum name="LIGHTING_BIT" value="0x00000040"/>
+ <enum name="FOG_BIT" value="0x00000080"/>
+ <enum name="DEPTH_BUFFER_BIT" value="0x00000100"/>
+ <enum name="ACCUM_BUFFER_BIT" value="0x00000200"/>
+ <enum name="STENCIL_BUFFER_BIT" value="0x00000400"/>
+ <enum name="VIEWPORT_BIT" value="0x00000800"/>
+ <enum name="TRANSFORM_BIT" value="0x00001000"/>
+ <enum name="ENABLE_BIT" value="0x00002000"/>
+ <enum name="COLOR_BUFFER_BIT" value="0x00004000"/>
+ <enum name="HINT_BIT" value="0x00008000"/>
+ <enum name="EVAL_BIT" value="0x00010000"/>
+ <enum name="LIST_BIT" value="0x00020000"/>
+ <enum name="TEXTURE_BIT" value="0x00040000"/>
+ <enum name="SCISSOR_BIT" value="0x00080000"/>
+ <enum name="ALL_ATTRIB_BITS" value="0x000FFFFF"/>
+
+ <type name="double" size="8" float="true" glx_name="FLOAT64"/>
+ <type name="clampd" size="8" float="true" glx_name="FLOAT64"/>
+
+ <type name="float" size="4" float="true" glx_name="FLOAT32"/>
+ <type name="clampf" size="4" float="true" glx_name="FLOAT32"/>
+
+ <type name="int" size="4" glx_name="CARD32"/>
+ <type name="uint" size="4" unsigned="true" glx_name="CARD32"/>
+ <type name="sizei" size="4" unsigned="true" glx_name="CARD32"/>
+ <type name="enum" size="4" unsigned="true" glx_name="ENUM"/>
+ <type name="bitfield" size="4" unsigned="true" glx_name="CARD32"/>
+
+ <type name="short" size="2" glx_name="CARD16"/>
+ <type name="ushort" size="2" unsigned="true" glx_name="CARD16"/>
+
+ <type name="byte" size="1" glx_name="CARD8"/>
+ <type name="ubyte" size="1" unsigned="true" glx_name="CARD8"/>
+ <type name="boolean" size="1" unsigned="true" glx_name="CARD8"/>
+
+ <type name="void" size="1"/>
+
+ <function name="NewList" offset="0">
+ <param name="list" type="GLuint"/>
+ <param name="mode" type="GLenum"/>
+ <glx sop="101"/>
+ </function>
+
+ <function name="EndList" offset="1">
+ <glx sop="102"/>
+ </function>
+
+ <function name="CallList" offset="2">
+ <param name="list" type="GLuint"/>
+ <glx rop="1"/>
+ </function>
+
+ <function name="CallLists" offset="3">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="type" type="GLenum"/>
+ <param name="lists" type="const GLvoid *" variable_param="type" count="n"/>
+ <glx rop="2" large="true"/>
+ </function>
+
+ <function name="DeleteLists" offset="4">
+ <param name="list" type="GLuint"/>
+ <param name="range" type="GLsizei"/>
+ <glx sop="103"/>
+ </function>
+
+ <function name="GenLists" offset="5">
+ <param name="range" type="GLsizei"/>
+ <return type="GLuint"/>
+ <glx sop="104"/>
+ </function>
+
+ <function name="ListBase" offset="6">
+ <param name="base" type="GLuint"/>
+ <glx rop="3"/>
+ </function>
+
+ <function name="Begin" offset="7">
+ <param name="mode" type="GLenum"/>
+ <glx rop="4"/>
+ </function>
+
+ <function name="Bitmap" offset="8">
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="xorig" type="GLfloat"/>
+ <param name="yorig" type="GLfloat"/>
+ <param name="xmove" type="GLfloat"/>
+ <param name="ymove" type="GLfloat"/>
+ <param name="bitmap" type="const GLubyte *" img_width="width" img_height="height" img_format="GL_COLOR_INDEX" img_type="GL_BITMAP" img_target="0" img_pad_dimensions="false"/>
+ <glx rop="5" large="true"/>
+ </function>
+
+ <function name="Color3b" offset="9" vectorequiv="Color3bv">
+ <param name="red" type="GLbyte"/>
+ <param name="green" type="GLbyte"/>
+ <param name="blue" type="GLbyte"/>
+ </function>
+
+ <function name="Color3bv" offset="10">
+ <param name="v" type="const GLbyte *" count="3"/>
+ <glx rop="6"/>
+ </function>
+
+ <function name="Color3d" offset="11" vectorequiv="Color3dv">
+ <param name="red" type="GLdouble"/>
+ <param name="green" type="GLdouble"/>
+ <param name="blue" type="GLdouble"/>
+ </function>
+
+ <function name="Color3dv" offset="12">
+ <param name="v" type="const GLdouble *" count="3"/>
+ <glx rop="7"/>
+ </function>
+
+ <function name="Color3f" offset="13" vectorequiv="Color3fv">
+ <param name="red" type="GLfloat"/>
+ <param name="green" type="GLfloat"/>
+ <param name="blue" type="GLfloat"/>
+ </function>
+
+ <function name="Color3fv" offset="14">
+ <param name="v" type="const GLfloat *" count="3"/>
+ <glx rop="8"/>
+ </function>
+
+ <function name="Color3i" offset="15" vectorequiv="Color3iv">
+ <param name="red" type="GLint"/>
+ <param name="green" type="GLint"/>
+ <param name="blue" type="GLint"/>
+ </function>
+
+ <function name="Color3iv" offset="16">
+ <param name="v" type="const GLint *" count="3"/>
+ <glx rop="9"/>
+ </function>
+
+ <function name="Color3s" offset="17" vectorequiv="Color3sv">
+ <param name="red" type="GLshort"/>
+ <param name="green" type="GLshort"/>
+ <param name="blue" type="GLshort"/>
+ </function>
+
+ <function name="Color3sv" offset="18">
+ <param name="v" type="const GLshort *" count="3"/>
+ <glx rop="10"/>
+ </function>
+
+ <function name="Color3ub" offset="19" vectorequiv="Color3ubv">
+ <param name="red" type="GLubyte"/>
+ <param name="green" type="GLubyte"/>
+ <param name="blue" type="GLubyte"/>
+ </function>
+
+ <function name="Color3ubv" offset="20">
+ <param name="v" type="const GLubyte *" count="3"/>
+ <glx rop="11"/>
+ </function>
+
+ <function name="Color3ui" offset="21" vectorequiv="Color3uiv">
+ <param name="red" type="GLuint"/>
+ <param name="green" type="GLuint"/>
+ <param name="blue" type="GLuint"/>
+ </function>
+
+ <function name="Color3uiv" offset="22">
+ <param name="v" type="const GLuint *" count="3"/>
+ <glx rop="12"/>
+ </function>
+
+ <function name="Color3us" offset="23" vectorequiv="Color3usv">
+ <param name="red" type="GLushort"/>
+ <param name="green" type="GLushort"/>
+ <param name="blue" type="GLushort"/>
+ </function>
+
+ <function name="Color3usv" offset="24">
+ <param name="v" type="const GLushort *" count="3"/>
+ <glx rop="13"/>
+ </function>
+
+ <function name="Color4b" offset="25" vectorequiv="Color4bv">
+ <param name="red" type="GLbyte"/>
+ <param name="green" type="GLbyte"/>
+ <param name="blue" type="GLbyte"/>
+ <param name="alpha" type="GLbyte"/>
+ </function>
+
+ <function name="Color4bv" offset="26">
+ <param name="v" type="const GLbyte *" count="4"/>
+ <glx rop="14"/>
+ </function>
+
+ <function name="Color4d" offset="27" vectorequiv="Color4dv">
+ <param name="red" type="GLdouble"/>
+ <param name="green" type="GLdouble"/>
+ <param name="blue" type="GLdouble"/>
+ <param name="alpha" type="GLdouble"/>
+ </function>
+
+ <function name="Color4dv" offset="28">
+ <param name="v" type="const GLdouble *" count="4"/>
+ <glx rop="15"/>
+ </function>
+
+ <function name="Color4f" offset="29" vectorequiv="Color4fv">
+ <param name="red" type="GLfloat"/>
+ <param name="green" type="GLfloat"/>
+ <param name="blue" type="GLfloat"/>
+ <param name="alpha" type="GLfloat"/>
+ </function>
+
+ <function name="Color4fv" offset="30">
+ <param name="v" type="const GLfloat *" count="4"/>
+ <glx rop="16"/>
+ </function>
+
+ <function name="Color4i" offset="31" vectorequiv="Color4iv">
+ <param name="red" type="GLint"/>
+ <param name="green" type="GLint"/>
+ <param name="blue" type="GLint"/>
+ <param name="alpha" type="GLint"/>
+ </function>
+
+ <function name="Color4iv" offset="32">
+ <param name="v" type="const GLint *" count="4"/>
+ <glx rop="17"/>
+ </function>
+
+ <function name="Color4s" offset="33" vectorequiv="Color4sv">
+ <param name="red" type="GLshort"/>
+ <param name="green" type="GLshort"/>
+ <param name="blue" type="GLshort"/>
+ <param name="alpha" type="GLshort"/>
+ </function>
+
+ <function name="Color4sv" offset="34">
+ <param name="v" type="const GLshort *" count="4"/>
+ <glx rop="18"/>
+ </function>
+
+ <function name="Color4ub" offset="35" vectorequiv="Color4ubv">
+ <param name="red" type="GLubyte"/>
+ <param name="green" type="GLubyte"/>
+ <param name="blue" type="GLubyte"/>
+ <param name="alpha" type="GLubyte"/>
+ </function>
+
+ <function name="Color4ubv" offset="36">
+ <param name="v" type="const GLubyte *" count="4"/>
+ <glx rop="19"/>
+ </function>
+
+ <function name="Color4ui" offset="37" vectorequiv="Color4uiv">
+ <param name="red" type="GLuint"/>
+ <param name="green" type="GLuint"/>
+ <param name="blue" type="GLuint"/>
+ <param name="alpha" type="GLuint"/>
+ </function>
+
+ <function name="Color4uiv" offset="38">
+ <param name="v" type="const GLuint *" count="4"/>
+ <glx rop="20"/>
+ </function>
+
+ <function name="Color4us" offset="39" vectorequiv="Color4usv">
+ <param name="red" type="GLushort"/>
+ <param name="green" type="GLushort"/>
+ <param name="blue" type="GLushort"/>
+ <param name="alpha" type="GLushort"/>
+ </function>
+
+ <function name="Color4usv" offset="40">
+ <param name="v" type="const GLushort *" count="4"/>
+ <glx rop="21"/>
+ </function>
+
+ <function name="EdgeFlag" offset="41" vectorequiv="EdgeFlagv">
+ <param name="flag" type="GLboolean"/>
+ </function>
+
+ <function name="EdgeFlagv" offset="42">
+ <param name="flag" type="const GLboolean *" count="1"/>
+ <glx rop="22"/>
+ </function>
+
+ <function name="End" offset="43">
+ <glx rop="23"/>
+ </function>
+
+ <function name="Indexd" offset="44" vectorequiv="Indexdv">
+ <param name="c" type="GLdouble"/>
+ </function>
+
+ <function name="Indexdv" offset="45">
+ <param name="c" type="const GLdouble *" count="1"/>
+ <glx rop="24"/>
+ </function>
+
+ <function name="Indexf" offset="46" vectorequiv="Indexfv">
+ <param name="c" type="GLfloat"/>
+ </function>
+
+ <function name="Indexfv" offset="47">
+ <param name="c" type="const GLfloat *" count="1"/>
+ <glx rop="25"/>
+ </function>
+
+ <function name="Indexi" offset="48" vectorequiv="Indexiv">
+ <param name="c" type="GLint"/>
+ </function>
+
+ <function name="Indexiv" offset="49">
+ <param name="c" type="const GLint *" count="1"/>
+ <glx rop="26"/>
+ </function>
+
+ <function name="Indexs" offset="50" vectorequiv="Indexsv">
+ <param name="c" type="GLshort"/>
+ </function>
+
+ <function name="Indexsv" offset="51">
+ <param name="c" type="const GLshort *" count="1"/>
+ <glx rop="27"/>
+ </function>
+
+ <function name="Normal3b" offset="52" vectorequiv="Normal3bv">
+ <param name="nx" type="GLbyte"/>
+ <param name="ny" type="GLbyte"/>
+ <param name="nz" type="GLbyte"/>
+ </function>
+
+ <function name="Normal3bv" offset="53">
+ <param name="v" type="const GLbyte *" count="3"/>
+ <glx rop="28"/>
+ </function>
+
+ <function name="Normal3d" offset="54" vectorequiv="Normal3dv">
+ <param name="nx" type="GLdouble"/>
+ <param name="ny" type="GLdouble"/>
+ <param name="nz" type="GLdouble"/>
+ </function>
+
+ <function name="Normal3dv" offset="55">
+ <param name="v" type="const GLdouble *" count="3"/>
+ <glx rop="29"/>
+ </function>
+
+ <function name="Normal3f" offset="56" vectorequiv="Normal3fv">
+ <param name="nx" type="GLfloat"/>
+ <param name="ny" type="GLfloat"/>
+ <param name="nz" type="GLfloat"/>
+ </function>
+
+ <function name="Normal3fv" offset="57">
+ <param name="v" type="const GLfloat *" count="3"/>
+ <glx rop="30"/>
+ </function>
+
+ <function name="Normal3i" offset="58" vectorequiv="Normal3iv">
+ <param name="nx" type="GLint"/>
+ <param name="ny" type="GLint"/>
+ <param name="nz" type="GLint"/>
+ </function>
+
+ <function name="Normal3iv" offset="59">
+ <param name="v" type="const GLint *" count="3"/>
+ <glx rop="31"/>
+ </function>
+
+ <function name="Normal3s" offset="60" vectorequiv="Normal3sv">
+ <param name="nx" type="GLshort"/>
+ <param name="ny" type="GLshort"/>
+ <param name="nz" type="GLshort"/>
+ </function>
+
+ <function name="Normal3sv" offset="61">
+ <param name="v" type="const GLshort *" count="3"/>
+ <glx rop="32"/>
+ </function>
+
+ <function name="RasterPos2d" offset="62" vectorequiv="RasterPos2dv">
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ </function>
+
+ <function name="RasterPos2dv" offset="63">
+ <param name="v" type="const GLdouble *" count="2"/>
+ <glx rop="33"/>
+ </function>
+
+ <function name="RasterPos2f" offset="64" vectorequiv="RasterPos2fv">
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ </function>
+
+ <function name="RasterPos2fv" offset="65">
+ <param name="v" type="const GLfloat *" count="2"/>
+ <glx rop="34"/>
+ </function>
+
+ <function name="RasterPos2i" offset="66" vectorequiv="RasterPos2iv">
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ </function>
+
+ <function name="RasterPos2iv" offset="67">
+ <param name="v" type="const GLint *" count="2"/>
+ <glx rop="35"/>
+ </function>
+
+ <function name="RasterPos2s" offset="68" vectorequiv="RasterPos2sv">
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ </function>
+
+ <function name="RasterPos2sv" offset="69">
+ <param name="v" type="const GLshort *" count="2"/>
+ <glx rop="36"/>
+ </function>
+
+ <function name="RasterPos3d" offset="70" vectorequiv="RasterPos3dv">
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ </function>
+
+ <function name="RasterPos3dv" offset="71">
+ <param name="v" type="const GLdouble *" count="3"/>
+ <glx rop="37"/>
+ </function>
+
+ <function name="RasterPos3f" offset="72" vectorequiv="RasterPos3fv">
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="RasterPos3fv" offset="73">
+ <param name="v" type="const GLfloat *" count="3"/>
+ <glx rop="38"/>
+ </function>
+
+ <function name="RasterPos3i" offset="74" vectorequiv="RasterPos3iv">
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="z" type="GLint"/>
+ </function>
+
+ <function name="RasterPos3iv" offset="75">
+ <param name="v" type="const GLint *" count="3"/>
+ <glx rop="39"/>
+ </function>
+
+ <function name="RasterPos3s" offset="76" vectorequiv="RasterPos3sv">
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ <param name="z" type="GLshort"/>
+ </function>
+
+ <function name="RasterPos3sv" offset="77">
+ <param name="v" type="const GLshort *" count="3"/>
+ <glx rop="40"/>
+ </function>
+
+ <function name="RasterPos4d" offset="78" vectorequiv="RasterPos4dv">
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ <param name="w" type="GLdouble"/>
+ </function>
+
+ <function name="RasterPos4dv" offset="79">
+ <param name="v" type="const GLdouble *" count="4"/>
+ <glx rop="41"/>
+ </function>
+
+ <function name="RasterPos4f" offset="80" vectorequiv="RasterPos4fv">
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ <param name="w" type="GLfloat"/>
+ </function>
+
+ <function name="RasterPos4fv" offset="81">
+ <param name="v" type="const GLfloat *" count="4"/>
+ <glx rop="42"/>
+ </function>
+
+ <function name="RasterPos4i" offset="82" vectorequiv="RasterPos4iv">
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="z" type="GLint"/>
+ <param name="w" type="GLint"/>
+ </function>
+
+ <function name="RasterPos4iv" offset="83">
+ <param name="v" type="const GLint *" count="4"/>
+ <glx rop="43"/>
+ </function>
+
+ <function name="RasterPos4s" offset="84" vectorequiv="RasterPos4sv">
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ <param name="z" type="GLshort"/>
+ <param name="w" type="GLshort"/>
+ </function>
+
+ <function name="RasterPos4sv" offset="85">
+ <param name="v" type="const GLshort *" count="4"/>
+ <glx rop="44"/>
+ </function>
+
+ <function name="Rectd" offset="86" vectorequiv="Rectdv">
+ <param name="x1" type="GLdouble"/>
+ <param name="y1" type="GLdouble"/>
+ <param name="x2" type="GLdouble"/>
+ <param name="y2" type="GLdouble"/>
+ </function>
+
+ <function name="Rectdv" offset="87">
+ <param name="v1" type="const GLdouble *" count="2"/>
+ <param name="v2" type="const GLdouble *" count="2"/>
+ <glx rop="45"/>
+ </function>
+
+ <function name="Rectf" offset="88" vectorequiv="Rectfv">
+ <param name="x1" type="GLfloat"/>
+ <param name="y1" type="GLfloat"/>
+ <param name="x2" type="GLfloat"/>
+ <param name="y2" type="GLfloat"/>
+ </function>
+
+ <function name="Rectfv" offset="89">
+ <param name="v1" type="const GLfloat *" count="2"/>
+ <param name="v2" type="const GLfloat *" count="2"/>
+ <glx rop="46"/>
+ </function>
+
+ <function name="Recti" offset="90" vectorequiv="Rectiv">
+ <param name="x1" type="GLint"/>
+ <param name="y1" type="GLint"/>
+ <param name="x2" type="GLint"/>
+ <param name="y2" type="GLint"/>
+ </function>
+
+ <function name="Rectiv" offset="91">
+ <param name="v1" type="const GLint *" count="2"/>
+ <param name="v2" type="const GLint *" count="2"/>
+ <glx rop="47"/>
+ </function>
+
+ <function name="Rects" offset="92" vectorequiv="Rectsv">
+ <param name="x1" type="GLshort"/>
+ <param name="y1" type="GLshort"/>
+ <param name="x2" type="GLshort"/>
+ <param name="y2" type="GLshort"/>
+ </function>
+
+ <function name="Rectsv" offset="93">
+ <param name="v1" type="const GLshort *" count="2"/>
+ <param name="v2" type="const GLshort *" count="2"/>
+ <glx rop="48"/>
+ </function>
+
+ <function name="TexCoord1d" offset="94" vectorequiv="TexCoord1dv">
+ <param name="s" type="GLdouble"/>
+ </function>
+
+ <function name="TexCoord1dv" offset="95">
+ <param name="v" type="const GLdouble *" count="1"/>
+ <glx rop="49"/>
+ </function>
+
+ <function name="TexCoord1f" offset="96" vectorequiv="TexCoord1fv">
+ <param name="s" type="GLfloat"/>
+ </function>
+
+ <function name="TexCoord1fv" offset="97">
+ <param name="v" type="const GLfloat *" count="1"/>
+ <glx rop="50"/>
+ </function>
+
+ <function name="TexCoord1i" offset="98" vectorequiv="TexCoord1iv">
+ <param name="s" type="GLint"/>
+ </function>
+
+ <function name="TexCoord1iv" offset="99">
+ <param name="v" type="const GLint *" count="1"/>
+ <glx rop="51"/>
+ </function>
+
+ <function name="TexCoord1s" offset="100" vectorequiv="TexCoord1sv">
+ <param name="s" type="GLshort"/>
+ </function>
+
+ <function name="TexCoord1sv" offset="101">
+ <param name="v" type="const GLshort *" count="1"/>
+ <glx rop="52"/>
+ </function>
+
+ <function name="TexCoord2d" offset="102" vectorequiv="TexCoord2dv">
+ <param name="s" type="GLdouble"/>
+ <param name="t" type="GLdouble"/>
+ </function>
+
+ <function name="TexCoord2dv" offset="103">
+ <param name="v" type="const GLdouble *" count="2"/>
+ <glx rop="53"/>
+ </function>
+
+ <function name="TexCoord2f" offset="104" vectorequiv="TexCoord2fv">
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ </function>
+
+ <function name="TexCoord2fv" offset="105">
+ <param name="v" type="const GLfloat *" count="2"/>
+ <glx rop="54"/>
+ </function>
+
+ <function name="TexCoord2i" offset="106" vectorequiv="TexCoord2iv">
+ <param name="s" type="GLint"/>
+ <param name="t" type="GLint"/>
+ </function>
+
+ <function name="TexCoord2iv" offset="107">
+ <param name="v" type="const GLint *" count="2"/>
+ <glx rop="55"/>
+ </function>
+
+ <function name="TexCoord2s" offset="108" vectorequiv="TexCoord2sv">
+ <param name="s" type="GLshort"/>
+ <param name="t" type="GLshort"/>
+ </function>
+
+ <function name="TexCoord2sv" offset="109">
+ <param name="v" type="const GLshort *" count="2"/>
+ <glx rop="56"/>
+ </function>
+
+ <function name="TexCoord3d" offset="110" vectorequiv="TexCoord3dv">
+ <param name="s" type="GLdouble"/>
+ <param name="t" type="GLdouble"/>
+ <param name="r" type="GLdouble"/>
+ </function>
+
+ <function name="TexCoord3dv" offset="111">
+ <param name="v" type="const GLdouble *" count="3"/>
+ <glx rop="57"/>
+ </function>
+
+ <function name="TexCoord3f" offset="112" vectorequiv="TexCoord3fv">
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ <param name="r" type="GLfloat"/>
+ </function>
+
+ <function name="TexCoord3fv" offset="113">
+ <param name="v" type="const GLfloat *" count="3"/>
+ <glx rop="58"/>
+ </function>
+
+ <function name="TexCoord3i" offset="114" vectorequiv="TexCoord3iv">
+ <param name="s" type="GLint"/>
+ <param name="t" type="GLint"/>
+ <param name="r" type="GLint"/>
+ </function>
+
+ <function name="TexCoord3iv" offset="115">
+ <param name="v" type="const GLint *" count="3"/>
+ <glx rop="59"/>
+ </function>
+
+ <function name="TexCoord3s" offset="116" vectorequiv="TexCoord3sv">
+ <param name="s" type="GLshort"/>
+ <param name="t" type="GLshort"/>
+ <param name="r" type="GLshort"/>
+ </function>
+
+ <function name="TexCoord3sv" offset="117">
+ <param name="v" type="const GLshort *" count="3"/>
+ <glx rop="60"/>
+ </function>
+
+ <function name="TexCoord4d" offset="118" vectorequiv="TexCoord4dv">
+ <param name="s" type="GLdouble"/>
+ <param name="t" type="GLdouble"/>
+ <param name="r" type="GLdouble"/>
+ <param name="q" type="GLdouble"/>
+ </function>
+
+ <function name="TexCoord4dv" offset="119">
+ <param name="v" type="const GLdouble *" count="4"/>
+ <glx rop="61"/>
+ </function>
+
+ <function name="TexCoord4f" offset="120" vectorequiv="TexCoord4fv">
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ <param name="r" type="GLfloat"/>
+ <param name="q" type="GLfloat"/>
+ </function>
+
+ <function name="TexCoord4fv" offset="121">
+ <param name="v" type="const GLfloat *" count="4"/>
+ <glx rop="62"/>
+ </function>
+
+ <function name="TexCoord4i" offset="122" vectorequiv="TexCoord4iv">
+ <param name="s" type="GLint"/>
+ <param name="t" type="GLint"/>
+ <param name="r" type="GLint"/>
+ <param name="q" type="GLint"/>
+ </function>
+
+ <function name="TexCoord4iv" offset="123">
+ <param name="v" type="const GLint *" count="4"/>
+ <glx rop="63"/>
+ </function>
+
+ <function name="TexCoord4s" offset="124" vectorequiv="TexCoord4sv">
+ <param name="s" type="GLshort"/>
+ <param name="t" type="GLshort"/>
+ <param name="r" type="GLshort"/>
+ <param name="q" type="GLshort"/>
+ </function>
+
+ <function name="TexCoord4sv" offset="125">
+ <param name="v" type="const GLshort *" count="4"/>
+ <glx rop="64"/>
+ </function>
+
+ <function name="Vertex2d" offset="126" vectorequiv="Vertex2dv">
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ </function>
+
+ <function name="Vertex2dv" offset="127">
+ <param name="v" type="const GLdouble *" count="2"/>
+ <glx rop="65"/>
+ </function>
+
+ <function name="Vertex2f" offset="128" vectorequiv="Vertex2fv">
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ </function>
+
+ <function name="Vertex2fv" offset="129">
+ <param name="v" type="const GLfloat *" count="2"/>
+ <glx rop="66"/>
+ </function>
+
+ <function name="Vertex2i" offset="130" vectorequiv="Vertex2iv">
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ </function>
+
+ <function name="Vertex2iv" offset="131">
+ <param name="v" type="const GLint *" count="2"/>
+ <glx rop="67"/>
+ </function>
+
+ <function name="Vertex2s" offset="132" vectorequiv="Vertex2sv">
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ </function>
+
+ <function name="Vertex2sv" offset="133">
+ <param name="v" type="const GLshort *" count="2"/>
+ <glx rop="68"/>
+ </function>
+
+ <function name="Vertex3d" offset="134" vectorequiv="Vertex3dv">
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ </function>
+
+ <function name="Vertex3dv" offset="135">
+ <param name="v" type="const GLdouble *" count="3"/>
+ <glx rop="69"/>
+ </function>
+
+ <function name="Vertex3f" offset="136" vectorequiv="Vertex3fv">
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="Vertex3fv" offset="137">
+ <param name="v" type="const GLfloat *" count="3"/>
+ <glx rop="70"/>
+ </function>
+
+ <function name="Vertex3i" offset="138" vectorequiv="Vertex3iv">
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="z" type="GLint"/>
+ </function>
+
+ <function name="Vertex3iv" offset="139">
+ <param name="v" type="const GLint *" count="3"/>
+ <glx rop="71"/>
+ </function>
+
+ <function name="Vertex3s" offset="140" vectorequiv="Vertex3sv">
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ <param name="z" type="GLshort"/>
+ </function>
+
+ <function name="Vertex3sv" offset="141">
+ <param name="v" type="const GLshort *" count="3"/>
+ <glx rop="72"/>
+ </function>
+
+ <function name="Vertex4d" offset="142" vectorequiv="Vertex4dv">
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ <param name="w" type="GLdouble"/>
+ </function>
+
+ <function name="Vertex4dv" offset="143">
+ <param name="v" type="const GLdouble *" count="4"/>
+ <glx rop="73"/>
+ </function>
+
+ <function name="Vertex4f" offset="144" vectorequiv="Vertex4fv">
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ <param name="w" type="GLfloat"/>
+ </function>
+
+ <function name="Vertex4fv" offset="145">
+ <param name="v" type="const GLfloat *" count="4"/>
+ <glx rop="74"/>
+ </function>
+
+ <function name="Vertex4i" offset="146" vectorequiv="Vertex4iv">
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="z" type="GLint"/>
+ <param name="w" type="GLint"/>
+ </function>
+
+ <function name="Vertex4iv" offset="147">
+ <param name="v" type="const GLint *" count="4"/>
+ <glx rop="75"/>
+ </function>
+
+ <function name="Vertex4s" offset="148" vectorequiv="Vertex4sv">
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ <param name="z" type="GLshort"/>
+ <param name="w" type="GLshort"/>
+ </function>
+
+ <function name="Vertex4sv" offset="149">
+ <param name="v" type="const GLshort *" count="4"/>
+ <glx rop="76"/>
+ </function>
+
+ <function name="ClipPlane" offset="150">
+ <param name="plane" type="GLenum"/>
+ <param name="equation" type="const GLdouble *" count="4"/>
+ <glx rop="77"/>
+ </function>
+
+ <function name="ColorMaterial" offset="151">
+ <param name="face" type="GLenum"/>
+ <param name="mode" type="GLenum"/>
+ <glx rop="78"/>
+ </function>
+
+ <function name="CullFace" offset="152">
+ <param name="mode" type="GLenum"/>
+ <glx rop="79"/>
+ </function>
+
+ <function name="Fogf" offset="153">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx rop="80"/>
+ </function>
+
+ <function name="Fogfv" offset="154">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *" variable_param="pname"/>
+ <glx rop="81"/>
+ </function>
+
+ <function name="Fogi" offset="155">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx rop="82"/>
+ </function>
+
+ <function name="Fogiv" offset="156">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *" variable_param="pname"/>
+ <glx rop="83"/>
+ </function>
+
+ <function name="FrontFace" offset="157">
+ <param name="mode" type="GLenum"/>
+ <glx rop="84"/>
+ </function>
+
+ <function name="Hint" offset="158">
+ <param name="target" type="GLenum"/>
+ <param name="mode" type="GLenum"/>
+ <glx rop="85"/>
+ </function>
+
+ <function name="Lightf" offset="159">
+ <param name="light" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx rop="86"/>
+ </function>
+
+ <function name="Lightfv" offset="160">
+ <param name="light" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *" variable_param="pname"/>
+ <glx rop="87"/>
+ </function>
+
+ <function name="Lighti" offset="161">
+ <param name="light" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx rop="88"/>
+ </function>
+
+ <function name="Lightiv" offset="162">
+ <param name="light" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *" variable_param="pname"/>
+ <glx rop="89"/>
+ </function>
+
+ <function name="LightModelf" offset="163">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx rop="90"/>
+ </function>
+
+ <function name="LightModelfv" offset="164">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *" variable_param="pname"/>
+ <glx rop="91"/>
+ </function>
+
+ <function name="LightModeli" offset="165">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx rop="92"/>
+ </function>
+
+ <function name="LightModeliv" offset="166">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *" variable_param="pname"/>
+ <glx rop="93"/>
+ </function>
+
+ <function name="LineStipple" offset="167">
+ <param name="factor" type="GLint"/>
+ <param name="pattern" type="GLushort"/>
+ <glx rop="94"/>
+ </function>
+
+ <function name="LineWidth" offset="168">
+ <param name="width" type="GLfloat"/>
+ <glx rop="95"/>
+ </function>
+
+ <function name="Materialf" offset="169">
+ <param name="face" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx rop="96"/>
+ </function>
+
+ <function name="Materialfv" offset="170">
+ <param name="face" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *" variable_param="pname"/>
+ <glx rop="97"/>
+ </function>
+
+ <function name="Materiali" offset="171">
+ <param name="face" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx rop="98"/>
+ </function>
+
+ <function name="Materialiv" offset="172">
+ <param name="face" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *" variable_param="pname"/>
+ <glx rop="99"/>
+ </function>
+
+ <function name="PointSize" offset="173">
+ <param name="size" type="GLfloat"/>
+ <glx rop="100"/>
+ </function>
+
+ <function name="PolygonMode" offset="174">
+ <param name="face" type="GLenum"/>
+ <param name="mode" type="GLenum"/>
+ <glx rop="101"/>
+ </function>
+
+ <function name="PolygonStipple" offset="175">
+ <param name="mask" type="const GLubyte *" img_width="32" img_height="32" img_format="GL_COLOR_INDEX" img_type="GL_BITMAP" img_target="0" img_pad_dimensions="false"/>
+ <glx rop="102"/>
+ </function>
+
+ <function name="Scissor" offset="176">
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <glx rop="103"/>
+ </function>
+
+ <function name="ShadeModel" offset="177">
+ <param name="mode" type="GLenum"/>
+ <glx rop="104"/>
+ </function>
+
+ <function name="TexParameterf" offset="178">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx rop="105"/>
+ </function>
+
+ <function name="TexParameterfv" offset="179">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *" variable_param="pname"/>
+ <glx rop="106"/>
+ </function>
+
+ <function name="TexParameteri" offset="180">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx rop="107"/>
+ </function>
+
+ <function name="TexParameteriv" offset="181">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *" variable_param="pname"/>
+ <glx rop="108"/>
+ </function>
+
+ <function name="TexImage1D" offset="182">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="internalformat" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="border" type="GLint"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="pixels" type="const GLvoid *" img_width="width" img_format="format" img_type="type" img_target="target" img_send_null="true" img_pad_dimensions="true"/>
+ <glx rop="109" large="true"/>
+ </function>
+
+ <function name="TexImage2D" offset="183">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="internalformat" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="border" type="GLint"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="pixels" type="const GLvoid *" img_width="width" img_height="height" img_format="format" img_type="type" img_target="target" img_send_null="true" img_pad_dimensions="true"/>
+ <glx rop="110" large="true"/>
+ </function>
+
+ <function name="TexEnvf" offset="184">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx rop="111"/>
+ </function>
+
+ <function name="TexEnvfv" offset="185">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *" variable_param="pname"/>
+ <glx rop="112"/>
+ </function>
+
+ <function name="TexEnvi" offset="186">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx rop="113"/>
+ </function>
+
+ <function name="TexEnviv" offset="187">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *" variable_param="pname"/>
+ <glx rop="114"/>
+ </function>
+
+ <function name="TexGend" offset="188">
+ <param name="coord" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLdouble"/>
+ <glx rop="115"/>
+ </function>
+
+ <function name="TexGendv" offset="189">
+ <param name="coord" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLdouble *" variable_param="pname"/>
+ <glx rop="116"/>
+ </function>
+
+ <function name="TexGenf" offset="190">
+ <param name="coord" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx rop="117"/>
+ </function>
+
+ <function name="TexGenfv" offset="191">
+ <param name="coord" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *" variable_param="pname"/>
+ <glx rop="118"/>
+ </function>
+
+ <function name="TexGeni" offset="192">
+ <param name="coord" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx rop="119"/>
+ </function>
+
+ <function name="TexGeniv" offset="193">
+ <param name="coord" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *" variable_param="pname"/>
+ <glx rop="120"/>
+ </function>
+
+ <function name="FeedbackBuffer" offset="194">
+ <param name="size" type="GLsizei"/>
+ <param name="type" type="GLenum"/>
+ <param name="buffer" type="GLfloat *" output="true"/>
+ <glx sop="105" handcode="true"/>
+ </function>
+
+ <function name="SelectBuffer" offset="195">
+ <param name="size" type="GLsizei"/>
+ <param name="buffer" type="GLuint *" output="true"/>
+ <glx sop="106" handcode="true"/>
+ </function>
+
+ <function name="RenderMode" offset="196">
+ <param name="mode" type="GLenum"/>
+ <return type="GLint"/>
+ <glx sop="107" handcode="true"/>
+ </function>
+
+ <function name="InitNames" offset="197">
+ <glx rop="121"/>
+ </function>
+
+ <function name="LoadName" offset="198">
+ <param name="name" type="GLuint"/>
+ <glx rop="122"/>
+ </function>
+
+ <function name="PassThrough" offset="199">
+ <param name="token" type="GLfloat"/>
+ <glx rop="123"/>
+ </function>
+
+ <function name="PopName" offset="200">
+ <glx rop="124"/>
+ </function>
+
+ <function name="PushName" offset="201">
+ <param name="name" type="GLuint"/>
+ <glx rop="125"/>
+ </function>
+
+ <function name="DrawBuffer" offset="202">
+ <param name="mode" type="GLenum"/>
+ <glx rop="126"/>
+ </function>
+
+ <function name="Clear" offset="203">
+ <param name="mask" type="GLbitfield"/>
+ <glx rop="127"/>
+ </function>
+
+ <function name="ClearAccum" offset="204">
+ <param name="red" type="GLfloat"/>
+ <param name="green" type="GLfloat"/>
+ <param name="blue" type="GLfloat"/>
+ <param name="alpha" type="GLfloat"/>
+ <glx rop="128"/>
+ </function>
+
+ <function name="ClearIndex" offset="205">
+ <param name="c" type="GLfloat"/>
+ <glx rop="129"/>
+ </function>
+
+ <function name="ClearColor" offset="206">
+ <param name="red" type="GLclampf"/>
+ <param name="green" type="GLclampf"/>
+ <param name="blue" type="GLclampf"/>
+ <param name="alpha" type="GLclampf"/>
+ <glx rop="130"/>
+ </function>
+
+ <function name="ClearStencil" offset="207">
+ <param name="s" type="GLint"/>
+ <glx rop="131"/>
+ </function>
+
+ <function name="ClearDepth" offset="208">
+ <param name="depth" type="GLclampd"/>
+ <glx rop="132"/>
+ </function>
+
+ <function name="StencilMask" offset="209">
+ <param name="mask" type="GLuint"/>
+ <glx rop="133"/>
+ </function>
+
+ <function name="ColorMask" offset="210">
+ <param name="red" type="GLboolean"/>
+ <param name="green" type="GLboolean"/>
+ <param name="blue" type="GLboolean"/>
+ <param name="alpha" type="GLboolean"/>
+ <glx rop="134"/>
+ </function>
+
+ <function name="DepthMask" offset="211">
+ <param name="flag" type="GLboolean"/>
+ <glx rop="135"/>
+ </function>
+
+ <function name="IndexMask" offset="212">
+ <param name="mask" type="GLuint"/>
+ <glx rop="136"/>
+ </function>
+
+ <function name="Accum" offset="213">
+ <param name="op" type="GLenum"/>
+ <param name="value" type="GLfloat"/>
+ <glx rop="137"/>
+ </function>
+
+ <function name="Disable" offset="214">
+ <param name="cap" type="GLenum"/>
+ <glx rop="138" handcode="client"/>
+ </function>
+
+ <function name="Enable" offset="215">
+ <param name="cap" type="GLenum"/>
+ <glx rop="139" handcode="client"/>
+ </function>
+
+ <function name="Finish" offset="216">
+ <glx sop="108" handcode="true"/>
+ </function>
+
+ <function name="Flush" offset="217">
+ <glx sop="142" handcode="true"/>
+ </function>
+
+ <function name="PopAttrib" offset="218">
+ <glx rop="141"/>
+ </function>
+
+ <function name="PushAttrib" offset="219">
+ <param name="mask" type="GLbitfield"/>
+ <glx rop="142"/>
+ </function>
+
+ <function name="Map1d" offset="220">
+ <param name="target" type="GLenum"/>
+ <param name="u1" type="GLdouble"/>
+ <param name="u2" type="GLdouble"/>
+ <param name="stride" type="GLint"/>
+ <param name="order" type="GLint"/>
+ <param name="points" type="const GLdouble *"/>
+ <glx rop="143" handcode="true"/>
+ </function>
+
+ <function name="Map1f" offset="221">
+ <param name="target" type="GLenum"/>
+ <param name="u1" type="GLfloat"/>
+ <param name="u2" type="GLfloat"/>
+ <param name="stride" type="GLint"/>
+ <param name="order" type="GLint"/>
+ <param name="points" type="const GLfloat *"/>
+ <glx rop="144" handcode="true"/>
+ </function>
+
+ <function name="Map2d" offset="222">
+ <param name="target" type="GLenum"/>
+ <param name="u1" type="GLdouble"/>
+ <param name="u2" type="GLdouble"/>
+ <param name="ustride" type="GLint"/>
+ <param name="uorder" type="GLint"/>
+ <param name="v1" type="GLdouble"/>
+ <param name="v2" type="GLdouble"/>
+ <param name="vstride" type="GLint"/>
+ <param name="vorder" type="GLint"/>
+ <param name="points" type="const GLdouble *"/>
+ <glx rop="145" handcode="true"/>
+ </function>
+
+ <function name="Map2f" offset="223">
+ <param name="target" type="GLenum"/>
+ <param name="u1" type="GLfloat"/>
+ <param name="u2" type="GLfloat"/>
+ <param name="ustride" type="GLint"/>
+ <param name="uorder" type="GLint"/>
+ <param name="v1" type="GLfloat"/>
+ <param name="v2" type="GLfloat"/>
+ <param name="vstride" type="GLint"/>
+ <param name="vorder" type="GLint"/>
+ <param name="points" type="const GLfloat *"/>
+ <glx rop="146" handcode="true"/>
+ </function>
+
+ <function name="MapGrid1d" offset="224">
+ <param name="un" type="GLint"/>
+ <param name="u1" type="GLdouble"/>
+ <param name="u2" type="GLdouble"/>
+ <glx rop="147"/>
+ </function>
+
+ <function name="MapGrid1f" offset="225">
+ <param name="un" type="GLint"/>
+ <param name="u1" type="GLfloat"/>
+ <param name="u2" type="GLfloat"/>
+ <glx rop="148"/>
+ </function>
+
+ <function name="MapGrid2d" offset="226">
+ <param name="un" type="GLint"/>
+ <param name="u1" type="GLdouble"/>
+ <param name="u2" type="GLdouble"/>
+ <param name="vn" type="GLint"/>
+ <param name="v1" type="GLdouble"/>
+ <param name="v2" type="GLdouble"/>
+ <glx rop="149"/>
+ </function>
+
+ <function name="MapGrid2f" offset="227">
+ <param name="un" type="GLint"/>
+ <param name="u1" type="GLfloat"/>
+ <param name="u2" type="GLfloat"/>
+ <param name="vn" type="GLint"/>
+ <param name="v1" type="GLfloat"/>
+ <param name="v2" type="GLfloat"/>
+ <glx rop="150"/>
+ </function>
+
+ <function name="EvalCoord1d" offset="228" vectorequiv="EvalCoord1dv">
+ <param name="u" type="GLdouble"/>
+ </function>
+
+ <function name="EvalCoord1dv" offset="229">
+ <param name="u" type="const GLdouble *" count="1"/>
+ <glx rop="151"/>
+ </function>
+
+ <function name="EvalCoord1f" offset="230" vectorequiv="EvalCoord1fv">
+ <param name="u" type="GLfloat"/>
+ </function>
+
+ <function name="EvalCoord1fv" offset="231">
+ <param name="u" type="const GLfloat *" count="1"/>
+ <glx rop="152"/>
+ </function>
+
+ <function name="EvalCoord2d" offset="232" vectorequiv="EvalCoord2dv">
+ <param name="u" type="GLdouble"/>
+ <param name="v" type="GLdouble"/>
+ </function>
+
+ <function name="EvalCoord2dv" offset="233">
+ <param name="u" type="const GLdouble *" count="2"/>
+ <glx rop="153"/>
+ </function>
+
+ <function name="EvalCoord2f" offset="234" vectorequiv="EvalCoord2fv">
+ <param name="u" type="GLfloat"/>
+ <param name="v" type="GLfloat"/>
+ </function>
+
+ <function name="EvalCoord2fv" offset="235">
+ <param name="u" type="const GLfloat *" count="2"/>
+ <glx rop="154"/>
+ </function>
+
+ <function name="EvalMesh1" offset="236">
+ <param name="mode" type="GLenum"/>
+ <param name="i1" type="GLint"/>
+ <param name="i2" type="GLint"/>
+ <glx rop="155"/>
+ </function>
+
+ <function name="EvalPoint1" offset="237">
+ <param name="i" type="GLint"/>
+ <glx rop="156"/>
+ </function>
+
+ <function name="EvalMesh2" offset="238">
+ <param name="mode" type="GLenum"/>
+ <param name="i1" type="GLint"/>
+ <param name="i2" type="GLint"/>
+ <param name="j1" type="GLint"/>
+ <param name="j2" type="GLint"/>
+ <glx rop="157"/>
+ </function>
+
+ <function name="EvalPoint2" offset="239">
+ <param name="i" type="GLint"/>
+ <param name="j" type="GLint"/>
+ <glx rop="158"/>
+ </function>
+
+ <function name="AlphaFunc" offset="240">
+ <param name="func" type="GLenum"/>
+ <param name="ref" type="GLclampf"/>
+ <glx rop="159"/>
+ </function>
+
+ <function name="BlendFunc" offset="241">
+ <param name="sfactor" type="GLenum"/>
+ <param name="dfactor" type="GLenum"/>
+ <glx rop="160"/>
+ </function>
+
+ <function name="LogicOp" offset="242">
+ <param name="opcode" type="GLenum"/>
+ <glx rop="161"/>
+ </function>
+
+ <function name="StencilFunc" offset="243">
+ <param name="func" type="GLenum"/>
+ <param name="ref" type="GLint"/>
+ <param name="mask" type="GLuint"/>
+ <glx rop="162"/>
+ </function>
+
+ <function name="StencilOp" offset="244">
+ <param name="fail" type="GLenum"/>
+ <param name="zfail" type="GLenum"/>
+ <param name="zpass" type="GLenum"/>
+ <glx rop="163"/>
+ </function>
+
+ <function name="DepthFunc" offset="245">
+ <param name="func" type="GLenum"/>
+ <glx rop="164"/>
+ </function>
+
+ <function name="PixelZoom" offset="246">
+ <param name="xfactor" type="GLfloat"/>
+ <param name="yfactor" type="GLfloat"/>
+ <glx rop="165"/>
+ </function>
+
+ <function name="PixelTransferf" offset="247">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx rop="166"/>
+ </function>
+
+ <function name="PixelTransferi" offset="248">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx rop="167"/>
+ </function>
+
+ <function name="PixelStoref" offset="249">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx sop="109" handcode="client"/>
+ </function>
+
+ <function name="PixelStorei" offset="250">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx sop="110" handcode="client"/>
+ </function>
+
+ <function name="PixelMapfv" offset="251">
+ <param name="map" type="GLenum"/>
+ <param name="mapsize" type="GLsizei" counter="true"/>
+ <param name="values" type="const GLfloat *" count="mapsize"/>
+ <glx rop="168" large="true"/>
+ </function>
+
+ <function name="PixelMapuiv" offset="252">
+ <param name="map" type="GLenum"/>
+ <param name="mapsize" type="GLsizei" counter="true"/>
+ <param name="values" type="const GLuint *" count="mapsize"/>
+ <glx rop="169" large="true"/>
+ </function>
+
+ <function name="PixelMapusv" offset="253">
+ <param name="map" type="GLenum"/>
+ <param name="mapsize" type="GLsizei" counter="true"/>
+ <param name="values" type="const GLushort *" count="mapsize"/>
+ <glx rop="170" large="true"/>
+ </function>
+
+ <function name="ReadBuffer" offset="254">
+ <param name="mode" type="GLenum"/>
+ <glx rop="171"/>
+ </function>
+
+ <function name="CopyPixels" offset="255">
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="type" type="GLenum"/>
+ <glx rop="172"/>
+ </function>
+
+ <function name="ReadPixels" offset="256">
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="pixels" type="GLvoid *" output="true" img_width="width" img_height="height" img_format="format" img_type="type" img_target="0"/>
+ <glx sop="111"/>
+ </function>
+
+ <function name="DrawPixels" offset="257">
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="pixels" type="const GLvoid *" img_width="width" img_height="height" img_format="format" img_type="type" img_target="0" img_pad_dimensions="false"/>
+ <glx rop="173" large="true"/>
+ </function>
+
+ <function name="GetBooleanv" offset="258">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLboolean *" output="true" variable_param="pname"/>
+ <glx sop="112" handcode="client"/>
+ </function>
+
+ <function name="GetClipPlane" offset="259">
+ <param name="plane" type="GLenum"/>
+ <param name="equation" type="GLdouble *" output="true" count="4"/>
+ <glx sop="113" always_array="true"/>
+ </function>
+
+ <function name="GetDoublev" offset="260">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLdouble *" output="true" variable_param="pname"/>
+ <glx sop="114" handcode="client"/>
+ </function>
+
+ <function name="GetError" offset="261">
+ <return type="GLenum"/>
+ <glx sop="115" handcode="client"/>
+ </function>
+
+ <function name="GetFloatv" offset="262">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx sop="116" handcode="client"/>
+ </function>
+
+ <function name="GetIntegerv" offset="263">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx sop="117" handcode="client"/>
+ </function>
+
+ <function name="GetLightfv" offset="264">
+ <param name="light" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx sop="118"/>
+ </function>
+
+ <function name="GetLightiv" offset="265">
+ <param name="light" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx sop="119"/>
+ </function>
+
+ <function name="GetMapdv" offset="266">
+ <param name="target" type="GLenum"/>
+ <param name="query" type="GLenum"/>
+ <param name="v" type="GLdouble *" output="true" variable_param="target query"/>
+ <glx sop="120"/>
+ </function>
+
+ <function name="GetMapfv" offset="267">
+ <param name="target" type="GLenum"/>
+ <param name="query" type="GLenum"/>
+ <param name="v" type="GLfloat *" output="true" variable_param="target query"/>
+ <glx sop="121"/>
+ </function>
+
+ <function name="GetMapiv" offset="268">
+ <param name="target" type="GLenum"/>
+ <param name="query" type="GLenum"/>
+ <param name="v" type="GLint *" output="true" variable_param="target query"/>
+ <glx sop="122"/>
+ </function>
+
+ <function name="GetMaterialfv" offset="269">
+ <param name="face" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx sop="123"/>
+ </function>
+
+ <function name="GetMaterialiv" offset="270">
+ <param name="face" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx sop="124"/>
+ </function>
+
+ <function name="GetPixelMapfv" offset="271">
+ <param name="map" type="GLenum"/>
+ <param name="values" type="GLfloat *" output="true" variable_param="map"/>
+ <glx sop="125"/>
+ </function>
+
+ <function name="GetPixelMapuiv" offset="272">
+ <param name="map" type="GLenum"/>
+ <param name="values" type="GLuint *" output="true" variable_param="map"/>
+ <glx sop="126"/>
+ </function>
+
+ <function name="GetPixelMapusv" offset="273">
+ <param name="map" type="GLenum"/>
+ <param name="values" type="GLushort *" output="true" variable_param="map"/>
+ <glx sop="127"/>
+ </function>
+
+ <function name="GetPolygonStipple" offset="274">
+ <param name="mask" type="GLubyte *" output="true" img_width="32" img_height="32" img_format="GL_COLOR_INDEX" img_type="GL_BITMAP"/>
+ <glx sop="128"/>
+ </function>
+
+ <function name="GetString" offset="275">
+ <param name="name" type="GLenum"/>
+ <return type="const GLubyte *"/>
+ <glx sop="129" handcode="true"/>
+ </function>
+
+ <function name="GetTexEnvfv" offset="276">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx sop="130"/>
+ </function>
+
+ <function name="GetTexEnviv" offset="277">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx sop="131"/>
+ </function>
+
+ <function name="GetTexGendv" offset="278">
+ <param name="coord" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLdouble *" output="true" variable_param="pname"/>
+ <glx sop="132"/>
+ </function>
+
+ <function name="GetTexGenfv" offset="279">
+ <param name="coord" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx sop="133"/>
+ </function>
+
+ <function name="GetTexGeniv" offset="280">
+ <param name="coord" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx sop="134"/>
+ </function>
+
+ <function name="GetTexImage" offset="281">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="pixels" type="GLvoid *" output="true" img_width="width" img_height="height" img_depth="depth" img_format="format" img_type="type"/>
+ <glx sop="135" dimensions_in_reply="true"/>
+ </function>
+
+ <function name="GetTexParameterfv" offset="282">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx sop="136"/>
+ </function>
+
+ <function name="GetTexParameteriv" offset="283">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx sop="137"/>
+ </function>
+
+ <function name="GetTexLevelParameterfv" offset="284">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx sop="138"/>
+ </function>
+
+ <function name="GetTexLevelParameteriv" offset="285">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx sop="139"/>
+ </function>
+
+ <function name="IsEnabled" offset="286">
+ <param name="cap" type="GLenum"/>
+ <return type="GLboolean"/>
+ <glx sop="140" handcode="client"/>
+ </function>
+
+ <function name="IsList" offset="287">
+ <param name="list" type="GLuint"/>
+ <return type="GLboolean"/>
+ <glx sop="141"/>
+ </function>
+
+ <function name="DepthRange" offset="288">
+ <param name="zNear" type="GLclampd"/>
+ <param name="zFar" type="GLclampd"/>
+ <glx rop="174"/>
+ </function>
+
+ <function name="Frustum" offset="289">
+ <param name="left" type="GLdouble"/>
+ <param name="right" type="GLdouble"/>
+ <param name="bottom" type="GLdouble"/>
+ <param name="top" type="GLdouble"/>
+ <param name="zNear" type="GLdouble"/>
+ <param name="zFar" type="GLdouble"/>
+ <glx rop="175"/>
+ </function>
+
+ <function name="LoadIdentity" offset="290">
+ <glx rop="176"/>
+ </function>
+
+ <function name="LoadMatrixf" offset="291">
+ <param name="m" type="const GLfloat *" count="16"/>
+ <glx rop="177"/>
+ </function>
+
+ <function name="LoadMatrixd" offset="292">
+ <param name="m" type="const GLdouble *" count="16"/>
+ <glx rop="178"/>
+ </function>
+
+ <function name="MatrixMode" offset="293">
+ <param name="mode" type="GLenum"/>
+ <glx rop="179"/>
+ </function>
+
+ <function name="MultMatrixf" offset="294">
+ <param name="m" type="const GLfloat *" count="16"/>
+ <glx rop="180"/>
+ </function>
+
+ <function name="MultMatrixd" offset="295">
+ <param name="m" type="const GLdouble *" count="16"/>
+ <glx rop="181"/>
+ </function>
+
+ <function name="Ortho" offset="296">
+ <param name="left" type="GLdouble"/>
+ <param name="right" type="GLdouble"/>
+ <param name="bottom" type="GLdouble"/>
+ <param name="top" type="GLdouble"/>
+ <param name="zNear" type="GLdouble"/>
+ <param name="zFar" type="GLdouble"/>
+ <glx rop="182"/>
+ </function>
+
+ <function name="PopMatrix" offset="297">
+ <glx rop="183"/>
+ </function>
+
+ <function name="PushMatrix" offset="298">
+ <glx rop="184"/>
+ </function>
+
+ <function name="Rotated" offset="299">
+ <param name="angle" type="GLdouble"/>
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ <glx rop="185"/>
+ </function>
+
+ <function name="Rotatef" offset="300">
+ <param name="angle" type="GLfloat"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ <glx rop="186"/>
+ </function>
+
+ <function name="Scaled" offset="301">
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ <glx rop="187"/>
+ </function>
+
+ <function name="Scalef" offset="302">
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ <glx rop="188"/>
+ </function>
+
+ <function name="Translated" offset="303">
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ <glx rop="189"/>
+ </function>
+
+ <function name="Translatef" offset="304">
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ <glx rop="190"/>
+ </function>
+
+ <function name="Viewport" offset="305">
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <glx rop="191"/>
+ </function>
+</category>
+
+<category name="1.1">
+ <enum name="INDEX_LOGIC_OP" value="0x0BF1"/>
+ <enum name="COLOR_LOGIC_OP" value="0x0BF2"/>
+ <enum name="TEXTURE_INTERNAL_FORMAT" value="0x1003"/>
+ <enum name="DOUBLE" value="0x140A"/>
+ <enum name="POLYGON_OFFSET_UNITS" count="1" value="0x2A00">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POLYGON_OFFSET_POINT" value="0x2A01"/>
+ <enum name="POLYGON_OFFSET_LINE" value="0x2A02"/>
+ <enum name="R3_G3_B2" value="0x2A10"/>
+ <enum name="V2F" value="0x2A20"/>
+ <enum name="V3F" value="0x2A21"/>
+ <enum name="C4UB_V2F" value="0x2A22"/>
+ <enum name="C4UB_V3F" value="0x2A23"/>
+ <enum name="C3F_V3F" value="0x2A24"/>
+ <enum name="N3F_V3F" value="0x2A25"/>
+ <enum name="C4F_N3F_V3F" value="0x2A26"/>
+ <enum name="T2F_V3F" value="0x2A27"/>
+ <enum name="T4F_V4F" value="0x2A28"/>
+ <enum name="T2F_C4UB_V3F" value="0x2A29"/>
+ <enum name="T2F_C3F_V3F" value="0x2A2A"/>
+ <enum name="T2F_N3F_V3F" value="0x2A2B"/>
+ <enum name="T2F_C4F_N3F_V3F" value="0x2A2C"/>
+ <enum name="T4F_C4F_N3F_V4F" value="0x2A2D"/>
+ <enum name="POLYGON_OFFSET_FILL" value="0x8037"/>
+ <enum name="POLYGON_OFFSET_FACTOR" count="1" value="0x8038">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POLYGON_OFFSET_BIAS" value="0x8039"/>
+ <enum name="ALPHA4" value="0x803B"/>
+ <enum name="ALPHA8" value="0x803C"/>
+ <enum name="ALPHA12" value="0x803D"/>
+ <enum name="ALPHA16" value="0x803E"/>
+ <enum name="LUMINANCE4" value="0x803F"/>
+ <enum name="LUMINANCE8" value="0x8040"/>
+ <enum name="LUMINANCE12" value="0x8041"/>
+ <enum name="LUMINANCE16" value="0x8042"/>
+ <enum name="LUMINANCE4_ALPHA4" value="0x8043"/>
+ <enum name="LUMINANCE6_ALPHA2" value="0x8044"/>
+ <enum name="LUMINANCE8_ALPHA8" value="0x8045"/>
+ <enum name="LUMINANCE12_ALPHA4" value="0x8046"/>
+ <enum name="LUMINANCE12_ALPHA12" value="0x8047"/>
+ <enum name="LUMINANCE16_ALPHA16" value="0x8048"/>
+ <enum name="INTENSITY" value="0x8049"/>
+ <enum name="INTENSITY4" value="0x804A"/>
+ <enum name="INTENSITY8" value="0x804B"/>
+ <enum name="INTENSITY12" value="0x804C"/>
+ <enum name="INTENSITY16" value="0x804D"/>
+ <enum name="RGB4" value="0x804F"/>
+ <enum name="RGB5" value="0x8050"/>
+ <enum name="RGB8" value="0x8051"/>
+ <enum name="RGB10" value="0x8052"/>
+ <enum name="RGB12" value="0x8053"/>
+ <enum name="RGB16" value="0x8054"/>
+ <enum name="RGBA2" value="0x8055"/>
+ <enum name="RGBA4" value="0x8056"/>
+ <enum name="RGB5_A1" value="0x8057"/>
+ <enum name="RGBA8" value="0x8058"/>
+ <enum name="RGB10_A2" value="0x8059"/>
+ <enum name="RGBA12" value="0x805A"/>
+ <enum name="RGBA16" value="0x805B"/>
+ <enum name="TEXTURE_RED_SIZE" count="1" value="0x805C">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_GREEN_SIZE" count="1" value="0x805D">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_BLUE_SIZE" count="1" value="0x805E">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_ALPHA_SIZE" count="1" value="0x805F">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_LUMINANCE_SIZE" count="1" value="0x8060">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_INTENSITY_SIZE" count="1" value="0x8061">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="PROXY_TEXTURE_1D" value="0x8063"/>
+ <enum name="PROXY_TEXTURE_2D" value="0x8064"/>
+ <enum name="TEXTURE_PRIORITY" count="1" value="0x8066">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_RESIDENT" count="1" value="0x8067">
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_BINDING_1D" count="1" value="0x8068">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_BINDING_2D" count="1" value="0x8069">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="VERTEX_ARRAY" count="1" value="0x8074">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="NORMAL_ARRAY" count="1" value="0x8075">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="COLOR_ARRAY" count="1" value="0x8076">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="INDEX_ARRAY" count="1" value="0x8077">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_COORD_ARRAY" count="1" value="0x8078">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="EDGE_FLAG_ARRAY" count="1" value="0x8079">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="VERTEX_ARRAY_SIZE" count="1" value="0x807A">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="VERTEX_ARRAY_TYPE" count="1" value="0x807B">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="VERTEX_ARRAY_STRIDE" count="1" value="0x807C">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="NORMAL_ARRAY_TYPE" count="1" value="0x807E">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="NORMAL_ARRAY_STRIDE" count="1" value="0x807F">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="COLOR_ARRAY_SIZE" count="1" value="0x8081">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="COLOR_ARRAY_TYPE" count="1" value="0x8082">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="COLOR_ARRAY_STRIDE" count="1" value="0x8083">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="INDEX_ARRAY_TYPE" count="1" value="0x8085">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="INDEX_ARRAY_STRIDE" count="1" value="0x8086">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_COORD_ARRAY_SIZE" count="1" value="0x8088">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_COORD_ARRAY_TYPE" count="1" value="0x8089">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_COORD_ARRAY_STRIDE" count="1" value="0x808A">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="EDGE_FLAG_ARRAY_STRIDE" count="1" value="0x808C">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="VERTEX_ARRAY_POINTER" value="0x808E"/>
+ <enum name="NORMAL_ARRAY_POINTER" value="0x808F"/>
+ <enum name="COLOR_ARRAY_POINTER" value="0x8090"/>
+ <enum name="INDEX_ARRAY_POINTER" value="0x8091"/>
+ <enum name="TEXTURE_COORD_ARRAY_POINTER" value="0x8092"/>
+ <enum name="EDGE_FLAG_ARRAY_POINTER" value="0x8093"/>
+ <enum name="CLIENT_PIXEL_STORE_BIT" value="0x00000001"/>
+ <enum name="CLIENT_VERTEX_ARRAY_BIT" value="0x00000002"/>
+ <enum name="ALL_CLIENT_ATTRIB_BITS" value="0xFFFFFFFF"/>
+ <enum name="CLIENT_ALL_ATTRIB_BITS" value="0xFFFFFFFF"/>
+
+ <function name="ArrayElement" offset="306">
+ <param name="i" type="GLint"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="ColorPointer" offset="308">
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="DisableClientState" offset="309">
+ <param name="array" type="GLenum"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="DrawArrays" offset="310">
+ <param name="mode" type="GLenum"/>
+ <param name="first" type="GLint"/>
+ <param name="count" type="GLsizei"/>
+ <glx rop="193" handcode="true"/>
+ </function>
+
+ <function name="DrawElements" offset="311">
+ <param name="mode" type="GLenum"/>
+ <param name="count" type="GLsizei"/>
+ <param name="type" type="GLenum"/>
+ <param name="indices" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="EdgeFlagPointer" offset="312">
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="EnableClientState" offset="313">
+ <param name="array" type="GLenum"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="GetPointerv" offset="329">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLvoid **" output="true"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="IndexPointer" offset="314">
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="InterleavedArrays" offset="317">
+ <param name="format" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="NormalPointer" offset="318">
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="TexCoordPointer" offset="320">
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="VertexPointer" offset="321">
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="PolygonOffset" offset="319">
+ <param name="factor" type="GLfloat"/>
+ <param name="units" type="GLfloat"/>
+ <glx rop="192"/>
+ </function>
+
+ <function name="CopyTexImage1D" offset="323">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="border" type="GLint"/>
+ <glx rop="4119"/>
+ </function>
+
+ <function name="CopyTexImage2D" offset="324">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="border" type="GLint"/>
+ <glx rop="4120"/>
+ </function>
+
+ <function name="CopyTexSubImage1D" offset="325">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <glx rop="4121"/>
+ </function>
+
+ <function name="CopyTexSubImage2D" offset="326">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="yoffset" type="GLint"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <glx rop="4122"/>
+ </function>
+
+ <function name="TexSubImage1D" offset="332">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="pixels" type="const GLvoid *" img_width="width" img_xoff="xoffset" img_format="format" img_type="type" img_target="target" img_null_flag="true" img_pad_dimensions="true"/>
+ <glx rop="4099" large="true"/>
+ </function>
+
+ <function name="TexSubImage2D" offset="333">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="yoffset" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="pixels" type="const GLvoid *" img_width="width" img_height="height" img_xoff="xoffset" img_yoff="yoffset" img_format="format" img_type="type" img_target="target" img_null_flag="true" img_pad_dimensions="true"/>
+ <glx rop="4100" large="true"/>
+ </function>
+
+ <function name="AreTexturesResident" offset="322">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="textures" type="const GLuint *" count="n"/>
+ <param name="residences" type="GLboolean *" output="true" count="n"/>
+ <return type="GLboolean"/>
+ <glx sop="143" always_array="true"/>
+ </function>
+
+ <function name="BindTexture" offset="307">
+ <param name="target" type="GLenum"/>
+ <param name="texture" type="GLuint"/>
+ <glx rop="4117"/>
+ </function>
+
+ <function name="DeleteTextures" offset="327">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="textures" type="const GLuint *" count="n"/>
+ <glx sop="144"/>
+ </function>
+
+ <function name="GenTextures" offset="328">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="textures" type="GLuint *" output="true" count="n"/>
+ <glx sop="145" always_array="true"/>
+ </function>
+
+ <function name="IsTexture" offset="330">
+ <param name="texture" type="GLuint"/>
+ <return type="GLboolean"/>
+ <glx sop="146"/>
+ </function>
+
+ <function name="PrioritizeTextures" offset="331">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="textures" type="const GLuint *" count="n"/>
+ <param name="priorities" type="const GLclampf *" count="n"/>
+ <glx rop="4118"/>
+ </function>
+
+ <function name="Indexub" offset="315" vectorequiv="Indexubv">
+ <param name="c" type="GLubyte"/>
+ </function>
+
+ <function name="Indexubv" offset="316">
+ <param name="c" type="const GLubyte *" count="1"/>
+ <glx rop="194"/>
+ </function>
+
+ <function name="PopClientAttrib" offset="334">
+ <glx handcode="true"/>
+ </function>
+
+ <function name="PushClientAttrib" offset="335">
+ <param name="mask" type="GLbitfield"/>
+ <glx handcode="true"/>
+ </function>
+</category>
+
+<category name="1.2">
+ <enum name="UNSIGNED_BYTE_3_3_2" value="0x8032"/>
+ <enum name="UNSIGNED_SHORT_4_4_4_4" value="0x8033"/>
+ <enum name="UNSIGNED_SHORT_5_5_5_1" value="0x8034"/>
+ <enum name="UNSIGNED_INT_8_8_8_8" value="0x8035"/>
+ <enum name="UNSIGNED_INT_10_10_10_2" value="0x8036"/>
+ <enum name="RESCALE_NORMAL" count="1" value="0x803A">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_BINDING_3D" count="1" value="0x806A">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PACK_SKIP_IMAGES" count="1" value="0x806B">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PACK_IMAGE_HEIGHT" count="1" value="0x806C">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="UNPACK_SKIP_IMAGES" count="1" value="0x806D">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="UNPACK_IMAGE_HEIGHT" count="1" value="0x806E">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_3D" count="1" value="0x806F">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PROXY_TEXTURE_3D" value="0x8070"/>
+ <enum name="TEXTURE_DEPTH" count="1" value="0x8071">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_WRAP_R" count="1" value="0x8072">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="MAX_3D_TEXTURE_SIZE" value="0x8073"/>
+ <enum name="UNSIGNED_BYTE_2_3_3_REV" value="0x8362"/>
+ <enum name="UNSIGNED_SHORT_5_6_5" value="0x8363"/>
+ <enum name="UNSIGNED_SHORT_5_6_5_REV" value="0x8364"/>
+ <enum name="UNSIGNED_SHORT_4_4_4_4_REV" value="0x8365"/>
+ <enum name="UNSIGNED_SHORT_1_5_5_5_REV" value="0x8366"/>
+ <enum name="UNSIGNED_INT_8_8_8_8_REV" value="0x8367"/>
+ <enum name="UNSIGNED_INT_2_10_10_10_REV" value="0x8368"/>
+ <enum name="BGR" value="0x80E0"/>
+ <enum name="BGRA" value="0x80E1"/>
+ <enum name="MAX_ELEMENTS_VERTICES" count="1" value="0x80E8">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_ELEMENTS_INDICES" count="1" value="0x80E9">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CLAMP_TO_EDGE" value="0x812F"/>
+ <enum name="TEXTURE_MIN_LOD" count="1" value="0x813A">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_MAX_LOD" count="1" value="0x813B">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_BASE_LEVEL" count="1" value="0x813C">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_MAX_LEVEL" count="1" value="0x813D">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="LIGHT_MODEL_COLOR_CONTROL" count="1" value="0x81F8">
+ <size name="LightModelfv"/>
+ <size name="LightModeliv"/>
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SINGLE_COLOR" value="0x81F9"/>
+ <enum name="SEPARATE_SPECULAR_COLOR" value="0x81FA"/>
+ <enum name="SMOOTH_POINT_SIZE_RANGE" count="2" value="0x0B12">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SMOOTH_POINT_SIZE_GRANULARITY" count="1" value="0x0B13">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SMOOTH_LINE_WIDTH_RANGE" count="2" value="0x0B22">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SMOOTH_LINE_WIDTH_GRANULARITY" count="1" value="0x0B23">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="ALIASED_POINT_SIZE_RANGE" count="2" value="0x846D">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="ALIASED_LINE_WIDTH_RANGE" count="2" value="0x846E">
+ <size name="Get" mode="get"/>
+ </enum>
+
+ <!-- These enums are actually part of the ARB_imaging subset. -->
+
+ <enum name="CONSTANT_COLOR" value="0x8001"/>
+ <enum name="ONE_MINUS_CONSTANT_COLOR" value="0x8002"/>
+ <enum name="CONSTANT_ALPHA" value="0x8003"/>
+ <enum name="ONE_MINUS_CONSTANT_ALPHA" value="0x8004"/>
+ <enum name="BLEND_COLOR" count="4" value="0x8005">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FUNC_ADD" value="0x8006"/>
+ <enum name="MIN" value="0x8007"/>
+ <enum name="MAX" value="0x8008"/>
+ <enum name="BLEND_EQUATION" count="1" value="0x8009">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FUNC_SUBTRACT" value="0x800A"/>
+ <enum name="FUNC_REVERSE_SUBTRACT" value="0x800B"/>
+ <enum name="CONVOLUTION_1D" count="1" value="0x8010">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CONVOLUTION_2D" count="1" value="0x8011">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SEPARABLE_2D" count="1" value="0x8012">
+ <size name="Get" mode="get"/>
+ </enum>
+
+ <enum name="CONVOLUTION_BORDER_MODE" count="1" value="0x8013">
+ <size name="ConvolutionParameterfv"/>
+ <size name="ConvolutionParameteriv"/>
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ </enum>
+ <enum name="CONVOLUTION_BORDER_COLOR" count="4" value="0x8154">
+ <size name="ConvolutionParameterfv"/>
+ <size name="ConvolutionParameteriv"/>
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ </enum>
+ <enum name="CONVOLUTION_FILTER_SCALE" count="4" value="0x8014">
+ <size name="ConvolutionParameterfv"/>
+ <size name="ConvolutionParameteriv"/>
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ </enum>
+ <enum name="CONVOLUTION_FILTER_BIAS" count="4" value="0x8015">
+ <size name="ConvolutionParameterfv"/>
+ <size name="ConvolutionParameteriv"/>
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ </enum>
+ <enum name="REDUCE" value="0x8016"/>
+ <enum name="CONVOLUTION_FORMAT" count="1" value="0x8017">
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ </enum>
+ <enum name="CONVOLUTION_WIDTH" count="1" value="0x8018">
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ </enum>
+ <enum name="CONVOLUTION_HEIGHT" count="1" value="0x8019">
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ </enum>
+ <enum name="MAX_CONVOLUTION_WIDTH" count="1" value="0x801A">
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_CONVOLUTION_HEIGHT" count="1" value="0x801B">
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_CONVOLUTION_RED_SCALE" count="1" value="0x801C">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_CONVOLUTION_GREEN_SCALE" count="1" value="0x801D">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_CONVOLUTION_BLUE_SCALE" count="1" value="0x801E">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_CONVOLUTION_ALPHA_SCALE" count="1" value="0x801F">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_CONVOLUTION_RED_BIAS" count="1" value="0x8020">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_CONVOLUTION_GREEN_BIAS" count="1" value="0x8021">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_CONVOLUTION_BLUE_BIAS" count="1" value="0x8022">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_CONVOLUTION_ALPHA_BIAS" count="1" value="0x8023">
+ <size name="Get" mode="get"/>
+ </enum>
+
+ <enum name="HISTOGRAM" count="1" value="0x8024">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PROXY_HISTOGRAM" value="0x8025"/>
+ <enum name="HISTOGRAM_WIDTH" count="1" value="0x8026">
+ <size name="GetHistogramParameterfv" mode="get"/>
+ <size name="GetHistogramParameteriv" mode="get"/>
+ </enum>
+ <enum name="HISTOGRAM_FORMAT" count="1" value="0x8027">
+ <size name="GetHistogramParameterfv" mode="get"/>
+ <size name="GetHistogramParameteriv" mode="get"/>
+ </enum>
+ <enum name="HISTOGRAM_RED_SIZE" count="1" value="0x8028">
+ <size name="GetHistogramParameterfv" mode="get"/>
+ <size name="GetHistogramParameteriv" mode="get"/>
+ </enum>
+ <enum name="HISTOGRAM_GREEN_SIZE" count="1" value="0x8029">
+ <size name="GetHistogramParameterfv" mode="get"/>
+ <size name="GetHistogramParameteriv" mode="get"/>
+ </enum>
+ <enum name="HISTOGRAM_BLUE_SIZE" count="1" value="0x802A">
+ <size name="GetHistogramParameterfv" mode="get"/>
+ <size name="GetHistogramParameteriv" mode="get"/>
+ </enum>
+ <enum name="HISTOGRAM_ALPHA_SIZE" count="1" value="0x802B">
+ <size name="GetHistogramParameterfv" mode="get"/>
+ <size name="GetHistogramParameteriv" mode="get"/>
+ </enum>
+ <enum name="HISTOGRAM_LUMINANCE_SIZE" count="1" value="0x802C">
+ <size name="GetHistogramParameterfv" mode="get"/>
+ <size name="GetHistogramParameteriv" mode="get"/>
+ </enum>
+ <enum name="HISTOGRAM_SINK" count="1" value="0x802D">
+ <size name="GetHistogramParameterfv" mode="get"/>
+ <size name="GetHistogramParameteriv" mode="get"/>
+ </enum>
+ <enum name="MINMAX" count="1" value="0x802E">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MINMAX_FORMAT" count="1" value="0x802F">
+ <size name="GetMinmaxParameterfv" mode="get"/>
+ <size name="GetMinmaxParameteriv" mode="get"/>
+ </enum>
+ <enum name="MINMAX_SINK" count="1" value="0x8030">
+ <size name="GetMinmaxParameterfv" mode="get"/>
+ <size name="GetMinmaxParameteriv" mode="get"/>
+ </enum>
+
+ <enum name="COLOR_MATRIX" count="16" value="0x80B1">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="COLOR_MATRIX_STACK_DEPTH" count="1" value="0x80B2">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_COLOR_MATRIX_STACK_DEPTH" count="1" value="0x80B3">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_COLOR_MATRIX_RED_SCALE" count="1" value="0x80B4">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_COLOR_MATRIX_GREEN_SCALE" count="1" value="0x80B5">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_COLOR_MATRIX_BLUE_SCALE" count="1" value="0x80B6">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_COLOR_MATRIX_ALPHA_SCALE" count="1" value="0x80B7">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_COLOR_MATRIX_RED_BIAS" count="1" value="0x80B8">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_COLOR_MATRIX_GREEN_BIAS" count="1" value="0x80B9">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_COLOR_MATRIX_BLUE_BIAS" count="1" value="0x80BA">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_COLOR_MATRIX_ALPHA_BIAS" count="1" value="0x80BB">
+ <size name="Get" mode="get"/>
+ </enum>
+
+ <enum name="COLOR_TABLE" count="1" value="0x80D0">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_CONVOLUTION_COLOR_TABLE" count="1" value="0x80D1">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_COLOR_MATRIX_COLOR_TABLE" count="1" value="0x80D2">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PROXY_COLOR_TABLE" value="0x80D3"/>
+ <enum name="PROXY_POST_CONVOLUTION_COLOR_TABLE" value="0x80D4"/>
+ <enum name="PROXY_POST_COLOR_MATRIX_COLOR_TABLE" value="0x80D5"/>
+
+ <enum name="COLOR_TABLE_SCALE" count="4" value="0x80D6">
+ <size name="ColorTableParameterfv"/>
+ <size name="ColorTableParameteriv"/>
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+ <enum name="COLOR_TABLE_BIAS" count="4" value="0x80D7">
+ <size name="ColorTableParameterfv"/>
+ <size name="ColorTableParameteriv"/>
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+ <enum name="COLOR_TABLE_FORMAT" count="1" value="0x80D8">
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+ <enum name="COLOR_TABLE_WIDTH" count="1" value="0x80D9">
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+ <enum name="COLOR_TABLE_RED_SIZE" count="1" value="0x80DA">
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+ <enum name="COLOR_TABLE_GREEN_SIZE" count="1" value="0x80DB">
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+ <enum name="COLOR_TABLE_BLUE_SIZE" count="1" value="0x80DC">
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+ <enum name="COLOR_TABLE_ALPHA_SIZE" count="1" value="0x80DD">
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+ <enum name="COLOR_TABLE_LUMINANCE_SIZE" count="1" value="0x80DE">
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+ <enum name="COLOR_TABLE_INTENSITY_SIZE" count="1" value="0x80DF">
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+
+
+ <function name="BlendColor" offset="336">
+ <param name="red" type="GLclampf"/>
+ <param name="green" type="GLclampf"/>
+ <param name="blue" type="GLclampf"/>
+ <param name="alpha" type="GLclampf"/>
+ <glx rop="4096"/>
+ </function>
+
+ <function name="BlendEquation" offset="337">
+ <param name="mode" type="GLenum"/>
+ <glx rop="4097"/>
+ </function>
+
+ <function name="DrawRangeElements" offset="338">
+ <param name="mode" type="GLenum"/>
+ <param name="start" type="GLuint"/>
+ <param name="end" type="GLuint"/>
+ <param name="count" type="GLsizei"/>
+ <param name="type" type="GLenum"/>
+ <param name="indices" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="ColorTable" offset="339">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="table" type="const GLvoid *" img_width="width" img_pad_dimensions="false" img_format="format" img_type="type" img_target="target"/>
+ <glx rop="2053" large="true"/>
+ </function>
+
+ <function name="ColorTableParameterfv" offset="340">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *" variable_param="pname"/>
+ <glx rop="2054"/>
+ </function>
+
+ <function name="ColorTableParameteriv" offset="341">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *" variable_param="pname"/>
+ <glx rop="2055"/>
+ </function>
+
+ <function name="CopyColorTable" offset="342">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <glx rop="2056"/>
+ </function>
+
+ <function name="GetColorTable" offset="343">
+ <param name="target" type="GLenum"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="table" type="GLvoid *" output="true" img_width="width" img_format="format" img_type="type"/>
+ <glx sop="147" dimensions_in_reply="true"/>
+ </function>
+
+ <function name="GetColorTableParameterfv" offset="344">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx sop="148"/>
+ </function>
+
+ <function name="GetColorTableParameteriv" offset="345">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx sop="149"/>
+ </function>
+
+ <function name="ColorSubTable" offset="346">
+ <param name="target" type="GLenum"/>
+ <param name="start" type="GLsizei"/>
+ <param name="count" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="data" type="const GLvoid *" img_width="count" img_pad_dimensions="false" img_format="format" img_type="type" img_target="target"/>
+ <glx rop="195" large="true"/>
+ </function>
+
+ <function name="CopyColorSubTable" offset="347">
+ <param name="target" type="GLenum"/>
+ <param name="start" type="GLsizei"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <glx rop="196"/>
+ </function>
+
+ <function name="ConvolutionFilter1D" offset="348">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="image" type="const GLvoid *" img_width="width" img_format="format" img_type="type" img_target="target" img_pad_dimensions="true"/>
+ <glx rop="4101" large="true"/>
+ </function>
+
+ <function name="ConvolutionFilter2D" offset="349">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="image" type="const GLvoid *" img_width="width" img_height="height" img_format="format" img_type="type" img_target="target" img_pad_dimensions="true"/>
+ <glx rop="4102" large="true"/>
+ </function>
+
+ <function name="ConvolutionParameterf" offset="350">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat"/>
+ <glx rop="4103"/>
+ </function>
+
+ <function name="ConvolutionParameterfv" offset="351">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *" variable_param="pname"/>
+ <glx rop="4104"/>
+ </function>
+
+ <function name="ConvolutionParameteri" offset="352">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint"/>
+ <glx rop="4105"/>
+ </function>
+
+ <function name="ConvolutionParameteriv" offset="353">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *" variable_param="pname"/>
+ <glx rop="4106"/>
+ </function>
+
+ <function name="CopyConvolutionFilter1D" offset="354">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <glx rop="4107"/>
+ </function>
+
+ <function name="CopyConvolutionFilter2D" offset="355">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <glx rop="4108"/>
+ </function>
+
+ <function name="GetConvolutionFilter" offset="356">
+ <param name="target" type="GLenum"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="image" type="GLvoid *" output="true" img_width="width" img_height="height" img_format="format" img_type="type"/>
+ <glx sop="150" dimensions_in_reply="true"/>
+ </function>
+
+ <function name="GetConvolutionParameterfv" offset="357">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx sop="151"/>
+ </function>
+
+ <function name="GetConvolutionParameteriv" offset="358">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx sop="152"/>
+ </function>
+
+ <function name="GetSeparableFilter" offset="359">
+ <param name="target" type="GLenum"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="row" type="GLvoid *" output="true"/>
+ <param name="column" type="GLvoid *" output="true"/>
+ <param name="span" type="GLvoid *" output="true"/>
+ <glx sop="153" handcode="true"/>
+ </function>
+
+ <function name="SeparableFilter2D" offset="360">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="row" type="const GLvoid *"/>
+ <param name="column" type="const GLvoid *"/>
+ <glx rop="4109" handcode="true"/>
+ </function>
+
+ <function name="GetHistogram" offset="361">
+ <param name="target" type="GLenum"/>
+ <param name="reset" type="GLboolean"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="values" type="GLvoid *" output="true" img_width="width" img_format="format" img_type="type"/>
+ <glx sop="154" dimensions_in_reply="true" img_reset="reset"/>
+ </function>
+
+ <function name="GetHistogramParameterfv" offset="362">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx sop="155"/>
+ </function>
+
+ <function name="GetHistogramParameteriv" offset="363">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx sop="156"/>
+ </function>
+
+ <function name="GetMinmax" offset="364">
+ <param name="target" type="GLenum"/>
+ <param name="reset" type="GLboolean"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="values" type="GLvoid *" output="true" img_width="2" img_format="format" img_type="type"/>
+ <glx sop="157" img_reset="reset"/>
+ </function>
+
+ <function name="GetMinmaxParameterfv" offset="365">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx sop="158"/>
+ </function>
+
+ <function name="GetMinmaxParameteriv" offset="366">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx sop="159"/>
+ </function>
+
+ <function name="Histogram" offset="367">
+ <param name="target" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="sink" type="GLboolean"/>
+ <glx rop="4110"/>
+ </function>
+
+ <function name="Minmax" offset="368">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="sink" type="GLboolean"/>
+ <glx rop="4111"/>
+ </function>
+
+ <function name="ResetHistogram" offset="369">
+ <param name="target" type="GLenum"/>
+ <glx rop="4112"/>
+ </function>
+
+ <function name="ResetMinmax" offset="370">
+ <param name="target" type="GLenum"/>
+ <glx rop="4113"/>
+ </function>
+
+ <function name="TexImage3D" offset="371">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="internalformat" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="depth" type="GLsizei"/>
+ <param name="border" type="GLint"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="pixels" type="const GLvoid *" img_width="width" img_height="height" img_depth="depth" img_format="format" img_type="type" img_target="target" img_null_flag="true" img_pad_dimensions="true"/>
+ <glx rop="4114" large="true"/>
+ </function>
+
+ <function name="TexSubImage3D" offset="372">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="yoffset" type="GLint"/>
+ <param name="zoffset" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="depth" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="pixels" type="const GLvoid *" img_width="width" img_height="height" img_depth="depth" img_xoff="xoffset" img_yoff="yoffset" img_zoff="zoffset" img_format="format" img_type="type" img_target="target" img_null_flag="true" img_pad_dimensions="true"/>
+ <glx rop="4115" large="true"/>
+ </function>
+
+ <function name="CopyTexSubImage3D" offset="373">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="yoffset" type="GLint"/>
+ <param name="zoffset" type="GLint"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <glx rop="4123"/>
+ </function>
+</category>
+
+<category name="1.3">
+ <enum name="TEXTURE0" value="0x84C0"/>
+ <enum name="TEXTURE1" value="0x84C1"/>
+ <enum name="TEXTURE2" value="0x84C2"/>
+ <enum name="TEXTURE3" value="0x84C3"/>
+ <enum name="TEXTURE4" value="0x84C4"/>
+ <enum name="TEXTURE5" value="0x84C5"/>
+ <enum name="TEXTURE6" value="0x84C6"/>
+ <enum name="TEXTURE7" value="0x84C7"/>
+ <enum name="TEXTURE8" value="0x84C8"/>
+ <enum name="TEXTURE9" value="0x84C9"/>
+ <enum name="TEXTURE10" value="0x84CA"/>
+ <enum name="TEXTURE11" value="0x84CB"/>
+ <enum name="TEXTURE12" value="0x84CC"/>
+ <enum name="TEXTURE13" value="0x84CD"/>
+ <enum name="TEXTURE14" value="0x84CE"/>
+ <enum name="TEXTURE15" value="0x84CF"/>
+ <enum name="TEXTURE16" value="0x84D0"/>
+ <enum name="TEXTURE17" value="0x84D1"/>
+ <enum name="TEXTURE18" value="0x84D2"/>
+ <enum name="TEXTURE19" value="0x84D3"/>
+ <enum name="TEXTURE20" value="0x84D4"/>
+ <enum name="TEXTURE21" value="0x84D5"/>
+ <enum name="TEXTURE22" value="0x84D6"/>
+ <enum name="TEXTURE23" value="0x84D7"/>
+ <enum name="TEXTURE24" value="0x84D8"/>
+ <enum name="TEXTURE25" value="0x84D9"/>
+ <enum name="TEXTURE26" value="0x84DA"/>
+ <enum name="TEXTURE27" value="0x84DB"/>
+ <enum name="TEXTURE28" value="0x84DC"/>
+ <enum name="TEXTURE29" value="0x84DD"/>
+ <enum name="TEXTURE30" value="0x84DE"/>
+ <enum name="TEXTURE31" value="0x84DF"/>
+ <enum name="ACTIVE_TEXTURE" count="1" value="0x84E0">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CLIENT_ACTIVE_TEXTURE" count="1" value="0x84E1">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_TEXTURE_UNITS" count="1" value="0x84E2">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TRANSPOSE_MODELVIEW_MATRIX" value="0x84E3"/>
+ <enum name="TRANSPOSE_PROJECTION_MATRIX" value="0x84E4"/>
+ <enum name="TRANSPOSE_TEXTURE_MATRIX" value="0x84E5"/>
+ <enum name="TRANSPOSE_COLOR_MATRIX" value="0x84E6"/>
+ <enum name="MULTISAMPLE" count="1" value="0x809D">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SAMPLE_ALPHA_TO_COVERAGE" count="1" value="0x809E">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SAMPLE_ALPHA_TO_ONE" count="1" value="0x809F">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SAMPLE_COVERAGE" count="1" value="0x80A0">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SAMPLE_BUFFERS" count="1" value="0x80A8">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SAMPLES" count="1" value="0x80A9">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SAMPLE_COVERAGE_VALUE" count="1" value="0x80AA">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SAMPLE_COVERAGE_INVERT" count="1" value="0x80AB">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MULTISAMPLE_BIT" value="0x20000000"/>
+ <enum name="NORMAL_MAP" value="0x8511"/>
+ <enum name="REFLECTION_MAP" value="0x8512"/>
+ <enum name="TEXTURE_CUBE_MAP" count="1" value="0x8513">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_BINDING_CUBE_MAP" count="1" value="0x8514">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_CUBE_MAP_POSITIVE_X" value="0x8515"/>
+ <enum name="TEXTURE_CUBE_MAP_NEGATIVE_X" value="0x8516"/>
+ <enum name="TEXTURE_CUBE_MAP_POSITIVE_Y" value="0x8517"/>
+ <enum name="TEXTURE_CUBE_MAP_NEGATIVE_Y" value="0x8518"/>
+ <enum name="TEXTURE_CUBE_MAP_POSITIVE_Z" value="0x8519"/>
+ <enum name="TEXTURE_CUBE_MAP_NEGATIVE_Z" value="0x851A"/>
+ <enum name="PROXY_TEXTURE_CUBE_MAP" value="0x851B"/>
+ <enum name="MAX_CUBE_MAP_TEXTURE_SIZE" count="1" value="0x851C">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="COMPRESSED_ALPHA" value="0x84E9"/>
+ <enum name="COMPRESSED_LUMINANCE" value="0x84EA"/>
+ <enum name="COMPRESSED_LUMINANCE_ALPHA" value="0x84EB"/>
+ <enum name="COMPRESSED_INTENSITY" value="0x84EC"/>
+ <enum name="COMPRESSED_RGB" value="0x84ED"/>
+ <enum name="COMPRESSED_RGBA" value="0x84EE"/>
+ <enum name="TEXTURE_COMPRESSION_HINT" count="1" value="0x84EF">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_COMPRESSED_IMAGE_SIZE" count="1" value="0x86A0">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_COMPRESSED" count="1" value="0x86A1">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="NUM_COMPRESSED_TEXTURE_FORMATS" count="1" value="0x86A2">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="COMPRESSED_TEXTURE_FORMATS" count="-1" value="0x86A3">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CLAMP_TO_BORDER" value="0x812D"/>
+ <enum name="COMBINE" value="0x8570"/>
+ <enum name="COMBINE_RGB" count="1" value="0x8571">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="COMBINE_ALPHA" count="1" value="0x8572">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="SOURCE0_RGB" count="1" value="0x8580">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="SOURCE1_RGB" count="1" value="0x8581">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="SOURCE2_RGB" count="1" value="0x8582">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="SOURCE0_ALPHA" count="1" value="0x8588">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="SOURCE1_ALPHA" count="1" value="0x8589">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="SOURCE2_ALPHA" count="1" value="0x858A">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="OPERAND0_RGB" count="1" value="0x8590">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="OPERAND1_RGB" count="1" value="0x8591">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="OPERAND2_RGB" count="1" value="0x8592">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="OPERAND0_ALPHA" count="1" value="0x8598">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="OPERAND1_ALPHA" count="1" value="0x8599">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="OPERAND2_ALPHA" count="1" value="0x859A">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="RGB_SCALE" count="1" value="0x8573">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="ADD_SIGNED" value="0x8574"/>
+ <enum name="INTERPOLATE" value="0x8575"/>
+ <enum name="SUBTRACT" value="0x84E7"/>
+ <enum name="CONSTANT" value="0x8576"/>
+ <enum name="PRIMARY_COLOR" value="0x8577"/>
+ <enum name="PREVIOUS" value="0x8578"/>
+ <enum name="DOT3_RGB" value="0x86AE"/>
+ <enum name="DOT3_RGBA" value="0x86AF"/>
+
+ <function name="ActiveTexture" alias="ActiveTextureARB">
+ <param name="texture" type="GLenum"/>
+ </function>
+
+ <function name="ClientActiveTexture" alias="ClientActiveTextureARB">
+ <param name="texture" type="GLenum"/>
+ </function>
+
+ <function name="MultiTexCoord1d" alias="MultiTexCoord1dARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLdouble"/>
+ </function>
+
+ <function name="MultiTexCoord1dv" alias="MultiTexCoord1dvARB">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLdouble *"/>
+ </function>
+
+ <function name="MultiTexCoord1f" alias="MultiTexCoord1fARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLfloat"/>
+ </function>
+
+ <function name="MultiTexCoord1fv" alias="MultiTexCoord1fvARB">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="MultiTexCoord1i" alias="MultiTexCoord1iARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLint"/>
+ </function>
+
+ <function name="MultiTexCoord1iv" alias="MultiTexCoord1ivARB">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLint *"/>
+ </function>
+
+ <function name="MultiTexCoord1s" alias="MultiTexCoord1sARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLshort"/>
+ </function>
+
+ <function name="MultiTexCoord1sv" alias="MultiTexCoord1svARB">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLshort *"/>
+ </function>
+
+ <function name="MultiTexCoord2d" alias="MultiTexCoord2dARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLdouble"/>
+ <param name="t" type="GLdouble"/>
+ </function>
+
+ <function name="MultiTexCoord2dv" alias="MultiTexCoord2dvARB">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLdouble *"/>
+ </function>
+
+ <function name="MultiTexCoord2f" alias="MultiTexCoord2fARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ </function>
+
+ <function name="MultiTexCoord2fv" alias="MultiTexCoord2fvARB">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="MultiTexCoord2i" alias="MultiTexCoord2iARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLint"/>
+ <param name="t" type="GLint"/>
+ </function>
+
+ <function name="MultiTexCoord2iv" alias="MultiTexCoord2ivARB">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLint *"/>
+ </function>
+
+ <function name="MultiTexCoord2s" alias="MultiTexCoord2sARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLshort"/>
+ <param name="t" type="GLshort"/>
+ </function>
+
+ <function name="MultiTexCoord2sv" alias="MultiTexCoord2svARB">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLshort *"/>
+ </function>
+
+ <function name="MultiTexCoord3d" alias="MultiTexCoord3dARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLdouble"/>
+ <param name="t" type="GLdouble"/>
+ <param name="r" type="GLdouble"/>
+ </function>
+
+ <function name="MultiTexCoord3dv" alias="MultiTexCoord3dvARB">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLdouble *"/>
+ </function>
+
+ <function name="MultiTexCoord3f" alias="MultiTexCoord3fARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ <param name="r" type="GLfloat"/>
+ </function>
+
+ <function name="MultiTexCoord3fv" alias="MultiTexCoord3fvARB">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="MultiTexCoord3i" alias="MultiTexCoord3iARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLint"/>
+ <param name="t" type="GLint"/>
+ <param name="r" type="GLint"/>
+ </function>
+
+ <function name="MultiTexCoord3iv" alias="MultiTexCoord3ivARB">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLint *"/>
+ </function>
+
+ <function name="MultiTexCoord3s" alias="MultiTexCoord3sARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLshort"/>
+ <param name="t" type="GLshort"/>
+ <param name="r" type="GLshort"/>
+ </function>
+
+ <function name="MultiTexCoord3sv" alias="MultiTexCoord3svARB">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLshort *"/>
+ </function>
+
+ <function name="MultiTexCoord4d" alias="MultiTexCoord4dARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLdouble"/>
+ <param name="t" type="GLdouble"/>
+ <param name="r" type="GLdouble"/>
+ <param name="q" type="GLdouble"/>
+ </function>
+
+ <function name="MultiTexCoord4dv" alias="MultiTexCoord4dvARB">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLdouble *"/>
+ </function>
+
+ <function name="MultiTexCoord4f" alias="MultiTexCoord4fARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ <param name="r" type="GLfloat"/>
+ <param name="q" type="GLfloat"/>
+ </function>
+
+ <function name="MultiTexCoord4fv" alias="MultiTexCoord4fvARB">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="MultiTexCoord4i" alias="MultiTexCoord4iARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLint"/>
+ <param name="t" type="GLint"/>
+ <param name="r" type="GLint"/>
+ <param name="q" type="GLint"/>
+ </function>
+
+ <function name="MultiTexCoord4iv" alias="MultiTexCoord4ivARB">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLint *"/>
+ </function>
+
+ <function name="MultiTexCoord4s" alias="MultiTexCoord4sARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLshort"/>
+ <param name="t" type="GLshort"/>
+ <param name="r" type="GLshort"/>
+ <param name="q" type="GLshort"/>
+ </function>
+
+ <function name="MultiTexCoord4sv" alias="MultiTexCoord4svARB">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLshort *"/>
+ </function>
+
+ <function name="LoadTransposeMatrixf" alias="LoadTransposeMatrixfARB">
+ <param name="m" type="const GLfloat *"/>
+ </function>
+
+ <function name="LoadTransposeMatrixd" alias="LoadTransposeMatrixdARB">
+ <param name="m" type="const GLdouble *"/>
+ </function>
+
+ <function name="MultTransposeMatrixf" alias="MultTransposeMatrixfARB">
+ <param name="m" type="const GLfloat *"/>
+ </function>
+
+ <function name="MultTransposeMatrixd" alias="MultTransposeMatrixdARB">
+ <param name="m" type="const GLdouble *"/>
+ </function>
+
+ <function name="SampleCoverage" alias="SampleCoverageARB">
+ <param name="value" type="GLclampf"/>
+ <param name="invert" type="GLboolean"/>
+ </function>
+
+ <function name="CompressedTexImage3D" alias="CompressedTexImage3DARB">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="depth" type="GLsizei"/>
+ <param name="border" type="GLint"/>
+ <param name="imageSize" type="GLsizei"/>
+ <param name="data" type="const GLvoid *"/>
+ </function>
+
+ <function name="CompressedTexImage2D" alias="CompressedTexImage2DARB">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="border" type="GLint"/>
+ <param name="imageSize" type="GLsizei"/>
+ <param name="data" type="const GLvoid *"/>
+ </function>
+
+ <function name="CompressedTexImage1D" alias="CompressedTexImage1DARB">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="border" type="GLint"/>
+ <param name="imageSize" type="GLsizei"/>
+ <param name="data" type="const GLvoid *"/>
+ </function>
+
+ <function name="CompressedTexSubImage3D" alias="CompressedTexSubImage3DARB">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="yoffset" type="GLint"/>
+ <param name="zoffset" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="depth" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="imageSize" type="GLsizei"/>
+ <param name="data" type="const GLvoid *"/>
+ </function>
+
+ <function name="CompressedTexSubImage2D" alias="CompressedTexSubImage2DARB">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="yoffset" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="imageSize" type="GLsizei"/>
+ <param name="data" type="const GLvoid *"/>
+ </function>
+
+ <function name="CompressedTexSubImage1D" alias="CompressedTexSubImage1DARB">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="imageSize" type="GLsizei"/>
+ <param name="data" type="const GLvoid *"/>
+ </function>
+
+ <function name="GetCompressedTexImage" alias="GetCompressedTexImageARB">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="img" type="GLvoid *" output="true"/>
+ </function>
+</category>
+
+<category name="1.4">
+ <enum name="BLEND_DST_RGB" count="1" value="0x80C8">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="BLEND_SRC_RGB" count="1" value="0x80C9">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="BLEND_DST_ALPHA" count="1" value="0x80CA">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="BLEND_SRC_ALPHA" count="1" value="0x80CB">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POINT_SIZE_MIN" count="1" value="0x8126">
+ <size name="PointParameterfvEXT"/>
+ </enum>
+ <enum name="POINT_SIZE_MAX" count="1" value="0x8127">
+ <size name="PointParameterfvEXT"/>
+ </enum>
+ <enum name="POINT_FADE_THRESHOLD_SIZE" count="1" value="0x8128">
+ <size name="PointParameterfvEXT"/>
+ </enum>
+ <enum name="POINT_DISTANCE_ATTENUATION" count="3" value="0x8129">
+ <size name="PointParameterfvEXT"/>
+ </enum>
+ <enum name="GENERATE_MIPMAP" count="1" value="0x8191">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="GENERATE_MIPMAP_HINT" value="0x8192"/>
+ <enum name="DEPTH_COMPONENT16" value="0x81A5"/>
+ <enum name="DEPTH_COMPONENT24" value="0x81A6"/>
+ <enum name="DEPTH_COMPONENT32" value="0x81A7"/>
+ <enum name="MIRRORED_REPEAT" value="0x8370"/>
+ <enum name="FOG_COORDINATE_SOURCE" count="1" value="0x8450">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FOG_COORDINATE" value="0x8451"/>
+ <enum name="FRAGMENT_DEPTH" value="0x8452"/>
+ <enum name="CURRENT_FOG_COORDINATE" count="1" value="0x8453">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FOG_COORDINATE_ARRAY_TYPE" count="1" value="0x8454">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FOG_COORDINATE_ARRAY_STRIDE" count="1" value="0x8455">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FOG_COORDINATE_ARRAY_POINTER" value="0x8456"/>
+ <enum name="FOG_COORDINATE_ARRAY" count="1" value="0x8457">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="COLOR_SUM" value="0x8458"/>
+ <enum name="CURRENT_SECONDARY_COLOR" count="4" value="0x8459">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SECONDARY_COLOR_ARRAY_SIZE" count="1" value="0x845A">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SECONDARY_COLOR_ARRAY_TYPE" count="1" value="0x845B">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SECONDARY_COLOR_ARRAY_STRIDE" count="1" value="0x845C">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SECONDARY_COLOR_ARRAY_POINTER" value="0x845D"/>
+ <enum name="SECONDARY_COLOR_ARRAY" count="1" value="0x845E">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_TEXTURE_LOD_BIAS" count="1" value="0x84FD">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_FILTER_CONTROL" value="0x8500"/>
+ <enum name="TEXTURE_LOD_BIAS" count="1" value="0x8501">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="INCR_WRAP" value="0x8507"/>
+ <enum name="DECR_WRAP" value="0x8508"/>
+ <enum name="TEXTURE_DEPTH_SIZE" count="1" value="0x884A">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="DEPTH_TEXTURE_MODE" count="1" value="0x884B">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_COMPARE_MODE" count="1" value="0x884C">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_COMPARE_FUNC" count="1" value="0x884D">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="COMPARE_R_TO_TEXTURE" value="0x884E"/>
+
+ <function name="BlendFuncSeparate" alias="BlendFuncSeparateEXT">
+ <param name="sfactorRGB" type="GLenum"/>
+ <param name="dfactorRGB" type="GLenum"/>
+ <param name="sfactorAlpha" type="GLenum"/>
+ <param name="dfactorAlpha" type="GLenum"/>
+ </function>
+
+ <function name="FogCoordf" alias="FogCoordfEXT">
+ <param name="coord" type="GLfloat"/>
+ </function>
+
+ <function name="FogCoordfv" alias="FogCoordfvEXT">
+ <param name="coord" type="const GLfloat *"/>
+ </function>
+
+ <function name="FogCoordd" alias="FogCoorddEXT">
+ <param name="coord" type="GLdouble"/>
+ </function>
+
+ <function name="FogCoorddv" alias="FogCoorddvEXT">
+ <param name="coord" type="const GLdouble *"/>
+ </function>
+
+ <function name="FogCoordPointer" alias="FogCoordPointerEXT">
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ </function>
+
+ <function name="MultiDrawArrays" alias="MultiDrawArraysEXT">
+ <param name="mode" type="GLenum"/>
+ <param name="first" type="GLint *"/> <!-- Spec bug. Should be const. -->
+ <param name="count" type="GLsizei *"/> <!-- Spec bug. Should be const. -->
+ <param name="primcount" type="GLsizei"/>
+ </function>
+
+ <function name="MultiDrawElements" alias="MultiDrawElementsEXT">
+ <param name="mode" type="GLenum"/>
+ <param name="count" type="const GLsizei *"/>
+ <param name="type" type="GLenum"/>
+ <param name="indices" type="const GLvoid **"/>
+ <param name="primcount" type="GLsizei"/>
+ </function>
+
+ <function name="PointParameterf" alias="PointParameterfEXT">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ </function>
+
+ <function name="PointParameterfv" alias="PointParameterfvEXT">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *"/>
+ </function>
+
+ <function name="PointParameteri" alias="PointParameteriNV">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ </function>
+
+ <function name="PointParameteriv" alias="PointParameterivNV">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *"/>
+ </function>
+
+ <function name="SecondaryColor3b" alias="SecondaryColor3bEXT">
+ <param name="red" type="GLbyte"/>
+ <param name="green" type="GLbyte"/>
+ <param name="blue" type="GLbyte"/>
+ </function>
+
+ <function name="SecondaryColor3bv" alias="SecondaryColor3bvEXT">
+ <param name="v" type="const GLbyte *"/>
+ </function>
+
+ <function name="SecondaryColor3d" alias="SecondaryColor3dEXT">
+ <param name="red" type="GLdouble"/>
+ <param name="green" type="GLdouble"/>
+ <param name="blue" type="GLdouble"/>
+ </function>
+
+ <function name="SecondaryColor3dv" alias="SecondaryColor3dvEXT">
+ <param name="v" type="const GLdouble *"/>
+ </function>
+
+ <function name="SecondaryColor3f" alias="SecondaryColor3fEXT">
+ <param name="red" type="GLfloat"/>
+ <param name="green" type="GLfloat"/>
+ <param name="blue" type="GLfloat"/>
+ </function>
+
+ <function name="SecondaryColor3fv" alias="SecondaryColor3fvEXT">
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="SecondaryColor3i" alias="SecondaryColor3iEXT">
+ <param name="red" type="GLint"/>
+ <param name="green" type="GLint"/>
+ <param name="blue" type="GLint"/>
+ </function>
+
+ <function name="SecondaryColor3iv" alias="SecondaryColor3ivEXT">
+ <param name="v" type="const GLint *"/>
+ </function>
+
+ <function name="SecondaryColor3s" alias="SecondaryColor3sEXT">
+ <param name="red" type="GLshort"/>
+ <param name="green" type="GLshort"/>
+ <param name="blue" type="GLshort"/>
+ </function>
+
+ <function name="SecondaryColor3sv" alias="SecondaryColor3svEXT">
+ <param name="v" type="const GLshort *"/>
+ </function>
+
+ <function name="SecondaryColor3ub" alias="SecondaryColor3ubEXT">
+ <param name="red" type="GLubyte"/>
+ <param name="green" type="GLubyte"/>
+ <param name="blue" type="GLubyte"/>
+ </function>
+
+ <function name="SecondaryColor3ubv" alias="SecondaryColor3ubvEXT">
+ <param name="v" type="const GLubyte *"/>
+ </function>
+
+ <function name="SecondaryColor3ui" alias="SecondaryColor3uiEXT">
+ <param name="red" type="GLuint"/>
+ <param name="green" type="GLuint"/>
+ <param name="blue" type="GLuint"/>
+ </function>
+
+ <function name="SecondaryColor3uiv" alias="SecondaryColor3uivEXT">
+ <param name="v" type="const GLuint *"/>
+ </function>
+
+ <function name="SecondaryColor3us" alias="SecondaryColor3usEXT">
+ <param name="red" type="GLushort"/>
+ <param name="green" type="GLushort"/>
+ <param name="blue" type="GLushort"/>
+ </function>
+
+ <function name="SecondaryColor3usv" alias="SecondaryColor3usvEXT">
+ <param name="v" type="const GLushort *"/>
+ </function>
+
+ <function name="SecondaryColorPointer" alias="SecondaryColorPointerEXT">
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ </function>
+
+ <function name="WindowPos2d" alias="WindowPos2dMESA">
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ </function>
+
+ <function name="WindowPos2dv" alias="WindowPos2dvMESA">
+ <param name="v" type="const GLdouble *"/>
+ </function>
+
+ <function name="WindowPos2f" alias="WindowPos2fMESA">
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ </function>
+
+ <function name="WindowPos2fv" alias="WindowPos2fvMESA">
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="WindowPos2i" alias="WindowPos2iMESA">
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ </function>
+
+ <function name="WindowPos2iv" alias="WindowPos2ivMESA">
+ <param name="v" type="const GLint *"/>
+ </function>
+
+ <function name="WindowPos2s" alias="WindowPos2sMESA">
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ </function>
+
+ <function name="WindowPos2sv" alias="WindowPos2svMESA">
+ <param name="v" type="const GLshort *"/>
+ </function>
+
+ <function name="WindowPos3d" alias="WindowPos3dMESA">
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ </function>
+
+ <function name="WindowPos3dv" alias="WindowPos3dvMESA">
+ <param name="v" type="const GLdouble *"/>
+ </function>
+
+ <function name="WindowPos3f" alias="WindowPos3fMESA">
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="WindowPos3fv" alias="WindowPos3fvMESA">
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="WindowPos3i" alias="WindowPos3iMESA">
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="z" type="GLint"/>
+ </function>
+
+ <function name="WindowPos3iv" alias="WindowPos3ivMESA">
+ <param name="v" type="const GLint *"/>
+ </function>
+
+ <function name="WindowPos3s" alias="WindowPos3sMESA">
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ <param name="z" type="GLshort"/>
+ </function>
+
+ <function name="WindowPos3sv" alias="WindowPos3svMESA">
+ <param name="v" type="const GLshort *"/>
+ </function>
+</category>
+
+<category name="1.5">
+ <enum name="BUFFER_SIZE" value="0x8764"/>
+ <enum name="BUFFER_USAGE" value="0x8765"/>
+ <enum name="QUERY_COUNTER_BITS" value="0x8864"/>
+ <enum name="CURRENT_QUERY" value="0x8865"/>
+ <enum name="QUERY_RESULT" value="0x8866"/>
+ <enum name="QUERY_RESULT_AVAILABLE" value="0x8867"/>
+ <enum name="ARRAY_BUFFER" value="0x8892"/>
+ <enum name="ELEMENT_ARRAY_BUFFER" value="0x8893"/>
+ <enum name="ARRAY_BUFFER_BINDING" value="0x8894"/>
+ <enum name="ELEMENT_ARRAY_BUFFER_BINDING" value="0x8895"/>
+ <enum name="VERTEX_ARRAY_BUFFER_BINDING" value="0x8896"/>
+ <enum name="NORMAL_ARRAY_BUFFER_BINDING" value="0x8897"/>
+ <enum name="COLOR_ARRAY_BUFFER_BINDING" value="0x8898"/>
+ <enum name="INDEX_ARRAY_BUFFER_BINDING" value="0x8899"/>
+ <enum name="TEXTURE_COORD_ARRAY_BUFFER_BINDING" value="0x889A"/>
+ <enum name="EDGE_FLAG_ARRAY_BUFFER_BINDING" value="0x889B"/>
+ <enum name="SECONDARY_COLOR_ARRAY_BUFFER_BINDING" value="0x889C"/>
+ <enum name="FOG_COORDINATE_ARRAY_BUFFER_BINDING" value="0x889D"/>
+ <enum name="WEIGHT_ARRAY_BUFFER_BINDING" value="0x889E"/>
+ <enum name="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING" value="0x889F"/>
+ <enum name="READ_ONLY" value="0x88B8"/>
+ <enum name="WRITE_ONLY" value="0x88B9"/>
+ <enum name="READ_WRITE" value="0x88BA"/>
+ <enum name="BUFFER_ACCESS" value="0x88BB"/>
+ <enum name="BUFFER_MAPPED" value="0x88BC"/>
+ <enum name="BUFFER_MAP_POINTER" value="0x88BD"/>
+ <enum name="STREAM_DRAW" value="0x88E0"/>
+ <enum name="STREAM_READ" value="0x88E1"/>
+ <enum name="STREAM_COPY" value="0x88E2"/>
+ <enum name="STATIC_DRAW" value="0x88E4"/>
+ <enum name="STATIC_READ" value="0x88E5"/>
+ <enum name="STATIC_COPY" value="0x88E6"/>
+ <enum name="DYNAMIC_DRAW" value="0x88E8"/>
+ <enum name="DYNAMIC_READ" value="0x88E9"/>
+ <enum name="DYNAMIC_COPY" value="0x88EA"/>
+ <enum name="SAMPLES_PASSED" count="1" value="0x8914"/>
+ <enum name="FOG_COORD_SRC" value="0x8450">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FOG_COORD" value="0x8451"/>
+ <enum name="CURRENT_FOG_COORD" count="1" value="0x8453">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FOG_COORD_ARRAY_TYPE" count="1" value="0x8454">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FOG_COORD_ARRAY_STRIDE" count="1" value="0x8455">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FOG_COORD_ARRAY_POINTER" value="0x8456"/>
+ <enum name="FOG_COORD_ARRAY" count="1" value="0x8457">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="FOG_COORD_ARRAY_BUFFER_BINDING" value="0x889D"/>
+ <enum name="SRC0_RGB" value="0x8580"/>
+ <enum name="SRC1_RGB" value="0x8581"/>
+ <enum name="SRC2_RGB" value="0x8582"/>
+ <enum name="SRC0_ALPHA" value="0x8588"/>
+ <enum name="SRC1_ALPHA" value="0x8589"/>
+ <enum name="SRC2_ALPHA" value="0x858A"/>
+
+ <type name="intptr" size="4" glx_name="CARD32"/>
+ <type name="sizeiptr" size="4" unsigned="true" glx_name="CARD32"/>
+
+ <function name="BindBuffer" alias="BindBufferARB">
+ <param name="target" type="GLenum"/>
+ <param name="buffer" type="GLuint"/>
+ </function>
+
+ <function name="BufferData" alias="BufferDataARB">
+ <param name="target" type="GLenum"/>
+ <param name="size" type="GLsizeiptr"/>
+ <param name="data" type="const GLvoid *"/>
+ <param name="usage" type="GLenum"/>
+ </function>
+
+ <function name="BufferSubData" alias="BufferSubDataARB">
+ <param name="target" type="GLenum"/>
+ <param name="offset" type="GLintptr"/>
+ <param name="size" type="GLsizeiptr"/>
+ <param name="data" type="const GLvoid *"/>
+ </function>
+
+ <function name="DeleteBuffers" alias="DeleteBuffersARB">
+ <param name="n" type="GLsizei"/>
+ <param name="buffer" type="const GLuint *"/>
+ </function>
+
+ <function name="GenBuffers" alias="GenBuffersARB">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="buffer" type="GLuint *" output="true" count="n"/>
+ </function>
+
+ <function name="GetBufferParameteriv" alias="GetBufferParameterivARB">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ </function>
+
+ <function name="GetBufferPointerv" alias="GetBufferPointervARB">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLvoid **" output="true"/>
+ </function>
+
+ <function name="GetBufferSubData" alias="GetBufferSubDataARB">
+ <param name="target" type="GLenum"/>
+ <param name="offset" type="GLintptr"/>
+ <param name="size" type="GLsizeiptr"/>
+ <param name="data" type="GLvoid *" output="true"/>
+ </function>
+
+ <function name="IsBuffer" alias="IsBufferARB">
+ <param name="buffer" type="GLuint"/>
+ <return type="GLboolean"/>
+ </function>
+
+ <function name="MapBuffer" alias="MapBufferARB">
+ <param name="target" type="GLenum"/>
+ <param name="access" type="GLenum"/>
+ <return type="GLvoid *"/>
+ </function>
+
+ <function name="UnmapBuffer" alias="UnmapBufferARB">
+ <param name="target" type="GLenum"/>
+ <return type="GLboolean"/>
+ </function>
+
+ <function name="GenQueries" alias="GenQueriesARB">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="ids" type="GLuint *" output="true" count="n"/>
+ </function>
+
+ <function name="DeleteQueries" alias="DeleteQueriesARB">
+ <param name="n" type="GLsizei"/>
+ <param name="ids" type="const GLuint *"/>
+ </function>
+
+ <function name="IsQuery" alias="IsQueryARB">
+ <param name="id" type="GLuint"/>
+ <return type="GLboolean"/>
+ </function>
+
+ <function name="BeginQuery" alias="BeginQueryARB">
+ <param name="target" type="GLenum"/>
+ <param name="id" type="GLuint"/>
+ </function>
+
+ <function name="EndQuery" alias="EndQueryARB">
+ <param name="target" type="GLenum"/>
+ </function>
+
+ <function name="GetQueryiv" alias="GetQueryivARB">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ </function>
+
+ <function name="GetQueryObjectiv" alias="GetQueryObjectivARB">
+ <param name="id" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ </function>
+
+ <function name="GetQueryObjectuiv" alias="GetQueryObjectuivARB">
+ <param name="id" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLuint *" output="true" variable_param="pname"/>
+ </function>
+</category>
+
+
+<category name="2.0">
+ <!-- XXX this section is very much incomplete!!! -->
+ <!-- These function offsets may change too!!! -->
+
+ <enum name="POINT_SPRITE_COORD_ORIGIN" count="1" value="0x8CA0">
+ <size name="PointParameterfvEXT"/>
+ <size name="PointParameterivNV"/>
+ </enum>
+
+ <function name="StencilFuncSeparate" offset="813">
+ <param name="face" type="GLenum"/>
+ <param name="func" type="GLenum"/>
+ <param name="ref" type="GLint"/>
+ <param name="mask" type="GLuint"/>
+ </function>
+
+ <function name="StencilOpSeparate" offset="814">
+ <param name="face" type="GLenum"/>
+ <param name="fail" type="GLenum"/>
+ <param name="zfail" type="GLenum"/>
+ <param name="zpass" type="GLenum"/>
+ </function>
+
+ <function name="StencilMaskSeparate" offset="815">
+ <param name="face" type="GLenum"/>
+ <param name="mask" type="GLuint"/>
+ </function>
+</category>
+
+
+<!-- ARB extensions sorted by extension number. -->
+
+<category name="GL_ARB_multitexture" number="1">
+ <enum name="TEXTURE0_ARB" value="0x84C0"/>
+ <enum name="TEXTURE1_ARB" value="0x84C1"/>
+ <enum name="TEXTURE2_ARB" value="0x84C2"/>
+ <enum name="TEXTURE3_ARB" value="0x84C3"/>
+ <enum name="TEXTURE4_ARB" value="0x84C4"/>
+ <enum name="TEXTURE5_ARB" value="0x84C5"/>
+ <enum name="TEXTURE6_ARB" value="0x84C6"/>
+ <enum name="TEXTURE7_ARB" value="0x84C7"/>
+ <enum name="TEXTURE8_ARB" value="0x84C8"/>
+ <enum name="TEXTURE9_ARB" value="0x84C9"/>
+ <enum name="TEXTURE10_ARB" value="0x84CA"/>
+ <enum name="TEXTURE11_ARB" value="0x84CB"/>
+ <enum name="TEXTURE12_ARB" value="0x84CC"/>
+ <enum name="TEXTURE13_ARB" value="0x84CD"/>
+ <enum name="TEXTURE14_ARB" value="0x84CE"/>
+ <enum name="TEXTURE15_ARB" value="0x84CF"/>
+ <enum name="TEXTURE16_ARB" value="0x84D0"/>
+ <enum name="TEXTURE17_ARB" value="0x84D1"/>
+ <enum name="TEXTURE18_ARB" value="0x84D2"/>
+ <enum name="TEXTURE19_ARB" value="0x84D3"/>
+ <enum name="TEXTURE20_ARB" value="0x84D4"/>
+ <enum name="TEXTURE21_ARB" value="0x84D5"/>
+ <enum name="TEXTURE22_ARB" value="0x84D6"/>
+ <enum name="TEXTURE23_ARB" value="0x84D7"/>
+ <enum name="TEXTURE24_ARB" value="0x84D8"/>
+ <enum name="TEXTURE25_ARB" value="0x84D9"/>
+ <enum name="TEXTURE26_ARB" value="0x84DA"/>
+ <enum name="TEXTURE27_ARB" value="0x84DB"/>
+ <enum name="TEXTURE28_ARB" value="0x84DC"/>
+ <enum name="TEXTURE29_ARB" value="0x84DD"/>
+ <enum name="TEXTURE30_ARB" value="0x84DE"/>
+ <enum name="TEXTURE31_ARB" value="0x84DF"/>
+ <enum name="ACTIVE_TEXTURE_ARB" count="1" value="0x84E0">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CLIENT_ACTIVE_TEXTURE_ARB" count="1" value="0x84E1">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_TEXTURE_UNITS_ARB" count="1" value="0x84E2">
+ <size name="Get" mode="get"/>
+ </enum>
+
+ <function name="ActiveTextureARB" offset="374">
+ <param name="texture" type="GLenum"/>
+ <glx rop="197"/>
+ </function>
+
+ <function name="ClientActiveTextureARB" offset="375">
+ <param name="texture" type="GLenum"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="MultiTexCoord1dARB" offset="376" vectorequiv="MultiTexCoord1dvARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLdouble"/>
+ </function>
+
+ <function name="MultiTexCoord1dvARB" offset="377">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLdouble *" count="1"/>
+ <glx rop="198"/>
+ </function>
+
+ <function name="MultiTexCoord1fARB" offset="378" vectorequiv="MultiTexCoord1fvARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLfloat"/>
+ </function>
+
+ <function name="MultiTexCoord1fvARB" offset="379">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLfloat *" count="1"/>
+ <glx rop="199"/>
+ </function>
+
+ <function name="MultiTexCoord1iARB" offset="380" vectorequiv="MultiTexCoord1ivARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLint"/>
+ </function>
+
+ <function name="MultiTexCoord1ivARB" offset="381">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLint *" count="1"/>
+ <glx rop="200"/>
+ </function>
+
+ <function name="MultiTexCoord1sARB" offset="382" vectorequiv="MultiTexCoord1svARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLshort"/>
+ </function>
+
+ <function name="MultiTexCoord1svARB" offset="383">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLshort *" count="1"/>
+ <glx rop="201"/>
+ </function>
+
+ <function name="MultiTexCoord2dARB" offset="384" vectorequiv="MultiTexCoord2dvARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLdouble"/>
+ <param name="t" type="GLdouble"/>
+ </function>
+
+ <function name="MultiTexCoord2dvARB" offset="385">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLdouble *" count="2"/>
+ <glx rop="202"/>
+ </function>
+
+ <function name="MultiTexCoord2fARB" offset="386" vectorequiv="MultiTexCoord2fvARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ </function>
+
+ <function name="MultiTexCoord2fvARB" offset="387">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLfloat *" count="2"/>
+ <glx rop="203"/>
+ </function>
+
+ <function name="MultiTexCoord2iARB" offset="388" vectorequiv="MultiTexCoord2ivARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLint"/>
+ <param name="t" type="GLint"/>
+ </function>
+
+ <function name="MultiTexCoord2ivARB" offset="389">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLint *" count="2"/>
+ <glx rop="204"/>
+ </function>
+
+ <function name="MultiTexCoord2sARB" offset="390" vectorequiv="MultiTexCoord2svARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLshort"/>
+ <param name="t" type="GLshort"/>
+ </function>
+
+ <function name="MultiTexCoord2svARB" offset="391">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLshort *" count="2"/>
+ <glx rop="205"/>
+ </function>
+
+ <function name="MultiTexCoord3dARB" offset="392" vectorequiv="MultiTexCoord3dvARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLdouble"/>
+ <param name="t" type="GLdouble"/>
+ <param name="r" type="GLdouble"/>
+ </function>
+
+ <function name="MultiTexCoord3dvARB" offset="393">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLdouble *" count="3"/>
+ <glx rop="206"/>
+ </function>
+
+ <function name="MultiTexCoord3fARB" offset="394" vectorequiv="MultiTexCoord3fvARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ <param name="r" type="GLfloat"/>
+ </function>
+
+ <function name="MultiTexCoord3fvARB" offset="395">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLfloat *" count="3"/>
+ <glx rop="207"/>
+ </function>
+
+ <function name="MultiTexCoord3iARB" offset="396" vectorequiv="MultiTexCoord3ivARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLint"/>
+ <param name="t" type="GLint"/>
+ <param name="r" type="GLint"/>
+ </function>
+
+ <function name="MultiTexCoord3ivARB" offset="397">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLint *" count="3"/>
+ <glx rop="208"/>
+ </function>
+
+ <function name="MultiTexCoord3sARB" offset="398" vectorequiv="MultiTexCoord3svARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLshort"/>
+ <param name="t" type="GLshort"/>
+ <param name="r" type="GLshort"/>
+ </function>
+
+ <function name="MultiTexCoord3svARB" offset="399">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLshort *" count="3"/>
+ <glx rop="209"/>
+ </function>
+
+ <function name="MultiTexCoord4dARB" offset="400" vectorequiv="MultiTexCoord4dvARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLdouble"/>
+ <param name="t" type="GLdouble"/>
+ <param name="r" type="GLdouble"/>
+ <param name="q" type="GLdouble"/>
+ </function>
+
+ <function name="MultiTexCoord4dvARB" offset="401">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLdouble *" count="4"/>
+ <glx rop="210"/>
+ </function>
+
+ <function name="MultiTexCoord4fARB" offset="402" vectorequiv="MultiTexCoord4fvARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ <param name="r" type="GLfloat"/>
+ <param name="q" type="GLfloat"/>
+ </function>
+
+ <function name="MultiTexCoord4fvARB" offset="403">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLfloat *" count="4"/>
+ <glx rop="211"/>
+ </function>
+
+ <function name="MultiTexCoord4iARB" offset="404" vectorequiv="MultiTexCoord4ivARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLint"/>
+ <param name="t" type="GLint"/>
+ <param name="r" type="GLint"/>
+ <param name="q" type="GLint"/>
+ </function>
+
+ <function name="MultiTexCoord4ivARB" offset="405">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLint *" count="4"/>
+ <glx rop="212"/>
+ </function>
+
+ <function name="MultiTexCoord4sARB" offset="406" vectorequiv="MultiTexCoord4svARB">
+ <param name="target" type="GLenum"/>
+ <param name="s" type="GLshort"/>
+ <param name="t" type="GLshort"/>
+ <param name="r" type="GLshort"/>
+ <param name="q" type="GLshort"/>
+ </function>
+
+ <function name="MultiTexCoord4svARB" offset="407">
+ <param name="target" type="GLenum"/>
+ <param name="v" type="const GLshort *" count="4"/>
+ <glx rop="213"/>
+ </function>
+</category>
+
+<!-- ARB extension number 2 is a GLX extension. -->
+
+<category name="GL_ARB_transpose_matrix" number="3">
+ <enum name="TRANSPOSE_MODELVIEW_MATRIX_ARB" value="0x84E3"/>
+ <enum name="TRANSPOSE_PROJECTION_MATRIX_ARB" value="0x84E4"/>
+ <enum name="TRANSPOSE_TEXTURE_MATRIX_ARB" value="0x84E5"/>
+ <enum name="TRANSPOSE_COLOR_MATRIX_ARB" value="0x84E6"/>
+
+ <function name="LoadTransposeMatrixfARB" offset="408">
+ <param name="m" type="const GLfloat *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="LoadTransposeMatrixdARB" offset="409">
+ <param name="m" type="const GLdouble *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="MultTransposeMatrixfARB" offset="410">
+ <param name="m" type="const GLfloat *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="MultTransposeMatrixdARB" offset="411">
+ <param name="m" type="const GLdouble *"/>
+ <glx handcode="true"/>
+ </function>
+</category>
+
+<!-- ARB extension number 4 is a WGL extension. -->
+
+<category name="GL_ARB_multisample" number="5">
+ <enum name="MULTISAMPLE_ARB" count="1" value="0x809D">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SAMPLE_ALPHA_TO_COVERAGE_ARB" count="1" value="0x809E">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SAMPLE_ALPHA_TO_ONE_ARB" count="1" value="0x809F">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SAMPLE_COVERAGE_ARB" count="1" value="0x80A0">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SAMPLE_BUFFERS_ARB" count="1" value="0x80A8">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SAMPLES_ARB" count="1" value="0x80A9">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SAMPLE_COVERAGE_VALUE_ARB" count="1" value="0x80AA">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="SAMPLE_COVERAGE_INVERT_ARB" count="1" value="0x80AB">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MULTISAMPLE_BIT_ARB" value="0x20000000"/>
+
+ <function name="SampleCoverageARB" offset="412">
+ <param name="value" type="GLclampf"/>
+ <param name="invert" type="GLboolean"/>
+ <glx rop="229"/>
+ </function>
+</category>
+
+<category name="GL_ARB_texture_env_add" number="6">
+ <!-- No new functions, types, enums. -->
+</category>
+
+<category name="GL_ARB_texture_cube_map" number="7">
+ <enum name="NORMAL_MAP_ARB" value="0x8511"/>
+ <enum name="REFLECTION_MAP_ARB" value="0x8512"/>
+ <enum name="TEXTURE_CUBE_MAP_ARB" count="1" value="0x8513">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_BINDING_CUBE_MAP_ARB" count="1" value="0x8514">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_CUBE_MAP_POSITIVE_X_ARB" value="0x8515"/>
+ <enum name="TEXTURE_CUBE_MAP_NEGATIVE_X_ARB" value="0x8516"/>
+ <enum name="TEXTURE_CUBE_MAP_POSITIVE_Y_ARB" value="0x8517"/>
+ <enum name="TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB" value="0x8518"/>
+ <enum name="TEXTURE_CUBE_MAP_POSITIVE_Z_ARB" value="0x8519"/>
+ <enum name="TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB" value="0x851A"/>
+ <enum name="PROXY_TEXTURE_CUBE_MAP_ARB" value="0x851B"/>
+ <enum name="MAX_CUBE_MAP_TEXTURE_SIZE_ARB" count="1" value="0x851C">
+ <size name="Get" mode="get"/>
+ </enum>
+</category>
+
+<!-- ARB extension number 8 is a WGL extension. -->
+<!-- ARB extension number 9 is a WGL extension. -->
+<!-- ARB extension number 10 is a WGL extension. -->
+<!-- ARB extension number 11 is a WGL extension. -->
+
+<category name="GL_ARB_texture_compression" number="12">
+ <enum name="COMPRESSED_ALPHA_ARB" value="0x84E9"/>
+ <enum name="COMPRESSED_LUMINANCE_ARB" value="0x84EA"/>
+ <enum name="COMPRESSED_LUMINANCE_ALPHA_ARB" value="0x84EB"/>
+ <enum name="COMPRESSED_INTENSITY_ARB" value="0x84EC"/>
+ <enum name="COMPRESSED_RGB_ARB" value="0x84ED"/>
+ <enum name="COMPRESSED_RGBA_ARB" value="0x84EE"/>
+ <enum name="TEXTURE_COMPRESSION_HINT_ARB" count="1" value="0x84EF">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_COMPRESSED_IMAGE_SIZE_ARB" count="1" value="0x86A0">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_COMPRESSED_ARB" count="1" value="0x86A1">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="NUM_TEXTURE_COMPRESSED_FORMATS_ARB" count="1" value="0x86A2">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_COMPRESSED_FORMATS_ARB" value="0x86A3"/>
+
+ <function name="CompressedTexImage3DARB" offset="554">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="depth" type="GLsizei"/>
+ <param name="border" type="GLint"/>
+ <param name="imageSize" type="GLsizei" counter="true"/>
+ <param name="data" type="const GLvoid *" count="imageSize"/>
+ <glx rop="216" handcode="client"/>
+ </function>
+
+ <function name="CompressedTexImage2DARB" offset="555">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="border" type="GLint"/>
+ <param name="imageSize" type="GLsizei" counter="true"/>
+ <param name="data" type="const GLvoid *" count="imageSize"/>
+ <glx rop="215" handcode="client"/>
+ </function>
+
+ <function name="CompressedTexImage1DARB" offset="556">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="border" type="GLint"/>
+ <param name="imageSize" type="GLsizei" counter="true"/>
+ <param name="data" type="const GLvoid *" count="imageSize"/>
+ <glx rop="214" handcode="client"/>
+ </function>
+
+ <function name="CompressedTexSubImage3DARB" offset="557">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="yoffset" type="GLint"/>
+ <param name="zoffset" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="depth" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="imageSize" type="GLsizei" counter="true"/>
+ <param name="data" type="const GLvoid *" count="imageSize"/>
+ <glx rop="219" handcode="client"/>
+ </function>
+
+ <function name="CompressedTexSubImage2DARB" offset="558">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="yoffset" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="imageSize" type="GLsizei" counter="true"/>
+ <param name="data" type="const GLvoid *" count="imageSize"/>
+ <glx rop="218" handcode="client"/>
+ </function>
+
+ <function name="CompressedTexSubImage1DARB" offset="559">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="imageSize" type="GLsizei" counter="true"/>
+ <param name="data" type="const GLvoid *" count="imageSize"/>
+ <glx rop="217" handcode="client"/>
+ </function>
+
+ <function name="GetCompressedTexImageARB" offset="560">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="img" type="GLvoid *" output="true"/>
+
+ <!-- This has to be hand coded because the image size is in the
+ "wrong" place. Technically, this should be a
+ 'always_array="true"' case. The size field in the reply would
+ be at offset 12. However, the size is actually at offset 16.
+ This is where the 'width' is in a GetTexImage reply. -->
+ <glx sop="160" handcode="true"/>
+ </function>
+</category>
+
+<category name="GL_ARB_texture_border_clamp" number="13">
+ <enum name="CLAMP_TO_BORDER_ARB" value="0x812D"/>
+</category>
+
+<category name="GL_ARB_point_parameters" number="14">
+ <enum name="POINT_SIZE_MIN_ARB" count="1" value="0x8126">
+ <size name="PointParameterfvEXT"/>
+ </enum>
+ <enum name="POINT_SIZE_MAX_ARB" count="1" value="0x8127">
+ <size name="PointParameterfvEXT"/>
+ </enum>
+ <enum name="POINT_FADE_THRESHOLD_SIZE_ARB" count="1" value="0x8128">
+ <size name="PointParameterfvEXT"/>
+ </enum>
+ <enum name="POINT_DISTANCE_ATTENUATION_ARB" count="3" value="0x8129">
+ <size name="PointParameterfvEXT"/>
+ </enum>
+
+ <function name="PointParameterfARB" alias="PointParameterfEXT">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx rop="2065"/>
+ </function>
+
+ <function name="PointParameterfvARB" alias="PointParameterfvEXT">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *" variable_param="pname"/>
+ <glx rop="2066"/>
+ </function>
+</category>
+
+<category name="GL_ARB_vertex_blend" number="15">
+ <enum name="MAX_VERTEX_UNITS_ARB" count="1" value="0x86A4">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="ACTIVE_VERTEX_UNITS_ARB" count="1" value="0x86A5">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="WEIGHT_SUM_UNITY_ARB" count="1" value="0x86A6">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="VERTEX_BLEND_ARB" count="1" value="0x86A7">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CURRENT_WEIGHT_ARB" count="1" value="0x86A8">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="WEIGHT_ARRAY_TYPE_ARB" count="1" value="0x86A9">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="WEIGHT_ARRAY_STRIDE_ARB" count="1" value="0x86AA">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="WEIGHT_ARRAY_SIZE_ARB" count="1" value="0x86AB">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="WEIGHT_ARRAY_POINTER_ARB" value="0x86AC"/>
+ <enum name="WEIGHT_ARRAY_ARB" count="1" value="0x86AD">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW0_ARB" count="16" value="0x1700">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW1_ARB" count="16" value="0x850A">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW2_ARB" count="16" value="0x8722">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW3_ARB" count="16" value="0x8723">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW4_ARB" count="16" value="0x8724">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW5_ARB" count="16" value="0x8725">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW6_ARB" count="16" value="0x8726">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW7_ARB" count="16" value="0x8727">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW8_ARB" count="16" value="0x8728">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW9_ARB" count="16" value="0x8729">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW10_ARB" count="16" value="0x872A">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW11_ARB" count="16" value="0x872B">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW12_ARB" count="16" value="0x872C">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW13_ARB" count="16" value="0x872D">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW14_ARB" count="16" value="0x872E">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW15_ARB" count="16" value="0x872F">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW16_ARB" count="16" value="0x8730">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW17_ARB" count="16" value="0x8731">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW18_ARB" count="16" value="0x8732">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW19_ARB" count="16" value="0x8733">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW20_ARB" count="16" value="0x8734">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW21_ARB" count="16" value="0x8735">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW22_ARB" count="16" value="0x8736">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW23_ARB" count="16" value="0x8737">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW24_ARB" count="16" value="0x8738">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW25_ARB" count="16" value="0x8739">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW26_ARB" count="16" value="0x873A">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW27_ARB" count="16" value="0x873B">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW28_ARB" count="16" value="0x873C">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW29_ARB" count="16" value="0x873D">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW30_ARB" count="16" value="0x873E">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MODELVIEW31_ARB" count="16" value="0x873F">
+ <size name="Get" mode="get"/>
+ </enum>
+
+ <function name="WeightbvARB" offset="?">
+ <param name="size" type="GLint"/>
+ <param name="weights" type="const GLbyte *"/>
+ </function>
+
+ <function name="WeightsvARB" offset="?">
+ <param name="size" type="GLint"/>
+ <param name="weights" type="const GLshort *"/>
+ </function>
+
+ <function name="WeightivARB" offset="?">
+ <param name="size" type="GLint"/>
+ <param name="weights" type="const GLint *"/>
+ </function>
+
+ <function name="WeightfvARB" offset="?">
+ <param name="size" type="GLint"/>
+ <param name="weights" type="const GLfloat *"/>
+ </function>
+
+ <function name="WeightdvARB" offset="?">
+ <param name="size" type="GLint"/>
+ <param name="weights" type="const GLdouble *"/>
+ </function>
+
+ <function name="WeightubvARB" offset="?">
+ <param name="size" type="GLint"/>
+ <param name="weights" type="const GLubyte *"/>
+ </function>
+
+ <function name="WeightusvARB" offset="?">
+ <param name="size" type="GLint"/>
+ <param name="weights" type="const GLushort *"/>
+ </function>
+
+ <function name="WeightuivARB" offset="?">
+ <param name="size" type="GLint"/>
+ <param name="weights" type="const GLuint *"/>
+ </function>
+
+ <function name="WeightPointerARB" offset="?">
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="VertexBlendARB" offset="?">
+ <param name="count" type="GLint"/>
+ </function>
+</category>
+
+<category name="GL_ARB_matrix_palette" number="16">
+ <enum name="MATRIX_PALETTE_ARB" count="1" value="0x8840">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_MATRIX_PALETTE_STACK_DEPTH_ARB" count="1" value="0x8841">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_PALETTE_MATRICES_ARB" count="1" value="0x8842">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CURRENT_PALETTE_MATRIX_ARB" count="1" value="0x8843">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MATRIX_INDEX_ARRAY_ARB" count="1" value="0x8844">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CURRENT_MATRIX_INDEX_ARB" count="1" value="0x8845">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MATRIX_INDEX_ARRAY_SIZE_ARB" count="1" value="0x8846">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MATRIX_INDEX_ARRAY_TYPE_ARB" count="1" value="0x8847">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MATRIX_INDEX_ARRAY_STRIDE_ARB" count="1" value="0x8848">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MATRIX_INDEX_ARRAY_POINTER_ARB" value="0x8849"/>
+
+ <function name="CurrentPaletteMatrixARB" offset="?">
+ <param name="index" type="GLint"/>
+ <glx ignore="true" rop="4329"/>
+ </function>
+
+ <function name="MatrixIndexubvARB" offset="?">
+ <param name="size" type="GLint" counter="true"/>
+ <param name="indices" type="const GLubyte *" count="size"/>
+ <glx ignore="true" rop="4326"/>
+ </function>
+
+ <function name="MatrixIndexusvARB" offset="?">
+ <param name="size" type="GLint" counter="true"/>
+ <param name="indices" type="const GLushort *" count="size"/>
+ <glx ignore="true" rop="4327"/>
+ </function>
+
+ <function name="MatrixIndexuivARB" offset="?">
+ <param name="size" type="GLint" counter="true"/>
+ <param name="indices" type="const GLuint *" count="size"/>
+ <glx ignore="true" rop="4328"/>
+ </function>
+
+ <function name="MatrixIndexPointerARB" offset="?">
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+</category>
+
+<category name="GL_ARB_texture_env_combine" number="17">
+ <enum name="COMBINE_ARB" value="0x8570"/>
+ <enum name="COMBINE_RGB_ARB" value="0x8571"/>
+ <enum name="COMBINE_ALPHA_ARB" value="0x8572"/>
+ <enum name="SOURCE0_RGB_ARB" value="0x8580"/>
+ <enum name="SOURCE1_RGB_ARB" value="0x8581"/>
+ <enum name="SOURCE2_RGB_ARB" value="0x8582"/>
+ <enum name="SOURCE0_ALPHA_ARB" value="0x8588"/>
+ <enum name="SOURCE1_ALPHA_ARB" value="0x8589"/>
+ <enum name="SOURCE2_ALPHA_ARB" value="0x858A"/>
+ <enum name="OPERAND0_RGB_ARB" value="0x8590"/>
+ <enum name="OPERAND1_RGB_ARB" value="0x8591"/>
+ <enum name="OPERAND2_RGB_ARB" value="0x8592"/>
+ <enum name="OPERAND0_ALPHA_ARB" value="0x8598"/>
+ <enum name="OPERAND1_ALPHA_ARB" value="0x8599"/>
+ <enum name="OPERAND2_ALPHA_ARB" value="0x859A"/>
+ <enum name="RGB_SCALE_ARB" value="0x8573"/>
+ <enum name="ADD_SIGNED_ARB" value="0x8574"/>
+ <enum name="INTERPOLATE_ARB" value="0x8575"/>
+ <enum name="SUBTRACT_ARB" value="0x84E7"/>
+ <enum name="CONSTANT_ARB" value="0x8576"/>
+ <enum name="PRIMARY_COLOR_ARB" value="0x8577"/>
+ <enum name="PREVIOUS_ARB" value="0x8578"/>
+</category>
+
+<category name="GL_ARB_texture_env_crossbar" number="18">
+ <!-- No new functions, types, enums. -->
+</category>
+
+<category name="GL_ARB_texture_env_dot3" number="19">
+ <enum name="DOT3_RGB_ARB" value="0x86AE"/>
+ <enum name="DOT3_RGBA_ARB" value="0x86AF"/>
+</category>
+
+<!-- ARB extension number 20 is a WGL extension. -->
+
+<category name="GL_ARB_texture_mirrored_repeat" number="21">
+ <enum name="MIRRORED_REPEAT_ARB" value="0x8370"/>
+</category>
+
+<category name="GL_ARB_depth_texture" number="22">
+ <enum name="DEPTH_COMPONENT16_ARB" value="0x81A5"/>
+ <enum name="DEPTH_COMPONENT24_ARB" value="0x81A6"/>
+ <enum name="DEPTH_COMPONENT32_ARB" value="0x81A7"/>
+ <enum name="TEXTURE_DEPTH_SIZE_ARB" count="1" value="0x884A">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="DEPTH_TEXTURE_MODE_ARB" count="1" value="0x884B">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+</category>
+
+<category name="GL_ARB_shadow" number="23">
+ <enum name="TEXTURE_COMPARE_MODE_ARB" count="1" value="0x884C">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_COMPARE_FUNC_ARB" count="1" value="0x884D">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="COMPARE_R_TO_TEXTURE_ARB" value="0x884E"/>
+</category>
+
+<category name="GL_ARB_shadow_ambient" number="24">
+ <enum name="TEXTURE_COMPARE_FAIL_VALUE_ARB" count="1" value="0x80BF">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+</category>
+
+<category name="GL_ARB_window_pos" number="25">
+ <function name="WindowPos2dARB" alias="WindowPos2dMESA">
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ </function>
+
+ <function name="WindowPos2fARB" alias="WindowPos2fMESA">
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ </function>
+
+ <function name="WindowPos2iARB" alias="WindowPos2iMESA">
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ </function>
+
+ <function name="WindowPos2sARB" alias="WindowPos2sMESA">
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ </function>
+
+ <function name="WindowPos2dvARB" alias="WindowPos2dvMESA">
+ <param name="v" type="const GLdouble *"/>
+ </function>
+
+ <function name="WindowPos2fvARB" alias="WindowPos2fvMESA">
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="WindowPos2ivARB" alias="WindowPos2ivMESA">
+ <param name="v" type="const GLint *"/>
+ </function>
+
+ <function name="WindowPos2svARB" alias="WindowPos2svMESA">
+ <param name="v" type="const GLshort *"/>
+ </function>
+
+ <function name="WindowPos3dARB" alias="WindowPos3dMESA">
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ </function>
+
+ <function name="WindowPos3fARB" alias="WindowPos3fMESA">
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="WindowPos3iARB" alias="WindowPos3iMESA">
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="z" type="GLint"/>
+ </function>
+
+ <function name="WindowPos3sARB" alias="WindowPos3sMESA">
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ <param name="z" type="GLshort"/>
+ </function>
+
+ <function name="WindowPos3dvARB" alias="WindowPos3dvMESA">
+ <param name="v" type="const GLdouble *"/>
+ </function>
+
+ <function name="WindowPos3fvARB" alias="WindowPos3fvMESA">
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="WindowPos3ivARB" alias="WindowPos3ivMESA">
+ <param name="v" type="const GLint *"/>
+ </function>
+
+ <function name="WindowPos3svARB" alias="WindowPos3svMESA">
+ <param name="v" type="const GLshort *"/>
+ </function>
+</category>
+
+<category name="GL_ARB_vertex_program" number="26">
+ <enum name="COLOR_SUM_ARB" count="1" value="0x8458">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="VERTEX_PROGRAM_ARB" count="1" value="0x8620">
+ <size name="GetVertexAttribdvARB" mode="get"/>
+ <size name="GetVertexAttribfvARB" mode="get"/>
+ <size name="GetVertexAttribivARB" mode="get"/>
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="VERTEX_ATTRIB_ARRAY_ENABLED_ARB" count="1" value="0x8622">
+ <size name="GetVertexAttribdvARB" mode="get"/>
+ <size name="GetVertexAttribfvARB" mode="get"/>
+ <size name="GetVertexAttribivARB" mode="get"/>
+ </enum>
+ <enum name="VERTEX_ATTRIB_ARRAY_SIZE_ARB" count="1" value="0x8623">
+ <size name="GetVertexAttribdvARB" mode="get"/>
+ <size name="GetVertexAttribfvARB" mode="get"/>
+ <size name="GetVertexAttribivARB" mode="get"/>
+ </enum>
+ <enum name="VERTEX_ATTRIB_ARRAY_STRIDE_ARB" count="1" value="0x8624">
+ <size name="GetVertexAttribdvARB" mode="get"/>
+ <size name="GetVertexAttribfvARB" mode="get"/>
+ <size name="GetVertexAttribivARB" mode="get"/>
+ </enum>
+ <enum name="VERTEX_ATTRIB_ARRAY_TYPE_ARB" count="1" value="0x8625">
+ <size name="GetVertexAttribdvARB" mode="get"/>
+ <size name="GetVertexAttribfvARB" mode="get"/>
+ <size name="GetVertexAttribivARB" mode="get"/>
+ </enum>
+ <enum name="CURRENT_VERTEX_ATTRIB_ARB" count="1" value="0x8626">
+ <size name="GetVertexAttribdvARB" mode="get"/>
+ <size name="GetVertexAttribfvARB" mode="get"/>
+ <size name="GetVertexAttribivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_LENGTH_ARB" count="1" value="0x8627">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_STRING_ARB" value="0x8628"/>
+ <enum name="MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB" count="1" value="0x862E">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_MATRICES_ARB" count="1" value="0x862F">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CURRENT_MATRIX_STACK_DEPTH_ARB" count="1" value="0x8640">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="CURRENT_MATRIX_ARB" count="16" value="0x8641">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="VERTEX_PROGRAM_POINT_SIZE_ARB" count="1" value="0x8642">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="VERTEX_PROGRAM_TWO_SIDE_ARB" count="1" value="0x8643">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="VERTEX_ATTRIB_ARRAY_POINTER_ARB" value="0x8645"/>
+ <enum name="PROGRAM_ERROR_POSITION_ARB" count="1" value="0x864B">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_BINDING_ARB" count="1" value="0x8677">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_VERTEX_ATTRIBS_ARB" count="1" value="0x8869">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB" value="0x886A"/>
+ <enum name="PROGRAM_ERROR_STRING_ARB" value="0x8874"/>
+ <enum name="PROGRAM_FORMAT_ASCII_ARB" value="0x8875"/>
+ <enum name="PROGRAM_FORMAT_ARB" count="1" value="0x8876">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_INSTRUCTIONS_ARB" count="1" value="0x88A0">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_INSTRUCTIONS_ARB" count="1" value="0x88A1">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_NATIVE_INSTRUCTIONS_ARB" count="1" value="0x88A2">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB" count="1" value="0x88A3">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_TEMPORARIES_ARB" count="1" value="0x88A4">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_TEMPORARIES_ARB" count="1" value="0x88A5">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_NATIVE_TEMPORARIES_ARB" count="1" value="0x88A6">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_NATIVE_TEMPORARIES_ARB" count="1" value="0x88A7">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_PARAMETERS_ARB" count="1" value="0x88A8">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_PARAMETERS_ARB" count="1" value="0x88A9">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_NATIVE_PARAMETERS_ARB" count="1" value="0x88AA">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_NATIVE_PARAMETERS_ARB" count="1" value="0x88AB">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_ATTRIBS_ARB" count="1" value="0x88AC">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_ATTRIBS_ARB" count="1" value="0x88AD">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_NATIVE_ATTRIBS_ARB" count="1" value="0x88AE">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_NATIVE_ATTRIBS_ARB" count="1" value="0x88AF">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_ADDRESS_REGISTERS_ARB" count="1" value="0x88B0">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_ADDRESS_REGISTERS_ARB" count="1" value="0x88B1">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB" count="1" value="0x88B2">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB" count="1" value="0x88B3">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_LOCAL_PARAMETERS_ARB" count="1" value="0x88B4">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_ENV_PARAMETERS_ARB" count="1" value="0x88B5">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_UNDER_NATIVE_LIMITS_ARB" count="1" value="0x88B6">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="TRANSPOSE_CURRENT_MATRIX_ARB" count="16" value="0x88B7">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MATRIX0_ARB" value="0x88C0"/>
+ <enum name="MATRIX1_ARB" value="0x88C1"/>
+ <enum name="MATRIX2_ARB" value="0x88C2"/>
+ <enum name="MATRIX3_ARB" value="0x88C3"/>
+ <enum name="MATRIX4_ARB" value="0x88C4"/>
+ <enum name="MATRIX5_ARB" value="0x88C5"/>
+ <enum name="MATRIX6_ARB" value="0x88C6"/>
+ <enum name="MATRIX7_ARB" value="0x88C7"/>
+ <enum name="MATRIX8_ARB" value="0x88C8"/>
+ <enum name="MATRIX9_ARB" value="0x88C9"/>
+ <enum name="MATRIX10_ARB" value="0x88CA"/>
+ <enum name="MATRIX11_ARB" value="0x88CB"/>
+ <enum name="MATRIX12_ARB" value="0x88CC"/>
+ <enum name="MATRIX13_ARB" value="0x88CD"/>
+ <enum name="MATRIX14_ARB" value="0x88CE"/>
+ <enum name="MATRIX15_ARB" value="0x88CF"/>
+ <enum name="MATRIX16_ARB" value="0x88D0"/>
+ <enum name="MATRIX17_ARB" value="0x88D1"/>
+ <enum name="MATRIX18_ARB" value="0x88D2"/>
+ <enum name="MATRIX19_ARB" value="0x88D3"/>
+ <enum name="MATRIX20_ARB" value="0x88D4"/>
+ <enum name="MATRIX21_ARB" value="0x88D5"/>
+ <enum name="MATRIX22_ARB" value="0x88D6"/>
+ <enum name="MATRIX23_ARB" value="0x88D7"/>
+ <enum name="MATRIX24_ARB" value="0x88D8"/>
+ <enum name="MATRIX25_ARB" value="0x88D9"/>
+ <enum name="MATRIX26_ARB" value="0x88DA"/>
+ <enum name="MATRIX27_ARB" value="0x88DB"/>
+ <enum name="MATRIX28_ARB" value="0x88DC"/>
+ <enum name="MATRIX29_ARB" value="0x88DD"/>
+ <enum name="MATRIX30_ARB" value="0x88DE"/>
+ <enum name="MATRIX31_ARB" value="0x88DF"/>
+
+ <function name="GetVertexAttribdvARB" offset="588">
+ <param name="index" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLdouble *" output="true" variable_param="pname"/>
+ <glx handcode="client" vendorpriv="1301"/>
+ </function>
+
+ <function name="GetVertexAttribfvARB" offset="589">
+ <param name="index" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx handcode="client" vendorpriv="1302"/>
+ </function>
+
+ <function name="GetVertexAttribivARB" offset="590">
+ <param name="index" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx handcode="client" vendorpriv="1303"/>
+ </function>
+
+ <function name="VertexAttrib1dARB" offset="603" vectorequiv="VertexAttrib1dvARB">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLdouble"/>
+ </function>
+
+ <function name="VertexAttrib1dvARB" offset="604">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLdouble *" count="1"/>
+ <glx rop="4197"/>
+ </function>
+
+ <function name="VertexAttrib1fARB" offset="605" vectorequiv="VertexAttrib1fvARB">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLfloat"/>
+ </function>
+
+ <function name="VertexAttrib1fvARB" offset="606">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLfloat *" count="1"/>
+ <glx rop="4193"/>
+ </function>
+
+ <function name="VertexAttrib1sARB" offset="607" vectorequiv="VertexAttrib1svARB">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLshort"/>
+ </function>
+
+ <function name="VertexAttrib1svARB" offset="608">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLshort *" count="1"/>
+ <glx rop="4189"/>
+ </function>
+
+ <function name="VertexAttrib2dARB" offset="609" vectorequiv="VertexAttrib2dvARB">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ </function>
+
+ <function name="VertexAttrib2dvARB" offset="610">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLdouble *" count="2"/>
+ <glx rop="4198"/>
+ </function>
+
+ <function name="VertexAttrib2fARB" offset="611" vectorequiv="VertexAttrib2fvARB">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ </function>
+
+ <function name="VertexAttrib2fvARB" offset="612">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLfloat *" count="2"/>
+ <glx rop="4194"/>
+ </function>
+
+ <function name="VertexAttrib2sARB" offset="613" vectorequiv="VertexAttrib2svARB">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ </function>
+
+ <function name="VertexAttrib2svARB" offset="614">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLshort *" count="2"/>
+ <glx rop="4190"/>
+ </function>
+
+ <function name="VertexAttrib3dARB" offset="615" vectorequiv="VertexAttrib3dvARB">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ </function>
+
+ <function name="VertexAttrib3dvARB" offset="616">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLdouble *" count="3"/>
+ <glx rop="4199"/>
+ </function>
+
+ <function name="VertexAttrib3fARB" offset="617" vectorequiv="VertexAttrib3fvARB">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="VertexAttrib3fvARB" offset="618">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLfloat *" count="3"/>
+ <glx rop="4195"/>
+ </function>
+
+ <function name="VertexAttrib3sARB" offset="619" vectorequiv="VertexAttrib3svARB">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ <param name="z" type="GLshort"/>
+ </function>
+
+ <function name="VertexAttrib3svARB" offset="620">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLshort *" count="3"/>
+ <glx rop="4191"/>
+ </function>
+
+ <function name="VertexAttrib4dARB" offset="621" vectorequiv="VertexAttrib4dvARB">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ <param name="w" type="GLdouble"/>
+ </function>
+
+ <function name="VertexAttrib4dvARB" offset="622">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLdouble *" count="4"/>
+ <glx rop="4200"/>
+ </function>
+
+ <function name="VertexAttrib4fARB" offset="623" vectorequiv="VertexAttrib4fvARB">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ <param name="w" type="GLfloat"/>
+ </function>
+
+ <function name="VertexAttrib4fvARB" offset="624">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLfloat *" count="4"/>
+ <glx rop="4196"/>
+ </function>
+
+ <function name="VertexAttrib4sARB" offset="625" vectorequiv="VertexAttrib4svARB">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ <param name="z" type="GLshort"/>
+ <param name="w" type="GLshort"/>
+ </function>
+
+ <function name="VertexAttrib4svARB" offset="626">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLshort *" count="4"/>
+ <glx rop="4192"/>
+ </function>
+
+ <function name="VertexAttrib4NubARB" offset="627" vectorequiv="VertexAttrib4NubvARB">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLubyte"/>
+ <param name="y" type="GLubyte"/>
+ <param name="z" type="GLubyte"/>
+ <param name="w" type="GLubyte"/>
+ </function>
+
+ <function name="VertexAttrib4NubvARB" offset="628">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLubyte *" count="4"/>
+ <glx rop="4201"/>
+ </function>
+
+ <function name="VertexAttrib4bvARB" offset="654">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLbyte *" count="4"/>
+ <glx rop="4230"/>
+ </function>
+
+ <function name="VertexAttrib4ivARB" offset="655">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLint *" count="4"/>
+ <glx rop="4231"/>
+ </function>
+
+ <function name="VertexAttrib4ubvARB" offset="656">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLubyte *" count="4"/>
+ <glx rop="4232"/>
+ </function>
+
+ <function name="VertexAttrib4usvARB" offset="657">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLushort *" count="4"/>
+ <glx rop="4233"/>
+ </function>
+
+ <function name="VertexAttrib4uivARB" offset="658">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLuint *" count="4"/>
+ <glx rop="4234"/>
+ </function>
+
+ <function name="VertexAttrib4NbvARB" offset="659">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLbyte *" count="4"/>
+ <glx rop="4235"/>
+ </function>
+
+ <function name="VertexAttrib4NsvARB" offset="660">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLshort *" count="4"/>
+ <glx rop="4236"/>
+ </function>
+
+ <function name="VertexAttrib4NivARB" offset="661">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLint *" count="4"/>
+ <glx rop="4237"/>
+ </function>
+
+ <function name="VertexAttrib4NusvARB" offset="662">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLushort *" count="4"/>
+ <glx rop="4238"/>
+ </function>
+
+ <function name="VertexAttrib4NuivARB" offset="663">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLuint *" count="4"/>
+ <glx rop="4239"/>
+ </function>
+
+ <function name="VertexAttribPointerARB" offset="664">
+ <param name="index" type="GLuint"/>
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="normalized" type="GLboolean"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="EnableVertexAttribArrayARB" offset="665">
+ <param name="index" type="GLuint"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="DisableVertexAttribArrayARB" offset="666">
+ <param name="index" type="GLuint"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="ProgramStringARB" offset="667">
+ <param name="target" type="GLenum"/>
+ <param name="format" type="GLenum"/>
+ <param name="len" type="GLsizei" counter="true"/>
+ <param name="string" type="const GLvoid *" count="len"/>
+ <glx rop="4217" large="true"/>
+ </function>
+
+ <function name="BindProgramARB" alias="BindProgramNV">
+ <param name="target" type="GLenum"/>
+ <param name="program" type="GLuint"/>
+ </function>
+
+ <function name="DeleteProgramsARB" alias="DeleteProgramsNV">
+ <param name="n" type="GLsizei"/>
+ <param name="programs" type="const GLuint *"/>
+ </function>
+
+ <function name="GenProgramsARB" alias="GenProgramsNV">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="programs" type="GLuint *" output="true" count="n"/>
+ </function>
+
+ <function name="IsProgramARB" alias="IsProgramNV">
+ <param name="program" type="GLuint"/>
+ <return type="GLboolean"/>
+ </function>
+
+ <function name="ProgramEnvParameter4dARB" offset="668" vectorequiv="ProgramEnvParameter4dvARB">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ <param name="w" type="GLdouble"/>
+ </function>
+
+ <function name="ProgramEnvParameter4dvARB" offset="669">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="params" type="const GLdouble *" count="4"/>
+ <glx rop="4185" doubles_in_order="true"/>
+ </function>
+
+ <function name="ProgramEnvParameter4fARB" offset="670" vectorequiv="ProgramEnvParameter4fvARB">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ <param name="w" type="GLfloat"/>
+ </function>
+
+ <function name="ProgramEnvParameter4fvARB" offset="671">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="params" type="const GLfloat *" count="4"/>
+ <glx rop="4184"/>
+ </function>
+
+ <function name="ProgramLocalParameter4dARB" offset="672" vectorequiv="ProgramLocalParameter4dvARB">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ <param name="w" type="GLdouble"/>
+ </function>
+
+ <function name="ProgramLocalParameter4dvARB" offset="673">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="params" type="const GLdouble *" count="4"/>
+ <glx rop="4216" doubles_in_order="true"/>
+ </function>
+
+ <function name="ProgramLocalParameter4fARB" offset="674" vectorequiv="ProgramLocalParameter4fvARB">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ <param name="w" type="GLfloat"/>
+ </function>
+
+ <function name="ProgramLocalParameter4fvARB" offset="675">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="params" type="const GLfloat *" count="4"/>
+ <glx rop="4215"/>
+ </function>
+
+ <!-- The GetProgramEnvParameter[df]vARB are handcoded because there
+ is an extra CARD32 of padding after the "index" field. Originally,
+ GetProgranEnvParameter[df]vARB and GetProgramParameter[df]vNV
+ shared the same GLX protocol. The pad field was where the pname
+ parameter was in the NV functions. When this error was discovered
+ and fixed, there was already at least one implementation of
+ GLX protocol for ARB_vertex_program, but there were no
+ implementations of NV_vertex_program. The sollution was to renumber
+ the opcodes for NV_vertex_program and convert the unused field in
+ the ARB_vertex_program protocol to unused padding.
+ -->
+
+ <function name="GetProgramEnvParameterdvARB" offset="676">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="params" type="GLdouble *" output="true" count="4"/>
+ <glx vendorpriv="1297" handcode="client" doubles_in_order="true"/>
+ </function>
+
+ <function name="GetProgramEnvParameterfvARB" offset="677">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="params" type="GLfloat *" output="true" count="4"/>
+ <glx vendorpriv="1296" handcode="client"/>
+ </function>
+
+ <function name="GetProgramLocalParameterdvARB" offset="678">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="params" type="GLdouble *" output="true" count="4"/>
+ <glx vendorpriv="1306" handcode="client" doubles_in_order="true"/>
+ </function>
+
+ <function name="GetProgramLocalParameterfvARB" offset="679">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="params" type="GLfloat *" output="true" count="4"/>
+ <glx vendorpriv="1305" handcode="client"/>
+ </function>
+
+
+ <function name="GetProgramivARB" offset="680">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx vendorpriv="1307"/>
+ </function>
+
+ <function name="GetProgramStringARB" offset="681">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="string" type="GLvoid *" output="true"/>
+ <glx vendorpriv="1308" handcode="server" always_array="true"/>
+ </function>
+
+ <function name="GetVertexAttribPointervARB" alias="GetVertexAttribPointervNV">
+ <param name="index" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLvoid **" output="true"/>
+ </function>
+</category>
+
+<category name="GL_ARB_fragment_program" number="27">
+ <enum name="FRAGMENT_PROGRAM_ARB" count="1" value="0x8804">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_ALU_INSTRUCTIONS_ARB" count="1" value="0x8805">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_TEX_INSTRUCTIONS_ARB" count="1" value="0x8806">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_TEX_INDIRECTIONS_ARB" count="1" value="0x8807">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB" count="1" value="0x8808">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB" count="1" value="0x8809">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB" count="1" value="0x880A">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_ALU_INSTRUCTIONS_ARB" count="1" value="0x880B">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_TEX_INSTRUCTIONS_ARB" count="1" value="0x880C">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_TEX_INDIRECTIONS_ARB" count="1" value="0x880D">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB" count="1" value="0x880E">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB" count="1" value="0x880F">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB" count="1" value="0x8810">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_TEXTURE_COORDS_ARB" count="1" value="0x8871">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_TEXTURE_IMAGE_UNITS_ARB" count="1" value="0x8872">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+</category>
+
+<category name="GL_ARB_vertex_buffer_object" number="28">
+ <enum name="BUFFER_SIZE_ARB" value="0x8764"/>
+ <enum name="BUFFER_USAGE_ARB" value="0x8765"/>
+ <enum name="ARRAY_BUFFER_ARB" value="0x8892"/>
+ <enum name="ELEMENT_ARRAY_BUFFER_ARB" value="0x8893"/>
+ <enum name="ARRAY_BUFFER_BINDING_ARB" value="0x8894"/>
+ <enum name="ELEMENT_ARRAY_BUFFER_BINDING_ARB" value="0x8895"/>
+ <enum name="VERTEX_ARRAY_BUFFER_BINDING_ARB" value="0x8896"/>
+ <enum name="NORMAL_ARRAY_BUFFER_BINDING_ARB" value="0x8897"/>
+ <enum name="COLOR_ARRAY_BUFFER_BINDING_ARB" value="0x8898"/>
+ <enum name="INDEX_ARRAY_BUFFER_BINDING_ARB" value="0x8899"/>
+ <enum name="TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB" value="0x889A"/>
+ <enum name="EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB" value="0x889B"/>
+ <enum name="SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB" value="0x889C"/>
+ <enum name="FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB" value="0x889D"/>
+ <enum name="WEIGHT_ARRAY_BUFFER_BINDING_ARB" value="0x889E"/>
+ <enum name="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB" value="0x889F"/>
+ <enum name="READ_ONLY_ARB" value="0x88B8"/>
+ <enum name="WRITE_ONLY_ARB" value="0x88B9"/>
+ <enum name="READ_WRITE_ARB" value="0x88BA"/>
+ <enum name="BUFFER_ACCESS_ARB" value="0x88BB"/>
+ <enum name="BUFFER_MAPPED_ARB" value="0x88BC"/>
+ <enum name="BUFFER_MAP_POINTER_ARB" value="0x88BD"/>
+ <enum name="STREAM_DRAW_ARB" value="0x88E0"/>
+ <enum name="STREAM_READ_ARB" value="0x88E1"/>
+ <enum name="STREAM_COPY_ARB" value="0x88E2"/>
+ <enum name="STATIC_DRAW_ARB" value="0x88E4"/>
+ <enum name="STATIC_READ_ARB" value="0x88E5"/>
+ <enum name="STATIC_COPY_ARB" value="0x88E6"/>
+ <enum name="DYNAMIC_DRAW_ARB" value="0x88E8"/>
+ <enum name="DYNAMIC_READ_ARB" value="0x88E9"/>
+ <enum name="DYNAMIC_COPY_ARB" value="0x88EA"/>
+
+ <type name="intptrARB" size="4"/>
+ <type name="sizeiptrARB" unsigned="true" size="4"/>
+
+ <function name="BindBufferARB" offset="688">
+ <param name="target" type="GLenum"/>
+ <param name="buffer" type="GLuint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="BufferDataARB" offset="689">
+ <param name="target" type="GLenum"/>
+ <param name="size" type="GLsizeiptrARB"/>
+ <param name="data" type="const GLvoid *"/>
+ <param name="usage" type="GLenum"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="BufferSubDataARB" offset="690">
+ <param name="target" type="GLenum"/>
+ <param name="offset" type="GLintptrARB"/>
+ <param name="size" type="GLsizeiptrARB"/>
+ <param name="data" type="const GLvoid *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="DeleteBuffersARB" offset="691">
+ <param name="n" type="GLsizei"/>
+ <param name="buffer" type="const GLuint *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GenBuffersARB" offset="692">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="buffer" type="GLuint *" output="true" count="n"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetBufferParameterivARB" offset="693">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetBufferPointervARB" offset="694">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLvoid **" output="true"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetBufferSubDataARB" offset="695">
+ <param name="target" type="GLenum"/>
+ <param name="offset" type="GLintptrARB"/>
+ <param name="size" type="GLsizeiptrARB"/>
+ <param name="data" type="GLvoid *" output="true"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="IsBufferARB" offset="696">
+ <param name="buffer" type="GLuint"/>
+ <return type="GLboolean"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="MapBufferARB" offset="697">
+ <param name="target" type="GLenum"/>
+ <param name="access" type="GLenum"/>
+ <return type="GLvoid *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="UnmapBufferARB" offset="698">
+ <param name="target" type="GLenum"/>
+ <return type="GLboolean"/>
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_ARB_occlusion_query" number="29">
+ <enum name="QUERY_COUNTER_BITS_ARB" count="1" value="0x8864">
+ <size name="GetQueryivARB" mode="get"/>
+ </enum>
+ <enum name="CURRENT_QUERY_ARB" count="1" value="0x8865">
+ <size name="GetQueryivARB" mode="get"/>
+ </enum>
+ <enum name="QUERY_RESULT_ARB" count="1" value="0x8866">
+ <size name="GetQueryObjectivARB" mode="get"/>
+ <size name="GetQueryObjectuivARB" mode="get"/>
+ </enum>
+ <enum name="QUERY_RESULT_AVAILABLE_ARB" count="1" value="0x8867">
+ <size name="GetQueryObjectivARB" mode="get"/>
+ <size name="GetQueryObjectuivARB" mode="get"/>
+ </enum>
+ <enum name="SAMPLES_PASSED_ARB" value="0x8914"/>
+
+ <function name="GenQueriesARB" offset="700">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="ids" type="GLuint *" output="true" count="n"/>
+ <glx sop="162" always_array="true"/>
+ </function>
+
+ <function name="DeleteQueriesARB" offset="701">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="ids" type="const GLuint *" count="n"/>
+ <glx sop="161"/>
+ </function>
+
+ <function name="IsQueryARB" offset="702">
+ <param name="id" type="GLuint"/>
+ <return type="GLboolean"/>
+ <glx sop="163"/>
+ </function>
+
+ <function name="BeginQueryARB" offset="703">
+ <param name="target" type="GLenum"/>
+ <param name="id" type="GLuint"/>
+ <glx rop="231"/>
+ </function>
+
+ <function name="EndQueryARB" offset="704">
+ <param name="target" type="GLenum"/>
+ <glx rop="232"/>
+ </function>
+
+ <function name="GetQueryivARB" offset="705">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx sop="164"/>
+ </function>
+
+ <function name="GetQueryObjectivARB" offset="706">
+ <param name="id" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx sop="165"/>
+ </function>
+
+ <function name="GetQueryObjectuivARB" offset="707">
+ <param name="id" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLuint *" output="true" variable_param="pname"/>
+ <glx sop="166"/>
+ </function>
+</category>
+
+<category name="GL_ARB_shader_objects" number="30">
+ <enum name="PROGRAM_OBJECT_ARB" value="0x8B40"/>
+ <enum name="SHADER_OBJECT_ARB" value="0x8B48"/>
+ <enum name="OBJECT_TYPE_ARB" value="0x8B4E"/>
+ <enum name="OBJECT_SUBTYPE_ARB" value="0x8B4F"/>
+ <enum name="FLOAT_VEC2_ARB" value="0x8B50"/>
+ <enum name="FLOAT_VEC3_ARB" value="0x8B51"/>
+ <enum name="FLOAT_VEC4_ARB" value="0x8B52"/>
+ <enum name="INT_VEC2_ARB" value="0x8B53"/>
+ <enum name="INT_VEC3_ARB" value="0x8B54"/>
+ <enum name="INT_VEC4_ARB" value="0x8B55"/>
+ <enum name="BOOL_ARB" value="0x8B56"/>
+ <enum name="BOOL_VEC2_ARB" value="0x8B57"/>
+ <enum name="BOOL_VEC3_ARB" value="0x8B58"/>
+ <enum name="BOOL_VEC4_ARB" value="0x8B59"/>
+ <enum name="FLOAT_MAT2_ARB" value="0x8B5A"/>
+ <enum name="FLOAT_MAT3_ARB" value="0x8B5B"/>
+ <enum name="FLOAT_MAT4_ARB" value="0x8B5C"/>
+ <enum name="OBJECT_DELETE_STATUS_ARB" value="0x8B80"/>
+ <enum name="OBJECT_COMPILE_STATUS_ARB" value="0x8B81"/>
+ <enum name="OBJECT_LINK_STATUS_ARB" value="0x8B82"/>
+ <enum name="OBJECT_VALIDATE_STATUS_ARB" value="0x8B83"/>
+ <enum name="OBJECT_INFO_LOG_LENGTH_ARB" value="0x8B84"/>
+ <enum name="OBJECT_ATTACHED_OBJECTS_ARB" value="0x8B85"/>
+ <enum name="OBJECT_ACTIVE_UNIFORMS_ARB" value="0x8B86"/>
+ <enum name="OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB" value="0x8B87"/>
+ <enum name="OBJECT_SHADER_SOURCE_LENGTH_ARB" value="0x8B88"/>
+
+ <type name="charARB" size="1" glx_name="CARD8"/>
+ <type name="handleARB" size="4" glx_name="CARD32"/>
+
+ <function name="DeleteObjectARB" offset="711">
+ <param name="obj" type="GLhandleARB"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetHandleARB" offset="712">
+ <param name="pname" type="GLenum"/>
+ <return type="GLhandleARB"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="DetachObjectARB" offset="713">
+ <param name="containerObj" type="GLhandleARB"/>
+ <param name="attachedObj" type="GLhandleARB"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="CreateShaderObjectARB" offset="714">
+ <param name="shaderType" type="GLenum"/>
+ <return type="GLhandleARB"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="ShaderSourceARB" offset="715">
+ <param name="shaderObj" type="GLhandleARB"/>
+ <param name="count" type="GLsizei"/>
+ <param name="string" type="const GLcharARB **"/>
+ <param name="length" type="const GLint *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="CompileShaderARB" offset="716">
+ <param name="shaderObj" type="GLhandleARB"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="CreateProgramObjectARB" offset="717">
+ <return type="GLhandleARB"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="AttachObjectARB" offset="718">
+ <param name="containerObj" type="GLhandleARB"/>
+ <param name="obj" type="GLhandleARB"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="LinkProgramARB" offset="719">
+ <param name="programObj" type="GLhandleARB"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="UseProgramObjectARB" offset="720">
+ <param name="programObj" type="GLhandleARB"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="ValidateProgramARB" offset="721">
+ <param name="programObj" type="GLhandleARB"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="Uniform1fARB" offset="722">
+ <param name="location" type="GLint"/>
+ <param name="v0" type="GLfloat"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="Uniform2fARB" offset="723">
+ <param name="location" type="GLint"/>
+ <param name="v0" type="GLfloat"/>
+ <param name="v1" type="GLfloat"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="Uniform3fARB" offset="724">
+ <param name="location" type="GLint"/>
+ <param name="v0" type="GLfloat"/>
+ <param name="v1" type="GLfloat"/>
+ <param name="v2" type="GLfloat"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="Uniform4fARB" offset="725">
+ <param name="location" type="GLint"/>
+ <param name="v0" type="GLfloat"/>
+ <param name="v1" type="GLfloat"/>
+ <param name="v2" type="GLfloat"/>
+ <param name="v3" type="GLfloat"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="Uniform1iARB" offset="726">
+ <param name="location" type="GLint"/>
+ <param name="v0" type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="Uniform2iARB" offset="727">
+ <param name="location" type="GLint"/>
+ <param name="v0" type="GLint"/>
+ <param name="v1" type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="Uniform3iARB" offset="728">
+ <param name="location" type="GLint"/>
+ <param name="v0" type="GLint"/>
+ <param name="v1" type="GLint"/>
+ <param name="v2" type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="Uniform4iARB" offset="729">
+ <param name="location" type="GLint"/>
+ <param name="v0" type="GLint"/>
+ <param name="v1" type="GLint"/>
+ <param name="v2" type="GLint"/>
+ <param name="v3" type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="Uniform1fvARB" offset="730">
+ <param name="location" type="GLint"/>
+ <param name="count" type="GLsizei"/>
+ <param name="value" type="const GLfloat *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="Uniform2fvARB" offset="731">
+ <param name="location" type="GLint"/>
+ <param name="count" type="GLsizei"/>
+ <param name="value" type="const GLfloat *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="Uniform3fvARB" offset="732">
+ <param name="location" type="GLint"/>
+ <param name="count" type="GLsizei"/>
+ <param name="value" type="const GLfloat *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="Uniform4fvARB" offset="733">
+ <param name="location" type="GLint"/>
+ <param name="count" type="GLsizei"/>
+ <param name="value" type="const GLfloat *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="Uniform1ivARB" offset="734">
+ <param name="location" type="GLint"/>
+ <param name="count" type="GLsizei"/>
+ <param name="value" type="const GLint *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="Uniform2ivARB" offset="735">
+ <param name="location" type="GLint"/>
+ <param name="count" type="GLsizei"/>
+ <param name="value" type="const GLint *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="Uniform3ivARB" offset="736">
+ <param name="location" type="GLint"/>
+ <param name="count" type="GLsizei"/>
+ <param name="value" type="const GLint *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="Uniform4ivARB" offset="737">
+ <param name="location" type="GLint"/>
+ <param name="count" type="GLsizei"/>
+ <param name="value" type="const GLint *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="UniformMatrix2fvARB" offset="738">
+ <param name="location" type="GLint"/>
+ <param name="count" type="GLsizei"/>
+ <param name="transpose" type="GLboolean"/>
+ <param name="value" type="const GLfloat *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="UniformMatrix3fvARB" offset="739">
+ <param name="location" type="GLint"/>
+ <param name="count" type="GLsizei"/>
+ <param name="transpose" type="GLboolean"/>
+ <param name="value" type="const GLfloat *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="UniformMatrix4fvARB" offset="740">
+ <param name="location" type="GLint"/>
+ <param name="count" type="GLsizei"/>
+ <param name="transpose" type="GLboolean"/>
+ <param name="value" type="const GLfloat *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetObjectParameterfvARB" offset="741">
+ <param name="obj" type="GLhandleARB"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetObjectParameterivARB" offset="742">
+ <param name="obj" type="GLhandleARB"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetInfoLogARB" offset="743">
+ <param name="obj" type="GLhandleARB"/>
+ <param name="maxLength" type="GLsizei"/>
+ <param name="length" type="GLsizei *" output="true"/>
+ <param name="infoLog" type="GLcharARB *" output="true"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetAttachedObjectsARB" offset="744">
+ <param name="containerObj" type="GLhandleARB"/>
+ <param name="maxLength" type="GLsizei"/>
+ <param name="length" type="GLsizei *" output="true"/>
+ <param name="infoLog" type="GLhandleARB *" output="true"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetUniformLocationARB" offset="745">
+ <param name="programObj" type="GLhandleARB"/>
+ <param name="name" type="const GLcharARB *"/>
+ <return type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetActiveUniformARB" offset="746">
+ <param name="programObj" type="GLhandleARB"/>
+ <param name="index" type="GLuint"/>
+ <param name="maxLength" type="GLsizei"/>
+ <param name="length" type="GLsizei *" output="true"/>
+ <param name="size" type="GLint *" output="true"/>
+ <param name="type" type="GLenum *" output="true"/>
+ <param name="name" type="GLcharARB *" output="true"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetUniformfvARB" offset="747">
+ <param name="programObj" type="GLhandleARB"/>
+ <param name="location" type="GLint"/>
+ <param name="params" type="GLfloat *" output="true"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetUniformivARB" offset="748">
+ <param name="programObj" type="GLhandleARB"/>
+ <param name="location" type="GLint"/>
+ <param name="params" type="GLint *" output="true"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetShaderSourceARB" offset="749">
+ <param name="obj" type="GLhandleARB"/>
+ <param name="maxLength" type="GLsizei"/>
+ <param name="length" type="GLsizei *" output="true"/>
+ <param name="source" type="GLcharARB *" output="true"/>
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_ARB_vertex_shader" number="31">
+ <enum name="VERTEX_SHADER_ARB" value="0x8B31"/>
+ <enum name="MAX_VERTEX_UNIFORM_COMPONENTS_ARB" value="0x8B4A"/>
+ <enum name="MAX_VARYING_FLOATS_ARB" value="0x8B4B"/>
+ <enum name="MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB" value="0x8B4C"/>
+ <enum name="MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB" value="0x8B4D"/>
+ <enum name="OBJECT_ACTIVE_ATTRIBUTES_ARB" value="0x8B89"/>
+ <enum name="OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB" value="0x8B8A"/>
+
+ <function name="BindAttribLocationARB" offset="750">
+ <param name="programObj" type="GLhandleARB"/>
+ <param name="index" type="GLuint"/>
+ <param name="name" type="const GLcharARB *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetActiveAttribARB" offset="751">
+ <param name="programObj" type="GLhandleARB"/>
+ <param name="index" type="GLuint"/>
+ <param name="maxLength" type="GLsizei"/>
+ <param name="length" type="GLsizei *" output="true"/>
+ <param name="size" type="GLint *" output="true"/>
+ <param name="type" type="GLenum *" output="true"/>
+ <param name="name" type="GLcharARB *" output="true"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetAttribLocationARB" offset="752">
+ <param name="programObj" type="GLhandleARB"/>
+ <param name="name" type="const GLcharARB *"/>
+ <return type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_ARB_fragment_shader" number="32">
+ <enum name="FRAGMENT_SHADER_ARB" value="0x8B30"/>
+ <enum name="MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB" value="0x8B49"/>
+</category>
+
+<category name="GL_ARB_shading_language_100" number="33">
+ <!-- No new functions, types, enums. -->
+</category>
+
+<category name="GL_ARB_texture_non_power_of_two" number="34">
+ <!-- No new functions, types, enums. -->
+</category>
+
+<category name="GL_ARB_point_sprite" number="35">
+ <enum name="POINT_SPRITE_ARB" count="1" value="0x8861">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="COORD_REPLACE_ARB" count="1" value="0x8862">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+</category>
+
+<category name="GL_ARB_fragment_program_shadow" number="36">
+ <!-- No new functions, types, enums. -->
+</category>
+
+<category name="GL_ARB_draw_buffers" number="37">
+ <enum name="MAX_DRAW_BUFFERS_ARB" count="1" value="0x8824">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER0_ARB" count="1" value="0x8825">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER1_ARB" count="1" value="0x8826">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER2_ARB" count="1" value="0x8827">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER3_ARB" count="1" value="0x8828">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER4_ARB" count="1" value="0x8829">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER5_ARB" count="1" value="0x882A">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER6_ARB" count="1" value="0x882B">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER7_ARB" count="1" value="0x882C">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER8_ARB" count="1" value="0x882D">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER9_ARB" count="1" value="0x882E">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER10_ARB" count="1" value="0x882F">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER11_ARB" count="1" value="0x8830">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER12_ARB" count="1" value="0x8831">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER13_ARB" count="1" value="0x8832">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER14_ARB" count="1" value="0x8833">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER15_ARB" count="1" value="0x8834">
+ <size name="Get" mode="get"/>
+ </enum>
+
+ <function name="DrawBuffersARB" offset="413">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="bufs" type="const GLenum *" count="n"/>
+ <glx rop="233" large="true"/>
+ </function>
+</category>
+
+<category name="GL_ARB_texture_rectangle" number="38">
+ <enum name="TEXTURE_RECTANGLE_ARB" count="1" value="0x84F5">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_BINDING_RECTANGLE_ARB" count="1" value="0x84F6">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PROXY_TEXTURE_RECTANGLE_ARB" value="0x84F7"/>
+ <enum name="MAX_RECTANGLE_TEXTURE_SIZE_ARB" count="1" value="0x84F8">
+ <size name="Get" mode="get"/>
+ </enum>
+</category>
+
+<!-- Non-ARB extensions sorted by extension number. -->
+
+<category name="GL_EXT_blend_color" number="2">
+ <enum name="CONSTANT_COLOR_EXT" value="0x8001"/>
+ <enum name="ONE_MINUS_CONSTANT_COLOR_EXT" value="0x8002"/>
+ <enum name="CONSTANT_ALPHA_EXT" value="0x8003"/>
+ <enum name="ONE_MINUS_CONSTANT_ALPHA_EXT" value="0x8004"/>
+ <enum name="BLEND_COLOR_EXT" count="4" value="0x8005">
+ <size name="Get" mode="get"/>
+ </enum>
+
+ <function name="BlendColorEXT" alias="BlendColor">
+ <param name="red" type="GLclampf"/>
+ <param name="green" type="GLclampf"/>
+ <param name="blue" type="GLclampf"/>
+ <param name="alpha" type="GLclampf"/>
+ </function>
+</category>
+
+<category name="GL_EXT_polygon_offset" number="3">
+ <function name="PolygonOffsetEXT" offset="414">
+ <param name="factor" type="GLfloat"/>
+ <param name="bias" type="GLfloat"/>
+ <glx rop="4098" ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_EXT_texture" number="4">
+ <enum name="ALPHA4_EXT" value="0x803B"/>
+ <enum name="ALPHA8_EXT" value="0x803C"/>
+ <enum name="ALPHA12_EXT" value="0x803D"/>
+ <enum name="ALPHA16_EXT" value="0x803E"/>
+ <enum name="LUMINANCE4_EXT" value="0x803F"/>
+ <enum name="LUMINANCE8_EXT" value="0x8040"/>
+ <enum name="LUMINANCE12_EXT" value="0x8041"/>
+ <enum name="LUMINANCE16_EXT" value="0x8042"/>
+ <enum name="LUMINANCE4_ALPHA4_EXT" value="0x8043"/>
+ <enum name="LUMINANCE6_ALPHA2_EXT" value="0x8044"/>
+ <enum name="LUMINANCE8_ALPHA8_EXT" value="0x8045"/>
+ <enum name="LUMINANCE12_ALPHA4_EXT" value="0x8046"/>
+ <enum name="LUMINANCE12_ALPHA12_EXT" value="0x8047"/>
+ <enum name="LUMINANCE16_ALPHA16_EXT" value="0x8048"/>
+ <enum name="INTENSITY_EXT" value="0x8049"/>
+ <enum name="INTENSITY4_EXT" value="0x804A"/>
+ <enum name="INTENSITY8_EXT" value="0x804B"/>
+ <enum name="INTENSITY12_EXT" value="0x804C"/>
+ <enum name="INTENSITY16_EXT" value="0x804D"/>
+ <enum name="RGB2_EXT" value="0x804E"/>
+ <enum name="RGB4_EXT" value="0x804F"/>
+ <enum name="RGB5_EXT" value="0x8050"/>
+ <enum name="RGB8_EXT" value="0x8051"/>
+ <enum name="RGB10_EXT" value="0x8052"/>
+ <enum name="RGB12_EXT" value="0x8053"/>
+ <enum name="RGB16_EXT" value="0x8054"/>
+ <enum name="RGBA2_EXT" value="0x8055"/>
+ <enum name="RGBA4_EXT" value="0x8056"/>
+ <enum name="RGB5_A1_EXT" value="0x8057"/>
+ <enum name="RGBA8_EXT" value="0x8058"/>
+ <enum name="RGB10_A2_EXT" value="0x8059"/>
+ <enum name="RGBA12_EXT" value="0x805A"/>
+ <enum name="RGBA16_EXT" value="0x805B"/>
+ <enum name="TEXTURE_RED_SIZE_EXT" count="1" value="0x805C">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_GREEN_SIZE_EXT" count="1" value="0x805D">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_BLUE_SIZE_EXT" count="1" value="0x805E">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_ALPHA_SIZE_EXT" count="1" value="0x805F">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_LUMINANCE_SIZE_EXT" count="1" value="0x8060">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_INTENSITY_SIZE_EXT" count="1" value="0x8061">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+ <enum name="REPLACE_EXT" value="0x8062"/>
+ <enum name="PROXY_TEXTURE_1D_EXT" value="0x8063"/>
+ <enum name="PROXY_TEXTURE_2D_EXT" value="0x8064"/>
+ <enum name="TEXTURE_TOO_LARGE_EXT" value="0x8065"/>
+</category>
+
+<!-- Extension number 5 is not listed in the extension registry. -->
+
+<category name="GL_EXT_texture3D" number="6">
+ <function name="TexImage3DEXT" alias="TexImage3D">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="depth" type="GLsizei"/>
+ <param name="border" type="GLint"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="pixels" type="const GLvoid *"/>
+ </function>
+
+ <function name="TexSubImage3DEXT" alias="TexSubImage3D">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="yoffset" type="GLint"/>
+ <param name="zoffset" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="depth" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="pixels" type="const GLvoid *"/>
+ </function>
+</category>
+
+<category name="GL_SGIS_texture_filter4" number="7">
+ <function name="GetTexFilterFuncSGIS" offset="415">
+ <param name="target" type="GLenum"/>
+ <param name="filter" type="GLenum"/>
+ <param name="weights" type="GLfloat *" output="true"/>
+ <glx vendorpriv="4101" ignore="true"/>
+ </function>
+
+ <function name="TexFilterFuncSGIS" offset="416">
+ <param name="target" type="GLenum"/>
+ <param name="filter" type="GLenum"/>
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="weights" type="const GLfloat *" count="n"/>
+ <glx rop="2064" ignore="true"/>
+ </function>
+</category>
+
+<!-- Extension number 8 is not listed in the extension registry. -->
+
+<category name="GL_EXT_subtexture" number="9">
+ <function name="TexSubImage1DEXT" alias="TexSubImage1D">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="pixels" type="const GLvoid *"/>
+ </function>
+
+ <function name="TexSubImage2DEXT" alias="TexSubImage2D">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="yoffset" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="pixels" type="const GLvoid *"/>
+ </function>
+</category>
+
+<category name="GL_EXT_copy_texture" number="10">
+ <function name="CopyTexImage1DEXT" alias="CopyTexImage1D">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="border" type="GLint"/>
+ </function>
+
+ <function name="CopyTexImage2DEXT" alias="CopyTexImage2D">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="border" type="GLint"/>
+ </function>
+
+ <function name="CopyTexSubImage1DEXT" alias="CopyTexSubImage1D">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ </function>
+
+ <function name="CopyTexSubImage2DEXT" alias="CopyTexSubImage2D">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="yoffset" type="GLint"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ </function>
+
+ <function name="CopyTexSubImage3DEXT" alias="CopyTexSubImage3D">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="yoffset" type="GLint"/>
+ <param name="zoffset" type="GLint"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ </function>
+</category>
+
+<category name="GL_EXT_histogram" number="11">
+ <enum name="HISTOGRAM_EXT" value="0x8024"/>
+ <enum name="PROXY_HISTOGRAM_EXT" value="0x8025"/>
+ <enum name="HISTOGRAM_WIDTH_EXT" count="1" value="0x8026">
+ <size name="GetHistogramParameterfvEXT" mode="get"/>
+ <size name="GetHistogramParameterivEXT" mode="get"/>
+ </enum>
+ <enum name="HISTOGRAM_FORMAT_EXT" count="1" value="0x8027">
+ <size name="GetHistogramParameterfvEXT" mode="get"/>
+ <size name="GetHistogramParameterivEXT" mode="get"/>
+ </enum>
+ <enum name="HISTOGRAM_RED_SIZE_EXT" count="1" value="0x8028">
+ <size name="GetHistogramParameterfvEXT" mode="get"/>
+ <size name="GetHistogramParameterivEXT" mode="get"/>
+ </enum>
+ <enum name="HISTOGRAM_GREEN_SIZE_EXT" count="1" value="0x8029">
+ <size name="GetHistogramParameterfvEXT" mode="get"/>
+ <size name="GetHistogramParameterivEXT" mode="get"/>
+ </enum>
+ <enum name="HISTOGRAM_BLUE_SIZE_EXT" count="1" value="0x802A">
+ <size name="GetHistogramParameterfvEXT" mode="get"/>
+ <size name="GetHistogramParameterivEXT" mode="get"/>
+ </enum>
+ <enum name="HISTOGRAM_ALPHA_SIZE_EXT" count="1" value="0x802B">
+ <size name="GetHistogramParameterfvEXT" mode="get"/>
+ <size name="GetHistogramParameterivEXT" mode="get"/>
+ </enum>
+ <enum name="HISTOGRAM_LUMINANCE_SIZE_EXT" count="1" value="0x802C">
+ <size name="GetHistogramParameterfvEXT" mode="get"/>
+ <size name="GetHistogramParameterivEXT" mode="get"/>
+ </enum>
+ <enum name="HISTOGRAM_SINK_EXT" count="1" value="0x802D">
+ <size name="GetHistogramParameterfvEXT" mode="get"/>
+ <size name="GetHistogramParameterivEXT" mode="get"/>
+ </enum>
+ <enum name="MINMAX_EXT" value="0x802E"/>
+ <enum name="MINMAX_FORMAT_EXT" count="1" value="0x802F">
+ <size name="GetMinmaxParameterfvEXT" mode="get"/>
+ <size name="GetMinmaxParameterivEXT" mode="get"/>
+ </enum>
+ <enum name="MINMAX_SINK_EXT" count="1" value="0x8030">
+ <size name="GetMinmaxParameterfvEXT" mode="get"/>
+ <size name="GetMinmaxParameterivEXT" mode="get"/>
+ </enum>
+ <enum name="TABLE_TOO_LARGE_EXT" value="0x8031"/>
+
+ <function name="GetHistogramEXT" offset="417">
+ <param name="target" type="GLenum"/>
+ <param name="reset" type="GLboolean"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="values" type="GLvoid *" output="true"/>
+ <glx vendorpriv="5" handcode="true" ignore="true"/>
+ </function>
+
+ <function name="GetHistogramParameterfvEXT" offset="418">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx vendorpriv="6" ignore="true"/>
+ </function>
+
+ <function name="GetHistogramParameterivEXT" offset="419">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx vendorpriv="7" ignore="true"/>
+ </function>
+
+ <function name="GetMinmaxEXT" offset="420">
+ <param name="target" type="GLenum"/>
+ <param name="reset" type="GLboolean"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="values" type="GLvoid *" output="true"/>
+ <glx vendorpriv="8" handcode="true" ignore="true"/>
+ </function>
+
+ <function name="GetMinmaxParameterfvEXT" offset="421">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx vendorpriv="9" ignore="true"/>
+ </function>
+
+ <function name="GetMinmaxParameterivEXT" offset="422">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx vendorpriv="10" ignore="true"/>
+ </function>
+
+ <function name="HistogramEXT" alias="Histogram">
+ <param name="target" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="sink" type="GLboolean"/>
+ </function>
+
+ <function name="MinmaxEXT" alias="Minmax">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="sink" type="GLboolean"/>
+ </function>
+
+ <function name="ResetHistogramEXT" alias="ResetHistogram">
+ <param name="target" type="GLenum"/>
+ </function>
+
+ <function name="ResetMinmaxEXT" alias="ResetMinmax">
+ <param name="target" type="GLenum"/>
+ </function>
+</category>
+
+<category name="GL_EXT_convolution" number="12">
+ <enum name="CONVOLUTION_BORDER_MODE_EXT" count="1" value="0x8013">
+ <size name="ConvolutionParameterfv"/>
+ <size name="ConvolutionParameteriv"/>
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ </enum>
+ <enum name="CONVOLUTION_FILTER_SCALE_EXT" count="4" value="0x8014">
+ <size name="ConvolutionParameterfv"/>
+ <size name="ConvolutionParameteriv"/>
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ </enum>
+ <enum name="CONVOLUTION_FILTER_BIAS_EXT" count="4" value="0x8015">
+ <size name="ConvolutionParameterfv"/>
+ <size name="ConvolutionParameteriv"/>
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ </enum>
+ <enum name="REDUCE_EXT" value="0x8016"/>
+ <enum name="CONVOLUTION_FORMAT_EXT" count="1" value="0x8017">
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ </enum>
+ <enum name="CONVOLUTION_WIDTH_EXT" count="1" value="0x8018">
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ </enum>
+ <enum name="CONVOLUTION_HEIGHT_EXT" count="1" value="0x8019">
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ </enum>
+ <enum name="MAX_CONVOLUTION_WIDTH_EXT" count="1" value="0x801A">
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_CONVOLUTION_HEIGHT_EXT" count="1" value="0x801B">
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_CONVOLUTION_RED_SCALE_EXT" count="1" value="0x801C">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_CONVOLUTION_GREEN_SCALE_EXT" count="1" value="0x801D">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_CONVOLUTION_BLUE_SCALE_EXT" count="1" value="0x801E">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_CONVOLUTION_ALPHA_SCALE_EXT" count="1" value="0x801F">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_CONVOLUTION_RED_BIAS_EXT" count="1" value="0x8020">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_CONVOLUTION_GREEN_BIAS_EXT" count="1" value="0x8021">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_CONVOLUTION_BLUE_BIAS_EXT" count="1" value="0x8022">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="POST_CONVOLUTION_ALPHA_BIAS_EXT" count="1" value="0x8023">
+ <size name="Get" mode="get"/>
+ </enum>
+
+ <function name="ConvolutionFilter1DEXT" alias="ConvolutionFilter1D">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="image" type="const GLvoid *"/>
+ </function>
+
+ <function name="ConvolutionFilter2DEXT" alias="ConvolutionFilter2D">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="image" type="const GLvoid *"/>
+ </function>
+
+ <function name="ConvolutionParameterfEXT" alias="ConvolutionParameterf">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat"/>
+ </function>
+
+ <function name="ConvolutionParameterfvEXT" alias="ConvolutionParameterfv">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *"/>
+ </function>
+
+ <function name="ConvolutionParameteriEXT" alias="ConvolutionParameteri">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint"/>
+ </function>
+
+ <function name="ConvolutionParameterivEXT" alias="ConvolutionParameteriv">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *"/>
+ </function>
+
+ <function name="CopyConvolutionFilter1DEXT" alias="CopyConvolutionFilter1D">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ </function>
+
+ <function name="CopyConvolutionFilter2DEXT" alias="CopyConvolutionFilter2D">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ </function>
+
+ <function name="GetConvolutionFilterEXT" offset="423">
+ <param name="target" type="GLenum"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="image" type="GLvoid *" output="true"/>
+ <glx vendorpriv="1" handcode="true" ignore="true"/>
+ </function>
+
+ <function name="GetConvolutionParameterfvEXT" offset="424">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx vendorpriv="2" ignore="true"/>
+ </function>
+
+ <function name="GetConvolutionParameterivEXT" offset="425">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx vendorpriv="3" ignore="true"/>
+ </function>
+
+ <function name="GetSeparableFilterEXT" offset="426">
+ <param name="target" type="GLenum"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="row" type="GLvoid *" output="true"/>
+ <param name="column" type="GLvoid *" output="true"/>
+ <param name="span" type="GLvoid *" output="true"/>
+ <glx vendorpriv="4" handcode="true" ignore="true"/>
+ </function>
+
+ <function name="SeparableFilter2DEXT" alias="SeparableFilter2D">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="row" type="const GLvoid *"/>
+ <param name="column" type="const GLvoid *"/>
+ </function>
+</category>
+
+<category name="GL_SGI_color_matrix" number="13">
+ <enum name="COLOR_MATRIX_SGI" value="0x80B1"/>
+ <enum name="COLOR_MATRIX_STACK_DEPTH_SGI" value="0x80B2"/>
+ <enum name="MAX_COLOR_MATRIX_STACK_DEPTH_SGI" value="0x80B3"/>
+ <enum name="POST_COLOR_MATRIX_RED_SCALE_SGI" value="0x80B4"/>
+ <enum name="POST_COLOR_MATRIX_GREEN_SCALE_SGI" value="0x80B5"/>
+ <enum name="POST_COLOR_MATRIX_BLUE_SCALE_SGI" value="0x80B6"/>
+ <enum name="POST_COLOR_MATRIX_ALPHA_SCALE_SGI" value="0x80B7"/>
+ <enum name="POST_COLOR_MATRIX_RED_BIAS_SGI" value="0x80B8"/>
+ <enum name="POST_COLOR_MATRIX_GREEN_BIAS_SGI" value="0x80B9"/>
+ <enum name="POST_COLOR_MATRIX_BLUE_BIAS_SGI" value="0x80BA"/>
+ <enum name="POST_COLOR_MATRIX_ALPHA_BIAS_SGI" value="0x80BB"/>
+</category>
+
+<category name="GL_SGI_color_table" number="14">
+ <function name="ColorTableSGI" alias="ColorTable">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="table" type="const GLvoid *"/>
+ </function>
+
+ <function name="ColorTableParameterfvSGI" alias="ColorTableParameterfv">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *"/>
+ </function>
+
+ <function name="ColorTableParameterivSGI" alias="ColorTableParameteriv">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *"/>
+ </function>
+
+ <function name="CopyColorTableSGI" alias="CopyColorTable">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ </function>
+
+ <function name="GetColorTableSGI" offset="427">
+ <param name="target" type="GLenum"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="table" type="GLvoid *" output="true"/>
+ <glx vendorpriv="4098" handcode="true" ignore="true"/>
+ </function>
+
+ <function name="GetColorTableParameterfvSGI" offset="428">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx vendorpriv="4099" ignore="true"/>
+ </function>
+
+ <function name="GetColorTableParameterivSGI" offset="429">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx vendorpriv="4100" ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_SGIS_pixel_texture" number="15">
+ <function name="PixelTexGenParameteriSGIS" offset="431">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="PixelTexGenParameterivSGIS" offset="432">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="PixelTexGenParameterfSGIS" offset="433">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="PixelTexGenParameterfvSGIS" offset="434">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetPixelTexGenParameterivSGIS" offset="435">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetPixelTexGenParameterfvSGIS" offset="436">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_SGIS_texture4D" number="16">
+ <function name="TexImage4DSGIS" offset="437">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="depth" type="GLsizei"/>
+ <param name="size4d" type="GLsizei"/>
+ <param name="border" type="GLint"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="pixels" type="const GLvoid *" img_width="width" img_height="height" img_depth="depth" img_extent="size4d" img_format="format" img_type="type" img_target="target" img_null_flag="true" img_pad_dimensions="true"/>
+ <glx rop="2057" ignore="true"/>
+ </function>
+
+ <function name="TexSubImage4DSGIS" offset="438">
+ <param name="target" type="GLenum"/>
+ <param name="level" type="GLint"/>
+ <param name="xoffset" type="GLint"/>
+ <param name="yoffset" type="GLint"/>
+ <param name="zoffset" type="GLint"/>
+ <param name="woffset" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ <param name="height" type="GLsizei"/>
+ <param name="depth" type="GLsizei"/>
+ <param name="size4d" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="pixels" type="const GLvoid *" img_width="width" img_height="height" img_depth="depth" img_extent="size4d" img_xoff="xoffset" img_yoff="yoffset" img_zoff="zoffset" img_woff="woffset" img_format="format" img_type="type" img_target="target" img_null_flag="true" img_pad_dimensions="true"/>
+ <glx rop="2058" ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_SGI_texture_color_table" number="17">
+ <enum name="TEXTURE_COLOR_TABLE_SGI" value="0x80BC"/>
+ <enum name="PROXY_TEXTURE_COLOR_TABLE_SGI" value="0x80BD"/>
+</category>
+
+<!-- Extension number 19 is not listed in the extension registry. -->
+
+<category name="GL_EXT_texture_object" number="20">
+ <function name="AreTexturesResidentEXT" offset="439">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="textures" type="const GLuint *" count="n"/>
+ <param name="residences" type="GLboolean *" output="true" count="n"/>
+ <return type="GLboolean"/>
+ <glx vendorpriv="11" always_array="true"/>
+ </function>
+
+ <function name="BindTextureEXT" alias="BindTexture">
+ <param name="target" type="GLenum"/>
+ <param name="texture" type="GLuint"/>
+ </function>
+
+ <!-- For GLX, this is wrong. DeleteTexturesEXT and DeleteTextures
+ do not have the same protocol!
+ -->
+ <function name="DeleteTexturesEXT" alias="DeleteTextures">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="textures" type="const GLuint *" count="n"/>
+ <glx vendorpriv="12"/>
+ </function>
+
+ <function name="GenTexturesEXT" offset="440">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="textures" type="GLuint *" output="true" count="n"/>
+ <glx vendorpriv="13" always_array="true"/>
+ </function>
+
+ <function name="IsTextureEXT" offset="441">
+ <param name="texture" type="GLuint"/>
+ <return type="GLboolean"/>
+ <glx vendorpriv="14"/>
+ </function>
+
+ <function name="PrioritizeTexturesEXT" alias="PrioritizeTextures">
+ <param name="n" type="GLsizei"/>
+ <param name="textures" type="const GLuint *"/>
+ <param name="priorities" type="const GLclampf *"/>
+ </function>
+</category>
+
+<category name="GL_SGIS_detail_texture" number="21">
+ <function name="DetailTexFuncSGIS" offset="442">
+ <param name="target" type="GLenum"/>
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="points" type="const GLfloat *" count="n"/>
+ <glx rop="2051" ignore="true"/>
+ </function>
+
+ <function name="GetDetailTexFuncSGIS" offset="443">
+ <param name="target" type="GLenum"/>
+ <param name="points" type="GLfloat *" output="true"/>
+ <glx vendorpriv="4096" ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_SGIS_sharpen_texture" number="22">
+ <function name="SharpenTexFuncSGIS" offset="444">
+ <param name="target" type="GLenum"/>
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="points" type="const GLfloat *" count="n" count_scale="2"/>
+ <glx rop="2052" ignore="true"/>
+ </function>
+
+ <function name="GetSharpenTexFuncSGIS" offset="445">
+ <param name="target" type="GLenum"/>
+ <param name="points" type="GLfloat *" output="true"/>
+ <glx vendorpriv="4097" ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_SGIS_multisample" number="25">
+ <function name="SampleMaskSGIS" offset="446">
+ <param name="value" type="GLclampf"/>
+ <param name="invert" type="GLboolean"/>
+ <glx rop="2048"/>
+ </function>
+
+ <function name="SamplePatternSGIS" offset="447">
+ <param name="pattern" type="GLenum"/>
+ <glx rop="2049"/>
+ </function>
+</category>
+
+<!-- Extension number 26 is not listed in the extension registry. -->
+
+<category name="GL_EXT_rescale_normal" number="27">
+ <enum name="RESCALE_NORMAL_EXT" count="1" value="0x803A">
+ <size name="Get" mode="get"/>
+ </enum>
+</category>
+
+<!-- Extension number 28 is a GLX extension. -->
+<!-- Extension number 29 is not listed in the extension registry. -->
+
+<category name="GL_EXT_vertex_array" number="30">
+ <function name="ArrayElementEXT" alias="ArrayElement">
+ <param name="i" type="GLint"/>
+ </function>
+
+ <function name="ColorPointerEXT" offset="448">
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="count" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="DrawArraysEXT" alias="DrawArrays">
+ <param name="mode" type="GLenum"/>
+ <param name="first" type="GLint"/>
+ <param name="count" type="GLsizei"/>
+ </function>
+
+ <function name="EdgeFlagPointerEXT" offset="449">
+ <param name="stride" type="GLsizei"/>
+ <param name="count" type="GLsizei"/>
+ <param name="pointer" type="const GLboolean *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="GetPointervEXT" alias="GetPointerv">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLvoid **" output="true"/>
+ </function>
+
+ <function name="IndexPointerEXT" offset="450">
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="count" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="NormalPointerEXT" offset="451">
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="count" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="TexCoordPointerEXT" offset="452">
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="count" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="VertexPointerEXT" offset="453">
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="count" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+</category>
+
+<category name="GL_SGIS_generate_mipmap" number="32">
+ <enum name="GENERATE_MIPMAP_SGIS" count="1" value="0x8191">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="GENERATE_MIPMAP_HINT_SGIS" value="0x8192"/>
+</category>
+
+<category name="GL_SGIX_clipmap" number="33">
+ <enum name="LINEAR_CLIPMAP_LINEAR_SGIX" value="0x8170"/>
+ <enum name="TEXTURE_CLIPMAP_CENTER_SGIX" count="2" value="0x8171">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_CLIPMAP_FRAME_SGIX" count="1" value="0x8172">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_CLIPMAP_OFFSET_SGIX" count="2" value="0x8173">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX" count="3" value="0x8174">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_CLIPMAP_LOD_OFFSET_SGIX" value="0x8175"/>
+ <enum name="TEXTURE_CLIPMAP_DEPTH_SGIX" value="0x8176"/>
+ <enum name="MAX_CLIPMAP_DEPTH_SGIX" value="0x8177"/>
+ <enum name="MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX" value="0x8178"/>
+ <enum name="NEAREST_CLIPMAP_NEAREST_SGIX" value="0x844D"/>
+ <enum name="NEAREST_CLIPMAP_LINEAR_SGIX" value="0x844E"/>
+ <enum name="LINEAR_CLIPMAP_NEAREST_SGIX" value="0x844F"/>
+</category>
+
+<category name="GL_SGIX_shadow" number="34">
+ <enum name="TEXTURE_COMPARE_SGIX" count="1" value="0x819A">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_COMPARE_OPERATOR_SGIX" count="1" value="0x819B">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_LEQUAL_R_SGIX" value="0x819C"/>
+ <enum name="TEXTURE_GEQUAL_R_SGIX" value="0x819D"/>
+</category>
+
+<category name="GL_SGIS_texture_edge_clamp" number="35">
+ <enum name="CLAMP_TO_EDGE_SGIS" value="0x812F"/>
+</category>
+
+<category name="GL_SGIS_texture_border_clamp" number="36">
+ <enum name="CLAMP_TO_BORDER_SGIS" value="0x812D"/>
+</category>
+
+<category name="GL_EXT_blend_minmax" number="37">
+ <enum name="FUNC_ADD_EXT" value="0x8006"/>
+ <enum name="MIN_EXT" value="0x8007"/>
+ <enum name="MAX_EXT" value="0x8008"/>
+ <enum name="BLEND_EQUATION_EXT" count="1" value="0x8009">
+ <size name="Get" mode="get"/>
+ </enum>
+
+ <function name="BlendEquationEXT" alias="BlendEquation">
+ <param name="mode" type="GLenum"/>
+ </function>
+</category>
+
+<category name="GL_EXT_blend_subtract" number="38">
+ <enum name="FUNC_SUBTRACT_EXT" value="0x800A"/>
+ <enum name="FUNC_REVERSE_SUBTRACT_EXT" value="0x800B"/>
+
+ <!-- <function name="BlendEquationEXT" alias="BlendEquation">
+ <param name="mode" type="GLenum"/>
+ </function> -->
+</category>
+
+<!-- Extension number 40 is a GLX extension. -->
+<!-- Extension number 41 is a GLX extension. -->
+<!-- Extension number 42 is a GLX extension. -->
+<!-- Extension number 43 is a GLX extension. -->
+<!-- Extension number 44 is a GLX extension. -->
+<!-- Extension number 46 is not listed in the extension registry. -->
+<!-- Extension number 47 is a GLX extension. -->
+<!-- Extension number 48 is not listed in the extension registry. -->
+<!-- Extension number 49 is a GLX extension. -->
+<!-- Extension number 50 is a GLX extension. -->
+
+<category name="GL_SGIX_sprite" number="52">
+ <function name="SpriteParameterfSGIX" offset="454">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="SpriteParameterfvSGIX" offset="455">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="SpriteParameteriSGIX" offset="456">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="SpriteParameterivSGIX" offset="457">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *"/>
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_EXT_point_parameters" number="54">
+ <enum name="POINT_SIZE_MIN_EXT" count="1" value="0x8126">
+ <size name="PointParameterfvEXT"/>
+ </enum>
+ <enum name="POINT_SIZE_MAX_EXT" count="1" value="0x8127">
+ <size name="PointParameterfvEXT"/>
+ </enum>
+ <enum name="POINT_FADE_THRESHOLD_SIZE_EXT" count="1" value="0x8128">
+ <size name="PointParameterfvEXT"/>
+ </enum>
+ <enum name="POINT_DISTANCE_ATTENUATION_EXT" count="3" value="0x8129">
+ <size name="PointParameterfvEXT"/>
+ </enum>
+
+ <function name="PointParameterfEXT" offset="458">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx rop="2065"/>
+ </function>
+
+ <function name="PointParameterfvEXT" offset="459">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *" variable_param="pname"/>
+ <glx rop="2066"/>
+ </function>
+</category>
+
+<category name="GL_SGIX_instruments" number="55">
+ <function name="GetInstrumentsSGIX" offset="460">
+ <return type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="InstrumentsBufferSGIX" offset="461">
+ <param name="size" type="GLsizei"/>
+ <param name="buffer" type="GLint *" output="true"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="PollInstrumentsSGIX" offset="462">
+ <param name="marker_p" type="GLint *" output="true"/>
+ <return type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="ReadInstrumentsSGIX" offset="463">
+ <param name="marker" type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="StartInstrumentsSGIX" offset="464">
+ <glx ignore="true"/>
+ </function>
+
+ <function name="StopInstrumentsSGIX" offset="465">
+ <param name="marker" type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_SGIX_texture_scale_bias" number="56">
+ <enum name="POST_TEXTURE_FILTER_BIAS_SGIX" count="4" value="0x8179">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="POST_TEXTURE_FILTER_SCALE_SGIX" count="4" value="0x817A">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="POST_TEXTURE_FILTER_BIAS_RANGE_SGIX" value="0x817B"/>
+ <enum name="POST_TEXTURE_FILTER_SCALE_RANGE_SGIX" value="0x817C"/>
+</category>
+
+<category name="GL_SGIX_framezoom" number="57">
+ <function name="FrameZoomSGIX" offset="466">
+ <param name="factor" type="GLint"/>
+ <glx rop="2072" ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_SGIX_tag_sample_buffer" number="58">
+ <function name="TagSampleBufferSGIX" offset="467">
+ <glx rop="2050" ignore="true"/>
+ </function>
+</category>
+
+<!-- Extension number 59 is not listed in the extension registry. -->
+
+<category name="GL_SGIX_reference_plane" number="60">
+ <function name="ReferencePlaneSGIX" offset="468">
+ <param name="equation" type="const GLdouble *" count="4"/>
+ <glx rop="2071" ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_SGIX_flush_raster" number="61">
+ <function name="FlushRasterSGIX" offset="469">
+ <glx vendorpriv="4105" ignore="true"/>
+ </function>
+</category>
+
+<!-- Extension number 62 is a GLX extension. -->
+
+<category name="GL_SGIX_depth_texture" number="63">
+ <enum name="DEPTH_COMPONENT16_SGIX" value="0x81A5"/>
+ <enum name="DEPTH_COMPONENT24_SGIX" value="0x81A6"/>
+ <enum name="DEPTH_COMPONENT32_SGIX" value="0x81A7"/>
+</category>
+
+<category name="GL_SGIS_fog_function" number="64">
+ <function name="FogFuncSGIS" offset="?">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="points" type="const GLfloat *" count="n" count_scale="2"/>
+ <glx rop="2067" ignore="true"/>
+ </function>
+
+ <function name="GetFogFuncSGIS" offset="?">
+ <param name="points" type="GLfloat *" output="true"/>
+ <!-- GLX protocol for this function is unknown. -->
+ </function>
+</category>
+
+<category name="GL_SGIX_fog_offset" number="65">
+ <enum name="FOG_OFFSET_SGIX" value="0x8198"/>
+ <enum name="FOG_OFFSET_VALUE_SGIX" count="1" value="0x8199">
+ <size name="Fogfv"/>
+ <size name="Fogiv"/>
+ </enum>
+</category>
+
+<category name="GL_HP_image_transform" number="66">
+ <function name="ImageTransformParameteriHP" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ </function>
+
+ <function name="ImageTransformParameterfHP" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ </function>
+
+ <function name="ImageTransformParameterivHP" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *"/>
+ </function>
+
+ <function name="ImageTransformParameterfvHP" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *"/>
+ </function>
+
+ <function name="GetImageTransformParameterivHP" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ </function>
+
+ <function name="GetImageTransformParameterfvHP" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ </function>
+</category>
+
+<category name="GL_HP_convolution_border_modes" number="67">
+ <enum name="IGNORE_BORDER_HP" value="0x8150"/>
+ <enum name="CONSTANT_BORDER_HP" value="0x8151"/>
+ <enum name="REPLICATE_BORDER_HP" value="0x8153"/>
+ <enum name="CONVOLUTION_BORDER_COLOR_HP" count="4" value="0x8154">
+ <size name="ConvolutionParameterfv"/>
+ <size name="ConvolutionParameteriv"/>
+ <size name="GetConvolutionParameterfv" mode="get"/>
+ <size name="GetConvolutionParameteriv" mode="get"/>
+ </enum>
+</category>
+
+<!-- Extension number 68 is not listed in the extension registry. -->
+<!-- Extension number 70 is not listed in the extension registry. -->
+<!-- Extension number 71 is not listed in the extension registry. -->
+<!-- Extension number 72 is not listed in the extension registry. -->
+<!-- Extension number 73 is not listed in the extension registry. -->
+
+<category name="GL_EXT_color_subtable" number="74">
+ <function name="ColorSubTableEXT" alias="ColorSubTable">
+ <param name="target" type="GLenum"/>
+ <param name="start" type="GLsizei"/>
+ <param name="count" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="data" type="const GLvoid *"/>
+ </function>
+
+ <function name="CopyColorSubTableEXT" alias="CopyColorSubTable">
+ <param name="target" type="GLenum"/>
+ <param name="start" type="GLsizei"/>
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="width" type="GLsizei"/>
+ </function>
+</category>
+
+<!-- Extension number 75 is a GLU extension. -->
+
+<category name="GL_PGI_misc_hints" number="77">
+ <function name="HintPGI" offset="544">
+ <param name="target" type="GLenum"/>
+ <param name="mode" type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_EXT_paletted_texture" number="78">
+ <enum name="COLOR_TABLE_FORMAT_EXT" count="1" value="0x80D8">
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+ <enum name="COLOR_TABLE_WIDTH_EXT" count="1" value="0x80D9">
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+ <enum name="COLOR_TABLE_RED_SIZE_EXT" count="1" value="0x80DA">
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+ <enum name="COLOR_TABLE_GREEN_SIZE_EXT" count="1" value="0x80DB">
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+ <enum name="COLOR_TABLE_BLUE_SIZE_EXT" count="1" value="0x80DC">
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+ <enum name="COLOR_TABLE_ALPHA_SIZE_EXT" count="1" value="0x80DD">
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+ <enum name="COLOR_TABLE_LUMINANCE_SIZE_EXT" count="1" value="0x80DE">
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+ <enum name="COLOR_TABLE_INTENSITY_SIZE_EXT" count="1" value="0x80DF">
+ <size name="GetColorTableParameterfv" mode="get"/>
+ <size name="GetColorTableParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_INDEX_SIZE_EXT" count="1" value="0x80ED">
+ <size name="GetTexLevelParameterfv" mode="get"/>
+ <size name="GetTexLevelParameteriv" mode="get"/>
+ </enum>
+
+ <function name="ColorTableEXT" alias="ColorTable">
+ <param name="target" type="GLenum"/>
+ <param name="internalformat" type="GLenum"/>
+ <param name="width" type="GLsizei"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="table" type="const GLvoid *"/>
+ </function>
+
+ <function name="GetColorTableEXT" offset="550">
+ <param name="target" type="GLenum"/>
+ <param name="format" type="GLenum"/>
+ <param name="type" type="GLenum"/>
+ <param name="data" type="GLvoid *" output="true"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetColorTableParameterivEXT" offset="551">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetColorTableParameterfvEXT" offset="552">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_EXT_clip_volume_hint" number="79">
+ <enum name="CLIP_VOLUME_CLIPPING_HINT_EXT" count="1" value="0x80F0">
+ <size name="Get" mode="get"/>
+ </enum>
+</category>
+
+<category name="GL_SGIX_list_priority" number="80">
+ <function name="GetListParameterfvSGIX" offset="470">
+ <param name="list" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetListParameterivSGIX" offset="471">
+ <param name="list" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="ListParameterfSGIX" offset="472">
+ <param name="list" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="ListParameterfvSGIX" offset="473">
+ <param name="list" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="ListParameteriSGIX" offset="474">
+ <param name="list" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="ListParameterivSGIX" offset="475">
+ <param name="list" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *"/>
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<!-- Extension number 82 is not listed in the extension registry. -->
+<!-- Extension number 83 is a GLX extension. -->
+
+<category name="GL_SGIX_texture_lod_bias" number="84">
+ <enum name="TEXTURE_LOD_BIAS_S_SGIX" count="1" value="0x818E">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_LOD_BIAS_T_SGIX" count="1" value="0x818F">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_LOD_BIAS_R_SGIX" count="1" value="0x8190">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+</category>
+
+<!-- Extension number 85 is a GLU extension. -->
+<!-- Extension number 86 is a GLX extension. -->
+<!-- Extension number 87 is not listed in the extension registry. -->
+<!-- Extension number 88 is not listed in the extension registry. -->
+<!-- Extension number 89 is not listed in the extension registry. -->
+
+
+<category name="GL_SGIX_shadow_ambient" number="90">
+ <enum name="SHADOW_AMBIENT_SGIX" count="1" value="0x80BF">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+</category>
+
+<!-- Extension number 91 is a GLX extension. -->
+<!-- Extension number 92 is a GLX extension. -->
+
+<category name="GL_EXT_index_material" number="94">
+ <function name="IndexMaterialEXT" offset="538">
+ <param name="face" type="GLenum"/>
+ <param name="mode" type="GLenum"/>
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_EXT_index_func" number="95">
+ <function name="IndexFuncEXT" offset="539">
+ <param name="func" type="GLenum"/>
+ <param name="ref" type="GLclampf"/>
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_EXT_compiled_vertex_array" number="97">
+ <function name="LockArraysEXT" offset="540">
+ <param name="first" type="GLint"/>
+ <param name="count" type="GLsizei"/>
+ <glx handcode="true" ignore="true"/>
+ </function>
+
+ <function name="UnlockArraysEXT" offset="541">
+ <glx handcode="true" ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_EXT_cull_vertex" number="98">
+ <enum name="CULL_VERTEX_EXT" value="0x81AA"/>
+ <enum name="CULL_VERTEX_OBJECT_POSITION_EXT" count="4" value="0x81AB">
+ <size name="CullParameterfv"/>
+ <size name="CullParameterdv"/>
+ </enum>
+ <enum name="CULL_VERTEX_EYE_POSITION_EXT" count="4" value="0x81AC">
+ <size name="CullParameterfv"/>
+ <size name="CullParameterdv"/>
+ </enum>
+
+ <function name="CullParameterdvEXT" offset="542">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLdouble *"/> <!-- Spec bug. Should be const. -->
+ <glx ignore="true"/>
+ </function>
+
+ <function name="CullParameterfvEXT" offset="543">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *"/> <!-- Spec bug. Should be const. -->
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<!-- Extension number 99 is not listed in the extension registry. -->
+<!-- Extension number 100 is a GLU extension. -->
+
+<!-- Shouldn't this be EXT_fragment_lighting? -->
+<category name="GL_SGIX_fragment_lighting" number="102">
+ <function name="FragmentColorMaterialSGIX" offset="476">
+ <param name="face" type="GLenum"/>
+ <param name="mode" type="GLenum"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="FragmentLightfSGIX" offset="477">
+ <param name="light" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="FragmentLightfvSGIX" offset="478">
+ <param name="light" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="FragmentLightiSGIX" offset="479">
+ <param name="light" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="FragmentLightivSGIX" offset="480">
+ <param name="light" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="FragmentLightModelfSGIX" offset="481">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="FragmentLightModelfvSGIX" offset="482">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="FragmentLightModeliSGIX" offset="483">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="FragmentLightModelivSGIX" offset="484">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="FragmentMaterialfSGIX" offset="485">
+ <param name="face" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="FragmentMaterialfvSGIX" offset="486">
+ <param name="face" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="FragmentMaterialiSGIX" offset="487">
+ <param name="face" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="FragmentMaterialivSGIX" offset="488">
+ <param name="face" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetFragmentLightfvSGIX" offset="489">
+ <param name="light" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetFragmentLightivSGIX" offset="490">
+ <param name="light" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetFragmentMaterialfvSGIX" offset="491">
+ <param name="face" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetFragmentMaterialivSGIX" offset="492">
+ <param name="face" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="LightEnviSGIX" offset="493">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<!-- Extension number 103 is not listed in the extension registry. -->
+<!-- Extension number 104 is not listed in the extension registry. -->
+<!-- Extension number 105 is not listed in the extension registry. -->
+<!-- Extension number 106 is not listed in the extension registry. -->
+<!-- Extension number 107 is not listed in the extension registry. -->
+<!-- Extension number 108 is not listed in the extension registry. -->
+<!-- Extension number 109 is not listed in the extension registry. -->
+
+<category name="GL_IBM_rasterpos_clip" number="110">
+ <enum name="RASTER_POSITION_UNCLIPPED_IBM" count="1" value="0x19262">
+ <size name="Get" mode="get"/>
+ </enum>
+</category>
+
+<category name="GL_EXT_draw_range_elements" number="112">
+ <function name="DrawRangeElementsEXT" alias="DrawRangeElements">
+ <param name="mode" type="GLenum"/>
+ <param name="start" type="GLuint"/>
+ <param name="end" type="GLuint"/>
+ <param name="count" type="GLsizei"/>
+ <param name="type" type="GLenum"/>
+ <param name="indices" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+</category>
+
+<!-- Extension number 115 is a GLX extension. -->
+<!-- Extension number 116 is not listed in the extension registry. -->
+
+<category name="GL_EXT_light_texture" number="117">
+ <function name="ApplyTextureEXT" offset="?">
+ <param name="mode" type="GLenum"/>
+ </function>
+
+ <function name="TextureLightEXT" offset="?">
+ <param name="pname" type="GLenum"/>
+ </function>
+
+ <function name="TextureMaterialEXT" offset="?">
+ <param name="face" type="GLenum"/>
+ <param name="mode" type="GLenum"/>
+ </function>
+</category>
+
+<!-- Extension number 118 is not listed in the extension registry. -->
+<!-- Extension number 121 is not listed in the extension registry. -->
+<!-- Extension number 122 is not listed in the extension registry. -->
+<!-- Extension number 123 is not listed in the extension registry. -->
+<!-- Extension number 124 is not listed in the extension registry. -->
+<!-- Extension number 125 is not listed in the extension registry. -->
+<!-- Extension number 126 is not listed in the extension registry. -->
+<!-- Extension number 128 is not listed in the extension registry. -->
+<!-- Extension number 130 is not listed in the extension registry. -->
+<!-- Extension number 131 is not listed in the extension registry. -->
+
+<category name="GL_SGIX_async" number="132">
+ <function name="AsyncMarkerSGIX" offset="?">
+ <param name="marker" type="GLuint"/>
+ </function>
+
+ <function name="FinishAsyncSGIX" offset="?">
+ <param name="markerp" type="GLuint *"/> <!-- Spec bug. Should be const. -->
+ <return type="GLint"/>
+ </function>
+
+ <function name="PollAsyncSGIX" offset="?">
+ <param name="markerp" type="GLuint *"/> <!-- Spec bug. Should be const. -->
+ <return type="GLint"/>
+ </function>
+
+ <function name="GenAsyncMarkersSGIX" offset="?">
+ <param name="range" type="GLsizei"/>
+ <return type="GLuint"/>
+ </function>
+
+ <function name="DeleteAsyncMarkersSGIX" offset="?">
+ <param name="marker" type="GLuint"/>
+ <param name="range" type="GLsizei"/>
+ </function>
+
+ <function name="IsAsyncMarkerSGIX" offset="?">
+ <param name="marker" type="GLuint"/>
+ <return type="GLboolean"/>
+ </function>
+</category>
+
+<category name="GL_INTEL_parallel_arrays" number="136">
+ <function name="VertexPointervINTEL" offset="?">
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="pointer" type="const GLvoid **"/>
+ </function>
+
+ <function name="NormalPointervINTEL" offset="?">
+ <param name="type" type="GLenum"/>
+ <param name="pointer" type="const GLvoid **"/>
+ </function>
+
+ <function name="ColorPointervINTEL" offset="?">
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="pointer" type="const GLvoid **"/>
+ </function>
+
+ <function name="TexCoordPointervINTEL" offset="?">
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="pointer" type="const GLvoid **"/>
+ </function>
+</category>
+
+<category name="GL_HP_occlusion_test" number="137">
+ <enum name="OCCLUSION_TEST_HP" count="1" value="0x8165">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="OCCLUSION_TEST_RESULT_HP" count="1" value="0x8166">
+ <size name="Get" mode="get"/>
+ </enum>
+</category>
+
+<category name="GL_EXT_pixel_transform" number="138">
+ <function name="PixelTransformParameteriEXT" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ </function>
+
+ <function name="PixelTransformParameterfEXT" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ </function>
+
+ <function name="PixelTransformParameterivEXT" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *"/>
+ </function>
+
+ <function name="PixelTransformParameterfvEXT" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *"/>
+ </function>
+</category>
+
+<!-- Extension number 140 is not listed in the extension registry. -->
+
+<category name="GL_EXT_shared_texture_palette" number="141">
+ <enum name="SHARED_TEXTURE_PALETTE_EXT" count="1" value="0x81FB"/>
+</category>
+
+<!-- Extension number 142 is a GLX extension. -->
+<!-- Extension number 143 is not listed in the extension registry. -->
+
+<category name="GL_EXT_separate_specular_color" number="144">
+ <enum name="LIGHT_MODEL_COLOR_CONTROL_EXT" count="1" value="0x81F8">
+ <size name="LightModelfv"/>
+ <size name="LightModeliv"/>
+ </enum>
+ <enum name="SINGLE_COLOR_EXT" value="0x81F9"/>
+ <enum name="SEPARATE_SPECULAR_COLOR_EXT" value="0x81FA"/>
+</category>
+
+<category name="GL_EXT_secondary_color" number="145">
+ <function name="SecondaryColor3bEXT" offset="561" vectorequiv="SecondaryColor3bvEXT">
+ <param name="red" type="GLbyte"/>
+ <param name="green" type="GLbyte"/>
+ <param name="blue" type="GLbyte"/>
+ </function>
+
+ <function name="SecondaryColor3bvEXT" offset="562">
+ <param name="v" type="const GLbyte *" count="3"/>
+ <glx rop="4126"/>
+ </function>
+
+ <function name="SecondaryColor3dEXT" offset="563" vectorequiv="SecondaryColor3dvEXT">
+ <param name="red" type="GLdouble"/>
+ <param name="green" type="GLdouble"/>
+ <param name="blue" type="GLdouble"/>
+ </function>
+
+ <function name="SecondaryColor3dvEXT" offset="564">
+ <param name="v" type="const GLdouble *" count="3"/>
+ <glx rop="4130"/>
+ </function>
+
+ <function name="SecondaryColor3fEXT" offset="565" vectorequiv="SecondaryColor3fvEXT">
+ <param name="red" type="GLfloat"/>
+ <param name="green" type="GLfloat"/>
+ <param name="blue" type="GLfloat"/>
+ </function>
+
+ <function name="SecondaryColor3fvEXT" offset="566">
+ <param name="v" type="const GLfloat *" count="3"/>
+ <glx rop="4129"/>
+ </function>
+
+ <function name="SecondaryColor3iEXT" offset="567" vectorequiv="SecondaryColor3ivEXT">
+ <param name="red" type="GLint"/>
+ <param name="green" type="GLint"/>
+ <param name="blue" type="GLint"/>
+ </function>
+
+ <function name="SecondaryColor3ivEXT" offset="568">
+ <param name="v" type="const GLint *" count="3"/>
+ <glx rop="4128"/>
+ </function>
+
+ <function name="SecondaryColor3sEXT" offset="569" vectorequiv="SecondaryColor3svEXT">
+ <param name="red" type="GLshort"/>
+ <param name="green" type="GLshort"/>
+ <param name="blue" type="GLshort"/>
+ </function>
+
+ <function name="SecondaryColor3svEXT" offset="570">
+ <param name="v" type="const GLshort *" count="3"/>
+ <glx rop="4127"/>
+ </function>
+
+ <function name="SecondaryColor3ubEXT" offset="571" vectorequiv="SecondaryColor3ubvEXT">
+ <param name="red" type="GLubyte"/>
+ <param name="green" type="GLubyte"/>
+ <param name="blue" type="GLubyte"/>
+ </function>
+
+ <function name="SecondaryColor3ubvEXT" offset="572">
+ <param name="v" type="const GLubyte *" count="3"/>
+ <glx rop="4131"/>
+ </function>
+
+ <function name="SecondaryColor3uiEXT" offset="573" vectorequiv="SecondaryColor3uivEXT">
+ <param name="red" type="GLuint"/>
+ <param name="green" type="GLuint"/>
+ <param name="blue" type="GLuint"/>
+ </function>
+
+ <function name="SecondaryColor3uivEXT" offset="574">
+ <param name="v" type="const GLuint *" count="3"/>
+ <glx rop="4133"/>
+ </function>
+
+ <function name="SecondaryColor3usEXT" offset="575" vectorequiv="SecondaryColor3usvEXT">
+ <param name="red" type="GLushort"/>
+ <param name="green" type="GLushort"/>
+ <param name="blue" type="GLushort"/>
+ </function>
+
+ <function name="SecondaryColor3usvEXT" offset="576">
+ <param name="v" type="const GLushort *" count="3"/>
+ <glx rop="4132"/>
+ </function>
+
+ <function name="SecondaryColorPointerEXT" offset="577">
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+</category>
+
+<category name="GL_EXT_texture_perturb_normal" number="147">
+ <function name="TextureNormalEXT" offset="?">
+ <param name="mode" type="GLenum"/>
+ </function>
+</category>
+
+<category name="GL_EXT_multi_draw_arrays" number="148">
+ <function name="MultiDrawArraysEXT" offset="644">
+ <param name="mode" type="GLenum"/>
+ <param name="first" type="GLint *"/> <!-- Spec bug. Should be const. -->
+ <param name="count" type="GLsizei *"/> <!-- Spec bug. Should be const. -->
+ <param name="primcount" type="GLsizei"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="MultiDrawElementsEXT" offset="645">
+ <param name="mode" type="GLenum"/>
+ <param name="count" type="const GLsizei *"/>
+ <param name="type" type="GLenum"/>
+ <param name="indices" type="const GLvoid **"/>
+ <param name="primcount" type="GLsizei"/>
+ <glx handcode="true"/>
+ </function>
+</category>
+
+<category name="GL_EXT_fog_coord" number="149">
+ <function name="FogCoordfEXT" offset="545" vectorequiv="FogCoordfvEXT">
+ <param name="coord" type="GLfloat"/>
+ </function>
+
+ <function name="FogCoordfvEXT" offset="546">
+ <param name="coord" type="const GLfloat *" count="1"/>
+ <glx rop="4124"/>
+ </function>
+
+ <function name="FogCoorddEXT" offset="547" vectorequiv="FogCoorddvEXT">
+ <param name="coord" type="GLdouble"/>
+ </function>
+
+ <function name="FogCoorddvEXT" offset="548">
+ <param name="coord" type="const GLdouble *" count="1"/>
+ <glx rop="4125"/>
+ </function>
+
+ <function name="FogCoordPointerEXT" offset="549">
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+</category>
+
+<!-- Extension number 150 is not listed in the extension registry. -->
+<!-- Extension number 151 is not listed in the extension registry. -->
+<!-- Extension number 152 is not listed in the extension registry. -->
+<!-- Extension number 153 is not listed in the extension registry. -->
+<!-- Extension number 154 is not listed in the extension registry. -->
+
+<category name="GL_EXT_coordinate_frame" number="156">
+ <function name="Tangent3bEXT" offset="?">
+ <param name="tx" type="GLbyte"/>
+ <param name="ty" type="GLbyte"/>
+ <param name="tz" type="GLbyte"/>
+ </function>
+
+ <function name="Tangent3bvEXT" offset="?">
+ <param name="v" type="const GLbyte *"/>
+ </function>
+
+ <function name="Tangent3dEXT" offset="?">
+ <param name="tx" type="GLdouble"/>
+ <param name="ty" type="GLdouble"/>
+ <param name="tz" type="GLdouble"/>
+ </function>
+
+ <function name="Tangent3dvEXT" offset="?">
+ <param name="v" type="const GLdouble *"/>
+ </function>
+
+ <function name="Tangent3fEXT" offset="?">
+ <param name="tx" type="GLfloat"/>
+ <param name="ty" type="GLfloat"/>
+ <param name="tz" type="GLfloat"/>
+ </function>
+
+ <function name="Tangent3fvEXT" offset="?">
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="Tangent3iEXT" offset="?">
+ <param name="tx" type="GLint"/>
+ <param name="ty" type="GLint"/>
+ <param name="tz" type="GLint"/>
+ </function>
+
+ <function name="Tangent3ivEXT" offset="?">
+ <param name="v" type="const GLint *"/>
+ </function>
+
+ <function name="Tangent3sEXT" offset="?">
+ <param name="tx" type="GLshort"/>
+ <param name="ty" type="GLshort"/>
+ <param name="tz" type="GLshort"/>
+ </function>
+
+ <function name="Tangent3svEXT" offset="?">
+ <param name="v" type="const GLshort *"/>
+ </function>
+
+ <function name="Binormal3bEXT" offset="?">
+ <param name="bx" type="GLbyte"/>
+ <param name="by" type="GLbyte"/>
+ <param name="bz" type="GLbyte"/>
+ </function>
+
+ <function name="Binormal3bvEXT" offset="?">
+ <param name="v" type="const GLbyte *"/>
+ </function>
+
+ <function name="Binormal3dEXT" offset="?">
+ <param name="bx" type="GLdouble"/>
+ <param name="by" type="GLdouble"/>
+ <param name="bz" type="GLdouble"/>
+ </function>
+
+ <function name="Binormal3dvEXT" offset="?">
+ <param name="v" type="const GLdouble *"/>
+ </function>
+
+ <function name="Binormal3fEXT" offset="?">
+ <param name="bx" type="GLfloat"/>
+ <param name="by" type="GLfloat"/>
+ <param name="bz" type="GLfloat"/>
+ </function>
+
+ <function name="Binormal3fvEXT" offset="?">
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="Binormal3iEXT" offset="?">
+ <param name="bx" type="GLint"/>
+ <param name="by" type="GLint"/>
+ <param name="bz" type="GLint"/>
+ </function>
+
+ <function name="Binormal3ivEXT" offset="?">
+ <param name="v" type="const GLint *"/>
+ </function>
+
+ <function name="Binormal3sEXT" offset="?">
+ <param name="bx" type="GLshort"/>
+ <param name="by" type="GLshort"/>
+ <param name="bz" type="GLshort"/>
+ </function>
+
+ <function name="Binormal3svEXT" offset="?">
+ <param name="v" type="const GLshort *"/>
+ </function>
+
+ <function name="TangentPointerEXT" offset="?">
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ </function>
+
+ <function name="BinormalPointerEXT" offset="?">
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ </function>
+</category>
+
+<!-- Extension number 157 is not listed in the extension registry. -->
+
+<category name="GL_EXT_texture_env_combine" number="158">
+ <enum name="COMBINE_EXT" value="0x8570"/>
+ <enum name="COMBINE_RGB_EXT" count="1" value="0x8571"/>
+ <enum name="COMBINE_ALPHA_EXT" count="1" value="0x8572"/>
+ <enum name="RGB_SCALE_EXT" count="1" value="0x8573"/>
+ <enum name="ADD_SIGNED_EXT" value="0x8574"/>
+ <enum name="INTERPOLATE_EXT" value="0x8575"/>
+ <enum name="CONSTANT_EXT" value="0x8576"/>
+ <enum name="PRIMARY_COLOR_EXT" value="0x8577"/>
+ <enum name="PREVIOUS_EXT" value="0x8578"/>
+ <enum name="SOURCE0_RGB_EXT" count="1" value="0x8580"/>
+ <enum name="SOURCE1_RGB_EXT" count="1" value="0x8581"/>
+ <enum name="SOURCE2_RGB_EXT" count="1" value="0x8582"/>
+ <enum name="SOURCE0_ALPHA_EXT" count="1" value="0x8588"/>
+ <enum name="SOURCE1_ALPHA_EXT" count="1" value="0x8589"/>
+ <enum name="SOURCE2_ALPHA_EXT" count="1" value="0x858A"/>
+ <enum name="OPERAND0_RGB_EXT" count="1" value="0x8590"/>
+ <enum name="OPERAND1_RGB_EXT" count="1" value="0x8591"/>
+ <enum name="OPERAND2_RGB_EXT" count="1" value="0x8592"/>
+ <enum name="OPERAND0_ALPHA_EXT" count="1" value="0x8598"/>
+ <enum name="OPERAND1_ALPHA_EXT" count="1" value="0x8599"/>
+ <enum name="OPERAND2_ALPHA_EXT" count="1" value="0x859A"/>
+</category>
+
+<category name="GL_SGIX_pixel_texture" number="160">
+ <function name="PixelTexGenSGIX" offset="430">
+ <param name="mode" type="GLenum"/>
+ <glx rop="2059" ignore="true"/>
+ </function>
+</category>
+
+<!-- Extension number 161 is not listed in the extension registry. -->
+<!-- Extension number 162 is not listed in the extension registry. -->
+
+<category name="GL_SUNX_constant_data" number="163">
+ <function name="FinishTextureSUNX" offset="?">
+ </function>
+</category>
+
+<category name="GL_SUN_global_alpha" number="164">
+ <function name="GlobalAlphaFactorbSUN" offset="?">
+ <param name="factor" type="GLbyte"/>
+ </function>
+
+ <function name="GlobalAlphaFactorsSUN" offset="?">
+ <param name="factor" type="GLshort"/>
+ </function>
+
+ <function name="GlobalAlphaFactoriSUN" offset="?">
+ <param name="factor" type="GLint"/>
+ </function>
+
+ <function name="GlobalAlphaFactorfSUN" offset="?">
+ <param name="factor" type="GLfloat"/>
+ </function>
+
+ <function name="GlobalAlphaFactordSUN" offset="?">
+ <param name="factor" type="GLdouble"/>
+ </function>
+
+ <function name="GlobalAlphaFactorubSUN" offset="?">
+ <param name="factor" type="GLubyte"/>
+ </function>
+
+ <function name="GlobalAlphaFactorusSUN" offset="?">
+ <param name="factor" type="GLushort"/>
+ </function>
+
+ <function name="GlobalAlphaFactoruiSUN" offset="?">
+ <param name="factor" type="GLuint"/>
+ </function>
+</category>
+
+<category name="GL_SUN_triangle_list" number="165">
+ <function name="ReplacementCodeuiSUN" offset="?">
+ <param name="code" type="GLuint"/>
+ </function>
+
+ <function name="ReplacementCodeusSUN" offset="?">
+ <param name="code" type="GLushort"/>
+ </function>
+
+ <function name="ReplacementCodeubSUN" offset="?">
+ <param name="code" type="GLubyte"/>
+ </function>
+
+ <function name="ReplacementCodeuivSUN" offset="?">
+ <param name="code" type="const GLuint *"/>
+ </function>
+
+ <function name="ReplacementCodeusvSUN" offset="?">
+ <param name="code" type="const GLushort *"/>
+ </function>
+
+ <function name="ReplacementCodeubvSUN" offset="?">
+ <param name="code" type="const GLubyte *"/>
+ </function>
+
+ <function name="ReplacementCodePointerSUN" offset="?">
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ </function>
+</category>
+
+<category name="GL_SUN_vertex" number="166">
+ <function name="Color4ubVertex2fSUN" offset="?">
+ <param name="r" type="GLubyte"/>
+ <param name="g" type="GLubyte"/>
+ <param name="b" type="GLubyte"/>
+ <param name="a" type="GLubyte"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ </function>
+
+ <function name="Color4ubVertex2fvSUN" offset="?">
+ <param name="c" type="const GLubyte *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="Color4ubVertex3fSUN" offset="?">
+ <param name="r" type="GLubyte"/>
+ <param name="g" type="GLubyte"/>
+ <param name="b" type="GLubyte"/>
+ <param name="a" type="GLubyte"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="Color4ubVertex3fvSUN" offset="?">
+ <param name="c" type="const GLubyte *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="Color3fVertex3fSUN" offset="?">
+ <param name="r" type="GLfloat"/>
+ <param name="g" type="GLfloat"/>
+ <param name="b" type="GLfloat"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="Color3fVertex3fvSUN" offset="?">
+ <param name="c" type="const GLfloat *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="Normal3fVertex3fSUN" offset="?">
+ <param name="nx" type="GLfloat"/>
+ <param name="ny" type="GLfloat"/>
+ <param name="nz" type="GLfloat"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="Normal3fVertex3fvSUN" offset="?">
+ <param name="n" type="const GLfloat *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="Color4fNormal3fVertex3fSUN" offset="?">
+ <param name="r" type="GLfloat"/>
+ <param name="g" type="GLfloat"/>
+ <param name="b" type="GLfloat"/>
+ <param name="a" type="GLfloat"/>
+ <param name="nx" type="GLfloat"/>
+ <param name="ny" type="GLfloat"/>
+ <param name="nz" type="GLfloat"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="Color4fNormal3fVertex3fvSUN" offset="?">
+ <param name="c" type="const GLfloat *"/>
+ <param name="n" type="const GLfloat *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="TexCoord2fVertex3fSUN" offset="?">
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="TexCoord2fVertex3fvSUN" offset="?">
+ <param name="tc" type="const GLfloat *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="TexCoord4fVertex4fSUN" offset="?">
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ <param name="p" type="GLfloat"/>
+ <param name="q" type="GLfloat"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ <param name="w" type="GLfloat"/>
+ </function>
+
+ <function name="TexCoord4fVertex4fvSUN" offset="?">
+ <param name="tc" type="const GLfloat *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="TexCoord2fColor4ubVertex3fSUN" offset="?">
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ <param name="r" type="GLubyte"/>
+ <param name="g" type="GLubyte"/>
+ <param name="b" type="GLubyte"/>
+ <param name="a" type="GLubyte"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="TexCoord2fColor4ubVertex3fvSUN" offset="?">
+ <param name="tc" type="const GLfloat *"/>
+ <param name="c" type="const GLubyte *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="TexCoord2fColor3fVertex3fSUN" offset="?">
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ <param name="r" type="GLfloat"/>
+ <param name="g" type="GLfloat"/>
+ <param name="b" type="GLfloat"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="TexCoord2fColor3fVertex3fvSUN" offset="?">
+ <param name="tc" type="const GLfloat *"/>
+ <param name="c" type="const GLfloat *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="TexCoord2fNormal3fVertex3fSUN" offset="?">
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ <param name="nx" type="GLfloat"/>
+ <param name="ny" type="GLfloat"/>
+ <param name="nz" type="GLfloat"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="TexCoord2fNormal3fVertex3fvSUN" offset="?">
+ <param name="tc" type="const GLfloat *"/>
+ <param name="n" type="const GLfloat *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="TexCoord2fColor4fNormal3fVertex3fSUN" offset="?">
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ <param name="r" type="GLfloat"/>
+ <param name="g" type="GLfloat"/>
+ <param name="b" type="GLfloat"/>
+ <param name="a" type="GLfloat"/>
+ <param name="nx" type="GLfloat"/>
+ <param name="ny" type="GLfloat"/>
+ <param name="nz" type="GLfloat"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="TexCoord2fColor4fNormal3fVertex3fvSUN" offset="?">
+ <param name="tc" type="const GLfloat *"/>
+ <param name="c" type="const GLfloat *"/>
+ <param name="n" type="const GLfloat *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="TexCoord4fColor4fNormal3fVertex4fSUN" offset="?">
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ <param name="p" type="GLfloat"/>
+ <param name="q" type="GLfloat"/>
+ <param name="r" type="GLfloat"/>
+ <param name="g" type="GLfloat"/>
+ <param name="b" type="GLfloat"/>
+ <param name="a" type="GLfloat"/>
+ <param name="nx" type="GLfloat"/>
+ <param name="ny" type="GLfloat"/>
+ <param name="nz" type="GLfloat"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ <param name="w" type="GLfloat"/>
+ </function>
+
+ <function name="TexCoord4fColor4fNormal3fVertex4fvSUN" offset="?">
+ <param name="tc" type="const GLfloat *"/>
+ <param name="c" type="const GLfloat *"/>
+ <param name="n" type="const GLfloat *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="ReplacementCodeuiVertex3fSUN" offset="?">
+ <param name="rc" type="GLuint"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="ReplacementCodeuiVertex3fvSUN" offset="?">
+ <param name="rc" type="const GLuint *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="ReplacementCodeuiColor4ubVertex3fSUN" offset="?">
+ <param name="rc" type="GLuint"/>
+ <param name="r" type="GLubyte"/>
+ <param name="g" type="GLubyte"/>
+ <param name="b" type="GLubyte"/>
+ <param name="a" type="GLubyte"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="ReplacementCodeuiColor4ubVertex3fvSUN" offset="?">
+ <param name="rc" type="const GLuint *"/>
+ <param name="c" type="const GLubyte *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="ReplacementCodeuiColor3fVertex3fSUN" offset="?">
+ <param name="rc" type="GLuint"/>
+ <param name="r" type="GLfloat"/>
+ <param name="g" type="GLfloat"/>
+ <param name="b" type="GLfloat"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="ReplacementCodeuiColor3fVertex3fvSUN" offset="?">
+ <param name="rc" type="const GLuint *"/>
+ <param name="c" type="const GLfloat *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="ReplacementCodeuiNormal3fVertex3fSUN" offset="?">
+ <param name="rc" type="GLuint"/>
+ <param name="nx" type="GLfloat"/>
+ <param name="ny" type="GLfloat"/>
+ <param name="nz" type="GLfloat"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="ReplacementCodeuiNormal3fVertex3fvSUN" offset="?">
+ <param name="rc" type="const GLuint *"/>
+ <param name="n" type="const GLfloat *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="ReplacementCodeuiColor4fNormal3fVertex3fSUN" offset="?">
+ <param name="rc" type="GLuint"/>
+ <param name="r" type="GLfloat"/>
+ <param name="g" type="GLfloat"/>
+ <param name="b" type="GLfloat"/>
+ <param name="a" type="GLfloat"/>
+ <param name="nx" type="GLfloat"/>
+ <param name="ny" type="GLfloat"/>
+ <param name="nz" type="GLfloat"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="ReplacementCodeuiColor4fNormal3fVertex3fvSUN" offset="?">
+ <param name="rc" type="const GLuint *"/>
+ <param name="c" type="const GLfloat *"/>
+ <param name="n" type="const GLfloat *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="ReplacementCodeuiTexCoord2fVertex3fSUN" offset="?">
+ <param name="rc" type="GLuint"/>
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="ReplacementCodeuiTexCoord2fVertex3fvSUN" offset="?">
+ <param name="rc" type="const GLuint *"/>
+ <param name="tc" type="const GLfloat *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN" offset="?">
+ <param name="rc" type="GLuint"/>
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ <param name="nx" type="GLfloat"/>
+ <param name="ny" type="GLfloat"/>
+ <param name="nz" type="GLfloat"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN" offset="?">
+ <param name="rc" type="const GLuint *"/>
+ <param name="tc" type="const GLfloat *"/>
+ <param name="n" type="const GLfloat *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+
+ <function name="ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN" offset="?">
+ <param name="rc" type="GLuint"/>
+ <param name="s" type="GLfloat"/>
+ <param name="t" type="GLfloat"/>
+ <param name="r" type="GLfloat"/>
+ <param name="g" type="GLfloat"/>
+ <param name="b" type="GLfloat"/>
+ <param name="a" type="GLfloat"/>
+ <param name="nx" type="GLfloat"/>
+ <param name="ny" type="GLfloat"/>
+ <param name="nz" type="GLfloat"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN" offset="?">
+ <param name="rc" type="const GLuint *"/>
+ <param name="tc" type="const GLfloat *"/>
+ <param name="c" type="const GLfloat *"/>
+ <param name="n" type="const GLfloat *"/>
+ <param name="v" type="const GLfloat *"/>
+ </function>
+</category>
+
+<!-- Extension number 167 is a WGL extension. -->
+<!-- Extension number 168 is a WGL extension. -->
+<!-- Extension number 169 is a WGL extension. -->
+<!-- Extension number 170 is a WGL extension. -->
+<!-- Extension number 171 is a WGL extension. -->
+<!-- Extension number 172 is a WGL extension. -->
+
+<category name="GL_EXT_blend_func_separate" number="173">
+ <function name="BlendFuncSeparateEXT" offset="537">
+ <param name="sfactorRGB" type="GLenum"/>
+ <param name="dfactorRGB" type="GLenum"/>
+ <param name="sfactorAlpha" type="GLenum"/>
+ <param name="dfactorAlpha" type="GLenum"/>
+ <glx rop="4134"/>
+ </function>
+</category>
+
+<category name="GL_EXT_stencil_wrap" number="176">
+ <enum name="INCR_WRAP_EXT" value="0x8507"/>
+ <enum name="DECR_WRAP_EXT" value="0x8508"/>
+</category>
+
+<!-- Extension number 177 is a WGL extension. -->
+
+<category name="GL_NV_texgen_reflection" number="179">
+ <enum name="NORMAL_MAP_NV" value="0x8511"/>
+ <enum name="REFLECTION_MAP_NV" value="0x8512"/>
+</category>
+
+<!-- Extension number 180 is not listed in the extension registry. -->
+
+<category name="GL_SUN_convolution_border_modes" number="182">
+ <enum name="WRAP_BORDER_SUN" value="0x81D4"/>
+</category>
+
+<!-- Extension number 183 is a GLX extension. -->
+<!-- Extension number 184 is not listed in the extension registry. -->
+
+<category name="GL_EXT_texture_env_add" number="185">
+ <!-- No new functions, types, enums. -->
+</category>
+
+<category name="GL_EXT_texture_lod_bias" number="186">
+ <enum name="TEXTURE_LOD_BIAS_EXT" count="1" value="0x8501">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+</category>
+
+<category name="GL_EXT_texture_filter_anisotropic" number="187">
+ <enum name="TEXTURE_MAX_ANISOTROPY_EXT" count="1" value="0x84FE">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="MAX_TEXTURE_MAX_ANISOTROPY_EXT" value="0x84FF"/>
+</category>
+
+<category name="GL_EXT_vertex_weighting" number="188">
+ <function name="VertexWeightfEXT" offset="494" vectorequiv="VertexWeightfvEXT">
+ <param name="weight" type="GLfloat"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="VertexWeightfvEXT" offset="495">
+ <param name="weight" type="const GLfloat *" count="1"/>
+ <glx rop="4135" ignore="true"/>
+ </function>
+
+ <function name="VertexWeightPointerEXT" offset="496">
+ <param name="size" type="GLsizei"/>
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true" ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_NV_light_max_exponent" number="189">
+ <enum name="MAX_SHININESS_NV" count="1" value="0x8504">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="MAX_SPOT_EXPONENT_NV" count="1" value="0x8505">
+ <size name="Get" mode="get"/>
+ </enum>
+</category>
+
+<category name="GL_NV_vertex_array_range" number="190">
+ <function name="FlushVertexArrayRangeNV" offset="497">
+ <glx ignore="true"/>
+ </function>
+
+ <function name="VertexArrayRangeNV" offset="498">
+ <param name="length" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_NV_register_combiners" number="191">
+ <function name="CombinerParameterfvNV" offset="499">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *" variable_param="pname"/>
+ <glx rop="4137" ignore="true"/>
+ </function>
+
+ <function name="CombinerParameterfNV" offset="500">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ <glx rop="4136" ignore="true"/>
+ </function>
+
+ <function name="CombinerParameterivNV" offset="501">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *" variable_param="pname"/>
+ <glx rop="4139" ignore="true"/>
+ </function>
+
+ <function name="CombinerParameteriNV" offset="502">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx rop="4138" ignore="true"/>
+ </function>
+
+ <function name="CombinerInputNV" offset="503">
+ <param name="stage" type="GLenum"/>
+ <param name="portion" type="GLenum"/>
+ <param name="variable" type="GLenum"/>
+ <param name="input" type="GLenum"/>
+ <param name="mapping" type="GLenum"/>
+ <param name="componentUsage" type="GLenum"/>
+ <glx rop="4140" ignore="true"/>
+ </function>
+
+ <function name="CombinerOutputNV" offset="504">
+ <param name="stage" type="GLenum"/>
+ <param name="portion" type="GLenum"/>
+ <param name="abOutput" type="GLenum"/>
+ <param name="cdOutput" type="GLenum"/>
+ <param name="sumOutput" type="GLenum"/>
+ <param name="scale" type="GLenum"/>
+ <param name="bias" type="GLenum"/>
+ <param name="abDotProduct" type="GLboolean"/>
+ <param name="cdDotProduct" type="GLboolean"/>
+ <param name="muxSum" type="GLboolean"/>
+ <glx rop="4141" ignore="true"/>
+ </function>
+
+ <function name="FinalCombinerInputNV" offset="505">
+ <param name="variable" type="GLenum"/>
+ <param name="input" type="GLenum"/>
+ <param name="mapping" type="GLenum"/>
+ <param name="componentUsage" type="GLenum"/>
+ <glx rop="4142" ignore="true"/>
+ </function>
+
+ <function name="GetCombinerInputParameterfvNV" offset="506">
+ <param name="stage" type="GLenum"/>
+ <param name="portion" type="GLenum"/>
+ <param name="variable" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true"/>
+ <glx vendorpriv="1270" ignore="true"/>
+ </function>
+
+ <function name="GetCombinerInputParameterivNV" offset="507">
+ <param name="stage" type="GLenum"/>
+ <param name="portion" type="GLenum"/>
+ <param name="variable" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true"/>
+ <glx vendorpriv="1271" ignore="true"/>
+ </function>
+
+ <function name="GetCombinerOutputParameterfvNV" offset="508">
+ <param name="stage" type="GLenum"/>
+ <param name="portion" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true"/>
+ <glx vendorpriv="1272" ignore="true"/>
+ </function>
+
+ <function name="GetCombinerOutputParameterivNV" offset="509">
+ <param name="stage" type="GLenum"/>
+ <param name="portion" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true"/>
+ <glx vendorpriv="1273" ignore="true"/>
+ </function>
+
+ <function name="GetFinalCombinerInputParameterfvNV" offset="510">
+ <param name="variable" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true"/>
+ <glx vendorpriv="1274" ignore="true"/>
+ </function>
+
+ <function name="GetFinalCombinerInputParameterivNV" offset="511">
+ <param name="variable" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true"/>
+ <glx vendorpriv="1275" ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_NV_fog_distance" number="192">
+ <enum name="FOG_DISTANCE_MODE_NV" count="1" value="0x855A">
+ <size name="Fogfv"/>
+ <size name="Fogiv"/>
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="EYE_RADIAL_NV" value="0x855B"/>
+ <enum name="EYE_PLANE_ABSOLUTE_NV" value="0x855C"/>
+</category>
+
+<category name="GL_NV_blend_square" number="194">
+ <!-- No new functions, types, enums. -->
+</category>
+
+<category name="GL_NV_texture_env_combine4" number="195">
+ <enum name="COMBINE4" value="0x8503"/>
+ <enum name="SOURCE3_RGB_NV" count="1" value="0x8583">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="SOURCE3_ALPHA_NV" count="1" value="0x858B">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="OPERAND3_RGB_NV" count="1" value="0x8593">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="OPERAND3_ALPHA_NV" count="1" value="0x859B">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+</category>
+
+<category name="GL_MESA_resize_buffers" number="196">
+ <function name="ResizeBuffersMESA" offset="512">
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_MESA_window_pos" number="197">
+ <function name="WindowPos2dMESA" offset="513">
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="WindowPos2dvMESA" offset="514">
+ <param name="v" type="const GLdouble *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="WindowPos2fMESA" offset="515">
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="WindowPos2fvMESA" offset="516">
+ <param name="v" type="const GLfloat *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="WindowPos2iMESA" offset="517">
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="WindowPos2ivMESA" offset="518">
+ <param name="v" type="const GLint *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="WindowPos2sMESA" offset="519">
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="WindowPos2svMESA" offset="520">
+ <param name="v" type="const GLshort *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="WindowPos3dMESA" offset="521">
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="WindowPos3dvMESA" offset="522">
+ <param name="v" type="const GLdouble *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="WindowPos3fMESA" offset="523" vectorequiv="WindowPos3fvMESA">
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="WindowPos3fvMESA" offset="524">
+ <param name="v" type="const GLfloat *" count="3"/>
+ <glx rop="230"/>
+ </function>
+
+ <function name="WindowPos3iMESA" offset="525">
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="z" type="GLint"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="WindowPos3ivMESA" offset="526">
+ <param name="v" type="const GLint *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="WindowPos3sMESA" offset="527">
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ <param name="z" type="GLshort"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="WindowPos3svMESA" offset="528">
+ <param name="v" type="const GLshort *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="WindowPos4dMESA" offset="529">
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ <param name="w" type="GLdouble"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="WindowPos4dvMESA" offset="530">
+ <param name="v" type="const GLdouble *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="WindowPos4fMESA" offset="531">
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ <param name="w" type="GLfloat"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="WindowPos4fvMESA" offset="532">
+ <param name="v" type="const GLfloat *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="WindowPos4iMESA" offset="533">
+ <param name="x" type="GLint"/>
+ <param name="y" type="GLint"/>
+ <param name="z" type="GLint"/>
+ <param name="w" type="GLint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="WindowPos4ivMESA" offset="534">
+ <param name="v" type="const GLint *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="WindowPos4sMESA" offset="535">
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ <param name="z" type="GLshort"/>
+ <param name="w" type="GLshort"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="WindowPos4svMESA" offset="536">
+ <param name="v" type="const GLshort *"/>
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_EXT_texture_compression_s3tc" number="198">
+ <enum name="COMPRESSED_RGB_S3TC_DXT1_EXT" value="0x83F0"/>
+ <enum name="COMPRESSED_RGBA_S3TC_DXT1_EXT" value="0x83F1"/>
+ <enum name="COMPRESSED_RGBA_S3TC_DXT3_EXT" value="0x83F2"/>
+ <enum name="COMPRESSED_RGBA_S3TC_DXT5_EXT" value="0x83F3"/>
+</category>
+
+<category name="GL_IBM_multimode_draw_arrays" number="200">
+ <function name="MultiModeDrawArraysIBM" offset="708">
+ <param name="mode" type="const GLenum *"/>
+ <param name="first" type="const GLint *"/>
+ <param name="count" type="const GLsizei *"/>
+ <param name="primcount" type="GLsizei"/>
+ <param name="modestride" type="GLint"/>
+ <glx handcode="true" ignore="true"/>
+ </function>
+
+ <function name="MultiModeDrawElementsIBM" offset="709">
+ <param name="mode" type="const GLenum *"/>
+ <param name="count" type="const GLsizei *"/>
+ <param name="type" type="GLenum"/>
+ <param name="indices" type="const GLvoid * const *"/>
+ <param name="primcount" type="GLsizei"/>
+ <param name="modestride" type="GLint"/>
+ <glx handcode="true" ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_IBM_vertex_array_lists" number="201">
+ <function name="ColorPointerListIBM" offset="?">
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLint"/>
+ <param name="pointer" type="const GLvoid **"/>
+ <param name="ptrstride" type="GLint"/>
+ </function>
+
+ <function name="SecondaryColorPointerListIBM" offset="?">
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLint"/>
+ <param name="pointer" type="const GLvoid **"/>
+ <param name="ptrstride" type="GLint"/>
+ </function>
+
+ <function name="EdgeFlagPointerListIBM" offset="?">
+ <param name="stride" type="GLint"/>
+ <param name="pointer" type="const GLboolean **"/>
+ <param name="ptrstride" type="GLint"/>
+ </function>
+
+ <function name="FogCoordPointerListIBM" offset="?">
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLint"/>
+ <param name="pointer" type="const GLvoid **"/>
+ <param name="ptrstride" type="GLint"/>
+ </function>
+
+ <function name="IndexPointerListIBM" offset="?">
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLint"/>
+ <param name="pointer" type="const GLvoid **"/>
+ <param name="ptrstride" type="GLint"/>
+ </function>
+
+ <function name="NormalPointerListIBM" offset="?">
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLint"/>
+ <param name="pointer" type="const GLvoid **"/>
+ <param name="ptrstride" type="GLint"/>
+ </function>
+
+ <function name="TexCoordPointerListIBM" offset="?">
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLint"/>
+ <param name="pointer" type="const GLvoid **"/>
+ <param name="ptrstride" type="GLint"/>
+ </function>
+
+ <function name="VertexPointerListIBM" offset="?">
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLint"/>
+ <param name="pointer" type="const GLvoid **"/>
+ <param name="ptrstride" type="GLint"/>
+ </function>
+</category>
+
+<!-- Extension number 202 is not listed in the extension registry. -->
+<!-- Extension number 203 is not listed in the extension registry. -->
+<!-- Extension number 204 is not listed in the extension registry. -->
+<!-- Extension number 205 is not listed in the extension registry. -->
+
+<category name="GL_3DFX_texture_compression_FXT1" number="206">
+ <enum name="COMPRESSED_RGB_FXT1_3DFX" value="0x86B0"/>
+ <enum name="COMPRESSED_RGBA_FXT1_3DFX" value="0x86B1"/>
+</category>
+
+<category name="GL_3DFX_multisample" number="207">
+ <enum name="MULTISAMPLE_3DFX" value="0x86B2"/>
+ <enum name="SAMPLE_BUFFERS_3DFX" value="0x86B3"/>
+ <enum name="SAMPLES_3DFX" value="0x86B4"/>
+ <enum name="MULTISAMPLE_BIT_3DFX" value="0x20000000"/>
+</category>
+
+<category name="GL_3DFX_tbuffer" number="208">
+ <function name="TbufferMask3DFX" offset="553">
+ <param name="mask" type="GLuint"/>
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_EXT_multisample" number="209">
+ <function name="SampleMaskEXT" alias="SampleMaskSGIS">
+ <param name="value" type="GLclampf"/>
+ <param name="invert" type="GLboolean"/>
+ </function>
+
+ <function name="SamplePatternEXT" alias="SamplePatternSGIS">
+ <param name="pattern" type="GLenum"/>
+ </function>
+</category>
+
+<!-- Extension number 211 is not listed in the extension registry. -->
+<!-- Extension number 213 is not listed in the extension registry. -->
+
+<category name="GL_SGIS_texture_color_mask" number="214">
+ <enum name="TEXTURE_COLOR_WRITEMASK_SGIS" value="0x81EF"/>
+
+ <function name="TextureColorMaskSGIS" offset="?">
+ <param name="red" type="GLboolean"/>
+ <param name="green" type="GLboolean"/>
+ <param name="blue" type="GLboolean"/>
+ <param name="alpha" type="GLboolean"/>
+ <glx rop="2082" ignore="true"/>
+ </function>
+</category>
+
+<!-- Extension number 215 is a GLX extension. -->
+<!-- Extension number 216 is a GLX extension. -->
+<!-- Extension number 217 is a GLX extension. -->
+<!-- Extension number 218 is a GLX extension. -->
+<!-- Extension number 219 is not listed in the extension registry. -->
+
+<category name="GL_EXT_texture_env_dot3" number="220">
+ <enum name="DOT3_RGB_EXT" value="0x8740"/>
+ <enum name="DOT3_RGBA_EXT" value="0x8741"/>
+</category>
+
+<category name="GL_ATI_texture_mirror_once" number="221">
+ <enum name="MIRROR_CLAMP_ATI" value="0x8742"/>
+ <enum name="MIRROR_CLAMP_TO_EDGE_ATI" value="0x8743"/>
+</category>
+
+<category name="GL_NV_fence" number="222">
+ <function name="DeleteFencesNV" offset="647">
+ <param name="n" type="GLsizei"/>
+ <param name="fences" type="const GLuint *"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GenFencesNV" offset="648">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="fences" type="GLuint *" output="true" count="n"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="IsFenceNV" offset="649">
+ <param name="fence" type="GLuint"/>
+ <return type="GLboolean"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="TestFenceNV" offset="650">
+ <param name="fence" type="GLuint"/>
+ <return type="GLboolean"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="GetFenceivNV" offset="651">
+ <param name="fence" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="FinishFenceNV" offset="652">
+ <param name="fence" type="GLuint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="SetFenceNV" offset="653">
+ <param name="fence" type="GLuint"/>
+ <param name="condition" type="GLenum"/>
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_IBM_texture_mirrored_repeat" number="224">
+ <enum name="MIRRORED_REPEAT_IBM" value="0x8370"/>
+</category>
+
+<category name="GL_NV_evaluators" number="225">
+ <function name="MapControlPointsNV" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="type" type="GLenum"/>
+ <param name="ustride" type="GLsizei"/>
+ <param name="vstride" type="GLsizei"/>
+ <param name="uorder" type="GLint"/>
+ <param name="vorder" type="GLint"/>
+ <param name="packed" type="GLboolean"/>
+ <param name="points" type="const GLvoid *"/>
+ </function>
+
+ <function name="MapParameterivNV" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *"/>
+ </function>
+
+ <function name="MapParameterfvNV" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *"/>
+ </function>
+
+ <function name="GetMapControlPointsNV" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="type" type="GLenum"/>
+ <param name="ustride" type="GLsizei"/>
+ <param name="vstride" type="GLsizei"/>
+ <param name="packed" type="GLboolean"/>
+ <param name="points" type="GLvoid *" output="true"/>
+ </function>
+
+ <function name="GetMapParameterivNV" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true"/>
+ </function>
+
+ <function name="GetMapParameterfvNV" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true"/>
+ </function>
+
+ <function name="GetMapAttribParameterivNV" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true"/>
+ </function>
+
+ <function name="GetMapAttribParameterfvNV" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true"/>
+ </function>
+
+ <function name="EvalMapsNV" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="mode" type="GLenum"/>
+ </function>
+</category>
+
+<category name="GL_NV_packed_depth_stencil" number="226">
+ <enum name="DEPTH_STENCIL_NV" value="0x84F9"/>
+ <enum name="UNSIGNED_INT_24_8_NV" value="0x84FA"/>
+</category>
+
+<category name="GL_NV_register_combiners2" number="227">
+ <function name="CombinerStageParameterfvNV" offset="?">
+ <param name="stage" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *"/>
+ </function>
+
+ <function name="GetCombinerStageParameterfvNV" offset="?">
+ <param name="stage" type="GLenum"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true"/>
+ </function>
+</category>
+
+<category name="GL_NV_texture_compression_vtc" number="228">
+ <enum name="COMPRESSED_RGB_S3TC_DXT1_EXT" value="0x83F0"/>
+ <enum name="COMPRESSED_RGBA_S3TC_DXT1_EXT" value="0x83F1"/>
+ <enum name="COMPRESSED_RGBA_S3TC_DXT3_EXT" value="0x83F2"/>
+ <enum name="COMPRESSED_RGBA_S3TC_DXT5_EXT" value="0x83F3"/>
+</category>
+
+<category name="GL_NV_texture_rectangle" number="229">
+ <enum name="TEXTURE_RECTANGLE_NV" count="1" value="0x84F5">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_BINDING_RECTANGLE_NV" count="1" value="0x84F6">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="PROXY_TEXTURE_RECTANGLE_NV" value="0x84F7"/>
+ <enum name="MAX_RECTANGLE_TEXTURE_SIZE_NV" count="1" value="0x84F8">
+ <size name="Get" mode="get"/>
+ </enum>
+</category>
+
+<category name="GL_NV_vertex_program" number="233">
+ <enum name="VERTEX_PROGRAM_NV" value="0x8620"/>
+ <enum name="VERTEX_STATE_PROGRAM_NV" value="0x8621"/>
+ <enum name="ATTRIB_ARRAY_SIZE_NV" count="1" value="0x8623">
+ <size name="GetVertexAttribdvNV" mode="get"/>
+ <size name="GetVertexAttribfvNV" mode="get"/>
+ <size name="GetVertexAttribivNV" mode="get"/>
+ </enum>
+ <enum name="ATTRIB_ARRAY_STRIDE_NV" count="1" value="0x8624">
+ <size name="GetVertexAttribdvNV" mode="get"/>
+ <size name="GetVertexAttribfvNV" mode="get"/>
+ <size name="GetVertexAttribivNV" mode="get"/>
+ </enum>
+ <enum name="ATTRIB_ARRAY_TYPE_NV" count="1" value="0x8625">
+ <size name="GetVertexAttribdvNV" mode="get"/>
+ <size name="GetVertexAttribfvNV" mode="get"/>
+ <size name="GetVertexAttribivNV" mode="get"/>
+ </enum>
+ <enum name="CURRENT_ATTRIB_NV" count="1" value="0x8626">
+ <size name="GetVertexAttribdvNV" mode="get"/>
+ <size name="GetVertexAttribfvNV" mode="get"/>
+ <size name="GetVertexAttribivNV" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_LENGTH_NV" count="1" value="0x8627">
+ <size name="GetProgramivNV" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_STRING_NV" value="0x8628"/>
+ <enum name="MODELVIEW_PROJECTION_NV" value="0x8629"/>
+ <enum name="IDENTITY_NV" value="0x862A"/>
+ <enum name="INVERSE_NV" value="0x862B"/>
+ <enum name="TRANSPOSE_NV" value="0x862C"/>
+ <enum name="INVERSE_TRANSPOSE_NV" value="0x862D"/>
+ <enum name="MAX_TRACK_MATRIX_STACK_DEPTH_NV" value="0x862E"/>
+ <enum name="MAX_TRACK_MATRICES_NV" value="0x862F"/>
+ <enum name="MATRIX0_NV" value="0x8630"/>
+ <enum name="MATRIX1_NV" value="0x8631"/>
+ <enum name="MATRIX2_NV" value="0x8632"/>
+ <enum name="MATRIX3_NV" value="0x8633"/>
+ <enum name="MATRIX4_NV" value="0x8634"/>
+ <enum name="MATRIX5_NV" value="0x8635"/>
+ <enum name="MATRIX6_NV" value="0x8636"/>
+ <enum name="MATRIX7_NV" value="0x8637"/>
+ <enum name="CURRENT_MATRIX_STACK_DEPTH_NV" value="0x8640"/>
+ <enum name="CURRENT_MATRIX_NV" value="0x8641"/>
+ <enum name="VERTEX_PROGRAM_POINT_SIZE_NV" value="0x8642"/>
+ <enum name="VERTEX_PROGRAM_TWO_SIDE_NV" value="0x8643"/>
+ <enum name="PROGRAM_PARAMETER_NV" value="0x8644"/>
+ <enum name="ATTRIB_ARRAY_POINTER_NV" value="0x8645"/>
+ <enum name="PROGRAM_TARGET_NV" count="1" value="0x8646">
+ <size name="GetProgramivNV" mode="get"/>
+ </enum>
+ <enum name="PROGRAM_RESIDENT_NV" count="1" value="0x8647">
+ <size name="GetProgramivNV" mode="get"/>
+ </enum>
+ <enum name="TRACK_MATRIX_NV" value="0x8648"/>
+ <enum name="TRACK_MATRIX_TRANSFORM_NV" value="0x8649"/>
+ <enum name="VERTEX_PROGRAM_BINDING_NV" value="0x864A"/>
+ <enum name="PROGRAM_ERROR_POSITION_NV" value="0x864B"/>
+ <enum name="VERTEX_ATTRIB_ARRAY0_NV" value="0x8650"/>
+ <enum name="VERTEX_ATTRIB_ARRAY1_NV" value="0x8651"/>
+ <enum name="VERTEX_ATTRIB_ARRAY2_NV" value="0x8652"/>
+ <enum name="VERTEX_ATTRIB_ARRAY3_NV" value="0x8653"/>
+ <enum name="VERTEX_ATTRIB_ARRAY4_NV" value="0x8654"/>
+ <enum name="VERTEX_ATTRIB_ARRAY5_NV" value="0x8655"/>
+ <enum name="VERTEX_ATTRIB_ARRAY6_NV" value="0x8656"/>
+ <enum name="VERTEX_ATTRIB_ARRAY7_NV" value="0x8657"/>
+ <enum name="VERTEX_ATTRIB_ARRAY8_NV" value="0x8658"/>
+ <enum name="VERTEX_ATTRIB_ARRAY9_NV" value="0x8659"/>
+ <enum name="VERTEX_ATTRIB_ARRAY10_NV" value="0x865A"/>
+ <enum name="VERTEX_ATTRIB_ARRAY11_NV" value="0x865B"/>
+ <enum name="VERTEX_ATTRIB_ARRAY12_NV" value="0x865C"/>
+ <enum name="VERTEX_ATTRIB_ARRAY13_NV" value="0x865D"/>
+ <enum name="VERTEX_ATTRIB_ARRAY14_NV" value="0x865E"/>
+ <enum name="VERTEX_ATTRIB_ARRAY15_NV" value="0x865F"/>
+ <enum name="MAP1_VERTEX_ATTRIB0_4_NV" value="0x8660"/>
+ <enum name="MAP1_VERTEX_ATTRIB1_4_NV" value="0x8661"/>
+ <enum name="MAP1_VERTEX_ATTRIB2_4_NV" value="0x8662"/>
+ <enum name="MAP1_VERTEX_ATTRIB3_4_NV" value="0x8663"/>
+ <enum name="MAP1_VERTEX_ATTRIB4_4_NV" value="0x8664"/>
+ <enum name="MAP1_VERTEX_ATTRIB5_4_NV" value="0x8665"/>
+ <enum name="MAP1_VERTEX_ATTRIB6_4_NV" value="0x8666"/>
+ <enum name="MAP1_VERTEX_ATTRIB7_4_NV" value="0x8667"/>
+ <enum name="MAP1_VERTEX_ATTRIB8_4_NV" value="0x8668"/>
+ <enum name="MAP1_VERTEX_ATTRIB9_4_NV" value="0x8669"/>
+ <enum name="MAP1_VERTEX_ATTRIB10_4_NV" value="0x866A"/>
+ <enum name="MAP1_VERTEX_ATTRIB11_4_NV" value="0x866B"/>
+ <enum name="MAP1_VERTEX_ATTRIB12_4_NV" value="0x866C"/>
+ <enum name="MAP1_VERTEX_ATTRIB13_4_NV" value="0x866D"/>
+ <enum name="MAP1_VERTEX_ATTRIB14_4_NV" value="0x866E"/>
+ <enum name="MAP1_VERTEX_ATTRIB15_4_NV" value="0x866F"/>
+ <enum name="MAP2_VERTEX_ATTRIB0_4_NV" value="0x8670"/>
+ <enum name="MAP2_VERTEX_ATTRIB1_4_NV" value="0x8671"/>
+ <enum name="MAP2_VERTEX_ATTRIB2_4_NV" value="0x8672"/>
+ <enum name="MAP2_VERTEX_ATTRIB3_4_NV" value="0x8673"/>
+ <enum name="MAP2_VERTEX_ATTRIB4_4_NV" value="0x8674"/>
+ <enum name="MAP2_VERTEX_ATTRIB5_4_NV" value="0x8675"/>
+ <enum name="MAP2_VERTEX_ATTRIB6_4_NV" value="0x8676"/>
+ <enum name="MAP2_VERTEX_ATTRIB7_4_NV" value="0x8677"/>
+ <enum name="MAP2_VERTEX_ATTRIB8_4_NV" value="0x8678"/>
+ <enum name="MAP2_VERTEX_ATTRIB9_4_NV" value="0x8679"/>
+ <enum name="MAP2_VERTEX_ATTRIB10_4_NV" value="0x867A"/>
+ <enum name="MAP2_VERTEX_ATTRIB11_4_NV" value="0x867B"/>
+ <enum name="MAP2_VERTEX_ATTRIB12_4_NV" value="0x867C"/>
+ <enum name="MAP2_VERTEX_ATTRIB13_4_NV" value="0x867D"/>
+ <enum name="MAP2_VERTEX_ATTRIB14_4_NV" value="0x867E"/>
+ <enum name="MAP2_VERTEX_ATTRIB15_4_NV" value="0x867F"/>
+
+ <function name="AreProgramsResidentNV" offset="578">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="ids" type="const GLuint *" count="n"/>
+ <param name="residences" type="GLboolean *" output="true" count="n"/>
+ <return type="GLboolean"/>
+ <glx vendorpriv="1293"/>
+ </function>
+
+ <function name="BindProgramNV" offset="579">
+ <param name="target" type="GLenum"/>
+ <param name="program" type="GLuint"/>
+ <glx rop="4180"/>
+ </function>
+
+ <function name="DeleteProgramsNV" offset="580">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="programs" type="const GLuint *" count="n"/>
+ <glx vendorpriv="1294"/>
+ </function>
+
+ <function name="ExecuteProgramNV" offset="581">
+ <param name="target" type="GLenum"/>
+ <param name="id" type="GLuint"/>
+ <param name="params" type="const GLfloat *" count="4"/>
+ <glx rop="4181"/>
+ </function>
+
+ <function name="GenProgramsNV" offset="582">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="programs" type="GLuint *" output="true" count="n"/>
+ <glx vendorpriv="1295"/>
+ </function>
+
+ <!-- This isn't 100% correct. Currently, the only valid value of pname
+ is GL_PROGRAM_PARAMETER_NV, and the count for that pname is always
+ 4. This is why the pname parameter was removed in the ARB version
+ of these functions.
+ -->
+
+ <function name="GetProgramParameterdvNV" offset="583">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLdouble *" output="true" count="4"/>
+ <glx vendorpriv="1297"/>
+ </function>
+
+ <function name="GetProgramParameterfvNV" offset="584">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" count="4"/>
+ <glx vendorpriv="1296"/>
+ </function>
+
+ <function name="GetProgramivNV" offset="585">
+ <param name="id" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx vendorpriv="1298"/>
+ </function>
+
+ <function name="GetProgramStringNV" offset="586">
+ <param name="id" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="program" type="GLubyte *" output="true"/>
+ <glx vendorpriv="1299" handcode="server" always_array="true"/>
+ </function>
+
+ <function name="GetTrackMatrixivNV" offset="587">
+ <param name="target" type="GLenum"/>
+ <param name="address" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" count="1"/>
+ <glx vendorpriv="1300"/>
+ </function>
+
+ <function name="GetVertexAttribdvNV" offset="753">
+ <param name="index" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLdouble *" output="true" variable_param="pname"/>
+ <glx vendorpriv="1301"/>
+ </function>
+
+ <function name="GetVertexAttribfvNV" offset="754">
+ <param name="index" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLfloat *" output="true" variable_param="pname"/>
+ <glx vendorpriv="1302"/>
+ </function>
+
+ <function name="GetVertexAttribivNV" offset="755">
+ <param name="index" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLint *" output="true" variable_param="pname"/>
+ <glx vendorpriv="1303"/>
+ </function>
+
+ <function name="GetVertexAttribPointervNV" offset="591">
+ <param name="index" type="GLuint"/>
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="GLvoid **" output="true"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="IsProgramNV" offset="592">
+ <param name="program" type="GLuint"/>
+ <return type="GLboolean"/>
+ <glx vendorpriv="1304"/>
+ </function>
+
+ <function name="LoadProgramNV" offset="593">
+ <param name="target" type="GLenum"/>
+ <param name="id" type="GLuint"/>
+ <param name="len" type="GLsizei" counter="true"/>
+ <param name="program" type="const GLubyte *" count="len"/>
+ <glx rop="4183"/>
+ </function>
+
+ <function name="ProgramParameter4dNV" offset="594" vectorequiv="ProgramParameter4dvNV">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ <param name="w" type="GLdouble"/>
+ </function>
+
+ <function name="ProgramParameter4dvNV" offset="595">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="params" type="const GLdouble *" count="4"/>
+ <glx rop="4185" doubles_in_order="true"/>
+ </function>
+
+ <function name="ProgramParameter4fNV" offset="596" vectorequiv="ProgramParameter4fvNV">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ <param name="w" type="GLfloat"/>
+ </function>
+
+ <function name="ProgramParameter4fvNV" offset="597">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="params" type="const GLfloat *" count="4"/>
+ <glx rop="4184"/>
+ </function>
+
+ <function name="ProgramParameters4dvNV" offset="598">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="num" type="GLuint" counter="true"/>
+ <param name="params" type="const GLdouble *" count="num" count_scale="4"/>
+ <glx rop="4187"/>
+ </function>
+
+ <function name="ProgramParameters4fvNV" offset="599">
+ <param name="target" type="GLenum"/>
+ <param name="index" type="GLuint"/>
+ <param name="num" type="GLuint" counter="true"/>
+ <param name="params" type="const GLfloat *" count="num" count_scale="4"/>
+ <glx rop="4186"/>
+ </function>
+
+ <function name="RequestResidentProgramsNV" offset="600">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="ids" type="const GLuint *" count="n"/>
+ <glx rop="4182"/>
+ </function>
+
+ <function name="TrackMatrixNV" offset="601">
+ <param name="target" type="GLenum"/>
+ <param name="address" type="GLuint"/>
+ <param name="matrix" type="GLenum"/>
+ <param name="transform" type="GLenum"/>
+ <glx rop="4188"/>
+ </function>
+
+ <function name="VertexAttribPointerNV" offset="602">
+ <param name="index" type="GLuint"/>
+ <param name="size" type="GLint"/>
+ <param name="type" type="GLenum"/>
+ <param name="stride" type="GLsizei"/>
+ <param name="pointer" type="const GLvoid *"/>
+ <glx handcode="true"/>
+ </function>
+
+ <function name="VertexAttrib1sNV" offset="760" vectorequiv="VertexAttrib1svNV">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLshort"/>
+ </function>
+
+ <function name="VertexAttrib1svNV" offset="761">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLshort *" count="1"/>
+ <glx rop="4189"/>
+ </function>
+
+ <function name="VertexAttrib2sNV" offset="766" vectorequiv="VertexAttrib2svNV">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ </function>
+
+ <function name="VertexAttrib2svNV" offset="767">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLshort *" count="2"/>
+ <glx rop="4190"/>
+ </function>
+
+ <function name="VertexAttrib3sNV" offset="772" vectorequiv="VertexAttrib3svNV">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ <param name="z" type="GLshort"/>
+ </function>
+
+ <function name="VertexAttrib3svNV" offset="773">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLshort *" count="3"/>
+ <glx rop="4191"/>
+ </function>
+
+ <function name="VertexAttrib4sNV" offset="778" vectorequiv="VertexAttrib4svNV">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLshort"/>
+ <param name="y" type="GLshort"/>
+ <param name="z" type="GLshort"/>
+ <param name="w" type="GLshort"/>
+ </function>
+
+ <function name="VertexAttrib4svNV" offset="779">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLshort *" count="4"/>
+ <glx rop="4192"/>
+ </function>
+
+ <function name="VertexAttrib1fNV" offset="758" vectorequiv="VertexAttrib1fvNV">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLfloat"/>
+ </function>
+
+ <function name="VertexAttrib1fvNV" offset="759">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLfloat *" count="1"/>
+ <glx rop="4193"/>
+ </function>
+
+ <function name="VertexAttrib2fNV" offset="764" vectorequiv="VertexAttrib2fvNV">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ </function>
+
+ <function name="VertexAttrib2fvNV" offset="765">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLfloat *" count="2"/>
+ <glx rop="4194"/>
+ </function>
+
+ <function name="VertexAttrib3fNV" offset="770" vectorequiv="VertexAttrib3fvNV">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ </function>
+
+ <function name="VertexAttrib3fvNV" offset="771">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLfloat *" count="3"/>
+ <glx rop="4195"/>
+ </function>
+
+ <function name="VertexAttrib4fNV" offset="776" vectorequiv="VertexAttrib4fvNV">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ <param name="w" type="GLfloat"/>
+ </function>
+
+ <function name="VertexAttrib4fvNV" offset="777">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLfloat *" count="4"/>
+ <glx rop="4196"/>
+ </function>
+
+ <function name="VertexAttrib1dNV" offset="756" vectorequiv="VertexAttrib1dvNV">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLdouble"/>
+ </function>
+
+ <function name="VertexAttrib1dvNV" offset="757">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLdouble *" count="1"/>
+ <glx rop="4197" doubles_in_order="true"/>
+ </function>
+
+ <function name="VertexAttrib2dNV" offset="762" vectorequiv="VertexAttrib2dvNV">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ </function>
+
+ <function name="VertexAttrib2dvNV" offset="763">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLdouble *" count="2"/>
+ <glx rop="4198" doubles_in_order="true"/>
+ </function>
+
+ <function name="VertexAttrib3dNV" offset="768" vectorequiv="VertexAttrib3dvNV">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ </function>
+
+ <function name="VertexAttrib3dvNV" offset="769">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLdouble *" count="3"/>
+ <glx rop="4199" doubles_in_order="true"/>
+ </function>
+
+ <function name="VertexAttrib4dNV" offset="774" vectorequiv="VertexAttrib4dvNV">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ <param name="w" type="GLdouble"/>
+ </function>
+
+ <function name="VertexAttrib4dvNV" offset="775">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLdouble *" count="4"/>
+ <glx rop="4200" doubles_in_order="true"/>
+ </function>
+
+ <function name="VertexAttrib4ubNV" offset="780" vectorequiv="VertexAttrib4ubvNV">
+ <param name="index" type="GLuint"/>
+ <param name="x" type="GLubyte"/>
+ <param name="y" type="GLubyte"/>
+ <param name="z" type="GLubyte"/>
+ <param name="w" type="GLubyte"/>
+ </function>
+
+ <function name="VertexAttrib4ubvNV" offset="781">
+ <param name="index" type="GLuint"/>
+ <param name="v" type="const GLubyte *" count="4"/>
+ <glx rop="4201"/>
+ </function>
+
+ <function name="VertexAttribs1svNV" offset="631">
+ <param name="index" type="GLuint"/>
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="v" type="const GLshort *" count="n"/>
+ <glx rop="4202"/>
+ </function>
+
+ <function name="VertexAttribs2svNV" offset="634">
+ <param name="index" type="GLuint"/>
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="v" type="const GLshort *" count="n" count_scale="2"/>
+ <glx rop="4203"/>
+ </function>
+
+ <function name="VertexAttribs3svNV" offset="637">
+ <param name="index" type="GLuint"/>
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="v" type="const GLshort *" count="n" count_scale="3"/>
+ <glx rop="4204"/>
+ </function>
+
+ <function name="VertexAttribs4svNV" offset="640">
+ <param name="index" type="GLuint"/>
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="v" type="const GLshort *" count="n" count_scale="4"/>
+ <glx rop="4205"/>
+ </function>
+
+ <function name="VertexAttribs1fvNV" offset="630">
+ <param name="index" type="GLuint"/>
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="v" type="const GLfloat *" count="n"/>
+ <glx rop="4206"/>
+ </function>
+
+ <function name="VertexAttribs2fvNV" offset="633">
+ <param name="index" type="GLuint"/>
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="v" type="const GLfloat *" count="n" count_scale="2"/>
+ <glx rop="4207"/>
+ </function>
+
+ <function name="VertexAttribs3fvNV" offset="636">
+ <param name="index" type="GLuint"/>
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="v" type="const GLfloat *" count="n" count_scale="3"/>
+ <glx rop="4208"/>
+ </function>
+
+ <function name="VertexAttribs4fvNV" offset="639">
+ <param name="index" type="GLuint"/>
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="v" type="const GLfloat *" count="n" count_scale="4"/>
+ <glx rop="4209"/>
+ </function>
+
+ <function name="VertexAttribs1dvNV" offset="629">
+ <param name="index" type="GLuint"/>
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="v" type="const GLdouble *" count="n"/>
+ <glx rop="4210" doubles_in_order="true"/>
+ </function>
+
+ <function name="VertexAttribs2dvNV" offset="632">
+ <param name="index" type="GLuint"/>
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="v" type="const GLdouble *" count="n" count_scale="2"/>
+ <glx rop="4211" doubles_in_order="true"/>
+ </function>
+
+ <function name="VertexAttribs3dvNV" offset="635">
+ <param name="index" type="GLuint"/>
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="v" type="const GLdouble *" count="n" count_scale="3"/>
+ <glx rop="4212" doubles_in_order="true"/>
+ </function>
+
+ <function name="VertexAttribs4dvNV" offset="638">
+ <param name="index" type="GLuint"/>
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="v" type="const GLdouble *" count="n" count_scale="4"/>
+ <glx rop="4213" doubles_in_order="true"/>
+ </function>
+
+ <function name="VertexAttribs4ubvNV" offset="641">
+ <param name="index" type="GLuint"/>
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="v" type="const GLubyte *" count="n" count_scale="4"/>
+ <glx rop="4214"/>
+ </function>
+</category>
+
+<!-- Extension number 234 is a GLX extension. -->
+
+<category name="GL_SGIX_texture_coordinate_clamp" number="235">
+ <enum name="TEXTURE_MAX_CLAMP_S_SGIX" count="1" value="0x8369">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_MAX_CLAMP_T_SGIX" count="1" value="0x836A">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+ <enum name="TEXTURE_MAX_CLAMP_R_SGIX" count="1" value="0x836B">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+</category>
+
+<!-- Extension number 236 is not listed in the extension registry. -->
+<!-- Extension number 237 is a GLX extension. -->
+<!-- Extension number 238 is a GLX extension. -->
+<!-- Extension number 242 is a WGL extension. -->
+
+<category name="GL_NV_copy_depth_to_color" number="243">
+ <enum name="DEPTH_STENCIL_TO_RGBA_NV" value="0x886E"/>
+ <enum name="DEPTH_STENCIL_TO_BGRA_NV" value="0x886F"/>
+</category>
+
+<category name="GL_ATI_fragment_shader" number="245">
+ <function name="GenFragmentShadersATI" offset="782">
+ <return type="GLuint"/>
+ <param name="range" type="GLuint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="BindFragmentShaderATI" offset="783">
+ <param name="id" type="GLuint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="DeleteFragmentShaderATI" offset="784">
+ <param name="id" type="GLuint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="BeginFragmentShaderATI" offset="785">
+ <glx ignore="true"/>
+ </function>
+
+ <function name="EndFragmentShaderATI" offset="786">
+ <glx ignore="true"/>
+ </function>
+
+ <function name="PassTexCoordATI" offset="787">
+ <param name="dst" type="GLuint"/>
+ <param name="coord" type="GLuint"/>
+ <param name="swizzle" type="GLenum"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="SampleMapATI" offset="788">
+ <param name="dst" type="GLuint"/>
+ <param name="interp" type="GLuint"/>
+ <param name="swizzle" type="GLenum"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="ColorFragmentOp1ATI" offset="789">
+ <param name="op" type="GLenum"/>
+ <param name="dst" type="GLuint"/>
+ <param name="dstMask" type="GLuint"/>
+ <param name="dstMod" type="GLuint"/>
+ <param name="arg1" type="GLuint"/>
+ <param name="arg1Rep" type="GLuint"/>
+ <param name="arg1Mod" type="GLuint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="ColorFragmentOp2ATI" offset="790">
+ <param name="op" type="GLenum"/>
+ <param name="dst" type="GLuint"/>
+ <param name="dstMask" type="GLuint"/>
+ <param name="dstMod" type="GLuint"/>
+ <param name="arg1" type="GLuint"/>
+ <param name="arg1Rep" type="GLuint"/>
+ <param name="arg1Mod" type="GLuint"/>
+ <param name="arg2" type="GLuint"/>
+ <param name="arg2Rep" type="GLuint"/>
+ <param name="arg2Mod" type="GLuint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="ColorFragmentOp3ATI" offset="791">
+ <param name="op" type="GLenum"/>
+ <param name="dst" type="GLuint"/>
+ <param name="dstMask" type="GLuint"/>
+ <param name="dstMod" type="GLuint"/>
+ <param name="arg1" type="GLuint"/>
+ <param name="arg1Rep" type="GLuint"/>
+ <param name="arg1Mod" type="GLuint"/>
+ <param name="arg2" type="GLuint"/>
+ <param name="arg2Rep" type="GLuint"/>
+ <param name="arg2Mod" type="GLuint"/>
+ <param name="arg3" type="GLuint"/>
+ <param name="arg3Rep" type="GLuint"/>
+ <param name="arg3Mod" type="GLuint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="AlphaFragmentOp1ATI" offset="792">
+ <param name="op" type="GLenum"/>
+ <param name="dst" type="GLuint"/>
+ <param name="dstMod" type="GLuint"/>
+ <param name="arg1" type="GLuint"/>
+ <param name="arg1Rep" type="GLuint"/>
+ <param name="arg1Mod" type="GLuint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="AlphaFragmentOp2ATI" offset="793">
+ <param name="op" type="GLenum"/>
+ <param name="dst" type="GLuint"/>
+ <param name="dstMod" type="GLuint"/>
+ <param name="arg1" type="GLuint"/>
+ <param name="arg1Rep" type="GLuint"/>
+ <param name="arg1Mod" type="GLuint"/>
+ <param name="arg2" type="GLuint"/>
+ <param name="arg2Rep" type="GLuint"/>
+ <param name="arg2Mod" type="GLuint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="AlphaFragmentOp3ATI" offset="794">
+ <param name="op" type="GLenum"/>
+ <param name="dst" type="GLuint"/>
+ <param name="dstMod" type="GLuint"/>
+ <param name="arg1" type="GLuint"/>
+ <param name="arg1Rep" type="GLuint"/>
+ <param name="arg1Mod" type="GLuint"/>
+ <param name="arg2" type="GLuint"/>
+ <param name="arg2Rep" type="GLuint"/>
+ <param name="arg2Mod" type="GLuint"/>
+ <param name="arg3" type="GLuint"/>
+ <param name="arg3Rep" type="GLuint"/>
+ <param name="arg3Mod" type="GLuint"/>
+ <glx ignore="true"/>
+ </function>
+
+ <function name="SetFragmentShaderConstantATI" offset="795">
+ <param name="dst" type="GLuint"/>
+ <param name="value" type="const GLfloat *"/>
+ <glx ignore="true"/>
+ </function>
+</category>
+
+<!-- Extension number 250 is a WGL extension. -->
+<!-- Extension number 251 is a WGL extension. -->
+<!-- Extension number 252 is a WGL extension. -->
+<!-- Extension number 253 is a WGL extension. -->
+<!-- Extension number 254 is a WGL extension. -->
+<!-- Extension number 255 is a WGL extension. -->
+
+<category name="GL_SUN_mesh_array" number="257">
+ <enum name="QUAD_MESH_SUN" value="0x8614"/>
+ <enum name="TRIANGLE_MESH_SUN" value="0x8615"/>
+
+ <function name="DrawMeshArraysSUN" offset="?">
+ <param name="mode" type="GLenum"/>
+ <param name="first" type="GLint"/>
+ <param name="count" type="GLsizei"/>
+ <param name="width" type="GLsizei"/>
+ </function>
+</category>
+
+<category name="GL_SUN_slice_accum" number="258">
+ <enum name="SLICE_ACCUM_SUN" value="0x85CC"/>
+</category>
+
+<category name="GL_NV_multisample_filter_hint" number="259">
+ <enum name="MULTISAMPLE_FILTER_HINT_NV" count="1" value="0x8534">
+ <size name="Get" mode="get"/>
+ </enum>
+</category>
+
+<category name="GL_NV_depth_clamp" number="260">
+ <enum name="DEPTH_CLAMP_NV" count="1" value="0x864F">
+ <size name="Get" mode="get"/>
+ </enum>
+</category>
+
+<category name="GL_NV_point_sprite" number="262">
+ <!-- These existing enums can be passed as a parameter to the function
+ added for this extension. -->
+
+ <enum name="POINT_SIZE_MIN_EXT" count="1" value="0x8126">
+ <size name="PointParameterivNV"/>
+ </enum>
+ <enum name="POINT_SIZE_MAX_EXT" count="1" value="0x8127">
+ <size name="PointParameterivNV"/>
+ </enum>
+ <enum name="POINT_FADE_THRESHOLD_SIZE_EXT" count="1" value="0x8128">
+ <size name="PointParameterivNV"/>
+ </enum>
+ <enum name="POINT_DISTANCE_ATTENUATION_EXT" count="3" value="0x8129">
+ <size name="PointParameterivNV"/>
+ </enum>
+
+ <enum name="POINT_SPRITE_NV" count="1" value="0x8861">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="COORD_REPLACE_NV" count="1" value="0x8862">
+ <size name="TexEnvfv"/>
+ <size name="TexEnviv"/>
+ <size name="GetTexEnvfv" mode="get"/>
+ <size name="GetTexEnviv" mode="get"/>
+ </enum>
+ <enum name="POINT_SPRITE_R_MODE_NV" count="1" value="0x8863">
+ <size name="PointParameterfvEXT"/>
+ <size name="PointParameterivNV"/>
+ <size name="Get" mode="get"/>
+ </enum>
+
+ <function name="PointParameteriNV" offset="642">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLint"/>
+ <glx rop="4221"/>
+ </function>
+
+ <function name="PointParameterivNV" offset="643">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLint *" variable_param="pname"/>
+ <glx rop="4222"/>
+ </function>
+</category>
+
+<!-- Extension number 263 is a WGL extension. -->
+<!-- Extension number 264 is a WGL extension. -->
+
+<category name="GL_EXT_shadow_funcs" number="267">
+ <!-- No new functions, types, enums. -->
+</category>
+
+<category name="GL_EXT_stencil_two_side" number="268">
+ <enum name="STENCIL_TEST_TWO_SIDE_EXT" count="1" value="0x8910">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="ACTIVE_STENCIL_FACE_EXT" count="1" value="0x8911">
+ <size name="Get" mode="get"/>
+ </enum>
+
+ <function name="ActiveStencilFaceEXT" offset="646">
+ <param name="face" type="GLenum"/>
+ <glx rop="4220"/>
+ </function>
+</category>
+
+<category name="GL_APPLE_ycbcr_422" number="275">
+ <enum name="YCBCR_422_APPLE" value="0x85B9"/>
+ <enum name="UNSIGNED_SHORT_8_8_APPLE" value="0x85BA"/>
+ <enum name="UNSIGNED_SHORT_8_8_REV_APPLE" value="0x85BB"/>
+</category>
+
+<category name="GL_S3_s3tc" number="276">
+ <enum name="RGB_S3TC" value="0x83A0"/>
+ <enum name="RGB4_S3TC" value="0x83A1"/>
+ <enum name="RGBA_S3TC" value="0x83A2"/>
+ <enum name="RGBA4_S3TC" value="0x83A3"/>
+ <enum name="RGBA_DXT5_S3TC" value="0x83A4"/>
+ <enum name="RGBA4_DXT5_S3TC" value="0x83A5"/>
+</category>
+
+<category name="GL_ATI_draw_buffers" number="277">
+ <enum name="MAX_DRAW_BUFFERS_ATI" count="1" value="0x8824">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER0_ATI" count="1" value="0x8825">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER1_ATI" count="1" value="0x8826">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER2_ATI" count="1" value="0x8827">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER3_ATI" count="1" value="0x8828">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER4_ATI" count="1" value="0x8829">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER5_ATI" count="1" value="0x882A">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER6_ATI" count="1" value="0x882B">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER7_ATI" count="1" value="0x882C">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER8_ATI" count="1" value="0x882D">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER9_ATI" count="1" value="0x882E">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER10_ATI" count="1" value="0x882F">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER11_ATI" count="1" value="0x8830">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER12_ATI" count="1" value="0x8831">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER13_ATI" count="1" value="0x8832">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER14_ATI" count="1" value="0x8833">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DRAW_BUFFER15_ATI" count="1" value="0x8834">
+ <size name="Get" mode="get"/>
+ </enum>
+
+ <function name="DrawBuffersATI" alias="DrawBuffersARB">
+ <param name="n" type="GLsizei" counter="true"/>
+ <param name="bufs" type="const GLenum *" count="n"/>
+ <!-- GLX protocol is not fully defined for this extension. -->
+ </function>
+</category>
+
+<!-- Extension number 278 is a WGL extension. -->
+
+<category name="GL_ATI_texture_env_combine3" number="279">
+ <enum name="MODULATE_ADD_ATI" value="0x8744"/>
+ <enum name="MODULATE_SIGNED_ADD_ATI" value="0x8745"/>
+ <enum name="MODULATE_SUBTRACT_ATI" value="0x8746"/>
+</category>
+
+<category name="GL_NV_fragment_program" number="282">
+ <function name="ProgramNamedParameter4fNV" offset="682" vectorequiv="ProgramNamedParameter4fvNV">
+ <param name="id" type="GLuint"/>
+ <param name="len" type="GLsizei" counter="true"/>
+ <param name="name" type="const GLubyte *" count="len"/>
+ <param name="x" type="GLfloat"/>
+ <param name="y" type="GLfloat"/>
+ <param name="z" type="GLfloat"/>
+ <param name="w" type="GLfloat"/>
+ </function>
+
+ <function name="ProgramNamedParameter4dNV" offset="683" vectorequiv="ProgramNamedParameter4dvNV">
+ <param name="id" type="GLuint"/>
+ <param name="len" type="GLsizei" counter="true"/>
+ <param name="name" type="const GLubyte *" count="len"/>
+ <param name="x" type="GLdouble"/>
+ <param name="y" type="GLdouble"/>
+ <param name="z" type="GLdouble"/>
+ <param name="w" type="GLdouble"/>
+ </function>
+
+ <function name="ProgramNamedParameter4fvNV" offset="684">
+ <param name="id" type="GLuint"/>
+ <param name="len" type="GLsizei" counter="true"/>
+ <param name="name" type="const GLubyte *" count="len"/>
+ <param name="v" type="const GLfloat *" count="4"/>
+ <glx rop="4218"/>
+ </function>
+
+ <function name="ProgramNamedParameter4dvNV" offset="685">
+ <param name="id" type="GLuint"/>
+ <param name="len" type="GLsizei" counter="true"/>
+ <param name="name" type="const GLubyte *" count="len"/>
+ <param name="v" type="const GLdouble *" count="4"/>
+ <glx rop="4219"/>
+ </function>
+
+ <function name="GetProgramNamedParameterfvNV" offset="686">
+ <param name="id" type="GLuint"/>
+ <param name="len" type="GLsizei" counter="true"/>
+ <param name="name" type="const GLubyte *" count="len"/>
+ <param name="params" type="GLfloat *" output="true" count="4"/>
+ <glx vendorpriv="1310" always_array="true"/>
+ </function>
+
+ <function name="GetProgramNamedParameterdvNV" offset="687">
+ <param name="id" type="GLuint"/>
+ <param name="len" type="GLsizei" counter="true"/>
+ <param name="name" type="const GLubyte *" count="len"/>
+ <param name="params" type="GLdouble *" output="true" count="4"/>
+ <glx vendorpriv="1311" always_array="true"/>
+ </function>
+</category>
+
+<category name="GL_NV_expand_normal" number="286">
+ <enum name="TEXTURE_UNSIGNED_REMAP_MODE_NV" count="1" value="0x888F">
+ <size name="TexParameterfv"/>
+ <size name="TexParameteriv"/>
+ <size name="GetTexParameterfv" mode="get"/>
+ <size name="GetTexParameteriv" mode="get"/>
+ </enum>
+</category>
+
+<category name="GL_OES_compressed_paletted_texture" number="294">
+ <enum name="PALETTE4_RGB8_OES" value="0x8B90"/>
+ <enum name="PALETTE4_RGBA8_OES" value="0x8B91"/>
+ <enum name="PALETTE4_R5_G6_B5_OES" value="0x8B92"/>
+ <enum name="PALETTE4_RGBA4_OES" value="0x8B93"/>
+ <enum name="PALETTE4_RGB5_A1_OES" value="0x8B94"/>
+ <enum name="PALETTE8_RGB8_OES" value="0x8B95"/>
+ <enum name="PALETTE8_RGBA8_OES" value="0x8B96"/>
+ <enum name="PALETTE8_R5_G6_B5_OES" value="0x8B97"/>
+ <enum name="PALETTE8_RGBA4_OES" value="0x8B98"/>
+ <enum name="PALETTE8_RGB5_A1_OES" value="0x8B99"/>
+</category>
+
+<category name="GL_OES_read_format" number="295">
+ <enum name="IMPLEMENTATION_COLOR_READ_TYPE_OES" value="0x8B9A"/>
+ <enum name="IMPLEMENTATION_COLOR_READ_FORMAT_OES" value="0x8B9B"/>
+</category>
+
+<category name="GL_EXT_depth_bounds_test" number="297">
+ <enum name="DEPTH_BOUNDS_TEST_EXT" count="1" value="0x8890">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="DEPTH_BOUNDS_EXT" count="2" value="0x8891">
+ <size name="Get" mode="get"/>
+ </enum>
+
+ <function name="DepthBoundsEXT" offset="699">
+ <param name="zmin" type="GLclampd"/>
+ <param name="zmax" type="GLclampd"/>
+ <glx rop="4229" ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_EXT_texture_mirror_clamp" number="298">
+ <enum name="MIRROR_CLAMP_EXT" value="0x8742"/>
+ <enum name="MIRROR_CLAMP_TO_EDGE_EXT" value="0x8743"/>
+ <enum name="MIRROR_CLAMP_TO_BORDER_EXT" value="0x8912"/>
+</category>
+
+<category name="GL_EXT_blend_equation_separate" number="299">
+ <enum name="BLEND_EQUATION_RGB_EXT" count="1" value="0x8009">
+ <size name="Get" mode="get"/>
+ </enum>
+ <enum name="BLEND_EQUATION_ALPHA_EXT" count="1" value="0x883D">
+ <size name="Get" mode="get"/>
+ </enum>
+
+ <function name="BlendEquationSeparateEXT" offset="710">
+ <param name="modeRGB" type="GLenum"/>
+ <param name="modeA" type="GLenum"/>
+ <glx rop="4228" ignore="true"/>
+ </function>
+</category>
+
+<category name="GL_MESA_pack_invert" number="300">
+ <enum name="PACK_INVERT_MESA" count="1" value="0x8758">
+ <size name="Get" mode="get"/>
+ </enum>
+</category>
+
+<category name="GL_MESA_ycbcr_texture" number="301">
+ <enum name="YCBCR_MESA" value="0x8757"/>
+ <enum name="UNSIGNED_SHORT_8_8_MESA" value="0x85BA"/>
+ <enum name="UNSIGNED_SHORT_8_8_REV_MESA" value="0x85BB"/>
+</category>
+
+<category name="GL_EXT_pixel_buffer_object" number="302">
+ <enum name="PIXEL_PACK_BUFFER_EXT" value="0x88EB"/>
+ <enum name="PIXEL_UNPACK_BUFFER_EXT" value="0x88EC"/>
+ <enum name="PIXEL_PACK_BUFFER_BINDING_EXT" value="0x88ED"/>
+ <enum name="PIXEL_UNPACK_BUFFER_BINDING_EXT" value="0x88EF"/>
+</category>
+
+<category name="GL_NV_fragment_program_option" number="303">
+ <!-- No new functions, types, enums. -->
+</category>
+
+<category name="GL_NV_fragment_program2" number="304">
+ <enum name="MAX_PROGRAM_EXEC_INSTRUCTIONS_NV" count="1" value="0x88F4">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_CALL_DEPTH_NV" count="1" value="0x88F5">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_IF_DEPTH_NV" count="1" value="0x88F6">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_LOOP_DEPTH_NV" count="1" value="0x88F7">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_LOOP_COUNT_NV" count="1" value="0x88F8">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+</category>
+
+<category name="GL_NV_vertex_program2_option" number="305">
+ <enum name="MAX_PROGRAM_EXEC_INSTRUCTIONS_NV" count="1" value="0x88F4">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+ <enum name="MAX_PROGRAM_CALL_DEPTH_NV" count="1" value="0x88F5">
+ <size name="GetProgramivARB" mode="get"/>
+ </enum>
+</category>
+
+<category name="GL_NV_vertex_program3" number="306">
+ <enum name="MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB" count="1" value="0x8B4C"/>
+</category>
+
+<xi:include href="EXT_framebuffer_object.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
+
+<!-- Extension number 307 is a GLX extension. -->
+<!-- Extension number 308 is a GLX extension. -->
+
+<category name="GL_EXT_texture_compression_dxt1" number="309">
+ <enum name="COMPRESSED_RGB_S3TC_DXT1_EXT" value="0x83F0"/>
+ <enum name="COMPRESSED_RGBA_S3TC_DXT1_EXT" value="0x83F1"/>
+</category>
+
+<!-- Unnumbered extensions sorted by name. -->
+
+<category name="GL_ATI_blend_equation_separate">
+ <function name="BlendEquationSeparateATI" alias="BlendEquationSeparateEXT">
+ <param name="modeRGB" type="GLenum"/>
+ <param name="modeA" type="GLenum"/>
+ </function>
+</category>
+
+<category name="GL_INGR_blend_func_separate">
+ <function name="BlendFuncSeparateINGR" alias="BlendFuncSeparateEXT">
+ <param name="sfactorRGB" type="GLenum"/>
+ <param name="dfactorRGB" type="GLenum"/>
+ <param name="sfactorAlpha" type="GLenum"/>
+ <param name="dfactorAlpha" type="GLenum"/>
+ </function>
+</category>
+
+<category name="GL_SGIS_point_parameters">
+ <enum name="POINT_SIZE_MIN_SGIS" count="1" value="0x8126">
+ <size name="PointParameterfvEXT"/>
+ </enum>
+ <enum name="POINT_SIZE_MAX_SGIS" count="1" value="0x8127">
+ <size name="PointParameterfvEXT"/>
+ </enum>
+ <enum name="POINT_FADE_THRESHOLD_SIZE_SGIS" count="1" value="0x8128">
+ <size name="PointParameterfvEXT"/>
+ </enum>
+ <enum name="POINT_DISTANCE_ATTENUATION_SGIS" count="3" value="0x8129">
+ <size name="PointParameterfvEXT"/>
+ </enum>
+
+ <function name="PointParameterfSGIS" alias="PointParameterfEXT">
+ <param name="pname" type="GLenum"/>
+ <param name="param" type="GLfloat"/>
+ </function>
+
+ <function name="PointParameterfvSGIS" alias="PointParameterfvEXT">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLfloat *"/>
+ </function>
+</category>
+
+<category name="GL_SGIX_igloo_interface">
+ <function name="IglooInterfaceSGIX" offset="?">
+ <param name="pname" type="GLenum"/>
+ <param name="params" type="const GLvoid *"/>
+ </function>
+</category>
+
+<category name="GL_SGIX_polynomial_ffd">
+ <function name="DeformationMap3dSGIX" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="u1" type="GLdouble"/>
+ <param name="u2" type="GLdouble"/>
+ <param name="ustride" type="GLint"/>
+ <param name="uorder" type="GLint"/>
+ <param name="v1" type="GLdouble"/>
+ <param name="v2" type="GLdouble"/>
+ <param name="vstride" type="GLint"/>
+ <param name="vorder" type="GLint"/>
+ <param name="w1" type="GLdouble"/>
+ <param name="w2" type="GLdouble"/>
+ <param name="wstride" type="GLint"/>
+ <param name="worder" type="GLint"/>
+ <param name="points" type="const GLdouble *"/>
+ </function>
+
+ <function name="DeformationMap3fSGIX" offset="?">
+ <param name="target" type="GLenum"/>
+ <param name="u1" type="GLfloat"/>
+ <param name="u2" type="GLfloat"/>
+ <param name="ustride" type="GLint"/>
+ <param name="uorder" type="GLint"/>
+ <param name="v1" type="GLfloat"/>
+ <param name="v2" type="GLfloat"/>
+ <param name="vstride" type="GLint"/>
+ <param name="vorder" type="GLint"/>
+ <param name="w1" type="GLfloat"/>
+ <param name="w2" type="GLfloat"/>
+ <param name="wstride" type="GLint"/>
+ <param name="worder" type="GLint"/>
+ <param name="points" type="const GLfloat *"/>
+ </function>
+
+ <function name="DeformSGIX" offset="?">
+ <param name="mask" type="GLenum"/>
+ </function>
+
+ <function name="LoadIdentityDeformationMapSGIX" offset="?">
+ <param name="mask" type="GLenum"/>
+ </function>
+</category>
+
+</OpenGLAPI>
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/gl_SPARC_asm.py b/nx-X11/extras/Mesa/src/mesa/glapi/gl_SPARC_asm.py
new file mode 100644
index 000000000..1a8823cc4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/gl_SPARC_asm.py
@@ -0,0 +1,135 @@
+#!/usr/bin/env python
+
+# (C) Copyright IBM Corporation 2004
+# 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
+# IBM 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:
+# Ian Romanick <idr@us.ibm.com>
+
+import gl_XML, license
+import sys, getopt
+
+class PrintGenericStubs(gl_XML.gl_print_base):
+ def __init__(self):
+ gl_XML.gl_print_base.__init__(self)
+ self.name = "gl_SPARC_asm.py (from Mesa)"
+ self.license = license.bsd_license_template % ( \
+"""Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+(C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM")
+
+
+ def printRealHeader(self):
+ print '#include "glapioffsets.h"'
+ print ''
+ print '#ifdef __arch64__'
+ print '# define GL_STUB(fn,off)\t\t\t\t\\'
+ print 'fn:\t\t\t\t\t\\'
+ print '\tsethi\t%hi(0xDEADBEEF), %g4 ;\t\t\t\\'
+ print '\tsethi\t%hi(0xDEADBEEF), %g1 ;\t\t\t\\'
+ print '\tor\t%g4, %lo(0xDEADBEEF), %g4 ;\t\t\\'
+ print '\tor\t%g1, %lo(0xDEADBEEF), %g1 ;\t\t\\'
+ print '\tsllx\t%g4, 32, %g4 ;\t\t\t\t\\'
+ print '\tldx\t[%g1 + %g4], %g1 ;\t\t\t\\'
+ print '\tsethi\t%hi(8 * off), %g4 ;\t\t\t\\'
+ print '\tor\t%g4, %lo(8 * off), %g4 ;\t\t\\'
+ print '\tldx\t[%g1 + %g4], %g5 ;\t\t\t\\'
+ print '\tjmpl\t%g5, %g0 ;\t\t\t\t\\'
+ print '\tnop'
+ print '#else'
+ print '# define GL_STUB(fn,off)\t\t\t\t\\'
+ print 'fn:\t\t\t\t\t\\'
+ print '\tsethi\t%hi(0xDEADBEEF), %g1 ;\t\t\t\\'
+ print '\tld\t[%g1 + %lo(0xDEADBEEF)], %g1 ;\t\t\\'
+ print '\tld\t[%g1 + (4 * off)], %g5 ;\t\t\\'
+ print '\tjmpl\t%g5, %g0 ;\t\t\t\t\\'
+ print '\tnop'
+ print '#endif'
+ print ''
+ print '#define GL_STUB_ALIAS(fn,alias) fn = alias'
+ print ''
+ print '.text'
+ print '.align 32'
+ print '\t\t.globl __glapi_sparc_icache_flush ; .type __glapi_sparc_icache_flush,#function'
+ print '__glapi_sparc_icache_flush: /* %o0 = insn_addr */'
+ print '\tflush\t%o0'
+ print '\tretl'
+ print '\tnop'
+ print ''
+ print '.data'
+ print '.align 64'
+ print ''
+ return
+
+
+ def printBody(self, api):
+ for f in api.functionIterateByOffset():
+ print '\t\t.globl gl%s ; .type gl%s,#function' % (f.name, f.name)
+
+ print '\t\t.globl _mesa_sparc_glapi_begin ; .type _mesa_sparc_glapi_begin,#function'
+ print '_mesa_sparc_glapi_begin:'
+ print ''
+
+ for f in api.functionIterateByOffset():
+ print '\tGL_STUB(gl%s, _gloffset_%s)' % (f.name, f.name)
+
+ print ''
+ print '\t\t.globl _mesa_sparc_glapi_end ; .type _mesa_sparc_glapi_end,#function'
+ print '_mesa_sparc_glapi_end:'
+ print ''
+
+
+ for f in api.functionIterateByOffset():
+ for n in f.entry_points:
+ if n != f.name:
+ print '\t.globl gl%s ; .type gl%s,#function ; gl%s = gl%s' % (n, n, n, f.name)
+
+ return
+
+
+def show_usage():
+ print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]
+ sys.exit(1)
+
+if __name__ == '__main__':
+ file_name = "gl_API.xml"
+ mode = "generic"
+
+ try:
+ (args, trail) = getopt.getopt(sys.argv[1:], "m:f:")
+ except Exception,e:
+ show_usage()
+
+ for (arg,val) in args:
+ if arg == '-m':
+ mode = val
+ elif arg == "-f":
+ file_name = val
+
+ if mode == "generic":
+ printer = PrintGenericStubs()
+ else:
+ print "ERROR: Invalid mode \"%s\" specified." % mode
+ show_usage()
+
+ api = gl_XML.parse_GL_API( file_name )
+
+ printer.Print( api )
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/gl_XML.py b/nx-X11/extras/Mesa/src/mesa/glapi/gl_XML.py
new file mode 100644
index 000000000..11b23b7a8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/gl_XML.py
@@ -0,0 +1,813 @@
+#!/usr/bin/env python
+
+# (C) Copyright IBM Corporation 2004, 2005
+# 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
+# IBM 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:
+# Ian Romanick <idr@us.ibm.com>
+
+import libxml2
+import re, sys, string
+import typeexpr
+
+
+def parse_GL_API( file_name, factory = None ):
+ doc = libxml2.readFile( file_name, None, libxml2.XML_PARSE_XINCLUDE + libxml2.XML_PARSE_NOBLANKS + libxml2.XML_PARSE_DTDVALID + libxml2.XML_PARSE_DTDATTR + libxml2.XML_PARSE_DTDLOAD + libxml2.XML_PARSE_NOENT )
+ ret = doc.xincludeProcess()
+
+ if not factory:
+ factory = gl_item_factory()
+
+ api = factory.create_item( "api", None, None )
+ api.process_element( doc )
+
+ doc.freeDoc()
+
+ return api
+
+
+def is_attr_true( element, name ):
+ """Read a name value from an element's attributes.
+
+ The value read from the attribute list must be either 'true' or
+ 'false'. If the value is 'false', zero will be returned. If the
+ value is 'true', non-zero will be returned. An exception will be
+ raised for any other value."""
+
+ value = element.nsProp( name, None )
+ if value == "true":
+ return 1
+ elif value == "false":
+ return 0
+ else:
+ raise RuntimeError('Invalid value "%s" for boolean "%s".' % (value, name))
+
+
+class gl_print_base:
+ """Base class of all API pretty-printers.
+
+ In the model-view-controller pattern, this is the view. Any derived
+ class will want to over-ride the printBody, printRealHader, and
+ printRealFooter methods. Some derived classes may want to over-ride
+ printHeader and printFooter, or even Print (though this is unlikely).
+ """
+
+ def __init__(self):
+ # Name of the script that is generating the output file.
+ # Every derived class should set this to the name of its
+ # source file.
+
+ self.name = "a"
+
+
+ # License on the *generated* source file. This may differ
+ # from the license on the script that is generating the file.
+ # Every derived class should set this to some reasonable
+ # value.
+ #
+ # See license.py for an example of a reasonable value.
+
+ self.license = "The license for this file is unspecified."
+
+
+ # The header_tag is the name of the C preprocessor define
+ # used to prevent multiple inclusion. Typically only
+ # generated C header files need this to be set. Setting it
+ # causes code to be generated automatically in printHeader
+ # and printFooter.
+
+ self.header_tag = None
+
+
+ # List of file-private defines that must be undefined at the
+ # end of the file. This can be used in header files to define
+ # names for use in the file, then undefine them at the end of
+ # the header file.
+
+ self.undef_list = []
+ return
+
+
+ def Print(self, api):
+ self.printHeader()
+ self.printBody(api)
+ self.printFooter()
+ return
+
+
+ def printHeader(self):
+ """Print the header associated with all files and call the printRealHeader method."""
+
+ print '/* DO NOT EDIT - This file generated automatically by %s script */' \
+ % (self.name)
+ print ''
+ print '/*'
+ print ' * ' + self.license.replace('\n', '\n * ')
+ print ' */'
+ print ''
+ if self.header_tag:
+ print '#if !defined( %s )' % (self.header_tag)
+ print '# define %s' % (self.header_tag)
+ print ''
+ self.printRealHeader();
+ return
+
+
+ def printFooter(self):
+ """Print the header associated with all files and call the printRealFooter method."""
+
+ self.printRealFooter()
+
+ if self.undef_list:
+ print ''
+ for u in self.undef_list:
+ print "# undef %s" % (u)
+
+ if self.header_tag:
+ print ''
+ print '#endif /* !defined( %s ) */' % (self.header_tag)
+
+
+ def printRealHeader(self):
+ """Print the "real" header for the created file.
+
+ In the base class, this function is empty. All derived
+ classes should over-ride this function."""
+ return
+
+
+ def printRealFooter(self):
+ """Print the "real" footer for the created file.
+
+ In the base class, this function is empty. All derived
+ classes should over-ride this function."""
+ return
+
+
+ def printPure(self):
+ """Conditionally define `PURE' function attribute.
+
+ Conditionally defines a preprocessor macro `PURE' that wraps
+ GCC's `pure' function attribute. The conditional code can be
+ easilly adapted to other compilers that support a similar
+ feature.
+
+ The name is also added to the file's undef_list.
+ """
+ self.undef_list.append("PURE")
+ print """# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+# define PURE __attribute__((pure))
+# else
+# define PURE
+# endif"""
+ return
+
+
+ def printFastcall(self):
+ """Conditionally define `FASTCALL' function attribute.
+
+ Conditionally defines a preprocessor macro `FASTCALL' that
+ wraps GCC's `fastcall' function attribute. The conditional
+ code can be easilly adapted to other compilers that support a
+ similar feature.
+
+ The name is also added to the file's undef_list.
+ """
+
+ self.undef_list.append("FASTCALL")
+ print """# if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__)
+# define FASTCALL __attribute__((fastcall))
+# else
+# define FASTCALL
+# endif"""
+ return
+
+
+ def printVisibility(self, S, s):
+ """Conditionally define visibility function attribute.
+
+ Conditionally defines a preprocessor macro name S that wraps
+ GCC's visibility function attribute. The visibility used is
+ the parameter s. The conditional code can be easilly adapted
+ to other compilers that support a similar feature.
+
+ The name is also added to the file's undef_list.
+ """
+
+ self.undef_list.append(S)
+ print """# if (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)) && defined(__ELF__)
+# define %s __attribute__((visibility("%s")))
+# else
+# define %s
+# endif""" % (S, s, S)
+ return
+
+
+ def printNoinline(self):
+ """Conditionally define `NOINLINE' function attribute.
+
+ Conditionally defines a preprocessor macro `NOINLINE' that
+ wraps GCC's `noinline' function attribute. The conditional
+ code can be easilly adapted to other compilers that support a
+ similar feature.
+
+ The name is also added to the file's undef_list.
+ """
+
+ self.undef_list.append("NOINLINE")
+ print """# if defined(__GNUC__)
+# define NOINLINE __attribute__((noinline))
+# else
+# define NOINLINE
+# endif"""
+ return
+
+
+def real_function_name(element):
+ name = element.nsProp( "name", None )
+ alias = element.nsProp( "alias", None )
+
+ if alias:
+ return alias
+ else:
+ return name
+
+
+def real_category_name(c):
+ if re.compile("[1-9][0-9]*[.][0-9]+").match(c):
+ return "GL_VERSION_" + c.replace(".", "_")
+ else:
+ return c
+
+
+def create_parameter_string(parameters, include_names):
+ """Create a parameter string from a list of gl_parameters."""
+
+ list = []
+ for p in parameters:
+ if include_names:
+ list.append( p.string() )
+ else:
+ list.append( p.type_string() )
+
+ if len(list) == 0: list = ["void"]
+
+ return string.join(list, ", ")
+
+
+class gl_item:
+ def __init__(self, element, context):
+ self.context = context
+ self.name = element.nsProp( "name", None )
+ self.category = real_category_name( element.parent.nsProp( "name", None ) )
+ return
+
+
+class gl_type( gl_item ):
+ def __init__(self, element, context):
+ gl_item.__init__(self, element, context)
+ self.size = int( element.nsProp( "size", None ), 0 )
+
+ te = typeexpr.type_expression( None )
+ tn = typeexpr.type_node()
+ tn.size = int( element.nsProp( "size", None ), 0 )
+ tn.integer = not is_attr_true( element, "float" )
+ tn.unsigned = is_attr_true( element, "unsigned" )
+ tn.name = "GL" + self.name
+ te.set_base_type_node( tn )
+
+ self.type_expr = te
+ return
+
+
+ def get_type_expression(self):
+ return self.type_expr
+
+
+class gl_enum( gl_item ):
+ def __init__(self, element, context):
+ gl_item.__init__(self, element, context)
+ self.value = int( element.nsProp( "value", None ), 0 )
+
+ temp = element.nsProp( "count", None )
+ if not temp or temp == "?":
+ self.default_count = -1
+ else:
+ try:
+ c = int(temp)
+ except Exception,e:
+ raise RuntimeError('Invalid count value "%s" for enum "%s" in function "%s" when an integer was expected.' % (temp, self.name, n))
+
+ self.default_count = c
+
+ return
+
+
+ def priority(self):
+ """Calculate a 'priority' for this enum name.
+
+ When an enum is looked up by number, there may be many
+ possible names, but only one is the 'prefered' name. The
+ priority is used to select which name is the 'best'.
+
+ Highest precedence is given to core GL name. ARB extension
+ names have the next highest, followed by EXT extension names.
+ Vendor extension names are the lowest.
+ """
+
+ if self.name.endswith( "_BIT" ):
+ bias = 1
+ else:
+ bias = 0
+
+ if self.category.startswith( "GL_VERSION_" ):
+ priority = 0
+ elif self.category.startswith( "GL_ARB_" ):
+ priority = 2
+ elif self.category.startswith( "GL_EXT_" ):
+ priority = 4
+ else:
+ priority = 6
+
+ return priority + bias
+
+
+
+class gl_parameter:
+ def __init__(self, element, context):
+ self.name = element.nsProp( "name", None )
+
+ ts = element.nsProp( "type", None )
+ self.type_expr = typeexpr.type_expression( ts, context )
+
+ temp = element.nsProp( "variable_param", None )
+ if temp:
+ self.count_parameter_list = temp.split( ' ' )
+ else:
+ self.count_parameter_list = []
+
+ # The count tag can be either a numeric string or the name of
+ # a variable. If it is the name of a variable, the int(c)
+ # statement will throw an exception, and the except block will
+ # take over.
+
+ c = element.nsProp( "count", None )
+ try:
+ count = int(c)
+ self.count = count
+ self.counter = None
+ except Exception,e:
+ count = 1
+ self.count = 0
+ self.counter = c
+
+ self.count_scale = int(element.nsProp( "count_scale", None ))
+
+ elements = (count * self.count_scale)
+ if elements == 1:
+ elements = 0
+
+ #if ts == "GLdouble":
+ # print '/* stack size -> %s = %u (before)*/' % (self.name, self.type_expr.get_stack_size())
+ # print '/* # elements = %u */' % (elements)
+ self.type_expr.set_elements( elements )
+ #if ts == "GLdouble":
+ # print '/* stack size -> %s = %u (after) */' % (self.name, self.type_expr.get_stack_size())
+
+ self.is_counter = is_attr_true( element, 'counter' )
+ self.is_output = is_attr_true( element, 'output' )
+
+
+ # Pixel data has special parameters.
+
+ self.width = element.nsProp('img_width', None)
+ self.height = element.nsProp('img_height', None)
+ self.depth = element.nsProp('img_depth', None)
+ self.extent = element.nsProp('img_extent', None)
+
+ self.img_xoff = element.nsProp('img_xoff', None)
+ self.img_yoff = element.nsProp('img_yoff', None)
+ self.img_zoff = element.nsProp('img_zoff', None)
+ self.img_woff = element.nsProp('img_woff', None)
+
+ self.img_format = element.nsProp('img_format', None)
+ self.img_type = element.nsProp('img_type', None)
+ self.img_target = element.nsProp('img_target', None)
+
+ self.img_pad_dimensions = is_attr_true( element, 'img_pad_dimensions' )
+ self.img_null_flag = is_attr_true( element, 'img_null_flag' )
+ self.img_send_null = is_attr_true( element, 'img_send_null' )
+
+ return
+
+
+ def compatible(self, other):
+ return 1
+
+
+ def is_array(self):
+ return self.is_pointer()
+
+
+ def is_pointer(self):
+ return self.type_expr.is_pointer()
+
+
+ def is_image(self):
+ if self.width:
+ return 1
+ else:
+ return 0
+
+
+ def is_variable_length(self):
+ return len(self.count_parameter_list) or self.counter
+
+
+ def is_64_bit(self):
+ count = self.type_expr.get_element_count()
+ if count:
+ if (self.size() / count) == 8:
+ return 1
+ else:
+ if self.size() == 8:
+ return 1
+
+ return 0
+
+
+ def string(self):
+ return self.type_expr.original_string + " " + self.name
+
+
+ def type_string(self):
+ return self.type_expr.original_string
+
+
+ def get_base_type_string(self):
+ return self.type_expr.get_base_name()
+
+
+ def get_dimensions(self):
+ if not self.width:
+ return [ 0, "0", "0", "0", "0" ]
+
+ dim = 1
+ w = self.width
+ h = "1"
+ d = "1"
+ e = "1"
+
+ if self.height:
+ dim = 2
+ h = self.height
+
+ if self.depth:
+ dim = 3
+ d = self.depth
+
+ if self.extent:
+ dim = 4
+ e = self.extent
+
+ return [ dim, w, h, d, e ]
+
+
+ def get_stack_size(self):
+ return self.type_expr.get_stack_size()
+
+
+ def size(self):
+ if self.is_image():
+ return 0
+ else:
+ return self.type_expr.get_element_size()
+
+
+ def get_element_count(self):
+ c = self.type_expr.get_element_count()
+ if c == 0:
+ return 1
+
+ return c
+
+
+ def size_string(self, use_parens = 1):
+ s = self.size()
+ if self.counter or self.count_parameter_list:
+ list = [ "compsize" ]
+
+ if self.counter and self.count_parameter_list:
+ list.append( self.counter )
+ elif self.counter:
+ list = [ self.counter ]
+
+ if s > 1:
+ list.append( str(s) )
+
+ if len(list) > 1 and use_parens :
+ return "(%s)" % (string.join(list, " * "))
+ else:
+ return string.join(list, " * ")
+
+ elif self.is_image():
+ return "compsize"
+ else:
+ return str(s)
+
+
+ def format_string(self):
+ if self.type_expr.original_string == "GLenum":
+ return "0x%x"
+ else:
+ return self.type_expr.format_string()
+
+
+
+class gl_function( gl_item ):
+ def __init__(self, element, context):
+ self.context = context
+ self.name = None
+
+ self.entry_points = []
+ self.return_type = "void"
+ self.parameters = []
+ self.offset = -1
+ self.initialized = 0
+ self.images = []
+
+ # Track the parameter string (for the function prototype)
+ # for each entry-point. This is done because some functions
+ # change their prototype slightly when promoted from extension
+ # to ARB extension to core. glTexImage3DEXT and glTexImage3D
+ # are good examples of this. Scripts that need to generate
+ # code for these differing aliases need to real prototype
+ # for each entry-point. Otherwise, they may generate code
+ # that won't compile.
+
+ self.parameter_strings = {}
+
+ self.process_element( element )
+
+ return
+
+
+ def process_element(self, element):
+ name = element.nsProp( "name", None )
+ alias = element.nsProp( "alias", None )
+
+ self.entry_points.append( name )
+ if alias:
+ true_name = alias
+ else:
+ true_name = name
+
+ # Only try to set the offset when a non-alias
+ # entry-point is being processes.
+
+ offset = element.nsProp( "offset", None )
+ if offset:
+ try:
+ o = int( offset )
+ self.offset = o
+ except Exception, e:
+ self.offset = -1
+
+
+ if not self.name:
+ self.name = true_name
+ elif self.name != true_name:
+ raise RuntimeError("Function true name redefined. Was %s, now %s." % (self.name, true_name))
+
+
+ # There are two possible cases. The first time an entry-point
+ # with data is seen, self.initialized will be 0. On that
+ # pass, we just fill in the data. The next time an
+ # entry-point with data is seen, self.initialized will be 1.
+ # On that pass we have to make that the new values match the
+ # valuse from the previous entry-point.
+
+ parameters = []
+ return_type = "void"
+ child = element.children
+ while child:
+ if child.type == "element":
+ if child.name == "return":
+ return_type = child.nsProp( "type", None )
+ elif child.name == "param":
+ param = self.context.factory.create_item( "parameter", child, self.context)
+ parameters.append( param )
+
+ child = child.next
+
+
+ if self.initialized:
+ if self.return_type != return_type:
+ raise RuntimeError( "Return type changed in %s. Was %s, now %s." % (name, self.return_type, return_type))
+
+ if len(parameters) != len(self.parameters):
+ raise RuntimeError( "Parameter count mismatch in %s. Was %d, now %d." % (name, len(self.parameters), len(parameters)))
+
+ for j in range(0, len(parameters)):
+ p1 = parameters[j]
+ p2 = self.parameters[j]
+ if not p1.compatible( p2 ):
+ raise RuntimeError( 'Parameter type mismatch in %s. "%s" was "%s", now "%s".' % (name, p2.name, p2.type_expr.original_string, p1.type_expr.original_string))
+
+
+ if true_name == name or not self.initialized:
+ self.return_type = return_type
+ self.parameters = parameters
+
+ for param in self.parameters:
+ if param.is_image():
+ self.images.append( param )
+
+ if element.children:
+ self.initialized = 1
+ self.parameter_strings[name] = create_parameter_string(parameters, 1)
+ else:
+ self.parameter_strings[name] = None
+
+ return
+
+
+ def get_images(self):
+ """Return potentially empty list of input images."""
+ return self.images
+
+
+ def parameterIterator(self):
+ return self.parameters.__iter__();
+
+
+ def get_parameter_string(self, entrypoint = None):
+ if entrypoint:
+ s = self.parameter_strings[ entrypoint ]
+ if s:
+ return s
+
+ return create_parameter_string( self.parameters, 1 )
+
+
+class gl_item_factory:
+ """Factory to create objects derived from gl_item."""
+
+ def create_item(self, item_name, element, context):
+ if item_name == "function":
+ return gl_function(element, context)
+ if item_name == "type":
+ return gl_type(element, context)
+ elif item_name == "enum":
+ return gl_enum(element, context)
+ elif item_name == "parameter":
+ return gl_parameter(element, context)
+ elif item_name == "api":
+ return gl_api(self)
+ else:
+ return None
+
+
+class gl_api:
+ def __init__(self, factory):
+ self.functions_by_name = {}
+ self.enums_by_name = {}
+ self.types_by_name = {}
+ self.category_dict = {}
+
+ self.factory = factory
+
+ typeexpr.create_initial_types()
+ return
+
+
+ def process_element(self, doc):
+ element = doc.children
+ while element.type != "element" or element.name != "OpenGLAPI":
+ element = element.next
+
+ if element:
+ self.process_OpenGLAPI(element)
+ return
+
+
+ def process_OpenGLAPI(self, element):
+ child = element.children
+ while child:
+ if child.type == "element":
+ if child.name == "category":
+ self.process_category( child )
+ elif child.name == "OpenGLAPI":
+ self.process_OpenGLAPI( child )
+
+ child = child.next
+
+ return
+
+
+ def process_category(self, cat):
+ cat_name = cat.nsProp( "name", None )
+ cat_number = cat.nsProp( "number", None )
+
+ child = cat.children
+ while child:
+ if child.type == "element":
+ if child.name == "function":
+ func_name = real_function_name( child )
+
+ temp_name = child.nsProp( "name", None )
+ self.category_dict[ temp_name ] = [cat_name, cat_number]
+
+ if self.functions_by_name.has_key( func_name ):
+ func = self.functions_by_name[ func_name ]
+ func.process_element( child )
+ else:
+ func = self.factory.create_item( "function", child, self )
+ self.functions_by_name[ func_name ] = func
+
+
+ elif child.name == "enum":
+ enum = self.factory.create_item( "enum", child, self )
+ self.enums_by_name[ enum.name ] = enum
+ elif child.name == "type":
+ t = self.factory.create_item( "type", child, self )
+ self.types_by_name[ "GL" + t.name ] = t
+
+
+ child = child.next
+
+ return
+
+
+ def functionIterateByOffset(self):
+ max_offset = -1
+ for func in self.functions_by_name.itervalues():
+ if func.offset > max_offset:
+ max_offset = func.offset
+
+
+ temp = [None for i in range(0, max_offset + 1)]
+ for func in self.functions_by_name.itervalues():
+ if func.offset != -1:
+ temp[ func.offset ] = func
+
+
+ list = []
+ for i in range(0, max_offset + 1):
+ if temp[i]:
+ list.append(temp[i])
+
+ return list.__iter__();
+
+
+ def functionIterateAll(self):
+ return self.functions_by_name.itervalues()
+
+
+ def enumIterateByName(self):
+ keys = self.enums_by_name.keys()
+ keys.sort()
+
+ list = []
+ for enum in keys:
+ list.append( self.enums_by_name[ enum ] )
+
+ return list.__iter__()
+
+
+ def get_category_for_name( self, name ):
+ if self.category_dict.has_key(name):
+ return self.category_dict[name]
+ else:
+ return ["<unknown category>", None]
+
+
+ def typeIterate(self):
+ return self.types_by_name.itervalues()
+
+
+ def find_type( self, type_name ):
+ if type_name in self.types_by_name:
+ return self.types_by_name[ type_name ].type_expr
+ else:
+ print "Unable to find base type matching \"%s\"." % (type_name)
+ return None
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/gl_apitemp.py b/nx-X11/extras/Mesa/src/mesa/glapi/gl_apitemp.py
new file mode 100644
index 000000000..7cc434fa8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/gl_apitemp.py
@@ -0,0 +1,216 @@
+#!/usr/bin/env python
+
+# (C) Copyright IBM Corporation 2004, 2005
+# 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
+# IBM 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:
+# Ian Romanick <idr@us.ibm.com>
+
+import gl_XML
+import license
+import sys, getopt
+
+class PrintGlOffsets(gl_XML.gl_print_base):
+ def __init__(self):
+ gl_XML.gl_print_base.__init__(self)
+
+ self.name = "gl_apitemp.py (from Mesa)"
+ self.license = license.bsd_license_template % ( \
+"""Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+(C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM")
+
+ self.undef_list.append( "KEYWORD1" )
+ self.undef_list.append( "KEYWORD2" )
+ self.undef_list.append( "NAME" )
+ self.undef_list.append( "DISPATCH" )
+ self.undef_list.append( "RETURN_DISPATCH" )
+ self.undef_list.append( "DISPATCH_TABLE_NAME" )
+ self.undef_list.append( "UNUSED_TABLE_NAME" )
+ self.undef_list.append( "TABLE_ENTRY" )
+
+
+ def printFunction(self, f, name):
+ p_string = ""
+ o_string = ""
+ t_string = ""
+ comma = ""
+
+ for p in f.parameterIterator():
+ if p.is_pointer():
+ cast = "(const void *) "
+ else:
+ cast = ""
+
+ t_string = t_string + comma + p.format_string()
+ p_string = p_string + comma + p.name
+ o_string = o_string + comma + cast + p.name
+ comma = ", "
+
+
+ if f.return_type != 'void':
+ dispatch = "RETURN_DISPATCH"
+ else:
+ dispatch = "DISPATCH"
+
+ print 'KEYWORD1 %s KEYWORD2 NAME(%s)(%s)' \
+ % (f.return_type, name, f.get_parameter_string(name))
+ print '{'
+ if p_string == "":
+ print ' %s(%s, (), (F, "gl%s();\\n"));' \
+ % (dispatch, f.name, name)
+ else:
+ print ' %s(%s, (%s), (F, "gl%s(%s);\\n", %s));' \
+ % (dispatch, f.name, p_string, name, t_string, o_string)
+ print '}'
+ print ''
+ return
+
+ def printRealHeader(self):
+ print """
+/*
+ * This file is a template which generates the OpenGL API entry point
+ * functions. It should be included by a .c file which first defines
+ * the following macros:
+ * KEYWORD1 - usually nothing, but might be __declspec(dllexport) on Win32
+ * KEYWORD2 - usually nothing, but might be __stdcall on Win32
+ * NAME(n) - builds the final function name (usually add "gl" prefix)
+ * DISPATCH(func, args, msg) - code to do dispatch of named function.
+ * msg is a printf-style debug message.
+ * RETURN_DISPATCH(func, args, msg) - code to do dispatch with a return value
+ *
+ * Here is an example which generates the usual OpenGL functions:
+ * #define KEYWORD1
+ * #define KEYWORD2
+ * #define NAME(func) gl##func
+ * #define DISPATCH(func, args, msg) \\
+ * struct _glapi_table *dispatch = CurrentDispatch; \\
+ * (*dispatch->func) args
+ * #define RETURN DISPATCH(func, args, msg) \\
+ * struct _glapi_table *dispatch = CurrentDispatch; \\
+ * return (*dispatch->func) args
+ *
+ */
+
+
+#if defined( NAME )
+#ifndef KEYWORD1
+#define KEYWORD1
+#endif
+
+#ifndef KEYWORD2
+#define KEYWORD2
+#endif
+
+#ifndef DISPATCH
+#error DISPATCH must be defined
+#endif
+
+#ifndef RETURN_DISPATCH
+#error RETURN_DISPATCH must be defined
+#endif
+
+"""
+ return
+
+
+
+ def printInitDispatch(self, api):
+ print """
+#endif /* defined( NAME ) */
+
+/*
+ * This is how a dispatch table can be initialized with all the functions
+ * we generated above.
+ */
+#ifdef DISPATCH_TABLE_NAME
+
+#ifndef TABLE_ENTRY
+#error TABLE_ENTRY must be defined
+#endif
+
+static _glapi_proc DISPATCH_TABLE_NAME[] = {"""
+ for f in api.functionIterateByOffset():
+ print ' TABLE_ENTRY(%s),' % (f.name)
+
+ print ' /* A whole bunch of no-op functions. These might be called'
+ print ' * when someone tries to call a dynamically-registered'
+ print ' * extension function without a current rendering context.'
+ print ' */'
+ for i in range(1, 100):
+ print ' TABLE_ENTRY(Unused),'
+
+ print '};'
+ print '#endif /* DISPATCH_TABLE_NAME */'
+ print ''
+ return
+
+
+ def printAliasedTable(self, api):
+ print """
+/*
+ * This is just used to silence compiler warnings.
+ * We list the functions which are not otherwise used.
+ */
+#ifdef UNUSED_TABLE_NAME
+static _glapi_proc UNUSED_TABLE_NAME[] = {"""
+
+ for f in api.functionIterateByOffset():
+ for n in f.entry_points:
+ if n != f.name:
+ print ' TABLE_ENTRY(%s),' % (n)
+
+ print '};'
+ print '#endif /*UNUSED_TABLE_NAME*/'
+ print ''
+ return
+
+
+ def printBody(self, api):
+ for func in api.functionIterateByOffset():
+ for n in func.entry_points:
+ self.printFunction( func, n )
+
+ self.printInitDispatch(api)
+ self.printAliasedTable(api)
+ return
+
+
+def show_usage():
+ print "Usage: %s [-f input_file_name]" % sys.argv[0]
+ sys.exit(1)
+
+if __name__ == '__main__':
+ file_name = "gl_API.xml"
+
+ try:
+ (args, trail) = getopt.getopt(sys.argv[1:], "f:")
+ except Exception,e:
+ show_usage()
+
+ for (arg,val) in args:
+ if arg == "-f":
+ file_name = val
+
+ api = gl_XML.parse_GL_API( file_name )
+
+ printer = PrintGlOffsets()
+ printer.Print(api)
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/gl_enums.py b/nx-X11/extras/Mesa/src/mesa/glapi/gl_enums.py
new file mode 100644
index 000000000..33d621dcd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/gl_enums.py
@@ -0,0 +1,217 @@
+#!/usr/bin/python2
+# -*- Mode: Python; py-indent-offset: 8 -*-
+
+# (C) Copyright Zack Rusin 2005
+# 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
+# IBM 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:
+# Zack Rusin <zack@kde.org>
+
+import license
+import gl_XML
+import sys, getopt
+
+class PrintGlEnums(gl_XML.gl_print_base):
+
+ def __init__(self):
+ gl_XML.gl_print_base.__init__(self)
+
+ self.name = "gl_enums.py (from Mesa)"
+ self.license = license.bsd_license_template % ( \
+"""Copyright (C) 1999-2005 Brian Paul All Rights Reserved.""", "BRIAN PAUL")
+ self.enum_table = {}
+
+
+ def printRealHeader(self):
+ print '#include "glheader.h"'
+ print '#include "enums.h"'
+ print '#include "imports.h"'
+ print ''
+ print 'typedef struct {'
+ print ' size_t offset;'
+ print ' int n;'
+ print '} enum_elt;'
+ print ''
+ return
+
+ def print_code(self):
+ print """
+#define Elements(x) sizeof(x)/sizeof(*x)
+
+typedef int (*cfunc)(const void *, const void *);
+
+/**
+ * Compare a key name to an element in the \c all_enums array.
+ *
+ * \c bsearch always passes the key as the first parameter and the pointer
+ * to the array element as the second parameter. We can elimiate some
+ * extra work by taking advantage of that fact.
+ *
+ * \param a Pointer to the desired enum name.
+ * \param b Pointer to an element of the \c all_enums array.
+ */
+static int compar_name( const char *a, const enum_elt *b )
+{
+ return _mesa_strcmp( a, & enum_string_table[ b->offset ] );
+}
+
+/**
+ * Compare a key enum value to an element in the \c all_enums array.
+ *
+ * \c bsearch always passes the key as the first parameter and the pointer
+ * to the array element as the second parameter. We can elimiate some
+ * extra work by taking advantage of that fact.
+ *
+ * \param a Pointer to the desired enum name.
+ * \param b Pointer to an index into the \c all_enums array.
+ */
+static int compar_nr( const int *a, const unsigned *b )
+{
+ return a[0] - all_enums[*b].n;
+}
+
+
+static char token_tmp[20];
+
+const char *_mesa_lookup_enum_by_nr( int nr )
+{
+ unsigned * i;
+
+ i = (unsigned *)bsearch( & nr, reduced_enums, Elements(reduced_enums),
+ sizeof(reduced_enums[0]), (cfunc) compar_nr );
+
+ if ( i != NULL ) {
+ return & enum_string_table[ all_enums[ *i ].offset ];
+ }
+ else {
+ /* this is not re-entrant safe, no big deal here */
+ _mesa_sprintf(token_tmp, "0x%x", nr);
+ return token_tmp;
+ }
+}
+
+int _mesa_lookup_enum_by_name( const char *symbol )
+{
+ enum_elt * f = NULL;
+
+ if ( symbol != NULL ) {
+ f = (enum_elt *)bsearch( symbol, all_enums, Elements(all_enums),
+ sizeof( enum_elt ), (cfunc) compar_name );
+ }
+
+ return (f != NULL) ? f->n : -1;
+}
+
+"""
+ return
+
+
+ def printBody(self, api):
+ self.process_enums( api )
+
+ keys = self.enum_table.keys()
+ keys.sort()
+
+ name_table = []
+ enum_table = {}
+
+ for enum in keys:
+ low_pri = 9
+ for [name, pri] in self.enum_table[ enum ]:
+ name_table.append( [name, enum] )
+
+ if pri < low_pri:
+ low_pri = pri
+ enum_table[enum] = name
+
+
+ name_table.sort()
+
+ string_offsets = {}
+ i = 0;
+ print 'static const char enum_string_table[] = '
+ for [name, enum] in name_table:
+ print ' "%s\\0"' % (name)
+ string_offsets[ name ] = i
+ i += len(name) + 1
+
+ print ' ;'
+ print ''
+
+
+ print 'static const enum_elt all_enums[%u] =' % (len(name_table))
+ print '{'
+ for [name, enum] in name_table:
+ print ' { % 5u, 0x%08X }, /* %s */' % (string_offsets[name], enum, name)
+ print '};'
+ print ''
+
+ print 'static const unsigned reduced_enums[%u] =' % (len(keys))
+ print '{'
+ for enum in keys:
+ name = enum_table[ enum ]
+ if [name, enum] not in name_table:
+ print ' /* Error! %s, 0x%04x */ 0,' % (name, enum)
+ else:
+ i = name_table.index( [name, enum] )
+
+ print ' % 4u, /* %s */' % (i, name)
+ print '};'
+
+
+ self.print_code()
+ return
+
+
+ def process_enums(self, api):
+ self.enum_table = {}
+
+ for obj in api.enumIterateByName():
+ if obj.value not in self.enum_table:
+ self.enum_table[ obj.value ] = []
+
+
+ name = "GL_" + obj.name
+ priority = obj.priority()
+ self.enum_table[ obj.value ].append( [name, priority] )
+
+
+def show_usage():
+ print "Usage: %s [-f input_file_name]" % sys.argv[0]
+ sys.exit(1)
+
+if __name__ == '__main__':
+ file_name = "gl_API.xml"
+
+ try:
+ (args, trail) = getopt.getopt(sys.argv[1:], "f:")
+ except Exception,e:
+ show_usage()
+
+ for (arg,val) in args:
+ if arg == "-f":
+ file_name = val
+
+ api = gl_XML.parse_GL_API( file_name )
+
+ printer = PrintGlEnums()
+ printer.Print( api )
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/gl_offsets.py b/nx-X11/extras/Mesa/src/mesa/glapi/gl_offsets.py
new file mode 100644
index 000000000..2966e3b62
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/gl_offsets.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python
+
+# (C) Copyright IBM Corporation 2004, 2005
+# 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
+# IBM 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:
+# Ian Romanick <idr@us.ibm.com>
+
+import gl_XML
+import license
+import sys, getopt
+
+class PrintGlOffsets(gl_XML.gl_print_base):
+ def __init__(self):
+ gl_XML.gl_print_base.__init__(self)
+
+ self.name = "gl_offsets.py (from Mesa)"
+ self.header_tag = '_GLAPI_OFFSETS_H_'
+ self.license = license.bsd_license_template % ( \
+"""Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+(C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM")
+ return
+
+ def printBody(self, api):
+ abi = [ "1.0", "1.1", "1.2", "GL_ARB_multitexture" ]
+
+ functions = []
+ abi_functions = []
+ count = 0
+ for f in api.functionIterateByOffset():
+ [category, num] = api.get_category_for_name( f.name )
+ if category not in abi:
+ functions.append( [f, count] )
+ count += 1
+ else:
+ abi_functions.append( f )
+
+
+ for f in abi_functions:
+ print '#define _gloffset_%s %d' % (f.name, f.offset)
+ last_static = f.offset
+
+ print ''
+ print '#if !defined(IN_DRI_DRIVER)'
+ print ''
+
+ for [f, index] in functions:
+ print '#define _gloffset_%s %d' % (f.name, f.offset)
+ if f.offset > last_static:
+ last_static = f.offset
+
+ print '#define _gloffset_FIRST_DYNAMIC %d' % (last_static + 1)
+
+ print ''
+ print '#else'
+ print ''
+
+ for [f, index] in functions:
+ print '#define _gloffset_%s driDispatchRemapTable[%s_remap_index]' % (f.name, f.name)
+
+ print ''
+ print '#endif /* !defined(IN_DRI_DRIVER) */'
+
+ return
+
+
+def show_usage():
+ print "Usage: %s [-f input_file_name]" % sys.argv[0]
+ sys.exit(1)
+
+if __name__ == '__main__':
+ file_name = "gl_API.xml"
+
+ try:
+ (args, trail) = getopt.getopt(sys.argv[1:], "f:")
+ except Exception,e:
+ show_usage()
+
+ for (arg,val) in args:
+ if arg == "-f":
+ file_name = val
+
+ api = gl_XML.parse_GL_API( file_name )
+
+ printer = PrintGlOffsets()
+ printer.Print( api )
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/gl_procs.py b/nx-X11/extras/Mesa/src/mesa/glapi/gl_procs.py
new file mode 100644
index 000000000..1ad683de5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/gl_procs.py
@@ -0,0 +1,155 @@
+#!/usr/bin/env python
+
+# (C) Copyright IBM Corporation 2004, 2005
+# 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
+# IBM 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:
+# Ian Romanick <idr@us.ibm.com>
+
+import license
+import gl_XML
+import sys, getopt
+
+class PrintGlProcs(gl_XML.gl_print_base):
+ def __init__(self, long_strings):
+ gl_XML.gl_print_base.__init__(self)
+
+ self.long_strings = long_strings
+ self.name = "gl_procs.py (from Mesa)"
+ self.license = license.bsd_license_template % ( \
+"""Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+(C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM")
+
+
+ def printRealHeader(self):
+ print '/* This file is only included by glapi.c and is used for'
+ print ' * the GetProcAddress() function'
+ print ' */'
+ print ''
+ print 'typedef struct {'
+ print ' GLint Name_offset;'
+ print '#ifdef NEED_FUNCTION_POINTER'
+ print ' _glapi_proc Address;'
+ print '#endif'
+ print ' GLuint Offset;'
+ print '} glprocs_table_t;'
+ print ''
+ print '#ifdef NEED_FUNCTION_POINTER'
+ print '# define NAME_FUNC_OFFSET(n,f,o) { n , (_glapi_proc) f , o }'
+ print '#else'
+ print '# define NAME_FUNC_OFFSET(n,f,o) { n , o }'
+ print '#endif'
+ print ''
+ return
+
+ def printRealFooter(self):
+ print ''
+ print '#undef NAME_FUNC_OFFSET'
+ return
+
+ def printFunctionString(self, name):
+ if self.long_strings:
+ print ' "gl%s\\0"' % (name)
+ else:
+ print " 'g','l',",
+ for c in name:
+ print "'%s'," % (c),
+
+ print "'\\0',"
+
+
+ def printBody(self, api):
+ print ''
+ if self.long_strings:
+ print 'static const char gl_string_table[] ='
+ else:
+ print 'static const char gl_string_table[] = {'
+
+ base_offset = 0
+ table = []
+ for func in api.functionIterateByOffset():
+ self.printFunctionString( func.name )
+ table.append((base_offset, func.name, func.name))
+
+ # The length of the function's name, plus 2 for "gl",
+ # plus 1 for the NUL.
+
+ base_offset += len(func.name) + 3
+
+
+ for func in api.functionIterateByOffset():
+ for n in func.entry_points:
+ if n != func.name:
+ self.printFunctionString( n )
+ table.append((base_offset, n, func.name))
+ base_offset += len(n) + 3
+
+
+ if self.long_strings:
+ print ' ;'
+ else:
+ print '};'
+
+ print ''
+ print 'static const glprocs_table_t static_functions[] = {'
+
+ for (offset, disp_name, real_name) in table:
+ print ' NAME_FUNC_OFFSET( % 5u, gl%s, _gloffset_%s ),' % (offset, disp_name, real_name)
+
+ print ' NAME_FUNC_OFFSET( -1, NULL, 0 )'
+ print '};'
+ return
+
+
+def show_usage():
+ print "Usage: %s [-f input_file_name] [-m mode]" % sys.argv[0]
+ print "mode can be one of:"
+ print " long - Create code for compilers that can handle very "
+ print " long string constants. (default)"
+ print " short - Create code for compilers that can only handle "
+ print " ANSI C89 string constants."
+ sys.exit(1)
+
+if __name__ == '__main__':
+ file_name = "gl_API.xml"
+
+ try:
+ (args, trail) = getopt.getopt(sys.argv[1:], "f:m:")
+ except Exception,e:
+ show_usage()
+
+ long_string = 1
+ for (arg,val) in args:
+ if arg == "-f":
+ file_name = val
+ elif arg == "-m":
+ if val == "short":
+ long_string = 0
+ elif val == "long":
+ long_string = 1
+ else:
+ show_usage()
+
+ api = gl_XML.parse_GL_API( file_name )
+
+ printer = PrintGlProcs( long_string )
+ printer.Print( api )
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/gl_table.py b/nx-X11/extras/Mesa/src/mesa/glapi/gl_table.py
new file mode 100644
index 000000000..52b4be1d2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/gl_table.py
@@ -0,0 +1,194 @@
+#!/usr/bin/python2
+
+# (C) Copyright IBM Corporation 2004
+# 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
+# IBM 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:
+# Ian Romanick <idr@us.ibm.com>
+
+import gl_XML
+import license
+import sys, getopt
+
+class PrintGlTable(gl_XML.gl_print_base):
+ def __init__(self):
+ gl_XML.gl_print_base.__init__(self)
+
+ self.header_tag = '_GLAPI_TABLE_H_'
+ self.name = "gl_table.py (from Mesa)"
+ self.license = license.bsd_license_template % ( \
+"""Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+(C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM")
+ return
+
+
+ def printBody(self, api):
+ for f in api.functionIterateByOffset():
+ arg_string = f.get_parameter_string()
+ print ' %s (GLAPIENTRYP %s)(%s); /* %d */' % (f.return_type, f.name, arg_string, f.offset)
+
+
+ def printRealHeader(self):
+ print '#ifndef GLAPIENTRYP'
+ print '#define GLAPIENTRYP'
+ print '#endif'
+ print ''
+ print 'typedef void (*_glapi_proc)(void); /* generic function pointer */'
+ print ''
+ print 'struct _glapi_table'
+ print '{'
+ return
+
+
+ def printRealFooter(self):
+ print '};'
+ return
+
+
+class PrintRemapTable(gl_XML.gl_print_base):
+ def __init__(self):
+ gl_XML.gl_print_base.__init__(self)
+
+ self.header_tag = '_DISPATCH_H_'
+ self.name = "gl_table.py (from Mesa)"
+ self.license = license.bsd_license_template % ("(C) Copyright IBM Corporation 2005", "IBM")
+ return
+
+
+ def printRealHeader(self):
+ print """/**
+ * \\file dispatch.h
+ * Macros for handling GL dispatch tables.
+ *
+ * For each known GL function, there are 3 macros in this file. The first
+ * macro is named CALL_FuncName and is used to call that GL function using
+ * the specified dispatch table. The other 2 macros, called GET_FuncName
+ * can SET_FuncName, are used to get and set the dispatch pointer for the
+ * named function in the specified dispatch table.
+ */
+"""
+
+ return
+
+ def printBody(self, api):
+ print '#define CALL_by_offset(disp, cast, offset, parameters) \\'
+ print ' (*(cast (GET_by_offset(disp, offset)))) parameters'
+ print '#define GET_by_offset(disp, offset) \\'
+ print ' (offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : NULL'
+ print '#define SET_by_offset(disp, offset, fn) \\'
+ print ' do { \\'
+ print ' if ( (offset) < 0 ) { \\'
+ print ' /* fprintf( stderr, "[%s:%u] SET_by_offset(%p, %d, %s)!\\n", */ \\'
+ print ' /* __func__, __LINE__, disp, offset, # fn); */ \\'
+ print ' /* abort(); */ \\'
+ print ' } \\'
+ print ' else { \\'
+ print ' ( (_glapi_proc *) (disp) )[offset] = (_glapi_proc) fn; \\'
+ print ' } \\'
+ print ' } while(0)'
+ print ''
+
+ abi = [ "1.0", "1.1", "1.2", "GL_ARB_multitexture" ]
+
+ functions = []
+ abi_functions = []
+ count = 0
+ for f in api.functionIterateByOffset():
+ [category, num] = api.get_category_for_name( f.name )
+ if category not in abi:
+ functions.append( [f, count] )
+ count += 1
+ else:
+ abi_functions.append( f )
+
+
+ for f in abi_functions:
+ print '#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name)
+ print '#define GET_%s(disp) ((disp)->%s)' % (f.name, f.name)
+ print '#define SET_%s(disp, fn) ((disp)->%s = fn)' % (f.name, f.name)
+
+
+ print ''
+ print '#if !defined(IN_DRI_DRIVER)'
+ print ''
+
+ for [f, index] in functions:
+ print '#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name)
+ print '#define GET_%s(disp) ((disp)->%s)' % (f.name, f.name)
+ print '#define SET_%s(disp, fn) ((disp)->%s = fn)' % (f.name, f.name)
+
+ print ''
+ print '#else'
+ print ''
+ print '#define driDispatchRemapTable_size %u' % (count)
+ print 'extern int driDispatchRemapTable[ driDispatchRemapTable_size ];'
+ print ''
+
+ for [f, index] in functions:
+ print '#define %s_remap_index %u' % (f.name, index)
+
+ print ''
+
+ for [f, index] in functions:
+ arg_string = gl_XML.create_parameter_string( f.parameters, 0 )
+ cast = '%s (GLAPIENTRYP)(%s)' % (f.return_type, arg_string)
+
+ print '#define CALL_%s(disp, parameters) CALL_by_offset(disp, (%s), driDispatchRemapTable[%s_remap_index], parameters)' % (f.name, cast, f.name)
+ print '#define GET_%s(disp) GET_by_offset(disp, driDispatchRemapTable[%s_remap_index])' % (f.name, f.name)
+ print '#define SET_%s(disp, fn) SET_by_offset(disp, driDispatchRemapTable[%s_remap_index], fn)' % (f.name, f.name)
+
+
+ print ''
+ print '#endif /* !defined(IN_DRI_DRIVER) */'
+ return
+
+
+def show_usage():
+ print "Usage: %s [-f input_file_name] [-m mode]" % sys.argv[0]
+ print " -m mode Mode can be 'table' or 'remap_table'."
+ sys.exit(1)
+
+if __name__ == '__main__':
+ file_name = "gl_API.xml"
+
+ try:
+ (args, trail) = getopt.getopt(sys.argv[1:], "f:m:")
+ except Exception,e:
+ show_usage()
+
+ mode = "table"
+ for (arg,val) in args:
+ if arg == "-f":
+ file_name = val
+ elif arg == "-m":
+ mode = val
+
+ if mode == "table":
+ printer = PrintGlTable()
+ elif mode == "remap_table":
+ printer = PrintRemapTable()
+ else:
+ show_usage()
+
+ api = gl_XML.parse_GL_API( file_name )
+
+ printer.Print( api )
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/gl_x86-64_asm.py b/nx-X11/extras/Mesa/src/mesa/glapi/gl_x86-64_asm.py
new file mode 100644
index 000000000..1bfe3db59
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/gl_x86-64_asm.py
@@ -0,0 +1,316 @@
+#!/usr/bin/env python
+
+# (C) Copyright IBM Corporation 2005
+# 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
+# IBM 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:
+# Ian Romanick <idr@us.ibm.com>
+
+import gl_XML, license
+import sys, getopt, copy
+
+def should_use_push(registers):
+ for [reg, offset] in registers:
+ if reg[1:4] == "xmm":
+ return 0
+
+ N = len(registers)
+ return (N & 1) != 0
+
+
+def local_size(registers):
+ # The x86-64 ABI says "the value (%rsp - 8) is always a multiple of
+ # 16 when control is transfered to the function entry point." This
+ # means that the local stack usage must be (16*N)+8 for some value
+ # of N. (16*N)+8 = (8*(2N))+8 = 8*(2N+1). As long as N is odd, we
+ # meet this requirement.
+
+ N = (len(registers) | 1)
+ return 8*N
+
+
+def save_all_regs(registers):
+ adjust_stack = 0
+ if not should_use_push(registers):
+ adjust_stack = local_size(registers)
+ print '\tsubq\t$%u, %%rsp' % (adjust_stack)
+
+ for [reg, stack_offset] in registers:
+ save_reg( reg, stack_offset, adjust_stack )
+ return
+
+
+def restore_all_regs(registers):
+ adjust_stack = 0
+ if not should_use_push(registers):
+ adjust_stack = local_size(registers)
+
+ temp = copy.deepcopy(registers)
+ while len(temp):
+ [reg, stack_offset] = temp.pop()
+ restore_reg(reg, stack_offset, adjust_stack)
+
+ if adjust_stack:
+ print '\taddq\t$%u, %%rsp' % (adjust_stack)
+ return
+
+
+def save_reg(reg, offset, use_move):
+ if use_move:
+ if offset == 0:
+ print '\tmovq\t%s, (%%rsp)' % (reg)
+ else:
+ print '\tmovq\t%s, %u(%%rsp)' % (reg, offset)
+ else:
+ print '\tpushq\t%s' % (reg)
+
+ return
+
+
+def restore_reg(reg, offset, use_move):
+ if use_move:
+ if offset == 0:
+ print '\tmovq\t(%%rsp), %s' % (reg)
+ else:
+ print '\tmovq\t%u(%%rsp), %s' % (offset, reg)
+ else:
+ print '\tpopq\t%s' % (reg)
+
+ return
+
+
+class PrintGenericStubs(gl_XML.gl_print_base):
+
+ def __init__(self):
+ gl_XML.gl_print_base.__init__(self)
+
+ self.name = "gl_x86-64_asm.py (from Mesa)"
+ self.license = license.bsd_license_template % ("(C) Copyright IBM Corporation 2005", "IBM")
+ return
+
+
+ def get_stack_size(self, f):
+ size = 0
+ for p in f.parameterIterator():
+ size += p.get_stack_size()
+
+ return size
+
+
+ def printRealHeader(self):
+ print "/* If we build with gcc's -fvisibility=hidden flag, we'll need to change"
+ print " * the symbol visibility mode to 'default'."
+ print ' */'
+ print ''
+ print '#include "assyntax.h"'
+ print ''
+ print '#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303'
+ print '# pragma GCC visibility push(default)'
+ print '# define HIDDEN(x) .hidden x'
+ print '#else'
+ print '# define HIDDEN(x)'
+ print '#endif'
+ print ''
+ print '# if defined(USE_MGL_NAMESPACE)'
+ print '# define GL_PREFIX(n) GLNAME(CONCAT(mgl,n))'
+ print '# else'
+ print '# define GL_PREFIX(n) GLNAME(CONCAT(gl,n))'
+ print '# endif'
+ print ''
+ print '#if defined(PTHREADS) || defined(USE_XTHREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)'
+ print '# define THREADS'
+ print '#endif'
+ print ''
+ print '\t.text'
+ print ''
+ print '#ifdef GLX_USE_TLS'
+ print ''
+ print '\t.globl _x86_64_get_get_dispatch; HIDDEN(_x86_64_get_get_dispatch)'
+ print '_x86_64_get_get_dispatch:'
+ print '\tlea\t_x86_64_get_dispatch(%rip), %rax'
+ print '\tret'
+ print ''
+ print '\t.p2align\t4,,15'
+ print '_x86_64_get_dispatch:'
+ print '\tmovq\t_glapi_tls_Dispatch@GOTTPOFF(%rip), %rax'
+ print '\tmovq\t%fs:(%rax), %rax'
+ print '\tret'
+ print '\t.size\t_x86_64_get_dispatch, .-_x86_64_get_dispatch'
+ print ''
+ print '#elif defined(PTHREADS)'
+ print ''
+ print '\t.extern\t_glapi_Dispatch'
+ print '\t.extern\t_gl_DispatchTSD'
+ print '\t.extern\tpthread_getspecific'
+ print ''
+ print '\t.p2align\t4,,15'
+ print '_x86_64_get_dispatch:'
+ print '\tmovq\t_gl_DispatchTSD(%rip), %rdi'
+ print '\tjmp\tpthread_getspecific@PLT'
+ print ''
+ print '#elif defined(THREADS)'
+ print ''
+ print '\t.extern\t_glapi_get_dispatch'
+ print ''
+ print '#endif'
+ print ''
+ return
+
+
+ def printRealFooter(self):
+ print ''
+ print '#if defined(GLX_USE_TLS) && defined(__linux__)'
+ print ' .section ".note.ABI-tag", "a"'
+ print ' .p2align 2'
+ print ' .long 1f - 0f /* name length */'
+ print ' .long 3f - 2f /* data length */'
+ print ' .long 1 /* note length */'
+ print '0: .asciz "GNU" /* vendor name */'
+ print '1: .p2align 2'
+ print '2: .long 0 /* note data: the ABI tag */'
+ print ' .long 2,4,20 /* Minimum kernel version w/TLS */'
+ print '3: .p2align 2 /* pad out section */'
+ print '#endif /* GLX_USE_TLS */'
+ return
+
+
+ def printFunction(self, f):
+
+ # The x86-64 ABI divides function parameters into a couple
+ # classes. For the OpenGL interface, the only ones that are
+ # relevent are INTEGER and SSE. Basically, the first 8
+ # GLfloat or GLdouble parameters are placed in %xmm0 - %xmm7,
+ # the first 6 non-GLfloat / non-GLdouble parameters are placed
+ # in registers listed in int_parameters.
+ #
+ # If more parameters than that are required, they are passed
+ # on the stack. Therefore, we just have to make sure that
+ # %esp hasn't changed when we jump to the actual function.
+ # Since we're jumping to the function (and not calling it), we
+ # have to make sure of that anyway!
+
+ int_parameters = ["%rdi", "%rsi", "%rdx", "%rcx", "%r8", "%r9"]
+
+ int_class = 0
+ sse_class = 0
+ stack_offset = 0
+ registers = []
+ for p in f.parameterIterator():
+ type_name = p.get_base_type_string()
+
+ if p.is_pointer() or (type_name != "GLfloat" and type_name != "GLdouble"):
+ if int_class < 6:
+ registers.append( [int_parameters[int_class], stack_offset] )
+ int_class += 1
+ stack_offset += 8
+ else:
+ if sse_class < 8:
+ registers.append( ["%%xmm%u" % (sse_class), stack_offset] )
+ sse_class += 1
+ stack_offset += 8
+
+ if ((int_class & 1) == 0) and (sse_class == 0):
+ registers.append( ["%rbp", 0] )
+
+
+ print '\t.p2align\t4,,15'
+ print '\t.globl\tGL_PREFIX(%s)' % (f.name)
+ print '\t.type\tGL_PREFIX(%s), @function' % (f.name)
+ print 'GL_PREFIX(%s):' % (f.name)
+ print '#if defined(GLX_USE_TLS)'
+ print '\tcall\t_x86_64_get_dispatch@PLT'
+ print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)
+ print '\tjmp\t*%r11'
+ print '#elif defined(PTHREADS)'
+
+ save_all_regs(registers)
+ print '\tcall\t_x86_64_get_dispatch@PLT'
+ restore_all_regs(registers)
+
+ if f.offset == 0:
+ print '\tmovq\t(%rax), %r11'
+ else:
+ print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)
+
+ print '\tjmp\t*%r11'
+
+ print '#else'
+ print '\tmovq\t_glapi_Dispatch(%rip), %rax'
+ print '\ttestq\t%rax, %rax'
+ print '\tje\t1f'
+ print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)
+ print '\tjmp\t*%r11'
+ print '1:'
+
+ save_all_regs(registers)
+ print '\tcall\t_glapi_get_dispatch'
+ restore_all_regs(registers)
+
+ print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)
+ print '\tjmp\t*%r11'
+ print '#endif /* defined(GLX_USE_TLS) */'
+
+ print '\t.size\tGL_PREFIX(%s), .-GL_PREFIX(%s)' % (f.name, f.name)
+ print ''
+ return
+
+
+ def printBody(self, api):
+ for f in api.functionIterateByOffset():
+ self.printFunction(f)
+
+
+ for f in api.functionIterateByOffset():
+ for n in f.entry_points:
+ if n != f.name:
+ print '\t.globl GL_PREFIX(%s) ; .set GL_PREFIX(%s), GL_PREFIX(%s)' % (n, n, f.name)
+
+ return
+
+def show_usage():
+ print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]
+ sys.exit(1)
+
+if __name__ == '__main__':
+ file_name = "gl_API.xml"
+ mode = "generic"
+
+ try:
+ (args, trail) = getopt.getopt(sys.argv[1:], "m:f:")
+ except Exception,e:
+ show_usage()
+
+ for (arg,val) in args:
+ if arg == '-m':
+ mode = val
+ elif arg == "-f":
+ file_name = val
+
+ if mode == "generic":
+ printer = PrintGenericStubs()
+ else:
+ print "ERROR: Invalid mode \"%s\" specified." % mode
+ show_usage()
+
+ api = gl_XML.parse_GL_API( file_name )
+
+ printer.Print( api )
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/gl_x86_asm.py b/nx-X11/extras/Mesa/src/mesa/glapi/gl_x86_asm.py
new file mode 100644
index 000000000..e62687a72
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/gl_x86_asm.py
@@ -0,0 +1,240 @@
+#!/usr/bin/env python
+
+# (C) Copyright IBM Corporation 2004, 2005
+# 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
+# IBM 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:
+# Ian Romanick <idr@us.ibm.com>
+
+import gl_XML, license
+import sys, getopt
+
+class PrintGenericStubs(gl_XML.gl_print_base):
+
+ def __init__(self):
+ gl_XML.gl_print_base.__init__(self)
+
+ self.name = "gl_x86_asm.py (from Mesa)"
+ self.license = license.bsd_license_template % ( \
+"""Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+(C) Copyright IBM Corporation 2004, 2005""", "BRIAN PAUL, IBM")
+ return
+
+
+ def get_stack_size(self, f):
+ size = 0
+ for p in f.parameterIterator():
+ size += p.get_stack_size()
+
+ return size
+
+
+ def printRealHeader(self):
+ print '#include "assyntax.h"'
+ print '#include "glapioffsets.h"'
+ print ''
+ print '#if defined(STDCALL_API)'
+ print '# if defined(USE_MGL_NAMESPACE)'
+ print '# define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n2))'
+ print '# else'
+ print '# define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n2))'
+ print '# endif'
+ print '#else'
+ print '# if defined(USE_MGL_NAMESPACE)'
+ print '# define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n))'
+ print '# else'
+ print '# define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n))'
+ print '# endif'
+ print '#endif'
+ print ''
+ print '#define GL_OFFSET(x) CODEPTR(REGOFF(4 * x, EAX))'
+ print ''
+ print '#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__)'
+ print '#define GLOBL_FN(x) GLOBL x ; .type x, function'
+ print '#else'
+ print '#define GLOBL_FN(x) GLOBL x'
+ print '#endif'
+ print ''
+ print '#if defined(PTHREADS) || defined(USE_XTHREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)'
+ print '# define THREADS'
+ print '#endif'
+ print ''
+ print '#ifdef GLX_USE_TLS'
+ print ''
+ print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\'
+ print 'ALIGNTEXT16;\t\t\t\t\t\t\\'
+ print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'
+ print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'
+ print '\tCALL(_x86_get_dispatch) ;\t\t\t\\'
+ print '\tNOP ;\t\t\t\t\t\t\\'
+ print '\tJMP(GL_OFFSET(off))'
+ print ''
+ print '#elif defined(PTHREADS)'
+ print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\'
+ print 'ALIGNTEXT16;\t\t\t\t\t\t\\'
+ print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'
+ print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'
+ print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\'
+ print '\tTEST_L(EAX, EAX) ;\t\t\t\t\\'
+ print '\tJE(1f) ;\t\t\t\t\t\\'
+ print '\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\'
+ print '1:\tCALL(_x86_get_dispatch) ;\t\t\t\\'
+ print '\tJMP(GL_OFFSET(off))'
+ print '#elif defined(THREADS)'
+ print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\'
+ print 'ALIGNTEXT16;\t\t\t\t\t\t\\'
+ print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'
+ print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'
+ print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\'
+ print '\tTEST_L(EAX, EAX) ;\t\t\t\t\\'
+ print '\tJE(1f) ;\t\t\t\t\t\\'
+ print '\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\'
+ print '1:\tCALL(_glapi_get_dispatch) ;\t\t\t\\'
+ print '\tJMP(GL_OFFSET(off))'
+ print '#else /* Non-threaded version. */'
+ print '# define GL_STUB(fn,off,fn_alt)\t\t\t\\'
+ print 'ALIGNTEXT16;\t\t\t\t\t\t\\'
+ print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'
+ print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'
+ print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\'
+ print '\tJMP(GL_OFFSET(off))'
+ print '#endif'
+ print ''
+ print '#ifdef HAVE_ALIAS'
+ print '# define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\'
+ print '\t.globl\tGL_PREFIX(fn, fn_alt) ;\t\t\t\\'
+ print '\t.set\tGL_PREFIX(fn, fn_alt), GL_PREFIX(alias, alias_alt)'
+ print '#else'
+ print '# define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\'
+ print ' GL_STUB(fn, off, fn_alt)'
+ print '#endif'
+ print ''
+ print 'SEG_TEXT'
+ print ''
+ print '#ifdef GLX_USE_TLS'
+ print ''
+ print '\tGLOBL\tGLNAME(_x86_get_dispatch)'
+ print '\tHIDDEN(GLNAME(_x86_get_dispatch))'
+ print 'ALIGNTEXT16'
+ print 'GLNAME(_x86_get_dispatch):'
+ print '\tmovl\t%gs:_glapi_tls_Dispatch@NTPOFF, %eax'
+ print '\tret'
+ print ''
+ print '#elif defined(PTHREADS)'
+ print 'EXTERN GLNAME(_glapi_Dispatch)'
+ print 'EXTERN GLNAME(_gl_DispatchTSD)'
+ print 'EXTERN GLNAME(pthread_getspecific)'
+ print ''
+ print 'ALIGNTEXT16'
+ print 'GLNAME(_x86_get_dispatch):'
+ print '\tSUB_L(CONST(24), ESP)'
+ print '\tPUSH_L(GLNAME(_gl_DispatchTSD))'
+ print '\tCALL(GLNAME(pthread_getspecific))'
+ print '\tADD_L(CONST(28), ESP)'
+ print '\tRET'
+ print '#elif defined(THREADS)'
+ print 'EXTERN GLNAME(_glapi_get_dispatch)'
+ print '#endif'
+ print ''
+
+ print '#if defined( GLX_USE_TLS )'
+ print '\t\t.section\twtext, "awx", @progbits'
+ print '#endif /* defined( GLX_USE_TLS ) */'
+
+ print ''
+ print '\t\tALIGNTEXT16'
+ print '\t\tGLOBL GLNAME(gl_dispatch_functions_start)'
+ print '\t\tHIDDEN(GLNAME(gl_dispatch_functions_start))'
+ print 'GLNAME(gl_dispatch_functions_start):'
+ print ''
+ return
+
+
+ def printRealFooter(self):
+ print ''
+ print '\t\tGLOBL\tGLNAME(gl_dispatch_functions_end)'
+ print '\t\tHIDDEN(GLNAME(gl_dispatch_functions_end))'
+ print '\t\tALIGNTEXT16'
+ print 'GLNAME(gl_dispatch_functions_end):'
+ print ''
+ print '#if defined(GLX_USE_TLS) && defined(__linux__)'
+ print ' .section ".note.ABI-tag", "a"'
+ print ' .p2align 2'
+ print ' .long 1f - 0f /* name length */'
+ print ' .long 3f - 2f /* data length */'
+ print ' .long 1 /* note length */'
+ print '0: .asciz "GNU" /* vendor name */'
+ print '1: .p2align 2'
+ print '2: .long 0 /* note data: the ABI tag */'
+ print ' .long 2,4,20 /* Minimum kernel version w/TLS */'
+ print '3: .p2align 2 /* pad out section */'
+ print '#endif /* GLX_USE_TLS */'
+ return
+
+
+ def printBody(self, api):
+ for f in api.functionIterateByOffset():
+ stack = self.get_stack_size(f)
+
+ alt = "%s@%u" % (f.name, stack)
+ print '\tGL_STUB(%s, _gloffset_%s, %s)' % (f.name, f.name, alt)
+
+ for f in api.functionIterateByOffset():
+ stack = self.get_stack_size(f)
+
+ alt = "%s@%u" % (f.name, stack)
+
+ for n in f.entry_points:
+ if n != f.name:
+ alt2 = "%s@%u" % (n, stack)
+ print '\tGL_STUB_ALIAS(%s, _gloffset_%s, %s, %s, %s)' % (n, f.name, alt2, f.name, alt)
+
+ return
+
+def show_usage():
+ print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]
+ sys.exit(1)
+
+if __name__ == '__main__':
+ file_name = "gl_API.xml"
+ mode = "generic"
+
+ try:
+ (args, trail) = getopt.getopt(sys.argv[1:], "m:f:")
+ except Exception,e:
+ show_usage()
+
+ for (arg,val) in args:
+ if arg == '-m':
+ mode = val
+ elif arg == "-f":
+ file_name = val
+
+ if mode == "generic":
+ printer = PrintGenericStubs()
+ else:
+ print "ERROR: Invalid mode \"%s\" specified." % mode
+ show_usage()
+
+ api = gl_XML.parse_GL_API( file_name )
+
+ printer.Print( api )
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/glapi.c b/nx-X11/extras/Mesa/src/mesa/glapi/glapi.c
new file mode 100644
index 000000000..39eb9b91b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/glapi.c
@@ -0,0 +1,1058 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+
+/*
+ * This file manages the OpenGL API dispatch layer.
+ * The dispatch table (struct _glapi_table) is basically just a list
+ * of function pointers.
+ * There are functions to set/get the current dispatch table for the
+ * current thread and to manage registration/dispatch of dynamically
+ * added extension functions.
+ *
+ * It's intended that this file and the other glapi*.[ch] files are
+ * flexible enough to be reused in several places: XFree86, DRI-
+ * based libGL.so, and perhaps the SGI SI.
+ *
+ * NOTE: There are no dependencies on Mesa in this code.
+ *
+ * Versions (API changes):
+ * 2000/02/23 - original version for Mesa 3.3 and XFree86 4.0
+ * 2001/01/16 - added dispatch override feature for Mesa 3.5
+ * 2002/06/28 - added _glapi_set_warning_func(), Mesa 4.1.
+ * 2002/10/01 - _glapi_get_proc_address() will now generate new entrypoints
+ * itself (using offset ~0). _glapi_add_entrypoint() can be
+ * called afterward and it'll fill in the correct dispatch
+ * offset. This allows DRI libGL to avoid probing for DRI
+ * drivers! No changes to the public glapi interface.
+ */
+
+
+
+#include "glheader.h"
+#include "glapi.h"
+#include "glapioffsets.h"
+#include "glapitable.h"
+#include "glthread.h"
+
+/***** BEGIN NO-OP DISPATCH *****/
+
+static GLboolean WarnFlag = GL_FALSE;
+static _glapi_warning_func warning_func;
+
+static void init_glapi_relocs(void);
+
+static _glapi_proc generate_entrypoint(GLuint functionOffset);
+static void fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset);
+
+/*
+ * Enable/disable printing of warning messages.
+ */
+PUBLIC void
+_glapi_noop_enable_warnings(GLboolean enable)
+{
+ WarnFlag = enable;
+}
+
+/*
+ * Register a callback function for reporting errors.
+ */
+PUBLIC void
+_glapi_set_warning_func( _glapi_warning_func func )
+{
+ warning_func = func;
+}
+
+static GLboolean
+warn(void)
+{
+ if ((WarnFlag || getenv("MESA_DEBUG") || getenv("LIBGL_DEBUG"))
+ && warning_func) {
+ return GL_TRUE;
+ }
+ else {
+ return GL_FALSE;
+ }
+}
+
+
+#define KEYWORD1 static
+#define KEYWORD2 GLAPIENTRY
+#define NAME(func) NoOp##func
+
+#define F NULL
+
+#define DISPATCH(func, args, msg) \
+ if (warn()) { \
+ warning_func(NULL, "GL User Error: called without context: %s", #func); \
+ }
+
+#define RETURN_DISPATCH(func, args, msg) \
+ if (warn()) { \
+ warning_func(NULL, "GL User Error: called without context: %s", #func); \
+ } \
+ return 0
+
+#define DISPATCH_TABLE_NAME __glapi_noop_table
+#define UNUSED_TABLE_NAME __unused_noop_functions
+
+#define TABLE_ENTRY(name) (_glapi_proc) NoOp##name
+
+static GLint NoOpUnused(void)
+{
+ if (warn()) {
+ warning_func(NULL, "GL User Error: calling extension function without a current context\n");
+ }
+ return 0;
+}
+
+#include "glapitemp.h"
+
+/***** END NO-OP DISPATCH *****/
+
+
+
+/**
+ * \name Current dispatch and current context control variables
+ *
+ * Depending on whether or not multithreading is support, and the type of
+ * support available, several variables are used to store the current context
+ * pointer and the current dispatch table pointer. In the non-threaded case,
+ * the variables \c _glapi_Dispatch and \c _glapi_Context are used for this
+ * purpose.
+ *
+ * In the "normal" threaded case, the variables \c _glapi_Dispatch and
+ * \c _glapi_Context will be \c NULL if an application is detected as being
+ * multithreaded. Single-threaded applications will use \c _glapi_Dispatch
+ * and \c _glapi_Context just like the case without any threading support.
+ * When \c _glapi_Dispatch and \c _glapi_Context are \c NULL, the thread state
+ * data \c _gl_DispatchTSD and \c ContextTSD are used. Drivers and the
+ * static dispatch functions access these variables via \c _glapi_get_dispatch
+ * and \c _glapi_get_context.
+ *
+ * There is a race condition in setting \c _glapi_Dispatch to \c NULL. It is
+ * possible for the original thread to be setting it at the same instant a new
+ * thread, perhaps running on a different processor, is clearing it. Because
+ * of that, \c ThreadSafe, which can only ever be changed to \c GL_TRUE, is
+ * used to determine whether or not the application is multithreaded.
+ *
+ * In the TLS case, the variables \c _glapi_Dispatch and \c _glapi_Context are
+ * hardcoded to \c NULL. Instead the TLS variables \c _glapi_tls_Dispatch and
+ * \c _glapi_tls_Context are used. Having \c _glapi_Dispatch and
+ * \c _glapi_Context be hardcoded to \c NULL maintains binary compatability
+ * between TLS enabled loaders and non-TLS DRI drivers.
+ */
+/*@{*/
+#if defined(GLX_USE_TLS)
+
+PUBLIC __thread struct _glapi_table * _glapi_tls_Dispatch
+ __attribute__((tls_model("initial-exec")))
+ = (struct _glapi_table *) __glapi_noop_table;
+
+PUBLIC __thread void * _glapi_tls_Context
+ __attribute__((tls_model("initial-exec")));
+
+PUBLIC const struct _glapi_table *_glapi_Dispatch = NULL;
+PUBLIC const void *_glapi_Context = NULL;
+
+#else
+
+#if defined(THREADS)
+
+static GLboolean ThreadSafe = GL_FALSE; /**< In thread-safe mode? */
+_glthread_TSD _gl_DispatchTSD; /**< Per-thread dispatch pointer */
+static _glthread_TSD ContextTSD; /**< Per-thread context pointer */
+
+#endif /* defined(THREADS) */
+
+PUBLIC struct _glapi_table *_glapi_Dispatch =
+ (struct _glapi_table *) __glapi_noop_table;
+PUBLIC void *_glapi_Context = NULL;
+
+#endif /* defined(GLX_USE_TLS) */
+/*@}*/
+
+
+/**
+ * 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;
+}
+
+
+
+/**
+ * We should call this periodically from a function such as glXMakeCurrent
+ * in order to test if multiple threads are being used.
+ */
+void
+_glapi_check_multithread(void)
+{
+#if defined(THREADS) && !defined(GLX_USE_TLS)
+ if (!ThreadSafe) {
+ static unsigned long knownID;
+ static GLboolean firstCall = GL_TRUE;
+ if (firstCall) {
+ knownID = _glthread_GetID();
+ firstCall = GL_FALSE;
+ }
+ else if (knownID != _glthread_GetID()) {
+ ThreadSafe = GL_TRUE;
+ _glapi_set_dispatch(NULL);
+ }
+ }
+ else if (!_glapi_get_dispatch()) {
+ /* make sure that this thread's dispatch pointer isn't null */
+ _glapi_set_dispatch(NULL);
+ }
+#endif
+}
+
+
+
+/**
+ * Set the current context pointer for this thread.
+ * The context pointer is an opaque type which should be cast to
+ * void from the real context pointer type.
+ */
+PUBLIC void
+_glapi_set_context(void *context)
+{
+ (void) __unused_noop_functions; /* silence a warning */
+#if defined(GLX_USE_TLS)
+ _glapi_tls_Context = context;
+#elif defined(THREADS)
+ _glthread_SetTSD(&ContextTSD, context);
+ _glapi_Context = (ThreadSafe) ? NULL : context;
+#else
+ _glapi_Context = context;
+#endif
+}
+
+
+
+/**
+ * Get the current context pointer for this thread.
+ * The context pointer is an opaque type which should be cast from
+ * void to the real context pointer type.
+ */
+PUBLIC void *
+_glapi_get_context(void)
+{
+#if defined(GLX_USE_TLS)
+ return _glapi_tls_Context;
+#elif defined(THREADS)
+ if (ThreadSafe) {
+ return _glthread_GetTSD(&ContextTSD);
+ }
+ else {
+ return _glapi_Context;
+ }
+#else
+ return _glapi_Context;
+#endif
+}
+
+
+
+/**
+ * Set the global or per-thread dispatch table pointer.
+ */
+PUBLIC void
+_glapi_set_dispatch(struct _glapi_table *dispatch)
+{
+#if defined(PTHREADS) || defined(GLX_USE_TLS)
+ static pthread_once_t once_control = PTHREAD_ONCE_INIT;
+
+
+ pthread_once( & once_control, init_glapi_relocs );
+#endif
+
+ if (!dispatch) {
+ /* use the no-op functions */
+ dispatch = (struct _glapi_table *) __glapi_noop_table;
+ }
+#ifdef DEBUG
+ else {
+ _glapi_check_table(dispatch);
+ }
+#endif
+
+#if defined(GLX_USE_TLS)
+ _glapi_tls_Dispatch = dispatch;
+#elif defined(THREADS)
+ _glthread_SetTSD(&_gl_DispatchTSD, (void *) dispatch);
+ _glapi_Dispatch = (ThreadSafe) ? NULL : dispatch;
+#else /*THREADS*/
+ _glapi_Dispatch = dispatch;
+#endif /*THREADS*/
+}
+
+
+
+/**
+ * Return pointer to current dispatch table for calling thread.
+ */
+PUBLIC struct _glapi_table *
+_glapi_get_dispatch(void)
+{
+ struct _glapi_table * api;
+
+#if defined(GLX_USE_TLS)
+ api = _glapi_tls_Dispatch;
+#elif defined(THREADS)
+ api = (ThreadSafe)
+ ? (struct _glapi_table *) _glthread_GetTSD(&_gl_DispatchTSD)
+ : _glapi_Dispatch;
+#else
+ api = _glapi_Dispatch;
+#endif
+
+ assert( api != NULL );
+ return api;
+}
+
+
+#if !defined( USE_X86_ASM ) && !defined( XFree86Server )
+#define NEED_FUNCTION_POINTER
+#endif
+
+/* The code in this file is auto-generated with Python */
+#include "glprocs.h"
+
+
+/**
+ * Search the table of static entrypoint functions for the named function
+ * and return the corresponding glprocs_table_t entry.
+ */
+static const glprocs_table_t *
+find_entry( const char * n )
+{
+ GLuint i;
+
+ for (i = 0; static_functions[i].Name_offset >= 0; i++) {
+ const char * test_name;
+
+ test_name = gl_string_table + static_functions[i].Name_offset;
+ if (strcmp(test_name, n) == 0) {
+ return & static_functions[i];
+ }
+ }
+ return NULL;
+}
+
+
+/**
+ * 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)
+{
+ const glprocs_table_t * const f = find_entry( funcName );
+
+ if ( f != NULL ) {
+ return f->Offset;
+ }
+ return -1;
+}
+
+
+#if !defined( XFree86Server )
+#ifdef USE_X86_ASM
+
+#if defined( GLX_USE_TLS )
+extern GLubyte gl_dispatch_functions_start[];
+extern GLubyte gl_dispatch_functions_end[];
+#else
+extern const GLubyte gl_dispatch_functions_start[];
+#endif
+
+# if defined(THREADS) && !defined(GLX_USE_TLS)
+# define X86_DISPATCH_FUNCTION_SIZE 32
+# else
+# define X86_DISPATCH_FUNCTION_SIZE 16
+# endif
+
+
+/**
+ * Return dispatch function address the named static (built-in) function.
+ * Return NULL if function not found.
+ */
+static const _glapi_proc
+get_static_proc_address(const char *funcName)
+{
+ const glprocs_table_t * const f = find_entry( funcName );
+
+ if ( f != NULL ) {
+ return (_glapi_proc) (gl_dispatch_functions_start
+ + (X86_DISPATCH_FUNCTION_SIZE * f->Offset));
+ }
+ else {
+ return NULL;
+ }
+}
+
+#else
+
+
+/**
+ * Return pointer to the named static (built-in) function.
+ * \return NULL if function not found.
+ */
+static const _glapi_proc
+get_static_proc_address(const char *funcName)
+{
+ const glprocs_table_t * const f = find_entry( funcName );
+ return ( f != NULL ) ? f->Address : NULL;
+}
+
+#endif /* USE_X86_ASM */
+#endif /* !defined( XFree86Server ) */
+
+
+/**
+ * Return the name of the function at the given offset in the dispatch
+ * table. For debugging only.
+ */
+static const char *
+get_static_proc_name( GLuint offset )
+{
+ GLuint i;
+
+ for (i = 0; static_functions[i].Name_offset >= 0; i++) {
+ if (static_functions[i].Offset == offset) {
+ return gl_string_table + static_functions[i].Name_offset;
+ }
+ }
+ return NULL;
+}
+
+
+
+/**********************************************************************
+ * Extension function management.
+ */
+
+/*
+ * Number of extension functions which we can dynamically add at runtime.
+ */
+#define MAX_EXTENSION_FUNCS 300
+
+
+/*
+ * The dispatch table size (number of entries) is the size of the
+ * _glapi_table struct plus the number of dynamic entries we can add.
+ * The extra slots can be filled in by DRI drivers that register new extension
+ * functions.
+ */
+#define DISPATCH_TABLE_SIZE (sizeof(struct _glapi_table) / sizeof(void *) + MAX_EXTENSION_FUNCS)
+
+
+/**
+ * Track information about a function added to the GL API.
+ */
+struct _glapi_function {
+ /**
+ * Name of the function.
+ */
+ const char * name;
+
+
+ /**
+ * Text string that describes the types of the parameters passed to the
+ * named function. Parameter types are converted to characters using the
+ * following rules:
+ * - 'i' for \c GLint, \c GLuint, and \c GLenum
+ * - 'p' for any pointer type
+ * - 'f' for \c GLfloat and \c GLclampf
+ * - 'd' for \c GLdouble and \c GLclampd
+ */
+ const char * parameter_signature;
+
+
+ /**
+ * Offset in the dispatch table where the pointer to the real function is
+ * located. If the driver has not requested that the named function be
+ * added to the dispatch table, this will have the value ~0.
+ */
+ unsigned dispatch_offset;
+
+
+ /**
+ * Pointer to the dispatch stub for the named function.
+ *
+ * \todo
+ * The semantic of this field should be changed slightly. Currently, it
+ * is always expected to be non-\c NULL. However, it would be better to
+ * only allocate the entry-point stub when the application requests the
+ * function via \c glXGetProcAddress. This would save memory for all the
+ * functions that the driver exports but that the application never wants
+ * to call.
+ */
+ _glapi_proc dispatch_stub;
+};
+
+
+static struct _glapi_function ExtEntryTable[MAX_EXTENSION_FUNCS];
+static GLuint NumExtEntryPoints = 0;
+
+#ifdef USE_SPARC_ASM
+extern void __glapi_sparc_icache_flush(unsigned int *);
+#endif
+
+/**
+ * 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 _glapi_proc
+generate_entrypoint(GLuint functionOffset)
+{
+#if defined(USE_X86_ASM)
+ /* 32 is chosen as something of a magic offset. For x86, the dispatch
+ * at offset 32 is the first one where the offset in the
+ * "jmp OFFSET*4(%eax)" can't be encoded in a single byte.
+ */
+ const GLubyte * const template_func = gl_dispatch_functions_start
+ + (X86_DISPATCH_FUNCTION_SIZE * 32);
+ GLubyte * const code = (GLubyte *) malloc( X86_DISPATCH_FUNCTION_SIZE );
+
+
+ if ( code != NULL ) {
+ (void) memcpy( code, template_func, X86_DISPATCH_FUNCTION_SIZE );
+ fill_in_entrypoint_offset( (_glapi_proc) code, functionOffset );
+ }
+
+ return (_glapi_proc) code;
+#elif defined(USE_SPARC_ASM)
+
+#ifdef __arch64__
+ static const unsigned int insn_template[] = {
+ 0x05000000, /* sethi %uhi(_glapi_Dispatch), %g2 */
+ 0x03000000, /* sethi %hi(_glapi_Dispatch), %g1 */
+ 0x8410a000, /* or %g2, %ulo(_glapi_Dispatch), %g2 */
+ 0x82106000, /* or %g1, %lo(_glapi_Dispatch), %g1 */
+ 0x8528b020, /* sllx %g2, 32, %g2 */
+ 0xc2584002, /* ldx [%g1 + %g2], %g1 */
+ 0x05000000, /* sethi %hi(8 * glapioffset), %g2 */
+ 0x8410a000, /* or %g2, %lo(8 * glapioffset), %g2 */
+ 0xc6584002, /* ldx [%g1 + %g2], %g3 */
+ 0x81c0c000, /* jmpl %g3, %g0 */
+ 0x01000000 /* nop */
+ };
+#else
+ static const unsigned int insn_template[] = {
+ 0x03000000, /* sethi %hi(_glapi_Dispatch), %g1 */
+ 0xc2006000, /* ld [%g1 + %lo(_glapi_Dispatch)], %g1 */
+ 0xc6006000, /* ld [%g1 + %lo(4*glapioffset)], %g3 */
+ 0x81c0c000, /* jmpl %g3, %g0 */
+ 0x01000000 /* nop */
+ };
+#endif
+ unsigned int *code = (unsigned int *) malloc(sizeof(insn_template));
+ unsigned long glapi_addr = (unsigned long) &_glapi_Dispatch;
+ if (code) {
+ memcpy(code, insn_template, sizeof(insn_template));
+
+#ifdef __arch64__
+ code[0] |= (glapi_addr >> (32 + 10));
+ code[1] |= ((glapi_addr & 0xffffffff) >> 10);
+ __glapi_sparc_icache_flush(&code[0]);
+ code[2] |= ((glapi_addr >> 32) & ((1 << 10) - 1));
+ code[3] |= (glapi_addr & ((1 << 10) - 1));
+ __glapi_sparc_icache_flush(&code[2]);
+ code[6] |= ((functionOffset * 8) >> 10);
+ code[7] |= ((functionOffset * 8) & ((1 << 10) - 1));
+ __glapi_sparc_icache_flush(&code[6]);
+#else
+ code[0] |= (glapi_addr >> 10);
+ code[1] |= (glapi_addr & ((1 << 10) - 1));
+ __glapi_sparc_icache_flush(&code[0]);
+ code[2] |= (functionOffset * 4);
+ __glapi_sparc_icache_flush(&code[2]);
+#endif
+ }
+ return (_glapi_proc) code;
+#else
+ (void) functionOffset;
+ return NULL;
+#endif /* USE_*_ASM */
+}
+
+
+/**
+ * This function inserts a new dispatch offset into the assembly language
+ * stub that was generated with the preceeding function.
+ */
+static void
+fill_in_entrypoint_offset(_glapi_proc entrypoint, GLuint offset)
+{
+#if defined(USE_X86_ASM)
+ GLubyte * const code = (GLubyte *) entrypoint;
+
+
+#if X86_DISPATCH_FUNCTION_SIZE == 32
+ *((unsigned int *)(code + 11)) = 4 * offset;
+ *((unsigned int *)(code + 22)) = 4 * offset;
+#elif X86_DISPATCH_FUNCTION_SIZE == 16 && defined( GLX_USE_TLS )
+ *((unsigned int *)(code + 8)) = 4 * offset;
+#elif X86_DISPATCH_FUNCTION_SIZE == 16
+ *((unsigned int *)(code + 7)) = 4 * offset;
+#else
+# error Invalid X86_DISPATCH_FUNCTION_SIZE!
+#endif
+
+#elif defined(USE_SPARC_ASM)
+
+ /* XXX this hasn't been tested! */
+ unsigned int *code = (unsigned int *) entrypoint;
+#ifdef __arch64__
+ code[6] = 0x05000000; /* sethi %hi(8 * glapioffset), %g2 */
+ code[7] = 0x8410a000; /* or %g2, %lo(8 * glapioffset), %g2 */
+ code[6] |= ((offset * 8) >> 10);
+ code[7] |= ((offset * 8) & ((1 << 10) - 1));
+ __glapi_sparc_icache_flush(&code[6]);
+#else /* __arch64__ */
+ code[2] = 0xc6006000; /* ld [%g1 + %lo(4*glapioffset)], %g3 */
+ code[2] |= (offset * 4);
+ __glapi_sparc_icache_flush(&code[2]);
+#endif /* __arch64__ */
+
+#else
+
+ /* an unimplemented architecture */
+ (void) entrypoint;
+ (void) offset;
+
+#endif /* USE_*_ASM */
+}
+
+
+/**
+ * Generate new entrypoint
+ *
+ * Use a temporary dispatch offset of ~0 (i.e. -1). Later, when the driver
+ * calls \c _glapi_add_dispatch we'll put in the proper offset. If that
+ * never happens, and the user calls this function, he'll segfault. That's
+ * what you get when you try calling a GL function that doesn't really exist.
+ *
+ * \param funcName Name of the function to create an entry-point for.
+ *
+ * \sa _glapi_add_entrypoint
+ */
+
+static struct _glapi_function *
+add_function_name( const char * funcName )
+{
+ struct _glapi_function * entry = NULL;
+
+ if (NumExtEntryPoints < MAX_EXTENSION_FUNCS) {
+ _glapi_proc entrypoint = generate_entrypoint(~0);
+ if (entrypoint != NULL) {
+ entry = & ExtEntryTable[NumExtEntryPoints];
+
+ ExtEntryTable[NumExtEntryPoints].name = str_dup(funcName);
+ ExtEntryTable[NumExtEntryPoints].parameter_signature = NULL;
+ ExtEntryTable[NumExtEntryPoints].dispatch_offset = ~0;
+ ExtEntryTable[NumExtEntryPoints].dispatch_stub = entrypoint;
+ NumExtEntryPoints++;
+ }
+ }
+
+ return entry;
+}
+
+
+/**
+ * Fill-in the dispatch stub for the named function.
+ *
+ * This function is intended to be called by a hardware driver. When called,
+ * a dispatch stub may be created created for the function. A pointer to this
+ * dispatch function will be returned by glXGetProcAddress.
+ *
+ * \param function_names Array of pointers to function names that should
+ * share a common dispatch offset.
+ * \param parameter_signature String representing the types of the parameters
+ * passed to the named function. Parameter types
+ * are converted to characters using the following
+ * rules:
+ * - 'i' for \c GLint, \c GLuint, and \c GLenum
+ * - 'p' for any pointer type
+ * - 'f' for \c GLfloat and \c GLclampf
+ * - 'd' for \c GLdouble and \c GLclampd
+ *
+ * \returns
+ * The offset in the dispatch table of the named function. A pointer to the
+ * driver's implementation of the named function should be stored at
+ * \c dispatch_table[\c offset].
+ *
+ * \sa glXGetProcAddress
+ *
+ * \warning
+ * This function can only handle up to 8 names at a time. As far as I know,
+ * the maximum number of names ever associated with an existing GL function is
+ * 4 (\c glPointParameterfSGIS, \c glPointParameterfEXT,
+ * \c glPointParameterfARB, and \c glPointParameterf), so this should not be
+ * too painful of a limitation.
+ *
+ * \todo
+ * Determine whether or not \c parameter_signature should be allowed to be
+ * \c NULL. It doesn't seem like much of a hardship for drivers to have to
+ * pass in an empty string.
+ *
+ * \todo
+ * Determine if code should be added to reject function names that start with
+ * 'glX'.
+ *
+ * \bug
+ * Add code to compare \c parameter_signature with the parameter signature of
+ * a static function. In order to do that, we need to find a way to \b get
+ * the parameter signature of a static function.
+ */
+
+PUBLIC int
+_glapi_add_dispatch( const char * const * function_names,
+ const char * parameter_signature )
+{
+ static int next_dynamic_offset = _gloffset_FIRST_DYNAMIC;
+ const char * const real_sig = (parameter_signature != NULL)
+ ? parameter_signature : "";
+ struct _glapi_function * entry[8];
+ GLboolean is_static[8];
+ unsigned i;
+ unsigned j;
+ int offset = ~0;
+ int new_offset;
+
+
+ (void) memset( is_static, 0, sizeof( is_static ) );
+ (void) memset( entry, 0, sizeof( entry ) );
+
+ for ( i = 0 ; function_names[i] != NULL ; i++ ) {
+ /* Do some trivial validation on the name of the function.
+ */
+
+#ifdef MANGLE
+ if (!function_names[i] || function_names[i][0] != 'm' || function_names[i][1] != 'g' || function_names[i][2] != 'l')
+ return GL_FALSE;
+#else
+ if (!function_names[i] || function_names[i][0] != 'g' || function_names[i][1] != 'l')
+ return GL_FALSE;
+#endif
+
+
+ /* Determine if the named function already exists. If the function does
+ * exist, it must have the same parameter signature as the function
+ * being added.
+ */
+
+ new_offset = get_static_proc_offset(function_names[i]);
+ if (new_offset >= 0) {
+ /* FIXME: Make sure the parameter signatures match! How do we get
+ * FIXME: the parameter signature for static functions?
+ */
+
+ if ( (offset != ~0) && (new_offset != offset) ) {
+ return -1;
+ }
+
+ is_static[i] = GL_TRUE;
+ offset = new_offset;
+ }
+
+
+ for ( j = 0 ; j < NumExtEntryPoints ; j++ ) {
+ if (strcmp(ExtEntryTable[j].name, function_names[i]) == 0) {
+ /* The offset may be ~0 if the function name was added by
+ * glXGetProcAddress but never filled in by the driver.
+ */
+
+ if (ExtEntryTable[j].dispatch_offset != ~0) {
+ if (strcmp(real_sig, ExtEntryTable[j].parameter_signature)
+ != 0) {
+ return -1;
+ }
+
+ if ( (offset != ~0) && (ExtEntryTable[j].dispatch_offset != offset) ) {
+ return -1;
+ }
+
+ offset = ExtEntryTable[j].dispatch_offset;
+ }
+
+ entry[i] = & ExtEntryTable[j];
+ break;
+ }
+ }
+ }
+
+
+ if (offset == ~0) {
+ offset = next_dynamic_offset;
+ next_dynamic_offset++;
+ }
+
+
+ for ( i = 0 ; function_names[i] != NULL ; i++ ) {
+ if (! is_static[i] ) {
+ if (entry[i] == NULL) {
+ entry[i] = add_function_name( function_names[i] );
+ if (entry[i] == NULL) {
+ /* FIXME: Possible memory leak here.
+ */
+ return -1;
+ }
+ }
+
+
+ entry[i]->parameter_signature = str_dup(real_sig);
+ fill_in_entrypoint_offset(entry[i]->dispatch_stub, offset);
+ entry[i]->dispatch_offset = offset;
+ }
+ }
+
+ return offset;
+}
+
+
+/**
+ * Return offset of entrypoint for named function within dispatch table.
+ */
+PUBLIC GLint
+_glapi_get_proc_offset(const char *funcName)
+{
+ /* search extension functions first */
+ GLuint i;
+ for (i = 0; i < NumExtEntryPoints; i++) {
+ if (strcmp(ExtEntryTable[i].name, funcName) == 0) {
+ return ExtEntryTable[i].dispatch_offset;
+ }
+ }
+
+ /* search static functions */
+ return get_static_proc_offset(funcName);
+}
+
+
+
+/**
+ * Return pointer to the named function. If the function name isn't found
+ * in the name of static functions, try generating a new API entrypoint on
+ * the fly with assembly language.
+ */
+_glapi_proc
+_glapi_get_proc_address(const char *funcName)
+{
+ struct _glapi_function * entry;
+ GLuint i;
+
+#ifdef MANGLE
+ if (funcName[0] != 'm' || funcName[1] != 'g' || funcName[2] != 'l')
+ return NULL;
+#else
+ if (funcName[0] != 'g' || funcName[1] != 'l')
+ return NULL;
+#endif
+
+ /* search extension functions first */
+ for (i = 0; i < NumExtEntryPoints; i++) {
+ if (strcmp(ExtEntryTable[i].name, funcName) == 0) {
+ return ExtEntryTable[i].dispatch_stub;
+ }
+ }
+
+#if !defined( XFree86Server )
+ /* search static functions */
+ {
+ const _glapi_proc func = get_static_proc_address(funcName);
+ if (func)
+ return func;
+ }
+#endif /* !defined( XFree86Server ) */
+
+ entry = add_function_name(funcName);
+ return (entry == NULL) ? NULL : entry->dispatch_stub;
+}
+
+
+
+/**
+ * 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)
+{
+ GLuint i;
+ const char * n;
+
+ /* search built-in functions */
+ n = get_static_proc_name(offset);
+ if ( n != NULL ) {
+ return n;
+ }
+
+ /* search added extension functions */
+ for (i = 0; i < NumExtEntryPoints; i++) {
+ if (ExtEntryTable[i].dispatch_offset == offset) {
+ return ExtEntryTable[i].name;
+ }
+ }
+ return NULL;
+}
+
+
+
+/**
+ * Return size of dispatch table struct as number of functions (or
+ * slots).
+ */
+PUBLIC GLuint
+_glapi_get_dispatch_table_size(void)
+{
+ return DISPATCH_TABLE_SIZE;
+}
+
+
+
+/**
+ * Make sure there are no NULL pointers in the given dispatch table.
+ * Intended for debugging purposes.
+ */
+void
+_glapi_check_table(const struct _glapi_table *table)
+{
+#ifdef DEBUG
+ 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]);
+ }
+
+ /* 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);
+ }
+ {
+ GLuint secondaryColor3fOffset = _glapi_get_proc_offset("glSecondaryColor3fEXT");
+ char *secondaryColor3fFunc = (char*) &table->SecondaryColor3fEXT;
+ GLuint offset = (secondaryColor3fFunc - (char *) table) / sizeof(void *);
+ assert(secondaryColor3fOffset == _gloffset_SecondaryColor3fEXT);
+ assert(secondaryColor3fOffset == offset);
+ assert(_glapi_get_proc_address("glSecondaryColor3fEXT") == (_glapi_proc) &glSecondaryColor3fEXT);
+ }
+ {
+ GLuint pointParameterivOffset = _glapi_get_proc_offset("glPointParameterivNV");
+ char *pointParameterivFunc = (char*) &table->PointParameterivNV;
+ GLuint offset = (pointParameterivFunc - (char *) table) / sizeof(void *);
+ assert(pointParameterivOffset == _gloffset_PointParameterivNV);
+ assert(pointParameterivOffset == offset);
+ assert(_glapi_get_proc_address("glPointParameterivNV") == (_glapi_proc) &glPointParameterivNV);
+ }
+ {
+ GLuint setFenceOffset = _glapi_get_proc_offset("glSetFenceNV");
+ char *setFenceFunc = (char*) &table->SetFenceNV;
+ GLuint offset = (setFenceFunc - (char *) table) / sizeof(void *);
+ assert(setFenceOffset == _gloffset_SetFenceNV);
+ assert(setFenceOffset == offset);
+ assert(_glapi_get_proc_address("glSetFenceNV") == (_glapi_proc) &glSetFenceNV);
+ }
+#else
+ (void) table;
+#endif
+}
+
+
+/**
+ * Perform platform-specific GL API entry-point fixups.
+ *
+ *
+ */
+static void
+init_glapi_relocs( void )
+{
+#if defined( USE_X86_ASM ) && defined( GLX_USE_TLS )
+ extern void * _x86_get_dispatch(void);
+ const GLubyte * const get_disp = (const GLubyte *) _x86_get_dispatch;
+ GLubyte * curr_func = (GLubyte *) gl_dispatch_functions_start;
+
+
+ while ( curr_func != (GLubyte *) gl_dispatch_functions_end ) {
+ (void) memcpy( curr_func, get_disp, 6 );
+ curr_func += X86_DISPATCH_FUNCTION_SIZE;
+ }
+#endif /* defined( USE_X86_ASM ) && defined( GLX_USE_TLS ) */
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/glapi.h b/nx-X11/extras/Mesa/src/mesa/glapi/glapi.h
new file mode 100644
index 000000000..80ce2c324
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/glapi.h
@@ -0,0 +1,152 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+/**
+ * \mainpage Mesa GL API Module
+ *
+ * \section GLAPIIntroduction Introduction
+ *
+ * The Mesa GL API module is responsible for dispatching all the
+ * gl*() functions. All GL functions are dispatched by jumping through
+ * the current dispatch table (basically a struct full of function
+ * pointers.)
+ *
+ * A per-thread current dispatch table and per-thread current context
+ * pointer are managed by this module too.
+ *
+ * This module is intended to be non-Mesa-specific so it can be used
+ * with the X/DRI libGL also.
+ */
+
+
+#ifndef _GLAPI_H
+#define _GLAPI_H
+
+
+#include "GL/gl.h"
+#include "glapitable.h"
+
+typedef void (*_glapi_warning_func)(void *ctx, const char *str, ...);
+
+
+#if defined (GLX_USE_TLS)
+
+const extern void *_glapi_Context;
+const extern struct _glapi_table *_glapi_Dispatch;
+
+extern __thread void * _glapi_tls_Context
+ __attribute__((tls_model("initial-exec")));
+
+# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_tls_Context
+
+#else
+
+extern void *_glapi_Context;
+extern struct _glapi_table *_glapi_Dispatch;
+
+/**
+ * Macro for declaration and fetching the current context.
+ *
+ * \param C local variable which will hold the current context.
+ *
+ * It should be used in the variable declaration area of a function:
+ * \code
+ * ...
+ * {
+ * GET_CURRENT_CONTEXT(ctx);
+ * ...
+ * \endcode
+ */
+# ifdef THREADS
+# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) (_glapi_Context ? _glapi_Context : _glapi_get_context())
+# else
+# define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context
+# endif
+
+#endif /* defined (GLX_USE_TLS) */
+
+extern void
+_glapi_noop_enable_warnings(GLboolean enable);
+
+extern void
+_glapi_set_warning_func(_glapi_warning_func func);
+
+extern void
+_glapi_check_multithread(void);
+
+
+extern void
+_glapi_set_context(void *context);
+
+
+extern void *
+_glapi_get_context(void);
+
+
+extern void
+_glapi_set_dispatch(struct _glapi_table *dispatch);
+
+
+extern struct _glapi_table *
+_glapi_get_dispatch(void);
+
+
+extern int
+_glapi_begin_dispatch_override(struct _glapi_table *override);
+
+
+extern void
+_glapi_end_dispatch_override(int layer);
+
+
+struct _glapi_table *
+_glapi_get_override_dispatch(int layer);
+
+
+extern GLuint
+_glapi_get_dispatch_table_size(void);
+
+
+extern void
+_glapi_check_table(const struct _glapi_table *table);
+
+
+extern int
+_glapi_add_dispatch( const char * const * function_names,
+ const char * parameter_signature );
+
+extern GLint
+_glapi_get_proc_offset(const char *funcName);
+
+
+extern _glapi_proc
+_glapi_get_proc_address(const char *funcName);
+
+
+extern const char *
+_glapi_get_proc_name(GLuint offset);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/glapioffsets.h b/nx-X11/extras/Mesa/src/mesa/glapi/glapioffsets.h
new file mode 100644
index 000000000..9e266450e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/glapioffsets.h
@@ -0,0 +1,1266 @@
+/* DO NOT EDIT - This file generated automatically by gl_offsets.py (from Mesa) script */
+
+/*
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * BRIAN PAUL, IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#if !defined( _GLAPI_OFFSETS_H_ )
+# define _GLAPI_OFFSETS_H_
+
+#define _gloffset_NewList 0
+#define _gloffset_EndList 1
+#define _gloffset_CallList 2
+#define _gloffset_CallLists 3
+#define _gloffset_DeleteLists 4
+#define _gloffset_GenLists 5
+#define _gloffset_ListBase 6
+#define _gloffset_Begin 7
+#define _gloffset_Bitmap 8
+#define _gloffset_Color3b 9
+#define _gloffset_Color3bv 10
+#define _gloffset_Color3d 11
+#define _gloffset_Color3dv 12
+#define _gloffset_Color3f 13
+#define _gloffset_Color3fv 14
+#define _gloffset_Color3i 15
+#define _gloffset_Color3iv 16
+#define _gloffset_Color3s 17
+#define _gloffset_Color3sv 18
+#define _gloffset_Color3ub 19
+#define _gloffset_Color3ubv 20
+#define _gloffset_Color3ui 21
+#define _gloffset_Color3uiv 22
+#define _gloffset_Color3us 23
+#define _gloffset_Color3usv 24
+#define _gloffset_Color4b 25
+#define _gloffset_Color4bv 26
+#define _gloffset_Color4d 27
+#define _gloffset_Color4dv 28
+#define _gloffset_Color4f 29
+#define _gloffset_Color4fv 30
+#define _gloffset_Color4i 31
+#define _gloffset_Color4iv 32
+#define _gloffset_Color4s 33
+#define _gloffset_Color4sv 34
+#define _gloffset_Color4ub 35
+#define _gloffset_Color4ubv 36
+#define _gloffset_Color4ui 37
+#define _gloffset_Color4uiv 38
+#define _gloffset_Color4us 39
+#define _gloffset_Color4usv 40
+#define _gloffset_EdgeFlag 41
+#define _gloffset_EdgeFlagv 42
+#define _gloffset_End 43
+#define _gloffset_Indexd 44
+#define _gloffset_Indexdv 45
+#define _gloffset_Indexf 46
+#define _gloffset_Indexfv 47
+#define _gloffset_Indexi 48
+#define _gloffset_Indexiv 49
+#define _gloffset_Indexs 50
+#define _gloffset_Indexsv 51
+#define _gloffset_Normal3b 52
+#define _gloffset_Normal3bv 53
+#define _gloffset_Normal3d 54
+#define _gloffset_Normal3dv 55
+#define _gloffset_Normal3f 56
+#define _gloffset_Normal3fv 57
+#define _gloffset_Normal3i 58
+#define _gloffset_Normal3iv 59
+#define _gloffset_Normal3s 60
+#define _gloffset_Normal3sv 61
+#define _gloffset_RasterPos2d 62
+#define _gloffset_RasterPos2dv 63
+#define _gloffset_RasterPos2f 64
+#define _gloffset_RasterPos2fv 65
+#define _gloffset_RasterPos2i 66
+#define _gloffset_RasterPos2iv 67
+#define _gloffset_RasterPos2s 68
+#define _gloffset_RasterPos2sv 69
+#define _gloffset_RasterPos3d 70
+#define _gloffset_RasterPos3dv 71
+#define _gloffset_RasterPos3f 72
+#define _gloffset_RasterPos3fv 73
+#define _gloffset_RasterPos3i 74
+#define _gloffset_RasterPos3iv 75
+#define _gloffset_RasterPos3s 76
+#define _gloffset_RasterPos3sv 77
+#define _gloffset_RasterPos4d 78
+#define _gloffset_RasterPos4dv 79
+#define _gloffset_RasterPos4f 80
+#define _gloffset_RasterPos4fv 81
+#define _gloffset_RasterPos4i 82
+#define _gloffset_RasterPos4iv 83
+#define _gloffset_RasterPos4s 84
+#define _gloffset_RasterPos4sv 85
+#define _gloffset_Rectd 86
+#define _gloffset_Rectdv 87
+#define _gloffset_Rectf 88
+#define _gloffset_Rectfv 89
+#define _gloffset_Recti 90
+#define _gloffset_Rectiv 91
+#define _gloffset_Rects 92
+#define _gloffset_Rectsv 93
+#define _gloffset_TexCoord1d 94
+#define _gloffset_TexCoord1dv 95
+#define _gloffset_TexCoord1f 96
+#define _gloffset_TexCoord1fv 97
+#define _gloffset_TexCoord1i 98
+#define _gloffset_TexCoord1iv 99
+#define _gloffset_TexCoord1s 100
+#define _gloffset_TexCoord1sv 101
+#define _gloffset_TexCoord2d 102
+#define _gloffset_TexCoord2dv 103
+#define _gloffset_TexCoord2f 104
+#define _gloffset_TexCoord2fv 105
+#define _gloffset_TexCoord2i 106
+#define _gloffset_TexCoord2iv 107
+#define _gloffset_TexCoord2s 108
+#define _gloffset_TexCoord2sv 109
+#define _gloffset_TexCoord3d 110
+#define _gloffset_TexCoord3dv 111
+#define _gloffset_TexCoord3f 112
+#define _gloffset_TexCoord3fv 113
+#define _gloffset_TexCoord3i 114
+#define _gloffset_TexCoord3iv 115
+#define _gloffset_TexCoord3s 116
+#define _gloffset_TexCoord3sv 117
+#define _gloffset_TexCoord4d 118
+#define _gloffset_TexCoord4dv 119
+#define _gloffset_TexCoord4f 120
+#define _gloffset_TexCoord4fv 121
+#define _gloffset_TexCoord4i 122
+#define _gloffset_TexCoord4iv 123
+#define _gloffset_TexCoord4s 124
+#define _gloffset_TexCoord4sv 125
+#define _gloffset_Vertex2d 126
+#define _gloffset_Vertex2dv 127
+#define _gloffset_Vertex2f 128
+#define _gloffset_Vertex2fv 129
+#define _gloffset_Vertex2i 130
+#define _gloffset_Vertex2iv 131
+#define _gloffset_Vertex2s 132
+#define _gloffset_Vertex2sv 133
+#define _gloffset_Vertex3d 134
+#define _gloffset_Vertex3dv 135
+#define _gloffset_Vertex3f 136
+#define _gloffset_Vertex3fv 137
+#define _gloffset_Vertex3i 138
+#define _gloffset_Vertex3iv 139
+#define _gloffset_Vertex3s 140
+#define _gloffset_Vertex3sv 141
+#define _gloffset_Vertex4d 142
+#define _gloffset_Vertex4dv 143
+#define _gloffset_Vertex4f 144
+#define _gloffset_Vertex4fv 145
+#define _gloffset_Vertex4i 146
+#define _gloffset_Vertex4iv 147
+#define _gloffset_Vertex4s 148
+#define _gloffset_Vertex4sv 149
+#define _gloffset_ClipPlane 150
+#define _gloffset_ColorMaterial 151
+#define _gloffset_CullFace 152
+#define _gloffset_Fogf 153
+#define _gloffset_Fogfv 154
+#define _gloffset_Fogi 155
+#define _gloffset_Fogiv 156
+#define _gloffset_FrontFace 157
+#define _gloffset_Hint 158
+#define _gloffset_Lightf 159
+#define _gloffset_Lightfv 160
+#define _gloffset_Lighti 161
+#define _gloffset_Lightiv 162
+#define _gloffset_LightModelf 163
+#define _gloffset_LightModelfv 164
+#define _gloffset_LightModeli 165
+#define _gloffset_LightModeliv 166
+#define _gloffset_LineStipple 167
+#define _gloffset_LineWidth 168
+#define _gloffset_Materialf 169
+#define _gloffset_Materialfv 170
+#define _gloffset_Materiali 171
+#define _gloffset_Materialiv 172
+#define _gloffset_PointSize 173
+#define _gloffset_PolygonMode 174
+#define _gloffset_PolygonStipple 175
+#define _gloffset_Scissor 176
+#define _gloffset_ShadeModel 177
+#define _gloffset_TexParameterf 178
+#define _gloffset_TexParameterfv 179
+#define _gloffset_TexParameteri 180
+#define _gloffset_TexParameteriv 181
+#define _gloffset_TexImage1D 182
+#define _gloffset_TexImage2D 183
+#define _gloffset_TexEnvf 184
+#define _gloffset_TexEnvfv 185
+#define _gloffset_TexEnvi 186
+#define _gloffset_TexEnviv 187
+#define _gloffset_TexGend 188
+#define _gloffset_TexGendv 189
+#define _gloffset_TexGenf 190
+#define _gloffset_TexGenfv 191
+#define _gloffset_TexGeni 192
+#define _gloffset_TexGeniv 193
+#define _gloffset_FeedbackBuffer 194
+#define _gloffset_SelectBuffer 195
+#define _gloffset_RenderMode 196
+#define _gloffset_InitNames 197
+#define _gloffset_LoadName 198
+#define _gloffset_PassThrough 199
+#define _gloffset_PopName 200
+#define _gloffset_PushName 201
+#define _gloffset_DrawBuffer 202
+#define _gloffset_Clear 203
+#define _gloffset_ClearAccum 204
+#define _gloffset_ClearIndex 205
+#define _gloffset_ClearColor 206
+#define _gloffset_ClearStencil 207
+#define _gloffset_ClearDepth 208
+#define _gloffset_StencilMask 209
+#define _gloffset_ColorMask 210
+#define _gloffset_DepthMask 211
+#define _gloffset_IndexMask 212
+#define _gloffset_Accum 213
+#define _gloffset_Disable 214
+#define _gloffset_Enable 215
+#define _gloffset_Finish 216
+#define _gloffset_Flush 217
+#define _gloffset_PopAttrib 218
+#define _gloffset_PushAttrib 219
+#define _gloffset_Map1d 220
+#define _gloffset_Map1f 221
+#define _gloffset_Map2d 222
+#define _gloffset_Map2f 223
+#define _gloffset_MapGrid1d 224
+#define _gloffset_MapGrid1f 225
+#define _gloffset_MapGrid2d 226
+#define _gloffset_MapGrid2f 227
+#define _gloffset_EvalCoord1d 228
+#define _gloffset_EvalCoord1dv 229
+#define _gloffset_EvalCoord1f 230
+#define _gloffset_EvalCoord1fv 231
+#define _gloffset_EvalCoord2d 232
+#define _gloffset_EvalCoord2dv 233
+#define _gloffset_EvalCoord2f 234
+#define _gloffset_EvalCoord2fv 235
+#define _gloffset_EvalMesh1 236
+#define _gloffset_EvalPoint1 237
+#define _gloffset_EvalMesh2 238
+#define _gloffset_EvalPoint2 239
+#define _gloffset_AlphaFunc 240
+#define _gloffset_BlendFunc 241
+#define _gloffset_LogicOp 242
+#define _gloffset_StencilFunc 243
+#define _gloffset_StencilOp 244
+#define _gloffset_DepthFunc 245
+#define _gloffset_PixelZoom 246
+#define _gloffset_PixelTransferf 247
+#define _gloffset_PixelTransferi 248
+#define _gloffset_PixelStoref 249
+#define _gloffset_PixelStorei 250
+#define _gloffset_PixelMapfv 251
+#define _gloffset_PixelMapuiv 252
+#define _gloffset_PixelMapusv 253
+#define _gloffset_ReadBuffer 254
+#define _gloffset_CopyPixels 255
+#define _gloffset_ReadPixels 256
+#define _gloffset_DrawPixels 257
+#define _gloffset_GetBooleanv 258
+#define _gloffset_GetClipPlane 259
+#define _gloffset_GetDoublev 260
+#define _gloffset_GetError 261
+#define _gloffset_GetFloatv 262
+#define _gloffset_GetIntegerv 263
+#define _gloffset_GetLightfv 264
+#define _gloffset_GetLightiv 265
+#define _gloffset_GetMapdv 266
+#define _gloffset_GetMapfv 267
+#define _gloffset_GetMapiv 268
+#define _gloffset_GetMaterialfv 269
+#define _gloffset_GetMaterialiv 270
+#define _gloffset_GetPixelMapfv 271
+#define _gloffset_GetPixelMapuiv 272
+#define _gloffset_GetPixelMapusv 273
+#define _gloffset_GetPolygonStipple 274
+#define _gloffset_GetString 275
+#define _gloffset_GetTexEnvfv 276
+#define _gloffset_GetTexEnviv 277
+#define _gloffset_GetTexGendv 278
+#define _gloffset_GetTexGenfv 279
+#define _gloffset_GetTexGeniv 280
+#define _gloffset_GetTexImage 281
+#define _gloffset_GetTexParameterfv 282
+#define _gloffset_GetTexParameteriv 283
+#define _gloffset_GetTexLevelParameterfv 284
+#define _gloffset_GetTexLevelParameteriv 285
+#define _gloffset_IsEnabled 286
+#define _gloffset_IsList 287
+#define _gloffset_DepthRange 288
+#define _gloffset_Frustum 289
+#define _gloffset_LoadIdentity 290
+#define _gloffset_LoadMatrixf 291
+#define _gloffset_LoadMatrixd 292
+#define _gloffset_MatrixMode 293
+#define _gloffset_MultMatrixf 294
+#define _gloffset_MultMatrixd 295
+#define _gloffset_Ortho 296
+#define _gloffset_PopMatrix 297
+#define _gloffset_PushMatrix 298
+#define _gloffset_Rotated 299
+#define _gloffset_Rotatef 300
+#define _gloffset_Scaled 301
+#define _gloffset_Scalef 302
+#define _gloffset_Translated 303
+#define _gloffset_Translatef 304
+#define _gloffset_Viewport 305
+#define _gloffset_ArrayElement 306
+#define _gloffset_BindTexture 307
+#define _gloffset_ColorPointer 308
+#define _gloffset_DisableClientState 309
+#define _gloffset_DrawArrays 310
+#define _gloffset_DrawElements 311
+#define _gloffset_EdgeFlagPointer 312
+#define _gloffset_EnableClientState 313
+#define _gloffset_IndexPointer 314
+#define _gloffset_Indexub 315
+#define _gloffset_Indexubv 316
+#define _gloffset_InterleavedArrays 317
+#define _gloffset_NormalPointer 318
+#define _gloffset_PolygonOffset 319
+#define _gloffset_TexCoordPointer 320
+#define _gloffset_VertexPointer 321
+#define _gloffset_AreTexturesResident 322
+#define _gloffset_CopyTexImage1D 323
+#define _gloffset_CopyTexImage2D 324
+#define _gloffset_CopyTexSubImage1D 325
+#define _gloffset_CopyTexSubImage2D 326
+#define _gloffset_DeleteTextures 327
+#define _gloffset_GenTextures 328
+#define _gloffset_GetPointerv 329
+#define _gloffset_IsTexture 330
+#define _gloffset_PrioritizeTextures 331
+#define _gloffset_TexSubImage1D 332
+#define _gloffset_TexSubImage2D 333
+#define _gloffset_PopClientAttrib 334
+#define _gloffset_PushClientAttrib 335
+#define _gloffset_BlendColor 336
+#define _gloffset_BlendEquation 337
+#define _gloffset_DrawRangeElements 338
+#define _gloffset_ColorTable 339
+#define _gloffset_ColorTableParameterfv 340
+#define _gloffset_ColorTableParameteriv 341
+#define _gloffset_CopyColorTable 342
+#define _gloffset_GetColorTable 343
+#define _gloffset_GetColorTableParameterfv 344
+#define _gloffset_GetColorTableParameteriv 345
+#define _gloffset_ColorSubTable 346
+#define _gloffset_CopyColorSubTable 347
+#define _gloffset_ConvolutionFilter1D 348
+#define _gloffset_ConvolutionFilter2D 349
+#define _gloffset_ConvolutionParameterf 350
+#define _gloffset_ConvolutionParameterfv 351
+#define _gloffset_ConvolutionParameteri 352
+#define _gloffset_ConvolutionParameteriv 353
+#define _gloffset_CopyConvolutionFilter1D 354
+#define _gloffset_CopyConvolutionFilter2D 355
+#define _gloffset_GetConvolutionFilter 356
+#define _gloffset_GetConvolutionParameterfv 357
+#define _gloffset_GetConvolutionParameteriv 358
+#define _gloffset_GetSeparableFilter 359
+#define _gloffset_SeparableFilter2D 360
+#define _gloffset_GetHistogram 361
+#define _gloffset_GetHistogramParameterfv 362
+#define _gloffset_GetHistogramParameteriv 363
+#define _gloffset_GetMinmax 364
+#define _gloffset_GetMinmaxParameterfv 365
+#define _gloffset_GetMinmaxParameteriv 366
+#define _gloffset_Histogram 367
+#define _gloffset_Minmax 368
+#define _gloffset_ResetHistogram 369
+#define _gloffset_ResetMinmax 370
+#define _gloffset_TexImage3D 371
+#define _gloffset_TexSubImage3D 372
+#define _gloffset_CopyTexSubImage3D 373
+#define _gloffset_ActiveTextureARB 374
+#define _gloffset_ClientActiveTextureARB 375
+#define _gloffset_MultiTexCoord1dARB 376
+#define _gloffset_MultiTexCoord1dvARB 377
+#define _gloffset_MultiTexCoord1fARB 378
+#define _gloffset_MultiTexCoord1fvARB 379
+#define _gloffset_MultiTexCoord1iARB 380
+#define _gloffset_MultiTexCoord1ivARB 381
+#define _gloffset_MultiTexCoord1sARB 382
+#define _gloffset_MultiTexCoord1svARB 383
+#define _gloffset_MultiTexCoord2dARB 384
+#define _gloffset_MultiTexCoord2dvARB 385
+#define _gloffset_MultiTexCoord2fARB 386
+#define _gloffset_MultiTexCoord2fvARB 387
+#define _gloffset_MultiTexCoord2iARB 388
+#define _gloffset_MultiTexCoord2ivARB 389
+#define _gloffset_MultiTexCoord2sARB 390
+#define _gloffset_MultiTexCoord2svARB 391
+#define _gloffset_MultiTexCoord3dARB 392
+#define _gloffset_MultiTexCoord3dvARB 393
+#define _gloffset_MultiTexCoord3fARB 394
+#define _gloffset_MultiTexCoord3fvARB 395
+#define _gloffset_MultiTexCoord3iARB 396
+#define _gloffset_MultiTexCoord3ivARB 397
+#define _gloffset_MultiTexCoord3sARB 398
+#define _gloffset_MultiTexCoord3svARB 399
+#define _gloffset_MultiTexCoord4dARB 400
+#define _gloffset_MultiTexCoord4dvARB 401
+#define _gloffset_MultiTexCoord4fARB 402
+#define _gloffset_MultiTexCoord4fvARB 403
+#define _gloffset_MultiTexCoord4iARB 404
+#define _gloffset_MultiTexCoord4ivARB 405
+#define _gloffset_MultiTexCoord4sARB 406
+#define _gloffset_MultiTexCoord4svARB 407
+
+#if !defined(IN_DRI_DRIVER)
+
+#define _gloffset_LoadTransposeMatrixfARB 408
+#define _gloffset_LoadTransposeMatrixdARB 409
+#define _gloffset_MultTransposeMatrixfARB 410
+#define _gloffset_MultTransposeMatrixdARB 411
+#define _gloffset_SampleCoverageARB 412
+#define _gloffset_DrawBuffersARB 413
+#define _gloffset_PolygonOffsetEXT 414
+#define _gloffset_GetTexFilterFuncSGIS 415
+#define _gloffset_TexFilterFuncSGIS 416
+#define _gloffset_GetHistogramEXT 417
+#define _gloffset_GetHistogramParameterfvEXT 418
+#define _gloffset_GetHistogramParameterivEXT 419
+#define _gloffset_GetMinmaxEXT 420
+#define _gloffset_GetMinmaxParameterfvEXT 421
+#define _gloffset_GetMinmaxParameterivEXT 422
+#define _gloffset_GetConvolutionFilterEXT 423
+#define _gloffset_GetConvolutionParameterfvEXT 424
+#define _gloffset_GetConvolutionParameterivEXT 425
+#define _gloffset_GetSeparableFilterEXT 426
+#define _gloffset_GetColorTableSGI 427
+#define _gloffset_GetColorTableParameterfvSGI 428
+#define _gloffset_GetColorTableParameterivSGI 429
+#define _gloffset_PixelTexGenSGIX 430
+#define _gloffset_PixelTexGenParameteriSGIS 431
+#define _gloffset_PixelTexGenParameterivSGIS 432
+#define _gloffset_PixelTexGenParameterfSGIS 433
+#define _gloffset_PixelTexGenParameterfvSGIS 434
+#define _gloffset_GetPixelTexGenParameterivSGIS 435
+#define _gloffset_GetPixelTexGenParameterfvSGIS 436
+#define _gloffset_TexImage4DSGIS 437
+#define _gloffset_TexSubImage4DSGIS 438
+#define _gloffset_AreTexturesResidentEXT 439
+#define _gloffset_GenTexturesEXT 440
+#define _gloffset_IsTextureEXT 441
+#define _gloffset_DetailTexFuncSGIS 442
+#define _gloffset_GetDetailTexFuncSGIS 443
+#define _gloffset_SharpenTexFuncSGIS 444
+#define _gloffset_GetSharpenTexFuncSGIS 445
+#define _gloffset_SampleMaskSGIS 446
+#define _gloffset_SamplePatternSGIS 447
+#define _gloffset_ColorPointerEXT 448
+#define _gloffset_EdgeFlagPointerEXT 449
+#define _gloffset_IndexPointerEXT 450
+#define _gloffset_NormalPointerEXT 451
+#define _gloffset_TexCoordPointerEXT 452
+#define _gloffset_VertexPointerEXT 453
+#define _gloffset_SpriteParameterfSGIX 454
+#define _gloffset_SpriteParameterfvSGIX 455
+#define _gloffset_SpriteParameteriSGIX 456
+#define _gloffset_SpriteParameterivSGIX 457
+#define _gloffset_PointParameterfEXT 458
+#define _gloffset_PointParameterfvEXT 459
+#define _gloffset_GetInstrumentsSGIX 460
+#define _gloffset_InstrumentsBufferSGIX 461
+#define _gloffset_PollInstrumentsSGIX 462
+#define _gloffset_ReadInstrumentsSGIX 463
+#define _gloffset_StartInstrumentsSGIX 464
+#define _gloffset_StopInstrumentsSGIX 465
+#define _gloffset_FrameZoomSGIX 466
+#define _gloffset_TagSampleBufferSGIX 467
+#define _gloffset_ReferencePlaneSGIX 468
+#define _gloffset_FlushRasterSGIX 469
+#define _gloffset_GetListParameterfvSGIX 470
+#define _gloffset_GetListParameterivSGIX 471
+#define _gloffset_ListParameterfSGIX 472
+#define _gloffset_ListParameterfvSGIX 473
+#define _gloffset_ListParameteriSGIX 474
+#define _gloffset_ListParameterivSGIX 475
+#define _gloffset_FragmentColorMaterialSGIX 476
+#define _gloffset_FragmentLightfSGIX 477
+#define _gloffset_FragmentLightfvSGIX 478
+#define _gloffset_FragmentLightiSGIX 479
+#define _gloffset_FragmentLightivSGIX 480
+#define _gloffset_FragmentLightModelfSGIX 481
+#define _gloffset_FragmentLightModelfvSGIX 482
+#define _gloffset_FragmentLightModeliSGIX 483
+#define _gloffset_FragmentLightModelivSGIX 484
+#define _gloffset_FragmentMaterialfSGIX 485
+#define _gloffset_FragmentMaterialfvSGIX 486
+#define _gloffset_FragmentMaterialiSGIX 487
+#define _gloffset_FragmentMaterialivSGIX 488
+#define _gloffset_GetFragmentLightfvSGIX 489
+#define _gloffset_GetFragmentLightivSGIX 490
+#define _gloffset_GetFragmentMaterialfvSGIX 491
+#define _gloffset_GetFragmentMaterialivSGIX 492
+#define _gloffset_LightEnviSGIX 493
+#define _gloffset_VertexWeightfEXT 494
+#define _gloffset_VertexWeightfvEXT 495
+#define _gloffset_VertexWeightPointerEXT 496
+#define _gloffset_FlushVertexArrayRangeNV 497
+#define _gloffset_VertexArrayRangeNV 498
+#define _gloffset_CombinerParameterfvNV 499
+#define _gloffset_CombinerParameterfNV 500
+#define _gloffset_CombinerParameterivNV 501
+#define _gloffset_CombinerParameteriNV 502
+#define _gloffset_CombinerInputNV 503
+#define _gloffset_CombinerOutputNV 504
+#define _gloffset_FinalCombinerInputNV 505
+#define _gloffset_GetCombinerInputParameterfvNV 506
+#define _gloffset_GetCombinerInputParameterivNV 507
+#define _gloffset_GetCombinerOutputParameterfvNV 508
+#define _gloffset_GetCombinerOutputParameterivNV 509
+#define _gloffset_GetFinalCombinerInputParameterfvNV 510
+#define _gloffset_GetFinalCombinerInputParameterivNV 511
+#define _gloffset_ResizeBuffersMESA 512
+#define _gloffset_WindowPos2dMESA 513
+#define _gloffset_WindowPos2dvMESA 514
+#define _gloffset_WindowPos2fMESA 515
+#define _gloffset_WindowPos2fvMESA 516
+#define _gloffset_WindowPos2iMESA 517
+#define _gloffset_WindowPos2ivMESA 518
+#define _gloffset_WindowPos2sMESA 519
+#define _gloffset_WindowPos2svMESA 520
+#define _gloffset_WindowPos3dMESA 521
+#define _gloffset_WindowPos3dvMESA 522
+#define _gloffset_WindowPos3fMESA 523
+#define _gloffset_WindowPos3fvMESA 524
+#define _gloffset_WindowPos3iMESA 525
+#define _gloffset_WindowPos3ivMESA 526
+#define _gloffset_WindowPos3sMESA 527
+#define _gloffset_WindowPos3svMESA 528
+#define _gloffset_WindowPos4dMESA 529
+#define _gloffset_WindowPos4dvMESA 530
+#define _gloffset_WindowPos4fMESA 531
+#define _gloffset_WindowPos4fvMESA 532
+#define _gloffset_WindowPos4iMESA 533
+#define _gloffset_WindowPos4ivMESA 534
+#define _gloffset_WindowPos4sMESA 535
+#define _gloffset_WindowPos4svMESA 536
+#define _gloffset_BlendFuncSeparateEXT 537
+#define _gloffset_IndexMaterialEXT 538
+#define _gloffset_IndexFuncEXT 539
+#define _gloffset_LockArraysEXT 540
+#define _gloffset_UnlockArraysEXT 541
+#define _gloffset_CullParameterdvEXT 542
+#define _gloffset_CullParameterfvEXT 543
+#define _gloffset_HintPGI 544
+#define _gloffset_FogCoordfEXT 545
+#define _gloffset_FogCoordfvEXT 546
+#define _gloffset_FogCoorddEXT 547
+#define _gloffset_FogCoorddvEXT 548
+#define _gloffset_FogCoordPointerEXT 549
+#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
+#define _gloffset_SecondaryColor3bEXT 561
+#define _gloffset_SecondaryColor3bvEXT 562
+#define _gloffset_SecondaryColor3dEXT 563
+#define _gloffset_SecondaryColor3dvEXT 564
+#define _gloffset_SecondaryColor3fEXT 565
+#define _gloffset_SecondaryColor3fvEXT 566
+#define _gloffset_SecondaryColor3iEXT 567
+#define _gloffset_SecondaryColor3ivEXT 568
+#define _gloffset_SecondaryColor3sEXT 569
+#define _gloffset_SecondaryColor3svEXT 570
+#define _gloffset_SecondaryColor3ubEXT 571
+#define _gloffset_SecondaryColor3ubvEXT 572
+#define _gloffset_SecondaryColor3uiEXT 573
+#define _gloffset_SecondaryColor3uivEXT 574
+#define _gloffset_SecondaryColor3usEXT 575
+#define _gloffset_SecondaryColor3usvEXT 576
+#define _gloffset_SecondaryColorPointerEXT 577
+#define _gloffset_AreProgramsResidentNV 578
+#define _gloffset_BindProgramNV 579
+#define _gloffset_DeleteProgramsNV 580
+#define _gloffset_ExecuteProgramNV 581
+#define _gloffset_GenProgramsNV 582
+#define _gloffset_GetProgramParameterdvNV 583
+#define _gloffset_GetProgramParameterfvNV 584
+#define _gloffset_GetProgramivNV 585
+#define _gloffset_GetProgramStringNV 586
+#define _gloffset_GetTrackMatrixivNV 587
+#define _gloffset_GetVertexAttribdvARB 588
+#define _gloffset_GetVertexAttribfvARB 589
+#define _gloffset_GetVertexAttribivARB 590
+#define _gloffset_GetVertexAttribPointervNV 591
+#define _gloffset_IsProgramNV 592
+#define _gloffset_LoadProgramNV 593
+#define _gloffset_ProgramParameter4dNV 594
+#define _gloffset_ProgramParameter4dvNV 595
+#define _gloffset_ProgramParameter4fNV 596
+#define _gloffset_ProgramParameter4fvNV 597
+#define _gloffset_ProgramParameters4dvNV 598
+#define _gloffset_ProgramParameters4fvNV 599
+#define _gloffset_RequestResidentProgramsNV 600
+#define _gloffset_TrackMatrixNV 601
+#define _gloffset_VertexAttribPointerNV 602
+#define _gloffset_VertexAttrib1dARB 603
+#define _gloffset_VertexAttrib1dvARB 604
+#define _gloffset_VertexAttrib1fARB 605
+#define _gloffset_VertexAttrib1fvARB 606
+#define _gloffset_VertexAttrib1sARB 607
+#define _gloffset_VertexAttrib1svARB 608
+#define _gloffset_VertexAttrib2dARB 609
+#define _gloffset_VertexAttrib2dvARB 610
+#define _gloffset_VertexAttrib2fARB 611
+#define _gloffset_VertexAttrib2fvARB 612
+#define _gloffset_VertexAttrib2sARB 613
+#define _gloffset_VertexAttrib2svARB 614
+#define _gloffset_VertexAttrib3dARB 615
+#define _gloffset_VertexAttrib3dvARB 616
+#define _gloffset_VertexAttrib3fARB 617
+#define _gloffset_VertexAttrib3fvARB 618
+#define _gloffset_VertexAttrib3sARB 619
+#define _gloffset_VertexAttrib3svARB 620
+#define _gloffset_VertexAttrib4dARB 621
+#define _gloffset_VertexAttrib4dvARB 622
+#define _gloffset_VertexAttrib4fARB 623
+#define _gloffset_VertexAttrib4fvARB 624
+#define _gloffset_VertexAttrib4sARB 625
+#define _gloffset_VertexAttrib4svARB 626
+#define _gloffset_VertexAttrib4NubARB 627
+#define _gloffset_VertexAttrib4NubvARB 628
+#define _gloffset_VertexAttribs1dvNV 629
+#define _gloffset_VertexAttribs1fvNV 630
+#define _gloffset_VertexAttribs1svNV 631
+#define _gloffset_VertexAttribs2dvNV 632
+#define _gloffset_VertexAttribs2fvNV 633
+#define _gloffset_VertexAttribs2svNV 634
+#define _gloffset_VertexAttribs3dvNV 635
+#define _gloffset_VertexAttribs3fvNV 636
+#define _gloffset_VertexAttribs3svNV 637
+#define _gloffset_VertexAttribs4dvNV 638
+#define _gloffset_VertexAttribs4fvNV 639
+#define _gloffset_VertexAttribs4svNV 640
+#define _gloffset_VertexAttribs4ubvNV 641
+#define _gloffset_PointParameteriNV 642
+#define _gloffset_PointParameterivNV 643
+#define _gloffset_MultiDrawArraysEXT 644
+#define _gloffset_MultiDrawElementsEXT 645
+#define _gloffset_ActiveStencilFaceEXT 646
+#define _gloffset_DeleteFencesNV 647
+#define _gloffset_GenFencesNV 648
+#define _gloffset_IsFenceNV 649
+#define _gloffset_TestFenceNV 650
+#define _gloffset_GetFenceivNV 651
+#define _gloffset_FinishFenceNV 652
+#define _gloffset_SetFenceNV 653
+#define _gloffset_VertexAttrib4bvARB 654
+#define _gloffset_VertexAttrib4ivARB 655
+#define _gloffset_VertexAttrib4ubvARB 656
+#define _gloffset_VertexAttrib4usvARB 657
+#define _gloffset_VertexAttrib4uivARB 658
+#define _gloffset_VertexAttrib4NbvARB 659
+#define _gloffset_VertexAttrib4NsvARB 660
+#define _gloffset_VertexAttrib4NivARB 661
+#define _gloffset_VertexAttrib4NusvARB 662
+#define _gloffset_VertexAttrib4NuivARB 663
+#define _gloffset_VertexAttribPointerARB 664
+#define _gloffset_EnableVertexAttribArrayARB 665
+#define _gloffset_DisableVertexAttribArrayARB 666
+#define _gloffset_ProgramStringARB 667
+#define _gloffset_ProgramEnvParameter4dARB 668
+#define _gloffset_ProgramEnvParameter4dvARB 669
+#define _gloffset_ProgramEnvParameter4fARB 670
+#define _gloffset_ProgramEnvParameter4fvARB 671
+#define _gloffset_ProgramLocalParameter4dARB 672
+#define _gloffset_ProgramLocalParameter4dvARB 673
+#define _gloffset_ProgramLocalParameter4fARB 674
+#define _gloffset_ProgramLocalParameter4fvARB 675
+#define _gloffset_GetProgramEnvParameterdvARB 676
+#define _gloffset_GetProgramEnvParameterfvARB 677
+#define _gloffset_GetProgramLocalParameterdvARB 678
+#define _gloffset_GetProgramLocalParameterfvARB 679
+#define _gloffset_GetProgramivARB 680
+#define _gloffset_GetProgramStringARB 681
+#define _gloffset_ProgramNamedParameter4fNV 682
+#define _gloffset_ProgramNamedParameter4dNV 683
+#define _gloffset_ProgramNamedParameter4fvNV 684
+#define _gloffset_ProgramNamedParameter4dvNV 685
+#define _gloffset_GetProgramNamedParameterfvNV 686
+#define _gloffset_GetProgramNamedParameterdvNV 687
+#define _gloffset_BindBufferARB 688
+#define _gloffset_BufferDataARB 689
+#define _gloffset_BufferSubDataARB 690
+#define _gloffset_DeleteBuffersARB 691
+#define _gloffset_GenBuffersARB 692
+#define _gloffset_GetBufferParameterivARB 693
+#define _gloffset_GetBufferPointervARB 694
+#define _gloffset_GetBufferSubDataARB 695
+#define _gloffset_IsBufferARB 696
+#define _gloffset_MapBufferARB 697
+#define _gloffset_UnmapBufferARB 698
+#define _gloffset_DepthBoundsEXT 699
+#define _gloffset_GenQueriesARB 700
+#define _gloffset_DeleteQueriesARB 701
+#define _gloffset_IsQueryARB 702
+#define _gloffset_BeginQueryARB 703
+#define _gloffset_EndQueryARB 704
+#define _gloffset_GetQueryivARB 705
+#define _gloffset_GetQueryObjectivARB 706
+#define _gloffset_GetQueryObjectuivARB 707
+#define _gloffset_MultiModeDrawArraysIBM 708
+#define _gloffset_MultiModeDrawElementsIBM 709
+#define _gloffset_BlendEquationSeparateEXT 710
+#define _gloffset_DeleteObjectARB 711
+#define _gloffset_GetHandleARB 712
+#define _gloffset_DetachObjectARB 713
+#define _gloffset_CreateShaderObjectARB 714
+#define _gloffset_ShaderSourceARB 715
+#define _gloffset_CompileShaderARB 716
+#define _gloffset_CreateProgramObjectARB 717
+#define _gloffset_AttachObjectARB 718
+#define _gloffset_LinkProgramARB 719
+#define _gloffset_UseProgramObjectARB 720
+#define _gloffset_ValidateProgramARB 721
+#define _gloffset_Uniform1fARB 722
+#define _gloffset_Uniform2fARB 723
+#define _gloffset_Uniform3fARB 724
+#define _gloffset_Uniform4fARB 725
+#define _gloffset_Uniform1iARB 726
+#define _gloffset_Uniform2iARB 727
+#define _gloffset_Uniform3iARB 728
+#define _gloffset_Uniform4iARB 729
+#define _gloffset_Uniform1fvARB 730
+#define _gloffset_Uniform2fvARB 731
+#define _gloffset_Uniform3fvARB 732
+#define _gloffset_Uniform4fvARB 733
+#define _gloffset_Uniform1ivARB 734
+#define _gloffset_Uniform2ivARB 735
+#define _gloffset_Uniform3ivARB 736
+#define _gloffset_Uniform4ivARB 737
+#define _gloffset_UniformMatrix2fvARB 738
+#define _gloffset_UniformMatrix3fvARB 739
+#define _gloffset_UniformMatrix4fvARB 740
+#define _gloffset_GetObjectParameterfvARB 741
+#define _gloffset_GetObjectParameterivARB 742
+#define _gloffset_GetInfoLogARB 743
+#define _gloffset_GetAttachedObjectsARB 744
+#define _gloffset_GetUniformLocationARB 745
+#define _gloffset_GetActiveUniformARB 746
+#define _gloffset_GetUniformfvARB 747
+#define _gloffset_GetUniformivARB 748
+#define _gloffset_GetShaderSourceARB 749
+#define _gloffset_BindAttribLocationARB 750
+#define _gloffset_GetActiveAttribARB 751
+#define _gloffset_GetAttribLocationARB 752
+#define _gloffset_GetVertexAttribdvNV 753
+#define _gloffset_GetVertexAttribfvNV 754
+#define _gloffset_GetVertexAttribivNV 755
+#define _gloffset_VertexAttrib1dNV 756
+#define _gloffset_VertexAttrib1dvNV 757
+#define _gloffset_VertexAttrib1fNV 758
+#define _gloffset_VertexAttrib1fvNV 759
+#define _gloffset_VertexAttrib1sNV 760
+#define _gloffset_VertexAttrib1svNV 761
+#define _gloffset_VertexAttrib2dNV 762
+#define _gloffset_VertexAttrib2dvNV 763
+#define _gloffset_VertexAttrib2fNV 764
+#define _gloffset_VertexAttrib2fvNV 765
+#define _gloffset_VertexAttrib2sNV 766
+#define _gloffset_VertexAttrib2svNV 767
+#define _gloffset_VertexAttrib3dNV 768
+#define _gloffset_VertexAttrib3dvNV 769
+#define _gloffset_VertexAttrib3fNV 770
+#define _gloffset_VertexAttrib3fvNV 771
+#define _gloffset_VertexAttrib3sNV 772
+#define _gloffset_VertexAttrib3svNV 773
+#define _gloffset_VertexAttrib4dNV 774
+#define _gloffset_VertexAttrib4dvNV 775
+#define _gloffset_VertexAttrib4fNV 776
+#define _gloffset_VertexAttrib4fvNV 777
+#define _gloffset_VertexAttrib4sNV 778
+#define _gloffset_VertexAttrib4svNV 779
+#define _gloffset_VertexAttrib4ubNV 780
+#define _gloffset_VertexAttrib4ubvNV 781
+#define _gloffset_GenFragmentShadersATI 782
+#define _gloffset_BindFragmentShaderATI 783
+#define _gloffset_DeleteFragmentShaderATI 784
+#define _gloffset_BeginFragmentShaderATI 785
+#define _gloffset_EndFragmentShaderATI 786
+#define _gloffset_PassTexCoordATI 787
+#define _gloffset_SampleMapATI 788
+#define _gloffset_ColorFragmentOp1ATI 789
+#define _gloffset_ColorFragmentOp2ATI 790
+#define _gloffset_ColorFragmentOp3ATI 791
+#define _gloffset_AlphaFragmentOp1ATI 792
+#define _gloffset_AlphaFragmentOp2ATI 793
+#define _gloffset_AlphaFragmentOp3ATI 794
+#define _gloffset_SetFragmentShaderConstantATI 795
+#define _gloffset_IsRenderbufferEXT 796
+#define _gloffset_BindRenderbufferEXT 797
+#define _gloffset_DeleteRenderbuffersEXT 798
+#define _gloffset_GenRenderbuffersEXT 799
+#define _gloffset_RenderbufferStorageEXT 800
+#define _gloffset_GetRenderbufferParameterivEXT 801
+#define _gloffset_IsFramebufferEXT 802
+#define _gloffset_BindFramebufferEXT 803
+#define _gloffset_DeleteFramebuffersEXT 804
+#define _gloffset_GenFramebuffersEXT 805
+#define _gloffset_CheckFramebufferStatusEXT 806
+#define _gloffset_FramebufferTexture1DEXT 807
+#define _gloffset_FramebufferTexture2DEXT 808
+#define _gloffset_FramebufferTexture3DEXT 809
+#define _gloffset_FramebufferRenderbufferEXT 810
+#define _gloffset_GetFramebufferAttachmentParameterivEXT 811
+#define _gloffset_GenerateMipmapEXT 812
+#define _gloffset_StencilFuncSeparate 813
+#define _gloffset_StencilOpSeparate 814
+#define _gloffset_StencilMaskSeparate 815
+#define _gloffset_FIRST_DYNAMIC 816
+
+#else
+
+#define _gloffset_LoadTransposeMatrixfARB driDispatchRemapTable[LoadTransposeMatrixfARB_remap_index]
+#define _gloffset_LoadTransposeMatrixdARB driDispatchRemapTable[LoadTransposeMatrixdARB_remap_index]
+#define _gloffset_MultTransposeMatrixfARB driDispatchRemapTable[MultTransposeMatrixfARB_remap_index]
+#define _gloffset_MultTransposeMatrixdARB driDispatchRemapTable[MultTransposeMatrixdARB_remap_index]
+#define _gloffset_SampleCoverageARB driDispatchRemapTable[SampleCoverageARB_remap_index]
+#define _gloffset_DrawBuffersARB driDispatchRemapTable[DrawBuffersARB_remap_index]
+#define _gloffset_PolygonOffsetEXT driDispatchRemapTable[PolygonOffsetEXT_remap_index]
+#define _gloffset_GetTexFilterFuncSGIS driDispatchRemapTable[GetTexFilterFuncSGIS_remap_index]
+#define _gloffset_TexFilterFuncSGIS driDispatchRemapTable[TexFilterFuncSGIS_remap_index]
+#define _gloffset_GetHistogramEXT driDispatchRemapTable[GetHistogramEXT_remap_index]
+#define _gloffset_GetHistogramParameterfvEXT driDispatchRemapTable[GetHistogramParameterfvEXT_remap_index]
+#define _gloffset_GetHistogramParameterivEXT driDispatchRemapTable[GetHistogramParameterivEXT_remap_index]
+#define _gloffset_GetMinmaxEXT driDispatchRemapTable[GetMinmaxEXT_remap_index]
+#define _gloffset_GetMinmaxParameterfvEXT driDispatchRemapTable[GetMinmaxParameterfvEXT_remap_index]
+#define _gloffset_GetMinmaxParameterivEXT driDispatchRemapTable[GetMinmaxParameterivEXT_remap_index]
+#define _gloffset_GetConvolutionFilterEXT driDispatchRemapTable[GetConvolutionFilterEXT_remap_index]
+#define _gloffset_GetConvolutionParameterfvEXT driDispatchRemapTable[GetConvolutionParameterfvEXT_remap_index]
+#define _gloffset_GetConvolutionParameterivEXT driDispatchRemapTable[GetConvolutionParameterivEXT_remap_index]
+#define _gloffset_GetSeparableFilterEXT driDispatchRemapTable[GetSeparableFilterEXT_remap_index]
+#define _gloffset_GetColorTableSGI driDispatchRemapTable[GetColorTableSGI_remap_index]
+#define _gloffset_GetColorTableParameterfvSGI driDispatchRemapTable[GetColorTableParameterfvSGI_remap_index]
+#define _gloffset_GetColorTableParameterivSGI driDispatchRemapTable[GetColorTableParameterivSGI_remap_index]
+#define _gloffset_PixelTexGenSGIX driDispatchRemapTable[PixelTexGenSGIX_remap_index]
+#define _gloffset_PixelTexGenParameteriSGIS driDispatchRemapTable[PixelTexGenParameteriSGIS_remap_index]
+#define _gloffset_PixelTexGenParameterivSGIS driDispatchRemapTable[PixelTexGenParameterivSGIS_remap_index]
+#define _gloffset_PixelTexGenParameterfSGIS driDispatchRemapTable[PixelTexGenParameterfSGIS_remap_index]
+#define _gloffset_PixelTexGenParameterfvSGIS driDispatchRemapTable[PixelTexGenParameterfvSGIS_remap_index]
+#define _gloffset_GetPixelTexGenParameterivSGIS driDispatchRemapTable[GetPixelTexGenParameterivSGIS_remap_index]
+#define _gloffset_GetPixelTexGenParameterfvSGIS driDispatchRemapTable[GetPixelTexGenParameterfvSGIS_remap_index]
+#define _gloffset_TexImage4DSGIS driDispatchRemapTable[TexImage4DSGIS_remap_index]
+#define _gloffset_TexSubImage4DSGIS driDispatchRemapTable[TexSubImage4DSGIS_remap_index]
+#define _gloffset_AreTexturesResidentEXT driDispatchRemapTable[AreTexturesResidentEXT_remap_index]
+#define _gloffset_GenTexturesEXT driDispatchRemapTable[GenTexturesEXT_remap_index]
+#define _gloffset_IsTextureEXT driDispatchRemapTable[IsTextureEXT_remap_index]
+#define _gloffset_DetailTexFuncSGIS driDispatchRemapTable[DetailTexFuncSGIS_remap_index]
+#define _gloffset_GetDetailTexFuncSGIS driDispatchRemapTable[GetDetailTexFuncSGIS_remap_index]
+#define _gloffset_SharpenTexFuncSGIS driDispatchRemapTable[SharpenTexFuncSGIS_remap_index]
+#define _gloffset_GetSharpenTexFuncSGIS driDispatchRemapTable[GetSharpenTexFuncSGIS_remap_index]
+#define _gloffset_SampleMaskSGIS driDispatchRemapTable[SampleMaskSGIS_remap_index]
+#define _gloffset_SamplePatternSGIS driDispatchRemapTable[SamplePatternSGIS_remap_index]
+#define _gloffset_ColorPointerEXT driDispatchRemapTable[ColorPointerEXT_remap_index]
+#define _gloffset_EdgeFlagPointerEXT driDispatchRemapTable[EdgeFlagPointerEXT_remap_index]
+#define _gloffset_IndexPointerEXT driDispatchRemapTable[IndexPointerEXT_remap_index]
+#define _gloffset_NormalPointerEXT driDispatchRemapTable[NormalPointerEXT_remap_index]
+#define _gloffset_TexCoordPointerEXT driDispatchRemapTable[TexCoordPointerEXT_remap_index]
+#define _gloffset_VertexPointerEXT driDispatchRemapTable[VertexPointerEXT_remap_index]
+#define _gloffset_SpriteParameterfSGIX driDispatchRemapTable[SpriteParameterfSGIX_remap_index]
+#define _gloffset_SpriteParameterfvSGIX driDispatchRemapTable[SpriteParameterfvSGIX_remap_index]
+#define _gloffset_SpriteParameteriSGIX driDispatchRemapTable[SpriteParameteriSGIX_remap_index]
+#define _gloffset_SpriteParameterivSGIX driDispatchRemapTable[SpriteParameterivSGIX_remap_index]
+#define _gloffset_PointParameterfEXT driDispatchRemapTable[PointParameterfEXT_remap_index]
+#define _gloffset_PointParameterfvEXT driDispatchRemapTable[PointParameterfvEXT_remap_index]
+#define _gloffset_GetInstrumentsSGIX driDispatchRemapTable[GetInstrumentsSGIX_remap_index]
+#define _gloffset_InstrumentsBufferSGIX driDispatchRemapTable[InstrumentsBufferSGIX_remap_index]
+#define _gloffset_PollInstrumentsSGIX driDispatchRemapTable[PollInstrumentsSGIX_remap_index]
+#define _gloffset_ReadInstrumentsSGIX driDispatchRemapTable[ReadInstrumentsSGIX_remap_index]
+#define _gloffset_StartInstrumentsSGIX driDispatchRemapTable[StartInstrumentsSGIX_remap_index]
+#define _gloffset_StopInstrumentsSGIX driDispatchRemapTable[StopInstrumentsSGIX_remap_index]
+#define _gloffset_FrameZoomSGIX driDispatchRemapTable[FrameZoomSGIX_remap_index]
+#define _gloffset_TagSampleBufferSGIX driDispatchRemapTable[TagSampleBufferSGIX_remap_index]
+#define _gloffset_ReferencePlaneSGIX driDispatchRemapTable[ReferencePlaneSGIX_remap_index]
+#define _gloffset_FlushRasterSGIX driDispatchRemapTable[FlushRasterSGIX_remap_index]
+#define _gloffset_GetListParameterfvSGIX driDispatchRemapTable[GetListParameterfvSGIX_remap_index]
+#define _gloffset_GetListParameterivSGIX driDispatchRemapTable[GetListParameterivSGIX_remap_index]
+#define _gloffset_ListParameterfSGIX driDispatchRemapTable[ListParameterfSGIX_remap_index]
+#define _gloffset_ListParameterfvSGIX driDispatchRemapTable[ListParameterfvSGIX_remap_index]
+#define _gloffset_ListParameteriSGIX driDispatchRemapTable[ListParameteriSGIX_remap_index]
+#define _gloffset_ListParameterivSGIX driDispatchRemapTable[ListParameterivSGIX_remap_index]
+#define _gloffset_FragmentColorMaterialSGIX driDispatchRemapTable[FragmentColorMaterialSGIX_remap_index]
+#define _gloffset_FragmentLightfSGIX driDispatchRemapTable[FragmentLightfSGIX_remap_index]
+#define _gloffset_FragmentLightfvSGIX driDispatchRemapTable[FragmentLightfvSGIX_remap_index]
+#define _gloffset_FragmentLightiSGIX driDispatchRemapTable[FragmentLightiSGIX_remap_index]
+#define _gloffset_FragmentLightivSGIX driDispatchRemapTable[FragmentLightivSGIX_remap_index]
+#define _gloffset_FragmentLightModelfSGIX driDispatchRemapTable[FragmentLightModelfSGIX_remap_index]
+#define _gloffset_FragmentLightModelfvSGIX driDispatchRemapTable[FragmentLightModelfvSGIX_remap_index]
+#define _gloffset_FragmentLightModeliSGIX driDispatchRemapTable[FragmentLightModeliSGIX_remap_index]
+#define _gloffset_FragmentLightModelivSGIX driDispatchRemapTable[FragmentLightModelivSGIX_remap_index]
+#define _gloffset_FragmentMaterialfSGIX driDispatchRemapTable[FragmentMaterialfSGIX_remap_index]
+#define _gloffset_FragmentMaterialfvSGIX driDispatchRemapTable[FragmentMaterialfvSGIX_remap_index]
+#define _gloffset_FragmentMaterialiSGIX driDispatchRemapTable[FragmentMaterialiSGIX_remap_index]
+#define _gloffset_FragmentMaterialivSGIX driDispatchRemapTable[FragmentMaterialivSGIX_remap_index]
+#define _gloffset_GetFragmentLightfvSGIX driDispatchRemapTable[GetFragmentLightfvSGIX_remap_index]
+#define _gloffset_GetFragmentLightivSGIX driDispatchRemapTable[GetFragmentLightivSGIX_remap_index]
+#define _gloffset_GetFragmentMaterialfvSGIX driDispatchRemapTable[GetFragmentMaterialfvSGIX_remap_index]
+#define _gloffset_GetFragmentMaterialivSGIX driDispatchRemapTable[GetFragmentMaterialivSGIX_remap_index]
+#define _gloffset_LightEnviSGIX driDispatchRemapTable[LightEnviSGIX_remap_index]
+#define _gloffset_VertexWeightfEXT driDispatchRemapTable[VertexWeightfEXT_remap_index]
+#define _gloffset_VertexWeightfvEXT driDispatchRemapTable[VertexWeightfvEXT_remap_index]
+#define _gloffset_VertexWeightPointerEXT driDispatchRemapTable[VertexWeightPointerEXT_remap_index]
+#define _gloffset_FlushVertexArrayRangeNV driDispatchRemapTable[FlushVertexArrayRangeNV_remap_index]
+#define _gloffset_VertexArrayRangeNV driDispatchRemapTable[VertexArrayRangeNV_remap_index]
+#define _gloffset_CombinerParameterfvNV driDispatchRemapTable[CombinerParameterfvNV_remap_index]
+#define _gloffset_CombinerParameterfNV driDispatchRemapTable[CombinerParameterfNV_remap_index]
+#define _gloffset_CombinerParameterivNV driDispatchRemapTable[CombinerParameterivNV_remap_index]
+#define _gloffset_CombinerParameteriNV driDispatchRemapTable[CombinerParameteriNV_remap_index]
+#define _gloffset_CombinerInputNV driDispatchRemapTable[CombinerInputNV_remap_index]
+#define _gloffset_CombinerOutputNV driDispatchRemapTable[CombinerOutputNV_remap_index]
+#define _gloffset_FinalCombinerInputNV driDispatchRemapTable[FinalCombinerInputNV_remap_index]
+#define _gloffset_GetCombinerInputParameterfvNV driDispatchRemapTable[GetCombinerInputParameterfvNV_remap_index]
+#define _gloffset_GetCombinerInputParameterivNV driDispatchRemapTable[GetCombinerInputParameterivNV_remap_index]
+#define _gloffset_GetCombinerOutputParameterfvNV driDispatchRemapTable[GetCombinerOutputParameterfvNV_remap_index]
+#define _gloffset_GetCombinerOutputParameterivNV driDispatchRemapTable[GetCombinerOutputParameterivNV_remap_index]
+#define _gloffset_GetFinalCombinerInputParameterfvNV driDispatchRemapTable[GetFinalCombinerInputParameterfvNV_remap_index]
+#define _gloffset_GetFinalCombinerInputParameterivNV driDispatchRemapTable[GetFinalCombinerInputParameterivNV_remap_index]
+#define _gloffset_ResizeBuffersMESA driDispatchRemapTable[ResizeBuffersMESA_remap_index]
+#define _gloffset_WindowPos2dMESA driDispatchRemapTable[WindowPos2dMESA_remap_index]
+#define _gloffset_WindowPos2dvMESA driDispatchRemapTable[WindowPos2dvMESA_remap_index]
+#define _gloffset_WindowPos2fMESA driDispatchRemapTable[WindowPos2fMESA_remap_index]
+#define _gloffset_WindowPos2fvMESA driDispatchRemapTable[WindowPos2fvMESA_remap_index]
+#define _gloffset_WindowPos2iMESA driDispatchRemapTable[WindowPos2iMESA_remap_index]
+#define _gloffset_WindowPos2ivMESA driDispatchRemapTable[WindowPos2ivMESA_remap_index]
+#define _gloffset_WindowPos2sMESA driDispatchRemapTable[WindowPos2sMESA_remap_index]
+#define _gloffset_WindowPos2svMESA driDispatchRemapTable[WindowPos2svMESA_remap_index]
+#define _gloffset_WindowPos3dMESA driDispatchRemapTable[WindowPos3dMESA_remap_index]
+#define _gloffset_WindowPos3dvMESA driDispatchRemapTable[WindowPos3dvMESA_remap_index]
+#define _gloffset_WindowPos3fMESA driDispatchRemapTable[WindowPos3fMESA_remap_index]
+#define _gloffset_WindowPos3fvMESA driDispatchRemapTable[WindowPos3fvMESA_remap_index]
+#define _gloffset_WindowPos3iMESA driDispatchRemapTable[WindowPos3iMESA_remap_index]
+#define _gloffset_WindowPos3ivMESA driDispatchRemapTable[WindowPos3ivMESA_remap_index]
+#define _gloffset_WindowPos3sMESA driDispatchRemapTable[WindowPos3sMESA_remap_index]
+#define _gloffset_WindowPos3svMESA driDispatchRemapTable[WindowPos3svMESA_remap_index]
+#define _gloffset_WindowPos4dMESA driDispatchRemapTable[WindowPos4dMESA_remap_index]
+#define _gloffset_WindowPos4dvMESA driDispatchRemapTable[WindowPos4dvMESA_remap_index]
+#define _gloffset_WindowPos4fMESA driDispatchRemapTable[WindowPos4fMESA_remap_index]
+#define _gloffset_WindowPos4fvMESA driDispatchRemapTable[WindowPos4fvMESA_remap_index]
+#define _gloffset_WindowPos4iMESA driDispatchRemapTable[WindowPos4iMESA_remap_index]
+#define _gloffset_WindowPos4ivMESA driDispatchRemapTable[WindowPos4ivMESA_remap_index]
+#define _gloffset_WindowPos4sMESA driDispatchRemapTable[WindowPos4sMESA_remap_index]
+#define _gloffset_WindowPos4svMESA driDispatchRemapTable[WindowPos4svMESA_remap_index]
+#define _gloffset_BlendFuncSeparateEXT driDispatchRemapTable[BlendFuncSeparateEXT_remap_index]
+#define _gloffset_IndexMaterialEXT driDispatchRemapTable[IndexMaterialEXT_remap_index]
+#define _gloffset_IndexFuncEXT driDispatchRemapTable[IndexFuncEXT_remap_index]
+#define _gloffset_LockArraysEXT driDispatchRemapTable[LockArraysEXT_remap_index]
+#define _gloffset_UnlockArraysEXT driDispatchRemapTable[UnlockArraysEXT_remap_index]
+#define _gloffset_CullParameterdvEXT driDispatchRemapTable[CullParameterdvEXT_remap_index]
+#define _gloffset_CullParameterfvEXT driDispatchRemapTable[CullParameterfvEXT_remap_index]
+#define _gloffset_HintPGI driDispatchRemapTable[HintPGI_remap_index]
+#define _gloffset_FogCoordfEXT driDispatchRemapTable[FogCoordfEXT_remap_index]
+#define _gloffset_FogCoordfvEXT driDispatchRemapTable[FogCoordfvEXT_remap_index]
+#define _gloffset_FogCoorddEXT driDispatchRemapTable[FogCoorddEXT_remap_index]
+#define _gloffset_FogCoorddvEXT driDispatchRemapTable[FogCoorddvEXT_remap_index]
+#define _gloffset_FogCoordPointerEXT driDispatchRemapTable[FogCoordPointerEXT_remap_index]
+#define _gloffset_GetColorTableEXT driDispatchRemapTable[GetColorTableEXT_remap_index]
+#define _gloffset_GetColorTableParameterivEXT driDispatchRemapTable[GetColorTableParameterivEXT_remap_index]
+#define _gloffset_GetColorTableParameterfvEXT driDispatchRemapTable[GetColorTableParameterfvEXT_remap_index]
+#define _gloffset_TbufferMask3DFX driDispatchRemapTable[TbufferMask3DFX_remap_index]
+#define _gloffset_CompressedTexImage3DARB driDispatchRemapTable[CompressedTexImage3DARB_remap_index]
+#define _gloffset_CompressedTexImage2DARB driDispatchRemapTable[CompressedTexImage2DARB_remap_index]
+#define _gloffset_CompressedTexImage1DARB driDispatchRemapTable[CompressedTexImage1DARB_remap_index]
+#define _gloffset_CompressedTexSubImage3DARB driDispatchRemapTable[CompressedTexSubImage3DARB_remap_index]
+#define _gloffset_CompressedTexSubImage2DARB driDispatchRemapTable[CompressedTexSubImage2DARB_remap_index]
+#define _gloffset_CompressedTexSubImage1DARB driDispatchRemapTable[CompressedTexSubImage1DARB_remap_index]
+#define _gloffset_GetCompressedTexImageARB driDispatchRemapTable[GetCompressedTexImageARB_remap_index]
+#define _gloffset_SecondaryColor3bEXT driDispatchRemapTable[SecondaryColor3bEXT_remap_index]
+#define _gloffset_SecondaryColor3bvEXT driDispatchRemapTable[SecondaryColor3bvEXT_remap_index]
+#define _gloffset_SecondaryColor3dEXT driDispatchRemapTable[SecondaryColor3dEXT_remap_index]
+#define _gloffset_SecondaryColor3dvEXT driDispatchRemapTable[SecondaryColor3dvEXT_remap_index]
+#define _gloffset_SecondaryColor3fEXT driDispatchRemapTable[SecondaryColor3fEXT_remap_index]
+#define _gloffset_SecondaryColor3fvEXT driDispatchRemapTable[SecondaryColor3fvEXT_remap_index]
+#define _gloffset_SecondaryColor3iEXT driDispatchRemapTable[SecondaryColor3iEXT_remap_index]
+#define _gloffset_SecondaryColor3ivEXT driDispatchRemapTable[SecondaryColor3ivEXT_remap_index]
+#define _gloffset_SecondaryColor3sEXT driDispatchRemapTable[SecondaryColor3sEXT_remap_index]
+#define _gloffset_SecondaryColor3svEXT driDispatchRemapTable[SecondaryColor3svEXT_remap_index]
+#define _gloffset_SecondaryColor3ubEXT driDispatchRemapTable[SecondaryColor3ubEXT_remap_index]
+#define _gloffset_SecondaryColor3ubvEXT driDispatchRemapTable[SecondaryColor3ubvEXT_remap_index]
+#define _gloffset_SecondaryColor3uiEXT driDispatchRemapTable[SecondaryColor3uiEXT_remap_index]
+#define _gloffset_SecondaryColor3uivEXT driDispatchRemapTable[SecondaryColor3uivEXT_remap_index]
+#define _gloffset_SecondaryColor3usEXT driDispatchRemapTable[SecondaryColor3usEXT_remap_index]
+#define _gloffset_SecondaryColor3usvEXT driDispatchRemapTable[SecondaryColor3usvEXT_remap_index]
+#define _gloffset_SecondaryColorPointerEXT driDispatchRemapTable[SecondaryColorPointerEXT_remap_index]
+#define _gloffset_AreProgramsResidentNV driDispatchRemapTable[AreProgramsResidentNV_remap_index]
+#define _gloffset_BindProgramNV driDispatchRemapTable[BindProgramNV_remap_index]
+#define _gloffset_DeleteProgramsNV driDispatchRemapTable[DeleteProgramsNV_remap_index]
+#define _gloffset_ExecuteProgramNV driDispatchRemapTable[ExecuteProgramNV_remap_index]
+#define _gloffset_GenProgramsNV driDispatchRemapTable[GenProgramsNV_remap_index]
+#define _gloffset_GetProgramParameterdvNV driDispatchRemapTable[GetProgramParameterdvNV_remap_index]
+#define _gloffset_GetProgramParameterfvNV driDispatchRemapTable[GetProgramParameterfvNV_remap_index]
+#define _gloffset_GetProgramivNV driDispatchRemapTable[GetProgramivNV_remap_index]
+#define _gloffset_GetProgramStringNV driDispatchRemapTable[GetProgramStringNV_remap_index]
+#define _gloffset_GetTrackMatrixivNV driDispatchRemapTable[GetTrackMatrixivNV_remap_index]
+#define _gloffset_GetVertexAttribdvARB driDispatchRemapTable[GetVertexAttribdvARB_remap_index]
+#define _gloffset_GetVertexAttribfvARB driDispatchRemapTable[GetVertexAttribfvARB_remap_index]
+#define _gloffset_GetVertexAttribivARB driDispatchRemapTable[GetVertexAttribivARB_remap_index]
+#define _gloffset_GetVertexAttribPointervNV driDispatchRemapTable[GetVertexAttribPointervNV_remap_index]
+#define _gloffset_IsProgramNV driDispatchRemapTable[IsProgramNV_remap_index]
+#define _gloffset_LoadProgramNV driDispatchRemapTable[LoadProgramNV_remap_index]
+#define _gloffset_ProgramParameter4dNV driDispatchRemapTable[ProgramParameter4dNV_remap_index]
+#define _gloffset_ProgramParameter4dvNV driDispatchRemapTable[ProgramParameter4dvNV_remap_index]
+#define _gloffset_ProgramParameter4fNV driDispatchRemapTable[ProgramParameter4fNV_remap_index]
+#define _gloffset_ProgramParameter4fvNV driDispatchRemapTable[ProgramParameter4fvNV_remap_index]
+#define _gloffset_ProgramParameters4dvNV driDispatchRemapTable[ProgramParameters4dvNV_remap_index]
+#define _gloffset_ProgramParameters4fvNV driDispatchRemapTable[ProgramParameters4fvNV_remap_index]
+#define _gloffset_RequestResidentProgramsNV driDispatchRemapTable[RequestResidentProgramsNV_remap_index]
+#define _gloffset_TrackMatrixNV driDispatchRemapTable[TrackMatrixNV_remap_index]
+#define _gloffset_VertexAttribPointerNV driDispatchRemapTable[VertexAttribPointerNV_remap_index]
+#define _gloffset_VertexAttrib1dARB driDispatchRemapTable[VertexAttrib1dARB_remap_index]
+#define _gloffset_VertexAttrib1dvARB driDispatchRemapTable[VertexAttrib1dvARB_remap_index]
+#define _gloffset_VertexAttrib1fARB driDispatchRemapTable[VertexAttrib1fARB_remap_index]
+#define _gloffset_VertexAttrib1fvARB driDispatchRemapTable[VertexAttrib1fvARB_remap_index]
+#define _gloffset_VertexAttrib1sARB driDispatchRemapTable[VertexAttrib1sARB_remap_index]
+#define _gloffset_VertexAttrib1svARB driDispatchRemapTable[VertexAttrib1svARB_remap_index]
+#define _gloffset_VertexAttrib2dARB driDispatchRemapTable[VertexAttrib2dARB_remap_index]
+#define _gloffset_VertexAttrib2dvARB driDispatchRemapTable[VertexAttrib2dvARB_remap_index]
+#define _gloffset_VertexAttrib2fARB driDispatchRemapTable[VertexAttrib2fARB_remap_index]
+#define _gloffset_VertexAttrib2fvARB driDispatchRemapTable[VertexAttrib2fvARB_remap_index]
+#define _gloffset_VertexAttrib2sARB driDispatchRemapTable[VertexAttrib2sARB_remap_index]
+#define _gloffset_VertexAttrib2svARB driDispatchRemapTable[VertexAttrib2svARB_remap_index]
+#define _gloffset_VertexAttrib3dARB driDispatchRemapTable[VertexAttrib3dARB_remap_index]
+#define _gloffset_VertexAttrib3dvARB driDispatchRemapTable[VertexAttrib3dvARB_remap_index]
+#define _gloffset_VertexAttrib3fARB driDispatchRemapTable[VertexAttrib3fARB_remap_index]
+#define _gloffset_VertexAttrib3fvARB driDispatchRemapTable[VertexAttrib3fvARB_remap_index]
+#define _gloffset_VertexAttrib3sARB driDispatchRemapTable[VertexAttrib3sARB_remap_index]
+#define _gloffset_VertexAttrib3svARB driDispatchRemapTable[VertexAttrib3svARB_remap_index]
+#define _gloffset_VertexAttrib4dARB driDispatchRemapTable[VertexAttrib4dARB_remap_index]
+#define _gloffset_VertexAttrib4dvARB driDispatchRemapTable[VertexAttrib4dvARB_remap_index]
+#define _gloffset_VertexAttrib4fARB driDispatchRemapTable[VertexAttrib4fARB_remap_index]
+#define _gloffset_VertexAttrib4fvARB driDispatchRemapTable[VertexAttrib4fvARB_remap_index]
+#define _gloffset_VertexAttrib4sARB driDispatchRemapTable[VertexAttrib4sARB_remap_index]
+#define _gloffset_VertexAttrib4svARB driDispatchRemapTable[VertexAttrib4svARB_remap_index]
+#define _gloffset_VertexAttrib4NubARB driDispatchRemapTable[VertexAttrib4NubARB_remap_index]
+#define _gloffset_VertexAttrib4NubvARB driDispatchRemapTable[VertexAttrib4NubvARB_remap_index]
+#define _gloffset_VertexAttribs1dvNV driDispatchRemapTable[VertexAttribs1dvNV_remap_index]
+#define _gloffset_VertexAttribs1fvNV driDispatchRemapTable[VertexAttribs1fvNV_remap_index]
+#define _gloffset_VertexAttribs1svNV driDispatchRemapTable[VertexAttribs1svNV_remap_index]
+#define _gloffset_VertexAttribs2dvNV driDispatchRemapTable[VertexAttribs2dvNV_remap_index]
+#define _gloffset_VertexAttribs2fvNV driDispatchRemapTable[VertexAttribs2fvNV_remap_index]
+#define _gloffset_VertexAttribs2svNV driDispatchRemapTable[VertexAttribs2svNV_remap_index]
+#define _gloffset_VertexAttribs3dvNV driDispatchRemapTable[VertexAttribs3dvNV_remap_index]
+#define _gloffset_VertexAttribs3fvNV driDispatchRemapTable[VertexAttribs3fvNV_remap_index]
+#define _gloffset_VertexAttribs3svNV driDispatchRemapTable[VertexAttribs3svNV_remap_index]
+#define _gloffset_VertexAttribs4dvNV driDispatchRemapTable[VertexAttribs4dvNV_remap_index]
+#define _gloffset_VertexAttribs4fvNV driDispatchRemapTable[VertexAttribs4fvNV_remap_index]
+#define _gloffset_VertexAttribs4svNV driDispatchRemapTable[VertexAttribs4svNV_remap_index]
+#define _gloffset_VertexAttribs4ubvNV driDispatchRemapTable[VertexAttribs4ubvNV_remap_index]
+#define _gloffset_PointParameteriNV driDispatchRemapTable[PointParameteriNV_remap_index]
+#define _gloffset_PointParameterivNV driDispatchRemapTable[PointParameterivNV_remap_index]
+#define _gloffset_MultiDrawArraysEXT driDispatchRemapTable[MultiDrawArraysEXT_remap_index]
+#define _gloffset_MultiDrawElementsEXT driDispatchRemapTable[MultiDrawElementsEXT_remap_index]
+#define _gloffset_ActiveStencilFaceEXT driDispatchRemapTable[ActiveStencilFaceEXT_remap_index]
+#define _gloffset_DeleteFencesNV driDispatchRemapTable[DeleteFencesNV_remap_index]
+#define _gloffset_GenFencesNV driDispatchRemapTable[GenFencesNV_remap_index]
+#define _gloffset_IsFenceNV driDispatchRemapTable[IsFenceNV_remap_index]
+#define _gloffset_TestFenceNV driDispatchRemapTable[TestFenceNV_remap_index]
+#define _gloffset_GetFenceivNV driDispatchRemapTable[GetFenceivNV_remap_index]
+#define _gloffset_FinishFenceNV driDispatchRemapTable[FinishFenceNV_remap_index]
+#define _gloffset_SetFenceNV driDispatchRemapTable[SetFenceNV_remap_index]
+#define _gloffset_VertexAttrib4bvARB driDispatchRemapTable[VertexAttrib4bvARB_remap_index]
+#define _gloffset_VertexAttrib4ivARB driDispatchRemapTable[VertexAttrib4ivARB_remap_index]
+#define _gloffset_VertexAttrib4ubvARB driDispatchRemapTable[VertexAttrib4ubvARB_remap_index]
+#define _gloffset_VertexAttrib4usvARB driDispatchRemapTable[VertexAttrib4usvARB_remap_index]
+#define _gloffset_VertexAttrib4uivARB driDispatchRemapTable[VertexAttrib4uivARB_remap_index]
+#define _gloffset_VertexAttrib4NbvARB driDispatchRemapTable[VertexAttrib4NbvARB_remap_index]
+#define _gloffset_VertexAttrib4NsvARB driDispatchRemapTable[VertexAttrib4NsvARB_remap_index]
+#define _gloffset_VertexAttrib4NivARB driDispatchRemapTable[VertexAttrib4NivARB_remap_index]
+#define _gloffset_VertexAttrib4NusvARB driDispatchRemapTable[VertexAttrib4NusvARB_remap_index]
+#define _gloffset_VertexAttrib4NuivARB driDispatchRemapTable[VertexAttrib4NuivARB_remap_index]
+#define _gloffset_VertexAttribPointerARB driDispatchRemapTable[VertexAttribPointerARB_remap_index]
+#define _gloffset_EnableVertexAttribArrayARB driDispatchRemapTable[EnableVertexAttribArrayARB_remap_index]
+#define _gloffset_DisableVertexAttribArrayARB driDispatchRemapTable[DisableVertexAttribArrayARB_remap_index]
+#define _gloffset_ProgramStringARB driDispatchRemapTable[ProgramStringARB_remap_index]
+#define _gloffset_ProgramEnvParameter4dARB driDispatchRemapTable[ProgramEnvParameter4dARB_remap_index]
+#define _gloffset_ProgramEnvParameter4dvARB driDispatchRemapTable[ProgramEnvParameter4dvARB_remap_index]
+#define _gloffset_ProgramEnvParameter4fARB driDispatchRemapTable[ProgramEnvParameter4fARB_remap_index]
+#define _gloffset_ProgramEnvParameter4fvARB driDispatchRemapTable[ProgramEnvParameter4fvARB_remap_index]
+#define _gloffset_ProgramLocalParameter4dARB driDispatchRemapTable[ProgramLocalParameter4dARB_remap_index]
+#define _gloffset_ProgramLocalParameter4dvARB driDispatchRemapTable[ProgramLocalParameter4dvARB_remap_index]
+#define _gloffset_ProgramLocalParameter4fARB driDispatchRemapTable[ProgramLocalParameter4fARB_remap_index]
+#define _gloffset_ProgramLocalParameter4fvARB driDispatchRemapTable[ProgramLocalParameter4fvARB_remap_index]
+#define _gloffset_GetProgramEnvParameterdvARB driDispatchRemapTable[GetProgramEnvParameterdvARB_remap_index]
+#define _gloffset_GetProgramEnvParameterfvARB driDispatchRemapTable[GetProgramEnvParameterfvARB_remap_index]
+#define _gloffset_GetProgramLocalParameterdvARB driDispatchRemapTable[GetProgramLocalParameterdvARB_remap_index]
+#define _gloffset_GetProgramLocalParameterfvARB driDispatchRemapTable[GetProgramLocalParameterfvARB_remap_index]
+#define _gloffset_GetProgramivARB driDispatchRemapTable[GetProgramivARB_remap_index]
+#define _gloffset_GetProgramStringARB driDispatchRemapTable[GetProgramStringARB_remap_index]
+#define _gloffset_ProgramNamedParameter4fNV driDispatchRemapTable[ProgramNamedParameter4fNV_remap_index]
+#define _gloffset_ProgramNamedParameter4dNV driDispatchRemapTable[ProgramNamedParameter4dNV_remap_index]
+#define _gloffset_ProgramNamedParameter4fvNV driDispatchRemapTable[ProgramNamedParameter4fvNV_remap_index]
+#define _gloffset_ProgramNamedParameter4dvNV driDispatchRemapTable[ProgramNamedParameter4dvNV_remap_index]
+#define _gloffset_GetProgramNamedParameterfvNV driDispatchRemapTable[GetProgramNamedParameterfvNV_remap_index]
+#define _gloffset_GetProgramNamedParameterdvNV driDispatchRemapTable[GetProgramNamedParameterdvNV_remap_index]
+#define _gloffset_BindBufferARB driDispatchRemapTable[BindBufferARB_remap_index]
+#define _gloffset_BufferDataARB driDispatchRemapTable[BufferDataARB_remap_index]
+#define _gloffset_BufferSubDataARB driDispatchRemapTable[BufferSubDataARB_remap_index]
+#define _gloffset_DeleteBuffersARB driDispatchRemapTable[DeleteBuffersARB_remap_index]
+#define _gloffset_GenBuffersARB driDispatchRemapTable[GenBuffersARB_remap_index]
+#define _gloffset_GetBufferParameterivARB driDispatchRemapTable[GetBufferParameterivARB_remap_index]
+#define _gloffset_GetBufferPointervARB driDispatchRemapTable[GetBufferPointervARB_remap_index]
+#define _gloffset_GetBufferSubDataARB driDispatchRemapTable[GetBufferSubDataARB_remap_index]
+#define _gloffset_IsBufferARB driDispatchRemapTable[IsBufferARB_remap_index]
+#define _gloffset_MapBufferARB driDispatchRemapTable[MapBufferARB_remap_index]
+#define _gloffset_UnmapBufferARB driDispatchRemapTable[UnmapBufferARB_remap_index]
+#define _gloffset_DepthBoundsEXT driDispatchRemapTable[DepthBoundsEXT_remap_index]
+#define _gloffset_GenQueriesARB driDispatchRemapTable[GenQueriesARB_remap_index]
+#define _gloffset_DeleteQueriesARB driDispatchRemapTable[DeleteQueriesARB_remap_index]
+#define _gloffset_IsQueryARB driDispatchRemapTable[IsQueryARB_remap_index]
+#define _gloffset_BeginQueryARB driDispatchRemapTable[BeginQueryARB_remap_index]
+#define _gloffset_EndQueryARB driDispatchRemapTable[EndQueryARB_remap_index]
+#define _gloffset_GetQueryivARB driDispatchRemapTable[GetQueryivARB_remap_index]
+#define _gloffset_GetQueryObjectivARB driDispatchRemapTable[GetQueryObjectivARB_remap_index]
+#define _gloffset_GetQueryObjectuivARB driDispatchRemapTable[GetQueryObjectuivARB_remap_index]
+#define _gloffset_MultiModeDrawArraysIBM driDispatchRemapTable[MultiModeDrawArraysIBM_remap_index]
+#define _gloffset_MultiModeDrawElementsIBM driDispatchRemapTable[MultiModeDrawElementsIBM_remap_index]
+#define _gloffset_BlendEquationSeparateEXT driDispatchRemapTable[BlendEquationSeparateEXT_remap_index]
+#define _gloffset_DeleteObjectARB driDispatchRemapTable[DeleteObjectARB_remap_index]
+#define _gloffset_GetHandleARB driDispatchRemapTable[GetHandleARB_remap_index]
+#define _gloffset_DetachObjectARB driDispatchRemapTable[DetachObjectARB_remap_index]
+#define _gloffset_CreateShaderObjectARB driDispatchRemapTable[CreateShaderObjectARB_remap_index]
+#define _gloffset_ShaderSourceARB driDispatchRemapTable[ShaderSourceARB_remap_index]
+#define _gloffset_CompileShaderARB driDispatchRemapTable[CompileShaderARB_remap_index]
+#define _gloffset_CreateProgramObjectARB driDispatchRemapTable[CreateProgramObjectARB_remap_index]
+#define _gloffset_AttachObjectARB driDispatchRemapTable[AttachObjectARB_remap_index]
+#define _gloffset_LinkProgramARB driDispatchRemapTable[LinkProgramARB_remap_index]
+#define _gloffset_UseProgramObjectARB driDispatchRemapTable[UseProgramObjectARB_remap_index]
+#define _gloffset_ValidateProgramARB driDispatchRemapTable[ValidateProgramARB_remap_index]
+#define _gloffset_Uniform1fARB driDispatchRemapTable[Uniform1fARB_remap_index]
+#define _gloffset_Uniform2fARB driDispatchRemapTable[Uniform2fARB_remap_index]
+#define _gloffset_Uniform3fARB driDispatchRemapTable[Uniform3fARB_remap_index]
+#define _gloffset_Uniform4fARB driDispatchRemapTable[Uniform4fARB_remap_index]
+#define _gloffset_Uniform1iARB driDispatchRemapTable[Uniform1iARB_remap_index]
+#define _gloffset_Uniform2iARB driDispatchRemapTable[Uniform2iARB_remap_index]
+#define _gloffset_Uniform3iARB driDispatchRemapTable[Uniform3iARB_remap_index]
+#define _gloffset_Uniform4iARB driDispatchRemapTable[Uniform4iARB_remap_index]
+#define _gloffset_Uniform1fvARB driDispatchRemapTable[Uniform1fvARB_remap_index]
+#define _gloffset_Uniform2fvARB driDispatchRemapTable[Uniform2fvARB_remap_index]
+#define _gloffset_Uniform3fvARB driDispatchRemapTable[Uniform3fvARB_remap_index]
+#define _gloffset_Uniform4fvARB driDispatchRemapTable[Uniform4fvARB_remap_index]
+#define _gloffset_Uniform1ivARB driDispatchRemapTable[Uniform1ivARB_remap_index]
+#define _gloffset_Uniform2ivARB driDispatchRemapTable[Uniform2ivARB_remap_index]
+#define _gloffset_Uniform3ivARB driDispatchRemapTable[Uniform3ivARB_remap_index]
+#define _gloffset_Uniform4ivARB driDispatchRemapTable[Uniform4ivARB_remap_index]
+#define _gloffset_UniformMatrix2fvARB driDispatchRemapTable[UniformMatrix2fvARB_remap_index]
+#define _gloffset_UniformMatrix3fvARB driDispatchRemapTable[UniformMatrix3fvARB_remap_index]
+#define _gloffset_UniformMatrix4fvARB driDispatchRemapTable[UniformMatrix4fvARB_remap_index]
+#define _gloffset_GetObjectParameterfvARB driDispatchRemapTable[GetObjectParameterfvARB_remap_index]
+#define _gloffset_GetObjectParameterivARB driDispatchRemapTable[GetObjectParameterivARB_remap_index]
+#define _gloffset_GetInfoLogARB driDispatchRemapTable[GetInfoLogARB_remap_index]
+#define _gloffset_GetAttachedObjectsARB driDispatchRemapTable[GetAttachedObjectsARB_remap_index]
+#define _gloffset_GetUniformLocationARB driDispatchRemapTable[GetUniformLocationARB_remap_index]
+#define _gloffset_GetActiveUniformARB driDispatchRemapTable[GetActiveUniformARB_remap_index]
+#define _gloffset_GetUniformfvARB driDispatchRemapTable[GetUniformfvARB_remap_index]
+#define _gloffset_GetUniformivARB driDispatchRemapTable[GetUniformivARB_remap_index]
+#define _gloffset_GetShaderSourceARB driDispatchRemapTable[GetShaderSourceARB_remap_index]
+#define _gloffset_BindAttribLocationARB driDispatchRemapTable[BindAttribLocationARB_remap_index]
+#define _gloffset_GetActiveAttribARB driDispatchRemapTable[GetActiveAttribARB_remap_index]
+#define _gloffset_GetAttribLocationARB driDispatchRemapTable[GetAttribLocationARB_remap_index]
+#define _gloffset_GetVertexAttribdvNV driDispatchRemapTable[GetVertexAttribdvNV_remap_index]
+#define _gloffset_GetVertexAttribfvNV driDispatchRemapTable[GetVertexAttribfvNV_remap_index]
+#define _gloffset_GetVertexAttribivNV driDispatchRemapTable[GetVertexAttribivNV_remap_index]
+#define _gloffset_VertexAttrib1dNV driDispatchRemapTable[VertexAttrib1dNV_remap_index]
+#define _gloffset_VertexAttrib1dvNV driDispatchRemapTable[VertexAttrib1dvNV_remap_index]
+#define _gloffset_VertexAttrib1fNV driDispatchRemapTable[VertexAttrib1fNV_remap_index]
+#define _gloffset_VertexAttrib1fvNV driDispatchRemapTable[VertexAttrib1fvNV_remap_index]
+#define _gloffset_VertexAttrib1sNV driDispatchRemapTable[VertexAttrib1sNV_remap_index]
+#define _gloffset_VertexAttrib1svNV driDispatchRemapTable[VertexAttrib1svNV_remap_index]
+#define _gloffset_VertexAttrib2dNV driDispatchRemapTable[VertexAttrib2dNV_remap_index]
+#define _gloffset_VertexAttrib2dvNV driDispatchRemapTable[VertexAttrib2dvNV_remap_index]
+#define _gloffset_VertexAttrib2fNV driDispatchRemapTable[VertexAttrib2fNV_remap_index]
+#define _gloffset_VertexAttrib2fvNV driDispatchRemapTable[VertexAttrib2fvNV_remap_index]
+#define _gloffset_VertexAttrib2sNV driDispatchRemapTable[VertexAttrib2sNV_remap_index]
+#define _gloffset_VertexAttrib2svNV driDispatchRemapTable[VertexAttrib2svNV_remap_index]
+#define _gloffset_VertexAttrib3dNV driDispatchRemapTable[VertexAttrib3dNV_remap_index]
+#define _gloffset_VertexAttrib3dvNV driDispatchRemapTable[VertexAttrib3dvNV_remap_index]
+#define _gloffset_VertexAttrib3fNV driDispatchRemapTable[VertexAttrib3fNV_remap_index]
+#define _gloffset_VertexAttrib3fvNV driDispatchRemapTable[VertexAttrib3fvNV_remap_index]
+#define _gloffset_VertexAttrib3sNV driDispatchRemapTable[VertexAttrib3sNV_remap_index]
+#define _gloffset_VertexAttrib3svNV driDispatchRemapTable[VertexAttrib3svNV_remap_index]
+#define _gloffset_VertexAttrib4dNV driDispatchRemapTable[VertexAttrib4dNV_remap_index]
+#define _gloffset_VertexAttrib4dvNV driDispatchRemapTable[VertexAttrib4dvNV_remap_index]
+#define _gloffset_VertexAttrib4fNV driDispatchRemapTable[VertexAttrib4fNV_remap_index]
+#define _gloffset_VertexAttrib4fvNV driDispatchRemapTable[VertexAttrib4fvNV_remap_index]
+#define _gloffset_VertexAttrib4sNV driDispatchRemapTable[VertexAttrib4sNV_remap_index]
+#define _gloffset_VertexAttrib4svNV driDispatchRemapTable[VertexAttrib4svNV_remap_index]
+#define _gloffset_VertexAttrib4ubNV driDispatchRemapTable[VertexAttrib4ubNV_remap_index]
+#define _gloffset_VertexAttrib4ubvNV driDispatchRemapTable[VertexAttrib4ubvNV_remap_index]
+#define _gloffset_GenFragmentShadersATI driDispatchRemapTable[GenFragmentShadersATI_remap_index]
+#define _gloffset_BindFragmentShaderATI driDispatchRemapTable[BindFragmentShaderATI_remap_index]
+#define _gloffset_DeleteFragmentShaderATI driDispatchRemapTable[DeleteFragmentShaderATI_remap_index]
+#define _gloffset_BeginFragmentShaderATI driDispatchRemapTable[BeginFragmentShaderATI_remap_index]
+#define _gloffset_EndFragmentShaderATI driDispatchRemapTable[EndFragmentShaderATI_remap_index]
+#define _gloffset_PassTexCoordATI driDispatchRemapTable[PassTexCoordATI_remap_index]
+#define _gloffset_SampleMapATI driDispatchRemapTable[SampleMapATI_remap_index]
+#define _gloffset_ColorFragmentOp1ATI driDispatchRemapTable[ColorFragmentOp1ATI_remap_index]
+#define _gloffset_ColorFragmentOp2ATI driDispatchRemapTable[ColorFragmentOp2ATI_remap_index]
+#define _gloffset_ColorFragmentOp3ATI driDispatchRemapTable[ColorFragmentOp3ATI_remap_index]
+#define _gloffset_AlphaFragmentOp1ATI driDispatchRemapTable[AlphaFragmentOp1ATI_remap_index]
+#define _gloffset_AlphaFragmentOp2ATI driDispatchRemapTable[AlphaFragmentOp2ATI_remap_index]
+#define _gloffset_AlphaFragmentOp3ATI driDispatchRemapTable[AlphaFragmentOp3ATI_remap_index]
+#define _gloffset_SetFragmentShaderConstantATI driDispatchRemapTable[SetFragmentShaderConstantATI_remap_index]
+#define _gloffset_IsRenderbufferEXT driDispatchRemapTable[IsRenderbufferEXT_remap_index]
+#define _gloffset_BindRenderbufferEXT driDispatchRemapTable[BindRenderbufferEXT_remap_index]
+#define _gloffset_DeleteRenderbuffersEXT driDispatchRemapTable[DeleteRenderbuffersEXT_remap_index]
+#define _gloffset_GenRenderbuffersEXT driDispatchRemapTable[GenRenderbuffersEXT_remap_index]
+#define _gloffset_RenderbufferStorageEXT driDispatchRemapTable[RenderbufferStorageEXT_remap_index]
+#define _gloffset_GetRenderbufferParameterivEXT driDispatchRemapTable[GetRenderbufferParameterivEXT_remap_index]
+#define _gloffset_IsFramebufferEXT driDispatchRemapTable[IsFramebufferEXT_remap_index]
+#define _gloffset_BindFramebufferEXT driDispatchRemapTable[BindFramebufferEXT_remap_index]
+#define _gloffset_DeleteFramebuffersEXT driDispatchRemapTable[DeleteFramebuffersEXT_remap_index]
+#define _gloffset_GenFramebuffersEXT driDispatchRemapTable[GenFramebuffersEXT_remap_index]
+#define _gloffset_CheckFramebufferStatusEXT driDispatchRemapTable[CheckFramebufferStatusEXT_remap_index]
+#define _gloffset_FramebufferTexture1DEXT driDispatchRemapTable[FramebufferTexture1DEXT_remap_index]
+#define _gloffset_FramebufferTexture2DEXT driDispatchRemapTable[FramebufferTexture2DEXT_remap_index]
+#define _gloffset_FramebufferTexture3DEXT driDispatchRemapTable[FramebufferTexture3DEXT_remap_index]
+#define _gloffset_FramebufferRenderbufferEXT driDispatchRemapTable[FramebufferRenderbufferEXT_remap_index]
+#define _gloffset_GetFramebufferAttachmentParameterivEXT driDispatchRemapTable[GetFramebufferAttachmentParameterivEXT_remap_index]
+#define _gloffset_GenerateMipmapEXT driDispatchRemapTable[GenerateMipmapEXT_remap_index]
+#define _gloffset_StencilFuncSeparate driDispatchRemapTable[StencilFuncSeparate_remap_index]
+#define _gloffset_StencilOpSeparate driDispatchRemapTable[StencilOpSeparate_remap_index]
+#define _gloffset_StencilMaskSeparate driDispatchRemapTable[StencilMaskSeparate_remap_index]
+
+#endif /* !defined(IN_DRI_DRIVER) */
+
+#endif /* !defined( _GLAPI_OFFSETS_H_ ) */
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/glapitable.h b/nx-X11/extras/Mesa/src/mesa/glapi/glapitable.h
new file mode 100644
index 000000000..b4c70bdaa
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/glapitable.h
@@ -0,0 +1,858 @@
+/* DO NOT EDIT - This file generated automatically by gl_table.py (from Mesa) script */
+
+/*
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * BRIAN PAUL, IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#if !defined( _GLAPI_TABLE_H_ )
+# define _GLAPI_TABLE_H_
+
+#ifndef GLAPIENTRYP
+#define GLAPIENTRYP
+#endif
+
+typedef void (*_glapi_proc)(void); /* generic function pointer */
+
+struct _glapi_table
+{
+ void (GLAPIENTRYP NewList)(GLuint list, GLenum mode); /* 0 */
+ void (GLAPIENTRYP EndList)(void); /* 1 */
+ void (GLAPIENTRYP CallList)(GLuint list); /* 2 */
+ void (GLAPIENTRYP CallLists)(GLsizei n, GLenum type, const GLvoid * lists); /* 3 */
+ void (GLAPIENTRYP DeleteLists)(GLuint list, GLsizei range); /* 4 */
+ GLuint (GLAPIENTRYP GenLists)(GLsizei range); /* 5 */
+ void (GLAPIENTRYP ListBase)(GLuint base); /* 6 */
+ void (GLAPIENTRYP Begin)(GLenum mode); /* 7 */
+ void (GLAPIENTRYP Bitmap)(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap); /* 8 */
+ void (GLAPIENTRYP Color3b)(GLbyte red, GLbyte green, GLbyte blue); /* 9 */
+ void (GLAPIENTRYP Color3bv)(const GLbyte * v); /* 10 */
+ void (GLAPIENTRYP Color3d)(GLdouble red, GLdouble green, GLdouble blue); /* 11 */
+ void (GLAPIENTRYP Color3dv)(const GLdouble * v); /* 12 */
+ void (GLAPIENTRYP Color3f)(GLfloat red, GLfloat green, GLfloat blue); /* 13 */
+ void (GLAPIENTRYP Color3fv)(const GLfloat * v); /* 14 */
+ void (GLAPIENTRYP Color3i)(GLint red, GLint green, GLint blue); /* 15 */
+ void (GLAPIENTRYP Color3iv)(const GLint * v); /* 16 */
+ void (GLAPIENTRYP Color3s)(GLshort red, GLshort green, GLshort blue); /* 17 */
+ void (GLAPIENTRYP Color3sv)(const GLshort * v); /* 18 */
+ void (GLAPIENTRYP Color3ub)(GLubyte red, GLubyte green, GLubyte blue); /* 19 */
+ void (GLAPIENTRYP Color3ubv)(const GLubyte * v); /* 20 */
+ void (GLAPIENTRYP Color3ui)(GLuint red, GLuint green, GLuint blue); /* 21 */
+ void (GLAPIENTRYP Color3uiv)(const GLuint * v); /* 22 */
+ void (GLAPIENTRYP Color3us)(GLushort red, GLushort green, GLushort blue); /* 23 */
+ void (GLAPIENTRYP Color3usv)(const GLushort * v); /* 24 */
+ void (GLAPIENTRYP Color4b)(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); /* 25 */
+ void (GLAPIENTRYP Color4bv)(const GLbyte * v); /* 26 */
+ void (GLAPIENTRYP Color4d)(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); /* 27 */
+ void (GLAPIENTRYP Color4dv)(const GLdouble * v); /* 28 */
+ void (GLAPIENTRYP Color4f)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); /* 29 */
+ void (GLAPIENTRYP Color4fv)(const GLfloat * v); /* 30 */
+ void (GLAPIENTRYP Color4i)(GLint red, GLint green, GLint blue, GLint alpha); /* 31 */
+ void (GLAPIENTRYP Color4iv)(const GLint * v); /* 32 */
+ void (GLAPIENTRYP Color4s)(GLshort red, GLshort green, GLshort blue, GLshort alpha); /* 33 */
+ void (GLAPIENTRYP Color4sv)(const GLshort * v); /* 34 */
+ void (GLAPIENTRYP Color4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); /* 35 */
+ void (GLAPIENTRYP Color4ubv)(const GLubyte * v); /* 36 */
+ void (GLAPIENTRYP Color4ui)(GLuint red, GLuint green, GLuint blue, GLuint alpha); /* 37 */
+ void (GLAPIENTRYP Color4uiv)(const GLuint * v); /* 38 */
+ void (GLAPIENTRYP Color4us)(GLushort red, GLushort green, GLushort blue, GLushort alpha); /* 39 */
+ void (GLAPIENTRYP Color4usv)(const GLushort * v); /* 40 */
+ void (GLAPIENTRYP EdgeFlag)(GLboolean flag); /* 41 */
+ void (GLAPIENTRYP EdgeFlagv)(const GLboolean * flag); /* 42 */
+ void (GLAPIENTRYP End)(void); /* 43 */
+ void (GLAPIENTRYP Indexd)(GLdouble c); /* 44 */
+ void (GLAPIENTRYP Indexdv)(const GLdouble * c); /* 45 */
+ void (GLAPIENTRYP Indexf)(GLfloat c); /* 46 */
+ void (GLAPIENTRYP Indexfv)(const GLfloat * c); /* 47 */
+ void (GLAPIENTRYP Indexi)(GLint c); /* 48 */
+ void (GLAPIENTRYP Indexiv)(const GLint * c); /* 49 */
+ void (GLAPIENTRYP Indexs)(GLshort c); /* 50 */
+ void (GLAPIENTRYP Indexsv)(const GLshort * c); /* 51 */
+ void (GLAPIENTRYP Normal3b)(GLbyte nx, GLbyte ny, GLbyte nz); /* 52 */
+ void (GLAPIENTRYP Normal3bv)(const GLbyte * v); /* 53 */
+ void (GLAPIENTRYP Normal3d)(GLdouble nx, GLdouble ny, GLdouble nz); /* 54 */
+ void (GLAPIENTRYP Normal3dv)(const GLdouble * v); /* 55 */
+ void (GLAPIENTRYP Normal3f)(GLfloat nx, GLfloat ny, GLfloat nz); /* 56 */
+ void (GLAPIENTRYP Normal3fv)(const GLfloat * v); /* 57 */
+ void (GLAPIENTRYP Normal3i)(GLint nx, GLint ny, GLint nz); /* 58 */
+ void (GLAPIENTRYP Normal3iv)(const GLint * v); /* 59 */
+ void (GLAPIENTRYP Normal3s)(GLshort nx, GLshort ny, GLshort nz); /* 60 */
+ void (GLAPIENTRYP Normal3sv)(const GLshort * v); /* 61 */
+ void (GLAPIENTRYP RasterPos2d)(GLdouble x, GLdouble y); /* 62 */
+ void (GLAPIENTRYP RasterPos2dv)(const GLdouble * v); /* 63 */
+ void (GLAPIENTRYP RasterPos2f)(GLfloat x, GLfloat y); /* 64 */
+ void (GLAPIENTRYP RasterPos2fv)(const GLfloat * v); /* 65 */
+ void (GLAPIENTRYP RasterPos2i)(GLint x, GLint y); /* 66 */
+ void (GLAPIENTRYP RasterPos2iv)(const GLint * v); /* 67 */
+ void (GLAPIENTRYP RasterPos2s)(GLshort x, GLshort y); /* 68 */
+ void (GLAPIENTRYP RasterPos2sv)(const GLshort * v); /* 69 */
+ void (GLAPIENTRYP RasterPos3d)(GLdouble x, GLdouble y, GLdouble z); /* 70 */
+ void (GLAPIENTRYP RasterPos3dv)(const GLdouble * v); /* 71 */
+ void (GLAPIENTRYP RasterPos3f)(GLfloat x, GLfloat y, GLfloat z); /* 72 */
+ void (GLAPIENTRYP RasterPos3fv)(const GLfloat * v); /* 73 */
+ void (GLAPIENTRYP RasterPos3i)(GLint x, GLint y, GLint z); /* 74 */
+ void (GLAPIENTRYP RasterPos3iv)(const GLint * v); /* 75 */
+ void (GLAPIENTRYP RasterPos3s)(GLshort x, GLshort y, GLshort z); /* 76 */
+ void (GLAPIENTRYP RasterPos3sv)(const GLshort * v); /* 77 */
+ void (GLAPIENTRYP RasterPos4d)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); /* 78 */
+ void (GLAPIENTRYP RasterPos4dv)(const GLdouble * v); /* 79 */
+ void (GLAPIENTRYP RasterPos4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); /* 80 */
+ void (GLAPIENTRYP RasterPos4fv)(const GLfloat * v); /* 81 */
+ void (GLAPIENTRYP RasterPos4i)(GLint x, GLint y, GLint z, GLint w); /* 82 */
+ void (GLAPIENTRYP RasterPos4iv)(const GLint * v); /* 83 */
+ void (GLAPIENTRYP RasterPos4s)(GLshort x, GLshort y, GLshort z, GLshort w); /* 84 */
+ void (GLAPIENTRYP RasterPos4sv)(const GLshort * v); /* 85 */
+ void (GLAPIENTRYP Rectd)(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2); /* 86 */
+ void (GLAPIENTRYP Rectdv)(const GLdouble * v1, const GLdouble * v2); /* 87 */
+ void (GLAPIENTRYP Rectf)(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2); /* 88 */
+ void (GLAPIENTRYP Rectfv)(const GLfloat * v1, const GLfloat * v2); /* 89 */
+ void (GLAPIENTRYP Recti)(GLint x1, GLint y1, GLint x2, GLint y2); /* 90 */
+ void (GLAPIENTRYP Rectiv)(const GLint * v1, const GLint * v2); /* 91 */
+ void (GLAPIENTRYP Rects)(GLshort x1, GLshort y1, GLshort x2, GLshort y2); /* 92 */
+ void (GLAPIENTRYP Rectsv)(const GLshort * v1, const GLshort * v2); /* 93 */
+ void (GLAPIENTRYP TexCoord1d)(GLdouble s); /* 94 */
+ void (GLAPIENTRYP TexCoord1dv)(const GLdouble * v); /* 95 */
+ void (GLAPIENTRYP TexCoord1f)(GLfloat s); /* 96 */
+ void (GLAPIENTRYP TexCoord1fv)(const GLfloat * v); /* 97 */
+ void (GLAPIENTRYP TexCoord1i)(GLint s); /* 98 */
+ void (GLAPIENTRYP TexCoord1iv)(const GLint * v); /* 99 */
+ void (GLAPIENTRYP TexCoord1s)(GLshort s); /* 100 */
+ void (GLAPIENTRYP TexCoord1sv)(const GLshort * v); /* 101 */
+ void (GLAPIENTRYP TexCoord2d)(GLdouble s, GLdouble t); /* 102 */
+ void (GLAPIENTRYP TexCoord2dv)(const GLdouble * v); /* 103 */
+ void (GLAPIENTRYP TexCoord2f)(GLfloat s, GLfloat t); /* 104 */
+ void (GLAPIENTRYP TexCoord2fv)(const GLfloat * v); /* 105 */
+ void (GLAPIENTRYP TexCoord2i)(GLint s, GLint t); /* 106 */
+ void (GLAPIENTRYP TexCoord2iv)(const GLint * v); /* 107 */
+ void (GLAPIENTRYP TexCoord2s)(GLshort s, GLshort t); /* 108 */
+ void (GLAPIENTRYP TexCoord2sv)(const GLshort * v); /* 109 */
+ void (GLAPIENTRYP TexCoord3d)(GLdouble s, GLdouble t, GLdouble r); /* 110 */
+ void (GLAPIENTRYP TexCoord3dv)(const GLdouble * v); /* 111 */
+ void (GLAPIENTRYP TexCoord3f)(GLfloat s, GLfloat t, GLfloat r); /* 112 */
+ void (GLAPIENTRYP TexCoord3fv)(const GLfloat * v); /* 113 */
+ void (GLAPIENTRYP TexCoord3i)(GLint s, GLint t, GLint r); /* 114 */
+ void (GLAPIENTRYP TexCoord3iv)(const GLint * v); /* 115 */
+ void (GLAPIENTRYP TexCoord3s)(GLshort s, GLshort t, GLshort r); /* 116 */
+ void (GLAPIENTRYP TexCoord3sv)(const GLshort * v); /* 117 */
+ void (GLAPIENTRYP TexCoord4d)(GLdouble s, GLdouble t, GLdouble r, GLdouble q); /* 118 */
+ void (GLAPIENTRYP TexCoord4dv)(const GLdouble * v); /* 119 */
+ void (GLAPIENTRYP TexCoord4f)(GLfloat s, GLfloat t, GLfloat r, GLfloat q); /* 120 */
+ void (GLAPIENTRYP TexCoord4fv)(const GLfloat * v); /* 121 */
+ void (GLAPIENTRYP TexCoord4i)(GLint s, GLint t, GLint r, GLint q); /* 122 */
+ void (GLAPIENTRYP TexCoord4iv)(const GLint * v); /* 123 */
+ void (GLAPIENTRYP TexCoord4s)(GLshort s, GLshort t, GLshort r, GLshort q); /* 124 */
+ void (GLAPIENTRYP TexCoord4sv)(const GLshort * v); /* 125 */
+ void (GLAPIENTRYP Vertex2d)(GLdouble x, GLdouble y); /* 126 */
+ void (GLAPIENTRYP Vertex2dv)(const GLdouble * v); /* 127 */
+ void (GLAPIENTRYP Vertex2f)(GLfloat x, GLfloat y); /* 128 */
+ void (GLAPIENTRYP Vertex2fv)(const GLfloat * v); /* 129 */
+ void (GLAPIENTRYP Vertex2i)(GLint x, GLint y); /* 130 */
+ void (GLAPIENTRYP Vertex2iv)(const GLint * v); /* 131 */
+ void (GLAPIENTRYP Vertex2s)(GLshort x, GLshort y); /* 132 */
+ void (GLAPIENTRYP Vertex2sv)(const GLshort * v); /* 133 */
+ void (GLAPIENTRYP Vertex3d)(GLdouble x, GLdouble y, GLdouble z); /* 134 */
+ void (GLAPIENTRYP Vertex3dv)(const GLdouble * v); /* 135 */
+ void (GLAPIENTRYP Vertex3f)(GLfloat x, GLfloat y, GLfloat z); /* 136 */
+ void (GLAPIENTRYP Vertex3fv)(const GLfloat * v); /* 137 */
+ void (GLAPIENTRYP Vertex3i)(GLint x, GLint y, GLint z); /* 138 */
+ void (GLAPIENTRYP Vertex3iv)(const GLint * v); /* 139 */
+ void (GLAPIENTRYP Vertex3s)(GLshort x, GLshort y, GLshort z); /* 140 */
+ void (GLAPIENTRYP Vertex3sv)(const GLshort * v); /* 141 */
+ void (GLAPIENTRYP Vertex4d)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); /* 142 */
+ void (GLAPIENTRYP Vertex4dv)(const GLdouble * v); /* 143 */
+ void (GLAPIENTRYP Vertex4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); /* 144 */
+ void (GLAPIENTRYP Vertex4fv)(const GLfloat * v); /* 145 */
+ void (GLAPIENTRYP Vertex4i)(GLint x, GLint y, GLint z, GLint w); /* 146 */
+ void (GLAPIENTRYP Vertex4iv)(const GLint * v); /* 147 */
+ void (GLAPIENTRYP Vertex4s)(GLshort x, GLshort y, GLshort z, GLshort w); /* 148 */
+ void (GLAPIENTRYP Vertex4sv)(const GLshort * v); /* 149 */
+ void (GLAPIENTRYP ClipPlane)(GLenum plane, const GLdouble * equation); /* 150 */
+ void (GLAPIENTRYP ColorMaterial)(GLenum face, GLenum mode); /* 151 */
+ void (GLAPIENTRYP CullFace)(GLenum mode); /* 152 */
+ void (GLAPIENTRYP Fogf)(GLenum pname, GLfloat param); /* 153 */
+ void (GLAPIENTRYP Fogfv)(GLenum pname, const GLfloat * params); /* 154 */
+ void (GLAPIENTRYP Fogi)(GLenum pname, GLint param); /* 155 */
+ void (GLAPIENTRYP Fogiv)(GLenum pname, const GLint * params); /* 156 */
+ void (GLAPIENTRYP FrontFace)(GLenum mode); /* 157 */
+ void (GLAPIENTRYP Hint)(GLenum target, GLenum mode); /* 158 */
+ void (GLAPIENTRYP Lightf)(GLenum light, GLenum pname, GLfloat param); /* 159 */
+ void (GLAPIENTRYP Lightfv)(GLenum light, GLenum pname, const GLfloat * params); /* 160 */
+ void (GLAPIENTRYP Lighti)(GLenum light, GLenum pname, GLint param); /* 161 */
+ void (GLAPIENTRYP Lightiv)(GLenum light, GLenum pname, const GLint * params); /* 162 */
+ void (GLAPIENTRYP LightModelf)(GLenum pname, GLfloat param); /* 163 */
+ void (GLAPIENTRYP LightModelfv)(GLenum pname, const GLfloat * params); /* 164 */
+ void (GLAPIENTRYP LightModeli)(GLenum pname, GLint param); /* 165 */
+ void (GLAPIENTRYP LightModeliv)(GLenum pname, const GLint * params); /* 166 */
+ void (GLAPIENTRYP LineStipple)(GLint factor, GLushort pattern); /* 167 */
+ void (GLAPIENTRYP LineWidth)(GLfloat width); /* 168 */
+ void (GLAPIENTRYP Materialf)(GLenum face, GLenum pname, GLfloat param); /* 169 */
+ void (GLAPIENTRYP Materialfv)(GLenum face, GLenum pname, const GLfloat * params); /* 170 */
+ void (GLAPIENTRYP Materiali)(GLenum face, GLenum pname, GLint param); /* 171 */
+ void (GLAPIENTRYP Materialiv)(GLenum face, GLenum pname, const GLint * params); /* 172 */
+ void (GLAPIENTRYP PointSize)(GLfloat size); /* 173 */
+ void (GLAPIENTRYP PolygonMode)(GLenum face, GLenum mode); /* 174 */
+ void (GLAPIENTRYP PolygonStipple)(const GLubyte * mask); /* 175 */
+ void (GLAPIENTRYP Scissor)(GLint x, GLint y, GLsizei width, GLsizei height); /* 176 */
+ void (GLAPIENTRYP ShadeModel)(GLenum mode); /* 177 */
+ void (GLAPIENTRYP TexParameterf)(GLenum target, GLenum pname, GLfloat param); /* 178 */
+ void (GLAPIENTRYP TexParameterfv)(GLenum target, GLenum pname, const GLfloat * params); /* 179 */
+ void (GLAPIENTRYP TexParameteri)(GLenum target, GLenum pname, GLint param); /* 180 */
+ void (GLAPIENTRYP TexParameteriv)(GLenum target, GLenum pname, const GLint * params); /* 181 */
+ void (GLAPIENTRYP TexImage1D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid * pixels); /* 182 */
+ void (GLAPIENTRYP TexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels); /* 183 */
+ void (GLAPIENTRYP TexEnvf)(GLenum target, GLenum pname, GLfloat param); /* 184 */
+ void (GLAPIENTRYP TexEnvfv)(GLenum target, GLenum pname, const GLfloat * params); /* 185 */
+ void (GLAPIENTRYP TexEnvi)(GLenum target, GLenum pname, GLint param); /* 186 */
+ void (GLAPIENTRYP TexEnviv)(GLenum target, GLenum pname, const GLint * params); /* 187 */
+ void (GLAPIENTRYP TexGend)(GLenum coord, GLenum pname, GLdouble param); /* 188 */
+ void (GLAPIENTRYP TexGendv)(GLenum coord, GLenum pname, const GLdouble * params); /* 189 */
+ void (GLAPIENTRYP TexGenf)(GLenum coord, GLenum pname, GLfloat param); /* 190 */
+ void (GLAPIENTRYP TexGenfv)(GLenum coord, GLenum pname, const GLfloat * params); /* 191 */
+ void (GLAPIENTRYP TexGeni)(GLenum coord, GLenum pname, GLint param); /* 192 */
+ void (GLAPIENTRYP TexGeniv)(GLenum coord, GLenum pname, const GLint * params); /* 193 */
+ void (GLAPIENTRYP FeedbackBuffer)(GLsizei size, GLenum type, GLfloat * buffer); /* 194 */
+ void (GLAPIENTRYP SelectBuffer)(GLsizei size, GLuint * buffer); /* 195 */
+ GLint (GLAPIENTRYP RenderMode)(GLenum mode); /* 196 */
+ void (GLAPIENTRYP InitNames)(void); /* 197 */
+ void (GLAPIENTRYP LoadName)(GLuint name); /* 198 */
+ void (GLAPIENTRYP PassThrough)(GLfloat token); /* 199 */
+ void (GLAPIENTRYP PopName)(void); /* 200 */
+ void (GLAPIENTRYP PushName)(GLuint name); /* 201 */
+ void (GLAPIENTRYP DrawBuffer)(GLenum mode); /* 202 */
+ void (GLAPIENTRYP Clear)(GLbitfield mask); /* 203 */
+ void (GLAPIENTRYP ClearAccum)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); /* 204 */
+ void (GLAPIENTRYP ClearIndex)(GLfloat c); /* 205 */
+ void (GLAPIENTRYP ClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); /* 206 */
+ void (GLAPIENTRYP ClearStencil)(GLint s); /* 207 */
+ void (GLAPIENTRYP ClearDepth)(GLclampd depth); /* 208 */
+ void (GLAPIENTRYP StencilMask)(GLuint mask); /* 209 */
+ void (GLAPIENTRYP ColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); /* 210 */
+ void (GLAPIENTRYP DepthMask)(GLboolean flag); /* 211 */
+ void (GLAPIENTRYP IndexMask)(GLuint mask); /* 212 */
+ void (GLAPIENTRYP Accum)(GLenum op, GLfloat value); /* 213 */
+ void (GLAPIENTRYP Disable)(GLenum cap); /* 214 */
+ void (GLAPIENTRYP Enable)(GLenum cap); /* 215 */
+ void (GLAPIENTRYP Finish)(void); /* 216 */
+ void (GLAPIENTRYP Flush)(void); /* 217 */
+ void (GLAPIENTRYP PopAttrib)(void); /* 218 */
+ void (GLAPIENTRYP PushAttrib)(GLbitfield mask); /* 219 */
+ void (GLAPIENTRYP Map1d)(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble * points); /* 220 */
+ void (GLAPIENTRYP Map1f)(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat * points); /* 221 */
+ void (GLAPIENTRYP Map2d)(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble * points); /* 222 */
+ void (GLAPIENTRYP Map2f)(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat * points); /* 223 */
+ void (GLAPIENTRYP MapGrid1d)(GLint un, GLdouble u1, GLdouble u2); /* 224 */
+ void (GLAPIENTRYP MapGrid1f)(GLint un, GLfloat u1, GLfloat u2); /* 225 */
+ void (GLAPIENTRYP MapGrid2d)(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2); /* 226 */
+ void (GLAPIENTRYP MapGrid2f)(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2); /* 227 */
+ void (GLAPIENTRYP EvalCoord1d)(GLdouble u); /* 228 */
+ void (GLAPIENTRYP EvalCoord1dv)(const GLdouble * u); /* 229 */
+ void (GLAPIENTRYP EvalCoord1f)(GLfloat u); /* 230 */
+ void (GLAPIENTRYP EvalCoord1fv)(const GLfloat * u); /* 231 */
+ void (GLAPIENTRYP EvalCoord2d)(GLdouble u, GLdouble v); /* 232 */
+ void (GLAPIENTRYP EvalCoord2dv)(const GLdouble * u); /* 233 */
+ void (GLAPIENTRYP EvalCoord2f)(GLfloat u, GLfloat v); /* 234 */
+ void (GLAPIENTRYP EvalCoord2fv)(const GLfloat * u); /* 235 */
+ void (GLAPIENTRYP EvalMesh1)(GLenum mode, GLint i1, GLint i2); /* 236 */
+ void (GLAPIENTRYP EvalPoint1)(GLint i); /* 237 */
+ void (GLAPIENTRYP EvalMesh2)(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2); /* 238 */
+ void (GLAPIENTRYP EvalPoint2)(GLint i, GLint j); /* 239 */
+ void (GLAPIENTRYP AlphaFunc)(GLenum func, GLclampf ref); /* 240 */
+ void (GLAPIENTRYP BlendFunc)(GLenum sfactor, GLenum dfactor); /* 241 */
+ void (GLAPIENTRYP LogicOp)(GLenum opcode); /* 242 */
+ void (GLAPIENTRYP StencilFunc)(GLenum func, GLint ref, GLuint mask); /* 243 */
+ void (GLAPIENTRYP StencilOp)(GLenum fail, GLenum zfail, GLenum zpass); /* 244 */
+ void (GLAPIENTRYP DepthFunc)(GLenum func); /* 245 */
+ void (GLAPIENTRYP PixelZoom)(GLfloat xfactor, GLfloat yfactor); /* 246 */
+ void (GLAPIENTRYP PixelTransferf)(GLenum pname, GLfloat param); /* 247 */
+ void (GLAPIENTRYP PixelTransferi)(GLenum pname, GLint param); /* 248 */
+ void (GLAPIENTRYP PixelStoref)(GLenum pname, GLfloat param); /* 249 */
+ void (GLAPIENTRYP PixelStorei)(GLenum pname, GLint param); /* 250 */
+ void (GLAPIENTRYP PixelMapfv)(GLenum map, GLsizei mapsize, const GLfloat * values); /* 251 */
+ void (GLAPIENTRYP PixelMapuiv)(GLenum map, GLsizei mapsize, const GLuint * values); /* 252 */
+ void (GLAPIENTRYP PixelMapusv)(GLenum map, GLsizei mapsize, const GLushort * values); /* 253 */
+ void (GLAPIENTRYP ReadBuffer)(GLenum mode); /* 254 */
+ void (GLAPIENTRYP CopyPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type); /* 255 */
+ void (GLAPIENTRYP ReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * pixels); /* 256 */
+ void (GLAPIENTRYP DrawPixels)(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels); /* 257 */
+ void (GLAPIENTRYP GetBooleanv)(GLenum pname, GLboolean * params); /* 258 */
+ void (GLAPIENTRYP GetClipPlane)(GLenum plane, GLdouble * equation); /* 259 */
+ void (GLAPIENTRYP GetDoublev)(GLenum pname, GLdouble * params); /* 260 */
+ GLenum (GLAPIENTRYP GetError)(void); /* 261 */
+ void (GLAPIENTRYP GetFloatv)(GLenum pname, GLfloat * params); /* 262 */
+ void (GLAPIENTRYP GetIntegerv)(GLenum pname, GLint * params); /* 263 */
+ void (GLAPIENTRYP GetLightfv)(GLenum light, GLenum pname, GLfloat * params); /* 264 */
+ void (GLAPIENTRYP GetLightiv)(GLenum light, GLenum pname, GLint * params); /* 265 */
+ void (GLAPIENTRYP GetMapdv)(GLenum target, GLenum query, GLdouble * v); /* 266 */
+ void (GLAPIENTRYP GetMapfv)(GLenum target, GLenum query, GLfloat * v); /* 267 */
+ void (GLAPIENTRYP GetMapiv)(GLenum target, GLenum query, GLint * v); /* 268 */
+ void (GLAPIENTRYP GetMaterialfv)(GLenum face, GLenum pname, GLfloat * params); /* 269 */
+ void (GLAPIENTRYP GetMaterialiv)(GLenum face, GLenum pname, GLint * params); /* 270 */
+ void (GLAPIENTRYP GetPixelMapfv)(GLenum map, GLfloat * values); /* 271 */
+ void (GLAPIENTRYP GetPixelMapuiv)(GLenum map, GLuint * values); /* 272 */
+ void (GLAPIENTRYP GetPixelMapusv)(GLenum map, GLushort * values); /* 273 */
+ void (GLAPIENTRYP GetPolygonStipple)(GLubyte * mask); /* 274 */
+ const GLubyte * (GLAPIENTRYP GetString)(GLenum name); /* 275 */
+ void (GLAPIENTRYP GetTexEnvfv)(GLenum target, GLenum pname, GLfloat * params); /* 276 */
+ void (GLAPIENTRYP GetTexEnviv)(GLenum target, GLenum pname, GLint * params); /* 277 */
+ void (GLAPIENTRYP GetTexGendv)(GLenum coord, GLenum pname, GLdouble * params); /* 278 */
+ void (GLAPIENTRYP GetTexGenfv)(GLenum coord, GLenum pname, GLfloat * params); /* 279 */
+ void (GLAPIENTRYP GetTexGeniv)(GLenum coord, GLenum pname, GLint * params); /* 280 */
+ void (GLAPIENTRYP GetTexImage)(GLenum target, GLint level, GLenum format, GLenum type, GLvoid * pixels); /* 281 */
+ void (GLAPIENTRYP GetTexParameterfv)(GLenum target, GLenum pname, GLfloat * params); /* 282 */
+ void (GLAPIENTRYP GetTexParameteriv)(GLenum target, GLenum pname, GLint * params); /* 283 */
+ void (GLAPIENTRYP GetTexLevelParameterfv)(GLenum target, GLint level, GLenum pname, GLfloat * params); /* 284 */
+ void (GLAPIENTRYP GetTexLevelParameteriv)(GLenum target, GLint level, GLenum pname, GLint * params); /* 285 */
+ GLboolean (GLAPIENTRYP IsEnabled)(GLenum cap); /* 286 */
+ GLboolean (GLAPIENTRYP IsList)(GLuint list); /* 287 */
+ void (GLAPIENTRYP DepthRange)(GLclampd zNear, GLclampd zFar); /* 288 */
+ void (GLAPIENTRYP Frustum)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); /* 289 */
+ void (GLAPIENTRYP LoadIdentity)(void); /* 290 */
+ void (GLAPIENTRYP LoadMatrixf)(const GLfloat * m); /* 291 */
+ void (GLAPIENTRYP LoadMatrixd)(const GLdouble * m); /* 292 */
+ void (GLAPIENTRYP MatrixMode)(GLenum mode); /* 293 */
+ void (GLAPIENTRYP MultMatrixf)(const GLfloat * m); /* 294 */
+ void (GLAPIENTRYP MultMatrixd)(const GLdouble * m); /* 295 */
+ void (GLAPIENTRYP Ortho)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); /* 296 */
+ void (GLAPIENTRYP PopMatrix)(void); /* 297 */
+ void (GLAPIENTRYP PushMatrix)(void); /* 298 */
+ void (GLAPIENTRYP Rotated)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z); /* 299 */
+ void (GLAPIENTRYP Rotatef)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z); /* 300 */
+ void (GLAPIENTRYP Scaled)(GLdouble x, GLdouble y, GLdouble z); /* 301 */
+ void (GLAPIENTRYP Scalef)(GLfloat x, GLfloat y, GLfloat z); /* 302 */
+ void (GLAPIENTRYP Translated)(GLdouble x, GLdouble y, GLdouble z); /* 303 */
+ void (GLAPIENTRYP Translatef)(GLfloat x, GLfloat y, GLfloat z); /* 304 */
+ void (GLAPIENTRYP Viewport)(GLint x, GLint y, GLsizei width, GLsizei height); /* 305 */
+ void (GLAPIENTRYP ArrayElement)(GLint i); /* 306 */
+ void (GLAPIENTRYP BindTexture)(GLenum target, GLuint texture); /* 307 */
+ void (GLAPIENTRYP ColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); /* 308 */
+ void (GLAPIENTRYP DisableClientState)(GLenum array); /* 309 */
+ void (GLAPIENTRYP DrawArrays)(GLenum mode, GLint first, GLsizei count); /* 310 */
+ void (GLAPIENTRYP DrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid * indices); /* 311 */
+ void (GLAPIENTRYP EdgeFlagPointer)(GLsizei stride, const GLvoid * pointer); /* 312 */
+ void (GLAPIENTRYP EnableClientState)(GLenum array); /* 313 */
+ void (GLAPIENTRYP IndexPointer)(GLenum type, GLsizei stride, const GLvoid * pointer); /* 314 */
+ void (GLAPIENTRYP Indexub)(GLubyte c); /* 315 */
+ void (GLAPIENTRYP Indexubv)(const GLubyte * c); /* 316 */
+ void (GLAPIENTRYP InterleavedArrays)(GLenum format, GLsizei stride, const GLvoid * pointer); /* 317 */
+ void (GLAPIENTRYP NormalPointer)(GLenum type, GLsizei stride, const GLvoid * pointer); /* 318 */
+ void (GLAPIENTRYP PolygonOffset)(GLfloat factor, GLfloat units); /* 319 */
+ void (GLAPIENTRYP TexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); /* 320 */
+ void (GLAPIENTRYP VertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); /* 321 */
+ GLboolean (GLAPIENTRYP AreTexturesResident)(GLsizei n, const GLuint * textures, GLboolean * residences); /* 322 */
+ void (GLAPIENTRYP CopyTexImage1D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border); /* 323 */
+ void (GLAPIENTRYP CopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); /* 324 */
+ void (GLAPIENTRYP CopyTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width); /* 325 */
+ void (GLAPIENTRYP CopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); /* 326 */
+ void (GLAPIENTRYP DeleteTextures)(GLsizei n, const GLuint * textures); /* 327 */
+ void (GLAPIENTRYP GenTextures)(GLsizei n, GLuint * textures); /* 328 */
+ void (GLAPIENTRYP GetPointerv)(GLenum pname, GLvoid ** params); /* 329 */
+ GLboolean (GLAPIENTRYP IsTexture)(GLuint texture); /* 330 */
+ void (GLAPIENTRYP PrioritizeTextures)(GLsizei n, const GLuint * textures, const GLclampf * priorities); /* 331 */
+ void (GLAPIENTRYP TexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid * pixels); /* 332 */
+ void (GLAPIENTRYP TexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels); /* 333 */
+ void (GLAPIENTRYP PopClientAttrib)(void); /* 334 */
+ void (GLAPIENTRYP PushClientAttrib)(GLbitfield mask); /* 335 */
+ void (GLAPIENTRYP BlendColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); /* 336 */
+ void (GLAPIENTRYP BlendEquation)(GLenum mode); /* 337 */
+ void (GLAPIENTRYP DrawRangeElements)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices); /* 338 */
+ void (GLAPIENTRYP ColorTable)(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * table); /* 339 */
+ void (GLAPIENTRYP ColorTableParameterfv)(GLenum target, GLenum pname, const GLfloat * params); /* 340 */
+ void (GLAPIENTRYP ColorTableParameteriv)(GLenum target, GLenum pname, const GLint * params); /* 341 */
+ void (GLAPIENTRYP CopyColorTable)(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); /* 342 */
+ void (GLAPIENTRYP GetColorTable)(GLenum target, GLenum format, GLenum type, GLvoid * table); /* 343 */
+ void (GLAPIENTRYP GetColorTableParameterfv)(GLenum target, GLenum pname, GLfloat * params); /* 344 */
+ void (GLAPIENTRYP GetColorTableParameteriv)(GLenum target, GLenum pname, GLint * params); /* 345 */
+ void (GLAPIENTRYP ColorSubTable)(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid * data); /* 346 */
+ void (GLAPIENTRYP CopyColorSubTable)(GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); /* 347 */
+ void (GLAPIENTRYP ConvolutionFilter1D)(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * image); /* 348 */
+ void (GLAPIENTRYP ConvolutionFilter2D)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * image); /* 349 */
+ void (GLAPIENTRYP ConvolutionParameterf)(GLenum target, GLenum pname, GLfloat params); /* 350 */
+ void (GLAPIENTRYP ConvolutionParameterfv)(GLenum target, GLenum pname, const GLfloat * params); /* 351 */
+ void (GLAPIENTRYP ConvolutionParameteri)(GLenum target, GLenum pname, GLint params); /* 352 */
+ void (GLAPIENTRYP ConvolutionParameteriv)(GLenum target, GLenum pname, const GLint * params); /* 353 */
+ void (GLAPIENTRYP CopyConvolutionFilter1D)(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); /* 354 */
+ void (GLAPIENTRYP CopyConvolutionFilter2D)(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); /* 355 */
+ void (GLAPIENTRYP GetConvolutionFilter)(GLenum target, GLenum format, GLenum type, GLvoid * image); /* 356 */
+ void (GLAPIENTRYP GetConvolutionParameterfv)(GLenum target, GLenum pname, GLfloat * params); /* 357 */
+ void (GLAPIENTRYP GetConvolutionParameteriv)(GLenum target, GLenum pname, GLint * params); /* 358 */
+ void (GLAPIENTRYP GetSeparableFilter)(GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span); /* 359 */
+ void (GLAPIENTRYP SeparableFilter2D)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * row, const GLvoid * column); /* 360 */
+ void (GLAPIENTRYP GetHistogram)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values); /* 361 */
+ void (GLAPIENTRYP GetHistogramParameterfv)(GLenum target, GLenum pname, GLfloat * params); /* 362 */
+ void (GLAPIENTRYP GetHistogramParameteriv)(GLenum target, GLenum pname, GLint * params); /* 363 */
+ void (GLAPIENTRYP GetMinmax)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values); /* 364 */
+ void (GLAPIENTRYP GetMinmaxParameterfv)(GLenum target, GLenum pname, GLfloat * params); /* 365 */
+ void (GLAPIENTRYP GetMinmaxParameteriv)(GLenum target, GLenum pname, GLint * params); /* 366 */
+ void (GLAPIENTRYP Histogram)(GLenum target, GLsizei width, GLenum internalformat, GLboolean sink); /* 367 */
+ void (GLAPIENTRYP Minmax)(GLenum target, GLenum internalformat, GLboolean sink); /* 368 */
+ void (GLAPIENTRYP ResetHistogram)(GLenum target); /* 369 */
+ void (GLAPIENTRYP ResetMinmax)(GLenum target); /* 370 */
+ void (GLAPIENTRYP TexImage3D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * pixels); /* 371 */
+ void (GLAPIENTRYP TexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid * pixels); /* 372 */
+ void (GLAPIENTRYP CopyTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); /* 373 */
+ void (GLAPIENTRYP ActiveTextureARB)(GLenum texture); /* 374 */
+ void (GLAPIENTRYP ClientActiveTextureARB)(GLenum texture); /* 375 */
+ void (GLAPIENTRYP MultiTexCoord1dARB)(GLenum target, GLdouble s); /* 376 */
+ void (GLAPIENTRYP MultiTexCoord1dvARB)(GLenum target, const GLdouble * v); /* 377 */
+ void (GLAPIENTRYP MultiTexCoord1fARB)(GLenum target, GLfloat s); /* 378 */
+ void (GLAPIENTRYP MultiTexCoord1fvARB)(GLenum target, const GLfloat * v); /* 379 */
+ void (GLAPIENTRYP MultiTexCoord1iARB)(GLenum target, GLint s); /* 380 */
+ void (GLAPIENTRYP MultiTexCoord1ivARB)(GLenum target, const GLint * v); /* 381 */
+ void (GLAPIENTRYP MultiTexCoord1sARB)(GLenum target, GLshort s); /* 382 */
+ void (GLAPIENTRYP MultiTexCoord1svARB)(GLenum target, const GLshort * v); /* 383 */
+ void (GLAPIENTRYP MultiTexCoord2dARB)(GLenum target, GLdouble s, GLdouble t); /* 384 */
+ void (GLAPIENTRYP MultiTexCoord2dvARB)(GLenum target, const GLdouble * v); /* 385 */
+ void (GLAPIENTRYP MultiTexCoord2fARB)(GLenum target, GLfloat s, GLfloat t); /* 386 */
+ void (GLAPIENTRYP MultiTexCoord2fvARB)(GLenum target, const GLfloat * v); /* 387 */
+ void (GLAPIENTRYP MultiTexCoord2iARB)(GLenum target, GLint s, GLint t); /* 388 */
+ void (GLAPIENTRYP MultiTexCoord2ivARB)(GLenum target, const GLint * v); /* 389 */
+ void (GLAPIENTRYP MultiTexCoord2sARB)(GLenum target, GLshort s, GLshort t); /* 390 */
+ void (GLAPIENTRYP MultiTexCoord2svARB)(GLenum target, const GLshort * v); /* 391 */
+ void (GLAPIENTRYP MultiTexCoord3dARB)(GLenum target, GLdouble s, GLdouble t, GLdouble r); /* 392 */
+ void (GLAPIENTRYP MultiTexCoord3dvARB)(GLenum target, const GLdouble * v); /* 393 */
+ void (GLAPIENTRYP MultiTexCoord3fARB)(GLenum target, GLfloat s, GLfloat t, GLfloat r); /* 394 */
+ void (GLAPIENTRYP MultiTexCoord3fvARB)(GLenum target, const GLfloat * v); /* 395 */
+ void (GLAPIENTRYP MultiTexCoord3iARB)(GLenum target, GLint s, GLint t, GLint r); /* 396 */
+ void (GLAPIENTRYP MultiTexCoord3ivARB)(GLenum target, const GLint * v); /* 397 */
+ void (GLAPIENTRYP MultiTexCoord3sARB)(GLenum target, GLshort s, GLshort t, GLshort r); /* 398 */
+ void (GLAPIENTRYP MultiTexCoord3svARB)(GLenum target, const GLshort * v); /* 399 */
+ void (GLAPIENTRYP MultiTexCoord4dARB)(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); /* 400 */
+ void (GLAPIENTRYP MultiTexCoord4dvARB)(GLenum target, const GLdouble * v); /* 401 */
+ void (GLAPIENTRYP MultiTexCoord4fARB)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); /* 402 */
+ void (GLAPIENTRYP MultiTexCoord4fvARB)(GLenum target, const GLfloat * v); /* 403 */
+ void (GLAPIENTRYP MultiTexCoord4iARB)(GLenum target, GLint s, GLint t, GLint r, GLint q); /* 404 */
+ void (GLAPIENTRYP MultiTexCoord4ivARB)(GLenum target, const GLint * v); /* 405 */
+ void (GLAPIENTRYP MultiTexCoord4sARB)(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); /* 406 */
+ void (GLAPIENTRYP MultiTexCoord4svARB)(GLenum target, const GLshort * v); /* 407 */
+ void (GLAPIENTRYP LoadTransposeMatrixfARB)(const GLfloat * m); /* 408 */
+ void (GLAPIENTRYP LoadTransposeMatrixdARB)(const GLdouble * m); /* 409 */
+ void (GLAPIENTRYP MultTransposeMatrixfARB)(const GLfloat * m); /* 410 */
+ void (GLAPIENTRYP MultTransposeMatrixdARB)(const GLdouble * m); /* 411 */
+ void (GLAPIENTRYP SampleCoverageARB)(GLclampf value, GLboolean invert); /* 412 */
+ void (GLAPIENTRYP DrawBuffersARB)(GLsizei n, const GLenum * bufs); /* 413 */
+ void (GLAPIENTRYP PolygonOffsetEXT)(GLfloat factor, GLfloat bias); /* 414 */
+ void (GLAPIENTRYP GetTexFilterFuncSGIS)(GLenum target, GLenum filter, GLfloat * weights); /* 415 */
+ void (GLAPIENTRYP TexFilterFuncSGIS)(GLenum target, GLenum filter, GLsizei n, const GLfloat * weights); /* 416 */
+ void (GLAPIENTRYP GetHistogramEXT)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values); /* 417 */
+ void (GLAPIENTRYP GetHistogramParameterfvEXT)(GLenum target, GLenum pname, GLfloat * params); /* 418 */
+ void (GLAPIENTRYP GetHistogramParameterivEXT)(GLenum target, GLenum pname, GLint * params); /* 419 */
+ void (GLAPIENTRYP GetMinmaxEXT)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values); /* 420 */
+ void (GLAPIENTRYP GetMinmaxParameterfvEXT)(GLenum target, GLenum pname, GLfloat * params); /* 421 */
+ void (GLAPIENTRYP GetMinmaxParameterivEXT)(GLenum target, GLenum pname, GLint * params); /* 422 */
+ void (GLAPIENTRYP GetConvolutionFilterEXT)(GLenum target, GLenum format, GLenum type, GLvoid * image); /* 423 */
+ void (GLAPIENTRYP GetConvolutionParameterfvEXT)(GLenum target, GLenum pname, GLfloat * params); /* 424 */
+ void (GLAPIENTRYP GetConvolutionParameterivEXT)(GLenum target, GLenum pname, GLint * params); /* 425 */
+ void (GLAPIENTRYP GetSeparableFilterEXT)(GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span); /* 426 */
+ void (GLAPIENTRYP GetColorTableSGI)(GLenum target, GLenum format, GLenum type, GLvoid * table); /* 427 */
+ void (GLAPIENTRYP GetColorTableParameterfvSGI)(GLenum target, GLenum pname, GLfloat * params); /* 428 */
+ void (GLAPIENTRYP GetColorTableParameterivSGI)(GLenum target, GLenum pname, GLint * params); /* 429 */
+ void (GLAPIENTRYP PixelTexGenSGIX)(GLenum mode); /* 430 */
+ void (GLAPIENTRYP PixelTexGenParameteriSGIS)(GLenum pname, GLint param); /* 431 */
+ void (GLAPIENTRYP PixelTexGenParameterivSGIS)(GLenum pname, const GLint * params); /* 432 */
+ void (GLAPIENTRYP PixelTexGenParameterfSGIS)(GLenum pname, GLfloat param); /* 433 */
+ void (GLAPIENTRYP PixelTexGenParameterfvSGIS)(GLenum pname, const GLfloat * params); /* 434 */
+ void (GLAPIENTRYP GetPixelTexGenParameterivSGIS)(GLenum pname, GLint * params); /* 435 */
+ void (GLAPIENTRYP GetPixelTexGenParameterfvSGIS)(GLenum pname, GLfloat * params); /* 436 */
+ void (GLAPIENTRYP 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 (GLAPIENTRYP 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 (GLAPIENTRYP AreTexturesResidentEXT)(GLsizei n, const GLuint * textures, GLboolean * residences); /* 439 */
+ void (GLAPIENTRYP GenTexturesEXT)(GLsizei n, GLuint * textures); /* 440 */
+ GLboolean (GLAPIENTRYP IsTextureEXT)(GLuint texture); /* 441 */
+ void (GLAPIENTRYP DetailTexFuncSGIS)(GLenum target, GLsizei n, const GLfloat * points); /* 442 */
+ void (GLAPIENTRYP GetDetailTexFuncSGIS)(GLenum target, GLfloat * points); /* 443 */
+ void (GLAPIENTRYP SharpenTexFuncSGIS)(GLenum target, GLsizei n, const GLfloat * points); /* 444 */
+ void (GLAPIENTRYP GetSharpenTexFuncSGIS)(GLenum target, GLfloat * points); /* 445 */
+ void (GLAPIENTRYP SampleMaskSGIS)(GLclampf value, GLboolean invert); /* 446 */
+ void (GLAPIENTRYP SamplePatternSGIS)(GLenum pattern); /* 447 */
+ void (GLAPIENTRYP ColorPointerEXT)(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); /* 448 */
+ void (GLAPIENTRYP EdgeFlagPointerEXT)(GLsizei stride, GLsizei count, const GLboolean * pointer); /* 449 */
+ void (GLAPIENTRYP IndexPointerEXT)(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); /* 450 */
+ void (GLAPIENTRYP NormalPointerEXT)(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); /* 451 */
+ void (GLAPIENTRYP TexCoordPointerEXT)(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); /* 452 */
+ void (GLAPIENTRYP VertexPointerEXT)(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer); /* 453 */
+ void (GLAPIENTRYP SpriteParameterfSGIX)(GLenum pname, GLfloat param); /* 454 */
+ void (GLAPIENTRYP SpriteParameterfvSGIX)(GLenum pname, const GLfloat * params); /* 455 */
+ void (GLAPIENTRYP SpriteParameteriSGIX)(GLenum pname, GLint param); /* 456 */
+ void (GLAPIENTRYP SpriteParameterivSGIX)(GLenum pname, const GLint * params); /* 457 */
+ void (GLAPIENTRYP PointParameterfEXT)(GLenum pname, GLfloat param); /* 458 */
+ void (GLAPIENTRYP PointParameterfvEXT)(GLenum pname, const GLfloat * params); /* 459 */
+ GLint (GLAPIENTRYP GetInstrumentsSGIX)(void); /* 460 */
+ void (GLAPIENTRYP InstrumentsBufferSGIX)(GLsizei size, GLint * buffer); /* 461 */
+ GLint (GLAPIENTRYP PollInstrumentsSGIX)(GLint * marker_p); /* 462 */
+ void (GLAPIENTRYP ReadInstrumentsSGIX)(GLint marker); /* 463 */
+ void (GLAPIENTRYP StartInstrumentsSGIX)(void); /* 464 */
+ void (GLAPIENTRYP StopInstrumentsSGIX)(GLint marker); /* 465 */
+ void (GLAPIENTRYP FrameZoomSGIX)(GLint factor); /* 466 */
+ void (GLAPIENTRYP TagSampleBufferSGIX)(void); /* 467 */
+ void (GLAPIENTRYP ReferencePlaneSGIX)(const GLdouble * equation); /* 468 */
+ void (GLAPIENTRYP FlushRasterSGIX)(void); /* 469 */
+ void (GLAPIENTRYP GetListParameterfvSGIX)(GLuint list, GLenum pname, GLfloat * params); /* 470 */
+ void (GLAPIENTRYP GetListParameterivSGIX)(GLuint list, GLenum pname, GLint * params); /* 471 */
+ void (GLAPIENTRYP ListParameterfSGIX)(GLuint list, GLenum pname, GLfloat param); /* 472 */
+ void (GLAPIENTRYP ListParameterfvSGIX)(GLuint list, GLenum pname, const GLfloat * params); /* 473 */
+ void (GLAPIENTRYP ListParameteriSGIX)(GLuint list, GLenum pname, GLint param); /* 474 */
+ void (GLAPIENTRYP ListParameterivSGIX)(GLuint list, GLenum pname, const GLint * params); /* 475 */
+ void (GLAPIENTRYP FragmentColorMaterialSGIX)(GLenum face, GLenum mode); /* 476 */
+ void (GLAPIENTRYP FragmentLightfSGIX)(GLenum light, GLenum pname, GLfloat param); /* 477 */
+ void (GLAPIENTRYP FragmentLightfvSGIX)(GLenum light, GLenum pname, const GLfloat * params); /* 478 */
+ void (GLAPIENTRYP FragmentLightiSGIX)(GLenum light, GLenum pname, GLint param); /* 479 */
+ void (GLAPIENTRYP FragmentLightivSGIX)(GLenum light, GLenum pname, const GLint * params); /* 480 */
+ void (GLAPIENTRYP FragmentLightModelfSGIX)(GLenum pname, GLfloat param); /* 481 */
+ void (GLAPIENTRYP FragmentLightModelfvSGIX)(GLenum pname, const GLfloat * params); /* 482 */
+ void (GLAPIENTRYP FragmentLightModeliSGIX)(GLenum pname, GLint param); /* 483 */
+ void (GLAPIENTRYP FragmentLightModelivSGIX)(GLenum pname, const GLint * params); /* 484 */
+ void (GLAPIENTRYP FragmentMaterialfSGIX)(GLenum face, GLenum pname, GLfloat param); /* 485 */
+ void (GLAPIENTRYP FragmentMaterialfvSGIX)(GLenum face, GLenum pname, const GLfloat * params); /* 486 */
+ void (GLAPIENTRYP FragmentMaterialiSGIX)(GLenum face, GLenum pname, GLint param); /* 487 */
+ void (GLAPIENTRYP FragmentMaterialivSGIX)(GLenum face, GLenum pname, const GLint * params); /* 488 */
+ void (GLAPIENTRYP GetFragmentLightfvSGIX)(GLenum light, GLenum pname, GLfloat * params); /* 489 */
+ void (GLAPIENTRYP GetFragmentLightivSGIX)(GLenum light, GLenum pname, GLint * params); /* 490 */
+ void (GLAPIENTRYP GetFragmentMaterialfvSGIX)(GLenum face, GLenum pname, GLfloat * params); /* 491 */
+ void (GLAPIENTRYP GetFragmentMaterialivSGIX)(GLenum face, GLenum pname, GLint * params); /* 492 */
+ void (GLAPIENTRYP LightEnviSGIX)(GLenum pname, GLint param); /* 493 */
+ void (GLAPIENTRYP VertexWeightfEXT)(GLfloat weight); /* 494 */
+ void (GLAPIENTRYP VertexWeightfvEXT)(const GLfloat * weight); /* 495 */
+ void (GLAPIENTRYP VertexWeightPointerEXT)(GLsizei size, GLenum type, GLsizei stride, const GLvoid * pointer); /* 496 */
+ void (GLAPIENTRYP FlushVertexArrayRangeNV)(void); /* 497 */
+ void (GLAPIENTRYP VertexArrayRangeNV)(GLsizei length, const GLvoid * pointer); /* 498 */
+ void (GLAPIENTRYP CombinerParameterfvNV)(GLenum pname, const GLfloat * params); /* 499 */
+ void (GLAPIENTRYP CombinerParameterfNV)(GLenum pname, GLfloat param); /* 500 */
+ void (GLAPIENTRYP CombinerParameterivNV)(GLenum pname, const GLint * params); /* 501 */
+ void (GLAPIENTRYP CombinerParameteriNV)(GLenum pname, GLint param); /* 502 */
+ void (GLAPIENTRYP CombinerInputNV)(GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); /* 503 */
+ void (GLAPIENTRYP CombinerOutputNV)(GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum); /* 504 */
+ void (GLAPIENTRYP FinalCombinerInputNV)(GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage); /* 505 */
+ void (GLAPIENTRYP GetCombinerInputParameterfvNV)(GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat * params); /* 506 */
+ void (GLAPIENTRYP GetCombinerInputParameterivNV)(GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint * params); /* 507 */
+ void (GLAPIENTRYP GetCombinerOutputParameterfvNV)(GLenum stage, GLenum portion, GLenum pname, GLfloat * params); /* 508 */
+ void (GLAPIENTRYP GetCombinerOutputParameterivNV)(GLenum stage, GLenum portion, GLenum pname, GLint * params); /* 509 */
+ void (GLAPIENTRYP GetFinalCombinerInputParameterfvNV)(GLenum variable, GLenum pname, GLfloat * params); /* 510 */
+ void (GLAPIENTRYP GetFinalCombinerInputParameterivNV)(GLenum variable, GLenum pname, GLint * params); /* 511 */
+ void (GLAPIENTRYP ResizeBuffersMESA)(void); /* 512 */
+ void (GLAPIENTRYP WindowPos2dMESA)(GLdouble x, GLdouble y); /* 513 */
+ void (GLAPIENTRYP WindowPos2dvMESA)(const GLdouble * v); /* 514 */
+ void (GLAPIENTRYP WindowPos2fMESA)(GLfloat x, GLfloat y); /* 515 */
+ void (GLAPIENTRYP WindowPos2fvMESA)(const GLfloat * v); /* 516 */
+ void (GLAPIENTRYP WindowPos2iMESA)(GLint x, GLint y); /* 517 */
+ void (GLAPIENTRYP WindowPos2ivMESA)(const GLint * v); /* 518 */
+ void (GLAPIENTRYP WindowPos2sMESA)(GLshort x, GLshort y); /* 519 */
+ void (GLAPIENTRYP WindowPos2svMESA)(const GLshort * v); /* 520 */
+ void (GLAPIENTRYP WindowPos3dMESA)(GLdouble x, GLdouble y, GLdouble z); /* 521 */
+ void (GLAPIENTRYP WindowPos3dvMESA)(const GLdouble * v); /* 522 */
+ void (GLAPIENTRYP WindowPos3fMESA)(GLfloat x, GLfloat y, GLfloat z); /* 523 */
+ void (GLAPIENTRYP WindowPos3fvMESA)(const GLfloat * v); /* 524 */
+ void (GLAPIENTRYP WindowPos3iMESA)(GLint x, GLint y, GLint z); /* 525 */
+ void (GLAPIENTRYP WindowPos3ivMESA)(const GLint * v); /* 526 */
+ void (GLAPIENTRYP WindowPos3sMESA)(GLshort x, GLshort y, GLshort z); /* 527 */
+ void (GLAPIENTRYP WindowPos3svMESA)(const GLshort * v); /* 528 */
+ void (GLAPIENTRYP WindowPos4dMESA)(GLdouble x, GLdouble y, GLdouble z, GLdouble w); /* 529 */
+ void (GLAPIENTRYP WindowPos4dvMESA)(const GLdouble * v); /* 530 */
+ void (GLAPIENTRYP WindowPos4fMESA)(GLfloat x, GLfloat y, GLfloat z, GLfloat w); /* 531 */
+ void (GLAPIENTRYP WindowPos4fvMESA)(const GLfloat * v); /* 532 */
+ void (GLAPIENTRYP WindowPos4iMESA)(GLint x, GLint y, GLint z, GLint w); /* 533 */
+ void (GLAPIENTRYP WindowPos4ivMESA)(const GLint * v); /* 534 */
+ void (GLAPIENTRYP WindowPos4sMESA)(GLshort x, GLshort y, GLshort z, GLshort w); /* 535 */
+ void (GLAPIENTRYP WindowPos4svMESA)(const GLshort * v); /* 536 */
+ void (GLAPIENTRYP BlendFuncSeparateEXT)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha); /* 537 */
+ void (GLAPIENTRYP IndexMaterialEXT)(GLenum face, GLenum mode); /* 538 */
+ void (GLAPIENTRYP IndexFuncEXT)(GLenum func, GLclampf ref); /* 539 */
+ void (GLAPIENTRYP LockArraysEXT)(GLint first, GLsizei count); /* 540 */
+ void (GLAPIENTRYP UnlockArraysEXT)(void); /* 541 */
+ void (GLAPIENTRYP CullParameterdvEXT)(GLenum pname, GLdouble * params); /* 542 */
+ void (GLAPIENTRYP CullParameterfvEXT)(GLenum pname, GLfloat * params); /* 543 */
+ void (GLAPIENTRYP HintPGI)(GLenum target, GLint mode); /* 544 */
+ void (GLAPIENTRYP FogCoordfEXT)(GLfloat coord); /* 545 */
+ void (GLAPIENTRYP FogCoordfvEXT)(const GLfloat * coord); /* 546 */
+ void (GLAPIENTRYP FogCoorddEXT)(GLdouble coord); /* 547 */
+ void (GLAPIENTRYP FogCoorddvEXT)(const GLdouble * coord); /* 548 */
+ void (GLAPIENTRYP FogCoordPointerEXT)(GLenum type, GLsizei stride, const GLvoid * pointer); /* 549 */
+ void (GLAPIENTRYP GetColorTableEXT)(GLenum target, GLenum format, GLenum type, GLvoid * data); /* 550 */
+ void (GLAPIENTRYP GetColorTableParameterivEXT)(GLenum target, GLenum pname, GLint * params); /* 551 */
+ void (GLAPIENTRYP GetColorTableParameterfvEXT)(GLenum target, GLenum pname, GLfloat * params); /* 552 */
+ void (GLAPIENTRYP TbufferMask3DFX)(GLuint mask); /* 553 */
+ void (GLAPIENTRYP CompressedTexImage3DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid * data); /* 554 */
+ void (GLAPIENTRYP CompressedTexImage2DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid * data); /* 555 */
+ void (GLAPIENTRYP CompressedTexImage1DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid * data); /* 556 */
+ void (GLAPIENTRYP 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 (GLAPIENTRYP CompressedTexSubImage2DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid * data); /* 558 */
+ void (GLAPIENTRYP CompressedTexSubImage1DARB)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid * data); /* 559 */
+ void (GLAPIENTRYP GetCompressedTexImageARB)(GLenum target, GLint level, GLvoid * img); /* 560 */
+ void (GLAPIENTRYP SecondaryColor3bEXT)(GLbyte red, GLbyte green, GLbyte blue); /* 561 */
+ void (GLAPIENTRYP SecondaryColor3bvEXT)(const GLbyte * v); /* 562 */
+ void (GLAPIENTRYP SecondaryColor3dEXT)(GLdouble red, GLdouble green, GLdouble blue); /* 563 */
+ void (GLAPIENTRYP SecondaryColor3dvEXT)(const GLdouble * v); /* 564 */
+ void (GLAPIENTRYP SecondaryColor3fEXT)(GLfloat red, GLfloat green, GLfloat blue); /* 565 */
+ void (GLAPIENTRYP SecondaryColor3fvEXT)(const GLfloat * v); /* 566 */
+ void (GLAPIENTRYP SecondaryColor3iEXT)(GLint red, GLint green, GLint blue); /* 567 */
+ void (GLAPIENTRYP SecondaryColor3ivEXT)(const GLint * v); /* 568 */
+ void (GLAPIENTRYP SecondaryColor3sEXT)(GLshort red, GLshort green, GLshort blue); /* 569 */
+ void (GLAPIENTRYP SecondaryColor3svEXT)(const GLshort * v); /* 570 */
+ void (GLAPIENTRYP SecondaryColor3ubEXT)(GLubyte red, GLubyte green, GLubyte blue); /* 571 */
+ void (GLAPIENTRYP SecondaryColor3ubvEXT)(const GLubyte * v); /* 572 */
+ void (GLAPIENTRYP SecondaryColor3uiEXT)(GLuint red, GLuint green, GLuint blue); /* 573 */
+ void (GLAPIENTRYP SecondaryColor3uivEXT)(const GLuint * v); /* 574 */
+ void (GLAPIENTRYP SecondaryColor3usEXT)(GLushort red, GLushort green, GLushort blue); /* 575 */
+ void (GLAPIENTRYP SecondaryColor3usvEXT)(const GLushort * v); /* 576 */
+ void (GLAPIENTRYP SecondaryColorPointerEXT)(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); /* 577 */
+ GLboolean (GLAPIENTRYP AreProgramsResidentNV)(GLsizei n, const GLuint * ids, GLboolean * residences); /* 578 */
+ void (GLAPIENTRYP BindProgramNV)(GLenum target, GLuint program); /* 579 */
+ void (GLAPIENTRYP DeleteProgramsNV)(GLsizei n, const GLuint * programs); /* 580 */
+ void (GLAPIENTRYP ExecuteProgramNV)(GLenum target, GLuint id, const GLfloat * params); /* 581 */
+ void (GLAPIENTRYP GenProgramsNV)(GLsizei n, GLuint * programs); /* 582 */
+ void (GLAPIENTRYP GetProgramParameterdvNV)(GLenum target, GLuint index, GLenum pname, GLdouble * params); /* 583 */
+ void (GLAPIENTRYP GetProgramParameterfvNV)(GLenum target, GLuint index, GLenum pname, GLfloat * params); /* 584 */
+ void (GLAPIENTRYP GetProgramivNV)(GLuint id, GLenum pname, GLint * params); /* 585 */
+ void (GLAPIENTRYP GetProgramStringNV)(GLuint id, GLenum pname, GLubyte * program); /* 586 */
+ void (GLAPIENTRYP GetTrackMatrixivNV)(GLenum target, GLuint address, GLenum pname, GLint * params); /* 587 */
+ void (GLAPIENTRYP GetVertexAttribdvARB)(GLuint index, GLenum pname, GLdouble * params); /* 588 */
+ void (GLAPIENTRYP GetVertexAttribfvARB)(GLuint index, GLenum pname, GLfloat * params); /* 589 */
+ void (GLAPIENTRYP GetVertexAttribivARB)(GLuint index, GLenum pname, GLint * params); /* 590 */
+ void (GLAPIENTRYP GetVertexAttribPointervNV)(GLuint index, GLenum pname, GLvoid ** params); /* 591 */
+ GLboolean (GLAPIENTRYP IsProgramNV)(GLuint program); /* 592 */
+ void (GLAPIENTRYP LoadProgramNV)(GLenum target, GLuint id, GLsizei len, const GLubyte * program); /* 593 */
+ void (GLAPIENTRYP ProgramParameter4dNV)(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); /* 594 */
+ void (GLAPIENTRYP ProgramParameter4dvNV)(GLenum target, GLuint index, const GLdouble * params); /* 595 */
+ void (GLAPIENTRYP ProgramParameter4fNV)(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); /* 596 */
+ void (GLAPIENTRYP ProgramParameter4fvNV)(GLenum target, GLuint index, const GLfloat * params); /* 597 */
+ void (GLAPIENTRYP ProgramParameters4dvNV)(GLenum target, GLuint index, GLuint num, const GLdouble * params); /* 598 */
+ void (GLAPIENTRYP ProgramParameters4fvNV)(GLenum target, GLuint index, GLuint num, const GLfloat * params); /* 599 */
+ void (GLAPIENTRYP RequestResidentProgramsNV)(GLsizei n, const GLuint * ids); /* 600 */
+ void (GLAPIENTRYP TrackMatrixNV)(GLenum target, GLuint address, GLenum matrix, GLenum transform); /* 601 */
+ void (GLAPIENTRYP VertexAttribPointerNV)(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); /* 602 */
+ void (GLAPIENTRYP VertexAttrib1dARB)(GLuint index, GLdouble x); /* 603 */
+ void (GLAPIENTRYP VertexAttrib1dvARB)(GLuint index, const GLdouble * v); /* 604 */
+ void (GLAPIENTRYP VertexAttrib1fARB)(GLuint index, GLfloat x); /* 605 */
+ void (GLAPIENTRYP VertexAttrib1fvARB)(GLuint index, const GLfloat * v); /* 606 */
+ void (GLAPIENTRYP VertexAttrib1sARB)(GLuint index, GLshort x); /* 607 */
+ void (GLAPIENTRYP VertexAttrib1svARB)(GLuint index, const GLshort * v); /* 608 */
+ void (GLAPIENTRYP VertexAttrib2dARB)(GLuint index, GLdouble x, GLdouble y); /* 609 */
+ void (GLAPIENTRYP VertexAttrib2dvARB)(GLuint index, const GLdouble * v); /* 610 */
+ void (GLAPIENTRYP VertexAttrib2fARB)(GLuint index, GLfloat x, GLfloat y); /* 611 */
+ void (GLAPIENTRYP VertexAttrib2fvARB)(GLuint index, const GLfloat * v); /* 612 */
+ void (GLAPIENTRYP VertexAttrib2sARB)(GLuint index, GLshort x, GLshort y); /* 613 */
+ void (GLAPIENTRYP VertexAttrib2svARB)(GLuint index, const GLshort * v); /* 614 */
+ void (GLAPIENTRYP VertexAttrib3dARB)(GLuint index, GLdouble x, GLdouble y, GLdouble z); /* 615 */
+ void (GLAPIENTRYP VertexAttrib3dvARB)(GLuint index, const GLdouble * v); /* 616 */
+ void (GLAPIENTRYP VertexAttrib3fARB)(GLuint index, GLfloat x, GLfloat y, GLfloat z); /* 617 */
+ void (GLAPIENTRYP VertexAttrib3fvARB)(GLuint index, const GLfloat * v); /* 618 */
+ void (GLAPIENTRYP VertexAttrib3sARB)(GLuint index, GLshort x, GLshort y, GLshort z); /* 619 */
+ void (GLAPIENTRYP VertexAttrib3svARB)(GLuint index, const GLshort * v); /* 620 */
+ void (GLAPIENTRYP VertexAttrib4dARB)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); /* 621 */
+ void (GLAPIENTRYP VertexAttrib4dvARB)(GLuint index, const GLdouble * v); /* 622 */
+ void (GLAPIENTRYP VertexAttrib4fARB)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); /* 623 */
+ void (GLAPIENTRYP VertexAttrib4fvARB)(GLuint index, const GLfloat * v); /* 624 */
+ void (GLAPIENTRYP VertexAttrib4sARB)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); /* 625 */
+ void (GLAPIENTRYP VertexAttrib4svARB)(GLuint index, const GLshort * v); /* 626 */
+ void (GLAPIENTRYP VertexAttrib4NubARB)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); /* 627 */
+ void (GLAPIENTRYP VertexAttrib4NubvARB)(GLuint index, const GLubyte * v); /* 628 */
+ void (GLAPIENTRYP VertexAttribs1dvNV)(GLuint index, GLsizei n, const GLdouble * v); /* 629 */
+ void (GLAPIENTRYP VertexAttribs1fvNV)(GLuint index, GLsizei n, const GLfloat * v); /* 630 */
+ void (GLAPIENTRYP VertexAttribs1svNV)(GLuint index, GLsizei n, const GLshort * v); /* 631 */
+ void (GLAPIENTRYP VertexAttribs2dvNV)(GLuint index, GLsizei n, const GLdouble * v); /* 632 */
+ void (GLAPIENTRYP VertexAttribs2fvNV)(GLuint index, GLsizei n, const GLfloat * v); /* 633 */
+ void (GLAPIENTRYP VertexAttribs2svNV)(GLuint index, GLsizei n, const GLshort * v); /* 634 */
+ void (GLAPIENTRYP VertexAttribs3dvNV)(GLuint index, GLsizei n, const GLdouble * v); /* 635 */
+ void (GLAPIENTRYP VertexAttribs3fvNV)(GLuint index, GLsizei n, const GLfloat * v); /* 636 */
+ void (GLAPIENTRYP VertexAttribs3svNV)(GLuint index, GLsizei n, const GLshort * v); /* 637 */
+ void (GLAPIENTRYP VertexAttribs4dvNV)(GLuint index, GLsizei n, const GLdouble * v); /* 638 */
+ void (GLAPIENTRYP VertexAttribs4fvNV)(GLuint index, GLsizei n, const GLfloat * v); /* 639 */
+ void (GLAPIENTRYP VertexAttribs4svNV)(GLuint index, GLsizei n, const GLshort * v); /* 640 */
+ void (GLAPIENTRYP VertexAttribs4ubvNV)(GLuint index, GLsizei n, const GLubyte * v); /* 641 */
+ void (GLAPIENTRYP PointParameteriNV)(GLenum pname, GLint param); /* 642 */
+ void (GLAPIENTRYP PointParameterivNV)(GLenum pname, const GLint * params); /* 643 */
+ void (GLAPIENTRYP MultiDrawArraysEXT)(GLenum mode, GLint * first, GLsizei * count, GLsizei primcount); /* 644 */
+ void (GLAPIENTRYP MultiDrawElementsEXT)(GLenum mode, const GLsizei * count, GLenum type, const GLvoid ** indices, GLsizei primcount); /* 645 */
+ void (GLAPIENTRYP ActiveStencilFaceEXT)(GLenum face); /* 646 */
+ void (GLAPIENTRYP DeleteFencesNV)(GLsizei n, const GLuint * fences); /* 647 */
+ void (GLAPIENTRYP GenFencesNV)(GLsizei n, GLuint * fences); /* 648 */
+ GLboolean (GLAPIENTRYP IsFenceNV)(GLuint fence); /* 649 */
+ GLboolean (GLAPIENTRYP TestFenceNV)(GLuint fence); /* 650 */
+ void (GLAPIENTRYP GetFenceivNV)(GLuint fence, GLenum pname, GLint * params); /* 651 */
+ void (GLAPIENTRYP FinishFenceNV)(GLuint fence); /* 652 */
+ void (GLAPIENTRYP SetFenceNV)(GLuint fence, GLenum condition); /* 653 */
+ void (GLAPIENTRYP VertexAttrib4bvARB)(GLuint index, const GLbyte * v); /* 654 */
+ void (GLAPIENTRYP VertexAttrib4ivARB)(GLuint index, const GLint * v); /* 655 */
+ void (GLAPIENTRYP VertexAttrib4ubvARB)(GLuint index, const GLubyte * v); /* 656 */
+ void (GLAPIENTRYP VertexAttrib4usvARB)(GLuint index, const GLushort * v); /* 657 */
+ void (GLAPIENTRYP VertexAttrib4uivARB)(GLuint index, const GLuint * v); /* 658 */
+ void (GLAPIENTRYP VertexAttrib4NbvARB)(GLuint index, const GLbyte * v); /* 659 */
+ void (GLAPIENTRYP VertexAttrib4NsvARB)(GLuint index, const GLshort * v); /* 660 */
+ void (GLAPIENTRYP VertexAttrib4NivARB)(GLuint index, const GLint * v); /* 661 */
+ void (GLAPIENTRYP VertexAttrib4NusvARB)(GLuint index, const GLushort * v); /* 662 */
+ void (GLAPIENTRYP VertexAttrib4NuivARB)(GLuint index, const GLuint * v); /* 663 */
+ void (GLAPIENTRYP VertexAttribPointerARB)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer); /* 664 */
+ void (GLAPIENTRYP EnableVertexAttribArrayARB)(GLuint index); /* 665 */
+ void (GLAPIENTRYP DisableVertexAttribArrayARB)(GLuint index); /* 666 */
+ void (GLAPIENTRYP ProgramStringARB)(GLenum target, GLenum format, GLsizei len, const GLvoid * string); /* 667 */
+ void (GLAPIENTRYP ProgramEnvParameter4dARB)(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); /* 668 */
+ void (GLAPIENTRYP ProgramEnvParameter4dvARB)(GLenum target, GLuint index, const GLdouble * params); /* 669 */
+ void (GLAPIENTRYP ProgramEnvParameter4fARB)(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); /* 670 */
+ void (GLAPIENTRYP ProgramEnvParameter4fvARB)(GLenum target, GLuint index, const GLfloat * params); /* 671 */
+ void (GLAPIENTRYP ProgramLocalParameter4dARB)(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); /* 672 */
+ void (GLAPIENTRYP ProgramLocalParameter4dvARB)(GLenum target, GLuint index, const GLdouble * params); /* 673 */
+ void (GLAPIENTRYP ProgramLocalParameter4fARB)(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); /* 674 */
+ void (GLAPIENTRYP ProgramLocalParameter4fvARB)(GLenum target, GLuint index, const GLfloat * params); /* 675 */
+ void (GLAPIENTRYP GetProgramEnvParameterdvARB)(GLenum target, GLuint index, GLdouble * params); /* 676 */
+ void (GLAPIENTRYP GetProgramEnvParameterfvARB)(GLenum target, GLuint index, GLfloat * params); /* 677 */
+ void (GLAPIENTRYP GetProgramLocalParameterdvARB)(GLenum target, GLuint index, GLdouble * params); /* 678 */
+ void (GLAPIENTRYP GetProgramLocalParameterfvARB)(GLenum target, GLuint index, GLfloat * params); /* 679 */
+ void (GLAPIENTRYP GetProgramivARB)(GLenum target, GLenum pname, GLint * params); /* 680 */
+ void (GLAPIENTRYP GetProgramStringARB)(GLenum target, GLenum pname, GLvoid * string); /* 681 */
+ void (GLAPIENTRYP ProgramNamedParameter4fNV)(GLuint id, GLsizei len, const GLubyte * name, GLfloat x, GLfloat y, GLfloat z, GLfloat w); /* 682 */
+ void (GLAPIENTRYP ProgramNamedParameter4dNV)(GLuint id, GLsizei len, const GLubyte * name, GLdouble x, GLdouble y, GLdouble z, GLdouble w); /* 683 */
+ void (GLAPIENTRYP ProgramNamedParameter4fvNV)(GLuint id, GLsizei len, const GLubyte * name, const GLfloat * v); /* 684 */
+ void (GLAPIENTRYP ProgramNamedParameter4dvNV)(GLuint id, GLsizei len, const GLubyte * name, const GLdouble * v); /* 685 */
+ void (GLAPIENTRYP GetProgramNamedParameterfvNV)(GLuint id, GLsizei len, const GLubyte * name, GLfloat * params); /* 686 */
+ void (GLAPIENTRYP GetProgramNamedParameterdvNV)(GLuint id, GLsizei len, const GLubyte * name, GLdouble * params); /* 687 */
+ void (GLAPIENTRYP BindBufferARB)(GLenum target, GLuint buffer); /* 688 */
+ void (GLAPIENTRYP BufferDataARB)(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage); /* 689 */
+ void (GLAPIENTRYP BufferSubDataARB)(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data); /* 690 */
+ void (GLAPIENTRYP DeleteBuffersARB)(GLsizei n, const GLuint * buffer); /* 691 */
+ void (GLAPIENTRYP GenBuffersARB)(GLsizei n, GLuint * buffer); /* 692 */
+ void (GLAPIENTRYP GetBufferParameterivARB)(GLenum target, GLenum pname, GLint * params); /* 693 */
+ void (GLAPIENTRYP GetBufferPointervARB)(GLenum target, GLenum pname, GLvoid ** params); /* 694 */
+ void (GLAPIENTRYP GetBufferSubDataARB)(GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid * data); /* 695 */
+ GLboolean (GLAPIENTRYP IsBufferARB)(GLuint buffer); /* 696 */
+ GLvoid * (GLAPIENTRYP MapBufferARB)(GLenum target, GLenum access); /* 697 */
+ GLboolean (GLAPIENTRYP UnmapBufferARB)(GLenum target); /* 698 */
+ void (GLAPIENTRYP DepthBoundsEXT)(GLclampd zmin, GLclampd zmax); /* 699 */
+ void (GLAPIENTRYP GenQueriesARB)(GLsizei n, GLuint * ids); /* 700 */
+ void (GLAPIENTRYP DeleteQueriesARB)(GLsizei n, const GLuint * ids); /* 701 */
+ GLboolean (GLAPIENTRYP IsQueryARB)(GLuint id); /* 702 */
+ void (GLAPIENTRYP BeginQueryARB)(GLenum target, GLuint id); /* 703 */
+ void (GLAPIENTRYP EndQueryARB)(GLenum target); /* 704 */
+ void (GLAPIENTRYP GetQueryivARB)(GLenum target, GLenum pname, GLint * params); /* 705 */
+ void (GLAPIENTRYP GetQueryObjectivARB)(GLuint id, GLenum pname, GLint * params); /* 706 */
+ void (GLAPIENTRYP GetQueryObjectuivARB)(GLuint id, GLenum pname, GLuint * params); /* 707 */
+ void (GLAPIENTRYP MultiModeDrawArraysIBM)(const GLenum * mode, const GLint * first, const GLsizei * count, GLsizei primcount, GLint modestride); /* 708 */
+ void (GLAPIENTRYP MultiModeDrawElementsIBM)(const GLenum * mode, const GLsizei * count, GLenum type, const GLvoid * const * indices, GLsizei primcount, GLint modestride); /* 709 */
+ void (GLAPIENTRYP BlendEquationSeparateEXT)(GLenum modeRGB, GLenum modeA); /* 710 */
+ void (GLAPIENTRYP DeleteObjectARB)(GLhandleARB obj); /* 711 */
+ GLhandleARB (GLAPIENTRYP GetHandleARB)(GLenum pname); /* 712 */
+ void (GLAPIENTRYP DetachObjectARB)(GLhandleARB containerObj, GLhandleARB attachedObj); /* 713 */
+ GLhandleARB (GLAPIENTRYP CreateShaderObjectARB)(GLenum shaderType); /* 714 */
+ void (GLAPIENTRYP ShaderSourceARB)(GLhandleARB shaderObj, GLsizei count, const GLcharARB ** string, const GLint * length); /* 715 */
+ void (GLAPIENTRYP CompileShaderARB)(GLhandleARB shaderObj); /* 716 */
+ GLhandleARB (GLAPIENTRYP CreateProgramObjectARB)(void); /* 717 */
+ void (GLAPIENTRYP AttachObjectARB)(GLhandleARB containerObj, GLhandleARB obj); /* 718 */
+ void (GLAPIENTRYP LinkProgramARB)(GLhandleARB programObj); /* 719 */
+ void (GLAPIENTRYP UseProgramObjectARB)(GLhandleARB programObj); /* 720 */
+ void (GLAPIENTRYP ValidateProgramARB)(GLhandleARB programObj); /* 721 */
+ void (GLAPIENTRYP Uniform1fARB)(GLint location, GLfloat v0); /* 722 */
+ void (GLAPIENTRYP Uniform2fARB)(GLint location, GLfloat v0, GLfloat v1); /* 723 */
+ void (GLAPIENTRYP Uniform3fARB)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); /* 724 */
+ void (GLAPIENTRYP Uniform4fARB)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); /* 725 */
+ void (GLAPIENTRYP Uniform1iARB)(GLint location, GLint v0); /* 726 */
+ void (GLAPIENTRYP Uniform2iARB)(GLint location, GLint v0, GLint v1); /* 727 */
+ void (GLAPIENTRYP Uniform3iARB)(GLint location, GLint v0, GLint v1, GLint v2); /* 728 */
+ void (GLAPIENTRYP Uniform4iARB)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3); /* 729 */
+ void (GLAPIENTRYP Uniform1fvARB)(GLint location, GLsizei count, const GLfloat * value); /* 730 */
+ void (GLAPIENTRYP Uniform2fvARB)(GLint location, GLsizei count, const GLfloat * value); /* 731 */
+ void (GLAPIENTRYP Uniform3fvARB)(GLint location, GLsizei count, const GLfloat * value); /* 732 */
+ void (GLAPIENTRYP Uniform4fvARB)(GLint location, GLsizei count, const GLfloat * value); /* 733 */
+ void (GLAPIENTRYP Uniform1ivARB)(GLint location, GLsizei count, const GLint * value); /* 734 */
+ void (GLAPIENTRYP Uniform2ivARB)(GLint location, GLsizei count, const GLint * value); /* 735 */
+ void (GLAPIENTRYP Uniform3ivARB)(GLint location, GLsizei count, const GLint * value); /* 736 */
+ void (GLAPIENTRYP Uniform4ivARB)(GLint location, GLsizei count, const GLint * value); /* 737 */
+ void (GLAPIENTRYP UniformMatrix2fvARB)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); /* 738 */
+ void (GLAPIENTRYP UniformMatrix3fvARB)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); /* 739 */
+ void (GLAPIENTRYP UniformMatrix4fvARB)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value); /* 740 */
+ void (GLAPIENTRYP GetObjectParameterfvARB)(GLhandleARB obj, GLenum pname, GLfloat * params); /* 741 */
+ void (GLAPIENTRYP GetObjectParameterivARB)(GLhandleARB obj, GLenum pname, GLint * params); /* 742 */
+ void (GLAPIENTRYP GetInfoLogARB)(GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog); /* 743 */
+ void (GLAPIENTRYP GetAttachedObjectsARB)(GLhandleARB containerObj, GLsizei maxLength, GLsizei * length, GLhandleARB * infoLog); /* 744 */
+ GLint (GLAPIENTRYP GetUniformLocationARB)(GLhandleARB programObj, const GLcharARB * name); /* 745 */
+ void (GLAPIENTRYP GetActiveUniformARB)(GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei * length, GLint * size, GLenum * type, GLcharARB * name); /* 746 */
+ void (GLAPIENTRYP GetUniformfvARB)(GLhandleARB programObj, GLint location, GLfloat * params); /* 747 */
+ void (GLAPIENTRYP GetUniformivARB)(GLhandleARB programObj, GLint location, GLint * params); /* 748 */
+ void (GLAPIENTRYP GetShaderSourceARB)(GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * source); /* 749 */
+ void (GLAPIENTRYP BindAttribLocationARB)(GLhandleARB programObj, GLuint index, const GLcharARB * name); /* 750 */
+ void (GLAPIENTRYP GetActiveAttribARB)(GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei * length, GLint * size, GLenum * type, GLcharARB * name); /* 751 */
+ GLint (GLAPIENTRYP GetAttribLocationARB)(GLhandleARB programObj, const GLcharARB * name); /* 752 */
+ void (GLAPIENTRYP GetVertexAttribdvNV)(GLuint index, GLenum pname, GLdouble * params); /* 753 */
+ void (GLAPIENTRYP GetVertexAttribfvNV)(GLuint index, GLenum pname, GLfloat * params); /* 754 */
+ void (GLAPIENTRYP GetVertexAttribivNV)(GLuint index, GLenum pname, GLint * params); /* 755 */
+ void (GLAPIENTRYP VertexAttrib1dNV)(GLuint index, GLdouble x); /* 756 */
+ void (GLAPIENTRYP VertexAttrib1dvNV)(GLuint index, const GLdouble * v); /* 757 */
+ void (GLAPIENTRYP VertexAttrib1fNV)(GLuint index, GLfloat x); /* 758 */
+ void (GLAPIENTRYP VertexAttrib1fvNV)(GLuint index, const GLfloat * v); /* 759 */
+ void (GLAPIENTRYP VertexAttrib1sNV)(GLuint index, GLshort x); /* 760 */
+ void (GLAPIENTRYP VertexAttrib1svNV)(GLuint index, const GLshort * v); /* 761 */
+ void (GLAPIENTRYP VertexAttrib2dNV)(GLuint index, GLdouble x, GLdouble y); /* 762 */
+ void (GLAPIENTRYP VertexAttrib2dvNV)(GLuint index, const GLdouble * v); /* 763 */
+ void (GLAPIENTRYP VertexAttrib2fNV)(GLuint index, GLfloat x, GLfloat y); /* 764 */
+ void (GLAPIENTRYP VertexAttrib2fvNV)(GLuint index, const GLfloat * v); /* 765 */
+ void (GLAPIENTRYP VertexAttrib2sNV)(GLuint index, GLshort x, GLshort y); /* 766 */
+ void (GLAPIENTRYP VertexAttrib2svNV)(GLuint index, const GLshort * v); /* 767 */
+ void (GLAPIENTRYP VertexAttrib3dNV)(GLuint index, GLdouble x, GLdouble y, GLdouble z); /* 768 */
+ void (GLAPIENTRYP VertexAttrib3dvNV)(GLuint index, const GLdouble * v); /* 769 */
+ void (GLAPIENTRYP VertexAttrib3fNV)(GLuint index, GLfloat x, GLfloat y, GLfloat z); /* 770 */
+ void (GLAPIENTRYP VertexAttrib3fvNV)(GLuint index, const GLfloat * v); /* 771 */
+ void (GLAPIENTRYP VertexAttrib3sNV)(GLuint index, GLshort x, GLshort y, GLshort z); /* 772 */
+ void (GLAPIENTRYP VertexAttrib3svNV)(GLuint index, const GLshort * v); /* 773 */
+ void (GLAPIENTRYP VertexAttrib4dNV)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w); /* 774 */
+ void (GLAPIENTRYP VertexAttrib4dvNV)(GLuint index, const GLdouble * v); /* 775 */
+ void (GLAPIENTRYP VertexAttrib4fNV)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w); /* 776 */
+ void (GLAPIENTRYP VertexAttrib4fvNV)(GLuint index, const GLfloat * v); /* 777 */
+ void (GLAPIENTRYP VertexAttrib4sNV)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w); /* 778 */
+ void (GLAPIENTRYP VertexAttrib4svNV)(GLuint index, const GLshort * v); /* 779 */
+ void (GLAPIENTRYP VertexAttrib4ubNV)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w); /* 780 */
+ void (GLAPIENTRYP VertexAttrib4ubvNV)(GLuint index, const GLubyte * v); /* 781 */
+ GLuint (GLAPIENTRYP GenFragmentShadersATI)(GLuint range); /* 782 */
+ void (GLAPIENTRYP BindFragmentShaderATI)(GLuint id); /* 783 */
+ void (GLAPIENTRYP DeleteFragmentShaderATI)(GLuint id); /* 784 */
+ void (GLAPIENTRYP BeginFragmentShaderATI)(void); /* 785 */
+ void (GLAPIENTRYP EndFragmentShaderATI)(void); /* 786 */
+ void (GLAPIENTRYP PassTexCoordATI)(GLuint dst, GLuint coord, GLenum swizzle); /* 787 */
+ void (GLAPIENTRYP SampleMapATI)(GLuint dst, GLuint interp, GLenum swizzle); /* 788 */
+ void (GLAPIENTRYP ColorFragmentOp1ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); /* 789 */
+ void (GLAPIENTRYP ColorFragmentOp2ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); /* 790 */
+ void (GLAPIENTRYP ColorFragmentOp3ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); /* 791 */
+ void (GLAPIENTRYP AlphaFragmentOp1ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod); /* 792 */
+ void (GLAPIENTRYP AlphaFragmentOp2ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod); /* 793 */
+ void (GLAPIENTRYP AlphaFragmentOp3ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod); /* 794 */
+ void (GLAPIENTRYP SetFragmentShaderConstantATI)(GLuint dst, const GLfloat * value); /* 795 */
+ GLboolean (GLAPIENTRYP IsRenderbufferEXT)(GLuint renderbuffer); /* 796 */
+ void (GLAPIENTRYP BindRenderbufferEXT)(GLenum target, GLuint renderbuffer); /* 797 */
+ void (GLAPIENTRYP DeleteRenderbuffersEXT)(GLsizei n, const GLuint * renderbuffers); /* 798 */
+ void (GLAPIENTRYP GenRenderbuffersEXT)(GLsizei n, GLuint * renderbuffers); /* 799 */
+ void (GLAPIENTRYP RenderbufferStorageEXT)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); /* 800 */
+ void (GLAPIENTRYP GetRenderbufferParameterivEXT)(GLenum target, GLenum pname, GLint * params); /* 801 */
+ GLboolean (GLAPIENTRYP IsFramebufferEXT)(GLuint framebuffer); /* 802 */
+ void (GLAPIENTRYP BindFramebufferEXT)(GLenum target, GLuint framebuffer); /* 803 */
+ void (GLAPIENTRYP DeleteFramebuffersEXT)(GLsizei n, const GLuint * framebuffers); /* 804 */
+ void (GLAPIENTRYP GenFramebuffersEXT)(GLsizei n, GLuint * framebuffers); /* 805 */
+ GLenum (GLAPIENTRYP CheckFramebufferStatusEXT)(GLenum target); /* 806 */
+ void (GLAPIENTRYP FramebufferTexture1DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); /* 807 */
+ void (GLAPIENTRYP FramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); /* 808 */
+ void (GLAPIENTRYP FramebufferTexture3DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); /* 809 */
+ void (GLAPIENTRYP FramebufferRenderbufferEXT)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); /* 810 */
+ void (GLAPIENTRYP GetFramebufferAttachmentParameterivEXT)(GLenum target, GLenum attachment, GLenum pname, GLint * params); /* 811 */
+ void (GLAPIENTRYP GenerateMipmapEXT)(GLenum target); /* 812 */
+ void (GLAPIENTRYP StencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask); /* 813 */
+ void (GLAPIENTRYP StencilOpSeparate)(GLenum face, GLenum fail, GLenum zfail, GLenum zpass); /* 814 */
+ void (GLAPIENTRYP StencilMaskSeparate)(GLenum face, GLuint mask); /* 815 */
+};
+
+#endif /* !defined( _GLAPI_TABLE_H_ ) */
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/glapitemp.h b/nx-X11/extras/Mesa/src/mesa/glapi/glapitemp.h
new file mode 100644
index 000000000..70bb05ec6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/glapitemp.h
@@ -0,0 +1,6175 @@
+/* DO NOT EDIT - This file generated automatically by gl_apitemp.py (from Mesa) script */
+
+/*
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * BRIAN PAUL, IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+
+/*
+ * This file is a template which generates the OpenGL API entry point
+ * functions. It should be included by a .c file which first defines
+ * the following macros:
+ * KEYWORD1 - usually nothing, but might be __declspec(dllexport) on Win32
+ * KEYWORD2 - usually nothing, but might be __stdcall on Win32
+ * NAME(n) - builds the final function name (usually add "gl" prefix)
+ * DISPATCH(func, args, msg) - code to do dispatch of named function.
+ * msg is a printf-style debug message.
+ * RETURN_DISPATCH(func, args, msg) - code to do dispatch with a return value
+ *
+ * Here is an example which generates the usual OpenGL functions:
+ * #define KEYWORD1
+ * #define KEYWORD2
+ * #define NAME(func) gl##func
+ * #define DISPATCH(func, args, msg) \
+ * struct _glapi_table *dispatch = CurrentDispatch; \
+ * (*dispatch->func) args
+ * #define RETURN DISPATCH(func, args, msg) \
+ * struct _glapi_table *dispatch = CurrentDispatch; \
+ * return (*dispatch->func) args
+ *
+ */
+
+
+#if defined( NAME )
+#ifndef KEYWORD1
+#define KEYWORD1
+#endif
+
+#ifndef KEYWORD2
+#define KEYWORD2
+#endif
+
+#ifndef DISPATCH
+#error DISPATCH must be defined
+#endif
+
+#ifndef RETURN_DISPATCH
+#error RETURN_DISPATCH must be defined
+#endif
+
+
+KEYWORD1 void KEYWORD2 NAME(NewList)(GLuint list, GLenum mode)
+{
+ DISPATCH(NewList, (list, mode), (F, "glNewList(%d, 0x%x);\n", list, mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EndList)(void)
+{
+ DISPATCH(EndList, (), (F, "glEndList();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CallList)(GLuint list)
+{
+ DISPATCH(CallList, (list), (F, "glCallList(%d);\n", list));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CallLists)(GLsizei n, GLenum type, const GLvoid * lists)
+{
+ DISPATCH(CallLists, (n, type, lists), (F, "glCallLists(%d, 0x%x, %p);\n", n, type, (const void *) lists));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DeleteLists)(GLuint list, GLsizei range)
+{
+ DISPATCH(DeleteLists, (list, range), (F, "glDeleteLists(%d, %d);\n", list, range));
+}
+
+KEYWORD1 GLuint KEYWORD2 NAME(GenLists)(GLsizei range)
+{
+ RETURN_DISPATCH(GenLists, (range), (F, "glGenLists(%d);\n", range));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ListBase)(GLuint base)
+{
+ DISPATCH(ListBase, (base), (F, "glListBase(%d);\n", base));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Begin)(GLenum mode)
+{
+ DISPATCH(Begin, (mode), (F, "glBegin(0x%x);\n", mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Bitmap)(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte * bitmap)
+{
+ DISPATCH(Bitmap, (width, height, xorig, yorig, xmove, ymove, bitmap), (F, "glBitmap(%d, %d, %f, %f, %f, %f, %p);\n", width, height, xorig, yorig, xmove, ymove, (const void *) bitmap));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color3b)(GLbyte red, GLbyte green, GLbyte blue)
+{
+ DISPATCH(Color3b, (red, green, blue), (F, "glColor3b(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color3bv)(const GLbyte * v)
+{
+ DISPATCH(Color3bv, (v), (F, "glColor3bv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color3d)(GLdouble red, GLdouble green, GLdouble blue)
+{
+ DISPATCH(Color3d, (red, green, blue), (F, "glColor3d(%f, %f, %f);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color3dv)(const GLdouble * v)
+{
+ DISPATCH(Color3dv, (v), (F, "glColor3dv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color3f)(GLfloat red, GLfloat green, GLfloat blue)
+{
+ DISPATCH(Color3f, (red, green, blue), (F, "glColor3f(%f, %f, %f);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color3fv)(const GLfloat * v)
+{
+ DISPATCH(Color3fv, (v), (F, "glColor3fv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color3i)(GLint red, GLint green, GLint blue)
+{
+ DISPATCH(Color3i, (red, green, blue), (F, "glColor3i(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color3iv)(const GLint * v)
+{
+ DISPATCH(Color3iv, (v), (F, "glColor3iv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color3s)(GLshort red, GLshort green, GLshort blue)
+{
+ DISPATCH(Color3s, (red, green, blue), (F, "glColor3s(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color3sv)(const GLshort * v)
+{
+ DISPATCH(Color3sv, (v), (F, "glColor3sv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color3ub)(GLubyte red, GLubyte green, GLubyte blue)
+{
+ DISPATCH(Color3ub, (red, green, blue), (F, "glColor3ub(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color3ubv)(const GLubyte * v)
+{
+ DISPATCH(Color3ubv, (v), (F, "glColor3ubv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color3ui)(GLuint red, GLuint green, GLuint blue)
+{
+ DISPATCH(Color3ui, (red, green, blue), (F, "glColor3ui(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color3uiv)(const GLuint * v)
+{
+ DISPATCH(Color3uiv, (v), (F, "glColor3uiv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color3us)(GLushort red, GLushort green, GLushort blue)
+{
+ DISPATCH(Color3us, (red, green, blue), (F, "glColor3us(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color3usv)(const GLushort * v)
+{
+ DISPATCH(Color3usv, (v), (F, "glColor3usv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color4b)(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha)
+{
+ DISPATCH(Color4b, (red, green, blue, alpha), (F, "glColor4b(%d, %d, %d, %d);\n", red, green, blue, alpha));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color4bv)(const GLbyte * v)
+{
+ DISPATCH(Color4bv, (v), (F, "glColor4bv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color4d)(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha)
+{
+ DISPATCH(Color4d, (red, green, blue, alpha), (F, "glColor4d(%f, %f, %f, %f);\n", red, green, blue, alpha));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color4dv)(const GLdouble * v)
+{
+ DISPATCH(Color4dv, (v), (F, "glColor4dv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color4f)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
+{
+ DISPATCH(Color4f, (red, green, blue, alpha), (F, "glColor4f(%f, %f, %f, %f);\n", red, green, blue, alpha));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color4fv)(const GLfloat * v)
+{
+ DISPATCH(Color4fv, (v), (F, "glColor4fv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color4i)(GLint red, GLint green, GLint blue, GLint alpha)
+{
+ DISPATCH(Color4i, (red, green, blue, alpha), (F, "glColor4i(%d, %d, %d, %d);\n", red, green, blue, alpha));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color4iv)(const GLint * v)
+{
+ DISPATCH(Color4iv, (v), (F, "glColor4iv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color4s)(GLshort red, GLshort green, GLshort blue, GLshort alpha)
+{
+ DISPATCH(Color4s, (red, green, blue, alpha), (F, "glColor4s(%d, %d, %d, %d);\n", red, green, blue, alpha));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color4sv)(const GLshort * v)
+{
+ DISPATCH(Color4sv, (v), (F, "glColor4sv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)
+{
+ DISPATCH(Color4ub, (red, green, blue, alpha), (F, "glColor4ub(%d, %d, %d, %d);\n", red, green, blue, alpha));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color4ubv)(const GLubyte * v)
+{
+ DISPATCH(Color4ubv, (v), (F, "glColor4ubv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color4ui)(GLuint red, GLuint green, GLuint blue, GLuint alpha)
+{
+ DISPATCH(Color4ui, (red, green, blue, alpha), (F, "glColor4ui(%d, %d, %d, %d);\n", red, green, blue, alpha));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color4uiv)(const GLuint * v)
+{
+ DISPATCH(Color4uiv, (v), (F, "glColor4uiv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color4us)(GLushort red, GLushort green, GLushort blue, GLushort alpha)
+{
+ DISPATCH(Color4us, (red, green, blue, alpha), (F, "glColor4us(%d, %d, %d, %d);\n", red, green, blue, alpha));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Color4usv)(const GLushort * v)
+{
+ DISPATCH(Color4usv, (v), (F, "glColor4usv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EdgeFlag)(GLboolean flag)
+{
+ DISPATCH(EdgeFlag, (flag), (F, "glEdgeFlag(%d);\n", flag));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EdgeFlagv)(const GLboolean * flag)
+{
+ DISPATCH(EdgeFlagv, (flag), (F, "glEdgeFlagv(%p);\n", (const void *) flag));
+}
+
+KEYWORD1 void KEYWORD2 NAME(End)(void)
+{
+ DISPATCH(End, (), (F, "glEnd();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Indexd)(GLdouble c)
+{
+ DISPATCH(Indexd, (c), (F, "glIndexd(%f);\n", c));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Indexdv)(const GLdouble * c)
+{
+ DISPATCH(Indexdv, (c), (F, "glIndexdv(%p);\n", (const void *) c));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Indexf)(GLfloat c)
+{
+ DISPATCH(Indexf, (c), (F, "glIndexf(%f);\n", c));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Indexfv)(const GLfloat * c)
+{
+ DISPATCH(Indexfv, (c), (F, "glIndexfv(%p);\n", (const void *) c));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Indexi)(GLint c)
+{
+ DISPATCH(Indexi, (c), (F, "glIndexi(%d);\n", c));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Indexiv)(const GLint * c)
+{
+ DISPATCH(Indexiv, (c), (F, "glIndexiv(%p);\n", (const void *) c));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Indexs)(GLshort c)
+{
+ DISPATCH(Indexs, (c), (F, "glIndexs(%d);\n", c));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Indexsv)(const GLshort * c)
+{
+ DISPATCH(Indexsv, (c), (F, "glIndexsv(%p);\n", (const void *) c));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Normal3b)(GLbyte nx, GLbyte ny, GLbyte nz)
+{
+ DISPATCH(Normal3b, (nx, ny, nz), (F, "glNormal3b(%d, %d, %d);\n", nx, ny, nz));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Normal3bv)(const GLbyte * v)
+{
+ DISPATCH(Normal3bv, (v), (F, "glNormal3bv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Normal3d)(GLdouble nx, GLdouble ny, GLdouble nz)
+{
+ DISPATCH(Normal3d, (nx, ny, nz), (F, "glNormal3d(%f, %f, %f);\n", nx, ny, nz));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Normal3dv)(const GLdouble * v)
+{
+ DISPATCH(Normal3dv, (v), (F, "glNormal3dv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Normal3f)(GLfloat nx, GLfloat ny, GLfloat nz)
+{
+ DISPATCH(Normal3f, (nx, ny, nz), (F, "glNormal3f(%f, %f, %f);\n", nx, ny, nz));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Normal3fv)(const GLfloat * v)
+{
+ DISPATCH(Normal3fv, (v), (F, "glNormal3fv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Normal3i)(GLint nx, GLint ny, GLint nz)
+{
+ DISPATCH(Normal3i, (nx, ny, nz), (F, "glNormal3i(%d, %d, %d);\n", nx, ny, nz));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Normal3iv)(const GLint * v)
+{
+ DISPATCH(Normal3iv, (v), (F, "glNormal3iv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Normal3s)(GLshort nx, GLshort ny, GLshort nz)
+{
+ DISPATCH(Normal3s, (nx, ny, nz), (F, "glNormal3s(%d, %d, %d);\n", nx, ny, nz));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Normal3sv)(const GLshort * v)
+{
+ DISPATCH(Normal3sv, (v), (F, "glNormal3sv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos2d)(GLdouble x, GLdouble y)
+{
+ DISPATCH(RasterPos2d, (x, y), (F, "glRasterPos2d(%f, %f);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos2dv)(const GLdouble * v)
+{
+ DISPATCH(RasterPos2dv, (v), (F, "glRasterPos2dv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos2f)(GLfloat x, GLfloat y)
+{
+ DISPATCH(RasterPos2f, (x, y), (F, "glRasterPos2f(%f, %f);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos2fv)(const GLfloat * v)
+{
+ DISPATCH(RasterPos2fv, (v), (F, "glRasterPos2fv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos2i)(GLint x, GLint y)
+{
+ DISPATCH(RasterPos2i, (x, y), (F, "glRasterPos2i(%d, %d);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos2iv)(const GLint * v)
+{
+ DISPATCH(RasterPos2iv, (v), (F, "glRasterPos2iv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos2s)(GLshort x, GLshort y)
+{
+ DISPATCH(RasterPos2s, (x, y), (F, "glRasterPos2s(%d, %d);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos2sv)(const GLshort * v)
+{
+ DISPATCH(RasterPos2sv, (v), (F, "glRasterPos2sv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos3d)(GLdouble x, GLdouble y, GLdouble z)
+{
+ DISPATCH(RasterPos3d, (x, y, z), (F, "glRasterPos3d(%f, %f, %f);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos3dv)(const GLdouble * v)
+{
+ DISPATCH(RasterPos3dv, (v), (F, "glRasterPos3dv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos3f)(GLfloat x, GLfloat y, GLfloat z)
+{
+ DISPATCH(RasterPos3f, (x, y, z), (F, "glRasterPos3f(%f, %f, %f);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos3fv)(const GLfloat * v)
+{
+ DISPATCH(RasterPos3fv, (v), (F, "glRasterPos3fv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos3i)(GLint x, GLint y, GLint z)
+{
+ DISPATCH(RasterPos3i, (x, y, z), (F, "glRasterPos3i(%d, %d, %d);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos3iv)(const GLint * v)
+{
+ DISPATCH(RasterPos3iv, (v), (F, "glRasterPos3iv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos3s)(GLshort x, GLshort y, GLshort z)
+{
+ DISPATCH(RasterPos3s, (x, y, z), (F, "glRasterPos3s(%d, %d, %d);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos3sv)(const GLshort * v)
+{
+ DISPATCH(RasterPos3sv, (v), (F, "glRasterPos3sv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos4d)(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ DISPATCH(RasterPos4d, (x, y, z, w), (F, "glRasterPos4d(%f, %f, %f, %f);\n", x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos4dv)(const GLdouble * v)
+{
+ DISPATCH(RasterPos4dv, (v), (F, "glRasterPos4dv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ DISPATCH(RasterPos4f, (x, y, z, w), (F, "glRasterPos4f(%f, %f, %f, %f);\n", x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos4fv)(const GLfloat * v)
+{
+ DISPATCH(RasterPos4fv, (v), (F, "glRasterPos4fv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos4i)(GLint x, GLint y, GLint z, GLint w)
+{
+ DISPATCH(RasterPos4i, (x, y, z, w), (F, "glRasterPos4i(%d, %d, %d, %d);\n", x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos4iv)(const GLint * v)
+{
+ DISPATCH(RasterPos4iv, (v), (F, "glRasterPos4iv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos4s)(GLshort x, GLshort y, GLshort z, GLshort w)
+{
+ DISPATCH(RasterPos4s, (x, y, z, w), (F, "glRasterPos4s(%d, %d, %d, %d);\n", x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RasterPos4sv)(const GLshort * v)
+{
+ DISPATCH(RasterPos4sv, (v), (F, "glRasterPos4sv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Rectd)(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
+{
+ DISPATCH(Rectd, (x1, y1, x2, y2), (F, "glRectd(%f, %f, %f, %f);\n", x1, y1, x2, y2));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Rectdv)(const GLdouble * v1, const GLdouble * v2)
+{
+ DISPATCH(Rectdv, (v1, v2), (F, "glRectdv(%p, %p);\n", (const void *) v1, (const void *) v2));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Rectf)(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
+{
+ DISPATCH(Rectf, (x1, y1, x2, y2), (F, "glRectf(%f, %f, %f, %f);\n", x1, y1, x2, y2));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Rectfv)(const GLfloat * v1, const GLfloat * v2)
+{
+ DISPATCH(Rectfv, (v1, v2), (F, "glRectfv(%p, %p);\n", (const void *) v1, (const void *) v2));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Recti)(GLint x1, GLint y1, GLint x2, GLint y2)
+{
+ DISPATCH(Recti, (x1, y1, x2, y2), (F, "glRecti(%d, %d, %d, %d);\n", x1, y1, x2, y2));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Rectiv)(const GLint * v1, const GLint * v2)
+{
+ DISPATCH(Rectiv, (v1, v2), (F, "glRectiv(%p, %p);\n", (const void *) v1, (const void *) v2));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Rects)(GLshort x1, GLshort y1, GLshort x2, GLshort y2)
+{
+ DISPATCH(Rects, (x1, y1, x2, y2), (F, "glRects(%d, %d, %d, %d);\n", x1, y1, x2, y2));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Rectsv)(const GLshort * v1, const GLshort * v2)
+{
+ DISPATCH(Rectsv, (v1, v2), (F, "glRectsv(%p, %p);\n", (const void *) v1, (const void *) v2));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord1d)(GLdouble s)
+{
+ DISPATCH(TexCoord1d, (s), (F, "glTexCoord1d(%f);\n", s));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord1dv)(const GLdouble * v)
+{
+ DISPATCH(TexCoord1dv, (v), (F, "glTexCoord1dv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord1f)(GLfloat s)
+{
+ DISPATCH(TexCoord1f, (s), (F, "glTexCoord1f(%f);\n", s));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord1fv)(const GLfloat * v)
+{
+ DISPATCH(TexCoord1fv, (v), (F, "glTexCoord1fv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord1i)(GLint s)
+{
+ DISPATCH(TexCoord1i, (s), (F, "glTexCoord1i(%d);\n", s));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord1iv)(const GLint * v)
+{
+ DISPATCH(TexCoord1iv, (v), (F, "glTexCoord1iv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord1s)(GLshort s)
+{
+ DISPATCH(TexCoord1s, (s), (F, "glTexCoord1s(%d);\n", s));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord1sv)(const GLshort * v)
+{
+ DISPATCH(TexCoord1sv, (v), (F, "glTexCoord1sv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord2d)(GLdouble s, GLdouble t)
+{
+ DISPATCH(TexCoord2d, (s, t), (F, "glTexCoord2d(%f, %f);\n", s, t));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord2dv)(const GLdouble * v)
+{
+ DISPATCH(TexCoord2dv, (v), (F, "glTexCoord2dv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord2f)(GLfloat s, GLfloat t)
+{
+ DISPATCH(TexCoord2f, (s, t), (F, "glTexCoord2f(%f, %f);\n", s, t));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord2fv)(const GLfloat * v)
+{
+ DISPATCH(TexCoord2fv, (v), (F, "glTexCoord2fv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord2i)(GLint s, GLint t)
+{
+ DISPATCH(TexCoord2i, (s, t), (F, "glTexCoord2i(%d, %d);\n", s, t));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord2iv)(const GLint * v)
+{
+ DISPATCH(TexCoord2iv, (v), (F, "glTexCoord2iv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord2s)(GLshort s, GLshort t)
+{
+ DISPATCH(TexCoord2s, (s, t), (F, "glTexCoord2s(%d, %d);\n", s, t));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord2sv)(const GLshort * v)
+{
+ DISPATCH(TexCoord2sv, (v), (F, "glTexCoord2sv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord3d)(GLdouble s, GLdouble t, GLdouble r)
+{
+ DISPATCH(TexCoord3d, (s, t, r), (F, "glTexCoord3d(%f, %f, %f);\n", s, t, r));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord3dv)(const GLdouble * v)
+{
+ DISPATCH(TexCoord3dv, (v), (F, "glTexCoord3dv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord3f)(GLfloat s, GLfloat t, GLfloat r)
+{
+ DISPATCH(TexCoord3f, (s, t, r), (F, "glTexCoord3f(%f, %f, %f);\n", s, t, r));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord3fv)(const GLfloat * v)
+{
+ DISPATCH(TexCoord3fv, (v), (F, "glTexCoord3fv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord3i)(GLint s, GLint t, GLint r)
+{
+ DISPATCH(TexCoord3i, (s, t, r), (F, "glTexCoord3i(%d, %d, %d);\n", s, t, r));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord3iv)(const GLint * v)
+{
+ DISPATCH(TexCoord3iv, (v), (F, "glTexCoord3iv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord3s)(GLshort s, GLshort t, GLshort r)
+{
+ DISPATCH(TexCoord3s, (s, t, r), (F, "glTexCoord3s(%d, %d, %d);\n", s, t, r));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord3sv)(const GLshort * v)
+{
+ DISPATCH(TexCoord3sv, (v), (F, "glTexCoord3sv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord4d)(GLdouble s, GLdouble t, GLdouble r, GLdouble q)
+{
+ DISPATCH(TexCoord4d, (s, t, r, q), (F, "glTexCoord4d(%f, %f, %f, %f);\n", s, t, r, q));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord4dv)(const GLdouble * v)
+{
+ DISPATCH(TexCoord4dv, (v), (F, "glTexCoord4dv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord4f)(GLfloat s, GLfloat t, GLfloat r, GLfloat q)
+{
+ DISPATCH(TexCoord4f, (s, t, r, q), (F, "glTexCoord4f(%f, %f, %f, %f);\n", s, t, r, q));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord4fv)(const GLfloat * v)
+{
+ DISPATCH(TexCoord4fv, (v), (F, "glTexCoord4fv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord4i)(GLint s, GLint t, GLint r, GLint q)
+{
+ DISPATCH(TexCoord4i, (s, t, r, q), (F, "glTexCoord4i(%d, %d, %d, %d);\n", s, t, r, q));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord4iv)(const GLint * v)
+{
+ DISPATCH(TexCoord4iv, (v), (F, "glTexCoord4iv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord4s)(GLshort s, GLshort t, GLshort r, GLshort q)
+{
+ DISPATCH(TexCoord4s, (s, t, r, q), (F, "glTexCoord4s(%d, %d, %d, %d);\n", s, t, r, q));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoord4sv)(const GLshort * v)
+{
+ DISPATCH(TexCoord4sv, (v), (F, "glTexCoord4sv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex2d)(GLdouble x, GLdouble y)
+{
+ DISPATCH(Vertex2d, (x, y), (F, "glVertex2d(%f, %f);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex2dv)(const GLdouble * v)
+{
+ DISPATCH(Vertex2dv, (v), (F, "glVertex2dv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex2f)(GLfloat x, GLfloat y)
+{
+ DISPATCH(Vertex2f, (x, y), (F, "glVertex2f(%f, %f);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex2fv)(const GLfloat * v)
+{
+ DISPATCH(Vertex2fv, (v), (F, "glVertex2fv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex2i)(GLint x, GLint y)
+{
+ DISPATCH(Vertex2i, (x, y), (F, "glVertex2i(%d, %d);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex2iv)(const GLint * v)
+{
+ DISPATCH(Vertex2iv, (v), (F, "glVertex2iv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex2s)(GLshort x, GLshort y)
+{
+ DISPATCH(Vertex2s, (x, y), (F, "glVertex2s(%d, %d);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex2sv)(const GLshort * v)
+{
+ DISPATCH(Vertex2sv, (v), (F, "glVertex2sv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex3d)(GLdouble x, GLdouble y, GLdouble z)
+{
+ DISPATCH(Vertex3d, (x, y, z), (F, "glVertex3d(%f, %f, %f);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex3dv)(const GLdouble * v)
+{
+ DISPATCH(Vertex3dv, (v), (F, "glVertex3dv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex3f)(GLfloat x, GLfloat y, GLfloat z)
+{
+ DISPATCH(Vertex3f, (x, y, z), (F, "glVertex3f(%f, %f, %f);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex3fv)(const GLfloat * v)
+{
+ DISPATCH(Vertex3fv, (v), (F, "glVertex3fv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex3i)(GLint x, GLint y, GLint z)
+{
+ DISPATCH(Vertex3i, (x, y, z), (F, "glVertex3i(%d, %d, %d);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex3iv)(const GLint * v)
+{
+ DISPATCH(Vertex3iv, (v), (F, "glVertex3iv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex3s)(GLshort x, GLshort y, GLshort z)
+{
+ DISPATCH(Vertex3s, (x, y, z), (F, "glVertex3s(%d, %d, %d);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex3sv)(const GLshort * v)
+{
+ DISPATCH(Vertex3sv, (v), (F, "glVertex3sv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex4d)(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ DISPATCH(Vertex4d, (x, y, z, w), (F, "glVertex4d(%f, %f, %f, %f);\n", x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex4dv)(const GLdouble * v)
+{
+ DISPATCH(Vertex4dv, (v), (F, "glVertex4dv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex4f)(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ DISPATCH(Vertex4f, (x, y, z, w), (F, "glVertex4f(%f, %f, %f, %f);\n", x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex4fv)(const GLfloat * v)
+{
+ DISPATCH(Vertex4fv, (v), (F, "glVertex4fv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex4i)(GLint x, GLint y, GLint z, GLint w)
+{
+ DISPATCH(Vertex4i, (x, y, z, w), (F, "glVertex4i(%d, %d, %d, %d);\n", x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex4iv)(const GLint * v)
+{
+ DISPATCH(Vertex4iv, (v), (F, "glVertex4iv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex4s)(GLshort x, GLshort y, GLshort z, GLshort w)
+{
+ DISPATCH(Vertex4s, (x, y, z, w), (F, "glVertex4s(%d, %d, %d, %d);\n", x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Vertex4sv)(const GLshort * v)
+{
+ DISPATCH(Vertex4sv, (v), (F, "glVertex4sv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ClipPlane)(GLenum plane, const GLdouble * equation)
+{
+ DISPATCH(ClipPlane, (plane, equation), (F, "glClipPlane(0x%x, %p);\n", plane, (const void *) equation));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ColorMaterial)(GLenum face, GLenum mode)
+{
+ DISPATCH(ColorMaterial, (face, mode), (F, "glColorMaterial(0x%x, 0x%x);\n", face, mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CullFace)(GLenum mode)
+{
+ DISPATCH(CullFace, (mode), (F, "glCullFace(0x%x);\n", mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Fogf)(GLenum pname, GLfloat param)
+{
+ DISPATCH(Fogf, (pname, param), (F, "glFogf(0x%x, %f);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Fogfv)(GLenum pname, const GLfloat * params)
+{
+ DISPATCH(Fogfv, (pname, params), (F, "glFogfv(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Fogi)(GLenum pname, GLint param)
+{
+ DISPATCH(Fogi, (pname, param), (F, "glFogi(0x%x, %d);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Fogiv)(GLenum pname, const GLint * params)
+{
+ DISPATCH(Fogiv, (pname, params), (F, "glFogiv(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FrontFace)(GLenum mode)
+{
+ DISPATCH(FrontFace, (mode), (F, "glFrontFace(0x%x);\n", mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Hint)(GLenum target, GLenum mode)
+{
+ DISPATCH(Hint, (target, mode), (F, "glHint(0x%x, 0x%x);\n", target, mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Lightf)(GLenum light, GLenum pname, GLfloat param)
+{
+ DISPATCH(Lightf, (light, pname, param), (F, "glLightf(0x%x, 0x%x, %f);\n", light, pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Lightfv)(GLenum light, GLenum pname, const GLfloat * params)
+{
+ DISPATCH(Lightfv, (light, pname, params), (F, "glLightfv(0x%x, 0x%x, %p);\n", light, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Lighti)(GLenum light, GLenum pname, GLint param)
+{
+ DISPATCH(Lighti, (light, pname, param), (F, "glLighti(0x%x, 0x%x, %d);\n", light, pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Lightiv)(GLenum light, GLenum pname, const GLint * params)
+{
+ DISPATCH(Lightiv, (light, pname, params), (F, "glLightiv(0x%x, 0x%x, %p);\n", light, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LightModelf)(GLenum pname, GLfloat param)
+{
+ DISPATCH(LightModelf, (pname, param), (F, "glLightModelf(0x%x, %f);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LightModelfv)(GLenum pname, const GLfloat * params)
+{
+ DISPATCH(LightModelfv, (pname, params), (F, "glLightModelfv(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LightModeli)(GLenum pname, GLint param)
+{
+ DISPATCH(LightModeli, (pname, param), (F, "glLightModeli(0x%x, %d);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LightModeliv)(GLenum pname, const GLint * params)
+{
+ DISPATCH(LightModeliv, (pname, params), (F, "glLightModeliv(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LineStipple)(GLint factor, GLushort pattern)
+{
+ DISPATCH(LineStipple, (factor, pattern), (F, "glLineStipple(%d, %d);\n", factor, pattern));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LineWidth)(GLfloat width)
+{
+ DISPATCH(LineWidth, (width), (F, "glLineWidth(%f);\n", width));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Materialf)(GLenum face, GLenum pname, GLfloat param)
+{
+ DISPATCH(Materialf, (face, pname, param), (F, "glMaterialf(0x%x, 0x%x, %f);\n", face, pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Materialfv)(GLenum face, GLenum pname, const GLfloat * params)
+{
+ DISPATCH(Materialfv, (face, pname, params), (F, "glMaterialfv(0x%x, 0x%x, %p);\n", face, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Materiali)(GLenum face, GLenum pname, GLint param)
+{
+ DISPATCH(Materiali, (face, pname, param), (F, "glMateriali(0x%x, 0x%x, %d);\n", face, pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Materialiv)(GLenum face, GLenum pname, const GLint * params)
+{
+ DISPATCH(Materialiv, (face, pname, params), (F, "glMaterialiv(0x%x, 0x%x, %p);\n", face, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PointSize)(GLfloat size)
+{
+ DISPATCH(PointSize, (size), (F, "glPointSize(%f);\n", size));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PolygonMode)(GLenum face, GLenum mode)
+{
+ DISPATCH(PolygonMode, (face, mode), (F, "glPolygonMode(0x%x, 0x%x);\n", face, mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PolygonStipple)(const GLubyte * mask)
+{
+ DISPATCH(PolygonStipple, (mask), (F, "glPolygonStipple(%p);\n", (const void *) mask));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Scissor)(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ DISPATCH(Scissor, (x, y, width, height), (F, "glScissor(%d, %d, %d, %d);\n", x, y, width, height));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ShadeModel)(GLenum mode)
+{
+ DISPATCH(ShadeModel, (mode), (F, "glShadeModel(0x%x);\n", mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexParameterf)(GLenum target, GLenum pname, GLfloat param)
+{
+ DISPATCH(TexParameterf, (target, pname, param), (F, "glTexParameterf(0x%x, 0x%x, %f);\n", target, pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexParameterfv)(GLenum target, GLenum pname, const GLfloat * params)
+{
+ DISPATCH(TexParameterfv, (target, pname, params), (F, "glTexParameterfv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexParameteri)(GLenum target, GLenum pname, GLint param)
+{
+ DISPATCH(TexParameteri, (target, pname, param), (F, "glTexParameteri(0x%x, 0x%x, %d);\n", target, pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexParameteriv)(GLenum target, GLenum pname, const GLint * params)
+{
+ DISPATCH(TexParameteriv, (target, pname, params), (F, "glTexParameteriv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexImage1D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ DISPATCH(TexImage1D, (target, level, internalformat, width, border, format, type, pixels), (F, "glTexImage1D(0x%x, %d, %d, %d, %d, 0x%x, 0x%x, %p);\n", target, level, internalformat, width, border, format, type, (const void *) pixels));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ DISPATCH(TexImage2D, (target, level, internalformat, width, height, border, format, type, pixels), (F, "glTexImage2D(0x%x, %d, %d, %d, %d, %d, 0x%x, 0x%x, %p);\n", target, level, internalformat, width, height, border, format, type, (const void *) pixels));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexEnvf)(GLenum target, GLenum pname, GLfloat param)
+{
+ DISPATCH(TexEnvf, (target, pname, param), (F, "glTexEnvf(0x%x, 0x%x, %f);\n", target, pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexEnvfv)(GLenum target, GLenum pname, const GLfloat * params)
+{
+ DISPATCH(TexEnvfv, (target, pname, params), (F, "glTexEnvfv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexEnvi)(GLenum target, GLenum pname, GLint param)
+{
+ DISPATCH(TexEnvi, (target, pname, param), (F, "glTexEnvi(0x%x, 0x%x, %d);\n", target, pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexEnviv)(GLenum target, GLenum pname, const GLint * params)
+{
+ DISPATCH(TexEnviv, (target, pname, params), (F, "glTexEnviv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexGend)(GLenum coord, GLenum pname, GLdouble param)
+{
+ DISPATCH(TexGend, (coord, pname, param), (F, "glTexGend(0x%x, 0x%x, %f);\n", coord, pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexGendv)(GLenum coord, GLenum pname, const GLdouble * params)
+{
+ DISPATCH(TexGendv, (coord, pname, params), (F, "glTexGendv(0x%x, 0x%x, %p);\n", coord, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexGenf)(GLenum coord, GLenum pname, GLfloat param)
+{
+ DISPATCH(TexGenf, (coord, pname, param), (F, "glTexGenf(0x%x, 0x%x, %f);\n", coord, pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexGenfv)(GLenum coord, GLenum pname, const GLfloat * params)
+{
+ DISPATCH(TexGenfv, (coord, pname, params), (F, "glTexGenfv(0x%x, 0x%x, %p);\n", coord, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexGeni)(GLenum coord, GLenum pname, GLint param)
+{
+ DISPATCH(TexGeni, (coord, pname, param), (F, "glTexGeni(0x%x, 0x%x, %d);\n", coord, pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexGeniv)(GLenum coord, GLenum pname, const GLint * params)
+{
+ DISPATCH(TexGeniv, (coord, pname, params), (F, "glTexGeniv(0x%x, 0x%x, %p);\n", coord, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FeedbackBuffer)(GLsizei size, GLenum type, GLfloat * buffer)
+{
+ DISPATCH(FeedbackBuffer, (size, type, buffer), (F, "glFeedbackBuffer(%d, 0x%x, %p);\n", size, type, (const void *) buffer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SelectBuffer)(GLsizei size, GLuint * buffer)
+{
+ DISPATCH(SelectBuffer, (size, buffer), (F, "glSelectBuffer(%d, %p);\n", size, (const void *) buffer));
+}
+
+KEYWORD1 GLint KEYWORD2 NAME(RenderMode)(GLenum mode)
+{
+ RETURN_DISPATCH(RenderMode, (mode), (F, "glRenderMode(0x%x);\n", mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(InitNames)(void)
+{
+ DISPATCH(InitNames, (), (F, "glInitNames();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LoadName)(GLuint name)
+{
+ DISPATCH(LoadName, (name), (F, "glLoadName(%d);\n", name));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PassThrough)(GLfloat token)
+{
+ DISPATCH(PassThrough, (token), (F, "glPassThrough(%f);\n", token));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PopName)(void)
+{
+ DISPATCH(PopName, (), (F, "glPopName();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PushName)(GLuint name)
+{
+ DISPATCH(PushName, (name), (F, "glPushName(%d);\n", name));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DrawBuffer)(GLenum mode)
+{
+ DISPATCH(DrawBuffer, (mode), (F, "glDrawBuffer(0x%x);\n", mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Clear)(GLbitfield mask)
+{
+ DISPATCH(Clear, (mask), (F, "glClear(%d);\n", mask));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ClearAccum)(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
+{
+ DISPATCH(ClearAccum, (red, green, blue, alpha), (F, "glClearAccum(%f, %f, %f, %f);\n", red, green, blue, alpha));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ClearIndex)(GLfloat c)
+{
+ DISPATCH(ClearIndex, (c), (F, "glClearIndex(%f);\n", c));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+ DISPATCH(ClearColor, (red, green, blue, alpha), (F, "glClearColor(%f, %f, %f, %f);\n", red, green, blue, alpha));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ClearStencil)(GLint s)
+{
+ DISPATCH(ClearStencil, (s), (F, "glClearStencil(%d);\n", s));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ClearDepth)(GLclampd depth)
+{
+ DISPATCH(ClearDepth, (depth), (F, "glClearDepth(%f);\n", depth));
+}
+
+KEYWORD1 void KEYWORD2 NAME(StencilMask)(GLuint mask)
+{
+ DISPATCH(StencilMask, (mask), (F, "glStencilMask(%d);\n", mask));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ColorMask)(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
+{
+ DISPATCH(ColorMask, (red, green, blue, alpha), (F, "glColorMask(%d, %d, %d, %d);\n", red, green, blue, alpha));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DepthMask)(GLboolean flag)
+{
+ DISPATCH(DepthMask, (flag), (F, "glDepthMask(%d);\n", flag));
+}
+
+KEYWORD1 void KEYWORD2 NAME(IndexMask)(GLuint mask)
+{
+ DISPATCH(IndexMask, (mask), (F, "glIndexMask(%d);\n", mask));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Accum)(GLenum op, GLfloat value)
+{
+ DISPATCH(Accum, (op, value), (F, "glAccum(0x%x, %f);\n", op, value));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Disable)(GLenum cap)
+{
+ DISPATCH(Disable, (cap), (F, "glDisable(0x%x);\n", cap));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Enable)(GLenum cap)
+{
+ DISPATCH(Enable, (cap), (F, "glEnable(0x%x);\n", cap));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Finish)(void)
+{
+ DISPATCH(Finish, (), (F, "glFinish();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Flush)(void)
+{
+ DISPATCH(Flush, (), (F, "glFlush();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PopAttrib)(void)
+{
+ DISPATCH(PopAttrib, (), (F, "glPopAttrib();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PushAttrib)(GLbitfield mask)
+{
+ DISPATCH(PushAttrib, (mask), (F, "glPushAttrib(%d);\n", mask));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Map1d)(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble * points)
+{
+ DISPATCH(Map1d, (target, u1, u2, stride, order, points), (F, "glMap1d(0x%x, %f, %f, %d, %d, %p);\n", target, u1, u2, stride, order, (const void *) points));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Map1f)(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat * points)
+{
+ DISPATCH(Map1f, (target, u1, u2, stride, order, points), (F, "glMap1f(0x%x, %f, %f, %d, %d, %p);\n", target, u1, u2, stride, order, (const void *) points));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Map2d)(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble * points)
+{
+ DISPATCH(Map2d, (target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points), (F, "glMap2d(0x%x, %f, %f, %d, %d, %f, %f, %d, %d, %p);\n", target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, (const void *) points));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Map2f)(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat * points)
+{
+ DISPATCH(Map2f, (target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points), (F, "glMap2f(0x%x, %f, %f, %d, %d, %f, %f, %d, %d, %p);\n", target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, (const void *) points));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MapGrid1d)(GLint un, GLdouble u1, GLdouble u2)
+{
+ DISPATCH(MapGrid1d, (un, u1, u2), (F, "glMapGrid1d(%d, %f, %f);\n", un, u1, u2));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MapGrid1f)(GLint un, GLfloat u1, GLfloat u2)
+{
+ DISPATCH(MapGrid1f, (un, u1, u2), (F, "glMapGrid1f(%d, %f, %f);\n", un, u1, u2));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MapGrid2d)(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2)
+{
+ DISPATCH(MapGrid2d, (un, u1, u2, vn, v1, v2), (F, "glMapGrid2d(%d, %f, %f, %d, %f, %f);\n", un, u1, u2, vn, v1, v2));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MapGrid2f)(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2)
+{
+ DISPATCH(MapGrid2f, (un, u1, u2, vn, v1, v2), (F, "glMapGrid2f(%d, %f, %f, %d, %f, %f);\n", un, u1, u2, vn, v1, v2));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EvalCoord1d)(GLdouble u)
+{
+ DISPATCH(EvalCoord1d, (u), (F, "glEvalCoord1d(%f);\n", u));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EvalCoord1dv)(const GLdouble * u)
+{
+ DISPATCH(EvalCoord1dv, (u), (F, "glEvalCoord1dv(%p);\n", (const void *) u));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EvalCoord1f)(GLfloat u)
+{
+ DISPATCH(EvalCoord1f, (u), (F, "glEvalCoord1f(%f);\n", u));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EvalCoord1fv)(const GLfloat * u)
+{
+ DISPATCH(EvalCoord1fv, (u), (F, "glEvalCoord1fv(%p);\n", (const void *) u));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EvalCoord2d)(GLdouble u, GLdouble v)
+{
+ DISPATCH(EvalCoord2d, (u, v), (F, "glEvalCoord2d(%f, %f);\n", u, v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EvalCoord2dv)(const GLdouble * u)
+{
+ DISPATCH(EvalCoord2dv, (u), (F, "glEvalCoord2dv(%p);\n", (const void *) u));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EvalCoord2f)(GLfloat u, GLfloat v)
+{
+ DISPATCH(EvalCoord2f, (u, v), (F, "glEvalCoord2f(%f, %f);\n", u, v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EvalCoord2fv)(const GLfloat * u)
+{
+ DISPATCH(EvalCoord2fv, (u), (F, "glEvalCoord2fv(%p);\n", (const void *) u));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EvalMesh1)(GLenum mode, GLint i1, GLint i2)
+{
+ DISPATCH(EvalMesh1, (mode, i1, i2), (F, "glEvalMesh1(0x%x, %d, %d);\n", mode, i1, i2));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EvalPoint1)(GLint i)
+{
+ DISPATCH(EvalPoint1, (i), (F, "glEvalPoint1(%d);\n", i));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EvalMesh2)(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)
+{
+ DISPATCH(EvalMesh2, (mode, i1, i2, j1, j2), (F, "glEvalMesh2(0x%x, %d, %d, %d, %d);\n", mode, i1, i2, j1, j2));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EvalPoint2)(GLint i, GLint j)
+{
+ DISPATCH(EvalPoint2, (i, j), (F, "glEvalPoint2(%d, %d);\n", i, j));
+}
+
+KEYWORD1 void KEYWORD2 NAME(AlphaFunc)(GLenum func, GLclampf ref)
+{
+ DISPATCH(AlphaFunc, (func, ref), (F, "glAlphaFunc(0x%x, %f);\n", func, ref));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BlendFunc)(GLenum sfactor, GLenum dfactor)
+{
+ DISPATCH(BlendFunc, (sfactor, dfactor), (F, "glBlendFunc(0x%x, 0x%x);\n", sfactor, dfactor));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LogicOp)(GLenum opcode)
+{
+ DISPATCH(LogicOp, (opcode), (F, "glLogicOp(0x%x);\n", opcode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(StencilFunc)(GLenum func, GLint ref, GLuint mask)
+{
+ DISPATCH(StencilFunc, (func, ref, mask), (F, "glStencilFunc(0x%x, %d, %d);\n", func, ref, mask));
+}
+
+KEYWORD1 void KEYWORD2 NAME(StencilOp)(GLenum fail, GLenum zfail, GLenum zpass)
+{
+ DISPATCH(StencilOp, (fail, zfail, zpass), (F, "glStencilOp(0x%x, 0x%x, 0x%x);\n", fail, zfail, zpass));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DepthFunc)(GLenum func)
+{
+ DISPATCH(DepthFunc, (func), (F, "glDepthFunc(0x%x);\n", func));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PixelZoom)(GLfloat xfactor, GLfloat yfactor)
+{
+ DISPATCH(PixelZoom, (xfactor, yfactor), (F, "glPixelZoom(%f, %f);\n", xfactor, yfactor));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PixelTransferf)(GLenum pname, GLfloat param)
+{
+ DISPATCH(PixelTransferf, (pname, param), (F, "glPixelTransferf(0x%x, %f);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PixelTransferi)(GLenum pname, GLint param)
+{
+ DISPATCH(PixelTransferi, (pname, param), (F, "glPixelTransferi(0x%x, %d);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PixelStoref)(GLenum pname, GLfloat param)
+{
+ DISPATCH(PixelStoref, (pname, param), (F, "glPixelStoref(0x%x, %f);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PixelStorei)(GLenum pname, GLint param)
+{
+ DISPATCH(PixelStorei, (pname, param), (F, "glPixelStorei(0x%x, %d);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PixelMapfv)(GLenum map, GLsizei mapsize, const GLfloat * values)
+{
+ DISPATCH(PixelMapfv, (map, mapsize, values), (F, "glPixelMapfv(0x%x, %d, %p);\n", map, mapsize, (const void *) values));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PixelMapuiv)(GLenum map, GLsizei mapsize, const GLuint * values)
+{
+ DISPATCH(PixelMapuiv, (map, mapsize, values), (F, "glPixelMapuiv(0x%x, %d, %p);\n", map, mapsize, (const void *) values));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PixelMapusv)(GLenum map, GLsizei mapsize, const GLushort * values)
+{
+ DISPATCH(PixelMapusv, (map, mapsize, values), (F, "glPixelMapusv(0x%x, %d, %p);\n", map, mapsize, (const void *) values));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ReadBuffer)(GLenum mode)
+{
+ DISPATCH(ReadBuffer, (mode), (F, "glReadBuffer(0x%x);\n", mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type)
+{
+ DISPATCH(CopyPixels, (x, y, width, height, type), (F, "glCopyPixels(%d, %d, %d, %d, 0x%x);\n", x, y, width, height, type));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid * pixels)
+{
+ DISPATCH(ReadPixels, (x, y, width, height, format, type, pixels), (F, "glReadPixels(%d, %d, %d, %d, 0x%x, 0x%x, %p);\n", x, y, width, height, format, type, (const void *) pixels));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DrawPixels)(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ DISPATCH(DrawPixels, (width, height, format, type, pixels), (F, "glDrawPixels(%d, %d, 0x%x, 0x%x, %p);\n", width, height, format, type, (const void *) pixels));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetBooleanv)(GLenum pname, GLboolean * params)
+{
+ DISPATCH(GetBooleanv, (pname, params), (F, "glGetBooleanv(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetClipPlane)(GLenum plane, GLdouble * equation)
+{
+ DISPATCH(GetClipPlane, (plane, equation), (F, "glGetClipPlane(0x%x, %p);\n", plane, (const void *) equation));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetDoublev)(GLenum pname, GLdouble * params)
+{
+ DISPATCH(GetDoublev, (pname, params), (F, "glGetDoublev(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 GLenum KEYWORD2 NAME(GetError)(void)
+{
+ RETURN_DISPATCH(GetError, (), (F, "glGetError();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetFloatv)(GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetFloatv, (pname, params), (F, "glGetFloatv(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetIntegerv)(GLenum pname, GLint * params)
+{
+ DISPATCH(GetIntegerv, (pname, params), (F, "glGetIntegerv(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetLightfv)(GLenum light, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetLightfv, (light, pname, params), (F, "glGetLightfv(0x%x, 0x%x, %p);\n", light, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetLightiv)(GLenum light, GLenum pname, GLint * params)
+{
+ DISPATCH(GetLightiv, (light, pname, params), (F, "glGetLightiv(0x%x, 0x%x, %p);\n", light, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetMapdv)(GLenum target, GLenum query, GLdouble * v)
+{
+ DISPATCH(GetMapdv, (target, query, v), (F, "glGetMapdv(0x%x, 0x%x, %p);\n", target, query, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetMapfv)(GLenum target, GLenum query, GLfloat * v)
+{
+ DISPATCH(GetMapfv, (target, query, v), (F, "glGetMapfv(0x%x, 0x%x, %p);\n", target, query, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetMapiv)(GLenum target, GLenum query, GLint * v)
+{
+ DISPATCH(GetMapiv, (target, query, v), (F, "glGetMapiv(0x%x, 0x%x, %p);\n", target, query, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetMaterialfv)(GLenum face, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetMaterialfv, (face, pname, params), (F, "glGetMaterialfv(0x%x, 0x%x, %p);\n", face, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetMaterialiv)(GLenum face, GLenum pname, GLint * params)
+{
+ DISPATCH(GetMaterialiv, (face, pname, params), (F, "glGetMaterialiv(0x%x, 0x%x, %p);\n", face, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetPixelMapfv)(GLenum map, GLfloat * values)
+{
+ DISPATCH(GetPixelMapfv, (map, values), (F, "glGetPixelMapfv(0x%x, %p);\n", map, (const void *) values));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetPixelMapuiv)(GLenum map, GLuint * values)
+{
+ DISPATCH(GetPixelMapuiv, (map, values), (F, "glGetPixelMapuiv(0x%x, %p);\n", map, (const void *) values));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetPixelMapusv)(GLenum map, GLushort * values)
+{
+ DISPATCH(GetPixelMapusv, (map, values), (F, "glGetPixelMapusv(0x%x, %p);\n", map, (const void *) values));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetPolygonStipple)(GLubyte * mask)
+{
+ DISPATCH(GetPolygonStipple, (mask), (F, "glGetPolygonStipple(%p);\n", (const void *) mask));
+}
+
+KEYWORD1 const GLubyte * KEYWORD2 NAME(GetString)(GLenum name)
+{
+ RETURN_DISPATCH(GetString, (name), (F, "glGetString(0x%x);\n", name));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetTexEnvfv)(GLenum target, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetTexEnvfv, (target, pname, params), (F, "glGetTexEnvfv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetTexEnviv)(GLenum target, GLenum pname, GLint * params)
+{
+ DISPATCH(GetTexEnviv, (target, pname, params), (F, "glGetTexEnviv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetTexGendv)(GLenum coord, GLenum pname, GLdouble * params)
+{
+ DISPATCH(GetTexGendv, (coord, pname, params), (F, "glGetTexGendv(0x%x, 0x%x, %p);\n", coord, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetTexGenfv)(GLenum coord, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetTexGenfv, (coord, pname, params), (F, "glGetTexGenfv(0x%x, 0x%x, %p);\n", coord, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetTexGeniv)(GLenum coord, GLenum pname, GLint * params)
+{
+ DISPATCH(GetTexGeniv, (coord, pname, params), (F, "glGetTexGeniv(0x%x, 0x%x, %p);\n", coord, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetTexImage)(GLenum target, GLint level, GLenum format, GLenum type, GLvoid * pixels)
+{
+ DISPATCH(GetTexImage, (target, level, format, type, pixels), (F, "glGetTexImage(0x%x, %d, 0x%x, 0x%x, %p);\n", target, level, format, type, (const void *) pixels));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetTexParameterfv)(GLenum target, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetTexParameterfv, (target, pname, params), (F, "glGetTexParameterfv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetTexParameteriv)(GLenum target, GLenum pname, GLint * params)
+{
+ DISPATCH(GetTexParameteriv, (target, pname, params), (F, "glGetTexParameteriv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetTexLevelParameterfv)(GLenum target, GLint level, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetTexLevelParameterfv, (target, level, pname, params), (F, "glGetTexLevelParameterfv(0x%x, %d, 0x%x, %p);\n", target, level, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetTexLevelParameteriv)(GLenum target, GLint level, GLenum pname, GLint * params)
+{
+ DISPATCH(GetTexLevelParameteriv, (target, level, pname, params), (F, "glGetTexLevelParameteriv(0x%x, %d, 0x%x, %p);\n", target, level, pname, (const void *) params));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(IsEnabled)(GLenum cap)
+{
+ RETURN_DISPATCH(IsEnabled, (cap), (F, "glIsEnabled(0x%x);\n", cap));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(IsList)(GLuint list)
+{
+ RETURN_DISPATCH(IsList, (list), (F, "glIsList(%d);\n", list));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DepthRange)(GLclampd zNear, GLclampd zFar)
+{
+ DISPATCH(DepthRange, (zNear, zFar), (F, "glDepthRange(%f, %f);\n", zNear, zFar));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Frustum)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
+{
+ DISPATCH(Frustum, (left, right, bottom, top, zNear, zFar), (F, "glFrustum(%f, %f, %f, %f, %f, %f);\n", left, right, bottom, top, zNear, zFar));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LoadIdentity)(void)
+{
+ DISPATCH(LoadIdentity, (), (F, "glLoadIdentity();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LoadMatrixf)(const GLfloat * m)
+{
+ DISPATCH(LoadMatrixf, (m), (F, "glLoadMatrixf(%p);\n", (const void *) m));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LoadMatrixd)(const GLdouble * m)
+{
+ DISPATCH(LoadMatrixd, (m), (F, "glLoadMatrixd(%p);\n", (const void *) m));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MatrixMode)(GLenum mode)
+{
+ DISPATCH(MatrixMode, (mode), (F, "glMatrixMode(0x%x);\n", mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultMatrixf)(const GLfloat * m)
+{
+ DISPATCH(MultMatrixf, (m), (F, "glMultMatrixf(%p);\n", (const void *) m));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultMatrixd)(const GLdouble * m)
+{
+ DISPATCH(MultMatrixd, (m), (F, "glMultMatrixd(%p);\n", (const void *) m));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Ortho)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar)
+{
+ DISPATCH(Ortho, (left, right, bottom, top, zNear, zFar), (F, "glOrtho(%f, %f, %f, %f, %f, %f);\n", left, right, bottom, top, zNear, zFar));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PopMatrix)(void)
+{
+ DISPATCH(PopMatrix, (), (F, "glPopMatrix();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PushMatrix)(void)
+{
+ DISPATCH(PushMatrix, (), (F, "glPushMatrix();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Rotated)(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
+{
+ DISPATCH(Rotated, (angle, x, y, z), (F, "glRotated(%f, %f, %f, %f);\n", angle, x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Rotatef)(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
+{
+ DISPATCH(Rotatef, (angle, x, y, z), (F, "glRotatef(%f, %f, %f, %f);\n", angle, x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Scaled)(GLdouble x, GLdouble y, GLdouble z)
+{
+ DISPATCH(Scaled, (x, y, z), (F, "glScaled(%f, %f, %f);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Scalef)(GLfloat x, GLfloat y, GLfloat z)
+{
+ DISPATCH(Scalef, (x, y, z), (F, "glScalef(%f, %f, %f);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Translated)(GLdouble x, GLdouble y, GLdouble z)
+{
+ DISPATCH(Translated, (x, y, z), (F, "glTranslated(%f, %f, %f);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Translatef)(GLfloat x, GLfloat y, GLfloat z)
+{
+ DISPATCH(Translatef, (x, y, z), (F, "glTranslatef(%f, %f, %f);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Viewport)(GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ DISPATCH(Viewport, (x, y, width, height), (F, "glViewport(%d, %d, %d, %d);\n", x, y, width, height));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ArrayElement)(GLint i)
+{
+ DISPATCH(ArrayElement, (i), (F, "glArrayElement(%d);\n", i));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ArrayElementEXT)(GLint i)
+{
+ DISPATCH(ArrayElement, (i), (F, "glArrayElementEXT(%d);\n", i));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BindTexture)(GLenum target, GLuint texture)
+{
+ DISPATCH(BindTexture, (target, texture), (F, "glBindTexture(0x%x, %d);\n", target, texture));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BindTextureEXT)(GLenum target, GLuint texture)
+{
+ DISPATCH(BindTexture, (target, texture), (F, "glBindTextureEXT(0x%x, %d);\n", target, texture));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)
+{
+ DISPATCH(ColorPointer, (size, type, stride, pointer), (F, "glColorPointer(%d, 0x%x, %d, %p);\n", size, type, stride, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DisableClientState)(GLenum array)
+{
+ DISPATCH(DisableClientState, (array), (F, "glDisableClientState(0x%x);\n", array));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DrawArrays)(GLenum mode, GLint first, GLsizei count)
+{
+ DISPATCH(DrawArrays, (mode, first, count), (F, "glDrawArrays(0x%x, %d, %d);\n", mode, first, count));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DrawArraysEXT)(GLenum mode, GLint first, GLsizei count)
+{
+ DISPATCH(DrawArrays, (mode, first, count), (F, "glDrawArraysEXT(0x%x, %d, %d);\n", mode, first, count));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid * indices)
+{
+ DISPATCH(DrawElements, (mode, count, type, indices), (F, "glDrawElements(0x%x, %d, 0x%x, %p);\n", mode, count, type, (const void *) indices));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EdgeFlagPointer)(GLsizei stride, const GLvoid * pointer)
+{
+ DISPATCH(EdgeFlagPointer, (stride, pointer), (F, "glEdgeFlagPointer(%d, %p);\n", stride, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EnableClientState)(GLenum array)
+{
+ DISPATCH(EnableClientState, (array), (F, "glEnableClientState(0x%x);\n", array));
+}
+
+KEYWORD1 void KEYWORD2 NAME(IndexPointer)(GLenum type, GLsizei stride, const GLvoid * pointer)
+{
+ DISPATCH(IndexPointer, (type, stride, pointer), (F, "glIndexPointer(0x%x, %d, %p);\n", type, stride, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Indexub)(GLubyte c)
+{
+ DISPATCH(Indexub, (c), (F, "glIndexub(%d);\n", c));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Indexubv)(const GLubyte * c)
+{
+ DISPATCH(Indexubv, (c), (F, "glIndexubv(%p);\n", (const void *) c));
+}
+
+KEYWORD1 void KEYWORD2 NAME(InterleavedArrays)(GLenum format, GLsizei stride, const GLvoid * pointer)
+{
+ DISPATCH(InterleavedArrays, (format, stride, pointer), (F, "glInterleavedArrays(0x%x, %d, %p);\n", format, stride, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(NormalPointer)(GLenum type, GLsizei stride, const GLvoid * pointer)
+{
+ DISPATCH(NormalPointer, (type, stride, pointer), (F, "glNormalPointer(0x%x, %d, %p);\n", type, stride, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PolygonOffset)(GLfloat factor, GLfloat units)
+{
+ DISPATCH(PolygonOffset, (factor, units), (F, "glPolygonOffset(%f, %f);\n", factor, units));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)
+{
+ DISPATCH(TexCoordPointer, (size, type, stride, pointer), (F, "glTexCoordPointer(%d, 0x%x, %d, %p);\n", size, type, stride, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)
+{
+ DISPATCH(VertexPointer, (size, type, stride, pointer), (F, "glVertexPointer(%d, 0x%x, %d, %p);\n", size, type, stride, (const void *) pointer));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(AreTexturesResident)(GLsizei n, const GLuint * textures, GLboolean * residences)
+{
+ RETURN_DISPATCH(AreTexturesResident, (n, textures, residences), (F, "glAreTexturesResident(%d, %p, %p);\n", n, (const void *) textures, (const void *) residences));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyTexImage1D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border)
+{
+ DISPATCH(CopyTexImage1D, (target, level, internalformat, x, y, width, border), (F, "glCopyTexImage1D(0x%x, %d, 0x%x, %d, %d, %d, %d);\n", target, level, internalformat, x, y, width, border));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyTexImage1DEXT)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border)
+{
+ DISPATCH(CopyTexImage1D, (target, level, internalformat, x, y, width, border), (F, "glCopyTexImage1DEXT(0x%x, %d, 0x%x, %d, %d, %d, %d);\n", target, level, internalformat, x, y, width, border));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyTexImage2D)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
+{
+ DISPATCH(CopyTexImage2D, (target, level, internalformat, x, y, width, height, border), (F, "glCopyTexImage2D(0x%x, %d, 0x%x, %d, %d, %d, %d, %d);\n", target, level, internalformat, x, y, width, height, border));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyTexImage2DEXT)(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
+{
+ DISPATCH(CopyTexImage2D, (target, level, internalformat, x, y, width, height, border), (F, "glCopyTexImage2DEXT(0x%x, %d, 0x%x, %d, %d, %d, %d, %d);\n", target, level, internalformat, x, y, width, height, border));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyTexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width)
+{
+ DISPATCH(CopyTexSubImage1D, (target, level, xoffset, x, y, width), (F, "glCopyTexSubImage1D(0x%x, %d, %d, %d, %d, %d);\n", target, level, xoffset, x, y, width));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyTexSubImage1DEXT)(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width)
+{
+ DISPATCH(CopyTexSubImage1D, (target, level, xoffset, x, y, width), (F, "glCopyTexSubImage1DEXT(0x%x, %d, %d, %d, %d, %d);\n", target, level, xoffset, x, y, width));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyTexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ DISPATCH(CopyTexSubImage2D, (target, level, xoffset, yoffset, x, y, width, height), (F, "glCopyTexSubImage2D(0x%x, %d, %d, %d, %d, %d, %d, %d);\n", target, level, xoffset, yoffset, x, y, width, height));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyTexSubImage2DEXT)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ DISPATCH(CopyTexSubImage2D, (target, level, xoffset, yoffset, x, y, width, height), (F, "glCopyTexSubImage2DEXT(0x%x, %d, %d, %d, %d, %d, %d, %d);\n", target, level, xoffset, yoffset, x, y, width, height));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DeleteTextures)(GLsizei n, const GLuint * textures)
+{
+ DISPATCH(DeleteTextures, (n, textures), (F, "glDeleteTextures(%d, %p);\n", n, (const void *) textures));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DeleteTexturesEXT)(GLsizei n, const GLuint * textures)
+{
+ DISPATCH(DeleteTextures, (n, textures), (F, "glDeleteTexturesEXT(%d, %p);\n", n, (const void *) textures));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GenTextures)(GLsizei n, GLuint * textures)
+{
+ DISPATCH(GenTextures, (n, textures), (F, "glGenTextures(%d, %p);\n", n, (const void *) textures));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetPointerv)(GLenum pname, GLvoid ** params)
+{
+ DISPATCH(GetPointerv, (pname, params), (F, "glGetPointerv(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetPointervEXT)(GLenum pname, GLvoid ** params)
+{
+ DISPATCH(GetPointerv, (pname, params), (F, "glGetPointervEXT(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(IsTexture)(GLuint texture)
+{
+ RETURN_DISPATCH(IsTexture, (texture), (F, "glIsTexture(%d);\n", texture));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PrioritizeTextures)(GLsizei n, const GLuint * textures, const GLclampf * priorities)
+{
+ DISPATCH(PrioritizeTextures, (n, textures, priorities), (F, "glPrioritizeTextures(%d, %p, %p);\n", n, (const void *) textures, (const void *) priorities));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PrioritizeTexturesEXT)(GLsizei n, const GLuint * textures, const GLclampf * priorities)
+{
+ DISPATCH(PrioritizeTextures, (n, textures, priorities), (F, "glPrioritizeTexturesEXT(%d, %p, %p);\n", n, (const void *) textures, (const void *) priorities));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexSubImage1D)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ DISPATCH(TexSubImage1D, (target, level, xoffset, width, format, type, pixels), (F, "glTexSubImage1D(0x%x, %d, %d, %d, 0x%x, 0x%x, %p);\n", target, level, xoffset, width, format, type, (const void *) pixels));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexSubImage1DEXT)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ DISPATCH(TexSubImage1D, (target, level, xoffset, width, format, type, pixels), (F, "glTexSubImage1DEXT(0x%x, %d, %d, %d, 0x%x, 0x%x, %p);\n", target, level, xoffset, width, format, type, (const void *) pixels));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ DISPATCH(TexSubImage2D, (target, level, xoffset, yoffset, width, height, format, type, pixels), (F, "glTexSubImage2D(0x%x, %d, %d, %d, %d, %d, 0x%x, 0x%x, %p);\n", target, level, xoffset, yoffset, width, height, format, type, (const void *) pixels));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexSubImage2DEXT)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ DISPATCH(TexSubImage2D, (target, level, xoffset, yoffset, width, height, format, type, pixels), (F, "glTexSubImage2DEXT(0x%x, %d, %d, %d, %d, %d, 0x%x, 0x%x, %p);\n", target, level, xoffset, yoffset, width, height, format, type, (const void *) pixels));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PopClientAttrib)(void)
+{
+ DISPATCH(PopClientAttrib, (), (F, "glPopClientAttrib();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PushClientAttrib)(GLbitfield mask)
+{
+ DISPATCH(PushClientAttrib, (mask), (F, "glPushClientAttrib(%d);\n", mask));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BlendColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+ DISPATCH(BlendColor, (red, green, blue, alpha), (F, "glBlendColor(%f, %f, %f, %f);\n", red, green, blue, alpha));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BlendColorEXT)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
+{
+ DISPATCH(BlendColor, (red, green, blue, alpha), (F, "glBlendColorEXT(%f, %f, %f, %f);\n", red, green, blue, alpha));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BlendEquation)(GLenum mode)
+{
+ DISPATCH(BlendEquation, (mode), (F, "glBlendEquation(0x%x);\n", mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BlendEquationEXT)(GLenum mode)
+{
+ DISPATCH(BlendEquation, (mode), (F, "glBlendEquationEXT(0x%x);\n", mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DrawRangeElements)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices)
+{
+ DISPATCH(DrawRangeElements, (mode, start, end, count, type, indices), (F, "glDrawRangeElements(0x%x, %d, %d, %d, 0x%x, %p);\n", mode, start, end, count, type, (const void *) indices));
+}
+
+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, %d, %d, %d, 0x%x, %p);\n", mode, start, end, count, type, (const void *) indices));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ColorTable)(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * table)
+{
+ DISPATCH(ColorTable, (target, internalformat, width, format, type, table), (F, "glColorTable(0x%x, 0x%x, %d, 0x%x, 0x%x, %p);\n", target, internalformat, width, format, type, (const void *) table));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ColorTableSGI)(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * table)
+{
+ DISPATCH(ColorTable, (target, internalformat, width, format, type, table), (F, "glColorTableSGI(0x%x, 0x%x, %d, 0x%x, 0x%x, %p);\n", target, internalformat, width, format, type, (const void *) table));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ColorTableEXT)(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * table)
+{
+ DISPATCH(ColorTable, (target, internalformat, width, format, type, table), (F, "glColorTableEXT(0x%x, 0x%x, %d, 0x%x, 0x%x, %p);\n", target, internalformat, width, format, type, (const void *) table));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ColorTableParameterfv)(GLenum target, GLenum pname, const GLfloat * params)
+{
+ DISPATCH(ColorTableParameterfv, (target, pname, params), (F, "glColorTableParameterfv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ColorTableParameterfvSGI)(GLenum target, GLenum pname, const GLfloat * params)
+{
+ DISPATCH(ColorTableParameterfv, (target, pname, params), (F, "glColorTableParameterfvSGI(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ColorTableParameteriv)(GLenum target, GLenum pname, const GLint * params)
+{
+ DISPATCH(ColorTableParameteriv, (target, pname, params), (F, "glColorTableParameteriv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ColorTableParameterivSGI)(GLenum target, GLenum pname, const GLint * params)
+{
+ DISPATCH(ColorTableParameteriv, (target, pname, params), (F, "glColorTableParameterivSGI(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyColorTable)(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width)
+{
+ DISPATCH(CopyColorTable, (target, internalformat, x, y, width), (F, "glCopyColorTable(0x%x, 0x%x, %d, %d, %d);\n", target, internalformat, x, y, width));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyColorTableSGI)(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width)
+{
+ DISPATCH(CopyColorTable, (target, internalformat, x, y, width), (F, "glCopyColorTableSGI(0x%x, 0x%x, %d, %d, %d);\n", target, internalformat, x, y, width));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetColorTable)(GLenum target, GLenum format, GLenum type, GLvoid * table)
+{
+ DISPATCH(GetColorTable, (target, format, type, table), (F, "glGetColorTable(0x%x, 0x%x, 0x%x, %p);\n", target, format, type, (const void *) table));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetColorTableParameterfv)(GLenum target, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetColorTableParameterfv, (target, pname, params), (F, "glGetColorTableParameterfv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetColorTableParameteriv)(GLenum target, GLenum pname, GLint * params)
+{
+ DISPATCH(GetColorTableParameteriv, (target, pname, params), (F, "glGetColorTableParameteriv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ColorSubTable)(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid * data)
+{
+ DISPATCH(ColorSubTable, (target, start, count, format, type, data), (F, "glColorSubTable(0x%x, %d, %d, 0x%x, 0x%x, %p);\n", target, start, count, format, type, (const void *) data));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ColorSubTableEXT)(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid * data)
+{
+ DISPATCH(ColorSubTable, (target, start, count, format, type, data), (F, "glColorSubTableEXT(0x%x, %d, %d, 0x%x, 0x%x, %p);\n", target, start, count, format, type, (const void *) data));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyColorSubTable)(GLenum target, GLsizei start, GLint x, GLint y, GLsizei width)
+{
+ DISPATCH(CopyColorSubTable, (target, start, x, y, width), (F, "glCopyColorSubTable(0x%x, %d, %d, %d, %d);\n", target, start, x, y, width));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyColorSubTableEXT)(GLenum target, GLsizei start, GLint x, GLint y, GLsizei width)
+{
+ DISPATCH(CopyColorSubTable, (target, start, x, y, width), (F, "glCopyColorSubTableEXT(0x%x, %d, %d, %d, %d);\n", target, start, x, y, width));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ConvolutionFilter1D)(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * image)
+{
+ DISPATCH(ConvolutionFilter1D, (target, internalformat, width, format, type, image), (F, "glConvolutionFilter1D(0x%x, 0x%x, %d, 0x%x, 0x%x, %p);\n", target, internalformat, width, format, type, (const void *) image));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ConvolutionFilter1DEXT)(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid * image)
+{
+ DISPATCH(ConvolutionFilter1D, (target, internalformat, width, format, type, image), (F, "glConvolutionFilter1DEXT(0x%x, 0x%x, %d, 0x%x, 0x%x, %p);\n", target, internalformat, width, format, type, (const void *) image));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ConvolutionFilter2D)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * image)
+{
+ DISPATCH(ConvolutionFilter2D, (target, internalformat, width, height, format, type, image), (F, "glConvolutionFilter2D(0x%x, 0x%x, %d, %d, 0x%x, 0x%x, %p);\n", target, internalformat, width, height, format, type, (const void *) image));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ConvolutionFilter2DEXT)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * image)
+{
+ DISPATCH(ConvolutionFilter2D, (target, internalformat, width, height, format, type, image), (F, "glConvolutionFilter2DEXT(0x%x, 0x%x, %d, %d, 0x%x, 0x%x, %p);\n", target, internalformat, width, height, format, type, (const void *) image));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ConvolutionParameterf)(GLenum target, GLenum pname, GLfloat params)
+{
+ DISPATCH(ConvolutionParameterf, (target, pname, params), (F, "glConvolutionParameterf(0x%x, 0x%x, %f);\n", target, pname, params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ConvolutionParameterfEXT)(GLenum target, GLenum pname, GLfloat params)
+{
+ DISPATCH(ConvolutionParameterf, (target, pname, params), (F, "glConvolutionParameterfEXT(0x%x, 0x%x, %f);\n", target, pname, params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ConvolutionParameterfv)(GLenum target, GLenum pname, const GLfloat * params)
+{
+ DISPATCH(ConvolutionParameterfv, (target, pname, params), (F, "glConvolutionParameterfv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ConvolutionParameterfvEXT)(GLenum target, GLenum pname, const GLfloat * params)
+{
+ DISPATCH(ConvolutionParameterfv, (target, pname, params), (F, "glConvolutionParameterfvEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ConvolutionParameteri)(GLenum target, GLenum pname, GLint params)
+{
+ DISPATCH(ConvolutionParameteri, (target, pname, params), (F, "glConvolutionParameteri(0x%x, 0x%x, %d);\n", target, pname, params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ConvolutionParameteriEXT)(GLenum target, GLenum pname, GLint params)
+{
+ DISPATCH(ConvolutionParameteri, (target, pname, params), (F, "glConvolutionParameteriEXT(0x%x, 0x%x, %d);\n", target, pname, params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ConvolutionParameteriv)(GLenum target, GLenum pname, const GLint * params)
+{
+ DISPATCH(ConvolutionParameteriv, (target, pname, params), (F, "glConvolutionParameteriv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ConvolutionParameterivEXT)(GLenum target, GLenum pname, const GLint * params)
+{
+ DISPATCH(ConvolutionParameteriv, (target, pname, params), (F, "glConvolutionParameterivEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyConvolutionFilter1D)(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width)
+{
+ DISPATCH(CopyConvolutionFilter1D, (target, internalformat, x, y, width), (F, "glCopyConvolutionFilter1D(0x%x, 0x%x, %d, %d, %d);\n", target, internalformat, x, y, width));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyConvolutionFilter1DEXT)(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width)
+{
+ DISPATCH(CopyConvolutionFilter1D, (target, internalformat, x, y, width), (F, "glCopyConvolutionFilter1DEXT(0x%x, 0x%x, %d, %d, %d);\n", target, internalformat, x, y, width));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyConvolutionFilter2D)(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ DISPATCH(CopyConvolutionFilter2D, (target, internalformat, x, y, width, height), (F, "glCopyConvolutionFilter2D(0x%x, 0x%x, %d, %d, %d, %d);\n", target, internalformat, x, y, width, height));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyConvolutionFilter2DEXT)(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ DISPATCH(CopyConvolutionFilter2D, (target, internalformat, x, y, width, height), (F, "glCopyConvolutionFilter2DEXT(0x%x, 0x%x, %d, %d, %d, %d);\n", target, internalformat, x, y, width, height));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetConvolutionFilter)(GLenum target, GLenum format, GLenum type, GLvoid * image)
+{
+ DISPATCH(GetConvolutionFilter, (target, format, type, image), (F, "glGetConvolutionFilter(0x%x, 0x%x, 0x%x, %p);\n", target, format, type, (const void *) image));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetConvolutionParameterfv)(GLenum target, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetConvolutionParameterfv, (target, pname, params), (F, "glGetConvolutionParameterfv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetConvolutionParameteriv)(GLenum target, GLenum pname, GLint * params)
+{
+ DISPATCH(GetConvolutionParameteriv, (target, pname, params), (F, "glGetConvolutionParameteriv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetSeparableFilter)(GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span)
+{
+ DISPATCH(GetSeparableFilter, (target, format, type, row, column, span), (F, "glGetSeparableFilter(0x%x, 0x%x, 0x%x, %p, %p, %p);\n", target, format, type, (const void *) row, (const void *) column, (const void *) span));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SeparableFilter2D)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * row, const GLvoid * column)
+{
+ DISPATCH(SeparableFilter2D, (target, internalformat, width, height, format, type, row, column), (F, "glSeparableFilter2D(0x%x, 0x%x, %d, %d, 0x%x, 0x%x, %p, %p);\n", target, internalformat, width, height, format, type, (const void *) row, (const void *) column));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SeparableFilter2DEXT)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid * row, const GLvoid * column)
+{
+ DISPATCH(SeparableFilter2D, (target, internalformat, width, height, format, type, row, column), (F, "glSeparableFilter2DEXT(0x%x, 0x%x, %d, %d, 0x%x, 0x%x, %p, %p);\n", target, internalformat, width, height, format, type, (const void *) row, (const void *) column));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetHistogram)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values)
+{
+ DISPATCH(GetHistogram, (target, reset, format, type, values), (F, "glGetHistogram(0x%x, %d, 0x%x, 0x%x, %p);\n", target, reset, format, type, (const void *) values));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetHistogramParameterfv)(GLenum target, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetHistogramParameterfv, (target, pname, params), (F, "glGetHistogramParameterfv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetHistogramParameteriv)(GLenum target, GLenum pname, GLint * params)
+{
+ DISPATCH(GetHistogramParameteriv, (target, pname, params), (F, "glGetHistogramParameteriv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetMinmax)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values)
+{
+ DISPATCH(GetMinmax, (target, reset, format, type, values), (F, "glGetMinmax(0x%x, %d, 0x%x, 0x%x, %p);\n", target, reset, format, type, (const void *) values));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetMinmaxParameterfv)(GLenum target, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetMinmaxParameterfv, (target, pname, params), (F, "glGetMinmaxParameterfv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetMinmaxParameteriv)(GLenum target, GLenum pname, GLint * params)
+{
+ DISPATCH(GetMinmaxParameteriv, (target, pname, params), (F, "glGetMinmaxParameteriv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Histogram)(GLenum target, GLsizei width, GLenum internalformat, GLboolean sink)
+{
+ DISPATCH(Histogram, (target, width, internalformat, sink), (F, "glHistogram(0x%x, %d, 0x%x, %d);\n", target, width, internalformat, sink));
+}
+
+KEYWORD1 void KEYWORD2 NAME(HistogramEXT)(GLenum target, GLsizei width, GLenum internalformat, GLboolean sink)
+{
+ DISPATCH(Histogram, (target, width, internalformat, sink), (F, "glHistogramEXT(0x%x, %d, 0x%x, %d);\n", target, width, internalformat, sink));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Minmax)(GLenum target, GLenum internalformat, GLboolean sink)
+{
+ DISPATCH(Minmax, (target, internalformat, sink), (F, "glMinmax(0x%x, 0x%x, %d);\n", target, internalformat, sink));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MinmaxEXT)(GLenum target, GLenum internalformat, GLboolean sink)
+{
+ DISPATCH(Minmax, (target, internalformat, sink), (F, "glMinmaxEXT(0x%x, 0x%x, %d);\n", target, internalformat, sink));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ResetHistogram)(GLenum target)
+{
+ DISPATCH(ResetHistogram, (target), (F, "glResetHistogram(0x%x);\n", target));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ResetHistogramEXT)(GLenum target)
+{
+ DISPATCH(ResetHistogram, (target), (F, "glResetHistogramEXT(0x%x);\n", target));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ResetMinmax)(GLenum target)
+{
+ DISPATCH(ResetMinmax, (target), (F, "glResetMinmax(0x%x);\n", target));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ResetMinmaxEXT)(GLenum target)
+{
+ DISPATCH(ResetMinmax, (target), (F, "glResetMinmaxEXT(0x%x);\n", target));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexImage3D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ DISPATCH(TexImage3D, (target, level, internalformat, width, height, depth, border, format, type, pixels), (F, "glTexImage3D(0x%x, %d, %d, %d, %d, %d, %d, 0x%x, 0x%x, %p);\n", target, level, internalformat, width, height, depth, border, format, type, (const void *) pixels));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexImage3DEXT)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ DISPATCH(TexImage3D, (target, level, internalformat, width, height, depth, border, format, type, pixels), (F, "glTexImage3DEXT(0x%x, %d, %d, %d, %d, %d, %d, 0x%x, 0x%x, %p);\n", target, level, internalformat, width, height, depth, border, format, type, (const void *) pixels));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ DISPATCH(TexSubImage3D, (target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels), (F, "glTexSubImage3D(0x%x, %d, %d, %d, %d, %d, %d, %d, 0x%x, 0x%x, %p);\n", target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, (const void *) pixels));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexSubImage3DEXT)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ DISPATCH(TexSubImage3D, (target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels), (F, "glTexSubImage3DEXT(0x%x, %d, %d, %d, %d, %d, %d, %d, 0x%x, 0x%x, %p);\n", target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, (const void *) pixels));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyTexSubImage3D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ DISPATCH(CopyTexSubImage3D, (target, level, xoffset, yoffset, zoffset, x, y, width, height), (F, "glCopyTexSubImage3D(0x%x, %d, %d, %d, %d, %d, %d, %d, %d);\n", target, level, xoffset, yoffset, zoffset, x, y, width, height));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CopyTexSubImage3DEXT)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ DISPATCH(CopyTexSubImage3D, (target, level, xoffset, yoffset, zoffset, x, y, width, height), (F, "glCopyTexSubImage3DEXT(0x%x, %d, %d, %d, %d, %d, %d, %d, %d);\n", target, level, xoffset, yoffset, zoffset, x, y, width, height));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ActiveTexture)(GLenum texture)
+{
+ DISPATCH(ActiveTextureARB, (texture), (F, "glActiveTexture(0x%x);\n", texture));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ActiveTextureARB)(GLenum texture)
+{
+ DISPATCH(ActiveTextureARB, (texture), (F, "glActiveTextureARB(0x%x);\n", texture));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ClientActiveTexture)(GLenum texture)
+{
+ DISPATCH(ClientActiveTextureARB, (texture), (F, "glClientActiveTexture(0x%x);\n", texture));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ClientActiveTextureARB)(GLenum texture)
+{
+ DISPATCH(ClientActiveTextureARB, (texture), (F, "glClientActiveTextureARB(0x%x);\n", texture));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1d)(GLenum target, GLdouble s)
+{
+ DISPATCH(MultiTexCoord1dARB, (target, s), (F, "glMultiTexCoord1d(0x%x, %f);\n", target, s));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1dARB)(GLenum target, GLdouble s)
+{
+ DISPATCH(MultiTexCoord1dARB, (target, s), (F, "glMultiTexCoord1dARB(0x%x, %f);\n", target, s));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1dv)(GLenum target, const GLdouble * v)
+{
+ DISPATCH(MultiTexCoord1dvARB, (target, v), (F, "glMultiTexCoord1dv(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1dvARB)(GLenum target, const GLdouble * v)
+{
+ DISPATCH(MultiTexCoord1dvARB, (target, v), (F, "glMultiTexCoord1dvARB(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1f)(GLenum target, GLfloat s)
+{
+ DISPATCH(MultiTexCoord1fARB, (target, s), (F, "glMultiTexCoord1f(0x%x, %f);\n", target, s));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1fARB)(GLenum target, GLfloat s)
+{
+ DISPATCH(MultiTexCoord1fARB, (target, s), (F, "glMultiTexCoord1fARB(0x%x, %f);\n", target, s));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1fv)(GLenum target, const GLfloat * v)
+{
+ DISPATCH(MultiTexCoord1fvARB, (target, v), (F, "glMultiTexCoord1fv(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1fvARB)(GLenum target, const GLfloat * v)
+{
+ DISPATCH(MultiTexCoord1fvARB, (target, v), (F, "glMultiTexCoord1fvARB(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1i)(GLenum target, GLint s)
+{
+ DISPATCH(MultiTexCoord1iARB, (target, s), (F, "glMultiTexCoord1i(0x%x, %d);\n", target, s));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1iARB)(GLenum target, GLint s)
+{
+ DISPATCH(MultiTexCoord1iARB, (target, s), (F, "glMultiTexCoord1iARB(0x%x, %d);\n", target, s));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1iv)(GLenum target, const GLint * v)
+{
+ DISPATCH(MultiTexCoord1ivARB, (target, v), (F, "glMultiTexCoord1iv(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1ivARB)(GLenum target, const GLint * v)
+{
+ DISPATCH(MultiTexCoord1ivARB, (target, v), (F, "glMultiTexCoord1ivARB(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1s)(GLenum target, GLshort s)
+{
+ DISPATCH(MultiTexCoord1sARB, (target, s), (F, "glMultiTexCoord1s(0x%x, %d);\n", target, s));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1sARB)(GLenum target, GLshort s)
+{
+ DISPATCH(MultiTexCoord1sARB, (target, s), (F, "glMultiTexCoord1sARB(0x%x, %d);\n", target, s));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1sv)(GLenum target, const GLshort * v)
+{
+ DISPATCH(MultiTexCoord1svARB, (target, v), (F, "glMultiTexCoord1sv(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1svARB)(GLenum target, const GLshort * v)
+{
+ DISPATCH(MultiTexCoord1svARB, (target, v), (F, "glMultiTexCoord1svARB(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2d)(GLenum target, GLdouble s, GLdouble t)
+{
+ DISPATCH(MultiTexCoord2dARB, (target, s, t), (F, "glMultiTexCoord2d(0x%x, %f, %f);\n", target, s, t));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2dARB)(GLenum target, GLdouble s, GLdouble t)
+{
+ DISPATCH(MultiTexCoord2dARB, (target, s, t), (F, "glMultiTexCoord2dARB(0x%x, %f, %f);\n", target, s, t));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2dv)(GLenum target, const GLdouble * v)
+{
+ DISPATCH(MultiTexCoord2dvARB, (target, v), (F, "glMultiTexCoord2dv(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2dvARB)(GLenum target, const GLdouble * v)
+{
+ DISPATCH(MultiTexCoord2dvARB, (target, v), (F, "glMultiTexCoord2dvARB(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2f)(GLenum target, GLfloat s, GLfloat t)
+{
+ DISPATCH(MultiTexCoord2fARB, (target, s, t), (F, "glMultiTexCoord2f(0x%x, %f, %f);\n", target, s, t));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2fARB)(GLenum target, GLfloat s, GLfloat t)
+{
+ DISPATCH(MultiTexCoord2fARB, (target, s, t), (F, "glMultiTexCoord2fARB(0x%x, %f, %f);\n", target, s, t));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2fv)(GLenum target, const GLfloat * v)
+{
+ DISPATCH(MultiTexCoord2fvARB, (target, v), (F, "glMultiTexCoord2fv(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2fvARB)(GLenum target, const GLfloat * v)
+{
+ DISPATCH(MultiTexCoord2fvARB, (target, v), (F, "glMultiTexCoord2fvARB(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2i)(GLenum target, GLint s, GLint t)
+{
+ DISPATCH(MultiTexCoord2iARB, (target, s, t), (F, "glMultiTexCoord2i(0x%x, %d, %d);\n", target, s, t));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2iARB)(GLenum target, GLint s, GLint t)
+{
+ DISPATCH(MultiTexCoord2iARB, (target, s, t), (F, "glMultiTexCoord2iARB(0x%x, %d, %d);\n", target, s, t));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2iv)(GLenum target, const GLint * v)
+{
+ DISPATCH(MultiTexCoord2ivARB, (target, v), (F, "glMultiTexCoord2iv(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2ivARB)(GLenum target, const GLint * v)
+{
+ DISPATCH(MultiTexCoord2ivARB, (target, v), (F, "glMultiTexCoord2ivARB(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2s)(GLenum target, GLshort s, GLshort t)
+{
+ DISPATCH(MultiTexCoord2sARB, (target, s, t), (F, "glMultiTexCoord2s(0x%x, %d, %d);\n", target, s, t));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2sARB)(GLenum target, GLshort s, GLshort t)
+{
+ DISPATCH(MultiTexCoord2sARB, (target, s, t), (F, "glMultiTexCoord2sARB(0x%x, %d, %d);\n", target, s, t));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2sv)(GLenum target, const GLshort * v)
+{
+ DISPATCH(MultiTexCoord2svARB, (target, v), (F, "glMultiTexCoord2sv(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2svARB)(GLenum target, const GLshort * v)
+{
+ DISPATCH(MultiTexCoord2svARB, (target, v), (F, "glMultiTexCoord2svARB(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3d)(GLenum target, GLdouble s, GLdouble t, GLdouble r)
+{
+ DISPATCH(MultiTexCoord3dARB, (target, s, t, r), (F, "glMultiTexCoord3d(0x%x, %f, %f, %f);\n", target, s, t, r));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3dARB)(GLenum target, GLdouble s, GLdouble t, GLdouble r)
+{
+ DISPATCH(MultiTexCoord3dARB, (target, s, t, r), (F, "glMultiTexCoord3dARB(0x%x, %f, %f, %f);\n", target, s, t, r));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3dv)(GLenum target, const GLdouble * v)
+{
+ DISPATCH(MultiTexCoord3dvARB, (target, v), (F, "glMultiTexCoord3dv(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3dvARB)(GLenum target, const GLdouble * v)
+{
+ DISPATCH(MultiTexCoord3dvARB, (target, v), (F, "glMultiTexCoord3dvARB(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3f)(GLenum target, GLfloat s, GLfloat t, GLfloat r)
+{
+ DISPATCH(MultiTexCoord3fARB, (target, s, t, r), (F, "glMultiTexCoord3f(0x%x, %f, %f, %f);\n", target, s, t, r));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3fARB)(GLenum target, GLfloat s, GLfloat t, GLfloat r)
+{
+ DISPATCH(MultiTexCoord3fARB, (target, s, t, r), (F, "glMultiTexCoord3fARB(0x%x, %f, %f, %f);\n", target, s, t, r));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3fv)(GLenum target, const GLfloat * v)
+{
+ DISPATCH(MultiTexCoord3fvARB, (target, v), (F, "glMultiTexCoord3fv(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3fvARB)(GLenum target, const GLfloat * v)
+{
+ DISPATCH(MultiTexCoord3fvARB, (target, v), (F, "glMultiTexCoord3fvARB(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3i)(GLenum target, GLint s, GLint t, GLint r)
+{
+ DISPATCH(MultiTexCoord3iARB, (target, s, t, r), (F, "glMultiTexCoord3i(0x%x, %d, %d, %d);\n", target, s, t, r));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3iARB)(GLenum target, GLint s, GLint t, GLint r)
+{
+ DISPATCH(MultiTexCoord3iARB, (target, s, t, r), (F, "glMultiTexCoord3iARB(0x%x, %d, %d, %d);\n", target, s, t, r));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3iv)(GLenum target, const GLint * v)
+{
+ DISPATCH(MultiTexCoord3ivARB, (target, v), (F, "glMultiTexCoord3iv(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3ivARB)(GLenum target, const GLint * v)
+{
+ DISPATCH(MultiTexCoord3ivARB, (target, v), (F, "glMultiTexCoord3ivARB(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3s)(GLenum target, GLshort s, GLshort t, GLshort r)
+{
+ DISPATCH(MultiTexCoord3sARB, (target, s, t, r), (F, "glMultiTexCoord3s(0x%x, %d, %d, %d);\n", target, s, t, r));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3sARB)(GLenum target, GLshort s, GLshort t, GLshort r)
+{
+ DISPATCH(MultiTexCoord3sARB, (target, s, t, r), (F, "glMultiTexCoord3sARB(0x%x, %d, %d, %d);\n", target, s, t, r));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3sv)(GLenum target, const GLshort * v)
+{
+ DISPATCH(MultiTexCoord3svARB, (target, v), (F, "glMultiTexCoord3sv(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3svARB)(GLenum target, const GLshort * v)
+{
+ DISPATCH(MultiTexCoord3svARB, (target, v), (F, "glMultiTexCoord3svARB(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4d)(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q)
+{
+ DISPATCH(MultiTexCoord4dARB, (target, s, t, r, q), (F, "glMultiTexCoord4d(0x%x, %f, %f, %f, %f);\n", target, s, t, r, q));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4dARB)(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q)
+{
+ DISPATCH(MultiTexCoord4dARB, (target, s, t, r, q), (F, "glMultiTexCoord4dARB(0x%x, %f, %f, %f, %f);\n", target, s, t, r, q));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4dv)(GLenum target, const GLdouble * v)
+{
+ DISPATCH(MultiTexCoord4dvARB, (target, v), (F, "glMultiTexCoord4dv(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4dvARB)(GLenum target, const GLdouble * v)
+{
+ DISPATCH(MultiTexCoord4dvARB, (target, v), (F, "glMultiTexCoord4dvARB(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4f)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
+{
+ DISPATCH(MultiTexCoord4fARB, (target, s, t, r, q), (F, "glMultiTexCoord4f(0x%x, %f, %f, %f, %f);\n", target, s, t, r, q));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4fARB)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
+{
+ DISPATCH(MultiTexCoord4fARB, (target, s, t, r, q), (F, "glMultiTexCoord4fARB(0x%x, %f, %f, %f, %f);\n", target, s, t, r, q));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4fv)(GLenum target, const GLfloat * v)
+{
+ DISPATCH(MultiTexCoord4fvARB, (target, v), (F, "glMultiTexCoord4fv(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4fvARB)(GLenum target, const GLfloat * v)
+{
+ DISPATCH(MultiTexCoord4fvARB, (target, v), (F, "glMultiTexCoord4fvARB(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4i)(GLenum target, GLint s, GLint t, GLint r, GLint q)
+{
+ DISPATCH(MultiTexCoord4iARB, (target, s, t, r, q), (F, "glMultiTexCoord4i(0x%x, %d, %d, %d, %d);\n", target, s, t, r, q));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4iARB)(GLenum target, GLint s, GLint t, GLint r, GLint q)
+{
+ DISPATCH(MultiTexCoord4iARB, (target, s, t, r, q), (F, "glMultiTexCoord4iARB(0x%x, %d, %d, %d, %d);\n", target, s, t, r, q));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4iv)(GLenum target, const GLint * v)
+{
+ DISPATCH(MultiTexCoord4ivARB, (target, v), (F, "glMultiTexCoord4iv(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4ivARB)(GLenum target, const GLint * v)
+{
+ DISPATCH(MultiTexCoord4ivARB, (target, v), (F, "glMultiTexCoord4ivARB(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4s)(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q)
+{
+ DISPATCH(MultiTexCoord4sARB, (target, s, t, r, q), (F, "glMultiTexCoord4s(0x%x, %d, %d, %d, %d);\n", target, s, t, r, q));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4sARB)(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q)
+{
+ DISPATCH(MultiTexCoord4sARB, (target, s, t, r, q), (F, "glMultiTexCoord4sARB(0x%x, %d, %d, %d, %d);\n", target, s, t, r, q));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4sv)(GLenum target, const GLshort * v)
+{
+ DISPATCH(MultiTexCoord4svARB, (target, v), (F, "glMultiTexCoord4sv(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4svARB)(GLenum target, const GLshort * v)
+{
+ DISPATCH(MultiTexCoord4svARB, (target, v), (F, "glMultiTexCoord4svARB(0x%x, %p);\n", target, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LoadTransposeMatrixf)(const GLfloat * m)
+{
+ DISPATCH(LoadTransposeMatrixfARB, (m), (F, "glLoadTransposeMatrixf(%p);\n", (const void *) m));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LoadTransposeMatrixfARB)(const GLfloat * m)
+{
+ DISPATCH(LoadTransposeMatrixfARB, (m), (F, "glLoadTransposeMatrixfARB(%p);\n", (const void *) m));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LoadTransposeMatrixd)(const GLdouble * m)
+{
+ DISPATCH(LoadTransposeMatrixdARB, (m), (F, "glLoadTransposeMatrixd(%p);\n", (const void *) m));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LoadTransposeMatrixdARB)(const GLdouble * m)
+{
+ DISPATCH(LoadTransposeMatrixdARB, (m), (F, "glLoadTransposeMatrixdARB(%p);\n", (const void *) m));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultTransposeMatrixf)(const GLfloat * m)
+{
+ DISPATCH(MultTransposeMatrixfARB, (m), (F, "glMultTransposeMatrixf(%p);\n", (const void *) m));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultTransposeMatrixfARB)(const GLfloat * m)
+{
+ DISPATCH(MultTransposeMatrixfARB, (m), (F, "glMultTransposeMatrixfARB(%p);\n", (const void *) m));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultTransposeMatrixd)(const GLdouble * m)
+{
+ DISPATCH(MultTransposeMatrixdARB, (m), (F, "glMultTransposeMatrixd(%p);\n", (const void *) m));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultTransposeMatrixdARB)(const GLdouble * m)
+{
+ DISPATCH(MultTransposeMatrixdARB, (m), (F, "glMultTransposeMatrixdARB(%p);\n", (const void *) m));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SampleCoverage)(GLclampf value, GLboolean invert)
+{
+ DISPATCH(SampleCoverageARB, (value, invert), (F, "glSampleCoverage(%f, %d);\n", value, invert));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SampleCoverageARB)(GLclampf value, GLboolean invert)
+{
+ DISPATCH(SampleCoverageARB, (value, invert), (F, "glSampleCoverageARB(%f, %d);\n", value, invert));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DrawBuffersARB)(GLsizei n, const GLenum * bufs)
+{
+ DISPATCH(DrawBuffersARB, (n, bufs), (F, "glDrawBuffersARB(%d, %p);\n", n, (const void *) bufs));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DrawBuffersATI)(GLsizei n, const GLenum * bufs)
+{
+ DISPATCH(DrawBuffersARB, (n, bufs), (F, "glDrawBuffersATI(%d, %p);\n", n, (const void *) bufs));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PolygonOffsetEXT)(GLfloat factor, GLfloat bias)
+{
+ DISPATCH(PolygonOffsetEXT, (factor, bias), (F, "glPolygonOffsetEXT(%f, %f);\n", factor, bias));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetTexFilterFuncSGIS)(GLenum target, GLenum filter, GLfloat * weights)
+{
+ DISPATCH(GetTexFilterFuncSGIS, (target, filter, weights), (F, "glGetTexFilterFuncSGIS(0x%x, 0x%x, %p);\n", target, filter, (const void *) weights));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexFilterFuncSGIS)(GLenum target, GLenum filter, GLsizei n, const GLfloat * weights)
+{
+ DISPATCH(TexFilterFuncSGIS, (target, filter, n, weights), (F, "glTexFilterFuncSGIS(0x%x, 0x%x, %d, %p);\n", target, filter, n, (const void *) weights));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetHistogramEXT)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values)
+{
+ DISPATCH(GetHistogramEXT, (target, reset, format, type, values), (F, "glGetHistogramEXT(0x%x, %d, 0x%x, 0x%x, %p);\n", target, reset, format, type, (const void *) values));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetHistogramParameterfvEXT)(GLenum target, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetHistogramParameterfvEXT, (target, pname, params), (F, "glGetHistogramParameterfvEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetHistogramParameterivEXT)(GLenum target, GLenum pname, GLint * params)
+{
+ DISPATCH(GetHistogramParameterivEXT, (target, pname, params), (F, "glGetHistogramParameterivEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetMinmaxEXT)(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid * values)
+{
+ DISPATCH(GetMinmaxEXT, (target, reset, format, type, values), (F, "glGetMinmaxEXT(0x%x, %d, 0x%x, 0x%x, %p);\n", target, reset, format, type, (const void *) values));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetMinmaxParameterfvEXT)(GLenum target, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetMinmaxParameterfvEXT, (target, pname, params), (F, "glGetMinmaxParameterfvEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetMinmaxParameterivEXT)(GLenum target, GLenum pname, GLint * params)
+{
+ DISPATCH(GetMinmaxParameterivEXT, (target, pname, params), (F, "glGetMinmaxParameterivEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetConvolutionFilterEXT)(GLenum target, GLenum format, GLenum type, GLvoid * image)
+{
+ DISPATCH(GetConvolutionFilterEXT, (target, format, type, image), (F, "glGetConvolutionFilterEXT(0x%x, 0x%x, 0x%x, %p);\n", target, format, type, (const void *) image));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetConvolutionParameterfvEXT)(GLenum target, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetConvolutionParameterfvEXT, (target, pname, params), (F, "glGetConvolutionParameterfvEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetConvolutionParameterivEXT)(GLenum target, GLenum pname, GLint * params)
+{
+ DISPATCH(GetConvolutionParameterivEXT, (target, pname, params), (F, "glGetConvolutionParameterivEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetSeparableFilterEXT)(GLenum target, GLenum format, GLenum type, GLvoid * row, GLvoid * column, GLvoid * span)
+{
+ DISPATCH(GetSeparableFilterEXT, (target, format, type, row, column, span), (F, "glGetSeparableFilterEXT(0x%x, 0x%x, 0x%x, %p, %p, %p);\n", target, format, type, (const void *) row, (const void *) column, (const void *) span));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetColorTableSGI)(GLenum target, GLenum format, GLenum type, GLvoid * table)
+{
+ DISPATCH(GetColorTableSGI, (target, format, type, table), (F, "glGetColorTableSGI(0x%x, 0x%x, 0x%x, %p);\n", target, format, type, (const void *) table));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetColorTableParameterfvSGI)(GLenum target, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetColorTableParameterfvSGI, (target, pname, params), (F, "glGetColorTableParameterfvSGI(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetColorTableParameterivSGI)(GLenum target, GLenum pname, GLint * params)
+{
+ DISPATCH(GetColorTableParameterivSGI, (target, pname, params), (F, "glGetColorTableParameterivSGI(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PixelTexGenSGIX)(GLenum mode)
+{
+ DISPATCH(PixelTexGenSGIX, (mode), (F, "glPixelTexGenSGIX(0x%x);\n", mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PixelTexGenParameteriSGIS)(GLenum pname, GLint param)
+{
+ DISPATCH(PixelTexGenParameteriSGIS, (pname, param), (F, "glPixelTexGenParameteriSGIS(0x%x, %d);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PixelTexGenParameterivSGIS)(GLenum pname, const GLint * params)
+{
+ DISPATCH(PixelTexGenParameterivSGIS, (pname, params), (F, "glPixelTexGenParameterivSGIS(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PixelTexGenParameterfSGIS)(GLenum pname, GLfloat param)
+{
+ DISPATCH(PixelTexGenParameterfSGIS, (pname, param), (F, "glPixelTexGenParameterfSGIS(0x%x, %f);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PixelTexGenParameterfvSGIS)(GLenum pname, const GLfloat * params)
+{
+ DISPATCH(PixelTexGenParameterfvSGIS, (pname, params), (F, "glPixelTexGenParameterfvSGIS(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetPixelTexGenParameterivSGIS)(GLenum pname, GLint * params)
+{
+ DISPATCH(GetPixelTexGenParameterivSGIS, (pname, params), (F, "glGetPixelTexGenParameterivSGIS(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetPixelTexGenParameterfvSGIS)(GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetPixelTexGenParameterfvSGIS, (pname, params), (F, "glGetPixelTexGenParameterfvSGIS(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexImage4DSGIS)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid * pixels)
+{
+ DISPATCH(TexImage4DSGIS, (target, level, internalformat, width, height, depth, size4d, border, format, type, pixels), (F, "glTexImage4DSGIS(0x%x, %d, 0x%x, %d, %d, %d, %d, %d, 0x%x, 0x%x, %p);\n", target, level, internalformat, width, height, depth, size4d, border, format, type, (const void *) pixels));
+}
+
+KEYWORD1 void KEYWORD2 NAME(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)
+{
+ DISPATCH(TexSubImage4DSGIS, (target, level, xoffset, yoffset, zoffset, woffset, width, height, depth, size4d, format, type, pixels), (F, "glTexSubImage4DSGIS(0x%x, %d, %d, %d, %d, %d, %d, %d, %d, %d, 0x%x, 0x%x, %p);\n", target, level, xoffset, yoffset, zoffset, woffset, width, height, depth, size4d, format, type, (const void *) pixels));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(AreTexturesResidentEXT)(GLsizei n, const GLuint * textures, GLboolean * residences)
+{
+ RETURN_DISPATCH(AreTexturesResidentEXT, (n, textures, residences), (F, "glAreTexturesResidentEXT(%d, %p, %p);\n", n, (const void *) textures, (const void *) residences));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GenTexturesEXT)(GLsizei n, GLuint * textures)
+{
+ DISPATCH(GenTexturesEXT, (n, textures), (F, "glGenTexturesEXT(%d, %p);\n", n, (const void *) textures));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(IsTextureEXT)(GLuint texture)
+{
+ RETURN_DISPATCH(IsTextureEXT, (texture), (F, "glIsTextureEXT(%d);\n", texture));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DetailTexFuncSGIS)(GLenum target, GLsizei n, const GLfloat * points)
+{
+ DISPATCH(DetailTexFuncSGIS, (target, n, points), (F, "glDetailTexFuncSGIS(0x%x, %d, %p);\n", target, n, (const void *) points));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetDetailTexFuncSGIS)(GLenum target, GLfloat * points)
+{
+ DISPATCH(GetDetailTexFuncSGIS, (target, points), (F, "glGetDetailTexFuncSGIS(0x%x, %p);\n", target, (const void *) points));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SharpenTexFuncSGIS)(GLenum target, GLsizei n, const GLfloat * points)
+{
+ DISPATCH(SharpenTexFuncSGIS, (target, n, points), (F, "glSharpenTexFuncSGIS(0x%x, %d, %p);\n", target, n, (const void *) points));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetSharpenTexFuncSGIS)(GLenum target, GLfloat * points)
+{
+ DISPATCH(GetSharpenTexFuncSGIS, (target, points), (F, "glGetSharpenTexFuncSGIS(0x%x, %p);\n", target, (const void *) points));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SampleMaskSGIS)(GLclampf value, GLboolean invert)
+{
+ DISPATCH(SampleMaskSGIS, (value, invert), (F, "glSampleMaskSGIS(%f, %d);\n", value, invert));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SampleMaskEXT)(GLclampf value, GLboolean invert)
+{
+ DISPATCH(SampleMaskSGIS, (value, invert), (F, "glSampleMaskEXT(%f, %d);\n", value, invert));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SamplePatternSGIS)(GLenum pattern)
+{
+ DISPATCH(SamplePatternSGIS, (pattern), (F, "glSamplePatternSGIS(0x%x);\n", pattern));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SamplePatternEXT)(GLenum pattern)
+{
+ DISPATCH(SamplePatternSGIS, (pattern), (F, "glSamplePatternEXT(0x%x);\n", pattern));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ColorPointerEXT)(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer)
+{
+ DISPATCH(ColorPointerEXT, (size, type, stride, count, pointer), (F, "glColorPointerEXT(%d, 0x%x, %d, %d, %p);\n", size, type, stride, count, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EdgeFlagPointerEXT)(GLsizei stride, GLsizei count, const GLboolean * pointer)
+{
+ DISPATCH(EdgeFlagPointerEXT, (stride, count, pointer), (F, "glEdgeFlagPointerEXT(%d, %d, %p);\n", stride, count, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(IndexPointerEXT)(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer)
+{
+ DISPATCH(IndexPointerEXT, (type, stride, count, pointer), (F, "glIndexPointerEXT(0x%x, %d, %d, %p);\n", type, stride, count, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(NormalPointerEXT)(GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer)
+{
+ DISPATCH(NormalPointerEXT, (type, stride, count, pointer), (F, "glNormalPointerEXT(0x%x, %d, %d, %p);\n", type, stride, count, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TexCoordPointerEXT)(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer)
+{
+ DISPATCH(TexCoordPointerEXT, (size, type, stride, count, pointer), (F, "glTexCoordPointerEXT(%d, 0x%x, %d, %d, %p);\n", size, type, stride, count, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexPointerEXT)(GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid * pointer)
+{
+ DISPATCH(VertexPointerEXT, (size, type, stride, count, pointer), (F, "glVertexPointerEXT(%d, 0x%x, %d, %d, %p);\n", size, type, stride, count, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SpriteParameterfSGIX)(GLenum pname, GLfloat param)
+{
+ DISPATCH(SpriteParameterfSGIX, (pname, param), (F, "glSpriteParameterfSGIX(0x%x, %f);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SpriteParameterfvSGIX)(GLenum pname, const GLfloat * params)
+{
+ DISPATCH(SpriteParameterfvSGIX, (pname, params), (F, "glSpriteParameterfvSGIX(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SpriteParameteriSGIX)(GLenum pname, GLint param)
+{
+ DISPATCH(SpriteParameteriSGIX, (pname, param), (F, "glSpriteParameteriSGIX(0x%x, %d);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SpriteParameterivSGIX)(GLenum pname, const GLint * params)
+{
+ DISPATCH(SpriteParameterivSGIX, (pname, params), (F, "glSpriteParameterivSGIX(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PointParameterf)(GLenum pname, GLfloat param)
+{
+ DISPATCH(PointParameterfEXT, (pname, param), (F, "glPointParameterf(0x%x, %f);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PointParameterfARB)(GLenum pname, GLfloat param)
+{
+ DISPATCH(PointParameterfEXT, (pname, param), (F, "glPointParameterfARB(0x%x, %f);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PointParameterfEXT)(GLenum pname, GLfloat param)
+{
+ DISPATCH(PointParameterfEXT, (pname, param), (F, "glPointParameterfEXT(0x%x, %f);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PointParameterfSGIS)(GLenum pname, GLfloat param)
+{
+ DISPATCH(PointParameterfEXT, (pname, param), (F, "glPointParameterfSGIS(0x%x, %f);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PointParameterfv)(GLenum pname, const GLfloat * params)
+{
+ DISPATCH(PointParameterfvEXT, (pname, params), (F, "glPointParameterfv(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PointParameterfvARB)(GLenum pname, const GLfloat * params)
+{
+ DISPATCH(PointParameterfvEXT, (pname, params), (F, "glPointParameterfvARB(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PointParameterfvEXT)(GLenum pname, const GLfloat * params)
+{
+ DISPATCH(PointParameterfvEXT, (pname, params), (F, "glPointParameterfvEXT(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PointParameterfvSGIS)(GLenum pname, const GLfloat * params)
+{
+ DISPATCH(PointParameterfvEXT, (pname, params), (F, "glPointParameterfvSGIS(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 GLint KEYWORD2 NAME(GetInstrumentsSGIX)(void)
+{
+ RETURN_DISPATCH(GetInstrumentsSGIX, (), (F, "glGetInstrumentsSGIX();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(InstrumentsBufferSGIX)(GLsizei size, GLint * buffer)
+{
+ DISPATCH(InstrumentsBufferSGIX, (size, buffer), (F, "glInstrumentsBufferSGIX(%d, %p);\n", size, (const void *) buffer));
+}
+
+KEYWORD1 GLint KEYWORD2 NAME(PollInstrumentsSGIX)(GLint * marker_p)
+{
+ RETURN_DISPATCH(PollInstrumentsSGIX, (marker_p), (F, "glPollInstrumentsSGIX(%p);\n", (const void *) marker_p));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ReadInstrumentsSGIX)(GLint marker)
+{
+ DISPATCH(ReadInstrumentsSGIX, (marker), (F, "glReadInstrumentsSGIX(%d);\n", marker));
+}
+
+KEYWORD1 void KEYWORD2 NAME(StartInstrumentsSGIX)(void)
+{
+ DISPATCH(StartInstrumentsSGIX, (), (F, "glStartInstrumentsSGIX();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(StopInstrumentsSGIX)(GLint marker)
+{
+ DISPATCH(StopInstrumentsSGIX, (marker), (F, "glStopInstrumentsSGIX(%d);\n", marker));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FrameZoomSGIX)(GLint factor)
+{
+ DISPATCH(FrameZoomSGIX, (factor), (F, "glFrameZoomSGIX(%d);\n", factor));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TagSampleBufferSGIX)(void)
+{
+ DISPATCH(TagSampleBufferSGIX, (), (F, "glTagSampleBufferSGIX();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ReferencePlaneSGIX)(const GLdouble * equation)
+{
+ DISPATCH(ReferencePlaneSGIX, (equation), (F, "glReferencePlaneSGIX(%p);\n", (const void *) equation));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FlushRasterSGIX)(void)
+{
+ DISPATCH(FlushRasterSGIX, (), (F, "glFlushRasterSGIX();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetListParameterfvSGIX)(GLuint list, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetListParameterfvSGIX, (list, pname, params), (F, "glGetListParameterfvSGIX(%d, 0x%x, %p);\n", list, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetListParameterivSGIX)(GLuint list, GLenum pname, GLint * params)
+{
+ DISPATCH(GetListParameterivSGIX, (list, pname, params), (F, "glGetListParameterivSGIX(%d, 0x%x, %p);\n", list, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ListParameterfSGIX)(GLuint list, GLenum pname, GLfloat param)
+{
+ DISPATCH(ListParameterfSGIX, (list, pname, param), (F, "glListParameterfSGIX(%d, 0x%x, %f);\n", list, pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ListParameterfvSGIX)(GLuint list, GLenum pname, const GLfloat * params)
+{
+ DISPATCH(ListParameterfvSGIX, (list, pname, params), (F, "glListParameterfvSGIX(%d, 0x%x, %p);\n", list, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ListParameteriSGIX)(GLuint list, GLenum pname, GLint param)
+{
+ DISPATCH(ListParameteriSGIX, (list, pname, param), (F, "glListParameteriSGIX(%d, 0x%x, %d);\n", list, pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ListParameterivSGIX)(GLuint list, GLenum pname, const GLint * params)
+{
+ DISPATCH(ListParameterivSGIX, (list, pname, params), (F, "glListParameterivSGIX(%d, 0x%x, %p);\n", list, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FragmentColorMaterialSGIX)(GLenum face, GLenum mode)
+{
+ DISPATCH(FragmentColorMaterialSGIX, (face, mode), (F, "glFragmentColorMaterialSGIX(0x%x, 0x%x);\n", face, mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FragmentLightfSGIX)(GLenum light, GLenum pname, GLfloat param)
+{
+ DISPATCH(FragmentLightfSGIX, (light, pname, param), (F, "glFragmentLightfSGIX(0x%x, 0x%x, %f);\n", light, pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FragmentLightfvSGIX)(GLenum light, GLenum pname, const GLfloat * params)
+{
+ DISPATCH(FragmentLightfvSGIX, (light, pname, params), (F, "glFragmentLightfvSGIX(0x%x, 0x%x, %p);\n", light, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FragmentLightiSGIX)(GLenum light, GLenum pname, GLint param)
+{
+ DISPATCH(FragmentLightiSGIX, (light, pname, param), (F, "glFragmentLightiSGIX(0x%x, 0x%x, %d);\n", light, pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FragmentLightivSGIX)(GLenum light, GLenum pname, const GLint * params)
+{
+ DISPATCH(FragmentLightivSGIX, (light, pname, params), (F, "glFragmentLightivSGIX(0x%x, 0x%x, %p);\n", light, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FragmentLightModelfSGIX)(GLenum pname, GLfloat param)
+{
+ DISPATCH(FragmentLightModelfSGIX, (pname, param), (F, "glFragmentLightModelfSGIX(0x%x, %f);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FragmentLightModelfvSGIX)(GLenum pname, const GLfloat * params)
+{
+ DISPATCH(FragmentLightModelfvSGIX, (pname, params), (F, "glFragmentLightModelfvSGIX(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FragmentLightModeliSGIX)(GLenum pname, GLint param)
+{
+ DISPATCH(FragmentLightModeliSGIX, (pname, param), (F, "glFragmentLightModeliSGIX(0x%x, %d);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FragmentLightModelivSGIX)(GLenum pname, const GLint * params)
+{
+ DISPATCH(FragmentLightModelivSGIX, (pname, params), (F, "glFragmentLightModelivSGIX(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FragmentMaterialfSGIX)(GLenum face, GLenum pname, GLfloat param)
+{
+ DISPATCH(FragmentMaterialfSGIX, (face, pname, param), (F, "glFragmentMaterialfSGIX(0x%x, 0x%x, %f);\n", face, pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FragmentMaterialfvSGIX)(GLenum face, GLenum pname, const GLfloat * params)
+{
+ DISPATCH(FragmentMaterialfvSGIX, (face, pname, params), (F, "glFragmentMaterialfvSGIX(0x%x, 0x%x, %p);\n", face, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FragmentMaterialiSGIX)(GLenum face, GLenum pname, GLint param)
+{
+ DISPATCH(FragmentMaterialiSGIX, (face, pname, param), (F, "glFragmentMaterialiSGIX(0x%x, 0x%x, %d);\n", face, pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FragmentMaterialivSGIX)(GLenum face, GLenum pname, const GLint * params)
+{
+ DISPATCH(FragmentMaterialivSGIX, (face, pname, params), (F, "glFragmentMaterialivSGIX(0x%x, 0x%x, %p);\n", face, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetFragmentLightfvSGIX)(GLenum light, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetFragmentLightfvSGIX, (light, pname, params), (F, "glGetFragmentLightfvSGIX(0x%x, 0x%x, %p);\n", light, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetFragmentLightivSGIX)(GLenum light, GLenum pname, GLint * params)
+{
+ DISPATCH(GetFragmentLightivSGIX, (light, pname, params), (F, "glGetFragmentLightivSGIX(0x%x, 0x%x, %p);\n", light, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetFragmentMaterialfvSGIX)(GLenum face, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetFragmentMaterialfvSGIX, (face, pname, params), (F, "glGetFragmentMaterialfvSGIX(0x%x, 0x%x, %p);\n", face, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetFragmentMaterialivSGIX)(GLenum face, GLenum pname, GLint * params)
+{
+ DISPATCH(GetFragmentMaterialivSGIX, (face, pname, params), (F, "glGetFragmentMaterialivSGIX(0x%x, 0x%x, %p);\n", face, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LightEnviSGIX)(GLenum pname, GLint param)
+{
+ DISPATCH(LightEnviSGIX, (pname, param), (F, "glLightEnviSGIX(0x%x, %d);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexWeightfEXT)(GLfloat weight)
+{
+ DISPATCH(VertexWeightfEXT, (weight), (F, "glVertexWeightfEXT(%f);\n", weight));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexWeightfvEXT)(const GLfloat * weight)
+{
+ DISPATCH(VertexWeightfvEXT, (weight), (F, "glVertexWeightfvEXT(%p);\n", (const void *) weight));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexWeightPointerEXT)(GLsizei size, GLenum type, GLsizei stride, const GLvoid * pointer)
+{
+ DISPATCH(VertexWeightPointerEXT, (size, type, stride, pointer), (F, "glVertexWeightPointerEXT(%d, 0x%x, %d, %p);\n", size, type, stride, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FlushVertexArrayRangeNV)(void)
+{
+ DISPATCH(FlushVertexArrayRangeNV, (), (F, "glFlushVertexArrayRangeNV();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexArrayRangeNV)(GLsizei length, const GLvoid * pointer)
+{
+ DISPATCH(VertexArrayRangeNV, (length, pointer), (F, "glVertexArrayRangeNV(%d, %p);\n", length, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CombinerParameterfvNV)(GLenum pname, const GLfloat * params)
+{
+ DISPATCH(CombinerParameterfvNV, (pname, params), (F, "glCombinerParameterfvNV(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CombinerParameterfNV)(GLenum pname, GLfloat param)
+{
+ DISPATCH(CombinerParameterfNV, (pname, param), (F, "glCombinerParameterfNV(0x%x, %f);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CombinerParameterivNV)(GLenum pname, const GLint * params)
+{
+ DISPATCH(CombinerParameterivNV, (pname, params), (F, "glCombinerParameterivNV(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CombinerParameteriNV)(GLenum pname, GLint param)
+{
+ DISPATCH(CombinerParameteriNV, (pname, param), (F, "glCombinerParameteriNV(0x%x, %d);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CombinerInputNV)(GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage)
+{
+ DISPATCH(CombinerInputNV, (stage, portion, variable, input, mapping, componentUsage), (F, "glCombinerInputNV(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x);\n", stage, portion, variable, input, mapping, componentUsage));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CombinerOutputNV)(GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum)
+{
+ DISPATCH(CombinerOutputNV, (stage, portion, abOutput, cdOutput, sumOutput, scale, bias, abDotProduct, cdDotProduct, muxSum), (F, "glCombinerOutputNV(0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, 0x%x, %d, %d, %d);\n", stage, portion, abOutput, cdOutput, sumOutput, scale, bias, abDotProduct, cdDotProduct, muxSum));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FinalCombinerInputNV)(GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage)
+{
+ DISPATCH(FinalCombinerInputNV, (variable, input, mapping, componentUsage), (F, "glFinalCombinerInputNV(0x%x, 0x%x, 0x%x, 0x%x);\n", variable, input, mapping, componentUsage));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetCombinerInputParameterfvNV)(GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetCombinerInputParameterfvNV, (stage, portion, variable, pname, params), (F, "glGetCombinerInputParameterfvNV(0x%x, 0x%x, 0x%x, 0x%x, %p);\n", stage, portion, variable, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetCombinerInputParameterivNV)(GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint * params)
+{
+ DISPATCH(GetCombinerInputParameterivNV, (stage, portion, variable, pname, params), (F, "glGetCombinerInputParameterivNV(0x%x, 0x%x, 0x%x, 0x%x, %p);\n", stage, portion, variable, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetCombinerOutputParameterfvNV)(GLenum stage, GLenum portion, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetCombinerOutputParameterfvNV, (stage, portion, pname, params), (F, "glGetCombinerOutputParameterfvNV(0x%x, 0x%x, 0x%x, %p);\n", stage, portion, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetCombinerOutputParameterivNV)(GLenum stage, GLenum portion, GLenum pname, GLint * params)
+{
+ DISPATCH(GetCombinerOutputParameterivNV, (stage, portion, pname, params), (F, "glGetCombinerOutputParameterivNV(0x%x, 0x%x, 0x%x, %p);\n", stage, portion, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetFinalCombinerInputParameterfvNV)(GLenum variable, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetFinalCombinerInputParameterfvNV, (variable, pname, params), (F, "glGetFinalCombinerInputParameterfvNV(0x%x, 0x%x, %p);\n", variable, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetFinalCombinerInputParameterivNV)(GLenum variable, GLenum pname, GLint * params)
+{
+ DISPATCH(GetFinalCombinerInputParameterivNV, (variable, pname, params), (F, "glGetFinalCombinerInputParameterivNV(0x%x, 0x%x, %p);\n", variable, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ResizeBuffersMESA)(void)
+{
+ DISPATCH(ResizeBuffersMESA, (), (F, "glResizeBuffersMESA();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2d)(GLdouble x, GLdouble y)
+{
+ DISPATCH(WindowPos2dMESA, (x, y), (F, "glWindowPos2d(%f, %f);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2dARB)(GLdouble x, GLdouble y)
+{
+ DISPATCH(WindowPos2dMESA, (x, y), (F, "glWindowPos2dARB(%f, %f);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2dMESA)(GLdouble x, GLdouble y)
+{
+ DISPATCH(WindowPos2dMESA, (x, y), (F, "glWindowPos2dMESA(%f, %f);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2dv)(const GLdouble * v)
+{
+ DISPATCH(WindowPos2dvMESA, (v), (F, "glWindowPos2dv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2dvARB)(const GLdouble * v)
+{
+ DISPATCH(WindowPos2dvMESA, (v), (F, "glWindowPos2dvARB(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2dvMESA)(const GLdouble * v)
+{
+ DISPATCH(WindowPos2dvMESA, (v), (F, "glWindowPos2dvMESA(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2f)(GLfloat x, GLfloat y)
+{
+ DISPATCH(WindowPos2fMESA, (x, y), (F, "glWindowPos2f(%f, %f);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2fARB)(GLfloat x, GLfloat y)
+{
+ DISPATCH(WindowPos2fMESA, (x, y), (F, "glWindowPos2fARB(%f, %f);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2fMESA)(GLfloat x, GLfloat y)
+{
+ DISPATCH(WindowPos2fMESA, (x, y), (F, "glWindowPos2fMESA(%f, %f);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2fv)(const GLfloat * v)
+{
+ DISPATCH(WindowPos2fvMESA, (v), (F, "glWindowPos2fv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2fvARB)(const GLfloat * v)
+{
+ DISPATCH(WindowPos2fvMESA, (v), (F, "glWindowPos2fvARB(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2fvMESA)(const GLfloat * v)
+{
+ DISPATCH(WindowPos2fvMESA, (v), (F, "glWindowPos2fvMESA(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2i)(GLint x, GLint y)
+{
+ DISPATCH(WindowPos2iMESA, (x, y), (F, "glWindowPos2i(%d, %d);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2iARB)(GLint x, GLint y)
+{
+ DISPATCH(WindowPos2iMESA, (x, y), (F, "glWindowPos2iARB(%d, %d);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2iMESA)(GLint x, GLint y)
+{
+ DISPATCH(WindowPos2iMESA, (x, y), (F, "glWindowPos2iMESA(%d, %d);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2iv)(const GLint * v)
+{
+ DISPATCH(WindowPos2ivMESA, (v), (F, "glWindowPos2iv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2ivARB)(const GLint * v)
+{
+ DISPATCH(WindowPos2ivMESA, (v), (F, "glWindowPos2ivARB(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2ivMESA)(const GLint * v)
+{
+ DISPATCH(WindowPos2ivMESA, (v), (F, "glWindowPos2ivMESA(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2s)(GLshort x, GLshort y)
+{
+ DISPATCH(WindowPos2sMESA, (x, y), (F, "glWindowPos2s(%d, %d);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2sARB)(GLshort x, GLshort y)
+{
+ DISPATCH(WindowPos2sMESA, (x, y), (F, "glWindowPos2sARB(%d, %d);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2sMESA)(GLshort x, GLshort y)
+{
+ DISPATCH(WindowPos2sMESA, (x, y), (F, "glWindowPos2sMESA(%d, %d);\n", x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2sv)(const GLshort * v)
+{
+ DISPATCH(WindowPos2svMESA, (v), (F, "glWindowPos2sv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2svARB)(const GLshort * v)
+{
+ DISPATCH(WindowPos2svMESA, (v), (F, "glWindowPos2svARB(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos2svMESA)(const GLshort * v)
+{
+ DISPATCH(WindowPos2svMESA, (v), (F, "glWindowPos2svMESA(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3d)(GLdouble x, GLdouble y, GLdouble z)
+{
+ DISPATCH(WindowPos3dMESA, (x, y, z), (F, "glWindowPos3d(%f, %f, %f);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3dARB)(GLdouble x, GLdouble y, GLdouble z)
+{
+ DISPATCH(WindowPos3dMESA, (x, y, z), (F, "glWindowPos3dARB(%f, %f, %f);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3dMESA)(GLdouble x, GLdouble y, GLdouble z)
+{
+ DISPATCH(WindowPos3dMESA, (x, y, z), (F, "glWindowPos3dMESA(%f, %f, %f);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3dv)(const GLdouble * v)
+{
+ DISPATCH(WindowPos3dvMESA, (v), (F, "glWindowPos3dv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3dvARB)(const GLdouble * v)
+{
+ DISPATCH(WindowPos3dvMESA, (v), (F, "glWindowPos3dvARB(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3dvMESA)(const GLdouble * v)
+{
+ DISPATCH(WindowPos3dvMESA, (v), (F, "glWindowPos3dvMESA(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3f)(GLfloat x, GLfloat y, GLfloat z)
+{
+ DISPATCH(WindowPos3fMESA, (x, y, z), (F, "glWindowPos3f(%f, %f, %f);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3fARB)(GLfloat x, GLfloat y, GLfloat z)
+{
+ DISPATCH(WindowPos3fMESA, (x, y, z), (F, "glWindowPos3fARB(%f, %f, %f);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3fMESA)(GLfloat x, GLfloat y, GLfloat z)
+{
+ DISPATCH(WindowPos3fMESA, (x, y, z), (F, "glWindowPos3fMESA(%f, %f, %f);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3fv)(const GLfloat * v)
+{
+ DISPATCH(WindowPos3fvMESA, (v), (F, "glWindowPos3fv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3fvARB)(const GLfloat * v)
+{
+ DISPATCH(WindowPos3fvMESA, (v), (F, "glWindowPos3fvARB(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3fvMESA)(const GLfloat * v)
+{
+ DISPATCH(WindowPos3fvMESA, (v), (F, "glWindowPos3fvMESA(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3i)(GLint x, GLint y, GLint z)
+{
+ DISPATCH(WindowPos3iMESA, (x, y, z), (F, "glWindowPos3i(%d, %d, %d);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3iARB)(GLint x, GLint y, GLint z)
+{
+ DISPATCH(WindowPos3iMESA, (x, y, z), (F, "glWindowPos3iARB(%d, %d, %d);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3iMESA)(GLint x, GLint y, GLint z)
+{
+ DISPATCH(WindowPos3iMESA, (x, y, z), (F, "glWindowPos3iMESA(%d, %d, %d);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3iv)(const GLint * v)
+{
+ DISPATCH(WindowPos3ivMESA, (v), (F, "glWindowPos3iv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3ivARB)(const GLint * v)
+{
+ DISPATCH(WindowPos3ivMESA, (v), (F, "glWindowPos3ivARB(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3ivMESA)(const GLint * v)
+{
+ DISPATCH(WindowPos3ivMESA, (v), (F, "glWindowPos3ivMESA(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3s)(GLshort x, GLshort y, GLshort z)
+{
+ DISPATCH(WindowPos3sMESA, (x, y, z), (F, "glWindowPos3s(%d, %d, %d);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3sARB)(GLshort x, GLshort y, GLshort z)
+{
+ DISPATCH(WindowPos3sMESA, (x, y, z), (F, "glWindowPos3sARB(%d, %d, %d);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3sMESA)(GLshort x, GLshort y, GLshort z)
+{
+ DISPATCH(WindowPos3sMESA, (x, y, z), (F, "glWindowPos3sMESA(%d, %d, %d);\n", x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3sv)(const GLshort * v)
+{
+ DISPATCH(WindowPos3svMESA, (v), (F, "glWindowPos3sv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3svARB)(const GLshort * v)
+{
+ DISPATCH(WindowPos3svMESA, (v), (F, "glWindowPos3svARB(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos3svMESA)(const GLshort * v)
+{
+ DISPATCH(WindowPos3svMESA, (v), (F, "glWindowPos3svMESA(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos4dMESA)(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ DISPATCH(WindowPos4dMESA, (x, y, z, w), (F, "glWindowPos4dMESA(%f, %f, %f, %f);\n", x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos4dvMESA)(const GLdouble * v)
+{
+ DISPATCH(WindowPos4dvMESA, (v), (F, "glWindowPos4dvMESA(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos4fMESA)(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ DISPATCH(WindowPos4fMESA, (x, y, z, w), (F, "glWindowPos4fMESA(%f, %f, %f, %f);\n", x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos4fvMESA)(const GLfloat * v)
+{
+ DISPATCH(WindowPos4fvMESA, (v), (F, "glWindowPos4fvMESA(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos4iMESA)(GLint x, GLint y, GLint z, GLint w)
+{
+ DISPATCH(WindowPos4iMESA, (x, y, z, w), (F, "glWindowPos4iMESA(%d, %d, %d, %d);\n", x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos4ivMESA)(const GLint * v)
+{
+ DISPATCH(WindowPos4ivMESA, (v), (F, "glWindowPos4ivMESA(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos4sMESA)(GLshort x, GLshort y, GLshort z, GLshort w)
+{
+ DISPATCH(WindowPos4sMESA, (x, y, z, w), (F, "glWindowPos4sMESA(%d, %d, %d, %d);\n", x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(WindowPos4svMESA)(const GLshort * v)
+{
+ DISPATCH(WindowPos4svMESA, (v), (F, "glWindowPos4svMESA(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BlendFuncSeparate)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)
+{
+ DISPATCH(BlendFuncSeparateEXT, (sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha), (F, "glBlendFuncSeparate(0x%x, 0x%x, 0x%x, 0x%x);\n", sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BlendFuncSeparateEXT)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)
+{
+ DISPATCH(BlendFuncSeparateEXT, (sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha), (F, "glBlendFuncSeparateEXT(0x%x, 0x%x, 0x%x, 0x%x);\n", sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BlendFuncSeparateINGR)(GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha)
+{
+ DISPATCH(BlendFuncSeparateEXT, (sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha), (F, "glBlendFuncSeparateINGR(0x%x, 0x%x, 0x%x, 0x%x);\n", sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha));
+}
+
+KEYWORD1 void KEYWORD2 NAME(IndexMaterialEXT)(GLenum face, GLenum mode)
+{
+ DISPATCH(IndexMaterialEXT, (face, mode), (F, "glIndexMaterialEXT(0x%x, 0x%x);\n", face, mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(IndexFuncEXT)(GLenum func, GLclampf ref)
+{
+ DISPATCH(IndexFuncEXT, (func, ref), (F, "glIndexFuncEXT(0x%x, %f);\n", func, ref));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LockArraysEXT)(GLint first, GLsizei count)
+{
+ DISPATCH(LockArraysEXT, (first, count), (F, "glLockArraysEXT(%d, %d);\n", first, count));
+}
+
+KEYWORD1 void KEYWORD2 NAME(UnlockArraysEXT)(void)
+{
+ DISPATCH(UnlockArraysEXT, (), (F, "glUnlockArraysEXT();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CullParameterdvEXT)(GLenum pname, GLdouble * params)
+{
+ DISPATCH(CullParameterdvEXT, (pname, params), (F, "glCullParameterdvEXT(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CullParameterfvEXT)(GLenum pname, GLfloat * params)
+{
+ DISPATCH(CullParameterfvEXT, (pname, params), (F, "glCullParameterfvEXT(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(HintPGI)(GLenum target, GLint mode)
+{
+ DISPATCH(HintPGI, (target, mode), (F, "glHintPGI(0x%x, %d);\n", target, mode));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FogCoordf)(GLfloat coord)
+{
+ DISPATCH(FogCoordfEXT, (coord), (F, "glFogCoordf(%f);\n", coord));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FogCoordfEXT)(GLfloat coord)
+{
+ DISPATCH(FogCoordfEXT, (coord), (F, "glFogCoordfEXT(%f);\n", coord));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FogCoordfv)(const GLfloat * coord)
+{
+ DISPATCH(FogCoordfvEXT, (coord), (F, "glFogCoordfv(%p);\n", (const void *) coord));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FogCoordfvEXT)(const GLfloat * coord)
+{
+ DISPATCH(FogCoordfvEXT, (coord), (F, "glFogCoordfvEXT(%p);\n", (const void *) coord));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FogCoordd)(GLdouble coord)
+{
+ DISPATCH(FogCoorddEXT, (coord), (F, "glFogCoordd(%f);\n", coord));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FogCoorddEXT)(GLdouble coord)
+{
+ DISPATCH(FogCoorddEXT, (coord), (F, "glFogCoorddEXT(%f);\n", coord));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FogCoorddv)(const GLdouble * coord)
+{
+ DISPATCH(FogCoorddvEXT, (coord), (F, "glFogCoorddv(%p);\n", (const void *) coord));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FogCoorddvEXT)(const GLdouble * coord)
+{
+ DISPATCH(FogCoorddvEXT, (coord), (F, "glFogCoorddvEXT(%p);\n", (const void *) coord));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FogCoordPointer)(GLenum type, GLsizei stride, const GLvoid * pointer)
+{
+ DISPATCH(FogCoordPointerEXT, (type, stride, pointer), (F, "glFogCoordPointer(0x%x, %d, %p);\n", type, stride, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FogCoordPointerEXT)(GLenum type, GLsizei stride, const GLvoid * pointer)
+{
+ DISPATCH(FogCoordPointerEXT, (type, stride, pointer), (F, "glFogCoordPointerEXT(0x%x, %d, %p);\n", type, stride, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetColorTableEXT)(GLenum target, GLenum format, GLenum type, GLvoid * data)
+{
+ DISPATCH(GetColorTableEXT, (target, format, type, data), (F, "glGetColorTableEXT(0x%x, 0x%x, 0x%x, %p);\n", target, format, type, (const void *) data));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetColorTableParameterivEXT)(GLenum target, GLenum pname, GLint * params)
+{
+ DISPATCH(GetColorTableParameterivEXT, (target, pname, params), (F, "glGetColorTableParameterivEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetColorTableParameterfvEXT)(GLenum target, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetColorTableParameterfvEXT, (target, pname, params), (F, "glGetColorTableParameterfvEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TbufferMask3DFX)(GLuint mask)
+{
+ DISPATCH(TbufferMask3DFX, (mask), (F, "glTbufferMask3DFX(%d);\n", mask));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CompressedTexImage3D)(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, "glCompressedTexImage3D(0x%x, %d, 0x%x, %d, %d, %d, %d, %d, %p);\n", target, level, internalformat, width, height, depth, border, imageSize, (const void *) data));
+}
+
+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(0x%x, %d, 0x%x, %d, %d, %d, %d, %d, %p);\n", target, level, internalformat, width, height, depth, border, imageSize, (const void *) data));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CompressedTexImage2D)(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, "glCompressedTexImage2D(0x%x, %d, 0x%x, %d, %d, %d, %d, %p);\n", target, level, internalformat, width, height, border, imageSize, (const void *) data));
+}
+
+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(0x%x, %d, 0x%x, %d, %d, %d, %d, %p);\n", target, level, internalformat, width, height, border, imageSize, (const void *) data));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CompressedTexImage1D)(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, "glCompressedTexImage1D(0x%x, %d, 0x%x, %d, %d, %d, %p);\n", target, level, internalformat, width, border, imageSize, (const void *) data));
+}
+
+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(0x%x, %d, 0x%x, %d, %d, %d, %p);\n", target, level, internalformat, width, border, imageSize, (const void *) data));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CompressedTexSubImage3D)(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, "glCompressedTexSubImage3D(0x%x, %d, %d, %d, %d, %d, %d, %d, 0x%x, %d, %p);\n", target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, (const void *) data));
+}
+
+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(0x%x, %d, %d, %d, %d, %d, %d, %d, 0x%x, %d, %p);\n", target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, (const void *) data));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CompressedTexSubImage2D)(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, "glCompressedTexSubImage2D(0x%x, %d, %d, %d, %d, %d, 0x%x, %d, %p);\n", target, level, xoffset, yoffset, width, height, format, imageSize, (const void *) data));
+}
+
+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(0x%x, %d, %d, %d, %d, %d, 0x%x, %d, %p);\n", target, level, xoffset, yoffset, width, height, format, imageSize, (const void *) data));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CompressedTexSubImage1D)(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, "glCompressedTexSubImage1D(0x%x, %d, %d, %d, 0x%x, %d, %p);\n", target, level, xoffset, width, format, imageSize, (const void *) data));
+}
+
+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(0x%x, %d, %d, %d, 0x%x, %d, %p);\n", target, level, xoffset, width, format, imageSize, (const void *) data));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetCompressedTexImage)(GLenum target, GLint level, GLvoid * img)
+{
+ DISPATCH(GetCompressedTexImageARB, (target, level, img), (F, "glGetCompressedTexImage(0x%x, %d, %p);\n", target, level, (const void *) img));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetCompressedTexImageARB)(GLenum target, GLint level, GLvoid * img)
+{
+ DISPATCH(GetCompressedTexImageARB, (target, level, img), (F, "glGetCompressedTexImageARB(0x%x, %d, %p);\n", target, level, (const void *) img));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3b)(GLbyte red, GLbyte green, GLbyte blue)
+{
+ DISPATCH(SecondaryColor3bEXT, (red, green, blue), (F, "glSecondaryColor3b(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3bEXT)(GLbyte red, GLbyte green, GLbyte blue)
+{
+ DISPATCH(SecondaryColor3bEXT, (red, green, blue), (F, "glSecondaryColor3bEXT(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3bv)(const GLbyte * v)
+{
+ DISPATCH(SecondaryColor3bvEXT, (v), (F, "glSecondaryColor3bv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3bvEXT)(const GLbyte * v)
+{
+ DISPATCH(SecondaryColor3bvEXT, (v), (F, "glSecondaryColor3bvEXT(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3d)(GLdouble red, GLdouble green, GLdouble blue)
+{
+ DISPATCH(SecondaryColor3dEXT, (red, green, blue), (F, "glSecondaryColor3d(%f, %f, %f);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3dEXT)(GLdouble red, GLdouble green, GLdouble blue)
+{
+ DISPATCH(SecondaryColor3dEXT, (red, green, blue), (F, "glSecondaryColor3dEXT(%f, %f, %f);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3dv)(const GLdouble * v)
+{
+ DISPATCH(SecondaryColor3dvEXT, (v), (F, "glSecondaryColor3dv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3dvEXT)(const GLdouble * v)
+{
+ DISPATCH(SecondaryColor3dvEXT, (v), (F, "glSecondaryColor3dvEXT(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3f)(GLfloat red, GLfloat green, GLfloat blue)
+{
+ DISPATCH(SecondaryColor3fEXT, (red, green, blue), (F, "glSecondaryColor3f(%f, %f, %f);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3fEXT)(GLfloat red, GLfloat green, GLfloat blue)
+{
+ DISPATCH(SecondaryColor3fEXT, (red, green, blue), (F, "glSecondaryColor3fEXT(%f, %f, %f);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3fv)(const GLfloat * v)
+{
+ DISPATCH(SecondaryColor3fvEXT, (v), (F, "glSecondaryColor3fv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3fvEXT)(const GLfloat * v)
+{
+ DISPATCH(SecondaryColor3fvEXT, (v), (F, "glSecondaryColor3fvEXT(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3i)(GLint red, GLint green, GLint blue)
+{
+ DISPATCH(SecondaryColor3iEXT, (red, green, blue), (F, "glSecondaryColor3i(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3iEXT)(GLint red, GLint green, GLint blue)
+{
+ DISPATCH(SecondaryColor3iEXT, (red, green, blue), (F, "glSecondaryColor3iEXT(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3iv)(const GLint * v)
+{
+ DISPATCH(SecondaryColor3ivEXT, (v), (F, "glSecondaryColor3iv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3ivEXT)(const GLint * v)
+{
+ DISPATCH(SecondaryColor3ivEXT, (v), (F, "glSecondaryColor3ivEXT(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3s)(GLshort red, GLshort green, GLshort blue)
+{
+ DISPATCH(SecondaryColor3sEXT, (red, green, blue), (F, "glSecondaryColor3s(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3sEXT)(GLshort red, GLshort green, GLshort blue)
+{
+ DISPATCH(SecondaryColor3sEXT, (red, green, blue), (F, "glSecondaryColor3sEXT(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3sv)(const GLshort * v)
+{
+ DISPATCH(SecondaryColor3svEXT, (v), (F, "glSecondaryColor3sv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3svEXT)(const GLshort * v)
+{
+ DISPATCH(SecondaryColor3svEXT, (v), (F, "glSecondaryColor3svEXT(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3ub)(GLubyte red, GLubyte green, GLubyte blue)
+{
+ DISPATCH(SecondaryColor3ubEXT, (red, green, blue), (F, "glSecondaryColor3ub(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3ubEXT)(GLubyte red, GLubyte green, GLubyte blue)
+{
+ DISPATCH(SecondaryColor3ubEXT, (red, green, blue), (F, "glSecondaryColor3ubEXT(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3ubv)(const GLubyte * v)
+{
+ DISPATCH(SecondaryColor3ubvEXT, (v), (F, "glSecondaryColor3ubv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3ubvEXT)(const GLubyte * v)
+{
+ DISPATCH(SecondaryColor3ubvEXT, (v), (F, "glSecondaryColor3ubvEXT(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3ui)(GLuint red, GLuint green, GLuint blue)
+{
+ DISPATCH(SecondaryColor3uiEXT, (red, green, blue), (F, "glSecondaryColor3ui(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3uiEXT)(GLuint red, GLuint green, GLuint blue)
+{
+ DISPATCH(SecondaryColor3uiEXT, (red, green, blue), (F, "glSecondaryColor3uiEXT(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3uiv)(const GLuint * v)
+{
+ DISPATCH(SecondaryColor3uivEXT, (v), (F, "glSecondaryColor3uiv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3uivEXT)(const GLuint * v)
+{
+ DISPATCH(SecondaryColor3uivEXT, (v), (F, "glSecondaryColor3uivEXT(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3us)(GLushort red, GLushort green, GLushort blue)
+{
+ DISPATCH(SecondaryColor3usEXT, (red, green, blue), (F, "glSecondaryColor3us(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3usEXT)(GLushort red, GLushort green, GLushort blue)
+{
+ DISPATCH(SecondaryColor3usEXT, (red, green, blue), (F, "glSecondaryColor3usEXT(%d, %d, %d);\n", red, green, blue));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3usv)(const GLushort * v)
+{
+ DISPATCH(SecondaryColor3usvEXT, (v), (F, "glSecondaryColor3usv(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColor3usvEXT)(const GLushort * v)
+{
+ DISPATCH(SecondaryColor3usvEXT, (v), (F, "glSecondaryColor3usvEXT(%p);\n", (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)
+{
+ DISPATCH(SecondaryColorPointerEXT, (size, type, stride, pointer), (F, "glSecondaryColorPointer(%d, 0x%x, %d, %p);\n", size, type, stride, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SecondaryColorPointerEXT)(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)
+{
+ DISPATCH(SecondaryColorPointerEXT, (size, type, stride, pointer), (F, "glSecondaryColorPointerEXT(%d, 0x%x, %d, %p);\n", size, type, stride, (const void *) pointer));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(AreProgramsResidentNV)(GLsizei n, const GLuint * ids, GLboolean * residences)
+{
+ RETURN_DISPATCH(AreProgramsResidentNV, (n, ids, residences), (F, "glAreProgramsResidentNV(%d, %p, %p);\n", n, (const void *) ids, (const void *) residences));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BindProgramARB)(GLenum target, GLuint program)
+{
+ DISPATCH(BindProgramNV, (target, program), (F, "glBindProgramARB(0x%x, %d);\n", target, program));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BindProgramNV)(GLenum target, GLuint program)
+{
+ DISPATCH(BindProgramNV, (target, program), (F, "glBindProgramNV(0x%x, %d);\n", target, program));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DeleteProgramsARB)(GLsizei n, const GLuint * programs)
+{
+ DISPATCH(DeleteProgramsNV, (n, programs), (F, "glDeleteProgramsARB(%d, %p);\n", n, (const void *) programs));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DeleteProgramsNV)(GLsizei n, const GLuint * programs)
+{
+ DISPATCH(DeleteProgramsNV, (n, programs), (F, "glDeleteProgramsNV(%d, %p);\n", n, (const void *) programs));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ExecuteProgramNV)(GLenum target, GLuint id, const GLfloat * params)
+{
+ DISPATCH(ExecuteProgramNV, (target, id, params), (F, "glExecuteProgramNV(0x%x, %d, %p);\n", target, id, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GenProgramsARB)(GLsizei n, GLuint * programs)
+{
+ DISPATCH(GenProgramsNV, (n, programs), (F, "glGenProgramsARB(%d, %p);\n", n, (const void *) programs));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GenProgramsNV)(GLsizei n, GLuint * programs)
+{
+ DISPATCH(GenProgramsNV, (n, programs), (F, "glGenProgramsNV(%d, %p);\n", n, (const void *) programs));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetProgramParameterdvNV)(GLenum target, GLuint index, GLenum pname, GLdouble * params)
+{
+ DISPATCH(GetProgramParameterdvNV, (target, index, pname, params), (F, "glGetProgramParameterdvNV(0x%x, %d, 0x%x, %p);\n", target, index, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetProgramParameterfvNV)(GLenum target, GLuint index, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetProgramParameterfvNV, (target, index, pname, params), (F, "glGetProgramParameterfvNV(0x%x, %d, 0x%x, %p);\n", target, index, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetProgramivNV)(GLuint id, GLenum pname, GLint * params)
+{
+ DISPATCH(GetProgramivNV, (id, pname, params), (F, "glGetProgramivNV(%d, 0x%x, %p);\n", id, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetProgramStringNV)(GLuint id, GLenum pname, GLubyte * program)
+{
+ DISPATCH(GetProgramStringNV, (id, pname, program), (F, "glGetProgramStringNV(%d, 0x%x, %p);\n", id, pname, (const void *) program));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetTrackMatrixivNV)(GLenum target, GLuint address, GLenum pname, GLint * params)
+{
+ DISPATCH(GetTrackMatrixivNV, (target, address, pname, params), (F, "glGetTrackMatrixivNV(0x%x, %d, 0x%x, %p);\n", target, address, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetVertexAttribdvARB)(GLuint index, GLenum pname, GLdouble * params)
+{
+ DISPATCH(GetVertexAttribdvARB, (index, pname, params), (F, "glGetVertexAttribdvARB(%d, 0x%x, %p);\n", index, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetVertexAttribfvARB)(GLuint index, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetVertexAttribfvARB, (index, pname, params), (F, "glGetVertexAttribfvARB(%d, 0x%x, %p);\n", index, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetVertexAttribivARB)(GLuint index, GLenum pname, GLint * params)
+{
+ DISPATCH(GetVertexAttribivARB, (index, pname, params), (F, "glGetVertexAttribivARB(%d, 0x%x, %p);\n", index, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetVertexAttribPointervARB)(GLuint index, GLenum pname, GLvoid ** params)
+{
+ DISPATCH(GetVertexAttribPointervNV, (index, pname, params), (F, "glGetVertexAttribPointervARB(%d, 0x%x, %p);\n", index, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetVertexAttribPointervNV)(GLuint index, GLenum pname, GLvoid ** params)
+{
+ DISPATCH(GetVertexAttribPointervNV, (index, pname, params), (F, "glGetVertexAttribPointervNV(%d, 0x%x, %p);\n", index, pname, (const void *) params));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(IsProgramARB)(GLuint program)
+{
+ RETURN_DISPATCH(IsProgramNV, (program), (F, "glIsProgramARB(%d);\n", program));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(IsProgramNV)(GLuint program)
+{
+ RETURN_DISPATCH(IsProgramNV, (program), (F, "glIsProgramNV(%d);\n", program));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LoadProgramNV)(GLenum target, GLuint id, GLsizei len, const GLubyte * program)
+{
+ DISPATCH(LoadProgramNV, (target, id, len, program), (F, "glLoadProgramNV(0x%x, %d, %d, %p);\n", target, id, len, (const void *) program));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramParameter4dNV)(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ DISPATCH(ProgramParameter4dNV, (target, index, x, y, z, w), (F, "glProgramParameter4dNV(0x%x, %d, %f, %f, %f, %f);\n", target, index, x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramParameter4dvNV)(GLenum target, GLuint index, const GLdouble * params)
+{
+ DISPATCH(ProgramParameter4dvNV, (target, index, params), (F, "glProgramParameter4dvNV(0x%x, %d, %p);\n", target, index, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramParameter4fNV)(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ DISPATCH(ProgramParameter4fNV, (target, index, x, y, z, w), (F, "glProgramParameter4fNV(0x%x, %d, %f, %f, %f, %f);\n", target, index, x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramParameter4fvNV)(GLenum target, GLuint index, const GLfloat * params)
+{
+ DISPATCH(ProgramParameter4fvNV, (target, index, params), (F, "glProgramParameter4fvNV(0x%x, %d, %p);\n", target, index, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramParameters4dvNV)(GLenum target, GLuint index, GLuint num, const GLdouble * params)
+{
+ DISPATCH(ProgramParameters4dvNV, (target, index, num, params), (F, "glProgramParameters4dvNV(0x%x, %d, %d, %p);\n", target, index, num, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramParameters4fvNV)(GLenum target, GLuint index, GLuint num, const GLfloat * params)
+{
+ DISPATCH(ProgramParameters4fvNV, (target, index, num, params), (F, "glProgramParameters4fvNV(0x%x, %d, %d, %p);\n", target, index, num, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RequestResidentProgramsNV)(GLsizei n, const GLuint * ids)
+{
+ DISPATCH(RequestResidentProgramsNV, (n, ids), (F, "glRequestResidentProgramsNV(%d, %p);\n", n, (const void *) ids));
+}
+
+KEYWORD1 void KEYWORD2 NAME(TrackMatrixNV)(GLenum target, GLuint address, GLenum matrix, GLenum transform)
+{
+ DISPATCH(TrackMatrixNV, (target, address, matrix, transform), (F, "glTrackMatrixNV(0x%x, %d, 0x%x, 0x%x);\n", target, address, matrix, transform));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttribPointerNV)(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)
+{
+ DISPATCH(VertexAttribPointerNV, (index, size, type, stride, pointer), (F, "glVertexAttribPointerNV(%d, %d, 0x%x, %d, %p);\n", index, size, type, stride, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib1dARB)(GLuint index, GLdouble x)
+{
+ DISPATCH(VertexAttrib1dARB, (index, x), (F, "glVertexAttrib1dARB(%d, %f);\n", index, x));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib1dvARB)(GLuint index, const GLdouble * v)
+{
+ DISPATCH(VertexAttrib1dvARB, (index, v), (F, "glVertexAttrib1dvARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib1fARB)(GLuint index, GLfloat x)
+{
+ DISPATCH(VertexAttrib1fARB, (index, x), (F, "glVertexAttrib1fARB(%d, %f);\n", index, x));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib1fvARB)(GLuint index, const GLfloat * v)
+{
+ DISPATCH(VertexAttrib1fvARB, (index, v), (F, "glVertexAttrib1fvARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib1sARB)(GLuint index, GLshort x)
+{
+ DISPATCH(VertexAttrib1sARB, (index, x), (F, "glVertexAttrib1sARB(%d, %d);\n", index, x));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib1svARB)(GLuint index, const GLshort * v)
+{
+ DISPATCH(VertexAttrib1svARB, (index, v), (F, "glVertexAttrib1svARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib2dARB)(GLuint index, GLdouble x, GLdouble y)
+{
+ DISPATCH(VertexAttrib2dARB, (index, x, y), (F, "glVertexAttrib2dARB(%d, %f, %f);\n", index, x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib2dvARB)(GLuint index, const GLdouble * v)
+{
+ DISPATCH(VertexAttrib2dvARB, (index, v), (F, "glVertexAttrib2dvARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib2fARB)(GLuint index, GLfloat x, GLfloat y)
+{
+ DISPATCH(VertexAttrib2fARB, (index, x, y), (F, "glVertexAttrib2fARB(%d, %f, %f);\n", index, x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib2fvARB)(GLuint index, const GLfloat * v)
+{
+ DISPATCH(VertexAttrib2fvARB, (index, v), (F, "glVertexAttrib2fvARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib2sARB)(GLuint index, GLshort x, GLshort y)
+{
+ DISPATCH(VertexAttrib2sARB, (index, x, y), (F, "glVertexAttrib2sARB(%d, %d, %d);\n", index, x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib2svARB)(GLuint index, const GLshort * v)
+{
+ DISPATCH(VertexAttrib2svARB, (index, v), (F, "glVertexAttrib2svARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib3dARB)(GLuint index, GLdouble x, GLdouble y, GLdouble z)
+{
+ DISPATCH(VertexAttrib3dARB, (index, x, y, z), (F, "glVertexAttrib3dARB(%d, %f, %f, %f);\n", index, x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib3dvARB)(GLuint index, const GLdouble * v)
+{
+ DISPATCH(VertexAttrib3dvARB, (index, v), (F, "glVertexAttrib3dvARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib3fARB)(GLuint index, GLfloat x, GLfloat y, GLfloat z)
+{
+ DISPATCH(VertexAttrib3fARB, (index, x, y, z), (F, "glVertexAttrib3fARB(%d, %f, %f, %f);\n", index, x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib3fvARB)(GLuint index, const GLfloat * v)
+{
+ DISPATCH(VertexAttrib3fvARB, (index, v), (F, "glVertexAttrib3fvARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib3sARB)(GLuint index, GLshort x, GLshort y, GLshort z)
+{
+ DISPATCH(VertexAttrib3sARB, (index, x, y, z), (F, "glVertexAttrib3sARB(%d, %d, %d, %d);\n", index, x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib3svARB)(GLuint index, const GLshort * v)
+{
+ DISPATCH(VertexAttrib3svARB, (index, v), (F, "glVertexAttrib3svARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4dARB)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ DISPATCH(VertexAttrib4dARB, (index, x, y, z, w), (F, "glVertexAttrib4dARB(%d, %f, %f, %f, %f);\n", index, x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4dvARB)(GLuint index, const GLdouble * v)
+{
+ DISPATCH(VertexAttrib4dvARB, (index, v), (F, "glVertexAttrib4dvARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4fARB)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ DISPATCH(VertexAttrib4fARB, (index, x, y, z, w), (F, "glVertexAttrib4fARB(%d, %f, %f, %f, %f);\n", index, x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4fvARB)(GLuint index, const GLfloat * v)
+{
+ DISPATCH(VertexAttrib4fvARB, (index, v), (F, "glVertexAttrib4fvARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4sARB)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w)
+{
+ DISPATCH(VertexAttrib4sARB, (index, x, y, z, w), (F, "glVertexAttrib4sARB(%d, %d, %d, %d, %d);\n", index, x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4svARB)(GLuint index, const GLshort * v)
+{
+ DISPATCH(VertexAttrib4svARB, (index, v), (F, "glVertexAttrib4svARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4NubARB)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w)
+{
+ DISPATCH(VertexAttrib4NubARB, (index, x, y, z, w), (F, "glVertexAttrib4NubARB(%d, %d, %d, %d, %d);\n", index, x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4NubvARB)(GLuint index, const GLubyte * v)
+{
+ DISPATCH(VertexAttrib4NubvARB, (index, v), (F, "glVertexAttrib4NubvARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttribs1dvNV)(GLuint index, GLsizei n, const GLdouble * v)
+{
+ DISPATCH(VertexAttribs1dvNV, (index, n, v), (F, "glVertexAttribs1dvNV(%d, %d, %p);\n", index, n, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttribs1fvNV)(GLuint index, GLsizei n, const GLfloat * v)
+{
+ DISPATCH(VertexAttribs1fvNV, (index, n, v), (F, "glVertexAttribs1fvNV(%d, %d, %p);\n", index, n, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttribs1svNV)(GLuint index, GLsizei n, const GLshort * v)
+{
+ DISPATCH(VertexAttribs1svNV, (index, n, v), (F, "glVertexAttribs1svNV(%d, %d, %p);\n", index, n, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttribs2dvNV)(GLuint index, GLsizei n, const GLdouble * v)
+{
+ DISPATCH(VertexAttribs2dvNV, (index, n, v), (F, "glVertexAttribs2dvNV(%d, %d, %p);\n", index, n, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttribs2fvNV)(GLuint index, GLsizei n, const GLfloat * v)
+{
+ DISPATCH(VertexAttribs2fvNV, (index, n, v), (F, "glVertexAttribs2fvNV(%d, %d, %p);\n", index, n, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttribs2svNV)(GLuint index, GLsizei n, const GLshort * v)
+{
+ DISPATCH(VertexAttribs2svNV, (index, n, v), (F, "glVertexAttribs2svNV(%d, %d, %p);\n", index, n, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttribs3dvNV)(GLuint index, GLsizei n, const GLdouble * v)
+{
+ DISPATCH(VertexAttribs3dvNV, (index, n, v), (F, "glVertexAttribs3dvNV(%d, %d, %p);\n", index, n, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttribs3fvNV)(GLuint index, GLsizei n, const GLfloat * v)
+{
+ DISPATCH(VertexAttribs3fvNV, (index, n, v), (F, "glVertexAttribs3fvNV(%d, %d, %p);\n", index, n, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttribs3svNV)(GLuint index, GLsizei n, const GLshort * v)
+{
+ DISPATCH(VertexAttribs3svNV, (index, n, v), (F, "glVertexAttribs3svNV(%d, %d, %p);\n", index, n, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttribs4dvNV)(GLuint index, GLsizei n, const GLdouble * v)
+{
+ DISPATCH(VertexAttribs4dvNV, (index, n, v), (F, "glVertexAttribs4dvNV(%d, %d, %p);\n", index, n, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttribs4fvNV)(GLuint index, GLsizei n, const GLfloat * v)
+{
+ DISPATCH(VertexAttribs4fvNV, (index, n, v), (F, "glVertexAttribs4fvNV(%d, %d, %p);\n", index, n, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttribs4svNV)(GLuint index, GLsizei n, const GLshort * v)
+{
+ DISPATCH(VertexAttribs4svNV, (index, n, v), (F, "glVertexAttribs4svNV(%d, %d, %p);\n", index, n, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttribs4ubvNV)(GLuint index, GLsizei n, const GLubyte * v)
+{
+ DISPATCH(VertexAttribs4ubvNV, (index, n, v), (F, "glVertexAttribs4ubvNV(%d, %d, %p);\n", index, n, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PointParameteri)(GLenum pname, GLint param)
+{
+ DISPATCH(PointParameteriNV, (pname, param), (F, "glPointParameteri(0x%x, %d);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PointParameteriNV)(GLenum pname, GLint param)
+{
+ DISPATCH(PointParameteriNV, (pname, param), (F, "glPointParameteriNV(0x%x, %d);\n", pname, param));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PointParameteriv)(GLenum pname, const GLint * params)
+{
+ DISPATCH(PointParameterivNV, (pname, params), (F, "glPointParameteriv(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PointParameterivNV)(GLenum pname, const GLint * params)
+{
+ DISPATCH(PointParameterivNV, (pname, params), (F, "glPointParameterivNV(0x%x, %p);\n", pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiDrawArrays)(GLenum mode, GLint * first, GLsizei * count, GLsizei primcount)
+{
+ DISPATCH(MultiDrawArraysEXT, (mode, first, count, primcount), (F, "glMultiDrawArrays(0x%x, %p, %p, %d);\n", mode, (const void *) first, (const void *) count, primcount));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiDrawArraysEXT)(GLenum mode, GLint * first, GLsizei * count, GLsizei primcount)
+{
+ DISPATCH(MultiDrawArraysEXT, (mode, first, count, primcount), (F, "glMultiDrawArraysEXT(0x%x, %p, %p, %d);\n", mode, (const void *) first, (const void *) count, primcount));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiDrawElements)(GLenum mode, const GLsizei * count, GLenum type, const GLvoid ** indices, GLsizei primcount)
+{
+ DISPATCH(MultiDrawElementsEXT, (mode, count, type, indices, primcount), (F, "glMultiDrawElements(0x%x, %p, 0x%x, %p, %d);\n", mode, (const void *) count, type, (const void *) indices, primcount));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiDrawElementsEXT)(GLenum mode, const GLsizei * count, GLenum type, const GLvoid ** indices, GLsizei primcount)
+{
+ DISPATCH(MultiDrawElementsEXT, (mode, count, type, indices, primcount), (F, "glMultiDrawElementsEXT(0x%x, %p, 0x%x, %p, %d);\n", mode, (const void *) count, type, (const void *) indices, primcount));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ActiveStencilFaceEXT)(GLenum face)
+{
+ DISPATCH(ActiveStencilFaceEXT, (face), (F, "glActiveStencilFaceEXT(0x%x);\n", face));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DeleteFencesNV)(GLsizei n, const GLuint * fences)
+{
+ DISPATCH(DeleteFencesNV, (n, fences), (F, "glDeleteFencesNV(%d, %p);\n", n, (const void *) fences));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GenFencesNV)(GLsizei n, GLuint * fences)
+{
+ DISPATCH(GenFencesNV, (n, fences), (F, "glGenFencesNV(%d, %p);\n", n, (const void *) fences));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(IsFenceNV)(GLuint fence)
+{
+ RETURN_DISPATCH(IsFenceNV, (fence), (F, "glIsFenceNV(%d);\n", fence));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(TestFenceNV)(GLuint fence)
+{
+ RETURN_DISPATCH(TestFenceNV, (fence), (F, "glTestFenceNV(%d);\n", fence));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetFenceivNV)(GLuint fence, GLenum pname, GLint * params)
+{
+ DISPATCH(GetFenceivNV, (fence, pname, params), (F, "glGetFenceivNV(%d, 0x%x, %p);\n", fence, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FinishFenceNV)(GLuint fence)
+{
+ DISPATCH(FinishFenceNV, (fence), (F, "glFinishFenceNV(%d);\n", fence));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SetFenceNV)(GLuint fence, GLenum condition)
+{
+ DISPATCH(SetFenceNV, (fence, condition), (F, "glSetFenceNV(%d, 0x%x);\n", fence, condition));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4bvARB)(GLuint index, const GLbyte * v)
+{
+ DISPATCH(VertexAttrib4bvARB, (index, v), (F, "glVertexAttrib4bvARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4ivARB)(GLuint index, const GLint * v)
+{
+ DISPATCH(VertexAttrib4ivARB, (index, v), (F, "glVertexAttrib4ivARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4ubvARB)(GLuint index, const GLubyte * v)
+{
+ DISPATCH(VertexAttrib4ubvARB, (index, v), (F, "glVertexAttrib4ubvARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4usvARB)(GLuint index, const GLushort * v)
+{
+ DISPATCH(VertexAttrib4usvARB, (index, v), (F, "glVertexAttrib4usvARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4uivARB)(GLuint index, const GLuint * v)
+{
+ DISPATCH(VertexAttrib4uivARB, (index, v), (F, "glVertexAttrib4uivARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4NbvARB)(GLuint index, const GLbyte * v)
+{
+ DISPATCH(VertexAttrib4NbvARB, (index, v), (F, "glVertexAttrib4NbvARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4NsvARB)(GLuint index, const GLshort * v)
+{
+ DISPATCH(VertexAttrib4NsvARB, (index, v), (F, "glVertexAttrib4NsvARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4NivARB)(GLuint index, const GLint * v)
+{
+ DISPATCH(VertexAttrib4NivARB, (index, v), (F, "glVertexAttrib4NivARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4NusvARB)(GLuint index, const GLushort * v)
+{
+ DISPATCH(VertexAttrib4NusvARB, (index, v), (F, "glVertexAttrib4NusvARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4NuivARB)(GLuint index, const GLuint * v)
+{
+ DISPATCH(VertexAttrib4NuivARB, (index, v), (F, "glVertexAttrib4NuivARB(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttribPointerARB)(GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid * pointer)
+{
+ DISPATCH(VertexAttribPointerARB, (index, size, type, normalized, stride, pointer), (F, "glVertexAttribPointerARB(%d, %d, 0x%x, %d, %d, %p);\n", index, size, type, normalized, stride, (const void *) pointer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EnableVertexAttribArrayARB)(GLuint index)
+{
+ DISPATCH(EnableVertexAttribArrayARB, (index), (F, "glEnableVertexAttribArrayARB(%d);\n", index));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DisableVertexAttribArrayARB)(GLuint index)
+{
+ DISPATCH(DisableVertexAttribArrayARB, (index), (F, "glDisableVertexAttribArrayARB(%d);\n", index));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramStringARB)(GLenum target, GLenum format, GLsizei len, const GLvoid * string)
+{
+ DISPATCH(ProgramStringARB, (target, format, len, string), (F, "glProgramStringARB(0x%x, 0x%x, %d, %p);\n", target, format, len, (const void *) string));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramEnvParameter4dARB)(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ DISPATCH(ProgramEnvParameter4dARB, (target, index, x, y, z, w), (F, "glProgramEnvParameter4dARB(0x%x, %d, %f, %f, %f, %f);\n", target, index, x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramEnvParameter4dvARB)(GLenum target, GLuint index, const GLdouble * params)
+{
+ DISPATCH(ProgramEnvParameter4dvARB, (target, index, params), (F, "glProgramEnvParameter4dvARB(0x%x, %d, %p);\n", target, index, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramEnvParameter4fARB)(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ DISPATCH(ProgramEnvParameter4fARB, (target, index, x, y, z, w), (F, "glProgramEnvParameter4fARB(0x%x, %d, %f, %f, %f, %f);\n", target, index, x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramEnvParameter4fvARB)(GLenum target, GLuint index, const GLfloat * params)
+{
+ DISPATCH(ProgramEnvParameter4fvARB, (target, index, params), (F, "glProgramEnvParameter4fvARB(0x%x, %d, %p);\n", target, index, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramLocalParameter4dARB)(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ DISPATCH(ProgramLocalParameter4dARB, (target, index, x, y, z, w), (F, "glProgramLocalParameter4dARB(0x%x, %d, %f, %f, %f, %f);\n", target, index, x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramLocalParameter4dvARB)(GLenum target, GLuint index, const GLdouble * params)
+{
+ DISPATCH(ProgramLocalParameter4dvARB, (target, index, params), (F, "glProgramLocalParameter4dvARB(0x%x, %d, %p);\n", target, index, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramLocalParameter4fARB)(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ DISPATCH(ProgramLocalParameter4fARB, (target, index, x, y, z, w), (F, "glProgramLocalParameter4fARB(0x%x, %d, %f, %f, %f, %f);\n", target, index, x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramLocalParameter4fvARB)(GLenum target, GLuint index, const GLfloat * params)
+{
+ DISPATCH(ProgramLocalParameter4fvARB, (target, index, params), (F, "glProgramLocalParameter4fvARB(0x%x, %d, %p);\n", target, index, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetProgramEnvParameterdvARB)(GLenum target, GLuint index, GLdouble * params)
+{
+ DISPATCH(GetProgramEnvParameterdvARB, (target, index, params), (F, "glGetProgramEnvParameterdvARB(0x%x, %d, %p);\n", target, index, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetProgramEnvParameterfvARB)(GLenum target, GLuint index, GLfloat * params)
+{
+ DISPATCH(GetProgramEnvParameterfvARB, (target, index, params), (F, "glGetProgramEnvParameterfvARB(0x%x, %d, %p);\n", target, index, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetProgramLocalParameterdvARB)(GLenum target, GLuint index, GLdouble * params)
+{
+ DISPATCH(GetProgramLocalParameterdvARB, (target, index, params), (F, "glGetProgramLocalParameterdvARB(0x%x, %d, %p);\n", target, index, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetProgramLocalParameterfvARB)(GLenum target, GLuint index, GLfloat * params)
+{
+ DISPATCH(GetProgramLocalParameterfvARB, (target, index, params), (F, "glGetProgramLocalParameterfvARB(0x%x, %d, %p);\n", target, index, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetProgramivARB)(GLenum target, GLenum pname, GLint * params)
+{
+ DISPATCH(GetProgramivARB, (target, pname, params), (F, "glGetProgramivARB(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetProgramStringARB)(GLenum target, GLenum pname, GLvoid * string)
+{
+ DISPATCH(GetProgramStringARB, (target, pname, string), (F, "glGetProgramStringARB(0x%x, 0x%x, %p);\n", target, pname, (const void *) string));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramNamedParameter4fNV)(GLuint id, GLsizei len, const GLubyte * name, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ DISPATCH(ProgramNamedParameter4fNV, (id, len, name, x, y, z, w), (F, "glProgramNamedParameter4fNV(%d, %d, %p, %f, %f, %f, %f);\n", id, len, (const void *) name, x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramNamedParameter4dNV)(GLuint id, GLsizei len, const GLubyte * name, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ DISPATCH(ProgramNamedParameter4dNV, (id, len, name, x, y, z, w), (F, "glProgramNamedParameter4dNV(%d, %d, %p, %f, %f, %f, %f);\n", id, len, (const void *) name, x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramNamedParameter4fvNV)(GLuint id, GLsizei len, const GLubyte * name, const GLfloat * v)
+{
+ DISPATCH(ProgramNamedParameter4fvNV, (id, len, name, v), (F, "glProgramNamedParameter4fvNV(%d, %d, %p, %p);\n", id, len, (const void *) name, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ProgramNamedParameter4dvNV)(GLuint id, GLsizei len, const GLubyte * name, const GLdouble * v)
+{
+ DISPATCH(ProgramNamedParameter4dvNV, (id, len, name, v), (F, "glProgramNamedParameter4dvNV(%d, %d, %p, %p);\n", id, len, (const void *) name, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetProgramNamedParameterfvNV)(GLuint id, GLsizei len, const GLubyte * name, GLfloat * params)
+{
+ DISPATCH(GetProgramNamedParameterfvNV, (id, len, name, params), (F, "glGetProgramNamedParameterfvNV(%d, %d, %p, %p);\n", id, len, (const void *) name, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetProgramNamedParameterdvNV)(GLuint id, GLsizei len, const GLubyte * name, GLdouble * params)
+{
+ DISPATCH(GetProgramNamedParameterdvNV, (id, len, name, params), (F, "glGetProgramNamedParameterdvNV(%d, %d, %p, %p);\n", id, len, (const void *) name, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BindBuffer)(GLenum target, GLuint buffer)
+{
+ DISPATCH(BindBufferARB, (target, buffer), (F, "glBindBuffer(0x%x, %d);\n", target, buffer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BindBufferARB)(GLenum target, GLuint buffer)
+{
+ DISPATCH(BindBufferARB, (target, buffer), (F, "glBindBufferARB(0x%x, %d);\n", target, buffer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BufferData)(GLenum target, GLsizeiptr size, const GLvoid * data, GLenum usage)
+{
+ DISPATCH(BufferDataARB, (target, size, data, usage), (F, "glBufferData(0x%x, %d, %p, 0x%x);\n", target, size, (const void *) data, usage));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BufferDataARB)(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage)
+{
+ DISPATCH(BufferDataARB, (target, size, data, usage), (F, "glBufferDataARB(0x%x, %d, %p, 0x%x);\n", target, size, (const void *) data, usage));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid * data)
+{
+ DISPATCH(BufferSubDataARB, (target, offset, size, data), (F, "glBufferSubData(0x%x, %d, %d, %p);\n", target, offset, size, (const void *) data));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BufferSubDataARB)(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data)
+{
+ DISPATCH(BufferSubDataARB, (target, offset, size, data), (F, "glBufferSubDataARB(0x%x, %d, %d, %p);\n", target, offset, size, (const void *) data));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DeleteBuffers)(GLsizei n, const GLuint * buffer)
+{
+ DISPATCH(DeleteBuffersARB, (n, buffer), (F, "glDeleteBuffers(%d, %p);\n", n, (const void *) buffer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DeleteBuffersARB)(GLsizei n, const GLuint * buffer)
+{
+ DISPATCH(DeleteBuffersARB, (n, buffer), (F, "glDeleteBuffersARB(%d, %p);\n", n, (const void *) buffer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GenBuffers)(GLsizei n, GLuint * buffer)
+{
+ DISPATCH(GenBuffersARB, (n, buffer), (F, "glGenBuffers(%d, %p);\n", n, (const void *) buffer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GenBuffersARB)(GLsizei n, GLuint * buffer)
+{
+ DISPATCH(GenBuffersARB, (n, buffer), (F, "glGenBuffersARB(%d, %p);\n", n, (const void *) buffer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetBufferParameteriv)(GLenum target, GLenum pname, GLint * params)
+{
+ DISPATCH(GetBufferParameterivARB, (target, pname, params), (F, "glGetBufferParameteriv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetBufferParameterivARB)(GLenum target, GLenum pname, GLint * params)
+{
+ DISPATCH(GetBufferParameterivARB, (target, pname, params), (F, "glGetBufferParameterivARB(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetBufferPointerv)(GLenum target, GLenum pname, GLvoid ** params)
+{
+ DISPATCH(GetBufferPointervARB, (target, pname, params), (F, "glGetBufferPointerv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetBufferPointervARB)(GLenum target, GLenum pname, GLvoid ** params)
+{
+ DISPATCH(GetBufferPointervARB, (target, pname, params), (F, "glGetBufferPointervARB(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetBufferSubData)(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid * data)
+{
+ DISPATCH(GetBufferSubDataARB, (target, offset, size, data), (F, "glGetBufferSubData(0x%x, %d, %d, %p);\n", target, offset, size, (const void *) data));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetBufferSubDataARB)(GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid * data)
+{
+ DISPATCH(GetBufferSubDataARB, (target, offset, size, data), (F, "glGetBufferSubDataARB(0x%x, %d, %d, %p);\n", target, offset, size, (const void *) data));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(IsBuffer)(GLuint buffer)
+{
+ RETURN_DISPATCH(IsBufferARB, (buffer), (F, "glIsBuffer(%d);\n", buffer));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(IsBufferARB)(GLuint buffer)
+{
+ RETURN_DISPATCH(IsBufferARB, (buffer), (F, "glIsBufferARB(%d);\n", buffer));
+}
+
+KEYWORD1 GLvoid * KEYWORD2 NAME(MapBuffer)(GLenum target, GLenum access)
+{
+ RETURN_DISPATCH(MapBufferARB, (target, access), (F, "glMapBuffer(0x%x, 0x%x);\n", target, access));
+}
+
+KEYWORD1 GLvoid * KEYWORD2 NAME(MapBufferARB)(GLenum target, GLenum access)
+{
+ RETURN_DISPATCH(MapBufferARB, (target, access), (F, "glMapBufferARB(0x%x, 0x%x);\n", target, access));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(UnmapBuffer)(GLenum target)
+{
+ RETURN_DISPATCH(UnmapBufferARB, (target), (F, "glUnmapBuffer(0x%x);\n", target));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(UnmapBufferARB)(GLenum target)
+{
+ RETURN_DISPATCH(UnmapBufferARB, (target), (F, "glUnmapBufferARB(0x%x);\n", target));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DepthBoundsEXT)(GLclampd zmin, GLclampd zmax)
+{
+ DISPATCH(DepthBoundsEXT, (zmin, zmax), (F, "glDepthBoundsEXT(%f, %f);\n", zmin, zmax));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GenQueries)(GLsizei n, GLuint * ids)
+{
+ DISPATCH(GenQueriesARB, (n, ids), (F, "glGenQueries(%d, %p);\n", n, (const void *) ids));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GenQueriesARB)(GLsizei n, GLuint * ids)
+{
+ DISPATCH(GenQueriesARB, (n, ids), (F, "glGenQueriesARB(%d, %p);\n", n, (const void *) ids));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DeleteQueries)(GLsizei n, const GLuint * ids)
+{
+ DISPATCH(DeleteQueriesARB, (n, ids), (F, "glDeleteQueries(%d, %p);\n", n, (const void *) ids));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DeleteQueriesARB)(GLsizei n, const GLuint * ids)
+{
+ DISPATCH(DeleteQueriesARB, (n, ids), (F, "glDeleteQueriesARB(%d, %p);\n", n, (const void *) ids));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(IsQuery)(GLuint id)
+{
+ RETURN_DISPATCH(IsQueryARB, (id), (F, "glIsQuery(%d);\n", id));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(IsQueryARB)(GLuint id)
+{
+ RETURN_DISPATCH(IsQueryARB, (id), (F, "glIsQueryARB(%d);\n", id));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BeginQuery)(GLenum target, GLuint id)
+{
+ DISPATCH(BeginQueryARB, (target, id), (F, "glBeginQuery(0x%x, %d);\n", target, id));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BeginQueryARB)(GLenum target, GLuint id)
+{
+ DISPATCH(BeginQueryARB, (target, id), (F, "glBeginQueryARB(0x%x, %d);\n", target, id));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EndQuery)(GLenum target)
+{
+ DISPATCH(EndQueryARB, (target), (F, "glEndQuery(0x%x);\n", target));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EndQueryARB)(GLenum target)
+{
+ DISPATCH(EndQueryARB, (target), (F, "glEndQueryARB(0x%x);\n", target));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetQueryiv)(GLenum target, GLenum pname, GLint * params)
+{
+ DISPATCH(GetQueryivARB, (target, pname, params), (F, "glGetQueryiv(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetQueryivARB)(GLenum target, GLenum pname, GLint * params)
+{
+ DISPATCH(GetQueryivARB, (target, pname, params), (F, "glGetQueryivARB(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetQueryObjectiv)(GLuint id, GLenum pname, GLint * params)
+{
+ DISPATCH(GetQueryObjectivARB, (id, pname, params), (F, "glGetQueryObjectiv(%d, 0x%x, %p);\n", id, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetQueryObjectivARB)(GLuint id, GLenum pname, GLint * params)
+{
+ DISPATCH(GetQueryObjectivARB, (id, pname, params), (F, "glGetQueryObjectivARB(%d, 0x%x, %p);\n", id, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetQueryObjectuiv)(GLuint id, GLenum pname, GLuint * params)
+{
+ DISPATCH(GetQueryObjectuivARB, (id, pname, params), (F, "glGetQueryObjectuiv(%d, 0x%x, %p);\n", id, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetQueryObjectuivARB)(GLuint id, GLenum pname, GLuint * params)
+{
+ DISPATCH(GetQueryObjectuivARB, (id, pname, params), (F, "glGetQueryObjectuivARB(%d, 0x%x, %p);\n", id, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiModeDrawArraysIBM)(const GLenum * mode, const GLint * first, const GLsizei * count, GLsizei primcount, GLint modestride)
+{
+ DISPATCH(MultiModeDrawArraysIBM, (mode, first, count, primcount, modestride), (F, "glMultiModeDrawArraysIBM(%p, %p, %p, %d, %d);\n", (const void *) mode, (const void *) first, (const void *) count, primcount, modestride));
+}
+
+KEYWORD1 void KEYWORD2 NAME(MultiModeDrawElementsIBM)(const GLenum * mode, const GLsizei * count, GLenum type, const GLvoid * const * indices, GLsizei primcount, GLint modestride)
+{
+ DISPATCH(MultiModeDrawElementsIBM, (mode, count, type, indices, primcount, modestride), (F, "glMultiModeDrawElementsIBM(%p, %p, 0x%x, %p, %d, %d);\n", (const void *) mode, (const void *) count, type, (const void *) indices, primcount, modestride));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BlendEquationSeparateEXT)(GLenum modeRGB, GLenum modeA)
+{
+ DISPATCH(BlendEquationSeparateEXT, (modeRGB, modeA), (F, "glBlendEquationSeparateEXT(0x%x, 0x%x);\n", modeRGB, modeA));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BlendEquationSeparateATI)(GLenum modeRGB, GLenum modeA)
+{
+ DISPATCH(BlendEquationSeparateEXT, (modeRGB, modeA), (F, "glBlendEquationSeparateATI(0x%x, 0x%x);\n", modeRGB, modeA));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DeleteObjectARB)(GLhandleARB obj)
+{
+ DISPATCH(DeleteObjectARB, (obj), (F, "glDeleteObjectARB(%d);\n", obj));
+}
+
+KEYWORD1 GLhandleARB KEYWORD2 NAME(GetHandleARB)(GLenum pname)
+{
+ RETURN_DISPATCH(GetHandleARB, (pname), (F, "glGetHandleARB(0x%x);\n", pname));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DetachObjectARB)(GLhandleARB containerObj, GLhandleARB attachedObj)
+{
+ DISPATCH(DetachObjectARB, (containerObj, attachedObj), (F, "glDetachObjectARB(%d, %d);\n", containerObj, attachedObj));
+}
+
+KEYWORD1 GLhandleARB KEYWORD2 NAME(CreateShaderObjectARB)(GLenum shaderType)
+{
+ RETURN_DISPATCH(CreateShaderObjectARB, (shaderType), (F, "glCreateShaderObjectARB(0x%x);\n", shaderType));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ShaderSourceARB)(GLhandleARB shaderObj, GLsizei count, const GLcharARB ** string, const GLint * length)
+{
+ DISPATCH(ShaderSourceARB, (shaderObj, count, string, length), (F, "glShaderSourceARB(%d, %d, %p, %p);\n", shaderObj, count, (const void *) string, (const void *) length));
+}
+
+KEYWORD1 void KEYWORD2 NAME(CompileShaderARB)(GLhandleARB shaderObj)
+{
+ DISPATCH(CompileShaderARB, (shaderObj), (F, "glCompileShaderARB(%d);\n", shaderObj));
+}
+
+KEYWORD1 GLhandleARB KEYWORD2 NAME(CreateProgramObjectARB)(void)
+{
+ RETURN_DISPATCH(CreateProgramObjectARB, (), (F, "glCreateProgramObjectARB();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(AttachObjectARB)(GLhandleARB containerObj, GLhandleARB obj)
+{
+ DISPATCH(AttachObjectARB, (containerObj, obj), (F, "glAttachObjectARB(%d, %d);\n", containerObj, obj));
+}
+
+KEYWORD1 void KEYWORD2 NAME(LinkProgramARB)(GLhandleARB programObj)
+{
+ DISPATCH(LinkProgramARB, (programObj), (F, "glLinkProgramARB(%d);\n", programObj));
+}
+
+KEYWORD1 void KEYWORD2 NAME(UseProgramObjectARB)(GLhandleARB programObj)
+{
+ DISPATCH(UseProgramObjectARB, (programObj), (F, "glUseProgramObjectARB(%d);\n", programObj));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ValidateProgramARB)(GLhandleARB programObj)
+{
+ DISPATCH(ValidateProgramARB, (programObj), (F, "glValidateProgramARB(%d);\n", programObj));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Uniform1fARB)(GLint location, GLfloat v0)
+{
+ DISPATCH(Uniform1fARB, (location, v0), (F, "glUniform1fARB(%d, %f);\n", location, v0));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Uniform2fARB)(GLint location, GLfloat v0, GLfloat v1)
+{
+ DISPATCH(Uniform2fARB, (location, v0, v1), (F, "glUniform2fARB(%d, %f, %f);\n", location, v0, v1));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Uniform3fARB)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
+{
+ DISPATCH(Uniform3fARB, (location, v0, v1, v2), (F, "glUniform3fARB(%d, %f, %f, %f);\n", location, v0, v1, v2));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Uniform4fARB)(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
+{
+ DISPATCH(Uniform4fARB, (location, v0, v1, v2, v3), (F, "glUniform4fARB(%d, %f, %f, %f, %f);\n", location, v0, v1, v2, v3));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Uniform1iARB)(GLint location, GLint v0)
+{
+ DISPATCH(Uniform1iARB, (location, v0), (F, "glUniform1iARB(%d, %d);\n", location, v0));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Uniform2iARB)(GLint location, GLint v0, GLint v1)
+{
+ DISPATCH(Uniform2iARB, (location, v0, v1), (F, "glUniform2iARB(%d, %d, %d);\n", location, v0, v1));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Uniform3iARB)(GLint location, GLint v0, GLint v1, GLint v2)
+{
+ DISPATCH(Uniform3iARB, (location, v0, v1, v2), (F, "glUniform3iARB(%d, %d, %d, %d);\n", location, v0, v1, v2));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Uniform4iARB)(GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
+{
+ DISPATCH(Uniform4iARB, (location, v0, v1, v2, v3), (F, "glUniform4iARB(%d, %d, %d, %d, %d);\n", location, v0, v1, v2, v3));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Uniform1fvARB)(GLint location, GLsizei count, const GLfloat * value)
+{
+ DISPATCH(Uniform1fvARB, (location, count, value), (F, "glUniform1fvARB(%d, %d, %p);\n", location, count, (const void *) value));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Uniform2fvARB)(GLint location, GLsizei count, const GLfloat * value)
+{
+ DISPATCH(Uniform2fvARB, (location, count, value), (F, "glUniform2fvARB(%d, %d, %p);\n", location, count, (const void *) value));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Uniform3fvARB)(GLint location, GLsizei count, const GLfloat * value)
+{
+ DISPATCH(Uniform3fvARB, (location, count, value), (F, "glUniform3fvARB(%d, %d, %p);\n", location, count, (const void *) value));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Uniform4fvARB)(GLint location, GLsizei count, const GLfloat * value)
+{
+ DISPATCH(Uniform4fvARB, (location, count, value), (F, "glUniform4fvARB(%d, %d, %p);\n", location, count, (const void *) value));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Uniform1ivARB)(GLint location, GLsizei count, const GLint * value)
+{
+ DISPATCH(Uniform1ivARB, (location, count, value), (F, "glUniform1ivARB(%d, %d, %p);\n", location, count, (const void *) value));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Uniform2ivARB)(GLint location, GLsizei count, const GLint * value)
+{
+ DISPATCH(Uniform2ivARB, (location, count, value), (F, "glUniform2ivARB(%d, %d, %p);\n", location, count, (const void *) value));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Uniform3ivARB)(GLint location, GLsizei count, const GLint * value)
+{
+ DISPATCH(Uniform3ivARB, (location, count, value), (F, "glUniform3ivARB(%d, %d, %p);\n", location, count, (const void *) value));
+}
+
+KEYWORD1 void KEYWORD2 NAME(Uniform4ivARB)(GLint location, GLsizei count, const GLint * value)
+{
+ DISPATCH(Uniform4ivARB, (location, count, value), (F, "glUniform4ivARB(%d, %d, %p);\n", location, count, (const void *) value));
+}
+
+KEYWORD1 void KEYWORD2 NAME(UniformMatrix2fvARB)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+{
+ DISPATCH(UniformMatrix2fvARB, (location, count, transpose, value), (F, "glUniformMatrix2fvARB(%d, %d, %d, %p);\n", location, count, transpose, (const void *) value));
+}
+
+KEYWORD1 void KEYWORD2 NAME(UniformMatrix3fvARB)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+{
+ DISPATCH(UniformMatrix3fvARB, (location, count, transpose, value), (F, "glUniformMatrix3fvARB(%d, %d, %d, %p);\n", location, count, transpose, (const void *) value));
+}
+
+KEYWORD1 void KEYWORD2 NAME(UniformMatrix4fvARB)(GLint location, GLsizei count, GLboolean transpose, const GLfloat * value)
+{
+ DISPATCH(UniformMatrix4fvARB, (location, count, transpose, value), (F, "glUniformMatrix4fvARB(%d, %d, %d, %p);\n", location, count, transpose, (const void *) value));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetObjectParameterfvARB)(GLhandleARB obj, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetObjectParameterfvARB, (obj, pname, params), (F, "glGetObjectParameterfvARB(%d, 0x%x, %p);\n", obj, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetObjectParameterivARB)(GLhandleARB obj, GLenum pname, GLint * params)
+{
+ DISPATCH(GetObjectParameterivARB, (obj, pname, params), (F, "glGetObjectParameterivARB(%d, 0x%x, %p);\n", obj, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetInfoLogARB)(GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * infoLog)
+{
+ DISPATCH(GetInfoLogARB, (obj, maxLength, length, infoLog), (F, "glGetInfoLogARB(%d, %d, %p, %p);\n", obj, maxLength, (const void *) length, (const void *) infoLog));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetAttachedObjectsARB)(GLhandleARB containerObj, GLsizei maxLength, GLsizei * length, GLhandleARB * infoLog)
+{
+ DISPATCH(GetAttachedObjectsARB, (containerObj, maxLength, length, infoLog), (F, "glGetAttachedObjectsARB(%d, %d, %p, %p);\n", containerObj, maxLength, (const void *) length, (const void *) infoLog));
+}
+
+KEYWORD1 GLint KEYWORD2 NAME(GetUniformLocationARB)(GLhandleARB programObj, const GLcharARB * name)
+{
+ RETURN_DISPATCH(GetUniformLocationARB, (programObj, name), (F, "glGetUniformLocationARB(%d, %p);\n", programObj, (const void *) name));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetActiveUniformARB)(GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei * length, GLint * size, GLenum * type, GLcharARB * name)
+{
+ DISPATCH(GetActiveUniformARB, (programObj, index, maxLength, length, size, type, name), (F, "glGetActiveUniformARB(%d, %d, %d, %p, %p, %p, %p);\n", programObj, index, maxLength, (const void *) length, (const void *) size, (const void *) type, (const void *) name));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetUniformfvARB)(GLhandleARB programObj, GLint location, GLfloat * params)
+{
+ DISPATCH(GetUniformfvARB, (programObj, location, params), (F, "glGetUniformfvARB(%d, %d, %p);\n", programObj, location, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetUniformivARB)(GLhandleARB programObj, GLint location, GLint * params)
+{
+ DISPATCH(GetUniformivARB, (programObj, location, params), (F, "glGetUniformivARB(%d, %d, %p);\n", programObj, location, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetShaderSourceARB)(GLhandleARB obj, GLsizei maxLength, GLsizei * length, GLcharARB * source)
+{
+ DISPATCH(GetShaderSourceARB, (obj, maxLength, length, source), (F, "glGetShaderSourceARB(%d, %d, %p, %p);\n", obj, maxLength, (const void *) length, (const void *) source));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BindAttribLocationARB)(GLhandleARB programObj, GLuint index, const GLcharARB * name)
+{
+ DISPATCH(BindAttribLocationARB, (programObj, index, name), (F, "glBindAttribLocationARB(%d, %d, %p);\n", programObj, index, (const void *) name));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetActiveAttribARB)(GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei * length, GLint * size, GLenum * type, GLcharARB * name)
+{
+ DISPATCH(GetActiveAttribARB, (programObj, index, maxLength, length, size, type, name), (F, "glGetActiveAttribARB(%d, %d, %d, %p, %p, %p, %p);\n", programObj, index, maxLength, (const void *) length, (const void *) size, (const void *) type, (const void *) name));
+}
+
+KEYWORD1 GLint KEYWORD2 NAME(GetAttribLocationARB)(GLhandleARB programObj, const GLcharARB * name)
+{
+ RETURN_DISPATCH(GetAttribLocationARB, (programObj, name), (F, "glGetAttribLocationARB(%d, %p);\n", programObj, (const void *) name));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetVertexAttribdvNV)(GLuint index, GLenum pname, GLdouble * params)
+{
+ DISPATCH(GetVertexAttribdvNV, (index, pname, params), (F, "glGetVertexAttribdvNV(%d, 0x%x, %p);\n", index, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetVertexAttribfvNV)(GLuint index, GLenum pname, GLfloat * params)
+{
+ DISPATCH(GetVertexAttribfvNV, (index, pname, params), (F, "glGetVertexAttribfvNV(%d, 0x%x, %p);\n", index, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetVertexAttribivNV)(GLuint index, GLenum pname, GLint * params)
+{
+ DISPATCH(GetVertexAttribivNV, (index, pname, params), (F, "glGetVertexAttribivNV(%d, 0x%x, %p);\n", index, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib1dNV)(GLuint index, GLdouble x)
+{
+ DISPATCH(VertexAttrib1dNV, (index, x), (F, "glVertexAttrib1dNV(%d, %f);\n", index, x));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib1dvNV)(GLuint index, const GLdouble * v)
+{
+ DISPATCH(VertexAttrib1dvNV, (index, v), (F, "glVertexAttrib1dvNV(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib1fNV)(GLuint index, GLfloat x)
+{
+ DISPATCH(VertexAttrib1fNV, (index, x), (F, "glVertexAttrib1fNV(%d, %f);\n", index, x));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib1fvNV)(GLuint index, const GLfloat * v)
+{
+ DISPATCH(VertexAttrib1fvNV, (index, v), (F, "glVertexAttrib1fvNV(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib1sNV)(GLuint index, GLshort x)
+{
+ DISPATCH(VertexAttrib1sNV, (index, x), (F, "glVertexAttrib1sNV(%d, %d);\n", index, x));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib1svNV)(GLuint index, const GLshort * v)
+{
+ DISPATCH(VertexAttrib1svNV, (index, v), (F, "glVertexAttrib1svNV(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib2dNV)(GLuint index, GLdouble x, GLdouble y)
+{
+ DISPATCH(VertexAttrib2dNV, (index, x, y), (F, "glVertexAttrib2dNV(%d, %f, %f);\n", index, x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib2dvNV)(GLuint index, const GLdouble * v)
+{
+ DISPATCH(VertexAttrib2dvNV, (index, v), (F, "glVertexAttrib2dvNV(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib2fNV)(GLuint index, GLfloat x, GLfloat y)
+{
+ DISPATCH(VertexAttrib2fNV, (index, x, y), (F, "glVertexAttrib2fNV(%d, %f, %f);\n", index, x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib2fvNV)(GLuint index, const GLfloat * v)
+{
+ DISPATCH(VertexAttrib2fvNV, (index, v), (F, "glVertexAttrib2fvNV(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib2sNV)(GLuint index, GLshort x, GLshort y)
+{
+ DISPATCH(VertexAttrib2sNV, (index, x, y), (F, "glVertexAttrib2sNV(%d, %d, %d);\n", index, x, y));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib2svNV)(GLuint index, const GLshort * v)
+{
+ DISPATCH(VertexAttrib2svNV, (index, v), (F, "glVertexAttrib2svNV(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib3dNV)(GLuint index, GLdouble x, GLdouble y, GLdouble z)
+{
+ DISPATCH(VertexAttrib3dNV, (index, x, y, z), (F, "glVertexAttrib3dNV(%d, %f, %f, %f);\n", index, x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib3dvNV)(GLuint index, const GLdouble * v)
+{
+ DISPATCH(VertexAttrib3dvNV, (index, v), (F, "glVertexAttrib3dvNV(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib3fNV)(GLuint index, GLfloat x, GLfloat y, GLfloat z)
+{
+ DISPATCH(VertexAttrib3fNV, (index, x, y, z), (F, "glVertexAttrib3fNV(%d, %f, %f, %f);\n", index, x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib3fvNV)(GLuint index, const GLfloat * v)
+{
+ DISPATCH(VertexAttrib3fvNV, (index, v), (F, "glVertexAttrib3fvNV(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib3sNV)(GLuint index, GLshort x, GLshort y, GLshort z)
+{
+ DISPATCH(VertexAttrib3sNV, (index, x, y, z), (F, "glVertexAttrib3sNV(%d, %d, %d, %d);\n", index, x, y, z));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib3svNV)(GLuint index, const GLshort * v)
+{
+ DISPATCH(VertexAttrib3svNV, (index, v), (F, "glVertexAttrib3svNV(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4dNV)(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ DISPATCH(VertexAttrib4dNV, (index, x, y, z, w), (F, "glVertexAttrib4dNV(%d, %f, %f, %f, %f);\n", index, x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4dvNV)(GLuint index, const GLdouble * v)
+{
+ DISPATCH(VertexAttrib4dvNV, (index, v), (F, "glVertexAttrib4dvNV(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4fNV)(GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ DISPATCH(VertexAttrib4fNV, (index, x, y, z, w), (F, "glVertexAttrib4fNV(%d, %f, %f, %f, %f);\n", index, x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4fvNV)(GLuint index, const GLfloat * v)
+{
+ DISPATCH(VertexAttrib4fvNV, (index, v), (F, "glVertexAttrib4fvNV(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4sNV)(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w)
+{
+ DISPATCH(VertexAttrib4sNV, (index, x, y, z, w), (F, "glVertexAttrib4sNV(%d, %d, %d, %d, %d);\n", index, x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4svNV)(GLuint index, const GLshort * v)
+{
+ DISPATCH(VertexAttrib4svNV, (index, v), (F, "glVertexAttrib4svNV(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4ubNV)(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w)
+{
+ DISPATCH(VertexAttrib4ubNV, (index, x, y, z, w), (F, "glVertexAttrib4ubNV(%d, %d, %d, %d, %d);\n", index, x, y, z, w));
+}
+
+KEYWORD1 void KEYWORD2 NAME(VertexAttrib4ubvNV)(GLuint index, const GLubyte * v)
+{
+ DISPATCH(VertexAttrib4ubvNV, (index, v), (F, "glVertexAttrib4ubvNV(%d, %p);\n", index, (const void *) v));
+}
+
+KEYWORD1 GLuint KEYWORD2 NAME(GenFragmentShadersATI)(GLuint range)
+{
+ RETURN_DISPATCH(GenFragmentShadersATI, (range), (F, "glGenFragmentShadersATI(%d);\n", range));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BindFragmentShaderATI)(GLuint id)
+{
+ DISPATCH(BindFragmentShaderATI, (id), (F, "glBindFragmentShaderATI(%d);\n", id));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DeleteFragmentShaderATI)(GLuint id)
+{
+ DISPATCH(DeleteFragmentShaderATI, (id), (F, "glDeleteFragmentShaderATI(%d);\n", id));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BeginFragmentShaderATI)(void)
+{
+ DISPATCH(BeginFragmentShaderATI, (), (F, "glBeginFragmentShaderATI();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(EndFragmentShaderATI)(void)
+{
+ DISPATCH(EndFragmentShaderATI, (), (F, "glEndFragmentShaderATI();\n"));
+}
+
+KEYWORD1 void KEYWORD2 NAME(PassTexCoordATI)(GLuint dst, GLuint coord, GLenum swizzle)
+{
+ DISPATCH(PassTexCoordATI, (dst, coord, swizzle), (F, "glPassTexCoordATI(%d, %d, 0x%x);\n", dst, coord, swizzle));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SampleMapATI)(GLuint dst, GLuint interp, GLenum swizzle)
+{
+ DISPATCH(SampleMapATI, (dst, interp, swizzle), (F, "glSampleMapATI(%d, %d, 0x%x);\n", dst, interp, swizzle));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ColorFragmentOp1ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod)
+{
+ DISPATCH(ColorFragmentOp1ATI, (op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod), (F, "glColorFragmentOp1ATI(0x%x, %d, %d, %d, %d, %d, %d);\n", op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ColorFragmentOp2ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod)
+{
+ DISPATCH(ColorFragmentOp2ATI, (op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod), (F, "glColorFragmentOp2ATI(0x%x, %d, %d, %d, %d, %d, %d, %d, %d, %d);\n", op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod));
+}
+
+KEYWORD1 void KEYWORD2 NAME(ColorFragmentOp3ATI)(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod)
+{
+ DISPATCH(ColorFragmentOp3ATI, (op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod), (F, "glColorFragmentOp3ATI(0x%x, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d);\n", op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod));
+}
+
+KEYWORD1 void KEYWORD2 NAME(AlphaFragmentOp1ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod)
+{
+ DISPATCH(AlphaFragmentOp1ATI, (op, dst, dstMod, arg1, arg1Rep, arg1Mod), (F, "glAlphaFragmentOp1ATI(0x%x, %d, %d, %d, %d, %d);\n", op, dst, dstMod, arg1, arg1Rep, arg1Mod));
+}
+
+KEYWORD1 void KEYWORD2 NAME(AlphaFragmentOp2ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod)
+{
+ DISPATCH(AlphaFragmentOp2ATI, (op, dst, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod), (F, "glAlphaFragmentOp2ATI(0x%x, %d, %d, %d, %d, %d, %d, %d, %d);\n", op, dst, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod));
+}
+
+KEYWORD1 void KEYWORD2 NAME(AlphaFragmentOp3ATI)(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod)
+{
+ DISPATCH(AlphaFragmentOp3ATI, (op, dst, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod), (F, "glAlphaFragmentOp3ATI(0x%x, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d);\n", op, dst, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod));
+}
+
+KEYWORD1 void KEYWORD2 NAME(SetFragmentShaderConstantATI)(GLuint dst, const GLfloat * value)
+{
+ DISPATCH(SetFragmentShaderConstantATI, (dst, value), (F, "glSetFragmentShaderConstantATI(%d, %p);\n", dst, (const void *) value));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(IsRenderbufferEXT)(GLuint renderbuffer)
+{
+ RETURN_DISPATCH(IsRenderbufferEXT, (renderbuffer), (F, "glIsRenderbufferEXT(%d);\n", renderbuffer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BindRenderbufferEXT)(GLenum target, GLuint renderbuffer)
+{
+ DISPATCH(BindRenderbufferEXT, (target, renderbuffer), (F, "glBindRenderbufferEXT(0x%x, %d);\n", target, renderbuffer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DeleteRenderbuffersEXT)(GLsizei n, const GLuint * renderbuffers)
+{
+ DISPATCH(DeleteRenderbuffersEXT, (n, renderbuffers), (F, "glDeleteRenderbuffersEXT(%d, %p);\n", n, (const void *) renderbuffers));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GenRenderbuffersEXT)(GLsizei n, GLuint * renderbuffers)
+{
+ DISPATCH(GenRenderbuffersEXT, (n, renderbuffers), (F, "glGenRenderbuffersEXT(%d, %p);\n", n, (const void *) renderbuffers));
+}
+
+KEYWORD1 void KEYWORD2 NAME(RenderbufferStorageEXT)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height)
+{
+ DISPATCH(RenderbufferStorageEXT, (target, internalformat, width, height), (F, "glRenderbufferStorageEXT(0x%x, 0x%x, %d, %d);\n", target, internalformat, width, height));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetRenderbufferParameterivEXT)(GLenum target, GLenum pname, GLint * params)
+{
+ DISPATCH(GetRenderbufferParameterivEXT, (target, pname, params), (F, "glGetRenderbufferParameterivEXT(0x%x, 0x%x, %p);\n", target, pname, (const void *) params));
+}
+
+KEYWORD1 GLboolean KEYWORD2 NAME(IsFramebufferEXT)(GLuint framebuffer)
+{
+ RETURN_DISPATCH(IsFramebufferEXT, (framebuffer), (F, "glIsFramebufferEXT(%d);\n", framebuffer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(BindFramebufferEXT)(GLenum target, GLuint framebuffer)
+{
+ DISPATCH(BindFramebufferEXT, (target, framebuffer), (F, "glBindFramebufferEXT(0x%x, %d);\n", target, framebuffer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(DeleteFramebuffersEXT)(GLsizei n, const GLuint * framebuffers)
+{
+ DISPATCH(DeleteFramebuffersEXT, (n, framebuffers), (F, "glDeleteFramebuffersEXT(%d, %p);\n", n, (const void *) framebuffers));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GenFramebuffersEXT)(GLsizei n, GLuint * framebuffers)
+{
+ DISPATCH(GenFramebuffersEXT, (n, framebuffers), (F, "glGenFramebuffersEXT(%d, %p);\n", n, (const void *) framebuffers));
+}
+
+KEYWORD1 GLenum KEYWORD2 NAME(CheckFramebufferStatusEXT)(GLenum target)
+{
+ RETURN_DISPATCH(CheckFramebufferStatusEXT, (target), (F, "glCheckFramebufferStatusEXT(0x%x);\n", target));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FramebufferTexture1DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+ DISPATCH(FramebufferTexture1DEXT, (target, attachment, textarget, texture, level), (F, "glFramebufferTexture1DEXT(0x%x, 0x%x, 0x%x, %d, %d);\n", target, attachment, textarget, texture, level));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FramebufferTexture2DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)
+{
+ DISPATCH(FramebufferTexture2DEXT, (target, attachment, textarget, texture, level), (F, "glFramebufferTexture2DEXT(0x%x, 0x%x, 0x%x, %d, %d);\n", target, attachment, textarget, texture, level));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FramebufferTexture3DEXT)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset)
+{
+ DISPATCH(FramebufferTexture3DEXT, (target, attachment, textarget, texture, level, zoffset), (F, "glFramebufferTexture3DEXT(0x%x, 0x%x, 0x%x, %d, %d, %d);\n", target, attachment, textarget, texture, level, zoffset));
+}
+
+KEYWORD1 void KEYWORD2 NAME(FramebufferRenderbufferEXT)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer)
+{
+ DISPATCH(FramebufferRenderbufferEXT, (target, attachment, renderbuffertarget, renderbuffer), (F, "glFramebufferRenderbufferEXT(0x%x, 0x%x, 0x%x, %d);\n", target, attachment, renderbuffertarget, renderbuffer));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GetFramebufferAttachmentParameterivEXT)(GLenum target, GLenum attachment, GLenum pname, GLint * params)
+{
+ DISPATCH(GetFramebufferAttachmentParameterivEXT, (target, attachment, pname, params), (F, "glGetFramebufferAttachmentParameterivEXT(0x%x, 0x%x, 0x%x, %p);\n", target, attachment, pname, (const void *) params));
+}
+
+KEYWORD1 void KEYWORD2 NAME(GenerateMipmapEXT)(GLenum target)
+{
+ DISPATCH(GenerateMipmapEXT, (target), (F, "glGenerateMipmapEXT(0x%x);\n", target));
+}
+
+KEYWORD1 void KEYWORD2 NAME(StencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask)
+{
+ DISPATCH(StencilFuncSeparate, (face, func, ref, mask), (F, "glStencilFuncSeparate(0x%x, 0x%x, %d, %d);\n", face, func, ref, mask));
+}
+
+KEYWORD1 void KEYWORD2 NAME(StencilOpSeparate)(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+{
+ DISPATCH(StencilOpSeparate, (face, fail, zfail, zpass), (F, "glStencilOpSeparate(0x%x, 0x%x, 0x%x, 0x%x);\n", face, fail, zfail, zpass));
+}
+
+KEYWORD1 void KEYWORD2 NAME(StencilMaskSeparate)(GLenum face, GLuint mask)
+{
+ DISPATCH(StencilMaskSeparate, (face, mask), (F, "glStencilMaskSeparate(0x%x, %d);\n", face, mask));
+}
+
+
+#endif /* defined( NAME ) */
+
+/*
+ * This is how a dispatch table can be initialized with all the functions
+ * we generated above.
+ */
+#ifdef DISPATCH_TABLE_NAME
+
+#ifndef TABLE_ENTRY
+#error TABLE_ENTRY must be defined
+#endif
+
+static _glapi_proc DISPATCH_TABLE_NAME[] = {
+ TABLE_ENTRY(NewList),
+ TABLE_ENTRY(EndList),
+ TABLE_ENTRY(CallList),
+ TABLE_ENTRY(CallLists),
+ TABLE_ENTRY(DeleteLists),
+ TABLE_ENTRY(GenLists),
+ TABLE_ENTRY(ListBase),
+ TABLE_ENTRY(Begin),
+ TABLE_ENTRY(Bitmap),
+ TABLE_ENTRY(Color3b),
+ TABLE_ENTRY(Color3bv),
+ TABLE_ENTRY(Color3d),
+ TABLE_ENTRY(Color3dv),
+ TABLE_ENTRY(Color3f),
+ TABLE_ENTRY(Color3fv),
+ TABLE_ENTRY(Color3i),
+ TABLE_ENTRY(Color3iv),
+ TABLE_ENTRY(Color3s),
+ TABLE_ENTRY(Color3sv),
+ TABLE_ENTRY(Color3ub),
+ TABLE_ENTRY(Color3ubv),
+ TABLE_ENTRY(Color3ui),
+ TABLE_ENTRY(Color3uiv),
+ TABLE_ENTRY(Color3us),
+ TABLE_ENTRY(Color3usv),
+ TABLE_ENTRY(Color4b),
+ TABLE_ENTRY(Color4bv),
+ TABLE_ENTRY(Color4d),
+ TABLE_ENTRY(Color4dv),
+ TABLE_ENTRY(Color4f),
+ TABLE_ENTRY(Color4fv),
+ TABLE_ENTRY(Color4i),
+ TABLE_ENTRY(Color4iv),
+ TABLE_ENTRY(Color4s),
+ TABLE_ENTRY(Color4sv),
+ TABLE_ENTRY(Color4ub),
+ TABLE_ENTRY(Color4ubv),
+ TABLE_ENTRY(Color4ui),
+ TABLE_ENTRY(Color4uiv),
+ TABLE_ENTRY(Color4us),
+ TABLE_ENTRY(Color4usv),
+ TABLE_ENTRY(EdgeFlag),
+ TABLE_ENTRY(EdgeFlagv),
+ TABLE_ENTRY(End),
+ TABLE_ENTRY(Indexd),
+ TABLE_ENTRY(Indexdv),
+ TABLE_ENTRY(Indexf),
+ TABLE_ENTRY(Indexfv),
+ TABLE_ENTRY(Indexi),
+ TABLE_ENTRY(Indexiv),
+ TABLE_ENTRY(Indexs),
+ TABLE_ENTRY(Indexsv),
+ TABLE_ENTRY(Normal3b),
+ TABLE_ENTRY(Normal3bv),
+ TABLE_ENTRY(Normal3d),
+ TABLE_ENTRY(Normal3dv),
+ TABLE_ENTRY(Normal3f),
+ TABLE_ENTRY(Normal3fv),
+ TABLE_ENTRY(Normal3i),
+ TABLE_ENTRY(Normal3iv),
+ TABLE_ENTRY(Normal3s),
+ TABLE_ENTRY(Normal3sv),
+ TABLE_ENTRY(RasterPos2d),
+ TABLE_ENTRY(RasterPos2dv),
+ TABLE_ENTRY(RasterPos2f),
+ TABLE_ENTRY(RasterPos2fv),
+ TABLE_ENTRY(RasterPos2i),
+ TABLE_ENTRY(RasterPos2iv),
+ TABLE_ENTRY(RasterPos2s),
+ TABLE_ENTRY(RasterPos2sv),
+ TABLE_ENTRY(RasterPos3d),
+ TABLE_ENTRY(RasterPos3dv),
+ TABLE_ENTRY(RasterPos3f),
+ TABLE_ENTRY(RasterPos3fv),
+ TABLE_ENTRY(RasterPos3i),
+ TABLE_ENTRY(RasterPos3iv),
+ TABLE_ENTRY(RasterPos3s),
+ TABLE_ENTRY(RasterPos3sv),
+ TABLE_ENTRY(RasterPos4d),
+ TABLE_ENTRY(RasterPos4dv),
+ TABLE_ENTRY(RasterPos4f),
+ TABLE_ENTRY(RasterPos4fv),
+ TABLE_ENTRY(RasterPos4i),
+ TABLE_ENTRY(RasterPos4iv),
+ TABLE_ENTRY(RasterPos4s),
+ TABLE_ENTRY(RasterPos4sv),
+ TABLE_ENTRY(Rectd),
+ TABLE_ENTRY(Rectdv),
+ TABLE_ENTRY(Rectf),
+ TABLE_ENTRY(Rectfv),
+ TABLE_ENTRY(Recti),
+ TABLE_ENTRY(Rectiv),
+ TABLE_ENTRY(Rects),
+ TABLE_ENTRY(Rectsv),
+ TABLE_ENTRY(TexCoord1d),
+ TABLE_ENTRY(TexCoord1dv),
+ TABLE_ENTRY(TexCoord1f),
+ TABLE_ENTRY(TexCoord1fv),
+ TABLE_ENTRY(TexCoord1i),
+ TABLE_ENTRY(TexCoord1iv),
+ TABLE_ENTRY(TexCoord1s),
+ TABLE_ENTRY(TexCoord1sv),
+ TABLE_ENTRY(TexCoord2d),
+ TABLE_ENTRY(TexCoord2dv),
+ TABLE_ENTRY(TexCoord2f),
+ TABLE_ENTRY(TexCoord2fv),
+ TABLE_ENTRY(TexCoord2i),
+ TABLE_ENTRY(TexCoord2iv),
+ TABLE_ENTRY(TexCoord2s),
+ TABLE_ENTRY(TexCoord2sv),
+ TABLE_ENTRY(TexCoord3d),
+ TABLE_ENTRY(TexCoord3dv),
+ TABLE_ENTRY(TexCoord3f),
+ TABLE_ENTRY(TexCoord3fv),
+ TABLE_ENTRY(TexCoord3i),
+ TABLE_ENTRY(TexCoord3iv),
+ TABLE_ENTRY(TexCoord3s),
+ TABLE_ENTRY(TexCoord3sv),
+ TABLE_ENTRY(TexCoord4d),
+ TABLE_ENTRY(TexCoord4dv),
+ TABLE_ENTRY(TexCoord4f),
+ TABLE_ENTRY(TexCoord4fv),
+ TABLE_ENTRY(TexCoord4i),
+ TABLE_ENTRY(TexCoord4iv),
+ TABLE_ENTRY(TexCoord4s),
+ TABLE_ENTRY(TexCoord4sv),
+ TABLE_ENTRY(Vertex2d),
+ TABLE_ENTRY(Vertex2dv),
+ TABLE_ENTRY(Vertex2f),
+ TABLE_ENTRY(Vertex2fv),
+ TABLE_ENTRY(Vertex2i),
+ TABLE_ENTRY(Vertex2iv),
+ TABLE_ENTRY(Vertex2s),
+ TABLE_ENTRY(Vertex2sv),
+ TABLE_ENTRY(Vertex3d),
+ TABLE_ENTRY(Vertex3dv),
+ TABLE_ENTRY(Vertex3f),
+ TABLE_ENTRY(Vertex3fv),
+ TABLE_ENTRY(Vertex3i),
+ TABLE_ENTRY(Vertex3iv),
+ TABLE_ENTRY(Vertex3s),
+ TABLE_ENTRY(Vertex3sv),
+ TABLE_ENTRY(Vertex4d),
+ TABLE_ENTRY(Vertex4dv),
+ TABLE_ENTRY(Vertex4f),
+ TABLE_ENTRY(Vertex4fv),
+ TABLE_ENTRY(Vertex4i),
+ TABLE_ENTRY(Vertex4iv),
+ TABLE_ENTRY(Vertex4s),
+ TABLE_ENTRY(Vertex4sv),
+ TABLE_ENTRY(ClipPlane),
+ TABLE_ENTRY(ColorMaterial),
+ TABLE_ENTRY(CullFace),
+ TABLE_ENTRY(Fogf),
+ TABLE_ENTRY(Fogfv),
+ TABLE_ENTRY(Fogi),
+ TABLE_ENTRY(Fogiv),
+ TABLE_ENTRY(FrontFace),
+ TABLE_ENTRY(Hint),
+ TABLE_ENTRY(Lightf),
+ TABLE_ENTRY(Lightfv),
+ TABLE_ENTRY(Lighti),
+ TABLE_ENTRY(Lightiv),
+ TABLE_ENTRY(LightModelf),
+ TABLE_ENTRY(LightModelfv),
+ TABLE_ENTRY(LightModeli),
+ TABLE_ENTRY(LightModeliv),
+ TABLE_ENTRY(LineStipple),
+ TABLE_ENTRY(LineWidth),
+ TABLE_ENTRY(Materialf),
+ TABLE_ENTRY(Materialfv),
+ TABLE_ENTRY(Materiali),
+ TABLE_ENTRY(Materialiv),
+ TABLE_ENTRY(PointSize),
+ TABLE_ENTRY(PolygonMode),
+ TABLE_ENTRY(PolygonStipple),
+ TABLE_ENTRY(Scissor),
+ TABLE_ENTRY(ShadeModel),
+ TABLE_ENTRY(TexParameterf),
+ TABLE_ENTRY(TexParameterfv),
+ TABLE_ENTRY(TexParameteri),
+ TABLE_ENTRY(TexParameteriv),
+ TABLE_ENTRY(TexImage1D),
+ TABLE_ENTRY(TexImage2D),
+ TABLE_ENTRY(TexEnvf),
+ TABLE_ENTRY(TexEnvfv),
+ TABLE_ENTRY(TexEnvi),
+ TABLE_ENTRY(TexEnviv),
+ TABLE_ENTRY(TexGend),
+ TABLE_ENTRY(TexGendv),
+ TABLE_ENTRY(TexGenf),
+ TABLE_ENTRY(TexGenfv),
+ TABLE_ENTRY(TexGeni),
+ TABLE_ENTRY(TexGeniv),
+ TABLE_ENTRY(FeedbackBuffer),
+ TABLE_ENTRY(SelectBuffer),
+ TABLE_ENTRY(RenderMode),
+ TABLE_ENTRY(InitNames),
+ TABLE_ENTRY(LoadName),
+ TABLE_ENTRY(PassThrough),
+ TABLE_ENTRY(PopName),
+ TABLE_ENTRY(PushName),
+ TABLE_ENTRY(DrawBuffer),
+ TABLE_ENTRY(Clear),
+ TABLE_ENTRY(ClearAccum),
+ TABLE_ENTRY(ClearIndex),
+ TABLE_ENTRY(ClearColor),
+ TABLE_ENTRY(ClearStencil),
+ TABLE_ENTRY(ClearDepth),
+ TABLE_ENTRY(StencilMask),
+ TABLE_ENTRY(ColorMask),
+ TABLE_ENTRY(DepthMask),
+ TABLE_ENTRY(IndexMask),
+ TABLE_ENTRY(Accum),
+ TABLE_ENTRY(Disable),
+ TABLE_ENTRY(Enable),
+ TABLE_ENTRY(Finish),
+ TABLE_ENTRY(Flush),
+ TABLE_ENTRY(PopAttrib),
+ TABLE_ENTRY(PushAttrib),
+ TABLE_ENTRY(Map1d),
+ TABLE_ENTRY(Map1f),
+ TABLE_ENTRY(Map2d),
+ TABLE_ENTRY(Map2f),
+ TABLE_ENTRY(MapGrid1d),
+ TABLE_ENTRY(MapGrid1f),
+ TABLE_ENTRY(MapGrid2d),
+ TABLE_ENTRY(MapGrid2f),
+ TABLE_ENTRY(EvalCoord1d),
+ TABLE_ENTRY(EvalCoord1dv),
+ TABLE_ENTRY(EvalCoord1f),
+ TABLE_ENTRY(EvalCoord1fv),
+ TABLE_ENTRY(EvalCoord2d),
+ TABLE_ENTRY(EvalCoord2dv),
+ TABLE_ENTRY(EvalCoord2f),
+ TABLE_ENTRY(EvalCoord2fv),
+ TABLE_ENTRY(EvalMesh1),
+ TABLE_ENTRY(EvalPoint1),
+ TABLE_ENTRY(EvalMesh2),
+ TABLE_ENTRY(EvalPoint2),
+ TABLE_ENTRY(AlphaFunc),
+ TABLE_ENTRY(BlendFunc),
+ TABLE_ENTRY(LogicOp),
+ TABLE_ENTRY(StencilFunc),
+ TABLE_ENTRY(StencilOp),
+ TABLE_ENTRY(DepthFunc),
+ TABLE_ENTRY(PixelZoom),
+ TABLE_ENTRY(PixelTransferf),
+ TABLE_ENTRY(PixelTransferi),
+ TABLE_ENTRY(PixelStoref),
+ TABLE_ENTRY(PixelStorei),
+ TABLE_ENTRY(PixelMapfv),
+ TABLE_ENTRY(PixelMapuiv),
+ TABLE_ENTRY(PixelMapusv),
+ TABLE_ENTRY(ReadBuffer),
+ TABLE_ENTRY(CopyPixels),
+ TABLE_ENTRY(ReadPixels),
+ TABLE_ENTRY(DrawPixels),
+ TABLE_ENTRY(GetBooleanv),
+ TABLE_ENTRY(GetClipPlane),
+ TABLE_ENTRY(GetDoublev),
+ TABLE_ENTRY(GetError),
+ TABLE_ENTRY(GetFloatv),
+ TABLE_ENTRY(GetIntegerv),
+ TABLE_ENTRY(GetLightfv),
+ TABLE_ENTRY(GetLightiv),
+ TABLE_ENTRY(GetMapdv),
+ TABLE_ENTRY(GetMapfv),
+ TABLE_ENTRY(GetMapiv),
+ TABLE_ENTRY(GetMaterialfv),
+ TABLE_ENTRY(GetMaterialiv),
+ TABLE_ENTRY(GetPixelMapfv),
+ TABLE_ENTRY(GetPixelMapuiv),
+ TABLE_ENTRY(GetPixelMapusv),
+ TABLE_ENTRY(GetPolygonStipple),
+ TABLE_ENTRY(GetString),
+ TABLE_ENTRY(GetTexEnvfv),
+ TABLE_ENTRY(GetTexEnviv),
+ TABLE_ENTRY(GetTexGendv),
+ TABLE_ENTRY(GetTexGenfv),
+ TABLE_ENTRY(GetTexGeniv),
+ TABLE_ENTRY(GetTexImage),
+ TABLE_ENTRY(GetTexParameterfv),
+ TABLE_ENTRY(GetTexParameteriv),
+ TABLE_ENTRY(GetTexLevelParameterfv),
+ TABLE_ENTRY(GetTexLevelParameteriv),
+ TABLE_ENTRY(IsEnabled),
+ TABLE_ENTRY(IsList),
+ TABLE_ENTRY(DepthRange),
+ TABLE_ENTRY(Frustum),
+ TABLE_ENTRY(LoadIdentity),
+ TABLE_ENTRY(LoadMatrixf),
+ TABLE_ENTRY(LoadMatrixd),
+ TABLE_ENTRY(MatrixMode),
+ TABLE_ENTRY(MultMatrixf),
+ TABLE_ENTRY(MultMatrixd),
+ TABLE_ENTRY(Ortho),
+ TABLE_ENTRY(PopMatrix),
+ TABLE_ENTRY(PushMatrix),
+ TABLE_ENTRY(Rotated),
+ TABLE_ENTRY(Rotatef),
+ TABLE_ENTRY(Scaled),
+ TABLE_ENTRY(Scalef),
+ TABLE_ENTRY(Translated),
+ TABLE_ENTRY(Translatef),
+ TABLE_ENTRY(Viewport),
+ TABLE_ENTRY(ArrayElement),
+ TABLE_ENTRY(BindTexture),
+ TABLE_ENTRY(ColorPointer),
+ TABLE_ENTRY(DisableClientState),
+ TABLE_ENTRY(DrawArrays),
+ TABLE_ENTRY(DrawElements),
+ TABLE_ENTRY(EdgeFlagPointer),
+ TABLE_ENTRY(EnableClientState),
+ TABLE_ENTRY(IndexPointer),
+ TABLE_ENTRY(Indexub),
+ TABLE_ENTRY(Indexubv),
+ TABLE_ENTRY(InterleavedArrays),
+ TABLE_ENTRY(NormalPointer),
+ TABLE_ENTRY(PolygonOffset),
+ TABLE_ENTRY(TexCoordPointer),
+ TABLE_ENTRY(VertexPointer),
+ TABLE_ENTRY(AreTexturesResident),
+ TABLE_ENTRY(CopyTexImage1D),
+ TABLE_ENTRY(CopyTexImage2D),
+ TABLE_ENTRY(CopyTexSubImage1D),
+ TABLE_ENTRY(CopyTexSubImage2D),
+ TABLE_ENTRY(DeleteTextures),
+ TABLE_ENTRY(GenTextures),
+ TABLE_ENTRY(GetPointerv),
+ TABLE_ENTRY(IsTexture),
+ TABLE_ENTRY(PrioritizeTextures),
+ TABLE_ENTRY(TexSubImage1D),
+ TABLE_ENTRY(TexSubImage2D),
+ TABLE_ENTRY(PopClientAttrib),
+ TABLE_ENTRY(PushClientAttrib),
+ TABLE_ENTRY(BlendColor),
+ TABLE_ENTRY(BlendEquation),
+ TABLE_ENTRY(DrawRangeElements),
+ TABLE_ENTRY(ColorTable),
+ TABLE_ENTRY(ColorTableParameterfv),
+ TABLE_ENTRY(ColorTableParameteriv),
+ TABLE_ENTRY(CopyColorTable),
+ TABLE_ENTRY(GetColorTable),
+ TABLE_ENTRY(GetColorTableParameterfv),
+ TABLE_ENTRY(GetColorTableParameteriv),
+ TABLE_ENTRY(ColorSubTable),
+ TABLE_ENTRY(CopyColorSubTable),
+ TABLE_ENTRY(ConvolutionFilter1D),
+ TABLE_ENTRY(ConvolutionFilter2D),
+ TABLE_ENTRY(ConvolutionParameterf),
+ TABLE_ENTRY(ConvolutionParameterfv),
+ TABLE_ENTRY(ConvolutionParameteri),
+ TABLE_ENTRY(ConvolutionParameteriv),
+ TABLE_ENTRY(CopyConvolutionFilter1D),
+ TABLE_ENTRY(CopyConvolutionFilter2D),
+ TABLE_ENTRY(GetConvolutionFilter),
+ TABLE_ENTRY(GetConvolutionParameterfv),
+ TABLE_ENTRY(GetConvolutionParameteriv),
+ TABLE_ENTRY(GetSeparableFilter),
+ TABLE_ENTRY(SeparableFilter2D),
+ TABLE_ENTRY(GetHistogram),
+ TABLE_ENTRY(GetHistogramParameterfv),
+ TABLE_ENTRY(GetHistogramParameteriv),
+ TABLE_ENTRY(GetMinmax),
+ TABLE_ENTRY(GetMinmaxParameterfv),
+ TABLE_ENTRY(GetMinmaxParameteriv),
+ TABLE_ENTRY(Histogram),
+ TABLE_ENTRY(Minmax),
+ TABLE_ENTRY(ResetHistogram),
+ TABLE_ENTRY(ResetMinmax),
+ TABLE_ENTRY(TexImage3D),
+ TABLE_ENTRY(TexSubImage3D),
+ TABLE_ENTRY(CopyTexSubImage3D),
+ TABLE_ENTRY(ActiveTextureARB),
+ TABLE_ENTRY(ClientActiveTextureARB),
+ TABLE_ENTRY(MultiTexCoord1dARB),
+ TABLE_ENTRY(MultiTexCoord1dvARB),
+ TABLE_ENTRY(MultiTexCoord1fARB),
+ TABLE_ENTRY(MultiTexCoord1fvARB),
+ TABLE_ENTRY(MultiTexCoord1iARB),
+ TABLE_ENTRY(MultiTexCoord1ivARB),
+ TABLE_ENTRY(MultiTexCoord1sARB),
+ TABLE_ENTRY(MultiTexCoord1svARB),
+ TABLE_ENTRY(MultiTexCoord2dARB),
+ TABLE_ENTRY(MultiTexCoord2dvARB),
+ TABLE_ENTRY(MultiTexCoord2fARB),
+ TABLE_ENTRY(MultiTexCoord2fvARB),
+ TABLE_ENTRY(MultiTexCoord2iARB),
+ TABLE_ENTRY(MultiTexCoord2ivARB),
+ TABLE_ENTRY(MultiTexCoord2sARB),
+ TABLE_ENTRY(MultiTexCoord2svARB),
+ TABLE_ENTRY(MultiTexCoord3dARB),
+ TABLE_ENTRY(MultiTexCoord3dvARB),
+ TABLE_ENTRY(MultiTexCoord3fARB),
+ TABLE_ENTRY(MultiTexCoord3fvARB),
+ TABLE_ENTRY(MultiTexCoord3iARB),
+ TABLE_ENTRY(MultiTexCoord3ivARB),
+ TABLE_ENTRY(MultiTexCoord3sARB),
+ TABLE_ENTRY(MultiTexCoord3svARB),
+ TABLE_ENTRY(MultiTexCoord4dARB),
+ TABLE_ENTRY(MultiTexCoord4dvARB),
+ TABLE_ENTRY(MultiTexCoord4fARB),
+ TABLE_ENTRY(MultiTexCoord4fvARB),
+ TABLE_ENTRY(MultiTexCoord4iARB),
+ TABLE_ENTRY(MultiTexCoord4ivARB),
+ TABLE_ENTRY(MultiTexCoord4sARB),
+ TABLE_ENTRY(MultiTexCoord4svARB),
+ TABLE_ENTRY(LoadTransposeMatrixfARB),
+ TABLE_ENTRY(LoadTransposeMatrixdARB),
+ TABLE_ENTRY(MultTransposeMatrixfARB),
+ TABLE_ENTRY(MultTransposeMatrixdARB),
+ TABLE_ENTRY(SampleCoverageARB),
+ TABLE_ENTRY(DrawBuffersARB),
+ TABLE_ENTRY(PolygonOffsetEXT),
+ TABLE_ENTRY(GetTexFilterFuncSGIS),
+ TABLE_ENTRY(TexFilterFuncSGIS),
+ TABLE_ENTRY(GetHistogramEXT),
+ TABLE_ENTRY(GetHistogramParameterfvEXT),
+ TABLE_ENTRY(GetHistogramParameterivEXT),
+ TABLE_ENTRY(GetMinmaxEXT),
+ TABLE_ENTRY(GetMinmaxParameterfvEXT),
+ TABLE_ENTRY(GetMinmaxParameterivEXT),
+ TABLE_ENTRY(GetConvolutionFilterEXT),
+ TABLE_ENTRY(GetConvolutionParameterfvEXT),
+ TABLE_ENTRY(GetConvolutionParameterivEXT),
+ TABLE_ENTRY(GetSeparableFilterEXT),
+ TABLE_ENTRY(GetColorTableSGI),
+ TABLE_ENTRY(GetColorTableParameterfvSGI),
+ TABLE_ENTRY(GetColorTableParameterivSGI),
+ TABLE_ENTRY(PixelTexGenSGIX),
+ TABLE_ENTRY(PixelTexGenParameteriSGIS),
+ TABLE_ENTRY(PixelTexGenParameterivSGIS),
+ TABLE_ENTRY(PixelTexGenParameterfSGIS),
+ TABLE_ENTRY(PixelTexGenParameterfvSGIS),
+ TABLE_ENTRY(GetPixelTexGenParameterivSGIS),
+ TABLE_ENTRY(GetPixelTexGenParameterfvSGIS),
+ TABLE_ENTRY(TexImage4DSGIS),
+ TABLE_ENTRY(TexSubImage4DSGIS),
+ TABLE_ENTRY(AreTexturesResidentEXT),
+ TABLE_ENTRY(GenTexturesEXT),
+ TABLE_ENTRY(IsTextureEXT),
+ TABLE_ENTRY(DetailTexFuncSGIS),
+ TABLE_ENTRY(GetDetailTexFuncSGIS),
+ TABLE_ENTRY(SharpenTexFuncSGIS),
+ TABLE_ENTRY(GetSharpenTexFuncSGIS),
+ TABLE_ENTRY(SampleMaskSGIS),
+ TABLE_ENTRY(SamplePatternSGIS),
+ TABLE_ENTRY(ColorPointerEXT),
+ TABLE_ENTRY(EdgeFlagPointerEXT),
+ TABLE_ENTRY(IndexPointerEXT),
+ TABLE_ENTRY(NormalPointerEXT),
+ TABLE_ENTRY(TexCoordPointerEXT),
+ TABLE_ENTRY(VertexPointerEXT),
+ TABLE_ENTRY(SpriteParameterfSGIX),
+ TABLE_ENTRY(SpriteParameterfvSGIX),
+ TABLE_ENTRY(SpriteParameteriSGIX),
+ TABLE_ENTRY(SpriteParameterivSGIX),
+ TABLE_ENTRY(PointParameterfEXT),
+ TABLE_ENTRY(PointParameterfvEXT),
+ TABLE_ENTRY(GetInstrumentsSGIX),
+ TABLE_ENTRY(InstrumentsBufferSGIX),
+ TABLE_ENTRY(PollInstrumentsSGIX),
+ TABLE_ENTRY(ReadInstrumentsSGIX),
+ TABLE_ENTRY(StartInstrumentsSGIX),
+ TABLE_ENTRY(StopInstrumentsSGIX),
+ TABLE_ENTRY(FrameZoomSGIX),
+ TABLE_ENTRY(TagSampleBufferSGIX),
+ TABLE_ENTRY(ReferencePlaneSGIX),
+ TABLE_ENTRY(FlushRasterSGIX),
+ TABLE_ENTRY(GetListParameterfvSGIX),
+ TABLE_ENTRY(GetListParameterivSGIX),
+ TABLE_ENTRY(ListParameterfSGIX),
+ TABLE_ENTRY(ListParameterfvSGIX),
+ TABLE_ENTRY(ListParameteriSGIX),
+ TABLE_ENTRY(ListParameterivSGIX),
+ TABLE_ENTRY(FragmentColorMaterialSGIX),
+ TABLE_ENTRY(FragmentLightfSGIX),
+ TABLE_ENTRY(FragmentLightfvSGIX),
+ TABLE_ENTRY(FragmentLightiSGIX),
+ TABLE_ENTRY(FragmentLightivSGIX),
+ TABLE_ENTRY(FragmentLightModelfSGIX),
+ TABLE_ENTRY(FragmentLightModelfvSGIX),
+ TABLE_ENTRY(FragmentLightModeliSGIX),
+ TABLE_ENTRY(FragmentLightModelivSGIX),
+ TABLE_ENTRY(FragmentMaterialfSGIX),
+ TABLE_ENTRY(FragmentMaterialfvSGIX),
+ TABLE_ENTRY(FragmentMaterialiSGIX),
+ TABLE_ENTRY(FragmentMaterialivSGIX),
+ TABLE_ENTRY(GetFragmentLightfvSGIX),
+ TABLE_ENTRY(GetFragmentLightivSGIX),
+ TABLE_ENTRY(GetFragmentMaterialfvSGIX),
+ TABLE_ENTRY(GetFragmentMaterialivSGIX),
+ TABLE_ENTRY(LightEnviSGIX),
+ TABLE_ENTRY(VertexWeightfEXT),
+ TABLE_ENTRY(VertexWeightfvEXT),
+ TABLE_ENTRY(VertexWeightPointerEXT),
+ TABLE_ENTRY(FlushVertexArrayRangeNV),
+ TABLE_ENTRY(VertexArrayRangeNV),
+ TABLE_ENTRY(CombinerParameterfvNV),
+ TABLE_ENTRY(CombinerParameterfNV),
+ TABLE_ENTRY(CombinerParameterivNV),
+ TABLE_ENTRY(CombinerParameteriNV),
+ TABLE_ENTRY(CombinerInputNV),
+ TABLE_ENTRY(CombinerOutputNV),
+ TABLE_ENTRY(FinalCombinerInputNV),
+ TABLE_ENTRY(GetCombinerInputParameterfvNV),
+ TABLE_ENTRY(GetCombinerInputParameterivNV),
+ TABLE_ENTRY(GetCombinerOutputParameterfvNV),
+ TABLE_ENTRY(GetCombinerOutputParameterivNV),
+ TABLE_ENTRY(GetFinalCombinerInputParameterfvNV),
+ TABLE_ENTRY(GetFinalCombinerInputParameterivNV),
+ TABLE_ENTRY(ResizeBuffersMESA),
+ TABLE_ENTRY(WindowPos2dMESA),
+ TABLE_ENTRY(WindowPos2dvMESA),
+ TABLE_ENTRY(WindowPos2fMESA),
+ TABLE_ENTRY(WindowPos2fvMESA),
+ TABLE_ENTRY(WindowPos2iMESA),
+ TABLE_ENTRY(WindowPos2ivMESA),
+ TABLE_ENTRY(WindowPos2sMESA),
+ TABLE_ENTRY(WindowPos2svMESA),
+ TABLE_ENTRY(WindowPos3dMESA),
+ TABLE_ENTRY(WindowPos3dvMESA),
+ TABLE_ENTRY(WindowPos3fMESA),
+ TABLE_ENTRY(WindowPos3fvMESA),
+ TABLE_ENTRY(WindowPos3iMESA),
+ TABLE_ENTRY(WindowPos3ivMESA),
+ TABLE_ENTRY(WindowPos3sMESA),
+ TABLE_ENTRY(WindowPos3svMESA),
+ TABLE_ENTRY(WindowPos4dMESA),
+ TABLE_ENTRY(WindowPos4dvMESA),
+ TABLE_ENTRY(WindowPos4fMESA),
+ TABLE_ENTRY(WindowPos4fvMESA),
+ TABLE_ENTRY(WindowPos4iMESA),
+ TABLE_ENTRY(WindowPos4ivMESA),
+ TABLE_ENTRY(WindowPos4sMESA),
+ TABLE_ENTRY(WindowPos4svMESA),
+ TABLE_ENTRY(BlendFuncSeparateEXT),
+ TABLE_ENTRY(IndexMaterialEXT),
+ TABLE_ENTRY(IndexFuncEXT),
+ TABLE_ENTRY(LockArraysEXT),
+ TABLE_ENTRY(UnlockArraysEXT),
+ TABLE_ENTRY(CullParameterdvEXT),
+ TABLE_ENTRY(CullParameterfvEXT),
+ TABLE_ENTRY(HintPGI),
+ TABLE_ENTRY(FogCoordfEXT),
+ TABLE_ENTRY(FogCoordfvEXT),
+ TABLE_ENTRY(FogCoorddEXT),
+ TABLE_ENTRY(FogCoorddvEXT),
+ TABLE_ENTRY(FogCoordPointerEXT),
+ TABLE_ENTRY(GetColorTableEXT),
+ TABLE_ENTRY(GetColorTableParameterivEXT),
+ TABLE_ENTRY(GetColorTableParameterfvEXT),
+ TABLE_ENTRY(TbufferMask3DFX),
+ TABLE_ENTRY(CompressedTexImage3DARB),
+ TABLE_ENTRY(CompressedTexImage2DARB),
+ TABLE_ENTRY(CompressedTexImage1DARB),
+ TABLE_ENTRY(CompressedTexSubImage3DARB),
+ TABLE_ENTRY(CompressedTexSubImage2DARB),
+ TABLE_ENTRY(CompressedTexSubImage1DARB),
+ TABLE_ENTRY(GetCompressedTexImageARB),
+ TABLE_ENTRY(SecondaryColor3bEXT),
+ TABLE_ENTRY(SecondaryColor3bvEXT),
+ TABLE_ENTRY(SecondaryColor3dEXT),
+ TABLE_ENTRY(SecondaryColor3dvEXT),
+ TABLE_ENTRY(SecondaryColor3fEXT),
+ TABLE_ENTRY(SecondaryColor3fvEXT),
+ TABLE_ENTRY(SecondaryColor3iEXT),
+ TABLE_ENTRY(SecondaryColor3ivEXT),
+ TABLE_ENTRY(SecondaryColor3sEXT),
+ TABLE_ENTRY(SecondaryColor3svEXT),
+ TABLE_ENTRY(SecondaryColor3ubEXT),
+ TABLE_ENTRY(SecondaryColor3ubvEXT),
+ TABLE_ENTRY(SecondaryColor3uiEXT),
+ TABLE_ENTRY(SecondaryColor3uivEXT),
+ TABLE_ENTRY(SecondaryColor3usEXT),
+ TABLE_ENTRY(SecondaryColor3usvEXT),
+ TABLE_ENTRY(SecondaryColorPointerEXT),
+ TABLE_ENTRY(AreProgramsResidentNV),
+ TABLE_ENTRY(BindProgramNV),
+ TABLE_ENTRY(DeleteProgramsNV),
+ TABLE_ENTRY(ExecuteProgramNV),
+ TABLE_ENTRY(GenProgramsNV),
+ TABLE_ENTRY(GetProgramParameterdvNV),
+ TABLE_ENTRY(GetProgramParameterfvNV),
+ TABLE_ENTRY(GetProgramivNV),
+ TABLE_ENTRY(GetProgramStringNV),
+ TABLE_ENTRY(GetTrackMatrixivNV),
+ TABLE_ENTRY(GetVertexAttribdvARB),
+ TABLE_ENTRY(GetVertexAttribfvARB),
+ TABLE_ENTRY(GetVertexAttribivARB),
+ TABLE_ENTRY(GetVertexAttribPointervNV),
+ TABLE_ENTRY(IsProgramNV),
+ TABLE_ENTRY(LoadProgramNV),
+ TABLE_ENTRY(ProgramParameter4dNV),
+ TABLE_ENTRY(ProgramParameter4dvNV),
+ TABLE_ENTRY(ProgramParameter4fNV),
+ TABLE_ENTRY(ProgramParameter4fvNV),
+ TABLE_ENTRY(ProgramParameters4dvNV),
+ TABLE_ENTRY(ProgramParameters4fvNV),
+ TABLE_ENTRY(RequestResidentProgramsNV),
+ TABLE_ENTRY(TrackMatrixNV),
+ TABLE_ENTRY(VertexAttribPointerNV),
+ TABLE_ENTRY(VertexAttrib1dARB),
+ TABLE_ENTRY(VertexAttrib1dvARB),
+ TABLE_ENTRY(VertexAttrib1fARB),
+ TABLE_ENTRY(VertexAttrib1fvARB),
+ TABLE_ENTRY(VertexAttrib1sARB),
+ TABLE_ENTRY(VertexAttrib1svARB),
+ TABLE_ENTRY(VertexAttrib2dARB),
+ TABLE_ENTRY(VertexAttrib2dvARB),
+ TABLE_ENTRY(VertexAttrib2fARB),
+ TABLE_ENTRY(VertexAttrib2fvARB),
+ TABLE_ENTRY(VertexAttrib2sARB),
+ TABLE_ENTRY(VertexAttrib2svARB),
+ TABLE_ENTRY(VertexAttrib3dARB),
+ TABLE_ENTRY(VertexAttrib3dvARB),
+ TABLE_ENTRY(VertexAttrib3fARB),
+ TABLE_ENTRY(VertexAttrib3fvARB),
+ TABLE_ENTRY(VertexAttrib3sARB),
+ TABLE_ENTRY(VertexAttrib3svARB),
+ TABLE_ENTRY(VertexAttrib4dARB),
+ TABLE_ENTRY(VertexAttrib4dvARB),
+ TABLE_ENTRY(VertexAttrib4fARB),
+ TABLE_ENTRY(VertexAttrib4fvARB),
+ TABLE_ENTRY(VertexAttrib4sARB),
+ TABLE_ENTRY(VertexAttrib4svARB),
+ TABLE_ENTRY(VertexAttrib4NubARB),
+ TABLE_ENTRY(VertexAttrib4NubvARB),
+ TABLE_ENTRY(VertexAttribs1dvNV),
+ TABLE_ENTRY(VertexAttribs1fvNV),
+ TABLE_ENTRY(VertexAttribs1svNV),
+ TABLE_ENTRY(VertexAttribs2dvNV),
+ TABLE_ENTRY(VertexAttribs2fvNV),
+ TABLE_ENTRY(VertexAttribs2svNV),
+ TABLE_ENTRY(VertexAttribs3dvNV),
+ TABLE_ENTRY(VertexAttribs3fvNV),
+ TABLE_ENTRY(VertexAttribs3svNV),
+ TABLE_ENTRY(VertexAttribs4dvNV),
+ TABLE_ENTRY(VertexAttribs4fvNV),
+ TABLE_ENTRY(VertexAttribs4svNV),
+ TABLE_ENTRY(VertexAttribs4ubvNV),
+ TABLE_ENTRY(PointParameteriNV),
+ TABLE_ENTRY(PointParameterivNV),
+ TABLE_ENTRY(MultiDrawArraysEXT),
+ TABLE_ENTRY(MultiDrawElementsEXT),
+ TABLE_ENTRY(ActiveStencilFaceEXT),
+ TABLE_ENTRY(DeleteFencesNV),
+ TABLE_ENTRY(GenFencesNV),
+ TABLE_ENTRY(IsFenceNV),
+ TABLE_ENTRY(TestFenceNV),
+ TABLE_ENTRY(GetFenceivNV),
+ TABLE_ENTRY(FinishFenceNV),
+ TABLE_ENTRY(SetFenceNV),
+ TABLE_ENTRY(VertexAttrib4bvARB),
+ TABLE_ENTRY(VertexAttrib4ivARB),
+ TABLE_ENTRY(VertexAttrib4ubvARB),
+ TABLE_ENTRY(VertexAttrib4usvARB),
+ TABLE_ENTRY(VertexAttrib4uivARB),
+ TABLE_ENTRY(VertexAttrib4NbvARB),
+ TABLE_ENTRY(VertexAttrib4NsvARB),
+ TABLE_ENTRY(VertexAttrib4NivARB),
+ TABLE_ENTRY(VertexAttrib4NusvARB),
+ TABLE_ENTRY(VertexAttrib4NuivARB),
+ TABLE_ENTRY(VertexAttribPointerARB),
+ TABLE_ENTRY(EnableVertexAttribArrayARB),
+ TABLE_ENTRY(DisableVertexAttribArrayARB),
+ TABLE_ENTRY(ProgramStringARB),
+ TABLE_ENTRY(ProgramEnvParameter4dARB),
+ TABLE_ENTRY(ProgramEnvParameter4dvARB),
+ TABLE_ENTRY(ProgramEnvParameter4fARB),
+ TABLE_ENTRY(ProgramEnvParameter4fvARB),
+ TABLE_ENTRY(ProgramLocalParameter4dARB),
+ TABLE_ENTRY(ProgramLocalParameter4dvARB),
+ TABLE_ENTRY(ProgramLocalParameter4fARB),
+ TABLE_ENTRY(ProgramLocalParameter4fvARB),
+ TABLE_ENTRY(GetProgramEnvParameterdvARB),
+ TABLE_ENTRY(GetProgramEnvParameterfvARB),
+ TABLE_ENTRY(GetProgramLocalParameterdvARB),
+ TABLE_ENTRY(GetProgramLocalParameterfvARB),
+ TABLE_ENTRY(GetProgramivARB),
+ TABLE_ENTRY(GetProgramStringARB),
+ TABLE_ENTRY(ProgramNamedParameter4fNV),
+ TABLE_ENTRY(ProgramNamedParameter4dNV),
+ TABLE_ENTRY(ProgramNamedParameter4fvNV),
+ TABLE_ENTRY(ProgramNamedParameter4dvNV),
+ TABLE_ENTRY(GetProgramNamedParameterfvNV),
+ TABLE_ENTRY(GetProgramNamedParameterdvNV),
+ TABLE_ENTRY(BindBufferARB),
+ TABLE_ENTRY(BufferDataARB),
+ TABLE_ENTRY(BufferSubDataARB),
+ TABLE_ENTRY(DeleteBuffersARB),
+ TABLE_ENTRY(GenBuffersARB),
+ TABLE_ENTRY(GetBufferParameterivARB),
+ TABLE_ENTRY(GetBufferPointervARB),
+ TABLE_ENTRY(GetBufferSubDataARB),
+ TABLE_ENTRY(IsBufferARB),
+ TABLE_ENTRY(MapBufferARB),
+ TABLE_ENTRY(UnmapBufferARB),
+ TABLE_ENTRY(DepthBoundsEXT),
+ TABLE_ENTRY(GenQueriesARB),
+ TABLE_ENTRY(DeleteQueriesARB),
+ TABLE_ENTRY(IsQueryARB),
+ TABLE_ENTRY(BeginQueryARB),
+ TABLE_ENTRY(EndQueryARB),
+ TABLE_ENTRY(GetQueryivARB),
+ TABLE_ENTRY(GetQueryObjectivARB),
+ TABLE_ENTRY(GetQueryObjectuivARB),
+ TABLE_ENTRY(MultiModeDrawArraysIBM),
+ TABLE_ENTRY(MultiModeDrawElementsIBM),
+ TABLE_ENTRY(BlendEquationSeparateEXT),
+ TABLE_ENTRY(DeleteObjectARB),
+ TABLE_ENTRY(GetHandleARB),
+ TABLE_ENTRY(DetachObjectARB),
+ TABLE_ENTRY(CreateShaderObjectARB),
+ TABLE_ENTRY(ShaderSourceARB),
+ TABLE_ENTRY(CompileShaderARB),
+ TABLE_ENTRY(CreateProgramObjectARB),
+ TABLE_ENTRY(AttachObjectARB),
+ TABLE_ENTRY(LinkProgramARB),
+ TABLE_ENTRY(UseProgramObjectARB),
+ TABLE_ENTRY(ValidateProgramARB),
+ TABLE_ENTRY(Uniform1fARB),
+ TABLE_ENTRY(Uniform2fARB),
+ TABLE_ENTRY(Uniform3fARB),
+ TABLE_ENTRY(Uniform4fARB),
+ TABLE_ENTRY(Uniform1iARB),
+ TABLE_ENTRY(Uniform2iARB),
+ TABLE_ENTRY(Uniform3iARB),
+ TABLE_ENTRY(Uniform4iARB),
+ TABLE_ENTRY(Uniform1fvARB),
+ TABLE_ENTRY(Uniform2fvARB),
+ TABLE_ENTRY(Uniform3fvARB),
+ TABLE_ENTRY(Uniform4fvARB),
+ TABLE_ENTRY(Uniform1ivARB),
+ TABLE_ENTRY(Uniform2ivARB),
+ TABLE_ENTRY(Uniform3ivARB),
+ TABLE_ENTRY(Uniform4ivARB),
+ TABLE_ENTRY(UniformMatrix2fvARB),
+ TABLE_ENTRY(UniformMatrix3fvARB),
+ TABLE_ENTRY(UniformMatrix4fvARB),
+ TABLE_ENTRY(GetObjectParameterfvARB),
+ TABLE_ENTRY(GetObjectParameterivARB),
+ TABLE_ENTRY(GetInfoLogARB),
+ TABLE_ENTRY(GetAttachedObjectsARB),
+ TABLE_ENTRY(GetUniformLocationARB),
+ TABLE_ENTRY(GetActiveUniformARB),
+ TABLE_ENTRY(GetUniformfvARB),
+ TABLE_ENTRY(GetUniformivARB),
+ TABLE_ENTRY(GetShaderSourceARB),
+ TABLE_ENTRY(BindAttribLocationARB),
+ TABLE_ENTRY(GetActiveAttribARB),
+ TABLE_ENTRY(GetAttribLocationARB),
+ TABLE_ENTRY(GetVertexAttribdvNV),
+ TABLE_ENTRY(GetVertexAttribfvNV),
+ TABLE_ENTRY(GetVertexAttribivNV),
+ TABLE_ENTRY(VertexAttrib1dNV),
+ TABLE_ENTRY(VertexAttrib1dvNV),
+ TABLE_ENTRY(VertexAttrib1fNV),
+ TABLE_ENTRY(VertexAttrib1fvNV),
+ TABLE_ENTRY(VertexAttrib1sNV),
+ TABLE_ENTRY(VertexAttrib1svNV),
+ TABLE_ENTRY(VertexAttrib2dNV),
+ TABLE_ENTRY(VertexAttrib2dvNV),
+ TABLE_ENTRY(VertexAttrib2fNV),
+ TABLE_ENTRY(VertexAttrib2fvNV),
+ TABLE_ENTRY(VertexAttrib2sNV),
+ TABLE_ENTRY(VertexAttrib2svNV),
+ TABLE_ENTRY(VertexAttrib3dNV),
+ TABLE_ENTRY(VertexAttrib3dvNV),
+ TABLE_ENTRY(VertexAttrib3fNV),
+ TABLE_ENTRY(VertexAttrib3fvNV),
+ TABLE_ENTRY(VertexAttrib3sNV),
+ TABLE_ENTRY(VertexAttrib3svNV),
+ TABLE_ENTRY(VertexAttrib4dNV),
+ TABLE_ENTRY(VertexAttrib4dvNV),
+ TABLE_ENTRY(VertexAttrib4fNV),
+ TABLE_ENTRY(VertexAttrib4fvNV),
+ TABLE_ENTRY(VertexAttrib4sNV),
+ TABLE_ENTRY(VertexAttrib4svNV),
+ TABLE_ENTRY(VertexAttrib4ubNV),
+ TABLE_ENTRY(VertexAttrib4ubvNV),
+ TABLE_ENTRY(GenFragmentShadersATI),
+ TABLE_ENTRY(BindFragmentShaderATI),
+ TABLE_ENTRY(DeleteFragmentShaderATI),
+ TABLE_ENTRY(BeginFragmentShaderATI),
+ TABLE_ENTRY(EndFragmentShaderATI),
+ TABLE_ENTRY(PassTexCoordATI),
+ TABLE_ENTRY(SampleMapATI),
+ TABLE_ENTRY(ColorFragmentOp1ATI),
+ TABLE_ENTRY(ColorFragmentOp2ATI),
+ TABLE_ENTRY(ColorFragmentOp3ATI),
+ TABLE_ENTRY(AlphaFragmentOp1ATI),
+ TABLE_ENTRY(AlphaFragmentOp2ATI),
+ TABLE_ENTRY(AlphaFragmentOp3ATI),
+ TABLE_ENTRY(SetFragmentShaderConstantATI),
+ TABLE_ENTRY(IsRenderbufferEXT),
+ TABLE_ENTRY(BindRenderbufferEXT),
+ TABLE_ENTRY(DeleteRenderbuffersEXT),
+ TABLE_ENTRY(GenRenderbuffersEXT),
+ TABLE_ENTRY(RenderbufferStorageEXT),
+ TABLE_ENTRY(GetRenderbufferParameterivEXT),
+ TABLE_ENTRY(IsFramebufferEXT),
+ TABLE_ENTRY(BindFramebufferEXT),
+ TABLE_ENTRY(DeleteFramebuffersEXT),
+ TABLE_ENTRY(GenFramebuffersEXT),
+ TABLE_ENTRY(CheckFramebufferStatusEXT),
+ TABLE_ENTRY(FramebufferTexture1DEXT),
+ TABLE_ENTRY(FramebufferTexture2DEXT),
+ TABLE_ENTRY(FramebufferTexture3DEXT),
+ TABLE_ENTRY(FramebufferRenderbufferEXT),
+ TABLE_ENTRY(GetFramebufferAttachmentParameterivEXT),
+ TABLE_ENTRY(GenerateMipmapEXT),
+ TABLE_ENTRY(StencilFuncSeparate),
+ TABLE_ENTRY(StencilOpSeparate),
+ TABLE_ENTRY(StencilMaskSeparate),
+ /* A whole bunch of no-op functions. These might be called
+ * when someone tries to call a dynamically-registered
+ * extension function without a current rendering context.
+ */
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+ TABLE_ENTRY(Unused),
+};
+#endif /* DISPATCH_TABLE_NAME */
+
+
+/*
+ * This is just used to silence compiler warnings.
+ * We list the functions which are not otherwise used.
+ */
+#ifdef UNUSED_TABLE_NAME
+static _glapi_proc UNUSED_TABLE_NAME[] = {
+ TABLE_ENTRY(ArrayElementEXT),
+ TABLE_ENTRY(BindTextureEXT),
+ TABLE_ENTRY(DrawArraysEXT),
+ TABLE_ENTRY(CopyTexImage1DEXT),
+ TABLE_ENTRY(CopyTexImage2DEXT),
+ TABLE_ENTRY(CopyTexSubImage1DEXT),
+ TABLE_ENTRY(CopyTexSubImage2DEXT),
+ TABLE_ENTRY(DeleteTexturesEXT),
+ TABLE_ENTRY(GetPointervEXT),
+ TABLE_ENTRY(PrioritizeTexturesEXT),
+ TABLE_ENTRY(TexSubImage1DEXT),
+ TABLE_ENTRY(TexSubImage2DEXT),
+ TABLE_ENTRY(BlendColorEXT),
+ TABLE_ENTRY(BlendEquationEXT),
+ TABLE_ENTRY(DrawRangeElementsEXT),
+ TABLE_ENTRY(ColorTableSGI),
+ TABLE_ENTRY(ColorTableEXT),
+ TABLE_ENTRY(ColorTableParameterfvSGI),
+ TABLE_ENTRY(ColorTableParameterivSGI),
+ TABLE_ENTRY(CopyColorTableSGI),
+ TABLE_ENTRY(ColorSubTableEXT),
+ TABLE_ENTRY(CopyColorSubTableEXT),
+ TABLE_ENTRY(ConvolutionFilter1DEXT),
+ TABLE_ENTRY(ConvolutionFilter2DEXT),
+ TABLE_ENTRY(ConvolutionParameterfEXT),
+ TABLE_ENTRY(ConvolutionParameterfvEXT),
+ TABLE_ENTRY(ConvolutionParameteriEXT),
+ TABLE_ENTRY(ConvolutionParameterivEXT),
+ TABLE_ENTRY(CopyConvolutionFilter1DEXT),
+ TABLE_ENTRY(CopyConvolutionFilter2DEXT),
+ TABLE_ENTRY(SeparableFilter2DEXT),
+ TABLE_ENTRY(HistogramEXT),
+ TABLE_ENTRY(MinmaxEXT),
+ TABLE_ENTRY(ResetHistogramEXT),
+ TABLE_ENTRY(ResetMinmaxEXT),
+ TABLE_ENTRY(TexImage3DEXT),
+ TABLE_ENTRY(TexSubImage3DEXT),
+ TABLE_ENTRY(CopyTexSubImage3DEXT),
+ TABLE_ENTRY(ActiveTexture),
+ TABLE_ENTRY(ClientActiveTexture),
+ TABLE_ENTRY(MultiTexCoord1d),
+ TABLE_ENTRY(MultiTexCoord1dv),
+ TABLE_ENTRY(MultiTexCoord1f),
+ TABLE_ENTRY(MultiTexCoord1fv),
+ TABLE_ENTRY(MultiTexCoord1i),
+ TABLE_ENTRY(MultiTexCoord1iv),
+ TABLE_ENTRY(MultiTexCoord1s),
+ TABLE_ENTRY(MultiTexCoord1sv),
+ TABLE_ENTRY(MultiTexCoord2d),
+ TABLE_ENTRY(MultiTexCoord2dv),
+ TABLE_ENTRY(MultiTexCoord2f),
+ TABLE_ENTRY(MultiTexCoord2fv),
+ TABLE_ENTRY(MultiTexCoord2i),
+ TABLE_ENTRY(MultiTexCoord2iv),
+ TABLE_ENTRY(MultiTexCoord2s),
+ TABLE_ENTRY(MultiTexCoord2sv),
+ TABLE_ENTRY(MultiTexCoord3d),
+ TABLE_ENTRY(MultiTexCoord3dv),
+ TABLE_ENTRY(MultiTexCoord3f),
+ TABLE_ENTRY(MultiTexCoord3fv),
+ TABLE_ENTRY(MultiTexCoord3i),
+ TABLE_ENTRY(MultiTexCoord3iv),
+ TABLE_ENTRY(MultiTexCoord3s),
+ TABLE_ENTRY(MultiTexCoord3sv),
+ TABLE_ENTRY(MultiTexCoord4d),
+ TABLE_ENTRY(MultiTexCoord4dv),
+ TABLE_ENTRY(MultiTexCoord4f),
+ TABLE_ENTRY(MultiTexCoord4fv),
+ TABLE_ENTRY(MultiTexCoord4i),
+ TABLE_ENTRY(MultiTexCoord4iv),
+ TABLE_ENTRY(MultiTexCoord4s),
+ TABLE_ENTRY(MultiTexCoord4sv),
+ TABLE_ENTRY(LoadTransposeMatrixf),
+ TABLE_ENTRY(LoadTransposeMatrixd),
+ TABLE_ENTRY(MultTransposeMatrixf),
+ TABLE_ENTRY(MultTransposeMatrixd),
+ TABLE_ENTRY(SampleCoverage),
+ TABLE_ENTRY(DrawBuffersATI),
+ TABLE_ENTRY(SampleMaskEXT),
+ TABLE_ENTRY(SamplePatternEXT),
+ TABLE_ENTRY(PointParameterf),
+ TABLE_ENTRY(PointParameterfARB),
+ TABLE_ENTRY(PointParameterfSGIS),
+ TABLE_ENTRY(PointParameterfv),
+ TABLE_ENTRY(PointParameterfvARB),
+ TABLE_ENTRY(PointParameterfvSGIS),
+ TABLE_ENTRY(WindowPos2d),
+ TABLE_ENTRY(WindowPos2dARB),
+ TABLE_ENTRY(WindowPos2dv),
+ TABLE_ENTRY(WindowPos2dvARB),
+ TABLE_ENTRY(WindowPos2f),
+ TABLE_ENTRY(WindowPos2fARB),
+ TABLE_ENTRY(WindowPos2fv),
+ TABLE_ENTRY(WindowPos2fvARB),
+ TABLE_ENTRY(WindowPos2i),
+ TABLE_ENTRY(WindowPos2iARB),
+ TABLE_ENTRY(WindowPos2iv),
+ TABLE_ENTRY(WindowPos2ivARB),
+ TABLE_ENTRY(WindowPos2s),
+ TABLE_ENTRY(WindowPos2sARB),
+ TABLE_ENTRY(WindowPos2sv),
+ TABLE_ENTRY(WindowPos2svARB),
+ TABLE_ENTRY(WindowPos3d),
+ TABLE_ENTRY(WindowPos3dARB),
+ TABLE_ENTRY(WindowPos3dv),
+ TABLE_ENTRY(WindowPos3dvARB),
+ TABLE_ENTRY(WindowPos3f),
+ TABLE_ENTRY(WindowPos3fARB),
+ TABLE_ENTRY(WindowPos3fv),
+ TABLE_ENTRY(WindowPos3fvARB),
+ TABLE_ENTRY(WindowPos3i),
+ TABLE_ENTRY(WindowPos3iARB),
+ TABLE_ENTRY(WindowPos3iv),
+ TABLE_ENTRY(WindowPos3ivARB),
+ TABLE_ENTRY(WindowPos3s),
+ TABLE_ENTRY(WindowPos3sARB),
+ TABLE_ENTRY(WindowPos3sv),
+ TABLE_ENTRY(WindowPos3svARB),
+ TABLE_ENTRY(BlendFuncSeparate),
+ TABLE_ENTRY(BlendFuncSeparateINGR),
+ TABLE_ENTRY(FogCoordf),
+ TABLE_ENTRY(FogCoordfv),
+ TABLE_ENTRY(FogCoordd),
+ TABLE_ENTRY(FogCoorddv),
+ TABLE_ENTRY(FogCoordPointer),
+ TABLE_ENTRY(CompressedTexImage3D),
+ TABLE_ENTRY(CompressedTexImage2D),
+ TABLE_ENTRY(CompressedTexImage1D),
+ TABLE_ENTRY(CompressedTexSubImage3D),
+ TABLE_ENTRY(CompressedTexSubImage2D),
+ TABLE_ENTRY(CompressedTexSubImage1D),
+ TABLE_ENTRY(GetCompressedTexImage),
+ TABLE_ENTRY(SecondaryColor3b),
+ TABLE_ENTRY(SecondaryColor3bv),
+ TABLE_ENTRY(SecondaryColor3d),
+ TABLE_ENTRY(SecondaryColor3dv),
+ TABLE_ENTRY(SecondaryColor3f),
+ TABLE_ENTRY(SecondaryColor3fv),
+ TABLE_ENTRY(SecondaryColor3i),
+ TABLE_ENTRY(SecondaryColor3iv),
+ TABLE_ENTRY(SecondaryColor3s),
+ TABLE_ENTRY(SecondaryColor3sv),
+ TABLE_ENTRY(SecondaryColor3ub),
+ TABLE_ENTRY(SecondaryColor3ubv),
+ TABLE_ENTRY(SecondaryColor3ui),
+ TABLE_ENTRY(SecondaryColor3uiv),
+ TABLE_ENTRY(SecondaryColor3us),
+ TABLE_ENTRY(SecondaryColor3usv),
+ TABLE_ENTRY(SecondaryColorPointer),
+ TABLE_ENTRY(BindProgramARB),
+ TABLE_ENTRY(DeleteProgramsARB),
+ TABLE_ENTRY(GenProgramsARB),
+ TABLE_ENTRY(GetVertexAttribPointervARB),
+ TABLE_ENTRY(IsProgramARB),
+ TABLE_ENTRY(PointParameteri),
+ TABLE_ENTRY(PointParameteriv),
+ TABLE_ENTRY(MultiDrawArrays),
+ TABLE_ENTRY(MultiDrawElements),
+ TABLE_ENTRY(BindBuffer),
+ TABLE_ENTRY(BufferData),
+ TABLE_ENTRY(BufferSubData),
+ TABLE_ENTRY(DeleteBuffers),
+ TABLE_ENTRY(GenBuffers),
+ TABLE_ENTRY(GetBufferParameteriv),
+ TABLE_ENTRY(GetBufferPointerv),
+ TABLE_ENTRY(GetBufferSubData),
+ TABLE_ENTRY(IsBuffer),
+ TABLE_ENTRY(MapBuffer),
+ TABLE_ENTRY(UnmapBuffer),
+ TABLE_ENTRY(GenQueries),
+ TABLE_ENTRY(DeleteQueries),
+ TABLE_ENTRY(IsQuery),
+ TABLE_ENTRY(BeginQuery),
+ TABLE_ENTRY(EndQuery),
+ TABLE_ENTRY(GetQueryiv),
+ TABLE_ENTRY(GetQueryObjectiv),
+ TABLE_ENTRY(GetQueryObjectuiv),
+ TABLE_ENTRY(BlendEquationSeparateATI),
+};
+#endif /*UNUSED_TABLE_NAME*/
+
+
+# undef KEYWORD1
+# undef KEYWORD2
+# undef NAME
+# undef DISPATCH
+# undef RETURN_DISPATCH
+# undef DISPATCH_TABLE_NAME
+# undef UNUSED_TABLE_NAME
+# undef TABLE_ENTRY
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/glprocs.h b/nx-X11/extras/Mesa/src/mesa/glapi/glprocs.h
new file mode 100644
index 000000000..596a3e4cf
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/glprocs.h
@@ -0,0 +1,2043 @@
+/* DO NOT EDIT - This file generated automatically by gl_procs.py (from Mesa) script */
+
+/*
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * BRIAN PAUL, IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/* This file is only included by glapi.c and is used for
+ * the GetProcAddress() function
+ */
+
+typedef struct {
+ GLint Name_offset;
+#ifdef NEED_FUNCTION_POINTER
+ _glapi_proc Address;
+#endif
+ GLuint Offset;
+} glprocs_table_t;
+
+#ifdef NEED_FUNCTION_POINTER
+# define NAME_FUNC_OFFSET(n,f,o) { n , (_glapi_proc) f , o }
+#else
+# define NAME_FUNC_OFFSET(n,f,o) { n , o }
+#endif
+
+
+static const char gl_string_table[] =
+ "glNewList\0"
+ "glEndList\0"
+ "glCallList\0"
+ "glCallLists\0"
+ "glDeleteLists\0"
+ "glGenLists\0"
+ "glListBase\0"
+ "glBegin\0"
+ "glBitmap\0"
+ "glColor3b\0"
+ "glColor3bv\0"
+ "glColor3d\0"
+ "glColor3dv\0"
+ "glColor3f\0"
+ "glColor3fv\0"
+ "glColor3i\0"
+ "glColor3iv\0"
+ "glColor3s\0"
+ "glColor3sv\0"
+ "glColor3ub\0"
+ "glColor3ubv\0"
+ "glColor3ui\0"
+ "glColor3uiv\0"
+ "glColor3us\0"
+ "glColor3usv\0"
+ "glColor4b\0"
+ "glColor4bv\0"
+ "glColor4d\0"
+ "glColor4dv\0"
+ "glColor4f\0"
+ "glColor4fv\0"
+ "glColor4i\0"
+ "glColor4iv\0"
+ "glColor4s\0"
+ "glColor4sv\0"
+ "glColor4ub\0"
+ "glColor4ubv\0"
+ "glColor4ui\0"
+ "glColor4uiv\0"
+ "glColor4us\0"
+ "glColor4usv\0"
+ "glEdgeFlag\0"
+ "glEdgeFlagv\0"
+ "glEnd\0"
+ "glIndexd\0"
+ "glIndexdv\0"
+ "glIndexf\0"
+ "glIndexfv\0"
+ "glIndexi\0"
+ "glIndexiv\0"
+ "glIndexs\0"
+ "glIndexsv\0"
+ "glNormal3b\0"
+ "glNormal3bv\0"
+ "glNormal3d\0"
+ "glNormal3dv\0"
+ "glNormal3f\0"
+ "glNormal3fv\0"
+ "glNormal3i\0"
+ "glNormal3iv\0"
+ "glNormal3s\0"
+ "glNormal3sv\0"
+ "glRasterPos2d\0"
+ "glRasterPos2dv\0"
+ "glRasterPos2f\0"
+ "glRasterPos2fv\0"
+ "glRasterPos2i\0"
+ "glRasterPos2iv\0"
+ "glRasterPos2s\0"
+ "glRasterPos2sv\0"
+ "glRasterPos3d\0"
+ "glRasterPos3dv\0"
+ "glRasterPos3f\0"
+ "glRasterPos3fv\0"
+ "glRasterPos3i\0"
+ "glRasterPos3iv\0"
+ "glRasterPos3s\0"
+ "glRasterPos3sv\0"
+ "glRasterPos4d\0"
+ "glRasterPos4dv\0"
+ "glRasterPos4f\0"
+ "glRasterPos4fv\0"
+ "glRasterPos4i\0"
+ "glRasterPos4iv\0"
+ "glRasterPos4s\0"
+ "glRasterPos4sv\0"
+ "glRectd\0"
+ "glRectdv\0"
+ "glRectf\0"
+ "glRectfv\0"
+ "glRecti\0"
+ "glRectiv\0"
+ "glRects\0"
+ "glRectsv\0"
+ "glTexCoord1d\0"
+ "glTexCoord1dv\0"
+ "glTexCoord1f\0"
+ "glTexCoord1fv\0"
+ "glTexCoord1i\0"
+ "glTexCoord1iv\0"
+ "glTexCoord1s\0"
+ "glTexCoord1sv\0"
+ "glTexCoord2d\0"
+ "glTexCoord2dv\0"
+ "glTexCoord2f\0"
+ "glTexCoord2fv\0"
+ "glTexCoord2i\0"
+ "glTexCoord2iv\0"
+ "glTexCoord2s\0"
+ "glTexCoord2sv\0"
+ "glTexCoord3d\0"
+ "glTexCoord3dv\0"
+ "glTexCoord3f\0"
+ "glTexCoord3fv\0"
+ "glTexCoord3i\0"
+ "glTexCoord3iv\0"
+ "glTexCoord3s\0"
+ "glTexCoord3sv\0"
+ "glTexCoord4d\0"
+ "glTexCoord4dv\0"
+ "glTexCoord4f\0"
+ "glTexCoord4fv\0"
+ "glTexCoord4i\0"
+ "glTexCoord4iv\0"
+ "glTexCoord4s\0"
+ "glTexCoord4sv\0"
+ "glVertex2d\0"
+ "glVertex2dv\0"
+ "glVertex2f\0"
+ "glVertex2fv\0"
+ "glVertex2i\0"
+ "glVertex2iv\0"
+ "glVertex2s\0"
+ "glVertex2sv\0"
+ "glVertex3d\0"
+ "glVertex3dv\0"
+ "glVertex3f\0"
+ "glVertex3fv\0"
+ "glVertex3i\0"
+ "glVertex3iv\0"
+ "glVertex3s\0"
+ "glVertex3sv\0"
+ "glVertex4d\0"
+ "glVertex4dv\0"
+ "glVertex4f\0"
+ "glVertex4fv\0"
+ "glVertex4i\0"
+ "glVertex4iv\0"
+ "glVertex4s\0"
+ "glVertex4sv\0"
+ "glClipPlane\0"
+ "glColorMaterial\0"
+ "glCullFace\0"
+ "glFogf\0"
+ "glFogfv\0"
+ "glFogi\0"
+ "glFogiv\0"
+ "glFrontFace\0"
+ "glHint\0"
+ "glLightf\0"
+ "glLightfv\0"
+ "glLighti\0"
+ "glLightiv\0"
+ "glLightModelf\0"
+ "glLightModelfv\0"
+ "glLightModeli\0"
+ "glLightModeliv\0"
+ "glLineStipple\0"
+ "glLineWidth\0"
+ "glMaterialf\0"
+ "glMaterialfv\0"
+ "glMateriali\0"
+ "glMaterialiv\0"
+ "glPointSize\0"
+ "glPolygonMode\0"
+ "glPolygonStipple\0"
+ "glScissor\0"
+ "glShadeModel\0"
+ "glTexParameterf\0"
+ "glTexParameterfv\0"
+ "glTexParameteri\0"
+ "glTexParameteriv\0"
+ "glTexImage1D\0"
+ "glTexImage2D\0"
+ "glTexEnvf\0"
+ "glTexEnvfv\0"
+ "glTexEnvi\0"
+ "glTexEnviv\0"
+ "glTexGend\0"
+ "glTexGendv\0"
+ "glTexGenf\0"
+ "glTexGenfv\0"
+ "glTexGeni\0"
+ "glTexGeniv\0"
+ "glFeedbackBuffer\0"
+ "glSelectBuffer\0"
+ "glRenderMode\0"
+ "glInitNames\0"
+ "glLoadName\0"
+ "glPassThrough\0"
+ "glPopName\0"
+ "glPushName\0"
+ "glDrawBuffer\0"
+ "glClear\0"
+ "glClearAccum\0"
+ "glClearIndex\0"
+ "glClearColor\0"
+ "glClearStencil\0"
+ "glClearDepth\0"
+ "glStencilMask\0"
+ "glColorMask\0"
+ "glDepthMask\0"
+ "glIndexMask\0"
+ "glAccum\0"
+ "glDisable\0"
+ "glEnable\0"
+ "glFinish\0"
+ "glFlush\0"
+ "glPopAttrib\0"
+ "glPushAttrib\0"
+ "glMap1d\0"
+ "glMap1f\0"
+ "glMap2d\0"
+ "glMap2f\0"
+ "glMapGrid1d\0"
+ "glMapGrid1f\0"
+ "glMapGrid2d\0"
+ "glMapGrid2f\0"
+ "glEvalCoord1d\0"
+ "glEvalCoord1dv\0"
+ "glEvalCoord1f\0"
+ "glEvalCoord1fv\0"
+ "glEvalCoord2d\0"
+ "glEvalCoord2dv\0"
+ "glEvalCoord2f\0"
+ "glEvalCoord2fv\0"
+ "glEvalMesh1\0"
+ "glEvalPoint1\0"
+ "glEvalMesh2\0"
+ "glEvalPoint2\0"
+ "glAlphaFunc\0"
+ "glBlendFunc\0"
+ "glLogicOp\0"
+ "glStencilFunc\0"
+ "glStencilOp\0"
+ "glDepthFunc\0"
+ "glPixelZoom\0"
+ "glPixelTransferf\0"
+ "glPixelTransferi\0"
+ "glPixelStoref\0"
+ "glPixelStorei\0"
+ "glPixelMapfv\0"
+ "glPixelMapuiv\0"
+ "glPixelMapusv\0"
+ "glReadBuffer\0"
+ "glCopyPixels\0"
+ "glReadPixels\0"
+ "glDrawPixels\0"
+ "glGetBooleanv\0"
+ "glGetClipPlane\0"
+ "glGetDoublev\0"
+ "glGetError\0"
+ "glGetFloatv\0"
+ "glGetIntegerv\0"
+ "glGetLightfv\0"
+ "glGetLightiv\0"
+ "glGetMapdv\0"
+ "glGetMapfv\0"
+ "glGetMapiv\0"
+ "glGetMaterialfv\0"
+ "glGetMaterialiv\0"
+ "glGetPixelMapfv\0"
+ "glGetPixelMapuiv\0"
+ "glGetPixelMapusv\0"
+ "glGetPolygonStipple\0"
+ "glGetString\0"
+ "glGetTexEnvfv\0"
+ "glGetTexEnviv\0"
+ "glGetTexGendv\0"
+ "glGetTexGenfv\0"
+ "glGetTexGeniv\0"
+ "glGetTexImage\0"
+ "glGetTexParameterfv\0"
+ "glGetTexParameteriv\0"
+ "glGetTexLevelParameterfv\0"
+ "glGetTexLevelParameteriv\0"
+ "glIsEnabled\0"
+ "glIsList\0"
+ "glDepthRange\0"
+ "glFrustum\0"
+ "glLoadIdentity\0"
+ "glLoadMatrixf\0"
+ "glLoadMatrixd\0"
+ "glMatrixMode\0"
+ "glMultMatrixf\0"
+ "glMultMatrixd\0"
+ "glOrtho\0"
+ "glPopMatrix\0"
+ "glPushMatrix\0"
+ "glRotated\0"
+ "glRotatef\0"
+ "glScaled\0"
+ "glScalef\0"
+ "glTranslated\0"
+ "glTranslatef\0"
+ "glViewport\0"
+ "glArrayElement\0"
+ "glBindTexture\0"
+ "glColorPointer\0"
+ "glDisableClientState\0"
+ "glDrawArrays\0"
+ "glDrawElements\0"
+ "glEdgeFlagPointer\0"
+ "glEnableClientState\0"
+ "glIndexPointer\0"
+ "glIndexub\0"
+ "glIndexubv\0"
+ "glInterleavedArrays\0"
+ "glNormalPointer\0"
+ "glPolygonOffset\0"
+ "glTexCoordPointer\0"
+ "glVertexPointer\0"
+ "glAreTexturesResident\0"
+ "glCopyTexImage1D\0"
+ "glCopyTexImage2D\0"
+ "glCopyTexSubImage1D\0"
+ "glCopyTexSubImage2D\0"
+ "glDeleteTextures\0"
+ "glGenTextures\0"
+ "glGetPointerv\0"
+ "glIsTexture\0"
+ "glPrioritizeTextures\0"
+ "glTexSubImage1D\0"
+ "glTexSubImage2D\0"
+ "glPopClientAttrib\0"
+ "glPushClientAttrib\0"
+ "glBlendColor\0"
+ "glBlendEquation\0"
+ "glDrawRangeElements\0"
+ "glColorTable\0"
+ "glColorTableParameterfv\0"
+ "glColorTableParameteriv\0"
+ "glCopyColorTable\0"
+ "glGetColorTable\0"
+ "glGetColorTableParameterfv\0"
+ "glGetColorTableParameteriv\0"
+ "glColorSubTable\0"
+ "glCopyColorSubTable\0"
+ "glConvolutionFilter1D\0"
+ "glConvolutionFilter2D\0"
+ "glConvolutionParameterf\0"
+ "glConvolutionParameterfv\0"
+ "glConvolutionParameteri\0"
+ "glConvolutionParameteriv\0"
+ "glCopyConvolutionFilter1D\0"
+ "glCopyConvolutionFilter2D\0"
+ "glGetConvolutionFilter\0"
+ "glGetConvolutionParameterfv\0"
+ "glGetConvolutionParameteriv\0"
+ "glGetSeparableFilter\0"
+ "glSeparableFilter2D\0"
+ "glGetHistogram\0"
+ "glGetHistogramParameterfv\0"
+ "glGetHistogramParameteriv\0"
+ "glGetMinmax\0"
+ "glGetMinmaxParameterfv\0"
+ "glGetMinmaxParameteriv\0"
+ "glHistogram\0"
+ "glMinmax\0"
+ "glResetHistogram\0"
+ "glResetMinmax\0"
+ "glTexImage3D\0"
+ "glTexSubImage3D\0"
+ "glCopyTexSubImage3D\0"
+ "glActiveTextureARB\0"
+ "glClientActiveTextureARB\0"
+ "glMultiTexCoord1dARB\0"
+ "glMultiTexCoord1dvARB\0"
+ "glMultiTexCoord1fARB\0"
+ "glMultiTexCoord1fvARB\0"
+ "glMultiTexCoord1iARB\0"
+ "glMultiTexCoord1ivARB\0"
+ "glMultiTexCoord1sARB\0"
+ "glMultiTexCoord1svARB\0"
+ "glMultiTexCoord2dARB\0"
+ "glMultiTexCoord2dvARB\0"
+ "glMultiTexCoord2fARB\0"
+ "glMultiTexCoord2fvARB\0"
+ "glMultiTexCoord2iARB\0"
+ "glMultiTexCoord2ivARB\0"
+ "glMultiTexCoord2sARB\0"
+ "glMultiTexCoord2svARB\0"
+ "glMultiTexCoord3dARB\0"
+ "glMultiTexCoord3dvARB\0"
+ "glMultiTexCoord3fARB\0"
+ "glMultiTexCoord3fvARB\0"
+ "glMultiTexCoord3iARB\0"
+ "glMultiTexCoord3ivARB\0"
+ "glMultiTexCoord3sARB\0"
+ "glMultiTexCoord3svARB\0"
+ "glMultiTexCoord4dARB\0"
+ "glMultiTexCoord4dvARB\0"
+ "glMultiTexCoord4fARB\0"
+ "glMultiTexCoord4fvARB\0"
+ "glMultiTexCoord4iARB\0"
+ "glMultiTexCoord4ivARB\0"
+ "glMultiTexCoord4sARB\0"
+ "glMultiTexCoord4svARB\0"
+ "glLoadTransposeMatrixfARB\0"
+ "glLoadTransposeMatrixdARB\0"
+ "glMultTransposeMatrixfARB\0"
+ "glMultTransposeMatrixdARB\0"
+ "glSampleCoverageARB\0"
+ "glDrawBuffersARB\0"
+ "glPolygonOffsetEXT\0"
+ "glGetTexFilterFuncSGIS\0"
+ "glTexFilterFuncSGIS\0"
+ "glGetHistogramEXT\0"
+ "glGetHistogramParameterfvEXT\0"
+ "glGetHistogramParameterivEXT\0"
+ "glGetMinmaxEXT\0"
+ "glGetMinmaxParameterfvEXT\0"
+ "glGetMinmaxParameterivEXT\0"
+ "glGetConvolutionFilterEXT\0"
+ "glGetConvolutionParameterfvEXT\0"
+ "glGetConvolutionParameterivEXT\0"
+ "glGetSeparableFilterEXT\0"
+ "glGetColorTableSGI\0"
+ "glGetColorTableParameterfvSGI\0"
+ "glGetColorTableParameterivSGI\0"
+ "glPixelTexGenSGIX\0"
+ "glPixelTexGenParameteriSGIS\0"
+ "glPixelTexGenParameterivSGIS\0"
+ "glPixelTexGenParameterfSGIS\0"
+ "glPixelTexGenParameterfvSGIS\0"
+ "glGetPixelTexGenParameterivSGIS\0"
+ "glGetPixelTexGenParameterfvSGIS\0"
+ "glTexImage4DSGIS\0"
+ "glTexSubImage4DSGIS\0"
+ "glAreTexturesResidentEXT\0"
+ "glGenTexturesEXT\0"
+ "glIsTextureEXT\0"
+ "glDetailTexFuncSGIS\0"
+ "glGetDetailTexFuncSGIS\0"
+ "glSharpenTexFuncSGIS\0"
+ "glGetSharpenTexFuncSGIS\0"
+ "glSampleMaskSGIS\0"
+ "glSamplePatternSGIS\0"
+ "glColorPointerEXT\0"
+ "glEdgeFlagPointerEXT\0"
+ "glIndexPointerEXT\0"
+ "glNormalPointerEXT\0"
+ "glTexCoordPointerEXT\0"
+ "glVertexPointerEXT\0"
+ "glSpriteParameterfSGIX\0"
+ "glSpriteParameterfvSGIX\0"
+ "glSpriteParameteriSGIX\0"
+ "glSpriteParameterivSGIX\0"
+ "glPointParameterfEXT\0"
+ "glPointParameterfvEXT\0"
+ "glGetInstrumentsSGIX\0"
+ "glInstrumentsBufferSGIX\0"
+ "glPollInstrumentsSGIX\0"
+ "glReadInstrumentsSGIX\0"
+ "glStartInstrumentsSGIX\0"
+ "glStopInstrumentsSGIX\0"
+ "glFrameZoomSGIX\0"
+ "glTagSampleBufferSGIX\0"
+ "glReferencePlaneSGIX\0"
+ "glFlushRasterSGIX\0"
+ "glGetListParameterfvSGIX\0"
+ "glGetListParameterivSGIX\0"
+ "glListParameterfSGIX\0"
+ "glListParameterfvSGIX\0"
+ "glListParameteriSGIX\0"
+ "glListParameterivSGIX\0"
+ "glFragmentColorMaterialSGIX\0"
+ "glFragmentLightfSGIX\0"
+ "glFragmentLightfvSGIX\0"
+ "glFragmentLightiSGIX\0"
+ "glFragmentLightivSGIX\0"
+ "glFragmentLightModelfSGIX\0"
+ "glFragmentLightModelfvSGIX\0"
+ "glFragmentLightModeliSGIX\0"
+ "glFragmentLightModelivSGIX\0"
+ "glFragmentMaterialfSGIX\0"
+ "glFragmentMaterialfvSGIX\0"
+ "glFragmentMaterialiSGIX\0"
+ "glFragmentMaterialivSGIX\0"
+ "glGetFragmentLightfvSGIX\0"
+ "glGetFragmentLightivSGIX\0"
+ "glGetFragmentMaterialfvSGIX\0"
+ "glGetFragmentMaterialivSGIX\0"
+ "glLightEnviSGIX\0"
+ "glVertexWeightfEXT\0"
+ "glVertexWeightfvEXT\0"
+ "glVertexWeightPointerEXT\0"
+ "glFlushVertexArrayRangeNV\0"
+ "glVertexArrayRangeNV\0"
+ "glCombinerParameterfvNV\0"
+ "glCombinerParameterfNV\0"
+ "glCombinerParameterivNV\0"
+ "glCombinerParameteriNV\0"
+ "glCombinerInputNV\0"
+ "glCombinerOutputNV\0"
+ "glFinalCombinerInputNV\0"
+ "glGetCombinerInputParameterfvNV\0"
+ "glGetCombinerInputParameterivNV\0"
+ "glGetCombinerOutputParameterfvNV\0"
+ "glGetCombinerOutputParameterivNV\0"
+ "glGetFinalCombinerInputParameterfvNV\0"
+ "glGetFinalCombinerInputParameterivNV\0"
+ "glResizeBuffersMESA\0"
+ "glWindowPos2dMESA\0"
+ "glWindowPos2dvMESA\0"
+ "glWindowPos2fMESA\0"
+ "glWindowPos2fvMESA\0"
+ "glWindowPos2iMESA\0"
+ "glWindowPos2ivMESA\0"
+ "glWindowPos2sMESA\0"
+ "glWindowPos2svMESA\0"
+ "glWindowPos3dMESA\0"
+ "glWindowPos3dvMESA\0"
+ "glWindowPos3fMESA\0"
+ "glWindowPos3fvMESA\0"
+ "glWindowPos3iMESA\0"
+ "glWindowPos3ivMESA\0"
+ "glWindowPos3sMESA\0"
+ "glWindowPos3svMESA\0"
+ "glWindowPos4dMESA\0"
+ "glWindowPos4dvMESA\0"
+ "glWindowPos4fMESA\0"
+ "glWindowPos4fvMESA\0"
+ "glWindowPos4iMESA\0"
+ "glWindowPos4ivMESA\0"
+ "glWindowPos4sMESA\0"
+ "glWindowPos4svMESA\0"
+ "glBlendFuncSeparateEXT\0"
+ "glIndexMaterialEXT\0"
+ "glIndexFuncEXT\0"
+ "glLockArraysEXT\0"
+ "glUnlockArraysEXT\0"
+ "glCullParameterdvEXT\0"
+ "glCullParameterfvEXT\0"
+ "glHintPGI\0"
+ "glFogCoordfEXT\0"
+ "glFogCoordfvEXT\0"
+ "glFogCoorddEXT\0"
+ "glFogCoorddvEXT\0"
+ "glFogCoordPointerEXT\0"
+ "glGetColorTableEXT\0"
+ "glGetColorTableParameterivEXT\0"
+ "glGetColorTableParameterfvEXT\0"
+ "glTbufferMask3DFX\0"
+ "glCompressedTexImage3DARB\0"
+ "glCompressedTexImage2DARB\0"
+ "glCompressedTexImage1DARB\0"
+ "glCompressedTexSubImage3DARB\0"
+ "glCompressedTexSubImage2DARB\0"
+ "glCompressedTexSubImage1DARB\0"
+ "glGetCompressedTexImageARB\0"
+ "glSecondaryColor3bEXT\0"
+ "glSecondaryColor3bvEXT\0"
+ "glSecondaryColor3dEXT\0"
+ "glSecondaryColor3dvEXT\0"
+ "glSecondaryColor3fEXT\0"
+ "glSecondaryColor3fvEXT\0"
+ "glSecondaryColor3iEXT\0"
+ "glSecondaryColor3ivEXT\0"
+ "glSecondaryColor3sEXT\0"
+ "glSecondaryColor3svEXT\0"
+ "glSecondaryColor3ubEXT\0"
+ "glSecondaryColor3ubvEXT\0"
+ "glSecondaryColor3uiEXT\0"
+ "glSecondaryColor3uivEXT\0"
+ "glSecondaryColor3usEXT\0"
+ "glSecondaryColor3usvEXT\0"
+ "glSecondaryColorPointerEXT\0"
+ "glAreProgramsResidentNV\0"
+ "glBindProgramNV\0"
+ "glDeleteProgramsNV\0"
+ "glExecuteProgramNV\0"
+ "glGenProgramsNV\0"
+ "glGetProgramParameterdvNV\0"
+ "glGetProgramParameterfvNV\0"
+ "glGetProgramivNV\0"
+ "glGetProgramStringNV\0"
+ "glGetTrackMatrixivNV\0"
+ "glGetVertexAttribdvARB\0"
+ "glGetVertexAttribfvARB\0"
+ "glGetVertexAttribivARB\0"
+ "glGetVertexAttribPointervNV\0"
+ "glIsProgramNV\0"
+ "glLoadProgramNV\0"
+ "glProgramParameter4dNV\0"
+ "glProgramParameter4dvNV\0"
+ "glProgramParameter4fNV\0"
+ "glProgramParameter4fvNV\0"
+ "glProgramParameters4dvNV\0"
+ "glProgramParameters4fvNV\0"
+ "glRequestResidentProgramsNV\0"
+ "glTrackMatrixNV\0"
+ "glVertexAttribPointerNV\0"
+ "glVertexAttrib1dARB\0"
+ "glVertexAttrib1dvARB\0"
+ "glVertexAttrib1fARB\0"
+ "glVertexAttrib1fvARB\0"
+ "glVertexAttrib1sARB\0"
+ "glVertexAttrib1svARB\0"
+ "glVertexAttrib2dARB\0"
+ "glVertexAttrib2dvARB\0"
+ "glVertexAttrib2fARB\0"
+ "glVertexAttrib2fvARB\0"
+ "glVertexAttrib2sARB\0"
+ "glVertexAttrib2svARB\0"
+ "glVertexAttrib3dARB\0"
+ "glVertexAttrib3dvARB\0"
+ "glVertexAttrib3fARB\0"
+ "glVertexAttrib3fvARB\0"
+ "glVertexAttrib3sARB\0"
+ "glVertexAttrib3svARB\0"
+ "glVertexAttrib4dARB\0"
+ "glVertexAttrib4dvARB\0"
+ "glVertexAttrib4fARB\0"
+ "glVertexAttrib4fvARB\0"
+ "glVertexAttrib4sARB\0"
+ "glVertexAttrib4svARB\0"
+ "glVertexAttrib4NubARB\0"
+ "glVertexAttrib4NubvARB\0"
+ "glVertexAttribs1dvNV\0"
+ "glVertexAttribs1fvNV\0"
+ "glVertexAttribs1svNV\0"
+ "glVertexAttribs2dvNV\0"
+ "glVertexAttribs2fvNV\0"
+ "glVertexAttribs2svNV\0"
+ "glVertexAttribs3dvNV\0"
+ "glVertexAttribs3fvNV\0"
+ "glVertexAttribs3svNV\0"
+ "glVertexAttribs4dvNV\0"
+ "glVertexAttribs4fvNV\0"
+ "glVertexAttribs4svNV\0"
+ "glVertexAttribs4ubvNV\0"
+ "glPointParameteriNV\0"
+ "glPointParameterivNV\0"
+ "glMultiDrawArraysEXT\0"
+ "glMultiDrawElementsEXT\0"
+ "glActiveStencilFaceEXT\0"
+ "glDeleteFencesNV\0"
+ "glGenFencesNV\0"
+ "glIsFenceNV\0"
+ "glTestFenceNV\0"
+ "glGetFenceivNV\0"
+ "glFinishFenceNV\0"
+ "glSetFenceNV\0"
+ "glVertexAttrib4bvARB\0"
+ "glVertexAttrib4ivARB\0"
+ "glVertexAttrib4ubvARB\0"
+ "glVertexAttrib4usvARB\0"
+ "glVertexAttrib4uivARB\0"
+ "glVertexAttrib4NbvARB\0"
+ "glVertexAttrib4NsvARB\0"
+ "glVertexAttrib4NivARB\0"
+ "glVertexAttrib4NusvARB\0"
+ "glVertexAttrib4NuivARB\0"
+ "glVertexAttribPointerARB\0"
+ "glEnableVertexAttribArrayARB\0"
+ "glDisableVertexAttribArrayARB\0"
+ "glProgramStringARB\0"
+ "glProgramEnvParameter4dARB\0"
+ "glProgramEnvParameter4dvARB\0"
+ "glProgramEnvParameter4fARB\0"
+ "glProgramEnvParameter4fvARB\0"
+ "glProgramLocalParameter4dARB\0"
+ "glProgramLocalParameter4dvARB\0"
+ "glProgramLocalParameter4fARB\0"
+ "glProgramLocalParameter4fvARB\0"
+ "glGetProgramEnvParameterdvARB\0"
+ "glGetProgramEnvParameterfvARB\0"
+ "glGetProgramLocalParameterdvARB\0"
+ "glGetProgramLocalParameterfvARB\0"
+ "glGetProgramivARB\0"
+ "glGetProgramStringARB\0"
+ "glProgramNamedParameter4fNV\0"
+ "glProgramNamedParameter4dNV\0"
+ "glProgramNamedParameter4fvNV\0"
+ "glProgramNamedParameter4dvNV\0"
+ "glGetProgramNamedParameterfvNV\0"
+ "glGetProgramNamedParameterdvNV\0"
+ "glBindBufferARB\0"
+ "glBufferDataARB\0"
+ "glBufferSubDataARB\0"
+ "glDeleteBuffersARB\0"
+ "glGenBuffersARB\0"
+ "glGetBufferParameterivARB\0"
+ "glGetBufferPointervARB\0"
+ "glGetBufferSubDataARB\0"
+ "glIsBufferARB\0"
+ "glMapBufferARB\0"
+ "glUnmapBufferARB\0"
+ "glDepthBoundsEXT\0"
+ "glGenQueriesARB\0"
+ "glDeleteQueriesARB\0"
+ "glIsQueryARB\0"
+ "glBeginQueryARB\0"
+ "glEndQueryARB\0"
+ "glGetQueryivARB\0"
+ "glGetQueryObjectivARB\0"
+ "glGetQueryObjectuivARB\0"
+ "glMultiModeDrawArraysIBM\0"
+ "glMultiModeDrawElementsIBM\0"
+ "glBlendEquationSeparateEXT\0"
+ "glDeleteObjectARB\0"
+ "glGetHandleARB\0"
+ "glDetachObjectARB\0"
+ "glCreateShaderObjectARB\0"
+ "glShaderSourceARB\0"
+ "glCompileShaderARB\0"
+ "glCreateProgramObjectARB\0"
+ "glAttachObjectARB\0"
+ "glLinkProgramARB\0"
+ "glUseProgramObjectARB\0"
+ "glValidateProgramARB\0"
+ "glUniform1fARB\0"
+ "glUniform2fARB\0"
+ "glUniform3fARB\0"
+ "glUniform4fARB\0"
+ "glUniform1iARB\0"
+ "glUniform2iARB\0"
+ "glUniform3iARB\0"
+ "glUniform4iARB\0"
+ "glUniform1fvARB\0"
+ "glUniform2fvARB\0"
+ "glUniform3fvARB\0"
+ "glUniform4fvARB\0"
+ "glUniform1ivARB\0"
+ "glUniform2ivARB\0"
+ "glUniform3ivARB\0"
+ "glUniform4ivARB\0"
+ "glUniformMatrix2fvARB\0"
+ "glUniformMatrix3fvARB\0"
+ "glUniformMatrix4fvARB\0"
+ "glGetObjectParameterfvARB\0"
+ "glGetObjectParameterivARB\0"
+ "glGetInfoLogARB\0"
+ "glGetAttachedObjectsARB\0"
+ "glGetUniformLocationARB\0"
+ "glGetActiveUniformARB\0"
+ "glGetUniformfvARB\0"
+ "glGetUniformivARB\0"
+ "glGetShaderSourceARB\0"
+ "glBindAttribLocationARB\0"
+ "glGetActiveAttribARB\0"
+ "glGetAttribLocationARB\0"
+ "glGetVertexAttribdvNV\0"
+ "glGetVertexAttribfvNV\0"
+ "glGetVertexAttribivNV\0"
+ "glVertexAttrib1dNV\0"
+ "glVertexAttrib1dvNV\0"
+ "glVertexAttrib1fNV\0"
+ "glVertexAttrib1fvNV\0"
+ "glVertexAttrib1sNV\0"
+ "glVertexAttrib1svNV\0"
+ "glVertexAttrib2dNV\0"
+ "glVertexAttrib2dvNV\0"
+ "glVertexAttrib2fNV\0"
+ "glVertexAttrib2fvNV\0"
+ "glVertexAttrib2sNV\0"
+ "glVertexAttrib2svNV\0"
+ "glVertexAttrib3dNV\0"
+ "glVertexAttrib3dvNV\0"
+ "glVertexAttrib3fNV\0"
+ "glVertexAttrib3fvNV\0"
+ "glVertexAttrib3sNV\0"
+ "glVertexAttrib3svNV\0"
+ "glVertexAttrib4dNV\0"
+ "glVertexAttrib4dvNV\0"
+ "glVertexAttrib4fNV\0"
+ "glVertexAttrib4fvNV\0"
+ "glVertexAttrib4sNV\0"
+ "glVertexAttrib4svNV\0"
+ "glVertexAttrib4ubNV\0"
+ "glVertexAttrib4ubvNV\0"
+ "glGenFragmentShadersATI\0"
+ "glBindFragmentShaderATI\0"
+ "glDeleteFragmentShaderATI\0"
+ "glBeginFragmentShaderATI\0"
+ "glEndFragmentShaderATI\0"
+ "glPassTexCoordATI\0"
+ "glSampleMapATI\0"
+ "glColorFragmentOp1ATI\0"
+ "glColorFragmentOp2ATI\0"
+ "glColorFragmentOp3ATI\0"
+ "glAlphaFragmentOp1ATI\0"
+ "glAlphaFragmentOp2ATI\0"
+ "glAlphaFragmentOp3ATI\0"
+ "glSetFragmentShaderConstantATI\0"
+ "glIsRenderbufferEXT\0"
+ "glBindRenderbufferEXT\0"
+ "glDeleteRenderbuffersEXT\0"
+ "glGenRenderbuffersEXT\0"
+ "glRenderbufferStorageEXT\0"
+ "glGetRenderbufferParameterivEXT\0"
+ "glIsFramebufferEXT\0"
+ "glBindFramebufferEXT\0"
+ "glDeleteFramebuffersEXT\0"
+ "glGenFramebuffersEXT\0"
+ "glCheckFramebufferStatusEXT\0"
+ "glFramebufferTexture1DEXT\0"
+ "glFramebufferTexture2DEXT\0"
+ "glFramebufferTexture3DEXT\0"
+ "glFramebufferRenderbufferEXT\0"
+ "glGetFramebufferAttachmentParameterivEXT\0"
+ "glGenerateMipmapEXT\0"
+ "glStencilFuncSeparate\0"
+ "glStencilOpSeparate\0"
+ "glStencilMaskSeparate\0"
+ "glArrayElementEXT\0"
+ "glBindTextureEXT\0"
+ "glDrawArraysEXT\0"
+ "glCopyTexImage1DEXT\0"
+ "glCopyTexImage2DEXT\0"
+ "glCopyTexSubImage1DEXT\0"
+ "glCopyTexSubImage2DEXT\0"
+ "glDeleteTexturesEXT\0"
+ "glGetPointervEXT\0"
+ "glPrioritizeTexturesEXT\0"
+ "glTexSubImage1DEXT\0"
+ "glTexSubImage2DEXT\0"
+ "glBlendColorEXT\0"
+ "glBlendEquationEXT\0"
+ "glDrawRangeElementsEXT\0"
+ "glColorTableSGI\0"
+ "glColorTableEXT\0"
+ "glColorTableParameterfvSGI\0"
+ "glColorTableParameterivSGI\0"
+ "glCopyColorTableSGI\0"
+ "glColorSubTableEXT\0"
+ "glCopyColorSubTableEXT\0"
+ "glConvolutionFilter1DEXT\0"
+ "glConvolutionFilter2DEXT\0"
+ "glConvolutionParameterfEXT\0"
+ "glConvolutionParameterfvEXT\0"
+ "glConvolutionParameteriEXT\0"
+ "glConvolutionParameterivEXT\0"
+ "glCopyConvolutionFilter1DEXT\0"
+ "glCopyConvolutionFilter2DEXT\0"
+ "glSeparableFilter2DEXT\0"
+ "glHistogramEXT\0"
+ "glMinmaxEXT\0"
+ "glResetHistogramEXT\0"
+ "glResetMinmaxEXT\0"
+ "glTexImage3DEXT\0"
+ "glTexSubImage3DEXT\0"
+ "glCopyTexSubImage3DEXT\0"
+ "glActiveTexture\0"
+ "glClientActiveTexture\0"
+ "glMultiTexCoord1d\0"
+ "glMultiTexCoord1dv\0"
+ "glMultiTexCoord1f\0"
+ "glMultiTexCoord1fv\0"
+ "glMultiTexCoord1i\0"
+ "glMultiTexCoord1iv\0"
+ "glMultiTexCoord1s\0"
+ "glMultiTexCoord1sv\0"
+ "glMultiTexCoord2d\0"
+ "glMultiTexCoord2dv\0"
+ "glMultiTexCoord2f\0"
+ "glMultiTexCoord2fv\0"
+ "glMultiTexCoord2i\0"
+ "glMultiTexCoord2iv\0"
+ "glMultiTexCoord2s\0"
+ "glMultiTexCoord2sv\0"
+ "glMultiTexCoord3d\0"
+ "glMultiTexCoord3dv\0"
+ "glMultiTexCoord3f\0"
+ "glMultiTexCoord3fv\0"
+ "glMultiTexCoord3i\0"
+ "glMultiTexCoord3iv\0"
+ "glMultiTexCoord3s\0"
+ "glMultiTexCoord3sv\0"
+ "glMultiTexCoord4d\0"
+ "glMultiTexCoord4dv\0"
+ "glMultiTexCoord4f\0"
+ "glMultiTexCoord4fv\0"
+ "glMultiTexCoord4i\0"
+ "glMultiTexCoord4iv\0"
+ "glMultiTexCoord4s\0"
+ "glMultiTexCoord4sv\0"
+ "glLoadTransposeMatrixf\0"
+ "glLoadTransposeMatrixd\0"
+ "glMultTransposeMatrixf\0"
+ "glMultTransposeMatrixd\0"
+ "glSampleCoverage\0"
+ "glDrawBuffersATI\0"
+ "glSampleMaskEXT\0"
+ "glSamplePatternEXT\0"
+ "glPointParameterf\0"
+ "glPointParameterfARB\0"
+ "glPointParameterfSGIS\0"
+ "glPointParameterfv\0"
+ "glPointParameterfvARB\0"
+ "glPointParameterfvSGIS\0"
+ "glWindowPos2d\0"
+ "glWindowPos2dARB\0"
+ "glWindowPos2dv\0"
+ "glWindowPos2dvARB\0"
+ "glWindowPos2f\0"
+ "glWindowPos2fARB\0"
+ "glWindowPos2fv\0"
+ "glWindowPos2fvARB\0"
+ "glWindowPos2i\0"
+ "glWindowPos2iARB\0"
+ "glWindowPos2iv\0"
+ "glWindowPos2ivARB\0"
+ "glWindowPos2s\0"
+ "glWindowPos2sARB\0"
+ "glWindowPos2sv\0"
+ "glWindowPos2svARB\0"
+ "glWindowPos3d\0"
+ "glWindowPos3dARB\0"
+ "glWindowPos3dv\0"
+ "glWindowPos3dvARB\0"
+ "glWindowPos3f\0"
+ "glWindowPos3fARB\0"
+ "glWindowPos3fv\0"
+ "glWindowPos3fvARB\0"
+ "glWindowPos3i\0"
+ "glWindowPos3iARB\0"
+ "glWindowPos3iv\0"
+ "glWindowPos3ivARB\0"
+ "glWindowPos3s\0"
+ "glWindowPos3sARB\0"
+ "glWindowPos3sv\0"
+ "glWindowPos3svARB\0"
+ "glBlendFuncSeparate\0"
+ "glBlendFuncSeparateINGR\0"
+ "glFogCoordf\0"
+ "glFogCoordfv\0"
+ "glFogCoordd\0"
+ "glFogCoorddv\0"
+ "glFogCoordPointer\0"
+ "glCompressedTexImage3D\0"
+ "glCompressedTexImage2D\0"
+ "glCompressedTexImage1D\0"
+ "glCompressedTexSubImage3D\0"
+ "glCompressedTexSubImage2D\0"
+ "glCompressedTexSubImage1D\0"
+ "glGetCompressedTexImage\0"
+ "glSecondaryColor3b\0"
+ "glSecondaryColor3bv\0"
+ "glSecondaryColor3d\0"
+ "glSecondaryColor3dv\0"
+ "glSecondaryColor3f\0"
+ "glSecondaryColor3fv\0"
+ "glSecondaryColor3i\0"
+ "glSecondaryColor3iv\0"
+ "glSecondaryColor3s\0"
+ "glSecondaryColor3sv\0"
+ "glSecondaryColor3ub\0"
+ "glSecondaryColor3ubv\0"
+ "glSecondaryColor3ui\0"
+ "glSecondaryColor3uiv\0"
+ "glSecondaryColor3us\0"
+ "glSecondaryColor3usv\0"
+ "glSecondaryColorPointer\0"
+ "glBindProgramARB\0"
+ "glDeleteProgramsARB\0"
+ "glGenProgramsARB\0"
+ "glGetVertexAttribPointervARB\0"
+ "glIsProgramARB\0"
+ "glPointParameteri\0"
+ "glPointParameteriv\0"
+ "glMultiDrawArrays\0"
+ "glMultiDrawElements\0"
+ "glBindBuffer\0"
+ "glBufferData\0"
+ "glBufferSubData\0"
+ "glDeleteBuffers\0"
+ "glGenBuffers\0"
+ "glGetBufferParameteriv\0"
+ "glGetBufferPointerv\0"
+ "glGetBufferSubData\0"
+ "glIsBuffer\0"
+ "glMapBuffer\0"
+ "glUnmapBuffer\0"
+ "glGenQueries\0"
+ "glDeleteQueries\0"
+ "glIsQuery\0"
+ "glBeginQuery\0"
+ "glEndQuery\0"
+ "glGetQueryiv\0"
+ "glGetQueryObjectiv\0"
+ "glGetQueryObjectuiv\0"
+ "glBlendEquationSeparateATI\0"
+ ;
+
+static const glprocs_table_t static_functions[] = {
+ NAME_FUNC_OFFSET( 0, glNewList, _gloffset_NewList ),
+ NAME_FUNC_OFFSET( 10, glEndList, _gloffset_EndList ),
+ NAME_FUNC_OFFSET( 20, glCallList, _gloffset_CallList ),
+ NAME_FUNC_OFFSET( 31, glCallLists, _gloffset_CallLists ),
+ NAME_FUNC_OFFSET( 43, glDeleteLists, _gloffset_DeleteLists ),
+ NAME_FUNC_OFFSET( 57, glGenLists, _gloffset_GenLists ),
+ NAME_FUNC_OFFSET( 68, glListBase, _gloffset_ListBase ),
+ NAME_FUNC_OFFSET( 79, glBegin, _gloffset_Begin ),
+ NAME_FUNC_OFFSET( 87, glBitmap, _gloffset_Bitmap ),
+ NAME_FUNC_OFFSET( 96, glColor3b, _gloffset_Color3b ),
+ NAME_FUNC_OFFSET( 106, glColor3bv, _gloffset_Color3bv ),
+ NAME_FUNC_OFFSET( 117, glColor3d, _gloffset_Color3d ),
+ NAME_FUNC_OFFSET( 127, glColor3dv, _gloffset_Color3dv ),
+ NAME_FUNC_OFFSET( 138, glColor3f, _gloffset_Color3f ),
+ NAME_FUNC_OFFSET( 148, glColor3fv, _gloffset_Color3fv ),
+ NAME_FUNC_OFFSET( 159, glColor3i, _gloffset_Color3i ),
+ NAME_FUNC_OFFSET( 169, glColor3iv, _gloffset_Color3iv ),
+ NAME_FUNC_OFFSET( 180, glColor3s, _gloffset_Color3s ),
+ NAME_FUNC_OFFSET( 190, glColor3sv, _gloffset_Color3sv ),
+ NAME_FUNC_OFFSET( 201, glColor3ub, _gloffset_Color3ub ),
+ NAME_FUNC_OFFSET( 212, glColor3ubv, _gloffset_Color3ubv ),
+ NAME_FUNC_OFFSET( 224, glColor3ui, _gloffset_Color3ui ),
+ NAME_FUNC_OFFSET( 235, glColor3uiv, _gloffset_Color3uiv ),
+ NAME_FUNC_OFFSET( 247, glColor3us, _gloffset_Color3us ),
+ NAME_FUNC_OFFSET( 258, glColor3usv, _gloffset_Color3usv ),
+ NAME_FUNC_OFFSET( 270, glColor4b, _gloffset_Color4b ),
+ NAME_FUNC_OFFSET( 280, glColor4bv, _gloffset_Color4bv ),
+ NAME_FUNC_OFFSET( 291, glColor4d, _gloffset_Color4d ),
+ NAME_FUNC_OFFSET( 301, glColor4dv, _gloffset_Color4dv ),
+ NAME_FUNC_OFFSET( 312, glColor4f, _gloffset_Color4f ),
+ NAME_FUNC_OFFSET( 322, glColor4fv, _gloffset_Color4fv ),
+ NAME_FUNC_OFFSET( 333, glColor4i, _gloffset_Color4i ),
+ NAME_FUNC_OFFSET( 343, glColor4iv, _gloffset_Color4iv ),
+ NAME_FUNC_OFFSET( 354, glColor4s, _gloffset_Color4s ),
+ NAME_FUNC_OFFSET( 364, glColor4sv, _gloffset_Color4sv ),
+ NAME_FUNC_OFFSET( 375, glColor4ub, _gloffset_Color4ub ),
+ NAME_FUNC_OFFSET( 386, glColor4ubv, _gloffset_Color4ubv ),
+ NAME_FUNC_OFFSET( 398, glColor4ui, _gloffset_Color4ui ),
+ NAME_FUNC_OFFSET( 409, glColor4uiv, _gloffset_Color4uiv ),
+ NAME_FUNC_OFFSET( 421, glColor4us, _gloffset_Color4us ),
+ NAME_FUNC_OFFSET( 432, glColor4usv, _gloffset_Color4usv ),
+ NAME_FUNC_OFFSET( 444, glEdgeFlag, _gloffset_EdgeFlag ),
+ NAME_FUNC_OFFSET( 455, glEdgeFlagv, _gloffset_EdgeFlagv ),
+ NAME_FUNC_OFFSET( 467, glEnd, _gloffset_End ),
+ NAME_FUNC_OFFSET( 473, glIndexd, _gloffset_Indexd ),
+ NAME_FUNC_OFFSET( 482, glIndexdv, _gloffset_Indexdv ),
+ NAME_FUNC_OFFSET( 492, glIndexf, _gloffset_Indexf ),
+ NAME_FUNC_OFFSET( 501, glIndexfv, _gloffset_Indexfv ),
+ NAME_FUNC_OFFSET( 511, glIndexi, _gloffset_Indexi ),
+ NAME_FUNC_OFFSET( 520, glIndexiv, _gloffset_Indexiv ),
+ NAME_FUNC_OFFSET( 530, glIndexs, _gloffset_Indexs ),
+ NAME_FUNC_OFFSET( 539, glIndexsv, _gloffset_Indexsv ),
+ NAME_FUNC_OFFSET( 549, glNormal3b, _gloffset_Normal3b ),
+ NAME_FUNC_OFFSET( 560, glNormal3bv, _gloffset_Normal3bv ),
+ NAME_FUNC_OFFSET( 572, glNormal3d, _gloffset_Normal3d ),
+ NAME_FUNC_OFFSET( 583, glNormal3dv, _gloffset_Normal3dv ),
+ NAME_FUNC_OFFSET( 595, glNormal3f, _gloffset_Normal3f ),
+ NAME_FUNC_OFFSET( 606, glNormal3fv, _gloffset_Normal3fv ),
+ NAME_FUNC_OFFSET( 618, glNormal3i, _gloffset_Normal3i ),
+ NAME_FUNC_OFFSET( 629, glNormal3iv, _gloffset_Normal3iv ),
+ NAME_FUNC_OFFSET( 641, glNormal3s, _gloffset_Normal3s ),
+ NAME_FUNC_OFFSET( 652, glNormal3sv, _gloffset_Normal3sv ),
+ NAME_FUNC_OFFSET( 664, glRasterPos2d, _gloffset_RasterPos2d ),
+ NAME_FUNC_OFFSET( 678, glRasterPos2dv, _gloffset_RasterPos2dv ),
+ NAME_FUNC_OFFSET( 693, glRasterPos2f, _gloffset_RasterPos2f ),
+ NAME_FUNC_OFFSET( 707, glRasterPos2fv, _gloffset_RasterPos2fv ),
+ NAME_FUNC_OFFSET( 722, glRasterPos2i, _gloffset_RasterPos2i ),
+ NAME_FUNC_OFFSET( 736, glRasterPos2iv, _gloffset_RasterPos2iv ),
+ NAME_FUNC_OFFSET( 751, glRasterPos2s, _gloffset_RasterPos2s ),
+ NAME_FUNC_OFFSET( 765, glRasterPos2sv, _gloffset_RasterPos2sv ),
+ NAME_FUNC_OFFSET( 780, glRasterPos3d, _gloffset_RasterPos3d ),
+ NAME_FUNC_OFFSET( 794, glRasterPos3dv, _gloffset_RasterPos3dv ),
+ NAME_FUNC_OFFSET( 809, glRasterPos3f, _gloffset_RasterPos3f ),
+ NAME_FUNC_OFFSET( 823, glRasterPos3fv, _gloffset_RasterPos3fv ),
+ NAME_FUNC_OFFSET( 838, glRasterPos3i, _gloffset_RasterPos3i ),
+ NAME_FUNC_OFFSET( 852, glRasterPos3iv, _gloffset_RasterPos3iv ),
+ NAME_FUNC_OFFSET( 867, glRasterPos3s, _gloffset_RasterPos3s ),
+ NAME_FUNC_OFFSET( 881, glRasterPos3sv, _gloffset_RasterPos3sv ),
+ NAME_FUNC_OFFSET( 896, glRasterPos4d, _gloffset_RasterPos4d ),
+ NAME_FUNC_OFFSET( 910, glRasterPos4dv, _gloffset_RasterPos4dv ),
+ NAME_FUNC_OFFSET( 925, glRasterPos4f, _gloffset_RasterPos4f ),
+ NAME_FUNC_OFFSET( 939, glRasterPos4fv, _gloffset_RasterPos4fv ),
+ NAME_FUNC_OFFSET( 954, glRasterPos4i, _gloffset_RasterPos4i ),
+ NAME_FUNC_OFFSET( 968, glRasterPos4iv, _gloffset_RasterPos4iv ),
+ NAME_FUNC_OFFSET( 983, glRasterPos4s, _gloffset_RasterPos4s ),
+ NAME_FUNC_OFFSET( 997, glRasterPos4sv, _gloffset_RasterPos4sv ),
+ NAME_FUNC_OFFSET( 1012, glRectd, _gloffset_Rectd ),
+ NAME_FUNC_OFFSET( 1020, glRectdv, _gloffset_Rectdv ),
+ NAME_FUNC_OFFSET( 1029, glRectf, _gloffset_Rectf ),
+ NAME_FUNC_OFFSET( 1037, glRectfv, _gloffset_Rectfv ),
+ NAME_FUNC_OFFSET( 1046, glRecti, _gloffset_Recti ),
+ NAME_FUNC_OFFSET( 1054, glRectiv, _gloffset_Rectiv ),
+ NAME_FUNC_OFFSET( 1063, glRects, _gloffset_Rects ),
+ NAME_FUNC_OFFSET( 1071, glRectsv, _gloffset_Rectsv ),
+ NAME_FUNC_OFFSET( 1080, glTexCoord1d, _gloffset_TexCoord1d ),
+ NAME_FUNC_OFFSET( 1093, glTexCoord1dv, _gloffset_TexCoord1dv ),
+ NAME_FUNC_OFFSET( 1107, glTexCoord1f, _gloffset_TexCoord1f ),
+ NAME_FUNC_OFFSET( 1120, glTexCoord1fv, _gloffset_TexCoord1fv ),
+ NAME_FUNC_OFFSET( 1134, glTexCoord1i, _gloffset_TexCoord1i ),
+ NAME_FUNC_OFFSET( 1147, glTexCoord1iv, _gloffset_TexCoord1iv ),
+ NAME_FUNC_OFFSET( 1161, glTexCoord1s, _gloffset_TexCoord1s ),
+ NAME_FUNC_OFFSET( 1174, glTexCoord1sv, _gloffset_TexCoord1sv ),
+ NAME_FUNC_OFFSET( 1188, glTexCoord2d, _gloffset_TexCoord2d ),
+ NAME_FUNC_OFFSET( 1201, glTexCoord2dv, _gloffset_TexCoord2dv ),
+ NAME_FUNC_OFFSET( 1215, glTexCoord2f, _gloffset_TexCoord2f ),
+ NAME_FUNC_OFFSET( 1228, glTexCoord2fv, _gloffset_TexCoord2fv ),
+ NAME_FUNC_OFFSET( 1242, glTexCoord2i, _gloffset_TexCoord2i ),
+ NAME_FUNC_OFFSET( 1255, glTexCoord2iv, _gloffset_TexCoord2iv ),
+ NAME_FUNC_OFFSET( 1269, glTexCoord2s, _gloffset_TexCoord2s ),
+ NAME_FUNC_OFFSET( 1282, glTexCoord2sv, _gloffset_TexCoord2sv ),
+ NAME_FUNC_OFFSET( 1296, glTexCoord3d, _gloffset_TexCoord3d ),
+ NAME_FUNC_OFFSET( 1309, glTexCoord3dv, _gloffset_TexCoord3dv ),
+ NAME_FUNC_OFFSET( 1323, glTexCoord3f, _gloffset_TexCoord3f ),
+ NAME_FUNC_OFFSET( 1336, glTexCoord3fv, _gloffset_TexCoord3fv ),
+ NAME_FUNC_OFFSET( 1350, glTexCoord3i, _gloffset_TexCoord3i ),
+ NAME_FUNC_OFFSET( 1363, glTexCoord3iv, _gloffset_TexCoord3iv ),
+ NAME_FUNC_OFFSET( 1377, glTexCoord3s, _gloffset_TexCoord3s ),
+ NAME_FUNC_OFFSET( 1390, glTexCoord3sv, _gloffset_TexCoord3sv ),
+ NAME_FUNC_OFFSET( 1404, glTexCoord4d, _gloffset_TexCoord4d ),
+ NAME_FUNC_OFFSET( 1417, glTexCoord4dv, _gloffset_TexCoord4dv ),
+ NAME_FUNC_OFFSET( 1431, glTexCoord4f, _gloffset_TexCoord4f ),
+ NAME_FUNC_OFFSET( 1444, glTexCoord4fv, _gloffset_TexCoord4fv ),
+ NAME_FUNC_OFFSET( 1458, glTexCoord4i, _gloffset_TexCoord4i ),
+ NAME_FUNC_OFFSET( 1471, glTexCoord4iv, _gloffset_TexCoord4iv ),
+ NAME_FUNC_OFFSET( 1485, glTexCoord4s, _gloffset_TexCoord4s ),
+ NAME_FUNC_OFFSET( 1498, glTexCoord4sv, _gloffset_TexCoord4sv ),
+ NAME_FUNC_OFFSET( 1512, glVertex2d, _gloffset_Vertex2d ),
+ NAME_FUNC_OFFSET( 1523, glVertex2dv, _gloffset_Vertex2dv ),
+ NAME_FUNC_OFFSET( 1535, glVertex2f, _gloffset_Vertex2f ),
+ NAME_FUNC_OFFSET( 1546, glVertex2fv, _gloffset_Vertex2fv ),
+ NAME_FUNC_OFFSET( 1558, glVertex2i, _gloffset_Vertex2i ),
+ NAME_FUNC_OFFSET( 1569, glVertex2iv, _gloffset_Vertex2iv ),
+ NAME_FUNC_OFFSET( 1581, glVertex2s, _gloffset_Vertex2s ),
+ NAME_FUNC_OFFSET( 1592, glVertex2sv, _gloffset_Vertex2sv ),
+ NAME_FUNC_OFFSET( 1604, glVertex3d, _gloffset_Vertex3d ),
+ NAME_FUNC_OFFSET( 1615, glVertex3dv, _gloffset_Vertex3dv ),
+ NAME_FUNC_OFFSET( 1627, glVertex3f, _gloffset_Vertex3f ),
+ NAME_FUNC_OFFSET( 1638, glVertex3fv, _gloffset_Vertex3fv ),
+ NAME_FUNC_OFFSET( 1650, glVertex3i, _gloffset_Vertex3i ),
+ NAME_FUNC_OFFSET( 1661, glVertex3iv, _gloffset_Vertex3iv ),
+ NAME_FUNC_OFFSET( 1673, glVertex3s, _gloffset_Vertex3s ),
+ NAME_FUNC_OFFSET( 1684, glVertex3sv, _gloffset_Vertex3sv ),
+ NAME_FUNC_OFFSET( 1696, glVertex4d, _gloffset_Vertex4d ),
+ NAME_FUNC_OFFSET( 1707, glVertex4dv, _gloffset_Vertex4dv ),
+ NAME_FUNC_OFFSET( 1719, glVertex4f, _gloffset_Vertex4f ),
+ NAME_FUNC_OFFSET( 1730, glVertex4fv, _gloffset_Vertex4fv ),
+ NAME_FUNC_OFFSET( 1742, glVertex4i, _gloffset_Vertex4i ),
+ NAME_FUNC_OFFSET( 1753, glVertex4iv, _gloffset_Vertex4iv ),
+ NAME_FUNC_OFFSET( 1765, glVertex4s, _gloffset_Vertex4s ),
+ NAME_FUNC_OFFSET( 1776, glVertex4sv, _gloffset_Vertex4sv ),
+ NAME_FUNC_OFFSET( 1788, glClipPlane, _gloffset_ClipPlane ),
+ NAME_FUNC_OFFSET( 1800, glColorMaterial, _gloffset_ColorMaterial ),
+ NAME_FUNC_OFFSET( 1816, glCullFace, _gloffset_CullFace ),
+ NAME_FUNC_OFFSET( 1827, glFogf, _gloffset_Fogf ),
+ NAME_FUNC_OFFSET( 1834, glFogfv, _gloffset_Fogfv ),
+ NAME_FUNC_OFFSET( 1842, glFogi, _gloffset_Fogi ),
+ NAME_FUNC_OFFSET( 1849, glFogiv, _gloffset_Fogiv ),
+ NAME_FUNC_OFFSET( 1857, glFrontFace, _gloffset_FrontFace ),
+ NAME_FUNC_OFFSET( 1869, glHint, _gloffset_Hint ),
+ NAME_FUNC_OFFSET( 1876, glLightf, _gloffset_Lightf ),
+ NAME_FUNC_OFFSET( 1885, glLightfv, _gloffset_Lightfv ),
+ NAME_FUNC_OFFSET( 1895, glLighti, _gloffset_Lighti ),
+ NAME_FUNC_OFFSET( 1904, glLightiv, _gloffset_Lightiv ),
+ NAME_FUNC_OFFSET( 1914, glLightModelf, _gloffset_LightModelf ),
+ NAME_FUNC_OFFSET( 1928, glLightModelfv, _gloffset_LightModelfv ),
+ NAME_FUNC_OFFSET( 1943, glLightModeli, _gloffset_LightModeli ),
+ NAME_FUNC_OFFSET( 1957, glLightModeliv, _gloffset_LightModeliv ),
+ NAME_FUNC_OFFSET( 1972, glLineStipple, _gloffset_LineStipple ),
+ NAME_FUNC_OFFSET( 1986, glLineWidth, _gloffset_LineWidth ),
+ NAME_FUNC_OFFSET( 1998, glMaterialf, _gloffset_Materialf ),
+ NAME_FUNC_OFFSET( 2010, glMaterialfv, _gloffset_Materialfv ),
+ NAME_FUNC_OFFSET( 2023, glMateriali, _gloffset_Materiali ),
+ NAME_FUNC_OFFSET( 2035, glMaterialiv, _gloffset_Materialiv ),
+ NAME_FUNC_OFFSET( 2048, glPointSize, _gloffset_PointSize ),
+ NAME_FUNC_OFFSET( 2060, glPolygonMode, _gloffset_PolygonMode ),
+ NAME_FUNC_OFFSET( 2074, glPolygonStipple, _gloffset_PolygonStipple ),
+ NAME_FUNC_OFFSET( 2091, glScissor, _gloffset_Scissor ),
+ NAME_FUNC_OFFSET( 2101, glShadeModel, _gloffset_ShadeModel ),
+ NAME_FUNC_OFFSET( 2114, glTexParameterf, _gloffset_TexParameterf ),
+ NAME_FUNC_OFFSET( 2130, glTexParameterfv, _gloffset_TexParameterfv ),
+ NAME_FUNC_OFFSET( 2147, glTexParameteri, _gloffset_TexParameteri ),
+ NAME_FUNC_OFFSET( 2163, glTexParameteriv, _gloffset_TexParameteriv ),
+ NAME_FUNC_OFFSET( 2180, glTexImage1D, _gloffset_TexImage1D ),
+ NAME_FUNC_OFFSET( 2193, glTexImage2D, _gloffset_TexImage2D ),
+ NAME_FUNC_OFFSET( 2206, glTexEnvf, _gloffset_TexEnvf ),
+ NAME_FUNC_OFFSET( 2216, glTexEnvfv, _gloffset_TexEnvfv ),
+ NAME_FUNC_OFFSET( 2227, glTexEnvi, _gloffset_TexEnvi ),
+ NAME_FUNC_OFFSET( 2237, glTexEnviv, _gloffset_TexEnviv ),
+ NAME_FUNC_OFFSET( 2248, glTexGend, _gloffset_TexGend ),
+ NAME_FUNC_OFFSET( 2258, glTexGendv, _gloffset_TexGendv ),
+ NAME_FUNC_OFFSET( 2269, glTexGenf, _gloffset_TexGenf ),
+ NAME_FUNC_OFFSET( 2279, glTexGenfv, _gloffset_TexGenfv ),
+ NAME_FUNC_OFFSET( 2290, glTexGeni, _gloffset_TexGeni ),
+ NAME_FUNC_OFFSET( 2300, glTexGeniv, _gloffset_TexGeniv ),
+ NAME_FUNC_OFFSET( 2311, glFeedbackBuffer, _gloffset_FeedbackBuffer ),
+ NAME_FUNC_OFFSET( 2328, glSelectBuffer, _gloffset_SelectBuffer ),
+ NAME_FUNC_OFFSET( 2343, glRenderMode, _gloffset_RenderMode ),
+ NAME_FUNC_OFFSET( 2356, glInitNames, _gloffset_InitNames ),
+ NAME_FUNC_OFFSET( 2368, glLoadName, _gloffset_LoadName ),
+ NAME_FUNC_OFFSET( 2379, glPassThrough, _gloffset_PassThrough ),
+ NAME_FUNC_OFFSET( 2393, glPopName, _gloffset_PopName ),
+ NAME_FUNC_OFFSET( 2403, glPushName, _gloffset_PushName ),
+ NAME_FUNC_OFFSET( 2414, glDrawBuffer, _gloffset_DrawBuffer ),
+ NAME_FUNC_OFFSET( 2427, glClear, _gloffset_Clear ),
+ NAME_FUNC_OFFSET( 2435, glClearAccum, _gloffset_ClearAccum ),
+ NAME_FUNC_OFFSET( 2448, glClearIndex, _gloffset_ClearIndex ),
+ NAME_FUNC_OFFSET( 2461, glClearColor, _gloffset_ClearColor ),
+ NAME_FUNC_OFFSET( 2474, glClearStencil, _gloffset_ClearStencil ),
+ NAME_FUNC_OFFSET( 2489, glClearDepth, _gloffset_ClearDepth ),
+ NAME_FUNC_OFFSET( 2502, glStencilMask, _gloffset_StencilMask ),
+ NAME_FUNC_OFFSET( 2516, glColorMask, _gloffset_ColorMask ),
+ NAME_FUNC_OFFSET( 2528, glDepthMask, _gloffset_DepthMask ),
+ NAME_FUNC_OFFSET( 2540, glIndexMask, _gloffset_IndexMask ),
+ NAME_FUNC_OFFSET( 2552, glAccum, _gloffset_Accum ),
+ NAME_FUNC_OFFSET( 2560, glDisable, _gloffset_Disable ),
+ NAME_FUNC_OFFSET( 2570, glEnable, _gloffset_Enable ),
+ NAME_FUNC_OFFSET( 2579, glFinish, _gloffset_Finish ),
+ NAME_FUNC_OFFSET( 2588, glFlush, _gloffset_Flush ),
+ NAME_FUNC_OFFSET( 2596, glPopAttrib, _gloffset_PopAttrib ),
+ NAME_FUNC_OFFSET( 2608, glPushAttrib, _gloffset_PushAttrib ),
+ NAME_FUNC_OFFSET( 2621, glMap1d, _gloffset_Map1d ),
+ NAME_FUNC_OFFSET( 2629, glMap1f, _gloffset_Map1f ),
+ NAME_FUNC_OFFSET( 2637, glMap2d, _gloffset_Map2d ),
+ NAME_FUNC_OFFSET( 2645, glMap2f, _gloffset_Map2f ),
+ NAME_FUNC_OFFSET( 2653, glMapGrid1d, _gloffset_MapGrid1d ),
+ NAME_FUNC_OFFSET( 2665, glMapGrid1f, _gloffset_MapGrid1f ),
+ NAME_FUNC_OFFSET( 2677, glMapGrid2d, _gloffset_MapGrid2d ),
+ NAME_FUNC_OFFSET( 2689, glMapGrid2f, _gloffset_MapGrid2f ),
+ NAME_FUNC_OFFSET( 2701, glEvalCoord1d, _gloffset_EvalCoord1d ),
+ NAME_FUNC_OFFSET( 2715, glEvalCoord1dv, _gloffset_EvalCoord1dv ),
+ NAME_FUNC_OFFSET( 2730, glEvalCoord1f, _gloffset_EvalCoord1f ),
+ NAME_FUNC_OFFSET( 2744, glEvalCoord1fv, _gloffset_EvalCoord1fv ),
+ NAME_FUNC_OFFSET( 2759, glEvalCoord2d, _gloffset_EvalCoord2d ),
+ NAME_FUNC_OFFSET( 2773, glEvalCoord2dv, _gloffset_EvalCoord2dv ),
+ NAME_FUNC_OFFSET( 2788, glEvalCoord2f, _gloffset_EvalCoord2f ),
+ NAME_FUNC_OFFSET( 2802, glEvalCoord2fv, _gloffset_EvalCoord2fv ),
+ NAME_FUNC_OFFSET( 2817, glEvalMesh1, _gloffset_EvalMesh1 ),
+ NAME_FUNC_OFFSET( 2829, glEvalPoint1, _gloffset_EvalPoint1 ),
+ NAME_FUNC_OFFSET( 2842, glEvalMesh2, _gloffset_EvalMesh2 ),
+ NAME_FUNC_OFFSET( 2854, glEvalPoint2, _gloffset_EvalPoint2 ),
+ NAME_FUNC_OFFSET( 2867, glAlphaFunc, _gloffset_AlphaFunc ),
+ NAME_FUNC_OFFSET( 2879, glBlendFunc, _gloffset_BlendFunc ),
+ NAME_FUNC_OFFSET( 2891, glLogicOp, _gloffset_LogicOp ),
+ NAME_FUNC_OFFSET( 2901, glStencilFunc, _gloffset_StencilFunc ),
+ NAME_FUNC_OFFSET( 2915, glStencilOp, _gloffset_StencilOp ),
+ NAME_FUNC_OFFSET( 2927, glDepthFunc, _gloffset_DepthFunc ),
+ NAME_FUNC_OFFSET( 2939, glPixelZoom, _gloffset_PixelZoom ),
+ NAME_FUNC_OFFSET( 2951, glPixelTransferf, _gloffset_PixelTransferf ),
+ NAME_FUNC_OFFSET( 2968, glPixelTransferi, _gloffset_PixelTransferi ),
+ NAME_FUNC_OFFSET( 2985, glPixelStoref, _gloffset_PixelStoref ),
+ NAME_FUNC_OFFSET( 2999, glPixelStorei, _gloffset_PixelStorei ),
+ NAME_FUNC_OFFSET( 3013, glPixelMapfv, _gloffset_PixelMapfv ),
+ NAME_FUNC_OFFSET( 3026, glPixelMapuiv, _gloffset_PixelMapuiv ),
+ NAME_FUNC_OFFSET( 3040, glPixelMapusv, _gloffset_PixelMapusv ),
+ NAME_FUNC_OFFSET( 3054, glReadBuffer, _gloffset_ReadBuffer ),
+ NAME_FUNC_OFFSET( 3067, glCopyPixels, _gloffset_CopyPixels ),
+ NAME_FUNC_OFFSET( 3080, glReadPixels, _gloffset_ReadPixels ),
+ NAME_FUNC_OFFSET( 3093, glDrawPixels, _gloffset_DrawPixels ),
+ NAME_FUNC_OFFSET( 3106, glGetBooleanv, _gloffset_GetBooleanv ),
+ NAME_FUNC_OFFSET( 3120, glGetClipPlane, _gloffset_GetClipPlane ),
+ NAME_FUNC_OFFSET( 3135, glGetDoublev, _gloffset_GetDoublev ),
+ NAME_FUNC_OFFSET( 3148, glGetError, _gloffset_GetError ),
+ NAME_FUNC_OFFSET( 3159, glGetFloatv, _gloffset_GetFloatv ),
+ NAME_FUNC_OFFSET( 3171, glGetIntegerv, _gloffset_GetIntegerv ),
+ NAME_FUNC_OFFSET( 3185, glGetLightfv, _gloffset_GetLightfv ),
+ NAME_FUNC_OFFSET( 3198, glGetLightiv, _gloffset_GetLightiv ),
+ NAME_FUNC_OFFSET( 3211, glGetMapdv, _gloffset_GetMapdv ),
+ NAME_FUNC_OFFSET( 3222, glGetMapfv, _gloffset_GetMapfv ),
+ NAME_FUNC_OFFSET( 3233, glGetMapiv, _gloffset_GetMapiv ),
+ NAME_FUNC_OFFSET( 3244, glGetMaterialfv, _gloffset_GetMaterialfv ),
+ NAME_FUNC_OFFSET( 3260, glGetMaterialiv, _gloffset_GetMaterialiv ),
+ NAME_FUNC_OFFSET( 3276, glGetPixelMapfv, _gloffset_GetPixelMapfv ),
+ NAME_FUNC_OFFSET( 3292, glGetPixelMapuiv, _gloffset_GetPixelMapuiv ),
+ NAME_FUNC_OFFSET( 3309, glGetPixelMapusv, _gloffset_GetPixelMapusv ),
+ NAME_FUNC_OFFSET( 3326, glGetPolygonStipple, _gloffset_GetPolygonStipple ),
+ NAME_FUNC_OFFSET( 3346, glGetString, _gloffset_GetString ),
+ NAME_FUNC_OFFSET( 3358, glGetTexEnvfv, _gloffset_GetTexEnvfv ),
+ NAME_FUNC_OFFSET( 3372, glGetTexEnviv, _gloffset_GetTexEnviv ),
+ NAME_FUNC_OFFSET( 3386, glGetTexGendv, _gloffset_GetTexGendv ),
+ NAME_FUNC_OFFSET( 3400, glGetTexGenfv, _gloffset_GetTexGenfv ),
+ NAME_FUNC_OFFSET( 3414, glGetTexGeniv, _gloffset_GetTexGeniv ),
+ NAME_FUNC_OFFSET( 3428, glGetTexImage, _gloffset_GetTexImage ),
+ NAME_FUNC_OFFSET( 3442, glGetTexParameterfv, _gloffset_GetTexParameterfv ),
+ NAME_FUNC_OFFSET( 3462, glGetTexParameteriv, _gloffset_GetTexParameteriv ),
+ NAME_FUNC_OFFSET( 3482, glGetTexLevelParameterfv, _gloffset_GetTexLevelParameterfv ),
+ NAME_FUNC_OFFSET( 3507, glGetTexLevelParameteriv, _gloffset_GetTexLevelParameteriv ),
+ NAME_FUNC_OFFSET( 3532, glIsEnabled, _gloffset_IsEnabled ),
+ NAME_FUNC_OFFSET( 3544, glIsList, _gloffset_IsList ),
+ NAME_FUNC_OFFSET( 3553, glDepthRange, _gloffset_DepthRange ),
+ NAME_FUNC_OFFSET( 3566, glFrustum, _gloffset_Frustum ),
+ NAME_FUNC_OFFSET( 3576, glLoadIdentity, _gloffset_LoadIdentity ),
+ NAME_FUNC_OFFSET( 3591, glLoadMatrixf, _gloffset_LoadMatrixf ),
+ NAME_FUNC_OFFSET( 3605, glLoadMatrixd, _gloffset_LoadMatrixd ),
+ NAME_FUNC_OFFSET( 3619, glMatrixMode, _gloffset_MatrixMode ),
+ NAME_FUNC_OFFSET( 3632, glMultMatrixf, _gloffset_MultMatrixf ),
+ NAME_FUNC_OFFSET( 3646, glMultMatrixd, _gloffset_MultMatrixd ),
+ NAME_FUNC_OFFSET( 3660, glOrtho, _gloffset_Ortho ),
+ NAME_FUNC_OFFSET( 3668, glPopMatrix, _gloffset_PopMatrix ),
+ NAME_FUNC_OFFSET( 3680, glPushMatrix, _gloffset_PushMatrix ),
+ NAME_FUNC_OFFSET( 3693, glRotated, _gloffset_Rotated ),
+ NAME_FUNC_OFFSET( 3703, glRotatef, _gloffset_Rotatef ),
+ NAME_FUNC_OFFSET( 3713, glScaled, _gloffset_Scaled ),
+ NAME_FUNC_OFFSET( 3722, glScalef, _gloffset_Scalef ),
+ NAME_FUNC_OFFSET( 3731, glTranslated, _gloffset_Translated ),
+ NAME_FUNC_OFFSET( 3744, glTranslatef, _gloffset_Translatef ),
+ NAME_FUNC_OFFSET( 3757, glViewport, _gloffset_Viewport ),
+ NAME_FUNC_OFFSET( 3768, glArrayElement, _gloffset_ArrayElement ),
+ NAME_FUNC_OFFSET( 3783, glBindTexture, _gloffset_BindTexture ),
+ NAME_FUNC_OFFSET( 3797, glColorPointer, _gloffset_ColorPointer ),
+ NAME_FUNC_OFFSET( 3812, glDisableClientState, _gloffset_DisableClientState ),
+ NAME_FUNC_OFFSET( 3833, glDrawArrays, _gloffset_DrawArrays ),
+ NAME_FUNC_OFFSET( 3846, glDrawElements, _gloffset_DrawElements ),
+ NAME_FUNC_OFFSET( 3861, glEdgeFlagPointer, _gloffset_EdgeFlagPointer ),
+ NAME_FUNC_OFFSET( 3879, glEnableClientState, _gloffset_EnableClientState ),
+ NAME_FUNC_OFFSET( 3899, glIndexPointer, _gloffset_IndexPointer ),
+ NAME_FUNC_OFFSET( 3914, glIndexub, _gloffset_Indexub ),
+ NAME_FUNC_OFFSET( 3924, glIndexubv, _gloffset_Indexubv ),
+ NAME_FUNC_OFFSET( 3935, glInterleavedArrays, _gloffset_InterleavedArrays ),
+ NAME_FUNC_OFFSET( 3955, glNormalPointer, _gloffset_NormalPointer ),
+ NAME_FUNC_OFFSET( 3971, glPolygonOffset, _gloffset_PolygonOffset ),
+ NAME_FUNC_OFFSET( 3987, glTexCoordPointer, _gloffset_TexCoordPointer ),
+ NAME_FUNC_OFFSET( 4005, glVertexPointer, _gloffset_VertexPointer ),
+ NAME_FUNC_OFFSET( 4021, glAreTexturesResident, _gloffset_AreTexturesResident ),
+ NAME_FUNC_OFFSET( 4043, glCopyTexImage1D, _gloffset_CopyTexImage1D ),
+ NAME_FUNC_OFFSET( 4060, glCopyTexImage2D, _gloffset_CopyTexImage2D ),
+ NAME_FUNC_OFFSET( 4077, glCopyTexSubImage1D, _gloffset_CopyTexSubImage1D ),
+ NAME_FUNC_OFFSET( 4097, glCopyTexSubImage2D, _gloffset_CopyTexSubImage2D ),
+ NAME_FUNC_OFFSET( 4117, glDeleteTextures, _gloffset_DeleteTextures ),
+ NAME_FUNC_OFFSET( 4134, glGenTextures, _gloffset_GenTextures ),
+ NAME_FUNC_OFFSET( 4148, glGetPointerv, _gloffset_GetPointerv ),
+ NAME_FUNC_OFFSET( 4162, glIsTexture, _gloffset_IsTexture ),
+ NAME_FUNC_OFFSET( 4174, glPrioritizeTextures, _gloffset_PrioritizeTextures ),
+ NAME_FUNC_OFFSET( 4195, glTexSubImage1D, _gloffset_TexSubImage1D ),
+ NAME_FUNC_OFFSET( 4211, glTexSubImage2D, _gloffset_TexSubImage2D ),
+ NAME_FUNC_OFFSET( 4227, glPopClientAttrib, _gloffset_PopClientAttrib ),
+ NAME_FUNC_OFFSET( 4245, glPushClientAttrib, _gloffset_PushClientAttrib ),
+ NAME_FUNC_OFFSET( 4264, glBlendColor, _gloffset_BlendColor ),
+ NAME_FUNC_OFFSET( 4277, glBlendEquation, _gloffset_BlendEquation ),
+ NAME_FUNC_OFFSET( 4293, glDrawRangeElements, _gloffset_DrawRangeElements ),
+ NAME_FUNC_OFFSET( 4313, glColorTable, _gloffset_ColorTable ),
+ NAME_FUNC_OFFSET( 4326, glColorTableParameterfv, _gloffset_ColorTableParameterfv ),
+ NAME_FUNC_OFFSET( 4350, glColorTableParameteriv, _gloffset_ColorTableParameteriv ),
+ NAME_FUNC_OFFSET( 4374, glCopyColorTable, _gloffset_CopyColorTable ),
+ NAME_FUNC_OFFSET( 4391, glGetColorTable, _gloffset_GetColorTable ),
+ NAME_FUNC_OFFSET( 4407, glGetColorTableParameterfv, _gloffset_GetColorTableParameterfv ),
+ NAME_FUNC_OFFSET( 4434, glGetColorTableParameteriv, _gloffset_GetColorTableParameteriv ),
+ NAME_FUNC_OFFSET( 4461, glColorSubTable, _gloffset_ColorSubTable ),
+ NAME_FUNC_OFFSET( 4477, glCopyColorSubTable, _gloffset_CopyColorSubTable ),
+ NAME_FUNC_OFFSET( 4497, glConvolutionFilter1D, _gloffset_ConvolutionFilter1D ),
+ NAME_FUNC_OFFSET( 4519, glConvolutionFilter2D, _gloffset_ConvolutionFilter2D ),
+ NAME_FUNC_OFFSET( 4541, glConvolutionParameterf, _gloffset_ConvolutionParameterf ),
+ NAME_FUNC_OFFSET( 4565, glConvolutionParameterfv, _gloffset_ConvolutionParameterfv ),
+ NAME_FUNC_OFFSET( 4590, glConvolutionParameteri, _gloffset_ConvolutionParameteri ),
+ NAME_FUNC_OFFSET( 4614, glConvolutionParameteriv, _gloffset_ConvolutionParameteriv ),
+ NAME_FUNC_OFFSET( 4639, glCopyConvolutionFilter1D, _gloffset_CopyConvolutionFilter1D ),
+ NAME_FUNC_OFFSET( 4665, glCopyConvolutionFilter2D, _gloffset_CopyConvolutionFilter2D ),
+ NAME_FUNC_OFFSET( 4691, glGetConvolutionFilter, _gloffset_GetConvolutionFilter ),
+ NAME_FUNC_OFFSET( 4714, glGetConvolutionParameterfv, _gloffset_GetConvolutionParameterfv ),
+ NAME_FUNC_OFFSET( 4742, glGetConvolutionParameteriv, _gloffset_GetConvolutionParameteriv ),
+ NAME_FUNC_OFFSET( 4770, glGetSeparableFilter, _gloffset_GetSeparableFilter ),
+ NAME_FUNC_OFFSET( 4791, glSeparableFilter2D, _gloffset_SeparableFilter2D ),
+ NAME_FUNC_OFFSET( 4811, glGetHistogram, _gloffset_GetHistogram ),
+ NAME_FUNC_OFFSET( 4826, glGetHistogramParameterfv, _gloffset_GetHistogramParameterfv ),
+ NAME_FUNC_OFFSET( 4852, glGetHistogramParameteriv, _gloffset_GetHistogramParameteriv ),
+ NAME_FUNC_OFFSET( 4878, glGetMinmax, _gloffset_GetMinmax ),
+ NAME_FUNC_OFFSET( 4890, glGetMinmaxParameterfv, _gloffset_GetMinmaxParameterfv ),
+ NAME_FUNC_OFFSET( 4913, glGetMinmaxParameteriv, _gloffset_GetMinmaxParameteriv ),
+ NAME_FUNC_OFFSET( 4936, glHistogram, _gloffset_Histogram ),
+ NAME_FUNC_OFFSET( 4948, glMinmax, _gloffset_Minmax ),
+ NAME_FUNC_OFFSET( 4957, glResetHistogram, _gloffset_ResetHistogram ),
+ NAME_FUNC_OFFSET( 4974, glResetMinmax, _gloffset_ResetMinmax ),
+ NAME_FUNC_OFFSET( 4988, glTexImage3D, _gloffset_TexImage3D ),
+ NAME_FUNC_OFFSET( 5001, glTexSubImage3D, _gloffset_TexSubImage3D ),
+ NAME_FUNC_OFFSET( 5017, glCopyTexSubImage3D, _gloffset_CopyTexSubImage3D ),
+ NAME_FUNC_OFFSET( 5037, glActiveTextureARB, _gloffset_ActiveTextureARB ),
+ NAME_FUNC_OFFSET( 5056, glClientActiveTextureARB, _gloffset_ClientActiveTextureARB ),
+ NAME_FUNC_OFFSET( 5081, glMultiTexCoord1dARB, _gloffset_MultiTexCoord1dARB ),
+ NAME_FUNC_OFFSET( 5102, glMultiTexCoord1dvARB, _gloffset_MultiTexCoord1dvARB ),
+ NAME_FUNC_OFFSET( 5124, glMultiTexCoord1fARB, _gloffset_MultiTexCoord1fARB ),
+ NAME_FUNC_OFFSET( 5145, glMultiTexCoord1fvARB, _gloffset_MultiTexCoord1fvARB ),
+ NAME_FUNC_OFFSET( 5167, glMultiTexCoord1iARB, _gloffset_MultiTexCoord1iARB ),
+ NAME_FUNC_OFFSET( 5188, glMultiTexCoord1ivARB, _gloffset_MultiTexCoord1ivARB ),
+ NAME_FUNC_OFFSET( 5210, glMultiTexCoord1sARB, _gloffset_MultiTexCoord1sARB ),
+ NAME_FUNC_OFFSET( 5231, glMultiTexCoord1svARB, _gloffset_MultiTexCoord1svARB ),
+ NAME_FUNC_OFFSET( 5253, glMultiTexCoord2dARB, _gloffset_MultiTexCoord2dARB ),
+ NAME_FUNC_OFFSET( 5274, glMultiTexCoord2dvARB, _gloffset_MultiTexCoord2dvARB ),
+ NAME_FUNC_OFFSET( 5296, glMultiTexCoord2fARB, _gloffset_MultiTexCoord2fARB ),
+ NAME_FUNC_OFFSET( 5317, glMultiTexCoord2fvARB, _gloffset_MultiTexCoord2fvARB ),
+ NAME_FUNC_OFFSET( 5339, glMultiTexCoord2iARB, _gloffset_MultiTexCoord2iARB ),
+ NAME_FUNC_OFFSET( 5360, glMultiTexCoord2ivARB, _gloffset_MultiTexCoord2ivARB ),
+ NAME_FUNC_OFFSET( 5382, glMultiTexCoord2sARB, _gloffset_MultiTexCoord2sARB ),
+ NAME_FUNC_OFFSET( 5403, glMultiTexCoord2svARB, _gloffset_MultiTexCoord2svARB ),
+ NAME_FUNC_OFFSET( 5425, glMultiTexCoord3dARB, _gloffset_MultiTexCoord3dARB ),
+ NAME_FUNC_OFFSET( 5446, glMultiTexCoord3dvARB, _gloffset_MultiTexCoord3dvARB ),
+ NAME_FUNC_OFFSET( 5468, glMultiTexCoord3fARB, _gloffset_MultiTexCoord3fARB ),
+ NAME_FUNC_OFFSET( 5489, glMultiTexCoord3fvARB, _gloffset_MultiTexCoord3fvARB ),
+ NAME_FUNC_OFFSET( 5511, glMultiTexCoord3iARB, _gloffset_MultiTexCoord3iARB ),
+ NAME_FUNC_OFFSET( 5532, glMultiTexCoord3ivARB, _gloffset_MultiTexCoord3ivARB ),
+ NAME_FUNC_OFFSET( 5554, glMultiTexCoord3sARB, _gloffset_MultiTexCoord3sARB ),
+ NAME_FUNC_OFFSET( 5575, glMultiTexCoord3svARB, _gloffset_MultiTexCoord3svARB ),
+ NAME_FUNC_OFFSET( 5597, glMultiTexCoord4dARB, _gloffset_MultiTexCoord4dARB ),
+ NAME_FUNC_OFFSET( 5618, glMultiTexCoord4dvARB, _gloffset_MultiTexCoord4dvARB ),
+ NAME_FUNC_OFFSET( 5640, glMultiTexCoord4fARB, _gloffset_MultiTexCoord4fARB ),
+ NAME_FUNC_OFFSET( 5661, glMultiTexCoord4fvARB, _gloffset_MultiTexCoord4fvARB ),
+ NAME_FUNC_OFFSET( 5683, glMultiTexCoord4iARB, _gloffset_MultiTexCoord4iARB ),
+ NAME_FUNC_OFFSET( 5704, glMultiTexCoord4ivARB, _gloffset_MultiTexCoord4ivARB ),
+ NAME_FUNC_OFFSET( 5726, glMultiTexCoord4sARB, _gloffset_MultiTexCoord4sARB ),
+ NAME_FUNC_OFFSET( 5747, glMultiTexCoord4svARB, _gloffset_MultiTexCoord4svARB ),
+ NAME_FUNC_OFFSET( 5769, glLoadTransposeMatrixfARB, _gloffset_LoadTransposeMatrixfARB ),
+ NAME_FUNC_OFFSET( 5795, glLoadTransposeMatrixdARB, _gloffset_LoadTransposeMatrixdARB ),
+ NAME_FUNC_OFFSET( 5821, glMultTransposeMatrixfARB, _gloffset_MultTransposeMatrixfARB ),
+ NAME_FUNC_OFFSET( 5847, glMultTransposeMatrixdARB, _gloffset_MultTransposeMatrixdARB ),
+ NAME_FUNC_OFFSET( 5873, glSampleCoverageARB, _gloffset_SampleCoverageARB ),
+ NAME_FUNC_OFFSET( 5893, glDrawBuffersARB, _gloffset_DrawBuffersARB ),
+ NAME_FUNC_OFFSET( 5910, glPolygonOffsetEXT, _gloffset_PolygonOffsetEXT ),
+ NAME_FUNC_OFFSET( 5929, glGetTexFilterFuncSGIS, _gloffset_GetTexFilterFuncSGIS ),
+ NAME_FUNC_OFFSET( 5952, glTexFilterFuncSGIS, _gloffset_TexFilterFuncSGIS ),
+ NAME_FUNC_OFFSET( 5972, glGetHistogramEXT, _gloffset_GetHistogramEXT ),
+ NAME_FUNC_OFFSET( 5990, glGetHistogramParameterfvEXT, _gloffset_GetHistogramParameterfvEXT ),
+ NAME_FUNC_OFFSET( 6019, glGetHistogramParameterivEXT, _gloffset_GetHistogramParameterivEXT ),
+ NAME_FUNC_OFFSET( 6048, glGetMinmaxEXT, _gloffset_GetMinmaxEXT ),
+ NAME_FUNC_OFFSET( 6063, glGetMinmaxParameterfvEXT, _gloffset_GetMinmaxParameterfvEXT ),
+ NAME_FUNC_OFFSET( 6089, glGetMinmaxParameterivEXT, _gloffset_GetMinmaxParameterivEXT ),
+ NAME_FUNC_OFFSET( 6115, glGetConvolutionFilterEXT, _gloffset_GetConvolutionFilterEXT ),
+ NAME_FUNC_OFFSET( 6141, glGetConvolutionParameterfvEXT, _gloffset_GetConvolutionParameterfvEXT ),
+ NAME_FUNC_OFFSET( 6172, glGetConvolutionParameterivEXT, _gloffset_GetConvolutionParameterivEXT ),
+ NAME_FUNC_OFFSET( 6203, glGetSeparableFilterEXT, _gloffset_GetSeparableFilterEXT ),
+ NAME_FUNC_OFFSET( 6227, glGetColorTableSGI, _gloffset_GetColorTableSGI ),
+ NAME_FUNC_OFFSET( 6246, glGetColorTableParameterfvSGI, _gloffset_GetColorTableParameterfvSGI ),
+ NAME_FUNC_OFFSET( 6276, glGetColorTableParameterivSGI, _gloffset_GetColorTableParameterivSGI ),
+ NAME_FUNC_OFFSET( 6306, glPixelTexGenSGIX, _gloffset_PixelTexGenSGIX ),
+ NAME_FUNC_OFFSET( 6324, glPixelTexGenParameteriSGIS, _gloffset_PixelTexGenParameteriSGIS ),
+ NAME_FUNC_OFFSET( 6352, glPixelTexGenParameterivSGIS, _gloffset_PixelTexGenParameterivSGIS ),
+ NAME_FUNC_OFFSET( 6381, glPixelTexGenParameterfSGIS, _gloffset_PixelTexGenParameterfSGIS ),
+ NAME_FUNC_OFFSET( 6409, glPixelTexGenParameterfvSGIS, _gloffset_PixelTexGenParameterfvSGIS ),
+ NAME_FUNC_OFFSET( 6438, glGetPixelTexGenParameterivSGIS, _gloffset_GetPixelTexGenParameterivSGIS ),
+ NAME_FUNC_OFFSET( 6470, glGetPixelTexGenParameterfvSGIS, _gloffset_GetPixelTexGenParameterfvSGIS ),
+ NAME_FUNC_OFFSET( 6502, glTexImage4DSGIS, _gloffset_TexImage4DSGIS ),
+ NAME_FUNC_OFFSET( 6519, glTexSubImage4DSGIS, _gloffset_TexSubImage4DSGIS ),
+ NAME_FUNC_OFFSET( 6539, glAreTexturesResidentEXT, _gloffset_AreTexturesResidentEXT ),
+ NAME_FUNC_OFFSET( 6564, glGenTexturesEXT, _gloffset_GenTexturesEXT ),
+ NAME_FUNC_OFFSET( 6581, glIsTextureEXT, _gloffset_IsTextureEXT ),
+ NAME_FUNC_OFFSET( 6596, glDetailTexFuncSGIS, _gloffset_DetailTexFuncSGIS ),
+ NAME_FUNC_OFFSET( 6616, glGetDetailTexFuncSGIS, _gloffset_GetDetailTexFuncSGIS ),
+ NAME_FUNC_OFFSET( 6639, glSharpenTexFuncSGIS, _gloffset_SharpenTexFuncSGIS ),
+ NAME_FUNC_OFFSET( 6660, glGetSharpenTexFuncSGIS, _gloffset_GetSharpenTexFuncSGIS ),
+ NAME_FUNC_OFFSET( 6684, glSampleMaskSGIS, _gloffset_SampleMaskSGIS ),
+ NAME_FUNC_OFFSET( 6701, glSamplePatternSGIS, _gloffset_SamplePatternSGIS ),
+ NAME_FUNC_OFFSET( 6721, glColorPointerEXT, _gloffset_ColorPointerEXT ),
+ NAME_FUNC_OFFSET( 6739, glEdgeFlagPointerEXT, _gloffset_EdgeFlagPointerEXT ),
+ NAME_FUNC_OFFSET( 6760, glIndexPointerEXT, _gloffset_IndexPointerEXT ),
+ NAME_FUNC_OFFSET( 6778, glNormalPointerEXT, _gloffset_NormalPointerEXT ),
+ NAME_FUNC_OFFSET( 6797, glTexCoordPointerEXT, _gloffset_TexCoordPointerEXT ),
+ NAME_FUNC_OFFSET( 6818, glVertexPointerEXT, _gloffset_VertexPointerEXT ),
+ NAME_FUNC_OFFSET( 6837, glSpriteParameterfSGIX, _gloffset_SpriteParameterfSGIX ),
+ NAME_FUNC_OFFSET( 6860, glSpriteParameterfvSGIX, _gloffset_SpriteParameterfvSGIX ),
+ NAME_FUNC_OFFSET( 6884, glSpriteParameteriSGIX, _gloffset_SpriteParameteriSGIX ),
+ NAME_FUNC_OFFSET( 6907, glSpriteParameterivSGIX, _gloffset_SpriteParameterivSGIX ),
+ NAME_FUNC_OFFSET( 6931, glPointParameterfEXT, _gloffset_PointParameterfEXT ),
+ NAME_FUNC_OFFSET( 6952, glPointParameterfvEXT, _gloffset_PointParameterfvEXT ),
+ NAME_FUNC_OFFSET( 6974, glGetInstrumentsSGIX, _gloffset_GetInstrumentsSGIX ),
+ NAME_FUNC_OFFSET( 6995, glInstrumentsBufferSGIX, _gloffset_InstrumentsBufferSGIX ),
+ NAME_FUNC_OFFSET( 7019, glPollInstrumentsSGIX, _gloffset_PollInstrumentsSGIX ),
+ NAME_FUNC_OFFSET( 7041, glReadInstrumentsSGIX, _gloffset_ReadInstrumentsSGIX ),
+ NAME_FUNC_OFFSET( 7063, glStartInstrumentsSGIX, _gloffset_StartInstrumentsSGIX ),
+ NAME_FUNC_OFFSET( 7086, glStopInstrumentsSGIX, _gloffset_StopInstrumentsSGIX ),
+ NAME_FUNC_OFFSET( 7108, glFrameZoomSGIX, _gloffset_FrameZoomSGIX ),
+ NAME_FUNC_OFFSET( 7124, glTagSampleBufferSGIX, _gloffset_TagSampleBufferSGIX ),
+ NAME_FUNC_OFFSET( 7146, glReferencePlaneSGIX, _gloffset_ReferencePlaneSGIX ),
+ NAME_FUNC_OFFSET( 7167, glFlushRasterSGIX, _gloffset_FlushRasterSGIX ),
+ NAME_FUNC_OFFSET( 7185, glGetListParameterfvSGIX, _gloffset_GetListParameterfvSGIX ),
+ NAME_FUNC_OFFSET( 7210, glGetListParameterivSGIX, _gloffset_GetListParameterivSGIX ),
+ NAME_FUNC_OFFSET( 7235, glListParameterfSGIX, _gloffset_ListParameterfSGIX ),
+ NAME_FUNC_OFFSET( 7256, glListParameterfvSGIX, _gloffset_ListParameterfvSGIX ),
+ NAME_FUNC_OFFSET( 7278, glListParameteriSGIX, _gloffset_ListParameteriSGIX ),
+ NAME_FUNC_OFFSET( 7299, glListParameterivSGIX, _gloffset_ListParameterivSGIX ),
+ NAME_FUNC_OFFSET( 7321, glFragmentColorMaterialSGIX, _gloffset_FragmentColorMaterialSGIX ),
+ NAME_FUNC_OFFSET( 7349, glFragmentLightfSGIX, _gloffset_FragmentLightfSGIX ),
+ NAME_FUNC_OFFSET( 7370, glFragmentLightfvSGIX, _gloffset_FragmentLightfvSGIX ),
+ NAME_FUNC_OFFSET( 7392, glFragmentLightiSGIX, _gloffset_FragmentLightiSGIX ),
+ NAME_FUNC_OFFSET( 7413, glFragmentLightivSGIX, _gloffset_FragmentLightivSGIX ),
+ NAME_FUNC_OFFSET( 7435, glFragmentLightModelfSGIX, _gloffset_FragmentLightModelfSGIX ),
+ NAME_FUNC_OFFSET( 7461, glFragmentLightModelfvSGIX, _gloffset_FragmentLightModelfvSGIX ),
+ NAME_FUNC_OFFSET( 7488, glFragmentLightModeliSGIX, _gloffset_FragmentLightModeliSGIX ),
+ NAME_FUNC_OFFSET( 7514, glFragmentLightModelivSGIX, _gloffset_FragmentLightModelivSGIX ),
+ NAME_FUNC_OFFSET( 7541, glFragmentMaterialfSGIX, _gloffset_FragmentMaterialfSGIX ),
+ NAME_FUNC_OFFSET( 7565, glFragmentMaterialfvSGIX, _gloffset_FragmentMaterialfvSGIX ),
+ NAME_FUNC_OFFSET( 7590, glFragmentMaterialiSGIX, _gloffset_FragmentMaterialiSGIX ),
+ NAME_FUNC_OFFSET( 7614, glFragmentMaterialivSGIX, _gloffset_FragmentMaterialivSGIX ),
+ NAME_FUNC_OFFSET( 7639, glGetFragmentLightfvSGIX, _gloffset_GetFragmentLightfvSGIX ),
+ NAME_FUNC_OFFSET( 7664, glGetFragmentLightivSGIX, _gloffset_GetFragmentLightivSGIX ),
+ NAME_FUNC_OFFSET( 7689, glGetFragmentMaterialfvSGIX, _gloffset_GetFragmentMaterialfvSGIX ),
+ NAME_FUNC_OFFSET( 7717, glGetFragmentMaterialivSGIX, _gloffset_GetFragmentMaterialivSGIX ),
+ NAME_FUNC_OFFSET( 7745, glLightEnviSGIX, _gloffset_LightEnviSGIX ),
+ NAME_FUNC_OFFSET( 7761, glVertexWeightfEXT, _gloffset_VertexWeightfEXT ),
+ NAME_FUNC_OFFSET( 7780, glVertexWeightfvEXT, _gloffset_VertexWeightfvEXT ),
+ NAME_FUNC_OFFSET( 7800, glVertexWeightPointerEXT, _gloffset_VertexWeightPointerEXT ),
+ NAME_FUNC_OFFSET( 7825, glFlushVertexArrayRangeNV, _gloffset_FlushVertexArrayRangeNV ),
+ NAME_FUNC_OFFSET( 7851, glVertexArrayRangeNV, _gloffset_VertexArrayRangeNV ),
+ NAME_FUNC_OFFSET( 7872, glCombinerParameterfvNV, _gloffset_CombinerParameterfvNV ),
+ NAME_FUNC_OFFSET( 7896, glCombinerParameterfNV, _gloffset_CombinerParameterfNV ),
+ NAME_FUNC_OFFSET( 7919, glCombinerParameterivNV, _gloffset_CombinerParameterivNV ),
+ NAME_FUNC_OFFSET( 7943, glCombinerParameteriNV, _gloffset_CombinerParameteriNV ),
+ NAME_FUNC_OFFSET( 7966, glCombinerInputNV, _gloffset_CombinerInputNV ),
+ NAME_FUNC_OFFSET( 7984, glCombinerOutputNV, _gloffset_CombinerOutputNV ),
+ NAME_FUNC_OFFSET( 8003, glFinalCombinerInputNV, _gloffset_FinalCombinerInputNV ),
+ NAME_FUNC_OFFSET( 8026, glGetCombinerInputParameterfvNV, _gloffset_GetCombinerInputParameterfvNV ),
+ NAME_FUNC_OFFSET( 8058, glGetCombinerInputParameterivNV, _gloffset_GetCombinerInputParameterivNV ),
+ NAME_FUNC_OFFSET( 8090, glGetCombinerOutputParameterfvNV, _gloffset_GetCombinerOutputParameterfvNV ),
+ NAME_FUNC_OFFSET( 8123, glGetCombinerOutputParameterivNV, _gloffset_GetCombinerOutputParameterivNV ),
+ NAME_FUNC_OFFSET( 8156, glGetFinalCombinerInputParameterfvNV, _gloffset_GetFinalCombinerInputParameterfvNV ),
+ NAME_FUNC_OFFSET( 8193, glGetFinalCombinerInputParameterivNV, _gloffset_GetFinalCombinerInputParameterivNV ),
+ NAME_FUNC_OFFSET( 8230, glResizeBuffersMESA, _gloffset_ResizeBuffersMESA ),
+ NAME_FUNC_OFFSET( 8250, glWindowPos2dMESA, _gloffset_WindowPos2dMESA ),
+ NAME_FUNC_OFFSET( 8268, glWindowPos2dvMESA, _gloffset_WindowPos2dvMESA ),
+ NAME_FUNC_OFFSET( 8287, glWindowPos2fMESA, _gloffset_WindowPos2fMESA ),
+ NAME_FUNC_OFFSET( 8305, glWindowPos2fvMESA, _gloffset_WindowPos2fvMESA ),
+ NAME_FUNC_OFFSET( 8324, glWindowPos2iMESA, _gloffset_WindowPos2iMESA ),
+ NAME_FUNC_OFFSET( 8342, glWindowPos2ivMESA, _gloffset_WindowPos2ivMESA ),
+ NAME_FUNC_OFFSET( 8361, glWindowPos2sMESA, _gloffset_WindowPos2sMESA ),
+ NAME_FUNC_OFFSET( 8379, glWindowPos2svMESA, _gloffset_WindowPos2svMESA ),
+ NAME_FUNC_OFFSET( 8398, glWindowPos3dMESA, _gloffset_WindowPos3dMESA ),
+ NAME_FUNC_OFFSET( 8416, glWindowPos3dvMESA, _gloffset_WindowPos3dvMESA ),
+ NAME_FUNC_OFFSET( 8435, glWindowPos3fMESA, _gloffset_WindowPos3fMESA ),
+ NAME_FUNC_OFFSET( 8453, glWindowPos3fvMESA, _gloffset_WindowPos3fvMESA ),
+ NAME_FUNC_OFFSET( 8472, glWindowPos3iMESA, _gloffset_WindowPos3iMESA ),
+ NAME_FUNC_OFFSET( 8490, glWindowPos3ivMESA, _gloffset_WindowPos3ivMESA ),
+ NAME_FUNC_OFFSET( 8509, glWindowPos3sMESA, _gloffset_WindowPos3sMESA ),
+ NAME_FUNC_OFFSET( 8527, glWindowPos3svMESA, _gloffset_WindowPos3svMESA ),
+ NAME_FUNC_OFFSET( 8546, glWindowPos4dMESA, _gloffset_WindowPos4dMESA ),
+ NAME_FUNC_OFFSET( 8564, glWindowPos4dvMESA, _gloffset_WindowPos4dvMESA ),
+ NAME_FUNC_OFFSET( 8583, glWindowPos4fMESA, _gloffset_WindowPos4fMESA ),
+ NAME_FUNC_OFFSET( 8601, glWindowPos4fvMESA, _gloffset_WindowPos4fvMESA ),
+ NAME_FUNC_OFFSET( 8620, glWindowPos4iMESA, _gloffset_WindowPos4iMESA ),
+ NAME_FUNC_OFFSET( 8638, glWindowPos4ivMESA, _gloffset_WindowPos4ivMESA ),
+ NAME_FUNC_OFFSET( 8657, glWindowPos4sMESA, _gloffset_WindowPos4sMESA ),
+ NAME_FUNC_OFFSET( 8675, glWindowPos4svMESA, _gloffset_WindowPos4svMESA ),
+ NAME_FUNC_OFFSET( 8694, glBlendFuncSeparateEXT, _gloffset_BlendFuncSeparateEXT ),
+ NAME_FUNC_OFFSET( 8717, glIndexMaterialEXT, _gloffset_IndexMaterialEXT ),
+ NAME_FUNC_OFFSET( 8736, glIndexFuncEXT, _gloffset_IndexFuncEXT ),
+ NAME_FUNC_OFFSET( 8751, glLockArraysEXT, _gloffset_LockArraysEXT ),
+ NAME_FUNC_OFFSET( 8767, glUnlockArraysEXT, _gloffset_UnlockArraysEXT ),
+ NAME_FUNC_OFFSET( 8785, glCullParameterdvEXT, _gloffset_CullParameterdvEXT ),
+ NAME_FUNC_OFFSET( 8806, glCullParameterfvEXT, _gloffset_CullParameterfvEXT ),
+ NAME_FUNC_OFFSET( 8827, glHintPGI, _gloffset_HintPGI ),
+ NAME_FUNC_OFFSET( 8837, glFogCoordfEXT, _gloffset_FogCoordfEXT ),
+ NAME_FUNC_OFFSET( 8852, glFogCoordfvEXT, _gloffset_FogCoordfvEXT ),
+ NAME_FUNC_OFFSET( 8868, glFogCoorddEXT, _gloffset_FogCoorddEXT ),
+ NAME_FUNC_OFFSET( 8883, glFogCoorddvEXT, _gloffset_FogCoorddvEXT ),
+ NAME_FUNC_OFFSET( 8899, glFogCoordPointerEXT, _gloffset_FogCoordPointerEXT ),
+ NAME_FUNC_OFFSET( 8920, glGetColorTableEXT, _gloffset_GetColorTableEXT ),
+ NAME_FUNC_OFFSET( 8939, glGetColorTableParameterivEXT, _gloffset_GetColorTableParameterivEXT ),
+ NAME_FUNC_OFFSET( 8969, glGetColorTableParameterfvEXT, _gloffset_GetColorTableParameterfvEXT ),
+ NAME_FUNC_OFFSET( 8999, glTbufferMask3DFX, _gloffset_TbufferMask3DFX ),
+ NAME_FUNC_OFFSET( 9017, glCompressedTexImage3DARB, _gloffset_CompressedTexImage3DARB ),
+ NAME_FUNC_OFFSET( 9043, glCompressedTexImage2DARB, _gloffset_CompressedTexImage2DARB ),
+ NAME_FUNC_OFFSET( 9069, glCompressedTexImage1DARB, _gloffset_CompressedTexImage1DARB ),
+ NAME_FUNC_OFFSET( 9095, glCompressedTexSubImage3DARB, _gloffset_CompressedTexSubImage3DARB ),
+ NAME_FUNC_OFFSET( 9124, glCompressedTexSubImage2DARB, _gloffset_CompressedTexSubImage2DARB ),
+ NAME_FUNC_OFFSET( 9153, glCompressedTexSubImage1DARB, _gloffset_CompressedTexSubImage1DARB ),
+ NAME_FUNC_OFFSET( 9182, glGetCompressedTexImageARB, _gloffset_GetCompressedTexImageARB ),
+ NAME_FUNC_OFFSET( 9209, glSecondaryColor3bEXT, _gloffset_SecondaryColor3bEXT ),
+ NAME_FUNC_OFFSET( 9231, glSecondaryColor3bvEXT, _gloffset_SecondaryColor3bvEXT ),
+ NAME_FUNC_OFFSET( 9254, glSecondaryColor3dEXT, _gloffset_SecondaryColor3dEXT ),
+ NAME_FUNC_OFFSET( 9276, glSecondaryColor3dvEXT, _gloffset_SecondaryColor3dvEXT ),
+ NAME_FUNC_OFFSET( 9299, glSecondaryColor3fEXT, _gloffset_SecondaryColor3fEXT ),
+ NAME_FUNC_OFFSET( 9321, glSecondaryColor3fvEXT, _gloffset_SecondaryColor3fvEXT ),
+ NAME_FUNC_OFFSET( 9344, glSecondaryColor3iEXT, _gloffset_SecondaryColor3iEXT ),
+ NAME_FUNC_OFFSET( 9366, glSecondaryColor3ivEXT, _gloffset_SecondaryColor3ivEXT ),
+ NAME_FUNC_OFFSET( 9389, glSecondaryColor3sEXT, _gloffset_SecondaryColor3sEXT ),
+ NAME_FUNC_OFFSET( 9411, glSecondaryColor3svEXT, _gloffset_SecondaryColor3svEXT ),
+ NAME_FUNC_OFFSET( 9434, glSecondaryColor3ubEXT, _gloffset_SecondaryColor3ubEXT ),
+ NAME_FUNC_OFFSET( 9457, glSecondaryColor3ubvEXT, _gloffset_SecondaryColor3ubvEXT ),
+ NAME_FUNC_OFFSET( 9481, glSecondaryColor3uiEXT, _gloffset_SecondaryColor3uiEXT ),
+ NAME_FUNC_OFFSET( 9504, glSecondaryColor3uivEXT, _gloffset_SecondaryColor3uivEXT ),
+ NAME_FUNC_OFFSET( 9528, glSecondaryColor3usEXT, _gloffset_SecondaryColor3usEXT ),
+ NAME_FUNC_OFFSET( 9551, glSecondaryColor3usvEXT, _gloffset_SecondaryColor3usvEXT ),
+ NAME_FUNC_OFFSET( 9575, glSecondaryColorPointerEXT, _gloffset_SecondaryColorPointerEXT ),
+ NAME_FUNC_OFFSET( 9602, glAreProgramsResidentNV, _gloffset_AreProgramsResidentNV ),
+ NAME_FUNC_OFFSET( 9626, glBindProgramNV, _gloffset_BindProgramNV ),
+ NAME_FUNC_OFFSET( 9642, glDeleteProgramsNV, _gloffset_DeleteProgramsNV ),
+ NAME_FUNC_OFFSET( 9661, glExecuteProgramNV, _gloffset_ExecuteProgramNV ),
+ NAME_FUNC_OFFSET( 9680, glGenProgramsNV, _gloffset_GenProgramsNV ),
+ NAME_FUNC_OFFSET( 9696, glGetProgramParameterdvNV, _gloffset_GetProgramParameterdvNV ),
+ NAME_FUNC_OFFSET( 9722, glGetProgramParameterfvNV, _gloffset_GetProgramParameterfvNV ),
+ NAME_FUNC_OFFSET( 9748, glGetProgramivNV, _gloffset_GetProgramivNV ),
+ NAME_FUNC_OFFSET( 9765, glGetProgramStringNV, _gloffset_GetProgramStringNV ),
+ NAME_FUNC_OFFSET( 9786, glGetTrackMatrixivNV, _gloffset_GetTrackMatrixivNV ),
+ NAME_FUNC_OFFSET( 9807, glGetVertexAttribdvARB, _gloffset_GetVertexAttribdvARB ),
+ NAME_FUNC_OFFSET( 9830, glGetVertexAttribfvARB, _gloffset_GetVertexAttribfvARB ),
+ NAME_FUNC_OFFSET( 9853, glGetVertexAttribivARB, _gloffset_GetVertexAttribivARB ),
+ NAME_FUNC_OFFSET( 9876, glGetVertexAttribPointervNV, _gloffset_GetVertexAttribPointervNV ),
+ NAME_FUNC_OFFSET( 9904, glIsProgramNV, _gloffset_IsProgramNV ),
+ NAME_FUNC_OFFSET( 9918, glLoadProgramNV, _gloffset_LoadProgramNV ),
+ NAME_FUNC_OFFSET( 9934, glProgramParameter4dNV, _gloffset_ProgramParameter4dNV ),
+ NAME_FUNC_OFFSET( 9957, glProgramParameter4dvNV, _gloffset_ProgramParameter4dvNV ),
+ NAME_FUNC_OFFSET( 9981, glProgramParameter4fNV, _gloffset_ProgramParameter4fNV ),
+ NAME_FUNC_OFFSET( 10004, glProgramParameter4fvNV, _gloffset_ProgramParameter4fvNV ),
+ NAME_FUNC_OFFSET( 10028, glProgramParameters4dvNV, _gloffset_ProgramParameters4dvNV ),
+ NAME_FUNC_OFFSET( 10053, glProgramParameters4fvNV, _gloffset_ProgramParameters4fvNV ),
+ NAME_FUNC_OFFSET( 10078, glRequestResidentProgramsNV, _gloffset_RequestResidentProgramsNV ),
+ NAME_FUNC_OFFSET( 10106, glTrackMatrixNV, _gloffset_TrackMatrixNV ),
+ NAME_FUNC_OFFSET( 10122, glVertexAttribPointerNV, _gloffset_VertexAttribPointerNV ),
+ NAME_FUNC_OFFSET( 10146, glVertexAttrib1dARB, _gloffset_VertexAttrib1dARB ),
+ NAME_FUNC_OFFSET( 10166, glVertexAttrib1dvARB, _gloffset_VertexAttrib1dvARB ),
+ NAME_FUNC_OFFSET( 10187, glVertexAttrib1fARB, _gloffset_VertexAttrib1fARB ),
+ NAME_FUNC_OFFSET( 10207, glVertexAttrib1fvARB, _gloffset_VertexAttrib1fvARB ),
+ NAME_FUNC_OFFSET( 10228, glVertexAttrib1sARB, _gloffset_VertexAttrib1sARB ),
+ NAME_FUNC_OFFSET( 10248, glVertexAttrib1svARB, _gloffset_VertexAttrib1svARB ),
+ NAME_FUNC_OFFSET( 10269, glVertexAttrib2dARB, _gloffset_VertexAttrib2dARB ),
+ NAME_FUNC_OFFSET( 10289, glVertexAttrib2dvARB, _gloffset_VertexAttrib2dvARB ),
+ NAME_FUNC_OFFSET( 10310, glVertexAttrib2fARB, _gloffset_VertexAttrib2fARB ),
+ NAME_FUNC_OFFSET( 10330, glVertexAttrib2fvARB, _gloffset_VertexAttrib2fvARB ),
+ NAME_FUNC_OFFSET( 10351, glVertexAttrib2sARB, _gloffset_VertexAttrib2sARB ),
+ NAME_FUNC_OFFSET( 10371, glVertexAttrib2svARB, _gloffset_VertexAttrib2svARB ),
+ NAME_FUNC_OFFSET( 10392, glVertexAttrib3dARB, _gloffset_VertexAttrib3dARB ),
+ NAME_FUNC_OFFSET( 10412, glVertexAttrib3dvARB, _gloffset_VertexAttrib3dvARB ),
+ NAME_FUNC_OFFSET( 10433, glVertexAttrib3fARB, _gloffset_VertexAttrib3fARB ),
+ NAME_FUNC_OFFSET( 10453, glVertexAttrib3fvARB, _gloffset_VertexAttrib3fvARB ),
+ NAME_FUNC_OFFSET( 10474, glVertexAttrib3sARB, _gloffset_VertexAttrib3sARB ),
+ NAME_FUNC_OFFSET( 10494, glVertexAttrib3svARB, _gloffset_VertexAttrib3svARB ),
+ NAME_FUNC_OFFSET( 10515, glVertexAttrib4dARB, _gloffset_VertexAttrib4dARB ),
+ NAME_FUNC_OFFSET( 10535, glVertexAttrib4dvARB, _gloffset_VertexAttrib4dvARB ),
+ NAME_FUNC_OFFSET( 10556, glVertexAttrib4fARB, _gloffset_VertexAttrib4fARB ),
+ NAME_FUNC_OFFSET( 10576, glVertexAttrib4fvARB, _gloffset_VertexAttrib4fvARB ),
+ NAME_FUNC_OFFSET( 10597, glVertexAttrib4sARB, _gloffset_VertexAttrib4sARB ),
+ NAME_FUNC_OFFSET( 10617, glVertexAttrib4svARB, _gloffset_VertexAttrib4svARB ),
+ NAME_FUNC_OFFSET( 10638, glVertexAttrib4NubARB, _gloffset_VertexAttrib4NubARB ),
+ NAME_FUNC_OFFSET( 10660, glVertexAttrib4NubvARB, _gloffset_VertexAttrib4NubvARB ),
+ NAME_FUNC_OFFSET( 10683, glVertexAttribs1dvNV, _gloffset_VertexAttribs1dvNV ),
+ NAME_FUNC_OFFSET( 10704, glVertexAttribs1fvNV, _gloffset_VertexAttribs1fvNV ),
+ NAME_FUNC_OFFSET( 10725, glVertexAttribs1svNV, _gloffset_VertexAttribs1svNV ),
+ NAME_FUNC_OFFSET( 10746, glVertexAttribs2dvNV, _gloffset_VertexAttribs2dvNV ),
+ NAME_FUNC_OFFSET( 10767, glVertexAttribs2fvNV, _gloffset_VertexAttribs2fvNV ),
+ NAME_FUNC_OFFSET( 10788, glVertexAttribs2svNV, _gloffset_VertexAttribs2svNV ),
+ NAME_FUNC_OFFSET( 10809, glVertexAttribs3dvNV, _gloffset_VertexAttribs3dvNV ),
+ NAME_FUNC_OFFSET( 10830, glVertexAttribs3fvNV, _gloffset_VertexAttribs3fvNV ),
+ NAME_FUNC_OFFSET( 10851, glVertexAttribs3svNV, _gloffset_VertexAttribs3svNV ),
+ NAME_FUNC_OFFSET( 10872, glVertexAttribs4dvNV, _gloffset_VertexAttribs4dvNV ),
+ NAME_FUNC_OFFSET( 10893, glVertexAttribs4fvNV, _gloffset_VertexAttribs4fvNV ),
+ NAME_FUNC_OFFSET( 10914, glVertexAttribs4svNV, _gloffset_VertexAttribs4svNV ),
+ NAME_FUNC_OFFSET( 10935, glVertexAttribs4ubvNV, _gloffset_VertexAttribs4ubvNV ),
+ NAME_FUNC_OFFSET( 10957, glPointParameteriNV, _gloffset_PointParameteriNV ),
+ NAME_FUNC_OFFSET( 10977, glPointParameterivNV, _gloffset_PointParameterivNV ),
+ NAME_FUNC_OFFSET( 10998, glMultiDrawArraysEXT, _gloffset_MultiDrawArraysEXT ),
+ NAME_FUNC_OFFSET( 11019, glMultiDrawElementsEXT, _gloffset_MultiDrawElementsEXT ),
+ NAME_FUNC_OFFSET( 11042, glActiveStencilFaceEXT, _gloffset_ActiveStencilFaceEXT ),
+ NAME_FUNC_OFFSET( 11065, glDeleteFencesNV, _gloffset_DeleteFencesNV ),
+ NAME_FUNC_OFFSET( 11082, glGenFencesNV, _gloffset_GenFencesNV ),
+ NAME_FUNC_OFFSET( 11096, glIsFenceNV, _gloffset_IsFenceNV ),
+ NAME_FUNC_OFFSET( 11108, glTestFenceNV, _gloffset_TestFenceNV ),
+ NAME_FUNC_OFFSET( 11122, glGetFenceivNV, _gloffset_GetFenceivNV ),
+ NAME_FUNC_OFFSET( 11137, glFinishFenceNV, _gloffset_FinishFenceNV ),
+ NAME_FUNC_OFFSET( 11153, glSetFenceNV, _gloffset_SetFenceNV ),
+ NAME_FUNC_OFFSET( 11166, glVertexAttrib4bvARB, _gloffset_VertexAttrib4bvARB ),
+ NAME_FUNC_OFFSET( 11187, glVertexAttrib4ivARB, _gloffset_VertexAttrib4ivARB ),
+ NAME_FUNC_OFFSET( 11208, glVertexAttrib4ubvARB, _gloffset_VertexAttrib4ubvARB ),
+ NAME_FUNC_OFFSET( 11230, glVertexAttrib4usvARB, _gloffset_VertexAttrib4usvARB ),
+ NAME_FUNC_OFFSET( 11252, glVertexAttrib4uivARB, _gloffset_VertexAttrib4uivARB ),
+ NAME_FUNC_OFFSET( 11274, glVertexAttrib4NbvARB, _gloffset_VertexAttrib4NbvARB ),
+ NAME_FUNC_OFFSET( 11296, glVertexAttrib4NsvARB, _gloffset_VertexAttrib4NsvARB ),
+ NAME_FUNC_OFFSET( 11318, glVertexAttrib4NivARB, _gloffset_VertexAttrib4NivARB ),
+ NAME_FUNC_OFFSET( 11340, glVertexAttrib4NusvARB, _gloffset_VertexAttrib4NusvARB ),
+ NAME_FUNC_OFFSET( 11363, glVertexAttrib4NuivARB, _gloffset_VertexAttrib4NuivARB ),
+ NAME_FUNC_OFFSET( 11386, glVertexAttribPointerARB, _gloffset_VertexAttribPointerARB ),
+ NAME_FUNC_OFFSET( 11411, glEnableVertexAttribArrayARB, _gloffset_EnableVertexAttribArrayARB ),
+ NAME_FUNC_OFFSET( 11440, glDisableVertexAttribArrayARB, _gloffset_DisableVertexAttribArrayARB ),
+ NAME_FUNC_OFFSET( 11470, glProgramStringARB, _gloffset_ProgramStringARB ),
+ NAME_FUNC_OFFSET( 11489, glProgramEnvParameter4dARB, _gloffset_ProgramEnvParameter4dARB ),
+ NAME_FUNC_OFFSET( 11516, glProgramEnvParameter4dvARB, _gloffset_ProgramEnvParameter4dvARB ),
+ NAME_FUNC_OFFSET( 11544, glProgramEnvParameter4fARB, _gloffset_ProgramEnvParameter4fARB ),
+ NAME_FUNC_OFFSET( 11571, glProgramEnvParameter4fvARB, _gloffset_ProgramEnvParameter4fvARB ),
+ NAME_FUNC_OFFSET( 11599, glProgramLocalParameter4dARB, _gloffset_ProgramLocalParameter4dARB ),
+ NAME_FUNC_OFFSET( 11628, glProgramLocalParameter4dvARB, _gloffset_ProgramLocalParameter4dvARB ),
+ NAME_FUNC_OFFSET( 11658, glProgramLocalParameter4fARB, _gloffset_ProgramLocalParameter4fARB ),
+ NAME_FUNC_OFFSET( 11687, glProgramLocalParameter4fvARB, _gloffset_ProgramLocalParameter4fvARB ),
+ NAME_FUNC_OFFSET( 11717, glGetProgramEnvParameterdvARB, _gloffset_GetProgramEnvParameterdvARB ),
+ NAME_FUNC_OFFSET( 11747, glGetProgramEnvParameterfvARB, _gloffset_GetProgramEnvParameterfvARB ),
+ NAME_FUNC_OFFSET( 11777, glGetProgramLocalParameterdvARB, _gloffset_GetProgramLocalParameterdvARB ),
+ NAME_FUNC_OFFSET( 11809, glGetProgramLocalParameterfvARB, _gloffset_GetProgramLocalParameterfvARB ),
+ NAME_FUNC_OFFSET( 11841, glGetProgramivARB, _gloffset_GetProgramivARB ),
+ NAME_FUNC_OFFSET( 11859, glGetProgramStringARB, _gloffset_GetProgramStringARB ),
+ NAME_FUNC_OFFSET( 11881, glProgramNamedParameter4fNV, _gloffset_ProgramNamedParameter4fNV ),
+ NAME_FUNC_OFFSET( 11909, glProgramNamedParameter4dNV, _gloffset_ProgramNamedParameter4dNV ),
+ NAME_FUNC_OFFSET( 11937, glProgramNamedParameter4fvNV, _gloffset_ProgramNamedParameter4fvNV ),
+ NAME_FUNC_OFFSET( 11966, glProgramNamedParameter4dvNV, _gloffset_ProgramNamedParameter4dvNV ),
+ NAME_FUNC_OFFSET( 11995, glGetProgramNamedParameterfvNV, _gloffset_GetProgramNamedParameterfvNV ),
+ NAME_FUNC_OFFSET( 12026, glGetProgramNamedParameterdvNV, _gloffset_GetProgramNamedParameterdvNV ),
+ NAME_FUNC_OFFSET( 12057, glBindBufferARB, _gloffset_BindBufferARB ),
+ NAME_FUNC_OFFSET( 12073, glBufferDataARB, _gloffset_BufferDataARB ),
+ NAME_FUNC_OFFSET( 12089, glBufferSubDataARB, _gloffset_BufferSubDataARB ),
+ NAME_FUNC_OFFSET( 12108, glDeleteBuffersARB, _gloffset_DeleteBuffersARB ),
+ NAME_FUNC_OFFSET( 12127, glGenBuffersARB, _gloffset_GenBuffersARB ),
+ NAME_FUNC_OFFSET( 12143, glGetBufferParameterivARB, _gloffset_GetBufferParameterivARB ),
+ NAME_FUNC_OFFSET( 12169, glGetBufferPointervARB, _gloffset_GetBufferPointervARB ),
+ NAME_FUNC_OFFSET( 12192, glGetBufferSubDataARB, _gloffset_GetBufferSubDataARB ),
+ NAME_FUNC_OFFSET( 12214, glIsBufferARB, _gloffset_IsBufferARB ),
+ NAME_FUNC_OFFSET( 12228, glMapBufferARB, _gloffset_MapBufferARB ),
+ NAME_FUNC_OFFSET( 12243, glUnmapBufferARB, _gloffset_UnmapBufferARB ),
+ NAME_FUNC_OFFSET( 12260, glDepthBoundsEXT, _gloffset_DepthBoundsEXT ),
+ NAME_FUNC_OFFSET( 12277, glGenQueriesARB, _gloffset_GenQueriesARB ),
+ NAME_FUNC_OFFSET( 12293, glDeleteQueriesARB, _gloffset_DeleteQueriesARB ),
+ NAME_FUNC_OFFSET( 12312, glIsQueryARB, _gloffset_IsQueryARB ),
+ NAME_FUNC_OFFSET( 12325, glBeginQueryARB, _gloffset_BeginQueryARB ),
+ NAME_FUNC_OFFSET( 12341, glEndQueryARB, _gloffset_EndQueryARB ),
+ NAME_FUNC_OFFSET( 12355, glGetQueryivARB, _gloffset_GetQueryivARB ),
+ NAME_FUNC_OFFSET( 12371, glGetQueryObjectivARB, _gloffset_GetQueryObjectivARB ),
+ NAME_FUNC_OFFSET( 12393, glGetQueryObjectuivARB, _gloffset_GetQueryObjectuivARB ),
+ NAME_FUNC_OFFSET( 12416, glMultiModeDrawArraysIBM, _gloffset_MultiModeDrawArraysIBM ),
+ NAME_FUNC_OFFSET( 12441, glMultiModeDrawElementsIBM, _gloffset_MultiModeDrawElementsIBM ),
+ NAME_FUNC_OFFSET( 12468, glBlendEquationSeparateEXT, _gloffset_BlendEquationSeparateEXT ),
+ NAME_FUNC_OFFSET( 12495, glDeleteObjectARB, _gloffset_DeleteObjectARB ),
+ NAME_FUNC_OFFSET( 12513, glGetHandleARB, _gloffset_GetHandleARB ),
+ NAME_FUNC_OFFSET( 12528, glDetachObjectARB, _gloffset_DetachObjectARB ),
+ NAME_FUNC_OFFSET( 12546, glCreateShaderObjectARB, _gloffset_CreateShaderObjectARB ),
+ NAME_FUNC_OFFSET( 12570, glShaderSourceARB, _gloffset_ShaderSourceARB ),
+ NAME_FUNC_OFFSET( 12588, glCompileShaderARB, _gloffset_CompileShaderARB ),
+ NAME_FUNC_OFFSET( 12607, glCreateProgramObjectARB, _gloffset_CreateProgramObjectARB ),
+ NAME_FUNC_OFFSET( 12632, glAttachObjectARB, _gloffset_AttachObjectARB ),
+ NAME_FUNC_OFFSET( 12650, glLinkProgramARB, _gloffset_LinkProgramARB ),
+ NAME_FUNC_OFFSET( 12667, glUseProgramObjectARB, _gloffset_UseProgramObjectARB ),
+ NAME_FUNC_OFFSET( 12689, glValidateProgramARB, _gloffset_ValidateProgramARB ),
+ NAME_FUNC_OFFSET( 12710, glUniform1fARB, _gloffset_Uniform1fARB ),
+ NAME_FUNC_OFFSET( 12725, glUniform2fARB, _gloffset_Uniform2fARB ),
+ NAME_FUNC_OFFSET( 12740, glUniform3fARB, _gloffset_Uniform3fARB ),
+ NAME_FUNC_OFFSET( 12755, glUniform4fARB, _gloffset_Uniform4fARB ),
+ NAME_FUNC_OFFSET( 12770, glUniform1iARB, _gloffset_Uniform1iARB ),
+ NAME_FUNC_OFFSET( 12785, glUniform2iARB, _gloffset_Uniform2iARB ),
+ NAME_FUNC_OFFSET( 12800, glUniform3iARB, _gloffset_Uniform3iARB ),
+ NAME_FUNC_OFFSET( 12815, glUniform4iARB, _gloffset_Uniform4iARB ),
+ NAME_FUNC_OFFSET( 12830, glUniform1fvARB, _gloffset_Uniform1fvARB ),
+ NAME_FUNC_OFFSET( 12846, glUniform2fvARB, _gloffset_Uniform2fvARB ),
+ NAME_FUNC_OFFSET( 12862, glUniform3fvARB, _gloffset_Uniform3fvARB ),
+ NAME_FUNC_OFFSET( 12878, glUniform4fvARB, _gloffset_Uniform4fvARB ),
+ NAME_FUNC_OFFSET( 12894, glUniform1ivARB, _gloffset_Uniform1ivARB ),
+ NAME_FUNC_OFFSET( 12910, glUniform2ivARB, _gloffset_Uniform2ivARB ),
+ NAME_FUNC_OFFSET( 12926, glUniform3ivARB, _gloffset_Uniform3ivARB ),
+ NAME_FUNC_OFFSET( 12942, glUniform4ivARB, _gloffset_Uniform4ivARB ),
+ NAME_FUNC_OFFSET( 12958, glUniformMatrix2fvARB, _gloffset_UniformMatrix2fvARB ),
+ NAME_FUNC_OFFSET( 12980, glUniformMatrix3fvARB, _gloffset_UniformMatrix3fvARB ),
+ NAME_FUNC_OFFSET( 13002, glUniformMatrix4fvARB, _gloffset_UniformMatrix4fvARB ),
+ NAME_FUNC_OFFSET( 13024, glGetObjectParameterfvARB, _gloffset_GetObjectParameterfvARB ),
+ NAME_FUNC_OFFSET( 13050, glGetObjectParameterivARB, _gloffset_GetObjectParameterivARB ),
+ NAME_FUNC_OFFSET( 13076, glGetInfoLogARB, _gloffset_GetInfoLogARB ),
+ NAME_FUNC_OFFSET( 13092, glGetAttachedObjectsARB, _gloffset_GetAttachedObjectsARB ),
+ NAME_FUNC_OFFSET( 13116, glGetUniformLocationARB, _gloffset_GetUniformLocationARB ),
+ NAME_FUNC_OFFSET( 13140, glGetActiveUniformARB, _gloffset_GetActiveUniformARB ),
+ NAME_FUNC_OFFSET( 13162, glGetUniformfvARB, _gloffset_GetUniformfvARB ),
+ NAME_FUNC_OFFSET( 13180, glGetUniformivARB, _gloffset_GetUniformivARB ),
+ NAME_FUNC_OFFSET( 13198, glGetShaderSourceARB, _gloffset_GetShaderSourceARB ),
+ NAME_FUNC_OFFSET( 13219, glBindAttribLocationARB, _gloffset_BindAttribLocationARB ),
+ NAME_FUNC_OFFSET( 13243, glGetActiveAttribARB, _gloffset_GetActiveAttribARB ),
+ NAME_FUNC_OFFSET( 13264, glGetAttribLocationARB, _gloffset_GetAttribLocationARB ),
+ NAME_FUNC_OFFSET( 13287, glGetVertexAttribdvNV, _gloffset_GetVertexAttribdvNV ),
+ NAME_FUNC_OFFSET( 13309, glGetVertexAttribfvNV, _gloffset_GetVertexAttribfvNV ),
+ NAME_FUNC_OFFSET( 13331, glGetVertexAttribivNV, _gloffset_GetVertexAttribivNV ),
+ NAME_FUNC_OFFSET( 13353, glVertexAttrib1dNV, _gloffset_VertexAttrib1dNV ),
+ NAME_FUNC_OFFSET( 13372, glVertexAttrib1dvNV, _gloffset_VertexAttrib1dvNV ),
+ NAME_FUNC_OFFSET( 13392, glVertexAttrib1fNV, _gloffset_VertexAttrib1fNV ),
+ NAME_FUNC_OFFSET( 13411, glVertexAttrib1fvNV, _gloffset_VertexAttrib1fvNV ),
+ NAME_FUNC_OFFSET( 13431, glVertexAttrib1sNV, _gloffset_VertexAttrib1sNV ),
+ NAME_FUNC_OFFSET( 13450, glVertexAttrib1svNV, _gloffset_VertexAttrib1svNV ),
+ NAME_FUNC_OFFSET( 13470, glVertexAttrib2dNV, _gloffset_VertexAttrib2dNV ),
+ NAME_FUNC_OFFSET( 13489, glVertexAttrib2dvNV, _gloffset_VertexAttrib2dvNV ),
+ NAME_FUNC_OFFSET( 13509, glVertexAttrib2fNV, _gloffset_VertexAttrib2fNV ),
+ NAME_FUNC_OFFSET( 13528, glVertexAttrib2fvNV, _gloffset_VertexAttrib2fvNV ),
+ NAME_FUNC_OFFSET( 13548, glVertexAttrib2sNV, _gloffset_VertexAttrib2sNV ),
+ NAME_FUNC_OFFSET( 13567, glVertexAttrib2svNV, _gloffset_VertexAttrib2svNV ),
+ NAME_FUNC_OFFSET( 13587, glVertexAttrib3dNV, _gloffset_VertexAttrib3dNV ),
+ NAME_FUNC_OFFSET( 13606, glVertexAttrib3dvNV, _gloffset_VertexAttrib3dvNV ),
+ NAME_FUNC_OFFSET( 13626, glVertexAttrib3fNV, _gloffset_VertexAttrib3fNV ),
+ NAME_FUNC_OFFSET( 13645, glVertexAttrib3fvNV, _gloffset_VertexAttrib3fvNV ),
+ NAME_FUNC_OFFSET( 13665, glVertexAttrib3sNV, _gloffset_VertexAttrib3sNV ),
+ NAME_FUNC_OFFSET( 13684, glVertexAttrib3svNV, _gloffset_VertexAttrib3svNV ),
+ NAME_FUNC_OFFSET( 13704, glVertexAttrib4dNV, _gloffset_VertexAttrib4dNV ),
+ NAME_FUNC_OFFSET( 13723, glVertexAttrib4dvNV, _gloffset_VertexAttrib4dvNV ),
+ NAME_FUNC_OFFSET( 13743, glVertexAttrib4fNV, _gloffset_VertexAttrib4fNV ),
+ NAME_FUNC_OFFSET( 13762, glVertexAttrib4fvNV, _gloffset_VertexAttrib4fvNV ),
+ NAME_FUNC_OFFSET( 13782, glVertexAttrib4sNV, _gloffset_VertexAttrib4sNV ),
+ NAME_FUNC_OFFSET( 13801, glVertexAttrib4svNV, _gloffset_VertexAttrib4svNV ),
+ NAME_FUNC_OFFSET( 13821, glVertexAttrib4ubNV, _gloffset_VertexAttrib4ubNV ),
+ NAME_FUNC_OFFSET( 13841, glVertexAttrib4ubvNV, _gloffset_VertexAttrib4ubvNV ),
+ NAME_FUNC_OFFSET( 13862, glGenFragmentShadersATI, _gloffset_GenFragmentShadersATI ),
+ NAME_FUNC_OFFSET( 13886, glBindFragmentShaderATI, _gloffset_BindFragmentShaderATI ),
+ NAME_FUNC_OFFSET( 13910, glDeleteFragmentShaderATI, _gloffset_DeleteFragmentShaderATI ),
+ NAME_FUNC_OFFSET( 13936, glBeginFragmentShaderATI, _gloffset_BeginFragmentShaderATI ),
+ NAME_FUNC_OFFSET( 13961, glEndFragmentShaderATI, _gloffset_EndFragmentShaderATI ),
+ NAME_FUNC_OFFSET( 13984, glPassTexCoordATI, _gloffset_PassTexCoordATI ),
+ NAME_FUNC_OFFSET( 14002, glSampleMapATI, _gloffset_SampleMapATI ),
+ NAME_FUNC_OFFSET( 14017, glColorFragmentOp1ATI, _gloffset_ColorFragmentOp1ATI ),
+ NAME_FUNC_OFFSET( 14039, glColorFragmentOp2ATI, _gloffset_ColorFragmentOp2ATI ),
+ NAME_FUNC_OFFSET( 14061, glColorFragmentOp3ATI, _gloffset_ColorFragmentOp3ATI ),
+ NAME_FUNC_OFFSET( 14083, glAlphaFragmentOp1ATI, _gloffset_AlphaFragmentOp1ATI ),
+ NAME_FUNC_OFFSET( 14105, glAlphaFragmentOp2ATI, _gloffset_AlphaFragmentOp2ATI ),
+ NAME_FUNC_OFFSET( 14127, glAlphaFragmentOp3ATI, _gloffset_AlphaFragmentOp3ATI ),
+ NAME_FUNC_OFFSET( 14149, glSetFragmentShaderConstantATI, _gloffset_SetFragmentShaderConstantATI ),
+ NAME_FUNC_OFFSET( 14180, glIsRenderbufferEXT, _gloffset_IsRenderbufferEXT ),
+ NAME_FUNC_OFFSET( 14200, glBindRenderbufferEXT, _gloffset_BindRenderbufferEXT ),
+ NAME_FUNC_OFFSET( 14222, glDeleteRenderbuffersEXT, _gloffset_DeleteRenderbuffersEXT ),
+ NAME_FUNC_OFFSET( 14247, glGenRenderbuffersEXT, _gloffset_GenRenderbuffersEXT ),
+ NAME_FUNC_OFFSET( 14269, glRenderbufferStorageEXT, _gloffset_RenderbufferStorageEXT ),
+ NAME_FUNC_OFFSET( 14294, glGetRenderbufferParameterivEXT, _gloffset_GetRenderbufferParameterivEXT ),
+ NAME_FUNC_OFFSET( 14326, glIsFramebufferEXT, _gloffset_IsFramebufferEXT ),
+ NAME_FUNC_OFFSET( 14345, glBindFramebufferEXT, _gloffset_BindFramebufferEXT ),
+ NAME_FUNC_OFFSET( 14366, glDeleteFramebuffersEXT, _gloffset_DeleteFramebuffersEXT ),
+ NAME_FUNC_OFFSET( 14390, glGenFramebuffersEXT, _gloffset_GenFramebuffersEXT ),
+ NAME_FUNC_OFFSET( 14411, glCheckFramebufferStatusEXT, _gloffset_CheckFramebufferStatusEXT ),
+ NAME_FUNC_OFFSET( 14439, glFramebufferTexture1DEXT, _gloffset_FramebufferTexture1DEXT ),
+ NAME_FUNC_OFFSET( 14465, glFramebufferTexture2DEXT, _gloffset_FramebufferTexture2DEXT ),
+ NAME_FUNC_OFFSET( 14491, glFramebufferTexture3DEXT, _gloffset_FramebufferTexture3DEXT ),
+ NAME_FUNC_OFFSET( 14517, glFramebufferRenderbufferEXT, _gloffset_FramebufferRenderbufferEXT ),
+ NAME_FUNC_OFFSET( 14546, glGetFramebufferAttachmentParameterivEXT, _gloffset_GetFramebufferAttachmentParameterivEXT ),
+ NAME_FUNC_OFFSET( 14587, glGenerateMipmapEXT, _gloffset_GenerateMipmapEXT ),
+ NAME_FUNC_OFFSET( 14607, glStencilFuncSeparate, _gloffset_StencilFuncSeparate ),
+ NAME_FUNC_OFFSET( 14629, glStencilOpSeparate, _gloffset_StencilOpSeparate ),
+ NAME_FUNC_OFFSET( 14649, glStencilMaskSeparate, _gloffset_StencilMaskSeparate ),
+ NAME_FUNC_OFFSET( 14671, glArrayElementEXT, _gloffset_ArrayElement ),
+ NAME_FUNC_OFFSET( 14689, glBindTextureEXT, _gloffset_BindTexture ),
+ NAME_FUNC_OFFSET( 14706, glDrawArraysEXT, _gloffset_DrawArrays ),
+ NAME_FUNC_OFFSET( 14722, glCopyTexImage1DEXT, _gloffset_CopyTexImage1D ),
+ NAME_FUNC_OFFSET( 14742, glCopyTexImage2DEXT, _gloffset_CopyTexImage2D ),
+ NAME_FUNC_OFFSET( 14762, glCopyTexSubImage1DEXT, _gloffset_CopyTexSubImage1D ),
+ NAME_FUNC_OFFSET( 14785, glCopyTexSubImage2DEXT, _gloffset_CopyTexSubImage2D ),
+ NAME_FUNC_OFFSET( 14808, glDeleteTexturesEXT, _gloffset_DeleteTextures ),
+ NAME_FUNC_OFFSET( 14828, glGetPointervEXT, _gloffset_GetPointerv ),
+ NAME_FUNC_OFFSET( 14845, glPrioritizeTexturesEXT, _gloffset_PrioritizeTextures ),
+ NAME_FUNC_OFFSET( 14869, glTexSubImage1DEXT, _gloffset_TexSubImage1D ),
+ NAME_FUNC_OFFSET( 14888, glTexSubImage2DEXT, _gloffset_TexSubImage2D ),
+ NAME_FUNC_OFFSET( 14907, glBlendColorEXT, _gloffset_BlendColor ),
+ NAME_FUNC_OFFSET( 14923, glBlendEquationEXT, _gloffset_BlendEquation ),
+ NAME_FUNC_OFFSET( 14942, glDrawRangeElementsEXT, _gloffset_DrawRangeElements ),
+ NAME_FUNC_OFFSET( 14965, glColorTableSGI, _gloffset_ColorTable ),
+ NAME_FUNC_OFFSET( 14981, glColorTableEXT, _gloffset_ColorTable ),
+ NAME_FUNC_OFFSET( 14997, glColorTableParameterfvSGI, _gloffset_ColorTableParameterfv ),
+ NAME_FUNC_OFFSET( 15024, glColorTableParameterivSGI, _gloffset_ColorTableParameteriv ),
+ NAME_FUNC_OFFSET( 15051, glCopyColorTableSGI, _gloffset_CopyColorTable ),
+ NAME_FUNC_OFFSET( 15071, glColorSubTableEXT, _gloffset_ColorSubTable ),
+ NAME_FUNC_OFFSET( 15090, glCopyColorSubTableEXT, _gloffset_CopyColorSubTable ),
+ NAME_FUNC_OFFSET( 15113, glConvolutionFilter1DEXT, _gloffset_ConvolutionFilter1D ),
+ NAME_FUNC_OFFSET( 15138, glConvolutionFilter2DEXT, _gloffset_ConvolutionFilter2D ),
+ NAME_FUNC_OFFSET( 15163, glConvolutionParameterfEXT, _gloffset_ConvolutionParameterf ),
+ NAME_FUNC_OFFSET( 15190, glConvolutionParameterfvEXT, _gloffset_ConvolutionParameterfv ),
+ NAME_FUNC_OFFSET( 15218, glConvolutionParameteriEXT, _gloffset_ConvolutionParameteri ),
+ NAME_FUNC_OFFSET( 15245, glConvolutionParameterivEXT, _gloffset_ConvolutionParameteriv ),
+ NAME_FUNC_OFFSET( 15273, glCopyConvolutionFilter1DEXT, _gloffset_CopyConvolutionFilter1D ),
+ NAME_FUNC_OFFSET( 15302, glCopyConvolutionFilter2DEXT, _gloffset_CopyConvolutionFilter2D ),
+ NAME_FUNC_OFFSET( 15331, glSeparableFilter2DEXT, _gloffset_SeparableFilter2D ),
+ NAME_FUNC_OFFSET( 15354, glHistogramEXT, _gloffset_Histogram ),
+ NAME_FUNC_OFFSET( 15369, glMinmaxEXT, _gloffset_Minmax ),
+ NAME_FUNC_OFFSET( 15381, glResetHistogramEXT, _gloffset_ResetHistogram ),
+ NAME_FUNC_OFFSET( 15401, glResetMinmaxEXT, _gloffset_ResetMinmax ),
+ NAME_FUNC_OFFSET( 15418, glTexImage3DEXT, _gloffset_TexImage3D ),
+ NAME_FUNC_OFFSET( 15434, glTexSubImage3DEXT, _gloffset_TexSubImage3D ),
+ NAME_FUNC_OFFSET( 15453, glCopyTexSubImage3DEXT, _gloffset_CopyTexSubImage3D ),
+ NAME_FUNC_OFFSET( 15476, glActiveTexture, _gloffset_ActiveTextureARB ),
+ NAME_FUNC_OFFSET( 15492, glClientActiveTexture, _gloffset_ClientActiveTextureARB ),
+ NAME_FUNC_OFFSET( 15514, glMultiTexCoord1d, _gloffset_MultiTexCoord1dARB ),
+ NAME_FUNC_OFFSET( 15532, glMultiTexCoord1dv, _gloffset_MultiTexCoord1dvARB ),
+ NAME_FUNC_OFFSET( 15551, glMultiTexCoord1f, _gloffset_MultiTexCoord1fARB ),
+ NAME_FUNC_OFFSET( 15569, glMultiTexCoord1fv, _gloffset_MultiTexCoord1fvARB ),
+ NAME_FUNC_OFFSET( 15588, glMultiTexCoord1i, _gloffset_MultiTexCoord1iARB ),
+ NAME_FUNC_OFFSET( 15606, glMultiTexCoord1iv, _gloffset_MultiTexCoord1ivARB ),
+ NAME_FUNC_OFFSET( 15625, glMultiTexCoord1s, _gloffset_MultiTexCoord1sARB ),
+ NAME_FUNC_OFFSET( 15643, glMultiTexCoord1sv, _gloffset_MultiTexCoord1svARB ),
+ NAME_FUNC_OFFSET( 15662, glMultiTexCoord2d, _gloffset_MultiTexCoord2dARB ),
+ NAME_FUNC_OFFSET( 15680, glMultiTexCoord2dv, _gloffset_MultiTexCoord2dvARB ),
+ NAME_FUNC_OFFSET( 15699, glMultiTexCoord2f, _gloffset_MultiTexCoord2fARB ),
+ NAME_FUNC_OFFSET( 15717, glMultiTexCoord2fv, _gloffset_MultiTexCoord2fvARB ),
+ NAME_FUNC_OFFSET( 15736, glMultiTexCoord2i, _gloffset_MultiTexCoord2iARB ),
+ NAME_FUNC_OFFSET( 15754, glMultiTexCoord2iv, _gloffset_MultiTexCoord2ivARB ),
+ NAME_FUNC_OFFSET( 15773, glMultiTexCoord2s, _gloffset_MultiTexCoord2sARB ),
+ NAME_FUNC_OFFSET( 15791, glMultiTexCoord2sv, _gloffset_MultiTexCoord2svARB ),
+ NAME_FUNC_OFFSET( 15810, glMultiTexCoord3d, _gloffset_MultiTexCoord3dARB ),
+ NAME_FUNC_OFFSET( 15828, glMultiTexCoord3dv, _gloffset_MultiTexCoord3dvARB ),
+ NAME_FUNC_OFFSET( 15847, glMultiTexCoord3f, _gloffset_MultiTexCoord3fARB ),
+ NAME_FUNC_OFFSET( 15865, glMultiTexCoord3fv, _gloffset_MultiTexCoord3fvARB ),
+ NAME_FUNC_OFFSET( 15884, glMultiTexCoord3i, _gloffset_MultiTexCoord3iARB ),
+ NAME_FUNC_OFFSET( 15902, glMultiTexCoord3iv, _gloffset_MultiTexCoord3ivARB ),
+ NAME_FUNC_OFFSET( 15921, glMultiTexCoord3s, _gloffset_MultiTexCoord3sARB ),
+ NAME_FUNC_OFFSET( 15939, glMultiTexCoord3sv, _gloffset_MultiTexCoord3svARB ),
+ NAME_FUNC_OFFSET( 15958, glMultiTexCoord4d, _gloffset_MultiTexCoord4dARB ),
+ NAME_FUNC_OFFSET( 15976, glMultiTexCoord4dv, _gloffset_MultiTexCoord4dvARB ),
+ NAME_FUNC_OFFSET( 15995, glMultiTexCoord4f, _gloffset_MultiTexCoord4fARB ),
+ NAME_FUNC_OFFSET( 16013, glMultiTexCoord4fv, _gloffset_MultiTexCoord4fvARB ),
+ NAME_FUNC_OFFSET( 16032, glMultiTexCoord4i, _gloffset_MultiTexCoord4iARB ),
+ NAME_FUNC_OFFSET( 16050, glMultiTexCoord4iv, _gloffset_MultiTexCoord4ivARB ),
+ NAME_FUNC_OFFSET( 16069, glMultiTexCoord4s, _gloffset_MultiTexCoord4sARB ),
+ NAME_FUNC_OFFSET( 16087, glMultiTexCoord4sv, _gloffset_MultiTexCoord4svARB ),
+ NAME_FUNC_OFFSET( 16106, glLoadTransposeMatrixf, _gloffset_LoadTransposeMatrixfARB ),
+ NAME_FUNC_OFFSET( 16129, glLoadTransposeMatrixd, _gloffset_LoadTransposeMatrixdARB ),
+ NAME_FUNC_OFFSET( 16152, glMultTransposeMatrixf, _gloffset_MultTransposeMatrixfARB ),
+ NAME_FUNC_OFFSET( 16175, glMultTransposeMatrixd, _gloffset_MultTransposeMatrixdARB ),
+ NAME_FUNC_OFFSET( 16198, glSampleCoverage, _gloffset_SampleCoverageARB ),
+ NAME_FUNC_OFFSET( 16215, glDrawBuffersATI, _gloffset_DrawBuffersARB ),
+ NAME_FUNC_OFFSET( 16232, glSampleMaskEXT, _gloffset_SampleMaskSGIS ),
+ NAME_FUNC_OFFSET( 16248, glSamplePatternEXT, _gloffset_SamplePatternSGIS ),
+ NAME_FUNC_OFFSET( 16267, glPointParameterf, _gloffset_PointParameterfEXT ),
+ NAME_FUNC_OFFSET( 16285, glPointParameterfARB, _gloffset_PointParameterfEXT ),
+ NAME_FUNC_OFFSET( 16306, glPointParameterfSGIS, _gloffset_PointParameterfEXT ),
+ NAME_FUNC_OFFSET( 16328, glPointParameterfv, _gloffset_PointParameterfvEXT ),
+ NAME_FUNC_OFFSET( 16347, glPointParameterfvARB, _gloffset_PointParameterfvEXT ),
+ NAME_FUNC_OFFSET( 16369, glPointParameterfvSGIS, _gloffset_PointParameterfvEXT ),
+ NAME_FUNC_OFFSET( 16392, glWindowPos2d, _gloffset_WindowPos2dMESA ),
+ NAME_FUNC_OFFSET( 16406, glWindowPos2dARB, _gloffset_WindowPos2dMESA ),
+ NAME_FUNC_OFFSET( 16423, glWindowPos2dv, _gloffset_WindowPos2dvMESA ),
+ NAME_FUNC_OFFSET( 16438, glWindowPos2dvARB, _gloffset_WindowPos2dvMESA ),
+ NAME_FUNC_OFFSET( 16456, glWindowPos2f, _gloffset_WindowPos2fMESA ),
+ NAME_FUNC_OFFSET( 16470, glWindowPos2fARB, _gloffset_WindowPos2fMESA ),
+ NAME_FUNC_OFFSET( 16487, glWindowPos2fv, _gloffset_WindowPos2fvMESA ),
+ NAME_FUNC_OFFSET( 16502, glWindowPos2fvARB, _gloffset_WindowPos2fvMESA ),
+ NAME_FUNC_OFFSET( 16520, glWindowPos2i, _gloffset_WindowPos2iMESA ),
+ NAME_FUNC_OFFSET( 16534, glWindowPos2iARB, _gloffset_WindowPos2iMESA ),
+ NAME_FUNC_OFFSET( 16551, glWindowPos2iv, _gloffset_WindowPos2ivMESA ),
+ NAME_FUNC_OFFSET( 16566, glWindowPos2ivARB, _gloffset_WindowPos2ivMESA ),
+ NAME_FUNC_OFFSET( 16584, glWindowPos2s, _gloffset_WindowPos2sMESA ),
+ NAME_FUNC_OFFSET( 16598, glWindowPos2sARB, _gloffset_WindowPos2sMESA ),
+ NAME_FUNC_OFFSET( 16615, glWindowPos2sv, _gloffset_WindowPos2svMESA ),
+ NAME_FUNC_OFFSET( 16630, glWindowPos2svARB, _gloffset_WindowPos2svMESA ),
+ NAME_FUNC_OFFSET( 16648, glWindowPos3d, _gloffset_WindowPos3dMESA ),
+ NAME_FUNC_OFFSET( 16662, glWindowPos3dARB, _gloffset_WindowPos3dMESA ),
+ NAME_FUNC_OFFSET( 16679, glWindowPos3dv, _gloffset_WindowPos3dvMESA ),
+ NAME_FUNC_OFFSET( 16694, glWindowPos3dvARB, _gloffset_WindowPos3dvMESA ),
+ NAME_FUNC_OFFSET( 16712, glWindowPos3f, _gloffset_WindowPos3fMESA ),
+ NAME_FUNC_OFFSET( 16726, glWindowPos3fARB, _gloffset_WindowPos3fMESA ),
+ NAME_FUNC_OFFSET( 16743, glWindowPos3fv, _gloffset_WindowPos3fvMESA ),
+ NAME_FUNC_OFFSET( 16758, glWindowPos3fvARB, _gloffset_WindowPos3fvMESA ),
+ NAME_FUNC_OFFSET( 16776, glWindowPos3i, _gloffset_WindowPos3iMESA ),
+ NAME_FUNC_OFFSET( 16790, glWindowPos3iARB, _gloffset_WindowPos3iMESA ),
+ NAME_FUNC_OFFSET( 16807, glWindowPos3iv, _gloffset_WindowPos3ivMESA ),
+ NAME_FUNC_OFFSET( 16822, glWindowPos3ivARB, _gloffset_WindowPos3ivMESA ),
+ NAME_FUNC_OFFSET( 16840, glWindowPos3s, _gloffset_WindowPos3sMESA ),
+ NAME_FUNC_OFFSET( 16854, glWindowPos3sARB, _gloffset_WindowPos3sMESA ),
+ NAME_FUNC_OFFSET( 16871, glWindowPos3sv, _gloffset_WindowPos3svMESA ),
+ NAME_FUNC_OFFSET( 16886, glWindowPos3svARB, _gloffset_WindowPos3svMESA ),
+ NAME_FUNC_OFFSET( 16904, glBlendFuncSeparate, _gloffset_BlendFuncSeparateEXT ),
+ NAME_FUNC_OFFSET( 16924, glBlendFuncSeparateINGR, _gloffset_BlendFuncSeparateEXT ),
+ NAME_FUNC_OFFSET( 16948, glFogCoordf, _gloffset_FogCoordfEXT ),
+ NAME_FUNC_OFFSET( 16960, glFogCoordfv, _gloffset_FogCoordfvEXT ),
+ NAME_FUNC_OFFSET( 16973, glFogCoordd, _gloffset_FogCoorddEXT ),
+ NAME_FUNC_OFFSET( 16985, glFogCoorddv, _gloffset_FogCoorddvEXT ),
+ NAME_FUNC_OFFSET( 16998, glFogCoordPointer, _gloffset_FogCoordPointerEXT ),
+ NAME_FUNC_OFFSET( 17016, glCompressedTexImage3D, _gloffset_CompressedTexImage3DARB ),
+ NAME_FUNC_OFFSET( 17039, glCompressedTexImage2D, _gloffset_CompressedTexImage2DARB ),
+ NAME_FUNC_OFFSET( 17062, glCompressedTexImage1D, _gloffset_CompressedTexImage1DARB ),
+ NAME_FUNC_OFFSET( 17085, glCompressedTexSubImage3D, _gloffset_CompressedTexSubImage3DARB ),
+ NAME_FUNC_OFFSET( 17111, glCompressedTexSubImage2D, _gloffset_CompressedTexSubImage2DARB ),
+ NAME_FUNC_OFFSET( 17137, glCompressedTexSubImage1D, _gloffset_CompressedTexSubImage1DARB ),
+ NAME_FUNC_OFFSET( 17163, glGetCompressedTexImage, _gloffset_GetCompressedTexImageARB ),
+ NAME_FUNC_OFFSET( 17187, glSecondaryColor3b, _gloffset_SecondaryColor3bEXT ),
+ NAME_FUNC_OFFSET( 17206, glSecondaryColor3bv, _gloffset_SecondaryColor3bvEXT ),
+ NAME_FUNC_OFFSET( 17226, glSecondaryColor3d, _gloffset_SecondaryColor3dEXT ),
+ NAME_FUNC_OFFSET( 17245, glSecondaryColor3dv, _gloffset_SecondaryColor3dvEXT ),
+ NAME_FUNC_OFFSET( 17265, glSecondaryColor3f, _gloffset_SecondaryColor3fEXT ),
+ NAME_FUNC_OFFSET( 17284, glSecondaryColor3fv, _gloffset_SecondaryColor3fvEXT ),
+ NAME_FUNC_OFFSET( 17304, glSecondaryColor3i, _gloffset_SecondaryColor3iEXT ),
+ NAME_FUNC_OFFSET( 17323, glSecondaryColor3iv, _gloffset_SecondaryColor3ivEXT ),
+ NAME_FUNC_OFFSET( 17343, glSecondaryColor3s, _gloffset_SecondaryColor3sEXT ),
+ NAME_FUNC_OFFSET( 17362, glSecondaryColor3sv, _gloffset_SecondaryColor3svEXT ),
+ NAME_FUNC_OFFSET( 17382, glSecondaryColor3ub, _gloffset_SecondaryColor3ubEXT ),
+ NAME_FUNC_OFFSET( 17402, glSecondaryColor3ubv, _gloffset_SecondaryColor3ubvEXT ),
+ NAME_FUNC_OFFSET( 17423, glSecondaryColor3ui, _gloffset_SecondaryColor3uiEXT ),
+ NAME_FUNC_OFFSET( 17443, glSecondaryColor3uiv, _gloffset_SecondaryColor3uivEXT ),
+ NAME_FUNC_OFFSET( 17464, glSecondaryColor3us, _gloffset_SecondaryColor3usEXT ),
+ NAME_FUNC_OFFSET( 17484, glSecondaryColor3usv, _gloffset_SecondaryColor3usvEXT ),
+ NAME_FUNC_OFFSET( 17505, glSecondaryColorPointer, _gloffset_SecondaryColorPointerEXT ),
+ NAME_FUNC_OFFSET( 17529, glBindProgramARB, _gloffset_BindProgramNV ),
+ NAME_FUNC_OFFSET( 17546, glDeleteProgramsARB, _gloffset_DeleteProgramsNV ),
+ NAME_FUNC_OFFSET( 17566, glGenProgramsARB, _gloffset_GenProgramsNV ),
+ NAME_FUNC_OFFSET( 17583, glGetVertexAttribPointervARB, _gloffset_GetVertexAttribPointervNV ),
+ NAME_FUNC_OFFSET( 17612, glIsProgramARB, _gloffset_IsProgramNV ),
+ NAME_FUNC_OFFSET( 17627, glPointParameteri, _gloffset_PointParameteriNV ),
+ NAME_FUNC_OFFSET( 17645, glPointParameteriv, _gloffset_PointParameterivNV ),
+ NAME_FUNC_OFFSET( 17664, glMultiDrawArrays, _gloffset_MultiDrawArraysEXT ),
+ NAME_FUNC_OFFSET( 17682, glMultiDrawElements, _gloffset_MultiDrawElementsEXT ),
+ NAME_FUNC_OFFSET( 17702, glBindBuffer, _gloffset_BindBufferARB ),
+ NAME_FUNC_OFFSET( 17715, glBufferData, _gloffset_BufferDataARB ),
+ NAME_FUNC_OFFSET( 17728, glBufferSubData, _gloffset_BufferSubDataARB ),
+ NAME_FUNC_OFFSET( 17744, glDeleteBuffers, _gloffset_DeleteBuffersARB ),
+ NAME_FUNC_OFFSET( 17760, glGenBuffers, _gloffset_GenBuffersARB ),
+ NAME_FUNC_OFFSET( 17773, glGetBufferParameteriv, _gloffset_GetBufferParameterivARB ),
+ NAME_FUNC_OFFSET( 17796, glGetBufferPointerv, _gloffset_GetBufferPointervARB ),
+ NAME_FUNC_OFFSET( 17816, glGetBufferSubData, _gloffset_GetBufferSubDataARB ),
+ NAME_FUNC_OFFSET( 17835, glIsBuffer, _gloffset_IsBufferARB ),
+ NAME_FUNC_OFFSET( 17846, glMapBuffer, _gloffset_MapBufferARB ),
+ NAME_FUNC_OFFSET( 17858, glUnmapBuffer, _gloffset_UnmapBufferARB ),
+ NAME_FUNC_OFFSET( 17872, glGenQueries, _gloffset_GenQueriesARB ),
+ NAME_FUNC_OFFSET( 17885, glDeleteQueries, _gloffset_DeleteQueriesARB ),
+ NAME_FUNC_OFFSET( 17901, glIsQuery, _gloffset_IsQueryARB ),
+ NAME_FUNC_OFFSET( 17911, glBeginQuery, _gloffset_BeginQueryARB ),
+ NAME_FUNC_OFFSET( 17924, glEndQuery, _gloffset_EndQueryARB ),
+ NAME_FUNC_OFFSET( 17935, glGetQueryiv, _gloffset_GetQueryivARB ),
+ NAME_FUNC_OFFSET( 17948, glGetQueryObjectiv, _gloffset_GetQueryObjectivARB ),
+ NAME_FUNC_OFFSET( 17967, glGetQueryObjectuiv, _gloffset_GetQueryObjectuivARB ),
+ NAME_FUNC_OFFSET( 17987, glBlendEquationSeparateATI, _gloffset_BlendEquationSeparateEXT ),
+ NAME_FUNC_OFFSET( -1, NULL, 0 )
+};
+
+#undef NAME_FUNC_OFFSET
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/glthread.c b/nx-X11/extras/Mesa/src/mesa/glapi/glthread.c
new file mode 100644
index 000000000..0683c1ec7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/glthread.c
@@ -0,0 +1,367 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 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.
+ */
+
+
+/*
+ * XXX There's probably some work to do in order to make this file
+ * truly reusable outside of Mesa. First, the glheader.h include must go.
+ */
+
+
+#include "glheader.h"
+#include "glthread.h"
+
+
+/*
+ * This file should still compile even when THREADS is not defined.
+ * This is to make things easier to deal with on the makefile scene..
+ */
+#ifdef THREADS
+#include <errno.h>
+
+/*
+ * Error messages
+ */
+#define INIT_TSD_ERROR "_glthread_: failed to allocate key for thread specific data"
+#define GET_TSD_ERROR "_glthread_: failed to get thread specific data"
+#define SET_TSD_ERROR "_glthread_: thread failed to set thread specific data"
+
+
+/*
+ * Magic number to determine if a TSD object has been initialized.
+ * Kind of a hack but there doesn't appear to be a better cross-platform
+ * solution.
+ */
+#define INIT_MAGIC 0xff8adc98
+
+
+
+/*
+ * POSIX Threads -- The best way to go if your platform supports them.
+ * Solaris >= 2.5 have POSIX threads, IRIX >= 6.4 reportedly
+ * has them, and many of the free Unixes now have them.
+ * Be sure to use appropriate -mt or -D_REENTRANT type
+ * compile flags when building.
+ */
+#ifdef PTHREADS
+
+unsigned long
+_glthread_GetID(void)
+{
+ return (unsigned long) pthread_self();
+}
+
+
+void
+_glthread_InitTSD(_glthread_TSD *tsd)
+{
+ if (pthread_key_create(&tsd->key, NULL/*free*/) != 0) {
+ perror(INIT_TSD_ERROR);
+ exit(-1);
+ }
+ tsd->initMagic = INIT_MAGIC;
+}
+
+
+void *
+_glthread_GetTSD(_glthread_TSD *tsd)
+{
+ if (tsd->initMagic != (int) INIT_MAGIC) {
+ _glthread_InitTSD(tsd);
+ }
+ return pthread_getspecific(tsd->key);
+}
+
+
+void
+_glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
+{
+ if (tsd->initMagic != (int) INIT_MAGIC) {
+ _glthread_InitTSD(tsd);
+ }
+ if (pthread_setspecific(tsd->key, ptr) != 0) {
+ perror(SET_TSD_ERROR);
+ exit(-1);
+ }
+}
+
+#endif /* PTHREADS */
+
+
+
+/*
+ * Solaris/Unix International Threads -- Use only if POSIX threads
+ * aren't available on your Unix platform. Solaris 2.[34] are examples
+ * of platforms where this is the case. Be sure to use -mt and/or
+ * -D_REENTRANT when compiling.
+ */
+#ifdef SOLARIS_THREADS
+#define USE_LOCK_FOR_KEY /* undef this to try a version without
+ lock for the global key... */
+
+unsigned long
+_glthread_GetID(void)
+{
+ abort(); /* XXX not implemented yet */
+ return (unsigned long) 0;
+}
+
+
+void
+_glthread_InitTSD(_glthread_TSD *tsd)
+{
+ if ((errno = mutex_init(&tsd->keylock, 0, NULL)) != 0 ||
+ (errno = thr_keycreate(&(tsd->key), free)) != 0) {
+ perror(INIT_TSD_ERROR);
+ exit(-1);
+ }
+ tsd->initMagic = INIT_MAGIC;
+}
+
+
+void *
+_glthread_GetTSD(_glthread_TSD *tsd)
+{
+ void* ret;
+ if (tsd->initMagic != INIT_MAGIC) {
+ _glthread_InitTSD(tsd);
+ }
+#ifdef USE_LOCK_FOR_KEY
+ mutex_lock(&tsd->keylock);
+ thr_getspecific(tsd->key, &ret);
+ mutex_unlock(&tsd->keylock);
+#else
+ if ((errno = thr_getspecific(tsd->key, &ret)) != 0) {
+ perror(GET_TSD_ERROR);
+ exit(-1);
+ }
+#endif
+ return ret;
+}
+
+
+void
+_glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
+{
+ if (tsd->initMagic != INIT_MAGIC) {
+ _glthread_InitTSD(tsd);
+ }
+ if ((errno = thr_setspecific(tsd->key, ptr)) != 0) {
+ perror(SET_TSD_ERROR);
+ exit(-1);
+ }
+}
+
+#undef USE_LOCK_FOR_KEY
+#endif /* SOLARIS_THREADS */
+
+
+
+/*
+ * Win32 Threads. The only available option for Windows 95/NT.
+ * Be sure that you compile using the Multithreaded runtime, otherwise
+ * bad things will happen.
+ */
+#ifdef WIN32_THREADS
+
+unsigned long
+_glthread_GetID(void)
+{
+ abort(); /* XXX not implemented yet */
+ return (unsigned long) 0;
+}
+
+
+void
+_glthread_InitTSD(_glthread_TSD *tsd)
+{
+ tsd->key = TlsAlloc();
+ if (tsd->key == 0xffffffff) {
+ /* Can Windows handle stderr messages for non-console
+ applications? Does Windows have perror? */
+ /* perror(SET_INIT_ERROR);*/
+ exit(-1);
+ }
+ tsd->initMagic = INIT_MAGIC;
+}
+
+
+void *
+_glthread_GetTSD(_glthread_TSD *tsd)
+{
+ if (tsd->initMagic != INIT_MAGIC) {
+ _glthread_InitTSD(tsd);
+ }
+ return TlsGetValue(tsd->key);
+}
+
+
+void
+_glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
+{
+ /* the following code assumes that the _glthread_TSD has been initialized
+ to zero at creation */
+ if (tsd->initMagic != INIT_MAGIC) {
+ _glthread_InitTSD(tsd);
+ }
+ if (TlsSetValue(tsd->key, ptr) == 0) {
+ /* Can Windows handle stderr messages for non-console
+ applications? Does Windows have perror? */
+ /* perror(SET_TSD_ERROR);*/
+ exit(-1);
+ }
+}
+
+#endif /* WIN32_THREADS */
+
+
+
+/*
+ * XFree86 has its own thread wrapper, Xthreads.h
+ * We wrap it again for GL.
+ */
+#ifdef USE_XTHREADS
+
+unsigned long
+_glthread_GetID(void)
+{
+ return (unsigned long) xthread_self();
+}
+
+
+void
+_glthread_InitTSD(_glthread_TSD *tsd)
+{
+ if (xthread_key_create(&tsd->key, NULL) != 0) {
+ perror(INIT_TSD_ERROR);
+ exit(-1);
+ }
+ tsd->initMagic = INIT_MAGIC;
+}
+
+
+void *
+_glthread_GetTSD(_glthread_TSD *tsd)
+{
+ void *ptr;
+ if (tsd->initMagic != INIT_MAGIC) {
+ _glthread_InitTSD(tsd);
+ }
+ xthread_get_specific(tsd->key, &ptr);
+ return ptr;
+}
+
+
+void
+_glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
+{
+ if (tsd->initMagic != INIT_MAGIC) {
+ _glthread_InitTSD(tsd);
+ }
+ xthread_set_specific(tsd->key, ptr);
+}
+
+#endif /* XTHREAD */
+
+
+
+/*
+ * BeOS threads
+ */
+#ifdef BEOS_THREADS
+
+unsigned long
+_glthread_GetID(void)
+{
+ return (unsigned long) find_thread(NULL);
+}
+
+void
+_glthread_InitTSD(_glthread_TSD *tsd)
+{
+ tsd->key = tls_allocate();
+ tsd->initMagic = INIT_MAGIC;
+}
+
+void *
+_glthread_GetTSD(_glthread_TSD *tsd)
+{
+ if (tsd->initMagic != (int) INIT_MAGIC) {
+ _glthread_InitTSD(tsd);
+ }
+ return tls_get(tsd->key);
+}
+
+void
+_glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
+{
+ if (tsd->initMagic != (int) INIT_MAGIC) {
+ _glthread_InitTSD(tsd);
+ }
+ tls_set(tsd->key, ptr);
+}
+
+#endif /* BEOS_THREADS */
+
+
+
+#else /* THREADS */
+
+
+/*
+ * no-op functions
+ */
+
+unsigned long
+_glthread_GetID(void)
+{
+ return 0;
+}
+
+
+void
+_glthread_InitTSD(_glthread_TSD *tsd)
+{
+ (void) tsd;
+}
+
+
+void *
+_glthread_GetTSD(_glthread_TSD *tsd)
+{
+ (void) tsd;
+ return NULL;
+}
+
+
+void
+_glthread_SetTSD(_glthread_TSD *tsd, void *ptr)
+{
+ (void) tsd;
+ (void) ptr;
+}
+
+
+#endif /* THREADS */
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/glthread.h b/nx-X11/extras/Mesa/src/mesa/glapi/glthread.h
new file mode 100644
index 000000000..53592aab3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/glthread.h
@@ -0,0 +1,314 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+
+/*
+ * Thread support for gl dispatch.
+ *
+ * Initial version by John Stone (j.stone@acm.org) (johns@cs.umr.edu)
+ * and Christoph Poliwoda (poliwoda@volumegraphics.com)
+ * Revised by Keith Whitwell
+ * Adapted for new gl dispatcher by Brian Paul
+ *
+ *
+ *
+ * DOCUMENTATION
+ *
+ * This thread module exports the following types:
+ * _glthread_TSD Thread-specific data area
+ * _glthread_Thread Thread datatype
+ * _glthread_Mutex Mutual exclusion lock
+ *
+ * Macros:
+ * _glthread_DECLARE_STATIC_MUTEX(name) Declare a non-local mutex
+ * _glthread_INIT_MUTEX(name) Initialize a mutex
+ * _glthread_LOCK_MUTEX(name) Lock a mutex
+ * _glthread_UNLOCK_MUTEX(name) Unlock a mutex
+ *
+ * Functions:
+ * _glthread_GetID(v) Get integer thread ID
+ * _glthread_InitTSD() Initialize thread-specific data
+ * _glthread_GetTSD() Get thread-specific data
+ * _glthread_SetTSD() Set thread-specific data
+ *
+ */
+
+/*
+ * If this file is accidentally included by a non-threaded build,
+ * it should not cause the build to fail, or otherwise cause problems.
+ * In general, it should only be included when needed however.
+ */
+
+#ifndef GLTHREAD_H
+#define GLTHREAD_H
+
+
+#if (defined(PTHREADS) || defined(SOLARIS_THREADS) ||\
+ defined(WIN32_THREADS) || defined(USE_XTHREADS) || defined(BEOS_THREADS)) \
+ && !defined(THREADS)
+# define THREADS
+#endif
+
+#ifdef VMS
+#include <GL/vms_x_fix.h>
+#endif
+
+/*
+ * POSIX threads. This should be your choice in the Unix world
+ * whenever possible. When building with POSIX threads, be sure
+ * to enable any compiler flags which will cause the MT-safe
+ * libc (if one exists) to be used when linking, as well as any
+ * header macros for MT-safe errno, etc. For Solaris, this is the -mt
+ * compiler flag. On Solaris with gcc, use -D_REENTRANT to enable
+ * proper compiling for MT-safe libc etc.
+ */
+#if defined(PTHREADS)
+#include <pthread.h> /* POSIX threads headers */
+
+typedef struct {
+ pthread_key_t key;
+ int initMagic;
+} _glthread_TSD;
+
+typedef pthread_t _glthread_Thread;
+
+typedef pthread_mutex_t _glthread_Mutex;
+
+#define _glthread_DECLARE_STATIC_MUTEX(name) \
+ static _glthread_Mutex name = PTHREAD_MUTEX_INITIALIZER
+
+#define _glthread_INIT_MUTEX(name) \
+ pthread_mutex_init(&(name), NULL)
+
+#define _glthread_DESTROY_MUTEX(name) \
+ pthread_mutex_destroy(&(name))
+
+#define _glthread_LOCK_MUTEX(name) \
+ (void) pthread_mutex_lock(&(name))
+
+#define _glthread_UNLOCK_MUTEX(name) \
+ (void) pthread_mutex_unlock(&(name))
+
+#endif /* PTHREADS */
+
+
+
+
+/*
+ * Solaris threads. Use only up to Solaris 2.4.
+ * Solaris 2.5 and higher provide POSIX threads.
+ * Be sure to compile with -mt on the Solaris compilers, or
+ * use -D_REENTRANT if using gcc.
+ */
+#ifdef SOLARIS_THREADS
+#include <thread.h>
+
+typedef struct {
+ thread_key_t key;
+ mutex_t keylock;
+ int initMagic;
+} _glthread_TSD;
+
+typedef thread_t _glthread_Thread;
+
+typedef mutex_t _glthread_Mutex;
+
+/* XXX need to really implement mutex-related macros */
+#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = 0
+#define _glthread_INIT_MUTEX(name) (void) name
+#define _glthread_DESTROY_MUTEX(name) (void) name
+#define _glthread_LOCK_MUTEX(name) (void) name
+#define _glthread_UNLOCK_MUTEX(name) (void) name
+
+#endif /* SOLARIS_THREADS */
+
+
+
+
+/*
+ * Windows threads. Should work with Windows NT and 95.
+ * IMPORTANT: Link with multithreaded runtime library when THREADS are
+ * used!
+ */
+#ifdef WIN32_THREADS
+#include <windows.h>
+
+typedef struct {
+ DWORD key;
+ int initMagic;
+} _glthread_TSD;
+
+typedef HANDLE _glthread_Thread;
+
+typedef CRITICAL_SECTION _glthread_Mutex;
+
+/* XXX need to really implement mutex-related macros */
+#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = 0
+#define _glthread_INIT_MUTEX(name) (void) name
+#define _glthread_DESTROY_MUTEX(name) (void) name
+#define _glthread_LOCK_MUTEX(name) (void) name
+#define _glthread_UNLOCK_MUTEX(name) (void) name
+
+#endif /* WIN32_THREADS */
+
+
+
+
+/*
+ * XFree86 has its own thread wrapper, Xthreads.h
+ * We wrap it again for GL.
+ */
+#ifdef USE_XTHREADS
+#include <X11/Xthreads.h>
+
+typedef struct {
+ xthread_key_t key;
+ int initMagic;
+} _glthread_TSD;
+
+typedef xthread_t _glthread_Thread;
+
+typedef xmutex_rec _glthread_Mutex;
+
+#ifdef XMUTEX_INITIALIZER
+#define _glthread_DECLARE_STATIC_MUTEX(name) \
+ static _glthread_Mutex name = XMUTEX_INITIALIZER
+#else
+#define _glthread_DECLARE_STATIC_MUTEX(name) \
+ static _glthread_Mutex name
+#endif
+
+#define _glthread_INIT_MUTEX(name) \
+ xmutex_init(&(name))
+
+#define _glthread_DESTROY_MUTEX(name) \
+ xmutex_clear(&(name))
+
+#define _glthread_LOCK_MUTEX(name) \
+ (void) xmutex_lock(&(name))
+
+#define _glthread_UNLOCK_MUTEX(name) \
+ (void) xmutex_unlock(&(name))
+
+#endif /* USE_XTHREADS */
+
+
+
+/*
+ * BeOS threads. R5.x required.
+ */
+#ifdef BEOS_THREADS
+
+#include <kernel/OS.h>
+#include <support/TLS.h>
+
+typedef struct {
+ int32 key;
+ int initMagic;
+} _glthread_TSD;
+
+typedef thread_id _glthread_Thread;
+
+/* Use Benaphore, aka speeder semaphore */
+typedef struct {
+ int32 lock;
+ sem_id sem;
+} benaphore;
+typedef benaphore _glthread_Mutex;
+
+#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = { 0, 0 }
+#define _glthread_INIT_MUTEX(name) name.sem = create_sem(0, #name"_benaphore"), name.lock = 0
+#define _glthread_DESTROY_MUTEX(name) delete_sem(name.sem), name.lock = 0
+#define _glthread_LOCK_MUTEX(name) if (name.sem == 0) _glthread_INIT_MUTEX(name); \
+ if (atomic_add(&(name.lock), 1) >= 1) acquire_sem(name.sem)
+#define _glthread_UNLOCK_MUTEX(name) if (atomic_add(&(name.lock), -1) > 1) release_sem(name.sem)
+
+#endif /* BEOS_THREADS */
+
+
+
+#ifndef THREADS
+
+/*
+ * THREADS not defined
+ */
+
+typedef GLuint _glthread_TSD;
+
+typedef GLuint _glthread_Thread;
+
+typedef GLuint _glthread_Mutex;
+
+#define _glthread_DECLARE_STATIC_MUTEX(name) static _glthread_Mutex name = 0
+
+#define _glthread_INIT_MUTEX(name) (void) name
+
+#define _glthread_DESTROY_MUTEX(name) (void) name
+
+#define _glthread_LOCK_MUTEX(name) (void) name
+
+#define _glthread_UNLOCK_MUTEX(name) (void) name
+
+#endif /* THREADS */
+
+
+
+/*
+ * Platform independent thread specific data API.
+ */
+
+extern unsigned long
+_glthread_GetID(void);
+
+
+extern void
+_glthread_InitTSD(_glthread_TSD *);
+
+
+extern void *
+_glthread_GetTSD(_glthread_TSD *);
+
+
+extern void
+_glthread_SetTSD(_glthread_TSD *, void *);
+
+#if defined(GLX_USE_TLS)
+
+extern __thread struct _glapi_table * _glapi_tls_Dispatch
+ __attribute__((tls_model("initial-exec")));
+
+#define GET_DISPATCH() _glapi_tls_Dispatch
+
+#elif !defined(GL_CALL)
+# if defined(THREADS)
+# define GET_DISPATCH() \
+ ((__builtin_expect( _glapi_Dispatch != NULL, 1 )) \
+ ? _glapi_Dispatch : _glapi_get_dispatch())
+# else
+# define GET_DISPATCH() _glapi_Dispatch
+# endif /* defined(THREADS) */
+#endif /* ndef GL_CALL */
+
+
+#endif /* THREADS_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/license.py b/nx-X11/extras/Mesa/src/mesa/glapi/license.py
new file mode 100644
index 000000000..02181648e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/license.py
@@ -0,0 +1,47 @@
+# (C) Copyright IBM Corporation 2004
+# 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
+# IBM 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:
+# Ian Romanick <idr@us.ibm.com>
+
+bsd_license_template = """%s
+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
+%s,
+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."""
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/mesadef.py b/nx-X11/extras/Mesa/src/mesa/glapi/mesadef.py
new file mode 100644
index 000000000..604be2ba6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/mesadef.py
@@ -0,0 +1,223 @@
+#!/usr/bin/env python
+
+# $Id: mesadef.py,v 1.1.1.1 2004/06/16 09:19:06 anholt Exp $
+
+# Mesa 3-D graphics library
+# Version: 4.1
+#
+# Copyright (C) 1999-2001 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.
+
+
+# Generate the mesa.def file for Windows.
+#
+# Usage:
+# mesadef.py >mesa.def
+# Then copy to src/mesa/drivers/windows/gdi
+#
+# Dependencies:
+# The apispec file must be in the current directory.
+
+
+
+import apiparser
+import string
+
+
+def PrintHead():
+ print '; DO NOT EDIT - This file generated automatically by mesadef.py script'
+ print 'DESCRIPTION \'Mesa (OpenGL work-alike) for Win32\''
+ print 'VERSION 6.0'
+ print ';'
+ print '; Module definition file for Mesa (OPENGL32.DLL)'
+ print ';'
+ print '; Note: The OpenGL functions use the STDCALL'
+ print '; function calling convention. Microsoft\'s'
+ print '; OPENGL32 uses this convention and so must the'
+ print '; Mesa OPENGL32 so that the Mesa DLL can be used'
+ print '; as a drop-in replacement.'
+ print ';'
+ print '; The linker exports STDCALL entry points with'
+ print '; \'decorated\' names; e.g., _glBegin@0, where the'
+ print '; trailing number is the number of bytes of '
+ print '; parameter data pushed onto the stack. The'
+ print '; callee is responsible for popping this data'
+ print '; off the stack, usually via a RETF n instruction.'
+ print ';'
+ print '; However, the Microsoft OPENGL32.DLL does not export'
+ print '; the decorated names, even though the calling convention'
+ print '; is STDCALL. So, this module definition file is'
+ print '; needed to force the Mesa OPENGL32.DLL to export the'
+ print '; symbols in the same manner as the Microsoft DLL.'
+ print '; Were it not for this problem, this file would not'
+ print '; be needed (for the gl* functions) since the entry'
+ print '; points are compiled with dllexport declspec.'
+ print ';'
+ print '; However, this file is still needed to export "internal"'
+ print '; Mesa symbols for the benefit of the OSMESA32.DLL.'
+ print ';'
+ print 'EXPORTS'
+ return
+#enddef
+
+
+def PrintTail():
+ print ';'
+ print '; WGL API'
+ print '\twglChoosePixelFormat'
+ print '\twglCopyContext'
+ print '\twglCreateContext'
+ print '\twglCreateLayerContext'
+ print '\twglDeleteContext'
+ print '\twglDescribeLayerPlane'
+ print '\twglDescribePixelFormat'
+ print '\twglGetCurrentContext'
+ print '\twglGetCurrentDC'
+ print '\twglGetLayerPaletteEntries'
+ print '\twglGetPixelFormat'
+ print '\twglGetProcAddress'
+ print '\twglMakeCurrent'
+ print '\twglRealizeLayerPalette'
+ print '\twglSetLayerPaletteEntries'
+ print '\twglSetPixelFormat'
+ print '\twglShareLists'
+ print '\twglSwapBuffers'
+ print '\twglSwapLayerBuffers'
+ print '\twglUseFontBitmapsA'
+ print '\twglUseFontBitmapsW'
+ print '\twglUseFontOutlinesA'
+ print '\twglUseFontOutlinesW'
+ print ';'
+ print '; Mesa internals - mostly for OSMESA'
+ print '\t_ac_CreateContext'
+ print '\t_ac_DestroyContext'
+ print '\t_ac_InvalidateState'
+ print '\t_glapi_get_context'
+ print '\t_glapi_get_proc_address'
+ print '\t_mesa_buffer_data'
+ print '\t_mesa_buffer_map'
+ print '\t_mesa_buffer_subdata'
+ print '\t_mesa_bzero'
+ print '\t_mesa_calloc'
+ print '\t_mesa_choose_tex_format'
+ print '\t_mesa_compressed_texture_size'
+ print '\t_mesa_create_framebuffer'
+ print '\t_mesa_create_visual'
+ print '\t_mesa_delete_buffer_object'
+ print '\t_mesa_delete_texture_object'
+ print '\t_mesa_destroy_framebuffer'
+ print '\t_mesa_destroy_visual'
+ print '\t_mesa_enable_1_3_extensions'
+ print '\t_mesa_enable_1_4_extensions'
+ print '\t_mesa_enable_1_5_extensions'
+ print '\t_mesa_enable_sw_extensions'
+ print '\t_mesa_error'
+ print '\t_mesa_free'
+ print '\t_mesa_free_context_data'
+ print '\t_mesa_get_current_context'
+ print '\t_mesa_init_default_imports'
+ print '\t_mesa_initialize_context'
+ print '\t_mesa_make_current'
+ print '\t_mesa_memcpy'
+ print '\t_mesa_memset'
+ print '\t_mesa_new_buffer_object'
+ print '\t_mesa_new_texture_object'
+ print '\t_mesa_problem'
+ print '\t_mesa_ResizeBuffersMESA'
+ print '\t_mesa_store_compressed_teximage1d'
+ print '\t_mesa_store_compressed_teximage2d'
+ print '\t_mesa_store_compressed_teximage3d'
+ print '\t_mesa_store_compressed_texsubimage1d'
+ print '\t_mesa_store_compressed_texsubimage2d'
+ print '\t_mesa_store_compressed_texsubimage3d'
+ print '\t_mesa_store_teximage1d'
+ print '\t_mesa_store_teximage2d'
+ print '\t_mesa_store_teximage3d'
+ print '\t_mesa_store_texsubimage1d'
+ print '\t_mesa_store_texsubimage2d'
+ print '\t_mesa_store_texsubimage3d'
+ print '\t_mesa_strcmp'
+ print '\t_mesa_test_proxy_teximage'
+ print '\t_mesa_Viewport'
+ print '\t_swrast_Accum'
+ print '\t_swrast_alloc_buffers'
+ print '\t_swrast_Bitmap'
+ print '\t_swrast_CopyPixels'
+ print '\t_swrast_DrawBuffer'
+ print '\t_swrast_DrawPixels'
+ print '\t_swrast_GetDeviceDriverReference'
+ print '\t_swrast_Clear'
+ print '\t_swrast_choose_line'
+ print '\t_swrast_choose_triangle'
+ print '\t_swrast_CopyColorSubTable'
+ print '\t_swrast_CopyColorTable'
+ print '\t_swrast_CopyConvolutionFilter1D'
+ print '\t_swrast_CopyConvolutionFilter2D'
+ print '\t_swrast_copy_teximage1d'
+ print '\t_swrast_copy_teximage2d'
+ print '\t_swrast_copy_texsubimage1d'
+ print '\t_swrast_copy_texsubimage2d'
+ print '\t_swrast_copy_texsubimage3d'
+ print '\t_swrast_CreateContext'
+ print '\t_swrast_DestroyContext'
+ print '\t_swrast_InvalidateState'
+ print '\t_swrast_ReadPixels'
+ print '\t_swrast_zbuffer_address'
+ print '\t_swsetup_Wakeup'
+ print '\t_swsetup_CreateContext'
+ print '\t_swsetup_DestroyContext'
+ print '\t_swsetup_InvalidateState'
+ print '\t_tnl_CreateContext'
+ print '\t_tnl_DestroyContext'
+ print '\t_tnl_InvalidateState'
+ print '\t_tnl_MakeCurrent'
+ print '\t_tnl_run_pipeline'
+#enddef
+
+
+records = []
+
+def FindOffset(funcName):
+ for (name, alias, offset) in records:
+ if name == funcName:
+ return offset
+ #endif
+ #endfor
+ return -1
+#enddef
+
+
+def EmitEntry(name, returnType, argTypeList, argNameList, alias, offset):
+ if alias == '':
+ dispatchName = name
+ else:
+ dispatchName = alias
+ if offset < 0:
+ offset = FindOffset(dispatchName)
+ if offset >= 0 and string.find(name, "unused") == -1:
+ print '\tgl%s' % (name)
+ # save this info in case we need to look up an alias later
+ records.append((name, dispatchName, offset))
+
+#enddef
+
+
+PrintHead()
+apiparser.ProcessSpecFile("APIspec", EmitEntry)
+PrintTail()
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/next_available_offset.sh b/nx-X11/extras/Mesa/src/mesa/glapi/next_available_offset.sh
new file mode 100755
index 000000000..e7d6c2f4a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/next_available_offset.sh
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+#
+# (C) Copyright IBM Corporation 2004
+# 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
+# IBM 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:
+# Ian Romanick <idr@us.ibm.com>
+
+# Trivial shell script to search the API definition file and print out the
+# next numerically available API entry-point offset. This could probably
+# be made smarter, but it would be better to use the existin Python
+# framework to do that. This is just a quick-and-dirty hack.
+
+num=$(grep 'offset="' gl_API.xml |\
+ sed 's/.\+ offset="//g;s/".*$//g' |\
+ grep -v '?' |\
+ sort -rn |\
+ head -1)
+
+echo $((num + 1))
diff --git a/nx-X11/extras/Mesa/src/mesa/glapi/typeexpr.py b/nx-X11/extras/Mesa/src/mesa/glapi/typeexpr.py
new file mode 100644
index 000000000..eface2a52
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/glapi/typeexpr.py
@@ -0,0 +1,288 @@
+#!/usr/bin/env python
+
+# (C) Copyright IBM Corporation 2005
+# 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
+# IBM 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:
+# Ian Romanick <idr@us.ibm.com>
+
+import string, copy
+
+class type_node:
+ def __init__(self):
+ self.pointer = 0
+ self.const = 0
+ self.signed = 1
+ self.integer = 1
+
+ # If elements is set to non-zero, then field is an array.
+ self.elements = 0
+
+ self.name = None
+ self.size = 0
+ return
+
+
+ def string(self):
+ s = ""
+
+ if self.pointer:
+ s = "* "
+
+ if self.const:
+ s += "const "
+
+ if not self.pointer:
+ if self.integer:
+ if self.signed:
+ s += "signed "
+ else:
+ s += "unsigned "
+
+ if self.name:
+ s += "%s " % (self.name)
+
+ return s
+
+
+class type_table:
+ def __init__(self):
+ self.types_by_name = {}
+ return
+
+
+ def add_type(self, type_expr):
+ self.types_by_name[ type_expr.get_base_name() ] = type_expr
+ return
+
+
+ def find_type(self, name):
+ if name in self.types_by_name:
+ return self.types_by_name[ name ]
+ else:
+ return None
+
+
+def create_initial_types():
+ tt = type_table()
+
+ basic_types = [ ["char", 1, 1], \
+ ["short", 2, 1], \
+ ["int", 4, 1], \
+ ["long", 4, 1], \
+ ["float", 4, 0], \
+ ["double", 8, 0], \
+ ["enum", 4, 1] ]
+
+
+ for [type_name, type_size, integer] in basic_types:
+ te = type_expression(None)
+ tn = type_node()
+ tn.name = type_name
+ tn.size = type_size
+ tn.integer = integer
+ te.expr.append(tn)
+ tt.add_type( te )
+
+ type_expression.built_in_types = tt
+ return
+
+
+class type_expression:
+ built_in_types = None
+
+ def __init__(self, type_string, extra_types = None):
+ self.expr = []
+
+ if not type_string: return
+
+ self.original_string = type_string
+
+ if not type_expression.built_in_types:
+ raise RuntimeError("create_initial_types must be called before creating type_expression objects.")
+
+
+ elements = string.split( string.replace( type_string, "*", " * " ) )
+
+ const = 0
+ t = None
+ signed = 0
+ unsigned = 0
+
+ for i in elements:
+ if i == "const":
+ if t and t.pointer:
+ t.const = 1
+ else:
+ const = 1
+ elif i == "signed":
+ signed = 1
+ elif i == "unsigned":
+ unsigned = 1
+ elif i == "*":
+ # This is a quirky special-case because of the
+ # way the C works for types. If 'unsigned' is
+ # specified all by itself, it is treated the
+ # same as "unsigned int".
+
+ if unsigned:
+ self.set_base_type( "int", signed, unsigned, const, extra_types )
+ const = 0
+ signed = 0
+ unsigned = 0
+
+ if not self.expr:
+ raise RuntimeError("Invalid type expression (dangling pointer)")
+
+ if signed:
+ raise RuntimeError("Invalid type expression (signed / unsigned applied to pointer)")
+
+ t = type_node()
+ t.pointer = 1
+ self.expr.append( t )
+ else:
+ if self.expr:
+ raise RuntimeError('Invalid type expression (garbage after pointer qualifier -> "%s")' % (self.original_string))
+
+ self.set_base_type( i, signed, unsigned, const, extra_types )
+ const = 0
+ signed = 0
+ unsigned = 0
+
+ if signed and unsigned:
+ raise RuntimeError("Invalid type expression (both signed and unsigned specified)")
+
+
+ if const:
+ raise RuntimeError("Invalid type expression (dangling const)")
+
+ if unsigned:
+ raise RuntimeError("Invalid type expression (dangling signed)")
+
+ if signed:
+ raise RuntimeError("Invalid type expression (dangling unsigned)")
+
+ return
+
+
+ def set_base_type(self, type_name, signed, unsigned, const, extra_types):
+ te = type_expression.built_in_types.find_type( type_name )
+ if not te:
+ te = extra_types.find_type( type_name )
+
+ if not te:
+ raise RuntimeError('Unknown base type "%s".' % (type_name))
+
+ self.expr = copy.deepcopy(te.expr)
+
+ t = self.expr[ len(self.expr) - 1 ]
+ t.const = const
+ if signed:
+ t.signed = 1
+ elif unsigned:
+ t.signed = 0
+
+
+ def set_base_type_node(self, tn):
+ self.expr = [tn]
+ return
+
+
+ def set_elements(self, count):
+ tn = self.expr[0]
+
+ tn.elements = count
+ return
+
+
+ def string(self):
+ s = ""
+ for t in self.expr:
+ s += t.string()
+
+ return s
+
+
+ def get_base_type_node(self):
+ return self.expr[0]
+
+
+ def get_base_name(self):
+ if len(self.expr):
+ return self.expr[0].name
+ else:
+ return None
+
+
+ def get_element_size(self):
+ tn = self.expr[0]
+
+ if tn.elements:
+ return tn.elements * tn.size
+ else:
+ return tn.size
+
+
+ def get_element_count(self):
+ tn = self.expr[0]
+ return tn.elements
+
+
+ def get_stack_size(self):
+ tn = self.expr[ len(self.expr) - 1 ]
+
+ if tn.elements or tn.pointer:
+ return 4
+ elif not tn.integer:
+ return tn.size
+ else:
+ return 4
+
+
+ def is_pointer(self):
+ tn = self.expr[ len(self.expr) - 1 ]
+ return tn.pointer
+
+
+ def format_string(self):
+ tn = self.expr[ len(self.expr) - 1 ]
+ if tn.pointer:
+ return "%p"
+ elif not tn.integer:
+ return "%f"
+ else:
+ return "%d"
+
+
+
+if __name__ == '__main__':
+
+ types_to_try = [ "int", "int *", "const int *", "int * const", "const int * const", \
+ "unsigned * const *", \
+ "float", "const double", "double * const"]
+
+ create_initial_types()
+
+ for t in types_to_try:
+ print 'Trying "%s"...' % (t)
+ te = type_expression( t )
+ print 'Got "%s" (%u, %u).' % (te.string(), te.get_stack_size(), te.get_element_size())
diff --git a/nx-X11/extras/Mesa/src/mesa/main/Imakefile b/nx-X11/extras/Mesa/src/mesa/main/Imakefile
new file mode 100644
index 000000000..fe0658c6c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/Imakefile
@@ -0,0 +1,129 @@
+#define DoNormalLib NO
+#define DoSharedLib YES
+#define DoDebugLib NO
+#define DoProfileLib NO
+#define LibName MESAGL
+#define SoRev SOX11REV
+#define LibHeaders NO
+
+#include <Threads.tmpl>
+
+REQUIREDLIBS = $(X11ROOT)\\XFree86\\lib\\ Xext X11
+BUILDLIBDIR = $(TOP)\\lib
+
+INCLUDES = -I$(TOP)\\include
+
+SRCS = \
+accum.c \
+alpha.c \
+alphabuf.c \
+api1.c \
+api2.c \
+attrib.c \
+bitmap.c \
+blend.c \
+bresenhm.c \
+clip.c \
+context.c \
+copypix.c \
+dd.c \
+depth.c \
+draw.c \
+drawpix.c \
+enable.c \
+eval2.c \
+feedback.c \
+fog.c \
+fortran.c \
+get.c \
+hash.c \
+glx.c \
+interp.c \
+light.c \
+lines.c \
+list.c \
+logic.c \
+masking.c \
+misc.c \
+osmesa.c \
+pb.c \
+pixel.c \
+points.c \
+polygons.c \
+readpix.c \
+scissor.c \
+span.c \
+stencil.c \
+svgamesa.c \
+texture.c \
+varray.c \
+vb.c \
+vertex.c \
+xfonts.c \
+xform.c \
+xm_api.c \
+xm_dd.c \
+xm_line.c \
+xm_span.c \
+xm_tri.c
+
+OBJS = \
+accum.o \
+alpha.o \
+alphabuf.o \
+api1.o \
+api2.o \
+attrib.o \
+bitmap.o \
+blend.o \
+bresenhm.o \
+clip.o \
+context.o \
+copypix.o \
+dd.o \
+depth.o \
+draw.o \
+drawpix.o \
+enable.o \
+eval2.o \
+feedback.o \
+fog.o \
+fortran.o \
+get.o \
+hash.o \
+glx.o \
+interp.o \
+light.o \
+lines.o \
+list.o \
+logic.o \
+masking.o \
+misc.o \
+osmesa.o \
+pb.o \
+pixel.o \
+points.o \
+polygons.o \
+readpix.o \
+scissor.o \
+span.o \
+stencil.o \
+svgamesa.o \
+texture.o \
+varray.o \
+vb.o \
+vertex.o \
+xfonts.o \
+xform.o \
+xm_api.o \
+xm_dd.o \
+xm_line.o \
+xm_span.o \
+xm_tri.o
+
+LINTLIBS =
+
+#include <Library.tmpl>
+
+DependTarget()
+
diff --git a/nx-X11/extras/Mesa/src/mesa/main/KNOWN_BUGS b/nx-X11/extras/Mesa/src/mesa/main/KNOWN_BUGS
new file mode 100644
index 000000000..efbb0ca40
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/KNOWN_BUGS
@@ -0,0 +1,21 @@
+
+
+Performance issues with EXT_point_parameters & quake2
+
+
+
+Using glPolygonMode() where the front and back modes aren't the
+same causes poor performance on 3Dfx.
+
+
+
+Broken drivers: some of the Mesa device drivers (such as BeOS, D3D,
+etc) haven't been updated for Mesa 3.3's device driver changes.
+
+
+
+glDrawRangeElements() should use vertex array locking to improve performance
+but trying to do so causes a rendering error. Reported by Scott McMillan.
+Fixed by disabling locking in glDrawRangeElements (varray.c) but that's
+really just hiding a bug in array locking.
+
diff --git a/nx-X11/extras/Mesa/src/mesa/main/Makefile.ugl b/nx-X11/extras/Mesa/src/mesa/main/Makefile.ugl
new file mode 100644
index 000000000..b440e1364
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/Makefile.ugl
@@ -0,0 +1,364 @@
+# Mesa 3-D graphics library
+# Version: 4.1
+#
+# Copyright (C) 2001 Wind River Systems, Inc
+
+# The MIT License
+# 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
+# THE AUTHORS OR COPYRIGHT HOLDERS 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.
+
+# Makefile for core library
+
+# This makefile can moved all objects files in MESA_OBJ for use with
+# ld in windShell or create a library from objects files in their
+# associated .c folder.
+#
+# For an easy inclusion of lib$(CPU)$(TOOL)GL.a in vxworks image, this
+# makefile collects together all .o in an only file
+# (obj$(CPU)$(TOOL)GL.o). This operation is unnecessary for
+# lib$(CPU)$(TOOL)OSMesa.a and lib$(CPU)$(TOOL)UglMesa.a because they
+# already contain only one file.
+#
+##### MACROS #####
+MESA_MAJOR=4
+MESA_MINOR=1
+MESA_TINY=0
+VERSION=$(MESA_MAJOR).$(MESA_MINOR)
+
+GL_MAJOR = 1
+GL_MINOR = 2
+GL_TINY = 0$(MESA_MAJOR)0$(MESA_MINOR)0$(MESA_TINY)
+
+##### RULES #####
+
+include ..\rules.windml
+
+#### GL #####
+
+GL_SOURCES = \
+ api_arrayelt.c \
+ api_loopback.c \
+ api_noop.c \
+ api_validate.c \
+ accum.c \
+ arbprogram.c \
+ attrib.c \
+ blend.c \
+ bufferobj.c \
+ buffers.c \
+ clip.c \
+ colortab.c \
+ context.c \
+ convolve.c \
+ debug.c \
+ depth.c \
+ dispatch.c \
+ dlist.c \
+ drawpix.c \
+ enable.c \
+ enums.c \
+ eval.c \
+ extensions.c \
+ feedback.c \
+ fog.c \
+ get.c \
+ glapi.c \
+ glthread.c \
+ hash.c \
+ hint.c \
+ histogram.c \
+ image.c \
+ imports.c \
+ light.c \
+ lines.c \
+ matrix.c \
+ pixel.c \
+ points.c \
+ polygon.c \
+ rastpos.c \
+ state.c \
+ stencil.c \
+ texcompress.c \
+ texformat.c \
+ teximage.c \
+ texobj.c \
+ texstate.c \
+ texstore.c \
+ texutil.c \
+ varray.c \
+ vtxfmt.c \
+ X86/x86.c \
+ X86/common_x86.c \
+ X86/3dnow.c \
+ X86/sse.c \
+ math/m_debug_clip.c \
+ math/m_debug_norm.c \
+ math/m_debug_vertex.c \
+ math/m_debug_xform.c \
+ math/m_eval.c \
+ math/m_matrix.c \
+ math/m_translate.c \
+ math/m_vector.c \
+ math/m_vertices.c \
+ math/m_xform.c \
+ array_cache/ac_context.c \
+ array_cache/ac_import.c \
+ swrast/s_aaline.c \
+ swrast/s_aatriangle.c \
+ swrast/s_accum.c \
+ swrast/s_alpha.c \
+ swrast/s_alphabuf.c \
+ swrast/s_bitmap.c \
+ swrast/s_blend.c \
+ swrast/s_buffers.c \
+ swrast/s_copypix.c \
+ swrast/s_context.c \
+ swrast/s_depth.c \
+ swrast/s_drawpix.c \
+ swrast/s_feedback.c \
+ swrast/s_fog.c \
+ swrast/s_imaging.c \
+ swrast/s_lines.c \
+ swrast/s_logic.c \
+ swrast/s_masking.c \
+ swrast/s_pixeltex.c \
+ swrast/s_points.c \
+ swrast/s_readpix.c \
+ swrast/s_span.c \
+ swrast/s_stencil.c \
+ swrast/s_texture.c \
+ swrast/s_texstore.c \
+ swrast/s_triangle.c \
+ swrast/s_zoom.c \
+ swrast_setup/ss_context.c \
+ swrast_setup/ss_triangle.c \
+ swrast_setup/ss_vb.c \
+ tnl/t_array_api.c \
+ tnl/t_array_import.c \
+ tnl/t_context.c \
+ tnl/t_eval_api.c \
+ tnl/t_imm_alloc.c \
+ tnl/t_imm_api.c \
+ tnl/t_imm_debug.c \
+ tnl/t_imm_dlist.c \
+ tnl/t_imm_elt.c \
+ tnl/t_imm_eval.c \
+ tnl/t_imm_exec.c \
+ tnl/t_imm_fixup.c \
+ tnl/t_pipeline.c \
+ tnl/t_vb_fog.c \
+ tnl/t_vb_light.c \
+ tnl/t_vb_normals.c \
+ tnl/t_vb_points.c \
+ tnl/t_vb_render.c \
+ tnl/t_vb_texgen.c \
+ tnl/t_vb_texmat.c \
+ tnl/t_vb_vertex.c
+
+GL_OBJECTS = $(GL_SOURCES:.c=.o)
+GL_OBJNAME = $(MESA_LIBDIR)/objMesaGL.o
+
+#### X86 #####
+
+x86_files = \
+ X86/common_x86_asm.S \
+ X86/glapi_x86.S \
+ X86/x86_cliptest.S \
+ X86/x86_vertex.S \
+ X86/x86_xform2.S \
+ X86/x86_xform3.S \
+ X86/x86_xform4.S \
+
+x3dnow_files = \
+ X86/3dnow_normal.S \
+ X86/3dnow_vertex.S \
+ X86/3dnow_xform1.S \
+ X86/3dnow_xform2.S \
+ X86/3dnow_xform3.S \
+ X86/3dnow_xform4.S
+
+sse_files = \
+ X86/sse_normal.S \
+ X86/sse_vertex.S \
+ X86/sse_xform1.S \
+ X86/sse_xform2.S \
+ X86/sse_xform3.S \
+ X86/sse_xform4.S
+
+mmx_files = X86/mmx_blend.S
+
+X86_OBJNAME = $(MESA_LIBDIR)/objMesaX86.o
+
+##### UGL #####
+
+UGL_SOURCES = \
+ windml/ugl_api.c \
+ windml/ugl_dd.c \
+ windml/ugl_span.c \
+ windml/ugl_line.c \
+ windml/ugl_tri.c \
+ windml/tornado/torMesaUGLInit.c
+
+UGL_OBJECTS = $(UGL_SOURCES:.c=.o)
+UGL_OBJNAME = $(MESA_LIBDIR)/objMesaUGL.o
+
+##### OS #####
+
+OS_SOURCES = OSmesa/osmesa.c windml/tornado/torMesaOSInit.c
+OS_OBJECTS = $(OS_SOURCES:.c=.o)
+OS_OBJNAME = $(MESA_LIBDIR)/objMesaOS.o
+
+##### GLUTSHAPES #####
+
+GLUTSHAPES_SOURCES = \
+ windml/ugl_glutshapes.c \
+ windml/tornado/torGLUTShapesInit.c
+
+GLUTSHAPES_OBJECTS = $(GLUTSHAPES_SOURCES:.c=.o)
+GLUTSHAPES_OBJNAME = $(MESA_LIBDIR)/objGLUTShapes.o
+
+SOURCES = $(GL_SOURCES) $(UGL_SOURCES) $(OS_SOURCES) \
+ $(GLUTSHAPES_SOURCES)
+
+##### TARGETS #####
+
+all: depend.$(CPU)$(TOOL) cfgX86 $(X86_OBJNAME) $(GL_OBJNAME)\
+$(UGL_OBJNAME) $(OS_OBJNAME) $(GLUTSHAPES_OBJNAME)
+
+#histogram.o:
+# $(CC) $(CFLAGS) -O1 $(OPTION_OBJECT_ONLY) $(OPTION_OBJECT_NAME)$@ $<
+
+#image.o:
+# $(CC) $(CFLAGS) -O1 $(OPTION_OBJECT_ONLY) $(OPTION_OBJECT_NAME)$@ $<
+
+cfgX86:
+ifdef HAVE_3DNOW
+x3dnow_sources = $(x3dnow_files)
+CFLAGS_3DNOW = -DUSE_3DNOW_ASM
+HAVE_X86 = 1
+endif
+ifdef HAVE_SSE
+sse_sources = $(sse_files)
+CFLAGS_SSE = -DUSE_SSE_ASM
+HAVE_X86 = 1
+endif
+ifdef HAVE_MMX
+mmx_sources = $(mmx_files)
+CFLAGS_MMX = -DUSE_MMX_ASM
+HAVE_X86 = 1
+endif
+ifdef HAVE_X86
+x86_sources = $(x86_files)
+CFLAGS_X86 = -DUSE_X86_ASM
+endif
+X86_SOURCES = $(x86_sources) $(mmx_sources) \
+ $(x3dnow_sources) $(sse_sources)
+X86_OBJECTS = $(X86_SOURCES:.S=.o)
+CFLAGS_USE_X86 = $(CFLAGS_3DNOW) $(CFLAGS_SSE) $(CFLAGS_MMX) $(CFLAGS_X86)
+
+#X86/matypes.h: mtypes.h tnl/t_context.h X86/gen_matypes.c
+# $(CC) -I ./ X86/gen_matypes.c -o X86/gen_matypes
+# ./X86/gen_matypes > X86/matypes.h
+# $(RM) X86/gen_matypes
+# $(RM) X86/gen_matypes.o
+
+# Make the Mesax86 library
+$(X86_OBJNAME): $(X86_OBJECTS)
+ifdef HAVE_X86
+# $(LD) -r $(X86_OBJECTS) -o $(MESA_OBJNAME)
+ $(LD) -r $(X86_OBJECTS) -o $(X86_OBJNAME)
+# $(AR) rus $(MESA_LIBNAME) $(X86_OBJNAME)
+# $(RM) $(X86_OBJNAME)
+endif
+
+# Make the GL library
+$(GL_OBJNAME): $(GL_OBJECTS)
+# $(LD) -r $(GL_OBJECTS) -o $(MESA_OBJNAME)
+ $(LD) -r $(GL_OBJECTS) -o $(GL_OBJNAME)
+# $(AR) rus $(MESA_LIBNAME) $(GL_OBJNAME)
+# $(AR) rus $(VX_LIBNAME) $(GL_OBJNAME)
+# $(RM) $(GL_OBJNAME)
+
+# Make the UGLMesa library
+$(UGL_OBJNAME): $(UGL_OBJECTS)
+# $(LD) -r $(UGL_OBJECTS) -o $(MESA_OBJNAME)
+ $(LD) -r $(UGL_OBJECTS) -o $(UGL_OBJNAME)
+# $(AR) rus $(MESA_LIBNAME) $(UGL_OBJNAME)
+# $(AR) rus $(VX_LIBNAME) $(UGL_OBJNAME)
+# $(RM) $(UGL_OBJNAME)
+
+# Make the OSMesa library
+$(OS_OBJNAME): $(OS_OBJECTS)
+# $(LD) -r $(OS_OBJECTS) -o $(MESA_OBJNAME)
+ $(LD) -r $(OS_OBJECTS) -o $(OS_OBJNAME)
+# $(AR) rus $(MESA_LIBNAME) $(OS_OBJNAME)
+# $(AR) rus $(VX_LIBNAME) $(OS_OBJNAME)
+# $(RM) $(OS_OBJNAME)
+
+# Make the GLUT Shapes library
+$(GLUTSHAPES_OBJNAME): $(GLUTSHAPES_OBJECTS)
+# $(LD) -r $(GLUTSHAPES_OBJECTS) -o $(MESA_OBJNAME)
+ $(LD) -r $(GLUTSHAPES_OBJECTS) -o $(GLUTSHAPES_OBJNAME)
+# $(AR) rus $(MESA_LIBNAME) $(GLUTSHAPES_OBJNAME)
+# $(AR) rus $(VX_LIBNAME) $(GLUTSHAPES_OBJNAME)
+# $(RM) $(GLUTSHAPES_OBJNAME)
+
+depend.$(CPU)$(TOOL):
+ifeq ($(WIND_HOST_TYPE),x86-win32)
+ @ $(RM) $@
+ @ $(ECHO) Creating depend.$(CPU)$(TOOL)
+ifneq ($(SOURCES),)
+ @ for %f in ($(SOURCES)) do \
+ $(CC) -MM $(CFLAGS) %f >>$@
+endif
+else
+Makefile
+ @ $(RM) $@
+ @ $(ECHO) "Creating depend.$(CPU)$(TOOL)"
+ifneq ($(SOURCES),)
+ @ for FILE in $(filter-out $(NODEPENDOBJS), $(SOURCES)); \
+ do \
+ $(CC) -MM $(CFLAGS) $$FILE \
+ | $(TCL) $(BIN_DIR)/depend.tcl $(TGT_DIR) >>$@; \
+ done
+endif
+endif
+
+.PHONY = clean
+
+clean:
+# $(AR) d $(MESA_LIBNAME) $(GL_OBJNAME)
+# $(AR) d $(MESA_LIBNAME) $(UGL_OBJNAME)
+# $(AR) d $(MESA_LIBNAME) $(OS_OBJNAME)
+# $(AR) d $(MESA_LIBNAME) $(GLUTSHAPES_OBJNAME)
+# $(AR) d $(VX_LIBNAME) $(GL_OBJNAME)
+# $(AR) d $(VX_LIBNAME) $(UGL_OBJNAME)
+# $(AR) d $(VX_LIBNAME) $(OS_OBJNAME)
+# $(AR) d $(VX_LIBNAME) $(GLUTSHAPES_OBJNAME)
+ $(RM) $(GL_OBJECTS)
+ $(RM) $(UGL_OBJECTS)
+ $(RM) $(OS_OBJECTS)
+ $(RM) $(GLUTSHAPES_OBJECTS)
+ $(RM) $(GL_OBJNAME)
+ $(RM) $(UGL_OBJNAME)
+ $(RM) $(OS_OBJNAME)
+ $(RM) $(GLUTSHAPES_OBJNAME)
+ $(RM) depend.$(CPU)$(TOOL)
+
+include depend.$(CPU)$(TOOL)
+
diff --git a/nx-X11/extras/Mesa/src/mesa/main/Makefile.win b/nx-X11/extras/Mesa/src/mesa/main/Makefile.win
new file mode 100644
index 000000000..a27f44c11
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/Makefile.win
@@ -0,0 +1,208 @@
+# Makefile for Win32
+#
+# NOTE: the install target may overwrite important files in the system dirs
+# Check first, before making the install target.
+#
+# This builds both the osmesa and Windows drivers.
+#
+
+!include <win32.mak>
+
+TOP = ..
+SUBDIRS = osmesa.dir
+
+CORE_SRCS = \
+ api_loopback.c \
+ api_noop.c \
+ api_validate.c \
+ accum.c \
+ arbprogram.c \
+ attrib.c \
+ blend.c \
+ bufferobj.c \
+ buffers.c \
+ clip.c \
+ colortab.c \
+ context.c \
+ convolve.c \
+ debug.c \
+ depth.c \
+ dispatch.c \
+ dlist.c \
+ drawpix.c \
+ enable.c \
+ enums.c \
+ eval.c \
+ extensions.c \
+ feedback.c \
+ fog.c \
+ get.c \
+ glapi.c \
+ glthread.c \
+ hash.c \
+ hint.c \
+ histogram.c \
+ image.c \
+ imports.c \
+ light.c \
+ lines.c \
+ matrix.c \
+ nvprogram.c \
+ nvfragparse.c \
+ nvvertexec.c \
+ nvvertparse.c \
+ pixel.c \
+ points.c \
+ polygon.c \
+ rastpos.c \
+ state.c \
+ stencil.c \
+ texcompress.c \
+ texcompress_fxt1.c \
+ texcompress_s3tc.c \
+ teximage.c \
+ texformat.c \
+ texobj.c \
+ texstate.c \
+ texstore.c \
+ varray.c \
+ vtxfmt.c \
+# X86\x86.c \
+# X86\common_x86.c \
+# X86\3dnow.c \
+# X86\sse.c \
+ math\m_debug_norm.c \
+ math\m_debug_xform.c \
+ math\m_eval.c \
+ math\m_matrix.c \
+ math\m_translate.c \
+ math\m_vector.c \
+ math\m_xform.c \
+ array_cache\ac_context.c \
+ array_cache\ac_import.c \
+ swrast\s_aaline.c \
+ swrast\s_aatriangle.c \
+ swrast\s_accum.c \
+ swrast\s_alpha.c \
+ swrast\s_alphabuf.c \
+ swrast\s_bitmap.c \
+ swrast\s_blend.c \
+ swrast\s_buffers.c \
+ swrast\s_copypix.c \
+ swrast\s_context.c \
+ swrast\s_depth.c \
+ swrast\s_drawpix.c \
+ swrast\s_feedback.c \
+ swrast\s_fog.c \
+ swrast\s_imaging.c \
+ swrast\s_lines.c \
+ swrast\s_logic.c \
+ swrast\s_masking.c \
+ swrast\s_nvfragprog.c \
+ swrast\s_pixeltex.c \
+ swrast\s_points.c \
+ swrast\s_readpix.c \
+ swrast\s_span.c \
+ swrast\s_stencil.c \
+ swrast\s_texstore.c \
+ swrast\s_texture.c \
+ swrast\s_triangle.c \
+ swrast\s_zoom.c \
+ swrast_setup\ss_context.c \
+ swrast_setup\ss_triangle.c \
+ swrast_setup\ss_vb.c \
+ tnl\t_array_api.c \
+ tnl\t_array_import.c \
+ tnl\t_context.c \
+ tnl\t_eval_api.c \
+ tnl\t_imm_alloc.c \
+ tnl\t_imm_api.c \
+ tnl\t_imm_debug.c \
+ tnl\t_imm_dlist.c \
+ tnl\t_imm_elt.c \
+ tnl\t_imm_eval.c \
+ tnl\t_imm_exec.c \
+ tnl\t_imm_fixup.c \
+ tnl\t_pipeline.c \
+ tnl\t_vb_fog.c \
+ tnl\t_vb_light.c \
+ tnl\t_vb_normals.c \
+ tnl\t_vb_points.c \
+ tnl\t_vb_program.c \
+ tnl\t_vb_render.c \
+ tnl\t_vb_texgen.c \
+ tnl\t_vb_texmat.c \
+ tnl\t_vb_vertex.c
+
+DRIVER_SRCS = \
+ Trace\tr_context.c \
+ Trace\tr_control.c \
+ Trace\tr_error.c \
+ Trace\tr_support.c \
+ Trace\tr_wrapper.c \
+ Trace\tr_write.c \
+ Windows\wgl.c \
+ Windows\wmesa.c
+
+ASM_SRCS =
+
+SRCS = $(CORE_SRCS) $(DRIVER_SRCS)
+
+all : mesadll $(SUBDIRS)
+
+!include "$(TOP)/mesawin32.mak"
+
+mesadll : $(MESADLL)
+
+CFLAGS = $(cvarsdll) $(CFLAGS) -D_OPENGL32_ -DBUILD_GL32 -DNO_PARALLEL -DNO_STEREO
+!IFNDEF NODEBUG
+CFLAGS = $(CFLAGS) -DMESA_DEBUG
+!ENDIF
+LFLAGS = $(dlllflags) $(lcommon) $(LFLAGS)
+
+OBJS = $(ASM_SRCS:.S=.obj) $(CORE_SRCS:.c=.obj) $(DRIVER_SRCS:.c=.obj)
+LIBS = winmm.lib $(guilibsdll)
+
+$(MESADLL) : $(OBJS) mesa.def
+ $(link) $(LFLAGS) -out:$(MESADLL) -def:mesa.def $(OBJS) $(LIBS)
+ @echo "copying Mesa dynamic link library to lib directory..."
+ -copy $(MESADLL) ..\lib
+ @echo "copying Mesa import library to lib directory..."
+ -copy $(MESALIB) ..\lib
+
+$(SUBDIRS) :
+ @echo.
+ @echo Making in $* directory
+ @cd $*
+ @nmake -f Makefile.win -nologo
+ @cd ..
+
+install : $(MESADLL)
+ @echo.
+ @echo "copying Mesa dynamic link library to system directory..."
+ -copy $(MESADLL) $(DLLINSTALL)
+ @echo "copying Mesa header files to include directory..."
+ -copy ..\..\include\GL\gl.h $(INCLUDEINSTALL)
+ -copy ..\..\include\GL\glext.h $(INCLUDEINSTALL)
+ @echo "copying Mesa import library to library directory..."
+ -copy $(MESALIB) $(LIBINSTALL)
+
+clean ::
+ @del /f tnl\*.obj
+ @del /f swrast_setup\*.obj
+ @del /f math\*.obj
+ @del /f array_cache\*.obj
+ @del /f swrast\*.obj
+ @del /f Trace\*.obj
+ @del /f osmesa\*.obj
+ @del /f Windows\*.obj
+
+clobber ::
+ @del /f OSmesa\*.lib
+ @del /f OSmesa\*.exp
+ @del /f OSmesa\*.dll
+
+# override default inference rule with one that writes the object to
+# the same subdir that the c file is in.
+.c.obj :
+ $(cc) $(CFLAGS) -I. $< /Fo$*.obj
diff --git a/nx-X11/extras/Mesa/src/mesa/main/accum.c b/nx-X11/extras/Mesa/src/mesa/main/accum.c
new file mode 100644
index 000000000..2f7375bd3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/accum.c
@@ -0,0 +1,110 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "glheader.h"
+#include "accum.h"
+#include "context.h"
+#include "imports.h"
+#include "macros.h"
+#include "state.h"
+#include "mtypes.h"
+
+
+void GLAPIENTRY
+_mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha )
+{
+ GLfloat tmp[4];
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ tmp[0] = CLAMP( red, -1.0F, 1.0F );
+ tmp[1] = CLAMP( green, -1.0F, 1.0F );
+ tmp[2] = CLAMP( blue, -1.0F, 1.0F );
+ tmp[3] = CLAMP( alpha, -1.0F, 1.0F );
+
+ if (TEST_EQ_4V(tmp, ctx->Accum.ClearColor))
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_ACCUM);
+ COPY_4FV( ctx->Accum.ClearColor, tmp );
+}
+
+
+void GLAPIENTRY
+_mesa_Accum( GLenum op, GLfloat value )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ switch (op) {
+ case GL_ADD:
+ case GL_MULT:
+ case GL_ACCUM:
+ case GL_LOAD:
+ case GL_RETURN:
+ /* OK */
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glAccum(op)");
+ return;
+ }
+
+ if (ctx->DrawBuffer->Visual.haveAccumBuffer == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glAccum(no accum buffer)");
+ return;
+ }
+
+ if (ctx->DrawBuffer != ctx->ReadBuffer) {
+ /* See GLX_SGI_make_current_read or WGL_ARB_make_current_read */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glAccum(different read/draw buffers)");
+ return;
+ }
+
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
+ "glAccum(incomplete framebuffer)");
+ return;
+ }
+
+ if (ctx->RenderMode == GL_RENDER) {
+ GLint x = ctx->DrawBuffer->_Xmin;
+ GLint y = ctx->DrawBuffer->_Ymin;
+ GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+ GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+ ctx->Driver.Accum(ctx, op, value, x, y, width, height);
+ }
+}
+
+
+
+void
+_mesa_init_accum( GLcontext *ctx )
+{
+ /* Accumulate buffer group */
+ ASSIGN_4V( ctx->Accum.ClearColor, 0.0, 0.0, 0.0, 0.0 );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/accum.h b/nx-X11/extras/Mesa/src/mesa/main/accum.h
new file mode 100644
index 000000000..ce92688a5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/accum.h
@@ -0,0 +1,62 @@
+/**
+ * \file accum.h
+ * Accumulation buffer operations.
+ *
+ * \if subset
+ * (No-op)
+ *
+ * \endif
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+
+#ifndef ACCUM_H
+#define ACCUM_H
+
+
+#include "mtypes.h"
+
+#if _HAVE_FULL_GL
+
+extern void GLAPIENTRY
+_mesa_Accum( GLenum op, GLfloat value );
+
+
+extern void GLAPIENTRY
+_mesa_ClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha );
+
+extern void
+_mesa_init_accum( GLcontext *ctx );
+
+#else
+
+/** No-op */
+#define _mesa_init_accum( c ) ((void)0)
+
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/api_arrayelt.c b/nx-X11/extras/Mesa/src/mesa/main/api_arrayelt.c
new file mode 100644
index 000000000..bfba2b657
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/api_arrayelt.c
@@ -0,0 +1,796 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4.1
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/* Author:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "api_arrayelt.h"
+#include "context.h"
+#include "glapi.h"
+#include "imports.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "glapioffsets.h"
+#include "dispatch.h"
+
+typedef void (GLAPIENTRY *array_func)( const void * );
+
+typedef struct {
+ const struct gl_client_array *array;
+ int offset;
+} AEarray;
+
+typedef void (GLAPIENTRY *attrib_func)( GLuint indx, const void *data );
+
+typedef struct {
+ const struct gl_client_array *array;
+ attrib_func func;
+ GLuint index;
+} AEattrib;
+
+typedef struct {
+ AEarray arrays[32];
+ AEattrib attribs[VERT_ATTRIB_MAX + 1];
+ GLuint NewState;
+} AEcontext;
+
+#define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
+
+
+/*
+ * Convert GL_BYTE, GL_UNSIGNED_BYTE, .. GL_DOUBLE into an integer
+ * in the range [0, 7]. Luckily these type tokens are sequentially
+ * numbered in gl.h, except for GL_DOUBLE.
+ */
+#define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
+
+static const int ColorFuncs[2][8] = {
+ {
+ _gloffset_Color3bv,
+ _gloffset_Color3ubv,
+ _gloffset_Color3sv,
+ _gloffset_Color3usv,
+ _gloffset_Color3iv,
+ _gloffset_Color3uiv,
+ _gloffset_Color3fv,
+ _gloffset_Color3dv,
+ },
+ {
+ _gloffset_Color4bv,
+ _gloffset_Color4ubv,
+ _gloffset_Color4sv,
+ _gloffset_Color4usv,
+ _gloffset_Color4iv,
+ _gloffset_Color4uiv,
+ _gloffset_Color4fv,
+ _gloffset_Color4dv,
+ },
+};
+
+static const int VertexFuncs[3][8] = {
+ {
+ -1,
+ -1,
+ _gloffset_Vertex2sv,
+ -1,
+ _gloffset_Vertex2iv,
+ -1,
+ _gloffset_Vertex2fv,
+ _gloffset_Vertex2dv,
+ },
+ {
+ -1,
+ -1,
+ _gloffset_Vertex3sv,
+ -1,
+ _gloffset_Vertex3iv,
+ -1,
+ _gloffset_Vertex3fv,
+ _gloffset_Vertex3dv,
+ },
+ {
+ -1,
+ -1,
+ _gloffset_Vertex4sv,
+ -1,
+ _gloffset_Vertex4iv,
+ -1,
+ _gloffset_Vertex4fv,
+ _gloffset_Vertex4dv,
+ },
+};
+
+static const int IndexFuncs[8] = {
+ -1,
+ _gloffset_Indexubv,
+ _gloffset_Indexsv,
+ -1,
+ _gloffset_Indexiv,
+ -1,
+ _gloffset_Indexfv,
+ _gloffset_Indexdv,
+};
+
+static const int NormalFuncs[8] = {
+ _gloffset_Normal3bv,
+ -1,
+ _gloffset_Normal3sv,
+ -1,
+ _gloffset_Normal3iv,
+ -1,
+ _gloffset_Normal3fv,
+ _gloffset_Normal3dv,
+};
+
+#if defined(IN_DRI_DRIVER)
+static int SecondaryColorFuncs[8];
+static int FogCoordFuncs[8] = {
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ 0,
+ 0,
+};
+#else
+static const int SecondaryColorFuncs[8] = {
+ _gloffset_SecondaryColor3bvEXT,
+ _gloffset_SecondaryColor3ubvEXT,
+ _gloffset_SecondaryColor3svEXT,
+ _gloffset_SecondaryColor3usvEXT,
+ _gloffset_SecondaryColor3ivEXT,
+ _gloffset_SecondaryColor3uivEXT,
+ _gloffset_SecondaryColor3fvEXT,
+ _gloffset_SecondaryColor3dvEXT,
+};
+
+static const int FogCoordFuncs[8] = {
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ -1,
+ _gloffset_FogCoordfvEXT,
+ _gloffset_FogCoorddvEXT
+};
+#endif
+
+/**********************************************************************/
+
+/* GL_BYTE attributes */
+
+static void GLAPIENTRY VertexAttrib1NbvNV(GLuint index, const GLbyte *v)
+{
+ CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0])));
+}
+
+static void GLAPIENTRY VertexAttrib1bvNV(GLuint index, const GLbyte *v)
+{
+ CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
+}
+
+static void GLAPIENTRY VertexAttrib2NbvNV(GLuint index, const GLbyte *v)
+{
+ CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1])));
+}
+
+static void GLAPIENTRY VertexAttrib2bvNV(GLuint index, const GLbyte *v)
+{
+ CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
+}
+
+static void GLAPIENTRY VertexAttrib3NbvNV(GLuint index, const GLbyte *v)
+{
+ CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
+ BYTE_TO_FLOAT(v[1]),
+ BYTE_TO_FLOAT(v[2])));
+}
+
+static void GLAPIENTRY VertexAttrib3bvNV(GLuint index, const GLbyte *v)
+{
+ CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+}
+
+static void GLAPIENTRY VertexAttrib4NbvNV(GLuint index, const GLbyte *v)
+{
+ CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, BYTE_TO_FLOAT(v[0]),
+ BYTE_TO_FLOAT(v[1]),
+ BYTE_TO_FLOAT(v[2]),
+ BYTE_TO_FLOAT(v[3])));
+}
+
+static void GLAPIENTRY VertexAttrib4bvNV(GLuint index, const GLbyte *v)
+{
+ CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+}
+
+/* GL_UNSIGNED_BYTE attributes */
+
+static void GLAPIENTRY VertexAttrib1NubvNV(GLuint index, const GLubyte *v)
+{
+ CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0])));
+}
+
+static void GLAPIENTRY VertexAttrib1ubvNV(GLuint index, const GLubyte *v)
+{
+ CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
+}
+
+static void GLAPIENTRY VertexAttrib2NubvNV(GLuint index, const GLubyte *v)
+{
+ CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
+ UBYTE_TO_FLOAT(v[1])));
+}
+
+static void GLAPIENTRY VertexAttrib2ubvNV(GLuint index, const GLubyte *v)
+{
+ CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
+}
+
+static void GLAPIENTRY VertexAttrib3NubvNV(GLuint index, const GLubyte *v)
+{
+ CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
+ UBYTE_TO_FLOAT(v[1]),
+ UBYTE_TO_FLOAT(v[2])));
+}
+static void GLAPIENTRY VertexAttrib3ubvNV(GLuint index, const GLubyte *v)
+{
+ CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+}
+
+static void GLAPIENTRY VertexAttrib4NubvNV(GLuint index, const GLubyte *v)
+{
+ CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UBYTE_TO_FLOAT(v[0]),
+ UBYTE_TO_FLOAT(v[1]),
+ UBYTE_TO_FLOAT(v[2]),
+ UBYTE_TO_FLOAT(v[3])));
+}
+
+static void GLAPIENTRY VertexAttrib4ubvNV(GLuint index, const GLubyte *v)
+{
+ CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+}
+
+/* GL_SHORT attributes */
+
+static void GLAPIENTRY VertexAttrib1NsvNV(GLuint index, const GLshort *v)
+{
+ CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0])));
+}
+
+static void GLAPIENTRY VertexAttrib1svNV(GLuint index, const GLshort *v)
+{
+ CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
+}
+
+static void GLAPIENTRY VertexAttrib2NsvNV(GLuint index, const GLshort *v)
+{
+ CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
+ SHORT_TO_FLOAT(v[1])));
+}
+
+static void GLAPIENTRY VertexAttrib2svNV(GLuint index, const GLshort *v)
+{
+ CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
+}
+
+static void GLAPIENTRY VertexAttrib3NsvNV(GLuint index, const GLshort *v)
+{
+ CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
+ SHORT_TO_FLOAT(v[1]),
+ SHORT_TO_FLOAT(v[2])));
+}
+
+static void GLAPIENTRY VertexAttrib3svNV(GLuint index, const GLshort *v)
+{
+ CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+}
+
+static void GLAPIENTRY VertexAttrib4NsvNV(GLuint index, const GLshort *v)
+{
+ CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, SHORT_TO_FLOAT(v[0]),
+ SHORT_TO_FLOAT(v[1]),
+ SHORT_TO_FLOAT(v[2]),
+ SHORT_TO_FLOAT(v[3])));
+}
+
+static void GLAPIENTRY VertexAttrib4svNV(GLuint index, const GLshort *v)
+{
+ CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+}
+
+/* GL_UNSIGNED_SHORT attributes */
+
+static void GLAPIENTRY VertexAttrib1NusvNV(GLuint index, const GLushort *v)
+{
+ CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0])));
+}
+
+static void GLAPIENTRY VertexAttrib1usvNV(GLuint index, const GLushort *v)
+{
+ CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
+}
+
+static void GLAPIENTRY VertexAttrib2NusvNV(GLuint index, const GLushort *v)
+{
+ CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
+ USHORT_TO_FLOAT(v[1])));
+}
+
+static void GLAPIENTRY VertexAttrib2usvNV(GLuint index, const GLushort *v)
+{
+ CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
+}
+
+static void GLAPIENTRY VertexAttrib3NusvNV(GLuint index, const GLushort *v)
+{
+ CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
+ USHORT_TO_FLOAT(v[1]),
+ USHORT_TO_FLOAT(v[2])));
+}
+
+static void GLAPIENTRY VertexAttrib3usvNV(GLuint index, const GLushort *v)
+{
+ CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+}
+
+static void GLAPIENTRY VertexAttrib4NusvNV(GLuint index, const GLushort *v)
+{
+ CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, USHORT_TO_FLOAT(v[0]),
+ USHORT_TO_FLOAT(v[1]),
+ USHORT_TO_FLOAT(v[2]),
+ USHORT_TO_FLOAT(v[3])));
+}
+
+static void GLAPIENTRY VertexAttrib4usvNV(GLuint index, const GLushort *v)
+{
+ CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+}
+
+/* GL_INT attributes */
+
+static void GLAPIENTRY VertexAttrib1NivNV(GLuint index, const GLint *v)
+{
+ CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0])));
+}
+
+static void GLAPIENTRY VertexAttrib1ivNV(GLuint index, const GLint *v)
+{
+ CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
+}
+
+static void GLAPIENTRY VertexAttrib2NivNV(GLuint index, const GLint *v)
+{
+ CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
+ INT_TO_FLOAT(v[1])));
+}
+
+static void GLAPIENTRY VertexAttrib2ivNV(GLuint index, const GLint *v)
+{
+ CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
+}
+
+static void GLAPIENTRY VertexAttrib3NivNV(GLuint index, const GLint *v)
+{
+ CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
+ INT_TO_FLOAT(v[1]),
+ INT_TO_FLOAT(v[2])));
+}
+
+static void GLAPIENTRY VertexAttrib3ivNV(GLuint index, const GLint *v)
+{
+ CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+}
+
+static void GLAPIENTRY VertexAttrib4NivNV(GLuint index, const GLint *v)
+{
+ CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, INT_TO_FLOAT(v[0]),
+ INT_TO_FLOAT(v[1]),
+ INT_TO_FLOAT(v[2]),
+ INT_TO_FLOAT(v[3])));
+}
+
+static void GLAPIENTRY VertexAttrib4ivNV(GLuint index, const GLint *v)
+{
+ CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+}
+
+/* GL_UNSIGNED_INT attributes */
+
+static void GLAPIENTRY VertexAttrib1NuivNV(GLuint index, const GLuint *v)
+{
+ CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0])));
+}
+
+static void GLAPIENTRY VertexAttrib1uivNV(GLuint index, const GLuint *v)
+{
+ CALL_VertexAttrib1fNV(GET_DISPATCH(), (index, v[0]));
+}
+
+static void GLAPIENTRY VertexAttrib2NuivNV(GLuint index, const GLuint *v)
+{
+ CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
+ UINT_TO_FLOAT(v[1])));
+}
+
+static void GLAPIENTRY VertexAttrib2uivNV(GLuint index, const GLuint *v)
+{
+ CALL_VertexAttrib2fNV(GET_DISPATCH(), (index, v[0], v[1]));
+}
+
+static void GLAPIENTRY VertexAttrib3NuivNV(GLuint index, const GLuint *v)
+{
+ CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
+ UINT_TO_FLOAT(v[1]),
+ UINT_TO_FLOAT(v[2])));
+}
+
+static void GLAPIENTRY VertexAttrib3uivNV(GLuint index, const GLuint *v)
+{
+ CALL_VertexAttrib3fNV(GET_DISPATCH(), (index, v[0], v[1], v[2]));
+}
+
+static void GLAPIENTRY VertexAttrib4NuivNV(GLuint index, const GLuint *v)
+{
+ CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, UINT_TO_FLOAT(v[0]),
+ UINT_TO_FLOAT(v[1]),
+ UINT_TO_FLOAT(v[2]),
+ UINT_TO_FLOAT(v[3])));
+}
+
+static void GLAPIENTRY VertexAttrib4uivNV(GLuint index, const GLuint *v)
+{
+ CALL_VertexAttrib4fNV(GET_DISPATCH(), (index, v[0], v[1], v[2], v[3]));
+}
+
+/* GL_FLOAT attributes */
+
+static void GLAPIENTRY VertexAttrib1fvNV(GLuint index, const GLfloat *v)
+{
+ CALL_VertexAttrib1fvNV(GET_DISPATCH(), (index, v));
+}
+
+static void GLAPIENTRY VertexAttrib2fvNV(GLuint index, const GLfloat *v)
+{
+ CALL_VertexAttrib2fvNV(GET_DISPATCH(), (index, v));
+}
+
+static void GLAPIENTRY VertexAttrib3fvNV(GLuint index, const GLfloat *v)
+{
+ CALL_VertexAttrib3fvNV(GET_DISPATCH(), (index, v));
+}
+
+static void GLAPIENTRY VertexAttrib4fvNV(GLuint index, const GLfloat *v)
+{
+ CALL_VertexAttrib4fvNV(GET_DISPATCH(), (index, v));
+}
+
+/* GL_DOUBLE attributes */
+
+static void GLAPIENTRY VertexAttrib1dvNV(GLuint index, const GLdouble *v)
+{
+ CALL_VertexAttrib1dvNV(GET_DISPATCH(), (index, v));
+}
+
+static void GLAPIENTRY VertexAttrib2dvNV(GLuint index, const GLdouble *v)
+{
+ CALL_VertexAttrib2dvNV(GET_DISPATCH(), (index, v));
+}
+
+static void GLAPIENTRY VertexAttrib3dvNV(GLuint index, const GLdouble *v)
+{
+ CALL_VertexAttrib3dvNV(GET_DISPATCH(), (index, v));
+}
+
+static void GLAPIENTRY VertexAttrib4dvNV(GLuint index, const GLdouble *v)
+{
+ CALL_VertexAttrib4dvNV(GET_DISPATCH(), (index, v));
+}
+
+
+/*
+ * Array [size][type] of VertexAttrib functions
+ */
+static attrib_func AttribFuncsNV[2][4][8] = {
+ {
+ /* non-normalized */
+ {
+ /* size 1 */
+ (attrib_func) VertexAttrib1bvNV,
+ (attrib_func) VertexAttrib1ubvNV,
+ (attrib_func) VertexAttrib1svNV,
+ (attrib_func) VertexAttrib1usvNV,
+ (attrib_func) VertexAttrib1ivNV,
+ (attrib_func) VertexAttrib1uivNV,
+ (attrib_func) VertexAttrib1fvNV,
+ (attrib_func) VertexAttrib1dvNV
+ },
+ {
+ /* size 2 */
+ (attrib_func) VertexAttrib2bvNV,
+ (attrib_func) VertexAttrib2ubvNV,
+ (attrib_func) VertexAttrib2svNV,
+ (attrib_func) VertexAttrib2usvNV,
+ (attrib_func) VertexAttrib2ivNV,
+ (attrib_func) VertexAttrib2uivNV,
+ (attrib_func) VertexAttrib2fvNV,
+ (attrib_func) VertexAttrib2dvNV
+ },
+ {
+ /* size 3 */
+ (attrib_func) VertexAttrib3bvNV,
+ (attrib_func) VertexAttrib3ubvNV,
+ (attrib_func) VertexAttrib3svNV,
+ (attrib_func) VertexAttrib3usvNV,
+ (attrib_func) VertexAttrib3ivNV,
+ (attrib_func) VertexAttrib3uivNV,
+ (attrib_func) VertexAttrib3fvNV,
+ (attrib_func) VertexAttrib3dvNV
+ },
+ {
+ /* size 4 */
+ (attrib_func) VertexAttrib4bvNV,
+ (attrib_func) VertexAttrib4ubvNV,
+ (attrib_func) VertexAttrib4svNV,
+ (attrib_func) VertexAttrib4usvNV,
+ (attrib_func) VertexAttrib4ivNV,
+ (attrib_func) VertexAttrib4uivNV,
+ (attrib_func) VertexAttrib4fvNV,
+ (attrib_func) VertexAttrib4dvNV
+ }
+ },
+ {
+ /* normalized (except for float/double) */
+ {
+ /* size 1 */
+ (attrib_func) VertexAttrib1NbvNV,
+ (attrib_func) VertexAttrib1NubvNV,
+ (attrib_func) VertexAttrib1NsvNV,
+ (attrib_func) VertexAttrib1NusvNV,
+ (attrib_func) VertexAttrib1NivNV,
+ (attrib_func) VertexAttrib1NuivNV,
+ (attrib_func) VertexAttrib1fvNV,
+ (attrib_func) VertexAttrib1dvNV
+ },
+ {
+ /* size 2 */
+ (attrib_func) VertexAttrib2NbvNV,
+ (attrib_func) VertexAttrib2NubvNV,
+ (attrib_func) VertexAttrib2NsvNV,
+ (attrib_func) VertexAttrib2NusvNV,
+ (attrib_func) VertexAttrib2NivNV,
+ (attrib_func) VertexAttrib2NuivNV,
+ (attrib_func) VertexAttrib2fvNV,
+ (attrib_func) VertexAttrib2dvNV
+ },
+ {
+ /* size 3 */
+ (attrib_func) VertexAttrib3NbvNV,
+ (attrib_func) VertexAttrib3NubvNV,
+ (attrib_func) VertexAttrib3NsvNV,
+ (attrib_func) VertexAttrib3NusvNV,
+ (attrib_func) VertexAttrib3NivNV,
+ (attrib_func) VertexAttrib3NuivNV,
+ (attrib_func) VertexAttrib3fvNV,
+ (attrib_func) VertexAttrib3dvNV
+ },
+ {
+ /* size 4 */
+ (attrib_func) VertexAttrib4NbvNV,
+ (attrib_func) VertexAttrib4NubvNV,
+ (attrib_func) VertexAttrib4NsvNV,
+ (attrib_func) VertexAttrib4NusvNV,
+ (attrib_func) VertexAttrib4NivNV,
+ (attrib_func) VertexAttrib4NuivNV,
+ (attrib_func) VertexAttrib4fvNV,
+ (attrib_func) VertexAttrib4dvNV
+ }
+ }
+};
+
+/**********************************************************************/
+
+
+GLboolean _ae_create_context( GLcontext *ctx )
+{
+ if (ctx->aelt_context)
+ return GL_TRUE;
+
+#if defined(IN_DRI_DRIVER)
+ SecondaryColorFuncs[0] = _gloffset_SecondaryColor3bvEXT;
+ SecondaryColorFuncs[1] = _gloffset_SecondaryColor3ubvEXT;
+ SecondaryColorFuncs[2] = _gloffset_SecondaryColor3svEXT;
+ SecondaryColorFuncs[3] = _gloffset_SecondaryColor3usvEXT;
+ SecondaryColorFuncs[4] = _gloffset_SecondaryColor3ivEXT;
+ SecondaryColorFuncs[5] = _gloffset_SecondaryColor3uivEXT;
+ SecondaryColorFuncs[6] = _gloffset_SecondaryColor3fvEXT;
+ SecondaryColorFuncs[7] = _gloffset_SecondaryColor3dvEXT;
+
+ FogCoordFuncs[6] = _gloffset_FogCoordfvEXT;
+ FogCoordFuncs[7] = _gloffset_FogCoorddvEXT;
+#endif
+
+ ctx->aelt_context = MALLOC( sizeof(AEcontext) );
+ if (!ctx->aelt_context)
+ return GL_FALSE;
+
+ AE_CONTEXT(ctx)->NewState = ~0;
+ return GL_TRUE;
+}
+
+
+void _ae_destroy_context( GLcontext *ctx )
+{
+ if ( AE_CONTEXT( ctx ) ) {
+ FREE( ctx->aelt_context );
+ ctx->aelt_context = NULL;
+ }
+}
+
+
+/**
+ * Make a list of per-vertex functions to call for each glArrayElement call.
+ * These functions access the array data (i.e. glVertex, glColor, glNormal,
+ * etc).
+ * Note: this may be called during display list construction.
+ */
+static void _ae_update_state( GLcontext *ctx )
+{
+ AEcontext *actx = AE_CONTEXT(ctx);
+ AEarray *aa = actx->arrays;
+ AEattrib *at = actx->attribs;
+ GLuint i;
+
+ /* conventional vertex arrays */
+ if (ctx->Array.Index.Enabled) {
+ aa->array = &ctx->Array.Index;
+ aa->offset = IndexFuncs[TYPE_IDX(aa->array->Type)];
+ aa++;
+ }
+ if (ctx->Array.EdgeFlag.Enabled) {
+ aa->array = &ctx->Array.EdgeFlag;
+ aa->offset = _gloffset_EdgeFlagv;
+ aa++;
+ }
+ if (ctx->Array.Normal.Enabled) {
+ aa->array = &ctx->Array.Normal;
+ aa->offset = NormalFuncs[TYPE_IDX(aa->array->Type)];
+ aa++;
+ }
+ if (ctx->Array.Color.Enabled) {
+ aa->array = &ctx->Array.Color;
+ aa->offset = ColorFuncs[aa->array->Size-3][TYPE_IDX(aa->array->Type)];
+ aa++;
+ }
+ if (ctx->Array.SecondaryColor.Enabled) {
+ aa->array = &ctx->Array.SecondaryColor;
+ aa->offset = SecondaryColorFuncs[TYPE_IDX(aa->array->Type)];
+ aa++;
+ }
+ if (ctx->Array.FogCoord.Enabled) {
+ aa->array = &ctx->Array.FogCoord;
+ aa->offset = FogCoordFuncs[TYPE_IDX(aa->array->Type)];
+ aa++;
+ }
+ for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
+ if (ctx->Array.TexCoord[i].Enabled) {
+ /* NOTE: we use generic glVertexAttrib functions here.
+ * If we ever de-alias conventional/generic vertex attribs this
+ * will have to change.
+ */
+ struct gl_client_array *attribArray = &ctx->Array.TexCoord[i];
+ at->array = attribArray;
+ at->func = AttribFuncsNV[at->array->Normalized][at->array->Size-1][TYPE_IDX(at->array->Type)];
+ at->index = VERT_ATTRIB_TEX0 + i;
+ at++;
+ }
+ }
+
+ /* generic vertex attribute arrays */
+ for (i = 1; i < VERT_ATTRIB_MAX; i++) { /* skip zero! */
+ if (ctx->Array.VertexAttrib[i].Enabled) {
+ struct gl_client_array *attribArray = &ctx->Array.VertexAttrib[i];
+ at->array = attribArray;
+ /* Note: we can't grab the _glapi_Dispatch->VertexAttrib1fvNV
+ * function pointer here (for float arrays) since the pointer may
+ * change from one execution of _ae_loopback_array_elt() to
+ * the next. Doing so caused UT to break.
+ */
+ at->func = AttribFuncsNV[at->array->Normalized][at->array->Size-1][TYPE_IDX(at->array->Type)];
+ at->index = i;
+ at++;
+ }
+ }
+
+ /* finally, vertex position */
+ if (ctx->Array.VertexAttrib[0].Enabled) {
+ /* Use glVertex(v) instead of glVertexAttrib(0, v) to be sure it's
+ * issued as the last (proviking) attribute).
+ */
+ aa->array = &ctx->Array.VertexAttrib[0];
+ assert(aa->array->Size >= 2); /* XXX fix someday? */
+ aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
+ aa++;
+ }
+ else if (ctx->Array.Vertex.Enabled) {
+ aa->array = &ctx->Array.Vertex;
+ aa->offset = VertexFuncs[aa->array->Size-2][TYPE_IDX(aa->array->Type)];
+ aa++;
+ }
+
+ ASSERT(at - actx->attribs <= VERT_ATTRIB_MAX);
+ ASSERT(aa - actx->arrays < 32);
+ at->func = NULL; /* terminate the list */
+ aa->offset = -1; /* terminate the list */
+
+ actx->NewState = 0;
+}
+
+
+/**
+ * Called via glArrayElement() and glDrawArrays().
+ * Issue the glNormal, glVertex, glColor, glVertexAttrib, etc functions
+ * for all enabled vertex arrays (for elt-th element).
+ * Note: this may be called during display list construction.
+ */
+void GLAPIENTRY _ae_loopback_array_elt( GLint elt )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ const AEcontext *actx = AE_CONTEXT(ctx);
+ const AEarray *aa;
+ const AEattrib *at;
+ const struct _glapi_table * const disp = GET_DISPATCH();
+
+
+ if (actx->NewState)
+ _ae_update_state( ctx );
+
+ /* generic attributes */
+ for (at = actx->attribs; at->func; at++) {
+ const GLubyte *src
+ = ADD_POINTERS(at->array->BufferObj->Data, at->array->Ptr)
+ + elt * at->array->StrideB;
+ at->func( at->index, src );
+ }
+
+ /* conventional arrays */
+ for (aa = actx->arrays; aa->offset != -1 ; aa++) {
+ const GLubyte *src
+ = ADD_POINTERS(aa->array->BufferObj->Data, aa->array->Ptr)
+ + elt * aa->array->StrideB;
+ CALL_by_offset( disp, (array_func), aa->offset,
+ ((const void *) src) );
+ }
+}
+
+
+void _ae_invalidate_state( GLcontext *ctx, GLuint new_state )
+{
+ AE_CONTEXT(ctx)->NewState |= new_state;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/api_arrayelt.h b/nx-X11/extras/Mesa/src/mesa/main/api_arrayelt.h
new file mode 100644
index 000000000..1c0af9f3e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/api_arrayelt.h
@@ -0,0 +1,37 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef API_ARRAYELT_H
+#define API_ARRAYELT_H
+
+#include "mtypes.h"
+
+extern GLboolean _ae_create_context( GLcontext *ctx );
+extern void _ae_destroy_context( GLcontext *ctx );
+extern void _ae_invalidate_state( GLcontext *ctx, GLuint new_state );
+extern void GLAPIENTRY _ae_loopback_array_elt( GLint elt );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/api_eval.h b/nx-X11/extras/Mesa/src/mesa/main/api_eval.h
new file mode 100644
index 000000000..d6cb38c9f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/api_eval.h
@@ -0,0 +1,42 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef API_EVAL_H
+#define API_EVAL_H
+
+#include "mtypes.h"
+
+extern void _mesa_EvalPoint1( GLint i );
+extern void _mesa_EvalPoint2( GLint i, GLint j );
+extern void _mesa_EvalCoord1f( GLfloat u );
+extern void _mesa_EvalCoord2f( GLfloat u, GLfloat v );
+extern void _mesa_EvalCoord1fv( const GLfloat *u );
+extern void _mesa_EvalCoord2fv( const GLfloat *u );
+
+#endif
+
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/main/api_loopback.c b/nx-X11/extras/Mesa/src/mesa/main/api_loopback.c
new file mode 100644
index 000000000..db30059e6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/api_loopback.c
@@ -0,0 +1,1647 @@
+/**
+ * \file api_loopback.c
+ *
+ * \author Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+#include "glheader.h"
+#include "glapi.h"
+#include "glapitable.h"
+#include "macros.h"
+#include "colormac.h"
+#include "api_loopback.h"
+#include "glthread.h"
+#include "mtypes.h"
+#include "dispatch.h"
+
+/* KW: A set of functions to convert unusual Color/Normal/Vertex/etc
+ * calls to a smaller set of driver-provided formats. Currently just
+ * go back to dispatch to find these (eg. call glNormal3f directly),
+ * hence 'loopback'.
+ *
+ * The driver must supply all of the remaining entry points, which are
+ * listed in dd.h. The easiest way for a driver to do this is to
+ * install the supplied software t&l module.
+ */
+#define COLORF(r,g,b,a) CALL_Color4f(GET_DISPATCH(), (r,g,b,a))
+#define VERTEX2(x,y) CALL_Vertex2f(GET_DISPATCH(), (x,y))
+#define VERTEX3(x,y,z) CALL_Vertex3f(GET_DISPATCH(), (x,y,z))
+#define VERTEX4(x,y,z,w) CALL_Vertex4f(GET_DISPATCH(), (x,y,z,w))
+#define NORMAL(x,y,z) CALL_Normal3f(GET_DISPATCH(), (x,y,z))
+#define TEXCOORD1(s) CALL_TexCoord1f(GET_DISPATCH(), (s))
+#define TEXCOORD2(s,t) CALL_TexCoord2f(GET_DISPATCH(), (s,t))
+#define TEXCOORD3(s,t,u) CALL_TexCoord3f(GET_DISPATCH(), (s,t,u))
+#define TEXCOORD4(s,t,u,v) CALL_TexCoord4f(GET_DISPATCH(), (s,t,u,v))
+#define INDEX(c) CALL_Indexf(GET_DISPATCH(), (c))
+#define MULTI_TEXCOORD1(z,s) CALL_MultiTexCoord1fARB(GET_DISPATCH(), (z,s))
+#define MULTI_TEXCOORD2(z,s,t) CALL_MultiTexCoord2fARB(GET_DISPATCH(), (z,s,t))
+#define MULTI_TEXCOORD3(z,s,t,u) CALL_MultiTexCoord3fARB(GET_DISPATCH(), (z,s,t,u))
+#define MULTI_TEXCOORD4(z,s,t,u,v) CALL_MultiTexCoord4fARB(GET_DISPATCH(), (z,s,t,u,v))
+#define EVALCOORD1(x) CALL_EvalCoord1f(GET_DISPATCH(), (x))
+#define EVALCOORD2(x,y) CALL_EvalCoord2f(GET_DISPATCH(), (x,y))
+#define MATERIALFV(a,b,c) CALL_Materialfv(GET_DISPATCH(), (a,b,c))
+#define RECTF(a,b,c,d) CALL_Rectf(GET_DISPATCH(), (a,b,c,d))
+
+#define ATTRIB1NV(index,x) CALL_VertexAttrib1fNV(GET_DISPATCH(), (index,x))
+#define ATTRIB2NV(index,x,y) CALL_VertexAttrib2fNV(GET_DISPATCH(), (index,x,y))
+#define ATTRIB3NV(index,x,y,z) CALL_VertexAttrib3fNV(GET_DISPATCH(), (index,x,y,z))
+#define ATTRIB4NV(index,x,y,z,w) CALL_VertexAttrib4fNV(GET_DISPATCH(), (index,x,y,z,w))
+#define ATTRIB1ARB(index,x) CALL_VertexAttrib1fARB(GET_DISPATCH(), (index,x))
+#define ATTRIB2ARB(index,x,y) CALL_VertexAttrib2fARB(GET_DISPATCH(), (index,x,y))
+#define ATTRIB3ARB(index,x,y,z) CALL_VertexAttrib3fARB(GET_DISPATCH(), (index,x,y,z))
+#define ATTRIB4ARB(index,x,y,z,w) CALL_VertexAttrib4fARB(GET_DISPATCH(), (index,x,y,z,w))
+#define FOGCOORDF(x) CALL_FogCoordfEXT(GET_DISPATCH(), (x))
+#define SECONDARYCOLORF(a,b,c) CALL_SecondaryColor3fEXT(GET_DISPATCH(), (a,b,c))
+
+static void GLAPIENTRY
+loopback_Color3b_f( GLbyte red, GLbyte green, GLbyte blue )
+{
+ COLORF( BYTE_TO_FLOAT(red),
+ BYTE_TO_FLOAT(green),
+ BYTE_TO_FLOAT(blue),
+ 1.0 );
+}
+
+static void GLAPIENTRY
+loopback_Color3d_f( GLdouble red, GLdouble green, GLdouble blue )
+{
+ COLORF( (GLfloat) red, (GLfloat) green, (GLfloat) blue, 1.0 );
+}
+
+static void GLAPIENTRY
+loopback_Color3i_f( GLint red, GLint green, GLint blue )
+{
+ COLORF( INT_TO_FLOAT(red), INT_TO_FLOAT(green),
+ INT_TO_FLOAT(blue), 1.0);
+}
+
+static void GLAPIENTRY
+loopback_Color3s_f( GLshort red, GLshort green, GLshort blue )
+{
+ COLORF( SHORT_TO_FLOAT(red), SHORT_TO_FLOAT(green),
+ SHORT_TO_FLOAT(blue), 1.0);
+}
+
+static void GLAPIENTRY
+loopback_Color3ui_f( GLuint red, GLuint green, GLuint blue )
+{
+ COLORF( UINT_TO_FLOAT(red), UINT_TO_FLOAT(green),
+ UINT_TO_FLOAT(blue), 1.0 );
+}
+
+static void GLAPIENTRY
+loopback_Color3us_f( GLushort red, GLushort green, GLushort blue )
+{
+ COLORF( USHORT_TO_FLOAT(red), USHORT_TO_FLOAT(green),
+ USHORT_TO_FLOAT(blue), 1.0 );
+}
+
+static void GLAPIENTRY
+loopback_Color3ub_f( GLubyte red, GLubyte green, GLubyte blue )
+{
+ COLORF( UBYTE_TO_FLOAT(red), UBYTE_TO_FLOAT(green),
+ UBYTE_TO_FLOAT(blue), 1.0 );
+}
+
+
+static void GLAPIENTRY
+loopback_Color3bv_f( const GLbyte *v )
+{
+ COLORF( BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]),
+ BYTE_TO_FLOAT(v[2]), 1.0 );
+}
+
+static void GLAPIENTRY
+loopback_Color3dv_f( const GLdouble *v )
+{
+ COLORF( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0 );
+}
+
+static void GLAPIENTRY
+loopback_Color3iv_f( const GLint *v )
+{
+ COLORF( INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]),
+ INT_TO_FLOAT(v[2]), INT_TO_FLOAT(v[3]) );
+}
+
+static void GLAPIENTRY
+loopback_Color3sv_f( const GLshort *v )
+{
+ COLORF( SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]),
+ SHORT_TO_FLOAT(v[2]), 1.0 );
+}
+
+static void GLAPIENTRY
+loopback_Color3uiv_f( const GLuint *v )
+{
+ COLORF( UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]),
+ UINT_TO_FLOAT(v[2]), 1.0 );
+}
+
+static void GLAPIENTRY
+loopback_Color3usv_f( const GLushort *v )
+{
+ COLORF( USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]),
+ USHORT_TO_FLOAT(v[2]), 1.0 );
+}
+
+static void GLAPIENTRY
+loopback_Color3ubv_f( const GLubyte *v )
+{
+ COLORF( UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]),
+ UBYTE_TO_FLOAT(v[2]), 1.0 );
+}
+
+
+static void GLAPIENTRY
+loopback_Color4b_f( GLbyte red, GLbyte green, GLbyte blue,
+ GLbyte alpha )
+{
+ COLORF( BYTE_TO_FLOAT(red), BYTE_TO_FLOAT(green),
+ BYTE_TO_FLOAT(blue), BYTE_TO_FLOAT(alpha) );
+}
+
+static void GLAPIENTRY
+loopback_Color4d_f( GLdouble red, GLdouble green, GLdouble blue,
+ GLdouble alpha )
+{
+ COLORF( (GLfloat) red, (GLfloat) green, (GLfloat) blue, (GLfloat) alpha );
+}
+
+static void GLAPIENTRY
+loopback_Color4i_f( GLint red, GLint green, GLint blue, GLint alpha )
+{
+ COLORF( INT_TO_FLOAT(red), INT_TO_FLOAT(green),
+ INT_TO_FLOAT(blue), INT_TO_FLOAT(alpha) );
+}
+
+static void GLAPIENTRY
+loopback_Color4s_f( GLshort red, GLshort green, GLshort blue,
+ GLshort alpha )
+{
+ COLORF( SHORT_TO_FLOAT(red), SHORT_TO_FLOAT(green),
+ SHORT_TO_FLOAT(blue), SHORT_TO_FLOAT(alpha) );
+}
+
+static void GLAPIENTRY
+loopback_Color4ui_f( GLuint red, GLuint green, GLuint blue, GLuint alpha )
+{
+ COLORF( UINT_TO_FLOAT(red), UINT_TO_FLOAT(green),
+ UINT_TO_FLOAT(blue), UINT_TO_FLOAT(alpha) );
+}
+
+static void GLAPIENTRY
+loopback_Color4us_f( GLushort red, GLushort green, GLushort blue, GLushort alpha )
+{
+ COLORF( USHORT_TO_FLOAT(red), USHORT_TO_FLOAT(green),
+ USHORT_TO_FLOAT(blue), USHORT_TO_FLOAT(alpha) );
+}
+
+static void GLAPIENTRY
+loopback_Color4ub_f( GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha )
+{
+ COLORF( UBYTE_TO_FLOAT(red), UBYTE_TO_FLOAT(green),
+ UBYTE_TO_FLOAT(blue), UBYTE_TO_FLOAT(alpha) );
+}
+
+
+static void GLAPIENTRY
+loopback_Color4iv_f( const GLint *v )
+{
+ COLORF( INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]),
+ INT_TO_FLOAT(v[2]), INT_TO_FLOAT(v[3]) );
+}
+
+
+static void GLAPIENTRY
+loopback_Color4bv_f( const GLbyte *v )
+{
+ COLORF( BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]),
+ BYTE_TO_FLOAT(v[2]), BYTE_TO_FLOAT(v[3]) );
+}
+
+static void GLAPIENTRY
+loopback_Color4dv_f( const GLdouble *v )
+{
+ COLORF( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3] );
+}
+
+
+static void GLAPIENTRY
+loopback_Color4sv_f( const GLshort *v)
+{
+ COLORF( SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]),
+ SHORT_TO_FLOAT(v[2]), SHORT_TO_FLOAT(v[3]) );
+}
+
+
+static void GLAPIENTRY
+loopback_Color4uiv_f( const GLuint *v)
+{
+ COLORF( UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]),
+ UINT_TO_FLOAT(v[2]), UINT_TO_FLOAT(v[3]) );
+}
+
+static void GLAPIENTRY
+loopback_Color4usv_f( const GLushort *v)
+{
+ COLORF( USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]),
+ USHORT_TO_FLOAT(v[2]), USHORT_TO_FLOAT(v[3]) );
+}
+
+static void GLAPIENTRY
+loopback_Color4ubv_f( const GLubyte *v)
+{
+ COLORF( UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]),
+ UBYTE_TO_FLOAT(v[2]), UBYTE_TO_FLOAT(v[3]) );
+}
+
+static void GLAPIENTRY
+loopback_FogCoorddEXT( GLdouble d )
+{
+ FOGCOORDF( (GLfloat) d );
+}
+
+static void GLAPIENTRY
+loopback_FogCoorddvEXT( const GLdouble *v )
+{
+ FOGCOORDF( (GLfloat) *v );
+}
+
+
+static void GLAPIENTRY
+loopback_Indexd( GLdouble c )
+{
+ INDEX( (GLfloat) c );
+}
+
+static void GLAPIENTRY
+loopback_Indexi( GLint c )
+{
+ INDEX( (GLfloat) c );
+}
+
+static void GLAPIENTRY
+loopback_Indexs( GLshort c )
+{
+ INDEX( (GLfloat) c );
+}
+
+static void GLAPIENTRY
+loopback_Indexub( GLubyte c )
+{
+ INDEX( (GLfloat) c );
+}
+
+static void GLAPIENTRY
+loopback_Indexdv( const GLdouble *c )
+{
+ INDEX( (GLfloat) *c );
+}
+
+static void GLAPIENTRY
+loopback_Indexiv( const GLint *c )
+{
+ INDEX( (GLfloat) *c );
+}
+
+static void GLAPIENTRY
+loopback_Indexsv( const GLshort *c )
+{
+ INDEX( (GLfloat) *c );
+}
+
+static void GLAPIENTRY
+loopback_Indexubv( const GLubyte *c )
+{
+ INDEX( (GLfloat) *c );
+}
+
+static void GLAPIENTRY
+loopback_Normal3b( GLbyte nx, GLbyte ny, GLbyte nz )
+{
+ NORMAL( BYTE_TO_FLOAT(nx), BYTE_TO_FLOAT(ny), BYTE_TO_FLOAT(nz) );
+}
+
+static void GLAPIENTRY
+loopback_Normal3d( GLdouble nx, GLdouble ny, GLdouble nz )
+{
+ NORMAL((GLfloat) nx, (GLfloat) ny, (GLfloat) nz);
+}
+
+static void GLAPIENTRY
+loopback_Normal3i( GLint nx, GLint ny, GLint nz )
+{
+ NORMAL( INT_TO_FLOAT(nx), INT_TO_FLOAT(ny), INT_TO_FLOAT(nz) );
+}
+
+static void GLAPIENTRY
+loopback_Normal3s( GLshort nx, GLshort ny, GLshort nz )
+{
+ NORMAL( SHORT_TO_FLOAT(nx), SHORT_TO_FLOAT(ny), SHORT_TO_FLOAT(nz) );
+}
+
+static void GLAPIENTRY
+loopback_Normal3bv( const GLbyte *v )
+{
+ NORMAL( BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]), BYTE_TO_FLOAT(v[2]) );
+}
+
+static void GLAPIENTRY
+loopback_Normal3dv( const GLdouble *v )
+{
+ NORMAL( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] );
+}
+
+static void GLAPIENTRY
+loopback_Normal3iv( const GLint *v )
+{
+ NORMAL( INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]), INT_TO_FLOAT(v[2]) );
+}
+
+static void GLAPIENTRY
+loopback_Normal3sv( const GLshort *v )
+{
+ NORMAL( SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]), SHORT_TO_FLOAT(v[2]) );
+}
+
+static void GLAPIENTRY
+loopback_TexCoord1d( GLdouble s )
+{
+ TEXCOORD1((GLfloat) s);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord1i( GLint s )
+{
+ TEXCOORD1((GLfloat) s);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord1s( GLshort s )
+{
+ TEXCOORD1((GLfloat) s);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord2d( GLdouble s, GLdouble t )
+{
+ TEXCOORD2((GLfloat) s,(GLfloat) t);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord2s( GLshort s, GLshort t )
+{
+ TEXCOORD2((GLfloat) s,(GLfloat) t);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord2i( GLint s, GLint t )
+{
+ TEXCOORD2((GLfloat) s,(GLfloat) t);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord3d( GLdouble s, GLdouble t, GLdouble r )
+{
+ TEXCOORD3((GLfloat) s,(GLfloat) t,(GLfloat) r);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord3i( GLint s, GLint t, GLint r )
+{
+ TEXCOORD3((GLfloat) s,(GLfloat) t,(GLfloat) r);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord3s( GLshort s, GLshort t, GLshort r )
+{
+ TEXCOORD3((GLfloat) s,(GLfloat) t,(GLfloat) r);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q )
+{
+ TEXCOORD4((GLfloat) s,(GLfloat) t,(GLfloat) r,(GLfloat) q);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord4i( GLint s, GLint t, GLint r, GLint q )
+{
+ TEXCOORD4((GLfloat) s,(GLfloat) t,(GLfloat) r,(GLfloat) q);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q )
+{
+ TEXCOORD4((GLfloat) s,(GLfloat) t,(GLfloat) r,(GLfloat) q);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord1dv( const GLdouble *v )
+{
+ TEXCOORD1((GLfloat) v[0]);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord1iv( const GLint *v )
+{
+ TEXCOORD1((GLfloat) v[0]);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord1sv( const GLshort *v )
+{
+ TEXCOORD1((GLfloat) v[0]);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord2dv( const GLdouble *v )
+{
+ TEXCOORD2((GLfloat) v[0],(GLfloat) v[1]);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord2iv( const GLint *v )
+{
+ TEXCOORD2((GLfloat) v[0],(GLfloat) v[1]);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord2sv( const GLshort *v )
+{
+ TEXCOORD2((GLfloat) v[0],(GLfloat) v[1]);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord3dv( const GLdouble *v )
+{
+ TEXCOORD2((GLfloat) v[0],(GLfloat) v[1]);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord3iv( const GLint *v )
+{
+ TEXCOORD3((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2]);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord3sv( const GLshort *v )
+{
+ TEXCOORD3((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2]);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord4dv( const GLdouble *v )
+{
+ TEXCOORD4((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2],(GLfloat) v[3]);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord4iv( const GLint *v )
+{
+ TEXCOORD4((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2],(GLfloat) v[3]);
+}
+
+static void GLAPIENTRY
+loopback_TexCoord4sv( const GLshort *v )
+{
+ TEXCOORD4((GLfloat) v[0],(GLfloat) v[1],(GLfloat) v[2],(GLfloat) v[3]);
+}
+
+static void GLAPIENTRY
+loopback_Vertex2d( GLdouble x, GLdouble y )
+{
+ VERTEX2( (GLfloat) x, (GLfloat) y );
+}
+
+static void GLAPIENTRY
+loopback_Vertex2i( GLint x, GLint y )
+{
+ VERTEX2( (GLfloat) x, (GLfloat) y );
+}
+
+static void GLAPIENTRY
+loopback_Vertex2s( GLshort x, GLshort y )
+{
+ VERTEX2( (GLfloat) x, (GLfloat) y );
+}
+
+static void GLAPIENTRY
+loopback_Vertex3d( GLdouble x, GLdouble y, GLdouble z )
+{
+ VERTEX3( (GLfloat) x, (GLfloat) y, (GLfloat) z );
+}
+
+static void GLAPIENTRY
+loopback_Vertex3i( GLint x, GLint y, GLint z )
+{
+ VERTEX3( (GLfloat) x, (GLfloat) y, (GLfloat) z );
+}
+
+static void GLAPIENTRY
+loopback_Vertex3s( GLshort x, GLshort y, GLshort z )
+{
+ VERTEX3( (GLfloat) x, (GLfloat) y, (GLfloat) z );
+}
+
+static void GLAPIENTRY
+loopback_Vertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w )
+{
+ VERTEX4( (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w );
+}
+
+static void GLAPIENTRY
+loopback_Vertex4i( GLint x, GLint y, GLint z, GLint w )
+{
+ VERTEX4( (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w );
+}
+
+static void GLAPIENTRY
+loopback_Vertex4s( GLshort x, GLshort y, GLshort z, GLshort w )
+{
+ VERTEX4( (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w );
+}
+
+static void GLAPIENTRY
+loopback_Vertex2dv( const GLdouble *v )
+{
+ VERTEX2( (GLfloat) v[0], (GLfloat) v[1] );
+}
+
+static void GLAPIENTRY
+loopback_Vertex2iv( const GLint *v )
+{
+ VERTEX2( (GLfloat) v[0], (GLfloat) v[1] );
+}
+
+static void GLAPIENTRY
+loopback_Vertex2sv( const GLshort *v )
+{
+ VERTEX2( (GLfloat) v[0], (GLfloat) v[1] );
+}
+
+static void GLAPIENTRY
+loopback_Vertex3dv( const GLdouble *v )
+{
+ VERTEX3( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] );
+}
+
+static void GLAPIENTRY
+loopback_Vertex3iv( const GLint *v )
+{
+ VERTEX3( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] );
+}
+
+static void GLAPIENTRY
+loopback_Vertex3sv( const GLshort *v )
+{
+ VERTEX3( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] );
+}
+
+static void GLAPIENTRY
+loopback_Vertex4dv( const GLdouble *v )
+{
+ VERTEX4( (GLfloat) v[0], (GLfloat) v[1],
+ (GLfloat) v[2], (GLfloat) v[3] );
+}
+
+static void GLAPIENTRY
+loopback_Vertex4iv( const GLint *v )
+{
+ VERTEX4( (GLfloat) v[0], (GLfloat) v[1],
+ (GLfloat) v[2], (GLfloat) v[3] );
+}
+
+static void GLAPIENTRY
+loopback_Vertex4sv( const GLshort *v )
+{
+ VERTEX4( (GLfloat) v[0], (GLfloat) v[1],
+ (GLfloat) v[2], (GLfloat) v[3] );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord1dARB(GLenum target, GLdouble s)
+{
+ MULTI_TEXCOORD1( target, (GLfloat) s );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord1dvARB(GLenum target, const GLdouble *v)
+{
+ MULTI_TEXCOORD1( target, (GLfloat) v[0] );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord1iARB(GLenum target, GLint s)
+{
+ MULTI_TEXCOORD1( target, (GLfloat) s );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord1ivARB(GLenum target, const GLint *v)
+{
+ MULTI_TEXCOORD1( target, (GLfloat) v[0] );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord1sARB(GLenum target, GLshort s)
+{
+ MULTI_TEXCOORD1( target, (GLfloat) s );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord1svARB(GLenum target, const GLshort *v)
+{
+ MULTI_TEXCOORD1( target, (GLfloat) v[0] );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t)
+{
+ MULTI_TEXCOORD2( target, (GLfloat) s, (GLfloat) t );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord2dvARB(GLenum target, const GLdouble *v)
+{
+ MULTI_TEXCOORD2( target, (GLfloat) v[0], (GLfloat) v[1] );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord2iARB(GLenum target, GLint s, GLint t)
+{
+ MULTI_TEXCOORD2( target, (GLfloat) s, (GLfloat) t );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord2ivARB(GLenum target, const GLint *v)
+{
+ MULTI_TEXCOORD2( target, (GLfloat) v[0], (GLfloat) v[1] );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord2sARB(GLenum target, GLshort s, GLshort t)
+{
+ MULTI_TEXCOORD2( target, (GLfloat) s, (GLfloat) t );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord2svARB(GLenum target, const GLshort *v)
+{
+ MULTI_TEXCOORD2( target, (GLfloat) v[0], (GLfloat) v[1] );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r)
+{
+ MULTI_TEXCOORD3( target, (GLfloat) s, (GLfloat) t, (GLfloat) r );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord3dvARB(GLenum target, const GLdouble *v)
+{
+ MULTI_TEXCOORD3( target, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r)
+{
+ MULTI_TEXCOORD3( target, (GLfloat) s, (GLfloat) t, (GLfloat) r );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord3ivARB(GLenum target, const GLint *v)
+{
+ MULTI_TEXCOORD3( target, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r)
+{
+ MULTI_TEXCOORD3( target, (GLfloat) s, (GLfloat) t, (GLfloat) r );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord3svARB(GLenum target, const GLshort *v)
+{
+ MULTI_TEXCOORD3( target, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q)
+{
+ MULTI_TEXCOORD4( target, (GLfloat) s, (GLfloat) t,
+ (GLfloat) r, (GLfloat) q );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord4dvARB(GLenum target, const GLdouble *v)
+{
+ MULTI_TEXCOORD4( target, (GLfloat) v[0], (GLfloat) v[1],
+ (GLfloat) v[2], (GLfloat) v[3] );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q)
+{
+ MULTI_TEXCOORD4( target, (GLfloat) s, (GLfloat) t,
+ (GLfloat) r, (GLfloat) q );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord4ivARB(GLenum target, const GLint *v)
+{
+ MULTI_TEXCOORD4( target, (GLfloat) v[0], (GLfloat) v[1],
+ (GLfloat) v[2], (GLfloat) v[3] );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q)
+{
+ MULTI_TEXCOORD4( target, (GLfloat) s, (GLfloat) t,
+ (GLfloat) r, (GLfloat) q );
+}
+
+static void GLAPIENTRY
+loopback_MultiTexCoord4svARB(GLenum target, const GLshort *v)
+{
+ MULTI_TEXCOORD4( target, (GLfloat) v[0], (GLfloat) v[1],
+ (GLfloat) v[2], (GLfloat) v[3] );
+}
+
+static void GLAPIENTRY
+loopback_EvalCoord2dv( const GLdouble *u )
+{
+ EVALCOORD2( (GLfloat) u[0], (GLfloat) u[1] );
+}
+
+static void GLAPIENTRY
+loopback_EvalCoord2fv( const GLfloat *u )
+{
+ EVALCOORD2( u[0], u[1] );
+}
+
+static void GLAPIENTRY
+loopback_EvalCoord2d( GLdouble u, GLdouble v )
+{
+ EVALCOORD2( (GLfloat) u, (GLfloat) v );
+}
+
+static void GLAPIENTRY
+loopback_EvalCoord1dv( const GLdouble *u )
+{
+ EVALCOORD1( (GLfloat) *u );
+}
+
+static void GLAPIENTRY
+loopback_EvalCoord1fv( const GLfloat *u )
+{
+ EVALCOORD1( (GLfloat) *u );
+}
+
+static void GLAPIENTRY
+loopback_EvalCoord1d( GLdouble u )
+{
+ EVALCOORD1( (GLfloat) u );
+}
+
+static void GLAPIENTRY
+loopback_Materialf( GLenum face, GLenum pname, GLfloat param )
+{
+ GLfloat fparam[4];
+ fparam[0] = param;
+ MATERIALFV( face, pname, fparam );
+}
+
+static void GLAPIENTRY
+loopback_Materiali(GLenum face, GLenum pname, GLint param )
+{
+ GLfloat p = (GLfloat) param;
+ MATERIALFV(face, pname, &p);
+}
+
+static void GLAPIENTRY
+loopback_Materialiv(GLenum face, GLenum pname, const GLint *params )
+{
+ GLfloat fparam[4];
+ switch (pname) {
+ case GL_AMBIENT:
+ case GL_DIFFUSE:
+ case GL_SPECULAR:
+ case GL_EMISSION:
+ case GL_AMBIENT_AND_DIFFUSE:
+ fparam[0] = INT_TO_FLOAT( params[0] );
+ fparam[1] = INT_TO_FLOAT( params[1] );
+ fparam[2] = INT_TO_FLOAT( params[2] );
+ fparam[3] = INT_TO_FLOAT( params[3] );
+ break;
+ case GL_SHININESS:
+ fparam[0] = (GLfloat) params[0];
+ break;
+ case GL_COLOR_INDEXES:
+ fparam[0] = (GLfloat) params[0];
+ fparam[1] = (GLfloat) params[1];
+ fparam[2] = (GLfloat) params[2];
+ break;
+ default:
+ ;
+ }
+ MATERIALFV(face, pname, fparam);
+}
+
+
+static void GLAPIENTRY
+loopback_Rectd(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2)
+{
+ RECTF((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2);
+}
+
+static void GLAPIENTRY
+loopback_Rectdv(const GLdouble *v1, const GLdouble *v2)
+{
+ RECTF((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]);
+}
+
+static void GLAPIENTRY
+loopback_Rectfv(const GLfloat *v1, const GLfloat *v2)
+{
+ RECTF(v1[0], v1[1], v2[0], v2[1]);
+}
+
+static void GLAPIENTRY
+loopback_Recti(GLint x1, GLint y1, GLint x2, GLint y2)
+{
+ RECTF((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2);
+}
+
+static void GLAPIENTRY
+loopback_Rectiv(const GLint *v1, const GLint *v2)
+{
+ RECTF((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]);
+}
+
+static void GLAPIENTRY
+loopback_Rects(GLshort x1, GLshort y1, GLshort x2, GLshort y2)
+{
+ RECTF((GLfloat) x1, (GLfloat) y1, (GLfloat) x2, (GLfloat) y2);
+}
+
+static void GLAPIENTRY
+loopback_Rectsv(const GLshort *v1, const GLshort *v2)
+{
+ RECTF((GLfloat) v1[0], (GLfloat) v1[1], (GLfloat) v2[0], (GLfloat) v2[1]);
+}
+
+static void GLAPIENTRY
+loopback_SecondaryColor3bEXT_f( GLbyte red, GLbyte green, GLbyte blue )
+{
+ SECONDARYCOLORF( BYTE_TO_FLOAT(red),
+ BYTE_TO_FLOAT(green),
+ BYTE_TO_FLOAT(blue) );
+}
+
+static void GLAPIENTRY
+loopback_SecondaryColor3dEXT_f( GLdouble red, GLdouble green, GLdouble blue )
+{
+ SECONDARYCOLORF( (GLfloat) red, (GLfloat) green, (GLfloat) blue );
+}
+
+static void GLAPIENTRY
+loopback_SecondaryColor3iEXT_f( GLint red, GLint green, GLint blue )
+{
+ SECONDARYCOLORF( INT_TO_FLOAT(red),
+ INT_TO_FLOAT(green),
+ INT_TO_FLOAT(blue));
+}
+
+static void GLAPIENTRY
+loopback_SecondaryColor3sEXT_f( GLshort red, GLshort green, GLshort blue )
+{
+ SECONDARYCOLORF(SHORT_TO_FLOAT(red),
+ SHORT_TO_FLOAT(green),
+ SHORT_TO_FLOAT(blue));
+}
+
+static void GLAPIENTRY
+loopback_SecondaryColor3uiEXT_f( GLuint red, GLuint green, GLuint blue )
+{
+ SECONDARYCOLORF(UINT_TO_FLOAT(red),
+ UINT_TO_FLOAT(green),
+ UINT_TO_FLOAT(blue));
+}
+
+static void GLAPIENTRY
+loopback_SecondaryColor3usEXT_f( GLushort red, GLushort green, GLushort blue )
+{
+ SECONDARYCOLORF(USHORT_TO_FLOAT(red),
+ USHORT_TO_FLOAT(green),
+ USHORT_TO_FLOAT(blue));
+}
+
+static void GLAPIENTRY
+loopback_SecondaryColor3ubEXT_f( GLubyte red, GLubyte green, GLubyte blue )
+{
+ SECONDARYCOLORF(UBYTE_TO_FLOAT(red),
+ UBYTE_TO_FLOAT(green),
+ UBYTE_TO_FLOAT(blue));
+}
+
+static void GLAPIENTRY
+loopback_SecondaryColor3bvEXT_f( const GLbyte *v )
+{
+ SECONDARYCOLORF(BYTE_TO_FLOAT(v[0]),
+ BYTE_TO_FLOAT(v[1]),
+ BYTE_TO_FLOAT(v[2]));
+}
+
+static void GLAPIENTRY
+loopback_SecondaryColor3dvEXT_f( const GLdouble *v )
+{
+ SECONDARYCOLORF( (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2] );
+}
+static void GLAPIENTRY
+loopback_SecondaryColor3ivEXT_f( const GLint *v )
+{
+ SECONDARYCOLORF(INT_TO_FLOAT(v[0]),
+ INT_TO_FLOAT(v[1]),
+ INT_TO_FLOAT(v[2]));
+}
+
+static void GLAPIENTRY
+loopback_SecondaryColor3svEXT_f( const GLshort *v )
+{
+ SECONDARYCOLORF(SHORT_TO_FLOAT(v[0]),
+ SHORT_TO_FLOAT(v[1]),
+ SHORT_TO_FLOAT(v[2]));
+}
+
+static void GLAPIENTRY
+loopback_SecondaryColor3uivEXT_f( const GLuint *v )
+{
+ SECONDARYCOLORF(UINT_TO_FLOAT(v[0]),
+ UINT_TO_FLOAT(v[1]),
+ UINT_TO_FLOAT(v[2]));
+}
+
+static void GLAPIENTRY
+loopback_SecondaryColor3usvEXT_f( const GLushort *v )
+{
+ SECONDARYCOLORF(USHORT_TO_FLOAT(v[0]),
+ USHORT_TO_FLOAT(v[1]),
+ USHORT_TO_FLOAT(v[2]));
+}
+
+static void GLAPIENTRY
+loopback_SecondaryColor3ubvEXT_f( const GLubyte *v )
+{
+ SECONDARYCOLORF(UBYTE_TO_FLOAT(v[0]),
+ UBYTE_TO_FLOAT(v[1]),
+ UBYTE_TO_FLOAT(v[2]));
+}
+
+
+/*
+ * GL_NV_vertex_program:
+ * Always loop-back to one of the VertexAttrib[1234]f[v]NV functions.
+ */
+
+static void GLAPIENTRY
+loopback_VertexAttrib1sNV(GLuint index, GLshort x)
+{
+ ATTRIB1NV(index, (GLfloat) x);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib1dNV(GLuint index, GLdouble x)
+{
+ ATTRIB1NV(index, (GLfloat) x);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib2sNV(GLuint index, GLshort x, GLshort y)
+{
+ ATTRIB2NV(index, (GLfloat) x, y);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib2dNV(GLuint index, GLdouble x, GLdouble y)
+{
+ ATTRIB2NV(index, (GLfloat) x, (GLfloat) y);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib3sNV(GLuint index, GLshort x, GLshort y, GLshort z)
+{
+ ATTRIB3NV(index, (GLfloat) x, (GLfloat) y, (GLfloat) z);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib3dNV(GLuint index, GLdouble x, GLdouble y, GLdouble z)
+{
+ ATTRIB4NV(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4sNV(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w)
+{
+ ATTRIB4NV(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4dNV(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ ATTRIB4NV(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4ubNV(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w)
+{
+ ATTRIB4NV(index, UBYTE_TO_FLOAT(x), UBYTE_TO_FLOAT(y),
+ UBYTE_TO_FLOAT(z), UBYTE_TO_FLOAT(w));
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib1svNV(GLuint index, const GLshort *v)
+{
+ ATTRIB1NV(index, (GLfloat) v[0]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib1dvNV(GLuint index, const GLdouble *v)
+{
+ ATTRIB1NV(index, (GLfloat) v[0]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib2svNV(GLuint index, const GLshort *v)
+{
+ ATTRIB2NV(index, (GLfloat) v[0], (GLfloat) v[1]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib2dvNV(GLuint index, const GLdouble *v)
+{
+ ATTRIB2NV(index, (GLfloat) v[0], (GLfloat) v[1]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib3svNV(GLuint index, const GLshort *v)
+{
+ ATTRIB3NV(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib3dvNV(GLuint index, const GLdouble *v)
+{
+ ATTRIB3NV(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4svNV(GLuint index, const GLshort *v)
+{
+ ATTRIB4NV(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2],
+ (GLfloat)v[3]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4dvNV(GLuint index, const GLdouble *v)
+{
+ ATTRIB4NV(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4ubvNV(GLuint index, const GLubyte *v)
+{
+ ATTRIB4NV(index, UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]),
+ UBYTE_TO_FLOAT(v[2]), UBYTE_TO_FLOAT(v[3]));
+}
+
+
+static void GLAPIENTRY
+loopback_VertexAttribs1svNV(GLuint index, GLsizei n, const GLshort *v)
+{
+ GLint i;
+ for (i = n - 1; i >= 0; i--)
+ loopback_VertexAttrib1svNV(index + i, v + i);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttribs1fvNV(GLuint index, GLsizei n, const GLfloat *v)
+{
+ GLint i;
+ for (i = n - 1; i >= 0; i--)
+ ATTRIB1NV(index + i, v[i]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttribs1dvNV(GLuint index, GLsizei n, const GLdouble *v)
+{
+ GLint i;
+ for (i = n - 1; i >= 0; i--)
+ loopback_VertexAttrib1dvNV(index + i, v + i);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttribs2svNV(GLuint index, GLsizei n, const GLshort *v)
+{
+ GLint i;
+ for (i = n - 1; i >= 0; i--)
+ loopback_VertexAttrib2svNV(index + i, v + 2 * i);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttribs2fvNV(GLuint index, GLsizei n, const GLfloat *v)
+{
+ GLint i;
+ for (i = n - 1; i >= 0; i--)
+ ATTRIB2NV(index + i, v[2 * i], v[2 * i + 1]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttribs2dvNV(GLuint index, GLsizei n, const GLdouble *v)
+{
+ GLint i;
+ for (i = n - 1; i >= 0; i--)
+ loopback_VertexAttrib2dvNV(index + i, v + 2 * i);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttribs3svNV(GLuint index, GLsizei n, const GLshort *v)
+{
+ GLint i;
+ for (i = n - 1; i >= 0; i--)
+ loopback_VertexAttrib3svNV(index + i, v + 3 * i);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttribs3fvNV(GLuint index, GLsizei n, const GLfloat *v)
+{
+ GLint i;
+ for (i = n - 1; i >= 0; i--)
+ ATTRIB3NV(index + i, v[3 * i], v[3 * i + 1], v[3 * i + 2]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttribs3dvNV(GLuint index, GLsizei n, const GLdouble *v)
+{
+ GLint i;
+ for (i = n - 1; i >= 0; i--)
+ loopback_VertexAttrib3dvNV(index + i, v + 3 * i);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttribs4svNV(GLuint index, GLsizei n, const GLshort *v)
+{
+ GLint i;
+ for (i = n - 1; i >= 0; i--)
+ loopback_VertexAttrib4svNV(index + i, v + 4 * i);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttribs4fvNV(GLuint index, GLsizei n, const GLfloat *v)
+{
+ GLint i;
+ for (i = n - 1; i >= 0; i--)
+ ATTRIB4NV(index + i, v[4 * i], v[4 * i + 1], v[4 * i + 2], v[4 * i + 3]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttribs4dvNV(GLuint index, GLsizei n, const GLdouble *v)
+{
+ GLint i;
+ for (i = n - 1; i >= 0; i--)
+ loopback_VertexAttrib4dvNV(index + i, v + 4 * i);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttribs4ubvNV(GLuint index, GLsizei n, const GLubyte *v)
+{
+ GLint i;
+ for (i = n - 1; i >= 0; i--)
+ loopback_VertexAttrib4ubvNV(index + i, v + 4 * i);
+}
+
+
+/*
+ * GL_ARB_vertex_program
+ * Always loop-back to one of the VertexAttrib[1234]f[v]ARB functions.
+ */
+
+static void GLAPIENTRY
+loopback_VertexAttrib1sARB(GLuint index, GLshort x)
+{
+ ATTRIB1ARB(index, (GLfloat) x);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib1dARB(GLuint index, GLdouble x)
+{
+ ATTRIB1ARB(index, (GLfloat) x);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib2sARB(GLuint index, GLshort x, GLshort y)
+{
+ ATTRIB2ARB(index, (GLfloat) x, y);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib2dARB(GLuint index, GLdouble x, GLdouble y)
+{
+ ATTRIB2ARB(index, (GLfloat) x, (GLfloat) y);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib3sARB(GLuint index, GLshort x, GLshort y, GLshort z)
+{
+ ATTRIB3ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib3dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z)
+{
+ ATTRIB4ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4sARB(GLuint index, GLshort x, GLshort y, GLshort z, GLshort w)
+{
+ ATTRIB4ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4dARB(GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ ATTRIB4ARB(index, (GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib1svARB(GLuint index, const GLshort *v)
+{
+ ATTRIB1ARB(index, (GLfloat) v[0]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib1dvARB(GLuint index, const GLdouble *v)
+{
+ ATTRIB1ARB(index, (GLfloat) v[0]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib2svARB(GLuint index, const GLshort *v)
+{
+ ATTRIB2ARB(index, (GLfloat) v[0], (GLfloat) v[1]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib2dvARB(GLuint index, const GLdouble *v)
+{
+ ATTRIB2ARB(index, (GLfloat) v[0], (GLfloat) v[1]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib3svARB(GLuint index, const GLshort *v)
+{
+ ATTRIB3ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib3dvARB(GLuint index, const GLdouble *v)
+{
+ ATTRIB3ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4svARB(GLuint index, const GLshort *v)
+{
+ ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2],
+ (GLfloat)v[3]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4dvARB(GLuint index, const GLdouble *v)
+{
+ ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4bvARB(GLuint index, const GLbyte * v)
+{
+ ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4ivARB(GLuint index, const GLint * v)
+{
+ ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4ubvARB(GLuint index, const GLubyte * v)
+{
+ ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4usvARB(GLuint index, const GLushort * v)
+{
+ ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4uivARB(GLuint index, const GLuint * v)
+{
+ ATTRIB4ARB(index, (GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], (GLfloat) v[3]);
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4NbvARB(GLuint index, const GLbyte * v)
+{
+ ATTRIB4ARB(index, BYTE_TO_FLOAT(v[0]), BYTE_TO_FLOAT(v[1]),
+ BYTE_TO_FLOAT(v[2]), BYTE_TO_FLOAT(v[3]));
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4NsvARB(GLuint index, const GLshort * v)
+{
+ ATTRIB4ARB(index, SHORT_TO_FLOAT(v[0]), SHORT_TO_FLOAT(v[1]),
+ SHORT_TO_FLOAT(v[2]), SHORT_TO_FLOAT(v[3]));
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4NivARB(GLuint index, const GLint * v)
+{
+ ATTRIB4ARB(index, INT_TO_FLOAT(v[0]), INT_TO_FLOAT(v[1]),
+ INT_TO_FLOAT(v[2]), INT_TO_FLOAT(v[3]));
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4NubARB(GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w)
+{
+ ATTRIB4ARB(index, UBYTE_TO_FLOAT(x), UBYTE_TO_FLOAT(y),
+ UBYTE_TO_FLOAT(z), UBYTE_TO_FLOAT(w));
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4NubvARB(GLuint index, const GLubyte * v)
+{
+ ATTRIB4ARB(index, UBYTE_TO_FLOAT(v[0]), UBYTE_TO_FLOAT(v[1]),
+ UBYTE_TO_FLOAT(v[2]), UBYTE_TO_FLOAT(v[3]));
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4NusvARB(GLuint index, const GLushort * v)
+{
+ ATTRIB4ARB(index, USHORT_TO_FLOAT(v[0]), USHORT_TO_FLOAT(v[1]),
+ USHORT_TO_FLOAT(v[2]), USHORT_TO_FLOAT(v[3]));
+}
+
+static void GLAPIENTRY
+loopback_VertexAttrib4NuivARB(GLuint index, const GLuint * v)
+{
+ ATTRIB4ARB(index, UINT_TO_FLOAT(v[0]), UINT_TO_FLOAT(v[1]),
+ UINT_TO_FLOAT(v[2]), UINT_TO_FLOAT(v[3]));
+}
+
+
+
+
+/*
+ * This code never registers handlers for any of the entry points
+ * listed in vtxfmt.h.
+ */
+void
+_mesa_loopback_init_api_table( struct _glapi_table *dest )
+{
+ SET_Color3b(dest, loopback_Color3b_f);
+ SET_Color3d(dest, loopback_Color3d_f);
+ SET_Color3i(dest, loopback_Color3i_f);
+ SET_Color3s(dest, loopback_Color3s_f);
+ SET_Color3ui(dest, loopback_Color3ui_f);
+ SET_Color3us(dest, loopback_Color3us_f);
+ SET_Color3ub(dest, loopback_Color3ub_f);
+ SET_Color4b(dest, loopback_Color4b_f);
+ SET_Color4d(dest, loopback_Color4d_f);
+ SET_Color4i(dest, loopback_Color4i_f);
+ SET_Color4s(dest, loopback_Color4s_f);
+ SET_Color4ui(dest, loopback_Color4ui_f);
+ SET_Color4us(dest, loopback_Color4us_f);
+ SET_Color4ub(dest, loopback_Color4ub_f);
+ SET_Color3bv(dest, loopback_Color3bv_f);
+ SET_Color3dv(dest, loopback_Color3dv_f);
+ SET_Color3iv(dest, loopback_Color3iv_f);
+ SET_Color3sv(dest, loopback_Color3sv_f);
+ SET_Color3uiv(dest, loopback_Color3uiv_f);
+ SET_Color3usv(dest, loopback_Color3usv_f);
+ SET_Color3ubv(dest, loopback_Color3ubv_f);
+ SET_Color4bv(dest, loopback_Color4bv_f);
+ SET_Color4dv(dest, loopback_Color4dv_f);
+ SET_Color4iv(dest, loopback_Color4iv_f);
+ SET_Color4sv(dest, loopback_Color4sv_f);
+ SET_Color4uiv(dest, loopback_Color4uiv_f);
+ SET_Color4usv(dest, loopback_Color4usv_f);
+ SET_Color4ubv(dest, loopback_Color4ubv_f);
+
+ SET_SecondaryColor3bEXT(dest, loopback_SecondaryColor3bEXT_f);
+ SET_SecondaryColor3dEXT(dest, loopback_SecondaryColor3dEXT_f);
+ SET_SecondaryColor3iEXT(dest, loopback_SecondaryColor3iEXT_f);
+ SET_SecondaryColor3sEXT(dest, loopback_SecondaryColor3sEXT_f);
+ SET_SecondaryColor3uiEXT(dest, loopback_SecondaryColor3uiEXT_f);
+ SET_SecondaryColor3usEXT(dest, loopback_SecondaryColor3usEXT_f);
+ SET_SecondaryColor3ubEXT(dest, loopback_SecondaryColor3ubEXT_f);
+ SET_SecondaryColor3bvEXT(dest, loopback_SecondaryColor3bvEXT_f);
+ SET_SecondaryColor3dvEXT(dest, loopback_SecondaryColor3dvEXT_f);
+ SET_SecondaryColor3ivEXT(dest, loopback_SecondaryColor3ivEXT_f);
+ SET_SecondaryColor3svEXT(dest, loopback_SecondaryColor3svEXT_f);
+ SET_SecondaryColor3uivEXT(dest, loopback_SecondaryColor3uivEXT_f);
+ SET_SecondaryColor3usvEXT(dest, loopback_SecondaryColor3usvEXT_f);
+ SET_SecondaryColor3ubvEXT(dest, loopback_SecondaryColor3ubvEXT_f);
+
+ SET_Indexd(dest, loopback_Indexd);
+ SET_Indexi(dest, loopback_Indexi);
+ SET_Indexs(dest, loopback_Indexs);
+ SET_Indexub(dest, loopback_Indexub);
+ SET_Indexdv(dest, loopback_Indexdv);
+ SET_Indexiv(dest, loopback_Indexiv);
+ SET_Indexsv(dest, loopback_Indexsv);
+ SET_Indexubv(dest, loopback_Indexubv);
+ SET_Normal3b(dest, loopback_Normal3b);
+ SET_Normal3d(dest, loopback_Normal3d);
+ SET_Normal3i(dest, loopback_Normal3i);
+ SET_Normal3s(dest, loopback_Normal3s);
+ SET_Normal3bv(dest, loopback_Normal3bv);
+ SET_Normal3dv(dest, loopback_Normal3dv);
+ SET_Normal3iv(dest, loopback_Normal3iv);
+ SET_Normal3sv(dest, loopback_Normal3sv);
+ SET_TexCoord1d(dest, loopback_TexCoord1d);
+ SET_TexCoord1i(dest, loopback_TexCoord1i);
+ SET_TexCoord1s(dest, loopback_TexCoord1s);
+ SET_TexCoord2d(dest, loopback_TexCoord2d);
+ SET_TexCoord2s(dest, loopback_TexCoord2s);
+ SET_TexCoord2i(dest, loopback_TexCoord2i);
+ SET_TexCoord3d(dest, loopback_TexCoord3d);
+ SET_TexCoord3i(dest, loopback_TexCoord3i);
+ SET_TexCoord3s(dest, loopback_TexCoord3s);
+ SET_TexCoord4d(dest, loopback_TexCoord4d);
+ SET_TexCoord4i(dest, loopback_TexCoord4i);
+ SET_TexCoord4s(dest, loopback_TexCoord4s);
+ SET_TexCoord1dv(dest, loopback_TexCoord1dv);
+ SET_TexCoord1iv(dest, loopback_TexCoord1iv);
+ SET_TexCoord1sv(dest, loopback_TexCoord1sv);
+ SET_TexCoord2dv(dest, loopback_TexCoord2dv);
+ SET_TexCoord2iv(dest, loopback_TexCoord2iv);
+ SET_TexCoord2sv(dest, loopback_TexCoord2sv);
+ SET_TexCoord3dv(dest, loopback_TexCoord3dv);
+ SET_TexCoord3iv(dest, loopback_TexCoord3iv);
+ SET_TexCoord3sv(dest, loopback_TexCoord3sv);
+ SET_TexCoord4dv(dest, loopback_TexCoord4dv);
+ SET_TexCoord4iv(dest, loopback_TexCoord4iv);
+ SET_TexCoord4sv(dest, loopback_TexCoord4sv);
+ SET_Vertex2d(dest, loopback_Vertex2d);
+ SET_Vertex2i(dest, loopback_Vertex2i);
+ SET_Vertex2s(dest, loopback_Vertex2s);
+ SET_Vertex3d(dest, loopback_Vertex3d);
+ SET_Vertex3i(dest, loopback_Vertex3i);
+ SET_Vertex3s(dest, loopback_Vertex3s);
+ SET_Vertex4d(dest, loopback_Vertex4d);
+ SET_Vertex4i(dest, loopback_Vertex4i);
+ SET_Vertex4s(dest, loopback_Vertex4s);
+ SET_Vertex2dv(dest, loopback_Vertex2dv);
+ SET_Vertex2iv(dest, loopback_Vertex2iv);
+ SET_Vertex2sv(dest, loopback_Vertex2sv);
+ SET_Vertex3dv(dest, loopback_Vertex3dv);
+ SET_Vertex3iv(dest, loopback_Vertex3iv);
+ SET_Vertex3sv(dest, loopback_Vertex3sv);
+ SET_Vertex4dv(dest, loopback_Vertex4dv);
+ SET_Vertex4iv(dest, loopback_Vertex4iv);
+ SET_Vertex4sv(dest, loopback_Vertex4sv);
+ SET_MultiTexCoord1dARB(dest, loopback_MultiTexCoord1dARB);
+ SET_MultiTexCoord1dvARB(dest, loopback_MultiTexCoord1dvARB);
+ SET_MultiTexCoord1iARB(dest, loopback_MultiTexCoord1iARB);
+ SET_MultiTexCoord1ivARB(dest, loopback_MultiTexCoord1ivARB);
+ SET_MultiTexCoord1sARB(dest, loopback_MultiTexCoord1sARB);
+ SET_MultiTexCoord1svARB(dest, loopback_MultiTexCoord1svARB);
+ SET_MultiTexCoord2dARB(dest, loopback_MultiTexCoord2dARB);
+ SET_MultiTexCoord2dvARB(dest, loopback_MultiTexCoord2dvARB);
+ SET_MultiTexCoord2iARB(dest, loopback_MultiTexCoord2iARB);
+ SET_MultiTexCoord2ivARB(dest, loopback_MultiTexCoord2ivARB);
+ SET_MultiTexCoord2sARB(dest, loopback_MultiTexCoord2sARB);
+ SET_MultiTexCoord2svARB(dest, loopback_MultiTexCoord2svARB);
+ SET_MultiTexCoord3dARB(dest, loopback_MultiTexCoord3dARB);
+ SET_MultiTexCoord3dvARB(dest, loopback_MultiTexCoord3dvARB);
+ SET_MultiTexCoord3iARB(dest, loopback_MultiTexCoord3iARB);
+ SET_MultiTexCoord3ivARB(dest, loopback_MultiTexCoord3ivARB);
+ SET_MultiTexCoord3sARB(dest, loopback_MultiTexCoord3sARB);
+ SET_MultiTexCoord3svARB(dest, loopback_MultiTexCoord3svARB);
+ SET_MultiTexCoord4dARB(dest, loopback_MultiTexCoord4dARB);
+ SET_MultiTexCoord4dvARB(dest, loopback_MultiTexCoord4dvARB);
+ SET_MultiTexCoord4iARB(dest, loopback_MultiTexCoord4iARB);
+ SET_MultiTexCoord4ivARB(dest, loopback_MultiTexCoord4ivARB);
+ SET_MultiTexCoord4sARB(dest, loopback_MultiTexCoord4sARB);
+ SET_MultiTexCoord4svARB(dest, loopback_MultiTexCoord4svARB);
+ SET_EvalCoord2dv(dest, loopback_EvalCoord2dv);
+ SET_EvalCoord2fv(dest, loopback_EvalCoord2fv);
+ SET_EvalCoord2d(dest, loopback_EvalCoord2d);
+ SET_EvalCoord1dv(dest, loopback_EvalCoord1dv);
+ SET_EvalCoord1fv(dest, loopback_EvalCoord1fv);
+ SET_EvalCoord1d(dest, loopback_EvalCoord1d);
+ SET_Materialf(dest, loopback_Materialf);
+ SET_Materiali(dest, loopback_Materiali);
+ SET_Materialiv(dest, loopback_Materialiv);
+ SET_Rectd(dest, loopback_Rectd);
+ SET_Rectdv(dest, loopback_Rectdv);
+ SET_Rectfv(dest, loopback_Rectfv);
+ SET_Recti(dest, loopback_Recti);
+ SET_Rectiv(dest, loopback_Rectiv);
+ SET_Rects(dest, loopback_Rects);
+ SET_Rectsv(dest, loopback_Rectsv);
+ SET_FogCoorddEXT(dest, loopback_FogCoorddEXT);
+ SET_FogCoorddvEXT(dest, loopback_FogCoorddvEXT);
+
+ SET_VertexAttrib1sNV(dest, loopback_VertexAttrib1sNV);
+ SET_VertexAttrib1dNV(dest, loopback_VertexAttrib1dNV);
+ SET_VertexAttrib2sNV(dest, loopback_VertexAttrib2sNV);
+ SET_VertexAttrib2dNV(dest, loopback_VertexAttrib2dNV);
+ SET_VertexAttrib3sNV(dest, loopback_VertexAttrib3sNV);
+ SET_VertexAttrib3dNV(dest, loopback_VertexAttrib3dNV);
+ SET_VertexAttrib4sNV(dest, loopback_VertexAttrib4sNV);
+ SET_VertexAttrib4dNV(dest, loopback_VertexAttrib4dNV);
+ SET_VertexAttrib4ubNV(dest, loopback_VertexAttrib4ubNV);
+ SET_VertexAttrib1svNV(dest, loopback_VertexAttrib1svNV);
+ SET_VertexAttrib1dvNV(dest, loopback_VertexAttrib1dvNV);
+ SET_VertexAttrib2svNV(dest, loopback_VertexAttrib2svNV);
+ SET_VertexAttrib2dvNV(dest, loopback_VertexAttrib2dvNV);
+ SET_VertexAttrib3svNV(dest, loopback_VertexAttrib3svNV);
+ SET_VertexAttrib3dvNV(dest, loopback_VertexAttrib3dvNV);
+ SET_VertexAttrib4svNV(dest, loopback_VertexAttrib4svNV);
+ SET_VertexAttrib4dvNV(dest, loopback_VertexAttrib4dvNV);
+ SET_VertexAttrib4ubvNV(dest, loopback_VertexAttrib4ubvNV);
+ SET_VertexAttribs1svNV(dest, loopback_VertexAttribs1svNV);
+ SET_VertexAttribs1fvNV(dest, loopback_VertexAttribs1fvNV);
+ SET_VertexAttribs1dvNV(dest, loopback_VertexAttribs1dvNV);
+ SET_VertexAttribs2svNV(dest, loopback_VertexAttribs2svNV);
+ SET_VertexAttribs2fvNV(dest, loopback_VertexAttribs2fvNV);
+ SET_VertexAttribs2dvNV(dest, loopback_VertexAttribs2dvNV);
+ SET_VertexAttribs3svNV(dest, loopback_VertexAttribs3svNV);
+ SET_VertexAttribs3fvNV(dest, loopback_VertexAttribs3fvNV);
+ SET_VertexAttribs3dvNV(dest, loopback_VertexAttribs3dvNV);
+ SET_VertexAttribs4svNV(dest, loopback_VertexAttribs4svNV);
+ SET_VertexAttribs4fvNV(dest, loopback_VertexAttribs4fvNV);
+ SET_VertexAttribs4dvNV(dest, loopback_VertexAttribs4dvNV);
+ SET_VertexAttribs4ubvNV(dest, loopback_VertexAttribs4ubvNV);
+
+ SET_VertexAttrib1sARB(dest, loopback_VertexAttrib1sARB);
+ SET_VertexAttrib1dARB(dest, loopback_VertexAttrib1dARB);
+ SET_VertexAttrib2sARB(dest, loopback_VertexAttrib2sARB);
+ SET_VertexAttrib2dARB(dest, loopback_VertexAttrib2dARB);
+ SET_VertexAttrib3sARB(dest, loopback_VertexAttrib3sARB);
+ SET_VertexAttrib3dARB(dest, loopback_VertexAttrib3dARB);
+ SET_VertexAttrib4sARB(dest, loopback_VertexAttrib4sARB);
+ SET_VertexAttrib4dARB(dest, loopback_VertexAttrib4dARB);
+ SET_VertexAttrib1svARB(dest, loopback_VertexAttrib1svARB);
+ SET_VertexAttrib1dvARB(dest, loopback_VertexAttrib1dvARB);
+ SET_VertexAttrib2svARB(dest, loopback_VertexAttrib2svARB);
+ SET_VertexAttrib2dvARB(dest, loopback_VertexAttrib2dvARB);
+ SET_VertexAttrib3svARB(dest, loopback_VertexAttrib3svARB);
+ SET_VertexAttrib3dvARB(dest, loopback_VertexAttrib3dvARB);
+ SET_VertexAttrib4svARB(dest, loopback_VertexAttrib4svARB);
+ SET_VertexAttrib4dvARB(dest, loopback_VertexAttrib4dvARB);
+ SET_VertexAttrib4NubARB(dest, loopback_VertexAttrib4NubARB);
+ SET_VertexAttrib4NubvARB(dest, loopback_VertexAttrib4NubvARB);
+ SET_VertexAttrib4bvARB(dest, loopback_VertexAttrib4bvARB);
+ SET_VertexAttrib4ivARB(dest, loopback_VertexAttrib4ivARB);
+ SET_VertexAttrib4ubvARB(dest, loopback_VertexAttrib4ubvARB);
+ SET_VertexAttrib4usvARB(dest, loopback_VertexAttrib4usvARB);
+ SET_VertexAttrib4uivARB(dest, loopback_VertexAttrib4uivARB);
+ SET_VertexAttrib4NbvARB(dest, loopback_VertexAttrib4NbvARB);
+ SET_VertexAttrib4NsvARB(dest, loopback_VertexAttrib4NsvARB);
+ SET_VertexAttrib4NivARB(dest, loopback_VertexAttrib4NivARB);
+ SET_VertexAttrib4NusvARB(dest, loopback_VertexAttrib4NusvARB);
+ SET_VertexAttrib4NuivARB(dest, loopback_VertexAttrib4NuivARB);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/api_loopback.h b/nx-X11/extras/Mesa/src/mesa/main/api_loopback.h
new file mode 100644
index 000000000..6f85bbc1d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/api_loopback.h
@@ -0,0 +1,37 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+
+#ifndef API_LOOPBACK_H
+#define API_LOOPBACK_H
+
+#include "glheader.h"
+
+
+struct _glapi_table;
+
+extern void _mesa_loopback_init_api_table( struct _glapi_table *dest );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/api_noop.c b/nx-X11/extras/Mesa/src/mesa/main/api_noop.c
new file mode 100644
index 000000000..f42f166ae
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/api_noop.c
@@ -0,0 +1,964 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "api_noop.h"
+#include "api_validate.h"
+#include "api_arrayelt.h"
+#include "context.h"
+#include "colormac.h"
+#include "light.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "dlist.h"
+#include "dispatch.h"
+
+
+/* In states where certain vertex components are required for t&l or
+ * rasterization, we still need to keep track of the current values.
+ * These functions provide this service by keeping uptodate the
+ * 'ctx->Current' struct for all data elements not included in the
+ * currently enabled hardware vertex.
+ * I.e. these functions would typically be used when outside of glBegin/End.
+ */
+
+
+void GLAPIENTRY _mesa_noop_EdgeFlag( GLboolean b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ctx->Current.EdgeFlag = b;
+}
+
+void GLAPIENTRY _mesa_noop_EdgeFlagv( const GLboolean *b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ctx->Current.EdgeFlag = *b;
+}
+
+void GLAPIENTRY _mesa_noop_Indexf( GLfloat f )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ctx->Current.Index = f;
+}
+
+void GLAPIENTRY _mesa_noop_Indexfv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ctx->Current.Index = *v;
+}
+
+void GLAPIENTRY _mesa_noop_FogCoordfEXT( GLfloat a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_FOG];
+ dest[0] = a;
+ dest[1] = 0.0;
+ dest[2] = 0.0;
+ dest[3] = 1.0;
+}
+
+void GLAPIENTRY _mesa_noop_FogCoordfvEXT( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_FOG];
+ dest[0] = v[0];
+ dest[1] = 0.0;
+ dest[2] = 0.0;
+ dest[3] = 1.0;
+}
+
+void GLAPIENTRY _mesa_noop_Normal3f( GLfloat a, GLfloat b, GLfloat c )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
+ dest[0] = a;
+ dest[1] = b;
+ dest[2] = c;
+ dest[3] = 1.0;
+}
+
+void GLAPIENTRY _mesa_noop_Normal3fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = v[2];
+ dest[3] = 1.0;
+}
+
+void GLAPIENTRY _mesa_noop_Color4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
+ color[0] = a;
+ color[1] = b;
+ color[2] = c;
+ color[3] = d;
+}
+
+void GLAPIENTRY _mesa_noop_Color4fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
+ color[0] = v[0];
+ color[1] = v[1];
+ color[2] = v[2];
+ color[3] = v[3];
+}
+
+void GLAPIENTRY _mesa_noop_Color3f( GLfloat a, GLfloat b, GLfloat c )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
+ color[0] = a;
+ color[1] = b;
+ color[2] = c;
+ color[3] = 1.0;
+}
+
+void GLAPIENTRY _mesa_noop_Color3fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
+ color[0] = v[0];
+ color[1] = v[1];
+ color[2] = v[2];
+ color[3] = 1.0;
+}
+
+void GLAPIENTRY _mesa_noop_MultiTexCoord1fARB( GLenum target, GLfloat a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint unit = target - GL_TEXTURE0_ARB;
+
+ /* unit is unsigned -- cannot be less than zero.
+ */
+ if (unit < MAX_TEXTURE_COORD_UNITS)
+ {
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
+ dest[0] = a;
+ dest[1] = 0;
+ dest[2] = 0;
+ dest[3] = 1;
+ }
+}
+
+void GLAPIENTRY _mesa_noop_MultiTexCoord1fvARB( GLenum target, const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint unit = target - GL_TEXTURE0_ARB;
+
+ /* unit is unsigned -- cannot be less than zero.
+ */
+ if (unit < MAX_TEXTURE_COORD_UNITS)
+ {
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
+ dest[0] = v[0];
+ dest[1] = 0;
+ dest[2] = 0;
+ dest[3] = 1;
+ }
+}
+
+void GLAPIENTRY _mesa_noop_MultiTexCoord2fARB( GLenum target, GLfloat a, GLfloat b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint unit = target - GL_TEXTURE0_ARB;
+
+ /* unit is unsigned -- cannot be less than zero.
+ */
+ if (unit < MAX_TEXTURE_COORD_UNITS)
+ {
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
+ dest[0] = a;
+ dest[1] = b;
+ dest[2] = 0;
+ dest[3] = 1;
+ }
+}
+
+void GLAPIENTRY _mesa_noop_MultiTexCoord2fvARB( GLenum target, const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint unit = target - GL_TEXTURE0_ARB;
+
+ /* unit is unsigned -- cannot be less than zero.
+ */
+ if (unit < MAX_TEXTURE_COORD_UNITS)
+ {
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = 0;
+ dest[3] = 1;
+ }
+}
+
+void GLAPIENTRY _mesa_noop_MultiTexCoord3fARB( GLenum target, GLfloat a, GLfloat b, GLfloat c)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint unit = target - GL_TEXTURE0_ARB;
+
+ /* unit is unsigned -- cannot be less than zero.
+ */
+ if (unit < MAX_TEXTURE_COORD_UNITS)
+ {
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
+ dest[0] = a;
+ dest[1] = b;
+ dest[2] = c;
+ dest[3] = 1;
+ }
+}
+
+void GLAPIENTRY _mesa_noop_MultiTexCoord3fvARB( GLenum target, const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint unit = target - GL_TEXTURE0_ARB;
+
+ /* unit is unsigned -- cannot be less than zero.
+ */
+ if (unit < MAX_TEXTURE_COORD_UNITS)
+ {
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = v[2];
+ dest[3] = 1;
+ }
+}
+
+void GLAPIENTRY _mesa_noop_MultiTexCoord4fARB( GLenum target, GLfloat a, GLfloat b,
+ GLfloat c, GLfloat d )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint unit = target - GL_TEXTURE0_ARB;
+
+ /* unit is unsigned -- cannot be less than zero.
+ */
+ if (unit < MAX_TEXTURE_COORD_UNITS)
+ {
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
+ dest[0] = a;
+ dest[1] = b;
+ dest[2] = c;
+ dest[3] = d;
+ }
+}
+
+void GLAPIENTRY _mesa_noop_MultiTexCoord4fvARB( GLenum target, const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint unit = target - GL_TEXTURE0_ARB;
+
+ /* unit is unsigned -- cannot be less than zero.
+ */
+ if (unit < MAX_TEXTURE_COORD_UNITS)
+ {
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + unit];
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = v[2];
+ dest[3] = v[3];
+ }
+}
+
+void GLAPIENTRY _mesa_noop_SecondaryColor3fEXT( GLfloat a, GLfloat b, GLfloat c )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
+ color[0] = a;
+ color[1] = b;
+ color[2] = c;
+ color[3] = 1.0;
+}
+
+void GLAPIENTRY _mesa_noop_SecondaryColor3fvEXT( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *color = ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
+ color[0] = v[0];
+ color[1] = v[1];
+ color[2] = v[2];
+ color[3] = 1.0;
+}
+
+void GLAPIENTRY _mesa_noop_TexCoord1f( GLfloat a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
+ dest[0] = a;
+ dest[1] = 0;
+ dest[2] = 0;
+ dest[3] = 1;
+}
+
+void GLAPIENTRY _mesa_noop_TexCoord1fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
+ dest[0] = v[0];
+ dest[1] = 0;
+ dest[2] = 0;
+ dest[3] = 1;
+}
+
+void GLAPIENTRY _mesa_noop_TexCoord2f( GLfloat a, GLfloat b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
+ dest[0] = a;
+ dest[1] = b;
+ dest[2] = 0;
+ dest[3] = 1;
+}
+
+void GLAPIENTRY _mesa_noop_TexCoord2fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = 0;
+ dest[3] = 1;
+}
+
+void GLAPIENTRY _mesa_noop_TexCoord3f( GLfloat a, GLfloat b, GLfloat c )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
+ dest[0] = a;
+ dest[1] = b;
+ dest[2] = c;
+ dest[3] = 1;
+}
+
+void GLAPIENTRY _mesa_noop_TexCoord3fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = v[2];
+ dest[3] = 1;
+}
+
+void GLAPIENTRY _mesa_noop_TexCoord4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
+ dest[0] = a;
+ dest[1] = b;
+ dest[2] = c;
+ dest[3] = d;
+}
+
+void GLAPIENTRY _mesa_noop_TexCoord4fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *dest = ctx->Current.Attrib[VERT_ATTRIB_TEX0];
+ dest[0] = v[0];
+ dest[1] = v[1];
+ dest[2] = v[2];
+ dest[3] = v[3];
+}
+
+
+
+void GLAPIENTRY _mesa_noop_VertexAttrib1fNV( GLuint index, GLfloat x )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index < VERT_ATTRIB_MAX) {
+ ASSIGN_4V(ctx->Current.Attrib[index], x, 0, 0, 1);
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib1fNV" );
+}
+
+void GLAPIENTRY _mesa_noop_VertexAttrib1fvNV( GLuint index, const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index < VERT_ATTRIB_MAX) {
+ ASSIGN_4V(ctx->Current.Attrib[index], v[0], 0, 0, 1);
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib1fvNV" );
+}
+
+void GLAPIENTRY _mesa_noop_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index < VERT_ATTRIB_MAX) {
+ ASSIGN_4V(ctx->Current.Attrib[index], x, y, 0, 1);
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib2fNV" );
+}
+
+void GLAPIENTRY _mesa_noop_VertexAttrib2fvNV( GLuint index, const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index < VERT_ATTRIB_MAX) {
+ ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], 0, 1);
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib2fvNV" );
+}
+
+void GLAPIENTRY _mesa_noop_VertexAttrib3fNV( GLuint index, GLfloat x,
+ GLfloat y, GLfloat z )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index < VERT_ATTRIB_MAX) {
+ ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, 1);
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib3fNV" );
+}
+
+void GLAPIENTRY _mesa_noop_VertexAttrib3fvNV( GLuint index, const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index < VERT_ATTRIB_MAX) {
+ ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], 1);
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib3fvNV" );
+}
+
+void GLAPIENTRY _mesa_noop_VertexAttrib4fNV( GLuint index, GLfloat x,
+ GLfloat y, GLfloat z, GLfloat w )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index < VERT_ATTRIB_MAX) {
+ ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, w);
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib4fNV" );
+}
+
+void GLAPIENTRY _mesa_noop_VertexAttrib4fvNV( GLuint index, const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index < VERT_ATTRIB_MAX) {
+ ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], v[3]);
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib4fvNV" );
+}
+
+
+/*
+ * XXX Un-alias attribs here
+ */
+
+void GLAPIENTRY _mesa_noop_VertexAttrib1fARB( GLuint index, GLfloat x )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index < VERT_ATTRIB_MAX) {
+ ASSIGN_4V(ctx->Current.Attrib[index], x, 0, 0, 1);
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib1fARB" );
+}
+
+void GLAPIENTRY _mesa_noop_VertexAttrib1fvARB( GLuint index, const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index < VERT_ATTRIB_MAX) {
+ ASSIGN_4V(ctx->Current.Attrib[index], v[0], 0, 0, 1);
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib1fvARB" );
+}
+
+void GLAPIENTRY _mesa_noop_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index < VERT_ATTRIB_MAX) {
+ ASSIGN_4V(ctx->Current.Attrib[index], x, y, 0, 1);
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib2fARB" );
+}
+
+void GLAPIENTRY _mesa_noop_VertexAttrib2fvARB( GLuint index, const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index < VERT_ATTRIB_MAX) {
+ ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], 0, 1);
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib2fvARB" );
+}
+
+void GLAPIENTRY _mesa_noop_VertexAttrib3fARB( GLuint index, GLfloat x,
+ GLfloat y, GLfloat z )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index < VERT_ATTRIB_MAX) {
+ ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, 1);
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib3fARB" );
+}
+
+void GLAPIENTRY _mesa_noop_VertexAttrib3fvARB( GLuint index, const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index < VERT_ATTRIB_MAX) {
+ ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], 1);
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib3fvARB" );
+}
+
+void GLAPIENTRY _mesa_noop_VertexAttrib4fARB( GLuint index, GLfloat x,
+ GLfloat y, GLfloat z, GLfloat w )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index < VERT_ATTRIB_MAX) {
+ ASSIGN_4V(ctx->Current.Attrib[index], x, y, z, w);
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib4fARB" );
+}
+
+void GLAPIENTRY _mesa_noop_VertexAttrib4fvARB( GLuint index, const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (index < VERT_ATTRIB_MAX) {
+ ASSIGN_4V(ctx->Current.Attrib[index], v[0], v[1], v[2], v[3]);
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib4fvARB" );
+}
+
+
+
+/* Material
+ */
+void GLAPIENTRY _mesa_noop_Materialfv( GLenum face, GLenum pname, const GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i, nr;
+ struct gl_material *mat = &ctx->Light.Material;
+ GLuint bitmask = _mesa_material_bitmask( ctx, face, pname, ~0,
+ "_mesa_noop_Materialfv" );
+
+ if (ctx->Light.ColorMaterialEnabled)
+ bitmask &= ~ctx->Light.ColorMaterialBitmask;
+
+ if (bitmask == 0)
+ return;
+
+ switch (face) {
+ case GL_SHININESS: nr = 1; break;
+ case GL_COLOR_INDEXES: nr = 3; break;
+ default: nr = 4 ; break;
+ }
+
+ for (i = 0 ; i < MAT_ATTRIB_MAX ; i++)
+ if (bitmask & (1<<i))
+ COPY_SZ_4V( mat->Attrib[i], nr, params );
+
+ _mesa_update_material( ctx, bitmask );
+}
+
+/* These really are noops outside begin/end:
+ */
+void GLAPIENTRY _mesa_noop_Vertex2fv( const GLfloat *v )
+{
+ (void) v;
+}
+
+void GLAPIENTRY _mesa_noop_Vertex3fv( const GLfloat *v )
+{
+ (void) v;
+}
+
+void GLAPIENTRY _mesa_noop_Vertex4fv( const GLfloat *v )
+{
+ (void) v;
+}
+
+void GLAPIENTRY _mesa_noop_Vertex2f( GLfloat a, GLfloat b )
+{
+ (void) a; (void) b;
+}
+
+void GLAPIENTRY _mesa_noop_Vertex3f( GLfloat a, GLfloat b, GLfloat c )
+{
+ (void) a; (void) b; (void) c;
+}
+
+void GLAPIENTRY _mesa_noop_Vertex4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d )
+{
+ (void) a; (void) b; (void) c; (void) d;
+}
+
+/* Similarly, these have no effect outside begin/end:
+ */
+void GLAPIENTRY _mesa_noop_EvalCoord1f( GLfloat a )
+{
+ (void) a;
+}
+
+void GLAPIENTRY _mesa_noop_EvalCoord1fv( const GLfloat *v )
+{
+ (void) v;
+}
+
+void GLAPIENTRY _mesa_noop_EvalCoord2f( GLfloat a, GLfloat b )
+{
+ (void) a; (void) b;
+}
+
+void GLAPIENTRY _mesa_noop_EvalCoord2fv( const GLfloat *v )
+{
+ (void) v;
+}
+
+void GLAPIENTRY _mesa_noop_EvalPoint1( GLint a )
+{
+ (void) a;
+}
+
+void GLAPIENTRY _mesa_noop_EvalPoint2( GLint a, GLint b )
+{
+ (void) a; (void) b;
+}
+
+
+/* Begin -- call into driver, should result in the vtxfmt being
+ * swapped out:
+ */
+void GLAPIENTRY _mesa_noop_Begin( GLenum mode )
+{
+ (void) mode;
+}
+
+
+/* End -- just raise an error
+ */
+void GLAPIENTRY _mesa_noop_End( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd" );
+}
+
+
+/* Execute a glRectf() function. This is not suitable for GL_COMPILE
+ * modes (as the test for outside begin/end is not compiled),
+ * but may be useful for drivers in circumstances which exclude
+ * display list interactions.
+ *
+ * (None of the functions in this file are suitable for GL_COMPILE
+ * modes).
+ */
+void GLAPIENTRY _mesa_noop_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
+{
+ {
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+ }
+
+ CALL_Begin(GET_DISPATCH(), (GL_QUADS));
+ CALL_Vertex2f(GET_DISPATCH(), (x1, y1));
+ CALL_Vertex2f(GET_DISPATCH(), (x2, y1));
+ CALL_Vertex2f(GET_DISPATCH(), (x2, y2));
+ CALL_Vertex2f(GET_DISPATCH(), (x1, y2));
+ CALL_End(GET_DISPATCH(), ());
+}
+
+
+/* Some very basic support for arrays. Drivers without explicit array
+ * support can hook these in, but still need to supply an array-elt
+ * implementation.
+ */
+void GLAPIENTRY _mesa_noop_DrawArrays(GLenum mode, GLint start, GLsizei count)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i;
+
+ if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
+ return;
+
+ CALL_Begin(GET_DISPATCH(), (mode));
+ for (i = 0; i < count; i++)
+ CALL_ArrayElement(GET_DISPATCH(), (start + i));
+ CALL_End(GET_DISPATCH(), ());
+}
+
+
+void GLAPIENTRY _mesa_noop_DrawElements(GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i;
+
+ if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices ))
+ return;
+
+ CALL_Begin(GET_DISPATCH(), (mode));
+
+ switch (type) {
+ case GL_UNSIGNED_BYTE:
+ for (i = 0 ; i < count ; i++)
+ CALL_ArrayElement(GET_DISPATCH(), ( ((GLubyte *)indices)[i] ));
+ break;
+ case GL_UNSIGNED_SHORT:
+ for (i = 0 ; i < count ; i++)
+ CALL_ArrayElement(GET_DISPATCH(), ( ((GLushort *)indices)[i] ));
+ break;
+ case GL_UNSIGNED_INT:
+ for (i = 0 ; i < count ; i++)
+ CALL_ArrayElement(GET_DISPATCH(), ( ((GLuint *)indices)[i] ));
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElements(type)" );
+ break;
+ }
+
+ CALL_End(GET_DISPATCH(), ());
+}
+
+void GLAPIENTRY _mesa_noop_DrawRangeElements(GLenum mode,
+ GLuint start, GLuint end,
+ GLsizei count, GLenum type,
+ const GLvoid *indices)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (_mesa_validate_DrawRangeElements( ctx, mode,
+ start, end,
+ count, type, indices ))
+ CALL_DrawElements(GET_DISPATCH(), (mode, count, type, indices));
+}
+
+/*
+ * Eval Mesh
+ */
+
+/* KW: If are compiling, we don't know whether eval will produce a
+ * vertex when it is run in the future. If this is pure immediate
+ * mode, eval is a noop if neither vertex map is enabled.
+ *
+ * Thus we need to have a check in the display list code or
+ * elsewhere for eval(1,2) vertices in the case where
+ * map(1,2)_vertex is disabled, and to purge those vertices from
+ * the vb.
+ */
+void GLAPIENTRY _mesa_noop_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i;
+ GLfloat u, du;
+ GLenum prim;
+
+ switch (mode) {
+ case GL_POINT:
+ prim = GL_POINTS;
+ break;
+ case GL_LINE:
+ prim = GL_LINE_STRIP;
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh1(mode)" );
+ return;
+ }
+
+ /* No effect if vertex maps disabled.
+ */
+ if (!ctx->Eval.Map1Vertex4 &&
+ !ctx->Eval.Map1Vertex3 &&
+ !(ctx->VertexProgram._Enabled && ctx->Eval.Map1Attrib[VERT_ATTRIB_POS]))
+ return;
+
+ du = ctx->Eval.MapGrid1du;
+ u = ctx->Eval.MapGrid1u1 + i1 * du;
+
+ CALL_Begin(GET_DISPATCH(), (prim));
+ for (i=i1;i<=i2;i++,u+=du) {
+ CALL_EvalCoord1f(GET_DISPATCH(), (u));
+ }
+ CALL_End(GET_DISPATCH(), ());
+}
+
+
+
+void GLAPIENTRY _mesa_noop_EvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat u, du, v, dv, v1, u1;
+ GLint i, j;
+
+ switch (mode) {
+ case GL_POINT:
+ case GL_LINE:
+ case GL_FILL:
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" );
+ return;
+ }
+
+ /* No effect if vertex maps disabled.
+ */
+ if (!ctx->Eval.Map2Vertex4 &&
+ !ctx->Eval.Map2Vertex3 &&
+ !(ctx->VertexProgram._Enabled && ctx->Eval.Map2Attrib[VERT_ATTRIB_POS]))
+ return;
+
+ du = ctx->Eval.MapGrid2du;
+ dv = ctx->Eval.MapGrid2dv;
+ v1 = ctx->Eval.MapGrid2v1 + j1 * dv;
+ u1 = ctx->Eval.MapGrid2u1 + i1 * du;
+
+ switch (mode) {
+ case GL_POINT:
+ CALL_Begin(GET_DISPATCH(), (GL_POINTS));
+ for (v=v1,j=j1;j<=j2;j++,v+=dv) {
+ for (u=u1,i=i1;i<=i2;i++,u+=du) {
+ CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
+ }
+ }
+ CALL_End(GET_DISPATCH(), ());
+ break;
+ case GL_LINE:
+ for (v=v1,j=j1;j<=j2;j++,v+=dv) {
+ CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP));
+ for (u=u1,i=i1;i<=i2;i++,u+=du) {
+ CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
+ }
+ CALL_End(GET_DISPATCH(), ());
+ }
+ for (u=u1,i=i1;i<=i2;i++,u+=du) {
+ CALL_Begin(GET_DISPATCH(), (GL_LINE_STRIP));
+ for (v=v1,j=j1;j<=j2;j++,v+=dv) {
+ CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
+ }
+ CALL_End(GET_DISPATCH(), ());
+ }
+ break;
+ case GL_FILL:
+ for (v=v1,j=j1;j<j2;j++,v+=dv) {
+ CALL_Begin(GET_DISPATCH(), (GL_TRIANGLE_STRIP));
+ for (u=u1,i=i1;i<=i2;i++,u+=du) {
+ CALL_EvalCoord2f(GET_DISPATCH(), (u, v));
+ CALL_EvalCoord2f(GET_DISPATCH(), (u, v+dv));
+ }
+ CALL_End(GET_DISPATCH(), ());
+ }
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glEvalMesh2(mode)" );
+ return;
+ }
+}
+
+
+
+/* Build a vertexformat full of things to use outside begin/end pairs.
+ *
+ * TODO -- build a whole dispatch table for this purpose, and likewise
+ * for inside begin/end.
+ */
+void _mesa_noop_vtxfmt_init( GLvertexformat *vfmt )
+{
+ vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */
+ vfmt->Begin = _mesa_noop_Begin;
+ vfmt->CallList = _mesa_CallList;
+ vfmt->CallLists = _mesa_CallLists;
+ vfmt->Color3f = _mesa_noop_Color3f;
+ vfmt->Color3fv = _mesa_noop_Color3fv;
+ vfmt->Color4f = _mesa_noop_Color4f;
+ vfmt->Color4fv = _mesa_noop_Color4fv;
+ vfmt->EdgeFlag = _mesa_noop_EdgeFlag;
+ vfmt->EdgeFlagv = _mesa_noop_EdgeFlagv;
+ vfmt->End = _mesa_noop_End;
+ vfmt->EvalCoord1f = _mesa_noop_EvalCoord1f;
+ vfmt->EvalCoord1fv = _mesa_noop_EvalCoord1fv;
+ vfmt->EvalCoord2f = _mesa_noop_EvalCoord2f;
+ vfmt->EvalCoord2fv = _mesa_noop_EvalCoord2fv;
+ vfmt->EvalPoint1 = _mesa_noop_EvalPoint1;
+ vfmt->EvalPoint2 = _mesa_noop_EvalPoint2;
+ vfmt->FogCoordfEXT = _mesa_noop_FogCoordfEXT;
+ vfmt->FogCoordfvEXT = _mesa_noop_FogCoordfvEXT;
+ vfmt->Indexf = _mesa_noop_Indexf;
+ vfmt->Indexfv = _mesa_noop_Indexfv;
+ vfmt->Materialfv = _mesa_noop_Materialfv;
+ vfmt->MultiTexCoord1fARB = _mesa_noop_MultiTexCoord1fARB;
+ vfmt->MultiTexCoord1fvARB = _mesa_noop_MultiTexCoord1fvARB;
+ vfmt->MultiTexCoord2fARB = _mesa_noop_MultiTexCoord2fARB;
+ vfmt->MultiTexCoord2fvARB = _mesa_noop_MultiTexCoord2fvARB;
+ vfmt->MultiTexCoord3fARB = _mesa_noop_MultiTexCoord3fARB;
+ vfmt->MultiTexCoord3fvARB = _mesa_noop_MultiTexCoord3fvARB;
+ vfmt->MultiTexCoord4fARB = _mesa_noop_MultiTexCoord4fARB;
+ vfmt->MultiTexCoord4fvARB = _mesa_noop_MultiTexCoord4fvARB;
+ vfmt->Normal3f = _mesa_noop_Normal3f;
+ vfmt->Normal3fv = _mesa_noop_Normal3fv;
+ vfmt->SecondaryColor3fEXT = _mesa_noop_SecondaryColor3fEXT;
+ vfmt->SecondaryColor3fvEXT = _mesa_noop_SecondaryColor3fvEXT;
+ vfmt->TexCoord1f = _mesa_noop_TexCoord1f;
+ vfmt->TexCoord1fv = _mesa_noop_TexCoord1fv;
+ vfmt->TexCoord2f = _mesa_noop_TexCoord2f;
+ vfmt->TexCoord2fv = _mesa_noop_TexCoord2fv;
+ vfmt->TexCoord3f = _mesa_noop_TexCoord3f;
+ vfmt->TexCoord3fv = _mesa_noop_TexCoord3fv;
+ vfmt->TexCoord4f = _mesa_noop_TexCoord4f;
+ vfmt->TexCoord4fv = _mesa_noop_TexCoord4fv;
+ vfmt->Vertex2f = _mesa_noop_Vertex2f;
+ vfmt->Vertex2fv = _mesa_noop_Vertex2fv;
+ vfmt->Vertex3f = _mesa_noop_Vertex3f;
+ vfmt->Vertex3fv = _mesa_noop_Vertex3fv;
+ vfmt->Vertex4f = _mesa_noop_Vertex4f;
+ vfmt->Vertex4fv = _mesa_noop_Vertex4fv;
+ vfmt->VertexAttrib1fNV = _mesa_noop_VertexAttrib1fNV;
+ vfmt->VertexAttrib1fvNV = _mesa_noop_VertexAttrib1fvNV;
+ vfmt->VertexAttrib2fNV = _mesa_noop_VertexAttrib2fNV;
+ vfmt->VertexAttrib2fvNV = _mesa_noop_VertexAttrib2fvNV;
+ vfmt->VertexAttrib3fNV = _mesa_noop_VertexAttrib3fNV;
+ vfmt->VertexAttrib3fvNV = _mesa_noop_VertexAttrib3fvNV;
+ vfmt->VertexAttrib4fNV = _mesa_noop_VertexAttrib4fNV;
+ vfmt->VertexAttrib4fvNV = _mesa_noop_VertexAttrib4fvNV;
+ vfmt->VertexAttrib1fARB = _mesa_noop_VertexAttrib1fARB;
+ vfmt->VertexAttrib1fvARB = _mesa_noop_VertexAttrib1fvARB;
+ vfmt->VertexAttrib2fARB = _mesa_noop_VertexAttrib2fARB;
+ vfmt->VertexAttrib2fvARB = _mesa_noop_VertexAttrib2fvARB;
+ vfmt->VertexAttrib3fARB = _mesa_noop_VertexAttrib3fARB;
+ vfmt->VertexAttrib3fvARB = _mesa_noop_VertexAttrib3fvARB;
+ vfmt->VertexAttrib4fARB = _mesa_noop_VertexAttrib4fARB;
+ vfmt->VertexAttrib4fvARB = _mesa_noop_VertexAttrib4fvARB;
+
+ vfmt->Rectf = _mesa_noop_Rectf;
+
+ vfmt->DrawArrays = _mesa_noop_DrawArrays;
+ vfmt->DrawElements = _mesa_noop_DrawElements;
+ vfmt->DrawRangeElements = _mesa_noop_DrawRangeElements;
+ vfmt->EvalMesh1 = _mesa_noop_EvalMesh1;
+ vfmt->EvalMesh2 = _mesa_noop_EvalMesh2;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/api_noop.h b/nx-X11/extras/Mesa/src/mesa/main/api_noop.h
new file mode 100644
index 000000000..56d930e3b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/api_noop.h
@@ -0,0 +1,147 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _API_NOOP_H
+#define _API_NOOP_H
+
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "context.h"
+
+/* In states where certain vertex components are required for t&l or
+ * rasterization, we still need to keep track of the current values.
+ * These functions provide this service by keeping uptodate the
+ * 'ctx->Current' struct for all data elements not included in the
+ * currently enabled hardware vertex.
+ *
+ */
+extern void GLAPIENTRY _mesa_noop_EdgeFlag( GLboolean b );
+extern void GLAPIENTRY _mesa_noop_EdgeFlagv( const GLboolean *b );
+
+extern void GLAPIENTRY _mesa_noop_FogCoordfEXT( GLfloat a );
+extern void GLAPIENTRY _mesa_noop_FogCoordfvEXT( const GLfloat *v );
+
+extern void GLAPIENTRY _mesa_noop_Indexf( GLfloat i );
+extern void GLAPIENTRY _mesa_noop_Indexfv( const GLfloat *v );
+
+extern void GLAPIENTRY _mesa_noop_Normal3f( GLfloat a, GLfloat b, GLfloat c );
+extern void GLAPIENTRY _mesa_noop_Normal3fv( const GLfloat *v );
+
+extern void GLAPIENTRY _mesa_noop_Materialfv( GLenum face, GLenum pname, const GLfloat *param );
+
+extern void _mesa_noop_Color4ub( GLubyte a, GLubyte b, GLubyte c, GLubyte d );
+extern void _mesa_noop_Color4ubv( const GLubyte *v );
+extern void GLAPIENTRY _mesa_noop_Color4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d );
+extern void GLAPIENTRY _mesa_noop_Color4fv( const GLfloat *v );
+extern void _mesa_noop_Color3ub( GLubyte a, GLubyte b, GLubyte c );
+extern void _mesa_noop_Color3ubv( const GLubyte *v );
+extern void GLAPIENTRY _mesa_noop_Color3f( GLfloat a, GLfloat b, GLfloat c );
+extern void GLAPIENTRY _mesa_noop_Color3fv( const GLfloat *v );
+
+extern void GLAPIENTRY _mesa_noop_MultiTexCoord1fARB( GLenum target, GLfloat a );
+extern void GLAPIENTRY _mesa_noop_MultiTexCoord1fvARB( GLenum target, const GLfloat *v );
+extern void GLAPIENTRY _mesa_noop_MultiTexCoord2fARB( GLenum target, GLfloat a, GLfloat b );
+extern void GLAPIENTRY _mesa_noop_MultiTexCoord2fvARB( GLenum target, const GLfloat *v );
+extern void GLAPIENTRY _mesa_noop_MultiTexCoord3fARB( GLenum target, GLfloat a, GLfloat b, GLfloat c);
+extern void GLAPIENTRY _mesa_noop_MultiTexCoord3fvARB( GLenum target, const GLfloat *v );
+extern void GLAPIENTRY _mesa_noop_MultiTexCoord4fARB( GLenum target, GLfloat a, GLfloat b, GLfloat c, GLfloat d );
+extern void GLAPIENTRY _mesa_noop_MultiTexCoord4fvARB( GLenum target, const GLfloat *v );
+
+extern void GLAPIENTRY _mesa_noop_SecondaryColor3ubEXT( GLubyte a, GLubyte b, GLubyte c );
+extern void GLAPIENTRY _mesa_noop_SecondaryColor3ubvEXT( const GLubyte *v );
+extern void GLAPIENTRY _mesa_noop_SecondaryColor3fEXT( GLfloat a, GLfloat b, GLfloat c );
+extern void GLAPIENTRY _mesa_noop_SecondaryColor3fvEXT( const GLfloat *v );
+
+extern void GLAPIENTRY _mesa_noop_TexCoord1f( GLfloat a );
+extern void GLAPIENTRY _mesa_noop_TexCoord1fv( const GLfloat *v );
+extern void GLAPIENTRY _mesa_noop_TexCoord2f( GLfloat a, GLfloat b );
+extern void GLAPIENTRY _mesa_noop_TexCoord2fv( const GLfloat *v );
+extern void GLAPIENTRY _mesa_noop_TexCoord3f( GLfloat a, GLfloat b, GLfloat c );
+extern void GLAPIENTRY _mesa_noop_TexCoord3fv( const GLfloat *v );
+extern void GLAPIENTRY _mesa_noop_TexCoord4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d );
+extern void GLAPIENTRY _mesa_noop_TexCoord4fv( const GLfloat *v );
+
+extern void GLAPIENTRY _mesa_noop_Vertex2f( GLfloat a, GLfloat b );
+extern void GLAPIENTRY _mesa_noop_Vertex2fv( const GLfloat *v );
+extern void GLAPIENTRY _mesa_noop_Vertex3f( GLfloat a, GLfloat b, GLfloat c );
+extern void GLAPIENTRY _mesa_noop_Vertex3fv( const GLfloat *v );
+extern void GLAPIENTRY _mesa_noop_Vertex4f( GLfloat a, GLfloat b, GLfloat c, GLfloat d );
+extern void GLAPIENTRY _mesa_noop_Vertex4fv( const GLfloat *v );
+
+extern void GLAPIENTRY _mesa_noop_VertexAttrib1fNV( GLuint index, GLfloat x );
+extern void GLAPIENTRY _mesa_noop_VertexAttrib1fvNV( GLuint index, const GLfloat *v );
+extern void GLAPIENTRY _mesa_noop_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y );
+extern void GLAPIENTRY _mesa_noop_VertexAttrib2fvNV( GLuint index, const GLfloat *v );
+extern void GLAPIENTRY _mesa_noop_VertexAttrib3fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z );
+extern void GLAPIENTRY _mesa_noop_VertexAttrib3fvNV( GLuint index, const GLfloat *v );
+extern void GLAPIENTRY _mesa_noop_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
+
+extern void GLAPIENTRY _mesa_noop_VertexAttrib4fvNV( GLuint index, const GLfloat *v );
+extern void GLAPIENTRY _mesa_noop_VertexAttrib1fARB( GLuint index, GLfloat x );
+extern void GLAPIENTRY _mesa_noop_VertexAttrib1fvARB( GLuint index, const GLfloat *v );
+extern void GLAPIENTRY _mesa_noop_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y );
+extern void GLAPIENTRY _mesa_noop_VertexAttrib2fvARB( GLuint index, const GLfloat *v );
+extern void GLAPIENTRY _mesa_noop_VertexAttrib3fARB( GLuint index, GLfloat x, GLfloat y, GLfloat z );
+extern void GLAPIENTRY _mesa_noop_VertexAttrib3fvARB( GLuint index, const GLfloat *v );
+extern void GLAPIENTRY _mesa_noop_VertexAttrib4fARB( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
+extern void GLAPIENTRY _mesa_noop_VertexAttrib4fvARB( GLuint index, const GLfloat *v );
+
+
+extern void GLAPIENTRY _mesa_noop_End( void );
+extern void GLAPIENTRY _mesa_noop_Begin( GLenum mode );
+extern void GLAPIENTRY _mesa_noop_EvalPoint2( GLint a, GLint b );
+extern void GLAPIENTRY _mesa_noop_EvalPoint1( GLint a );
+extern void GLAPIENTRY _mesa_noop_EvalCoord2fv( const GLfloat *v );
+extern void GLAPIENTRY _mesa_noop_EvalCoord2f( GLfloat a, GLfloat b );
+extern void GLAPIENTRY _mesa_noop_EvalCoord1fv( const GLfloat *v );
+extern void GLAPIENTRY _mesa_noop_EvalCoord1f( GLfloat a );
+
+extern void _mesa_noop_vtxfmt_init( GLvertexformat *vfmt );
+
+extern void GLAPIENTRY _mesa_noop_EvalMesh2( GLenum mode, GLint i1, GLint i2,
+ GLint j1, GLint j2 );
+
+extern void GLAPIENTRY _mesa_noop_EvalMesh1( GLenum mode, GLint i1, GLint i2 );
+
+
+/* Not strictly a noop -- translate Rectf down to Begin/End and
+ * vertices. Closer to the loopback operations, but doesn't meet the
+ * criteria for inclusion there (cannot be used in the Save table).
+ */
+extern void GLAPIENTRY _mesa_noop_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 );
+
+
+extern void GLAPIENTRY _mesa_noop_DrawArrays(GLenum mode, GLint start, GLsizei count);
+extern void GLAPIENTRY _mesa_noop_DrawElements(GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices);
+extern void GLAPIENTRY _mesa_noop_DrawRangeElements(GLenum mode,
+ GLuint start, GLuint end,
+ GLsizei count, GLenum type,
+ const GLvoid *indices);
+
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/api_validate.c b/nx-X11/extras/Mesa/src/mesa/main/api_validate.c
new file mode 100644
index 000000000..d1c8f42e7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/api_validate.c
@@ -0,0 +1,238 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+#include "glheader.h"
+#include "api_validate.h"
+#include "context.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "state.h"
+
+
+GLboolean
+_mesa_validate_DrawElements(GLcontext *ctx,
+ GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices)
+{
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+
+ if (count <= 0) {
+ if (count < 0)
+ _mesa_error(ctx, GL_INVALID_VALUE, "glDrawElements(count)" );
+ return GL_FALSE;
+ }
+
+ if (mode > GL_POLYGON) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(mode)" );
+ return GL_FALSE;
+ }
+
+ if (type != GL_UNSIGNED_INT &&
+ type != GL_UNSIGNED_BYTE &&
+ type != GL_UNSIGNED_SHORT)
+ {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glDrawElements(type)" );
+ return GL_FALSE;
+ }
+
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ /* Always need vertex positions */
+ if (!ctx->Array.Vertex.Enabled
+ && !(ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[0].Enabled))
+ return GL_FALSE;
+
+ /* Vertex buffer object tests */
+ if (ctx->Array.ElementArrayBufferObj->Name) {
+ GLuint indexBytes;
+
+ /* use indices in the buffer object */
+ if (!ctx->Array.ElementArrayBufferObj->Data) {
+ _mesa_warning(ctx, "DrawElements with empty vertex elements buffer!");
+ return GL_FALSE;
+ }
+
+ /* make sure count doesn't go outside buffer bounds */
+ if (type == GL_UNSIGNED_INT) {
+ indexBytes = count * sizeof(GLuint);
+ }
+ else if (type == GL_UNSIGNED_BYTE) {
+ indexBytes = count * sizeof(GLubyte);
+ }
+ else {
+ ASSERT(type == GL_UNSIGNED_SHORT);
+ indexBytes = count * sizeof(GLushort);
+ }
+
+ if ((GLubyte *) indices + indexBytes >
+ ctx->Array.ElementArrayBufferObj->Data +
+ ctx->Array.ElementArrayBufferObj->Size) {
+ _mesa_warning(ctx, "glDrawElements index out of buffer bounds");
+ return GL_FALSE;
+ }
+
+ /* Actual address is the sum of pointers. Indices may be used below. */
+ if (ctx->Const.CheckArrayBounds) {
+ indices = (const GLvoid *)
+ ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Data,
+ (const GLubyte *) indices);
+ }
+ }
+
+ if (ctx->Const.CheckArrayBounds) {
+ /* find max array index */
+ GLuint max = 0;
+ GLint i;
+ if (type == GL_UNSIGNED_INT) {
+ for (i = 0; i < count; i++)
+ if (((GLuint *) indices)[i] > max)
+ max = ((GLuint *) indices)[i];
+ }
+ else if (type == GL_UNSIGNED_SHORT) {
+ for (i = 0; i < count; i++)
+ if (((GLushort *) indices)[i] > max)
+ max = ((GLushort *) indices)[i];
+ }
+ else {
+ ASSERT(type == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++)
+ if (((GLubyte *) indices)[i] > max)
+ max = ((GLubyte *) indices)[i];
+ }
+ if (max >= ctx->Array._MaxElement) {
+ /* the max element is out of bounds of one or more enabled arrays */
+ return GL_FALSE;
+ }
+ }
+
+ return GL_TRUE;
+}
+
+
+GLboolean
+_mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
+ GLuint start, GLuint end,
+ GLsizei count, GLenum type,
+ const GLvoid *indices)
+{
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+
+ if (count <= 0) {
+ if (count < 0)
+ _mesa_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements(count)" );
+ return GL_FALSE;
+ }
+
+ if (mode > GL_POLYGON) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glDrawRangeElements(mode)" );
+ return GL_FALSE;
+ }
+
+ if (end < start) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glDrawRangeElements(end<start)");
+ return GL_FALSE;
+ }
+
+ if (type != GL_UNSIGNED_INT &&
+ type != GL_UNSIGNED_BYTE &&
+ type != GL_UNSIGNED_SHORT) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glDrawRangeElements(type)" );
+ return GL_FALSE;
+ }
+
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ /* Always need vertex positions */
+ if (!ctx->Array.Vertex.Enabled
+ && !(ctx->VertexProgram._Enabled && ctx->Array.VertexAttrib[0].Enabled))
+ return GL_FALSE;
+
+ if (ctx->Const.CheckArrayBounds) {
+ /* Find max array index.
+ * We don't trust the user's start and end values.
+ */
+ GLuint max = 0;
+ GLint i;
+ if (type == GL_UNSIGNED_INT) {
+ for (i = 0; i < count; i++)
+ if (((GLuint *) indices)[i] > max)
+ max = ((GLuint *) indices)[i];
+ }
+ else if (type == GL_UNSIGNED_SHORT) {
+ for (i = 0; i < count; i++)
+ if (((GLushort *) indices)[i] > max)
+ max = ((GLushort *) indices)[i];
+ }
+ else {
+ ASSERT(type == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++)
+ if (((GLubyte *) indices)[i] > max)
+ max = ((GLubyte *) indices)[i];
+ }
+ if (max >= ctx->Array._MaxElement) {
+ /* the max element is out of bounds of one or more enabled arrays */
+ return GL_FALSE;
+ }
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Called from the tnl module to error check the function parameters and
+ * verify that we really can draw something.
+ */
+GLboolean
+_mesa_validate_DrawArrays(GLcontext *ctx,
+ GLenum mode, GLint start, GLsizei count)
+{
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+
+ if (count < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glDrawArrays(count)" );
+ return GL_FALSE;
+ }
+
+ if (mode > GL_POLYGON) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glDrawArrays(mode)" );
+ return GL_FALSE;
+ }
+
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ /* Always need vertex positions */
+ if (!ctx->Array.Vertex.Enabled && !ctx->Array.VertexAttrib[0].Enabled)
+ return GL_FALSE;
+
+ if (ctx->Const.CheckArrayBounds) {
+ if (start + count > (GLint) ctx->Array._MaxElement)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/api_validate.h b/nx-X11/extras/Mesa/src/mesa/main/api_validate.h
new file mode 100644
index 000000000..10f0c34e6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/api_validate.h
@@ -0,0 +1,49 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef API_VALIDATE_H
+#define API_VALIDATE_H
+
+
+#include "mtypes.h"
+
+extern GLboolean
+_mesa_validate_DrawArrays(GLcontext *ctx,
+ GLenum mode, GLint start, GLsizei count);
+
+extern GLboolean
+_mesa_validate_DrawElements(GLcontext *ctx,
+ GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices);
+
+extern GLboolean
+_mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode,
+ GLuint start, GLuint end,
+ GLsizei count, GLenum type,
+ const GLvoid *indices);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/attrib.c b/nx-X11/extras/Mesa/src/mesa/main/attrib.c
new file mode 100644
index 000000000..4f8b6c2d6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/attrib.c
@@ -0,0 +1,1338 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4.1
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "accum.h"
+#include "attrib.h"
+#include "blend.h"
+#include "buffers.h"
+#include "bufferobj.h"
+#include "colormac.h"
+#include "colortab.h"
+#include "context.h"
+#include "depth.h"
+#include "enable.h"
+#include "enums.h"
+#include "fog.h"
+#include "hint.h"
+#include "light.h"
+#include "lines.h"
+#include "matrix.h"
+#include "points.h"
+#include "polygon.h"
+#include "simple_list.h"
+#include "stencil.h"
+#include "texobj.h"
+#include "texstate.h"
+#include "mtypes.h"
+#include "math/m_xform.h"
+
+
+/*
+ * Allocate a new attribute state node. These nodes have a
+ * "kind" value and a pointer to a struct of state data.
+ */
+static struct gl_attrib_node *
+new_attrib_node( GLbitfield kind )
+{
+ struct gl_attrib_node *an = MALLOC_STRUCT(gl_attrib_node);
+ if (an) {
+ an->kind = kind;
+ }
+ return an;
+}
+
+
+void GLAPIENTRY
+_mesa_PushAttrib(GLbitfield mask)
+{
+ struct gl_attrib_node *newnode;
+ struct gl_attrib_node *head;
+
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glPushAttrib %x\n", (int) mask);
+
+ if (ctx->AttribStackDepth >= MAX_ATTRIB_STACK_DEPTH) {
+ _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushAttrib" );
+ return;
+ }
+
+ /* Build linked list of attribute nodes which save all attribute */
+ /* groups specified by the mask. */
+ head = NULL;
+
+ if (mask & GL_ACCUM_BUFFER_BIT) {
+ struct gl_accum_attrib *attr;
+ attr = MALLOC_STRUCT( gl_accum_attrib );
+ MEMCPY( attr, &ctx->Accum, sizeof(struct gl_accum_attrib) );
+ newnode = new_attrib_node( GL_ACCUM_BUFFER_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_COLOR_BUFFER_BIT) {
+ struct gl_colorbuffer_attrib *attr;
+ attr = MALLOC_STRUCT( gl_colorbuffer_attrib );
+ MEMCPY( attr, &ctx->Color, sizeof(struct gl_colorbuffer_attrib) );
+ newnode = new_attrib_node( GL_COLOR_BUFFER_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_CURRENT_BIT) {
+ struct gl_current_attrib *attr;
+ FLUSH_CURRENT( ctx, 0 );
+ attr = MALLOC_STRUCT( gl_current_attrib );
+ MEMCPY( attr, &ctx->Current, sizeof(struct gl_current_attrib) );
+ newnode = new_attrib_node( GL_CURRENT_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_DEPTH_BUFFER_BIT) {
+ struct gl_depthbuffer_attrib *attr;
+ attr = MALLOC_STRUCT( gl_depthbuffer_attrib );
+ MEMCPY( attr, &ctx->Depth, sizeof(struct gl_depthbuffer_attrib) );
+ newnode = new_attrib_node( GL_DEPTH_BUFFER_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_ENABLE_BIT) {
+ struct gl_enable_attrib *attr;
+ GLuint i;
+ attr = MALLOC_STRUCT( gl_enable_attrib );
+ /* Copy enable flags from all other attributes into the enable struct. */
+ attr->AlphaTest = ctx->Color.AlphaEnabled;
+ attr->AutoNormal = ctx->Eval.AutoNormal;
+ attr->Blend = ctx->Color.BlendEnabled;
+ attr->ClipPlanes = ctx->Transform.ClipPlanesEnabled;
+ attr->ColorMaterial = ctx->Light.ColorMaterialEnabled;
+ attr->ColorTable = ctx->Pixel.ColorTableEnabled;
+ attr->PostColorMatrixColorTable = ctx->Pixel.PostColorMatrixColorTableEnabled;
+ attr->PostConvolutionColorTable = ctx->Pixel.PostConvolutionColorTableEnabled;
+ 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;
+ attr->Fog = ctx->Fog.Enabled;
+ for (i=0;i<MAX_LIGHTS;i++) {
+ attr->Light[i] = ctx->Light.Light[i].Enabled;
+ }
+ 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;
+ attr->Map1Index = ctx->Eval.Map1Index;
+ attr->Map1Normal = ctx->Eval.Map1Normal;
+ attr->Map1TextureCoord1 = ctx->Eval.Map1TextureCoord1;
+ attr->Map1TextureCoord2 = ctx->Eval.Map1TextureCoord2;
+ attr->Map1TextureCoord3 = ctx->Eval.Map1TextureCoord3;
+ attr->Map1TextureCoord4 = ctx->Eval.Map1TextureCoord4;
+ attr->Map1Vertex3 = ctx->Eval.Map1Vertex3;
+ attr->Map1Vertex4 = ctx->Eval.Map1Vertex4;
+ MEMCPY(attr->Map1Attrib, ctx->Eval.Map1Attrib, sizeof(ctx->Eval.Map1Attrib));
+ attr->Map2Color4 = ctx->Eval.Map2Color4;
+ attr->Map2Index = ctx->Eval.Map2Index;
+ attr->Map2Normal = ctx->Eval.Map2Normal;
+ attr->Map2TextureCoord1 = ctx->Eval.Map2TextureCoord1;
+ attr->Map2TextureCoord2 = ctx->Eval.Map2TextureCoord2;
+ attr->Map2TextureCoord3 = ctx->Eval.Map2TextureCoord3;
+ attr->Map2TextureCoord4 = ctx->Eval.Map2TextureCoord4;
+ attr->Map2Vertex3 = ctx->Eval.Map2Vertex3;
+ attr->Map2Vertex4 = ctx->Eval.Map2Vertex4;
+ MEMCPY(attr->Map2Attrib, ctx->Eval.Map2Attrib, sizeof(ctx->Eval.Map2Attrib));
+ attr->Normalize = ctx->Transform.Normalize;
+ attr->RasterPositionUnclipped = ctx->Transform.RasterPositionUnclipped;
+ attr->PixelTexture = ctx->Pixel.PixelTextureEnabled;
+ attr->PointSmooth = ctx->Point.SmoothFlag;
+ attr->PointSprite = ctx->Point.PointSprite;
+ attr->PolygonOffsetPoint = ctx->Polygon.OffsetPoint;
+ attr->PolygonOffsetLine = ctx->Polygon.OffsetLine;
+ attr->PolygonOffsetFill = ctx->Polygon.OffsetFill;
+ attr->PolygonSmooth = ctx->Polygon.SmoothFlag;
+ attr->PolygonStipple = ctx->Polygon.StippleFlag;
+ attr->RescaleNormals = ctx->Transform.RescaleNormals;
+ attr->Scissor = ctx->Scissor.Enabled;
+ attr->Stencil = ctx->Stencil.Enabled;
+ attr->StencilTwoSide = ctx->Stencil.TestTwoSide;
+ attr->MultisampleEnabled = ctx->Multisample.Enabled;
+ attr->SampleAlphaToCoverage = ctx->Multisample.SampleAlphaToCoverage;
+ attr->SampleAlphaToOne = ctx->Multisample.SampleAlphaToOne;
+ attr->SampleCoverage = ctx->Multisample.SampleCoverage;
+ attr->SampleCoverageInvert = ctx->Multisample.SampleCoverageInvert;
+ for (i=0; i<MAX_TEXTURE_UNITS; i++) {
+ attr->Texture[i] = ctx->Texture.Unit[i].Enabled;
+ attr->TexGen[i] = ctx->Texture.Unit[i].TexGenEnabled;
+ attr->TextureColorTable[i] = ctx->Texture.Unit[i].ColorTableEnabled;
+ }
+ /* GL_NV_vertex_program */
+ attr->VertexProgram = ctx->VertexProgram.Enabled;
+ attr->VertexProgramPointSize = ctx->VertexProgram.PointSizeEnabled;
+ attr->VertexProgramTwoSide = ctx->VertexProgram.TwoSideEnabled;
+ newnode = new_attrib_node( GL_ENABLE_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_EVAL_BIT) {
+ struct gl_eval_attrib *attr;
+ attr = MALLOC_STRUCT( gl_eval_attrib );
+ MEMCPY( attr, &ctx->Eval, sizeof(struct gl_eval_attrib) );
+ newnode = new_attrib_node( GL_EVAL_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_FOG_BIT) {
+ struct gl_fog_attrib *attr;
+ attr = MALLOC_STRUCT( gl_fog_attrib );
+ MEMCPY( attr, &ctx->Fog, sizeof(struct gl_fog_attrib) );
+ newnode = new_attrib_node( GL_FOG_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_HINT_BIT) {
+ struct gl_hint_attrib *attr;
+ attr = MALLOC_STRUCT( gl_hint_attrib );
+ MEMCPY( attr, &ctx->Hint, sizeof(struct gl_hint_attrib) );
+ newnode = new_attrib_node( GL_HINT_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_LIGHTING_BIT) {
+ struct gl_light_attrib *attr;
+ FLUSH_CURRENT(ctx, 0); /* flush material changes */
+ attr = MALLOC_STRUCT( gl_light_attrib );
+ MEMCPY( attr, &ctx->Light, sizeof(struct gl_light_attrib) );
+ newnode = new_attrib_node( GL_LIGHTING_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_LINE_BIT) {
+ struct gl_line_attrib *attr;
+ attr = MALLOC_STRUCT( gl_line_attrib );
+ MEMCPY( attr, &ctx->Line, sizeof(struct gl_line_attrib) );
+ newnode = new_attrib_node( GL_LINE_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_LIST_BIT) {
+ struct gl_list_attrib *attr;
+ attr = MALLOC_STRUCT( gl_list_attrib );
+ MEMCPY( attr, &ctx->List, sizeof(struct gl_list_attrib) );
+ newnode = new_attrib_node( GL_LIST_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_PIXEL_MODE_BIT) {
+ struct gl_pixel_attrib *attr;
+ attr = MALLOC_STRUCT( gl_pixel_attrib );
+ MEMCPY( attr, &ctx->Pixel, sizeof(struct gl_pixel_attrib) );
+ newnode = new_attrib_node( GL_PIXEL_MODE_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_POINT_BIT) {
+ struct gl_point_attrib *attr;
+ attr = MALLOC_STRUCT( gl_point_attrib );
+ MEMCPY( attr, &ctx->Point, sizeof(struct gl_point_attrib) );
+ newnode = new_attrib_node( GL_POINT_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_POLYGON_BIT) {
+ struct gl_polygon_attrib *attr;
+ attr = MALLOC_STRUCT( gl_polygon_attrib );
+ MEMCPY( attr, &ctx->Polygon, sizeof(struct gl_polygon_attrib) );
+ newnode = new_attrib_node( GL_POLYGON_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_POLYGON_STIPPLE_BIT) {
+ GLuint *stipple;
+ stipple = (GLuint *) MALLOC( 32*sizeof(GLuint) );
+ MEMCPY( stipple, ctx->PolygonStipple, 32*sizeof(GLuint) );
+ newnode = new_attrib_node( GL_POLYGON_STIPPLE_BIT );
+ newnode->data = stipple;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_SCISSOR_BIT) {
+ struct gl_scissor_attrib *attr;
+ attr = MALLOC_STRUCT( gl_scissor_attrib );
+ MEMCPY( attr, &ctx->Scissor, sizeof(struct gl_scissor_attrib) );
+ newnode = new_attrib_node( GL_SCISSOR_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_STENCIL_BUFFER_BIT) {
+ struct gl_stencil_attrib *attr;
+ attr = MALLOC_STRUCT( gl_stencil_attrib );
+ MEMCPY( attr, &ctx->Stencil, sizeof(struct gl_stencil_attrib) );
+ newnode = new_attrib_node( GL_STENCIL_BUFFER_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_TEXTURE_BIT) {
+ struct gl_texture_attrib *attr;
+ GLuint u;
+ /* Bump the texture object reference counts so that they don't
+ * inadvertantly get deleted.
+ */
+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
+ ctx->Texture.Unit[u].Current1D->RefCount++;
+ ctx->Texture.Unit[u].Current2D->RefCount++;
+ ctx->Texture.Unit[u].Current3D->RefCount++;
+ ctx->Texture.Unit[u].CurrentCubeMap->RefCount++;
+ ctx->Texture.Unit[u].CurrentRect->RefCount++;
+ }
+ attr = MALLOC_STRUCT( gl_texture_attrib );
+ MEMCPY( attr, &ctx->Texture, sizeof(struct gl_texture_attrib) );
+ /* copy state of the currently bound texture objects */
+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
+ _mesa_copy_texture_object(&attr->Unit[u].Saved1D,
+ attr->Unit[u].Current1D);
+ _mesa_copy_texture_object(&attr->Unit[u].Saved2D,
+ attr->Unit[u].Current2D);
+ _mesa_copy_texture_object(&attr->Unit[u].Saved3D,
+ attr->Unit[u].Current3D);
+ _mesa_copy_texture_object(&attr->Unit[u].SavedCubeMap,
+ attr->Unit[u].CurrentCubeMap);
+ _mesa_copy_texture_object(&attr->Unit[u].SavedRect,
+ attr->Unit[u].CurrentRect);
+ }
+ newnode = new_attrib_node( GL_TEXTURE_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_TRANSFORM_BIT) {
+ struct gl_transform_attrib *attr;
+ attr = MALLOC_STRUCT( gl_transform_attrib );
+ MEMCPY( attr, &ctx->Transform, sizeof(struct gl_transform_attrib) );
+ newnode = new_attrib_node( GL_TRANSFORM_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ if (mask & GL_VIEWPORT_BIT) {
+ struct gl_viewport_attrib *attr;
+ attr = MALLOC_STRUCT( gl_viewport_attrib );
+ MEMCPY( attr, &ctx->Viewport, sizeof(struct gl_viewport_attrib) );
+ newnode = new_attrib_node( GL_VIEWPORT_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ /* GL_ARB_multisample */
+ if (mask & GL_MULTISAMPLE_BIT_ARB) {
+ struct gl_multisample_attrib *attr;
+ attr = MALLOC_STRUCT( gl_multisample_attrib );
+ MEMCPY( attr, &ctx->Multisample, sizeof(struct gl_multisample_attrib) );
+ newnode = new_attrib_node( GL_MULTISAMPLE_BIT_ARB );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+
+ ctx->AttribStack[ctx->AttribStackDepth] = head;
+ ctx->AttribStackDepth++;
+}
+
+
+
+static void
+pop_enable_group(GLcontext *ctx, const struct gl_enable_attrib *enable)
+{
+ GLuint i;
+
+#define TEST_AND_UPDATE(VALUE, NEWVALUE, ENUM) \
+ if ((VALUE) != (NEWVALUE)) { \
+ _mesa_set_enable( ctx, ENUM, (NEWVALUE) ); \
+ }
+
+ TEST_AND_UPDATE(ctx->Color.AlphaEnabled, enable->AlphaTest, GL_ALPHA_TEST);
+ TEST_AND_UPDATE(ctx->Color.BlendEnabled, enable->Blend, GL_BLEND);
+
+ for (i=0;i<MAX_CLIP_PLANES;i++) {
+ const GLuint mask = 1 << i;
+ if ((ctx->Transform.ClipPlanesEnabled & mask) != (enable->ClipPlanes & mask))
+ _mesa_set_enable(ctx, (GLenum) (GL_CLIP_PLANE0 + i),
+ (GLboolean) ((enable->ClipPlanes & mask) ? GL_TRUE : GL_FALSE));
+ }
+
+ TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, enable->ColorMaterial,
+ GL_COLOR_MATERIAL);
+ TEST_AND_UPDATE(ctx->Pixel.ColorTableEnabled, enable->ColorTable,
+ GL_COLOR_TABLE);
+ TEST_AND_UPDATE(ctx->Pixel.PostColorMatrixColorTableEnabled,
+ enable->PostColorMatrixColorTable,
+ GL_POST_COLOR_MATRIX_COLOR_TABLE);
+ TEST_AND_UPDATE(ctx->Pixel.PostConvolutionColorTableEnabled,
+ enable->PostConvolutionColorTable,
+ GL_POST_CONVOLUTION_COLOR_TABLE);
+ 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);
+ TEST_AND_UPDATE(ctx->Line.StippleFlag, enable->LineStipple,
+ GL_LINE_STIPPLE);
+ TEST_AND_UPDATE(ctx->Color.IndexLogicOpEnabled, enable->IndexLogicOp,
+ GL_INDEX_LOGIC_OP);
+ TEST_AND_UPDATE(ctx->Color.ColorLogicOpEnabled, enable->ColorLogicOp,
+ GL_COLOR_LOGIC_OP);
+
+ TEST_AND_UPDATE(ctx->Eval.Map1Color4, enable->Map1Color4, GL_MAP1_COLOR_4);
+ TEST_AND_UPDATE(ctx->Eval.Map1Index, enable->Map1Index, GL_MAP1_INDEX);
+ TEST_AND_UPDATE(ctx->Eval.Map1Normal, enable->Map1Normal, GL_MAP1_NORMAL);
+ TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord1, enable->Map1TextureCoord1,
+ GL_MAP1_TEXTURE_COORD_1);
+ TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord2, enable->Map1TextureCoord2,
+ GL_MAP1_TEXTURE_COORD_2);
+ TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord3, enable->Map1TextureCoord3,
+ GL_MAP1_TEXTURE_COORD_3);
+ TEST_AND_UPDATE(ctx->Eval.Map1TextureCoord4, enable->Map1TextureCoord4,
+ GL_MAP1_TEXTURE_COORD_4);
+ TEST_AND_UPDATE(ctx->Eval.Map1Vertex3, enable->Map1Vertex3,
+ GL_MAP1_VERTEX_3);
+ TEST_AND_UPDATE(ctx->Eval.Map1Vertex4, enable->Map1Vertex4,
+ GL_MAP1_VERTEX_4);
+ for (i = 0; i < 16; i++) {
+ TEST_AND_UPDATE(ctx->Eval.Map1Attrib[i], enable->Map1Attrib[i],
+ GL_MAP1_VERTEX_ATTRIB0_4_NV + i);
+ }
+
+ TEST_AND_UPDATE(ctx->Eval.Map2Color4, enable->Map2Color4, GL_MAP2_COLOR_4);
+ TEST_AND_UPDATE(ctx->Eval.Map2Index, enable->Map2Index, GL_MAP2_INDEX);
+ TEST_AND_UPDATE(ctx->Eval.Map2Normal, enable->Map2Normal, GL_MAP2_NORMAL);
+ TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord1, enable->Map2TextureCoord1,
+ GL_MAP2_TEXTURE_COORD_1);
+ TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord2, enable->Map2TextureCoord2,
+ GL_MAP2_TEXTURE_COORD_2);
+ TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord3, enable->Map2TextureCoord3,
+ GL_MAP2_TEXTURE_COORD_3);
+ TEST_AND_UPDATE(ctx->Eval.Map2TextureCoord4, enable->Map2TextureCoord4,
+ GL_MAP2_TEXTURE_COORD_4);
+ TEST_AND_UPDATE(ctx->Eval.Map2Vertex3, enable->Map2Vertex3,
+ GL_MAP2_VERTEX_3);
+ TEST_AND_UPDATE(ctx->Eval.Map2Vertex4, enable->Map2Vertex4,
+ GL_MAP2_VERTEX_4);
+ for (i = 0; i < 16; i++) {
+ TEST_AND_UPDATE(ctx->Eval.Map2Attrib[i], enable->Map2Attrib[i],
+ GL_MAP2_VERTEX_ATTRIB0_4_NV + i);
+ }
+
+ TEST_AND_UPDATE(ctx->Eval.AutoNormal, enable->AutoNormal, GL_AUTO_NORMAL);
+ 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->Transform.RasterPositionUnclipped,
+ enable->RasterPositionUnclipped,
+ GL_RASTER_POSITION_UNCLIPPED_IBM);
+ TEST_AND_UPDATE(ctx->Pixel.PixelTextureEnabled, enable->PixelTexture,
+ GL_POINT_SMOOTH);
+ TEST_AND_UPDATE(ctx->Point.SmoothFlag, enable->PointSmooth,
+ GL_POINT_SMOOTH);
+ if (ctx->Extensions.NV_point_sprite || ctx->Extensions.ARB_point_sprite) {
+ TEST_AND_UPDATE(ctx->Point.PointSprite, enable->PointSprite,
+ GL_POINT_SPRITE_NV);
+ }
+ TEST_AND_UPDATE(ctx->Polygon.OffsetPoint, enable->PolygonOffsetPoint,
+ GL_POLYGON_OFFSET_POINT);
+ TEST_AND_UPDATE(ctx->Polygon.OffsetLine, enable->PolygonOffsetLine,
+ GL_POLYGON_OFFSET_LINE);
+ TEST_AND_UPDATE(ctx->Polygon.OffsetFill, enable->PolygonOffsetFill,
+ GL_POLYGON_OFFSET_FILL);
+ TEST_AND_UPDATE(ctx->Polygon.SmoothFlag, enable->PolygonSmooth,
+ GL_POLYGON_SMOOTH);
+ TEST_AND_UPDATE(ctx->Polygon.StippleFlag, enable->PolygonStipple,
+ GL_POLYGON_STIPPLE);
+ TEST_AND_UPDATE(ctx->Scissor.Enabled, enable->Scissor, GL_SCISSOR_TEST);
+ TEST_AND_UPDATE(ctx->Stencil.Enabled, enable->Stencil, GL_STENCIL_TEST);
+ if (ctx->Extensions.EXT_stencil_two_side) {
+ TEST_AND_UPDATE(ctx->Stencil.TestTwoSide, enable->StencilTwoSide, GL_STENCIL_TEST_TWO_SIDE_EXT);
+ }
+ TEST_AND_UPDATE(ctx->Multisample.Enabled, enable->MultisampleEnabled,
+ GL_MULTISAMPLE_ARB);
+ TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToCoverage,
+ enable->SampleAlphaToCoverage,
+ GL_SAMPLE_ALPHA_TO_COVERAGE_ARB);
+ TEST_AND_UPDATE(ctx->Multisample.SampleAlphaToOne,
+ enable->SampleAlphaToOne,
+ GL_SAMPLE_ALPHA_TO_ONE_ARB);
+ TEST_AND_UPDATE(ctx->Multisample.SampleCoverage,
+ enable->SampleCoverage,
+ GL_SAMPLE_COVERAGE_ARB);
+ TEST_AND_UPDATE(ctx->Multisample.SampleCoverageInvert,
+ enable->SampleCoverageInvert,
+ GL_SAMPLE_COVERAGE_INVERT_ARB);
+ /* GL_NV_vertex_program */
+ TEST_AND_UPDATE(ctx->VertexProgram.Enabled,
+ enable->VertexProgram,
+ GL_VERTEX_PROGRAM_NV);
+ TEST_AND_UPDATE(ctx->VertexProgram.PointSizeEnabled,
+ enable->VertexProgramPointSize,
+ GL_VERTEX_PROGRAM_POINT_SIZE_NV);
+ TEST_AND_UPDATE(ctx->VertexProgram.TwoSideEnabled,
+ enable->VertexProgramTwoSide,
+ GL_VERTEX_PROGRAM_TWO_SIDE_NV);
+
+#undef TEST_AND_UPDATE
+
+ /* texture unit enables */
+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+ if (ctx->Texture.Unit[i].Enabled != enable->Texture[i]) {
+ ctx->Texture.Unit[i].Enabled = enable->Texture[i];
+ if (ctx->Driver.Enable) {
+ if (ctx->Driver.ActiveTexture) {
+ (*ctx->Driver.ActiveTexture)(ctx, i);
+ }
+ (*ctx->Driver.Enable)( ctx, GL_TEXTURE_1D,
+ (GLboolean) (enable->Texture[i] & TEXTURE_1D_BIT) );
+ (*ctx->Driver.Enable)( ctx, GL_TEXTURE_2D,
+ (GLboolean) (enable->Texture[i] & TEXTURE_2D_BIT) );
+ (*ctx->Driver.Enable)( ctx, GL_TEXTURE_3D,
+ (GLboolean) (enable->Texture[i] & TEXTURE_3D_BIT) );
+ if (ctx->Extensions.ARB_texture_cube_map)
+ (*ctx->Driver.Enable)( ctx, GL_TEXTURE_CUBE_MAP_ARB,
+ (GLboolean) (enable->Texture[i] & TEXTURE_CUBE_BIT) );
+ if (ctx->Extensions.NV_texture_rectangle)
+ (*ctx->Driver.Enable)( ctx, GL_TEXTURE_RECTANGLE_NV,
+ (GLboolean) (enable->Texture[i] & TEXTURE_RECT_BIT) );
+ }
+ }
+
+ if (ctx->Texture.Unit[i].TexGenEnabled != enable->TexGen[i]) {
+ ctx->Texture.Unit[i].TexGenEnabled = enable->TexGen[i];
+ if (ctx->Driver.Enable) {
+ if (ctx->Driver.ActiveTexture) {
+ (*ctx->Driver.ActiveTexture)(ctx, i);
+ }
+ if (enable->TexGen[i] & S_BIT)
+ (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_S, GL_TRUE);
+ else
+ (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_S, GL_FALSE);
+ if (enable->TexGen[i] & T_BIT)
+ (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_T, GL_TRUE);
+ else
+ (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_T, GL_FALSE);
+ if (enable->TexGen[i] & R_BIT)
+ (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_R, GL_TRUE);
+ else
+ (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_R, GL_FALSE);
+ if (enable->TexGen[i] & Q_BIT)
+ (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_Q, GL_TRUE);
+ else
+ (*ctx->Driver.Enable)( ctx, GL_TEXTURE_GEN_Q, GL_FALSE);
+ }
+ }
+
+ /* GL_SGI_texture_color_table */
+ ctx->Texture.Unit[i].ColorTableEnabled = enable->TextureColorTable[i];
+ }
+
+ if (ctx->Driver.ActiveTexture) {
+ (*ctx->Driver.ActiveTexture)(ctx, ctx->Texture.CurrentUnit);
+ }
+}
+
+
+static void
+pop_texture_group(GLcontext *ctx, const struct gl_texture_attrib *texAttrib)
+{
+ GLuint u;
+
+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
+ const struct gl_texture_unit *unit = &texAttrib->Unit[u];
+ GLuint i;
+
+ _mesa_ActiveTextureARB(GL_TEXTURE0_ARB + u);
+ _mesa_set_enable(ctx, GL_TEXTURE_1D,
+ (unit->Enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE);
+ _mesa_set_enable(ctx, GL_TEXTURE_2D,
+ (unit->Enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE);
+ _mesa_set_enable(ctx, GL_TEXTURE_3D,
+ (unit->Enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE);
+ if (ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_set_enable(ctx, GL_TEXTURE_CUBE_MAP_ARB,
+ (unit->Enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE);
+ }
+ if (ctx->Extensions.NV_texture_rectangle) {
+ _mesa_set_enable(ctx, GL_TEXTURE_RECTANGLE_NV,
+ (unit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE);
+ }
+ if (ctx->Extensions.SGI_texture_color_table) {
+ _mesa_set_enable(ctx, GL_TEXTURE_COLOR_TABLE_SGI,
+ unit->ColorTableEnabled);
+ }
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, unit->EnvMode);
+ _mesa_TexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, unit->EnvColor);
+ _mesa_TexGeni(GL_S, GL_TEXTURE_GEN_MODE, unit->GenModeS);
+ _mesa_TexGeni(GL_T, GL_TEXTURE_GEN_MODE, unit->GenModeT);
+ _mesa_TexGeni(GL_R, GL_TEXTURE_GEN_MODE, unit->GenModeR);
+ _mesa_TexGeni(GL_Q, GL_TEXTURE_GEN_MODE, unit->GenModeQ);
+ _mesa_TexGenfv(GL_S, GL_OBJECT_PLANE, unit->ObjectPlaneS);
+ _mesa_TexGenfv(GL_T, GL_OBJECT_PLANE, unit->ObjectPlaneT);
+ _mesa_TexGenfv(GL_R, GL_OBJECT_PLANE, unit->ObjectPlaneR);
+ _mesa_TexGenfv(GL_Q, GL_OBJECT_PLANE, unit->ObjectPlaneQ);
+ /* Eye plane done differently to avoid re-transformation */
+ {
+ struct gl_texture_unit *destUnit = &ctx->Texture.Unit[u];
+ COPY_4FV(destUnit->EyePlaneS, unit->EyePlaneS);
+ COPY_4FV(destUnit->EyePlaneT, unit->EyePlaneT);
+ COPY_4FV(destUnit->EyePlaneR, unit->EyePlaneR);
+ COPY_4FV(destUnit->EyePlaneQ, unit->EyePlaneQ);
+ if (ctx->Driver.TexGen) {
+ ctx->Driver.TexGen(ctx, GL_S, GL_EYE_PLANE, unit->EyePlaneS);
+ ctx->Driver.TexGen(ctx, GL_T, GL_EYE_PLANE, unit->EyePlaneT);
+ ctx->Driver.TexGen(ctx, GL_R, GL_EYE_PLANE, unit->EyePlaneR);
+ ctx->Driver.TexGen(ctx, GL_Q, GL_EYE_PLANE, unit->EyePlaneQ);
+ }
+ }
+ _mesa_set_enable(ctx, GL_TEXTURE_GEN_S,
+ ((unit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE));
+ _mesa_set_enable(ctx, GL_TEXTURE_GEN_T,
+ ((unit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE));
+ _mesa_set_enable(ctx, GL_TEXTURE_GEN_R,
+ ((unit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE));
+ _mesa_set_enable(ctx, GL_TEXTURE_GEN_Q,
+ ((unit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE));
+ if (ctx->Extensions.EXT_texture_lod_bias) {
+ _mesa_TexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT,
+ GL_TEXTURE_LOD_BIAS_EXT, unit->LodBias);
+ }
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB,
+ unit->Combine.ModeRGB);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA,
+ unit->Combine.ModeA);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB,
+ unit->Combine.SourceRGB[0]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB,
+ unit->Combine.SourceRGB[1]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB,
+ unit->Combine.SourceRGB[2]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA,
+ unit->Combine.SourceA[0]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA,
+ unit->Combine.SourceA[1]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA,
+ unit->Combine.SourceA[2]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB,
+ unit->Combine.OperandRGB[0]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB,
+ unit->Combine.OperandRGB[1]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB,
+ unit->Combine.OperandRGB[2]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA,
+ unit->Combine.OperandA[0]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA,
+ unit->Combine.OperandA[1]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA,
+ unit->Combine.OperandA[2]);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE,
+ 1 << unit->Combine.ScaleShiftRGB);
+ _mesa_TexEnvi(GL_TEXTURE_ENV, GL_ALPHA_SCALE,
+ 1 << unit->Combine.ScaleShiftA);
+ }
+
+ /* Restore texture object state */
+ for (i = 0; i < NUM_TEXTURE_TARGETS; i++) {
+ GLenum target = 0;
+ const struct gl_texture_object *obj = NULL;
+ GLfloat bordColor[4];
+
+ switch (i) {
+ case 0:
+ target = GL_TEXTURE_1D;
+ obj = &unit->Saved1D;
+ break;
+ case 1:
+ target = GL_TEXTURE_2D;
+ obj = &unit->Saved2D;
+ break;
+ case 2:
+ target = GL_TEXTURE_3D;
+ obj = &unit->Saved3D;
+ break;
+ case 3:
+ if (!ctx->Extensions.ARB_texture_cube_map)
+ continue;
+ target = GL_TEXTURE_CUBE_MAP_ARB;
+ obj = &unit->SavedCubeMap;
+ break;
+ case 4:
+ if (!ctx->Extensions.NV_texture_rectangle)
+ continue;
+ target = GL_TEXTURE_RECTANGLE_NV;
+ obj = &unit->SavedRect;
+ break;
+ default:
+ ; /* silence warnings */
+ }
+
+ _mesa_BindTexture(target, obj->Name);
+
+ bordColor[0] = CHAN_TO_FLOAT(obj->BorderColor[0]);
+ bordColor[1] = CHAN_TO_FLOAT(obj->BorderColor[1]);
+ bordColor[2] = CHAN_TO_FLOAT(obj->BorderColor[2]);
+ bordColor[3] = CHAN_TO_FLOAT(obj->BorderColor[3]);
+
+ _mesa_TexParameterf(target, GL_TEXTURE_PRIORITY, obj->Priority);
+ _mesa_TexParameterfv(target, GL_TEXTURE_BORDER_COLOR, bordColor);
+ _mesa_TexParameteri(target, GL_TEXTURE_WRAP_S, obj->WrapS);
+ _mesa_TexParameteri(target, GL_TEXTURE_WRAP_T, obj->WrapT);
+ _mesa_TexParameteri(target, GL_TEXTURE_WRAP_R, obj->WrapR);
+ _mesa_TexParameteri(target, GL_TEXTURE_MIN_FILTER, obj->MinFilter);
+ _mesa_TexParameteri(target, GL_TEXTURE_MAG_FILTER, obj->MagFilter);
+ _mesa_TexParameterf(target, GL_TEXTURE_MIN_LOD, obj->MinLod);
+ _mesa_TexParameterf(target, GL_TEXTURE_MAX_LOD, obj->MaxLod);
+ _mesa_TexParameteri(target, GL_TEXTURE_BASE_LEVEL, obj->BaseLevel);
+ _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, obj->MaxLevel);
+ if (ctx->Extensions.EXT_texture_filter_anisotropic) {
+ _mesa_TexParameterf(target, GL_TEXTURE_MAX_ANISOTROPY_EXT,
+ obj->MaxAnisotropy);
+ }
+ if (ctx->Extensions.SGIX_shadow) {
+ _mesa_TexParameteri(target, GL_TEXTURE_COMPARE_SGIX,
+ obj->CompareFlag);
+ _mesa_TexParameteri(target, GL_TEXTURE_COMPARE_OPERATOR_SGIX,
+ obj->CompareOperator);
+ }
+ if (ctx->Extensions.SGIX_shadow_ambient) {
+ _mesa_TexParameterf(target, GL_SHADOW_AMBIENT_SGIX,
+ obj->ShadowAmbient);
+ }
+
+ }
+ }
+ _mesa_ActiveTextureARB(GL_TEXTURE0_ARB
+ + texAttrib->CurrentUnit);
+
+ /* "un-bump" the texture object reference counts. We did that so they
+ * wouldn't inadvertantly get deleted while they were still referenced
+ * inside the attribute state stack.
+ */
+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
+ ctx->Texture.Unit[u].Current1D->RefCount--;
+ ctx->Texture.Unit[u].Current2D->RefCount--;
+ ctx->Texture.Unit[u].Current3D->RefCount--;
+ ctx->Texture.Unit[u].CurrentCubeMap->RefCount--;
+ ctx->Texture.Unit[u].CurrentRect->RefCount--;
+ }
+}
+
+
+/*
+ * This function is kind of long just because we have to call a lot
+ * of device driver functions to update device driver state.
+ *
+ * XXX As it is now, most of the pop-code calls immediate-mode Mesa functions
+ * in order to restore GL state. This isn't terribly efficient but it
+ * ensures that dirty flags and any derived state gets updated correctly.
+ * We could at least check if the value to restore equals the current value
+ * and then skip the Mesa call.
+ */
+void GLAPIENTRY
+_mesa_PopAttrib(void)
+{
+ struct gl_attrib_node *attr, *next;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (ctx->AttribStackDepth == 0) {
+ _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopAttrib" );
+ return;
+ }
+
+ ctx->AttribStackDepth--;
+ attr = ctx->AttribStack[ctx->AttribStackDepth];
+
+ while (attr) {
+
+ if (MESA_VERBOSE & VERBOSE_API) {
+ _mesa_debug(ctx, "glPopAttrib %s\n",
+ _mesa_lookup_enum_by_nr(attr->kind));
+ }
+
+ switch (attr->kind) {
+ case GL_ACCUM_BUFFER_BIT:
+ {
+ const struct gl_accum_attrib *accum;
+ accum = (const struct gl_accum_attrib *) attr->data;
+ _mesa_ClearAccum(accum->ClearColor[0],
+ accum->ClearColor[1],
+ accum->ClearColor[2],
+ accum->ClearColor[3]);
+ }
+ break;
+ case GL_COLOR_BUFFER_BIT:
+ {
+ const struct gl_colorbuffer_attrib *color;
+ color = (const struct gl_colorbuffer_attrib *) attr->data;
+ _mesa_ClearIndex((GLfloat) color->ClearIndex);
+ _mesa_ClearColor(color->ClearColor[0],
+ color->ClearColor[1],
+ color->ClearColor[2],
+ color->ClearColor[3]);
+ _mesa_IndexMask(color->IndexMask);
+ _mesa_ColorMask((GLboolean) (color->ColorMask[0] != 0),
+ (GLboolean) (color->ColorMask[1] != 0),
+ (GLboolean) (color->ColorMask[2] != 0),
+ (GLboolean) (color->ColorMask[3] != 0));
+#if 0
+ _mesa_DrawBuffersARB(ctx->Const.MaxDrawBuffers,
+ color->DrawBuffer);
+#else
+ _mesa_drawbuffers(ctx, ctx->Const.MaxDrawBuffers,
+ color->DrawBuffer, NULL);
+#endif
+ _mesa_set_enable(ctx, GL_ALPHA_TEST, color->AlphaEnabled);
+ _mesa_AlphaFunc(color->AlphaFunc, color->AlphaRef);
+ _mesa_set_enable(ctx, GL_BLEND, color->BlendEnabled);
+ _mesa_BlendFuncSeparateEXT(color->BlendSrcRGB,
+ color->BlendDstRGB,
+ color->BlendSrcA,
+ color->BlendDstA);
+ /* This special case is because glBlendEquationSeparateEXT
+ * cannot take GL_LOGIC_OP as a parameter.
+ */
+ if ( color->BlendEquationRGB == color->BlendEquationA ) {
+ _mesa_BlendEquation(color->BlendEquationRGB);
+ }
+ else {
+ _mesa_BlendEquationSeparateEXT(color->BlendEquationRGB,
+ color->BlendEquationA);
+ }
+ _mesa_BlendColor(color->BlendColor[0],
+ color->BlendColor[1],
+ color->BlendColor[2],
+ color->BlendColor[3]);
+ _mesa_LogicOp(color->LogicOp);
+ _mesa_set_enable(ctx, GL_COLOR_LOGIC_OP,
+ color->ColorLogicOpEnabled);
+ _mesa_set_enable(ctx, GL_INDEX_LOGIC_OP,
+ color->IndexLogicOpEnabled);
+ _mesa_set_enable(ctx, GL_DITHER, color->DitherFlag);
+ }
+ break;
+ case GL_CURRENT_BIT:
+ FLUSH_CURRENT( ctx, 0 );
+ MEMCPY( &ctx->Current, attr->data,
+ sizeof(struct gl_current_attrib) );
+ break;
+ case GL_DEPTH_BUFFER_BIT:
+ {
+ const struct gl_depthbuffer_attrib *depth;
+ depth = (const struct gl_depthbuffer_attrib *) attr->data;
+ _mesa_DepthFunc(depth->Func);
+ _mesa_ClearDepth(depth->Clear);
+ _mesa_set_enable(ctx, GL_DEPTH_TEST, depth->Test);
+ _mesa_DepthMask(depth->Mask);
+ if (ctx->Extensions.HP_occlusion_test)
+ _mesa_set_enable(ctx, GL_OCCLUSION_TEST_HP,
+ depth->OcclusionTest);
+ }
+ break;
+ case GL_ENABLE_BIT:
+ {
+ const struct gl_enable_attrib *enable;
+ enable = (const struct gl_enable_attrib *) attr->data;
+ pop_enable_group(ctx, enable);
+ ctx->NewState |= _NEW_ALL;
+ }
+ break;
+ case GL_EVAL_BIT:
+ MEMCPY( &ctx->Eval, attr->data, sizeof(struct gl_eval_attrib) );
+ ctx->NewState |= _NEW_EVAL;
+ break;
+ case GL_FOG_BIT:
+ {
+ const struct gl_fog_attrib *fog;
+ fog = (const struct gl_fog_attrib *) attr->data;
+ _mesa_set_enable(ctx, GL_FOG, fog->Enabled);
+ _mesa_Fogfv(GL_FOG_COLOR, fog->Color);
+ _mesa_Fogf(GL_FOG_DENSITY, fog->Density);
+ _mesa_Fogf(GL_FOG_START, fog->Start);
+ _mesa_Fogf(GL_FOG_END, fog->End);
+ _mesa_Fogf(GL_FOG_INDEX, fog->Index);
+ _mesa_Fogi(GL_FOG_MODE, fog->Mode);
+ }
+ break;
+ case GL_HINT_BIT:
+ {
+ const struct gl_hint_attrib *hint;
+ hint = (const struct gl_hint_attrib *) attr->data;
+ _mesa_Hint(GL_PERSPECTIVE_CORRECTION_HINT,
+ hint->PerspectiveCorrection );
+ _mesa_Hint(GL_POINT_SMOOTH_HINT, hint->PointSmooth);
+ _mesa_Hint(GL_LINE_SMOOTH_HINT, hint->LineSmooth);
+ _mesa_Hint(GL_POLYGON_SMOOTH_HINT, hint->PolygonSmooth);
+ _mesa_Hint(GL_FOG_HINT, hint->Fog);
+ _mesa_Hint(GL_CLIP_VOLUME_CLIPPING_HINT_EXT,
+ hint->ClipVolumeClipping);
+ if (ctx->Extensions.ARB_texture_compression)
+ _mesa_Hint(GL_TEXTURE_COMPRESSION_HINT_ARB,
+ hint->TextureCompression);
+ }
+ break;
+ case GL_LIGHTING_BIT:
+ {
+ GLuint i;
+ const struct gl_light_attrib *light;
+ light = (const struct gl_light_attrib *) attr->data;
+ /* lighting enable */
+ _mesa_set_enable(ctx, GL_LIGHTING, light->Enabled);
+ /* per-light state */
+ if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top))
+ _math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
+
+ for (i = 0; i < MAX_LIGHTS; i++) {
+ GLenum lgt = (GLenum) (GL_LIGHT0 + i);
+ const struct gl_light *l = &light->Light[i];
+ GLfloat tmp[4];
+ _mesa_set_enable(ctx, lgt, l->Enabled);
+ _mesa_Lightfv( lgt, GL_AMBIENT, l->Ambient );
+ _mesa_Lightfv( lgt, GL_DIFFUSE, l->Diffuse );
+ _mesa_Lightfv( lgt, GL_SPECULAR, l->Specular );
+ TRANSFORM_POINT( tmp, ctx->ModelviewMatrixStack.Top->inv, l->EyePosition );
+ _mesa_Lightfv( lgt, GL_POSITION, tmp );
+ TRANSFORM_NORMAL( tmp, l->EyeDirection, ctx->ModelviewMatrixStack.Top->m );
+ _mesa_Lightfv( lgt, GL_SPOT_DIRECTION, tmp );
+ _mesa_Lightfv( lgt, GL_SPOT_EXPONENT, &l->SpotExponent );
+ _mesa_Lightfv( lgt, GL_SPOT_CUTOFF, &l->SpotCutoff );
+ _mesa_Lightfv( lgt, GL_CONSTANT_ATTENUATION,
+ &l->ConstantAttenuation );
+ _mesa_Lightfv( lgt, GL_LINEAR_ATTENUATION,
+ &l->LinearAttenuation );
+ _mesa_Lightfv( lgt, GL_QUADRATIC_ATTENUATION,
+ &l->QuadraticAttenuation );
+ }
+ /* light model */
+ _mesa_LightModelfv(GL_LIGHT_MODEL_AMBIENT,
+ light->Model.Ambient);
+ _mesa_LightModelf(GL_LIGHT_MODEL_LOCAL_VIEWER,
+ (GLfloat) light->Model.LocalViewer);
+ _mesa_LightModelf(GL_LIGHT_MODEL_TWO_SIDE,
+ (GLfloat) light->Model.TwoSide);
+ _mesa_LightModelf(GL_LIGHT_MODEL_COLOR_CONTROL,
+ (GLfloat) light->Model.ColorControl);
+ /* materials */
+ MEMCPY(&ctx->Light.Material, &light->Material,
+ sizeof(struct gl_material));
+ /* shade model */
+ _mesa_ShadeModel(light->ShadeModel);
+ /* color material */
+ _mesa_ColorMaterial(light->ColorMaterialFace,
+ light->ColorMaterialMode);
+ _mesa_set_enable(ctx, GL_COLOR_MATERIAL,
+ light->ColorMaterialEnabled);
+ }
+ break;
+ case GL_LINE_BIT:
+ {
+ const struct gl_line_attrib *line;
+ line = (const struct gl_line_attrib *) attr->data;
+ _mesa_set_enable(ctx, GL_LINE_SMOOTH, line->SmoothFlag);
+ _mesa_set_enable(ctx, GL_LINE_STIPPLE, line->StippleFlag);
+ _mesa_LineStipple(line->StippleFactor, line->StipplePattern);
+ _mesa_LineWidth(line->Width);
+ }
+ break;
+ case GL_LIST_BIT:
+ MEMCPY( &ctx->List, attr->data, sizeof(struct gl_list_attrib) );
+ break;
+ case GL_PIXEL_MODE_BIT:
+ MEMCPY( &ctx->Pixel, attr->data, sizeof(struct gl_pixel_attrib) );
+ /* XXX what other pixel state needs to be set by function calls? */
+ _mesa_ReadBuffer(ctx->Pixel.ReadBuffer);
+ ctx->NewState |= _NEW_PIXEL;
+ break;
+ case GL_POINT_BIT:
+ {
+ const struct gl_point_attrib *point;
+ point = (const struct gl_point_attrib *) attr->data;
+ _mesa_PointSize(point->Size);
+ _mesa_set_enable(ctx, GL_POINT_SMOOTH, point->SmoothFlag);
+ if (ctx->Extensions.EXT_point_parameters) {
+ _mesa_PointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT,
+ point->Params);
+ _mesa_PointParameterfEXT(GL_POINT_SIZE_MIN_EXT,
+ point->MinSize);
+ _mesa_PointParameterfEXT(GL_POINT_SIZE_MAX_EXT,
+ point->MaxSize);
+ _mesa_PointParameterfEXT(GL_POINT_FADE_THRESHOLD_SIZE_EXT,
+ point->Threshold);
+ }
+ if (ctx->Extensions.NV_point_sprite
+ || ctx->Extensions.ARB_point_sprite) {
+ GLuint u;
+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
+ _mesa_TexEnvi(GL_POINT_SPRITE_NV, GL_COORD_REPLACE_NV,
+ (GLint) point->CoordReplace[u]);
+ }
+ _mesa_set_enable(ctx, GL_POINT_SPRITE_NV,point->PointSprite);
+ _mesa_PointParameteriNV(GL_POINT_SPRITE_R_MODE_NV,
+ ctx->Point.SpriteRMode);
+ _mesa_PointParameterfEXT(GL_POINT_SPRITE_COORD_ORIGIN,
+ (GLfloat)ctx->Point.SpriteOrigin);
+ }
+ }
+ break;
+ case GL_POLYGON_BIT:
+ {
+ const struct gl_polygon_attrib *polygon;
+ polygon = (const struct gl_polygon_attrib *) attr->data;
+ _mesa_CullFace(polygon->CullFaceMode);
+ _mesa_FrontFace(polygon->FrontFace);
+ _mesa_PolygonMode(GL_FRONT, polygon->FrontMode);
+ _mesa_PolygonMode(GL_BACK, polygon->BackMode);
+ _mesa_PolygonOffset(polygon->OffsetFactor,
+ polygon->OffsetUnits);
+ _mesa_set_enable(ctx, GL_POLYGON_SMOOTH, polygon->SmoothFlag);
+ _mesa_set_enable(ctx, GL_POLYGON_STIPPLE, polygon->StippleFlag);
+ _mesa_set_enable(ctx, GL_CULL_FACE, polygon->CullFlag);
+ _mesa_set_enable(ctx, GL_POLYGON_OFFSET_POINT,
+ polygon->OffsetPoint);
+ _mesa_set_enable(ctx, GL_POLYGON_OFFSET_LINE,
+ polygon->OffsetLine);
+ _mesa_set_enable(ctx, GL_POLYGON_OFFSET_FILL,
+ polygon->OffsetFill);
+ }
+ break;
+ case GL_POLYGON_STIPPLE_BIT:
+ MEMCPY( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) );
+ ctx->NewState |= _NEW_POLYGONSTIPPLE;
+ if (ctx->Driver.PolygonStipple)
+ ctx->Driver.PolygonStipple( ctx, (const GLubyte *) attr->data );
+ break;
+ case GL_SCISSOR_BIT:
+ {
+ const struct gl_scissor_attrib *scissor;
+ scissor = (const struct gl_scissor_attrib *) attr->data;
+ _mesa_Scissor(scissor->X, scissor->Y,
+ scissor->Width, scissor->Height);
+ _mesa_set_enable(ctx, GL_SCISSOR_TEST, scissor->Enabled);
+ }
+ break;
+ case GL_STENCIL_BUFFER_BIT:
+ {
+ GLint face;
+ const struct gl_stencil_attrib *stencil;
+ stencil = (const struct gl_stencil_attrib *) attr->data;
+ _mesa_set_enable(ctx, GL_STENCIL_TEST, stencil->Enabled);
+ _mesa_ClearStencil(stencil->Clear);
+ face = stencil->ActiveFace;
+ if (ctx->Extensions.EXT_stencil_two_side) {
+ _mesa_set_enable(ctx, GL_STENCIL_TEST_TWO_SIDE_EXT, stencil->TestTwoSide);
+ face ^= 1;
+ }
+ do {
+ _mesa_ActiveStencilFaceEXT(face);
+ _mesa_StencilFunc(stencil->Function[face], stencil->Ref[face],
+ stencil->ValueMask[face]);
+ _mesa_StencilMask(stencil->WriteMask[face]);
+ _mesa_StencilOp(stencil->FailFunc[face],
+ stencil->ZFailFunc[face],
+ stencil->ZPassFunc[face]);
+ face ^= 1;
+ } while (face != (stencil->ActiveFace ^ 1));
+ }
+ break;
+ case GL_TRANSFORM_BIT:
+ {
+ GLuint i;
+ const struct gl_transform_attrib *xform;
+ xform = (const struct gl_transform_attrib *) attr->data;
+ _mesa_MatrixMode(xform->MatrixMode);
+ if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top))
+ _math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
+
+ /* restore clip planes */
+ for (i = 0; i < MAX_CLIP_PLANES; i++) {
+ const GLuint mask = 1 << 1;
+ const GLfloat *eyePlane = xform->EyeUserPlane[i];
+ COPY_4V(ctx->Transform.EyeUserPlane[i], eyePlane);
+ if (xform->ClipPlanesEnabled & mask) {
+ _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_TRUE);
+ }
+ else {
+ _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_FALSE);
+ }
+ if (ctx->Driver.ClipPlane)
+ ctx->Driver.ClipPlane( ctx, GL_CLIP_PLANE0 + i, eyePlane );
+ }
+
+ /* normalize/rescale */
+ if (xform->Normalize != ctx->Transform.Normalize)
+ _mesa_set_enable(ctx, GL_NORMALIZE,ctx->Transform.Normalize);
+ if (xform->RescaleNormals != ctx->Transform.RescaleNormals)
+ _mesa_set_enable(ctx, GL_RESCALE_NORMAL_EXT,
+ ctx->Transform.RescaleNormals);
+ }
+ break;
+ case GL_TEXTURE_BIT:
+ /* Take care of texture object reference counters */
+ {
+ const struct gl_texture_attrib *texture;
+ texture = (const struct gl_texture_attrib *) attr->data;
+ pop_texture_group(ctx, texture);
+ ctx->NewState |= _NEW_TEXTURE;
+ }
+ break;
+ case GL_VIEWPORT_BIT:
+ {
+ const struct gl_viewport_attrib *vp;
+ vp = (const struct gl_viewport_attrib *) attr->data;
+ _mesa_Viewport(vp->X, vp->Y, vp->Width, vp->Height);
+ _mesa_DepthRange(vp->Near, vp->Far);
+ }
+ break;
+ case GL_MULTISAMPLE_BIT_ARB:
+ {
+ const struct gl_multisample_attrib *ms;
+ ms = (const struct gl_multisample_attrib *) attr->data;
+ _mesa_SampleCoverageARB(ms->SampleCoverageValue,
+ ms->SampleCoverageInvert);
+ }
+ break;
+
+ default:
+ _mesa_problem( ctx, "Bad attrib flag in PopAttrib");
+ break;
+ }
+
+ next = attr->next;
+ FREE( attr->data );
+ FREE( attr );
+ attr = next;
+ }
+}
+
+
+/**
+ * Helper for incrementing/decrementing vertex buffer object reference
+ * counts when pushing/popping the GL_CLIENT_VERTEX_ARRAY_BIT attribute group.
+ */
+static void
+adjust_buffer_object_ref_counts(struct gl_array_attrib *array, GLint step)
+{
+ GLuint i;
+ array->Vertex.BufferObj->RefCount += step;
+ array->Normal.BufferObj->RefCount += step;
+ array->Color.BufferObj->RefCount += step;
+ array->SecondaryColor.BufferObj->RefCount += step;
+ array->FogCoord.BufferObj->RefCount += step;
+ array->Index.BufferObj->RefCount += step;
+ array->EdgeFlag.BufferObj->RefCount += step;
+ for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++)
+ array->TexCoord[i].BufferObj->RefCount += step;
+ for (i = 0; i < VERT_ATTRIB_MAX; i++)
+ array->VertexAttrib[i].BufferObj->RefCount += step;
+
+ array->ArrayBufferObj->RefCount += step;
+ array->ElementArrayBufferObj->RefCount += step;
+}
+
+
+#define GL_CLIENT_PACK_BIT (1<<20)
+#define GL_CLIENT_UNPACK_BIT (1<<21)
+
+
+void GLAPIENTRY
+_mesa_PushClientAttrib(GLbitfield mask)
+{
+ struct gl_attrib_node *newnode;
+ struct gl_attrib_node *head;
+
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (ctx->ClientAttribStackDepth >= MAX_CLIENT_ATTRIB_STACK_DEPTH) {
+ _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushClientAttrib" );
+ return;
+ }
+
+ /* Build linked list of attribute nodes which save all attribute */
+ /* groups specified by the mask. */
+ head = NULL;
+
+ if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
+ struct gl_pixelstore_attrib *attr;
+#if FEATURE_EXT_pixel_buffer_object
+ ctx->Pack.BufferObj->RefCount++;
+ ctx->Unpack.BufferObj->RefCount++;
+#endif
+ /* packing attribs */
+ attr = MALLOC_STRUCT( gl_pixelstore_attrib );
+ MEMCPY( attr, &ctx->Pack, sizeof(struct gl_pixelstore_attrib) );
+ newnode = new_attrib_node( GL_CLIENT_PACK_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ /* unpacking attribs */
+ attr = MALLOC_STRUCT( gl_pixelstore_attrib );
+ MEMCPY( attr, &ctx->Unpack, sizeof(struct gl_pixelstore_attrib) );
+ newnode = new_attrib_node( GL_CLIENT_UNPACK_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ }
+ if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
+ struct gl_array_attrib *attr;
+ attr = MALLOC_STRUCT( gl_array_attrib );
+ MEMCPY( attr, &ctx->Array, sizeof(struct gl_array_attrib) );
+ newnode = new_attrib_node( GL_CLIENT_VERTEX_ARRAY_BIT );
+ newnode->data = attr;
+ newnode->next = head;
+ head = newnode;
+ /* bump reference counts on buffer objects */
+ adjust_buffer_object_ref_counts(&ctx->Array, 1);
+ }
+
+ ctx->ClientAttribStack[ctx->ClientAttribStackDepth] = head;
+ ctx->ClientAttribStackDepth++;
+}
+
+
+
+
+void GLAPIENTRY
+_mesa_PopClientAttrib(void)
+{
+ struct gl_attrib_node *attr, *next;
+
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (ctx->ClientAttribStackDepth == 0) {
+ _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopClientAttrib" );
+ return;
+ }
+
+ ctx->ClientAttribStackDepth--;
+ attr = ctx->ClientAttribStack[ctx->ClientAttribStackDepth];
+
+ while (attr) {
+ switch (attr->kind) {
+ case GL_CLIENT_PACK_BIT:
+#if FEATURE_EXT_pixel_buffer_object
+ ctx->Pack.BufferObj->RefCount--;
+ if (ctx->Pack.BufferObj->RefCount <= 0) {
+ _mesa_remove_buffer_object( ctx, ctx->Pack.BufferObj );
+ (*ctx->Driver.DeleteBuffer)( ctx, ctx->Pack.BufferObj );
+ }
+#endif
+ MEMCPY( &ctx->Pack, attr->data,
+ sizeof(struct gl_pixelstore_attrib) );
+ ctx->NewState |= _NEW_PACKUNPACK;
+ break;
+ case GL_CLIENT_UNPACK_BIT:
+#if FEATURE_EXT_pixel_buffer_object
+ ctx->Unpack.BufferObj->RefCount--;
+ if (ctx->Unpack.BufferObj->RefCount <= 0) {
+ _mesa_remove_buffer_object( ctx, ctx->Unpack.BufferObj );
+ (*ctx->Driver.DeleteBuffer)( ctx, ctx->Unpack.BufferObj );
+ }
+#endif
+ MEMCPY( &ctx->Unpack, attr->data,
+ sizeof(struct gl_pixelstore_attrib) );
+ ctx->NewState |= _NEW_PACKUNPACK;
+ break;
+ case GL_CLIENT_VERTEX_ARRAY_BIT:
+ adjust_buffer_object_ref_counts(&ctx->Array, -1);
+ MEMCPY( &ctx->Array, attr->data,
+ sizeof(struct gl_array_attrib) );
+ /* decrement reference counts on buffer objects */
+ ctx->NewState |= _NEW_ARRAY;
+ break;
+ default:
+ _mesa_problem( ctx, "Bad attrib flag in PopClientAttrib");
+ break;
+ }
+
+ next = attr->next;
+ FREE( attr->data );
+ FREE( attr );
+ attr = next;
+ }
+}
+
+
+void _mesa_init_attrib( GLcontext *ctx )
+{
+ /* Renderer and client attribute stacks */
+ ctx->AttribStackDepth = 0;
+ ctx->ClientAttribStackDepth = 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/attrib.h b/nx-X11/extras/Mesa/src/mesa/main/attrib.h
new file mode 100644
index 000000000..09d75196b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/attrib.h
@@ -0,0 +1,68 @@
+/**
+ * \file attrib.h
+ * Attribute stacks.
+ *
+ * \if subset
+ * (No-op)
+ *
+ * \endif
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+
+#ifndef ATTRIB_H
+#define ATTRIB_H
+
+
+#include "mtypes.h"
+
+
+#if _HAVE_FULL_GL
+
+extern void GLAPIENTRY
+_mesa_PushAttrib( GLbitfield mask );
+
+extern void GLAPIENTRY
+_mesa_PopAttrib( void );
+
+extern void GLAPIENTRY
+_mesa_PushClientAttrib( GLbitfield mask );
+
+extern void GLAPIENTRY
+_mesa_PopClientAttrib( void );
+
+extern void
+_mesa_init_attrib( GLcontext *ctx );
+
+#else
+
+/** No-op */
+#define _mesa_init_attrib( c ) ((void)0)
+
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/blend.c b/nx-X11/extras/Mesa/src/mesa/main/blend.c
new file mode 100644
index 000000000..61b2b17c0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/blend.c
@@ -0,0 +1,579 @@
+/**
+ * \file blend.c
+ * Blending operations.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+
+#include "glheader.h"
+#include "blend.h"
+#include "colormac.h"
+#include "context.h"
+#include "enums.h"
+#include "macros.h"
+#include "mtypes.h"
+
+
+/**
+ * Specify the blending operation.
+ *
+ * \param sfactor source factor operator.
+ * \param dfactor destination factor operator.
+ *
+ * \sa glBlendFunc, glBlendFuncSeparateEXT
+ *
+ * Swizzles the inputs and calls \c glBlendFuncSeparateEXT. This is done
+ * using the \c CurrentDispatch table in the context, so this same function
+ * can be used while compiling display lists. Therefore, there is no need
+ * for the display list code to save and restore this function.
+ */
+void GLAPIENTRY
+_mesa_BlendFunc( GLenum sfactor, GLenum dfactor )
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ (*ctx->CurrentDispatch->BlendFuncSeparateEXT)( sfactor, dfactor,
+ sfactor, dfactor );
+}
+
+
+/**
+ * Process GL_EXT_blend_func_separate().
+ *
+ * \param sfactorRGB RGB source factor operator.
+ * \param dfactorRGB RGB destination factor operator.
+ * \param sfactorA alpha source factor operator.
+ * \param dfactorA alpha destination factor operator.
+ *
+ * Verifies the parameters and updates gl_colorbuffer_attrib.
+ * On a change, flush the vertices and notify the driver via
+ * dd_function_table::BlendFuncSeparate.
+ */
+void GLAPIENTRY
+_mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB,
+ GLenum sfactorA, GLenum dfactorA )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
+ _mesa_debug(ctx, "glBlendFuncSeparate %s %s %s %s\n",
+ _mesa_lookup_enum_by_nr(sfactorRGB),
+ _mesa_lookup_enum_by_nr(dfactorRGB),
+ _mesa_lookup_enum_by_nr(sfactorA),
+ _mesa_lookup_enum_by_nr(dfactorA));
+
+ switch (sfactorRGB) {
+ case GL_SRC_COLOR:
+ case GL_ONE_MINUS_SRC_COLOR:
+ if (!ctx->Extensions.NV_blend_square) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorRGB)");
+ return;
+ }
+ /* fall-through */
+ case GL_ZERO:
+ case GL_ONE:
+ case GL_DST_COLOR:
+ case GL_ONE_MINUS_DST_COLOR:
+ case GL_SRC_ALPHA:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ case GL_DST_ALPHA:
+ case GL_ONE_MINUS_DST_ALPHA:
+ case GL_SRC_ALPHA_SATURATE:
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorRGB)");
+ return;
+ }
+
+ switch (dfactorRGB) {
+ case GL_DST_COLOR:
+ case GL_ONE_MINUS_DST_COLOR:
+ if (!ctx->Extensions.NV_blend_square) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorRGB)");
+ return;
+ }
+ /* fall-through */
+ case GL_ZERO:
+ case GL_ONE:
+ case GL_SRC_COLOR:
+ case GL_ONE_MINUS_SRC_COLOR:
+ case GL_SRC_ALPHA:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ case GL_DST_ALPHA:
+ case GL_ONE_MINUS_DST_ALPHA:
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorRGB)");
+ return;
+ }
+
+ switch (sfactorA) {
+ case GL_SRC_COLOR:
+ case GL_ONE_MINUS_SRC_COLOR:
+ if (!ctx->Extensions.NV_blend_square) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorA)");
+ return;
+ }
+ /* fall-through */
+ case GL_ZERO:
+ case GL_ONE:
+ case GL_DST_COLOR:
+ case GL_ONE_MINUS_DST_COLOR:
+ case GL_SRC_ALPHA:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ case GL_DST_ALPHA:
+ case GL_ONE_MINUS_DST_ALPHA:
+ case GL_SRC_ALPHA_SATURATE:
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (sfactorA)");
+ return;
+ }
+
+ switch (dfactorA) {
+ case GL_DST_COLOR:
+ case GL_ONE_MINUS_DST_COLOR:
+ if (!ctx->Extensions.NV_blend_square) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorA)");
+ return;
+ }
+ /* fall-through */
+ case GL_ZERO:
+ case GL_ONE:
+ case GL_SRC_COLOR:
+ case GL_ONE_MINUS_SRC_COLOR:
+ case GL_SRC_ALPHA:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ case GL_DST_ALPHA:
+ case GL_ONE_MINUS_DST_ALPHA:
+ case GL_CONSTANT_COLOR:
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ case GL_CONSTANT_ALPHA:
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBlendFunc or glBlendFuncSeparate (dfactorA)" );
+ return;
+ }
+
+ if (ctx->Color.BlendSrcRGB == sfactorRGB &&
+ ctx->Color.BlendDstRGB == dfactorRGB &&
+ ctx->Color.BlendSrcA == sfactorA &&
+ ctx->Color.BlendDstA == dfactorA)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_COLOR);
+
+ ctx->Color.BlendSrcRGB = sfactorRGB;
+ ctx->Color.BlendDstRGB = dfactorRGB;
+ ctx->Color.BlendSrcA = sfactorA;
+ ctx->Color.BlendDstA = dfactorA;
+
+ if (ctx->Driver.BlendFuncSeparate) {
+ (*ctx->Driver.BlendFuncSeparate)( ctx, sfactorRGB, dfactorRGB,
+ sfactorA, dfactorA );
+ }
+}
+
+
+#if _HAVE_FULL_GL
+
+static GLboolean
+_mesa_validate_blend_equation( GLcontext *ctx,
+ GLenum mode, GLboolean is_separate )
+{
+ switch (mode) {
+ case GL_FUNC_ADD:
+ break;
+ case GL_MIN:
+ case GL_MAX:
+ if (!ctx->Extensions.EXT_blend_minmax &&
+ !ctx->Extensions.ARB_imaging) {
+ return GL_FALSE;
+ }
+ break;
+ /* glBlendEquationSeparate cannot take GL_LOGIC_OP as a parameter.
+ */
+ case GL_LOGIC_OP:
+ if (!ctx->Extensions.EXT_blend_logic_op || is_separate) {
+ return GL_FALSE;
+ }
+ break;
+ case GL_FUNC_SUBTRACT:
+ case GL_FUNC_REVERSE_SUBTRACT:
+ if (!ctx->Extensions.EXT_blend_subtract &&
+ !ctx->Extensions.ARB_imaging) {
+ return GL_FALSE;
+ }
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+
+/* This is really an extension function! */
+void GLAPIENTRY
+_mesa_BlendEquation( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
+ _mesa_debug(ctx, "glBlendEquation %s\n",
+ _mesa_lookup_enum_by_nr(mode));
+
+ if ( ! _mesa_validate_blend_equation( ctx, mode, GL_FALSE ) ) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquation");
+ return;
+ }
+
+ if ( (ctx->Color.BlendEquationRGB == mode) &&
+ (ctx->Color.BlendEquationA == mode) )
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_COLOR);
+ ctx->Color.BlendEquationRGB = mode;
+ ctx->Color.BlendEquationA = mode;
+
+ /* This is needed to support 1.1's RGB logic ops AND
+ * 1.0's blending logicops.
+ */
+ ctx->Color._LogicOpEnabled = (ctx->Color.ColorLogicOpEnabled ||
+ (ctx->Color.BlendEnabled &&
+ mode == GL_LOGIC_OP));
+
+ if (ctx->Driver.BlendEquationSeparate)
+ (*ctx->Driver.BlendEquationSeparate)( ctx, mode, mode );
+}
+
+
+void GLAPIENTRY
+_mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
+ _mesa_debug(ctx, "glBlendEquationSeparateEXT %s %s\n",
+ _mesa_lookup_enum_by_nr(modeRGB),
+ _mesa_lookup_enum_by_nr(modeA));
+
+ if ( (modeRGB != modeA) && !ctx->Extensions.EXT_blend_equation_separate ) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBlendEquationSeparateEXT not supported by driver");
+ return;
+ }
+
+ if ( ! _mesa_validate_blend_equation( ctx, modeRGB, GL_TRUE ) ) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparateEXT(modeRGB)");
+ return;
+ }
+
+ if ( ! _mesa_validate_blend_equation( ctx, modeA, GL_TRUE ) ) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBlendEquationSeparateEXT(modeA)");
+ return;
+ }
+
+
+ if ( (ctx->Color.BlendEquationRGB == modeRGB) &&
+ (ctx->Color.BlendEquationA == modeA) )
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_COLOR);
+ ctx->Color.BlendEquationRGB = modeRGB;
+ ctx->Color.BlendEquationA = modeA;
+
+ /* This is needed to support 1.1's RGB logic ops AND
+ * 1.0's blending logicops. This test is simplified over glBlendEquation
+ * because modeRGB cannot be GL_LOGIC_OP.
+ */
+ ctx->Color._LogicOpEnabled = (ctx->Color.ColorLogicOpEnabled);
+
+ if (ctx->Driver.BlendEquationSeparate)
+ (*ctx->Driver.BlendEquationSeparate)( ctx, modeRGB, modeA );
+}
+#endif
+
+
+/**
+ * Set the blending color.
+ *
+ * \param red red color component.
+ * \param green green color component.
+ * \param blue blue color component.
+ * \param alpha alpha color component.
+ *
+ * \sa glBlendColor().
+ *
+ * Clamps the parameters and updates gl_colorbuffer_attrib::BlendColor. On a
+ * change, flushes the vertices and notifies the driver via
+ * dd_function_table::BlendColor callback.
+ */
+void GLAPIENTRY
+_mesa_BlendColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
+{
+ GLfloat tmp[4];
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ tmp[0] = CLAMP( red, 0.0F, 1.0F );
+ tmp[1] = CLAMP( green, 0.0F, 1.0F );
+ tmp[2] = CLAMP( blue, 0.0F, 1.0F );
+ tmp[3] = CLAMP( alpha, 0.0F, 1.0F );
+
+ if (TEST_EQ_4V(tmp, ctx->Color.BlendColor))
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_COLOR);
+ COPY_4FV( ctx->Color.BlendColor, tmp );
+
+ if (ctx->Driver.BlendColor)
+ (*ctx->Driver.BlendColor)(ctx, tmp);
+}
+
+
+/**
+ * Specify the alpha test function.
+ *
+ * \param func alpha comparison function.
+ * \param ref reference value.
+ *
+ * Verifies the parameters and updates gl_colorbuffer_attrib.
+ * On a change, flushes the vertices and notifies the driver via
+ * dd_function_table::AlphaFunc callback.
+ */
+void GLAPIENTRY
+_mesa_AlphaFunc( GLenum func, GLclampf ref )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ switch (func) {
+ case GL_NEVER:
+ case GL_LESS:
+ case GL_EQUAL:
+ case GL_LEQUAL:
+ case GL_GREATER:
+ case GL_NOTEQUAL:
+ case GL_GEQUAL:
+ case GL_ALWAYS:
+ ref = CLAMP(ref, 0.0F, 1.0F);
+
+ if (ctx->Color.AlphaFunc == func && ctx->Color.AlphaRef == ref)
+ return; /* no change */
+
+ FLUSH_VERTICES(ctx, _NEW_COLOR);
+ ctx->Color.AlphaFunc = func;
+ ctx->Color.AlphaRef = ref;
+
+ if (ctx->Driver.AlphaFunc)
+ ctx->Driver.AlphaFunc(ctx, func, ref);
+ return;
+
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glAlphaFunc(func)" );
+ return;
+ }
+}
+
+
+/**
+ * Specify a logic pixel operation for color index rendering.
+ *
+ * \param opcode operation.
+ *
+ * Verifies that \p opcode is a valid enum and updates
+gl_colorbuffer_attrib::LogicOp.
+ * On a change, flushes the vertices and notifies the driver via the
+ * dd_function_table::LogicOpcode callback.
+ */
+void GLAPIENTRY
+_mesa_LogicOp( GLenum opcode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ switch (opcode) {
+ case GL_CLEAR:
+ case GL_SET:
+ case GL_COPY:
+ case GL_COPY_INVERTED:
+ case GL_NOOP:
+ case GL_INVERT:
+ case GL_AND:
+ case GL_NAND:
+ case GL_OR:
+ case GL_NOR:
+ case GL_XOR:
+ case GL_EQUIV:
+ case GL_AND_REVERSE:
+ case GL_AND_INVERTED:
+ case GL_OR_REVERSE:
+ case GL_OR_INVERTED:
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glLogicOp" );
+ return;
+ }
+
+ if (ctx->Color.LogicOp == opcode)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_COLOR);
+ ctx->Color.LogicOp = opcode;
+
+ if (ctx->Driver.LogicOpcode)
+ ctx->Driver.LogicOpcode( ctx, opcode );
+}
+
+#if _HAVE_FULL_GL
+void GLAPIENTRY
+_mesa_IndexMask( GLuint mask )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (ctx->Color.IndexMask == mask)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_COLOR);
+ ctx->Color.IndexMask = mask;
+
+ if (ctx->Driver.IndexMask)
+ ctx->Driver.IndexMask( ctx, mask );
+}
+#endif
+
+
+/**
+ * Enable or disable writing of frame buffer color components.
+ *
+ * \param red whether to mask writing of the red color component.
+ * \param green whether to mask writing of the green color component.
+ * \param blue whether to mask writing of the blue color component.
+ * \param alpha whether to mask writing of the alpha color component.
+ *
+ * \sa glColorMask().
+ *
+ * Sets the appropriate value of gl_colorbuffer_attrib::ColorMask. On a
+ * change, flushes the vertices and notifies the driver via the
+ * dd_function_table::ColorMask callback.
+ */
+void GLAPIENTRY
+_mesa_ColorMask( GLboolean red, GLboolean green,
+ GLboolean blue, GLboolean alpha )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLubyte tmp[4];
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glColorMask %d %d %d %d\n", red, green, blue, alpha);
+
+ /* Shouldn't have any information about channel depth in core mesa
+ * -- should probably store these as the native booleans:
+ */
+ tmp[RCOMP] = red ? 0xff : 0x0;
+ tmp[GCOMP] = green ? 0xff : 0x0;
+ tmp[BCOMP] = blue ? 0xff : 0x0;
+ tmp[ACOMP] = alpha ? 0xff : 0x0;
+
+ if (TEST_EQ_4UBV(tmp, ctx->Color.ColorMask))
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_COLOR);
+ COPY_4UBV(ctx->Color.ColorMask, tmp);
+
+ if (ctx->Driver.ColorMask)
+ ctx->Driver.ColorMask( ctx, red, green, blue, alpha );
+}
+
+
+/**********************************************************************/
+/** \name Initialization */
+/*@{*/
+
+/**
+ * Initialization of the context's Color attribute group.
+ *
+ * \param ctx GL context.
+ *
+ * Initializes the related fields in the context color attribute group,
+ * __GLcontextRec::Color.
+ */
+void _mesa_init_color( GLcontext * ctx )
+{
+ /* Color buffer group */
+ ctx->Color.IndexMask = ~0u;
+ ctx->Color.ColorMask[0] = 0xff;
+ ctx->Color.ColorMask[1] = 0xff;
+ ctx->Color.ColorMask[2] = 0xff;
+ ctx->Color.ColorMask[3] = 0xff;
+ ctx->Color.ClearIndex = 0;
+ ASSIGN_4V( ctx->Color.ClearColor, 0, 0, 0, 0 );
+ ctx->Color.AlphaEnabled = GL_FALSE;
+ ctx->Color.AlphaFunc = GL_ALWAYS;
+ ctx->Color.AlphaRef = 0;
+ ctx->Color.BlendEnabled = GL_FALSE;
+ ctx->Color.BlendSrcRGB = GL_ONE;
+ ctx->Color.BlendDstRGB = GL_ZERO;
+ ctx->Color.BlendSrcA = GL_ONE;
+ ctx->Color.BlendDstA = GL_ZERO;
+ ctx->Color.BlendEquationRGB = GL_FUNC_ADD;
+ ctx->Color.BlendEquationA = GL_FUNC_ADD;
+ ASSIGN_4V( ctx->Color.BlendColor, 0.0, 0.0, 0.0, 0.0 );
+ ctx->Color.IndexLogicOpEnabled = GL_FALSE;
+ ctx->Color.ColorLogicOpEnabled = GL_FALSE;
+ ctx->Color._LogicOpEnabled = GL_FALSE;
+ ctx->Color.LogicOp = GL_COPY;
+ ctx->Color.DitherFlag = GL_TRUE;
+
+ if (ctx->Visual.doubleBufferMode) {
+ ctx->Color.DrawBuffer[0] = GL_BACK;
+ }
+ else {
+ ctx->Color.DrawBuffer[0] = GL_FRONT;
+ }
+}
+
+/*@}*/
diff --git a/nx-X11/extras/Mesa/src/mesa/main/blend.h b/nx-X11/extras/Mesa/src/mesa/main/blend.h
new file mode 100644
index 000000000..d6c03d903
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/blend.h
@@ -0,0 +1,78 @@
+/**
+ * \file blend.h
+ * Blending functions operations.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+
+#ifndef BLEND_H
+#define BLEND_H
+
+
+#include "mtypes.h"
+
+
+extern void GLAPIENTRY
+_mesa_BlendFunc( GLenum sfactor, GLenum dfactor );
+
+
+extern void GLAPIENTRY
+_mesa_BlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB,
+ GLenum sfactorA, GLenum dfactorA );
+
+
+extern void GLAPIENTRY
+_mesa_BlendEquation( GLenum mode );
+
+
+extern void GLAPIENTRY
+_mesa_BlendEquationSeparateEXT( GLenum modeRGB, GLenum modeA );
+
+
+extern void GLAPIENTRY
+_mesa_BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+
+
+extern void GLAPIENTRY
+_mesa_AlphaFunc( GLenum func, GLclampf ref );
+
+
+extern void GLAPIENTRY
+_mesa_LogicOp( GLenum opcode );
+
+
+extern void GLAPIENTRY
+_mesa_IndexMask( GLuint mask );
+
+extern void GLAPIENTRY
+_mesa_ColorMask( GLboolean red, GLboolean green,
+ GLboolean blue, GLboolean alpha );
+
+extern void
+_mesa_init_color( GLcontext * ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/bufferobj.c b/nx-X11/extras/Mesa/src/mesa/main/bufferobj.c
new file mode 100644
index 000000000..a1d4c0190
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/bufferobj.c
@@ -0,0 +1,940 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file bufferobj.c
+ * \brief Functions for the GL_ARB_vertex_buffer_object extension.
+ * \author Brian Paul, Ian Romanick
+ */
+
+
+#include "glheader.h"
+#include "hash.h"
+#include "imports.h"
+#include "image.h"
+#include "context.h"
+#include "bufferobj.h"
+
+
+/**
+ * Get the buffer object bound to the specified target in a GL context.
+ *
+ * \param ctx GL context
+ * \param target Buffer object target to be retrieved. Currently this must
+ * be either \c GL_ARRAY_BUFFER or \c GL_ELEMENT_ARRAY_BUFFER.
+ * \param str Name of caller for logging errors.
+ * \return A pointer to the buffer object bound to \c target in the
+ * specified context or \c NULL if \c target is invalid or no
+ * buffer object is bound.
+ */
+static INLINE struct gl_buffer_object *
+buffer_object_get_target( GLcontext *ctx, GLenum target, const char * str )
+{
+ struct gl_buffer_object * bufObj = NULL;
+
+ switch (target) {
+ case GL_ARRAY_BUFFER_ARB:
+ bufObj = ctx->Array.ArrayBufferObj;
+ break;
+ case GL_ELEMENT_ARRAY_BUFFER_ARB:
+ bufObj = ctx->Array.ElementArrayBufferObj;
+ break;
+ case GL_PIXEL_PACK_BUFFER_EXT:
+ bufObj = ctx->Pack.BufferObj;
+ break;
+ case GL_PIXEL_UNPACK_BUFFER_EXT:
+ bufObj = ctx->Unpack.BufferObj;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(target)", str);
+ return NULL;
+ }
+
+ if (bufObj->Name == 0)
+ return NULL;
+
+ return bufObj;
+}
+
+
+/**
+ * Tests the subdata range parameters and sets the GL error code for
+ * \c glBufferSubDataARB and \c glGetBufferSubDataARB.
+ *
+ * \param ctx GL context.
+ * \param target Buffer object target on which to operate.
+ * \param offset Offset of the first byte of the subdata range.
+ * \param size Size, in bytes, of the subdata range.
+ * \param str Name of caller for logging errors.
+ * \return A pointer to the buffer object bound to \c target in the
+ * specified context or \c NULL if any of the parameter or state
+ * conditions for \c glBufferSubDataARB or \c glGetBufferSubDataARB
+ * are invalid.
+ *
+ * \sa glBufferSubDataARB, glGetBufferSubDataARB
+ */
+static struct gl_buffer_object *
+buffer_object_subdata_range_good( GLcontext * ctx, GLenum target,
+ GLintptrARB offset, GLsizeiptrARB size,
+ const char * str )
+{
+ struct gl_buffer_object *bufObj;
+
+ if (size < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(size < 0)", str);
+ return NULL;
+ }
+
+ if (offset < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "%s(offset < 0)", str);
+ return NULL;
+ }
+
+ bufObj = buffer_object_get_target( ctx, target, str );
+ if (!bufObj || bufObj->Name == 0) {
+ return NULL;
+ }
+
+ if ((GLuint) (offset + size) > bufObj->Size) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "%s(size + offset > buffer size)", str);
+ return NULL;
+ }
+
+ if (bufObj->Pointer) {
+ /* Buffer is currently mapped */
+ _mesa_error(ctx, GL_INVALID_OPERATION, "%s", str);
+ return NULL;
+ }
+
+ return bufObj;
+}
+
+
+/**
+ * Allocate and initialize a new buffer object.
+ *
+ * This function is intended to be called via
+ * \c dd_function_table::NewBufferObject.
+ */
+struct gl_buffer_object *
+_mesa_new_buffer_object( GLcontext *ctx, GLuint name, GLenum target )
+{
+ struct gl_buffer_object *obj;
+
+ (void) ctx;
+
+ obj = MALLOC_STRUCT(gl_buffer_object);
+ _mesa_initialize_buffer_object(obj, name, target);
+ return obj;
+}
+
+
+/**
+ * Delete a buffer object.
+ *
+ * This function is intended to be called via
+ * \c dd_function_table::DeleteBuffer.
+ */
+void
+_mesa_delete_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
+{
+ (void) ctx;
+
+ if (bufObj->Data)
+ _mesa_free(bufObj->Data);
+ _mesa_free(bufObj);
+}
+
+
+/**
+ * Initialize a buffer object to default values.
+ */
+void
+_mesa_initialize_buffer_object( struct gl_buffer_object *obj,
+ GLuint name, GLenum target )
+{
+ (void) target;
+
+ _mesa_bzero(obj, sizeof(struct gl_buffer_object));
+ obj->RefCount = 1;
+ obj->Name = name;
+ obj->Usage = GL_STATIC_DRAW_ARB;
+ obj->Access = GL_READ_WRITE_ARB;
+}
+
+
+/**
+ * Add the given buffer object to the buffer object pool.
+ */
+void
+_mesa_save_buffer_object( GLcontext *ctx, struct gl_buffer_object *obj )
+{
+ if (obj->Name > 0) {
+ /* insert into hash table */
+ _mesa_HashInsert(ctx->Shared->BufferObjects, obj->Name, obj);
+ }
+}
+
+
+/**
+ * Remove the given buffer object from the buffer object pool.
+ * Do not deallocate the buffer object though.
+ */
+void
+_mesa_remove_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj )
+{
+ if (bufObj->Name > 0) {
+ /* remove from hash table */
+ _mesa_HashRemove(ctx->Shared->BufferObjects, bufObj->Name);
+ }
+}
+
+
+/**
+ * Allocate space for and store data in a buffer object. Any data that was
+ * previously stored in the buffer object is lost. If \c data is \c NULL,
+ * memory will be allocated, but no copy will occur.
+ *
+ * This function is intended to be called via
+ * \c dd_function_table::BufferData. This function need not set GL error
+ * codes. The input parameters will have been tested before calling.
+ *
+ * \param ctx GL context.
+ * \param target Buffer object target on which to operate.
+ * \param size Size, in bytes, of the new data store.
+ * \param data Pointer to the data to store in the buffer object. This
+ * pointer may be \c NULL.
+ * \param usage Hints about how the data will be used.
+ * \param bufObj Object to be used.
+ *
+ * \sa glBufferDataARB, dd_function_table::BufferData.
+ */
+void
+_mesa_buffer_data( GLcontext *ctx, GLenum target, GLsizeiptrARB size,
+ const GLvoid * data, GLenum usage,
+ struct gl_buffer_object * bufObj )
+{
+ void * new_data;
+
+ (void) ctx; (void) target;
+
+ new_data = _mesa_realloc( bufObj->Data, bufObj->Size, size );
+ if (new_data) {
+ bufObj->Data = (GLubyte *) new_data;
+ bufObj->Size = size;
+ bufObj->Usage = usage;
+
+ if (data) {
+ _mesa_memcpy( bufObj->Data, data, size );
+ }
+ }
+}
+
+
+/**
+ * Replace data in a subrange of buffer object. If the data range
+ * specified by \c size + \c offset extends beyond the end of the buffer or
+ * if \c data is \c NULL, no copy is performed.
+ *
+ * This function is intended to be called by
+ * \c dd_function_table::BufferSubData. This function need not set GL error
+ * codes. The input parameters will have been tested before calling.
+ *
+ * \param ctx GL context.
+ * \param target Buffer object target on which to operate.
+ * \param offset Offset of the first byte to be modified.
+ * \param size Size, in bytes, of the data range.
+ * \param data Pointer to the data to store in the buffer object.
+ * \param bufObj Object to be used.
+ *
+ * \sa glBufferSubDataARB, dd_function_table::BufferSubData.
+ */
+void
+_mesa_buffer_subdata( GLcontext *ctx, GLenum target, GLintptrARB offset,
+ GLsizeiptrARB size, const GLvoid * data,
+ struct gl_buffer_object * bufObj )
+{
+ (void) ctx; (void) target;
+
+ if (bufObj->Data && ((GLuint) (size + offset) <= bufObj->Size)) {
+ _mesa_memcpy( (GLubyte *) bufObj->Data + offset, data, size );
+ }
+}
+
+
+/**
+ * Retrieve data from a subrange of buffer object. If the data range
+ * specified by \c size + \c offset extends beyond the end of the buffer or
+ * if \c data is \c NULL, no copy is performed.
+ *
+ * This function is intended to be called by
+ * \c dd_function_table::BufferGetSubData. This function need not set GL error
+ * codes. The input parameters will have been tested before calling.
+ *
+ * \param ctx GL context.
+ * \param target Buffer object target on which to operate.
+ * \param offset Offset of the first byte to be modified.
+ * \param size Size, in bytes, of the data range.
+ * \param data Pointer to the data to store in the buffer object.
+ * \param bufObj Object to be used.
+ *
+ * \sa glBufferGetSubDataARB, dd_function_table::GetBufferSubData.
+ */
+void
+_mesa_buffer_get_subdata( GLcontext *ctx, GLenum target, GLintptrARB offset,
+ GLsizeiptrARB size, GLvoid * data,
+ struct gl_buffer_object * bufObj )
+{
+ (void) ctx; (void) target;
+
+ if (bufObj->Data && ((GLsizeiptrARB) (size + offset) <= bufObj->Size)) {
+ _mesa_memcpy( data, (GLubyte *) bufObj->Data + offset, size );
+ }
+}
+
+
+/**
+ * Fallback function called via ctx->Driver.MapBuffer().
+ * Hardware drivers that really implement buffer objects should never use
+ * function.
+ *
+ * The input parameters will have been already tested for errors.
+ *
+ * \param ctx GL context.
+ * \param target Buffer object target on which to operate.
+ * \param access Information about how the buffer will be accessed.
+ * \param bufObj Object to be mapped.
+ * \return A pointer to the object's internal data store that can be accessed
+ * by the processor
+ *
+ * \sa glMapBufferARB, dd_function_table::MapBuffer
+ */
+void *
+_mesa_buffer_map( GLcontext *ctx, GLenum target, GLenum access,
+ struct gl_buffer_object *bufObj )
+{
+ (void) ctx;
+ (void) target;
+ (void) access;
+ ASSERT(!bufObj->OnCard);
+ /* Just return a direct pointer to the data */
+ if (bufObj->Pointer) {
+ /* already mapped! */
+ return NULL;
+ }
+ bufObj->Pointer = bufObj->Data;
+ return bufObj->Pointer;
+}
+
+
+/**
+ * Fallback function called via ctx->Driver.MapBuffer().
+ * Hardware drivers that really implement buffer objects should never use
+ * function.
+ *
+ * The input parameters will have been already tested for errors.
+ *
+ * \sa glUnmapBufferARB, dd_function_table::UnmapBuffer
+ */
+GLboolean
+_mesa_buffer_unmap( GLcontext *ctx, GLenum target,
+ struct gl_buffer_object *bufObj )
+{
+ (void) ctx;
+ (void) target;
+ ASSERT(!bufObj->OnCard);
+ /* XXX we might assert here that bufObj->Pointer is non-null */
+ bufObj->Pointer = NULL;
+ return GL_TRUE;
+}
+
+
+/**
+ * Initialize the state associated with buffer objects
+ */
+void
+_mesa_init_buffer_objects( GLcontext *ctx )
+{
+ GLuint i;
+
+ /* Allocate the default buffer object and set refcount so high that
+ * it never gets deleted.
+ */
+ ctx->Array.NullBufferObj = _mesa_new_buffer_object(ctx, 0, 0);
+ if (ctx->Array.NullBufferObj)
+ ctx->Array.NullBufferObj->RefCount = 1000;
+
+ ctx->Array.ArrayBufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.ElementArrayBufferObj = ctx->Array.NullBufferObj;
+
+ /* Vertex array buffers */
+ ctx->Array.Vertex.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.Normal.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.Color.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.SecondaryColor.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.FogCoord.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.Index.BufferObj = ctx->Array.NullBufferObj;
+ for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
+ ctx->Array.TexCoord[i].BufferObj = ctx->Array.NullBufferObj;
+ }
+ ctx->Array.EdgeFlag.BufferObj = ctx->Array.NullBufferObj;
+ for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+ ctx->Array.VertexAttrib[i].BufferObj = ctx->Array.NullBufferObj;
+ }
+}
+
+
+/**
+ * When we're about to read pixel data out of a PBO (via glDrawPixels,
+ * glTexImage, etc) or write data into a PBO (via glReadPixels,
+ * glGetTexImage, etc) we call this function to check that we're not
+ * going to read out of bounds.
+ *
+ * XXX This would also be a convenient time to check that the PBO isn't
+ * currently mapped. Whoever calls this function should check for that.
+ * Remember, we can't use a PBO when it's mapped!
+ *
+ * \param width width of image to read/write
+ * \param height height of image to read/write
+ * \param depth depth of image to read/write
+ * \param format format of image to read/write
+ * \param type datatype of image to read/write
+ * \param ptr the user-provided pointer/offset
+ * \return GL_TRUE if the PBO access is OK, GL_FALSE if the access would
+ * go out of bounds.
+ */
+GLboolean
+_mesa_validate_pbo_access(GLuint dimensions,
+ const struct gl_pixelstore_attrib *pack,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type, const GLvoid *ptr)
+{
+ GLvoid *start, *end;
+
+ ASSERT(pack->BufferObj->Name != 0);
+
+ if (pack->BufferObj->Size == 0)
+ /* no buffer! */
+ return GL_FALSE;
+
+ /* get address of first pixel we'll read */
+ start = _mesa_image_address(dimensions, pack, ptr, width, height,
+ format, type, 0, 0, 0);
+
+ /* get address just past the last pixel we'll read */
+ end = _mesa_image_address(dimensions, pack, ptr, width, height,
+ format, type, depth-1, height-1, width);
+
+
+ if ((const GLubyte *) start > (const GLubyte *)(uintptr_t) pack->BufferObj->Size) {
+ /* This will catch negative values / wrap-around */
+ return GL_FALSE;
+ }
+ if ((const GLubyte *) end > (const GLubyte *)(uintptr_t) pack->BufferObj->Size) {
+ /* Image read goes beyond end of buffer */
+ return GL_FALSE;
+ }
+
+ /* OK! */
+ return GL_TRUE;
+}
+
+
+
+
+/**********************************************************************/
+/* API Functions */
+/**********************************************************************/
+
+void GLAPIENTRY
+_mesa_BindBufferARB(GLenum target, GLuint buffer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object *oldBufObj;
+ struct gl_buffer_object *newBufObj = NULL;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ oldBufObj = buffer_object_get_target( ctx, target, "BindBufferARB" );
+ if (oldBufObj && oldBufObj->Name == buffer)
+ return; /* rebinding the same buffer object- no change */
+
+ /*
+ * Get pointer to new buffer object (newBufObj)
+ */
+ if (buffer == 0) {
+ /* The spec says there's not a buffer object named 0, but we use
+ * one internally because it simplifies things.
+ */
+ newBufObj = ctx->Array.NullBufferObj;
+ }
+ else {
+ /* non-default buffer object */
+ const struct _mesa_HashTable *hash = ctx->Shared->BufferObjects;
+ newBufObj = (struct gl_buffer_object *) _mesa_HashLookup(hash, buffer);
+ if (!newBufObj) {
+ /* if this is a new buffer object id, allocate a buffer object now */
+ newBufObj = (*ctx->Driver.NewBufferObject)(ctx, buffer, target);
+ if (!newBufObj) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindBufferARB");
+ return;
+ }
+ _mesa_save_buffer_object(ctx, newBufObj);
+ }
+ newBufObj->RefCount++;
+ }
+
+ switch (target) {
+ case GL_ARRAY_BUFFER_ARB:
+ ctx->Array.ArrayBufferObj = newBufObj;
+ break;
+ case GL_ELEMENT_ARRAY_BUFFER_ARB:
+ ctx->Array.ElementArrayBufferObj = newBufObj;
+ break;
+ case GL_PIXEL_PACK_BUFFER_EXT:
+ ctx->Pack.BufferObj = newBufObj;
+ break;
+ case GL_PIXEL_UNPACK_BUFFER_EXT:
+ ctx->Unpack.BufferObj = newBufObj;
+ break;
+ default:
+ _mesa_problem(ctx, "Bad target in _mesa_BindBufferARB");
+ return;
+ }
+
+ /* Pass BindBuffer call to device driver */
+ if (ctx->Driver.BindBuffer && newBufObj)
+ (*ctx->Driver.BindBuffer)( ctx, target, newBufObj );
+
+ if (oldBufObj) {
+ oldBufObj->RefCount--;
+ assert(oldBufObj->RefCount >= 0);
+ if (oldBufObj->RefCount == 0) {
+ assert(oldBufObj->Name != 0);
+ ASSERT(ctx->Driver.DeleteBuffer);
+ ctx->Driver.DeleteBuffer( ctx, oldBufObj );
+ }
+ }
+}
+
+
+/**
+ * Delete a set of buffer objects.
+ *
+ * \param n Number of buffer objects to delete.
+ * \param ids Array of \c n buffer object IDs.
+ */
+void GLAPIENTRY
+_mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLsizei i;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (n < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteBuffersARB(n)");
+ return;
+ }
+
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+
+ for (i = 0; i < n; i++) {
+ if (ids[i] != 0) {
+ struct gl_buffer_object *bufObj = (struct gl_buffer_object *)
+ _mesa_HashLookup(ctx->Shared->BufferObjects, ids[i]);
+ if (bufObj) {
+ /* unbind any vertex pointers bound to this buffer */
+ GLuint j;
+
+ ASSERT(bufObj->Name == ids[i]);
+
+ if (ctx->Array.Vertex.BufferObj == bufObj) {
+ bufObj->RefCount--;
+ ctx->Array.Vertex.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.NullBufferObj->RefCount++;
+ }
+ if (ctx->Array.Normal.BufferObj == bufObj) {
+ bufObj->RefCount--;
+ ctx->Array.Normal.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.NullBufferObj->RefCount++;
+ }
+ if (ctx->Array.Color.BufferObj == bufObj) {
+ bufObj->RefCount--;
+ ctx->Array.Color.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.NullBufferObj->RefCount++;
+ }
+ if (ctx->Array.SecondaryColor.BufferObj == bufObj) {
+ bufObj->RefCount--;
+ ctx->Array.SecondaryColor.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.NullBufferObj->RefCount++;
+ }
+ if (ctx->Array.FogCoord.BufferObj == bufObj) {
+ bufObj->RefCount--;
+ ctx->Array.FogCoord.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.NullBufferObj->RefCount++;
+ }
+ if (ctx->Array.Index.BufferObj == bufObj) {
+ bufObj->RefCount--;
+ ctx->Array.Index.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.NullBufferObj->RefCount++;
+ }
+ if (ctx->Array.EdgeFlag.BufferObj == bufObj) {
+ bufObj->RefCount--;
+ ctx->Array.EdgeFlag.BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.NullBufferObj->RefCount++;
+ }
+ for (j = 0; j < MAX_TEXTURE_UNITS; j++) {
+ if (ctx->Array.TexCoord[j].BufferObj == bufObj) {
+ bufObj->RefCount--;
+ ctx->Array.TexCoord[j].BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.NullBufferObj->RefCount++;
+ }
+ }
+ for (j = 0; j < VERT_ATTRIB_MAX; j++) {
+ if (ctx->Array.VertexAttrib[j].BufferObj == bufObj) {
+ bufObj->RefCount--;
+ ctx->Array.VertexAttrib[j].BufferObj = ctx->Array.NullBufferObj;
+ ctx->Array.NullBufferObj->RefCount++;
+ }
+ }
+
+ if (ctx->Array.ArrayBufferObj == bufObj) {
+ _mesa_BindBufferARB( GL_ARRAY_BUFFER_ARB, 0 );
+ }
+ if (ctx->Array.ElementArrayBufferObj == bufObj) {
+ _mesa_BindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0 );
+ }
+
+ if (ctx->Pack.BufferObj == bufObj) {
+ _mesa_BindBufferARB( GL_PIXEL_PACK_BUFFER_EXT, 0 );
+ }
+ if (ctx->Unpack.BufferObj == bufObj) {
+ _mesa_BindBufferARB( GL_PIXEL_UNPACK_BUFFER_EXT, 0 );
+ }
+
+ /* The ID is immediately freed for re-use */
+ _mesa_remove_buffer_object(ctx, bufObj);
+ bufObj->RefCount--;
+ if (bufObj->RefCount <= 0) {
+ ASSERT(ctx->Array.ArrayBufferObj != bufObj);
+ ASSERT(ctx->Array.ElementArrayBufferObj != bufObj);
+ ASSERT(ctx->Array.Vertex.BufferObj != bufObj);
+ ASSERT(ctx->Driver.DeleteBuffer);
+ ctx->Driver.DeleteBuffer(ctx, bufObj);
+ }
+ }
+ }
+ }
+
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+}
+
+
+/**
+ * Generate a set of unique buffer object IDs and store them in \c buffer.
+ *
+ * \param n Number of IDs to generate.
+ * \param buffer Array of \c n locations to store the IDs.
+ */
+void GLAPIENTRY
+_mesa_GenBuffersARB(GLsizei n, GLuint *buffer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint first;
+ GLint i;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (n < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGenBuffersARB");
+ return;
+ }
+
+ if (!buffer) {
+ return;
+ }
+
+ /*
+ * This must be atomic (generation and allocation of buffer object IDs)
+ */
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+
+ first = _mesa_HashFindFreeKeyBlock(ctx->Shared->BufferObjects, n);
+
+ /* Allocate new, empty buffer objects and return identifiers */
+ for (i = 0; i < n; i++) {
+ struct gl_buffer_object *bufObj;
+ GLuint name = first + i;
+ GLenum target = 0;
+ bufObj = (*ctx->Driver.NewBufferObject)( ctx, name, target );
+ if (!bufObj) {
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenBuffersARB");
+ return;
+ }
+ _mesa_save_buffer_object(ctx, bufObj);
+ buffer[i] = first + i;
+ }
+
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+}
+
+
+/**
+ * Determine if ID is the name of a buffer object.
+ *
+ * \param id ID of the potential buffer object.
+ * \return \c GL_TRUE if \c id is the name of a buffer object,
+ * \c GL_FALSE otherwise.
+ */
+GLboolean GLAPIENTRY
+_mesa_IsBufferARB(GLuint id)
+{
+ struct gl_buffer_object * bufObj;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+
+ if (id == 0)
+ return GL_FALSE;
+
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+ bufObj = (struct gl_buffer_object *) _mesa_HashLookup(ctx->Shared->BufferObjects, id);
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+
+ return bufObj ? GL_TRUE : GL_FALSE;
+}
+
+
+void GLAPIENTRY
+_mesa_BufferDataARB(GLenum target, GLsizeiptrARB size,
+ const GLvoid * data, GLenum usage)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object *bufObj;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (size < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glBufferDataARB(size < 0)");
+ return;
+ }
+
+ switch (usage) {
+ case GL_STREAM_DRAW_ARB:
+ case GL_STREAM_READ_ARB:
+ case GL_STREAM_COPY_ARB:
+ case GL_STATIC_DRAW_ARB:
+ case GL_STATIC_READ_ARB:
+ case GL_STATIC_COPY_ARB:
+ case GL_DYNAMIC_DRAW_ARB:
+ case GL_DYNAMIC_READ_ARB:
+ case GL_DYNAMIC_COPY_ARB:
+ /* OK */
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBufferDataARB(usage)");
+ return;
+ }
+
+ bufObj = buffer_object_get_target( ctx, target, "BufferDataARB" );
+ if (!bufObj || bufObj->Name ==0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferDataARB" );
+ return;
+ }
+
+ if (bufObj->Pointer) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glBufferDataARB(buffer is mapped)" );
+ return;
+ }
+
+ ASSERT(ctx->Driver.BufferData);
+
+ /* Give the buffer object to the driver! <data> may be null! */
+ (*ctx->Driver.BufferData)( ctx, target, size, data, usage, bufObj );
+}
+
+
+void GLAPIENTRY
+_mesa_BufferSubDataARB(GLenum target, GLintptrARB offset,
+ GLsizeiptrARB size, const GLvoid * data)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object *bufObj;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ bufObj = buffer_object_subdata_range_good( ctx, target, offset, size,
+ "BufferSubDataARB" );
+ if (!bufObj) {
+ /* error already recorded */
+ return;
+ }
+
+ ASSERT(ctx->Driver.BufferSubData);
+ (*ctx->Driver.BufferSubData)( ctx, target, offset, size, data, bufObj );
+}
+
+
+void GLAPIENTRY
+_mesa_GetBufferSubDataARB(GLenum target, GLintptrARB offset,
+ GLsizeiptrARB size, void * data)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object *bufObj;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ bufObj = buffer_object_subdata_range_good( ctx, target, offset, size,
+ "GetBufferSubDataARB" );
+ if (!bufObj) {
+ /* error already recorded */
+ return;
+ }
+
+ ASSERT(ctx->Driver.GetBufferSubData);
+ (*ctx->Driver.GetBufferSubData)( ctx, target, offset, size, data, bufObj );
+}
+
+
+void * GLAPIENTRY
+_mesa_MapBufferARB(GLenum target, GLenum access)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object * bufObj;
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL);
+
+ switch (access) {
+ case GL_READ_ONLY_ARB:
+ case GL_WRITE_ONLY_ARB:
+ case GL_READ_WRITE_ARB:
+ /* OK */
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glMapBufferARB(access)");
+ return NULL;
+ }
+
+ bufObj = buffer_object_get_target( ctx, target, "MapBufferARB" );
+ if (!bufObj || bufObj->Name == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB" );
+ return NULL;
+ }
+
+ if (bufObj->Pointer) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glMapBufferARB(already mapped)");
+ return NULL;
+ }
+
+ ASSERT(ctx->Driver.MapBuffer);
+ bufObj->Pointer = (*ctx->Driver.MapBuffer)( ctx, target, access, bufObj );
+ if (!bufObj->Pointer) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMapBufferARB(access)");
+ }
+
+ bufObj->Access = access;
+
+ return bufObj->Pointer;
+}
+
+
+GLboolean GLAPIENTRY
+_mesa_UnmapBufferARB(GLenum target)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object *bufObj;
+ GLboolean status = GL_TRUE;
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+
+ bufObj = buffer_object_get_target( ctx, target, "UnmapBufferARB" );
+ if (!bufObj || bufObj->Name == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB" );
+ return GL_FALSE;
+ }
+
+ if (!bufObj->Pointer) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glUnmapBufferARB");
+ return GL_FALSE;
+ }
+
+ if (ctx->Driver.UnmapBuffer) {
+ status = (*ctx->Driver.UnmapBuffer)( ctx, target, bufObj );
+ }
+
+ bufObj->Access = GL_READ_WRITE_ARB; /* initial value, OK? */
+ bufObj->Pointer = NULL;
+
+ return status;
+}
+
+
+void GLAPIENTRY
+_mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object *bufObj;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ bufObj = buffer_object_get_target( ctx, target, "GetBufferParameterivARB" );
+ if (!bufObj || bufObj->Name == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "GetBufferParameterivARB" );
+ return;
+ }
+
+ switch (pname) {
+ case GL_BUFFER_SIZE_ARB:
+ *params = (GLint) bufObj->Size;
+ break;
+ case GL_BUFFER_USAGE_ARB:
+ *params = bufObj->Usage;
+ break;
+ case GL_BUFFER_ACCESS_ARB:
+ *params = bufObj->Access;
+ break;
+ case GL_BUFFER_MAPPED_ARB:
+ *params = (bufObj->Pointer != NULL);
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferParameterivARB(pname)");
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_buffer_object * bufObj;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (pname != GL_BUFFER_MAP_POINTER_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetBufferPointervARB(pname)");
+ return;
+ }
+
+ bufObj = buffer_object_get_target( ctx, target, "GetBufferPointervARB" );
+ if (!bufObj || bufObj->Name == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetBufferPointervARB" );
+ return;
+ }
+
+ *params = bufObj->Pointer;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/bufferobj.h b/nx-X11/extras/Mesa/src/mesa/main/bufferobj.h
new file mode 100644
index 000000000..bc1005332
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/bufferobj.h
@@ -0,0 +1,124 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+
+#ifndef BUFFEROBJ_H
+#define BUFFEROBJ_H
+
+
+#include "context.h"
+
+
+/*
+ * Internal functions
+ */
+
+extern void
+_mesa_init_buffer_objects( GLcontext *ctx );
+
+extern struct gl_buffer_object *
+_mesa_new_buffer_object( GLcontext *ctx, GLuint name, GLenum target );
+
+extern void
+_mesa_delete_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj );
+
+extern void
+_mesa_initialize_buffer_object( struct gl_buffer_object *obj,
+ GLuint name, GLenum target );
+
+extern void
+_mesa_save_buffer_object( GLcontext *ctx, struct gl_buffer_object *obj );
+
+extern void
+_mesa_remove_buffer_object( GLcontext *ctx, struct gl_buffer_object *bufObj );
+
+extern void
+_mesa_buffer_data( GLcontext *ctx, GLenum target, GLsizeiptrARB size,
+ const GLvoid * data, GLenum usage,
+ struct gl_buffer_object * bufObj );
+
+extern void
+_mesa_buffer_subdata( GLcontext *ctx, GLenum target, GLintptrARB offset,
+ GLsizeiptrARB size, const GLvoid * data,
+ struct gl_buffer_object * bufObj );
+
+extern void
+_mesa_buffer_get_subdata( GLcontext *ctx, GLenum target, GLintptrARB offset,
+ GLsizeiptrARB size, GLvoid * data,
+ struct gl_buffer_object * bufObj );
+
+extern void *
+_mesa_buffer_map( GLcontext *ctx, GLenum target, GLenum access,
+ struct gl_buffer_object * bufObj );
+
+extern GLboolean
+_mesa_buffer_unmap( GLcontext *ctx, GLenum target,
+ struct gl_buffer_object * bufObj );
+
+extern GLboolean
+_mesa_validate_pbo_access(GLuint dimensions,
+ const struct gl_pixelstore_attrib *pack,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type, const GLvoid *ptr);
+
+
+/*
+ * API functions
+ */
+
+extern void GLAPIENTRY
+_mesa_BindBufferARB(GLenum target, GLuint buffer);
+
+extern void GLAPIENTRY
+_mesa_DeleteBuffersARB(GLsizei n, const GLuint * buffer);
+
+extern void GLAPIENTRY
+_mesa_GenBuffersARB(GLsizei n, GLuint * buffer);
+
+extern GLboolean GLAPIENTRY
+_mesa_IsBufferARB(GLuint buffer);
+
+extern void GLAPIENTRY
+_mesa_BufferDataARB(GLenum target, GLsizeiptrARB size, const GLvoid * data, GLenum usage);
+
+extern void GLAPIENTRY
+_mesa_BufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid * data);
+
+extern void GLAPIENTRY
+_mesa_GetBufferSubDataARB(GLenum target, GLintptrARB offset, GLsizeiptrARB size, void * data);
+
+extern void * GLAPIENTRY
+_mesa_MapBufferARB(GLenum target, GLenum access);
+
+extern GLboolean GLAPIENTRY
+_mesa_UnmapBufferARB(GLenum target);
+
+extern void GLAPIENTRY
+_mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params);
+
+extern void GLAPIENTRY
+_mesa_GetBufferPointervARB(GLenum target, GLenum pname, GLvoid **params);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/buffers.c b/nx-X11/extras/Mesa/src/mesa/main/buffers.c
new file mode 100644
index 000000000..58435e0ed
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/buffers.c
@@ -0,0 +1,723 @@
+/**
+ * \file buffers.c
+ * Frame buffer management.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "buffers.h"
+#include "colormac.h"
+#include "context.h"
+#include "enums.h"
+#include "fbobject.h"
+#include "state.h"
+
+
+#define BAD_MASK ~0u
+
+
+#if _HAVE_FULL_GL
+void GLAPIENTRY
+_mesa_ClearIndex( GLfloat c )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (ctx->Color.ClearIndex == (GLuint) c)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_COLOR);
+ ctx->Color.ClearIndex = (GLuint) c;
+
+ if (!ctx->Visual.rgbMode && ctx->Driver.ClearIndex) {
+ /* it's OK to call glClearIndex in RGBA mode but it should be a NOP */
+ (*ctx->Driver.ClearIndex)( ctx, ctx->Color.ClearIndex );
+ }
+}
+#endif
+
+
+/**
+ * Specify the clear values for the color buffers.
+ *
+ * \param red red color component.
+ * \param green green color component.
+ * \param blue blue color component.
+ * \param alpha alpha component.
+ *
+ * \sa glClearColor().
+ *
+ * Clamps the parameters and updates gl_colorbuffer_attrib::ClearColor. On a
+ * change, flushes the vertices and notifies the driver via the
+ * dd_function_table::ClearColor callback.
+ */
+void GLAPIENTRY
+_mesa_ClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha )
+{
+ GLfloat tmp[4];
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ tmp[0] = CLAMP(red, 0.0F, 1.0F);
+ tmp[1] = CLAMP(green, 0.0F, 1.0F);
+ tmp[2] = CLAMP(blue, 0.0F, 1.0F);
+ tmp[3] = CLAMP(alpha, 0.0F, 1.0F);
+
+ if (TEST_EQ_4V(tmp, ctx->Color.ClearColor))
+ return; /* no change */
+
+ FLUSH_VERTICES(ctx, _NEW_COLOR);
+ COPY_4V(ctx->Color.ClearColor, tmp);
+
+ if (ctx->Visual.rgbMode && ctx->Driver.ClearColor) {
+ /* it's OK to call glClearColor in CI mode but it should be a NOP */
+ (*ctx->Driver.ClearColor)(ctx, ctx->Color.ClearColor);
+ }
+}
+
+
+/**
+ * Clear buffers.
+ *
+ * \param mask bit-mask indicating the buffers to be cleared.
+ *
+ * Flushes the vertices and verifies the parameter. If __GLcontextRec::NewState
+ * is set then calls _mesa_update_state() to update gl_frame_buffer::_Xmin,
+ * etc. If the rasterization mode is set to GL_RENDER then requests the driver
+ * to clear the buffers, via the dd_function_table::Clear callback.
+ */
+void GLAPIENTRY
+_mesa_Clear( GLbitfield mask )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glClear 0x%x\n", mask);
+
+ if (mask & ~(GL_COLOR_BUFFER_BIT |
+ GL_DEPTH_BUFFER_BIT |
+ GL_STENCIL_BUFFER_BIT |
+ GL_ACCUM_BUFFER_BIT)) {
+ /* invalid bit set */
+ _mesa_error( ctx, GL_INVALID_VALUE, "glClear(0x%x)", mask);
+ return;
+ }
+
+ if (ctx->NewState) {
+ _mesa_update_state( ctx ); /* update _Xmin, etc */
+ }
+
+ if (ctx->RenderMode == GL_RENDER) {
+ const GLint x = ctx->DrawBuffer->_Xmin;
+ const GLint y = ctx->DrawBuffer->_Ymin;
+ const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+ const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+ GLbitfield bufferMask;
+
+ /* don't clear depth buffer if depth writing disabled */
+ if (!ctx->Depth.Mask)
+ mask &= ~GL_DEPTH_BUFFER_BIT;
+
+ /* Build the bitmask to send to device driver's Clear function.
+ * Note that the GL_COLOR_BUFFER_BIT flag will expand to 0, 1, 2 or 4
+ * of the BUFFER_BIT_FRONT/BACK_LEFT/RIGHT flags, or one of the
+ * BUFFER_BIT_COLORn flags.
+ */
+ bufferMask = 0;
+ if (mask & GL_COLOR_BUFFER_BIT) {
+ bufferMask |= ctx->DrawBuffer->_ColorDrawBufferMask[0];
+ }
+
+ if ((mask & GL_DEPTH_BUFFER_BIT)
+ && ctx->DrawBuffer->Visual.haveDepthBuffer) {
+ bufferMask |= BUFFER_BIT_DEPTH;
+ }
+
+ if ((mask & GL_STENCIL_BUFFER_BIT)
+ && ctx->DrawBuffer->Visual.haveStencilBuffer) {
+ bufferMask |= BUFFER_BIT_STENCIL;
+ }
+
+ if ((mask & GL_ACCUM_BUFFER_BIT)
+ && ctx->DrawBuffer->Visual.haveAccumBuffer) {
+ bufferMask |= BUFFER_BIT_ACCUM;
+ }
+
+ ASSERT(ctx->Driver.Clear);
+ ctx->Driver.Clear( ctx, bufferMask, (GLboolean) !ctx->Scissor.Enabled,
+ x, y, width, height );
+ }
+}
+
+
+
+/**
+ * Return bitmask of BUFFER_BIT_* flags indicating which color buffers are
+ * available to the rendering context.
+ * This depends on the framebuffer we're writing to. For window system
+ * framebuffers we look at the framebuffer's visual. But for user-
+ * create framebuffers we look at the number of supported color attachments.
+ */
+static GLuint
+supported_buffer_bitmask(const GLcontext *ctx, GLuint framebufferID)
+{
+ GLuint mask = 0x0;
+ GLint i;
+
+ if (framebufferID > 0) {
+ /* A user-created renderbuffer */
+ ASSERT(ctx->Extensions.EXT_framebuffer_object);
+ for (i = 0; i < ctx->Const.MaxColorAttachments; i++) {
+ mask |= (BUFFER_BIT_COLOR0 << i);
+ }
+ }
+ else {
+ /* A window system renderbuffer */
+ mask = BUFFER_BIT_FRONT_LEFT; /* always have this */
+ if (ctx->Visual.stereoMode) {
+ mask |= BUFFER_BIT_FRONT_RIGHT;
+ if (ctx->Visual.doubleBufferMode) {
+ mask |= BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT;
+ }
+ }
+ else if (ctx->Visual.doubleBufferMode) {
+ mask |= BUFFER_BIT_BACK_LEFT;
+ }
+
+ for (i = 0; i < ctx->Visual.numAuxBuffers; i++) {
+ mask |= (BUFFER_BIT_AUX0 << i);
+ }
+ }
+
+ return mask;
+}
+
+
+/**
+ * Helper routine used by glDrawBuffer and glDrawBuffersARB.
+ * Given a GLenum naming one or more color buffers (such as
+ * GL_FRONT_AND_BACK), return the corresponding bitmask of BUFFER_BIT_* flags.
+ */
+static GLuint
+draw_buffer_enum_to_bitmask(GLenum buffer)
+{
+ switch (buffer) {
+ case GL_NONE:
+ return 0;
+ case GL_FRONT:
+ return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT;
+ case GL_BACK:
+ return BUFFER_BIT_BACK_LEFT | BUFFER_BIT_BACK_RIGHT;
+ case GL_RIGHT:
+ return BUFFER_BIT_FRONT_RIGHT | BUFFER_BIT_BACK_RIGHT;
+ case GL_FRONT_RIGHT:
+ return BUFFER_BIT_FRONT_RIGHT;
+ case GL_BACK_RIGHT:
+ return BUFFER_BIT_BACK_RIGHT;
+ case GL_BACK_LEFT:
+ return BUFFER_BIT_BACK_LEFT;
+ case GL_FRONT_AND_BACK:
+ return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT
+ | BUFFER_BIT_FRONT_RIGHT | BUFFER_BIT_BACK_RIGHT;
+ case GL_LEFT:
+ return BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT;
+ case GL_FRONT_LEFT:
+ return BUFFER_BIT_FRONT_LEFT;
+ case GL_AUX0:
+ return BUFFER_BIT_AUX0;
+ case GL_AUX1:
+ return BUFFER_BIT_AUX1;
+ case GL_AUX2:
+ return BUFFER_BIT_AUX2;
+ case GL_AUX3:
+ return BUFFER_BIT_AUX3;
+ case GL_COLOR_ATTACHMENT0_EXT:
+ return BUFFER_BIT_COLOR0;
+ case GL_COLOR_ATTACHMENT1_EXT:
+ return BUFFER_BIT_COLOR1;
+ case GL_COLOR_ATTACHMENT2_EXT:
+ return BUFFER_BIT_COLOR2;
+ case GL_COLOR_ATTACHMENT3_EXT:
+ return BUFFER_BIT_COLOR3;
+ default:
+ /* error */
+ return BAD_MASK;
+ }
+}
+
+
+/**
+ * Helper routine used by glReadBuffer.
+ * Given a GLenum naming (a) color buffer(s), return the corresponding
+ * bitmask of DD_* flags.
+ */
+static GLuint
+read_buffer_enum_to_bitmask(GLenum buffer)
+{
+ switch (buffer) {
+ case GL_FRONT:
+ return BUFFER_BIT_FRONT_LEFT;
+ case GL_BACK:
+ return BUFFER_BIT_BACK_LEFT;
+ case GL_RIGHT:
+ return BUFFER_BIT_FRONT_RIGHT;
+ case GL_FRONT_RIGHT:
+ return BUFFER_BIT_FRONT_RIGHT;
+ case GL_BACK_RIGHT:
+ return BUFFER_BIT_BACK_RIGHT;
+ case GL_BACK_LEFT:
+ return BUFFER_BIT_BACK_LEFT;
+ case GL_LEFT:
+ return BUFFER_BIT_FRONT_LEFT;
+ case GL_FRONT_LEFT:
+ return BUFFER_BIT_FRONT_LEFT;
+ case GL_AUX0:
+ return BUFFER_BIT_AUX0;
+ case GL_AUX1:
+ return BUFFER_BIT_AUX1;
+ case GL_AUX2:
+ return BUFFER_BIT_AUX2;
+ case GL_AUX3:
+ return BUFFER_BIT_AUX3;
+ case GL_COLOR_ATTACHMENT0_EXT:
+ return BUFFER_BIT_COLOR0;
+ case GL_COLOR_ATTACHMENT1_EXT:
+ return BUFFER_BIT_COLOR1;
+ case GL_COLOR_ATTACHMENT2_EXT:
+ return BUFFER_BIT_COLOR2;
+ case GL_COLOR_ATTACHMENT3_EXT:
+ return BUFFER_BIT_COLOR3;
+ default:
+ /* error */
+ return BAD_MASK;
+ }
+}
+
+
+/**
+ * Specify which color buffers to draw into.
+ *
+ * \param buffer color buffer, such as GL_LEFT or GL_FRONT_AND_BACK.
+ *
+ * Flushes the vertices and verifies the parameter and updates the
+ * gl_colorbuffer_attrib::_DrawDestMask bitfield. Marks new color state in
+ * __GLcontextRec::NewState and notifies the driver via the
+ * dd_function_table::DrawBuffer callback.
+ */
+void GLAPIENTRY
+_mesa_DrawBuffer(GLenum buffer)
+{
+ GLuint bufferID;
+ GLuint destMask;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex... */
+
+ if (MESA_VERBOSE & VERBOSE_API) {
+ _mesa_debug(ctx, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
+ }
+
+ bufferID = ctx->DrawBuffer->Name;
+
+ if (buffer == GL_NONE) {
+ destMask = 0x0;
+ }
+ else {
+ const GLuint supportedMask = supported_buffer_bitmask(ctx, bufferID);
+ destMask = draw_buffer_enum_to_bitmask(buffer);
+ if (destMask == BAD_MASK) {
+ /* totally bogus buffer */
+ _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffer(buffer)");
+ return;
+ }
+ destMask &= supportedMask;
+ if (destMask == 0x0) {
+ /* none of the named color buffers exist! */
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffer(buffer)");
+ return;
+ }
+ }
+
+ /* if we get here, there's no error so set new state */
+ _mesa_drawbuffers(ctx, 1, &buffer, &destMask);
+}
+
+
+/**
+ * Called by glDrawBuffersARB; specifies the destination color buffers
+ * for N fragment program color outputs.
+ *
+ * XXX This function is called by _mesa_PopAttrib() and we need to do
+ * some more work to deal with the current framebuffer binding state!
+ */
+void GLAPIENTRY
+_mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers)
+{
+ GLint output;
+ GLuint usedBufferMask, supportedMask;
+ GLuint bufferID;
+ GLuint destMask[MAX_DRAW_BUFFERS];
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (!ctx->Extensions.ARB_draw_buffers) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffersARB");
+ return;
+ }
+ if (n < 1 || n > (GLsizei) ctx->Const.MaxDrawBuffers) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glDrawBuffersARB(n)");
+ return;
+ }
+
+ bufferID = ctx->DrawBuffer->Name;
+
+ supportedMask = supported_buffer_bitmask(ctx, bufferID);
+ usedBufferMask = 0x0;
+
+ /* complicated error checking... */
+ for (output = 0; output < n; output++) {
+ if (buffers[output] == GL_NONE) {
+ destMask[output] = 0x0;
+ }
+ else {
+ destMask[output] = draw_buffer_enum_to_bitmask(buffers[output]);
+ if (destMask[output] == BAD_MASK
+ || _mesa_bitcount(destMask[output]) > 1) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glDrawBuffersARB(buffer)");
+ return;
+ }
+ destMask[output] &= supportedMask;
+ if (destMask[output] == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDrawBuffersARB(unsupported buffer)");
+ return;
+ }
+ if (destMask[output] & usedBufferMask) {
+ /* can't specify a dest buffer more than once! */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDrawBuffersARB(duplicated buffer)");
+ return;
+ }
+
+ /* update bitmask */
+ usedBufferMask |= destMask[output];
+ }
+ }
+
+ /* OK, if we get here, there were no errors so set the new state */
+ _mesa_drawbuffers(ctx, n, buffers, destMask);
+}
+
+
+/**
+ * Set color output state. Traditionally, there was only one color
+ * output, but fragment programs can now have several distinct color
+ * outputs (see GL_ARB_draw_buffers). This function sets the state
+ * for one such color output.
+ */
+static void
+set_color_output(GLcontext *ctx, GLuint output, GLenum buffer, GLuint destMask)
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+
+ ASSERT(output < ctx->Const.MaxDrawBuffers);
+
+ fb->ColorDrawBuffer[output] = buffer;
+ fb->_ColorDrawBufferMask[output] = destMask;
+
+ if (fb->Name == 0) {
+ /* Set traditional state var */
+ ctx->Color.DrawBuffer[output] = buffer;
+ }
+
+ /* not really needed, will be set later */
+ fb->_NumColorDrawBuffers[output] = 0;
+}
+
+
+/**
+ * Helper routine used by _mesa_DrawBuffer, _mesa_DrawBuffersARB and
+ * _mesa_PopAttrib to set drawbuffer state.
+ */
+void
+_mesa_drawbuffers(GLcontext *ctx, GLsizei n, const GLenum *buffers,
+ const GLuint *destMask)
+{
+ GLuint mask[MAX_DRAW_BUFFERS];
+ GLint output;
+
+ if (!destMask) {
+ /* compute destMask values now */
+ const GLuint bufferID = ctx->DrawBuffer->Name;
+ const GLuint supportedMask = supported_buffer_bitmask(ctx, bufferID);
+ for (output = 0; output < n; output++) {
+ mask[output] = draw_buffer_enum_to_bitmask(buffers[output]);
+ ASSERT(mask[output] != BAD_MASK);
+ mask[output] &= supportedMask;
+ }
+ destMask = mask;
+ }
+
+ for (output = 0; output < n; output++) {
+ set_color_output(ctx, output, buffers[output], destMask[output]);
+ }
+
+ /* set remaining color outputs to NONE */
+ for (output = n; output < ctx->Const.MaxDrawBuffers; output++) {
+ set_color_output(ctx, output, GL_NONE, 0x0);
+ }
+
+ ctx->NewState |= _NEW_COLOR;
+
+ /*
+ * Call device driver function.
+ */
+ if (ctx->Driver.DrawBuffers)
+ ctx->Driver.DrawBuffers(ctx, n, buffers);
+ else if (ctx->Driver.DrawBuffer)
+ ctx->Driver.DrawBuffer(ctx, buffers[0]);
+}
+
+
+
+/**
+ * Set the color buffer source for reading pixels.
+ *
+ * \param mode color buffer.
+ *
+ * \sa glReadBuffer().
+ *
+ */
+void GLAPIENTRY
+_mesa_ReadBuffer(GLenum buffer)
+{
+ struct gl_framebuffer *fb;
+ GLuint srcMask, supportedMask;
+ GLuint bufferID;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ fb = ctx->ReadBuffer;
+ bufferID = fb->Name;
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer));
+
+ if (bufferID > 0 && buffer == GL_NONE) {
+ /* legal! */
+ srcMask = 0x0;
+ }
+ else {
+ /* general case */
+ srcMask = read_buffer_enum_to_bitmask(buffer);
+ if (srcMask == BAD_MASK) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glReadBuffer(buffer)");
+ return;
+ }
+ supportedMask = supported_buffer_bitmask(ctx, bufferID);
+ if ((srcMask & supportedMask) == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glReadBuffer(buffer)");
+ return;
+ }
+ }
+
+ if (bufferID == 0) {
+ ctx->Pixel.ReadBuffer = buffer;
+ }
+ fb->ColorReadBuffer = buffer;
+ fb->_ColorReadBufferMask = srcMask;
+
+ ctx->NewState |= _NEW_PIXEL;
+
+ /*
+ * Call device driver function.
+ */
+ if (ctx->Driver.ReadBuffer)
+ (*ctx->Driver.ReadBuffer)(ctx, buffer);
+}
+
+
+#if _HAVE_FULL_GL
+
+/**
+ * GL_MESA_resize_buffers extension.
+ *
+ * When this function is called, we'll ask the window system how large
+ * the current window is. If it's a new size, we'll call the driver's
+ * ResizeBuffers function. The driver will then resize its color buffers
+ * as needed, and maybe call the swrast's routine for reallocating
+ * swrast-managed depth/stencil/accum/etc buffers.
+ * \note This function may be called from within Mesa or called by the
+ * user directly (see the GL_MESA_resize_buffers extension).
+ */
+void GLAPIENTRY
+_mesa_ResizeBuffersMESA( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx );
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glResizeBuffersMESA\n");
+
+ if (ctx->DrawBuffer && ctx->DrawBuffer->Name == 0) {
+ GLuint newWidth, newHeight;
+ GLframebuffer *buffer = ctx->DrawBuffer;
+
+ /* ask device driver for size of output buffer */
+ ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight );
+
+ /* see if size of device driver's color buffer (window) has changed */
+ if (buffer->Width != newWidth || buffer->Height != newHeight) {
+ if (ctx->Driver.ResizeBuffers)
+ ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight );
+ }
+ }
+
+ if (ctx->ReadBuffer && ctx->ReadBuffer != ctx->DrawBuffer
+ && ctx->ReadBuffer->Name == 0) {
+ GLuint newWidth, newHeight;
+ GLframebuffer *buffer = ctx->ReadBuffer;
+
+ /* ask device driver for size of read buffer */
+ ctx->Driver.GetBufferSize( buffer, &newWidth, &newHeight );
+
+ /* see if size of device driver's color buffer (window) has changed */
+ if (buffer->Width != newWidth || buffer->Height != newHeight) {
+ if (ctx->Driver.ResizeBuffers)
+ ctx->Driver.ResizeBuffers(ctx, buffer, newWidth, newHeight );
+ }
+ }
+
+ ctx->NewState |= _NEW_BUFFERS; /* to update scissor / window bounds */
+}
+
+
+/*
+ * XXX move somewhere else someday?
+ */
+void GLAPIENTRY
+_mesa_SampleCoverageARB(GLclampf value, GLboolean invert)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->Extensions.ARB_multisample) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleCoverageARB");
+ return;
+ }
+
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH( ctx );
+ ctx->Multisample.SampleCoverageValue = (GLfloat) CLAMP(value, 0.0, 1.0);
+ ctx->Multisample.SampleCoverageInvert = invert;
+ ctx->NewState |= _NEW_MULTISAMPLE;
+}
+
+#endif /* _HAVE_FULL_GL */
+
+
+
+/**
+ * Define the scissor box.
+ *
+ * \param x, y coordinates of the scissor box lower-left corner.
+ * \param width width of the scissor box.
+ * \param height height of the scissor box.
+ *
+ * \sa glScissor().
+ *
+ * Verifies the parameters and updates __GLcontextRec::Scissor. On a
+ * change flushes the vertices and notifies the driver via
+ * the dd_function_table::Scissor callback.
+ */
+void GLAPIENTRY
+_mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (width < 0 || height < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glScissor" );
+ return;
+ }
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glScissor %d %d %d %d\n", x, y, width, height);
+
+ if (x == ctx->Scissor.X &&
+ y == ctx->Scissor.Y &&
+ width == ctx->Scissor.Width &&
+ height == ctx->Scissor.Height)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_SCISSOR);
+ ctx->Scissor.X = x;
+ ctx->Scissor.Y = y;
+ ctx->Scissor.Width = width;
+ ctx->Scissor.Height = height;
+
+ if (ctx->Driver.Scissor)
+ ctx->Driver.Scissor( ctx, x, y, width, height );
+}
+
+
+
+/**********************************************************************/
+/** \name Initialization */
+/*@{*/
+
+/**
+ * Initialize the context's scissor state.
+ * \param ctx the GL context.
+ */
+void
+_mesa_init_scissor(GLcontext *ctx)
+{
+ /* Scissor group */
+ ctx->Scissor.Enabled = GL_FALSE;
+ ctx->Scissor.X = 0;
+ ctx->Scissor.Y = 0;
+ ctx->Scissor.Width = 0;
+ ctx->Scissor.Height = 0;
+}
+
+
+/**
+ * Initialize the context's multisample state.
+ * \param ctx the GL context.
+ */
+void
+_mesa_init_multisample(GLcontext *ctx)
+{
+ ctx->Multisample.Enabled = GL_FALSE;
+ ctx->Multisample.SampleAlphaToCoverage = GL_FALSE;
+ ctx->Multisample.SampleAlphaToOne = GL_FALSE;
+ ctx->Multisample.SampleCoverage = GL_FALSE;
+ ctx->Multisample.SampleCoverageValue = 1.0;
+ ctx->Multisample.SampleCoverageInvert = GL_FALSE;
+}
+
+/*@}*/
diff --git a/nx-X11/extras/Mesa/src/mesa/main/buffers.h b/nx-X11/extras/Mesa/src/mesa/main/buffers.h
new file mode 100644
index 000000000..0c7f68ee7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/buffers.h
@@ -0,0 +1,78 @@
+/**
+ * \file buffers.h
+ * Frame buffer management functions declarations.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+
+#ifndef BUFFERS_H
+#define BUFFERS_H
+
+
+#include "mtypes.h"
+
+
+extern void GLAPIENTRY
+_mesa_ClearIndex( GLfloat c );
+
+extern void GLAPIENTRY
+_mesa_ClearColor( GLclampf red, GLclampf green,
+ GLclampf blue, GLclampf alpha );
+
+extern void GLAPIENTRY
+_mesa_Clear( GLbitfield mask );
+
+extern void GLAPIENTRY
+_mesa_DrawBuffer( GLenum mode );
+
+extern void GLAPIENTRY
+_mesa_DrawBuffersARB(GLsizei n, const GLenum *buffers);
+
+extern void
+_mesa_drawbuffers(GLcontext *ctx, GLsizei n, const GLenum *buffers,
+ const GLuint *destMask);
+
+extern void GLAPIENTRY
+_mesa_ReadBuffer( GLenum mode );
+
+extern void GLAPIENTRY
+_mesa_ResizeBuffersMESA( void );
+
+extern void GLAPIENTRY
+_mesa_Scissor( GLint x, GLint y, GLsizei width, GLsizei height );
+
+extern void GLAPIENTRY
+_mesa_SampleCoverageARB(GLclampf value, GLboolean invert);
+
+extern void
+_mesa_init_scissor(GLcontext *ctx);
+
+extern void
+_mesa_init_multisample(GLcontext *ctx);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/clip.c b/nx-X11/extras/Mesa/src/mesa/main/clip.c
new file mode 100644
index 000000000..43ef55ee3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/clip.c
@@ -0,0 +1,160 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "clip.h"
+#include "context.h"
+#include "macros.h"
+#include "mtypes.h"
+
+#include "math/m_xform.h"
+#include "math/m_matrix.h"
+
+
+
+/**********************************************************************/
+/* Get/Set User clip-planes. */
+/**********************************************************************/
+
+
+
+void GLAPIENTRY
+_mesa_ClipPlane( GLenum plane, const GLdouble *eq )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint p;
+ GLfloat equation[4];
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ p = (GLint) plane - (GLint) GL_CLIP_PLANE0;
+ if (p < 0 || p >= (GLint) ctx->Const.MaxClipPlanes) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glClipPlane" );
+ return;
+ }
+
+ equation[0] = (GLfloat) eq[0];
+ equation[1] = (GLfloat) eq[1];
+ equation[2] = (GLfloat) eq[2];
+ equation[3] = (GLfloat) eq[3];
+
+ /*
+ * The equation is transformed by the transpose of the inverse of the
+ * current modelview matrix and stored in the resulting eye coordinates.
+ *
+ * KW: Eqn is then transformed to the current clip space, where user
+ * clipping now takes place. The clip-space equations are recalculated
+ * whenever the projection matrix changes.
+ */
+ if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top))
+ _math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
+
+ _mesa_transform_vector( equation, equation,
+ ctx->ModelviewMatrixStack.Top->inv );
+
+ if (TEST_EQ_4V(ctx->Transform.EyeUserPlane[p], equation))
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+ COPY_4FV(ctx->Transform.EyeUserPlane[p], equation);
+
+ /* Update derived state. This state also depends on the projection
+ * matrix, and is recalculated on changes to the projection matrix by
+ * code in _mesa_update_state().
+ */
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
+ if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top))
+ _math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
+
+ _mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
+ ctx->Transform.EyeUserPlane[p],
+ ctx->ProjectionMatrixStack.Top->inv );
+ }
+
+ if (ctx->Driver.ClipPlane)
+ ctx->Driver.ClipPlane( ctx, plane, equation );
+}
+
+
+void GLAPIENTRY
+_mesa_GetClipPlane( GLenum plane, GLdouble *equation )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint p;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ p = (GLint) (plane - GL_CLIP_PLANE0);
+ if (p < 0 || p >= (GLint) ctx->Const.MaxClipPlanes) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetClipPlane" );
+ return;
+ }
+
+ equation[0] = (GLdouble) ctx->Transform.EyeUserPlane[p][0];
+ equation[1] = (GLdouble) ctx->Transform.EyeUserPlane[p][1];
+ equation[2] = (GLdouble) ctx->Transform.EyeUserPlane[p][2];
+ equation[3] = (GLdouble) ctx->Transform.EyeUserPlane[p][3];
+}
+
+void GLAPIENTRY
+_mesa_CullParameterfvEXT (GLenum cap, GLfloat *v)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ switch (cap) {
+ case GL_CULL_VERTEX_EYE_POSITION_EXT:
+ FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+ COPY_4FV(ctx->Transform.CullEyePos, v);
+
+ _mesa_transform_vector( ctx->Transform.CullObjPos,
+ ctx->Transform.CullEyePos,
+ ctx->ModelviewMatrixStack.Top->inv );
+ break;
+
+ case GL_CULL_VERTEX_OBJECT_POSITION_EXT:
+ FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+ COPY_4FV(ctx->Transform.CullObjPos, v);
+
+ _mesa_transform_vector( ctx->Transform.CullEyePos,
+ ctx->Transform.CullObjPos,
+ ctx->ModelviewMatrixStack.Top->m );
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glCullParameterfvEXT" );
+ }
+}
+
+void GLAPIENTRY
+_mesa_CullParameterdvEXT (GLenum cap, GLdouble *v)
+{
+ GLfloat f[4];
+
+ f[0] = (GLfloat)v[0];
+ f[1] = (GLfloat)v[1];
+ f[2] = (GLfloat)v[2];
+ f[3] = (GLfloat)v[3];
+
+ _mesa_CullParameterfvEXT(cap, f);
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/main/clip.h b/nx-X11/extras/Mesa/src/mesa/main/clip.h
new file mode 100644
index 000000000..d53afb45b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/clip.h
@@ -0,0 +1,49 @@
+/**
+ * \file clip.h
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+
+#ifndef CLIP_H
+#define CLIP_H
+
+#include "mtypes.h"
+
+extern void GLAPIENTRY
+_mesa_ClipPlane( GLenum plane, const GLdouble *equation );
+
+extern void GLAPIENTRY
+_mesa_GetClipPlane( GLenum plane, GLdouble *equation );
+
+extern void GLAPIENTRY
+_mesa_CullParameterfvEXT (GLenum cap, GLfloat *v);
+
+extern void GLAPIENTRY
+_mesa_CullParameterdvEXT (GLenum cap, GLdouble *v);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/colormac.h b/nx-X11/extras/Mesa/src/mesa/main/colormac.h
new file mode 100644
index 000000000..a19521fc8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/colormac.h
@@ -0,0 +1,227 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file colormac.h
+ * Color-related macros
+ */
+
+
+#ifndef COLORMAC_H
+#define COLORMAC_H
+
+
+#include "imports.h"
+#include "config.h"
+#include "macros.h"
+
+
+/** \def BYTE_TO_CHAN
+ * Convert from GLbyte to GLchan */
+
+/** \def UBYTE_TO_CHAN
+ * Convert from GLubyte to GLchan */
+
+/** \def SHORT_TO_CHAN
+ * Convert from GLshort to GLchan */
+
+/** \def USHORT_TO_CHAN
+ * Convert from GLushort to GLchan */
+
+/** \def INT_TO_CHAN
+ * Convert from GLint to GLchan */
+
+/** \def UINT_TO_CHAN
+ * Convert from GLuint to GLchan */
+
+/** \def CHAN_TO_UBYTE
+ * Convert from GLchan to GLubyte */
+
+/** \def CHAN_TO_FLOAT
+ * Convert from GLchan to GLfloat */
+
+/** \def CLAMPED_FLOAT_TO_CHAN
+ * Convert from GLclampf to GLchan */
+
+/** \def UNCLAMPED_FLOAT_TO_CHAN
+ * Convert from GLfloat to GLchan */
+
+/** \def COPY_CHAN4
+ * Copy a GLchan[4] array */
+
+/** \def CHAN_PRODUCT
+ * Scaled product (usually approximated) between two GLchan arguments */
+
+#if CHAN_BITS == 8
+
+#define BYTE_TO_CHAN(b) ((b) < 0 ? 0 : (GLchan) (b))
+#define UBYTE_TO_CHAN(b) (b)
+#define SHORT_TO_CHAN(s) ((s) < 0 ? 0 : (GLchan) ((s) >> 7))
+#define USHORT_TO_CHAN(s) ((GLchan) ((s) >> 8))
+#define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 23))
+#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 24))
+
+#define CHAN_TO_UBYTE(c) (c)
+#define CHAN_TO_FLOAT(c) UBYTE_TO_FLOAT(c)
+
+#define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_UBYTE(c, f)
+#define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_UBYTE(c, f)
+
+#define COPY_CHAN4(DST, SRC) COPY_4UBV(DST, SRC)
+
+#define CHAN_PRODUCT(a, b) ((GLubyte) (((GLint)(a) * ((GLint)(b) + 1)) >> 8))
+
+#elif CHAN_BITS == 16
+
+#define BYTE_TO_CHAN(b) ((b) < 0 ? 0 : (((GLchan) (b)) * 516))
+#define UBYTE_TO_CHAN(b) ((((GLchan) (b)) << 8) | ((GLchan) (b)))
+#define SHORT_TO_CHAN(s) ((s) < 0 ? 0 : (GLchan) (s))
+#define USHORT_TO_CHAN(s) (s)
+#define INT_TO_CHAN(i) ((i) < 0 ? 0 : (GLchan) ((i) >> 15))
+#define UINT_TO_CHAN(i) ((GLchan) ((i) >> 16))
+
+#define CHAN_TO_UBYTE(c) ((c) >> 8)
+#define CHAN_TO_FLOAT(c) ((GLfloat) ((c) * (1.0 / CHAN_MAXF)))
+
+#define CLAMPED_FLOAT_TO_CHAN(c, f) CLAMPED_FLOAT_TO_USHORT(c, f)
+#define UNCLAMPED_FLOAT_TO_CHAN(c, f) UNCLAMPED_FLOAT_TO_USHORT(c, f)
+
+#define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC)
+
+#define CHAN_PRODUCT(a, b) ((GLchan) ((((GLuint) (a)) * ((GLuint) (b))) / 65535))
+
+#elif CHAN_BITS == 32
+
+/* XXX floating-point color channels not fully thought-out */
+#define BYTE_TO_CHAN(b) ((GLfloat) ((b) * (1.0F / 127.0F)))
+#define UBYTE_TO_CHAN(b) ((GLfloat) ((b) * (1.0F / 255.0F)))
+#define SHORT_TO_CHAN(s) ((GLfloat) ((s) * (1.0F / 32767.0F)))
+#define USHORT_TO_CHAN(s) ((GLfloat) ((s) * (1.0F / 65535.0F)))
+#define INT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 2147483647.0F)))
+#define UINT_TO_CHAN(i) ((GLfloat) ((i) * (1.0F / 4294967295.0F)))
+
+#define CHAN_TO_UBYTE(c) FLOAT_TO_UBYTE(c)
+#define CHAN_TO_FLOAT(c) (c)
+
+#define CLAMPED_FLOAT_TO_CHAN(c, f) c = (f)
+#define UNCLAMPED_FLOAT_TO_CHAN(c, f) c = (f)
+
+#define COPY_CHAN4(DST, SRC) COPY_4V(DST, SRC)
+
+#define CHAN_PRODUCT(a, b) ((a) * (b))
+
+#else
+
+#error unexpected CHAN_BITS size
+
+#endif
+
+
+/**
+ * Convert 3 channels at once.
+ *
+ * \param dst pointer to destination GLchan[3] array.
+ * \param f pointer to source GLfloat[3] array.
+ *
+ * \sa #UNCLAMPED_FLOAT_TO_CHAN.
+ */
+#define UNCLAMPED_FLOAT_TO_RGB_CHAN(dst, f) \
+do { \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[0], f[0]); \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[1], f[1]); \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[2], f[2]); \
+} while (0)
+
+
+/**
+ * Convert 4 channels at once.
+ *
+ * \param dst pointer to destination GLchan[4] array.
+ * \param f pointer to source GLfloat[4] array.
+ *
+ * \sa #UNCLAMPED_FLOAT_TO_CHAN.
+ */
+#define UNCLAMPED_FLOAT_TO_RGBA_CHAN(dst, f) \
+do { \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[0], f[0]); \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[1], f[1]); \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[2], f[2]); \
+ UNCLAMPED_FLOAT_TO_CHAN(dst[3], f[3]); \
+} while (0)
+
+
+
+/**
+ * \name Generic color packing macros. All inputs should be GLubytes.
+ *
+ * \todo We may move these into texstore.h at some point.
+ */
+/*@{*/
+
+#define PACK_COLOR_8888( R, G, B, A ) \
+ (((R) << 24) | ((G) << 16) | ((B) << 8) | (A))
+
+#define PACK_COLOR_8888_REV( R, G, B, A ) \
+ (((A) << 24) | ((B) << 16) | ((G) << 8) | (R))
+
+#define PACK_COLOR_888( R, G, B ) \
+ (((R) << 16) | ((G) << 8) | (B))
+
+#define PACK_COLOR_565( R, G, B ) \
+ ((((R) & 0xf8) << 8) | (((G) & 0xfc) << 3) | (((B) & 0xf8) >> 3))
+
+#define PACK_COLOR_565_REV( R, G, B ) \
+ (((R) & 0xf8) | ((G) & 0xe0) >> 5 | (((G) & 0x1c) << 11) | (((B) & 0xf8) << 5))
+
+#define PACK_COLOR_1555( A, B, G, R ) \
+ ((((B) & 0xf8) << 7) | (((G) & 0xf8) << 2) | (((R) & 0xf8) >> 3) | \
+ ((A) ? 0x8000 : 0))
+
+#define PACK_COLOR_1555_REV( A, B, G, R ) \
+ ((((B) & 0xf8) >> 1) | (((G) & 0xc0) >> 6) | (((G) & 0x38) << 10) | (((R) & 0xf8) << 5) | \
+ ((A) ? 0x80 : 0))
+
+#define PACK_COLOR_4444( R, G, B, A ) \
+ ((((R) & 0xf0) << 8) | (((G) & 0xf0) << 4) | ((B) & 0xf0) | ((A) >> 4))
+
+#define PACK_COLOR_4444_REV( R, G, B, A ) \
+ ((((B) & 0xf0) << 8) | (((A) & 0xf0) << 4) | ((R) & 0xf0) | ((G) >> 4))
+
+#define PACK_COLOR_88( L, A ) \
+ (((L) << 8) | (A))
+
+#define PACK_COLOR_88_REV( L, A ) \
+ (((A) << 8) | (L))
+
+#define PACK_COLOR_332( R, G, B ) \
+ (((R) & 0xe0) | (((G) & 0xe0) >> 3) | (((B) & 0xc0) >> 6))
+
+#define PACK_COLOR_233( B, G, R ) \
+ (((B) & 0xc0) | (((G) & 0xe0) >> 2) | (((R) & 0xe0) >> 5))
+
+/*@}*/
+
+
+#endif /* COLORMAC_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/main/colortab.c b/nx-X11/extras/Mesa/src/mesa/main/colortab.c
new file mode 100644
index 000000000..4f0801578
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/colortab.c
@@ -0,0 +1,1445 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "bufferobj.h"
+#include "colortab.h"
+#include "context.h"
+#include "image.h"
+#include "macros.h"
+#include "state.h"
+
+
+/*
+ * Given an internalFormat token passed to glColorTable,
+ * return the corresponding base format.
+ * Return -1 if invalid token.
+ */
+static GLint
+base_colortab_format( GLenum format )
+{
+ 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 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 */
+ }
+}
+
+
+
+/*
+ * Examine table's format and set the component sizes accordingly.
+ */
+static void
+set_component_sizes( struct gl_color_table *table )
+{
+ GLubyte sz;
+
+ switch (table->Type) {
+ case GL_UNSIGNED_BYTE:
+ sz = 8 * sizeof(GLubyte);
+ break;
+ case GL_UNSIGNED_SHORT:
+ sz = 8 * sizeof(GLushort);
+ break;
+ case GL_FLOAT:
+ /* Don't actually return 32 here since that causes the conformance
+ * tests to blow up. Conform thinks the component is an integer,
+ * not a float.
+ */
+ sz = 8; /** 8 * sizeof(GLfloat); **/
+ break;
+ default:
+ _mesa_problem(NULL, "bad color table type in set_component_sizes 0x%x", table->Type);
+ return;
+ }
+
+ switch (table->Format) {
+ case GL_ALPHA:
+ table->RedSize = 0;
+ table->GreenSize = 0;
+ table->BlueSize = 0;
+ table->AlphaSize = sz;
+ 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 = sz;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ table->RedSize = 0;
+ table->GreenSize = 0;
+ table->BlueSize = 0;
+ table->AlphaSize = sz;
+ table->IntensitySize = 0;
+ table->LuminanceSize = sz;
+ break;
+ case GL_INTENSITY:
+ table->RedSize = 0;
+ table->GreenSize = 0;
+ table->BlueSize = 0;
+ table->AlphaSize = 0;
+ table->IntensitySize = sz;
+ table->LuminanceSize = 0;
+ break;
+ case GL_RGB:
+ table->RedSize = sz;
+ table->GreenSize = sz;
+ table->BlueSize = sz;
+ table->AlphaSize = 0;
+ table->IntensitySize = 0;
+ table->LuminanceSize = 0;
+ break;
+ case GL_RGBA:
+ table->RedSize = sz;
+ table->GreenSize = sz;
+ table->BlueSize = sz;
+ table->AlphaSize = sz;
+ table->IntensitySize = 0;
+ table->LuminanceSize = 0;
+ break;
+ default:
+ _mesa_problem(NULL, "unexpected format in set_component_sizes");
+ }
+}
+
+
+
+/**
+ * Update/replace all or part of a color table. Helper function
+ * used by _mesa_ColorTable() and _mesa_ColorSubTable().
+ * The table->Table buffer should already be allocated.
+ * \param start first entry to update
+ * \param count number of entries to update
+ * \param format format of user-provided table data
+ * \param type datatype of user-provided table data
+ * \param data user-provided table data
+ * \param [rgba]Scale - RGBA scale factors
+ * \param [rgba]Bias - RGBA bias factors
+ */
+static void
+store_colortable_entries(GLcontext *ctx, struct gl_color_table *table,
+ GLsizei start, GLsizei count,
+ GLenum format, GLenum type, const GLvoid *data,
+ GLfloat rScale, GLfloat rBias,
+ GLfloat gScale, GLfloat gBias,
+ GLfloat bScale, GLfloat bBias,
+ GLfloat aScale, GLfloat aBias)
+{
+ if (ctx->Unpack.BufferObj->Name) {
+ /* Get/unpack the color table data from a PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(1, &ctx->Unpack, count, 1, 1,
+ format, type, data)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glColor[Sub]Table(bad PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ GL_READ_ONLY_ARB,
+ ctx->Unpack.BufferObj);
+ if (!buf) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glColor[Sub]Table(PBO mapped)");
+ return;
+ }
+ data = ADD_POINTERS(buf, data);
+ }
+
+
+ if (table->Type == GL_FLOAT) {
+ /* convert user-provided data to GLfloat values */
+ GLfloat tempTab[MAX_COLOR_TABLE_SIZE * 4];
+ GLfloat *tableF;
+ GLint i;
+
+ _mesa_unpack_color_span_float(ctx,
+ count, /* number of pixels */
+ table->Format, /* dest format */
+ tempTab, /* dest address */
+ format, type, /* src format/type */
+ data, /* src data */
+ &ctx->Unpack,
+ IMAGE_CLAMP_BIT); /* transfer ops */
+
+ /* the destination */
+ tableF = (GLfloat *) table->Table;
+
+ /* Apply scale & bias & clamp now */
+ switch (table->Format) {
+ case GL_INTENSITY:
+ for (i = 0; i < count; i++) {
+ GLuint j = start + i;
+ tableF[j] = CLAMP(tempTab[i] * rScale + rBias, 0.0F, 1.0F);
+ }
+ break;
+ case GL_LUMINANCE:
+ for (i = 0; i < count; i++) {
+ GLuint j = start + i;
+ tableF[j] = CLAMP(tempTab[i] * rScale + rBias, 0.0F, 1.0F);
+ }
+ break;
+ case GL_ALPHA:
+ for (i = 0; i < count; i++) {
+ GLuint j = start + i;
+ tableF[j] = CLAMP(tempTab[i] * aScale + aBias, 0.0F, 1.0F);
+ }
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i = 0; i < count; i++) {
+ GLuint j = start + i;
+ tableF[j*2+0] = CLAMP(tempTab[i*2+0] * rScale + rBias, 0.0F, 1.0F);
+ tableF[j*2+1] = CLAMP(tempTab[i*2+1] * aScale + aBias, 0.0F, 1.0F);
+ }
+ break;
+ case GL_RGB:
+ for (i = 0; i < count; i++) {
+ GLuint j = start + i;
+ tableF[j*3+0] = CLAMP(tempTab[i*3+0] * rScale + rBias, 0.0F, 1.0F);
+ tableF[j*3+1] = CLAMP(tempTab[i*3+1] * gScale + gBias, 0.0F, 1.0F);
+ tableF[j*3+2] = CLAMP(tempTab[i*3+2] * bScale + bBias, 0.0F, 1.0F);
+ }
+ break;
+ case GL_RGBA:
+ for (i = 0; i < count; i++) {
+ GLuint j = start + i;
+ tableF[j*4+0] = CLAMP(tempTab[i*4+0] * rScale + rBias, 0.0F, 1.0F);
+ tableF[j*4+1] = CLAMP(tempTab[i*4+1] * gScale + gBias, 0.0F, 1.0F);
+ tableF[j*4+2] = CLAMP(tempTab[i*4+2] * bScale + bBias, 0.0F, 1.0F);
+ tableF[j*4+3] = CLAMP(tempTab[i*4+3] * aScale + aBias, 0.0F, 1.0F);
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad format in store_colortable_entries");
+ return;
+ }
+ }
+ else {
+ /* non-float (GLchan) */
+ const GLint comps = _mesa_components_in_format(table->Format);
+ GLchan *dest = (GLchan *) table->Table + start * comps;
+ _mesa_unpack_color_span_chan(ctx, count, /* number of entries */
+ table->Format, /* dest format */
+ dest, /* dest address */
+ format, type, data, /* src data */
+ &ctx->Unpack,
+ 0); /* transfer ops */
+ }
+
+ if (ctx->Unpack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ ctx->Unpack.BufferObj);
+ }
+}
+
+
+
+void GLAPIENTRY
+_mesa_ColorTable( GLenum target, GLenum internalFormat,
+ GLsizei width, GLenum format, GLenum type,
+ const GLvoid *data )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ 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;
+ GLenum tableType = CHAN_TYPE;
+ GLint comps;
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */
+
+ switch (target) {
+ case GL_TEXTURE_1D:
+ texObj = texUnit->Current1D;
+ table = &texObj->Palette;
+ break;
+ case GL_TEXTURE_2D:
+ texObj = texUnit->Current2D;
+ table = &texObj->Palette;
+ break;
+ case GL_TEXTURE_3D:
+ texObj = texUnit->Current3D;
+ table = &texObj->Palette;
+ break;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
+ return;
+ }
+ texObj = texUnit->CurrentCubeMap;
+ table = &texObj->Palette;
+ break;
+ case GL_PROXY_TEXTURE_1D:
+ texObj = ctx->Texture.Proxy1D;
+ table = &texObj->Palette;
+ proxy = GL_TRUE;
+ break;
+ case GL_PROXY_TEXTURE_2D:
+ texObj = ctx->Texture.Proxy2D;
+ table = &texObj->Palette;
+ proxy = GL_TRUE;
+ break;
+ case GL_PROXY_TEXTURE_3D:
+ texObj = ctx->Texture.Proxy3D;
+ table = &texObj->Palette;
+ proxy = GL_TRUE;
+ break;
+ case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
+ return;
+ }
+ texObj = ctx->Texture.ProxyCubeMap;
+ table = &texObj->Palette;
+ break;
+ case GL_SHARED_TEXTURE_PALETTE_EXT:
+ table = &ctx->Texture.Palette;
+ tableType = GL_FLOAT;
+ break;
+ case GL_COLOR_TABLE:
+ table = &ctx->ColorTable;
+ tableType = GL_FLOAT;
+ 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_TEXTURE_COLOR_TABLE_SGI:
+ if (!ctx->Extensions.SGI_texture_color_table) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
+ return;
+ }
+ table = &(texUnit->ColorTable);
+ tableType = GL_FLOAT;
+ rScale = ctx->Pixel.TextureColorTableScale[0];
+ gScale = ctx->Pixel.TextureColorTableScale[1];
+ bScale = ctx->Pixel.TextureColorTableScale[2];
+ aScale = ctx->Pixel.TextureColorTableScale[3];
+ rBias = ctx->Pixel.TextureColorTableBias[0];
+ gBias = ctx->Pixel.TextureColorTableBias[1];
+ bBias = ctx->Pixel.TextureColorTableBias[2];
+ aBias = ctx->Pixel.TextureColorTableBias[3];
+ break;
+ case GL_PROXY_TEXTURE_COLOR_TABLE_SGI:
+ if (!ctx->Extensions.SGI_texture_color_table) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
+ return;
+ }
+ table = &(texUnit->ProxyColorTable);
+ tableType = GL_FLOAT;
+ proxy = GL_TRUE;
+ break;
+ case GL_POST_CONVOLUTION_COLOR_TABLE:
+ table = &ctx->PostConvolutionColorTable;
+ tableType = GL_FLOAT;
+ 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;
+ tableType = GL_FLOAT;
+ proxy = GL_TRUE;
+ break;
+ case GL_POST_COLOR_MATRIX_COLOR_TABLE:
+ table = &ctx->PostColorMatrixColorTable;
+ tableType = GL_FLOAT;
+ 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;
+ tableType = GL_FLOAT;
+ proxy = GL_TRUE;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(target)");
+ return;
+ }
+
+ assert(table);
+
+ if (!_mesa_is_legal_format_and_type(ctx, format, type) ||
+ format == GL_INTENSITY) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glColorTable(format or type)");
+ return;
+ }
+
+ baseFormat = base_colortab_format(internalFormat);
+ if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glColorTable(internalFormat)");
+ return;
+ }
+
+ if (width < 0 || (width != 0 && _mesa_bitcount(width) != 1)) {
+ /* error */
+ if (proxy) {
+ table->Size = 0;
+ table->IntFormat = (GLenum) 0;
+ table->Format = (GLenum) 0;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glColorTable(width=%d)", width);
+ }
+ return;
+ }
+
+ if (width > (GLsizei) ctx->Const.MaxColorTableSize) {
+ if (proxy) {
+ table->Size = 0;
+ table->IntFormat = (GLenum) 0;
+ table->Format = (GLenum) 0;
+ }
+ else {
+ _mesa_error(ctx, GL_TABLE_TOO_LARGE, "glColorTable(width)");
+ }
+ return;
+ }
+
+ table->Size = width;
+ table->IntFormat = internalFormat;
+ table->Format = (GLenum) baseFormat;
+ table->Type = (tableType == GL_FLOAT) ? GL_FLOAT : CHAN_TYPE;
+
+ comps = _mesa_components_in_format(table->Format);
+ assert(comps > 0); /* error should have been caught sooner */
+
+ if (!proxy) {
+ /* free old table, if any */
+ if (table->Table) {
+ FREE(table->Table);
+ table->Table = NULL;
+ }
+
+ if (width > 0) {
+ if (table->Type == GL_FLOAT) {
+ table->Table = MALLOC(comps * width * sizeof(GLfloat));
+ }
+ else {
+ table->Table = MALLOC(comps * width * sizeof(GLchan));
+ }
+
+ if (!table->Table) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glColorTable");
+ return;
+ }
+
+ store_colortable_entries(ctx, table,
+ 0, width, /* start, count */
+ format, type, data,
+ rScale, rBias,
+ gScale, gBias,
+ bScale, bBias,
+ aScale, aBias);
+ }
+ } /* proxy */
+
+ /* do this after the table's Type and Format are set */
+ set_component_sizes(table);
+
+ 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, texObj );
+ }
+ }
+
+ ctx->NewState |= _NEW_PIXEL;
+}
+
+
+
+void GLAPIENTRY
+_mesa_ColorSubTable( GLenum target, GLsizei start,
+ GLsizei count, GLenum format, GLenum type,
+ const GLvoid *data )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ struct gl_texture_object *texObj = NULL;
+ struct gl_color_table *table = NULL;
+ 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;
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ switch (target) {
+ case GL_TEXTURE_1D:
+ texObj = texUnit->Current1D;
+ table = &texObj->Palette;
+ break;
+ case GL_TEXTURE_2D:
+ texObj = texUnit->Current2D;
+ table = &texObj->Palette;
+ break;
+ case GL_TEXTURE_3D:
+ texObj = texUnit->Current3D;
+ table = &texObj->Palette;
+ break;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)");
+ return;
+ }
+ texObj = texUnit->CurrentCubeMap;
+ table = &texObj->Palette;
+ break;
+ case GL_SHARED_TEXTURE_PALETTE_EXT:
+ table = &ctx->Texture.Palette;
+ break;
+ case GL_COLOR_TABLE:
+ table = &ctx->ColorTable;
+ 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_TEXTURE_COLOR_TABLE_SGI:
+ if (!ctx->Extensions.SGI_texture_color_table) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)");
+ return;
+ }
+ table = &(texUnit->ColorTable);
+ rScale = ctx->Pixel.TextureColorTableScale[0];
+ gScale = ctx->Pixel.TextureColorTableScale[1];
+ bScale = ctx->Pixel.TextureColorTableScale[2];
+ aScale = ctx->Pixel.TextureColorTableScale[3];
+ rBias = ctx->Pixel.TextureColorTableBias[0];
+ gBias = ctx->Pixel.TextureColorTableBias[1];
+ bBias = ctx->Pixel.TextureColorTableBias[2];
+ aBias = ctx->Pixel.TextureColorTableBias[3];
+ break;
+ case GL_POST_CONVOLUTION_COLOR_TABLE:
+ table = &ctx->PostConvolutionColorTable;
+ 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_POST_COLOR_MATRIX_COLOR_TABLE:
+ table = &ctx->PostColorMatrixColorTable;
+ 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;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)");
+ return;
+ }
+
+ assert(table);
+
+ if (!_mesa_is_legal_format_and_type(ctx, format, type) ||
+ format == GL_INTENSITY) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glColorSubTable(format or type)");
+ return;
+ }
+
+ if (count < 1) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glColorSubTable(count)");
+ return;
+ }
+
+ /* error should have been caught sooner */
+ assert(_mesa_components_in_format(table->Format) > 0);
+
+ if (start + count > (GLint) table->Size) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glColorSubTable(count)");
+ return;
+ }
+
+ if (!table->Table) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glColorSubTable");
+ return;
+ }
+
+ store_colortable_entries(ctx, table, start, count,
+ format, type, data,
+ rScale, rBias,
+ gScale, gBias,
+ bScale, bBias,
+ aScale, aBias);
+
+ if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) {
+ /* per-texture object palette */
+ if (ctx->Driver.UpdateTexturePalette) {
+ (*ctx->Driver.UpdateTexturePalette)( ctx, texObj );
+ }
+ }
+
+ ctx->NewState |= _NEW_PIXEL;
+}
+
+
+
+void GLAPIENTRY
+_mesa_CopyColorTable(GLenum target, GLenum internalformat,
+ GLint x, GLint y, GLsizei width)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ /* Select buffer to read from */
+ ctx->Driver.CopyColorTable( ctx, target, internalformat, x, y, width );
+}
+
+
+
+void GLAPIENTRY
+_mesa_CopyColorSubTable(GLenum target, GLsizei start,
+ GLint x, GLint y, GLsizei width)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ ctx->Driver.CopyColorSubTable( ctx, target, start, x, y, width );
+}
+
+
+
+void GLAPIENTRY
+_mesa_GetColorTable( GLenum target, GLenum format,
+ GLenum type, GLvoid *data )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ struct gl_color_table *table = NULL;
+ GLchan rgba[MAX_COLOR_TABLE_SIZE][4];
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (ctx->NewState) {
+ _mesa_update_state(ctx);
+ }
+
+ switch (target) {
+ case GL_TEXTURE_1D:
+ table = &texUnit->Current1D->Palette;
+ break;
+ case GL_TEXTURE_2D:
+ table = &texUnit->Current2D->Palette;
+ break;
+ case GL_TEXTURE_3D:
+ table = &texUnit->Current3D->Palette;
+ break;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)");
+ return;
+ }
+ table = &texUnit->CurrentCubeMap->Palette;
+ break;
+ case GL_SHARED_TEXTURE_PALETTE_EXT:
+ table = &ctx->Texture.Palette;
+ break;
+ case GL_COLOR_TABLE:
+ table = &ctx->ColorTable;
+ break;
+ case GL_TEXTURE_COLOR_TABLE_SGI:
+ if (!ctx->Extensions.SGI_texture_color_table) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)");
+ return;
+ }
+ table = &(texUnit->ColorTable);
+ break;
+ case GL_POST_CONVOLUTION_COLOR_TABLE:
+ table = &ctx->PostConvolutionColorTable;
+ break;
+ case GL_POST_COLOR_MATRIX_COLOR_TABLE:
+ table = &ctx->PostColorMatrixColorTable;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)");
+ return;
+ }
+
+ ASSERT(table);
+
+ switch (table->Format) {
+ case GL_ALPHA:
+ if (table->Type == GL_FLOAT) {
+ const GLfloat *tableF = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = 0;
+ rgba[i][GCOMP] = 0;
+ rgba[i][BCOMP] = 0;
+ rgba[i][ACOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ }
+ }
+ else {
+ const GLchan *tableUB = (const GLchan *) table->Table;
+ GLuint i;
+ 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:
+ if (table->Type == GL_FLOAT) {
+ const GLfloat *tableF = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ rgba[i][GCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ rgba[i][BCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ rgba[i][ACOMP] = CHAN_MAX;
+ }
+ }
+ else {
+ const GLchan *tableUB = (const GLchan *) table->Table;
+ GLuint i;
+ 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] = CHAN_MAX;
+ }
+ }
+ break;
+ case GL_LUMINANCE_ALPHA:
+ if (table->Type == GL_FLOAT) {
+ const GLfloat *tableF = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = IROUND_POS(tableF[i*2+0] * CHAN_MAXF);
+ rgba[i][GCOMP] = IROUND_POS(tableF[i*2+0] * CHAN_MAXF);
+ rgba[i][BCOMP] = IROUND_POS(tableF[i*2+0] * CHAN_MAXF);
+ rgba[i][ACOMP] = IROUND_POS(tableF[i*2+1] * CHAN_MAXF);
+ }
+ }
+ else {
+ const GLchan *tableUB = (const GLchan *) table->Table;
+ GLuint i;
+ 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:
+ if (table->Type == GL_FLOAT) {
+ const GLfloat *tableF = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ rgba[i][GCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ rgba[i][BCOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ rgba[i][ACOMP] = IROUND_POS(tableF[i] * CHAN_MAXF);
+ }
+ }
+ else {
+ const GLchan *tableUB = (const GLchan *) table->Table;
+ GLuint i;
+ 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:
+ if (table->Type == GL_FLOAT) {
+ const GLfloat *tableF = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = IROUND_POS(tableF[i*3+0] * CHAN_MAXF);
+ rgba[i][GCOMP] = IROUND_POS(tableF[i*3+1] * CHAN_MAXF);
+ rgba[i][BCOMP] = IROUND_POS(tableF[i*3+2] * CHAN_MAXF);
+ rgba[i][ACOMP] = CHAN_MAX;
+ }
+ }
+ else {
+ const GLchan *tableUB = (const GLchan *) table->Table;
+ GLuint i;
+ 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] = CHAN_MAX;
+ }
+ }
+ break;
+ case GL_RGBA:
+ if (table->Type == GL_FLOAT) {
+ const GLfloat *tableF = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < table->Size; i++) {
+ rgba[i][RCOMP] = IROUND_POS(tableF[i*4+0] * CHAN_MAXF);
+ rgba[i][GCOMP] = IROUND_POS(tableF[i*4+1] * CHAN_MAXF);
+ rgba[i][BCOMP] = IROUND_POS(tableF[i*4+2] * CHAN_MAXF);
+ rgba[i][ACOMP] = IROUND_POS(tableF[i*4+3] * CHAN_MAXF);
+ }
+ }
+ else {
+ const GLchan *tableUB = (const GLchan *) table->Table;
+ GLuint i;
+ 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:
+ _mesa_problem(ctx, "bad table format in glGetColorTable");
+ return;
+ }
+
+ if (ctx->Pack.BufferObj->Name) {
+ /* pack color table into PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(1, &ctx->Pack, table->Size, 1, 1,
+ format, type, data)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetColorTable(invalid PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ GL_WRITE_ONLY_ARB,
+ ctx->Pack.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetColorTable(PBO is mapped)");
+ return;
+ }
+ data = ADD_POINTERS(buf, data);
+ }
+
+ _mesa_pack_rgba_span_chan(ctx, table->Size, (const GLchan (*)[4]) rgba,
+ format, type, data, &ctx->Pack, GL_FALSE);
+
+ if (ctx->Pack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ ctx->Pack.BufferObj);
+ }
+}
+
+
+
+void GLAPIENTRY
+_mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ 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 {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
+ return;
+ }
+ break;
+ case GL_TEXTURE_COLOR_TABLE_SGI:
+ if (!ctx->Extensions.SGI_texture_color_table) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)");
+ return;
+ }
+ if (pname == GL_COLOR_TABLE_SCALE_SGI) {
+ ctx->Pixel.TextureColorTableScale[0] = params[0];
+ ctx->Pixel.TextureColorTableScale[1] = params[1];
+ ctx->Pixel.TextureColorTableScale[2] = params[2];
+ ctx->Pixel.TextureColorTableScale[3] = params[3];
+ }
+ else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
+ ctx->Pixel.TextureColorTableBias[0] = params[0];
+ ctx->Pixel.TextureColorTableBias[1] = params[1];
+ ctx->Pixel.TextureColorTableBias[2] = params[2];
+ ctx->Pixel.TextureColorTableBias[3] = params[3];
+ }
+ else {
+ _mesa_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 {
+ _mesa_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 {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)");
+ return;
+ }
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)");
+ return;
+ }
+
+ ctx->NewState |= _NEW_PIXEL;
+}
+
+
+
+void GLAPIENTRY
+_mesa_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
+{
+ GLfloat fparams[4];
+ if (pname == GL_COLOR_TABLE_SGI ||
+ pname == GL_TEXTURE_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 GLAPIENTRY
+_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 *table = NULL;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ switch (target) {
+ case GL_TEXTURE_1D:
+ table = &texUnit->Current1D->Palette;
+ break;
+ case GL_TEXTURE_2D:
+ table = &texUnit->Current2D->Palette;
+ break;
+ case GL_TEXTURE_3D:
+ table = &texUnit->Current3D->Palette;
+ break;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetColorTableParameterfv(target)");
+ return;
+ }
+ table = &texUnit->CurrentCubeMap->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_PROXY_TEXTURE_CUBE_MAP_ARB:
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetColorTableParameterfv(target)");
+ return;
+ }
+ table = &ctx->Texture.ProxyCubeMap->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] = 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_TEXTURE_COLOR_TABLE_SGI:
+ if (!ctx->Extensions.SGI_texture_color_table) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");
+ return;
+ }
+ table = &(texUnit->ColorTable);
+ if (pname == GL_COLOR_TABLE_SCALE_SGI) {
+ params[0] = ctx->Pixel.TextureColorTableScale[0];
+ params[1] = ctx->Pixel.TextureColorTableScale[1];
+ params[2] = ctx->Pixel.TextureColorTableScale[2];
+ params[3] = ctx->Pixel.TextureColorTableScale[3];
+ return;
+ }
+ else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
+ params[0] = ctx->Pixel.TextureColorTableBias[0];
+ params[1] = ctx->Pixel.TextureColorTableBias[1];
+ params[2] = ctx->Pixel.TextureColorTableBias[2];
+ params[3] = ctx->Pixel.TextureColorTableBias[3];
+ return;
+ }
+ break;
+ case GL_PROXY_TEXTURE_COLOR_TABLE_SGI:
+ if (!ctx->Extensions.SGI_texture_color_table) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");
+ return;
+ }
+ table = &(texUnit->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:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(target)");
+ return;
+ }
+
+ assert(table);
+
+ switch (pname) {
+ case GL_COLOR_TABLE_FORMAT:
+ *params = (GLfloat) table->IntFormat;
+ break;
+ case GL_COLOR_TABLE_WIDTH:
+ *params = (GLfloat) table->Size;
+ break;
+ case GL_COLOR_TABLE_RED_SIZE:
+ *params = (GLfloat) table->RedSize;
+ break;
+ case GL_COLOR_TABLE_GREEN_SIZE:
+ *params = (GLfloat) table->GreenSize;
+ break;
+ case GL_COLOR_TABLE_BLUE_SIZE:
+ *params = (GLfloat) table->BlueSize;
+ break;
+ case GL_COLOR_TABLE_ALPHA_SIZE:
+ *params = (GLfloat) table->AlphaSize;
+ break;
+ case GL_COLOR_TABLE_LUMINANCE_SIZE:
+ *params = (GLfloat) table->LuminanceSize;
+ break;
+ case GL_COLOR_TABLE_INTENSITY_SIZE:
+ *params = (GLfloat) table->IntensitySize;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(pname)" );
+ return;
+ }
+}
+
+
+
+void GLAPIENTRY
+_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);
+
+ switch (target) {
+ case GL_TEXTURE_1D:
+ table = &texUnit->Current1D->Palette;
+ break;
+ case GL_TEXTURE_2D:
+ table = &texUnit->Current2D->Palette;
+ break;
+ case GL_TEXTURE_3D:
+ table = &texUnit->Current3D->Palette;
+ break;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetColorTableParameteriv(target)");
+ return;
+ }
+ table = &texUnit->CurrentCubeMap->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_PROXY_TEXTURE_CUBE_MAP_ARB:
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetColorTableParameteriv(target)");
+ return;
+ }
+ table = &ctx->Texture.ProxyCubeMap->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_TEXTURE_COLOR_TABLE_SGI:
+ if (!ctx->Extensions.SGI_texture_color_table) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");
+ return;
+ }
+ table = &(texUnit->ColorTable);
+ if (pname == GL_COLOR_TABLE_SCALE_SGI) {
+ params[0] = (GLint) ctx->Pixel.TextureColorTableScale[0];
+ params[1] = (GLint) ctx->Pixel.TextureColorTableScale[1];
+ params[2] = (GLint) ctx->Pixel.TextureColorTableScale[2];
+ params[3] = (GLint) ctx->Pixel.TextureColorTableScale[3];
+ return;
+ }
+ else if (pname == GL_COLOR_TABLE_BIAS_SGI) {
+ params[0] = (GLint) ctx->Pixel.TextureColorTableBias[0];
+ params[1] = (GLint) ctx->Pixel.TextureColorTableBias[1];
+ params[2] = (GLint) ctx->Pixel.TextureColorTableBias[2];
+ params[3] = (GLint) ctx->Pixel.TextureColorTableBias[3];
+ return;
+ }
+ break;
+ case GL_PROXY_TEXTURE_COLOR_TABLE_SGI:
+ if (!ctx->Extensions.SGI_texture_color_table) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)");
+ return;
+ }
+ table = &(texUnit->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:
+ _mesa_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:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(pname)" );
+ return;
+ }
+}
+
+/**********************************************************************/
+/***** Initialization *****/
+/**********************************************************************/
+
+
+void
+_mesa_init_colortable( struct gl_color_table *p )
+{
+ p->Type = CHAN_TYPE;
+ p->Table = NULL;
+ p->Size = 0;
+ p->IntFormat = GL_RGBA;
+}
+
+
+
+void
+_mesa_free_colortable_data( struct gl_color_table *p )
+{
+ if (p->Table) {
+ FREE(p->Table);
+ p->Table = NULL;
+ }
+}
+
+
+/*
+ * Initialize all colortables for a context.
+ */
+void _mesa_init_colortables( GLcontext * ctx )
+{
+ /* 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);
+}
+
+
+/*
+ * Free all colortable data for a context
+ */
+void _mesa_free_colortables_data( GLcontext *ctx )
+{
+ _mesa_free_colortable_data(&ctx->ColorTable);
+ _mesa_free_colortable_data(&ctx->ProxyColorTable);
+ _mesa_free_colortable_data(&ctx->PostConvolutionColorTable);
+ _mesa_free_colortable_data(&ctx->ProxyPostConvolutionColorTable);
+ _mesa_free_colortable_data(&ctx->PostColorMatrixColorTable);
+ _mesa_free_colortable_data(&ctx->ProxyPostColorMatrixColorTable);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/colortab.h b/nx-X11/extras/Mesa/src/mesa/main/colortab.h
new file mode 100644
index 000000000..4bd16210a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/colortab.h
@@ -0,0 +1,110 @@
+/**
+ * \file colortab.h
+ * Color tables.
+ *
+ * \if subset
+ * (No-op)
+ *
+ * \endif
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef COLORTAB_H
+#define COLORTAB_H
+
+
+#include "mtypes.h"
+
+#if _HAVE_FULL_GL
+
+extern void GLAPIENTRY
+_mesa_ColorTable( GLenum target, GLenum internalformat,
+ GLsizei width, GLenum format, GLenum type,
+ const GLvoid *table );
+
+extern void GLAPIENTRY
+_mesa_ColorSubTable( GLenum target, GLsizei start,
+ GLsizei count, GLenum format, GLenum type,
+ const GLvoid *table );
+
+extern void GLAPIENTRY
+_mesa_CopyColorSubTable(GLenum target, GLsizei start,
+ GLint x, GLint y, GLsizei width);
+
+extern void GLAPIENTRY
+_mesa_CopyColorTable(GLenum target, GLenum internalformat,
+ GLint x, GLint y, GLsizei width);
+
+extern void GLAPIENTRY
+_mesa_GetColorTable( GLenum target, GLenum format,
+ GLenum type, GLvoid *table );
+
+extern void GLAPIENTRY
+_mesa_ColorTableParameterfv(GLenum target, GLenum pname,
+ const GLfloat *params);
+
+extern void GLAPIENTRY
+_mesa_ColorTableParameteriv(GLenum target, GLenum pname,
+ const GLint *params);
+
+extern void GLAPIENTRY
+_mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params );
+
+extern void GLAPIENTRY
+_mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params );
+
+
+
+extern void
+_mesa_init_colortable( struct gl_color_table *table );
+
+extern void
+_mesa_free_colortable_data( struct gl_color_table *table );
+
+extern void
+_mesa_init_colortables( GLcontext *ctx );
+
+extern void
+_mesa_free_colortables_data( GLcontext *ctx );
+
+#else
+
+/** No-op */
+#define _mesa_init_colortable( p ) ((void) 0)
+
+/** No-op */
+#define _mesa_free_colortable_data( p ) ((void) 0)
+
+/** No-op */
+#define _mesa_init_colortables( p ) ((void)0)
+
+/** No-op */
+#define _mesa_free_colortables_data( p ) ((void)0)
+
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/config.h b/nx-X11/extras/Mesa/src/mesa/main/config.h
new file mode 100644
index 000000000..de2bae9cb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/config.h
@@ -0,0 +1,324 @@
+/**
+ * \file config.h
+ * Tunable configuration parameters.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef CONFIG_H
+#define CONFIG_H
+
+/**
+ * \name OpenGL implementation limits
+ */
+/*@{*/
+
+/** Maximum modelview matrix stack depth */
+#define MAX_MODELVIEW_STACK_DEPTH 32
+
+/** Maximum projection matrix stack depth */
+#define MAX_PROJECTION_STACK_DEPTH 32
+
+/** 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
+
+/** Maximum client attribute stack depth */
+#define MAX_CLIENT_ATTRIB_STACK_DEPTH 16
+
+/** Maximum recursion depth of display list calls */
+#define MAX_LIST_NESTING 64
+
+/** Maximum number of lights */
+#define MAX_LIGHTS 8
+
+/** Maximum user-defined clipping planes */
+#define MAX_CLIP_PLANES 6
+
+/** Maximum pixel map lookup table size */
+#define MAX_PIXEL_MAP_TABLE 256
+
+/** Maximum number of auxillary color buffers */
+#define MAX_AUX_BUFFERS 4
+
+/** Maximum order (degree) of curves */
+#ifdef AMIGA
+# define MAX_EVAL_ORDER 12
+#else
+# define MAX_EVAL_ORDER 30
+#endif
+
+/** Maximum Name stack depth */
+#define MAX_NAME_STACK_DEPTH 64
+
+/** Minimum point size */
+#define MIN_POINT_SIZE 1.0
+/** Maximum point size */
+#define MAX_POINT_SIZE 20.0
+/** Point size granularity */
+#define POINT_SIZE_GRANULARITY 0.1
+
+/** Minimum line width */
+#define MIN_LINE_WIDTH 1.0
+/** Maximum line width */
+#define MAX_LINE_WIDTH 10.0
+/** Line width granularity */
+#define LINE_WIDTH_GRANULARITY 0.1
+
+/** Max texture palette / color table size */
+#define MAX_COLOR_TABLE_SIZE 256
+
+/** Number of 1D/2D texture mipmap levels */
+#define MAX_TEXTURE_LEVELS 12
+
+/** Number of 3D texture mipmap levels */
+#define MAX_3D_TEXTURE_LEVELS 9
+
+/** Number of cube texture mipmap levels - GL_ARB_texture_cube_map */
+#define MAX_CUBE_TEXTURE_LEVELS 12
+
+/** Maximum rectangular texture size - GL_NV_texture_rectangle */
+#define MAX_TEXTURE_RECT_SIZE 2048
+
+/** Number of texture units - GL_ARB_multitexture */
+#define MAX_TEXTURE_UNITS 8
+
+/*@}*/
+
+
+/**
+ * \name Separate numbers of texture coordinates and texture image units.
+ *
+ * These values will eventually replace most instances of MAX_TEXTURE_UNITS.
+ * We should always have MAX_TEXTURE_COORD_UNITS <= MAX_TEXTURE_IMAGE_UNITS.
+ * And, GL_MAX_TEXTURE_UNITS <= MAX_TEXTURE_COORD_UNITS.
+ */
+/*@{*/
+#define MAX_TEXTURE_COORD_UNITS 8
+#define MAX_TEXTURE_IMAGE_UNITS 8
+/*@}*/
+
+/**
+ * Maximum viewport/image width. Must accomodate all texture sizes too.
+ */
+#define MAX_WIDTH 4096
+/** Maximum viewport/image height */
+#define MAX_HEIGHT 4096
+
+/** Maxmimum size for CVA. May be overridden by the drivers. */
+#define MAX_ARRAY_LOCK_SIZE 3000
+
+/** Subpixel precision for antialiasing, window coordinate snapping */
+#define SUB_PIXEL_BITS 4
+
+/** Size of histogram tables */
+#define HISTOGRAM_TABLE_SIZE 256
+
+/** Max convolution filter width */
+#define MAX_CONVOLUTION_WIDTH 9
+/** Max convolution filter height */
+#define MAX_CONVOLUTION_HEIGHT 9
+
+/** For GL_ARB_texture_compression */
+#define MAX_COMPRESSED_TEXTURE_FORMATS 25
+
+/** For GL_EXT_texture_filter_anisotropic */
+#define MAX_TEXTURE_MAX_ANISOTROPY 16.0
+
+/** For GL_EXT_texture_lod_bias (typically MAX_TEXTURE_LEVELS - 1) */
+#define MAX_TEXTURE_LOD_BIAS 11.0
+
+/** For GL_NV_vertex_program */
+/*@{*/
+#define MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS 128
+#define MAX_NV_VERTEX_PROGRAM_TEMPS 12
+#define MAX_NV_VERTEX_PROGRAM_PARAMS 128 /* KW: power of two */
+#define MAX_NV_VERTEX_PROGRAM_INPUTS 16
+#define MAX_NV_VERTEX_PROGRAM_OUTPUTS 15
+/*@}*/
+
+/** For GL_NV_fragment_program */
+/*@{*/
+#define MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS 128
+#define MAX_NV_FRAGMENT_PROGRAM_TEMPS 96
+#define MAX_NV_FRAGMENT_PROGRAM_PARAMS 64
+#define MAX_NV_FRAGMENT_PROGRAM_INPUTS 12
+#define MAX_NV_FRAGMENT_PROGRAM_OUTPUTS 3
+#define MAX_NV_FRAGMENT_PROGRAM_WRITE_ONLYS 2
+/*@}*/
+
+/** For GL_ARB_vertex_program */
+/*@{*/
+#define MAX_VERTEX_PROGRAM_ADDRESS_REGS 1
+#define MAX_VERTEX_PROGRAM_ATTRIBS 16
+/*@}*/
+
+/** For GL_ARB_fragment_program */
+/*@{*/
+#define MAX_FRAGMENT_PROGRAM_ADDRESS_REGS 1
+#define MAX_FRAGMENT_PROGRAM_ALU_INSTRUCTIONS 48
+#define MAX_FRAGMENT_PROGRAM_TEX_INSTRUCTIONS 24
+#define MAX_FRAGMENT_PROGRAM_TEX_INDIRECTIONS 4
+/*@}*/
+
+/** For any program target/extension */
+/*@{*/
+#define MAX_PROGRAM_LOCAL_PARAMS 128 /* KW: power of two */
+#define MAX_PROGRAM_MATRICES 8
+#define MAX_PROGRAM_MATRIX_STACK_DEPTH 4
+/*@}*/
+
+/** For GL_ARB_fragment_shader */
+/*@{*/
+#define MAX_FRAGMENT_UNIFORM_COMPONENTS 64
+/*@}*/
+
+/** For GL_ARB_vertex_shader */
+/*@{*/
+#define MAX_VERTEX_UNIFORM_COMPONENTS 512
+#define MAX_VARYING_FLOATS 32
+#define MAX_VERTEX_TEXTURE_IMAGE_UNITS 0
+#define MAX_COMBINED_TEXTURE_IMAGE_UNITS (MAX_TEXTURE_IMAGE_UNITS + MAX_VERTEX_TEXTURE_IMAGE_UNITS)
+/*@}*/
+
+
+/** For GL_ARB_draw_buffers */
+/*@{*/
+#define MAX_DRAW_BUFFERS 1
+/*@}*/
+
+
+/** For GL_EXT_framebuffer_object */
+/*@{*/
+#define MAX_COLOR_ATTACHMENTS 8
+/*@}*/
+
+
+
+/**
+ * \name Mesa-specific parameters
+ */
+/*@{*/
+
+
+/**
+ * If non-zero use GLdouble for walking triangle edges, for better accuracy.
+ */
+#define TRIANGLE_WALK_DOUBLE 0
+
+/**
+ * Bits per accumulation buffer color component: 8, 16 or 32
+ */
+#define ACCUM_BITS 16
+
+/**
+ * Bits per depth buffer value.
+ *
+ * Any reasonable value up to 31 will work. 32 doesn't work because of integer
+ * overflow problems in the rasterizer code.
+ */
+#ifndef DEFAULT_SOFTWARE_DEPTH_BITS
+#define DEFAULT_SOFTWARE_DEPTH_BITS 16
+#endif
+/** Depth buffer data type */
+#if DEFAULT_SOFTWARE_DEPTH_BITS <= 16
+#define DEFAULT_SOFTWARE_DEPTH_TYPE GLushort
+#else
+#define DEFAULT_SOFTWARE_DEPTH_TYPE GLuint
+#endif
+
+
+/**
+ * Bits per stencil value: 8
+ */
+#define STENCIL_BITS 8
+
+
+/**
+ * Bits per color channel: 8, 16 or 32
+ */
+#ifndef CHAN_BITS
+#define CHAN_BITS 8
+#endif
+
+
+/*
+ * Color channel component order
+ *
+ * \note Changes will almost certainly cause problems at this time.
+ */
+#define RCOMP 0
+#define GCOMP 1
+#define BCOMP 2
+#define ACOMP 3
+
+
+/*
+ * Enable/disable features (blocks of code) by setting FEATURE_xyz to 0 or 1.
+ */
+#ifndef _HAVE_FULL_GL
+#define _HAVE_FULL_GL 1
+#endif
+
+#define FEATURE_ARB_vertex_buffer_object _HAVE_FULL_GL
+#define FEATURE_ARB_vertex_program _HAVE_FULL_GL
+#define FEATURE_ARB_fragment_program _HAVE_FULL_GL
+#define FEATURE_ARB_occlusion_query _HAVE_FULL_GL
+#define FEATURE_EXT_pixel_buffer_object _HAVE_FULL_GL
+#define FEATURE_MESA_program_debug _HAVE_FULL_GL
+#define FEATURE_NV_fence _HAVE_FULL_GL
+#define FEATURE_NV_fragment_program _HAVE_FULL_GL
+#define FEATURE_NV_vertex_program _HAVE_FULL_GL
+#define FEATURE_userclip _HAVE_FULL_GL
+#define FEATURE_texgen _HAVE_FULL_GL
+#define FEATURE_windowpos _HAVE_FULL_GL
+#define FEATURE_ARB_vertex_shader _HAVE_FULL_GL
+#define FEATURE_ARB_fragment_shader _HAVE_FULL_GL
+#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader)
+#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects
+#define FEATURE_ATI_fragment_shader _HAVE_FULL_GL
+#define FEATURE_EXT_framebuffer_object _HAVE_FULL_GL
+/*@}*/
+
+
+/**
+ * Maximum number of temporary vertices required for clipping.
+ *
+ * Used in array_cache and tnl modules.
+ */
+#define MAX_CLIPPED_VERTICES ((2 * (6 + MAX_CLIP_PLANES))+1)
+
+
+/* XXX everything marked with OLD_RENDERBUFFER will be going away... */
+#define OLD_RENDERBUFFER 1
+
+
+#endif /* CONFIG_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/main/context.c b/nx-X11/extras/Mesa/src/mesa/main/context.c
new file mode 100644
index 000000000..25a3f6a37
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/context.c
@@ -0,0 +1,1750 @@
+/**
+ * \file context.c
+ * Mesa context/visual/framebuffer management functions.
+ * \author Brian Paul
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \mainpage Mesa Main Module
+ *
+ * \section MainIntroduction Introduction
+ *
+ * The Mesa Main module consists of all the files in the main/ directory.
+ * Among the features of this module are:
+ * <UL>
+ * <LI> Structures to represent most GL state </LI>
+ * <LI> State set/get functions </LI>
+ * <LI> Display lists </LI>
+ * <LI> Texture unit, object and image handling </LI>
+ * <LI> Matrix and attribute stacks </LI>
+ * </UL>
+ *
+ * Other modules are responsible for API dispatch, vertex transformation,
+ * point/line/triangle setup, rasterization, vertex array caching,
+ * vertex/fragment programs/shaders, etc.
+ *
+ *
+ * \section AboutDoxygen About Doxygen
+ *
+ * If you're viewing this information as Doxygen-generated HTML you'll
+ * see the documentation index at the top of this page.
+ *
+ * The first line lists the Mesa source code modules.
+ * The second line lists the indexes available for viewing the documentation
+ * for each module.
+ *
+ * Selecting the <b>Main page</b> link will display a summary of the module
+ * (this page).
+ *
+ * Selecting <b>Data Structures</b> will list all C structures.
+ *
+ * Selecting the <b>File List</b> link will list all the source files in
+ * the module.
+ * Selecting a filename will show a list of all functions defined in that file.
+ *
+ * Selecting the <b>Data Fields</b> link will display a list of all
+ * documented structure members.
+ *
+ * Selecting the <b>Globals</b> link will display a list
+ * of all functions, structures, global variables and macros in the module.
+ *
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "accum.h"
+#include "attrib.h"
+#include "blend.h"
+#include "buffers.h"
+#include "bufferobj.h"
+#include "colortab.h"
+#include "context.h"
+#include "debug.h"
+#include "depth.h"
+#include "dlist.h"
+#include "eval.h"
+#include "enums.h"
+#include "extensions.h"
+#include "fbobject.h"
+#include "feedback.h"
+#include "fog.h"
+#include "get.h"
+#include "glthread.h"
+#include "glapioffsets.h"
+#include "histogram.h"
+#include "hint.h"
+#include "hash.h"
+#include "light.h"
+#include "lines.h"
+#include "macros.h"
+#include "matrix.h"
+#include "occlude.h"
+#include "pixel.h"
+#include "points.h"
+#include "polygon.h"
+#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program
+#include "program.h"
+#endif
+#include "rastpos.h"
+#include "simple_list.h"
+#include "state.h"
+#include "stencil.h"
+#include "texcompress.h"
+#include "teximage.h"
+#include "texobj.h"
+#include "texstate.h"
+#include "mtypes.h"
+#include "varray.h"
+#include "version.h"
+#include "vtxfmt.h"
+#if _HAVE_FULL_GL
+#include "math/m_translate.h"
+#include "math/m_matrix.h"
+#include "math/m_xform.h"
+#include "math/mathmod.h"
+#endif
+#include "shaderobjects.h"
+
+#ifdef USE_SPARC_ASM
+#include "sparc/sparc.h"
+#endif
+
+#ifndef MESA_VERBOSE
+int MESA_VERBOSE = 0;
+#endif
+
+#ifndef MESA_DEBUG_FLAGS
+int MESA_DEBUG_FLAGS = 0;
+#endif
+
+
+/* ubyte -> float conversion */
+GLfloat _mesa_ubyte_to_float_color_tab[256];
+
+static void
+free_shared_state( GLcontext *ctx, struct gl_shared_state *ss );
+
+
+/**********************************************************************/
+/** \name OpenGL SI-style interface (new in Mesa 3.5)
+ *
+ * \if subset
+ * \note Most of these functions are never called in the Mesa subset.
+ * \endif
+ */
+/*@{*/
+
+/**
+ * Destroy context callback.
+ *
+ * \param gc context.
+ * \return GL_TRUE on success, or GL_FALSE on failure.
+ *
+ * \ifnot subset
+ * Called by window system/device driver (via __GLexports::destroyCurrent) when
+ * the rendering context is to be destroyed.
+ * \endif
+ *
+ * Frees the context data and the context structure.
+ */
+GLboolean
+_mesa_destroyContext(__GLcontext *gc)
+{
+ if (gc) {
+ _mesa_free_context_data(gc);
+ _mesa_free(gc);
+ }
+ return GL_TRUE;
+}
+
+/**
+ * Unbind context callback.
+ *
+ * \param gc context.
+ * \return GL_TRUE on success, or GL_FALSE on failure.
+ *
+ * \ifnot subset
+ * Called by window system/device driver (via __GLexports::loseCurrent)
+ * when the rendering context is made non-current.
+ * \endif
+ *
+ * No-op
+ */
+GLboolean
+_mesa_loseCurrent(__GLcontext *gc)
+{
+ /* XXX unbind context from thread */
+ (void) gc;
+ return GL_TRUE;
+}
+
+/**
+ * Bind context callback.
+ *
+ * \param gc context.
+ * \return GL_TRUE on success, or GL_FALSE on failure.
+ *
+ * \ifnot subset
+ * Called by window system/device driver (via __GLexports::makeCurrent)
+ * when the rendering context is made current.
+ * \endif
+ *
+ * No-op
+ */
+GLboolean
+_mesa_makeCurrent(__GLcontext *gc)
+{
+ /* XXX bind context to thread */
+ (void) gc;
+ return GL_TRUE;
+}
+
+/**
+ * Share context callback.
+ *
+ * \param gc context.
+ * \param gcShare shared context.
+ * \return GL_TRUE on success, or GL_FALSE on failure.
+ *
+ * \ifnot subset
+ * Called by window system/device driver (via __GLexports::shareContext)
+ * \endif
+ *
+ * Update the shared context reference count, gl_shared_state::RefCount.
+ */
+GLboolean
+_mesa_shareContext(__GLcontext *gc, __GLcontext *gcShare)
+{
+ if (gc && gcShare && gc->Shared && gcShare->Shared) {
+ gc->Shared->RefCount--;
+ if (gc->Shared->RefCount == 0) {
+ free_shared_state(gc, gc->Shared);
+ }
+ gc->Shared = gcShare->Shared;
+ gc->Shared->RefCount++;
+ return GL_TRUE;
+ }
+ else {
+ return GL_FALSE;
+ }
+}
+
+
+#if _HAVE_FULL_GL
+/**
+ * Copy context callback.
+ */
+GLboolean
+_mesa_copyContext(__GLcontext *dst, const __GLcontext *src, GLuint mask)
+{
+ if (dst && src) {
+ _mesa_copy_context( src, dst, mask );
+ return GL_TRUE;
+ }
+ else {
+ return GL_FALSE;
+ }
+}
+#endif
+
+/** No-op */
+GLboolean
+_mesa_forceCurrent(__GLcontext *gc)
+{
+ (void) gc;
+ return GL_TRUE;
+}
+
+/**
+ * Windows/buffer resizing notification callback.
+ *
+ * \param gc GL context.
+ * \return GL_TRUE on success, or GL_FALSE on failure.
+ */
+GLboolean
+_mesa_notifyResize(__GLcontext *gc)
+{
+ GLint x, y;
+ GLuint width, height;
+ __GLdrawablePrivate *d = gc->imports.getDrawablePrivate(gc);
+ if (!d || !d->getDrawableSize)
+ return GL_FALSE;
+ d->getDrawableSize( d, &x, &y, &width, &height );
+ /* update viewport, resize software buffers, etc. */
+ return GL_TRUE;
+}
+
+/**
+ * Window/buffer destruction notification callback.
+ *
+ * \param gc GL context.
+ *
+ * Called when the context's window/buffer is going to be destroyed.
+ *
+ * No-op
+ */
+void
+_mesa_notifyDestroy(__GLcontext *gc)
+{
+ /* Unbind from it. */
+ (void) gc;
+}
+
+/**
+ * Swap buffers notification callback.
+ *
+ * \param gc GL context.
+ *
+ * Called by window system just before swapping buffers.
+ * We have to finish any pending rendering.
+ */
+void
+_mesa_notifySwapBuffers(__GLcontext *gc)
+{
+ FLUSH_VERTICES( gc, 0 );
+}
+
+/** No-op */
+struct __GLdispatchStateRec *
+_mesa_dispatchExec(__GLcontext *gc)
+{
+ (void) gc;
+ return NULL;
+}
+
+/** No-op */
+void
+_mesa_beginDispatchOverride(__GLcontext *gc)
+{
+ (void) gc;
+}
+
+/** No-op */
+void
+_mesa_endDispatchOverride(__GLcontext *gc)
+{
+ (void) gc;
+}
+
+/**
+ * \ifnot subset
+ * Setup the exports.
+ *
+ * The window system will call these functions when it needs Mesa to do
+ * something.
+ *
+ * \note Device drivers should override these functions! For example,
+ * the Xlib driver should plug in the XMesa*-style functions into this
+ * structure. The XMesa-style functions should then call the _mesa_*
+ * version of these functions. This is an approximation to OO design
+ * (inheritance and virtual functions).
+ * \endif
+ *
+ * \if subset
+ * No-op.
+ *
+ * \endif
+ */
+static void
+_mesa_init_default_exports(__GLexports *exports)
+{
+#if _HAVE_FULL_GL
+ exports->destroyContext = _mesa_destroyContext;
+ exports->loseCurrent = _mesa_loseCurrent;
+ exports->makeCurrent = _mesa_makeCurrent;
+ exports->shareContext = _mesa_shareContext;
+ exports->copyContext = _mesa_copyContext;
+ exports->forceCurrent = _mesa_forceCurrent;
+ exports->notifyResize = _mesa_notifyResize;
+ exports->notifyDestroy = _mesa_notifyDestroy;
+ exports->notifySwapBuffers = _mesa_notifySwapBuffers;
+ exports->dispatchExec = _mesa_dispatchExec;
+ exports->beginDispatchOverride = _mesa_beginDispatchOverride;
+ exports->endDispatchOverride = _mesa_endDispatchOverride;
+#else
+ (void) exports;
+#endif
+}
+
+/**
+ * Exported OpenGL SI interface.
+ */
+__GLcontext *
+__glCoreCreateContext(__GLimports *imports, __GLcontextModes *modes)
+{
+ GLcontext *ctx;
+
+ ctx = (GLcontext *) (*imports->calloc)(NULL, 1, sizeof(GLcontext));
+ if (ctx == NULL) {
+ return NULL;
+ }
+
+ /* XXX doesn't work at this time */
+ _mesa_initialize_context(ctx, modes, NULL, NULL, NULL);
+ ctx->imports = *imports;
+
+ return ctx;
+}
+
+/**
+ * Exported OpenGL SI interface.
+ */
+void
+__glCoreNopDispatch(void)
+{
+#if 0
+ /* SI */
+ __gl_dispatch = __glNopDispatchState;
+#else
+ /* Mesa */
+ _glapi_set_dispatch(NULL);
+#endif
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name GL Visual allocation/destruction */
+/**********************************************************************/
+/*@{*/
+
+/**
+ * Allocates a GLvisual structure and initializes it via
+ * _mesa_initialize_visual().
+ *
+ * \param rgbFlag GL_TRUE for RGB(A) mode, GL_FALSE for Color Index mode.
+ * \param dbFlag double buffering
+ * \param stereoFlag stereo buffer
+ * \param 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.
+ * \param stencilBits requested minimum bits per stencil buffer value
+ * \param accumRedBits, accumGreenBits, accumBlueBits, accumAlphaBits number of bits per color component in accum buffer.
+ * \param indexBits number of bits per pixel if \p rgbFlag is GL_FALSE
+ * \param redBits number of bits per color component in frame buffer for RGB(A)
+ * mode. We always use 8 in core Mesa though.
+ * \param greenBits same as above.
+ * \param blueBits same as above.
+ * \param alphaBits same as above.
+ * \param numSamples not really used.
+ *
+ * \return pointer to new GLvisual or NULL if requested parameters can't be
+ * met.
+ *
+ * \note Need to add params for level and numAuxBuffers (at least)
+ */
+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 )
+{
+ 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;
+}
+
+/**
+ * Makes some sanity checks and fills in the fields of the
+ * GLvisual object with the given parameters. If the caller needs
+ * to set additional fields, he should just probably init the whole GLvisual
+ * object himself.
+ * \return GL_TRUE on success, or GL_FALSE on failure.
+ *
+ * \sa _mesa_create_visual() above for the parameter description.
+ */
+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 )
+{
+ assert(vis);
+
+ if (depthBits < 0 || depthBits > 32) {
+ return GL_FALSE;
+ }
+ if (stencilBits < 0 || stencilBits > STENCIL_BITS) {
+ return GL_FALSE;
+ }
+ if (accumRedBits < 0 || accumRedBits > ACCUM_BITS) {
+ return GL_FALSE;
+ }
+ if (accumGreenBits < 0 || accumGreenBits > ACCUM_BITS) {
+ return GL_FALSE;
+ }
+ if (accumBlueBits < 0 || accumBlueBits > ACCUM_BITS) {
+ return GL_FALSE;
+ }
+ if (accumAlphaBits < 0 || accumAlphaBits > ACCUM_BITS) {
+ return GL_FALSE;
+ }
+
+ vis->rgbMode = rgbFlag;
+ vis->doubleBufferMode = dbFlag;
+ vis->stereoMode = stereoFlag;
+
+ vis->redBits = redBits;
+ vis->greenBits = greenBits;
+ vis->blueBits = blueBits;
+ vis->alphaBits = alphaBits;
+ vis->rgbBits = redBits + greenBits + blueBits;
+
+ vis->indexBits = indexBits;
+ vis->depthBits = depthBits;
+ vis->stencilBits = stencilBits;
+
+ vis->accumRedBits = accumRedBits;
+ vis->accumGreenBits = accumGreenBits;
+ vis->accumBlueBits = accumBlueBits;
+ vis->accumAlphaBits = accumAlphaBits;
+
+ vis->haveAccumBuffer = accumRedBits > 0;
+ vis->haveDepthBuffer = depthBits > 0;
+ vis->haveStencilBuffer = stencilBits > 0;
+
+ vis->numAuxBuffers = 0;
+ vis->level = 0;
+ vis->pixmapMode = 0;
+ vis->sampleBuffers = numSamples > 0 ? 1 : 0;
+ vis->samples = numSamples;
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Destroy a visual and free its memory.
+ *
+ * \param vis visual.
+ *
+ * Frees the visual structure.
+ */
+void
+_mesa_destroy_visual( GLvisual *vis )
+{
+ FREE(vis);
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Context allocation, initialization, destroying
+ *
+ * The purpose of the most initialization functions here is to provide the
+ * default state values according to the OpenGL specification.
+ */
+/**********************************************************************/
+/*@{*/
+
+/**
+ * One-time initialization mutex lock.
+ *
+ * \sa Used by one_time_init().
+ */
+_glthread_DECLARE_STATIC_MUTEX(OneTimeLock);
+
+/**
+ * Calls all the various one-time-init functions in Mesa.
+ *
+ * While holding a global mutex lock, calls several initialization functions,
+ * and sets the glapi callbacks if the \c MESA_DEBUG environment variable is
+ * defined.
+ *
+ * \sa _mesa_init_lists(), _math_init().
+ */
+static void
+one_time_init( GLcontext *ctx )
+{
+ static GLboolean alreadyCalled = GL_FALSE;
+ (void) ctx;
+ _glthread_LOCK_MUTEX(OneTimeLock);
+ if (!alreadyCalled) {
+ GLuint i;
+
+ /* do some implementation tests */
+ assert( sizeof(GLbyte) == 1 );
+ assert( sizeof(GLubyte) == 1 );
+ assert( sizeof(GLshort) == 2 );
+ assert( sizeof(GLushort) == 2 );
+ assert( sizeof(GLint) == 4 );
+ assert( sizeof(GLuint) == 4 );
+
+ _mesa_init_lists();
+
+#if _HAVE_FULL_GL
+ _math_init();
+
+ for (i = 0; i < 256; i++) {
+ _mesa_ubyte_to_float_color_tab[i] = (float) i / 255.0F;
+ }
+#endif
+
+#ifdef USE_SPARC_ASM
+ _mesa_init_sparc_glapi_relocs();
+#endif
+ if (_mesa_getenv("MESA_DEBUG")) {
+ _glapi_noop_enable_warnings(GL_TRUE);
+ _glapi_set_warning_func( (_glapi_warning_func) _mesa_warning );
+ }
+ else {
+ _glapi_noop_enable_warnings(GL_FALSE);
+ }
+
+#if defined(DEBUG) && defined(__DATE__) && defined(__TIME__)
+ _mesa_debug(ctx, "Mesa %s DEBUG build %s %s\n",
+ MESA_VERSION_STRING, __DATE__, __TIME__);
+#endif
+
+ alreadyCalled = GL_TRUE;
+ }
+ _glthread_UNLOCK_MUTEX(OneTimeLock);
+}
+
+
+/**
+ * Allocate and initialize a shared context state structure.
+ * Initializes the display list, texture objects and vertex programs hash
+ * tables, allocates the texture objects. If it runs out of memory, frees
+ * everything already allocated before returning NULL.
+ *
+ * \return pointer to a gl_shared_state structure on success, or NULL on
+ * failure.
+ */
+static GLboolean
+alloc_shared_state( GLcontext *ctx )
+{
+ struct gl_shared_state *ss = CALLOC_STRUCT(gl_shared_state);
+ if (!ss)
+ return GL_FALSE;
+
+ ctx->Shared = ss;
+
+ _glthread_INIT_MUTEX(ss->Mutex);
+
+ ss->DisplayList = _mesa_NewHashTable();
+ ss->TexObjects = _mesa_NewHashTable();
+#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program
+ ss->Programs = _mesa_NewHashTable();
+#endif
+
+#if FEATURE_ARB_vertex_program
+ ss->DefaultVertexProgram = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
+ if (!ss->DefaultVertexProgram)
+ goto cleanup;
+#endif
+#if FEATURE_ARB_fragment_program
+ ss->DefaultFragmentProgram = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
+ if (!ss->DefaultFragmentProgram)
+ goto cleanup;
+#endif
+#if FEATURE_ATI_fragment_shader
+ ss->DefaultFragmentShader = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_SHADER_ATI, 0);
+ if (!ss->DefaultFragmentShader)
+ goto cleanup;
+#endif
+
+ ss->BufferObjects = _mesa_NewHashTable();
+
+ ss->GL2Objects = _mesa_NewHashTable ();
+
+ ss->Default1D = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_1D);
+ if (!ss->Default1D)
+ goto cleanup;
+
+ ss->Default2D = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_2D);
+ if (!ss->Default2D)
+ goto cleanup;
+
+ ss->Default3D = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_3D);
+ if (!ss->Default3D)
+ goto cleanup;
+
+ ss->DefaultCubeMap = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_CUBE_MAP_ARB);
+ if (!ss->DefaultCubeMap)
+ goto cleanup;
+
+ ss->DefaultRect = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_RECTANGLE_NV);
+ if (!ss->DefaultRect)
+ goto cleanup;
+
+ /* Effectively bind the default textures to all texture units */
+ ss->Default1D->RefCount += MAX_TEXTURE_IMAGE_UNITS;
+ ss->Default2D->RefCount += MAX_TEXTURE_IMAGE_UNITS;
+ ss->Default3D->RefCount += MAX_TEXTURE_IMAGE_UNITS;
+ ss->DefaultCubeMap->RefCount += MAX_TEXTURE_IMAGE_UNITS;
+ ss->DefaultRect->RefCount += MAX_TEXTURE_IMAGE_UNITS;
+
+#if FEATURE_EXT_framebuffer_object
+ ss->FrameBuffers = _mesa_NewHashTable();
+ if (!ss->FrameBuffers)
+ goto cleanup;
+ ss->RenderBuffers = _mesa_NewHashTable();
+ if (!ss->RenderBuffers)
+ goto cleanup;
+#endif
+
+
+ return GL_TRUE;
+
+ cleanup:
+ /* Ran out of memory at some point. Free everything and return NULL */
+ if (ss->DisplayList)
+ _mesa_DeleteHashTable(ss->DisplayList);
+ if (ss->TexObjects)
+ _mesa_DeleteHashTable(ss->TexObjects);
+#if FEATURE_NV_vertex_program
+ if (ss->Programs)
+ _mesa_DeleteHashTable(ss->Programs);
+#endif
+#if FEATURE_ARB_vertex_program
+ if (ss->DefaultVertexProgram)
+ ctx->Driver.DeleteProgram(ctx, ss->DefaultVertexProgram);
+#endif
+#if FEATURE_ARB_fragment_program
+ if (ss->DefaultFragmentProgram)
+ ctx->Driver.DeleteProgram(ctx, ss->DefaultFragmentProgram);
+#endif
+#if FEATURE_ATI_fragment_shader
+ if (ss->DefaultFragmentShader)
+ ctx->Driver.DeleteProgram(ctx, ss->DefaultFragmentShader);
+#endif
+#if FEATURE_ARB_vertex_buffer_object
+ if (ss->BufferObjects)
+ _mesa_DeleteHashTable(ss->BufferObjects);
+#endif
+
+ if (ss->GL2Objects)
+ _mesa_DeleteHashTable (ss->GL2Objects);
+
+#if FEATURE_EXT_framebuffer_object
+ if (ss->FrameBuffers)
+ _mesa_DeleteHashTable(ss->FrameBuffers);
+ if (ss->RenderBuffers)
+ _mesa_DeleteHashTable(ss->RenderBuffers);
+#endif
+
+ if (ss->Default1D)
+ (*ctx->Driver.DeleteTexture)(ctx, ss->Default1D);
+ if (ss->Default2D)
+ (*ctx->Driver.DeleteTexture)(ctx, ss->Default2D);
+ if (ss->Default3D)
+ (*ctx->Driver.DeleteTexture)(ctx, ss->Default3D);
+ if (ss->DefaultCubeMap)
+ (*ctx->Driver.DeleteTexture)(ctx, ss->DefaultCubeMap);
+ if (ss->DefaultRect)
+ (*ctx->Driver.DeleteTexture)(ctx, ss->DefaultRect);
+ if (ss)
+ _mesa_free(ss);
+ return GL_FALSE;
+}
+
+/**
+ * Deallocate a shared state context and all children structures.
+ *
+ * \param ctx GL context.
+ * \param ss shared state pointer.
+ *
+ * Frees the display lists, the texture objects (calling the driver texture
+ * deletion callback to free its private data) and the vertex programs, as well
+ * as their hash tables.
+ *
+ * \sa alloc_shared_state().
+ */
+static void
+free_shared_state( GLcontext *ctx, struct gl_shared_state *ss )
+{
+ /* Free display lists */
+ while (1) {
+ GLuint list = _mesa_HashFirstEntry(ss->DisplayList);
+ if (list) {
+ _mesa_destroy_list(ctx, list);
+ }
+ else {
+ break;
+ }
+ }
+ _mesa_DeleteHashTable(ss->DisplayList);
+
+ /* Free texture objects */
+ ASSERT(ctx->Driver.DeleteTexture);
+ /* the default textures */
+ (*ctx->Driver.DeleteTexture)(ctx, ss->Default1D);
+ (*ctx->Driver.DeleteTexture)(ctx, ss->Default2D);
+ (*ctx->Driver.DeleteTexture)(ctx, ss->Default3D);
+ (*ctx->Driver.DeleteTexture)(ctx, ss->DefaultCubeMap);
+ (*ctx->Driver.DeleteTexture)(ctx, ss->DefaultRect);
+ /* all other textures */
+ while (1) {
+ GLuint texName = _mesa_HashFirstEntry(ss->TexObjects);
+ if (texName) {
+ struct gl_texture_object *texObj = (struct gl_texture_object *)
+ _mesa_HashLookup(ss->TexObjects, texName);
+ ASSERT(texObj);
+ (*ctx->Driver.DeleteTexture)(ctx, texObj);
+ _mesa_HashRemove(ss->TexObjects, texName);
+ }
+ else {
+ break;
+ }
+ }
+ _mesa_DeleteHashTable(ss->TexObjects);
+
+#if FEATURE_NV_vertex_program
+ /* Free vertex programs */
+ while (1) {
+ GLuint prog = _mesa_HashFirstEntry(ss->Programs);
+ if (prog) {
+ struct program *p = (struct program *) _mesa_HashLookup(ss->Programs,
+ prog);
+ ASSERT(p);
+ ctx->Driver.DeleteProgram(ctx, p);
+ _mesa_HashRemove(ss->Programs, prog);
+ }
+ else {
+ break;
+ }
+ }
+ _mesa_DeleteHashTable(ss->Programs);
+#endif
+#if FEATURE_ARB_vertex_program
+ _mesa_delete_program(ctx, ss->DefaultVertexProgram);
+#endif
+#if FEATURE_ARB_fragment_program
+ _mesa_delete_program(ctx, ss->DefaultFragmentProgram);
+#endif
+#if FEATURE_ATI_fragment_shader
+ _mesa_delete_program(ctx, ss->DefaultFragmentShader);
+#endif
+
+#if FEATURE_ARB_vertex_buffer_object
+ _mesa_DeleteHashTable(ss->BufferObjects);
+#endif
+
+ _mesa_DeleteHashTable (ss->GL2Objects);
+
+#if FEATURE_EXT_framebuffer_object
+ _mesa_DeleteHashTable(ss->FrameBuffers);
+ _mesa_DeleteHashTable(ss->RenderBuffers);
+#endif
+
+ _glthread_DESTROY_MUTEX(ss->Mutex);
+
+ FREE(ss);
+}
+
+
+/**
+ * Initialize fields of gl_current_attrib (aka ctx->Current.*)
+ */
+static void
+_mesa_init_current( GLcontext *ctx )
+{
+ GLuint i;
+
+ /* Current group */
+ for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+ ASSIGN_4V( ctx->Current.Attrib[i], 0.0, 0.0, 0.0, 1.0 );
+ }
+ /* special cases: */
+ ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_WEIGHT], 1.0, 0.0, 0.0, 1.0 );
+ ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_NORMAL], 0.0, 0.0, 1.0, 1.0 );
+ ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR0], 1.0, 1.0, 1.0, 1.0 );
+ ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_COLOR1], 0.0, 0.0, 0.0, 1.0 );
+ ASSIGN_4V( ctx->Current.Attrib[VERT_ATTRIB_FOG], 0.0, 0.0, 0.0, 0.0 );
+
+ ctx->Current.Index = 1;
+ ctx->Current.EdgeFlag = GL_TRUE;
+}
+
+
+/**
+ * Initialize fields of gl_constants (aka ctx->Const.*).
+ * Use defaults from config.h. The device drivers will often override
+ * some of these values (such as number of texture units).
+ */
+static void
+_mesa_init_constants( GLcontext *ctx )
+{
+ assert(ctx);
+
+ assert(MAX_TEXTURE_LEVELS >= MAX_3D_TEXTURE_LEVELS);
+ assert(MAX_TEXTURE_LEVELS >= MAX_CUBE_TEXTURE_LEVELS);
+
+ /* Constants, may be overriden (usually only reduced) by device drivers */
+ ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS;
+ ctx->Const.Max3DTextureLevels = MAX_3D_TEXTURE_LEVELS;
+ ctx->Const.MaxCubeTextureLevels = MAX_CUBE_TEXTURE_LEVELS;
+ ctx->Const.MaxTextureRectSize = MAX_TEXTURE_RECT_SIZE;
+ ctx->Const.MaxTextureUnits = MAX_TEXTURE_UNITS;
+ ctx->Const.MaxTextureCoordUnits = MAX_TEXTURE_COORD_UNITS;
+ ctx->Const.MaxTextureImageUnits = MAX_TEXTURE_IMAGE_UNITS;
+ ctx->Const.MaxTextureMaxAnisotropy = MAX_TEXTURE_MAX_ANISOTROPY;
+ ctx->Const.MaxTextureLodBias = MAX_TEXTURE_LOD_BIAS;
+ ctx->Const.MaxArrayLockSize = MAX_ARRAY_LOCK_SIZE;
+ ctx->Const.SubPixelBits = SUB_PIXEL_BITS;
+ ctx->Const.MinPointSize = MIN_POINT_SIZE;
+ ctx->Const.MaxPointSize = MAX_POINT_SIZE;
+ ctx->Const.MinPointSizeAA = MIN_POINT_SIZE;
+ ctx->Const.MaxPointSizeAA = MAX_POINT_SIZE;
+ ctx->Const.PointSizeGranularity = (GLfloat) POINT_SIZE_GRANULARITY;
+ ctx->Const.MinLineWidth = MIN_LINE_WIDTH;
+ ctx->Const.MaxLineWidth = MAX_LINE_WIDTH;
+ ctx->Const.MinLineWidthAA = MIN_LINE_WIDTH;
+ ctx->Const.MaxLineWidthAA = MAX_LINE_WIDTH;
+ ctx->Const.LineWidthGranularity = (GLfloat) LINE_WIDTH_GRANULARITY;
+ ctx->Const.MaxColorTableSize = MAX_COLOR_TABLE_SIZE;
+ ctx->Const.MaxConvolutionWidth = MAX_CONVOLUTION_WIDTH;
+ ctx->Const.MaxConvolutionHeight = MAX_CONVOLUTION_HEIGHT;
+ ctx->Const.MaxClipPlanes = MAX_CLIP_PLANES;
+ ctx->Const.MaxLights = MAX_LIGHTS;
+ ctx->Const.MaxShininess = 128.0;
+ ctx->Const.MaxSpotExponent = 128.0;
+ ctx->Const.MaxViewportWidth = MAX_WIDTH;
+ ctx->Const.MaxViewportHeight = MAX_HEIGHT;
+#if FEATURE_ARB_vertex_program
+ ctx->Const.MaxVertexProgramInstructions = MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS;
+ ctx->Const.MaxVertexProgramAttribs = MAX_NV_VERTEX_PROGRAM_INPUTS;
+ ctx->Const.MaxVertexProgramTemps = MAX_NV_VERTEX_PROGRAM_TEMPS;
+ ctx->Const.MaxVertexProgramLocalParams = MAX_NV_VERTEX_PROGRAM_PARAMS;
+ ctx->Const.MaxVertexProgramEnvParams = MAX_NV_VERTEX_PROGRAM_PARAMS;/*XXX*/
+ ctx->Const.MaxVertexProgramAddressRegs = MAX_VERTEX_PROGRAM_ADDRESS_REGS;
+#endif
+#if FEATURE_ARB_fragment_program
+ ctx->Const.MaxFragmentProgramInstructions = MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS;
+ ctx->Const.MaxFragmentProgramAttribs = MAX_NV_FRAGMENT_PROGRAM_INPUTS;
+ ctx->Const.MaxFragmentProgramTemps = MAX_NV_FRAGMENT_PROGRAM_TEMPS;
+ ctx->Const.MaxFragmentProgramLocalParams = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
+ ctx->Const.MaxFragmentProgramEnvParams = MAX_NV_FRAGMENT_PROGRAM_PARAMS;/*XXX*/
+ ctx->Const.MaxFragmentProgramAddressRegs = MAX_FRAGMENT_PROGRAM_ADDRESS_REGS;
+ ctx->Const.MaxFragmentProgramAluInstructions = MAX_FRAGMENT_PROGRAM_ALU_INSTRUCTIONS;
+ ctx->Const.MaxFragmentProgramTexInstructions = MAX_FRAGMENT_PROGRAM_TEX_INSTRUCTIONS;
+ ctx->Const.MaxFragmentProgramTexIndirections = MAX_FRAGMENT_PROGRAM_TEX_INDIRECTIONS;
+#endif
+
+ ctx->Const.MaxProgramMatrices = MAX_PROGRAM_MATRICES;
+ ctx->Const.MaxProgramMatrixStackDepth = MAX_PROGRAM_MATRIX_STACK_DEPTH;
+
+ /* If we're running in the X server, do bounds checking to prevent
+ * segfaults and server crashes!
+ */
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ ctx->Const.CheckArrayBounds = GL_TRUE;
+#else
+ ctx->Const.CheckArrayBounds = GL_FALSE;
+#endif
+
+ ctx->Const.MaxDrawBuffers = MAX_DRAW_BUFFERS;
+
+ /* GL_OES_read_format */
+ ctx->Const.ColorReadFormat = GL_RGBA;
+ ctx->Const.ColorReadType = GL_UNSIGNED_BYTE;
+
+#if FEATURE_EXT_framebuffer_object
+ ctx->Const.MaxColorAttachments = MAX_COLOR_ATTACHMENTS;
+ ctx->Const.MaxRenderbufferSize = MAX_WIDTH;
+#endif
+
+ /* sanity checks */
+ ASSERT(ctx->Const.MaxTextureUnits == MAX2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits));
+}
+
+
+/**
+ * Initialize the attribute groups in a GL context.
+ *
+ * \param ctx GL context.
+ *
+ * Initializes all the attributes, calling the respective <tt>init*</tt>
+ * functions for the more complex data structures.
+ */
+static GLboolean
+init_attrib_groups( GLcontext *ctx )
+{
+ assert(ctx);
+
+ /* Constants */
+ _mesa_init_constants( ctx );
+
+ /* Extensions */
+ _mesa_init_extensions( ctx );
+
+ /* Attribute Groups */
+ _mesa_init_accum( ctx );
+ _mesa_init_attrib( ctx );
+ _mesa_init_buffer_objects( ctx );
+ _mesa_init_color( ctx );
+ _mesa_init_colortables( ctx );
+ _mesa_init_current( ctx );
+ _mesa_init_depth( ctx );
+ _mesa_init_debug( ctx );
+ _mesa_init_display_list( ctx );
+ _mesa_init_eval( ctx );
+ _mesa_init_feedback( ctx );
+ _mesa_init_fog( ctx );
+ _mesa_init_histogram( ctx );
+ _mesa_init_hint( ctx );
+ _mesa_init_line( ctx );
+ _mesa_init_lighting( ctx );
+ _mesa_init_matrix( ctx );
+ _mesa_init_multisample( ctx );
+ _mesa_init_occlude( ctx );
+ _mesa_init_pixel( ctx );
+ _mesa_init_point( ctx );
+ _mesa_init_polygon( ctx );
+ _mesa_init_program( ctx );
+ _mesa_init_rastpos( ctx );
+ _mesa_init_scissor( ctx );
+ _mesa_init_shaderobjects (ctx);
+ _mesa_init_stencil( ctx );
+ _mesa_init_transform( ctx );
+ _mesa_init_varray( ctx );
+ _mesa_init_viewport( ctx );
+
+ if (!_mesa_init_texture( ctx ))
+ return GL_FALSE;
+
+ _mesa_init_texture_s3tc( ctx );
+ _mesa_init_texture_fxt1( ctx );
+
+ /* Miscellaneous */
+ ctx->NewState = _NEW_ALL;
+ ctx->ErrorValue = (GLenum) GL_NO_ERROR;
+ ctx->_Facing = 0;
+#if CHAN_TYPE == GL_FLOAT
+ ctx->ClampFragmentColors = GL_FALSE; /* XXX temporary */
+#else
+ ctx->ClampFragmentColors = GL_TRUE;
+#endif
+ ctx->ClampVertexColors = GL_TRUE;
+
+ return GL_TRUE;
+}
+
+
+/**
+ * This is the default function we plug into all dispatch table slots
+ * This helps prevents a segfault when someone calls a GL function without
+ * first checking if the extension's supported.
+ */
+static int
+generic_nop(void)
+{
+ _mesa_problem(NULL, "User called no-op dispatch function (an unsupported extension function?)");
+ return 0;
+}
+
+
+/**
+ * Allocate and initialize a new dispatch table.
+ */
+static struct _glapi_table *
+alloc_dispatch_table(void)
+{
+ /* 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.
+ */
+ GLint numEntries = MAX2(_glapi_get_dispatch_table_size(),
+ sizeof(struct _glapi_table) / sizeof(_glapi_proc));
+ struct _glapi_table *table =
+ (struct _glapi_table *) _mesa_malloc(numEntries * sizeof(_glapi_proc));
+ if (table) {
+ _glapi_proc *entry = (_glapi_proc *) table;
+ GLint i;
+ for (i = 0; i < numEntries; i++) {
+ entry[i] = (_glapi_proc) generic_nop;
+ }
+ }
+ return table;
+}
+
+
+/**
+ * Initialize a GLcontext struct (rendering context).
+ *
+ * This includes allocating all the other structs and arrays which hang off of
+ * the context by pointers.
+ * Note that the driver needs to pass in its dd_function_table here since
+ * we need to at least call driverFunctions->NewTextureObject to create the
+ * default texture objects.
+ *
+ * Called by _mesa_create_context().
+ *
+ * Performs the imports and exports callback tables initialization, and
+ * miscellaneous one-time initializations. If no shared context is supplied one
+ * is allocated, and increase its reference count. Setups the GL API dispatch
+ * tables. Initialize the TNL module. Sets the maximum Z buffer depth.
+ * Finally queries the \c MESA_DEBUG and \c MESA_VERBOSE environment variables
+ * for debug flags.
+ *
+ * \param ctx the context to initialize
+ * \param visual describes the visual attributes for this context
+ * \param share_list points to context to share textures, display lists,
+ * etc with, or NULL
+ * \param driverFunctions table of device driver functions for this context
+ * to use
+ * \param driverContext pointer to driver-specific context data
+ */
+GLboolean
+_mesa_initialize_context( GLcontext *ctx,
+ const GLvisual *visual,
+ GLcontext *share_list,
+ const struct dd_function_table *driverFunctions,
+ void *driverContext )
+{
+ ASSERT(driverContext);
+ assert(driverFunctions->NewTextureObject);
+ assert(driverFunctions->FreeTexImageData);
+
+ /* If the driver wants core Mesa to use special imports, it'll have to
+ * override these defaults.
+ */
+ _mesa_init_default_imports( &(ctx->imports), driverContext );
+
+ /* initialize the exports (Mesa functions called by the window system) */
+ _mesa_init_default_exports( &(ctx->exports) );
+
+ /* misc one-time initializations */
+ one_time_init(ctx);
+
+ ctx->Visual = *visual;
+ ctx->DrawBuffer = NULL;
+ ctx->ReadBuffer = NULL;
+ ctx->WinSysDrawBuffer = NULL;
+ ctx->WinSysReadBuffer = NULL;
+
+ /* Plug in driver functions and context pointer here.
+ * This is important because when we call alloc_shared_state() below
+ * we'll call ctx->Driver.NewTextureObject() to create the default
+ * textures.
+ */
+ ctx->Driver = *driverFunctions;
+ ctx->DriverCtx = driverContext;
+
+ if (share_list) {
+ /* share state with another context */
+ ctx->Shared = share_list->Shared;
+ }
+ else {
+ /* allocate new, unshared state */
+ if (!alloc_shared_state( ctx )) {
+ return GL_FALSE;
+ }
+ }
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+ ctx->Shared->RefCount++;
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+
+ if (!init_attrib_groups( ctx )) {
+ free_shared_state(ctx, ctx->Shared);
+ return GL_FALSE;
+ }
+
+ /* setup the API dispatch tables */
+ ctx->Exec = alloc_dispatch_table();
+ ctx->Save = alloc_dispatch_table();
+ if (!ctx->Exec || !ctx->Save) {
+ free_shared_state(ctx, ctx->Shared);
+ if (ctx->Exec)
+ _mesa_free(ctx->Exec);
+ }
+ _mesa_init_exec_table(ctx->Exec);
+ ctx->CurrentDispatch = ctx->Exec;
+#if _HAVE_FULL_GL
+ _mesa_init_dlist_table(ctx->Save);
+ _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt );
+ /* Neutral tnl module stuff */
+ _mesa_init_exec_vtxfmt( ctx );
+ ctx->TnlModule.Current = NULL;
+ ctx->TnlModule.SwapCount = 0;
+#endif
+
+ ctx->_MaintainTexEnvProgram = (_mesa_getenv("MESA_TEX_PROG") != NULL);
+ ctx->_MaintainTnlProgram = (_mesa_getenv("MESA_TNL_PROG") != NULL);
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Allocate and initialize a GLcontext structure.
+ * Note that the driver needs to pass in its dd_function_table here since
+ * we need to at least call driverFunctions->NewTextureObject to initialize
+ * the rendering context.
+ *
+ * \param visual a GLvisual pointer (we copy the struct contents)
+ * \param share_list another context to share display lists with or NULL
+ * \param driverFunctions points to the dd_function_table into which the
+ * driver has plugged in all its special functions.
+ * \param driverCtx points to the device driver's private context state
+ *
+ * \return pointer to a new __GLcontextRec or NULL if error.
+ */
+GLcontext *
+_mesa_create_context( const GLvisual *visual,
+ GLcontext *share_list,
+ const struct dd_function_table *driverFunctions,
+ void *driverContext )
+
+{
+ GLcontext *ctx;
+
+ ASSERT(visual);
+ ASSERT(driverContext);
+
+ ctx = (GLcontext *) _mesa_calloc(sizeof(GLcontext));
+ if (!ctx)
+ return NULL;
+
+ if (_mesa_initialize_context(ctx, visual, share_list,
+ driverFunctions, driverContext)) {
+ return ctx;
+ }
+ else {
+ _mesa_free(ctx);
+ return NULL;
+ }
+}
+
+
+/**
+ * Free the data associated with the given context.
+ *
+ * But doesn't free the GLcontext struct itself.
+ *
+ * \sa _mesa_initialize_context() and init_attrib_groups().
+ */
+void
+_mesa_free_context_data( GLcontext *ctx )
+{
+ /* if we're destroying the current context, unbind it first */
+ if (ctx == _mesa_get_current_context()) {
+ _mesa_make_current(NULL, NULL, NULL);
+ }
+
+ _mesa_free_lighting_data( ctx );
+ _mesa_free_eval_data( ctx );
+ _mesa_free_texture_data( ctx );
+ _mesa_free_matrix_data( ctx );
+ _mesa_free_viewport_data( ctx );
+ _mesa_free_colortables_data( ctx );
+ _mesa_free_program_data(ctx);
+ _mesa_free_occlude_data(ctx);
+
+#if FEATURE_ARB_vertex_buffer_object
+ _mesa_delete_buffer_object(ctx, ctx->Array.NullBufferObj);
+#endif
+
+ /* free dispatch tables */
+ _mesa_free(ctx->Exec);
+ _mesa_free(ctx->Save);
+
+ /* Shared context state (display lists, textures, etc) */
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+ ctx->Shared->RefCount--;
+ assert(ctx->Shared->RefCount >= 0);
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+ if (ctx->Shared->RefCount == 0) {
+ /* free shared state */
+ free_shared_state( ctx, ctx->Shared );
+ }
+
+ if (ctx->Extensions.String)
+ FREE((void *) ctx->Extensions.String);
+}
+
+
+/**
+ * Destroy a GLcontext structure.
+ *
+ * \param ctx GL context.
+ *
+ * Calls _mesa_free_context_data() and frees the GLcontext structure itself.
+ */
+void
+_mesa_destroy_context( GLcontext *ctx )
+{
+ if (ctx) {
+ _mesa_free_context_data(ctx);
+ FREE( (void *) ctx );
+ }
+}
+
+
+#if _HAVE_FULL_GL
+/**
+ * Copy attribute groups from one context to another.
+ *
+ * \param src source context
+ * \param dst destination context
+ * \param mask bitwise OR of GL_*_BIT flags
+ *
+ * According to the bits specified in \p mask, copies the corresponding
+ * attributes from \p src into \p dst. For many of the attributes a simple \c
+ * memcpy is not enough due to the existence of internal pointers in their data
+ * structures.
+ */
+void
+_mesa_copy_context( const GLcontext *src, GLcontext *dst, GLuint mask )
+{
+ if (mask & GL_ACCUM_BUFFER_BIT) {
+ /* OK to memcpy */
+ dst->Accum = src->Accum;
+ }
+ if (mask & GL_COLOR_BUFFER_BIT) {
+ /* OK to memcpy */
+ dst->Color = src->Color;
+ }
+ if (mask & GL_CURRENT_BIT) {
+ /* OK to memcpy */
+ dst->Current = src->Current;
+ }
+ if (mask & GL_DEPTH_BUFFER_BIT) {
+ /* OK to memcpy */
+ dst->Depth = src->Depth;
+ }
+ if (mask & GL_ENABLE_BIT) {
+ /* no op */
+ }
+ if (mask & GL_EVAL_BIT) {
+ /* OK to memcpy */
+ dst->Eval = src->Eval;
+ }
+ if (mask & GL_FOG_BIT) {
+ /* OK to memcpy */
+ dst->Fog = src->Fog;
+ }
+ if (mask & GL_HINT_BIT) {
+ /* OK to memcpy */
+ dst->Hint = src->Hint;
+ }
+ if (mask & GL_LIGHTING_BIT) {
+ GLuint i;
+ /* begin with memcpy */
+ MEMCPY( &dst->Light, &src->Light, sizeof(struct gl_light) );
+ /* fixup linked lists to prevent pointer insanity */
+ make_empty_list( &(dst->Light.EnabledList) );
+ for (i = 0; i < MAX_LIGHTS; i++) {
+ if (dst->Light.Light[i].Enabled) {
+ insert_at_tail(&(dst->Light.EnabledList), &(dst->Light.Light[i]));
+ }
+ }
+ }
+ if (mask & GL_LINE_BIT) {
+ /* OK to memcpy */
+ dst->Line = src->Line;
+ }
+ if (mask & GL_LIST_BIT) {
+ /* OK to memcpy */
+ dst->List = src->List;
+ }
+ if (mask & GL_PIXEL_MODE_BIT) {
+ /* OK to memcpy */
+ dst->Pixel = src->Pixel;
+ }
+ if (mask & GL_POINT_BIT) {
+ /* OK to memcpy */
+ dst->Point = src->Point;
+ }
+ if (mask & GL_POLYGON_BIT) {
+ /* OK to memcpy */
+ dst->Polygon = src->Polygon;
+ }
+ if (mask & GL_POLYGON_STIPPLE_BIT) {
+ /* Use loop instead of MEMCPY due to problem with Portland Group's
+ * C compiler. Reported by John Stone.
+ */
+ GLuint i;
+ for (i = 0; i < 32; i++) {
+ dst->PolygonStipple[i] = src->PolygonStipple[i];
+ }
+ }
+ if (mask & GL_SCISSOR_BIT) {
+ /* OK to memcpy */
+ dst->Scissor = src->Scissor;
+ }
+ if (mask & GL_STENCIL_BUFFER_BIT) {
+ /* OK to memcpy */
+ dst->Stencil = src->Stencil;
+ }
+ if (mask & GL_TEXTURE_BIT) {
+ /* Cannot memcpy because of pointers */
+ _mesa_copy_texture_state(src, dst);
+ }
+ if (mask & GL_TRANSFORM_BIT) {
+ /* OK to memcpy */
+ dst->Transform = src->Transform;
+ }
+ if (mask & GL_VIEWPORT_BIT) {
+ /* Cannot use memcpy, because of pointers in GLmatrix _WindowMap */
+ dst->Viewport.X = src->Viewport.X;
+ dst->Viewport.Y = src->Viewport.Y;
+ dst->Viewport.Width = src->Viewport.Width;
+ dst->Viewport.Height = src->Viewport.Height;
+ dst->Viewport.Near = src->Viewport.Near;
+ dst->Viewport.Far = src->Viewport.Far;
+ _math_matrix_copy(&dst->Viewport._WindowMap, &src->Viewport._WindowMap);
+ }
+
+ /* XXX FIXME: Call callbacks?
+ */
+ dst->NewState = _NEW_ALL;
+}
+#endif
+
+
+/**
+ * Check if the given context can render into the given framebuffer
+ * by checking visual attributes.
+ * \return GL_TRUE if compatible, GL_FALSE otherwise.
+ */
+static GLboolean
+check_compatible(const GLcontext *ctx, const GLframebuffer *buffer)
+{
+ const GLvisual *ctxvis = &ctx->Visual;
+ const GLvisual *bufvis = &buffer->Visual;
+
+ if (ctxvis == bufvis)
+ return GL_TRUE;
+
+ if (ctxvis->rgbMode != bufvis->rgbMode)
+ return GL_FALSE;
+ if (ctxvis->doubleBufferMode && !bufvis->doubleBufferMode)
+ return GL_FALSE;
+ if (ctxvis->stereoMode && !bufvis->stereoMode)
+ return GL_FALSE;
+ if (ctxvis->haveAccumBuffer && !bufvis->haveAccumBuffer)
+ return GL_FALSE;
+ if (ctxvis->haveDepthBuffer && !bufvis->haveDepthBuffer)
+ return GL_FALSE;
+ if (ctxvis->haveStencilBuffer && !bufvis->haveStencilBuffer)
+ return GL_FALSE;
+ if (ctxvis->redMask && ctxvis->redMask != bufvis->redMask)
+ return GL_FALSE;
+ if (ctxvis->greenMask && ctxvis->greenMask != bufvis->greenMask)
+ return GL_FALSE;
+ if (ctxvis->blueMask && ctxvis->blueMask != bufvis->blueMask)
+ return GL_FALSE;
+ if (ctxvis->depthBits && ctxvis->depthBits != bufvis->depthBits)
+ return GL_FALSE;
+ if (ctxvis->stencilBits && ctxvis->stencilBits != bufvis->stencilBits)
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Bind the given context to the given draw-buffer and read-buffer and
+ * make it the current context for this thread.
+ *
+ * \param newCtx new GL context. If NULL then there will be no current GL
+ * context.
+ * \param drawBuffer draw framebuffer.
+ * \param readBuffer read framebuffer.
+ *
+ * Check that the context's and framebuffer's visuals are compatible, returning
+ * immediately otherwise. Sets the glapi current context via
+ * _glapi_set_context(). If \p newCtx is not NULL, associates \p drawBuffer and
+ * \p readBuffer with it and calls dd_function_table::ResizeBuffers if the buffers size has changed.
+ * Calls dd_function_table::MakeCurrent callback if defined.
+ *
+ * When a context is bound by the first time and the \c MESA_INFO environment
+ * variable is set it calls print_info() as an aid for remote user
+ * troubleshooting.
+ */
+void
+_mesa_make_current( GLcontext *newCtx, GLframebuffer *drawBuffer,
+ GLframebuffer *readBuffer )
+{
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(newCtx, "_mesa_make_current()\n");
+
+ /* Check that the context's and framebuffer's visuals are compatible.
+ */
+ if (newCtx && drawBuffer && newCtx->DrawBuffer != drawBuffer) {
+ if (!check_compatible(newCtx, drawBuffer))
+ return;
+ }
+ if (newCtx && readBuffer && newCtx->ReadBuffer != readBuffer) {
+ if (!check_compatible(newCtx, readBuffer))
+ return;
+ }
+
+#if !defined(IN_DRI_DRIVER)
+ /* We call this function periodically (just here for now) in
+ * order to detect when multithreading has begun. In a DRI driver, this
+ * step is done by the driver loader (e.g., libGL).
+ */
+ _glapi_check_multithread();
+#endif /* !defined(IN_DRI_DRIVER) */
+
+ _glapi_set_context((void *) newCtx);
+ ASSERT(_mesa_get_current_context() == newCtx);
+
+ if (!newCtx) {
+ _glapi_set_dispatch(NULL); /* none current */
+ }
+ else {
+ _glapi_set_dispatch(newCtx->CurrentDispatch);
+
+ if (drawBuffer && readBuffer) {
+ /* TODO: check if newCtx and buffer's visual match??? */
+
+ ASSERT(drawBuffer->Name == 0);
+ ASSERT(readBuffer->Name == 0);
+ newCtx->WinSysDrawBuffer = drawBuffer;
+ newCtx->WinSysReadBuffer = readBuffer;
+ /* don't replace user-buffer bindings with window system buffer */
+ if (!newCtx->DrawBuffer || newCtx->DrawBuffer->Name == 0) {
+ newCtx->DrawBuffer = drawBuffer;
+ newCtx->ReadBuffer = readBuffer;
+ }
+
+ newCtx->NewState |= _NEW_BUFFERS;
+
+#if _HAVE_FULL_GL
+ if (!drawBuffer->Initialized) {
+ /* get initial window size */
+ GLuint bufWidth, bufHeight;
+ /* ask device driver for size of the buffer */
+ (*newCtx->Driver.GetBufferSize)(drawBuffer, &bufWidth, &bufHeight);
+ /* set initial buffer size */
+ if (newCtx->Driver.ResizeBuffers)
+ newCtx->Driver.ResizeBuffers(newCtx, drawBuffer,
+ bufWidth, bufHeight);
+ drawBuffer->Initialized = GL_TRUE;
+ }
+
+ if (readBuffer != drawBuffer && !readBuffer->Initialized) {
+ /* get initial window size */
+ GLuint bufWidth, bufHeight;
+ /* ask device driver for size of the buffer */
+ (*newCtx->Driver.GetBufferSize)(readBuffer, &bufWidth, &bufHeight);
+ /* set initial buffer size */
+ if (newCtx->Driver.ResizeBuffers)
+ newCtx->Driver.ResizeBuffers(newCtx, readBuffer,
+ bufWidth, bufHeight);
+ readBuffer->Initialized = GL_TRUE;
+ }
+#endif
+ if (newCtx->FirstTimeCurrent) {
+ /* set initial viewport and scissor size now */
+ _mesa_set_viewport(newCtx, 0, 0, drawBuffer->Width, drawBuffer->Height);
+ newCtx->Scissor.Width = drawBuffer->Width;
+ newCtx->Scissor.Height = drawBuffer->Height;
+ }
+ }
+
+ /* Alert the driver - usually passed on to the sw t&l module,
+ * but also used to detect threaded cases in the radeon codegen
+ * hw t&l module.
+ */
+ if (newCtx->Driver.MakeCurrent)
+ newCtx->Driver.MakeCurrent( newCtx, drawBuffer, readBuffer );
+
+ /* We can use this to help debug user's problems. Tell them to set
+ * the MESA_INFO env variable before running their app. Then the
+ * first time each context is made current we'll print some useful
+ * information.
+ */
+ if (newCtx->FirstTimeCurrent) {
+ if (_mesa_getenv("MESA_INFO")) {
+ _mesa_print_info();
+ }
+ newCtx->FirstTimeCurrent = GL_FALSE;
+ }
+ }
+}
+
+
+/**
+ * Make context 'ctx' share the display lists, textures and programs
+ * that are associated with 'ctxToShare'.
+ * Any display lists, textures or programs associated with 'ctx' will
+ * be deleted if nobody else is sharing them.
+ */
+GLboolean
+_mesa_share_state(GLcontext *ctx, GLcontext *ctxToShare)
+{
+ if (ctx && ctxToShare && ctx->Shared && ctxToShare->Shared) {
+ ctx->Shared->RefCount--;
+ if (ctx->Shared->RefCount == 0) {
+ free_shared_state(ctx, ctx->Shared);
+ }
+ ctx->Shared = ctxToShare->Shared;
+ ctx->Shared->RefCount++;
+ return GL_TRUE;
+ }
+ else {
+ return GL_FALSE;
+ }
+}
+
+
+
+/**
+ * Get current context for the calling thread.
+ *
+ * \return pointer to the current GL context.
+ *
+ * Calls _glapi_get_context(). This isn't the fastest way to get the current
+ * context. If you need speed, see the #GET_CURRENT_CONTEXT macro in context.h.
+ */
+GLcontext *
+_mesa_get_current_context( void )
+{
+ return (GLcontext *) _glapi_get_context();
+}
+
+/**
+ * Get context's current API dispatch table.
+ *
+ * It'll either be the immediate-mode execute dispatcher or the display list
+ * compile dispatcher.
+ *
+ * \param ctx GL context.
+ *
+ * \return pointer to dispatch_table.
+ *
+ * Simply returns __GLcontextRec::CurrentDispatch.
+ */
+struct _glapi_table *
+_mesa_get_dispatch(GLcontext *ctx)
+{
+ return ctx->CurrentDispatch;
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Miscellaneous functions */
+/**********************************************************************/
+/*@{*/
+
+/**
+ * Record an error.
+ *
+ * \param ctx GL context.
+ * \param error error code.
+ *
+ * Records the given error code and call the driver's dd_function_table::Error
+ * function if defined.
+ *
+ * \sa
+ * This is called via _mesa_error().
+ */
+void
+_mesa_record_error( GLcontext *ctx, GLenum error )
+{
+ if (!ctx)
+ return;
+
+ if (ctx->ErrorValue == GL_NO_ERROR) {
+ ctx->ErrorValue = error;
+ }
+
+ /* Call device driver's error handler, if any. This is used on the Mac. */
+ if (ctx->Driver.Error) {
+ (*ctx->Driver.Error)( ctx );
+ }
+}
+
+/**
+ * Execute glFinish().
+ *
+ * Calls the #ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH macro and the
+ * dd_function_table::Finish driver callback, if not NULL.
+ */
+void GLAPIENTRY
+_mesa_Finish( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ if (ctx->Driver.Finish) {
+ (*ctx->Driver.Finish)( ctx );
+ }
+}
+
+/**
+ * Execute glFlush().
+ *
+ * Calls the #ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH macro and the
+ * dd_function_table::Flush driver callback, if not NULL.
+ */
+void GLAPIENTRY
+_mesa_Flush( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ if (ctx->Driver.Flush) {
+ (*ctx->Driver.Flush)( ctx );
+ }
+}
+
+
+/*@}*/
diff --git a/nx-X11/extras/Mesa/src/mesa/main/context.h b/nx-X11/extras/Mesa/src/mesa/main/context.h
new file mode 100644
index 000000000..8b7e7c995
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/context.h
@@ -0,0 +1,340 @@
+/**
+ * \file context.h
+ * Mesa context/visual/framebuffer management functions.
+ *
+ * There are three Mesa data types which are meant to be used by device
+ * drivers:
+ * - GLcontext: this contains the Mesa rendering state
+ * - GLvisual: this describes the color buffer (RGB vs. ci), whether or not
+ * there's a depth buffer, stencil buffer, etc.
+ * - GLframebuffer: contains pointers to the depth buffer, stencil buffer,
+ * accum buffer and alpha buffers.
+ *
+ * These types should be encapsulated by corresponding device driver
+ * data types. See xmesa.h and xmesaP.h for an example.
+ *
+ * In OOP terms, GLcontext, GLvisual, and GLframebuffer are base classes
+ * which the device driver must derive from.
+ *
+ * The following functions create and destroy these data types.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef CONTEXT_H
+#define CONTEXT_H
+
+
+#include "glapi.h"
+#include "imports.h"
+#include "mtypes.h"
+
+
+/**********************************************************************/
+/** \name Create/destroy a GLvisual. */
+/*@{*/
+
+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 );
+
+extern void
+_mesa_destroy_visual( GLvisual *vis );
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Create/destroy a GLcontext. */
+/*@{*/
+
+extern GLcontext *
+_mesa_create_context( const GLvisual *visual,
+ GLcontext *share_list,
+ const struct dd_function_table *driverFunctions,
+ void *driverContext );
+
+extern GLboolean
+_mesa_initialize_context( GLcontext *ctx,
+ const GLvisual *visual,
+ GLcontext *share_list,
+ const struct dd_function_table *driverFunctions,
+ void *driverContext );
+
+extern void
+_mesa_free_context_data( GLcontext *ctx );
+
+extern void
+_mesa_destroy_context( GLcontext *ctx );
+
+
+extern void
+_mesa_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask);
+
+
+extern void
+_mesa_make_current( GLcontext *ctx, GLframebuffer *drawBuffer,
+ GLframebuffer *readBuffer );
+
+extern GLboolean
+_mesa_share_state(GLcontext *ctx, GLcontext *ctxToShare);
+
+extern GLcontext *
+_mesa_get_current_context(void);
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name OpenGL SI-style export functions. */
+/*@{*/
+
+extern GLboolean
+_mesa_destroyContext(__GLcontext *gc);
+
+extern GLboolean
+_mesa_loseCurrent(__GLcontext *gc);
+
+extern GLboolean
+_mesa_makeCurrent(__GLcontext *gc);
+
+extern GLboolean
+_mesa_shareContext(__GLcontext *gc, __GLcontext *gcShare);
+
+extern GLboolean
+_mesa_copyContext(__GLcontext *dst, const __GLcontext *src, GLuint mask);
+
+extern GLboolean
+_mesa_forceCurrent(__GLcontext *gc);
+
+extern GLboolean
+_mesa_notifyResize(__GLcontext *gc);
+
+extern void
+_mesa_notifyDestroy(__GLcontext *gc);
+
+extern void
+_mesa_notifySwapBuffers(__GLcontext *gc);
+
+extern struct __GLdispatchStateRec *
+_mesa_dispatchExec(__GLcontext *gc);
+
+extern void
+_mesa_beginDispatchOverride(__GLcontext *gc);
+
+extern void
+_mesa_endDispatchOverride(__GLcontext *gc);
+
+/*@}*/
+
+
+extern struct _glapi_table *
+_mesa_get_dispatch(GLcontext *ctx);
+
+
+
+/**********************************************************************/
+/** \name Miscellaneous */
+/*@{*/
+
+extern void
+_mesa_record_error( GLcontext *ctx, GLenum error );
+
+
+extern void GLAPIENTRY
+_mesa_Finish( void );
+
+extern void GLAPIENTRY
+_mesa_Flush( void );
+
+/*@}*/
+
+
+
+/**********************************************************************/
+/** \name Macros for contexts/flushing. */
+/*@{*/
+
+
+/**
+ * Flush vertices.
+ *
+ * \param ctx GL context.
+ * \param newstate new state.
+ *
+ * Checks if dd_function_table::NeedFlush is marked to flush stored vertices,
+ * and calls dd_function_table::FlushVertices if so. Marks
+ * __GLcontextRec::NewState with \p newstate.
+ */
+#define FLUSH_VERTICES(ctx, newstate) \
+do { \
+ if (MESA_VERBOSE & VERBOSE_STATE) \
+ _mesa_debug(ctx, "FLUSH_VERTICES in %s\n", MESA_FUNCTION);\
+ if (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) \
+ ctx->Driver.FlushVertices(ctx, FLUSH_STORED_VERTICES); \
+ ctx->NewState |= newstate; \
+} while (0)
+
+/**
+ * Flush current state.
+ *
+ * \param ctx GL context.
+ * \param newstate new state.
+ *
+ * Checks if dd_function_table::NeedFlush is marked to flush current state,
+ * and calls dd_function_table::FlushVertices if so. Marks
+ * __GLcontextRec::NewState with \p newstate.
+ */
+#define FLUSH_CURRENT(ctx, newstate) \
+do { \
+ if (MESA_VERBOSE & VERBOSE_STATE) \
+ _mesa_debug(ctx, "FLUSH_CURRENT in %s\n", MESA_FUNCTION); \
+ if (ctx->Driver.NeedFlush & FLUSH_UPDATE_CURRENT) \
+ ctx->Driver.FlushVertices(ctx, FLUSH_UPDATE_CURRENT); \
+ ctx->NewState |= newstate; \
+} while (0)
+
+/**
+ * Macro to assert that the API call was made outside the
+ * glBegin()/glEnd() pair, with return value.
+ *
+ * \param ctx GL context.
+ * \param retval value to return value in case the assertion fails.
+ */
+#define ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval) \
+do { \
+ if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
+ _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
+ return retval; \
+ } \
+} while (0)
+
+/**
+ * Macro to assert that the API call was made outside the
+ * glBegin()/glEnd() pair.
+ *
+ * \param ctx GL context.
+ */
+#define ASSERT_OUTSIDE_BEGIN_END(ctx) \
+do { \
+ if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) { \
+ _mesa_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
+ return; \
+ } \
+} while (0)
+
+/**
+ * Macro to assert that the API call was made outside the
+ * glBegin()/glEnd() pair and flush the vertices.
+ *
+ * \param ctx GL context.
+ */
+#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx) \
+do { \
+ ASSERT_OUTSIDE_BEGIN_END(ctx); \
+ FLUSH_VERTICES(ctx, 0); \
+} while (0)
+
+/**
+ * Macro to assert that the API call was made outside the
+ * glBegin()/glEnd() pair and flush the vertices, with return value.
+ *
+ * \param ctx GL context.
+ * \param retval value to return value in case the assertion fails.
+ */
+#define ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval) \
+do { \
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, retval); \
+ FLUSH_VERTICES(ctx, 0); \
+} while (0)
+
+
+/*@}*/
+
+
+
+/**
+ * Macros to help evaluate current state conditions
+ */
+
+/*@{*/
+
+/**
+ * Is the secondary color needed?
+ */
+#define NEED_SECONDARY_COLOR(CTX) \
+ (((CTX)->Light.Enabled && \
+ (CTX)->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) \
+ || (CTX)->Fog.ColorSumEnabled \
+ || ((CTX)->VertexProgram._Enabled && \
+ ((CTX)->VertexProgram.Current->InputsRead & VERT_BIT_COLOR1)) \
+ || ((CTX)->FragmentProgram._Enabled && \
+ ((CTX)->FragmentProgram.Current->InputsRead & FRAG_BIT_COL1)) \
+ )
+
+
+/**
+ * Is two-sided lighting in effect?
+ */
+#define NEED_TWO_SIDED_LIGHTING(CTX) \
+ (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
+
+
+/*@}*/
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/convolve.c b/nx-X11/extras/Mesa/src/mesa/main/convolve.c
new file mode 100644
index 000000000..6b97c7f56
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/convolve.c
@@ -0,0 +1,1527 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+/*
+ * Image convolution functions.
+ *
+ * Notes: filter kernel elements are indexed by <n> and <m> as in
+ * the GL spec.
+ */
+
+
+#include "glheader.h"
+#include "bufferobj.h"
+#include "colormac.h"
+#include "convolve.h"
+#include "context.h"
+#include "image.h"
+#include "mtypes.h"
+#include "pixel.h"
+#include "state.h"
+
+
+/*
+ * 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 )
+{
+ 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 GLAPIENTRY
+_mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *image)
+{
+ GLint baseFormat;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (target != GL_CONVOLUTION_1D) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter1D(target)");
+ return;
+ }
+
+ baseFormat = base_filter_format(internalFormat);
+ if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter1D(internalFormat)");
+ return;
+ }
+
+ if (width < 0 || width > MAX_CONVOLUTION_WIDTH) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glConvolutionFilter1D(width)");
+ return;
+ }
+
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glConvolutionFilter1D(format or type)");
+ return;
+ }
+
+ if (format == GL_COLOR_INDEX ||
+ format == GL_STENCIL_INDEX ||
+ format == GL_DEPTH_COMPONENT ||
+ format == GL_INTENSITY ||
+ type == GL_BITMAP) {
+ _mesa_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;
+
+ if (ctx->Unpack.BufferObj->Name) {
+ /* unpack filter from PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(1, &ctx->Unpack, width, 1, 1,
+ format, type, image)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glConvolutionFilter1D(invalid PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ GL_READ_ONLY_ARB,
+ ctx->Unpack.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glConvolutionFilter1D(PBO is mapped)");
+ return;
+ }
+ image = ADD_POINTERS(buf, image);
+ }
+ else if (!image) {
+ return;
+ }
+
+ _mesa_unpack_color_span_float(ctx, width, GL_RGBA,
+ ctx->Convolution1D.Filter,
+ format, type, image, &ctx->Unpack,
+ 0); /* transferOps */
+
+ if (ctx->Unpack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ ctx->Unpack.BufferObj);
+ }
+
+ _mesa_scale_and_bias_rgba(width,
+ (GLfloat (*)[4]) ctx->Convolution1D.Filter,
+ ctx->Pixel.ConvolutionFilterScale[0][0],
+ ctx->Pixel.ConvolutionFilterScale[0][1],
+ ctx->Pixel.ConvolutionFilterScale[0][2],
+ ctx->Pixel.ConvolutionFilterScale[0][3],
+ ctx->Pixel.ConvolutionFilterBias[0][0],
+ ctx->Pixel.ConvolutionFilterBias[0][1],
+ ctx->Pixel.ConvolutionFilterBias[0][2],
+ ctx->Pixel.ConvolutionFilterBias[0][3]);
+
+ ctx->NewState |= _NEW_PIXEL;
+}
+
+
+void GLAPIENTRY
+_mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image)
+{
+ GLint baseFormat;
+ GLint i;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (target != GL_CONVOLUTION_2D) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter2D(target)");
+ return;
+ }
+
+ baseFormat = base_filter_format(internalFormat);
+ if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter2D(internalFormat)");
+ return;
+ }
+
+ if (width < 0 || width > MAX_CONVOLUTION_WIDTH) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glConvolutionFilter2D(width)");
+ return;
+ }
+ if (height < 0 || height > MAX_CONVOLUTION_HEIGHT) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glConvolutionFilter2D(height)");
+ return;
+ }
+
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glConvolutionFilter2D(format or type)");
+ return;
+ }
+ if (format == GL_COLOR_INDEX ||
+ format == GL_STENCIL_INDEX ||
+ format == GL_DEPTH_COMPONENT ||
+ format == GL_INTENSITY ||
+ type == GL_BITMAP) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter2D(format or type)");
+ return;
+ }
+
+ /* this should have been caught earlier */
+ assert(_mesa_components_in_format(format));
+
+ ctx->Convolution2D.Format = format;
+ ctx->Convolution2D.InternalFormat = internalFormat;
+ ctx->Convolution2D.Width = width;
+ ctx->Convolution2D.Height = height;
+
+ if (ctx->Unpack.BufferObj->Name) {
+ /* unpack filter from PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(2, &ctx->Unpack, width, height, 1,
+ format, type, image)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glConvolutionFilter2D(invalid PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ GL_READ_ONLY_ARB,
+ ctx->Unpack.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glConvolutionFilter2D(PBO is mapped)");
+ return;
+ }
+ image = ADD_POINTERS(buf, image);
+ }
+ else if (!image) {
+ return;
+ }
+
+ /* Unpack filter image. We always store filters in RGBA format. */
+ for (i = 0; i < height; i++) {
+ const GLvoid *src = _mesa_image_address2d(&ctx->Unpack, image, width,
+ height, format, type, i, 0);
+ GLfloat *dst = ctx->Convolution2D.Filter + i * width * 4;
+ _mesa_unpack_color_span_float(ctx, width, GL_RGBA, dst,
+ format, type, src, &ctx->Unpack,
+ 0); /* transferOps */
+ }
+
+ if (ctx->Unpack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ ctx->Unpack.BufferObj);
+ }
+
+ _mesa_scale_and_bias_rgba(width * height,
+ (GLfloat (*)[4]) ctx->Convolution2D.Filter,
+ ctx->Pixel.ConvolutionFilterScale[1][0],
+ ctx->Pixel.ConvolutionFilterScale[1][1],
+ ctx->Pixel.ConvolutionFilterScale[1][2],
+ ctx->Pixel.ConvolutionFilterScale[1][3],
+ ctx->Pixel.ConvolutionFilterBias[1][0],
+ ctx->Pixel.ConvolutionFilterBias[1][1],
+ ctx->Pixel.ConvolutionFilterBias[1][2],
+ ctx->Pixel.ConvolutionFilterBias[1][3]);
+
+ ctx->NewState |= _NEW_PIXEL;
+}
+
+
+void GLAPIENTRY
+_mesa_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint c;
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ switch (target) {
+ case GL_CONVOLUTION_1D:
+ c = 0;
+ break;
+ case GL_CONVOLUTION_2D:
+ c = 1;
+ break;
+ case GL_SEPARABLE_2D:
+ c = 2;
+ break;
+ default:
+ _mesa_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 {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterf(params)");
+ return;
+ }
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterf(pname)");
+ return;
+ }
+
+ ctx->NewState |= _NEW_PIXEL;
+}
+
+
+void GLAPIENTRY
+_mesa_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint c;
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ switch (target) {
+ case GL_CONVOLUTION_1D:
+ c = 0;
+ break;
+ case GL_CONVOLUTION_2D:
+ c = 1;
+ break;
+ case GL_SEPARABLE_2D:
+ c = 2;
+ break;
+ default:
+ _mesa_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 {
+ _mesa_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:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv(pname)");
+ return;
+ }
+
+ ctx->NewState |= _NEW_PIXEL;
+}
+
+
+void GLAPIENTRY
+_mesa_ConvolutionParameteri(GLenum target, GLenum pname, GLint param)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint c;
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ switch (target) {
+ case GL_CONVOLUTION_1D:
+ c = 0;
+ break;
+ case GL_CONVOLUTION_2D:
+ c = 1;
+ break;
+ case GL_SEPARABLE_2D:
+ c = 2;
+ break;
+ default:
+ _mesa_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 {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteri(params)");
+ return;
+ }
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteri(pname)");
+ return;
+ }
+
+ ctx->NewState |= _NEW_PIXEL;
+}
+
+
+void GLAPIENTRY
+_mesa_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint c;
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ switch (target) {
+ case GL_CONVOLUTION_1D:
+ c = 0;
+ break;
+ case GL_CONVOLUTION_2D:
+ c = 1;
+ break;
+ case GL_SEPARABLE_2D:
+ c = 2;
+ break;
+ default:
+ _mesa_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 {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv(params)");
+ return;
+ }
+ break;
+ case GL_CONVOLUTION_FILTER_SCALE:
+ /* COPY_4V(ctx->Pixel.ConvolutionFilterScale[c], params); */
+ /* need cast to prevent compiler warnings */
+ ctx->Pixel.ConvolutionFilterScale[c][0] = (GLfloat) params[0];
+ ctx->Pixel.ConvolutionFilterScale[c][1] = (GLfloat) params[1];
+ ctx->Pixel.ConvolutionFilterScale[c][2] = (GLfloat) params[2];
+ ctx->Pixel.ConvolutionFilterScale[c][3] = (GLfloat) params[3];
+ break;
+ case GL_CONVOLUTION_FILTER_BIAS:
+ /* COPY_4V(ctx->Pixel.ConvolutionFilterBias[c], params); */
+ /* need cast to prevent compiler warnings */
+ ctx->Pixel.ConvolutionFilterBias[c][0] = (GLfloat) params[0];
+ ctx->Pixel.ConvolutionFilterBias[c][1] = (GLfloat) params[1];
+ ctx->Pixel.ConvolutionFilterBias[c][2] = (GLfloat) params[2];
+ ctx->Pixel.ConvolutionFilterBias[c][3] = (GLfloat) params[3];
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv(pname)");
+ return;
+ }
+
+ ctx->NewState |= _NEW_PIXEL;
+}
+
+
+void GLAPIENTRY
+_mesa_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width)
+{
+ GLint baseFormat;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (target != GL_CONVOLUTION_1D) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter1D(target)");
+ return;
+ }
+
+ baseFormat = base_filter_format(internalFormat);
+ if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter1D(internalFormat)");
+ return;
+ }
+
+ if (width < 0 || width > MAX_CONVOLUTION_WIDTH) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glCopyConvolutionFilter1D(width)");
+ return;
+ }
+
+ ctx->Driver.CopyConvolutionFilter1D( ctx, target,
+ internalFormat, x, y, width);
+}
+
+
+void GLAPIENTRY
+_mesa_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ GLint baseFormat;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (target != GL_CONVOLUTION_2D) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter2D(target)");
+ return;
+ }
+
+ baseFormat = base_filter_format(internalFormat);
+ if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter2D(internalFormat)");
+ return;
+ }
+
+ if (width < 0 || width > MAX_CONVOLUTION_WIDTH) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glCopyConvolutionFilter2D(width)");
+ return;
+ }
+ if (height < 0 || height > MAX_CONVOLUTION_HEIGHT) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glCopyConvolutionFilter2D(height)");
+ return;
+ }
+
+ ctx->Driver.CopyConvolutionFilter2D( ctx, target, internalFormat, x, y,
+ width, height );
+}
+
+
+void GLAPIENTRY
+_mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *image)
+{
+ const struct gl_convolution_attrib *filter;
+ GLuint row;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (ctx->NewState) {
+ _mesa_update_state(ctx);
+ }
+
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetConvolutionFilter(format or type)");
+ return;
+ }
+
+ if (format == GL_COLOR_INDEX ||
+ format == GL_STENCIL_INDEX ||
+ format == GL_DEPTH_COMPONENT ||
+ format == GL_INTENSITY ||
+ type == GL_BITMAP) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionFilter(format or type)");
+ return;
+ }
+
+ switch (target) {
+ case GL_CONVOLUTION_1D:
+ filter = &(ctx->Convolution1D);
+ break;
+ case GL_CONVOLUTION_2D:
+ filter = &(ctx->Convolution2D);
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionFilter(target)");
+ return;
+ }
+
+ if (ctx->Pack.BufferObj->Name) {
+ /* Pack the filter into a PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(2, &ctx->Pack,
+ filter->Width, filter->Height,
+ 1, format, type, image)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetConvolutionFilter(invalid PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ GL_WRITE_ONLY_ARB,
+ ctx->Pack.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetConvolutionFilter(PBO is mapped)");
+ return;
+ }
+ image = ADD_POINTERS(image, buf);
+ }
+
+ for (row = 0; row < filter->Height; row++) {
+ GLvoid *dst = _mesa_image_address2d(&ctx->Pack, image, filter->Width,
+ filter->Height, format, type,
+ row, 0);
+ const GLfloat *src = filter->Filter + row * filter->Width * 4;
+ _mesa_pack_rgba_span_float(ctx, filter->Width,
+ (const GLfloat (*)[4]) src,
+ format, type, dst, &ctx->Pack, 0);
+ }
+
+ if (ctx->Pack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ ctx->Pack.BufferObj);
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ const struct gl_convolution_attrib *conv;
+ GLuint c;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ 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:
+ _mesa_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:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameterfv(pname)");
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ const struct gl_convolution_attrib *conv;
+ GLuint c;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ 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:
+ _mesa_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[c];
+ 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:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameteriv(pname)");
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span)
+{
+ const GLint colStart = MAX_CONVOLUTION_WIDTH * 4;
+ const struct gl_convolution_attrib *filter;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (ctx->NewState) {
+ _mesa_update_state(ctx);
+ }
+
+ if (target != GL_SEPARABLE_2D) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetSeparableFilter(target)");
+ return;
+ }
+
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetConvolutionFilter(format or type)");
+ return;
+ }
+
+ if (format == GL_COLOR_INDEX ||
+ format == GL_STENCIL_INDEX ||
+ format == GL_DEPTH_COMPONENT ||
+ format == GL_INTENSITY ||
+ type == GL_BITMAP) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetConvolutionFilter(format or type)");
+ return;
+ }
+
+ filter = &ctx->Separable2D;
+
+ if (ctx->Pack.BufferObj->Name) {
+ /* Pack filter into PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(1, &ctx->Pack, filter->Width, 1, 1,
+ format, type, row)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetSeparableFilter(invalid PBO access, width)");
+ return;
+ }
+ if (!_mesa_validate_pbo_access(1, &ctx->Pack, filter->Height, 1, 1,
+ format, type, column)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetSeparableFilter(invalid PBO access, height)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ GL_WRITE_ONLY_ARB,
+ ctx->Pack.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetSeparableFilter(PBO is mapped)");
+ return;
+ }
+ row = ADD_POINTERS(buf, row);
+ column = ADD_POINTERS(buf, column);
+ }
+
+ /* Row filter */
+ if (row) {
+ GLvoid *dst = _mesa_image_address1d(&ctx->Pack, row, filter->Width,
+ format, type, 0);
+ _mesa_pack_rgba_span_float(ctx, filter->Width,
+ (const GLfloat (*)[4]) filter->Filter,
+ format, type, dst, &ctx->Pack, 0);
+ }
+
+ /* Column filter */
+ if (column) {
+ GLvoid *dst = _mesa_image_address1d(&ctx->Pack, column, filter->Height,
+ format, type, 0);
+ const GLfloat *src = filter->Filter + colStart;
+ _mesa_pack_rgba_span_float(ctx, filter->Height,
+ (const GLfloat (*)[4]) src,
+ format, type, dst, &ctx->Pack, 0);
+ }
+
+ (void) span; /* unused at this time */
+
+ if (ctx->Pack.BufferObj->Name) {
+ /* Pack filter into PBO */
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ ctx->Unpack.BufferObj);
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column)
+{
+ const GLint colStart = MAX_CONVOLUTION_WIDTH * 4;
+ GLint baseFormat;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (target != GL_SEPARABLE_2D) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glSeparableFilter2D(target)");
+ return;
+ }
+
+ baseFormat = base_filter_format(internalFormat);
+ if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glSeparableFilter2D(internalFormat)");
+ return;
+ }
+
+ if (width < 0 || width > MAX_CONVOLUTION_WIDTH) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glSeparableFilter2D(width)");
+ return;
+ }
+ if (height < 0 || height > MAX_CONVOLUTION_HEIGHT) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glSeparableFilter2D(height)");
+ return;
+ }
+
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glSeparableFilter2D(format or type)");
+ return;
+ }
+
+ if (format == GL_COLOR_INDEX ||
+ format == GL_STENCIL_INDEX ||
+ format == GL_DEPTH_COMPONENT ||
+ format == GL_INTENSITY ||
+ type == GL_BITMAP) {
+ _mesa_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;
+
+ if (ctx->Unpack.BufferObj->Name) {
+ /* unpack filter from PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(1, &ctx->Unpack, width, 1, 1,
+ format, type, row)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glSeparableFilter2D(invalid PBO access, width)");
+ return;
+ }
+ if (!_mesa_validate_pbo_access(1, &ctx->Unpack, height, 1, 1,
+ format, type, column)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glSeparableFilter2D(invalid PBO access, height)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ GL_READ_ONLY_ARB,
+ ctx->Unpack.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glSeparableFilter2D(PBO is mapped)");
+ return;
+ }
+ row = ADD_POINTERS(buf, row);
+ column = ADD_POINTERS(buf, column);
+ }
+
+ /* unpack row filter */
+ if (row) {
+ _mesa_unpack_color_span_float(ctx, width, GL_RGBA,
+ ctx->Separable2D.Filter,
+ format, type, row, &ctx->Unpack,
+ 0); /* transferOps */
+
+ _mesa_scale_and_bias_rgba(width,
+ (GLfloat (*)[4]) ctx->Separable2D.Filter,
+ ctx->Pixel.ConvolutionFilterScale[2][0],
+ ctx->Pixel.ConvolutionFilterScale[2][1],
+ ctx->Pixel.ConvolutionFilterScale[2][2],
+ ctx->Pixel.ConvolutionFilterScale[2][3],
+ ctx->Pixel.ConvolutionFilterBias[2][0],
+ ctx->Pixel.ConvolutionFilterBias[2][1],
+ ctx->Pixel.ConvolutionFilterBias[2][2],
+ ctx->Pixel.ConvolutionFilterBias[2][3]);
+ }
+
+ /* unpack column filter */
+ if (column) {
+ _mesa_unpack_color_span_float(ctx, height, GL_RGBA,
+ &ctx->Separable2D.Filter[colStart],
+ format, type, column, &ctx->Unpack,
+ 0); /* transferOps */
+
+ _mesa_scale_and_bias_rgba(height,
+ (GLfloat (*)[4]) (ctx->Separable2D.Filter + colStart),
+ ctx->Pixel.ConvolutionFilterScale[2][0],
+ ctx->Pixel.ConvolutionFilterScale[2][1],
+ ctx->Pixel.ConvolutionFilterScale[2][2],
+ ctx->Pixel.ConvolutionFilterScale[2][3],
+ ctx->Pixel.ConvolutionFilterBias[2][0],
+ ctx->Pixel.ConvolutionFilterBias[2][1],
+ ctx->Pixel.ConvolutionFilterBias[2][2],
+ ctx->Pixel.ConvolutionFilterBias[2][3]);
+ }
+
+ if (ctx->Unpack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ ctx->Unpack.BufferObj);
+ }
+
+ ctx->NewState |= _NEW_PIXEL;
+}
+
+
+/**********************************************************************/
+/*** image convolution functions ***/
+/**********************************************************************/
+
+static void
+convolve_1d_reduce(GLint srcWidth, const GLfloat src[][4],
+ GLint filterWidth, const GLfloat filter[][4],
+ GLfloat dest[][4])
+{
+ GLint dstWidth;
+ GLint i, n;
+
+ if (filterWidth >= 1)
+ dstWidth = srcWidth - (filterWidth - 1);
+ else
+ dstWidth = srcWidth;
+
+ if (dstWidth <= 0)
+ return; /* null result */
+
+ for (i = 0; i < dstWidth; i++) {
+ GLfloat sumR = 0.0;
+ GLfloat sumG = 0.0;
+ GLfloat sumB = 0.0;
+ GLfloat sumA = 0.0;
+ for (n = 0; n < filterWidth; n++) {
+ sumR += src[i + n][RCOMP] * filter[n][RCOMP];
+ sumG += src[i + n][GCOMP] * filter[n][GCOMP];
+ sumB += src[i + n][BCOMP] * filter[n][BCOMP];
+ sumA += src[i + n][ACOMP] * filter[n][ACOMP];
+ }
+ dest[i][RCOMP] = sumR;
+ dest[i][GCOMP] = sumG;
+ dest[i][BCOMP] = sumB;
+ dest[i][ACOMP] = sumA;
+ }
+}
+
+
+static void
+convolve_1d_constant(GLint srcWidth, const GLfloat src[][4],
+ GLint filterWidth, const GLfloat filter[][4],
+ GLfloat dest[][4],
+ const GLfloat borderColor[4])
+{
+ const GLint halfFilterWidth = filterWidth / 2;
+ GLint i, n;
+
+ for (i = 0; i < srcWidth; i++) {
+ GLfloat sumR = 0.0;
+ GLfloat sumG = 0.0;
+ GLfloat sumB = 0.0;
+ GLfloat sumA = 0.0;
+ for (n = 0; n < filterWidth; n++) {
+ if (i + n < halfFilterWidth || i + n - halfFilterWidth >= srcWidth) {
+ sumR += borderColor[RCOMP] * filter[n][RCOMP];
+ sumG += borderColor[GCOMP] * filter[n][GCOMP];
+ sumB += borderColor[BCOMP] * filter[n][BCOMP];
+ sumA += borderColor[ACOMP] * filter[n][ACOMP];
+ }
+ else {
+ sumR += src[i + n - halfFilterWidth][RCOMP] * filter[n][RCOMP];
+ sumG += src[i + n - halfFilterWidth][GCOMP] * filter[n][GCOMP];
+ sumB += src[i + n - halfFilterWidth][BCOMP] * filter[n][BCOMP];
+ sumA += src[i + n - halfFilterWidth][ACOMP] * filter[n][ACOMP];
+ }
+ }
+ dest[i][RCOMP] = sumR;
+ dest[i][GCOMP] = sumG;
+ dest[i][BCOMP] = sumB;
+ dest[i][ACOMP] = sumA;
+ }
+}
+
+
+static void
+convolve_1d_replicate(GLint srcWidth, const GLfloat src[][4],
+ GLint filterWidth, const GLfloat filter[][4],
+ GLfloat dest[][4])
+{
+ const GLint halfFilterWidth = filterWidth / 2;
+ GLint i, n;
+
+ for (i = 0; i < srcWidth; i++) {
+ GLfloat sumR = 0.0;
+ GLfloat sumG = 0.0;
+ GLfloat sumB = 0.0;
+ GLfloat sumA = 0.0;
+ for (n = 0; n < filterWidth; n++) {
+ if (i + n < halfFilterWidth) {
+ sumR += src[0][RCOMP] * filter[n][RCOMP];
+ sumG += src[0][GCOMP] * filter[n][GCOMP];
+ sumB += src[0][BCOMP] * filter[n][BCOMP];
+ sumA += src[0][ACOMP] * filter[n][ACOMP];
+ }
+ else if (i + n - halfFilterWidth >= srcWidth) {
+ sumR += src[srcWidth - 1][RCOMP] * filter[n][RCOMP];
+ sumG += src[srcWidth - 1][GCOMP] * filter[n][GCOMP];
+ sumB += src[srcWidth - 1][BCOMP] * filter[n][BCOMP];
+ sumA += src[srcWidth - 1][ACOMP] * filter[n][ACOMP];
+ }
+ else {
+ sumR += src[i + n - halfFilterWidth][RCOMP] * filter[n][RCOMP];
+ sumG += src[i + n - halfFilterWidth][GCOMP] * filter[n][GCOMP];
+ sumB += src[i + n - halfFilterWidth][BCOMP] * filter[n][BCOMP];
+ sumA += src[i + n - halfFilterWidth][ACOMP] * filter[n][ACOMP];
+ }
+ }
+ dest[i][RCOMP] = sumR;
+ dest[i][GCOMP] = sumG;
+ dest[i][BCOMP] = sumB;
+ dest[i][ACOMP] = sumA;
+ }
+}
+
+
+static void
+convolve_2d_reduce(GLint srcWidth, GLint srcHeight,
+ const GLfloat src[][4],
+ GLint filterWidth, GLint filterHeight,
+ const GLfloat filter[][4],
+ GLfloat dest[][4])
+{
+ GLint dstWidth, dstHeight;
+ GLint i, j, n, m;
+
+ if (filterWidth >= 1)
+ dstWidth = srcWidth - (filterWidth - 1);
+ else
+ dstWidth = srcWidth;
+
+ if (filterHeight >= 1)
+ dstHeight = srcHeight - (filterHeight - 1);
+ else
+ dstHeight = srcHeight;
+
+ if (dstWidth <= 0 || dstHeight <= 0)
+ return;
+
+ for (j = 0; j < dstHeight; j++) {
+ for (i = 0; i < dstWidth; i++) {
+ GLfloat sumR = 0.0;
+ GLfloat sumG = 0.0;
+ GLfloat sumB = 0.0;
+ GLfloat sumA = 0.0;
+ for (m = 0; m < filterHeight; m++) {
+ for (n = 0; n < filterWidth; n++) {
+ const GLint k = (j + m) * srcWidth + i + n;
+ const GLint f = m * filterWidth + n;
+ sumR += src[k][RCOMP] * filter[f][RCOMP];
+ sumG += src[k][GCOMP] * filter[f][GCOMP];
+ sumB += src[k][BCOMP] * filter[f][BCOMP];
+ sumA += src[k][ACOMP] * filter[f][ACOMP];
+ }
+ }
+ dest[j * dstWidth + i][RCOMP] = sumR;
+ dest[j * dstWidth + i][GCOMP] = sumG;
+ dest[j * dstWidth + i][BCOMP] = sumB;
+ dest[j * dstWidth + i][ACOMP] = sumA;
+ }
+ }
+}
+
+
+static void
+convolve_2d_constant(GLint srcWidth, GLint srcHeight,
+ const GLfloat src[][4],
+ GLint filterWidth, GLint filterHeight,
+ const GLfloat filter[][4],
+ GLfloat dest[][4],
+ const GLfloat borderColor[4])
+{
+ const GLint halfFilterWidth = filterWidth / 2;
+ const GLint halfFilterHeight = filterHeight / 2;
+ GLint i, j, n, m;
+
+ for (j = 0; j < srcHeight; j++) {
+ for (i = 0; i < srcWidth; i++) {
+ GLfloat sumR = 0.0;
+ GLfloat sumG = 0.0;
+ GLfloat sumB = 0.0;
+ GLfloat sumA = 0.0;
+ for (m = 0; m < filterHeight; m++) {
+ for (n = 0; n < filterWidth; n++) {
+ const GLint f = m * filterWidth + n;
+ const GLint is = i + n - halfFilterWidth;
+ const GLint js = j + m - halfFilterHeight;
+ if (is < 0 || is >= srcWidth ||
+ js < 0 || js >= srcHeight) {
+ sumR += borderColor[RCOMP] * filter[f][RCOMP];
+ sumG += borderColor[GCOMP] * filter[f][GCOMP];
+ sumB += borderColor[BCOMP] * filter[f][BCOMP];
+ sumA += borderColor[ACOMP] * filter[f][ACOMP];
+ }
+ else {
+ const GLint k = js * srcWidth + is;
+ sumR += src[k][RCOMP] * filter[f][RCOMP];
+ sumG += src[k][GCOMP] * filter[f][GCOMP];
+ sumB += src[k][BCOMP] * filter[f][BCOMP];
+ sumA += src[k][ACOMP] * filter[f][ACOMP];
+ }
+ }
+ }
+ dest[j * srcWidth + i][RCOMP] = sumR;
+ dest[j * srcWidth + i][GCOMP] = sumG;
+ dest[j * srcWidth + i][BCOMP] = sumB;
+ dest[j * srcWidth + i][ACOMP] = sumA;
+ }
+ }
+}
+
+
+static void
+convolve_2d_replicate(GLint srcWidth, GLint srcHeight,
+ const GLfloat src[][4],
+ GLint filterWidth, GLint filterHeight,
+ const GLfloat filter[][4],
+ GLfloat dest[][4])
+{
+ const GLint halfFilterWidth = filterWidth / 2;
+ const GLint halfFilterHeight = filterHeight / 2;
+ GLint i, j, n, m;
+
+ for (j = 0; j < srcHeight; j++) {
+ for (i = 0; i < srcWidth; i++) {
+ GLfloat sumR = 0.0;
+ GLfloat sumG = 0.0;
+ GLfloat sumB = 0.0;
+ GLfloat sumA = 0.0;
+ for (m = 0; m < filterHeight; m++) {
+ for (n = 0; n < filterWidth; n++) {
+ const GLint f = m * filterWidth + n;
+ GLint is = i + n - halfFilterWidth;
+ GLint js = j + m - halfFilterHeight;
+ GLint k;
+ if (is < 0)
+ is = 0;
+ else if (is >= srcWidth)
+ is = srcWidth - 1;
+ if (js < 0)
+ js = 0;
+ else if (js >= srcHeight)
+ js = srcHeight - 1;
+ k = js * srcWidth + is;
+ sumR += src[k][RCOMP] * filter[f][RCOMP];
+ sumG += src[k][GCOMP] * filter[f][GCOMP];
+ sumB += src[k][BCOMP] * filter[f][BCOMP];
+ sumA += src[k][ACOMP] * filter[f][ACOMP];
+ }
+ }
+ dest[j * srcWidth + i][RCOMP] = sumR;
+ dest[j * srcWidth + i][GCOMP] = sumG;
+ dest[j * srcWidth + i][BCOMP] = sumB;
+ dest[j * srcWidth + i][ACOMP] = sumA;
+ }
+ }
+}
+
+
+static void
+convolve_sep_reduce(GLint srcWidth, GLint srcHeight,
+ const GLfloat src[][4],
+ GLint filterWidth, GLint filterHeight,
+ const GLfloat rowFilt[][4],
+ const GLfloat colFilt[][4],
+ GLfloat dest[][4])
+{
+ GLint dstWidth, dstHeight;
+ GLint i, j, n, m;
+
+ if (filterWidth >= 1)
+ dstWidth = srcWidth - (filterWidth - 1);
+ else
+ dstWidth = srcWidth;
+
+ if (filterHeight >= 1)
+ dstHeight = srcHeight - (filterHeight - 1);
+ else
+ dstHeight = srcHeight;
+
+ if (dstWidth <= 0 || dstHeight <= 0)
+ return;
+
+ for (j = 0; j < dstHeight; j++) {
+ for (i = 0; i < dstWidth; i++) {
+ GLfloat sumR = 0.0;
+ GLfloat sumG = 0.0;
+ GLfloat sumB = 0.0;
+ GLfloat sumA = 0.0;
+ for (m = 0; m < filterHeight; m++) {
+ for (n = 0; n < filterWidth; n++) {
+ GLint k = (j + m) * srcWidth + i + n;
+ sumR += src[k][RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP];
+ sumG += src[k][GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP];
+ sumB += src[k][BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP];
+ sumA += src[k][ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP];
+ }
+ }
+ dest[j * dstWidth + i][RCOMP] = sumR;
+ dest[j * dstWidth + i][GCOMP] = sumG;
+ dest[j * dstWidth + i][BCOMP] = sumB;
+ dest[j * dstWidth + i][ACOMP] = sumA;
+ }
+ }
+}
+
+
+static void
+convolve_sep_constant(GLint srcWidth, GLint srcHeight,
+ const GLfloat src[][4],
+ GLint filterWidth, GLint filterHeight,
+ const GLfloat rowFilt[][4],
+ const GLfloat colFilt[][4],
+ GLfloat dest[][4],
+ const GLfloat borderColor[4])
+{
+ const GLint halfFilterWidth = filterWidth / 2;
+ const GLint halfFilterHeight = filterHeight / 2;
+ GLint i, j, n, m;
+
+ for (j = 0; j < srcHeight; j++) {
+ for (i = 0; i < srcWidth; i++) {
+ GLfloat sumR = 0.0;
+ GLfloat sumG = 0.0;
+ GLfloat sumB = 0.0;
+ GLfloat sumA = 0.0;
+ for (m = 0; m < filterHeight; m++) {
+ for (n = 0; n < filterWidth; n++) {
+ const GLint is = i + n - halfFilterWidth;
+ const GLint js = j + m - halfFilterHeight;
+ if (is < 0 || is >= srcWidth ||
+ js < 0 || js >= srcHeight) {
+ sumR += borderColor[RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP];
+ sumG += borderColor[GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP];
+ sumB += borderColor[BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP];
+ sumA += borderColor[ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP];
+ }
+ else {
+ GLint k = js * srcWidth + is;
+ sumR += src[k][RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP];
+ sumG += src[k][GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP];
+ sumB += src[k][BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP];
+ sumA += src[k][ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP];
+ }
+
+ }
+ }
+ dest[j * srcWidth + i][RCOMP] = sumR;
+ dest[j * srcWidth + i][GCOMP] = sumG;
+ dest[j * srcWidth + i][BCOMP] = sumB;
+ dest[j * srcWidth + i][ACOMP] = sumA;
+ }
+ }
+}
+
+
+static void
+convolve_sep_replicate(GLint srcWidth, GLint srcHeight,
+ const GLfloat src[][4],
+ GLint filterWidth, GLint filterHeight,
+ const GLfloat rowFilt[][4],
+ const GLfloat colFilt[][4],
+ GLfloat dest[][4])
+{
+ const GLint halfFilterWidth = filterWidth / 2;
+ const GLint halfFilterHeight = filterHeight / 2;
+ GLint i, j, n, m;
+
+ for (j = 0; j < srcHeight; j++) {
+ for (i = 0; i < srcWidth; i++) {
+ GLfloat sumR = 0.0;
+ GLfloat sumG = 0.0;
+ GLfloat sumB = 0.0;
+ GLfloat sumA = 0.0;
+ for (m = 0; m < filterHeight; m++) {
+ for (n = 0; n < filterWidth; n++) {
+ GLint is = i + n - halfFilterWidth;
+ GLint js = j + m - halfFilterHeight;
+ GLint k;
+ if (is < 0)
+ is = 0;
+ else if (is >= srcWidth)
+ is = srcWidth - 1;
+ if (js < 0)
+ js = 0;
+ else if (js >= srcHeight)
+ js = srcHeight - 1;
+ k = js * srcWidth + is;
+ sumR += src[k][RCOMP] * rowFilt[n][RCOMP] * colFilt[m][RCOMP];
+ sumG += src[k][GCOMP] * rowFilt[n][GCOMP] * colFilt[m][GCOMP];
+ sumB += src[k][BCOMP] * rowFilt[n][BCOMP] * colFilt[m][BCOMP];
+ sumA += src[k][ACOMP] * rowFilt[n][ACOMP] * colFilt[m][ACOMP];
+ }
+ }
+ dest[j * srcWidth + i][RCOMP] = sumR;
+ dest[j * srcWidth + i][GCOMP] = sumG;
+ dest[j * srcWidth + i][BCOMP] = sumB;
+ dest[j * srcWidth + i][ACOMP] = sumA;
+ }
+ }
+}
+
+
+
+void
+_mesa_convolve_1d_image(const GLcontext *ctx, GLsizei *width,
+ const GLfloat *srcImage, GLfloat *dstImage)
+{
+ switch (ctx->Pixel.ConvolutionBorderMode[0]) {
+ case GL_REDUCE:
+ convolve_1d_reduce(*width, (const GLfloat (*)[4]) srcImage,
+ ctx->Convolution1D.Width,
+ (const GLfloat (*)[4]) ctx->Convolution1D.Filter,
+ (GLfloat (*)[4]) dstImage);
+ *width = *width - (MAX2(ctx->Convolution1D.Width, 1) - 1);
+ break;
+ case GL_CONSTANT_BORDER:
+ convolve_1d_constant(*width, (const GLfloat (*)[4]) srcImage,
+ ctx->Convolution1D.Width,
+ (const GLfloat (*)[4]) ctx->Convolution1D.Filter,
+ (GLfloat (*)[4]) dstImage,
+ ctx->Pixel.ConvolutionBorderColor[0]);
+ break;
+ case GL_REPLICATE_BORDER:
+ convolve_1d_replicate(*width, (const GLfloat (*)[4]) srcImage,
+ ctx->Convolution1D.Width,
+ (const GLfloat (*)[4]) ctx->Convolution1D.Filter,
+ (GLfloat (*)[4]) dstImage);
+ break;
+ default:
+ ;
+ }
+}
+
+
+void
+_mesa_convolve_2d_image(const GLcontext *ctx, GLsizei *width, GLsizei *height,
+ const GLfloat *srcImage, GLfloat *dstImage)
+{
+ switch (ctx->Pixel.ConvolutionBorderMode[1]) {
+ case GL_REDUCE:
+ convolve_2d_reduce(*width, *height,
+ (const GLfloat (*)[4]) srcImage,
+ ctx->Convolution2D.Width,
+ ctx->Convolution2D.Height,
+ (const GLfloat (*)[4]) ctx->Convolution2D.Filter,
+ (GLfloat (*)[4]) dstImage);
+ *width = *width - (MAX2(ctx->Convolution2D.Width, 1) - 1);
+ *height = *height - (MAX2(ctx->Convolution2D.Height, 1) - 1);
+ break;
+ case GL_CONSTANT_BORDER:
+ convolve_2d_constant(*width, *height,
+ (const GLfloat (*)[4]) srcImage,
+ ctx->Convolution2D.Width,
+ ctx->Convolution2D.Height,
+ (const GLfloat (*)[4]) ctx->Convolution2D.Filter,
+ (GLfloat (*)[4]) dstImage,
+ ctx->Pixel.ConvolutionBorderColor[1]);
+ break;
+ case GL_REPLICATE_BORDER:
+ convolve_2d_replicate(*width, *height,
+ (const GLfloat (*)[4]) srcImage,
+ ctx->Convolution2D.Width,
+ ctx->Convolution2D.Height,
+ (const GLfloat (*)[4])ctx->Convolution2D.Filter,
+ (GLfloat (*)[4]) dstImage);
+ break;
+ default:
+ ;
+ }
+}
+
+
+void
+_mesa_convolve_sep_image(const GLcontext *ctx,
+ GLsizei *width, GLsizei *height,
+ const GLfloat *srcImage, GLfloat *dstImage)
+{
+ const GLfloat *rowFilter = ctx->Separable2D.Filter;
+ const GLfloat *colFilter = rowFilter + 4 * MAX_CONVOLUTION_WIDTH;
+
+ switch (ctx->Pixel.ConvolutionBorderMode[2]) {
+ case GL_REDUCE:
+ convolve_sep_reduce(*width, *height,
+ (const GLfloat (*)[4]) srcImage,
+ ctx->Separable2D.Width,
+ ctx->Separable2D.Height,
+ (const GLfloat (*)[4]) rowFilter,
+ (const GLfloat (*)[4]) colFilter,
+ (GLfloat (*)[4]) dstImage);
+ *width = *width - (MAX2(ctx->Separable2D.Width, 1) - 1);
+ *height = *height - (MAX2(ctx->Separable2D.Height, 1) - 1);
+ break;
+ case GL_CONSTANT_BORDER:
+ convolve_sep_constant(*width, *height,
+ (const GLfloat (*)[4]) srcImage,
+ ctx->Separable2D.Width,
+ ctx->Separable2D.Height,
+ (const GLfloat (*)[4]) rowFilter,
+ (const GLfloat (*)[4]) colFilter,
+ (GLfloat (*)[4]) dstImage,
+ ctx->Pixel.ConvolutionBorderColor[2]);
+ break;
+ case GL_REPLICATE_BORDER:
+ convolve_sep_replicate(*width, *height,
+ (const GLfloat (*)[4]) srcImage,
+ ctx->Separable2D.Width,
+ ctx->Separable2D.Height,
+ (const GLfloat (*)[4]) rowFilter,
+ (const GLfloat (*)[4]) colFilter,
+ (GLfloat (*)[4]) dstImage);
+ break;
+ default:
+ ;
+ }
+}
+
+
+
+/*
+ * This function computes an image's size after convolution.
+ * If the convolution border mode is GL_REDUCE, the post-convolution
+ * image will be smaller than the original.
+ */
+void
+_mesa_adjust_image_for_convolution(const GLcontext *ctx, GLuint dimensions,
+ GLsizei *width, GLsizei *height)
+{
+ if (ctx->Pixel.Convolution1DEnabled
+ && dimensions == 1
+ && ctx->Pixel.ConvolutionBorderMode[0] == GL_REDUCE) {
+ *width = *width - (MAX2(ctx->Convolution1D.Width, 1) - 1);
+ }
+ else if (ctx->Pixel.Convolution2DEnabled
+ && dimensions > 1
+ && ctx->Pixel.ConvolutionBorderMode[1] == GL_REDUCE) {
+ *width = *width - (MAX2(ctx->Convolution2D.Width, 1) - 1);
+ *height = *height - (MAX2(ctx->Convolution2D.Height, 1) - 1);
+ }
+ else if (ctx->Pixel.Separable2DEnabled
+ && dimensions > 1
+ && ctx->Pixel.ConvolutionBorderMode[2] == GL_REDUCE) {
+ *width = *width - (MAX2(ctx->Separable2D.Width, 1) - 1);
+ *height = *height - (MAX2(ctx->Separable2D.Height, 1) - 1);
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/convolve.h b/nx-X11/extras/Mesa/src/mesa/main/convolve.h
new file mode 100644
index 000000000..4505cdae0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/convolve.h
@@ -0,0 +1,114 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef CONVOLVE_H
+#define CONVOLVE_H
+
+
+#include "mtypes.h"
+
+
+#if _HAVE_FULL_GL
+extern void GLAPIENTRY
+_mesa_ConvolutionFilter1D(GLenum target, GLenum internalformat, GLsizei width,
+ GLenum format, GLenum type, const GLvoid *image);
+
+extern void GLAPIENTRY
+_mesa_ConvolutionFilter2D(GLenum target, GLenum internalformat, GLsizei width,
+ GLsizei height, GLenum format, GLenum type,
+ const GLvoid *image);
+
+extern void GLAPIENTRY
+_mesa_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat params);
+
+extern void GLAPIENTRY
+_mesa_ConvolutionParameterfv(GLenum target, GLenum pname,
+ const GLfloat *params);
+
+extern void GLAPIENTRY
+_mesa_ConvolutionParameteri(GLenum target, GLenum pname, GLint params);
+
+extern void GLAPIENTRY
+_mesa_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params);
+
+extern void GLAPIENTRY
+_mesa_CopyConvolutionFilter1D(GLenum target, GLenum internalformat,
+ GLint x, GLint y, GLsizei width);
+
+extern void GLAPIENTRY
+_mesa_CopyConvolutionFilter2D(GLenum target, GLenum internalformat,
+ GLint x, GLint y, GLsizei width, GLsizei height);
+
+extern void GLAPIENTRY
+_mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type,
+ GLvoid *image);
+
+extern void GLAPIENTRY
+_mesa_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params);
+
+extern void GLAPIENTRY
+_mesa_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params);
+
+extern void GLAPIENTRY
+_mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type,
+ GLvoid *row, GLvoid *column, GLvoid *span);
+
+extern void GLAPIENTRY
+_mesa_SeparableFilter2D(GLenum target, GLenum internalformat,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *row, const GLvoid *column);
+
+
+
+extern void
+_mesa_convolve_1d_image(const GLcontext *ctx, GLsizei *width,
+ const GLfloat *srcImage, GLfloat *dstImage);
+
+
+extern void
+_mesa_convolve_2d_image(const GLcontext *ctx, GLsizei *width, GLsizei *height,
+ const GLfloat *srcImage, GLfloat *dstImage);
+
+
+extern void
+_mesa_convolve_sep_image(const GLcontext *ctx,
+ GLsizei *width, GLsizei *height,
+ const GLfloat *srcImage, GLfloat *dstImage);
+
+
+extern void
+_mesa_adjust_image_for_convolution(const GLcontext *ctx, GLuint dimensions,
+ GLsizei *width, GLsizei *height);
+
+#else
+#define _mesa_adjust_image_for_convolution(c, d, w, h) ((void)0)
+#define _mesa_convolve_1d_image(c,w,s,d) ((void)0)
+#define _mesa_convolve_2d_image(c,w,h,s,d) ((void)0)
+#define _mesa_convolve_sep_image(c,w,h,s,d) ((void)0)
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/dd.h b/nx-X11/extras/Mesa/src/mesa/main/dd.h
new file mode 100644
index 000000000..e4c103c55
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/dd.h
@@ -0,0 +1,1063 @@
+/**
+ * \file dd.h
+ * Device driver interfaces.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef DD_INCLUDED
+#define DD_INCLUDED
+
+/* THIS FILE ONLY INCLUDED BY mtypes.h !!!!! */
+
+struct gl_pixelstore_attrib;
+struct mesa_display_list;
+
+/**
+ * Device driver function table.
+ * Core Mesa uses these function pointers to call into device drivers.
+ * Most of these functions directly correspond to OpenGL state commands.
+ * Core Mesa will call these functions after error checking has been done
+ * so that the drivers don't have to worry about error testing.
+ *
+ * Vertex transformation/clipping/lighting is patched into the T&L module.
+ * Rasterization functions are patched into the swrast module.
+ *
+ * Note: when new functions are added here, the drivers/common/driverfuncs.c
+ * file should be updated too!!!
+ */
+struct dd_function_table {
+ /**
+ * Return a string as needed by glGetString().
+ *
+ * Only the GL_RENDERER token must be implemented. Otherwise, NULL can be
+ * returned.
+ */
+ const GLubyte * (*GetString)( GLcontext *ctx, GLenum name );
+
+ /**
+ * Notify the driver after Mesa has made some internal state changes.
+ *
+ * This is in addition to any state change callbacks Mesa may already have
+ * made.
+ */
+ void (*UpdateState)( GLcontext *ctx, GLuint new_state );
+
+ /**
+ * Get the width and height of the named buffer/window.
+ *
+ * Mesa uses this to determine when the driver's window size has changed.
+ */
+ void (*GetBufferSize)( GLframebuffer *buffer,
+ GLuint *width, GLuint *height );
+
+ /**
+ * Resize the given framebuffer to the given size.
+ */
+ void (*ResizeBuffers)( GLcontext *ctx, GLframebuffer *fb,
+ GLuint width, GLuint height);
+
+ /**
+ * Called whenever an error is generated.
+ *
+ * __GLcontextRec::ErrorValue contains the error value.
+ */
+ void (*Error)( GLcontext *ctx );
+
+ /**
+ * This is called whenever glFinish() is called.
+ */
+ void (*Finish)( GLcontext *ctx );
+
+ /**
+ * This is called whenever glFlush() is called.
+ */
+ void (*Flush)( GLcontext *ctx );
+
+ /**
+ * Clear the color/depth/stencil/accum buffer(s).
+ *
+ * \param mask a bitmask of the DD_*_BIT values defined above that indicates
+ * which buffers need to be cleared.
+ * \param all if true then clear the whole buffer, else clear only the
+ * region defined by <tt>(x, y, width, height)</tt>.
+ *
+ * This function must obey the glColorMask(), glIndexMask() and
+ * glStencilMask() settings!
+ * Software Mesa can do masked clears if the device driver can't.
+ */
+ void (*Clear)( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height );
+
+
+ /**
+ * \name For hardware accumulation buffer
+ */
+ /*@{*/
+ /**
+ * Execute glAccum command within the given scissor region.
+ */
+ void (*Accum)( GLcontext *ctx, GLenum op, GLfloat value,
+ GLint xpos, GLint ypos, GLint width, GLint height );
+ /*@}*/
+
+
+ /**
+ * \name glDraw(), glRead(), glCopyPixels() and glBitmap() functions
+ */
+ /*@{*/
+
+ /**
+ * This is called by glDrawPixels().
+ *
+ * \p unpack describes how to unpack the source image data.
+ */
+ void (*DrawPixels)( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels );
+
+ /**
+ * Called by glReadPixels().
+ */
+ void (*ReadPixels)( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ GLvoid *dest );
+
+ /**
+ * Do a glCopyPixels().
+ *
+ * This function must respect all rasterization state, glPixelTransfer(),
+ * glPixelZoom(), etc.
+ */
+ void (*CopyPixels)( GLcontext *ctx, GLint srcx, GLint srcy,
+ GLsizei width, GLsizei height,
+ GLint dstx, GLint dsty, GLenum type );
+
+ /**
+ * This is called by glBitmap().
+ *
+ * Works the same as dd_function_table::DrawPixels, above.
+ */
+ void (*Bitmap)( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap );
+ /*@}*/
+
+
+ /**
+ * \name Texture image functions
+ */
+ /*@{*/
+
+ /**
+ * Choose texture format.
+ *
+ * This is called by the \c _mesa_store_tex[sub]image[123]d() fallback
+ * functions. The driver should examine \p internalFormat and return a
+ * pointer to an appropriate gl_texture_format.
+ */
+ const struct gl_texture_format *(*ChooseTextureFormat)( GLcontext *ctx,
+ GLint internalFormat, GLenum srcFormat, GLenum srcType );
+
+ /**
+ * Called by glTexImage1D().
+ *
+ * \param target user specified.
+ * \param format user specified.
+ * \param type user specified.
+ * \param pixels user specified.
+ * \param packing indicates the image packing of pixels.
+ * \param texObj is the target texture object.
+ * \param texImage is the target texture image. It will have the texture \p
+ * width, \p height, \p depth, \p border and \p internalFormat information.
+ *
+ * \p retainInternalCopy is returned by this function and indicates whether
+ * core Mesa should keep an internal copy of the texture image.
+ *
+ * Drivers should call a fallback routine from texstore.c if needed.
+ */
+ void (*TexImage1D)( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ 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 glTexImage2D().
+ *
+ * \sa dd_function_table::TexImage1D.
+ */
+ void (*TexImage2D)( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ 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 glTexImage3D().
+ *
+ * \sa dd_function_table::TexImage1D.
+ */
+ void (*TexImage3D)( GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint depth, GLint border,
+ 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 glTexSubImage1D().
+ *
+ * \param target user specified.
+ * \param level user specified.
+ * \param xoffset user specified.
+ * \param yoffset user specified.
+ * \param zoffset user specified.
+ * \param width user specified.
+ * \param height user specified.
+ * \param depth user specified.
+ * \param format user specified.
+ * \param type user specified.
+ * \param pixels user specified.
+ * \param packing indicates the image packing of pixels.
+ * \param texObj is the target texture object.
+ * \param texImage is the target texture image. It will have the texture \p
+ * width, \p height, \p border and \p internalFormat information.
+ *
+ * The driver should use a fallback routine from texstore.c if needed.
+ */
+ void (*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 );
+
+ /**
+ * Called by glTexSubImage2D().
+ *
+ * \sa dd_function_table::TexSubImage1D.
+ */
+ void (*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 );
+
+ /**
+ * Called by glTexSubImage3D().
+ *
+ * \sa dd_function_table::TexSubImage1D.
+ */
+ void (*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 glGetTexImage().
+ */
+ void (*GetTexImage)( GLcontext *ctx, GLenum target, GLint level,
+ GLenum format, GLenum type, GLvoid *pixels,
+ const struct gl_texture_object *texObj,
+ const struct gl_texture_image *texImage );
+
+ /**
+ * Called by glCopyTexImage1D().
+ *
+ * Drivers should use a fallback routine from texstore.c if needed.
+ */
+ void (*CopyTexImage1D)( GLcontext *ctx, GLenum target, GLint level,
+ GLenum internalFormat, GLint x, GLint y,
+ GLsizei width, GLint border );
+
+ /**
+ * Called by glCopyTexImage2D().
+ *
+ * Drivers should use a fallback routine from texstore.c if needed.
+ */
+ void (*CopyTexImage2D)( GLcontext *ctx, GLenum target, GLint level,
+ GLenum internalFormat, GLint x, GLint y,
+ GLsizei width, GLsizei height, GLint border );
+
+ /**
+ * Called by glCopyTexSubImage1D().
+ *
+ * Drivers should use a fallback routine from texstore.c if needed.
+ */
+ void (*CopyTexSubImage1D)( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset,
+ GLint x, GLint y, GLsizei width );
+ /**
+ * Called by glCopyTexSubImage2D().
+ *
+ * Drivers should use a fallback routine from texstore.c if needed.
+ */
+ void (*CopyTexSubImage2D)( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height );
+ /**
+ * Called by glCopyTexSubImage3D().
+ *
+ * Drivers should use a fallback routine from texstore.c if needed.
+ */
+ void (*CopyTexSubImage3D)( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height );
+
+ /**
+ * Called by glTexImage[123]D when user specifies a proxy texture
+ * target.
+ *
+ * \return GL_TRUE if the proxy test passes, or GL_FALSE if the test fails.
+ */
+ GLboolean (*TestProxyTexImage)(GLcontext *ctx, GLenum target,
+ GLint level, GLint internalFormat,
+ GLenum format, GLenum type,
+ GLint width, GLint height,
+ GLint depth, GLint border);
+ /*@}*/
+
+
+ /**
+ * \name Compressed texture functions
+ */
+ /*@{*/
+
+ /**
+ * Called by glCompressedTexImage1D().
+ *
+ * \param target user specified.
+ * \param format user specified.
+ * \param type user specified.
+ * \param pixels user specified.
+ * \param packing indicates the image packing of pixels.
+ * \param texObj is the target texture object.
+ * \param texImage is the target texture image. It will have the texture \p
+ * width, \p height, \p depth, \p border and \p internalFormat information.
+ *
+ * \a retainInternalCopy is returned by this function and indicates whether
+ * core Mesa should keep an internal copy of the texture image.
+ */
+ void (*CompressedTexImage1D)( GLcontext *ctx, GLenum target,
+ GLint level, GLint internalFormat,
+ GLsizei width, GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage );
+ /**
+ * Called by glCompressedTexImage2D().
+ *
+ * \sa dd_function_table::CompressedTexImage1D.
+ */
+ void (*CompressedTexImage2D)( GLcontext *ctx, GLenum target,
+ GLint level, GLint internalFormat,
+ GLsizei width, GLsizei height, GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage );
+ /**
+ * Called by glCompressedTexImage3D().
+ *
+ * \sa dd_function_table::CompressedTexImage3D.
+ */
+ void (*CompressedTexImage3D)( GLcontext *ctx, GLenum target,
+ GLint level, GLint internalFormat,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage );
+
+ /**
+ * Called by glCompressedTexSubImage1D().
+ *
+ * \param target user specified.
+ * \param level user specified.
+ * \param xoffset user specified.
+ * \param yoffset user specified.
+ * \param zoffset user specified.
+ * \param width user specified.
+ * \param height user specified.
+ * \param depth user specified.
+ * \param imageSize user specified.
+ * \param data user specified.
+ * \param texObj is the target texture object.
+ * \param texImage is the target texture image. It will have the texture \p
+ * width, \p height, \p depth, \p border and \p internalFormat information.
+ */
+ void (*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);
+ /**
+ * Called by glCompressedTexSubImage2D().
+ *
+ * \sa dd_function_table::CompressedTexImage3D.
+ */
+ void (*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);
+ /**
+ * Called by glCompressedTexSubImage3D().
+ *
+ * \sa dd_function_table::CompressedTexImage3D.
+ */
+ void (*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 glGetCompressedTexImage.
+ */
+ void (*GetCompressedTexImage)(GLcontext *ctx, GLenum target, GLint level,
+ GLvoid *img,
+ const struct gl_texture_object *texObj,
+ const struct gl_texture_image *texImage);
+
+ /**
+ * Called to query number of bytes of storage needed to store the
+ * specified compressed texture.
+ */
+ GLuint (*CompressedTextureSize)( GLcontext *ctx, GLsizei width,
+ GLsizei height, GLsizei depth,
+ GLenum format );
+ /*@}*/
+
+ /**
+ * \name Texture object functions
+ */
+ /*@{*/
+
+ /**
+ * Called by glBindTexture().
+ */
+ void (*BindTexture)( GLcontext *ctx, GLenum target,
+ struct gl_texture_object *tObj );
+
+ /**
+ * Called to allocate a new texture object.
+ * A new gl_texture_object should be returned. The driver should
+ * attach to it any device-specific info it needs.
+ */
+ struct gl_texture_object * (*NewTextureObject)( GLcontext *ctx, GLuint name,
+ GLenum target );
+ /**
+ * Called when a texture object is about to be deallocated.
+ *
+ * Driver should delete the gl_texture_object object and anything
+ * hanging off of it.
+ */
+ void (*DeleteTexture)( GLcontext *ctx, struct gl_texture_object *tObj );
+
+ /**
+ * Called to allocate a new texture image object.
+ */
+ struct gl_texture_image * (*NewTextureImage)( GLcontext *ctx );
+
+ /**
+ * Called to free tImage->Data.
+ */
+ void (*FreeTexImageData)( GLcontext *ctx, struct gl_texture_image *tImage );
+
+ /**
+ * Note: no context argument. This function doesn't initially look
+ * like it belongs here, except that the driver is the only entity
+ * that knows for sure how the texture memory is allocated - via
+ * the above callbacks. There is then an argument that the driver
+ * knows what memcpy paths might be fast. Typically this is invoked with
+ *
+ * to -- a pointer into texture memory allocated by NewTextureImage() above.
+ * from -- a pointer into client memory or a mesa temporary.
+ * sz -- nr bytes to copy.
+ */
+ void* (*TextureMemCpy)( void *to, const void *from, size_t sz );
+
+ /**
+ * Called by glAreTextureResident().
+ */
+ GLboolean (*IsTextureResident)( GLcontext *ctx,
+ struct gl_texture_object *t );
+
+ /**
+ * Called by glPrioritizeTextures().
+ */
+ void (*PrioritizeTexture)( GLcontext *ctx, struct gl_texture_object *t,
+ GLclampf priority );
+
+ /**
+ * Called by glActiveTextureARB() to set current texture unit.
+ */
+ void (*ActiveTexture)( GLcontext *ctx, GLuint texUnitNumber );
+
+ /**
+ * Called when the texture's color lookup table is changed.
+ *
+ * If \p tObj is NULL then the shared texture palette
+ * gl_texture_object::Palette is to be updated.
+ */
+ void (*UpdateTexturePalette)( GLcontext *ctx,
+ struct gl_texture_object *tObj );
+ /*@}*/
+
+
+ /**
+ * \name Imaging functionality
+ */
+ /*@{*/
+ void (*CopyColorTable)( GLcontext *ctx,
+ GLenum target, GLenum internalformat,
+ GLint x, GLint y, GLsizei width );
+
+ void (*CopyColorSubTable)( GLcontext *ctx,
+ GLenum target, GLsizei start,
+ GLint x, GLint y, GLsizei width );
+
+ void (*CopyConvolutionFilter1D)( GLcontext *ctx, GLenum target,
+ GLenum internalFormat,
+ GLint x, GLint y, GLsizei width );
+
+ void (*CopyConvolutionFilter2D)( GLcontext *ctx, GLenum target,
+ GLenum internalFormat,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height );
+ /*@}*/
+
+
+ /**
+ * \name Vertex/fragment program functions
+ */
+ /*@{*/
+ /** Bind a vertex/fragment program */
+ void (*BindProgram)(GLcontext *ctx, GLenum target, struct program *prog);
+ /** Allocate a new program */
+ struct program * (*NewProgram)(GLcontext *ctx, GLenum target, GLuint id);
+ /** Delete a program */
+ void (*DeleteProgram)(GLcontext *ctx, struct program *prog);
+ /** Notify driver that a program string has been specified. */
+ void (*ProgramStringNotify)(GLcontext *ctx, GLenum target,
+ struct program *prog);
+
+
+
+ /** Query if program can be loaded onto hardware */
+ GLboolean (*IsProgramNative)(GLcontext *ctx, GLenum target,
+ struct program *prog);
+
+ /*@}*/
+
+
+ /**
+ * \name State-changing functions.
+ *
+ * \note drawing functions are above.
+ *
+ * These functions are called by their corresponding OpenGL API functions.
+ * They are \e also called by the gl_PopAttrib() function!!!
+ * May add more functions like these to the device driver in the future.
+ */
+ /*@{*/
+ /** Specify the alpha test function */
+ void (*AlphaFunc)(GLcontext *ctx, GLenum func, GLfloat ref);
+ /** Set the blend color */
+ void (*BlendColor)(GLcontext *ctx, const GLfloat color[4]);
+ /** Set the blend equation */
+ void (*BlendEquationSeparate)(GLcontext *ctx, GLenum modeRGB, GLenum modeA);
+ /** Specify pixel arithmetic */
+ void (*BlendFuncSeparate)(GLcontext *ctx,
+ GLenum sfactorRGB, GLenum dfactorRGB,
+ GLenum sfactorA, GLenum dfactorA);
+ /** Specify clear values for the color buffers */
+ void (*ClearColor)(GLcontext *ctx, const GLfloat color[4]);
+ /** Specify the clear value for the depth buffer */
+ void (*ClearDepth)(GLcontext *ctx, GLclampd d);
+ /** Specify the clear value for the color index buffers */
+ void (*ClearIndex)(GLcontext *ctx, GLuint index);
+ /** Specify the clear value for the stencil buffer */
+ void (*ClearStencil)(GLcontext *ctx, GLint s);
+ /** Specify a plane against which all geometry is clipped */
+ void (*ClipPlane)(GLcontext *ctx, GLenum plane, const GLfloat *equation );
+ /** Enable and disable writing of frame buffer color components */
+ void (*ColorMask)(GLcontext *ctx, GLboolean rmask, GLboolean gmask,
+ GLboolean bmask, GLboolean amask );
+ /** Cause a material color to track the current color */
+ void (*ColorMaterial)(GLcontext *ctx, GLenum face, GLenum mode);
+ /** Specify whether front- or back-facing facets can be culled */
+ void (*CullFace)(GLcontext *ctx, GLenum mode);
+ /** Define front- and back-facing polygons */
+ void (*FrontFace)(GLcontext *ctx, GLenum mode);
+ /** Specify the value used for depth buffer comparisons */
+ void (*DepthFunc)(GLcontext *ctx, GLenum func);
+ /** Enable or disable writing into the depth buffer */
+ void (*DepthMask)(GLcontext *ctx, GLboolean flag);
+ /** Specify mapping of depth values from NDC to window coordinates */
+ void (*DepthRange)(GLcontext *ctx, GLclampd nearval, GLclampd farval);
+ /** Specify the current buffer for writing */
+ void (*DrawBuffer)( GLcontext *ctx, GLenum buffer );
+ /** Specify the buffers for writing for fragment programs*/
+ void (*DrawBuffers)( GLcontext *ctx, GLsizei n, const GLenum *buffers );
+ /** Enable or disable server-side gl capabilities */
+ void (*Enable)(GLcontext *ctx, GLenum cap, GLboolean state);
+ /** Specify fog parameters */
+ void (*Fogfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
+ /** Specify implementation-specific hints */
+ void (*Hint)(GLcontext *ctx, GLenum target, GLenum mode);
+ /** Control the writing of individual bits in the color index buffers */
+ void (*IndexMask)(GLcontext *ctx, GLuint mask);
+ /** Set light source parameters */
+ void (*Lightfv)(GLcontext *ctx, GLenum light,
+ GLenum pname, const GLfloat *params );
+ /** Set the lighting model parameters */
+ void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params);
+ /** Specify the line stipple pattern */
+ void (*LineStipple)(GLcontext *ctx, GLint factor, GLushort pattern );
+ /** Specify the width of rasterized lines */
+ void (*LineWidth)(GLcontext *ctx, GLfloat width);
+ /** Specify a logical pixel operation for color index rendering */
+ void (*LogicOpcode)(GLcontext *ctx, GLenum opcode);
+ void (*PointParameterfv)(GLcontext *ctx, GLenum pname,
+ const GLfloat *params);
+ /** Specify the diameter of rasterized points */
+ void (*PointSize)(GLcontext *ctx, GLfloat size);
+ /** Select a polygon rasterization mode */
+ void (*PolygonMode)(GLcontext *ctx, GLenum face, GLenum mode);
+ /** Set the scale and units used to calculate depth values */
+ void (*PolygonOffset)(GLcontext *ctx, GLfloat factor, GLfloat units);
+ /** Set the polygon stippling pattern */
+ void (*PolygonStipple)(GLcontext *ctx, const GLubyte *mask );
+ /* Specifies the current buffer for reading */
+ void (*ReadBuffer)( GLcontext *ctx, GLenum buffer );
+ /** Set rasterization mode */
+ void (*RenderMode)(GLcontext *ctx, GLenum mode );
+ /** Define the scissor box */
+ void (*Scissor)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
+ /** Select flat or smooth shading */
+ void (*ShadeModel)(GLcontext *ctx, GLenum mode);
+ /** Set function and reference value for stencil testing */
+ void (*StencilFunc)(GLcontext *ctx, GLenum func, GLint ref, GLuint mask);
+ /** Control the writing of individual bits in the stencil planes */
+ void (*StencilMask)(GLcontext *ctx, GLuint mask);
+ /** Set stencil test actions */
+ void (*StencilOp)(GLcontext *ctx, GLenum fail, GLenum zfail, GLenum zpass);
+ /** Set active stencil face (GL_EXT_stencil_two_side) */
+ void (*ActiveStencilFace)(GLcontext *ctx, GLuint face);
+ /** OpenGL 2.0 two-sided StencilFunc */
+ void (*StencilFuncSeparate)(GLcontext *ctx, GLenum face, GLenum func,
+ GLint ref, GLuint mask);
+ /** OpenGL 2.0 two-sided StencilMask */
+ void (*StencilMaskSeparate)(GLcontext *ctx, GLenum face, GLuint mask);
+ /** OpenGL 2.0 two-sided StencilOp */
+ void (*StencilOpSeparate)(GLcontext *ctx, GLenum face, GLenum fail,
+ GLenum zfail, GLenum zpass);
+ /** Control the generation of texture coordinates */
+ void (*TexGen)(GLcontext *ctx, GLenum coord, GLenum pname,
+ const GLfloat *params);
+ /** Set texture environment parameters */
+ void (*TexEnv)(GLcontext *ctx, GLenum target, GLenum pname,
+ const GLfloat *param);
+ /** Set texture parameters */
+ void (*TexParameter)(GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj,
+ GLenum pname, const GLfloat *params);
+ void (*TextureMatrix)(GLcontext *ctx, GLuint unit, const GLmatrix *mat);
+ /** Set the viewport */
+ void (*Viewport)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h);
+ /*@}*/
+
+
+ /**
+ * \name Vertex array functions
+ *
+ * Called by the corresponding OpenGL functions.
+ */
+ /*@{*/
+ void (*VertexPointer)(GLcontext *ctx, GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr);
+ void (*NormalPointer)(GLcontext *ctx, GLenum type,
+ GLsizei stride, const GLvoid *ptr);
+ void (*ColorPointer)(GLcontext *ctx, GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr);
+ void (*FogCoordPointer)(GLcontext *ctx, GLenum type,
+ GLsizei stride, const GLvoid *ptr);
+ void (*IndexPointer)(GLcontext *ctx, GLenum type,
+ GLsizei stride, const GLvoid *ptr);
+ void (*SecondaryColorPointer)(GLcontext *ctx, GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr);
+ void (*TexCoordPointer)(GLcontext *ctx, GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr);
+ void (*EdgeFlagPointer)(GLcontext *ctx, GLsizei stride, const GLvoid *ptr);
+ void (*VertexAttribPointer)(GLcontext *ctx, GLuint index, GLint size,
+ GLenum type, GLsizei stride, const GLvoid *ptr);
+ void (*LockArraysEXT)( GLcontext *ctx, GLint first, GLsizei count );
+ void (*UnlockArraysEXT)( GLcontext *ctx );
+ /*@}*/
+
+
+ /**
+ * \name State-query functions
+ *
+ * Return GL_TRUE if query was completed, GL_FALSE otherwise.
+ */
+ /*@{*/
+ /** Return the value or values of a selected parameter */
+ GLboolean (*GetBooleanv)(GLcontext *ctx, GLenum pname, GLboolean *result);
+ /** Return the value or values of a selected parameter */
+ GLboolean (*GetDoublev)(GLcontext *ctx, GLenum pname, GLdouble *result);
+ /** Return the value or values of a selected parameter */
+ GLboolean (*GetFloatv)(GLcontext *ctx, GLenum pname, GLfloat *result);
+ /** Return the value or values of a selected parameter */
+ GLboolean (*GetIntegerv)(GLcontext *ctx, GLenum pname, GLint *result);
+ /** Return the value or values of a selected parameter */
+ GLboolean (*GetPointerv)(GLcontext *ctx, GLenum pname, GLvoid **result);
+ /*@}*/
+
+
+ /**
+ * \name Vertex/pixel buffer object functions
+ */
+#if FEATURE_ARB_vertex_buffer_object
+ /*@{*/
+ void (*BindBuffer)( GLcontext *ctx, GLenum target,
+ struct gl_buffer_object *obj );
+
+ struct gl_buffer_object * (*NewBufferObject)( GLcontext *ctx, GLuint buffer,
+ GLenum target );
+
+ void (*DeleteBuffer)( GLcontext *ctx, struct gl_buffer_object *obj );
+
+ void (*BufferData)( GLcontext *ctx, GLenum target, GLsizeiptrARB size,
+ const GLvoid *data, GLenum usage,
+ struct gl_buffer_object *obj );
+
+ void (*BufferSubData)( GLcontext *ctx, GLenum target, GLintptrARB offset,
+ GLsizeiptrARB size, const GLvoid *data,
+ struct gl_buffer_object *obj );
+
+ void (*GetBufferSubData)( GLcontext *ctx, GLenum target,
+ GLintptrARB offset, GLsizeiptrARB size,
+ GLvoid *data, struct gl_buffer_object *obj );
+
+ void * (*MapBuffer)( GLcontext *ctx, GLenum target, GLenum access,
+ struct gl_buffer_object *obj );
+
+ GLboolean (*UnmapBuffer)( GLcontext *ctx, GLenum target,
+ struct gl_buffer_object *obj );
+ /*@}*/
+#endif
+
+ /**
+ * \name Functions for GL_EXT_framebuffer_object
+ */
+#if FEATURE_EXT_framebuffer_object
+ /*@{*/
+ struct gl_framebuffer * (*NewFramebuffer)(GLcontext *ctx, GLuint name);
+ struct gl_renderbuffer * (*NewRenderbuffer)(GLcontext *ctx, GLuint name);
+ void (*FramebufferRenderbuffer)(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_renderbuffer *rb);
+ void (*RenderbufferTexture)(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_texture_object *texObj,
+ GLenum texTarget, GLuint level, GLuint zoffset);
+ /*@}*/
+#endif
+
+
+ /**
+ * \name Support for multiple T&L engines
+ */
+ /*@{*/
+
+ /**
+ * Bitmask of state changes that require the current T&L module to be
+ * validated, using ValidateTnlModule() below.
+ */
+ GLuint NeedValidate;
+
+ /**
+ * Validate the current T&L module.
+ *
+ * This is called directly after UpdateState() when a state change that has
+ * occurred matches the dd_function_table::NeedValidate bitmask above. This
+ * ensures all computed values are up to date, thus allowing the driver to
+ * decide if the current T&L module needs to be swapped out.
+ *
+ * This must be non-NULL if a driver installs a custom T&L module and sets
+ * the dd_function_table::NeedValidate bitmask, but may be NULL otherwise.
+ */
+ void (*ValidateTnlModule)( GLcontext *ctx, GLuint new_state );
+
+
+#define PRIM_OUTSIDE_BEGIN_END GL_POLYGON+1
+#define PRIM_INSIDE_UNKNOWN_PRIM GL_POLYGON+2
+#define PRIM_UNKNOWN GL_POLYGON+3
+
+ /**
+ * Set by the driver-supplied T&L engine.
+ *
+ * Set to PRIM_OUTSIDE_BEGIN_END when outside glBegin()/glEnd().
+ */
+ GLuint CurrentExecPrimitive;
+
+ /**
+ * Current state of an in-progress compilation.
+ *
+ * May take on any of the additional values PRIM_OUTSIDE_BEGIN_END,
+ * PRIM_INSIDE_UNKNOWN_PRIM or PRIM_UNKNOWN defined above.
+ */
+ GLuint CurrentSavePrimitive;
+
+
+#define FLUSH_STORED_VERTICES 0x1
+#define FLUSH_UPDATE_CURRENT 0x2
+ /**
+ * Set by the driver-supplied T&L engine whenever vertices are buffered
+ * between glBegin()/glEnd() objects or __GLcontextRec::Current is not
+ * updated.
+ *
+ * The dd_function_table::FlushVertices call below may be used to resolve
+ * these conditions.
+ */
+ GLuint NeedFlush;
+ GLuint SaveNeedFlush;
+
+ /**
+ * If inside glBegin()/glEnd(), it should ASSERT(0). Otherwise, if
+ * FLUSH_STORED_VERTICES bit in \p flags is set flushes any buffered
+ * vertices, if FLUSH_UPDATE_CURRENT bit is set updates
+ * __GLcontextRec::Current and gl_light_attrib::Material
+ *
+ * Note that the default T&L engine never clears the
+ * FLUSH_UPDATE_CURRENT bit, even after performing the update.
+ */
+ void (*FlushVertices)( GLcontext *ctx, GLuint flags );
+ void (*SaveFlushVertices)( GLcontext *ctx );
+
+ /**
+ * Give the driver the opportunity to hook in its own vtxfmt for
+ * compiling optimized display lists. This is called on each valid
+ * glBegin() during list compilation.
+ */
+ GLboolean (*NotifySaveBegin)( GLcontext *ctx, GLenum mode );
+
+ /**
+ * Notify driver that the special derived value _NeedEyeCoords has
+ * changed.
+ */
+ void (*LightingSpaceChange)( GLcontext *ctx );
+
+ /**
+ * Let the T&L component know when the context becomes current.
+ */
+ void (*MakeCurrent)( GLcontext *ctx, GLframebuffer *drawBuffer,
+ GLframebuffer *readBuffer );
+
+ /**
+ * Called by glNewList().
+ *
+ * Let the T&L component know what is going on with display lists
+ * in time to make changes to dispatch tables, etc.
+ */
+ void (*NewList)( GLcontext *ctx, GLuint list, GLenum mode );
+ /**
+ * Called by glEndList().
+ *
+ * \sa dd_function_table::NewList.
+ */
+ void (*EndList)( GLcontext *ctx );
+
+ /**
+ * Called by glCallList(s).
+ *
+ * Notify the T&L component before and after calling a display list.
+ */
+ void (*BeginCallList)( GLcontext *ctx,
+ struct mesa_display_list *dlist );
+ /**
+ * Called by glEndCallList().
+ *
+ * \sa dd_function_table::BeginCallList.
+ */
+ void (*EndCallList)( GLcontext *ctx );
+
+};
+
+
+/**
+ * Transform/Clip/Lighting interface
+ *
+ * Drivers present a reduced set of the functions possible in
+ * glBegin()/glEnd() objects. Core mesa provides translation stubs for the
+ * remaining functions to map down to these entry points.
+ *
+ * These are the initial values to be installed into dispatch by
+ * mesa. If the T&L driver wants to modify the dispatch table
+ * while installed, it must do so itself. It would be possible for
+ * the vertexformat to install it's own initial values for these
+ * functions, but this way there is an obvious list of what is
+ * expected of the driver.
+ *
+ * If the driver wants to hook in entry points other than those
+ * listed, it must restore them to their original values in
+ * the disable() callback, below.
+ */
+typedef struct {
+ /**
+ * \name Vertex
+ */
+ /*@{*/
+ void (GLAPIENTRYP ArrayElement)( GLint ); /* NOTE */
+ void (GLAPIENTRYP Color3f)( GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP Color3fv)( const GLfloat * );
+ void (GLAPIENTRYP Color4f)( GLfloat, GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP Color4fv)( const GLfloat * );
+ void (GLAPIENTRYP EdgeFlag)( GLboolean );
+ void (GLAPIENTRYP EdgeFlagv)( const GLboolean * );
+ void (GLAPIENTRYP EvalCoord1f)( GLfloat ); /* NOTE */
+ void (GLAPIENTRYP EvalCoord1fv)( const GLfloat * ); /* NOTE */
+ void (GLAPIENTRYP EvalCoord2f)( GLfloat, GLfloat ); /* NOTE */
+ void (GLAPIENTRYP EvalCoord2fv)( const GLfloat * ); /* NOTE */
+ void (GLAPIENTRYP EvalPoint1)( GLint ); /* NOTE */
+ void (GLAPIENTRYP EvalPoint2)( GLint, GLint ); /* NOTE */
+ void (GLAPIENTRYP FogCoordfEXT)( GLfloat );
+ void (GLAPIENTRYP FogCoordfvEXT)( const GLfloat * );
+ void (GLAPIENTRYP Indexf)( GLfloat );
+ void (GLAPIENTRYP Indexfv)( const GLfloat * );
+ void (GLAPIENTRYP Materialfv)( GLenum face, GLenum pname, const GLfloat * ); /* NOTE */
+ void (GLAPIENTRYP MultiTexCoord1fARB)( GLenum, GLfloat );
+ void (GLAPIENTRYP MultiTexCoord1fvARB)( GLenum, const GLfloat * );
+ void (GLAPIENTRYP MultiTexCoord2fARB)( GLenum, GLfloat, GLfloat );
+ void (GLAPIENTRYP MultiTexCoord2fvARB)( GLenum, const GLfloat * );
+ void (GLAPIENTRYP MultiTexCoord3fARB)( GLenum, GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP MultiTexCoord3fvARB)( GLenum, const GLfloat * );
+ void (GLAPIENTRYP MultiTexCoord4fARB)( GLenum, GLfloat, GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP MultiTexCoord4fvARB)( GLenum, const GLfloat * );
+ void (GLAPIENTRYP Normal3f)( GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP Normal3fv)( const GLfloat * );
+ void (GLAPIENTRYP SecondaryColor3fEXT)( GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP SecondaryColor3fvEXT)( const GLfloat * );
+ void (GLAPIENTRYP TexCoord1f)( GLfloat );
+ void (GLAPIENTRYP TexCoord1fv)( const GLfloat * );
+ void (GLAPIENTRYP TexCoord2f)( GLfloat, GLfloat );
+ void (GLAPIENTRYP TexCoord2fv)( const GLfloat * );
+ void (GLAPIENTRYP TexCoord3f)( GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP TexCoord3fv)( const GLfloat * );
+ void (GLAPIENTRYP TexCoord4f)( GLfloat, GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP TexCoord4fv)( const GLfloat * );
+ void (GLAPIENTRYP Vertex2f)( GLfloat, GLfloat );
+ void (GLAPIENTRYP Vertex2fv)( const GLfloat * );
+ void (GLAPIENTRYP Vertex3f)( GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP Vertex3fv)( const GLfloat * );
+ void (GLAPIENTRYP Vertex4f)( GLfloat, GLfloat, GLfloat, GLfloat );
+ void (GLAPIENTRYP Vertex4fv)( const GLfloat * );
+ void (GLAPIENTRYP CallList)( GLuint ); /* NOTE */
+ void (GLAPIENTRYP CallLists)( GLsizei, GLenum, const GLvoid * ); /* NOTE */
+ void (GLAPIENTRYP Begin)( GLenum );
+ void (GLAPIENTRYP End)( void );
+ void (GLAPIENTRYP VertexAttrib1fNV)( GLuint index, GLfloat x );
+ void (GLAPIENTRYP VertexAttrib1fvNV)( GLuint index, const GLfloat *v );
+ void (GLAPIENTRYP VertexAttrib2fNV)( GLuint index, GLfloat x, GLfloat y );
+ void (GLAPIENTRYP VertexAttrib2fvNV)( GLuint index, const GLfloat *v );
+ void (GLAPIENTRYP VertexAttrib3fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z );
+ void (GLAPIENTRYP VertexAttrib3fvNV)( GLuint index, const GLfloat *v );
+ void (GLAPIENTRYP VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
+ void (GLAPIENTRYP VertexAttrib4fvNV)( GLuint index, const GLfloat *v );
+ void (GLAPIENTRYP VertexAttrib1fARB)( GLuint index, GLfloat x );
+ void (GLAPIENTRYP VertexAttrib1fvARB)( GLuint index, const GLfloat *v );
+ void (GLAPIENTRYP VertexAttrib2fARB)( GLuint index, GLfloat x, GLfloat y );
+ void (GLAPIENTRYP VertexAttrib2fvARB)( GLuint index, const GLfloat *v );
+ void (GLAPIENTRYP VertexAttrib3fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z );
+ void (GLAPIENTRYP VertexAttrib3fvARB)( GLuint index, const GLfloat *v );
+ void (GLAPIENTRYP VertexAttrib4fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w );
+ void (GLAPIENTRYP VertexAttrib4fvARB)( GLuint index, const GLfloat *v );
+ /*@}*/
+
+ /*
+ */
+ void (GLAPIENTRYP Rectf)( GLfloat, GLfloat, GLfloat, GLfloat );
+
+ /**
+ * \name Array
+ */
+ /*@{*/
+ void (GLAPIENTRYP DrawArrays)( GLenum mode, GLint start, GLsizei count );
+ void (GLAPIENTRYP DrawElements)( GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices );
+ void (GLAPIENTRYP DrawRangeElements)( GLenum mode, GLuint start,
+ GLuint end, GLsizei count,
+ GLenum type, const GLvoid *indices );
+ /*@}*/
+
+ /**
+ * \name Eval
+ *
+ * If you don't support eval, fallback to the default vertex format
+ * on receiving an eval call and use the pipeline mechanism to
+ * provide partial T&L acceleration.
+ *
+ * Mesa will provide a set of helper functions to do eval within
+ * accelerated vertex formats, eventually...
+ */
+ /*@{*/
+ void (GLAPIENTRYP EvalMesh1)( GLenum mode, GLint i1, GLint i2 );
+ void (GLAPIENTRYP EvalMesh2)( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 );
+ /*@}*/
+
+} GLvertexformat;
+
+
+#endif /* DD_INCLUDED */
diff --git a/nx-X11/extras/Mesa/src/mesa/main/debug.c b/nx-X11/extras/Mesa/src/mesa/main/debug.c
new file mode 100644
index 000000000..edc32b1f9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/debug.c
@@ -0,0 +1,218 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+#include "mtypes.h"
+#include "context.h"
+#include "imports.h"
+#include "debug.h"
+#include "get.h"
+
+/**
+ * Primitive names
+ */
+const char *_mesa_prim_name[GL_POLYGON+4] = {
+ "GL_POINTS",
+ "GL_LINES",
+ "GL_LINE_LOOP",
+ "GL_LINE_STRIP",
+ "GL_TRIANGLES",
+ "GL_TRIANGLE_STRIP",
+ "GL_TRIANGLE_FAN",
+ "GL_QUADS",
+ "GL_QUAD_STRIP",
+ "GL_POLYGON",
+ "outside begin/end",
+ "inside unkown primitive",
+ "unknown state"
+};
+
+void
+_mesa_print_state( const char *msg, GLuint state )
+{
+ _mesa_debug(NULL,
+ "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+ msg,
+ state,
+ (state & _NEW_MODELVIEW) ? "ctx->ModelView, " : "",
+ (state & _NEW_PROJECTION) ? "ctx->Projection, " : "",
+ (state & _NEW_TEXTURE_MATRIX) ? "ctx->TextureMatrix, " : "",
+ (state & _NEW_COLOR_MATRIX) ? "ctx->ColorMatrix, " : "",
+ (state & _NEW_ACCUM) ? "ctx->Accum, " : "",
+ (state & _NEW_COLOR) ? "ctx->Color, " : "",
+ (state & _NEW_DEPTH) ? "ctx->Depth, " : "",
+ (state & _NEW_EVAL) ? "ctx->Eval/EvalMap, " : "",
+ (state & _NEW_FOG) ? "ctx->Fog, " : "",
+ (state & _NEW_HINT) ? "ctx->Hint, " : "",
+ (state & _NEW_LIGHT) ? "ctx->Light, " : "",
+ (state & _NEW_LINE) ? "ctx->Line, " : "",
+ (state & _NEW_PIXEL) ? "ctx->Pixel, " : "",
+ (state & _NEW_POINT) ? "ctx->Point, " : "",
+ (state & _NEW_POLYGON) ? "ctx->Polygon, " : "",
+ (state & _NEW_POLYGONSTIPPLE) ? "ctx->PolygonStipple, " : "",
+ (state & _NEW_SCISSOR) ? "ctx->Scissor, " : "",
+ (state & _NEW_TEXTURE) ? "ctx->Texture, " : "",
+ (state & _NEW_TRANSFORM) ? "ctx->Transform, " : "",
+ (state & _NEW_VIEWPORT) ? "ctx->Viewport, " : "",
+ (state & _NEW_PACKUNPACK) ? "ctx->Pack/Unpack, " : "",
+ (state & _NEW_ARRAY) ? "ctx->Array, " : "",
+ (state & _NEW_RENDERMODE) ? "ctx->RenderMode, " : "",
+ (state & _NEW_BUFFERS) ? "ctx->Visual, ctx->DrawBuffer,, " : "");
+}
+
+
+
+void
+_mesa_print_tri_caps( const char *name, GLuint flags )
+{
+ _mesa_debug(NULL,
+ "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+ name,
+ flags,
+ (flags & DD_FLATSHADE) ? "flat-shade, " : "",
+ (flags & DD_SEPARATE_SPECULAR) ? "separate-specular, " : "",
+ (flags & DD_TRI_LIGHT_TWOSIDE) ? "tri-light-twoside, " : "",
+ (flags & DD_TRI_TWOSTENCIL) ? "tri-twostencil, " : "",
+ (flags & DD_TRI_UNFILLED) ? "tri-unfilled, " : "",
+ (flags & DD_TRI_STIPPLE) ? "tri-stipple, " : "",
+ (flags & DD_TRI_OFFSET) ? "tri-offset, " : "",
+ (flags & DD_TRI_SMOOTH) ? "tri-smooth, " : "",
+ (flags & DD_LINE_SMOOTH) ? "line-smooth, " : "",
+ (flags & DD_LINE_STIPPLE) ? "line-stipple, " : "",
+ (flags & DD_LINE_WIDTH) ? "line-wide, " : "",
+ (flags & DD_POINT_SMOOTH) ? "point-smooth, " : "",
+ (flags & DD_POINT_SIZE) ? "point-size, " : "",
+ (flags & DD_POINT_ATTEN) ? "point-atten, " : "",
+ (flags & DD_TRI_CULL_FRONT_BACK) ? "cull-all, " : ""
+ );
+}
+
+
+/**
+ * Print information about this Mesa version and build options.
+ */
+void _mesa_print_info( void )
+{
+ _mesa_debug(NULL, "Mesa GL_VERSION = %s\n",
+ (char *) _mesa_GetString(GL_VERSION));
+ _mesa_debug(NULL, "Mesa GL_RENDERER = %s\n",
+ (char *) _mesa_GetString(GL_RENDERER));
+ _mesa_debug(NULL, "Mesa GL_VENDOR = %s\n",
+ (char *) _mesa_GetString(GL_VENDOR));
+ _mesa_debug(NULL, "Mesa GL_EXTENSIONS = %s\n",
+ (char *) _mesa_GetString(GL_EXTENSIONS));
+#if defined(THREADS)
+ _mesa_debug(NULL, "Mesa thread-safe: YES\n");
+#else
+ _mesa_debug(NULL, "Mesa thread-safe: NO\n");
+#endif
+#if defined(USE_X86_ASM)
+ _mesa_debug(NULL, "Mesa x86-optimized: YES\n");
+#else
+ _mesa_debug(NULL, "Mesa x86-optimized: NO\n");
+#endif
+#if defined(USE_SPARC_ASM)
+ _mesa_debug(NULL, "Mesa sparc-optimized: YES\n");
+#else
+ _mesa_debug(NULL, "Mesa sparc-optimized: NO\n");
+#endif
+}
+
+
+/**
+ * Set the debugging flags.
+ *
+ * \param debug debug string
+ *
+ * If compiled with debugging support then search for keywords in \p debug and
+ * enables the verbose debug output of the respective feature.
+ */
+static void add_debug_flags( const char *debug )
+{
+#ifdef MESA_DEBUG
+ if (_mesa_strstr(debug, "varray"))
+ MESA_VERBOSE |= VERBOSE_VARRAY;
+
+ if (_mesa_strstr(debug, "tex"))
+ MESA_VERBOSE |= VERBOSE_TEXTURE;
+
+ if (_mesa_strstr(debug, "imm"))
+ MESA_VERBOSE |= VERBOSE_IMMEDIATE;
+
+ if (_mesa_strstr(debug, "pipe"))
+ MESA_VERBOSE |= VERBOSE_PIPELINE;
+
+ if (_mesa_strstr(debug, "driver"))
+ MESA_VERBOSE |= VERBOSE_DRIVER;
+
+ if (_mesa_strstr(debug, "state"))
+ MESA_VERBOSE |= VERBOSE_STATE;
+
+ if (_mesa_strstr(debug, "api"))
+ MESA_VERBOSE |= VERBOSE_API;
+
+ if (_mesa_strstr(debug, "list"))
+ MESA_VERBOSE |= VERBOSE_DISPLAY_LIST;
+
+ if (_mesa_strstr(debug, "lighting"))
+ MESA_VERBOSE |= VERBOSE_LIGHTING;
+
+ if (_mesa_strstr(debug, "disassem"))
+ MESA_VERBOSE |= VERBOSE_DISASSEM;
+
+ /* Debug flag:
+ */
+ if (_mesa_strstr(debug, "flush"))
+ MESA_DEBUG_FLAGS |= DEBUG_ALWAYS_FLUSH;
+#else
+ (void) debug;
+#endif
+}
+
+
+void
+_mesa_init_debug( GLcontext *ctx )
+{
+ char *c;
+
+ /* For debug/development only */
+ ctx->FirstTimeCurrent = GL_TRUE;
+
+ /* Dither disable */
+ ctx->NoDither = _mesa_getenv("MESA_NO_DITHER") ? GL_TRUE : GL_FALSE;
+ if (ctx->NoDither) {
+ if (_mesa_getenv("MESA_DEBUG")) {
+ _mesa_debug(ctx, "MESA_NO_DITHER set - dithering disabled\n");
+ }
+ ctx->Color.DitherFlag = GL_FALSE;
+ }
+
+ c = _mesa_getenv("MESA_DEBUG");
+ if (c)
+ add_debug_flags(c);
+
+ c = _mesa_getenv("MESA_VERBOSE");
+ if (c)
+ add_debug_flags(c);
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/main/debug.h b/nx-X11/extras/Mesa/src/mesa/main/debug.h
new file mode 100644
index 000000000..94d99c384
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/debug.h
@@ -0,0 +1,60 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file debug.h
+ * Debugging functions.
+ *
+ * \if subset
+ * (No-op)
+ *
+ * \endif
+ */
+
+
+#ifndef _DEBUG_H
+#define _DEBUG_H
+
+#if _HAVE_FULL_GL
+
+extern void _mesa_print_tri_caps( const char *name, GLuint flags );
+extern void _mesa_print_enable_flags( const char *msg, GLuint flags );
+extern void _mesa_print_state( const char *msg, GLuint state );
+extern void _mesa_print_info( void );
+extern void _mesa_init_debug( GLcontext *ctx );
+
+#else
+
+/** No-op */
+#define _mesa_print_state( m, s ) ((void)0)
+
+/** No-op */
+#define _mesa_print_info() ((void)0)
+
+/** No-op */
+#define _mesa_init_debug( c ) ((void)0)
+
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/depth.c b/nx-X11/extras/Mesa/src/mesa/main/depth.c
new file mode 100644
index 000000000..aca471a06
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/depth.c
@@ -0,0 +1,189 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "depth.h"
+#include "enums.h"
+#include "hash.h"
+#include "macros.h"
+#include "mtypes.h"
+
+
+/**********************************************************************/
+/***** API Functions *****/
+/**********************************************************************/
+
+
+
+void GLAPIENTRY
+_mesa_ClearDepth( GLclampd depth )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ depth = CLAMP( depth, 0.0, 1.0 );
+
+ if (ctx->Depth.Clear == depth)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_DEPTH);
+ ctx->Depth.Clear = depth;
+ if (ctx->Driver.ClearDepth)
+ (*ctx->Driver.ClearDepth)( ctx, ctx->Depth.Clear );
+}
+
+
+
+void GLAPIENTRY
+_mesa_DepthFunc( GLenum func )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
+ _mesa_debug(ctx, "glDepthFunc %s\n", _mesa_lookup_enum_by_nr(func));
+
+ switch (func) {
+ case GL_LESS: /* (default) pass if incoming z < stored z */
+ case GL_GEQUAL:
+ case GL_LEQUAL:
+ case GL_GREATER:
+ case GL_NOTEQUAL:
+ case GL_EQUAL:
+ case GL_ALWAYS:
+ case GL_NEVER:
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glDepth.Func" );
+ return;
+ }
+
+ if (ctx->Depth.Func == func)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_DEPTH);
+ ctx->Depth.Func = func;
+
+ if (ctx->Driver.DepthFunc)
+ ctx->Driver.DepthFunc( ctx, func );
+}
+
+
+
+void GLAPIENTRY
+_mesa_DepthMask( GLboolean flag )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
+ _mesa_debug(ctx, "glDepthMask %d\n", flag);
+
+ /*
+ * GL_TRUE indicates depth buffer writing is enabled (default)
+ * GL_FALSE indicates depth buffer writing is disabled
+ */
+ if (ctx->Depth.Mask == flag)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_DEPTH);
+ ctx->Depth.Mask = flag;
+
+ if (ctx->Driver.DepthMask)
+ ctx->Driver.DepthMask( ctx, flag );
+}
+
+
+
+/**
+ * Specified by the GL_EXT_depth_bounds_test extension.
+ */
+void GLAPIENTRY
+_mesa_DepthBoundsEXT( GLclampd zmin, GLclampd zmax )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (zmin > zmax) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glDepthBoundsEXT(zmin > zmax)");
+ return;
+ }
+
+ zmin = CLAMP(zmin, 0.0, 1.0);
+ zmax = CLAMP(zmax, 0.0, 1.0);
+
+ if (ctx->Depth.BoundsMin == zmin && ctx->Depth.BoundsMax == zmax)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_DEPTH);
+ ctx->Depth.BoundsMin = (GLfloat) zmin;
+ ctx->Depth.BoundsMax = (GLfloat) zmax;
+}
+
+
+/**********************************************************************/
+/***** Initialization *****/
+/**********************************************************************/
+
+
+/**
+ * Initialize the depth buffer attribute group in the given context.
+ */
+void _mesa_init_depth( GLcontext * ctx )
+{
+ /* Depth buffer group */
+ ctx->Depth.Test = GL_FALSE;
+ ctx->Depth.Clear = 1.0;
+ ctx->Depth.Func = GL_LESS;
+ ctx->Depth.Mask = GL_TRUE;
+ ctx->Depth.OcclusionTest = GL_FALSE;
+
+ /* XXX this is now per-framebuffer state */
+#if 00
+ /* Z buffer stuff */
+ if (ctx->Visual.depthBits == 0) {
+ /* Special case. Even if we don't have a depth buffer we need
+ * good values for DepthMax for Z vertex transformation purposes
+ * and for per-fragment fog computation.
+ */
+ ctx->DepthMax = (1 << 16) - 1;
+ ctx->DepthMaxF = (GLfloat) ctx->DepthMax;
+ }
+ else if (ctx->Visual.depthBits < 32) {
+ ctx->DepthMax = (1 << ctx->Visual.depthBits) - 1;
+ ctx->DepthMaxF = (GLfloat) ctx->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.
+ */
+ ctx->DepthMax = 0xffffffff;
+ ctx->DepthMaxF = (GLfloat) ctx->DepthMax;
+ }
+ ctx->MRD = 1.0; /* Minimum resolvable depth value, for polygon offset */
+#endif
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/depth.h b/nx-X11/extras/Mesa/src/mesa/main/depth.h
new file mode 100644
index 000000000..dcc0b4637
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/depth.h
@@ -0,0 +1,62 @@
+/**
+ * \file depth.h
+ * Depth buffer operations.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef DEPTH_H
+#define DEPTH_H
+
+
+#include "mtypes.h"
+
+
+#if _HAVE_FULL_GL
+
+extern void GLAPIENTRY
+_mesa_ClearDepth( GLclampd depth );
+
+extern void GLAPIENTRY
+_mesa_DepthFunc( GLenum func );
+
+extern void GLAPIENTRY
+_mesa_DepthMask( GLboolean flag );
+
+extern void GLAPIENTRY
+_mesa_DepthBoundsEXT( GLclampd zmin, GLclampd zmax );
+
+extern void
+_mesa_init_depth( GLcontext * ctx );
+
+#else
+
+/** No-op */
+#define _mesa_init_depth( c ) ((void)0)
+
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/descrip.mms b/nx-X11/extras/Mesa/src/mesa/main/descrip.mms
new file mode 100644
index 000000000..ce298229c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/descrip.mms
@@ -0,0 +1,210 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+# Last revision : 10 May 2005
+
+.first
+ define gl [---.include.gl]
+ define math [-.math]
+ define shader [-.shader]
+
+.include [---]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [---.include],[-.glapi],[-.shader]
+LIBDIR = [---.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)
+
+SOURCES =accum.c \
+ api_arrayelt.c \
+ api_loopback.c \
+ api_noop.c \
+ api_validate.c \
+ attrib.c \
+ blend.c \
+ bufferobj.c \
+ buffers.c \
+ clip.c \
+ colortab.c \
+ context.c \
+ convolve.c \
+ debug.c \
+ depth.c \
+ dispatch.c \
+ dlist.c \
+ drawpix.c \
+ enable.c \
+ enums.c \
+ eval.c \
+ execmem.c \
+ extensions.c \
+ fbobject.c \
+ feedback.c \
+ fog.c \
+ framebuffer.c \
+ get.c \
+ getstring.c \
+ hash.c \
+ hint.c \
+ histogram.c \
+ image.c \
+ imports.c \
+ light.c \
+ lines.c \
+ matrix.c \
+ mm.c \
+ occlude.c \
+ pixel.c \
+ points.c \
+ polygon.c \
+ rastpos.c \
+ renderbuffer.c \
+ state.c \
+ stencil.c \
+ texcompress.c \
+ texcompress_fxt1.c \
+ texcompress_s3tc.c \
+ texenvprogram.c \
+ texformat.c \
+ teximage.c \
+ texobj.c \
+ texrender.c \
+ texstate.c \
+ texstore.c \
+ varray.c \
+ vtxfmt.c
+
+OBJECTS=accum.obj,\
+api_arrayelt.obj,\
+api_loopback.obj,\
+api_noop.obj,\
+api_validate.obj,\
+attrib.obj,\
+blend.obj,\
+bufferobj.obj,\
+buffers.obj,\
+clip.obj,\
+colortab.obj,\
+context.obj,\
+convolve.obj,\
+debug.obj,\
+depth.obj,\
+dispatch.obj,\
+dlist.obj,\
+drawpix.obj,\
+enable.obj,\
+enums.obj,\
+eval.obj,\
+execmem.obj,\
+extensions.obj,\
+fbobject.obj,\
+feedback.obj,\
+fog.obj,\
+framebuffer.obj,\
+get.obj,\
+getstring.obj,\
+hash.obj,\
+hint.obj,\
+histogram.obj,\
+image.obj,\
+imports.obj,\
+light.obj,\
+lines.obj,\
+matrix.obj,\
+mm.obj,\
+occlude.obj,\
+pixel.obj,\
+points.obj,\
+polygon.obj,\
+rastpos.obj,\
+renderbuffer.obj,\
+state.obj,\
+stencil.obj,\
+texcompress.obj,\
+texcompress_fxt1.obj,\
+texcompress_s3tc.obj,\
+texenvprogram.obj,\
+texformat.obj,\
+teximage.obj,\
+texobj.obj,\
+texrender.obj,\
+texstate.obj,\
+texstore.obj,\
+varray.obj,\
+vtxfmt.obj
+
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+ @ $(MAKELIB) $(GL_LIB) $(OBJECTS)
+ @ rename $(GL_LIB)* $(LIBDIR)
+
+clean :
+ purge
+ delete *.obj;*
+
+accum.obj : accum.c
+api_arrayelt.obj : api_arrayelt.c
+api_loopback.obj : api_loopback.c
+api_noop.obj : api_noop.c
+api_validate.obj : api_validate.c
+attrib.obj : attrib.c
+blend.obj : blend.c
+bufferobj.obj : bufferobj.c
+buffers.obj : buffers.c
+clip.obj : clip.c
+colortab.obj : colortab.c
+context.obj : context.c
+convolve.obj : convolve.c
+debug.obj : debug.c
+depth.obj : depth.c
+dispatch.obj : dispatch.c
+dlist.obj : dlist.c
+drawpix.obj : drawpix.c
+enable.obj : enable.c
+enums.obj : enums.c
+eval.obj : eval.c
+execmem.obj : execmem.c
+extensions.obj : extensions.c
+fbobject.obj : fbobject.c
+feedback.obj : feedback.c
+fog.obj : fog.c
+framebuffer.obj : framebuffer.c
+get.obj : get.c
+getstring.obj : getstring.c
+hash.obj : hash.c
+hint.obj : hint.c
+histogram.obj : histogram.c
+image.obj : image.c
+imports.obj : imports.c vsnprintf.c
+light.obj : light.c
+lines.obj : lines.c
+matrix.obj : matrix.c
+mm.obj: mm.c
+occlude.obj : occlude.c
+pixel.obj : pixel.c
+points.obj : points.c
+polygon.obj : polygon.c
+rastpos.obj : rastpos.c
+renderbuffer.obj : renderbuffer.c
+state.obj : state.c
+stencil.obj : stencil.c
+texcompress.obj : texcompress.c
+texcompress_fxt1.obj : texcompress_fxt1.c
+ cc$(CFLAGS)/warn=(disable=SHIFTCOUNT) texcompress_fxt1.c
+texcompress_s3tc.obj : texcompress_s3tc.c
+texenvprogram.obj : texenvprogram.c
+texformat.obj : texformat.c
+teximage.obj : teximage.c
+texobj.obj : texobj.c
+texrender.obj : texrender.c
+texstate.obj : texstate.c
+texstore.obj : texstore.c
+varray.obj : varray.c
+vtxfmt.obj : vtxfmt.c
diff --git a/nx-X11/extras/Mesa/src/mesa/main/dispatch.c b/nx-X11/extras/Mesa/src/mesa/main/dispatch.c
new file mode 100644
index 000000000..05c1c36c0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/dispatch.c
@@ -0,0 +1,95 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file dispatch.c
+ *
+ * This file generates all the gl* function entrypoints. This code is not
+ * used if optimized assembly stubs are available (e.g., using x86/glapi_x86.S
+ * on IA32 or sparc/glapi_sparc.S on SPARC).
+ *
+ * \note
+ * This file is also used to build the client-side libGL that loads DRI-based
+ * device drivers. At build-time it is symlinked to src/glx/x11.
+ *
+ * \author Brian Paul <brian@precisioninsight.com>
+ */
+
+#ifndef GLX_USE_APPLEGL
+
+#include "glheader.h"
+#include "glapi.h"
+#include "glapitable.h"
+#include "glthread.h"
+
+
+#if !(defined(USE_X86_ASM) || defined(USE_X86_64_ASM) || defined(USE_SPARC_ASM))
+
+#if defined(WIN32)
+#define KEYWORD1 GLAPI
+#else
+#define KEYWORD1 PUBLIC
+#endif
+
+#define KEYWORD2 GLAPIENTRY
+
+#if defined(USE_MGL_NAMESPACE)
+#define NAME(func) mgl##func
+#else
+#define NAME(func) gl##func
+#endif
+
+#if 0 /* Use this to log GL calls to stdout (for DEBUG only!) */
+
+#define F stdout
+#define DISPATCH(FUNC, ARGS, MESSAGE) \
+ fprintf MESSAGE; \
+ CALL_ ## FUNC(GET_DISPATCH(), ARGS);
+
+#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
+ fprintf MESSAGE; \
+ return CALL_ ## FUNC(GET_DISPATCH(), ARGS);
+
+#else
+
+#define DISPATCH(FUNC, ARGS, MESSAGE) \
+ CALL_ ## FUNC(GET_DISPATCH(), ARGS);
+
+#define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) \
+ return CALL_ ## FUNC(GET_DISPATCH(), ARGS);
+
+#endif /* logging */
+
+
+#ifndef GLAPIENTRY
+#define GLAPIENTRY
+#endif
+
+#include "dispatch.h"
+#include "glapitemp.h"
+
+#endif /* USE_X86_ASM */
+
+#endif /* !GLX_USE_APPLEGL */
diff --git a/nx-X11/extras/Mesa/src/mesa/main/dlist.c b/nx-X11/extras/Mesa/src/mesa/main/dlist.c
new file mode 100644
index 000000000..7bd11c31a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/dlist.c
@@ -0,0 +1,8434 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file dlist.c
+ * Display lists management functions.
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "api_arrayelt.h"
+#include "api_loopback.h"
+#include "config.h"
+#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
+#include "arbprogram.h"
+#include "program.h"
+#endif
+#include "attrib.h"
+#include "blend.h"
+#include "buffers.h"
+#if FEATURE_ARB_vertex_buffer_object
+#include "bufferobj.h"
+#endif
+#include "clip.h"
+#include "colormac.h"
+#include "colortab.h"
+#include "context.h"
+#include "convolve.h"
+#include "depth.h"
+#include "dlist.h"
+#include "enable.h"
+#include "enums.h"
+#include "eval.h"
+#include "extensions.h"
+#include "feedback.h"
+#include "get.h"
+#include "glapi.h"
+#include "hash.h"
+#include "histogram.h"
+#include "image.h"
+#include "light.h"
+#include "lines.h"
+#include "dlist.h"
+#include "macros.h"
+#include "matrix.h"
+#include "occlude.h"
+#include "pixel.h"
+#include "points.h"
+#include "polygon.h"
+#include "state.h"
+#include "texobj.h"
+#include "teximage.h"
+#include "texstate.h"
+#include "mtypes.h"
+#include "varray.h"
+#if FEATURE_NV_vertex_program || FEATURE_NV_fragment_program
+#include "nvprogram.h"
+#include "program.h"
+#endif
+#if FEATURE_ATI_fragment_shader
+#include "atifragshader.h"
+#endif
+
+#include "math/m_matrix.h"
+#include "math/m_xform.h"
+
+#include "dispatch.h"
+
+
+/**
+ * Flush vertices.
+ *
+ * \param ctx GL context.
+ *
+ * Checks if dd_function_table::SaveNeedFlush is marked to flush
+ * stored (save) vertices, and calls
+ * dd_function_table::SaveFlushVertices if so.
+ */
+#define SAVE_FLUSH_VERTICES(ctx) \
+do { \
+ if (ctx->Driver.SaveNeedFlush) \
+ ctx->Driver.SaveFlushVertices(ctx); \
+} while (0)
+
+
+/**
+ * Macro to assert that the API call was made outside the
+ * glBegin()/glEnd() pair, with return value.
+ *
+ * \param ctx GL context.
+ * \param retval value to return value in case the assertion fails.
+ */
+#define ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval) \
+do { \
+ if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \
+ ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \
+ _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
+ return retval; \
+ } \
+} while (0)
+
+/**
+ * Macro to assert that the API call was made outside the
+ * glBegin()/glEnd() pair.
+ *
+ * \param ctx GL context.
+ */
+#define ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx) \
+do { \
+ if (ctx->Driver.CurrentSavePrimitive <= GL_POLYGON || \
+ ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM) { \
+ _mesa_compile_error( ctx, GL_INVALID_OPERATION, "begin/end" ); \
+ return; \
+ } \
+} while (0)
+
+/**
+ * Macro to assert that the API call was made outside the
+ * glBegin()/glEnd() pair and flush the vertices.
+ *
+ * \param ctx GL context.
+ */
+#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx) \
+do { \
+ ASSERT_OUTSIDE_SAVE_BEGIN_END(ctx); \
+ SAVE_FLUSH_VERTICES(ctx); \
+} while (0)
+
+/**
+ * Macro to assert that the API call was made outside the
+ * glBegin()/glEnd() pair and flush the vertices, with return value.
+ *
+ * \param ctx GL context.
+ * \param retval value to return value in case the assertion fails.
+ */
+#define ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH_WITH_RETVAL(ctx, retval)\
+do { \
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_WITH_RETVAL(ctx, retval); \
+ SAVE_FLUSH_VERTICES(ctx); \
+} while (0)
+
+
+
+/**
+ * Display list opcodes.
+ *
+ * The fact that these identifiers are assigned consecutive
+ * integer values starting at 0 is very important, see InstSize array usage)
+ */
+typedef enum {
+ OPCODE_INVALID = -1, /* Force signed enum */
+ OPCODE_ACCUM,
+ OPCODE_ALPHA_FUNC,
+ OPCODE_BIND_TEXTURE,
+ OPCODE_BITMAP,
+ OPCODE_BLEND_COLOR,
+ OPCODE_BLEND_EQUATION,
+ OPCODE_BLEND_EQUATION_SEPARATE,
+ OPCODE_BLEND_FUNC_SEPARATE,
+ OPCODE_CALL_LIST,
+ OPCODE_CALL_LIST_OFFSET,
+ OPCODE_CLEAR,
+ OPCODE_CLEAR_ACCUM,
+ OPCODE_CLEAR_COLOR,
+ OPCODE_CLEAR_DEPTH,
+ OPCODE_CLEAR_INDEX,
+ OPCODE_CLEAR_STENCIL,
+ OPCODE_CLIP_PLANE,
+ 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,
+ OPCODE_COPY_TEX_SUB_IMAGE1D,
+ OPCODE_COPY_TEX_SUB_IMAGE2D,
+ OPCODE_COPY_TEX_SUB_IMAGE3D,
+ OPCODE_CULL_FACE,
+ OPCODE_DEPTH_FUNC,
+ OPCODE_DEPTH_MASK,
+ OPCODE_DEPTH_RANGE,
+ OPCODE_DISABLE,
+ OPCODE_DRAW_BUFFER,
+ OPCODE_DRAW_PIXELS,
+ OPCODE_ENABLE,
+ OPCODE_EVALMESH1,
+ OPCODE_EVALMESH2,
+ OPCODE_FOG,
+ OPCODE_FRONT_FACE,
+ OPCODE_FRUSTUM,
+ OPCODE_HINT,
+ OPCODE_HISTOGRAM,
+ OPCODE_INDEX_MASK,
+ OPCODE_INIT_NAMES,
+ OPCODE_LIGHT,
+ OPCODE_LIGHT_MODEL,
+ OPCODE_LINE_STIPPLE,
+ OPCODE_LINE_WIDTH,
+ OPCODE_LIST_BASE,
+ OPCODE_LOAD_IDENTITY,
+ OPCODE_LOAD_MATRIX,
+ OPCODE_LOAD_NAME,
+ OPCODE_LOGIC_OP,
+ OPCODE_MAP1,
+ OPCODE_MAP2,
+ OPCODE_MAPGRID1,
+ OPCODE_MAPGRID2,
+ OPCODE_MATRIX_MODE,
+ OPCODE_MIN_MAX,
+ OPCODE_MULT_MATRIX,
+ OPCODE_ORTHO,
+ OPCODE_PASSTHROUGH,
+ OPCODE_PIXEL_MAP,
+ OPCODE_PIXEL_TRANSFER,
+ OPCODE_PIXEL_ZOOM,
+ OPCODE_POINT_SIZE,
+ OPCODE_POINT_PARAMETERS,
+ OPCODE_POLYGON_MODE,
+ OPCODE_POLYGON_STIPPLE,
+ OPCODE_POLYGON_OFFSET,
+ OPCODE_POP_ATTRIB,
+ OPCODE_POP_MATRIX,
+ OPCODE_POP_NAME,
+ OPCODE_PRIORITIZE_TEXTURE,
+ OPCODE_PUSH_ATTRIB,
+ OPCODE_PUSH_MATRIX,
+ OPCODE_PUSH_NAME,
+ OPCODE_RASTER_POS,
+ OPCODE_READ_BUFFER,
+ OPCODE_RESET_HISTOGRAM,
+ OPCODE_RESET_MIN_MAX,
+ OPCODE_ROTATE,
+ OPCODE_SCALE,
+ OPCODE_SCISSOR,
+ OPCODE_SELECT_TEXTURE_SGIS,
+ OPCODE_SELECT_TEXTURE_COORD_SET,
+ OPCODE_SHADE_MODEL,
+ OPCODE_STENCIL_FUNC,
+ OPCODE_STENCIL_MASK,
+ OPCODE_STENCIL_OP,
+ OPCODE_TEXENV,
+ OPCODE_TEXGEN,
+ OPCODE_TEXPARAMETER,
+ OPCODE_TEX_IMAGE1D,
+ OPCODE_TEX_IMAGE2D,
+ OPCODE_TEX_IMAGE3D,
+ OPCODE_TEX_SUB_IMAGE1D,
+ OPCODE_TEX_SUB_IMAGE2D,
+ OPCODE_TEX_SUB_IMAGE3D,
+ OPCODE_TRANSLATE,
+ OPCODE_VIEWPORT,
+ OPCODE_WINDOW_POS,
+ /* GL_ARB_multitexture */
+ OPCODE_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,
+ /* GL_ARB_multisample */
+ OPCODE_SAMPLE_COVERAGE,
+ /* GL_ARB_window_pos */
+ OPCODE_WINDOW_POS_ARB,
+ /* GL_NV_vertex_program */
+ OPCODE_BIND_PROGRAM_NV,
+ OPCODE_EXECUTE_PROGRAM_NV,
+ OPCODE_REQUEST_RESIDENT_PROGRAMS_NV,
+ OPCODE_LOAD_PROGRAM_NV,
+ OPCODE_PROGRAM_PARAMETER4F_NV,
+ OPCODE_TRACK_MATRIX_NV,
+ /* GL_NV_fragment_program */
+ OPCODE_PROGRAM_LOCAL_PARAMETER_ARB,
+ OPCODE_PROGRAM_NAMED_PARAMETER_NV,
+ /* GL_EXT_stencil_two_side */
+ OPCODE_ACTIVE_STENCIL_FACE_EXT,
+ /* GL_EXT_depth_bounds_test */
+ OPCODE_DEPTH_BOUNDS_EXT,
+ /* GL_ARB_vertex/fragment_program */
+ OPCODE_PROGRAM_STRING_ARB,
+ OPCODE_PROGRAM_ENV_PARAMETER_ARB,
+ /* GL_ARB_occlusion_query */
+ OPCODE_BEGIN_QUERY_ARB,
+ OPCODE_END_QUERY_ARB,
+ /* GL_ARB_draw_buffers */
+ OPCODE_DRAW_BUFFERS_ARB,
+ /* GL_ATI_fragment_shader */
+ OPCODE_BIND_FRAGMENT_SHADER_ATI,
+ OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI,
+ /* OpenGL 2.0 */
+ OPCODE_STENCIL_FUNC_SEPARATE,
+ OPCODE_STENCIL_OP_SEPARATE,
+ OPCODE_STENCIL_MASK_SEPARATE,
+
+ /* Vertex attributes -- fallback for when optimized display
+ * list build isn't active.
+ */
+ OPCODE_ATTR_1F_NV,
+ OPCODE_ATTR_2F_NV,
+ OPCODE_ATTR_3F_NV,
+ OPCODE_ATTR_4F_NV,
+ OPCODE_ATTR_1F_ARB,
+ OPCODE_ATTR_2F_ARB,
+ OPCODE_ATTR_3F_ARB,
+ OPCODE_ATTR_4F_ARB,
+ OPCODE_MATERIAL,
+ OPCODE_INDEX,
+ OPCODE_EDGEFLAG,
+ OPCODE_BEGIN,
+ OPCODE_END,
+ OPCODE_RECTF,
+ OPCODE_EVAL_C1,
+ OPCODE_EVAL_C2,
+ OPCODE_EVAL_P1,
+ OPCODE_EVAL_P2,
+
+
+ /* The following three are meta instructions */
+ OPCODE_ERROR, /* raise compiled-in error */
+ OPCODE_CONTINUE,
+ OPCODE_END_OF_LIST,
+ OPCODE_EXT_0
+} OpCode;
+
+
+
+/**
+ * Display list node.
+ *
+ * Display list instructions are stored as sequences of "nodes". Nodes
+ * are allocated in blocks. Each block has BLOCK_SIZE nodes. Blocks
+ * are linked together with a pointer.
+ *
+ * Each instruction in the display list is stored as a sequence of
+ * contiguous nodes in memory.
+ * Each node is the union of a variety of data types.
+ */
+union node {
+ OpCode opcode;
+ GLboolean b;
+ GLbitfield bf;
+ GLubyte ub;
+ GLshort s;
+ GLushort us;
+ GLint i;
+ GLuint ui;
+ GLenum e;
+ GLfloat f;
+ GLvoid *data;
+ void *next; /* If prev node's opcode==OPCODE_CONTINUE */
+};
+
+
+/**
+ * How many nodes to allocate at a time.
+ *
+ * \note Reduced now that we hold vertices etc. elsewhere.
+ */
+#define BLOCK_SIZE 256
+
+
+
+/**
+ * Number of nodes of storage needed for each instruction.
+ * Sizes for dynamically allocated opcodes are stored in the context struct.
+ */
+static GLuint InstSize[ OPCODE_END_OF_LIST+1 ];
+
+void mesa_print_display_list( GLuint list );
+
+
+/**********************************************************************/
+/***** Private *****/
+/**********************************************************************/
+
+/*
+ * Make an empty display list. This is used by glGenLists() to
+ * reserver display list IDs.
+ */
+static struct mesa_display_list *make_list( GLuint list, GLuint count )
+{
+ struct mesa_display_list *dlist = CALLOC_STRUCT( mesa_display_list );
+ dlist->id = list;
+ dlist->node = (Node *) MALLOC( sizeof(Node) * count );
+ dlist->node[0].opcode = OPCODE_END_OF_LIST;
+ return dlist;
+}
+
+
+
+/*
+ * Destroy all nodes in a display list.
+ * \param list - display list number
+ */
+void _mesa_destroy_list( GLcontext *ctx, GLuint list )
+{
+ struct mesa_display_list *dlist;
+ Node *n, *block;
+ GLboolean done;
+
+ if (list==0)
+ return;
+
+ dlist = (struct mesa_display_list *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
+ if (!dlist)
+ return;
+
+ n = block = dlist->node;
+
+ done = block ? GL_FALSE : GL_TRUE;
+ while (!done) {
+
+ /* check for extension opcodes first */
+
+ GLint i = (GLint) n[0].opcode - (GLint) OPCODE_EXT_0;
+ if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
+ ctx->ListExt.Opcode[i].Destroy(ctx, &n[1]);
+ n += ctx->ListExt.Opcode[i].Size;
+ }
+ else {
+ switch (n[0].opcode) {
+ /* for some commands, we need to free malloc'd memory */
+ case OPCODE_MAP1:
+ FREE(n[6].data);
+ n += InstSize[n[0].opcode];
+ break;
+ case OPCODE_MAP2:
+ FREE(n[10].data);
+ n += InstSize[n[0].opcode];
+ break;
+ case OPCODE_DRAW_PIXELS:
+ FREE( n[5].data );
+ n += InstSize[n[0].opcode];
+ break;
+ case OPCODE_BITMAP:
+ FREE( n[7].data );
+ n += InstSize[n[0].opcode];
+ break;
+ case OPCODE_COLOR_TABLE:
+ FREE( n[6].data );
+ n += InstSize[n[0].opcode];
+ break;
+ case OPCODE_COLOR_SUB_TABLE:
+ 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];
+ break;
+ case OPCODE_TEX_IMAGE1D:
+ FREE(n[8].data);
+ n += InstSize[n[0].opcode];
+ break;
+ case OPCODE_TEX_IMAGE2D:
+ FREE( n[9]. data );
+ n += InstSize[n[0].opcode];
+ break;
+ case OPCODE_TEX_IMAGE3D:
+ FREE( n[10]. data );
+ n += InstSize[n[0].opcode];
+ break;
+ case OPCODE_TEX_SUB_IMAGE1D:
+ FREE(n[7].data);
+ n += InstSize[n[0].opcode];
+ break;
+ case OPCODE_TEX_SUB_IMAGE2D:
+ FREE(n[9].data);
+ n += InstSize[n[0].opcode];
+ break;
+ case OPCODE_TEX_SUB_IMAGE3D:
+ 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;
+#if FEATURE_NV_vertex_program
+ case OPCODE_LOAD_PROGRAM_NV:
+ FREE(n[4].data); /* program string */
+ n += InstSize[n[0].opcode];
+ break;
+ case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV:
+ FREE(n[2].data); /* array of program ids */
+ n += InstSize[n[0].opcode];
+ break;
+#endif
+#if FEATURE_NV_fragment_program
+ case OPCODE_PROGRAM_NAMED_PARAMETER_NV:
+ FREE(n[3].data); /* parameter name */
+ n += InstSize[n[0].opcode];
+ break;
+#endif
+#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
+ case OPCODE_PROGRAM_STRING_ARB:
+ FREE(n[4].data); /* program string */
+ n += InstSize[n[0].opcode];
+ break;
+#endif
+ case OPCODE_CONTINUE:
+ n = (Node *) n[1].next;
+ FREE( block );
+ block = n;
+ break;
+ case OPCODE_END_OF_LIST:
+ FREE( block );
+ done = GL_TRUE;
+ break;
+ default:
+ /* Most frequent case */
+ n += InstSize[n[0].opcode];
+ break;
+ }
+ }
+ }
+
+ FREE( dlist );
+ _mesa_HashRemove(ctx->Shared->DisplayList, list);
+}
+
+
+
+/*
+ * Translate the nth element of list from type to GLuint.
+ */
+static GLuint translate_id( GLsizei n, GLenum type, const GLvoid *list )
+{
+ GLbyte *bptr;
+ GLubyte *ubptr;
+ GLshort *sptr;
+ GLushort *usptr;
+ GLint *iptr;
+ GLuint *uiptr;
+ GLfloat *fptr;
+
+ switch (type) {
+ case GL_BYTE:
+ bptr = (GLbyte *) list;
+ return (GLuint) *(bptr+n);
+ case GL_UNSIGNED_BYTE:
+ ubptr = (GLubyte *) list;
+ return (GLuint) *(ubptr+n);
+ case GL_SHORT:
+ sptr = (GLshort *) list;
+ return (GLuint) *(sptr+n);
+ case GL_UNSIGNED_SHORT:
+ usptr = (GLushort *) list;
+ return (GLuint) *(usptr+n);
+ case GL_INT:
+ iptr = (GLint *) list;
+ return (GLuint) *(iptr+n);
+ case GL_UNSIGNED_INT:
+ uiptr = (GLuint *) list;
+ return (GLuint) *(uiptr+n);
+ case GL_FLOAT:
+ fptr = (GLfloat *) list;
+ return (GLuint) *(fptr+n);
+ case GL_2_BYTES:
+ ubptr = ((GLubyte *) list) + 2*n;
+ return (GLuint) *ubptr * 256 + (GLuint) *(ubptr+1);
+ case GL_3_BYTES:
+ ubptr = ((GLubyte *) list) + 3*n;
+ return (GLuint) *ubptr * 65536
+ + (GLuint) *(ubptr+1) * 256
+ + (GLuint) *(ubptr+2);
+ case GL_4_BYTES:
+ ubptr = ((GLubyte *) list) + 4*n;
+ return (GLuint) *ubptr * 16777216
+ + (GLuint) *(ubptr+1) * 65536
+ + (GLuint) *(ubptr+2) * 256
+ + (GLuint) *(ubptr+3);
+ default:
+ return 0;
+ }
+}
+
+
+
+
+/**********************************************************************/
+/***** Public *****/
+/**********************************************************************/
+
+/**
+ * Do one-time initialiazations for display lists.
+ */
+void
+_mesa_init_lists( void )
+{
+ static int init_flag = 0;
+
+ if (init_flag==0) {
+ InstSize[OPCODE_ACCUM] = 3;
+ InstSize[OPCODE_ALPHA_FUNC] = 3;
+ InstSize[OPCODE_BIND_TEXTURE] = 3;
+ InstSize[OPCODE_BITMAP] = 8;
+ InstSize[OPCODE_BLEND_COLOR] = 5;
+ InstSize[OPCODE_BLEND_EQUATION] = 2;
+ InstSize[OPCODE_BLEND_EQUATION_SEPARATE] = 3;
+ InstSize[OPCODE_BLEND_FUNC_SEPARATE] = 5;
+ InstSize[OPCODE_CALL_LIST] = 2;
+ InstSize[OPCODE_CALL_LIST_OFFSET] = 3;
+ InstSize[OPCODE_CLEAR] = 2;
+ InstSize[OPCODE_CLEAR_ACCUM] = 5;
+ InstSize[OPCODE_CLEAR_COLOR] = 5;
+ InstSize[OPCODE_CLEAR_DEPTH] = 2;
+ InstSize[OPCODE_CLEAR_INDEX] = 2;
+ InstSize[OPCODE_CLEAR_STENCIL] = 2;
+ InstSize[OPCODE_CLIP_PLANE] = 6;
+ 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;
+ InstSize[OPCODE_COPY_TEX_SUB_IMAGE2D] = 9;
+ InstSize[OPCODE_COPY_TEX_SUB_IMAGE3D] = 10;
+ InstSize[OPCODE_CULL_FACE] = 2;
+ InstSize[OPCODE_DEPTH_FUNC] = 2;
+ InstSize[OPCODE_DEPTH_MASK] = 2;
+ InstSize[OPCODE_DEPTH_RANGE] = 3;
+ InstSize[OPCODE_DISABLE] = 2;
+ InstSize[OPCODE_DRAW_BUFFER] = 2;
+ InstSize[OPCODE_DRAW_PIXELS] = 6;
+ InstSize[OPCODE_ENABLE] = 2;
+ InstSize[OPCODE_EVALMESH1] = 4;
+ InstSize[OPCODE_EVALMESH2] = 6;
+ InstSize[OPCODE_FOG] = 6;
+ InstSize[OPCODE_FRONT_FACE] = 2;
+ InstSize[OPCODE_FRUSTUM] = 7;
+ InstSize[OPCODE_HINT] = 3;
+ InstSize[OPCODE_HISTOGRAM] = 5;
+ InstSize[OPCODE_INDEX_MASK] = 2;
+ InstSize[OPCODE_INIT_NAMES] = 1;
+ InstSize[OPCODE_LIGHT] = 7;
+ InstSize[OPCODE_LIGHT_MODEL] = 6;
+ InstSize[OPCODE_LINE_STIPPLE] = 3;
+ InstSize[OPCODE_LINE_WIDTH] = 2;
+ InstSize[OPCODE_LIST_BASE] = 2;
+ InstSize[OPCODE_LOAD_IDENTITY] = 1;
+ InstSize[OPCODE_LOAD_MATRIX] = 17;
+ InstSize[OPCODE_LOAD_NAME] = 2;
+ InstSize[OPCODE_LOGIC_OP] = 2;
+ InstSize[OPCODE_MAP1] = 7;
+ InstSize[OPCODE_MAP2] = 11;
+ 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;
+ InstSize[OPCODE_PIXEL_MAP] = 4;
+ InstSize[OPCODE_PIXEL_TRANSFER] = 3;
+ InstSize[OPCODE_PIXEL_ZOOM] = 3;
+ InstSize[OPCODE_POINT_SIZE] = 2;
+ InstSize[OPCODE_POINT_PARAMETERS] = 5;
+ InstSize[OPCODE_POLYGON_MODE] = 3;
+ InstSize[OPCODE_POLYGON_STIPPLE] = 2;
+ InstSize[OPCODE_POLYGON_OFFSET] = 3;
+ InstSize[OPCODE_POP_ATTRIB] = 1;
+ InstSize[OPCODE_POP_MATRIX] = 1;
+ InstSize[OPCODE_POP_NAME] = 1;
+ InstSize[OPCODE_PRIORITIZE_TEXTURE] = 3;
+ InstSize[OPCODE_PUSH_ATTRIB] = 2;
+ InstSize[OPCODE_PUSH_MATRIX] = 1;
+ InstSize[OPCODE_PUSH_NAME] = 2;
+ InstSize[OPCODE_RASTER_POS] = 5;
+ InstSize[OPCODE_READ_BUFFER] = 2;
+ InstSize[OPCODE_RESET_HISTOGRAM] = 2;
+ InstSize[OPCODE_RESET_MIN_MAX] = 2;
+ InstSize[OPCODE_ROTATE] = 5;
+ InstSize[OPCODE_SCALE] = 4;
+ InstSize[OPCODE_SCISSOR] = 5;
+ InstSize[OPCODE_STENCIL_FUNC] = 4;
+ InstSize[OPCODE_STENCIL_MASK] = 2;
+ InstSize[OPCODE_STENCIL_OP] = 4;
+ InstSize[OPCODE_SHADE_MODEL] = 2;
+ InstSize[OPCODE_TEXENV] = 7;
+ InstSize[OPCODE_TEXGEN] = 7;
+ InstSize[OPCODE_TEXPARAMETER] = 7;
+ InstSize[OPCODE_TEX_IMAGE1D] = 9;
+ InstSize[OPCODE_TEX_IMAGE2D] = 10;
+ InstSize[OPCODE_TEX_IMAGE3D] = 11;
+ InstSize[OPCODE_TEX_SUB_IMAGE1D] = 8;
+ InstSize[OPCODE_TEX_SUB_IMAGE2D] = 10;
+ InstSize[OPCODE_TEX_SUB_IMAGE3D] = 12;
+ InstSize[OPCODE_TRANSLATE] = 4;
+ InstSize[OPCODE_VIEWPORT] = 5;
+ InstSize[OPCODE_WINDOW_POS] = 5;
+ InstSize[OPCODE_CONTINUE] = 2;
+ InstSize[OPCODE_ERROR] = 3;
+ 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_multisample */
+ InstSize[OPCODE_SAMPLE_COVERAGE] = 3;
+ /* GL_ARB_multitexture */
+ InstSize[OPCODE_ACTIVE_TEXTURE] = 2;
+ /* GL_ARB_window_pos */
+ InstSize[OPCODE_WINDOW_POS_ARB] = 4;
+ /* GL_NV_vertex_program */
+ InstSize[OPCODE_BIND_PROGRAM_NV] = 3;
+ InstSize[OPCODE_EXECUTE_PROGRAM_NV] = 7;
+ InstSize[OPCODE_REQUEST_RESIDENT_PROGRAMS_NV] = 2;
+ InstSize[OPCODE_LOAD_PROGRAM_NV] = 5;
+ InstSize[OPCODE_PROGRAM_PARAMETER4F_NV] = 7;
+ InstSize[OPCODE_TRACK_MATRIX_NV] = 5;
+ /* GL_NV_fragment_program */
+ InstSize[OPCODE_PROGRAM_LOCAL_PARAMETER_ARB] = 7;
+ InstSize[OPCODE_PROGRAM_NAMED_PARAMETER_NV] = 8;
+ /* GL_EXT_stencil_two_side */
+ InstSize[OPCODE_ACTIVE_STENCIL_FACE_EXT] = 2;
+ /* GL_EXT_depth_bounds_test */
+ InstSize[OPCODE_DEPTH_BOUNDS_EXT] = 3;
+#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
+ InstSize[OPCODE_PROGRAM_STRING_ARB] = 5;
+ InstSize[OPCODE_PROGRAM_ENV_PARAMETER_ARB] = 7;
+#endif
+#if FEATURE_ARB_occlusion_query
+ InstSize[OPCODE_BEGIN_QUERY_ARB] = 3;
+ InstSize[OPCODE_END_QUERY_ARB] = 2;
+#endif
+ InstSize[OPCODE_DRAW_BUFFERS_ARB] = 2 + MAX_DRAW_BUFFERS;
+#if FEATURE_ATI_fragment_shader
+ InstSize[OPCODE_BIND_FRAGMENT_SHADER_ATI] = 2;
+ InstSize[OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI] = 6;
+#endif
+ /* OpenGL 2.0 */
+ InstSize[OPCODE_STENCIL_FUNC_SEPARATE] = 5;
+ InstSize[OPCODE_STENCIL_MASK_SEPARATE] = 3;
+ InstSize[OPCODE_STENCIL_OP_SEPARATE] = 5;
+
+ InstSize[OPCODE_ATTR_1F_NV] = 3;
+ InstSize[OPCODE_ATTR_2F_NV] = 4;
+ InstSize[OPCODE_ATTR_3F_NV] = 5;
+ InstSize[OPCODE_ATTR_4F_NV] = 6;
+ InstSize[OPCODE_ATTR_1F_ARB] = 3;
+ InstSize[OPCODE_ATTR_2F_ARB] = 4;
+ InstSize[OPCODE_ATTR_3F_ARB] = 5;
+ InstSize[OPCODE_ATTR_4F_ARB] = 6;
+ InstSize[OPCODE_MATERIAL] = 7;
+ InstSize[OPCODE_INDEX] = 2;
+ InstSize[OPCODE_EDGEFLAG] = 2;
+ InstSize[OPCODE_BEGIN] = 2;
+ InstSize[OPCODE_END] = 1;
+ InstSize[OPCODE_RECTF] = 5;
+ InstSize[OPCODE_EVAL_C1] = 2;
+ InstSize[OPCODE_EVAL_C2] = 3;
+ InstSize[OPCODE_EVAL_P1] = 2;
+ InstSize[OPCODE_EVAL_P2] = 3;
+ }
+ init_flag = 1;
+}
+
+
+
+/**
+ * Wrapper for _mesa_unpack_image() that handles pixel buffer objects.
+ * \todo This won't suffice when the PBO is really in VRAM/GPU memory.
+ */
+static GLvoid *
+unpack_image( GLuint dimensions, GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *unpack )
+{
+ if (unpack->BufferObj->Name == 0) {
+ /* no PBO */
+ return _mesa_unpack_image(dimensions, width, height, depth, format, type,
+ pixels, unpack);
+ }
+ else if (_mesa_validate_pbo_access(dimensions, unpack, width, height, depth,
+ format, type, pixels)) {
+ const GLubyte *src = ADD_POINTERS(unpack->BufferObj->Data, pixels);
+ return _mesa_unpack_image(dimensions, width, height, depth, format, type,
+ src, unpack);
+ }
+ /* bad access! */
+ return NULL;
+}
+
+
+/*
+ * Allocate space for a display list instruction.
+ * \param opcode - type of instruction
+ * argcount - size in bytes of data required.
+ * \return pointer to the usable data area (not including the internal
+ * opcode).
+ */
+void *
+_mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz )
+{
+ Node *n, *newblock;
+ GLuint count = 1 + (sz + sizeof(Node) - 1) / sizeof(Node);
+
+#ifdef DEBUG
+ if (opcode < (int) OPCODE_EXT_0) {
+ assert( count == InstSize[opcode] );
+ }
+#endif
+
+ if (ctx->ListState.CurrentPos + count + 2 > BLOCK_SIZE) {
+ /* This block is full. Allocate a new block and chain to it */
+ n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
+ n[0].opcode = OPCODE_CONTINUE;
+ newblock = (Node *) MALLOC( sizeof(Node) * BLOCK_SIZE );
+ if (!newblock) {
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "Building display list" );
+ return NULL;
+ }
+ n[1].next = (Node *) newblock;
+ ctx->ListState.CurrentBlock = newblock;
+ ctx->ListState.CurrentPos = 0;
+ }
+
+ n = ctx->ListState.CurrentBlock + ctx->ListState.CurrentPos;
+ ctx->ListState.CurrentPos += count;
+
+ n[0].opcode = (OpCode) opcode;
+
+ return (void *)&n[1];
+}
+
+
+/**
+ * This function allows modules and drivers to get their own opcodes
+ * for extending display list functionality.
+ * \param ctx the rendering context
+ * \param size number of bytes for storing the new display list command
+ * \param execute function to execute the new display list command
+ * \param destroy function to destroy the new display list command
+ * \param print function to print the new display list command
+ * \return the new opcode number or -1 if error
+ */
+GLint
+_mesa_alloc_opcode( GLcontext *ctx,
+ GLuint size,
+ void (*execute)( GLcontext *, void * ),
+ void (*destroy)( GLcontext *, void * ),
+ void (*print)( GLcontext *, void * ) )
+{
+ if (ctx->ListExt.NumOpcodes < MAX_DLIST_EXT_OPCODES) {
+ const GLuint i = ctx->ListExt.NumOpcodes++;
+ ctx->ListExt.Opcode[i].Size = 1 + (size + sizeof(Node) - 1)/sizeof(Node);
+ ctx->ListExt.Opcode[i].Execute = execute;
+ ctx->ListExt.Opcode[i].Destroy = destroy;
+ ctx->ListExt.Opcode[i].Print = print;
+ return i + OPCODE_EXT_0;
+ }
+ return -1;
+}
+
+
+
+/* Mimic the old behaviour of alloc_instruction:
+ * - sz is in units of sizeof(Node)
+ * - return value a pointer to sizeof(Node) before the actual
+ * usable data area.
+ */
+#define ALLOC_INSTRUCTION(ctx, opcode, sz) \
+ ((Node *)_mesa_alloc_instruction(ctx, opcode, sz*sizeof(Node)) - 1)
+
+
+
+/*
+ * Display List compilation functions
+ */
+static void GLAPIENTRY save_Accum( GLenum op, GLfloat value )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ACCUM, 2 );
+ if (n) {
+ n[1].e = op;
+ n[2].f = value;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Accum(ctx->Exec, ( op, value ));
+ }
+}
+
+
+static void GLAPIENTRY save_AlphaFunc( GLenum func, GLclampf ref )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ALPHA_FUNC, 2 );
+ if (n) {
+ n[1].e = func;
+ n[2].f = (GLfloat) ref;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_AlphaFunc(ctx->Exec, ( func, ref ));
+ }
+}
+
+
+static void GLAPIENTRY save_BindTexture( GLenum target, GLuint texture )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_BIND_TEXTURE, 2 );
+ if (n) {
+ n[1].e = target;
+ n[2].ui = texture;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_BindTexture(ctx->Exec, ( target, texture ));
+ }
+}
+
+
+static void GLAPIENTRY save_Bitmap( GLsizei width, GLsizei height,
+ GLfloat xorig, GLfloat yorig,
+ GLfloat xmove, GLfloat ymove,
+ const GLubyte *pixels )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLvoid *image = _mesa_unpack_bitmap( width, height, pixels, &ctx->Unpack );
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_BITMAP, 7 );
+ if (n) {
+ n[1].i = (GLint) width;
+ n[2].i = (GLint) height;
+ n[3].f = xorig;
+ n[4].f = yorig;
+ n[5].f = xmove;
+ n[6].f = ymove;
+ n[7].data = image;
+ }
+ else if (image) {
+ FREE(image);
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Bitmap(ctx->Exec, ( width, height,
+ xorig, yorig, xmove, ymove, pixels ));
+ }
+}
+
+
+static void GLAPIENTRY save_BlendEquation( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_EQUATION, 1 );
+ if (n) {
+ n[1].e = mode;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_BlendEquation(ctx->Exec, ( mode ));
+ }
+}
+
+
+static void GLAPIENTRY save_BlendEquationSeparateEXT( GLenum modeRGB,
+ GLenum modeA )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_EQUATION_SEPARATE, 2 );
+ if (n) {
+ n[1].e = modeRGB;
+ n[2].e = modeA;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_BlendEquationSeparateEXT(ctx->Exec, ( modeRGB, modeA ));
+ }
+}
+
+
+static void GLAPIENTRY save_BlendFuncSeparateEXT(GLenum sfactorRGB, GLenum dfactorRGB,
+ GLenum sfactorA, GLenum dfactorA)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_FUNC_SEPARATE, 4 );
+ if (n) {
+ n[1].e = sfactorRGB;
+ n[2].e = dfactorRGB;
+ n[3].e = sfactorA;
+ n[4].e = dfactorA;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_BlendFuncSeparateEXT(ctx->Exec,
+ (sfactorRGB, dfactorRGB, sfactorA, dfactorA));
+ }
+}
+
+
+static void GLAPIENTRY save_BlendColor( GLfloat red, GLfloat green,
+ GLfloat blue, GLfloat alpha )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_BLEND_COLOR, 4 );
+ if (n) {
+ n[1].f = red;
+ n[2].f = green;
+ n[3].f = blue;
+ n[4].f = alpha;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_BlendColor(ctx->Exec, ( red, green, blue, alpha ));
+ }
+}
+
+
+void GLAPIENTRY _mesa_save_CallList( GLuint list )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ SAVE_FLUSH_VERTICES(ctx);
+
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST, 1 );
+ if (n) {
+ n[1].ui = list;
+ }
+
+ /* After this, we don't know what begin/end state we're in:
+ */
+ ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
+
+ if (ctx->ExecuteFlag) {
+ CALL_CallList(ctx->Exec, ( list ));
+ }
+}
+
+
+void GLAPIENTRY _mesa_save_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i;
+ GLboolean typeErrorFlag;
+
+ SAVE_FLUSH_VERTICES(ctx);
+
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ case GL_2_BYTES:
+ case GL_3_BYTES:
+ case GL_4_BYTES:
+ typeErrorFlag = GL_FALSE;
+ break;
+ default:
+ typeErrorFlag = GL_TRUE;
+ }
+
+ for (i=0;i<n;i++) {
+ GLuint list = translate_id( i, type, lists );
+ Node *n = ALLOC_INSTRUCTION( ctx, OPCODE_CALL_LIST_OFFSET, 2 );
+ if (n) {
+ n[1].ui = list;
+ n[2].b = typeErrorFlag;
+ }
+ }
+
+ /* After this, we don't know what begin/end state we're in:
+ */
+ ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
+
+ if (ctx->ExecuteFlag) {
+ CALL_CallLists(ctx->Exec, ( n, type, lists ));
+ }
+}
+
+
+static void GLAPIENTRY save_Clear( GLbitfield mask )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR, 1 );
+ if (n) {
+ n[1].bf = mask;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Clear(ctx->Exec, ( mask ));
+ }
+}
+
+
+static void GLAPIENTRY save_ClearAccum( GLfloat red, GLfloat green,
+ GLfloat blue, GLfloat alpha )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_ACCUM, 4 );
+ if (n) {
+ n[1].f = red;
+ n[2].f = green;
+ n[3].f = blue;
+ n[4].f = alpha;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ClearAccum(ctx->Exec, ( red, green, blue, alpha ));
+ }
+}
+
+
+static void GLAPIENTRY save_ClearColor( GLclampf red, GLclampf green,
+ GLclampf blue, GLclampf alpha )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_COLOR, 4 );
+ if (n) {
+ n[1].f = red;
+ n[2].f = green;
+ n[3].f = blue;
+ n[4].f = alpha;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ClearColor(ctx->Exec, ( red, green, blue, alpha ));
+ }
+}
+
+
+static void GLAPIENTRY save_ClearDepth( GLclampd depth )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_DEPTH, 1 );
+ if (n) {
+ n[1].f = (GLfloat) depth;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ClearDepth(ctx->Exec, ( depth ));
+ }
+}
+
+
+static void GLAPIENTRY save_ClearIndex( GLfloat c )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_INDEX, 1 );
+ if (n) {
+ n[1].f = c;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ClearIndex(ctx->Exec, ( c ));
+ }
+}
+
+
+static void GLAPIENTRY save_ClearStencil( GLint s )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CLEAR_STENCIL, 1 );
+ if (n) {
+ n[1].i = s;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ClearStencil(ctx->Exec, ( s ));
+ }
+}
+
+
+static void GLAPIENTRY save_ClipPlane( GLenum plane, const GLdouble *equ )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CLIP_PLANE, 5 );
+ if (n) {
+ n[1].e = plane;
+ n[2].f = (GLfloat) equ[0];
+ n[3].f = (GLfloat) equ[1];
+ n[4].f = (GLfloat) equ[2];
+ n[5].f = (GLfloat) equ[3];
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ClipPlane(ctx->Exec, ( plane, equ ));
+ }
+}
+
+
+
+static void GLAPIENTRY save_ColorMask( GLboolean red, GLboolean green,
+ GLboolean blue, GLboolean alpha )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_MASK, 4 );
+ if (n) {
+ n[1].b = red;
+ n[2].b = green;
+ n[3].b = blue;
+ n[4].b = alpha;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ColorMask(ctx->Exec, ( red, green, blue, alpha ));
+ }
+}
+
+
+static void GLAPIENTRY save_ColorMaterial( GLenum face, GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_MATERIAL, 2 );
+ if (n) {
+ n[1].e = face;
+ n[2].e = mode;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ColorMaterial(ctx->Exec, ( face, mode ));
+ }
+}
+
+
+static void GLAPIENTRY save_ColorTable( GLenum target, GLenum internalFormat,
+ GLsizei width, GLenum format, GLenum type,
+ const GLvoid *table )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (target == GL_PROXY_TEXTURE_1D ||
+ target == GL_PROXY_TEXTURE_2D ||
+ target == GL_PROXY_TEXTURE_3D ||
+ target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
+ /* execute immediately */
+ CALL_ColorTable(ctx->Exec, ( target, internalFormat, width,
+ format, type, table ));
+ }
+ else {
+ GLvoid *image = unpack_image(1, width, 1, 1, format, type, table,
+ &ctx->Unpack);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_TABLE, 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) {
+ CALL_ColorTable(ctx->Exec, ( target, internalFormat, width,
+ format, type, table ));
+ }
+ }
+}
+
+
+
+static void GLAPIENTRY
+save_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+
+ 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 ||
+ pname == GL_TEXTURE_COLOR_TABLE_SGI) {
+ n[4].f = params[1];
+ n[5].f = params[2];
+ n[6].f = params[3];
+ }
+ }
+
+ if (ctx->ExecuteFlag) {
+ CALL_ColorTableParameterfv(ctx->Exec, ( target, pname, params ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+
+ 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 ||
+ pname == GL_TEXTURE_COLOR_TABLE_SGI) {
+ n[4].i = params[1];
+ n[5].i = params[2];
+ n[6].i = params[3];
+ }
+ }
+
+ if (ctx->ExecuteFlag) {
+ CALL_ColorTableParameteriv(ctx->Exec, ( target, pname, params ));
+ }
+}
+
+
+
+static void GLAPIENTRY save_ColorSubTable( GLenum target, GLsizei start, GLsizei count,
+ GLenum format, GLenum type,
+ const GLvoid *table)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLvoid *image = unpack_image(1, count, 1, 1, format, type, table,
+ &ctx->Unpack);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COLOR_SUB_TABLE, 6 );
+ if (n) {
+ n[1].e = target;
+ n[2].i = start;
+ n[3].i = count;
+ n[4].e = format;
+ n[5].e = type;
+ n[6].data = image;
+ }
+ else if (image) {
+ FREE(image);
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ColorSubTable(ctx->Exec, (target, start, count, format, type, table));
+ }
+}
+
+
+static void GLAPIENTRY
+save_CopyColorSubTable(GLenum target, GLsizei start,
+ GLint x, GLint y, GLsizei width)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5 );
+ 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) {
+ CALL_CopyColorSubTable(ctx->Exec, (target, start, x, y, width));
+ }
+}
+
+
+static void GLAPIENTRY
+save_CopyColorTable(GLenum target, GLenum internalformat,
+ GLint x, GLint y, GLsizei width)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_COLOR_TABLE, 5 );
+ 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) {
+ CALL_CopyColorTable(ctx->Exec, (target, internalformat, x, y, width));
+ }
+}
+
+
+static void GLAPIENTRY
+save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width,
+ GLenum format, GLenum type, const GLvoid *filter)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLvoid *image = unpack_image(1, width, 1, 1, format, type, filter,
+ &ctx->Unpack);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ 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) {
+ CALL_ConvolutionFilter1D(ctx->Exec, ( target, internalFormat, width,
+ format, type, filter ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_ConvolutionFilter2D(GLenum target, GLenum internalFormat,
+ GLsizei width, GLsizei height, GLenum format,
+ GLenum type, const GLvoid *filter)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLvoid *image = unpack_image(2, width, height, 1, format, type, filter,
+ &ctx->Unpack);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ 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) {
+ CALL_ConvolutionFilter2D(ctx->Exec, ( target, internalFormat, width, height,
+ format, type, filter ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ 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) {
+ CALL_ConvolutionParameteri(ctx->Exec, ( target, pname, param ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ 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) {
+ CALL_ConvolutionParameteriv(ctx->Exec, ( target, pname, params ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ 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) {
+ CALL_ConvolutionParameterf(ctx->Exec, ( target, pname, param ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 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) {
+ CALL_ConvolutionParameterfv(ctx->Exec, ( target, pname, params ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_CopyPixels( GLint x, GLint y,
+ GLsizei width, GLsizei height, GLenum type )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_PIXELS, 5 );
+ if (n) {
+ n[1].i = x;
+ n[2].i = y;
+ n[3].i = (GLint) width;
+ n[4].i = (GLint) height;
+ n[5].e = type;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_CopyPixels(ctx->Exec, ( x, y, width, height, type ));
+ }
+}
+
+
+
+static void GLAPIENTRY
+save_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
+ GLint x, GLint y, GLsizei width, GLint border )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_IMAGE1D, 7 );
+ if (n) {
+ n[1].e = target;
+ n[2].i = level;
+ n[3].e = internalformat;
+ n[4].i = x;
+ n[5].i = y;
+ n[6].i = width;
+ n[7].i = border;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_CopyTexImage1D(ctx->Exec, ( target, level, internalformat,
+ x, y, width, border ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_CopyTexImage2D( GLenum target, GLint level,
+ GLenum internalformat,
+ GLint x, GLint y, GLsizei width,
+ GLsizei height, GLint border )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_IMAGE2D, 8 );
+ if (n) {
+ n[1].e = target;
+ n[2].i = level;
+ n[3].e = internalformat;
+ n[4].i = x;
+ n[5].i = y;
+ n[6].i = width;
+ n[7].i = height;
+ n[8].i = border;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_CopyTexImage2D(ctx->Exec, ( target, level, internalformat,
+ x, y, width, height, border ));
+ }
+}
+
+
+
+static void GLAPIENTRY
+save_CopyTexSubImage1D( GLenum target, GLint level,
+ GLint xoffset, GLint x, GLint y,
+ GLsizei width )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE1D, 6 );
+ if (n) {
+ n[1].e = target;
+ n[2].i = level;
+ n[3].i = xoffset;
+ n[4].i = x;
+ n[5].i = y;
+ n[6].i = width;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_CopyTexSubImage1D(ctx->Exec, ( target, level, xoffset, x, y, width ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_CopyTexSubImage2D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint x, GLint y,
+ GLsizei width, GLint height )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE2D, 8 );
+ if (n) {
+ n[1].e = target;
+ n[2].i = level;
+ n[3].i = xoffset;
+ n[4].i = yoffset;
+ n[5].i = x;
+ n[6].i = y;
+ n[7].i = width;
+ n[8].i = height;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_CopyTexSubImage2D(ctx->Exec, ( target, level, xoffset, yoffset,
+ x, y, width, height ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_CopyTexSubImage3D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLint x, GLint y,
+ GLsizei width, GLint height )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COPY_TEX_SUB_IMAGE3D, 9 );
+ 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 = x;
+ n[7].i = y;
+ n[8].i = width;
+ n[9].i = height;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_CopyTexSubImage3D(ctx->Exec, ( target, level,
+ xoffset, yoffset, zoffset,
+ x, y, width, height ));
+ }
+}
+
+
+static void GLAPIENTRY save_CullFace( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_CULL_FACE, 1 );
+ if (n) {
+ n[1].e = mode;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_CullFace(ctx->Exec, ( mode ));
+ }
+}
+
+
+static void GLAPIENTRY save_DepthFunc( GLenum func )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_FUNC, 1 );
+ if (n) {
+ n[1].e = func;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_DepthFunc(ctx->Exec, ( func ));
+ }
+}
+
+
+static void GLAPIENTRY save_DepthMask( GLboolean mask )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_MASK, 1 );
+ if (n) {
+ n[1].b = mask;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_DepthMask(ctx->Exec, ( mask ));
+ }
+}
+
+
+static void GLAPIENTRY save_DepthRange( GLclampd nearval, GLclampd farval )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_RANGE, 2 );
+ if (n) {
+ n[1].f = (GLfloat) nearval;
+ n[2].f = (GLfloat) farval;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_DepthRange(ctx->Exec, ( nearval, farval ));
+ }
+}
+
+
+static void GLAPIENTRY save_Disable( GLenum cap )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_DISABLE, 1 );
+ if (n) {
+ n[1].e = cap;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Disable(ctx->Exec, ( cap ));
+ }
+}
+
+
+static void GLAPIENTRY save_DrawBuffer( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_DRAW_BUFFER, 1 );
+ if (n) {
+ n[1].e = mode;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_DrawBuffer(ctx->Exec, ( mode ));
+ }
+}
+
+
+static void GLAPIENTRY save_DrawPixels( GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *pixels )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLvoid *image = unpack_image(2, width, height, 1, format, type,
+ pixels, &ctx->Unpack);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_DRAW_PIXELS, 5 );
+ if (n) {
+ n[1].i = width;
+ n[2].i = height;
+ n[3].e = format;
+ n[4].e = type;
+ n[5].data = image;
+ }
+ else if (image) {
+ FREE(image);
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_DrawPixels(ctx->Exec, ( width, height, format, type, pixels ));
+ }
+}
+
+
+
+static void GLAPIENTRY save_Enable( GLenum cap )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ENABLE, 1 );
+ if (n) {
+ n[1].e = cap;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Enable(ctx->Exec, ( cap ));
+ }
+}
+
+
+
+void GLAPIENTRY _mesa_save_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_EVALMESH1, 3 );
+ if (n) {
+ n[1].e = mode;
+ n[2].i = i1;
+ n[3].i = i2;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_EvalMesh1(ctx->Exec, ( mode, i1, i2 ));
+ }
+}
+
+
+void GLAPIENTRY _mesa_save_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_EVALMESH2, 5 );
+ if (n) {
+ n[1].e = mode;
+ n[2].i = i1;
+ n[3].i = i2;
+ n[4].i = j1;
+ n[5].i = j2;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_EvalMesh2(ctx->Exec, ( mode, i1, i2, j1, j2 ));
+ }
+}
+
+
+
+
+static void GLAPIENTRY save_Fogfv( GLenum pname, const GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_FOG, 5 );
+ if (n) {
+ n[1].e = pname;
+ n[2].f = params[0];
+ n[3].f = params[1];
+ n[4].f = params[2];
+ n[5].f = params[3];
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Fogfv(ctx->Exec, ( pname, params ));
+ }
+}
+
+
+static void GLAPIENTRY save_Fogf( GLenum pname, GLfloat param )
+{
+ save_Fogfv(pname, &param);
+}
+
+
+static void GLAPIENTRY save_Fogiv(GLenum pname, const GLint *params )
+{
+ GLfloat p[4];
+ switch (pname) {
+ case GL_FOG_MODE:
+ case GL_FOG_DENSITY:
+ case GL_FOG_START:
+ case GL_FOG_END:
+ case GL_FOG_INDEX:
+ p[0] = (GLfloat) *params;
+ break;
+ case GL_FOG_COLOR:
+ p[0] = INT_TO_FLOAT( params[0] );
+ p[1] = INT_TO_FLOAT( params[1] );
+ p[2] = INT_TO_FLOAT( params[2] );
+ p[3] = INT_TO_FLOAT( params[3] );
+ break;
+ default:
+ /* Error will be caught later in gl_Fogfv */
+ ;
+ }
+ save_Fogfv(pname, p);
+}
+
+
+static void GLAPIENTRY save_Fogi(GLenum pname, GLint param )
+{
+ save_Fogiv(pname, &param);
+}
+
+
+static void GLAPIENTRY save_FrontFace( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_FRONT_FACE, 1 );
+ if (n) {
+ n[1].e = mode;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_FrontFace(ctx->Exec, ( mode ));
+ }
+}
+
+
+static void GLAPIENTRY save_Frustum( GLdouble left, GLdouble right,
+ GLdouble bottom, GLdouble top,
+ GLdouble nearval, GLdouble farval )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_FRUSTUM, 6 );
+ if (n) {
+ n[1].f = (GLfloat) left;
+ n[2].f = (GLfloat) right;
+ n[3].f = (GLfloat) bottom;
+ n[4].f = (GLfloat) top;
+ n[5].f = (GLfloat) nearval;
+ n[6].f = (GLfloat) farval;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Frustum(ctx->Exec, ( left, right, bottom, top, nearval, farval ));
+ }
+}
+
+
+static void GLAPIENTRY save_Hint( GLenum target, GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_HINT, 2 );
+ if (n) {
+ n[1].e = target;
+ n[2].e = mode;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Hint(ctx->Exec, ( target, mode ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ 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) {
+ CALL_Histogram(ctx->Exec, ( target, width, internalFormat, sink ));
+ }
+}
+
+
+static void GLAPIENTRY save_IndexMask( GLuint mask )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_INDEX_MASK, 1 );
+ if (n) {
+ n[1].ui = mask;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_IndexMask(ctx->Exec, ( mask ));
+ }
+}
+
+
+static void GLAPIENTRY save_InitNames( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ (void) ALLOC_INSTRUCTION( ctx, OPCODE_INIT_NAMES, 0 );
+ if (ctx->ExecuteFlag) {
+ CALL_InitNames(ctx->Exec, ());
+ }
+}
+
+
+static void GLAPIENTRY save_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_LIGHT, 6 );
+ if (OPCODE_LIGHT) {
+ GLint i, nParams;
+ n[1].e = light;
+ n[2].e = pname;
+ switch (pname) {
+ case GL_AMBIENT:
+ nParams = 4;
+ break;
+ case GL_DIFFUSE:
+ nParams = 4;
+ break;
+ case GL_SPECULAR:
+ nParams = 4;
+ break;
+ case GL_POSITION:
+ nParams = 4;
+ break;
+ case GL_SPOT_DIRECTION:
+ nParams = 3;
+ break;
+ case GL_SPOT_EXPONENT:
+ nParams = 1;
+ break;
+ case GL_SPOT_CUTOFF:
+ nParams = 1;
+ break;
+ case GL_CONSTANT_ATTENUATION:
+ nParams = 1;
+ break;
+ case GL_LINEAR_ATTENUATION:
+ nParams = 1;
+ break;
+ case GL_QUADRATIC_ATTENUATION:
+ nParams = 1;
+ break;
+ default:
+ nParams = 0;
+ }
+ for (i = 0; i < nParams; i++) {
+ n[3+i].f = params[i];
+ }
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Lightfv(ctx->Exec, ( light, pname, params ));
+ }
+}
+
+
+static void GLAPIENTRY save_Lightf( GLenum light, GLenum pname, GLfloat params )
+{
+ save_Lightfv(light, pname, &params);
+}
+
+
+static void GLAPIENTRY save_Lightiv( GLenum light, GLenum pname, const GLint *params )
+{
+ GLfloat fparam[4];
+ switch (pname) {
+ case GL_AMBIENT:
+ case GL_DIFFUSE:
+ case GL_SPECULAR:
+ fparam[0] = INT_TO_FLOAT( params[0] );
+ fparam[1] = INT_TO_FLOAT( params[1] );
+ fparam[2] = INT_TO_FLOAT( params[2] );
+ fparam[3] = INT_TO_FLOAT( params[3] );
+ break;
+ case GL_POSITION:
+ fparam[0] = (GLfloat) params[0];
+ fparam[1] = (GLfloat) params[1];
+ fparam[2] = (GLfloat) params[2];
+ fparam[3] = (GLfloat) params[3];
+ break;
+ case GL_SPOT_DIRECTION:
+ fparam[0] = (GLfloat) params[0];
+ fparam[1] = (GLfloat) params[1];
+ fparam[2] = (GLfloat) params[2];
+ break;
+ case GL_SPOT_EXPONENT:
+ case GL_SPOT_CUTOFF:
+ case GL_CONSTANT_ATTENUATION:
+ case GL_LINEAR_ATTENUATION:
+ case GL_QUADRATIC_ATTENUATION:
+ fparam[0] = (GLfloat) params[0];
+ break;
+ default:
+ /* error will be caught later in gl_Lightfv */
+ ;
+ }
+ save_Lightfv( light, pname, fparam );
+}
+
+
+static void GLAPIENTRY save_Lighti( GLenum light, GLenum pname, GLint param )
+{
+ save_Lightiv( light, pname, &param );
+}
+
+
+static void GLAPIENTRY save_LightModelfv( GLenum pname, const GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_LIGHT_MODEL, 5 );
+ if (n) {
+ n[1].e = pname;
+ n[2].f = params[0];
+ n[3].f = params[1];
+ n[4].f = params[2];
+ n[5].f = params[3];
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_LightModelfv(ctx->Exec, ( pname, params ));
+ }
+}
+
+
+static void GLAPIENTRY save_LightModelf( GLenum pname, GLfloat param )
+{
+ save_LightModelfv(pname, &param);
+}
+
+
+static void GLAPIENTRY save_LightModeliv( GLenum pname, const GLint *params )
+{
+ GLfloat fparam[4];
+ switch (pname) {
+ case GL_LIGHT_MODEL_AMBIENT:
+ fparam[0] = INT_TO_FLOAT( params[0] );
+ fparam[1] = INT_TO_FLOAT( params[1] );
+ fparam[2] = INT_TO_FLOAT( params[2] );
+ fparam[3] = INT_TO_FLOAT( params[3] );
+ break;
+ case GL_LIGHT_MODEL_LOCAL_VIEWER:
+ case GL_LIGHT_MODEL_TWO_SIDE:
+ case GL_LIGHT_MODEL_COLOR_CONTROL:
+ fparam[0] = (GLfloat) params[0];
+ break;
+ default:
+ /* Error will be caught later in gl_LightModelfv */
+ ;
+ }
+ save_LightModelfv(pname, fparam);
+}
+
+
+static void GLAPIENTRY save_LightModeli( GLenum pname, GLint param )
+{
+ save_LightModeliv(pname, &param);
+}
+
+
+static void GLAPIENTRY save_LineStipple( GLint factor, GLushort pattern )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_LINE_STIPPLE, 2 );
+ if (n) {
+ n[1].i = factor;
+ n[2].us = pattern;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_LineStipple(ctx->Exec, ( factor, pattern ));
+ }
+}
+
+
+static void GLAPIENTRY save_LineWidth( GLfloat width )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_LINE_WIDTH, 1 );
+ if (n) {
+ n[1].f = width;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_LineWidth(ctx->Exec, ( width ));
+ }
+}
+
+
+static void GLAPIENTRY save_ListBase( GLuint base )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_LIST_BASE, 1 );
+ if (n) {
+ n[1].ui = base;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ListBase(ctx->Exec, ( base ));
+ }
+}
+
+
+static void GLAPIENTRY save_LoadIdentity( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ (void) ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_IDENTITY, 0 );
+ if (ctx->ExecuteFlag) {
+ CALL_LoadIdentity(ctx->Exec, ());
+ }
+}
+
+
+static void GLAPIENTRY save_LoadMatrixf( const GLfloat *m )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_MATRIX, 16 );
+ if (n) {
+ GLuint i;
+ for (i=0;i<16;i++) {
+ n[1+i].f = m[i];
+ }
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_LoadMatrixf(ctx->Exec, ( m ));
+ }
+}
+
+
+static void GLAPIENTRY save_LoadMatrixd( const GLdouble *m )
+{
+ GLfloat f[16];
+ GLint i;
+ for (i = 0; i < 16; i++) {
+ f[i] = (GLfloat) m[i];
+ }
+ save_LoadMatrixf(f);
+}
+
+
+static void GLAPIENTRY save_LoadName( GLuint name )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_NAME, 1 );
+ if (n) {
+ n[1].ui = name;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_LoadName(ctx->Exec, ( name ));
+ }
+}
+
+
+static void GLAPIENTRY save_LogicOp( GLenum opcode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_LOGIC_OP, 1 );
+ if (n) {
+ n[1].e = opcode;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_LogicOp(ctx->Exec, ( opcode ));
+ }
+}
+
+
+static void GLAPIENTRY save_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
+ GLint order, const GLdouble *points)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP1, 6 );
+ if (n) {
+ GLfloat *pnts = _mesa_copy_map_points1d( target, stride, order, points );
+ n[1].e = target;
+ n[2].f = (GLfloat) u1;
+ n[3].f = (GLfloat) u2;
+ n[4].i = _mesa_evaluator_components(target); /* stride */
+ n[5].i = order;
+ n[6].data = (void *) pnts;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Map1d(ctx->Exec, ( target, u1, u2, stride, order, points ));
+ }
+}
+
+static void GLAPIENTRY save_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
+ GLint order, const GLfloat *points)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP1, 6 );
+ if (n) {
+ GLfloat *pnts = _mesa_copy_map_points1f( target, stride, order, points );
+ n[1].e = target;
+ n[2].f = u1;
+ n[3].f = u2;
+ n[4].i = _mesa_evaluator_components(target); /* stride */
+ n[5].i = order;
+ n[6].data = (void *) pnts;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Map1f(ctx->Exec, ( target, u1, u2, stride, order, points ));
+ }
+}
+
+
+static void GLAPIENTRY save_Map2d( GLenum target,
+ GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
+ GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
+ const GLdouble *points )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP2, 10 );
+ if (n) {
+ GLfloat *pnts = _mesa_copy_map_points2d( target, ustride, uorder,
+ vstride, vorder, points );
+ n[1].e = target;
+ n[2].f = (GLfloat) u1;
+ n[3].f = (GLfloat) u2;
+ n[4].f = (GLfloat) v1;
+ n[5].f = (GLfloat) v2;
+ /* XXX verify these strides are correct */
+ n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride*/
+ n[7].i = _mesa_evaluator_components(target); /*vstride*/
+ n[8].i = uorder;
+ n[9].i = vorder;
+ n[10].data = (void *) pnts;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Map2d(ctx->Exec, ( target,
+ u1, u2, ustride, uorder,
+ v1, v2, vstride, vorder, points ));
+ }
+}
+
+
+static void GLAPIENTRY save_Map2f( GLenum target,
+ GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
+ GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
+ const GLfloat *points )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MAP2, 10 );
+ if (n) {
+ GLfloat *pnts = _mesa_copy_map_points2f( target, ustride, uorder,
+ vstride, vorder, points );
+ n[1].e = target;
+ n[2].f = u1;
+ n[3].f = u2;
+ n[4].f = v1;
+ n[5].f = v2;
+ /* XXX verify these strides are correct */
+ n[6].i = _mesa_evaluator_components(target) * vorder; /*ustride*/
+ n[7].i = _mesa_evaluator_components(target); /*vstride*/
+ n[8].i = uorder;
+ n[9].i = vorder;
+ n[10].data = (void *) pnts;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Map2f(ctx->Exec, ( target, u1, u2, ustride, uorder,
+ v1, v2, vstride, vorder, points ));
+ }
+}
+
+
+static void GLAPIENTRY save_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MAPGRID1, 3 );
+ if (n) {
+ n[1].i = un;
+ n[2].f = u1;
+ n[3].f = u2;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_MapGrid1f(ctx->Exec, ( un, u1, u2 ));
+ }
+}
+
+
+static void GLAPIENTRY save_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 )
+{
+ save_MapGrid1f(un, (GLfloat) u1, (GLfloat) u2);
+}
+
+
+static void GLAPIENTRY save_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
+ GLint vn, GLfloat v1, GLfloat v2 )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MAPGRID2, 6 );
+ if (n) {
+ n[1].i = un;
+ n[2].f = u1;
+ n[3].f = u2;
+ n[4].i = vn;
+ n[5].f = v1;
+ n[6].f = v2;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_MapGrid2f(ctx->Exec, ( un, u1, u2, vn, v1, v2 ));
+ }
+}
+
+
+
+static void GLAPIENTRY save_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
+ GLint vn, GLdouble v1, GLdouble v2 )
+{
+ save_MapGrid2f(un, (GLfloat) u1, (GLfloat) u2,
+ vn, (GLfloat) v1, (GLfloat) v2);
+}
+
+
+static void GLAPIENTRY save_MatrixMode( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MATRIX_MODE, 1 );
+ if (n) {
+ n[1].e = mode;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_MatrixMode(ctx->Exec, ( mode ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ 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) {
+ CALL_Minmax(ctx->Exec, ( target, internalFormat, sink ));
+ }
+}
+
+
+static void GLAPIENTRY save_MultMatrixf( const GLfloat *m )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MULT_MATRIX, 16 );
+ if (n) {
+ GLuint i;
+ for (i=0;i<16;i++) {
+ n[1+i].f = m[i];
+ }
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_MultMatrixf(ctx->Exec, ( m ));
+ }
+}
+
+
+static void GLAPIENTRY save_MultMatrixd( const GLdouble *m )
+{
+ GLfloat f[16];
+ GLint i;
+ for (i = 0; i < 16; i++) {
+ f[i] = (GLfloat) m[i];
+ }
+ save_MultMatrixf(f);
+}
+
+
+static void GLAPIENTRY save_NewList( GLuint list, GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ /* It's an error to call this function while building a display list */
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glNewList" );
+ (void) list;
+ (void) mode;
+}
+
+
+
+static void GLAPIENTRY save_Ortho( GLdouble left, GLdouble right,
+ GLdouble bottom, GLdouble top,
+ GLdouble nearval, GLdouble farval )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ORTHO, 6 );
+ if (n) {
+ n[1].f = (GLfloat) left;
+ n[2].f = (GLfloat) right;
+ n[3].f = (GLfloat) bottom;
+ n[4].f = (GLfloat) top;
+ n[5].f = (GLfloat) nearval;
+ n[6].f = (GLfloat) farval;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Ortho(ctx->Exec, ( left, right, bottom, top, nearval, farval ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_PixelMapfv( GLenum map, GLint mapsize, const GLfloat *values )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_MAP, 3 );
+ if (n) {
+ n[1].e = map;
+ n[2].i = mapsize;
+ n[3].data = (void *) MALLOC( mapsize * sizeof(GLfloat) );
+ MEMCPY( n[3].data, (void *) values, mapsize * sizeof(GLfloat) );
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_PixelMapfv(ctx->Exec, ( map, mapsize, values ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_PixelMapuiv(GLenum map, GLint mapsize, const GLuint *values )
+{
+ GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
+ GLint i;
+ if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
+ for (i=0;i<mapsize;i++) {
+ fvalues[i] = (GLfloat) values[i];
+ }
+ }
+ else {
+ for (i=0;i<mapsize;i++) {
+ fvalues[i] = UINT_TO_FLOAT( values[i] );
+ }
+ }
+ save_PixelMapfv(map, mapsize, fvalues);
+}
+
+
+static void GLAPIENTRY
+save_PixelMapusv(GLenum map, GLint mapsize, const GLushort *values)
+{
+ GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
+ GLint i;
+ if (map==GL_PIXEL_MAP_I_TO_I || map==GL_PIXEL_MAP_S_TO_S) {
+ for (i=0;i<mapsize;i++) {
+ fvalues[i] = (GLfloat) values[i];
+ }
+ }
+ else {
+ for (i=0;i<mapsize;i++) {
+ fvalues[i] = USHORT_TO_FLOAT( values[i] );
+ }
+ }
+ save_PixelMapfv(map, mapsize, fvalues);
+}
+
+
+static void GLAPIENTRY
+save_PixelTransferf( GLenum pname, GLfloat param )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TRANSFER, 2 );
+ if (n) {
+ n[1].e = pname;
+ n[2].f = param;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_PixelTransferf(ctx->Exec, ( pname, param ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_PixelTransferi( GLenum pname, GLint param )
+{
+ save_PixelTransferf( pname, (GLfloat) param );
+}
+
+
+static void GLAPIENTRY
+save_PixelZoom( GLfloat xfactor, GLfloat yfactor )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_ZOOM, 2 );
+ if (n) {
+ n[1].f = xfactor;
+ n[2].f = yfactor;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_PixelZoom(ctx->Exec, ( xfactor, yfactor ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_PointParameterfvEXT( GLenum pname, const GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_POINT_PARAMETERS, 4 );
+ if (n) {
+ n[1].e = pname;
+ n[2].f = params[0];
+ n[3].f = params[1];
+ n[4].f = params[2];
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_PointParameterfvEXT(ctx->Exec, ( pname, params ));
+ }
+}
+
+
+static void GLAPIENTRY save_PointParameterfEXT( GLenum pname, GLfloat param )
+{
+ save_PointParameterfvEXT(pname, &param);
+}
+
+static void GLAPIENTRY save_PointParameteriNV( GLenum pname, GLint param )
+{
+ GLfloat p = (GLfloat) param;
+ save_PointParameterfvEXT(pname, &p);
+}
+
+static void GLAPIENTRY save_PointParameterivNV( GLenum pname, const GLint *param )
+{
+ GLfloat p = (GLfloat) param[0];
+ save_PointParameterfvEXT(pname, &p);
+}
+
+
+static void GLAPIENTRY save_PointSize( GLfloat size )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_POINT_SIZE, 1 );
+ if (n) {
+ n[1].f = size;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_PointSize(ctx->Exec, ( size ));
+ }
+}
+
+
+static void GLAPIENTRY save_PolygonMode( GLenum face, GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_MODE, 2 );
+ if (n) {
+ n[1].e = face;
+ n[2].e = mode;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_PolygonMode(ctx->Exec, ( face, mode ));
+ }
+}
+
+
+/*
+ * Polygon stipple must have been upacked already!
+ */
+static void GLAPIENTRY save_PolygonStipple( const GLubyte *pattern )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_STIPPLE, 1 );
+ if (n) {
+ void *data;
+ n[1].data = MALLOC( 32 * 4 );
+ data = n[1].data; /* This needed for Acorn compiler */
+ MEMCPY( data, pattern, 32 * 4 );
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_PolygonStipple(ctx->Exec, ( (GLubyte*) pattern ));
+ }
+}
+
+
+static void GLAPIENTRY save_PolygonOffset( GLfloat factor, GLfloat units )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_POLYGON_OFFSET, 2 );
+ if (n) {
+ n[1].f = factor;
+ n[2].f = units;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_PolygonOffset(ctx->Exec, ( factor, units ));
+ }
+}
+
+
+static void GLAPIENTRY save_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ /* XXX mult by DepthMaxF here??? */
+ save_PolygonOffset(factor, ctx->DrawBuffer->_DepthMaxF * bias);
+}
+
+
+static void GLAPIENTRY save_PopAttrib( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_ATTRIB, 0 );
+ if (ctx->ExecuteFlag) {
+ CALL_PopAttrib(ctx->Exec, ());
+ }
+}
+
+
+static void GLAPIENTRY save_PopMatrix( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_MATRIX, 0 );
+ if (ctx->ExecuteFlag) {
+ CALL_PopMatrix(ctx->Exec, ());
+ }
+}
+
+
+static void GLAPIENTRY save_PopName( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ (void) ALLOC_INSTRUCTION( ctx, OPCODE_POP_NAME, 0 );
+ if (ctx->ExecuteFlag) {
+ CALL_PopName(ctx->Exec, ());
+ }
+}
+
+
+static void GLAPIENTRY save_PrioritizeTextures( GLsizei num, const GLuint *textures,
+ const GLclampf *priorities )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+
+ for (i=0;i<num;i++) {
+ Node *n;
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PRIORITIZE_TEXTURE, 2 );
+ if (n) {
+ n[1].ui = textures[i];
+ n[2].f = priorities[i];
+ }
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_PrioritizeTextures(ctx->Exec, ( num, textures, priorities ));
+ }
+}
+
+
+static void GLAPIENTRY save_PushAttrib( GLbitfield mask )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_ATTRIB, 1 );
+ if (n) {
+ n[1].bf = mask;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_PushAttrib(ctx->Exec, ( mask ));
+ }
+}
+
+
+static void GLAPIENTRY save_PushMatrix( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ (void) ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_MATRIX, 0 );
+ if (ctx->ExecuteFlag) {
+ CALL_PushMatrix(ctx->Exec, ());
+ }
+}
+
+
+static void GLAPIENTRY save_PushName( GLuint name )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PUSH_NAME, 1 );
+ if (n) {
+ n[1].ui = name;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_PushName(ctx->Exec, ( name ));
+ }
+}
+
+
+static void GLAPIENTRY save_RasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_RASTER_POS, 4 );
+ if (n) {
+ n[1].f = x;
+ n[2].f = y;
+ n[3].f = z;
+ n[4].f = w;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_RasterPos4f(ctx->Exec, ( x, y, z, w ));
+ }
+}
+
+static void GLAPIENTRY save_RasterPos2d(GLdouble x, GLdouble y)
+{
+ save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
+}
+
+static void GLAPIENTRY save_RasterPos2f(GLfloat x, GLfloat y)
+{
+ save_RasterPos4f(x, y, 0.0F, 1.0F);
+}
+
+static void GLAPIENTRY save_RasterPos2i(GLint x, GLint y)
+{
+ save_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
+}
+
+static void GLAPIENTRY save_RasterPos2s(GLshort x, GLshort y)
+{
+ save_RasterPos4f(x, y, 0.0F, 1.0F);
+}
+
+static void GLAPIENTRY save_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
+{
+ save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
+}
+
+static void GLAPIENTRY save_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
+{
+ save_RasterPos4f(x, y, z, 1.0F);
+}
+
+static void GLAPIENTRY save_RasterPos3i(GLint x, GLint y, GLint z)
+{
+ save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
+}
+
+static void GLAPIENTRY save_RasterPos3s(GLshort x, GLshort y, GLshort z)
+{
+ save_RasterPos4f(x, y, z, 1.0F);
+}
+
+static void GLAPIENTRY save_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
+}
+
+static void GLAPIENTRY save_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
+{
+ save_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
+}
+
+static void GLAPIENTRY save_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
+{
+ save_RasterPos4f(x, y, z, w);
+}
+
+static void GLAPIENTRY save_RasterPos2dv(const GLdouble *v)
+{
+ save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
+}
+
+static void GLAPIENTRY save_RasterPos2fv(const GLfloat *v)
+{
+ save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
+}
+
+static void GLAPIENTRY save_RasterPos2iv(const GLint *v)
+{
+ save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
+}
+
+static void GLAPIENTRY save_RasterPos2sv(const GLshort *v)
+{
+ save_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
+}
+
+static void GLAPIENTRY save_RasterPos3dv(const GLdouble *v)
+{
+ save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
+}
+
+static void GLAPIENTRY save_RasterPos3fv(const GLfloat *v)
+{
+ save_RasterPos4f(v[0], v[1], v[2], 1.0F);
+}
+
+static void GLAPIENTRY save_RasterPos3iv(const GLint *v)
+{
+ save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
+}
+
+static void GLAPIENTRY save_RasterPos3sv(const GLshort *v)
+{
+ save_RasterPos4f(v[0], v[1], v[2], 1.0F);
+}
+
+static void GLAPIENTRY save_RasterPos4dv(const GLdouble *v)
+{
+ save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
+ (GLfloat) v[2], (GLfloat) v[3]);
+}
+
+static void GLAPIENTRY save_RasterPos4fv(const GLfloat *v)
+{
+ save_RasterPos4f(v[0], v[1], v[2], v[3]);
+}
+
+static void GLAPIENTRY save_RasterPos4iv(const GLint *v)
+{
+ save_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
+ (GLfloat) v[2], (GLfloat) v[3]);
+}
+
+static void GLAPIENTRY save_RasterPos4sv(const GLshort *v)
+{
+ save_RasterPos4f(v[0], v[1], v[2], v[3]);
+}
+
+
+static void GLAPIENTRY save_PassThrough( GLfloat token )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PASSTHROUGH, 1 );
+ if (n) {
+ n[1].f = token;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_PassThrough(ctx->Exec, ( token ));
+ }
+}
+
+
+static void GLAPIENTRY save_ReadBuffer( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_READ_BUFFER, 1 );
+ if (n) {
+ n[1].e = mode;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ReadBuffer(ctx->Exec, ( mode ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_ResetHistogram(GLenum target)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_RESET_HISTOGRAM, 1 );
+ if (n) {
+ n[1].e = target;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ResetHistogram(ctx->Exec, ( target ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_ResetMinmax(GLenum target)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_RESET_MIN_MAX, 1 );
+ if (n) {
+ n[1].e = target;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ResetMinmax(ctx->Exec, ( target ));
+ }
+}
+
+
+static void GLAPIENTRY save_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ROTATE, 4 );
+ if (n) {
+ n[1].f = angle;
+ n[2].f = x;
+ n[3].f = y;
+ n[4].f = z;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Rotatef(ctx->Exec, ( angle, x, y, z ));
+ }
+}
+
+
+static void GLAPIENTRY save_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z )
+{
+ save_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
+}
+
+
+static void GLAPIENTRY save_Scalef( GLfloat x, GLfloat y, GLfloat z )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_SCALE, 3 );
+ if (n) {
+ n[1].f = x;
+ n[2].f = y;
+ n[3].f = z;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Scalef(ctx->Exec, ( x, y, z ));
+ }
+}
+
+
+static void GLAPIENTRY save_Scaled( GLdouble x, GLdouble y, GLdouble z )
+{
+ save_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z);
+}
+
+
+static void GLAPIENTRY save_Scissor( GLint x, GLint y, GLsizei width, GLsizei height )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_SCISSOR, 4 );
+ if (n) {
+ n[1].i = x;
+ n[2].i = y;
+ n[3].i = width;
+ n[4].i = height;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Scissor(ctx->Exec, ( x, y, width, height ));
+ }
+}
+
+
+static void GLAPIENTRY save_ShadeModel( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_SHADE_MODEL, 1 );
+ if (n) {
+ n[1].e = mode;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ShadeModel(ctx->Exec, ( mode ));
+ }
+}
+
+
+static void GLAPIENTRY save_StencilFunc( GLenum func, GLint ref, GLuint mask )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_FUNC, 3 );
+ if (n) {
+ n[1].e = func;
+ n[2].i = ref;
+ n[3].ui = mask;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_StencilFunc(ctx->Exec, ( func, ref, mask ));
+ }
+}
+
+
+static void GLAPIENTRY save_StencilMask( GLuint mask )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_MASK, 1 );
+ if (n) {
+ n[1].ui = mask;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_StencilMask(ctx->Exec, ( mask ));
+ }
+}
+
+
+static void GLAPIENTRY save_StencilOp( GLenum fail, GLenum zfail, GLenum zpass )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_OP, 3 );
+ if (n) {
+ n[1].e = fail;
+ n[2].e = zfail;
+ n[3].e = zpass;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_StencilOp(ctx->Exec, ( fail, zfail, zpass ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_FUNC_SEPARATE, 4);
+ if (n) {
+ n[1].e = face;
+ n[2].e = func;
+ n[3].i = ref;
+ n[4].ui = mask;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_StencilFuncSeparate(ctx->Exec, (face, func, ref, mask));
+ }
+}
+
+
+static void GLAPIENTRY
+save_StencilMaskSeparate(GLenum face, GLuint mask)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION(ctx, OPCODE_STENCIL_MASK_SEPARATE, 2);
+ if (n) {
+ n[1].e = face;
+ n[2].ui = mask;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_StencilMaskSeparate(ctx->Exec, (face, mask));
+ }
+}
+
+
+static void GLAPIENTRY
+save_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_STENCIL_OP_SEPARATE, 4 );
+ if (n) {
+ n[1].e = face;
+ n[2].e = fail;
+ n[3].e = zfail;
+ n[4].e = zpass;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_StencilOpSeparate(ctx->Exec, (face, fail, zfail, zpass));
+ }
+}
+
+
+static void GLAPIENTRY save_TexEnvfv( GLenum target, GLenum pname, const GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXENV, 6 );
+ if (n) {
+ n[1].e = target;
+ n[2].e = pname;
+ if (pname == GL_TEXTURE_ENV_COLOR) {
+ n[3].f = params[0];
+ n[4].f = params[1];
+ n[5].f = params[2];
+ n[6].f = params[3];
+ }
+ else {
+ n[3].f = params[0];
+ n[4].f = n[5].f = n[6].f = 0.0F;
+ }
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_TexEnvfv(ctx->Exec, ( target, pname, params ));
+ }
+}
+
+
+static void GLAPIENTRY save_TexEnvf( GLenum target, GLenum pname, GLfloat param )
+{
+ save_TexEnvfv( target, pname, &param );
+}
+
+
+static void GLAPIENTRY save_TexEnvi( GLenum target, GLenum pname, GLint param )
+{
+ GLfloat p[4];
+ p[0] = (GLfloat) param;
+ p[1] = p[2] = p[3] = 0.0;
+ save_TexEnvfv( target, pname, p );
+}
+
+
+static void GLAPIENTRY save_TexEnviv( GLenum target, GLenum pname, const GLint *param )
+{
+ GLfloat p[4];
+ if (pname == GL_TEXTURE_ENV_COLOR) {
+ p[0] = INT_TO_FLOAT( param[0] );
+ p[1] = INT_TO_FLOAT( param[1] );
+ p[2] = INT_TO_FLOAT( param[2] );
+ p[3] = INT_TO_FLOAT( param[3] );
+ }
+ else {
+ p[0] = (GLfloat) param[0];
+ p[1] = p[2] = p[3] = 0.0F;
+ }
+ save_TexEnvfv( target, pname, p );
+}
+
+
+static void GLAPIENTRY save_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXGEN, 6 );
+ if (n) {
+ n[1].e = coord;
+ n[2].e = pname;
+ n[3].f = params[0];
+ n[4].f = params[1];
+ n[5].f = params[2];
+ n[6].f = params[3];
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_TexGenfv(ctx->Exec, ( coord, pname, params ));
+ }
+}
+
+
+static void GLAPIENTRY save_TexGeniv(GLenum coord, GLenum pname, const GLint *params )
+{
+ GLfloat p[4];
+ p[0] = (GLfloat) params[0];
+ p[1] = (GLfloat) params[1];
+ p[2] = (GLfloat) params[2];
+ p[3] = (GLfloat) params[3];
+ save_TexGenfv(coord, pname, p);
+}
+
+
+static void GLAPIENTRY save_TexGend(GLenum coord, GLenum pname, GLdouble param )
+{
+ GLfloat p = (GLfloat) param;
+ save_TexGenfv( coord, pname, &p );
+}
+
+
+static void GLAPIENTRY save_TexGendv(GLenum coord, GLenum pname, const GLdouble *params )
+{
+ GLfloat p[4];
+ p[0] = (GLfloat) params[0];
+ p[1] = (GLfloat) params[1];
+ p[2] = (GLfloat) params[2];
+ p[3] = (GLfloat) params[3];
+ save_TexGenfv( coord, pname, p );
+}
+
+
+static void GLAPIENTRY save_TexGenf( GLenum coord, GLenum pname, GLfloat param )
+{
+ save_TexGenfv(coord, pname, &param);
+}
+
+
+static void GLAPIENTRY save_TexGeni( GLenum coord, GLenum pname, GLint param )
+{
+ save_TexGeniv( coord, pname, &param );
+}
+
+
+static void GLAPIENTRY save_TexParameterfv( GLenum target,
+ GLenum pname, const GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEXPARAMETER, 6 );
+ if (n) {
+ n[1].e = target;
+ n[2].e = pname;
+ n[3].f = params[0];
+ n[4].f = params[1];
+ n[5].f = params[2];
+ n[6].f = params[3];
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_TexParameterfv(ctx->Exec, ( target, pname, params ));
+ }
+}
+
+
+static void GLAPIENTRY save_TexParameterf( GLenum target, GLenum pname, GLfloat param )
+{
+ save_TexParameterfv(target, pname, &param);
+}
+
+
+static void GLAPIENTRY save_TexParameteri( GLenum target, GLenum pname, GLint param )
+{
+ GLfloat fparam[4];
+ fparam[0] = (GLfloat) param;
+ fparam[1] = fparam[2] = fparam[3] = 0.0;
+ save_TexParameterfv(target, pname, fparam);
+}
+
+
+static void GLAPIENTRY save_TexParameteriv( GLenum target, GLenum pname, const GLint *params )
+{
+ GLfloat fparam[4];
+ fparam[0] = (GLfloat) params[0];
+ fparam[1] = fparam[2] = fparam[3] = 0.0;
+ save_TexParameterfv(target, pname, fparam);
+}
+
+
+static void GLAPIENTRY save_TexImage1D( GLenum target,
+ GLint level, GLint components,
+ GLsizei width, GLint border,
+ GLenum format, GLenum type,
+ const GLvoid *pixels )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (target == GL_PROXY_TEXTURE_1D) {
+ /* don't compile, execute immediately */
+ CALL_TexImage1D(ctx->Exec, ( target, level, components, width,
+ border, format, type, pixels ));
+ }
+ else {
+ GLvoid *image = unpack_image(1, width, 1, 1, format, type,
+ pixels, &ctx->Unpack);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE1D, 8 );
+ if (n) {
+ n[1].e = target;
+ n[2].i = level;
+ n[3].i = components;
+ n[4].i = (GLint) width;
+ n[5].i = border;
+ n[6].e = format;
+ n[7].e = type;
+ n[8].data = image;
+ }
+ else if (image) {
+ FREE(image);
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_TexImage1D(ctx->Exec, ( target, level, components, width,
+ border, format, type, pixels ));
+ }
+ }
+}
+
+
+static void GLAPIENTRY save_TexImage2D( GLenum target,
+ GLint level, GLint components,
+ GLsizei width, GLsizei height, GLint border,
+ GLenum format, GLenum type,
+ const GLvoid *pixels)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (target == GL_PROXY_TEXTURE_2D) {
+ /* don't compile, execute immediately */
+ CALL_TexImage2D(ctx->Exec, ( target, level, components, width,
+ height, border, format, type, pixels ));
+ }
+ else {
+ GLvoid *image = unpack_image(2, width, height, 1, format, type,
+ pixels, &ctx->Unpack);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE2D, 9 );
+ if (n) {
+ n[1].e = target;
+ n[2].i = level;
+ n[3].i = components;
+ n[4].i = (GLint) width;
+ n[5].i = (GLint) height;
+ n[6].i = border;
+ n[7].e = format;
+ n[8].e = type;
+ n[9].data = image;
+ }
+ else if (image) {
+ FREE(image);
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_TexImage2D(ctx->Exec, ( target, level, components, width,
+ height, border, format, type, pixels ));
+ }
+ }
+}
+
+
+static void GLAPIENTRY save_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);
+ if (target == GL_PROXY_TEXTURE_3D) {
+ /* don't compile, execute immediately */
+ CALL_TexImage3D(ctx->Exec, ( target, level, internalFormat, width,
+ height, depth, border, format, type, pixels ));
+ }
+ else {
+ Node *n;
+ GLvoid *image = unpack_image(3, width, height, depth, format, type,
+ pixels, &ctx->Unpack);
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_IMAGE3D, 10 );
+ if (n) {
+ n[1].e = target;
+ n[2].i = level;
+ n[3].i = (GLint) internalFormat;
+ n[4].i = (GLint) width;
+ n[5].i = (GLint) height;
+ n[6].i = (GLint) depth;
+ n[7].i = border;
+ n[8].e = format;
+ n[9].e = type;
+ n[10].data = image;
+ }
+ else if (image) {
+ FREE(image);
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_TexImage3D(ctx->Exec, ( target, level, internalFormat, width,
+ height, depth, border, format, type, pixels ));
+ }
+ }
+}
+
+
+static void GLAPIENTRY save_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
+ GLsizei width, GLenum format, GLenum type,
+ const GLvoid *pixels )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ GLvoid *image = unpack_image(1, width, 1, 1, format, type,
+ pixels, &ctx->Unpack);
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE1D, 7 );
+ 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].e = type;
+ n[7].data = image;
+ }
+ else if (image) {
+ FREE(image);
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_TexSubImage1D(ctx->Exec, ( target, level, xoffset, width,
+ format, type, pixels ));
+ }
+}
+
+
+static void GLAPIENTRY save_TexSubImage2D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *pixels )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ GLvoid *image = unpack_image(2, width, height, 1, format, type,
+ pixels, &ctx->Unpack);
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE2D, 9 );
+ 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].e = type;
+ n[9].data = image;
+ }
+ else if (image) {
+ FREE(image);
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_TexSubImage2D(ctx->Exec, ( target, level, xoffset, yoffset,
+ width, height, format, type, pixels ));
+ }
+}
+
+
+static void GLAPIENTRY save_TexSubImage3D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type,
+ const GLvoid *pixels )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ GLvoid *image = unpack_image(3, width, height, depth, format, type,
+ pixels, &ctx->Unpack);
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TEX_SUB_IMAGE3D, 11 );
+ 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].e = type;
+ n[11].data = image;
+ }
+ else if (image) {
+ FREE(image);
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_TexSubImage3D(ctx->Exec, ( target, level,
+ xoffset, yoffset, zoffset,
+ width, height, depth, format, type, pixels ));
+ }
+}
+
+
+static void GLAPIENTRY save_Translatef( GLfloat x, GLfloat y, GLfloat z )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TRANSLATE, 3 );
+ if (n) {
+ n[1].f = x;
+ n[2].f = y;
+ n[3].f = z;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Translatef(ctx->Exec, ( x, y, z ));
+ }
+}
+
+
+static void GLAPIENTRY save_Translated( GLdouble x, GLdouble y, GLdouble z )
+{
+ save_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z);
+}
+
+
+
+static void GLAPIENTRY save_Viewport( GLint x, GLint y, GLsizei width, GLsizei height )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_VIEWPORT, 4 );
+ if (n) {
+ n[1].i = x;
+ n[2].i = y;
+ n[3].i = (GLint) width;
+ n[4].i = (GLint) height;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Viewport(ctx->Exec, ( x, y, width, height ));
+ }
+}
+
+
+static void GLAPIENTRY save_WindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_WINDOW_POS, 4 );
+ if (n) {
+ n[1].f = x;
+ n[2].f = y;
+ n[3].f = z;
+ n[4].f = w;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_WindowPos4fMESA(ctx->Exec, ( x, y, z, w ));
+ }
+}
+
+static void GLAPIENTRY save_WindowPos2dMESA(GLdouble x, GLdouble y)
+{
+ save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
+}
+
+static void GLAPIENTRY save_WindowPos2fMESA(GLfloat x, GLfloat y)
+{
+ save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
+}
+
+static void GLAPIENTRY save_WindowPos2iMESA(GLint x, GLint y)
+{
+ save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
+}
+
+static void GLAPIENTRY save_WindowPos2sMESA(GLshort x, GLshort y)
+{
+ save_WindowPos4fMESA(x, y, 0.0F, 1.0F);
+}
+
+static void GLAPIENTRY save_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
+{
+ save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
+}
+
+static void GLAPIENTRY save_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
+{
+ save_WindowPos4fMESA(x, y, z, 1.0F);
+}
+
+static void GLAPIENTRY save_WindowPos3iMESA(GLint x, GLint y, GLint z)
+{
+ save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
+}
+
+static void GLAPIENTRY save_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
+{
+ save_WindowPos4fMESA(x, y, z, 1.0F);
+}
+
+static void GLAPIENTRY save_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
+}
+
+static void GLAPIENTRY save_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
+{
+ save_WindowPos4fMESA((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
+}
+
+static void GLAPIENTRY save_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
+{
+ save_WindowPos4fMESA(x, y, z, w);
+}
+
+static void GLAPIENTRY save_WindowPos2dvMESA(const GLdouble *v)
+{
+ save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
+}
+
+static void GLAPIENTRY save_WindowPos2fvMESA(const GLfloat *v)
+{
+ save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
+}
+
+static void GLAPIENTRY save_WindowPos2ivMESA(const GLint *v)
+{
+ save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
+}
+
+static void GLAPIENTRY save_WindowPos2svMESA(const GLshort *v)
+{
+ save_WindowPos4fMESA(v[0], v[1], 0.0F, 1.0F);
+}
+
+static void GLAPIENTRY save_WindowPos3dvMESA(const GLdouble *v)
+{
+ save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
+}
+
+static void GLAPIENTRY save_WindowPos3fvMESA(const GLfloat *v)
+{
+ save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
+}
+
+static void GLAPIENTRY save_WindowPos3ivMESA(const GLint *v)
+{
+ save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
+}
+
+static void GLAPIENTRY save_WindowPos3svMESA(const GLshort *v)
+{
+ save_WindowPos4fMESA(v[0], v[1], v[2], 1.0F);
+}
+
+static void GLAPIENTRY save_WindowPos4dvMESA(const GLdouble *v)
+{
+ save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
+ (GLfloat) v[2], (GLfloat) v[3]);
+}
+
+static void GLAPIENTRY save_WindowPos4fvMESA(const GLfloat *v)
+{
+ save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
+}
+
+static void GLAPIENTRY save_WindowPos4ivMESA(const GLint *v)
+{
+ save_WindowPos4fMESA((GLfloat) v[0], (GLfloat) v[1],
+ (GLfloat) v[2], (GLfloat) v[3]);
+}
+
+static void GLAPIENTRY save_WindowPos4svMESA(const GLshort *v)
+{
+ save_WindowPos4fMESA(v[0], v[1], v[2], v[3]);
+}
+
+
+
+/* GL_ARB_multitexture */
+static void GLAPIENTRY save_ActiveTextureARB( GLenum target )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_TEXTURE, 1 );
+ if (n) {
+ n[1].e = target;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ActiveTextureARB(ctx->Exec, ( target ));
+ }
+}
+
+
+/* GL_ARB_transpose_matrix */
+
+static void GLAPIENTRY save_LoadTransposeMatrixdARB( const GLdouble m[16] )
+{
+ GLfloat tm[16];
+ _math_transposefd(tm, m);
+ save_LoadMatrixf(tm);
+}
+
+
+static void GLAPIENTRY save_LoadTransposeMatrixfARB( const GLfloat m[16] )
+{
+ GLfloat tm[16];
+ _math_transposef(tm, m);
+ save_LoadMatrixf(tm);
+}
+
+
+static void GLAPIENTRY
+save_MultTransposeMatrixdARB( const GLdouble m[16] )
+{
+ GLfloat tm[16];
+ _math_transposefd(tm, m);
+ save_MultMatrixf(tm);
+}
+
+
+static void GLAPIENTRY
+save_MultTransposeMatrixfARB( const GLfloat m[16] )
+{
+ GLfloat tm[16];
+ _math_transposef(tm, m);
+ save_MultMatrixf(tm);
+}
+
+
+static void GLAPIENTRY
+save_PixelTexGenSGIX(GLenum mode)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TEXGEN_SGIX, 1 );
+ if (n) {
+ n[1].e = mode;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_PixelTexGenSGIX(ctx->Exec, ( mode ));
+ }
+}
+
+
+/* GL_ARB_texture_compression */
+static void GLAPIENTRY
+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 */
+ CALL_CompressedTexImage1DARB(ctx->Exec, (target, level, internalFormat,
+ width, border, imageSize, data));
+ }
+ else {
+ Node *n;
+ GLvoid *image;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ /* make copy of image */
+ image = MALLOC(imageSize);
+ if (!image) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB");
+ return;
+ }
+ MEMCPY(image, data, imageSize);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7 );
+ 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) {
+ CALL_CompressedTexImage1DARB(ctx->Exec, (target, level, internalFormat,
+ width, border, imageSize, data));
+ }
+ }
+}
+
+
+static void GLAPIENTRY
+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 */
+ CALL_CompressedTexImage2DARB(ctx->Exec, (target, level, internalFormat,
+ width, height, border, imageSize, data));
+ }
+ else {
+ Node *n;
+ GLvoid *image;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ /* make copy of image */
+ image = MALLOC(imageSize);
+ if (!image) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
+ return;
+ }
+ MEMCPY(image, data, imageSize);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8 );
+ 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) {
+ CALL_CompressedTexImage2DARB(ctx->Exec, (target, level, internalFormat,
+ width, height, border, imageSize, data));
+ }
+ }
+}
+
+
+static void GLAPIENTRY
+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 */
+ CALL_CompressedTexImage3DARB(ctx->Exec, (target, level, internalFormat,
+ width, height, depth, border, imageSize, data));
+ }
+ else {
+ Node *n;
+ GLvoid *image;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ /* make copy of image */
+ image = MALLOC(imageSize);
+ if (!image) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB");
+ return;
+ }
+ MEMCPY(image, data, imageSize);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 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 = (GLint) depth;
+ n[7].i = border;
+ n[8].i = imageSize;
+ n[9].data = image;
+ }
+ else if (image) {
+ FREE(image);
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_CompressedTexImage3DARB(ctx->Exec, (target, level, internalFormat,
+ width, height, depth, border, imageSize, data));
+ }
+ }
+}
+
+
+static void GLAPIENTRY
+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);
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+
+ /* make copy of image */
+ image = MALLOC(imageSize);
+ if (!image) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB");
+ return;
+ }
+ MEMCPY(image, data, imageSize);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7 );
+ 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) {
+ CALL_CompressedTexSubImage1DARB(ctx->Exec, (target, level, xoffset,
+ width, format, imageSize, data));
+ }
+}
+
+
+static void GLAPIENTRY
+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);
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+
+ /* make copy of image */
+ image = MALLOC(imageSize);
+ if (!image) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB");
+ return;
+ }
+ MEMCPY(image, data, imageSize);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9 );
+ 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) {
+ CALL_CompressedTexSubImage2DARB(ctx->Exec, (target, level, xoffset, yoffset,
+ width, height, format, imageSize, data));
+ }
+}
+
+
+static void GLAPIENTRY
+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);
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+
+ /* make copy of image */
+ image = MALLOC(imageSize);
+ if (!image) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB");
+ return;
+ }
+ MEMCPY(image, data, imageSize);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11 );
+ 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) {
+ CALL_CompressedTexSubImage3DARB(ctx->Exec, (target, level, xoffset, yoffset,
+ zoffset, width, height, depth, format, imageSize, data));
+ }
+}
+
+
+/* GL_ARB_multisample */
+static void GLAPIENTRY
+save_SampleCoverageARB(GLclampf value, GLboolean invert)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_SAMPLE_COVERAGE, 2 );
+ if (n) {
+ n[1].f = value;
+ n[2].b = invert;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_SampleCoverageARB(ctx->Exec, ( value, invert ));
+ }
+}
+
+
+/* GL_SGIS_pixel_texture */
+
+static void GLAPIENTRY
+save_PixelTexGenParameteriSGIS(GLenum target, GLint value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS, 2 );
+ if (n) {
+ n[1].e = target;
+ n[2].i = value;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_PixelTexGenParameteriSGIS(ctx->Exec, ( target, value ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_PixelTexGenParameterfSGIS(GLenum target, GLfloat value)
+{
+ save_PixelTexGenParameteriSGIS(target, (GLint) value);
+}
+
+
+static void GLAPIENTRY
+save_PixelTexGenParameterivSGIS(GLenum target, const GLint *value)
+{
+ save_PixelTexGenParameteriSGIS(target, *value);
+}
+
+
+static void GLAPIENTRY
+save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value)
+{
+ save_PixelTexGenParameteriSGIS(target, (GLint) *value);
+}
+
+
+/*
+ * GL_NV_vertex_program
+ */
+#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
+static void GLAPIENTRY
+save_BindProgramNV(GLenum target, GLuint id)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_BIND_PROGRAM_NV, 2 );
+ if (n) {
+ n[1].e = target;
+ n[2].ui = id;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_BindProgramNV(ctx->Exec, ( target, id ));
+ }
+}
+#endif /* FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */
+
+#if FEATURE_NV_vertex_program
+static void GLAPIENTRY
+save_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_EXECUTE_PROGRAM_NV, 6 );
+ if (n) {
+ n[1].e = target;
+ n[2].ui = id;
+ n[3].f = params[0];
+ n[4].f = params[1];
+ n[5].f = params[2];
+ n[6].f = params[3];
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ExecuteProgramNV(ctx->Exec, (target, id, params));
+ }
+}
+
+
+static void GLAPIENTRY
+save_ProgramParameter4fNV(GLenum target, GLuint index,
+ GLfloat x, GLfloat y,
+ GLfloat z, GLfloat w)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_PARAMETER4F_NV, 6 );
+ if (n) {
+ n[1].e = target;
+ n[2].ui = index;
+ n[3].f = x;
+ n[4].f = y;
+ n[5].f = z;
+ n[6].f = w;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ProgramParameter4fNV(ctx->Exec, (target, index, x, y, z, w));
+ }
+}
+
+
+static void GLAPIENTRY
+save_ProgramParameter4fvNV(GLenum target, GLuint index, const GLfloat *params)
+{
+ save_ProgramParameter4fNV(target, index, params[0], params[1],
+ params[2], params[3]);
+}
+
+
+static void GLAPIENTRY
+save_ProgramParameter4dNV(GLenum target, GLuint index,
+ GLdouble x, GLdouble y,
+ GLdouble z, GLdouble w)
+{
+ save_ProgramParameter4fNV(target, index, (GLfloat) x, (GLfloat) y,
+ (GLfloat) z, (GLfloat) w);
+}
+
+
+static void GLAPIENTRY
+save_ProgramParameter4dvNV(GLenum target, GLuint index,
+ const GLdouble *params)
+{
+ save_ProgramParameter4fNV(target, index, (GLfloat) params[0],
+ (GLfloat) params[1], (GLfloat) params[2],
+ (GLfloat) params[3]);
+}
+
+
+static void GLAPIENTRY
+save_ProgramParameters4dvNV(GLenum target, GLuint index,
+ GLuint num, const GLdouble *params)
+{
+ GLuint i;
+ for (i = 0; i < num; i++) {
+ save_ProgramParameter4dvNV(target, index + i, params + 4 * i);
+ }
+}
+
+
+static void GLAPIENTRY
+save_ProgramParameters4fvNV(GLenum target, GLuint index,
+ GLuint num, const GLfloat *params)
+{
+ GLuint i;
+ for (i = 0; i < num; i++) {
+ save_ProgramParameter4fvNV(target, index + i, params + 4 * i);
+ }
+}
+
+
+static void GLAPIENTRY
+save_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
+ const GLubyte *program)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ GLubyte *programCopy;
+
+ programCopy = (GLubyte *) _mesa_malloc(len);
+ if (!programCopy) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
+ return;
+ }
+ _mesa_memcpy(programCopy, program, len);
+
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_LOAD_PROGRAM_NV, 4 );
+ if (n) {
+ n[1].e = target;
+ n[2].ui = id;
+ n[3].i = len;
+ n[4].data = programCopy;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_LoadProgramNV(ctx->Exec, (target, id, len, program));
+ }
+}
+
+
+static void GLAPIENTRY
+save_RequestResidentProgramsNV(GLsizei num, const GLuint *ids)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ GLuint *idCopy = (GLuint *) _mesa_malloc(num * sizeof(GLuint));
+ if (!idCopy) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glRequestResidentProgramsNV");
+ return;
+ }
+ _mesa_memcpy(idCopy, ids, num * sizeof(GLuint));
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TRACK_MATRIX_NV, 2 );
+ if (n) {
+ n[1].i = num;
+ n[2].data = idCopy;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_RequestResidentProgramsNV(ctx->Exec, (num, ids));
+ }
+}
+
+
+static void GLAPIENTRY
+save_TrackMatrixNV(GLenum target, GLuint address,
+ GLenum matrix, GLenum transform)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_TRACK_MATRIX_NV, 4 );
+ if (n) {
+ n[1].e = target;
+ n[2].ui = address;
+ n[3].e = matrix;
+ n[4].e = transform;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_TrackMatrixNV(ctx->Exec, (target, address, matrix, transform));
+ }
+}
+#endif /* FEATURE_NV_vertex_program */
+
+
+/*
+ * GL_NV_fragment_program
+ */
+#if FEATURE_NV_fragment_program
+static void GLAPIENTRY
+save_ProgramLocalParameter4fARB(GLenum target, GLuint index,
+ GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6 );
+ if (n) {
+ n[1].e = target;
+ n[2].ui = index;
+ n[3].f = x;
+ n[4].f = y;
+ n[5].f = z;
+ n[6].f = w;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ProgramLocalParameter4fARB(ctx->Exec, (target, index, x, y, z, w));
+ }
+}
+
+
+static void GLAPIENTRY
+save_ProgramLocalParameter4fvARB(GLenum target, GLuint index,
+ const GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6 );
+ if (n) {
+ n[1].e = target;
+ n[2].ui = index;
+ n[3].f = params[0];
+ n[4].f = params[1];
+ n[5].f = params[2];
+ n[6].f = params[3];
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ProgramLocalParameter4fvARB(ctx->Exec, (target, index, params));
+ }
+}
+
+
+static void GLAPIENTRY
+save_ProgramLocalParameter4dARB(GLenum target, GLuint index,
+ GLdouble x, GLdouble y,
+ GLdouble z, GLdouble w)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6 );
+ if (n) {
+ n[1].e = target;
+ n[2].ui = index;
+ n[3].f = (GLfloat) x;
+ n[4].f = (GLfloat) y;
+ n[5].f = (GLfloat) z;
+ n[6].f = (GLfloat) w;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ProgramLocalParameter4dARB(ctx->Exec, (target, index, x, y, z, w));
+ }
+}
+
+
+static void GLAPIENTRY
+save_ProgramLocalParameter4dvARB(GLenum target, GLuint index,
+ const GLdouble *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_LOCAL_PARAMETER_ARB, 6 );
+ if (n) {
+ n[1].e = target;
+ n[2].ui = index;
+ n[3].f = (GLfloat) params[0];
+ n[4].f = (GLfloat) params[1];
+ n[5].f = (GLfloat) params[2];
+ n[6].f = (GLfloat) params[3];
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ProgramLocalParameter4dvARB(ctx->Exec, (target, index, params));
+ }
+}
+
+static void GLAPIENTRY
+save_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name,
+ GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ GLubyte *nameCopy = (GLubyte *) _mesa_malloc(len);
+ if (!nameCopy) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramNamedParameter4fNV");
+ return;
+ }
+ _mesa_memcpy(nameCopy, name, len);
+
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_NAMED_PARAMETER_NV, 6 );
+ if (n) {
+ n[1].ui = id;
+ n[2].i = len;
+ n[3].data = nameCopy;
+ n[4].f = x;
+ n[5].f = y;
+ n[6].f = z;
+ n[7].f = w;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ProgramNamedParameter4fNV(ctx->Exec, (id, len, name, x, y, z, w));
+ }
+}
+
+
+static void GLAPIENTRY
+save_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte *name,
+ const float v[])
+{
+ save_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]);
+}
+
+
+static void GLAPIENTRY
+save_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte *name,
+ GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) x, (GLfloat) y,
+ (GLfloat) z,(GLfloat) w);
+}
+
+
+static void GLAPIENTRY
+save_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte *name,
+ const double v[])
+{
+ save_ProgramNamedParameter4fNV(id, len, name, (GLfloat) v[0],
+ (GLfloat) v[1], (GLfloat) v[2],
+ (GLfloat) v[3]);
+}
+
+#endif /* FEATURE_NV_fragment_program */
+
+
+
+/* GL_EXT_stencil_two_side */
+static void GLAPIENTRY save_ActiveStencilFaceEXT( GLenum face )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ACTIVE_STENCIL_FACE_EXT, 1 );
+ if (n) {
+ n[1].e = face;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ActiveStencilFaceEXT(ctx->Exec, ( face ));
+ }
+}
+
+
+/* GL_EXT_depth_bounds_test */
+static void GLAPIENTRY save_DepthBoundsEXT( GLclampd zmin, GLclampd zmax )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_DEPTH_BOUNDS_EXT, 2 );
+ if (n) {
+ n[1].f = (GLfloat) zmin;
+ n[2].f = (GLfloat) zmax;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_DepthBoundsEXT(ctx->Exec, ( zmin, zmax ));
+ }
+}
+
+
+
+#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
+
+static void GLAPIENTRY
+save_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
+ const GLvoid *string)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ GLubyte *programCopy;
+
+ programCopy = (GLubyte *) _mesa_malloc(len);
+ if (!programCopy) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glProgramStringARB");
+ return;
+ }
+ _mesa_memcpy(programCopy, string, len);
+
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_STRING_ARB, 4 );
+ if (n) {
+ n[1].e = target;
+ n[2].e = format;
+ n[3].i = len;
+ n[4].data = programCopy;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ProgramStringARB(ctx->Exec, (target, format, len, string));
+ }
+}
+
+
+static void GLAPIENTRY
+save_ProgramEnvParameter4fARB(GLenum target, GLuint index,
+ GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_PROGRAM_ENV_PARAMETER_ARB, 6 );
+ if (n) {
+ n[1].e = target;
+ n[2].ui = index;
+ n[3].f = x;
+ n[4].f = y;
+ n[5].f = z;
+ n[6].f = w;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_ProgramEnvParameter4fARB(ctx->Exec, ( target, index, x, y, z, w));
+ }
+}
+
+
+static void GLAPIENTRY
+save_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
+ const GLfloat *params)
+{
+ save_ProgramEnvParameter4fARB(target, index, params[0], params[1],
+ params[2], params[3]);
+}
+
+
+static void GLAPIENTRY
+save_ProgramEnvParameter4dARB(GLenum target, GLuint index,
+ GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ save_ProgramEnvParameter4fARB(target, index,
+ (GLfloat) x,
+ (GLfloat) y,
+ (GLfloat) z,
+ (GLfloat) w);
+}
+
+
+static void GLAPIENTRY
+save_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
+ const GLdouble *params)
+{
+ save_ProgramEnvParameter4fARB(target, index,
+ (GLfloat) params[0],
+ (GLfloat) params[1],
+ (GLfloat) params[2],
+ (GLfloat) params[3]);
+}
+
+#endif /* FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program */
+
+
+#ifdef FEATURE_ARB_occlusion_query
+
+static void GLAPIENTRY
+save_BeginQueryARB(GLenum target, GLuint id)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_BEGIN_QUERY_ARB, 2 );
+ if (n) {
+ n[1].e = target;
+ n[2].ui = id;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_BeginQueryARB(ctx->Exec, ( target, id ));
+ }
+}
+
+
+static void GLAPIENTRY
+save_EndQueryARB(GLenum target)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_END_QUERY_ARB, 1 );
+ if (n) {
+ n[1].e = target;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_EndQueryARB(ctx->Exec, ( target ));
+ }
+}
+
+#endif /* FEATURE_ARB_occlusion_query */
+
+
+static void GLAPIENTRY
+save_DrawBuffersARB(GLsizei count, const GLenum *buffers)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_DRAW_BUFFERS_ARB, 1 + MAX_DRAW_BUFFERS );
+ if (n) {
+ GLint i;
+ n[1].i = count;
+ if (count > MAX_DRAW_BUFFERS)
+ count = MAX_DRAW_BUFFERS;
+ for (i = 0; i < count; i++) {
+ n[2 + i].e = buffers[i];
+ }
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_DrawBuffersARB(ctx->Exec, (count, buffers));
+ }
+}
+
+#if FEATURE_ATI_fragment_shader
+static void GLAPIENTRY
+save_BindFragmentShaderATI(GLuint id)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_BIND_FRAGMENT_SHADER_ATI, 1);
+ if (n) {
+ n[1].ui = id;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_BindFragmentShaderATI(ctx->Exec, (id));
+ }
+}
+
+static void GLAPIENTRY
+save_SetFragmentShaderConstantATI(GLuint dst, const GLfloat *value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI, 5);
+ if (n) {
+ n[1].ui = dst;
+ n[2].f = value[0];
+ n[3].f = value[1];
+ n[4].f = value[2];
+ n[5].f = value[3];
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, value));
+ }
+}
+#endif
+
+static void save_Attr1fNV( GLenum attr, GLfloat x )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ SAVE_FLUSH_VERTICES( ctx );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_1F_NV, 2 );
+ if (n) {
+ n[1].e = attr;
+ n[2].f = x;
+ }
+
+ ASSERT(attr < VERT_ATTRIB_MAX);
+ ctx->ListState.ActiveAttribSize[attr] = 1;
+ ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
+
+ if (ctx->ExecuteFlag) {
+ CALL_VertexAttrib1fNV(ctx->Exec, ( attr, x ));
+ }
+}
+
+static void save_Attr2fNV( GLenum attr, GLfloat x, GLfloat y )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ SAVE_FLUSH_VERTICES( ctx );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_2F_NV, 3 );
+ if (n) {
+ n[1].e = attr;
+ n[2].f = x;
+ n[3].f = y;
+ }
+
+ ASSERT(attr < VERT_ATTRIB_MAX);
+ ctx->ListState.ActiveAttribSize[attr] = 2;
+ ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
+
+ if (ctx->ExecuteFlag) {
+ CALL_VertexAttrib2fNV(ctx->Exec, ( attr, x, y ));
+ }
+}
+
+static void save_Attr3fNV( GLenum attr, GLfloat x, GLfloat y, GLfloat z )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ SAVE_FLUSH_VERTICES( ctx );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_3F_NV, 4 );
+ if (n) {
+ n[1].e = attr;
+ n[2].f = x;
+ n[3].f = y;
+ n[4].f = z;
+ }
+
+ ASSERT(attr < VERT_ATTRIB_MAX);
+ ctx->ListState.ActiveAttribSize[attr] = 3;
+ ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
+
+ if (ctx->ExecuteFlag) {
+ CALL_VertexAttrib3fNV(ctx->Exec, ( attr, x, y, z ));
+ }
+}
+
+static void save_Attr4fNV( GLenum attr, GLfloat x, GLfloat y, GLfloat z,
+ GLfloat w )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ SAVE_FLUSH_VERTICES( ctx );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_4F_NV, 5 );
+ if (n) {
+ n[1].e = attr;
+ n[2].f = x;
+ n[3].f = y;
+ n[4].f = z;
+ n[5].f = w;
+ }
+
+ ASSERT(attr < VERT_ATTRIB_MAX);
+ ctx->ListState.ActiveAttribSize[attr] = 4;
+ ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, z, w);
+
+ if (ctx->ExecuteFlag) {
+ CALL_VertexAttrib4fNV(ctx->Exec, ( attr, x, y, z, w ));
+ }
+}
+
+
+static void save_Attr1fARB( GLenum attr, GLfloat x )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ SAVE_FLUSH_VERTICES( ctx );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_1F_ARB, 2 );
+ if (n) {
+ n[1].e = attr;
+ n[2].f = x;
+ }
+
+ ASSERT(attr < VERT_ATTRIB_MAX);
+ ctx->ListState.ActiveAttribSize[attr] = 1;
+ ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, 0, 0, 1);
+
+ if (ctx->ExecuteFlag) {
+ CALL_VertexAttrib1fARB(ctx->Exec, ( attr, x ));
+ }
+}
+
+static void save_Attr2fARB( GLenum attr, GLfloat x, GLfloat y )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ SAVE_FLUSH_VERTICES( ctx );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_2F_ARB, 3 );
+ if (n) {
+ n[1].e = attr;
+ n[2].f = x;
+ n[3].f = y;
+ }
+
+ ASSERT(attr < VERT_ATTRIB_MAX);
+ ctx->ListState.ActiveAttribSize[attr] = 2;
+ ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, 0, 1);
+
+ if (ctx->ExecuteFlag) {
+ CALL_VertexAttrib2fARB(ctx->Exec, ( attr, x, y ));
+ }
+}
+
+static void save_Attr3fARB( GLenum attr, GLfloat x, GLfloat y, GLfloat z )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ SAVE_FLUSH_VERTICES( ctx );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_3F_ARB, 4 );
+ if (n) {
+ n[1].e = attr;
+ n[2].f = x;
+ n[3].f = y;
+ n[4].f = z;
+ }
+
+ ASSERT(attr < VERT_ATTRIB_MAX);
+ ctx->ListState.ActiveAttribSize[attr] = 3;
+ ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, z, 1);
+
+ if (ctx->ExecuteFlag) {
+ CALL_VertexAttrib3fARB(ctx->Exec, ( attr, x, y, z ));
+ }
+}
+
+static void save_Attr4fARB( GLenum attr, GLfloat x, GLfloat y, GLfloat z,
+ GLfloat w )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ SAVE_FLUSH_VERTICES( ctx );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ATTR_4F_ARB, 5 );
+ if (n) {
+ n[1].e = attr;
+ n[2].f = x;
+ n[3].f = y;
+ n[4].f = z;
+ n[5].f = w;
+ }
+
+ ASSERT(attr < VERT_ATTRIB_MAX);
+ ctx->ListState.ActiveAttribSize[attr] = 4;
+ ASSIGN_4V( ctx->ListState.CurrentAttrib[attr], x, y, z, w);
+
+ if (ctx->ExecuteFlag) {
+ CALL_VertexAttrib4fARB(ctx->Exec, ( attr, x, y, z, w ));
+ }
+}
+
+
+static void GLAPIENTRY save_EvalCoord1f( GLfloat x )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ SAVE_FLUSH_VERTICES( ctx );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_C1, 1 );
+ if (n) {
+ n[1].f = x;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_EvalCoord1f(ctx->Exec, ( x ));
+ }
+}
+
+static void GLAPIENTRY save_EvalCoord1fv( const GLfloat *v )
+{
+ save_EvalCoord1f( v[0] );
+}
+
+static void GLAPIENTRY save_EvalCoord2f( GLfloat x, GLfloat y )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ SAVE_FLUSH_VERTICES( ctx );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_C2, 2 );
+ if (n) {
+ n[1].f = x;
+ n[2].f = y;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_EvalCoord2f(ctx->Exec, ( x, y ));
+ }
+}
+
+static void GLAPIENTRY save_EvalCoord2fv( const GLfloat *v )
+{
+ save_EvalCoord2f( v[0], v[1] );
+}
+
+
+static void GLAPIENTRY save_EvalPoint1( GLint x )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ SAVE_FLUSH_VERTICES( ctx );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_P1, 1 );
+ if (n) {
+ n[1].i = x;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_EvalPoint1(ctx->Exec, ( x ));
+ }
+}
+
+static void GLAPIENTRY save_EvalPoint2( GLint x, GLint y )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ SAVE_FLUSH_VERTICES( ctx );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_EVAL_P2, 2 );
+ if (n) {
+ n[1].i = x;
+ n[2].i = y;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_EvalPoint2(ctx->Exec, ( x, y ));
+ }
+}
+
+static void GLAPIENTRY save_Indexf( GLfloat x )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ SAVE_FLUSH_VERTICES( ctx );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_INDEX, 1 );
+ if (n) {
+ n[1].f = x;
+ }
+
+ ctx->ListState.ActiveIndex = 1;
+ ctx->ListState.CurrentIndex = x;
+
+ if (ctx->ExecuteFlag) {
+ CALL_Indexi(ctx->Exec, ( (GLint) x ));
+ }
+}
+
+static void GLAPIENTRY save_Indexfv( const GLfloat *v )
+{
+ save_Indexf( v[0] );
+}
+
+static void GLAPIENTRY save_EdgeFlag( GLboolean x )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ SAVE_FLUSH_VERTICES( ctx );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_EDGEFLAG, 1 );
+ if (n) {
+ n[1].b = x;
+ }
+
+ ctx->ListState.ActiveEdgeFlag = 1;
+ ctx->ListState.CurrentEdgeFlag = x;
+
+ if (ctx->ExecuteFlag) {
+ CALL_EdgeFlag(ctx->Exec, ( x ));
+ }
+}
+
+static void GLAPIENTRY save_EdgeFlagv( const GLboolean *v )
+{
+ save_EdgeFlag( v[0] );
+}
+
+static void GLAPIENTRY save_Materialfv( GLenum face, GLenum pname, const GLfloat *param )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ int args, i;
+
+ SAVE_FLUSH_VERTICES( ctx );
+
+ switch (face) {
+ case GL_BACK:
+ case GL_FRONT:
+ case GL_FRONT_AND_BACK:
+ break;
+ default:
+ _mesa_compile_error( ctx, GL_INVALID_ENUM, "material(face)" );
+ return;
+ }
+
+ switch (pname) {
+ case GL_EMISSION:
+ case GL_AMBIENT:
+ case GL_DIFFUSE:
+ case GL_SPECULAR:
+ case GL_AMBIENT_AND_DIFFUSE:
+ args = 4;
+ break;
+ case GL_SHININESS:
+ args = 1;
+ break;
+ case GL_COLOR_INDEXES:
+ args = 3;
+ break;
+ default:
+ _mesa_compile_error( ctx, GL_INVALID_ENUM, "material(pname)" );
+ return;
+ }
+
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_MATERIAL, 6 );
+ if (n) {
+ n[1].e = face;
+ n[2].e = pname;
+ for (i = 0 ; i < args ; i++)
+ n[3+i].f = param[i];
+ }
+
+ {
+ GLuint bitmask = _mesa_material_bitmask( ctx, face, pname, ~0, NULL );
+ for (i = 0 ; i < MAT_ATTRIB_MAX ; i++)
+ if (bitmask & (1<<i)) {
+ ctx->ListState.ActiveMaterialSize[i] = args;
+ COPY_SZ_4V( ctx->ListState.CurrentMaterial[i], args, param );
+ }
+ }
+
+ if (ctx->ExecuteFlag) {
+ CALL_Materialfv(ctx->Exec, ( face, pname, param ));
+ }
+}
+
+static void GLAPIENTRY save_Begin( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ GLboolean error = GL_FALSE;
+
+ if (/*mode < GL_POINTS ||*/ mode > GL_POLYGON) {
+ _mesa_compile_error( ctx, GL_INVALID_ENUM, "Begin (mode)");
+ error = GL_TRUE;
+ }
+ else if (ctx->Driver.CurrentSavePrimitive == PRIM_UNKNOWN) {
+ /* Typically the first begin. This may raise an error on
+ * playback, depending on whether CallList is issued from inside
+ * a begin/end or not.
+ */
+ ctx->Driver.CurrentSavePrimitive = PRIM_INSIDE_UNKNOWN_PRIM;
+ }
+ else if (ctx->Driver.CurrentSavePrimitive == PRIM_OUTSIDE_BEGIN_END) {
+ ctx->Driver.CurrentSavePrimitive = mode;
+ }
+ else {
+ _mesa_compile_error( ctx, GL_INVALID_OPERATION, "recursive begin" );
+ error = GL_TRUE;
+ }
+
+ if (!error) {
+ /* Give the driver an opportunity to hook in an optimized
+ * display list compiler.
+ */
+ if (ctx->Driver.NotifySaveBegin( ctx, mode ))
+ return;
+
+ SAVE_FLUSH_VERTICES( ctx );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_BEGIN, 1 );
+ if (n) {
+ n[1].e = mode;
+ }
+ }
+
+ if (ctx->ExecuteFlag) {
+ CALL_Begin(ctx->Exec, ( mode ));
+ }
+}
+
+static void GLAPIENTRY save_End( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ SAVE_FLUSH_VERTICES( ctx );
+ (void) ALLOC_INSTRUCTION( ctx, OPCODE_END, 0 );
+ ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
+ if (ctx->ExecuteFlag) {
+ CALL_End(ctx->Exec, ( ));
+ }
+}
+
+static void GLAPIENTRY save_Rectf( GLfloat a, GLfloat b, GLfloat c, GLfloat d )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ Node *n;
+ SAVE_FLUSH_VERTICES( ctx );
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_RECTF, 4 );
+ if (n) {
+ n[1].f = a;
+ n[2].f = b;
+ n[3].f = c;
+ n[4].f = d;
+ }
+ if (ctx->ExecuteFlag) {
+ CALL_Rectf(ctx->Exec, ( a, b, c, d ));
+ }
+}
+
+
+static void GLAPIENTRY save_Vertex2f( GLfloat x, GLfloat y )
+{
+ save_Attr2fNV( VERT_ATTRIB_POS, x, y );
+}
+
+static void GLAPIENTRY save_Vertex2fv( const GLfloat *v )
+{
+ save_Attr2fNV( VERT_ATTRIB_POS, v[0], v[1] );
+}
+
+static void GLAPIENTRY save_Vertex3f( GLfloat x, GLfloat y, GLfloat z )
+{
+ save_Attr3fNV( VERT_ATTRIB_POS, x, y, z );
+}
+
+static void GLAPIENTRY save_Vertex3fv( const GLfloat *v )
+{
+ save_Attr3fNV( VERT_ATTRIB_POS, v[0], v[1], v[2] );
+}
+
+static void GLAPIENTRY save_Vertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+ save_Attr4fNV( VERT_ATTRIB_POS, x, y, z, w );
+}
+
+static void GLAPIENTRY save_Vertex4fv( const GLfloat *v )
+{
+ save_Attr4fNV( VERT_ATTRIB_POS, v[0], v[1], v[2], v[3] );
+}
+
+static void GLAPIENTRY save_TexCoord1f( GLfloat x )
+{
+ save_Attr1fNV( VERT_ATTRIB_TEX0, x );
+}
+
+static void GLAPIENTRY save_TexCoord1fv( const GLfloat *v )
+{
+ save_Attr1fNV( VERT_ATTRIB_TEX0, v[0] );
+}
+
+static void GLAPIENTRY save_TexCoord2f( GLfloat x, GLfloat y )
+{
+ save_Attr2fNV( VERT_ATTRIB_TEX0, x, y );
+}
+
+static void GLAPIENTRY save_TexCoord2fv( const GLfloat *v )
+{
+ save_Attr2fNV( VERT_ATTRIB_TEX0, v[0], v[1] );
+}
+
+static void GLAPIENTRY save_TexCoord3f( GLfloat x, GLfloat y, GLfloat z )
+{
+ save_Attr3fNV( VERT_ATTRIB_TEX0, x, y, z );
+}
+
+static void GLAPIENTRY save_TexCoord3fv( const GLfloat *v )
+{
+ save_Attr3fNV( VERT_ATTRIB_TEX0, v[0], v[1], v[2] );
+}
+
+static void GLAPIENTRY save_TexCoord4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+ save_Attr4fNV( VERT_ATTRIB_TEX0, x, y, z, w );
+}
+
+static void GLAPIENTRY save_TexCoord4fv( const GLfloat *v )
+{
+ save_Attr4fNV( VERT_ATTRIB_TEX0, v[0], v[1], v[2], v[3] );
+}
+
+static void GLAPIENTRY save_Normal3f( GLfloat x, GLfloat y, GLfloat z )
+{
+ save_Attr3fNV( VERT_ATTRIB_NORMAL, x, y, z );
+}
+
+static void GLAPIENTRY save_Normal3fv( const GLfloat *v )
+{
+ save_Attr3fNV( VERT_ATTRIB_NORMAL, v[0], v[1], v[2] );
+}
+
+static void GLAPIENTRY save_FogCoordfEXT( GLfloat x )
+{
+ save_Attr1fNV( VERT_ATTRIB_FOG, x );
+}
+
+static void GLAPIENTRY save_FogCoordfvEXT( const GLfloat *v )
+{
+ save_Attr1fNV( VERT_ATTRIB_FOG, v[0] );
+}
+
+static void GLAPIENTRY save_Color3f( GLfloat x, GLfloat y, GLfloat z )
+{
+ save_Attr3fNV( VERT_ATTRIB_COLOR0, x, y, z );
+}
+
+static void GLAPIENTRY save_Color3fv( const GLfloat *v )
+{
+ save_Attr3fNV( VERT_ATTRIB_COLOR0, v[0], v[1], v[2] );
+}
+
+static void GLAPIENTRY save_Color4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+ save_Attr4fNV( VERT_ATTRIB_COLOR0, x, y, z, w );
+}
+
+static void GLAPIENTRY save_Color4fv( const GLfloat *v )
+{
+ save_Attr4fNV( VERT_ATTRIB_COLOR0, v[0], v[1], v[2], v[3] );
+}
+
+static void GLAPIENTRY save_SecondaryColor3fEXT( GLfloat x, GLfloat y, GLfloat z )
+{
+ save_Attr3fNV( VERT_ATTRIB_COLOR1, x, y, z );
+}
+
+static void GLAPIENTRY save_SecondaryColor3fvEXT( const GLfloat *v )
+{
+ save_Attr3fNV( VERT_ATTRIB_COLOR1, v[0], v[1], v[2] );
+}
+
+
+/* Just call the respective ATTR for texcoord
+ */
+static void GLAPIENTRY save_MultiTexCoord1f( GLenum target, GLfloat x )
+{
+ GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+ save_Attr1fNV( attr, x );
+}
+
+static void GLAPIENTRY save_MultiTexCoord1fv( GLenum target, const GLfloat *v )
+{
+ GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+ save_Attr1fNV( attr, v[0] );
+}
+
+static void GLAPIENTRY save_MultiTexCoord2f( GLenum target, GLfloat x, GLfloat y )
+{
+ GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+ save_Attr2fNV( attr, x, y );
+}
+
+static void GLAPIENTRY save_MultiTexCoord2fv( GLenum target, const GLfloat *v )
+{
+ GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+ save_Attr2fNV( attr, v[0], v[1] );
+}
+
+static void GLAPIENTRY save_MultiTexCoord3f( GLenum target, GLfloat x, GLfloat y,
+ GLfloat z)
+{
+ GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+ save_Attr3fNV( attr, x, y, z );
+}
+
+static void GLAPIENTRY save_MultiTexCoord3fv( GLenum target, const GLfloat *v )
+{
+ GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+ save_Attr3fNV( attr, v[0], v[1], v[2] );
+}
+
+static void GLAPIENTRY save_MultiTexCoord4f( GLenum target, GLfloat x, GLfloat y,
+ GLfloat z, GLfloat w )
+{
+ GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+ save_Attr4fNV( attr, x, y, z, w );
+}
+
+static void GLAPIENTRY save_MultiTexCoord4fv( GLenum target, const GLfloat *v )
+{
+ GLuint attr = (target & 0x7) + VERT_ATTRIB_TEX0;
+ save_Attr4fNV( attr, v[0], v[1], v[2], v[3] );
+}
+
+
+static void enum_error( void )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ _mesa_error( ctx, GL_INVALID_ENUM, "VertexAttribfNV" );
+}
+
+/* First level for NV_vertex_program:
+ *
+ * Check for errors at compile time?.
+ */
+static void GLAPIENTRY save_VertexAttrib1fNV( GLuint index, GLfloat x )
+{
+ if (index < VERT_ATTRIB_MAX)
+ save_Attr1fNV( index, x );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib1fvNV( GLuint index, const GLfloat *v )
+{
+ if (index < VERT_ATTRIB_MAX)
+ save_Attr1fNV( index, v[0] );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y )
+{
+ if (index < VERT_ATTRIB_MAX)
+ save_Attr2fNV( index, x, y );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib2fvNV( GLuint index, const GLfloat *v )
+{
+ if (index < VERT_ATTRIB_MAX)
+ save_Attr2fNV( index, v[0], v[1] );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib3fNV( GLuint index, GLfloat x, GLfloat y,
+ GLfloat z )
+{
+ if (index < VERT_ATTRIB_MAX)
+ save_Attr3fNV( index, x, y, z );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib3fvNV( GLuint index, const GLfloat *v )
+{
+ if (index < VERT_ATTRIB_MAX)
+ save_Attr3fNV( index, v[0], v[1], v[2] );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y,
+ GLfloat z, GLfloat w )
+{
+ if (index < VERT_ATTRIB_MAX)
+ save_Attr4fNV( index, x, y, z, w );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY save_VertexAttrib4fvNV( GLuint index, const GLfloat *v )
+{
+ if (index < VERT_ATTRIB_MAX)
+ save_Attr4fNV( index, v[0], v[1], v[2], v[3] );
+ else
+ enum_error();
+}
+
+
+
+
+static void GLAPIENTRY
+save_VertexAttrib1fARB( GLuint index, GLfloat x )
+{
+ if (index < VERT_ATTRIB_MAX)
+ save_Attr1fARB( index, x );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY
+save_VertexAttrib1fvARB( GLuint index, const GLfloat *v )
+{
+ if (index < VERT_ATTRIB_MAX)
+ save_Attr1fARB( index, v[0] );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY
+save_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y )
+{
+ if (index < VERT_ATTRIB_MAX)
+ save_Attr2fARB( index, x, y );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY
+save_VertexAttrib2fvARB( GLuint index, const GLfloat *v )
+{
+ if (index < VERT_ATTRIB_MAX)
+ save_Attr2fARB( index, v[0], v[1] );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY
+save_VertexAttrib3fARB( GLuint index, GLfloat x, GLfloat y, GLfloat z )
+{
+ if (index < VERT_ATTRIB_MAX)
+ save_Attr3fARB( index, x, y, z );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY
+save_VertexAttrib3fvARB( GLuint index, const GLfloat *v )
+{
+ if (index < VERT_ATTRIB_MAX)
+ save_Attr3fARB( index, v[0], v[1], v[2] );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY
+save_VertexAttrib4fARB( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+ if (index < VERT_ATTRIB_MAX)
+ save_Attr4fARB( index, x, y, z, w );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY
+save_VertexAttrib4fvARB( GLuint index, const GLfloat *v )
+{
+ if (index < VERT_ATTRIB_MAX)
+ save_Attr4fARB( index, v[0], v[1], v[2], v[3] );
+ else
+ enum_error();
+}
+
+
+
+
+
+/* KW: Compile commands
+ *
+ * Will appear in the list before the vertex buffer containing the
+ * command that provoked the error. I don't see this as a problem.
+ */
+void
+_mesa_save_error( GLcontext *ctx, GLenum error, const char *s )
+{
+ Node *n;
+ n = ALLOC_INSTRUCTION( ctx, OPCODE_ERROR, 2 );
+ if (n) {
+ n[1].e = error;
+ n[2].data = (void *) s;
+ }
+ /* execute already done */
+}
+
+
+/*
+ * Compile an error into current display list.
+ */
+void
+_mesa_compile_error( GLcontext *ctx, GLenum error, const char *s )
+{
+ if (ctx->CompileFlag)
+ _mesa_save_error( ctx, error, s );
+
+ if (ctx->ExecuteFlag)
+ _mesa_error( ctx, error, s );
+}
+
+
+
+static GLboolean
+islist(GLcontext *ctx, GLuint list)
+{
+ if (list > 0 && _mesa_HashLookup(ctx->Shared->DisplayList, list)) {
+ return GL_TRUE;
+ }
+ else {
+ return GL_FALSE;
+ }
+}
+
+
+
+/**********************************************************************/
+/* Display list execution */
+/**********************************************************************/
+
+
+/*
+ * Execute a display list. Note that the ListBase offset must have already
+ * been added before calling this function. I.e. the list argument is
+ * the absolute list number, not relative to ListBase.
+ * \param list - display list number
+ */
+static void GLAPIENTRY
+execute_list( GLcontext *ctx, GLuint list )
+{
+ struct mesa_display_list *dlist;
+ Node *n;
+ GLboolean done;
+
+ if (list == 0 || !islist(ctx,list))
+ return;
+
+ if (ctx->ListState.CallDepth == MAX_LIST_NESTING) {
+ /* raise an error? */
+ return;
+ }
+
+
+ dlist = (struct mesa_display_list *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
+ if (!dlist)
+ return;
+
+ ctx->ListState.CallStack[ctx->ListState.CallDepth++] = dlist;
+
+ if (ctx->Driver.BeginCallList)
+ ctx->Driver.BeginCallList( ctx, dlist );
+
+ n = dlist->node;
+
+ done = GL_FALSE;
+ while (!done) {
+ OpCode opcode = n[0].opcode;
+ int i = (int)n[0].opcode - (int)OPCODE_EXT_0;
+
+ if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
+ /* this is a driver-extended opcode */
+ ctx->ListExt.Opcode[i].Execute(ctx, &n[1]);
+ n += ctx->ListExt.Opcode[i].Size;
+ }
+ else {
+ switch (opcode) {
+ case OPCODE_ERROR:
+ _mesa_error( ctx, n[1].e, (const char *) n[2].data );
+ break;
+ case OPCODE_ACCUM:
+ CALL_Accum(ctx->Exec, ( n[1].e, n[2].f ));
+ break;
+ case OPCODE_ALPHA_FUNC:
+ CALL_AlphaFunc(ctx->Exec, ( n[1].e, n[2].f ));
+ break;
+ case OPCODE_BIND_TEXTURE:
+ CALL_BindTexture(ctx->Exec, ( n[1].e, n[2].ui ));
+ break;
+ case OPCODE_BITMAP:
+ {
+ const struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = ctx->DefaultPacking;
+ CALL_Bitmap(ctx->Exec, ( (GLsizei) n[1].i, (GLsizei) n[2].i,
+ n[3].f, n[4].f, n[5].f, n[6].f, (const GLubyte *) n[7].data ));
+ ctx->Unpack = save; /* restore */
+ }
+ break;
+ case OPCODE_BLEND_COLOR:
+ CALL_BlendColor(ctx->Exec, ( n[1].f, n[2].f, n[3].f, n[4].f ));
+ break;
+ case OPCODE_BLEND_EQUATION:
+ CALL_BlendEquation(ctx->Exec, ( n[1].e ));
+ break;
+ case OPCODE_BLEND_EQUATION_SEPARATE:
+ CALL_BlendEquationSeparateEXT(ctx->Exec, ( n[1].e, n[2].e ));
+ break;
+ case OPCODE_BLEND_FUNC_SEPARATE:
+ CALL_BlendFuncSeparateEXT(ctx->Exec, (n[1].e, n[2].e, n[3].e, n[4].e));
+ break;
+ case OPCODE_CALL_LIST:
+ /* Generated by glCallList(), don't add ListBase */
+ if (ctx->ListState.CallDepth<MAX_LIST_NESTING) {
+ execute_list( ctx, n[1].ui );
+ }
+ break;
+ case OPCODE_CALL_LIST_OFFSET:
+ /* Generated by glCallLists() so we must add ListBase */
+ if (n[2].b) {
+ /* user specified a bad data type at compile time */
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
+ }
+ else if (ctx->ListState.CallDepth < MAX_LIST_NESTING) {
+ execute_list( ctx, ctx->List.ListBase + n[1].ui );
+ }
+ break;
+ case OPCODE_CLEAR:
+ CALL_Clear(ctx->Exec, ( n[1].bf ));
+ break;
+ case OPCODE_CLEAR_COLOR:
+ CALL_ClearColor(ctx->Exec, ( n[1].f, n[2].f, n[3].f, n[4].f ));
+ break;
+ case OPCODE_CLEAR_ACCUM:
+ CALL_ClearAccum(ctx->Exec, ( n[1].f, n[2].f, n[3].f, n[4].f ));
+ break;
+ case OPCODE_CLEAR_DEPTH:
+ CALL_ClearDepth(ctx->Exec, ( (GLclampd) n[1].f ));
+ break;
+ case OPCODE_CLEAR_INDEX:
+ CALL_ClearIndex(ctx->Exec, ( (GLfloat) n[1].ui ));
+ break;
+ case OPCODE_CLEAR_STENCIL:
+ CALL_ClearStencil(ctx->Exec, ( n[1].i ));
+ break;
+ case OPCODE_CLIP_PLANE:
+ {
+ GLdouble eq[4];
+ eq[0] = n[2].f;
+ eq[1] = n[3].f;
+ eq[2] = n[4].f;
+ eq[3] = n[5].f;
+ CALL_ClipPlane(ctx->Exec, ( n[1].e, eq ));
+ }
+ break;
+ case OPCODE_COLOR_MASK:
+ CALL_ColorMask(ctx->Exec, ( n[1].b, n[2].b, n[3].b, n[4].b ));
+ break;
+ case OPCODE_COLOR_MATERIAL:
+ CALL_ColorMaterial(ctx->Exec, ( n[1].e, n[2].e ));
+ break;
+ case OPCODE_COLOR_TABLE:
+ {
+ const struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = ctx->DefaultPacking;
+ CALL_ColorTable(ctx->Exec, ( n[1].e, n[2].e, n[3].i, n[4].e,
+ n[5].e, n[6].data ));
+ 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;
+ CALL_ColorTableParameterfv(ctx->Exec, ( 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;
+ CALL_ColorTableParameteriv(ctx->Exec, ( n[1].e, n[2].e, params ));
+ }
+ break;
+ case OPCODE_COLOR_SUB_TABLE:
+ {
+ const struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = ctx->DefaultPacking;
+ CALL_ColorSubTable(ctx->Exec, ( 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_1D:
+ {
+ const struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = ctx->DefaultPacking;
+ CALL_ConvolutionFilter1D(ctx->Exec, ( 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:
+ {
+ const struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = ctx->DefaultPacking;
+ CALL_ConvolutionFilter2D(ctx->Exec, ( 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:
+ CALL_ConvolutionParameteri(ctx->Exec, ( 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;
+ CALL_ConvolutionParameteriv(ctx->Exec, ( n[1].e, n[2].e, params ));
+ }
+ break;
+ case OPCODE_CONVOLUTION_PARAMETER_F:
+ CALL_ConvolutionParameterf(ctx->Exec, ( 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;
+ CALL_ConvolutionParameterfv(ctx->Exec, ( n[1].e, n[2].e, params ));
+ }
+ break;
+ case OPCODE_COPY_COLOR_SUB_TABLE:
+ CALL_CopyColorSubTable(ctx->Exec, ( n[1].e, n[2].i,
+ n[3].i, n[4].i, n[5].i ));
+ break;
+ case OPCODE_COPY_COLOR_TABLE:
+ CALL_CopyColorSubTable(ctx->Exec, ( n[1].e, n[2].i,
+ n[3].i, n[4].i, n[5].i ));
+ break;
+ case OPCODE_COPY_PIXELS:
+ CALL_CopyPixels(ctx->Exec, ( n[1].i, n[2].i,
+ (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e ));
+ break;
+ case OPCODE_COPY_TEX_IMAGE1D:
+ CALL_CopyTexImage1D(ctx->Exec, ( n[1].e, n[2].i, n[3].e, n[4].i,
+ n[5].i, n[6].i, n[7].i ));
+ break;
+ case OPCODE_COPY_TEX_IMAGE2D:
+ CALL_CopyTexImage2D(ctx->Exec, ( n[1].e, n[2].i, n[3].e, n[4].i,
+ n[5].i, n[6].i, n[7].i, n[8].i ));
+ break;
+ case OPCODE_COPY_TEX_SUB_IMAGE1D:
+ CALL_CopyTexSubImage1D(ctx->Exec, ( n[1].e, n[2].i, n[3].i,
+ n[4].i, n[5].i, n[6].i ));
+ break;
+ case OPCODE_COPY_TEX_SUB_IMAGE2D:
+ CALL_CopyTexSubImage2D(ctx->Exec, ( n[1].e, n[2].i, n[3].i,
+ n[4].i, n[5].i, n[6].i, n[7].i, n[8].i ));
+ break;
+ case OPCODE_COPY_TEX_SUB_IMAGE3D:
+ CALL_CopyTexSubImage3D(ctx->Exec, ( 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].i));
+ break;
+ case OPCODE_CULL_FACE:
+ CALL_CullFace(ctx->Exec, ( n[1].e ));
+ break;
+ case OPCODE_DEPTH_FUNC:
+ CALL_DepthFunc(ctx->Exec, ( n[1].e ));
+ break;
+ case OPCODE_DEPTH_MASK:
+ CALL_DepthMask(ctx->Exec, ( n[1].b ));
+ break;
+ case OPCODE_DEPTH_RANGE:
+ CALL_DepthRange(ctx->Exec, ( (GLclampd) n[1].f, (GLclampd) n[2].f ));
+ break;
+ case OPCODE_DISABLE:
+ CALL_Disable(ctx->Exec, ( n[1].e ));
+ break;
+ case OPCODE_DRAW_BUFFER:
+ CALL_DrawBuffer(ctx->Exec, ( n[1].e ));
+ break;
+ case OPCODE_DRAW_PIXELS:
+ {
+ const struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = ctx->DefaultPacking;
+ CALL_DrawPixels(ctx->Exec, ( n[1].i, n[2].i, n[3].e, n[4].e,
+ n[5].data ));
+ ctx->Unpack = save; /* restore */
+ }
+ break;
+ case OPCODE_ENABLE:
+ CALL_Enable(ctx->Exec, ( n[1].e ));
+ break;
+ case OPCODE_EVALMESH1:
+ CALL_EvalMesh1(ctx->Exec, ( n[1].e, n[2].i, n[3].i ));
+ break;
+ case OPCODE_EVALMESH2:
+ CALL_EvalMesh2(ctx->Exec, ( n[1].e, n[2].i, n[3].i, n[4].i, n[5].i ));
+ break;
+ case OPCODE_FOG:
+ {
+ GLfloat p[4];
+ p[0] = n[2].f;
+ p[1] = n[3].f;
+ p[2] = n[4].f;
+ p[3] = n[5].f;
+ CALL_Fogfv(ctx->Exec, ( n[1].e, p ));
+ }
+ break;
+ case OPCODE_FRONT_FACE:
+ CALL_FrontFace(ctx->Exec, ( n[1].e ));
+ break;
+ case OPCODE_FRUSTUM:
+ CALL_Frustum(ctx->Exec, ( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f ));
+ break;
+ case OPCODE_HINT:
+ CALL_Hint(ctx->Exec, ( n[1].e, n[2].e ));
+ break;
+ case OPCODE_HISTOGRAM:
+ CALL_Histogram(ctx->Exec, ( n[1].e, n[2].i, n[3].e, n[4].b ));
+ break;
+ case OPCODE_INDEX_MASK:
+ CALL_IndexMask(ctx->Exec, ( n[1].ui ));
+ break;
+ case OPCODE_INIT_NAMES:
+ CALL_InitNames(ctx->Exec, ());
+ break;
+ case OPCODE_LIGHT:
+ {
+ GLfloat p[4];
+ p[0] = n[3].f;
+ p[1] = n[4].f;
+ p[2] = n[5].f;
+ p[3] = n[6].f;
+ CALL_Lightfv(ctx->Exec, ( n[1].e, n[2].e, p ));
+ }
+ break;
+ case OPCODE_LIGHT_MODEL:
+ {
+ GLfloat p[4];
+ p[0] = n[2].f;
+ p[1] = n[3].f;
+ p[2] = n[4].f;
+ p[3] = n[5].f;
+ CALL_LightModelfv(ctx->Exec, ( n[1].e, p ));
+ }
+ break;
+ case OPCODE_LINE_STIPPLE:
+ CALL_LineStipple(ctx->Exec, ( n[1].i, n[2].us ));
+ break;
+ case OPCODE_LINE_WIDTH:
+ CALL_LineWidth(ctx->Exec, ( n[1].f ));
+ break;
+ case OPCODE_LIST_BASE:
+ CALL_ListBase(ctx->Exec, ( n[1].ui ));
+ break;
+ case OPCODE_LOAD_IDENTITY:
+ CALL_LoadIdentity(ctx->Exec, ());
+ break;
+ case OPCODE_LOAD_MATRIX:
+ if (sizeof(Node)==sizeof(GLfloat)) {
+ CALL_LoadMatrixf(ctx->Exec, ( &n[1].f ));
+ }
+ else {
+ GLfloat m[16];
+ GLuint i;
+ for (i=0;i<16;i++) {
+ m[i] = n[1+i].f;
+ }
+ CALL_LoadMatrixf(ctx->Exec, ( m ));
+ }
+ break;
+ case OPCODE_LOAD_NAME:
+ CALL_LoadName(ctx->Exec, ( n[1].ui ));
+ break;
+ case OPCODE_LOGIC_OP:
+ CALL_LogicOp(ctx->Exec, ( n[1].e ));
+ break;
+ case OPCODE_MAP1:
+ {
+ GLenum target = n[1].e;
+ GLint ustride = _mesa_evaluator_components(target);
+ GLint uorder = n[5].i;
+ GLfloat u1 = n[2].f;
+ GLfloat u2 = n[3].f;
+ CALL_Map1f(ctx->Exec, ( target, u1, u2, ustride, uorder,
+ (GLfloat *) n[6].data ));
+ }
+ break;
+ case OPCODE_MAP2:
+ {
+ GLenum target = n[1].e;
+ GLfloat u1 = n[2].f;
+ GLfloat u2 = n[3].f;
+ GLfloat v1 = n[4].f;
+ GLfloat v2 = n[5].f;
+ GLint ustride = n[6].i;
+ GLint vstride = n[7].i;
+ GLint uorder = n[8].i;
+ GLint vorder = n[9].i;
+ CALL_Map2f(ctx->Exec, ( target, u1, u2, ustride, uorder,
+ v1, v2, vstride, vorder,
+ (GLfloat *) n[10].data ));
+ }
+ break;
+ case OPCODE_MAPGRID1:
+ CALL_MapGrid1f(ctx->Exec, ( n[1].i, n[2].f, n[3].f ));
+ break;
+ case OPCODE_MAPGRID2:
+ CALL_MapGrid2f(ctx->Exec, ( n[1].i, n[2].f, n[3].f, n[4].i, n[5].f, n[6].f));
+ break;
+ case OPCODE_MATRIX_MODE:
+ CALL_MatrixMode(ctx->Exec, ( n[1].e ));
+ break;
+ case OPCODE_MIN_MAX:
+ CALL_Minmax(ctx->Exec, (n[1].e, n[2].e, n[3].b));
+ break;
+ case OPCODE_MULT_MATRIX:
+ if (sizeof(Node)==sizeof(GLfloat)) {
+ CALL_MultMatrixf(ctx->Exec, ( &n[1].f ));
+ }
+ else {
+ GLfloat m[16];
+ GLuint i;
+ for (i=0;i<16;i++) {
+ m[i] = n[1+i].f;
+ }
+ CALL_MultMatrixf(ctx->Exec, ( m ));
+ }
+ break;
+ case OPCODE_ORTHO:
+ CALL_Ortho(ctx->Exec, ( n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f ));
+ break;
+ case OPCODE_PASSTHROUGH:
+ CALL_PassThrough(ctx->Exec, ( n[1].f ));
+ break;
+ case OPCODE_PIXEL_MAP:
+ CALL_PixelMapfv(ctx->Exec, ( n[1].e, n[2].i, (GLfloat *) n[3].data ));
+ break;
+ case OPCODE_PIXEL_TRANSFER:
+ CALL_PixelTransferf(ctx->Exec, ( n[1].e, n[2].f ));
+ break;
+ case OPCODE_PIXEL_ZOOM:
+ CALL_PixelZoom(ctx->Exec, ( n[1].f, n[2].f ));
+ break;
+ case OPCODE_POINT_SIZE:
+ CALL_PointSize(ctx->Exec, ( n[1].f ));
+ break;
+ case OPCODE_POINT_PARAMETERS:
+ {
+ GLfloat params[3];
+ params[0] = n[2].f;
+ params[1] = n[3].f;
+ params[2] = n[4].f;
+ CALL_PointParameterfvEXT(ctx->Exec, ( n[1].e, params ));
+ }
+ break;
+ case OPCODE_POLYGON_MODE:
+ CALL_PolygonMode(ctx->Exec, ( n[1].e, n[2].e ));
+ break;
+ case OPCODE_POLYGON_STIPPLE:
+ CALL_PolygonStipple(ctx->Exec, ( (GLubyte *) n[1].data ));
+ break;
+ case OPCODE_POLYGON_OFFSET:
+ CALL_PolygonOffset(ctx->Exec, ( n[1].f, n[2].f ));
+ break;
+ case OPCODE_POP_ATTRIB:
+ CALL_PopAttrib(ctx->Exec, ());
+ break;
+ case OPCODE_POP_MATRIX:
+ CALL_PopMatrix(ctx->Exec, ());
+ break;
+ case OPCODE_POP_NAME:
+ CALL_PopName(ctx->Exec, ());
+ break;
+ case OPCODE_PRIORITIZE_TEXTURE:
+ CALL_PrioritizeTextures(ctx->Exec, ( 1, &n[1].ui, &n[2].f ));
+ break;
+ case OPCODE_PUSH_ATTRIB:
+ CALL_PushAttrib(ctx->Exec, ( n[1].bf ));
+ break;
+ case OPCODE_PUSH_MATRIX:
+ CALL_PushMatrix(ctx->Exec, ());
+ break;
+ case OPCODE_PUSH_NAME:
+ CALL_PushName(ctx->Exec, ( n[1].ui ));
+ break;
+ case OPCODE_RASTER_POS:
+ CALL_RasterPos4f(ctx->Exec, ( n[1].f, n[2].f, n[3].f, n[4].f ));
+ break;
+ case OPCODE_READ_BUFFER:
+ CALL_ReadBuffer(ctx->Exec, ( n[1].e ));
+ break;
+ case OPCODE_RESET_HISTOGRAM:
+ CALL_ResetHistogram(ctx->Exec, ( n[1].e ));
+ break;
+ case OPCODE_RESET_MIN_MAX:
+ CALL_ResetMinmax(ctx->Exec, ( n[1].e ));
+ break;
+ case OPCODE_ROTATE:
+ CALL_Rotatef(ctx->Exec, ( n[1].f, n[2].f, n[3].f, n[4].f ));
+ break;
+ case OPCODE_SCALE:
+ CALL_Scalef(ctx->Exec, ( n[1].f, n[2].f, n[3].f ));
+ break;
+ case OPCODE_SCISSOR:
+ CALL_Scissor(ctx->Exec, ( n[1].i, n[2].i, n[3].i, n[4].i ));
+ break;
+ case OPCODE_SHADE_MODEL:
+ CALL_ShadeModel(ctx->Exec, ( n[1].e ));
+ break;
+ case OPCODE_STENCIL_FUNC:
+ CALL_StencilFunc(ctx->Exec, ( n[1].e, n[2].i, n[3].ui ));
+ break;
+ case OPCODE_STENCIL_MASK:
+ CALL_StencilMask(ctx->Exec, ( n[1].ui ));
+ break;
+ case OPCODE_STENCIL_OP:
+ CALL_StencilOp(ctx->Exec, ( n[1].e, n[2].e, n[3].e ));
+ break;
+ case OPCODE_STENCIL_FUNC_SEPARATE:
+ CALL_StencilFuncSeparate(ctx->Exec, ( n[1].e, n[2].e, n[3].i, n[4].ui ));
+ break;
+ case OPCODE_STENCIL_MASK_SEPARATE:
+ CALL_StencilMaskSeparate(ctx->Exec, ( n[1].e, n[2].ui ));
+ break;
+ case OPCODE_STENCIL_OP_SEPARATE:
+ CALL_StencilOpSeparate(ctx->Exec, ( n[1].e, n[2].e, n[3].e, n[4].e ));
+ break;
+ case OPCODE_TEXENV:
+ {
+ GLfloat params[4];
+ params[0] = n[3].f;
+ params[1] = n[4].f;
+ params[2] = n[5].f;
+ params[3] = n[6].f;
+ CALL_TexEnvfv(ctx->Exec, ( n[1].e, n[2].e, params ));
+ }
+ break;
+ case OPCODE_TEXGEN:
+ {
+ GLfloat params[4];
+ params[0] = n[3].f;
+ params[1] = n[4].f;
+ params[2] = n[5].f;
+ params[3] = n[6].f;
+ CALL_TexGenfv(ctx->Exec, ( n[1].e, n[2].e, params ));
+ }
+ break;
+ case OPCODE_TEXPARAMETER:
+ {
+ GLfloat params[4];
+ params[0] = n[3].f;
+ params[1] = n[4].f;
+ params[2] = n[5].f;
+ params[3] = n[6].f;
+ CALL_TexParameterfv(ctx->Exec, ( n[1].e, n[2].e, params ));
+ }
+ break;
+ case OPCODE_TEX_IMAGE1D:
+ {
+ const struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = ctx->DefaultPacking;
+ CALL_TexImage1D(ctx->Exec, (
+ n[1].e, /* target */
+ n[2].i, /* level */
+ n[3].i, /* components */
+ n[4].i, /* width */
+ n[5].e, /* border */
+ n[6].e, /* format */
+ n[7].e, /* type */
+ n[8].data ));
+ ctx->Unpack = save; /* restore */
+ }
+ break;
+ case OPCODE_TEX_IMAGE2D:
+ {
+ const struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = ctx->DefaultPacking;
+ CALL_TexImage2D(ctx->Exec, (
+ n[1].e, /* target */
+ n[2].i, /* level */
+ n[3].i, /* components */
+ n[4].i, /* width */
+ n[5].i, /* height */
+ n[6].e, /* border */
+ n[7].e, /* format */
+ n[8].e, /* type */
+ n[9].data ));
+ ctx->Unpack = save; /* restore */
+ }
+ break;
+ case OPCODE_TEX_IMAGE3D:
+ {
+ const struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = ctx->DefaultPacking;
+ CALL_TexImage3D(ctx->Exec, (
+ n[1].e, /* target */
+ n[2].i, /* level */
+ n[3].i, /* components */
+ n[4].i, /* width */
+ n[5].i, /* height */
+ n[6].i, /* depth */
+ n[7].e, /* border */
+ n[8].e, /* format */
+ n[9].e, /* type */
+ n[10].data ));
+ ctx->Unpack = save; /* restore */
+ }
+ break;
+ case OPCODE_TEX_SUB_IMAGE1D:
+ {
+ const struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = ctx->DefaultPacking;
+ CALL_TexSubImage1D(ctx->Exec, ( 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_TEX_SUB_IMAGE2D:
+ {
+ const struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = ctx->DefaultPacking;
+ CALL_TexSubImage2D(ctx->Exec, ( n[1].e, n[2].i, n[3].i,
+ n[4].i, n[5].e,
+ n[6].i, n[7].e, n[8].e, n[9].data ));
+ ctx->Unpack = save; /* restore */
+ }
+ break;
+ case OPCODE_TEX_SUB_IMAGE3D:
+ {
+ const struct gl_pixelstore_attrib save = ctx->Unpack;
+ ctx->Unpack = ctx->DefaultPacking;
+ CALL_TexSubImage3D(ctx->Exec, ( 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].e,
+ n[11].data ));
+ ctx->Unpack = save; /* restore */
+ }
+ break;
+ case OPCODE_TRANSLATE:
+ CALL_Translatef(ctx->Exec, ( n[1].f, n[2].f, n[3].f ));
+ break;
+ case OPCODE_VIEWPORT:
+ CALL_Viewport(ctx->Exec, (n[1].i, n[2].i,
+ (GLsizei) n[3].i, (GLsizei) n[4].i));
+ break;
+ case OPCODE_WINDOW_POS:
+ CALL_WindowPos4fMESA(ctx->Exec, ( n[1].f, n[2].f, n[3].f, n[4].f ));
+ break;
+ case OPCODE_ACTIVE_TEXTURE: /* GL_ARB_multitexture */
+ CALL_ActiveTextureARB(ctx->Exec, ( n[1].e ));
+ break;
+ case OPCODE_PIXEL_TEXGEN_SGIX: /* GL_SGIX_pixel_texture */
+ CALL_PixelTexGenSGIX(ctx->Exec, ( n[1].e ));
+ break;
+ case OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS: /* GL_SGIS_pixel_texture */
+ CALL_PixelTexGenParameteriSGIS(ctx->Exec, ( n[1].e, n[2].i ));
+ break;
+ case OPCODE_COMPRESSED_TEX_IMAGE_1D: /* GL_ARB_texture_compression */
+ CALL_CompressedTexImage1DARB(ctx->Exec, (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 */
+ CALL_CompressedTexImage2DARB(ctx->Exec, (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 */
+ CALL_CompressedTexImage3DARB(ctx->Exec, (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 */
+ CALL_CompressedTexSubImage1DARB(ctx->Exec, (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 */
+ CALL_CompressedTexSubImage2DARB(ctx->Exec, (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 */
+ CALL_CompressedTexSubImage3DARB(ctx->Exec, (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_SAMPLE_COVERAGE: /* GL_ARB_multisample */
+ CALL_SampleCoverageARB(ctx->Exec, (n[1].f, n[2].b));
+ break;
+ case OPCODE_WINDOW_POS_ARB: /* GL_ARB_window_pos */
+ CALL_WindowPos3fMESA(ctx->Exec, ( n[1].f, n[2].f, n[3].f ));
+ break;
+#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
+ case OPCODE_BIND_PROGRAM_NV: /* GL_NV_vertex_program */
+ CALL_BindProgramNV(ctx->Exec, ( n[1].e, n[2].ui ));
+ break;
+#endif
+#if FEATURE_NV_vertex_program
+ case OPCODE_EXECUTE_PROGRAM_NV:
+ {
+ GLfloat v[4];
+ v[0] = n[3].f;
+ v[1] = n[4].f;
+ v[2] = n[5].f;
+ v[3] = n[6].f;
+ CALL_ExecuteProgramNV(ctx->Exec, (n[1].e, n[2].ui, v));
+ }
+ break;
+ case OPCODE_REQUEST_RESIDENT_PROGRAMS_NV:
+ CALL_RequestResidentProgramsNV(ctx->Exec, (n[1].ui,
+ (GLuint *) n[2].data));
+ break;
+ case OPCODE_LOAD_PROGRAM_NV:
+ CALL_LoadProgramNV(ctx->Exec, (n[1].e, n[2].ui, n[3].i,
+ (const GLubyte *) n[4].data));
+ break;
+ case OPCODE_PROGRAM_PARAMETER4F_NV:
+ CALL_ProgramParameter4fNV(ctx->Exec, (n[1].e, n[2].ui, n[3].f,
+ n[4].f, n[5].f, n[6].f));
+ break;
+ case OPCODE_TRACK_MATRIX_NV:
+ CALL_TrackMatrixNV(ctx->Exec, (n[1].e, n[2].ui, n[3].e, n[4].e));
+ break;
+#endif
+
+#if FEATURE_NV_fragment_program
+ case OPCODE_PROGRAM_LOCAL_PARAMETER_ARB:
+ CALL_ProgramLocalParameter4fARB(ctx->Exec, (n[1].e, n[2].ui, n[3].f,
+ n[4].f, n[5].f, n[6].f));
+ break;
+ case OPCODE_PROGRAM_NAMED_PARAMETER_NV:
+ CALL_ProgramNamedParameter4fNV(ctx->Exec, (n[1].ui, n[2].i,
+ (const GLubyte *) n[3].data,
+ n[4].f, n[5].f, n[6].f, n[7].f));
+ break;
+#endif
+
+ case OPCODE_ACTIVE_STENCIL_FACE_EXT:
+ CALL_ActiveStencilFaceEXT(ctx->Exec, (n[1].e));
+ break;
+ case OPCODE_DEPTH_BOUNDS_EXT:
+ CALL_DepthBoundsEXT(ctx->Exec, (n[1].f, n[2].f));
+ break;
+#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
+ case OPCODE_PROGRAM_STRING_ARB:
+ CALL_ProgramStringARB(ctx->Exec, (n[1].e, n[2].e, n[3].i, n[4].data));
+ break;
+ case OPCODE_PROGRAM_ENV_PARAMETER_ARB:
+ CALL_ProgramEnvParameter4fARB(ctx->Exec, (n[1].e, n[2].ui, n[3].f,
+ n[4].f, n[5].f, n[6].f));
+ break;
+#endif
+#if FEATURE_ARB_occlusion_query
+ case OPCODE_BEGIN_QUERY_ARB:
+ CALL_BeginQueryARB(ctx->Exec, (n[1].e, n[2].ui));
+ break;
+ case OPCODE_END_QUERY_ARB:
+ CALL_EndQueryARB(ctx->Exec, (n[1].e));
+ break;
+#endif
+ case OPCODE_DRAW_BUFFERS_ARB:
+ {
+ GLenum buffers[MAX_DRAW_BUFFERS];
+ GLint i, count = MIN2(n[1].i, MAX_DRAW_BUFFERS);
+ for (i = 0; i < count; i++)
+ buffers[i] = n[2 + i].e;
+ CALL_DrawBuffersARB(ctx->Exec, (n[1].i, buffers));
+ }
+ break;
+#if FEATURE_ATI_fragment_shader
+ case OPCODE_BIND_FRAGMENT_SHADER_ATI:
+ CALL_BindFragmentShaderATI(ctx->Exec, (n[1].i));
+ break;
+ case OPCODE_SET_FRAGMENT_SHADER_CONSTANTS_ATI:
+ {
+ GLfloat values[4];
+ GLuint i, dst = n[1].ui;
+
+ for (i = 0; i < 4; i++)
+ values[i] = n[1+i].f;
+ CALL_SetFragmentShaderConstantATI(ctx->Exec, (dst, values));
+ }
+ break;
+#endif
+ case OPCODE_ATTR_1F_NV:
+ CALL_VertexAttrib1fNV(ctx->Exec, (n[1].e, n[2].f));
+ break;
+ case OPCODE_ATTR_2F_NV:
+ /* Really shouldn't have to do this - the Node structure
+ * is convenient, but it would be better to store the data
+ * packed appropriately so that it can be sent directly
+ * on. With x86_64 becoming common, this will start to
+ * matter more.
+ */
+ if (sizeof(Node)==sizeof(GLfloat))
+ CALL_VertexAttrib2fvNV(ctx->Exec, (n[1].e, &n[2].f));
+ else
+ CALL_VertexAttrib2fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f));
+ break;
+ case OPCODE_ATTR_3F_NV:
+ if (sizeof(Node)==sizeof(GLfloat))
+ CALL_VertexAttrib3fvNV(ctx->Exec, (n[1].e, &n[2].f));
+ else
+ CALL_VertexAttrib3fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f,
+ n[4].f));
+ break;
+ case OPCODE_ATTR_4F_NV:
+ if (sizeof(Node)==sizeof(GLfloat))
+ CALL_VertexAttrib4fvNV(ctx->Exec, (n[1].e, &n[2].f));
+ else
+ CALL_VertexAttrib4fNV(ctx->Exec, (n[1].e, n[2].f, n[3].f,
+ n[4].f, n[5].f));
+ break;
+ case OPCODE_ATTR_1F_ARB:
+ CALL_VertexAttrib1fARB(ctx->Exec, (n[1].e, n[2].f));
+ break;
+ case OPCODE_ATTR_2F_ARB:
+ /* Really shouldn't have to do this - the Node structure
+ * is convenient, but it would be better to store the data
+ * packed appropriately so that it can be sent directly
+ * on. With x86_64 becoming common, this will start to
+ * matter more.
+ */
+ if (sizeof(Node)==sizeof(GLfloat))
+ CALL_VertexAttrib2fvARB(ctx->Exec, (n[1].e, &n[2].f));
+ else
+ CALL_VertexAttrib2fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f));
+ break;
+ case OPCODE_ATTR_3F_ARB:
+ if (sizeof(Node)==sizeof(GLfloat))
+ CALL_VertexAttrib3fvARB(ctx->Exec, (n[1].e, &n[2].f));
+ else
+ CALL_VertexAttrib3fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f,
+ n[4].f));
+ break;
+ case OPCODE_ATTR_4F_ARB:
+ if (sizeof(Node)==sizeof(GLfloat))
+ CALL_VertexAttrib4fvARB(ctx->Exec, (n[1].e, &n[2].f));
+ else
+ CALL_VertexAttrib4fARB(ctx->Exec, (n[1].e, n[2].f, n[3].f,
+ n[4].f, n[5].f));
+ break;
+ case OPCODE_MATERIAL:
+ if (sizeof(Node)==sizeof(GLfloat))
+ CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, &n[3].f));
+ else {
+ GLfloat f[4];
+ f[0] = n[3].f;
+ f[1] = n[4].f;
+ f[2] = n[5].f;
+ f[3] = n[6].f;
+ CALL_Materialfv(ctx->Exec, (n[1].e, n[2].e, f));
+ }
+ break;
+ case OPCODE_INDEX:
+ CALL_Indexi(ctx->Exec, (n[1].i));
+ break;
+ case OPCODE_EDGEFLAG:
+ CALL_EdgeFlag(ctx->Exec, (n[1].b));
+ break;
+ case OPCODE_BEGIN:
+ CALL_Begin(ctx->Exec, (n[1].e));
+ break;
+ case OPCODE_END:
+ CALL_End(ctx->Exec, ());
+ break;
+ case OPCODE_RECTF:
+ CALL_Rectf(ctx->Exec, (n[1].f, n[2].f, n[3].f, n[4].f));
+ break;
+ case OPCODE_EVAL_C1:
+ CALL_EvalCoord1f(ctx->Exec, (n[1].f));
+ break;
+ case OPCODE_EVAL_C2:
+ CALL_EvalCoord2f(ctx->Exec, (n[1].f, n[2].f));
+ break;
+ case OPCODE_EVAL_P1:
+ CALL_EvalPoint1(ctx->Exec, (n[1].i));
+ break;
+ case OPCODE_EVAL_P2:
+ CALL_EvalPoint2(ctx->Exec, (n[1].i, n[2].i));
+ break;
+
+
+
+
+ case OPCODE_CONTINUE:
+ n = (Node *) n[1].next;
+ break;
+ case OPCODE_END_OF_LIST:
+ done = GL_TRUE;
+ break;
+ default:
+ {
+ char msg[1000];
+ _mesa_sprintf(msg, "Error in execute_list: opcode=%d", (int) opcode);
+ _mesa_problem(ctx, msg);
+ }
+ done = GL_TRUE;
+ }
+
+ /* increment n to point to next compiled command */
+ if (opcode!=OPCODE_CONTINUE) {
+ n += InstSize[opcode];
+ }
+ }
+ }
+
+ if (ctx->Driver.EndCallList)
+ ctx->Driver.EndCallList( ctx );
+
+ ctx->ListState.CallStack[ctx->ListState.CallDepth--] = NULL;
+}
+
+
+
+
+
+/**********************************************************************/
+/* GL functions */
+/**********************************************************************/
+
+
+
+
+/*
+ * Test if a display list number is valid.
+ */
+GLboolean GLAPIENTRY
+_mesa_IsList( GLuint list )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0); /* must be called before assert */
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+ return islist(ctx, list);
+}
+
+
+/*
+ * Delete a sequence of consecutive display lists.
+ */
+void GLAPIENTRY
+_mesa_DeleteLists( GLuint list, GLsizei range )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint i;
+ FLUSH_VERTICES(ctx, 0); /* must be called before assert */
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (range<0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glDeleteLists" );
+ return;
+ }
+ for (i=list;i<list+range;i++) {
+ _mesa_destroy_list( ctx, i );
+ }
+}
+
+
+
+/*
+ * Return a display list number, n, such that lists n through n+range-1
+ * are free.
+ */
+GLuint GLAPIENTRY
+_mesa_GenLists(GLsizei range )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint base;
+ FLUSH_VERTICES(ctx, 0); /* must be called before assert */
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
+
+ if (range<0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glGenLists" );
+ return 0;
+ }
+ if (range==0) {
+ 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 */
+ GLint i;
+ for (i=0; i<range; i++) {
+ _mesa_HashInsert(ctx->Shared->DisplayList, base+i, make_list(base+i, 1));
+ }
+ }
+
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+
+ return base;
+}
+
+
+
+/*
+ * Begin a new display list.
+ */
+void GLAPIENTRY
+_mesa_NewList( GLuint list, GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i;
+
+ FLUSH_CURRENT(ctx, 0); /* must be called before assert */
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE&VERBOSE_API)
+ _mesa_debug(ctx, "glNewList %u %s\n", list,
+ _mesa_lookup_enum_by_nr(mode));
+
+ if (list==0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glNewList" );
+ return;
+ }
+
+ if (mode!=GL_COMPILE && mode!=GL_COMPILE_AND_EXECUTE) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glNewList" );
+ return;
+ }
+
+ if (ctx->ListState.CurrentListPtr) {
+ /* already compiling a display list */
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glNewList" );
+ return;
+ }
+
+ ctx->CompileFlag = GL_TRUE;
+ ctx->ExecuteFlag = (mode == GL_COMPILE_AND_EXECUTE);
+
+ /* Allocate new display list */
+ ctx->ListState.CurrentListNum = list;
+ ctx->ListState.CurrentList = make_list( list, BLOCK_SIZE );
+ ctx->ListState.CurrentBlock = ctx->ListState.CurrentList->node;
+ ctx->ListState.CurrentListPtr = ctx->ListState.CurrentBlock;
+ ctx->ListState.CurrentPos = 0;
+
+ /* Reset acumulated list state:
+ */
+ for (i = 0; i < VERT_ATTRIB_MAX; i++)
+ ctx->ListState.ActiveAttribSize[i] = 0;
+
+ for (i = 0; i < MAT_ATTRIB_MAX; i++)
+ ctx->ListState.ActiveMaterialSize[i] = 0;
+
+ ctx->ListState.ActiveIndex = 0;
+ ctx->ListState.ActiveEdgeFlag = 0;
+
+ ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
+ ctx->Driver.NewList( ctx, list, mode );
+
+ ctx->CurrentDispatch = ctx->Save;
+ _glapi_set_dispatch( ctx->CurrentDispatch );
+}
+
+
+
+/*
+ * End definition of current display list.
+ */
+void GLAPIENTRY
+_mesa_EndList( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ SAVE_FLUSH_VERTICES(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (MESA_VERBOSE&VERBOSE_API)
+ _mesa_debug(ctx, "glEndList\n");
+
+ /* Check that a list is under construction */
+ if (!ctx->ListState.CurrentListPtr) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glEndList" );
+ return;
+ }
+
+ (void) ALLOC_INSTRUCTION( ctx, OPCODE_END_OF_LIST, 0 );
+
+ /* Destroy old list, if any */
+ _mesa_destroy_list(ctx, ctx->ListState.CurrentListNum);
+ /* Install the list */
+ _mesa_HashInsert(ctx->Shared->DisplayList, ctx->ListState.CurrentListNum, ctx->ListState.CurrentList);
+
+
+ if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST)
+ mesa_print_display_list(ctx->ListState.CurrentListNum);
+
+ ctx->Driver.EndList( ctx );
+
+ ctx->ListState.CurrentList = NULL;
+ ctx->ListState.CurrentListNum = 0;
+ ctx->ListState.CurrentListPtr = NULL;
+ ctx->ExecuteFlag = GL_TRUE;
+ ctx->CompileFlag = GL_FALSE;
+
+ ctx->CurrentDispatch = ctx->Exec;
+ _glapi_set_dispatch( ctx->CurrentDispatch );
+}
+
+
+
+void GLAPIENTRY
+_mesa_CallList( GLuint list )
+{
+ GLboolean save_compile_flag;
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_CURRENT(ctx, 0);
+ /* VERY IMPORTANT: Save the CompileFlag status, turn it off, */
+ /* execute the display list, and restore the CompileFlag. */
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glCallList %d\n", list);
+
+ if (list == 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)");
+ return;
+ }
+
+/* mesa_print_display_list( list ); */
+
+ save_compile_flag = ctx->CompileFlag;
+ if (save_compile_flag) {
+ ctx->CompileFlag = GL_FALSE;
+ }
+
+ execute_list( ctx, list );
+ ctx->CompileFlag = save_compile_flag;
+
+ /* also restore API function pointers to point to "save" versions */
+ if (save_compile_flag) {
+ ctx->CurrentDispatch = ctx->Save;
+ _glapi_set_dispatch( ctx->CurrentDispatch );
+ }
+}
+
+
+
+/*
+ * Execute glCallLists: call multiple display lists.
+ */
+void GLAPIENTRY
+_mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint list;
+ GLint i;
+ GLboolean save_compile_flag;
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glCallLists %d\n", n);
+
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ case GL_2_BYTES:
+ case GL_3_BYTES:
+ case GL_4_BYTES:
+ /* OK */
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCallLists(type)");
+ return;
+ }
+
+ /* Save the CompileFlag status, turn it off, execute display list,
+ * and restore the CompileFlag.
+ */
+ save_compile_flag = ctx->CompileFlag;
+ ctx->CompileFlag = GL_FALSE;
+
+ for (i=0;i<n;i++) {
+ list = translate_id( i, type, lists );
+ execute_list( ctx, ctx->List.ListBase + list );
+ }
+
+ ctx->CompileFlag = save_compile_flag;
+
+ /* also restore API function pointers to point to "save" versions */
+ if (save_compile_flag) {
+ ctx->CurrentDispatch = ctx->Save;
+ _glapi_set_dispatch( ctx->CurrentDispatch );
+ }
+}
+
+
+
+/*
+ * Set the offset added to list numbers in glCallLists.
+ */
+void GLAPIENTRY
+_mesa_ListBase( GLuint base )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0); /* must be called before assert */
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+ ctx->List.ListBase = base;
+}
+
+
+/* Can no longer assume ctx->Exec->Func is equal to _mesa_Func.
+ */
+static void GLAPIENTRY exec_Finish( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_Finish(ctx->Exec, ());
+}
+
+static void GLAPIENTRY exec_Flush( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_Flush(ctx->Exec, ( ));
+}
+
+static void GLAPIENTRY exec_GetBooleanv( GLenum pname, GLboolean *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetBooleanv(ctx->Exec, ( pname, params ));
+}
+
+static void GLAPIENTRY exec_GetClipPlane( GLenum plane, GLdouble *equation )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetClipPlane(ctx->Exec, ( plane, equation ));
+}
+
+static void GLAPIENTRY exec_GetDoublev( GLenum pname, GLdouble *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetDoublev(ctx->Exec, ( pname, params ));
+}
+
+static GLenum GLAPIENTRY exec_GetError( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ return CALL_GetError(ctx->Exec, ( ));
+}
+
+static void GLAPIENTRY exec_GetFloatv( GLenum pname, GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetFloatv(ctx->Exec, ( pname, params ));
+}
+
+static void GLAPIENTRY exec_GetIntegerv( GLenum pname, GLint *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetIntegerv(ctx->Exec, ( pname, params ));
+}
+
+static void GLAPIENTRY exec_GetLightfv( GLenum light, GLenum pname, GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetLightfv(ctx->Exec, ( light, pname, params ));
+}
+
+static void GLAPIENTRY exec_GetLightiv( GLenum light, GLenum pname, GLint *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetLightiv(ctx->Exec, ( light, pname, params ));
+}
+
+static void GLAPIENTRY exec_GetMapdv( GLenum target, GLenum query, GLdouble *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetMapdv(ctx->Exec, ( target, query, v ));
+}
+
+static void GLAPIENTRY exec_GetMapfv( GLenum target, GLenum query, GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetMapfv(ctx->Exec, ( target, query, v ));
+}
+
+static void GLAPIENTRY exec_GetMapiv( GLenum target, GLenum query, GLint *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetMapiv(ctx->Exec, ( target, query, v ));
+}
+
+static void GLAPIENTRY exec_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetMaterialfv(ctx->Exec, ( face, pname, params ));
+}
+
+static void GLAPIENTRY exec_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetMaterialiv(ctx->Exec, ( face, pname, params ));
+}
+
+static void GLAPIENTRY exec_GetPixelMapfv( GLenum map, GLfloat *values )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetPixelMapfv(ctx->Exec, ( map, values ));
+}
+
+static void GLAPIENTRY exec_GetPixelMapuiv( GLenum map, GLuint *values )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetPixelMapuiv(ctx->Exec, ( map, values ));
+}
+
+static void GLAPIENTRY exec_GetPixelMapusv( GLenum map, GLushort *values )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetPixelMapusv(ctx->Exec, ( map, values ));
+}
+
+static void GLAPIENTRY exec_GetPolygonStipple( GLubyte *dest )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetPolygonStipple(ctx->Exec, ( dest ));
+}
+
+static const GLubyte * GLAPIENTRY exec_GetString( GLenum name )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ return CALL_GetString(ctx->Exec, ( name ));
+}
+
+static void GLAPIENTRY exec_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetTexEnvfv(ctx->Exec, ( target, pname, params ));
+}
+
+static void GLAPIENTRY exec_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetTexEnviv(ctx->Exec, ( target, pname, params ));
+}
+
+static void GLAPIENTRY exec_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetTexGendv(ctx->Exec, ( coord, pname, params ));
+}
+
+static void GLAPIENTRY exec_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetTexGenfv(ctx->Exec, ( coord, pname, params ));
+}
+
+static void GLAPIENTRY exec_GetTexGeniv( GLenum coord, GLenum pname, GLint *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetTexGeniv(ctx->Exec, ( coord, pname, params ));
+}
+
+static void GLAPIENTRY exec_GetTexImage( GLenum target, GLint level, GLenum format,
+ GLenum type, GLvoid *pixels )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetTexImage(ctx->Exec, ( target, level, format, type, pixels ));
+}
+
+static void GLAPIENTRY exec_GetTexLevelParameterfv( GLenum target, GLint level,
+ GLenum pname, GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetTexLevelParameterfv(ctx->Exec, ( target, level, pname, params ));
+}
+
+static void GLAPIENTRY exec_GetTexLevelParameteriv( GLenum target, GLint level,
+ GLenum pname, GLint *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetTexLevelParameteriv(ctx->Exec, ( target, level, pname, params ));
+}
+
+static void GLAPIENTRY exec_GetTexParameterfv( GLenum target, GLenum pname,
+ GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetTexParameterfv(ctx->Exec, ( target, pname, params ));
+}
+
+static void GLAPIENTRY exec_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetTexParameteriv(ctx->Exec, ( target, pname, params ));
+}
+
+static GLboolean GLAPIENTRY exec_IsEnabled( GLenum cap )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ return CALL_IsEnabled(ctx->Exec, ( cap ));
+}
+
+static void GLAPIENTRY exec_PixelStoref( GLenum pname, GLfloat param )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_PixelStoref(ctx->Exec, ( pname, param ));
+}
+
+static void GLAPIENTRY exec_PixelStorei( GLenum pname, GLint param )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_PixelStorei(ctx->Exec, ( pname, param ));
+}
+
+static void GLAPIENTRY exec_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type, GLvoid *pixels )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_ReadPixels(ctx->Exec, ( x, y, width, height, format, type, pixels ));
+}
+
+static GLint GLAPIENTRY exec_RenderMode( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ return CALL_RenderMode(ctx->Exec, ( mode ));
+}
+
+static void GLAPIENTRY exec_FeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_FeedbackBuffer(ctx->Exec, ( size, type, buffer ));
+}
+
+static void GLAPIENTRY exec_SelectBuffer( GLsizei size, GLuint *buffer )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_SelectBuffer(ctx->Exec, ( size, buffer ));
+}
+
+static GLboolean GLAPIENTRY exec_AreTexturesResident(GLsizei n, const GLuint *texName,
+ GLboolean *residences)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ return CALL_AreTexturesResident(ctx->Exec, ( n, texName, residences));
+}
+
+static void GLAPIENTRY exec_ColorPointer(GLint size, GLenum type, GLsizei stride,
+ const GLvoid *ptr)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_ColorPointer(ctx->Exec, ( size, type, stride, ptr));
+}
+
+static void GLAPIENTRY exec_DeleteTextures( GLsizei n, const GLuint *texName)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_DeleteTextures(ctx->Exec, ( n, texName));
+}
+
+static void GLAPIENTRY exec_DisableClientState( GLenum cap )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_DisableClientState(ctx->Exec, ( cap ));
+}
+
+static void GLAPIENTRY exec_EdgeFlagPointer(GLsizei stride, const GLvoid *vptr)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_EdgeFlagPointer(ctx->Exec, ( stride, vptr));
+}
+
+static void GLAPIENTRY exec_EnableClientState( GLenum cap )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_EnableClientState(ctx->Exec, ( cap ));
+}
+
+static void GLAPIENTRY exec_GenTextures( GLsizei n, GLuint *texName )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GenTextures(ctx->Exec, ( n, texName ));
+}
+
+static void GLAPIENTRY exec_GetPointerv( GLenum pname, GLvoid **params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetPointerv(ctx->Exec, ( pname, params ));
+}
+
+static void GLAPIENTRY exec_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_IndexPointer(ctx->Exec, ( type, stride, ptr));
+}
+
+static void GLAPIENTRY exec_InterleavedArrays(GLenum format, GLsizei stride,
+ const GLvoid *pointer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_InterleavedArrays(ctx->Exec, ( format, stride, pointer));
+}
+
+static GLboolean GLAPIENTRY exec_IsTexture( GLuint texture )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ return CALL_IsTexture(ctx->Exec, ( texture ));
+}
+
+static void GLAPIENTRY exec_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_NormalPointer(ctx->Exec, ( type, stride, ptr ));
+}
+
+static void GLAPIENTRY exec_PopClientAttrib(void)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_PopClientAttrib(ctx->Exec, ());
+}
+
+static void GLAPIENTRY exec_PushClientAttrib(GLbitfield mask)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_PushClientAttrib(ctx->Exec, ( mask));
+}
+
+static void GLAPIENTRY exec_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
+ const GLvoid *ptr)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_TexCoordPointer(ctx->Exec, ( size, type, stride, ptr));
+}
+
+static void GLAPIENTRY exec_GetCompressedTexImageARB(GLenum target, GLint level,
+ GLvoid *img)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetCompressedTexImageARB(ctx->Exec, ( target, level, img));
+}
+
+static void GLAPIENTRY exec_VertexPointer(GLint size, GLenum type, GLsizei stride,
+ const GLvoid *ptr)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_VertexPointer(ctx->Exec, ( size, type, stride, ptr));
+}
+
+static void GLAPIENTRY exec_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat,
+ GLint x, GLint y, GLsizei width)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_CopyConvolutionFilter1D(ctx->Exec, ( target, internalFormat, x, y, width));
+}
+
+static void GLAPIENTRY exec_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat,
+ GLint x, GLint y, GLsizei width,
+ GLsizei height)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_CopyConvolutionFilter2D(ctx->Exec, ( target, internalFormat, x, y, width,
+ height));
+}
+
+static void GLAPIENTRY exec_GetColorTable( GLenum target, GLenum format,
+ GLenum type, GLvoid *data )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetColorTable(ctx->Exec, ( target, format, type, data ));
+}
+
+static void GLAPIENTRY exec_GetColorTableParameterfv( GLenum target, GLenum pname,
+ GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetColorTableParameterfv(ctx->Exec, ( target, pname, params ));
+}
+
+static void GLAPIENTRY exec_GetColorTableParameteriv( GLenum target, GLenum pname,
+ GLint *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetColorTableParameteriv(ctx->Exec, ( target, pname, params ));
+}
+
+static void GLAPIENTRY exec_GetConvolutionFilter(GLenum target, GLenum format, GLenum type,
+ GLvoid *image)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetConvolutionFilter(ctx->Exec, ( target, format, type, image));
+}
+
+static void GLAPIENTRY exec_GetConvolutionParameterfv(GLenum target, GLenum pname,
+ GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetConvolutionParameterfv(ctx->Exec, ( target, pname, params));
+}
+
+static void GLAPIENTRY exec_GetConvolutionParameteriv(GLenum target, GLenum pname,
+ GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetConvolutionParameteriv(ctx->Exec, ( target, pname, params));
+}
+
+static void GLAPIENTRY exec_GetHistogram(GLenum target, GLboolean reset, GLenum format,
+ GLenum type, GLvoid *values)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetHistogram(ctx->Exec, ( target, reset, format, type, values));
+}
+
+static void GLAPIENTRY exec_GetHistogramParameterfv(GLenum target, GLenum pname,
+ GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetHistogramParameterfv(ctx->Exec, ( target, pname, params));
+}
+
+static void GLAPIENTRY exec_GetHistogramParameteriv(GLenum target, GLenum pname,
+ GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetHistogramParameteriv(ctx->Exec, ( target, pname, params));
+}
+
+static void GLAPIENTRY exec_GetMinmax(GLenum target, GLboolean reset, GLenum format,
+ GLenum type, GLvoid *values)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetMinmax(ctx->Exec, ( target, reset, format, type, values));
+}
+
+static void GLAPIENTRY exec_GetMinmaxParameterfv(GLenum target, GLenum pname,
+ GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetMinmaxParameterfv(ctx->Exec, ( target, pname, params));
+}
+
+static void GLAPIENTRY exec_GetMinmaxParameteriv(GLenum target, GLenum pname,
+ GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetMinmaxParameteriv(ctx->Exec, ( target, pname, params));
+}
+
+static void GLAPIENTRY exec_GetSeparableFilter(GLenum target, GLenum format, GLenum type,
+ GLvoid *row, GLvoid *column, GLvoid *span)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetSeparableFilter(ctx->Exec, ( target, format, type, row, column, span));
+}
+
+static void GLAPIENTRY exec_SeparableFilter2D(GLenum target, GLenum internalFormat,
+ GLsizei width, GLsizei height, GLenum format,
+ GLenum type, const GLvoid *row,
+ const GLvoid *column)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_SeparableFilter2D(ctx->Exec, ( target, internalFormat, width, height, format,
+ type, row, column));
+}
+
+static void GLAPIENTRY exec_GetPixelTexGenParameterivSGIS(GLenum target, GLint *value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetPixelTexGenParameterivSGIS(ctx->Exec, ( target, value));
+}
+
+static void GLAPIENTRY exec_GetPixelTexGenParameterfvSGIS(GLenum target, GLfloat *value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_GetPixelTexGenParameterfvSGIS(ctx->Exec, ( target, value));
+}
+
+static void GLAPIENTRY exec_ColorPointerEXT(GLint size, GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid *ptr)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_ColorPointerEXT(ctx->Exec, ( size, type, stride, count, ptr));
+}
+
+static void GLAPIENTRY exec_EdgeFlagPointerEXT(GLsizei stride, GLsizei count,
+ const GLboolean *ptr)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_EdgeFlagPointerEXT(ctx->Exec, ( stride, count, ptr));
+}
+
+static void GLAPIENTRY exec_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
+ const GLvoid *ptr)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_IndexPointerEXT(ctx->Exec, ( type, stride, count, ptr));
+}
+
+static void GLAPIENTRY exec_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
+ const GLvoid *ptr)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_NormalPointerEXT(ctx->Exec, ( type, stride, count, ptr));
+}
+
+static void GLAPIENTRY exec_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid *ptr)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_TexCoordPointerEXT(ctx->Exec, ( size, type, stride, count, ptr));
+}
+
+static void GLAPIENTRY exec_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid *ptr)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_VertexPointerEXT(ctx->Exec, ( size, type, stride, count, ptr));
+}
+
+static void GLAPIENTRY exec_LockArraysEXT(GLint first, GLsizei count)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_LockArraysEXT(ctx->Exec, ( first, count));
+}
+
+static void GLAPIENTRY exec_UnlockArraysEXT( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_UnlockArraysEXT(ctx->Exec, ( ));
+}
+
+static void GLAPIENTRY exec_ClientActiveTextureARB( GLenum target )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_ClientActiveTextureARB(ctx->Exec, (target));
+}
+
+static void GLAPIENTRY exec_SecondaryColorPointerEXT(GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_SecondaryColorPointerEXT(ctx->Exec, ( size, type, stride, ptr));
+}
+
+static void GLAPIENTRY exec_FogCoordPointerEXT(GLenum type, GLsizei stride,
+ const GLvoid *ptr)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_FogCoordPointerEXT(ctx->Exec, ( type, stride, ptr));
+}
+
+/* GL_EXT_multi_draw_arrays */
+static void GLAPIENTRY exec_MultiDrawArraysEXT(GLenum mode, GLint *first,
+ GLsizei *count, GLsizei primcount)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_MultiDrawArraysEXT(ctx->Exec, ( mode, first, count, primcount ));
+}
+
+/* GL_EXT_multi_draw_arrays */
+static void GLAPIENTRY exec_MultiDrawElementsEXT(GLenum mode, const GLsizei *count,
+ GLenum type, const GLvoid **indices,
+ GLsizei primcount)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_MultiDrawElementsEXT(ctx->Exec, (mode, count, type, indices, primcount));
+}
+
+/* GL_IBM_multimode_draw_arrays */
+static void GLAPIENTRY exec_MultiModeDrawArraysIBM(const GLenum *mode, const GLint *first,
+ const GLsizei *count, GLsizei primcount,
+ GLint modestride)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_MultiModeDrawArraysIBM(ctx->Exec, (mode, first, count, primcount, modestride));
+}
+
+/* GL_IBM_multimode_draw_arrays */
+static void GLAPIENTRY exec_MultiModeDrawElementsIBM(const GLenum *mode,
+ const GLsizei *count,
+ GLenum type,
+ const GLvoid * const *indices,
+ GLsizei primcount, GLint modestride)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FLUSH_VERTICES(ctx, 0);
+ CALL_MultiModeDrawElementsIBM(ctx->Exec, (mode, count, type, indices, primcount,
+ modestride));
+}
+
+
+
+
+/**
+ * Setup the given dispatch table to point to Mesa's display list
+ * building functions.
+ *
+ * This does not include any of the tnl functions - they are
+ * initialized from _mesa_init_api_defaults and from the active vtxfmt
+ * struct.
+ */
+void
+_mesa_init_dlist_table( struct _glapi_table *table )
+{
+ _mesa_loopback_init_api_table( table );
+
+ /* GL 1.0 */
+ SET_Accum(table, save_Accum);
+ SET_AlphaFunc(table, save_AlphaFunc);
+ SET_Bitmap(table, save_Bitmap);
+ SET_BlendFunc(table, _mesa_BlendFunc); /* loops-back to BlendFuncSeparate */
+ SET_CallList(table, _mesa_save_CallList);
+ SET_CallLists(table, _mesa_save_CallLists);
+ SET_Clear(table, save_Clear);
+ SET_ClearAccum(table, save_ClearAccum);
+ SET_ClearColor(table, save_ClearColor);
+ SET_ClearDepth(table, save_ClearDepth);
+ SET_ClearIndex(table, save_ClearIndex);
+ SET_ClearStencil(table, save_ClearStencil);
+ SET_ClipPlane(table, save_ClipPlane);
+ SET_ColorMask(table, save_ColorMask);
+ SET_ColorMaterial(table, save_ColorMaterial);
+ SET_CopyPixels(table, save_CopyPixels);
+ SET_CullFace(table, save_CullFace);
+ SET_DeleteLists(table, _mesa_DeleteLists);
+ SET_DepthFunc(table, save_DepthFunc);
+ SET_DepthMask(table, save_DepthMask);
+ SET_DepthRange(table, save_DepthRange);
+ SET_Disable(table, save_Disable);
+ SET_DrawBuffer(table, save_DrawBuffer);
+ SET_DrawPixels(table, save_DrawPixels);
+ SET_Enable(table, save_Enable);
+ SET_EndList(table, _mesa_EndList);
+ SET_EvalMesh1(table, _mesa_save_EvalMesh1);
+ SET_EvalMesh2(table, _mesa_save_EvalMesh2);
+ SET_Finish(table, exec_Finish);
+ SET_Flush(table, exec_Flush);
+ SET_Fogf(table, save_Fogf);
+ SET_Fogfv(table, save_Fogfv);
+ SET_Fogi(table, save_Fogi);
+ SET_Fogiv(table, save_Fogiv);
+ SET_FrontFace(table, save_FrontFace);
+ SET_Frustum(table, save_Frustum);
+ SET_GenLists(table, _mesa_GenLists);
+ SET_GetBooleanv(table, exec_GetBooleanv);
+ SET_GetClipPlane(table, exec_GetClipPlane);
+ SET_GetDoublev(table, exec_GetDoublev);
+ SET_GetError(table, exec_GetError);
+ SET_GetFloatv(table, exec_GetFloatv);
+ SET_GetIntegerv(table, exec_GetIntegerv);
+ SET_GetLightfv(table, exec_GetLightfv);
+ SET_GetLightiv(table, exec_GetLightiv);
+ SET_GetMapdv(table, exec_GetMapdv);
+ SET_GetMapfv(table, exec_GetMapfv);
+ SET_GetMapiv(table, exec_GetMapiv);
+ SET_GetMaterialfv(table, exec_GetMaterialfv);
+ SET_GetMaterialiv(table, exec_GetMaterialiv);
+ SET_GetPixelMapfv(table, exec_GetPixelMapfv);
+ SET_GetPixelMapuiv(table, exec_GetPixelMapuiv);
+ SET_GetPixelMapusv(table, exec_GetPixelMapusv);
+ SET_GetPolygonStipple(table, exec_GetPolygonStipple);
+ SET_GetString(table, exec_GetString);
+ SET_GetTexEnvfv(table, exec_GetTexEnvfv);
+ SET_GetTexEnviv(table, exec_GetTexEnviv);
+ SET_GetTexGendv(table, exec_GetTexGendv);
+ SET_GetTexGenfv(table, exec_GetTexGenfv);
+ SET_GetTexGeniv(table, exec_GetTexGeniv);
+ SET_GetTexImage(table, exec_GetTexImage);
+ SET_GetTexLevelParameterfv(table, exec_GetTexLevelParameterfv);
+ SET_GetTexLevelParameteriv(table, exec_GetTexLevelParameteriv);
+ SET_GetTexParameterfv(table, exec_GetTexParameterfv);
+ SET_GetTexParameteriv(table, exec_GetTexParameteriv);
+ SET_Hint(table, save_Hint);
+ SET_IndexMask(table, save_IndexMask);
+ SET_InitNames(table, save_InitNames);
+ SET_IsEnabled(table, exec_IsEnabled);
+ SET_IsList(table, _mesa_IsList);
+ SET_LightModelf(table, save_LightModelf);
+ SET_LightModelfv(table, save_LightModelfv);
+ SET_LightModeli(table, save_LightModeli);
+ SET_LightModeliv(table, save_LightModeliv);
+ SET_Lightf(table, save_Lightf);
+ SET_Lightfv(table, save_Lightfv);
+ SET_Lighti(table, save_Lighti);
+ SET_Lightiv(table, save_Lightiv);
+ SET_LineStipple(table, save_LineStipple);
+ SET_LineWidth(table, save_LineWidth);
+ SET_ListBase(table, save_ListBase);
+ SET_LoadIdentity(table, save_LoadIdentity);
+ SET_LoadMatrixd(table, save_LoadMatrixd);
+ SET_LoadMatrixf(table, save_LoadMatrixf);
+ SET_LoadName(table, save_LoadName);
+ SET_LogicOp(table, save_LogicOp);
+ SET_Map1d(table, save_Map1d);
+ SET_Map1f(table, save_Map1f);
+ SET_Map2d(table, save_Map2d);
+ SET_Map2f(table, save_Map2f);
+ SET_MapGrid1d(table, save_MapGrid1d);
+ SET_MapGrid1f(table, save_MapGrid1f);
+ SET_MapGrid2d(table, save_MapGrid2d);
+ SET_MapGrid2f(table, save_MapGrid2f);
+ SET_MatrixMode(table, save_MatrixMode);
+ SET_MultMatrixd(table, save_MultMatrixd);
+ SET_MultMatrixf(table, save_MultMatrixf);
+ SET_NewList(table, save_NewList);
+ SET_Ortho(table, save_Ortho);
+ SET_PassThrough(table, save_PassThrough);
+ SET_PixelMapfv(table, save_PixelMapfv);
+ SET_PixelMapuiv(table, save_PixelMapuiv);
+ SET_PixelMapusv(table, save_PixelMapusv);
+ SET_PixelStoref(table, exec_PixelStoref);
+ SET_PixelStorei(table, exec_PixelStorei);
+ SET_PixelTransferf(table, save_PixelTransferf);
+ SET_PixelTransferi(table, save_PixelTransferi);
+ SET_PixelZoom(table, save_PixelZoom);
+ SET_PointSize(table, save_PointSize);
+ SET_PolygonMode(table, save_PolygonMode);
+ SET_PolygonOffset(table, save_PolygonOffset);
+ SET_PolygonStipple(table, save_PolygonStipple);
+ SET_PopAttrib(table, save_PopAttrib);
+ SET_PopMatrix(table, save_PopMatrix);
+ SET_PopName(table, save_PopName);
+ SET_PushAttrib(table, save_PushAttrib);
+ SET_PushMatrix(table, save_PushMatrix);
+ SET_PushName(table, save_PushName);
+ SET_RasterPos2d(table, save_RasterPos2d);
+ SET_RasterPos2dv(table, save_RasterPos2dv);
+ SET_RasterPos2f(table, save_RasterPos2f);
+ SET_RasterPos2fv(table, save_RasterPos2fv);
+ SET_RasterPos2i(table, save_RasterPos2i);
+ SET_RasterPos2iv(table, save_RasterPos2iv);
+ SET_RasterPos2s(table, save_RasterPos2s);
+ SET_RasterPos2sv(table, save_RasterPos2sv);
+ SET_RasterPos3d(table, save_RasterPos3d);
+ SET_RasterPos3dv(table, save_RasterPos3dv);
+ SET_RasterPos3f(table, save_RasterPos3f);
+ SET_RasterPos3fv(table, save_RasterPos3fv);
+ SET_RasterPos3i(table, save_RasterPos3i);
+ SET_RasterPos3iv(table, save_RasterPos3iv);
+ SET_RasterPos3s(table, save_RasterPos3s);
+ SET_RasterPos3sv(table, save_RasterPos3sv);
+ SET_RasterPos4d(table, save_RasterPos4d);
+ SET_RasterPos4dv(table, save_RasterPos4dv);
+ SET_RasterPos4f(table, save_RasterPos4f);
+ SET_RasterPos4fv(table, save_RasterPos4fv);
+ SET_RasterPos4i(table, save_RasterPos4i);
+ SET_RasterPos4iv(table, save_RasterPos4iv);
+ SET_RasterPos4s(table, save_RasterPos4s);
+ SET_RasterPos4sv(table, save_RasterPos4sv);
+ SET_ReadBuffer(table, save_ReadBuffer);
+ SET_ReadPixels(table, exec_ReadPixels);
+ SET_RenderMode(table, exec_RenderMode);
+ SET_Rotated(table, save_Rotated);
+ SET_Rotatef(table, save_Rotatef);
+ SET_Scaled(table, save_Scaled);
+ SET_Scalef(table, save_Scalef);
+ SET_Scissor(table, save_Scissor);
+ SET_FeedbackBuffer(table, exec_FeedbackBuffer);
+ SET_SelectBuffer(table, exec_SelectBuffer);
+ SET_ShadeModel(table, save_ShadeModel);
+ SET_StencilFunc(table, save_StencilFunc);
+ SET_StencilMask(table, save_StencilMask);
+ SET_StencilOp(table, save_StencilOp);
+ SET_TexEnvf(table, save_TexEnvf);
+ SET_TexEnvfv(table, save_TexEnvfv);
+ SET_TexEnvi(table, save_TexEnvi);
+ SET_TexEnviv(table, save_TexEnviv);
+ SET_TexGend(table, save_TexGend);
+ SET_TexGendv(table, save_TexGendv);
+ SET_TexGenf(table, save_TexGenf);
+ SET_TexGenfv(table, save_TexGenfv);
+ SET_TexGeni(table, save_TexGeni);
+ SET_TexGeniv(table, save_TexGeniv);
+ SET_TexImage1D(table, save_TexImage1D);
+ SET_TexImage2D(table, save_TexImage2D);
+ SET_TexParameterf(table, save_TexParameterf);
+ SET_TexParameterfv(table, save_TexParameterfv);
+ SET_TexParameteri(table, save_TexParameteri);
+ SET_TexParameteriv(table, save_TexParameteriv);
+ SET_Translated(table, save_Translated);
+ SET_Translatef(table, save_Translatef);
+ SET_Viewport(table, save_Viewport);
+
+ /* GL 1.1 */
+ SET_AreTexturesResident(table, exec_AreTexturesResident);
+ SET_AreTexturesResidentEXT(table, exec_AreTexturesResident);
+ SET_BindTexture(table, save_BindTexture);
+ SET_ColorPointer(table, exec_ColorPointer);
+ SET_CopyTexImage1D(table, save_CopyTexImage1D);
+ SET_CopyTexImage2D(table, save_CopyTexImage2D);
+ SET_CopyTexSubImage1D(table, save_CopyTexSubImage1D);
+ SET_CopyTexSubImage2D(table, save_CopyTexSubImage2D);
+ SET_DeleteTextures(table, exec_DeleteTextures);
+ SET_DisableClientState(table, exec_DisableClientState);
+ SET_EdgeFlagPointer(table, exec_EdgeFlagPointer);
+ SET_EnableClientState(table, exec_EnableClientState);
+ SET_GenTextures(table, exec_GenTextures);
+ SET_GenTexturesEXT(table, exec_GenTextures);
+ SET_GetPointerv(table, exec_GetPointerv);
+ SET_IndexPointer(table, exec_IndexPointer);
+ SET_InterleavedArrays(table, exec_InterleavedArrays);
+ SET_IsTexture(table, exec_IsTexture);
+ SET_IsTextureEXT(table, exec_IsTexture);
+ SET_NormalPointer(table, exec_NormalPointer);
+ SET_PopClientAttrib(table, exec_PopClientAttrib);
+ SET_PrioritizeTextures(table, save_PrioritizeTextures);
+ SET_PushClientAttrib(table, exec_PushClientAttrib);
+ SET_TexCoordPointer(table, exec_TexCoordPointer);
+ SET_TexSubImage1D(table, save_TexSubImage1D);
+ SET_TexSubImage2D(table, save_TexSubImage2D);
+ SET_VertexPointer(table, exec_VertexPointer);
+
+ /* GL 1.2 */
+ SET_CopyTexSubImage3D(table, save_CopyTexSubImage3D);
+ SET_TexImage3D(table, save_TexImage3D);
+ SET_TexSubImage3D(table, save_TexSubImage3D);
+
+ /* GL 2.0 */
+ SET_StencilFuncSeparate(table, save_StencilFuncSeparate);
+ SET_StencilMaskSeparate(table, save_StencilMaskSeparate);
+ SET_StencilOpSeparate(table, save_StencilOpSeparate);
+
+ /* GL_ARB_imaging */
+ /* Not all are supported */
+ SET_BlendColor(table, save_BlendColor);
+ SET_BlendEquation(table, save_BlendEquation);
+ SET_ColorSubTable(table, save_ColorSubTable);
+ SET_ColorTable(table, save_ColorTable);
+ SET_ColorTableParameterfv(table, save_ColorTableParameterfv);
+ SET_ColorTableParameteriv(table, save_ColorTableParameteriv);
+ SET_ConvolutionFilter1D(table, save_ConvolutionFilter1D);
+ SET_ConvolutionFilter2D(table, save_ConvolutionFilter2D);
+ SET_ConvolutionParameterf(table, save_ConvolutionParameterf);
+ SET_ConvolutionParameterfv(table, save_ConvolutionParameterfv);
+ SET_ConvolutionParameteri(table, save_ConvolutionParameteri);
+ SET_ConvolutionParameteriv(table, save_ConvolutionParameteriv);
+ SET_CopyColorSubTable(table, save_CopyColorSubTable);
+ SET_CopyColorTable(table, save_CopyColorTable);
+ SET_CopyConvolutionFilter1D(table, exec_CopyConvolutionFilter1D);
+ SET_CopyConvolutionFilter2D(table, exec_CopyConvolutionFilter2D);
+ SET_GetColorTable(table, exec_GetColorTable);
+ SET_GetColorTableEXT(table, exec_GetColorTable);
+ SET_GetColorTableParameterfv(table, exec_GetColorTableParameterfv);
+ SET_GetColorTableParameterfvEXT(table, exec_GetColorTableParameterfv);
+ SET_GetColorTableParameteriv(table, exec_GetColorTableParameteriv);
+ SET_GetColorTableParameterivEXT(table, exec_GetColorTableParameteriv);
+ SET_GetConvolutionFilter(table, exec_GetConvolutionFilter);
+ SET_GetConvolutionFilterEXT(table, exec_GetConvolutionFilter);
+ SET_GetConvolutionParameterfv(table, exec_GetConvolutionParameterfv);
+ SET_GetConvolutionParameterfvEXT(table, exec_GetConvolutionParameterfv);
+ SET_GetConvolutionParameteriv(table, exec_GetConvolutionParameteriv);
+ SET_GetConvolutionParameterivEXT(table, exec_GetConvolutionParameteriv);
+ SET_GetHistogram(table, exec_GetHistogram);
+ SET_GetHistogramEXT(table, exec_GetHistogram);
+ SET_GetHistogramParameterfv(table, exec_GetHistogramParameterfv);
+ SET_GetHistogramParameterfvEXT(table, exec_GetHistogramParameterfv);
+ SET_GetHistogramParameteriv(table, exec_GetHistogramParameteriv);
+ SET_GetHistogramParameterivEXT(table, exec_GetHistogramParameteriv);
+ SET_GetMinmax(table, exec_GetMinmax);
+ SET_GetMinmaxEXT(table, exec_GetMinmax);
+ SET_GetMinmaxParameterfv(table, exec_GetMinmaxParameterfv);
+ SET_GetMinmaxParameterfvEXT(table, exec_GetMinmaxParameterfv);
+ SET_GetMinmaxParameteriv(table, exec_GetMinmaxParameteriv);
+ SET_GetMinmaxParameterivEXT(table, exec_GetMinmaxParameteriv);
+ SET_GetSeparableFilter(table, exec_GetSeparableFilter);
+ SET_GetSeparableFilterEXT(table, exec_GetSeparableFilter);
+ SET_Histogram(table, save_Histogram);
+ SET_Minmax(table, save_Minmax);
+ SET_ResetHistogram(table, save_ResetHistogram);
+ SET_ResetMinmax(table, save_ResetMinmax);
+ SET_SeparableFilter2D(table, exec_SeparableFilter2D);
+
+ /* 2. GL_EXT_blend_color */
+#if 0
+ SET_BlendColorEXT(table, save_BlendColorEXT);
+#endif
+
+ /* 3. GL_EXT_polygon_offset */
+ SET_PolygonOffsetEXT(table, save_PolygonOffsetEXT);
+
+ /* 6. GL_EXT_texture3d */
+#if 0
+ SET_CopyTexSubImage3DEXT(table, save_CopyTexSubImage3D);
+ SET_TexImage3DEXT(table, save_TexImage3DEXT);
+ SET_TexSubImage3DEXT(table, save_TexSubImage3D);
+#endif
+
+ /* 15. GL_SGIX_pixel_texture */
+ SET_PixelTexGenSGIX(table, save_PixelTexGenSGIX);
+
+ /* 15. GL_SGIS_pixel_texture */
+ SET_PixelTexGenParameteriSGIS(table, save_PixelTexGenParameteriSGIS);
+ SET_PixelTexGenParameterfSGIS(table, save_PixelTexGenParameterfSGIS);
+ SET_PixelTexGenParameterivSGIS(table, save_PixelTexGenParameterivSGIS);
+ SET_PixelTexGenParameterfvSGIS(table, save_PixelTexGenParameterfvSGIS);
+ SET_GetPixelTexGenParameterivSGIS(table, exec_GetPixelTexGenParameterivSGIS);
+ SET_GetPixelTexGenParameterfvSGIS(table, exec_GetPixelTexGenParameterfvSGIS);
+
+ /* 30. GL_EXT_vertex_array */
+ SET_ColorPointerEXT(table, exec_ColorPointerEXT);
+ SET_EdgeFlagPointerEXT(table, exec_EdgeFlagPointerEXT);
+ SET_IndexPointerEXT(table, exec_IndexPointerEXT);
+ SET_NormalPointerEXT(table, exec_NormalPointerEXT);
+ SET_TexCoordPointerEXT(table, exec_TexCoordPointerEXT);
+ SET_VertexPointerEXT(table, exec_VertexPointerEXT);
+
+ /* 37. GL_EXT_blend_minmax */
+#if 0
+ SET_BlendEquationEXT(table, save_BlendEquationEXT);
+#endif
+
+ /* 54. GL_EXT_point_parameters */
+ SET_PointParameterfEXT(table, save_PointParameterfEXT);
+ SET_PointParameterfvEXT(table, save_PointParameterfvEXT);
+
+ /* 78. GL_EXT_paletted_texture */
+#if 0
+ SET_ColorTableEXT(table, save_ColorTable);
+ SET_ColorSubTableEXT(table, save_ColorSubTable);
+#endif
+ SET_GetColorTableEXT(table, exec_GetColorTable);
+ SET_GetColorTableParameterfvEXT(table, exec_GetColorTableParameterfv);
+ SET_GetColorTableParameterivEXT(table, exec_GetColorTableParameteriv);
+
+ /* 97. GL_EXT_compiled_vertex_array */
+ SET_LockArraysEXT(table, exec_LockArraysEXT);
+ SET_UnlockArraysEXT(table, exec_UnlockArraysEXT);
+
+ /* 145. GL_EXT_secondary_color */
+ SET_SecondaryColorPointerEXT(table, exec_SecondaryColorPointerEXT);
+
+ /* 148. GL_EXT_multi_draw_arrays */
+ SET_MultiDrawArraysEXT(table, exec_MultiDrawArraysEXT);
+ SET_MultiDrawElementsEXT(table, exec_MultiDrawElementsEXT);
+
+ /* 149. GL_EXT_fog_coord */
+ SET_FogCoordPointerEXT(table, exec_FogCoordPointerEXT);
+
+ /* 173. GL_EXT_blend_func_separate */
+ SET_BlendFuncSeparateEXT(table, save_BlendFuncSeparateEXT);
+
+ /* 196. GL_MESA_resize_buffers */
+ SET_ResizeBuffersMESA(table, _mesa_ResizeBuffersMESA);
+
+ /* 197. GL_MESA_window_pos */
+ SET_WindowPos2dMESA(table, save_WindowPos2dMESA);
+ SET_WindowPos2dvMESA(table, save_WindowPos2dvMESA);
+ SET_WindowPos2fMESA(table, save_WindowPos2fMESA);
+ SET_WindowPos2fvMESA(table, save_WindowPos2fvMESA);
+ SET_WindowPos2iMESA(table, save_WindowPos2iMESA);
+ SET_WindowPos2ivMESA(table, save_WindowPos2ivMESA);
+ SET_WindowPos2sMESA(table, save_WindowPos2sMESA);
+ SET_WindowPos2svMESA(table, save_WindowPos2svMESA);
+ SET_WindowPos3dMESA(table, save_WindowPos3dMESA);
+ SET_WindowPos3dvMESA(table, save_WindowPos3dvMESA);
+ SET_WindowPos3fMESA(table, save_WindowPos3fMESA);
+ SET_WindowPos3fvMESA(table, save_WindowPos3fvMESA);
+ SET_WindowPos3iMESA(table, save_WindowPos3iMESA);
+ SET_WindowPos3ivMESA(table, save_WindowPos3ivMESA);
+ SET_WindowPos3sMESA(table, save_WindowPos3sMESA);
+ SET_WindowPos3svMESA(table, save_WindowPos3svMESA);
+ SET_WindowPos4dMESA(table, save_WindowPos4dMESA);
+ SET_WindowPos4dvMESA(table, save_WindowPos4dvMESA);
+ SET_WindowPos4fMESA(table, save_WindowPos4fMESA);
+ SET_WindowPos4fvMESA(table, save_WindowPos4fvMESA);
+ SET_WindowPos4iMESA(table, save_WindowPos4iMESA);
+ SET_WindowPos4ivMESA(table, save_WindowPos4ivMESA);
+ SET_WindowPos4sMESA(table, save_WindowPos4sMESA);
+ SET_WindowPos4svMESA(table, save_WindowPos4svMESA);
+
+ /* 200. GL_IBM_multimode_draw_arrays */
+ SET_MultiModeDrawArraysIBM(table, exec_MultiModeDrawArraysIBM);
+ SET_MultiModeDrawElementsIBM(table, exec_MultiModeDrawElementsIBM);
+
+#if FEATURE_NV_vertex_program
+ /* 233. GL_NV_vertex_program */
+ /* The following commands DO NOT go into display lists:
+ * AreProgramsResidentNV, IsProgramNV, GenProgramsNV, DeleteProgramsNV,
+ * VertexAttribPointerNV, GetProgram*, GetVertexAttrib*
+ */
+ SET_BindProgramNV(table, save_BindProgramNV);
+ SET_DeleteProgramsNV(table, _mesa_DeletePrograms);
+ SET_ExecuteProgramNV(table, save_ExecuteProgramNV);
+ SET_GenProgramsNV(table, _mesa_GenPrograms);
+ SET_AreProgramsResidentNV(table, _mesa_AreProgramsResidentNV);
+ SET_RequestResidentProgramsNV(table, save_RequestResidentProgramsNV);
+ SET_GetProgramParameterfvNV(table, _mesa_GetProgramParameterfvNV);
+ SET_GetProgramParameterdvNV(table, _mesa_GetProgramParameterdvNV);
+ SET_GetProgramivNV(table, _mesa_GetProgramivNV);
+ SET_GetProgramStringNV(table, _mesa_GetProgramStringNV);
+ SET_GetTrackMatrixivNV(table, _mesa_GetTrackMatrixivNV);
+ SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV);
+ SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV);
+ SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV);
+ SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV);
+ SET_IsProgramNV(table, _mesa_IsProgram);
+ SET_LoadProgramNV(table, save_LoadProgramNV);
+ SET_ProgramParameter4dNV(table, save_ProgramParameter4dNV);
+ SET_ProgramParameter4dvNV(table, save_ProgramParameter4dvNV);
+ SET_ProgramParameter4fNV(table, save_ProgramParameter4fNV);
+ SET_ProgramParameter4fvNV(table, save_ProgramParameter4fvNV);
+ SET_ProgramParameters4dvNV(table, save_ProgramParameters4dvNV);
+ SET_ProgramParameters4fvNV(table, save_ProgramParameters4fvNV);
+ SET_TrackMatrixNV(table, save_TrackMatrixNV);
+ SET_VertexAttribPointerNV(table, _mesa_VertexAttribPointerNV);
+#endif
+
+ /* 245. GL_ATI_fragment_shader */
+#if FEATURE_ATI_fragment_shader
+ SET_BindFragmentShaderATI(table, save_BindFragmentShaderATI);
+ SET_SetFragmentShaderConstantATI(table, save_SetFragmentShaderConstantATI);
+#endif
+
+ /* 282. GL_NV_fragment_program */
+#if FEATURE_NV_fragment_program
+ SET_ProgramNamedParameter4fNV(table, save_ProgramNamedParameter4fNV);
+ SET_ProgramNamedParameter4dNV(table, save_ProgramNamedParameter4dNV);
+ SET_ProgramNamedParameter4fvNV(table, save_ProgramNamedParameter4fvNV);
+ SET_ProgramNamedParameter4dvNV(table, save_ProgramNamedParameter4dvNV);
+ SET_GetProgramNamedParameterfvNV(table, _mesa_GetProgramNamedParameterfvNV);
+ SET_GetProgramNamedParameterdvNV(table, _mesa_GetProgramNamedParameterdvNV);
+ SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB);
+ SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB);
+ SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB);
+ SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB);
+ SET_GetProgramLocalParameterdvARB(table, _mesa_GetProgramLocalParameterdvARB);
+ SET_GetProgramLocalParameterfvARB(table, _mesa_GetProgramLocalParameterfvARB);
+#endif
+
+ /* 262. GL_NV_point_sprite */
+ SET_PointParameteriNV(table, save_PointParameteriNV);
+ SET_PointParameterivNV(table, save_PointParameterivNV);
+
+ /* 268. GL_EXT_stencil_two_side */
+ SET_ActiveStencilFaceEXT(table, save_ActiveStencilFaceEXT);
+
+ /* ???. GL_EXT_depth_bounds_test */
+ SET_DepthBoundsEXT(table, save_DepthBoundsEXT);
+
+ /* ARB 1. GL_ARB_multitexture */
+ SET_ActiveTextureARB(table, save_ActiveTextureARB);
+ SET_ClientActiveTextureARB(table, exec_ClientActiveTextureARB);
+
+ /* ARB 3. GL_ARB_transpose_matrix */
+ SET_LoadTransposeMatrixdARB(table, save_LoadTransposeMatrixdARB);
+ SET_LoadTransposeMatrixfARB(table, save_LoadTransposeMatrixfARB);
+ SET_MultTransposeMatrixdARB(table, save_MultTransposeMatrixdARB);
+ SET_MultTransposeMatrixfARB(table, save_MultTransposeMatrixfARB);
+
+ /* ARB 5. GL_ARB_multisample */
+ SET_SampleCoverageARB(table, save_SampleCoverageARB);
+
+ /* ARB 12. GL_ARB_texture_compression */
+ SET_CompressedTexImage3DARB(table, save_CompressedTexImage3DARB);
+ SET_CompressedTexImage2DARB(table, save_CompressedTexImage2DARB);
+ SET_CompressedTexImage1DARB(table, save_CompressedTexImage1DARB);
+ SET_CompressedTexSubImage3DARB(table, save_CompressedTexSubImage3DARB);
+ SET_CompressedTexSubImage2DARB(table, save_CompressedTexSubImage2DARB);
+ SET_CompressedTexSubImage1DARB(table, save_CompressedTexSubImage1DARB);
+ SET_GetCompressedTexImageARB(table, exec_GetCompressedTexImageARB);
+
+ /* ARB 14. GL_ARB_point_parameters */
+ /* aliased with EXT_point_parameters functions */
+
+ /* ARB 25. GL_ARB_window_pos */
+ /* aliased with MESA_window_pos functions */
+
+ /* ARB 26. GL_ARB_vertex_program */
+ /* ARB 27. GL_ARB_fragment_program */
+#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
+ /* glVertexAttrib* functions alias the NV ones, handled elsewhere */
+ SET_VertexAttribPointerARB(table, _mesa_VertexAttribPointerARB);
+ SET_EnableVertexAttribArrayARB(table, _mesa_EnableVertexAttribArrayARB);
+ SET_DisableVertexAttribArrayARB(table, _mesa_DisableVertexAttribArrayARB);
+ SET_ProgramStringARB(table, save_ProgramStringARB);
+ SET_BindProgramNV(table, save_BindProgramNV);
+ SET_DeleteProgramsNV(table, _mesa_DeletePrograms);
+ SET_GenProgramsNV(table, _mesa_GenPrograms);
+ SET_IsProgramNV(table, _mesa_IsProgram);
+ SET_GetVertexAttribdvNV(table, _mesa_GetVertexAttribdvNV);
+ SET_GetVertexAttribfvNV(table, _mesa_GetVertexAttribfvNV);
+ SET_GetVertexAttribivNV(table, _mesa_GetVertexAttribivNV);
+ SET_GetVertexAttribPointervNV(table, _mesa_GetVertexAttribPointervNV);
+ SET_ProgramEnvParameter4dARB(table, save_ProgramEnvParameter4dARB);
+ SET_ProgramEnvParameter4dvARB(table, save_ProgramEnvParameter4dvARB);
+ SET_ProgramEnvParameter4fARB(table, save_ProgramEnvParameter4fARB);
+ SET_ProgramEnvParameter4fvARB(table, save_ProgramEnvParameter4fvARB);
+ SET_ProgramLocalParameter4dARB(table, save_ProgramLocalParameter4dARB);
+ SET_ProgramLocalParameter4dvARB(table, save_ProgramLocalParameter4dvARB);
+ SET_ProgramLocalParameter4fARB(table, save_ProgramLocalParameter4fARB);
+ SET_ProgramLocalParameter4fvARB(table, save_ProgramLocalParameter4fvARB);
+ SET_GetProgramEnvParameterdvARB(table, _mesa_GetProgramEnvParameterdvARB);
+ SET_GetProgramEnvParameterfvARB(table, _mesa_GetProgramEnvParameterfvARB);
+ SET_GetProgramLocalParameterdvARB(table, _mesa_GetProgramLocalParameterdvARB);
+ SET_GetProgramLocalParameterfvARB(table, _mesa_GetProgramLocalParameterfvARB);
+ SET_GetProgramivARB(table, _mesa_GetProgramivARB);
+ SET_GetProgramStringARB(table, _mesa_GetProgramStringARB);
+#endif
+
+ /* ARB 28. GL_ARB_vertex_buffer_object */
+#if FEATURE_ARB_vertex_buffer_object
+ /* None of the extension's functions get compiled */
+ SET_BindBufferARB(table, _mesa_BindBufferARB);
+ SET_BufferDataARB(table, _mesa_BufferDataARB);
+ SET_BufferSubDataARB(table, _mesa_BufferSubDataARB);
+ SET_DeleteBuffersARB(table, _mesa_DeleteBuffersARB);
+ SET_GenBuffersARB(table, _mesa_GenBuffersARB);
+ SET_GetBufferParameterivARB(table, _mesa_GetBufferParameterivARB);
+ SET_GetBufferPointervARB(table, _mesa_GetBufferPointervARB);
+ SET_GetBufferSubDataARB(table, _mesa_GetBufferSubDataARB);
+ SET_IsBufferARB(table, _mesa_IsBufferARB);
+ SET_MapBufferARB(table, _mesa_MapBufferARB);
+ SET_UnmapBufferARB(table, _mesa_UnmapBufferARB);
+#endif
+
+#if FEATURE_ARB_occlusion_query
+ SET_BeginQueryARB(table, save_BeginQueryARB);
+ SET_EndQueryARB(table, save_EndQueryARB);
+ SET_GenQueriesARB(table, _mesa_GenQueriesARB);
+ SET_DeleteQueriesARB(table, _mesa_DeleteQueriesARB);
+ SET_IsQueryARB(table, _mesa_IsQueryARB);
+ SET_GetQueryivARB(table, _mesa_GetQueryivARB);
+ SET_GetQueryObjectivARB(table, _mesa_GetQueryObjectivARB);
+ SET_GetQueryObjectuivARB(table, _mesa_GetQueryObjectuivARB);
+#endif
+ SET_DrawBuffersARB(table, save_DrawBuffersARB);
+
+ /* 299. GL_EXT_blend_equation_separate */
+ SET_BlendEquationSeparateEXT(table, save_BlendEquationSeparateEXT);
+}
+
+
+
+/***
+ *** Debugging code
+ ***/
+static const char *enum_string( GLenum k )
+{
+ return _mesa_lookup_enum_by_nr( k );
+}
+
+
+/*
+ * Print the commands in a display list. For debugging only.
+ * TODO: many commands aren't handled yet.
+ */
+static void GLAPIENTRY print_list( GLcontext *ctx, GLuint list )
+{
+ struct mesa_display_list *dlist;
+ Node *n;
+ GLboolean done;
+
+ if (!CALL_IsList(GET_DISPATCH(), (list))) {
+ _mesa_printf("%u is not a display list ID\n", list);
+ return;
+ }
+
+ dlist = (struct mesa_display_list *) _mesa_HashLookup(ctx->Shared->DisplayList, list);
+ if (!dlist)
+ return;
+
+ n = dlist->node;
+
+ _mesa_printf("START-LIST %u, address %p\n", list, (void*)n );
+
+ done = n ? GL_FALSE : GL_TRUE;
+ while (!done) {
+ OpCode opcode = n[0].opcode;
+ GLint i = (GLint) n[0].opcode - (GLint) OPCODE_EXT_0;
+
+ if (i >= 0 && i < (GLint) ctx->ListExt.NumOpcodes) {
+ /* this is a driver-extended opcode */
+ ctx->ListExt.Opcode[i].Print(ctx, &n[1]);
+ n += ctx->ListExt.Opcode[i].Size;
+ }
+ else {
+ switch (opcode) {
+ case OPCODE_ACCUM:
+ _mesa_printf("accum %s %g\n", enum_string(n[1].e), n[2].f );
+ break;
+ case OPCODE_BITMAP:
+ _mesa_printf("Bitmap %d %d %g %g %g %g %p\n", n[1].i, n[2].i,
+ n[3].f, n[4].f, n[5].f, n[6].f, (void *) n[7].data );
+ break;
+ case OPCODE_CALL_LIST:
+ _mesa_printf("CallList %d\n", (int) n[1].ui );
+ break;
+ case OPCODE_CALL_LIST_OFFSET:
+ _mesa_printf("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:
+ _mesa_printf("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:
+ _mesa_printf("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:
+ _mesa_printf("Disable %s\n", enum_string(n[1].e));
+ break;
+ case OPCODE_ENABLE:
+ _mesa_printf("Enable %s\n", enum_string(n[1].e));
+ break;
+ case OPCODE_FRUSTUM:
+ _mesa_printf("Frustum %g %g %g %g %g %g\n",
+ n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
+ break;
+ case OPCODE_LINE_STIPPLE:
+ _mesa_printf("LineStipple %d %x\n", n[1].i, (int) n[2].us );
+ break;
+ case OPCODE_LOAD_IDENTITY:
+ _mesa_printf("LoadIdentity\n");
+ break;
+ case OPCODE_LOAD_MATRIX:
+ _mesa_printf("LoadMatrix\n");
+ _mesa_printf(" %8f %8f %8f %8f\n",
+ n[1].f, n[5].f, n[9].f, n[13].f);
+ _mesa_printf(" %8f %8f %8f %8f\n",
+ n[2].f, n[6].f, n[10].f, n[14].f);
+ _mesa_printf(" %8f %8f %8f %8f\n",
+ n[3].f, n[7].f, n[11].f, n[15].f);
+ _mesa_printf(" %8f %8f %8f %8f\n",
+ n[4].f, n[8].f, n[12].f, n[16].f);
+ break;
+ case OPCODE_MULT_MATRIX:
+ _mesa_printf("MultMatrix (or Rotate)\n");
+ _mesa_printf(" %8f %8f %8f %8f\n",
+ n[1].f, n[5].f, n[9].f, n[13].f);
+ _mesa_printf(" %8f %8f %8f %8f\n",
+ n[2].f, n[6].f, n[10].f, n[14].f);
+ _mesa_printf(" %8f %8f %8f %8f\n",
+ n[3].f, n[7].f, n[11].f, n[15].f);
+ _mesa_printf(" %8f %8f %8f %8f\n",
+ n[4].f, n[8].f, n[12].f, n[16].f);
+ break;
+ case OPCODE_ORTHO:
+ _mesa_printf("Ortho %g %g %g %g %g %g\n",
+ n[1].f, n[2].f, n[3].f, n[4].f, n[5].f, n[6].f );
+ break;
+ case OPCODE_POP_ATTRIB:
+ _mesa_printf("PopAttrib\n");
+ break;
+ case OPCODE_POP_MATRIX:
+ _mesa_printf("PopMatrix\n");
+ break;
+ case OPCODE_POP_NAME:
+ _mesa_printf("PopName\n");
+ break;
+ case OPCODE_PUSH_ATTRIB:
+ _mesa_printf("PushAttrib %x\n", n[1].bf );
+ break;
+ case OPCODE_PUSH_MATRIX:
+ _mesa_printf("PushMatrix\n");
+ break;
+ case OPCODE_PUSH_NAME:
+ _mesa_printf("PushName %d\n", (int) n[1].ui );
+ break;
+ case OPCODE_RASTER_POS:
+ _mesa_printf("RasterPos %g %g %g %g\n",
+ n[1].f, n[2].f,n[3].f,n[4].f);
+ break;
+ case OPCODE_ROTATE:
+ _mesa_printf("Rotate %g %g %g %g\n",
+ n[1].f, n[2].f, n[3].f, n[4].f );
+ break;
+ case OPCODE_SCALE:
+ _mesa_printf("Scale %g %g %g\n", n[1].f, n[2].f, n[3].f );
+ break;
+ case OPCODE_TRANSLATE:
+ _mesa_printf("Translate %g %g %g\n", n[1].f, n[2].f, n[3].f );
+ break;
+ case OPCODE_BIND_TEXTURE:
+ _mesa_printf("BindTexture %s %d\n",
+ _mesa_lookup_enum_by_nr(n[1].ui), n[2].ui);
+ break;
+ case OPCODE_SHADE_MODEL:
+ _mesa_printf("ShadeModel %s\n",
+ _mesa_lookup_enum_by_nr(n[1].ui));
+ break;
+ case OPCODE_MAP1:
+ _mesa_printf("Map1 %s %.3f %.3f %d %d\n",
+ _mesa_lookup_enum_by_nr(n[1].ui),
+ n[2].f, n[3].f, n[4].i, n[5].i);
+ break;
+ case OPCODE_MAP2:
+ _mesa_printf("Map2 %s %.3f %.3f %.3f %.3f %d %d %d %d\n",
+ _mesa_lookup_enum_by_nr(n[1].ui),
+ n[2].f, n[3].f, n[4].f, n[5].f,
+ n[6].i, n[7].i, n[8].i, n[9].i);
+ break;
+ case OPCODE_MAPGRID1:
+ _mesa_printf("MapGrid1 %d %.3f %.3f\n",
+ n[1].i, n[2].f, n[3].f);
+ break;
+ case OPCODE_MAPGRID2:
+ _mesa_printf("MapGrid2 %d %.3f %.3f, %d %.3f %.3f\n",
+ n[1].i, n[2].f, n[3].f,
+ n[4].i, n[5].f, n[6].f);
+ break;
+ case OPCODE_EVALMESH1:
+ _mesa_printf("EvalMesh1 %d %d\n", n[1].i, n[2].i);
+ break;
+ case OPCODE_EVALMESH2:
+ _mesa_printf("EvalMesh2 %d %d %d %d\n",
+ n[1].i, n[2].i, n[3].i, n[4].i);
+ break;
+
+ case OPCODE_ATTR_1F_NV:
+ _mesa_printf("ATTR_1F_NV attr %d: %f\n",
+ n[1].i, n[2].f);
+ break;
+ case OPCODE_ATTR_2F_NV:
+ _mesa_printf("ATTR_2F_NV attr %d: %f %f\n",
+ n[1].i, n[2].f, n[3].f);
+ break;
+ case OPCODE_ATTR_3F_NV:
+ _mesa_printf("ATTR_3F_NV attr %d: %f %f %f\n",
+ n[1].i, n[2].f, n[3].f, n[4].f);
+ break;
+ case OPCODE_ATTR_4F_NV:
+ _mesa_printf("ATTR_4F_NV attr %d: %f %f %f %f\n",
+ n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
+ break;
+ case OPCODE_ATTR_1F_ARB:
+ _mesa_printf("ATTR_1F_ARB attr %d: %f\n",
+ n[1].i, n[2].f);
+ break;
+ case OPCODE_ATTR_2F_ARB:
+ _mesa_printf("ATTR_2F_ARB attr %d: %f %f\n",
+ n[1].i, n[2].f, n[3].f);
+ break;
+ case OPCODE_ATTR_3F_ARB:
+ _mesa_printf("ATTR_3F_ARB attr %d: %f %f %f\n",
+ n[1].i, n[2].f, n[3].f, n[4].f);
+ break;
+ case OPCODE_ATTR_4F_ARB:
+ _mesa_printf("ATTR_4F_ARB attr %d: %f %f %f %f\n",
+ n[1].i, n[2].f, n[3].f, n[4].f, n[5].f);
+ break;
+
+ case OPCODE_MATERIAL:
+ _mesa_printf("MATERIAL %x %x: %f %f %f %f\n",
+ n[1].i, n[2].i, n[3].f, n[4].f, n[5].f, n[6].f);
+ break;
+ case OPCODE_INDEX:
+ _mesa_printf("INDEX: %f\n", n[1].f);
+ break;
+ case OPCODE_EDGEFLAG:
+ _mesa_printf("EDGEFLAG: %d\n", n[1].i);
+ break;
+ case OPCODE_BEGIN:
+ _mesa_printf("BEGIN %x\n", n[1].i);
+ break;
+ case OPCODE_END:
+ _mesa_printf("END\n");
+ break;
+ case OPCODE_RECTF:
+ _mesa_printf("RECTF %f %f %f %f\n", n[1].f, n[2].f, n[3].f, n[4].f);
+ break;
+ case OPCODE_EVAL_C1:
+ _mesa_printf("EVAL_C1 %f\n", n[1].f);
+ break;
+ case OPCODE_EVAL_C2:
+ _mesa_printf("EVAL_C2 %f %f\n", n[1].f, n[2].f);
+ break;
+ case OPCODE_EVAL_P1:
+ _mesa_printf("EVAL_P1 %d\n", n[1].i);
+ break;
+ case OPCODE_EVAL_P2:
+ _mesa_printf("EVAL_P2 %d %d\n", n[1].i, n[2].i);
+ break;
+
+
+
+ /*
+ * meta opcodes/commands
+ */
+ case OPCODE_ERROR:
+ _mesa_printf("Error: %s %s\n",
+ enum_string(n[1].e), (const char *)n[2].data );
+ break;
+ case OPCODE_CONTINUE:
+ _mesa_printf("DISPLAY-LIST-CONTINUE\n");
+ n = (Node *) n[1].next;
+ break;
+ case OPCODE_END_OF_LIST:
+ _mesa_printf("END-LIST %u\n", list);
+ done = GL_TRUE;
+ break;
+ default:
+ if (opcode < 0 || opcode > OPCODE_END_OF_LIST) {
+ _mesa_printf("ERROR IN DISPLAY LIST: opcode = %d, address = %p\n",
+ opcode, (void*) n);
+ return;
+ }
+ else {
+ _mesa_printf("command %d, %u operands\n", opcode, InstSize[opcode]);
+ }
+ }
+ /* increment n to point to next compiled command */
+ if (opcode!=OPCODE_CONTINUE) {
+ n += InstSize[opcode];
+ }
+ }
+ }
+}
+
+
+
+/*
+ * Clients may call this function to help debug display list problems.
+ * This function is _ONLY_FOR_DEBUGGING_PURPOSES_. It may be removed,
+ * changed, or break in the future without notice.
+ */
+void mesa_print_display_list( GLuint list )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ print_list( ctx, list );
+}
+
+
+/**********************************************************************/
+/***** Initialization *****/
+/**********************************************************************/
+
+
+void _mesa_save_vtxfmt_init( GLvertexformat *vfmt )
+{
+ vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */
+ vfmt->Begin = save_Begin;
+ vfmt->CallList = _mesa_save_CallList;
+ vfmt->CallLists = _mesa_save_CallLists;
+ vfmt->Color3f = save_Color3f;
+ vfmt->Color3fv = save_Color3fv;
+ vfmt->Color4f = save_Color4f;
+ vfmt->Color4fv = save_Color4fv;
+ vfmt->EdgeFlag = save_EdgeFlag;
+ vfmt->EdgeFlagv = save_EdgeFlagv;
+ vfmt->End = save_End;
+ vfmt->EvalCoord1f = save_EvalCoord1f;
+ vfmt->EvalCoord1fv = save_EvalCoord1fv;
+ vfmt->EvalCoord2f = save_EvalCoord2f;
+ vfmt->EvalCoord2fv = save_EvalCoord2fv;
+ vfmt->EvalPoint1 = save_EvalPoint1;
+ vfmt->EvalPoint2 = save_EvalPoint2;
+ vfmt->FogCoordfEXT = save_FogCoordfEXT;
+ vfmt->FogCoordfvEXT = save_FogCoordfvEXT;
+ vfmt->Indexf = save_Indexf;
+ vfmt->Indexfv = save_Indexfv;
+ vfmt->Materialfv = save_Materialfv;
+ vfmt->MultiTexCoord1fARB = save_MultiTexCoord1f;
+ vfmt->MultiTexCoord1fvARB = save_MultiTexCoord1fv;
+ vfmt->MultiTexCoord2fARB = save_MultiTexCoord2f;
+ vfmt->MultiTexCoord2fvARB = save_MultiTexCoord2fv;
+ vfmt->MultiTexCoord3fARB = save_MultiTexCoord3f;
+ vfmt->MultiTexCoord3fvARB = save_MultiTexCoord3fv;
+ vfmt->MultiTexCoord4fARB = save_MultiTexCoord4f;
+ vfmt->MultiTexCoord4fvARB = save_MultiTexCoord4fv;
+ vfmt->Normal3f = save_Normal3f;
+ vfmt->Normal3fv = save_Normal3fv;
+ vfmt->SecondaryColor3fEXT = save_SecondaryColor3fEXT;
+ vfmt->SecondaryColor3fvEXT = save_SecondaryColor3fvEXT;
+ vfmt->TexCoord1f = save_TexCoord1f;
+ vfmt->TexCoord1fv = save_TexCoord1fv;
+ vfmt->TexCoord2f = save_TexCoord2f;
+ vfmt->TexCoord2fv = save_TexCoord2fv;
+ vfmt->TexCoord3f = save_TexCoord3f;
+ vfmt->TexCoord3fv = save_TexCoord3fv;
+ vfmt->TexCoord4f = save_TexCoord4f;
+ vfmt->TexCoord4fv = save_TexCoord4fv;
+ vfmt->Vertex2f = save_Vertex2f;
+ vfmt->Vertex2fv = save_Vertex2fv;
+ vfmt->Vertex3f = save_Vertex3f;
+ vfmt->Vertex3fv = save_Vertex3fv;
+ vfmt->Vertex4f = save_Vertex4f;
+ vfmt->Vertex4fv = save_Vertex4fv;
+ vfmt->VertexAttrib1fNV = save_VertexAttrib1fNV;
+ vfmt->VertexAttrib1fvNV = save_VertexAttrib1fvNV;
+ vfmt->VertexAttrib2fNV = save_VertexAttrib2fNV;
+ vfmt->VertexAttrib2fvNV = save_VertexAttrib2fvNV;
+ vfmt->VertexAttrib3fNV = save_VertexAttrib3fNV;
+ vfmt->VertexAttrib3fvNV = save_VertexAttrib3fvNV;
+ vfmt->VertexAttrib4fNV = save_VertexAttrib4fNV;
+ vfmt->VertexAttrib4fvNV = save_VertexAttrib4fvNV;
+ vfmt->VertexAttrib1fARB = save_VertexAttrib1fARB;
+ vfmt->VertexAttrib1fvARB = save_VertexAttrib1fvARB;
+ vfmt->VertexAttrib2fARB = save_VertexAttrib2fARB;
+ vfmt->VertexAttrib2fvARB = save_VertexAttrib2fvARB;
+ vfmt->VertexAttrib3fARB = save_VertexAttrib3fARB;
+ vfmt->VertexAttrib3fvARB = save_VertexAttrib3fvARB;
+ vfmt->VertexAttrib4fARB = save_VertexAttrib4fARB;
+ vfmt->VertexAttrib4fvARB = save_VertexAttrib4fvARB;
+
+ vfmt->EvalMesh1 = _mesa_save_EvalMesh1;
+ vfmt->EvalMesh2 = _mesa_save_EvalMesh2;
+ vfmt->Rectf = save_Rectf;
+
+ /* The driver is required to implement these as
+ * 1) They can probably do a better job.
+ * 2) A lot of new mechanisms would have to be added to this module
+ * to support it. That code would probably never get used,
+ * because of (1).
+ */
+#if 0
+ vfmt->DrawArrays = 0;
+ vfmt->DrawElements = 0;
+ vfmt->DrawRangeElements = 0;
+#endif
+}
+
+
+
+void _mesa_init_display_list( GLcontext * ctx )
+{
+ /* Display list */
+ ctx->ListState.CallDepth = 0;
+ ctx->ExecuteFlag = GL_TRUE;
+ ctx->CompileFlag = GL_FALSE;
+ ctx->ListState.CurrentListPtr = NULL;
+ ctx->ListState.CurrentBlock = NULL;
+ ctx->ListState.CurrentListNum = 0;
+ ctx->ListState.CurrentPos = 0;
+
+ /* Display List group */
+ ctx->List.ListBase = 0;
+
+ _mesa_save_vtxfmt_init( &ctx->ListState.ListVtxfmt );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/dlist.h b/nx-X11/extras/Mesa/src/mesa/main/dlist.h
new file mode 100644
index 000000000..1a5b391e7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/dlist.h
@@ -0,0 +1,103 @@
+/**
+ * \file dlist.h
+ * Display lists management.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+
+#ifndef DLIST_H
+#define DLIST_H
+
+
+#include "mtypes.h"
+
+
+#if _HAVE_FULL_GL
+
+extern void _mesa_init_lists( void );
+
+extern void _mesa_destroy_list( GLcontext *ctx, GLuint list );
+
+extern void GLAPIENTRY _mesa_CallList( GLuint list );
+
+extern void GLAPIENTRY _mesa_CallLists( GLsizei n, GLenum type, const GLvoid *lists );
+
+extern void GLAPIENTRY _mesa_DeleteLists( GLuint list, GLsizei range );
+
+extern void GLAPIENTRY _mesa_EndList( void );
+
+extern GLuint GLAPIENTRY _mesa_GenLists( GLsizei range );
+
+extern GLboolean GLAPIENTRY _mesa_IsList( GLuint list );
+
+extern void GLAPIENTRY _mesa_ListBase( GLuint base );
+
+extern void GLAPIENTRY _mesa_NewList( GLuint list, GLenum mode );
+
+extern void _mesa_init_dlist_table( struct _glapi_table *table );
+
+extern void _mesa_save_error( GLcontext *ctx, GLenum error, const char *s );
+
+extern void _mesa_compile_error( GLcontext *ctx, GLenum error, const char *s );
+
+
+extern void *_mesa_alloc_instruction( GLcontext *ctx, int opcode, GLint sz );
+
+extern GLint _mesa_alloc_opcode( GLcontext *ctx, GLuint sz,
+ void (*execute)( GLcontext *, void * ),
+ void (*destroy)( GLcontext *, void * ),
+ void (*print)( GLcontext *, void * ) );
+
+extern void GLAPIENTRY _mesa_save_EvalMesh2(GLenum mode, GLint i1, GLint i2,
+ GLint j1, GLint j2 );
+extern void GLAPIENTRY _mesa_save_EvalMesh1( GLenum mode, GLint i1, GLint i2 );
+extern void GLAPIENTRY _mesa_save_CallLists( GLsizei n, GLenum type, const GLvoid *lists );
+extern void GLAPIENTRY _mesa_save_CallList( GLuint list );
+extern void _mesa_init_display_list( GLcontext * ctx );
+extern void _mesa_save_vtxfmt_init( GLvertexformat *vfmt );
+
+
+#else
+
+/** No-op */
+#define _mesa_init_lists() ((void)0)
+
+/** No-op */
+#define _mesa_destroy_list(c,l) ((void)0)
+
+/** No-op */
+#define _mesa_init_dlist_table(t,ts) ((void)0)
+
+/** No-op */
+#define _mesa_init_display_list(c) ((void)0)
+
+/** No-op */
+#define _mesa_save_vtxfmt_init(v) ((void)0)
+
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/drawpix.c b/nx-X11/extras/Mesa/src/mesa/main/drawpix.c
new file mode 100644
index 000000000..4f7e24a1e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/drawpix.c
@@ -0,0 +1,317 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "colormac.h"
+#include "context.h"
+#include "drawpix.h"
+#include "feedback.h"
+#include "macros.h"
+#include "state.h"
+#include "mtypes.h"
+
+
+#if _HAVE_FULL_GL
+
+/*
+ * Execute glDrawPixels
+ */
+void GLAPIENTRY
+_mesa_DrawPixels( GLsizei width, GLsizei height,
+ GLenum format, GLenum type, const GLvoid *pixels )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDrawPixels (invalid fragment program)");
+ return;
+ }
+
+ if (width < 0 || height < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glDrawPixels(width or height < 0" );
+ return;
+ }
+
+ if (ctx->NewState) {
+ _mesa_update_state(ctx);
+ }
+
+ if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
+ "glDrawPixels(incomplete framebuffer)" );
+ return;
+ }
+
+ if (!ctx->Current.RasterPosValid) {
+ return;
+ }
+
+ if (ctx->RenderMode == GL_RENDER) {
+ /* Round, to satisfy conformance tests (matches SGI's OpenGL) */
+ GLint x = IROUND(ctx->Current.RasterPos[0]);
+ GLint y = IROUND(ctx->Current.RasterPos[1]);
+ ctx->OcclusionResult = GL_TRUE;
+ ctx->Driver.DrawPixels(ctx, x, y, width, height, format, type,
+ &ctx->Unpack, pixels);
+ }
+ else if (ctx->RenderMode == GL_FEEDBACK) {
+ /* Feedback the current raster pos info */
+ FLUSH_CURRENT( ctx, 0 );
+ FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_DRAW_PIXEL_TOKEN );
+ _mesa_feedback_vertex( ctx,
+ ctx->Current.RasterPos,
+ ctx->Current.RasterColor,
+ ctx->Current.RasterIndex,
+ ctx->Current.RasterTexCoords[0] );
+ }
+ else {
+ ASSERT(ctx->RenderMode == GL_SELECT);
+ /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height,
+ GLenum type )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyPixels (invalid fragment program)");
+ return;
+ }
+
+ if (width < 0 || height < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glCopyPixels(width or height < 0)" );
+ return;
+ }
+
+ if (ctx->NewState) {
+ _mesa_update_state(ctx);
+ }
+
+ if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT ||
+ ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
+ "glCopyPixels(incomplete framebuffer)" );
+ return;
+ }
+
+ if (!ctx->Current.RasterPosValid) {
+ return;
+ }
+
+ if (ctx->RenderMode == GL_RENDER) {
+ /* Round to satisfy conformance tests (matches SGI's OpenGL) */
+ GLint destx = IROUND(ctx->Current.RasterPos[0]);
+ GLint desty = IROUND(ctx->Current.RasterPos[1]);
+ ctx->OcclusionResult = GL_TRUE;
+ ctx->Driver.CopyPixels( ctx, srcx, srcy, width, height, destx, desty,
+ type );
+ }
+ else if (ctx->RenderMode == GL_FEEDBACK) {
+ FLUSH_CURRENT( ctx, 0 );
+ FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_COPY_PIXEL_TOKEN );
+ _mesa_feedback_vertex( ctx,
+ ctx->Current.RasterPos,
+ ctx->Current.RasterColor,
+ ctx->Current.RasterIndex,
+ ctx->Current.RasterTexCoords[0] );
+ }
+ else {
+ ASSERT(ctx->RenderMode == GL_SELECT);
+ /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */
+ }
+}
+
+#endif /* _HAVE_FULL_GL */
+
+
+
+void GLAPIENTRY
+_mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type, GLvoid *pixels )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ const struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (width < 0 || height < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE,
+ "glReadPixels(width=%d height=%d)", width, height );
+ return;
+ }
+
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ if (ctx->ReadBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
+ "glReadPixels(incomplete framebuffer)" );
+ return;
+ }
+
+ if (!rb) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(no readbuffer)");
+ return;
+ }
+
+ ctx->Driver.ReadPixels(ctx, x, y, width, height,
+ format, type, &ctx->Pack, pixels);
+}
+
+
+
+void GLAPIENTRY
+_mesa_Bitmap( GLsizei width, GLsizei height,
+ GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove,
+ const GLubyte *bitmap )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBitmap (invalid fragment program)");
+ return;
+ }
+
+ if (width < 0 || height < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glBitmap(width or height < 0)" );
+ return;
+ }
+
+ if (!ctx->Current.RasterPosValid) {
+ return; /* do nothing */
+ }
+
+ if (ctx->NewState) {
+ _mesa_update_state(ctx);
+ }
+
+ if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
+ "glBitmap(incomplete framebuffer)");
+ return;
+ }
+
+ if (ctx->RenderMode == GL_RENDER) {
+ /* Truncate, to satisfy conformance tests (matches SGI's OpenGL). */
+ GLint x = IFLOOR(ctx->Current.RasterPos[0] - xorig);
+ GLint y = IFLOOR(ctx->Current.RasterPos[1] - yorig);
+ ctx->OcclusionResult = GL_TRUE;
+ ctx->Driver.Bitmap( ctx, x, y, width, height, &ctx->Unpack, bitmap );
+ }
+#if _HAVE_FULL_GL
+ else if (ctx->RenderMode == GL_FEEDBACK) {
+ FLUSH_CURRENT(ctx, 0);
+ FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_BITMAP_TOKEN );
+ _mesa_feedback_vertex( ctx,
+ ctx->Current.RasterPos,
+ ctx->Current.RasterColor,
+ ctx->Current.RasterIndex,
+ ctx->Current.RasterTexCoords[0] );
+ }
+ else {
+ ASSERT(ctx->RenderMode == GL_SELECT);
+ /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */
+ }
+#endif
+
+ /* update raster position */
+ ctx->Current.RasterPos[0] += xmove;
+ ctx->Current.RasterPos[1] += ymove;
+}
+
+
+
+#if 0 /* experimental */
+/*
+ * Execute glDrawDepthPixelsMESA(). This function accepts both a color
+ * image and depth (Z) image. Rasterization produces fragments with
+ * color and Z taken from these images. This function is intended for
+ * Z-compositing. Normally, this operation requires two glDrawPixels
+ * calls with stencil testing.
+ */
+void GLAPIENTRY
+_mesa_DrawDepthPixelsMESA( GLsizei width, GLsizei height,
+ GLenum colorFormat, GLenum colorType,
+ const GLvoid *colors,
+ GLenum depthType, const GLvoid *depths )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (width < 0 || height < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE,
+ "glDrawDepthPixelsMESA(width or height < 0" );
+ return;
+ }
+
+ if (!ctx->Current.RasterPosValid) {
+ return;
+ }
+
+ if (ctx->NewState) {
+ _mesa_update_state(ctx);
+ }
+
+ if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
+ "glDrawDepthPixelsMESA(incomplete framebuffer)");
+ return;
+ }
+
+ if (ctx->RenderMode == GL_RENDER) {
+ /* Round, to satisfy conformance tests (matches SGI's OpenGL) */
+ GLint x = IROUND(ctx->Current.RasterPos[0]);
+ GLint y = IROUND(ctx->Current.RasterPos[1]);
+ ctx->OcclusionResult = GL_TRUE;
+ ctx->Driver.DrawDepthPixelsMESA(ctx, x, y, width, height,
+ colorFormat, colorType, colors,
+ depthType, depths, &ctx->Unpack);
+ }
+ else if (ctx->RenderMode == GL_FEEDBACK) {
+ /* Feedback the current raster pos info */
+ FLUSH_CURRENT( ctx, 0 );
+ FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_DRAW_PIXEL_TOKEN );
+ _mesa_feedback_vertex( ctx,
+ ctx->Current.RasterPos,
+ ctx->Current.RasterColor,
+ ctx->Current.RasterIndex,
+ ctx->Current.RasterTexCoords[0] );
+ }
+ else {
+ ASSERT(ctx->RenderMode == GL_SELECT);
+ /* Do nothing. See OpenGL Spec, Appendix B, Corollary 6. */
+ }
+}
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/drawpix.h b/nx-X11/extras/Mesa/src/mesa/main/drawpix.h
new file mode 100644
index 000000000..2a2d7de8d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/drawpix.h
@@ -0,0 +1,55 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef DRAWPIXELS_H
+#define DRAWPIXELS_H
+
+
+#include "mtypes.h"
+
+
+extern void GLAPIENTRY
+_mesa_DrawPixels( GLsizei width, GLsizei height,
+ GLenum format, GLenum type, const GLvoid *pixels );
+
+
+extern void GLAPIENTRY
+_mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type, GLvoid *pixels );
+
+
+extern void GLAPIENTRY
+_mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height,
+ GLenum type );
+
+
+extern void GLAPIENTRY
+_mesa_Bitmap( GLsizei width, GLsizei height,
+ GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove,
+ const GLubyte *bitmap );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/enable.c b/nx-X11/extras/Mesa/src/mesa/main/enable.c
new file mode 100644
index 000000000..67fd083ca
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/enable.c
@@ -0,0 +1,1456 @@
+/**
+ * \file enable.c
+ * Enable/disable/query GL capabilities.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "enable.h"
+#include "light.h"
+#include "macros.h"
+#include "simple_list.h"
+#include "mtypes.h"
+#include "enums.h"
+#include "math/m_matrix.h"
+#include "math/m_xform.h"
+
+
+
+#define CHECK_EXTENSION(EXTNAME, CAP) \
+ if (!ctx->Extensions.EXTNAME) { \
+ _mesa_error(ctx, GL_INVALID_ENUM, "gl%sClientState(0x%x)", \
+ state ? "Enable" : "Disable", CAP); \
+ return; \
+ }
+
+
+static void
+client_state( GLcontext *ctx, GLenum cap, GLboolean state )
+{
+ GLuint flag;
+ GLuint *var;
+
+ switch (cap) {
+ case GL_VERTEX_ARRAY:
+ var = &ctx->Array.Vertex.Enabled;
+ flag = _NEW_ARRAY_VERTEX;
+ break;
+ case GL_NORMAL_ARRAY:
+ var = &ctx->Array.Normal.Enabled;
+ flag = _NEW_ARRAY_NORMAL;
+ break;
+ case GL_COLOR_ARRAY:
+ var = &ctx->Array.Color.Enabled;
+ flag = _NEW_ARRAY_COLOR0;
+ break;
+ case GL_INDEX_ARRAY:
+ var = &ctx->Array.Index.Enabled;
+ flag = _NEW_ARRAY_INDEX;
+ break;
+ case GL_TEXTURE_COORD_ARRAY:
+ var = &ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled;
+ flag = _NEW_ARRAY_TEXCOORD(ctx->Array.ActiveTexture);
+ break;
+ case GL_EDGE_FLAG_ARRAY:
+ var = &ctx->Array.EdgeFlag.Enabled;
+ flag = _NEW_ARRAY_EDGEFLAG;
+ break;
+ case GL_FOG_COORDINATE_ARRAY_EXT:
+ var = &ctx->Array.FogCoord.Enabled;
+ flag = _NEW_ARRAY_FOGCOORD;
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_EXT:
+ var = &ctx->Array.SecondaryColor.Enabled;
+ flag = _NEW_ARRAY_COLOR1;
+ break;
+
+#if FEATURE_NV_vertex_program
+ case GL_VERTEX_ATTRIB_ARRAY0_NV:
+ case GL_VERTEX_ATTRIB_ARRAY1_NV:
+ case GL_VERTEX_ATTRIB_ARRAY2_NV:
+ case GL_VERTEX_ATTRIB_ARRAY3_NV:
+ case GL_VERTEX_ATTRIB_ARRAY4_NV:
+ case GL_VERTEX_ATTRIB_ARRAY5_NV:
+ case GL_VERTEX_ATTRIB_ARRAY6_NV:
+ case GL_VERTEX_ATTRIB_ARRAY7_NV:
+ case GL_VERTEX_ATTRIB_ARRAY8_NV:
+ case GL_VERTEX_ATTRIB_ARRAY9_NV:
+ case GL_VERTEX_ATTRIB_ARRAY10_NV:
+ case GL_VERTEX_ATTRIB_ARRAY11_NV:
+ case GL_VERTEX_ATTRIB_ARRAY12_NV:
+ case GL_VERTEX_ATTRIB_ARRAY13_NV:
+ case GL_VERTEX_ATTRIB_ARRAY14_NV:
+ case GL_VERTEX_ATTRIB_ARRAY15_NV:
+ CHECK_EXTENSION(NV_vertex_program, cap);
+ {
+ GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
+ var = &ctx->Array.VertexAttrib[n].Enabled;
+ flag = _NEW_ARRAY_ATTRIB(n);
+ }
+ break;
+#endif /* FEATURE_NV_vertex_program */
+
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM,
+ "glEnable/DisableClientState(0x%x)", cap);
+ return;
+ }
+
+ if (*var == state)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_ARRAY);
+ ctx->Array.NewState |= flag;
+ *var = state;
+
+ if (state)
+ ctx->Array._Enabled |= flag;
+ else
+ ctx->Array._Enabled &= ~flag;
+
+ if (ctx->Driver.Enable) {
+ (*ctx->Driver.Enable)( ctx, cap, state );
+ }
+}
+
+
+/**
+ * Enable GL capability.
+ *
+ * \param cap capability.
+ *
+ * \sa glEnable().
+ *
+ * Get's the current context, assures that we're outside glBegin()/glEnd() and
+ * calls client_state().
+ */
+void GLAPIENTRY
+_mesa_EnableClientState( GLenum cap )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+ client_state( ctx, cap, GL_TRUE );
+}
+
+
+/**
+ * Disable GL capability.
+ *
+ * \param cap capability.
+ *
+ * \sa glDisable().
+ *
+ * Get's the current context, assures that we're outside glBegin()/glEnd() and
+ * calls client_state().
+ */
+void GLAPIENTRY
+_mesa_DisableClientState( GLenum cap )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+ client_state( ctx, cap, GL_FALSE );
+}
+
+
+#undef CHECK_EXTENSION
+#define CHECK_EXTENSION(EXTNAME, CAP) \
+ if (!ctx->Extensions.EXTNAME) { \
+ _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
+ state ? "Enable" : "Disable", CAP); \
+ return; \
+ }
+
+#define CHECK_EXTENSION2(EXT1, EXT2, CAP) \
+ if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \
+ _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(0x%x)", \
+ state ? "Enable" : "Disable", CAP); \
+ return; \
+ }
+
+
+
+/**
+ * Perform glEnable() and glDisable() calls.
+ *
+ * \param ctx GL context.
+ * \param cap capability.
+ * \param state whether to enable or disable the specified capability.
+ *
+ * Updates the current context and flushes the vertices as needed. For
+ * capabilities associated with extensions it verifies that those extensions
+ * are effectivly present before updating. Notifies the driver via
+ * dd_function_table::Enable.
+ */
+void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state )
+{
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "%s %s (newstate is %x)\n",
+ state ? "glEnable" : "glDisable",
+ _mesa_lookup_enum_by_nr(cap),
+ ctx->NewState);
+
+ switch (cap) {
+ case GL_ALPHA_TEST:
+ if (ctx->Color.AlphaEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_COLOR);
+ ctx->Color.AlphaEnabled = state;
+ break;
+ case GL_AUTO_NORMAL:
+ if (ctx->Eval.AutoNormal == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.AutoNormal = state;
+ break;
+ case GL_BLEND:
+ if (ctx->Color.BlendEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_COLOR);
+ ctx->Color.BlendEnabled = state;
+ /* This is needed to support 1.1's RGB logic ops AND
+ * 1.0's blending logicops.
+ */
+ ctx->Color._LogicOpEnabled =
+ (ctx->Color.ColorLogicOpEnabled ||
+ (state && ctx->Color.BlendEquationRGB == GL_LOGIC_OP));
+ break;
+#if FEATURE_userclip
+ case GL_CLIP_PLANE0:
+ case GL_CLIP_PLANE1:
+ case GL_CLIP_PLANE2:
+ case GL_CLIP_PLANE3:
+ case GL_CLIP_PLANE4:
+ case GL_CLIP_PLANE5:
+ {
+ const GLuint p = cap - GL_CLIP_PLANE0;
+
+ if ((ctx->Transform.ClipPlanesEnabled & (1 << p)) == ((GLuint) state << p))
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+
+ if (state) {
+ ctx->Transform.ClipPlanesEnabled |= (1 << p);
+
+ if (_math_matrix_is_dirty(ctx->ProjectionMatrixStack.Top))
+ _math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
+
+ /* This derived state also calculated in clip.c and
+ * from _mesa_update_state() on changes to EyeUserPlane
+ * and ctx->ProjectionMatrix respectively.
+ */
+ _mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
+ ctx->Transform.EyeUserPlane[p],
+ ctx->ProjectionMatrixStack.Top->inv );
+ }
+ else {
+ ctx->Transform.ClipPlanesEnabled &= ~(1 << p);
+ }
+ }
+ break;
+#endif
+ case GL_COLOR_MATERIAL:
+ if (ctx->Light.ColorMaterialEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ FLUSH_CURRENT(ctx, 0);
+ ctx->Light.ColorMaterialEnabled = state;
+ if (state) {
+ _mesa_update_color_material( ctx,
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0] );
+ }
+ break;
+ case GL_CULL_FACE:
+ if (ctx->Polygon.CullFlag == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POLYGON);
+ ctx->Polygon.CullFlag = state;
+ break;
+
+ case GL_CULL_VERTEX_EXT:
+ CHECK_EXTENSION(EXT_cull_vertex, cap);
+ if (ctx->Transform.CullVertexFlag == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+ ctx->Transform.CullVertexFlag = state;
+ break;
+
+ case GL_DEPTH_TEST:
+ if (state && ctx->DrawBuffer->Visual.depthBits == 0) {
+ _mesa_warning(ctx,"glEnable(GL_DEPTH_TEST) but no depth buffer");
+ return;
+ }
+ if (ctx->Depth.Test==state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_DEPTH);
+ ctx->Depth.Test = state;
+ break;
+ case GL_DITHER:
+ if (ctx->NoDither) {
+ state = GL_FALSE; /* MESA_NO_DITHER env var */
+ }
+ if (ctx->Color.DitherFlag==state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_COLOR);
+ ctx->Color.DitherFlag = state;
+ break;
+ case GL_FOG:
+ if (ctx->Fog.Enabled==state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_FOG);
+ ctx->Fog.Enabled = state;
+ break;
+ case GL_HISTOGRAM:
+ CHECK_EXTENSION(EXT_histogram, cap);
+ if (ctx->Pixel.HistogramEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.HistogramEnabled = state;
+ 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:
+ if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ ctx->Light.Light[cap-GL_LIGHT0].Enabled = state;
+ if (state) {
+ insert_at_tail(&ctx->Light.EnabledList,
+ &ctx->Light.Light[cap-GL_LIGHT0]);
+ }
+ else {
+ remove_from_list(&ctx->Light.Light[cap-GL_LIGHT0]);
+ }
+ break;
+ case GL_LIGHTING:
+ if (ctx->Light.Enabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ ctx->Light.Enabled = state;
+
+ if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
+ ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
+ else
+ ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
+
+ break;
+ case GL_LINE_SMOOTH:
+ if (ctx->Line.SmoothFlag == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LINE);
+ ctx->Line.SmoothFlag = state;
+ ctx->_TriangleCaps ^= DD_LINE_SMOOTH;
+ break;
+ case GL_LINE_STIPPLE:
+ if (ctx->Line.StippleFlag == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LINE);
+ ctx->Line.StippleFlag = state;
+ ctx->_TriangleCaps ^= DD_LINE_STIPPLE;
+ break;
+ case GL_INDEX_LOGIC_OP:
+ if (ctx->Color.IndexLogicOpEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_COLOR);
+ ctx->Color.IndexLogicOpEnabled = state;
+ break;
+ case GL_COLOR_LOGIC_OP:
+ if (ctx->Color.ColorLogicOpEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_COLOR);
+ ctx->Color.ColorLogicOpEnabled = state;
+ /* This is needed to support 1.1's RGB logic ops AND
+ * 1.0's blending logicops.
+ */
+ ctx->Color._LogicOpEnabled =
+ (state || (ctx->Color.BlendEnabled &&
+ ctx->Color.BlendEquationRGB == GL_LOGIC_OP));
+ break;
+ case GL_MAP1_COLOR_4:
+ if (ctx->Eval.Map1Color4 == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map1Color4 = state;
+ break;
+ case GL_MAP1_INDEX:
+ if (ctx->Eval.Map1Index == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map1Index = state;
+ break;
+ case GL_MAP1_NORMAL:
+ if (ctx->Eval.Map1Normal == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map1Normal = state;
+ break;
+ case GL_MAP1_TEXTURE_COORD_1:
+ if (ctx->Eval.Map1TextureCoord1 == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map1TextureCoord1 = state;
+ break;
+ case GL_MAP1_TEXTURE_COORD_2:
+ if (ctx->Eval.Map1TextureCoord2 == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map1TextureCoord2 = state;
+ break;
+ case GL_MAP1_TEXTURE_COORD_3:
+ if (ctx->Eval.Map1TextureCoord3 == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map1TextureCoord3 = state;
+ break;
+ case GL_MAP1_TEXTURE_COORD_4:
+ if (ctx->Eval.Map1TextureCoord4 == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map1TextureCoord4 = state;
+ break;
+ case GL_MAP1_VERTEX_3:
+ if (ctx->Eval.Map1Vertex3 == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map1Vertex3 = state;
+ break;
+ case GL_MAP1_VERTEX_4:
+ if (ctx->Eval.Map1Vertex4 == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map1Vertex4 = state;
+ break;
+ case GL_MAP2_COLOR_4:
+ if (ctx->Eval.Map2Color4 == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map2Color4 = state;
+ break;
+ case GL_MAP2_INDEX:
+ if (ctx->Eval.Map2Index == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map2Index = state;
+ break;
+ case GL_MAP2_NORMAL:
+ if (ctx->Eval.Map2Normal == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map2Normal = state;
+ break;
+ case GL_MAP2_TEXTURE_COORD_1:
+ if (ctx->Eval.Map2TextureCoord1 == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map2TextureCoord1 = state;
+ break;
+ case GL_MAP2_TEXTURE_COORD_2:
+ if (ctx->Eval.Map2TextureCoord2 == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map2TextureCoord2 = state;
+ break;
+ case GL_MAP2_TEXTURE_COORD_3:
+ if (ctx->Eval.Map2TextureCoord3 == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map2TextureCoord3 = state;
+ break;
+ case GL_MAP2_TEXTURE_COORD_4:
+ if (ctx->Eval.Map2TextureCoord4 == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map2TextureCoord4 = state;
+ break;
+ case GL_MAP2_VERTEX_3:
+ if (ctx->Eval.Map2Vertex3 == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map2Vertex3 = state;
+ break;
+ case GL_MAP2_VERTEX_4:
+ if (ctx->Eval.Map2Vertex4 == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map2Vertex4 = state;
+ break;
+ case GL_MINMAX:
+ if (ctx->Pixel.MinMaxEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.MinMaxEnabled = state;
+ break;
+ case GL_NORMALIZE:
+ if (ctx->Transform.Normalize == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+ ctx->Transform.Normalize = state;
+ break;
+ case GL_POINT_SMOOTH:
+ if (ctx->Point.SmoothFlag==state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POINT);
+ ctx->Point.SmoothFlag = state;
+ ctx->_TriangleCaps ^= DD_POINT_SMOOTH;
+ break;
+ case GL_POLYGON_SMOOTH:
+ if (ctx->Polygon.SmoothFlag==state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POLYGON);
+ ctx->Polygon.SmoothFlag = state;
+ ctx->_TriangleCaps ^= DD_TRI_SMOOTH;
+ break;
+ case GL_POLYGON_STIPPLE:
+ if (ctx->Polygon.StippleFlag==state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POLYGON);
+ ctx->Polygon.StippleFlag = state;
+ ctx->_TriangleCaps ^= DD_TRI_STIPPLE;
+ break;
+ case GL_POLYGON_OFFSET_POINT:
+ if (ctx->Polygon.OffsetPoint==state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POLYGON);
+ ctx->Polygon.OffsetPoint = state;
+ break;
+ case GL_POLYGON_OFFSET_LINE:
+ if (ctx->Polygon.OffsetLine==state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POLYGON);
+ ctx->Polygon.OffsetLine = state;
+ break;
+ case GL_POLYGON_OFFSET_FILL:
+ /*case GL_POLYGON_OFFSET_EXT:*/
+ if (ctx->Polygon.OffsetFill==state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POLYGON);
+ ctx->Polygon.OffsetFill = state;
+ break;
+ case GL_RESCALE_NORMAL_EXT:
+ if (ctx->Transform.RescaleNormals == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+ ctx->Transform.RescaleNormals = state;
+ break;
+ case GL_SCISSOR_TEST:
+ if (ctx->Scissor.Enabled==state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_SCISSOR);
+ ctx->Scissor.Enabled = state;
+ break;
+ case GL_SHARED_TEXTURE_PALETTE_EXT:
+ if (ctx->Texture.SharedPalette == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ ctx->Texture.SharedPalette = state;
+ break;
+ case GL_STENCIL_TEST:
+ if (state && ctx->DrawBuffer->Visual.stencilBits == 0) {
+ _mesa_warning(ctx,
+ "glEnable(GL_STENCIL_TEST) but no stencil buffer");
+ return;
+ }
+ if (ctx->Stencil.Enabled==state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_STENCIL);
+ ctx->Stencil.Enabled = state;
+ break;
+ case GL_TEXTURE_1D: {
+ const GLuint curr = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
+ GLuint newenabled = texUnit->Enabled & ~TEXTURE_1D_BIT;
+ if (state)
+ newenabled |= TEXTURE_1D_BIT;
+ if (!ctx->DrawBuffer->Visual.rgbMode
+ || texUnit->Enabled == newenabled)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->Enabled = newenabled;
+ break;
+ }
+ case GL_TEXTURE_2D: {
+ const GLuint curr = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
+ GLuint newenabled = texUnit->Enabled & ~TEXTURE_2D_BIT;
+ if (state)
+ newenabled |= TEXTURE_2D_BIT;
+ if (!ctx->DrawBuffer->Visual.rgbMode
+ || texUnit->Enabled == newenabled)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->Enabled = newenabled;
+ break;
+ }
+ case GL_TEXTURE_3D: {
+ const GLuint curr = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
+ GLuint newenabled = texUnit->Enabled & ~TEXTURE_3D_BIT;
+ if (state)
+ newenabled |= TEXTURE_3D_BIT;
+ if (!ctx->DrawBuffer->Visual.rgbMode
+ || texUnit->Enabled == newenabled)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->Enabled = newenabled;
+ break;
+ }
+ case GL_TEXTURE_GEN_Q: {
+ GLuint unit = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ GLuint newenabled = texUnit->TexGenEnabled & ~Q_BIT;
+ if (state)
+ newenabled |= Q_BIT;
+ if (texUnit->TexGenEnabled == newenabled)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->TexGenEnabled = newenabled;
+ break;
+ }
+ case GL_TEXTURE_GEN_R: {
+ GLuint unit = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ GLuint newenabled = texUnit->TexGenEnabled & ~R_BIT;
+ if (state)
+ newenabled |= R_BIT;
+ if (texUnit->TexGenEnabled == newenabled)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->TexGenEnabled = newenabled;
+ break;
+ }
+ case GL_TEXTURE_GEN_S: {
+ GLuint unit = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ GLuint newenabled = texUnit->TexGenEnabled & ~S_BIT;
+ if (state)
+ newenabled |= S_BIT;
+ if (texUnit->TexGenEnabled == newenabled)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->TexGenEnabled = newenabled;
+ break;
+ }
+ case GL_TEXTURE_GEN_T: {
+ GLuint unit = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ GLuint newenabled = texUnit->TexGenEnabled & ~T_BIT;
+ if (state)
+ newenabled |= T_BIT;
+ if (texUnit->TexGenEnabled == newenabled)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->TexGenEnabled = newenabled;
+ break;
+ }
+
+ /*
+ * 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:
+ case GL_FOG_COORDINATE_ARRAY_EXT:
+ case GL_SECONDARY_COLOR_ARRAY_EXT:
+ client_state( ctx, cap, state );
+ return;
+
+ /* GL_HP_occlusion_test */
+ case GL_OCCLUSION_TEST_HP:
+ CHECK_EXTENSION(HP_occlusion_test, cap);
+ if (ctx->Depth.OcclusionTest == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_DEPTH);
+ ctx->Depth.OcclusionTest = state;
+ if (state)
+ ctx->OcclusionResult = ctx->OcclusionResultSaved;
+ else
+ ctx->OcclusionResultSaved = ctx->OcclusionResult;
+ break;
+
+ /* GL_SGIS_pixel_texture */
+ case GL_PIXEL_TEXTURE_SGIS:
+ CHECK_EXTENSION(SGIS_pixel_texture, cap);
+ if (ctx->Pixel.PixelTextureEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PixelTextureEnabled = state;
+ break;
+
+ /* GL_SGIX_pixel_texture */
+ case GL_PIXEL_TEX_GEN_SGIX:
+ CHECK_EXTENSION(SGIX_pixel_texture, cap);
+ if (ctx->Pixel.PixelTextureEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PixelTextureEnabled = state;
+ break;
+
+ /* GL_SGI_color_table */
+ case GL_COLOR_TABLE_SGI:
+ CHECK_EXTENSION(SGI_color_table, cap);
+ if (ctx->Pixel.ColorTableEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.ColorTableEnabled = state;
+ break;
+ case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
+ CHECK_EXTENSION(SGI_color_table, cap);
+ if (ctx->Pixel.PostConvolutionColorTableEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostConvolutionColorTableEnabled = state;
+ break;
+ case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
+ CHECK_EXTENSION(SGI_color_table, cap);
+ if (ctx->Pixel.PostColorMatrixColorTableEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostColorMatrixColorTableEnabled = state;
+ break;
+ case GL_TEXTURE_COLOR_TABLE_SGI:
+ CHECK_EXTENSION(SGI_texture_color_table, cap);
+ if (ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled = state;
+ break;
+
+ /* GL_EXT_convolution */
+ case GL_CONVOLUTION_1D:
+ CHECK_EXTENSION(EXT_convolution, cap);
+ if (ctx->Pixel.Convolution1DEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.Convolution1DEnabled = state;
+ break;
+ case GL_CONVOLUTION_2D:
+ CHECK_EXTENSION(EXT_convolution, cap);
+ if (ctx->Pixel.Convolution2DEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.Convolution2DEnabled = state;
+ break;
+ case GL_SEPARABLE_2D:
+ CHECK_EXTENSION(EXT_convolution, cap);
+ if (ctx->Pixel.Separable2DEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.Separable2DEnabled = state;
+ break;
+
+ /* GL_ARB_texture_cube_map */
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ {
+ const GLuint curr = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
+ GLuint newenabled = texUnit->Enabled & ~TEXTURE_CUBE_BIT;
+ CHECK_EXTENSION(ARB_texture_cube_map, cap);
+ if (state)
+ newenabled |= TEXTURE_CUBE_BIT;
+ if (!ctx->DrawBuffer->Visual.rgbMode
+ || texUnit->Enabled == newenabled)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->Enabled = newenabled;
+ }
+ break;
+
+ /* GL_EXT_secondary_color */
+ case GL_COLOR_SUM_EXT:
+ CHECK_EXTENSION(EXT_secondary_color, cap);
+ if (ctx->Fog.ColorSumEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_FOG);
+ ctx->Fog.ColorSumEnabled = state;
+ break;
+
+ /* GL_ARB_multisample */
+ case GL_MULTISAMPLE_ARB:
+ CHECK_EXTENSION(ARB_multisample, cap);
+ if (ctx->Multisample.Enabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+ ctx->Multisample.Enabled = state;
+ break;
+ case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
+ CHECK_EXTENSION(ARB_multisample, cap);
+ if (ctx->Multisample.SampleAlphaToCoverage == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+ ctx->Multisample.SampleAlphaToCoverage = state;
+ break;
+ case GL_SAMPLE_ALPHA_TO_ONE_ARB:
+ CHECK_EXTENSION(ARB_multisample, cap);
+ if (ctx->Multisample.SampleAlphaToOne == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+ ctx->Multisample.SampleAlphaToOne = state;
+ break;
+ case GL_SAMPLE_COVERAGE_ARB:
+ CHECK_EXTENSION(ARB_multisample, cap);
+ if (ctx->Multisample.SampleCoverage == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+ ctx->Multisample.SampleCoverage = state;
+ break;
+ case GL_SAMPLE_COVERAGE_INVERT_ARB:
+ CHECK_EXTENSION(ARB_multisample, cap);
+ if (ctx->Multisample.SampleCoverageInvert == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
+ ctx->Multisample.SampleCoverageInvert = state;
+ break;
+
+ /* GL_IBM_rasterpos_clip */
+ case GL_RASTER_POSITION_UNCLIPPED_IBM:
+ CHECK_EXTENSION(IBM_rasterpos_clip, cap);
+ if (ctx->Transform.RasterPositionUnclipped == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+ ctx->Transform.RasterPositionUnclipped = state;
+ break;
+
+ /* GL_NV_point_sprite */
+ case GL_POINT_SPRITE_NV:
+ CHECK_EXTENSION2(NV_point_sprite, ARB_point_sprite, cap);
+ if (ctx->Point.PointSprite == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POINT);
+ ctx->Point.PointSprite = state;
+ break;
+
+#if FEATURE_NV_vertex_program
+ case GL_VERTEX_PROGRAM_NV:
+ CHECK_EXTENSION2(NV_vertex_program, ARB_vertex_program, cap);
+ if (ctx->VertexProgram.Enabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+ ctx->VertexProgram.Enabled = state;
+ break;
+ case GL_VERTEX_PROGRAM_POINT_SIZE_NV:
+ CHECK_EXTENSION2(NV_vertex_program, ARB_vertex_program, cap);
+ if (ctx->VertexProgram.PointSizeEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+ ctx->VertexProgram.PointSizeEnabled = state;
+ break;
+ case GL_VERTEX_PROGRAM_TWO_SIDE_NV:
+ CHECK_EXTENSION2(NV_vertex_program, ARB_vertex_program, cap);
+ if (ctx->VertexProgram.TwoSideEnabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+ ctx->VertexProgram.TwoSideEnabled = state;
+ break;
+ case GL_MAP1_VERTEX_ATTRIB0_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB1_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB2_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB3_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB4_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB5_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB6_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB7_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB8_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB9_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB10_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB11_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB12_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB13_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB14_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB15_4_NV:
+ CHECK_EXTENSION(NV_vertex_program, cap);
+ {
+ const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV);
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map1Attrib[map] = state;
+ }
+ break;
+ case GL_MAP2_VERTEX_ATTRIB0_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB1_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB2_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB3_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB4_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB5_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB6_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB7_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB8_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB9_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB10_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB11_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB12_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB13_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB14_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB15_4_NV:
+ CHECK_EXTENSION(NV_vertex_program, cap);
+ {
+ const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV);
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.Map2Attrib[map] = state;
+ }
+ break;
+#endif /* FEATURE_NV_vertex_program */
+
+#if FEATURE_NV_fragment_program
+ case GL_FRAGMENT_PROGRAM_NV:
+ CHECK_EXTENSION(NV_fragment_program, cap);
+ if (ctx->FragmentProgram.Enabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+ ctx->FragmentProgram.Enabled = state;
+ break;
+#endif /* FEATURE_NV_fragment_program */
+
+ /* GL_NV_texture_rectangle */
+ case GL_TEXTURE_RECTANGLE_NV:
+ CHECK_EXTENSION(NV_texture_rectangle, cap);
+ {
+ const GLuint curr = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr];
+ GLuint newenabled = texUnit->Enabled & ~TEXTURE_RECT_BIT;
+ CHECK_EXTENSION(NV_texture_rectangle, cap);
+ if (state)
+ newenabled |= TEXTURE_RECT_BIT;
+ if (!ctx->DrawBuffer->Visual.rgbMode
+ || texUnit->Enabled == newenabled)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->Enabled = newenabled;
+ }
+ break;
+
+ /* GL_EXT_stencil_two_side */
+ case GL_STENCIL_TEST_TWO_SIDE_EXT:
+ CHECK_EXTENSION(EXT_stencil_two_side, cap);
+ if (ctx->Stencil.TestTwoSide == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_STENCIL);
+ ctx->Stencil.TestTwoSide = state;
+ if (state) {
+ ctx->_TriangleCaps |= DD_TRI_TWOSTENCIL;
+ } else {
+ ctx->_TriangleCaps &= ~DD_TRI_TWOSTENCIL;
+ }
+ break;
+
+#if FEATURE_ARB_fragment_program
+ case GL_FRAGMENT_PROGRAM_ARB:
+ CHECK_EXTENSION(ARB_fragment_program, cap);
+ if (ctx->FragmentProgram.Enabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+ ctx->FragmentProgram.Enabled = state;
+ break;
+#endif /* FEATURE_ARB_fragment_program */
+
+ /* GL_EXT_depth_bounds_test */
+ case GL_DEPTH_BOUNDS_TEST_EXT:
+ CHECK_EXTENSION(EXT_depth_bounds_test, cap);
+ if (state && ctx->DrawBuffer->Visual.depthBits == 0) {
+ _mesa_warning(ctx,
+ "glEnable(GL_DEPTH_BOUNDS_TEST_EXT) but no depth buffer");
+ return;
+ }
+ if (ctx->Depth.BoundsTest == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_DEPTH);
+ ctx->Depth.BoundsTest = state;
+ break;
+
+ /* GL_MESA_program_debug */
+ case GL_FRAGMENT_PROGRAM_CALLBACK_MESA:
+ CHECK_EXTENSION(MESA_program_debug, cap);
+ ctx->FragmentProgram.CallbackEnabled = state;
+ break;
+ case GL_VERTEX_PROGRAM_CALLBACK_MESA:
+ CHECK_EXTENSION(MESA_program_debug, cap);
+ ctx->VertexProgram.CallbackEnabled = state;
+ break;
+
+#if FEATURE_ATI_fragment_shader
+ case GL_FRAGMENT_SHADER_ATI:
+ CHECK_EXTENSION(ATI_fragment_shader, cap);
+ if (ctx->ATIFragmentShader.Enabled == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+ ctx->ATIFragmentShader.Enabled = state;
+ break;
+#endif
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "%s(0x%x)", state ? "glEnable" : "glDisable", cap);
+ return;
+ }
+
+ if (ctx->Driver.Enable) {
+ (*ctx->Driver.Enable)( ctx, cap, state );
+ }
+}
+
+
+/**
+ * Enable GL capability.
+ *
+ * \param cap capability.
+ *
+ * \sa glEnable().
+ *
+ * Get's the current context, assures that we're outside glBegin()/glEnd() and
+ * calls _mesa_set_enable().
+ */
+void GLAPIENTRY
+_mesa_Enable( GLenum cap )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ _mesa_set_enable( ctx, cap, GL_TRUE );
+}
+
+
+/**
+ * Disable GL capability.
+ *
+ * \param cap capability.
+ *
+ * \sa glDisable().
+ *
+ * Get's the current context, assures that we're outside glBegin()/glEnd() and
+ * calls _mesa_set_enable().
+ */
+void GLAPIENTRY
+_mesa_Disable( GLenum cap )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ _mesa_set_enable( ctx, cap, GL_FALSE );
+}
+
+
+#undef CHECK_EXTENSION
+#define CHECK_EXTENSION(EXTNAME) \
+ if (!ctx->Extensions.EXTNAME) { \
+ _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); \
+ return GL_FALSE; \
+ }
+
+
+/**
+ * Test whether a capability is enabled.
+ *
+ * \param cap capability.
+ *
+ * Returns the state of the specified capability from the current GL context.
+ * For the capabilities associated with extensions verifies that those
+ * extensions are effectively present before reporting.
+ */
+GLboolean GLAPIENTRY
+_mesa_IsEnabled( GLenum cap )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ switch (cap) {
+ case GL_ALPHA_TEST:
+ return ctx->Color.AlphaEnabled;
+ case GL_AUTO_NORMAL:
+ return ctx->Eval.AutoNormal;
+ case GL_BLEND:
+ return ctx->Color.BlendEnabled;
+ case GL_CLIP_PLANE0:
+ case GL_CLIP_PLANE1:
+ case GL_CLIP_PLANE2:
+ case GL_CLIP_PLANE3:
+ case GL_CLIP_PLANE4:
+ case GL_CLIP_PLANE5:
+ return (ctx->Transform.ClipPlanesEnabled >> (cap - GL_CLIP_PLANE0)) & 1;
+ case GL_COLOR_MATERIAL:
+ return ctx->Light.ColorMaterialEnabled;
+ case GL_CULL_FACE:
+ return ctx->Polygon.CullFlag;
+ case GL_DEPTH_TEST:
+ return ctx->Depth.Test;
+ case GL_DITHER:
+ return ctx->Color.DitherFlag;
+ case GL_FOG:
+ return ctx->Fog.Enabled;
+ case GL_LIGHTING:
+ return ctx->Light.Enabled;
+ case GL_LIGHT0:
+ case GL_LIGHT1:
+ case GL_LIGHT2:
+ case GL_LIGHT3:
+ case GL_LIGHT4:
+ case GL_LIGHT5:
+ case GL_LIGHT6:
+ case GL_LIGHT7:
+ return ctx->Light.Light[cap-GL_LIGHT0].Enabled;
+ case GL_LINE_SMOOTH:
+ return ctx->Line.SmoothFlag;
+ case GL_LINE_STIPPLE:
+ return ctx->Line.StippleFlag;
+ case GL_INDEX_LOGIC_OP:
+ return ctx->Color.IndexLogicOpEnabled;
+ case GL_COLOR_LOGIC_OP:
+ return ctx->Color.ColorLogicOpEnabled;
+ case GL_MAP1_COLOR_4:
+ return ctx->Eval.Map1Color4;
+ case GL_MAP1_INDEX:
+ return ctx->Eval.Map1Index;
+ case GL_MAP1_NORMAL:
+ return ctx->Eval.Map1Normal;
+ case GL_MAP1_TEXTURE_COORD_1:
+ return ctx->Eval.Map1TextureCoord1;
+ case GL_MAP1_TEXTURE_COORD_2:
+ return ctx->Eval.Map1TextureCoord2;
+ case GL_MAP1_TEXTURE_COORD_3:
+ return ctx->Eval.Map1TextureCoord3;
+ case GL_MAP1_TEXTURE_COORD_4:
+ return ctx->Eval.Map1TextureCoord4;
+ case GL_MAP1_VERTEX_3:
+ return ctx->Eval.Map1Vertex3;
+ case GL_MAP1_VERTEX_4:
+ return ctx->Eval.Map1Vertex4;
+ case GL_MAP2_COLOR_4:
+ return ctx->Eval.Map2Color4;
+ case GL_MAP2_INDEX:
+ return ctx->Eval.Map2Index;
+ case GL_MAP2_NORMAL:
+ return ctx->Eval.Map2Normal;
+ case GL_MAP2_TEXTURE_COORD_1:
+ return ctx->Eval.Map2TextureCoord1;
+ case GL_MAP2_TEXTURE_COORD_2:
+ return ctx->Eval.Map2TextureCoord2;
+ case GL_MAP2_TEXTURE_COORD_3:
+ return ctx->Eval.Map2TextureCoord3;
+ case GL_MAP2_TEXTURE_COORD_4:
+ return ctx->Eval.Map2TextureCoord4;
+ case GL_MAP2_VERTEX_3:
+ return ctx->Eval.Map2Vertex3;
+ case GL_MAP2_VERTEX_4:
+ return ctx->Eval.Map2Vertex4;
+ case GL_NORMALIZE:
+ return ctx->Transform.Normalize;
+ case GL_POINT_SMOOTH:
+ return ctx->Point.SmoothFlag;
+ case GL_POLYGON_SMOOTH:
+ return ctx->Polygon.SmoothFlag;
+ case GL_POLYGON_STIPPLE:
+ return ctx->Polygon.StippleFlag;
+ case GL_POLYGON_OFFSET_POINT:
+ return ctx->Polygon.OffsetPoint;
+ case GL_POLYGON_OFFSET_LINE:
+ return ctx->Polygon.OffsetLine;
+ case GL_POLYGON_OFFSET_FILL:
+ /*case GL_POLYGON_OFFSET_EXT:*/
+ return ctx->Polygon.OffsetFill;
+ case GL_RESCALE_NORMAL_EXT:
+ return ctx->Transform.RescaleNormals;
+ case GL_SCISSOR_TEST:
+ return ctx->Scissor.Enabled;
+ case GL_SHARED_TEXTURE_PALETTE_EXT:
+ return ctx->Texture.SharedPalette;
+ case GL_STENCIL_TEST:
+ return ctx->Stencil.Enabled;
+ case GL_TEXTURE_1D:
+ {
+ const struct gl_texture_unit *texUnit;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ return (texUnit->Enabled & TEXTURE_1D_BIT) ? GL_TRUE : GL_FALSE;
+ }
+ case GL_TEXTURE_2D:
+ {
+ const struct gl_texture_unit *texUnit;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ return (texUnit->Enabled & TEXTURE_2D_BIT) ? GL_TRUE : GL_FALSE;
+ }
+ case GL_TEXTURE_3D:
+ {
+ const struct gl_texture_unit *texUnit;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ return (texUnit->Enabled & TEXTURE_3D_BIT) ? GL_TRUE : GL_FALSE;
+ }
+ case GL_TEXTURE_GEN_Q:
+ {
+ const struct gl_texture_unit *texUnit;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ return (texUnit->TexGenEnabled & Q_BIT) ? GL_TRUE : GL_FALSE;
+ }
+ case GL_TEXTURE_GEN_R:
+ {
+ const struct gl_texture_unit *texUnit;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ return (texUnit->TexGenEnabled & R_BIT) ? GL_TRUE : GL_FALSE;
+ }
+ case GL_TEXTURE_GEN_S:
+ {
+ const struct gl_texture_unit *texUnit;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ return (texUnit->TexGenEnabled & S_BIT) ? GL_TRUE : GL_FALSE;
+ }
+ case GL_TEXTURE_GEN_T:
+ {
+ const struct gl_texture_unit *texUnit;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ return (texUnit->TexGenEnabled & T_BIT) ? GL_TRUE : GL_FALSE;
+ }
+
+ /*
+ * CLIENT STATE!!!
+ */
+ case GL_VERTEX_ARRAY:
+ return (ctx->Array.Vertex.Enabled != 0);
+ case GL_NORMAL_ARRAY:
+ return (ctx->Array.Normal.Enabled != 0);
+ case GL_COLOR_ARRAY:
+ return (ctx->Array.Color.Enabled != 0);
+ case GL_INDEX_ARRAY:
+ return (ctx->Array.Index.Enabled != 0);
+ case GL_TEXTURE_COORD_ARRAY:
+ return (ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled != 0);
+ case GL_EDGE_FLAG_ARRAY:
+ return (ctx->Array.EdgeFlag.Enabled != 0);
+ case GL_FOG_COORDINATE_ARRAY_EXT:
+ CHECK_EXTENSION(EXT_fog_coord);
+ return (ctx->Array.FogCoord.Enabled != 0);
+ case GL_SECONDARY_COLOR_ARRAY_EXT:
+ CHECK_EXTENSION(EXT_secondary_color);
+ return (ctx->Array.SecondaryColor.Enabled != 0);
+
+ /* GL_EXT_histogram */
+ case GL_HISTOGRAM:
+ CHECK_EXTENSION(EXT_histogram);
+ return ctx->Pixel.HistogramEnabled;
+ case GL_MINMAX:
+ CHECK_EXTENSION(EXT_histogram);
+ return ctx->Pixel.MinMaxEnabled;
+
+ /* GL_HP_occlusion_test */
+ case GL_OCCLUSION_TEST_HP:
+ CHECK_EXTENSION(HP_occlusion_test);
+ return ctx->Depth.OcclusionTest;
+
+ /* GL_SGIS_pixel_texture */
+ case GL_PIXEL_TEXTURE_SGIS:
+ CHECK_EXTENSION(SGIS_pixel_texture);
+ return ctx->Pixel.PixelTextureEnabled;
+
+ /* GL_SGIX_pixel_texture */
+ case GL_PIXEL_TEX_GEN_SGIX:
+ CHECK_EXTENSION(SGIX_pixel_texture);
+ return ctx->Pixel.PixelTextureEnabled;
+
+ /* GL_SGI_color_table */
+ case GL_COLOR_TABLE_SGI:
+ CHECK_EXTENSION(SGI_color_table);
+ return ctx->Pixel.ColorTableEnabled;
+ case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
+ CHECK_EXTENSION(SGI_color_table);
+ return ctx->Pixel.PostConvolutionColorTableEnabled;
+ case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
+ CHECK_EXTENSION(SGI_color_table);
+ return ctx->Pixel.PostColorMatrixColorTableEnabled;
+
+ /* GL_SGI_texture_color_table */
+ case GL_TEXTURE_COLOR_TABLE_SGI:
+ CHECK_EXTENSION(SGI_texture_color_table);
+ return ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled;
+
+ /* GL_EXT_convolution */
+ case GL_CONVOLUTION_1D:
+ CHECK_EXTENSION(EXT_convolution);
+ return ctx->Pixel.Convolution1DEnabled;
+ case GL_CONVOLUTION_2D:
+ CHECK_EXTENSION(EXT_convolution);
+ return ctx->Pixel.Convolution2DEnabled;
+ case GL_SEPARABLE_2D:
+ CHECK_EXTENSION(EXT_convolution);
+ return ctx->Pixel.Separable2DEnabled;
+
+ /* GL_ARB_texture_cube_map */
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ CHECK_EXTENSION(ARB_texture_cube_map);
+ {
+ const struct gl_texture_unit *texUnit;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ return (texUnit->Enabled & TEXTURE_CUBE_BIT) ? GL_TRUE : GL_FALSE;
+ }
+
+ /* GL_ARB_multisample */
+ case GL_MULTISAMPLE_ARB:
+ CHECK_EXTENSION(ARB_multisample);
+ return ctx->Multisample.Enabled;
+ case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
+ CHECK_EXTENSION(ARB_multisample);
+ return ctx->Multisample.SampleAlphaToCoverage;
+ case GL_SAMPLE_ALPHA_TO_ONE_ARB:
+ CHECK_EXTENSION(ARB_multisample);
+ return ctx->Multisample.SampleAlphaToOne;
+ case GL_SAMPLE_COVERAGE_ARB:
+ CHECK_EXTENSION(ARB_multisample);
+ return ctx->Multisample.SampleCoverage;
+ case GL_SAMPLE_COVERAGE_INVERT_ARB:
+ CHECK_EXTENSION(ARB_multisample);
+ return ctx->Multisample.SampleCoverageInvert;
+
+ /* GL_IBM_rasterpos_clip */
+ case GL_RASTER_POSITION_UNCLIPPED_IBM:
+ CHECK_EXTENSION(IBM_rasterpos_clip);
+ return ctx->Transform.RasterPositionUnclipped;
+
+ /* GL_NV_point_sprite */
+ case GL_POINT_SPRITE_NV:
+ return ctx->Point.PointSprite;
+
+#if FEATURE_NV_vertex_program
+ case GL_VERTEX_PROGRAM_NV:
+ CHECK_EXTENSION(NV_vertex_program);
+ return ctx->VertexProgram.Enabled;
+ case GL_VERTEX_PROGRAM_POINT_SIZE_NV:
+ CHECK_EXTENSION(NV_vertex_program);
+ return ctx->VertexProgram.PointSizeEnabled;
+ case GL_VERTEX_PROGRAM_TWO_SIDE_NV:
+ CHECK_EXTENSION(NV_vertex_program);
+ return ctx->VertexProgram.TwoSideEnabled;
+ case GL_VERTEX_ATTRIB_ARRAY0_NV:
+ case GL_VERTEX_ATTRIB_ARRAY1_NV:
+ case GL_VERTEX_ATTRIB_ARRAY2_NV:
+ case GL_VERTEX_ATTRIB_ARRAY3_NV:
+ case GL_VERTEX_ATTRIB_ARRAY4_NV:
+ case GL_VERTEX_ATTRIB_ARRAY5_NV:
+ case GL_VERTEX_ATTRIB_ARRAY6_NV:
+ case GL_VERTEX_ATTRIB_ARRAY7_NV:
+ case GL_VERTEX_ATTRIB_ARRAY8_NV:
+ case GL_VERTEX_ATTRIB_ARRAY9_NV:
+ case GL_VERTEX_ATTRIB_ARRAY10_NV:
+ case GL_VERTEX_ATTRIB_ARRAY11_NV:
+ case GL_VERTEX_ATTRIB_ARRAY12_NV:
+ case GL_VERTEX_ATTRIB_ARRAY13_NV:
+ case GL_VERTEX_ATTRIB_ARRAY14_NV:
+ case GL_VERTEX_ATTRIB_ARRAY15_NV:
+ CHECK_EXTENSION(NV_vertex_program);
+ {
+ GLint n = (GLint) cap - GL_VERTEX_ATTRIB_ARRAY0_NV;
+ return (ctx->Array.VertexAttrib[n].Enabled != 0);
+ }
+ case GL_MAP1_VERTEX_ATTRIB0_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB1_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB2_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB3_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB4_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB5_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB6_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB7_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB8_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB9_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB10_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB11_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB12_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB13_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB14_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB15_4_NV:
+ CHECK_EXTENSION(NV_vertex_program);
+ {
+ const GLuint map = (GLuint) (cap - GL_MAP1_VERTEX_ATTRIB0_4_NV);
+ return ctx->Eval.Map1Attrib[map];
+ }
+ case GL_MAP2_VERTEX_ATTRIB0_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB1_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB2_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB3_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB4_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB5_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB6_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB7_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB8_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB9_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB10_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB11_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB12_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB13_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB14_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB15_4_NV:
+ CHECK_EXTENSION(NV_vertex_program);
+ {
+ const GLuint map = (GLuint) (cap - GL_MAP2_VERTEX_ATTRIB0_4_NV);
+ return ctx->Eval.Map2Attrib[map];
+ }
+#endif /* FEATURE_NV_vertex_program */
+
+#if FEATURE_NV_fragment_program
+ case GL_FRAGMENT_PROGRAM_NV:
+ CHECK_EXTENSION(NV_fragment_program);
+ return ctx->FragmentProgram.Enabled;
+#endif /* FEATURE_NV_fragment_program */
+
+ /* GL_NV_texture_rectangle */
+ case GL_TEXTURE_RECTANGLE_NV:
+ CHECK_EXTENSION(NV_texture_rectangle);
+ {
+ const struct gl_texture_unit *texUnit;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ return (texUnit->Enabled & TEXTURE_RECT_BIT) ? GL_TRUE : GL_FALSE;
+ }
+
+ /* GL_EXT_stencil_two_side */
+ case GL_STENCIL_TEST_TWO_SIDE_EXT:
+ CHECK_EXTENSION(EXT_stencil_two_side);
+ return ctx->Stencil.TestTwoSide;
+
+#if FEATURE_ARB_fragment_program
+ case GL_FRAGMENT_PROGRAM_ARB:
+ return ctx->FragmentProgram.Enabled;
+#endif /* FEATURE_ARB_fragment_program */
+
+ /* GL_EXT_depth_bounds_test */
+ case GL_DEPTH_BOUNDS_TEST_EXT:
+ CHECK_EXTENSION(EXT_depth_bounds_test);
+ return ctx->Depth.BoundsTest;
+
+ /* GL_MESA_program_debug */
+ case GL_FRAGMENT_PROGRAM_CALLBACK_MESA:
+ CHECK_EXTENSION(MESA_program_debug);
+ return ctx->FragmentProgram.CallbackEnabled;
+ case GL_VERTEX_PROGRAM_CALLBACK_MESA:
+ CHECK_EXTENSION(MESA_program_debug);
+ return ctx->VertexProgram.CallbackEnabled;
+#if FEATURE_ATI_fragment_shader
+ case GL_FRAGMENT_SHADER_ATI:
+ CHECK_EXTENSION(ATI_fragment_shader);
+ return ctx->ATIFragmentShader.Enabled;
+#endif /* FEATURE_ATI_fragment_shader */
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glIsEnabled(0x%x)", (int) cap);
+ return GL_FALSE;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/enable.h b/nx-X11/extras/Mesa/src/mesa/main/enable.h
new file mode 100644
index 000000000..25c90b027
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/enable.h
@@ -0,0 +1,57 @@
+/**
+ * \file enable.h
+ * Enable/disable/query GL capabilities.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef ENABLE_H
+#define ENABLE_H
+
+
+#include "mtypes.h"
+
+
+extern void
+_mesa_set_enable( GLcontext* ctx, GLenum cap, GLboolean state );
+
+extern void GLAPIENTRY
+_mesa_Disable( GLenum cap );
+
+extern void GLAPIENTRY
+_mesa_Enable( GLenum cap );
+
+extern GLboolean GLAPIENTRY
+_mesa_IsEnabled( GLenum cap );
+
+extern void GLAPIENTRY
+_mesa_EnableClientState( GLenum cap );
+
+extern void GLAPIENTRY
+_mesa_DisableClientState( GLenum cap );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/enums.c b/nx-X11/extras/Mesa/src/mesa/main/enums.c
new file mode 100644
index 000000000..837618cd7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/enums.c
@@ -0,0 +1,4570 @@
+/* DO NOT EDIT - This file generated automatically by gl_enums.py (from Mesa) script */
+
+/*
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ * 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
+ * BRIAN PAUL,
+ * 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.
+ */
+
+#include "glheader.h"
+#include "enums.h"
+#include "imports.h"
+
+typedef struct {
+ size_t offset;
+ int n;
+} enum_elt;
+
+static const char enum_string_table[] =
+ "GL_2D\0"
+ "GL_2_BYTES\0"
+ "GL_3D\0"
+ "GL_3D_COLOR\0"
+ "GL_3D_COLOR_TEXTURE\0"
+ "GL_3_BYTES\0"
+ "GL_4D_COLOR_TEXTURE\0"
+ "GL_4_BYTES\0"
+ "GL_ACCUM\0"
+ "GL_ACCUM_ALPHA_BITS\0"
+ "GL_ACCUM_BLUE_BITS\0"
+ "GL_ACCUM_BUFFER_BIT\0"
+ "GL_ACCUM_CLEAR_VALUE\0"
+ "GL_ACCUM_GREEN_BITS\0"
+ "GL_ACCUM_RED_BITS\0"
+ "GL_ACTIVE_STENCIL_FACE_EXT\0"
+ "GL_ACTIVE_TEXTURE\0"
+ "GL_ACTIVE_TEXTURE_ARB\0"
+ "GL_ACTIVE_VERTEX_UNITS_ARB\0"
+ "GL_ADD\0"
+ "GL_ADD_SIGNED\0"
+ "GL_ADD_SIGNED_ARB\0"
+ "GL_ADD_SIGNED_EXT\0"
+ "GL_ALIASED_LINE_WIDTH_RANGE\0"
+ "GL_ALIASED_POINT_SIZE_RANGE\0"
+ "GL_ALL_ATTRIB_BITS\0"
+ "GL_ALL_CLIENT_ATTRIB_BITS\0"
+ "GL_ALPHA\0"
+ "GL_ALPHA12\0"
+ "GL_ALPHA12_EXT\0"
+ "GL_ALPHA16\0"
+ "GL_ALPHA16_EXT\0"
+ "GL_ALPHA4\0"
+ "GL_ALPHA4_EXT\0"
+ "GL_ALPHA8\0"
+ "GL_ALPHA8_EXT\0"
+ "GL_ALPHA_BIAS\0"
+ "GL_ALPHA_BITS\0"
+ "GL_ALPHA_SCALE\0"
+ "GL_ALPHA_TEST\0"
+ "GL_ALPHA_TEST_FUNC\0"
+ "GL_ALPHA_TEST_REF\0"
+ "GL_ALWAYS\0"
+ "GL_AMBIENT\0"
+ "GL_AMBIENT_AND_DIFFUSE\0"
+ "GL_AND\0"
+ "GL_AND_INVERTED\0"
+ "GL_AND_REVERSE\0"
+ "GL_ARRAY_BUFFER\0"
+ "GL_ARRAY_BUFFER_ARB\0"
+ "GL_ARRAY_BUFFER_BINDING\0"
+ "GL_ARRAY_BUFFER_BINDING_ARB\0"
+ "GL_ATTRIB_ARRAY_POINTER_NV\0"
+ "GL_ATTRIB_ARRAY_SIZE_NV\0"
+ "GL_ATTRIB_ARRAY_STRIDE_NV\0"
+ "GL_ATTRIB_ARRAY_TYPE_NV\0"
+ "GL_ATTRIB_STACK_DEPTH\0"
+ "GL_AUTO_NORMAL\0"
+ "GL_AUX0\0"
+ "GL_AUX1\0"
+ "GL_AUX2\0"
+ "GL_AUX3\0"
+ "GL_AUX_BUFFERS\0"
+ "GL_BACK\0"
+ "GL_BACK_LEFT\0"
+ "GL_BACK_RIGHT\0"
+ "GL_BGR\0"
+ "GL_BGRA\0"
+ "GL_BITMAP\0"
+ "GL_BITMAP_TOKEN\0"
+ "GL_BLEND\0"
+ "GL_BLEND_COLOR\0"
+ "GL_BLEND_COLOR_EXT\0"
+ "GL_BLEND_DST\0"
+ "GL_BLEND_DST_ALPHA\0"
+ "GL_BLEND_DST_RGB\0"
+ "GL_BLEND_EQUATION\0"
+ "GL_BLEND_EQUATION_ALPHA_EXT\0"
+ "GL_BLEND_EQUATION_EXT\0"
+ "GL_BLEND_EQUATION_RGB_EXT\0"
+ "GL_BLEND_SRC\0"
+ "GL_BLEND_SRC_ALPHA\0"
+ "GL_BLEND_SRC_RGB\0"
+ "GL_BLUE\0"
+ "GL_BLUE_BIAS\0"
+ "GL_BLUE_BITS\0"
+ "GL_BLUE_SCALE\0"
+ "GL_BOOL_ARB\0"
+ "GL_BOOL_VEC2_ARB\0"
+ "GL_BOOL_VEC3_ARB\0"
+ "GL_BOOL_VEC4_ARB\0"
+ "GL_BUFFER_ACCESS\0"
+ "GL_BUFFER_ACCESS_ARB\0"
+ "GL_BUFFER_MAPPED\0"
+ "GL_BUFFER_MAPPED_ARB\0"
+ "GL_BUFFER_MAP_POINTER\0"
+ "GL_BUFFER_MAP_POINTER_ARB\0"
+ "GL_BUFFER_SIZE\0"
+ "GL_BUFFER_SIZE_ARB\0"
+ "GL_BUFFER_USAGE\0"
+ "GL_BUFFER_USAGE_ARB\0"
+ "GL_BYTE\0"
+ "GL_C3F_V3F\0"
+ "GL_C4F_N3F_V3F\0"
+ "GL_C4UB_V2F\0"
+ "GL_C4UB_V3F\0"
+ "GL_CCW\0"
+ "GL_CLAMP\0"
+ "GL_CLAMP_TO_BORDER\0"
+ "GL_CLAMP_TO_BORDER_ARB\0"
+ "GL_CLAMP_TO_BORDER_SGIS\0"
+ "GL_CLAMP_TO_EDGE\0"
+ "GL_CLAMP_TO_EDGE_SGIS\0"
+ "GL_CLEAR\0"
+ "GL_CLIENT_ACTIVE_TEXTURE\0"
+ "GL_CLIENT_ACTIVE_TEXTURE_ARB\0"
+ "GL_CLIENT_ALL_ATTRIB_BITS\0"
+ "GL_CLIENT_ATTRIB_STACK_DEPTH\0"
+ "GL_CLIENT_PIXEL_STORE_BIT\0"
+ "GL_CLIENT_VERTEX_ARRAY_BIT\0"
+ "GL_CLIP_PLANE0\0"
+ "GL_CLIP_PLANE1\0"
+ "GL_CLIP_PLANE2\0"
+ "GL_CLIP_PLANE3\0"
+ "GL_CLIP_PLANE4\0"
+ "GL_CLIP_PLANE5\0"
+ "GL_CLIP_VOLUME_CLIPPING_HINT_EXT\0"
+ "GL_COEFF\0"
+ "GL_COLOR\0"
+ "GL_COLOR_ARRAY\0"
+ "GL_COLOR_ARRAY_BUFFER_BINDING\0"
+ "GL_COLOR_ARRAY_BUFFER_BINDING_ARB\0"
+ "GL_COLOR_ARRAY_POINTER\0"
+ "GL_COLOR_ARRAY_SIZE\0"
+ "GL_COLOR_ARRAY_STRIDE\0"
+ "GL_COLOR_ARRAY_TYPE\0"
+ "GL_COLOR_ATTACHMENT0_EXT\0"
+ "GL_COLOR_ATTACHMENT10_EXT\0"
+ "GL_COLOR_ATTACHMENT11_EXT\0"
+ "GL_COLOR_ATTACHMENT12_EXT\0"
+ "GL_COLOR_ATTACHMENT13_EXT\0"
+ "GL_COLOR_ATTACHMENT14_EXT\0"
+ "GL_COLOR_ATTACHMENT15_EXT\0"
+ "GL_COLOR_ATTACHMENT1_EXT\0"
+ "GL_COLOR_ATTACHMENT2_EXT\0"
+ "GL_COLOR_ATTACHMENT3_EXT\0"
+ "GL_COLOR_ATTACHMENT4_EXT\0"
+ "GL_COLOR_ATTACHMENT5_EXT\0"
+ "GL_COLOR_ATTACHMENT6_EXT\0"
+ "GL_COLOR_ATTACHMENT7_EXT\0"
+ "GL_COLOR_ATTACHMENT8_EXT\0"
+ "GL_COLOR_ATTACHMENT9_EXT\0"
+ "GL_COLOR_BUFFER_BIT\0"
+ "GL_COLOR_CLEAR_VALUE\0"
+ "GL_COLOR_INDEX\0"
+ "GL_COLOR_INDEXES\0"
+ "GL_COLOR_LOGIC_OP\0"
+ "GL_COLOR_MATERIAL\0"
+ "GL_COLOR_MATERIAL_FACE\0"
+ "GL_COLOR_MATERIAL_PARAMETER\0"
+ "GL_COLOR_MATRIX\0"
+ "GL_COLOR_MATRIX_SGI\0"
+ "GL_COLOR_MATRIX_STACK_DEPTH\0"
+ "GL_COLOR_MATRIX_STACK_DEPTH_SGI\0"
+ "GL_COLOR_SUM\0"
+ "GL_COLOR_SUM_ARB\0"
+ "GL_COLOR_TABLE\0"
+ "GL_COLOR_TABLE_ALPHA_SIZE\0"
+ "GL_COLOR_TABLE_ALPHA_SIZE_EXT\0"
+ "GL_COLOR_TABLE_BIAS\0"
+ "GL_COLOR_TABLE_BLUE_SIZE\0"
+ "GL_COLOR_TABLE_BLUE_SIZE_EXT\0"
+ "GL_COLOR_TABLE_FORMAT\0"
+ "GL_COLOR_TABLE_FORMAT_EXT\0"
+ "GL_COLOR_TABLE_GREEN_SIZE\0"
+ "GL_COLOR_TABLE_GREEN_SIZE_EXT\0"
+ "GL_COLOR_TABLE_INTENSITY_SIZE\0"
+ "GL_COLOR_TABLE_INTENSITY_SIZE_EXT\0"
+ "GL_COLOR_TABLE_LUMINANCE_SIZE\0"
+ "GL_COLOR_TABLE_LUMINANCE_SIZE_EXT\0"
+ "GL_COLOR_TABLE_RED_SIZE\0"
+ "GL_COLOR_TABLE_RED_SIZE_EXT\0"
+ "GL_COLOR_TABLE_SCALE\0"
+ "GL_COLOR_TABLE_WIDTH\0"
+ "GL_COLOR_TABLE_WIDTH_EXT\0"
+ "GL_COLOR_WRITEMASK\0"
+ "GL_COMBINE\0"
+ "GL_COMBINE4\0"
+ "GL_COMBINE_ALPHA\0"
+ "GL_COMBINE_ALPHA_ARB\0"
+ "GL_COMBINE_ALPHA_EXT\0"
+ "GL_COMBINE_ARB\0"
+ "GL_COMBINE_EXT\0"
+ "GL_COMBINE_RGB\0"
+ "GL_COMBINE_RGB_ARB\0"
+ "GL_COMBINE_RGB_EXT\0"
+ "GL_COMPARE_R_TO_TEXTURE\0"
+ "GL_COMPARE_R_TO_TEXTURE_ARB\0"
+ "GL_COMPILE\0"
+ "GL_COMPILE_AND_EXECUTE\0"
+ "GL_COMPRESSED_ALPHA\0"
+ "GL_COMPRESSED_ALPHA_ARB\0"
+ "GL_COMPRESSED_INTENSITY\0"
+ "GL_COMPRESSED_INTENSITY_ARB\0"
+ "GL_COMPRESSED_LUMINANCE\0"
+ "GL_COMPRESSED_LUMINANCE_ALPHA\0"
+ "GL_COMPRESSED_LUMINANCE_ALPHA_ARB\0"
+ "GL_COMPRESSED_LUMINANCE_ARB\0"
+ "GL_COMPRESSED_RGB\0"
+ "GL_COMPRESSED_RGBA\0"
+ "GL_COMPRESSED_RGBA_ARB\0"
+ "GL_COMPRESSED_RGBA_FXT1_3DFX\0"
+ "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT\0"
+ "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT\0"
+ "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT\0"
+ "GL_COMPRESSED_RGB_ARB\0"
+ "GL_COMPRESSED_RGB_FXT1_3DFX\0"
+ "GL_COMPRESSED_RGB_S3TC_DXT1_EXT\0"
+ "GL_COMPRESSED_TEXTURE_FORMATS\0"
+ "GL_CONSTANT\0"
+ "GL_CONSTANT_ALPHA\0"
+ "GL_CONSTANT_ALPHA_EXT\0"
+ "GL_CONSTANT_ARB\0"
+ "GL_CONSTANT_ATTENUATION\0"
+ "GL_CONSTANT_BORDER_HP\0"
+ "GL_CONSTANT_COLOR\0"
+ "GL_CONSTANT_COLOR_EXT\0"
+ "GL_CONSTANT_EXT\0"
+ "GL_CONVOLUTION_1D\0"
+ "GL_CONVOLUTION_2D\0"
+ "GL_CONVOLUTION_BORDER_COLOR\0"
+ "GL_CONVOLUTION_BORDER_COLOR_HP\0"
+ "GL_CONVOLUTION_BORDER_MODE\0"
+ "GL_CONVOLUTION_BORDER_MODE_EXT\0"
+ "GL_CONVOLUTION_FILTER_BIAS\0"
+ "GL_CONVOLUTION_FILTER_BIAS_EXT\0"
+ "GL_CONVOLUTION_FILTER_SCALE\0"
+ "GL_CONVOLUTION_FILTER_SCALE_EXT\0"
+ "GL_CONVOLUTION_FORMAT\0"
+ "GL_CONVOLUTION_FORMAT_EXT\0"
+ "GL_CONVOLUTION_HEIGHT\0"
+ "GL_CONVOLUTION_HEIGHT_EXT\0"
+ "GL_CONVOLUTION_WIDTH\0"
+ "GL_CONVOLUTION_WIDTH_EXT\0"
+ "GL_COORD_REPLACE_ARB\0"
+ "GL_COORD_REPLACE_NV\0"
+ "GL_COPY\0"
+ "GL_COPY_INVERTED\0"
+ "GL_COPY_PIXEL_TOKEN\0"
+ "GL_CULL_FACE\0"
+ "GL_CULL_FACE_MODE\0"
+ "GL_CULL_VERTEX_EXT\0"
+ "GL_CULL_VERTEX_EYE_POSITION_EXT\0"
+ "GL_CULL_VERTEX_OBJECT_POSITION_EXT\0"
+ "GL_CURRENT_ATTRIB_NV\0"
+ "GL_CURRENT_BIT\0"
+ "GL_CURRENT_COLOR\0"
+ "GL_CURRENT_FOG_COORD\0"
+ "GL_CURRENT_FOG_COORDINATE\0"
+ "GL_CURRENT_INDEX\0"
+ "GL_CURRENT_MATRIX_ARB\0"
+ "GL_CURRENT_MATRIX_INDEX_ARB\0"
+ "GL_CURRENT_MATRIX_NV\0"
+ "GL_CURRENT_MATRIX_STACK_DEPTH_ARB\0"
+ "GL_CURRENT_MATRIX_STACK_DEPTH_NV\0"
+ "GL_CURRENT_NORMAL\0"
+ "GL_CURRENT_PALETTE_MATRIX_ARB\0"
+ "GL_CURRENT_QUERY\0"
+ "GL_CURRENT_QUERY_ARB\0"
+ "GL_CURRENT_RASTER_COLOR\0"
+ "GL_CURRENT_RASTER_DISTANCE\0"
+ "GL_CURRENT_RASTER_INDEX\0"
+ "GL_CURRENT_RASTER_POSITION\0"
+ "GL_CURRENT_RASTER_POSITION_VALID\0"
+ "GL_CURRENT_RASTER_TEXTURE_COORDS\0"
+ "GL_CURRENT_SECONDARY_COLOR\0"
+ "GL_CURRENT_TEXTURE_COORDS\0"
+ "GL_CURRENT_VERTEX_ATTRIB_ARB\0"
+ "GL_CURRENT_WEIGHT_ARB\0"
+ "GL_CW\0"
+ "GL_DECAL\0"
+ "GL_DECR\0"
+ "GL_DECR_WRAP\0"
+ "GL_DECR_WRAP_EXT\0"
+ "GL_DEPTH\0"
+ "GL_DEPTH_ATTACHMENT_EXT\0"
+ "GL_DEPTH_BIAS\0"
+ "GL_DEPTH_BITS\0"
+ "GL_DEPTH_BOUNDS_EXT\0"
+ "GL_DEPTH_BOUNDS_TEST_EXT\0"
+ "GL_DEPTH_BUFFER_BIT\0"
+ "GL_DEPTH_CLAMP_NV\0"
+ "GL_DEPTH_CLEAR_VALUE\0"
+ "GL_DEPTH_COMPONENT\0"
+ "GL_DEPTH_COMPONENT16\0"
+ "GL_DEPTH_COMPONENT16_ARB\0"
+ "GL_DEPTH_COMPONENT16_SGIX\0"
+ "GL_DEPTH_COMPONENT24\0"
+ "GL_DEPTH_COMPONENT24_ARB\0"
+ "GL_DEPTH_COMPONENT24_SGIX\0"
+ "GL_DEPTH_COMPONENT32\0"
+ "GL_DEPTH_COMPONENT32_ARB\0"
+ "GL_DEPTH_COMPONENT32_SGIX\0"
+ "GL_DEPTH_FUNC\0"
+ "GL_DEPTH_RANGE\0"
+ "GL_DEPTH_SCALE\0"
+ "GL_DEPTH_STENCIL_NV\0"
+ "GL_DEPTH_STENCIL_TO_BGRA_NV\0"
+ "GL_DEPTH_STENCIL_TO_RGBA_NV\0"
+ "GL_DEPTH_TEST\0"
+ "GL_DEPTH_TEXTURE_MODE\0"
+ "GL_DEPTH_TEXTURE_MODE_ARB\0"
+ "GL_DEPTH_WRITEMASK\0"
+ "GL_DIFFUSE\0"
+ "GL_DITHER\0"
+ "GL_DOMAIN\0"
+ "GL_DONT_CARE\0"
+ "GL_DOT3_RGB\0"
+ "GL_DOT3_RGBA\0"
+ "GL_DOT3_RGBA_ARB\0"
+ "GL_DOT3_RGBA_EXT\0"
+ "GL_DOT3_RGB_ARB\0"
+ "GL_DOT3_RGB_EXT\0"
+ "GL_DOUBLE\0"
+ "GL_DOUBLEBUFFER\0"
+ "GL_DRAW_BUFFER\0"
+ "GL_DRAW_BUFFER0_ARB\0"
+ "GL_DRAW_BUFFER0_ATI\0"
+ "GL_DRAW_BUFFER10_ARB\0"
+ "GL_DRAW_BUFFER10_ATI\0"
+ "GL_DRAW_BUFFER11_ARB\0"
+ "GL_DRAW_BUFFER11_ATI\0"
+ "GL_DRAW_BUFFER12_ARB\0"
+ "GL_DRAW_BUFFER12_ATI\0"
+ "GL_DRAW_BUFFER13_ARB\0"
+ "GL_DRAW_BUFFER13_ATI\0"
+ "GL_DRAW_BUFFER14_ARB\0"
+ "GL_DRAW_BUFFER14_ATI\0"
+ "GL_DRAW_BUFFER15_ARB\0"
+ "GL_DRAW_BUFFER15_ATI\0"
+ "GL_DRAW_BUFFER1_ARB\0"
+ "GL_DRAW_BUFFER1_ATI\0"
+ "GL_DRAW_BUFFER2_ARB\0"
+ "GL_DRAW_BUFFER2_ATI\0"
+ "GL_DRAW_BUFFER3_ARB\0"
+ "GL_DRAW_BUFFER3_ATI\0"
+ "GL_DRAW_BUFFER4_ARB\0"
+ "GL_DRAW_BUFFER4_ATI\0"
+ "GL_DRAW_BUFFER5_ARB\0"
+ "GL_DRAW_BUFFER5_ATI\0"
+ "GL_DRAW_BUFFER6_ARB\0"
+ "GL_DRAW_BUFFER6_ATI\0"
+ "GL_DRAW_BUFFER7_ARB\0"
+ "GL_DRAW_BUFFER7_ATI\0"
+ "GL_DRAW_BUFFER8_ARB\0"
+ "GL_DRAW_BUFFER8_ATI\0"
+ "GL_DRAW_BUFFER9_ARB\0"
+ "GL_DRAW_BUFFER9_ATI\0"
+ "GL_DRAW_PIXEL_TOKEN\0"
+ "GL_DST_ALPHA\0"
+ "GL_DST_COLOR\0"
+ "GL_DYNAMIC_COPY\0"
+ "GL_DYNAMIC_COPY_ARB\0"
+ "GL_DYNAMIC_DRAW\0"
+ "GL_DYNAMIC_DRAW_ARB\0"
+ "GL_DYNAMIC_READ\0"
+ "GL_DYNAMIC_READ_ARB\0"
+ "GL_EDGE_FLAG\0"
+ "GL_EDGE_FLAG_ARRAY\0"
+ "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING\0"
+ "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB\0"
+ "GL_EDGE_FLAG_ARRAY_POINTER\0"
+ "GL_EDGE_FLAG_ARRAY_STRIDE\0"
+ "GL_ELEMENT_ARRAY_BUFFER\0"
+ "GL_ELEMENT_ARRAY_BUFFER_ARB\0"
+ "GL_ELEMENT_ARRAY_BUFFER_BINDING\0"
+ "GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB\0"
+ "GL_EMISSION\0"
+ "GL_ENABLE_BIT\0"
+ "GL_EQUAL\0"
+ "GL_EQUIV\0"
+ "GL_EVAL_BIT\0"
+ "GL_EXP\0"
+ "GL_EXP2\0"
+ "GL_EXTENSIONS\0"
+ "GL_EYE_LINEAR\0"
+ "GL_EYE_PLANE\0"
+ "GL_EYE_PLANE_ABSOLUTE_NV\0"
+ "GL_EYE_RADIAL_NV\0"
+ "GL_FALSE\0"
+ "GL_FASTEST\0"
+ "GL_FEEDBACK\0"
+ "GL_FEEDBACK_BUFFER_POINTER\0"
+ "GL_FEEDBACK_BUFFER_SIZE\0"
+ "GL_FEEDBACK_BUFFER_TYPE\0"
+ "GL_FILL\0"
+ "GL_FLAT\0"
+ "GL_FLOAT\0"
+ "GL_FLOAT_MAT2_ARB\0"
+ "GL_FLOAT_MAT3_ARB\0"
+ "GL_FLOAT_MAT4_ARB\0"
+ "GL_FLOAT_VEC2_ARB\0"
+ "GL_FLOAT_VEC3_ARB\0"
+ "GL_FLOAT_VEC4_ARB\0"
+ "GL_FOG\0"
+ "GL_FOG_BIT\0"
+ "GL_FOG_COLOR\0"
+ "GL_FOG_COORD\0"
+ "GL_FOG_COORDINATE\0"
+ "GL_FOG_COORDINATE_ARRAY\0"
+ "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING\0"
+ "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB\0"
+ "GL_FOG_COORDINATE_ARRAY_POINTER\0"
+ "GL_FOG_COORDINATE_ARRAY_STRIDE\0"
+ "GL_FOG_COORDINATE_ARRAY_TYPE\0"
+ "GL_FOG_COORDINATE_SOURCE\0"
+ "GL_FOG_COORD_ARRAY\0"
+ "GL_FOG_COORD_ARRAY_BUFFER_BINDING\0"
+ "GL_FOG_COORD_ARRAY_POINTER\0"
+ "GL_FOG_COORD_ARRAY_STRIDE\0"
+ "GL_FOG_COORD_ARRAY_TYPE\0"
+ "GL_FOG_COORD_SOURCE\0"
+ "GL_FOG_DENSITY\0"
+ "GL_FOG_DISTANCE_MODE_NV\0"
+ "GL_FOG_END\0"
+ "GL_FOG_HINT\0"
+ "GL_FOG_INDEX\0"
+ "GL_FOG_MODE\0"
+ "GL_FOG_OFFSET_SGIX\0"
+ "GL_FOG_OFFSET_VALUE_SGIX\0"
+ "GL_FOG_START\0"
+ "GL_FRAGMENT_DEPTH\0"
+ "GL_FRAGMENT_PROGRAM_ARB\0"
+ "GL_FRAGMENT_SHADER_ARB\0"
+ "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT\0"
+ "GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT\0"
+ "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT\0"
+ "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT\0"
+ "GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT\0"
+ "GL_FRAMEBUFFER_BINDING_EXT\0"
+ "GL_FRAMEBUFFER_COMPLETE_EXT\0"
+ "GL_FRAMEBUFFER_EXT\0"
+ "GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT\0"
+ "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT\0"
+ "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT\0"
+ "GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT\0"
+ "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT\0"
+ "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT\0"
+ "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT\0"
+ "GL_FRAMEBUFFER_STATUS_ERROR_EXT\0"
+ "GL_FRAMEBUFFER_UNSUPPORTED_EXT\0"
+ "GL_FRONT\0"
+ "GL_FRONT_AND_BACK\0"
+ "GL_FRONT_FACE\0"
+ "GL_FRONT_LEFT\0"
+ "GL_FRONT_RIGHT\0"
+ "GL_FUNC_ADD\0"
+ "GL_FUNC_ADD_EXT\0"
+ "GL_FUNC_REVERSE_SUBTRACT\0"
+ "GL_FUNC_REVERSE_SUBTRACT_EXT\0"
+ "GL_FUNC_SUBTRACT\0"
+ "GL_FUNC_SUBTRACT_EXT\0"
+ "GL_GENERATE_MIPMAP\0"
+ "GL_GENERATE_MIPMAP_HINT\0"
+ "GL_GENERATE_MIPMAP_HINT_SGIS\0"
+ "GL_GENERATE_MIPMAP_SGIS\0"
+ "GL_GEQUAL\0"
+ "GL_GREATER\0"
+ "GL_GREEN\0"
+ "GL_GREEN_BIAS\0"
+ "GL_GREEN_BITS\0"
+ "GL_GREEN_SCALE\0"
+ "GL_HINT_BIT\0"
+ "GL_HISTOGRAM\0"
+ "GL_HISTOGRAM_ALPHA_SIZE\0"
+ "GL_HISTOGRAM_ALPHA_SIZE_EXT\0"
+ "GL_HISTOGRAM_BLUE_SIZE\0"
+ "GL_HISTOGRAM_BLUE_SIZE_EXT\0"
+ "GL_HISTOGRAM_EXT\0"
+ "GL_HISTOGRAM_FORMAT\0"
+ "GL_HISTOGRAM_FORMAT_EXT\0"
+ "GL_HISTOGRAM_GREEN_SIZE\0"
+ "GL_HISTOGRAM_GREEN_SIZE_EXT\0"
+ "GL_HISTOGRAM_LUMINANCE_SIZE\0"
+ "GL_HISTOGRAM_LUMINANCE_SIZE_EXT\0"
+ "GL_HISTOGRAM_RED_SIZE\0"
+ "GL_HISTOGRAM_RED_SIZE_EXT\0"
+ "GL_HISTOGRAM_SINK\0"
+ "GL_HISTOGRAM_SINK_EXT\0"
+ "GL_HISTOGRAM_WIDTH\0"
+ "GL_HISTOGRAM_WIDTH_EXT\0"
+ "GL_IDENTITY_NV\0"
+ "GL_IGNORE_BORDER_HP\0"
+ "GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES\0"
+ "GL_IMPLEMENTATION_COLOR_READ_TYPE_OES\0"
+ "GL_INCR\0"
+ "GL_INCR_WRAP\0"
+ "GL_INCR_WRAP_EXT\0"
+ "GL_INDEX_ARRAY\0"
+ "GL_INDEX_ARRAY_BUFFER_BINDING\0"
+ "GL_INDEX_ARRAY_BUFFER_BINDING_ARB\0"
+ "GL_INDEX_ARRAY_POINTER\0"
+ "GL_INDEX_ARRAY_STRIDE\0"
+ "GL_INDEX_ARRAY_TYPE\0"
+ "GL_INDEX_BITS\0"
+ "GL_INDEX_CLEAR_VALUE\0"
+ "GL_INDEX_LOGIC_OP\0"
+ "GL_INDEX_MODE\0"
+ "GL_INDEX_OFFSET\0"
+ "GL_INDEX_SHIFT\0"
+ "GL_INDEX_WRITEMASK\0"
+ "GL_INT\0"
+ "GL_INTENSITY\0"
+ "GL_INTENSITY12\0"
+ "GL_INTENSITY12_EXT\0"
+ "GL_INTENSITY16\0"
+ "GL_INTENSITY16_EXT\0"
+ "GL_INTENSITY4\0"
+ "GL_INTENSITY4_EXT\0"
+ "GL_INTENSITY8\0"
+ "GL_INTENSITY8_EXT\0"
+ "GL_INTENSITY_EXT\0"
+ "GL_INTERPOLATE\0"
+ "GL_INTERPOLATE_ARB\0"
+ "GL_INTERPOLATE_EXT\0"
+ "GL_INT_VEC2_ARB\0"
+ "GL_INT_VEC3_ARB\0"
+ "GL_INT_VEC4_ARB\0"
+ "GL_INVALID_ENUM\0"
+ "GL_INVALID_FRAMEBUFFER_OPERATION_EXT\0"
+ "GL_INVALID_OPERATION\0"
+ "GL_INVALID_VALUE\0"
+ "GL_INVERSE_NV\0"
+ "GL_INVERSE_TRANSPOSE_NV\0"
+ "GL_INVERT\0"
+ "GL_KEEP\0"
+ "GL_LEFT\0"
+ "GL_LEQUAL\0"
+ "GL_LESS\0"
+ "GL_LIGHT0\0"
+ "GL_LIGHT1\0"
+ "GL_LIGHT2\0"
+ "GL_LIGHT3\0"
+ "GL_LIGHT4\0"
+ "GL_LIGHT5\0"
+ "GL_LIGHT6\0"
+ "GL_LIGHT7\0"
+ "GL_LIGHTING\0"
+ "GL_LIGHTING_BIT\0"
+ "GL_LIGHT_MODEL_AMBIENT\0"
+ "GL_LIGHT_MODEL_COLOR_CONTROL\0"
+ "GL_LIGHT_MODEL_COLOR_CONTROL_EXT\0"
+ "GL_LIGHT_MODEL_LOCAL_VIEWER\0"
+ "GL_LIGHT_MODEL_TWO_SIDE\0"
+ "GL_LINE\0"
+ "GL_LINEAR\0"
+ "GL_LINEAR_ATTENUATION\0"
+ "GL_LINEAR_CLIPMAP_LINEAR_SGIX\0"
+ "GL_LINEAR_CLIPMAP_NEAREST_SGIX\0"
+ "GL_LINEAR_MIPMAP_LINEAR\0"
+ "GL_LINEAR_MIPMAP_NEAREST\0"
+ "GL_LINES\0"
+ "GL_LINE_BIT\0"
+ "GL_LINE_LOOP\0"
+ "GL_LINE_RESET_TOKEN\0"
+ "GL_LINE_SMOOTH\0"
+ "GL_LINE_SMOOTH_HINT\0"
+ "GL_LINE_STIPPLE\0"
+ "GL_LINE_STIPPLE_PATTERN\0"
+ "GL_LINE_STIPPLE_REPEAT\0"
+ "GL_LINE_STRIP\0"
+ "GL_LINE_TOKEN\0"
+ "GL_LINE_WIDTH\0"
+ "GL_LINE_WIDTH_GRANULARITY\0"
+ "GL_LINE_WIDTH_RANGE\0"
+ "GL_LIST_BASE\0"
+ "GL_LIST_BIT\0"
+ "GL_LIST_INDEX\0"
+ "GL_LIST_MODE\0"
+ "GL_LOAD\0"
+ "GL_LOGIC_OP\0"
+ "GL_LOGIC_OP_MODE\0"
+ "GL_LUMINANCE\0"
+ "GL_LUMINANCE12\0"
+ "GL_LUMINANCE12_ALPHA12\0"
+ "GL_LUMINANCE12_ALPHA12_EXT\0"
+ "GL_LUMINANCE12_ALPHA4\0"
+ "GL_LUMINANCE12_ALPHA4_EXT\0"
+ "GL_LUMINANCE12_EXT\0"
+ "GL_LUMINANCE16\0"
+ "GL_LUMINANCE16_ALPHA16\0"
+ "GL_LUMINANCE16_ALPHA16_EXT\0"
+ "GL_LUMINANCE16_EXT\0"
+ "GL_LUMINANCE4\0"
+ "GL_LUMINANCE4_ALPHA4\0"
+ "GL_LUMINANCE4_ALPHA4_EXT\0"
+ "GL_LUMINANCE4_EXT\0"
+ "GL_LUMINANCE6_ALPHA2\0"
+ "GL_LUMINANCE6_ALPHA2_EXT\0"
+ "GL_LUMINANCE8\0"
+ "GL_LUMINANCE8_ALPHA8\0"
+ "GL_LUMINANCE8_ALPHA8_EXT\0"
+ "GL_LUMINANCE8_EXT\0"
+ "GL_LUMINANCE_ALPHA\0"
+ "GL_MAP1_COLOR_4\0"
+ "GL_MAP1_GRID_DOMAIN\0"
+ "GL_MAP1_GRID_SEGMENTS\0"
+ "GL_MAP1_INDEX\0"
+ "GL_MAP1_NORMAL\0"
+ "GL_MAP1_TEXTURE_COORD_1\0"
+ "GL_MAP1_TEXTURE_COORD_2\0"
+ "GL_MAP1_TEXTURE_COORD_3\0"
+ "GL_MAP1_TEXTURE_COORD_4\0"
+ "GL_MAP1_VERTEX_3\0"
+ "GL_MAP1_VERTEX_4\0"
+ "GL_MAP1_VERTEX_ATTRIB0_4_NV\0"
+ "GL_MAP1_VERTEX_ATTRIB10_4_NV\0"
+ "GL_MAP1_VERTEX_ATTRIB11_4_NV\0"
+ "GL_MAP1_VERTEX_ATTRIB12_4_NV\0"
+ "GL_MAP1_VERTEX_ATTRIB13_4_NV\0"
+ "GL_MAP1_VERTEX_ATTRIB14_4_NV\0"
+ "GL_MAP1_VERTEX_ATTRIB15_4_NV\0"
+ "GL_MAP1_VERTEX_ATTRIB1_4_NV\0"
+ "GL_MAP1_VERTEX_ATTRIB2_4_NV\0"
+ "GL_MAP1_VERTEX_ATTRIB3_4_NV\0"
+ "GL_MAP1_VERTEX_ATTRIB4_4_NV\0"
+ "GL_MAP1_VERTEX_ATTRIB5_4_NV\0"
+ "GL_MAP1_VERTEX_ATTRIB6_4_NV\0"
+ "GL_MAP1_VERTEX_ATTRIB7_4_NV\0"
+ "GL_MAP1_VERTEX_ATTRIB8_4_NV\0"
+ "GL_MAP1_VERTEX_ATTRIB9_4_NV\0"
+ "GL_MAP2_COLOR_4\0"
+ "GL_MAP2_GRID_DOMAIN\0"
+ "GL_MAP2_GRID_SEGMENTS\0"
+ "GL_MAP2_INDEX\0"
+ "GL_MAP2_NORMAL\0"
+ "GL_MAP2_TEXTURE_COORD_1\0"
+ "GL_MAP2_TEXTURE_COORD_2\0"
+ "GL_MAP2_TEXTURE_COORD_3\0"
+ "GL_MAP2_TEXTURE_COORD_4\0"
+ "GL_MAP2_VERTEX_3\0"
+ "GL_MAP2_VERTEX_4\0"
+ "GL_MAP2_VERTEX_ATTRIB0_4_NV\0"
+ "GL_MAP2_VERTEX_ATTRIB10_4_NV\0"
+ "GL_MAP2_VERTEX_ATTRIB11_4_NV\0"
+ "GL_MAP2_VERTEX_ATTRIB12_4_NV\0"
+ "GL_MAP2_VERTEX_ATTRIB13_4_NV\0"
+ "GL_MAP2_VERTEX_ATTRIB14_4_NV\0"
+ "GL_MAP2_VERTEX_ATTRIB15_4_NV\0"
+ "GL_MAP2_VERTEX_ATTRIB1_4_NV\0"
+ "GL_MAP2_VERTEX_ATTRIB2_4_NV\0"
+ "GL_MAP2_VERTEX_ATTRIB3_4_NV\0"
+ "GL_MAP2_VERTEX_ATTRIB4_4_NV\0"
+ "GL_MAP2_VERTEX_ATTRIB5_4_NV\0"
+ "GL_MAP2_VERTEX_ATTRIB6_4_NV\0"
+ "GL_MAP2_VERTEX_ATTRIB7_4_NV\0"
+ "GL_MAP2_VERTEX_ATTRIB8_4_NV\0"
+ "GL_MAP2_VERTEX_ATTRIB9_4_NV\0"
+ "GL_MAP_COLOR\0"
+ "GL_MAP_STENCIL\0"
+ "GL_MATRIX0_ARB\0"
+ "GL_MATRIX0_NV\0"
+ "GL_MATRIX10_ARB\0"
+ "GL_MATRIX11_ARB\0"
+ "GL_MATRIX12_ARB\0"
+ "GL_MATRIX13_ARB\0"
+ "GL_MATRIX14_ARB\0"
+ "GL_MATRIX15_ARB\0"
+ "GL_MATRIX16_ARB\0"
+ "GL_MATRIX17_ARB\0"
+ "GL_MATRIX18_ARB\0"
+ "GL_MATRIX19_ARB\0"
+ "GL_MATRIX1_ARB\0"
+ "GL_MATRIX1_NV\0"
+ "GL_MATRIX20_ARB\0"
+ "GL_MATRIX21_ARB\0"
+ "GL_MATRIX22_ARB\0"
+ "GL_MATRIX23_ARB\0"
+ "GL_MATRIX24_ARB\0"
+ "GL_MATRIX25_ARB\0"
+ "GL_MATRIX26_ARB\0"
+ "GL_MATRIX27_ARB\0"
+ "GL_MATRIX28_ARB\0"
+ "GL_MATRIX29_ARB\0"
+ "GL_MATRIX2_ARB\0"
+ "GL_MATRIX2_NV\0"
+ "GL_MATRIX30_ARB\0"
+ "GL_MATRIX31_ARB\0"
+ "GL_MATRIX3_ARB\0"
+ "GL_MATRIX3_NV\0"
+ "GL_MATRIX4_ARB\0"
+ "GL_MATRIX4_NV\0"
+ "GL_MATRIX5_ARB\0"
+ "GL_MATRIX5_NV\0"
+ "GL_MATRIX6_ARB\0"
+ "GL_MATRIX6_NV\0"
+ "GL_MATRIX7_ARB\0"
+ "GL_MATRIX7_NV\0"
+ "GL_MATRIX8_ARB\0"
+ "GL_MATRIX9_ARB\0"
+ "GL_MATRIX_INDEX_ARRAY_ARB\0"
+ "GL_MATRIX_INDEX_ARRAY_POINTER_ARB\0"
+ "GL_MATRIX_INDEX_ARRAY_SIZE_ARB\0"
+ "GL_MATRIX_INDEX_ARRAY_STRIDE_ARB\0"
+ "GL_MATRIX_INDEX_ARRAY_TYPE_ARB\0"
+ "GL_MATRIX_MODE\0"
+ "GL_MATRIX_PALETTE_ARB\0"
+ "GL_MAX\0"
+ "GL_MAX_3D_TEXTURE_SIZE\0"
+ "GL_MAX_ATTRIB_STACK_DEPTH\0"
+ "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH\0"
+ "GL_MAX_CLIPMAP_DEPTH_SGIX\0"
+ "GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX\0"
+ "GL_MAX_CLIP_PLANES\0"
+ "GL_MAX_COLOR_ATTACHMENTS_EXT\0"
+ "GL_MAX_COLOR_MATRIX_STACK_DEPTH\0"
+ "GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI\0"
+ "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB\0"
+ "GL_MAX_CONVOLUTION_HEIGHT\0"
+ "GL_MAX_CONVOLUTION_HEIGHT_EXT\0"
+ "GL_MAX_CONVOLUTION_WIDTH\0"
+ "GL_MAX_CONVOLUTION_WIDTH_EXT\0"
+ "GL_MAX_CUBE_MAP_TEXTURE_SIZE\0"
+ "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB\0"
+ "GL_MAX_DRAW_BUFFERS_ARB\0"
+ "GL_MAX_DRAW_BUFFERS_ATI\0"
+ "GL_MAX_ELEMENTS_INDICES\0"
+ "GL_MAX_ELEMENTS_VERTICES\0"
+ "GL_MAX_EVAL_ORDER\0"
+ "GL_MAX_EXT\0"
+ "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB\0"
+ "GL_MAX_LIGHTS\0"
+ "GL_MAX_LIST_NESTING\0"
+ "GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB\0"
+ "GL_MAX_MODELVIEW_STACK_DEPTH\0"
+ "GL_MAX_NAME_STACK_DEPTH\0"
+ "GL_MAX_PALETTE_MATRICES_ARB\0"
+ "GL_MAX_PIXEL_MAP_TABLE\0"
+ "GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB\0"
+ "GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB\0"
+ "GL_MAX_PROGRAM_ATTRIBS_ARB\0"
+ "GL_MAX_PROGRAM_CALL_DEPTH_NV\0"
+ "GL_MAX_PROGRAM_ENV_PARAMETERS_ARB\0"
+ "GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV\0"
+ "GL_MAX_PROGRAM_IF_DEPTH_NV\0"
+ "GL_MAX_PROGRAM_INSTRUCTIONS_ARB\0"
+ "GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB\0"
+ "GL_MAX_PROGRAM_LOOP_COUNT_NV\0"
+ "GL_MAX_PROGRAM_LOOP_DEPTH_NV\0"
+ "GL_MAX_PROGRAM_MATRICES_ARB\0"
+ "GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB\0"
+ "GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB\0"
+ "GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB\0"
+ "GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB\0"
+ "GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB\0"
+ "GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB\0"
+ "GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB\0"
+ "GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB\0"
+ "GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB\0"
+ "GL_MAX_PROGRAM_PARAMETERS_ARB\0"
+ "GL_MAX_PROGRAM_TEMPORARIES_ARB\0"
+ "GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB\0"
+ "GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB\0"
+ "GL_MAX_PROJECTION_STACK_DEPTH\0"
+ "GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB\0"
+ "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV\0"
+ "GL_MAX_RENDERBUFFER_SIZE_EXT\0"
+ "GL_MAX_SHININESS_NV\0"
+ "GL_MAX_SPOT_EXPONENT_NV\0"
+ "GL_MAX_TEXTURE_COORDS_ARB\0"
+ "GL_MAX_TEXTURE_IMAGE_UNITS_ARB\0"
+ "GL_MAX_TEXTURE_LOD_BIAS\0"
+ "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT\0"
+ "GL_MAX_TEXTURE_SIZE\0"
+ "GL_MAX_TEXTURE_STACK_DEPTH\0"
+ "GL_MAX_TEXTURE_UNITS\0"
+ "GL_MAX_TEXTURE_UNITS_ARB\0"
+ "GL_MAX_TRACK_MATRICES_NV\0"
+ "GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV\0"
+ "GL_MAX_VARYING_FLOATS_ARB\0"
+ "GL_MAX_VERTEX_ATTRIBS_ARB\0"
+ "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB\0"
+ "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB\0"
+ "GL_MAX_VERTEX_UNITS_ARB\0"
+ "GL_MAX_VIEWPORT_DIMS\0"
+ "GL_MIN\0"
+ "GL_MINMAX\0"
+ "GL_MINMAX_EXT\0"
+ "GL_MINMAX_FORMAT\0"
+ "GL_MINMAX_FORMAT_EXT\0"
+ "GL_MINMAX_SINK\0"
+ "GL_MINMAX_SINK_EXT\0"
+ "GL_MIN_EXT\0"
+ "GL_MIRRORED_REPEAT\0"
+ "GL_MIRRORED_REPEAT_ARB\0"
+ "GL_MIRRORED_REPEAT_IBM\0"
+ "GL_MIRROR_CLAMP_ATI\0"
+ "GL_MIRROR_CLAMP_EXT\0"
+ "GL_MIRROR_CLAMP_TO_BORDER_EXT\0"
+ "GL_MIRROR_CLAMP_TO_EDGE_ATI\0"
+ "GL_MIRROR_CLAMP_TO_EDGE_EXT\0"
+ "GL_MODELVIEW\0"
+ "GL_MODELVIEW0_ARB\0"
+ "GL_MODELVIEW10_ARB\0"
+ "GL_MODELVIEW11_ARB\0"
+ "GL_MODELVIEW12_ARB\0"
+ "GL_MODELVIEW13_ARB\0"
+ "GL_MODELVIEW14_ARB\0"
+ "GL_MODELVIEW15_ARB\0"
+ "GL_MODELVIEW16_ARB\0"
+ "GL_MODELVIEW17_ARB\0"
+ "GL_MODELVIEW18_ARB\0"
+ "GL_MODELVIEW19_ARB\0"
+ "GL_MODELVIEW1_ARB\0"
+ "GL_MODELVIEW20_ARB\0"
+ "GL_MODELVIEW21_ARB\0"
+ "GL_MODELVIEW22_ARB\0"
+ "GL_MODELVIEW23_ARB\0"
+ "GL_MODELVIEW24_ARB\0"
+ "GL_MODELVIEW25_ARB\0"
+ "GL_MODELVIEW26_ARB\0"
+ "GL_MODELVIEW27_ARB\0"
+ "GL_MODELVIEW28_ARB\0"
+ "GL_MODELVIEW29_ARB\0"
+ "GL_MODELVIEW2_ARB\0"
+ "GL_MODELVIEW30_ARB\0"
+ "GL_MODELVIEW31_ARB\0"
+ "GL_MODELVIEW3_ARB\0"
+ "GL_MODELVIEW4_ARB\0"
+ "GL_MODELVIEW5_ARB\0"
+ "GL_MODELVIEW6_ARB\0"
+ "GL_MODELVIEW7_ARB\0"
+ "GL_MODELVIEW8_ARB\0"
+ "GL_MODELVIEW9_ARB\0"
+ "GL_MODELVIEW_MATRIX\0"
+ "GL_MODELVIEW_PROJECTION_NV\0"
+ "GL_MODELVIEW_STACK_DEPTH\0"
+ "GL_MODULATE\0"
+ "GL_MODULATE_ADD_ATI\0"
+ "GL_MODULATE_SIGNED_ADD_ATI\0"
+ "GL_MODULATE_SUBTRACT_ATI\0"
+ "GL_MULT\0"
+ "GL_MULTISAMPLE\0"
+ "GL_MULTISAMPLE_3DFX\0"
+ "GL_MULTISAMPLE_ARB\0"
+ "GL_MULTISAMPLE_BIT\0"
+ "GL_MULTISAMPLE_BIT_3DFX\0"
+ "GL_MULTISAMPLE_BIT_ARB\0"
+ "GL_MULTISAMPLE_FILTER_HINT_NV\0"
+ "GL_N3F_V3F\0"
+ "GL_NAME_STACK_DEPTH\0"
+ "GL_NAND\0"
+ "GL_NEAREST\0"
+ "GL_NEAREST_CLIPMAP_LINEAR_SGIX\0"
+ "GL_NEAREST_CLIPMAP_NEAREST_SGIX\0"
+ "GL_NEAREST_MIPMAP_LINEAR\0"
+ "GL_NEAREST_MIPMAP_NEAREST\0"
+ "GL_NEVER\0"
+ "GL_NICEST\0"
+ "GL_NONE\0"
+ "GL_NOOP\0"
+ "GL_NOR\0"
+ "GL_NORMALIZE\0"
+ "GL_NORMAL_ARRAY\0"
+ "GL_NORMAL_ARRAY_BUFFER_BINDING\0"
+ "GL_NORMAL_ARRAY_BUFFER_BINDING_ARB\0"
+ "GL_NORMAL_ARRAY_POINTER\0"
+ "GL_NORMAL_ARRAY_STRIDE\0"
+ "GL_NORMAL_ARRAY_TYPE\0"
+ "GL_NORMAL_MAP\0"
+ "GL_NORMAL_MAP_ARB\0"
+ "GL_NORMAL_MAP_NV\0"
+ "GL_NOTEQUAL\0"
+ "GL_NO_ERROR\0"
+ "GL_NUM_COMPRESSED_TEXTURE_FORMATS\0"
+ "GL_NUM_TEXTURE_COMPRESSED_FORMATS_ARB\0"
+ "GL_OBJECT_ACTIVE_ATTRIBUTES_ARB\0"
+ "GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB\0"
+ "GL_OBJECT_ACTIVE_UNIFORMS_ARB\0"
+ "GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB\0"
+ "GL_OBJECT_ATTACHED_OBJECTS_ARB\0"
+ "GL_OBJECT_COMPILE_STATUS_ARB\0"
+ "GL_OBJECT_DELETE_STATUS_ARB\0"
+ "GL_OBJECT_INFO_LOG_LENGTH_ARB\0"
+ "GL_OBJECT_LINEAR\0"
+ "GL_OBJECT_LINK_STATUS_ARB\0"
+ "GL_OBJECT_PLANE\0"
+ "GL_OBJECT_SHADER_SOURCE_LENGTH_ARB\0"
+ "GL_OBJECT_SUBTYPE_ARB\0"
+ "GL_OBJECT_TYPE_ARB\0"
+ "GL_OBJECT_VALIDATE_STATUS_ARB\0"
+ "GL_OCCLUSION_TEST_HP\0"
+ "GL_OCCLUSION_TEST_RESULT_HP\0"
+ "GL_ONE\0"
+ "GL_ONE_MINUS_CONSTANT_ALPHA\0"
+ "GL_ONE_MINUS_CONSTANT_ALPHA_EXT\0"
+ "GL_ONE_MINUS_CONSTANT_COLOR\0"
+ "GL_ONE_MINUS_CONSTANT_COLOR_EXT\0"
+ "GL_ONE_MINUS_DST_ALPHA\0"
+ "GL_ONE_MINUS_DST_COLOR\0"
+ "GL_ONE_MINUS_SRC_ALPHA\0"
+ "GL_ONE_MINUS_SRC_COLOR\0"
+ "GL_OPERAND0_ALPHA\0"
+ "GL_OPERAND0_ALPHA_ARB\0"
+ "GL_OPERAND0_ALPHA_EXT\0"
+ "GL_OPERAND0_RGB\0"
+ "GL_OPERAND0_RGB_ARB\0"
+ "GL_OPERAND0_RGB_EXT\0"
+ "GL_OPERAND1_ALPHA\0"
+ "GL_OPERAND1_ALPHA_ARB\0"
+ "GL_OPERAND1_ALPHA_EXT\0"
+ "GL_OPERAND1_RGB\0"
+ "GL_OPERAND1_RGB_ARB\0"
+ "GL_OPERAND1_RGB_EXT\0"
+ "GL_OPERAND2_ALPHA\0"
+ "GL_OPERAND2_ALPHA_ARB\0"
+ "GL_OPERAND2_ALPHA_EXT\0"
+ "GL_OPERAND2_RGB\0"
+ "GL_OPERAND2_RGB_ARB\0"
+ "GL_OPERAND2_RGB_EXT\0"
+ "GL_OPERAND3_ALPHA_NV\0"
+ "GL_OPERAND3_RGB_NV\0"
+ "GL_OR\0"
+ "GL_ORDER\0"
+ "GL_OR_INVERTED\0"
+ "GL_OR_REVERSE\0"
+ "GL_OUT_OF_MEMORY\0"
+ "GL_PACK_ALIGNMENT\0"
+ "GL_PACK_IMAGE_HEIGHT\0"
+ "GL_PACK_INVERT_MESA\0"
+ "GL_PACK_LSB_FIRST\0"
+ "GL_PACK_ROW_LENGTH\0"
+ "GL_PACK_SKIP_IMAGES\0"
+ "GL_PACK_SKIP_PIXELS\0"
+ "GL_PACK_SKIP_ROWS\0"
+ "GL_PACK_SWAP_BYTES\0"
+ "GL_PALETTE4_R5_G6_B5_OES\0"
+ "GL_PALETTE4_RGB5_A1_OES\0"
+ "GL_PALETTE4_RGB8_OES\0"
+ "GL_PALETTE4_RGBA4_OES\0"
+ "GL_PALETTE4_RGBA8_OES\0"
+ "GL_PALETTE8_R5_G6_B5_OES\0"
+ "GL_PALETTE8_RGB5_A1_OES\0"
+ "GL_PALETTE8_RGB8_OES\0"
+ "GL_PALETTE8_RGBA4_OES\0"
+ "GL_PALETTE8_RGBA8_OES\0"
+ "GL_PASS_THROUGH_TOKEN\0"
+ "GL_PERSPECTIVE_CORRECTION_HINT\0"
+ "GL_PIXEL_MAP_A_TO_A\0"
+ "GL_PIXEL_MAP_A_TO_A_SIZE\0"
+ "GL_PIXEL_MAP_B_TO_B\0"
+ "GL_PIXEL_MAP_B_TO_B_SIZE\0"
+ "GL_PIXEL_MAP_G_TO_G\0"
+ "GL_PIXEL_MAP_G_TO_G_SIZE\0"
+ "GL_PIXEL_MAP_I_TO_A\0"
+ "GL_PIXEL_MAP_I_TO_A_SIZE\0"
+ "GL_PIXEL_MAP_I_TO_B\0"
+ "GL_PIXEL_MAP_I_TO_B_SIZE\0"
+ "GL_PIXEL_MAP_I_TO_G\0"
+ "GL_PIXEL_MAP_I_TO_G_SIZE\0"
+ "GL_PIXEL_MAP_I_TO_I\0"
+ "GL_PIXEL_MAP_I_TO_I_SIZE\0"
+ "GL_PIXEL_MAP_I_TO_R\0"
+ "GL_PIXEL_MAP_I_TO_R_SIZE\0"
+ "GL_PIXEL_MAP_R_TO_R\0"
+ "GL_PIXEL_MAP_R_TO_R_SIZE\0"
+ "GL_PIXEL_MAP_S_TO_S\0"
+ "GL_PIXEL_MAP_S_TO_S_SIZE\0"
+ "GL_PIXEL_MODE_BIT\0"
+ "GL_PIXEL_PACK_BUFFER_BINDING_EXT\0"
+ "GL_PIXEL_PACK_BUFFER_EXT\0"
+ "GL_PIXEL_UNPACK_BUFFER_BINDING_EXT\0"
+ "GL_PIXEL_UNPACK_BUFFER_EXT\0"
+ "GL_POINT\0"
+ "GL_POINTS\0"
+ "GL_POINT_BIT\0"
+ "GL_POINT_DISTANCE_ATTENUATION\0"
+ "GL_POINT_DISTANCE_ATTENUATION_ARB\0"
+ "GL_POINT_DISTANCE_ATTENUATION_EXT\0"
+ "GL_POINT_DISTANCE_ATTENUATION_SGIS\0"
+ "GL_POINT_FADE_THRESHOLD_SIZE\0"
+ "GL_POINT_FADE_THRESHOLD_SIZE_ARB\0"
+ "GL_POINT_FADE_THRESHOLD_SIZE_EXT\0"
+ "GL_POINT_FADE_THRESHOLD_SIZE_SGIS\0"
+ "GL_POINT_SIZE\0"
+ "GL_POINT_SIZE_GRANULARITY\0"
+ "GL_POINT_SIZE_MAX\0"
+ "GL_POINT_SIZE_MAX_ARB\0"
+ "GL_POINT_SIZE_MAX_EXT\0"
+ "GL_POINT_SIZE_MAX_SGIS\0"
+ "GL_POINT_SIZE_MIN\0"
+ "GL_POINT_SIZE_MIN_ARB\0"
+ "GL_POINT_SIZE_MIN_EXT\0"
+ "GL_POINT_SIZE_MIN_SGIS\0"
+ "GL_POINT_SIZE_RANGE\0"
+ "GL_POINT_SMOOTH\0"
+ "GL_POINT_SMOOTH_HINT\0"
+ "GL_POINT_SPRITE_ARB\0"
+ "GL_POINT_SPRITE_COORD_ORIGIN\0"
+ "GL_POINT_SPRITE_NV\0"
+ "GL_POINT_SPRITE_R_MODE_NV\0"
+ "GL_POINT_TOKEN\0"
+ "GL_POLYGON\0"
+ "GL_POLYGON_BIT\0"
+ "GL_POLYGON_MODE\0"
+ "GL_POLYGON_OFFSET_BIAS\0"
+ "GL_POLYGON_OFFSET_FACTOR\0"
+ "GL_POLYGON_OFFSET_FILL\0"
+ "GL_POLYGON_OFFSET_LINE\0"
+ "GL_POLYGON_OFFSET_POINT\0"
+ "GL_POLYGON_OFFSET_UNITS\0"
+ "GL_POLYGON_SMOOTH\0"
+ "GL_POLYGON_SMOOTH_HINT\0"
+ "GL_POLYGON_STIPPLE\0"
+ "GL_POLYGON_STIPPLE_BIT\0"
+ "GL_POLYGON_TOKEN\0"
+ "GL_POSITION\0"
+ "GL_POST_COLOR_MATRIX_ALPHA_BIAS\0"
+ "GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI\0"
+ "GL_POST_COLOR_MATRIX_ALPHA_SCALE\0"
+ "GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI\0"
+ "GL_POST_COLOR_MATRIX_BLUE_BIAS\0"
+ "GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI\0"
+ "GL_POST_COLOR_MATRIX_BLUE_SCALE\0"
+ "GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI\0"
+ "GL_POST_COLOR_MATRIX_COLOR_TABLE\0"
+ "GL_POST_COLOR_MATRIX_GREEN_BIAS\0"
+ "GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI\0"
+ "GL_POST_COLOR_MATRIX_GREEN_SCALE\0"
+ "GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI\0"
+ "GL_POST_COLOR_MATRIX_RED_BIAS\0"
+ "GL_POST_COLOR_MATRIX_RED_BIAS_SGI\0"
+ "GL_POST_COLOR_MATRIX_RED_SCALE\0"
+ "GL_POST_COLOR_MATRIX_RED_SCALE_SGI\0"
+ "GL_POST_CONVOLUTION_ALPHA_BIAS\0"
+ "GL_POST_CONVOLUTION_ALPHA_BIAS_EXT\0"
+ "GL_POST_CONVOLUTION_ALPHA_SCALE\0"
+ "GL_POST_CONVOLUTION_ALPHA_SCALE_EXT\0"
+ "GL_POST_CONVOLUTION_BLUE_BIAS\0"
+ "GL_POST_CONVOLUTION_BLUE_BIAS_EXT\0"
+ "GL_POST_CONVOLUTION_BLUE_SCALE\0"
+ "GL_POST_CONVOLUTION_BLUE_SCALE_EXT\0"
+ "GL_POST_CONVOLUTION_COLOR_TABLE\0"
+ "GL_POST_CONVOLUTION_GREEN_BIAS\0"
+ "GL_POST_CONVOLUTION_GREEN_BIAS_EXT\0"
+ "GL_POST_CONVOLUTION_GREEN_SCALE\0"
+ "GL_POST_CONVOLUTION_GREEN_SCALE_EXT\0"
+ "GL_POST_CONVOLUTION_RED_BIAS\0"
+ "GL_POST_CONVOLUTION_RED_BIAS_EXT\0"
+ "GL_POST_CONVOLUTION_RED_SCALE\0"
+ "GL_POST_CONVOLUTION_RED_SCALE_EXT\0"
+ "GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX\0"
+ "GL_POST_TEXTURE_FILTER_BIAS_SGIX\0"
+ "GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX\0"
+ "GL_POST_TEXTURE_FILTER_SCALE_SGIX\0"
+ "GL_PREVIOUS\0"
+ "GL_PREVIOUS_ARB\0"
+ "GL_PREVIOUS_EXT\0"
+ "GL_PRIMARY_COLOR\0"
+ "GL_PRIMARY_COLOR_ARB\0"
+ "GL_PRIMARY_COLOR_EXT\0"
+ "GL_PROGRAM_ADDRESS_REGISTERS_ARB\0"
+ "GL_PROGRAM_ALU_INSTRUCTIONS_ARB\0"
+ "GL_PROGRAM_ATTRIBS_ARB\0"
+ "GL_PROGRAM_BINDING_ARB\0"
+ "GL_PROGRAM_ERROR_POSITION_ARB\0"
+ "GL_PROGRAM_ERROR_POSITION_NV\0"
+ "GL_PROGRAM_ERROR_STRING_ARB\0"
+ "GL_PROGRAM_FORMAT_ARB\0"
+ "GL_PROGRAM_FORMAT_ASCII_ARB\0"
+ "GL_PROGRAM_INSTRUCTIONS_ARB\0"
+ "GL_PROGRAM_LENGTH_ARB\0"
+ "GL_PROGRAM_LENGTH_NV\0"
+ "GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB\0"
+ "GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB\0"
+ "GL_PROGRAM_NATIVE_ATTRIBS_ARB\0"
+ "GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB\0"
+ "GL_PROGRAM_NATIVE_PARAMETERS_ARB\0"
+ "GL_PROGRAM_NATIVE_TEMPORARIES_ARB\0"
+ "GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB\0"
+ "GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB\0"
+ "GL_PROGRAM_OBJECT_ARB\0"
+ "GL_PROGRAM_PARAMETERS_ARB\0"
+ "GL_PROGRAM_PARAMETER_NV\0"
+ "GL_PROGRAM_RESIDENT_NV\0"
+ "GL_PROGRAM_STRING_ARB\0"
+ "GL_PROGRAM_STRING_NV\0"
+ "GL_PROGRAM_TARGET_NV\0"
+ "GL_PROGRAM_TEMPORARIES_ARB\0"
+ "GL_PROGRAM_TEX_INDIRECTIONS_ARB\0"
+ "GL_PROGRAM_TEX_INSTRUCTIONS_ARB\0"
+ "GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB\0"
+ "GL_PROJECTION\0"
+ "GL_PROJECTION_MATRIX\0"
+ "GL_PROJECTION_STACK_DEPTH\0"
+ "GL_PROXY_COLOR_TABLE\0"
+ "GL_PROXY_HISTOGRAM\0"
+ "GL_PROXY_HISTOGRAM_EXT\0"
+ "GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE\0"
+ "GL_PROXY_POST_CONVOLUTION_COLOR_TABLE\0"
+ "GL_PROXY_TEXTURE_1D\0"
+ "GL_PROXY_TEXTURE_1D_EXT\0"
+ "GL_PROXY_TEXTURE_2D\0"
+ "GL_PROXY_TEXTURE_2D_EXT\0"
+ "GL_PROXY_TEXTURE_3D\0"
+ "GL_PROXY_TEXTURE_COLOR_TABLE_SGI\0"
+ "GL_PROXY_TEXTURE_CUBE_MAP\0"
+ "GL_PROXY_TEXTURE_CUBE_MAP_ARB\0"
+ "GL_PROXY_TEXTURE_RECTANGLE_ARB\0"
+ "GL_PROXY_TEXTURE_RECTANGLE_NV\0"
+ "GL_Q\0"
+ "GL_QUADRATIC_ATTENUATION\0"
+ "GL_QUADS\0"
+ "GL_QUAD_MESH_SUN\0"
+ "GL_QUAD_STRIP\0"
+ "GL_QUERY_COUNTER_BITS\0"
+ "GL_QUERY_COUNTER_BITS_ARB\0"
+ "GL_QUERY_RESULT\0"
+ "GL_QUERY_RESULT_ARB\0"
+ "GL_QUERY_RESULT_AVAILABLE\0"
+ "GL_QUERY_RESULT_AVAILABLE_ARB\0"
+ "GL_R\0"
+ "GL_R3_G3_B2\0"
+ "GL_RASTER_POSITION_UNCLIPPED_IBM\0"
+ "GL_READ_BUFFER\0"
+ "GL_READ_ONLY\0"
+ "GL_READ_ONLY_ARB\0"
+ "GL_READ_WRITE\0"
+ "GL_READ_WRITE_ARB\0"
+ "GL_RED\0"
+ "GL_REDUCE\0"
+ "GL_REDUCE_EXT\0"
+ "GL_RED_BIAS\0"
+ "GL_RED_BITS\0"
+ "GL_RED_SCALE\0"
+ "GL_REFLECTION_MAP\0"
+ "GL_REFLECTION_MAP_ARB\0"
+ "GL_REFLECTION_MAP_NV\0"
+ "GL_RENDER\0"
+ "GL_RENDERBUFFER_BINDING_EXT\0"
+ "GL_RENDERBUFFER_EXT\0"
+ "GL_RENDERBUFFER_HEIGHT_EXT\0"
+ "GL_RENDERBUFFER_INTERNAL_FORMAT_EXT\0"
+ "GL_RENDERBUFFER_WIDTH_EXT\0"
+ "GL_RENDERER\0"
+ "GL_RENDER_MODE\0"
+ "GL_REPEAT\0"
+ "GL_REPLACE\0"
+ "GL_REPLACE_EXT\0"
+ "GL_REPLICATE_BORDER_HP\0"
+ "GL_RESCALE_NORMAL\0"
+ "GL_RESCALE_NORMAL_EXT\0"
+ "GL_RETURN\0"
+ "GL_RGB\0"
+ "GL_RGB10\0"
+ "GL_RGB10_A2\0"
+ "GL_RGB10_A2_EXT\0"
+ "GL_RGB10_EXT\0"
+ "GL_RGB12\0"
+ "GL_RGB12_EXT\0"
+ "GL_RGB16\0"
+ "GL_RGB16_EXT\0"
+ "GL_RGB2_EXT\0"
+ "GL_RGB4\0"
+ "GL_RGB4_EXT\0"
+ "GL_RGB4_S3TC\0"
+ "GL_RGB5\0"
+ "GL_RGB5_A1\0"
+ "GL_RGB5_A1_EXT\0"
+ "GL_RGB5_EXT\0"
+ "GL_RGB8\0"
+ "GL_RGB8_EXT\0"
+ "GL_RGBA\0"
+ "GL_RGBA12\0"
+ "GL_RGBA12_EXT\0"
+ "GL_RGBA16\0"
+ "GL_RGBA16_EXT\0"
+ "GL_RGBA2\0"
+ "GL_RGBA2_EXT\0"
+ "GL_RGBA4\0"
+ "GL_RGBA4_DXT5_S3TC\0"
+ "GL_RGBA4_EXT\0"
+ "GL_RGBA4_S3TC\0"
+ "GL_RGBA8\0"
+ "GL_RGBA8_EXT\0"
+ "GL_RGBA_DXT5_S3TC\0"
+ "GL_RGBA_MODE\0"
+ "GL_RGBA_S3TC\0"
+ "GL_RGB_S3TC\0"
+ "GL_RGB_SCALE\0"
+ "GL_RGB_SCALE_ARB\0"
+ "GL_RGB_SCALE_EXT\0"
+ "GL_RIGHT\0"
+ "GL_S\0"
+ "GL_SAMPLES\0"
+ "GL_SAMPLES_3DFX\0"
+ "GL_SAMPLES_ARB\0"
+ "GL_SAMPLES_PASSED\0"
+ "GL_SAMPLES_PASSED_ARB\0"
+ "GL_SAMPLE_ALPHA_TO_COVERAGE\0"
+ "GL_SAMPLE_ALPHA_TO_COVERAGE_ARB\0"
+ "GL_SAMPLE_ALPHA_TO_ONE\0"
+ "GL_SAMPLE_ALPHA_TO_ONE_ARB\0"
+ "GL_SAMPLE_BUFFERS\0"
+ "GL_SAMPLE_BUFFERS_3DFX\0"
+ "GL_SAMPLE_BUFFERS_ARB\0"
+ "GL_SAMPLE_COVERAGE\0"
+ "GL_SAMPLE_COVERAGE_ARB\0"
+ "GL_SAMPLE_COVERAGE_INVERT\0"
+ "GL_SAMPLE_COVERAGE_INVERT_ARB\0"
+ "GL_SAMPLE_COVERAGE_VALUE\0"
+ "GL_SAMPLE_COVERAGE_VALUE_ARB\0"
+ "GL_SCISSOR_BIT\0"
+ "GL_SCISSOR_BOX\0"
+ "GL_SCISSOR_TEST\0"
+ "GL_SECONDARY_COLOR_ARRAY\0"
+ "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING\0"
+ "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB\0"
+ "GL_SECONDARY_COLOR_ARRAY_POINTER\0"
+ "GL_SECONDARY_COLOR_ARRAY_SIZE\0"
+ "GL_SECONDARY_COLOR_ARRAY_STRIDE\0"
+ "GL_SECONDARY_COLOR_ARRAY_TYPE\0"
+ "GL_SELECT\0"
+ "GL_SELECTION_BUFFER_POINTER\0"
+ "GL_SELECTION_BUFFER_SIZE\0"
+ "GL_SEPARABLE_2D\0"
+ "GL_SEPARATE_SPECULAR_COLOR\0"
+ "GL_SEPARATE_SPECULAR_COLOR_EXT\0"
+ "GL_SET\0"
+ "GL_SHADER_OBJECT_ARB\0"
+ "GL_SHADE_MODEL\0"
+ "GL_SHADOW_AMBIENT_SGIX\0"
+ "GL_SHARED_TEXTURE_PALETTE_EXT\0"
+ "GL_SHININESS\0"
+ "GL_SHORT\0"
+ "GL_SINGLE_COLOR\0"
+ "GL_SINGLE_COLOR_EXT\0"
+ "GL_SLICE_ACCUM_SUN\0"
+ "GL_SMOOTH\0"
+ "GL_SMOOTH_LINE_WIDTH_GRANULARITY\0"
+ "GL_SMOOTH_LINE_WIDTH_RANGE\0"
+ "GL_SMOOTH_POINT_SIZE_GRANULARITY\0"
+ "GL_SMOOTH_POINT_SIZE_RANGE\0"
+ "GL_SOURCE0_ALPHA\0"
+ "GL_SOURCE0_ALPHA_ARB\0"
+ "GL_SOURCE0_ALPHA_EXT\0"
+ "GL_SOURCE0_RGB\0"
+ "GL_SOURCE0_RGB_ARB\0"
+ "GL_SOURCE0_RGB_EXT\0"
+ "GL_SOURCE1_ALPHA\0"
+ "GL_SOURCE1_ALPHA_ARB\0"
+ "GL_SOURCE1_ALPHA_EXT\0"
+ "GL_SOURCE1_RGB\0"
+ "GL_SOURCE1_RGB_ARB\0"
+ "GL_SOURCE1_RGB_EXT\0"
+ "GL_SOURCE2_ALPHA\0"
+ "GL_SOURCE2_ALPHA_ARB\0"
+ "GL_SOURCE2_ALPHA_EXT\0"
+ "GL_SOURCE2_RGB\0"
+ "GL_SOURCE2_RGB_ARB\0"
+ "GL_SOURCE2_RGB_EXT\0"
+ "GL_SOURCE3_ALPHA_NV\0"
+ "GL_SOURCE3_RGB_NV\0"
+ "GL_SPECULAR\0"
+ "GL_SPHERE_MAP\0"
+ "GL_SPOT_CUTOFF\0"
+ "GL_SPOT_DIRECTION\0"
+ "GL_SPOT_EXPONENT\0"
+ "GL_SRC0_ALPHA\0"
+ "GL_SRC0_RGB\0"
+ "GL_SRC1_ALPHA\0"
+ "GL_SRC1_RGB\0"
+ "GL_SRC2_ALPHA\0"
+ "GL_SRC2_RGB\0"
+ "GL_SRC_ALPHA\0"
+ "GL_SRC_ALPHA_SATURATE\0"
+ "GL_SRC_COLOR\0"
+ "GL_STACK_OVERFLOW\0"
+ "GL_STACK_UNDERFLOW\0"
+ "GL_STATIC_COPY\0"
+ "GL_STATIC_COPY_ARB\0"
+ "GL_STATIC_DRAW\0"
+ "GL_STATIC_DRAW_ARB\0"
+ "GL_STATIC_READ\0"
+ "GL_STATIC_READ_ARB\0"
+ "GL_STENCIL\0"
+ "GL_STENCIL_ATTACHMENT_EXT\0"
+ "GL_STENCIL_BITS\0"
+ "GL_STENCIL_BUFFER_BIT\0"
+ "GL_STENCIL_CLEAR_VALUE\0"
+ "GL_STENCIL_FAIL\0"
+ "GL_STENCIL_FUNC\0"
+ "GL_STENCIL_INDEX\0"
+ "GL_STENCIL_INDEX16_EXT\0"
+ "GL_STENCIL_INDEX1_EXT\0"
+ "GL_STENCIL_INDEX4_EXT\0"
+ "GL_STENCIL_INDEX8_EXT\0"
+ "GL_STENCIL_INDEX_EXT\0"
+ "GL_STENCIL_PASS_DEPTH_FAIL\0"
+ "GL_STENCIL_PASS_DEPTH_PASS\0"
+ "GL_STENCIL_REF\0"
+ "GL_STENCIL_TEST\0"
+ "GL_STENCIL_TEST_TWO_SIDE_EXT\0"
+ "GL_STENCIL_VALUE_MASK\0"
+ "GL_STENCIL_WRITEMASK\0"
+ "GL_STEREO\0"
+ "GL_STREAM_COPY\0"
+ "GL_STREAM_COPY_ARB\0"
+ "GL_STREAM_DRAW\0"
+ "GL_STREAM_DRAW_ARB\0"
+ "GL_STREAM_READ\0"
+ "GL_STREAM_READ_ARB\0"
+ "GL_SUBPIXEL_BITS\0"
+ "GL_SUBTRACT\0"
+ "GL_SUBTRACT_ARB\0"
+ "GL_T\0"
+ "GL_T2F_C3F_V3F\0"
+ "GL_T2F_C4F_N3F_V3F\0"
+ "GL_T2F_C4UB_V3F\0"
+ "GL_T2F_N3F_V3F\0"
+ "GL_T2F_V3F\0"
+ "GL_T4F_C4F_N3F_V4F\0"
+ "GL_T4F_V4F\0"
+ "GL_TABLE_TOO_LARGE_EXT\0"
+ "GL_TEXTURE\0"
+ "GL_TEXTURE0\0"
+ "GL_TEXTURE0_ARB\0"
+ "GL_TEXTURE1\0"
+ "GL_TEXTURE10\0"
+ "GL_TEXTURE10_ARB\0"
+ "GL_TEXTURE11\0"
+ "GL_TEXTURE11_ARB\0"
+ "GL_TEXTURE12\0"
+ "GL_TEXTURE12_ARB\0"
+ "GL_TEXTURE13\0"
+ "GL_TEXTURE13_ARB\0"
+ "GL_TEXTURE14\0"
+ "GL_TEXTURE14_ARB\0"
+ "GL_TEXTURE15\0"
+ "GL_TEXTURE15_ARB\0"
+ "GL_TEXTURE16\0"
+ "GL_TEXTURE16_ARB\0"
+ "GL_TEXTURE17\0"
+ "GL_TEXTURE17_ARB\0"
+ "GL_TEXTURE18\0"
+ "GL_TEXTURE18_ARB\0"
+ "GL_TEXTURE19\0"
+ "GL_TEXTURE19_ARB\0"
+ "GL_TEXTURE1_ARB\0"
+ "GL_TEXTURE2\0"
+ "GL_TEXTURE20\0"
+ "GL_TEXTURE20_ARB\0"
+ "GL_TEXTURE21\0"
+ "GL_TEXTURE21_ARB\0"
+ "GL_TEXTURE22\0"
+ "GL_TEXTURE22_ARB\0"
+ "GL_TEXTURE23\0"
+ "GL_TEXTURE23_ARB\0"
+ "GL_TEXTURE24\0"
+ "GL_TEXTURE24_ARB\0"
+ "GL_TEXTURE25\0"
+ "GL_TEXTURE25_ARB\0"
+ "GL_TEXTURE26\0"
+ "GL_TEXTURE26_ARB\0"
+ "GL_TEXTURE27\0"
+ "GL_TEXTURE27_ARB\0"
+ "GL_TEXTURE28\0"
+ "GL_TEXTURE28_ARB\0"
+ "GL_TEXTURE29\0"
+ "GL_TEXTURE29_ARB\0"
+ "GL_TEXTURE2_ARB\0"
+ "GL_TEXTURE3\0"
+ "GL_TEXTURE30\0"
+ "GL_TEXTURE30_ARB\0"
+ "GL_TEXTURE31\0"
+ "GL_TEXTURE31_ARB\0"
+ "GL_TEXTURE3_ARB\0"
+ "GL_TEXTURE4\0"
+ "GL_TEXTURE4_ARB\0"
+ "GL_TEXTURE5\0"
+ "GL_TEXTURE5_ARB\0"
+ "GL_TEXTURE6\0"
+ "GL_TEXTURE6_ARB\0"
+ "GL_TEXTURE7\0"
+ "GL_TEXTURE7_ARB\0"
+ "GL_TEXTURE8\0"
+ "GL_TEXTURE8_ARB\0"
+ "GL_TEXTURE9\0"
+ "GL_TEXTURE9_ARB\0"
+ "GL_TEXTURE_1D\0"
+ "GL_TEXTURE_2D\0"
+ "GL_TEXTURE_3D\0"
+ "GL_TEXTURE_ALPHA_SIZE\0"
+ "GL_TEXTURE_ALPHA_SIZE_EXT\0"
+ "GL_TEXTURE_BASE_LEVEL\0"
+ "GL_TEXTURE_BINDING_1D\0"
+ "GL_TEXTURE_BINDING_2D\0"
+ "GL_TEXTURE_BINDING_3D\0"
+ "GL_TEXTURE_BINDING_CUBE_MAP\0"
+ "GL_TEXTURE_BINDING_CUBE_MAP_ARB\0"
+ "GL_TEXTURE_BINDING_RECTANGLE_ARB\0"
+ "GL_TEXTURE_BINDING_RECTANGLE_NV\0"
+ "GL_TEXTURE_BIT\0"
+ "GL_TEXTURE_BLUE_SIZE\0"
+ "GL_TEXTURE_BLUE_SIZE_EXT\0"
+ "GL_TEXTURE_BORDER\0"
+ "GL_TEXTURE_BORDER_COLOR\0"
+ "GL_TEXTURE_CLIPMAP_CENTER_SGIX\0"
+ "GL_TEXTURE_CLIPMAP_DEPTH_SGIX\0"
+ "GL_TEXTURE_CLIPMAP_FRAME_SGIX\0"
+ "GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX\0"
+ "GL_TEXTURE_CLIPMAP_OFFSET_SGIX\0"
+ "GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX\0"
+ "GL_TEXTURE_COLOR_TABLE_SGI\0"
+ "GL_TEXTURE_COLOR_WRITEMASK_SGIS\0"
+ "GL_TEXTURE_COMPARE_FAIL_VALUE_ARB\0"
+ "GL_TEXTURE_COMPARE_FUNC\0"
+ "GL_TEXTURE_COMPARE_FUNC_ARB\0"
+ "GL_TEXTURE_COMPARE_MODE\0"
+ "GL_TEXTURE_COMPARE_MODE_ARB\0"
+ "GL_TEXTURE_COMPARE_OPERATOR_SGIX\0"
+ "GL_TEXTURE_COMPARE_SGIX\0"
+ "GL_TEXTURE_COMPONENTS\0"
+ "GL_TEXTURE_COMPRESSED\0"
+ "GL_TEXTURE_COMPRESSED_ARB\0"
+ "GL_TEXTURE_COMPRESSED_FORMATS_ARB\0"
+ "GL_TEXTURE_COMPRESSED_IMAGE_SIZE\0"
+ "GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB\0"
+ "GL_TEXTURE_COMPRESSION_HINT\0"
+ "GL_TEXTURE_COMPRESSION_HINT_ARB\0"
+ "GL_TEXTURE_COORD_ARRAY\0"
+ "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING\0"
+ "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB\0"
+ "GL_TEXTURE_COORD_ARRAY_POINTER\0"
+ "GL_TEXTURE_COORD_ARRAY_SIZE\0"
+ "GL_TEXTURE_COORD_ARRAY_STRIDE\0"
+ "GL_TEXTURE_COORD_ARRAY_TYPE\0"
+ "GL_TEXTURE_CUBE_MAP\0"
+ "GL_TEXTURE_CUBE_MAP_ARB\0"
+ "GL_TEXTURE_CUBE_MAP_NEGATIVE_X\0"
+ "GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB\0"
+ "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y\0"
+ "GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB\0"
+ "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z\0"
+ "GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB\0"
+ "GL_TEXTURE_CUBE_MAP_POSITIVE_X\0"
+ "GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB\0"
+ "GL_TEXTURE_CUBE_MAP_POSITIVE_Y\0"
+ "GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB\0"
+ "GL_TEXTURE_CUBE_MAP_POSITIVE_Z\0"
+ "GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB\0"
+ "GL_TEXTURE_DEPTH\0"
+ "GL_TEXTURE_DEPTH_SIZE\0"
+ "GL_TEXTURE_DEPTH_SIZE_ARB\0"
+ "GL_TEXTURE_ENV\0"
+ "GL_TEXTURE_ENV_COLOR\0"
+ "GL_TEXTURE_ENV_MODE\0"
+ "GL_TEXTURE_FILTER_CONTROL\0"
+ "GL_TEXTURE_GEN_MODE\0"
+ "GL_TEXTURE_GEN_Q\0"
+ "GL_TEXTURE_GEN_R\0"
+ "GL_TEXTURE_GEN_S\0"
+ "GL_TEXTURE_GEN_T\0"
+ "GL_TEXTURE_GEQUAL_R_SGIX\0"
+ "GL_TEXTURE_GREEN_SIZE\0"
+ "GL_TEXTURE_GREEN_SIZE_EXT\0"
+ "GL_TEXTURE_HEIGHT\0"
+ "GL_TEXTURE_INDEX_SIZE_EXT\0"
+ "GL_TEXTURE_INTENSITY_SIZE\0"
+ "GL_TEXTURE_INTENSITY_SIZE_EXT\0"
+ "GL_TEXTURE_INTERNAL_FORMAT\0"
+ "GL_TEXTURE_LEQUAL_R_SGIX\0"
+ "GL_TEXTURE_LOD_BIAS\0"
+ "GL_TEXTURE_LOD_BIAS_EXT\0"
+ "GL_TEXTURE_LOD_BIAS_R_SGIX\0"
+ "GL_TEXTURE_LOD_BIAS_S_SGIX\0"
+ "GL_TEXTURE_LOD_BIAS_T_SGIX\0"
+ "GL_TEXTURE_LUMINANCE_SIZE\0"
+ "GL_TEXTURE_LUMINANCE_SIZE_EXT\0"
+ "GL_TEXTURE_MAG_FILTER\0"
+ "GL_TEXTURE_MATRIX\0"
+ "GL_TEXTURE_MAX_ANISOTROPY_EXT\0"
+ "GL_TEXTURE_MAX_CLAMP_R_SGIX\0"
+ "GL_TEXTURE_MAX_CLAMP_S_SGIX\0"
+ "GL_TEXTURE_MAX_CLAMP_T_SGIX\0"
+ "GL_TEXTURE_MAX_LEVEL\0"
+ "GL_TEXTURE_MAX_LOD\0"
+ "GL_TEXTURE_MIN_FILTER\0"
+ "GL_TEXTURE_MIN_LOD\0"
+ "GL_TEXTURE_PRIORITY\0"
+ "GL_TEXTURE_RECTANGLE_ARB\0"
+ "GL_TEXTURE_RECTANGLE_NV\0"
+ "GL_TEXTURE_RED_SIZE\0"
+ "GL_TEXTURE_RED_SIZE_EXT\0"
+ "GL_TEXTURE_RESIDENT\0"
+ "GL_TEXTURE_STACK_DEPTH\0"
+ "GL_TEXTURE_TOO_LARGE_EXT\0"
+ "GL_TEXTURE_UNSIGNED_REMAP_MODE_NV\0"
+ "GL_TEXTURE_WIDTH\0"
+ "GL_TEXTURE_WRAP_R\0"
+ "GL_TEXTURE_WRAP_S\0"
+ "GL_TEXTURE_WRAP_T\0"
+ "GL_TRACK_MATRIX_NV\0"
+ "GL_TRACK_MATRIX_TRANSFORM_NV\0"
+ "GL_TRANSFORM_BIT\0"
+ "GL_TRANSPOSE_COLOR_MATRIX\0"
+ "GL_TRANSPOSE_COLOR_MATRIX_ARB\0"
+ "GL_TRANSPOSE_CURRENT_MATRIX_ARB\0"
+ "GL_TRANSPOSE_MODELVIEW_MATRIX\0"
+ "GL_TRANSPOSE_MODELVIEW_MATRIX_ARB\0"
+ "GL_TRANSPOSE_NV\0"
+ "GL_TRANSPOSE_PROJECTION_MATRIX\0"
+ "GL_TRANSPOSE_PROJECTION_MATRIX_ARB\0"
+ "GL_TRANSPOSE_TEXTURE_MATRIX\0"
+ "GL_TRANSPOSE_TEXTURE_MATRIX_ARB\0"
+ "GL_TRIANGLES\0"
+ "GL_TRIANGLE_FAN\0"
+ "GL_TRIANGLE_MESH_SUN\0"
+ "GL_TRIANGLE_STRIP\0"
+ "GL_TRUE\0"
+ "GL_UNPACK_ALIGNMENT\0"
+ "GL_UNPACK_IMAGE_HEIGHT\0"
+ "GL_UNPACK_LSB_FIRST\0"
+ "GL_UNPACK_ROW_LENGTH\0"
+ "GL_UNPACK_SKIP_IMAGES\0"
+ "GL_UNPACK_SKIP_PIXELS\0"
+ "GL_UNPACK_SKIP_ROWS\0"
+ "GL_UNPACK_SWAP_BYTES\0"
+ "GL_UNSIGNED_BYTE\0"
+ "GL_UNSIGNED_BYTE_2_3_3_REV\0"
+ "GL_UNSIGNED_BYTE_3_3_2\0"
+ "GL_UNSIGNED_INT\0"
+ "GL_UNSIGNED_INT_10_10_10_2\0"
+ "GL_UNSIGNED_INT_24_8_NV\0"
+ "GL_UNSIGNED_INT_2_10_10_10_REV\0"
+ "GL_UNSIGNED_INT_8_8_8_8\0"
+ "GL_UNSIGNED_INT_8_8_8_8_REV\0"
+ "GL_UNSIGNED_SHORT\0"
+ "GL_UNSIGNED_SHORT_1_5_5_5_REV\0"
+ "GL_UNSIGNED_SHORT_4_4_4_4\0"
+ "GL_UNSIGNED_SHORT_4_4_4_4_REV\0"
+ "GL_UNSIGNED_SHORT_5_5_5_1\0"
+ "GL_UNSIGNED_SHORT_5_6_5\0"
+ "GL_UNSIGNED_SHORT_5_6_5_REV\0"
+ "GL_UNSIGNED_SHORT_8_8_APPLE\0"
+ "GL_UNSIGNED_SHORT_8_8_MESA\0"
+ "GL_UNSIGNED_SHORT_8_8_REV_APPLE\0"
+ "GL_UNSIGNED_SHORT_8_8_REV_MESA\0"
+ "GL_V2F\0"
+ "GL_V3F\0"
+ "GL_VENDOR\0"
+ "GL_VERSION\0"
+ "GL_VERTEX_ARRAY\0"
+ "GL_VERTEX_ARRAY_BUFFER_BINDING\0"
+ "GL_VERTEX_ARRAY_BUFFER_BINDING_ARB\0"
+ "GL_VERTEX_ARRAY_POINTER\0"
+ "GL_VERTEX_ARRAY_SIZE\0"
+ "GL_VERTEX_ARRAY_STRIDE\0"
+ "GL_VERTEX_ARRAY_TYPE\0"
+ "GL_VERTEX_ATTRIB_ARRAY0_NV\0"
+ "GL_VERTEX_ATTRIB_ARRAY10_NV\0"
+ "GL_VERTEX_ATTRIB_ARRAY11_NV\0"
+ "GL_VERTEX_ATTRIB_ARRAY12_NV\0"
+ "GL_VERTEX_ATTRIB_ARRAY13_NV\0"
+ "GL_VERTEX_ATTRIB_ARRAY14_NV\0"
+ "GL_VERTEX_ATTRIB_ARRAY15_NV\0"
+ "GL_VERTEX_ATTRIB_ARRAY1_NV\0"
+ "GL_VERTEX_ATTRIB_ARRAY2_NV\0"
+ "GL_VERTEX_ATTRIB_ARRAY3_NV\0"
+ "GL_VERTEX_ATTRIB_ARRAY4_NV\0"
+ "GL_VERTEX_ATTRIB_ARRAY5_NV\0"
+ "GL_VERTEX_ATTRIB_ARRAY6_NV\0"
+ "GL_VERTEX_ATTRIB_ARRAY7_NV\0"
+ "GL_VERTEX_ATTRIB_ARRAY8_NV\0"
+ "GL_VERTEX_ATTRIB_ARRAY9_NV\0"
+ "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING\0"
+ "GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB\0"
+ "GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB\0"
+ "GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB\0"
+ "GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB\0"
+ "GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB\0"
+ "GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB\0"
+ "GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB\0"
+ "GL_VERTEX_BLEND_ARB\0"
+ "GL_VERTEX_PROGRAM_ARB\0"
+ "GL_VERTEX_PROGRAM_BINDING_NV\0"
+ "GL_VERTEX_PROGRAM_NV\0"
+ "GL_VERTEX_PROGRAM_POINT_SIZE_ARB\0"
+ "GL_VERTEX_PROGRAM_POINT_SIZE_NV\0"
+ "GL_VERTEX_PROGRAM_TWO_SIDE_ARB\0"
+ "GL_VERTEX_PROGRAM_TWO_SIDE_NV\0"
+ "GL_VERTEX_SHADER_ARB\0"
+ "GL_VERTEX_STATE_PROGRAM_NV\0"
+ "GL_VIEWPORT\0"
+ "GL_VIEWPORT_BIT\0"
+ "GL_WEIGHT_ARRAY_ARB\0"
+ "GL_WEIGHT_ARRAY_BUFFER_BINDING\0"
+ "GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB\0"
+ "GL_WEIGHT_ARRAY_POINTER_ARB\0"
+ "GL_WEIGHT_ARRAY_SIZE_ARB\0"
+ "GL_WEIGHT_ARRAY_STRIDE_ARB\0"
+ "GL_WEIGHT_ARRAY_TYPE_ARB\0"
+ "GL_WEIGHT_SUM_UNITY_ARB\0"
+ "GL_WRAP_BORDER_SUN\0"
+ "GL_WRITE_ONLY\0"
+ "GL_WRITE_ONLY_ARB\0"
+ "GL_XOR\0"
+ "GL_YCBCR_422_APPLE\0"
+ "GL_YCBCR_MESA\0"
+ "GL_ZERO\0"
+ "GL_ZOOM_X\0"
+ "GL_ZOOM_Y\0"
+ ;
+
+static const enum_elt all_enums[1612] =
+{
+ { 0, 0x00000600 }, /* GL_2D */
+ { 6, 0x00001407 }, /* GL_2_BYTES */
+ { 17, 0x00000601 }, /* GL_3D */
+ { 23, 0x00000602 }, /* GL_3D_COLOR */
+ { 35, 0x00000603 }, /* GL_3D_COLOR_TEXTURE */
+ { 55, 0x00001408 }, /* GL_3_BYTES */
+ { 66, 0x00000604 }, /* GL_4D_COLOR_TEXTURE */
+ { 86, 0x00001409 }, /* GL_4_BYTES */
+ { 97, 0x00000100 }, /* GL_ACCUM */
+ { 106, 0x00000D5B }, /* GL_ACCUM_ALPHA_BITS */
+ { 126, 0x00000D5A }, /* GL_ACCUM_BLUE_BITS */
+ { 145, 0x00000200 }, /* GL_ACCUM_BUFFER_BIT */
+ { 165, 0x00000B80 }, /* GL_ACCUM_CLEAR_VALUE */
+ { 186, 0x00000D59 }, /* GL_ACCUM_GREEN_BITS */
+ { 206, 0x00000D58 }, /* GL_ACCUM_RED_BITS */
+ { 224, 0x00008911 }, /* GL_ACTIVE_STENCIL_FACE_EXT */
+ { 251, 0x000084E0 }, /* GL_ACTIVE_TEXTURE */
+ { 269, 0x000084E0 }, /* GL_ACTIVE_TEXTURE_ARB */
+ { 291, 0x000086A5 }, /* GL_ACTIVE_VERTEX_UNITS_ARB */
+ { 318, 0x00000104 }, /* GL_ADD */
+ { 325, 0x00008574 }, /* GL_ADD_SIGNED */
+ { 339, 0x00008574 }, /* GL_ADD_SIGNED_ARB */
+ { 357, 0x00008574 }, /* GL_ADD_SIGNED_EXT */
+ { 375, 0x0000846E }, /* GL_ALIASED_LINE_WIDTH_RANGE */
+ { 403, 0x0000846D }, /* GL_ALIASED_POINT_SIZE_RANGE */
+ { 431, 0x000FFFFF }, /* GL_ALL_ATTRIB_BITS */
+ { 450, 0xFFFFFFFF }, /* GL_ALL_CLIENT_ATTRIB_BITS */
+ { 476, 0x00001906 }, /* GL_ALPHA */
+ { 485, 0x0000803D }, /* GL_ALPHA12 */
+ { 496, 0x0000803D }, /* GL_ALPHA12_EXT */
+ { 511, 0x0000803E }, /* GL_ALPHA16 */
+ { 522, 0x0000803E }, /* GL_ALPHA16_EXT */
+ { 537, 0x0000803B }, /* GL_ALPHA4 */
+ { 547, 0x0000803B }, /* GL_ALPHA4_EXT */
+ { 561, 0x0000803C }, /* GL_ALPHA8 */
+ { 571, 0x0000803C }, /* GL_ALPHA8_EXT */
+ { 585, 0x00000D1D }, /* GL_ALPHA_BIAS */
+ { 599, 0x00000D55 }, /* GL_ALPHA_BITS */
+ { 613, 0x00000D1C }, /* GL_ALPHA_SCALE */
+ { 628, 0x00000BC0 }, /* GL_ALPHA_TEST */
+ { 642, 0x00000BC1 }, /* GL_ALPHA_TEST_FUNC */
+ { 661, 0x00000BC2 }, /* GL_ALPHA_TEST_REF */
+ { 679, 0x00000207 }, /* GL_ALWAYS */
+ { 689, 0x00001200 }, /* GL_AMBIENT */
+ { 700, 0x00001602 }, /* GL_AMBIENT_AND_DIFFUSE */
+ { 723, 0x00001501 }, /* GL_AND */
+ { 730, 0x00001504 }, /* GL_AND_INVERTED */
+ { 746, 0x00001502 }, /* GL_AND_REVERSE */
+ { 761, 0x00008892 }, /* GL_ARRAY_BUFFER */
+ { 777, 0x00008892 }, /* GL_ARRAY_BUFFER_ARB */
+ { 797, 0x00008894 }, /* GL_ARRAY_BUFFER_BINDING */
+ { 821, 0x00008894 }, /* GL_ARRAY_BUFFER_BINDING_ARB */
+ { 849, 0x00008645 }, /* GL_ATTRIB_ARRAY_POINTER_NV */
+ { 876, 0x00008623 }, /* GL_ATTRIB_ARRAY_SIZE_NV */
+ { 900, 0x00008624 }, /* GL_ATTRIB_ARRAY_STRIDE_NV */
+ { 926, 0x00008625 }, /* GL_ATTRIB_ARRAY_TYPE_NV */
+ { 950, 0x00000BB0 }, /* GL_ATTRIB_STACK_DEPTH */
+ { 972, 0x00000D80 }, /* GL_AUTO_NORMAL */
+ { 987, 0x00000409 }, /* GL_AUX0 */
+ { 995, 0x0000040A }, /* GL_AUX1 */
+ { 1003, 0x0000040B }, /* GL_AUX2 */
+ { 1011, 0x0000040C }, /* GL_AUX3 */
+ { 1019, 0x00000C00 }, /* GL_AUX_BUFFERS */
+ { 1034, 0x00000405 }, /* GL_BACK */
+ { 1042, 0x00000402 }, /* GL_BACK_LEFT */
+ { 1055, 0x00000403 }, /* GL_BACK_RIGHT */
+ { 1069, 0x000080E0 }, /* GL_BGR */
+ { 1076, 0x000080E1 }, /* GL_BGRA */
+ { 1084, 0x00001A00 }, /* GL_BITMAP */
+ { 1094, 0x00000704 }, /* GL_BITMAP_TOKEN */
+ { 1110, 0x00000BE2 }, /* GL_BLEND */
+ { 1119, 0x00008005 }, /* GL_BLEND_COLOR */
+ { 1134, 0x00008005 }, /* GL_BLEND_COLOR_EXT */
+ { 1153, 0x00000BE0 }, /* GL_BLEND_DST */
+ { 1166, 0x000080CA }, /* GL_BLEND_DST_ALPHA */
+ { 1185, 0x000080C8 }, /* GL_BLEND_DST_RGB */
+ { 1202, 0x00008009 }, /* GL_BLEND_EQUATION */
+ { 1220, 0x0000883D }, /* GL_BLEND_EQUATION_ALPHA_EXT */
+ { 1248, 0x00008009 }, /* GL_BLEND_EQUATION_EXT */
+ { 1270, 0x00008009 }, /* GL_BLEND_EQUATION_RGB_EXT */
+ { 1296, 0x00000BE1 }, /* GL_BLEND_SRC */
+ { 1309, 0x000080CB }, /* GL_BLEND_SRC_ALPHA */
+ { 1328, 0x000080C9 }, /* GL_BLEND_SRC_RGB */
+ { 1345, 0x00001905 }, /* GL_BLUE */
+ { 1353, 0x00000D1B }, /* GL_BLUE_BIAS */
+ { 1366, 0x00000D54 }, /* GL_BLUE_BITS */
+ { 1379, 0x00000D1A }, /* GL_BLUE_SCALE */
+ { 1393, 0x00008B56 }, /* GL_BOOL_ARB */
+ { 1405, 0x00008B57 }, /* GL_BOOL_VEC2_ARB */
+ { 1422, 0x00008B58 }, /* GL_BOOL_VEC3_ARB */
+ { 1439, 0x00008B59 }, /* GL_BOOL_VEC4_ARB */
+ { 1456, 0x000088BB }, /* GL_BUFFER_ACCESS */
+ { 1473, 0x000088BB }, /* GL_BUFFER_ACCESS_ARB */
+ { 1494, 0x000088BC }, /* GL_BUFFER_MAPPED */
+ { 1511, 0x000088BC }, /* GL_BUFFER_MAPPED_ARB */
+ { 1532, 0x000088BD }, /* GL_BUFFER_MAP_POINTER */
+ { 1554, 0x000088BD }, /* GL_BUFFER_MAP_POINTER_ARB */
+ { 1580, 0x00008764 }, /* GL_BUFFER_SIZE */
+ { 1595, 0x00008764 }, /* GL_BUFFER_SIZE_ARB */
+ { 1614, 0x00008765 }, /* GL_BUFFER_USAGE */
+ { 1630, 0x00008765 }, /* GL_BUFFER_USAGE_ARB */
+ { 1650, 0x00001400 }, /* GL_BYTE */
+ { 1658, 0x00002A24 }, /* GL_C3F_V3F */
+ { 1669, 0x00002A26 }, /* GL_C4F_N3F_V3F */
+ { 1684, 0x00002A22 }, /* GL_C4UB_V2F */
+ { 1696, 0x00002A23 }, /* GL_C4UB_V3F */
+ { 1708, 0x00000901 }, /* GL_CCW */
+ { 1715, 0x00002900 }, /* GL_CLAMP */
+ { 1724, 0x0000812D }, /* GL_CLAMP_TO_BORDER */
+ { 1743, 0x0000812D }, /* GL_CLAMP_TO_BORDER_ARB */
+ { 1766, 0x0000812D }, /* GL_CLAMP_TO_BORDER_SGIS */
+ { 1790, 0x0000812F }, /* GL_CLAMP_TO_EDGE */
+ { 1807, 0x0000812F }, /* GL_CLAMP_TO_EDGE_SGIS */
+ { 1829, 0x00001500 }, /* GL_CLEAR */
+ { 1838, 0x000084E1 }, /* GL_CLIENT_ACTIVE_TEXTURE */
+ { 1863, 0x000084E1 }, /* GL_CLIENT_ACTIVE_TEXTURE_ARB */
+ { 1892, 0xFFFFFFFF }, /* GL_CLIENT_ALL_ATTRIB_BITS */
+ { 1918, 0x00000BB1 }, /* GL_CLIENT_ATTRIB_STACK_DEPTH */
+ { 1947, 0x00000001 }, /* GL_CLIENT_PIXEL_STORE_BIT */
+ { 1973, 0x00000002 }, /* GL_CLIENT_VERTEX_ARRAY_BIT */
+ { 2000, 0x00003000 }, /* GL_CLIP_PLANE0 */
+ { 2015, 0x00003001 }, /* GL_CLIP_PLANE1 */
+ { 2030, 0x00003002 }, /* GL_CLIP_PLANE2 */
+ { 2045, 0x00003003 }, /* GL_CLIP_PLANE3 */
+ { 2060, 0x00003004 }, /* GL_CLIP_PLANE4 */
+ { 2075, 0x00003005 }, /* GL_CLIP_PLANE5 */
+ { 2090, 0x000080F0 }, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */
+ { 2123, 0x00000A00 }, /* GL_COEFF */
+ { 2132, 0x00001800 }, /* GL_COLOR */
+ { 2141, 0x00008076 }, /* GL_COLOR_ARRAY */
+ { 2156, 0x00008898 }, /* GL_COLOR_ARRAY_BUFFER_BINDING */
+ { 2186, 0x00008898 }, /* GL_COLOR_ARRAY_BUFFER_BINDING_ARB */
+ { 2220, 0x00008090 }, /* GL_COLOR_ARRAY_POINTER */
+ { 2243, 0x00008081 }, /* GL_COLOR_ARRAY_SIZE */
+ { 2263, 0x00008083 }, /* GL_COLOR_ARRAY_STRIDE */
+ { 2285, 0x00008082 }, /* GL_COLOR_ARRAY_TYPE */
+ { 2305, 0x00008CE0 }, /* GL_COLOR_ATTACHMENT0_EXT */
+ { 2330, 0x00008CEA }, /* GL_COLOR_ATTACHMENT10_EXT */
+ { 2356, 0x00008CEB }, /* GL_COLOR_ATTACHMENT11_EXT */
+ { 2382, 0x00008CEC }, /* GL_COLOR_ATTACHMENT12_EXT */
+ { 2408, 0x00008CED }, /* GL_COLOR_ATTACHMENT13_EXT */
+ { 2434, 0x00008CEE }, /* GL_COLOR_ATTACHMENT14_EXT */
+ { 2460, 0x00008CEF }, /* GL_COLOR_ATTACHMENT15_EXT */
+ { 2486, 0x00008CE1 }, /* GL_COLOR_ATTACHMENT1_EXT */
+ { 2511, 0x00008CE2 }, /* GL_COLOR_ATTACHMENT2_EXT */
+ { 2536, 0x00008CE3 }, /* GL_COLOR_ATTACHMENT3_EXT */
+ { 2561, 0x00008CE4 }, /* GL_COLOR_ATTACHMENT4_EXT */
+ { 2586, 0x00008CE5 }, /* GL_COLOR_ATTACHMENT5_EXT */
+ { 2611, 0x00008CE6 }, /* GL_COLOR_ATTACHMENT6_EXT */
+ { 2636, 0x00008CE7 }, /* GL_COLOR_ATTACHMENT7_EXT */
+ { 2661, 0x00008CE8 }, /* GL_COLOR_ATTACHMENT8_EXT */
+ { 2686, 0x00008CE9 }, /* GL_COLOR_ATTACHMENT9_EXT */
+ { 2711, 0x00004000 }, /* GL_COLOR_BUFFER_BIT */
+ { 2731, 0x00000C22 }, /* GL_COLOR_CLEAR_VALUE */
+ { 2752, 0x00001900 }, /* GL_COLOR_INDEX */
+ { 2767, 0x00001603 }, /* GL_COLOR_INDEXES */
+ { 2784, 0x00000BF2 }, /* GL_COLOR_LOGIC_OP */
+ { 2802, 0x00000B57 }, /* GL_COLOR_MATERIAL */
+ { 2820, 0x00000B55 }, /* GL_COLOR_MATERIAL_FACE */
+ { 2843, 0x00000B56 }, /* GL_COLOR_MATERIAL_PARAMETER */
+ { 2871, 0x000080B1 }, /* GL_COLOR_MATRIX */
+ { 2887, 0x000080B1 }, /* GL_COLOR_MATRIX_SGI */
+ { 2907, 0x000080B2 }, /* GL_COLOR_MATRIX_STACK_DEPTH */
+ { 2935, 0x000080B2 }, /* GL_COLOR_MATRIX_STACK_DEPTH_SGI */
+ { 2967, 0x00008458 }, /* GL_COLOR_SUM */
+ { 2980, 0x00008458 }, /* GL_COLOR_SUM_ARB */
+ { 2997, 0x000080D0 }, /* GL_COLOR_TABLE */
+ { 3012, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE */
+ { 3038, 0x000080DD }, /* GL_COLOR_TABLE_ALPHA_SIZE_EXT */
+ { 3068, 0x000080D7 }, /* GL_COLOR_TABLE_BIAS */
+ { 3088, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE */
+ { 3113, 0x000080DC }, /* GL_COLOR_TABLE_BLUE_SIZE_EXT */
+ { 3142, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT */
+ { 3164, 0x000080D8 }, /* GL_COLOR_TABLE_FORMAT_EXT */
+ { 3190, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE */
+ { 3216, 0x000080DB }, /* GL_COLOR_TABLE_GREEN_SIZE_EXT */
+ { 3246, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE */
+ { 3276, 0x000080DF }, /* GL_COLOR_TABLE_INTENSITY_SIZE_EXT */
+ { 3310, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE */
+ { 3340, 0x000080DE }, /* GL_COLOR_TABLE_LUMINANCE_SIZE_EXT */
+ { 3374, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE */
+ { 3398, 0x000080DA }, /* GL_COLOR_TABLE_RED_SIZE_EXT */
+ { 3426, 0x000080D6 }, /* GL_COLOR_TABLE_SCALE */
+ { 3447, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH */
+ { 3468, 0x000080D9 }, /* GL_COLOR_TABLE_WIDTH_EXT */
+ { 3493, 0x00000C23 }, /* GL_COLOR_WRITEMASK */
+ { 3512, 0x00008570 }, /* GL_COMBINE */
+ { 3523, 0x00008503 }, /* GL_COMBINE4 */
+ { 3535, 0x00008572 }, /* GL_COMBINE_ALPHA */
+ { 3552, 0x00008572 }, /* GL_COMBINE_ALPHA_ARB */
+ { 3573, 0x00008572 }, /* GL_COMBINE_ALPHA_EXT */
+ { 3594, 0x00008570 }, /* GL_COMBINE_ARB */
+ { 3609, 0x00008570 }, /* GL_COMBINE_EXT */
+ { 3624, 0x00008571 }, /* GL_COMBINE_RGB */
+ { 3639, 0x00008571 }, /* GL_COMBINE_RGB_ARB */
+ { 3658, 0x00008571 }, /* GL_COMBINE_RGB_EXT */
+ { 3677, 0x0000884E }, /* GL_COMPARE_R_TO_TEXTURE */
+ { 3701, 0x0000884E }, /* GL_COMPARE_R_TO_TEXTURE_ARB */
+ { 3729, 0x00001300 }, /* GL_COMPILE */
+ { 3740, 0x00001301 }, /* GL_COMPILE_AND_EXECUTE */
+ { 3763, 0x000084E9 }, /* GL_COMPRESSED_ALPHA */
+ { 3783, 0x000084E9 }, /* GL_COMPRESSED_ALPHA_ARB */
+ { 3807, 0x000084EC }, /* GL_COMPRESSED_INTENSITY */
+ { 3831, 0x000084EC }, /* GL_COMPRESSED_INTENSITY_ARB */
+ { 3859, 0x000084EA }, /* GL_COMPRESSED_LUMINANCE */
+ { 3883, 0x000084EB }, /* GL_COMPRESSED_LUMINANCE_ALPHA */
+ { 3913, 0x000084EB }, /* GL_COMPRESSED_LUMINANCE_ALPHA_ARB */
+ { 3947, 0x000084EA }, /* GL_COMPRESSED_LUMINANCE_ARB */
+ { 3975, 0x000084ED }, /* GL_COMPRESSED_RGB */
+ { 3993, 0x000084EE }, /* GL_COMPRESSED_RGBA */
+ { 4012, 0x000084EE }, /* GL_COMPRESSED_RGBA_ARB */
+ { 4035, 0x000086B1 }, /* GL_COMPRESSED_RGBA_FXT1_3DFX */
+ { 4064, 0x000083F1 }, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */
+ { 4097, 0x000083F2 }, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */
+ { 4130, 0x000083F3 }, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */
+ { 4163, 0x000084ED }, /* GL_COMPRESSED_RGB_ARB */
+ { 4185, 0x000086B0 }, /* GL_COMPRESSED_RGB_FXT1_3DFX */
+ { 4213, 0x000083F0 }, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */
+ { 4245, 0x000086A3 }, /* GL_COMPRESSED_TEXTURE_FORMATS */
+ { 4275, 0x00008576 }, /* GL_CONSTANT */
+ { 4287, 0x00008003 }, /* GL_CONSTANT_ALPHA */
+ { 4305, 0x00008003 }, /* GL_CONSTANT_ALPHA_EXT */
+ { 4327, 0x00008576 }, /* GL_CONSTANT_ARB */
+ { 4343, 0x00001207 }, /* GL_CONSTANT_ATTENUATION */
+ { 4367, 0x00008151 }, /* GL_CONSTANT_BORDER_HP */
+ { 4389, 0x00008001 }, /* GL_CONSTANT_COLOR */
+ { 4407, 0x00008001 }, /* GL_CONSTANT_COLOR_EXT */
+ { 4429, 0x00008576 }, /* GL_CONSTANT_EXT */
+ { 4445, 0x00008010 }, /* GL_CONVOLUTION_1D */
+ { 4463, 0x00008011 }, /* GL_CONVOLUTION_2D */
+ { 4481, 0x00008154 }, /* GL_CONVOLUTION_BORDER_COLOR */
+ { 4509, 0x00008154 }, /* GL_CONVOLUTION_BORDER_COLOR_HP */
+ { 4540, 0x00008013 }, /* GL_CONVOLUTION_BORDER_MODE */
+ { 4567, 0x00008013 }, /* GL_CONVOLUTION_BORDER_MODE_EXT */
+ { 4598, 0x00008015 }, /* GL_CONVOLUTION_FILTER_BIAS */
+ { 4625, 0x00008015 }, /* GL_CONVOLUTION_FILTER_BIAS_EXT */
+ { 4656, 0x00008014 }, /* GL_CONVOLUTION_FILTER_SCALE */
+ { 4684, 0x00008014 }, /* GL_CONVOLUTION_FILTER_SCALE_EXT */
+ { 4716, 0x00008017 }, /* GL_CONVOLUTION_FORMAT */
+ { 4738, 0x00008017 }, /* GL_CONVOLUTION_FORMAT_EXT */
+ { 4764, 0x00008019 }, /* GL_CONVOLUTION_HEIGHT */
+ { 4786, 0x00008019 }, /* GL_CONVOLUTION_HEIGHT_EXT */
+ { 4812, 0x00008018 }, /* GL_CONVOLUTION_WIDTH */
+ { 4833, 0x00008018 }, /* GL_CONVOLUTION_WIDTH_EXT */
+ { 4858, 0x00008862 }, /* GL_COORD_REPLACE_ARB */
+ { 4879, 0x00008862 }, /* GL_COORD_REPLACE_NV */
+ { 4899, 0x00001503 }, /* GL_COPY */
+ { 4907, 0x0000150C }, /* GL_COPY_INVERTED */
+ { 4924, 0x00000706 }, /* GL_COPY_PIXEL_TOKEN */
+ { 4944, 0x00000B44 }, /* GL_CULL_FACE */
+ { 4957, 0x00000B45 }, /* GL_CULL_FACE_MODE */
+ { 4975, 0x000081AA }, /* GL_CULL_VERTEX_EXT */
+ { 4994, 0x000081AC }, /* GL_CULL_VERTEX_EYE_POSITION_EXT */
+ { 5026, 0x000081AB }, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */
+ { 5061, 0x00008626 }, /* GL_CURRENT_ATTRIB_NV */
+ { 5082, 0x00000001 }, /* GL_CURRENT_BIT */
+ { 5097, 0x00000B00 }, /* GL_CURRENT_COLOR */
+ { 5114, 0x00008453 }, /* GL_CURRENT_FOG_COORD */
+ { 5135, 0x00008453 }, /* GL_CURRENT_FOG_COORDINATE */
+ { 5161, 0x00000B01 }, /* GL_CURRENT_INDEX */
+ { 5178, 0x00008641 }, /* GL_CURRENT_MATRIX_ARB */
+ { 5200, 0x00008845 }, /* GL_CURRENT_MATRIX_INDEX_ARB */
+ { 5228, 0x00008641 }, /* GL_CURRENT_MATRIX_NV */
+ { 5249, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */
+ { 5283, 0x00008640 }, /* GL_CURRENT_MATRIX_STACK_DEPTH_NV */
+ { 5316, 0x00000B02 }, /* GL_CURRENT_NORMAL */
+ { 5334, 0x00008843 }, /* GL_CURRENT_PALETTE_MATRIX_ARB */
+ { 5364, 0x00008865 }, /* GL_CURRENT_QUERY */
+ { 5381, 0x00008865 }, /* GL_CURRENT_QUERY_ARB */
+ { 5402, 0x00000B04 }, /* GL_CURRENT_RASTER_COLOR */
+ { 5426, 0x00000B09 }, /* GL_CURRENT_RASTER_DISTANCE */
+ { 5453, 0x00000B05 }, /* GL_CURRENT_RASTER_INDEX */
+ { 5477, 0x00000B07 }, /* GL_CURRENT_RASTER_POSITION */
+ { 5504, 0x00000B08 }, /* GL_CURRENT_RASTER_POSITION_VALID */
+ { 5537, 0x00000B06 }, /* GL_CURRENT_RASTER_TEXTURE_COORDS */
+ { 5570, 0x00008459 }, /* GL_CURRENT_SECONDARY_COLOR */
+ { 5597, 0x00000B03 }, /* GL_CURRENT_TEXTURE_COORDS */
+ { 5623, 0x00008626 }, /* GL_CURRENT_VERTEX_ATTRIB_ARB */
+ { 5652, 0x000086A8 }, /* GL_CURRENT_WEIGHT_ARB */
+ { 5674, 0x00000900 }, /* GL_CW */
+ { 5680, 0x00002101 }, /* GL_DECAL */
+ { 5689, 0x00001E03 }, /* GL_DECR */
+ { 5697, 0x00008508 }, /* GL_DECR_WRAP */
+ { 5710, 0x00008508 }, /* GL_DECR_WRAP_EXT */
+ { 5727, 0x00001801 }, /* GL_DEPTH */
+ { 5736, 0x00008D00 }, /* GL_DEPTH_ATTACHMENT_EXT */
+ { 5760, 0x00000D1F }, /* GL_DEPTH_BIAS */
+ { 5774, 0x00000D56 }, /* GL_DEPTH_BITS */
+ { 5788, 0x00008891 }, /* GL_DEPTH_BOUNDS_EXT */
+ { 5808, 0x00008890 }, /* GL_DEPTH_BOUNDS_TEST_EXT */
+ { 5833, 0x00000100 }, /* GL_DEPTH_BUFFER_BIT */
+ { 5853, 0x0000864F }, /* GL_DEPTH_CLAMP_NV */
+ { 5871, 0x00000B73 }, /* GL_DEPTH_CLEAR_VALUE */
+ { 5892, 0x00001902 }, /* GL_DEPTH_COMPONENT */
+ { 5911, 0x000081A5 }, /* GL_DEPTH_COMPONENT16 */
+ { 5932, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_ARB */
+ { 5957, 0x000081A5 }, /* GL_DEPTH_COMPONENT16_SGIX */
+ { 5983, 0x000081A6 }, /* GL_DEPTH_COMPONENT24 */
+ { 6004, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_ARB */
+ { 6029, 0x000081A6 }, /* GL_DEPTH_COMPONENT24_SGIX */
+ { 6055, 0x000081A7 }, /* GL_DEPTH_COMPONENT32 */
+ { 6076, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_ARB */
+ { 6101, 0x000081A7 }, /* GL_DEPTH_COMPONENT32_SGIX */
+ { 6127, 0x00000B74 }, /* GL_DEPTH_FUNC */
+ { 6141, 0x00000B70 }, /* GL_DEPTH_RANGE */
+ { 6156, 0x00000D1E }, /* GL_DEPTH_SCALE */
+ { 6171, 0x000084F9 }, /* GL_DEPTH_STENCIL_NV */
+ { 6191, 0x0000886F }, /* GL_DEPTH_STENCIL_TO_BGRA_NV */
+ { 6219, 0x0000886E }, /* GL_DEPTH_STENCIL_TO_RGBA_NV */
+ { 6247, 0x00000B71 }, /* GL_DEPTH_TEST */
+ { 6261, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE */
+ { 6283, 0x0000884B }, /* GL_DEPTH_TEXTURE_MODE_ARB */
+ { 6309, 0x00000B72 }, /* GL_DEPTH_WRITEMASK */
+ { 6328, 0x00001201 }, /* GL_DIFFUSE */
+ { 6339, 0x00000BD0 }, /* GL_DITHER */
+ { 6349, 0x00000A02 }, /* GL_DOMAIN */
+ { 6359, 0x00001100 }, /* GL_DONT_CARE */
+ { 6372, 0x000086AE }, /* GL_DOT3_RGB */
+ { 6384, 0x000086AF }, /* GL_DOT3_RGBA */
+ { 6397, 0x000086AF }, /* GL_DOT3_RGBA_ARB */
+ { 6414, 0x00008741 }, /* GL_DOT3_RGBA_EXT */
+ { 6431, 0x000086AE }, /* GL_DOT3_RGB_ARB */
+ { 6447, 0x00008740 }, /* GL_DOT3_RGB_EXT */
+ { 6463, 0x0000140A }, /* GL_DOUBLE */
+ { 6473, 0x00000C32 }, /* GL_DOUBLEBUFFER */
+ { 6489, 0x00000C01 }, /* GL_DRAW_BUFFER */
+ { 6504, 0x00008825 }, /* GL_DRAW_BUFFER0_ARB */
+ { 6524, 0x00008825 }, /* GL_DRAW_BUFFER0_ATI */
+ { 6544, 0x0000882F }, /* GL_DRAW_BUFFER10_ARB */
+ { 6565, 0x0000882F }, /* GL_DRAW_BUFFER10_ATI */
+ { 6586, 0x00008830 }, /* GL_DRAW_BUFFER11_ARB */
+ { 6607, 0x00008830 }, /* GL_DRAW_BUFFER11_ATI */
+ { 6628, 0x00008831 }, /* GL_DRAW_BUFFER12_ARB */
+ { 6649, 0x00008831 }, /* GL_DRAW_BUFFER12_ATI */
+ { 6670, 0x00008832 }, /* GL_DRAW_BUFFER13_ARB */
+ { 6691, 0x00008832 }, /* GL_DRAW_BUFFER13_ATI */
+ { 6712, 0x00008833 }, /* GL_DRAW_BUFFER14_ARB */
+ { 6733, 0x00008833 }, /* GL_DRAW_BUFFER14_ATI */
+ { 6754, 0x00008834 }, /* GL_DRAW_BUFFER15_ARB */
+ { 6775, 0x00008834 }, /* GL_DRAW_BUFFER15_ATI */
+ { 6796, 0x00008826 }, /* GL_DRAW_BUFFER1_ARB */
+ { 6816, 0x00008826 }, /* GL_DRAW_BUFFER1_ATI */
+ { 6836, 0x00008827 }, /* GL_DRAW_BUFFER2_ARB */
+ { 6856, 0x00008827 }, /* GL_DRAW_BUFFER2_ATI */
+ { 6876, 0x00008828 }, /* GL_DRAW_BUFFER3_ARB */
+ { 6896, 0x00008828 }, /* GL_DRAW_BUFFER3_ATI */
+ { 6916, 0x00008829 }, /* GL_DRAW_BUFFER4_ARB */
+ { 6936, 0x00008829 }, /* GL_DRAW_BUFFER4_ATI */
+ { 6956, 0x0000882A }, /* GL_DRAW_BUFFER5_ARB */
+ { 6976, 0x0000882A }, /* GL_DRAW_BUFFER5_ATI */
+ { 6996, 0x0000882B }, /* GL_DRAW_BUFFER6_ARB */
+ { 7016, 0x0000882B }, /* GL_DRAW_BUFFER6_ATI */
+ { 7036, 0x0000882C }, /* GL_DRAW_BUFFER7_ARB */
+ { 7056, 0x0000882C }, /* GL_DRAW_BUFFER7_ATI */
+ { 7076, 0x0000882D }, /* GL_DRAW_BUFFER8_ARB */
+ { 7096, 0x0000882D }, /* GL_DRAW_BUFFER8_ATI */
+ { 7116, 0x0000882E }, /* GL_DRAW_BUFFER9_ARB */
+ { 7136, 0x0000882E }, /* GL_DRAW_BUFFER9_ATI */
+ { 7156, 0x00000705 }, /* GL_DRAW_PIXEL_TOKEN */
+ { 7176, 0x00000304 }, /* GL_DST_ALPHA */
+ { 7189, 0x00000306 }, /* GL_DST_COLOR */
+ { 7202, 0x000088EA }, /* GL_DYNAMIC_COPY */
+ { 7218, 0x000088EA }, /* GL_DYNAMIC_COPY_ARB */
+ { 7238, 0x000088E8 }, /* GL_DYNAMIC_DRAW */
+ { 7254, 0x000088E8 }, /* GL_DYNAMIC_DRAW_ARB */
+ { 7274, 0x000088E9 }, /* GL_DYNAMIC_READ */
+ { 7290, 0x000088E9 }, /* GL_DYNAMIC_READ_ARB */
+ { 7310, 0x00000B43 }, /* GL_EDGE_FLAG */
+ { 7323, 0x00008079 }, /* GL_EDGE_FLAG_ARRAY */
+ { 7342, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */
+ { 7376, 0x0000889B }, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB */
+ { 7414, 0x00008093 }, /* GL_EDGE_FLAG_ARRAY_POINTER */
+ { 7441, 0x0000808C }, /* GL_EDGE_FLAG_ARRAY_STRIDE */
+ { 7467, 0x00008893 }, /* GL_ELEMENT_ARRAY_BUFFER */
+ { 7491, 0x00008893 }, /* GL_ELEMENT_ARRAY_BUFFER_ARB */
+ { 7519, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */
+ { 7551, 0x00008895 }, /* GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB */
+ { 7587, 0x00001600 }, /* GL_EMISSION */
+ { 7599, 0x00002000 }, /* GL_ENABLE_BIT */
+ { 7613, 0x00000202 }, /* GL_EQUAL */
+ { 7622, 0x00001509 }, /* GL_EQUIV */
+ { 7631, 0x00010000 }, /* GL_EVAL_BIT */
+ { 7643, 0x00000800 }, /* GL_EXP */
+ { 7650, 0x00000801 }, /* GL_EXP2 */
+ { 7658, 0x00001F03 }, /* GL_EXTENSIONS */
+ { 7672, 0x00002400 }, /* GL_EYE_LINEAR */
+ { 7686, 0x00002502 }, /* GL_EYE_PLANE */
+ { 7699, 0x0000855C }, /* GL_EYE_PLANE_ABSOLUTE_NV */
+ { 7724, 0x0000855B }, /* GL_EYE_RADIAL_NV */
+ { 7741, 0x00000000 }, /* GL_FALSE */
+ { 7750, 0x00001101 }, /* GL_FASTEST */
+ { 7761, 0x00001C01 }, /* GL_FEEDBACK */
+ { 7773, 0x00000DF0 }, /* GL_FEEDBACK_BUFFER_POINTER */
+ { 7800, 0x00000DF1 }, /* GL_FEEDBACK_BUFFER_SIZE */
+ { 7824, 0x00000DF2 }, /* GL_FEEDBACK_BUFFER_TYPE */
+ { 7848, 0x00001B02 }, /* GL_FILL */
+ { 7856, 0x00001D00 }, /* GL_FLAT */
+ { 7864, 0x00001406 }, /* GL_FLOAT */
+ { 7873, 0x00008B5A }, /* GL_FLOAT_MAT2_ARB */
+ { 7891, 0x00008B5B }, /* GL_FLOAT_MAT3_ARB */
+ { 7909, 0x00008B5C }, /* GL_FLOAT_MAT4_ARB */
+ { 7927, 0x00008B50 }, /* GL_FLOAT_VEC2_ARB */
+ { 7945, 0x00008B51 }, /* GL_FLOAT_VEC3_ARB */
+ { 7963, 0x00008B52 }, /* GL_FLOAT_VEC4_ARB */
+ { 7981, 0x00000B60 }, /* GL_FOG */
+ { 7988, 0x00000080 }, /* GL_FOG_BIT */
+ { 7999, 0x00000B66 }, /* GL_FOG_COLOR */
+ { 8012, 0x00008451 }, /* GL_FOG_COORD */
+ { 8025, 0x00008451 }, /* GL_FOG_COORDINATE */
+ { 8043, 0x00008457 }, /* GL_FOG_COORDINATE_ARRAY */
+ { 8067, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */
+ { 8106, 0x0000889D }, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB */
+ { 8149, 0x00008456 }, /* GL_FOG_COORDINATE_ARRAY_POINTER */
+ { 8181, 0x00008455 }, /* GL_FOG_COORDINATE_ARRAY_STRIDE */
+ { 8212, 0x00008454 }, /* GL_FOG_COORDINATE_ARRAY_TYPE */
+ { 8241, 0x00008450 }, /* GL_FOG_COORDINATE_SOURCE */
+ { 8266, 0x00008457 }, /* GL_FOG_COORD_ARRAY */
+ { 8285, 0x0000889D }, /* GL_FOG_COORD_ARRAY_BUFFER_BINDING */
+ { 8319, 0x00008456 }, /* GL_FOG_COORD_ARRAY_POINTER */
+ { 8346, 0x00008455 }, /* GL_FOG_COORD_ARRAY_STRIDE */
+ { 8372, 0x00008454 }, /* GL_FOG_COORD_ARRAY_TYPE */
+ { 8396, 0x00008450 }, /* GL_FOG_COORD_SOURCE */
+ { 8416, 0x00000B62 }, /* GL_FOG_DENSITY */
+ { 8431, 0x0000855A }, /* GL_FOG_DISTANCE_MODE_NV */
+ { 8455, 0x00000B64 }, /* GL_FOG_END */
+ { 8466, 0x00000C54 }, /* GL_FOG_HINT */
+ { 8478, 0x00000B61 }, /* GL_FOG_INDEX */
+ { 8491, 0x00000B65 }, /* GL_FOG_MODE */
+ { 8503, 0x00008198 }, /* GL_FOG_OFFSET_SGIX */
+ { 8522, 0x00008199 }, /* GL_FOG_OFFSET_VALUE_SGIX */
+ { 8547, 0x00000B63 }, /* GL_FOG_START */
+ { 8560, 0x00008452 }, /* GL_FRAGMENT_DEPTH */
+ { 8578, 0x00008804 }, /* GL_FRAGMENT_PROGRAM_ARB */
+ { 8602, 0x00008B30 }, /* GL_FRAGMENT_SHADER_ARB */
+ { 8625, 0x00008CD1 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT */
+ { 8667, 0x00008CD0 }, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT */
+ { 8709, 0x00008CD4 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT */
+ { 8758, 0x00008CD3 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT */
+ { 8810, 0x00008CD2 }, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT */
+ { 8854, 0x00008CA6 }, /* GL_FRAMEBUFFER_BINDING_EXT */
+ { 8881, 0x00008CD5 }, /* GL_FRAMEBUFFER_COMPLETE_EXT */
+ { 8909, 0x00008D40 }, /* GL_FRAMEBUFFER_EXT */
+ { 8928, 0x00008CD6 }, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT */
+ { 8969, 0x00008CD9 }, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */
+ { 9010, 0x00008CDB }, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */
+ { 9052, 0x00008CD8 }, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */
+ { 9103, 0x00008CDA }, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */
+ { 9141, 0x00008CD7 }, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT */
+ { 9190, 0x00008CDC }, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */
+ { 9232, 0x00008CDE }, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */
+ { 9264, 0x00008CDD }, /* GL_FRAMEBUFFER_UNSUPPORTED_EXT */
+ { 9295, 0x00000404 }, /* GL_FRONT */
+ { 9304, 0x00000408 }, /* GL_FRONT_AND_BACK */
+ { 9322, 0x00000B46 }, /* GL_FRONT_FACE */
+ { 9336, 0x00000400 }, /* GL_FRONT_LEFT */
+ { 9350, 0x00000401 }, /* GL_FRONT_RIGHT */
+ { 9365, 0x00008006 }, /* GL_FUNC_ADD */
+ { 9377, 0x00008006 }, /* GL_FUNC_ADD_EXT */
+ { 9393, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT */
+ { 9418, 0x0000800B }, /* GL_FUNC_REVERSE_SUBTRACT_EXT */
+ { 9447, 0x0000800A }, /* GL_FUNC_SUBTRACT */
+ { 9464, 0x0000800A }, /* GL_FUNC_SUBTRACT_EXT */
+ { 9485, 0x00008191 }, /* GL_GENERATE_MIPMAP */
+ { 9504, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT */
+ { 9528, 0x00008192 }, /* GL_GENERATE_MIPMAP_HINT_SGIS */
+ { 9557, 0x00008191 }, /* GL_GENERATE_MIPMAP_SGIS */
+ { 9581, 0x00000206 }, /* GL_GEQUAL */
+ { 9591, 0x00000204 }, /* GL_GREATER */
+ { 9602, 0x00001904 }, /* GL_GREEN */
+ { 9611, 0x00000D19 }, /* GL_GREEN_BIAS */
+ { 9625, 0x00000D53 }, /* GL_GREEN_BITS */
+ { 9639, 0x00000D18 }, /* GL_GREEN_SCALE */
+ { 9654, 0x00008000 }, /* GL_HINT_BIT */
+ { 9666, 0x00008024 }, /* GL_HISTOGRAM */
+ { 9679, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE */
+ { 9703, 0x0000802B }, /* GL_HISTOGRAM_ALPHA_SIZE_EXT */
+ { 9731, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE */
+ { 9754, 0x0000802A }, /* GL_HISTOGRAM_BLUE_SIZE_EXT */
+ { 9781, 0x00008024 }, /* GL_HISTOGRAM_EXT */
+ { 9798, 0x00008027 }, /* GL_HISTOGRAM_FORMAT */
+ { 9818, 0x00008027 }, /* GL_HISTOGRAM_FORMAT_EXT */
+ { 9842, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE */
+ { 9866, 0x00008029 }, /* GL_HISTOGRAM_GREEN_SIZE_EXT */
+ { 9894, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE */
+ { 9922, 0x0000802C }, /* GL_HISTOGRAM_LUMINANCE_SIZE_EXT */
+ { 9954, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE */
+ { 9976, 0x00008028 }, /* GL_HISTOGRAM_RED_SIZE_EXT */
+ { 10002, 0x0000802D }, /* GL_HISTOGRAM_SINK */
+ { 10020, 0x0000802D }, /* GL_HISTOGRAM_SINK_EXT */
+ { 10042, 0x00008026 }, /* GL_HISTOGRAM_WIDTH */
+ { 10061, 0x00008026 }, /* GL_HISTOGRAM_WIDTH_EXT */
+ { 10084, 0x0000862A }, /* GL_IDENTITY_NV */
+ { 10099, 0x00008150 }, /* GL_IGNORE_BORDER_HP */
+ { 10119, 0x00008B9B }, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */
+ { 10159, 0x00008B9A }, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */
+ { 10197, 0x00001E02 }, /* GL_INCR */
+ { 10205, 0x00008507 }, /* GL_INCR_WRAP */
+ { 10218, 0x00008507 }, /* GL_INCR_WRAP_EXT */
+ { 10235, 0x00008077 }, /* GL_INDEX_ARRAY */
+ { 10250, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING */
+ { 10280, 0x00008899 }, /* GL_INDEX_ARRAY_BUFFER_BINDING_ARB */
+ { 10314, 0x00008091 }, /* GL_INDEX_ARRAY_POINTER */
+ { 10337, 0x00008086 }, /* GL_INDEX_ARRAY_STRIDE */
+ { 10359, 0x00008085 }, /* GL_INDEX_ARRAY_TYPE */
+ { 10379, 0x00000D51 }, /* GL_INDEX_BITS */
+ { 10393, 0x00000C20 }, /* GL_INDEX_CLEAR_VALUE */
+ { 10414, 0x00000BF1 }, /* GL_INDEX_LOGIC_OP */
+ { 10432, 0x00000C30 }, /* GL_INDEX_MODE */
+ { 10446, 0x00000D13 }, /* GL_INDEX_OFFSET */
+ { 10462, 0x00000D12 }, /* GL_INDEX_SHIFT */
+ { 10477, 0x00000C21 }, /* GL_INDEX_WRITEMASK */
+ { 10496, 0x00001404 }, /* GL_INT */
+ { 10503, 0x00008049 }, /* GL_INTENSITY */
+ { 10516, 0x0000804C }, /* GL_INTENSITY12 */
+ { 10531, 0x0000804C }, /* GL_INTENSITY12_EXT */
+ { 10550, 0x0000804D }, /* GL_INTENSITY16 */
+ { 10565, 0x0000804D }, /* GL_INTENSITY16_EXT */
+ { 10584, 0x0000804A }, /* GL_INTENSITY4 */
+ { 10598, 0x0000804A }, /* GL_INTENSITY4_EXT */
+ { 10616, 0x0000804B }, /* GL_INTENSITY8 */
+ { 10630, 0x0000804B }, /* GL_INTENSITY8_EXT */
+ { 10648, 0x00008049 }, /* GL_INTENSITY_EXT */
+ { 10665, 0x00008575 }, /* GL_INTERPOLATE */
+ { 10680, 0x00008575 }, /* GL_INTERPOLATE_ARB */
+ { 10699, 0x00008575 }, /* GL_INTERPOLATE_EXT */
+ { 10718, 0x00008B53 }, /* GL_INT_VEC2_ARB */
+ { 10734, 0x00008B54 }, /* GL_INT_VEC3_ARB */
+ { 10750, 0x00008B55 }, /* GL_INT_VEC4_ARB */
+ { 10766, 0x00000500 }, /* GL_INVALID_ENUM */
+ { 10782, 0x00000506 }, /* GL_INVALID_FRAMEBUFFER_OPERATION_EXT */
+ { 10819, 0x00000502 }, /* GL_INVALID_OPERATION */
+ { 10840, 0x00000501 }, /* GL_INVALID_VALUE */
+ { 10857, 0x0000862B }, /* GL_INVERSE_NV */
+ { 10871, 0x0000862D }, /* GL_INVERSE_TRANSPOSE_NV */
+ { 10895, 0x0000150A }, /* GL_INVERT */
+ { 10905, 0x00001E00 }, /* GL_KEEP */
+ { 10913, 0x00000406 }, /* GL_LEFT */
+ { 10921, 0x00000203 }, /* GL_LEQUAL */
+ { 10931, 0x00000201 }, /* GL_LESS */
+ { 10939, 0x00004000 }, /* GL_LIGHT0 */
+ { 10949, 0x00004001 }, /* GL_LIGHT1 */
+ { 10959, 0x00004002 }, /* GL_LIGHT2 */
+ { 10969, 0x00004003 }, /* GL_LIGHT3 */
+ { 10979, 0x00004004 }, /* GL_LIGHT4 */
+ { 10989, 0x00004005 }, /* GL_LIGHT5 */
+ { 10999, 0x00004006 }, /* GL_LIGHT6 */
+ { 11009, 0x00004007 }, /* GL_LIGHT7 */
+ { 11019, 0x00000B50 }, /* GL_LIGHTING */
+ { 11031, 0x00000040 }, /* GL_LIGHTING_BIT */
+ { 11047, 0x00000B53 }, /* GL_LIGHT_MODEL_AMBIENT */
+ { 11070, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL */
+ { 11099, 0x000081F8 }, /* GL_LIGHT_MODEL_COLOR_CONTROL_EXT */
+ { 11132, 0x00000B51 }, /* GL_LIGHT_MODEL_LOCAL_VIEWER */
+ { 11160, 0x00000B52 }, /* GL_LIGHT_MODEL_TWO_SIDE */
+ { 11184, 0x00001B01 }, /* GL_LINE */
+ { 11192, 0x00002601 }, /* GL_LINEAR */
+ { 11202, 0x00001208 }, /* GL_LINEAR_ATTENUATION */
+ { 11224, 0x00008170 }, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */
+ { 11254, 0x0000844F }, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */
+ { 11285, 0x00002703 }, /* GL_LINEAR_MIPMAP_LINEAR */
+ { 11309, 0x00002701 }, /* GL_LINEAR_MIPMAP_NEAREST */
+ { 11334, 0x00000001 }, /* GL_LINES */
+ { 11343, 0x00000004 }, /* GL_LINE_BIT */
+ { 11355, 0x00000002 }, /* GL_LINE_LOOP */
+ { 11368, 0x00000707 }, /* GL_LINE_RESET_TOKEN */
+ { 11388, 0x00000B20 }, /* GL_LINE_SMOOTH */
+ { 11403, 0x00000C52 }, /* GL_LINE_SMOOTH_HINT */
+ { 11423, 0x00000B24 }, /* GL_LINE_STIPPLE */
+ { 11439, 0x00000B25 }, /* GL_LINE_STIPPLE_PATTERN */
+ { 11463, 0x00000B26 }, /* GL_LINE_STIPPLE_REPEAT */
+ { 11486, 0x00000003 }, /* GL_LINE_STRIP */
+ { 11500, 0x00000702 }, /* GL_LINE_TOKEN */
+ { 11514, 0x00000B21 }, /* GL_LINE_WIDTH */
+ { 11528, 0x00000B23 }, /* GL_LINE_WIDTH_GRANULARITY */
+ { 11554, 0x00000B22 }, /* GL_LINE_WIDTH_RANGE */
+ { 11574, 0x00000B32 }, /* GL_LIST_BASE */
+ { 11587, 0x00020000 }, /* GL_LIST_BIT */
+ { 11599, 0x00000B33 }, /* GL_LIST_INDEX */
+ { 11613, 0x00000B30 }, /* GL_LIST_MODE */
+ { 11626, 0x00000101 }, /* GL_LOAD */
+ { 11634, 0x00000BF1 }, /* GL_LOGIC_OP */
+ { 11646, 0x00000BF0 }, /* GL_LOGIC_OP_MODE */
+ { 11663, 0x00001909 }, /* GL_LUMINANCE */
+ { 11676, 0x00008041 }, /* GL_LUMINANCE12 */
+ { 11691, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12 */
+ { 11714, 0x00008047 }, /* GL_LUMINANCE12_ALPHA12_EXT */
+ { 11741, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4 */
+ { 11763, 0x00008046 }, /* GL_LUMINANCE12_ALPHA4_EXT */
+ { 11789, 0x00008041 }, /* GL_LUMINANCE12_EXT */
+ { 11808, 0x00008042 }, /* GL_LUMINANCE16 */
+ { 11823, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16 */
+ { 11846, 0x00008048 }, /* GL_LUMINANCE16_ALPHA16_EXT */
+ { 11873, 0x00008042 }, /* GL_LUMINANCE16_EXT */
+ { 11892, 0x0000803F }, /* GL_LUMINANCE4 */
+ { 11906, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4 */
+ { 11927, 0x00008043 }, /* GL_LUMINANCE4_ALPHA4_EXT */
+ { 11952, 0x0000803F }, /* GL_LUMINANCE4_EXT */
+ { 11970, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2 */
+ { 11991, 0x00008044 }, /* GL_LUMINANCE6_ALPHA2_EXT */
+ { 12016, 0x00008040 }, /* GL_LUMINANCE8 */
+ { 12030, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8 */
+ { 12051, 0x00008045 }, /* GL_LUMINANCE8_ALPHA8_EXT */
+ { 12076, 0x00008040 }, /* GL_LUMINANCE8_EXT */
+ { 12094, 0x0000190A }, /* GL_LUMINANCE_ALPHA */
+ { 12113, 0x00000D90 }, /* GL_MAP1_COLOR_4 */
+ { 12129, 0x00000DD0 }, /* GL_MAP1_GRID_DOMAIN */
+ { 12149, 0x00000DD1 }, /* GL_MAP1_GRID_SEGMENTS */
+ { 12171, 0x00000D91 }, /* GL_MAP1_INDEX */
+ { 12185, 0x00000D92 }, /* GL_MAP1_NORMAL */
+ { 12200, 0x00000D93 }, /* GL_MAP1_TEXTURE_COORD_1 */
+ { 12224, 0x00000D94 }, /* GL_MAP1_TEXTURE_COORD_2 */
+ { 12248, 0x00000D95 }, /* GL_MAP1_TEXTURE_COORD_3 */
+ { 12272, 0x00000D96 }, /* GL_MAP1_TEXTURE_COORD_4 */
+ { 12296, 0x00000D97 }, /* GL_MAP1_VERTEX_3 */
+ { 12313, 0x00000D98 }, /* GL_MAP1_VERTEX_4 */
+ { 12330, 0x00008660 }, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */
+ { 12358, 0x0000866A }, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */
+ { 12387, 0x0000866B }, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */
+ { 12416, 0x0000866C }, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */
+ { 12445, 0x0000866D }, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */
+ { 12474, 0x0000866E }, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */
+ { 12503, 0x0000866F }, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */
+ { 12532, 0x00008661 }, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */
+ { 12560, 0x00008662 }, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */
+ { 12588, 0x00008663 }, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */
+ { 12616, 0x00008664 }, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */
+ { 12644, 0x00008665 }, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */
+ { 12672, 0x00008666 }, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */
+ { 12700, 0x00008667 }, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */
+ { 12728, 0x00008668 }, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */
+ { 12756, 0x00008669 }, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */
+ { 12784, 0x00000DB0 }, /* GL_MAP2_COLOR_4 */
+ { 12800, 0x00000DD2 }, /* GL_MAP2_GRID_DOMAIN */
+ { 12820, 0x00000DD3 }, /* GL_MAP2_GRID_SEGMENTS */
+ { 12842, 0x00000DB1 }, /* GL_MAP2_INDEX */
+ { 12856, 0x00000DB2 }, /* GL_MAP2_NORMAL */
+ { 12871, 0x00000DB3 }, /* GL_MAP2_TEXTURE_COORD_1 */
+ { 12895, 0x00000DB4 }, /* GL_MAP2_TEXTURE_COORD_2 */
+ { 12919, 0x00000DB5 }, /* GL_MAP2_TEXTURE_COORD_3 */
+ { 12943, 0x00000DB6 }, /* GL_MAP2_TEXTURE_COORD_4 */
+ { 12967, 0x00000DB7 }, /* GL_MAP2_VERTEX_3 */
+ { 12984, 0x00000DB8 }, /* GL_MAP2_VERTEX_4 */
+ { 13001, 0x00008670 }, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */
+ { 13029, 0x0000867A }, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */
+ { 13058, 0x0000867B }, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */
+ { 13087, 0x0000867C }, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */
+ { 13116, 0x0000867D }, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */
+ { 13145, 0x0000867E }, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */
+ { 13174, 0x0000867F }, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */
+ { 13203, 0x00008671 }, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */
+ { 13231, 0x00008672 }, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */
+ { 13259, 0x00008673 }, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */
+ { 13287, 0x00008674 }, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */
+ { 13315, 0x00008675 }, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */
+ { 13343, 0x00008676 }, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */
+ { 13371, 0x00008677 }, /* GL_MAP2_VERTEX_ATTRIB7_4_NV */
+ { 13399, 0x00008678 }, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */
+ { 13427, 0x00008679 }, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */
+ { 13455, 0x00000D10 }, /* GL_MAP_COLOR */
+ { 13468, 0x00000D11 }, /* GL_MAP_STENCIL */
+ { 13483, 0x000088C0 }, /* GL_MATRIX0_ARB */
+ { 13498, 0x00008630 }, /* GL_MATRIX0_NV */
+ { 13512, 0x000088CA }, /* GL_MATRIX10_ARB */
+ { 13528, 0x000088CB }, /* GL_MATRIX11_ARB */
+ { 13544, 0x000088CC }, /* GL_MATRIX12_ARB */
+ { 13560, 0x000088CD }, /* GL_MATRIX13_ARB */
+ { 13576, 0x000088CE }, /* GL_MATRIX14_ARB */
+ { 13592, 0x000088CF }, /* GL_MATRIX15_ARB */
+ { 13608, 0x000088D0 }, /* GL_MATRIX16_ARB */
+ { 13624, 0x000088D1 }, /* GL_MATRIX17_ARB */
+ { 13640, 0x000088D2 }, /* GL_MATRIX18_ARB */
+ { 13656, 0x000088D3 }, /* GL_MATRIX19_ARB */
+ { 13672, 0x000088C1 }, /* GL_MATRIX1_ARB */
+ { 13687, 0x00008631 }, /* GL_MATRIX1_NV */
+ { 13701, 0x000088D4 }, /* GL_MATRIX20_ARB */
+ { 13717, 0x000088D5 }, /* GL_MATRIX21_ARB */
+ { 13733, 0x000088D6 }, /* GL_MATRIX22_ARB */
+ { 13749, 0x000088D7 }, /* GL_MATRIX23_ARB */
+ { 13765, 0x000088D8 }, /* GL_MATRIX24_ARB */
+ { 13781, 0x000088D9 }, /* GL_MATRIX25_ARB */
+ { 13797, 0x000088DA }, /* GL_MATRIX26_ARB */
+ { 13813, 0x000088DB }, /* GL_MATRIX27_ARB */
+ { 13829, 0x000088DC }, /* GL_MATRIX28_ARB */
+ { 13845, 0x000088DD }, /* GL_MATRIX29_ARB */
+ { 13861, 0x000088C2 }, /* GL_MATRIX2_ARB */
+ { 13876, 0x00008632 }, /* GL_MATRIX2_NV */
+ { 13890, 0x000088DE }, /* GL_MATRIX30_ARB */
+ { 13906, 0x000088DF }, /* GL_MATRIX31_ARB */
+ { 13922, 0x000088C3 }, /* GL_MATRIX3_ARB */
+ { 13937, 0x00008633 }, /* GL_MATRIX3_NV */
+ { 13951, 0x000088C4 }, /* GL_MATRIX4_ARB */
+ { 13966, 0x00008634 }, /* GL_MATRIX4_NV */
+ { 13980, 0x000088C5 }, /* GL_MATRIX5_ARB */
+ { 13995, 0x00008635 }, /* GL_MATRIX5_NV */
+ { 14009, 0x000088C6 }, /* GL_MATRIX6_ARB */
+ { 14024, 0x00008636 }, /* GL_MATRIX6_NV */
+ { 14038, 0x000088C7 }, /* GL_MATRIX7_ARB */
+ { 14053, 0x00008637 }, /* GL_MATRIX7_NV */
+ { 14067, 0x000088C8 }, /* GL_MATRIX8_ARB */
+ { 14082, 0x000088C9 }, /* GL_MATRIX9_ARB */
+ { 14097, 0x00008844 }, /* GL_MATRIX_INDEX_ARRAY_ARB */
+ { 14123, 0x00008849 }, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */
+ { 14157, 0x00008846 }, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */
+ { 14188, 0x00008848 }, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */
+ { 14221, 0x00008847 }, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */
+ { 14252, 0x00000BA0 }, /* GL_MATRIX_MODE */
+ { 14267, 0x00008840 }, /* GL_MATRIX_PALETTE_ARB */
+ { 14289, 0x00008008 }, /* GL_MAX */
+ { 14296, 0x00008073 }, /* GL_MAX_3D_TEXTURE_SIZE */
+ { 14319, 0x00000D35 }, /* GL_MAX_ATTRIB_STACK_DEPTH */
+ { 14345, 0x00000D3B }, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */
+ { 14378, 0x00008177 }, /* GL_MAX_CLIPMAP_DEPTH_SGIX */
+ { 14404, 0x00008178 }, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */
+ { 14438, 0x00000D32 }, /* GL_MAX_CLIP_PLANES */
+ { 14457, 0x00008CDF }, /* GL_MAX_COLOR_ATTACHMENTS_EXT */
+ { 14486, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */
+ { 14518, 0x000080B3 }, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI */
+ { 14554, 0x00008B4D }, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB */
+ { 14594, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT */
+ { 14620, 0x0000801B }, /* GL_MAX_CONVOLUTION_HEIGHT_EXT */
+ { 14650, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH */
+ { 14675, 0x0000801A }, /* GL_MAX_CONVOLUTION_WIDTH_EXT */
+ { 14704, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */
+ { 14733, 0x0000851C }, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB */
+ { 14766, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ARB */
+ { 14790, 0x00008824 }, /* GL_MAX_DRAW_BUFFERS_ATI */
+ { 14814, 0x000080E9 }, /* GL_MAX_ELEMENTS_INDICES */
+ { 14838, 0x000080E8 }, /* GL_MAX_ELEMENTS_VERTICES */
+ { 14863, 0x00000D30 }, /* GL_MAX_EVAL_ORDER */
+ { 14881, 0x00008008 }, /* GL_MAX_EXT */
+ { 14892, 0x00008B49 }, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB */
+ { 14931, 0x00000D31 }, /* GL_MAX_LIGHTS */
+ { 14945, 0x00000B31 }, /* GL_MAX_LIST_NESTING */
+ { 14965, 0x00008841 }, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */
+ { 15003, 0x00000D36 }, /* GL_MAX_MODELVIEW_STACK_DEPTH */
+ { 15032, 0x00000D37 }, /* GL_MAX_NAME_STACK_DEPTH */
+ { 15056, 0x00008842 }, /* GL_MAX_PALETTE_MATRICES_ARB */
+ { 15084, 0x00000D34 }, /* GL_MAX_PIXEL_MAP_TABLE */
+ { 15107, 0x000088B1 }, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */
+ { 15144, 0x0000880B }, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */
+ { 15180, 0x000088AD }, /* GL_MAX_PROGRAM_ATTRIBS_ARB */
+ { 15207, 0x000088F5 }, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */
+ { 15236, 0x000088B5 }, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */
+ { 15270, 0x000088F4 }, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
+ { 15306, 0x000088F6 }, /* GL_MAX_PROGRAM_IF_DEPTH_NV */
+ { 15333, 0x000088A1 }, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */
+ { 15365, 0x000088B4 }, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */
+ { 15401, 0x000088F8 }, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */
+ { 15430, 0x000088F7 }, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */
+ { 15459, 0x0000862F }, /* GL_MAX_PROGRAM_MATRICES_ARB */
+ { 15487, 0x0000862E }, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */
+ { 15525, 0x000088B3 }, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
+ { 15569, 0x0000880E }, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
+ { 15612, 0x000088AF }, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */
+ { 15646, 0x000088A3 }, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
+ { 15685, 0x000088AB }, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */
+ { 15722, 0x000088A7 }, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */
+ { 15760, 0x00008810 }, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
+ { 15803, 0x0000880F }, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
+ { 15846, 0x000088A9 }, /* GL_MAX_PROGRAM_PARAMETERS_ARB */
+ { 15876, 0x000088A5 }, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */
+ { 15907, 0x0000880D }, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */
+ { 15943, 0x0000880C }, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */
+ { 15979, 0x00000D38 }, /* GL_MAX_PROJECTION_STACK_DEPTH */
+ { 16009, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */
+ { 16043, 0x000084F8 }, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_NV */
+ { 16076, 0x000084E8 }, /* GL_MAX_RENDERBUFFER_SIZE_EXT */
+ { 16105, 0x00008504 }, /* GL_MAX_SHININESS_NV */
+ { 16125, 0x00008505 }, /* GL_MAX_SPOT_EXPONENT_NV */
+ { 16149, 0x00008871 }, /* GL_MAX_TEXTURE_COORDS_ARB */
+ { 16175, 0x00008872 }, /* GL_MAX_TEXTURE_IMAGE_UNITS_ARB */
+ { 16206, 0x000084FD }, /* GL_MAX_TEXTURE_LOD_BIAS */
+ { 16230, 0x000084FF }, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */
+ { 16264, 0x00000D33 }, /* GL_MAX_TEXTURE_SIZE */
+ { 16284, 0x00000D39 }, /* GL_MAX_TEXTURE_STACK_DEPTH */
+ { 16311, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS */
+ { 16332, 0x000084E2 }, /* GL_MAX_TEXTURE_UNITS_ARB */
+ { 16357, 0x0000862F }, /* GL_MAX_TRACK_MATRICES_NV */
+ { 16382, 0x0000862E }, /* GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV */
+ { 16417, 0x00008B4B }, /* GL_MAX_VARYING_FLOATS_ARB */
+ { 16443, 0x00008869 }, /* GL_MAX_VERTEX_ATTRIBS_ARB */
+ { 16469, 0x00008B4C }, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */
+ { 16507, 0x00008B4A }, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB */
+ { 16544, 0x000086A4 }, /* GL_MAX_VERTEX_UNITS_ARB */
+ { 16568, 0x00000D3A }, /* GL_MAX_VIEWPORT_DIMS */
+ { 16589, 0x00008007 }, /* GL_MIN */
+ { 16596, 0x0000802E }, /* GL_MINMAX */
+ { 16606, 0x0000802E }, /* GL_MINMAX_EXT */
+ { 16620, 0x0000802F }, /* GL_MINMAX_FORMAT */
+ { 16637, 0x0000802F }, /* GL_MINMAX_FORMAT_EXT */
+ { 16658, 0x00008030 }, /* GL_MINMAX_SINK */
+ { 16673, 0x00008030 }, /* GL_MINMAX_SINK_EXT */
+ { 16692, 0x00008007 }, /* GL_MIN_EXT */
+ { 16703, 0x00008370 }, /* GL_MIRRORED_REPEAT */
+ { 16722, 0x00008370 }, /* GL_MIRRORED_REPEAT_ARB */
+ { 16745, 0x00008370 }, /* GL_MIRRORED_REPEAT_IBM */
+ { 16768, 0x00008742 }, /* GL_MIRROR_CLAMP_ATI */
+ { 16788, 0x00008742 }, /* GL_MIRROR_CLAMP_EXT */
+ { 16808, 0x00008912 }, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */
+ { 16838, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_ATI */
+ { 16866, 0x00008743 }, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */
+ { 16894, 0x00001700 }, /* GL_MODELVIEW */
+ { 16907, 0x00001700 }, /* GL_MODELVIEW0_ARB */
+ { 16925, 0x0000872A }, /* GL_MODELVIEW10_ARB */
+ { 16944, 0x0000872B }, /* GL_MODELVIEW11_ARB */
+ { 16963, 0x0000872C }, /* GL_MODELVIEW12_ARB */
+ { 16982, 0x0000872D }, /* GL_MODELVIEW13_ARB */
+ { 17001, 0x0000872E }, /* GL_MODELVIEW14_ARB */
+ { 17020, 0x0000872F }, /* GL_MODELVIEW15_ARB */
+ { 17039, 0x00008730 }, /* GL_MODELVIEW16_ARB */
+ { 17058, 0x00008731 }, /* GL_MODELVIEW17_ARB */
+ { 17077, 0x00008732 }, /* GL_MODELVIEW18_ARB */
+ { 17096, 0x00008733 }, /* GL_MODELVIEW19_ARB */
+ { 17115, 0x0000850A }, /* GL_MODELVIEW1_ARB */
+ { 17133, 0x00008734 }, /* GL_MODELVIEW20_ARB */
+ { 17152, 0x00008735 }, /* GL_MODELVIEW21_ARB */
+ { 17171, 0x00008736 }, /* GL_MODELVIEW22_ARB */
+ { 17190, 0x00008737 }, /* GL_MODELVIEW23_ARB */
+ { 17209, 0x00008738 }, /* GL_MODELVIEW24_ARB */
+ { 17228, 0x00008739 }, /* GL_MODELVIEW25_ARB */
+ { 17247, 0x0000873A }, /* GL_MODELVIEW26_ARB */
+ { 17266, 0x0000873B }, /* GL_MODELVIEW27_ARB */
+ { 17285, 0x0000873C }, /* GL_MODELVIEW28_ARB */
+ { 17304, 0x0000873D }, /* GL_MODELVIEW29_ARB */
+ { 17323, 0x00008722 }, /* GL_MODELVIEW2_ARB */
+ { 17341, 0x0000873E }, /* GL_MODELVIEW30_ARB */
+ { 17360, 0x0000873F }, /* GL_MODELVIEW31_ARB */
+ { 17379, 0x00008723 }, /* GL_MODELVIEW3_ARB */
+ { 17397, 0x00008724 }, /* GL_MODELVIEW4_ARB */
+ { 17415, 0x00008725 }, /* GL_MODELVIEW5_ARB */
+ { 17433, 0x00008726 }, /* GL_MODELVIEW6_ARB */
+ { 17451, 0x00008727 }, /* GL_MODELVIEW7_ARB */
+ { 17469, 0x00008728 }, /* GL_MODELVIEW8_ARB */
+ { 17487, 0x00008729 }, /* GL_MODELVIEW9_ARB */
+ { 17505, 0x00000BA6 }, /* GL_MODELVIEW_MATRIX */
+ { 17525, 0x00008629 }, /* GL_MODELVIEW_PROJECTION_NV */
+ { 17552, 0x00000BA3 }, /* GL_MODELVIEW_STACK_DEPTH */
+ { 17577, 0x00002100 }, /* GL_MODULATE */
+ { 17589, 0x00008744 }, /* GL_MODULATE_ADD_ATI */
+ { 17609, 0x00008745 }, /* GL_MODULATE_SIGNED_ADD_ATI */
+ { 17636, 0x00008746 }, /* GL_MODULATE_SUBTRACT_ATI */
+ { 17661, 0x00000103 }, /* GL_MULT */
+ { 17669, 0x0000809D }, /* GL_MULTISAMPLE */
+ { 17684, 0x000086B2 }, /* GL_MULTISAMPLE_3DFX */
+ { 17704, 0x0000809D }, /* GL_MULTISAMPLE_ARB */
+ { 17723, 0x20000000 }, /* GL_MULTISAMPLE_BIT */
+ { 17742, 0x20000000 }, /* GL_MULTISAMPLE_BIT_3DFX */
+ { 17766, 0x20000000 }, /* GL_MULTISAMPLE_BIT_ARB */
+ { 17789, 0x00008534 }, /* GL_MULTISAMPLE_FILTER_HINT_NV */
+ { 17819, 0x00002A25 }, /* GL_N3F_V3F */
+ { 17830, 0x00000D70 }, /* GL_NAME_STACK_DEPTH */
+ { 17850, 0x0000150E }, /* GL_NAND */
+ { 17858, 0x00002600 }, /* GL_NEAREST */
+ { 17869, 0x0000844E }, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */
+ { 17900, 0x0000844D }, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */
+ { 17932, 0x00002702 }, /* GL_NEAREST_MIPMAP_LINEAR */
+ { 17957, 0x00002700 }, /* GL_NEAREST_MIPMAP_NEAREST */
+ { 17983, 0x00000200 }, /* GL_NEVER */
+ { 17992, 0x00001102 }, /* GL_NICEST */
+ { 18002, 0x00000000 }, /* GL_NONE */
+ { 18010, 0x00001505 }, /* GL_NOOP */
+ { 18018, 0x00001508 }, /* GL_NOR */
+ { 18025, 0x00000BA1 }, /* GL_NORMALIZE */
+ { 18038, 0x00008075 }, /* GL_NORMAL_ARRAY */
+ { 18054, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING */
+ { 18085, 0x00008897 }, /* GL_NORMAL_ARRAY_BUFFER_BINDING_ARB */
+ { 18120, 0x0000808F }, /* GL_NORMAL_ARRAY_POINTER */
+ { 18144, 0x0000807F }, /* GL_NORMAL_ARRAY_STRIDE */
+ { 18167, 0x0000807E }, /* GL_NORMAL_ARRAY_TYPE */
+ { 18188, 0x00008511 }, /* GL_NORMAL_MAP */
+ { 18202, 0x00008511 }, /* GL_NORMAL_MAP_ARB */
+ { 18220, 0x00008511 }, /* GL_NORMAL_MAP_NV */
+ { 18237, 0x00000205 }, /* GL_NOTEQUAL */
+ { 18249, 0x00000000 }, /* GL_NO_ERROR */
+ { 18261, 0x000086A2 }, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */
+ { 18295, 0x000086A2 }, /* GL_NUM_TEXTURE_COMPRESSED_FORMATS_ARB */
+ { 18333, 0x00008B89 }, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */
+ { 18365, 0x00008B8A }, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */
+ { 18407, 0x00008B86 }, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */
+ { 18437, 0x00008B87 }, /* GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB */
+ { 18477, 0x00008B85 }, /* GL_OBJECT_ATTACHED_OBJECTS_ARB */
+ { 18508, 0x00008B81 }, /* GL_OBJECT_COMPILE_STATUS_ARB */
+ { 18537, 0x00008B80 }, /* GL_OBJECT_DELETE_STATUS_ARB */
+ { 18565, 0x00008B84 }, /* GL_OBJECT_INFO_LOG_LENGTH_ARB */
+ { 18595, 0x00002401 }, /* GL_OBJECT_LINEAR */
+ { 18612, 0x00008B82 }, /* GL_OBJECT_LINK_STATUS_ARB */
+ { 18638, 0x00002501 }, /* GL_OBJECT_PLANE */
+ { 18654, 0x00008B88 }, /* GL_OBJECT_SHADER_SOURCE_LENGTH_ARB */
+ { 18689, 0x00008B4F }, /* GL_OBJECT_SUBTYPE_ARB */
+ { 18711, 0x00008B4E }, /* GL_OBJECT_TYPE_ARB */
+ { 18730, 0x00008B83 }, /* GL_OBJECT_VALIDATE_STATUS_ARB */
+ { 18760, 0x00008165 }, /* GL_OCCLUSION_TEST_HP */
+ { 18781, 0x00008166 }, /* GL_OCCLUSION_TEST_RESULT_HP */
+ { 18809, 0x00000001 }, /* GL_ONE */
+ { 18816, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA */
+ { 18844, 0x00008004 }, /* GL_ONE_MINUS_CONSTANT_ALPHA_EXT */
+ { 18876, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR */
+ { 18904, 0x00008002 }, /* GL_ONE_MINUS_CONSTANT_COLOR_EXT */
+ { 18936, 0x00000305 }, /* GL_ONE_MINUS_DST_ALPHA */
+ { 18959, 0x00000307 }, /* GL_ONE_MINUS_DST_COLOR */
+ { 18982, 0x00000303 }, /* GL_ONE_MINUS_SRC_ALPHA */
+ { 19005, 0x00000301 }, /* GL_ONE_MINUS_SRC_COLOR */
+ { 19028, 0x00008598 }, /* GL_OPERAND0_ALPHA */
+ { 19046, 0x00008598 }, /* GL_OPERAND0_ALPHA_ARB */
+ { 19068, 0x00008598 }, /* GL_OPERAND0_ALPHA_EXT */
+ { 19090, 0x00008590 }, /* GL_OPERAND0_RGB */
+ { 19106, 0x00008590 }, /* GL_OPERAND0_RGB_ARB */
+ { 19126, 0x00008590 }, /* GL_OPERAND0_RGB_EXT */
+ { 19146, 0x00008599 }, /* GL_OPERAND1_ALPHA */
+ { 19164, 0x00008599 }, /* GL_OPERAND1_ALPHA_ARB */
+ { 19186, 0x00008599 }, /* GL_OPERAND1_ALPHA_EXT */
+ { 19208, 0x00008591 }, /* GL_OPERAND1_RGB */
+ { 19224, 0x00008591 }, /* GL_OPERAND1_RGB_ARB */
+ { 19244, 0x00008591 }, /* GL_OPERAND1_RGB_EXT */
+ { 19264, 0x0000859A }, /* GL_OPERAND2_ALPHA */
+ { 19282, 0x0000859A }, /* GL_OPERAND2_ALPHA_ARB */
+ { 19304, 0x0000859A }, /* GL_OPERAND2_ALPHA_EXT */
+ { 19326, 0x00008592 }, /* GL_OPERAND2_RGB */
+ { 19342, 0x00008592 }, /* GL_OPERAND2_RGB_ARB */
+ { 19362, 0x00008592 }, /* GL_OPERAND2_RGB_EXT */
+ { 19382, 0x0000859B }, /* GL_OPERAND3_ALPHA_NV */
+ { 19403, 0x00008593 }, /* GL_OPERAND3_RGB_NV */
+ { 19422, 0x00001507 }, /* GL_OR */
+ { 19428, 0x00000A01 }, /* GL_ORDER */
+ { 19437, 0x0000150D }, /* GL_OR_INVERTED */
+ { 19452, 0x0000150B }, /* GL_OR_REVERSE */
+ { 19466, 0x00000505 }, /* GL_OUT_OF_MEMORY */
+ { 19483, 0x00000D05 }, /* GL_PACK_ALIGNMENT */
+ { 19501, 0x0000806C }, /* GL_PACK_IMAGE_HEIGHT */
+ { 19522, 0x00008758 }, /* GL_PACK_INVERT_MESA */
+ { 19542, 0x00000D01 }, /* GL_PACK_LSB_FIRST */
+ { 19560, 0x00000D02 }, /* GL_PACK_ROW_LENGTH */
+ { 19579, 0x0000806B }, /* GL_PACK_SKIP_IMAGES */
+ { 19599, 0x00000D04 }, /* GL_PACK_SKIP_PIXELS */
+ { 19619, 0x00000D03 }, /* GL_PACK_SKIP_ROWS */
+ { 19637, 0x00000D00 }, /* GL_PACK_SWAP_BYTES */
+ { 19656, 0x00008B92 }, /* GL_PALETTE4_R5_G6_B5_OES */
+ { 19681, 0x00008B94 }, /* GL_PALETTE4_RGB5_A1_OES */
+ { 19705, 0x00008B90 }, /* GL_PALETTE4_RGB8_OES */
+ { 19726, 0x00008B93 }, /* GL_PALETTE4_RGBA4_OES */
+ { 19748, 0x00008B91 }, /* GL_PALETTE4_RGBA8_OES */
+ { 19770, 0x00008B97 }, /* GL_PALETTE8_R5_G6_B5_OES */
+ { 19795, 0x00008B99 }, /* GL_PALETTE8_RGB5_A1_OES */
+ { 19819, 0x00008B95 }, /* GL_PALETTE8_RGB8_OES */
+ { 19840, 0x00008B98 }, /* GL_PALETTE8_RGBA4_OES */
+ { 19862, 0x00008B96 }, /* GL_PALETTE8_RGBA8_OES */
+ { 19884, 0x00000700 }, /* GL_PASS_THROUGH_TOKEN */
+ { 19906, 0x00000C50 }, /* GL_PERSPECTIVE_CORRECTION_HINT */
+ { 19937, 0x00000C79 }, /* GL_PIXEL_MAP_A_TO_A */
+ { 19957, 0x00000CB9 }, /* GL_PIXEL_MAP_A_TO_A_SIZE */
+ { 19982, 0x00000C78 }, /* GL_PIXEL_MAP_B_TO_B */
+ { 20002, 0x00000CB8 }, /* GL_PIXEL_MAP_B_TO_B_SIZE */
+ { 20027, 0x00000C77 }, /* GL_PIXEL_MAP_G_TO_G */
+ { 20047, 0x00000CB7 }, /* GL_PIXEL_MAP_G_TO_G_SIZE */
+ { 20072, 0x00000C75 }, /* GL_PIXEL_MAP_I_TO_A */
+ { 20092, 0x00000CB5 }, /* GL_PIXEL_MAP_I_TO_A_SIZE */
+ { 20117, 0x00000C74 }, /* GL_PIXEL_MAP_I_TO_B */
+ { 20137, 0x00000CB4 }, /* GL_PIXEL_MAP_I_TO_B_SIZE */
+ { 20162, 0x00000C73 }, /* GL_PIXEL_MAP_I_TO_G */
+ { 20182, 0x00000CB3 }, /* GL_PIXEL_MAP_I_TO_G_SIZE */
+ { 20207, 0x00000C70 }, /* GL_PIXEL_MAP_I_TO_I */
+ { 20227, 0x00000CB0 }, /* GL_PIXEL_MAP_I_TO_I_SIZE */
+ { 20252, 0x00000C72 }, /* GL_PIXEL_MAP_I_TO_R */
+ { 20272, 0x00000CB2 }, /* GL_PIXEL_MAP_I_TO_R_SIZE */
+ { 20297, 0x00000C76 }, /* GL_PIXEL_MAP_R_TO_R */
+ { 20317, 0x00000CB6 }, /* GL_PIXEL_MAP_R_TO_R_SIZE */
+ { 20342, 0x00000C71 }, /* GL_PIXEL_MAP_S_TO_S */
+ { 20362, 0x00000CB1 }, /* GL_PIXEL_MAP_S_TO_S_SIZE */
+ { 20387, 0x00000020 }, /* GL_PIXEL_MODE_BIT */
+ { 20405, 0x000088ED }, /* GL_PIXEL_PACK_BUFFER_BINDING_EXT */
+ { 20438, 0x000088EB }, /* GL_PIXEL_PACK_BUFFER_EXT */
+ { 20463, 0x000088EF }, /* GL_PIXEL_UNPACK_BUFFER_BINDING_EXT */
+ { 20498, 0x000088EC }, /* GL_PIXEL_UNPACK_BUFFER_EXT */
+ { 20525, 0x00001B00 }, /* GL_POINT */
+ { 20534, 0x00000000 }, /* GL_POINTS */
+ { 20544, 0x00000002 }, /* GL_POINT_BIT */
+ { 20557, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION */
+ { 20587, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_ARB */
+ { 20621, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_EXT */
+ { 20655, 0x00008129 }, /* GL_POINT_DISTANCE_ATTENUATION_SGIS */
+ { 20690, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE */
+ { 20719, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_ARB */
+ { 20752, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_EXT */
+ { 20785, 0x00008128 }, /* GL_POINT_FADE_THRESHOLD_SIZE_SGIS */
+ { 20819, 0x00000B11 }, /* GL_POINT_SIZE */
+ { 20833, 0x00000B13 }, /* GL_POINT_SIZE_GRANULARITY */
+ { 20859, 0x00008127 }, /* GL_POINT_SIZE_MAX */
+ { 20877, 0x00008127 }, /* GL_POINT_SIZE_MAX_ARB */
+ { 20899, 0x00008127 }, /* GL_POINT_SIZE_MAX_EXT */
+ { 20921, 0x00008127 }, /* GL_POINT_SIZE_MAX_SGIS */
+ { 20944, 0x00008126 }, /* GL_POINT_SIZE_MIN */
+ { 20962, 0x00008126 }, /* GL_POINT_SIZE_MIN_ARB */
+ { 20984, 0x00008126 }, /* GL_POINT_SIZE_MIN_EXT */
+ { 21006, 0x00008126 }, /* GL_POINT_SIZE_MIN_SGIS */
+ { 21029, 0x00000B12 }, /* GL_POINT_SIZE_RANGE */
+ { 21049, 0x00000B10 }, /* GL_POINT_SMOOTH */
+ { 21065, 0x00000C51 }, /* GL_POINT_SMOOTH_HINT */
+ { 21086, 0x00008861 }, /* GL_POINT_SPRITE_ARB */
+ { 21106, 0x00008CA0 }, /* GL_POINT_SPRITE_COORD_ORIGIN */
+ { 21135, 0x00008861 }, /* GL_POINT_SPRITE_NV */
+ { 21154, 0x00008863 }, /* GL_POINT_SPRITE_R_MODE_NV */
+ { 21180, 0x00000701 }, /* GL_POINT_TOKEN */
+ { 21195, 0x00000009 }, /* GL_POLYGON */
+ { 21206, 0x00000008 }, /* GL_POLYGON_BIT */
+ { 21221, 0x00000B40 }, /* GL_POLYGON_MODE */
+ { 21237, 0x00008039 }, /* GL_POLYGON_OFFSET_BIAS */
+ { 21260, 0x00008038 }, /* GL_POLYGON_OFFSET_FACTOR */
+ { 21285, 0x00008037 }, /* GL_POLYGON_OFFSET_FILL */
+ { 21308, 0x00002A02 }, /* GL_POLYGON_OFFSET_LINE */
+ { 21331, 0x00002A01 }, /* GL_POLYGON_OFFSET_POINT */
+ { 21355, 0x00002A00 }, /* GL_POLYGON_OFFSET_UNITS */
+ { 21379, 0x00000B41 }, /* GL_POLYGON_SMOOTH */
+ { 21397, 0x00000C53 }, /* GL_POLYGON_SMOOTH_HINT */
+ { 21420, 0x00000B42 }, /* GL_POLYGON_STIPPLE */
+ { 21439, 0x00000010 }, /* GL_POLYGON_STIPPLE_BIT */
+ { 21462, 0x00000703 }, /* GL_POLYGON_TOKEN */
+ { 21479, 0x00001203 }, /* GL_POSITION */
+ { 21491, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */
+ { 21523, 0x000080BB }, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI */
+ { 21559, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */
+ { 21592, 0x000080B7 }, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI */
+ { 21629, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */
+ { 21660, 0x000080BA }, /* GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI */
+ { 21695, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */
+ { 21727, 0x000080B6 }, /* GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI */
+ { 21763, 0x000080D2 }, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */
+ { 21796, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */
+ { 21828, 0x000080B9 }, /* GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI */
+ { 21864, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */
+ { 21897, 0x000080B5 }, /* GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI */
+ { 21934, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS */
+ { 21964, 0x000080B8 }, /* GL_POST_COLOR_MATRIX_RED_BIAS_SGI */
+ { 21998, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE */
+ { 22029, 0x000080B4 }, /* GL_POST_COLOR_MATRIX_RED_SCALE_SGI */
+ { 22064, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS */
+ { 22095, 0x00008023 }, /* GL_POST_CONVOLUTION_ALPHA_BIAS_EXT */
+ { 22130, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE */
+ { 22162, 0x0000801F }, /* GL_POST_CONVOLUTION_ALPHA_SCALE_EXT */
+ { 22198, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS */
+ { 22228, 0x00008022 }, /* GL_POST_CONVOLUTION_BLUE_BIAS_EXT */
+ { 22262, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE */
+ { 22293, 0x0000801E }, /* GL_POST_CONVOLUTION_BLUE_SCALE_EXT */
+ { 22328, 0x000080D1 }, /* GL_POST_CONVOLUTION_COLOR_TABLE */
+ { 22360, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS */
+ { 22391, 0x00008021 }, /* GL_POST_CONVOLUTION_GREEN_BIAS_EXT */
+ { 22426, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE */
+ { 22458, 0x0000801D }, /* GL_POST_CONVOLUTION_GREEN_SCALE_EXT */
+ { 22494, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS */
+ { 22523, 0x00008020 }, /* GL_POST_CONVOLUTION_RED_BIAS_EXT */
+ { 22556, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE */
+ { 22586, 0x0000801C }, /* GL_POST_CONVOLUTION_RED_SCALE_EXT */
+ { 22620, 0x0000817B }, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */
+ { 22659, 0x00008179 }, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */
+ { 22692, 0x0000817C }, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */
+ { 22732, 0x0000817A }, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */
+ { 22766, 0x00008578 }, /* GL_PREVIOUS */
+ { 22778, 0x00008578 }, /* GL_PREVIOUS_ARB */
+ { 22794, 0x00008578 }, /* GL_PREVIOUS_EXT */
+ { 22810, 0x00008577 }, /* GL_PRIMARY_COLOR */
+ { 22827, 0x00008577 }, /* GL_PRIMARY_COLOR_ARB */
+ { 22848, 0x00008577 }, /* GL_PRIMARY_COLOR_EXT */
+ { 22869, 0x000088B0 }, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */
+ { 22902, 0x00008805 }, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */
+ { 22934, 0x000088AC }, /* GL_PROGRAM_ATTRIBS_ARB */
+ { 22957, 0x00008677 }, /* GL_PROGRAM_BINDING_ARB */
+ { 22980, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_ARB */
+ { 23010, 0x0000864B }, /* GL_PROGRAM_ERROR_POSITION_NV */
+ { 23039, 0x00008874 }, /* GL_PROGRAM_ERROR_STRING_ARB */
+ { 23067, 0x00008876 }, /* GL_PROGRAM_FORMAT_ARB */
+ { 23089, 0x00008875 }, /* GL_PROGRAM_FORMAT_ASCII_ARB */
+ { 23117, 0x000088A0 }, /* GL_PROGRAM_INSTRUCTIONS_ARB */
+ { 23145, 0x00008627 }, /* GL_PROGRAM_LENGTH_ARB */
+ { 23167, 0x00008627 }, /* GL_PROGRAM_LENGTH_NV */
+ { 23188, 0x000088B2 }, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
+ { 23228, 0x00008808 }, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
+ { 23267, 0x000088AE }, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */
+ { 23297, 0x000088A2 }, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
+ { 23332, 0x000088AA }, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */
+ { 23365, 0x000088A6 }, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */
+ { 23399, 0x0000880A }, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
+ { 23438, 0x00008809 }, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
+ { 23477, 0x00008B40 }, /* GL_PROGRAM_OBJECT_ARB */
+ { 23499, 0x000088A8 }, /* GL_PROGRAM_PARAMETERS_ARB */
+ { 23525, 0x00008644 }, /* GL_PROGRAM_PARAMETER_NV */
+ { 23549, 0x00008647 }, /* GL_PROGRAM_RESIDENT_NV */
+ { 23572, 0x00008628 }, /* GL_PROGRAM_STRING_ARB */
+ { 23594, 0x00008628 }, /* GL_PROGRAM_STRING_NV */
+ { 23615, 0x00008646 }, /* GL_PROGRAM_TARGET_NV */
+ { 23636, 0x000088A4 }, /* GL_PROGRAM_TEMPORARIES_ARB */
+ { 23663, 0x00008807 }, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */
+ { 23695, 0x00008806 }, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */
+ { 23727, 0x000088B6 }, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */
+ { 23762, 0x00001701 }, /* GL_PROJECTION */
+ { 23776, 0x00000BA7 }, /* GL_PROJECTION_MATRIX */
+ { 23797, 0x00000BA4 }, /* GL_PROJECTION_STACK_DEPTH */
+ { 23823, 0x000080D3 }, /* GL_PROXY_COLOR_TABLE */
+ { 23844, 0x00008025 }, /* GL_PROXY_HISTOGRAM */
+ { 23863, 0x00008025 }, /* GL_PROXY_HISTOGRAM_EXT */
+ { 23886, 0x000080D5 }, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */
+ { 23925, 0x000080D4 }, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */
+ { 23963, 0x00008063 }, /* GL_PROXY_TEXTURE_1D */
+ { 23983, 0x00008063 }, /* GL_PROXY_TEXTURE_1D_EXT */
+ { 24007, 0x00008064 }, /* GL_PROXY_TEXTURE_2D */
+ { 24027, 0x00008064 }, /* GL_PROXY_TEXTURE_2D_EXT */
+ { 24051, 0x00008070 }, /* GL_PROXY_TEXTURE_3D */
+ { 24071, 0x000080BD }, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */
+ { 24104, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP */
+ { 24130, 0x0000851B }, /* GL_PROXY_TEXTURE_CUBE_MAP_ARB */
+ { 24160, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */
+ { 24191, 0x000084F7 }, /* GL_PROXY_TEXTURE_RECTANGLE_NV */
+ { 24221, 0x00002003 }, /* GL_Q */
+ { 24226, 0x00001209 }, /* GL_QUADRATIC_ATTENUATION */
+ { 24251, 0x00000007 }, /* GL_QUADS */
+ { 24260, 0x00008614 }, /* GL_QUAD_MESH_SUN */
+ { 24277, 0x00000008 }, /* GL_QUAD_STRIP */
+ { 24291, 0x00008864 }, /* GL_QUERY_COUNTER_BITS */
+ { 24313, 0x00008864 }, /* GL_QUERY_COUNTER_BITS_ARB */
+ { 24339, 0x00008866 }, /* GL_QUERY_RESULT */
+ { 24355, 0x00008866 }, /* GL_QUERY_RESULT_ARB */
+ { 24375, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE */
+ { 24401, 0x00008867 }, /* GL_QUERY_RESULT_AVAILABLE_ARB */
+ { 24431, 0x00002002 }, /* GL_R */
+ { 24436, 0x00002A10 }, /* GL_R3_G3_B2 */
+ { 24448, 0x00019262 }, /* GL_RASTER_POSITION_UNCLIPPED_IBM */
+ { 24481, 0x00000C02 }, /* GL_READ_BUFFER */
+ { 24496, 0x000088B8 }, /* GL_READ_ONLY */
+ { 24509, 0x000088B8 }, /* GL_READ_ONLY_ARB */
+ { 24526, 0x000088BA }, /* GL_READ_WRITE */
+ { 24540, 0x000088BA }, /* GL_READ_WRITE_ARB */
+ { 24558, 0x00001903 }, /* GL_RED */
+ { 24565, 0x00008016 }, /* GL_REDUCE */
+ { 24575, 0x00008016 }, /* GL_REDUCE_EXT */
+ { 24589, 0x00000D15 }, /* GL_RED_BIAS */
+ { 24601, 0x00000D52 }, /* GL_RED_BITS */
+ { 24613, 0x00000D14 }, /* GL_RED_SCALE */
+ { 24626, 0x00008512 }, /* GL_REFLECTION_MAP */
+ { 24644, 0x00008512 }, /* GL_REFLECTION_MAP_ARB */
+ { 24666, 0x00008512 }, /* GL_REFLECTION_MAP_NV */
+ { 24687, 0x00001C00 }, /* GL_RENDER */
+ { 24697, 0x00008CA7 }, /* GL_RENDERBUFFER_BINDING_EXT */
+ { 24725, 0x00008D41 }, /* GL_RENDERBUFFER_EXT */
+ { 24745, 0x00008D43 }, /* GL_RENDERBUFFER_HEIGHT_EXT */
+ { 24772, 0x00008D44 }, /* GL_RENDERBUFFER_INTERNAL_FORMAT_EXT */
+ { 24808, 0x00008D42 }, /* GL_RENDERBUFFER_WIDTH_EXT */
+ { 24834, 0x00001F01 }, /* GL_RENDERER */
+ { 24846, 0x00000C40 }, /* GL_RENDER_MODE */
+ { 24861, 0x00002901 }, /* GL_REPEAT */
+ { 24871, 0x00001E01 }, /* GL_REPLACE */
+ { 24882, 0x00008062 }, /* GL_REPLACE_EXT */
+ { 24897, 0x00008153 }, /* GL_REPLICATE_BORDER_HP */
+ { 24920, 0x0000803A }, /* GL_RESCALE_NORMAL */
+ { 24938, 0x0000803A }, /* GL_RESCALE_NORMAL_EXT */
+ { 24960, 0x00000102 }, /* GL_RETURN */
+ { 24970, 0x00001907 }, /* GL_RGB */
+ { 24977, 0x00008052 }, /* GL_RGB10 */
+ { 24986, 0x00008059 }, /* GL_RGB10_A2 */
+ { 24998, 0x00008059 }, /* GL_RGB10_A2_EXT */
+ { 25014, 0x00008052 }, /* GL_RGB10_EXT */
+ { 25027, 0x00008053 }, /* GL_RGB12 */
+ { 25036, 0x00008053 }, /* GL_RGB12_EXT */
+ { 25049, 0x00008054 }, /* GL_RGB16 */
+ { 25058, 0x00008054 }, /* GL_RGB16_EXT */
+ { 25071, 0x0000804E }, /* GL_RGB2_EXT */
+ { 25083, 0x0000804F }, /* GL_RGB4 */
+ { 25091, 0x0000804F }, /* GL_RGB4_EXT */
+ { 25103, 0x000083A1 }, /* GL_RGB4_S3TC */
+ { 25116, 0x00008050 }, /* GL_RGB5 */
+ { 25124, 0x00008057 }, /* GL_RGB5_A1 */
+ { 25135, 0x00008057 }, /* GL_RGB5_A1_EXT */
+ { 25150, 0x00008050 }, /* GL_RGB5_EXT */
+ { 25162, 0x00008051 }, /* GL_RGB8 */
+ { 25170, 0x00008051 }, /* GL_RGB8_EXT */
+ { 25182, 0x00001908 }, /* GL_RGBA */
+ { 25190, 0x0000805A }, /* GL_RGBA12 */
+ { 25200, 0x0000805A }, /* GL_RGBA12_EXT */
+ { 25214, 0x0000805B }, /* GL_RGBA16 */
+ { 25224, 0x0000805B }, /* GL_RGBA16_EXT */
+ { 25238, 0x00008055 }, /* GL_RGBA2 */
+ { 25247, 0x00008055 }, /* GL_RGBA2_EXT */
+ { 25260, 0x00008056 }, /* GL_RGBA4 */
+ { 25269, 0x000083A5 }, /* GL_RGBA4_DXT5_S3TC */
+ { 25288, 0x00008056 }, /* GL_RGBA4_EXT */
+ { 25301, 0x000083A3 }, /* GL_RGBA4_S3TC */
+ { 25315, 0x00008058 }, /* GL_RGBA8 */
+ { 25324, 0x00008058 }, /* GL_RGBA8_EXT */
+ { 25337, 0x000083A4 }, /* GL_RGBA_DXT5_S3TC */
+ { 25355, 0x00000C31 }, /* GL_RGBA_MODE */
+ { 25368, 0x000083A2 }, /* GL_RGBA_S3TC */
+ { 25381, 0x000083A0 }, /* GL_RGB_S3TC */
+ { 25393, 0x00008573 }, /* GL_RGB_SCALE */
+ { 25406, 0x00008573 }, /* GL_RGB_SCALE_ARB */
+ { 25423, 0x00008573 }, /* GL_RGB_SCALE_EXT */
+ { 25440, 0x00000407 }, /* GL_RIGHT */
+ { 25449, 0x00002000 }, /* GL_S */
+ { 25454, 0x000080A9 }, /* GL_SAMPLES */
+ { 25465, 0x000086B4 }, /* GL_SAMPLES_3DFX */
+ { 25481, 0x000080A9 }, /* GL_SAMPLES_ARB */
+ { 25496, 0x00008914 }, /* GL_SAMPLES_PASSED */
+ { 25514, 0x00008914 }, /* GL_SAMPLES_PASSED_ARB */
+ { 25536, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE */
+ { 25564, 0x0000809E }, /* GL_SAMPLE_ALPHA_TO_COVERAGE_ARB */
+ { 25596, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE */
+ { 25619, 0x0000809F }, /* GL_SAMPLE_ALPHA_TO_ONE_ARB */
+ { 25646, 0x000080A8 }, /* GL_SAMPLE_BUFFERS */
+ { 25664, 0x000086B3 }, /* GL_SAMPLE_BUFFERS_3DFX */
+ { 25687, 0x000080A8 }, /* GL_SAMPLE_BUFFERS_ARB */
+ { 25709, 0x000080A0 }, /* GL_SAMPLE_COVERAGE */
+ { 25728, 0x000080A0 }, /* GL_SAMPLE_COVERAGE_ARB */
+ { 25751, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT */
+ { 25777, 0x000080AB }, /* GL_SAMPLE_COVERAGE_INVERT_ARB */
+ { 25807, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE */
+ { 25832, 0x000080AA }, /* GL_SAMPLE_COVERAGE_VALUE_ARB */
+ { 25861, 0x00080000 }, /* GL_SCISSOR_BIT */
+ { 25876, 0x00000C10 }, /* GL_SCISSOR_BOX */
+ { 25891, 0x00000C11 }, /* GL_SCISSOR_TEST */
+ { 25907, 0x0000845E }, /* GL_SECONDARY_COLOR_ARRAY */
+ { 25932, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */
+ { 25972, 0x0000889C }, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB */
+ { 26016, 0x0000845D }, /* GL_SECONDARY_COLOR_ARRAY_POINTER */
+ { 26049, 0x0000845A }, /* GL_SECONDARY_COLOR_ARRAY_SIZE */
+ { 26079, 0x0000845C }, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */
+ { 26111, 0x0000845B }, /* GL_SECONDARY_COLOR_ARRAY_TYPE */
+ { 26141, 0x00001C02 }, /* GL_SELECT */
+ { 26151, 0x00000DF3 }, /* GL_SELECTION_BUFFER_POINTER */
+ { 26179, 0x00000DF4 }, /* GL_SELECTION_BUFFER_SIZE */
+ { 26204, 0x00008012 }, /* GL_SEPARABLE_2D */
+ { 26220, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR */
+ { 26247, 0x000081FA }, /* GL_SEPARATE_SPECULAR_COLOR_EXT */
+ { 26278, 0x0000150F }, /* GL_SET */
+ { 26285, 0x00008B48 }, /* GL_SHADER_OBJECT_ARB */
+ { 26306, 0x00000B54 }, /* GL_SHADE_MODEL */
+ { 26321, 0x000080BF }, /* GL_SHADOW_AMBIENT_SGIX */
+ { 26344, 0x000081FB }, /* GL_SHARED_TEXTURE_PALETTE_EXT */
+ { 26374, 0x00001601 }, /* GL_SHININESS */
+ { 26387, 0x00001402 }, /* GL_SHORT */
+ { 26396, 0x000081F9 }, /* GL_SINGLE_COLOR */
+ { 26412, 0x000081F9 }, /* GL_SINGLE_COLOR_EXT */
+ { 26432, 0x000085CC }, /* GL_SLICE_ACCUM_SUN */
+ { 26451, 0x00001D01 }, /* GL_SMOOTH */
+ { 26461, 0x00000B23 }, /* GL_SMOOTH_LINE_WIDTH_GRANULARITY */
+ { 26494, 0x00000B22 }, /* GL_SMOOTH_LINE_WIDTH_RANGE */
+ { 26521, 0x00000B13 }, /* GL_SMOOTH_POINT_SIZE_GRANULARITY */
+ { 26554, 0x00000B12 }, /* GL_SMOOTH_POINT_SIZE_RANGE */
+ { 26581, 0x00008588 }, /* GL_SOURCE0_ALPHA */
+ { 26598, 0x00008588 }, /* GL_SOURCE0_ALPHA_ARB */
+ { 26619, 0x00008588 }, /* GL_SOURCE0_ALPHA_EXT */
+ { 26640, 0x00008580 }, /* GL_SOURCE0_RGB */
+ { 26655, 0x00008580 }, /* GL_SOURCE0_RGB_ARB */
+ { 26674, 0x00008580 }, /* GL_SOURCE0_RGB_EXT */
+ { 26693, 0x00008589 }, /* GL_SOURCE1_ALPHA */
+ { 26710, 0x00008589 }, /* GL_SOURCE1_ALPHA_ARB */
+ { 26731, 0x00008589 }, /* GL_SOURCE1_ALPHA_EXT */
+ { 26752, 0x00008581 }, /* GL_SOURCE1_RGB */
+ { 26767, 0x00008581 }, /* GL_SOURCE1_RGB_ARB */
+ { 26786, 0x00008581 }, /* GL_SOURCE1_RGB_EXT */
+ { 26805, 0x0000858A }, /* GL_SOURCE2_ALPHA */
+ { 26822, 0x0000858A }, /* GL_SOURCE2_ALPHA_ARB */
+ { 26843, 0x0000858A }, /* GL_SOURCE2_ALPHA_EXT */
+ { 26864, 0x00008582 }, /* GL_SOURCE2_RGB */
+ { 26879, 0x00008582 }, /* GL_SOURCE2_RGB_ARB */
+ { 26898, 0x00008582 }, /* GL_SOURCE2_RGB_EXT */
+ { 26917, 0x0000858B }, /* GL_SOURCE3_ALPHA_NV */
+ { 26937, 0x00008583 }, /* GL_SOURCE3_RGB_NV */
+ { 26955, 0x00001202 }, /* GL_SPECULAR */
+ { 26967, 0x00002402 }, /* GL_SPHERE_MAP */
+ { 26981, 0x00001206 }, /* GL_SPOT_CUTOFF */
+ { 26996, 0x00001204 }, /* GL_SPOT_DIRECTION */
+ { 27014, 0x00001205 }, /* GL_SPOT_EXPONENT */
+ { 27031, 0x00008588 }, /* GL_SRC0_ALPHA */
+ { 27045, 0x00008580 }, /* GL_SRC0_RGB */
+ { 27057, 0x00008589 }, /* GL_SRC1_ALPHA */
+ { 27071, 0x00008581 }, /* GL_SRC1_RGB */
+ { 27083, 0x0000858A }, /* GL_SRC2_ALPHA */
+ { 27097, 0x00008582 }, /* GL_SRC2_RGB */
+ { 27109, 0x00000302 }, /* GL_SRC_ALPHA */
+ { 27122, 0x00000308 }, /* GL_SRC_ALPHA_SATURATE */
+ { 27144, 0x00000300 }, /* GL_SRC_COLOR */
+ { 27157, 0x00000503 }, /* GL_STACK_OVERFLOW */
+ { 27175, 0x00000504 }, /* GL_STACK_UNDERFLOW */
+ { 27194, 0x000088E6 }, /* GL_STATIC_COPY */
+ { 27209, 0x000088E6 }, /* GL_STATIC_COPY_ARB */
+ { 27228, 0x000088E4 }, /* GL_STATIC_DRAW */
+ { 27243, 0x000088E4 }, /* GL_STATIC_DRAW_ARB */
+ { 27262, 0x000088E5 }, /* GL_STATIC_READ */
+ { 27277, 0x000088E5 }, /* GL_STATIC_READ_ARB */
+ { 27296, 0x00001802 }, /* GL_STENCIL */
+ { 27307, 0x00008D20 }, /* GL_STENCIL_ATTACHMENT_EXT */
+ { 27333, 0x00000D57 }, /* GL_STENCIL_BITS */
+ { 27349, 0x00000400 }, /* GL_STENCIL_BUFFER_BIT */
+ { 27371, 0x00000B91 }, /* GL_STENCIL_CLEAR_VALUE */
+ { 27394, 0x00000B94 }, /* GL_STENCIL_FAIL */
+ { 27410, 0x00000B92 }, /* GL_STENCIL_FUNC */
+ { 27426, 0x00001901 }, /* GL_STENCIL_INDEX */
+ { 27443, 0x00008D49 }, /* GL_STENCIL_INDEX16_EXT */
+ { 27466, 0x00008D46 }, /* GL_STENCIL_INDEX1_EXT */
+ { 27488, 0x00008D47 }, /* GL_STENCIL_INDEX4_EXT */
+ { 27510, 0x00008D48 }, /* GL_STENCIL_INDEX8_EXT */
+ { 27532, 0x00008D45 }, /* GL_STENCIL_INDEX_EXT */
+ { 27553, 0x00000B95 }, /* GL_STENCIL_PASS_DEPTH_FAIL */
+ { 27580, 0x00000B96 }, /* GL_STENCIL_PASS_DEPTH_PASS */
+ { 27607, 0x00000B97 }, /* GL_STENCIL_REF */
+ { 27622, 0x00000B90 }, /* GL_STENCIL_TEST */
+ { 27638, 0x00008910 }, /* GL_STENCIL_TEST_TWO_SIDE_EXT */
+ { 27667, 0x00000B93 }, /* GL_STENCIL_VALUE_MASK */
+ { 27689, 0x00000B98 }, /* GL_STENCIL_WRITEMASK */
+ { 27710, 0x00000C33 }, /* GL_STEREO */
+ { 27720, 0x000088E2 }, /* GL_STREAM_COPY */
+ { 27735, 0x000088E2 }, /* GL_STREAM_COPY_ARB */
+ { 27754, 0x000088E0 }, /* GL_STREAM_DRAW */
+ { 27769, 0x000088E0 }, /* GL_STREAM_DRAW_ARB */
+ { 27788, 0x000088E1 }, /* GL_STREAM_READ */
+ { 27803, 0x000088E1 }, /* GL_STREAM_READ_ARB */
+ { 27822, 0x00000D50 }, /* GL_SUBPIXEL_BITS */
+ { 27839, 0x000084E7 }, /* GL_SUBTRACT */
+ { 27851, 0x000084E7 }, /* GL_SUBTRACT_ARB */
+ { 27867, 0x00002001 }, /* GL_T */
+ { 27872, 0x00002A2A }, /* GL_T2F_C3F_V3F */
+ { 27887, 0x00002A2C }, /* GL_T2F_C4F_N3F_V3F */
+ { 27906, 0x00002A29 }, /* GL_T2F_C4UB_V3F */
+ { 27922, 0x00002A2B }, /* GL_T2F_N3F_V3F */
+ { 27937, 0x00002A27 }, /* GL_T2F_V3F */
+ { 27948, 0x00002A2D }, /* GL_T4F_C4F_N3F_V4F */
+ { 27967, 0x00002A28 }, /* GL_T4F_V4F */
+ { 27978, 0x00008031 }, /* GL_TABLE_TOO_LARGE_EXT */
+ { 28001, 0x00001702 }, /* GL_TEXTURE */
+ { 28012, 0x000084C0 }, /* GL_TEXTURE0 */
+ { 28024, 0x000084C0 }, /* GL_TEXTURE0_ARB */
+ { 28040, 0x000084C1 }, /* GL_TEXTURE1 */
+ { 28052, 0x000084CA }, /* GL_TEXTURE10 */
+ { 28065, 0x000084CA }, /* GL_TEXTURE10_ARB */
+ { 28082, 0x000084CB }, /* GL_TEXTURE11 */
+ { 28095, 0x000084CB }, /* GL_TEXTURE11_ARB */
+ { 28112, 0x000084CC }, /* GL_TEXTURE12 */
+ { 28125, 0x000084CC }, /* GL_TEXTURE12_ARB */
+ { 28142, 0x000084CD }, /* GL_TEXTURE13 */
+ { 28155, 0x000084CD }, /* GL_TEXTURE13_ARB */
+ { 28172, 0x000084CE }, /* GL_TEXTURE14 */
+ { 28185, 0x000084CE }, /* GL_TEXTURE14_ARB */
+ { 28202, 0x000084CF }, /* GL_TEXTURE15 */
+ { 28215, 0x000084CF }, /* GL_TEXTURE15_ARB */
+ { 28232, 0x000084D0 }, /* GL_TEXTURE16 */
+ { 28245, 0x000084D0 }, /* GL_TEXTURE16_ARB */
+ { 28262, 0x000084D1 }, /* GL_TEXTURE17 */
+ { 28275, 0x000084D1 }, /* GL_TEXTURE17_ARB */
+ { 28292, 0x000084D2 }, /* GL_TEXTURE18 */
+ { 28305, 0x000084D2 }, /* GL_TEXTURE18_ARB */
+ { 28322, 0x000084D3 }, /* GL_TEXTURE19 */
+ { 28335, 0x000084D3 }, /* GL_TEXTURE19_ARB */
+ { 28352, 0x000084C1 }, /* GL_TEXTURE1_ARB */
+ { 28368, 0x000084C2 }, /* GL_TEXTURE2 */
+ { 28380, 0x000084D4 }, /* GL_TEXTURE20 */
+ { 28393, 0x000084D4 }, /* GL_TEXTURE20_ARB */
+ { 28410, 0x000084D5 }, /* GL_TEXTURE21 */
+ { 28423, 0x000084D5 }, /* GL_TEXTURE21_ARB */
+ { 28440, 0x000084D6 }, /* GL_TEXTURE22 */
+ { 28453, 0x000084D6 }, /* GL_TEXTURE22_ARB */
+ { 28470, 0x000084D7 }, /* GL_TEXTURE23 */
+ { 28483, 0x000084D7 }, /* GL_TEXTURE23_ARB */
+ { 28500, 0x000084D8 }, /* GL_TEXTURE24 */
+ { 28513, 0x000084D8 }, /* GL_TEXTURE24_ARB */
+ { 28530, 0x000084D9 }, /* GL_TEXTURE25 */
+ { 28543, 0x000084D9 }, /* GL_TEXTURE25_ARB */
+ { 28560, 0x000084DA }, /* GL_TEXTURE26 */
+ { 28573, 0x000084DA }, /* GL_TEXTURE26_ARB */
+ { 28590, 0x000084DB }, /* GL_TEXTURE27 */
+ { 28603, 0x000084DB }, /* GL_TEXTURE27_ARB */
+ { 28620, 0x000084DC }, /* GL_TEXTURE28 */
+ { 28633, 0x000084DC }, /* GL_TEXTURE28_ARB */
+ { 28650, 0x000084DD }, /* GL_TEXTURE29 */
+ { 28663, 0x000084DD }, /* GL_TEXTURE29_ARB */
+ { 28680, 0x000084C2 }, /* GL_TEXTURE2_ARB */
+ { 28696, 0x000084C3 }, /* GL_TEXTURE3 */
+ { 28708, 0x000084DE }, /* GL_TEXTURE30 */
+ { 28721, 0x000084DE }, /* GL_TEXTURE30_ARB */
+ { 28738, 0x000084DF }, /* GL_TEXTURE31 */
+ { 28751, 0x000084DF }, /* GL_TEXTURE31_ARB */
+ { 28768, 0x000084C3 }, /* GL_TEXTURE3_ARB */
+ { 28784, 0x000084C4 }, /* GL_TEXTURE4 */
+ { 28796, 0x000084C4 }, /* GL_TEXTURE4_ARB */
+ { 28812, 0x000084C5 }, /* GL_TEXTURE5 */
+ { 28824, 0x000084C5 }, /* GL_TEXTURE5_ARB */
+ { 28840, 0x000084C6 }, /* GL_TEXTURE6 */
+ { 28852, 0x000084C6 }, /* GL_TEXTURE6_ARB */
+ { 28868, 0x000084C7 }, /* GL_TEXTURE7 */
+ { 28880, 0x000084C7 }, /* GL_TEXTURE7_ARB */
+ { 28896, 0x000084C8 }, /* GL_TEXTURE8 */
+ { 28908, 0x000084C8 }, /* GL_TEXTURE8_ARB */
+ { 28924, 0x000084C9 }, /* GL_TEXTURE9 */
+ { 28936, 0x000084C9 }, /* GL_TEXTURE9_ARB */
+ { 28952, 0x00000DE0 }, /* GL_TEXTURE_1D */
+ { 28966, 0x00000DE1 }, /* GL_TEXTURE_2D */
+ { 28980, 0x0000806F }, /* GL_TEXTURE_3D */
+ { 28994, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE */
+ { 29016, 0x0000805F }, /* GL_TEXTURE_ALPHA_SIZE_EXT */
+ { 29042, 0x0000813C }, /* GL_TEXTURE_BASE_LEVEL */
+ { 29064, 0x00008068 }, /* GL_TEXTURE_BINDING_1D */
+ { 29086, 0x00008069 }, /* GL_TEXTURE_BINDING_2D */
+ { 29108, 0x0000806A }, /* GL_TEXTURE_BINDING_3D */
+ { 29130, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP */
+ { 29158, 0x00008514 }, /* GL_TEXTURE_BINDING_CUBE_MAP_ARB */
+ { 29190, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */
+ { 29223, 0x000084F6 }, /* GL_TEXTURE_BINDING_RECTANGLE_NV */
+ { 29255, 0x00040000 }, /* GL_TEXTURE_BIT */
+ { 29270, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE */
+ { 29291, 0x0000805E }, /* GL_TEXTURE_BLUE_SIZE_EXT */
+ { 29316, 0x00001005 }, /* GL_TEXTURE_BORDER */
+ { 29334, 0x00001004 }, /* GL_TEXTURE_BORDER_COLOR */
+ { 29358, 0x00008171 }, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */
+ { 29389, 0x00008176 }, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */
+ { 29419, 0x00008172 }, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */
+ { 29449, 0x00008175 }, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */
+ { 29484, 0x00008173 }, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */
+ { 29515, 0x00008174 }, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */
+ { 29553, 0x000080BC }, /* GL_TEXTURE_COLOR_TABLE_SGI */
+ { 29580, 0x000081EF }, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */
+ { 29612, 0x000080BF }, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
+ { 29646, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC */
+ { 29670, 0x0000884D }, /* GL_TEXTURE_COMPARE_FUNC_ARB */
+ { 29698, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE */
+ { 29722, 0x0000884C }, /* GL_TEXTURE_COMPARE_MODE_ARB */
+ { 29750, 0x0000819B }, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */
+ { 29783, 0x0000819A }, /* GL_TEXTURE_COMPARE_SGIX */
+ { 29807, 0x00001003 }, /* GL_TEXTURE_COMPONENTS */
+ { 29829, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED */
+ { 29851, 0x000086A1 }, /* GL_TEXTURE_COMPRESSED_ARB */
+ { 29877, 0x000086A3 }, /* GL_TEXTURE_COMPRESSED_FORMATS_ARB */
+ { 29911, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */
+ { 29944, 0x000086A0 }, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB */
+ { 29981, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT */
+ { 30009, 0x000084EF }, /* GL_TEXTURE_COMPRESSION_HINT_ARB */
+ { 30041, 0x00008078 }, /* GL_TEXTURE_COORD_ARRAY */
+ { 30064, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */
+ { 30102, 0x0000889A }, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB */
+ { 30144, 0x00008092 }, /* GL_TEXTURE_COORD_ARRAY_POINTER */
+ { 30175, 0x00008088 }, /* GL_TEXTURE_COORD_ARRAY_SIZE */
+ { 30203, 0x0000808A }, /* GL_TEXTURE_COORD_ARRAY_STRIDE */
+ { 30233, 0x00008089 }, /* GL_TEXTURE_COORD_ARRAY_TYPE */
+ { 30261, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP */
+ { 30281, 0x00008513 }, /* GL_TEXTURE_CUBE_MAP_ARB */
+ { 30305, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */
+ { 30336, 0x00008516 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB */
+ { 30371, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */
+ { 30402, 0x00008518 }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB */
+ { 30437, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */
+ { 30468, 0x0000851A }, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB */
+ { 30503, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */
+ { 30534, 0x00008515 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB */
+ { 30569, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */
+ { 30600, 0x00008517 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB */
+ { 30635, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */
+ { 30666, 0x00008519 }, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB */
+ { 30701, 0x00008071 }, /* GL_TEXTURE_DEPTH */
+ { 30718, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE */
+ { 30740, 0x0000884A }, /* GL_TEXTURE_DEPTH_SIZE_ARB */
+ { 30766, 0x00002300 }, /* GL_TEXTURE_ENV */
+ { 30781, 0x00002201 }, /* GL_TEXTURE_ENV_COLOR */
+ { 30802, 0x00002200 }, /* GL_TEXTURE_ENV_MODE */
+ { 30822, 0x00008500 }, /* GL_TEXTURE_FILTER_CONTROL */
+ { 30848, 0x00002500 }, /* GL_TEXTURE_GEN_MODE */
+ { 30868, 0x00000C63 }, /* GL_TEXTURE_GEN_Q */
+ { 30885, 0x00000C62 }, /* GL_TEXTURE_GEN_R */
+ { 30902, 0x00000C60 }, /* GL_TEXTURE_GEN_S */
+ { 30919, 0x00000C61 }, /* GL_TEXTURE_GEN_T */
+ { 30936, 0x0000819D }, /* GL_TEXTURE_GEQUAL_R_SGIX */
+ { 30961, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE */
+ { 30983, 0x0000805D }, /* GL_TEXTURE_GREEN_SIZE_EXT */
+ { 31009, 0x00001001 }, /* GL_TEXTURE_HEIGHT */
+ { 31027, 0x000080ED }, /* GL_TEXTURE_INDEX_SIZE_EXT */
+ { 31053, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE */
+ { 31079, 0x00008061 }, /* GL_TEXTURE_INTENSITY_SIZE_EXT */
+ { 31109, 0x00001003 }, /* GL_TEXTURE_INTERNAL_FORMAT */
+ { 31136, 0x0000819C }, /* GL_TEXTURE_LEQUAL_R_SGIX */
+ { 31161, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS */
+ { 31181, 0x00008501 }, /* GL_TEXTURE_LOD_BIAS_EXT */
+ { 31205, 0x00008190 }, /* GL_TEXTURE_LOD_BIAS_R_SGIX */
+ { 31232, 0x0000818E }, /* GL_TEXTURE_LOD_BIAS_S_SGIX */
+ { 31259, 0x0000818F }, /* GL_TEXTURE_LOD_BIAS_T_SGIX */
+ { 31286, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE */
+ { 31312, 0x00008060 }, /* GL_TEXTURE_LUMINANCE_SIZE_EXT */
+ { 31342, 0x00002800 }, /* GL_TEXTURE_MAG_FILTER */
+ { 31364, 0x00000BA8 }, /* GL_TEXTURE_MATRIX */
+ { 31382, 0x000084FE }, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */
+ { 31412, 0x0000836B }, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */
+ { 31440, 0x00008369 }, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */
+ { 31468, 0x0000836A }, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */
+ { 31496, 0x0000813D }, /* GL_TEXTURE_MAX_LEVEL */
+ { 31517, 0x0000813B }, /* GL_TEXTURE_MAX_LOD */
+ { 31536, 0x00002801 }, /* GL_TEXTURE_MIN_FILTER */
+ { 31558, 0x0000813A }, /* GL_TEXTURE_MIN_LOD */
+ { 31577, 0x00008066 }, /* GL_TEXTURE_PRIORITY */
+ { 31597, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_ARB */
+ { 31622, 0x000084F5 }, /* GL_TEXTURE_RECTANGLE_NV */
+ { 31646, 0x0000805C }, /* GL_TEXTURE_RED_SIZE */
+ { 31666, 0x0000805C }, /* GL_TEXTURE_RED_SIZE_EXT */
+ { 31690, 0x00008067 }, /* GL_TEXTURE_RESIDENT */
+ { 31710, 0x00000BA5 }, /* GL_TEXTURE_STACK_DEPTH */
+ { 31733, 0x00008065 }, /* GL_TEXTURE_TOO_LARGE_EXT */
+ { 31758, 0x0000888F }, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */
+ { 31792, 0x00001000 }, /* GL_TEXTURE_WIDTH */
+ { 31809, 0x00008072 }, /* GL_TEXTURE_WRAP_R */
+ { 31827, 0x00002802 }, /* GL_TEXTURE_WRAP_S */
+ { 31845, 0x00002803 }, /* GL_TEXTURE_WRAP_T */
+ { 31863, 0x00008648 }, /* GL_TRACK_MATRIX_NV */
+ { 31882, 0x00008649 }, /* GL_TRACK_MATRIX_TRANSFORM_NV */
+ { 31911, 0x00001000 }, /* GL_TRANSFORM_BIT */
+ { 31928, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX */
+ { 31954, 0x000084E6 }, /* GL_TRANSPOSE_COLOR_MATRIX_ARB */
+ { 31984, 0x000088B7 }, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */
+ { 32016, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX */
+ { 32046, 0x000084E3 }, /* GL_TRANSPOSE_MODELVIEW_MATRIX_ARB */
+ { 32080, 0x0000862C }, /* GL_TRANSPOSE_NV */
+ { 32096, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX */
+ { 32127, 0x000084E4 }, /* GL_TRANSPOSE_PROJECTION_MATRIX_ARB */
+ { 32162, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX */
+ { 32190, 0x000084E5 }, /* GL_TRANSPOSE_TEXTURE_MATRIX_ARB */
+ { 32222, 0x00000004 }, /* GL_TRIANGLES */
+ { 32235, 0x00000006 }, /* GL_TRIANGLE_FAN */
+ { 32251, 0x00008615 }, /* GL_TRIANGLE_MESH_SUN */
+ { 32272, 0x00000005 }, /* GL_TRIANGLE_STRIP */
+ { 32290, 0x00000001 }, /* GL_TRUE */
+ { 32298, 0x00000CF5 }, /* GL_UNPACK_ALIGNMENT */
+ { 32318, 0x0000806E }, /* GL_UNPACK_IMAGE_HEIGHT */
+ { 32341, 0x00000CF1 }, /* GL_UNPACK_LSB_FIRST */
+ { 32361, 0x00000CF2 }, /* GL_UNPACK_ROW_LENGTH */
+ { 32382, 0x0000806D }, /* GL_UNPACK_SKIP_IMAGES */
+ { 32404, 0x00000CF4 }, /* GL_UNPACK_SKIP_PIXELS */
+ { 32426, 0x00000CF3 }, /* GL_UNPACK_SKIP_ROWS */
+ { 32446, 0x00000CF0 }, /* GL_UNPACK_SWAP_BYTES */
+ { 32467, 0x00001401 }, /* GL_UNSIGNED_BYTE */
+ { 32484, 0x00008362 }, /* GL_UNSIGNED_BYTE_2_3_3_REV */
+ { 32511, 0x00008032 }, /* GL_UNSIGNED_BYTE_3_3_2 */
+ { 32534, 0x00001405 }, /* GL_UNSIGNED_INT */
+ { 32550, 0x00008036 }, /* GL_UNSIGNED_INT_10_10_10_2 */
+ { 32577, 0x000084FA }, /* GL_UNSIGNED_INT_24_8_NV */
+ { 32601, 0x00008368 }, /* GL_UNSIGNED_INT_2_10_10_10_REV */
+ { 32632, 0x00008035 }, /* GL_UNSIGNED_INT_8_8_8_8 */
+ { 32656, 0x00008367 }, /* GL_UNSIGNED_INT_8_8_8_8_REV */
+ { 32684, 0x00001403 }, /* GL_UNSIGNED_SHORT */
+ { 32702, 0x00008366 }, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */
+ { 32732, 0x00008033 }, /* GL_UNSIGNED_SHORT_4_4_4_4 */
+ { 32758, 0x00008365 }, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */
+ { 32788, 0x00008034 }, /* GL_UNSIGNED_SHORT_5_5_5_1 */
+ { 32814, 0x00008363 }, /* GL_UNSIGNED_SHORT_5_6_5 */
+ { 32838, 0x00008364 }, /* GL_UNSIGNED_SHORT_5_6_5_REV */
+ { 32866, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_APPLE */
+ { 32894, 0x000085BA }, /* GL_UNSIGNED_SHORT_8_8_MESA */
+ { 32921, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */
+ { 32953, 0x000085BB }, /* GL_UNSIGNED_SHORT_8_8_REV_MESA */
+ { 32984, 0x00002A20 }, /* GL_V2F */
+ { 32991, 0x00002A21 }, /* GL_V3F */
+ { 32998, 0x00001F00 }, /* GL_VENDOR */
+ { 33008, 0x00001F02 }, /* GL_VERSION */
+ { 33019, 0x00008074 }, /* GL_VERTEX_ARRAY */
+ { 33035, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
+ { 33066, 0x00008896 }, /* GL_VERTEX_ARRAY_BUFFER_BINDING_ARB */
+ { 33101, 0x0000808E }, /* GL_VERTEX_ARRAY_POINTER */
+ { 33125, 0x0000807A }, /* GL_VERTEX_ARRAY_SIZE */
+ { 33146, 0x0000807C }, /* GL_VERTEX_ARRAY_STRIDE */
+ { 33169, 0x0000807B }, /* GL_VERTEX_ARRAY_TYPE */
+ { 33190, 0x00008650 }, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
+ { 33217, 0x0000865A }, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
+ { 33245, 0x0000865B }, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
+ { 33273, 0x0000865C }, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
+ { 33301, 0x0000865D }, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
+ { 33329, 0x0000865E }, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
+ { 33357, 0x0000865F }, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
+ { 33385, 0x00008651 }, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
+ { 33412, 0x00008652 }, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
+ { 33439, 0x00008653 }, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
+ { 33466, 0x00008654 }, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
+ { 33493, 0x00008655 }, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
+ { 33520, 0x00008656 }, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
+ { 33547, 0x00008657 }, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
+ { 33574, 0x00008658 }, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
+ { 33601, 0x00008659 }, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
+ { 33628, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
+ { 33666, 0x0000889F }, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB */
+ { 33708, 0x00008622 }, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB */
+ { 33743, 0x0000886A }, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB */
+ { 33781, 0x00008645 }, /* GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB */
+ { 33816, 0x00008623 }, /* GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB */
+ { 33848, 0x00008624 }, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB */
+ { 33882, 0x00008625 }, /* GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB */
+ { 33914, 0x000086A7 }, /* GL_VERTEX_BLEND_ARB */
+ { 33934, 0x00008620 }, /* GL_VERTEX_PROGRAM_ARB */
+ { 33956, 0x0000864A }, /* GL_VERTEX_PROGRAM_BINDING_NV */
+ { 33985, 0x00008620 }, /* GL_VERTEX_PROGRAM_NV */
+ { 34006, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_ARB */
+ { 34039, 0x00008642 }, /* GL_VERTEX_PROGRAM_POINT_SIZE_NV */
+ { 34071, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_ARB */
+ { 34102, 0x00008643 }, /* GL_VERTEX_PROGRAM_TWO_SIDE_NV */
+ { 34132, 0x00008B31 }, /* GL_VERTEX_SHADER_ARB */
+ { 34153, 0x00008621 }, /* GL_VERTEX_STATE_PROGRAM_NV */
+ { 34180, 0x00000BA2 }, /* GL_VIEWPORT */
+ { 34192, 0x00000800 }, /* GL_VIEWPORT_BIT */
+ { 34208, 0x000086AD }, /* GL_WEIGHT_ARRAY_ARB */
+ { 34228, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
+ { 34259, 0x0000889E }, /* GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB */
+ { 34294, 0x000086AC }, /* GL_WEIGHT_ARRAY_POINTER_ARB */
+ { 34322, 0x000086AB }, /* GL_WEIGHT_ARRAY_SIZE_ARB */
+ { 34347, 0x000086AA }, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
+ { 34374, 0x000086A9 }, /* GL_WEIGHT_ARRAY_TYPE_ARB */
+ { 34399, 0x000086A6 }, /* GL_WEIGHT_SUM_UNITY_ARB */
+ { 34423, 0x000081D4 }, /* GL_WRAP_BORDER_SUN */
+ { 34442, 0x000088B9 }, /* GL_WRITE_ONLY */
+ { 34456, 0x000088B9 }, /* GL_WRITE_ONLY_ARB */
+ { 34474, 0x00001506 }, /* GL_XOR */
+ { 34481, 0x000085B9 }, /* GL_YCBCR_422_APPLE */
+ { 34500, 0x00008757 }, /* GL_YCBCR_MESA */
+ { 34514, 0x00000000 }, /* GL_ZERO */
+ { 34522, 0x00000D16 }, /* GL_ZOOM_X */
+ { 34532, 0x00000D17 }, /* GL_ZOOM_Y */
+};
+
+static const unsigned reduced_enums[1232] =
+{
+ 26, /* GL_ALL_CLIENT_ATTRIB_BITS */
+ 389, /* GL_FALSE */
+ 561, /* GL_LINES */
+ 563, /* GL_LINE_LOOP */
+ 570, /* GL_LINE_STRIP */
+ 1515, /* GL_TRIANGLES */
+ 1518, /* GL_TRIANGLE_STRIP */
+ 1516, /* GL_TRIANGLE_FAN */
+ 1112, /* GL_QUADS */
+ 1114, /* GL_QUAD_STRIP */
+ 1002, /* GL_POLYGON */
+ 1014, /* GL_POLYGON_STIPPLE_BIT */
+ 968, /* GL_PIXEL_MODE_BIT */
+ 548, /* GL_LIGHTING_BIT */
+ 405, /* GL_FOG_BIT */
+ 8, /* GL_ACCUM */
+ 579, /* GL_LOAD */
+ 1152, /* GL_RETURN */
+ 841, /* GL_MULT */
+ 19, /* GL_ADD */
+ 857, /* GL_NEVER */
+ 538, /* GL_LESS */
+ 379, /* GL_EQUAL */
+ 537, /* GL_LEQUAL */
+ 467, /* GL_GREATER */
+ 872, /* GL_NOTEQUAL */
+ 466, /* GL_GEQUAL */
+ 42, /* GL_ALWAYS */
+ 1276, /* GL_SRC_COLOR */
+ 901, /* GL_ONE_MINUS_SRC_COLOR */
+ 1274, /* GL_SRC_ALPHA */
+ 900, /* GL_ONE_MINUS_SRC_ALPHA */
+ 359, /* GL_DST_ALPHA */
+ 898, /* GL_ONE_MINUS_DST_ALPHA */
+ 360, /* GL_DST_COLOR */
+ 899, /* GL_ONE_MINUS_DST_COLOR */
+ 1275, /* GL_SRC_ALPHA_SATURATE */
+ 454, /* GL_FRONT_LEFT */
+ 455, /* GL_FRONT_RIGHT */
+ 64, /* GL_BACK_LEFT */
+ 65, /* GL_BACK_RIGHT */
+ 451, /* GL_FRONT */
+ 63, /* GL_BACK */
+ 536, /* GL_LEFT */
+ 1192, /* GL_RIGHT */
+ 452, /* GL_FRONT_AND_BACK */
+ 58, /* GL_AUX0 */
+ 59, /* GL_AUX1 */
+ 60, /* GL_AUX2 */
+ 61, /* GL_AUX3 */
+ 528, /* GL_INVALID_ENUM */
+ 531, /* GL_INVALID_VALUE */
+ 530, /* GL_INVALID_OPERATION */
+ 1277, /* GL_STACK_OVERFLOW */
+ 1278, /* GL_STACK_UNDERFLOW */
+ 926, /* GL_OUT_OF_MEMORY */
+ 529, /* GL_INVALID_FRAMEBUFFER_OPERATION_EXT */
+ 0, /* GL_2D */
+ 2, /* GL_3D */
+ 3, /* GL_3D_COLOR */
+ 4, /* GL_3D_COLOR_TEXTURE */
+ 6, /* GL_4D_COLOR_TEXTURE */
+ 946, /* GL_PASS_THROUGH_TOKEN */
+ 1001, /* GL_POINT_TOKEN */
+ 571, /* GL_LINE_TOKEN */
+ 1015, /* GL_POLYGON_TOKEN */
+ 69, /* GL_BITMAP_TOKEN */
+ 358, /* GL_DRAW_PIXEL_TOKEN */
+ 248, /* GL_COPY_PIXEL_TOKEN */
+ 564, /* GL_LINE_RESET_TOKEN */
+ 382, /* GL_EXP */
+ 383, /* GL_EXP2 */
+ 279, /* GL_CW */
+ 106, /* GL_CCW */
+ 127, /* GL_COEFF */
+ 923, /* GL_ORDER */
+ 315, /* GL_DOMAIN */
+ 256, /* GL_CURRENT_COLOR */
+ 259, /* GL_CURRENT_INDEX */
+ 265, /* GL_CURRENT_NORMAL */
+ 276, /* GL_CURRENT_TEXTURE_COORDS */
+ 269, /* GL_CURRENT_RASTER_COLOR */
+ 271, /* GL_CURRENT_RASTER_INDEX */
+ 274, /* GL_CURRENT_RASTER_TEXTURE_COORDS */
+ 272, /* GL_CURRENT_RASTER_POSITION */
+ 273, /* GL_CURRENT_RASTER_POSITION_VALID */
+ 270, /* GL_CURRENT_RASTER_DISTANCE */
+ 995, /* GL_POINT_SMOOTH */
+ 984, /* GL_POINT_SIZE */
+ 994, /* GL_POINT_SIZE_RANGE */
+ 985, /* GL_POINT_SIZE_GRANULARITY */
+ 565, /* GL_LINE_SMOOTH */
+ 572, /* GL_LINE_WIDTH */
+ 574, /* GL_LINE_WIDTH_RANGE */
+ 573, /* GL_LINE_WIDTH_GRANULARITY */
+ 567, /* GL_LINE_STIPPLE */
+ 568, /* GL_LINE_STIPPLE_PATTERN */
+ 569, /* GL_LINE_STIPPLE_REPEAT */
+ 578, /* GL_LIST_MODE */
+ 732, /* GL_MAX_LIST_NESTING */
+ 575, /* GL_LIST_BASE */
+ 577, /* GL_LIST_INDEX */
+ 1004, /* GL_POLYGON_MODE */
+ 1011, /* GL_POLYGON_SMOOTH */
+ 1013, /* GL_POLYGON_STIPPLE */
+ 367, /* GL_EDGE_FLAG */
+ 249, /* GL_CULL_FACE */
+ 250, /* GL_CULL_FACE_MODE */
+ 453, /* GL_FRONT_FACE */
+ 547, /* GL_LIGHTING */
+ 552, /* GL_LIGHT_MODEL_LOCAL_VIEWER */
+ 553, /* GL_LIGHT_MODEL_TWO_SIDE */
+ 549, /* GL_LIGHT_MODEL_AMBIENT */
+ 1230, /* GL_SHADE_MODEL */
+ 158, /* GL_COLOR_MATERIAL_FACE */
+ 159, /* GL_COLOR_MATERIAL_PARAMETER */
+ 157, /* GL_COLOR_MATERIAL */
+ 404, /* GL_FOG */
+ 426, /* GL_FOG_INDEX */
+ 422, /* GL_FOG_DENSITY */
+ 430, /* GL_FOG_START */
+ 424, /* GL_FOG_END */
+ 427, /* GL_FOG_MODE */
+ 406, /* GL_FOG_COLOR */
+ 304, /* GL_DEPTH_RANGE */
+ 309, /* GL_DEPTH_TEST */
+ 312, /* GL_DEPTH_WRITEMASK */
+ 292, /* GL_DEPTH_CLEAR_VALUE */
+ 303, /* GL_DEPTH_FUNC */
+ 12, /* GL_ACCUM_CLEAR_VALUE */
+ 1301, /* GL_STENCIL_TEST */
+ 1289, /* GL_STENCIL_CLEAR_VALUE */
+ 1291, /* GL_STENCIL_FUNC */
+ 1303, /* GL_STENCIL_VALUE_MASK */
+ 1290, /* GL_STENCIL_FAIL */
+ 1298, /* GL_STENCIL_PASS_DEPTH_FAIL */
+ 1299, /* GL_STENCIL_PASS_DEPTH_PASS */
+ 1300, /* GL_STENCIL_REF */
+ 1304, /* GL_STENCIL_WRITEMASK */
+ 705, /* GL_MATRIX_MODE */
+ 862, /* GL_NORMALIZE */
+ 1593, /* GL_VIEWPORT */
+ 836, /* GL_MODELVIEW_STACK_DEPTH */
+ 1094, /* GL_PROJECTION_STACK_DEPTH */
+ 1495, /* GL_TEXTURE_STACK_DEPTH */
+ 834, /* GL_MODELVIEW_MATRIX */
+ 1093, /* GL_PROJECTION_MATRIX */
+ 1480, /* GL_TEXTURE_MATRIX */
+ 56, /* GL_ATTRIB_STACK_DEPTH */
+ 117, /* GL_CLIENT_ATTRIB_STACK_DEPTH */
+ 39, /* GL_ALPHA_TEST */
+ 40, /* GL_ALPHA_TEST_FUNC */
+ 41, /* GL_ALPHA_TEST_REF */
+ 314, /* GL_DITHER */
+ 73, /* GL_BLEND_DST */
+ 80, /* GL_BLEND_SRC */
+ 70, /* GL_BLEND */
+ 581, /* GL_LOGIC_OP_MODE */
+ 506, /* GL_INDEX_LOGIC_OP */
+ 156, /* GL_COLOR_LOGIC_OP */
+ 62, /* GL_AUX_BUFFERS */
+ 325, /* GL_DRAW_BUFFER */
+ 1124, /* GL_READ_BUFFER */
+ 1213, /* GL_SCISSOR_BOX */
+ 1214, /* GL_SCISSOR_TEST */
+ 505, /* GL_INDEX_CLEAR_VALUE */
+ 510, /* GL_INDEX_WRITEMASK */
+ 153, /* GL_COLOR_CLEAR_VALUE */
+ 185, /* GL_COLOR_WRITEMASK */
+ 507, /* GL_INDEX_MODE */
+ 1186, /* GL_RGBA_MODE */
+ 324, /* GL_DOUBLEBUFFER */
+ 1305, /* GL_STEREO */
+ 1145, /* GL_RENDER_MODE */
+ 947, /* GL_PERSPECTIVE_CORRECTION_HINT */
+ 996, /* GL_POINT_SMOOTH_HINT */
+ 566, /* GL_LINE_SMOOTH_HINT */
+ 1012, /* GL_POLYGON_SMOOTH_HINT */
+ 425, /* GL_FOG_HINT */
+ 1461, /* GL_TEXTURE_GEN_S */
+ 1462, /* GL_TEXTURE_GEN_T */
+ 1460, /* GL_TEXTURE_GEN_R */
+ 1459, /* GL_TEXTURE_GEN_Q */
+ 960, /* GL_PIXEL_MAP_I_TO_I */
+ 966, /* GL_PIXEL_MAP_S_TO_S */
+ 962, /* GL_PIXEL_MAP_I_TO_R */
+ 958, /* GL_PIXEL_MAP_I_TO_G */
+ 956, /* GL_PIXEL_MAP_I_TO_B */
+ 954, /* GL_PIXEL_MAP_I_TO_A */
+ 964, /* GL_PIXEL_MAP_R_TO_R */
+ 952, /* GL_PIXEL_MAP_G_TO_G */
+ 950, /* GL_PIXEL_MAP_B_TO_B */
+ 948, /* GL_PIXEL_MAP_A_TO_A */
+ 961, /* GL_PIXEL_MAP_I_TO_I_SIZE */
+ 967, /* GL_PIXEL_MAP_S_TO_S_SIZE */
+ 963, /* GL_PIXEL_MAP_I_TO_R_SIZE */
+ 959, /* GL_PIXEL_MAP_I_TO_G_SIZE */
+ 957, /* GL_PIXEL_MAP_I_TO_B_SIZE */
+ 955, /* GL_PIXEL_MAP_I_TO_A_SIZE */
+ 965, /* GL_PIXEL_MAP_R_TO_R_SIZE */
+ 953, /* GL_PIXEL_MAP_G_TO_G_SIZE */
+ 951, /* GL_PIXEL_MAP_B_TO_B_SIZE */
+ 949, /* GL_PIXEL_MAP_A_TO_A_SIZE */
+ 1527, /* GL_UNPACK_SWAP_BYTES */
+ 1522, /* GL_UNPACK_LSB_FIRST */
+ 1523, /* GL_UNPACK_ROW_LENGTH */
+ 1526, /* GL_UNPACK_SKIP_ROWS */
+ 1525, /* GL_UNPACK_SKIP_PIXELS */
+ 1520, /* GL_UNPACK_ALIGNMENT */
+ 935, /* GL_PACK_SWAP_BYTES */
+ 930, /* GL_PACK_LSB_FIRST */
+ 931, /* GL_PACK_ROW_LENGTH */
+ 934, /* GL_PACK_SKIP_ROWS */
+ 933, /* GL_PACK_SKIP_PIXELS */
+ 927, /* GL_PACK_ALIGNMENT */
+ 658, /* GL_MAP_COLOR */
+ 659, /* GL_MAP_STENCIL */
+ 509, /* GL_INDEX_SHIFT */
+ 508, /* GL_INDEX_OFFSET */
+ 1134, /* GL_RED_SCALE */
+ 1132, /* GL_RED_BIAS */
+ 1610, /* GL_ZOOM_X */
+ 1611, /* GL_ZOOM_Y */
+ 471, /* GL_GREEN_SCALE */
+ 469, /* GL_GREEN_BIAS */
+ 86, /* GL_BLUE_SCALE */
+ 84, /* GL_BLUE_BIAS */
+ 38, /* GL_ALPHA_SCALE */
+ 36, /* GL_ALPHA_BIAS */
+ 305, /* GL_DEPTH_SCALE */
+ 286, /* GL_DEPTH_BIAS */
+ 728, /* GL_MAX_EVAL_ORDER */
+ 731, /* GL_MAX_LIGHTS */
+ 713, /* GL_MAX_CLIP_PLANES */
+ 773, /* GL_MAX_TEXTURE_SIZE */
+ 737, /* GL_MAX_PIXEL_MAP_TABLE */
+ 709, /* GL_MAX_ATTRIB_STACK_DEPTH */
+ 734, /* GL_MAX_MODELVIEW_STACK_DEPTH */
+ 735, /* GL_MAX_NAME_STACK_DEPTH */
+ 763, /* GL_MAX_PROJECTION_STACK_DEPTH */
+ 774, /* GL_MAX_TEXTURE_STACK_DEPTH */
+ 784, /* GL_MAX_VIEWPORT_DIMS */
+ 710, /* GL_MAX_CLIENT_ATTRIB_STACK_DEPTH */
+ 1312, /* GL_SUBPIXEL_BITS */
+ 504, /* GL_INDEX_BITS */
+ 1133, /* GL_RED_BITS */
+ 470, /* GL_GREEN_BITS */
+ 85, /* GL_BLUE_BITS */
+ 37, /* GL_ALPHA_BITS */
+ 287, /* GL_DEPTH_BITS */
+ 1287, /* GL_STENCIL_BITS */
+ 14, /* GL_ACCUM_RED_BITS */
+ 13, /* GL_ACCUM_GREEN_BITS */
+ 10, /* GL_ACCUM_BLUE_BITS */
+ 9, /* GL_ACCUM_ALPHA_BITS */
+ 850, /* GL_NAME_STACK_DEPTH */
+ 57, /* GL_AUTO_NORMAL */
+ 604, /* GL_MAP1_COLOR_4 */
+ 607, /* GL_MAP1_INDEX */
+ 608, /* GL_MAP1_NORMAL */
+ 609, /* GL_MAP1_TEXTURE_COORD_1 */
+ 610, /* GL_MAP1_TEXTURE_COORD_2 */
+ 611, /* GL_MAP1_TEXTURE_COORD_3 */
+ 612, /* GL_MAP1_TEXTURE_COORD_4 */
+ 613, /* GL_MAP1_VERTEX_3 */
+ 614, /* GL_MAP1_VERTEX_4 */
+ 631, /* GL_MAP2_COLOR_4 */
+ 634, /* GL_MAP2_INDEX */
+ 635, /* GL_MAP2_NORMAL */
+ 636, /* GL_MAP2_TEXTURE_COORD_1 */
+ 637, /* GL_MAP2_TEXTURE_COORD_2 */
+ 638, /* GL_MAP2_TEXTURE_COORD_3 */
+ 639, /* GL_MAP2_TEXTURE_COORD_4 */
+ 640, /* GL_MAP2_VERTEX_3 */
+ 641, /* GL_MAP2_VERTEX_4 */
+ 605, /* GL_MAP1_GRID_DOMAIN */
+ 606, /* GL_MAP1_GRID_SEGMENTS */
+ 632, /* GL_MAP2_GRID_DOMAIN */
+ 633, /* GL_MAP2_GRID_SEGMENTS */
+ 1389, /* GL_TEXTURE_1D */
+ 1390, /* GL_TEXTURE_2D */
+ 392, /* GL_FEEDBACK_BUFFER_POINTER */
+ 393, /* GL_FEEDBACK_BUFFER_SIZE */
+ 394, /* GL_FEEDBACK_BUFFER_TYPE */
+ 1223, /* GL_SELECTION_BUFFER_POINTER */
+ 1224, /* GL_SELECTION_BUFFER_SIZE */
+ 1498, /* GL_TEXTURE_WIDTH */
+ 1466, /* GL_TEXTURE_HEIGHT */
+ 1422, /* GL_TEXTURE_COMPONENTS */
+ 1406, /* GL_TEXTURE_BORDER_COLOR */
+ 1405, /* GL_TEXTURE_BORDER */
+ 316, /* GL_DONT_CARE */
+ 390, /* GL_FASTEST */
+ 858, /* GL_NICEST */
+ 43, /* GL_AMBIENT */
+ 313, /* GL_DIFFUSE */
+ 1263, /* GL_SPECULAR */
+ 1016, /* GL_POSITION */
+ 1266, /* GL_SPOT_DIRECTION */
+ 1267, /* GL_SPOT_EXPONENT */
+ 1265, /* GL_SPOT_CUTOFF */
+ 223, /* GL_CONSTANT_ATTENUATION */
+ 556, /* GL_LINEAR_ATTENUATION */
+ 1111, /* GL_QUADRATIC_ATTENUATION */
+ 198, /* GL_COMPILE */
+ 199, /* GL_COMPILE_AND_EXECUTE */
+ 101, /* GL_BYTE */
+ 1528, /* GL_UNSIGNED_BYTE */
+ 1234, /* GL_SHORT */
+ 1537, /* GL_UNSIGNED_SHORT */
+ 511, /* GL_INT */
+ 1531, /* GL_UNSIGNED_INT */
+ 397, /* GL_FLOAT */
+ 1, /* GL_2_BYTES */
+ 5, /* GL_3_BYTES */
+ 7, /* GL_4_BYTES */
+ 323, /* GL_DOUBLE */
+ 113, /* GL_CLEAR */
+ 45, /* GL_AND */
+ 47, /* GL_AND_REVERSE */
+ 246, /* GL_COPY */
+ 46, /* GL_AND_INVERTED */
+ 860, /* GL_NOOP */
+ 1606, /* GL_XOR */
+ 922, /* GL_OR */
+ 861, /* GL_NOR */
+ 380, /* GL_EQUIV */
+ 534, /* GL_INVERT */
+ 925, /* GL_OR_REVERSE */
+ 247, /* GL_COPY_INVERTED */
+ 924, /* GL_OR_INVERTED */
+ 851, /* GL_NAND */
+ 1228, /* GL_SET */
+ 377, /* GL_EMISSION */
+ 1233, /* GL_SHININESS */
+ 44, /* GL_AMBIENT_AND_DIFFUSE */
+ 155, /* GL_COLOR_INDEXES */
+ 801, /* GL_MODELVIEW */
+ 1092, /* GL_PROJECTION */
+ 1324, /* GL_TEXTURE */
+ 128, /* GL_COLOR */
+ 284, /* GL_DEPTH */
+ 1285, /* GL_STENCIL */
+ 154, /* GL_COLOR_INDEX */
+ 1292, /* GL_STENCIL_INDEX */
+ 293, /* GL_DEPTH_COMPONENT */
+ 1129, /* GL_RED */
+ 468, /* GL_GREEN */
+ 83, /* GL_BLUE */
+ 27, /* GL_ALPHA */
+ 1153, /* GL_RGB */
+ 1172, /* GL_RGBA */
+ 582, /* GL_LUMINANCE */
+ 603, /* GL_LUMINANCE_ALPHA */
+ 68, /* GL_BITMAP */
+ 973, /* GL_POINT */
+ 554, /* GL_LINE */
+ 395, /* GL_FILL */
+ 1138, /* GL_RENDER */
+ 391, /* GL_FEEDBACK */
+ 1222, /* GL_SELECT */
+ 396, /* GL_FLAT */
+ 1238, /* GL_SMOOTH */
+ 535, /* GL_KEEP */
+ 1147, /* GL_REPLACE */
+ 495, /* GL_INCR */
+ 281, /* GL_DECR */
+ 1550, /* GL_VENDOR */
+ 1144, /* GL_RENDERER */
+ 1551, /* GL_VERSION */
+ 384, /* GL_EXTENSIONS */
+ 1193, /* GL_S */
+ 1315, /* GL_T */
+ 1121, /* GL_R */
+ 1110, /* GL_Q */
+ 837, /* GL_MODULATE */
+ 280, /* GL_DECAL */
+ 1456, /* GL_TEXTURE_ENV_MODE */
+ 1455, /* GL_TEXTURE_ENV_COLOR */
+ 1454, /* GL_TEXTURE_ENV */
+ 385, /* GL_EYE_LINEAR */
+ 884, /* GL_OBJECT_LINEAR */
+ 1264, /* GL_SPHERE_MAP */
+ 1458, /* GL_TEXTURE_GEN_MODE */
+ 886, /* GL_OBJECT_PLANE */
+ 386, /* GL_EYE_PLANE */
+ 852, /* GL_NEAREST */
+ 555, /* GL_LINEAR */
+ 856, /* GL_NEAREST_MIPMAP_NEAREST */
+ 560, /* GL_LINEAR_MIPMAP_NEAREST */
+ 855, /* GL_NEAREST_MIPMAP_LINEAR */
+ 559, /* GL_LINEAR_MIPMAP_LINEAR */
+ 1479, /* GL_TEXTURE_MAG_FILTER */
+ 1487, /* GL_TEXTURE_MIN_FILTER */
+ 1500, /* GL_TEXTURE_WRAP_S */
+ 1501, /* GL_TEXTURE_WRAP_T */
+ 107, /* GL_CLAMP */
+ 1146, /* GL_REPEAT */
+ 1010, /* GL_POLYGON_OFFSET_UNITS */
+ 1009, /* GL_POLYGON_OFFSET_POINT */
+ 1008, /* GL_POLYGON_OFFSET_LINE */
+ 1122, /* GL_R3_G3_B2 */
+ 1548, /* GL_V2F */
+ 1549, /* GL_V3F */
+ 104, /* GL_C4UB_V2F */
+ 105, /* GL_C4UB_V3F */
+ 102, /* GL_C3F_V3F */
+ 849, /* GL_N3F_V3F */
+ 103, /* GL_C4F_N3F_V3F */
+ 1320, /* GL_T2F_V3F */
+ 1322, /* GL_T4F_V4F */
+ 1318, /* GL_T2F_C4UB_V3F */
+ 1316, /* GL_T2F_C3F_V3F */
+ 1319, /* GL_T2F_N3F_V3F */
+ 1317, /* GL_T2F_C4F_N3F_V3F */
+ 1321, /* GL_T4F_C4F_N3F_V4F */
+ 120, /* GL_CLIP_PLANE0 */
+ 121, /* GL_CLIP_PLANE1 */
+ 122, /* GL_CLIP_PLANE2 */
+ 123, /* GL_CLIP_PLANE3 */
+ 124, /* GL_CLIP_PLANE4 */
+ 125, /* GL_CLIP_PLANE5 */
+ 539, /* GL_LIGHT0 */
+ 540, /* GL_LIGHT1 */
+ 541, /* GL_LIGHT2 */
+ 542, /* GL_LIGHT3 */
+ 543, /* GL_LIGHT4 */
+ 544, /* GL_LIGHT5 */
+ 545, /* GL_LIGHT6 */
+ 546, /* GL_LIGHT7 */
+ 472, /* GL_HINT_BIT */
+ 225, /* GL_CONSTANT_COLOR */
+ 896, /* GL_ONE_MINUS_CONSTANT_COLOR */
+ 220, /* GL_CONSTANT_ALPHA */
+ 894, /* GL_ONE_MINUS_CONSTANT_ALPHA */
+ 71, /* GL_BLEND_COLOR */
+ 456, /* GL_FUNC_ADD */
+ 785, /* GL_MIN */
+ 707, /* GL_MAX */
+ 76, /* GL_BLEND_EQUATION */
+ 460, /* GL_FUNC_SUBTRACT */
+ 458, /* GL_FUNC_REVERSE_SUBTRACT */
+ 228, /* GL_CONVOLUTION_1D */
+ 229, /* GL_CONVOLUTION_2D */
+ 1225, /* GL_SEPARABLE_2D */
+ 232, /* GL_CONVOLUTION_BORDER_MODE */
+ 236, /* GL_CONVOLUTION_FILTER_SCALE */
+ 234, /* GL_CONVOLUTION_FILTER_BIAS */
+ 1130, /* GL_REDUCE */
+ 238, /* GL_CONVOLUTION_FORMAT */
+ 242, /* GL_CONVOLUTION_WIDTH */
+ 240, /* GL_CONVOLUTION_HEIGHT */
+ 720, /* GL_MAX_CONVOLUTION_WIDTH */
+ 718, /* GL_MAX_CONVOLUTION_HEIGHT */
+ 1049, /* GL_POST_CONVOLUTION_RED_SCALE */
+ 1045, /* GL_POST_CONVOLUTION_GREEN_SCALE */
+ 1040, /* GL_POST_CONVOLUTION_BLUE_SCALE */
+ 1036, /* GL_POST_CONVOLUTION_ALPHA_SCALE */
+ 1047, /* GL_POST_CONVOLUTION_RED_BIAS */
+ 1043, /* GL_POST_CONVOLUTION_GREEN_BIAS */
+ 1038, /* GL_POST_CONVOLUTION_BLUE_BIAS */
+ 1034, /* GL_POST_CONVOLUTION_ALPHA_BIAS */
+ 473, /* GL_HISTOGRAM */
+ 1096, /* GL_PROXY_HISTOGRAM */
+ 489, /* GL_HISTOGRAM_WIDTH */
+ 479, /* GL_HISTOGRAM_FORMAT */
+ 485, /* GL_HISTOGRAM_RED_SIZE */
+ 481, /* GL_HISTOGRAM_GREEN_SIZE */
+ 476, /* GL_HISTOGRAM_BLUE_SIZE */
+ 474, /* GL_HISTOGRAM_ALPHA_SIZE */
+ 483, /* GL_HISTOGRAM_LUMINANCE_SIZE */
+ 487, /* GL_HISTOGRAM_SINK */
+ 786, /* GL_MINMAX */
+ 788, /* GL_MINMAX_FORMAT */
+ 790, /* GL_MINMAX_SINK */
+ 1323, /* GL_TABLE_TOO_LARGE_EXT */
+ 1530, /* GL_UNSIGNED_BYTE_3_3_2 */
+ 1539, /* GL_UNSIGNED_SHORT_4_4_4_4 */
+ 1541, /* GL_UNSIGNED_SHORT_5_5_5_1 */
+ 1535, /* GL_UNSIGNED_INT_8_8_8_8 */
+ 1532, /* GL_UNSIGNED_INT_10_10_10_2 */
+ 1007, /* GL_POLYGON_OFFSET_FILL */
+ 1006, /* GL_POLYGON_OFFSET_FACTOR */
+ 1005, /* GL_POLYGON_OFFSET_BIAS */
+ 1150, /* GL_RESCALE_NORMAL */
+ 32, /* GL_ALPHA4 */
+ 34, /* GL_ALPHA8 */
+ 28, /* GL_ALPHA12 */
+ 30, /* GL_ALPHA16 */
+ 593, /* GL_LUMINANCE4 */
+ 599, /* GL_LUMINANCE8 */
+ 583, /* GL_LUMINANCE12 */
+ 589, /* GL_LUMINANCE16 */
+ 594, /* GL_LUMINANCE4_ALPHA4 */
+ 597, /* GL_LUMINANCE6_ALPHA2 */
+ 600, /* GL_LUMINANCE8_ALPHA8 */
+ 586, /* GL_LUMINANCE12_ALPHA4 */
+ 584, /* GL_LUMINANCE12_ALPHA12 */
+ 590, /* GL_LUMINANCE16_ALPHA16 */
+ 512, /* GL_INTENSITY */
+ 517, /* GL_INTENSITY4 */
+ 519, /* GL_INTENSITY8 */
+ 513, /* GL_INTENSITY12 */
+ 515, /* GL_INTENSITY16 */
+ 1162, /* GL_RGB2_EXT */
+ 1163, /* GL_RGB4 */
+ 1166, /* GL_RGB5 */
+ 1170, /* GL_RGB8 */
+ 1154, /* GL_RGB10 */
+ 1158, /* GL_RGB12 */
+ 1160, /* GL_RGB16 */
+ 1177, /* GL_RGBA2 */
+ 1179, /* GL_RGBA4 */
+ 1167, /* GL_RGB5_A1 */
+ 1183, /* GL_RGBA8 */
+ 1155, /* GL_RGB10_A2 */
+ 1173, /* GL_RGBA12 */
+ 1175, /* GL_RGBA16 */
+ 1492, /* GL_TEXTURE_RED_SIZE */
+ 1464, /* GL_TEXTURE_GREEN_SIZE */
+ 1403, /* GL_TEXTURE_BLUE_SIZE */
+ 1392, /* GL_TEXTURE_ALPHA_SIZE */
+ 1477, /* GL_TEXTURE_LUMINANCE_SIZE */
+ 1468, /* GL_TEXTURE_INTENSITY_SIZE */
+ 1148, /* GL_REPLACE_EXT */
+ 1100, /* GL_PROXY_TEXTURE_1D */
+ 1102, /* GL_PROXY_TEXTURE_2D */
+ 1496, /* GL_TEXTURE_TOO_LARGE_EXT */
+ 1489, /* GL_TEXTURE_PRIORITY */
+ 1494, /* GL_TEXTURE_RESIDENT */
+ 1395, /* GL_TEXTURE_BINDING_1D */
+ 1396, /* GL_TEXTURE_BINDING_2D */
+ 1397, /* GL_TEXTURE_BINDING_3D */
+ 932, /* GL_PACK_SKIP_IMAGES */
+ 928, /* GL_PACK_IMAGE_HEIGHT */
+ 1524, /* GL_UNPACK_SKIP_IMAGES */
+ 1521, /* GL_UNPACK_IMAGE_HEIGHT */
+ 1391, /* GL_TEXTURE_3D */
+ 1104, /* GL_PROXY_TEXTURE_3D */
+ 1451, /* GL_TEXTURE_DEPTH */
+ 1499, /* GL_TEXTURE_WRAP_R */
+ 708, /* GL_MAX_3D_TEXTURE_SIZE */
+ 1552, /* GL_VERTEX_ARRAY */
+ 863, /* GL_NORMAL_ARRAY */
+ 129, /* GL_COLOR_ARRAY */
+ 498, /* GL_INDEX_ARRAY */
+ 1430, /* GL_TEXTURE_COORD_ARRAY */
+ 368, /* GL_EDGE_FLAG_ARRAY */
+ 1556, /* GL_VERTEX_ARRAY_SIZE */
+ 1558, /* GL_VERTEX_ARRAY_TYPE */
+ 1557, /* GL_VERTEX_ARRAY_STRIDE */
+ 868, /* GL_NORMAL_ARRAY_TYPE */
+ 867, /* GL_NORMAL_ARRAY_STRIDE */
+ 133, /* GL_COLOR_ARRAY_SIZE */
+ 135, /* GL_COLOR_ARRAY_TYPE */
+ 134, /* GL_COLOR_ARRAY_STRIDE */
+ 503, /* GL_INDEX_ARRAY_TYPE */
+ 502, /* GL_INDEX_ARRAY_STRIDE */
+ 1434, /* GL_TEXTURE_COORD_ARRAY_SIZE */
+ 1436, /* GL_TEXTURE_COORD_ARRAY_TYPE */
+ 1435, /* GL_TEXTURE_COORD_ARRAY_STRIDE */
+ 372, /* GL_EDGE_FLAG_ARRAY_STRIDE */
+ 1555, /* GL_VERTEX_ARRAY_POINTER */
+ 866, /* GL_NORMAL_ARRAY_POINTER */
+ 132, /* GL_COLOR_ARRAY_POINTER */
+ 501, /* GL_INDEX_ARRAY_POINTER */
+ 1433, /* GL_TEXTURE_COORD_ARRAY_POINTER */
+ 371, /* GL_EDGE_FLAG_ARRAY_POINTER */
+ 842, /* GL_MULTISAMPLE */
+ 1199, /* GL_SAMPLE_ALPHA_TO_COVERAGE */
+ 1201, /* GL_SAMPLE_ALPHA_TO_ONE */
+ 1206, /* GL_SAMPLE_COVERAGE */
+ 1203, /* GL_SAMPLE_BUFFERS */
+ 1194, /* GL_SAMPLES */
+ 1210, /* GL_SAMPLE_COVERAGE_VALUE */
+ 1208, /* GL_SAMPLE_COVERAGE_INVERT */
+ 160, /* GL_COLOR_MATRIX */
+ 162, /* GL_COLOR_MATRIX_STACK_DEPTH */
+ 715, /* GL_MAX_COLOR_MATRIX_STACK_DEPTH */
+ 1032, /* GL_POST_COLOR_MATRIX_RED_SCALE */
+ 1028, /* GL_POST_COLOR_MATRIX_GREEN_SCALE */
+ 1023, /* GL_POST_COLOR_MATRIX_BLUE_SCALE */
+ 1019, /* GL_POST_COLOR_MATRIX_ALPHA_SCALE */
+ 1030, /* GL_POST_COLOR_MATRIX_RED_BIAS */
+ 1026, /* GL_POST_COLOR_MATRIX_GREEN_BIAS */
+ 1021, /* GL_POST_COLOR_MATRIX_BLUE_BIAS */
+ 1017, /* GL_POST_COLOR_MATRIX_ALPHA_BIAS */
+ 1413, /* GL_TEXTURE_COLOR_TABLE_SGI */
+ 1105, /* GL_PROXY_TEXTURE_COLOR_TABLE_SGI */
+ 1415, /* GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
+ 75, /* GL_BLEND_DST_RGB */
+ 82, /* GL_BLEND_SRC_RGB */
+ 74, /* GL_BLEND_DST_ALPHA */
+ 81, /* GL_BLEND_SRC_ALPHA */
+ 166, /* GL_COLOR_TABLE */
+ 1042, /* GL_POST_CONVOLUTION_COLOR_TABLE */
+ 1025, /* GL_POST_COLOR_MATRIX_COLOR_TABLE */
+ 1095, /* GL_PROXY_COLOR_TABLE */
+ 1099, /* GL_PROXY_POST_CONVOLUTION_COLOR_TABLE */
+ 1098, /* GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE */
+ 182, /* GL_COLOR_TABLE_SCALE */
+ 169, /* GL_COLOR_TABLE_BIAS */
+ 172, /* GL_COLOR_TABLE_FORMAT */
+ 183, /* GL_COLOR_TABLE_WIDTH */
+ 180, /* GL_COLOR_TABLE_RED_SIZE */
+ 174, /* GL_COLOR_TABLE_GREEN_SIZE */
+ 170, /* GL_COLOR_TABLE_BLUE_SIZE */
+ 167, /* GL_COLOR_TABLE_ALPHA_SIZE */
+ 178, /* GL_COLOR_TABLE_LUMINANCE_SIZE */
+ 176, /* GL_COLOR_TABLE_INTENSITY_SIZE */
+ 66, /* GL_BGR */
+ 67, /* GL_BGRA */
+ 727, /* GL_MAX_ELEMENTS_VERTICES */
+ 726, /* GL_MAX_ELEMENTS_INDICES */
+ 1467, /* GL_TEXTURE_INDEX_SIZE_EXT */
+ 126, /* GL_CLIP_VOLUME_CLIPPING_HINT_EXT */
+ 990, /* GL_POINT_SIZE_MIN */
+ 986, /* GL_POINT_SIZE_MAX */
+ 980, /* GL_POINT_FADE_THRESHOLD_SIZE */
+ 976, /* GL_POINT_DISTANCE_ATTENUATION */
+ 108, /* GL_CLAMP_TO_BORDER */
+ 111, /* GL_CLAMP_TO_EDGE */
+ 1488, /* GL_TEXTURE_MIN_LOD */
+ 1486, /* GL_TEXTURE_MAX_LOD */
+ 1394, /* GL_TEXTURE_BASE_LEVEL */
+ 1485, /* GL_TEXTURE_MAX_LEVEL */
+ 492, /* GL_IGNORE_BORDER_HP */
+ 224, /* GL_CONSTANT_BORDER_HP */
+ 1149, /* GL_REPLICATE_BORDER_HP */
+ 230, /* GL_CONVOLUTION_BORDER_COLOR */
+ 891, /* GL_OCCLUSION_TEST_HP */
+ 892, /* GL_OCCLUSION_TEST_RESULT_HP */
+ 557, /* GL_LINEAR_CLIPMAP_LINEAR_SGIX */
+ 1407, /* GL_TEXTURE_CLIPMAP_CENTER_SGIX */
+ 1409, /* GL_TEXTURE_CLIPMAP_FRAME_SGIX */
+ 1411, /* GL_TEXTURE_CLIPMAP_OFFSET_SGIX */
+ 1412, /* GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX */
+ 1410, /* GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX */
+ 1408, /* GL_TEXTURE_CLIPMAP_DEPTH_SGIX */
+ 711, /* GL_MAX_CLIPMAP_DEPTH_SGIX */
+ 712, /* GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX */
+ 1052, /* GL_POST_TEXTURE_FILTER_BIAS_SGIX */
+ 1054, /* GL_POST_TEXTURE_FILTER_SCALE_SGIX */
+ 1051, /* GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX */
+ 1053, /* GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX */
+ 1475, /* GL_TEXTURE_LOD_BIAS_S_SGIX */
+ 1476, /* GL_TEXTURE_LOD_BIAS_T_SGIX */
+ 1474, /* GL_TEXTURE_LOD_BIAS_R_SGIX */
+ 462, /* GL_GENERATE_MIPMAP */
+ 463, /* GL_GENERATE_MIPMAP_HINT */
+ 428, /* GL_FOG_OFFSET_SGIX */
+ 429, /* GL_FOG_OFFSET_VALUE_SGIX */
+ 1421, /* GL_TEXTURE_COMPARE_SGIX */
+ 1420, /* GL_TEXTURE_COMPARE_OPERATOR_SGIX */
+ 1471, /* GL_TEXTURE_LEQUAL_R_SGIX */
+ 1463, /* GL_TEXTURE_GEQUAL_R_SGIX */
+ 294, /* GL_DEPTH_COMPONENT16 */
+ 297, /* GL_DEPTH_COMPONENT24 */
+ 300, /* GL_DEPTH_COMPONENT32 */
+ 251, /* GL_CULL_VERTEX_EXT */
+ 253, /* GL_CULL_VERTEX_OBJECT_POSITION_EXT */
+ 252, /* GL_CULL_VERTEX_EYE_POSITION_EXT */
+ 1603, /* GL_WRAP_BORDER_SUN */
+ 1414, /* GL_TEXTURE_COLOR_WRITEMASK_SGIS */
+ 550, /* GL_LIGHT_MODEL_COLOR_CONTROL */
+ 1235, /* GL_SINGLE_COLOR */
+ 1226, /* GL_SEPARATE_SPECULAR_COLOR */
+ 1232, /* GL_SHARED_TEXTURE_PALETTE_EXT */
+ 1529, /* GL_UNSIGNED_BYTE_2_3_3_REV */
+ 1542, /* GL_UNSIGNED_SHORT_5_6_5 */
+ 1543, /* GL_UNSIGNED_SHORT_5_6_5_REV */
+ 1540, /* GL_UNSIGNED_SHORT_4_4_4_4_REV */
+ 1538, /* GL_UNSIGNED_SHORT_1_5_5_5_REV */
+ 1536, /* GL_UNSIGNED_INT_8_8_8_8_REV */
+ 1534, /* GL_UNSIGNED_INT_2_10_10_10_REV */
+ 1483, /* GL_TEXTURE_MAX_CLAMP_S_SGIX */
+ 1484, /* GL_TEXTURE_MAX_CLAMP_T_SGIX */
+ 1482, /* GL_TEXTURE_MAX_CLAMP_R_SGIX */
+ 793, /* GL_MIRRORED_REPEAT */
+ 1188, /* GL_RGB_S3TC */
+ 1165, /* GL_RGB4_S3TC */
+ 1187, /* GL_RGBA_S3TC */
+ 1182, /* GL_RGBA4_S3TC */
+ 1185, /* GL_RGBA_DXT5_S3TC */
+ 1180, /* GL_RGBA4_DXT5_S3TC */
+ 217, /* GL_COMPRESSED_RGB_S3TC_DXT1_EXT */
+ 212, /* GL_COMPRESSED_RGBA_S3TC_DXT1_EXT */
+ 213, /* GL_COMPRESSED_RGBA_S3TC_DXT3_EXT */
+ 214, /* GL_COMPRESSED_RGBA_S3TC_DXT5_EXT */
+ 854, /* GL_NEAREST_CLIPMAP_NEAREST_SGIX */
+ 853, /* GL_NEAREST_CLIPMAP_LINEAR_SGIX */
+ 558, /* GL_LINEAR_CLIPMAP_NEAREST_SGIX */
+ 415, /* GL_FOG_COORDINATE_SOURCE */
+ 407, /* GL_FOG_COORD */
+ 431, /* GL_FRAGMENT_DEPTH */
+ 257, /* GL_CURRENT_FOG_COORD */
+ 414, /* GL_FOG_COORDINATE_ARRAY_TYPE */
+ 413, /* GL_FOG_COORDINATE_ARRAY_STRIDE */
+ 412, /* GL_FOG_COORDINATE_ARRAY_POINTER */
+ 409, /* GL_FOG_COORDINATE_ARRAY */
+ 164, /* GL_COLOR_SUM */
+ 275, /* GL_CURRENT_SECONDARY_COLOR */
+ 1219, /* GL_SECONDARY_COLOR_ARRAY_SIZE */
+ 1221, /* GL_SECONDARY_COLOR_ARRAY_TYPE */
+ 1220, /* GL_SECONDARY_COLOR_ARRAY_STRIDE */
+ 1218, /* GL_SECONDARY_COLOR_ARRAY_POINTER */
+ 1215, /* GL_SECONDARY_COLOR_ARRAY */
+ 24, /* GL_ALIASED_POINT_SIZE_RANGE */
+ 23, /* GL_ALIASED_LINE_WIDTH_RANGE */
+ 1325, /* GL_TEXTURE0 */
+ 1327, /* GL_TEXTURE1 */
+ 1349, /* GL_TEXTURE2 */
+ 1371, /* GL_TEXTURE3 */
+ 1377, /* GL_TEXTURE4 */
+ 1379, /* GL_TEXTURE5 */
+ 1381, /* GL_TEXTURE6 */
+ 1383, /* GL_TEXTURE7 */
+ 1385, /* GL_TEXTURE8 */
+ 1387, /* GL_TEXTURE9 */
+ 1328, /* GL_TEXTURE10 */
+ 1330, /* GL_TEXTURE11 */
+ 1332, /* GL_TEXTURE12 */
+ 1334, /* GL_TEXTURE13 */
+ 1336, /* GL_TEXTURE14 */
+ 1338, /* GL_TEXTURE15 */
+ 1340, /* GL_TEXTURE16 */
+ 1342, /* GL_TEXTURE17 */
+ 1344, /* GL_TEXTURE18 */
+ 1346, /* GL_TEXTURE19 */
+ 1350, /* GL_TEXTURE20 */
+ 1352, /* GL_TEXTURE21 */
+ 1354, /* GL_TEXTURE22 */
+ 1356, /* GL_TEXTURE23 */
+ 1358, /* GL_TEXTURE24 */
+ 1360, /* GL_TEXTURE25 */
+ 1362, /* GL_TEXTURE26 */
+ 1364, /* GL_TEXTURE27 */
+ 1366, /* GL_TEXTURE28 */
+ 1368, /* GL_TEXTURE29 */
+ 1372, /* GL_TEXTURE30 */
+ 1374, /* GL_TEXTURE31 */
+ 16, /* GL_ACTIVE_TEXTURE */
+ 114, /* GL_CLIENT_ACTIVE_TEXTURE */
+ 775, /* GL_MAX_TEXTURE_UNITS */
+ 1508, /* GL_TRANSPOSE_MODELVIEW_MATRIX */
+ 1511, /* GL_TRANSPOSE_PROJECTION_MATRIX */
+ 1513, /* GL_TRANSPOSE_TEXTURE_MATRIX */
+ 1505, /* GL_TRANSPOSE_COLOR_MATRIX */
+ 1313, /* GL_SUBTRACT */
+ 766, /* GL_MAX_RENDERBUFFER_SIZE_EXT */
+ 200, /* GL_COMPRESSED_ALPHA */
+ 204, /* GL_COMPRESSED_LUMINANCE */
+ 205, /* GL_COMPRESSED_LUMINANCE_ALPHA */
+ 202, /* GL_COMPRESSED_INTENSITY */
+ 208, /* GL_COMPRESSED_RGB */
+ 209, /* GL_COMPRESSED_RGBA */
+ 1428, /* GL_TEXTURE_COMPRESSION_HINT */
+ 1490, /* GL_TEXTURE_RECTANGLE_ARB */
+ 1400, /* GL_TEXTURE_BINDING_RECTANGLE_ARB */
+ 1108, /* GL_PROXY_TEXTURE_RECTANGLE_ARB */
+ 764, /* GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB */
+ 306, /* GL_DEPTH_STENCIL_NV */
+ 1533, /* GL_UNSIGNED_INT_24_8_NV */
+ 771, /* GL_MAX_TEXTURE_LOD_BIAS */
+ 1481, /* GL_TEXTURE_MAX_ANISOTROPY_EXT */
+ 772, /* GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT */
+ 1457, /* GL_TEXTURE_FILTER_CONTROL */
+ 1472, /* GL_TEXTURE_LOD_BIAS */
+ 187, /* GL_COMBINE4 */
+ 767, /* GL_MAX_SHININESS_NV */
+ 768, /* GL_MAX_SPOT_EXPONENT_NV */
+ 496, /* GL_INCR_WRAP */
+ 282, /* GL_DECR_WRAP */
+ 813, /* GL_MODELVIEW1_ARB */
+ 869, /* GL_NORMAL_MAP */
+ 1135, /* GL_REFLECTION_MAP */
+ 1437, /* GL_TEXTURE_CUBE_MAP */
+ 1398, /* GL_TEXTURE_BINDING_CUBE_MAP */
+ 1445, /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */
+ 1439, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_X */
+ 1447, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Y */
+ 1441, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Y */
+ 1449, /* GL_TEXTURE_CUBE_MAP_POSITIVE_Z */
+ 1443, /* GL_TEXTURE_CUBE_MAP_NEGATIVE_Z */
+ 1106, /* GL_PROXY_TEXTURE_CUBE_MAP */
+ 722, /* GL_MAX_CUBE_MAP_TEXTURE_SIZE */
+ 848, /* GL_MULTISAMPLE_FILTER_HINT_NV */
+ 423, /* GL_FOG_DISTANCE_MODE_NV */
+ 388, /* GL_EYE_RADIAL_NV */
+ 387, /* GL_EYE_PLANE_ABSOLUTE_NV */
+ 186, /* GL_COMBINE */
+ 193, /* GL_COMBINE_RGB */
+ 188, /* GL_COMBINE_ALPHA */
+ 1189, /* GL_RGB_SCALE */
+ 20, /* GL_ADD_SIGNED */
+ 522, /* GL_INTERPOLATE */
+ 219, /* GL_CONSTANT */
+ 1058, /* GL_PRIMARY_COLOR */
+ 1055, /* GL_PREVIOUS */
+ 1246, /* GL_SOURCE0_RGB */
+ 1252, /* GL_SOURCE1_RGB */
+ 1258, /* GL_SOURCE2_RGB */
+ 1262, /* GL_SOURCE3_RGB_NV */
+ 1243, /* GL_SOURCE0_ALPHA */
+ 1249, /* GL_SOURCE1_ALPHA */
+ 1255, /* GL_SOURCE2_ALPHA */
+ 1261, /* GL_SOURCE3_ALPHA_NV */
+ 905, /* GL_OPERAND0_RGB */
+ 911, /* GL_OPERAND1_RGB */
+ 917, /* GL_OPERAND2_RGB */
+ 921, /* GL_OPERAND3_RGB_NV */
+ 902, /* GL_OPERAND0_ALPHA */
+ 908, /* GL_OPERAND1_ALPHA */
+ 914, /* GL_OPERAND2_ALPHA */
+ 920, /* GL_OPERAND3_ALPHA_NV */
+ 1607, /* GL_YCBCR_422_APPLE */
+ 1544, /* GL_UNSIGNED_SHORT_8_8_APPLE */
+ 1546, /* GL_UNSIGNED_SHORT_8_8_REV_APPLE */
+ 1237, /* GL_SLICE_ACCUM_SUN */
+ 1113, /* GL_QUAD_MESH_SUN */
+ 1517, /* GL_TRIANGLE_MESH_SUN */
+ 1584, /* GL_VERTEX_PROGRAM_ARB */
+ 1592, /* GL_VERTEX_STATE_PROGRAM_NV */
+ 1577, /* GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB */
+ 1580, /* GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB */
+ 1581, /* GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB */
+ 1582, /* GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB */
+ 277, /* GL_CURRENT_VERTEX_ATTRIB_ARB */
+ 1071, /* GL_PROGRAM_LENGTH_ARB */
+ 1085, /* GL_PROGRAM_STRING_ARB */
+ 835, /* GL_MODELVIEW_PROJECTION_NV */
+ 491, /* GL_IDENTITY_NV */
+ 532, /* GL_INVERSE_NV */
+ 1510, /* GL_TRANSPOSE_NV */
+ 533, /* GL_INVERSE_TRANSPOSE_NV */
+ 750, /* GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB */
+ 749, /* GL_MAX_PROGRAM_MATRICES_ARB */
+ 661, /* GL_MATRIX0_NV */
+ 673, /* GL_MATRIX1_NV */
+ 685, /* GL_MATRIX2_NV */
+ 689, /* GL_MATRIX3_NV */
+ 691, /* GL_MATRIX4_NV */
+ 693, /* GL_MATRIX5_NV */
+ 695, /* GL_MATRIX6_NV */
+ 697, /* GL_MATRIX7_NV */
+ 263, /* GL_CURRENT_MATRIX_STACK_DEPTH_ARB */
+ 260, /* GL_CURRENT_MATRIX_ARB */
+ 1587, /* GL_VERTEX_PROGRAM_POINT_SIZE_ARB */
+ 1589, /* GL_VERTEX_PROGRAM_TWO_SIDE_ARB */
+ 1083, /* GL_PROGRAM_PARAMETER_NV */
+ 1579, /* GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB */
+ 1087, /* GL_PROGRAM_TARGET_NV */
+ 1084, /* GL_PROGRAM_RESIDENT_NV */
+ 1502, /* GL_TRACK_MATRIX_NV */
+ 1503, /* GL_TRACK_MATRIX_TRANSFORM_NV */
+ 1585, /* GL_VERTEX_PROGRAM_BINDING_NV */
+ 1065, /* GL_PROGRAM_ERROR_POSITION_ARB */
+ 291, /* GL_DEPTH_CLAMP_NV */
+ 1559, /* GL_VERTEX_ATTRIB_ARRAY0_NV */
+ 1566, /* GL_VERTEX_ATTRIB_ARRAY1_NV */
+ 1567, /* GL_VERTEX_ATTRIB_ARRAY2_NV */
+ 1568, /* GL_VERTEX_ATTRIB_ARRAY3_NV */
+ 1569, /* GL_VERTEX_ATTRIB_ARRAY4_NV */
+ 1570, /* GL_VERTEX_ATTRIB_ARRAY5_NV */
+ 1571, /* GL_VERTEX_ATTRIB_ARRAY6_NV */
+ 1572, /* GL_VERTEX_ATTRIB_ARRAY7_NV */
+ 1573, /* GL_VERTEX_ATTRIB_ARRAY8_NV */
+ 1574, /* GL_VERTEX_ATTRIB_ARRAY9_NV */
+ 1560, /* GL_VERTEX_ATTRIB_ARRAY10_NV */
+ 1561, /* GL_VERTEX_ATTRIB_ARRAY11_NV */
+ 1562, /* GL_VERTEX_ATTRIB_ARRAY12_NV */
+ 1563, /* GL_VERTEX_ATTRIB_ARRAY13_NV */
+ 1564, /* GL_VERTEX_ATTRIB_ARRAY14_NV */
+ 1565, /* GL_VERTEX_ATTRIB_ARRAY15_NV */
+ 615, /* GL_MAP1_VERTEX_ATTRIB0_4_NV */
+ 622, /* GL_MAP1_VERTEX_ATTRIB1_4_NV */
+ 623, /* GL_MAP1_VERTEX_ATTRIB2_4_NV */
+ 624, /* GL_MAP1_VERTEX_ATTRIB3_4_NV */
+ 625, /* GL_MAP1_VERTEX_ATTRIB4_4_NV */
+ 626, /* GL_MAP1_VERTEX_ATTRIB5_4_NV */
+ 627, /* GL_MAP1_VERTEX_ATTRIB6_4_NV */
+ 628, /* GL_MAP1_VERTEX_ATTRIB7_4_NV */
+ 629, /* GL_MAP1_VERTEX_ATTRIB8_4_NV */
+ 630, /* GL_MAP1_VERTEX_ATTRIB9_4_NV */
+ 616, /* GL_MAP1_VERTEX_ATTRIB10_4_NV */
+ 617, /* GL_MAP1_VERTEX_ATTRIB11_4_NV */
+ 618, /* GL_MAP1_VERTEX_ATTRIB12_4_NV */
+ 619, /* GL_MAP1_VERTEX_ATTRIB13_4_NV */
+ 620, /* GL_MAP1_VERTEX_ATTRIB14_4_NV */
+ 621, /* GL_MAP1_VERTEX_ATTRIB15_4_NV */
+ 642, /* GL_MAP2_VERTEX_ATTRIB0_4_NV */
+ 649, /* GL_MAP2_VERTEX_ATTRIB1_4_NV */
+ 650, /* GL_MAP2_VERTEX_ATTRIB2_4_NV */
+ 651, /* GL_MAP2_VERTEX_ATTRIB3_4_NV */
+ 652, /* GL_MAP2_VERTEX_ATTRIB4_4_NV */
+ 653, /* GL_MAP2_VERTEX_ATTRIB5_4_NV */
+ 654, /* GL_MAP2_VERTEX_ATTRIB6_4_NV */
+ 1064, /* GL_PROGRAM_BINDING_ARB */
+ 656, /* GL_MAP2_VERTEX_ATTRIB8_4_NV */
+ 657, /* GL_MAP2_VERTEX_ATTRIB9_4_NV */
+ 643, /* GL_MAP2_VERTEX_ATTRIB10_4_NV */
+ 644, /* GL_MAP2_VERTEX_ATTRIB11_4_NV */
+ 645, /* GL_MAP2_VERTEX_ATTRIB12_4_NV */
+ 646, /* GL_MAP2_VERTEX_ATTRIB13_4_NV */
+ 647, /* GL_MAP2_VERTEX_ATTRIB14_4_NV */
+ 648, /* GL_MAP2_VERTEX_ATTRIB15_4_NV */
+ 1426, /* GL_TEXTURE_COMPRESSED_IMAGE_SIZE */
+ 1423, /* GL_TEXTURE_COMPRESSED */
+ 874, /* GL_NUM_COMPRESSED_TEXTURE_FORMATS */
+ 218, /* GL_COMPRESSED_TEXTURE_FORMATS */
+ 783, /* GL_MAX_VERTEX_UNITS_ARB */
+ 18, /* GL_ACTIVE_VERTEX_UNITS_ARB */
+ 1602, /* GL_WEIGHT_SUM_UNITY_ARB */
+ 1583, /* GL_VERTEX_BLEND_ARB */
+ 278, /* GL_CURRENT_WEIGHT_ARB */
+ 1601, /* GL_WEIGHT_ARRAY_TYPE_ARB */
+ 1600, /* GL_WEIGHT_ARRAY_STRIDE_ARB */
+ 1599, /* GL_WEIGHT_ARRAY_SIZE_ARB */
+ 1598, /* GL_WEIGHT_ARRAY_POINTER_ARB */
+ 1595, /* GL_WEIGHT_ARRAY_ARB */
+ 317, /* GL_DOT3_RGB */
+ 318, /* GL_DOT3_RGBA */
+ 216, /* GL_COMPRESSED_RGB_FXT1_3DFX */
+ 211, /* GL_COMPRESSED_RGBA_FXT1_3DFX */
+ 843, /* GL_MULTISAMPLE_3DFX */
+ 1204, /* GL_SAMPLE_BUFFERS_3DFX */
+ 1195, /* GL_SAMPLES_3DFX */
+ 824, /* GL_MODELVIEW2_ARB */
+ 827, /* GL_MODELVIEW3_ARB */
+ 828, /* GL_MODELVIEW4_ARB */
+ 829, /* GL_MODELVIEW5_ARB */
+ 830, /* GL_MODELVIEW6_ARB */
+ 831, /* GL_MODELVIEW7_ARB */
+ 832, /* GL_MODELVIEW8_ARB */
+ 833, /* GL_MODELVIEW9_ARB */
+ 803, /* GL_MODELVIEW10_ARB */
+ 804, /* GL_MODELVIEW11_ARB */
+ 805, /* GL_MODELVIEW12_ARB */
+ 806, /* GL_MODELVIEW13_ARB */
+ 807, /* GL_MODELVIEW14_ARB */
+ 808, /* GL_MODELVIEW15_ARB */
+ 809, /* GL_MODELVIEW16_ARB */
+ 810, /* GL_MODELVIEW17_ARB */
+ 811, /* GL_MODELVIEW18_ARB */
+ 812, /* GL_MODELVIEW19_ARB */
+ 814, /* GL_MODELVIEW20_ARB */
+ 815, /* GL_MODELVIEW21_ARB */
+ 816, /* GL_MODELVIEW22_ARB */
+ 817, /* GL_MODELVIEW23_ARB */
+ 818, /* GL_MODELVIEW24_ARB */
+ 819, /* GL_MODELVIEW25_ARB */
+ 820, /* GL_MODELVIEW26_ARB */
+ 821, /* GL_MODELVIEW27_ARB */
+ 822, /* GL_MODELVIEW28_ARB */
+ 823, /* GL_MODELVIEW29_ARB */
+ 825, /* GL_MODELVIEW30_ARB */
+ 826, /* GL_MODELVIEW31_ARB */
+ 322, /* GL_DOT3_RGB_EXT */
+ 320, /* GL_DOT3_RGBA_EXT */
+ 797, /* GL_MIRROR_CLAMP_EXT */
+ 800, /* GL_MIRROR_CLAMP_TO_EDGE_EXT */
+ 838, /* GL_MODULATE_ADD_ATI */
+ 839, /* GL_MODULATE_SIGNED_ADD_ATI */
+ 840, /* GL_MODULATE_SUBTRACT_ATI */
+ 1608, /* GL_YCBCR_MESA */
+ 929, /* GL_PACK_INVERT_MESA */
+ 97, /* GL_BUFFER_SIZE */
+ 99, /* GL_BUFFER_USAGE */
+ 432, /* GL_FRAGMENT_PROGRAM_ARB */
+ 1062, /* GL_PROGRAM_ALU_INSTRUCTIONS_ARB */
+ 1090, /* GL_PROGRAM_TEX_INSTRUCTIONS_ARB */
+ 1089, /* GL_PROGRAM_TEX_INDIRECTIONS_ARB */
+ 1074, /* GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
+ 1080, /* GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
+ 1079, /* GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
+ 739, /* GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB */
+ 762, /* GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB */
+ 761, /* GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB */
+ 752, /* GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB */
+ 758, /* GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB */
+ 757, /* GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB */
+ 724, /* GL_MAX_DRAW_BUFFERS_ARB */
+ 326, /* GL_DRAW_BUFFER0_ARB */
+ 340, /* GL_DRAW_BUFFER1_ARB */
+ 342, /* GL_DRAW_BUFFER2_ARB */
+ 344, /* GL_DRAW_BUFFER3_ARB */
+ 346, /* GL_DRAW_BUFFER4_ARB */
+ 348, /* GL_DRAW_BUFFER5_ARB */
+ 350, /* GL_DRAW_BUFFER6_ARB */
+ 352, /* GL_DRAW_BUFFER7_ARB */
+ 354, /* GL_DRAW_BUFFER8_ARB */
+ 356, /* GL_DRAW_BUFFER9_ARB */
+ 328, /* GL_DRAW_BUFFER10_ARB */
+ 330, /* GL_DRAW_BUFFER11_ARB */
+ 332, /* GL_DRAW_BUFFER12_ARB */
+ 334, /* GL_DRAW_BUFFER13_ARB */
+ 336, /* GL_DRAW_BUFFER14_ARB */
+ 338, /* GL_DRAW_BUFFER15_ARB */
+ 77, /* GL_BLEND_EQUATION_ALPHA_EXT */
+ 706, /* GL_MATRIX_PALETTE_ARB */
+ 733, /* GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB */
+ 736, /* GL_MAX_PALETTE_MATRICES_ARB */
+ 266, /* GL_CURRENT_PALETTE_MATRIX_ARB */
+ 700, /* GL_MATRIX_INDEX_ARRAY_ARB */
+ 261, /* GL_CURRENT_MATRIX_INDEX_ARB */
+ 702, /* GL_MATRIX_INDEX_ARRAY_SIZE_ARB */
+ 704, /* GL_MATRIX_INDEX_ARRAY_TYPE_ARB */
+ 703, /* GL_MATRIX_INDEX_ARRAY_STRIDE_ARB */
+ 701, /* GL_MATRIX_INDEX_ARRAY_POINTER_ARB */
+ 1452, /* GL_TEXTURE_DEPTH_SIZE */
+ 310, /* GL_DEPTH_TEXTURE_MODE */
+ 1418, /* GL_TEXTURE_COMPARE_MODE */
+ 1416, /* GL_TEXTURE_COMPARE_FUNC */
+ 196, /* GL_COMPARE_R_TO_TEXTURE */
+ 997, /* GL_POINT_SPRITE_ARB */
+ 244, /* GL_COORD_REPLACE_ARB */
+ 1000, /* GL_POINT_SPRITE_R_MODE_NV */
+ 1115, /* GL_QUERY_COUNTER_BITS */
+ 267, /* GL_CURRENT_QUERY */
+ 1117, /* GL_QUERY_RESULT */
+ 1119, /* GL_QUERY_RESULT_AVAILABLE */
+ 780, /* GL_MAX_VERTEX_ATTRIBS_ARB */
+ 1578, /* GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB */
+ 308, /* GL_DEPTH_STENCIL_TO_RGBA_NV */
+ 307, /* GL_DEPTH_STENCIL_TO_BGRA_NV */
+ 769, /* GL_MAX_TEXTURE_COORDS_ARB */
+ 770, /* GL_MAX_TEXTURE_IMAGE_UNITS_ARB */
+ 1067, /* GL_PROGRAM_ERROR_STRING_ARB */
+ 1069, /* GL_PROGRAM_FORMAT_ASCII_ARB */
+ 1068, /* GL_PROGRAM_FORMAT_ARB */
+ 1497, /* GL_TEXTURE_UNSIGNED_REMAP_MODE_NV */
+ 289, /* GL_DEPTH_BOUNDS_TEST_EXT */
+ 288, /* GL_DEPTH_BOUNDS_EXT */
+ 48, /* GL_ARRAY_BUFFER */
+ 373, /* GL_ELEMENT_ARRAY_BUFFER */
+ 50, /* GL_ARRAY_BUFFER_BINDING */
+ 375, /* GL_ELEMENT_ARRAY_BUFFER_BINDING */
+ 1553, /* GL_VERTEX_ARRAY_BUFFER_BINDING */
+ 864, /* GL_NORMAL_ARRAY_BUFFER_BINDING */
+ 130, /* GL_COLOR_ARRAY_BUFFER_BINDING */
+ 499, /* GL_INDEX_ARRAY_BUFFER_BINDING */
+ 1431, /* GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING */
+ 369, /* GL_EDGE_FLAG_ARRAY_BUFFER_BINDING */
+ 1216, /* GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING */
+ 410, /* GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING */
+ 1596, /* GL_WEIGHT_ARRAY_BUFFER_BINDING */
+ 1575, /* GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING */
+ 1070, /* GL_PROGRAM_INSTRUCTIONS_ARB */
+ 745, /* GL_MAX_PROGRAM_INSTRUCTIONS_ARB */
+ 1076, /* GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
+ 754, /* GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB */
+ 1088, /* GL_PROGRAM_TEMPORARIES_ARB */
+ 760, /* GL_MAX_PROGRAM_TEMPORARIES_ARB */
+ 1078, /* GL_PROGRAM_NATIVE_TEMPORARIES_ARB */
+ 756, /* GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB */
+ 1082, /* GL_PROGRAM_PARAMETERS_ARB */
+ 759, /* GL_MAX_PROGRAM_PARAMETERS_ARB */
+ 1077, /* GL_PROGRAM_NATIVE_PARAMETERS_ARB */
+ 755, /* GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB */
+ 1063, /* GL_PROGRAM_ATTRIBS_ARB */
+ 740, /* GL_MAX_PROGRAM_ATTRIBS_ARB */
+ 1075, /* GL_PROGRAM_NATIVE_ATTRIBS_ARB */
+ 753, /* GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB */
+ 1061, /* GL_PROGRAM_ADDRESS_REGISTERS_ARB */
+ 738, /* GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB */
+ 1073, /* GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
+ 751, /* GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB */
+ 746, /* GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB */
+ 742, /* GL_MAX_PROGRAM_ENV_PARAMETERS_ARB */
+ 1091, /* GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB */
+ 1507, /* GL_TRANSPOSE_CURRENT_MATRIX_ARB */
+ 1125, /* GL_READ_ONLY */
+ 1604, /* GL_WRITE_ONLY */
+ 1127, /* GL_READ_WRITE */
+ 91, /* GL_BUFFER_ACCESS */
+ 93, /* GL_BUFFER_MAPPED */
+ 95, /* GL_BUFFER_MAP_POINTER */
+ 660, /* GL_MATRIX0_ARB */
+ 672, /* GL_MATRIX1_ARB */
+ 684, /* GL_MATRIX2_ARB */
+ 688, /* GL_MATRIX3_ARB */
+ 690, /* GL_MATRIX4_ARB */
+ 692, /* GL_MATRIX5_ARB */
+ 694, /* GL_MATRIX6_ARB */
+ 696, /* GL_MATRIX7_ARB */
+ 698, /* GL_MATRIX8_ARB */
+ 699, /* GL_MATRIX9_ARB */
+ 662, /* GL_MATRIX10_ARB */
+ 663, /* GL_MATRIX11_ARB */
+ 664, /* GL_MATRIX12_ARB */
+ 665, /* GL_MATRIX13_ARB */
+ 666, /* GL_MATRIX14_ARB */
+ 667, /* GL_MATRIX15_ARB */
+ 668, /* GL_MATRIX16_ARB */
+ 669, /* GL_MATRIX17_ARB */
+ 670, /* GL_MATRIX18_ARB */
+ 671, /* GL_MATRIX19_ARB */
+ 674, /* GL_MATRIX20_ARB */
+ 675, /* GL_MATRIX21_ARB */
+ 676, /* GL_MATRIX22_ARB */
+ 677, /* GL_MATRIX23_ARB */
+ 678, /* GL_MATRIX24_ARB */
+ 679, /* GL_MATRIX25_ARB */
+ 680, /* GL_MATRIX26_ARB */
+ 681, /* GL_MATRIX27_ARB */
+ 682, /* GL_MATRIX28_ARB */
+ 683, /* GL_MATRIX29_ARB */
+ 686, /* GL_MATRIX30_ARB */
+ 687, /* GL_MATRIX31_ARB */
+ 1308, /* GL_STREAM_DRAW */
+ 1310, /* GL_STREAM_READ */
+ 1306, /* GL_STREAM_COPY */
+ 1281, /* GL_STATIC_DRAW */
+ 1283, /* GL_STATIC_READ */
+ 1279, /* GL_STATIC_COPY */
+ 363, /* GL_DYNAMIC_DRAW */
+ 365, /* GL_DYNAMIC_READ */
+ 361, /* GL_DYNAMIC_COPY */
+ 970, /* GL_PIXEL_PACK_BUFFER_EXT */
+ 972, /* GL_PIXEL_UNPACK_BUFFER_EXT */
+ 969, /* GL_PIXEL_PACK_BUFFER_BINDING_EXT */
+ 971, /* GL_PIXEL_UNPACK_BUFFER_BINDING_EXT */
+ 743, /* GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
+ 741, /* GL_MAX_PROGRAM_CALL_DEPTH_NV */
+ 744, /* GL_MAX_PROGRAM_IF_DEPTH_NV */
+ 748, /* GL_MAX_PROGRAM_LOOP_DEPTH_NV */
+ 747, /* GL_MAX_PROGRAM_LOOP_COUNT_NV */
+ 1302, /* GL_STENCIL_TEST_TWO_SIDE_EXT */
+ 15, /* GL_ACTIVE_STENCIL_FACE_EXT */
+ 798, /* GL_MIRROR_CLAMP_TO_BORDER_EXT */
+ 1197, /* GL_SAMPLES_PASSED */
+ 433, /* GL_FRAGMENT_SHADER_ARB */
+ 1591, /* GL_VERTEX_SHADER_ARB */
+ 1081, /* GL_PROGRAM_OBJECT_ARB */
+ 1229, /* GL_SHADER_OBJECT_ARB */
+ 730, /* GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB */
+ 782, /* GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB */
+ 779, /* GL_MAX_VARYING_FLOATS_ARB */
+ 781, /* GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */
+ 717, /* GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB */
+ 889, /* GL_OBJECT_TYPE_ARB */
+ 888, /* GL_OBJECT_SUBTYPE_ARB */
+ 401, /* GL_FLOAT_VEC2_ARB */
+ 402, /* GL_FLOAT_VEC3_ARB */
+ 403, /* GL_FLOAT_VEC4_ARB */
+ 525, /* GL_INT_VEC2_ARB */
+ 526, /* GL_INT_VEC3_ARB */
+ 527, /* GL_INT_VEC4_ARB */
+ 87, /* GL_BOOL_ARB */
+ 88, /* GL_BOOL_VEC2_ARB */
+ 89, /* GL_BOOL_VEC3_ARB */
+ 90, /* GL_BOOL_VEC4_ARB */
+ 398, /* GL_FLOAT_MAT2_ARB */
+ 399, /* GL_FLOAT_MAT3_ARB */
+ 400, /* GL_FLOAT_MAT4_ARB */
+ 882, /* GL_OBJECT_DELETE_STATUS_ARB */
+ 881, /* GL_OBJECT_COMPILE_STATUS_ARB */
+ 885, /* GL_OBJECT_LINK_STATUS_ARB */
+ 890, /* GL_OBJECT_VALIDATE_STATUS_ARB */
+ 883, /* GL_OBJECT_INFO_LOG_LENGTH_ARB */
+ 880, /* GL_OBJECT_ATTACHED_OBJECTS_ARB */
+ 878, /* GL_OBJECT_ACTIVE_UNIFORMS_ARB */
+ 879, /* GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB */
+ 887, /* GL_OBJECT_SHADER_SOURCE_LENGTH_ARB */
+ 876, /* GL_OBJECT_ACTIVE_ATTRIBUTES_ARB */
+ 877, /* GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB */
+ 938, /* GL_PALETTE4_RGB8_OES */
+ 940, /* GL_PALETTE4_RGBA8_OES */
+ 936, /* GL_PALETTE4_R5_G6_B5_OES */
+ 939, /* GL_PALETTE4_RGBA4_OES */
+ 937, /* GL_PALETTE4_RGB5_A1_OES */
+ 943, /* GL_PALETTE8_RGB8_OES */
+ 945, /* GL_PALETTE8_RGBA8_OES */
+ 941, /* GL_PALETTE8_R5_G6_B5_OES */
+ 944, /* GL_PALETTE8_RGBA4_OES */
+ 942, /* GL_PALETTE8_RGB5_A1_OES */
+ 494, /* GL_IMPLEMENTATION_COLOR_READ_TYPE_OES */
+ 493, /* GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES */
+ 998, /* GL_POINT_SPRITE_COORD_ORIGIN */
+ 439, /* GL_FRAMEBUFFER_BINDING_EXT */
+ 1139, /* GL_RENDERBUFFER_BINDING_EXT */
+ 435, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT */
+ 434, /* GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT */
+ 438, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT */
+ 437, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT */
+ 436, /* GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT */
+ 440, /* GL_FRAMEBUFFER_COMPLETE_EXT */
+ 442, /* GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT */
+ 447, /* GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT */
+ 445, /* GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT */
+ 443, /* GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT */
+ 446, /* GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT */
+ 444, /* GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT */
+ 448, /* GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT */
+ 450, /* GL_FRAMEBUFFER_UNSUPPORTED_EXT */
+ 449, /* GL_FRAMEBUFFER_STATUS_ERROR_EXT */
+ 714, /* GL_MAX_COLOR_ATTACHMENTS_EXT */
+ 136, /* GL_COLOR_ATTACHMENT0_EXT */
+ 143, /* GL_COLOR_ATTACHMENT1_EXT */
+ 144, /* GL_COLOR_ATTACHMENT2_EXT */
+ 145, /* GL_COLOR_ATTACHMENT3_EXT */
+ 146, /* GL_COLOR_ATTACHMENT4_EXT */
+ 147, /* GL_COLOR_ATTACHMENT5_EXT */
+ 148, /* GL_COLOR_ATTACHMENT6_EXT */
+ 149, /* GL_COLOR_ATTACHMENT7_EXT */
+ 150, /* GL_COLOR_ATTACHMENT8_EXT */
+ 151, /* GL_COLOR_ATTACHMENT9_EXT */
+ 137, /* GL_COLOR_ATTACHMENT10_EXT */
+ 138, /* GL_COLOR_ATTACHMENT11_EXT */
+ 139, /* GL_COLOR_ATTACHMENT12_EXT */
+ 140, /* GL_COLOR_ATTACHMENT13_EXT */
+ 141, /* GL_COLOR_ATTACHMENT14_EXT */
+ 142, /* GL_COLOR_ATTACHMENT15_EXT */
+ 285, /* GL_DEPTH_ATTACHMENT_EXT */
+ 1286, /* GL_STENCIL_ATTACHMENT_EXT */
+ 441, /* GL_FRAMEBUFFER_EXT */
+ 1140, /* GL_RENDERBUFFER_EXT */
+ 1143, /* GL_RENDERBUFFER_WIDTH_EXT */
+ 1141, /* GL_RENDERBUFFER_HEIGHT_EXT */
+ 1142, /* GL_RENDERBUFFER_INTERNAL_FORMAT_EXT */
+ 1297, /* GL_STENCIL_INDEX_EXT */
+ 1294, /* GL_STENCIL_INDEX1_EXT */
+ 1295, /* GL_STENCIL_INDEX4_EXT */
+ 1296, /* GL_STENCIL_INDEX8_EXT */
+ 1293, /* GL_STENCIL_INDEX16_EXT */
+ 381, /* GL_EVAL_BIT */
+ 1123, /* GL_RASTER_POSITION_UNCLIPPED_IBM */
+ 576, /* GL_LIST_BIT */
+ 1402, /* GL_TEXTURE_BIT */
+ 1212, /* GL_SCISSOR_BIT */
+ 25, /* GL_ALL_ATTRIB_BITS */
+ 845, /* GL_MULTISAMPLE_BIT */
+};
+
+#define Elements(x) sizeof(x)/sizeof(*x)
+
+typedef int (*cfunc)(const void *, const void *);
+
+/**
+ * Compare a key name to an element in the \c all_enums array.
+ *
+ * \c bsearch always passes the key as the first parameter and the pointer
+ * to the array element as the second parameter. We can elimiate some
+ * extra work by taking advantage of that fact.
+ *
+ * \param a Pointer to the desired enum name.
+ * \param b Pointer to an element of the \c all_enums array.
+ */
+static int compar_name( const char *a, const enum_elt *b )
+{
+ return _mesa_strcmp( a, & enum_string_table[ b->offset ] );
+}
+
+/**
+ * Compare a key enum value to an element in the \c all_enums array.
+ *
+ * \c bsearch always passes the key as the first parameter and the pointer
+ * to the array element as the second parameter. We can elimiate some
+ * extra work by taking advantage of that fact.
+ *
+ * \param a Pointer to the desired enum name.
+ * \param b Pointer to an index into the \c all_enums array.
+ */
+static int compar_nr( const int *a, const unsigned *b )
+{
+ return a[0] - all_enums[*b].n;
+}
+
+
+static char token_tmp[20];
+
+const char *_mesa_lookup_enum_by_nr( int nr )
+{
+ unsigned * i;
+
+ i = (unsigned *)bsearch( & nr, reduced_enums, Elements(reduced_enums),
+ sizeof(reduced_enums[0]), (cfunc) compar_nr );
+
+ if ( i != NULL ) {
+ return & enum_string_table[ all_enums[ *i ].offset ];
+ }
+ else {
+ /* this is not re-entrant safe, no big deal here */
+ _mesa_sprintf(token_tmp, "0x%x", nr);
+ return token_tmp;
+ }
+}
+
+int _mesa_lookup_enum_by_name( const char *symbol )
+{
+ enum_elt * f = NULL;
+
+ if ( symbol != NULL ) {
+ f = (enum_elt *)bsearch( symbol, all_enums, Elements(all_enums),
+ sizeof( enum_elt ), (cfunc) compar_name );
+ }
+
+ return (f != NULL) ? f->n : -1;
+}
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/main/enums.h b/nx-X11/extras/Mesa/src/mesa/main/enums.h
new file mode 100644
index 000000000..7e8d4ee94
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/enums.h
@@ -0,0 +1,55 @@
+/**
+ * \file enums.h
+ * Enumeration name/number lookup functions.
+ *
+ * \if subset
+ * (No-op)
+ *
+ * \endif
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+/* $XFree86: xc/extras/Mesa/src/mesa/main/enums.h,v 1.2 2004/06/23 19:40:14 tsi Exp $ */
+
+#ifndef _ENUMS_H_
+#define _ENUMS_H_
+
+
+#if defined(_HAVE_FULL_GL) && _HAVE_FULL_GL
+
+extern const char *_mesa_lookup_enum_by_nr( int nr );
+extern int _mesa_lookup_enum_by_name( const char *symbol );
+
+#else
+
+/** No-op */
+#define _mesa_lookup_enum_by_name( s ) 0
+
+/** No-op */
+#define _mesa_lookup_enum_by_nr( n ) "unknown"
+
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/eval.c b/nx-X11/extras/Mesa/src/mesa/main/eval.c
new file mode 100644
index 000000000..3f89f9c1e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/eval.c
@@ -0,0 +1,962 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+
+/*
+ * eval.c was written by
+ * Bernd Barsuhn (bdbarsuh@cip.informatik.uni-erlangen.de) and
+ * Volker Weiss (vrweiss@cip.informatik.uni-erlangen.de).
+ *
+ * My original implementation of evaluators was simplistic and didn't
+ * compute surface normal vectors properly. Bernd and Volker applied
+ * used more sophisticated methods to get better results.
+ *
+ * Thanks guys!
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "colormac.h"
+#include "context.h"
+#include "eval.h"
+#include "macros.h"
+#include "mtypes.h"
+
+
+/*
+ * Return the number of components per control point for any type of
+ * evaluator. Return 0 if bad target.
+ * See table 5.1 in the OpenGL 1.2 spec.
+ */
+GLuint _mesa_evaluator_components( GLenum target )
+{
+ switch (target) {
+ case GL_MAP1_VERTEX_3: return 3;
+ case GL_MAP1_VERTEX_4: return 4;
+ case GL_MAP1_INDEX: return 1;
+ case GL_MAP1_COLOR_4: return 4;
+ case GL_MAP1_NORMAL: return 3;
+ case GL_MAP1_TEXTURE_COORD_1: return 1;
+ case GL_MAP1_TEXTURE_COORD_2: return 2;
+ case GL_MAP1_TEXTURE_COORD_3: return 3;
+ case GL_MAP1_TEXTURE_COORD_4: return 4;
+ case GL_MAP2_VERTEX_3: return 3;
+ case GL_MAP2_VERTEX_4: return 4;
+ case GL_MAP2_INDEX: return 1;
+ case GL_MAP2_COLOR_4: return 4;
+ case GL_MAP2_NORMAL: return 3;
+ case GL_MAP2_TEXTURE_COORD_1: return 1;
+ case GL_MAP2_TEXTURE_COORD_2: return 2;
+ case GL_MAP2_TEXTURE_COORD_3: return 3;
+ case GL_MAP2_TEXTURE_COORD_4: return 4;
+ default: break;
+ }
+
+ /* XXX need to check for the vertex program extension
+ if (!ctx->Extensions.NV_vertex_program)
+ return 0;
+ */
+
+ if (target >= GL_MAP1_VERTEX_ATTRIB0_4_NV &&
+ target <= GL_MAP1_VERTEX_ATTRIB15_4_NV)
+ return 4;
+
+ if (target >= GL_MAP2_VERTEX_ATTRIB0_4_NV &&
+ target <= GL_MAP2_VERTEX_ATTRIB15_4_NV)
+ return 4;
+
+ return 0;
+}
+
+
+/*
+ * Return pointer to the gl_1d_map struct for the named target.
+ */
+static struct gl_1d_map *
+get_1d_map( GLcontext *ctx, GLenum target )
+{
+ switch (target) {
+ case GL_MAP1_VERTEX_3:
+ return &ctx->EvalMap.Map1Vertex3;
+ case GL_MAP1_VERTEX_4:
+ return &ctx->EvalMap.Map1Vertex4;
+ case GL_MAP1_INDEX:
+ return &ctx->EvalMap.Map1Index;
+ case GL_MAP1_COLOR_4:
+ return &ctx->EvalMap.Map1Color4;
+ case GL_MAP1_NORMAL:
+ return &ctx->EvalMap.Map1Normal;
+ case GL_MAP1_TEXTURE_COORD_1:
+ return &ctx->EvalMap.Map1Texture1;
+ case GL_MAP1_TEXTURE_COORD_2:
+ return &ctx->EvalMap.Map1Texture2;
+ case GL_MAP1_TEXTURE_COORD_3:
+ return &ctx->EvalMap.Map1Texture3;
+ case GL_MAP1_TEXTURE_COORD_4:
+ return &ctx->EvalMap.Map1Texture4;
+ case GL_MAP1_VERTEX_ATTRIB0_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB1_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB2_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB3_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB4_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB5_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB6_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB7_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB8_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB9_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB10_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB11_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB12_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB13_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB14_4_NV:
+ case GL_MAP1_VERTEX_ATTRIB15_4_NV:
+ if (!ctx->Extensions.NV_vertex_program)
+ return NULL;
+ return &ctx->EvalMap.Map1Attrib[target - GL_MAP1_VERTEX_ATTRIB0_4_NV];
+ default:
+ return NULL;
+ }
+}
+
+
+/*
+ * Return pointer to the gl_2d_map struct for the named target.
+ */
+static struct gl_2d_map *
+get_2d_map( GLcontext *ctx, GLenum target )
+{
+ switch (target) {
+ case GL_MAP2_VERTEX_3:
+ return &ctx->EvalMap.Map2Vertex3;
+ case GL_MAP2_VERTEX_4:
+ return &ctx->EvalMap.Map2Vertex4;
+ case GL_MAP2_INDEX:
+ return &ctx->EvalMap.Map2Index;
+ case GL_MAP2_COLOR_4:
+ return &ctx->EvalMap.Map2Color4;
+ case GL_MAP2_NORMAL:
+ return &ctx->EvalMap.Map2Normal;
+ case GL_MAP2_TEXTURE_COORD_1:
+ return &ctx->EvalMap.Map2Texture1;
+ case GL_MAP2_TEXTURE_COORD_2:
+ return &ctx->EvalMap.Map2Texture2;
+ case GL_MAP2_TEXTURE_COORD_3:
+ return &ctx->EvalMap.Map2Texture3;
+ case GL_MAP2_TEXTURE_COORD_4:
+ return &ctx->EvalMap.Map2Texture4;
+ case GL_MAP2_VERTEX_ATTRIB0_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB1_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB2_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB3_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB4_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB5_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB6_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB7_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB8_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB9_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB10_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB11_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB12_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB13_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB14_4_NV:
+ case GL_MAP2_VERTEX_ATTRIB15_4_NV:
+ if (!ctx->Extensions.NV_vertex_program)
+ return NULL;
+ return &ctx->EvalMap.Map2Attrib[target - GL_MAP2_VERTEX_ATTRIB0_4_NV];
+ default:
+ return NULL;
+ }
+}
+
+
+/**********************************************************************/
+/*** Copy and deallocate control points ***/
+/**********************************************************************/
+
+
+/*
+ * Copy 1-parametric evaluator control points from user-specified
+ * memory space to a buffer of contiguous control points.
+ * \param see glMap1f for details
+ * \return pointer to buffer of contiguous control points or NULL if out
+ * of memory.
+ */
+GLfloat *_mesa_copy_map_points1f( GLenum target, GLint ustride, GLint uorder,
+ const GLfloat *points )
+{
+ GLfloat *buffer, *p;
+ GLint i, k, size = _mesa_evaluator_components(target);
+
+ if (!points || !size)
+ return NULL;
+
+ buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat));
+
+ if (buffer)
+ for (i = 0, p = buffer; i < uorder; i++, points += ustride)
+ for (k = 0; k < size; k++)
+ *p++ = points[k];
+
+ return buffer;
+}
+
+
+
+/*
+ * Same as above but convert doubles to floats.
+ */
+GLfloat *_mesa_copy_map_points1d( GLenum target, GLint ustride, GLint uorder,
+ const GLdouble *points )
+{
+ GLfloat *buffer, *p;
+ GLint i, k, size = _mesa_evaluator_components(target);
+
+ if (!points || !size)
+ return NULL;
+
+ buffer = (GLfloat *) MALLOC(uorder * size * sizeof(GLfloat));
+
+ if (buffer)
+ for (i = 0, p = buffer; i < uorder; i++, points += ustride)
+ for (k = 0; k < size; k++)
+ *p++ = (GLfloat) points[k];
+
+ return buffer;
+}
+
+
+
+/*
+ * Copy 2-parametric evaluator control points from user-specified
+ * memory space to a buffer of contiguous control points.
+ * Additional memory is allocated to be used by the horner and
+ * de Casteljau evaluation schemes.
+ *
+ * \param see glMap2f for details
+ * \return pointer to buffer of contiguous control points or NULL if out
+ * of memory.
+ */
+GLfloat *_mesa_copy_map_points2f( GLenum target,
+ GLint ustride, GLint uorder,
+ GLint vstride, GLint vorder,
+ const GLfloat *points )
+{
+ GLfloat *buffer, *p;
+ GLint i, j, k, size, dsize, hsize;
+ GLint uinc;
+
+ size = _mesa_evaluator_components(target);
+
+ if (!points || size==0) {
+ return NULL;
+ }
+
+ /* max(uorder, vorder) additional points are used in */
+ /* horner evaluation and uorder*vorder additional */
+ /* values are needed for de Casteljau */
+ dsize = (uorder == 2 && vorder == 2)? 0 : uorder*vorder;
+ hsize = (uorder > vorder ? uorder : vorder)*size;
+
+ if(hsize>dsize)
+ buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat));
+ else
+ buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat));
+
+ /* compute the increment value for the u-loop */
+ uinc = ustride - vorder*vstride;
+
+ if (buffer)
+ for (i=0, p=buffer; i<uorder; i++, points += uinc)
+ for (j=0; j<vorder; j++, points += vstride)
+ for (k=0; k<size; k++)
+ *p++ = points[k];
+
+ return buffer;
+}
+
+
+
+/*
+ * Same as above but convert doubles to floats.
+ */
+GLfloat *_mesa_copy_map_points2d(GLenum target,
+ GLint ustride, GLint uorder,
+ GLint vstride, GLint vorder,
+ const GLdouble *points )
+{
+ GLfloat *buffer, *p;
+ GLint i, j, k, size, hsize, dsize;
+ GLint uinc;
+
+ size = _mesa_evaluator_components(target);
+
+ if (!points || size==0) {
+ return NULL;
+ }
+
+ /* max(uorder, vorder) additional points are used in */
+ /* horner evaluation and uorder*vorder additional */
+ /* values are needed for de Casteljau */
+ dsize = (uorder == 2 && vorder == 2)? 0 : uorder*vorder;
+ hsize = (uorder > vorder ? uorder : vorder)*size;
+
+ if(hsize>dsize)
+ buffer = (GLfloat *) MALLOC((uorder*vorder*size+hsize)*sizeof(GLfloat));
+ else
+ buffer = (GLfloat *) MALLOC((uorder*vorder*size+dsize)*sizeof(GLfloat));
+
+ /* compute the increment value for the u-loop */
+ uinc = ustride - vorder*vstride;
+
+ if (buffer)
+ for (i=0, p=buffer; i<uorder; i++, points += uinc)
+ for (j=0; j<vorder; j++, points += vstride)
+ for (k=0; k<size; k++)
+ *p++ = (GLfloat) points[k];
+
+ return buffer;
+}
+
+
+
+
+/**********************************************************************/
+/*** API entry points ***/
+/**********************************************************************/
+
+
+/*
+ * This does the work of glMap1[fd].
+ */
+static void
+map1(GLenum target, GLfloat u1, GLfloat u2, GLint ustride,
+ GLint uorder, const GLvoid *points, GLenum type )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint k;
+ GLfloat *pnts;
+ struct gl_1d_map *map = NULL;
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+ ASSERT(type == GL_FLOAT || type == GL_DOUBLE);
+
+ if (u1 == u2) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(u1,u2)" );
+ return;
+ }
+ if (uorder < 1 || uorder > MAX_EVAL_ORDER) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(order)" );
+ return;
+ }
+ if (!points) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(points)" );
+ return;
+ }
+
+ k = _mesa_evaluator_components( target );
+ if (k == 0) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" );
+ }
+
+ if (ustride < k) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glMap1(stride)" );
+ return;
+ }
+
+ if (ctx->Texture.CurrentUnit != 0) {
+ /* See OpenGL 1.2.1 spec, section F.2.13 */
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glMap2(ACTIVE_TEXTURE != 0)" );
+ return;
+ }
+
+ map = get_1d_map(ctx, target);
+ if (!map) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glMap1(target)" );
+ return;
+ }
+
+ /* make copy of the control points */
+ if (type == GL_FLOAT)
+ pnts = _mesa_copy_map_points1f(target, ustride, uorder, (GLfloat*) points);
+ else
+ pnts = _mesa_copy_map_points1d(target, ustride, uorder, (GLdouble*) points);
+
+
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ map->Order = uorder;
+ map->u1 = u1;
+ map->u2 = u2;
+ map->du = 1.0F / (u2 - u1);
+ if (map->Points)
+ FREE( map->Points );
+ map->Points = pnts;
+}
+
+
+
+void GLAPIENTRY
+_mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
+ GLint order, const GLfloat *points )
+{
+ map1(target, u1, u2, stride, order, points, GL_FLOAT);
+}
+
+
+void GLAPIENTRY
+_mesa_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
+ GLint order, const GLdouble *points )
+{
+ map1(target, (GLfloat) u1, (GLfloat) u2, stride, order, points, GL_DOUBLE);
+}
+
+
+static void
+map2( GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
+ GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
+ const GLvoid *points, GLenum type )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint k;
+ GLfloat *pnts;
+ struct gl_2d_map *map = NULL;
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+ ASSERT(type == GL_FLOAT || type == GL_DOUBLE);
+
+ if (u1==u2) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(u1,u2)" );
+ return;
+ }
+
+ if (v1==v2) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(v1,v2)" );
+ return;
+ }
+
+ if (uorder<1 || uorder>MAX_EVAL_ORDER) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(uorder)" );
+ return;
+ }
+
+ if (vorder<1 || vorder>MAX_EVAL_ORDER) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(vorder)" );
+ return;
+ }
+
+ k = _mesa_evaluator_components( target );
+ if (k==0) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" );
+ }
+
+ if (ustride < k) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(ustride)" );
+ return;
+ }
+ if (vstride < k) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glMap2(vstride)" );
+ return;
+ }
+
+ if (ctx->Texture.CurrentUnit != 0) {
+ /* See OpenGL 1.2.1 spec, section F.2.13 */
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glMap2(ACTIVE_TEXTURE != 0)" );
+ return;
+ }
+
+ map = get_2d_map(ctx, target);
+ if (!map) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glMap2(target)" );
+ return;
+ }
+
+ /* make copy of the control points */
+ if (type == GL_FLOAT)
+ pnts = _mesa_copy_map_points2f(target, ustride, uorder,
+ vstride, vorder, (GLfloat*) points);
+ else
+ pnts = _mesa_copy_map_points2d(target, ustride, uorder,
+ vstride, vorder, (GLdouble*) points);
+
+
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ map->Uorder = uorder;
+ map->u1 = u1;
+ map->u2 = u2;
+ map->du = 1.0F / (u2 - u1);
+ map->Vorder = vorder;
+ map->v1 = v1;
+ map->v2 = v2;
+ map->dv = 1.0F / (v2 - v1);
+ if (map->Points)
+ FREE( map->Points );
+ map->Points = pnts;
+}
+
+
+void GLAPIENTRY
+_mesa_Map2f( GLenum target,
+ GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
+ GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
+ const GLfloat *points)
+{
+ map2(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder,
+ points, GL_FLOAT);
+}
+
+
+void GLAPIENTRY
+_mesa_Map2d( GLenum target,
+ GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
+ GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
+ const GLdouble *points )
+{
+ map2(target, (GLfloat) u1, (GLfloat) u2, ustride, uorder,
+ (GLfloat) v1, (GLfloat) v2, vstride, vorder, points, GL_DOUBLE);
+}
+
+
+
+void GLAPIENTRY
+_mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_1d_map *map1d;
+ struct gl_2d_map *map2d;
+ GLint i, n;
+ GLfloat *data;
+ GLuint comps;
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ comps = _mesa_evaluator_components(target);
+ if (!comps) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(target)" );
+ return;
+ }
+
+ map1d = get_1d_map(ctx, target);
+ map2d = get_2d_map(ctx, target);
+ ASSERT(map1d || map2d);
+
+ switch (query) {
+ case GL_COEFF:
+ if (map1d) {
+ data = map1d->Points;
+ n = map1d->Order * comps;
+ }
+ else {
+ data = map2d->Points;
+ n = map2d->Uorder * map2d->Vorder * comps;
+ }
+ if (data) {
+ for (i=0;i<n;i++) {
+ v[i] = data[i];
+ }
+ }
+ break;
+ case GL_ORDER:
+ if (map1d) {
+ v[0] = (GLdouble) map1d->Order;
+ }
+ else {
+ v[0] = (GLdouble) map2d->Uorder;
+ v[1] = (GLdouble) map2d->Vorder;
+ }
+ break;
+ case GL_DOMAIN:
+ if (map1d) {
+ v[0] = (GLdouble) map1d->u1;
+ v[1] = (GLdouble) map1d->u2;
+ }
+ else {
+ v[0] = (GLdouble) map2d->u1;
+ v[1] = (GLdouble) map2d->u2;
+ v[2] = (GLdouble) map2d->v1;
+ v[3] = (GLdouble) map2d->v2;
+ }
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapdv(query)" );
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_1d_map *map1d;
+ struct gl_2d_map *map2d;
+ GLint i, n;
+ GLfloat *data;
+ GLuint comps;
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ comps = _mesa_evaluator_components(target);
+ if (!comps) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(target)" );
+ return;
+ }
+
+ map1d = get_1d_map(ctx, target);
+ map2d = get_2d_map(ctx, target);
+ ASSERT(map1d || map2d);
+
+ switch (query) {
+ case GL_COEFF:
+ if (map1d) {
+ data = map1d->Points;
+ n = map1d->Order * comps;
+ }
+ else {
+ data = map2d->Points;
+ n = map2d->Uorder * map2d->Vorder * comps;
+ }
+ if (data) {
+ for (i=0;i<n;i++) {
+ v[i] = data[i];
+ }
+ }
+ break;
+ case GL_ORDER:
+ if (map1d) {
+ v[0] = (GLfloat) map1d->Order;
+ }
+ else {
+ v[0] = (GLfloat) map2d->Uorder;
+ v[1] = (GLfloat) map2d->Vorder;
+ }
+ break;
+ case GL_DOMAIN:
+ if (map1d) {
+ v[0] = map1d->u1;
+ v[1] = map1d->u2;
+ }
+ else {
+ v[0] = map2d->u1;
+ v[1] = map2d->u2;
+ v[2] = map2d->v1;
+ v[3] = map2d->v2;
+ }
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapfv(query)" );
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetMapiv( GLenum target, GLenum query, GLint *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_1d_map *map1d;
+ struct gl_2d_map *map2d;
+ GLuint i, n;
+ GLfloat *data;
+ GLuint comps;
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ comps = _mesa_evaluator_components(target);
+ if (!comps) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" );
+ return;
+ }
+
+ map1d = get_1d_map(ctx, target);
+ map2d = get_2d_map(ctx, target);
+ ASSERT(map1d || map2d);
+
+ switch (query) {
+ case GL_COEFF:
+ if (map1d) {
+ data = map1d->Points;
+ n = map1d->Order * comps;
+ }
+ else {
+ data = map2d->Points;
+ n = map2d->Uorder * map2d->Vorder * comps;
+ }
+ if (data) {
+ for (i=0;i<n;i++) {
+ v[i] = IROUND(data[i]);
+ }
+ }
+ break;
+ case GL_ORDER:
+ if (map1d) {
+ v[0] = map1d->Order;
+ }
+ else {
+ v[0] = map2d->Uorder;
+ v[1] = map2d->Vorder;
+ }
+ break;
+ case GL_DOMAIN:
+ if (map1d) {
+ v[0] = IROUND(map1d->u1);
+ v[1] = IROUND(map1d->u2);
+ }
+ else {
+ v[0] = IROUND(map2d->u1);
+ v[1] = IROUND(map2d->u2);
+ v[2] = IROUND(map2d->v1);
+ v[3] = IROUND(map2d->v2);
+ }
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(query)" );
+ }
+}
+
+
+
+void GLAPIENTRY
+_mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (un<1) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid1f" );
+ return;
+ }
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.MapGrid1un = un;
+ ctx->Eval.MapGrid1u1 = u1;
+ ctx->Eval.MapGrid1u2 = u2;
+ ctx->Eval.MapGrid1du = (u2 - u1) / (GLfloat) un;
+}
+
+
+void GLAPIENTRY
+_mesa_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 )
+{
+ _mesa_MapGrid1f( un, (GLfloat) u1, (GLfloat) u2 );
+}
+
+
+void GLAPIENTRY
+_mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
+ GLint vn, GLfloat v1, GLfloat v2 )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (un<1) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(un)" );
+ return;
+ }
+ if (vn<1) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glMapGrid2f(vn)" );
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_EVAL);
+ ctx->Eval.MapGrid2un = un;
+ ctx->Eval.MapGrid2u1 = u1;
+ ctx->Eval.MapGrid2u2 = u2;
+ ctx->Eval.MapGrid2du = (u2 - u1) / (GLfloat) un;
+ ctx->Eval.MapGrid2vn = vn;
+ ctx->Eval.MapGrid2v1 = v1;
+ ctx->Eval.MapGrid2v2 = v2;
+ ctx->Eval.MapGrid2dv = (v2 - v1) / (GLfloat) vn;
+}
+
+
+void GLAPIENTRY
+_mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
+ GLint vn, GLdouble v1, GLdouble v2 )
+{
+ _mesa_MapGrid2f( un, (GLfloat) u1, (GLfloat) u2,
+ vn, (GLfloat) v1, (GLfloat) v2 );
+}
+
+
+
+/**********************************************************************/
+/***** Initialization *****/
+/**********************************************************************/
+
+/**
+ * Initialize a 1-D evaluator map.
+ */
+static void
+init_1d_map( struct gl_1d_map *map, int n, const float *initial )
+{
+ map->Order = 1;
+ map->u1 = 0.0;
+ map->u2 = 1.0;
+ map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat));
+ if (map->Points) {
+ GLint i;
+ for (i=0;i<n;i++)
+ map->Points[i] = initial[i];
+ }
+}
+
+
+/**
+ * Initialize a 2-D evaluator map
+ */
+static void
+init_2d_map( struct gl_2d_map *map, int n, const float *initial )
+{
+ map->Uorder = 1;
+ map->Vorder = 1;
+ map->u1 = 0.0;
+ map->u2 = 1.0;
+ map->v1 = 0.0;
+ map->v2 = 1.0;
+ map->Points = (GLfloat *) MALLOC(n * sizeof(GLfloat));
+ if (map->Points) {
+ GLint i;
+ for (i=0;i<n;i++)
+ map->Points[i] = initial[i];
+ }
+}
+
+
+void _mesa_init_eval( GLcontext *ctx )
+{
+ int i;
+
+ /* Evaluators group */
+ ctx->Eval.Map1Color4 = GL_FALSE;
+ ctx->Eval.Map1Index = GL_FALSE;
+ ctx->Eval.Map1Normal = GL_FALSE;
+ ctx->Eval.Map1TextureCoord1 = GL_FALSE;
+ ctx->Eval.Map1TextureCoord2 = GL_FALSE;
+ ctx->Eval.Map1TextureCoord3 = GL_FALSE;
+ ctx->Eval.Map1TextureCoord4 = GL_FALSE;
+ ctx->Eval.Map1Vertex3 = GL_FALSE;
+ ctx->Eval.Map1Vertex4 = GL_FALSE;
+ MEMSET(ctx->Eval.Map1Attrib, 0, sizeof(ctx->Eval.Map1Attrib));
+ ctx->Eval.Map2Color4 = GL_FALSE;
+ ctx->Eval.Map2Index = GL_FALSE;
+ ctx->Eval.Map2Normal = GL_FALSE;
+ ctx->Eval.Map2TextureCoord1 = GL_FALSE;
+ ctx->Eval.Map2TextureCoord2 = GL_FALSE;
+ ctx->Eval.Map2TextureCoord3 = GL_FALSE;
+ ctx->Eval.Map2TextureCoord4 = GL_FALSE;
+ ctx->Eval.Map2Vertex3 = GL_FALSE;
+ ctx->Eval.Map2Vertex4 = GL_FALSE;
+ MEMSET(ctx->Eval.Map2Attrib, 0, sizeof(ctx->Eval.Map2Attrib));
+ ctx->Eval.AutoNormal = GL_FALSE;
+ ctx->Eval.MapGrid1un = 1;
+ ctx->Eval.MapGrid1u1 = 0.0;
+ ctx->Eval.MapGrid1u2 = 1.0;
+ ctx->Eval.MapGrid2un = 1;
+ ctx->Eval.MapGrid2vn = 1;
+ ctx->Eval.MapGrid2u1 = 0.0;
+ ctx->Eval.MapGrid2u2 = 1.0;
+ ctx->Eval.MapGrid2v1 = 0.0;
+ ctx->Eval.MapGrid2v2 = 1.0;
+
+ /* Evaluator data */
+ {
+ static GLfloat vertex[4] = { 0.0, 0.0, 0.0, 1.0 };
+ static GLfloat normal[3] = { 0.0, 0.0, 1.0 };
+ static GLfloat index[1] = { 1.0 };
+ static GLfloat color[4] = { 1.0, 1.0, 1.0, 1.0 };
+ static GLfloat texcoord[4] = { 0.0, 0.0, 0.0, 1.0 };
+ static GLfloat attrib[4] = { 0.0, 0.0, 0.0, 1.0 };
+
+ init_1d_map( &ctx->EvalMap.Map1Vertex3, 3, vertex );
+ init_1d_map( &ctx->EvalMap.Map1Vertex4, 4, vertex );
+ init_1d_map( &ctx->EvalMap.Map1Index, 1, index );
+ init_1d_map( &ctx->EvalMap.Map1Color4, 4, color );
+ init_1d_map( &ctx->EvalMap.Map1Normal, 3, normal );
+ init_1d_map( &ctx->EvalMap.Map1Texture1, 1, texcoord );
+ init_1d_map( &ctx->EvalMap.Map1Texture2, 2, texcoord );
+ init_1d_map( &ctx->EvalMap.Map1Texture3, 3, texcoord );
+ init_1d_map( &ctx->EvalMap.Map1Texture4, 4, texcoord );
+ for (i = 0; i < 16; i++)
+ init_1d_map( ctx->EvalMap.Map1Attrib + i, 4, attrib );
+
+ init_2d_map( &ctx->EvalMap.Map2Vertex3, 3, vertex );
+ init_2d_map( &ctx->EvalMap.Map2Vertex4, 4, vertex );
+ init_2d_map( &ctx->EvalMap.Map2Index, 1, index );
+ init_2d_map( &ctx->EvalMap.Map2Color4, 4, color );
+ init_2d_map( &ctx->EvalMap.Map2Normal, 3, normal );
+ init_2d_map( &ctx->EvalMap.Map2Texture1, 1, texcoord );
+ init_2d_map( &ctx->EvalMap.Map2Texture2, 2, texcoord );
+ init_2d_map( &ctx->EvalMap.Map2Texture3, 3, texcoord );
+ init_2d_map( &ctx->EvalMap.Map2Texture4, 4, texcoord );
+ for (i = 0; i < 16; i++)
+ init_2d_map( ctx->EvalMap.Map2Attrib + i, 4, attrib );
+ }
+}
+
+
+void _mesa_free_eval_data( GLcontext *ctx )
+{
+ int i;
+
+ /* Free evaluator data */
+ if (ctx->EvalMap.Map1Vertex3.Points)
+ FREE( ctx->EvalMap.Map1Vertex3.Points );
+ if (ctx->EvalMap.Map1Vertex4.Points)
+ FREE( ctx->EvalMap.Map1Vertex4.Points );
+ if (ctx->EvalMap.Map1Index.Points)
+ FREE( ctx->EvalMap.Map1Index.Points );
+ if (ctx->EvalMap.Map1Color4.Points)
+ FREE( ctx->EvalMap.Map1Color4.Points );
+ if (ctx->EvalMap.Map1Normal.Points)
+ FREE( ctx->EvalMap.Map1Normal.Points );
+ if (ctx->EvalMap.Map1Texture1.Points)
+ FREE( ctx->EvalMap.Map1Texture1.Points );
+ if (ctx->EvalMap.Map1Texture2.Points)
+ FREE( ctx->EvalMap.Map1Texture2.Points );
+ if (ctx->EvalMap.Map1Texture3.Points)
+ FREE( ctx->EvalMap.Map1Texture3.Points );
+ if (ctx->EvalMap.Map1Texture4.Points)
+ FREE( ctx->EvalMap.Map1Texture4.Points );
+ for (i = 0; i < 16; i++)
+ FREE((ctx->EvalMap.Map1Attrib[i].Points));
+
+ if (ctx->EvalMap.Map2Vertex3.Points)
+ FREE( ctx->EvalMap.Map2Vertex3.Points );
+ if (ctx->EvalMap.Map2Vertex4.Points)
+ FREE( ctx->EvalMap.Map2Vertex4.Points );
+ if (ctx->EvalMap.Map2Index.Points)
+ FREE( ctx->EvalMap.Map2Index.Points );
+ if (ctx->EvalMap.Map2Color4.Points)
+ FREE( ctx->EvalMap.Map2Color4.Points );
+ if (ctx->EvalMap.Map2Normal.Points)
+ FREE( ctx->EvalMap.Map2Normal.Points );
+ if (ctx->EvalMap.Map2Texture1.Points)
+ FREE( ctx->EvalMap.Map2Texture1.Points );
+ if (ctx->EvalMap.Map2Texture2.Points)
+ FREE( ctx->EvalMap.Map2Texture2.Points );
+ if (ctx->EvalMap.Map2Texture3.Points)
+ FREE( ctx->EvalMap.Map2Texture3.Points );
+ if (ctx->EvalMap.Map2Texture4.Points)
+ FREE( ctx->EvalMap.Map2Texture4.Points );
+ for (i = 0; i < 16; i++)
+ FREE((ctx->EvalMap.Map2Attrib[i].Points));
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/eval.h b/nx-X11/extras/Mesa/src/mesa/main/eval.h
new file mode 100644
index 000000000..b3ff0a96f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/eval.h
@@ -0,0 +1,128 @@
+/**
+ * \file eval.h
+ * Eval operations.
+ *
+ * \if subset
+ * (No-op)
+ *
+ * \endif
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef EVAL_H
+#define EVAL_H
+
+
+#include "mtypes.h"
+
+#if _HAVE_FULL_GL
+
+extern void _mesa_init_eval( GLcontext *ctx );
+extern void _mesa_free_eval_data( GLcontext *ctx );
+
+
+extern GLuint _mesa_evaluator_components( GLenum target );
+
+
+extern void gl_free_control_points( GLcontext *ctx,
+ GLenum target, GLfloat *data );
+
+
+extern GLfloat *_mesa_copy_map_points1f( GLenum target,
+ GLint ustride, GLint uorder,
+ const GLfloat *points );
+
+extern GLfloat *_mesa_copy_map_points1d( GLenum target,
+ GLint ustride, GLint uorder,
+ const GLdouble *points );
+
+extern GLfloat *_mesa_copy_map_points2f( GLenum target,
+ GLint ustride, GLint uorder,
+ GLint vstride, GLint vorder,
+ const GLfloat *points );
+
+extern GLfloat *_mesa_copy_map_points2d(GLenum target,
+ GLint ustride, GLint uorder,
+ GLint vstride, GLint vorder,
+ const GLdouble *points );
+
+
+
+extern void GLAPIENTRY
+_mesa_Map1f( GLenum target, GLfloat u1, GLfloat u2, GLint stride,
+ GLint order, const GLfloat *points );
+
+extern void GLAPIENTRY
+_mesa_Map2f( GLenum target,
+ GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
+ GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
+ const GLfloat *points );
+
+extern void GLAPIENTRY
+_mesa_Map1d( GLenum target, GLdouble u1, GLdouble u2, GLint stride,
+ GLint order, const GLdouble *points );
+
+extern void GLAPIENTRY
+_mesa_Map2d( GLenum target,
+ GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
+ GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
+ const GLdouble *points );
+
+extern void GLAPIENTRY
+_mesa_MapGrid1f( GLint un, GLfloat u1, GLfloat u2 );
+
+extern void GLAPIENTRY
+_mesa_MapGrid1d( GLint un, GLdouble u1, GLdouble u2 );
+
+extern void GLAPIENTRY
+_mesa_MapGrid2f( GLint un, GLfloat u1, GLfloat u2,
+ GLint vn, GLfloat v1, GLfloat v2 );
+
+extern void GLAPIENTRY
+_mesa_MapGrid2d( GLint un, GLdouble u1, GLdouble u2,
+ GLint vn, GLdouble v1, GLdouble v2 );
+
+extern void GLAPIENTRY
+_mesa_GetMapdv( GLenum target, GLenum query, GLdouble *v );
+
+extern void GLAPIENTRY
+_mesa_GetMapfv( GLenum target, GLenum query, GLfloat *v );
+
+extern void GLAPIENTRY
+_mesa_GetMapiv( GLenum target, GLenum query, GLint *v );
+
+#else
+
+/** No-op */
+#define _mesa_init_eval( c ) ((void)0)
+
+/** No-op */
+#define _mesa_free_eval_data( c ) ((void)0)
+
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/execmem.c b/nx-X11/extras/Mesa/src/mesa/main/execmem.c
new file mode 100644
index 000000000..a6b110ae7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/execmem.c
@@ -0,0 +1,132 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file exemem.c
+ * Functions for allocating executable memory.
+ *
+ * \author Keith Whitwell
+ */
+
+
+#include "imports.h"
+#include "glthread.h"
+
+
+
+#if defined(__linux__) && !defined(XFree86Server)
+
+/*
+ * Allocate a large block of memory which can hold code then dole it out
+ * in pieces by means of the generic memory manager code.
+*/
+
+
+#include <unistd.h>
+#include <sys/mman.h>
+#include "mm.h"
+
+#define EXEC_HEAP_SIZE (128*1024)
+
+_glthread_DECLARE_STATIC_MUTEX(exec_mutex);
+
+static memHeap_t *exec_heap = NULL;
+static unsigned char *exec_mem = NULL;
+
+
+static void
+init_heap(void)
+{
+ if (!exec_heap)
+ exec_heap = mmInit( 0, EXEC_HEAP_SIZE );
+
+ if (!exec_mem)
+ exec_mem = (unsigned char *) mmap(0, EXEC_HEAP_SIZE,
+ PROT_EXEC | PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+}
+
+
+void *
+_mesa_exec_malloc(GLuint size)
+{
+ PMemBlock block = NULL;
+ void *addr = NULL;
+
+ _glthread_LOCK_MUTEX(exec_mutex);
+
+ init_heap();
+
+ if (exec_heap) {
+ size = (size + 31) & ~31;
+ block = mmAllocMem( exec_heap, size, 32, 0 );
+ }
+
+ if (block)
+ addr = exec_mem + block->ofs;
+
+ _glthread_UNLOCK_MUTEX(exec_mutex);
+
+ return addr;
+}
+
+
+void
+_mesa_exec_free(void *addr)
+{
+ _glthread_LOCK_MUTEX(exec_mutex);
+
+ if (exec_heap) {
+ PMemBlock block = mmFindBlock(exec_heap, (unsigned char *)addr - exec_mem);
+
+ if (block)
+ mmFreeMem(block);
+ }
+
+ _glthread_UNLOCK_MUTEX(exec_mutex);
+}
+
+
+#else
+
+/*
+ * Just use regular memory.
+ */
+
+void *
+_mesa_exec_malloc(GLuint size)
+{
+ return _mesa_malloc( size );
+}
+
+
+void
+_mesa_exec_free(void *addr)
+{
+ _mesa_free(addr);
+}
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/extensions.c b/nx-X11/extras/Mesa/src/mesa/main/extensions.c
new file mode 100644
index 000000000..fae984165
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/extensions.c
@@ -0,0 +1,516 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "extensions.h"
+#include "simple_list.h"
+#include "mtypes.h"
+
+
+#define F(x) (int)(uintptr_t)&(((struct gl_extensions *)0)->x)
+#define ON GL_TRUE
+#define OFF GL_FALSE
+
+
+/*
+ * Note: The GL_MESAX_* extensions are placeholders for future ARB extensions.
+ */
+static const struct {
+ GLboolean enabled;
+ const char *name;
+ int flag_offset;
+} default_extensions[] = {
+ { OFF, "GL_ARB_depth_texture", F(ARB_depth_texture) },
+ { OFF, "GL_ARB_draw_buffers", F(ARB_draw_buffers) },
+ { OFF, "GL_ARB_fragment_program", F(ARB_fragment_program) },
+ { OFF, "GL_ARB_fragment_shader", F(ARB_fragment_shader) },
+ { OFF, "GL_MESAX_half_float_pixel", F(ARB_half_float_pixel) },
+ { OFF, "GL_ARB_imaging", F(ARB_imaging) },
+ { OFF, "GL_ARB_multisample", F(ARB_multisample) },
+ { OFF, "GL_ARB_multitexture", F(ARB_multitexture) },
+ { OFF, "GL_ARB_occlusion_query", F(ARB_occlusion_query) },
+ { OFF, "GL_ARB_pixel_buffer_object", F(EXT_pixel_buffer_object) },
+ { OFF, "GL_ARB_point_parameters", F(EXT_point_parameters) },
+ { OFF, "GL_ARB_point_sprite", F(ARB_point_sprite) },
+ { OFF, "GL_ARB_shader_objects", F(ARB_shader_objects) },
+ { OFF, "GL_ARB_shading_language_100", F(ARB_shading_language_100) },
+ { OFF, "GL_ARB_shadow", F(ARB_shadow) },
+ { OFF, "GL_ARB_shadow_ambient", F(SGIX_shadow_ambient) },
+ { OFF, "GL_ARB_texture_border_clamp", F(ARB_texture_border_clamp) },
+ { OFF, "GL_ARB_texture_compression", F(ARB_texture_compression) },
+ { OFF, "GL_ARB_texture_cube_map", F(ARB_texture_cube_map) },
+ { OFF, "GL_ARB_texture_env_add", F(EXT_texture_env_add) },
+ { OFF, "GL_ARB_texture_env_combine", F(ARB_texture_env_combine) },
+ { OFF, "GL_ARB_texture_env_crossbar", F(ARB_texture_env_crossbar) },
+ { OFF, "GL_ARB_texture_env_dot3", F(ARB_texture_env_dot3) },
+ { OFF, "GL_MESAX_texture_float", F(ARB_texture_float) },
+ { OFF, "GL_ARB_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)},
+ { OFF, "GL_ARB_texture_non_power_of_two", F(ARB_texture_non_power_of_two)},
+ { OFF, "GL_ARB_texture_rectangle", F(NV_texture_rectangle) },
+ { ON, "GL_ARB_transpose_matrix", F(ARB_transpose_matrix) },
+ { OFF, "GL_ARB_vertex_buffer_object", F(ARB_vertex_buffer_object) },
+ { OFF, "GL_ARB_vertex_program", F(ARB_vertex_program) },
+ { OFF, "GL_ARB_vertex_shader", F(ARB_vertex_shader) },
+ { ON, "GL_ARB_window_pos", F(ARB_window_pos) },
+ { ON, "GL_EXT_abgr", F(EXT_abgr) },
+ { ON, "GL_EXT_bgra", F(EXT_bgra) },
+ { OFF, "GL_EXT_blend_color", F(EXT_blend_color) },
+ { OFF, "GL_EXT_blend_equation_separate", F(EXT_blend_equation_separate) },
+ { OFF, "GL_EXT_blend_func_separate", F(EXT_blend_func_separate) },
+ { OFF, "GL_EXT_blend_logic_op", F(EXT_blend_logic_op) },
+ { OFF, "GL_EXT_blend_minmax", F(EXT_blend_minmax) },
+ { OFF, "GL_EXT_blend_subtract", F(EXT_blend_subtract) },
+ { ON, "GL_EXT_clip_volume_hint", F(EXT_clip_volume_hint) },
+ { OFF, "GL_EXT_cull_vertex", F(EXT_cull_vertex) },
+ { ON, "GL_EXT_compiled_vertex_array", F(EXT_compiled_vertex_array) },
+ { OFF, "GL_EXT_convolution", F(EXT_convolution) },
+ { ON, "GL_EXT_copy_texture", F(EXT_copy_texture) },
+ { OFF, "GL_EXT_depth_bounds_test", F(EXT_depth_bounds_test) },
+ { ON, "GL_EXT_draw_range_elements", F(EXT_draw_range_elements) },
+ { OFF, "GL_EXT_framebuffer_object", F(EXT_framebuffer_object) },
+ { OFF, "GL_EXT_fog_coord", F(EXT_fog_coord) },
+ { OFF, "GL_EXT_histogram", F(EXT_histogram) },
+ { OFF, "GL_EXT_multi_draw_arrays", F(EXT_multi_draw_arrays) },
+ { ON, "GL_EXT_packed_pixels", F(EXT_packed_pixels) },
+ { OFF, "GL_EXT_paletted_texture", F(EXT_paletted_texture) },
+ { OFF, "GL_EXT_pixel_buffer_object", F(EXT_pixel_buffer_object) },
+ { OFF, "GL_EXT_point_parameters", F(EXT_point_parameters) },
+ { ON, "GL_EXT_polygon_offset", F(EXT_polygon_offset) },
+ { ON, "GL_EXT_rescale_normal", F(EXT_rescale_normal) },
+ { OFF, "GL_EXT_secondary_color", F(EXT_secondary_color) },
+ { ON, "GL_EXT_separate_specular_color", F(EXT_separate_specular_color) },
+ { OFF, "GL_EXT_shadow_funcs", F(EXT_shadow_funcs) },
+ { OFF, "GL_EXT_shared_texture_palette", F(EXT_shared_texture_palette) },
+ { OFF, "GL_EXT_stencil_two_side", F(EXT_stencil_two_side) },
+ { OFF, "GL_EXT_stencil_wrap", F(EXT_stencil_wrap) },
+ { ON, "GL_EXT_subtexture", F(EXT_subtexture) },
+ { ON, "GL_EXT_texture", F(EXT_texture) },
+ { ON, "GL_EXT_texture3D", F(EXT_texture3D) },
+ { OFF, "GL_EXT_texture_compression_s3tc", F(EXT_texture_compression_s3tc) },
+ { ON, "GL_EXT_texture_edge_clamp", F(SGIS_texture_edge_clamp) },
+ { OFF, "GL_EXT_texture_env_add", F(EXT_texture_env_add) },
+ { OFF, "GL_EXT_texture_env_combine", F(EXT_texture_env_combine) },
+ { OFF, "GL_EXT_texture_env_dot3", F(EXT_texture_env_dot3) },
+ { OFF, "GL_EXT_texture_filter_anisotropic", F(EXT_texture_filter_anisotropic) },
+ { OFF, "GL_EXT_texture_lod_bias", F(EXT_texture_lod_bias) },
+ { OFF, "GL_EXT_texture_mirror_clamp", F(EXT_texture_mirror_clamp) },
+ { ON, "GL_EXT_texture_object", F(EXT_texture_object) },
+ { OFF, "GL_EXT_texture_rectangle", F(NV_texture_rectangle) },
+ { ON, "GL_EXT_vertex_array", F(EXT_vertex_array) },
+ { OFF, "GL_EXT_vertex_array_set", F(EXT_vertex_array_set) },
+ { OFF, "GL_3DFX_texture_compression_FXT1", F(TDFX_texture_compression_FXT1) },
+ { OFF, "GL_APPLE_client_storage", F(APPLE_client_storage) },
+ { ON, "GL_APPLE_packed_pixels", F(APPLE_packed_pixels) },
+ { OFF, "GL_ATI_blend_equation_separate", F(EXT_blend_equation_separate) },
+ { OFF, "GL_ATI_texture_env_combine3", F(ATI_texture_env_combine3)},
+ { OFF, "GL_ATI_texture_mirror_once", F(ATI_texture_mirror_once)},
+ { OFF, "GL_ATI_fragment_shader", F(ATI_fragment_shader)},
+ { OFF, "GL_HP_occlusion_test", F(HP_occlusion_test) },
+ { OFF, "GL_IBM_multimode_draw_arrays", F(IBM_multimode_draw_arrays) },
+ { ON, "GL_IBM_rasterpos_clip", F(IBM_rasterpos_clip) },
+ { OFF, "GL_IBM_texture_mirrored_repeat", F(ARB_texture_mirrored_repeat)},
+ { OFF, "GL_INGR_blend_func_separate", F(EXT_blend_func_separate) },
+ { OFF, "GL_MESA_pack_invert", F(MESA_pack_invert) },
+ { OFF, "GL_MESA_packed_depth_stencil", F(MESA_packed_depth_stencil) },
+ { OFF, "GL_MESA_program_debug", F(MESA_program_debug) },
+ { OFF, "GL_MESA_resize_buffers", F(MESA_resize_buffers) },
+ { OFF, "GL_MESA_ycbcr_texture", F(MESA_ycbcr_texture) },
+ { ON, "GL_MESA_window_pos", F(ARB_window_pos) },
+ { OFF, "GL_NV_blend_square", F(NV_blend_square) },
+ { OFF, "GL_NV_fragment_program", F(NV_fragment_program) },
+ { ON, "GL_NV_light_max_exponent", F(NV_light_max_exponent) },
+ { OFF, "GL_NV_point_sprite", F(NV_point_sprite) },
+ { OFF, "GL_NV_texture_rectangle", F(NV_texture_rectangle) },
+ { ON, "GL_NV_texgen_reflection", F(NV_texgen_reflection) },
+ { OFF, "GL_NV_vertex_program", F(NV_vertex_program) },
+ { OFF, "GL_NV_vertex_program1_1", F(NV_vertex_program1_1) },
+ { ON, "GL_OES_read_format", F(OES_read_format) },
+ { OFF, "GL_SGI_color_matrix", F(SGI_color_matrix) },
+ { OFF, "GL_SGI_color_table", F(SGI_color_table) },
+ { OFF, "GL_SGI_texture_color_table", F(SGI_texture_color_table) },
+ { OFF, "GL_SGIS_generate_mipmap", F(SGIS_generate_mipmap) },
+ { OFF, "GL_SGIS_pixel_texture", F(SGIS_pixel_texture) },
+ { OFF, "GL_SGIS_texture_border_clamp", F(ARB_texture_border_clamp) },
+ { ON, "GL_SGIS_texture_edge_clamp", F(SGIS_texture_edge_clamp) },
+ { ON, "GL_SGIS_texture_lod", F(SGIS_texture_lod) },
+ { OFF, "GL_SGIX_depth_texture", F(SGIX_depth_texture) },
+ { OFF, "GL_SGIX_pixel_texture", F(SGIX_pixel_texture) },
+ { OFF, "GL_SGIX_shadow", F(SGIX_shadow) },
+ { OFF, "GL_SGIX_shadow_ambient", F(SGIX_shadow_ambient) },
+ { OFF, "GL_SUN_multi_draw_arrays", F(EXT_multi_draw_arrays) },
+ { OFF, "GL_S3_s3tc", F(S3_s3tc) },
+};
+
+
+
+/**
+ * Enable all extensions suitable for a software-only renderer.
+ * This is a convenience function used by the XMesa, OSMesa, GGI drivers, etc.
+ */
+void
+_mesa_enable_sw_extensions(GLcontext *ctx)
+{
+ ctx->Extensions.ARB_depth_texture = GL_TRUE;
+ ctx->Extensions.ARB_draw_buffers = GL_TRUE;
+#if FEATURE_ARB_fragment_program
+ ctx->Extensions.ARB_fragment_program = GL_TRUE;
+#endif
+#if 0 && FEATURE_ARB_fragment_shader
+ ctx->Extensions.ARB_fragment_shader = GL_TRUE;
+#endif
+ /*ctx->Extensions.ARB_half_float_pixel = GL_TRUE;*/
+ ctx->Extensions.ARB_imaging = GL_TRUE;
+ ctx->Extensions.ARB_multitexture = GL_TRUE;
+#if FEATURE_ARB_occlusion_query
+ ctx->Extensions.ARB_occlusion_query = GL_TRUE;
+#endif
+ ctx->Extensions.ARB_point_sprite = GL_TRUE;
+#if 0 && FEATURE_ARB_shader_objects
+ ctx->Extensions.ARB_shader_objects = GL_TRUE;
+#endif
+#if 0 && FEATURE_ARB_shading_language_100
+ ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
+#endif
+ ctx->Extensions.ARB_shadow = GL_TRUE;
+ ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
+ ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
+ ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
+ ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
+ ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
+ /*ctx->Extensions.ARB_texture_float = GL_TRUE;*/
+ ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
+ ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
+#if FEATURE_ARB_vertex_program
+ ctx->Extensions.ARB_vertex_program = GL_TRUE;
+#endif
+#if 0 && FEATURE_ARB_vertex_shader
+ ctx->Extensions.ARB_vertex_shader = GL_TRUE;
+#endif
+#if FEATURE_ARB_vertex_buffer_object
+ ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;
+#endif
+#if FEATURE_ATI_fragment_shader
+ ctx->Extensions.ATI_fragment_shader = GL_TRUE;
+#endif
+ ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
+ ctx->Extensions.ATI_texture_mirror_once = GL_TRUE;
+ ctx->Extensions.EXT_blend_color = GL_TRUE;
+ ctx->Extensions.EXT_blend_equation_separate = GL_TRUE;
+ ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
+ ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
+ ctx->Extensions.EXT_blend_minmax = GL_TRUE;
+ ctx->Extensions.EXT_blend_subtract = GL_TRUE;
+ ctx->Extensions.EXT_convolution = GL_TRUE;
+ ctx->Extensions.EXT_depth_bounds_test = GL_TRUE;
+ ctx->Extensions.EXT_fog_coord = GL_TRUE;
+#if FEATURE_EXT_framebuffer_object
+ ctx->Extensions.EXT_framebuffer_object = GL_TRUE;
+#endif
+ ctx->Extensions.EXT_histogram = GL_TRUE;
+ ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;
+ ctx->Extensions.EXT_paletted_texture = GL_TRUE;
+#if FEATURE_EXT_pixel_buffer_object
+ ctx->Extensions.EXT_pixel_buffer_object = GL_TRUE;
+#endif
+ ctx->Extensions.EXT_point_parameters = GL_TRUE;
+ ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
+ ctx->Extensions.EXT_secondary_color = GL_TRUE;
+ ctx->Extensions.EXT_shared_texture_palette = GL_TRUE;
+ ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
+ ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
+ ctx->Extensions.EXT_texture_env_add = GL_TRUE;
+ ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
+ ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
+ ctx->Extensions.EXT_texture_mirror_clamp = GL_TRUE;
+ ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
+ ctx->Extensions.HP_occlusion_test = GL_TRUE;
+ ctx->Extensions.IBM_multimode_draw_arrays = GL_TRUE;
+ ctx->Extensions.MESA_pack_invert = GL_TRUE;
+#if FEATURE_MESA_program_debug
+ ctx->Extensions.MESA_program_debug = GL_TRUE;
+#endif
+ ctx->Extensions.MESA_resize_buffers = GL_TRUE;
+ ctx->Extensions.MESA_ycbcr_texture = GL_TRUE;
+ ctx->Extensions.NV_blend_square = GL_TRUE;
+ /*ctx->Extensions.NV_light_max_exponent = GL_TRUE;*/
+ ctx->Extensions.NV_point_sprite = GL_TRUE;
+ ctx->Extensions.NV_texture_rectangle = GL_TRUE;
+ /*ctx->Extensions.NV_texgen_reflection = GL_TRUE;*/
+#if FEATURE_NV_vertex_program
+ ctx->Extensions.NV_vertex_program = GL_TRUE;
+ ctx->Extensions.NV_vertex_program1_1 = GL_TRUE;
+#endif
+#if FEATURE_NV_fragment_program
+ ctx->Extensions.NV_fragment_program = GL_TRUE;
+#endif
+ ctx->Extensions.SGI_color_matrix = GL_TRUE;
+ ctx->Extensions.SGI_color_table = GL_TRUE;
+ ctx->Extensions.SGI_texture_color_table = GL_TRUE;
+ ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
+ ctx->Extensions.SGIS_pixel_texture = GL_TRUE;
+ ctx->Extensions.SGIS_texture_edge_clamp = GL_TRUE;
+ ctx->Extensions.SGIX_depth_texture = GL_TRUE;
+ ctx->Extensions.SGIX_pixel_texture = GL_TRUE;
+ ctx->Extensions.SGIX_shadow = GL_TRUE;
+ ctx->Extensions.SGIX_shadow_ambient = GL_TRUE;
+}
+
+
+/**
+ * Enable GL_ARB_imaging and all the EXT extensions that are subsets of it.
+ */
+void
+_mesa_enable_imaging_extensions(GLcontext *ctx)
+{
+ ctx->Extensions.ARB_imaging = GL_TRUE;
+ ctx->Extensions.EXT_blend_color = GL_TRUE;
+ ctx->Extensions.EXT_blend_minmax = GL_TRUE;
+ ctx->Extensions.EXT_blend_subtract = GL_TRUE;
+ ctx->Extensions.EXT_convolution = GL_TRUE;
+ ctx->Extensions.EXT_histogram = GL_TRUE;
+ ctx->Extensions.SGI_color_matrix = GL_TRUE;
+ ctx->Extensions.SGI_color_table = GL_TRUE;
+}
+
+
+
+/**
+ * Enable all OpenGL 1.3 features and extensions.
+ * A convenience function to be called by drivers.
+ */
+void
+_mesa_enable_1_3_extensions(GLcontext *ctx)
+{
+ ctx->Extensions.ARB_multisample = GL_TRUE;
+ ctx->Extensions.ARB_multitexture = GL_TRUE;
+ ctx->Extensions.ARB_texture_border_clamp = GL_TRUE;
+ ctx->Extensions.ARB_texture_compression = GL_TRUE;
+ ctx->Extensions.ARB_texture_cube_map = GL_TRUE;
+ ctx->Extensions.ARB_texture_env_combine = GL_TRUE;
+ ctx->Extensions.ARB_texture_env_dot3 = GL_TRUE;
+ ctx->Extensions.EXT_texture_env_add = GL_TRUE;
+ /*ctx->Extensions.ARB_transpose_matrix = GL_TRUE;*/
+}
+
+
+
+/**
+ * Enable all OpenGL 1.4 features and extensions.
+ * A convenience function to be called by drivers.
+ */
+void
+_mesa_enable_1_4_extensions(GLcontext *ctx)
+{
+ ctx->Extensions.ARB_depth_texture = GL_TRUE;
+ ctx->Extensions.ARB_shadow = GL_TRUE;
+ ctx->Extensions.ARB_texture_env_crossbar = GL_TRUE;
+ ctx->Extensions.ARB_texture_mirrored_repeat = GL_TRUE;
+ ctx->Extensions.ARB_window_pos = GL_TRUE;
+ ctx->Extensions.EXT_blend_color = GL_TRUE;
+ ctx->Extensions.EXT_blend_func_separate = GL_TRUE;
+ ctx->Extensions.EXT_blend_logic_op = GL_TRUE;
+ ctx->Extensions.EXT_blend_minmax = GL_TRUE;
+ ctx->Extensions.EXT_blend_subtract = GL_TRUE;
+ ctx->Extensions.EXT_fog_coord = GL_TRUE;
+ ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE;
+ ctx->Extensions.EXT_point_parameters = GL_TRUE;
+ ctx->Extensions.EXT_secondary_color = GL_TRUE;
+ ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
+ ctx->Extensions.EXT_texture_lod_bias = GL_TRUE;
+ ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
+}
+
+
+/**
+ * Enable all OpenGL 1.5 features and extensions.
+ * A convenience function to be called by drivers.
+ */
+void
+_mesa_enable_1_5_extensions(GLcontext *ctx)
+{
+ ctx->Extensions.ARB_occlusion_query = GL_TRUE;
+ ctx->Extensions.ARB_vertex_buffer_object = GL_TRUE;
+ ctx->Extensions.EXT_shadow_funcs = GL_TRUE;
+}
+
+
+/**
+ * Enable all OpenGL 2.0 features and extensions.
+ * A convenience function to be called by drivers.
+ */
+void
+_mesa_enable_2_0_extensions(GLcontext *ctx)
+{
+ ctx->Extensions.ARB_draw_buffers = GL_TRUE;
+#if 0 && FEATURE_ARB_fragment_shader
+ ctx->Extensions.ARB_fragment_shader = GL_TRUE;
+#endif
+ ctx->Extensions.ARB_point_sprite = GL_TRUE;
+ ctx->Extensions.ARB_texture_non_power_of_two = GL_TRUE;
+#if 0 && FEATURE_ARB_shader_objects
+ ctx->Extensions.ARB_shader_objects = GL_TRUE;
+#endif
+#if 0 && FEATURE_ARB_shading_language_100
+ ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
+#endif
+ ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
+#if 0 && FEATURE_ARB_vertex_shader
+ ctx->Extensions.ARB_vertex_shader = GL_TRUE;
+#endif
+}
+
+
+
+/**
+ * Either enable or disable the named extension.
+ */
+static void
+set_extension( GLcontext *ctx, const char *name, GLboolean state )
+{
+ GLboolean *base = (GLboolean *) &ctx->Extensions;
+ GLuint i;
+
+ if (ctx->Extensions.String) {
+ /* The string was already queried - can't change it now! */
+ _mesa_problem(ctx, "Trying to enable/disable extension after glGetString(GL_EXTENSIONS): %s", name);
+ return;
+ }
+
+ for (i = 0 ; i < Elements(default_extensions) ; i++) {
+ if (_mesa_strcmp(default_extensions[i].name, name) == 0) {
+ if (default_extensions[i].flag_offset) {
+ GLboolean *enabled = base + default_extensions[i].flag_offset;
+ *enabled = state;
+ }
+ return;
+ }
+ }
+ _mesa_problem(ctx, "Trying to enable unknown extension: %s", name);
+}
+
+
+/**
+ * Enable the named extension.
+ * Typically called by drivers.
+ */
+void
+_mesa_enable_extension( GLcontext *ctx, const char *name )
+{
+ set_extension(ctx, name, GL_TRUE);
+}
+
+
+/**
+ * Disable the named extension.
+ * XXX is this really needed???
+ */
+void
+_mesa_disable_extension( GLcontext *ctx, const char *name )
+{
+ set_extension(ctx, name, GL_FALSE);
+}
+
+
+/**
+ * Test if the named extension is enabled in this context.
+ */
+GLboolean
+_mesa_extension_is_enabled( GLcontext *ctx, const char *name )
+{
+ const GLboolean *base = (const GLboolean *) &ctx->Extensions;
+ GLuint i;
+
+ for (i = 0 ; i < Elements(default_extensions) ; i++) {
+ if (_mesa_strcmp(default_extensions[i].name, name) == 0) {
+ if (!default_extensions[i].flag_offset)
+ return GL_TRUE;
+ return *(base + default_extensions[i].flag_offset);
+ }
+ }
+ return GL_FALSE;
+}
+
+
+/**
+ * Run through the default_extensions array above and set the
+ * ctx->Extensions.ARB/EXT_* flags accordingly.
+ * To be called during context initialization.
+ */
+void
+_mesa_init_extensions( GLcontext *ctx )
+{
+ GLboolean *base = (GLboolean *) &ctx->Extensions;
+ GLuint i;
+
+ for (i = 0 ; i < Elements(default_extensions) ; i++) {
+ if (default_extensions[i].enabled &&
+ default_extensions[i].flag_offset) {
+ *(base + default_extensions[i].flag_offset) = GL_TRUE;
+ }
+ }
+}
+
+
+/**
+ * Construct the GL_EXTENSIONS string. Called the first time that
+ * glGetString(GL_EXTENSIONS) is called.
+ */
+GLubyte *
+_mesa_make_extension_string( GLcontext *ctx )
+{
+ const GLboolean *base = (const GLboolean *) &ctx->Extensions;
+ GLuint extStrLen = 0;
+ GLubyte *s;
+ GLuint i;
+
+ /* first, compute length of the extension string */
+ for (i = 0 ; i < Elements(default_extensions) ; i++) {
+ if (!default_extensions[i].flag_offset ||
+ *(base + default_extensions[i].flag_offset)) {
+ extStrLen += (GLuint)_mesa_strlen(default_extensions[i].name) + 1;
+ }
+ }
+ s = (GLubyte *) _mesa_malloc(extStrLen);
+
+ /* second, build the extension string */
+ extStrLen = 0;
+ for (i = 0 ; i < Elements(default_extensions) ; i++) {
+ if (!default_extensions[i].flag_offset ||
+ *(base + default_extensions[i].flag_offset)) {
+ GLuint len = (GLuint)_mesa_strlen(default_extensions[i].name);
+ _mesa_memcpy(s + extStrLen, default_extensions[i].name, len);
+ extStrLen += len;
+ s[extStrLen] = (GLubyte) ' ';
+ extStrLen++;
+ }
+ }
+ ASSERT(extStrLen > 0);
+
+ s[extStrLen - 1] = 0;
+
+ return s;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/extensions.h b/nx-X11/extras/Mesa/src/mesa/main/extensions.h
new file mode 100644
index 000000000..9d843a8b6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/extensions.h
@@ -0,0 +1,84 @@
+/**
+ * \file extensions.h
+ * Extension handling.
+ *
+ * \if subset
+ * (No-op)
+ *
+ * \endif
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef _EXTENSIONS_H_
+#define _EXTENSIONS_H_
+
+#include "mtypes.h"
+
+#if _HAVE_FULL_GL
+
+extern void _mesa_enable_sw_extensions(GLcontext *ctx);
+
+extern void _mesa_enable_imaging_extensions(GLcontext *ctx);
+
+extern void _mesa_enable_1_3_extensions(GLcontext *ctx);
+
+extern void _mesa_enable_1_4_extensions(GLcontext *ctx);
+
+extern void _mesa_enable_1_5_extensions(GLcontext *ctx);
+
+extern void _mesa_enable_2_0_extensions(GLcontext *ctx);
+
+extern void _mesa_enable_extension(GLcontext *ctx, const char *name);
+
+extern void _mesa_disable_extension(GLcontext *ctx, const char *name);
+
+extern GLboolean _mesa_extension_is_enabled(GLcontext *ctx, const char *name);
+
+extern void _mesa_init_extensions(GLcontext *ctx);
+
+extern GLubyte *_mesa_make_extension_string(GLcontext *ctx);
+
+#else
+
+/** No-op */
+#define _mesa_extensions_dtr( ctx ) ((void)0)
+
+/** No-op */
+#define _mesa_extensions_ctr( ctx ) ((void)0)
+
+/** No-op */
+#define _mesa_extensions_get_string( ctx ) "GL_EXT_texture_object"
+
+/** No-op */
+#define _mesa_enable_imaging_extensions( c ) ((void)0)
+
+/** No-op */
+#define _mesa_enable_extension( c, n ) ((void)0)
+
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/fbobject.c b/nx-X11/extras/Mesa/src/mesa/main/fbobject.c
new file mode 100644
index 000000000..b16e13a22
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/fbobject.c
@@ -0,0 +1,1357 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/*
+ * Authors:
+ * Brian Paul
+ */
+
+
+#include "context.h"
+#include "fbobject.h"
+#include "framebuffer.h"
+#include "hash.h"
+#include "renderbuffer.h"
+#include "teximage.h"
+#include "texstore.h"
+
+
+/**
+ * Notes:
+ *
+ * None of the GL_EXT_framebuffer_object functions are compiled into
+ * display lists.
+ */
+
+
+
+/*
+ * When glGenRender/FramebuffersEXT() is called we insert pointers to
+ * these placeholder objects into the hash table.
+ * Later, when the object ID is first bound, we replace the placeholder
+ * with the real frame/renderbuffer.
+ */
+static struct gl_framebuffer DummyFramebuffer;
+static struct gl_renderbuffer DummyRenderbuffer;
+
+
+#define IS_CUBE_FACE(TARGET) \
+ ((TARGET) >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && \
+ (TARGET) <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)
+
+
+/**
+ * Helper routine for getting a gl_renderbuffer.
+ */
+static struct gl_renderbuffer *
+lookup_renderbuffer(GLcontext *ctx, GLuint id)
+{
+ struct gl_renderbuffer *rb;
+
+ if (id == 0)
+ return NULL;
+
+ rb = (struct gl_renderbuffer *)
+ _mesa_HashLookup(ctx->Shared->RenderBuffers, id);
+ return rb;
+}
+
+
+/**
+ * Helper routine for getting a gl_framebuffer.
+ */
+static struct gl_framebuffer *
+lookup_framebuffer(GLcontext *ctx, GLuint id)
+{
+ struct gl_framebuffer *fb;
+
+ if (id == 0)
+ return NULL;
+
+ fb = (struct gl_framebuffer *)
+ _mesa_HashLookup(ctx->Shared->FrameBuffers, id);
+ return fb;
+}
+
+
+/**
+ * Given a GL_*_ATTACHMENTn token, return a pointer to the corresponding
+ * gl_renderbuffer_attachment object.
+ */
+static struct gl_renderbuffer_attachment *
+get_attachment(GLcontext *ctx, struct gl_framebuffer *fb, GLenum attachment)
+{
+ GLuint i;
+
+ switch (attachment) {
+ case GL_COLOR_ATTACHMENT0_EXT:
+ case GL_COLOR_ATTACHMENT1_EXT:
+ case GL_COLOR_ATTACHMENT2_EXT:
+ case GL_COLOR_ATTACHMENT3_EXT:
+ case GL_COLOR_ATTACHMENT4_EXT:
+ case GL_COLOR_ATTACHMENT5_EXT:
+ case GL_COLOR_ATTACHMENT6_EXT:
+ case GL_COLOR_ATTACHMENT7_EXT:
+ case GL_COLOR_ATTACHMENT8_EXT:
+ case GL_COLOR_ATTACHMENT9_EXT:
+ case GL_COLOR_ATTACHMENT10_EXT:
+ case GL_COLOR_ATTACHMENT11_EXT:
+ case GL_COLOR_ATTACHMENT12_EXT:
+ case GL_COLOR_ATTACHMENT13_EXT:
+ case GL_COLOR_ATTACHMENT14_EXT:
+ case GL_COLOR_ATTACHMENT15_EXT:
+ i = attachment - GL_COLOR_ATTACHMENT0_EXT;
+ if (i >= ctx->Const.MaxColorAttachments) {
+ return NULL;
+ }
+ return &fb->Attachment[BUFFER_COLOR0 + i];
+ case GL_DEPTH_ATTACHMENT_EXT:
+ return &fb->Attachment[BUFFER_DEPTH];
+ case GL_STENCIL_ATTACHMENT_EXT:
+ return &fb->Attachment[BUFFER_STENCIL];
+ default:
+ return NULL;
+ }
+}
+
+
+/**
+ * Remove any texture or renderbuffer attached to the given attachment
+ * point. Update reference counts, etc.
+ */
+void
+_mesa_remove_attachment(GLcontext *ctx, struct gl_renderbuffer_attachment *att)
+{
+ if (att->Type == GL_TEXTURE) {
+ ASSERT(att->Texture);
+ if (att->Renderbuffer) {
+ /* delete/remove the 'wrapper' renderbuffer */
+ /* XXX do we really want to do this??? */
+ att->Renderbuffer->Delete(att->Renderbuffer);
+ att->Renderbuffer = NULL;
+ }
+ att->Texture->RefCount--;
+ if (att->Texture->RefCount == 0) {
+ ctx->Driver.DeleteTexture(ctx, att->Texture);
+ }
+ att->Texture = NULL;
+ }
+ else if (att->Type == GL_RENDERBUFFER_EXT) {
+ ASSERT(att->Renderbuffer);
+ ASSERT(!att->Texture);
+ att->Renderbuffer->RefCount--;
+ if (att->Renderbuffer->RefCount == 0) {
+ att->Renderbuffer->Delete(att->Renderbuffer);
+ }
+ att->Renderbuffer = NULL;
+ }
+ att->Type = GL_NONE;
+ att->Complete = GL_TRUE;
+}
+
+
+/**
+ * Bind a texture object to an attachment point.
+ * The previous binding, if any, will be removed first.
+ */
+void
+_mesa_set_texture_attachment(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_texture_object *texObj,
+ GLenum texTarget, GLuint level, GLuint zoffset)
+{
+ _mesa_remove_attachment(ctx, att);
+ att->Type = GL_TEXTURE;
+ att->Texture = texObj;
+ att->TextureLevel = level;
+ if (IS_CUBE_FACE(texTarget)) {
+ att->CubeMapFace = texTarget - GL_TEXTURE_CUBE_MAP_POSITIVE_X;
+ }
+ else {
+ att->CubeMapFace = 0;
+ }
+ att->Zoffset = zoffset;
+ att->Complete = GL_FALSE;
+
+ texObj->RefCount++;
+
+ /* XXX when we attach to a texture, we should probably set the
+ * att->Renderbuffer pointer to a "wrapper renderbuffer" which
+ * makes the texture image look like renderbuffer.
+ */
+}
+
+
+/**
+ * Bind a renderbuffer to an attachment point.
+ * The previous binding, if any, will be removed first.
+ */
+void
+_mesa_set_renderbuffer_attachment(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_renderbuffer *rb)
+{
+ _mesa_remove_attachment(ctx, att);
+ att->Type = GL_RENDERBUFFER_EXT;
+ att->Renderbuffer = rb;
+ att->Texture = NULL; /* just to be safe */
+ att->Complete = GL_FALSE;
+ rb->RefCount++;
+}
+
+
+/**
+ * Fallback for ctx->Driver.FramebufferRenderbuffer()
+ * Sets a framebuffer attachment to a particular renderbuffer.
+ * The framebuffer in question is ctx->DrawBuffer.
+ * \sa _mesa_renderbuffer_texture
+ */
+void
+_mesa_framebuffer_renderbuffer(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_renderbuffer *rb)
+{
+ if (rb) {
+ _mesa_set_renderbuffer_attachment(ctx, att, rb);
+ }
+ else {
+ _mesa_remove_attachment(ctx, att);
+ }
+}
+
+
+/**
+ * Test if an attachment point is complete and update its Complete field.
+ * \param format if GL_COLOR, this is a color attachment point,
+ * if GL_DEPTH, this is a depth component attachment point,
+ * if GL_STENCIL, this is a stencil component attachment point.
+ */
+static void
+test_attachment_completeness(const GLcontext *ctx, GLenum format,
+ struct gl_renderbuffer_attachment *att)
+{
+ assert(format == GL_COLOR || format == GL_DEPTH || format == GL_STENCIL);
+
+ /* assume complete */
+ att->Complete = GL_TRUE;
+
+ /* Look for reasons why the attachment might be incomplete */
+ if (att->Type == GL_TEXTURE) {
+ const struct gl_texture_object *texObj = att->Texture;
+ struct gl_texture_image *texImage;
+
+ if (!texObj) {
+ att->Complete = GL_FALSE;
+ return;
+ }
+
+ texImage = texObj->Image[att->CubeMapFace][att->TextureLevel];
+ if (!texImage) {
+ att->Complete = GL_FALSE;
+ return;
+ }
+ if (texImage->Width < 1 || texImage->Height < 1) {
+ att->Complete = GL_FALSE;
+ return;
+ }
+ if (texObj->Target == GL_TEXTURE_3D && att->Zoffset >= texImage->Depth) {
+ att->Complete = GL_FALSE;
+ return;
+ }
+
+ if (format == GL_COLOR) {
+ if (texImage->TexFormat->BaseFormat != GL_RGB &&
+ texImage->TexFormat->BaseFormat != GL_RGBA) {
+ att->Complete = GL_FALSE;
+ return;
+ }
+ }
+ else if (format == GL_DEPTH) {
+ if (texImage->TexFormat->BaseFormat != GL_DEPTH_COMPONENT) {
+ att->Complete = GL_FALSE;
+ return;
+ }
+ }
+ else {
+ /* no such thing as stencil textures */
+ att->Complete = GL_FALSE;
+ return;
+ }
+ }
+ else if (att->Type == GL_RENDERBUFFER_EXT) {
+ if (att->Renderbuffer->Width < 1 || att->Renderbuffer->Height < 1) {
+ att->Complete = GL_FALSE;
+ return;
+ }
+ if (format == GL_COLOR) {
+ if (att->Renderbuffer->_BaseFormat != GL_RGB &&
+ att->Renderbuffer->_BaseFormat != GL_RGBA) {
+ att->Complete = GL_FALSE;
+ return;
+ }
+ }
+ else if (format == GL_DEPTH) {
+ if (att->Renderbuffer->_BaseFormat != GL_DEPTH_COMPONENT) {
+ att->Complete = GL_FALSE;
+ return;
+ }
+ }
+ else {
+ assert(format == GL_STENCIL);
+ if (att->Renderbuffer->_BaseFormat != GL_STENCIL_INDEX) {
+ att->Complete = GL_FALSE;
+ return;
+ }
+ }
+ }
+ else {
+ ASSERT(att->Type == GL_NONE);
+ /* complete */
+ return;
+ }
+}
+
+
+/**
+ * Test if the given framebuffer object is complete and update its
+ * Status field with the results.
+ * Also update the framebuffer's Width and Height fields if the
+ * framebuffer is complete.
+ */
+void
+_mesa_test_framebuffer_completeness(GLcontext *ctx, struct gl_framebuffer *fb)
+{
+ GLuint numImages, width = 0, height = 0;
+ GLenum intFormat = GL_NONE;
+ GLuint w = 0, h = 0;
+ GLint i;
+
+ assert(fb->Name != 0);
+
+ numImages = 0;
+ fb->Width = 0;
+ fb->Height = 0;
+
+ /* Start at -2 to more easily loop over all attachment points */
+ for (i = -2; i < (GLint) ctx->Const.MaxColorAttachments; i++) {
+ struct gl_renderbuffer_attachment *att;
+ GLenum f;
+
+ if (i == -2) {
+ att = &fb->Attachment[BUFFER_DEPTH];
+ test_attachment_completeness(ctx, GL_DEPTH, att);
+ if (!att->Complete) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT;
+ return;
+ }
+ }
+ else if (i == -1) {
+ att = &fb->Attachment[BUFFER_STENCIL];
+ test_attachment_completeness(ctx, GL_STENCIL, att);
+ if (!att->Complete) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT;
+ return;
+ }
+ }
+ else {
+ att = &fb->Attachment[BUFFER_COLOR0 + i];
+ test_attachment_completeness(ctx, GL_COLOR, att);
+ if (!att->Complete) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT;
+ return;
+ }
+ }
+
+ if (att->Type == GL_TEXTURE) {
+ w = att->Texture->Image[att->CubeMapFace][att->TextureLevel]->Width;
+ h = att->Texture->Image[att->CubeMapFace][att->TextureLevel]->Height;
+ f = att->Texture->Image[att->CubeMapFace][att->TextureLevel]->Format;
+ numImages++;
+ if (f != GL_RGB && f != GL_RGBA && f != GL_DEPTH_COMPONENT) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT;
+ return;
+ }
+ }
+ else if (att->Type == GL_RENDERBUFFER_EXT) {
+ w = att->Renderbuffer->Width;
+ h = att->Renderbuffer->Height;
+ f = att->Renderbuffer->InternalFormat;
+ numImages++;
+ }
+ else {
+ assert(att->Type == GL_NONE);
+ continue;
+ }
+
+ if (numImages == 1) {
+ /* set required width, height and format */
+ width = w;
+ height = h;
+ if (i >= 0)
+ intFormat = f;
+ }
+ else {
+ /* check that width, height, format are same */
+ if (w != width || h != height) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT;
+ return;
+ }
+ if (intFormat != GL_NONE && f != intFormat) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT;
+ return;
+ }
+ }
+ }
+
+ /* Check that all DrawBuffers are present */
+ for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
+ if (fb->ColorDrawBuffer[i] != GL_NONE) {
+ const struct gl_renderbuffer_attachment *att
+ = get_attachment(ctx, fb, fb->ColorDrawBuffer[i]);
+ assert(att);
+ if (att->Type == GL_NONE) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT;
+ return;
+ }
+ }
+ }
+
+ /* Check that the ReadBuffer is present */
+ if (fb->ColorReadBuffer != GL_NONE) {
+ const struct gl_renderbuffer_attachment *att
+ = get_attachment(ctx, fb, fb->ColorReadBuffer);
+ assert(att);
+ if (att->Type == GL_NONE) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT;
+ return;
+ }
+ }
+
+ /* Check if any renderbuffer is attached more than once */
+ for (i = 0; i < BUFFER_COUNT - 1; i++) {
+ struct gl_renderbuffer *rb_i = fb->Attachment[i].Renderbuffer;
+ if (rb_i) {
+ GLint j;
+ for (j = i + 1; j < BUFFER_COUNT; j++) {
+ struct gl_renderbuffer *rb_j = fb->Attachment[j].Renderbuffer;
+ if (rb_i == rb_j) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT;
+ return;
+ }
+ }
+ }
+ }
+
+
+ if (numImages == 0) {
+ fb->_Status = GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT;
+ return;
+ }
+
+ /*
+ * If we get here, the framebuffer is complete!
+ */
+ fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT;
+ fb->Width = w;
+ fb->Height = h;
+}
+
+
+GLboolean GLAPIENTRY
+_mesa_IsRenderbufferEXT(GLuint renderbuffer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+ if (renderbuffer) {
+ struct gl_renderbuffer *rb = lookup_renderbuffer(ctx, renderbuffer);
+ if (rb != NULL && rb != &DummyRenderbuffer)
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+}
+
+
+void GLAPIENTRY
+_mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer)
+{
+ struct gl_renderbuffer *newRb, *oldRb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target != GL_RENDERBUFFER_EXT) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glBindRenderbufferEXT(target)");
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+ if (renderbuffer) {
+ newRb = lookup_renderbuffer(ctx, renderbuffer);
+ if (newRb == &DummyRenderbuffer) {
+ /* ID was reserved, but no real renderbuffer object made yet */
+ newRb = NULL;
+ }
+ if (!newRb) {
+ /* create new renderbuffer object */
+ newRb = ctx->Driver.NewRenderbuffer(ctx, renderbuffer);
+ if (!newRb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindRenderbufferEXT");
+ return;
+ }
+ ASSERT(newRb->AllocStorage);
+ _mesa_HashInsert(ctx->Shared->RenderBuffers, renderbuffer, newRb);
+ }
+ newRb->RefCount++;
+ }
+ else {
+ newRb = NULL;
+ }
+
+ oldRb = ctx->CurrentRenderbuffer;
+ if (oldRb) {
+ oldRb->RefCount--;
+ if (oldRb->RefCount == 0) {
+ oldRb->Delete(oldRb);
+ }
+ }
+
+ ASSERT(newRb != &DummyRenderbuffer);
+
+ ctx->CurrentRenderbuffer = newRb;
+}
+
+
+void GLAPIENTRY
+_mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers)
+{
+ GLint i;
+ GET_CURRENT_CONTEXT(ctx);
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+ for (i = 0; i < n; i++) {
+ if (renderbuffers[i] > 0) {
+ struct gl_renderbuffer *rb;
+ rb = lookup_renderbuffer(ctx, renderbuffers[i]);
+ if (rb) {
+ /* check if deleting currently bound renderbuffer object */
+ if (rb == ctx->CurrentRenderbuffer) {
+ /* bind default */
+ ASSERT(rb->RefCount >= 2);
+ _mesa_BindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
+ }
+
+ /* remove from hash table immediately, to free the ID */
+ _mesa_HashRemove(ctx->Shared->RenderBuffers, renderbuffers[i]);
+
+ if (rb != &DummyRenderbuffer) {
+ /* But the object will not be freed until it's no longer
+ * bound in any context.
+ */
+ rb->RefCount--;
+ if (rb->RefCount == 0) {
+ rb->Delete(rb);
+ }
+ }
+ }
+ }
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint first;
+ GLint i;
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (n < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGenRenderbuffersEXT(n)");
+ return;
+ }
+
+ if (!renderbuffers)
+ return;
+
+ first = _mesa_HashFindFreeKeyBlock(ctx->Shared->RenderBuffers, n);
+
+ for (i = 0; i < n; i++) {
+ GLuint name = first + i;
+ renderbuffers[i] = name;
+ /* insert dummy placeholder into hash table */
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+ _mesa_HashInsert(ctx->Shared->RenderBuffers, name, &DummyRenderbuffer);
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+ }
+}
+
+
+/**
+ * Given an internal format token for a render buffer, return the
+ * corresponding base format.
+ * \return one of GL_RGB, GL_RGBA, GL_STENCIL_INDEX, GL_DEPTH_COMPONENT
+ * or zero if error.
+ */
+static GLenum
+base_internal_format(GLcontext *ctx, GLenum internalFormat)
+{
+ switch (internalFormat) {
+ 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;
+ case GL_STENCIL_INDEX:
+ case GL_STENCIL_INDEX1_EXT:
+ case GL_STENCIL_INDEX4_EXT:
+ case GL_STENCIL_INDEX8_EXT:
+ case GL_STENCIL_INDEX16_EXT:
+ return GL_STENCIL_INDEX;
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT16:
+ case GL_DEPTH_COMPONENT24:
+ case GL_DEPTH_COMPONENT32:
+ return GL_DEPTH_COMPONENT;
+ /* XXX add floating point formats eventually */
+ default:
+ return 0;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat,
+ GLsizei width, GLsizei height)
+{
+ struct gl_renderbuffer *rb;
+ GLenum baseFormat;
+ GET_CURRENT_CONTEXT(ctx);
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target != GL_RENDERBUFFER_EXT) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glRenderbufferStorageEXT(target)");
+ return;
+ }
+
+ baseFormat = base_internal_format(ctx, internalFormat);
+ if (baseFormat == 0) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glRenderbufferStorageEXT(internalFormat)");
+ return;
+ }
+
+ if (width < 1 || width > ctx->Const.MaxRenderbufferSize) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glRenderbufferStorageEXT(width)");
+ return;
+ }
+
+ if (height < 1 || height > ctx->Const.MaxRenderbufferSize) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glRenderbufferStorageEXT(height)");
+ return;
+ }
+
+ rb = ctx->CurrentRenderbuffer;
+
+ if (!rb) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glRenderbufferStorageEXT");
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+ /* Now allocate the storage */
+ ASSERT(rb->AllocStorage);
+ if (rb->AllocStorage(ctx, rb, internalFormat, width, height)) {
+ /* No error - check/set fields now */
+ assert(rb->Width == width);
+ assert(rb->Height == height);
+ assert(rb->InternalFormat);
+ rb->_BaseFormat = baseFormat;
+ }
+ else {
+ /* Probably ran out of memory - clear the fields */
+ rb->Width = 0;
+ rb->Height = 0;
+ rb->InternalFormat = GL_NONE;
+ rb->_BaseFormat = GL_NONE;
+ }
+
+ /*
+ test_framebuffer_completeness(ctx, fb);
+ */
+ /* XXX if this renderbuffer is attached anywhere, invalidate attachment
+ * points???
+ */
+}
+
+
+void GLAPIENTRY
+_mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname, GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target != GL_RENDERBUFFER_EXT) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetRenderbufferParameterivEXT(target)");
+ return;
+ }
+
+ if (!ctx->CurrentRenderbuffer) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetRenderbufferParameterivEXT");
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+ switch (pname) {
+ case GL_RENDERBUFFER_WIDTH_EXT:
+ *params = ctx->CurrentRenderbuffer->Width;
+ return;
+ case GL_RENDERBUFFER_HEIGHT_EXT:
+ *params = ctx->CurrentRenderbuffer->Height;
+ return;
+ case GL_RENDERBUFFER_INTERNAL_FORMAT_EXT:
+ *params = ctx->CurrentRenderbuffer->InternalFormat;
+ return;
+ case GL_RENDERBUFFER_RED_SIZE_EXT:
+ if (ctx->CurrentRenderbuffer->_BaseFormat == GL_RGB ||
+ ctx->CurrentRenderbuffer->_BaseFormat == GL_RGBA) {
+ *params = ctx->CurrentRenderbuffer->ComponentSizes[0];
+ }
+ else {
+ *params = 0;
+ }
+ break;
+ case GL_RENDERBUFFER_GREEN_SIZE_EXT:
+ if (ctx->CurrentRenderbuffer->_BaseFormat == GL_RGB ||
+ ctx->CurrentRenderbuffer->_BaseFormat == GL_RGBA) {
+ *params = ctx->CurrentRenderbuffer->ComponentSizes[1];
+ }
+ else {
+ *params = 0;
+ }
+ break;
+ case GL_RENDERBUFFER_BLUE_SIZE_EXT:
+ if (ctx->CurrentRenderbuffer->_BaseFormat == GL_RGB ||
+ ctx->CurrentRenderbuffer->_BaseFormat == GL_RGBA) {
+ *params = ctx->CurrentRenderbuffer->ComponentSizes[2];
+ }
+ else {
+ *params = 0;
+ }
+ break;
+ case GL_RENDERBUFFER_ALPHA_SIZE_EXT:
+ if (ctx->CurrentRenderbuffer->_BaseFormat == GL_RGB ||
+ ctx->CurrentRenderbuffer->_BaseFormat == GL_RGBA) {
+ *params = ctx->CurrentRenderbuffer->ComponentSizes[3];
+ }
+ else {
+ *params = 0;
+ }
+ break;
+ case GL_RENDERBUFFER_DEPTH_SIZE_EXT:
+ if (ctx->CurrentRenderbuffer->_BaseFormat == GL_DEPTH_COMPONENT) {
+ *params = ctx->CurrentRenderbuffer->ComponentSizes[0];
+ }
+ else {
+ *params = 0;
+ }
+ break;
+ case GL_RENDERBUFFER_STENCIL_SIZE_EXT:
+ if (ctx->CurrentRenderbuffer->_BaseFormat == GL_STENCIL_INDEX) {
+ *params = ctx->CurrentRenderbuffer->ComponentSizes[0];
+ }
+ else {
+ *params = 0;
+ }
+ break;
+
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetRenderbufferParameterivEXT(target)");
+ return;
+ }
+}
+
+
+GLboolean GLAPIENTRY
+_mesa_IsFramebufferEXT(GLuint framebuffer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+ if (framebuffer) {
+ struct gl_framebuffer *rb = lookup_framebuffer(ctx, framebuffer);
+ if (rb != NULL && rb != &DummyFramebuffer)
+ return GL_TRUE;
+ }
+ return GL_FALSE;
+}
+
+
+void GLAPIENTRY
+_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer)
+{
+ struct gl_framebuffer *newFb, *newReadFb, *oldFb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target != GL_FRAMEBUFFER_EXT) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glBindFramebufferEXT(target)");
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+ if (framebuffer) {
+ /* Binding a user-created framebuffer object */
+ newFb = lookup_framebuffer(ctx, framebuffer);
+ if (newFb == &DummyFramebuffer) {
+ /* ID was reserved, but no real framebuffer object made yet */
+ newFb = NULL;
+ }
+ if (!newFb) {
+ /* create new framebuffer object */
+ newFb = ctx->Driver.NewFramebuffer(ctx, framebuffer);
+ if (!newFb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindFramebufferEXT");
+ return;
+ }
+ _mesa_HashInsert(ctx->Shared->FrameBuffers, framebuffer, newFb);
+ }
+ newFb->RefCount++;
+ newReadFb = newFb;
+ }
+ else {
+ /* Binding the window system framebuffer (which was originally set
+ * with MakeCurrent).
+ */
+ newFb = ctx->WinSysDrawBuffer;
+ newReadFb = ctx->WinSysReadBuffer;
+ }
+
+ oldFb = ctx->DrawBuffer;
+ if (oldFb && oldFb->Name != 0) {
+ oldFb->RefCount--;
+ if (oldFb->RefCount == 0) {
+ oldFb->Delete(oldFb);
+ }
+ }
+
+ ASSERT(newFb != &DummyFramebuffer);
+
+ /* Note, we set both the GL_DRAW_BUFFER and GL_READ_BUFFER state: */
+ ctx->DrawBuffer = newFb;
+ ctx->ReadBuffer = newReadFb;
+}
+
+
+void GLAPIENTRY
+_mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers)
+{
+ GLint i;
+ GET_CURRENT_CONTEXT(ctx);
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+ for (i = 0; i < n; i++) {
+ if (framebuffers[i] > 0) {
+ struct gl_framebuffer *fb;
+ fb = lookup_framebuffer(ctx, framebuffers[i]);
+ if (fb) {
+ ASSERT(fb == &DummyFramebuffer || fb->Name == framebuffers[i]);
+
+ /* check if deleting currently bound framebuffer object */
+ if (fb == ctx->DrawBuffer) {
+ /* bind default */
+ ASSERT(fb->RefCount >= 2);
+ _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ }
+
+ /* remove from hash table immediately, to free the ID */
+ _mesa_HashRemove(ctx->Shared->FrameBuffers, framebuffers[i]);
+
+ if (fb != &DummyFramebuffer) {
+ /* But the object will not be freed until it's no longer
+ * bound in any context.
+ */
+ fb->RefCount--;
+ if (fb->RefCount == 0) {
+ fb->Delete(fb);
+ }
+ }
+ }
+ }
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GenFramebuffersEXT(GLsizei n, GLuint *framebuffers)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint first;
+ GLint i;
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (n < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGenFramebuffersEXT(n)");
+ return;
+ }
+
+ if (!framebuffers)
+ return;
+
+ first = _mesa_HashFindFreeKeyBlock(ctx->Shared->FrameBuffers, n);
+
+ for (i = 0; i < n; i++) {
+ GLuint name = first + i;
+ framebuffers[i] = name;
+ /* insert dummy placeholder into hash table */
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+ _mesa_HashInsert(ctx->Shared->FrameBuffers, name, &DummyFramebuffer);
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+ }
+}
+
+
+
+GLenum GLAPIENTRY
+_mesa_CheckFramebufferStatusEXT(GLenum target)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
+
+ if (target != GL_FRAMEBUFFER_EXT) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCheckFramebufferStatus(target)");
+ return 0; /* formerly GL_FRAMEBUFFER_STATUS_ERROR_EXT */
+ }
+
+ if (ctx->DrawBuffer->Name == 0) {
+ /* The window system / default framebuffer is always complete */
+ return GL_FRAMEBUFFER_COMPLETE_EXT;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+ _mesa_test_framebuffer_completeness(ctx, ctx->DrawBuffer);
+ return ctx->DrawBuffer->_Status;
+}
+
+
+
+/**
+ * Do error checking common to glFramebufferTexture1D/2D/3DEXT.
+ * \return GL_TRUE if any error, GL_FALSE otherwise
+ */
+static GLboolean
+error_check_framebuffer_texture(GLcontext *ctx, GLuint dims,
+ GLenum target, GLenum attachment,
+ GLenum textarget, GLuint texture, GLint level)
+{
+ ASSERT(dims >= 1 && dims <= 3);
+
+ if (target != GL_FRAMEBUFFER_EXT) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferTexture%dDEXT(target)", dims);
+ return GL_TRUE;
+ }
+
+ /* check framebuffer binding */
+ if (ctx->DrawBuffer->Name == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glFramebufferTexture%dDEXT", dims);
+ return GL_TRUE;
+ }
+
+ /* only check textarget, level if texture ID is non-zero */
+ if (texture) {
+ if ((dims == 1 && textarget != GL_TEXTURE_1D) ||
+ (dims == 3 && textarget != GL_TEXTURE_3D) ||
+ (dims == 2 && textarget != GL_TEXTURE_2D &&
+ textarget != GL_TEXTURE_RECTANGLE_ARB &&
+ !IS_CUBE_FACE(textarget))) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glFramebufferTexture%dDEXT(textarget)", dims);
+ return GL_TRUE;
+ }
+
+ if ((level < 0) || level >= _mesa_max_texture_levels(ctx, textarget)) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glFramebufferTexture%dDEXT(level)", dims);
+ return GL_TRUE;
+ }
+ }
+
+ return GL_FALSE;
+}
+
+
+void GLAPIENTRY
+_mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment,
+ GLenum textarget, GLuint texture, GLint level)
+{
+ struct gl_renderbuffer_attachment *att;
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (error_check_framebuffer_texture(ctx, 1, target, attachment,
+ textarget, texture, level))
+ return;
+
+ ASSERT(textarget == GL_TEXTURE_1D);
+
+ att = get_attachment(ctx, ctx->DrawBuffer, attachment);
+ if (att == NULL) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferTexture1DEXT(attachment)");
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+ if (texture) {
+ texObj = (struct gl_texture_object *)
+ _mesa_HashLookup(ctx->Shared->TexObjects, texture);
+ if (!texObj) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glFramebufferTexture1DEXT(texture)");
+ return;
+ }
+ if (texObj->Target != textarget) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, /* XXX correct error? */
+ "glFramebufferTexture1DEXT(texture target)");
+ return;
+ }
+ }
+ else {
+ /* remove texture attachment */
+ texObj = NULL;
+ }
+ ctx->Driver.RenderbufferTexture(ctx, att, texObj, textarget, level, 0);
+}
+
+
+void GLAPIENTRY
+_mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment,
+ GLenum textarget, GLuint texture, GLint level)
+{
+ struct gl_renderbuffer_attachment *att;
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (error_check_framebuffer_texture(ctx, 2, target, attachment,
+ textarget, texture, level))
+ return;
+
+ ASSERT(textarget == GL_TEXTURE_2D ||
+ textarget == GL_TEXTURE_RECTANGLE_ARB ||
+ IS_CUBE_FACE(textarget));
+
+ att = get_attachment(ctx, ctx->DrawBuffer, attachment);
+ if (att == NULL) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferTexture2DEXT(attachment)");
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+ if (texture) {
+ texObj = (struct gl_texture_object *)
+ _mesa_HashLookup(ctx->Shared->TexObjects, texture);
+ if (!texObj) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glFramebufferTexture2DEXT(texture)");
+ return;
+ }
+ if ((texObj->Target == GL_TEXTURE_2D && textarget != GL_TEXTURE_2D) ||
+ (texObj->Target == GL_TEXTURE_RECTANGLE_ARB
+ && textarget != GL_TEXTURE_RECTANGLE_ARB) ||
+ (texObj->Target == GL_TEXTURE_CUBE_MAP
+ && !IS_CUBE_FACE(textarget))) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, /* XXX correct error? */
+ "glFramebufferTexture2DEXT(texture target)");
+ return;
+ }
+ }
+ else {
+ /* remove texture attachment */
+ texObj = NULL;
+ }
+ ctx->Driver.RenderbufferTexture(ctx, att, texObj, textarget, level, 0);
+}
+
+
+void GLAPIENTRY
+_mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment,
+ GLenum textarget, GLuint texture,
+ GLint level, GLint zoffset)
+{
+ struct gl_renderbuffer_attachment *att;
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (error_check_framebuffer_texture(ctx, 3, target, attachment,
+ textarget, texture, level))
+ return;
+
+ ASSERT(textarget == GL_TEXTURE_3D);
+
+ att = get_attachment(ctx, ctx->DrawBuffer, attachment);
+ if (att == NULL) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferTexture1DEXT(attachment)");
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+ if (texture) {
+ const GLint maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
+ texObj = (struct gl_texture_object *)
+ _mesa_HashLookup(ctx->Shared->TexObjects, texture);
+ if (!texObj) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glFramebufferTexture3DEXT(texture)");
+ return;
+ }
+ if (texObj->Target != textarget) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, /* XXX correct error? */
+ "glFramebufferTexture3DEXT(texture target)");
+ return;
+ }
+ if (zoffset < 0 || zoffset >= maxSize) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glFramebufferTexture3DEXT(zoffset)");
+ return;
+ }
+ }
+ else {
+ /* remove texture attachment */
+ texObj = NULL;
+ }
+ ctx->Driver.RenderbufferTexture(ctx, att, texObj, textarget,
+ level, zoffset);
+}
+
+
+void GLAPIENTRY
+_mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
+ GLenum renderbufferTarget,
+ GLuint renderbuffer)
+{
+ struct gl_renderbuffer_attachment *att;
+ struct gl_renderbuffer *rb;
+ GET_CURRENT_CONTEXT(ctx);
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target != GL_FRAMEBUFFER_EXT) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferRenderbufferEXT(target)");
+ return;
+ }
+
+ if (renderbufferTarget != GL_RENDERBUFFER_EXT) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferRenderbufferEXT(renderbufferTarget)");
+ return;
+ }
+
+ if (ctx->DrawBuffer->Name == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glFramebufferRenderbufferEXT");
+ return;
+ }
+
+ att = get_attachment(ctx, ctx->DrawBuffer, attachment);
+ if (att == NULL) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glFramebufferRenderbufferEXT(attachment)");
+ return;
+ }
+
+ if (renderbuffer) {
+ rb = lookup_renderbuffer(ctx, renderbuffer);
+ if (!rb) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glFramebufferRenderbufferEXT(renderbuffer)");
+ return;
+ }
+ }
+ else {
+ /* remove renderbuffer attachment */
+ rb = NULL;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+ assert(ctx->Driver.FramebufferRenderbuffer);
+ ctx->Driver.FramebufferRenderbuffer(ctx, att, rb);
+}
+
+
+void GLAPIENTRY
+_mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
+ GLenum pname, GLint *params)
+{
+ const struct gl_renderbuffer_attachment *att;
+ GET_CURRENT_CONTEXT(ctx);
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target != GL_FRAMEBUFFER_EXT) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetFramebufferAttachmentParameterivEXT(target)");
+ return;
+ }
+
+ if (ctx->DrawBuffer->Name == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetFramebufferAttachmentParameterivEXT");
+ return;
+ }
+
+ att = get_attachment(ctx, ctx->DrawBuffer, attachment);
+ if (att == NULL) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetFramebufferAttachmentParameterivEXT(attachment)");
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+ switch (pname) {
+ case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT:
+ *params = att->Type;
+ return;
+ case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT:
+ if (att->Type == GL_RENDERBUFFER_EXT) {
+ *params = att->Renderbuffer->Name;
+ }
+ else if (att->Type == GL_TEXTURE) {
+ *params = att->Texture->Name;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetFramebufferAttachmentParameterivEXT(pname)");
+ }
+ return;
+ case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT:
+ if (att->Type == GL_TEXTURE) {
+ *params = att->TextureLevel;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetFramebufferAttachmentParameterivEXT(pname)");
+ }
+ return;
+ case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT:
+ if (att->Type == GL_TEXTURE) {
+ *params = GL_TEXTURE_CUBE_MAP_POSITIVE_X + att->CubeMapFace;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetFramebufferAttachmentParameterivEXT(pname)");
+ }
+ return;
+ case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT:
+ if (att->Type == GL_TEXTURE) {
+ *params = att->Zoffset;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetFramebufferAttachmentParameterivEXT(pname)");
+ }
+ return;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetFramebufferAttachmentParameterivEXT(pname)");
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GenerateMipmapEXT(GLenum target)
+{
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ GET_CURRENT_CONTEXT(ctx);
+
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+ FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+
+ switch (target) {
+ case GL_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ case GL_TEXTURE_CUBE_MAP:
+ /* OK, legal value */
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGenerateMipmapEXT(target)");
+ return;
+ }
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+
+ /* XXX this might not handle cube maps correctly */
+ _mesa_generate_mipmap(ctx, target, texUnit, texObj);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/fbobject.h b/nx-X11/extras/Mesa/src/mesa/main/fbobject.h
new file mode 100644
index 000000000..2c86ef937
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/fbobject.h
@@ -0,0 +1,114 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef FBOBJECT_H
+#define FBOBJECT_H
+
+
+extern void
+_mesa_remove_attachment(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att);
+
+extern void
+_mesa_set_texture_attachment(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_texture_object *texObj,
+ GLenum texTarget, GLuint level, GLuint zoffset);
+
+extern void
+_mesa_set_renderbuffer_attachment(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_renderbuffer *rb);
+
+extern void
+_mesa_framebuffer_renderbuffer(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_renderbuffer *rb);
+
+extern void
+_mesa_test_framebuffer_completeness(GLcontext *ctx, struct gl_framebuffer *fb);
+
+extern GLboolean GLAPIENTRY
+_mesa_IsRenderbufferEXT(GLuint renderbuffer);
+
+extern void GLAPIENTRY
+_mesa_BindRenderbufferEXT(GLenum target, GLuint renderbuffer);
+
+extern void GLAPIENTRY
+_mesa_DeleteRenderbuffersEXT(GLsizei n, const GLuint *renderbuffers);
+
+extern void GLAPIENTRY
+_mesa_GenRenderbuffersEXT(GLsizei n, GLuint *renderbuffers);
+
+extern void GLAPIENTRY
+_mesa_RenderbufferStorageEXT(GLenum target, GLenum internalformat,
+ GLsizei width, GLsizei height);
+
+extern void GLAPIENTRY
+_mesa_GetRenderbufferParameterivEXT(GLenum target, GLenum pname,
+ GLint *params);
+
+extern GLboolean GLAPIENTRY
+_mesa_IsFramebufferEXT(GLuint framebuffer);
+
+extern void GLAPIENTRY
+_mesa_BindFramebufferEXT(GLenum target, GLuint framebuffer);
+
+extern void GLAPIENTRY
+_mesa_DeleteFramebuffersEXT(GLsizei n, const GLuint *framebuffers);
+
+extern void GLAPIENTRY
+_mesa_GenFramebuffersEXT(GLsizei n, GLuint *framebuffers);
+
+extern GLenum GLAPIENTRY
+_mesa_CheckFramebufferStatusEXT(GLenum target);
+
+extern void GLAPIENTRY
+_mesa_FramebufferTexture1DEXT(GLenum target, GLenum attachment,
+ GLenum textarget, GLuint texture, GLint level);
+
+extern void GLAPIENTRY
+_mesa_FramebufferTexture2DEXT(GLenum target, GLenum attachment,
+ GLenum textarget, GLuint texture, GLint level);
+
+extern void GLAPIENTRY
+_mesa_FramebufferTexture3DEXT(GLenum target, GLenum attachment,
+ GLenum textarget, GLuint texture,
+ GLint level, GLint zoffset);
+
+extern void GLAPIENTRY
+_mesa_FramebufferRenderbufferEXT(GLenum target, GLenum attachment,
+ GLenum renderbuffertarget,
+ GLuint renderbuffer);
+
+extern void GLAPIENTRY
+_mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
+ GLenum pname, GLint *params);
+
+extern void GLAPIENTRY
+_mesa_GenerateMipmapEXT(GLenum target);
+
+
+#endif /* FBOBJECT_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/main/feedback.c b/nx-X11/extras/Mesa/src/mesa/main/feedback.c
new file mode 100644
index 000000000..48c2ccbff
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/feedback.c
@@ -0,0 +1,541 @@
+/**
+ * \file feedback.c
+ * Selection and feedback modes functions.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "enums.h"
+#include "feedback.h"
+#include "macros.h"
+#include "mtypes.h"
+
+
+#if _HAVE_FULL_GL
+
+
+#define FB_3D 0x01
+#define FB_4D 0x02
+#define FB_INDEX 0x04
+#define FB_COLOR 0x08
+#define FB_TEXTURE 0X10
+
+
+
+void GLAPIENTRY
+_mesa_FeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (ctx->RenderMode==GL_FEEDBACK) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glFeedbackBuffer" );
+ return;
+ }
+ if (size<0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(size<0)" );
+ return;
+ }
+ if (!buffer) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glFeedbackBuffer(buffer==NULL)" );
+ ctx->Feedback.BufferSize = 0;
+ return;
+ }
+
+ switch (type) {
+ case GL_2D:
+ ctx->Feedback._Mask = 0;
+ break;
+ case GL_3D:
+ ctx->Feedback._Mask = FB_3D;
+ break;
+ case GL_3D_COLOR:
+ ctx->Feedback._Mask = (FB_3D |
+ (ctx->Visual.rgbMode ? FB_COLOR : FB_INDEX));
+ break;
+ case GL_3D_COLOR_TEXTURE:
+ ctx->Feedback._Mask = (FB_3D |
+ (ctx->Visual.rgbMode ? FB_COLOR : FB_INDEX) |
+ FB_TEXTURE);
+ break;
+ case GL_4D_COLOR_TEXTURE:
+ ctx->Feedback._Mask = (FB_3D | FB_4D |
+ (ctx->Visual.rgbMode ? FB_COLOR : FB_INDEX) |
+ FB_TEXTURE);
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glFeedbackBuffer" );
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_RENDERMODE); /* Always flush */
+ ctx->Feedback.Type = type;
+ ctx->Feedback.BufferSize = size;
+ ctx->Feedback.Buffer = buffer;
+ ctx->Feedback.Count = 0; /* Becaues of this. */
+}
+
+
+void GLAPIENTRY
+_mesa_PassThrough( GLfloat token )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (ctx->RenderMode==GL_FEEDBACK) {
+ FLUSH_VERTICES(ctx, 0);
+ FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_PASS_THROUGH_TOKEN );
+ FEEDBACK_TOKEN( ctx, token );
+ }
+}
+
+
+
+/*
+ * Put a vertex into the feedback buffer.
+ */
+void _mesa_feedback_vertex( GLcontext *ctx,
+ const GLfloat win[4],
+ const GLfloat color[4],
+ GLfloat index,
+ const GLfloat texcoord[4] )
+{
+#if 0
+ {
+ /* snap window x, y to fractional pixel position */
+ const GLint snapMask = ~((FIXED_ONE / (1 << SUB_PIXEL_BITS)) - 1);
+ GLfixed x, y;
+ x = FloatToFixed(win[0]) & snapMask;
+ y = FloatToFixed(win[1]) & snapMask;
+ FEEDBACK_TOKEN(ctx, FixedToFloat(x));
+ FEEDBACK_TOKEN(ctx, FixedToFloat(y) );
+ }
+#else
+ FEEDBACK_TOKEN( ctx, win[0] );
+ FEEDBACK_TOKEN( ctx, win[1] );
+#endif
+ if (ctx->Feedback._Mask & FB_3D) {
+ FEEDBACK_TOKEN( ctx, win[2] );
+ }
+ if (ctx->Feedback._Mask & FB_4D) {
+ FEEDBACK_TOKEN( ctx, win[3] );
+ }
+ if (ctx->Feedback._Mask & FB_INDEX) {
+ FEEDBACK_TOKEN( ctx, (GLfloat) index );
+ }
+ if (ctx->Feedback._Mask & FB_COLOR) {
+ FEEDBACK_TOKEN( ctx, color[0] );
+ FEEDBACK_TOKEN( ctx, color[1] );
+ FEEDBACK_TOKEN( ctx, color[2] );
+ FEEDBACK_TOKEN( ctx, color[3] );
+ }
+ if (ctx->Feedback._Mask & FB_TEXTURE) {
+ FEEDBACK_TOKEN( ctx, texcoord[0] );
+ FEEDBACK_TOKEN( ctx, texcoord[1] );
+ FEEDBACK_TOKEN( ctx, texcoord[2] );
+ FEEDBACK_TOKEN( ctx, texcoord[3] );
+ }
+}
+
+#endif
+
+
+/**********************************************************************/
+/** \name Selection */
+/*@{*/
+
+/**
+ * Establish a buffer for selection mode values.
+ *
+ * \param size buffer size.
+ * \param buffer buffer.
+ *
+ * \sa glSelectBuffer().
+ *
+ * \note this function can't be put in a display list.
+ *
+ * Verifies we're not in selection mode, flushes the vertices and initialize
+ * the fields in __GLcontextRec::Select with the given buffer.
+ */
+void GLAPIENTRY
+_mesa_SelectBuffer( GLsizei size, GLuint *buffer )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (ctx->RenderMode==GL_SELECT) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glSelectBuffer" );
+ return; /* KW: added return */
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_RENDERMODE);
+ ctx->Select.Buffer = buffer;
+ ctx->Select.BufferSize = size;
+ ctx->Select.BufferCount = 0;
+ ctx->Select.HitFlag = GL_FALSE;
+ ctx->Select.HitMinZ = 1.0;
+ ctx->Select.HitMaxZ = 0.0;
+}
+
+
+/**
+ * Write a value of a record into the selection buffer.
+ *
+ * \param CTX GL context.
+ * \param V value.
+ *
+ * Verifies there is free space in the buffer to write the value and
+ * increments the pointer.
+ */
+#define WRITE_RECORD( CTX, V ) \
+ if (CTX->Select.BufferCount < CTX->Select.BufferSize) { \
+ CTX->Select.Buffer[CTX->Select.BufferCount] = (V); \
+ } \
+ CTX->Select.BufferCount++;
+
+
+/**
+ * Update the hit flag and the maximum and minimum depth values.
+ *
+ * \param ctx GL context.
+ * \param z depth.
+ *
+ * Sets gl_selection::HitFlag and updates gl_selection::HitMinZ and
+ * gl_selection::HitMaxZ.
+ */
+void _mesa_update_hitflag( GLcontext *ctx, GLfloat z )
+{
+ ctx->Select.HitFlag = GL_TRUE;
+ if (z < ctx->Select.HitMinZ) {
+ ctx->Select.HitMinZ = z;
+ }
+ if (z > ctx->Select.HitMaxZ) {
+ ctx->Select.HitMaxZ = z;
+ }
+}
+
+
+/**
+ * Write the hit record.
+ *
+ * \param ctx GL context.
+ *
+ * Write the hit record, i.e., the number of names in the stack, the minimum and
+ * maximum depth values and the number of names in the name stack at the time
+ * of the event. Resets the hit flag.
+ *
+ * \sa gl_selection.
+ */
+static void write_hit_record( GLcontext *ctx )
+{
+ GLuint i;
+ GLuint zmin, zmax, zscale = (~0u);
+
+ /* HitMinZ and HitMaxZ are in [0,1]. Multiply these values by */
+ /* 2^32-1 and round to nearest unsigned integer. */
+
+ assert( ctx != NULL ); /* this line magically fixes a SunOS 5.x/gcc bug */
+ zmin = (GLuint) ((GLfloat) zscale * ctx->Select.HitMinZ);
+ zmax = (GLuint) ((GLfloat) zscale * ctx->Select.HitMaxZ);
+
+ WRITE_RECORD( ctx, ctx->Select.NameStackDepth );
+ WRITE_RECORD( ctx, zmin );
+ WRITE_RECORD( ctx, zmax );
+ for (i = 0; i < ctx->Select.NameStackDepth; i++) {
+ WRITE_RECORD( ctx, ctx->Select.NameStack[i] );
+ }
+
+ ctx->Select.Hits++;
+ ctx->Select.HitFlag = GL_FALSE;
+ ctx->Select.HitMinZ = 1.0;
+ ctx->Select.HitMaxZ = -1.0;
+}
+
+
+/**
+ * Initialize the name stack.
+ *
+ * Verifies we are in select mode and resets the name stack depth and resets
+ * the hit record data in gl_selection. Marks new render mode in
+ * __GLcontextRec::NewState.
+ */
+void GLAPIENTRY
+_mesa_InitNames( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ /* Record the hit before the HitFlag is wiped out again. */
+ if (ctx->RenderMode == GL_SELECT) {
+ if (ctx->Select.HitFlag) {
+ write_hit_record( ctx );
+ }
+ }
+ ctx->Select.NameStackDepth = 0;
+ ctx->Select.HitFlag = GL_FALSE;
+ ctx->Select.HitMinZ = 1.0;
+ ctx->Select.HitMaxZ = 0.0;
+ ctx->NewState |= _NEW_RENDERMODE;
+}
+
+
+/**
+ * Load the top-most name of the name stack.
+ *
+ * \param name name.
+ *
+ * Verifies we are in selection mode and that the name stack is not empty.
+ * Flushes vertices. If there is a hit flag writes it (via write_hit_record()),
+ * and replace the top-most name in the stack.
+ *
+ * sa __GLcontextRec::Select.
+ */
+void GLAPIENTRY
+_mesa_LoadName( GLuint name )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (ctx->RenderMode != GL_SELECT) {
+ return;
+ }
+ if (ctx->Select.NameStackDepth == 0) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glLoadName" );
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_RENDERMODE);
+
+ if (ctx->Select.HitFlag) {
+ write_hit_record( ctx );
+ }
+ if (ctx->Select.NameStackDepth < MAX_NAME_STACK_DEPTH) {
+ ctx->Select.NameStack[ctx->Select.NameStackDepth-1] = name;
+ }
+ else {
+ ctx->Select.NameStack[MAX_NAME_STACK_DEPTH-1] = name;
+ }
+}
+
+
+/**
+ * Push a name into the name stack.
+ *
+ * \param name name.
+ *
+ * Verifies we are in selection mode and that the name stack is not full.
+ * Flushes vertices. If there is a hit flag writes it (via write_hit_record()),
+ * and adds the name to the top of the name stack.
+ *
+ * sa __GLcontextRec::Select.
+ */
+void GLAPIENTRY
+_mesa_PushName( GLuint name )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (ctx->RenderMode != GL_SELECT) {
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_RENDERMODE);
+ if (ctx->Select.HitFlag) {
+ write_hit_record( ctx );
+ }
+ if (ctx->Select.NameStackDepth >= MAX_NAME_STACK_DEPTH) {
+ _mesa_error( ctx, GL_STACK_OVERFLOW, "glPushName" );
+ }
+ else
+ ctx->Select.NameStack[ctx->Select.NameStackDepth++] = name;
+}
+
+
+/**
+ * Pop a name into the name stack.
+ *
+ * Verifies we are in selection mode and that the name stack is not empty.
+ * Flushes vertices. If there is a hit flag writes it (via write_hit_record()),
+ * and removes top-most name in the name stack.
+ *
+ * sa __GLcontextRec::Select.
+ */
+void GLAPIENTRY
+_mesa_PopName( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (ctx->RenderMode != GL_SELECT) {
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_RENDERMODE);
+ if (ctx->Select.HitFlag) {
+ write_hit_record( ctx );
+ }
+ if (ctx->Select.NameStackDepth == 0) {
+ _mesa_error( ctx, GL_STACK_UNDERFLOW, "glPopName" );
+ }
+ else
+ ctx->Select.NameStackDepth--;
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Render Mode */
+/*@{*/
+
+/**
+ * Set rasterization mode.
+ *
+ * \param mode rasterization mode.
+ *
+ * \note this function can't be put in a display list.
+ *
+ * \sa glRenderMode().
+ *
+ * Flushes the vertices and do the necessary cleanup according to the previous
+ * rasterization mode, such as writing the hit record or resent the select
+ * buffer index when exiting the select mode. Updates
+ * __GLcontextRec::RenderMode and notifies the driver via the
+ * dd_function_table::RenderMode callback.
+ */
+GLint GLAPIENTRY
+_mesa_RenderMode( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint result;
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glRenderMode %s\n", _mesa_lookup_enum_by_nr(mode));
+
+ FLUSH_VERTICES(ctx, _NEW_RENDERMODE);
+
+ switch (ctx->RenderMode) {
+ case GL_RENDER:
+ result = 0;
+ break;
+ case GL_SELECT:
+ if (ctx->Select.HitFlag) {
+ write_hit_record( ctx );
+ }
+ if (ctx->Select.BufferCount > ctx->Select.BufferSize) {
+ /* overflow */
+#ifdef DEBUG
+ _mesa_warning(ctx, "Feedback buffer overflow");
+#endif
+ result = -1;
+ }
+ else {
+ result = ctx->Select.Hits;
+ }
+ ctx->Select.BufferCount = 0;
+ ctx->Select.Hits = 0;
+ ctx->Select.NameStackDepth = 0;
+ break;
+#if _HAVE_FULL_GL
+ case GL_FEEDBACK:
+ if (ctx->Feedback.Count > ctx->Feedback.BufferSize) {
+ /* overflow */
+ result = -1;
+ }
+ else {
+ result = ctx->Feedback.Count;
+ }
+ ctx->Feedback.Count = 0;
+ break;
+#endif
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glRenderMode" );
+ return 0;
+ }
+
+ switch (mode) {
+ case GL_RENDER:
+ break;
+ case GL_SELECT:
+ if (ctx->Select.BufferSize==0) {
+ /* haven't called glSelectBuffer yet */
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glRenderMode" );
+ }
+ break;
+#if _HAVE_FULL_GL
+ case GL_FEEDBACK:
+ if (ctx->Feedback.BufferSize==0) {
+ /* haven't called glFeedbackBuffer yet */
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glRenderMode" );
+ }
+ break;
+#endif
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glRenderMode" );
+ return 0;
+ }
+
+ ctx->RenderMode = mode;
+ if (ctx->Driver.RenderMode)
+ ctx->Driver.RenderMode( ctx, mode );
+
+ return result;
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Initialization */
+/*@{*/
+
+/**
+ * Initialize context feedback data.
+ */
+void _mesa_init_feedback( GLcontext * ctx )
+{
+ /* Feedback */
+ ctx->Feedback.Type = GL_2D; /* TODO: verify */
+ ctx->Feedback.Buffer = NULL;
+ ctx->Feedback.BufferSize = 0;
+ ctx->Feedback.Count = 0;
+
+ /* Selection/picking */
+ ctx->Select.Buffer = NULL;
+ ctx->Select.BufferSize = 0;
+ ctx->Select.BufferCount = 0;
+ ctx->Select.Hits = 0;
+ ctx->Select.NameStackDepth = 0;
+
+ /* Miscellaneous */
+ ctx->RenderMode = GL_RENDER;
+}
+
+/*@}*/
diff --git a/nx-X11/extras/Mesa/src/mesa/main/feedback.h b/nx-X11/extras/Mesa/src/mesa/main/feedback.h
new file mode 100644
index 000000000..6c448ad63
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/feedback.h
@@ -0,0 +1,82 @@
+/**
+ * \file feedback.h
+ * Selection and feedback modes functions.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef FEEDBACK_H
+#define FEEDBACK_H
+
+
+#include "mtypes.h"
+
+
+#define FEEDBACK_TOKEN( CTX, T ) \
+ if (CTX->Feedback.Count < CTX->Feedback.BufferSize) { \
+ CTX->Feedback.Buffer[CTX->Feedback.Count] = (GLfloat) (T); \
+ } \
+ CTX->Feedback.Count++;
+
+
+extern void _mesa_init_feedback( GLcontext * ctx );
+
+extern void _mesa_feedback_vertex( GLcontext *ctx,
+ const GLfloat win[4],
+ const GLfloat color[4],
+ GLfloat index,
+ const GLfloat texcoord[4] );
+
+
+extern void _mesa_update_hitflag( GLcontext *ctx, GLfloat z );
+
+
+extern void GLAPIENTRY
+_mesa_PassThrough( GLfloat token );
+
+extern void GLAPIENTRY
+_mesa_FeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer );
+
+extern void GLAPIENTRY
+_mesa_SelectBuffer( GLsizei size, GLuint *buffer );
+
+extern void GLAPIENTRY
+_mesa_InitNames( void );
+
+extern void GLAPIENTRY
+_mesa_LoadName( GLuint name );
+
+extern void GLAPIENTRY
+_mesa_PushName( GLuint name );
+
+extern void GLAPIENTRY
+_mesa_PopName( void );
+
+extern GLint GLAPIENTRY
+_mesa_RenderMode( GLenum mode );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/fog.c b/nx-X11/extras/Mesa/src/mesa/main/fog.c
new file mode 100644
index 000000000..d3b8a923a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/fog.c
@@ -0,0 +1,177 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "fog.h"
+#include "mtypes.h"
+
+
+
+void GLAPIENTRY
+_mesa_Fogf(GLenum pname, GLfloat param)
+{
+ _mesa_Fogfv(pname, &param);
+}
+
+
+void GLAPIENTRY
+_mesa_Fogi(GLenum pname, GLint param )
+{
+ GLfloat fparam = (GLfloat) param;
+ _mesa_Fogfv(pname, &fparam);
+}
+
+
+void GLAPIENTRY
+_mesa_Fogiv(GLenum pname, const GLint *params )
+{
+ GLfloat p[4];
+ switch (pname) {
+ case GL_FOG_MODE:
+ case GL_FOG_DENSITY:
+ case GL_FOG_START:
+ case GL_FOG_END:
+ case GL_FOG_INDEX:
+ case GL_FOG_COORDINATE_SOURCE_EXT:
+ p[0] = (GLfloat) *params;
+ break;
+ case GL_FOG_COLOR:
+ p[0] = INT_TO_FLOAT( params[0] );
+ p[1] = INT_TO_FLOAT( params[1] );
+ p[2] = INT_TO_FLOAT( params[2] );
+ p[3] = INT_TO_FLOAT( params[3] );
+ break;
+ default:
+ /* Error will be caught later in _mesa_Fogfv */
+ ;
+ }
+ _mesa_Fogfv(pname, p);
+}
+
+
+void GLAPIENTRY
+_mesa_Fogfv( GLenum pname, const GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLenum m;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ switch (pname) {
+ case GL_FOG_MODE:
+ m = (GLenum) (GLint) *params;
+ switch (m) {
+ case GL_LINEAR:
+ case GL_EXP:
+ case GL_EXP2:
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glFog" );
+ return;
+ }
+ if (ctx->Fog.Mode == m)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_FOG);
+ ctx->Fog.Mode = m;
+ break;
+ case GL_FOG_DENSITY:
+ if (*params<0.0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glFog" );
+ return;
+ }
+ if (ctx->Fog.Density == *params)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_FOG);
+ ctx->Fog.Density = *params;
+ break;
+ case GL_FOG_START:
+ if (ctx->Fog.Start == *params)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_FOG);
+ ctx->Fog.Start = *params;
+ break;
+ case GL_FOG_END:
+ if (ctx->Fog.End == *params)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_FOG);
+ ctx->Fog.End = *params;
+ break;
+ case GL_FOG_INDEX:
+ if (ctx->Fog.Index == *params)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_FOG);
+ ctx->Fog.Index = *params;
+ break;
+ case GL_FOG_COLOR:
+ if (TEST_EQ_4V(ctx->Fog.Color, params))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_FOG);
+ ctx->Fog.Color[0] = CLAMP(params[0], 0.0F, 1.0F);
+ ctx->Fog.Color[1] = CLAMP(params[1], 0.0F, 1.0F);
+ ctx->Fog.Color[2] = CLAMP(params[2], 0.0F, 1.0F);
+ ctx->Fog.Color[3] = CLAMP(params[3], 0.0F, 1.0F);
+ break;
+ case GL_FOG_COORDINATE_SOURCE_EXT: {
+ GLenum p = (GLenum) (GLint) *params;
+ if (!ctx->Extensions.EXT_fog_coord ||
+ (p != GL_FOG_COORDINATE_EXT && p != GL_FRAGMENT_DEPTH_EXT)) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glFog");
+ return;
+ }
+ if (ctx->Fog.FogCoordinateSource == p)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_FOG);
+ ctx->Fog.FogCoordinateSource = p;
+ break;
+ }
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glFog" );
+ return;
+ }
+
+ if (ctx->Driver.Fogfv) {
+ (*ctx->Driver.Fogfv)( ctx, pname, params );
+ }
+}
+
+
+/**********************************************************************/
+/***** Initialization *****/
+/**********************************************************************/
+
+void _mesa_init_fog( GLcontext * ctx )
+{
+ /* Fog group */
+ ctx->Fog.Enabled = GL_FALSE;
+ ctx->Fog.Mode = GL_EXP;
+ ASSIGN_4V( ctx->Fog.Color, 0.0, 0.0, 0.0, 0.0 );
+ ctx->Fog.Index = 0.0;
+ ctx->Fog.Density = 1.0;
+ ctx->Fog.Start = 0.0;
+ ctx->Fog.End = 1.0;
+ ctx->Fog.ColorSumEnabled = GL_FALSE;
+ ctx->Fog.FogCoordinateSource = GL_FRAGMENT_DEPTH_EXT;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/fog.h b/nx-X11/extras/Mesa/src/mesa/main/fog.h
new file mode 100644
index 000000000..a14d19cdb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/fog.h
@@ -0,0 +1,66 @@
+/**
+ * \file fog.h
+ * Fog operations.
+ *
+ * \if subset
+ * (No-op)
+ *
+ * \endif
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef FOG_H
+#define FOG_H
+
+
+#include "mtypes.h"
+
+
+#if _HAVE_FULL_GL
+
+extern void GLAPIENTRY
+_mesa_Fogf(GLenum pname, GLfloat param);
+
+extern void GLAPIENTRY
+_mesa_Fogi(GLenum pname, GLint param );
+
+extern void GLAPIENTRY
+_mesa_Fogfv(GLenum pname, const GLfloat *params );
+
+extern void GLAPIENTRY
+_mesa_Fogiv(GLenum pname, const GLint *params );
+
+extern void _mesa_init_fog( GLcontext * ctx );
+
+#else
+
+/** No-op */
+#define _mesa_init_fog( c ) ((void)0)
+
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/framebuffer.c b/nx-X11/extras/Mesa/src/mesa/main/framebuffer.c
new file mode 100644
index 000000000..de44d1a85
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/framebuffer.c
@@ -0,0 +1,528 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * Functions for allocating/managing framebuffers and renderbuffers.
+ * Also, routines for reading/writing renderbuffer data as ubytes,
+ * ushorts, uints, etc.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "mtypes.h"
+#include "fbobject.h"
+#include "framebuffer.h"
+#include "renderbuffer.h"
+
+
+
+/**
+ * Compute/set the _DepthMax field for the given framebuffer.
+ * This value depends on the Z buffer resolution.
+ */
+static void
+compute_depth_max(struct gl_framebuffer *fb)
+{
+ if (fb->Visual.depthBits == 0) {
+ /* Special case. Even if we don't have a depth buffer we need
+ * good values for DepthMax for Z vertex transformation purposes
+ * and for per-fragment fog computation.
+ */
+ fb->_DepthMax = (1 << 16) - 1;
+ }
+ else if (fb->Visual.depthBits < 32) {
+ fb->_DepthMax = (1 << fb->Visual.depthBits) - 1;
+ }
+ else {
+ /* Special case since shift values greater than or equal to the
+ * number of bits in the left hand expression's type are undefined.
+ */
+ fb->_DepthMax = 0xffffffff;
+ }
+ fb->_DepthMaxF = (GLfloat) fb->_DepthMax;
+ fb->_MRD = 1.0; /* Minimum resolvable depth value, for polygon offset */
+}
+
+
+/**
+ * Create and initialize a gl_framebuffer object.
+ * This is intended for creating _window_system_ framebuffers, not generic
+ * framebuffer objects ala GL_EXT_framebuffer_object.
+ *
+ * \sa _mesa_new_framebuffer
+ */
+struct gl_framebuffer *
+_mesa_create_framebuffer(const GLvisual *visual)
+{
+ struct gl_framebuffer *fb = CALLOC_STRUCT(gl_framebuffer);
+ assert(visual);
+ if (fb) {
+ _mesa_initialize_framebuffer(fb, visual);
+ }
+ return fb;
+}
+
+
+/**
+ * Allocate a new gl_framebuffer object.
+ * This is the default function for ctx->Driver.NewFramebuffer().
+ * This is for allocating user-created framebuffers, not window-system
+ * framebuffers!
+ * \sa _mesa_create_framebuffer
+ */
+struct gl_framebuffer *
+_mesa_new_framebuffer(GLcontext *ctx, GLuint name)
+{
+ struct gl_framebuffer *fb;
+ assert(name != 0);
+ fb = CALLOC_STRUCT(gl_framebuffer);
+ if (fb) {
+ fb->Name = name;
+ fb->RefCount = 1;
+ fb->Delete = _mesa_destroy_framebuffer;
+ fb->ColorDrawBuffer[0] = GL_COLOR_ATTACHMENT0_EXT;
+ fb->_ColorDrawBufferMask[0] = BUFFER_BIT_COLOR0;
+ fb->ColorReadBuffer = GL_COLOR_ATTACHMENT0_EXT;
+ fb->_ColorReadBufferMask = BUFFER_BIT_COLOR0;
+ fb->Delete = _mesa_destroy_framebuffer;
+ }
+ return fb;
+}
+
+
+/**
+ * Initialize a gl_framebuffer object.
+ * \sa _mesa_create_framebuffer
+ */
+void
+_mesa_initialize_framebuffer(struct gl_framebuffer *fb, const GLvisual *visual)
+{
+ assert(fb);
+ assert(visual);
+
+ _mesa_bzero(fb, sizeof(struct gl_framebuffer));
+
+ /* save the visual */
+ fb->Visual = *visual;
+
+ /* Init glRead/DrawBuffer state */
+ if (visual->doubleBufferMode) {
+ fb->ColorDrawBuffer[0] = GL_BACK;
+ fb->_ColorDrawBufferMask[0] = BUFFER_BIT_BACK_LEFT;
+ fb->ColorReadBuffer = GL_BACK;
+ fb->_ColorReadBufferMask = BUFFER_BIT_BACK_LEFT;
+ }
+ else {
+ fb->ColorDrawBuffer[0] = GL_FRONT;
+ fb->_ColorDrawBufferMask[0] = BUFFER_BIT_FRONT_LEFT;
+ fb->ColorReadBuffer = GL_FRONT;
+ fb->_ColorReadBufferMask = BUFFER_BIT_FRONT_LEFT;
+ }
+
+ fb->Delete = _mesa_destroy_framebuffer;
+ fb->_Status = GL_FRAMEBUFFER_COMPLETE_EXT;
+
+ compute_depth_max(fb);
+}
+
+
+/**
+ * Create/attach software-based renderbuffers to the given framebuffer.
+ * This is a helper routine for device drivers. Drivers can just as well
+ * call the individual _mesa_add_*_renderbuffer() routines directly.
+ */
+void
+_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb,
+ GLboolean color,
+ GLboolean depth,
+ GLboolean stencil,
+ GLboolean accum,
+ GLboolean alpha,
+ GLboolean aux)
+{
+ GLboolean frontLeft = GL_TRUE;
+ GLboolean backLeft = fb->Visual.doubleBufferMode;
+ GLboolean frontRight = fb->Visual.stereoMode;
+ GLboolean backRight = fb->Visual.stereoMode && fb->Visual.doubleBufferMode;
+
+ if (color) {
+ if (fb->Visual.rgbMode) {
+ assert(fb->Visual.redBits == fb->Visual.greenBits);
+ assert(fb->Visual.redBits == fb->Visual.blueBits);
+ _mesa_add_color_renderbuffers(NULL, fb,
+ fb->Visual.redBits,
+ fb->Visual.alphaBits,
+ frontLeft, backLeft,
+ frontRight, backRight);
+ }
+ else {
+ _mesa_add_color_index_renderbuffers(NULL, fb,
+ fb->Visual.indexBits,
+ frontLeft, backLeft,
+ frontRight, backRight);
+ }
+ }
+
+ if (depth) {
+ assert(fb->Visual.depthBits > 0);
+ _mesa_add_depth_renderbuffer(NULL, fb, fb->Visual.depthBits);
+ }
+
+ if (stencil) {
+ assert(fb->Visual.stencilBits > 0);
+ _mesa_add_stencil_renderbuffer(NULL, fb, fb->Visual.stencilBits);
+ }
+
+ if (accum) {
+ assert(fb->Visual.rgbMode);
+ assert(fb->Visual.accumRedBits > 0);
+ assert(fb->Visual.accumGreenBits > 0);
+ assert(fb->Visual.accumBlueBits > 0);
+ _mesa_add_accum_renderbuffer(NULL, fb,
+ fb->Visual.accumRedBits,
+ fb->Visual.accumGreenBits,
+ fb->Visual.accumBlueBits,
+ fb->Visual.accumAlphaBits);
+ }
+
+ if (aux) {
+ assert(fb->Visual.rgbMode);
+ assert(fb->Visual.numAuxBuffers > 0);
+ _mesa_add_aux_renderbuffers(NULL, fb, fb->Visual.redBits,
+ fb->Visual.numAuxBuffers);
+ }
+
+#if 1
+ if (alpha) {
+ assert(fb->Visual.rgbMode);
+ assert(fb->Visual.alphaBits > 0);
+ _mesa_add_alpha_renderbuffers(NULL, fb, fb->Visual.alphaBits,
+ frontLeft, backLeft,
+ frontRight, backRight);
+ }
+#endif
+
+#if 0
+ if (multisample) {
+ /* maybe someday */
+ }
+#endif
+}
+
+
+/**
+ * Deallocate buffer and everything attached to it.
+ */
+void
+_mesa_destroy_framebuffer(struct gl_framebuffer *buffer)
+{
+ if (buffer) {
+ _mesa_free_framebuffer_data(buffer);
+ FREE(buffer);
+ }
+}
+
+
+/**
+ * Free all the data hanging off the given gl_framebuffer, but don't free
+ * the gl_framebuffer object itself.
+ */
+void
+_mesa_free_framebuffer_data(struct gl_framebuffer *fb)
+{
+ GLuint i;
+
+ assert(fb);
+
+ for (i = 0; i < BUFFER_COUNT; i++) {
+ struct gl_renderbuffer_attachment *att = &fb->Attachment[i];
+ if (att->Type == GL_RENDERBUFFER_EXT && att->Renderbuffer) {
+ struct gl_renderbuffer *rb = att->Renderbuffer;
+ rb->RefCount--;
+ if (rb->RefCount == 0) {
+ rb->Delete(rb);
+ }
+ }
+ att->Type = GL_NONE;
+ att->Renderbuffer = NULL;
+ }
+}
+
+
+/**
+ * Resize the given framebuffer's renderbuffers to the new width and height.
+ * This should only be used for window-system framebuffers, not
+ * user-created renderbuffers (i.e. made with GL_EXT_framebuffer_object).
+ * This will typically be called via ctx->Driver.ResizeBuffers()
+ */
+void
+_mesa_resize_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint width, GLuint height)
+{
+ GLuint i;
+
+ /* For window system framebuffers, Name is zero */
+ assert(fb->Name == 0);
+
+ for (i = 0; i < BUFFER_COUNT; i++) {
+ struct gl_renderbuffer_attachment *att = &fb->Attachment[i];
+ if (att->Type == GL_RENDERBUFFER_EXT && att->Renderbuffer) {
+ struct gl_renderbuffer *rb = att->Renderbuffer;
+ /* only resize if size is changing */
+ if (rb->Width != width || rb->Height != height) {
+ if (rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height)) {
+ rb->Width = width;
+ rb->Height = height;
+ }
+ else {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Resizing framebuffer");
+ }
+ }
+ }
+ }
+
+ fb->Width = width;
+ fb->Height = height;
+
+ /* to update scissor / window bounds */
+ if (ctx)
+ ctx->NewState |= _NEW_BUFFERS;
+}
+
+
+/**
+ * Examine all the framebuffer's renderbuffers to update the Width/Height
+ * fields of the framebuffer. If we have renderbuffers with different
+ * sizes, set the framebuffer's width and height to zero.
+ * Note: this is only intended for user-created framebuffers, not
+ * window-system framebuffes.
+ */
+static void
+update_framebuffer_size(struct gl_framebuffer *fb)
+{
+ GLboolean haveSize = GL_FALSE;
+ GLuint i;
+
+ /* user-created framebuffers only */
+ assert(fb->Name);
+
+ for (i = 0; i < BUFFER_COUNT; i++) {
+ struct gl_renderbuffer_attachment *att = &fb->Attachment[i];
+ const struct gl_renderbuffer *rb = att->Renderbuffer;
+ if (rb) {
+ if (haveSize) {
+ if (rb->Width != fb->Width && rb->Height != fb->Height) {
+ /* size mismatch! */
+ fb->Width = 0;
+ fb->Height = 0;
+ return;
+ }
+ }
+ else {
+ fb->Width = rb->Width;
+ fb->Height = rb->Height;
+ haveSize = GL_TRUE;
+ }
+ }
+ }
+}
+
+
+/**
+ * Update the context's current drawing buffer's Xmin, Xmax, Ymin, Ymax fields.
+ * These values are computed from the buffer's width and height and
+ * the scissor box, if it's enabled.
+ * \param ctx the GL context.
+ */
+void
+_mesa_update_draw_buffer_bounds(GLcontext *ctx)
+{
+ struct gl_framebuffer *buffer = ctx->DrawBuffer;
+
+ if (buffer->Name) {
+ /* user-created framebuffer size depends on the renderbuffers */
+ update_framebuffer_size(buffer);
+ }
+
+ buffer->_Xmin = 0;
+ buffer->_Ymin = 0;
+ buffer->_Xmax = buffer->Width;
+ buffer->_Ymax = buffer->Height;
+
+ if (ctx->Scissor.Enabled) {
+ if (ctx->Scissor.X > buffer->_Xmin) {
+ buffer->_Xmin = ctx->Scissor.X;
+ }
+ if (ctx->Scissor.Y > buffer->_Ymin) {
+ buffer->_Ymin = ctx->Scissor.Y;
+ }
+ if (ctx->Scissor.X + ctx->Scissor.Width < buffer->_Xmax) {
+ buffer->_Xmax = ctx->Scissor.X + ctx->Scissor.Width;
+ }
+ if (ctx->Scissor.Y + ctx->Scissor.Height < buffer->_Ymax) {
+ buffer->_Ymax = ctx->Scissor.Y + ctx->Scissor.Height;
+ }
+ /* finally, check for empty region */
+ if (buffer->_Xmin > buffer->_Xmax) {
+ buffer->_Xmin = buffer->_Xmax;
+ }
+ if (buffer->_Ymin > buffer->_Ymax) {
+ buffer->_Ymin = buffer->_Ymax;
+ }
+ }
+
+ ASSERT(buffer->_Xmin <= buffer->_Xmax);
+ ASSERT(buffer->_Ymin <= buffer->_Ymax);
+}
+
+
+/**
+ * The glGet queries of the framebuffer red/green/blue size, stencil size,
+ * etc. are satisfied by the fields of ctx->DrawBuffer->Visual. These can
+ * change depending on the renderbuffer bindings. This function update's
+ * the given framebuffer's Visual from the current renderbuffer bindings.
+ * This is only intended for user-created framebuffers.
+ */
+void
+_mesa_update_framebuffer_visual(struct gl_framebuffer *fb)
+{
+ GLuint i;
+
+ assert(fb->Name != 0);
+
+ _mesa_bzero(&fb->Visual, sizeof(fb->Visual));
+ fb->Visual.rgbMode = GL_TRUE;
+
+ /* find first RGB or CI renderbuffer */
+ for (i = 0; i < BUFFER_COUNT; i++) {
+ if (fb->Attachment[i].Renderbuffer) {
+ const struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer;
+ if (rb->_BaseFormat == GL_RGBA || rb->_BaseFormat == GL_RGB) {
+ fb->Visual.redBits = rb->ComponentSizes[0];
+ fb->Visual.greenBits = rb->ComponentSizes[1];
+ fb->Visual.blueBits = rb->ComponentSizes[2];
+ fb->Visual.alphaBits = rb->ComponentSizes[3];
+ fb->Visual.floatMode = GL_FALSE;
+ break;
+ }
+ else if (rb->_BaseFormat == GL_COLOR_INDEX) {
+ fb->Visual.indexBits = rb->ComponentSizes[0];
+ fb->Visual.rgbMode = GL_FALSE;
+ break;
+ }
+ }
+ }
+
+ if (fb->Attachment[BUFFER_DEPTH].Renderbuffer) {
+ fb->Visual.haveDepthBuffer = GL_TRUE;
+ fb->Visual.depthBits
+ = fb->Attachment[BUFFER_DEPTH].Renderbuffer->ComponentSizes[0];
+ }
+
+ if (fb->Attachment[BUFFER_STENCIL].Renderbuffer) {
+ fb->Visual.haveStencilBuffer = GL_TRUE;
+ fb->Visual.stencilBits
+ = fb->Attachment[BUFFER_STENCIL].Renderbuffer->ComponentSizes[0];
+ }
+
+ compute_depth_max(fb);
+}
+
+
+/**
+ * Given a framebuffer and a buffer bit (like BUFFER_BIT_FRONT_LEFT), return
+ * the corresponding renderbuffer.
+ */
+static struct gl_renderbuffer *
+get_renderbuffer(struct gl_framebuffer *fb, GLuint bufferBit)
+{
+ GLuint index;
+ for (index = 0; index < BUFFER_COUNT; index++) {
+ if ((1 << index) == bufferBit) {
+ return fb->Attachment[index].Renderbuffer;
+ }
+ }
+ _mesa_problem(NULL, "Bad bufferBit in get_renderbuffer");
+ return NULL;
+}
+
+
+/**
+ * Update state related to the current draw/read framebuffers.
+ * If the current framebuffer is user-created, make sure it's complete.
+ */
+void
+_mesa_update_framebuffer(GLcontext *ctx)
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ GLuint output;
+
+ /* Completeness only matters for user-created framebuffers */
+ if (fb->Name != 0) {
+ _mesa_test_framebuffer_completeness(ctx, fb);
+ _mesa_update_framebuffer_visual(fb);
+ }
+
+ /*
+ * Update the list of drawing renderbuffer pointers.
+ * Later, when we're rendering we'll loop from 0 to _NumColorDrawBuffers
+ * writing colors. We have a loop because glDrawBuffer(GL_FRONT_AND_BACK)
+ * can specify writing to two or four color buffers.
+ */
+ for (output = 0; output < ctx->Const.MaxDrawBuffers; output++) {
+ GLuint bufferMask = fb->_ColorDrawBufferMask[output];
+ GLuint count = 0;
+ GLuint bufferBit;
+ /* for each bit that's set in the bufferMask... */
+ for (bufferBit = 1; bufferMask; bufferBit <<= 1) {
+ if (bufferBit & bufferMask) {
+ struct gl_renderbuffer *rb = get_renderbuffer(fb, bufferBit);
+ if (rb) {
+ fb->_ColorDrawBuffers[output][count] = rb;
+ fb->_ColorDrawBit[output][count] = bufferBit;
+ count++;
+ }
+ else {
+ /*_mesa_warning(ctx, "DrawBuffer names a missing buffer!");*/
+ }
+ bufferMask &= ~bufferBit;
+ }
+ }
+ fb->_NumColorDrawBuffers[output] = count;
+ }
+
+ /*
+ * Update the read renderbuffer pointer.
+ * Unlike the DrawBuffer, we can only read from one (or zero) color buffers.
+ */
+ if (fb->_ColorReadBufferMask == 0x0)
+ fb->_ColorReadBuffer = NULL; /* legal! */
+ else
+ fb->_ColorReadBuffer = get_renderbuffer(fb, fb->_ColorReadBufferMask);
+
+ compute_depth_max(fb);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/framebuffer.h b/nx-X11/extras/Mesa/src/mesa/main/framebuffer.h
new file mode 100644
index 000000000..11b002877
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/framebuffer.h
@@ -0,0 +1,67 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef FRAMEBUFFER_H
+#define FRAMEBUFFER_H
+
+
+extern struct gl_framebuffer *
+_mesa_create_framebuffer(const GLvisual *visual);
+
+extern struct gl_framebuffer *
+_mesa_new_framebuffer(GLcontext *ctx, GLuint name);
+
+extern void
+_mesa_initialize_framebuffer(struct gl_framebuffer *fb, const GLvisual *visual);
+
+extern void
+_mesa_add_soft_renderbuffers(struct gl_framebuffer *fb,
+ GLboolean color,
+ GLboolean depth,
+ GLboolean stencil,
+ GLboolean accum,
+ GLboolean alpha,
+ GLboolean aux);
+
+extern void
+_mesa_destroy_framebuffer(struct gl_framebuffer *buffer);
+
+extern void
+_mesa_free_framebuffer_data(struct gl_framebuffer *buffer);
+
+extern void
+_mesa_resize_framebuffer(GLcontext *ctx, struct gl_framebuffer *b,
+ GLuint width, GLuint height);
+
+extern void
+_mesa_update_draw_buffer_bounds(GLcontext *ctx);
+
+extern void
+_mesa_update_framebuffer_visual(struct gl_framebuffer *fb);
+
+extern void
+_mesa_update_framebuffer(GLcontext *ctx);
+
+#endif /* FRAMEBUFFER_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/main/get.c b/nx-X11/extras/Mesa/src/mesa/main/get.c
new file mode 100644
index 000000000..f5b981967
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/get.c
@@ -0,0 +1,5646 @@
+
+/***
+ *** NOTE!!! DO NOT EDIT THIS FILE!!! IT IS GENERATED BY get_gen.py
+ ***/
+
+#include "glheader.h"
+#include "context.h"
+#include "enable.h"
+#include "extensions.h"
+#include "fbobject.h"
+#include "get.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "state.h"
+#include "texcompress.h"
+
+
+#define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE )
+
+#define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
+
+#define ENUM_TO_BOOLEAN(E) ( (E) ? GL_TRUE : GL_FALSE )
+#define ENUM_TO_INT(E) ( (GLint) (E) )
+#define ENUM_TO_FLOAT(E) ( (GLfloat) (E) )
+
+#define BOOLEAN_TO_INT(B) ( (GLint) (B) )
+#define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F )
+
+
+/* Check if named extension is enabled, if not generate error and return */
+
+#define CHECK1(E1, str, PNAME) \
+ if (!ctx->Extensions.E1) { \
+ _mesa_error(ctx, GL_INVALID_VALUE, \
+ "glGet" str "v(0x%x)", (int) PNAME); \
+ return; \
+ }
+
+#define CHECK2(E1, E2, str, PNAME) \
+ if (!ctx->Extensions.E1 && !ctx->Extensions.E2) { \
+ _mesa_error(ctx, GL_INVALID_VALUE, \
+ "glGet" str "v(0x%x)", (int) PNAME); \
+ return; \
+ }
+
+#define CHECK_EXTENSION_B(EXTNAME, PNAME) \
+ CHECK1(EXTNAME, "Boolean", PNAME )
+
+#define CHECK_EXTENSION_I(EXTNAME, PNAME) \
+ CHECK1(EXTNAME, "Integer", PNAME )
+
+#define CHECK_EXTENSION_F(EXTNAME, PNAME) \
+ CHECK1(EXTNAME, "Float", PNAME )
+
+
+/**
+ * Helper routine.
+ */
+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 GLAPIENTRY
+_mesa_GetBooleanv( GLenum pname, GLboolean *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!params)
+ return;
+
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ if (ctx->Driver.GetBooleanv &&
+ ctx->Driver.GetBooleanv(ctx, pname, params))
+ return;
+
+ switch (pname) {
+ case GL_ACCUM_RED_BITS:
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.accumRedBits);
+ break;
+ case GL_ACCUM_GREEN_BITS:
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.accumGreenBits);
+ break;
+ case GL_ACCUM_BLUE_BITS:
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.accumBlueBits);
+ break;
+ case GL_ACCUM_ALPHA_BITS:
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.accumAlphaBits);
+ break;
+ case GL_ACCUM_CLEAR_VALUE:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Accum.ClearColor[0]);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Accum.ClearColor[1]);
+ params[2] = FLOAT_TO_BOOLEAN(ctx->Accum.ClearColor[2]);
+ params[3] = FLOAT_TO_BOOLEAN(ctx->Accum.ClearColor[3]);
+ break;
+ case GL_ALPHA_BIAS:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.AlphaBias);
+ break;
+ case GL_ALPHA_BITS:
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.alphaBits);
+ break;
+ case GL_ALPHA_SCALE:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.AlphaScale);
+ break;
+ case GL_ALPHA_TEST:
+ params[0] = ctx->Color.AlphaEnabled;
+ break;
+ case GL_ALPHA_TEST_FUNC:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Color.AlphaFunc);
+ break;
+ case GL_ALPHA_TEST_REF:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Color.AlphaRef);
+ break;
+ case GL_ATTRIB_STACK_DEPTH:
+ params[0] = INT_TO_BOOLEAN(ctx->AttribStackDepth);
+ break;
+ case GL_AUTO_NORMAL:
+ params[0] = ctx->Eval.AutoNormal;
+ break;
+ case GL_AUX_BUFFERS:
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.numAuxBuffers);
+ break;
+ case GL_BLEND:
+ params[0] = ctx->Color.BlendEnabled;
+ break;
+ case GL_BLEND_DST:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendDstRGB);
+ break;
+ case GL_BLEND_SRC:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendSrcRGB);
+ break;
+ case GL_BLEND_SRC_RGB_EXT:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendSrcRGB);
+ break;
+ case GL_BLEND_DST_RGB_EXT:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendDstRGB);
+ break;
+ case GL_BLEND_SRC_ALPHA_EXT:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendSrcA);
+ break;
+ case GL_BLEND_DST_ALPHA_EXT:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendDstA);
+ break;
+ case GL_BLEND_EQUATION:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendEquationRGB );
+ break;
+ case GL_BLEND_EQUATION_ALPHA_EXT:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Color.BlendEquationA );
+ break;
+ case GL_BLEND_COLOR_EXT:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Color.BlendColor[0]);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Color.BlendColor[1]);
+ params[2] = FLOAT_TO_BOOLEAN(ctx->Color.BlendColor[2]);
+ params[3] = FLOAT_TO_BOOLEAN(ctx->Color.BlendColor[3]);
+ break;
+ case GL_BLUE_BIAS:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.BlueBias);
+ break;
+ case GL_BLUE_BITS:
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.blueBits);
+ break;
+ case GL_BLUE_SCALE:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.BlueScale);
+ break;
+ case GL_CLIENT_ATTRIB_STACK_DEPTH:
+ params[0] = INT_TO_BOOLEAN(ctx->ClientAttribStackDepth);
+ break;
+ case GL_CLIP_PLANE0:
+ params[0] = (ctx->Transform.ClipPlanesEnabled >> 0) & 1;
+ break;
+ case GL_CLIP_PLANE1:
+ params[0] = (ctx->Transform.ClipPlanesEnabled >> 1) & 1;
+ break;
+ case GL_CLIP_PLANE2:
+ params[0] = (ctx->Transform.ClipPlanesEnabled >> 2) & 1;
+ break;
+ case GL_CLIP_PLANE3:
+ params[0] = (ctx->Transform.ClipPlanesEnabled >> 3) & 1;
+ break;
+ case GL_CLIP_PLANE4:
+ params[0] = (ctx->Transform.ClipPlanesEnabled >> 4) & 1;
+ break;
+ case GL_CLIP_PLANE5:
+ params[0] = (ctx->Transform.ClipPlanesEnabled >> 5) & 1;
+ break;
+ case GL_COLOR_CLEAR_VALUE:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Color.ClearColor[0]);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Color.ClearColor[1]);
+ params[2] = FLOAT_TO_BOOLEAN(ctx->Color.ClearColor[2]);
+ params[3] = FLOAT_TO_BOOLEAN(ctx->Color.ClearColor[3]);
+ break;
+ case GL_COLOR_MATERIAL:
+ params[0] = ctx->Light.ColorMaterialEnabled;
+ break;
+ case GL_COLOR_MATERIAL_FACE:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Light.ColorMaterialFace);
+ break;
+ case GL_COLOR_MATERIAL_PARAMETER:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Light.ColorMaterialMode);
+ break;
+ case GL_COLOR_WRITEMASK:
+ params[0] = INT_TO_BOOLEAN(ctx->Color.ColorMask[RCOMP] ? 1 : 0);
+ params[1] = INT_TO_BOOLEAN(ctx->Color.ColorMask[GCOMP] ? 1 : 0);
+ params[2] = INT_TO_BOOLEAN(ctx->Color.ColorMask[BCOMP] ? 1 : 0);
+ params[3] = INT_TO_BOOLEAN(ctx->Color.ColorMask[ACOMP] ? 1 : 0);
+ break;
+ case GL_CULL_FACE:
+ params[0] = ctx->Polygon.CullFlag;
+ break;
+ case GL_CULL_FACE_MODE:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Polygon.CullFaceMode);
+ break;
+ case GL_CURRENT_COLOR:
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]);
+ params[2] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]);
+ params[3] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]);
+ }
+ break;
+ case GL_CURRENT_INDEX:
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Index);
+ }
+ break;
+ case GL_CURRENT_NORMAL:
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]);
+ params[2] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]);
+ }
+ break;
+ case GL_CURRENT_RASTER_COLOR:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Current.RasterColor[0]);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Current.RasterColor[1]);
+ params[2] = FLOAT_TO_BOOLEAN(ctx->Current.RasterColor[2]);
+ params[3] = FLOAT_TO_BOOLEAN(ctx->Current.RasterColor[3]);
+ break;
+ case GL_CURRENT_RASTER_DISTANCE:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Current.RasterDistance);
+ break;
+ case GL_CURRENT_RASTER_INDEX:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Current.RasterIndex);
+ break;
+ case GL_CURRENT_RASTER_POSITION:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Current.RasterPos[0]);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Current.RasterPos[1]);
+ params[2] = FLOAT_TO_BOOLEAN(ctx->Current.RasterPos[2]);
+ params[3] = FLOAT_TO_BOOLEAN(ctx->Current.RasterPos[3]);
+ break;
+ case GL_CURRENT_RASTER_TEXTURE_COORDS:
+ {
+ const GLuint texUnit = ctx->Texture.CurrentUnit;
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Current.RasterTexCoords[texUnit][0]);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Current.RasterTexCoords[texUnit][1]);
+ params[2] = FLOAT_TO_BOOLEAN(ctx->Current.RasterTexCoords[texUnit][2]);
+ params[3] = FLOAT_TO_BOOLEAN(ctx->Current.RasterTexCoords[texUnit][3]);
+ }
+ break;
+ case GL_CURRENT_RASTER_POSITION_VALID:
+ params[0] = ctx->Current.RasterPosValid;
+ break;
+ case GL_CURRENT_TEXTURE_COORDS:
+ {
+ const GLuint texUnit = ctx->Texture.CurrentUnit;
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][0]);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][1]);
+ params[2] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][2]);
+ params[3] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][3]);
+ }
+ break;
+ case GL_DEPTH_BIAS:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.DepthBias);
+ break;
+ case GL_DEPTH_BITS:
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.depthBits);
+ break;
+ case GL_DEPTH_CLEAR_VALUE:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Depth.Clear);
+ break;
+ case GL_DEPTH_FUNC:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Depth.Func);
+ break;
+ case GL_DEPTH_RANGE:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Viewport.Near);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Viewport.Far);
+ break;
+ case GL_DEPTH_SCALE:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.DepthScale);
+ break;
+ case GL_DEPTH_TEST:
+ params[0] = ctx->Depth.Test;
+ break;
+ case GL_DEPTH_WRITEMASK:
+ params[0] = ctx->Depth.Mask;
+ break;
+ case GL_DITHER:
+ params[0] = ctx->Color.DitherFlag;
+ break;
+ case GL_DOUBLEBUFFER:
+ params[0] = ctx->DrawBuffer->Visual.doubleBufferMode;
+ break;
+ case GL_DRAW_BUFFER:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Color.DrawBuffer[0]);
+ break;
+ case GL_EDGE_FLAG:
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = ctx->Current.EdgeFlag;
+ }
+ break;
+ case GL_FEEDBACK_BUFFER_SIZE:
+ params[0] = INT_TO_BOOLEAN(ctx->Feedback.BufferSize);
+ break;
+ case GL_FEEDBACK_BUFFER_TYPE:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Feedback.Type);
+ break;
+ case GL_FOG:
+ params[0] = ctx->Fog.Enabled;
+ break;
+ case GL_FOG_COLOR:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Fog.Color[0]);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Fog.Color[1]);
+ params[2] = FLOAT_TO_BOOLEAN(ctx->Fog.Color[2]);
+ params[3] = FLOAT_TO_BOOLEAN(ctx->Fog.Color[3]);
+ break;
+ case GL_FOG_DENSITY:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Fog.Density);
+ break;
+ case GL_FOG_END:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Fog.End);
+ break;
+ case GL_FOG_HINT:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Hint.Fog);
+ break;
+ case GL_FOG_INDEX:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Fog.Index);
+ break;
+ case GL_FOG_MODE:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Fog.Mode);
+ break;
+ case GL_FOG_START:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Fog.Start);
+ break;
+ case GL_FRONT_FACE:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Polygon.FrontFace);
+ break;
+ case GL_GREEN_BIAS:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.GreenBias);
+ break;
+ case GL_GREEN_BITS:
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.greenBits);
+ break;
+ case GL_GREEN_SCALE:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.GreenScale);
+ break;
+ case GL_INDEX_BITS:
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.indexBits);
+ break;
+ case GL_INDEX_CLEAR_VALUE:
+ params[0] = INT_TO_BOOLEAN(ctx->Color.ClearIndex);
+ break;
+ case GL_INDEX_MODE:
+ params[0] = !ctx->DrawBuffer->Visual.rgbMode;
+ break;
+ case GL_INDEX_OFFSET:
+ params[0] = INT_TO_BOOLEAN(ctx->Pixel.IndexOffset);
+ break;
+ case GL_INDEX_SHIFT:
+ params[0] = INT_TO_BOOLEAN(ctx->Pixel.IndexShift);
+ break;
+ case GL_INDEX_WRITEMASK:
+ params[0] = INT_TO_BOOLEAN(ctx->Color.IndexMask);
+ break;
+ case GL_LIGHT0:
+ params[0] = ctx->Light.Light[0].Enabled;
+ break;
+ case GL_LIGHT1:
+ params[0] = ctx->Light.Light[1].Enabled;
+ break;
+ case GL_LIGHT2:
+ params[0] = ctx->Light.Light[2].Enabled;
+ break;
+ case GL_LIGHT3:
+ params[0] = ctx->Light.Light[3].Enabled;
+ break;
+ case GL_LIGHT4:
+ params[0] = ctx->Light.Light[4].Enabled;
+ break;
+ case GL_LIGHT5:
+ params[0] = ctx->Light.Light[5].Enabled;
+ break;
+ case GL_LIGHT6:
+ params[0] = ctx->Light.Light[6].Enabled;
+ break;
+ case GL_LIGHT7:
+ params[0] = ctx->Light.Light[7].Enabled;
+ break;
+ case GL_LIGHTING:
+ params[0] = ctx->Light.Enabled;
+ break;
+ case GL_LIGHT_MODEL_AMBIENT:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Light.Model.Ambient[0]);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Light.Model.Ambient[1]);
+ params[2] = FLOAT_TO_BOOLEAN(ctx->Light.Model.Ambient[2]);
+ params[3] = FLOAT_TO_BOOLEAN(ctx->Light.Model.Ambient[3]);
+ break;
+ case GL_LIGHT_MODEL_COLOR_CONTROL:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Light.Model.ColorControl);
+ break;
+ case GL_LIGHT_MODEL_LOCAL_VIEWER:
+ params[0] = ctx->Light.Model.LocalViewer;
+ break;
+ case GL_LIGHT_MODEL_TWO_SIDE:
+ params[0] = ctx->Light.Model.TwoSide;
+ break;
+ case GL_LINE_SMOOTH:
+ params[0] = ctx->Line.SmoothFlag;
+ break;
+ case GL_LINE_SMOOTH_HINT:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Hint.LineSmooth);
+ break;
+ case GL_LINE_STIPPLE:
+ params[0] = ctx->Line.StippleFlag;
+ break;
+ case GL_LINE_STIPPLE_PATTERN:
+ params[0] = INT_TO_BOOLEAN(ctx->Line.StipplePattern);
+ break;
+ case GL_LINE_STIPPLE_REPEAT:
+ params[0] = INT_TO_BOOLEAN(ctx->Line.StippleFactor);
+ break;
+ case GL_LINE_WIDTH:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Line.Width);
+ break;
+ case GL_LINE_WIDTH_GRANULARITY:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Const.LineWidthGranularity);
+ break;
+ case GL_LINE_WIDTH_RANGE:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Const.MinLineWidthAA);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Const.MaxLineWidthAA);
+ break;
+ case GL_ALIASED_LINE_WIDTH_RANGE:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Const.MinLineWidth);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Const.MaxLineWidth);
+ break;
+ case GL_LIST_BASE:
+ params[0] = INT_TO_BOOLEAN(ctx->List.ListBase);
+ break;
+ case GL_LIST_INDEX:
+ params[0] = INT_TO_BOOLEAN(ctx->ListState.CurrentListNum);
+ break;
+ case GL_LIST_MODE:
+ {
+ GLenum mode;
+ if (!ctx->CompileFlag)
+ mode = 0;
+ else if (ctx->ExecuteFlag)
+ mode = GL_COMPILE_AND_EXECUTE;
+ else
+ mode = GL_COMPILE;
+ params[0] = ENUM_TO_BOOLEAN(mode);
+ }
+ break;
+ case GL_INDEX_LOGIC_OP:
+ params[0] = ctx->Color.IndexLogicOpEnabled;
+ break;
+ case GL_COLOR_LOGIC_OP:
+ params[0] = ctx->Color.ColorLogicOpEnabled;
+ break;
+ case GL_LOGIC_OP_MODE:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Color.LogicOp);
+ break;
+ case GL_MAP1_COLOR_4:
+ params[0] = ctx->Eval.Map1Color4;
+ break;
+ case GL_MAP1_GRID_DOMAIN:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Eval.MapGrid1u1);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Eval.MapGrid1u2);
+ break;
+ case GL_MAP1_GRID_SEGMENTS:
+ params[0] = INT_TO_BOOLEAN(ctx->Eval.MapGrid1un);
+ break;
+ case GL_MAP1_INDEX:
+ params[0] = ctx->Eval.Map1Index;
+ break;
+ case GL_MAP1_NORMAL:
+ params[0] = ctx->Eval.Map1Normal;
+ break;
+ case GL_MAP1_TEXTURE_COORD_1:
+ params[0] = ctx->Eval.Map1TextureCoord1;
+ break;
+ case GL_MAP1_TEXTURE_COORD_2:
+ params[0] = ctx->Eval.Map1TextureCoord2;
+ break;
+ case GL_MAP1_TEXTURE_COORD_3:
+ params[0] = ctx->Eval.Map1TextureCoord3;
+ break;
+ case GL_MAP1_TEXTURE_COORD_4:
+ params[0] = ctx->Eval.Map1TextureCoord4;
+ break;
+ case GL_MAP1_VERTEX_3:
+ params[0] = ctx->Eval.Map1Vertex3;
+ break;
+ case GL_MAP1_VERTEX_4:
+ params[0] = ctx->Eval.Map1Vertex4;
+ break;
+ case GL_MAP2_COLOR_4:
+ params[0] = ctx->Eval.Map2Color4;
+ break;
+ case GL_MAP2_GRID_DOMAIN:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Eval.MapGrid2u1);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Eval.MapGrid2u2);
+ params[2] = FLOAT_TO_BOOLEAN(ctx->Eval.MapGrid2v1);
+ params[3] = FLOAT_TO_BOOLEAN(ctx->Eval.MapGrid2v2);
+ break;
+ case GL_MAP2_GRID_SEGMENTS:
+ params[0] = INT_TO_BOOLEAN(ctx->Eval.MapGrid2un);
+ params[1] = INT_TO_BOOLEAN(ctx->Eval.MapGrid2vn);
+ break;
+ case GL_MAP2_INDEX:
+ params[0] = ctx->Eval.Map2Index;
+ break;
+ case GL_MAP2_NORMAL:
+ params[0] = ctx->Eval.Map2Normal;
+ break;
+ case GL_MAP2_TEXTURE_COORD_1:
+ params[0] = ctx->Eval.Map2TextureCoord1;
+ break;
+ case GL_MAP2_TEXTURE_COORD_2:
+ params[0] = ctx->Eval.Map2TextureCoord2;
+ break;
+ case GL_MAP2_TEXTURE_COORD_3:
+ params[0] = ctx->Eval.Map2TextureCoord3;
+ break;
+ case GL_MAP2_TEXTURE_COORD_4:
+ params[0] = ctx->Eval.Map2TextureCoord4;
+ break;
+ case GL_MAP2_VERTEX_3:
+ params[0] = ctx->Eval.Map2Vertex3;
+ break;
+ case GL_MAP2_VERTEX_4:
+ params[0] = ctx->Eval.Map2Vertex4;
+ break;
+ case GL_MAP_COLOR:
+ params[0] = ctx->Pixel.MapColorFlag;
+ break;
+ case GL_MAP_STENCIL:
+ params[0] = ctx->Pixel.MapStencilFlag;
+ break;
+ case GL_MATRIX_MODE:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Transform.MatrixMode);
+ break;
+ case GL_MAX_ATTRIB_STACK_DEPTH:
+ params[0] = INT_TO_BOOLEAN(MAX_ATTRIB_STACK_DEPTH);
+ break;
+ case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
+ params[0] = INT_TO_BOOLEAN(MAX_CLIENT_ATTRIB_STACK_DEPTH);
+ break;
+ case GL_MAX_CLIP_PLANES:
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxClipPlanes);
+ break;
+ case GL_MAX_ELEMENTS_VERTICES:
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxArrayLockSize);
+ break;
+ case GL_MAX_ELEMENTS_INDICES:
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxArrayLockSize);
+ break;
+ case GL_MAX_EVAL_ORDER:
+ params[0] = INT_TO_BOOLEAN(MAX_EVAL_ORDER);
+ break;
+ case GL_MAX_LIGHTS:
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxLights);
+ break;
+ case GL_MAX_LIST_NESTING:
+ params[0] = INT_TO_BOOLEAN(MAX_LIST_NESTING);
+ break;
+ case GL_MAX_MODELVIEW_STACK_DEPTH:
+ params[0] = INT_TO_BOOLEAN(MAX_MODELVIEW_STACK_DEPTH);
+ break;
+ case GL_MAX_NAME_STACK_DEPTH:
+ params[0] = INT_TO_BOOLEAN(MAX_NAME_STACK_DEPTH);
+ break;
+ case GL_MAX_PIXEL_MAP_TABLE:
+ params[0] = INT_TO_BOOLEAN(MAX_PIXEL_MAP_TABLE);
+ break;
+ case GL_MAX_PROJECTION_STACK_DEPTH:
+ params[0] = INT_TO_BOOLEAN(MAX_PROJECTION_STACK_DEPTH);
+ break;
+ case GL_MAX_TEXTURE_SIZE:
+ params[0] = INT_TO_BOOLEAN(1 << (ctx->Const.MaxTextureLevels - 1));
+ break;
+ case GL_MAX_3D_TEXTURE_SIZE:
+ params[0] = INT_TO_BOOLEAN(1 << (ctx->Const.Max3DTextureLevels - 1));
+ break;
+ case GL_MAX_TEXTURE_STACK_DEPTH:
+ params[0] = INT_TO_BOOLEAN(MAX_TEXTURE_STACK_DEPTH);
+ break;
+ case GL_MAX_VIEWPORT_DIMS:
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxViewportWidth);
+ params[1] = INT_TO_BOOLEAN(ctx->Const.MaxViewportHeight);
+ break;
+ case GL_MODELVIEW_MATRIX:
+ {
+ const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;
+ params[0] = FLOAT_TO_BOOLEAN(matrix[0]);
+ params[1] = FLOAT_TO_BOOLEAN(matrix[1]);
+ params[2] = FLOAT_TO_BOOLEAN(matrix[2]);
+ params[3] = FLOAT_TO_BOOLEAN(matrix[3]);
+ params[4] = FLOAT_TO_BOOLEAN(matrix[4]);
+ params[5] = FLOAT_TO_BOOLEAN(matrix[5]);
+ params[6] = FLOAT_TO_BOOLEAN(matrix[6]);
+ params[7] = FLOAT_TO_BOOLEAN(matrix[7]);
+ params[8] = FLOAT_TO_BOOLEAN(matrix[8]);
+ params[9] = FLOAT_TO_BOOLEAN(matrix[9]);
+ params[10] = FLOAT_TO_BOOLEAN(matrix[10]);
+ params[11] = FLOAT_TO_BOOLEAN(matrix[11]);
+ params[12] = FLOAT_TO_BOOLEAN(matrix[12]);
+ params[13] = FLOAT_TO_BOOLEAN(matrix[13]);
+ params[14] = FLOAT_TO_BOOLEAN(matrix[14]);
+ params[15] = FLOAT_TO_BOOLEAN(matrix[15]);
+ }
+ break;
+ case GL_MODELVIEW_STACK_DEPTH:
+ params[0] = INT_TO_BOOLEAN(ctx->ModelviewMatrixStack.Depth + 1);
+ break;
+ case GL_NAME_STACK_DEPTH:
+ params[0] = INT_TO_BOOLEAN(ctx->Select.NameStackDepth);
+ break;
+ case GL_NORMALIZE:
+ params[0] = ctx->Transform.Normalize;
+ break;
+ case GL_PACK_ALIGNMENT:
+ params[0] = INT_TO_BOOLEAN(ctx->Pack.Alignment);
+ break;
+ case GL_PACK_LSB_FIRST:
+ params[0] = ctx->Pack.LsbFirst;
+ break;
+ case GL_PACK_ROW_LENGTH:
+ params[0] = INT_TO_BOOLEAN(ctx->Pack.RowLength);
+ break;
+ case GL_PACK_SKIP_PIXELS:
+ params[0] = INT_TO_BOOLEAN(ctx->Pack.SkipPixels);
+ break;
+ case GL_PACK_SKIP_ROWS:
+ params[0] = INT_TO_BOOLEAN(ctx->Pack.SkipRows);
+ break;
+ case GL_PACK_SWAP_BYTES:
+ params[0] = ctx->Pack.SwapBytes;
+ break;
+ case GL_PACK_SKIP_IMAGES_EXT:
+ params[0] = INT_TO_BOOLEAN(ctx->Pack.SkipImages);
+ break;
+ case GL_PACK_IMAGE_HEIGHT_EXT:
+ params[0] = INT_TO_BOOLEAN(ctx->Pack.ImageHeight);
+ break;
+ case GL_PACK_INVERT_MESA:
+ params[0] = ctx->Pack.Invert;
+ break;
+ case GL_PERSPECTIVE_CORRECTION_HINT:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Hint.PerspectiveCorrection);
+ break;
+ case GL_PIXEL_MAP_A_TO_A_SIZE:
+ params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapAtoAsize);
+ break;
+ case GL_PIXEL_MAP_B_TO_B_SIZE:
+ params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapBtoBsize);
+ break;
+ case GL_PIXEL_MAP_G_TO_G_SIZE:
+ params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapGtoGsize);
+ break;
+ case GL_PIXEL_MAP_I_TO_A_SIZE:
+ params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapItoAsize);
+ break;
+ case GL_PIXEL_MAP_I_TO_B_SIZE:
+ params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapItoBsize);
+ break;
+ case GL_PIXEL_MAP_I_TO_G_SIZE:
+ params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapItoGsize);
+ break;
+ case GL_PIXEL_MAP_I_TO_I_SIZE:
+ params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapItoIsize);
+ break;
+ case GL_PIXEL_MAP_I_TO_R_SIZE:
+ params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapItoRsize);
+ break;
+ case GL_PIXEL_MAP_R_TO_R_SIZE:
+ params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapRtoRsize);
+ break;
+ case GL_PIXEL_MAP_S_TO_S_SIZE:
+ params[0] = INT_TO_BOOLEAN(ctx->Pixel.MapStoSsize);
+ break;
+ case GL_POINT_SIZE:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Point.Size);
+ break;
+ case GL_POINT_SIZE_GRANULARITY:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Const.PointSizeGranularity);
+ break;
+ case GL_POINT_SIZE_RANGE:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Const.MinPointSizeAA);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Const.MaxPointSizeAA);
+ break;
+ case GL_ALIASED_POINT_SIZE_RANGE:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Const.MinPointSize);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Const.MaxPointSize);
+ break;
+ case GL_POINT_SMOOTH:
+ params[0] = ctx->Point.SmoothFlag;
+ break;
+ case GL_POINT_SMOOTH_HINT:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Hint.PointSmooth);
+ break;
+ case GL_POINT_SIZE_MIN_EXT:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Point.MinSize);
+ break;
+ case GL_POINT_SIZE_MAX_EXT:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Point.MaxSize);
+ break;
+ case GL_POINT_FADE_THRESHOLD_SIZE_EXT:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Point.Threshold);
+ break;
+ case GL_DISTANCE_ATTENUATION_EXT:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Point.Params[0]);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Point.Params[1]);
+ params[2] = FLOAT_TO_BOOLEAN(ctx->Point.Params[2]);
+ break;
+ case GL_POLYGON_MODE:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Polygon.FrontMode);
+ params[1] = ENUM_TO_BOOLEAN(ctx->Polygon.BackMode);
+ break;
+ case GL_POLYGON_OFFSET_BIAS_EXT:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Polygon.OffsetUnits);
+ break;
+ case GL_POLYGON_OFFSET_FACTOR:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Polygon.OffsetFactor );
+ break;
+ case GL_POLYGON_OFFSET_UNITS:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Polygon.OffsetUnits );
+ break;
+ case GL_POLYGON_SMOOTH:
+ params[0] = ctx->Polygon.SmoothFlag;
+ break;
+ case GL_POLYGON_SMOOTH_HINT:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Hint.PolygonSmooth);
+ break;
+ case GL_POLYGON_STIPPLE:
+ params[0] = ctx->Polygon.StippleFlag;
+ break;
+ case GL_PROJECTION_MATRIX:
+ {
+ const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;
+ params[0] = FLOAT_TO_BOOLEAN(matrix[0]);
+ params[1] = FLOAT_TO_BOOLEAN(matrix[1]);
+ params[2] = FLOAT_TO_BOOLEAN(matrix[2]);
+ params[3] = FLOAT_TO_BOOLEAN(matrix[3]);
+ params[4] = FLOAT_TO_BOOLEAN(matrix[4]);
+ params[5] = FLOAT_TO_BOOLEAN(matrix[5]);
+ params[6] = FLOAT_TO_BOOLEAN(matrix[6]);
+ params[7] = FLOAT_TO_BOOLEAN(matrix[7]);
+ params[8] = FLOAT_TO_BOOLEAN(matrix[8]);
+ params[9] = FLOAT_TO_BOOLEAN(matrix[9]);
+ params[10] = FLOAT_TO_BOOLEAN(matrix[10]);
+ params[11] = FLOAT_TO_BOOLEAN(matrix[11]);
+ params[12] = FLOAT_TO_BOOLEAN(matrix[12]);
+ params[13] = FLOAT_TO_BOOLEAN(matrix[13]);
+ params[14] = FLOAT_TO_BOOLEAN(matrix[14]);
+ params[15] = FLOAT_TO_BOOLEAN(matrix[15]);
+ }
+ break;
+ case GL_PROJECTION_STACK_DEPTH:
+ params[0] = INT_TO_BOOLEAN(ctx->ProjectionMatrixStack.Depth + 1);
+ break;
+ case GL_READ_BUFFER:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Pixel.ReadBuffer);
+ break;
+ case GL_RED_BIAS:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.RedBias);
+ break;
+ case GL_RED_BITS:
+ params[0] = INT_TO_BOOLEAN( ctx->DrawBuffer->Visual.redBits );
+ break;
+ case GL_RED_SCALE:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.RedScale);
+ break;
+ case GL_RENDER_MODE:
+ params[0] = ENUM_TO_BOOLEAN(ctx->RenderMode);
+ break;
+ case GL_RESCALE_NORMAL:
+ params[0] = ctx->Transform.RescaleNormals;
+ break;
+ case GL_RGBA_MODE:
+ params[0] = ctx->DrawBuffer->Visual.rgbMode;
+ break;
+ case GL_SCISSOR_BOX:
+ params[0] = INT_TO_BOOLEAN(ctx->Scissor.X);
+ params[1] = INT_TO_BOOLEAN(ctx->Scissor.Y);
+ params[2] = INT_TO_BOOLEAN(ctx->Scissor.Width);
+ params[3] = INT_TO_BOOLEAN(ctx->Scissor.Height);
+ break;
+ case GL_SCISSOR_TEST:
+ params[0] = ctx->Scissor.Enabled;
+ break;
+ case GL_SELECTION_BUFFER_SIZE:
+ params[0] = INT_TO_BOOLEAN(ctx->Select.BufferSize);
+ break;
+ case GL_SHADE_MODEL:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Light.ShadeModel);
+ break;
+ case GL_SHARED_TEXTURE_PALETTE_EXT:
+ params[0] = ctx->Texture.SharedPalette;
+ break;
+ case GL_STENCIL_BITS:
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.stencilBits);
+ break;
+ case GL_STENCIL_CLEAR_VALUE:
+ params[0] = INT_TO_BOOLEAN(ctx->Stencil.Clear);
+ break;
+ case GL_STENCIL_FAIL:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STENCIL_FUNC:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.Function[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STENCIL_PASS_DEPTH_FAIL:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STENCIL_PASS_DEPTH_PASS:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STENCIL_REF:
+ params[0] = INT_TO_BOOLEAN(ctx->Stencil.Ref[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STENCIL_TEST:
+ params[0] = ctx->Stencil.Enabled;
+ break;
+ case GL_STENCIL_VALUE_MASK:
+ params[0] = INT_TO_BOOLEAN(ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STENCIL_WRITEMASK:
+ params[0] = INT_TO_BOOLEAN(ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STEREO:
+ params[0] = ctx->DrawBuffer->Visual.stereoMode;
+ break;
+ case GL_SUBPIXEL_BITS:
+ params[0] = INT_TO_BOOLEAN(ctx->Const.SubPixelBits);
+ break;
+ case GL_TEXTURE_1D:
+ params[0] = _mesa_IsEnabled(GL_TEXTURE_1D);
+ break;
+ case GL_TEXTURE_2D:
+ params[0] = _mesa_IsEnabled(GL_TEXTURE_2D);
+ break;
+ case GL_TEXTURE_3D:
+ params[0] = _mesa_IsEnabled(GL_TEXTURE_3D);
+ break;
+ case GL_TEXTURE_BINDING_1D:
+ params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current1D->Name);
+ break;
+ case GL_TEXTURE_BINDING_2D:
+ params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current2D->Name);
+ break;
+ case GL_TEXTURE_BINDING_3D:
+ params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current3D->Name);
+ break;
+ case GL_TEXTURE_ENV_COLOR:
+ {
+ const GLfloat *color = ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvColor;
+ params[0] = FLOAT_TO_BOOLEAN(color[0]);
+ params[1] = FLOAT_TO_BOOLEAN(color[1]);
+ params[2] = FLOAT_TO_BOOLEAN(color[2]);
+ params[3] = FLOAT_TO_BOOLEAN(color[3]);
+ }
+ break;
+ case GL_TEXTURE_ENV_MODE:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvMode);
+ break;
+ case GL_TEXTURE_GEN_S:
+ params[0] = ((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0);
+ break;
+ case GL_TEXTURE_GEN_T:
+ params[0] = ((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & T_BIT) ? 1 : 0);
+ break;
+ case GL_TEXTURE_GEN_R:
+ params[0] = ((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & R_BIT) ? 1 : 0);
+ break;
+ case GL_TEXTURE_GEN_Q:
+ params[0] = ((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & Q_BIT) ? 1 : 0);
+ break;
+ case GL_TEXTURE_MATRIX:
+ {
+ const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;
+ params[0] = FLOAT_TO_BOOLEAN(matrix[0]);
+ params[1] = FLOAT_TO_BOOLEAN(matrix[1]);
+ params[2] = FLOAT_TO_BOOLEAN(matrix[2]);
+ params[3] = FLOAT_TO_BOOLEAN(matrix[3]);
+ params[4] = FLOAT_TO_BOOLEAN(matrix[4]);
+ params[5] = FLOAT_TO_BOOLEAN(matrix[5]);
+ params[6] = FLOAT_TO_BOOLEAN(matrix[6]);
+ params[7] = FLOAT_TO_BOOLEAN(matrix[7]);
+ params[8] = FLOAT_TO_BOOLEAN(matrix[8]);
+ params[9] = FLOAT_TO_BOOLEAN(matrix[9]);
+ params[10] = FLOAT_TO_BOOLEAN(matrix[10]);
+ params[11] = FLOAT_TO_BOOLEAN(matrix[11]);
+ params[12] = FLOAT_TO_BOOLEAN(matrix[12]);
+ params[13] = FLOAT_TO_BOOLEAN(matrix[13]);
+ params[14] = FLOAT_TO_BOOLEAN(matrix[14]);
+ params[15] = FLOAT_TO_BOOLEAN(matrix[15]);
+ }
+ break;
+ case GL_TEXTURE_STACK_DEPTH:
+ params[0] = INT_TO_BOOLEAN(ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Depth + 1);
+ break;
+ case GL_UNPACK_ALIGNMENT:
+ params[0] = INT_TO_BOOLEAN(ctx->Unpack.Alignment);
+ break;
+ case GL_UNPACK_LSB_FIRST:
+ params[0] = ctx->Unpack.LsbFirst;
+ break;
+ case GL_UNPACK_ROW_LENGTH:
+ params[0] = INT_TO_BOOLEAN(ctx->Unpack.RowLength);
+ break;
+ case GL_UNPACK_SKIP_PIXELS:
+ params[0] = INT_TO_BOOLEAN(ctx->Unpack.SkipPixels);
+ break;
+ case GL_UNPACK_SKIP_ROWS:
+ params[0] = INT_TO_BOOLEAN(ctx->Unpack.SkipRows);
+ break;
+ case GL_UNPACK_SWAP_BYTES:
+ params[0] = ctx->Unpack.SwapBytes;
+ break;
+ case GL_UNPACK_SKIP_IMAGES_EXT:
+ params[0] = INT_TO_BOOLEAN(ctx->Unpack.SkipImages);
+ break;
+ case GL_UNPACK_IMAGE_HEIGHT_EXT:
+ params[0] = INT_TO_BOOLEAN(ctx->Unpack.ImageHeight);
+ break;
+ case GL_UNPACK_CLIENT_STORAGE_APPLE:
+ params[0] = ctx->Unpack.ClientStorage;
+ break;
+ case GL_VIEWPORT:
+ params[0] = INT_TO_BOOLEAN(ctx->Viewport.X);
+ params[1] = INT_TO_BOOLEAN(ctx->Viewport.Y);
+ params[2] = INT_TO_BOOLEAN(ctx->Viewport.Width);
+ params[3] = INT_TO_BOOLEAN(ctx->Viewport.Height);
+ break;
+ case GL_ZOOM_X:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.ZoomX);
+ break;
+ case GL_ZOOM_Y:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.ZoomY);
+ break;
+ case GL_VERTEX_ARRAY:
+ params[0] = ctx->Array.Vertex.Enabled;
+ break;
+ case GL_VERTEX_ARRAY_SIZE:
+ params[0] = INT_TO_BOOLEAN(ctx->Array.Vertex.Size);
+ break;
+ case GL_VERTEX_ARRAY_TYPE:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Array.Vertex.Type);
+ break;
+ case GL_VERTEX_ARRAY_STRIDE:
+ params[0] = INT_TO_BOOLEAN(ctx->Array.Vertex.Stride);
+ break;
+ case GL_VERTEX_ARRAY_COUNT_EXT:
+ params[0] = INT_TO_BOOLEAN(0);
+ break;
+ case GL_NORMAL_ARRAY:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Array.Normal.Enabled);
+ break;
+ case GL_NORMAL_ARRAY_TYPE:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Array.Normal.Type);
+ break;
+ case GL_NORMAL_ARRAY_STRIDE:
+ params[0] = INT_TO_BOOLEAN(ctx->Array.Normal.Stride);
+ break;
+ case GL_NORMAL_ARRAY_COUNT_EXT:
+ params[0] = INT_TO_BOOLEAN(0);
+ break;
+ case GL_COLOR_ARRAY:
+ params[0] = ctx->Array.Color.Enabled;
+ break;
+ case GL_COLOR_ARRAY_SIZE:
+ params[0] = INT_TO_BOOLEAN(ctx->Array.Color.Size);
+ break;
+ case GL_COLOR_ARRAY_TYPE:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Array.Color.Type);
+ break;
+ case GL_COLOR_ARRAY_STRIDE:
+ params[0] = INT_TO_BOOLEAN(ctx->Array.Color.Stride);
+ break;
+ case GL_COLOR_ARRAY_COUNT_EXT:
+ params[0] = INT_TO_BOOLEAN(0);
+ break;
+ case GL_INDEX_ARRAY:
+ params[0] = ctx->Array.Index.Enabled;
+ break;
+ case GL_INDEX_ARRAY_TYPE:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Array.Index.Type);
+ break;
+ case GL_INDEX_ARRAY_STRIDE:
+ params[0] = INT_TO_BOOLEAN(ctx->Array.Index.Stride);
+ break;
+ case GL_INDEX_ARRAY_COUNT_EXT:
+ params[0] = INT_TO_BOOLEAN(0);
+ break;
+ case GL_TEXTURE_COORD_ARRAY:
+ params[0] = ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled;
+ break;
+ case GL_TEXTURE_COORD_ARRAY_SIZE:
+ params[0] = INT_TO_BOOLEAN(ctx->Array.TexCoord[ctx->Array.ActiveTexture].Size);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_TYPE:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Array.TexCoord[ctx->Array.ActiveTexture].Type);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_STRIDE:
+ params[0] = INT_TO_BOOLEAN(ctx->Array.TexCoord[ctx->Array.ActiveTexture].Stride);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_COUNT_EXT:
+ params[0] = INT_TO_BOOLEAN(0);
+ break;
+ case GL_EDGE_FLAG_ARRAY:
+ params[0] = ctx->Array.EdgeFlag.Enabled;
+ break;
+ case GL_EDGE_FLAG_ARRAY_STRIDE:
+ params[0] = INT_TO_BOOLEAN(ctx->Array.EdgeFlag.Stride);
+ break;
+ case GL_EDGE_FLAG_ARRAY_COUNT_EXT:
+ params[0] = INT_TO_BOOLEAN(0);
+ break;
+ case GL_MAX_TEXTURE_UNITS_ARB:
+ CHECK_EXTENSION_B(ARB_multitexture, pname);
+ params[0] = INT_TO_BOOLEAN(MIN2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits));
+ break;
+ case GL_ACTIVE_TEXTURE_ARB:
+ CHECK_EXTENSION_B(ARB_multitexture, pname);
+ params[0] = INT_TO_BOOLEAN(GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit);
+ break;
+ case GL_CLIENT_ACTIVE_TEXTURE_ARB:
+ CHECK_EXTENSION_B(ARB_multitexture, pname);
+ params[0] = INT_TO_BOOLEAN(GL_TEXTURE0_ARB + ctx->Array.ActiveTexture);
+ break;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ CHECK_EXTENSION_B(ARB_texture_cube_map, pname);
+ params[0] = _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB);
+ break;
+ case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
+ CHECK_EXTENSION_B(ARB_texture_cube_map, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentCubeMap->Name);
+ break;
+ case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
+ CHECK_EXTENSION_B(ARB_texture_cube_map, pname);
+ params[0] = INT_TO_BOOLEAN((1 << (ctx->Const.MaxCubeTextureLevels - 1)));
+ break;
+ case GL_TEXTURE_COMPRESSION_HINT_ARB:
+ CHECK_EXTENSION_B(ARB_texture_compression, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Hint.TextureCompression);
+ break;
+ case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
+ CHECK_EXTENSION_B(ARB_texture_compression, pname);
+ params[0] = INT_TO_BOOLEAN(_mesa_get_compressed_formats(ctx, NULL));
+ break;
+ case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
+ CHECK_EXTENSION_B(ARB_texture_compression, pname);
+ {
+ GLint formats[100];
+ GLuint i, n = _mesa_get_compressed_formats(ctx, formats);
+ ASSERT(n <= 100);
+ for (i = 0; i < n; i++)
+ params[i] = ENUM_TO_INT(formats[i]);
+ }
+ break;
+ case GL_ARRAY_ELEMENT_LOCK_FIRST_EXT:
+ CHECK_EXTENSION_B(EXT_compiled_vertex_array, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Array.LockFirst);
+ break;
+ case GL_ARRAY_ELEMENT_LOCK_COUNT_EXT:
+ CHECK_EXTENSION_B(EXT_compiled_vertex_array, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Array.LockCount);
+ break;
+ case GL_TRANSPOSE_COLOR_MATRIX_ARB:
+ {
+ const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;
+ params[0] = FLOAT_TO_BOOLEAN(matrix[0]);
+ params[1] = FLOAT_TO_BOOLEAN(matrix[4]);
+ params[2] = FLOAT_TO_BOOLEAN(matrix[8]);
+ params[3] = FLOAT_TO_BOOLEAN(matrix[12]);
+ params[4] = FLOAT_TO_BOOLEAN(matrix[1]);
+ params[5] = FLOAT_TO_BOOLEAN(matrix[5]);
+ params[6] = FLOAT_TO_BOOLEAN(matrix[9]);
+ params[7] = FLOAT_TO_BOOLEAN(matrix[13]);
+ params[8] = FLOAT_TO_BOOLEAN(matrix[2]);
+ params[9] = FLOAT_TO_BOOLEAN(matrix[6]);
+ params[10] = FLOAT_TO_BOOLEAN(matrix[10]);
+ params[11] = FLOAT_TO_BOOLEAN(matrix[14]);
+ params[12] = FLOAT_TO_BOOLEAN(matrix[3]);
+ params[13] = FLOAT_TO_BOOLEAN(matrix[7]);
+ params[14] = FLOAT_TO_BOOLEAN(matrix[11]);
+ params[15] = FLOAT_TO_BOOLEAN(matrix[15]);
+ }
+ break;
+ case GL_TRANSPOSE_MODELVIEW_MATRIX_ARB:
+ {
+ const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;
+ params[0] = FLOAT_TO_BOOLEAN(matrix[0]);
+ params[1] = FLOAT_TO_BOOLEAN(matrix[4]);
+ params[2] = FLOAT_TO_BOOLEAN(matrix[8]);
+ params[3] = FLOAT_TO_BOOLEAN(matrix[12]);
+ params[4] = FLOAT_TO_BOOLEAN(matrix[1]);
+ params[5] = FLOAT_TO_BOOLEAN(matrix[5]);
+ params[6] = FLOAT_TO_BOOLEAN(matrix[9]);
+ params[7] = FLOAT_TO_BOOLEAN(matrix[13]);
+ params[8] = FLOAT_TO_BOOLEAN(matrix[2]);
+ params[9] = FLOAT_TO_BOOLEAN(matrix[6]);
+ params[10] = FLOAT_TO_BOOLEAN(matrix[10]);
+ params[11] = FLOAT_TO_BOOLEAN(matrix[14]);
+ params[12] = FLOAT_TO_BOOLEAN(matrix[3]);
+ params[13] = FLOAT_TO_BOOLEAN(matrix[7]);
+ params[14] = FLOAT_TO_BOOLEAN(matrix[11]);
+ params[15] = FLOAT_TO_BOOLEAN(matrix[15]);
+ }
+ break;
+ case GL_TRANSPOSE_PROJECTION_MATRIX_ARB:
+ {
+ const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;
+ params[0] = FLOAT_TO_BOOLEAN(matrix[0]);
+ params[1] = FLOAT_TO_BOOLEAN(matrix[4]);
+ params[2] = FLOAT_TO_BOOLEAN(matrix[8]);
+ params[3] = FLOAT_TO_BOOLEAN(matrix[12]);
+ params[4] = FLOAT_TO_BOOLEAN(matrix[1]);
+ params[5] = FLOAT_TO_BOOLEAN(matrix[5]);
+ params[6] = FLOAT_TO_BOOLEAN(matrix[9]);
+ params[7] = FLOAT_TO_BOOLEAN(matrix[13]);
+ params[8] = FLOAT_TO_BOOLEAN(matrix[2]);
+ params[9] = FLOAT_TO_BOOLEAN(matrix[6]);
+ params[10] = FLOAT_TO_BOOLEAN(matrix[10]);
+ params[11] = FLOAT_TO_BOOLEAN(matrix[14]);
+ params[12] = FLOAT_TO_BOOLEAN(matrix[3]);
+ params[13] = FLOAT_TO_BOOLEAN(matrix[7]);
+ params[14] = FLOAT_TO_BOOLEAN(matrix[11]);
+ params[15] = FLOAT_TO_BOOLEAN(matrix[15]);
+ }
+ break;
+ case GL_TRANSPOSE_TEXTURE_MATRIX_ARB:
+ {
+ const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;
+ params[0] = FLOAT_TO_BOOLEAN(matrix[0]);
+ params[1] = FLOAT_TO_BOOLEAN(matrix[4]);
+ params[2] = FLOAT_TO_BOOLEAN(matrix[8]);
+ params[3] = FLOAT_TO_BOOLEAN(matrix[12]);
+ params[4] = FLOAT_TO_BOOLEAN(matrix[1]);
+ params[5] = FLOAT_TO_BOOLEAN(matrix[5]);
+ params[6] = FLOAT_TO_BOOLEAN(matrix[9]);
+ params[7] = FLOAT_TO_BOOLEAN(matrix[13]);
+ params[8] = FLOAT_TO_BOOLEAN(matrix[2]);
+ params[9] = FLOAT_TO_BOOLEAN(matrix[6]);
+ params[10] = FLOAT_TO_BOOLEAN(matrix[10]);
+ params[11] = FLOAT_TO_BOOLEAN(matrix[14]);
+ params[12] = FLOAT_TO_BOOLEAN(matrix[3]);
+ params[13] = FLOAT_TO_BOOLEAN(matrix[7]);
+ params[14] = FLOAT_TO_BOOLEAN(matrix[11]);
+ params[15] = FLOAT_TO_BOOLEAN(matrix[15]);
+ }
+ break;
+ case GL_OCCLUSION_TEST_HP:
+ CHECK_EXTENSION_B(HP_occlusion_test, pname);
+ params[0] = ctx->Depth.OcclusionTest;
+ break;
+ case GL_OCCLUSION_TEST_RESULT_HP:
+ CHECK_EXTENSION_B(HP_occlusion_test, pname);
+ {
+ FLUSH_VERTICES(ctx, _NEW_DEPTH);
+ if (ctx->Depth.OcclusionTest)
+ params[0] = ctx->OcclusionResult;
+ else
+ params[0] = ctx->OcclusionResultSaved;
+ /* reset flag now */
+ ctx->OcclusionResult = GL_FALSE;
+ ctx->OcclusionResultSaved = GL_FALSE;
+ return;
+ }
+ break;
+ case GL_PIXEL_TEXTURE_SGIS:
+ CHECK_EXTENSION_B(SGIS_pixel_texture, pname);
+ params[0] = ctx->Pixel.PixelTextureEnabled;
+ break;
+ case GL_PIXEL_TEX_GEN_SGIX:
+ CHECK_EXTENSION_B(SGIX_pixel_texture, pname);
+ params[0] = ctx->Pixel.PixelTextureEnabled;
+ break;
+ case GL_PIXEL_TEX_GEN_MODE_SGIX:
+ CHECK_EXTENSION_B(SGIX_pixel_texture, pname);
+ params[0] = ENUM_TO_BOOLEAN(pixel_texgen_mode(ctx));
+ break;
+ case GL_COLOR_MATRIX_SGI:
+ {
+ const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;
+ params[0] = FLOAT_TO_BOOLEAN(matrix[0]);
+ params[1] = FLOAT_TO_BOOLEAN(matrix[1]);
+ params[2] = FLOAT_TO_BOOLEAN(matrix[2]);
+ params[3] = FLOAT_TO_BOOLEAN(matrix[3]);
+ params[4] = FLOAT_TO_BOOLEAN(matrix[4]);
+ params[5] = FLOAT_TO_BOOLEAN(matrix[5]);
+ params[6] = FLOAT_TO_BOOLEAN(matrix[6]);
+ params[7] = FLOAT_TO_BOOLEAN(matrix[7]);
+ params[8] = FLOAT_TO_BOOLEAN(matrix[8]);
+ params[9] = FLOAT_TO_BOOLEAN(matrix[9]);
+ params[10] = FLOAT_TO_BOOLEAN(matrix[10]);
+ params[11] = FLOAT_TO_BOOLEAN(matrix[11]);
+ params[12] = FLOAT_TO_BOOLEAN(matrix[12]);
+ params[13] = FLOAT_TO_BOOLEAN(matrix[13]);
+ params[14] = FLOAT_TO_BOOLEAN(matrix[14]);
+ params[15] = FLOAT_TO_BOOLEAN(matrix[15]);
+ }
+ break;
+ case GL_COLOR_MATRIX_STACK_DEPTH_SGI:
+ params[0] = INT_TO_BOOLEAN(ctx->ColorMatrixStack.Depth + 1);
+ break;
+ case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI:
+ params[0] = INT_TO_BOOLEAN(MAX_COLOR_STACK_DEPTH);
+ break;
+ case GL_POST_COLOR_MATRIX_RED_SCALE_SGI:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostColorMatrixScale[0]);
+ break;
+ case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostColorMatrixScale[1]);
+ break;
+ case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostColorMatrixScale[2]);
+ break;
+ case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostColorMatrixScale[3]);
+ break;
+ case GL_POST_COLOR_MATRIX_RED_BIAS_SGI:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostColorMatrixBias[0]);
+ break;
+ case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostColorMatrixBias[1]);
+ break;
+ case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostColorMatrixBias[2]);
+ break;
+ case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI:
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostColorMatrixBias[3]);
+ break;
+ case GL_CONVOLUTION_1D_EXT:
+ CHECK_EXTENSION_B(EXT_convolution, pname);
+ params[0] = ctx->Pixel.Convolution1DEnabled;
+ break;
+ case GL_CONVOLUTION_2D_EXT:
+ CHECK_EXTENSION_B(EXT_convolution, pname);
+ params[0] = ctx->Pixel.Convolution2DEnabled;
+ break;
+ case GL_SEPARABLE_2D_EXT:
+ CHECK_EXTENSION_B(EXT_convolution, pname);
+ params[0] = ctx->Pixel.Separable2DEnabled;
+ break;
+ case GL_POST_CONVOLUTION_RED_SCALE_EXT:
+ CHECK_EXTENSION_B(EXT_convolution, pname);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostConvolutionScale[0]);
+ break;
+ case GL_POST_CONVOLUTION_GREEN_SCALE_EXT:
+ CHECK_EXTENSION_B(EXT_convolution, pname);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostConvolutionScale[1]);
+ break;
+ case GL_POST_CONVOLUTION_BLUE_SCALE_EXT:
+ CHECK_EXTENSION_B(EXT_convolution, pname);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostConvolutionScale[2]);
+ break;
+ case GL_POST_CONVOLUTION_ALPHA_SCALE_EXT:
+ CHECK_EXTENSION_B(EXT_convolution, pname);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostConvolutionScale[3]);
+ break;
+ case GL_POST_CONVOLUTION_RED_BIAS_EXT:
+ CHECK_EXTENSION_B(EXT_convolution, pname);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostConvolutionBias[0]);
+ break;
+ case GL_POST_CONVOLUTION_GREEN_BIAS_EXT:
+ CHECK_EXTENSION_B(EXT_convolution, pname);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostConvolutionBias[1]);
+ break;
+ case GL_POST_CONVOLUTION_BLUE_BIAS_EXT:
+ CHECK_EXTENSION_B(EXT_convolution, pname);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostConvolutionBias[2]);
+ break;
+ case GL_POST_CONVOLUTION_ALPHA_BIAS_EXT:
+ CHECK_EXTENSION_B(EXT_convolution, pname);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Pixel.PostConvolutionBias[3]);
+ break;
+ case GL_HISTOGRAM:
+ CHECK_EXTENSION_B(EXT_histogram, pname);
+ params[0] = ctx->Pixel.HistogramEnabled;
+ break;
+ case GL_MINMAX:
+ CHECK_EXTENSION_B(EXT_histogram, pname);
+ params[0] = ctx->Pixel.MinMaxEnabled;
+ break;
+ case GL_COLOR_TABLE_SGI:
+ CHECK_EXTENSION_B(SGI_color_table, pname);
+ params[0] = ctx->Pixel.ColorTableEnabled;
+ break;
+ case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
+ CHECK_EXTENSION_B(SGI_color_table, pname);
+ params[0] = ctx->Pixel.PostConvolutionColorTableEnabled;
+ break;
+ case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
+ CHECK_EXTENSION_B(SGI_color_table, pname);
+ params[0] = ctx->Pixel.PostColorMatrixColorTableEnabled;
+ break;
+ case GL_TEXTURE_COLOR_TABLE_SGI:
+ CHECK_EXTENSION_B(SGI_texture_color_table, pname);
+ params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled;
+ break;
+ case GL_COLOR_SUM_EXT:
+ CHECK_EXTENSION_B(EXT_secondary_color, pname);
+ params[0] = ctx->Fog.ColorSumEnabled;
+ break;
+ case GL_CURRENT_SECONDARY_COLOR_EXT:
+ CHECK_EXTENSION_B(EXT_secondary_color, pname);
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0]);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1]);
+ params[2] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2]);
+ params[3] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3]);
+ }
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_EXT:
+ CHECK_EXTENSION_B(EXT_secondary_color, pname);
+ params[0] = ctx->Array.SecondaryColor.Enabled;
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_TYPE_EXT:
+ CHECK_EXTENSION_B(EXT_secondary_color, pname);
+ params[0] = ENUM_TO_BOOLEAN(ctx->Array.SecondaryColor.Type);
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT:
+ CHECK_EXTENSION_B(EXT_secondary_color, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Array.SecondaryColor.Stride);
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_SIZE_EXT:
+ CHECK_EXTENSION_B(EXT_secondary_color, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Array.SecondaryColor.Size);
+ break;
+ case GL_CURRENT_FOG_COORDINATE_EXT:
+ CHECK_EXTENSION_B(EXT_fog_coord, pname);
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Current.Attrib[VERT_ATTRIB_FOG][0]);
+ }
+ break;
+ case GL_FOG_COORDINATE_ARRAY_EXT:
+ CHECK_EXTENSION_B(EXT_fog_coord, pname);
+ params[0] = ctx->Array.FogCoord.Enabled;
+ break;
+ case GL_FOG_COORDINATE_ARRAY_TYPE_EXT:
+ CHECK_EXTENSION_B(EXT_fog_coord, pname);
+ params[0] = ENUM_TO_BOOLEAN(ctx->Array.FogCoord.Type);
+ break;
+ case GL_FOG_COORDINATE_ARRAY_STRIDE_EXT:
+ CHECK_EXTENSION_B(EXT_fog_coord, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Array.FogCoord.Stride);
+ break;
+ case GL_FOG_COORDINATE_SOURCE_EXT:
+ CHECK_EXTENSION_B(EXT_fog_coord, pname);
+ params[0] = ENUM_TO_BOOLEAN(ctx->Fog.FogCoordinateSource);
+ break;
+ case GL_MAX_TEXTURE_LOD_BIAS_EXT:
+ CHECK_EXTENSION_B(EXT_texture_lod_bias, pname);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Const.MaxTextureLodBias);
+ break;
+ case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
+ CHECK_EXTENSION_B(EXT_texture_filter_anisotropic, pname);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Const.MaxTextureMaxAnisotropy);
+ break;
+ case GL_MULTISAMPLE_ARB:
+ CHECK_EXTENSION_B(ARB_multisample, pname);
+ params[0] = ctx->Multisample.Enabled;
+ break;
+ case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
+ CHECK_EXTENSION_B(ARB_multisample, pname);
+ params[0] = ctx->Multisample.SampleAlphaToCoverage;
+ break;
+ case GL_SAMPLE_ALPHA_TO_ONE_ARB:
+ CHECK_EXTENSION_B(ARB_multisample, pname);
+ params[0] = ctx->Multisample.SampleAlphaToOne;
+ break;
+ case GL_SAMPLE_COVERAGE_ARB:
+ CHECK_EXTENSION_B(ARB_multisample, pname);
+ params[0] = ctx->Multisample.SampleCoverage;
+ break;
+ case GL_SAMPLE_COVERAGE_VALUE_ARB:
+ CHECK_EXTENSION_B(ARB_multisample, pname);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Multisample.SampleCoverageValue);
+ break;
+ case GL_SAMPLE_COVERAGE_INVERT_ARB:
+ CHECK_EXTENSION_B(ARB_multisample, pname);
+ params[0] = ctx->Multisample.SampleCoverageInvert;
+ break;
+ case GL_SAMPLE_BUFFERS_ARB:
+ CHECK_EXTENSION_B(ARB_multisample, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.sampleBuffers);
+ break;
+ case GL_SAMPLES_ARB:
+ CHECK_EXTENSION_B(ARB_multisample, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Visual.samples);
+ break;
+ case GL_RASTER_POSITION_UNCLIPPED_IBM:
+ CHECK_EXTENSION_B(IBM_rasterpos_clip, pname);
+ params[0] = ctx->Transform.RasterPositionUnclipped;
+ break;
+ case GL_POINT_SPRITE_NV:
+ CHECK_EXTENSION_B(NV_point_sprite, pname);
+ params[0] = ctx->Point.PointSprite;
+ break;
+ case GL_POINT_SPRITE_R_MODE_NV:
+ CHECK_EXTENSION_B(NV_point_sprite, pname);
+ params[0] = ENUM_TO_BOOLEAN(ctx->Point.SpriteRMode);
+ break;
+ case GL_POINT_SPRITE_COORD_ORIGIN:
+ CHECK_EXTENSION_B(NV_point_sprite, pname);
+ params[0] = ENUM_TO_BOOLEAN(ctx->Point.SpriteOrigin);
+ break;
+ case GL_GENERATE_MIPMAP_HINT_SGIS:
+ CHECK_EXTENSION_B(SGIS_generate_mipmap, pname);
+ params[0] = ENUM_TO_BOOLEAN(ctx->Hint.GenerateMipmap);
+ break;
+ case GL_VERTEX_PROGRAM_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->VertexProgram.Enabled;
+ break;
+ case GL_VERTEX_PROGRAM_POINT_SIZE_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->VertexProgram.PointSizeEnabled;
+ break;
+ case GL_VERTEX_PROGRAM_TWO_SIDE_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->VertexProgram.TwoSideEnabled;
+ break;
+ case GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxProgramMatrixStackDepth);
+ break;
+ case GL_MAX_TRACK_MATRICES_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxProgramMatrices);
+ break;
+ case GL_CURRENT_MATRIX_STACK_DEPTH_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->CurrentStack->Depth + 1;
+ break;
+ case GL_CURRENT_MATRIX_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ {
+ const GLfloat *matrix = ctx->CurrentStack->Top->m;
+ params[0] = FLOAT_TO_BOOLEAN(matrix[0]);
+ params[1] = FLOAT_TO_BOOLEAN(matrix[1]);
+ params[2] = FLOAT_TO_BOOLEAN(matrix[2]);
+ params[3] = FLOAT_TO_BOOLEAN(matrix[3]);
+ params[4] = FLOAT_TO_BOOLEAN(matrix[4]);
+ params[5] = FLOAT_TO_BOOLEAN(matrix[5]);
+ params[6] = FLOAT_TO_BOOLEAN(matrix[6]);
+ params[7] = FLOAT_TO_BOOLEAN(matrix[7]);
+ params[8] = FLOAT_TO_BOOLEAN(matrix[8]);
+ params[9] = FLOAT_TO_BOOLEAN(matrix[9]);
+ params[10] = FLOAT_TO_BOOLEAN(matrix[10]);
+ params[11] = FLOAT_TO_BOOLEAN(matrix[11]);
+ params[12] = FLOAT_TO_BOOLEAN(matrix[12]);
+ params[13] = FLOAT_TO_BOOLEAN(matrix[13]);
+ params[14] = FLOAT_TO_BOOLEAN(matrix[14]);
+ params[15] = FLOAT_TO_BOOLEAN(matrix[15]);
+ }
+ break;
+ case GL_VERTEX_PROGRAM_BINDING_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = INT_TO_BOOLEAN((ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0));
+ break;
+ case GL_PROGRAM_ERROR_POSITION_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Program.ErrorPos);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY0_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Array.VertexAttrib[0].Enabled;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY1_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Array.VertexAttrib[1].Enabled;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY2_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Array.VertexAttrib[2].Enabled;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY3_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Array.VertexAttrib[3].Enabled;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY4_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Array.VertexAttrib[4].Enabled;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY5_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Array.VertexAttrib[5].Enabled;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY6_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Array.VertexAttrib[6].Enabled;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY7_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Array.VertexAttrib[7].Enabled;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY8_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Array.VertexAttrib[8].Enabled;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY9_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Array.VertexAttrib[9].Enabled;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY10_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Array.VertexAttrib[10].Enabled;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY11_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Array.VertexAttrib[11].Enabled;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY12_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Array.VertexAttrib[12].Enabled;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY13_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Array.VertexAttrib[13].Enabled;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY14_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Array.VertexAttrib[14].Enabled;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY15_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Array.VertexAttrib[15].Enabled;
+ break;
+ case GL_MAP1_VERTEX_ATTRIB0_4_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Eval.Map1Attrib[0];
+ break;
+ case GL_MAP1_VERTEX_ATTRIB1_4_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Eval.Map1Attrib[1];
+ break;
+ case GL_MAP1_VERTEX_ATTRIB2_4_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Eval.Map1Attrib[2];
+ break;
+ case GL_MAP1_VERTEX_ATTRIB3_4_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Eval.Map1Attrib[3];
+ break;
+ case GL_MAP1_VERTEX_ATTRIB4_4_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Eval.Map1Attrib[4];
+ break;
+ case GL_MAP1_VERTEX_ATTRIB5_4_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Eval.Map1Attrib[5];
+ break;
+ case GL_MAP1_VERTEX_ATTRIB6_4_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Eval.Map1Attrib[6];
+ break;
+ case GL_MAP1_VERTEX_ATTRIB7_4_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Eval.Map1Attrib[7];
+ break;
+ case GL_MAP1_VERTEX_ATTRIB8_4_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Eval.Map1Attrib[8];
+ break;
+ case GL_MAP1_VERTEX_ATTRIB9_4_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Eval.Map1Attrib[9];
+ break;
+ case GL_MAP1_VERTEX_ATTRIB10_4_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Eval.Map1Attrib[10];
+ break;
+ case GL_MAP1_VERTEX_ATTRIB11_4_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Eval.Map1Attrib[11];
+ break;
+ case GL_MAP1_VERTEX_ATTRIB12_4_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Eval.Map1Attrib[12];
+ break;
+ case GL_MAP1_VERTEX_ATTRIB13_4_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Eval.Map1Attrib[13];
+ break;
+ case GL_MAP1_VERTEX_ATTRIB14_4_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Eval.Map1Attrib[14];
+ break;
+ case GL_MAP1_VERTEX_ATTRIB15_4_NV:
+ CHECK_EXTENSION_B(NV_vertex_program, pname);
+ params[0] = ctx->Eval.Map1Attrib[15];
+ break;
+ case GL_FRAGMENT_PROGRAM_NV:
+ CHECK_EXTENSION_B(NV_fragment_program, pname);
+ params[0] = ctx->FragmentProgram.Enabled;
+ break;
+ case GL_MAX_TEXTURE_COORDS_NV:
+ CHECK_EXTENSION_B(NV_fragment_program, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTextureCoordUnits);
+ break;
+ case GL_MAX_TEXTURE_IMAGE_UNITS_NV:
+ CHECK_EXTENSION_B(NV_fragment_program, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTextureImageUnits);
+ break;
+ case GL_FRAGMENT_PROGRAM_BINDING_NV:
+ CHECK_EXTENSION_B(NV_fragment_program, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0);
+ break;
+ case GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV:
+ CHECK_EXTENSION_B(NV_fragment_program, pname);
+ params[0] = INT_TO_BOOLEAN(MAX_NV_FRAGMENT_PROGRAM_PARAMS);
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ CHECK_EXTENSION_B(NV_texture_rectangle, pname);
+ params[0] = _mesa_IsEnabled(GL_TEXTURE_RECTANGLE_NV);
+ break;
+ case GL_TEXTURE_BINDING_RECTANGLE_NV:
+ CHECK_EXTENSION_B(NV_texture_rectangle, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentRect->Name);
+ break;
+ case GL_MAX_RECTANGLE_TEXTURE_SIZE_NV:
+ CHECK_EXTENSION_B(NV_texture_rectangle, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxTextureRectSize);
+ break;
+ case GL_STENCIL_TEST_TWO_SIDE_EXT:
+ CHECK_EXTENSION_B(EXT_stencil_two_side, pname);
+ params[0] = ctx->Stencil.TestTwoSide;
+ break;
+ case GL_ACTIVE_STENCIL_FACE_EXT:
+ CHECK_EXTENSION_B(EXT_stencil_two_side, pname);
+ params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT);
+ break;
+ case GL_MAX_SHININESS_NV:
+ CHECK_EXTENSION_B(NV_light_max_exponent, pname);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Const.MaxShininess);
+ break;
+ case GL_MAX_SPOT_EXPONENT_NV:
+ CHECK_EXTENSION_B(NV_light_max_exponent, pname);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Const.MaxSpotExponent);
+ break;
+ case GL_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Array.ArrayBufferObj->Name);
+ break;
+ case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Array.Vertex.BufferObj->Name);
+ break;
+ case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Array.Normal.BufferObj->Name);
+ break;
+ case GL_COLOR_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Array.Color.BufferObj->Name);
+ break;
+ case GL_INDEX_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Array.Index.BufferObj->Name);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Array.TexCoord[ctx->Array.ActiveTexture].BufferObj->Name);
+ break;
+ case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Array.EdgeFlag.BufferObj->Name);
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Array.SecondaryColor.BufferObj->Name);
+ break;
+ case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Array.FogCoord.BufferObj->Name);
+ break;
+ case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_B(ARB_vertex_buffer_object, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Array.ElementArrayBufferObj->Name);
+ break;
+ case GL_PIXEL_PACK_BUFFER_BINDING_EXT:
+ CHECK_EXTENSION_B(EXT_pixel_buffer_object, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Pack.BufferObj->Name);
+ break;
+ case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT:
+ CHECK_EXTENSION_B(EXT_pixel_buffer_object, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Unpack.BufferObj->Name);
+ break;
+ case GL_MAX_VERTEX_ATTRIBS_ARB:
+ CHECK_EXTENSION_B(ARB_vertex_program, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxVertexProgramAttribs);
+ break;
+ case GL_FRAGMENT_PROGRAM_ARB:
+ CHECK_EXTENSION_B(ARB_fragment_program, pname);
+ params[0] = ctx->FragmentProgram.Enabled;
+ break;
+ case GL_TRANSPOSE_CURRENT_MATRIX_ARB:
+ CHECK_EXTENSION_B(ARB_fragment_program, pname);
+ {
+ const GLfloat *matrix = ctx->CurrentStack->Top->m;
+ params[0] = FLOAT_TO_BOOLEAN(matrix[0]);
+ params[1] = FLOAT_TO_BOOLEAN(matrix[4]);
+ params[2] = FLOAT_TO_BOOLEAN(matrix[8]);
+ params[3] = FLOAT_TO_BOOLEAN(matrix[12]);
+ params[4] = FLOAT_TO_BOOLEAN(matrix[1]);
+ params[5] = FLOAT_TO_BOOLEAN(matrix[5]);
+ params[6] = FLOAT_TO_BOOLEAN(matrix[9]);
+ params[7] = FLOAT_TO_BOOLEAN(matrix[13]);
+ params[8] = FLOAT_TO_BOOLEAN(matrix[2]);
+ params[9] = FLOAT_TO_BOOLEAN(matrix[6]);
+ params[10] = FLOAT_TO_BOOLEAN(matrix[10]);
+ params[11] = FLOAT_TO_BOOLEAN(matrix[14]);
+ params[12] = FLOAT_TO_BOOLEAN(matrix[3]);
+ params[13] = FLOAT_TO_BOOLEAN(matrix[7]);
+ params[14] = FLOAT_TO_BOOLEAN(matrix[11]);
+ params[15] = FLOAT_TO_BOOLEAN(matrix[15]);
+ }
+ break;
+ case GL_DEPTH_BOUNDS_TEST_EXT:
+ CHECK_EXTENSION_B(EXT_depth_bounds_test, pname);
+ params[0] = ctx->Depth.BoundsTest;
+ break;
+ case GL_DEPTH_BOUNDS_EXT:
+ CHECK_EXTENSION_B(EXT_depth_bounds_test, pname);
+ params[0] = FLOAT_TO_BOOLEAN(ctx->Depth.BoundsMin);
+ params[1] = FLOAT_TO_BOOLEAN(ctx->Depth.BoundsMax);
+ break;
+ case GL_FRAGMENT_PROGRAM_CALLBACK_MESA:
+ CHECK_EXTENSION_B(MESA_program_debug, pname);
+ params[0] = ctx->FragmentProgram.CallbackEnabled;
+ break;
+ case GL_VERTEX_PROGRAM_CALLBACK_MESA:
+ CHECK_EXTENSION_B(MESA_program_debug, pname);
+ params[0] = ctx->VertexProgram.CallbackEnabled;
+ break;
+ case GL_FRAGMENT_PROGRAM_POSITION_MESA:
+ CHECK_EXTENSION_B(MESA_program_debug, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->FragmentProgram.CurrentPosition);
+ break;
+ case GL_VERTEX_PROGRAM_POSITION_MESA:
+ CHECK_EXTENSION_B(MESA_program_debug, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->VertexProgram.CurrentPosition);
+ break;
+ case GL_MAX_DRAW_BUFFERS_ARB:
+ CHECK_EXTENSION_B(ARB_draw_buffers, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxDrawBuffers);
+ break;
+ case GL_DRAW_BUFFER0_ARB:
+ CHECK_EXTENSION_B(ARB_draw_buffers, pname);
+ params[0] = ENUM_TO_BOOLEAN(ctx->Color.DrawBuffer[0]);
+ break;
+ case GL_DRAW_BUFFER1_ARB:
+ CHECK_EXTENSION_B(ARB_draw_buffers, pname);
+ {
+ GLenum buffer;
+ if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)");
+ return;
+ }
+ buffer = ctx->Color.DrawBuffer[1];
+ params[0] = ENUM_TO_BOOLEAN(buffer);
+ }
+ break;
+ case GL_DRAW_BUFFER2_ARB:
+ CHECK_EXTENSION_B(ARB_draw_buffers, pname);
+ {
+ GLenum buffer;
+ if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)");
+ return;
+ }
+ buffer = ctx->Color.DrawBuffer[2];
+ params[0] = ENUM_TO_BOOLEAN(buffer);
+ }
+ break;
+ case GL_DRAW_BUFFER3_ARB:
+ CHECK_EXTENSION_B(ARB_draw_buffers, pname);
+ {
+ GLenum buffer;
+ if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)");
+ return;
+ }
+ buffer = ctx->Color.DrawBuffer[3];
+ params[0] = ENUM_TO_BOOLEAN(buffer);
+ }
+ break;
+ case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
+ CHECK_EXTENSION_B(OES_read_format, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Const.ColorReadType);
+ break;
+ case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
+ CHECK_EXTENSION_B(OES_read_format, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Const.ColorReadFormat);
+ break;
+ case GL_NUM_FRAGMENT_REGISTERS_ATI:
+ CHECK_EXTENSION_B(ATI_fragment_shader, pname);
+ params[0] = INT_TO_BOOLEAN(6);
+ break;
+ case GL_NUM_FRAGMENT_CONSTANTS_ATI:
+ CHECK_EXTENSION_B(ATI_fragment_shader, pname);
+ params[0] = INT_TO_BOOLEAN(8);
+ break;
+ case GL_NUM_PASSES_ATI:
+ CHECK_EXTENSION_B(ATI_fragment_shader, pname);
+ params[0] = INT_TO_BOOLEAN(2);
+ break;
+ case GL_NUM_INSTRUCTIONS_PER_PASS_ATI:
+ CHECK_EXTENSION_B(ATI_fragment_shader, pname);
+ params[0] = INT_TO_BOOLEAN(8);
+ break;
+ case GL_NUM_INSTRUCTIONS_TOTAL_ATI:
+ CHECK_EXTENSION_B(ATI_fragment_shader, pname);
+ params[0] = INT_TO_BOOLEAN(16);
+ break;
+ case GL_COLOR_ALPHA_PAIRING_ATI:
+ CHECK_EXTENSION_B(ATI_fragment_shader, pname);
+ params[0] = GL_TRUE;
+ break;
+ case GL_NUM_LOOPBACK_COMPONENTS_ATI:
+ CHECK_EXTENSION_B(ATI_fragment_shader, pname);
+ params[0] = INT_TO_BOOLEAN(3);
+ break;
+ case GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI:
+ CHECK_EXTENSION_B(ATI_fragment_shader, pname);
+ params[0] = INT_TO_BOOLEAN(3);
+ break;
+ case GL_STENCIL_BACK_FUNC:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.Function[1]);
+ break;
+ case GL_STENCIL_BACK_VALUE_MASK:
+ params[0] = INT_TO_BOOLEAN(ctx->Stencil.ValueMask[1]);
+ break;
+ case GL_STENCIL_BACK_REF:
+ params[0] = INT_TO_BOOLEAN(ctx->Stencil.Ref[1]);
+ break;
+ case GL_STENCIL_BACK_FAIL:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.FailFunc[1]);
+ break;
+ case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.ZFailFunc[1]);
+ break;
+ case GL_STENCIL_BACK_PASS_DEPTH_PASS:
+ params[0] = ENUM_TO_BOOLEAN(ctx->Stencil.ZPassFunc[1]);
+ break;
+ case GL_FRAMEBUFFER_BINDING_EXT:
+ CHECK_EXTENSION_B(EXT_framebuffer_object, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->DrawBuffer->Name);
+ break;
+ case GL_RENDERBUFFER_BINDING_EXT:
+ CHECK_EXTENSION_B(EXT_framebuffer_object, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0);
+ break;
+ case GL_MAX_COLOR_ATTACHMENTS_EXT:
+ CHECK_EXTENSION_B(EXT_framebuffer_object, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxColorAttachments);
+ break;
+ case GL_MAX_RENDERBUFFER_SIZE_EXT:
+ CHECK_EXTENSION_B(EXT_framebuffer_object, pname);
+ params[0] = INT_TO_BOOLEAN(ctx->Const.MaxRenderbufferSize);
+ break;
+ case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB:
+ CHECK_EXTENSION_B(ARB_fragment_shader, pname);
+ params[0] = INT_TO_BOOLEAN(MAX_FRAGMENT_UNIFORM_COMPONENTS);
+ break;
+ case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB:
+ CHECK_EXTENSION_B(ARB_fragment_shader, pname);
+ params[0] = ENUM_TO_BOOLEAN(ctx->Hint.FragmentShaderDerivative);
+ break;
+ case GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB:
+ CHECK_EXTENSION_B(ARB_vertex_shader, pname);
+ params[0] = INT_TO_BOOLEAN(MAX_VERTEX_UNIFORM_COMPONENTS);
+ break;
+ case GL_MAX_VARYING_FLOATS_ARB:
+ CHECK_EXTENSION_B(ARB_vertex_shader, pname);
+ params[0] = INT_TO_BOOLEAN(MAX_VARYING_FLOATS);
+ break;
+ case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB:
+ CHECK_EXTENSION_B(ARB_vertex_shader, pname);
+ params[0] = INT_TO_BOOLEAN(MAX_VERTEX_TEXTURE_IMAGE_UNITS);
+ break;
+ case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB:
+ CHECK_EXTENSION_B(ARB_vertex_shader, pname);
+ params[0] = INT_TO_BOOLEAN(MAX_COMBINED_TEXTURE_IMAGE_UNITS);
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetBooleanv(pname=0x%x)", pname);
+ }
+}
+
+void GLAPIENTRY
+_mesa_GetFloatv( GLenum pname, GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!params)
+ return;
+
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ if (ctx->Driver.GetFloatv &&
+ ctx->Driver.GetFloatv(ctx, pname, params))
+ return;
+
+ switch (pname) {
+ case GL_ACCUM_RED_BITS:
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.accumRedBits);
+ break;
+ case GL_ACCUM_GREEN_BITS:
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.accumGreenBits);
+ break;
+ case GL_ACCUM_BLUE_BITS:
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.accumBlueBits);
+ break;
+ case GL_ACCUM_ALPHA_BITS:
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.accumAlphaBits);
+ break;
+ case GL_ACCUM_CLEAR_VALUE:
+ params[0] = ctx->Accum.ClearColor[0];
+ params[1] = ctx->Accum.ClearColor[1];
+ params[2] = ctx->Accum.ClearColor[2];
+ params[3] = ctx->Accum.ClearColor[3];
+ break;
+ case GL_ALPHA_BIAS:
+ params[0] = ctx->Pixel.AlphaBias;
+ break;
+ case GL_ALPHA_BITS:
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.alphaBits);
+ break;
+ case GL_ALPHA_SCALE:
+ params[0] = ctx->Pixel.AlphaScale;
+ break;
+ case GL_ALPHA_TEST:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Color.AlphaEnabled);
+ break;
+ case GL_ALPHA_TEST_FUNC:
+ params[0] = ENUM_TO_FLOAT(ctx->Color.AlphaFunc);
+ break;
+ case GL_ALPHA_TEST_REF:
+ params[0] = ctx->Color.AlphaRef;
+ break;
+ case GL_ATTRIB_STACK_DEPTH:
+ params[0] = (GLfloat)(ctx->AttribStackDepth);
+ break;
+ case GL_AUTO_NORMAL:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.AutoNormal);
+ break;
+ case GL_AUX_BUFFERS:
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.numAuxBuffers);
+ break;
+ case GL_BLEND:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Color.BlendEnabled);
+ break;
+ case GL_BLEND_DST:
+ params[0] = ENUM_TO_FLOAT(ctx->Color.BlendDstRGB);
+ break;
+ case GL_BLEND_SRC:
+ params[0] = ENUM_TO_FLOAT(ctx->Color.BlendSrcRGB);
+ break;
+ case GL_BLEND_SRC_RGB_EXT:
+ params[0] = ENUM_TO_FLOAT(ctx->Color.BlendSrcRGB);
+ break;
+ case GL_BLEND_DST_RGB_EXT:
+ params[0] = ENUM_TO_FLOAT(ctx->Color.BlendDstRGB);
+ break;
+ case GL_BLEND_SRC_ALPHA_EXT:
+ params[0] = ENUM_TO_FLOAT(ctx->Color.BlendSrcA);
+ break;
+ case GL_BLEND_DST_ALPHA_EXT:
+ params[0] = ENUM_TO_FLOAT(ctx->Color.BlendDstA);
+ break;
+ case GL_BLEND_EQUATION:
+ params[0] = ENUM_TO_FLOAT(ctx->Color.BlendEquationRGB );
+ break;
+ case GL_BLEND_EQUATION_ALPHA_EXT:
+ params[0] = ENUM_TO_FLOAT(ctx->Color.BlendEquationA );
+ break;
+ case GL_BLEND_COLOR_EXT:
+ params[0] = ctx->Color.BlendColor[0];
+ params[1] = ctx->Color.BlendColor[1];
+ params[2] = ctx->Color.BlendColor[2];
+ params[3] = ctx->Color.BlendColor[3];
+ break;
+ case GL_BLUE_BIAS:
+ params[0] = ctx->Pixel.BlueBias;
+ break;
+ case GL_BLUE_BITS:
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.blueBits);
+ break;
+ case GL_BLUE_SCALE:
+ params[0] = ctx->Pixel.BlueScale;
+ break;
+ case GL_CLIENT_ATTRIB_STACK_DEPTH:
+ params[0] = (GLfloat)(ctx->ClientAttribStackDepth);
+ break;
+ case GL_CLIP_PLANE0:
+ params[0] = BOOLEAN_TO_FLOAT((ctx->Transform.ClipPlanesEnabled >> 0) & 1);
+ break;
+ case GL_CLIP_PLANE1:
+ params[0] = BOOLEAN_TO_FLOAT((ctx->Transform.ClipPlanesEnabled >> 1) & 1);
+ break;
+ case GL_CLIP_PLANE2:
+ params[0] = BOOLEAN_TO_FLOAT((ctx->Transform.ClipPlanesEnabled >> 2) & 1);
+ break;
+ case GL_CLIP_PLANE3:
+ params[0] = BOOLEAN_TO_FLOAT((ctx->Transform.ClipPlanesEnabled >> 3) & 1);
+ break;
+ case GL_CLIP_PLANE4:
+ params[0] = BOOLEAN_TO_FLOAT((ctx->Transform.ClipPlanesEnabled >> 4) & 1);
+ break;
+ case GL_CLIP_PLANE5:
+ params[0] = BOOLEAN_TO_FLOAT((ctx->Transform.ClipPlanesEnabled >> 5) & 1);
+ break;
+ case GL_COLOR_CLEAR_VALUE:
+ params[0] = ctx->Color.ClearColor[0];
+ params[1] = ctx->Color.ClearColor[1];
+ params[2] = ctx->Color.ClearColor[2];
+ params[3] = ctx->Color.ClearColor[3];
+ break;
+ case GL_COLOR_MATERIAL:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Light.ColorMaterialEnabled);
+ break;
+ case GL_COLOR_MATERIAL_FACE:
+ params[0] = ENUM_TO_FLOAT(ctx->Light.ColorMaterialFace);
+ break;
+ case GL_COLOR_MATERIAL_PARAMETER:
+ params[0] = ENUM_TO_FLOAT(ctx->Light.ColorMaterialMode);
+ break;
+ case GL_COLOR_WRITEMASK:
+ params[0] = (GLfloat)(ctx->Color.ColorMask[RCOMP] ? 1 : 0);
+ params[1] = (GLfloat)(ctx->Color.ColorMask[GCOMP] ? 1 : 0);
+ params[2] = (GLfloat)(ctx->Color.ColorMask[BCOMP] ? 1 : 0);
+ params[3] = (GLfloat)(ctx->Color.ColorMask[ACOMP] ? 1 : 0);
+ break;
+ case GL_CULL_FACE:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.CullFlag);
+ break;
+ case GL_CULL_FACE_MODE:
+ params[0] = ENUM_TO_FLOAT(ctx->Polygon.CullFaceMode);
+ break;
+ case GL_CURRENT_COLOR:
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0];
+ params[1] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1];
+ params[2] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2];
+ params[3] = ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3];
+ }
+ break;
+ case GL_CURRENT_INDEX:
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = ctx->Current.Index;
+ }
+ break;
+ case GL_CURRENT_NORMAL:
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0];
+ params[1] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1];
+ params[2] = ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2];
+ }
+ break;
+ case GL_CURRENT_RASTER_COLOR:
+ params[0] = ctx->Current.RasterColor[0];
+ params[1] = ctx->Current.RasterColor[1];
+ params[2] = ctx->Current.RasterColor[2];
+ params[3] = ctx->Current.RasterColor[3];
+ break;
+ case GL_CURRENT_RASTER_DISTANCE:
+ params[0] = ctx->Current.RasterDistance;
+ break;
+ case GL_CURRENT_RASTER_INDEX:
+ params[0] = ctx->Current.RasterIndex;
+ break;
+ case GL_CURRENT_RASTER_POSITION:
+ params[0] = ctx->Current.RasterPos[0];
+ params[1] = ctx->Current.RasterPos[1];
+ params[2] = ctx->Current.RasterPos[2];
+ params[3] = ctx->Current.RasterPos[3];
+ break;
+ case GL_CURRENT_RASTER_TEXTURE_COORDS:
+ {
+ const GLuint texUnit = ctx->Texture.CurrentUnit;
+ params[0] = ctx->Current.RasterTexCoords[texUnit][0];
+ params[1] = ctx->Current.RasterTexCoords[texUnit][1];
+ params[2] = ctx->Current.RasterTexCoords[texUnit][2];
+ params[3] = ctx->Current.RasterTexCoords[texUnit][3];
+ }
+ break;
+ case GL_CURRENT_RASTER_POSITION_VALID:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Current.RasterPosValid);
+ break;
+ case GL_CURRENT_TEXTURE_COORDS:
+ {
+ const GLuint texUnit = ctx->Texture.CurrentUnit;
+ params[0] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][0];
+ params[1] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][1];
+ params[2] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][2];
+ params[3] = ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][3];
+ }
+ break;
+ case GL_DEPTH_BIAS:
+ params[0] = ctx->Pixel.DepthBias;
+ break;
+ case GL_DEPTH_BITS:
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.depthBits);
+ break;
+ case GL_DEPTH_CLEAR_VALUE:
+ params[0] = ctx->Depth.Clear;
+ break;
+ case GL_DEPTH_FUNC:
+ params[0] = ENUM_TO_FLOAT(ctx->Depth.Func);
+ break;
+ case GL_DEPTH_RANGE:
+ params[0] = ctx->Viewport.Near;
+ params[1] = ctx->Viewport.Far;
+ break;
+ case GL_DEPTH_SCALE:
+ params[0] = ctx->Pixel.DepthScale;
+ break;
+ case GL_DEPTH_TEST:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Depth.Test);
+ break;
+ case GL_DEPTH_WRITEMASK:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Depth.Mask);
+ break;
+ case GL_DITHER:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Color.DitherFlag);
+ break;
+ case GL_DOUBLEBUFFER:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->DrawBuffer->Visual.doubleBufferMode);
+ break;
+ case GL_DRAW_BUFFER:
+ params[0] = ENUM_TO_FLOAT(ctx->Color.DrawBuffer[0]);
+ break;
+ case GL_EDGE_FLAG:
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Current.EdgeFlag);
+ }
+ break;
+ case GL_FEEDBACK_BUFFER_SIZE:
+ params[0] = (GLfloat)(ctx->Feedback.BufferSize);
+ break;
+ case GL_FEEDBACK_BUFFER_TYPE:
+ params[0] = ENUM_TO_FLOAT(ctx->Feedback.Type);
+ break;
+ case GL_FOG:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Fog.Enabled);
+ break;
+ case GL_FOG_COLOR:
+ params[0] = ctx->Fog.Color[0];
+ params[1] = ctx->Fog.Color[1];
+ params[2] = ctx->Fog.Color[2];
+ params[3] = ctx->Fog.Color[3];
+ break;
+ case GL_FOG_DENSITY:
+ params[0] = ctx->Fog.Density;
+ break;
+ case GL_FOG_END:
+ params[0] = ctx->Fog.End;
+ break;
+ case GL_FOG_HINT:
+ params[0] = ENUM_TO_FLOAT(ctx->Hint.Fog);
+ break;
+ case GL_FOG_INDEX:
+ params[0] = ctx->Fog.Index;
+ break;
+ case GL_FOG_MODE:
+ params[0] = ENUM_TO_FLOAT(ctx->Fog.Mode);
+ break;
+ case GL_FOG_START:
+ params[0] = ctx->Fog.Start;
+ break;
+ case GL_FRONT_FACE:
+ params[0] = ENUM_TO_FLOAT(ctx->Polygon.FrontFace);
+ break;
+ case GL_GREEN_BIAS:
+ params[0] = ctx->Pixel.GreenBias;
+ break;
+ case GL_GREEN_BITS:
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.greenBits);
+ break;
+ case GL_GREEN_SCALE:
+ params[0] = ctx->Pixel.GreenScale;
+ break;
+ case GL_INDEX_BITS:
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.indexBits);
+ break;
+ case GL_INDEX_CLEAR_VALUE:
+ params[0] = (GLfloat)(ctx->Color.ClearIndex);
+ break;
+ case GL_INDEX_MODE:
+ params[0] = BOOLEAN_TO_FLOAT(!ctx->DrawBuffer->Visual.rgbMode);
+ break;
+ case GL_INDEX_OFFSET:
+ params[0] = (GLfloat)(ctx->Pixel.IndexOffset);
+ break;
+ case GL_INDEX_SHIFT:
+ params[0] = (GLfloat)(ctx->Pixel.IndexShift);
+ break;
+ case GL_INDEX_WRITEMASK:
+ params[0] = (GLfloat)(ctx->Color.IndexMask);
+ break;
+ case GL_LIGHT0:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Light[0].Enabled);
+ break;
+ case GL_LIGHT1:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Light[1].Enabled);
+ break;
+ case GL_LIGHT2:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Light[2].Enabled);
+ break;
+ case GL_LIGHT3:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Light[3].Enabled);
+ break;
+ case GL_LIGHT4:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Light[4].Enabled);
+ break;
+ case GL_LIGHT5:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Light[5].Enabled);
+ break;
+ case GL_LIGHT6:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Light[6].Enabled);
+ break;
+ case GL_LIGHT7:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Light[7].Enabled);
+ break;
+ case GL_LIGHTING:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Enabled);
+ break;
+ case GL_LIGHT_MODEL_AMBIENT:
+ params[0] = ctx->Light.Model.Ambient[0];
+ params[1] = ctx->Light.Model.Ambient[1];
+ params[2] = ctx->Light.Model.Ambient[2];
+ params[3] = ctx->Light.Model.Ambient[3];
+ break;
+ case GL_LIGHT_MODEL_COLOR_CONTROL:
+ params[0] = ENUM_TO_FLOAT(ctx->Light.Model.ColorControl);
+ break;
+ case GL_LIGHT_MODEL_LOCAL_VIEWER:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Model.LocalViewer);
+ break;
+ case GL_LIGHT_MODEL_TWO_SIDE:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Light.Model.TwoSide);
+ break;
+ case GL_LINE_SMOOTH:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Line.SmoothFlag);
+ break;
+ case GL_LINE_SMOOTH_HINT:
+ params[0] = ENUM_TO_FLOAT(ctx->Hint.LineSmooth);
+ break;
+ case GL_LINE_STIPPLE:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Line.StippleFlag);
+ break;
+ case GL_LINE_STIPPLE_PATTERN:
+ params[0] = (GLfloat)(ctx->Line.StipplePattern);
+ break;
+ case GL_LINE_STIPPLE_REPEAT:
+ params[0] = (GLfloat)(ctx->Line.StippleFactor);
+ break;
+ case GL_LINE_WIDTH:
+ params[0] = ctx->Line.Width;
+ break;
+ case GL_LINE_WIDTH_GRANULARITY:
+ params[0] = ctx->Const.LineWidthGranularity;
+ break;
+ case GL_LINE_WIDTH_RANGE:
+ params[0] = ctx->Const.MinLineWidthAA;
+ params[1] = ctx->Const.MaxLineWidthAA;
+ break;
+ case GL_ALIASED_LINE_WIDTH_RANGE:
+ params[0] = ctx->Const.MinLineWidth;
+ params[1] = ctx->Const.MaxLineWidth;
+ break;
+ case GL_LIST_BASE:
+ params[0] = (GLfloat)(ctx->List.ListBase);
+ break;
+ case GL_LIST_INDEX:
+ params[0] = (GLfloat)(ctx->ListState.CurrentListNum);
+ break;
+ case GL_LIST_MODE:
+ {
+ GLenum mode;
+ if (!ctx->CompileFlag)
+ mode = 0;
+ else if (ctx->ExecuteFlag)
+ mode = GL_COMPILE_AND_EXECUTE;
+ else
+ mode = GL_COMPILE;
+ params[0] = ENUM_TO_FLOAT(mode);
+ }
+ break;
+ case GL_INDEX_LOGIC_OP:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Color.IndexLogicOpEnabled);
+ break;
+ case GL_COLOR_LOGIC_OP:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Color.ColorLogicOpEnabled);
+ break;
+ case GL_LOGIC_OP_MODE:
+ params[0] = ENUM_TO_FLOAT(ctx->Color.LogicOp);
+ break;
+ case GL_MAP1_COLOR_4:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Color4);
+ break;
+ case GL_MAP1_GRID_DOMAIN:
+ params[0] = ctx->Eval.MapGrid1u1;
+ params[1] = ctx->Eval.MapGrid1u2;
+ break;
+ case GL_MAP1_GRID_SEGMENTS:
+ params[0] = (GLfloat)(ctx->Eval.MapGrid1un);
+ break;
+ case GL_MAP1_INDEX:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Index);
+ break;
+ case GL_MAP1_NORMAL:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Normal);
+ break;
+ case GL_MAP1_TEXTURE_COORD_1:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1TextureCoord1);
+ break;
+ case GL_MAP1_TEXTURE_COORD_2:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1TextureCoord2);
+ break;
+ case GL_MAP1_TEXTURE_COORD_3:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1TextureCoord3);
+ break;
+ case GL_MAP1_TEXTURE_COORD_4:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1TextureCoord4);
+ break;
+ case GL_MAP1_VERTEX_3:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Vertex3);
+ break;
+ case GL_MAP1_VERTEX_4:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Vertex4);
+ break;
+ case GL_MAP2_COLOR_4:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2Color4);
+ break;
+ case GL_MAP2_GRID_DOMAIN:
+ params[0] = ctx->Eval.MapGrid2u1;
+ params[1] = ctx->Eval.MapGrid2u2;
+ params[2] = ctx->Eval.MapGrid2v1;
+ params[3] = ctx->Eval.MapGrid2v2;
+ break;
+ case GL_MAP2_GRID_SEGMENTS:
+ params[0] = (GLfloat)(ctx->Eval.MapGrid2un);
+ params[1] = (GLfloat)(ctx->Eval.MapGrid2vn);
+ break;
+ case GL_MAP2_INDEX:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2Index);
+ break;
+ case GL_MAP2_NORMAL:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2Normal);
+ break;
+ case GL_MAP2_TEXTURE_COORD_1:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2TextureCoord1);
+ break;
+ case GL_MAP2_TEXTURE_COORD_2:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2TextureCoord2);
+ break;
+ case GL_MAP2_TEXTURE_COORD_3:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2TextureCoord3);
+ break;
+ case GL_MAP2_TEXTURE_COORD_4:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2TextureCoord4);
+ break;
+ case GL_MAP2_VERTEX_3:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2Vertex3);
+ break;
+ case GL_MAP2_VERTEX_4:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map2Vertex4);
+ break;
+ case GL_MAP_COLOR:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.MapColorFlag);
+ break;
+ case GL_MAP_STENCIL:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.MapStencilFlag);
+ break;
+ case GL_MATRIX_MODE:
+ params[0] = ENUM_TO_FLOAT(ctx->Transform.MatrixMode);
+ break;
+ case GL_MAX_ATTRIB_STACK_DEPTH:
+ params[0] = (GLfloat)(MAX_ATTRIB_STACK_DEPTH);
+ break;
+ case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
+ params[0] = (GLfloat)(MAX_CLIENT_ATTRIB_STACK_DEPTH);
+ break;
+ case GL_MAX_CLIP_PLANES:
+ params[0] = (GLfloat)(ctx->Const.MaxClipPlanes);
+ break;
+ case GL_MAX_ELEMENTS_VERTICES:
+ params[0] = (GLfloat)(ctx->Const.MaxArrayLockSize);
+ break;
+ case GL_MAX_ELEMENTS_INDICES:
+ params[0] = (GLfloat)(ctx->Const.MaxArrayLockSize);
+ break;
+ case GL_MAX_EVAL_ORDER:
+ params[0] = (GLfloat)(MAX_EVAL_ORDER);
+ break;
+ case GL_MAX_LIGHTS:
+ params[0] = (GLfloat)(ctx->Const.MaxLights);
+ break;
+ case GL_MAX_LIST_NESTING:
+ params[0] = (GLfloat)(MAX_LIST_NESTING);
+ break;
+ case GL_MAX_MODELVIEW_STACK_DEPTH:
+ params[0] = (GLfloat)(MAX_MODELVIEW_STACK_DEPTH);
+ break;
+ case GL_MAX_NAME_STACK_DEPTH:
+ params[0] = (GLfloat)(MAX_NAME_STACK_DEPTH);
+ break;
+ case GL_MAX_PIXEL_MAP_TABLE:
+ params[0] = (GLfloat)(MAX_PIXEL_MAP_TABLE);
+ break;
+ case GL_MAX_PROJECTION_STACK_DEPTH:
+ params[0] = (GLfloat)(MAX_PROJECTION_STACK_DEPTH);
+ break;
+ case GL_MAX_TEXTURE_SIZE:
+ params[0] = (GLfloat)(1 << (ctx->Const.MaxTextureLevels - 1));
+ break;
+ case GL_MAX_3D_TEXTURE_SIZE:
+ params[0] = (GLfloat)(1 << (ctx->Const.Max3DTextureLevels - 1));
+ break;
+ case GL_MAX_TEXTURE_STACK_DEPTH:
+ params[0] = (GLfloat)(MAX_TEXTURE_STACK_DEPTH);
+ break;
+ case GL_MAX_VIEWPORT_DIMS:
+ params[0] = (GLfloat)(ctx->Const.MaxViewportWidth);
+ params[1] = (GLfloat)(ctx->Const.MaxViewportHeight);
+ break;
+ case GL_MODELVIEW_MATRIX:
+ {
+ const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;
+ params[0] = matrix[0];
+ params[1] = matrix[1];
+ params[2] = matrix[2];
+ params[3] = matrix[3];
+ params[4] = matrix[4];
+ params[5] = matrix[5];
+ params[6] = matrix[6];
+ params[7] = matrix[7];
+ params[8] = matrix[8];
+ params[9] = matrix[9];
+ params[10] = matrix[10];
+ params[11] = matrix[11];
+ params[12] = matrix[12];
+ params[13] = matrix[13];
+ params[14] = matrix[14];
+ params[15] = matrix[15];
+ }
+ break;
+ case GL_MODELVIEW_STACK_DEPTH:
+ params[0] = (GLfloat)(ctx->ModelviewMatrixStack.Depth + 1);
+ break;
+ case GL_NAME_STACK_DEPTH:
+ params[0] = (GLfloat)(ctx->Select.NameStackDepth);
+ break;
+ case GL_NORMALIZE:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Transform.Normalize);
+ break;
+ case GL_PACK_ALIGNMENT:
+ params[0] = (GLfloat)(ctx->Pack.Alignment);
+ break;
+ case GL_PACK_LSB_FIRST:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Pack.LsbFirst);
+ break;
+ case GL_PACK_ROW_LENGTH:
+ params[0] = (GLfloat)(ctx->Pack.RowLength);
+ break;
+ case GL_PACK_SKIP_PIXELS:
+ params[0] = (GLfloat)(ctx->Pack.SkipPixels);
+ break;
+ case GL_PACK_SKIP_ROWS:
+ params[0] = (GLfloat)(ctx->Pack.SkipRows);
+ break;
+ case GL_PACK_SWAP_BYTES:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Pack.SwapBytes);
+ break;
+ case GL_PACK_SKIP_IMAGES_EXT:
+ params[0] = (GLfloat)(ctx->Pack.SkipImages);
+ break;
+ case GL_PACK_IMAGE_HEIGHT_EXT:
+ params[0] = (GLfloat)(ctx->Pack.ImageHeight);
+ break;
+ case GL_PACK_INVERT_MESA:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Pack.Invert);
+ break;
+ case GL_PERSPECTIVE_CORRECTION_HINT:
+ params[0] = ENUM_TO_FLOAT(ctx->Hint.PerspectiveCorrection);
+ break;
+ case GL_PIXEL_MAP_A_TO_A_SIZE:
+ params[0] = (GLfloat)(ctx->Pixel.MapAtoAsize);
+ break;
+ case GL_PIXEL_MAP_B_TO_B_SIZE:
+ params[0] = (GLfloat)(ctx->Pixel.MapBtoBsize);
+ break;
+ case GL_PIXEL_MAP_G_TO_G_SIZE:
+ params[0] = (GLfloat)(ctx->Pixel.MapGtoGsize);
+ break;
+ case GL_PIXEL_MAP_I_TO_A_SIZE:
+ params[0] = (GLfloat)(ctx->Pixel.MapItoAsize);
+ break;
+ case GL_PIXEL_MAP_I_TO_B_SIZE:
+ params[0] = (GLfloat)(ctx->Pixel.MapItoBsize);
+ break;
+ case GL_PIXEL_MAP_I_TO_G_SIZE:
+ params[0] = (GLfloat)(ctx->Pixel.MapItoGsize);
+ break;
+ case GL_PIXEL_MAP_I_TO_I_SIZE:
+ params[0] = (GLfloat)(ctx->Pixel.MapItoIsize);
+ break;
+ case GL_PIXEL_MAP_I_TO_R_SIZE:
+ params[0] = (GLfloat)(ctx->Pixel.MapItoRsize);
+ break;
+ case GL_PIXEL_MAP_R_TO_R_SIZE:
+ params[0] = (GLfloat)(ctx->Pixel.MapRtoRsize);
+ break;
+ case GL_PIXEL_MAP_S_TO_S_SIZE:
+ params[0] = (GLfloat)(ctx->Pixel.MapStoSsize);
+ break;
+ case GL_POINT_SIZE:
+ params[0] = ctx->Point.Size;
+ break;
+ case GL_POINT_SIZE_GRANULARITY:
+ params[0] = ctx->Const.PointSizeGranularity;
+ break;
+ case GL_POINT_SIZE_RANGE:
+ params[0] = ctx->Const.MinPointSizeAA;
+ params[1] = ctx->Const.MaxPointSizeAA;
+ break;
+ case GL_ALIASED_POINT_SIZE_RANGE:
+ params[0] = ctx->Const.MinPointSize;
+ params[1] = ctx->Const.MaxPointSize;
+ break;
+ case GL_POINT_SMOOTH:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Point.SmoothFlag);
+ break;
+ case GL_POINT_SMOOTH_HINT:
+ params[0] = ENUM_TO_FLOAT(ctx->Hint.PointSmooth);
+ break;
+ case GL_POINT_SIZE_MIN_EXT:
+ params[0] = ctx->Point.MinSize;
+ break;
+ case GL_POINT_SIZE_MAX_EXT:
+ params[0] = ctx->Point.MaxSize;
+ break;
+ case GL_POINT_FADE_THRESHOLD_SIZE_EXT:
+ params[0] = ctx->Point.Threshold;
+ break;
+ case GL_DISTANCE_ATTENUATION_EXT:
+ params[0] = ctx->Point.Params[0];
+ params[1] = ctx->Point.Params[1];
+ params[2] = ctx->Point.Params[2];
+ break;
+ case GL_POLYGON_MODE:
+ params[0] = ENUM_TO_FLOAT(ctx->Polygon.FrontMode);
+ params[1] = ENUM_TO_FLOAT(ctx->Polygon.BackMode);
+ break;
+ case GL_POLYGON_OFFSET_BIAS_EXT:
+ params[0] = ctx->Polygon.OffsetUnits;
+ break;
+ case GL_POLYGON_OFFSET_FACTOR:
+ params[0] = ctx->Polygon.OffsetFactor ;
+ break;
+ case GL_POLYGON_OFFSET_UNITS:
+ params[0] = ctx->Polygon.OffsetUnits ;
+ break;
+ case GL_POLYGON_SMOOTH:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.SmoothFlag);
+ break;
+ case GL_POLYGON_SMOOTH_HINT:
+ params[0] = ENUM_TO_FLOAT(ctx->Hint.PolygonSmooth);
+ break;
+ case GL_POLYGON_STIPPLE:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Polygon.StippleFlag);
+ break;
+ case GL_PROJECTION_MATRIX:
+ {
+ const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;
+ params[0] = matrix[0];
+ params[1] = matrix[1];
+ params[2] = matrix[2];
+ params[3] = matrix[3];
+ params[4] = matrix[4];
+ params[5] = matrix[5];
+ params[6] = matrix[6];
+ params[7] = matrix[7];
+ params[8] = matrix[8];
+ params[9] = matrix[9];
+ params[10] = matrix[10];
+ params[11] = matrix[11];
+ params[12] = matrix[12];
+ params[13] = matrix[13];
+ params[14] = matrix[14];
+ params[15] = matrix[15];
+ }
+ break;
+ case GL_PROJECTION_STACK_DEPTH:
+ params[0] = (GLfloat)(ctx->ProjectionMatrixStack.Depth + 1);
+ break;
+ case GL_READ_BUFFER:
+ params[0] = ENUM_TO_FLOAT(ctx->Pixel.ReadBuffer);
+ break;
+ case GL_RED_BIAS:
+ params[0] = ctx->Pixel.RedBias;
+ break;
+ case GL_RED_BITS:
+ params[0] = (GLfloat)( ctx->DrawBuffer->Visual.redBits );
+ break;
+ case GL_RED_SCALE:
+ params[0] = ctx->Pixel.RedScale;
+ break;
+ case GL_RENDER_MODE:
+ params[0] = ENUM_TO_FLOAT(ctx->RenderMode);
+ break;
+ case GL_RESCALE_NORMAL:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Transform.RescaleNormals);
+ break;
+ case GL_RGBA_MODE:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->DrawBuffer->Visual.rgbMode);
+ break;
+ case GL_SCISSOR_BOX:
+ params[0] = (GLfloat)(ctx->Scissor.X);
+ params[1] = (GLfloat)(ctx->Scissor.Y);
+ params[2] = (GLfloat)(ctx->Scissor.Width);
+ params[3] = (GLfloat)(ctx->Scissor.Height);
+ break;
+ case GL_SCISSOR_TEST:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Scissor.Enabled);
+ break;
+ case GL_SELECTION_BUFFER_SIZE:
+ params[0] = (GLfloat)(ctx->Select.BufferSize);
+ break;
+ case GL_SHADE_MODEL:
+ params[0] = ENUM_TO_FLOAT(ctx->Light.ShadeModel);
+ break;
+ case GL_SHARED_TEXTURE_PALETTE_EXT:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Texture.SharedPalette);
+ break;
+ case GL_STENCIL_BITS:
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.stencilBits);
+ break;
+ case GL_STENCIL_CLEAR_VALUE:
+ params[0] = (GLfloat)(ctx->Stencil.Clear);
+ break;
+ case GL_STENCIL_FAIL:
+ params[0] = ENUM_TO_FLOAT(ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STENCIL_FUNC:
+ params[0] = ENUM_TO_FLOAT(ctx->Stencil.Function[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STENCIL_PASS_DEPTH_FAIL:
+ params[0] = ENUM_TO_FLOAT(ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STENCIL_PASS_DEPTH_PASS:
+ params[0] = ENUM_TO_FLOAT(ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STENCIL_REF:
+ params[0] = (GLfloat)(ctx->Stencil.Ref[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STENCIL_TEST:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Stencil.Enabled);
+ break;
+ case GL_STENCIL_VALUE_MASK:
+ params[0] = (GLfloat)(ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STENCIL_WRITEMASK:
+ params[0] = (GLfloat)(ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STEREO:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->DrawBuffer->Visual.stereoMode);
+ break;
+ case GL_SUBPIXEL_BITS:
+ params[0] = (GLfloat)(ctx->Const.SubPixelBits);
+ break;
+ case GL_TEXTURE_1D:
+ params[0] = BOOLEAN_TO_FLOAT(_mesa_IsEnabled(GL_TEXTURE_1D));
+ break;
+ case GL_TEXTURE_2D:
+ params[0] = BOOLEAN_TO_FLOAT(_mesa_IsEnabled(GL_TEXTURE_2D));
+ break;
+ case GL_TEXTURE_3D:
+ params[0] = BOOLEAN_TO_FLOAT(_mesa_IsEnabled(GL_TEXTURE_3D));
+ break;
+ case GL_TEXTURE_BINDING_1D:
+ params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current1D->Name);
+ break;
+ case GL_TEXTURE_BINDING_2D:
+ params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current2D->Name);
+ break;
+ case GL_TEXTURE_BINDING_3D:
+ params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current3D->Name);
+ break;
+ case GL_TEXTURE_ENV_COLOR:
+ {
+ const GLfloat *color = ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvColor;
+ params[0] = color[0];
+ params[1] = color[1];
+ params[2] = color[2];
+ params[3] = color[3];
+ }
+ break;
+ case GL_TEXTURE_ENV_MODE:
+ params[0] = ENUM_TO_FLOAT(ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvMode);
+ break;
+ case GL_TEXTURE_GEN_S:
+ params[0] = BOOLEAN_TO_FLOAT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0));
+ break;
+ case GL_TEXTURE_GEN_T:
+ params[0] = BOOLEAN_TO_FLOAT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & T_BIT) ? 1 : 0));
+ break;
+ case GL_TEXTURE_GEN_R:
+ params[0] = BOOLEAN_TO_FLOAT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & R_BIT) ? 1 : 0));
+ break;
+ case GL_TEXTURE_GEN_Q:
+ params[0] = BOOLEAN_TO_FLOAT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & Q_BIT) ? 1 : 0));
+ break;
+ case GL_TEXTURE_MATRIX:
+ {
+ const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;
+ params[0] = matrix[0];
+ params[1] = matrix[1];
+ params[2] = matrix[2];
+ params[3] = matrix[3];
+ params[4] = matrix[4];
+ params[5] = matrix[5];
+ params[6] = matrix[6];
+ params[7] = matrix[7];
+ params[8] = matrix[8];
+ params[9] = matrix[9];
+ params[10] = matrix[10];
+ params[11] = matrix[11];
+ params[12] = matrix[12];
+ params[13] = matrix[13];
+ params[14] = matrix[14];
+ params[15] = matrix[15];
+ }
+ break;
+ case GL_TEXTURE_STACK_DEPTH:
+ params[0] = (GLfloat)(ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Depth + 1);
+ break;
+ case GL_UNPACK_ALIGNMENT:
+ params[0] = (GLfloat)(ctx->Unpack.Alignment);
+ break;
+ case GL_UNPACK_LSB_FIRST:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Unpack.LsbFirst);
+ break;
+ case GL_UNPACK_ROW_LENGTH:
+ params[0] = (GLfloat)(ctx->Unpack.RowLength);
+ break;
+ case GL_UNPACK_SKIP_PIXELS:
+ params[0] = (GLfloat)(ctx->Unpack.SkipPixels);
+ break;
+ case GL_UNPACK_SKIP_ROWS:
+ params[0] = (GLfloat)(ctx->Unpack.SkipRows);
+ break;
+ case GL_UNPACK_SWAP_BYTES:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Unpack.SwapBytes);
+ break;
+ case GL_UNPACK_SKIP_IMAGES_EXT:
+ params[0] = (GLfloat)(ctx->Unpack.SkipImages);
+ break;
+ case GL_UNPACK_IMAGE_HEIGHT_EXT:
+ params[0] = (GLfloat)(ctx->Unpack.ImageHeight);
+ break;
+ case GL_UNPACK_CLIENT_STORAGE_APPLE:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Unpack.ClientStorage);
+ break;
+ case GL_VIEWPORT:
+ params[0] = (GLfloat)(ctx->Viewport.X);
+ params[1] = (GLfloat)(ctx->Viewport.Y);
+ params[2] = (GLfloat)(ctx->Viewport.Width);
+ params[3] = (GLfloat)(ctx->Viewport.Height);
+ break;
+ case GL_ZOOM_X:
+ params[0] = ctx->Pixel.ZoomX;
+ break;
+ case GL_ZOOM_Y:
+ params[0] = ctx->Pixel.ZoomY;
+ break;
+ case GL_VERTEX_ARRAY:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.Vertex.Enabled);
+ break;
+ case GL_VERTEX_ARRAY_SIZE:
+ params[0] = (GLfloat)(ctx->Array.Vertex.Size);
+ break;
+ case GL_VERTEX_ARRAY_TYPE:
+ params[0] = ENUM_TO_FLOAT(ctx->Array.Vertex.Type);
+ break;
+ case GL_VERTEX_ARRAY_STRIDE:
+ params[0] = (GLfloat)(ctx->Array.Vertex.Stride);
+ break;
+ case GL_VERTEX_ARRAY_COUNT_EXT:
+ params[0] = (GLfloat)(0);
+ break;
+ case GL_NORMAL_ARRAY:
+ params[0] = ENUM_TO_FLOAT(ctx->Array.Normal.Enabled);
+ break;
+ case GL_NORMAL_ARRAY_TYPE:
+ params[0] = ENUM_TO_FLOAT(ctx->Array.Normal.Type);
+ break;
+ case GL_NORMAL_ARRAY_STRIDE:
+ params[0] = (GLfloat)(ctx->Array.Normal.Stride);
+ break;
+ case GL_NORMAL_ARRAY_COUNT_EXT:
+ params[0] = (GLfloat)(0);
+ break;
+ case GL_COLOR_ARRAY:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.Color.Enabled);
+ break;
+ case GL_COLOR_ARRAY_SIZE:
+ params[0] = (GLfloat)(ctx->Array.Color.Size);
+ break;
+ case GL_COLOR_ARRAY_TYPE:
+ params[0] = ENUM_TO_FLOAT(ctx->Array.Color.Type);
+ break;
+ case GL_COLOR_ARRAY_STRIDE:
+ params[0] = (GLfloat)(ctx->Array.Color.Stride);
+ break;
+ case GL_COLOR_ARRAY_COUNT_EXT:
+ params[0] = (GLfloat)(0);
+ break;
+ case GL_INDEX_ARRAY:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.Index.Enabled);
+ break;
+ case GL_INDEX_ARRAY_TYPE:
+ params[0] = ENUM_TO_FLOAT(ctx->Array.Index.Type);
+ break;
+ case GL_INDEX_ARRAY_STRIDE:
+ params[0] = (GLfloat)(ctx->Array.Index.Stride);
+ break;
+ case GL_INDEX_ARRAY_COUNT_EXT:
+ params[0] = (GLfloat)(0);
+ break;
+ case GL_TEXTURE_COORD_ARRAY:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_SIZE:
+ params[0] = (GLfloat)(ctx->Array.TexCoord[ctx->Array.ActiveTexture].Size);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_TYPE:
+ params[0] = ENUM_TO_FLOAT(ctx->Array.TexCoord[ctx->Array.ActiveTexture].Type);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_STRIDE:
+ params[0] = (GLfloat)(ctx->Array.TexCoord[ctx->Array.ActiveTexture].Stride);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_COUNT_EXT:
+ params[0] = (GLfloat)(0);
+ break;
+ case GL_EDGE_FLAG_ARRAY:
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.EdgeFlag.Enabled);
+ break;
+ case GL_EDGE_FLAG_ARRAY_STRIDE:
+ params[0] = (GLfloat)(ctx->Array.EdgeFlag.Stride);
+ break;
+ case GL_EDGE_FLAG_ARRAY_COUNT_EXT:
+ params[0] = (GLfloat)(0);
+ break;
+ case GL_MAX_TEXTURE_UNITS_ARB:
+ CHECK_EXTENSION_F(ARB_multitexture, pname);
+ params[0] = (GLfloat)(MIN2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits));
+ break;
+ case GL_ACTIVE_TEXTURE_ARB:
+ CHECK_EXTENSION_F(ARB_multitexture, pname);
+ params[0] = (GLfloat)(GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit);
+ break;
+ case GL_CLIENT_ACTIVE_TEXTURE_ARB:
+ CHECK_EXTENSION_F(ARB_multitexture, pname);
+ params[0] = (GLfloat)(GL_TEXTURE0_ARB + ctx->Array.ActiveTexture);
+ break;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ CHECK_EXTENSION_F(ARB_texture_cube_map, pname);
+ params[0] = BOOLEAN_TO_FLOAT(_mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB));
+ break;
+ case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
+ CHECK_EXTENSION_F(ARB_texture_cube_map, pname);
+ params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentCubeMap->Name);
+ break;
+ case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
+ CHECK_EXTENSION_F(ARB_texture_cube_map, pname);
+ params[0] = (GLfloat)((1 << (ctx->Const.MaxCubeTextureLevels - 1)));
+ break;
+ case GL_TEXTURE_COMPRESSION_HINT_ARB:
+ CHECK_EXTENSION_F(ARB_texture_compression, pname);
+ params[0] = (GLfloat)(ctx->Hint.TextureCompression);
+ break;
+ case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
+ CHECK_EXTENSION_F(ARB_texture_compression, pname);
+ params[0] = (GLfloat)(_mesa_get_compressed_formats(ctx, NULL));
+ break;
+ case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
+ CHECK_EXTENSION_F(ARB_texture_compression, pname);
+ {
+ GLint formats[100];
+ GLuint i, n = _mesa_get_compressed_formats(ctx, formats);
+ ASSERT(n <= 100);
+ for (i = 0; i < n; i++)
+ params[i] = ENUM_TO_INT(formats[i]);
+ }
+ break;
+ case GL_ARRAY_ELEMENT_LOCK_FIRST_EXT:
+ CHECK_EXTENSION_F(EXT_compiled_vertex_array, pname);
+ params[0] = (GLfloat)(ctx->Array.LockFirst);
+ break;
+ case GL_ARRAY_ELEMENT_LOCK_COUNT_EXT:
+ CHECK_EXTENSION_F(EXT_compiled_vertex_array, pname);
+ params[0] = (GLfloat)(ctx->Array.LockCount);
+ break;
+ case GL_TRANSPOSE_COLOR_MATRIX_ARB:
+ {
+ const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;
+ params[0] = matrix[0];
+ params[1] = matrix[4];
+ params[2] = matrix[8];
+ params[3] = matrix[12];
+ params[4] = matrix[1];
+ params[5] = matrix[5];
+ params[6] = matrix[9];
+ params[7] = matrix[13];
+ params[8] = matrix[2];
+ params[9] = matrix[6];
+ params[10] = matrix[10];
+ params[11] = matrix[14];
+ params[12] = matrix[3];
+ params[13] = matrix[7];
+ params[14] = matrix[11];
+ params[15] = matrix[15];
+ }
+ break;
+ case GL_TRANSPOSE_MODELVIEW_MATRIX_ARB:
+ {
+ const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;
+ params[0] = matrix[0];
+ params[1] = matrix[4];
+ params[2] = matrix[8];
+ params[3] = matrix[12];
+ params[4] = matrix[1];
+ params[5] = matrix[5];
+ params[6] = matrix[9];
+ params[7] = matrix[13];
+ params[8] = matrix[2];
+ params[9] = matrix[6];
+ params[10] = matrix[10];
+ params[11] = matrix[14];
+ params[12] = matrix[3];
+ params[13] = matrix[7];
+ params[14] = matrix[11];
+ params[15] = matrix[15];
+ }
+ break;
+ case GL_TRANSPOSE_PROJECTION_MATRIX_ARB:
+ {
+ const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;
+ params[0] = matrix[0];
+ params[1] = matrix[4];
+ params[2] = matrix[8];
+ params[3] = matrix[12];
+ params[4] = matrix[1];
+ params[5] = matrix[5];
+ params[6] = matrix[9];
+ params[7] = matrix[13];
+ params[8] = matrix[2];
+ params[9] = matrix[6];
+ params[10] = matrix[10];
+ params[11] = matrix[14];
+ params[12] = matrix[3];
+ params[13] = matrix[7];
+ params[14] = matrix[11];
+ params[15] = matrix[15];
+ }
+ break;
+ case GL_TRANSPOSE_TEXTURE_MATRIX_ARB:
+ {
+ const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;
+ params[0] = matrix[0];
+ params[1] = matrix[4];
+ params[2] = matrix[8];
+ params[3] = matrix[12];
+ params[4] = matrix[1];
+ params[5] = matrix[5];
+ params[6] = matrix[9];
+ params[7] = matrix[13];
+ params[8] = matrix[2];
+ params[9] = matrix[6];
+ params[10] = matrix[10];
+ params[11] = matrix[14];
+ params[12] = matrix[3];
+ params[13] = matrix[7];
+ params[14] = matrix[11];
+ params[15] = matrix[15];
+ }
+ break;
+ case GL_OCCLUSION_TEST_HP:
+ CHECK_EXTENSION_F(HP_occlusion_test, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Depth.OcclusionTest);
+ break;
+ case GL_OCCLUSION_TEST_RESULT_HP:
+ CHECK_EXTENSION_F(HP_occlusion_test, pname);
+ {
+ FLUSH_VERTICES(ctx, _NEW_DEPTH);
+ if (ctx->Depth.OcclusionTest)
+ params[0] = ctx->OcclusionResult;
+ else
+ params[0] = ctx->OcclusionResultSaved;
+ /* reset flag now */
+ ctx->OcclusionResult = GL_FALSE;
+ ctx->OcclusionResultSaved = GL_FALSE;
+ return;
+ }
+ break;
+ case GL_PIXEL_TEXTURE_SGIS:
+ CHECK_EXTENSION_F(SGIS_pixel_texture, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.PixelTextureEnabled);
+ break;
+ case GL_PIXEL_TEX_GEN_SGIX:
+ CHECK_EXTENSION_F(SGIX_pixel_texture, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.PixelTextureEnabled);
+ break;
+ case GL_PIXEL_TEX_GEN_MODE_SGIX:
+ CHECK_EXTENSION_F(SGIX_pixel_texture, pname);
+ params[0] = ENUM_TO_FLOAT(pixel_texgen_mode(ctx));
+ break;
+ case GL_COLOR_MATRIX_SGI:
+ {
+ const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;
+ params[0] = matrix[0];
+ params[1] = matrix[1];
+ params[2] = matrix[2];
+ params[3] = matrix[3];
+ params[4] = matrix[4];
+ params[5] = matrix[5];
+ params[6] = matrix[6];
+ params[7] = matrix[7];
+ params[8] = matrix[8];
+ params[9] = matrix[9];
+ params[10] = matrix[10];
+ params[11] = matrix[11];
+ params[12] = matrix[12];
+ params[13] = matrix[13];
+ params[14] = matrix[14];
+ params[15] = matrix[15];
+ }
+ break;
+ case GL_COLOR_MATRIX_STACK_DEPTH_SGI:
+ params[0] = (GLfloat)(ctx->ColorMatrixStack.Depth + 1);
+ break;
+ case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI:
+ params[0] = (GLfloat)(MAX_COLOR_STACK_DEPTH);
+ break;
+ case GL_POST_COLOR_MATRIX_RED_SCALE_SGI:
+ params[0] = ctx->Pixel.PostColorMatrixScale[0];
+ break;
+ case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI:
+ params[0] = ctx->Pixel.PostColorMatrixScale[1];
+ break;
+ case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI:
+ params[0] = ctx->Pixel.PostColorMatrixScale[2];
+ break;
+ case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI:
+ params[0] = ctx->Pixel.PostColorMatrixScale[3];
+ break;
+ case GL_POST_COLOR_MATRIX_RED_BIAS_SGI:
+ params[0] = ctx->Pixel.PostColorMatrixBias[0];
+ break;
+ case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI:
+ params[0] = ctx->Pixel.PostColorMatrixBias[1];
+ break;
+ case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI:
+ params[0] = ctx->Pixel.PostColorMatrixBias[2];
+ break;
+ case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI:
+ params[0] = ctx->Pixel.PostColorMatrixBias[3];
+ break;
+ case GL_CONVOLUTION_1D_EXT:
+ CHECK_EXTENSION_F(EXT_convolution, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.Convolution1DEnabled);
+ break;
+ case GL_CONVOLUTION_2D_EXT:
+ CHECK_EXTENSION_F(EXT_convolution, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.Convolution2DEnabled);
+ break;
+ case GL_SEPARABLE_2D_EXT:
+ CHECK_EXTENSION_F(EXT_convolution, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.Separable2DEnabled);
+ break;
+ case GL_POST_CONVOLUTION_RED_SCALE_EXT:
+ CHECK_EXTENSION_F(EXT_convolution, pname);
+ params[0] = ctx->Pixel.PostConvolutionScale[0];
+ break;
+ case GL_POST_CONVOLUTION_GREEN_SCALE_EXT:
+ CHECK_EXTENSION_F(EXT_convolution, pname);
+ params[0] = ctx->Pixel.PostConvolutionScale[1];
+ break;
+ case GL_POST_CONVOLUTION_BLUE_SCALE_EXT:
+ CHECK_EXTENSION_F(EXT_convolution, pname);
+ params[0] = ctx->Pixel.PostConvolutionScale[2];
+ break;
+ case GL_POST_CONVOLUTION_ALPHA_SCALE_EXT:
+ CHECK_EXTENSION_F(EXT_convolution, pname);
+ params[0] = ctx->Pixel.PostConvolutionScale[3];
+ break;
+ case GL_POST_CONVOLUTION_RED_BIAS_EXT:
+ CHECK_EXTENSION_F(EXT_convolution, pname);
+ params[0] = ctx->Pixel.PostConvolutionBias[0];
+ break;
+ case GL_POST_CONVOLUTION_GREEN_BIAS_EXT:
+ CHECK_EXTENSION_F(EXT_convolution, pname);
+ params[0] = ctx->Pixel.PostConvolutionBias[1];
+ break;
+ case GL_POST_CONVOLUTION_BLUE_BIAS_EXT:
+ CHECK_EXTENSION_F(EXT_convolution, pname);
+ params[0] = ctx->Pixel.PostConvolutionBias[2];
+ break;
+ case GL_POST_CONVOLUTION_ALPHA_BIAS_EXT:
+ CHECK_EXTENSION_F(EXT_convolution, pname);
+ params[0] = ctx->Pixel.PostConvolutionBias[3];
+ break;
+ case GL_HISTOGRAM:
+ CHECK_EXTENSION_F(EXT_histogram, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.HistogramEnabled);
+ break;
+ case GL_MINMAX:
+ CHECK_EXTENSION_F(EXT_histogram, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.MinMaxEnabled);
+ break;
+ case GL_COLOR_TABLE_SGI:
+ CHECK_EXTENSION_F(SGI_color_table, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.ColorTableEnabled);
+ break;
+ case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
+ CHECK_EXTENSION_F(SGI_color_table, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.PostConvolutionColorTableEnabled);
+ break;
+ case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
+ CHECK_EXTENSION_F(SGI_color_table, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Pixel.PostColorMatrixColorTableEnabled);
+ break;
+ case GL_TEXTURE_COLOR_TABLE_SGI:
+ CHECK_EXTENSION_F(SGI_texture_color_table, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled);
+ break;
+ case GL_COLOR_SUM_EXT:
+ CHECK_EXTENSION_F(EXT_secondary_color, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Fog.ColorSumEnabled);
+ break;
+ case GL_CURRENT_SECONDARY_COLOR_EXT:
+ CHECK_EXTENSION_F(EXT_secondary_color, pname);
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0];
+ params[1] = ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1];
+ params[2] = ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2];
+ params[3] = ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3];
+ }
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_EXT:
+ CHECK_EXTENSION_F(EXT_secondary_color, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.SecondaryColor.Enabled);
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_TYPE_EXT:
+ CHECK_EXTENSION_F(EXT_secondary_color, pname);
+ params[0] = ENUM_TO_FLOAT(ctx->Array.SecondaryColor.Type);
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT:
+ CHECK_EXTENSION_F(EXT_secondary_color, pname);
+ params[0] = (GLfloat)(ctx->Array.SecondaryColor.Stride);
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_SIZE_EXT:
+ CHECK_EXTENSION_F(EXT_secondary_color, pname);
+ params[0] = (GLfloat)(ctx->Array.SecondaryColor.Size);
+ break;
+ case GL_CURRENT_FOG_COORDINATE_EXT:
+ CHECK_EXTENSION_F(EXT_fog_coord, pname);
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = ctx->Current.Attrib[VERT_ATTRIB_FOG][0];
+ }
+ break;
+ case GL_FOG_COORDINATE_ARRAY_EXT:
+ CHECK_EXTENSION_F(EXT_fog_coord, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.FogCoord.Enabled);
+ break;
+ case GL_FOG_COORDINATE_ARRAY_TYPE_EXT:
+ CHECK_EXTENSION_F(EXT_fog_coord, pname);
+ params[0] = ENUM_TO_FLOAT(ctx->Array.FogCoord.Type);
+ break;
+ case GL_FOG_COORDINATE_ARRAY_STRIDE_EXT:
+ CHECK_EXTENSION_F(EXT_fog_coord, pname);
+ params[0] = (GLfloat)(ctx->Array.FogCoord.Stride);
+ break;
+ case GL_FOG_COORDINATE_SOURCE_EXT:
+ CHECK_EXTENSION_F(EXT_fog_coord, pname);
+ params[0] = ENUM_TO_FLOAT(ctx->Fog.FogCoordinateSource);
+ break;
+ case GL_MAX_TEXTURE_LOD_BIAS_EXT:
+ CHECK_EXTENSION_F(EXT_texture_lod_bias, pname);
+ params[0] = ctx->Const.MaxTextureLodBias;
+ break;
+ case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
+ CHECK_EXTENSION_F(EXT_texture_filter_anisotropic, pname);
+ params[0] = ctx->Const.MaxTextureMaxAnisotropy;
+ break;
+ case GL_MULTISAMPLE_ARB:
+ CHECK_EXTENSION_F(ARB_multisample, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Multisample.Enabled);
+ break;
+ case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
+ CHECK_EXTENSION_F(ARB_multisample, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Multisample.SampleAlphaToCoverage);
+ break;
+ case GL_SAMPLE_ALPHA_TO_ONE_ARB:
+ CHECK_EXTENSION_F(ARB_multisample, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Multisample.SampleAlphaToOne);
+ break;
+ case GL_SAMPLE_COVERAGE_ARB:
+ CHECK_EXTENSION_F(ARB_multisample, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Multisample.SampleCoverage);
+ break;
+ case GL_SAMPLE_COVERAGE_VALUE_ARB:
+ CHECK_EXTENSION_F(ARB_multisample, pname);
+ params[0] = ctx->Multisample.SampleCoverageValue;
+ break;
+ case GL_SAMPLE_COVERAGE_INVERT_ARB:
+ CHECK_EXTENSION_F(ARB_multisample, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Multisample.SampleCoverageInvert);
+ break;
+ case GL_SAMPLE_BUFFERS_ARB:
+ CHECK_EXTENSION_F(ARB_multisample, pname);
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.sampleBuffers);
+ break;
+ case GL_SAMPLES_ARB:
+ CHECK_EXTENSION_F(ARB_multisample, pname);
+ params[0] = (GLfloat)(ctx->DrawBuffer->Visual.samples);
+ break;
+ case GL_RASTER_POSITION_UNCLIPPED_IBM:
+ CHECK_EXTENSION_F(IBM_rasterpos_clip, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Transform.RasterPositionUnclipped);
+ break;
+ case GL_POINT_SPRITE_NV:
+ CHECK_EXTENSION_F(NV_point_sprite, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Point.PointSprite);
+ break;
+ case GL_POINT_SPRITE_R_MODE_NV:
+ CHECK_EXTENSION_F(NV_point_sprite, pname);
+ params[0] = ENUM_TO_FLOAT(ctx->Point.SpriteRMode);
+ break;
+ case GL_POINT_SPRITE_COORD_ORIGIN:
+ CHECK_EXTENSION_F(NV_point_sprite, pname);
+ params[0] = ENUM_TO_FLOAT(ctx->Point.SpriteOrigin);
+ break;
+ case GL_GENERATE_MIPMAP_HINT_SGIS:
+ CHECK_EXTENSION_F(SGIS_generate_mipmap, pname);
+ params[0] = ENUM_TO_FLOAT(ctx->Hint.GenerateMipmap);
+ break;
+ case GL_VERTEX_PROGRAM_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->VertexProgram.Enabled);
+ break;
+ case GL_VERTEX_PROGRAM_POINT_SIZE_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->VertexProgram.PointSizeEnabled);
+ break;
+ case GL_VERTEX_PROGRAM_TWO_SIDE_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->VertexProgram.TwoSideEnabled);
+ break;
+ case GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = (GLfloat)(ctx->Const.MaxProgramMatrixStackDepth);
+ break;
+ case GL_MAX_TRACK_MATRICES_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = (GLfloat)(ctx->Const.MaxProgramMatrices);
+ break;
+ case GL_CURRENT_MATRIX_STACK_DEPTH_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->CurrentStack->Depth + 1);
+ break;
+ case GL_CURRENT_MATRIX_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ {
+ const GLfloat *matrix = ctx->CurrentStack->Top->m;
+ params[0] = matrix[0];
+ params[1] = matrix[1];
+ params[2] = matrix[2];
+ params[3] = matrix[3];
+ params[4] = matrix[4];
+ params[5] = matrix[5];
+ params[6] = matrix[6];
+ params[7] = matrix[7];
+ params[8] = matrix[8];
+ params[9] = matrix[9];
+ params[10] = matrix[10];
+ params[11] = matrix[11];
+ params[12] = matrix[12];
+ params[13] = matrix[13];
+ params[14] = matrix[14];
+ params[15] = matrix[15];
+ }
+ break;
+ case GL_VERTEX_PROGRAM_BINDING_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = (GLfloat)((ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0));
+ break;
+ case GL_PROGRAM_ERROR_POSITION_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = (GLfloat)(ctx->Program.ErrorPos);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY0_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.VertexAttrib[0].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY1_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.VertexAttrib[1].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY2_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.VertexAttrib[2].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY3_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.VertexAttrib[3].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY4_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.VertexAttrib[4].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY5_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.VertexAttrib[5].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY6_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.VertexAttrib[6].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY7_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.VertexAttrib[7].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY8_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.VertexAttrib[8].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY9_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.VertexAttrib[9].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY10_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.VertexAttrib[10].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY11_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.VertexAttrib[11].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY12_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.VertexAttrib[12].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY13_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.VertexAttrib[13].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY14_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.VertexAttrib[14].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY15_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Array.VertexAttrib[15].Enabled);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB0_4_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[0]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB1_4_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[1]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB2_4_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[2]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB3_4_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[3]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB4_4_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[4]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB5_4_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[5]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB6_4_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[6]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB7_4_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[7]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB8_4_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[8]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB9_4_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[9]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB10_4_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[10]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB11_4_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[11]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB12_4_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[12]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB13_4_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[13]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB14_4_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[14]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB15_4_NV:
+ CHECK_EXTENSION_F(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Eval.Map1Attrib[15]);
+ break;
+ case GL_FRAGMENT_PROGRAM_NV:
+ CHECK_EXTENSION_F(NV_fragment_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->FragmentProgram.Enabled);
+ break;
+ case GL_MAX_TEXTURE_COORDS_NV:
+ CHECK_EXTENSION_F(NV_fragment_program, pname);
+ params[0] = (GLfloat)(ctx->Const.MaxTextureCoordUnits);
+ break;
+ case GL_MAX_TEXTURE_IMAGE_UNITS_NV:
+ CHECK_EXTENSION_F(NV_fragment_program, pname);
+ params[0] = (GLfloat)(ctx->Const.MaxTextureImageUnits);
+ break;
+ case GL_FRAGMENT_PROGRAM_BINDING_NV:
+ CHECK_EXTENSION_F(NV_fragment_program, pname);
+ params[0] = (GLfloat)(ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0);
+ break;
+ case GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV:
+ CHECK_EXTENSION_F(NV_fragment_program, pname);
+ params[0] = (GLfloat)(MAX_NV_FRAGMENT_PROGRAM_PARAMS);
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ CHECK_EXTENSION_F(NV_texture_rectangle, pname);
+ params[0] = BOOLEAN_TO_FLOAT(_mesa_IsEnabled(GL_TEXTURE_RECTANGLE_NV));
+ break;
+ case GL_TEXTURE_BINDING_RECTANGLE_NV:
+ CHECK_EXTENSION_F(NV_texture_rectangle, pname);
+ params[0] = (GLfloat)(ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentRect->Name);
+ break;
+ case GL_MAX_RECTANGLE_TEXTURE_SIZE_NV:
+ CHECK_EXTENSION_F(NV_texture_rectangle, pname);
+ params[0] = (GLfloat)(ctx->Const.MaxTextureRectSize);
+ break;
+ case GL_STENCIL_TEST_TWO_SIDE_EXT:
+ CHECK_EXTENSION_F(EXT_stencil_two_side, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Stencil.TestTwoSide);
+ break;
+ case GL_ACTIVE_STENCIL_FACE_EXT:
+ CHECK_EXTENSION_F(EXT_stencil_two_side, pname);
+ params[0] = ENUM_TO_FLOAT(ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT);
+ break;
+ case GL_MAX_SHININESS_NV:
+ CHECK_EXTENSION_F(NV_light_max_exponent, pname);
+ params[0] = ctx->Const.MaxShininess;
+ break;
+ case GL_MAX_SPOT_EXPONENT_NV:
+ CHECK_EXTENSION_F(NV_light_max_exponent, pname);
+ params[0] = ctx->Const.MaxSpotExponent;
+ break;
+ case GL_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
+ params[0] = (GLfloat)(ctx->Array.ArrayBufferObj->Name);
+ break;
+ case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
+ params[0] = (GLfloat)(ctx->Array.Vertex.BufferObj->Name);
+ break;
+ case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
+ params[0] = (GLfloat)(ctx->Array.Normal.BufferObj->Name);
+ break;
+ case GL_COLOR_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
+ params[0] = (GLfloat)(ctx->Array.Color.BufferObj->Name);
+ break;
+ case GL_INDEX_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
+ params[0] = (GLfloat)(ctx->Array.Index.BufferObj->Name);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
+ params[0] = (GLfloat)(ctx->Array.TexCoord[ctx->Array.ActiveTexture].BufferObj->Name);
+ break;
+ case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
+ params[0] = (GLfloat)(ctx->Array.EdgeFlag.BufferObj->Name);
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
+ params[0] = (GLfloat)(ctx->Array.SecondaryColor.BufferObj->Name);
+ break;
+ case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
+ params[0] = (GLfloat)(ctx->Array.FogCoord.BufferObj->Name);
+ break;
+ case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_F(ARB_vertex_buffer_object, pname);
+ params[0] = (GLfloat)(ctx->Array.ElementArrayBufferObj->Name);
+ break;
+ case GL_PIXEL_PACK_BUFFER_BINDING_EXT:
+ CHECK_EXTENSION_F(EXT_pixel_buffer_object, pname);
+ params[0] = (GLfloat)(ctx->Pack.BufferObj->Name);
+ break;
+ case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT:
+ CHECK_EXTENSION_F(EXT_pixel_buffer_object, pname);
+ params[0] = (GLfloat)(ctx->Unpack.BufferObj->Name);
+ break;
+ case GL_MAX_VERTEX_ATTRIBS_ARB:
+ CHECK_EXTENSION_F(ARB_vertex_program, pname);
+ params[0] = (GLfloat)(ctx->Const.MaxVertexProgramAttribs);
+ break;
+ case GL_FRAGMENT_PROGRAM_ARB:
+ CHECK_EXTENSION_F(ARB_fragment_program, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->FragmentProgram.Enabled);
+ break;
+ case GL_TRANSPOSE_CURRENT_MATRIX_ARB:
+ CHECK_EXTENSION_F(ARB_fragment_program, pname);
+ {
+ const GLfloat *matrix = ctx->CurrentStack->Top->m;
+ params[0] = matrix[0];
+ params[1] = matrix[4];
+ params[2] = matrix[8];
+ params[3] = matrix[12];
+ params[4] = matrix[1];
+ params[5] = matrix[5];
+ params[6] = matrix[9];
+ params[7] = matrix[13];
+ params[8] = matrix[2];
+ params[9] = matrix[6];
+ params[10] = matrix[10];
+ params[11] = matrix[14];
+ params[12] = matrix[3];
+ params[13] = matrix[7];
+ params[14] = matrix[11];
+ params[15] = matrix[15];
+ }
+ break;
+ case GL_DEPTH_BOUNDS_TEST_EXT:
+ CHECK_EXTENSION_F(EXT_depth_bounds_test, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->Depth.BoundsTest);
+ break;
+ case GL_DEPTH_BOUNDS_EXT:
+ CHECK_EXTENSION_F(EXT_depth_bounds_test, pname);
+ params[0] = ctx->Depth.BoundsMin;
+ params[1] = ctx->Depth.BoundsMax;
+ break;
+ case GL_FRAGMENT_PROGRAM_CALLBACK_MESA:
+ CHECK_EXTENSION_F(MESA_program_debug, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->FragmentProgram.CallbackEnabled);
+ break;
+ case GL_VERTEX_PROGRAM_CALLBACK_MESA:
+ CHECK_EXTENSION_F(MESA_program_debug, pname);
+ params[0] = BOOLEAN_TO_FLOAT(ctx->VertexProgram.CallbackEnabled);
+ break;
+ case GL_FRAGMENT_PROGRAM_POSITION_MESA:
+ CHECK_EXTENSION_F(MESA_program_debug, pname);
+ params[0] = (GLfloat)(ctx->FragmentProgram.CurrentPosition);
+ break;
+ case GL_VERTEX_PROGRAM_POSITION_MESA:
+ CHECK_EXTENSION_F(MESA_program_debug, pname);
+ params[0] = (GLfloat)(ctx->VertexProgram.CurrentPosition);
+ break;
+ case GL_MAX_DRAW_BUFFERS_ARB:
+ CHECK_EXTENSION_F(ARB_draw_buffers, pname);
+ params[0] = (GLfloat)(ctx->Const.MaxDrawBuffers);
+ break;
+ case GL_DRAW_BUFFER0_ARB:
+ CHECK_EXTENSION_F(ARB_draw_buffers, pname);
+ params[0] = ENUM_TO_FLOAT(ctx->Color.DrawBuffer[0]);
+ break;
+ case GL_DRAW_BUFFER1_ARB:
+ CHECK_EXTENSION_F(ARB_draw_buffers, pname);
+ {
+ GLenum buffer;
+ if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)");
+ return;
+ }
+ buffer = ctx->Color.DrawBuffer[1];
+ params[0] = ENUM_TO_FLOAT(buffer);
+ }
+ break;
+ case GL_DRAW_BUFFER2_ARB:
+ CHECK_EXTENSION_F(ARB_draw_buffers, pname);
+ {
+ GLenum buffer;
+ if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)");
+ return;
+ }
+ buffer = ctx->Color.DrawBuffer[2];
+ params[0] = ENUM_TO_FLOAT(buffer);
+ }
+ break;
+ case GL_DRAW_BUFFER3_ARB:
+ CHECK_EXTENSION_F(ARB_draw_buffers, pname);
+ {
+ GLenum buffer;
+ if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)");
+ return;
+ }
+ buffer = ctx->Color.DrawBuffer[3];
+ params[0] = ENUM_TO_FLOAT(buffer);
+ }
+ break;
+ case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
+ CHECK_EXTENSION_F(OES_read_format, pname);
+ params[0] = (GLfloat)(ctx->Const.ColorReadType);
+ break;
+ case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
+ CHECK_EXTENSION_F(OES_read_format, pname);
+ params[0] = (GLfloat)(ctx->Const.ColorReadFormat);
+ break;
+ case GL_NUM_FRAGMENT_REGISTERS_ATI:
+ CHECK_EXTENSION_F(ATI_fragment_shader, pname);
+ params[0] = (GLfloat)(6);
+ break;
+ case GL_NUM_FRAGMENT_CONSTANTS_ATI:
+ CHECK_EXTENSION_F(ATI_fragment_shader, pname);
+ params[0] = (GLfloat)(8);
+ break;
+ case GL_NUM_PASSES_ATI:
+ CHECK_EXTENSION_F(ATI_fragment_shader, pname);
+ params[0] = (GLfloat)(2);
+ break;
+ case GL_NUM_INSTRUCTIONS_PER_PASS_ATI:
+ CHECK_EXTENSION_F(ATI_fragment_shader, pname);
+ params[0] = (GLfloat)(8);
+ break;
+ case GL_NUM_INSTRUCTIONS_TOTAL_ATI:
+ CHECK_EXTENSION_F(ATI_fragment_shader, pname);
+ params[0] = (GLfloat)(16);
+ break;
+ case GL_COLOR_ALPHA_PAIRING_ATI:
+ CHECK_EXTENSION_F(ATI_fragment_shader, pname);
+ params[0] = BOOLEAN_TO_FLOAT(GL_TRUE);
+ break;
+ case GL_NUM_LOOPBACK_COMPONENTS_ATI:
+ CHECK_EXTENSION_F(ATI_fragment_shader, pname);
+ params[0] = (GLfloat)(3);
+ break;
+ case GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI:
+ CHECK_EXTENSION_F(ATI_fragment_shader, pname);
+ params[0] = (GLfloat)(3);
+ break;
+ case GL_STENCIL_BACK_FUNC:
+ params[0] = ENUM_TO_FLOAT(ctx->Stencil.Function[1]);
+ break;
+ case GL_STENCIL_BACK_VALUE_MASK:
+ params[0] = (GLfloat)(ctx->Stencil.ValueMask[1]);
+ break;
+ case GL_STENCIL_BACK_REF:
+ params[0] = (GLfloat)(ctx->Stencil.Ref[1]);
+ break;
+ case GL_STENCIL_BACK_FAIL:
+ params[0] = ENUM_TO_FLOAT(ctx->Stencil.FailFunc[1]);
+ break;
+ case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
+ params[0] = ENUM_TO_FLOAT(ctx->Stencil.ZFailFunc[1]);
+ break;
+ case GL_STENCIL_BACK_PASS_DEPTH_PASS:
+ params[0] = ENUM_TO_FLOAT(ctx->Stencil.ZPassFunc[1]);
+ break;
+ case GL_FRAMEBUFFER_BINDING_EXT:
+ CHECK_EXTENSION_F(EXT_framebuffer_object, pname);
+ params[0] = (GLfloat)(ctx->DrawBuffer->Name);
+ break;
+ case GL_RENDERBUFFER_BINDING_EXT:
+ CHECK_EXTENSION_F(EXT_framebuffer_object, pname);
+ params[0] = (GLfloat)(ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0);
+ break;
+ case GL_MAX_COLOR_ATTACHMENTS_EXT:
+ CHECK_EXTENSION_F(EXT_framebuffer_object, pname);
+ params[0] = (GLfloat)(ctx->Const.MaxColorAttachments);
+ break;
+ case GL_MAX_RENDERBUFFER_SIZE_EXT:
+ CHECK_EXTENSION_F(EXT_framebuffer_object, pname);
+ params[0] = (GLfloat)(ctx->Const.MaxRenderbufferSize);
+ break;
+ case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB:
+ CHECK_EXTENSION_F(ARB_fragment_shader, pname);
+ params[0] = (GLfloat)(MAX_FRAGMENT_UNIFORM_COMPONENTS);
+ break;
+ case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB:
+ CHECK_EXTENSION_F(ARB_fragment_shader, pname);
+ params[0] = ENUM_TO_FLOAT(ctx->Hint.FragmentShaderDerivative);
+ break;
+ case GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB:
+ CHECK_EXTENSION_F(ARB_vertex_shader, pname);
+ params[0] = (GLfloat)(MAX_VERTEX_UNIFORM_COMPONENTS);
+ break;
+ case GL_MAX_VARYING_FLOATS_ARB:
+ CHECK_EXTENSION_F(ARB_vertex_shader, pname);
+ params[0] = (GLfloat)(MAX_VARYING_FLOATS);
+ break;
+ case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB:
+ CHECK_EXTENSION_F(ARB_vertex_shader, pname);
+ params[0] = (GLfloat)(MAX_VERTEX_TEXTURE_IMAGE_UNITS);
+ break;
+ case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB:
+ CHECK_EXTENSION_F(ARB_vertex_shader, pname);
+ params[0] = (GLfloat)(MAX_COMBINED_TEXTURE_IMAGE_UNITS);
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetFloatv(pname=0x%x)", pname);
+ }
+}
+
+void GLAPIENTRY
+_mesa_GetIntegerv( GLenum pname, GLint *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!params)
+ return;
+
+ if (ctx->NewState)
+ _mesa_update_state(ctx);
+
+ if (ctx->Driver.GetIntegerv &&
+ ctx->Driver.GetIntegerv(ctx, pname, params))
+ return;
+
+ switch (pname) {
+ case GL_ACCUM_RED_BITS:
+ params[0] = ctx->DrawBuffer->Visual.accumRedBits;
+ break;
+ case GL_ACCUM_GREEN_BITS:
+ params[0] = ctx->DrawBuffer->Visual.accumGreenBits;
+ break;
+ case GL_ACCUM_BLUE_BITS:
+ params[0] = ctx->DrawBuffer->Visual.accumBlueBits;
+ break;
+ case GL_ACCUM_ALPHA_BITS:
+ params[0] = ctx->DrawBuffer->Visual.accumAlphaBits;
+ break;
+ case GL_ACCUM_CLEAR_VALUE:
+ params[0] = FLOAT_TO_INT(ctx->Accum.ClearColor[0]);
+ params[1] = FLOAT_TO_INT(ctx->Accum.ClearColor[1]);
+ params[2] = FLOAT_TO_INT(ctx->Accum.ClearColor[2]);
+ params[3] = FLOAT_TO_INT(ctx->Accum.ClearColor[3]);
+ break;
+ case GL_ALPHA_BIAS:
+ params[0] = IROUND(ctx->Pixel.AlphaBias);
+ break;
+ case GL_ALPHA_BITS:
+ params[0] = ctx->DrawBuffer->Visual.alphaBits;
+ break;
+ case GL_ALPHA_SCALE:
+ params[0] = IROUND(ctx->Pixel.AlphaScale);
+ break;
+ case GL_ALPHA_TEST:
+ params[0] = BOOLEAN_TO_INT(ctx->Color.AlphaEnabled);
+ break;
+ case GL_ALPHA_TEST_FUNC:
+ params[0] = ENUM_TO_INT(ctx->Color.AlphaFunc);
+ break;
+ case GL_ALPHA_TEST_REF:
+ params[0] = FLOAT_TO_INT(ctx->Color.AlphaRef);
+ break;
+ case GL_ATTRIB_STACK_DEPTH:
+ params[0] = ctx->AttribStackDepth;
+ break;
+ case GL_AUTO_NORMAL:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.AutoNormal);
+ break;
+ case GL_AUX_BUFFERS:
+ params[0] = ctx->DrawBuffer->Visual.numAuxBuffers;
+ break;
+ case GL_BLEND:
+ params[0] = BOOLEAN_TO_INT(ctx->Color.BlendEnabled);
+ break;
+ case GL_BLEND_DST:
+ params[0] = ENUM_TO_INT(ctx->Color.BlendDstRGB);
+ break;
+ case GL_BLEND_SRC:
+ params[0] = ENUM_TO_INT(ctx->Color.BlendSrcRGB);
+ break;
+ case GL_BLEND_SRC_RGB_EXT:
+ params[0] = ENUM_TO_INT(ctx->Color.BlendSrcRGB);
+ break;
+ case GL_BLEND_DST_RGB_EXT:
+ params[0] = ENUM_TO_INT(ctx->Color.BlendDstRGB);
+ break;
+ case GL_BLEND_SRC_ALPHA_EXT:
+ params[0] = ENUM_TO_INT(ctx->Color.BlendSrcA);
+ break;
+ case GL_BLEND_DST_ALPHA_EXT:
+ params[0] = ENUM_TO_INT(ctx->Color.BlendDstA);
+ break;
+ case GL_BLEND_EQUATION:
+ params[0] = ENUM_TO_INT(ctx->Color.BlendEquationRGB );
+ break;
+ case GL_BLEND_EQUATION_ALPHA_EXT:
+ params[0] = ENUM_TO_INT(ctx->Color.BlendEquationA );
+ break;
+ case GL_BLEND_COLOR_EXT:
+ params[0] = FLOAT_TO_INT(ctx->Color.BlendColor[0]);
+ params[1] = FLOAT_TO_INT(ctx->Color.BlendColor[1]);
+ params[2] = FLOAT_TO_INT(ctx->Color.BlendColor[2]);
+ params[3] = FLOAT_TO_INT(ctx->Color.BlendColor[3]);
+ break;
+ case GL_BLUE_BIAS:
+ params[0] = IROUND(ctx->Pixel.BlueBias);
+ break;
+ case GL_BLUE_BITS:
+ params[0] = ctx->DrawBuffer->Visual.blueBits;
+ break;
+ case GL_BLUE_SCALE:
+ params[0] = IROUND(ctx->Pixel.BlueScale);
+ break;
+ case GL_CLIENT_ATTRIB_STACK_DEPTH:
+ params[0] = ctx->ClientAttribStackDepth;
+ break;
+ case GL_CLIP_PLANE0:
+ params[0] = BOOLEAN_TO_INT((ctx->Transform.ClipPlanesEnabled >> 0) & 1);
+ break;
+ case GL_CLIP_PLANE1:
+ params[0] = BOOLEAN_TO_INT((ctx->Transform.ClipPlanesEnabled >> 1) & 1);
+ break;
+ case GL_CLIP_PLANE2:
+ params[0] = BOOLEAN_TO_INT((ctx->Transform.ClipPlanesEnabled >> 2) & 1);
+ break;
+ case GL_CLIP_PLANE3:
+ params[0] = BOOLEAN_TO_INT((ctx->Transform.ClipPlanesEnabled >> 3) & 1);
+ break;
+ case GL_CLIP_PLANE4:
+ params[0] = BOOLEAN_TO_INT((ctx->Transform.ClipPlanesEnabled >> 4) & 1);
+ break;
+ case GL_CLIP_PLANE5:
+ params[0] = BOOLEAN_TO_INT((ctx->Transform.ClipPlanesEnabled >> 5) & 1);
+ break;
+ case GL_COLOR_CLEAR_VALUE:
+ params[0] = FLOAT_TO_INT(ctx->Color.ClearColor[0]);
+ params[1] = FLOAT_TO_INT(ctx->Color.ClearColor[1]);
+ params[2] = FLOAT_TO_INT(ctx->Color.ClearColor[2]);
+ params[3] = FLOAT_TO_INT(ctx->Color.ClearColor[3]);
+ break;
+ case GL_COLOR_MATERIAL:
+ params[0] = BOOLEAN_TO_INT(ctx->Light.ColorMaterialEnabled);
+ break;
+ case GL_COLOR_MATERIAL_FACE:
+ params[0] = ENUM_TO_INT(ctx->Light.ColorMaterialFace);
+ break;
+ case GL_COLOR_MATERIAL_PARAMETER:
+ params[0] = ENUM_TO_INT(ctx->Light.ColorMaterialMode);
+ break;
+ case GL_COLOR_WRITEMASK:
+ params[0] = ctx->Color.ColorMask[RCOMP] ? 1 : 0;
+ params[1] = ctx->Color.ColorMask[GCOMP] ? 1 : 0;
+ params[2] = ctx->Color.ColorMask[BCOMP] ? 1 : 0;
+ params[3] = ctx->Color.ColorMask[ACOMP] ? 1 : 0;
+ break;
+ case GL_CULL_FACE:
+ params[0] = BOOLEAN_TO_INT(ctx->Polygon.CullFlag);
+ break;
+ case GL_CULL_FACE_MODE:
+ params[0] = ENUM_TO_INT(ctx->Polygon.CullFaceMode);
+ break;
+ case GL_CURRENT_COLOR:
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]);
+ params[1] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]);
+ params[2] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]);
+ params[3] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]);
+ }
+ break;
+ case GL_CURRENT_INDEX:
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = IROUND(ctx->Current.Index);
+ }
+ break;
+ case GL_CURRENT_NORMAL:
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]);
+ params[1] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]);
+ params[2] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]);
+ }
+ break;
+ case GL_CURRENT_RASTER_COLOR:
+ params[0] = FLOAT_TO_INT(ctx->Current.RasterColor[0]);
+ params[1] = FLOAT_TO_INT(ctx->Current.RasterColor[1]);
+ params[2] = FLOAT_TO_INT(ctx->Current.RasterColor[2]);
+ params[3] = FLOAT_TO_INT(ctx->Current.RasterColor[3]);
+ break;
+ case GL_CURRENT_RASTER_DISTANCE:
+ params[0] = IROUND(ctx->Current.RasterDistance);
+ break;
+ case GL_CURRENT_RASTER_INDEX:
+ params[0] = IROUND(ctx->Current.RasterIndex);
+ break;
+ case GL_CURRENT_RASTER_POSITION:
+ params[0] = IROUND(ctx->Current.RasterPos[0]);
+ params[1] = IROUND(ctx->Current.RasterPos[1]);
+ params[2] = IROUND(ctx->Current.RasterPos[2]);
+ params[3] = IROUND(ctx->Current.RasterPos[3]);
+ break;
+ case GL_CURRENT_RASTER_TEXTURE_COORDS:
+ {
+ const GLuint texUnit = ctx->Texture.CurrentUnit;
+ params[0] = IROUND(ctx->Current.RasterTexCoords[texUnit][0]);
+ params[1] = IROUND(ctx->Current.RasterTexCoords[texUnit][1]);
+ params[2] = IROUND(ctx->Current.RasterTexCoords[texUnit][2]);
+ params[3] = IROUND(ctx->Current.RasterTexCoords[texUnit][3]);
+ }
+ break;
+ case GL_CURRENT_RASTER_POSITION_VALID:
+ params[0] = BOOLEAN_TO_INT(ctx->Current.RasterPosValid);
+ break;
+ case GL_CURRENT_TEXTURE_COORDS:
+ {
+ const GLuint texUnit = ctx->Texture.CurrentUnit;
+ params[0] = IROUND(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][0]);
+ params[1] = IROUND(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][1]);
+ params[2] = IROUND(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][2]);
+ params[3] = IROUND(ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][3]);
+ }
+ break;
+ case GL_DEPTH_BIAS:
+ params[0] = IROUND(ctx->Pixel.DepthBias);
+ break;
+ case GL_DEPTH_BITS:
+ params[0] = ctx->DrawBuffer->Visual.depthBits;
+ break;
+ case GL_DEPTH_CLEAR_VALUE:
+ params[0] = IROUND(ctx->Depth.Clear);
+ break;
+ case GL_DEPTH_FUNC:
+ params[0] = ENUM_TO_INT(ctx->Depth.Func);
+ break;
+ case GL_DEPTH_RANGE:
+ params[0] = FLOAT_TO_INT(ctx->Viewport.Near);
+ params[1] = FLOAT_TO_INT(ctx->Viewport.Far);
+ break;
+ case GL_DEPTH_SCALE:
+ params[0] = IROUND(ctx->Pixel.DepthScale);
+ break;
+ case GL_DEPTH_TEST:
+ params[0] = BOOLEAN_TO_INT(ctx->Depth.Test);
+ break;
+ case GL_DEPTH_WRITEMASK:
+ params[0] = BOOLEAN_TO_INT(ctx->Depth.Mask);
+ break;
+ case GL_DITHER:
+ params[0] = BOOLEAN_TO_INT(ctx->Color.DitherFlag);
+ break;
+ case GL_DOUBLEBUFFER:
+ params[0] = BOOLEAN_TO_INT(ctx->DrawBuffer->Visual.doubleBufferMode);
+ break;
+ case GL_DRAW_BUFFER:
+ params[0] = ENUM_TO_INT(ctx->Color.DrawBuffer[0]);
+ break;
+ case GL_EDGE_FLAG:
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = BOOLEAN_TO_INT(ctx->Current.EdgeFlag);
+ }
+ break;
+ case GL_FEEDBACK_BUFFER_SIZE:
+ params[0] = ctx->Feedback.BufferSize;
+ break;
+ case GL_FEEDBACK_BUFFER_TYPE:
+ params[0] = ENUM_TO_INT(ctx->Feedback.Type);
+ break;
+ case GL_FOG:
+ params[0] = BOOLEAN_TO_INT(ctx->Fog.Enabled);
+ break;
+ case GL_FOG_COLOR:
+ params[0] = FLOAT_TO_INT(ctx->Fog.Color[0]);
+ params[1] = FLOAT_TO_INT(ctx->Fog.Color[1]);
+ params[2] = FLOAT_TO_INT(ctx->Fog.Color[2]);
+ params[3] = FLOAT_TO_INT(ctx->Fog.Color[3]);
+ break;
+ case GL_FOG_DENSITY:
+ params[0] = IROUND(ctx->Fog.Density);
+ break;
+ case GL_FOG_END:
+ params[0] = IROUND(ctx->Fog.End);
+ break;
+ case GL_FOG_HINT:
+ params[0] = ENUM_TO_INT(ctx->Hint.Fog);
+ break;
+ case GL_FOG_INDEX:
+ params[0] = IROUND(ctx->Fog.Index);
+ break;
+ case GL_FOG_MODE:
+ params[0] = ENUM_TO_INT(ctx->Fog.Mode);
+ break;
+ case GL_FOG_START:
+ params[0] = IROUND(ctx->Fog.Start);
+ break;
+ case GL_FRONT_FACE:
+ params[0] = ENUM_TO_INT(ctx->Polygon.FrontFace);
+ break;
+ case GL_GREEN_BIAS:
+ params[0] = IROUND(ctx->Pixel.GreenBias);
+ break;
+ case GL_GREEN_BITS:
+ params[0] = ctx->DrawBuffer->Visual.greenBits;
+ break;
+ case GL_GREEN_SCALE:
+ params[0] = IROUND(ctx->Pixel.GreenScale);
+ break;
+ case GL_INDEX_BITS:
+ params[0] = ctx->DrawBuffer->Visual.indexBits;
+ break;
+ case GL_INDEX_CLEAR_VALUE:
+ params[0] = ctx->Color.ClearIndex;
+ break;
+ case GL_INDEX_MODE:
+ params[0] = BOOLEAN_TO_INT(!ctx->DrawBuffer->Visual.rgbMode);
+ break;
+ case GL_INDEX_OFFSET:
+ params[0] = ctx->Pixel.IndexOffset;
+ break;
+ case GL_INDEX_SHIFT:
+ params[0] = ctx->Pixel.IndexShift;
+ break;
+ case GL_INDEX_WRITEMASK:
+ params[0] = ctx->Color.IndexMask;
+ break;
+ case GL_LIGHT0:
+ params[0] = BOOLEAN_TO_INT(ctx->Light.Light[0].Enabled);
+ break;
+ case GL_LIGHT1:
+ params[0] = BOOLEAN_TO_INT(ctx->Light.Light[1].Enabled);
+ break;
+ case GL_LIGHT2:
+ params[0] = BOOLEAN_TO_INT(ctx->Light.Light[2].Enabled);
+ break;
+ case GL_LIGHT3:
+ params[0] = BOOLEAN_TO_INT(ctx->Light.Light[3].Enabled);
+ break;
+ case GL_LIGHT4:
+ params[0] = BOOLEAN_TO_INT(ctx->Light.Light[4].Enabled);
+ break;
+ case GL_LIGHT5:
+ params[0] = BOOLEAN_TO_INT(ctx->Light.Light[5].Enabled);
+ break;
+ case GL_LIGHT6:
+ params[0] = BOOLEAN_TO_INT(ctx->Light.Light[6].Enabled);
+ break;
+ case GL_LIGHT7:
+ params[0] = BOOLEAN_TO_INT(ctx->Light.Light[7].Enabled);
+ break;
+ case GL_LIGHTING:
+ params[0] = BOOLEAN_TO_INT(ctx->Light.Enabled);
+ break;
+ case GL_LIGHT_MODEL_AMBIENT:
+ params[0] = FLOAT_TO_INT(ctx->Light.Model.Ambient[0]);
+ params[1] = FLOAT_TO_INT(ctx->Light.Model.Ambient[1]);
+ params[2] = FLOAT_TO_INT(ctx->Light.Model.Ambient[2]);
+ params[3] = FLOAT_TO_INT(ctx->Light.Model.Ambient[3]);
+ break;
+ case GL_LIGHT_MODEL_COLOR_CONTROL:
+ params[0] = ENUM_TO_INT(ctx->Light.Model.ColorControl);
+ break;
+ case GL_LIGHT_MODEL_LOCAL_VIEWER:
+ params[0] = BOOLEAN_TO_INT(ctx->Light.Model.LocalViewer);
+ break;
+ case GL_LIGHT_MODEL_TWO_SIDE:
+ params[0] = BOOLEAN_TO_INT(ctx->Light.Model.TwoSide);
+ break;
+ case GL_LINE_SMOOTH:
+ params[0] = BOOLEAN_TO_INT(ctx->Line.SmoothFlag);
+ break;
+ case GL_LINE_SMOOTH_HINT:
+ params[0] = ENUM_TO_INT(ctx->Hint.LineSmooth);
+ break;
+ case GL_LINE_STIPPLE:
+ params[0] = BOOLEAN_TO_INT(ctx->Line.StippleFlag);
+ break;
+ case GL_LINE_STIPPLE_PATTERN:
+ params[0] = ctx->Line.StipplePattern;
+ break;
+ case GL_LINE_STIPPLE_REPEAT:
+ params[0] = ctx->Line.StippleFactor;
+ break;
+ case GL_LINE_WIDTH:
+ params[0] = IROUND(ctx->Line.Width);
+ break;
+ case GL_LINE_WIDTH_GRANULARITY:
+ params[0] = IROUND(ctx->Const.LineWidthGranularity);
+ break;
+ case GL_LINE_WIDTH_RANGE:
+ params[0] = IROUND(ctx->Const.MinLineWidthAA);
+ params[1] = IROUND(ctx->Const.MaxLineWidthAA);
+ break;
+ case GL_ALIASED_LINE_WIDTH_RANGE:
+ params[0] = IROUND(ctx->Const.MinLineWidth);
+ params[1] = IROUND(ctx->Const.MaxLineWidth);
+ break;
+ case GL_LIST_BASE:
+ params[0] = ctx->List.ListBase;
+ break;
+ case GL_LIST_INDEX:
+ params[0] = ctx->ListState.CurrentListNum;
+ break;
+ case GL_LIST_MODE:
+ {
+ GLenum mode;
+ if (!ctx->CompileFlag)
+ mode = 0;
+ else if (ctx->ExecuteFlag)
+ mode = GL_COMPILE_AND_EXECUTE;
+ else
+ mode = GL_COMPILE;
+ params[0] = ENUM_TO_INT(mode);
+ }
+ break;
+ case GL_INDEX_LOGIC_OP:
+ params[0] = BOOLEAN_TO_INT(ctx->Color.IndexLogicOpEnabled);
+ break;
+ case GL_COLOR_LOGIC_OP:
+ params[0] = BOOLEAN_TO_INT(ctx->Color.ColorLogicOpEnabled);
+ break;
+ case GL_LOGIC_OP_MODE:
+ params[0] = ENUM_TO_INT(ctx->Color.LogicOp);
+ break;
+ case GL_MAP1_COLOR_4:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Color4);
+ break;
+ case GL_MAP1_GRID_DOMAIN:
+ params[0] = IROUND(ctx->Eval.MapGrid1u1);
+ params[1] = IROUND(ctx->Eval.MapGrid1u2);
+ break;
+ case GL_MAP1_GRID_SEGMENTS:
+ params[0] = ctx->Eval.MapGrid1un;
+ break;
+ case GL_MAP1_INDEX:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Index);
+ break;
+ case GL_MAP1_NORMAL:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Normal);
+ break;
+ case GL_MAP1_TEXTURE_COORD_1:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1TextureCoord1);
+ break;
+ case GL_MAP1_TEXTURE_COORD_2:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1TextureCoord2);
+ break;
+ case GL_MAP1_TEXTURE_COORD_3:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1TextureCoord3);
+ break;
+ case GL_MAP1_TEXTURE_COORD_4:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1TextureCoord4);
+ break;
+ case GL_MAP1_VERTEX_3:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Vertex3);
+ break;
+ case GL_MAP1_VERTEX_4:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Vertex4);
+ break;
+ case GL_MAP2_COLOR_4:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2Color4);
+ break;
+ case GL_MAP2_GRID_DOMAIN:
+ params[0] = IROUND(ctx->Eval.MapGrid2u1);
+ params[1] = IROUND(ctx->Eval.MapGrid2u2);
+ params[2] = IROUND(ctx->Eval.MapGrid2v1);
+ params[3] = IROUND(ctx->Eval.MapGrid2v2);
+ break;
+ case GL_MAP2_GRID_SEGMENTS:
+ params[0] = ctx->Eval.MapGrid2un;
+ params[1] = ctx->Eval.MapGrid2vn;
+ break;
+ case GL_MAP2_INDEX:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2Index);
+ break;
+ case GL_MAP2_NORMAL:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2Normal);
+ break;
+ case GL_MAP2_TEXTURE_COORD_1:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2TextureCoord1);
+ break;
+ case GL_MAP2_TEXTURE_COORD_2:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2TextureCoord2);
+ break;
+ case GL_MAP2_TEXTURE_COORD_3:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2TextureCoord3);
+ break;
+ case GL_MAP2_TEXTURE_COORD_4:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2TextureCoord4);
+ break;
+ case GL_MAP2_VERTEX_3:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2Vertex3);
+ break;
+ case GL_MAP2_VERTEX_4:
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map2Vertex4);
+ break;
+ case GL_MAP_COLOR:
+ params[0] = BOOLEAN_TO_INT(ctx->Pixel.MapColorFlag);
+ break;
+ case GL_MAP_STENCIL:
+ params[0] = BOOLEAN_TO_INT(ctx->Pixel.MapStencilFlag);
+ break;
+ case GL_MATRIX_MODE:
+ params[0] = ENUM_TO_INT(ctx->Transform.MatrixMode);
+ break;
+ case GL_MAX_ATTRIB_STACK_DEPTH:
+ params[0] = MAX_ATTRIB_STACK_DEPTH;
+ break;
+ case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
+ params[0] = MAX_CLIENT_ATTRIB_STACK_DEPTH;
+ break;
+ case GL_MAX_CLIP_PLANES:
+ params[0] = ctx->Const.MaxClipPlanes;
+ break;
+ case GL_MAX_ELEMENTS_VERTICES:
+ params[0] = ctx->Const.MaxArrayLockSize;
+ break;
+ case GL_MAX_ELEMENTS_INDICES:
+ params[0] = ctx->Const.MaxArrayLockSize;
+ break;
+ case GL_MAX_EVAL_ORDER:
+ params[0] = MAX_EVAL_ORDER;
+ break;
+ case GL_MAX_LIGHTS:
+ params[0] = ctx->Const.MaxLights;
+ break;
+ case GL_MAX_LIST_NESTING:
+ params[0] = MAX_LIST_NESTING;
+ break;
+ case GL_MAX_MODELVIEW_STACK_DEPTH:
+ params[0] = MAX_MODELVIEW_STACK_DEPTH;
+ break;
+ case GL_MAX_NAME_STACK_DEPTH:
+ params[0] = MAX_NAME_STACK_DEPTH;
+ break;
+ case GL_MAX_PIXEL_MAP_TABLE:
+ params[0] = MAX_PIXEL_MAP_TABLE;
+ break;
+ case GL_MAX_PROJECTION_STACK_DEPTH:
+ params[0] = MAX_PROJECTION_STACK_DEPTH;
+ break;
+ case GL_MAX_TEXTURE_SIZE:
+ params[0] = 1 << (ctx->Const.MaxTextureLevels - 1);
+ break;
+ case GL_MAX_3D_TEXTURE_SIZE:
+ params[0] = 1 << (ctx->Const.Max3DTextureLevels - 1);
+ break;
+ case GL_MAX_TEXTURE_STACK_DEPTH:
+ params[0] = MAX_TEXTURE_STACK_DEPTH;
+ break;
+ case GL_MAX_VIEWPORT_DIMS:
+ params[0] = ctx->Const.MaxViewportWidth;
+ params[1] = ctx->Const.MaxViewportHeight;
+ break;
+ case GL_MODELVIEW_MATRIX:
+ {
+ const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;
+ params[0] = IROUND(matrix[0]);
+ params[1] = IROUND(matrix[1]);
+ params[2] = IROUND(matrix[2]);
+ params[3] = IROUND(matrix[3]);
+ params[4] = IROUND(matrix[4]);
+ params[5] = IROUND(matrix[5]);
+ params[6] = IROUND(matrix[6]);
+ params[7] = IROUND(matrix[7]);
+ params[8] = IROUND(matrix[8]);
+ params[9] = IROUND(matrix[9]);
+ params[10] = IROUND(matrix[10]);
+ params[11] = IROUND(matrix[11]);
+ params[12] = IROUND(matrix[12]);
+ params[13] = IROUND(matrix[13]);
+ params[14] = IROUND(matrix[14]);
+ params[15] = IROUND(matrix[15]);
+ }
+ break;
+ case GL_MODELVIEW_STACK_DEPTH:
+ params[0] = ctx->ModelviewMatrixStack.Depth + 1;
+ break;
+ case GL_NAME_STACK_DEPTH:
+ params[0] = ctx->Select.NameStackDepth;
+ break;
+ case GL_NORMALIZE:
+ params[0] = BOOLEAN_TO_INT(ctx->Transform.Normalize);
+ break;
+ case GL_PACK_ALIGNMENT:
+ params[0] = ctx->Pack.Alignment;
+ break;
+ case GL_PACK_LSB_FIRST:
+ params[0] = BOOLEAN_TO_INT(ctx->Pack.LsbFirst);
+ break;
+ case GL_PACK_ROW_LENGTH:
+ params[0] = ctx->Pack.RowLength;
+ break;
+ case GL_PACK_SKIP_PIXELS:
+ params[0] = ctx->Pack.SkipPixels;
+ break;
+ case GL_PACK_SKIP_ROWS:
+ params[0] = ctx->Pack.SkipRows;
+ break;
+ case GL_PACK_SWAP_BYTES:
+ params[0] = BOOLEAN_TO_INT(ctx->Pack.SwapBytes);
+ break;
+ case GL_PACK_SKIP_IMAGES_EXT:
+ params[0] = ctx->Pack.SkipImages;
+ break;
+ case GL_PACK_IMAGE_HEIGHT_EXT:
+ params[0] = ctx->Pack.ImageHeight;
+ break;
+ case GL_PACK_INVERT_MESA:
+ params[0] = BOOLEAN_TO_INT(ctx->Pack.Invert);
+ break;
+ case GL_PERSPECTIVE_CORRECTION_HINT:
+ params[0] = ENUM_TO_INT(ctx->Hint.PerspectiveCorrection);
+ break;
+ case GL_PIXEL_MAP_A_TO_A_SIZE:
+ params[0] = ctx->Pixel.MapAtoAsize;
+ break;
+ case GL_PIXEL_MAP_B_TO_B_SIZE:
+ params[0] = ctx->Pixel.MapBtoBsize;
+ break;
+ case GL_PIXEL_MAP_G_TO_G_SIZE:
+ params[0] = ctx->Pixel.MapGtoGsize;
+ break;
+ case GL_PIXEL_MAP_I_TO_A_SIZE:
+ params[0] = ctx->Pixel.MapItoAsize;
+ break;
+ case GL_PIXEL_MAP_I_TO_B_SIZE:
+ params[0] = ctx->Pixel.MapItoBsize;
+ break;
+ case GL_PIXEL_MAP_I_TO_G_SIZE:
+ params[0] = ctx->Pixel.MapItoGsize;
+ break;
+ case GL_PIXEL_MAP_I_TO_I_SIZE:
+ params[0] = ctx->Pixel.MapItoIsize;
+ break;
+ case GL_PIXEL_MAP_I_TO_R_SIZE:
+ params[0] = ctx->Pixel.MapItoRsize;
+ break;
+ case GL_PIXEL_MAP_R_TO_R_SIZE:
+ params[0] = ctx->Pixel.MapRtoRsize;
+ break;
+ case GL_PIXEL_MAP_S_TO_S_SIZE:
+ params[0] = ctx->Pixel.MapStoSsize;
+ break;
+ case GL_POINT_SIZE:
+ params[0] = IROUND(ctx->Point.Size);
+ break;
+ case GL_POINT_SIZE_GRANULARITY:
+ params[0] = IROUND(ctx->Const.PointSizeGranularity);
+ break;
+ case GL_POINT_SIZE_RANGE:
+ params[0] = IROUND(ctx->Const.MinPointSizeAA);
+ params[1] = IROUND(ctx->Const.MaxPointSizeAA);
+ break;
+ case GL_ALIASED_POINT_SIZE_RANGE:
+ params[0] = IROUND(ctx->Const.MinPointSize);
+ params[1] = IROUND(ctx->Const.MaxPointSize);
+ break;
+ case GL_POINT_SMOOTH:
+ params[0] = BOOLEAN_TO_INT(ctx->Point.SmoothFlag);
+ break;
+ case GL_POINT_SMOOTH_HINT:
+ params[0] = ENUM_TO_INT(ctx->Hint.PointSmooth);
+ break;
+ case GL_POINT_SIZE_MIN_EXT:
+ params[0] = IROUND(ctx->Point.MinSize);
+ break;
+ case GL_POINT_SIZE_MAX_EXT:
+ params[0] = IROUND(ctx->Point.MaxSize);
+ break;
+ case GL_POINT_FADE_THRESHOLD_SIZE_EXT:
+ params[0] = IROUND(ctx->Point.Threshold);
+ break;
+ case GL_DISTANCE_ATTENUATION_EXT:
+ params[0] = IROUND(ctx->Point.Params[0]);
+ params[1] = IROUND(ctx->Point.Params[1]);
+ params[2] = IROUND(ctx->Point.Params[2]);
+ break;
+ case GL_POLYGON_MODE:
+ params[0] = ENUM_TO_INT(ctx->Polygon.FrontMode);
+ params[1] = ENUM_TO_INT(ctx->Polygon.BackMode);
+ break;
+ case GL_POLYGON_OFFSET_BIAS_EXT:
+ params[0] = IROUND(ctx->Polygon.OffsetUnits);
+ break;
+ case GL_POLYGON_OFFSET_FACTOR:
+ params[0] = IROUND(ctx->Polygon.OffsetFactor );
+ break;
+ case GL_POLYGON_OFFSET_UNITS:
+ params[0] = IROUND(ctx->Polygon.OffsetUnits );
+ break;
+ case GL_POLYGON_SMOOTH:
+ params[0] = BOOLEAN_TO_INT(ctx->Polygon.SmoothFlag);
+ break;
+ case GL_POLYGON_SMOOTH_HINT:
+ params[0] = ENUM_TO_INT(ctx->Hint.PolygonSmooth);
+ break;
+ case GL_POLYGON_STIPPLE:
+ params[0] = BOOLEAN_TO_INT(ctx->Polygon.StippleFlag);
+ break;
+ case GL_PROJECTION_MATRIX:
+ {
+ const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;
+ params[0] = IROUND(matrix[0]);
+ params[1] = IROUND(matrix[1]);
+ params[2] = IROUND(matrix[2]);
+ params[3] = IROUND(matrix[3]);
+ params[4] = IROUND(matrix[4]);
+ params[5] = IROUND(matrix[5]);
+ params[6] = IROUND(matrix[6]);
+ params[7] = IROUND(matrix[7]);
+ params[8] = IROUND(matrix[8]);
+ params[9] = IROUND(matrix[9]);
+ params[10] = IROUND(matrix[10]);
+ params[11] = IROUND(matrix[11]);
+ params[12] = IROUND(matrix[12]);
+ params[13] = IROUND(matrix[13]);
+ params[14] = IROUND(matrix[14]);
+ params[15] = IROUND(matrix[15]);
+ }
+ break;
+ case GL_PROJECTION_STACK_DEPTH:
+ params[0] = ctx->ProjectionMatrixStack.Depth + 1;
+ break;
+ case GL_READ_BUFFER:
+ params[0] = ENUM_TO_INT(ctx->Pixel.ReadBuffer);
+ break;
+ case GL_RED_BIAS:
+ params[0] = IROUND(ctx->Pixel.RedBias);
+ break;
+ case GL_RED_BITS:
+ params[0] = ctx->DrawBuffer->Visual.redBits ;
+ break;
+ case GL_RED_SCALE:
+ params[0] = IROUND(ctx->Pixel.RedScale);
+ break;
+ case GL_RENDER_MODE:
+ params[0] = ENUM_TO_INT(ctx->RenderMode);
+ break;
+ case GL_RESCALE_NORMAL:
+ params[0] = BOOLEAN_TO_INT(ctx->Transform.RescaleNormals);
+ break;
+ case GL_RGBA_MODE:
+ params[0] = BOOLEAN_TO_INT(ctx->DrawBuffer->Visual.rgbMode);
+ break;
+ case GL_SCISSOR_BOX:
+ params[0] = ctx->Scissor.X;
+ params[1] = ctx->Scissor.Y;
+ params[2] = ctx->Scissor.Width;
+ params[3] = ctx->Scissor.Height;
+ break;
+ case GL_SCISSOR_TEST:
+ params[0] = BOOLEAN_TO_INT(ctx->Scissor.Enabled);
+ break;
+ case GL_SELECTION_BUFFER_SIZE:
+ params[0] = ctx->Select.BufferSize;
+ break;
+ case GL_SHADE_MODEL:
+ params[0] = ENUM_TO_INT(ctx->Light.ShadeModel);
+ break;
+ case GL_SHARED_TEXTURE_PALETTE_EXT:
+ params[0] = BOOLEAN_TO_INT(ctx->Texture.SharedPalette);
+ break;
+ case GL_STENCIL_BITS:
+ params[0] = ctx->DrawBuffer->Visual.stencilBits;
+ break;
+ case GL_STENCIL_CLEAR_VALUE:
+ params[0] = ctx->Stencil.Clear;
+ break;
+ case GL_STENCIL_FAIL:
+ params[0] = ENUM_TO_INT(ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STENCIL_FUNC:
+ params[0] = ENUM_TO_INT(ctx->Stencil.Function[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STENCIL_PASS_DEPTH_FAIL:
+ params[0] = ENUM_TO_INT(ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STENCIL_PASS_DEPTH_PASS:
+ params[0] = ENUM_TO_INT(ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]);
+ break;
+ case GL_STENCIL_REF:
+ params[0] = ctx->Stencil.Ref[ctx->Stencil.ActiveFace];
+ break;
+ case GL_STENCIL_TEST:
+ params[0] = BOOLEAN_TO_INT(ctx->Stencil.Enabled);
+ break;
+ case GL_STENCIL_VALUE_MASK:
+ params[0] = ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace];
+ break;
+ case GL_STENCIL_WRITEMASK:
+ params[0] = ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace];
+ break;
+ case GL_STEREO:
+ params[0] = BOOLEAN_TO_INT(ctx->DrawBuffer->Visual.stereoMode);
+ break;
+ case GL_SUBPIXEL_BITS:
+ params[0] = ctx->Const.SubPixelBits;
+ break;
+ case GL_TEXTURE_1D:
+ params[0] = BOOLEAN_TO_INT(_mesa_IsEnabled(GL_TEXTURE_1D));
+ break;
+ case GL_TEXTURE_2D:
+ params[0] = BOOLEAN_TO_INT(_mesa_IsEnabled(GL_TEXTURE_2D));
+ break;
+ case GL_TEXTURE_3D:
+ params[0] = BOOLEAN_TO_INT(_mesa_IsEnabled(GL_TEXTURE_3D));
+ break;
+ case GL_TEXTURE_BINDING_1D:
+ params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current1D->Name;
+ break;
+ case GL_TEXTURE_BINDING_2D:
+ params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current2D->Name;
+ break;
+ case GL_TEXTURE_BINDING_3D:
+ params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current3D->Name;
+ break;
+ case GL_TEXTURE_ENV_COLOR:
+ {
+ const GLfloat *color = ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvColor;
+ params[0] = FLOAT_TO_INT(color[0]);
+ params[1] = FLOAT_TO_INT(color[1]);
+ params[2] = FLOAT_TO_INT(color[2]);
+ params[3] = FLOAT_TO_INT(color[3]);
+ }
+ break;
+ case GL_TEXTURE_ENV_MODE:
+ params[0] = ENUM_TO_INT(ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvMode);
+ break;
+ case GL_TEXTURE_GEN_S:
+ params[0] = BOOLEAN_TO_INT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0));
+ break;
+ case GL_TEXTURE_GEN_T:
+ params[0] = BOOLEAN_TO_INT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & T_BIT) ? 1 : 0));
+ break;
+ case GL_TEXTURE_GEN_R:
+ params[0] = BOOLEAN_TO_INT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & R_BIT) ? 1 : 0));
+ break;
+ case GL_TEXTURE_GEN_Q:
+ params[0] = BOOLEAN_TO_INT(((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & Q_BIT) ? 1 : 0));
+ break;
+ case GL_TEXTURE_MATRIX:
+ {
+ const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;
+ params[0] = IROUND(matrix[0]);
+ params[1] = IROUND(matrix[1]);
+ params[2] = IROUND(matrix[2]);
+ params[3] = IROUND(matrix[3]);
+ params[4] = IROUND(matrix[4]);
+ params[5] = IROUND(matrix[5]);
+ params[6] = IROUND(matrix[6]);
+ params[7] = IROUND(matrix[7]);
+ params[8] = IROUND(matrix[8]);
+ params[9] = IROUND(matrix[9]);
+ params[10] = IROUND(matrix[10]);
+ params[11] = IROUND(matrix[11]);
+ params[12] = IROUND(matrix[12]);
+ params[13] = IROUND(matrix[13]);
+ params[14] = IROUND(matrix[14]);
+ params[15] = IROUND(matrix[15]);
+ }
+ break;
+ case GL_TEXTURE_STACK_DEPTH:
+ params[0] = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Depth + 1;
+ break;
+ case GL_UNPACK_ALIGNMENT:
+ params[0] = ctx->Unpack.Alignment;
+ break;
+ case GL_UNPACK_LSB_FIRST:
+ params[0] = BOOLEAN_TO_INT(ctx->Unpack.LsbFirst);
+ break;
+ case GL_UNPACK_ROW_LENGTH:
+ params[0] = ctx->Unpack.RowLength;
+ break;
+ case GL_UNPACK_SKIP_PIXELS:
+ params[0] = ctx->Unpack.SkipPixels;
+ break;
+ case GL_UNPACK_SKIP_ROWS:
+ params[0] = ctx->Unpack.SkipRows;
+ break;
+ case GL_UNPACK_SWAP_BYTES:
+ params[0] = BOOLEAN_TO_INT(ctx->Unpack.SwapBytes);
+ break;
+ case GL_UNPACK_SKIP_IMAGES_EXT:
+ params[0] = ctx->Unpack.SkipImages;
+ break;
+ case GL_UNPACK_IMAGE_HEIGHT_EXT:
+ params[0] = ctx->Unpack.ImageHeight;
+ break;
+ case GL_UNPACK_CLIENT_STORAGE_APPLE:
+ params[0] = BOOLEAN_TO_INT(ctx->Unpack.ClientStorage);
+ break;
+ case GL_VIEWPORT:
+ params[0] = ctx->Viewport.X;
+ params[1] = ctx->Viewport.Y;
+ params[2] = ctx->Viewport.Width;
+ params[3] = ctx->Viewport.Height;
+ break;
+ case GL_ZOOM_X:
+ params[0] = IROUND(ctx->Pixel.ZoomX);
+ break;
+ case GL_ZOOM_Y:
+ params[0] = IROUND(ctx->Pixel.ZoomY);
+ break;
+ case GL_VERTEX_ARRAY:
+ params[0] = BOOLEAN_TO_INT(ctx->Array.Vertex.Enabled);
+ break;
+ case GL_VERTEX_ARRAY_SIZE:
+ params[0] = ctx->Array.Vertex.Size;
+ break;
+ case GL_VERTEX_ARRAY_TYPE:
+ params[0] = ENUM_TO_INT(ctx->Array.Vertex.Type);
+ break;
+ case GL_VERTEX_ARRAY_STRIDE:
+ params[0] = ctx->Array.Vertex.Stride;
+ break;
+ case GL_VERTEX_ARRAY_COUNT_EXT:
+ params[0] = 0;
+ break;
+ case GL_NORMAL_ARRAY:
+ params[0] = ENUM_TO_INT(ctx->Array.Normal.Enabled);
+ break;
+ case GL_NORMAL_ARRAY_TYPE:
+ params[0] = ENUM_TO_INT(ctx->Array.Normal.Type);
+ break;
+ case GL_NORMAL_ARRAY_STRIDE:
+ params[0] = ctx->Array.Normal.Stride;
+ break;
+ case GL_NORMAL_ARRAY_COUNT_EXT:
+ params[0] = 0;
+ break;
+ case GL_COLOR_ARRAY:
+ params[0] = BOOLEAN_TO_INT(ctx->Array.Color.Enabled);
+ break;
+ case GL_COLOR_ARRAY_SIZE:
+ params[0] = ctx->Array.Color.Size;
+ break;
+ case GL_COLOR_ARRAY_TYPE:
+ params[0] = ENUM_TO_INT(ctx->Array.Color.Type);
+ break;
+ case GL_COLOR_ARRAY_STRIDE:
+ params[0] = ctx->Array.Color.Stride;
+ break;
+ case GL_COLOR_ARRAY_COUNT_EXT:
+ params[0] = 0;
+ break;
+ case GL_INDEX_ARRAY:
+ params[0] = BOOLEAN_TO_INT(ctx->Array.Index.Enabled);
+ break;
+ case GL_INDEX_ARRAY_TYPE:
+ params[0] = ENUM_TO_INT(ctx->Array.Index.Type);
+ break;
+ case GL_INDEX_ARRAY_STRIDE:
+ params[0] = ctx->Array.Index.Stride;
+ break;
+ case GL_INDEX_ARRAY_COUNT_EXT:
+ params[0] = 0;
+ break;
+ case GL_TEXTURE_COORD_ARRAY:
+ params[0] = BOOLEAN_TO_INT(ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_SIZE:
+ params[0] = ctx->Array.TexCoord[ctx->Array.ActiveTexture].Size;
+ break;
+ case GL_TEXTURE_COORD_ARRAY_TYPE:
+ params[0] = ENUM_TO_INT(ctx->Array.TexCoord[ctx->Array.ActiveTexture].Type);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_STRIDE:
+ params[0] = ctx->Array.TexCoord[ctx->Array.ActiveTexture].Stride;
+ break;
+ case GL_TEXTURE_COORD_ARRAY_COUNT_EXT:
+ params[0] = 0;
+ break;
+ case GL_EDGE_FLAG_ARRAY:
+ params[0] = BOOLEAN_TO_INT(ctx->Array.EdgeFlag.Enabled);
+ break;
+ case GL_EDGE_FLAG_ARRAY_STRIDE:
+ params[0] = ctx->Array.EdgeFlag.Stride;
+ break;
+ case GL_EDGE_FLAG_ARRAY_COUNT_EXT:
+ params[0] = 0;
+ break;
+ case GL_MAX_TEXTURE_UNITS_ARB:
+ CHECK_EXTENSION_I(ARB_multitexture, pname);
+ params[0] = MIN2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits);
+ break;
+ case GL_ACTIVE_TEXTURE_ARB:
+ CHECK_EXTENSION_I(ARB_multitexture, pname);
+ params[0] = GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit;
+ break;
+ case GL_CLIENT_ACTIVE_TEXTURE_ARB:
+ CHECK_EXTENSION_I(ARB_multitexture, pname);
+ params[0] = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture;
+ break;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ CHECK_EXTENSION_I(ARB_texture_cube_map, pname);
+ params[0] = BOOLEAN_TO_INT(_mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB));
+ break;
+ case GL_TEXTURE_BINDING_CUBE_MAP_ARB:
+ CHECK_EXTENSION_I(ARB_texture_cube_map, pname);
+ params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentCubeMap->Name;
+ break;
+ case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB:
+ CHECK_EXTENSION_I(ARB_texture_cube_map, pname);
+ params[0] = (1 << (ctx->Const.MaxCubeTextureLevels - 1));
+ break;
+ case GL_TEXTURE_COMPRESSION_HINT_ARB:
+ CHECK_EXTENSION_I(ARB_texture_compression, pname);
+ params[0] = ctx->Hint.TextureCompression;
+ break;
+ case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB:
+ CHECK_EXTENSION_I(ARB_texture_compression, pname);
+ params[0] = _mesa_get_compressed_formats(ctx, NULL);
+ break;
+ case GL_COMPRESSED_TEXTURE_FORMATS_ARB:
+ CHECK_EXTENSION_I(ARB_texture_compression, pname);
+ {
+ GLint formats[100];
+ GLuint i, n = _mesa_get_compressed_formats(ctx, formats);
+ ASSERT(n <= 100);
+ for (i = 0; i < n; i++)
+ params[i] = ENUM_TO_INT(formats[i]);
+ }
+ break;
+ case GL_ARRAY_ELEMENT_LOCK_FIRST_EXT:
+ CHECK_EXTENSION_I(EXT_compiled_vertex_array, pname);
+ params[0] = ctx->Array.LockFirst;
+ break;
+ case GL_ARRAY_ELEMENT_LOCK_COUNT_EXT:
+ CHECK_EXTENSION_I(EXT_compiled_vertex_array, pname);
+ params[0] = ctx->Array.LockCount;
+ break;
+ case GL_TRANSPOSE_COLOR_MATRIX_ARB:
+ {
+ const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;
+ params[0] = IROUND(matrix[0]);
+ params[1] = IROUND(matrix[4]);
+ params[2] = IROUND(matrix[8]);
+ params[3] = IROUND(matrix[12]);
+ params[4] = IROUND(matrix[1]);
+ params[5] = IROUND(matrix[5]);
+ params[6] = IROUND(matrix[9]);
+ params[7] = IROUND(matrix[13]);
+ params[8] = IROUND(matrix[2]);
+ params[9] = IROUND(matrix[6]);
+ params[10] = IROUND(matrix[10]);
+ params[11] = IROUND(matrix[14]);
+ params[12] = IROUND(matrix[3]);
+ params[13] = IROUND(matrix[7]);
+ params[14] = IROUND(matrix[11]);
+ params[15] = IROUND(matrix[15]);
+ }
+ break;
+ case GL_TRANSPOSE_MODELVIEW_MATRIX_ARB:
+ {
+ const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;
+ params[0] = IROUND(matrix[0]);
+ params[1] = IROUND(matrix[4]);
+ params[2] = IROUND(matrix[8]);
+ params[3] = IROUND(matrix[12]);
+ params[4] = IROUND(matrix[1]);
+ params[5] = IROUND(matrix[5]);
+ params[6] = IROUND(matrix[9]);
+ params[7] = IROUND(matrix[13]);
+ params[8] = IROUND(matrix[2]);
+ params[9] = IROUND(matrix[6]);
+ params[10] = IROUND(matrix[10]);
+ params[11] = IROUND(matrix[14]);
+ params[12] = IROUND(matrix[3]);
+ params[13] = IROUND(matrix[7]);
+ params[14] = IROUND(matrix[11]);
+ params[15] = IROUND(matrix[15]);
+ }
+ break;
+ case GL_TRANSPOSE_PROJECTION_MATRIX_ARB:
+ {
+ const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;
+ params[0] = IROUND(matrix[0]);
+ params[1] = IROUND(matrix[4]);
+ params[2] = IROUND(matrix[8]);
+ params[3] = IROUND(matrix[12]);
+ params[4] = IROUND(matrix[1]);
+ params[5] = IROUND(matrix[5]);
+ params[6] = IROUND(matrix[9]);
+ params[7] = IROUND(matrix[13]);
+ params[8] = IROUND(matrix[2]);
+ params[9] = IROUND(matrix[6]);
+ params[10] = IROUND(matrix[10]);
+ params[11] = IROUND(matrix[14]);
+ params[12] = IROUND(matrix[3]);
+ params[13] = IROUND(matrix[7]);
+ params[14] = IROUND(matrix[11]);
+ params[15] = IROUND(matrix[15]);
+ }
+ break;
+ case GL_TRANSPOSE_TEXTURE_MATRIX_ARB:
+ {
+ const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;
+ params[0] = IROUND(matrix[0]);
+ params[1] = IROUND(matrix[4]);
+ params[2] = IROUND(matrix[8]);
+ params[3] = IROUND(matrix[12]);
+ params[4] = IROUND(matrix[1]);
+ params[5] = IROUND(matrix[5]);
+ params[6] = IROUND(matrix[9]);
+ params[7] = IROUND(matrix[13]);
+ params[8] = IROUND(matrix[2]);
+ params[9] = IROUND(matrix[6]);
+ params[10] = IROUND(matrix[10]);
+ params[11] = IROUND(matrix[14]);
+ params[12] = IROUND(matrix[3]);
+ params[13] = IROUND(matrix[7]);
+ params[14] = IROUND(matrix[11]);
+ params[15] = IROUND(matrix[15]);
+ }
+ break;
+ case GL_OCCLUSION_TEST_HP:
+ CHECK_EXTENSION_I(HP_occlusion_test, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Depth.OcclusionTest);
+ break;
+ case GL_OCCLUSION_TEST_RESULT_HP:
+ CHECK_EXTENSION_I(HP_occlusion_test, pname);
+ {
+ FLUSH_VERTICES(ctx, _NEW_DEPTH);
+ if (ctx->Depth.OcclusionTest)
+ params[0] = ctx->OcclusionResult;
+ else
+ params[0] = ctx->OcclusionResultSaved;
+ /* reset flag now */
+ ctx->OcclusionResult = GL_FALSE;
+ ctx->OcclusionResultSaved = GL_FALSE;
+ return;
+ }
+ break;
+ case GL_PIXEL_TEXTURE_SGIS:
+ CHECK_EXTENSION_I(SGIS_pixel_texture, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Pixel.PixelTextureEnabled);
+ break;
+ case GL_PIXEL_TEX_GEN_SGIX:
+ CHECK_EXTENSION_I(SGIX_pixel_texture, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Pixel.PixelTextureEnabled);
+ break;
+ case GL_PIXEL_TEX_GEN_MODE_SGIX:
+ CHECK_EXTENSION_I(SGIX_pixel_texture, pname);
+ params[0] = ENUM_TO_INT(pixel_texgen_mode(ctx));
+ break;
+ case GL_COLOR_MATRIX_SGI:
+ {
+ const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;
+ params[0] = IROUND(matrix[0]);
+ params[1] = IROUND(matrix[1]);
+ params[2] = IROUND(matrix[2]);
+ params[3] = IROUND(matrix[3]);
+ params[4] = IROUND(matrix[4]);
+ params[5] = IROUND(matrix[5]);
+ params[6] = IROUND(matrix[6]);
+ params[7] = IROUND(matrix[7]);
+ params[8] = IROUND(matrix[8]);
+ params[9] = IROUND(matrix[9]);
+ params[10] = IROUND(matrix[10]);
+ params[11] = IROUND(matrix[11]);
+ params[12] = IROUND(matrix[12]);
+ params[13] = IROUND(matrix[13]);
+ params[14] = IROUND(matrix[14]);
+ params[15] = IROUND(matrix[15]);
+ }
+ break;
+ case GL_COLOR_MATRIX_STACK_DEPTH_SGI:
+ params[0] = ctx->ColorMatrixStack.Depth + 1;
+ break;
+ case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI:
+ params[0] = MAX_COLOR_STACK_DEPTH;
+ break;
+ case GL_POST_COLOR_MATRIX_RED_SCALE_SGI:
+ params[0] = IROUND(ctx->Pixel.PostColorMatrixScale[0]);
+ break;
+ case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI:
+ params[0] = IROUND(ctx->Pixel.PostColorMatrixScale[1]);
+ break;
+ case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI:
+ params[0] = IROUND(ctx->Pixel.PostColorMatrixScale[2]);
+ break;
+ case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI:
+ params[0] = IROUND(ctx->Pixel.PostColorMatrixScale[3]);
+ break;
+ case GL_POST_COLOR_MATRIX_RED_BIAS_SGI:
+ params[0] = IROUND(ctx->Pixel.PostColorMatrixBias[0]);
+ break;
+ case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI:
+ params[0] = IROUND(ctx->Pixel.PostColorMatrixBias[1]);
+ break;
+ case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI:
+ params[0] = IROUND(ctx->Pixel.PostColorMatrixBias[2]);
+ break;
+ case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI:
+ params[0] = IROUND(ctx->Pixel.PostColorMatrixBias[3]);
+ break;
+ case GL_CONVOLUTION_1D_EXT:
+ CHECK_EXTENSION_I(EXT_convolution, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Pixel.Convolution1DEnabled);
+ break;
+ case GL_CONVOLUTION_2D_EXT:
+ CHECK_EXTENSION_I(EXT_convolution, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Pixel.Convolution2DEnabled);
+ break;
+ case GL_SEPARABLE_2D_EXT:
+ CHECK_EXTENSION_I(EXT_convolution, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Pixel.Separable2DEnabled);
+ break;
+ case GL_POST_CONVOLUTION_RED_SCALE_EXT:
+ CHECK_EXTENSION_I(EXT_convolution, pname);
+ params[0] = IROUND(ctx->Pixel.PostConvolutionScale[0]);
+ break;
+ case GL_POST_CONVOLUTION_GREEN_SCALE_EXT:
+ CHECK_EXTENSION_I(EXT_convolution, pname);
+ params[0] = IROUND(ctx->Pixel.PostConvolutionScale[1]);
+ break;
+ case GL_POST_CONVOLUTION_BLUE_SCALE_EXT:
+ CHECK_EXTENSION_I(EXT_convolution, pname);
+ params[0] = IROUND(ctx->Pixel.PostConvolutionScale[2]);
+ break;
+ case GL_POST_CONVOLUTION_ALPHA_SCALE_EXT:
+ CHECK_EXTENSION_I(EXT_convolution, pname);
+ params[0] = IROUND(ctx->Pixel.PostConvolutionScale[3]);
+ break;
+ case GL_POST_CONVOLUTION_RED_BIAS_EXT:
+ CHECK_EXTENSION_I(EXT_convolution, pname);
+ params[0] = IROUND(ctx->Pixel.PostConvolutionBias[0]);
+ break;
+ case GL_POST_CONVOLUTION_GREEN_BIAS_EXT:
+ CHECK_EXTENSION_I(EXT_convolution, pname);
+ params[0] = IROUND(ctx->Pixel.PostConvolutionBias[1]);
+ break;
+ case GL_POST_CONVOLUTION_BLUE_BIAS_EXT:
+ CHECK_EXTENSION_I(EXT_convolution, pname);
+ params[0] = IROUND(ctx->Pixel.PostConvolutionBias[2]);
+ break;
+ case GL_POST_CONVOLUTION_ALPHA_BIAS_EXT:
+ CHECK_EXTENSION_I(EXT_convolution, pname);
+ params[0] = IROUND(ctx->Pixel.PostConvolutionBias[3]);
+ break;
+ case GL_HISTOGRAM:
+ CHECK_EXTENSION_I(EXT_histogram, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Pixel.HistogramEnabled);
+ break;
+ case GL_MINMAX:
+ CHECK_EXTENSION_I(EXT_histogram, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Pixel.MinMaxEnabled);
+ break;
+ case GL_COLOR_TABLE_SGI:
+ CHECK_EXTENSION_I(SGI_color_table, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Pixel.ColorTableEnabled);
+ break;
+ case GL_POST_CONVOLUTION_COLOR_TABLE_SGI:
+ CHECK_EXTENSION_I(SGI_color_table, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Pixel.PostConvolutionColorTableEnabled);
+ break;
+ case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI:
+ CHECK_EXTENSION_I(SGI_color_table, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Pixel.PostColorMatrixColorTableEnabled);
+ break;
+ case GL_TEXTURE_COLOR_TABLE_SGI:
+ CHECK_EXTENSION_I(SGI_texture_color_table, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled);
+ break;
+ case GL_COLOR_SUM_EXT:
+ CHECK_EXTENSION_I(EXT_secondary_color, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Fog.ColorSumEnabled);
+ break;
+ case GL_CURRENT_SECONDARY_COLOR_EXT:
+ CHECK_EXTENSION_I(EXT_secondary_color, pname);
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0]);
+ params[1] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1]);
+ params[2] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2]);
+ params[3] = FLOAT_TO_INT(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3]);
+ }
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_EXT:
+ CHECK_EXTENSION_I(EXT_secondary_color, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.SecondaryColor.Enabled);
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_TYPE_EXT:
+ CHECK_EXTENSION_I(EXT_secondary_color, pname);
+ params[0] = ENUM_TO_INT(ctx->Array.SecondaryColor.Type);
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT:
+ CHECK_EXTENSION_I(EXT_secondary_color, pname);
+ params[0] = ctx->Array.SecondaryColor.Stride;
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_SIZE_EXT:
+ CHECK_EXTENSION_I(EXT_secondary_color, pname);
+ params[0] = ctx->Array.SecondaryColor.Size;
+ break;
+ case GL_CURRENT_FOG_COORDINATE_EXT:
+ CHECK_EXTENSION_I(EXT_fog_coord, pname);
+ {
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = IROUND(ctx->Current.Attrib[VERT_ATTRIB_FOG][0]);
+ }
+ break;
+ case GL_FOG_COORDINATE_ARRAY_EXT:
+ CHECK_EXTENSION_I(EXT_fog_coord, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.FogCoord.Enabled);
+ break;
+ case GL_FOG_COORDINATE_ARRAY_TYPE_EXT:
+ CHECK_EXTENSION_I(EXT_fog_coord, pname);
+ params[0] = ENUM_TO_INT(ctx->Array.FogCoord.Type);
+ break;
+ case GL_FOG_COORDINATE_ARRAY_STRIDE_EXT:
+ CHECK_EXTENSION_I(EXT_fog_coord, pname);
+ params[0] = ctx->Array.FogCoord.Stride;
+ break;
+ case GL_FOG_COORDINATE_SOURCE_EXT:
+ CHECK_EXTENSION_I(EXT_fog_coord, pname);
+ params[0] = ENUM_TO_INT(ctx->Fog.FogCoordinateSource);
+ break;
+ case GL_MAX_TEXTURE_LOD_BIAS_EXT:
+ CHECK_EXTENSION_I(EXT_texture_lod_bias, pname);
+ params[0] = IROUND(ctx->Const.MaxTextureLodBias);
+ break;
+ case GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT:
+ CHECK_EXTENSION_I(EXT_texture_filter_anisotropic, pname);
+ params[0] = IROUND(ctx->Const.MaxTextureMaxAnisotropy);
+ break;
+ case GL_MULTISAMPLE_ARB:
+ CHECK_EXTENSION_I(ARB_multisample, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Multisample.Enabled);
+ break;
+ case GL_SAMPLE_ALPHA_TO_COVERAGE_ARB:
+ CHECK_EXTENSION_I(ARB_multisample, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Multisample.SampleAlphaToCoverage);
+ break;
+ case GL_SAMPLE_ALPHA_TO_ONE_ARB:
+ CHECK_EXTENSION_I(ARB_multisample, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Multisample.SampleAlphaToOne);
+ break;
+ case GL_SAMPLE_COVERAGE_ARB:
+ CHECK_EXTENSION_I(ARB_multisample, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Multisample.SampleCoverage);
+ break;
+ case GL_SAMPLE_COVERAGE_VALUE_ARB:
+ CHECK_EXTENSION_I(ARB_multisample, pname);
+ params[0] = IROUND(ctx->Multisample.SampleCoverageValue);
+ break;
+ case GL_SAMPLE_COVERAGE_INVERT_ARB:
+ CHECK_EXTENSION_I(ARB_multisample, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Multisample.SampleCoverageInvert);
+ break;
+ case GL_SAMPLE_BUFFERS_ARB:
+ CHECK_EXTENSION_I(ARB_multisample, pname);
+ params[0] = ctx->DrawBuffer->Visual.sampleBuffers;
+ break;
+ case GL_SAMPLES_ARB:
+ CHECK_EXTENSION_I(ARB_multisample, pname);
+ params[0] = ctx->DrawBuffer->Visual.samples;
+ break;
+ case GL_RASTER_POSITION_UNCLIPPED_IBM:
+ CHECK_EXTENSION_I(IBM_rasterpos_clip, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Transform.RasterPositionUnclipped);
+ break;
+ case GL_POINT_SPRITE_NV:
+ CHECK_EXTENSION_I(NV_point_sprite, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Point.PointSprite);
+ break;
+ case GL_POINT_SPRITE_R_MODE_NV:
+ CHECK_EXTENSION_I(NV_point_sprite, pname);
+ params[0] = ENUM_TO_INT(ctx->Point.SpriteRMode);
+ break;
+ case GL_POINT_SPRITE_COORD_ORIGIN:
+ CHECK_EXTENSION_I(NV_point_sprite, pname);
+ params[0] = ENUM_TO_INT(ctx->Point.SpriteOrigin);
+ break;
+ case GL_GENERATE_MIPMAP_HINT_SGIS:
+ CHECK_EXTENSION_I(SGIS_generate_mipmap, pname);
+ params[0] = ENUM_TO_INT(ctx->Hint.GenerateMipmap);
+ break;
+ case GL_VERTEX_PROGRAM_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->VertexProgram.Enabled);
+ break;
+ case GL_VERTEX_PROGRAM_POINT_SIZE_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->VertexProgram.PointSizeEnabled);
+ break;
+ case GL_VERTEX_PROGRAM_TWO_SIDE_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->VertexProgram.TwoSideEnabled);
+ break;
+ case GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = ctx->Const.MaxProgramMatrixStackDepth;
+ break;
+ case GL_MAX_TRACK_MATRICES_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = ctx->Const.MaxProgramMatrices;
+ break;
+ case GL_CURRENT_MATRIX_STACK_DEPTH_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->CurrentStack->Depth + 1);
+ break;
+ case GL_CURRENT_MATRIX_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ {
+ const GLfloat *matrix = ctx->CurrentStack->Top->m;
+ params[0] = IROUND(matrix[0]);
+ params[1] = IROUND(matrix[1]);
+ params[2] = IROUND(matrix[2]);
+ params[3] = IROUND(matrix[3]);
+ params[4] = IROUND(matrix[4]);
+ params[5] = IROUND(matrix[5]);
+ params[6] = IROUND(matrix[6]);
+ params[7] = IROUND(matrix[7]);
+ params[8] = IROUND(matrix[8]);
+ params[9] = IROUND(matrix[9]);
+ params[10] = IROUND(matrix[10]);
+ params[11] = IROUND(matrix[11]);
+ params[12] = IROUND(matrix[12]);
+ params[13] = IROUND(matrix[13]);
+ params[14] = IROUND(matrix[14]);
+ params[15] = IROUND(matrix[15]);
+ }
+ break;
+ case GL_VERTEX_PROGRAM_BINDING_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = (ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0);
+ break;
+ case GL_PROGRAM_ERROR_POSITION_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = ctx->Program.ErrorPos;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY0_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.VertexAttrib[0].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY1_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.VertexAttrib[1].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY2_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.VertexAttrib[2].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY3_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.VertexAttrib[3].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY4_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.VertexAttrib[4].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY5_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.VertexAttrib[5].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY6_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.VertexAttrib[6].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY7_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.VertexAttrib[7].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY8_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.VertexAttrib[8].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY9_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.VertexAttrib[9].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY10_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.VertexAttrib[10].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY11_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.VertexAttrib[11].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY12_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.VertexAttrib[12].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY13_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.VertexAttrib[13].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY14_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.VertexAttrib[14].Enabled);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY15_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Array.VertexAttrib[15].Enabled);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB0_4_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[0]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB1_4_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[1]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB2_4_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[2]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB3_4_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[3]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB4_4_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[4]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB5_4_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[5]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB6_4_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[6]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB7_4_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[7]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB8_4_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[8]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB9_4_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[9]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB10_4_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[10]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB11_4_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[11]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB12_4_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[12]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB13_4_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[13]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB14_4_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[14]);
+ break;
+ case GL_MAP1_VERTEX_ATTRIB15_4_NV:
+ CHECK_EXTENSION_I(NV_vertex_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Eval.Map1Attrib[15]);
+ break;
+ case GL_FRAGMENT_PROGRAM_NV:
+ CHECK_EXTENSION_I(NV_fragment_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->FragmentProgram.Enabled);
+ break;
+ case GL_MAX_TEXTURE_COORDS_NV:
+ CHECK_EXTENSION_I(NV_fragment_program, pname);
+ params[0] = ctx->Const.MaxTextureCoordUnits;
+ break;
+ case GL_MAX_TEXTURE_IMAGE_UNITS_NV:
+ CHECK_EXTENSION_I(NV_fragment_program, pname);
+ params[0] = ctx->Const.MaxTextureImageUnits;
+ break;
+ case GL_FRAGMENT_PROGRAM_BINDING_NV:
+ CHECK_EXTENSION_I(NV_fragment_program, pname);
+ params[0] = ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0;
+ break;
+ case GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV:
+ CHECK_EXTENSION_I(NV_fragment_program, pname);
+ params[0] = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ CHECK_EXTENSION_I(NV_texture_rectangle, pname);
+ params[0] = BOOLEAN_TO_INT(_mesa_IsEnabled(GL_TEXTURE_RECTANGLE_NV));
+ break;
+ case GL_TEXTURE_BINDING_RECTANGLE_NV:
+ CHECK_EXTENSION_I(NV_texture_rectangle, pname);
+ params[0] = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentRect->Name;
+ break;
+ case GL_MAX_RECTANGLE_TEXTURE_SIZE_NV:
+ CHECK_EXTENSION_I(NV_texture_rectangle, pname);
+ params[0] = ctx->Const.MaxTextureRectSize;
+ break;
+ case GL_STENCIL_TEST_TWO_SIDE_EXT:
+ CHECK_EXTENSION_I(EXT_stencil_two_side, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Stencil.TestTwoSide);
+ break;
+ case GL_ACTIVE_STENCIL_FACE_EXT:
+ CHECK_EXTENSION_I(EXT_stencil_two_side, pname);
+ params[0] = ENUM_TO_INT(ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT);
+ break;
+ case GL_MAX_SHININESS_NV:
+ CHECK_EXTENSION_I(NV_light_max_exponent, pname);
+ params[0] = IROUND(ctx->Const.MaxShininess);
+ break;
+ case GL_MAX_SPOT_EXPONENT_NV:
+ CHECK_EXTENSION_I(NV_light_max_exponent, pname);
+ params[0] = IROUND(ctx->Const.MaxSpotExponent);
+ break;
+ case GL_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
+ params[0] = ctx->Array.ArrayBufferObj->Name;
+ break;
+ case GL_VERTEX_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
+ params[0] = ctx->Array.Vertex.BufferObj->Name;
+ break;
+ case GL_NORMAL_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
+ params[0] = ctx->Array.Normal.BufferObj->Name;
+ break;
+ case GL_COLOR_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
+ params[0] = ctx->Array.Color.BufferObj->Name;
+ break;
+ case GL_INDEX_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
+ params[0] = ctx->Array.Index.BufferObj->Name;
+ break;
+ case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
+ params[0] = ctx->Array.TexCoord[ctx->Array.ActiveTexture].BufferObj->Name;
+ break;
+ case GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
+ params[0] = ctx->Array.EdgeFlag.BufferObj->Name;
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
+ params[0] = ctx->Array.SecondaryColor.BufferObj->Name;
+ break;
+ case GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
+ params[0] = ctx->Array.FogCoord.BufferObj->Name;
+ break;
+ case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB:
+ CHECK_EXTENSION_I(ARB_vertex_buffer_object, pname);
+ params[0] = ctx->Array.ElementArrayBufferObj->Name;
+ break;
+ case GL_PIXEL_PACK_BUFFER_BINDING_EXT:
+ CHECK_EXTENSION_I(EXT_pixel_buffer_object, pname);
+ params[0] = ctx->Pack.BufferObj->Name;
+ break;
+ case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT:
+ CHECK_EXTENSION_I(EXT_pixel_buffer_object, pname);
+ params[0] = ctx->Unpack.BufferObj->Name;
+ break;
+ case GL_MAX_VERTEX_ATTRIBS_ARB:
+ CHECK_EXTENSION_I(ARB_vertex_program, pname);
+ params[0] = ctx->Const.MaxVertexProgramAttribs;
+ break;
+ case GL_FRAGMENT_PROGRAM_ARB:
+ CHECK_EXTENSION_I(ARB_fragment_program, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->FragmentProgram.Enabled);
+ break;
+ case GL_TRANSPOSE_CURRENT_MATRIX_ARB:
+ CHECK_EXTENSION_I(ARB_fragment_program, pname);
+ {
+ const GLfloat *matrix = ctx->CurrentStack->Top->m;
+ params[0] = IROUND(matrix[0]);
+ params[1] = IROUND(matrix[4]);
+ params[2] = IROUND(matrix[8]);
+ params[3] = IROUND(matrix[12]);
+ params[4] = IROUND(matrix[1]);
+ params[5] = IROUND(matrix[5]);
+ params[6] = IROUND(matrix[9]);
+ params[7] = IROUND(matrix[13]);
+ params[8] = IROUND(matrix[2]);
+ params[9] = IROUND(matrix[6]);
+ params[10] = IROUND(matrix[10]);
+ params[11] = IROUND(matrix[14]);
+ params[12] = IROUND(matrix[3]);
+ params[13] = IROUND(matrix[7]);
+ params[14] = IROUND(matrix[11]);
+ params[15] = IROUND(matrix[15]);
+ }
+ break;
+ case GL_DEPTH_BOUNDS_TEST_EXT:
+ CHECK_EXTENSION_I(EXT_depth_bounds_test, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->Depth.BoundsTest);
+ break;
+ case GL_DEPTH_BOUNDS_EXT:
+ CHECK_EXTENSION_I(EXT_depth_bounds_test, pname);
+ params[0] = IROUND(ctx->Depth.BoundsMin);
+ params[1] = IROUND(ctx->Depth.BoundsMax);
+ break;
+ case GL_FRAGMENT_PROGRAM_CALLBACK_MESA:
+ CHECK_EXTENSION_I(MESA_program_debug, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->FragmentProgram.CallbackEnabled);
+ break;
+ case GL_VERTEX_PROGRAM_CALLBACK_MESA:
+ CHECK_EXTENSION_I(MESA_program_debug, pname);
+ params[0] = BOOLEAN_TO_INT(ctx->VertexProgram.CallbackEnabled);
+ break;
+ case GL_FRAGMENT_PROGRAM_POSITION_MESA:
+ CHECK_EXTENSION_I(MESA_program_debug, pname);
+ params[0] = ctx->FragmentProgram.CurrentPosition;
+ break;
+ case GL_VERTEX_PROGRAM_POSITION_MESA:
+ CHECK_EXTENSION_I(MESA_program_debug, pname);
+ params[0] = ctx->VertexProgram.CurrentPosition;
+ break;
+ case GL_MAX_DRAW_BUFFERS_ARB:
+ CHECK_EXTENSION_I(ARB_draw_buffers, pname);
+ params[0] = ctx->Const.MaxDrawBuffers;
+ break;
+ case GL_DRAW_BUFFER0_ARB:
+ CHECK_EXTENSION_I(ARB_draw_buffers, pname);
+ params[0] = ENUM_TO_INT(ctx->Color.DrawBuffer[0]);
+ break;
+ case GL_DRAW_BUFFER1_ARB:
+ CHECK_EXTENSION_I(ARB_draw_buffers, pname);
+ {
+ GLenum buffer;
+ if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)");
+ return;
+ }
+ buffer = ctx->Color.DrawBuffer[1];
+ params[0] = ENUM_TO_INT(buffer);
+ }
+ break;
+ case GL_DRAW_BUFFER2_ARB:
+ CHECK_EXTENSION_I(ARB_draw_buffers, pname);
+ {
+ GLenum buffer;
+ if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)");
+ return;
+ }
+ buffer = ctx->Color.DrawBuffer[2];
+ params[0] = ENUM_TO_INT(buffer);
+ }
+ break;
+ case GL_DRAW_BUFFER3_ARB:
+ CHECK_EXTENSION_I(ARB_draw_buffers, pname);
+ {
+ GLenum buffer;
+ if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)");
+ return;
+ }
+ buffer = ctx->Color.DrawBuffer[3];
+ params[0] = ENUM_TO_INT(buffer);
+ }
+ break;
+ case GL_IMPLEMENTATION_COLOR_READ_TYPE_OES:
+ CHECK_EXTENSION_I(OES_read_format, pname);
+ params[0] = ctx->Const.ColorReadType;
+ break;
+ case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
+ CHECK_EXTENSION_I(OES_read_format, pname);
+ params[0] = ctx->Const.ColorReadFormat;
+ break;
+ case GL_NUM_FRAGMENT_REGISTERS_ATI:
+ CHECK_EXTENSION_I(ATI_fragment_shader, pname);
+ params[0] = 6;
+ break;
+ case GL_NUM_FRAGMENT_CONSTANTS_ATI:
+ CHECK_EXTENSION_I(ATI_fragment_shader, pname);
+ params[0] = 8;
+ break;
+ case GL_NUM_PASSES_ATI:
+ CHECK_EXTENSION_I(ATI_fragment_shader, pname);
+ params[0] = 2;
+ break;
+ case GL_NUM_INSTRUCTIONS_PER_PASS_ATI:
+ CHECK_EXTENSION_I(ATI_fragment_shader, pname);
+ params[0] = 8;
+ break;
+ case GL_NUM_INSTRUCTIONS_TOTAL_ATI:
+ CHECK_EXTENSION_I(ATI_fragment_shader, pname);
+ params[0] = 16;
+ break;
+ case GL_COLOR_ALPHA_PAIRING_ATI:
+ CHECK_EXTENSION_I(ATI_fragment_shader, pname);
+ params[0] = BOOLEAN_TO_INT(GL_TRUE);
+ break;
+ case GL_NUM_LOOPBACK_COMPONENTS_ATI:
+ CHECK_EXTENSION_I(ATI_fragment_shader, pname);
+ params[0] = 3;
+ break;
+ case GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI:
+ CHECK_EXTENSION_I(ATI_fragment_shader, pname);
+ params[0] = 3;
+ break;
+ case GL_STENCIL_BACK_FUNC:
+ params[0] = ENUM_TO_INT(ctx->Stencil.Function[1]);
+ break;
+ case GL_STENCIL_BACK_VALUE_MASK:
+ params[0] = ctx->Stencil.ValueMask[1];
+ break;
+ case GL_STENCIL_BACK_REF:
+ params[0] = ctx->Stencil.Ref[1];
+ break;
+ case GL_STENCIL_BACK_FAIL:
+ params[0] = ENUM_TO_INT(ctx->Stencil.FailFunc[1]);
+ break;
+ case GL_STENCIL_BACK_PASS_DEPTH_FAIL:
+ params[0] = ENUM_TO_INT(ctx->Stencil.ZFailFunc[1]);
+ break;
+ case GL_STENCIL_BACK_PASS_DEPTH_PASS:
+ params[0] = ENUM_TO_INT(ctx->Stencil.ZPassFunc[1]);
+ break;
+ case GL_FRAMEBUFFER_BINDING_EXT:
+ CHECK_EXTENSION_I(EXT_framebuffer_object, pname);
+ params[0] = ctx->DrawBuffer->Name;
+ break;
+ case GL_RENDERBUFFER_BINDING_EXT:
+ CHECK_EXTENSION_I(EXT_framebuffer_object, pname);
+ params[0] = ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0;
+ break;
+ case GL_MAX_COLOR_ATTACHMENTS_EXT:
+ CHECK_EXTENSION_I(EXT_framebuffer_object, pname);
+ params[0] = ctx->Const.MaxColorAttachments;
+ break;
+ case GL_MAX_RENDERBUFFER_SIZE_EXT:
+ CHECK_EXTENSION_I(EXT_framebuffer_object, pname);
+ params[0] = ctx->Const.MaxRenderbufferSize;
+ break;
+ case GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB:
+ CHECK_EXTENSION_I(ARB_fragment_shader, pname);
+ params[0] = MAX_FRAGMENT_UNIFORM_COMPONENTS;
+ break;
+ case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB:
+ CHECK_EXTENSION_I(ARB_fragment_shader, pname);
+ params[0] = ENUM_TO_INT(ctx->Hint.FragmentShaderDerivative);
+ break;
+ case GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB:
+ CHECK_EXTENSION_I(ARB_vertex_shader, pname);
+ params[0] = MAX_VERTEX_UNIFORM_COMPONENTS;
+ break;
+ case GL_MAX_VARYING_FLOATS_ARB:
+ CHECK_EXTENSION_I(ARB_vertex_shader, pname);
+ params[0] = MAX_VARYING_FLOATS;
+ break;
+ case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB:
+ CHECK_EXTENSION_I(ARB_vertex_shader, pname);
+ params[0] = MAX_VERTEX_TEXTURE_IMAGE_UNITS;
+ break;
+ case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB:
+ CHECK_EXTENSION_I(ARB_vertex_shader, pname);
+ params[0] = MAX_COMBINED_TEXTURE_IMAGE_UNITS;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetIntegerv(pname=0x%x)", pname);
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetDoublev( GLenum pname, GLdouble *params )
+{
+ const GLfloat magic = -1234.5F;
+ GLfloat values[16];
+ GLuint i;
+
+ if (!params)
+ return;
+
+ /* Init temp array to magic numbers so we can figure out how many values
+ * are returned by the GetFloatv() call.
+ */
+ for (i = 0; i < 16; i++)
+ values[i] = magic;
+
+ _mesa_GetFloatv(pname, values);
+
+ for (i = 0; i < 16 && values[i] != magic; i++)
+ params[i] = (GLdouble) values[i];
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/main/get.h b/nx-X11/extras/Mesa/src/mesa/main/get.h
new file mode 100644
index 000000000..9b47b230a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/get.h
@@ -0,0 +1,59 @@
+/**
+ * \file get.h
+ * State query functions.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef GET_H
+#define GET_H
+
+
+#include "mtypes.h"
+
+
+extern void GLAPIENTRY
+_mesa_GetBooleanv( GLenum pname, GLboolean *params );
+
+extern void GLAPIENTRY
+_mesa_GetDoublev( GLenum pname, GLdouble *params );
+
+extern void GLAPIENTRY
+_mesa_GetFloatv( GLenum pname, GLfloat *params );
+
+extern void GLAPIENTRY
+_mesa_GetIntegerv( GLenum pname, GLint *params );
+
+extern void GLAPIENTRY
+_mesa_GetPointerv( GLenum pname, GLvoid **params );
+
+extern const GLubyte * GLAPIENTRY
+_mesa_GetString( GLenum name );
+
+extern GLenum GLAPIENTRY
+_mesa_GetError( void );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/get_gen.py b/nx-X11/extras/Mesa/src/mesa/main/get_gen.py
new file mode 100644
index 000000000..32a5a3d77
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/get_gen.py
@@ -0,0 +1,1200 @@
+#!/usr/bin/env python
+
+# Mesa 3-D graphics library
+#
+# Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+# This script is used to generate the get.c file:
+# python get_gen.py > get.c
+
+
+import string
+
+
+GLint = 1
+GLenum = 2
+GLfloat = 3
+GLdouble = 4
+GLboolean = 5
+GLfloatN = 6 # A normalized value, such as a color or depth range
+
+
+TypeStrings = {
+ GLint : "GLint",
+ GLenum : "GLenum",
+ GLfloat : "GLfloat",
+ GLdouble : "GLdouble",
+ GLboolean : "GLboolean"
+}
+
+
+# Each entry is a tuple of:
+# - the GL state name, such as GL_CURRENT_COLOR
+# - the state datatype, one of GLint, GLfloat, GLboolean or GLenum
+# - list of code fragments to get the state, such as ["ctx->Foo.Bar"]
+# - optional extra code or empty string
+# - optional extension to check, or None (XXX this should be a list!)
+#
+StateVars = [
+ ( "GL_ACCUM_RED_BITS", GLint, ["ctx->DrawBuffer->Visual.accumRedBits"],
+ "", None ),
+ ( "GL_ACCUM_GREEN_BITS", GLint, ["ctx->DrawBuffer->Visual.accumGreenBits"],
+ "", None ),
+ ( "GL_ACCUM_BLUE_BITS", GLint, ["ctx->DrawBuffer->Visual.accumBlueBits"],
+ "", None ),
+ ( "GL_ACCUM_ALPHA_BITS", GLint, ["ctx->DrawBuffer->Visual.accumAlphaBits"],
+ "", None ),
+ ( "GL_ACCUM_CLEAR_VALUE", GLfloatN,
+ [ "ctx->Accum.ClearColor[0]",
+ "ctx->Accum.ClearColor[1]",
+ "ctx->Accum.ClearColor[2]",
+ "ctx->Accum.ClearColor[3]" ],
+ "", None ),
+ ( "GL_ALPHA_BIAS", GLfloat, ["ctx->Pixel.AlphaBias"], "", None ),
+ ( "GL_ALPHA_BITS", GLint, ["ctx->DrawBuffer->Visual.alphaBits"],
+ "", None ),
+ ( "GL_ALPHA_SCALE", GLfloat, ["ctx->Pixel.AlphaScale"], "", None ),
+ ( "GL_ALPHA_TEST", GLboolean, ["ctx->Color.AlphaEnabled"], "", None ),
+ ( "GL_ALPHA_TEST_FUNC", GLenum, ["ctx->Color.AlphaFunc"], "", None ),
+ ( "GL_ALPHA_TEST_REF", GLfloatN, ["ctx->Color.AlphaRef"], "", None ),
+ ( "GL_ATTRIB_STACK_DEPTH", GLint, ["ctx->AttribStackDepth"], "", None ),
+ ( "GL_AUTO_NORMAL", GLboolean, ["ctx->Eval.AutoNormal"], "", None ),
+ ( "GL_AUX_BUFFERS", GLint, ["ctx->DrawBuffer->Visual.numAuxBuffers"],
+ "", None ),
+ ( "GL_BLEND", GLboolean, ["ctx->Color.BlendEnabled"], "", None ),
+ ( "GL_BLEND_DST", GLenum, ["ctx->Color.BlendDstRGB"], "", None ),
+ ( "GL_BLEND_SRC", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ),
+ ( "GL_BLEND_SRC_RGB_EXT", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ),
+ ( "GL_BLEND_DST_RGB_EXT", GLenum, ["ctx->Color.BlendDstRGB"], "", None ),
+ ( "GL_BLEND_SRC_ALPHA_EXT", GLenum, ["ctx->Color.BlendSrcA"], "", None ),
+ ( "GL_BLEND_DST_ALPHA_EXT", GLenum, ["ctx->Color.BlendDstA"], "", None ),
+ ( "GL_BLEND_EQUATION", GLenum, ["ctx->Color.BlendEquationRGB "], "", None),
+ ( "GL_BLEND_EQUATION_ALPHA_EXT", GLenum, ["ctx->Color.BlendEquationA "],
+ "", None ),
+ ( "GL_BLEND_COLOR_EXT", GLfloatN,
+ [ "ctx->Color.BlendColor[0]",
+ "ctx->Color.BlendColor[1]",
+ "ctx->Color.BlendColor[2]",
+ "ctx->Color.BlendColor[3]"], "", None ),
+ ( "GL_BLUE_BIAS", GLfloat, ["ctx->Pixel.BlueBias"], "", None ),
+ ( "GL_BLUE_BITS", GLint, ["ctx->DrawBuffer->Visual.blueBits"], "", None ),
+ ( "GL_BLUE_SCALE", GLfloat, ["ctx->Pixel.BlueScale"], "", None ),
+ ( "GL_CLIENT_ATTRIB_STACK_DEPTH", GLint,
+ ["ctx->ClientAttribStackDepth"], "", None ),
+ ( "GL_CLIP_PLANE0", GLboolean,
+ [ "(ctx->Transform.ClipPlanesEnabled >> 0) & 1" ], "", None ),
+ ( "GL_CLIP_PLANE1", GLboolean,
+ [ "(ctx->Transform.ClipPlanesEnabled >> 1) & 1" ], "", None ),
+ ( "GL_CLIP_PLANE2", GLboolean,
+ [ "(ctx->Transform.ClipPlanesEnabled >> 2) & 1" ], "", None ),
+ ( "GL_CLIP_PLANE3", GLboolean,
+ [ "(ctx->Transform.ClipPlanesEnabled >> 3) & 1" ], "", None ),
+ ( "GL_CLIP_PLANE4", GLboolean,
+ [ "(ctx->Transform.ClipPlanesEnabled >> 4) & 1" ], "", None ),
+ ( "GL_CLIP_PLANE5", GLboolean,
+ [ "(ctx->Transform.ClipPlanesEnabled >> 5) & 1" ], "", None ),
+ ( "GL_COLOR_CLEAR_VALUE", GLfloatN,
+ [ "ctx->Color.ClearColor[0]",
+ "ctx->Color.ClearColor[1]",
+ "ctx->Color.ClearColor[2]",
+ "ctx->Color.ClearColor[3]" ], "", None ),
+ ( "GL_COLOR_MATERIAL", GLboolean,
+ ["ctx->Light.ColorMaterialEnabled"], "", None ),
+ ( "GL_COLOR_MATERIAL_FACE", GLenum,
+ ["ctx->Light.ColorMaterialFace"], "", None ),
+ ( "GL_COLOR_MATERIAL_PARAMETER", GLenum,
+ ["ctx->Light.ColorMaterialMode"], "", None ),
+ ( "GL_COLOR_WRITEMASK", GLint,
+ [ "ctx->Color.ColorMask[RCOMP] ? 1 : 0",
+ "ctx->Color.ColorMask[GCOMP] ? 1 : 0",
+ "ctx->Color.ColorMask[BCOMP] ? 1 : 0",
+ "ctx->Color.ColorMask[ACOMP] ? 1 : 0" ], "", None ),
+ ( "GL_CULL_FACE", GLboolean, ["ctx->Polygon.CullFlag"], "", None ),
+ ( "GL_CULL_FACE_MODE", GLenum, ["ctx->Polygon.CullFaceMode"], "", None ),
+ ( "GL_CURRENT_COLOR", GLfloatN,
+ [ "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]",
+ "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]",
+ "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]",
+ "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]" ],
+ "FLUSH_CURRENT(ctx, 0);", None ),
+ ( "GL_CURRENT_INDEX", GLfloat, ["ctx->Current.Index"],
+ "FLUSH_CURRENT(ctx, 0);", None ),
+ ( "GL_CURRENT_NORMAL", GLfloatN,
+ [ "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]",
+ "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]",
+ "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]"],
+ "FLUSH_CURRENT(ctx, 0);", None ),
+ ( "GL_CURRENT_RASTER_COLOR", GLfloatN,
+ ["ctx->Current.RasterColor[0]",
+ "ctx->Current.RasterColor[1]",
+ "ctx->Current.RasterColor[2]",
+ "ctx->Current.RasterColor[3]"], "", None ),
+ ( "GL_CURRENT_RASTER_DISTANCE", GLfloat,
+ ["ctx->Current.RasterDistance"], "", None ),
+ ( "GL_CURRENT_RASTER_INDEX", GLfloat,
+ ["ctx->Current.RasterIndex"], "", None ),
+ ( "GL_CURRENT_RASTER_POSITION", GLfloat,
+ ["ctx->Current.RasterPos[0]",
+ "ctx->Current.RasterPos[1]",
+ "ctx->Current.RasterPos[2]",
+ "ctx->Current.RasterPos[3]"], "", None ),
+ ( "GL_CURRENT_RASTER_TEXTURE_COORDS", GLfloat,
+ ["ctx->Current.RasterTexCoords[texUnit][0]",
+ "ctx->Current.RasterTexCoords[texUnit][1]",
+ "ctx->Current.RasterTexCoords[texUnit][2]",
+ "ctx->Current.RasterTexCoords[texUnit][3]"],
+ "const GLuint texUnit = ctx->Texture.CurrentUnit;", None ),
+ ( "GL_CURRENT_RASTER_POSITION_VALID", GLboolean,
+ ["ctx->Current.RasterPosValid"], "", None ),
+ ( "GL_CURRENT_TEXTURE_COORDS", GLfloat,
+ ["ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][0]",
+ "ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][1]",
+ "ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][2]",
+ "ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][3]"],
+ "const GLuint texUnit = ctx->Texture.CurrentUnit;", None ),
+ ( "GL_DEPTH_BIAS", GLfloat, ["ctx->Pixel.DepthBias"], "", None ),
+ ( "GL_DEPTH_BITS", GLint, ["ctx->DrawBuffer->Visual.depthBits"],
+ "", None ),
+ ( "GL_DEPTH_CLEAR_VALUE", GLfloat, ["ctx->Depth.Clear"], "", None ),
+ ( "GL_DEPTH_FUNC", GLenum, ["ctx->Depth.Func"], "", None ),
+ ( "GL_DEPTH_RANGE", GLfloatN,
+ [ "ctx->Viewport.Near", "ctx->Viewport.Far" ], "", None ),
+ ( "GL_DEPTH_SCALE", GLfloat, ["ctx->Pixel.DepthScale"], "", None ),
+ ( "GL_DEPTH_TEST", GLboolean, ["ctx->Depth.Test"], "", None ),
+ ( "GL_DEPTH_WRITEMASK", GLboolean, ["ctx->Depth.Mask"], "", None ),
+ ( "GL_DITHER", GLboolean, ["ctx->Color.DitherFlag"], "", None ),
+ ( "GL_DOUBLEBUFFER", GLboolean,
+ ["ctx->DrawBuffer->Visual.doubleBufferMode"], "", None ),
+ ( "GL_DRAW_BUFFER", GLenum, ["ctx->Color.DrawBuffer[0]"], "", None ),
+ ( "GL_EDGE_FLAG", GLboolean, ["ctx->Current.EdgeFlag"],
+ "FLUSH_CURRENT(ctx, 0);", None ),
+ ( "GL_FEEDBACK_BUFFER_SIZE", GLint, ["ctx->Feedback.BufferSize"], "", None ),
+ ( "GL_FEEDBACK_BUFFER_TYPE", GLenum, ["ctx->Feedback.Type"], "", None ),
+ ( "GL_FOG", GLboolean, ["ctx->Fog.Enabled"], "", None ),
+ ( "GL_FOG_COLOR", GLfloatN,
+ [ "ctx->Fog.Color[0]",
+ "ctx->Fog.Color[1]",
+ "ctx->Fog.Color[2]",
+ "ctx->Fog.Color[3]" ], "", None ),
+ ( "GL_FOG_DENSITY", GLfloat, ["ctx->Fog.Density"], "", None ),
+ ( "GL_FOG_END", GLfloat, ["ctx->Fog.End"], "", None ),
+ ( "GL_FOG_HINT", GLenum, ["ctx->Hint.Fog"], "", None ),
+ ( "GL_FOG_INDEX", GLfloat, ["ctx->Fog.Index"], "", None ),
+ ( "GL_FOG_MODE", GLenum, ["ctx->Fog.Mode"], "", None ),
+ ( "GL_FOG_START", GLfloat, ["ctx->Fog.Start"], "", None ),
+ ( "GL_FRONT_FACE", GLenum, ["ctx->Polygon.FrontFace"], "", None ),
+ ( "GL_GREEN_BIAS", GLfloat, ["ctx->Pixel.GreenBias"], "", None ),
+ ( "GL_GREEN_BITS", GLint, ["ctx->DrawBuffer->Visual.greenBits"],
+ "", None ),
+ ( "GL_GREEN_SCALE", GLfloat, ["ctx->Pixel.GreenScale"], "", None ),
+ ( "GL_INDEX_BITS", GLint, ["ctx->DrawBuffer->Visual.indexBits"],
+ "", None ),
+ ( "GL_INDEX_CLEAR_VALUE", GLint, ["ctx->Color.ClearIndex"], "", None ),
+ ( "GL_INDEX_MODE", GLboolean, ["!ctx->DrawBuffer->Visual.rgbMode"],
+ "", None ),
+ ( "GL_INDEX_OFFSET", GLint, ["ctx->Pixel.IndexOffset"], "", None ),
+ ( "GL_INDEX_SHIFT", GLint, ["ctx->Pixel.IndexShift"], "", None ),
+ ( "GL_INDEX_WRITEMASK", GLint, ["ctx->Color.IndexMask"], "", None ),
+ ( "GL_LIGHT0", GLboolean, ["ctx->Light.Light[0].Enabled"], "", None ),
+ ( "GL_LIGHT1", GLboolean, ["ctx->Light.Light[1].Enabled"], "", None ),
+ ( "GL_LIGHT2", GLboolean, ["ctx->Light.Light[2].Enabled"], "", None ),
+ ( "GL_LIGHT3", GLboolean, ["ctx->Light.Light[3].Enabled"], "", None ),
+ ( "GL_LIGHT4", GLboolean, ["ctx->Light.Light[4].Enabled"], "", None ),
+ ( "GL_LIGHT5", GLboolean, ["ctx->Light.Light[5].Enabled"], "", None ),
+ ( "GL_LIGHT6", GLboolean, ["ctx->Light.Light[6].Enabled"], "", None ),
+ ( "GL_LIGHT7", GLboolean, ["ctx->Light.Light[7].Enabled"], "", None ),
+ ( "GL_LIGHTING", GLboolean, ["ctx->Light.Enabled"], "", None ),
+ ( "GL_LIGHT_MODEL_AMBIENT", GLfloatN,
+ ["ctx->Light.Model.Ambient[0]",
+ "ctx->Light.Model.Ambient[1]",
+ "ctx->Light.Model.Ambient[2]",
+ "ctx->Light.Model.Ambient[3]"], "", None ),
+ ( "GL_LIGHT_MODEL_COLOR_CONTROL", GLenum,
+ ["ctx->Light.Model.ColorControl"], "", None ),
+ ( "GL_LIGHT_MODEL_LOCAL_VIEWER", GLboolean,
+ ["ctx->Light.Model.LocalViewer"], "", None ),
+ ( "GL_LIGHT_MODEL_TWO_SIDE", GLboolean, ["ctx->Light.Model.TwoSide"], "", None ),
+ ( "GL_LINE_SMOOTH", GLboolean, ["ctx->Line.SmoothFlag"], "", None ),
+ ( "GL_LINE_SMOOTH_HINT", GLenum, ["ctx->Hint.LineSmooth"], "", None ),
+ ( "GL_LINE_STIPPLE", GLboolean, ["ctx->Line.StippleFlag"], "", None ),
+ ( "GL_LINE_STIPPLE_PATTERN", GLint, ["ctx->Line.StipplePattern"], "", None ),
+ ( "GL_LINE_STIPPLE_REPEAT", GLint, ["ctx->Line.StippleFactor"], "", None ),
+ ( "GL_LINE_WIDTH", GLfloat, ["ctx->Line.Width"], "", None ),
+ ( "GL_LINE_WIDTH_GRANULARITY", GLfloat,
+ ["ctx->Const.LineWidthGranularity"], "", None ),
+ ( "GL_LINE_WIDTH_RANGE", GLfloat,
+ ["ctx->Const.MinLineWidthAA",
+ "ctx->Const.MaxLineWidthAA"], "", None ),
+ ( "GL_ALIASED_LINE_WIDTH_RANGE", GLfloat,
+ ["ctx->Const.MinLineWidth",
+ "ctx->Const.MaxLineWidth"], "", None ),
+ ( "GL_LIST_BASE", GLint, ["ctx->List.ListBase"], "", None ),
+ ( "GL_LIST_INDEX", GLint, ["ctx->ListState.CurrentListNum"], "", None ),
+ ( "GL_LIST_MODE", GLenum, ["mode"],
+ """GLenum mode;
+ if (!ctx->CompileFlag)
+ mode = 0;
+ else if (ctx->ExecuteFlag)
+ mode = GL_COMPILE_AND_EXECUTE;
+ else
+ mode = GL_COMPILE;""", None ),
+ ( "GL_INDEX_LOGIC_OP", GLboolean, ["ctx->Color.IndexLogicOpEnabled"], "", None ),
+ ( "GL_COLOR_LOGIC_OP", GLboolean, ["ctx->Color.ColorLogicOpEnabled"], "", None ),
+ ( "GL_LOGIC_OP_MODE", GLenum, ["ctx->Color.LogicOp"], "", None ),
+ ( "GL_MAP1_COLOR_4", GLboolean, ["ctx->Eval.Map1Color4"], "", None ),
+ ( "GL_MAP1_GRID_DOMAIN", GLfloat,
+ ["ctx->Eval.MapGrid1u1",
+ "ctx->Eval.MapGrid1u2"], "", None ),
+ ( "GL_MAP1_GRID_SEGMENTS", GLint, ["ctx->Eval.MapGrid1un"], "", None ),
+ ( "GL_MAP1_INDEX", GLboolean, ["ctx->Eval.Map1Index"], "", None ),
+ ( "GL_MAP1_NORMAL", GLboolean, ["ctx->Eval.Map1Normal"], "", None ),
+ ( "GL_MAP1_TEXTURE_COORD_1", GLboolean, ["ctx->Eval.Map1TextureCoord1"], "", None ),
+ ( "GL_MAP1_TEXTURE_COORD_2", GLboolean, ["ctx->Eval.Map1TextureCoord2"], "", None ),
+ ( "GL_MAP1_TEXTURE_COORD_3", GLboolean, ["ctx->Eval.Map1TextureCoord3"], "", None ),
+ ( "GL_MAP1_TEXTURE_COORD_4", GLboolean, ["ctx->Eval.Map1TextureCoord4"], "", None ),
+ ( "GL_MAP1_VERTEX_3", GLboolean, ["ctx->Eval.Map1Vertex3"], "", None ),
+ ( "GL_MAP1_VERTEX_4", GLboolean, ["ctx->Eval.Map1Vertex4"], "", None ),
+ ( "GL_MAP2_COLOR_4", GLboolean, ["ctx->Eval.Map2Color4"], "", None ),
+ ( "GL_MAP2_GRID_DOMAIN", GLfloat,
+ ["ctx->Eval.MapGrid2u1",
+ "ctx->Eval.MapGrid2u2",
+ "ctx->Eval.MapGrid2v1",
+ "ctx->Eval.MapGrid2v2"], "", None ),
+ ( "GL_MAP2_GRID_SEGMENTS", GLint,
+ ["ctx->Eval.MapGrid2un",
+ "ctx->Eval.MapGrid2vn"], "", None ),
+ ( "GL_MAP2_INDEX", GLboolean, ["ctx->Eval.Map2Index"], "", None ),
+ ( "GL_MAP2_NORMAL", GLboolean, ["ctx->Eval.Map2Normal"], "", None ),
+ ( "GL_MAP2_TEXTURE_COORD_1", GLboolean, ["ctx->Eval.Map2TextureCoord1"], "", None ),
+ ( "GL_MAP2_TEXTURE_COORD_2", GLboolean, ["ctx->Eval.Map2TextureCoord2"], "", None ),
+ ( "GL_MAP2_TEXTURE_COORD_3", GLboolean, ["ctx->Eval.Map2TextureCoord3"], "", None ),
+ ( "GL_MAP2_TEXTURE_COORD_4", GLboolean, ["ctx->Eval.Map2TextureCoord4"], "", None ),
+ ( "GL_MAP2_VERTEX_3", GLboolean, ["ctx->Eval.Map2Vertex3"], "", None ),
+ ( "GL_MAP2_VERTEX_4", GLboolean, ["ctx->Eval.Map2Vertex4"], "", None ),
+ ( "GL_MAP_COLOR", GLboolean, ["ctx->Pixel.MapColorFlag"], "", None ),
+ ( "GL_MAP_STENCIL", GLboolean, ["ctx->Pixel.MapStencilFlag"], "", None ),
+ ( "GL_MATRIX_MODE", GLenum, ["ctx->Transform.MatrixMode"], "", None ),
+
+ ( "GL_MAX_ATTRIB_STACK_DEPTH", GLint, ["MAX_ATTRIB_STACK_DEPTH"], "", None ),
+ ( "GL_MAX_CLIENT_ATTRIB_STACK_DEPTH", GLint, ["MAX_CLIENT_ATTRIB_STACK_DEPTH"], "", None ),
+ ( "GL_MAX_CLIP_PLANES", GLint, ["ctx->Const.MaxClipPlanes"], "", None ),
+ ( "GL_MAX_ELEMENTS_VERTICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", None ),
+ ( "GL_MAX_ELEMENTS_INDICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", None ),
+ ( "GL_MAX_EVAL_ORDER", GLint, ["MAX_EVAL_ORDER"], "", None ),
+ ( "GL_MAX_LIGHTS", GLint, ["ctx->Const.MaxLights"], "", None ),
+ ( "GL_MAX_LIST_NESTING", GLint, ["MAX_LIST_NESTING"], "", None ),
+ ( "GL_MAX_MODELVIEW_STACK_DEPTH", GLint, ["MAX_MODELVIEW_STACK_DEPTH"], "", None ),
+ ( "GL_MAX_NAME_STACK_DEPTH", GLint, ["MAX_NAME_STACK_DEPTH"], "", None ),
+ ( "GL_MAX_PIXEL_MAP_TABLE", GLint, ["MAX_PIXEL_MAP_TABLE"], "", None ),
+ ( "GL_MAX_PROJECTION_STACK_DEPTH", GLint, ["MAX_PROJECTION_STACK_DEPTH"], "", None ),
+ ( "GL_MAX_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.MaxTextureLevels - 1)"], "", None ),
+ ( "GL_MAX_3D_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.Max3DTextureLevels - 1)"], "", None ),
+ ( "GL_MAX_TEXTURE_STACK_DEPTH", GLint, ["MAX_TEXTURE_STACK_DEPTH"], "", None ),
+ ( "GL_MAX_VIEWPORT_DIMS", GLint,
+ ["ctx->Const.MaxViewportWidth", "ctx->Const.MaxViewportHeight"],
+ "", None ),
+ ( "GL_MODELVIEW_MATRIX", GLfloat,
+ [ "matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]",
+ "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]",
+ "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]",
+ "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ],
+ "const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;", None ),
+ ( "GL_MODELVIEW_STACK_DEPTH", GLint, ["ctx->ModelviewMatrixStack.Depth + 1"], "", None ),
+ ( "GL_NAME_STACK_DEPTH", GLint, ["ctx->Select.NameStackDepth"], "", None ),
+ ( "GL_NORMALIZE", GLboolean, ["ctx->Transform.Normalize"], "", None ),
+ ( "GL_PACK_ALIGNMENT", GLint, ["ctx->Pack.Alignment"], "", None ),
+ ( "GL_PACK_LSB_FIRST", GLboolean, ["ctx->Pack.LsbFirst"], "", None ),
+ ( "GL_PACK_ROW_LENGTH", GLint, ["ctx->Pack.RowLength"], "", None ),
+ ( "GL_PACK_SKIP_PIXELS", GLint, ["ctx->Pack.SkipPixels"], "", None ),
+ ( "GL_PACK_SKIP_ROWS", GLint, ["ctx->Pack.SkipRows"], "", None ),
+ ( "GL_PACK_SWAP_BYTES", GLboolean, ["ctx->Pack.SwapBytes"], "", None ),
+ ( "GL_PACK_SKIP_IMAGES_EXT", GLint, ["ctx->Pack.SkipImages"], "", None ),
+ ( "GL_PACK_IMAGE_HEIGHT_EXT", GLint, ["ctx->Pack.ImageHeight"], "", None ),
+ ( "GL_PACK_INVERT_MESA", GLboolean, ["ctx->Pack.Invert"], "", None ),
+ ( "GL_PERSPECTIVE_CORRECTION_HINT", GLenum,
+ ["ctx->Hint.PerspectiveCorrection"], "", None ),
+ ( "GL_PIXEL_MAP_A_TO_A_SIZE", GLint, ["ctx->Pixel.MapAtoAsize"], "", None ),
+ ( "GL_PIXEL_MAP_B_TO_B_SIZE", GLint, ["ctx->Pixel.MapBtoBsize"], "", None ),
+ ( "GL_PIXEL_MAP_G_TO_G_SIZE", GLint, ["ctx->Pixel.MapGtoGsize"], "", None ),
+ ( "GL_PIXEL_MAP_I_TO_A_SIZE", GLint, ["ctx->Pixel.MapItoAsize"], "", None ),
+ ( "GL_PIXEL_MAP_I_TO_B_SIZE", GLint, ["ctx->Pixel.MapItoBsize"], "", None ),
+ ( "GL_PIXEL_MAP_I_TO_G_SIZE", GLint, ["ctx->Pixel.MapItoGsize"], "", None ),
+ ( "GL_PIXEL_MAP_I_TO_I_SIZE", GLint, ["ctx->Pixel.MapItoIsize"], "", None ),
+ ( "GL_PIXEL_MAP_I_TO_R_SIZE", GLint, ["ctx->Pixel.MapItoRsize"], "", None ),
+ ( "GL_PIXEL_MAP_R_TO_R_SIZE", GLint, ["ctx->Pixel.MapRtoRsize"], "", None ),
+ ( "GL_PIXEL_MAP_S_TO_S_SIZE", GLint, ["ctx->Pixel.MapStoSsize"], "", None ),
+ ( "GL_POINT_SIZE", GLfloat, ["ctx->Point.Size"], "", None ),
+ ( "GL_POINT_SIZE_GRANULARITY", GLfloat,
+ ["ctx->Const.PointSizeGranularity"], "", None ),
+ ( "GL_POINT_SIZE_RANGE", GLfloat,
+ ["ctx->Const.MinPointSizeAA",
+ "ctx->Const.MaxPointSizeAA"], "", None ),
+ ( "GL_ALIASED_POINT_SIZE_RANGE", GLfloat,
+ ["ctx->Const.MinPointSize",
+ "ctx->Const.MaxPointSize"], "", None ),
+ ( "GL_POINT_SMOOTH", GLboolean, ["ctx->Point.SmoothFlag"], "", None ),
+ ( "GL_POINT_SMOOTH_HINT", GLenum, ["ctx->Hint.PointSmooth"], "", None ),
+ ( "GL_POINT_SIZE_MIN_EXT", GLfloat, ["ctx->Point.MinSize"], "", None ),
+ ( "GL_POINT_SIZE_MAX_EXT", GLfloat, ["ctx->Point.MaxSize"], "", None ),
+ ( "GL_POINT_FADE_THRESHOLD_SIZE_EXT", GLfloat,
+ ["ctx->Point.Threshold"], "", None ),
+ ( "GL_DISTANCE_ATTENUATION_EXT", GLfloat,
+ ["ctx->Point.Params[0]",
+ "ctx->Point.Params[1]",
+ "ctx->Point.Params[2]"], "", None ),
+ ( "GL_POLYGON_MODE", GLenum,
+ ["ctx->Polygon.FrontMode",
+ "ctx->Polygon.BackMode"], "", None ),
+ ( "GL_POLYGON_OFFSET_BIAS_EXT", GLfloat, ["ctx->Polygon.OffsetUnits"], "", None ),
+ ( "GL_POLYGON_OFFSET_FACTOR", GLfloat, ["ctx->Polygon.OffsetFactor "], "", None ),
+ ( "GL_POLYGON_OFFSET_UNITS", GLfloat, ["ctx->Polygon.OffsetUnits "], "", None ),
+ ( "GL_POLYGON_SMOOTH", GLboolean, ["ctx->Polygon.SmoothFlag"], "", None ),
+ ( "GL_POLYGON_SMOOTH_HINT", GLenum, ["ctx->Hint.PolygonSmooth"], "", None ),
+ ( "GL_POLYGON_STIPPLE", GLboolean, ["ctx->Polygon.StippleFlag"], "", None ),
+ ( "GL_PROJECTION_MATRIX", GLfloat,
+ [ "matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]",
+ "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]",
+ "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]",
+ "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ],
+ "const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;", None ),
+ ( "GL_PROJECTION_STACK_DEPTH", GLint,
+ ["ctx->ProjectionMatrixStack.Depth + 1"], "", None ),
+ ( "GL_READ_BUFFER", GLenum, ["ctx->Pixel.ReadBuffer"], "", None ),
+ ( "GL_RED_BIAS", GLfloat, ["ctx->Pixel.RedBias"], "", None ),
+ ( "GL_RED_BITS", GLint, [" ctx->DrawBuffer->Visual.redBits "], "", None ),
+ ( "GL_RED_SCALE", GLfloat, ["ctx->Pixel.RedScale"], "", None ),
+ ( "GL_RENDER_MODE", GLenum, ["ctx->RenderMode"], "", None ),
+ ( "GL_RESCALE_NORMAL", GLboolean,
+ ["ctx->Transform.RescaleNormals"], "", None ),
+ ( "GL_RGBA_MODE", GLboolean, ["ctx->DrawBuffer->Visual.rgbMode"],
+ "", None ),
+ ( "GL_SCISSOR_BOX", GLint,
+ ["ctx->Scissor.X",
+ "ctx->Scissor.Y",
+ "ctx->Scissor.Width",
+ "ctx->Scissor.Height"], "", None ),
+ ( "GL_SCISSOR_TEST", GLboolean, ["ctx->Scissor.Enabled"], "", None ),
+ ( "GL_SELECTION_BUFFER_SIZE", GLint, ["ctx->Select.BufferSize"], "", None ),
+ ( "GL_SHADE_MODEL", GLenum, ["ctx->Light.ShadeModel"], "", None ),
+ ( "GL_SHARED_TEXTURE_PALETTE_EXT", GLboolean,
+ ["ctx->Texture.SharedPalette"], "", None ),
+ ( "GL_STENCIL_BITS", GLint, ["ctx->DrawBuffer->Visual.stencilBits"], "", None ),
+ ( "GL_STENCIL_CLEAR_VALUE", GLint, ["ctx->Stencil.Clear"], "", None ),
+ ( "GL_STENCIL_FAIL", GLenum,
+ ["ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]"], "", None ),
+ ( "GL_STENCIL_FUNC", GLenum,
+ ["ctx->Stencil.Function[ctx->Stencil.ActiveFace]"], "", None ),
+ ( "GL_STENCIL_PASS_DEPTH_FAIL", GLenum,
+ ["ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]"], "", None ),
+ ( "GL_STENCIL_PASS_DEPTH_PASS", GLenum,
+ ["ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]"], "", None ),
+ ( "GL_STENCIL_REF", GLint,
+ ["ctx->Stencil.Ref[ctx->Stencil.ActiveFace]"], "", None ),
+ ( "GL_STENCIL_TEST", GLboolean, ["ctx->Stencil.Enabled"], "", None ),
+ ( "GL_STENCIL_VALUE_MASK", GLint,
+ ["ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]"], "", None ),
+ ( "GL_STENCIL_WRITEMASK", GLint,
+ ["ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]"], "", None ),
+ ( "GL_STEREO", GLboolean, ["ctx->DrawBuffer->Visual.stereoMode"],
+ "", None ),
+ ( "GL_SUBPIXEL_BITS", GLint, ["ctx->Const.SubPixelBits"], "", None ),
+ ( "GL_TEXTURE_1D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_1D)"], "", None ),
+ ( "GL_TEXTURE_2D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_2D)"], "", None ),
+ ( "GL_TEXTURE_3D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_3D)"], "", None ),
+ ( "GL_TEXTURE_BINDING_1D", GLint,
+ ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current1D->Name"], "", None ),
+ ( "GL_TEXTURE_BINDING_2D", GLint,
+ ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current2D->Name"], "", None ),
+ ( "GL_TEXTURE_BINDING_3D", GLint,
+ ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].Current3D->Name"], "", None ),
+ ( "GL_TEXTURE_ENV_COLOR", GLfloatN,
+ ["color[0]", "color[1]", "color[2]", "color[3]"],
+ "const GLfloat *color = ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvColor;",
+ None ),
+ ( "GL_TEXTURE_ENV_MODE", GLenum,
+ ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].EnvMode"], "", None ),
+ ( "GL_TEXTURE_GEN_S", GLboolean,
+ ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)"], "", None ),
+ ( "GL_TEXTURE_GEN_T", GLboolean,
+ ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & T_BIT) ? 1 : 0)"], "", None ),
+ ( "GL_TEXTURE_GEN_R", GLboolean,
+ ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & R_BIT) ? 1 : 0)"], "", None ),
+ ( "GL_TEXTURE_GEN_Q", GLboolean,
+ ["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & Q_BIT) ? 1 : 0)"], "", None ),
+ ( "GL_TEXTURE_MATRIX", GLfloat,
+ ["matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]",
+ "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]",
+ "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]",
+ "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ],
+ "const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;", None ),
+ ( "GL_TEXTURE_STACK_DEPTH", GLint,
+ ["ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Depth + 1"], "", None ),
+ ( "GL_UNPACK_ALIGNMENT", GLint, ["ctx->Unpack.Alignment"], "", None ),
+ ( "GL_UNPACK_LSB_FIRST", GLboolean, ["ctx->Unpack.LsbFirst"], "", None ),
+ ( "GL_UNPACK_ROW_LENGTH", GLint, ["ctx->Unpack.RowLength"], "", None ),
+ ( "GL_UNPACK_SKIP_PIXELS", GLint, ["ctx->Unpack.SkipPixels"], "", None ),
+ ( "GL_UNPACK_SKIP_ROWS", GLint, ["ctx->Unpack.SkipRows"], "", None ),
+ ( "GL_UNPACK_SWAP_BYTES", GLboolean, ["ctx->Unpack.SwapBytes"], "", None ),
+ ( "GL_UNPACK_SKIP_IMAGES_EXT", GLint, ["ctx->Unpack.SkipImages"], "", None ),
+ ( "GL_UNPACK_IMAGE_HEIGHT_EXT", GLint, ["ctx->Unpack.ImageHeight"], "", None ),
+ ( "GL_UNPACK_CLIENT_STORAGE_APPLE", GLboolean, ["ctx->Unpack.ClientStorage"], "", None ),
+ ( "GL_VIEWPORT", GLint, [ "ctx->Viewport.X", "ctx->Viewport.Y",
+ "ctx->Viewport.Width", "ctx->Viewport.Height" ], "", None ),
+ ( "GL_ZOOM_X", GLfloat, ["ctx->Pixel.ZoomX"], "", None ),
+ ( "GL_ZOOM_Y", GLfloat, ["ctx->Pixel.ZoomY"], "", None ),
+
+ # Vertex arrays
+ ( "GL_VERTEX_ARRAY", GLboolean, ["ctx->Array.Vertex.Enabled"], "", None ),
+ ( "GL_VERTEX_ARRAY_SIZE", GLint, ["ctx->Array.Vertex.Size"], "", None ),
+ ( "GL_VERTEX_ARRAY_TYPE", GLenum, ["ctx->Array.Vertex.Type"], "", None ),
+ ( "GL_VERTEX_ARRAY_STRIDE", GLint, ["ctx->Array.Vertex.Stride"], "", None ),
+ ( "GL_VERTEX_ARRAY_COUNT_EXT", GLint, ["0"], "", None ),
+ ( "GL_NORMAL_ARRAY", GLenum, ["ctx->Array.Normal.Enabled"], "", None ),
+ ( "GL_NORMAL_ARRAY_TYPE", GLenum, ["ctx->Array.Normal.Type"], "", None ),
+ ( "GL_NORMAL_ARRAY_STRIDE", GLint, ["ctx->Array.Normal.Stride"], "", None ),
+ ( "GL_NORMAL_ARRAY_COUNT_EXT", GLint, ["0"], "", None ),
+ ( "GL_COLOR_ARRAY", GLboolean, ["ctx->Array.Color.Enabled"], "", None ),
+ ( "GL_COLOR_ARRAY_SIZE", GLint, ["ctx->Array.Color.Size"], "", None ),
+ ( "GL_COLOR_ARRAY_TYPE", GLenum, ["ctx->Array.Color.Type"], "", None ),
+ ( "GL_COLOR_ARRAY_STRIDE", GLint, ["ctx->Array.Color.Stride"], "", None ),
+ ( "GL_COLOR_ARRAY_COUNT_EXT", GLint, ["0"], "", None ),
+ ( "GL_INDEX_ARRAY", GLboolean, ["ctx->Array.Index.Enabled"], "", None ),
+ ( "GL_INDEX_ARRAY_TYPE", GLenum, ["ctx->Array.Index.Type"], "", None ),
+ ( "GL_INDEX_ARRAY_STRIDE", GLint, ["ctx->Array.Index.Stride"], "", None ),
+ ( "GL_INDEX_ARRAY_COUNT_EXT", GLint, ["0"], "", None ),
+ ( "GL_TEXTURE_COORD_ARRAY", GLboolean,
+ ["ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled"], "", None ),
+ ( "GL_TEXTURE_COORD_ARRAY_SIZE", GLint,
+ ["ctx->Array.TexCoord[ctx->Array.ActiveTexture].Size"], "", None ),
+ ( "GL_TEXTURE_COORD_ARRAY_TYPE", GLenum,
+ ["ctx->Array.TexCoord[ctx->Array.ActiveTexture].Type"], "", None ),
+ ( "GL_TEXTURE_COORD_ARRAY_STRIDE", GLint,
+ ["ctx->Array.TexCoord[ctx->Array.ActiveTexture].Stride"], "", None ),
+ ( "GL_TEXTURE_COORD_ARRAY_COUNT_EXT", GLint, ["0"], "", None ),
+ ( "GL_EDGE_FLAG_ARRAY", GLboolean, ["ctx->Array.EdgeFlag.Enabled"], "", None ),
+ ( "GL_EDGE_FLAG_ARRAY_STRIDE", GLint, ["ctx->Array.EdgeFlag.Stride"], "", None ),
+ ( "GL_EDGE_FLAG_ARRAY_COUNT_EXT", GLint, ["0"], "", None ),
+
+ # GL_ARB_multitexture
+ ( "GL_MAX_TEXTURE_UNITS_ARB", GLint,
+ ["MIN2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits)"],
+ "", "ARB_multitexture" ),
+ ( "GL_ACTIVE_TEXTURE_ARB", GLint,
+ [ "GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit"], "", "ARB_multitexture" ),
+ ( "GL_CLIENT_ACTIVE_TEXTURE_ARB", GLint,
+ ["GL_TEXTURE0_ARB + ctx->Array.ActiveTexture"], "", "ARB_multitexture" ),
+
+ # GL_ARB_texture_cube_map
+ ( "GL_TEXTURE_CUBE_MAP_ARB", GLboolean,
+ ["_mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB)"], "", "ARB_texture_cube_map" ),
+ ( "GL_TEXTURE_BINDING_CUBE_MAP_ARB", GLint,
+ ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentCubeMap->Name"],
+ "", "ARB_texture_cube_map" ),
+ ( "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB", GLint,
+ ["(1 << (ctx->Const.MaxCubeTextureLevels - 1))"],
+ "", "ARB_texture_cube_map"),
+
+ # GL_ARB_texture_compression */
+ ( "GL_TEXTURE_COMPRESSION_HINT_ARB", GLint,
+ ["ctx->Hint.TextureCompression"], "", "ARB_texture_compression" ),
+ ( "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB", GLint,
+ ["_mesa_get_compressed_formats(ctx, NULL)"], "", "ARB_texture_compression" ),
+ ( "GL_COMPRESSED_TEXTURE_FORMATS_ARB", GLenum,
+ [],
+ """GLint formats[100];
+ GLuint i, n = _mesa_get_compressed_formats(ctx, formats);
+ ASSERT(n <= 100);
+ for (i = 0; i < n; i++)
+ params[i] = ENUM_TO_INT(formats[i]);""",
+ "ARB_texture_compression" ),
+
+ # GL_EXT_compiled_vertex_array
+ ( "GL_ARRAY_ELEMENT_LOCK_FIRST_EXT", GLint, ["ctx->Array.LockFirst"],
+ "", "EXT_compiled_vertex_array" ),
+ ( "GL_ARRAY_ELEMENT_LOCK_COUNT_EXT", GLint, ["ctx->Array.LockCount"],
+ "", "EXT_compiled_vertex_array" ),
+
+ # GL_ARB_transpose_matrix
+ ( "GL_TRANSPOSE_COLOR_MATRIX_ARB", GLfloat,
+ ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]",
+ "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]",
+ "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]",
+ "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"],
+ "const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;", None ),
+ ( "GL_TRANSPOSE_MODELVIEW_MATRIX_ARB", GLfloat,
+ ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]",
+ "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]",
+ "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]",
+ "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"],
+ "const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;", None ),
+ ( "GL_TRANSPOSE_PROJECTION_MATRIX_ARB", GLfloat,
+ ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]",
+ "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]",
+ "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]",
+ "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"],
+ "const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;", None ),
+ ( "GL_TRANSPOSE_TEXTURE_MATRIX_ARB", GLfloat,
+ ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]",
+ "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]",
+ "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]",
+ "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"],
+ "const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;", None ),
+
+ # GL_HP_occlusion_test
+ ( "GL_OCCLUSION_TEST_HP", GLboolean, ["ctx->Depth.OcclusionTest"], "",
+ "HP_occlusion_test" ),
+ ( "GL_OCCLUSION_TEST_RESULT_HP", GLboolean, [],
+ """FLUSH_VERTICES(ctx, _NEW_DEPTH);
+ if (ctx->Depth.OcclusionTest)
+ params[0] = ctx->OcclusionResult;
+ else
+ params[0] = ctx->OcclusionResultSaved;
+ /* reset flag now */
+ ctx->OcclusionResult = GL_FALSE;
+ ctx->OcclusionResultSaved = GL_FALSE;
+ return;""",
+ "HP_occlusion_test" ),
+
+ # GL_SGIS_pixel_texture
+ ( "GL_PIXEL_TEXTURE_SGIS", GLboolean, ["ctx->Pixel.PixelTextureEnabled"],
+ "", "SGIS_pixel_texture" ),
+
+ # GL_SGIX_pixel_texture
+ ( "GL_PIXEL_TEX_GEN_SGIX", GLboolean, ["ctx->Pixel.PixelTextureEnabled"],
+ "", "SGIX_pixel_texture" ),
+ ( "GL_PIXEL_TEX_GEN_MODE_SGIX", GLenum, ["pixel_texgen_mode(ctx)"],
+ "", "SGIX_pixel_texture" ),
+
+ # GL_SGI_color_matrix (also in 1.2 imaging)
+ ( "GL_COLOR_MATRIX_SGI", GLfloat,
+ ["matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]",
+ "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]",
+ "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]",
+ "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ],
+ "const GLfloat *matrix = ctx->ColorMatrixStack.Top->m;", None ),
+ ( "GL_COLOR_MATRIX_STACK_DEPTH_SGI", GLint,
+ ["ctx->ColorMatrixStack.Depth + 1"], "", None ),
+ ( "GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI", GLint,
+ ["MAX_COLOR_STACK_DEPTH"], "", None ),
+ ( "GL_POST_COLOR_MATRIX_RED_SCALE_SGI", GLfloat,
+ ["ctx->Pixel.PostColorMatrixScale[0]"], "", None ),
+ ( "GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI", GLfloat,
+ ["ctx->Pixel.PostColorMatrixScale[1]"], "", None ),
+ ( "GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI", GLfloat,
+ ["ctx->Pixel.PostColorMatrixScale[2]"], "", None ),
+ ( "GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI", GLfloat,
+ ["ctx->Pixel.PostColorMatrixScale[3]"], "", None ),
+ ( "GL_POST_COLOR_MATRIX_RED_BIAS_SGI", GLfloat,
+ ["ctx->Pixel.PostColorMatrixBias[0]"], "", None ),
+ ( "GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI", GLfloat,
+ ["ctx->Pixel.PostColorMatrixBias[1]"], "", None ),
+ ( "GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI", GLfloat,
+ ["ctx->Pixel.PostColorMatrixBias[2]"], "", None ),
+ ( "GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI", GLfloat,
+ ["ctx->Pixel.PostColorMatrixBias[3]"], "", None ),
+
+ # GL_EXT_convolution (also in 1.2 imaging)
+ ( "GL_CONVOLUTION_1D_EXT", GLboolean,
+ ["ctx->Pixel.Convolution1DEnabled"], "", "EXT_convolution" ),
+ ( "GL_CONVOLUTION_2D_EXT", GLboolean,
+ ["ctx->Pixel.Convolution2DEnabled"], "", "EXT_convolution" ),
+ ( "GL_SEPARABLE_2D_EXT", GLboolean,
+ ["ctx->Pixel.Separable2DEnabled"], "", "EXT_convolution" ),
+ ( "GL_POST_CONVOLUTION_RED_SCALE_EXT", GLfloat,
+ ["ctx->Pixel.PostConvolutionScale[0]"], "", "EXT_convolution" ),
+ ( "GL_POST_CONVOLUTION_GREEN_SCALE_EXT", GLfloat,
+ ["ctx->Pixel.PostConvolutionScale[1]"], "", "EXT_convolution" ),
+ ( "GL_POST_CONVOLUTION_BLUE_SCALE_EXT", GLfloat,
+ ["ctx->Pixel.PostConvolutionScale[2]"], "", "EXT_convolution" ),
+ ( "GL_POST_CONVOLUTION_ALPHA_SCALE_EXT", GLfloat,
+ ["ctx->Pixel.PostConvolutionScale[3]"], "", "EXT_convolution" ),
+ ( "GL_POST_CONVOLUTION_RED_BIAS_EXT", GLfloat,
+ ["ctx->Pixel.PostConvolutionBias[0]"], "", "EXT_convolution" ),
+ ( "GL_POST_CONVOLUTION_GREEN_BIAS_EXT", GLfloat,
+ ["ctx->Pixel.PostConvolutionBias[1]"], "", "EXT_convolution" ),
+ ( "GL_POST_CONVOLUTION_BLUE_BIAS_EXT", GLfloat,
+ ["ctx->Pixel.PostConvolutionBias[2]"], "", "EXT_convolution" ),
+ ( "GL_POST_CONVOLUTION_ALPHA_BIAS_EXT", GLfloat,
+ ["ctx->Pixel.PostConvolutionBias[3]"], "", "EXT_convolution" ),
+
+ # GL_EXT_histogram / GL_ARB_imaging
+ ( "GL_HISTOGRAM", GLboolean,
+ [ "ctx->Pixel.HistogramEnabled" ], "", "EXT_histogram" ),
+ ( "GL_MINMAX", GLboolean,
+ [ "ctx->Pixel.MinMaxEnabled" ], "", "EXT_histogram" ),
+
+ # GL_SGI_color_table / GL_ARB_imaging
+ ( "GL_COLOR_TABLE_SGI", GLboolean,
+ ["ctx->Pixel.ColorTableEnabled"], "", "SGI_color_table" ),
+ ( "GL_POST_CONVOLUTION_COLOR_TABLE_SGI", GLboolean,
+ ["ctx->Pixel.PostConvolutionColorTableEnabled"], "", "SGI_color_table" ),
+ ( "GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI", GLboolean,
+ ["ctx->Pixel.PostColorMatrixColorTableEnabled"], "", "SGI_color_table" ),
+
+ # GL_SGI_texture_color_table
+ ( "GL_TEXTURE_COLOR_TABLE_SGI", GLboolean,
+ ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].ColorTableEnabled"],
+ "", "SGI_texture_color_table" ),
+
+ # GL_EXT_secondary_color
+ ( "GL_COLOR_SUM_EXT", GLboolean,
+ ["ctx->Fog.ColorSumEnabled"], "", "EXT_secondary_color" ),
+ ( "GL_CURRENT_SECONDARY_COLOR_EXT", GLfloatN,
+ ["ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0]",
+ "ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1]",
+ "ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2]",
+ "ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3]"],
+ "FLUSH_CURRENT(ctx, 0);", "EXT_secondary_color" ),
+ ( "GL_SECONDARY_COLOR_ARRAY_EXT", GLboolean,
+ ["ctx->Array.SecondaryColor.Enabled"], "", "EXT_secondary_color" ),
+ ( "GL_SECONDARY_COLOR_ARRAY_TYPE_EXT", GLenum,
+ ["ctx->Array.SecondaryColor.Type"], "", "EXT_secondary_color" ),
+ ( "GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT", GLint,
+ ["ctx->Array.SecondaryColor.Stride"], "", "EXT_secondary_color" ),
+ ( "GL_SECONDARY_COLOR_ARRAY_SIZE_EXT", GLint,
+ ["ctx->Array.SecondaryColor.Size"], "", "EXT_secondary_color" ),
+
+ # GL_EXT_fog_coord
+ ( "GL_CURRENT_FOG_COORDINATE_EXT", GLfloat,
+ ["ctx->Current.Attrib[VERT_ATTRIB_FOG][0]"],
+ "FLUSH_CURRENT(ctx, 0);", "EXT_fog_coord" ),
+ ( "GL_FOG_COORDINATE_ARRAY_EXT", GLboolean, ["ctx->Array.FogCoord.Enabled"],
+ "", "EXT_fog_coord" ),
+ ( "GL_FOG_COORDINATE_ARRAY_TYPE_EXT", GLenum, ["ctx->Array.FogCoord.Type"],
+ "", "EXT_fog_coord" ),
+ ( "GL_FOG_COORDINATE_ARRAY_STRIDE_EXT", GLint, ["ctx->Array.FogCoord.Stride"],
+ "", "EXT_fog_coord" ),
+ ( "GL_FOG_COORDINATE_SOURCE_EXT", GLenum, ["ctx->Fog.FogCoordinateSource"],
+ "", "EXT_fog_coord" ),
+
+ # GL_EXT_texture_lod_bias
+ ( "GL_MAX_TEXTURE_LOD_BIAS_EXT", GLfloat,
+ ["ctx->Const.MaxTextureLodBias"], "", "EXT_texture_lod_bias"),
+
+ # GL_EXT_texture_filter_anisotropic
+ ( "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT", GLfloat,
+ ["ctx->Const.MaxTextureMaxAnisotropy"], "", "EXT_texture_filter_anisotropic"),
+
+ # GL_ARB_multisample
+ ( "GL_MULTISAMPLE_ARB", GLboolean,
+ ["ctx->Multisample.Enabled"], "", "ARB_multisample" ),
+ ( "GL_SAMPLE_ALPHA_TO_COVERAGE_ARB", GLboolean,
+ ["ctx->Multisample.SampleAlphaToCoverage"], "", "ARB_multisample" ),
+ ( "GL_SAMPLE_ALPHA_TO_ONE_ARB", GLboolean,
+ ["ctx->Multisample.SampleAlphaToOne"], "", "ARB_multisample" ),
+ ( "GL_SAMPLE_COVERAGE_ARB", GLboolean,
+ ["ctx->Multisample.SampleCoverage"], "", "ARB_multisample" ),
+ ( "GL_SAMPLE_COVERAGE_VALUE_ARB", GLfloat,
+ ["ctx->Multisample.SampleCoverageValue"], "", "ARB_multisample" ),
+ ( "GL_SAMPLE_COVERAGE_INVERT_ARB", GLboolean,
+ ["ctx->Multisample.SampleCoverageInvert"], "", "ARB_multisample" ),
+ ( "GL_SAMPLE_BUFFERS_ARB", GLint,
+ ["ctx->DrawBuffer->Visual.sampleBuffers"], "", "ARB_multisample" ),
+ ( "GL_SAMPLES_ARB", GLint,
+ ["ctx->DrawBuffer->Visual.samples"], "", "ARB_multisample" ),
+
+ # GL_IBM_rasterpos_clip
+ ( "GL_RASTER_POSITION_UNCLIPPED_IBM", GLboolean,
+ ["ctx->Transform.RasterPositionUnclipped"], "", "IBM_rasterpos_clip" ),
+
+ # GL_NV_point_sprite
+ ( "GL_POINT_SPRITE_NV", GLboolean, ["ctx->Point.PointSprite"],
+ "", "NV_point_sprite" ), # OR ARB_point_sprite
+ ( "GL_POINT_SPRITE_R_MODE_NV", GLenum, ["ctx->Point.SpriteRMode"],
+ "", "NV_point_sprite" ), # OR ARB_point_sprite
+ ( "GL_POINT_SPRITE_COORD_ORIGIN", GLenum, ["ctx->Point.SpriteOrigin"],
+ "", "NV_point_sprite" ), # OR ARB_point_sprite
+
+ # GL_SGIS_generate_mipmap
+ ( "GL_GENERATE_MIPMAP_HINT_SGIS", GLenum, ["ctx->Hint.GenerateMipmap"],
+ "", "SGIS_generate_mipmap" ),
+
+ # GL_NV_vertex_program
+ ( "GL_VERTEX_PROGRAM_NV", GLboolean,
+ ["ctx->VertexProgram.Enabled"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_PROGRAM_POINT_SIZE_NV", GLboolean,
+ ["ctx->VertexProgram.PointSizeEnabled"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_PROGRAM_TWO_SIDE_NV", GLboolean,
+ ["ctx->VertexProgram.TwoSideEnabled"], "", "NV_vertex_program" ),
+ ( "GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV", GLint,
+ ["ctx->Const.MaxProgramMatrixStackDepth"], "", "NV_vertex_program" ),
+ ( "GL_MAX_TRACK_MATRICES_NV", GLint,
+ ["ctx->Const.MaxProgramMatrices"], "", "NV_vertex_program" ),
+ ( "GL_CURRENT_MATRIX_STACK_DEPTH_NV", GLboolean,
+ ["ctx->CurrentStack->Depth + 1"], "", "NV_vertex_program" ),
+ ( "GL_CURRENT_MATRIX_NV", GLfloat,
+ ["matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]",
+ "matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]",
+ "matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]",
+ "matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ],
+ "const GLfloat *matrix = ctx->CurrentStack->Top->m;", "NV_vertex_program" ),
+ ( "GL_VERTEX_PROGRAM_BINDING_NV", GLint,
+ ["(ctx->VertexProgram.Current ? ctx->VertexProgram.Current->Base.Id : 0)"],
+ "", "NV_vertex_program" ),
+ ( "GL_PROGRAM_ERROR_POSITION_NV", GLint,
+ ["ctx->Program.ErrorPos"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_ATTRIB_ARRAY0_NV", GLboolean,
+ ["ctx->Array.VertexAttrib[0].Enabled"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_ATTRIB_ARRAY1_NV", GLboolean,
+ ["ctx->Array.VertexAttrib[1].Enabled"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_ATTRIB_ARRAY2_NV", GLboolean,
+ ["ctx->Array.VertexAttrib[2].Enabled"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_ATTRIB_ARRAY3_NV", GLboolean,
+ ["ctx->Array.VertexAttrib[3].Enabled"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_ATTRIB_ARRAY4_NV", GLboolean,
+ ["ctx->Array.VertexAttrib[4].Enabled"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_ATTRIB_ARRAY5_NV", GLboolean,
+ ["ctx->Array.VertexAttrib[5].Enabled"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_ATTRIB_ARRAY6_NV", GLboolean,
+ ["ctx->Array.VertexAttrib[6].Enabled"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_ATTRIB_ARRAY7_NV", GLboolean,
+ ["ctx->Array.VertexAttrib[7].Enabled"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_ATTRIB_ARRAY8_NV", GLboolean,
+ ["ctx->Array.VertexAttrib[8].Enabled"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_ATTRIB_ARRAY9_NV", GLboolean,
+ ["ctx->Array.VertexAttrib[9].Enabled"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_ATTRIB_ARRAY10_NV", GLboolean,
+ ["ctx->Array.VertexAttrib[10].Enabled"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_ATTRIB_ARRAY11_NV", GLboolean,
+ ["ctx->Array.VertexAttrib[11].Enabled"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_ATTRIB_ARRAY12_NV", GLboolean,
+ ["ctx->Array.VertexAttrib[12].Enabled"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_ATTRIB_ARRAY13_NV", GLboolean,
+ ["ctx->Array.VertexAttrib[13].Enabled"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_ATTRIB_ARRAY14_NV", GLboolean,
+ ["ctx->Array.VertexAttrib[14].Enabled"], "", "NV_vertex_program" ),
+ ( "GL_VERTEX_ATTRIB_ARRAY15_NV", GLboolean,
+ ["ctx->Array.VertexAttrib[15].Enabled"], "", "NV_vertex_program" ),
+ ( "GL_MAP1_VERTEX_ATTRIB0_4_NV", GLboolean,
+ ["ctx->Eval.Map1Attrib[0]"], "", "NV_vertex_program" ),
+ ( "GL_MAP1_VERTEX_ATTRIB1_4_NV", GLboolean,
+ ["ctx->Eval.Map1Attrib[1]"], "", "NV_vertex_program" ),
+ ( "GL_MAP1_VERTEX_ATTRIB2_4_NV", GLboolean,
+ ["ctx->Eval.Map1Attrib[2]"], "", "NV_vertex_program" ),
+ ( "GL_MAP1_VERTEX_ATTRIB3_4_NV", GLboolean,
+ ["ctx->Eval.Map1Attrib[3]"], "", "NV_vertex_program" ),
+ ( "GL_MAP1_VERTEX_ATTRIB4_4_NV", GLboolean,
+ ["ctx->Eval.Map1Attrib[4]"], "", "NV_vertex_program" ),
+ ( "GL_MAP1_VERTEX_ATTRIB5_4_NV", GLboolean,
+ ["ctx->Eval.Map1Attrib[5]"], "", "NV_vertex_program" ),
+ ( "GL_MAP1_VERTEX_ATTRIB6_4_NV", GLboolean,
+ ["ctx->Eval.Map1Attrib[6]"], "", "NV_vertex_program" ),
+ ( "GL_MAP1_VERTEX_ATTRIB7_4_NV", GLboolean,
+ ["ctx->Eval.Map1Attrib[7]"], "", "NV_vertex_program" ),
+ ( "GL_MAP1_VERTEX_ATTRIB8_4_NV", GLboolean,
+ ["ctx->Eval.Map1Attrib[8]"], "", "NV_vertex_program" ),
+ ( "GL_MAP1_VERTEX_ATTRIB9_4_NV", GLboolean,
+ ["ctx->Eval.Map1Attrib[9]"], "", "NV_vertex_program" ),
+ ( "GL_MAP1_VERTEX_ATTRIB10_4_NV", GLboolean,
+ ["ctx->Eval.Map1Attrib[10]"], "", "NV_vertex_program" ),
+ ( "GL_MAP1_VERTEX_ATTRIB11_4_NV", GLboolean,
+ ["ctx->Eval.Map1Attrib[11]"], "", "NV_vertex_program" ),
+ ( "GL_MAP1_VERTEX_ATTRIB12_4_NV", GLboolean,
+ ["ctx->Eval.Map1Attrib[12]"], "", "NV_vertex_program" ),
+ ( "GL_MAP1_VERTEX_ATTRIB13_4_NV", GLboolean,
+ ["ctx->Eval.Map1Attrib[13]"], "", "NV_vertex_program" ),
+ ( "GL_MAP1_VERTEX_ATTRIB14_4_NV", GLboolean,
+ ["ctx->Eval.Map1Attrib[14]"], "", "NV_vertex_program" ),
+ ( "GL_MAP1_VERTEX_ATTRIB15_4_NV", GLboolean,
+ ["ctx->Eval.Map1Attrib[15]"], "", "NV_vertex_program" ),
+
+ # GL_NV_fragment_program
+ ( "GL_FRAGMENT_PROGRAM_NV", GLboolean,
+ ["ctx->FragmentProgram.Enabled"], "", "NV_fragment_program" ),
+ ( "GL_MAX_TEXTURE_COORDS_NV", GLint,
+ ["ctx->Const.MaxTextureCoordUnits"], "", "NV_fragment_program" ),
+ ( "GL_MAX_TEXTURE_IMAGE_UNITS_NV", GLint,
+ ["ctx->Const.MaxTextureImageUnits"], "", "NV_fragment_program" ),
+ ( "GL_FRAGMENT_PROGRAM_BINDING_NV", GLint,
+ ["ctx->FragmentProgram.Current ? ctx->FragmentProgram.Current->Base.Id : 0"],
+ "", "NV_fragment_program" ),
+ ( "GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV", GLint,
+ ["MAX_NV_FRAGMENT_PROGRAM_PARAMS"], "", "NV_fragment_program" ),
+
+ # GL_NV_texture_rectangle
+ ( "GL_TEXTURE_RECTANGLE_NV", GLboolean,
+ ["_mesa_IsEnabled(GL_TEXTURE_RECTANGLE_NV)"], "", "NV_texture_rectangle" ),
+ ( "GL_TEXTURE_BINDING_RECTANGLE_NV", GLint,
+ ["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentRect->Name"],
+ "", "NV_texture_rectangle" ),
+ ( "GL_MAX_RECTANGLE_TEXTURE_SIZE_NV", GLint,
+ ["ctx->Const.MaxTextureRectSize"], "", "NV_texture_rectangle" ),
+
+ # GL_EXT_stencil_two_side
+ ( "GL_STENCIL_TEST_TWO_SIDE_EXT", GLboolean,
+ ["ctx->Stencil.TestTwoSide"], "", "EXT_stencil_two_side" ),
+ ( "GL_ACTIVE_STENCIL_FACE_EXT", GLenum,
+ ["ctx->Stencil.ActiveFace ? GL_BACK : GL_FRONT"],
+ "", "EXT_stencil_two_side" ),
+
+ # GL_NV_light_max_exponent
+ ( "GL_MAX_SHININESS_NV", GLfloat,
+ ["ctx->Const.MaxShininess"], "", "NV_light_max_exponent" ),
+ ( "GL_MAX_SPOT_EXPONENT_NV", GLfloat,
+ ["ctx->Const.MaxSpotExponent"], "", "NV_light_max_exponent" ),
+
+ # GL_ARB_vertex_buffer_object
+ ( "GL_ARRAY_BUFFER_BINDING_ARB", GLint,
+ ["ctx->Array.ArrayBufferObj->Name"], "", "ARB_vertex_buffer_object" ),
+ ( "GL_VERTEX_ARRAY_BUFFER_BINDING_ARB", GLint,
+ ["ctx->Array.Vertex.BufferObj->Name"], "", "ARB_vertex_buffer_object" ),
+ ( "GL_NORMAL_ARRAY_BUFFER_BINDING_ARB", GLint,
+ ["ctx->Array.Normal.BufferObj->Name"], "", "ARB_vertex_buffer_object" ),
+ ( "GL_COLOR_ARRAY_BUFFER_BINDING_ARB", GLint,
+ ["ctx->Array.Color.BufferObj->Name"], "", "ARB_vertex_buffer_object" ),
+ ( "GL_INDEX_ARRAY_BUFFER_BINDING_ARB", GLint,
+ ["ctx->Array.Index.BufferObj->Name"], "", "ARB_vertex_buffer_object" ),
+ ( "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB", GLint,
+ ["ctx->Array.TexCoord[ctx->Array.ActiveTexture].BufferObj->Name"],
+ "", "ARB_vertex_buffer_object" ),
+ ( "GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB", GLint,
+ ["ctx->Array.EdgeFlag.BufferObj->Name"], "", "ARB_vertex_buffer_object" ),
+ ( "GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB", GLint,
+ ["ctx->Array.SecondaryColor.BufferObj->Name"],
+ "", "ARB_vertex_buffer_object" ),
+ ( "GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB", GLint,
+ ["ctx->Array.FogCoord.BufferObj->Name"], "", "ARB_vertex_buffer_object" ),
+ # GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported
+ ( "GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB", GLint,
+ ["ctx->Array.ElementArrayBufferObj->Name"], "", "ARB_vertex_buffer_object" ),
+
+ # GL_EXT_pixel_buffer_object
+ ( "GL_PIXEL_PACK_BUFFER_BINDING_EXT", GLint,
+ ["ctx->Pack.BufferObj->Name"], "", "EXT_pixel_buffer_object" ),
+ ( "GL_PIXEL_UNPACK_BUFFER_BINDING_EXT", GLint,
+ ["ctx->Unpack.BufferObj->Name"], "", "EXT_pixel_buffer_object" ),
+
+ # GL_ARB_vertex_program
+ ( "GL_MAX_VERTEX_ATTRIBS_ARB", GLint,
+ ["ctx->Const.MaxVertexProgramAttribs"], "", "ARB_vertex_program" ),
+
+ # GL_ARB_fragment_program
+ ( "GL_FRAGMENT_PROGRAM_ARB", GLboolean,
+ ["ctx->FragmentProgram.Enabled"], "", "ARB_fragment_program" ),
+ ( "GL_TRANSPOSE_CURRENT_MATRIX_ARB", GLfloat,
+ ["matrix[0]", "matrix[4]", "matrix[8]", "matrix[12]",
+ "matrix[1]", "matrix[5]", "matrix[9]", "matrix[13]",
+ "matrix[2]", "matrix[6]", "matrix[10]", "matrix[14]",
+ "matrix[3]", "matrix[7]", "matrix[11]", "matrix[15]"],
+ "const GLfloat *matrix = ctx->CurrentStack->Top->m;", "ARB_fragment_program" ),
+
+ # GL_EXT_depth_bounds_test
+ ( "GL_DEPTH_BOUNDS_TEST_EXT", GLboolean,
+ ["ctx->Depth.BoundsTest"], "", "EXT_depth_bounds_test" ),
+ ( "GL_DEPTH_BOUNDS_EXT", GLfloat,
+ ["ctx->Depth.BoundsMin", "ctx->Depth.BoundsMax"],
+ "", "EXT_depth_bounds_test" ),
+
+ # GL_MESA_program_debug
+ ( "GL_FRAGMENT_PROGRAM_CALLBACK_MESA", GLboolean,
+ ["ctx->FragmentProgram.CallbackEnabled"], "", "MESA_program_debug" ),
+ ( "GL_VERTEX_PROGRAM_CALLBACK_MESA", GLboolean,
+ ["ctx->VertexProgram.CallbackEnabled"], "", "MESA_program_debug" ),
+ ( "GL_FRAGMENT_PROGRAM_POSITION_MESA", GLint,
+ ["ctx->FragmentProgram.CurrentPosition"], "", "MESA_program_debug" ),
+ ( "GL_VERTEX_PROGRAM_POSITION_MESA", GLint,
+ ["ctx->VertexProgram.CurrentPosition"], "", "MESA_program_debug" ),
+
+ # GL_ARB_draw_buffers
+ ( "GL_MAX_DRAW_BUFFERS_ARB", GLint,
+ ["ctx->Const.MaxDrawBuffers"], "", "ARB_draw_buffers" ),
+ ( "GL_DRAW_BUFFER0_ARB", GLenum,
+ ["ctx->Color.DrawBuffer[0]"], "", "ARB_draw_buffers" ),
+ ( "GL_DRAW_BUFFER1_ARB", GLenum,
+ ["buffer"],
+ """GLenum buffer;
+ if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)");
+ return;
+ }
+ buffer = ctx->Color.DrawBuffer[1];""", "ARB_draw_buffers" ),
+ ( "GL_DRAW_BUFFER2_ARB", GLenum,
+ ["buffer"],
+ """GLenum buffer;
+ if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)");
+ return;
+ }
+ buffer = ctx->Color.DrawBuffer[2];""", "ARB_draw_buffers" ),
+ ( "GL_DRAW_BUFFER3_ARB", GLenum,
+ ["buffer"],
+ """GLenum buffer;
+ if (pname - GL_DRAW_BUFFER0_ARB >= ctx->Const.MaxDrawBuffers) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGet(GL_DRAW_BUFFERx_ARB)");
+ return;
+ }
+ buffer = ctx->Color.DrawBuffer[3];""", "ARB_draw_buffers" ),
+ # XXX Add more GL_DRAW_BUFFERn_ARB entries as needed in the future
+
+ # GL_OES_read_format
+ ( "GL_IMPLEMENTATION_COLOR_READ_TYPE_OES", GLint,
+ ["ctx->Const.ColorReadType"], "", "OES_read_format" ),
+ ( "GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES", GLint,
+ ["ctx->Const.ColorReadFormat"], "", "OES_read_format" ),
+
+ # GL_ATI_fragment_shader
+ ( "GL_NUM_FRAGMENT_REGISTERS_ATI", GLint, ["6"], "", "ATI_fragment_shader" ),
+ ( "GL_NUM_FRAGMENT_CONSTANTS_ATI", GLint, ["8"], "", "ATI_fragment_shader" ),
+ ( "GL_NUM_PASSES_ATI", GLint, ["2"], "", "ATI_fragment_shader" ),
+ ( "GL_NUM_INSTRUCTIONS_PER_PASS_ATI", GLint, ["8"], "", "ATI_fragment_shader" ),
+ ( "GL_NUM_INSTRUCTIONS_TOTAL_ATI", GLint, ["16"], "", "ATI_fragment_shader" ),
+ ( "GL_COLOR_ALPHA_PAIRING_ATI", GLboolean, ["GL_TRUE"], "", "ATI_fragment_shader" ),
+ ( "GL_NUM_LOOPBACK_COMPONENTS_ATI", GLint, ["3"], "", "ATI_fragment_shader" ),
+ ( "GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI", GLint, ["3"], "", "ATI_fragment_shader" ),
+
+ # OpenGL 2.0
+ ( "GL_STENCIL_BACK_FUNC", GLenum, ["ctx->Stencil.Function[1]"], "", None ),
+ ( "GL_STENCIL_BACK_VALUE_MASK", GLint, ["ctx->Stencil.ValueMask[1]"], "", None ),
+ ( "GL_STENCIL_BACK_REF", GLint, ["ctx->Stencil.Ref[1]"], "", None ),
+ ( "GL_STENCIL_BACK_FAIL", GLenum, ["ctx->Stencil.FailFunc[1]"], "", None ),
+ ( "GL_STENCIL_BACK_PASS_DEPTH_FAIL", GLenum, ["ctx->Stencil.ZFailFunc[1]"], "", None ),
+ ( "GL_STENCIL_BACK_PASS_DEPTH_PASS", GLenum, ["ctx->Stencil.ZPassFunc[1]"], "", None ),
+
+ # GL_EXT_framebuffer_object
+ ( "GL_FRAMEBUFFER_BINDING_EXT", GLint, ["ctx->DrawBuffer->Name"], "",
+ "EXT_framebuffer_object" ),
+ ( "GL_RENDERBUFFER_BINDING_EXT", GLint,
+ ["ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0"], "",
+ "EXT_framebuffer_object" ),
+ ( "GL_MAX_COLOR_ATTACHMENTS_EXT", GLint,
+ ["ctx->Const.MaxColorAttachments"], "",
+ "EXT_framebuffer_object" ),
+ ( "GL_MAX_RENDERBUFFER_SIZE_EXT", GLint,
+ ["ctx->Const.MaxRenderbufferSize"], "",
+ "EXT_framebuffer_object" ),
+
+ # GL_ARB_fragment_shader
+ ( "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB", GLint, ["MAX_FRAGMENT_UNIFORM_COMPONENTS"], "",
+ "ARB_fragment_shader" ),
+ ( "GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB", GLenum, ["ctx->Hint.FragmentShaderDerivative"], "",
+ "ARB_fragment_shader" ),
+
+ # GL_ARB_vertex_shader
+ ( "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB", GLint, ["MAX_VERTEX_UNIFORM_COMPONENTS"], "",
+ "ARB_vertex_shader" ),
+ ( "GL_MAX_VARYING_FLOATS_ARB", GLint, ["MAX_VARYING_FLOATS"], "", "ARB_vertex_shader" ),
+ ( "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB", GLint, ["MAX_VERTEX_TEXTURE_IMAGE_UNITS"], "",
+ "ARB_vertex_shader" ),
+ ( "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB", GLint, ["MAX_COMBINED_TEXTURE_IMAGE_UNITS"], "",
+ "ARB_vertex_shader" )
+]
+
+
+def ConversionFunc(fromType, toType):
+ """Return the name of the macro to convert between two data types."""
+ if fromType == toType:
+ return ""
+ elif fromType == GLfloat and toType == GLint:
+ return "IROUND"
+ elif fromType == GLfloatN and toType == GLfloat:
+ return ""
+ elif fromType == GLint and toType == GLfloat: # but not GLfloatN!
+ return "(GLfloat)"
+ else:
+ if fromType == GLfloatN:
+ fromType = GLfloat
+ fromStr = TypeStrings[fromType]
+ fromStr = string.upper(fromStr[2:])
+ toStr = TypeStrings[toType]
+ toStr = string.upper(toStr[2:])
+ return fromStr + "_TO_" + toStr
+
+
+def EmitGetFunction(stateVars, returnType):
+ """Emit the code to implement glGetBooleanv, glGetIntegerv or glGetFloatv."""
+ assert (returnType == GLboolean or
+ returnType == GLint or
+ returnType == GLfloat)
+
+ strType = TypeStrings[returnType]
+ # Capitalize first letter of return type
+ if returnType == GLint:
+ function = "GetIntegerv"
+ else:
+ function = "Get" + string.upper(strType[2]) + strType[3:] + "v"
+
+ print "void GLAPIENTRY"
+ print "_mesa_%s( GLenum pname, %s *params )" % (function, TypeStrings[returnType])
+ print "{"
+ print " GET_CURRENT_CONTEXT(ctx);"
+ print " ASSERT_OUTSIDE_BEGIN_END(ctx);"
+ print ""
+ print " if (!params)"
+ print " return;"
+ print ""
+ print " if (ctx->NewState)"
+ print " _mesa_update_state(ctx);"
+ print ""
+ print " if (ctx->Driver.%s &&" % function
+ print " ctx->Driver.%s(ctx, pname, params))" % function
+ print " return;"
+ print ""
+ print " switch (pname) {"
+
+ extCheck = "CHECK_EXTENSION_%s" % string.upper(TypeStrings[returnType][2])
+
+ for (name, varType, state, optionalCode, extension) in stateVars:
+ print " case " + name + ":"
+ if extension:
+ print " %s(%s, pname);" % (extCheck, extension)
+ if optionalCode:
+ print " {"
+ print " " + optionalCode
+ conversion = ConversionFunc(varType, returnType)
+ n = len(state)
+ for i in range(n):
+ if conversion:
+ print " params[%d] = %s(%s);" % (i, conversion, state[i])
+ else:
+ print " params[%d] = %s;" % (i, state[i])
+ if optionalCode:
+ print " }"
+ print " break;"
+
+ print " default:"
+ print ' _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(pname=0x%%x)", pname);' % function
+ print " }"
+ print "}"
+ print ""
+ return
+
+
+
+def EmitHeader():
+ """Print the get.c file header."""
+ print """
+/***
+ *** NOTE!!! DO NOT EDIT THIS FILE!!! IT IS GENERATED BY get_gen.py
+ ***/
+
+#include "glheader.h"
+#include "context.h"
+#include "enable.h"
+#include "extensions.h"
+#include "fbobject.h"
+#include "get.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "state.h"
+#include "texcompress.h"
+
+
+#define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE )
+
+#define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
+
+#define ENUM_TO_BOOLEAN(E) ( (E) ? GL_TRUE : GL_FALSE )
+#define ENUM_TO_INT(E) ( (GLint) (E) )
+#define ENUM_TO_FLOAT(E) ( (GLfloat) (E) )
+
+#define BOOLEAN_TO_INT(B) ( (GLint) (B) )
+#define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F )
+
+
+/* Check if named extension is enabled, if not generate error and return */
+
+#define CHECK1(E1, str, PNAME) \\
+ if (!ctx->Extensions.E1) { \\
+ _mesa_error(ctx, GL_INVALID_VALUE, \\
+ "glGet" str "v(0x%x)", (int) PNAME); \\
+ return; \\
+ }
+
+#define CHECK2(E1, E2, str, PNAME) \\
+ if (!ctx->Extensions.E1 && !ctx->Extensions.E2) { \\
+ _mesa_error(ctx, GL_INVALID_VALUE, \\
+ "glGet" str "v(0x%x)", (int) PNAME); \\
+ return; \\
+ }
+
+#define CHECK_EXTENSION_B(EXTNAME, PNAME) \\
+ CHECK1(EXTNAME, "Boolean", PNAME )
+
+#define CHECK_EXTENSION_I(EXTNAME, PNAME) \\
+ CHECK1(EXTNAME, "Integer", PNAME )
+
+#define CHECK_EXTENSION_F(EXTNAME, PNAME) \\
+ CHECK1(EXTNAME, "Float", PNAME )
+
+
+/**
+ * Helper routine.
+ */
+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;
+ }
+ }
+}
+"""
+ return
+
+
+
+def EmitGetDoublev():
+ print """
+void GLAPIENTRY
+_mesa_GetDoublev( GLenum pname, GLdouble *params )
+{
+ const GLfloat magic = -1234.5F;
+ GLfloat values[16];
+ GLuint i;
+
+ if (!params)
+ return;
+
+ /* Init temp array to magic numbers so we can figure out how many values
+ * are returned by the GetFloatv() call.
+ */
+ for (i = 0; i < 16; i++)
+ values[i] = magic;
+
+ _mesa_GetFloatv(pname, values);
+
+ for (i = 0; i < 16 && values[i] != magic; i++)
+ params[i] = (GLdouble) values[i];
+}
+"""
+
+
+
+
+EmitHeader()
+# XXX Maybe sort the StateVars list
+EmitGetFunction(StateVars, GLboolean)
+EmitGetFunction(StateVars, GLfloat)
+EmitGetFunction(StateVars, GLint)
+EmitGetDoublev()
+
diff --git a/nx-X11/extras/Mesa/src/mesa/main/getstring.c b/nx-X11/extras/Mesa/src/mesa/main/getstring.c
new file mode 100644
index 000000000..5188a79c9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/getstring.c
@@ -0,0 +1,261 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "get.h"
+#include "version.h"
+#include "enums.h"
+#include "extensions.h"
+
+
+/**
+ * Query string-valued state. The return value should _not_ be freed by
+ * the caller.
+ *
+ * \param name the state variable to query.
+ *
+ * \sa glGetString().
+ *
+ * Tries to get the string from dd_function_table::GetString, otherwise returns
+ * the hardcoded strings.
+ */
+const GLubyte * GLAPIENTRY
+_mesa_GetString( GLenum name )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ static const char *vendor = "Brian Paul";
+ static const char *renderer = "Mesa";
+ static const char *version_1_2 = "1.2 Mesa " MESA_VERSION_STRING;
+ static const char *version_1_3 = "1.3 Mesa " MESA_VERSION_STRING;
+ static const char *version_1_4 = "1.4 Mesa " MESA_VERSION_STRING;
+ static const char *version_1_5 = "1.5 Mesa " MESA_VERSION_STRING;
+ static const char *version_2_0 = "1.5 Mesa " MESA_VERSION_STRING;/*XXX FIX*/
+
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, NULL);
+
+ /* this is a required driver function */
+ assert(ctx->Driver.GetString);
+ {
+ /* Give the driver the chance to handle this query */
+ const GLubyte *str = (*ctx->Driver.GetString)(ctx, name);
+ if (str)
+ return str;
+ }
+
+ switch (name) {
+ case GL_VENDOR:
+ return (const GLubyte *) vendor;
+ case GL_RENDERER:
+ return (const GLubyte *) renderer;
+ case GL_VERSION:
+ if (ctx->Extensions.ARB_multisample &&
+ ctx->Extensions.ARB_multitexture &&
+ ctx->Extensions.ARB_texture_border_clamp &&
+ ctx->Extensions.ARB_texture_compression &&
+ ctx->Extensions.ARB_texture_cube_map &&
+ ctx->Extensions.EXT_texture_env_add &&
+ ctx->Extensions.ARB_texture_env_combine &&
+ ctx->Extensions.ARB_texture_env_dot3) {
+ if (ctx->Extensions.ARB_depth_texture &&
+ ctx->Extensions.ARB_shadow &&
+ ctx->Extensions.ARB_texture_env_crossbar &&
+ ctx->Extensions.ARB_texture_mirrored_repeat &&
+ ctx->Extensions.ARB_window_pos &&
+ ctx->Extensions.EXT_blend_color &&
+ ctx->Extensions.EXT_blend_func_separate &&
+ ctx->Extensions.EXT_blend_logic_op &&
+ ctx->Extensions.EXT_blend_minmax &&
+ ctx->Extensions.EXT_blend_subtract &&
+ ctx->Extensions.EXT_fog_coord &&
+ ctx->Extensions.EXT_multi_draw_arrays &&
+ ctx->Extensions.EXT_point_parameters && /*aka ARB*/
+ ctx->Extensions.EXT_secondary_color &&
+ ctx->Extensions.EXT_stencil_wrap &&
+ ctx->Extensions.EXT_texture_lod_bias &&
+ ctx->Extensions.SGIS_generate_mipmap) {
+ if (ctx->Extensions.ARB_occlusion_query &&
+ ctx->Extensions.ARB_vertex_buffer_object &&
+ ctx->Extensions.EXT_shadow_funcs) {
+ if (ctx->Extensions.ARB_draw_buffers &&
+ ctx->Extensions.ARB_point_sprite &&
+ ctx->Extensions.ARB_texture_non_power_of_two &&
+ ctx->Extensions.EXT_stencil_two_side) {
+ return (const GLubyte *) version_2_0;
+ }
+ else {
+ return (const GLubyte *) version_1_5;
+ }
+ }
+ else {
+ return (const GLubyte *) version_1_4;
+ }
+ }
+ else {
+ return (const GLubyte *) version_1_3;
+ }
+ }
+ else {
+ return (const GLubyte *) version_1_2;
+ }
+ case GL_EXTENSIONS:
+ if (!ctx->Extensions.String)
+ ctx->Extensions.String = _mesa_make_extension_string(ctx);
+ return (const GLubyte *) ctx->Extensions.String;
+#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program || \
+ FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
+ case GL_PROGRAM_ERROR_STRING_NV:
+ if (ctx->Extensions.NV_fragment_program ||
+ ctx->Extensions.ARB_fragment_program ||
+ ctx->Extensions.NV_vertex_program ||
+ ctx->Extensions.ARB_vertex_program) {
+ return (const GLubyte *) ctx->Program.ErrorString;
+ }
+ /* FALL-THROUGH */
+#endif
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetString" );
+ return (const GLubyte *) 0;
+ }
+}
+
+
+/**
+ * Return pointer-valued state, such as a vertex array pointer.
+ *
+ * \param pname names state to be queried
+ * \param params returns the pointer value
+ *
+ * \sa glGetPointerv().
+ *
+ * Tries to get the specified pointer via dd_function_table::GetPointerv,
+ * otherwise gets the specified pointer from the current context.
+ */
+void GLAPIENTRY
+_mesa_GetPointerv( GLenum pname, GLvoid **params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ const GLuint clientUnit = ctx->Array.ActiveTexture;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!params)
+ return;
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glGetPointerv %s\n", _mesa_lookup_enum_by_nr(pname));
+
+ if (ctx->Driver.GetPointerv
+ && (*ctx->Driver.GetPointerv)(ctx, pname, params))
+ return;
+
+ switch (pname) {
+ case GL_VERTEX_ARRAY_POINTER:
+ *params = (GLvoid *) ctx->Array.Vertex.Ptr;
+ break;
+ case GL_NORMAL_ARRAY_POINTER:
+ *params = (GLvoid *) ctx->Array.Normal.Ptr;
+ break;
+ case GL_COLOR_ARRAY_POINTER:
+ *params = (GLvoid *) ctx->Array.Color.Ptr;
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_POINTER_EXT:
+ *params = (GLvoid *) ctx->Array.SecondaryColor.Ptr;
+ break;
+ case GL_FOG_COORDINATE_ARRAY_POINTER_EXT:
+ *params = (GLvoid *) ctx->Array.FogCoord.Ptr;
+ break;
+ case GL_INDEX_ARRAY_POINTER:
+ *params = (GLvoid *) ctx->Array.Index.Ptr;
+ break;
+ case GL_TEXTURE_COORD_ARRAY_POINTER:
+ *params = (GLvoid *) ctx->Array.TexCoord[clientUnit].Ptr;
+ break;
+ case GL_EDGE_FLAG_ARRAY_POINTER:
+ *params = (GLvoid *) ctx->Array.EdgeFlag.Ptr;
+ break;
+ case GL_FEEDBACK_BUFFER_POINTER:
+ *params = ctx->Feedback.Buffer;
+ break;
+ case GL_SELECTION_BUFFER_POINTER:
+ *params = ctx->Select.Buffer;
+ break;
+#if FEATURE_MESA_program_debug
+ case GL_FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA:
+ if (!ctx->Extensions.MESA_program_debug) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetPointerv");
+ return;
+ }
+ *params = *(GLvoid **) &ctx->FragmentProgram.Callback;
+ break;
+ case GL_FRAGMENT_PROGRAM_CALLBACK_DATA_MESA:
+ if (!ctx->Extensions.MESA_program_debug) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetPointerv");
+ return;
+ }
+ *params = ctx->FragmentProgram.CallbackData;
+ break;
+ case GL_VERTEX_PROGRAM_CALLBACK_FUNC_MESA:
+ if (!ctx->Extensions.MESA_program_debug) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetPointerv");
+ return;
+ }
+ *params = *(GLvoid **) &ctx->VertexProgram.Callback;
+ break;
+ case GL_VERTEX_PROGRAM_CALLBACK_DATA_MESA:
+ if (!ctx->Extensions.MESA_program_debug) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetPointerv");
+ return;
+ }
+ *params = ctx->VertexProgram.CallbackData;
+ break;
+#endif
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetPointerv" );
+ return;
+ }
+}
+
+
+/**
+ * Returns the current GL error code, or GL_NO_ERROR.
+ * \return current error code
+ *
+ * Returns __GLcontextRec::ErrorValue.
+ */
+GLenum GLAPIENTRY
+_mesa_GetError( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLenum e = ctx->ErrorValue;
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glGetError <-- %s\n", _mesa_lookup_enum_by_nr(e));
+
+ ctx->ErrorValue = (GLenum) GL_NO_ERROR;
+ return e;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/glheader.h b/nx-X11/extras/Mesa/src/mesa/main/glheader.h
new file mode 100644
index 000000000..90b3a81a4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/glheader.h
@@ -0,0 +1,315 @@
+/**
+ * \file glheader.h
+ * Top-most include file.
+ *
+ * This is the top-most include file of the Mesa sources.
+ * It includes gl.h and all system headers which are needed.
+ * Other Mesa source files should \e not directly include any system
+ * headers. This allows Mesa to be integrated into XFree86 and
+ * allows system-dependent hacks/workarounds to be collected in one place.
+ *
+ * \note Actually, a lot of system-dependent stuff is now in imports.[ch].
+ *
+ * If you touch this file, everything gets recompiled!
+ *
+ * This file should be included before any other header in the .c files.
+ *
+ * Put compiler/OS/assembly pragmas and macros here to avoid
+ * cluttering other source files.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4.1
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef GLHEADER_H
+#define GLHEADER_H
+
+
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+#include "xf86_ansic.h"
+#else
+#include <assert.h>
+#include <ctype.h>
+/* If we can use Compaq's Fast Math Library on Alpha */
+#if defined(__alpha__) && defined(CCPML)
+#include <cpml.h>
+#else
+#include <math.h>
+#endif
+#include <limits.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#if defined(__linux__) && defined(__i386__)
+#include <fpu_control.h>
+#endif
+#endif
+#include <float.h>
+#include <stdarg.h>
+
+/* Get typedefs for uintptr_t and friends */
+#if defined(__MINGW32__) || defined(__NetBSD__)
+# include <stdint.h>
+#elif defined(_WIN32)
+# include <BaseTsd.h>
+# if _MSC_VER == 1200
+ typedef UINT_PTR uintptr_t;
+# endif
+#else
+# include <inttypes.h>
+#endif
+
+#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__) && !defined(BUILD_FOR_SNAP)
+# define __WIN32__
+# define finite _finite
+#endif
+
+#if defined(__WATCOMC__)
+# define finite _finite
+# pragma disable_message(201) /* Disable unreachable code warnings */
+#endif
+
+
+#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__)) && !defined(BUILD_FOR_SNAP)
+# if !defined(__GNUC__) /* mingw environment */
+# 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
+# endif
+# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
+# define WGLAPI __declspec(dllexport)
+# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
+# define WGLAPI __declspec(dllimport)
+# else /* for use with static link lib build of Win32 edition only */
+# define WGLAPI __declspec(dllimport)
+# endif /* _STATIC_MESA support */
+#endif /* WIN32 / CYGWIN bracket */
+
+
+#ifndef __MINGW32__
+/* XXX why is this here?
+ * It should probaby be somewhere in src/mesa/drivers/windows/
+ */
+#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_WINGDI_H) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(BUILD_FOR_SNAP)
+# 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;
+#if !defined(GLX_USE_MESA)
+#include <GL/mesa_wgl.h>
+#endif
+#endif
+#endif /* !__MINGW32__ */
+
+
+/*
+ * Either define MESA_BIG_ENDIAN or MESA_LITTLE_ENDIAN.
+ * Do not use them unless absolutely necessary!
+ * Try to use a runtime test instead.
+ * For now, only used by some DRI hardware drivers for color/texel packing.
+ */
+#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
+#if defined(__linux__)
+#include <byteswap.h>
+#define CPU_TO_LE32( x ) bswap_32( x )
+#else /*__linux__*/
+#define CPU_TO_LE32( x ) ( x ) /* fix me for non-Linux big-endian! */
+#endif /*__linux__*/
+#define MESA_BIG_ENDIAN 1
+#else
+#define CPU_TO_LE32( x ) ( x )
+#define MESA_LITTLE_ENDIAN 1
+#endif
+#define LE32_TO_CPU( x ) CPU_TO_LE32( x )
+
+
+#define GL_GLEXT_PROTOTYPES
+#include "GL/gl.h"
+#include "GL/glext.h"
+
+
+#if !defined(CAPI) && defined(WIN32) && !defined(BUILD_FOR_SNAP)
+#define CAPI _cdecl
+#endif
+#include <GL/internal/glcore.h>
+
+
+/* This is a macro on IRIX */
+#ifdef _P
+#undef _P
+#endif
+
+
+/* Turn off macro checking systems used by other libraries */
+#ifdef CHECK
+#undef CHECK
+#endif
+
+
+/* Create a macro so that asm functions can be linked into compilers other
+ * than GNU C
+ */
+#ifndef _ASMAPI
+#if defined(WIN32) && !defined(BUILD_FOR_SNAP)/* was: !defined( __GNUC__ ) && !defined( VMS ) && !defined( __INTEL_COMPILER )*/
+#define _ASMAPI __cdecl
+#else
+#define _ASMAPI
+#endif
+#ifdef PTR_DECL_IN_FRONT
+#define _ASMAPIP * _ASMAPI
+#else
+#define _ASMAPIP _ASMAPI *
+#endif
+#endif
+
+#ifdef USE_X86_ASM
+#define _NORMAPI _ASMAPI
+#define _NORMAPIP _ASMAPIP
+#else
+#define _NORMAPI
+#define _NORMAPIP *
+#endif
+
+
+/* Function inlining */
+#if defined(__GNUC__)
+# define INLINE __inline__
+#elif defined(__MSC__)
+# define INLINE __inline
+#elif defined(_MSC_VER)
+# define INLINE __inline
+#elif defined(__ICL)
+# define INLINE __inline
+#elif defined(__INTEL_COMPILER)
+# define INLINE inline
+#elif defined(__WATCOMC__) && (__WATCOMC__ >= 1100)
+# define INLINE __inline
+#else
+# define INLINE
+#endif
+
+
+/* If we build the library with gcc's -fvisibility=hidden flag, we'll
+ * use the PUBLIC macro to mark functions that are to be exported.
+ *
+ * We also need to define a USED attribute, so the optimizer doesn't
+ * inline a static function that we later use in an alias. - ajax
+ */
+#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
+# define PUBLIC __attribute__((visibility("default")))
+# define USED __attribute__((used))
+#else
+# define PUBLIC
+# define USED
+#endif
+
+
+/* Some compilers don't like some of Mesa's const usage */
+#ifdef NO_CONST
+# define CONST
+#else
+# define CONST const
+#endif
+
+
+#if defined(BUILD_FOR_SNAP) && defined(CHECKED)
+# define ASSERT(X) _CHECK(X)
+#elif defined(DEBUG)
+# define ASSERT(X) assert(X)
+#else
+# define ASSERT(X)
+#endif
+
+
+#if !defined __GNUC__ || __GNUC__ < 3
+# define __builtin_expect(x, y) x
+#endif
+
+/* Windows does not have the ffs() function */
+#if defined(_WIN32)
+static int INLINE
+ffs(register int value)
+{
+ register int bit = 0;
+ if (value != 0)
+ {
+ if ((value & 0xffff) == 0)
+ {
+ bit += 16;
+ value >>= 16;
+ }
+ if ((value & 0xff) == 0)
+ {
+ bit += 8;
+ value >>= 8;
+ }
+ if ((value & 0xf) == 0)
+ {
+ bit += 4;
+ value >>= 4;
+ }
+ while ((value & 1) == 0)
+ {
+ bit++;
+ value >>= 1;
+ }
+ }
+ return bit;
+}
+#endif
+
+
+/* The __FUNCTION__ gcc variable is generally only used for debugging.
+ * If we're not using gcc, define __FUNCTION__ as a cpp symbol here.
+ * Don't define it if using a newer Windows compiler.
+ */
+#if defined(__VMS)
+#define __FUNCTION__ "VMS$NL:"
+#elif !(defined(__GNUC__) && __GNUC__ >= 2) && !(defined(_MSC_VER) && _MSC_VER >= 1300)
+#define __FUNCTION__ "unknown"
+#endif
+
+
+#include "config.h"
+
+#endif /* GLHEADER_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/main/hash.c b/nx-X11/extras/Mesa/src/mesa/main/hash.c
new file mode 100644
index 000000000..74ab57df0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/hash.c
@@ -0,0 +1,451 @@
+/**
+ * \file hash.c
+ * Generic hash table.
+ *
+ * Used for display lists, texture objects, vertex/fragment programs,
+ * buffer objects, etc. The hash functions are thread-safe.
+ *
+ * \note key=0 is illegal.
+ *
+ * \author Brian Paul
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "glthread.h"
+#include "hash.h"
+
+
+#define TABLE_SIZE 1023 /**< Size of lookup table/array */
+
+#define HASH_FUNC(K) ((K) % TABLE_SIZE)
+
+
+/**
+ * An entry in the hash table.
+ *
+ * This struct is private to this file.
+ */
+struct HashEntry {
+ GLuint Key; /**< the entry's key */
+ void *Data; /**< the entry's data */
+ struct HashEntry *Next; /**< pointer to next entry */
+};
+
+/**
+ * The hash table data structure.
+ *
+ * This is an opaque types (it's not defined in hash.h file).
+ */
+struct _mesa_HashTable {
+ struct HashEntry *Table[TABLE_SIZE]; /**< the lookup table */
+ GLuint MaxKey; /**< highest key inserted so far */
+ _glthread_Mutex Mutex; /**< mutual exclusion lock */
+};
+
+
+/**
+ * Create a new hash table.
+ *
+ * \return pointer to a new, empty hash table.
+ */
+struct _mesa_HashTable *
+_mesa_NewHashTable(void)
+{
+ struct _mesa_HashTable *table = CALLOC_STRUCT(_mesa_HashTable);
+ if (table) {
+ _glthread_INIT_MUTEX(table->Mutex);
+ }
+ return table;
+}
+
+
+
+/**
+ * Delete a hash table.
+ * Frees each entry on the hash table and then the hash table structure itself.
+ * Note that the caller should have already traversed the table and deleted
+ * the objects in the table (i.e. We don't free the entries' data pointer).
+ *
+ * \param table the hash table to delete.
+ */
+void
+_mesa_DeleteHashTable(struct _mesa_HashTable *table)
+{
+ GLuint i;
+ assert(table);
+ for (i = 0; i < TABLE_SIZE; i++) {
+ struct HashEntry *entry = table->Table[i];
+ while (entry) {
+ struct HashEntry *next = entry->Next;
+ FREE(entry);
+ entry = next;
+ }
+ }
+ _glthread_DESTROY_MUTEX(table->Mutex);
+ FREE(table);
+}
+
+
+
+/**
+ * Lookup an entry in the hash table.
+ *
+ * \param table the hash table.
+ * \param key the key.
+ *
+ * \return pointer to user's data or NULL if key not in table
+ */
+void *
+_mesa_HashLookup(const struct _mesa_HashTable *table, GLuint key)
+{
+ GLuint pos;
+ const struct HashEntry *entry;
+
+ assert(table);
+ assert(key);
+
+ pos = HASH_FUNC(key);
+ entry = table->Table[pos];
+ while (entry) {
+ if (entry->Key == key) {
+ return entry->Data;
+ }
+ entry = entry->Next;
+ }
+ return NULL;
+}
+
+
+
+/**
+ * Insert a key/pointer pair into the hash table.
+ * If an entry with this key already exists we'll replace the existing entry.
+ *
+ * \param table the hash table.
+ * \param key the key (not zero).
+ * \param data pointer to user data.
+ */
+void
+_mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data)
+{
+ /* search for existing entry with this key */
+ GLuint pos;
+ struct HashEntry *entry;
+
+ assert(table);
+ assert(key);
+
+ _glthread_LOCK_MUTEX(table->Mutex);
+
+ if (key > table->MaxKey)
+ table->MaxKey = key;
+
+ pos = HASH_FUNC(key);
+ entry = table->Table[pos];
+ while (entry) {
+ if (entry->Key == key) {
+ /* replace entry's data */
+ entry->Data = data;
+ _glthread_UNLOCK_MUTEX(table->Mutex);
+ return;
+ }
+ entry = entry->Next;
+ }
+
+ /* alloc and insert new table entry */
+ entry = MALLOC_STRUCT(HashEntry);
+ entry->Key = key;
+ entry->Data = data;
+ entry->Next = table->Table[pos];
+ table->Table[pos] = entry;
+
+ _glthread_UNLOCK_MUTEX(table->Mutex);
+}
+
+
+
+/**
+ * Remove an entry from the hash table.
+ *
+ * \param table the hash table.
+ * \param key key of entry to remove.
+ *
+ * While holding the hash table's lock, searches the entry with the matching
+ * key and unlinks it.
+ */
+void
+_mesa_HashRemove(struct _mesa_HashTable *table, GLuint key)
+{
+ GLuint pos;
+ struct HashEntry *entry, *prev;
+
+ assert(table);
+ assert(key);
+
+ _glthread_LOCK_MUTEX(table->Mutex);
+
+ pos = HASH_FUNC(key);
+ prev = NULL;
+ entry = table->Table[pos];
+ while (entry) {
+ if (entry->Key == key) {
+ /* found it! */
+ if (prev) {
+ prev->Next = entry->Next;
+ }
+ else {
+ table->Table[pos] = entry->Next;
+ }
+ FREE(entry);
+ _glthread_UNLOCK_MUTEX(table->Mutex);
+ return;
+ }
+ prev = entry;
+ entry = entry->Next;
+ }
+
+ _glthread_UNLOCK_MUTEX(table->Mutex);
+}
+
+
+
+/**
+ * Get the key of the "first" entry in the hash table.
+ *
+ * This is used in the course of deleting all display lists when
+ * a context is destroyed.
+ *
+ * \param table the hash table
+ *
+ * \return key for the "first" entry in the hash table.
+ *
+ * While holding the lock, walks through all table positions until finding
+ * the first entry of the first non-empty one.
+ */
+GLuint
+_mesa_HashFirstEntry(struct _mesa_HashTable *table)
+{
+ GLuint pos;
+ assert(table);
+ _glthread_LOCK_MUTEX(table->Mutex);
+ for (pos=0; pos < TABLE_SIZE; pos++) {
+ if (table->Table[pos]) {
+ _glthread_UNLOCK_MUTEX(table->Mutex);
+ return table->Table[pos]->Key;
+ }
+ }
+ _glthread_UNLOCK_MUTEX(table->Mutex);
+ return 0;
+}
+
+
+/**
+ * Given a hash table key, return the next key. This is used to walk
+ * over all entries in the table. Note that the keys returned during
+ * walking won't be in any particular order.
+ * \return next hash key or 0 if end of table.
+ */
+GLuint
+_mesa_HashNextEntry(const struct _mesa_HashTable *table, GLuint key)
+{
+ const struct HashEntry *entry;
+ GLuint pos;
+
+ assert(table);
+ assert(key);
+
+ /* Find the entry with given key */
+ pos = HASH_FUNC(key);
+ entry = table->Table[pos];
+ while (entry) {
+ if (entry->Key == key) {
+ break;
+ }
+ entry = entry->Next;
+ }
+
+ if (!entry) {
+ /* the key was not found, we can't find next entry */
+ return 0;
+ }
+
+ if (entry->Next) {
+ /* return next in linked list */
+ return entry->Next->Key;
+ }
+ else {
+ /* look for next non-empty table slot */
+ pos++;
+ while (pos < TABLE_SIZE) {
+ if (table->Table[pos]) {
+ return table->Table[pos]->Key;
+ }
+ pos++;
+ }
+ return 0;
+ }
+}
+
+
+/**
+ * Dump contents of hash table for debugging.
+ *
+ * \param table the hash table.
+ */
+void
+_mesa_HashPrint(const struct _mesa_HashTable *table)
+{
+ GLuint i;
+ assert(table);
+ for (i=0;i<TABLE_SIZE;i++) {
+ const struct HashEntry *entry = table->Table[i];
+ while (entry) {
+ _mesa_debug(NULL, "%u %p\n", entry->Key, entry->Data);
+ entry = entry->Next;
+ }
+ }
+}
+
+
+
+/**
+ * Find a block of adjacent unused hash keys.
+ *
+ * \param table the hash table.
+ * \param numKeys number of keys needed.
+ *
+ * \return Starting key of free block or 0 if failure.
+ *
+ * If there are enough free keys between the maximum key existing in the table
+ * (_mesa_HashTable::MaxKey) and the maximum key possible, then simply return
+ * the adjacent key. Otherwise do a full search for a free key block in the
+ * allowable key range.
+ */
+GLuint
+_mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys)
+{
+ GLuint maxKey = ~((GLuint) 0);
+ _glthread_LOCK_MUTEX(table->Mutex);
+ if (maxKey - numKeys > table->MaxKey) {
+ /* the quick solution */
+ _glthread_UNLOCK_MUTEX(table->Mutex);
+ return table->MaxKey + 1;
+ }
+ else {
+ /* the slow solution */
+ GLuint freeCount = 0;
+ GLuint freeStart = 1;
+ GLuint key;
+ for (key=1; key!=maxKey; key++) {
+ if (_mesa_HashLookup(table, key)) {
+ /* darn, this key is already in use */
+ freeCount = 0;
+ freeStart = key+1;
+ }
+ else {
+ /* this key not in use, check if we've found enough */
+ freeCount++;
+ if (freeCount == numKeys) {
+ _glthread_UNLOCK_MUTEX(table->Mutex);
+ return freeStart;
+ }
+ }
+ }
+ /* cannot allocate a block of numKeys consecutive keys */
+ _glthread_UNLOCK_MUTEX(table->Mutex);
+ return 0;
+ }
+}
+
+
+#if 0 /* debug only */
+
+/**
+ * Test walking over all the entries in a hash table.
+ */
+static void
+test_hash_walking(void)
+{
+ struct _mesa_HashTable *t = _mesa_NewHashTable();
+ const GLuint limit = 50000;
+ GLuint i;
+
+ /* create some entries */
+ for (i = 0; i < limit; i++) {
+ GLuint dummy;
+ GLuint k = (rand() % (limit * 10)) + 1;
+ while (_mesa_HashLookup(t, k)) {
+ /* id already in use, try another */
+ k = (rand() % (limit * 10)) + 1;
+ }
+ _mesa_HashInsert(t, k, &dummy);
+ }
+
+ /* walk over all entries */
+ {
+ GLuint k = _mesa_HashFirstEntry(t);
+ GLuint count = 0;
+ while (k) {
+ GLuint knext = _mesa_HashNextEntry(t, k);
+ assert(knext != k);
+ _mesa_HashRemove(t, k);
+ count++;
+ k = knext;
+ }
+ assert(count == limit);
+ k = _mesa_HashFirstEntry(t);
+ assert(k==0);
+ }
+
+ _mesa_DeleteHashTable(t);
+}
+
+
+void
+_mesa_test_hash_functions(void)
+{
+ int a, b, c;
+ struct _mesa_HashTable *t;
+
+ t = _mesa_NewHashTable();
+ _mesa_HashInsert(t, 501, &a);
+ _mesa_HashInsert(t, 10, &c);
+ _mesa_HashInsert(t, 0xfffffff8, &b);
+ /*_mesa_HashPrint(t);*/
+
+ assert(_mesa_HashLookup(t,501));
+ assert(!_mesa_HashLookup(t,1313));
+ assert(_mesa_HashFindFreeKeyBlock(t, 100));
+
+ _mesa_DeleteHashTable(t);
+
+ test_hash_walking();
+}
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/hash.h b/nx-X11/extras/Mesa/src/mesa/main/hash.h
new file mode 100644
index 000000000..3cbe668e9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/hash.h
@@ -0,0 +1,59 @@
+/**
+ * \file hash.h
+ * Generic hash table.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef HASH_H
+#define HASH_H
+
+
+#include "glheader.h"
+
+
+extern struct _mesa_HashTable *_mesa_NewHashTable(void);
+
+extern void _mesa_DeleteHashTable(struct _mesa_HashTable *table);
+
+extern void *_mesa_HashLookup(const struct _mesa_HashTable *table, GLuint key);
+
+extern void _mesa_HashInsert(struct _mesa_HashTable *table, GLuint key, void *data);
+
+extern void _mesa_HashRemove(struct _mesa_HashTable *table, GLuint key);
+
+extern GLuint _mesa_HashFirstEntry(struct _mesa_HashTable *table);
+
+extern GLuint _mesa_HashNextEntry(const struct _mesa_HashTable *table, GLuint key);
+
+extern void _mesa_HashPrint(const struct _mesa_HashTable *table);
+
+extern GLuint _mesa_HashFindFreeKeyBlock(struct _mesa_HashTable *table, GLuint numKeys);
+
+extern void _mesa_test_hash_functions(void);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/hint.c b/nx-X11/extras/Mesa/src/mesa/main/hint.c
new file mode 100644
index 000000000..6680edd16
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/hint.c
@@ -0,0 +1,153 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 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.
+ */
+
+
+#include "glheader.h"
+#include "enums.h"
+#include "context.h"
+#include "hint.h"
+#include "imports.h"
+
+
+
+void GLAPIENTRY
+_mesa_Hint( GLenum target, GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glHint %s %d\n",
+ _mesa_lookup_enum_by_nr(target), mode);
+
+ if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glHint(mode)");
+ return;
+ }
+
+ switch (target) {
+ case GL_FOG_HINT:
+ if (ctx->Hint.Fog == mode)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_HINT);
+ ctx->Hint.Fog = mode;
+ break;
+ case GL_LINE_SMOOTH_HINT:
+ if (ctx->Hint.LineSmooth == mode)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_HINT);
+ ctx->Hint.LineSmooth = mode;
+ break;
+ case GL_PERSPECTIVE_CORRECTION_HINT:
+ if (ctx->Hint.PerspectiveCorrection == mode)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_HINT);
+ ctx->Hint.PerspectiveCorrection = mode;
+ break;
+ case GL_POINT_SMOOTH_HINT:
+ if (ctx->Hint.PointSmooth == mode)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_HINT);
+ ctx->Hint.PointSmooth = mode;
+ break;
+ case GL_POLYGON_SMOOTH_HINT:
+ if (ctx->Hint.PolygonSmooth == mode)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_HINT);
+ ctx->Hint.PolygonSmooth = mode;
+ break;
+
+ /* GL_EXT_clip_volume_hint */
+ case GL_CLIP_VOLUME_CLIPPING_HINT_EXT:
+ if (ctx->Hint.ClipVolumeClipping == mode)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_HINT);
+ ctx->Hint.ClipVolumeClipping = mode;
+ break;
+
+ /* GL_ARB_texture_compression */
+ case GL_TEXTURE_COMPRESSION_HINT_ARB:
+ if (!ctx->Extensions.ARB_texture_compression) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)");
+ return;
+ }
+ if (ctx->Hint.TextureCompression == mode)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_HINT);
+ ctx->Hint.TextureCompression = mode;
+ break;
+
+ /* GL_SGIS_generate_mipmap */
+ case GL_GENERATE_MIPMAP_HINT_SGIS:
+ if (!ctx->Extensions.SGIS_generate_mipmap) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)");
+ return;
+ }
+ if (ctx->Hint.GenerateMipmap == mode)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_HINT);
+ ctx->Hint.GenerateMipmap = mode;
+ break;
+
+ /* GL_ARB_fragment_shader */
+ case GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB:
+ if (!ctx->Extensions.ARB_fragment_shader) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)");
+ return;
+ }
+ if (ctx->Hint.FragmentShaderDerivative == mode)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_HINT);
+ ctx->Hint.FragmentShaderDerivative = mode;
+ break;
+
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glHint(target)");
+ return;
+ }
+
+ if (ctx->Driver.Hint) {
+ (*ctx->Driver.Hint)( ctx, target, mode );
+ }
+}
+
+
+/**********************************************************************/
+/***** Initialization *****/
+/**********************************************************************/
+
+void _mesa_init_hint( GLcontext * ctx )
+{
+ /* Hint group */
+ ctx->Hint.PerspectiveCorrection = GL_DONT_CARE;
+ ctx->Hint.PointSmooth = GL_DONT_CARE;
+ ctx->Hint.LineSmooth = GL_DONT_CARE;
+ ctx->Hint.PolygonSmooth = GL_DONT_CARE;
+ ctx->Hint.Fog = GL_DONT_CARE;
+ ctx->Hint.ClipVolumeClipping = GL_DONT_CARE;
+ ctx->Hint.TextureCompression = GL_DONT_CARE;
+ ctx->Hint.GenerateMipmap = GL_DONT_CARE;
+ ctx->Hint.FragmentShaderDerivative = GL_DONT_CARE;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/hint.h b/nx-X11/extras/Mesa/src/mesa/main/hint.h
new file mode 100644
index 000000000..bfc388710
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/hint.h
@@ -0,0 +1,57 @@
+/**
+ * \file hint.h
+ * Hints operations.
+ *
+ * \if subset
+ * (No-op)
+ *
+ * \endif
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef HINT_H
+#define HINT_H
+
+
+#include "mtypes.h"
+
+#if _HAVE_FULL_GL
+
+extern void GLAPIENTRY
+_mesa_Hint( GLenum target, GLenum mode );
+
+extern void
+_mesa_init_hint( GLcontext * ctx );
+
+#else
+
+/** No-op */
+#define _mesa_init_hint( c ) ((void) 0)
+
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/histogram.c b/nx-X11/extras/Mesa/src/mesa/main/histogram.c
new file mode 100644
index 000000000..29aced0c7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/histogram.c
@@ -0,0 +1,1187 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+#include "glheader.h"
+#include "bufferobj.h"
+#include "colormac.h"
+#include "context.h"
+#include "image.h"
+#include "histogram.h"
+
+
+/**********************************************************************
+ * Internal functions
+ */
+
+
+/*
+ * Update the min/max values from an array of fragment colors.
+ */
+void
+_mesa_update_minmax(GLcontext *ctx, GLuint n, const GLfloat rgba[][4])
+{
+ 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];
+ }
+}
+
+
+/*
+ * Update the histogram values from an array of fragment colors.
+ */
+void
+_mesa_update_histogram(GLcontext *ctx, GLuint n, const GLfloat rgba[][4])
+{
+ 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 = IROUND(rgba[i][RCOMP] * w);
+ GLint gi = IROUND(rgba[i][GCOMP] * w);
+ GLint bi = IROUND(rgba[i][BCOMP] * w);
+ GLint ai = IROUND(rgba[i][ACOMP] * w);
+ 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]++;
+ }
+}
+
+
+/*
+ * XXX the packed pixel formats haven't been tested.
+ */
+static void
+pack_histogram( GLcontext *ctx,
+ GLuint n, CONST GLuint rgba[][4],
+ GLenum format, GLenum type, GLvoid *destination,
+ const struct gl_pixelstore_attrib *packing )
+{
+ const GLint comps = _mesa_components_in_format(format);
+ GLuint luminance[MAX_WIDTH];
+
+ 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: \
+ _mesa_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;
+ case GL_HALF_FLOAT_ARB:
+ {
+ /* temporarily store as GLuints */
+ GLuint temp[4*HISTOGRAM_TABLE_SIZE];
+ GLhalfARB *dst = (GLhalfARB *) destination;
+ GLuint i;
+ /* get GLuint values */
+ PACK_MACRO(GLuint);
+ /* convert to GLhalf */
+ for (i = 0; i < n * comps; i++) {
+ dst[i] = _mesa_float_to_half((GLfloat) temp[i]);
+ }
+ if (packing->SwapBytes) {
+ _mesa_swap2((GLushort *) dst, n * comps);
+ }
+ }
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ if (format == GL_RGB) {
+ GLubyte *dst = (GLubyte *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][RCOMP] & 0x7) << 5)
+ | ((rgba[i][GCOMP] & 0x7) << 2)
+ | ((rgba[i][BCOMP] & 0x3) );
+ }
+ }
+ else {
+ GLubyte *dst = (GLubyte *) destination;
+ GLuint i;
+ ASSERT(format == GL_BGR);
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][BCOMP] & 0x7) << 5)
+ | ((rgba[i][GCOMP] & 0x7) << 2)
+ | ((rgba[i][RCOMP] & 0x3) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ if (format == GL_RGB) {
+ GLubyte *dst = (GLubyte *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][RCOMP] & 0x3) << 6)
+ | ((rgba[i][GCOMP] & 0x7) << 3)
+ | ((rgba[i][BCOMP] & 0x7) );
+ }
+ }
+ else {
+ GLubyte *dst = (GLubyte *) destination;
+ GLuint i;
+ ASSERT(format == GL_BGR);
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][BCOMP] & 0x3) << 6)
+ | ((rgba[i][GCOMP] & 0x7) << 3)
+ | ((rgba[i][RCOMP] & 0x7) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ if (format == GL_RGB) {
+ GLushort *dst = (GLushort *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][RCOMP] & 0x1f) << 11)
+ | ((rgba[i][GCOMP] & 0x3f) << 5)
+ | ((rgba[i][BCOMP] & 0x1f) );
+ }
+ }
+ else {
+ GLushort *dst = (GLushort *) destination;
+ GLuint i;
+ ASSERT(format == GL_BGR);
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][BCOMP] & 0x1f) << 11)
+ | ((rgba[i][GCOMP] & 0x3f) << 5)
+ | ((rgba[i][RCOMP] & 0x1f) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ if (format == GL_RGB) {
+ GLushort *dst = (GLushort *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][BCOMP] & 0x1f) << 11)
+ | ((rgba[i][GCOMP] & 0x3f) << 5)
+ | ((rgba[i][RCOMP] & 0x1f) );
+ }
+ }
+ else {
+ GLushort *dst = (GLushort *) destination;
+ GLuint i;
+ ASSERT(format == GL_BGR);
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][RCOMP] & 0x1f) << 11)
+ | ((rgba[i][GCOMP] & 0x3f) << 5)
+ | ((rgba[i][BCOMP] & 0x1f) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ if (format == GL_RGBA) {
+ GLushort *dst = (GLushort *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][RCOMP] & 0xf) << 12)
+ | ((rgba[i][GCOMP] & 0xf) << 8)
+ | ((rgba[i][BCOMP] & 0xf) << 4)
+ | ((rgba[i][ACOMP] & 0xf) );
+ }
+ }
+ else if (format == GL_BGRA) {
+ GLushort *dst = (GLushort *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][BCOMP] & 0xf) << 12)
+ | ((rgba[i][GCOMP] & 0xf) << 8)
+ | ((rgba[i][RCOMP] & 0xf) << 4)
+ | ((rgba[i][ACOMP] & 0xf) );
+ }
+ }
+ else {
+ GLushort *dst = (GLushort *) destination;
+ GLuint i;
+ ASSERT(format == GL_ABGR_EXT);
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][ACOMP] & 0xf) << 12)
+ | ((rgba[i][BCOMP] & 0xf) << 8)
+ | ((rgba[i][GCOMP] & 0xf) << 4)
+ | ((rgba[i][RCOMP] & 0xf) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ if (format == GL_RGBA) {
+ GLushort *dst = (GLushort *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][ACOMP] & 0xf) << 12)
+ | ((rgba[i][BCOMP] & 0xf) << 8)
+ | ((rgba[i][GCOMP] & 0xf) << 4)
+ | ((rgba[i][RCOMP] & 0xf) );
+ }
+ }
+ else if (format == GL_BGRA) {
+ GLushort *dst = (GLushort *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][ACOMP] & 0xf) << 12)
+ | ((rgba[i][RCOMP] & 0xf) << 8)
+ | ((rgba[i][GCOMP] & 0xf) << 4)
+ | ((rgba[i][BCOMP] & 0xf) );
+ }
+ }
+ else {
+ GLushort *dst = (GLushort *) destination;
+ GLuint i;
+ ASSERT(format == GL_ABGR_EXT);
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][RCOMP] & 0xf) << 12)
+ | ((rgba[i][GCOMP] & 0xf) << 8)
+ | ((rgba[i][BCOMP] & 0xf) << 4)
+ | ((rgba[i][ACOMP] & 0xf) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ if (format == GL_RGBA) {
+ GLushort *dst = (GLushort *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][RCOMP] & 0x1f) << 11)
+ | ((rgba[i][GCOMP] & 0x1f) << 6)
+ | ((rgba[i][BCOMP] & 0x1f) << 1)
+ | ((rgba[i][ACOMP] & 0x1) );
+ }
+ }
+ else if (format == GL_BGRA) {
+ GLushort *dst = (GLushort *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][BCOMP] & 0x1f) << 11)
+ | ((rgba[i][GCOMP] & 0x1f) << 6)
+ | ((rgba[i][RCOMP] & 0x1f) << 1)
+ | ((rgba[i][ACOMP] & 0x1) );
+ }
+ }
+ else {
+ GLushort *dst = (GLushort *) destination;
+ GLuint i;
+ ASSERT(format == GL_ABGR_EXT);
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][ACOMP] & 0x1f) << 11)
+ | ((rgba[i][BCOMP] & 0x1f) << 6)
+ | ((rgba[i][GCOMP] & 0x1f) << 1)
+ | ((rgba[i][RCOMP] & 0x1) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ if (format == GL_RGBA) {
+ GLushort *dst = (GLushort *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][ACOMP] & 0x1f) << 11)
+ | ((rgba[i][BCOMP] & 0x1f) << 6)
+ | ((rgba[i][GCOMP] & 0x1f) << 1)
+ | ((rgba[i][RCOMP] & 0x1) );
+ }
+ }
+ else if (format == GL_BGRA) {
+ GLushort *dst = (GLushort *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][ACOMP] & 0x1f) << 11)
+ | ((rgba[i][RCOMP] & 0x1f) << 6)
+ | ((rgba[i][GCOMP] & 0x1f) << 1)
+ | ((rgba[i][BCOMP] & 0x1) );
+ }
+ }
+ else {
+ GLushort *dst = (GLushort *) destination;
+ GLuint i;
+ ASSERT(format == GL_ABGR_EXT);
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][RCOMP] & 0x1f) << 11)
+ | ((rgba[i][GCOMP] & 0x1f) << 6)
+ | ((rgba[i][BCOMP] & 0x1f) << 1)
+ | ((rgba[i][ACOMP] & 0x1) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ if (format == GL_RGBA) {
+ GLuint *dst = (GLuint *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][RCOMP] & 0xff) << 24)
+ | ((rgba[i][GCOMP] & 0xff) << 16)
+ | ((rgba[i][BCOMP] & 0xff) << 8)
+ | ((rgba[i][ACOMP] & 0xff) );
+ }
+ }
+ else if (format == GL_BGRA) {
+ GLuint *dst = (GLuint *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][BCOMP] & 0xff) << 24)
+ | ((rgba[i][GCOMP] & 0xff) << 16)
+ | ((rgba[i][RCOMP] & 0xff) << 8)
+ | ((rgba[i][ACOMP] & 0xff) );
+ }
+ }
+ else {
+ GLuint *dst = (GLuint *) destination;
+ GLuint i;
+ ASSERT(format == GL_ABGR_EXT);
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][ACOMP] & 0xff) << 24)
+ | ((rgba[i][BCOMP] & 0xff) << 16)
+ | ((rgba[i][GCOMP] & 0xff) << 8)
+ | ((rgba[i][RCOMP] & 0xff) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ if (format == GL_RGBA) {
+ GLuint *dst = (GLuint *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][ACOMP] & 0xff) << 24)
+ | ((rgba[i][BCOMP] & 0xff) << 16)
+ | ((rgba[i][GCOMP] & 0xff) << 8)
+ | ((rgba[i][RCOMP] & 0xff) );
+ }
+ }
+ else if (format == GL_BGRA) {
+ GLuint *dst = (GLuint *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][ACOMP] & 0xff) << 24)
+ | ((rgba[i][RCOMP] & 0xff) << 16)
+ | ((rgba[i][GCOMP] & 0xff) << 8)
+ | ((rgba[i][BCOMP] & 0xff) );
+ }
+ }
+ else {
+ GLuint *dst = (GLuint *) destination;
+ GLuint i;
+ ASSERT(format == GL_ABGR_EXT);
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][RCOMP] & 0xff) << 24)
+ | ((rgba[i][GCOMP] & 0xff) << 16)
+ | ((rgba[i][BCOMP] & 0xff) << 8)
+ | ((rgba[i][ACOMP] & 0xff) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT_10_10_10_2:
+ if (format == GL_RGBA) {
+ GLuint *dst = (GLuint *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][RCOMP] & 0x3ff) << 22)
+ | ((rgba[i][GCOMP] & 0x3ff) << 12)
+ | ((rgba[i][BCOMP] & 0x3ff) << 2)
+ | ((rgba[i][ACOMP] & 0x3) );
+ }
+ }
+ else if (format == GL_BGRA) {
+ GLuint *dst = (GLuint *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][BCOMP] & 0x3ff) << 22)
+ | ((rgba[i][GCOMP] & 0x3ff) << 12)
+ | ((rgba[i][RCOMP] & 0x3ff) << 2)
+ | ((rgba[i][ACOMP] & 0x3) );
+ }
+ }
+ else {
+ GLuint *dst = (GLuint *) destination;
+ GLuint i;
+ ASSERT(format == GL_ABGR_EXT);
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][ACOMP] & 0x3ff) << 22)
+ | ((rgba[i][BCOMP] & 0x3ff) << 12)
+ | ((rgba[i][GCOMP] & 0x3ff) << 2)
+ | ((rgba[i][RCOMP] & 0x3) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ if (format == GL_RGBA) {
+ GLuint *dst = (GLuint *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][ACOMP] & 0x3ff) << 22)
+ | ((rgba[i][BCOMP] & 0x3ff) << 12)
+ | ((rgba[i][GCOMP] & 0x3ff) << 2)
+ | ((rgba[i][RCOMP] & 0x3) );
+ }
+ }
+ else if (format == GL_BGRA) {
+ GLuint *dst = (GLuint *) destination;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][ACOMP] & 0x3ff) << 22)
+ | ((rgba[i][RCOMP] & 0x3ff) << 12)
+ | ((rgba[i][GCOMP] & 0x3ff) << 2)
+ | ((rgba[i][BCOMP] & 0x3) );
+ }
+ }
+ else {
+ GLuint *dst = (GLuint *) destination;
+ GLuint i;
+ ASSERT(format == GL_ABGR_EXT);
+ for (i = 0; i < n; i++) {
+ dst[i] = ((rgba[i][RCOMP] & 0x3ff) << 22)
+ | ((rgba[i][GCOMP] & 0x3ff) << 12)
+ | ((rgba[i][BCOMP] & 0x3ff) << 2)
+ | ((rgba[i][ACOMP] & 0x3) );
+ }
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad type in pack_histogram");
+ }
+
+#undef PACK_MACRO
+}
+
+
+/*
+ * 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 )
+{
+ 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 */
+ }
+}
+
+
+
+/**********************************************************************
+ * API functions
+ */
+
+
+void GLAPIENTRY
+_mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmax");
+ return;
+ }
+
+ if (target != GL_MINMAX) {
+ _mesa_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_BGR &&
+ format != GL_RGBA &&
+ format != GL_BGRA &&
+ format != GL_ABGR_EXT &&
+ format != GL_LUMINANCE &&
+ format != GL_LUMINANCE_ALPHA) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetMinMax(format)");
+ }
+
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmax(format or type)");
+ return;
+ }
+
+ if (ctx->Pack.BufferObj->Name) {
+ /* pack min/max values into a PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(1, &ctx->Pack, 2, 1, 1,
+ format, type, values)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetMinMax(invalid PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ GL_WRITE_ONLY_ARB,
+ ctx->Pack.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,"glGetMinMax(PBO is mapped)");
+ return;
+ }
+ values = ADD_POINTERS(buf, values);
+ }
+ else if (!values) {
+ /* not an error */
+ 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);
+ _mesa_pack_rgba_span_float(ctx, 2, (CONST GLfloat (*)[4]) minmax,
+ format, type, values, &ctx->Pack, 0);
+ }
+
+ if (ctx->Pack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ ctx->Pack.BufferObj);
+ }
+
+ if (reset) {
+ _mesa_ResetMinmax(GL_MINMAX);
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogram");
+ return;
+ }
+
+ if (target != GL_HISTOGRAM) {
+ _mesa_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_BGR &&
+ format != GL_RGBA &&
+ format != GL_BGRA &&
+ format != GL_ABGR_EXT &&
+ format != GL_LUMINANCE &&
+ format != GL_LUMINANCE_ALPHA) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogram(format)");
+ }
+
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogram(format or type)");
+ return;
+ }
+
+ if (ctx->Pack.BufferObj->Name) {
+ /* pack min/max values into a PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(1, &ctx->Pack, ctx->Histogram.Width, 1, 1,
+ format, type, values)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetHistogram(invalid PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ GL_WRITE_ONLY_ARB,
+ ctx->Pack.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx,GL_INVALID_OPERATION,"glGetHistogram(PBO is mapped)");
+ return;
+ }
+ values = ADD_POINTERS(buf, values);
+ }
+ else if (!values) {
+ /* not an error */
+ return;
+ }
+
+ pack_histogram(ctx, ctx->Histogram.Width,
+ (CONST GLuint (*)[4]) ctx->Histogram.Count,
+ format, type, values, &ctx->Pack);
+
+ if (ctx->Pack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ ctx->Pack.BufferObj);
+ }
+
+ 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 GLAPIENTRY
+_mesa_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogramParameterfv");
+ return;
+ }
+
+ if (target != GL_HISTOGRAM && target != GL_PROXY_HISTOGRAM) {
+ _mesa_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:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameterfv(pname)");
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetHistogramParameteriv");
+ return;
+ }
+
+ if (target != GL_HISTOGRAM && target != GL_PROXY_HISTOGRAM) {
+ _mesa_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:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameteriv(pname)");
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmaxParameterfv");
+ return;
+ }
+ if (target != GL_MINMAX) {
+ _mesa_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 {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetMinMaxParameterfv(pname)");
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetMinmaxParameteriv");
+ return;
+ }
+ if (target != GL_MINMAX) {
+ _mesa_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 {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetMinMaxParameteriv(pname)");
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink)
+{
+ GLuint i;
+ GLboolean error = GL_FALSE;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* sideeffects */
+
+ if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glHistogram");
+ return;
+ }
+
+ if (target != GL_HISTOGRAM && target != GL_PROXY_HISTOGRAM) {
+ _mesa_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)
+ _mesa_error(ctx, GL_INVALID_VALUE, "glHistogram(width)");
+ else
+ _mesa_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 {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glHistogram(width)");
+ return;
+ }
+ }
+
+ if (base_histogram_format(internalFormat) < 0) {
+ if (target == GL_PROXY_HISTOGRAM) {
+ error = GL_TRUE;
+ }
+ else {
+ _mesa_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 = 8 * sizeof(GLuint);
+ ctx->Histogram.GreenSize = 8 * sizeof(GLuint);
+ ctx->Histogram.BlueSize = 8 * sizeof(GLuint);
+ ctx->Histogram.AlphaSize = 8 * sizeof(GLuint);
+ ctx->Histogram.LuminanceSize = 8 * sizeof(GLuint);
+ }
+
+ ctx->NewState |= _NEW_PIXEL;
+}
+
+
+void GLAPIENTRY
+_mesa_Minmax(GLenum target, GLenum internalFormat, GLboolean sink)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glMinmax");
+ return;
+ }
+
+ if (target != GL_MINMAX) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glMinMax(target)");
+ return;
+ }
+
+ if (base_histogram_format(internalFormat) < 0) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glMinMax(internalFormat)");
+ return;
+ }
+
+ if (ctx->MinMax.Sink == sink)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->MinMax.Sink = sink;
+}
+
+
+void GLAPIENTRY
+_mesa_ResetHistogram(GLenum target)
+{
+ GLuint i;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* sideeffects */
+
+ if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glResetHistogram");
+ return;
+ }
+
+ if (target != GL_HISTOGRAM) {
+ _mesa_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;
+ }
+
+ ctx->NewState |= _NEW_PIXEL;
+}
+
+
+void GLAPIENTRY
+_mesa_ResetMinmax(GLenum target)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (!ctx->Extensions.EXT_histogram && !ctx->Extensions.ARB_imaging) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glResetMinmax");
+ return;
+ }
+
+ if (target != GL_MINMAX) {
+ _mesa_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;
+ ctx->NewState |= _NEW_PIXEL;
+}
+
+
+
+/**********************************************************************/
+/***** Initialization *****/
+/**********************************************************************/
+
+void _mesa_init_histogram( GLcontext * ctx )
+{
+ int i;
+
+ /* Histogram group */
+ ctx->Histogram.Width = 0;
+ ctx->Histogram.Format = GL_RGBA;
+ ctx->Histogram.Sink = GL_FALSE;
+ ctx->Histogram.RedSize = 0;
+ ctx->Histogram.GreenSize = 0;
+ ctx->Histogram.BlueSize = 0;
+ ctx->Histogram.AlphaSize = 0;
+ ctx->Histogram.LuminanceSize = 0;
+ 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;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/histogram.h b/nx-X11/extras/Mesa/src/mesa/main/histogram.h
new file mode 100644
index 000000000..974447231
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/histogram.h
@@ -0,0 +1,89 @@
+/**
+ * \file histogram.h
+ * Histogram.
+ *
+ * \if subset
+ * (No-op)
+ *
+ * \endif
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef HISTOGRAM_H
+#define HISTOGRAM_H
+
+#include "glheader.h"
+#include "mtypes.h"
+
+#if _HAVE_FULL_GL
+
+extern void GLAPIENTRY
+_mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum types, GLvoid *values);
+
+extern void GLAPIENTRY
+_mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+
+extern void GLAPIENTRY
+_mesa_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params);
+
+extern void GLAPIENTRY
+_mesa_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params);
+
+extern void GLAPIENTRY
+_mesa_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params);
+
+extern void GLAPIENTRY
+_mesa_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params);
+
+extern void GLAPIENTRY
+_mesa_Histogram(GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+
+extern void GLAPIENTRY
+_mesa_Minmax(GLenum target, GLenum internalformat, GLboolean sink);
+
+extern void GLAPIENTRY
+_mesa_ResetHistogram(GLenum target);
+
+extern void GLAPIENTRY
+_mesa_ResetMinmax(GLenum target);
+
+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]);
+
+extern void _mesa_init_histogram( GLcontext * ctx );
+
+#else
+
+/** No-op */
+#define _mesa_init_histogram( c ) ((void) 0)
+
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/image.c b/nx-X11/extras/Mesa/src/mesa/main/image.c
new file mode 100644
index 000000000..bd0c5ba1f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/image.c
@@ -0,0 +1,4202 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file image.c
+ * Image handling.
+ */
+
+
+#include "glheader.h"
+#include "bufferobj.h"
+#include "colormac.h"
+#include "context.h"
+#include "image.h"
+#include "imports.h"
+#include "histogram.h"
+#include "macros.h"
+#include "pixel.h"
+#include "mtypes.h"
+
+
+/** Compute ceiling of integer quotient of A divided by B. */
+#define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )
+
+
+/**
+ * Flip the 8 bits in each byte of the given array.
+ *
+ * \param p array.
+ * \param n number of bytes.
+ *
+ * \todo try this trick to flip bytes someday:
+ * \code
+ * v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555);
+ * v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333);
+ * v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f);
+ * \endcode
+ */
+static void
+flip_bytes( GLubyte *p, GLuint n )
+{
+ register GLuint i, a, b;
+
+ for (i=0;i<n;i++) {
+ b = (GLuint) p[i]; /* words are often faster than bytes */
+ a = ((b & 0x01) << 7) |
+ ((b & 0x02) << 5) |
+ ((b & 0x04) << 3) |
+ ((b & 0x08) << 1) |
+ ((b & 0x10) >> 1) |
+ ((b & 0x20) >> 3) |
+ ((b & 0x40) >> 5) |
+ ((b & 0x80) >> 7);
+ p[i] = (GLubyte) a;
+ }
+}
+
+
+/**
+ * Flip the order of the 2 bytes in each word in the given array.
+ *
+ * \param p array.
+ * \param n number of words.
+ */
+void
+_mesa_swap2( GLushort *p, GLuint n )
+{
+ register GLuint i;
+
+ for (i=0;i<n;i++) {
+ p[i] = (p[i] >> 8) | ((p[i] << 8) & 0xff00);
+ }
+}
+
+
+
+/*
+ * Flip the order of the 4 bytes in each word in the given array.
+ */
+void
+_mesa_swap4( GLuint *p, GLuint n )
+{
+ register GLuint i, a, b;
+
+ for (i=0;i<n;i++) {
+ b = p[i];
+ a = (b >> 24)
+ | ((b >> 8) & 0xff00)
+ | ((b << 8) & 0xff0000)
+ | ((b << 24) & 0xff000000);
+ p[i] = a;
+ }
+}
+
+
+/**
+ * Get the size of a GL data type.
+ *
+ * \param type GL data type.
+ *
+ * \return the size, in bytes, of the given data type, 0 if a GL_BITMAP, or -1
+ * if an invalid type enum.
+ */
+GLint _mesa_sizeof_type( GLenum type )
+{
+ switch (type) {
+ case GL_BITMAP:
+ return 0;
+ case GL_UNSIGNED_BYTE:
+ return sizeof(GLubyte);
+ case GL_BYTE:
+ return sizeof(GLbyte);
+ case GL_UNSIGNED_SHORT:
+ return sizeof(GLushort);
+ case GL_SHORT:
+ return sizeof(GLshort);
+ case GL_UNSIGNED_INT:
+ return sizeof(GLuint);
+ case GL_INT:
+ return sizeof(GLint);
+ case GL_FLOAT:
+ return sizeof(GLfloat);
+ case GL_HALF_FLOAT_ARB:
+ return sizeof(GLhalfARB);
+ default:
+ return -1;
+ }
+}
+
+
+/**
+ * Same as _mesa_sizeof_type() but also accepting the packed pixel
+ * format data types.
+ */
+GLint _mesa_sizeof_packed_type( GLenum type )
+{
+ switch (type) {
+ case GL_BITMAP:
+ return 0;
+ case GL_UNSIGNED_BYTE:
+ return sizeof(GLubyte);
+ case GL_BYTE:
+ return sizeof(GLbyte);
+ case GL_UNSIGNED_SHORT:
+ return sizeof(GLushort);
+ case GL_SHORT:
+ return sizeof(GLshort);
+ case GL_UNSIGNED_INT:
+ return sizeof(GLuint);
+ case GL_INT:
+ return sizeof(GLint);
+ case GL_HALF_FLOAT_ARB:
+ return sizeof(GLhalfARB);
+ case GL_FLOAT:
+ return sizeof(GLfloat);
+ case GL_UNSIGNED_BYTE_3_3_2:
+ return sizeof(GLubyte);
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ return sizeof(GLubyte);
+ case GL_UNSIGNED_SHORT_5_6_5:
+ return sizeof(GLushort);
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ return sizeof(GLushort);
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ return sizeof(GLushort);
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ return sizeof(GLushort);
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ return sizeof(GLushort);
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ return sizeof(GLushort);
+ case GL_UNSIGNED_INT_8_8_8_8:
+ return sizeof(GLuint);
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ return sizeof(GLuint);
+ case GL_UNSIGNED_INT_10_10_10_2:
+ return sizeof(GLuint);
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return sizeof(GLuint);
+ case GL_UNSIGNED_SHORT_8_8_MESA:
+ case GL_UNSIGNED_SHORT_8_8_REV_MESA:
+ return sizeof(GLushort);
+ default:
+ return -1;
+ }
+}
+
+
+/**
+ * Get the number of components in a pixel format.
+ *
+ * \param format pixel format.
+ *
+ * \return the number of components in the given format, or -1 if a bad format.
+ */
+GLint _mesa_components_in_format( GLenum format )
+{
+ switch (format) {
+ 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:
+ case GL_STENCIL_INDEX:
+ case GL_DEPTH_COMPONENT:
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_INTENSITY:
+ return 1;
+ case GL_LUMINANCE_ALPHA:
+ return 2;
+ case GL_RGB:
+ return 3;
+ case GL_RGBA:
+ return 4;
+ case GL_BGR:
+ return 3;
+ case GL_BGRA:
+ return 4;
+ case GL_ABGR_EXT:
+ return 4;
+ case GL_YCBCR_MESA:
+ return 2;
+ default:
+ return -1;
+ }
+}
+
+
+/**
+ * Get the bytes per pixel of pixel format type pair.
+ *
+ * \param format pixel format.
+ * \param type pixel type.
+ *
+ * \return bytes per pixel, or -1 if a bad format or type was given.
+ */
+GLint _mesa_bytes_per_pixel( GLenum format, GLenum type )
+{
+ GLint comps = _mesa_components_in_format( format );
+ if (comps < 0)
+ return -1;
+
+ switch (type) {
+ case GL_BITMAP:
+ return 0; /* special case */
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ return comps * sizeof(GLubyte);
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ return comps * sizeof(GLshort);
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ return comps * sizeof(GLint);
+ case GL_FLOAT:
+ return comps * sizeof(GLfloat);
+ case GL_HALF_FLOAT_ARB:
+ return comps * sizeof(GLhalfARB);
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ if (format == GL_RGB || format == GL_BGR)
+ return sizeof(GLubyte);
+ else
+ return -1; /* error */
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ if (format == GL_RGB || format == GL_BGR)
+ return sizeof(GLushort);
+ else
+ return -1; /* error */
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT)
+ return sizeof(GLushort);
+ else
+ return -1;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ if (format == GL_RGBA || format == GL_BGRA || format == GL_ABGR_EXT)
+ return sizeof(GLuint);
+ else
+ return -1;
+ case GL_UNSIGNED_SHORT_8_8_MESA:
+ case GL_UNSIGNED_SHORT_8_8_REV_MESA:
+ if (format == GL_YCBCR_MESA)
+ return sizeof(GLushort);
+ else
+ return -1;
+ default:
+ return -1;
+ }
+}
+
+
+/**
+ * Test for a legal pixel format and type.
+ *
+ * \param format pixel format.
+ * \param type pixel type.
+ *
+ * \return GL_TRUE if the given pixel format and type are legal, or GL_FALSE
+ * otherwise.
+ */
+GLboolean
+_mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type )
+{
+ switch (format) {
+ case GL_COLOR_INDEX:
+ case GL_STENCIL_INDEX:
+ switch (type) {
+ case GL_BITMAP:
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ return GL_TRUE;
+ case GL_HALF_FLOAT_ARB:
+ return ctx->Extensions.ARB_half_float_pixel;
+ default:
+ return GL_FALSE;
+ }
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+#if 0 /* not legal! see table 3.6 of the 1.5 spec */
+ case GL_INTENSITY:
+#endif
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_DEPTH_COMPONENT:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ return GL_TRUE;
+ case GL_HALF_FLOAT_ARB:
+ return ctx->Extensions.ARB_half_float_pixel;
+ default:
+ return GL_FALSE;
+ }
+ case GL_RGB:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ return GL_TRUE;
+ case GL_HALF_FLOAT_ARB:
+ return ctx->Extensions.ARB_half_float_pixel;
+ default:
+ return GL_FALSE;
+ }
+ case GL_BGR:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ return GL_TRUE;
+ case GL_HALF_FLOAT_ARB:
+ return ctx->Extensions.ARB_half_float_pixel;
+ default:
+ return GL_FALSE;
+ }
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_ABGR_EXT:
+ switch (type) {
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT:
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ return GL_TRUE;
+ case GL_HALF_FLOAT_ARB:
+ return ctx->Extensions.ARB_half_float_pixel;
+ default:
+ return GL_FALSE;
+ }
+ case GL_YCBCR_MESA:
+ if (type == GL_UNSIGNED_SHORT_8_8_MESA ||
+ type == GL_UNSIGNED_SHORT_8_8_REV_MESA)
+ return GL_TRUE;
+ else
+ return GL_FALSE;
+ default:
+ ; /* fall-through */
+ }
+ return GL_FALSE;
+}
+
+
+/**
+ * Return the address of a specific pixel in an image (1D, 2D or 3D).
+ *
+ * Pixel unpacking/packing parameters are observed according to \p packing.
+ *
+ * \param dimensions either 1, 2 or 3 to indicate dimensionality of image
+ * \param image starting address of image data
+ * \param width the image width
+ * \param height theimage height
+ * \param format the pixel format
+ * \param type the pixel data type
+ * \param packing the pixelstore attributes
+ * \param img which image in the volume (0 for 1D or 2D images)
+ * \param row row of pixel in the image (0 for 1D images)
+ * \param column column of pixel in the image
+ *
+ * \return address of pixel on success, or NULL on error.
+ *
+ * \sa gl_pixelstore_attrib.
+ */
+GLvoid *
+_mesa_image_address( GLuint dimensions,
+ 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;
+ GLint rows_per_image;
+ GLint skiprows;
+ GLint skippixels;
+ GLint skipimages; /* for 3-D volume images */
+ GLubyte *pixel_addr;
+
+ ASSERT(dimensions >= 1 && dimensions <= 3);
+
+ alignment = packing->Alignment;
+ if (packing->RowLength > 0) {
+ pixels_per_row = packing->RowLength;
+ }
+ else {
+ pixels_per_row = width;
+ }
+ if (packing->ImageHeight > 0) {
+ rows_per_image = packing->ImageHeight;
+ }
+ else {
+ rows_per_image = height;
+ }
+
+ skippixels = packing->SkipPixels;
+ /* Note: SKIP_ROWS _is_ used for 1D images */
+ skiprows = packing->SkipRows;
+ /* Note: SKIP_IMAGES is only used for 3D images */
+ skipimages = (dimensions == 3) ? packing->SkipImages : 0;
+
+ if (type == GL_BITMAP) {
+ /* BITMAP data */
+ GLint comp_per_pixel; /* components per pixel */
+ GLint bytes_per_comp; /* bytes per component */
+ GLint bytes_per_row;
+ GLint bytes_per_image;
+
+ /* Compute bytes per component */
+ bytes_per_comp = _mesa_sizeof_packed_type( type );
+ if (bytes_per_comp < 0) {
+ return NULL;
+ }
+
+ /* Compute number of components per pixel */
+ comp_per_pixel = _mesa_components_in_format( format );
+ if (comp_per_pixel < 0) {
+ return NULL;
+ }
+
+ bytes_per_row = alignment
+ * CEILING( comp_per_pixel*pixels_per_row, 8*alignment );
+
+ bytes_per_image = bytes_per_row * rows_per_image;
+
+ pixel_addr = (GLubyte *) image
+ + (skipimages + img) * bytes_per_image
+ + (skiprows + row) * bytes_per_row
+ + (skippixels + column) / 8;
+ }
+ else {
+ /* Non-BITMAP data */
+ GLint bytes_per_pixel, bytes_per_row, remainder, bytes_per_image;
+ GLint topOfImage;
+
+ 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);
+
+ bytes_per_row = pixels_per_row * bytes_per_pixel;
+ remainder = bytes_per_row % alignment;
+ if (remainder > 0)
+ bytes_per_row += (alignment - remainder);
+
+ ASSERT(bytes_per_row % alignment == 0);
+
+ bytes_per_image = bytes_per_row * rows_per_image;
+
+ if (packing->Invert) {
+ /* set pixel_addr to the last row */
+ topOfImage = bytes_per_row * (height - 1);
+ bytes_per_row = -bytes_per_row;
+ }
+ else {
+ topOfImage = 0;
+ }
+
+ /* compute final pixel address */
+ pixel_addr = (GLubyte *) image
+ + (skipimages + img) * bytes_per_image
+ + topOfImage
+ + (skiprows + row) * bytes_per_row
+ + (skippixels + column) * bytes_per_pixel;
+ }
+
+ return (GLvoid *) pixel_addr;
+}
+
+
+GLvoid *
+_mesa_image_address1d( const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width,
+ GLenum format, GLenum type,
+ GLint column )
+{
+ return _mesa_image_address(1, packing, image, width, 1,
+ format, type, 0, 0, column);
+}
+
+
+GLvoid *
+_mesa_image_address2d( const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLint row, GLint column )
+{
+ return _mesa_image_address(2, packing, image, width, height,
+ format, type, 0, row, column);
+}
+
+
+GLvoid *
+_mesa_image_address3d( const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLint img, GLint row, GLint column )
+{
+ return _mesa_image_address(3, packing, image, width, height,
+ format, type, img, row, column);
+}
+
+
+
+/**
+ * Compute the stride between image rows.
+ *
+ * \param packing the pixelstore attributes
+ * \param width image width.
+ * \param format pixel format.
+ * \param type pixel data type.
+ *
+ * \return the stride in bytes for the given parameters.
+ *
+ * Computes the number of bytes per pixel and row and compensates for alignment.
+ *
+ * \sa gl_pixelstore_attrib.
+ */
+GLint
+_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing,
+ GLint width, GLenum format, GLenum type )
+{
+ ASSERT(packing);
+ if (type == GL_BITMAP) {
+ /* BITMAP data */
+ GLint bytes;
+ if (packing->RowLength == 0) {
+ bytes = (width + 7) / 8;
+ }
+ else {
+ bytes = (packing->RowLength + 7) / 8;
+ }
+ if (packing->Invert) {
+ /* negate the bytes per row (negative row stride) */
+ bytes = -bytes;
+ }
+ 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);
+ if (packing->Invert)
+ bytesPerRow = -bytesPerRow;
+ return bytesPerRow;
+ }
+}
+
+
+#if _HAVE_FULL_GL
+
+/*
+ * Compute the stride between images in a 3D texture (in bytes) for the given
+ * pixel packing parameters and image width, format and type.
+ */
+GLint
+_mesa_image_image_stride( const struct gl_pixelstore_attrib *packing,
+ GLint width, GLint height,
+ GLenum format, GLenum type )
+{
+ ASSERT(packing);
+ ASSERT(type != GL_BITMAP);
+
+ {
+ const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type);
+ GLint bytesPerRow, bytesPerImage, 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);
+
+ if (packing->ImageHeight == 0)
+ bytesPerImage = bytesPerRow * height;
+ else
+ bytesPerImage = bytesPerRow * packing->ImageHeight;
+
+ return bytesPerImage;
+ }
+}
+
+
+/*
+ * 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);
+ }
+}
+
+
+/*
+ * Pack polygon stipple into user memory given current pixel packing
+ * settings.
+ */
+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++) {
+ 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);
+}
+
+
+/*
+ * Unpack bitmap data. Resulting data will be in most-significant-bit-first
+ * order with row alignment = 1 byte.
+ */
+GLvoid *
+_mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels,
+ const struct gl_pixelstore_attrib *packing )
+{
+ GLint bytes, row, width_in_bytes;
+ GLubyte *buffer, *dst;
+
+ if (!pixels)
+ return NULL;
+
+ /* Alloc dest storage */
+ bytes = ((width + 7) / 8 * height);
+ buffer = (GLubyte *) MALLOC( bytes );
+ if (!buffer)
+ return NULL;
+
+
+ width_in_bytes = CEILING( width, 8 );
+ dst = buffer;
+ for (row = 0; row < height; row++) {
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address2d(packing, pixels, width, height,
+ GL_COLOR_INDEX, GL_BITMAP, row, 0);
+ if (!src) {
+ FREE(buffer);
+ return NULL;
+ }
+
+ 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;
+ }
+ }
+ }
+ }
+ dst += width_in_bytes;
+ }
+
+ 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 = (GLubyte *) _mesa_image_address2d(packing, dest,
+ width, height, GL_COLOR_INDEX, GL_BITMAP, 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;
+ }
+}
+
+
+/**
+ * Apply various pixel transfer operations to an array of RGBA pixels
+ * as indicated by the transferOps bitmask
+ */
+void
+_mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLuint transferOps,
+ GLuint n, GLfloat rgba[][4])
+{
+ /* scale & bias */
+ if (transferOps & IMAGE_SCALE_BIAS_BIT) {
+ _mesa_scale_and_bias_rgba(n, rgba,
+ ctx->Pixel.RedScale, ctx->Pixel.GreenScale,
+ ctx->Pixel.BlueScale, ctx->Pixel.AlphaScale,
+ ctx->Pixel.RedBias, ctx->Pixel.GreenBias,
+ ctx->Pixel.BlueBias, ctx->Pixel.AlphaBias);
+ }
+ /* color map lookup */
+ if (transferOps & IMAGE_MAP_COLOR_BIT) {
+ _mesa_map_rgba( ctx, n, rgba );
+ }
+ /* GL_COLOR_TABLE lookup */
+ if (transferOps & IMAGE_COLOR_TABLE_BIT) {
+ _mesa_lookup_rgba_float(&ctx->ColorTable, n, rgba);
+ }
+ /* convolution */
+ if (transferOps & IMAGE_CONVOLUTION_BIT) {
+ /* this has to be done in the calling code */
+ _mesa_problem(ctx, "IMAGE_CONVOLUTION_BIT set in _mesa_apply_transfer_ops");
+ }
+ /* GL_POST_CONVOLUTION_RED/GREEN/BLUE/ALPHA_SCALE/BIAS */
+ if (transferOps & IMAGE_POST_CONVOLUTION_SCALE_BIAS) {
+ _mesa_scale_and_bias_rgba(n, rgba,
+ ctx->Pixel.PostConvolutionScale[RCOMP],
+ ctx->Pixel.PostConvolutionScale[GCOMP],
+ ctx->Pixel.PostConvolutionScale[BCOMP],
+ ctx->Pixel.PostConvolutionScale[ACOMP],
+ ctx->Pixel.PostConvolutionBias[RCOMP],
+ ctx->Pixel.PostConvolutionBias[GCOMP],
+ ctx->Pixel.PostConvolutionBias[BCOMP],
+ ctx->Pixel.PostConvolutionBias[ACOMP]);
+ }
+ /* GL_POST_CONVOLUTION_COLOR_TABLE lookup */
+ if (transferOps & IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT) {
+ _mesa_lookup_rgba_float(&ctx->PostConvolutionColorTable, n, rgba);
+ }
+ /* color matrix transform */
+ if (transferOps & IMAGE_COLOR_MATRIX_BIT) {
+ _mesa_transform_rgba(ctx, n, rgba);
+ }
+ /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */
+ if (transferOps & IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT) {
+ _mesa_lookup_rgba_float(&ctx->PostColorMatrixColorTable, n, rgba);
+ }
+ /* update histogram count */
+ if (transferOps & IMAGE_HISTOGRAM_BIT) {
+ _mesa_update_histogram(ctx, n, (CONST GLfloat (*)[4]) rgba);
+ }
+ /* update min/max values */
+ if (transferOps & IMAGE_MIN_MAX_BIT) {
+ _mesa_update_minmax(ctx, n, (CONST GLfloat (*)[4]) rgba);
+ }
+ /* clamping to [0,1] */
+ if (transferOps & IMAGE_CLAMP_BIT) {
+ 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);
+ }
+ }
+}
+
+
+
+/**
+ * Used to pack an array [][4] of RGBA float colors as specified
+ * by the dstFormat, dstType and dstPacking. Used by glReadPixels,
+ * glGetConvolutionFilter(), etc.
+ * NOTE: it's assumed the incoming float colors are all in [0,1].
+ */
+void
+_mesa_pack_rgba_span_float( GLcontext *ctx,
+ GLuint n, CONST GLfloat rgbaIn[][4],
+ GLenum dstFormat, GLenum dstType,
+ GLvoid *dstAddr,
+ const struct gl_pixelstore_attrib *dstPacking,
+ GLuint transferOps )
+{
+ const GLint comps = _mesa_components_in_format(dstFormat);
+ GLfloat luminance[MAX_WIDTH];
+ const GLfloat (*rgba)[4];
+ GLuint i;
+
+ if (transferOps) {
+ /* make copy of incoming data */
+ DEFMARRAY(GLfloat, rgbaCopy, MAX_WIDTH, 4); /* mac 32k limitation */
+ CHECKARRAY(rgbaCopy, return); /* mac 32k limitation */
+
+ _mesa_memcpy(rgbaCopy, rgbaIn, n * 4 * sizeof(GLfloat));
+ _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgbaCopy);
+ rgba = (const GLfloat (*)[4]) rgbaCopy;
+
+ if ((transferOps & IMAGE_MIN_MAX_BIT) && ctx->MinMax.Sink) {
+ UNDEFARRAY(rgbaCopy); /* mac 32k limitation */
+ return;
+ }
+ UNDEFARRAY(rgbaCopy); /* mac 32k limitation */
+ }
+ else {
+ /* use incoming data, not a copy */
+ rgba = (const GLfloat (*)[4]) rgbaIn;
+ }
+
+ if (dstFormat == GL_LUMINANCE || dstFormat == GL_LUMINANCE_ALPHA) {
+ /* compute luminance values */
+ if (ctx->ClampFragmentColors) {
+ for (i = 0; i < n; i++) {
+ GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
+ luminance[i] = CLAMP(sum, 0.0F, 1.0F);
+ }
+ }
+ else {
+ for (i = 0; i < n; i++) {
+ luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP];
+ }
+ }
+ }
+
+ /*
+ * Pack/store the pixels. Ugh! Lots of cases!!!
+ */
+ switch (dstType) {
+ case GL_UNSIGNED_BYTE:
+ {
+ GLubyte *dst = (GLubyte *) dstAddr;
+ switch (dstFormat) {
+ case GL_RED:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UBYTE(rgba[i][RCOMP]);
+ break;
+ case GL_GREEN:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UBYTE(rgba[i][GCOMP]);
+ break;
+ case GL_BLUE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UBYTE(rgba[i][BCOMP]);
+ break;
+ case GL_ALPHA:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UBYTE(rgba[i][ACOMP]);
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UBYTE(luminance[i]);
+ break;
+ 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(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;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(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(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(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(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:
+ _mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
+ }
+ }
+ break;
+ case GL_BYTE:
+ {
+ GLbyte *dst = (GLbyte *) dstAddr;
+ switch (dstFormat) {
+ case GL_RED:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_BYTE(rgba[i][RCOMP]);
+ break;
+ case GL_GREEN:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_BYTE(rgba[i][GCOMP]);
+ break;
+ case GL_BLUE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_BYTE(rgba[i][BCOMP]);
+ break;
+ case GL_ALPHA:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_BYTE(rgba[i][ACOMP]);
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_BYTE(luminance[i]);
+ break;
+ 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(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;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(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(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(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(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:
+ _mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ {
+ GLushort *dst = (GLushort *) dstAddr;
+ switch (dstFormat) {
+ case GL_RED:
+ for (i=0;i<n;i++)
+ CLAMPED_FLOAT_TO_USHORT(dst[i], rgba[i][RCOMP]);
+ break;
+ case GL_GREEN:
+ for (i=0;i<n;i++)
+ CLAMPED_FLOAT_TO_USHORT(dst[i], rgba[i][GCOMP]);
+ break;
+ case GL_BLUE:
+ for (i=0;i<n;i++)
+ CLAMPED_FLOAT_TO_USHORT(dst[i], rgba[i][BCOMP]);
+ break;
+ case GL_ALPHA:
+ for (i=0;i<n;i++)
+ CLAMPED_FLOAT_TO_USHORT(dst[i], rgba[i][ACOMP]);
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++)
+ UNCLAMPED_FLOAT_TO_USHORT(dst[i], luminance[i]);
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i=0;i<n;i++) {
+ UNCLAMPED_FLOAT_TO_USHORT(dst[i*2+0], luminance[i]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*2+1], rgba[i][ACOMP]);
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;i++) {
+ CLAMPED_FLOAT_TO_USHORT(dst[i*3+0], rgba[i][RCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*3+1], rgba[i][GCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*3+2], rgba[i][BCOMP]);
+ }
+ break;
+ case GL_RGBA:
+ for (i=0;i<n;i++) {
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+0], rgba[i][RCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+1], rgba[i][GCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+2], rgba[i][BCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+3], rgba[i][ACOMP]);
+ }
+ break;
+ case GL_BGR:
+ for (i=0;i<n;i++) {
+ CLAMPED_FLOAT_TO_USHORT(dst[i*3+0], rgba[i][BCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*3+1], rgba[i][GCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*3+2], rgba[i][RCOMP]);
+ }
+ break;
+ case GL_BGRA:
+ for (i=0;i<n;i++) {
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+0], rgba[i][BCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+1], rgba[i][GCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+2], rgba[i][RCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+3], rgba[i][ACOMP]);
+ }
+ break;
+ case GL_ABGR_EXT:
+ for (i=0;i<n;i++) {
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+0], rgba[i][ACOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+1], rgba[i][BCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+2], rgba[i][GCOMP]);
+ CLAMPED_FLOAT_TO_USHORT(dst[i*4+3], rgba[i][RCOMP]);
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap2( (GLushort *) dst, n * comps);
+ }
+ }
+ break;
+ case GL_SHORT:
+ {
+ GLshort *dst = (GLshort *) dstAddr;
+ switch (dstFormat) {
+ case GL_RED:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_SHORT(rgba[i][RCOMP]);
+ break;
+ case GL_GREEN:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_SHORT(rgba[i][GCOMP]);
+ break;
+ case GL_BLUE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_SHORT(rgba[i][BCOMP]);
+ break;
+ case GL_ALPHA:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_SHORT(rgba[i][ACOMP]);
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_SHORT(luminance[i]);
+ break;
+ 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(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;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(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(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(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(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:
+ _mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap2( (GLushort *) dst, n * comps );
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ {
+ GLuint *dst = (GLuint *) dstAddr;
+ switch (dstFormat) {
+ case GL_RED:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UINT(rgba[i][RCOMP]);
+ break;
+ case GL_GREEN:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UINT(rgba[i][GCOMP]);
+ break;
+ case GL_BLUE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UINT(rgba[i][BCOMP]);
+ break;
+ case GL_ALPHA:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UINT(rgba[i][ACOMP]);
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_UINT(luminance[i]);
+ break;
+ 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(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;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(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(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(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(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:
+ _mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n * comps );
+ }
+ }
+ break;
+ case GL_INT:
+ {
+ GLint *dst = (GLint *) dstAddr;
+ switch (dstFormat) {
+ case GL_RED:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_INT(rgba[i][RCOMP]);
+ break;
+ case GL_GREEN:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_INT(rgba[i][GCOMP]);
+ break;
+ case GL_BLUE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_INT(rgba[i][BCOMP]);
+ break;
+ case GL_ALPHA:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_INT(rgba[i][ACOMP]);
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++)
+ dst[i] = FLOAT_TO_INT(luminance[i]);
+ break;
+ 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(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;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(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(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(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(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:
+ _mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n * comps );
+ }
+ }
+ break;
+ case GL_FLOAT:
+ {
+ GLfloat *dst = (GLfloat *) dstAddr;
+ switch (dstFormat) {
+ case GL_RED:
+ for (i=0;i<n;i++)
+ dst[i] = rgba[i][RCOMP];
+ break;
+ case GL_GREEN:
+ for (i=0;i<n;i++)
+ dst[i] = rgba[i][GCOMP];
+ break;
+ case GL_BLUE:
+ for (i=0;i<n;i++)
+ dst[i] = rgba[i][BCOMP];
+ break;
+ case GL_ALPHA:
+ for (i=0;i<n;i++)
+ dst[i] = rgba[i][ACOMP];
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++)
+ dst[i] = luminance[i];
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = luminance[i];
+ dst[i*2+1] = rgba[i][ACOMP];
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;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] = 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] = 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] = 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] = 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:
+ _mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n * comps );
+ }
+ }
+ break;
+ case GL_HALF_FLOAT_ARB:
+ {
+ GLhalfARB *dst = (GLhalfARB *) dstAddr;
+ switch (dstFormat) {
+ case GL_RED:
+ for (i=0;i<n;i++)
+ dst[i] = _mesa_float_to_half(rgba[i][RCOMP]);
+ break;
+ case GL_GREEN:
+ for (i=0;i<n;i++)
+ dst[i] = _mesa_float_to_half(rgba[i][GCOMP]);
+ break;
+ case GL_BLUE:
+ for (i=0;i<n;i++)
+ dst[i] = _mesa_float_to_half(rgba[i][BCOMP]);
+ break;
+ case GL_ALPHA:
+ for (i=0;i<n;i++)
+ dst[i] = _mesa_float_to_half(rgba[i][ACOMP]);
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++)
+ dst[i] = _mesa_float_to_half(luminance[i]);
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i=0;i<n;i++) {
+ dst[i*2+0] = _mesa_float_to_half(luminance[i]);
+ dst[i*2+1] = _mesa_float_to_half(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;i++) {
+ dst[i*3+0] = _mesa_float_to_half(rgba[i][RCOMP]);
+ dst[i*3+1] = _mesa_float_to_half(rgba[i][GCOMP]);
+ dst[i*3+2] = _mesa_float_to_half(rgba[i][BCOMP]);
+ }
+ break;
+ case GL_RGBA:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = _mesa_float_to_half(rgba[i][RCOMP]);
+ dst[i*4+1] = _mesa_float_to_half(rgba[i][GCOMP]);
+ dst[i*4+2] = _mesa_float_to_half(rgba[i][BCOMP]);
+ dst[i*4+3] = _mesa_float_to_half(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_BGR:
+ for (i=0;i<n;i++) {
+ dst[i*3+0] = _mesa_float_to_half(rgba[i][BCOMP]);
+ dst[i*3+1] = _mesa_float_to_half(rgba[i][GCOMP]);
+ dst[i*3+2] = _mesa_float_to_half(rgba[i][RCOMP]);
+ }
+ break;
+ case GL_BGRA:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = _mesa_float_to_half(rgba[i][BCOMP]);
+ dst[i*4+1] = _mesa_float_to_half(rgba[i][GCOMP]);
+ dst[i*4+2] = _mesa_float_to_half(rgba[i][RCOMP]);
+ dst[i*4+3] = _mesa_float_to_half(rgba[i][ACOMP]);
+ }
+ break;
+ case GL_ABGR_EXT:
+ for (i=0;i<n;i++) {
+ dst[i*4+0] = _mesa_float_to_half(rgba[i][ACOMP]);
+ dst[i*4+1] = _mesa_float_to_half(rgba[i][BCOMP]);
+ dst[i*4+2] = _mesa_float_to_half(rgba[i][GCOMP]);
+ dst[i*4+3] = _mesa_float_to_half(rgba[i][RCOMP]);
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "bad format in _mesa_pack_rgba_span\n");
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap2( (GLushort *) dst, n * comps );
+ }
+ }
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ if (dstFormat == GL_RGB) {
+ GLubyte *dst = (GLubyte *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 7.0F)) << 5)
+ | (((GLint) (rgba[i][GCOMP] * 7.0F)) << 2)
+ | (((GLint) (rgba[i][BCOMP] * 3.0F)) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ if (dstFormat == GL_RGB) {
+ GLubyte *dst = (GLubyte *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 7.0F)) )
+ | (((GLint) (rgba[i][GCOMP] * 7.0F)) << 3)
+ | (((GLint) (rgba[i][BCOMP] * 3.0F)) << 5);
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ if (dstFormat == GL_RGB) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) << 11)
+ | (((GLint) (rgba[i][GCOMP] * 63.0F)) << 5)
+ | (((GLint) (rgba[i][BCOMP] * 31.0F)) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ if (dstFormat == GL_RGB) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) )
+ | (((GLint) (rgba[i][GCOMP] * 63.0F)) << 5)
+ | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 11);
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ if (dstFormat == GL_RGBA) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ 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)) );
+ }
+ }
+ else if (dstFormat == GL_BGRA) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][BCOMP] * 15.0F)) << 12)
+ | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 8)
+ | (((GLint) (rgba[i][RCOMP] * 15.0F)) << 4)
+ | (((GLint) (rgba[i][ACOMP] * 15.0F)) );
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][ACOMP] * 15.0F)) << 4)
+ | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 8)
+ | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 12)
+ | (((GLint) (rgba[i][RCOMP] * 15.0F)) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ if (dstFormat == GL_RGBA) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ 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);
+ }
+ }
+ else if (dstFormat == GL_BGRA) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][BCOMP] * 15.0F)) )
+ | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 4)
+ | (((GLint) (rgba[i][RCOMP] * 15.0F)) << 8)
+ | (((GLint) (rgba[i][ACOMP] * 15.0F)) << 12);
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][ACOMP] * 15.0F)) )
+ | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 4)
+ | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 8)
+ | (((GLint) (rgba[i][RCOMP] * 15.0F)) << 12);
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ if (dstFormat == GL_RGBA) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ 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)) );
+ }
+ }
+ else if (dstFormat == GL_BGRA) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][BCOMP] * 31.0F)) << 11)
+ | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 6)
+ | (((GLint) (rgba[i][RCOMP] * 31.0F)) << 1)
+ | (((GLint) (rgba[i][ACOMP] * 1.0F)) );
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][ACOMP] * 31.0F)) << 11)
+ | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 6)
+ | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 1)
+ | (((GLint) (rgba[i][RCOMP] * 1.0F)) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ if (dstFormat == GL_RGBA) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ 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);
+ }
+ }
+ else if (dstFormat == GL_BGRA) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][BCOMP] * 31.0F)) )
+ | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 5)
+ | (((GLint) (rgba[i][RCOMP] * 31.0F)) << 10)
+ | (((GLint) (rgba[i][ACOMP] * 1.0F)) << 15);
+ }
+ }
+ else if (dstFormat == GL_ABGR_EXT) {
+ GLushort *dst = (GLushort *) dstAddr;
+ for (i=0;i<n;i++) {
+ dst[i] = (((GLint) (rgba[i][ACOMP] * 31.0F)) )
+ | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 5)
+ | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 10)
+ | (((GLint) (rgba[i][RCOMP] * 1.0F)) << 15);
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ if (dstFormat == GL_RGBA) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ 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 (dstFormat == GL_BGRA) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ 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 (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ 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;
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ if (dstFormat == GL_RGBA) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ 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 (dstFormat == GL_BGRA) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ 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 (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ 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;
+ case GL_UNSIGNED_INT_10_10_10_2:
+ if (dstFormat == GL_RGBA) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ 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 (dstFormat == GL_BGRA) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ 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 (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ 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;
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ if (dstFormat == GL_RGBA) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ 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 (dstFormat == GL_BGRA) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ 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 (dstFormat == GL_ABGR_EXT) {
+ GLuint *dst = (GLuint *) dstAddr;
+ for (i=0;i<n;i++) {
+ 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:
+ _mesa_problem(ctx, "bad type in _mesa_pack_rgba_span_float");
+ }
+}
+
+
+/*
+ * Pack the given RGBA span into client memory at 'dest' address
+ * in the given pixel format and type.
+ * Optionally apply the enabled pixel transfer ops.
+ * Pack into memory using the given packing params struct.
+ * This is used by glReadPixels and glGetTexImage?D()
+ * \param ctx - the context
+ * n - number of pixels in the span
+ * rgba - the pixels
+ * format - dest packing format
+ * type - dest packing data type
+ * destination - destination packing address
+ * packing - pixel packing parameters
+ * transferOps - bitmask of IMAGE_*_BIT operations to apply
+ */
+void
+_mesa_pack_rgba_span_chan( GLcontext *ctx,
+ GLuint n, CONST GLchan srcRgba[][4],
+ GLenum dstFormat, GLenum dstType,
+ GLvoid *dstAddr,
+ const struct gl_pixelstore_attrib *dstPacking,
+ GLuint transferOps)
+{
+ ASSERT((ctx->NewState & _NEW_PIXEL) == 0 || transferOps == 0);
+
+ /* Test for optimized case first */
+ if (transferOps == 0 && dstFormat == GL_RGBA && dstType == CHAN_TYPE) {
+ /* common simple case */
+ MEMCPY(dstAddr, srcRgba, n * 4 * sizeof(GLchan));
+ }
+ else if (transferOps == 0 && dstFormat == GL_RGB && dstType == CHAN_TYPE) {
+ /* common simple case */
+ GLuint i;
+ GLchan *dest = (GLchan *) dstAddr;
+ for (i = 0; i < n; i++) {
+ dest[0] = srcRgba[i][RCOMP];
+ dest[1] = srcRgba[i][GCOMP];
+ dest[2] = srcRgba[i][BCOMP];
+ dest += 3;
+ }
+ }
+ else if (transferOps == 0 && dstFormat == GL_RGBA && dstType == GL_UNSIGNED_BYTE) {
+ /* common simple case */
+ GLuint i;
+ GLubyte *dest = (GLubyte *) dstAddr;
+ for (i = 0; i < n; i++) {
+ dest[0] = CHAN_TO_UBYTE(srcRgba[i][RCOMP]);
+ dest[1] = CHAN_TO_UBYTE(srcRgba[i][GCOMP]);
+ dest[2] = CHAN_TO_UBYTE(srcRgba[i][BCOMP]);
+ dest[3] = CHAN_TO_UBYTE(srcRgba[i][ACOMP]);
+ dest += 4;
+ }
+ }
+ else {
+ /* general solution */
+ GLuint i;
+ DEFMARRAY(GLfloat, rgba, MAX_WIDTH, 4); /* mac 32k limitation */
+ CHECKARRAY(rgba, return); /* mac 32k limitation */
+
+ assert(n <= MAX_WIDTH);
+ /* convert color components to floating point */
+ for (i = 0; i < n; i++) {
+ rgba[i][RCOMP] = CHAN_TO_FLOAT(srcRgba[i][RCOMP]);
+ rgba[i][GCOMP] = CHAN_TO_FLOAT(srcRgba[i][GCOMP]);
+ rgba[i][BCOMP] = CHAN_TO_FLOAT(srcRgba[i][BCOMP]);
+ rgba[i][ACOMP] = CHAN_TO_FLOAT(srcRgba[i][ACOMP]);
+ }
+ _mesa_pack_rgba_span_float(ctx, n, (const GLfloat (*)[4]) rgba,
+ dstFormat, dstType, dstAddr,
+ dstPacking, transferOps);
+ UNDEFARRAY(rgba); /* mac 32k limitation */
+ }
+}
+
+
+#define SWAP2BYTE(VALUE) \
+ { \
+ GLubyte *bytes = (GLubyte *) &(VALUE); \
+ GLubyte tmp = bytes[0]; \
+ bytes[0] = bytes[1]; \
+ bytes[1] = tmp; \
+ }
+
+#define SWAP4BYTE(VALUE) \
+ { \
+ GLubyte *bytes = (GLubyte *) &(VALUE); \
+ GLubyte tmp = bytes[0]; \
+ bytes[0] = bytes[3]; \
+ bytes[3] = tmp; \
+ tmp = bytes[1]; \
+ bytes[1] = bytes[2]; \
+ bytes[2] = tmp; \
+ }
+
+
+static void
+extract_uint_indexes(GLuint n, GLuint indexes[],
+ GLenum srcFormat, GLenum srcType, const GLvoid *src,
+ const struct gl_pixelstore_attrib *unpack )
+{
+ assert(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_HALF_FLOAT_ARB ||
+ srcType == GL_FLOAT);
+
+ switch (srcType) {
+ case GL_BITMAP:
+ {
+ GLubyte *ubsrc = (GLubyte *) src;
+ if (unpack->LsbFirst) {
+ GLubyte mask = 1 << (unpack->SkipPixels & 0x7);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ indexes[i] = (*ubsrc & mask) ? 1 : 0;
+ if (mask == 128) {
+ mask = 1;
+ ubsrc++;
+ }
+ else {
+ mask = mask << 1;
+ }
+ }
+ }
+ else {
+ GLubyte mask = 128 >> (unpack->SkipPixels & 0x7);
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ indexes[i] = (*ubsrc & mask) ? 1 : 0;
+ if (mask == 1) {
+ mask = 128;
+ ubsrc++;
+ }
+ else {
+ mask = mask >> 1;
+ }
+ }
+ }
+ }
+ break;
+ case GL_UNSIGNED_BYTE:
+ {
+ GLuint i;
+ const GLubyte *s = (const GLubyte *) src;
+ for (i = 0; i < n; i++)
+ indexes[i] = s[i];
+ }
+ break;
+ case GL_BYTE:
+ {
+ GLuint i;
+ const GLbyte *s = (const GLbyte *) src;
+ for (i = 0; i < n; i++)
+ indexes[i] = s[i];
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ {
+ GLuint i;
+ const GLushort *s = (const GLushort *) src;
+ if (unpack->SwapBytes) {
+ for (i = 0; i < n; i++) {
+ GLushort value = s[i];
+ SWAP2BYTE(value);
+ indexes[i] = value;
+ }
+ }
+ else {
+ for (i = 0; i < n; i++)
+ indexes[i] = s[i];
+ }
+ }
+ break;
+ case GL_SHORT:
+ {
+ GLuint i;
+ const GLshort *s = (const GLshort *) src;
+ if (unpack->SwapBytes) {
+ for (i = 0; i < n; i++) {
+ GLshort value = s[i];
+ SWAP2BYTE(value);
+ indexes[i] = value;
+ }
+ }
+ else {
+ for (i = 0; i < n; i++)
+ indexes[i] = s[i];
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ {
+ GLuint i;
+ const GLuint *s = (const GLuint *) src;
+ if (unpack->SwapBytes) {
+ for (i = 0; i < n; i++) {
+ GLuint value = s[i];
+ SWAP4BYTE(value);
+ indexes[i] = value;
+ }
+ }
+ else {
+ for (i = 0; i < n; i++)
+ indexes[i] = s[i];
+ }
+ }
+ break;
+ case GL_INT:
+ {
+ GLuint i;
+ const GLint *s = (const GLint *) src;
+ if (unpack->SwapBytes) {
+ for (i = 0; i < n; i++) {
+ GLint value = s[i];
+ SWAP4BYTE(value);
+ indexes[i] = value;
+ }
+ }
+ else {
+ for (i = 0; i < n; i++)
+ indexes[i] = s[i];
+ }
+ }
+ break;
+ case GL_FLOAT:
+ {
+ GLuint i;
+ const GLfloat *s = (const GLfloat *) src;
+ if (unpack->SwapBytes) {
+ for (i = 0; i < n; i++) {
+ GLfloat value = s[i];
+ SWAP4BYTE(value);
+ indexes[i] = (GLuint) value;
+ }
+ }
+ else {
+ for (i = 0; i < n; i++)
+ indexes[i] = (GLuint) s[i];
+ }
+ }
+ break;
+ case GL_HALF_FLOAT_ARB:
+ {
+ GLuint i;
+ const GLhalfARB *s = (const GLhalfARB *) src;
+ if (unpack->SwapBytes) {
+ for (i = 0; i < n; i++) {
+ GLhalfARB value = s[i];
+ SWAP2BYTE(value);
+ indexes[i] = (GLuint) _mesa_half_to_float(value);
+ }
+ }
+ else {
+ for (i = 0; i < n; i++)
+ indexes[i] = (GLuint) _mesa_half_to_float(s[i]);
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL, "bad srcType in extract_uint_indexes");
+ return;
+ }
+}
+
+
+/*
+ * This function extracts floating point RGBA values from arbitrary
+ * image data. srcFormat and srcType are the format and type parameters
+ * passed to glDrawPixels, glTexImage[123]D, glTexSubImage[123]D, etc.
+ *
+ * Refering to section 3.6.4 of the OpenGL 1.2 spec, this function
+ * implements the "Conversion to floating point", "Conversion to RGB",
+ * and "Final Expansion to RGBA" operations.
+ *
+ * Args: n - number of pixels
+ * rgba - output colors
+ * srcFormat - format of incoming data
+ * srcType - data type of incoming data
+ * src - source data pointer
+ * swapBytes - perform byteswapping of incoming data?
+ */
+static void
+extract_float_rgba(GLuint n, GLfloat rgba[][4],
+ GLenum srcFormat, GLenum srcType, const GLvoid *src,
+ GLboolean swapBytes)
+{
+ GLint redIndex, greenIndex, blueIndex, alphaIndex;
+ GLint stride;
+ GLint rComp, bComp, gComp, aComp;
+
+ 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);
+
+ ASSERT(srcType == GL_UNSIGNED_BYTE ||
+ srcType == GL_BYTE ||
+ srcType == GL_UNSIGNED_SHORT ||
+ srcType == GL_SHORT ||
+ srcType == GL_UNSIGNED_INT ||
+ srcType == GL_INT ||
+ srcType == GL_HALF_FLOAT_ARB ||
+ 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);
+
+ rComp = gComp = bComp = aComp = -1;
+
+ switch (srcFormat) {
+ case GL_RED:
+ redIndex = 0;
+ greenIndex = blueIndex = alphaIndex = -1;
+ stride = 1;
+ break;
+ case GL_GREEN:
+ greenIndex = 0;
+ redIndex = blueIndex = alphaIndex = -1;
+ stride = 1;
+ break;
+ case GL_BLUE:
+ blueIndex = 0;
+ redIndex = greenIndex = alphaIndex = -1;
+ stride = 1;
+ break;
+ case GL_ALPHA:
+ redIndex = greenIndex = blueIndex = -1;
+ alphaIndex = 0;
+ stride = 1;
+ break;
+ case GL_LUMINANCE:
+ redIndex = greenIndex = blueIndex = 0;
+ alphaIndex = -1;
+ stride = 1;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ redIndex = greenIndex = blueIndex = 0;
+ alphaIndex = 1;
+ stride = 2;
+ break;
+ case GL_INTENSITY:
+ redIndex = greenIndex = blueIndex = alphaIndex = 0;
+ stride = 1;
+ break;
+ case GL_RGB:
+ redIndex = 0;
+ greenIndex = 1;
+ blueIndex = 2;
+ alphaIndex = -1;
+ rComp = 0;
+ gComp = 1;
+ bComp = 2;
+ aComp = 3;
+ stride = 3;
+ break;
+ case GL_BGR:
+ redIndex = 2;
+ greenIndex = 1;
+ blueIndex = 0;
+ alphaIndex = -1;
+ rComp = 2;
+ gComp = 1;
+ bComp = 0;
+ aComp = 3;
+ stride = 3;
+ break;
+ case GL_RGBA:
+ redIndex = 0;
+ greenIndex = 1;
+ blueIndex = 2;
+ alphaIndex = 3;
+ rComp = 0;
+ gComp = 1;
+ bComp = 2;
+ aComp = 3;
+ stride = 4;
+ break;
+ case GL_BGRA:
+ redIndex = 2;
+ greenIndex = 1;
+ blueIndex = 0;
+ alphaIndex = 3;
+ rComp = 2;
+ gComp = 1;
+ bComp = 0;
+ aComp = 3;
+ stride = 4;
+ break;
+ case GL_ABGR_EXT:
+ redIndex = 3;
+ greenIndex = 2;
+ blueIndex = 1;
+ alphaIndex = 0;
+ rComp = 3;
+ gComp = 2;
+ bComp = 1;
+ aComp = 0;
+ stride = 4;
+ break;
+ default:
+ _mesa_problem(NULL, "bad srcFormat in extract float data");
+ return;
+ }
+
+
+#define PROCESS(INDEX, CHANNEL, DEFAULT, TYPE, CONVERSION) \
+ if ((INDEX) < 0) { \
+ GLuint i; \
+ for (i = 0; i < n; i++) { \
+ rgba[i][CHANNEL] = DEFAULT; \
+ } \
+ } \
+ else if (swapBytes) { \
+ const TYPE *s = (const TYPE *) src; \
+ GLuint i; \
+ for (i = 0; i < n; i++) { \
+ TYPE value = s[INDEX]; \
+ if (sizeof(TYPE) == 2) { \
+ SWAP2BYTE(value); \
+ } \
+ else if (sizeof(TYPE) == 4) { \
+ SWAP4BYTE(value); \
+ } \
+ rgba[i][CHANNEL] = (GLfloat) CONVERSION(value); \
+ s += stride; \
+ } \
+ } \
+ else { \
+ const TYPE *s = (const TYPE *) src; \
+ GLuint i; \
+ for (i = 0; i < n; i++) { \
+ rgba[i][CHANNEL] = (GLfloat) CONVERSION(s[INDEX]); \
+ s += stride; \
+ } \
+ }
+
+ switch (srcType) {
+ case GL_UNSIGNED_BYTE:
+ PROCESS(redIndex, RCOMP, 0.0F, GLubyte, UBYTE_TO_FLOAT);
+ PROCESS(greenIndex, GCOMP, 0.0F, GLubyte, UBYTE_TO_FLOAT);
+ PROCESS(blueIndex, BCOMP, 0.0F, GLubyte, UBYTE_TO_FLOAT);
+ PROCESS(alphaIndex, ACOMP, 1.0F, GLubyte, UBYTE_TO_FLOAT);
+ break;
+ case GL_BYTE:
+ PROCESS(redIndex, RCOMP, 0.0F, GLbyte, BYTE_TO_FLOAT);
+ PROCESS(greenIndex, GCOMP, 0.0F, GLbyte, BYTE_TO_FLOAT);
+ PROCESS(blueIndex, BCOMP, 0.0F, GLbyte, BYTE_TO_FLOAT);
+ PROCESS(alphaIndex, ACOMP, 1.0F, GLbyte, BYTE_TO_FLOAT);
+ break;
+ case GL_UNSIGNED_SHORT:
+ PROCESS(redIndex, RCOMP, 0.0F, GLushort, USHORT_TO_FLOAT);
+ PROCESS(greenIndex, GCOMP, 0.0F, GLushort, USHORT_TO_FLOAT);
+ PROCESS(blueIndex, BCOMP, 0.0F, GLushort, USHORT_TO_FLOAT);
+ PROCESS(alphaIndex, ACOMP, 1.0F, GLushort, USHORT_TO_FLOAT);
+ break;
+ case GL_SHORT:
+ PROCESS(redIndex, RCOMP, 0.0F, GLshort, SHORT_TO_FLOAT);
+ PROCESS(greenIndex, GCOMP, 0.0F, GLshort, SHORT_TO_FLOAT);
+ PROCESS(blueIndex, BCOMP, 0.0F, GLshort, SHORT_TO_FLOAT);
+ PROCESS(alphaIndex, ACOMP, 1.0F, GLshort, SHORT_TO_FLOAT);
+ break;
+ case GL_UNSIGNED_INT:
+ PROCESS(redIndex, RCOMP, 0.0F, GLuint, UINT_TO_FLOAT);
+ PROCESS(greenIndex, GCOMP, 0.0F, GLuint, UINT_TO_FLOAT);
+ PROCESS(blueIndex, BCOMP, 0.0F, GLuint, UINT_TO_FLOAT);
+ PROCESS(alphaIndex, ACOMP, 1.0F, GLuint, UINT_TO_FLOAT);
+ break;
+ case GL_INT:
+ PROCESS(redIndex, RCOMP, 0.0F, GLint, INT_TO_FLOAT);
+ PROCESS(greenIndex, GCOMP, 0.0F, GLint, INT_TO_FLOAT);
+ PROCESS(blueIndex, BCOMP, 0.0F, GLint, INT_TO_FLOAT);
+ PROCESS(alphaIndex, ACOMP, 1.0F, GLint, INT_TO_FLOAT);
+ break;
+ case GL_FLOAT:
+ PROCESS(redIndex, RCOMP, 0.0F, GLfloat, (GLfloat));
+ PROCESS(greenIndex, GCOMP, 0.0F, GLfloat, (GLfloat));
+ PROCESS(blueIndex, BCOMP, 0.0F, GLfloat, (GLfloat));
+ PROCESS(alphaIndex, ACOMP, 1.0F, GLfloat, (GLfloat));
+ break;
+ case GL_HALF_FLOAT_ARB:
+ PROCESS(redIndex, RCOMP, 0.0F, GLhalfARB, _mesa_half_to_float);
+ PROCESS(greenIndex, GCOMP, 0.0F, GLhalfARB, _mesa_half_to_float);
+ PROCESS(blueIndex, BCOMP, 0.0F, GLhalfARB, _mesa_half_to_float);
+ PROCESS(alphaIndex, ACOMP, 1.0F, GLhalfARB, _mesa_half_to_float);
+ break;
+ case GL_UNSIGNED_BYTE_3_3_2:
+ {
+ const GLubyte *ubsrc = (const GLubyte *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLubyte p = ubsrc[i];
+ rgba[i][rComp] = ((p >> 5) ) * (1.0F / 7.0F);
+ rgba[i][gComp] = ((p >> 2) & 0x7) * (1.0F / 7.0F);
+ rgba[i][bComp] = ((p ) & 0x3) * (1.0F / 3.0F);
+ rgba[i][aComp] = 1.0F;
+ }
+ }
+ break;
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ {
+ const GLubyte *ubsrc = (const GLubyte *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLubyte p = ubsrc[i];
+ rgba[i][rComp] = ((p ) & 0x7) * (1.0F / 7.0F);
+ rgba[i][gComp] = ((p >> 3) & 0x7) * (1.0F / 7.0F);
+ rgba[i][bComp] = ((p >> 6) ) * (1.0F / 3.0F);
+ rgba[i][aComp] = 1.0F;
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5:
+ if (swapBytes) {
+ const GLushort *ussrc = (const GLushort *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLushort p = ussrc[i];
+ SWAP2BYTE(p);
+ rgba[i][rComp] = ((p >> 11) ) * (1.0F / 31.0F);
+ rgba[i][gComp] = ((p >> 5) & 0x3f) * (1.0F / 63.0F);
+ rgba[i][bComp] = ((p ) & 0x1f) * (1.0F / 31.0F);
+ rgba[i][aComp] = 1.0F;
+ }
+ }
+ else {
+ const GLushort *ussrc = (const GLushort *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLushort p = ussrc[i];
+ rgba[i][rComp] = ((p >> 11) ) * (1.0F / 31.0F);
+ rgba[i][gComp] = ((p >> 5) & 0x3f) * (1.0F / 63.0F);
+ rgba[i][bComp] = ((p ) & 0x1f) * (1.0F / 31.0F);
+ rgba[i][aComp] = 1.0F;
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ if (swapBytes) {
+ const GLushort *ussrc = (const GLushort *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLushort p = ussrc[i];
+ SWAP2BYTE(p);
+ rgba[i][rComp] = ((p ) & 0x1f) * (1.0F / 31.0F);
+ rgba[i][gComp] = ((p >> 5) & 0x3f) * (1.0F / 63.0F);
+ rgba[i][bComp] = ((p >> 11) ) * (1.0F / 31.0F);
+ rgba[i][aComp] = 1.0F;
+ }
+ }
+ else {
+ const GLushort *ussrc = (const GLushort *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLushort p = ussrc[i];
+ rgba[i][rComp] = ((p ) & 0x1f) * (1.0F / 31.0F);
+ rgba[i][gComp] = ((p >> 5) & 0x3f) * (1.0F / 63.0F);
+ rgba[i][bComp] = ((p >> 11) ) * (1.0F / 31.0F);
+ rgba[i][aComp] = 1.0F;
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ if (swapBytes) {
+ const GLushort *ussrc = (const GLushort *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLushort p = ussrc[i];
+ SWAP2BYTE(p);
+ rgba[i][rComp] = ((p >> 12) ) * (1.0F / 15.0F);
+ rgba[i][gComp] = ((p >> 8) & 0xf) * (1.0F / 15.0F);
+ rgba[i][bComp] = ((p >> 4) & 0xf) * (1.0F / 15.0F);
+ rgba[i][aComp] = ((p ) & 0xf) * (1.0F / 15.0F);
+ }
+ }
+ else {
+ const GLushort *ussrc = (const GLushort *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLushort p = ussrc[i];
+ rgba[i][rComp] = ((p >> 12) ) * (1.0F / 15.0F);
+ rgba[i][gComp] = ((p >> 8) & 0xf) * (1.0F / 15.0F);
+ rgba[i][bComp] = ((p >> 4) & 0xf) * (1.0F / 15.0F);
+ rgba[i][aComp] = ((p ) & 0xf) * (1.0F / 15.0F);
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ if (swapBytes) {
+ const GLushort *ussrc = (const GLushort *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLushort p = ussrc[i];
+ SWAP2BYTE(p);
+ rgba[i][rComp] = ((p ) & 0xf) * (1.0F / 15.0F);
+ rgba[i][gComp] = ((p >> 4) & 0xf) * (1.0F / 15.0F);
+ rgba[i][bComp] = ((p >> 8) & 0xf) * (1.0F / 15.0F);
+ rgba[i][aComp] = ((p >> 12) ) * (1.0F / 15.0F);
+ }
+ }
+ else {
+ const GLushort *ussrc = (const GLushort *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLushort p = ussrc[i];
+ rgba[i][rComp] = ((p ) & 0xf) * (1.0F / 15.0F);
+ rgba[i][gComp] = ((p >> 4) & 0xf) * (1.0F / 15.0F);
+ rgba[i][bComp] = ((p >> 8) & 0xf) * (1.0F / 15.0F);
+ rgba[i][aComp] = ((p >> 12) ) * (1.0F / 15.0F);
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ if (swapBytes) {
+ const GLushort *ussrc = (const GLushort *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLushort p = ussrc[i];
+ SWAP2BYTE(p);
+ rgba[i][rComp] = ((p >> 11) ) * (1.0F / 31.0F);
+ rgba[i][gComp] = ((p >> 6) & 0x1f) * (1.0F / 31.0F);
+ rgba[i][bComp] = ((p >> 1) & 0x1f) * (1.0F / 31.0F);
+ rgba[i][aComp] = ((p ) & 0x1) * (1.0F / 1.0F);
+ }
+ }
+ else {
+ const GLushort *ussrc = (const GLushort *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLushort p = ussrc[i];
+ rgba[i][rComp] = ((p >> 11) ) * (1.0F / 31.0F);
+ rgba[i][gComp] = ((p >> 6) & 0x1f) * (1.0F / 31.0F);
+ rgba[i][bComp] = ((p >> 1) & 0x1f) * (1.0F / 31.0F);
+ rgba[i][aComp] = ((p ) & 0x1) * (1.0F / 1.0F);
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ if (swapBytes) {
+ const GLushort *ussrc = (const GLushort *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLushort p = ussrc[i];
+ SWAP2BYTE(p);
+ rgba[i][rComp] = ((p ) & 0x1f) * (1.0F / 31.0F);
+ rgba[i][gComp] = ((p >> 5) & 0x1f) * (1.0F / 31.0F);
+ rgba[i][bComp] = ((p >> 10) & 0x1f) * (1.0F / 31.0F);
+ rgba[i][aComp] = ((p >> 15) ) * (1.0F / 1.0F);
+ }
+ }
+ else {
+ const GLushort *ussrc = (const GLushort *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLushort p = ussrc[i];
+ rgba[i][rComp] = ((p ) & 0x1f) * (1.0F / 31.0F);
+ rgba[i][gComp] = ((p >> 5) & 0x1f) * (1.0F / 31.0F);
+ rgba[i][bComp] = ((p >> 10) & 0x1f) * (1.0F / 31.0F);
+ rgba[i][aComp] = ((p >> 15) ) * (1.0F / 1.0F);
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8:
+ if (swapBytes) {
+ const GLuint *uisrc = (const GLuint *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLuint p = uisrc[i];
+ rgba[i][rComp] = UBYTE_TO_FLOAT((p ) & 0xff);
+ rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff);
+ rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff);
+ rgba[i][aComp] = UBYTE_TO_FLOAT((p >> 24) );
+ }
+ }
+ else {
+ const GLuint *uisrc = (const GLuint *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLuint p = uisrc[i];
+ rgba[i][rComp] = UBYTE_TO_FLOAT((p >> 24) );
+ rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff);
+ rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff);
+ rgba[i][aComp] = UBYTE_TO_FLOAT((p ) & 0xff);
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ if (swapBytes) {
+ const GLuint *uisrc = (const GLuint *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLuint p = uisrc[i];
+ rgba[i][rComp] = UBYTE_TO_FLOAT((p >> 24) );
+ rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff);
+ rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff);
+ rgba[i][aComp] = UBYTE_TO_FLOAT((p ) & 0xff);
+ }
+ }
+ else {
+ const GLuint *uisrc = (const GLuint *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLuint p = uisrc[i];
+ rgba[i][rComp] = UBYTE_TO_FLOAT((p ) & 0xff);
+ rgba[i][gComp] = UBYTE_TO_FLOAT((p >> 8) & 0xff);
+ rgba[i][bComp] = UBYTE_TO_FLOAT((p >> 16) & 0xff);
+ rgba[i][aComp] = UBYTE_TO_FLOAT((p >> 24) );
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT_10_10_10_2:
+ if (swapBytes) {
+ const GLuint *uisrc = (const GLuint *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLuint p = uisrc[i];
+ SWAP4BYTE(p);
+ rgba[i][rComp] = ((p >> 22) ) * (1.0F / 1023.0F);
+ rgba[i][gComp] = ((p >> 12) & 0x3ff) * (1.0F / 1023.0F);
+ rgba[i][bComp] = ((p >> 2) & 0x3ff) * (1.0F / 1023.0F);
+ rgba[i][aComp] = ((p ) & 0x3 ) * (1.0F / 3.0F);
+ }
+ }
+ else {
+ const GLuint *uisrc = (const GLuint *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLuint p = uisrc[i];
+ rgba[i][rComp] = ((p >> 22) ) * (1.0F / 1023.0F);
+ rgba[i][gComp] = ((p >> 12) & 0x3ff) * (1.0F / 1023.0F);
+ rgba[i][bComp] = ((p >> 2) & 0x3ff) * (1.0F / 1023.0F);
+ rgba[i][aComp] = ((p ) & 0x3 ) * (1.0F / 3.0F);
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ if (swapBytes) {
+ const GLuint *uisrc = (const GLuint *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLuint p = uisrc[i];
+ SWAP4BYTE(p);
+ rgba[i][rComp] = ((p ) & 0x3ff) * (1.0F / 1023.0F);
+ rgba[i][gComp] = ((p >> 10) & 0x3ff) * (1.0F / 1023.0F);
+ rgba[i][bComp] = ((p >> 20) & 0x3ff) * (1.0F / 1023.0F);
+ rgba[i][aComp] = ((p >> 30) ) * (1.0F / 3.0F);
+ }
+ }
+ else {
+ const GLuint *uisrc = (const GLuint *) src;
+ GLuint i;
+ for (i = 0; i < n; i ++) {
+ GLuint p = uisrc[i];
+ rgba[i][rComp] = ((p ) & 0x3ff) * (1.0F / 1023.0F);
+ rgba[i][gComp] = ((p >> 10) & 0x3ff) * (1.0F / 1023.0F);
+ rgba[i][bComp] = ((p >> 20) & 0x3ff) * (1.0F / 1023.0F);
+ rgba[i][aComp] = ((p >> 30) ) * (1.0F / 3.0F);
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL, "bad srcType in extract float data");
+ break;
+ }
+}
+
+
+/*
+ * Unpack a row of color image data from a client buffer according to
+ * the pixel unpacking parameters.
+ * Return GLchan values in the specified dest image format.
+ * This is used by glDrawPixels and glTexImage?D().
+ * \param ctx - the context
+ * n - number of pixels in the span
+ * dstFormat - format of destination color array
+ * dest - the destination color array
+ * srcFormat - source image format
+ * srcType - source image data type
+ * source - source image pointer
+ * srcPacking - pixel unpacking parameters
+ * transferOps - bitmask of IMAGE_*_BIT values of operations to apply
+ *
+ * XXX perhaps expand this to process whole images someday.
+ */
+void
+_mesa_unpack_color_span_chan( GLcontext *ctx,
+ GLuint n, GLenum dstFormat, GLchan dest[],
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking,
+ GLuint transferOps )
+{
+ 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_HALF_FLOAT_ARB ||
+ 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);
+
+ /* Try simple cases first */
+ if (transferOps == 0) {
+ if (srcType == CHAN_TYPE) {
+ if (dstFormat == GL_RGBA) {
+ if (srcFormat == GL_RGBA) {
+ MEMCPY( dest, source, n * 4 * sizeof(GLchan) );
+ return;
+ }
+ else if (srcFormat == GL_RGB) {
+ GLuint i;
+ const GLchan *src = (const GLchan *) source;
+ GLchan *dst = dest;
+ for (i = 0; i < n; i++) {
+ dst[0] = src[0];
+ dst[1] = src[1];
+ dst[2] = src[2];
+ dst[3] = CHAN_MAX;
+ src += 3;
+ dst += 4;
+ }
+ return;
+ }
+ }
+ else if (dstFormat == GL_RGB) {
+ if (srcFormat == GL_RGB) {
+ MEMCPY( dest, source, n * 3 * sizeof(GLchan) );
+ return;
+ }
+ else if (srcFormat == GL_RGBA) {
+ GLuint i;
+ const GLchan *src = (const GLchan *) source;
+ GLchan *dst = dest;
+ for (i = 0; i < n; i++) {
+ dst[0] = src[0];
+ dst[1] = src[1];
+ dst[2] = src[2];
+ src += 4;
+ dst += 3;
+ }
+ return;
+ }
+ }
+ else if (dstFormat == srcFormat) {
+ GLint comps = _mesa_components_in_format(srcFormat);
+ assert(comps > 0);
+ MEMCPY( dest, source, n * comps * sizeof(GLchan) );
+ return;
+ }
+ }
+ /*
+ * Common situation, loading 8bit RGBA/RGB source images
+ * into 16/32 bit destination. (OSMesa16/32)
+ */
+ else if (srcType == GL_UNSIGNED_BYTE) {
+ if (dstFormat == GL_RGBA) {
+ if (srcFormat == GL_RGB) {
+ GLuint i;
+ const GLubyte *src = (const GLubyte *) source;
+ GLchan *dst = dest;
+ for (i = 0; i < n; i++) {
+ dst[0] = UBYTE_TO_CHAN(src[0]);
+ dst[1] = UBYTE_TO_CHAN(src[1]);
+ dst[2] = UBYTE_TO_CHAN(src[2]);
+ dst[3] = CHAN_MAX;
+ src += 3;
+ dst += 4;
+ }
+ return;
+ }
+ else if (srcFormat == GL_RGBA) {
+ GLuint i;
+ const GLubyte *src = (const GLubyte *) source;
+ GLchan *dst = dest;
+ for (i = 0; i < n; i++) {
+ dst[0] = UBYTE_TO_CHAN(src[0]);
+ dst[1] = UBYTE_TO_CHAN(src[1]);
+ dst[2] = UBYTE_TO_CHAN(src[2]);
+ dst[3] = UBYTE_TO_CHAN(src[3]);
+ src += 4;
+ dst += 4;
+ }
+ return;
+ }
+ }
+ else if (dstFormat == GL_RGB) {
+ if (srcFormat == GL_RGB) {
+ GLuint i;
+ const GLubyte *src = (const GLubyte *) source;
+ GLchan *dst = dest;
+ for (i = 0; i < n; i++) {
+ dst[0] = UBYTE_TO_CHAN(src[0]);
+ dst[1] = UBYTE_TO_CHAN(src[1]);
+ dst[2] = UBYTE_TO_CHAN(src[2]);
+ src += 3;
+ dst += 3;
+ }
+ return;
+ }
+ else if (srcFormat == GL_RGBA) {
+ GLuint i;
+ const GLubyte *src = (const GLubyte *) source;
+ GLchan *dst = dest;
+ for (i = 0; i < n; i++) {
+ dst[0] = UBYTE_TO_CHAN(src[0]);
+ dst[1] = UBYTE_TO_CHAN(src[1]);
+ dst[2] = UBYTE_TO_CHAN(src[2]);
+ src += 4;
+ dst += 3;
+ }
+ return;
+ }
+ }
+ }
+ }
+
+
+ /* general solution begins here */
+ {
+ GLint dstComponents;
+ GLint dstRedIndex, dstGreenIndex, dstBlueIndex, dstAlphaIndex;
+ GLint dstLuminanceIndex, dstIntensityIndex;
+ DEFMARRAY(GLfloat, rgba, MAX_WIDTH, 4); /* mac 32k limitation */
+ CHECKARRAY(rgba, return); /* mac 32k limitation */
+
+ 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,
+ srcPacking);
+
+ if (dstFormat == GL_COLOR_INDEX
+ && (transferOps & IMAGE_MAP_COLOR_BIT)) {
+ _mesa_map_ci(ctx, n, indexes);
+ }
+ if (transferOps & IMAGE_SHIFT_OFFSET_BIT) {
+ _mesa_shift_and_offset_ci(ctx, n, indexes);
+ }
+
+ if (dstFormat == GL_COLOR_INDEX) {
+ /* convert to GLchan and return */
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dest[i] = (GLchan) (indexes[i] & 0xff);
+ }
+ UNDEFARRAY(rgba); /* mac 32k limitation */
+ return;
+ }
+ else {
+ /* Convert indexes to RGBA */
+ _mesa_map_ci_to_rgba(ctx, n, indexes, rgba);
+ }
+
+ /* Don't do RGBA scale/bias or RGBA->RGBA mapping if starting
+ * with color indexes.
+ */
+ transferOps &= ~(IMAGE_SCALE_BIAS_BIT | IMAGE_MAP_COLOR_BIT);
+ }
+ else {
+ /* non-color index data */
+ extract_float_rgba(n, rgba, srcFormat, srcType, source,
+ srcPacking->SwapBytes);
+ }
+
+ /* Need to clamp if returning GLubytes or GLushorts */
+#if CHAN_TYPE != GL_FLOAT
+ transferOps |= IMAGE_CLAMP_BIT;
+#endif
+
+ if (transferOps) {
+ _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba);
+ }
+
+ /* 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:
+ _mesa_problem(ctx, "bad dstFormat in _mesa_unpack_chan_span()");
+ UNDEFARRAY(rgba); /* mac 32k limitation */
+ return;
+ }
+
+
+ /* Now return the GLchan data in the requested dstFormat */
+
+ if (dstRedIndex >= 0) {
+ GLchan *dst = dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ CLAMPED_FLOAT_TO_CHAN(dst[dstRedIndex], rgba[i][RCOMP]);
+ dst += dstComponents;
+ }
+ }
+
+ if (dstGreenIndex >= 0) {
+ GLchan *dst = dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ CLAMPED_FLOAT_TO_CHAN(dst[dstGreenIndex], rgba[i][GCOMP]);
+ dst += dstComponents;
+ }
+ }
+
+ if (dstBlueIndex >= 0) {
+ GLchan *dst = dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ CLAMPED_FLOAT_TO_CHAN(dst[dstBlueIndex], rgba[i][BCOMP]);
+ dst += dstComponents;
+ }
+ }
+
+ if (dstAlphaIndex >= 0) {
+ GLchan *dst = dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ CLAMPED_FLOAT_TO_CHAN(dst[dstAlphaIndex], rgba[i][ACOMP]);
+ dst += dstComponents;
+ }
+ }
+
+ if (dstIntensityIndex >= 0) {
+ GLchan *dst = dest;
+ GLuint i;
+ assert(dstIntensityIndex == 0);
+ assert(dstComponents == 1);
+ for (i = 0; i < n; i++) {
+ /* Intensity comes from red channel */
+ CLAMPED_FLOAT_TO_CHAN(dst[i], rgba[i][RCOMP]);
+ }
+ }
+
+ if (dstLuminanceIndex >= 0) {
+ GLchan *dst = dest;
+ GLuint i;
+ assert(dstLuminanceIndex == 0);
+ for (i = 0; i < n; i++) {
+ /* Luminance comes from red channel */
+ CLAMPED_FLOAT_TO_CHAN(dst[0], rgba[i][RCOMP]);
+ dst += dstComponents;
+ }
+ }
+ UNDEFARRAY(rgba); /* mac 32k limitation */
+ }
+}
+
+
+/**
+ * Same as _mesa_unpack_color_span_chan(), but return GLfloat data
+ * instead of GLchan.
+ */
+void
+_mesa_unpack_color_span_float( GLcontext *ctx,
+ GLuint n, GLenum dstFormat, GLfloat dest[],
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking,
+ GLuint transferOps )
+{
+ 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_HALF_FLOAT_ARB ||
+ 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);
+
+ /* general solution, no special cases, yet */
+ {
+ GLint dstComponents;
+ GLint dstRedIndex, dstGreenIndex, dstBlueIndex, dstAlphaIndex;
+ GLint dstLuminanceIndex, dstIntensityIndex;
+ DEFMARRAY(GLfloat, rgba, MAX_WIDTH, 4); /* mac 32k limitation */
+ CHECKARRAY(rgba, return); /* mac 32k limitation */
+
+ 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,
+ srcPacking);
+
+ if (dstFormat == GL_COLOR_INDEX
+ && (transferOps & IMAGE_MAP_COLOR_BIT)) {
+ _mesa_map_ci(ctx, n, indexes);
+ }
+ if (transferOps & IMAGE_SHIFT_OFFSET_BIT) {
+ _mesa_shift_and_offset_ci(ctx, n, indexes);
+ }
+
+ if (dstFormat == GL_COLOR_INDEX) {
+ /* convert to GLchan and return */
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dest[i] = (GLchan) (indexes[i] & 0xff);
+ }
+ UNDEFARRAY(rgba); /* mac 32k limitation */
+ return;
+ }
+ else {
+ /* Convert indexes to RGBA */
+ _mesa_map_ci_to_rgba(ctx, n, indexes, rgba);
+ }
+
+ /* Don't do RGBA scale/bias or RGBA->RGBA mapping if starting
+ * with color indexes.
+ */
+ transferOps &= ~(IMAGE_SCALE_BIAS_BIT | IMAGE_MAP_COLOR_BIT);
+ }
+ else {
+ /* non-color index data */
+ extract_float_rgba(n, rgba, srcFormat, srcType, source,
+ srcPacking->SwapBytes);
+ }
+
+ if (transferOps) {
+ _mesa_apply_rgba_transfer_ops(ctx, transferOps, n, rgba);
+ }
+
+ /* 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:
+ _mesa_problem(ctx, "bad dstFormat in _mesa_unpack_color_span_float()");
+ UNDEFARRAY(rgba); /* mac 32k limitation */
+ return;
+ }
+
+ /* Now pack results in the 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;
+ }
+ }
+ UNDEFARRAY(rgba); /* mac 32k limitation */
+ }
+}
+
+
+/*
+ * Unpack a row of color index data from a client buffer according to
+ * the pixel unpacking parameters.
+ * This is (or will be) used by glDrawPixels, glTexImage[123]D, etc.
+ *
+ * Args: ctx - the context
+ * n - number of pixels
+ * dstType - destination data type
+ * dest - destination array
+ * srcType - source pixel type
+ * source - source data pointer
+ * srcPacking - pixel unpacking parameters
+ * transferOps - the pixel transfer operations to apply
+ */
+void
+_mesa_unpack_index_span( const GLcontext *ctx, GLuint n,
+ GLenum dstType, GLvoid *dest,
+ GLenum srcType, const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking,
+ GLuint transferOps )
+{
+ 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_HALF_FLOAT_ARB ||
+ srcType == GL_FLOAT);
+
+ ASSERT(dstType == GL_UNSIGNED_BYTE ||
+ dstType == GL_UNSIGNED_SHORT ||
+ dstType == GL_UNSIGNED_INT);
+
+
+ transferOps &= (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT);
+
+ /*
+ * Try simple cases first
+ */
+ if (transferOps == 0 && srcType == GL_UNSIGNED_BYTE
+ && dstType == GL_UNSIGNED_BYTE) {
+ MEMCPY(dest, source, n * sizeof(GLubyte));
+ }
+ else if (transferOps == 0 && srcType == GL_UNSIGNED_INT
+ && dstType == GL_UNSIGNED_INT && !srcPacking->SwapBytes) {
+ MEMCPY(dest, source, n * sizeof(GLuint));
+ }
+ else {
+ /*
+ * general solution
+ */
+ GLuint indexes[MAX_WIDTH];
+ assert(n <= MAX_WIDTH);
+
+ extract_uint_indexes(n, indexes, GL_COLOR_INDEX, srcType, source,
+ srcPacking);
+
+ if (transferOps & IMAGE_SHIFT_OFFSET_BIT) {
+ /* shift and offset indexes */
+ _mesa_shift_and_offset_ci(ctx, n, indexes);
+ }
+ if (transferOps & IMAGE_MAP_COLOR_BIT) {
+ /* Apply lookup table */
+ _mesa_map_ci(ctx, n, indexes);
+ }
+
+ /* convert to dest type */
+ switch (dstType) {
+ case GL_UNSIGNED_BYTE:
+ {
+ GLubyte *dst = (GLubyte *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = (GLubyte) (indexes[i] & 0xff);
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ {
+ GLuint *dst = (GLuint *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = (GLushort) (indexes[i] & 0xffff);
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ MEMCPY(dest, indexes, n * sizeof(GLuint));
+ break;
+ default:
+ _mesa_problem(ctx, "bad dstType in _mesa_unpack_index_span");
+ }
+ }
+}
+
+
+void
+_mesa_pack_index_span( const GLcontext *ctx, GLuint n,
+ GLenum dstType, GLvoid *dest, const GLuint *source,
+ const struct gl_pixelstore_attrib *dstPacking,
+ GLuint transferOps )
+{
+ GLuint indexes[MAX_WIDTH];
+
+ ASSERT(n <= MAX_WIDTH);
+
+ transferOps &= (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT);
+
+ if (transferOps & (IMAGE_MAP_COLOR_BIT | IMAGE_SHIFT_OFFSET_BIT)) {
+ /* make a copy of input */
+ MEMCPY(indexes, source, n * sizeof(GLuint));
+ if (transferOps & IMAGE_SHIFT_OFFSET_BIT) {
+ _mesa_shift_and_offset_ci( ctx, n, indexes);
+ }
+ if (transferOps & IMAGE_MAP_COLOR_BIT) {
+ _mesa_map_ci(ctx, n, indexes);
+ }
+ source = indexes;
+ }
+
+ switch (dstType) {
+ case GL_UNSIGNED_BYTE:
+ {
+ GLubyte *dst = (GLubyte *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ *dst++ = (GLubyte) source[i];
+ }
+ }
+ break;
+ case GL_BYTE:
+ {
+ GLbyte *dst = (GLbyte *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = (GLbyte) source[i];
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ {
+ GLushort *dst = (GLushort *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = (GLushort) source[i];
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap2( (GLushort *) dst, n );
+ }
+ }
+ break;
+ case GL_SHORT:
+ {
+ GLshort *dst = (GLshort *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = (GLshort) source[i];
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap2( (GLushort *) dst, n );
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ {
+ GLuint *dst = (GLuint *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = (GLuint) source[i];
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n );
+ }
+ }
+ break;
+ case GL_INT:
+ {
+ GLint *dst = (GLint *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = (GLint) source[i];
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n );
+ }
+ }
+ break;
+ case GL_FLOAT:
+ {
+ GLfloat *dst = (GLfloat *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = (GLfloat) source[i];
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n );
+ }
+ }
+ break;
+ case GL_HALF_FLOAT_ARB:
+ {
+ GLhalfARB *dst = (GLhalfARB *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = _mesa_float_to_half((GLfloat) source[i]);
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap2( (GLushort *) dst, n );
+ }
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "bad type in _mesa_pack_index_span");
+ }
+}
+
+
+/*
+ * Unpack a row of stencil data from a client buffer according to
+ * the pixel unpacking parameters.
+ * This is (or will be) used by glDrawPixels
+ *
+ * Args: ctx - the context
+ * n - number of pixels
+ * dstType - destination data type
+ * dest - destination array
+ * srcType - source pixel type
+ * source - source data pointer
+ * srcPacking - pixel unpacking parameters
+ * transferOps - apply offset/bias/lookup ops?
+ */
+void
+_mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n,
+ GLenum dstType, GLvoid *dest,
+ GLenum srcType, const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking,
+ GLuint transferOps )
+{
+ 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_HALF_FLOAT_ARB ||
+ srcType == GL_FLOAT);
+
+ ASSERT(dstType == GL_UNSIGNED_BYTE ||
+ dstType == GL_UNSIGNED_SHORT ||
+ dstType == GL_UNSIGNED_INT);
+
+ /* only shift and offset apply to stencil */
+ transferOps &= IMAGE_SHIFT_OFFSET_BIT;
+
+ /*
+ * Try simple cases first
+ */
+ if (transferOps == 0 &&
+ srcType == GL_UNSIGNED_BYTE &&
+ dstType == GL_UNSIGNED_BYTE) {
+ MEMCPY(dest, source, n * sizeof(GLubyte));
+ }
+ else if (transferOps == 0 &&
+ srcType == GL_UNSIGNED_INT &&
+ dstType == GL_UNSIGNED_INT &&
+ !srcPacking->SwapBytes) {
+ MEMCPY(dest, source, n * sizeof(GLuint));
+ }
+ else {
+ /*
+ * general solution
+ */
+ GLuint indexes[MAX_WIDTH];
+ assert(n <= MAX_WIDTH);
+
+ extract_uint_indexes(n, indexes, GL_COLOR_INDEX, srcType, source,
+ srcPacking);
+
+ if (transferOps) {
+ if (transferOps & IMAGE_SHIFT_OFFSET_BIT) {
+ /* shift and offset indexes */
+ _mesa_shift_and_offset_ci(ctx, n, indexes);
+ }
+
+ if (ctx->Pixel.MapStencilFlag) {
+ /* Apply stencil lookup table */
+ GLuint mask = ctx->Pixel.MapStoSsize - 1;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ indexes[i] = ctx->Pixel.MapStoS[ indexes[i] & mask ];
+ }
+ }
+ }
+
+ /* convert to dest type */
+ switch (dstType) {
+ case GL_UNSIGNED_BYTE:
+ {
+ GLubyte *dst = (GLubyte *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = (GLubyte) (indexes[i] & 0xff);
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ {
+ GLuint *dst = (GLuint *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = (GLushort) (indexes[i] & 0xffff);
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ MEMCPY(dest, indexes, n * sizeof(GLuint));
+ break;
+ default:
+ _mesa_problem(ctx, "bad dstType in _mesa_unpack_stencil_span");
+ }
+ }
+}
+
+
+void
+_mesa_pack_stencil_span( const GLcontext *ctx, GLuint n,
+ GLenum dstType, GLvoid *dest, const GLstencil *source,
+ const struct gl_pixelstore_attrib *dstPacking )
+{
+ GLstencil stencil[MAX_WIDTH];
+
+ ASSERT(n <= MAX_WIDTH);
+
+ if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset ||
+ ctx->Pixel.MapStencilFlag) {
+ /* make a copy of input */
+ MEMCPY(stencil, source, n * sizeof(GLstencil));
+ if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) {
+ _mesa_shift_and_offset_stencil( ctx, n, stencil );
+ }
+ if (ctx->Pixel.MapStencilFlag) {
+ _mesa_map_stencil( ctx, n, stencil );
+ }
+ source = stencil;
+ }
+
+ switch (dstType) {
+ case GL_UNSIGNED_BYTE:
+ if (sizeof(GLstencil) == 8) {
+ MEMCPY( dest, source, n );
+ }
+ else {
+ GLubyte *dst = (GLubyte *) dest;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ dst[i] = (GLubyte) source[i];
+ }
+ }
+ break;
+ case GL_BYTE:
+ if (sizeof(GLstencil) == 8) {
+ MEMCPY( dest, source, n );
+ }
+ else {
+ GLbyte *dst = (GLbyte *) dest;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ dst[i] = (GLbyte) source[i];
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ {
+ GLushort *dst = (GLushort *) dest;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ dst[i] = (GLushort) source[i];
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap2( (GLushort *) dst, n );
+ }
+ }
+ break;
+ case GL_SHORT:
+ {
+ GLshort *dst = (GLshort *) dest;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ dst[i] = (GLshort) source[i];
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap2( (GLushort *) dst, n );
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ {
+ GLuint *dst = (GLuint *) dest;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ dst[i] = (GLuint) source[i];
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n );
+ }
+ }
+ break;
+ case GL_INT:
+ {
+ GLint *dst = (GLint *) dest;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ *dst++ = (GLint) source[i];
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n );
+ }
+ }
+ break;
+ case GL_FLOAT:
+ {
+ GLfloat *dst = (GLfloat *) dest;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ dst[i] = (GLfloat) source[i];
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n );
+ }
+ }
+ break;
+ case GL_HALF_FLOAT_ARB:
+ {
+ GLhalfARB *dst = (GLhalfARB *) dest;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ dst[i] = _mesa_float_to_half( (float) source[i] );
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap2( (GLushort *) dst, n );
+ }
+ }
+ break;
+ case GL_BITMAP:
+ if (dstPacking->LsbFirst) {
+ GLubyte *dst = (GLubyte *) dest;
+ GLint shift = 0;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ if (shift == 0)
+ *dst = 0;
+ *dst |= ((source[i] != 0) << shift);
+ shift++;
+ if (shift == 8) {
+ shift = 0;
+ dst++;
+ }
+ }
+ }
+ else {
+ GLubyte *dst = (GLubyte *) dest;
+ GLint shift = 7;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ if (shift == 7)
+ *dst = 0;
+ *dst |= ((source[i] != 0) << shift);
+ shift--;
+ if (shift < 0) {
+ shift = 7;
+ dst++;
+ }
+ }
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "bad type in _mesa_pack_index_span");
+ }
+}
+
+
+void
+_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLfloat *dest,
+ GLenum srcType, const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking )
+{
+ (void) srcPacking;
+
+ switch (srcType) {
+ case GL_BYTE:
+ {
+ GLuint i;
+ const GLubyte *src = (const GLubyte *) source;
+ for (i = 0; i < n; i++) {
+ dest[i] = BYTE_TO_FLOAT(src[i]);
+ }
+ }
+ break;
+ case GL_UNSIGNED_BYTE:
+ {
+ GLuint i;
+ const GLubyte *src = (const GLubyte *) source;
+ for (i = 0; i < n; i++) {
+ dest[i] = UBYTE_TO_FLOAT(src[i]);
+ }
+ }
+ break;
+ case GL_SHORT:
+ {
+ GLuint i;
+ const GLshort *src = (const GLshort *) source;
+ for (i = 0; i < n; i++) {
+ dest[i] = SHORT_TO_FLOAT(src[i]);
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ {
+ GLuint i;
+ const GLushort *src = (const GLushort *) source;
+ for (i = 0; i < n; i++) {
+ dest[i] = USHORT_TO_FLOAT(src[i]);
+ }
+ }
+ break;
+ case GL_INT:
+ {
+ GLuint i;
+ const GLint *src = (const GLint *) source;
+ for (i = 0; i < n; i++) {
+ dest[i] = INT_TO_FLOAT(src[i]);
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ {
+ GLuint i;
+ const GLuint *src = (const GLuint *) source;
+ for (i = 0; i < n; i++) {
+ dest[i] = UINT_TO_FLOAT(src[i]);
+ }
+ }
+ break;
+ case GL_FLOAT:
+ MEMCPY(dest, source, n * sizeof(GLfloat));
+ break;
+ case GL_HALF_FLOAT_ARB:
+ {
+ GLuint i;
+ const GLhalfARB *src = (const GLhalfARB *) source;
+ for (i = 0; i < n; i++) {
+ dest[i] = _mesa_half_to_float(src[i]);
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL, "bad type in _mesa_unpack_depth_span()");
+ return;
+ }
+
+
+ /* apply depth scale and bias and clamp to [0,1] */
+ if (ctx->Pixel.DepthScale != 1.0 || ctx->Pixel.DepthBias != 0.0) {
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLfloat d = dest[i] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias;
+ dest[i] = CLAMP(d, 0.0F, 1.0F);
+ }
+ }
+}
+
+
+/*
+ * Pack an array of depth values. The values are floats in [0,1].
+ */
+void
+_mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLvoid *dest,
+ GLenum dstType, const GLfloat *depthSpan,
+ const struct gl_pixelstore_attrib *dstPacking )
+{
+ GLfloat depthCopy[MAX_WIDTH];
+ const GLboolean bias_or_scale = ctx->Pixel.DepthBias != 0.0 ||
+ ctx->Pixel.DepthScale != 1.0;
+
+ ASSERT(n <= MAX_WIDTH);
+
+ if (bias_or_scale) {
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLfloat d;
+ d = depthSpan[i] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias;
+ depthCopy[i] = CLAMP(d, 0.0F, 1.0F);
+ }
+ depthSpan = depthCopy;
+ }
+
+ switch (dstType) {
+ case GL_UNSIGNED_BYTE:
+ {
+ GLubyte *dst = (GLubyte *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = FLOAT_TO_UBYTE( depthSpan[i] );
+ }
+ }
+ break;
+ case GL_BYTE:
+ {
+ GLbyte *dst = (GLbyte *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = FLOAT_TO_BYTE( depthSpan[i] );
+ }
+ }
+ break;
+ case GL_UNSIGNED_SHORT:
+ {
+ GLushort *dst = (GLushort *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ CLAMPED_FLOAT_TO_USHORT(dst[i], depthSpan[i]);
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap2( (GLushort *) dst, n );
+ }
+ }
+ break;
+ case GL_SHORT:
+ {
+ GLshort *dst = (GLshort *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = FLOAT_TO_SHORT( depthSpan[i] );
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap2( (GLushort *) dst, n );
+ }
+ }
+ break;
+ case GL_UNSIGNED_INT:
+ {
+ GLuint *dst = (GLuint *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = FLOAT_TO_UINT( depthSpan[i] );
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n );
+ }
+ }
+ break;
+ case GL_INT:
+ {
+ GLint *dst = (GLint *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = FLOAT_TO_INT( depthSpan[i] );
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n );
+ }
+ }
+ break;
+ case GL_FLOAT:
+ {
+ GLfloat *dst = (GLfloat *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = depthSpan[i];
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap4( (GLuint *) dst, n );
+ }
+ }
+ break;
+ case GL_HALF_FLOAT_ARB:
+ {
+ GLhalfARB *dst = (GLhalfARB *) dest;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ dst[i] = _mesa_float_to_half(depthSpan[i]);
+ }
+ if (dstPacking->SwapBytes) {
+ _mesa_swap2( (GLushort *) dst, n );
+ }
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "bad type in _mesa_pack_depth_span");
+ }
+}
+
+
+/**
+ * Unpack image data. Apply byte swapping, byte flipping (bitmap).
+ * Return all image data in a contiguous block. This is used when we
+ * compile glDrawPixels, glTexImage, etc into a display list. We
+ * need a copy of the data in a standard format.
+ */
+void *
+_mesa_unpack_image( GLuint dimensions,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *unpack )
+{
+ GLint bytesPerRow, compsPerRow;
+ GLboolean flipBytes, swap2, swap4;
+
+ if (!pixels)
+ return NULL; /* not necessarily an error */
+
+ if (width <= 0 || height <= 0 || depth <= 0)
+ return NULL; /* generate error later */
+
+ if (format == GL_BITMAP) {
+ bytesPerRow = (width + 7) >> 3;
+ flipBytes = !unpack->LsbFirst;
+ swap2 = swap4 = GL_FALSE;
+ compsPerRow = 0;
+ }
+ else {
+ 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 */
+ bytesPerRow = bytesPerPixel * width;
+ bytesPerComp = bytesPerPixel / components;
+ flipBytes = GL_FALSE;
+ swap2 = (bytesPerComp == 2) && unpack->SwapBytes;
+ swap4 = (bytesPerComp == 4) && unpack->SwapBytes;
+ compsPerRow = components * width;
+ assert(compsPerRow >= width);
+ }
+
+ {
+ GLubyte *destBuffer = (GLubyte *) MALLOC(bytesPerRow * height * depth);
+ GLubyte *dst;
+ GLint img, row;
+ if (!destBuffer)
+ return NULL; /* generate GL_OUT_OF_MEMORY later */
+
+ dst = destBuffer;
+ for (img = 0; img < depth; img++) {
+ for (row = 0; row < height; row++) {
+ const GLvoid *src = _mesa_image_address(dimensions, unpack, pixels,
+ width, height, format, type, img, row, 0);
+ MEMCPY(dst, src, bytesPerRow);
+ /* byte flipping/swapping */
+ if (flipBytes) {
+ flip_bytes((GLubyte *) dst, bytesPerRow);
+ }
+ else if (swap2) {
+ _mesa_swap2((GLushort*) dst, compsPerRow);
+ }
+ else if (swap4) {
+ _mesa_swap4((GLuint*) dst, compsPerRow);
+ }
+ dst += bytesPerRow;
+ }
+ }
+ return destBuffer;
+ }
+}
+
+#endif
+
+
+/**
+ * Perform clipping for glDrawPixels. The image's window position
+ * and size, and the unpack skipPixels and skipRows are adjusted so
+ * that the image region is entirely within the window and scissor bounds.
+ * NOTE: this will only work when glPixelZoom is (1, 1).
+ *
+ * \return GL_TRUE if image is ready for drawing or
+ * GL_FALSE if image was completely clipped away (draw nothing)
+ */
+GLboolean
+_mesa_clip_drawpixels(const GLcontext *ctx,
+ GLint *destX, GLint *destY,
+ GLsizei *width, GLsizei *height,
+ GLint *skipPixels, GLint *skipRows)
+{
+ const GLframebuffer *buffer = ctx->DrawBuffer;
+
+ ASSERT(ctx->Pixel.ZoomX == 1.0F && ctx->Pixel.ZoomY == 1.0F);
+
+ /* left clipping */
+ if (*destX < buffer->_Xmin) {
+ *skipPixels += (buffer->_Xmin - *destX);
+ *width -= (buffer->_Xmin - *destX);
+ *destX = buffer->_Xmin;
+ }
+ /* right clipping */
+ if (*destX + *width > buffer->_Xmax)
+ *width -= (*destX + *width - buffer->_Xmax);
+
+ if (*width <= 0)
+ return GL_FALSE;
+
+ /* bottom clipping */
+ if (*destY < buffer->_Ymin) {
+ *skipRows += (buffer->_Ymin - *destY);
+ *height -= (buffer->_Ymin - *destY);
+ *destY = buffer->_Ymin;
+ }
+ /* top clipping */
+ if (*destY + *height > buffer->_Ymax)
+ *height -= (*destY + *height - buffer->_Ymax);
+
+ if (*height <= 0)
+ return GL_TRUE;
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Perform clipping for glReadPixels. The image's window position
+ * and size, and the pack skipPixels and skipRows are adjusted so
+ * that the image region is entirely within the window bounds.
+ * Note: this is different from _mesa_clip_drawpixels() in that the
+ * scissor box is ignored, and we use the bounds of the current "read"
+ * surface;
+ *
+ * \return GL_TRUE if image is ready for drawing or
+ * GL_FALSE if image was completely clipped away (draw nothing)
+ */
+GLboolean
+_mesa_clip_readpixels(const GLcontext *ctx,
+ GLint *srcX, GLint *srcY,
+ GLsizei *width, GLsizei *height,
+ GLint *skipPixels, GLint *skipRows)
+{
+ const GLframebuffer *buffer = ctx->ReadBuffer;
+
+ /* left clipping */
+ if (*srcX < 0) {
+ *skipPixels += (0 - *srcX);
+ *width -= (0 - *srcX);
+ *srcX = 0;
+ }
+ /* right clipping */
+ if (*srcX + *width > (GLsizei) buffer->Width)
+ *width -= (*srcX + *width - buffer->Width);
+
+ if (*width <= 0)
+ return GL_FALSE;
+
+ /* bottom clipping */
+ if (*srcY < 0) {
+ *skipRows += (0 - *srcY);
+ *height -= (0 - *srcY);
+ *srcY = 0;
+ }
+ /* top clipping */
+ if (*srcY + *height > (GLsizei) buffer->Height)
+ *height -= (*srcY + *height - buffer->Height);
+
+ if (*height <= 0)
+ return GL_TRUE;
+
+ return GL_TRUE;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/main/image.h b/nx-X11/extras/Mesa/src/mesa/main/image.h
new file mode 100644
index 000000000..6b76fd8af
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/image.h
@@ -0,0 +1,217 @@
+/**
+ * \file image.h
+ * Image handling.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef IMAGE_H
+#define IMAGE_H
+
+
+#include "mtypes.h"
+
+
+extern void
+_mesa_swap2( GLushort *p, GLuint n );
+
+extern void
+_mesa_swap4( GLuint *p, GLuint n );
+
+extern GLint
+_mesa_sizeof_type( GLenum type );
+
+extern GLint
+_mesa_sizeof_packed_type( GLenum type );
+
+extern GLint
+_mesa_components_in_format( GLenum format );
+
+extern GLint
+_mesa_bytes_per_pixel( GLenum format, GLenum type );
+
+extern GLboolean
+_mesa_is_legal_format_and_type( GLcontext *ctx, GLenum format, GLenum type );
+
+
+extern GLvoid *
+_mesa_image_address( GLuint dimensions,
+ const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLint img, GLint row, GLint column );
+
+extern GLvoid *
+_mesa_image_address1d( const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width,
+ GLenum format, GLenum type,
+ GLint column );
+
+extern GLvoid *
+_mesa_image_address2d( const struct gl_pixelstore_attrib *packing,
+ const GLvoid *image,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLint row, GLint column );
+
+extern GLvoid *
+_mesa_image_address3d( 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 GLint
+_mesa_image_image_stride( const struct gl_pixelstore_attrib *packing,
+ GLint width, GLint height,
+ GLenum format, GLenum type );
+
+extern void
+_mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32],
+ const struct gl_pixelstore_attrib *unpacking );
+
+
+extern void
+_mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest,
+ const struct gl_pixelstore_attrib *packing );
+
+
+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 );
+
+
+extern void
+_mesa_apply_rgba_transfer_ops(GLcontext *ctx, GLuint transferOps,
+ GLuint n, GLfloat rgba[][4]);
+
+extern void
+_mesa_pack_rgba_span_float( GLcontext *ctx,
+ GLuint n, CONST GLfloat rgba[][4],
+ GLenum dstFormat, GLenum dstType, GLvoid *dstAddr,
+ const struct gl_pixelstore_attrib *dstPacking,
+ GLuint transferOps );
+
+
+extern void
+_mesa_pack_rgba_span_chan( GLcontext *ctx,
+ GLuint n, CONST GLchan rgba[][4],
+ GLenum dstFormat, GLenum dstType, GLvoid *dstAddr,
+ const struct gl_pixelstore_attrib *dstPacking,
+ GLuint transferOps );
+
+
+extern void
+_mesa_unpack_color_span_chan( GLcontext *ctx,
+ GLuint n, GLenum dstFormat, GLchan dest[],
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking,
+ GLuint transferOps );
+
+
+extern void
+_mesa_unpack_color_span_float( GLcontext *ctx,
+ GLuint n, GLenum dstFormat, GLfloat dest[],
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking,
+ GLuint transferOps );
+
+
+extern void
+_mesa_unpack_index_span( const GLcontext *ctx, GLuint n,
+ GLenum dstType, GLvoid *dest,
+ GLenum srcType, const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking,
+ GLuint transferOps );
+
+
+extern void
+_mesa_pack_index_span( const GLcontext *ctx, GLuint n,
+ GLenum dstType, GLvoid *dest, const GLuint *source,
+ const struct gl_pixelstore_attrib *dstPacking,
+ GLuint transferOps );
+
+
+extern void
+_mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n,
+ GLenum dstType, GLvoid *dest,
+ GLenum srcType, const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking,
+ GLuint transferOps );
+
+extern void
+_mesa_pack_stencil_span( const GLcontext *ctx, GLuint n,
+ GLenum dstType, GLvoid *dest, const GLstencil *source,
+ const struct gl_pixelstore_attrib *dstPacking );
+
+
+extern void
+_mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLfloat *dest,
+ GLenum srcType, const GLvoid *source,
+ const struct gl_pixelstore_attrib *srcPacking );
+
+extern void
+_mesa_pack_depth_span( const GLcontext *ctx, GLuint n, GLvoid *dest,
+ GLenum dstType, const GLfloat *depthSpan,
+ const struct gl_pixelstore_attrib *dstPacking );
+
+
+extern void *
+_mesa_unpack_image( GLuint dimensions,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *unpack );
+
+
+extern GLboolean
+_mesa_clip_drawpixels(const GLcontext *ctx,
+ GLint *destX, GLint *destY,
+ GLsizei *width, GLsizei *height,
+ GLint *skipPixels, GLint *skipRows);
+
+
+extern GLboolean
+_mesa_clip_readpixels(const GLcontext *ctx,
+ GLint *destX, GLint *destY,
+ GLsizei *width, GLsizei *height,
+ GLint *skipPixels, GLint *skipRows);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/imports.c b/nx-X11/extras/Mesa/src/mesa/main/imports.c
new file mode 100644
index 000000000..9cdf4e347
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/imports.c
@@ -0,0 +1,1203 @@
+/**
+ * \file imports.c
+ * Standard C library function wrappers.
+ *
+ * Imports are services which the device driver or window system or
+ * operating system provides to the core renderer. The core renderer (Mesa)
+ * will call these functions in order to do memory allocation, simple I/O,
+ * etc.
+ *
+ * Some drivers will want to override/replace this file with something
+ * specialized, but that'll be rare.
+ *
+ * Eventually, I want to move roll the glheader.h file into this.
+ *
+ * The OpenGL SI's __GLimports structure allows per-context specification of
+ * replacements for the standard C lib functions. In practice that's probably
+ * never needed; compile-time replacements are far more likely.
+ *
+ * The _mesa_*() functions defined here don't in general take a context
+ * parameter. I guess we can change that someday, if need be.
+ * So for now, the __GLimports stuff really isn't used.
+ *
+ * \todo Functions still needed:
+ * - scanf
+ * - qsort
+ * - bsearch
+ * - rand and RAND_MAX
+ *
+ * \note When compiled into a XFree86 module these functions wrap around
+ * XFree86 own wrappers.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4.1
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+
+#include "imports.h"
+#include "context.h"
+#include "version.h"
+
+
+#define MAXSTRING 4000 /* for vsnprintf() */
+
+#ifdef WIN32
+#define vsnprintf _vsnprintf
+#elif defined(__IBMC__) || defined(__IBMCPP__) || ( defined(__VMS) && __CRTL_VER < 70312000 )
+extern int vsnprintf(char *str, size_t count, const char *fmt, va_list arg);
+#ifdef __VMS
+#include "vsnprintf.c"
+#endif
+#endif
+
+
+/**********************************************************************/
+/** \name Memory */
+/*@{*/
+
+/** Wrapper around either malloc() or xf86malloc() */
+void *
+_mesa_malloc(size_t bytes)
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86malloc(bytes);
+#else
+ return malloc(bytes);
+#endif
+}
+
+/** Wrapper around either calloc() or xf86calloc() */
+void *
+_mesa_calloc(size_t bytes)
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86calloc(1, bytes);
+#else
+ return calloc(1, bytes);
+#endif
+}
+
+/** Wrapper around either free() or xf86free() */
+void
+_mesa_free(void *ptr)
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ xf86free(ptr);
+#else
+ free(ptr);
+#endif
+}
+
+/**
+ * Allocate aligned memory.
+ *
+ * \param bytes number of bytes to allocate.
+ * \param alignment alignment (must be greater than zero).
+ *
+ * Allocates extra memory to accommodate rounding up the address for
+ * alignment and to record the real malloc address.
+ *
+ * \sa _mesa_align_free().
+ */
+void *
+_mesa_align_malloc(size_t bytes, unsigned long alignment)
+{
+ uintptr_t ptr, buf;
+
+ ASSERT( alignment > 0 );
+
+ ptr = (uintptr_t) _mesa_malloc(bytes + alignment + sizeof(void *));
+ if (!ptr)
+ return NULL;
+
+ buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1);
+ *(uintptr_t *)(buf - sizeof(void *)) = ptr;
+
+#ifdef DEBUG
+ /* mark the non-aligned area */
+ while ( ptr < buf - sizeof(void *) ) {
+ *(unsigned long *)ptr = 0xcdcdcdcd;
+ ptr += sizeof(unsigned long);
+ }
+#endif
+
+ return (void *) buf;
+}
+
+/**
+ * Same as _mesa_align_malloc(), but using _mesa_calloc() instead of
+ * _mesa_malloc()
+ */
+void *
+_mesa_align_calloc(size_t bytes, unsigned long alignment)
+{
+ uintptr_t ptr, buf;
+
+ ASSERT( alignment > 0 );
+
+ ptr = (uintptr_t) _mesa_calloc(bytes + alignment + sizeof(void *));
+ if (!ptr)
+ return NULL;
+
+ buf = (ptr + alignment + sizeof(void *)) & ~(uintptr_t)(alignment - 1);
+ *(uintptr_t *)(buf - sizeof(void *)) = ptr;
+
+#ifdef DEBUG
+ /* mark the non-aligned area */
+ while ( ptr < buf - sizeof(void *) ) {
+ *(unsigned long *)ptr = 0xcdcdcdcd;
+ ptr += sizeof(unsigned long);
+ }
+#endif
+
+ return (void *)buf;
+}
+
+/**
+ * Free memory which was allocated with either _mesa_align_malloc()
+ * or _mesa_align_calloc().
+ * \param ptr pointer to the memory to be freed.
+ * The actual address to free is stored in the word immediately before the
+ * address the client sees.
+ */
+void
+_mesa_align_free(void *ptr)
+{
+#if 0
+ _mesa_free( (void *)(*(unsigned long *)((unsigned long)ptr - sizeof(void *))) );
+#else
+ void **cubbyHole = (void **) ((char *) ptr - sizeof(void *));
+ void *realAddr = *cubbyHole;
+ _mesa_free(realAddr);
+#endif
+}
+
+/** Reallocate memory */
+void *
+_mesa_realloc(void *oldBuffer, size_t oldSize, size_t newSize)
+{
+ const size_t copySize = (oldSize < newSize) ? oldSize : newSize;
+ void *newBuffer = _mesa_malloc(newSize);
+ if (newBuffer && oldBuffer && copySize > 0)
+ _mesa_memcpy(newBuffer, oldBuffer, copySize);
+ if (oldBuffer)
+ _mesa_free(oldBuffer);
+ return newBuffer;
+}
+
+/** memcpy wrapper */
+void *
+_mesa_memcpy(void *dest, const void *src, size_t n)
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86memcpy(dest, src, n);
+#elif defined(SUNOS4)
+ return memcpy((char *) dest, (char *) src, (int) n);
+#else
+ return memcpy(dest, src, n);
+#endif
+}
+
+/** Wrapper around either memset() or xf86memset() */
+void
+_mesa_memset( void *dst, int val, size_t n )
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ xf86memset( dst, val, n );
+#elif defined(SUNOS4)
+ memset( (char *) dst, (int) val, (int) n );
+#else
+ memset(dst, val, n);
+#endif
+}
+
+/**
+ * Fill memory with a constant 16bit word.
+ * \param dst destination pointer.
+ * \param val value.
+ * \param n number of words.
+ */
+void
+_mesa_memset16( unsigned short *dst, unsigned short val, size_t n )
+{
+ while (n-- > 0)
+ *dst++ = val;
+}
+
+/** Wrapper around either memcpy() or xf86memcpy() or bzero() */
+void
+_mesa_bzero( void *dst, size_t n )
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ xf86memset( dst, 0, n );
+#elif defined(__FreeBSD__)
+ bzero( dst, n );
+#else
+ memset( dst, 0, n );
+#endif
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Math */
+/*@{*/
+
+/** Wrapper around either sin() or xf86sin() */
+double
+_mesa_sin(double a)
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86sin(a);
+#else
+ return sin(a);
+#endif
+}
+
+/** Wrapper around either cos() or xf86cos() */
+double
+_mesa_cos(double a)
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86cos(a);
+#else
+ return cos(a);
+#endif
+}
+
+/** Wrapper around either sqrt() or xf86sqrt() */
+double
+_mesa_sqrtd(double x)
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86sqrt(x);
+#else
+ return sqrt(x);
+#endif
+}
+
+
+/*
+ * A High Speed, Low Precision Square Root
+ * by Paul Lalonde and Robert Dawson
+ * from "Graphics Gems", Academic Press, 1990
+ *
+ * SPARC implementation of a fast square root by table
+ * lookup.
+ * SPARC floating point format is as follows:
+ *
+ * BIT 31 30 23 22 0
+ * sign exponent mantissa
+ */
+static short sqrttab[0x100]; /* declare table of square roots */
+
+static void init_sqrt_table(void)
+{
+#if defined(USE_IEEE) && !defined(DEBUG)
+ unsigned short i;
+ fi_type fi; /* to access the bits of a float in C quickly */
+ /* we use a union defined in glheader.h */
+
+ for(i=0; i<= 0x7f; i++) {
+ fi.i = 0;
+
+ /*
+ * Build a float with the bit pattern i as mantissa
+ * and an exponent of 0, stored as 127
+ */
+
+ fi.i = (i << 16) | (127 << 23);
+ fi.f = _mesa_sqrtd(fi.f);
+
+ /*
+ * Take the square root then strip the first 7 bits of
+ * the mantissa into the table
+ */
+
+ sqrttab[i] = (fi.i & 0x7fffff) >> 16;
+
+ /*
+ * Repeat the process, this time with an exponent of
+ * 1, stored as 128
+ */
+
+ fi.i = 0;
+ fi.i = (i << 16) | (128 << 23);
+ fi.f = sqrt(fi.f);
+ sqrttab[i+0x80] = (fi.i & 0x7fffff) >> 16;
+ }
+#else
+ (void) sqrttab; /* silence compiler warnings */
+#endif /*HAVE_FAST_MATH*/
+}
+
+
+/**
+ * Single precision square root.
+ */
+float
+_mesa_sqrtf( float x )
+{
+#if defined(USE_IEEE) && !defined(DEBUG)
+ fi_type num;
+ /* to access the bits of a float in C
+ * we use a union from glheader.h */
+
+ short e; /* the exponent */
+ if (x == 0.0F) return 0.0F; /* check for square root of 0 */
+ num.f = x;
+ e = (num.i >> 23) - 127; /* get the exponent - on a SPARC the */
+ /* exponent is stored with 127 added */
+ num.i &= 0x7fffff; /* leave only the mantissa */
+ if (e & 0x01) num.i |= 0x800000;
+ /* the exponent is odd so we have to */
+ /* look it up in the second half of */
+ /* the lookup table, so we set the */
+ /* high bit */
+ e >>= 1; /* divide the exponent by two */
+ /* note that in C the shift */
+ /* operators are sign preserving */
+ /* for signed operands */
+ /* Do the table lookup, based on the quaternary mantissa,
+ * then reconstruct the result back into a float
+ */
+ num.i = ((sqrttab[num.i >> 16]) << 16) | ((e + 127) << 23);
+
+ return num.f;
+#else
+ return (float) _mesa_sqrtd((double) x);
+#endif
+}
+
+
+/**
+ inv_sqrt - A single precision 1/sqrt routine for IEEE format floats.
+ written by Josh Vanderhoof, based on newsgroup posts by James Van Buskirk
+ and Vesa Karvonen.
+*/
+float
+_mesa_inv_sqrtf(float n)
+{
+#if defined(USE_IEEE) && !defined(DEBUG)
+ float r0, x0, y0;
+ float r1, x1, y1;
+ float r2, x2, y2;
+#if 0 /* not used, see below -BP */
+ float r3, x3, y3;
+#endif
+ union { float f; unsigned int i; } u;
+ unsigned int magic;
+
+ /*
+ Exponent part of the magic number -
+
+ We want to:
+ 1. subtract the bias from the exponent,
+ 2. negate it
+ 3. divide by two (rounding towards -inf)
+ 4. add the bias back
+
+ Which is the same as subtracting the exponent from 381 and dividing
+ by 2.
+
+ floor(-(x - 127) / 2) + 127 = floor((381 - x) / 2)
+ */
+
+ magic = 381 << 23;
+
+ /*
+ Significand part of magic number -
+
+ With the current magic number, "(magic - u.i) >> 1" will give you:
+
+ for 1 <= u.f <= 2: 1.25 - u.f / 4
+ for 2 <= u.f <= 4: 1.00 - u.f / 8
+
+ This isn't a bad approximation of 1/sqrt. The maximum difference from
+ 1/sqrt will be around .06. After three Newton-Raphson iterations, the
+ maximum difference is less than 4.5e-8. (Which is actually close
+ enough to make the following bias academic...)
+
+ To get a better approximation you can add a bias to the magic
+ number. For example, if you subtract 1/2 of the maximum difference in
+ the first approximation (.03), you will get the following function:
+
+ for 1 <= u.f <= 2: 1.22 - u.f / 4
+ for 2 <= u.f <= 3.76: 0.97 - u.f / 8
+ for 3.76 <= u.f <= 4: 0.72 - u.f / 16
+ (The 3.76 to 4 range is where the result is < .5.)
+
+ This is the closest possible initial approximation, but with a maximum
+ error of 8e-11 after three NR iterations, it is still not perfect. If
+ you subtract 0.0332281 instead of .03, the maximum error will be
+ 2.5e-11 after three NR iterations, which should be about as close as
+ is possible.
+
+ for 1 <= u.f <= 2: 1.2167719 - u.f / 4
+ for 2 <= u.f <= 3.73: 0.9667719 - u.f / 8
+ for 3.73 <= u.f <= 4: 0.7167719 - u.f / 16
+
+ */
+
+ magic -= (int)(0.0332281 * (1 << 25));
+
+ u.f = n;
+ u.i = (magic - u.i) >> 1;
+
+ /*
+ Instead of Newton-Raphson, we use Goldschmidt's algorithm, which
+ allows more parallelism. From what I understand, the parallelism
+ comes at the cost of less precision, because it lets error
+ accumulate across iterations.
+ */
+ x0 = 1.0f;
+ y0 = 0.5f * n;
+ r0 = u.f;
+
+ x1 = x0 * r0;
+ y1 = y0 * r0 * r0;
+ r1 = 1.5f - y1;
+
+ x2 = x1 * r1;
+ y2 = y1 * r1 * r1;
+ r2 = 1.5f - y2;
+
+#if 1
+ return x2 * r2; /* we can stop here, and be conformant -BP */
+#else
+ x3 = x2 * r2;
+ y3 = y2 * r2 * r2;
+ r3 = 1.5f - y3;
+
+ return x3 * r3;
+#endif
+#elif defined(XFree86LOADER) && defined(IN_MODULE)
+ return 1.0F / xf86sqrt(n);
+#else
+ return (float) (1.0 / sqrt(n));
+#endif
+}
+
+
+/**
+ * Wrapper around either pow() or xf86pow().
+ */
+double
+_mesa_pow(double x, double y)
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86pow(x, y);
+#else
+ return pow(x, y);
+#endif
+}
+
+
+/**
+ * Return number of bits set in given GLuint.
+ */
+unsigned int
+_mesa_bitcount(unsigned int n)
+{
+ unsigned int bits;
+ for (bits = 0; n > 0; n = n >> 1) {
+ bits += (n & 1);
+ }
+ return bits;
+}
+
+
+/**
+ * Convert a 4-byte float to a 2-byte half float.
+ * Based on code from:
+ * http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008786.html
+ */
+GLhalfARB
+_mesa_float_to_half(float val)
+{
+ const int flt = *((int *) (void *) &val);
+ const int flt_m = flt & 0x7fffff;
+ const int flt_e = (flt >> 23) & 0xff;
+ const int flt_s = (flt >> 31) & 0x1;
+ int s, e, m = 0;
+ GLhalfARB result;
+
+ /* sign bit */
+ s = flt_s;
+
+ /* handle special cases */
+ if ((flt_e == 0) && (flt_m == 0)) {
+ /* zero */
+ /* m = 0; - already set */
+ e = 0;
+ }
+ else if ((flt_e == 0) && (flt_m != 0)) {
+ /* denorm -- denorm float maps to 0 half */
+ /* m = 0; - already set */
+ e = 0;
+ }
+ else if ((flt_e == 0xff) && (flt_m == 0)) {
+ /* infinity */
+ /* m = 0; - already set */
+ e = 31;
+ }
+ else if ((flt_e == 0xff) && (flt_m != 0)) {
+ /* NaN */
+ m = 1;
+ e = 31;
+ }
+ else {
+ /* regular number */
+ const int new_exp = flt_e - 127;
+ if (new_exp < -24) {
+ /* this maps to 0 */
+ /* m = 0; - already set */
+ e = 0;
+ }
+ else if (new_exp < -14) {
+ /* this maps to a denorm */
+ unsigned int exp_val = (unsigned int) (-14 - new_exp); /* 2^-exp_val*/
+ e = 0;
+ switch (exp_val) {
+ case 0:
+ _mesa_warning(NULL,
+ "float_to_half: logical error in denorm creation!\n");
+ /* m = 0; - already set */
+ break;
+ case 1: m = 512 + (flt_m >> 14); break;
+ case 2: m = 256 + (flt_m >> 15); break;
+ case 3: m = 128 + (flt_m >> 16); break;
+ case 4: m = 64 + (flt_m >> 17); break;
+ case 5: m = 32 + (flt_m >> 18); break;
+ case 6: m = 16 + (flt_m >> 19); break;
+ case 7: m = 8 + (flt_m >> 20); break;
+ case 8: m = 4 + (flt_m >> 21); break;
+ case 9: m = 2 + (flt_m >> 22); break;
+ case 10: m = 1; break;
+ }
+ }
+ else if (new_exp > 15) {
+ /* map this value to infinity */
+ /* m = 0; - already set */
+ e = 31;
+ }
+ else {
+ /* regular */
+ e = new_exp + 15;
+ m = flt_m >> 13;
+ }
+ }
+
+ result = (s << 15) | (e << 10) | m;
+ return result;
+}
+
+
+/**
+ * Convert a 2-byte half float to a 4-byte float.
+ * Based on code from:
+ * http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/008786.html
+ */
+float
+_mesa_half_to_float(GLhalfARB val)
+{
+ /* XXX could also use a 64K-entry lookup table */
+ const int m = val & 0x3ff;
+ const int e = (val >> 10) & 0x1f;
+ const int s = (val >> 15) & 0x1;
+ int flt_m, flt_e, flt_s, flt;
+ float result;
+
+ /* sign bit */
+ flt_s = s;
+
+ /* handle special cases */
+ if ((e == 0) && (m == 0)) {
+ /* zero */
+ flt_m = 0;
+ flt_e = 0;
+ }
+ else if ((e == 0) && (m != 0)) {
+ /* denorm -- denorm half will fit in non-denorm single */
+ const float half_denorm = 1.0f / 16384.0f; /* 2^-14 */
+ float mantissa = ((float) (m)) / 1024.0f;
+ float sign = s ? -1.0f : 1.0f;
+ return sign * mantissa * half_denorm;
+ }
+ else if ((e == 31) && (m == 0)) {
+ /* infinity */
+ flt_e = 0xff;
+ flt_m = 0;
+ }
+ else if ((e == 31) && (m != 0)) {
+ /* NaN */
+ flt_e = 0xff;
+ flt_m = 1;
+ }
+ else {
+ /* regular */
+ flt_e = e + 112;
+ flt_m = m << 13;
+ }
+
+ flt = (flt_s << 31) | (flt_e << 23) | flt_m;
+ result = *((float *) (void *) &flt);
+ return result;
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Environment vars */
+/*@{*/
+
+/**
+ * Wrapper for getenv().
+ */
+char *
+_mesa_getenv( const char *var )
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86getenv(var);
+#elif defined(_XBOX)
+ return NULL;
+#else
+ return getenv(var);
+#endif
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name String */
+/*@{*/
+
+/** Wrapper around either strstr() or xf86strstr() */
+char *
+_mesa_strstr( const char *haystack, const char *needle )
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86strstr(haystack, needle);
+#else
+ return strstr(haystack, needle);
+#endif
+}
+
+/** Wrapper around either strncat() or xf86strncat() */
+char *
+_mesa_strncat( char *dest, const char *src, size_t n )
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86strncat(dest, src, n);
+#else
+ return strncat(dest, src, n);
+#endif
+}
+
+/** Wrapper around either strcpy() or xf86strcpy() */
+char *
+_mesa_strcpy( char *dest, const char *src )
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86strcpy(dest, src);
+#else
+ return strcpy(dest, src);
+#endif
+}
+
+/** Wrapper around either strncpy() or xf86strncpy() */
+char *
+_mesa_strncpy( char *dest, const char *src, size_t n )
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86strncpy(dest, src, n);
+#else
+ return strncpy(dest, src, n);
+#endif
+}
+
+/** Wrapper around either strlen() or xf86strlen() */
+size_t
+_mesa_strlen( const char *s )
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86strlen(s);
+#else
+ return strlen(s);
+#endif
+}
+
+/** Wrapper around either strcmp() or xf86strcmp() */
+int
+_mesa_strcmp( const char *s1, const char *s2 )
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86strcmp(s1, s2);
+#else
+ return strcmp(s1, s2);
+#endif
+}
+
+/** Wrapper around either strncmp() or xf86strncmp() */
+int
+_mesa_strncmp( const char *s1, const char *s2, size_t n )
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86strncmp(s1, s2, n);
+#else
+ return strncmp(s1, s2, n);
+#endif
+}
+
+/** Implemented using _mesa_malloc() and _mesa_strcpy */
+char *
+_mesa_strdup( const char *s )
+{
+ size_t l = _mesa_strlen(s);
+ char *s2 = (char *) _mesa_malloc(l + 1);
+ if (s2)
+ _mesa_strcpy(s2, s);
+ return s2;
+}
+
+/** Wrapper around either atoi() or xf86atoi() */
+int
+_mesa_atoi(const char *s)
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86atoi(s);
+#else
+ return atoi(s);
+#endif
+}
+
+/** Wrapper around either strtod() or xf86strtod() */
+double
+_mesa_strtod( const char *s, char **end )
+{
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86strtod(s, end);
+#else
+ return strtod(s, end);
+#endif
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name I/O */
+/*@{*/
+
+/** Wrapper around either vsprintf() or xf86vsprintf() */
+int
+_mesa_sprintf( char *str, const char *fmt, ... )
+{
+ int r;
+ va_list args;
+ va_start( args, fmt );
+ va_end( args );
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ r = xf86vsprintf( str, fmt, args );
+#else
+ r = vsprintf( str, fmt, args );
+#endif
+ return r;
+}
+
+/** Wrapper around either printf() or xf86printf(), using vsprintf() for
+ * the formatting. */
+void
+_mesa_printf( const char *fmtString, ... )
+{
+ char s[MAXSTRING];
+ va_list args;
+ va_start( args, fmtString );
+ vsnprintf(s, MAXSTRING, fmtString, args);
+ va_end( args );
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ xf86printf("%s", s);
+#else
+ fprintf(stderr,"%s", s);
+#endif
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Diagnostics */
+/*@{*/
+
+/**
+ * Display a warning.
+ *
+ * \param ctx GL context.
+ * \param fmtString printf() alike format string.
+ *
+ * If debugging is enabled (either at compile-time via the DEBUG macro, or
+ * run-time via the MESA_DEBUG environment variable), prints the warning to
+ * stderr, either via fprintf() or xf86printf().
+ */
+void
+_mesa_warning( GLcontext *ctx, const char *fmtString, ... )
+{
+ GLboolean debug;
+ char str[MAXSTRING];
+ va_list args;
+ (void) ctx;
+ va_start( args, fmtString );
+ (void) vsnprintf( str, MAXSTRING, fmtString, args );
+ va_end( args );
+#ifdef DEBUG
+ debug = GL_TRUE; /* always print warning */
+#else
+ debug = _mesa_getenv("MESA_DEBUG") ? GL_TRUE : GL_FALSE;
+#endif
+ if (debug) {
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ xf86fprintf(stderr, "Mesa warning: %s", str);
+#else
+ fprintf(stderr, "Mesa warning: %s", str);
+#endif
+ }
+}
+
+/**
+ * This function is called when the Mesa user has stumbled into a code
+ * path which may not be implemented fully or correctly.
+ *
+ * \param ctx GL context.
+ * \param s problem description string.
+ *
+ * Prints the message to stderr, either via fprintf() or xf86fprintf().
+ */
+void
+_mesa_problem( const GLcontext *ctx, const char *fmtString, ... )
+{
+ va_list args;
+ char str[MAXSTRING];
+ (void) ctx;
+
+ va_start( args, fmtString );
+ vsnprintf( str, MAXSTRING, fmtString, args );
+ va_end( args );
+
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ xf86fprintf(stderr, "Mesa %s implementation error: %s\n", MESA_VERSION_STRING, str);
+ xf86fprintf(stderr, "Please report at bugzilla.freedesktop.org\n");
+#else
+ fprintf(stderr, "Mesa %s implementation error: %s\n", MESA_VERSION_STRING, str);
+ fprintf(stderr, "Please report at bugzilla.freedesktop.org\n");
+#endif
+}
+
+/**
+ * Display an error message.
+ *
+ * If in debug mode, print error message.
+ * Also, record the error code by calling _mesa_record_error().
+ *
+ * \param ctx the GL context.
+ * \param error the error value.
+ * \param fmtString printf() style format string, followed by optional args
+ *
+ * If debugging is enabled (either at compile-time via the DEBUG macro, or
+ * run-time via the MESA_DEBUG environment variable), interperts the error code and
+ * prints the error message via _mesa_debug().
+ */
+void
+_mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... )
+{
+ const char *debugEnv;
+ GLboolean debug;
+
+ debugEnv = _mesa_getenv("MESA_DEBUG");
+
+#ifdef DEBUG
+ if (debugEnv && _mesa_strstr(debugEnv, "silent"))
+ debug = GL_FALSE;
+ else
+ debug = GL_TRUE;
+#else
+ if (debugEnv)
+ debug = GL_TRUE;
+ else
+ debug = GL_FALSE;
+#endif
+
+ if (debug) {
+ va_list args;
+ char where[MAXSTRING];
+ const char *errstr;
+
+ va_start( args, fmtString );
+ vsnprintf( where, MAXSTRING, fmtString, args );
+ va_end( args );
+
+ switch (error) {
+ case GL_NO_ERROR:
+ errstr = "GL_NO_ERROR";
+ break;
+ case GL_INVALID_VALUE:
+ errstr = "GL_INVALID_VALUE";
+ break;
+ case GL_INVALID_ENUM:
+ errstr = "GL_INVALID_ENUM";
+ break;
+ case GL_INVALID_OPERATION:
+ errstr = "GL_INVALID_OPERATION";
+ break;
+ case GL_STACK_OVERFLOW:
+ errstr = "GL_STACK_OVERFLOW";
+ break;
+ case GL_STACK_UNDERFLOW:
+ errstr = "GL_STACK_UNDERFLOW";
+ break;
+ case GL_OUT_OF_MEMORY:
+ errstr = "GL_OUT_OF_MEMORY";
+ break;
+ case GL_TABLE_TOO_LARGE:
+ errstr = "GL_TABLE_TOO_LARGE";
+ break;
+ case GL_INVALID_FRAMEBUFFER_OPERATION_EXT:
+ errstr = "GL_INVALID_FRAMEBUFFER_OPERATION";
+ break;
+ default:
+ errstr = "unknown";
+ break;
+ }
+ _mesa_debug(ctx, "User error: %s in %s\n", errstr, where);
+ }
+
+ _mesa_record_error(ctx, error);
+}
+
+/**
+ * Report debug information.
+ *
+ * \param ctx GL context.
+ * \param fmtString printf() alike format string.
+ *
+ * Prints the message to stderr, either via fprintf() or xf86printf().
+ */
+void
+_mesa_debug( const GLcontext *ctx, const char *fmtString, ... )
+{
+ char s[MAXSTRING];
+ va_list args;
+ (void) ctx;
+ va_start(args, fmtString);
+ vsnprintf(s, MAXSTRING, fmtString, args);
+ va_end(args);
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ xf86fprintf(stderr, "Mesa: %s", s);
+#else
+ fprintf(stderr, "Mesa: %s", s);
+#endif
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Default Imports Wrapper */
+/*@{*/
+
+/** Wrapper around _mesa_malloc() */
+static void *
+default_malloc(__GLcontext *gc, size_t size)
+{
+ (void) gc;
+ return _mesa_malloc(size);
+}
+
+/** Wrapper around _mesa_malloc() */
+static void *
+default_calloc(__GLcontext *gc, size_t numElem, size_t elemSize)
+{
+ (void) gc;
+ return _mesa_calloc(numElem * elemSize);
+}
+
+/** Wrapper around either realloc() or xf86realloc() */
+static void *
+default_realloc(__GLcontext *gc, void *oldAddr, size_t newSize)
+{
+ (void) gc;
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+ return xf86realloc(oldAddr, newSize);
+#else
+ return realloc(oldAddr, newSize);
+#endif
+}
+
+/** Wrapper around _mesa_free() */
+static void
+default_free(__GLcontext *gc, void *addr)
+{
+ (void) gc;
+ _mesa_free(addr);
+}
+
+/** Wrapper around _mesa_getenv() */
+static char * CAPI
+default_getenv( __GLcontext *gc, const char *var )
+{
+ (void) gc;
+ return _mesa_getenv(var);
+}
+
+/** Wrapper around _mesa_warning() */
+static void
+default_warning(__GLcontext *gc, char *str)
+{
+ _mesa_warning(gc, str);
+}
+
+/** Wrapper around _mesa_problem() */
+static void
+default_fatal(__GLcontext *gc, char *str)
+{
+ _mesa_problem(gc, str);
+ abort();
+}
+
+/** Wrapper around atoi() */
+static int CAPI
+default_atoi(__GLcontext *gc, const char *str)
+{
+ (void) gc;
+ return atoi(str);
+}
+
+/** Wrapper around vsprintf() */
+static int CAPI
+default_sprintf(__GLcontext *gc, char *str, const char *fmt, ...)
+{
+ int r;
+ va_list args;
+ (void) gc;
+ va_start( args, fmt );
+ r = vsprintf( str, fmt, args );
+ va_end( args );
+ return r;
+}
+
+/** Wrapper around fopen() */
+static void * CAPI
+default_fopen(__GLcontext *gc, const char *path, const char *mode)
+{
+ (void) gc;
+ return fopen(path, mode);
+}
+
+/** Wrapper around fclose() */
+static int CAPI
+default_fclose(__GLcontext *gc, void *stream)
+{
+ (void) gc;
+ return fclose((FILE *) stream);
+}
+
+/** Wrapper around vfprintf() */
+static int CAPI
+default_fprintf(__GLcontext *gc, void *stream, const char *fmt, ...)
+{
+ int r;
+ va_list args;
+ (void) gc;
+ va_start( args, fmt );
+ r = vfprintf( (FILE *) stream, fmt, args );
+ va_end( args );
+ return r;
+}
+
+/**
+ * \todo this really is driver-specific and can't be here
+ */
+static __GLdrawablePrivate *
+default_GetDrawablePrivate(__GLcontext *gc)
+{
+ (void) gc;
+ return NULL;
+}
+
+/*@}*/
+
+
+/**
+ * Initialize a __GLimports object to point to the functions in this
+ * file.
+ *
+ * This is to be called from device drivers.
+ *
+ * Also, do some one-time initializations.
+ *
+ * \param imports the object to initialize.
+ * \param driverCtx pointer to device driver-specific data.
+ */
+void
+_mesa_init_default_imports(__GLimports *imports, void *driverCtx)
+{
+ /* XXX maybe move this one-time init stuff into context.c */
+ static GLboolean initialized = GL_FALSE;
+ if (!initialized) {
+ init_sqrt_table();
+
+#if defined(_FPU_GETCW) && defined(_FPU_SETCW)
+ {
+ const char *debug = _mesa_getenv("MESA_DEBUG");
+ if (debug && _mesa_strcmp(debug, "FP")==0) {
+ /* die on FP exceptions */
+ fpu_control_t mask;
+ _FPU_GETCW(mask);
+ mask &= ~(_FPU_MASK_IM | _FPU_MASK_DM | _FPU_MASK_ZM
+ | _FPU_MASK_OM | _FPU_MASK_UM);
+ _FPU_SETCW(mask);
+ }
+ }
+#endif
+ initialized = GL_TRUE;
+ }
+
+ imports->malloc = default_malloc;
+ imports->calloc = default_calloc;
+ imports->realloc = default_realloc;
+ imports->free = default_free;
+ imports->warning = default_warning;
+ imports->fatal = default_fatal;
+ imports->getenv = default_getenv; /* not used for now */
+ imports->atoi = default_atoi;
+ imports->sprintf = default_sprintf;
+ imports->fopen = default_fopen;
+ imports->fclose = default_fclose;
+ imports->fprintf = default_fprintf;
+ imports->getDrawablePrivate = default_GetDrawablePrivate;
+ imports->other = driverCtx;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/imports.h b/nx-X11/extras/Mesa/src/mesa/main/imports.h
new file mode 100644
index 000000000..37e808fc4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/imports.h
@@ -0,0 +1,782 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4.1
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file imports.h
+ * Standard C library function wrappers.
+ *
+ * This file provides wrappers for all the standard C library functions
+ * like malloc(), free(), printf(), getenv(), etc.
+ */
+
+
+#ifndef IMPORTS_H
+#define IMPORTS_H
+
+
+/* XXX some of the stuff in glheader.h should be moved into this file.
+ */
+#include "glheader.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**********************************************************************/
+/** \name General macros */
+/*@{*/
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+/*@}*/
+
+
+/**********************************************************************/
+/** Memory macros */
+/*@{*/
+
+/** Allocate \p BYTES bytes */
+#define MALLOC(BYTES) _mesa_malloc(BYTES)
+/** Allocate and zero \p BYTES bytes */
+#define CALLOC(BYTES) _mesa_calloc(BYTES)
+/** Allocate a structure of type \p T */
+#define MALLOC_STRUCT(T) (struct T *) _mesa_malloc(sizeof(struct T))
+/** Allocate and zero a structure of type \p T */
+#define CALLOC_STRUCT(T) (struct T *) _mesa_calloc(sizeof(struct T))
+/** Free memory */
+#define FREE(PTR) _mesa_free(PTR)
+
+/** Allocate \p BYTES aligned at \p N bytes */
+#define ALIGN_MALLOC(BYTES, N) _mesa_align_malloc(BYTES, N)
+/** Allocate and zero \p BYTES bytes aligned at \p N bytes */
+#define ALIGN_CALLOC(BYTES, N) _mesa_align_calloc(BYTES, N)
+/** Allocate a structure of type \p T aligned at \p N bytes */
+#define ALIGN_MALLOC_STRUCT(T, N) (struct T *) _mesa_align_malloc(sizeof(struct T), N)
+/** Allocate and zero a structure of type \p T aligned at \p N bytes */
+#define ALIGN_CALLOC_STRUCT(T, N) (struct T *) _mesa_align_calloc(sizeof(struct T), N)
+/** Free aligned memory */
+#define ALIGN_FREE(PTR) _mesa_align_free(PTR)
+
+/** Copy \p BYTES bytes from \p SRC into \p DST */
+#define MEMCPY( DST, SRC, BYTES) _mesa_memcpy(DST, SRC, BYTES)
+/** Set \p N bytes in \p DST to \p VAL */
+#define MEMSET( DST, VAL, N ) _mesa_memset(DST, VAL, N)
+
+/*@}*/
+
+
+/*
+ * For GL_ARB_vertex_buffer_object we need to treat vertex array pointers
+ * as offsets into buffer stores. Since the vertex array pointer and
+ * buffer store pointer are both pointers and we need to add them, we use
+ * this macro.
+ * Both pointers/offsets are expressed in bytes.
+ */
+#define ADD_POINTERS(A, B) ( (GLubyte *) (A) + (uintptr_t) (B) )
+
+
+/**********************************************************************/
+/** \name [Pseudo] static array declaration.
+ *
+ * MACs and BeOS don't support static larger than 32kb, so ...
+ */
+/*@{*/
+
+/**
+ * \def DEFARRAY
+ * Define a [static] unidimensional array
+ */
+
+/**
+ * \def DEFMARRAY
+ * Define a [static] bi-dimensional array
+ */
+
+/**
+ * \def DEFMNARRAY
+ * Define a [static] tri-dimensional array
+ */
+
+/**
+ * \def CHECKARRAY
+ * Verifies a [static] array was properly allocated.
+ */
+
+/**
+ * \def UNDEFARRAY
+ * Undefine (free) a [static] array.
+ */
+
+#if defined(macintosh) && !defined(__MRC__)
+/*extern char *AGLAlloc(int size);*/
+/*extern void AGLFree(char* ptr);*/
+# define DEFARRAY(TYPE,NAME,SIZE) TYPE *NAME = (TYPE*)_mesa_alloc(sizeof(TYPE)*(SIZE))
+# define DEFMARRAY(TYPE,NAME,SIZE1,SIZE2) TYPE (*NAME)[SIZE2] = (TYPE(*)[SIZE2])_mesa_alloc(sizeof(TYPE)*(SIZE1)*(SIZE2))
+# define DEFMNARRAY(TYPE,NAME,SIZE1,SIZE2,SIZE3) TYPE (*NAME)[SIZE2][SIZE3] = (TYPE(*)[SIZE2][SIZE3])_mesa_alloc(sizeof(TYPE)*(SIZE1)*(SIZE2)*(SIZE3))
+# define CHECKARRAY(NAME,CMD) do {if (!(NAME)) {CMD;}} while (0)
+# define UNDEFARRAY(NAME) do {if ((NAME)) {_mesa_free((char*)NAME);} }while (0)
+#elif defined(__BEOS__)
+# define DEFARRAY(TYPE,NAME,SIZE) TYPE *NAME = (TYPE*)_mesa_malloc(sizeof(TYPE)*(SIZE))
+# define DEFMARRAY(TYPE,NAME,SIZE1,SIZE2) TYPE (*NAME)[SIZE2] = (TYPE(*)[SIZE2])_mesa_malloc(sizeof(TYPE)*(SIZE1)*(SIZE2))
+# define DEFMNARRAY(TYPE,NAME,SIZE1,SIZE2,SIZE3) TYPE (*NAME)[SIZE2][SIZE3] = (TYPE(*)[SIZE2][SIZE3])_mesa_malloc(sizeof(TYPE)*(SIZE1)*(SIZE2)*(SIZE3))
+# define CHECKARRAY(NAME,CMD) do {if (!(NAME)) {CMD;}} while (0)
+# define UNDEFARRAY(NAME) do {if ((NAME)) {_mesa_free((char*)NAME);} }while (0)
+#else
+# define DEFARRAY(TYPE,NAME,SIZE) TYPE NAME[SIZE]
+# define DEFMARRAY(TYPE,NAME,SIZE1,SIZE2) TYPE NAME[SIZE1][SIZE2]
+# define DEFMNARRAY(TYPE,NAME,SIZE1,SIZE2,SIZE3) TYPE NAME[SIZE1][SIZE2][SIZE3]
+# define CHECKARRAY(NAME,CMD) do {} while(0)
+# define UNDEFARRAY(NAME)
+#endif
+
+/*@}*/
+
+
+/**
+ * Sometimes we treat GLfloats as GLints. On x86 systems, moving a float
+ * as a int (thereby using integer registers instead of FP registers) is
+ * a performance win. Typically, this can be done with ordinary casts.
+ * But with gcc's -fstrict-aliasing flag (which defaults to on in gcc 3.0)
+ * these casts generate warnings.
+ * The following union typedef is used to solve that.
+ */
+typedef union { GLfloat f; GLint i; } fi_type;
+
+
+
+/**********************************************************************
+ * Math macros
+ */
+
+#define MAX_GLUSHORT 0xffff
+#define MAX_GLUINT 0xffffffff
+
+#ifndef M_PI
+#define M_PI (3.1415926536)
+#endif
+
+#ifndef M_E
+#define M_E (2.7182818284590452354)
+#endif
+
+
+/* XXX this is a bit of a hack needed for compilation within XFree86 */
+#ifndef FLT_MIN
+#define FLT_MIN (1.0e-37)
+#endif
+
+/* Degrees to radians conversion: */
+#define DEG2RAD (M_PI/180.0)
+
+
+/***
+ *** USE_IEEE: Determine if we're using IEEE floating point
+ ***/
+#if defined(__i386__) || defined(__386__) || defined(__sparc__) || \
+ defined(__s390x__) || defined(__powerpc__) || \
+ defined(__amd64__) || \
+ defined(ia64) || defined(__ia64__) || \
+ defined(__hppa__) || defined(hpux) || \
+ defined(__mips) || defined(_MIPS_ARCH) || \
+ defined(__arm__) || \
+ defined(__sh__) || \
+ (defined(__alpha__) && (defined(__IEEE_FLOAT) || !defined(VMS)))
+#define USE_IEEE
+#define IEEE_ONE 0x3f800000
+#endif
+
+
+/***
+ *** SQRTF: single-precision square root
+ ***/
+#if 0 /* _mesa_sqrtf() not accurate enough - temporarily disabled */
+# define SQRTF(X) _mesa_sqrtf(X)
+#elif defined(XFree86LOADER) && defined(IN_MODULE)
+# define SQRTF(X) (float) xf86sqrt((float) (X))
+#else
+# define SQRTF(X) (float) sqrt((float) (X))
+#endif
+
+
+/***
+ *** INV_SQRTF: single-precision inverse square root
+ ***/
+#if 0
+#define INV_SQRTF(X) _mesa_inv_sqrt(X)
+#else
+#define INV_SQRTF(X) (1.0F / SQRTF(X)) /* this is faster on a P4 */
+#endif
+
+
+/***
+ *** LOG2: Log base 2 of float
+ ***/
+#ifdef USE_IEEE
+#if 0
+/* This is pretty fast, but not accurate enough (only 2 fractional bits).
+ * Based on code from http://www.stereopsis.com/log2.html
+ */
+static INLINE GLfloat LOG2(GLfloat x)
+{
+ const GLfloat y = x * x * x * x;
+ const GLuint ix = *((GLuint *) &y);
+ const GLuint exp = (ix >> 23) & 0xFF;
+ const GLint log2 = ((GLint) exp) - 127;
+ return (GLfloat) log2 * (1.0 / 4.0); /* 4, because of x^4 above */
+}
+#endif
+/* Pretty fast, and accurate.
+ * Based on code from http://www.flipcode.com/totd/
+ */
+static INLINE GLfloat LOG2(GLfloat val)
+{
+ fi_type num;
+ GLint log_2;
+ num.f = val;
+ log_2 = ((num.i >> 23) & 255) - 128;
+ num.i &= ~(255 << 23);
+ num.i += 127 << 23;
+ num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3;
+ return num.f + log_2;
+}
+#elif defined(XFree86LOADER) && defined(IN_MODULE)
+#define LOG2(x) ((GLfloat) (xf86log(x) * 1.442695))
+#else
+/*
+ * NOTE: log_base_2(x) = log(x) / log(2)
+ * NOTE: 1.442695 = 1/log(2).
+ */
+#define LOG2(x) ((GLfloat) (log(x) * 1.442695F))
+#endif
+
+
+/***
+ *** IS_INF_OR_NAN: test if float is infinite or NaN
+ ***/
+#ifdef USE_IEEE
+static INLINE int IS_INF_OR_NAN( float x )
+{
+ fi_type tmp;
+ tmp.f = x;
+ return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31);
+}
+#elif defined(isfinite)
+#define IS_INF_OR_NAN(x) (!isfinite(x))
+#elif defined(finite)
+#define IS_INF_OR_NAN(x) (!finite(x))
+#elif defined(__VMS)
+#define IS_INF_OR_NAN(x) (!finite(x))
+#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#define IS_INF_OR_NAN(x) (!isfinite(x))
+#else
+#define IS_INF_OR_NAN(x) (!finite(x))
+#endif
+
+
+/***
+ *** IS_NEGATIVE: test if float is negative
+ ***/
+#if defined(USE_IEEE)
+static INLINE int GET_FLOAT_BITS( float x )
+{
+ fi_type fi;
+ fi.f = x;
+ return fi.i;
+}
+#define IS_NEGATIVE(x) (GET_FLOAT_BITS(x) < 0)
+#else
+#define IS_NEGATIVE(x) (x < 0.0F)
+#endif
+
+
+/***
+ *** DIFFERENT_SIGNS: test if two floats have opposite signs
+ ***/
+#if defined(USE_IEEE)
+#define DIFFERENT_SIGNS(x,y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1<<31))
+#else
+/* Could just use (x*y<0) except for the flatshading requirements.
+ * Maybe there's a better way?
+ */
+#define DIFFERENT_SIGNS(x,y) ((x) * (y) <= 0.0F && (x) - (y) != 0.0F)
+#endif
+
+
+/***
+ *** CEILF: ceiling of float
+ *** FLOORF: floor of float
+ *** FABSF: absolute value of float
+ *** LOGF: the natural logarithm (base e) of the value
+ *** EXPF: raise e to the value
+ *** LDEXPF: multiply value by an integral power of two
+ *** FREXPF: extract mantissa and exponent from value
+ ***/
+#if defined(XFree86LOADER) && defined(IN_MODULE)
+#define CEILF(x) ((GLfloat) xf86ceil(x))
+#define FLOORF(x) ((GLfloat) xf86floor(x))
+#define FABSF(x) ((GLfloat) xf86fabs(x))
+#define LOGF(x) ((GLfloat) xf86log(x))
+#define EXPF(x) ((GLfloat) xf86exp(x))
+#define LDEXPF(x,y) ((GLfloat) xf86ldexp(x,y))
+#define FREXPF(x,y) ((GLfloat) xf86frexp(x,y))
+#elif defined(__gnu_linux__)
+/* C99 functions */
+#define CEILF(x) ceilf(x)
+#define FLOORF(x) floorf(x)
+#define FABSF(x) fabsf(x)
+#define LOGF(x) logf(x)
+#define EXPF(x) expf(x)
+#define LDEXPF(x,y) ldexpf(x,y)
+#define FREXPF(x,y) frexpf(x,y)
+#else
+#define CEILF(x) ((GLfloat) ceil(x))
+#define FLOORF(x) ((GLfloat) floor(x))
+#define FABSF(x) ((GLfloat) fabs(x))
+#define LOGF(x) ((GLfloat) log(x))
+#define EXPF(x) ((GLfloat) exp(x))
+#define LDEXPF(x,y) ((GLfloat) ldexp(x,y))
+#define FREXPF(x,y) ((GLfloat) frexp(x,y))
+#endif
+
+
+/***
+ *** IROUND: return (as an integer) float rounded to nearest integer
+ ***/
+#if defined(USE_SPARC_ASM) && defined(__GNUC__) && defined(__sparc__)
+static INLINE int iround(float f)
+{
+ int r;
+ __asm__ ("fstoi %1, %0" : "=f" (r) : "f" (f));
+ return r;
+}
+#define IROUND(x) iround(x)
+#elif defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__) && \
+ (!defined(__BEOS__) || (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)))
+static INLINE int iround(float f)
+{
+ int r;
+ __asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
+ return r;
+}
+#define IROUND(x) iround(x)
+#elif defined(USE_X86_ASM) && defined(__MSC__) && defined(__WIN32__)
+static INLINE int iround(float f)
+{
+ int r;
+ _asm {
+ fld f
+ fistp r
+ }
+ return r;
+}
+#define IROUND(x) iround(x)
+#elif defined(__WATCOMC__) && defined(__386__)
+long iround(float f);
+#pragma aux iround = \
+ "push eax" \
+ "fistp dword ptr [esp]" \
+ "pop eax" \
+ parm [8087] \
+ value [eax] \
+ modify exact [eax];
+#define IROUND(x) iround(x)
+#else
+#define IROUND(f) ((int) (((f) >= 0.0F) ? ((f) + 0.5F) : ((f) - 0.5F)))
+#endif
+
+
+/***
+ *** IROUND_POS: return (as an integer) positive float rounded to nearest int
+ ***/
+#ifdef DEBUG
+#define IROUND_POS(f) (assert((f) >= 0.0F), IROUND(f))
+#else
+#define IROUND_POS(f) (IROUND(f))
+#endif
+
+
+/***
+ *** IFLOOR: return (as an integer) floor of float
+ ***/
+#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
+/*
+ * IEEE floor for computers that round to nearest or even.
+ * 'f' must be between -4194304 and 4194303.
+ * This floor operation is done by "(iround(f + .5) + iround(f - .5)) >> 1",
+ * but uses some IEEE specific tricks for better speed.
+ * Contributed by Josh Vanderhoof
+ */
+static INLINE int ifloor(float f)
+{
+ int ai, bi;
+ double af, bf;
+ af = (3 << 22) + 0.5 + (double)f;
+ bf = (3 << 22) + 0.5 - (double)f;
+ /* GCC generates an extra fstp/fld without this. */
+ __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st");
+ __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st");
+ return (ai - bi) >> 1;
+}
+#define IFLOOR(x) ifloor(x)
+#elif defined(USE_IEEE)
+static INLINE int ifloor(float f)
+{
+ int ai, bi;
+ double af, bf;
+ fi_type u;
+
+ af = (3 << 22) + 0.5 + (double)f;
+ bf = (3 << 22) + 0.5 - (double)f;
+ u.f = (float) af; ai = u.i;
+ u.f = (float) bf; bi = u.i;
+ return (ai - bi) >> 1;
+}
+#define IFLOOR(x) ifloor(x)
+#else
+static INLINE int ifloor(float f)
+{
+ int i = IROUND(f);
+ return (i > f) ? i - 1 : i;
+}
+#define IFLOOR(x) ifloor(x)
+#endif
+
+
+/***
+ *** ICEIL: return (as an integer) ceiling of float
+ ***/
+#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
+/*
+ * IEEE ceil for computers that round to nearest or even.
+ * 'f' must be between -4194304 and 4194303.
+ * This ceil operation is done by "(iround(f + .5) + iround(f - .5) + 1) >> 1",
+ * but uses some IEEE specific tricks for better speed.
+ * Contributed by Josh Vanderhoof
+ */
+static INLINE int iceil(float f)
+{
+ int ai, bi;
+ double af, bf;
+ af = (3 << 22) + 0.5 + (double)f;
+ bf = (3 << 22) + 0.5 - (double)f;
+ /* GCC generates an extra fstp/fld without this. */
+ __asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st");
+ __asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st");
+ return (ai - bi + 1) >> 1;
+}
+#define ICEIL(x) iceil(x)
+#elif defined(USE_IEEE)
+static INLINE int iceil(float f)
+{
+ int ai, bi;
+ double af, bf;
+ fi_type u;
+ af = (3 << 22) + 0.5 + (double)f;
+ bf = (3 << 22) + 0.5 - (double)f;
+ u.f = (float) af; ai = u.i;
+ u.f = (float) bf; bi = u.i;
+ return (ai - bi + 1) >> 1;
+}
+#define ICEIL(x) iceil(x)
+#else
+static INLINE int iceil(float f)
+{
+ int i = IROUND(f);
+ return (i < f) ? i + 1 : i;
+}
+#define ICEIL(x) iceil(x)
+#endif
+
+
+/***
+ *** UNCLAMPED_FLOAT_TO_UBYTE: clamp float to [0,1] and map to ubyte in [0,255]
+ *** CLAMPED_FLOAT_TO_UBYTE: map float known to be in [0,1] to ubyte in [0,255]
+ ***/
+#if defined(USE_IEEE) && !defined(DEBUG)
+#define IEEE_0996 0x3f7f0000 /* 0.996 or so */
+/* This function/macro is sensitive to precision. Test very carefully
+ * if you change it!
+ */
+#define UNCLAMPED_FLOAT_TO_UBYTE(UB, F) \
+ do { \
+ fi_type __tmp; \
+ __tmp.f = (F); \
+ if (__tmp.i < 0) \
+ UB = (GLubyte) 0; \
+ else if (__tmp.i >= IEEE_0996) \
+ UB = (GLubyte) 255; \
+ else { \
+ __tmp.f = __tmp.f * (255.0F/256.0F) + 32768.0F; \
+ UB = (GLubyte) __tmp.i; \
+ } \
+ } while (0)
+#define CLAMPED_FLOAT_TO_UBYTE(UB, F) \
+ do { \
+ fi_type __tmp; \
+ __tmp.f = (F) * (255.0F/256.0F) + 32768.0F; \
+ UB = (GLubyte) __tmp.i; \
+ } while (0)
+#else
+#define UNCLAMPED_FLOAT_TO_UBYTE(ub, f) \
+ ub = ((GLubyte) IROUND(CLAMP((f), 0.0F, 1.0F) * 255.0F))
+#define CLAMPED_FLOAT_TO_UBYTE(ub, f) \
+ ub = ((GLubyte) IROUND((f) * 255.0F))
+#endif
+
+
+/***
+ *** COPY_FLOAT: copy a float from src to dest.
+ ***/
+#define COPY_FLOAT( dst, src ) (dst) = (src)
+
+
+/***
+ *** START_FAST_MATH: Set x86 FPU to faster, 32-bit precision mode (and save
+ *** original mode to a temporary).
+ *** END_FAST_MATH: Restore x86 FPU to original mode.
+ ***/
+#if defined(__GNUC__) && defined(__i386__)
+/*
+ * Set the x86 FPU control word to guarentee only 32 bits of precision
+ * are stored in registers. Allowing the FPU to store more introduces
+ * differences between situations where numbers are pulled out of memory
+ * vs. situations where the compiler is able to optimize register usage.
+ *
+ * In the worst case, we force the compiler to use a memory access to
+ * truncate the float, by specifying the 'volatile' keyword.
+ */
+/* Hardware default: All exceptions masked, extended double precision,
+ * round to nearest (IEEE compliant):
+ */
+#define DEFAULT_X86_FPU 0x037f
+/* All exceptions masked, single precision, round to nearest:
+ */
+#define FAST_X86_FPU 0x003f
+/* The fldcw instruction will cause any pending FP exceptions to be
+ * raised prior to entering the block, and we clear any pending
+ * exceptions before exiting the block. Hence, asm code has free
+ * reign over the FPU while in the fast math block.
+ */
+#if defined(NO_FAST_MATH)
+#define START_FAST_MATH(x) \
+do { \
+ static GLuint mask = DEFAULT_X86_FPU; \
+ __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \
+ __asm__ ( "fldcw %0" : : "m" (mask) ); \
+} while (0)
+#else
+#define START_FAST_MATH(x) \
+do { \
+ static GLuint mask = FAST_X86_FPU; \
+ __asm__ ( "fnstcw %0" : "=m" (*&(x)) ); \
+ __asm__ ( "fldcw %0" : : "m" (mask) ); \
+} while (0)
+#endif
+/* Restore original FPU mode, and clear any exceptions that may have
+ * occurred in the FAST_MATH block.
+ */
+#define END_FAST_MATH(x) \
+do { \
+ __asm__ ( "fnclex ; fldcw %0" : : "m" (*&(x)) ); \
+} while (0)
+
+#elif defined(__WATCOMC__) && defined(__386__)
+#define DEFAULT_X86_FPU 0x037f /* See GCC comments above */
+#define FAST_X86_FPU 0x003f /* See GCC comments above */
+void _watcom_start_fast_math(unsigned short *x,unsigned short *mask);
+#pragma aux _watcom_start_fast_math = \
+ "fnstcw word ptr [eax]" \
+ "fldcw word ptr [ecx]" \
+ parm [eax] [ecx] \
+ modify exact [];
+void _watcom_end_fast_math(unsigned short *x);
+#pragma aux _watcom_end_fast_math = \
+ "fnclex" \
+ "fldcw word ptr [eax]" \
+ parm [eax] \
+ modify exact [];
+#if defined(NO_FAST_MATH)
+#define START_FAST_MATH(x) \
+do { \
+ static GLushort mask = DEFAULT_X86_FPU; \
+ _watcom_start_fast_math(&x,&mask); \
+} while (0)
+#else
+#define START_FAST_MATH(x) \
+do { \
+ static GLushort mask = FAST_X86_FPU; \
+ _watcom_start_fast_math(&x,&mask); \
+} while (0)
+#endif
+#define END_FAST_MATH(x) _watcom_end_fast_math(&x)
+#else
+#define START_FAST_MATH(x) x = 0
+#define END_FAST_MATH(x) (void)(x)
+#endif
+
+
+
+/**********************************************************************
+ * Functions
+ */
+
+extern void *
+_mesa_malloc( size_t bytes );
+
+extern void *
+_mesa_calloc( size_t bytes );
+
+extern void
+_mesa_free( void *ptr );
+
+extern void *
+_mesa_align_malloc( size_t bytes, unsigned long alignment );
+
+extern void *
+_mesa_align_calloc( size_t bytes, unsigned long alignment );
+
+extern void
+_mesa_align_free( void *ptr );
+
+extern void *
+_mesa_exec_malloc( GLuint size );
+
+extern void
+_mesa_exec_free( void *addr );
+
+extern void *
+_mesa_realloc( void *oldBuffer, size_t oldSize, size_t newSize );
+
+extern void *
+_mesa_memcpy( void *dest, const void *src, size_t n );
+
+extern void
+_mesa_memset( void *dst, int val, size_t n );
+
+extern void
+_mesa_memset16( unsigned short *dst, unsigned short val, size_t n );
+
+extern void
+_mesa_bzero( void *dst, size_t n );
+
+
+extern double
+_mesa_sin(double a);
+
+extern double
+_mesa_cos(double a);
+
+extern double
+_mesa_sqrtd(double x);
+
+extern float
+_mesa_sqrtf(float x);
+
+extern float
+_mesa_inv_sqrtf(float x);
+
+extern double
+_mesa_pow(double x, double y);
+
+extern float
+_mesa_log2(float x);
+
+extern unsigned int
+_mesa_bitcount(unsigned int n);
+
+extern GLhalfARB
+_mesa_float_to_half(float f);
+
+extern float
+_mesa_half_to_float(GLhalfARB h);
+
+
+extern char *
+_mesa_getenv( const char *var );
+
+extern char *
+_mesa_strstr( const char *haystack, const char *needle );
+
+extern char *
+_mesa_strncat( char *dest, const char *src, size_t n );
+
+extern char *
+_mesa_strcpy( char *dest, const char *src );
+
+extern char *
+_mesa_strncpy( char *dest, const char *src, size_t n );
+
+extern size_t
+_mesa_strlen( const char *s );
+
+extern int
+_mesa_strcmp( const char *s1, const char *s2 );
+
+extern int
+_mesa_strncmp( const char *s1, const char *s2, size_t n );
+
+extern char *
+_mesa_strdup( const char *s );
+
+extern int
+_mesa_atoi( const char *s );
+
+extern double
+_mesa_strtod( const char *s, char **end );
+
+extern int
+_mesa_sprintf( char *str, const char *fmt, ... );
+
+extern void
+_mesa_printf( const char *fmtString, ... );
+
+
+extern void
+_mesa_warning( __GLcontext *gc, const char *fmtString, ... );
+
+extern void
+_mesa_problem( const __GLcontext *ctx, const char *fmtString, ... );
+
+extern void
+_mesa_error( __GLcontext *ctx, GLenum error, const char *fmtString, ... );
+
+extern void
+_mesa_debug( const __GLcontext *ctx, const char *fmtString, ... );
+
+
+extern void
+_mesa_init_default_imports( __GLimports *imports, void *driverCtx );
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* IMPORTS_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/main/light.c b/nx-X11/extras/Mesa/src/mesa/main/light.c
new file mode 100644
index 000000000..98934f398
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/light.c
@@ -0,0 +1,1313 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "enums.h"
+#include "light.h"
+#include "macros.h"
+#include "simple_list.h"
+#include "mtypes.h"
+#include "math/m_matrix.h"
+
+
+void GLAPIENTRY
+_mesa_ShadeModel( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glShadeModel %s\n", _mesa_lookup_enum_by_nr(mode));
+
+ if (mode != GL_FLAT && mode != GL_SMOOTH) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glShadeModel" );
+ return;
+ }
+
+ if (ctx->Light.ShadeModel == mode)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ ctx->Light.ShadeModel = mode;
+ ctx->_TriangleCaps ^= DD_FLATSHADE;
+ if (ctx->Driver.ShadeModel)
+ (*ctx->Driver.ShadeModel)( ctx, mode );
+}
+
+
+void GLAPIENTRY
+_mesa_Lightf( GLenum light, GLenum pname, GLfloat param )
+{
+ _mesa_Lightfv( light, pname, &param );
+}
+
+
+void GLAPIENTRY
+_mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i = (GLint) (light - GL_LIGHT0);
+ struct gl_light *l = &ctx->Light.Light[i];
+
+ if (i < 0 || i >= (GLint) ctx->Const.MaxLights) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glLight(light=0x%x)", light );
+ return;
+ }
+
+ switch (pname) {
+ case GL_AMBIENT:
+ if (TEST_EQ_4V(l->Ambient, params))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ COPY_4V( l->Ambient, params );
+ break;
+ case GL_DIFFUSE:
+ if (TEST_EQ_4V(l->Diffuse, params))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ COPY_4V( l->Diffuse, params );
+ break;
+ case GL_SPECULAR:
+ if (TEST_EQ_4V(l->Specular, params))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ COPY_4V( l->Specular, params );
+ break;
+ case GL_POSITION: {
+ GLfloat tmp[4];
+ /* transform position by ModelView matrix */
+ TRANSFORM_POINT( tmp, ctx->ModelviewMatrixStack.Top->m, params );
+ if (TEST_EQ_4V(l->EyePosition, tmp))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ COPY_4V(l->EyePosition, tmp);
+ if (l->EyePosition[3] != 0.0F)
+ l->_Flags |= LIGHT_POSITIONAL;
+ else
+ l->_Flags &= ~LIGHT_POSITIONAL;
+ break;
+ }
+ case GL_SPOT_DIRECTION: {
+ GLfloat tmp[4];
+ /* transform direction by inverse modelview */
+ if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) {
+ _math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
+ }
+ TRANSFORM_NORMAL( tmp, params, ctx->ModelviewMatrixStack.Top->inv );
+ if (TEST_EQ_3V(l->EyeDirection, tmp))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ COPY_3V(l->EyeDirection, tmp);
+ break;
+ }
+ case GL_SPOT_EXPONENT:
+ if (params[0]<0.0 || params[0]>ctx->Const.MaxSpotExponent) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glLight" );
+ return;
+ }
+ if (l->SpotExponent == params[0])
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ l->SpotExponent = params[0];
+ _mesa_invalidate_spot_exp_table( l );
+ break;
+ case GL_SPOT_CUTOFF:
+ if ((params[0]<0.0 || params[0]>90.0) && params[0]!=180.0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glLight" );
+ return;
+ }
+ if (l->SpotCutoff == params[0])
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ l->SpotCutoff = params[0];
+ l->_CosCutoff = (GLfloat) _mesa_cos(params[0]*DEG2RAD);
+ if (l->_CosCutoff < 0)
+ l->_CosCutoff = 0;
+ if (l->SpotCutoff != 180.0F)
+ l->_Flags |= LIGHT_SPOT;
+ else
+ l->_Flags &= ~LIGHT_SPOT;
+ break;
+ case GL_CONSTANT_ATTENUATION:
+ if (params[0]<0.0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glLight" );
+ return;
+ }
+ if (l->ConstantAttenuation == params[0])
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ l->ConstantAttenuation = params[0];
+ break;
+ case GL_LINEAR_ATTENUATION:
+ if (params[0]<0.0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glLight" );
+ return;
+ }
+ if (l->LinearAttenuation == params[0])
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ l->LinearAttenuation = params[0];
+ break;
+ case GL_QUADRATIC_ATTENUATION:
+ if (params[0]<0.0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glLight" );
+ return;
+ }
+ if (l->QuadraticAttenuation == params[0])
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ l->QuadraticAttenuation = params[0];
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glLight(pname=0x%x)", pname );
+ return;
+ }
+
+ if (ctx->Driver.Lightfv)
+ ctx->Driver.Lightfv( ctx, light, pname, params );
+}
+
+
+void GLAPIENTRY
+_mesa_Lighti( GLenum light, GLenum pname, GLint param )
+{
+ _mesa_Lightiv( light, pname, &param );
+}
+
+
+void GLAPIENTRY
+_mesa_Lightiv( GLenum light, GLenum pname, const GLint *params )
+{
+ GLfloat fparam[4];
+
+ switch (pname) {
+ case GL_AMBIENT:
+ case GL_DIFFUSE:
+ case GL_SPECULAR:
+ fparam[0] = INT_TO_FLOAT( params[0] );
+ fparam[1] = INT_TO_FLOAT( params[1] );
+ fparam[2] = INT_TO_FLOAT( params[2] );
+ fparam[3] = INT_TO_FLOAT( params[3] );
+ break;
+ case GL_POSITION:
+ fparam[0] = (GLfloat) params[0];
+ fparam[1] = (GLfloat) params[1];
+ fparam[2] = (GLfloat) params[2];
+ fparam[3] = (GLfloat) params[3];
+ break;
+ case GL_SPOT_DIRECTION:
+ fparam[0] = (GLfloat) params[0];
+ fparam[1] = (GLfloat) params[1];
+ fparam[2] = (GLfloat) params[2];
+ break;
+ case GL_SPOT_EXPONENT:
+ case GL_SPOT_CUTOFF:
+ case GL_CONSTANT_ATTENUATION:
+ case GL_LINEAR_ATTENUATION:
+ case GL_QUADRATIC_ATTENUATION:
+ fparam[0] = (GLfloat) params[0];
+ break;
+ default:
+ /* error will be caught later in gl_Lightfv */
+ ;
+ }
+
+ _mesa_Lightfv( light, pname, fparam );
+}
+
+
+
+void GLAPIENTRY
+_mesa_GetLightfv( GLenum light, GLenum pname, GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint l = (GLint) (light - GL_LIGHT0);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (l < 0 || l >= (GLint) ctx->Const.MaxLights) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightfv" );
+ return;
+ }
+
+ switch (pname) {
+ case GL_AMBIENT:
+ COPY_4V( params, ctx->Light.Light[l].Ambient );
+ break;
+ case GL_DIFFUSE:
+ COPY_4V( params, ctx->Light.Light[l].Diffuse );
+ break;
+ case GL_SPECULAR:
+ COPY_4V( params, ctx->Light.Light[l].Specular );
+ break;
+ case GL_POSITION:
+ COPY_4V( params, ctx->Light.Light[l].EyePosition );
+ break;
+ case GL_SPOT_DIRECTION:
+ COPY_3V( params, ctx->Light.Light[l].EyeDirection );
+ break;
+ case GL_SPOT_EXPONENT:
+ params[0] = ctx->Light.Light[l].SpotExponent;
+ break;
+ case GL_SPOT_CUTOFF:
+ params[0] = ctx->Light.Light[l].SpotCutoff;
+ break;
+ case GL_CONSTANT_ATTENUATION:
+ params[0] = ctx->Light.Light[l].ConstantAttenuation;
+ break;
+ case GL_LINEAR_ATTENUATION:
+ params[0] = ctx->Light.Light[l].LinearAttenuation;
+ break;
+ case GL_QUADRATIC_ATTENUATION:
+ params[0] = ctx->Light.Light[l].QuadraticAttenuation;
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightfv" );
+ break;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetLightiv( GLenum light, GLenum pname, GLint *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint l = (GLint) (light - GL_LIGHT0);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (l < 0 || l >= (GLint) ctx->Const.MaxLights) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightiv" );
+ return;
+ }
+
+ switch (pname) {
+ case GL_AMBIENT:
+ params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[0]);
+ params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[1]);
+ params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[2]);
+ params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Ambient[3]);
+ break;
+ case GL_DIFFUSE:
+ params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[0]);
+ params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[1]);
+ params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[2]);
+ params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Diffuse[3]);
+ break;
+ case GL_SPECULAR:
+ params[0] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[0]);
+ params[1] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[1]);
+ params[2] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[2]);
+ params[3] = FLOAT_TO_INT(ctx->Light.Light[l].Specular[3]);
+ break;
+ case GL_POSITION:
+ params[0] = (GLint) ctx->Light.Light[l].EyePosition[0];
+ params[1] = (GLint) ctx->Light.Light[l].EyePosition[1];
+ params[2] = (GLint) ctx->Light.Light[l].EyePosition[2];
+ params[3] = (GLint) ctx->Light.Light[l].EyePosition[3];
+ break;
+ case GL_SPOT_DIRECTION:
+ params[0] = (GLint) ctx->Light.Light[l].EyeDirection[0];
+ params[1] = (GLint) ctx->Light.Light[l].EyeDirection[1];
+ params[2] = (GLint) ctx->Light.Light[l].EyeDirection[2];
+ break;
+ case GL_SPOT_EXPONENT:
+ params[0] = (GLint) ctx->Light.Light[l].SpotExponent;
+ break;
+ case GL_SPOT_CUTOFF:
+ params[0] = (GLint) ctx->Light.Light[l].SpotCutoff;
+ break;
+ case GL_CONSTANT_ATTENUATION:
+ params[0] = (GLint) ctx->Light.Light[l].ConstantAttenuation;
+ break;
+ case GL_LINEAR_ATTENUATION:
+ params[0] = (GLint) ctx->Light.Light[l].LinearAttenuation;
+ break;
+ case GL_QUADRATIC_ATTENUATION:
+ params[0] = (GLint) ctx->Light.Light[l].QuadraticAttenuation;
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetLightiv" );
+ break;
+ }
+}
+
+
+
+/**********************************************************************/
+/*** Light Model ***/
+/**********************************************************************/
+
+
+void GLAPIENTRY
+_mesa_LightModelfv( GLenum pname, const GLfloat *params )
+{
+ GLenum newenum;
+ GLboolean newbool;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ switch (pname) {
+ case GL_LIGHT_MODEL_AMBIENT:
+ if (TEST_EQ_4V( ctx->Light.Model.Ambient, params ))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ COPY_4V( ctx->Light.Model.Ambient, params );
+ break;
+ case GL_LIGHT_MODEL_LOCAL_VIEWER:
+ newbool = (params[0]!=0.0);
+ if (ctx->Light.Model.LocalViewer == newbool)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ ctx->Light.Model.LocalViewer = newbool;
+ break;
+ case GL_LIGHT_MODEL_TWO_SIDE:
+ newbool = (params[0]!=0.0);
+ if (ctx->Light.Model.TwoSide == newbool)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ ctx->Light.Model.TwoSide = newbool;
+
+ if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
+ ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
+ else
+ ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
+ break;
+ case GL_LIGHT_MODEL_COLOR_CONTROL:
+ if (params[0] == (GLfloat) GL_SINGLE_COLOR)
+ newenum = GL_SINGLE_COLOR;
+ else if (params[0] == (GLfloat) GL_SEPARATE_SPECULAR_COLOR)
+ newenum = GL_SEPARATE_SPECULAR_COLOR;
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glLightModel(param=0x0%x)",
+ (GLint) params[0] );
+ return;
+ }
+ if (ctx->Light.Model.ColorControl == newenum)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ ctx->Light.Model.ColorControl = newenum;
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glLightModel(pname=0x%x)", pname );
+ break;
+ }
+
+ if (ctx->Driver.LightModelfv)
+ ctx->Driver.LightModelfv( ctx, pname, params );
+}
+
+
+void GLAPIENTRY
+_mesa_LightModeliv( GLenum pname, const GLint *params )
+{
+ GLfloat fparam[4];
+
+ switch (pname) {
+ case GL_LIGHT_MODEL_AMBIENT:
+ fparam[0] = INT_TO_FLOAT( params[0] );
+ fparam[1] = INT_TO_FLOAT( params[1] );
+ fparam[2] = INT_TO_FLOAT( params[2] );
+ fparam[3] = INT_TO_FLOAT( params[3] );
+ break;
+ case GL_LIGHT_MODEL_LOCAL_VIEWER:
+ case GL_LIGHT_MODEL_TWO_SIDE:
+ case GL_LIGHT_MODEL_COLOR_CONTROL:
+ fparam[0] = (GLfloat) params[0];
+ break;
+ default:
+ /* Error will be caught later in gl_LightModelfv */
+ ;
+ }
+ _mesa_LightModelfv( pname, fparam );
+}
+
+
+void GLAPIENTRY
+_mesa_LightModeli( GLenum pname, GLint param )
+{
+ _mesa_LightModeliv( pname, &param );
+}
+
+
+void GLAPIENTRY
+_mesa_LightModelf( GLenum pname, GLfloat param )
+{
+ _mesa_LightModelfv( pname, &param );
+}
+
+
+
+/********** MATERIAL **********/
+
+
+/*
+ * Given a face and pname value (ala glColorMaterial), compute a bitmask
+ * of the targeted material values.
+ */
+GLuint
+_mesa_material_bitmask( GLcontext *ctx, GLenum face, GLenum pname,
+ GLuint legal, const char *where )
+{
+ GLuint bitmask = 0;
+
+ /* Make a bitmask indicating what material attribute(s) we're updating */
+ switch (pname) {
+ case GL_EMISSION:
+ bitmask |= MAT_BIT_FRONT_EMISSION | MAT_BIT_BACK_EMISSION;
+ break;
+ case GL_AMBIENT:
+ bitmask |= MAT_BIT_FRONT_AMBIENT | MAT_BIT_BACK_AMBIENT;
+ break;
+ case GL_DIFFUSE:
+ bitmask |= MAT_BIT_FRONT_DIFFUSE | MAT_BIT_BACK_DIFFUSE;
+ break;
+ case GL_SPECULAR:
+ bitmask |= MAT_BIT_FRONT_SPECULAR | MAT_BIT_BACK_SPECULAR;
+ break;
+ case GL_SHININESS:
+ bitmask |= MAT_BIT_FRONT_SHININESS | MAT_BIT_BACK_SHININESS;
+ break;
+ case GL_AMBIENT_AND_DIFFUSE:
+ bitmask |= MAT_BIT_FRONT_AMBIENT | MAT_BIT_BACK_AMBIENT;
+ bitmask |= MAT_BIT_FRONT_DIFFUSE | MAT_BIT_BACK_DIFFUSE;
+ break;
+ case GL_COLOR_INDEXES:
+ bitmask |= MAT_BIT_FRONT_INDEXES | MAT_BIT_BACK_INDEXES;
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, where );
+ return 0;
+ }
+
+ if (face==GL_FRONT) {
+ bitmask &= FRONT_MATERIAL_BITS;
+ }
+ else if (face==GL_BACK) {
+ bitmask &= BACK_MATERIAL_BITS;
+ }
+ else if (face != GL_FRONT_AND_BACK) {
+ _mesa_error( ctx, GL_INVALID_ENUM, where );
+ return 0;
+ }
+
+ if (bitmask & ~legal) {
+ _mesa_error( ctx, GL_INVALID_ENUM, where );
+ return 0;
+ }
+
+ return bitmask;
+}
+
+
+
+/* Perform a straight copy between materials.
+ */
+void
+_mesa_copy_materials( struct gl_material *dst,
+ const struct gl_material *src,
+ GLuint bitmask )
+{
+ int i;
+
+ for (i = 0 ; i < MAT_ATTRIB_MAX ; i++)
+ if (bitmask & (1<<i))
+ COPY_4FV( dst->Attrib[i], src->Attrib[i] );
+}
+
+
+
+/* Update derived values following a change in ctx->Light.Material
+ */
+void
+_mesa_update_material( GLcontext *ctx, GLuint bitmask )
+{
+ struct gl_light *light, *list = &ctx->Light.EnabledList;
+ GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
+
+ if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
+ _mesa_debug(ctx, "_mesa_update_material, mask 0x%x\n", bitmask);
+
+ if (!bitmask)
+ return;
+
+ /* update material ambience */
+ if (bitmask & MAT_BIT_FRONT_AMBIENT) {
+ foreach (light, list) {
+ SCALE_3V( light->_MatAmbient[0], light->Ambient,
+ mat[MAT_ATTRIB_FRONT_AMBIENT]);
+ }
+ }
+
+ if (bitmask & MAT_BIT_BACK_AMBIENT) {
+ foreach (light, list) {
+ SCALE_3V( light->_MatAmbient[1], light->Ambient,
+ mat[MAT_ATTRIB_BACK_AMBIENT]);
+ }
+ }
+
+ /* update BaseColor = emission + scene's ambience * material's ambience */
+ if (bitmask & (MAT_BIT_FRONT_EMISSION | MAT_BIT_FRONT_AMBIENT)) {
+ COPY_3V( ctx->Light._BaseColor[0], mat[MAT_ATTRIB_FRONT_EMISSION] );
+ ACC_SCALE_3V( ctx->Light._BaseColor[0], mat[MAT_ATTRIB_FRONT_AMBIENT],
+ ctx->Light.Model.Ambient );
+ }
+
+ if (bitmask & (MAT_BIT_BACK_EMISSION | MAT_BIT_BACK_AMBIENT)) {
+ COPY_3V( ctx->Light._BaseColor[1], mat[MAT_ATTRIB_BACK_EMISSION] );
+ ACC_SCALE_3V( ctx->Light._BaseColor[1], mat[MAT_ATTRIB_BACK_AMBIENT],
+ ctx->Light.Model.Ambient );
+ }
+
+ /* update material diffuse values */
+ if (bitmask & MAT_BIT_FRONT_DIFFUSE) {
+ foreach (light, list) {
+ SCALE_3V( light->_MatDiffuse[0], light->Diffuse,
+ mat[MAT_ATTRIB_FRONT_DIFFUSE] );
+ }
+ }
+
+ if (bitmask & MAT_BIT_BACK_DIFFUSE) {
+ foreach (light, list) {
+ SCALE_3V( light->_MatDiffuse[1], light->Diffuse,
+ mat[MAT_ATTRIB_BACK_DIFFUSE] );
+ }
+ }
+
+ /* update material specular values */
+ if (bitmask & MAT_BIT_FRONT_SPECULAR) {
+ foreach (light, list) {
+ SCALE_3V( light->_MatSpecular[0], light->Specular,
+ mat[MAT_ATTRIB_FRONT_SPECULAR]);
+ }
+ }
+
+ if (bitmask & MAT_BIT_BACK_SPECULAR) {
+ foreach (light, list) {
+ SCALE_3V( light->_MatSpecular[1], light->Specular,
+ mat[MAT_ATTRIB_BACK_SPECULAR]);
+ }
+ }
+
+ if (bitmask & MAT_BIT_FRONT_SHININESS) {
+ _mesa_invalidate_shine_table( ctx, 0 );
+ }
+
+ if (bitmask & MAT_BIT_BACK_SHININESS) {
+ _mesa_invalidate_shine_table( ctx, 1 );
+ }
+}
+
+
+/*
+ * Update the current materials from the given rgba color
+ * according to the bitmask in ColorMaterialBitmask, which is
+ * set by glColorMaterial().
+ */
+void
+_mesa_update_color_material( GLcontext *ctx, const GLfloat color[4] )
+{
+ GLuint bitmask = ctx->Light.ColorMaterialBitmask;
+ struct gl_material *mat = &ctx->Light.Material;
+ int i;
+
+ for (i = 0 ; i < MAT_ATTRIB_MAX ; i++)
+ if (bitmask & (1<<i))
+ COPY_4FV( mat->Attrib[i], color );
+
+ _mesa_update_material( ctx, bitmask );
+}
+
+
+void GLAPIENTRY
+_mesa_ColorMaterial( GLenum face, GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint bitmask;
+ GLuint legal = (MAT_BIT_FRONT_EMISSION | MAT_BIT_BACK_EMISSION |
+ MAT_BIT_FRONT_SPECULAR | MAT_BIT_BACK_SPECULAR |
+ MAT_BIT_FRONT_DIFFUSE | MAT_BIT_BACK_DIFFUSE |
+ MAT_BIT_FRONT_AMBIENT | MAT_BIT_BACK_AMBIENT);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE&VERBOSE_API)
+ _mesa_debug(ctx, "glColorMaterial %s %s\n",
+ _mesa_lookup_enum_by_nr(face),
+ _mesa_lookup_enum_by_nr(mode));
+
+ bitmask = _mesa_material_bitmask(ctx, face, mode, legal, "glColorMaterial");
+
+ if (ctx->Light.ColorMaterialBitmask == bitmask &&
+ ctx->Light.ColorMaterialFace == face &&
+ ctx->Light.ColorMaterialMode == mode)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_LIGHT);
+ ctx->Light.ColorMaterialBitmask = bitmask;
+ ctx->Light.ColorMaterialFace = face;
+ ctx->Light.ColorMaterialMode = mode;
+
+ if (ctx->Light.ColorMaterialEnabled) {
+ FLUSH_CURRENT( ctx, 0 );
+ _mesa_update_color_material(ctx,ctx->Current.Attrib[VERT_ATTRIB_COLOR0]);
+ }
+
+ if (ctx->Driver.ColorMaterial)
+ (*ctx->Driver.ColorMaterial)( ctx, face, mode );
+}
+
+
+void GLAPIENTRY
+_mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint f;
+ GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */
+
+ FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */
+
+ if (face==GL_FRONT) {
+ f = 0;
+ }
+ else if (face==GL_BACK) {
+ f = 1;
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(face)" );
+ return;
+ }
+
+ switch (pname) {
+ case GL_AMBIENT:
+ COPY_4FV( params, mat[MAT_ATTRIB_AMBIENT(f)] );
+ break;
+ case GL_DIFFUSE:
+ COPY_4FV( params, mat[MAT_ATTRIB_DIFFUSE(f)] );
+ break;
+ case GL_SPECULAR:
+ COPY_4FV( params, mat[MAT_ATTRIB_SPECULAR(f)] );
+ break;
+ case GL_EMISSION:
+ COPY_4FV( params, mat[MAT_ATTRIB_EMISSION(f)] );
+ break;
+ case GL_SHININESS:
+ *params = mat[MAT_ATTRIB_SHININESS(f)][0];
+ break;
+ case GL_COLOR_INDEXES:
+ params[0] = mat[MAT_ATTRIB_INDEXES(f)][0];
+ params[1] = mat[MAT_ATTRIB_INDEXES(f)][1];
+ params[2] = mat[MAT_ATTRIB_INDEXES(f)][2];
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" );
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint f;
+ GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* update materials */
+
+ FLUSH_CURRENT(ctx, 0); /* update ctx->Light.Material from vertex buffer */
+
+ if (face==GL_FRONT) {
+ f = 0;
+ }
+ else if (face==GL_BACK) {
+ f = 1;
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialiv(face)" );
+ return;
+ }
+ switch (pname) {
+ case GL_AMBIENT:
+ params[0] = FLOAT_TO_INT( mat[MAT_ATTRIB_AMBIENT(f)][0] );
+ params[1] = FLOAT_TO_INT( mat[MAT_ATTRIB_AMBIENT(f)][1] );
+ params[2] = FLOAT_TO_INT( mat[MAT_ATTRIB_AMBIENT(f)][2] );
+ params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_AMBIENT(f)][3] );
+ break;
+ case GL_DIFFUSE:
+ params[0] = FLOAT_TO_INT( mat[MAT_ATTRIB_DIFFUSE(f)][0] );
+ params[1] = FLOAT_TO_INT( mat[MAT_ATTRIB_DIFFUSE(f)][1] );
+ params[2] = FLOAT_TO_INT( mat[MAT_ATTRIB_DIFFUSE(f)][2] );
+ params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_DIFFUSE(f)][3] );
+ break;
+ case GL_SPECULAR:
+ params[0] = FLOAT_TO_INT( mat[MAT_ATTRIB_SPECULAR(f)][0] );
+ params[1] = FLOAT_TO_INT( mat[MAT_ATTRIB_SPECULAR(f)][1] );
+ params[2] = FLOAT_TO_INT( mat[MAT_ATTRIB_SPECULAR(f)][2] );
+ params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_SPECULAR(f)][3] );
+ break;
+ case GL_EMISSION:
+ params[0] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][0] );
+ params[1] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][1] );
+ params[2] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][2] );
+ params[3] = FLOAT_TO_INT( mat[MAT_ATTRIB_EMISSION(f)][3] );
+ break;
+ case GL_SHININESS:
+ *params = IROUND( mat[MAT_ATTRIB_SHININESS(f)][0] );
+ break;
+ case GL_COLOR_INDEXES:
+ params[0] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][0] );
+ params[1] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][1] );
+ params[2] = IROUND( mat[MAT_ATTRIB_INDEXES(f)][2] );
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetMaterialfv(pname)" );
+ }
+}
+
+
+
+/**********************************************************************/
+/***** Lighting computation *****/
+/**********************************************************************/
+
+
+/*
+ * Notes:
+ * When two-sided lighting is enabled we compute the color (or index)
+ * for both the front and back side of the primitive. Then, when the
+ * orientation of the facet is later learned, we can determine which
+ * color (or index) to use for rendering.
+ *
+ * KW: We now know orientation in advance and only shade for
+ * the side or sides which are actually required.
+ *
+ * Variables:
+ * n = normal vector
+ * V = vertex position
+ * P = light source position
+ * Pe = (0,0,0,1)
+ *
+ * Precomputed:
+ * IF P[3]==0 THEN
+ * // light at infinity
+ * IF local_viewer THEN
+ * _VP_inf_norm = unit vector from V to P // Precompute
+ * ELSE
+ * // eye at infinity
+ * _h_inf_norm = Normalize( VP + <0,0,1> ) // Precompute
+ * ENDIF
+ * ENDIF
+ *
+ * Functions:
+ * Normalize( v ) = normalized vector v
+ * Magnitude( v ) = length of vector v
+ */
+
+
+
+/*
+ * Whenever the spotlight exponent for a light changes we must call
+ * this function to recompute the exponent lookup table.
+ */
+void
+_mesa_invalidate_spot_exp_table( struct gl_light *l )
+{
+ l->_SpotExpTable[0][0] = -1;
+}
+
+
+static void
+validate_spot_exp_table( struct gl_light *l )
+{
+ GLint i;
+ GLdouble exponent = l->SpotExponent;
+ GLdouble tmp = 0;
+ GLint clamp = 0;
+
+ l->_SpotExpTable[0][0] = 0.0;
+
+ for (i = EXP_TABLE_SIZE - 1; i > 0 ;i--) {
+ if (clamp == 0) {
+ tmp = _mesa_pow(i / (GLdouble) (EXP_TABLE_SIZE - 1), exponent);
+ if (tmp < FLT_MIN * 100.0) {
+ tmp = 0.0;
+ clamp = 1;
+ }
+ }
+ l->_SpotExpTable[i][0] = (GLfloat) tmp;
+ }
+ for (i = 0; i < EXP_TABLE_SIZE - 1; i++) {
+ l->_SpotExpTable[i][1] = (l->_SpotExpTable[i+1][0] -
+ l->_SpotExpTable[i][0]);
+ }
+ l->_SpotExpTable[EXP_TABLE_SIZE-1][1] = 0.0;
+}
+
+
+
+/* Calculate a new shine table. Doing this here saves a branch in
+ * lighting, and the cost of doing it early may be partially offset
+ * by keeping a MRU cache of shine tables for various shine values.
+ */
+void
+_mesa_invalidate_shine_table( GLcontext *ctx, GLuint side )
+{
+ ASSERT(side < 2);
+ if (ctx->_ShineTable[side])
+ ctx->_ShineTable[side]->refcount--;
+ ctx->_ShineTable[side] = NULL;
+}
+
+
+static void
+validate_shine_table( GLcontext *ctx, GLuint side, GLfloat shininess )
+{
+ struct gl_shine_tab *list = ctx->_ShineTabList;
+ struct gl_shine_tab *s;
+
+ ASSERT(side < 2);
+
+ foreach(s, list)
+ if ( s->shininess == shininess )
+ break;
+
+ if (s == list) {
+ GLint j;
+ GLfloat *m;
+
+ foreach(s, list)
+ if (s->refcount == 0)
+ break;
+
+ m = s->tab;
+ m[0] = 0.0;
+ if (shininess == 0.0) {
+ for (j = 1 ; j <= SHINE_TABLE_SIZE ; j++)
+ m[j] = 1.0;
+ }
+ else {
+ for (j = 1 ; j < SHINE_TABLE_SIZE ; j++) {
+ GLdouble t, x = j / (GLfloat) (SHINE_TABLE_SIZE - 1);
+ if (x < 0.005) /* underflow check */
+ x = 0.005;
+ t = _mesa_pow(x, shininess);
+ if (t > 1e-20)
+ m[j] = (GLfloat) t;
+ else
+ m[j] = 0.0;
+ }
+ m[SHINE_TABLE_SIZE] = 1.0;
+ }
+
+ s->shininess = shininess;
+ }
+
+ if (ctx->_ShineTable[side])
+ ctx->_ShineTable[side]->refcount--;
+
+ ctx->_ShineTable[side] = s;
+ move_to_tail( list, s );
+ s->refcount++;
+}
+
+
+void
+_mesa_validate_all_lighting_tables( GLcontext *ctx )
+{
+ GLuint i;
+ GLfloat shininess;
+
+ shininess = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SHININESS][0];
+ if (!ctx->_ShineTable[0] || ctx->_ShineTable[0]->shininess != shininess)
+ validate_shine_table( ctx, 0, shininess );
+
+ shininess = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_SHININESS][0];
+ if (!ctx->_ShineTable[1] || ctx->_ShineTable[1]->shininess != shininess)
+ validate_shine_table( ctx, 1, shininess );
+
+ for (i = 0 ; i < MAX_LIGHTS ; i++)
+ if (ctx->Light.Light[i]._SpotExpTable[0][0] == -1)
+ validate_spot_exp_table( &ctx->Light.Light[i] );
+}
+
+
+
+/*
+ * Examine current lighting parameters to determine if the optimized lighting
+ * function can be used.
+ * Also, precompute some lighting values such as the products of light
+ * source and material ambient, diffuse and specular coefficients.
+ */
+void
+_mesa_update_lighting( GLcontext *ctx )
+{
+ struct gl_light *light;
+ ctx->Light._NeedEyeCoords = 0;
+ ctx->Light._Flags = 0;
+
+ if (!ctx->Light.Enabled)
+ return;
+
+ foreach(light, &ctx->Light.EnabledList) {
+ ctx->Light._Flags |= light->_Flags;
+ }
+
+ ctx->Light._NeedVertices =
+ ((ctx->Light._Flags & (LIGHT_POSITIONAL|LIGHT_SPOT)) ||
+ ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR ||
+ ctx->Light.Model.LocalViewer);
+
+ ctx->Light._NeedEyeCoords = ((ctx->Light._Flags & LIGHT_POSITIONAL) ||
+ ctx->Light.Model.LocalViewer);
+
+
+
+ /* XXX: This test is overkill & needs to be fixed both for software and
+ * hardware t&l drivers. The above should be sufficient & should
+ * be tested to verify this.
+ */
+ if (ctx->Light._NeedVertices)
+ ctx->Light._NeedEyeCoords = GL_TRUE;
+
+
+ /* Precompute some shading values. Although we reference
+ * Light.Material here, we can get away without flushing
+ * FLUSH_UPDATE_CURRENT, as when any outstanding material changes
+ * are flushed, they will update the derived state at that time.
+ */
+ if (ctx->Visual.rgbMode) {
+ if (ctx->Light.Model.TwoSide)
+ _mesa_update_material( ctx,
+ MAT_BIT_FRONT_EMISSION |
+ MAT_BIT_FRONT_AMBIENT |
+ MAT_BIT_FRONT_DIFFUSE |
+ MAT_BIT_FRONT_SPECULAR |
+ MAT_BIT_BACK_EMISSION |
+ MAT_BIT_BACK_AMBIENT |
+ MAT_BIT_BACK_DIFFUSE |
+ MAT_BIT_BACK_SPECULAR);
+ else
+ _mesa_update_material( ctx,
+ MAT_BIT_FRONT_EMISSION |
+ MAT_BIT_FRONT_AMBIENT |
+ MAT_BIT_FRONT_DIFFUSE |
+ MAT_BIT_FRONT_SPECULAR);
+ }
+ else {
+ static const GLfloat ci[3] = { .30F, .59F, .11F };
+ foreach(light, &ctx->Light.EnabledList) {
+ light->_dli = DOT3(ci, light->Diffuse);
+ light->_sli = DOT3(ci, light->Specular);
+ }
+ }
+}
+
+
+/* _NEW_MODELVIEW
+ * _NEW_LIGHT
+ * _TNL_NEW_NEED_EYE_COORDS
+ *
+ * Update on (_NEW_MODELVIEW | _NEW_LIGHT) when lighting is enabled.
+ * Also update on lighting space changes.
+ */
+static void
+compute_light_positions( GLcontext *ctx )
+{
+ struct gl_light *light;
+ static const GLfloat eye_z[3] = { 0, 0, 1 };
+
+ if (!ctx->Light.Enabled)
+ return;
+
+ if (ctx->_NeedEyeCoords) {
+ COPY_3V( ctx->_EyeZDir, eye_z );
+ }
+ else {
+ TRANSFORM_NORMAL( ctx->_EyeZDir, eye_z, ctx->ModelviewMatrixStack.Top->m );
+ }
+
+ foreach (light, &ctx->Light.EnabledList) {
+
+ if (ctx->_NeedEyeCoords) {
+ COPY_4FV( light->_Position, light->EyePosition );
+ }
+ else {
+ TRANSFORM_POINT( light->_Position, ctx->ModelviewMatrixStack.Top->inv,
+ light->EyePosition );
+ }
+
+ if (!(light->_Flags & LIGHT_POSITIONAL)) {
+ /* VP (VP) = Normalize( Position ) */
+ COPY_3V( light->_VP_inf_norm, light->_Position );
+ NORMALIZE_3FV( light->_VP_inf_norm );
+
+ if (!ctx->Light.Model.LocalViewer) {
+ /* _h_inf_norm = Normalize( V_to_P + <0,0,1> ) */
+ ADD_3V( light->_h_inf_norm, light->_VP_inf_norm, ctx->_EyeZDir);
+ NORMALIZE_3FV( light->_h_inf_norm );
+ }
+ light->_VP_inf_spot_attenuation = 1.0;
+ }
+
+ if (light->_Flags & LIGHT_SPOT) {
+ if (ctx->_NeedEyeCoords) {
+ COPY_3V( light->_NormDirection, light->EyeDirection );
+ }
+ else {
+ TRANSFORM_NORMAL( light->_NormDirection,
+ light->EyeDirection,
+ ctx->ModelviewMatrixStack.Top->m);
+ }
+
+ NORMALIZE_3FV( light->_NormDirection );
+
+ if (!(light->_Flags & LIGHT_POSITIONAL)) {
+ GLfloat PV_dot_dir = - DOT3(light->_VP_inf_norm,
+ light->_NormDirection);
+
+ if (PV_dot_dir > light->_CosCutoff) {
+ double x = PV_dot_dir * (EXP_TABLE_SIZE-1);
+ int k = (int) x;
+ light->_VP_inf_spot_attenuation =
+ (GLfloat) (light->_SpotExpTable[k][0] +
+ (x-k)*light->_SpotExpTable[k][1]);
+ }
+ else {
+ light->_VP_inf_spot_attenuation = 0;
+ }
+ }
+ }
+ }
+}
+
+
+
+static void
+update_modelview_scale( GLcontext *ctx )
+{
+ ctx->_ModelViewInvScale = 1.0F;
+ if (!_math_matrix_is_length_preserving(ctx->ModelviewMatrixStack.Top)) {
+ const GLfloat *m = ctx->ModelviewMatrixStack.Top->inv;
+ GLfloat f = m[2] * m[2] + m[6] * m[6] + m[10] * m[10];
+ if (f < 1e-12) f = 1.0;
+ if (ctx->_NeedEyeCoords)
+ ctx->_ModelViewInvScale = (GLfloat) INV_SQRTF(f);
+ else
+ ctx->_ModelViewInvScale = (GLfloat) SQRTF(f);
+ }
+}
+
+
+/* Bring uptodate any state that relies on _NeedEyeCoords.
+ */
+void
+_mesa_update_tnl_spaces( GLcontext *ctx, GLuint new_state )
+{
+ const GLuint oldneedeyecoords = ctx->_NeedEyeCoords;
+
+ (void) new_state;
+ ctx->_NeedEyeCoords = 0;
+
+ if (ctx->_ForceEyeCoords ||
+ (ctx->Texture._GenFlags & TEXGEN_NEED_EYE_COORD) ||
+ ctx->Point._Attenuated ||
+ ctx->Light._NeedEyeCoords)
+ ctx->_NeedEyeCoords = 1;
+
+ if (ctx->Light.Enabled &&
+ !_math_matrix_is_length_preserving(ctx->ModelviewMatrixStack.Top))
+ ctx->_NeedEyeCoords = 1;
+
+
+ /* Check if the truth-value interpretations of the bitfields have
+ * changed:
+ */
+ if (oldneedeyecoords != ctx->_NeedEyeCoords) {
+ /* Recalculate all state that depends on _NeedEyeCoords.
+ */
+ update_modelview_scale(ctx);
+ compute_light_positions( ctx );
+
+ if (ctx->Driver.LightingSpaceChange)
+ ctx->Driver.LightingSpaceChange( ctx );
+ }
+ else {
+ GLuint new_state = ctx->NewState;
+
+ /* Recalculate that same state only if it has been invalidated
+ * by other statechanges.
+ */
+ if (new_state & _NEW_MODELVIEW)
+ update_modelview_scale(ctx);
+
+ if (new_state & (_NEW_LIGHT|_NEW_MODELVIEW))
+ compute_light_positions( ctx );
+ }
+}
+
+
+/* Drivers may need this if the hardware tnl unit doesn't support the
+ * light-in-modelspace optimization. It's also useful for debugging.
+ */
+void
+_mesa_allow_light_in_model( GLcontext *ctx, GLboolean flag )
+{
+ ctx->_ForceEyeCoords = !flag;
+ ctx->NewState |= _NEW_POINT; /* one of the bits from
+ * _MESA_NEW_NEED_EYE_COORDS.
+ */
+}
+
+
+
+/**********************************************************************/
+/***** Initialization *****/
+/**********************************************************************/
+
+/**
+ * Initialize the n-th light data structure.
+ *
+ * \param l pointer to the gl_light structure to be initialized.
+ * \param n number of the light.
+ * \note The defaults for light 0 are different than the other lights.
+ */
+static void
+init_light( struct gl_light *l, GLuint n )
+{
+ make_empty_list( l );
+
+ ASSIGN_4V( l->Ambient, 0.0, 0.0, 0.0, 1.0 );
+ if (n==0) {
+ ASSIGN_4V( l->Diffuse, 1.0, 1.0, 1.0, 1.0 );
+ ASSIGN_4V( l->Specular, 1.0, 1.0, 1.0, 1.0 );
+ }
+ else {
+ ASSIGN_4V( l->Diffuse, 0.0, 0.0, 0.0, 1.0 );
+ ASSIGN_4V( l->Specular, 0.0, 0.0, 0.0, 1.0 );
+ }
+ ASSIGN_4V( l->EyePosition, 0.0, 0.0, 1.0, 0.0 );
+ ASSIGN_3V( l->EyeDirection, 0.0, 0.0, -1.0 );
+ l->SpotExponent = 0.0;
+ _mesa_invalidate_spot_exp_table( l );
+ l->SpotCutoff = 180.0;
+ l->_CosCutoff = 0.0; /* KW: -ve values not admitted */
+ l->ConstantAttenuation = 1.0;
+ l->LinearAttenuation = 0.0;
+ l->QuadraticAttenuation = 0.0;
+ l->Enabled = GL_FALSE;
+}
+
+
+/**
+ * Initialize the light model data structure.
+ *
+ * \param lm pointer to the gl_lightmodel structure to be initialized.
+ */
+static void
+init_lightmodel( struct gl_lightmodel *lm )
+{
+ ASSIGN_4V( lm->Ambient, 0.2F, 0.2F, 0.2F, 1.0F );
+ lm->LocalViewer = GL_FALSE;
+ lm->TwoSide = GL_FALSE;
+ lm->ColorControl = GL_SINGLE_COLOR;
+}
+
+
+/**
+ * Initialize the material data structure.
+ *
+ * \param m pointer to the gl_material structure to be initialized.
+ */
+static void
+init_material( struct gl_material *m )
+{
+ ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_AMBIENT], 0.2F, 0.2F, 0.2F, 1.0F );
+ ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_DIFFUSE], 0.8F, 0.8F, 0.8F, 1.0F );
+ ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_SPECULAR], 0.0F, 0.0F, 0.0F, 1.0F );
+ ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_EMISSION], 0.0F, 0.0F, 0.0F, 1.0F );
+ ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_SHININESS], 0.0F, 0.0F, 0.0F, 0.0F );
+ ASSIGN_4V( m->Attrib[MAT_ATTRIB_FRONT_INDEXES], 0.0F, 1.0F, 1.0F, 0.0F );
+
+ ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_AMBIENT], 0.2F, 0.2F, 0.2F, 1.0F );
+ ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_DIFFUSE], 0.8F, 0.8F, 0.8F, 1.0F );
+ ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_SPECULAR], 0.0F, 0.0F, 0.0F, 1.0F );
+ ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_EMISSION], 0.0F, 0.0F, 0.0F, 1.0F );
+ ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_SHININESS], 0.0F, 0.0F, 0.0F, 0.0F );
+ ASSIGN_4V( m->Attrib[MAT_ATTRIB_BACK_INDEXES], 0.0F, 1.0F, 1.0F, 0.0F );
+}
+
+
+void
+_mesa_init_lighting( GLcontext *ctx )
+{
+ GLuint i;
+
+ /* Lighting group */
+ for (i = 0; i < MAX_LIGHTS; i++) {
+ init_light( &ctx->Light.Light[i], i );
+ }
+ make_empty_list( &ctx->Light.EnabledList );
+
+ init_lightmodel( &ctx->Light.Model );
+ init_material( &ctx->Light.Material );
+ ctx->Light.ShadeModel = GL_SMOOTH;
+ ctx->Light.Enabled = GL_FALSE;
+ ctx->Light.ColorMaterialFace = GL_FRONT_AND_BACK;
+ ctx->Light.ColorMaterialMode = GL_AMBIENT_AND_DIFFUSE;
+ ctx->Light.ColorMaterialBitmask = _mesa_material_bitmask( ctx,
+ GL_FRONT_AND_BACK,
+ GL_AMBIENT_AND_DIFFUSE, ~0,
+ NULL );
+
+ ctx->Light.ColorMaterialEnabled = GL_FALSE;
+
+ /* Lighting miscellaneous */
+ ctx->_ShineTabList = MALLOC_STRUCT( gl_shine_tab );
+ make_empty_list( ctx->_ShineTabList );
+ /* Allocate 10 (arbitrary) shininess lookup tables */
+ for (i = 0 ; i < 10 ; i++) {
+ struct gl_shine_tab *s = MALLOC_STRUCT( gl_shine_tab );
+ s->shininess = -1;
+ s->refcount = 0;
+ insert_at_tail( ctx->_ShineTabList, s );
+ }
+
+ /* Miscellaneous */
+ ctx->Light._NeedEyeCoords = 0;
+ ctx->_NeedEyeCoords = 0;
+ ctx->_ModelViewInvScale = 1.0;
+}
+
+
+void
+_mesa_free_lighting_data( GLcontext *ctx )
+{
+ struct gl_shine_tab *s, *tmps;
+
+ /* Free lighting shininess exponentiation table */
+ foreach_s( s, tmps, ctx->_ShineTabList ) {
+ FREE( s );
+ }
+ FREE( ctx->_ShineTabList );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/light.h b/nx-X11/extras/Mesa/src/mesa/main/light.h
new file mode 100644
index 000000000..1f1901945
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/light.h
@@ -0,0 +1,141 @@
+/**
+ * \file light.h
+ * Lighting.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef LIGHT_H
+#define LIGHT_H
+
+
+#include "mtypes.h"
+
+extern void GLAPIENTRY
+_mesa_ShadeModel( GLenum mode );
+
+#if _HAVE_FULL_GL
+extern void GLAPIENTRY
+_mesa_ColorMaterial( GLenum face, GLenum mode );
+
+extern void GLAPIENTRY
+_mesa_Lightf( GLenum light, GLenum pname, GLfloat param );
+
+extern void GLAPIENTRY
+_mesa_Lightfv( GLenum light, GLenum pname, const GLfloat *params );
+
+extern void GLAPIENTRY
+_mesa_Lightiv( GLenum light, GLenum pname, const GLint *params );
+
+extern void GLAPIENTRY
+_mesa_Lighti( GLenum light, GLenum pname, GLint param );
+
+extern void GLAPIENTRY
+_mesa_LightModelf( GLenum pname, GLfloat param );
+
+extern void GLAPIENTRY
+_mesa_LightModelfv( GLenum pname, const GLfloat *params );
+
+extern void GLAPIENTRY
+_mesa_LightModeli( GLenum pname, GLint param );
+
+extern void GLAPIENTRY
+_mesa_LightModeliv( GLenum pname, const GLint *params );
+
+extern void GLAPIENTRY
+_mesa_GetLightfv( GLenum light, GLenum pname, GLfloat *params );
+
+extern void GLAPIENTRY
+_mesa_GetLightiv( GLenum light, GLenum pname, GLint *params );
+
+extern void GLAPIENTRY
+_mesa_GetMaterialfv( GLenum face, GLenum pname, GLfloat *params );
+
+extern void GLAPIENTRY
+_mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params );
+
+
+/* Lerp between adjacent values in the f(x) lookup table, giving a
+ * continuous function, with adequeate overall accuracy. (Though
+ * still pretty good compared to a straight lookup).
+ * Result should be a GLfloat.
+ */
+#define GET_SHINE_TAB_ENTRY( table, dp, result ) \
+do { \
+ struct gl_shine_tab *_tab = table; \
+ float f = (dp * (SHINE_TABLE_SIZE-1)); \
+ int k = (int) f; \
+ if (k > SHINE_TABLE_SIZE-2) \
+ result = (GLfloat) _mesa_pow( dp, _tab->shininess ); \
+ else \
+ result = _tab->tab[k] + (f-k)*(_tab->tab[k+1]-_tab->tab[k]); \
+} while (0)
+
+
+extern GLuint _mesa_material_bitmask( GLcontext *ctx,
+ GLenum face, GLenum pname,
+ GLuint legal,
+ const char * );
+
+extern void _mesa_invalidate_spot_exp_table( struct gl_light *l );
+
+extern void _mesa_invalidate_shine_table( GLcontext *ctx, GLuint i );
+
+extern void _mesa_validate_all_lighting_tables( GLcontext *ctx );
+
+extern void _mesa_update_lighting( GLcontext *ctx );
+
+extern void _mesa_update_tnl_spaces( GLcontext *ctx, GLuint new_state );
+
+extern void _mesa_update_material( GLcontext *ctx,
+ GLuint bitmask );
+
+extern void _mesa_copy_materials( struct gl_material *dst,
+ const struct gl_material *src,
+ GLuint bitmask );
+
+extern void _mesa_update_color_material( GLcontext *ctx,
+ const GLfloat rgba[4] );
+
+extern void _mesa_init_lighting( GLcontext *ctx );
+
+extern void _mesa_free_lighting_data( GLcontext *ctx );
+
+extern void _mesa_allow_light_in_model( GLcontext *ctx, GLboolean flag );
+
+#else
+#define _mesa_update_color_material( c, r ) ((void)0)
+#define _mesa_validate_all_lighting_tables( c ) ((void)0)
+#define _mesa_invalidate_spot_exp_table( l ) ((void)0)
+#define _mesa_material_bitmask( c, f, p, l, s ) 0
+#define _mesa_init_lighting( c ) ((void)0)
+#define _mesa_free_lighting_data( c ) ((void)0)
+#define _mesa_update_lighting( c ) ((void)0)
+#define _mesa_update_tnl_spaces( c, n ) ((void)0)
+#define GET_SHINE_TAB_ENTRY( table, dp, result ) ((result)=0)
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/lines.c b/nx-X11/extras/Mesa/src/mesa/main/lines.c
new file mode 100644
index 000000000..c30d9ac10
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/lines.c
@@ -0,0 +1,134 @@
+/**
+ * \file lines.c
+ * Line operations.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "depth.h"
+#include "lines.h"
+#include "macros.h"
+#include "texstate.h"
+#include "mtypes.h"
+
+
+/**
+ * Set the line width.
+ *
+ * \param width line width in pixels.
+ *
+ * \sa glLineWidth().
+ *
+ * Verifies the parameter and updates gl_line_attrib::Width. On a change,
+ * flushes the vertices, updates the clamped line width and marks the
+ * DD_LINE_WIDTH flag in __GLcontextRec::_TriangleCaps for the drivers if the
+ * width is different from one. Notifies the driver via the
+ * dd_function_table::LineWidth callback.
+ */
+void GLAPIENTRY
+_mesa_LineWidth( GLfloat width )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (width<=0.0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glLineWidth" );
+ return;
+ }
+
+ if (ctx->Line.Width == width)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_LINE);
+ ctx->Line.Width = width;
+ ctx->Line._Width = CLAMP(width,
+ ctx->Const.MinLineWidth,
+ ctx->Const.MaxLineWidth);
+
+
+ if (width != 1.0)
+ ctx->_TriangleCaps |= DD_LINE_WIDTH;
+ else
+ ctx->_TriangleCaps &= ~DD_LINE_WIDTH;
+
+ if (ctx->Driver.LineWidth)
+ (*ctx->Driver.LineWidth)(ctx, width);
+}
+
+
+/**
+ * Set the line stipple pattern.
+ *
+ * \param factor pattern scale factor.
+ * \param pattern bit pattern.
+ *
+ * \sa glLineStipple().
+ *
+ * Updates gl_line_attrib::StippleFactor and gl_line_attrib::StipplePattern. On
+ * change flushes the vertices and notifies the driver via
+ * the dd_function_table::LineStipple callback.
+ */
+void GLAPIENTRY
+_mesa_LineStipple( GLint factor, GLushort pattern )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ factor = CLAMP( factor, 1, 256 );
+
+ if (ctx->Line.StippleFactor == factor &&
+ ctx->Line.StipplePattern == pattern)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_LINE);
+ ctx->Line.StippleFactor = factor;
+ ctx->Line.StipplePattern = pattern;
+
+ if (ctx->Driver.LineStipple)
+ ctx->Driver.LineStipple( ctx, factor, pattern );
+}
+
+
+/**
+ * Initialize the context line state.
+ *
+ * \param ctx GL context.
+ *
+ * Initializes __GLcontextRec::Line and line related constants in
+ * __GLcontextRec::Const.
+ */
+void GLAPIENTRY _mesa_init_line( GLcontext * ctx )
+{
+ /* Line group */
+ ctx->Line.SmoothFlag = GL_FALSE;
+ ctx->Line.StippleFlag = GL_FALSE;
+ ctx->Line.Width = 1.0;
+ ctx->Line._Width = 1.0;
+ ctx->Line.StipplePattern = 0xffff;
+ ctx->Line.StippleFactor = 1;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/lines.h b/nx-X11/extras/Mesa/src/mesa/main/lines.h
new file mode 100644
index 000000000..5a47e9858
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/lines.h
@@ -0,0 +1,48 @@
+/**
+ * \file lines.h
+ * Line operations.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+
+#ifndef LINES_H
+#define LINES_H
+
+
+#include "mtypes.h"
+
+
+extern void GLAPIENTRY
+_mesa_LineWidth( GLfloat width );
+
+extern void GLAPIENTRY
+_mesa_LineStipple( GLint factor, GLushort pattern );
+
+extern void GLAPIENTRY
+_mesa_init_line( GLcontext * ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/macros.h b/nx-X11/extras/Mesa/src/mesa/main/macros.h
new file mode 100644
index 000000000..a398dd812
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/macros.h
@@ -0,0 +1,654 @@
+/**
+ * \file macros.h
+ * A collection of useful macros.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.0
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef MACROS_H
+#define MACROS_H
+
+#include "imports.h"
+
+
+/**
+ * \name Integer / float conversion for colors, normals, etc.
+ */
+/*@{*/
+
+/** Convert GLubyte in [0,255] to GLfloat in [0.0,1.0] */
+extern GLfloat _mesa_ubyte_to_float_color_tab[256];
+#define UBYTE_TO_FLOAT(u) _mesa_ubyte_to_float_color_tab[(unsigned int)(u)]
+
+/** Convert GLfloat in [0.0,1.0] to GLubyte in [0,255] */
+#define FLOAT_TO_UBYTE(X) ((GLubyte) (GLint) ((X) * 255.0F))
+
+
+/** Convert GLbyte in [-128,127] to GLfloat in [-1.0,1.0] */
+#define BYTE_TO_FLOAT(B) ((2.0F * (B) + 1.0F) * (1.0F/255.0F))
+
+/** Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127] */
+#define FLOAT_TO_BYTE(X) ( (((GLint) (255.0F * (X))) - 1) / 2 )
+
+
+/** Convert GLushort in [0,65536] to GLfloat in [0.0,1.0] */
+#define USHORT_TO_FLOAT(S) ((GLfloat) (S) * (1.0F / 65535.0F))
+
+/** Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0] */
+#define SHORT_TO_FLOAT(S) ((2.0F * (S) + 1.0F) * (1.0F/65535.0F))
+
+/** Convert GLfloat in [0.0,1.0] to GLshort in [-32768,32767] */
+#define FLOAT_TO_SHORT(X) ( (((GLint) (65535.0F * (X))) - 1) / 2 )
+
+
+/** Convert GLuint in [0,4294967295] to GLfloat in [0.0,1.0] */
+#define UINT_TO_FLOAT(U) ((GLfloat) (U) * (1.0F / 4294967295.0F))
+
+/** Convert GLfloat in [0.0,1.0] to GLuint in [0,4294967295] */
+#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0))
+
+
+/** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0] */
+#define INT_TO_FLOAT(I) ((2.0F * (I) + 1.0F) * (1.0F/4294967294.0F))
+
+/** Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647] */
+/* causes overflow:
+#define FLOAT_TO_INT(X) ( (((GLint) (4294967294.0F * (X))) - 1) / 2 )
+*/
+/* a close approximation: */
+#define FLOAT_TO_INT(X) ( (GLint) (2147483647.0 * (X)) )
+
+
+#define BYTE_TO_UBYTE(b) ((GLubyte) ((b) < 0 ? 0 : (GLubyte) (b)))
+#define SHORT_TO_UBYTE(s) ((GLubyte) ((s) < 0 ? 0 : (GLubyte) ((s) >> 7)))
+#define USHORT_TO_UBYTE(s) ((GLubyte) ((s) >> 8))
+#define INT_TO_UBYTE(i) ((GLubyte) ((i) < 0 ? 0 : (GLubyte) ((i) >> 23)))
+#define UINT_TO_UBYTE(i) ((GLubyte) ((i) >> 24))
+
+
+#define BYTE_TO_USHORT(b) ((b) < 0 ? 0 : ((GLushort) (((b) * 65535) / 255)))
+#define UBYTE_TO_USHORT(b) (((GLushort) (b) << 8) | (GLushort) (b))
+#define SHORT_TO_USHORT(s) ((s) < 0 ? 0 : ((GLushort) (((s) * 65535 / 32767))))
+#define INT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 15)))
+#define UINT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 16)))
+#define UNCLAMPED_FLOAT_TO_USHORT(us, f) \
+ us = ( (GLushort) IROUND( CLAMP((f), 0.0, 1.0) * 65535.0F) )
+#define CLAMPED_FLOAT_TO_USHORT(us, f) \
+ us = ( (GLushort) IROUND( (f) * 65535.0F) )
+
+/*@}*/
+
+
+/** Stepping a GLfloat pointer by a byte stride */
+#define STRIDE_F(p, i) (p = (GLfloat *)((GLubyte *)p + i))
+/** Stepping a GLuint pointer by a byte stride */
+#define STRIDE_UI(p, i) (p = (GLuint *)((GLubyte *)p + i))
+/** Stepping a GLubyte[4] pointer by a byte stride */
+#define STRIDE_4UB(p, i) (p = (GLubyte (*)[4])((GLubyte *)p + i))
+/** Stepping a GLfloat[4] pointer by a byte stride */
+#define STRIDE_4F(p, i) (p = (GLfloat (*)[4])((GLubyte *)p + i))
+/** Stepping a GLchan[4] pointer by a byte stride */
+#define STRIDE_4CHAN(p, i) (p = (GLchan (*)[4])((GLubyte *)p + i))
+/** Stepping a GLchan pointer by a byte stride */
+#define STRIDE_CHAN(p, i) (p = (GLchan *)((GLubyte *)p + i))
+/** Stepping a \p t pointer by a byte stride */
+#define STRIDE_T(p, t, i) (p = (t)((GLubyte *)p + i))
+
+
+/**********************************************************************/
+/** \name 4-element vector operations */
+/*@{*/
+
+/** Zero */
+#define ZERO_4V( DST ) (DST)[0] = (DST)[1] = (DST)[2] = (DST)[3] = 0
+
+/** Test for equality */
+#define TEST_EQ_4V(a,b) ((a)[0] == (b)[0] && \
+ (a)[1] == (b)[1] && \
+ (a)[2] == (b)[2] && \
+ (a)[3] == (b)[3])
+
+/** Test for equality (unsigned bytes) */
+#if defined(__i386__)
+#define TEST_EQ_4UBV(DST, SRC) *((GLuint*)(DST)) == *((GLuint*)(SRC))
+#else
+#define TEST_EQ_4UBV(DST, SRC) TEST_EQ_4V(DST, SRC)
+#endif
+
+/** Copy a 4-element vector */
+#define COPY_4V( DST, SRC ) \
+do { \
+ (DST)[0] = (SRC)[0]; \
+ (DST)[1] = (SRC)[1]; \
+ (DST)[2] = (SRC)[2]; \
+ (DST)[3] = (SRC)[3]; \
+} while (0)
+
+/** Copy a 4-element vector with cast */
+#define COPY_4V_CAST( DST, SRC, CAST ) \
+do { \
+ (DST)[0] = (CAST)(SRC)[0]; \
+ (DST)[1] = (CAST)(SRC)[1]; \
+ (DST)[2] = (CAST)(SRC)[2]; \
+ (DST)[3] = (CAST)(SRC)[3]; \
+} while (0)
+
+/** Copy a 4-element unsigned byte vector */
+#if defined(__i386__)
+#define COPY_4UBV(DST, SRC) \
+do { \
+ *((GLuint*)(DST)) = *((GLuint*)(SRC)); \
+} while (0)
+#else
+/* The GLuint cast might fail if DST or SRC are not dword-aligned (RISC) */
+#define COPY_4UBV(DST, SRC) \
+do { \
+ (DST)[0] = (SRC)[0]; \
+ (DST)[1] = (SRC)[1]; \
+ (DST)[2] = (SRC)[2]; \
+ (DST)[3] = (SRC)[3]; \
+} while (0)
+#endif
+
+/** Copy a 4-element float vector (Use COPY_FLOAT to avoid loading FPU) */
+#define COPY_4FV( DST, SRC ) \
+do { \
+ COPY_FLOAT((DST)[0], (SRC)[0]); \
+ COPY_FLOAT((DST)[1], (SRC)[1]); \
+ COPY_FLOAT((DST)[2], (SRC)[2]); \
+ COPY_FLOAT((DST)[3], (SRC)[3]); \
+} while (0)
+
+
+/** Copy \p SZ elements into a 4-element vector */
+#define COPY_SZ_4V(DST, SZ, SRC) \
+do { \
+ switch (SZ) { \
+ case 4: (DST)[3] = (SRC)[3]; \
+ case 3: (DST)[2] = (SRC)[2]; \
+ case 2: (DST)[1] = (SRC)[1]; \
+ case 1: (DST)[0] = (SRC)[0]; \
+ } \
+} while(0)
+
+/** Copy \p SZ elements into a homegeneous (4-element) vector, giving
+ * default values to the remaining */
+#define COPY_CLEAN_4V(DST, SZ, SRC) \
+do { \
+ ASSIGN_4V( DST, 0, 0, 0, 1 ); \
+ COPY_SZ_4V( DST, SZ, SRC ); \
+} while (0)
+
+/** Subtraction */
+#define SUB_4V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] - (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] - (SRCB)[1]; \
+ (DST)[2] = (SRCA)[2] - (SRCB)[2]; \
+ (DST)[3] = (SRCA)[3] - (SRCB)[3]; \
+} while (0)
+
+/** Addition */
+#define ADD_4V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] + (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] + (SRCB)[1]; \
+ (DST)[2] = (SRCA)[2] + (SRCB)[2]; \
+ (DST)[3] = (SRCA)[3] + (SRCB)[3]; \
+} while (0)
+
+/** Element-wise multiplication */
+#define SCALE_4V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] * (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] * (SRCB)[1]; \
+ (DST)[2] = (SRCA)[2] * (SRCB)[2]; \
+ (DST)[3] = (SRCA)[3] * (SRCB)[3]; \
+} while (0)
+
+/** In-place addition */
+#define ACC_4V( DST, SRC ) \
+do { \
+ (DST)[0] += (SRC)[0]; \
+ (DST)[1] += (SRC)[1]; \
+ (DST)[2] += (SRC)[2]; \
+ (DST)[3] += (SRC)[3]; \
+} while (0)
+
+/** Element-wise multiplication and addition */
+#define ACC_SCALE_4V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] += (SRCA)[0] * (SRCB)[0]; \
+ (DST)[1] += (SRCA)[1] * (SRCB)[1]; \
+ (DST)[2] += (SRCA)[2] * (SRCB)[2]; \
+ (DST)[3] += (SRCA)[3] * (SRCB)[3]; \
+} while (0)
+
+/** In-place scalar multiplication and addition */
+#define ACC_SCALE_SCALAR_4V( DST, S, SRCB ) \
+do { \
+ (DST)[0] += S * (SRCB)[0]; \
+ (DST)[1] += S * (SRCB)[1]; \
+ (DST)[2] += S * (SRCB)[2]; \
+ (DST)[3] += S * (SRCB)[3]; \
+} while (0)
+
+/** Scalar multiplication */
+#define SCALE_SCALAR_4V( DST, S, SRCB ) \
+do { \
+ (DST)[0] = S * (SRCB)[0]; \
+ (DST)[1] = S * (SRCB)[1]; \
+ (DST)[2] = S * (SRCB)[2]; \
+ (DST)[3] = S * (SRCB)[3]; \
+} while (0)
+
+/** In-place scalar multiplication */
+#define SELF_SCALE_SCALAR_4V( DST, S ) \
+do { \
+ (DST)[0] *= S; \
+ (DST)[1] *= S; \
+ (DST)[2] *= S; \
+ (DST)[3] *= S; \
+} while (0)
+
+/** Assignment */
+#define ASSIGN_4V( V, V0, V1, V2, V3 ) \
+do { \
+ V[0] = V0; \
+ V[1] = V1; \
+ V[2] = V2; \
+ V[3] = V3; \
+} while(0)
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name 3-element vector operations*/
+/*@{*/
+
+/** Zero */
+#define ZERO_3V( DST ) (DST)[0] = (DST)[1] = (DST)[2] = 0
+
+/** Test for equality */
+#define TEST_EQ_3V(a,b) \
+ ((a)[0] == (b)[0] && \
+ (a)[1] == (b)[1] && \
+ (a)[2] == (b)[2])
+
+/** Copy a 3-element vector */
+#define COPY_3V( DST, SRC ) \
+do { \
+ (DST)[0] = (SRC)[0]; \
+ (DST)[1] = (SRC)[1]; \
+ (DST)[2] = (SRC)[2]; \
+} while (0)
+
+/** Copy a 3-element vector with cast */
+#define COPY_3V_CAST( DST, SRC, CAST ) \
+do { \
+ (DST)[0] = (CAST)(SRC)[0]; \
+ (DST)[1] = (CAST)(SRC)[1]; \
+ (DST)[2] = (CAST)(SRC)[2]; \
+} while (0)
+
+/** Copy a 3-element float vector */
+#define COPY_3FV( DST, SRC ) \
+do { \
+ const GLfloat *_tmp = (SRC); \
+ (DST)[0] = _tmp[0]; \
+ (DST)[1] = _tmp[1]; \
+ (DST)[2] = _tmp[2]; \
+} while (0)
+
+/** Subtraction */
+#define SUB_3V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] - (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] - (SRCB)[1]; \
+ (DST)[2] = (SRCA)[2] - (SRCB)[2]; \
+} while (0)
+
+/** Addition */
+#define ADD_3V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] + (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] + (SRCB)[1]; \
+ (DST)[2] = (SRCA)[2] + (SRCB)[2]; \
+} while (0)
+
+/** In-place scalar multiplication */
+#define SCALE_3V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] * (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] * (SRCB)[1]; \
+ (DST)[2] = (SRCA)[2] * (SRCB)[2]; \
+} while (0)
+
+/** In-place element-wise multiplication */
+#define SELF_SCALE_3V( DST, SRC ) \
+do { \
+ (DST)[0] *= (SRC)[0]; \
+ (DST)[1] *= (SRC)[1]; \
+ (DST)[2] *= (SRC)[2]; \
+} while (0)
+
+/** In-place addition */
+#define ACC_3V( DST, SRC ) \
+do { \
+ (DST)[0] += (SRC)[0]; \
+ (DST)[1] += (SRC)[1]; \
+ (DST)[2] += (SRC)[2]; \
+} while (0)
+
+/** Element-wise multiplication and addition */
+#define ACC_SCALE_3V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] += (SRCA)[0] * (SRCB)[0]; \
+ (DST)[1] += (SRCA)[1] * (SRCB)[1]; \
+ (DST)[2] += (SRCA)[2] * (SRCB)[2]; \
+} while (0)
+
+/** Scalar multiplication */
+#define SCALE_SCALAR_3V( DST, S, SRCB ) \
+do { \
+ (DST)[0] = S * (SRCB)[0]; \
+ (DST)[1] = S * (SRCB)[1]; \
+ (DST)[2] = S * (SRCB)[2]; \
+} while (0)
+
+/** In-place scalar multiplication and addition */
+#define ACC_SCALE_SCALAR_3V( DST, S, SRCB ) \
+do { \
+ (DST)[0] += S * (SRCB)[0]; \
+ (DST)[1] += S * (SRCB)[1]; \
+ (DST)[2] += S * (SRCB)[2]; \
+} while (0)
+
+/** In-place scalar multiplication */
+#define SELF_SCALE_SCALAR_3V( DST, S ) \
+do { \
+ (DST)[0] *= S; \
+ (DST)[1] *= S; \
+ (DST)[2] *= S; \
+} while (0)
+
+/** In-place scalar addition */
+#define ACC_SCALAR_3V( DST, S ) \
+do { \
+ (DST)[0] += S; \
+ (DST)[1] += S; \
+ (DST)[2] += S; \
+} while (0)
+
+/** Assignment */
+#define ASSIGN_3V( V, V0, V1, V2 ) \
+do { \
+ V[0] = V0; \
+ V[1] = V1; \
+ V[2] = V2; \
+} while(0)
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name 2-element vector operations*/
+/*@{*/
+
+/** Zero */
+#define ZERO_2V( DST ) (DST)[0] = (DST)[1] = 0
+
+/** Copy a 2-element vector */
+#define COPY_2V( DST, SRC ) \
+do { \
+ (DST)[0] = (SRC)[0]; \
+ (DST)[1] = (SRC)[1]; \
+} while (0)
+
+/** Copy a 2-element vector with cast */
+#define COPY_2V_CAST( DST, SRC, CAST ) \
+do { \
+ (DST)[0] = (CAST)(SRC)[0]; \
+ (DST)[1] = (CAST)(SRC)[1]; \
+} while (0)
+
+/** Copy a 2-element float vector */
+#define COPY_2FV( DST, SRC ) \
+do { \
+ const GLfloat *_tmp = (SRC); \
+ (DST)[0] = _tmp[0]; \
+ (DST)[1] = _tmp[1]; \
+} while (0)
+
+/** Subtraction */
+#define SUB_2V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] - (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] - (SRCB)[1]; \
+} while (0)
+
+/** Addition */
+#define ADD_2V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] + (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] + (SRCB)[1]; \
+} while (0)
+
+/** In-place scalar multiplication */
+#define SCALE_2V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] = (SRCA)[0] * (SRCB)[0]; \
+ (DST)[1] = (SRCA)[1] * (SRCB)[1]; \
+} while (0)
+
+/** In-place addition */
+#define ACC_2V( DST, SRC ) \
+do { \
+ (DST)[0] += (SRC)[0]; \
+ (DST)[1] += (SRC)[1]; \
+} while (0)
+
+/** Element-wise multiplication and addition */
+#define ACC_SCALE_2V( DST, SRCA, SRCB ) \
+do { \
+ (DST)[0] += (SRCA)[0] * (SRCB)[0]; \
+ (DST)[1] += (SRCA)[1] * (SRCB)[1]; \
+} while (0)
+
+/** Scalar multiplication */
+#define SCALE_SCALAR_2V( DST, S, SRCB ) \
+do { \
+ (DST)[0] = S * (SRCB)[0]; \
+ (DST)[1] = S * (SRCB)[1]; \
+} while (0)
+
+/** In-place scalar multiplication and addition */
+#define ACC_SCALE_SCALAR_2V( DST, S, SRCB ) \
+do { \
+ (DST)[0] += S * (SRCB)[0]; \
+ (DST)[1] += S * (SRCB)[1]; \
+} while (0)
+
+/** In-place scalar multiplication */
+#define SELF_SCALE_SCALAR_2V( DST, S ) \
+do { \
+ (DST)[0] *= S; \
+ (DST)[1] *= S; \
+} while (0)
+
+/** In-place scalar addition */
+#define ACC_SCALAR_2V( DST, S ) \
+do { \
+ (DST)[0] += S; \
+ (DST)[1] += S; \
+} while (0)
+
+
+
+/**
+ * Linear interpolation
+ *
+ * \note \p OUT argument is evaluated twice!
+ * \note Be wary of using *coord++ as an argument to any of these macros!
+ */
+#define LINTERP(T, OUT, IN) ((OUT) + (T) * ((IN) - (OUT)))
+
+/* Can do better with integer math
+ */
+#define INTERP_UB( t, dstub, outub, inub ) \
+do { \
+ GLfloat inf = UBYTE_TO_FLOAT( inub ); \
+ GLfloat outf = UBYTE_TO_FLOAT( outub ); \
+ GLfloat dstf = LINTERP( t, outf, inf ); \
+ UNCLAMPED_FLOAT_TO_UBYTE( dstub, dstf ); \
+} while (0)
+
+#define INTERP_CHAN( t, dstc, outc, inc ) \
+do { \
+ GLfloat inf = CHAN_TO_FLOAT( inc ); \
+ GLfloat outf = CHAN_TO_FLOAT( outc ); \
+ GLfloat dstf = LINTERP( t, outf, inf ); \
+ UNCLAMPED_FLOAT_TO_CHAN( dstc, dstf ); \
+} while (0)
+
+#define INTERP_UI( t, dstui, outui, inui ) \
+ dstui = (GLuint) (GLint) LINTERP( (t), (GLfloat) (outui), (GLfloat) (inui) )
+
+#define INTERP_F( t, dstf, outf, inf ) \
+ dstf = LINTERP( t, outf, inf )
+
+#define INTERP_4F( t, dst, out, in ) \
+do { \
+ dst[0] = LINTERP( (t), (out)[0], (in)[0] ); \
+ dst[1] = LINTERP( (t), (out)[1], (in)[1] ); \
+ dst[2] = LINTERP( (t), (out)[2], (in)[2] ); \
+ dst[3] = LINTERP( (t), (out)[3], (in)[3] ); \
+} while (0)
+
+#define INTERP_3F( t, dst, out, in ) \
+do { \
+ dst[0] = LINTERP( (t), (out)[0], (in)[0] ); \
+ dst[1] = LINTERP( (t), (out)[1], (in)[1] ); \
+ dst[2] = LINTERP( (t), (out)[2], (in)[2] ); \
+} while (0)
+
+#define INTERP_4CHAN( t, dst, out, in ) \
+do { \
+ INTERP_CHAN( (t), (dst)[0], (out)[0], (in)[0] ); \
+ INTERP_CHAN( (t), (dst)[1], (out)[1], (in)[1] ); \
+ INTERP_CHAN( (t), (dst)[2], (out)[2], (in)[2] ); \
+ INTERP_CHAN( (t), (dst)[3], (out)[3], (in)[3] ); \
+} while (0)
+
+#define INTERP_3CHAN( t, dst, out, in ) \
+do { \
+ INTERP_CHAN( (t), (dst)[0], (out)[0], (in)[0] ); \
+ INTERP_CHAN( (t), (dst)[1], (out)[1], (in)[1] ); \
+ INTERP_CHAN( (t), (dst)[2], (out)[2], (in)[2] ); \
+} while (0)
+
+#define INTERP_SZ( t, vec, to, out, in, sz ) \
+do { \
+ switch (sz) { \
+ case 4: vec[to][3] = LINTERP( (t), (vec)[out][3], (vec)[in][3] ); \
+ case 3: vec[to][2] = LINTERP( (t), (vec)[out][2], (vec)[in][2] ); \
+ case 2: vec[to][1] = LINTERP( (t), (vec)[out][1], (vec)[in][1] ); \
+ case 1: vec[to][0] = LINTERP( (t), (vec)[out][0], (vec)[in][0] ); \
+ } \
+} while(0)
+
+
+
+/** Assign scalers to short vectors */
+#define ASSIGN_2V( V, V0, V1 ) \
+do { \
+ V[0] = V0; \
+ V[1] = V1; \
+} while(0)
+
+/*@}*/
+
+
+
+/** Clamp X to [MIN,MAX] */
+#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) )
+
+/** Assign X to CLAMP(X, MIN, MAX) */
+#define CLAMP_SELF(x, mn, mx) \
+ ( (x)<(mn) ? ((x) = (mn)) : ((x)>(mx) ? ((x)=(mx)) : (x)) )
+
+
+
+/** Minimum of two values: */
+#define MIN2( A, B ) ( (A)<(B) ? (A) : (B) )
+
+/** Maximum of two values: */
+#define MAX2( A, B ) ( (A)>(B) ? (A) : (B) )
+
+/** Dot product of two 2-element vectors */
+#define DOT2( a, b ) ( (a)[0]*(b)[0] + (a)[1]*(b)[1] )
+
+/** Dot product of two 3-element vectors */
+#define DOT3( a, b ) ( (a)[0]*(b)[0] + (a)[1]*(b)[1] + (a)[2]*(b)[2] )
+
+/** Dot product of two 4-element vectors */
+#define DOT4( a, b ) ( (a)[0]*(b)[0] + (a)[1]*(b)[1] + \
+ (a)[2]*(b)[2] + (a)[3]*(b)[3] )
+
+/** Dot product of two 4-element vectors */
+#define DOT4V(v,a,b,c,d) (v[0]*(a) + v[1]*(b) + v[2]*(c) + v[3]*(d))
+
+
+/** Cross product of two 3-element vectors */
+#define CROSS3(n, u, v) \
+do { \
+ (n)[0] = (u)[1]*(v)[2] - (u)[2]*(v)[1]; \
+ (n)[1] = (u)[2]*(v)[0] - (u)[0]*(v)[2]; \
+ (n)[2] = (u)[0]*(v)[1] - (u)[1]*(v)[0]; \
+} while (0)
+
+
+/* Normalize a 3-element vector to unit length. */
+#define NORMALIZE_3FV( V ) \
+do { \
+ GLfloat len = (GLfloat) LEN_SQUARED_3FV(V); \
+ if (len) { \
+ len = INV_SQRTF(len); \
+ (V)[0] = (GLfloat) ((V)[0] * len); \
+ (V)[1] = (GLfloat) ((V)[1] * len); \
+ (V)[2] = (GLfloat) ((V)[2] * len); \
+ } \
+} while(0)
+
+#define LEN_3FV( V ) (SQRTF((V)[0]*(V)[0]+(V)[1]*(V)[1]+(V)[2]*(V)[2]))
+#define LEN_2FV( V ) (SQRTF((V)[0]*(V)[0]+(V)[1]*(V)[1]))
+
+#define LEN_SQUARED_3FV( V ) ((V)[0]*(V)[0]+(V)[1]*(V)[1]+(V)[2]*(V)[2])
+#define LEN_SQUARED_2FV( V ) ((V)[0]*(V)[0]+(V)[1]*(V)[1])
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/matrix.c b/nx-X11/extras/Mesa/src/mesa/main/matrix.c
new file mode 100644
index 000000000..f4ec97356
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/matrix.c
@@ -0,0 +1,943 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file matrix.c
+ * Matrix operations.
+ *
+ * \note
+ * -# 4x4 transformation matrices are stored in memory in column major order.
+ * -# Points/vertices are to be thought of as column vectors.
+ * -# Transformation of a point p by a matrix M is: p' = M * p
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "enums.h"
+#include "macros.h"
+#include "matrix.h"
+#include "mtypes.h"
+#include "math/m_matrix.h"
+#include "math/m_xform.h"
+
+
+/**
+ * Apply a perspective projection matrix.
+ *
+ * \param left left clipping plane coordinate.
+ * \param right right clipping plane coordinate.
+ * \param bottom bottom clipping plane coordinate.
+ * \param top top clipping plane coordinate.
+ * \param nearval distance to the near clipping plane.
+ * \param farval distance to the far clipping plane.
+ *
+ * \sa glFrustum().
+ *
+ * Flushes vertices and validates parameters. Calls _math_matrix_frustum() with
+ * the top matrix of the current matrix stack and sets
+ * __GLcontextRec::NewState.
+ */
+void GLAPIENTRY
+_mesa_Frustum( GLdouble left, GLdouble right,
+ GLdouble bottom, GLdouble top,
+ GLdouble nearval, GLdouble farval )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (nearval <= 0.0 ||
+ farval <= 0.0 ||
+ nearval == farval ||
+ left == right ||
+ top == bottom)
+ {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glFrustum" );
+ return;
+ }
+
+ _math_matrix_frustum( ctx->CurrentStack->Top,
+ (GLfloat) left, (GLfloat) right,
+ (GLfloat) bottom, (GLfloat) top,
+ (GLfloat) nearval, (GLfloat) farval );
+ ctx->NewState |= ctx->CurrentStack->DirtyFlag;
+}
+
+
+/**
+ * Apply an orthographic projection matrix.
+ *
+ * \param left left clipping plane coordinate.
+ * \param right right clipping plane coordinate.
+ * \param bottom bottom clipping plane coordinate.
+ * \param top top clipping plane coordinate.
+ * \param nearval distance to the near clipping plane.
+ * \param farval distance to the far clipping plane.
+ *
+ * \sa glOrtho().
+ *
+ * Flushes vertices and validates parameters. Calls _math_matrix_ortho() with
+ * the top matrix of the current matrix stack and sets
+ * __GLcontextRec::NewState.
+ */
+void GLAPIENTRY
+_mesa_Ortho( GLdouble left, GLdouble right,
+ GLdouble bottom, GLdouble top,
+ GLdouble nearval, GLdouble farval )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glOrtho(%f, %f, %f, %f, %f, %f)\n",
+ left, right, bottom, top, nearval, farval);
+
+ if (left == right ||
+ bottom == top ||
+ nearval == farval)
+ {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glOrtho" );
+ return;
+ }
+
+ _math_matrix_ortho( ctx->CurrentStack->Top,
+ (GLfloat) left, (GLfloat) right,
+ (GLfloat) bottom, (GLfloat) top,
+ (GLfloat) nearval, (GLfloat) farval );
+ ctx->NewState |= ctx->CurrentStack->DirtyFlag;
+}
+
+
+/**
+ * Set the current matrix stack.
+ *
+ * \param mode matrix stack.
+ *
+ * \sa glMatrixMode().
+ *
+ * Flushes the vertices, validates the parameter and updates
+ * __GLcontextRec::CurrentStack and gl_transform_attrib::MatrixMode with the
+ * specified matrix stack.
+ */
+void GLAPIENTRY
+_mesa_MatrixMode( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (ctx->Transform.MatrixMode == mode && mode != GL_TEXTURE)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TRANSFORM);
+
+ switch (mode) {
+ case GL_MODELVIEW:
+ ctx->CurrentStack = &ctx->ModelviewMatrixStack;
+ break;
+ case GL_PROJECTION:
+ ctx->CurrentStack = &ctx->ProjectionMatrixStack;
+ break;
+ case GL_TEXTURE:
+ ctx->CurrentStack = &ctx->TextureMatrixStack[ctx->Texture.CurrentUnit];
+ break;
+ case GL_COLOR:
+ ctx->CurrentStack = &ctx->ColorMatrixStack;
+ break;
+ case GL_MATRIX0_NV:
+ case GL_MATRIX1_NV:
+ case GL_MATRIX2_NV:
+ case GL_MATRIX3_NV:
+ case GL_MATRIX4_NV:
+ case GL_MATRIX5_NV:
+ case GL_MATRIX6_NV:
+ case GL_MATRIX7_NV:
+ if (ctx->Extensions.NV_vertex_program) {
+ ctx->CurrentStack = &ctx->ProgramMatrixStack[mode - GL_MATRIX0_NV];
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" );
+ return;
+ }
+ break;
+ case GL_MATRIX0_ARB:
+ case GL_MATRIX1_ARB:
+ case GL_MATRIX2_ARB:
+ case GL_MATRIX3_ARB:
+ case GL_MATRIX4_ARB:
+ case GL_MATRIX5_ARB:
+ case GL_MATRIX6_ARB:
+ case GL_MATRIX7_ARB:
+ if (ctx->Extensions.ARB_vertex_program ||
+ ctx->Extensions.ARB_fragment_program) {
+ const GLuint m = mode - GL_MATRIX0_ARB;
+ if (m > ctx->Const.MaxProgramMatrices) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glMatrixMode(GL_MATRIX%d_ARB)", m);
+ return;
+ }
+ ctx->CurrentStack = &ctx->ProgramMatrixStack[m];
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" );
+ return;
+ }
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glMatrixMode(mode)" );
+ return;
+ }
+
+ ctx->Transform.MatrixMode = mode;
+}
+
+
+/**
+ * Push the current matrix stack.
+ *
+ * \sa glPushMatrix().
+ *
+ * Verifies the current matrix stack is not full, and duplicates the top-most
+ * matrix in the stack. Marks __GLcontextRec::NewState with the stack dirty
+ * flag.
+ */
+void GLAPIENTRY
+_mesa_PushMatrix( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct matrix_stack *stack = ctx->CurrentStack;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE&VERBOSE_API)
+ _mesa_debug(ctx, "glPushMatrix %s\n",
+ _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode));
+
+ if (stack->Depth + 1 >= stack->MaxDepth) {
+ if (ctx->Transform.MatrixMode == GL_TEXTURE) {
+ _mesa_error(ctx, GL_STACK_OVERFLOW,
+ "glPushMatrix(mode=GL_TEXTURE, unit=%d)",
+ ctx->Texture.CurrentUnit);
+ }
+ else {
+ _mesa_error(ctx, GL_STACK_OVERFLOW, "glPushMatrix(mode=%s)",
+ _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode));
+ }
+ return;
+ }
+ _math_matrix_copy( &stack->Stack[stack->Depth + 1],
+ &stack->Stack[stack->Depth] );
+ stack->Depth++;
+ stack->Top = &(stack->Stack[stack->Depth]);
+ ctx->NewState |= stack->DirtyFlag;
+}
+
+
+/**
+ * Pop the current matrix stack.
+ *
+ * \sa glPopMatrix().
+ *
+ * Flushes the vertices, verifies the current matrix stack is not empty, and
+ * moves the stack head down. Marks __GLcontextRec::NewState with the dirty
+ * stack flag.
+ */
+void GLAPIENTRY
+_mesa_PopMatrix( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct matrix_stack *stack = ctx->CurrentStack;
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (MESA_VERBOSE&VERBOSE_API)
+ _mesa_debug(ctx, "glPopMatrix %s\n",
+ _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode));
+
+ if (stack->Depth == 0) {
+ if (ctx->Transform.MatrixMode == GL_TEXTURE) {
+ _mesa_error(ctx, GL_STACK_UNDERFLOW,
+ "glPopMatrix(mode=GL_TEXTURE, unit=%d)",
+ ctx->Texture.CurrentUnit);
+ }
+ else {
+ _mesa_error(ctx, GL_STACK_UNDERFLOW, "glPopMatrix(mode=%s)",
+ _mesa_lookup_enum_by_nr(ctx->Transform.MatrixMode));
+ }
+ return;
+ }
+ stack->Depth--;
+ stack->Top = &(stack->Stack[stack->Depth]);
+ ctx->NewState |= stack->DirtyFlag;
+}
+
+
+/**
+ * Replace the current matrix with the identity matrix.
+ *
+ * \sa glLoadIdentity().
+ *
+ * Flushes the vertices and calls _math_matrix_set_identity() with the top-most
+ * matrix in the current stack. Marks __GLcontextRec::NewState with the stack
+ * dirty flag.
+ */
+void GLAPIENTRY
+_mesa_LoadIdentity( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glLoadIdentity()");
+
+ _math_matrix_set_identity( ctx->CurrentStack->Top );
+ ctx->NewState |= ctx->CurrentStack->DirtyFlag;
+}
+
+
+/**
+ * Replace the current matrix with a given matrix.
+ *
+ * \param m matrix.
+ *
+ * \sa glLoadMatrixf().
+ *
+ * Flushes the vertices and calls _math_matrix_loadf() with the top-most matrix
+ * in the current stack and the given matrix. Marks __GLcontextRec::NewState
+ * with the dirty stack flag.
+ */
+void GLAPIENTRY
+_mesa_LoadMatrixf( const GLfloat *m )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (!m) return;
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx,
+ "glLoadMatrix(%f %f %f %f, %f %f %f %f, %f %f %f %f, %f %f %f %f\n",
+ m[0], m[4], m[8], m[12],
+ m[1], m[5], m[9], m[13],
+ m[2], m[6], m[10], m[14],
+ m[3], m[7], m[11], m[15]);
+
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ _math_matrix_loadf( ctx->CurrentStack->Top, m );
+ ctx->NewState |= ctx->CurrentStack->DirtyFlag;
+}
+
+
+/**
+ * Multiply the current matrix with a given matrix.
+ *
+ * \param m matrix.
+ *
+ * \sa glMultMatrixf().
+ *
+ * Flushes the vertices and calls _math_matrix_mul_floats() with the top-most
+ * matrix in the current stack and the given matrix. Marks
+ * __GLcontextRec::NewState with the dirty stack flag.
+ */
+void GLAPIENTRY
+_mesa_MultMatrixf( const GLfloat *m )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (!m) return;
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx,
+ "glMultMatrix(%f %f %f %f, %f %f %f %f, %f %f %f %f, %f %f %f %f\n",
+ m[0], m[4], m[8], m[12],
+ m[1], m[5], m[9], m[13],
+ m[2], m[6], m[10], m[14],
+ m[3], m[7], m[11], m[15]);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ _math_matrix_mul_floats( ctx->CurrentStack->Top, m );
+ ctx->NewState |= ctx->CurrentStack->DirtyFlag;
+}
+
+
+/**
+ * Multiply the current matrix with a rotation matrix.
+ *
+ * \param angle angle of rotation, in degrees.
+ * \param x rotation vector x coordinate.
+ * \param y rotation vector y coordinate.
+ * \param z rotation vector z coordinate.
+ *
+ * \sa glRotatef().
+ *
+ * Flushes the vertices and calls _math_matrix_rotate() with the top-most
+ * matrix in the current stack and the given parameters. Marks
+ * __GLcontextRec::NewState with the dirty stack flag.
+ */
+void GLAPIENTRY
+_mesa_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ if (angle != 0.0F) {
+ _math_matrix_rotate( ctx->CurrentStack->Top, angle, x, y, z);
+ ctx->NewState |= ctx->CurrentStack->DirtyFlag;
+ }
+}
+
+
+/**
+ * Multiply the current matrix with a general scaling matrix.
+ *
+ * \param x x axis scale factor.
+ * \param y y axis scale factor.
+ * \param z z axis scale factor.
+ *
+ * \sa glScalef().
+ *
+ * Flushes the vertices and calls _math_matrix_scale() with the top-most
+ * matrix in the current stack and the given parameters. Marks
+ * __GLcontextRec::NewState with the dirty stack flag.
+ */
+void GLAPIENTRY
+_mesa_Scalef( GLfloat x, GLfloat y, GLfloat z )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ _math_matrix_scale( ctx->CurrentStack->Top, x, y, z);
+ ctx->NewState |= ctx->CurrentStack->DirtyFlag;
+}
+
+
+/**
+ * Multiply the current matrix with a general scaling matrix.
+ *
+ * \param x translation vector x coordinate.
+ * \param y translation vector y coordinate.
+ * \param z translation vector z coordinate.
+ *
+ * \sa glTranslatef().
+ *
+ * Flushes the vertices and calls _math_matrix_translate() with the top-most
+ * matrix in the current stack and the given parameters. Marks
+ * __GLcontextRec::NewState with the dirty stack flag.
+ */
+void GLAPIENTRY
+_mesa_Translatef( GLfloat x, GLfloat y, GLfloat z )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ _math_matrix_translate( ctx->CurrentStack->Top, x, y, z);
+ ctx->NewState |= ctx->CurrentStack->DirtyFlag;
+}
+
+
+#if _HAVE_FULL_GL
+void GLAPIENTRY
+_mesa_LoadMatrixd( const GLdouble *m )
+{
+ GLint i;
+ GLfloat f[16];
+ if (!m) return;
+ for (i = 0; i < 16; i++)
+ f[i] = (GLfloat) m[i];
+ _mesa_LoadMatrixf(f);
+}
+
+void GLAPIENTRY
+_mesa_MultMatrixd( const GLdouble *m )
+{
+ GLint i;
+ GLfloat f[16];
+ if (!m) return;
+ for (i = 0; i < 16; i++)
+ f[i] = (GLfloat) m[i];
+ _mesa_MultMatrixf( f );
+}
+
+
+void GLAPIENTRY
+_mesa_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z )
+{
+ _mesa_Rotatef((GLfloat) angle, (GLfloat) x, (GLfloat) y, (GLfloat) z);
+}
+
+
+void GLAPIENTRY
+_mesa_Scaled( GLdouble x, GLdouble y, GLdouble z )
+{
+ _mesa_Scalef((GLfloat) x, (GLfloat) y, (GLfloat) z);
+}
+
+
+void GLAPIENTRY
+_mesa_Translated( GLdouble x, GLdouble y, GLdouble z )
+{
+ _mesa_Translatef((GLfloat) x, (GLfloat) y, (GLfloat) z);
+}
+#endif
+
+
+#if _HAVE_FULL_GL
+void GLAPIENTRY
+_mesa_LoadTransposeMatrixfARB( const GLfloat *m )
+{
+ GLfloat tm[16];
+ if (!m) return;
+ _math_transposef(tm, m);
+ _mesa_LoadMatrixf(tm);
+}
+
+
+void GLAPIENTRY
+_mesa_LoadTransposeMatrixdARB( const GLdouble *m )
+{
+ GLfloat tm[16];
+ if (!m) return;
+ _math_transposefd(tm, m);
+ _mesa_LoadMatrixf(tm);
+}
+
+
+void GLAPIENTRY
+_mesa_MultTransposeMatrixfARB( const GLfloat *m )
+{
+ GLfloat tm[16];
+ if (!m) return;
+ _math_transposef(tm, m);
+ _mesa_MultMatrixf(tm);
+}
+
+
+void GLAPIENTRY
+_mesa_MultTransposeMatrixdARB( const GLdouble *m )
+{
+ GLfloat tm[16];
+ if (!m) return;
+ _math_transposefd(tm, m);
+ _mesa_MultMatrixf(tm);
+}
+#endif
+
+/**
+ * Set the viewport.
+ *
+ * \param x, y coordinates of the lower-left corner of the viewport rectangle.
+ * \param width width of the viewport rectangle.
+ * \param height height of the viewport rectangle.
+ *
+ * \sa Called via glViewport() or display list execution.
+ *
+ * Flushes the vertices and calls _mesa_set_viewport() with the given
+ * parameters.
+ */
+void GLAPIENTRY
+_mesa_Viewport( GLint x, GLint y, GLsizei width, GLsizei height )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ _mesa_set_viewport(ctx, x, y, width, height);
+}
+
+/**
+ * Set new viewport parameters and update derived state (the _WindowMap
+ * matrix). Usually called from _mesa_Viewport().
+ *
+ * \param ctx GL context.
+ * \param x, y coordinates of the lower left corner of the viewport rectangle.
+ * \param width width of the viewport rectangle.
+ * \param height height of the viewport rectangle.
+ *
+ * Verifies the parameters, clamps them to the implementation dependent range
+ * and updates __GLcontextRec::Viewport. Computes the scale and bias values for
+ * the drivers and notifies the driver via the dd_function_table::Viewport
+ * callback.
+ */
+void
+_mesa_set_viewport( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
+ const GLfloat n = ctx->Viewport.Near;
+ const GLfloat f = ctx->Viewport.Far;
+
+ ASSERT(depthMax > 0);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glViewport %d %d %d %d\n", x, y, width, height);
+
+ if (width < 0 || height < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE,
+ "glViewport(%d, %d, %d, %d)", x, y, width, height );
+ return;
+ }
+
+ /* clamp width, and height to implementation dependent range */
+ width = CLAMP( width, 1, ctx->Const.MaxViewportWidth );
+ height = CLAMP( height, 1, ctx->Const.MaxViewportHeight );
+
+ /* Save viewport */
+ ctx->Viewport.X = x;
+ ctx->Viewport.Width = width;
+ ctx->Viewport.Y = y;
+ ctx->Viewport.Height = height;
+
+ /* XXX send transposed width/height to Driver.Viewport() below??? */
+ if (ctx->_RotateMode) {
+ GLint tmp, tmps;
+ tmp = x; x = y; y = tmp;
+ tmps = width; width = height; height = tmps;
+ }
+
+ /* Compute scale and bias values. This is really driver-specific
+ * and should be maintained elsewhere if at all.
+ * NOTE: RasterPos uses this.
+ */
+ _math_matrix_viewport(&ctx->Viewport._WindowMap, x, y, width, height,
+ n, f, depthMax);
+
+ ctx->NewState |= _NEW_VIEWPORT;
+
+ if (ctx->Driver.Viewport) {
+ /* Many drivers will use this call to check for window size changes
+ * and reallocate the z/stencil/accum/etc buffers if needed.
+ */
+ (*ctx->Driver.Viewport)( ctx, x, y, width, height );
+ }
+}
+
+
+#if _HAVE_FULL_GL
+void GLAPIENTRY
+_mesa_DepthRange( GLclampd nearval, GLclampd farval )
+{
+ /*
+ * nearval - specifies mapping of the near clipping plane to window
+ * coordinates, default is 0
+ * farval - specifies mapping of the far clipping plane to window
+ * coordinates, default is 1
+ *
+ * After clipping and div by w, z coords are in -1.0 to 1.0,
+ * corresponding to near and far clipping planes. glDepthRange
+ * specifies a linear mapping of the normalized z coords in
+ * this range to window z coords.
+ */
+ GLfloat depthMax;
+ GLfloat n, f;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ depthMax = ctx->DrawBuffer->_DepthMaxF;
+
+ if (MESA_VERBOSE&VERBOSE_API)
+ _mesa_debug(ctx, "glDepthRange %f %f\n", nearval, farval);
+
+ n = (GLfloat) CLAMP( nearval, 0.0, 1.0 );
+ f = (GLfloat) CLAMP( farval, 0.0, 1.0 );
+
+ ctx->Viewport.Near = n;
+ ctx->Viewport.Far = f;
+ ctx->Viewport._WindowMap.m[MAT_SZ] = depthMax * ((f - n) / 2.0F);
+ ctx->Viewport._WindowMap.m[MAT_TZ] = depthMax * ((f - n) / 2.0F + n);
+ ctx->NewState |= _NEW_VIEWPORT;
+
+ if (ctx->Driver.DepthRange) {
+ (*ctx->Driver.DepthRange)( ctx, nearval, farval );
+ }
+}
+#endif
+
+
+
+/**********************************************************************/
+/** \name State management */
+/*@{*/
+
+
+/**
+ * Update the projection matrix stack.
+ *
+ * \param ctx GL context.
+ *
+ * Calls _math_matrix_analyse() with the top-matrix of the projection matrix
+ * stack, and recomputes user clip positions if necessary.
+ *
+ * \note This routine references __GLcontextRec::Tranform attribute values to
+ * compute userclip positions in clip space, but is only called on
+ * _NEW_PROJECTION. The _mesa_ClipPlane() function keeps these values up to
+ * date across changes to the __GLcontextRec::Transform attributes.
+ */
+static void
+update_projection( GLcontext *ctx )
+{
+ _math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
+
+#if FEATURE_userclip
+ /* Recompute clip plane positions in clipspace. This is also done
+ * in _mesa_ClipPlane().
+ */
+ if (ctx->Transform.ClipPlanesEnabled) {
+ GLuint p;
+ for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
+ _mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
+ ctx->Transform.EyeUserPlane[p],
+ ctx->ProjectionMatrixStack.Top->inv );
+ }
+ }
+ }
+#endif
+}
+
+
+/**
+ * Calculate the combined modelview-projection matrix.
+ *
+ * \param ctx GL context.
+ *
+ * Multiplies the top matrices of the projection and model view stacks into
+ * __GLcontextRec::_ModelProjectMatrix via _math_matrix_mul_matrix() and
+ * analyzes the resulting matrix via _math_matrix_analyse().
+ */
+static void
+calculate_model_project_matrix( GLcontext *ctx )
+{
+ _math_matrix_mul_matrix( &ctx->_ModelProjectMatrix,
+ ctx->ProjectionMatrixStack.Top,
+ ctx->ModelviewMatrixStack.Top );
+
+ _math_matrix_analyse( &ctx->_ModelProjectMatrix );
+}
+
+
+/**
+ * Updates the combined modelview-projection matrix.
+ *
+ * \param ctx GL context.
+ * \param new_state new state bit mask.
+ *
+ * If there is a new model view matrix then analyzes it. If there is a new
+ * projection matrix, updates it. Finally calls
+ * calculate_model_project_matrix() to recalculate the modelview-projection
+ * matrix.
+ */
+void _mesa_update_modelview_project( GLcontext *ctx, GLuint new_state )
+{
+ if (new_state & _NEW_MODELVIEW) {
+ _math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
+
+ /* Bring cull position uptodate.
+ */
+ TRANSFORM_POINT3( ctx->Transform.CullObjPos,
+ ctx->ModelviewMatrixStack.Top->inv,
+ ctx->Transform.CullEyePos );
+ }
+
+
+ if (new_state & _NEW_PROJECTION)
+ update_projection( ctx );
+
+ /* Keep ModelviewProject uptodate always to allow tnl
+ * implementations that go model->clip even when eye is required.
+ */
+ calculate_model_project_matrix(ctx);
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** Matrix stack initialization */
+/*@{*/
+
+
+/**
+ * Initialize a matrix stack.
+ *
+ * \param stack matrix stack.
+ * \param maxDepth maximum stack depth.
+ * \param dirtyFlag dirty flag.
+ *
+ * Allocates an array of \p maxDepth elements for the matrix stack and calls
+ * _math_matrix_ctr() and _math_matrix_alloc_inv() for each element to
+ * initialize it.
+ */
+static void
+init_matrix_stack( struct matrix_stack *stack,
+ GLuint maxDepth, GLuint dirtyFlag )
+{
+ GLuint i;
+
+ stack->Depth = 0;
+ stack->MaxDepth = maxDepth;
+ stack->DirtyFlag = dirtyFlag;
+ /* The stack */
+ stack->Stack = (GLmatrix *) CALLOC(maxDepth * sizeof(GLmatrix));
+ for (i = 0; i < maxDepth; i++) {
+ _math_matrix_ctr(&stack->Stack[i]);
+ _math_matrix_alloc_inv(&stack->Stack[i]);
+ }
+ stack->Top = stack->Stack;
+}
+
+/**
+ * Free matrix stack.
+ *
+ * \param stack matrix stack.
+ *
+ * Calls _math_matrix_dtr() for each element of the matrix stack and
+ * frees the array.
+ */
+static void
+free_matrix_stack( struct matrix_stack *stack )
+{
+ GLuint i;
+ for (i = 0; i < stack->MaxDepth; i++) {
+ _math_matrix_dtr(&stack->Stack[i]);
+ }
+ FREE(stack->Stack);
+ stack->Stack = stack->Top = NULL;
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Initialization */
+/*@{*/
+
+
+/**
+ * Initialize the context matrix data.
+ *
+ * \param ctx GL context.
+ *
+ * Initializes each of the matrix stacks and the combined modelview-projection
+ * matrix.
+ */
+void _mesa_init_matrix( GLcontext * ctx )
+{
+ GLint i;
+
+ /* Initialize matrix stacks */
+ init_matrix_stack(&ctx->ModelviewMatrixStack, MAX_MODELVIEW_STACK_DEPTH,
+ _NEW_MODELVIEW);
+ init_matrix_stack(&ctx->ProjectionMatrixStack, MAX_PROJECTION_STACK_DEPTH,
+ _NEW_PROJECTION);
+ init_matrix_stack(&ctx->ColorMatrixStack, MAX_COLOR_STACK_DEPTH,
+ _NEW_COLOR_MATRIX);
+ for (i = 0; i < MAX_TEXTURE_UNITS; i++)
+ init_matrix_stack(&ctx->TextureMatrixStack[i], MAX_TEXTURE_STACK_DEPTH,
+ _NEW_TEXTURE_MATRIX);
+ for (i = 0; i < MAX_PROGRAM_MATRICES; i++)
+ init_matrix_stack(&ctx->ProgramMatrixStack[i],
+ MAX_PROGRAM_MATRIX_STACK_DEPTH, _NEW_TRACK_MATRIX);
+ ctx->CurrentStack = &ctx->ModelviewMatrixStack;
+
+ /* Init combined Modelview*Projection matrix */
+ _math_matrix_ctr( &ctx->_ModelProjectMatrix );
+}
+
+
+/**
+ * Free the context matrix data.
+ *
+ * \param ctx GL context.
+ *
+ * Frees each of the matrix stacks and the combined modelview-projection
+ * matrix.
+ */
+void _mesa_free_matrix_data( GLcontext *ctx )
+{
+ GLint i;
+
+ free_matrix_stack(&ctx->ModelviewMatrixStack);
+ free_matrix_stack(&ctx->ProjectionMatrixStack);
+ free_matrix_stack(&ctx->ColorMatrixStack);
+ for (i = 0; i < MAX_TEXTURE_UNITS; i++)
+ free_matrix_stack(&ctx->TextureMatrixStack[i]);
+ for (i = 0; i < MAX_PROGRAM_MATRICES; i++)
+ free_matrix_stack(&ctx->ProgramMatrixStack[i]);
+ /* combined Modelview*Projection matrix */
+ _math_matrix_dtr( &ctx->_ModelProjectMatrix );
+
+}
+
+
+/**
+ * Initialize the context transform attribute group.
+ *
+ * \param ctx GL context.
+ *
+ * \todo Move this to a new file with other 'transform' routines.
+ */
+void _mesa_init_transform( GLcontext *ctx )
+{
+ GLint i;
+
+ /* Transformation group */
+ ctx->Transform.MatrixMode = GL_MODELVIEW;
+ ctx->Transform.Normalize = GL_FALSE;
+ ctx->Transform.RescaleNormals = GL_FALSE;
+ ctx->Transform.RasterPositionUnclipped = GL_FALSE;
+ for (i=0;i<MAX_CLIP_PLANES;i++) {
+ ASSIGN_4V( ctx->Transform.EyeUserPlane[i], 0.0, 0.0, 0.0, 0.0 );
+ }
+ ctx->Transform.ClipPlanesEnabled = 0;
+
+ ASSIGN_4V( ctx->Transform.CullObjPos, 0.0, 0.0, 1.0, 0.0 );
+ ASSIGN_4V( ctx->Transform.CullEyePos, 0.0, 0.0, 1.0, 0.0 );
+}
+
+
+/**
+ * Initialize the context viewport attribute group.
+ *
+ * \param ctx GL context.
+ *
+ * \todo Move this to a new file with other 'viewport' routines.
+ */
+void _mesa_init_viewport( GLcontext *ctx )
+{
+ GLfloat depthMax = 65535.0F; /* sorf of arbitrary */
+
+ /* Viewport group */
+ ctx->Viewport.X = 0;
+ ctx->Viewport.Y = 0;
+ ctx->Viewport.Width = 0;
+ ctx->Viewport.Height = 0;
+ ctx->Viewport.Near = 0.0;
+ ctx->Viewport.Far = 1.0;
+ _math_matrix_ctr(&ctx->Viewport._WindowMap);
+
+ _math_matrix_viewport(&ctx->Viewport._WindowMap, 0, 0, 0, 0,
+ 0.0F, 1.0F, depthMax);
+}
+
+
+/**
+ * Free the context viewport attribute group data.
+ *
+ * \param ctx GL context.
+ *
+ * \todo Move this to a new file with other 'viewport' routines.
+ */
+void _mesa_free_viewport_data( GLcontext *ctx )
+{
+ _math_matrix_dtr(&ctx->Viewport._WindowMap);
+}
+
+/*@}*/
diff --git a/nx-X11/extras/Mesa/src/mesa/main/matrix.h b/nx-X11/extras/Mesa/src/mesa/main/matrix.h
new file mode 100644
index 000000000..38769867a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/matrix.h
@@ -0,0 +1,131 @@
+/**
+ * \file matrix.h
+ * Matrix operations.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef MATRIX_H
+#define MATRIX_H
+
+
+#include "mtypes.h"
+
+
+extern void GLAPIENTRY
+_mesa_Frustum( GLdouble left, GLdouble right,
+ GLdouble bottom, GLdouble top,
+ GLdouble nearval, GLdouble farval );
+
+extern void GLAPIENTRY
+_mesa_Ortho( GLdouble left, GLdouble right,
+ GLdouble bottom, GLdouble top,
+ GLdouble nearval, GLdouble farval );
+
+extern void GLAPIENTRY
+_mesa_PushMatrix( void );
+
+extern void GLAPIENTRY
+_mesa_PopMatrix( void );
+
+extern void GLAPIENTRY
+_mesa_LoadIdentity( void );
+
+extern void GLAPIENTRY
+_mesa_LoadMatrixf( const GLfloat *m );
+
+extern void GLAPIENTRY
+_mesa_LoadMatrixd( const GLdouble *m );
+
+extern void GLAPIENTRY
+_mesa_MatrixMode( GLenum mode );
+
+extern void GLAPIENTRY
+_mesa_MultMatrixf( const GLfloat *m );
+
+extern void GLAPIENTRY
+_mesa_MultMatrixd( const GLdouble *m );
+
+extern void GLAPIENTRY
+_mesa_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z );
+
+extern void GLAPIENTRY
+_mesa_Rotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z );
+
+extern void GLAPIENTRY
+_mesa_Scalef( GLfloat x, GLfloat y, GLfloat z );
+
+extern void GLAPIENTRY
+_mesa_Scaled( GLdouble x, GLdouble y, GLdouble z );
+
+extern void GLAPIENTRY
+_mesa_Translatef( GLfloat x, GLfloat y, GLfloat z );
+
+extern void GLAPIENTRY
+_mesa_Translated( GLdouble x, GLdouble y, GLdouble z );
+
+extern void GLAPIENTRY
+_mesa_LoadTransposeMatrixfARB( const GLfloat *m );
+
+extern void GLAPIENTRY
+_mesa_LoadTransposeMatrixdARB( const GLdouble *m );
+
+extern void GLAPIENTRY
+_mesa_MultTransposeMatrixfARB( const GLfloat *m );
+
+extern void GLAPIENTRY
+_mesa_MultTransposeMatrixdARB( const GLdouble *m );
+
+extern void GLAPIENTRY
+_mesa_Viewport( GLint x, GLint y, GLsizei width, GLsizei height );
+
+extern void
+_mesa_set_viewport( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height );
+
+extern void GLAPIENTRY
+_mesa_DepthRange( GLclampd nearval, GLclampd farval );
+
+
+extern void
+_mesa_init_matrix( GLcontext * ctx );
+
+extern void
+_mesa_init_transform( GLcontext *ctx );
+
+extern void
+_mesa_init_viewport( GLcontext *ctx );
+
+extern void
+_mesa_free_matrix_data( GLcontext *ctx );
+
+extern void
+_mesa_free_viewport_data( GLcontext *ctx );
+
+extern void
+_mesa_update_modelview_project( GLcontext *ctx, GLuint newstate );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/mesa.def b/nx-X11/extras/Mesa/src/mesa/main/mesa.def
new file mode 100644
index 000000000..b0c9ab3ca
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/mesa.def
@@ -0,0 +1,491 @@
+DESCRIPTION 'Mesa (OpenGL work-alike) for Win32'
+VERSION 4.1
+
+EXPORTS
+ glAccum
+ glAlphaFunc
+ glAreTexturesResident
+ glAreTexturesResidentEXT
+ glArrayElement
+ glArrayElementEXT
+ glBegin
+ glBindTexture
+ glBindTextureEXT
+ glBitmap
+ glBlendColorEXT
+ glBlendEquationEXT
+ glBlendFunc
+ glCallList
+ glCallLists
+ glClear
+ glClearAccum
+ glClearColor
+ glClearDepth
+ glClearIndex
+ glClearStencil
+ glClipPlane
+ glColor3b
+ glColor3bv
+ glColor3d
+ glColor3dv
+ glColor3f
+ glColor3fv
+ glColor3i
+ glColor3iv
+ glColor3s
+ glColor3sv
+ glColor3ub
+ glColor3ubv
+ glColor3ui
+ glColor3uiv
+ glColor3us
+ glColor3usv
+ glColor4b
+ glColor4bv
+ glColor4d
+ glColor4dv
+ glColor4f
+ glColor4fv
+ glColor4i
+ glColor4iv
+ glColor4s
+ glColor4sv
+ glColor4ub
+ glColor4ubv
+ glColor4ui
+ glColor4uiv
+ glColor4us
+ glColor4usv
+ glColorMask
+ glColorMaterial
+ glColorPointer
+ glColorPointerEXT
+ glColorSubTableEXT
+ glColorTableEXT
+ glCopyPixels
+ glCopyTexImage1D
+ glCopyTexImage2D
+ glCopyTexSubImage1D
+ glCopyTexSubImage2D
+ glCopyTexSubImage3DEXT
+ glCullFace
+ glDeleteLists
+ glDeleteTextures
+ glDeleteTexturesEXT
+ glDepthFunc
+ glDepthMask
+ glDepthRange
+ glDisable
+ glDisableClientState
+ glDrawArrays
+ glDrawArraysEXT
+ glDrawBuffer
+ glDrawElements
+ glDrawPixels
+ glEdgeFlag
+ glEdgeFlagPointer
+ glEdgeFlagPointerEXT
+ glEdgeFlagv
+ glEnable
+ glEnableClientState
+ glEnd
+ glEndList
+ glEvalCoord1d
+ glEvalCoord1dv
+ glEvalCoord1f
+ glEvalCoord1fv
+ glEvalCoord2d
+ glEvalCoord2dv
+ glEvalCoord2f
+ glEvalCoord2fv
+ glEvalMesh1
+ glEvalMesh2
+ glEvalPoint1
+ glEvalPoint2
+ glFeedbackBuffer
+ glFinish
+ glFlush
+ glFogf
+ glFogfv
+ glFogi
+ glFogiv
+ glFrontFace
+ glFrustum
+ glGenLists
+ glGenTextures
+ glGenTexturesEXT
+ glGetBooleanv
+ glGetClipPlane
+ glGetColorTableEXT
+ glGetColorTableParameterfvEXT
+ glGetColorTableParameterivEXT
+ glGetDoublev
+ glGetError
+ glGetFloatv
+ glGetIntegerv
+ glGetLightfv
+ glGetLightiv
+ glGetMapdv
+ glGetMapfv
+ glGetMapiv
+ glGetMaterialfv
+ glGetMaterialiv
+ glGetPixelMapfv
+ glGetPixelMapuiv
+ glGetPixelMapusv
+ glGetPointerv
+ glGetPointervEXT
+ glGetPolygonStipple
+ glGetString
+ glGetTexEnvfv
+ glGetTexEnviv
+ glGetTexGendv
+ glGetTexGenfv
+ glGetTexGeniv
+ glGetTexImage
+ glGetTexLevelParameterfv
+ glGetTexLevelParameteriv
+ glGetTexParameterfv
+ glGetTexParameteriv
+ glHint
+ glIndexd
+ glIndexdv
+ glIndexf
+ glIndexfv
+ glIndexi
+ glIndexiv
+ glIndexMask
+ glIndexPointer
+ glIndexPointerEXT
+ glIndexs
+ glIndexsv
+ glIndexub
+ glIndexubv
+ glInitNames
+ glInterleavedArrays
+ glIsEnabled
+ glIsList
+ glIsTexture
+ glIsTextureEXT
+ glLightf
+ glLightfv
+ glLighti
+ glLightiv
+ glLightModelf
+ glLightModelfv
+ glLightModeli
+ glLightModeliv
+ glLineStipple
+ glLineWidth
+ glListBase
+ glLoadIdentity
+ glLoadMatrixd
+ glLoadMatrixf
+ glLoadName
+ glLogicOp
+ glMap1d
+ glMap1f
+ glMap2d
+ glMap2f
+ glMapGrid1d
+ glMapGrid1f
+ glMapGrid2d
+ glMapGrid2f
+ glMaterialf
+ glMaterialfv
+ glMateriali
+ glMaterialiv
+ glMatrixMode
+ glMultMatrixd
+ glMultMatrixf
+ glNewList
+ glNormal3b
+ glNormal3bv
+ glNormal3d
+ glNormal3dv
+ glNormal3f
+ glNormal3fv
+ glNormal3i
+ glNormal3iv
+ glNormal3s
+ glNormal3sv
+ glNormalPointer
+ glNormalPointerEXT
+ glOrtho
+ glPassThrough
+ glPixelMapfv
+ glPixelMapuiv
+ glPixelMapusv
+ glPixelStoref
+ glPixelStorei
+ glPixelTransferf
+ glPixelTransferi
+ glPixelZoom
+ glPointParameterfEXT
+ glPointParameterfvEXT
+ glPointSize
+ glPolygonMode
+ glPolygonOffset
+ glPolygonOffsetEXT
+ glPolygonStipple
+ glPopAttrib
+ glPopClientAttrib
+ glPopMatrix
+ glPopName
+ glPrioritizeTextures
+ glPrioritizeTexturesEXT
+ glPushAttrib
+ glPushClientAttrib
+ glPushMatrix
+ glPushName
+ glRasterPos2d
+ glRasterPos2dv
+ glRasterPos2f
+ glRasterPos2fv
+ glRasterPos2i
+ glRasterPos2iv
+ glRasterPos2s
+ glRasterPos2sv
+ glRasterPos3d
+ glRasterPos3dv
+ glRasterPos3f
+ glRasterPos3fv
+ glRasterPos3i
+ glRasterPos3iv
+ glRasterPos3s
+ glRasterPos3sv
+ glRasterPos4d
+ glRasterPos4dv
+ glRasterPos4f
+ glRasterPos4fv
+ glRasterPos4i
+ glRasterPos4iv
+ glRasterPos4s
+ glRasterPos4sv
+ glReadBuffer
+ glReadPixels
+ glRectd
+ glRectdv
+ glRectf
+ glRectfv
+ glRecti
+ glRectiv
+ glRects
+ glRectsv
+ glRenderMode
+ glResizeBuffersMESA
+ glRotated
+ glRotatef
+ glScaled
+ glScalef
+ glScissor
+ glSelectBuffer
+ glShadeModel
+ glStencilFunc
+ glStencilMask
+ glStencilOp
+ glTexCoord1d
+ glTexCoord1dv
+ glTexCoord1f
+ glTexCoord1fv
+ glTexCoord1i
+ glTexCoord1iv
+ glTexCoord1s
+ glTexCoord1sv
+ glTexCoord2d
+ glTexCoord2dv
+ glTexCoord2f
+ glTexCoord2fv
+ glTexCoord2i
+ glTexCoord2iv
+ glTexCoord2s
+ glTexCoord2sv
+ glTexCoord3d
+ glTexCoord3dv
+ glTexCoord3f
+ glTexCoord3fv
+ glTexCoord3i
+ glTexCoord3iv
+ glTexCoord3s
+ glTexCoord3sv
+ glTexCoord4d
+ glTexCoord4dv
+ glTexCoord4f
+ glTexCoord4fv
+ glTexCoord4i
+ glTexCoord4iv
+ glTexCoord4s
+ glTexCoord4sv
+ glTexCoordPointer
+ glTexCoordPointerEXT
+ glTexEnvf
+ glTexEnvfv
+ glTexEnvi
+ glTexEnviv
+ glTexGend
+ glTexGendv
+ glTexGenf
+ glTexGenfv
+ glTexGeni
+ glTexGeniv
+ glTexImage1D
+ glTexImage2D
+ glTexImage3DEXT
+ glTexParameterf
+ glTexParameterfv
+ glTexParameteri
+ glTexParameteriv
+ glTexSubImage1D
+ glTexSubImage2D
+ glTexSubImage3DEXT
+ glTranslated
+ glTranslatef
+ glVertex2d
+ glVertex2dv
+ glVertex2f
+ glVertex2fv
+ glVertex2i
+ glVertex2iv
+ glVertex2s
+ glVertex2sv
+ glVertex3d
+ glVertex3dv
+ glVertex3f
+ glVertex3fv
+ glVertex3i
+ glVertex3iv
+ glVertex3s
+ glVertex3sv
+ glVertex4d
+ glVertex4dv
+ glVertex4f
+ glVertex4fv
+ glVertex4i
+ glVertex4iv
+ glVertex4s
+ glVertex4sv
+ glVertexPointer
+ glVertexPointerEXT
+ glViewport
+ glWindowPos2dMESA
+ glWindowPos2dvMESA
+ glWindowPos2fMESA
+ glWindowPos2fvMESA
+ glWindowPos2iMESA
+ glWindowPos2ivMESA
+ glWindowPos2sMESA
+ glWindowPos2svMESA
+ glWindowPos3dMESA
+ glWindowPos3dvMESA
+ glWindowPos3fMESA
+ glWindowPos3fvMESA
+ glWindowPos3iMESA
+ glWindowPos3ivMESA
+ glWindowPos3sMESA
+ glWindowPos3svMESA
+ glWindowPos4dMESA
+ glWindowPos4dvMESA
+ glWindowPos4fMESA
+ glWindowPos4fvMESA
+ glWindowPos4iMESA
+ glWindowPos4ivMESA
+ glWindowPos4sMESA
+ glWindowPos4svMESA
+ _swsetup_Wakeup
+ _swsetup_CreateContext
+ _tnl_CreateContext
+ _ac_CreateContext
+ _swrast_CreateContext
+ _mesa_free_context_data
+ _mesa_create_framebuffer
+ _mesa_enable_1_3_extensions
+ _mesa_enable_1_4_extensions
+ _mesa_enable_sw_extensions
+ _mesa_destroy_visual
+ _mesa_initialize_context
+ _mesa_create_visual
+ _mesa_destroy_framebuffer
+ _swrast_DestroyContext
+ _ac_DestroyContext
+ _tnl_DestroyContext
+ _swsetup_DestroyContext
+ _mesa_Viewport
+ _mesa_make_current
+ _mesa_get_current_context
+ _mesa_error
+ _swrast_choose_triangle
+ _mesa_zbuffer_address
+ _swrast_choose_line
+ _tnl_InvalidateState
+ _ac_InvalidateState
+ _swsetup_InvalidateState
+ _swrast_InvalidateState
+ _tnl_run_pipeline
+ _swrast_CopyConvolutionFilter2D
+ _swrast_CopyConvolutionFilter1D
+ _swrast_CopyColorSubTable
+ _swrast_CopyColorTable
+ _swrast_copy_texsubimage3d
+ _swrast_copy_texsubimage2d
+ _swrast_copy_texsubimage1d
+ _swrast_copy_teximage2d
+ _swrast_copy_teximage1d
+ _mesa_test_proxy_teximage
+ _mesa_store_texsubimage3d
+ _mesa_store_texsubimage2d
+ _mesa_store_texsubimage1d
+ _mesa_store_teximage3d
+ _mesa_store_teximage2d
+ _mesa_store_teximage1d
+ _mesa_store_compressed_texsubimage3d
+ _mesa_store_compressed_texsubimage2d
+ _mesa_store_compressed_texsubimage1d
+ _mesa_store_compressed_teximage3d
+ _mesa_store_compressed_teximage2d
+ _mesa_store_compressed_teximage1d
+ _mesa_choose_tex_format
+ _mesa_compressed_texture_size
+ _swrast_ReadPixels
+ _swrast_DrawPixels
+ _swrast_CopyPixels
+ _swrast_Bitmap
+ _swrast_Accum
+ _swrast_alloc_buffers
+ _swrast_GetDeviceDriverReference
+ _swrast_Clear
+ _glapi_get_context
+ _mesa_ResizeBuffersMESA
+ _glapi_get_proc_address
+ _mesa_init_default_imports
+ _tnl_MakeCurrent
+ _swrast_DrawBuffer
+ _mesa_free
+ _mesa_calloc
+ _mesa_strcmp
+ _mesa_bzero
+ _mesa_memset
+ _mesa_memcpy
+ _mesa_problem
+ wglCopyContext
+ wglCreateContext
+ wglDeleteContext
+ wglCreateLayerContext
+ wglGetCurrentContext
+ wglGetCurrentDC
+ wglMakeCurrent
+ wglShareLists
+ wglUseFontBitmapsA
+ wglUseFontBitmapsW
+ wglUseFontOutlinesA
+ wglUseFontOutlinesW
+ wglDescribeLayerPlane
+ wglSetLayerPaletteEntries
+ wglGetLayerPaletteEntries
+ wglRealizeLayerPalette
+ wglSwapLayerBuffers
+ wglChoosePixelFormat
+ wglDescribePixelFormat
+ wglGetProcAddress
+ wglGetPixelFormat
+ wglSetPixelFormat
+ wglSwapBuffers
diff --git a/nx-X11/extras/Mesa/src/mesa/main/mm.c b/nx-X11/extras/Mesa/src/mesa/main/mm.c
new file mode 100644
index 000000000..e4c968217
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/mm.c
@@ -0,0 +1,220 @@
+/*
+ * GLX Hardware Device Driver common code
+ * Copyright (C) 1999 Wittawat Yamwong
+ *
+ * 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
+ * WITTAWAT YAMWONG, OR ANY OTHER CONTRIBUTORS 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.
+ *
+ */
+
+#include "mm.h"
+
+
+void
+mmDumpMemInfo(const memHeap_t *heap)
+{
+ const TMemBlock *p;
+
+ fprintf(stderr, "Memory heap %p:\n", (void *)heap);
+ if (heap == 0) {
+ fprintf(stderr, " heap == 0\n");
+ } else {
+ p = (TMemBlock *)heap;
+ while (p) {
+ fprintf(stderr, " Offset:%08x, Size:%08x, %c%c\n",p->ofs,p->size,
+ p->free ? '.':'U',
+ p->reserved ? 'R':'.');
+ p = p->next;
+ }
+ }
+ fprintf(stderr, "End of memory blocks\n");
+}
+
+memHeap_t *
+mmInit(int ofs, int size)
+{
+ PMemBlock blocks;
+
+ if (size <= 0) {
+ return NULL;
+ }
+ blocks = (TMemBlock *) _mesa_calloc(sizeof(TMemBlock));
+ if (blocks) {
+ blocks->ofs = ofs;
+ blocks->size = size;
+ blocks->free = 1;
+ return (memHeap_t *)blocks;
+ }
+ else {
+ return NULL;
+ }
+}
+
+
+static TMemBlock *
+SliceBlock(TMemBlock *p,
+ int startofs, int size,
+ int reserved, int alignment)
+{
+ TMemBlock *newblock;
+
+ /* break left */
+ if (startofs > p->ofs) {
+ newblock = (TMemBlock*) _mesa_calloc(sizeof(TMemBlock));
+ if (!newblock)
+ return NULL;
+ newblock->ofs = startofs;
+ newblock->size = p->size - (startofs - p->ofs);
+ newblock->free = 1;
+ newblock->next = p->next;
+ p->size -= newblock->size;
+ p->next = newblock;
+ p = newblock;
+ }
+
+ /* break right */
+ if (size < p->size) {
+ newblock = (TMemBlock*) _mesa_calloc(sizeof(TMemBlock));
+ if (!newblock)
+ return NULL;
+ newblock->ofs = startofs + size;
+ newblock->size = p->size - size;
+ newblock->free = 1;
+ newblock->next = p->next;
+ p->size = size;
+ p->next = newblock;
+ }
+
+ /* p = middle block */
+ p->align = alignment;
+ p->free = 0;
+ p->reserved = reserved;
+ return p;
+}
+
+
+PMemBlock
+mmAllocMem(memHeap_t *heap, int size, int align2, int startSearch)
+{
+ int mask,startofs,endofs;
+ TMemBlock *p;
+
+ if (!heap || align2 < 0 || size <= 0)
+ return NULL;
+ mask = (1 << align2)-1;
+ startofs = 0;
+ p = (TMemBlock *)heap;
+ while (p) {
+ if ((p)->free) {
+ startofs = (p->ofs + mask) & ~mask;
+ if ( startofs < startSearch ) {
+ startofs = startSearch;
+ }
+ endofs = startofs+size;
+ if (endofs <= (p->ofs+p->size))
+ break;
+ }
+ p = p->next;
+ }
+ if (!p)
+ return NULL;
+ p = SliceBlock(p,startofs,size,0,mask+1);
+ p->heap = heap;
+ return p;
+}
+
+
+PMemBlock
+mmFindBlock(memHeap_t *heap, int start)
+{
+ TMemBlock *p = (TMemBlock *)heap;
+
+ while (p) {
+ if (p->ofs == start && p->free)
+ return p;
+
+ p = p->next;
+ }
+
+ return NULL;
+}
+
+
+static INLINE int
+Join2Blocks(TMemBlock *p)
+{
+ /* XXX there should be some assertions here */
+ if (p->free && p->next && p->next->free) {
+ TMemBlock *q = p->next;
+ p->size += q->size;
+ p->next = q->next;
+ _mesa_free(q);
+ return 1;
+ }
+ return 0;
+}
+
+int
+mmFreeMem(PMemBlock b)
+{
+ TMemBlock *p,*prev;
+
+ if (!b)
+ return 0;
+ if (!b->heap) {
+ fprintf(stderr, "no heap\n");
+ return -1;
+ }
+ p = b->heap;
+ prev = NULL;
+ while (p && p != b) {
+ prev = p;
+ p = p->next;
+ }
+ if (!p || p->free || p->reserved) {
+ if (!p)
+ fprintf(stderr, "block not found in heap\n");
+ else if (p->free)
+ fprintf(stderr, "block already free\n");
+ else
+ fprintf(stderr, "block is reserved\n");
+ return -1;
+ }
+ p->free = 1;
+ Join2Blocks(p);
+ if (prev)
+ Join2Blocks(prev);
+ return 0;
+}
+
+
+void
+mmDestroy(memHeap_t *heap)
+{
+ TMemBlock *p;
+
+ if (!heap)
+ return;
+
+ p = (TMemBlock *) heap;
+ while (p) {
+ TMemBlock *next = p->next;
+ _mesa_free(p);
+ p = next;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/mm.h b/nx-X11/extras/Mesa/src/mesa/main/mm.h
new file mode 100644
index 000000000..33c986b4c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/mm.h
@@ -0,0 +1,115 @@
+/*
+ * GLX Hardware Device Driver common code
+ * Copyright (C) 1999 Keith Whitwell
+ *
+ * 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
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
+ */
+
+
+/**
+ * Memory manager code. Primarily used by device drivers to manage texture
+ * heaps, etc.
+ */
+
+
+#ifndef MM_H
+#define MM_H
+
+
+#include "imports.h"
+
+
+struct mem_block_t {
+ struct mem_block_t *next;
+ struct mem_block_t *heap;
+ int ofs,size;
+ int align;
+ unsigned int free:1;
+ unsigned int reserved:1;
+};
+
+typedef struct mem_block_t TMemBlock;
+
+typedef struct mem_block_t *PMemBlock;
+
+/* a heap is just the first block in a chain */
+typedef struct mem_block_t memHeap_t;
+
+
+/* XXX are these needed? */
+#if 0
+static INLINE int
+mmBlockSize(PMemBlock b)
+{
+ return b->size;
+}
+
+static INLINE int
+mmOffset(PMemBlock b)
+{
+ return b->ofs;
+}
+#endif
+
+
+
+/**
+ * input: total size in bytes
+ * return: a heap pointer if OK, NULL if error
+ */
+extern memHeap_t *mmInit(int ofs, int size);
+
+/**
+ * Allocate 'size' bytes with 2^align2 bytes alignment,
+ * restrict the search to free memory after 'startSearch'
+ * depth and back buffers should be in different 4mb banks
+ * to get better page hits if possible
+ * input: size = size of block
+ * align2 = 2^align2 bytes alignment
+ * startSearch = linear offset from start of heap to begin search
+ * return: pointer to the allocated block, 0 if error
+ */
+extern PMemBlock mmAllocMem(memHeap_t *heap, int size, int align2,
+ int startSearch);
+
+/**
+ * Free block starts at offset
+ * input: pointer to a block
+ * return: 0 if OK, -1 if error
+ */
+extern int mmFreeMem(PMemBlock b);
+
+/**
+ * Free block starts at offset
+ * input: pointer to a heap, start offset
+ * return: pointer to a block
+ */
+extern PMemBlock mmFindBlock(memHeap_t *heap, int start);
+
+/**
+ * destroy MM
+ */
+extern void mmDestroy(memHeap_t *mmInit);
+
+/**
+ * For debuging purpose.
+ */
+extern void mmDumpMemInfo(const memHeap_t *mmInit);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/mtypes.h b/nx-X11/extras/Mesa/src/mesa/main/mtypes.h
new file mode 100644
index 000000000..2a0bbd942
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/mtypes.h
@@ -0,0 +1,2930 @@
+/**
+ * \file mtypes.h
+ * Main Mesa data structures.
+ *
+ * Please try to mark derived values with a leading underscore ('_').
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+
+#ifndef TYPES_H
+#define TYPES_H
+
+
+#include "glheader.h"
+#include "config.h" /* Hardwired parameters */
+#include "glapitable.h"
+#include "glthread.h"
+#include "math/m_matrix.h" /* GLmatrix */
+
+
+/**
+ * Color channel data type.
+ */
+#if CHAN_BITS == 8
+ typedef GLubyte GLchan;
+#define CHAN_MAX 255
+#define CHAN_MAXF 255.0F
+#define CHAN_TYPE GL_UNSIGNED_BYTE
+#elif CHAN_BITS == 16
+ typedef GLushort GLchan;
+#define CHAN_MAX 65535
+#define CHAN_MAXF 65535.0F
+#define CHAN_TYPE GL_UNSIGNED_SHORT
+#elif CHAN_BITS == 32
+ typedef GLfloat GLchan;
+#define CHAN_MAX 1.0
+#define CHAN_MAXF 1.0F
+#define CHAN_TYPE GL_FLOAT
+#else
+#error "illegal number of color channel bits"
+#endif
+
+
+#if ACCUM_BITS != 16
+/* Software accum done with GLshort at this time */
+# error "illegal number of accumulation bits"
+#endif
+
+
+/**
+ * Stencil buffer data type.
+ */
+#if STENCIL_BITS==8
+ typedef GLubyte GLstencil;
+# define STENCIL_MAX 0xff
+#elif STENCIL_BITS==16
+ typedef GLushort GLstencil;
+# define STENCIL_MAX 0xffff
+#else
+# error "illegal number of stencil bits"
+#endif
+
+
+/**
+ * Used for storing intermediate depth buffer values.
+ * The actual depth/Z buffer might use 16 or 32-bit values.
+ *
+ * \note Must be 32-bits!
+ */
+typedef GLuint GLdepth;
+
+
+/**
+ * Fixed point data type.
+ */
+typedef int GLfixed;
+/*
+ * Fixed point arithmetic macros
+ */
+#ifndef FIXED_FRAC_BITS
+#define FIXED_FRAC_BITS 11
+#endif
+
+#define FIXED_SHIFT FIXED_FRAC_BITS
+#define FIXED_ONE (1 << FIXED_SHIFT)
+#define FIXED_HALF (1 << (FIXED_SHIFT-1))
+#define FIXED_FRAC_MASK (FIXED_ONE - 1)
+#define FIXED_INT_MASK (~FIXED_FRAC_MASK)
+#define FIXED_EPSILON 1
+#define FIXED_SCALE ((float) FIXED_ONE)
+#define FIXED_DBL_SCALE ((double) FIXED_ONE)
+#define FloatToFixed(X) (IROUND((X) * FIXED_SCALE))
+#define FixedToDouble(X) ((X) * (1.0 / FIXED_DBL_SCALE))
+#define IntToFixed(I) ((I) << FIXED_SHIFT)
+#define FixedToInt(X) ((X) >> FIXED_SHIFT)
+#define FixedToUns(X) (((unsigned int)(X)) >> FIXED_SHIFT)
+#define FixedCeil(X) (((X) + FIXED_ONE - FIXED_EPSILON) & FIXED_INT_MASK)
+#define FixedFloor(X) ((X) & FIXED_INT_MASK)
+#define FixedToFloat(X) ((X) * (1.0F / FIXED_SCALE))
+#define PosFloatToFixed(X) FloatToFixed(X)
+#define SignedFloatToFixed(X) FloatToFixed(X)
+
+
+
+/**
+ * \name Some forward type declarations
+ */
+/*@{*/
+struct _mesa_HashTable;
+struct gl_pixelstore_attrib;
+struct gl_texture_format;
+struct gl_texture_image;
+struct gl_texture_object;
+typedef struct __GLcontextRec GLcontext;
+typedef struct __GLcontextModesRec GLvisual;
+typedef struct gl_framebuffer GLframebuffer;
+/*@}*/
+
+
+
+/**
+ * Indexes for vertex program attributes.
+ * GL_NV_vertex_program aliases generic attributes over the conventional
+ * attributes. In GL_ARB_vertex_program shader the aliasing is optional.
+ * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
+ * generic attributes are distinct/separate).
+ */
+enum
+{
+ VERT_ATTRIB_POS = 0,
+ VERT_ATTRIB_WEIGHT = 1,
+ VERT_ATTRIB_NORMAL = 2,
+ VERT_ATTRIB_COLOR0 = 3,
+ VERT_ATTRIB_COLOR1 = 4,
+ VERT_ATTRIB_FOG = 5,
+ VERT_ATTRIB_SIX = 6,
+ VERT_ATTRIB_SEVEN = 7,
+ VERT_ATTRIB_TEX0 = 8,
+ VERT_ATTRIB_TEX1 = 9,
+ VERT_ATTRIB_TEX2 = 10,
+ VERT_ATTRIB_TEX3 = 11,
+ VERT_ATTRIB_TEX4 = 12,
+ VERT_ATTRIB_TEX5 = 13,
+ VERT_ATTRIB_TEX6 = 14,
+ VERT_ATTRIB_TEX7 = 15,
+ VERT_ATTRIB_GENERIC0 = 16,
+ VERT_ATTRIB_GENERIC1 = 17,
+ VERT_ATTRIB_GENERIC2 = 18,
+ VERT_ATTRIB_GENERIC3 = 19,
+ VERT_ATTRIB_MAX = 16
+};
+
+/**
+ * Bitflags for vertex attributes.
+ * These are used in bitfields in many places.
+ */
+/*@{*/
+#define VERT_BIT_POS (1 << VERT_ATTRIB_POS)
+#define VERT_BIT_WEIGHT (1 << VERT_ATTRIB_WEIGHT)
+#define VERT_BIT_NORMAL (1 << VERT_ATTRIB_NORMAL)
+#define VERT_BIT_COLOR0 (1 << VERT_ATTRIB_COLOR0)
+#define VERT_BIT_COLOR1 (1 << VERT_ATTRIB_COLOR1)
+#define VERT_BIT_FOG (1 << VERT_ATTRIB_FOG)
+#define VERT_BIT_SIX (1 << VERT_ATTRIB_SIX)
+#define VERT_BIT_SEVEN (1 << VERT_ATTRIB_SEVEN)
+#define VERT_BIT_TEX0 (1 << VERT_ATTRIB_TEX0)
+#define VERT_BIT_TEX1 (1 << VERT_ATTRIB_TEX1)
+#define VERT_BIT_TEX2 (1 << VERT_ATTRIB_TEX2)
+#define VERT_BIT_TEX3 (1 << VERT_ATTRIB_TEX3)
+#define VERT_BIT_TEX4 (1 << VERT_ATTRIB_TEX4)
+#define VERT_BIT_TEX5 (1 << VERT_ATTRIB_TEX5)
+#define VERT_BIT_TEX6 (1 << VERT_ATTRIB_TEX6)
+#define VERT_BIT_TEX7 (1 << VERT_ATTRIB_TEX7)
+#define VERT_BIT_GENERIC0 (1 << VERT_ATTRIB_GENERIC0)
+#define VERT_BIT_GENERIC1 (1 << VERT_ATTRIB_GENERIC1)
+#define VERT_BIT_GENERIC2 (1 << VERT_ATTRIB_GENERIC2)
+#define VERT_BIT_GENERIC3 (1 << VERT_ATTRIB_GENERIC3)
+
+#define VERT_BIT_TEX(u) (1 << (VERT_ATTRIB_TEX0 + (u)))
+#define VERT_BIT_GENERIC(g) (1 << (VERT_ATTRIB_GENERIC0 + (g)))
+/*@}*/
+
+
+/**
+ * Indexes for vertex program result attributes
+ */
+#define VERT_RESULT_HPOS 0
+#define VERT_RESULT_COL0 1
+#define VERT_RESULT_COL1 2
+#define VERT_RESULT_BFC0 3
+#define VERT_RESULT_BFC1 4
+#define VERT_RESULT_FOGC 5
+#define VERT_RESULT_PSIZ 6
+#define VERT_RESULT_TEX0 7
+#define VERT_RESULT_TEX1 8
+#define VERT_RESULT_TEX2 9
+#define VERT_RESULT_TEX3 10
+#define VERT_RESULT_TEX4 11
+#define VERT_RESULT_TEX5 12
+#define VERT_RESULT_TEX6 13
+#define VERT_RESULT_TEX7 14
+#define VERT_RESULT_MAX 15
+
+
+/**
+ * Indexes for fragment program input attributes.
+ */
+enum
+{
+ FRAG_ATTRIB_WPOS = 0,
+ FRAG_ATTRIB_COL0 = 1,
+ FRAG_ATTRIB_COL1 = 2,
+ FRAG_ATTRIB_FOGC = 3,
+ FRAG_ATTRIB_TEX0 = 4,
+ FRAG_ATTRIB_TEX1 = 5,
+ FRAG_ATTRIB_TEX2 = 6,
+ FRAG_ATTRIB_TEX3 = 7,
+ FRAG_ATTRIB_TEX4 = 8,
+ FRAG_ATTRIB_TEX5 = 9,
+ FRAG_ATTRIB_TEX6 = 10,
+ FRAG_ATTRIB_TEX7 = 11
+};
+
+/*
+ * Bitflags for fragment attributes.
+ */
+/*@{*/
+#define FRAG_BIT_WPOS (1 << FRAG_ATTRIB_WPOS)
+#define FRAG_BIT_COL0 (1 << FRAG_ATTRIB_COL0)
+#define FRAG_BIT_COL1 (1 << FRAG_ATTRIB_COL1)
+#define FRAG_BIT_FOGC (1 << FRAG_ATTRIB_FOGC)
+#define FRAG_BIT_TEX0 (1 << FRAG_ATTRIB_TEX0)
+#define FRAG_BIT_TEX1 (1 << FRAG_ATTRIB_TEX1)
+#define FRAG_BIT_TEX2 (1 << FRAG_ATTRIB_TEX2)
+#define FRAG_BIT_TEX3 (1 << FRAG_ATTRIB_TEX3)
+#define FRAG_BIT_TEX4 (1 << FRAG_ATTRIB_TEX4)
+#define FRAG_BIT_TEX5 (1 << FRAG_ATTRIB_TEX5)
+#define FRAG_BIT_TEX6 (1 << FRAG_ATTRIB_TEX6)
+#define FRAG_BIT_TEX7 (1 << FRAG_ATTRIB_TEX7)
+
+#define FRAG_BITS_TEX_ANY (FRAG_BIT_TEX0| \
+ FRAG_BIT_TEX1| \
+ FRAG_BIT_TEX2| \
+ FRAG_BIT_TEX3| \
+ FRAG_BIT_TEX4| \
+ FRAG_BIT_TEX5| \
+ FRAG_BIT_TEX6| \
+ FRAG_BIT_TEX7)
+/*@}*/
+
+
+/**
+ * Indexes for all renderbuffers
+ */
+enum {
+ BUFFER_FRONT_LEFT = 0, /* the four standard color buffers */
+ BUFFER_BACK_LEFT = 1,
+ BUFFER_FRONT_RIGHT = 2,
+ BUFFER_BACK_RIGHT = 3,
+ BUFFER_AUX0 = 4, /* optional aux buffer */
+ BUFFER_AUX1 = 5,
+ BUFFER_AUX2 = 6,
+ BUFFER_AUX3 = 7,
+ BUFFER_DEPTH = 8,
+ BUFFER_STENCIL = 9,
+ BUFFER_ACCUM = 10,
+ BUFFER_COLOR0 = 11, /* generic renderbuffers */
+ BUFFER_COLOR1 = 12,
+ BUFFER_COLOR2 = 13,
+ BUFFER_COLOR3 = 14,
+ BUFFER_COLOR4 = 15,
+ BUFFER_COLOR5 = 16,
+ BUFFER_COLOR6 = 17,
+ BUFFER_COLOR7 = 18,
+ BUFFER_COUNT = 19
+};
+
+/**
+ * Bit flags for all renderbuffers
+ */
+#define BUFFER_BIT_FRONT_LEFT (1 << BUFFER_FRONT_LEFT)
+#define BUFFER_BIT_BACK_LEFT (1 << BUFFER_BACK_LEFT)
+#define BUFFER_BIT_FRONT_RIGHT (1 << BUFFER_FRONT_RIGHT)
+#define BUFFER_BIT_BACK_RIGHT (1 << BUFFER_BACK_RIGHT)
+#define BUFFER_BIT_AUX0 (1 << BUFFER_AUX0)
+#define BUFFER_BIT_AUX1 (1 << BUFFER_AUX1)
+#define BUFFER_BIT_AUX2 (1 << BUFFER_AUX2)
+#define BUFFER_BIT_AUX3 (1 << BUFFER_AUX3)
+#define BUFFER_BIT_DEPTH (1 << BUFFER_DEPTH)
+#define BUFFER_BIT_STENCIL (1 << BUFFER_STENCIL)
+#define BUFFER_BIT_ACCUM (1 << BUFFER_ACCUM)
+#define BUFFER_BIT_COLOR0 (1 << BUFFER_COLOR0)
+#define BUFFER_BIT_COLOR1 (1 << BUFFER_COLOR1)
+#define BUFFER_BIT_COLOR2 (1 << BUFFER_COLOR2)
+#define BUFFER_BIT_COLOR3 (1 << BUFFER_COLOR3)
+#define BUFFER_BIT_COLOR4 (1 << BUFFER_COLOR4)
+#define BUFFER_BIT_COLOR5 (1 << BUFFER_COLOR5)
+#define BUFFER_BIT_COLOR6 (1 << BUFFER_COLOR6)
+#define BUFFER_BIT_COLOR7 (1 << BUFFER_COLOR7)
+
+
+/**
+ * Data structure for color tables
+ */
+struct gl_color_table
+{
+ GLenum Format; /**< GL_ALPHA, GL_RGB, GL_RGB, etc */
+ GLenum IntFormat;
+ GLuint Size; /**< number of entries (rows) in table */
+ GLvoid *Table; /**< points to data of <Type> */
+ GLenum Type; /**< GL_UNSIGNED_BYTE or GL_FLOAT */
+ GLubyte RedSize;
+ GLubyte GreenSize;
+ GLubyte BlueSize;
+ GLubyte AlphaSize;
+ GLubyte LuminanceSize;
+ GLubyte IntensitySize;
+};
+
+
+/**
+ * \name Bit flags used for updating material values.
+ */
+/*@{*/
+#define MAT_ATTRIB_FRONT_AMBIENT 0
+#define MAT_ATTRIB_BACK_AMBIENT 1
+#define MAT_ATTRIB_FRONT_DIFFUSE 2
+#define MAT_ATTRIB_BACK_DIFFUSE 3
+#define MAT_ATTRIB_FRONT_SPECULAR 4
+#define MAT_ATTRIB_BACK_SPECULAR 5
+#define MAT_ATTRIB_FRONT_EMISSION 6
+#define MAT_ATTRIB_BACK_EMISSION 7
+#define MAT_ATTRIB_FRONT_SHININESS 8
+#define MAT_ATTRIB_BACK_SHININESS 9
+#define MAT_ATTRIB_FRONT_INDEXES 10
+#define MAT_ATTRIB_BACK_INDEXES 11
+#define MAT_ATTRIB_MAX 12
+
+#define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
+#define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
+#define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
+#define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
+#define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
+#define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
+
+#define MAT_INDEX_AMBIENT 0
+#define MAT_INDEX_DIFFUSE 1
+#define MAT_INDEX_SPECULAR 2
+
+#define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
+#define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
+#define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
+#define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
+#define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
+#define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
+#define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
+#define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
+#define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
+#define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
+#define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
+#define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
+
+
+#define FRONT_MATERIAL_BITS (MAT_BIT_FRONT_EMISSION | \
+ MAT_BIT_FRONT_AMBIENT | \
+ MAT_BIT_FRONT_DIFFUSE | \
+ MAT_BIT_FRONT_SPECULAR | \
+ MAT_BIT_FRONT_SHININESS | \
+ MAT_BIT_FRONT_INDEXES)
+
+#define BACK_MATERIAL_BITS (MAT_BIT_BACK_EMISSION | \
+ MAT_BIT_BACK_AMBIENT | \
+ MAT_BIT_BACK_DIFFUSE | \
+ MAT_BIT_BACK_SPECULAR | \
+ MAT_BIT_BACK_SHININESS | \
+ MAT_BIT_BACK_INDEXES)
+
+#define ALL_MATERIAL_BITS (FRONT_MATERIAL_BITS | BACK_MATERIAL_BITS)
+/*@}*/
+
+
+#define EXP_TABLE_SIZE 512 /**< Specular exponent lookup table sizes */
+#define SHINE_TABLE_SIZE 256 /**< Material shininess lookup table sizes */
+
+/**
+ * Material shininess lookup table.
+ */
+struct gl_shine_tab
+{
+ struct gl_shine_tab *next, *prev;
+ GLfloat tab[SHINE_TABLE_SIZE+1];
+ GLfloat shininess;
+ GLuint refcount;
+};
+
+
+/**
+ * Light source state.
+ */
+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 degrees */
+ GLfloat _CosCutoff; /**< = MAX(0, cos(SpotCutoff)) */
+ GLfloat ConstantAttenuation;
+ GLfloat LinearAttenuation;
+ GLfloat QuadraticAttenuation;
+ GLboolean Enabled; /**< On/off flag */
+
+ /**
+ * \name 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 */
+ /*@}*/
+};
+
+
+/**
+ * Light model state.
+ */
+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 */
+};
+
+
+/**
+ * Material state.
+ */
+struct gl_material
+{
+ GLfloat Attrib[MAT_ATTRIB_MAX][4];
+};
+
+
+/**
+ * Accumulation buffer attribute group (GL_ACCUM_BUFFER_BIT)
+ */
+struct gl_accum_attrib
+{
+ GLfloat ClearColor[4]; /**< Accumulation buffer clear color */
+};
+
+
+/**
+ * Color buffer attribute group (GL_COLOR_BUFFER_BIT).
+ */
+struct gl_colorbuffer_attrib
+{
+ GLuint ClearIndex; /**< Index to use for glClear */
+ GLclampf ClearColor[4]; /**< Color to use for glClear */
+
+ GLuint IndexMask; /**< Color index write mask */
+ GLubyte ColorMask[4]; /**< Each flag is 0xff or 0x0 */
+
+ GLenum DrawBuffer[MAX_DRAW_BUFFERS]; /**< Which buffer to draw into */
+
+ /**
+ * \name alpha testing
+ */
+ /*@{*/
+ GLboolean AlphaEnabled; /**< Alpha test enabled flag */
+ GLenum AlphaFunc; /**< Alpha test function */
+ GLclampf AlphaRef; /**< Alpha reference value */
+ /*@}*/
+
+ /**
+ * \name 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 BlendEquationRGB; /**< Blending equation */
+ GLenum BlendEquationA; /**< GL_EXT_blend_equation_separate */
+ GLfloat BlendColor[4]; /**< Blending color */
+ /*@}*/
+
+ /**
+ * \name Logic op
+ */
+ /*@{*/
+ GLenum LogicOp; /**< Logic operator */
+ GLboolean IndexLogicOpEnabled; /**< Color index logic op enabled flag */
+ GLboolean ColorLogicOpEnabled; /**< RGBA logic op enabled flag */
+ GLboolean _LogicOpEnabled; /**< RGBA logic op + EXT_blend_logic_op enabled flag */
+ /*@}*/
+
+ GLboolean DitherFlag; /**< Dither enable flag */
+};
+
+
+/**
+ * Current attribute group (GL_CURRENT_BIT).
+ */
+struct gl_current_attrib
+{
+ /**
+ * \name Values valid only when FLUSH_VERTICES has been called.
+ */
+ /*@{*/
+ GLfloat Attrib[VERT_ATTRIB_MAX][4]; /**< Current vertex attributes
+ * indexed by VERT_ATTRIB_* */
+ GLfloat Index; /**< Current color index */
+ GLboolean EdgeFlag; /**< Current edge flag */
+ /*@}*/
+
+ /**
+ * \name Values are always valid.
+ *
+ * \note BTW, note how similar this set of attributes is to the SWvertex
+ * data type in the software rasterizer...
+ */
+ /*@{*/
+ GLfloat RasterPos[4]; /**< Current raster position */
+ GLfloat RasterDistance; /**< Current raster distance */
+ GLfloat RasterColor[4]; /**< Current raster color */
+ GLfloat RasterSecondaryColor[4]; /**< Current raster secondary color */
+ GLfloat RasterIndex; /**< Current raster index */
+ GLfloat RasterTexCoords[MAX_TEXTURE_UNITS][4];/**< Current raster texcoords */
+ GLboolean RasterPosValid; /**< Raster pos valid flag */
+ /*@}*/
+};
+
+
+/**
+ * Depth buffer attribute group (GL_DEPTH_BUFFER_BIT).
+ */
+struct gl_depthbuffer_attrib
+{
+ GLenum Func; /**< Function for depth buffer compare */
+ GLclampd Clear; /**< Value to clear depth buffer to */
+ GLboolean Test; /**< Depth buffering enabled flag */
+ GLboolean Mask; /**< Depth buffer writable? */
+ GLboolean OcclusionTest; /**< GL_HP_occlusion_test */
+ GLboolean BoundsTest; /**< GL_EXT_depth_bounds_test */
+ GLfloat BoundsMin, BoundsMax;/**< GL_EXT_depth_bounds_test */
+};
+
+
+/**
+ * glEnable()/glDisable() attribute group (GL_ENABLE_BIT).
+ */
+struct gl_enable_attrib
+{
+ GLboolean AlphaTest;
+ GLboolean AutoNormal;
+ GLboolean Blend;
+ GLuint ClipPlanes;
+ GLboolean ColorMaterial;
+ GLboolean ColorTable; /* SGI_color_table */
+ GLboolean PostColorMatrixColorTable; /* SGI_color_table */
+ GLboolean PostConvolutionColorTable; /* SGI_color_table */
+ 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 Map1Attrib[16]; /* GL_NV_vertex_program */
+ GLboolean Map2Color4;
+ GLboolean Map2Index;
+ GLboolean Map2Normal;
+ GLboolean Map2TextureCoord1;
+ GLboolean Map2TextureCoord2;
+ GLboolean Map2TextureCoord3;
+ GLboolean Map2TextureCoord4;
+ GLboolean Map2Vertex3;
+ GLboolean Map2Vertex4;
+ GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */
+ GLboolean MinMax;
+ GLboolean Normalize;
+ GLboolean PixelTexture;
+ GLboolean PointSmooth;
+ GLboolean PolygonOffsetPoint;
+ GLboolean PolygonOffsetLine;
+ GLboolean PolygonOffsetFill;
+ GLboolean PolygonSmooth;
+ GLboolean PolygonStipple;
+ GLboolean RescaleNormals;
+ GLboolean Scissor;
+ GLboolean Stencil;
+ GLboolean StencilTwoSide; /* GL_EXT_stencil_two_side */
+ GLboolean MultisampleEnabled; /* GL_ARB_multisample */
+ GLboolean SampleAlphaToCoverage; /* GL_ARB_multisample */
+ GLboolean SampleAlphaToOne; /* GL_ARB_multisample */
+ GLboolean SampleCoverage; /* GL_ARB_multisample */
+ GLboolean SampleCoverageInvert; /* GL_ARB_multisample */
+ GLboolean RasterPositionUnclipped; /* GL_IBM_rasterpos_clip */
+ GLuint Texture[MAX_TEXTURE_IMAGE_UNITS];
+ GLuint TexGen[MAX_TEXTURE_COORD_UNITS];
+ /* SGI_texture_color_table */
+ GLboolean TextureColorTable[MAX_TEXTURE_IMAGE_UNITS];
+ /* GL_NV_vertex_program */
+ GLboolean VertexProgram;
+ GLboolean VertexProgramPointSize;
+ GLboolean VertexProgramTwoSide;
+ /* GL_ARB_point_sprite / GL_NV_point_sprite */
+ GLboolean PointSprite;
+ GLboolean FragmentShaderATI;
+};
+
+
+/**
+ * Evaluator attribute group (GL_EVAL_BIT).
+ */
+struct gl_eval_attrib
+{
+ /**
+ * \name Enable bits
+ */
+ /*@{*/
+ GLboolean Map1Color4;
+ GLboolean Map1Index;
+ GLboolean Map1Normal;
+ GLboolean Map1TextureCoord1;
+ GLboolean Map1TextureCoord2;
+ GLboolean Map1TextureCoord3;
+ GLboolean Map1TextureCoord4;
+ GLboolean Map1Vertex3;
+ GLboolean Map1Vertex4;
+ GLboolean Map1Attrib[16]; /* GL_NV_vertex_program */
+ GLboolean Map2Color4;
+ GLboolean Map2Index;
+ GLboolean Map2Normal;
+ GLboolean Map2TextureCoord1;
+ GLboolean Map2TextureCoord2;
+ GLboolean Map2TextureCoord3;
+ GLboolean Map2TextureCoord4;
+ GLboolean Map2Vertex3;
+ GLboolean Map2Vertex4;
+ GLboolean Map2Attrib[16]; /* GL_NV_vertex_program */
+ GLboolean AutoNormal;
+ /*@}*/
+
+ /**
+ * \name 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;
+ /*@}*/
+};
+
+
+/**
+ * Fog attribute group (GL_FOG_BIT).
+ */
+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 ColorSumEnabled;
+ GLenum FogCoordinateSource; /**< GL_EXT_fog_coord */
+};
+
+
+/**
+ * Hint attribute group (GL_HINT_BIT).
+ *
+ * Values are always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE.
+ */
+struct gl_hint_attrib
+{
+ GLenum PerspectiveCorrection;
+ GLenum PointSmooth;
+ GLenum LineSmooth;
+ GLenum PolygonSmooth;
+ GLenum Fog;
+ GLenum ClipVolumeClipping; /**< GL_EXT_clip_volume_hint */
+ GLenum TextureCompression; /**< GL_ARB_texture_compression */
+ GLenum GenerateMipmap; /**< GL_SGIS_generate_mipmap */
+ GLenum FragmentShaderDerivative; /**< GL_ARB_fragment_shader */
+};
+
+
+/**
+ * Histogram attributes.
+ */
+struct gl_histogram_attrib
+{
+ GLuint Width; /**< number of table entries */
+ GLint Format; /**< GL_ALPHA, GL_RGB, etc */
+ GLuint Count[HISTOGRAM_TABLE_SIZE][4]; /**< the histogram */
+ GLboolean Sink; /**< terminate image transfer? */
+ GLubyte RedSize; /**< Bits per counter */
+ GLubyte GreenSize;
+ GLubyte BlueSize;
+ GLubyte AlphaSize;
+ GLubyte LuminanceSize;
+};
+
+
+/**
+ * Color Min/max state.
+ */
+struct gl_minmax_attrib
+{
+ GLenum Format;
+ GLboolean Sink;
+ GLfloat Min[4], Max[4]; /**< RGBA */
+};
+
+
+/**
+ * Image convolution state.
+ */
+struct gl_convolution_attrib
+{
+ GLenum Format;
+ GLenum InternalFormat;
+ GLuint Width;
+ GLuint Height;
+ GLfloat Filter[MAX_CONVOLUTION_WIDTH * MAX_CONVOLUTION_HEIGHT * 4];
+};
+
+
+/**
+ * Light state flags.
+ */
+/*@{*/
+#define LIGHT_SPOT 0x1
+#define LIGHT_LOCAL_VIEWER 0x2
+#define LIGHT_POSITIONAL 0x4
+#define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER)
+/*@}*/
+
+
+/**
+ * Lighting attribute group (GL_LIGHT_BIT).
+ */
+struct gl_light_attrib
+{
+ struct gl_light Light[MAX_LIGHTS]; /**< Array of light sources */
+ struct gl_lightmodel Model; /**< Lighting model */
+
+ /**
+ * Must flush FLUSH_VERTICES before referencing:
+ */
+ /*@{*/
+ struct gl_material Material; /**< Includes front & back values */
+ /*@}*/
+
+ GLboolean Enabled; /**< Lighting enabled flag */
+ GLenum ShadeModel; /**< GL_FLAT or GL_SMOOTH */
+ GLenum ColorMaterialFace; /**< GL_FRONT, BACK or FRONT_AND_BACK */
+ GLenum ColorMaterialMode; /**< GL_AMBIENT, GL_DIFFUSE, etc */
+ GLuint ColorMaterialBitmask; /**< bitmask formed from Face and Mode */
+ GLboolean ColorMaterialEnabled;
+
+ struct gl_light EnabledList; /**< List sentinel */
+
+ /**
+ * Derived state for optimizations:
+ */
+ /*@{*/
+ GLboolean _NeedEyeCoords;
+ GLboolean _NeedVertices; /**< Use fast shader? */
+ GLuint _Flags; /**< LIGHT_* flags, see above */
+ GLfloat _BaseColor[2][3];
+ /*@}*/
+};
+
+
+/**
+ * Line attribute group (GL_LINE_BIT).
+ */
+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 */
+ GLfloat _Width; /**< Clamped Line width */
+};
+
+
+/**
+ * Display list attribute group (GL_LIST_BIT).
+ */
+struct gl_list_attrib
+{
+ GLuint ListBase;
+};
+
+
+/**
+ * Used by device drivers to hook new commands into display lists.
+ */
+struct gl_list_instruction
+{
+ GLuint Size;
+ void (*Execute)( GLcontext *ctx, void *data );
+ void (*Destroy)( GLcontext *ctx, void *data );
+ void (*Print)( GLcontext *ctx, void *data );
+};
+
+#define MAX_DLIST_EXT_OPCODES 16
+
+/**
+ * Used by device drivers to hook new commands into display lists.
+ */
+struct gl_list_extensions
+{
+ struct gl_list_instruction Opcode[MAX_DLIST_EXT_OPCODES];
+ GLuint NumOpcodes;
+};
+
+
+/**
+ * Multisample attribute group (GL_MULTISAMPLE_BIT).
+ */
+struct gl_multisample_attrib
+{
+ GLboolean Enabled;
+ GLboolean SampleAlphaToCoverage;
+ GLboolean SampleAlphaToOne;
+ GLboolean SampleCoverage;
+ GLfloat SampleCoverageValue;
+ GLboolean SampleCoverageInvert;
+};
+
+
+/**
+ * Pixel attribute group (GL_PIXEL_MODE_BIT).
+ */
+struct gl_pixel_attrib
+{
+ GLenum ReadBuffer; /**< source buffer for glRead/CopyPixels() */
+ GLfloat RedBias, RedScale;
+ GLfloat GreenBias, GreenScale;
+ GLfloat BlueBias, BlueScale;
+ GLfloat AlphaBias, AlphaScale;
+ GLfloat DepthBias, DepthScale;
+ GLint IndexShift, IndexOffset;
+ GLboolean MapColorFlag;
+ GLboolean MapStencilFlag;
+ GLfloat ZoomX, ZoomY;
+ /* XXX move these out of gl_pixel_attrib */
+ 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 */
+ GLfloat 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 */
+ /** 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;
+ /** GL_SGI_texture_color_table */
+ GLfloat TextureColorTableScale[4];
+ GLfloat TextureColorTableBias[4];
+ /** 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 */
+};
+
+
+/**
+ * Point attribute group (GL_POINT_BIT).
+ */
+struct gl_point_attrib
+{
+ GLboolean SmoothFlag; /**< True if GL_POINT_SMOOTH is enabled */
+ GLfloat Size; /**< User-specified point size */
+ GLfloat _Size; /**< Size clamped to Const.Min/MaxPointSize */
+ GLfloat Params[3]; /**< GL_EXT_point_parameters */
+ GLfloat MinSize, MaxSize; /**< GL_EXT_point_parameters */
+ GLfloat Threshold; /**< GL_EXT_point_parameters */
+ GLboolean _Attenuated; /**< True if Params != [1, 0, 0] */
+ GLboolean PointSprite; /**< GL_NV_point_sprite / GL_NV_point_sprite */
+ GLboolean CoordReplace[MAX_TEXTURE_UNITS]; /**< GL_NV/ARB_point_sprite */
+ GLenum SpriteRMode; /**< GL_NV_point_sprite (only!) */
+ GLenum SpriteOrigin; /**< GL_ARB_point_sprite */
+};
+
+
+/**
+ * Polygon attribute group (GL_POLYGON_BIT).
+ */
+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; /**< 0=GL_CCW, 1=GL_CW */
+ GLboolean CullFlag; /**< Culling on/off flag */
+ 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, from user */
+ GLfloat OffsetUnits; /**< Polygon offset units, from user */
+ GLboolean OffsetPoint; /**< Offset in GL_POINT mode */
+ GLboolean OffsetLine; /**< Offset in GL_LINE mode */
+ GLboolean OffsetFill; /**< Offset in GL_FILL mode */
+};
+
+
+/**
+ * Scissor attributes (GL_SCISSOR_BIT).
+ */
+struct gl_scissor_attrib
+{
+ GLboolean Enabled; /**< Scissor test enabled? */
+ GLint X, Y; /**< Lower left corner of box */
+ GLsizei Width, Height; /**< Size of box */
+};
+
+
+/**
+ * Stencil attribute group (GL_STENCIL_BUFFER_BIT).
+ */
+struct gl_stencil_attrib
+{
+ GLboolean Enabled; /**< Enabled flag */
+ GLboolean TestTwoSide; /**< GL_EXT_stencil_two_side */
+ GLubyte ActiveFace; /**< GL_EXT_stencil_two_side (0 or 1) */
+ GLenum Function[2]; /**< Stencil function */
+ GLenum FailFunc[2]; /**< Fail function */
+ GLenum ZPassFunc[2]; /**< Depth buffer pass function */
+ GLenum ZFailFunc[2]; /**< Depth buffer fail function */
+ GLstencil Ref[2]; /**< Reference value */
+ GLstencil ValueMask[2]; /**< Value mask */
+ GLstencil WriteMask[2]; /**< Write mask */
+ GLstencil Clear; /**< Clear value */
+};
+
+
+#define NUM_TEXTURE_TARGETS 5 /* 1D, 2D, 3D, CUBE and RECT */
+
+/**
+ * An index for each type of texture object
+ */
+/*@{*/
+#define TEXTURE_1D_INDEX 0
+#define TEXTURE_2D_INDEX 1
+#define TEXTURE_3D_INDEX 2
+#define TEXTURE_CUBE_INDEX 3
+#define TEXTURE_RECT_INDEX 4
+/*@}*/
+
+/**
+ * Bit flags for each type of texture object
+ * Used for Texture.Unit[]._ReallyEnabled flags.
+ */
+/*@{*/
+#define TEXTURE_1D_BIT (1 << TEXTURE_1D_INDEX)
+#define TEXTURE_2D_BIT (1 << TEXTURE_2D_INDEX)
+#define TEXTURE_3D_BIT (1 << TEXTURE_3D_INDEX)
+#define TEXTURE_CUBE_BIT (1 << TEXTURE_CUBE_INDEX)
+#define TEXTURE_RECT_BIT (1 << TEXTURE_RECT_INDEX)
+/*@}*/
+
+
+/**
+ * TexGenEnabled flags.
+ */
+/*@{*/
+#define S_BIT 1
+#define T_BIT 2
+#define R_BIT 4
+#define Q_BIT 8
+/*@}*/
+
+
+/**
+ * Bit flag versions of the corresponding GL_ constants.
+ */
+/*@{*/
+#define TEXGEN_SPHERE_MAP 0x1
+#define TEXGEN_OBJ_LINEAR 0x2
+#define TEXGEN_EYE_LINEAR 0x4
+#define TEXGEN_REFLECTION_MAP_NV 0x8
+#define TEXGEN_NORMAL_MAP_NV 0x10
+
+#define TEXGEN_NEED_NORMALS (TEXGEN_SPHERE_MAP | \
+ TEXGEN_REFLECTION_MAP_NV | \
+ TEXGEN_NORMAL_MAP_NV)
+#define TEXGEN_NEED_EYE_COORD (TEXGEN_SPHERE_MAP | \
+ TEXGEN_REFLECTION_MAP_NV | \
+ TEXGEN_NORMAL_MAP_NV | \
+ TEXGEN_EYE_LINEAR)
+/*@}*/
+
+
+/* A selection of state flags to make driver and module's lives easier. */
+#define ENABLE_TEXGEN0 0x1
+#define ENABLE_TEXGEN1 0x2
+#define ENABLE_TEXGEN2 0x4
+#define ENABLE_TEXGEN3 0x8
+#define ENABLE_TEXGEN4 0x10
+#define ENABLE_TEXGEN5 0x20
+#define ENABLE_TEXGEN6 0x40
+#define ENABLE_TEXGEN7 0x80
+
+#define ENABLE_TEXMAT0 0x1 /* Ie. not the identity matrix */
+#define ENABLE_TEXMAT1 0x2
+#define ENABLE_TEXMAT2 0x4
+#define ENABLE_TEXMAT3 0x8
+#define ENABLE_TEXMAT4 0x10
+#define ENABLE_TEXMAT5 0x20
+#define ENABLE_TEXMAT6 0x40
+#define ENABLE_TEXMAT7 0x80
+
+#define ENABLE_TEXGEN(i) (ENABLE_TEXGEN0 << (i))
+#define ENABLE_TEXMAT(i) (ENABLE_TEXMAT0 << (i))
+
+
+/**
+ * Texel fetch function prototype. We use texel fetch functions to
+ * extract RGBA, color indexes and depth components out of 1D, 2D and 3D
+ * texture images. These functions help to isolate us from the gritty
+ * details of all the various texture image encodings.
+ *
+ * \param texImage texture image.
+ * \param col texel column.
+ * \param row texel row.
+ * \param img texel image level/layer.
+ * \param texelOut output texel (up to 4 GLchans)
+ */
+typedef void (*FetchTexelFuncC)( const struct gl_texture_image *texImage,
+ GLint col, GLint row, GLint img,
+ GLchan *texelOut );
+
+/**
+ * As above, but returns floats.
+ * Used for depth component images and for upcoming signed/float
+ * texture images.
+ */
+typedef void (*FetchTexelFuncF)( const struct gl_texture_image *texImage,
+ GLint col, GLint row, GLint img,
+ GLfloat *texelOut );
+
+
+typedef void (*StoreTexelFunc)(struct gl_texture_image *texImage,
+ GLint col, GLint row, GLint img,
+ const void *texel);
+
+/**
+ * TexImage store function. This is called by the glTex[Sub]Image
+ * functions and is responsible for converting the user-specified texture
+ * image into a specific (hardware) image format.
+ */
+typedef GLboolean (*StoreTexImageFunc)(GLcontext *ctx, GLuint dims,
+ GLenum baseInternalFormat,
+ const struct gl_texture_format *dstFormat,
+ GLvoid *dstAddr,
+ GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
+ GLint dstRowStride, GLint dstImageStride,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *srcAddr,
+ const struct gl_pixelstore_attrib *srcPacking);
+
+
+
+/**
+ * Texture format record
+ */
+struct gl_texture_format
+{
+ GLint MesaFormat; /**< One of the MESA_FORMAT_* values */
+
+ GLenum BaseFormat; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
+ * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
+ * GL_INTENSITY, GL_COLOR_INDEX or
+ * GL_DEPTH_COMPONENT.
+ */
+ GLenum DataType; /**< GL_FLOAT or GL_UNSIGNED_NORMALIZED_ARB */
+ GLubyte RedBits; /**< Bits per texel component */
+ GLubyte GreenBits; /**< These are just rough approximations for */
+ GLubyte BlueBits; /**< compressed texture formats. */
+ GLubyte AlphaBits;
+ GLubyte LuminanceBits;
+ GLubyte IntensityBits;
+ GLubyte IndexBits;
+ GLubyte DepthBits;
+
+ GLuint TexelBytes; /**< Bytes per texel, 0 if compressed format */
+
+ StoreTexImageFunc StoreImage;
+
+ /**
+ * \name Texel fetch function pointers
+ */
+ /*@{*/
+ FetchTexelFuncC FetchTexel1D;
+ FetchTexelFuncC FetchTexel2D;
+ FetchTexelFuncC FetchTexel3D;
+ FetchTexelFuncF FetchTexel1Df;
+ FetchTexelFuncF FetchTexel2Df;
+ FetchTexelFuncF FetchTexel3Df;
+ /*@}*/
+
+ StoreTexelFunc StoreTexel;
+};
+
+
+/**
+ * Texture image state. Describes the dimensions of a texture image,
+ * the texel format and pointers to Texel Fetch functions.
+ */
+struct gl_texture_image
+{
+ GLenum Format; /**< Either GL_RGB, GL_RGBA, GL_ALPHA,
+ * GL_LUMINANCE, GL_LUMINANCE_ALPHA,
+ * GL_INTENSITY, GL_COLOR_INDEX or
+ * GL_DEPTH_COMPONENT only.
+ * Used for choosing TexEnv arithmetic.
+ */
+ GLint IntFormat; /**< Internal format as given by the user */
+ GLuint Border; /**< 0 or 1 */
+ GLuint Width; /**< = 2^WidthLog2 + 2*Border */
+ GLuint Height; /**< = 2^HeightLog2 + 2*Border */
+ GLuint Depth; /**< = 2^DepthLog2 + 2*Border */
+ GLuint RowStride; /**< == Width unless IsClientData and padded */
+ 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) */
+ GLfloat WidthScale; /**< used for mipmap LOD computation */
+ GLfloat HeightScale; /**< used for mipmap LOD computation */
+ GLfloat DepthScale; /**< used for mipmap LOD computation */
+ GLvoid *Data; /**< Image data, accessed via FetchTexel() */
+ GLboolean IsClientData; /**< Data owned by client? */
+ GLboolean _IsPowerOfTwo; /**< Are all dimensions powers of two? */
+
+ const struct gl_texture_format *TexFormat;
+
+ struct gl_texture_object *TexObject; /**< Pointer back to parent object */
+
+ FetchTexelFuncC FetchTexelc; /**< GLchan texel fetch function pointer */
+ FetchTexelFuncF FetchTexelf; /**< Float texel fetch function pointer */
+
+ GLboolean IsCompressed; /**< GL_ARB_texture_compression */
+ GLuint CompressedSize; /**< GL_ARB_texture_compression */
+
+ /**
+ * \name For device driver:
+ */
+ /*@{*/
+ void *DriverData; /**< Arbitrary device driver data */
+ /*@}*/
+};
+
+
+/**
+ * Indexes for cube map faces.
+ */
+/*@{*/
+#define FACE_POS_X 0
+#define FACE_NEG_X 1
+#define FACE_POS_Y 2
+#define FACE_NEG_Y 3
+#define FACE_POS_Z 4
+#define FACE_NEG_Z 5
+#define MAX_FACES 6
+/*@}*/
+
+
+/**
+ * Texture object state. Contains the array of mipmap images, border color,
+ * wrap modes, filter modes, shadow/texcompare state, and the per-texture
+ * color palette.
+ */
+struct gl_texture_object
+{
+ _glthread_Mutex Mutex; /**< for thread safety */
+ GLint RefCount; /**< reference count */
+ GLuint Name; /**< the user-visible texture object ID */
+ GLenum Target; /**< GL_TEXTURE_1D, GL_TEXTURE_2D, etc. */
+ GLfloat Priority; /**< in [0,1] */
+ GLfloat BorderColor[4]; /**< unclamped */
+ GLchan _BorderChan[4]; /**< clamped, as GLchan */
+ GLenum WrapS; /**< S-axis texture image wrap mode */
+ GLenum WrapT; /**< T-axis texture image wrap mode */
+ GLenum WrapR; /**< R-axis texture image wrap mode */
+ GLenum MinFilter; /**< minification filter */
+ GLenum MagFilter; /**< magnification filter */
+ GLfloat MinLod; /**< min lambda, OpenGL 1.2 */
+ GLfloat MaxLod; /**< max lambda, OpenGL 1.2 */
+ GLfloat LodBias; /**< OpenGL 1.4 */
+ GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
+ GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */
+ GLfloat MaxAnisotropy; /**< GL_EXT_texture_filter_anisotropic */
+ GLboolean CompareFlag; /**< GL_SGIX_shadow */
+ GLenum CompareOperator; /**< GL_SGIX_shadow */
+ GLfloat ShadowAmbient; /**< GL_ARB_shadow_ambient */
+ GLenum CompareMode; /**< GL_ARB_shadow */
+ GLenum CompareFunc; /**< GL_ARB_shadow */
+ GLenum DepthMode; /**< GL_ARB_depth_texture */
+ GLint _MaxLevel; /**< actual max mipmap level (q in the spec) */
+ GLfloat _MaxLambda; /**< = _MaxLevel - BaseLevel (q - b in spec) */
+ GLboolean GenerateMipmap; /**< GL_SGIS_generate_mipmap */
+ GLboolean _IsPowerOfTwo; /**< Are all image dimensions powers of two? */
+ GLboolean Complete; /**< Is texture object complete? */
+
+ /** Actual texture images, indexed by [cube face] and [mipmap level] */
+ struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
+
+ /** GL_EXT_paletted_texture */
+ struct gl_color_table Palette;
+
+
+ /**
+ * \name For device driver.
+ * Note: instead of attaching driver data to this pointer, it's preferable
+ * to instead use this struct as a base class for your own texture object
+ * class. Driver->NewTextureObject() can be used to implement the
+ * allocation.
+ */
+ void *DriverData; /**< Arbitrary device driver data */
+};
+
+
+/**
+ * Texture combine environment state.
+ *
+ * \todo
+ * If GL_NV_texture_env_combine4 is ever supported, the arrays in this
+ * structure will need to be expanded for 4 elements.
+ */
+struct gl_tex_env_combine_state
+{
+ GLenum ModeRGB; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
+ GLenum ModeA; /**< GL_REPLACE, GL_DECAL, GL_ADD, etc. */
+ GLenum SourceRGB[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
+ GLenum SourceA[3]; /**< GL_PRIMARY_COLOR, GL_TEXTURE, etc. */
+ GLenum OperandRGB[3]; /**< SRC_COLOR, ONE_MINUS_SRC_COLOR, etc */
+ GLenum OperandA[3]; /**< SRC_ALPHA, ONE_MINUS_SRC_ALPHA, etc */
+ GLuint ScaleShiftRGB; /**< 0, 1 or 2 */
+ GLuint ScaleShiftA; /**< 0, 1 or 2 */
+ GLuint _NumArgsRGB; /**< Number of inputs used for the combine mode. */
+ GLuint _NumArgsA; /**< Number of inputs used for the combine mode. */
+};
+
+
+/**
+ * Texture unit state. Contains enable flags, texture environment/function/
+ * combiners, texgen state, pointers to current texture objects and
+ * post-filter color tables.
+ */
+struct gl_texture_unit
+{
+ GLuint Enabled; /**< bitmask of TEXTURE_*_BIT flags */
+ GLuint _ReallyEnabled; /**< 0 or exactly one of TEXTURE_*_BIT flags */
+
+ GLenum EnvMode; /**< GL_MODULATE, GL_DECAL, GL_BLEND, etc. */
+ GLfloat EnvColor[4];
+ GLuint TexGenEnabled; /**< Bitwise-OR of [STRQ]_BIT values */
+ /** \name Tex coord generation mode
+ * Either GL_OBJECT_LINEAR, GL_EYE_LINEAR or GL_SPHERE_MAP. */
+ /*@{*/
+ GLenum GenModeS;
+ GLenum GenModeT;
+ GLenum GenModeR;
+ GLenum GenModeQ;
+ /*@}*/
+ 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];
+ GLfloat LodBias; /**< for biasing mipmap levels */
+
+ /**
+ * \name GL_EXT_texture_env_combine
+ */
+ struct gl_tex_env_combine_state Combine;
+
+ /**
+ * Derived state based on \c EnvMode and the \c BaseFormat of the
+ * currently enabled texture.
+ */
+ struct gl_tex_env_combine_state _EnvMode;
+
+ /**
+ * Currently enabled combiner state. This will point to either
+ * \c Combine or \c _EnvMode.
+ */
+ struct gl_tex_env_combine_state *_CurrentCombine;
+
+ struct gl_texture_object *Current1D;
+ struct gl_texture_object *Current2D;
+ struct gl_texture_object *Current3D;
+ struct gl_texture_object *CurrentCubeMap; /**< GL_ARB_texture_cube_map */
+ struct gl_texture_object *CurrentRect; /**< GL_NV_texture_rectangle */
+
+ struct gl_texture_object *_Current; /**< Points to really enabled tex obj */
+
+ struct gl_texture_object Saved1D; /**< only used by glPush/PopAttrib */
+ struct gl_texture_object Saved2D;
+ struct gl_texture_object Saved3D;
+ struct gl_texture_object SavedCubeMap;
+ struct gl_texture_object SavedRect;
+
+ /* GL_SGI_texture_color_table */
+ struct gl_color_table ColorTable;
+ struct gl_color_table ProxyColorTable;
+ GLboolean ColorTableEnabled;
+};
+
+struct texenvprog_cache {
+ GLuint hash;
+ void *key;
+ void *data;
+ struct texenvprog_cache *next;
+};
+
+/**
+ * Texture attribute group (GL_TEXTURE_BIT).
+ */
+struct gl_texture_attrib
+{
+ /**
+ * name multitexture
+ */
+ /**@{*/
+ GLuint CurrentUnit; /**< Active texture unit */
+ GLuint _EnabledUnits; /**< one bit set for each really-enabled unit */
+ GLuint _EnabledCoordUnits; /**< one bit per enabled coordinate unit */
+ GLuint _GenFlags; /**< for texgen */
+ GLuint _TexGenEnabled;
+ GLuint _TexMatEnabled;
+ /**@}*/
+
+ struct gl_texture_unit Unit[MAX_TEXTURE_UNITS];
+
+ struct gl_texture_object *Proxy1D;
+ struct gl_texture_object *Proxy2D;
+ struct gl_texture_object *Proxy3D;
+ struct gl_texture_object *ProxyCubeMap;
+ struct gl_texture_object *ProxyRect;
+
+ /** GL_EXT_shared_texture_palette */
+ GLboolean SharedPalette;
+ struct gl_color_table Palette;
+
+ /** Cached texenv fragment programs */
+ struct texenvprog_cache *env_fp_cache;
+};
+
+
+/**
+ * Transformation attribute group (GL_TRANSFORM_BIT).
+ */
+struct gl_transform_attrib
+{
+ GLenum MatrixMode; /**< Matrix mode */
+ GLfloat EyeUserPlane[MAX_CLIP_PLANES][4]; /**< User clip planes */
+ GLfloat _ClipUserPlane[MAX_CLIP_PLANES][4]; /**< derived */
+ GLuint ClipPlanesEnabled; /**< on/off bitmask */
+ GLboolean Normalize; /**< Normalize all normals? */
+ GLboolean RescaleNormals; /**< GL_EXT_rescale_normal */
+ GLboolean RasterPositionUnclipped; /**< GL_IBM_rasterpos_clip */
+
+ GLboolean CullVertexFlag; /**< True if GL_CULL_VERTEX_EXT is enabled */
+ GLfloat CullEyePos[4];
+ GLfloat CullObjPos[4];
+};
+
+
+/**
+ * Viewport attribute group (GL_VIEWPORT_BIT).
+ */
+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. */
+};
+
+
+/**
+ * Node for the attribute stack.
+ */
+struct gl_attrib_node
+{
+ GLbitfield kind;
+ void *data;
+ struct gl_attrib_node *next;
+};
+
+
+/**
+ * GL_ARB_vertex/pixel_buffer_object buffer object
+ */
+struct gl_buffer_object
+{
+ GLint RefCount;
+ GLuint Name;
+ GLenum Usage;
+ GLenum Access;
+ GLvoid *Pointer; /**< Only valid while buffer is mapped */
+ GLsizeiptrARB Size; /**< Size of storage in bytes */
+ GLubyte *Data; /**< Location of storage either in RAM or VRAM. */
+ GLboolean OnCard; /**< Is buffer in VRAM? (hardware drivers) */
+};
+
+
+
+/**
+ * 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;
+ GLboolean ClientStorage; /**< GL_APPLE_client_storage */
+ GLboolean Invert; /**< GL_MESA_pack_invert */
+ struct gl_buffer_object *BufferObj; /**< GL_ARB_pixel_buffer_object */
+};
+
+
+#define CA_CLIENT_DATA 0x1 /**< Data not allocated by mesa */
+
+
+/**
+ * Client vertex array attributes
+ */
+struct gl_client_array
+{
+ GLint Size; /**< components per element (1,2,3,4) */
+ GLenum Type; /**< datatype: GL_FLOAT, GL_INT, etc */
+ GLsizei Stride; /**< user-specified stride */
+ GLsizei StrideB; /**< actual stride in bytes */
+ const GLubyte *Ptr; /**< Points to array data */
+ GLuint Enabled; /**< one of the _NEW_ARRAY_ bits */
+ GLboolean Normalized; /**< GL_ARB_vertex_program */
+
+ /**< GL_ARB_vertex_buffer_object */
+ struct gl_buffer_object *BufferObj;
+ GLuint _MaxElement;
+
+ GLuint Flags;
+};
+
+
+/**
+ * Vertex array state
+ */
+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 SecondaryColor;
+ struct gl_client_array FogCoord;
+ struct gl_client_array Index;
+ struct gl_client_array TexCoord[MAX_TEXTURE_COORD_UNITS];
+ struct gl_client_array EdgeFlag;
+
+ struct gl_client_array VertexAttrib[VERT_ATTRIB_MAX]; /**< GL_NV_vertex_program */
+
+ GLint ActiveTexture; /**< Client Active Texture */
+ GLuint LockFirst; /**< GL_EXT_compiled_vertex_array */
+ GLuint LockCount; /**< GL_EXT_compiled_vertex_array */
+
+ GLuint _Enabled; /**< _NEW_ARRAY_* - bit set if array enabled */
+ GLuint NewState; /**< _NEW_ARRAY_* */
+
+#if FEATURE_ARB_vertex_buffer_object
+ struct gl_buffer_object *NullBufferObj;
+ struct gl_buffer_object *ArrayBufferObj;
+ struct gl_buffer_object *ElementArrayBufferObj;
+#endif
+ GLuint _MaxElement; /* Min of all enabled array's maxes */
+};
+
+
+/**
+ * Feedback buffer state
+ */
+struct gl_feedback
+{
+ GLenum Type;
+ GLuint _Mask; /* FB_* bits */
+ GLfloat *Buffer;
+ GLuint BufferSize;
+ GLuint Count;
+};
+
+
+/**
+ * Selection buffer state
+ */
+struct gl_selection
+{
+ GLuint *Buffer; /**< selection buffer */
+ GLuint BufferSize; /**< size of the selection buffer */
+ GLuint BufferCount; /**< number of values in the selection buffer */
+ GLuint Hits; /**< number of records in the selection buffer */
+ GLuint NameStackDepth; /**< name stack depth */
+ GLuint NameStack[MAX_NAME_STACK_DEPTH]; /**< name stack */
+ GLboolean HitFlag; /**< hit flag */
+ GLfloat HitMinZ; /**< minimum hit depth */
+ GLfloat HitMaxZ; /**< maximum hit depth */
+};
+
+
+/**
+ * 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 */
+};
+
+
+/**
+ * 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 */
+};
+
+
+/**
+ * All evaluator control point state
+ */
+struct gl_evaluators
+{
+ /**
+ * \name 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;
+ struct gl_1d_map Map1Attrib[16]; /**< GL_NV_vertex_program */
+ /*@}*/
+
+ /**
+ * \name 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;
+ struct gl_2d_map Map2Attrib[16]; /**< GL_NV_vertex_program */
+ /*@}*/
+};
+
+
+/**
+ * NV_fragment_program runtime state
+ */
+struct fp_machine
+{
+ GLfloat Temporaries[MAX_NV_FRAGMENT_PROGRAM_TEMPS][4];
+ GLfloat Inputs[MAX_NV_FRAGMENT_PROGRAM_INPUTS][4];
+ GLfloat Outputs[MAX_NV_FRAGMENT_PROGRAM_OUTPUTS][4];
+ GLuint CondCodes[4];
+};
+
+/**
+ * ATI_fragment_shader runtime state
+ */
+#define ATI_FS_INPUT_PRIMARY 0
+#define ATI_FS_INPUT_SECONDARY 1
+
+/* 6 register sets - 2 inputs (primary, secondary) */
+struct atifs_machine
+{
+ GLfloat Registers[6][4];
+ GLfloat PrevPassRegisters[6][4];
+ GLfloat Inputs[2][4];
+ GLuint pass;
+};
+
+
+/**
+ * Names of the various vertex/fragment register files
+ */
+enum register_file
+{
+ PROGRAM_TEMPORARY,
+ PROGRAM_INPUT,
+ PROGRAM_OUTPUT,
+ PROGRAM_LOCAL_PARAM,
+ PROGRAM_ENV_PARAM,
+ PROGRAM_NAMED_PARAM,
+ PROGRAM_STATE_VAR,
+ PROGRAM_WRITE_ONLY,
+ PROGRAM_ADDRESS,
+ PROGRAM_UNDEFINED /* invalid value */
+};
+
+
+/** Vertex and fragment instructions */
+struct vp_instruction;
+struct fp_instruction;
+struct atifs_instruction;
+struct program_parameter_list;
+
+
+/**
+ * Base class for any kind of program object
+ */
+struct program
+{
+ GLuint Id;
+ GLubyte *String; /**< Null-terminated program text */
+ GLint RefCount;
+ GLenum Target;
+ GLenum Format; /**< String encoding format */
+ GLboolean Resident;
+ GLfloat LocalParams[MAX_PROGRAM_LOCAL_PARAMS][4];
+ GLuint NumInstructions; /* GL_ARB_vertex/fragment_program */
+ GLuint NumTemporaries;
+ GLuint NumParameters;
+ GLuint NumAttributes;
+ GLuint NumAddressRegs;
+};
+
+
+/** Vertex program object */
+struct vertex_program
+{
+ struct program Base; /* base class */
+ struct vp_instruction *Instructions; /* Compiled instructions */
+ GLboolean IsNVProgram; /* GL_NV_vertex_program ? */
+ GLboolean IsPositionInvariant; /* GL_NV_vertex_program1_1 */
+ GLuint InputsRead; /* Bitmask of which input regs are read */
+ GLuint OutputsWritten; /* Bitmask of which output regs are written to */
+ struct program_parameter_list *Parameters; /**< array [NumParameters] */
+ void *TnlData; /* should probably use Base.DriverData */
+};
+
+
+/** Fragment program object */
+struct fragment_program
+{
+ struct program Base; /**< base class */
+ struct fp_instruction *Instructions; /**< Compiled instructions */
+ GLuint InputsRead; /**< Bitmask of which input regs are read */
+ GLuint OutputsWritten; /**< Bitmask of which output regs are written to */
+ GLuint TexturesUsed[MAX_TEXTURE_IMAGE_UNITS]; /**< TEXTURE_x_INDEX bitmask */
+ GLuint NumAluInstructions; /**< GL_ARB_fragment_program */
+ GLuint NumTexInstructions;
+ GLuint NumTexIndirections;
+ GLenum FogOption;
+ struct program_parameter_list *Parameters; /**< array [NumParameters] */
+
+#ifdef USE_TCC
+ char c_str[4096]; /* experimental... */
+ int c_strlen;
+#endif
+};
+
+struct ati_fragment_shader
+{
+ struct program Base;
+ struct atifs_instruction *Instructions;
+ GLfloat Constants[8][4];
+ GLint NumPasses;
+ GLint cur_pass;
+};
+
+/**
+ * State common to vertex and fragment programs.
+ */
+struct gl_program_state
+{
+ GLint ErrorPos; /* GL_PROGRAM_ERROR_POSITION_NV */
+ const char *ErrorString; /* GL_PROGRAM_ERROR_STRING_NV */
+};
+
+
+/**
+ * State vars for GL_ARB/GL_NV_vertex_program
+ */
+struct gl_vertex_program_state
+{
+ GLboolean Enabled; /**< GL_VERTEX_PROGRAM_NV */
+ GLboolean _Enabled; /**< Really enabled? */
+ GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_NV */
+ GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_NV */
+ struct vertex_program *Current; /**< ptr to currently bound program */
+
+ GLenum TrackMatrix[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
+ GLenum TrackMatrixTransform[MAX_NV_VERTEX_PROGRAM_PARAMS / 4];
+
+ GLfloat Parameters[MAX_NV_VERTEX_PROGRAM_PARAMS][4]; /* Env params */
+ /* Only used during program execution (may be moved someday): */
+ GLfloat Temporaries[MAX_NV_VERTEX_PROGRAM_TEMPS][4];
+ GLfloat Inputs[MAX_NV_VERTEX_PROGRAM_INPUTS][4];
+ GLuint InputsSize[MAX_NV_VERTEX_PROGRAM_INPUTS];
+ GLfloat Outputs[MAX_NV_VERTEX_PROGRAM_OUTPUTS][4];
+ GLint AddressReg[4];
+
+#if FEATURE_MESA_program_debug
+ GLprogramcallbackMESA Callback;
+ GLvoid *CallbackData;
+ GLboolean CallbackEnabled;
+ GLuint CurrentPosition;
+#endif
+};
+
+
+/*
+ * State for GL_ARB/NV_fragment_program
+ */
+struct gl_fragment_program_state
+{
+ GLboolean Enabled; /* GL_VERTEX_PROGRAM_NV */
+ GLboolean _Enabled; /* Really enabled? */
+ GLboolean _Active; /* Really really enabled? */
+ struct fragment_program *Current; /* ptr to currently bound program */
+ struct fragment_program *_Current; /* ptr to currently active program */
+ struct fp_machine Machine; /* machine state */
+ GLfloat Parameters[MAX_NV_FRAGMENT_PROGRAM_PARAMS][4]; /* Env params */
+
+#if FEATURE_MESA_program_debug
+ GLprogramcallbackMESA Callback;
+ GLvoid *CallbackData;
+ GLboolean CallbackEnabled;
+ GLuint CurrentPosition;
+#endif
+};
+
+/*
+ * State for GL_fragment_shader
+ */
+struct gl_ati_fragment_shader_state
+{
+ GLboolean Enabled;
+ GLboolean _Enabled;
+ GLboolean Compiling;
+ struct atifs_machine Machine; /* machine state */
+ struct ati_fragment_shader *Current;
+};
+
+/*
+ * State for GL_ARB_occlusion_query
+ */
+struct gl_occlusion_state
+{
+ GLboolean Active;
+ GLuint CurrentQueryObject;
+ GLuint PassedCounter;
+ struct _mesa_HashTable *QueryObjects;
+};
+
+/**
+ * gl2 unique interface identifier.
+ * Each gl2 interface has its own interface id used for object queries.
+ */
+enum gl2_uiid
+{
+ UIID_UNKNOWN, /* supported by all objects */
+ UIID_GENERIC, /* generic object */
+ UIID_CONTAINER, /* contains generic objects */
+ UIID_SHADER, /* shader object */
+ UIID_FRAGMENT_SHADER, /* fragment shader */
+ UIID_VERTEX_SHADER, /* vertex shader */
+ UIID_PROGRAM, /* program object */
+ UIID_3DLABS_SHHANDLE /* encapsulates 3dlabs' ShHandle */
+};
+
+struct gl2_unknown_intf
+{
+ GLvoid (* AddRef) (struct gl2_unknown_intf **);
+ GLvoid (* Release) (struct gl2_unknown_intf **);
+ struct gl2_unknown_intf **(* QueryInterface) (struct gl2_unknown_intf **, enum gl2_uiid uiid);
+};
+
+struct gl2_generic_intf
+{
+ struct gl2_unknown_intf _unknown;
+ GLvoid (* Delete) (struct gl2_generic_intf **);
+ GLenum (* GetType) (struct gl2_generic_intf **);
+ GLhandleARB (* GetName) (struct gl2_generic_intf **);
+ GLboolean (* GetDeleteStatus) (struct gl2_generic_intf **);
+ const GLcharARB *(* GetInfoLog) (struct gl2_generic_intf **);
+};
+
+struct gl2_container_intf
+{
+ struct gl2_generic_intf _generic;
+ GLboolean (* Attach) (struct gl2_container_intf **, struct gl2_generic_intf **);
+ GLboolean (* Detach) (struct gl2_container_intf **, struct gl2_generic_intf **);
+ GLsizei (* GetAttachedCount) (struct gl2_container_intf **);
+ struct gl2_generic_intf **(* GetAttached) (struct gl2_container_intf **, GLuint);
+};
+
+struct gl2_shader_intf
+{
+ struct gl2_generic_intf _generic;
+ GLenum (* GetSubType) (struct gl2_shader_intf **);
+ GLboolean (* GetCompileStatus) (struct gl2_shader_intf **);
+ GLvoid (* SetSource) (struct gl2_shader_intf **, GLcharARB *, GLint *, GLsizei);
+ const GLcharARB *(* GetSource) (struct gl2_shader_intf **);
+ GLvoid (* Compile) (struct gl2_shader_intf **);
+};
+
+struct gl2_program_intf
+{
+ struct gl2_container_intf _container;
+ GLboolean (* GetLinkStatus) (struct gl2_program_intf **);
+ GLboolean (* GetValidateStatus) (struct gl2_program_intf **);
+ GLvoid (* Link) (struct gl2_program_intf **);
+ GLvoid (* Validate) (struct gl2_program_intf **);
+};
+
+struct gl2_fragment_shader_intf
+{
+ struct gl2_shader_intf _shader;
+};
+
+struct gl2_vertex_shader_intf
+{
+ struct gl2_shader_intf _shader;
+};
+
+struct gl2_3dlabs_shhandle_intf
+{
+ struct gl2_unknown_intf _unknown;
+ GLvoid *(* GetShHandle) (struct gl2_3dlabs_shhandle_intf **);
+};
+
+struct gl_shader_objects_state
+{
+ struct gl2_program_intf **current_program;
+};
+
+
+/**
+ * State which can be shared by multiple contexts:
+ */
+struct gl_shared_state
+{
+ _glthread_Mutex Mutex; /**< for thread safety */
+ GLint RefCount; /**< Reference count */
+ struct _mesa_HashTable *DisplayList; /**< Display lists hash table */
+ struct _mesa_HashTable *TexObjects; /**< Texture objects hash table */
+
+ /**
+ * \name Default texture objects (shared by all multi-texture units)
+ */
+ /*@{*/
+ struct gl_texture_object *Default1D;
+ struct gl_texture_object *Default2D;
+ struct gl_texture_object *Default3D;
+ struct gl_texture_object *DefaultCubeMap;
+ struct gl_texture_object *DefaultRect;
+ /*@}*/
+
+ /**
+ * \name Vertex/fragment programs
+ */
+ /*@{*/
+ struct _mesa_HashTable *Programs;
+#if FEATURE_ARB_vertex_program
+ struct program *DefaultVertexProgram;
+#endif
+#if FEATURE_ARB_fragment_program
+ struct program *DefaultFragmentProgram;
+#endif
+#if FEATURE_ATI_fragment_shader
+ struct program *DefaultFragmentShader;
+#endif
+ /*@}*/
+
+#if FEATURE_ARB_vertex_buffer_object || FEATURE_ARB_pixel_buffer_object
+ struct _mesa_HashTable *BufferObjects;
+#endif
+
+ struct _mesa_HashTable *GL2Objects;
+
+#if FEATURE_EXT_framebuffer_object
+ struct _mesa_HashTable *RenderBuffers;
+ struct _mesa_HashTable *FrameBuffers;
+#endif
+
+ void *DriverData; /**< Device driver shared state */
+};
+
+
+
+
+/**
+ * A renderbuffer stores colors or depth values or stencil values.
+ * A framebuffer object will have a collection of these.
+ * Data are read/written to the buffer with a handful of Get/Put functions.
+ *
+ * Instances of this object are allocated with the Driver's NewRenderbuffer
+ * hook. Drivers will likely wrap this class inside a driver-specific
+ * class to simulate inheritance.
+ */
+struct gl_renderbuffer
+{
+ GLuint Name;
+ GLint RefCount;
+ GLuint Width, Height;
+ GLenum InternalFormat; /* The user-specified value */
+ GLenum _BaseFormat; /* Either GL_RGB, GL_RGBA, GL_DEPTH_COMPONENT or */
+ /* GL_STENCIL_INDEX. */
+ GLenum DataType; /* Type of values passed to the Get/Put functions */
+ GLubyte ComponentSizes[4]; /* bits per component or channel */
+ GLvoid *Data;
+
+ /* Used to wrap one renderbuffer around another: */
+ struct gl_renderbuffer *Wrapped;
+
+ /* Delete this renderbuffer */
+ void (*Delete)(struct gl_renderbuffer *rb);
+
+ /* Allocate new storage for this renderbuffer */
+ GLboolean (*AllocStorage)(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat,
+ GLuint width, GLuint height);
+
+ /* Lock/Unlock are called before/after calling the Get/Put functions.
+ * Not sure this is the right place for these yet.
+ void (*Lock)(GLcontext *ctx, struct gl_renderbuffer *rb);
+ void (*Unlock)(GLcontext *ctx, struct gl_renderbuffer *rb);
+ */
+
+ /* Return a pointer to the element/pixel at (x,y).
+ * Should return NULL if the buffer memory can't be directly addressed.
+ */
+ void *(*GetPointer)(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint x, GLint y);
+
+ /* Get/Read a row of values.
+ * The values will be of format _BaseFormat and type DataType.
+ */
+ void (*GetRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values);
+
+ /* Get/Read values at arbitrary locations.
+ * The values will be of format _BaseFormat and type DataType.
+ */
+ void (*GetValues)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values);
+
+ /* Put/Write a row of values.
+ * The values will be of format _BaseFormat and type DataType.
+ */
+ void (*PutRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask);
+
+ /* Put/Write a row of RGB values. This is a special-case routine that's
+ * only used for RGBA renderbuffers when the source data is GL_RGB. That's
+ * a common case for glDrawPixels and some triangle routines.
+ * The values will be of format GL_RGB and type DataType.
+ */
+ void (*PutRowRGB)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask);
+
+
+ /* Put/Write a row of identical values.
+ * The values will be of format _BaseFormat and type DataType.
+ */
+ void (*PutMonoRow)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask);
+
+ /* Put/Write values at arbitrary locations.
+ * The values will be of format _BaseFormat and type DataType.
+ */
+ void (*PutValues)(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask);
+ /* Put/Write identical values at arbitrary locations.
+ * The values will be of format _BaseFormat and type DataType.
+ */
+ void (*PutMonoValues)(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask);
+};
+
+
+/**
+ * A renderbuffer attachment point points to either a texture object
+ * (and specifies a mipmap level, cube face or 3D texture slice) or
+ * points to a renderbuffer.
+ */
+struct gl_renderbuffer_attachment
+{
+ GLenum Type; /* GL_NONE or GL_TEXTURE or GL_RENDERBUFFER_EXT */
+ GLboolean Complete;
+
+ /* IF Type == GL_RENDERBUFFER_EXT: */
+ struct gl_renderbuffer *Renderbuffer;
+
+ /* IF Type == GL_TEXTURE: */
+ struct gl_texture_object *Texture;
+ GLuint TextureLevel;
+ GLuint CubeMapFace; /* 0 .. 5, for cube map textures */
+ GLuint Zoffset; /* for 3D textures */
+};
+
+
+/**
+ * A framebuffer is a collection of renderbuffers (color, depth, stencil, etc).
+ * In C++ terms, think of this as a base class from which device drivers
+ * will make derived classes.
+ */
+struct gl_framebuffer
+{
+ GLuint Name; /* if zero, this is a window system framebuffer */
+ GLint RefCount;
+
+ GLvisual Visual; /**< The corresponding visual */
+
+ GLboolean Initialized;
+
+ GLuint Width, Height; /**< size of frame buffer in pixels */
+
+ /** \name Drawing bounds (Intersection of buffer size and scissor box) */
+ /*@{*/
+ GLint _Xmin, _Xmax; /**< inclusive */
+ GLint _Ymin, _Ymax; /**< exclusive */
+ /*@}*/
+
+ /** \name Derived Z buffer stuff */
+ /*@{*/
+ GLuint _DepthMax; /**< Max depth buffer value */
+ GLfloat _DepthMaxF; /**< Float max depth buffer value */
+ GLfloat _MRD; /**< minimum resolvable difference in Z values */
+ /*@}*/
+
+ GLenum _Status; /* One of the GL_FRAMEBUFFER_(IN)COMPLETE_* tokens */
+
+ /* Array of all renderbuffer attachments, indexed by BUFFER_* tokens. */
+ struct gl_renderbuffer_attachment Attachment[BUFFER_COUNT];
+
+ /* In unextended OpenGL these vars are part of the GL_COLOR_BUFFER
+ * attribute group and GL_PIXEL attribute group, respectively.
+ */
+ GLenum ColorDrawBuffer[MAX_DRAW_BUFFERS];
+ GLenum ColorReadBuffer;
+
+ /* These are computed from ColorDrawBuffer and ColorReadBuffer */
+ GLuint _ColorDrawBufferMask[MAX_DRAW_BUFFERS]; /* Mask of BUFFER_BIT_* flags */
+ GLuint _ColorReadBufferMask; /* Zero or one of BUFFER_BIT_ flags */
+
+ /* These are computed from _Draw/ReadBufferMask, above. */
+ GLuint _NumColorDrawBuffers[MAX_DRAW_BUFFERS];
+ struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS][4];
+ struct gl_renderbuffer *_ColorReadBuffer;
+
+#if OLD_RENDERBUFFER
+ /* XXX THIS IS TEMPORARY */
+ GLuint _ColorDrawBit[MAX_DRAW_BUFFERS][4];
+#endif
+
+ /** Delete this framebuffer */
+ void (*Delete)(struct gl_framebuffer *fb);
+};
+
+
+/**
+ * Constants which may be overridden by device driver during context creation
+ * but are never changed after that.
+ */
+struct gl_constants
+{
+ GLint MaxTextureLevels; /**< Maximum number of allowed mipmap levels. */
+ GLint Max3DTextureLevels; /**< Maximum number of allowed mipmap levels for 3D texture targets. */
+ GLint MaxCubeTextureLevels; /**< Maximum number of allowed mipmap levels for GL_ARB_texture_cube_map */
+ GLint MaxTextureRectSize; /* GL_NV_texture_rectangle */
+ GLuint MaxTextureCoordUnits;
+ GLuint MaxTextureImageUnits;
+ GLuint MaxTextureUnits; /* = MAX(CoordUnits, ImageUnits) */
+ GLfloat MaxTextureMaxAnisotropy; /* GL_EXT_texture_filter_anisotropic */
+ GLfloat MaxTextureLodBias; /* GL_EXT_texture_lod_bias */
+ GLuint MaxArrayLockSize;
+ GLint SubPixelBits;
+ GLfloat MinPointSize, MaxPointSize; /* aliased */
+ GLfloat MinPointSizeAA, MaxPointSizeAA; /* antialiased */
+ GLfloat PointSizeGranularity;
+ GLfloat MinLineWidth, MaxLineWidth; /* aliased */
+ GLfloat MinLineWidthAA, MaxLineWidthAA; /* antialiased */
+ GLfloat LineWidthGranularity;
+ GLuint MaxColorTableSize;
+ GLuint MaxConvolutionWidth;
+ GLuint MaxConvolutionHeight;
+ GLuint MaxClipPlanes;
+ GLuint MaxLights;
+ GLfloat MaxShininess; /* GL_NV_light_max_exponent */
+ GLfloat MaxSpotExponent; /* GL_NV_light_max_exponent */
+ GLuint MaxViewportWidth, MaxViewportHeight;
+ /* GL_ARB_vertex_program */
+ GLuint MaxVertexProgramInstructions;
+ GLuint MaxVertexProgramAttribs;
+ GLuint MaxVertexProgramTemps;
+ GLuint MaxVertexProgramLocalParams;
+ GLuint MaxVertexProgramEnvParams;
+ GLuint MaxVertexProgramAddressRegs;
+ /* GL_ARB_fragment_program */
+ GLuint MaxFragmentProgramInstructions;
+ GLuint MaxFragmentProgramAttribs;
+ GLuint MaxFragmentProgramTemps;
+ GLuint MaxFragmentProgramLocalParams;
+ GLuint MaxFragmentProgramEnvParams;
+ GLuint MaxFragmentProgramAddressRegs;
+ GLuint MaxFragmentProgramAluInstructions;
+ GLuint MaxFragmentProgramTexInstructions;
+ GLuint MaxFragmentProgramTexIndirections;
+ /* vertex or fragment program */
+ GLuint MaxProgramMatrices;
+ GLuint MaxProgramMatrixStackDepth;
+ /* vertex array / buffer object bounds checking */
+ GLboolean CheckArrayBounds;
+ /* GL_ARB_draw_buffers */
+ GLuint MaxDrawBuffers;
+ /* GL_OES_read_format */
+ GLenum ColorReadFormat;
+ GLenum ColorReadType;
+ /* GL_EXT_framebuffer_object */
+ GLuint MaxColorAttachments;
+ GLuint MaxRenderbufferSize;
+};
+
+
+/**
+ * Enable flag for each OpenGL extension. Different device drivers will
+ * enable different extensions at runtime.
+ */
+struct gl_extensions
+{
+ /**
+ * \name Flags to quickly test if certain extensions are available.
+ *
+ * Not every extension needs to have such a flag, but it's encouraged.
+ */
+ /*@{*/
+ GLboolean dummy; /* don't remove this! */
+ GLboolean ARB_depth_texture;
+ GLboolean ARB_draw_buffers;
+ GLboolean ARB_fragment_program;
+ GLboolean ARB_fragment_shader;
+ GLboolean ARB_half_float_pixel;
+ GLboolean ARB_imaging;
+ GLboolean ARB_multisample;
+ GLboolean ARB_multitexture;
+ GLboolean ARB_occlusion_query;
+ GLboolean ARB_point_sprite;
+ GLboolean ARB_shader_objects;
+ GLboolean ARB_shading_language_100;
+ GLboolean ARB_shadow;
+ GLboolean ARB_texture_border_clamp;
+ GLboolean ARB_texture_compression;
+ GLboolean ARB_texture_cube_map;
+ GLboolean ARB_texture_env_combine;
+ GLboolean ARB_texture_env_crossbar;
+ GLboolean ARB_texture_env_dot3;
+ GLboolean ARB_texture_float;
+ GLboolean ARB_texture_mirrored_repeat;
+ GLboolean ARB_texture_non_power_of_two;
+ GLboolean ARB_transpose_matrix;
+ GLboolean ARB_vertex_buffer_object;
+ GLboolean ARB_vertex_program;
+ GLboolean ARB_vertex_shader;
+ GLboolean ARB_window_pos;
+ GLboolean EXT_abgr;
+ GLboolean EXT_bgra;
+ GLboolean EXT_blend_color;
+ GLboolean EXT_blend_equation_separate;
+ GLboolean EXT_blend_func_separate;
+ GLboolean EXT_blend_logic_op;
+ GLboolean EXT_blend_minmax;
+ GLboolean EXT_blend_subtract;
+ GLboolean EXT_clip_volume_hint;
+ GLboolean EXT_cull_vertex;
+ GLboolean EXT_convolution;
+ GLboolean EXT_compiled_vertex_array;
+ GLboolean EXT_copy_texture;
+ GLboolean EXT_depth_bounds_test;
+ GLboolean EXT_draw_range_elements;
+ GLboolean EXT_framebuffer_object;
+ GLboolean EXT_fog_coord;
+ GLboolean EXT_histogram;
+ GLboolean EXT_multi_draw_arrays;
+ GLboolean EXT_paletted_texture;
+ GLboolean EXT_packed_pixels;
+ GLboolean EXT_pixel_buffer_object;
+ GLboolean EXT_point_parameters;
+ GLboolean EXT_polygon_offset;
+ GLboolean EXT_rescale_normal;
+ GLboolean EXT_shadow_funcs;
+ GLboolean EXT_secondary_color;
+ GLboolean EXT_separate_specular_color;
+ GLboolean EXT_shared_texture_palette;
+ GLboolean EXT_stencil_wrap;
+ GLboolean EXT_stencil_two_side;
+ GLboolean EXT_subtexture;
+ GLboolean EXT_texture;
+ GLboolean EXT_texture_object;
+ GLboolean EXT_texture3D;
+ GLboolean EXT_texture_compression_s3tc;
+ GLboolean EXT_texture_env_add;
+ GLboolean EXT_texture_env_combine;
+ GLboolean EXT_texture_env_dot3;
+ GLboolean EXT_texture_filter_anisotropic;
+ GLboolean EXT_texture_lod_bias;
+ GLboolean EXT_texture_mirror_clamp;
+ GLboolean EXT_vertex_array;
+ GLboolean EXT_vertex_array_set;
+ /* vendor extensions */
+ GLboolean APPLE_client_storage;
+ GLboolean APPLE_packed_pixels;
+ GLboolean ATI_texture_mirror_once;
+ GLboolean ATI_texture_env_combine3;
+ GLboolean ATI_fragment_shader;
+ GLboolean HP_occlusion_test;
+ GLboolean IBM_rasterpos_clip;
+ GLboolean IBM_multimode_draw_arrays;
+ GLboolean MESA_pack_invert;
+ GLboolean MESA_packed_depth_stencil;
+ GLboolean MESA_program_debug;
+ GLboolean MESA_resize_buffers;
+ GLboolean MESA_ycbcr_texture;
+ GLboolean NV_blend_square;
+ GLboolean NV_fragment_program;
+ GLboolean NV_light_max_exponent;
+ GLboolean NV_point_sprite;
+ GLboolean NV_texgen_reflection;
+ GLboolean NV_texture_rectangle;
+ GLboolean NV_vertex_program;
+ GLboolean NV_vertex_program1_1;
+ GLboolean OES_read_format;
+ GLboolean SGI_color_matrix;
+ GLboolean SGI_color_table;
+ GLboolean SGI_texture_color_table;
+ GLboolean SGIS_generate_mipmap;
+ GLboolean SGIS_pixel_texture;
+ GLboolean SGIS_texture_edge_clamp;
+ GLboolean SGIS_texture_lod;
+ GLboolean SGIX_depth_texture;
+ GLboolean SGIX_pixel_texture;
+ GLboolean SGIX_shadow;
+ GLboolean SGIX_shadow_ambient; /* or GL_ARB_shadow_ambient */
+ GLboolean TDFX_texture_compression_FXT1;
+ GLboolean S3_s3tc;
+ /*@}*/
+ /* The extension string */
+ const GLubyte *String;
+};
+
+
+/**
+ * A stack of matrices (projection, modelview, color, texture, etc).
+ */
+struct matrix_stack
+{
+ GLmatrix *Top; /**< points into Stack */
+ GLmatrix *Stack; /**< array [MaxDepth] of GLmatrix */
+ GLuint Depth; /**< 0 <= Depth < MaxDepth */
+ GLuint MaxDepth; /**< size of Stack[] array */
+ GLuint DirtyFlag; /**< _NEW_MODELVIEW or _NEW_PROJECTION, for example */
+};
+
+
+/**
+ * \name Bits for image transfer operations
+ *
+ * \sa __GLcontextRec::ImageTransferState.
+ */
+/*@{*/
+#define IMAGE_SCALE_BIAS_BIT 0x1
+#define IMAGE_SHIFT_OFFSET_BIT 0x2
+#define IMAGE_MAP_COLOR_BIT 0x4
+#define IMAGE_COLOR_TABLE_BIT 0x8
+#define IMAGE_CONVOLUTION_BIT 0x10
+#define IMAGE_POST_CONVOLUTION_SCALE_BIAS 0x20
+#define IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT 0x40
+#define IMAGE_COLOR_MATRIX_BIT 0x80
+#define IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT 0x100
+#define IMAGE_HISTOGRAM_BIT 0x200
+#define IMAGE_MIN_MAX_BIT 0x400
+#define IMAGE_CLAMP_BIT 0x800 /* extra */
+
+
+/** Pixel Transfer ops up to convolution */
+#define IMAGE_PRE_CONVOLUTION_BITS (IMAGE_SCALE_BIAS_BIT | \
+ IMAGE_SHIFT_OFFSET_BIT | \
+ IMAGE_MAP_COLOR_BIT | \
+ IMAGE_COLOR_TABLE_BIT)
+
+/** Pixel transfer ops after convolution */
+#define IMAGE_POST_CONVOLUTION_BITS (IMAGE_POST_CONVOLUTION_SCALE_BIAS | \
+ IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT | \
+ IMAGE_COLOR_MATRIX_BIT | \
+ IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT |\
+ IMAGE_HISTOGRAM_BIT | \
+ IMAGE_MIN_MAX_BIT)
+/*@}*/
+
+
+/**
+ * \name Bits to indicate what state has changed.
+ *
+ * 4 unused flags.
+ */
+/*@{*/
+#define _NEW_MODELVIEW 0x1 /**< __GLcontextRec::ModelView */
+#define _NEW_PROJECTION 0x2 /**< __GLcontextRec::Projection */
+#define _NEW_TEXTURE_MATRIX 0x4 /**< __GLcontextRec::TextureMatrix */
+#define _NEW_COLOR_MATRIX 0x8 /**< __GLcontextRec::ColorMatrix */
+#define _NEW_ACCUM 0x10 /**< __GLcontextRec::Accum */
+#define _NEW_COLOR 0x20 /**< __GLcontextRec::Color */
+#define _NEW_DEPTH 0x40 /**< __GLcontextRec::Depth */
+#define _NEW_EVAL 0x80 /**< __GLcontextRec::Eval, __GLcontextRec::EvalMap */
+#define _NEW_FOG 0x100 /**< __GLcontextRec::Fog */
+#define _NEW_HINT 0x200 /**< __GLcontextRec::Hint */
+#define _NEW_LIGHT 0x400 /**< __GLcontextRec::Light */
+#define _NEW_LINE 0x800 /**< __GLcontextRec::Line */
+#define _NEW_PIXEL 0x1000 /**< __GLcontextRec::Pixel */
+#define _NEW_POINT 0x2000 /**< __GLcontextRec::Point */
+#define _NEW_POLYGON 0x4000 /**< __GLcontextRec::Polygon */
+#define _NEW_POLYGONSTIPPLE 0x8000 /**< __GLcontextRec::PolygonStipple */
+#define _NEW_SCISSOR 0x10000 /**< __GLcontextRec::Scissor */
+#define _NEW_STENCIL 0x20000 /**< __GLcontextRec::Stencil */
+#define _NEW_TEXTURE 0x40000 /**< __GLcontextRec::Texture */
+#define _NEW_TRANSFORM 0x80000 /**< __GLcontextRec::Transform */
+#define _NEW_VIEWPORT 0x100000 /**< __GLcontextRec::Viewport */
+#define _NEW_PACKUNPACK 0x200000 /**< __GLcontextRec::Pack, __GLcontextRec::Unpack */
+#define _NEW_ARRAY 0x400000 /**< __GLcontextRec::Array */
+#define _NEW_RENDERMODE 0x800000 /**< __GLcontextRec::RenderMode, __GLcontextRec::Feedback, __GLcontextRec::Select */
+#define _NEW_BUFFERS 0x1000000 /**< __GLcontextRec::Visual, __GLcontextRec::DrawBuffer, */
+#define _NEW_MULTISAMPLE 0x2000000 /**< __GLcontextRec::Multisample */
+#define _NEW_TRACK_MATRIX 0x4000000 /**< __GLcontextRec::VertexProgram */
+#define _NEW_PROGRAM 0x8000000 /**< __GLcontextRec::VertexProgram */
+#define _NEW_ALL ~0
+/*@}*/
+
+
+/**
+ * \name Bits to track array state changes
+ *
+ * Also used to summarize array enabled.
+ */
+/*@{*/
+#define _NEW_ARRAY_VERTEX VERT_BIT_POS
+#define _NEW_ARRAY_WEIGHT VERT_BIT_WEIGHT
+#define _NEW_ARRAY_NORMAL VERT_BIT_NORMAL
+#define _NEW_ARRAY_COLOR0 VERT_BIT_COLOR0
+#define _NEW_ARRAY_COLOR1 VERT_BIT_COLOR1
+#define _NEW_ARRAY_FOGCOORD VERT_BIT_FOG
+#define _NEW_ARRAY_INDEX VERT_BIT_SIX
+#define _NEW_ARRAY_EDGEFLAG VERT_BIT_SEVEN
+#define _NEW_ARRAY_TEXCOORD_0 VERT_BIT_TEX0
+#define _NEW_ARRAY_TEXCOORD_1 VERT_BIT_TEX1
+#define _NEW_ARRAY_TEXCOORD_2 VERT_BIT_TEX2
+#define _NEW_ARRAY_TEXCOORD_3 VERT_BIT_TEX3
+#define _NEW_ARRAY_TEXCOORD_4 VERT_BIT_TEX4
+#define _NEW_ARRAY_TEXCOORD_5 VERT_BIT_TEX5
+#define _NEW_ARRAY_TEXCOORD_6 VERT_BIT_TEX6
+#define _NEW_ARRAY_TEXCOORD_7 VERT_BIT_TEX7
+#define _NEW_ARRAY_ATTRIB_0 0x10000 /* start at bit 16 */
+#define _NEW_ARRAY_ALL 0xffffffff
+
+
+#define _NEW_ARRAY_TEXCOORD(i) (_NEW_ARRAY_TEXCOORD_0 << (i))
+#define _NEW_ARRAY_ATTRIB(i) (_NEW_ARRAY_ATTRIB_0 << (i))
+/*@}*/
+
+
+/**
+ * \name A bunch of flags that we think might be useful to drivers.
+ *
+ * Set in the __GLcontextRec::_TriangleCaps bitfield.
+ */
+/*@{*/
+#define DD_FLATSHADE 0x1
+#define DD_SEPARATE_SPECULAR 0x2
+#define DD_TRI_CULL_FRONT_BACK 0x4 /* special case on some hw */
+#define DD_TRI_LIGHT_TWOSIDE 0x8
+#define DD_TRI_UNFILLED 0x10
+#define DD_TRI_SMOOTH 0x20
+#define DD_TRI_STIPPLE 0x40
+#define DD_TRI_OFFSET 0x80
+#define DD_LINE_SMOOTH 0x100
+#define DD_LINE_STIPPLE 0x200
+#define DD_LINE_WIDTH 0x400
+#define DD_POINT_SMOOTH 0x800
+#define DD_POINT_SIZE 0x1000
+#define DD_POINT_ATTEN 0x2000
+#define DD_TRI_TWOSTENCIL 0x4000
+/*@}*/
+
+
+/**
+ * \name Define the state changes under which each of these bits might change
+ */
+/*@{*/
+#define _DD_NEW_FLATSHADE _NEW_LIGHT
+#define _DD_NEW_SEPARATE_SPECULAR (_NEW_LIGHT | _NEW_FOG | _NEW_PROGRAM)
+#define _DD_NEW_TRI_CULL_FRONT_BACK _NEW_POLYGON
+#define _DD_NEW_TRI_LIGHT_TWOSIDE _NEW_LIGHT
+#define _DD_NEW_TRI_UNFILLED _NEW_POLYGON
+#define _DD_NEW_TRI_SMOOTH _NEW_POLYGON
+#define _DD_NEW_TRI_STIPPLE _NEW_POLYGON
+#define _DD_NEW_TRI_OFFSET _NEW_POLYGON
+#define _DD_NEW_LINE_SMOOTH _NEW_LINE
+#define _DD_NEW_LINE_STIPPLE _NEW_LINE
+#define _DD_NEW_LINE_WIDTH _NEW_LINE
+#define _DD_NEW_POINT_SMOOTH _NEW_POINT
+#define _DD_NEW_POINT_SIZE _NEW_POINT
+#define _DD_NEW_POINT_ATTEN _NEW_POINT
+/*@}*/
+
+
+#define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \
+ _NEW_TEXTURE | \
+ _NEW_POINT | \
+ _NEW_MODELVIEW)
+
+#define _MESA_NEW_NEED_NORMALS (_NEW_LIGHT | \
+ _NEW_TEXTURE)
+
+#define _IMAGE_NEW_TRANSFER_STATE (_NEW_PIXEL | _NEW_COLOR_MATRIX)
+
+
+
+
+/*
+ * Forward declaration of display list data types:
+ */
+union node;
+typedef union node Node;
+
+
+/* This has to be included here. */
+#include "dd.h"
+
+
+#define NUM_VERTEX_FORMAT_ENTRIES (sizeof(GLvertexformat) / sizeof(void *))
+
+/**
+ * Core Mesa's support for tnl modules:
+ */
+struct gl_tnl_module
+{
+ /**
+ * Vertex format to be lazily swapped into current dispatch.
+ */
+ const GLvertexformat *Current;
+
+ /**
+ * \name Record of functions swapped out.
+ * On restore, only need to swap these functions back in.
+ */
+ /*@{*/
+ struct {
+ _glapi_proc * location;
+ _glapi_proc function;
+ } Swapped[NUM_VERTEX_FORMAT_ENTRIES];
+ GLuint SwapCount;
+ /*@}*/
+};
+
+/* Strictly this is a tnl/ private concept, but it doesn't seem
+ * worthwhile adding a tnl private structure just to hold this one bit
+ * of information:
+ */
+#define MESA_DLIST_DANGLING_REFS 0x1
+
+/* Provide a location where information about a display list can be
+ * collected. Could be extended with driverPrivate structures,
+ * etc. in the future.
+ */
+struct mesa_display_list
+{
+ Node *node;
+ GLuint id;
+ GLuint flags;
+};
+
+
+/**
+ * State used during display list compilation and execution.
+ */
+struct mesa_list_state
+{
+ struct mesa_display_list *CallStack[MAX_LIST_NESTING];
+ GLuint CallDepth; /**< Current recursion calling depth */
+
+ struct mesa_display_list *CurrentList;
+ 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 */
+
+ GLvertexformat ListVtxfmt;
+
+ GLubyte ActiveAttribSize[VERT_ATTRIB_MAX];
+ GLfloat CurrentAttrib[VERT_ATTRIB_MAX][4];
+
+ GLubyte ActiveMaterialSize[MAT_ATTRIB_MAX];
+ GLfloat CurrentMaterial[MAT_ATTRIB_MAX][4];
+
+ GLubyte ActiveIndex;
+ GLfloat CurrentIndex;
+
+ GLubyte ActiveEdgeFlag;
+ GLboolean CurrentEdgeFlag;
+};
+
+
+/**
+ * Mesa rendering context.
+ *
+ * This is the central context data structure for Mesa. Almost all
+ * OpenGL state is contained in this structure.
+ * Think of this as a base class from which device drivers will derive
+ * sub classes.
+ *
+ * The GLcontext typedef names this structure.
+ */
+struct __GLcontextRec
+{
+ /**
+ * \name OS related interfaces.
+ *
+ * These \b must be the first members of this structure, because they are
+ * exposed to the outside world (i.e. GLX extension).
+ */
+ /*@{*/
+ __GLimports imports;
+ __GLexports exports;
+ /*@}*/
+
+ /** State possibly shared with other contexts in the address space */
+ struct gl_shared_state *Shared;
+
+ /** \name API function pointer tables */
+ /*@{*/
+ struct _glapi_table *Save; /**< Display list save functions */
+ struct _glapi_table *Exec; /**< Execute functions */
+ struct _glapi_table *CurrentDispatch; /**< == Save or Exec !! */
+ /*@}*/
+
+ GLvisual Visual;
+ GLframebuffer *DrawBuffer; /**< buffer for writing */
+ GLframebuffer *ReadBuffer; /**< buffer for reading */
+ GLframebuffer *WinSysDrawBuffer; /**< set with MakeCurrent */
+ GLframebuffer *WinSysReadBuffer; /**< set with MakeCurrent */
+
+ /**
+ * Device driver function pointer table
+ */
+ struct dd_function_table Driver;
+
+ void *DriverCtx; /**< Points to device driver context/state */
+ void *DriverMgrCtx; /**< Points to device driver manager (optional)*/
+
+ /** Core/Driver constants */
+ struct gl_constants Const;
+
+ /** \name The various 4x4 matrix stacks */
+ /*@{*/
+ struct matrix_stack ModelviewMatrixStack;
+ struct matrix_stack ProjectionMatrixStack;
+ struct matrix_stack ColorMatrixStack;
+ struct matrix_stack TextureMatrixStack[MAX_TEXTURE_COORD_UNITS];
+ struct matrix_stack ProgramMatrixStack[MAX_PROGRAM_MATRICES];
+ struct matrix_stack *CurrentStack; /**< Points to one of the above stacks */
+ /*@}*/
+
+ /** Combined modelview and projection matrix */
+ GLmatrix _ModelProjectMatrix;
+
+ /** \name Display lists */
+ struct mesa_list_state ListState;
+
+ GLboolean ExecuteFlag; /**< Execute GL commands? */
+ GLboolean CompileFlag; /**< Compile GL commands into display list? */
+
+ /** Extensions */
+ struct gl_extensions Extensions;
+
+ /** \name Renderer attribute stack */
+ /*@{*/
+ GLuint AttribStackDepth;
+ struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH];
+ /*@}*/
+
+ /** \name Renderer attribute groups
+ *
+ * We define a struct for each attribute group to make pushing and popping
+ * attributes easy. Also it's a good organization.
+ */
+ /*@{*/
+ struct gl_accum_attrib Accum; /**< Accumulation buffer attributes */
+ struct gl_colorbuffer_attrib Color; /**< Color buffers attributes */
+ struct gl_current_attrib Current; /**< Current attributes */
+ struct gl_depthbuffer_attrib Depth; /**< Depth buffer attributes */
+ struct gl_eval_attrib Eval; /**< Eval attributes */
+ struct gl_fog_attrib Fog; /**< Fog attributes */
+ struct gl_hint_attrib Hint; /**< Hint attributes */
+ struct gl_light_attrib Light; /**< Light attributes */
+ struct gl_line_attrib Line; /**< Line attributes */
+ struct gl_list_attrib List; /**< List attributes */
+ struct gl_multisample_attrib Multisample;
+ struct gl_pixel_attrib Pixel; /**< Pixel attributes */
+ struct gl_point_attrib Point; /**< Point attributes */
+ struct gl_polygon_attrib Polygon; /**< Polygon attributes */
+ GLuint PolygonStipple[32]; /**< Polygon stipple */
+ struct gl_scissor_attrib Scissor; /**< Scissor attributes */
+ struct gl_stencil_attrib Stencil; /**< Stencil buffer attributes */
+ struct gl_texture_attrib Texture; /**< Texture attributes */
+ struct gl_transform_attrib Transform; /**< Transformation attributes */
+ struct gl_viewport_attrib Viewport; /**< Viewport attributes */
+ /*@}*/
+
+ /** \name Client attribute stack */
+ /*@{*/
+ GLuint ClientAttribStackDepth;
+ struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH];
+ /*@}*/
+
+ /** \name 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_pixelstore_attrib DefaultPacking; /**< Default params */
+ /*@}*/
+
+ /** \name Other assorted state (not pushed/popped on attribute stack) */
+ /*@{*/
+ 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;
+
+ 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;
+
+ struct gl_program_state Program; /**< for vertex or fragment progs */
+ struct gl_vertex_program_state VertexProgram; /**< GL_NV_vertex_program */
+ struct gl_fragment_program_state FragmentProgram; /**< GL_NV_fragment_program */
+ struct gl_ati_fragment_shader_state ATIFragmentShader; /**< GL_ATI_fragment_shader */
+
+ struct fragment_program *_TexEnvProgram; /**< Texture state as fragment program */
+ struct vertex_program *_TnlProgram; /**< Fixed func TNL state as vertex program */
+
+ GLboolean _MaintainTexEnvProgram;
+ GLboolean _MaintainTnlProgram;
+
+ struct gl_occlusion_state Occlusion; /**< GL_ARB_occlusion_query */
+
+ struct gl_shader_objects_state ShaderObjects; /* GL_ARB_shader_objects */
+ /*@}*/
+
+#if FEATURE_EXT_framebuffer_object
+ /*struct gl_framebuffer *CurrentFramebuffer;*/
+ struct gl_renderbuffer *CurrentRenderbuffer;
+#endif
+
+ GLenum ErrorValue; /**< Last error code */
+ GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
+ GLuint NewState; /**< bitwise-or of _NEW_* flags */
+
+ /** \name Derived state */
+ /*@{*/
+ GLuint _TriangleCaps; /**< bitwise-or of DD_* flags */
+ GLuint _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */
+ GLfloat _EyeZDir[3];
+ GLfloat _ModelViewInvScale;
+ GLuint _NeedEyeCoords;
+ GLuint _ForceEyeCoords;
+ GLboolean _RotateMode;
+ GLenum _CurrentProgram; /* currently executing program */
+
+ struct gl_shine_tab *_ShineTable[2]; /**< Active shine tables */
+ struct gl_shine_tab *_ShineTabList; /**< MRU list of inactive shine tables */
+ /**@}*/
+
+ struct gl_list_extensions ListExt; /**< driver dlist extensions */
+
+
+ GLboolean OcclusionResult; /**< for GL_HP_occlusion_test */
+ GLboolean OcclusionResultSaved; /**< for GL_HP_occlusion_test */
+ GLuint _Facing; /**< This is a hack for 2-sided stencil test.
+ *
+ * We don't have a better way to communicate this value from
+ * swrast_setup to swrast. */
+
+ /** \name Color clamping (tentative part of GL_ARB_color_clamp_control) */
+ /*@{*/
+ GLboolean ClampFragmentColors;
+ GLboolean ClampVertexColors;
+ /*@}*/
+
+ /** \name For debugging/development only */
+ /*@{*/
+ GLboolean FirstTimeCurrent;
+ /*@}*/
+
+ /** Dither disable via MESA_NO_DITHER env var */
+ GLboolean NoDither;
+
+ /** software compression/decompression supported or not */
+ GLboolean Mesa_DXTn;
+
+ /** Core tnl module support */
+ struct gl_tnl_module TnlModule;
+
+ /**
+ * \name Hooks for module contexts.
+ *
+ * These will eventually live in the driver or elsewhere.
+ */
+ /*@{*/
+ void *swrast_context;
+ void *swsetup_context;
+ void *swtnl_context;
+ void *swtnl_im;
+ void *acache_context;
+ void *aelt_context;
+ /*@}*/
+};
+
+
+/** The string names for GL_POINT, GL_LINE_LOOP, etc */
+extern const char *_mesa_prim_name[GL_POLYGON+4];
+
+
+#ifdef MESA_DEBUG
+extern int MESA_VERBOSE;
+extern int MESA_DEBUG_FLAGS;
+# define MESA_FUNCTION __FUNCTION__
+#else
+# define MESA_VERBOSE 0
+# define MESA_DEBUG_FLAGS 0
+# define MESA_FUNCTION "a function"
+# ifndef NDEBUG
+# define NDEBUG
+# endif
+#endif
+
+
+enum _verbose
+{
+ VERBOSE_VARRAY = 0x0001,
+ VERBOSE_TEXTURE = 0x0002,
+ VERBOSE_IMMEDIATE = 0x0004,
+ VERBOSE_PIPELINE = 0x0008,
+ VERBOSE_DRIVER = 0x0010,
+ VERBOSE_STATE = 0x0020,
+ VERBOSE_API = 0x0040,
+ VERBOSE_DISPLAY_LIST = 0x0100,
+ VERBOSE_LIGHTING = 0x0200,
+ VERBOSE_PRIMS = 0x0400,
+ VERBOSE_VERTS = 0x0800,
+ VERBOSE_DISASSEM = 0x1000
+};
+
+
+enum _debug
+{
+ DEBUG_ALWAYS_FLUSH = 0x1
+};
+
+
+
+#define Elements(x) sizeof(x)/sizeof(*(x))
+
+
+#endif /* TYPES_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/main/occlude.c b/nx-X11/extras/Mesa/src/mesa/main/occlude.c
new file mode 100644
index 000000000..bc61a475d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/occlude.c
@@ -0,0 +1,353 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.0.2
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+/*
+ * Functions to implement the GL_ARB_occlusion_query extension.
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "hash.h"
+#include "imports.h"
+#include "occlude.h"
+#include "mtypes.h"
+
+
+struct occlusion_query
+{
+ GLenum Target;
+ GLuint Id;
+ GLuint PassedCounter;
+ GLboolean Active;
+};
+
+
+/**
+ * Allocate a new occlusion query object.
+ * \param target - must be GL_SAMPLES_PASSED_ARB at this time
+ * \param id - the object's ID
+ * \return pointer to new occlusion_query object or NULL if out of memory.
+ */
+static struct occlusion_query *
+new_query_object(GLenum target, GLuint id)
+{
+ struct occlusion_query *q = MALLOC_STRUCT(occlusion_query);
+ if (q) {
+ q->Target = target;
+ q->Id = id;
+ q->PassedCounter = 0;
+ q->Active = GL_FALSE;
+ }
+ return q;
+}
+
+
+/**
+ * Delete an occlusion query object.
+ */
+static void
+delete_query_object(struct occlusion_query *q)
+{
+ FREE(q);
+}
+
+
+void GLAPIENTRY
+_mesa_GenQueriesARB(GLsizei n, GLuint *ids)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint first;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (n < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGenQueriesARB(n < 0)");
+ return;
+ }
+
+ if (ctx->Occlusion.Active) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGenQueriesARB");
+ return;
+ }
+
+ first = _mesa_HashFindFreeKeyBlock(ctx->Occlusion.QueryObjects, n);
+ if (first) {
+ GLsizei i;
+ for (i = 0; i < n; i++) {
+ struct occlusion_query *q = new_query_object(GL_SAMPLES_PASSED_ARB,
+ first + i);
+ if (!q) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenQueriesARB");
+ return;
+ }
+ ids[i] = first + i;
+ _mesa_HashInsert(ctx->Occlusion.QueryObjects, first + i, q);
+ }
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_DeleteQueriesARB(GLsizei n, const GLuint *ids)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (n < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glDeleteQueriesARB(n < 0)");
+ return;
+ }
+
+ if (ctx->Occlusion.Active) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glDeleteQueriesARB");
+ return;
+ }
+
+ for (i = 0; i < n; i++) {
+ if (ids[i] > 0) {
+ struct occlusion_query *q = (struct occlusion_query *)
+ _mesa_HashLookup(ctx->Occlusion.QueryObjects, ids[i]);
+ if (q) {
+ _mesa_HashRemove(ctx->Occlusion.QueryObjects, ids[i]);
+ delete_query_object(q);
+ }
+ }
+ }
+}
+
+
+GLboolean GLAPIENTRY
+_mesa_IsQueryARB(GLuint id)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+
+ if (id && _mesa_HashLookup(ctx->Occlusion.QueryObjects, id))
+ return GL_TRUE;
+ else
+ return GL_FALSE;
+}
+
+
+void GLAPIENTRY
+_mesa_BeginQueryARB(GLenum target, GLuint id)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct occlusion_query *q;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ FLUSH_VERTICES(ctx, _NEW_DEPTH);
+
+ if (target != GL_SAMPLES_PASSED_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBeginQueryARB(target)");
+ return;
+ }
+
+ if (id == 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQueryARB(id==0)");
+ return;
+ }
+
+ if (ctx->Occlusion.CurrentQueryObject) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQueryARB(target)");
+ return;
+ }
+
+ q = (struct occlusion_query *)
+ _mesa_HashLookup(ctx->Occlusion.QueryObjects, id);
+ if (q && q->Active) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glBeginQueryARB");
+ return;
+ }
+ else if (!q) {
+ q = new_query_object(target, id);
+ if (!q) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBeginQueryARB");
+ return;
+ }
+ _mesa_HashInsert(ctx->Occlusion.QueryObjects, id, q);
+ }
+
+ q->Active = GL_TRUE;
+ q->PassedCounter = 0;
+ ctx->Occlusion.Active = GL_TRUE;
+ ctx->Occlusion.CurrentQueryObject = id;
+ ctx->Occlusion.PassedCounter = 0;
+}
+
+
+void GLAPIENTRY
+_mesa_EndQueryARB(GLenum target)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct occlusion_query *q = NULL;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ FLUSH_VERTICES(ctx, _NEW_DEPTH);
+
+ if (target != GL_SAMPLES_PASSED_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glEndQueryARB(target)");
+ return;
+ }
+
+ if (ctx->Occlusion.CurrentQueryObject)
+ q = (struct occlusion_query *)
+ _mesa_HashLookup(ctx->Occlusion.QueryObjects,
+ ctx->Occlusion.CurrentQueryObject);
+ if (!q || !q->Active) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glEndQuery with no glBeginQuery");
+ return;
+ }
+
+ q->PassedCounter = ctx->Occlusion.PassedCounter;
+ q->Active = GL_FALSE;
+ ctx->Occlusion.Active = GL_FALSE;
+ ctx->Occlusion.CurrentQueryObject = 0;
+}
+
+
+void GLAPIENTRY
+_mesa_GetQueryivARB(GLenum target, GLenum pname, GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target != GL_SAMPLES_PASSED_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryivARB(target)");
+ return;
+ }
+
+ switch (pname) {
+ case GL_QUERY_COUNTER_BITS_ARB:
+ *params = 8 * sizeof(GLuint);
+ break;
+ case GL_CURRENT_QUERY_ARB:
+ *params = ctx->Occlusion.CurrentQueryObject;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryivARB(pname)");
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct occlusion_query *q = NULL;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (id)
+ q = (struct occlusion_query *)
+ _mesa_HashLookup(ctx->Occlusion.QueryObjects, id);
+
+ if (!q || q->Active) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetQueryObjectivARB(id=%d)", id);
+ return;
+ }
+
+ switch (pname) {
+ case GL_QUERY_RESULT_ARB:
+ *params = q->PassedCounter;
+ break;
+ case GL_QUERY_RESULT_AVAILABLE_ARB:
+ /* XXX revisit when we have a hardware implementation! */
+ *params = GL_TRUE;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectivARB(pname)");
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct occlusion_query *q = NULL;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (id)
+ q = (struct occlusion_query *)
+ _mesa_HashLookup(ctx->Occlusion.QueryObjects, id);
+ if (!q || q->Active) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetQueryObjectuivARB(id=%d", id);
+ return;
+ }
+
+ switch (pname) {
+ case GL_QUERY_RESULT_ARB:
+ *params = q->PassedCounter;
+ break;
+ case GL_QUERY_RESULT_AVAILABLE_ARB:
+ /* XXX revisit when we have a hardware implementation! */
+ *params = GL_TRUE;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetQueryObjectuivARB(pname)");
+ return;
+ }
+}
+
+
+
+/**
+ * Allocate/init the context state related to occlusion query objects.
+ */
+void
+_mesa_init_occlude(GLcontext *ctx)
+{
+#if FEATURE_ARB_occlusion_query
+ ctx->Occlusion.QueryObjects = _mesa_NewHashTable();
+#endif
+ ctx->OcclusionResult = GL_FALSE;
+ ctx->OcclusionResultSaved = GL_FALSE;
+}
+
+
+/**
+ * Free the context state related to occlusion query objects.
+ */
+void
+_mesa_free_occlude_data(GLcontext *ctx)
+{
+ while (1) {
+ GLuint query = _mesa_HashFirstEntry(ctx->Occlusion.QueryObjects);
+ if (query) {
+ struct occlusion_query *q = (struct occlusion_query *)
+ _mesa_HashLookup(ctx->Occlusion.QueryObjects, query);
+ ASSERT(q);
+ delete_query_object(q);
+ _mesa_HashRemove(ctx->Occlusion.QueryObjects, query);
+ }
+ else {
+ break;
+ }
+ }
+ _mesa_DeleteHashTable(ctx->Occlusion.QueryObjects);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/occlude.h b/nx-X11/extras/Mesa/src/mesa/main/occlude.h
new file mode 100644
index 000000000..acf19101f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/occlude.h
@@ -0,0 +1,61 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.0.2
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef OCCLUDE_H
+#define OCCLUDE_H
+
+
+extern void
+_mesa_init_occlude(GLcontext *ctx);
+
+extern void
+_mesa_free_occlude_data(GLcontext *ctx);
+
+extern void GLAPIENTRY
+_mesa_GenQueriesARB(GLsizei n, GLuint *ids);
+
+extern void GLAPIENTRY
+_mesa_DeleteQueriesARB(GLsizei n, const GLuint *ids);
+
+extern GLboolean GLAPIENTRY
+_mesa_IsQueryARB(GLuint id);
+
+extern void GLAPIENTRY
+_mesa_BeginQueryARB(GLenum target, GLuint id);
+
+extern void GLAPIENTRY
+_mesa_EndQueryARB(GLenum target);
+
+extern void GLAPIENTRY
+_mesa_GetQueryivARB(GLenum target, GLenum pname, GLint *params);
+
+extern void GLAPIENTRY
+_mesa_GetQueryObjectivARB(GLuint id, GLenum pname, GLint *params);
+
+extern void GLAPIENTRY
+_mesa_GetQueryObjectuivARB(GLuint id, GLenum pname, GLuint *params);
+
+
+#endif /* OCCLUDE_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/main/pixel.c b/nx-X11/extras/Mesa/src/mesa/main/pixel.c
new file mode 100644
index 000000000..d2edd0ecb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/pixel.c
@@ -0,0 +1,2119 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "glheader.h"
+#include "bufferobj.h"
+#include "colormac.h"
+#include "context.h"
+#include "image.h"
+#include "macros.h"
+#include "pixel.h"
+#include "mtypes.h"
+
+
+/**********************************************************************/
+/***** glPixelZoom *****/
+/**********************************************************************/
+
+
+
+void GLAPIENTRY
+_mesa_PixelZoom( GLfloat xfactor, GLfloat yfactor )
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->Pixel.ZoomX == xfactor &&
+ ctx->Pixel.ZoomY == yfactor)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.ZoomX = xfactor;
+ ctx->Pixel.ZoomY = yfactor;
+}
+
+
+
+/**********************************************************************/
+/***** glPixelStore *****/
+/**********************************************************************/
+
+
+void GLAPIENTRY
+_mesa_PixelStorei( GLenum pname, GLint param )
+{
+ /* NOTE: this call can't be compiled into the display list */
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ switch (pname) {
+ case GL_PACK_SWAP_BYTES:
+ if (param == (GLint)ctx->Pack.SwapBytes)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Pack.SwapBytes = param ? GL_TRUE : GL_FALSE;
+ break;
+ case GL_PACK_LSB_FIRST:
+ if (param == (GLint)ctx->Pack.LsbFirst)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Pack.LsbFirst = param ? GL_TRUE : GL_FALSE;
+ break;
+ case GL_PACK_ROW_LENGTH:
+ if (param<0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
+ return;
+ }
+ if (ctx->Pack.RowLength == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Pack.RowLength = param;
+ break;
+ case GL_PACK_IMAGE_HEIGHT:
+ if (param<0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
+ return;
+ }
+ if (ctx->Pack.ImageHeight == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Pack.ImageHeight = param;
+ break;
+ case GL_PACK_SKIP_PIXELS:
+ if (param<0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
+ return;
+ }
+ if (ctx->Pack.SkipPixels == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Pack.SkipPixels = param;
+ break;
+ case GL_PACK_SKIP_ROWS:
+ if (param<0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
+ return;
+ }
+ if (ctx->Pack.SkipRows == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Pack.SkipRows = param;
+ break;
+ case GL_PACK_SKIP_IMAGES:
+ if (param<0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
+ return;
+ }
+ if (ctx->Pack.SkipImages == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Pack.SkipImages = param;
+ break;
+ case GL_PACK_ALIGNMENT:
+ if (param!=1 && param!=2 && param!=4 && param!=8) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
+ return;
+ }
+ if (ctx->Pack.Alignment == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Pack.Alignment = param;
+ break;
+ case GL_PACK_INVERT_MESA:
+ if (!ctx->Extensions.MESA_pack_invert) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glPixelstore(pname)" );
+ return;
+ }
+ if (ctx->Pack.Invert == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Pack.Invert = param;
+ break;
+
+ case GL_UNPACK_SWAP_BYTES:
+ if (param == (GLint)ctx->Unpack.SwapBytes)
+ return;
+ if ((GLint)ctx->Unpack.SwapBytes == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Unpack.SwapBytes = param ? GL_TRUE : GL_FALSE;
+ break;
+ case GL_UNPACK_LSB_FIRST:
+ if (param == (GLint)ctx->Unpack.LsbFirst)
+ return;
+ if ((GLint)ctx->Unpack.LsbFirst == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Unpack.LsbFirst = param ? GL_TRUE : GL_FALSE;
+ break;
+ case GL_UNPACK_ROW_LENGTH:
+ if (param<0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
+ return;
+ }
+ if (ctx->Unpack.RowLength == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Unpack.RowLength = param;
+ break;
+ case GL_UNPACK_IMAGE_HEIGHT:
+ if (param<0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
+ return;
+ }
+ if (ctx->Unpack.ImageHeight == param)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Unpack.ImageHeight = param;
+ break;
+ case GL_UNPACK_SKIP_PIXELS:
+ if (param<0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
+ return;
+ }
+ if (ctx->Unpack.SkipPixels == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Unpack.SkipPixels = param;
+ break;
+ case GL_UNPACK_SKIP_ROWS:
+ if (param<0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
+ return;
+ }
+ if (ctx->Unpack.SkipRows == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Unpack.SkipRows = param;
+ break;
+ case GL_UNPACK_SKIP_IMAGES:
+ if (param < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore(param)" );
+ return;
+ }
+ if (ctx->Unpack.SkipImages == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Unpack.SkipImages = param;
+ break;
+ case GL_UNPACK_ALIGNMENT:
+ if (param!=1 && param!=2 && param!=4 && param!=8) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelStore" );
+ return;
+ }
+ if (ctx->Unpack.Alignment == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Unpack.Alignment = param;
+ break;
+ case GL_UNPACK_CLIENT_STORAGE_APPLE:
+ if (param == (GLint)ctx->Unpack.ClientStorage)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PACKUNPACK);
+ ctx->Unpack.ClientStorage = param ? GL_TRUE : GL_FALSE;
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glPixelStore" );
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_PixelStoref( GLenum pname, GLfloat param )
+{
+ _mesa_PixelStorei( pname, (GLint) param );
+}
+
+
+
+/**********************************************************************/
+/***** glPixelMap *****/
+/**********************************************************************/
+
+
+/**
+ * Helper routine used by the other _mesa_PixelMap() functions.
+ */
+static void
+pixelmap(GLcontext *ctx, GLenum map, GLsizei mapsize, const GLfloat *values)
+{
+ GLint i;
+ switch (map) {
+ case GL_PIXEL_MAP_S_TO_S:
+ ctx->Pixel.MapStoSsize = mapsize;
+ for (i = 0; i < mapsize; i++) {
+ ctx->Pixel.MapStoS[i] = IROUND(values[i]);
+ }
+ break;
+ case GL_PIXEL_MAP_I_TO_I:
+ ctx->Pixel.MapItoIsize = mapsize;
+ for (i = 0; i < mapsize; i++) {
+ ctx->Pixel.MapItoI[i] = values[i];
+ }
+ break;
+ case GL_PIXEL_MAP_I_TO_R:
+ ctx->Pixel.MapItoRsize = mapsize;
+ for (i = 0; i < mapsize; i++) {
+ GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
+ ctx->Pixel.MapItoR[i] = val;
+ ctx->Pixel.MapItoR8[i] = (GLint) (val * 255.0F);
+ }
+ break;
+ case GL_PIXEL_MAP_I_TO_G:
+ ctx->Pixel.MapItoGsize = mapsize;
+ for (i = 0; i < mapsize; i++) {
+ GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
+ ctx->Pixel.MapItoG[i] = val;
+ ctx->Pixel.MapItoG8[i] = (GLint) (val * 255.0F);
+ }
+ break;
+ case GL_PIXEL_MAP_I_TO_B:
+ ctx->Pixel.MapItoBsize = mapsize;
+ for (i = 0; i < mapsize; i++) {
+ GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
+ ctx->Pixel.MapItoB[i] = val;
+ ctx->Pixel.MapItoB8[i] = (GLint) (val * 255.0F);
+ }
+ break;
+ case GL_PIXEL_MAP_I_TO_A:
+ ctx->Pixel.MapItoAsize = mapsize;
+ for (i = 0; i < mapsize; i++) {
+ GLfloat val = CLAMP( values[i], 0.0F, 1.0F );
+ ctx->Pixel.MapItoA[i] = val;
+ ctx->Pixel.MapItoA8[i] = (GLint) (val * 255.0F);
+ }
+ break;
+ case GL_PIXEL_MAP_R_TO_R:
+ ctx->Pixel.MapRtoRsize = mapsize;
+ for (i = 0; i < mapsize; i++) {
+ ctx->Pixel.MapRtoR[i] = CLAMP( values[i], 0.0F, 1.0F );
+ }
+ break;
+ case GL_PIXEL_MAP_G_TO_G:
+ ctx->Pixel.MapGtoGsize = mapsize;
+ for (i = 0; i < mapsize; i++) {
+ ctx->Pixel.MapGtoG[i] = CLAMP( values[i], 0.0F, 1.0F );
+ }
+ break;
+ case GL_PIXEL_MAP_B_TO_B:
+ ctx->Pixel.MapBtoBsize = mapsize;
+ for (i = 0; i < mapsize; i++) {
+ ctx->Pixel.MapBtoB[i] = CLAMP( values[i], 0.0F, 1.0F );
+ }
+ break;
+ case GL_PIXEL_MAP_A_TO_A:
+ ctx->Pixel.MapAtoAsize = mapsize;
+ for (i = 0; i < mapsize; i++) {
+ ctx->Pixel.MapAtoA[i] = CLAMP( values[i], 0.0F, 1.0F );
+ }
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glPixelMap(map)" );
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ /* XXX someday, test against ctx->Const.MaxPixelMapTableSize */
+ if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" );
+ return;
+ }
+
+ if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
+ /* test that mapsize is a power of two */
+ if (_mesa_bitcount((GLuint) mapsize) != 1) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapfv(mapsize)" );
+ return;
+ }
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+
+ if (ctx->Unpack.BufferObj->Name) {
+ /* unpack pixelmap from PBO */
+ GLubyte *buf;
+ /* Note, need to use DefaultPacking and Unpack's buffer object */
+ ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj;
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
+ GL_INTENSITY, GL_FLOAT, values)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glPixelMapfv(invalid PBO access)");
+ return;
+ }
+ /* restore */
+ ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ GL_READ_ONLY_ARB,
+ ctx->Unpack.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glPixelMapfv(PBO is mapped)");
+ return;
+ }
+ values = (const GLfloat *) ADD_POINTERS(buf, values);
+ }
+ else if (!values) {
+ return;
+ }
+
+ pixelmap(ctx, map, mapsize, values);
+
+ if (ctx->Unpack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ ctx->Unpack.BufferObj);
+ }
+}
+
+
+
+void GLAPIENTRY
+_mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values )
+{
+ GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" );
+ return;
+ }
+
+ if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
+ /* test that mapsize is a power of two */
+ if (_mesa_bitcount((GLuint) mapsize) != 1) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" );
+ return;
+ }
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+
+ if (ctx->Unpack.BufferObj->Name) {
+ /* unpack pixelmap from PBO */
+ GLubyte *buf;
+ /* Note, need to use DefaultPacking and Unpack's buffer object */
+ ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj;
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
+ GL_INTENSITY, GL_UNSIGNED_INT, values)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glPixelMapuiv(invalid PBO access)");
+ return;
+ }
+ /* restore */
+ ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ GL_READ_ONLY_ARB,
+ ctx->Unpack.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glPixelMapuiv(PBO is mapped)");
+ return;
+ }
+ values = (const GLuint *) ADD_POINTERS(buf, values);
+ }
+ else if (!values) {
+ return;
+ }
+
+ /* convert to floats */
+ if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
+ GLint i;
+ for (i = 0; i < mapsize; i++) {
+ fvalues[i] = (GLfloat) values[i];
+ }
+ }
+ else {
+ GLint i;
+ for (i = 0; i < mapsize; i++) {
+ fvalues[i] = UINT_TO_FLOAT( values[i] );
+ }
+ }
+
+ if (ctx->Unpack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ ctx->Unpack.BufferObj);
+ }
+
+ pixelmap(ctx, map, mapsize, fvalues);
+}
+
+
+
+void GLAPIENTRY
+_mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values )
+{
+ GLfloat fvalues[MAX_PIXEL_MAP_TABLE];
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (mapsize < 1 || mapsize > MAX_PIXEL_MAP_TABLE) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapusv(mapsize)" );
+ return;
+ }
+
+ if (map >= GL_PIXEL_MAP_S_TO_S && map <= GL_PIXEL_MAP_I_TO_A) {
+ /* test that mapsize is a power of two */
+ if (_mesa_bitcount((GLuint) mapsize) != 1) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPixelMapuiv(mapsize)" );
+ return;
+ }
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+
+ if (ctx->Unpack.BufferObj->Name) {
+ /* unpack pixelmap from PBO */
+ GLubyte *buf;
+ /* Note, need to use DefaultPacking and Unpack's buffer object */
+ ctx->DefaultPacking.BufferObj = ctx->Unpack.BufferObj;
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
+ GL_INTENSITY, GL_UNSIGNED_SHORT,
+ values)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glPixelMapusv(invalid PBO access)");
+ return;
+ }
+ /* restore */
+ ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ GL_READ_ONLY_ARB,
+ ctx->Unpack.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glPixelMapusv(PBO is mapped)");
+ return;
+ }
+ values = (const GLushort *) ADD_POINTERS(buf, values);
+ }
+ else if (!values) {
+ return;
+ }
+
+ /* convert to floats */
+ if (map == GL_PIXEL_MAP_I_TO_I || map == GL_PIXEL_MAP_S_TO_S) {
+ GLint i;
+ for (i = 0; i < mapsize; i++) {
+ fvalues[i] = (GLfloat) values[i];
+ }
+ }
+ else {
+ GLint i;
+ for (i = 0; i < mapsize; i++) {
+ fvalues[i] = USHORT_TO_FLOAT( values[i] );
+ }
+ }
+
+ if (ctx->Unpack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ ctx->Unpack.BufferObj);
+ }
+
+ pixelmap(ctx, map, mapsize, fvalues);
+}
+
+
+/**
+ * Return size of the named map.
+ */
+static GLuint
+get_map_size(GLcontext *ctx, GLenum map)
+{
+ switch (map) {
+ case GL_PIXEL_MAP_I_TO_I:
+ return ctx->Pixel.MapItoIsize;
+ case GL_PIXEL_MAP_S_TO_S:
+ return ctx->Pixel.MapStoSsize;
+ case GL_PIXEL_MAP_I_TO_R:
+ return ctx->Pixel.MapItoRsize;
+ case GL_PIXEL_MAP_I_TO_G:
+ return ctx->Pixel.MapItoGsize;
+ case GL_PIXEL_MAP_I_TO_B:
+ return ctx->Pixel.MapItoBsize;
+ case GL_PIXEL_MAP_I_TO_A:
+ return ctx->Pixel.MapItoAsize;
+ case GL_PIXEL_MAP_R_TO_R:
+ return ctx->Pixel.MapRtoRsize;
+ case GL_PIXEL_MAP_G_TO_G:
+ return ctx->Pixel.MapGtoGsize;
+ case GL_PIXEL_MAP_B_TO_B:
+ return ctx->Pixel.MapBtoBsize;
+ case GL_PIXEL_MAP_A_TO_A:
+ return ctx->Pixel.MapAtoAsize;
+ default:
+ return 0;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetPixelMapfv( GLenum map, GLfloat *values )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint mapsize, i;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ mapsize = get_map_size(ctx, map);
+
+ if (ctx->Pack.BufferObj->Name) {
+ /* pack pixelmap into PBO */
+ GLubyte *buf;
+ /* Note, need to use DefaultPacking and Pack's buffer object */
+ ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj;
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
+ GL_INTENSITY, GL_FLOAT, values)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetPixelMapfv(invalid PBO access)");
+ return;
+ }
+ /* restore */
+ ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ GL_WRITE_ONLY_ARB,
+ ctx->Pack.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetPixelMapfv(PBO is mapped)");
+ return;
+ }
+ values = (GLfloat *) ADD_POINTERS(buf, values);
+ }
+ else if (!values) {
+ return;
+ }
+
+ switch (map) {
+ case GL_PIXEL_MAP_I_TO_I:
+ MEMCPY(values, ctx->Pixel.MapItoI, mapsize * sizeof(GLfloat));
+ break;
+ case GL_PIXEL_MAP_S_TO_S:
+ for (i = 0; i < mapsize; i++) {
+ values[i] = (GLfloat) ctx->Pixel.MapStoS[i];
+ }
+ break;
+ case GL_PIXEL_MAP_I_TO_R:
+ MEMCPY(values, ctx->Pixel.MapItoR, mapsize * sizeof(GLfloat));
+ break;
+ case GL_PIXEL_MAP_I_TO_G:
+ MEMCPY(values, ctx->Pixel.MapItoG, mapsize * sizeof(GLfloat));
+ break;
+ case GL_PIXEL_MAP_I_TO_B:
+ MEMCPY(values, ctx->Pixel.MapItoB, mapsize * sizeof(GLfloat));
+ break;
+ case GL_PIXEL_MAP_I_TO_A:
+ MEMCPY(values, ctx->Pixel.MapItoA, mapsize * sizeof(GLfloat));
+ break;
+ case GL_PIXEL_MAP_R_TO_R:
+ MEMCPY(values, ctx->Pixel.MapRtoR, mapsize * sizeof(GLfloat));
+ break;
+ case GL_PIXEL_MAP_G_TO_G:
+ MEMCPY(values, ctx->Pixel.MapGtoG, mapsize * sizeof(GLfloat));
+ break;
+ case GL_PIXEL_MAP_B_TO_B:
+ MEMCPY(values, ctx->Pixel.MapBtoB, mapsize * sizeof(GLfloat));
+ break;
+ case GL_PIXEL_MAP_A_TO_A:
+ MEMCPY(values, ctx->Pixel.MapAtoA, mapsize * sizeof(GLfloat));
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetPixelMapfv" );
+ }
+
+ if (ctx->Pack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ ctx->Pack.BufferObj);
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetPixelMapuiv( GLenum map, GLuint *values )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint mapsize, i;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ mapsize = get_map_size(ctx, map);
+
+ if (ctx->Pack.BufferObj->Name) {
+ /* pack pixelmap into PBO */
+ GLubyte *buf;
+ /* Note, need to use DefaultPacking and Pack's buffer object */
+ ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj;
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
+ GL_INTENSITY, GL_UNSIGNED_INT, values)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetPixelMapuiv(invalid PBO access)");
+ return;
+ }
+ /* restore */
+ ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ GL_WRITE_ONLY_ARB,
+ ctx->Pack.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetPixelMapuiv(PBO is mapped)");
+ return;
+ }
+ values = (GLuint *) ADD_POINTERS(buf, values);
+ }
+ else if (!values) {
+ return;
+ }
+
+ switch (map) {
+ case GL_PIXEL_MAP_I_TO_I:
+ for (i = 0; i < mapsize; i++) {
+ values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoI[i] );
+ }
+ break;
+ case GL_PIXEL_MAP_S_TO_S:
+ MEMCPY(values, ctx->Pixel.MapStoS, mapsize * sizeof(GLint));
+ break;
+ case GL_PIXEL_MAP_I_TO_R:
+ for (i = 0; i < mapsize; i++) {
+ values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoR[i] );
+ }
+ break;
+ case GL_PIXEL_MAP_I_TO_G:
+ for (i = 0; i < mapsize; i++) {
+ values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoG[i] );
+ }
+ break;
+ case GL_PIXEL_MAP_I_TO_B:
+ for (i = 0; i < mapsize; i++) {
+ values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoB[i] );
+ }
+ break;
+ case GL_PIXEL_MAP_I_TO_A:
+ for (i = 0; i < mapsize; i++) {
+ values[i] = FLOAT_TO_UINT( ctx->Pixel.MapItoA[i] );
+ }
+ break;
+ case GL_PIXEL_MAP_R_TO_R:
+ for (i = 0; i < mapsize; i++) {
+ values[i] = FLOAT_TO_UINT( ctx->Pixel.MapRtoR[i] );
+ }
+ break;
+ case GL_PIXEL_MAP_G_TO_G:
+ for (i = 0; i < mapsize; i++) {
+ values[i] = FLOAT_TO_UINT( ctx->Pixel.MapGtoG[i] );
+ }
+ break;
+ case GL_PIXEL_MAP_B_TO_B:
+ for (i = 0; i < mapsize; i++) {
+ values[i] = FLOAT_TO_UINT( ctx->Pixel.MapBtoB[i] );
+ }
+ break;
+ case GL_PIXEL_MAP_A_TO_A:
+ for (i = 0; i < mapsize; i++) {
+ values[i] = FLOAT_TO_UINT( ctx->Pixel.MapAtoA[i] );
+ }
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetPixelMapfv" );
+ }
+
+ if (ctx->Pack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ ctx->Pack.BufferObj);
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetPixelMapusv( GLenum map, GLushort *values )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint mapsize, i;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ mapsize = get_map_size(ctx, map);
+
+ if (ctx->Pack.BufferObj->Name) {
+ /* pack pixelmap into PBO */
+ GLubyte *buf;
+ /* Note, need to use DefaultPacking and Pack's buffer object */
+ ctx->DefaultPacking.BufferObj = ctx->Pack.BufferObj;
+ if (!_mesa_validate_pbo_access(1, &ctx->DefaultPacking, mapsize, 1, 1,
+ GL_INTENSITY, GL_UNSIGNED_SHORT,
+ values)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetPixelMapusv(invalid PBO access)");
+ return;
+ }
+ /* restore */
+ ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ GL_WRITE_ONLY_ARB,
+ ctx->Pack.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetPixelMapusv(PBO is mapped)");
+ return;
+ }
+ values = (GLushort *) ADD_POINTERS(buf, values);
+ }
+ else if (!values) {
+ return;
+ }
+
+ switch (map) {
+ case GL_PIXEL_MAP_I_TO_I:
+ for (i = 0; i < mapsize; i++) {
+ values[i] = (GLushort) CLAMP(ctx->Pixel.MapItoI[i], 0.0, 65535.0);
+ }
+ break;
+ case GL_PIXEL_MAP_S_TO_S:
+ for (i = 0; i < mapsize; i++) {
+ values[i] = (GLushort) CLAMP(ctx->Pixel.MapStoS[i], 0.0, 65535.0);
+ }
+ break;
+ case GL_PIXEL_MAP_I_TO_R:
+ for (i = 0; i < mapsize; i++) {
+ CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapItoR[i] );
+ }
+ break;
+ case GL_PIXEL_MAP_I_TO_G:
+ for (i = 0; i < mapsize; i++) {
+ CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapItoG[i] );
+ }
+ break;
+ case GL_PIXEL_MAP_I_TO_B:
+ for (i = 0; i < mapsize; i++) {
+ CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapItoB[i] );
+ }
+ break;
+ case GL_PIXEL_MAP_I_TO_A:
+ for (i = 0; i < mapsize; i++) {
+ CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapItoA[i] );
+ }
+ break;
+ case GL_PIXEL_MAP_R_TO_R:
+ for (i = 0; i < mapsize; i++) {
+ CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapRtoR[i] );
+ }
+ break;
+ case GL_PIXEL_MAP_G_TO_G:
+ for (i = 0; i < mapsize; i++) {
+ CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapGtoG[i] );
+ }
+ break;
+ case GL_PIXEL_MAP_B_TO_B:
+ for (i = 0; i < mapsize; i++) {
+ CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapBtoB[i] );
+ }
+ break;
+ case GL_PIXEL_MAP_A_TO_A:
+ for (i = 0; i < mapsize; i++) {
+ CLAMPED_FLOAT_TO_USHORT(values[i] , ctx->Pixel.MapAtoA[i] );
+ }
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetPixelMapfv" );
+ }
+
+ if (ctx->Pack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ ctx->Pack.BufferObj);
+ }
+}
+
+
+
+/**********************************************************************/
+/***** glPixelTransfer *****/
+/**********************************************************************/
+
+
+/*
+ * Implements glPixelTransfer[fi] whether called immediately or from a
+ * display list.
+ */
+void GLAPIENTRY
+_mesa_PixelTransferf( GLenum pname, GLfloat param )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ switch (pname) {
+ case GL_MAP_COLOR:
+ if (ctx->Pixel.MapColorFlag == (param ? GL_TRUE : GL_FALSE))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.MapColorFlag = param ? GL_TRUE : GL_FALSE;
+ break;
+ case GL_MAP_STENCIL:
+ if (ctx->Pixel.MapStencilFlag == (param ? GL_TRUE : GL_FALSE))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.MapStencilFlag = param ? GL_TRUE : GL_FALSE;
+ break;
+ case GL_INDEX_SHIFT:
+ if (ctx->Pixel.IndexShift == (GLint) param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.IndexShift = (GLint) param;
+ break;
+ case GL_INDEX_OFFSET:
+ if (ctx->Pixel.IndexOffset == (GLint) param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.IndexOffset = (GLint) param;
+ break;
+ case GL_RED_SCALE:
+ if (ctx->Pixel.RedScale == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.RedScale = param;
+ break;
+ case GL_RED_BIAS:
+ if (ctx->Pixel.RedBias == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.RedBias = param;
+ break;
+ case GL_GREEN_SCALE:
+ if (ctx->Pixel.GreenScale == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.GreenScale = param;
+ break;
+ case GL_GREEN_BIAS:
+ if (ctx->Pixel.GreenBias == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.GreenBias = param;
+ break;
+ case GL_BLUE_SCALE:
+ if (ctx->Pixel.BlueScale == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.BlueScale = param;
+ break;
+ case GL_BLUE_BIAS:
+ if (ctx->Pixel.BlueBias == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.BlueBias = param;
+ break;
+ case GL_ALPHA_SCALE:
+ if (ctx->Pixel.AlphaScale == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.AlphaScale = param;
+ break;
+ case GL_ALPHA_BIAS:
+ if (ctx->Pixel.AlphaBias == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.AlphaBias = param;
+ break;
+ case GL_DEPTH_SCALE:
+ if (ctx->Pixel.DepthScale == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.DepthScale = param;
+ break;
+ case GL_DEPTH_BIAS:
+ if (ctx->Pixel.DepthBias == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.DepthBias = param;
+ break;
+ case GL_POST_COLOR_MATRIX_RED_SCALE:
+ if (ctx->Pixel.PostColorMatrixScale[0] == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostColorMatrixScale[0] = param;
+ break;
+ case GL_POST_COLOR_MATRIX_RED_BIAS:
+ if (ctx->Pixel.PostColorMatrixBias[0] == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostColorMatrixBias[0] = param;
+ break;
+ case GL_POST_COLOR_MATRIX_GREEN_SCALE:
+ if (ctx->Pixel.PostColorMatrixScale[1] == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostColorMatrixScale[1] = param;
+ break;
+ case GL_POST_COLOR_MATRIX_GREEN_BIAS:
+ if (ctx->Pixel.PostColorMatrixBias[1] == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostColorMatrixBias[1] = param;
+ break;
+ case GL_POST_COLOR_MATRIX_BLUE_SCALE:
+ if (ctx->Pixel.PostColorMatrixScale[2] == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostColorMatrixScale[2] = param;
+ break;
+ case GL_POST_COLOR_MATRIX_BLUE_BIAS:
+ if (ctx->Pixel.PostColorMatrixBias[2] == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostColorMatrixBias[2] = param;
+ break;
+ case GL_POST_COLOR_MATRIX_ALPHA_SCALE:
+ if (ctx->Pixel.PostColorMatrixScale[3] == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostColorMatrixScale[3] = param;
+ break;
+ case GL_POST_COLOR_MATRIX_ALPHA_BIAS:
+ if (ctx->Pixel.PostColorMatrixBias[3] == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostColorMatrixBias[3] = param;
+ break;
+ case GL_POST_CONVOLUTION_RED_SCALE:
+ if (ctx->Pixel.PostConvolutionScale[0] == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostConvolutionScale[0] = param;
+ break;
+ case GL_POST_CONVOLUTION_RED_BIAS:
+ if (ctx->Pixel.PostConvolutionBias[0] == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostConvolutionBias[0] = param;
+ break;
+ case GL_POST_CONVOLUTION_GREEN_SCALE:
+ if (ctx->Pixel.PostConvolutionScale[1] == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostConvolutionScale[1] = param;
+ break;
+ case GL_POST_CONVOLUTION_GREEN_BIAS:
+ if (ctx->Pixel.PostConvolutionBias[1] == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostConvolutionBias[1] = param;
+ break;
+ case GL_POST_CONVOLUTION_BLUE_SCALE:
+ if (ctx->Pixel.PostConvolutionScale[2] == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostConvolutionScale[2] = param;
+ break;
+ case GL_POST_CONVOLUTION_BLUE_BIAS:
+ if (ctx->Pixel.PostConvolutionBias[2] == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostConvolutionBias[2] = param;
+ break;
+ case GL_POST_CONVOLUTION_ALPHA_SCALE:
+ if (ctx->Pixel.PostConvolutionScale[2] == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostConvolutionScale[2] = param;
+ break;
+ case GL_POST_CONVOLUTION_ALPHA_BIAS:
+ if (ctx->Pixel.PostConvolutionBias[2] == param)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.PostConvolutionBias[2] = param;
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glPixelTransfer(pname)" );
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_PixelTransferi( GLenum pname, GLint param )
+{
+ _mesa_PixelTransferf( pname, (GLfloat) param );
+}
+
+
+
+/**********************************************************************/
+/***** Pixel processing functions ******/
+/**********************************************************************/
+
+/*
+ * Apply scale and bias factors to an array of RGBA pixels.
+ */
+void
+_mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4],
+ GLfloat rScale, GLfloat gScale,
+ GLfloat bScale, GLfloat aScale,
+ GLfloat rBias, GLfloat gBias,
+ GLfloat bBias, GLfloat aBias)
+{
+ if (rScale != 1.0 || rBias != 0.0) {
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ rgba[i][RCOMP] = rgba[i][RCOMP] * rScale + rBias;
+ }
+ }
+ if (gScale != 1.0 || gBias != 0.0) {
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ rgba[i][GCOMP] = rgba[i][GCOMP] * gScale + gBias;
+ }
+ }
+ if (bScale != 1.0 || bBias != 0.0) {
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ rgba[i][BCOMP] = rgba[i][BCOMP] * bScale + bBias;
+ }
+ }
+ if (aScale != 1.0 || aBias != 0.0) {
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ rgba[i][ACOMP] = rgba[i][ACOMP] * aScale + aBias;
+ }
+ }
+}
+
+
+/*
+ * Apply pixel mapping to an array of floating point RGBA pixels.
+ */
+void
+_mesa_map_rgba( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] )
+{
+ const GLfloat rscale = (GLfloat) (ctx->Pixel.MapRtoRsize - 1);
+ const GLfloat gscale = (GLfloat) (ctx->Pixel.MapGtoGsize - 1);
+ const GLfloat bscale = (GLfloat) (ctx->Pixel.MapBtoBsize - 1);
+ const GLfloat ascale = (GLfloat) (ctx->Pixel.MapAtoAsize - 1);
+ const GLfloat *rMap = ctx->Pixel.MapRtoR;
+ const GLfloat *gMap = ctx->Pixel.MapGtoG;
+ const GLfloat *bMap = ctx->Pixel.MapBtoB;
+ const GLfloat *aMap = ctx->Pixel.MapAtoA;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ GLfloat r = CLAMP(rgba[i][RCOMP], 0.0F, 1.0F);
+ GLfloat g = CLAMP(rgba[i][GCOMP], 0.0F, 1.0F);
+ GLfloat b = CLAMP(rgba[i][BCOMP], 0.0F, 1.0F);
+ GLfloat a = CLAMP(rgba[i][ACOMP], 0.0F, 1.0F);
+ rgba[i][RCOMP] = rMap[IROUND(r * rscale)];
+ rgba[i][GCOMP] = gMap[IROUND(g * gscale)];
+ rgba[i][BCOMP] = bMap[IROUND(b * bscale)];
+ rgba[i][ACOMP] = aMap[IROUND(a * ascale)];
+ }
+}
+
+
+/*
+ * Apply the color matrix and post color matrix scaling and biasing.
+ */
+void
+_mesa_transform_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4])
+{
+ 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->ColorMatrixStack.Top->m;
+ GLuint i;
+ 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 floating point RGBA colors.
+ */
+void
+_mesa_lookup_rgba_float(const struct gl_color_table *table,
+ GLuint n, GLfloat rgba[][4])
+{
+ if (!table->Table || table->Size == 0)
+ return;
+
+ switch (table->Format) {
+ case GL_INTENSITY:
+ /* replace RGBA with I */
+ if (table->Type == GL_FLOAT) {
+ const GLint max = table->Size - 1;
+ const GLfloat scale = (GLfloat) max;
+ const GLfloat *lut = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = IROUND(rgba[i][RCOMP] * scale);
+ GLfloat c = lut[CLAMP(j, 0, max)];
+ rgba[i][RCOMP] = rgba[i][GCOMP] =
+ rgba[i][BCOMP] = rgba[i][ACOMP] = c;
+ }
+ }
+ else {
+ const GLint max = table->Size - 1;
+ const GLfloat scale = (GLfloat) max;
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = IROUND(rgba[i][RCOMP] * scale);
+ GLfloat c = CHAN_TO_FLOAT(lut[CLAMP(j, 0, max)]);
+ rgba[i][RCOMP] = rgba[i][GCOMP] =
+ rgba[i][BCOMP] = rgba[i][ACOMP] = c;
+ }
+ }
+ break;
+ case GL_LUMINANCE:
+ /* replace RGB with L */
+ if (table->Type == GL_FLOAT) {
+ const GLint max = table->Size - 1;
+ const GLfloat scale = (GLfloat) max;
+ const GLfloat *lut = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = IROUND(rgba[i][RCOMP] * scale);
+ GLfloat c = lut[CLAMP(j, 0, max)];
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
+ }
+ }
+ else {
+ const GLint max = table->Size - 1;
+ const GLfloat scale = (GLfloat) max;
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = IROUND(rgba[i][RCOMP] * scale);
+ GLfloat c = CHAN_TO_FLOAT(lut[CLAMP(j, 0, max)]);
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
+ }
+ }
+ break;
+ case GL_ALPHA:
+ /* replace A with A */
+ if (table->Type == GL_FLOAT) {
+ const GLint max = table->Size - 1;
+ const GLfloat scale = (GLfloat) max;
+ const GLfloat *lut = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = IROUND(rgba[i][ACOMP] * scale);
+ rgba[i][ACOMP] = lut[CLAMP(j, 0, max)];
+ }
+ }
+ else {
+ const GLint max = table->Size - 1;
+ const GLfloat scale = (GLfloat) max;
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = IROUND(rgba[i][ACOMP] * scale);
+ rgba[i][ACOMP] = CHAN_TO_FLOAT(lut[CLAMP(j, 0, max)]);
+ }
+ }
+ break;
+ case GL_LUMINANCE_ALPHA:
+ /* replace RGBA with LLLA */
+ if (table->Type == GL_FLOAT) {
+ const GLint max = table->Size - 1;
+ const GLfloat scale = (GLfloat) max;
+ const GLfloat *lut = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jL = IROUND(rgba[i][RCOMP] * scale);
+ GLint jA = IROUND(rgba[i][ACOMP] * scale);
+ GLfloat luminance, alpha;
+ jL = CLAMP(jL, 0, max);
+ jA = CLAMP(jA, 0, max);
+ luminance = lut[jL * 2 + 0];
+ alpha = lut[jA * 2 + 1];
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
+ rgba[i][ACOMP] = alpha;;
+ }
+ }
+ else {
+ const GLint max = table->Size - 1;
+ const GLfloat scale = (GLfloat) max;
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jL = IROUND(rgba[i][RCOMP] * scale);
+ GLint jA = IROUND(rgba[i][ACOMP] * scale);
+ GLfloat luminance, alpha;
+ jL = CLAMP(jL, 0, max);
+ jA = CLAMP(jA, 0, max);
+ luminance = CHAN_TO_FLOAT(lut[jL * 2 + 0]);
+ alpha = CHAN_TO_FLOAT(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->Type == GL_FLOAT) {
+ const GLint max = table->Size - 1;
+ const GLfloat scale = (GLfloat) max;
+ const GLfloat *lut = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jR = IROUND(rgba[i][RCOMP] * scale);
+ GLint jG = IROUND(rgba[i][GCOMP] * scale);
+ GLint jB = IROUND(rgba[i][BCOMP] * scale);
+ jR = CLAMP(jR, 0, max);
+ jG = CLAMP(jG, 0, max);
+ jB = CLAMP(jB, 0, max);
+ rgba[i][RCOMP] = lut[jR * 3 + 0];
+ rgba[i][GCOMP] = lut[jG * 3 + 1];
+ rgba[i][BCOMP] = lut[jB * 3 + 2];
+ }
+ }
+ else {
+ const GLint max = table->Size - 1;
+ const GLfloat scale = (GLfloat) max;
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jR = IROUND(rgba[i][RCOMP] * scale);
+ GLint jG = IROUND(rgba[i][GCOMP] * scale);
+ GLint jB = IROUND(rgba[i][BCOMP] * scale);
+ jR = CLAMP(jR, 0, max);
+ jG = CLAMP(jG, 0, max);
+ jB = CLAMP(jB, 0, max);
+ rgba[i][RCOMP] = CHAN_TO_FLOAT(lut[jR * 3 + 0]);
+ rgba[i][GCOMP] = CHAN_TO_FLOAT(lut[jG * 3 + 1]);
+ rgba[i][BCOMP] = CHAN_TO_FLOAT(lut[jB * 3 + 2]);
+ }
+ }
+ break;
+ case GL_RGBA:
+ /* replace RGBA with RGBA */
+ if (table->Type == GL_FLOAT) {
+ const GLint max = table->Size - 1;
+ const GLfloat scale = (GLfloat) max;
+ const GLfloat *lut = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jR = IROUND(rgba[i][RCOMP] * scale);
+ GLint jG = IROUND(rgba[i][GCOMP] * scale);
+ GLint jB = IROUND(rgba[i][BCOMP] * scale);
+ GLint jA = IROUND(rgba[i][ACOMP] * scale);
+ jR = CLAMP(jR, 0, max);
+ jG = CLAMP(jG, 0, max);
+ jB = CLAMP(jB, 0, max);
+ jA = CLAMP(jA, 0, max);
+ 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];
+ }
+ }
+ else {
+ const GLint max = table->Size - 1;
+ const GLfloat scale = (GLfloat) max;
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jR = IROUND(rgba[i][RCOMP] * scale);
+ GLint jG = IROUND(rgba[i][GCOMP] * scale);
+ GLint jB = IROUND(rgba[i][BCOMP] * scale);
+ GLint jA = IROUND(rgba[i][ACOMP] * scale);
+ jR = CLAMP(jR, 0, max);
+ jG = CLAMP(jG, 0, max);
+ jB = CLAMP(jB, 0, max);
+ jA = CLAMP(jA, 0, max);
+ rgba[i][RCOMP] = CHAN_TO_FLOAT(lut[jR * 4 + 0]);
+ rgba[i][GCOMP] = CHAN_TO_FLOAT(lut[jG * 4 + 1]);
+ rgba[i][BCOMP] = CHAN_TO_FLOAT(lut[jB * 4 + 2]);
+ rgba[i][ACOMP] = CHAN_TO_FLOAT(lut[jA * 4 + 3]);
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL, "Bad format in _mesa_lookup_rgba_float");
+ return;
+ }
+}
+
+
+
+/**
+ * Apply a color table lookup to an array of GLchan RGBA colors.
+ */
+void
+_mesa_lookup_rgba_chan(const struct gl_color_table *table,
+ GLuint n, GLchan rgba[][4])
+{
+ if (!table->Table || table->Size == 0)
+ return;
+
+ switch (table->Format) {
+ case GL_INTENSITY:
+ /* replace RGBA with I */
+ if (table->Type == GL_FLOAT) {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLfloat *lut = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ GLchan c;
+ CLAMPED_FLOAT_TO_CHAN(c, lut[j]);
+ rgba[i][RCOMP] = rgba[i][GCOMP] =
+ rgba[i][BCOMP] = rgba[i][ACOMP] = c;
+ }
+ }
+ else {
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ if (table->Size == 256) {
+ /* common case */
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ const GLchan c = lut[rgba[i][RCOMP]];
+ rgba[i][RCOMP] = rgba[i][GCOMP] =
+ rgba[i][BCOMP] = rgba[i][ACOMP] = c;
+ }
+ }
+ else
+#endif
+ {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ rgba[i][RCOMP] = rgba[i][GCOMP] =
+ rgba[i][BCOMP] = rgba[i][ACOMP] = lut[j];
+ }
+ }
+ }
+ break;
+ case GL_LUMINANCE:
+ /* replace RGB with L */
+ if (table->Type == GL_FLOAT) {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLfloat *lut = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ GLchan c;
+ CLAMPED_FLOAT_TO_CHAN(c, lut[j]);
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
+ }
+ }
+ else {
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ if (table->Size == 256) {
+ /* common case */
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ const GLchan c = lut[rgba[i][RCOMP]];
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
+ }
+ }
+ else
+#endif
+ {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = lut[j];
+ }
+ }
+ }
+ break;
+ case GL_ALPHA:
+ /* replace A with A */
+ if (table->Type == GL_FLOAT) {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLfloat *lut = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = IROUND((GLfloat) rgba[i][ACOMP] * scale);
+ GLchan c;
+ CLAMPED_FLOAT_TO_CHAN(c, lut[j]);
+ rgba[i][ACOMP] = c;
+ }
+ }
+ else {
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ if (table->Size == 256) {
+ /* common case */
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ rgba[i][ACOMP] = lut[rgba[i][ACOMP]];
+ }
+ }
+ else
+#endif
+ {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint j = IROUND((GLfloat) rgba[i][ACOMP] * scale);
+ rgba[i][ACOMP] = lut[j];
+ }
+ }
+ }
+ break;
+ case GL_LUMINANCE_ALPHA:
+ /* replace RGBA with LLLA */
+ if (table->Type == GL_FLOAT) {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLfloat *lut = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jL = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale);
+ GLchan luminance, alpha;
+ CLAMPED_FLOAT_TO_CHAN(luminance, lut[jL * 2 + 0]);
+ CLAMPED_FLOAT_TO_CHAN(alpha, lut[jA * 2 + 1]);
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
+ rgba[i][ACOMP] = alpha;;
+ }
+ }
+ else {
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ if (table->Size == 256) {
+ /* common case */
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLchan l = lut[rgba[i][RCOMP] * 2 + 0];
+ GLchan a = lut[rgba[i][ACOMP] * 2 + 1];;
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = l;
+ rgba[i][ACOMP] = a;
+ }
+ }
+ else
+#endif
+ {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jL = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale);
+ GLchan luminance = lut[jL * 2 + 0];
+ GLchan 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->Type == GL_FLOAT) {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLfloat *lut = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale);
+ GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], lut[jR * 3 + 0]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], lut[jG * 3 + 1]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], lut[jB * 3 + 2]);
+ }
+ }
+ else {
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ if (table->Size == 256) {
+ /* common case */
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ rgba[i][RCOMP] = lut[rgba[i][RCOMP] * 3 + 0];
+ rgba[i][GCOMP] = lut[rgba[i][GCOMP] * 3 + 1];
+ rgba[i][BCOMP] = lut[rgba[i][BCOMP] * 3 + 2];
+ }
+ }
+ else
+#endif
+ {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale);
+ GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale);
+ 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->Type == GL_FLOAT) {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLfloat *lut = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale);
+ GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale);
+ GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], lut[jR * 4 + 0]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], lut[jG * 4 + 1]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], lut[jB * 4 + 2]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], lut[jA * 4 + 3]);
+ }
+ }
+ else {
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ if (table->Size == 256) {
+ /* common case */
+ const GLchan *lut = (const GLchan *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ rgba[i][RCOMP] = lut[rgba[i][RCOMP] * 4 + 0];
+ rgba[i][GCOMP] = lut[rgba[i][GCOMP] * 4 + 1];
+ rgba[i][BCOMP] = lut[rgba[i][BCOMP] * 4 + 2];
+ rgba[i][ACOMP] = lut[rgba[i][ACOMP] * 4 + 3];
+ }
+ }
+ else
+#endif
+ {
+ const GLfloat scale = (GLfloat) (table->Size - 1) / CHAN_MAXF;
+ const GLfloat *lut = (const GLfloat *) table->Table;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint jR = IROUND((GLfloat) rgba[i][RCOMP] * scale);
+ GLint jG = IROUND((GLfloat) rgba[i][GCOMP] * scale);
+ GLint jB = IROUND((GLfloat) rgba[i][BCOMP] * scale);
+ GLint jA = IROUND((GLfloat) rgba[i][ACOMP] * scale);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], lut[jR * 4 + 0]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], lut[jG * 4 + 1]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], lut[jB * 4 + 2]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], lut[jA * 4 + 3]);
+ }
+ }
+ }
+ break;
+ default:
+ _mesa_problem(NULL, "Bad format in _mesa_lookup_rgba_chan");
+ return;
+ }
+}
+
+
+
+/*
+ * Apply color index shift and offset to an array of pixels.
+ */
+void
+_mesa_shift_and_offset_ci( const GLcontext *ctx, GLuint n, GLuint indexes[] )
+{
+ GLint shift = ctx->Pixel.IndexShift;
+ GLint offset = ctx->Pixel.IndexOffset;
+ GLuint i;
+ if (shift > 0) {
+ for (i=0;i<n;i++) {
+ indexes[i] = (indexes[i] << shift) + offset;
+ }
+ }
+ else if (shift < 0) {
+ shift = -shift;
+ for (i=0;i<n;i++) {
+ indexes[i] = (indexes[i] >> shift) + offset;
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ indexes[i] = indexes[i] + offset;
+ }
+ }
+}
+
+
+/*
+ * Apply color index mapping to color indexes.
+ */
+void
+_mesa_map_ci( const GLcontext *ctx, GLuint n, GLuint index[] )
+{
+ const GLuint mask = ctx->Pixel.MapItoIsize - 1;
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ const GLuint j = index[i] & mask;
+ index[i] = IROUND(ctx->Pixel.MapItoI[j]);
+ }
+}
+
+
+/*
+ * Map color indexes to rgba values.
+ */
+void
+_mesa_map_ci_to_rgba_chan( const GLcontext *ctx, GLuint n,
+ const GLuint index[], GLchan rgba[][4] )
+{
+#if CHAN_BITS == 8
+ GLuint rmask = ctx->Pixel.MapItoRsize - 1;
+ GLuint gmask = ctx->Pixel.MapItoGsize - 1;
+ GLuint bmask = ctx->Pixel.MapItoBsize - 1;
+ GLuint amask = ctx->Pixel.MapItoAsize - 1;
+ const GLubyte *rMap = ctx->Pixel.MapItoR8;
+ const GLubyte *gMap = ctx->Pixel.MapItoG8;
+ const GLubyte *bMap = ctx->Pixel.MapItoB8;
+ const GLubyte *aMap = ctx->Pixel.MapItoA8;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ rgba[i][RCOMP] = rMap[index[i] & rmask];
+ rgba[i][GCOMP] = gMap[index[i] & gmask];
+ rgba[i][BCOMP] = bMap[index[i] & bmask];
+ rgba[i][ACOMP] = aMap[index[i] & amask];
+ }
+#else
+ GLuint rmask = ctx->Pixel.MapItoRsize - 1;
+ GLuint gmask = ctx->Pixel.MapItoGsize - 1;
+ GLuint bmask = ctx->Pixel.MapItoBsize - 1;
+ GLuint amask = ctx->Pixel.MapItoAsize - 1;
+ const GLfloat *rMap = ctx->Pixel.MapItoR;
+ const GLfloat *gMap = ctx->Pixel.MapItoG;
+ const GLfloat *bMap = ctx->Pixel.MapItoB;
+ const GLfloat *aMap = ctx->Pixel.MapItoA;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], rMap[index[i] & rmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], gMap[index[i] & gmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], bMap[index[i] & bmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], aMap[index[i] & amask]);
+ }
+#endif
+}
+
+
+/*
+ * Map color indexes to float rgba values.
+ */
+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;
+ GLuint bmask = ctx->Pixel.MapItoBsize - 1;
+ GLuint amask = ctx->Pixel.MapItoAsize - 1;
+ const GLfloat *rMap = ctx->Pixel.MapItoR;
+ const GLfloat *gMap = ctx->Pixel.MapItoG;
+ const GLfloat *bMap = ctx->Pixel.MapItoB;
+ const GLfloat *aMap = ctx->Pixel.MapItoA;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ rgba[i][RCOMP] = rMap[index[i] & rmask];
+ rgba[i][GCOMP] = gMap[index[i] & gmask];
+ rgba[i][BCOMP] = bMap[index[i] & bmask];
+ rgba[i][ACOMP] = aMap[index[i] & amask];
+ }
+}
+
+
+/*
+ * Map 8-bit color indexes to rgb values.
+ */
+void
+_mesa_map_ci8_to_rgba( const GLcontext *ctx, GLuint n, const GLubyte index[],
+ GLchan rgba[][4] )
+{
+#if CHAN_BITS == 8
+ GLuint rmask = ctx->Pixel.MapItoRsize - 1;
+ GLuint gmask = ctx->Pixel.MapItoGsize - 1;
+ GLuint bmask = ctx->Pixel.MapItoBsize - 1;
+ GLuint amask = ctx->Pixel.MapItoAsize - 1;
+ const GLubyte *rMap = ctx->Pixel.MapItoR8;
+ const GLubyte *gMap = ctx->Pixel.MapItoG8;
+ const GLubyte *bMap = ctx->Pixel.MapItoB8;
+ const GLubyte *aMap = ctx->Pixel.MapItoA8;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ rgba[i][RCOMP] = rMap[index[i] & rmask];
+ rgba[i][GCOMP] = gMap[index[i] & gmask];
+ rgba[i][BCOMP] = bMap[index[i] & bmask];
+ rgba[i][ACOMP] = aMap[index[i] & amask];
+ }
+#else
+ GLuint rmask = ctx->Pixel.MapItoRsize - 1;
+ GLuint gmask = ctx->Pixel.MapItoGsize - 1;
+ GLuint bmask = ctx->Pixel.MapItoBsize - 1;
+ GLuint amask = ctx->Pixel.MapItoAsize - 1;
+ const GLfloat *rMap = ctx->Pixel.MapItoR;
+ const GLfloat *gMap = ctx->Pixel.MapItoG;
+ const GLfloat *bMap = ctx->Pixel.MapItoB;
+ const GLfloat *aMap = ctx->Pixel.MapItoA;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][RCOMP], rMap[index[i] & rmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][GCOMP], gMap[index[i] & gmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][BCOMP], bMap[index[i] & bmask]);
+ CLAMPED_FLOAT_TO_CHAN(rgba[i][ACOMP], aMap[index[i] & amask]);
+ }
+#endif
+}
+
+
+void
+_mesa_shift_and_offset_stencil( const GLcontext *ctx, GLuint n,
+ GLstencil stencil[] )
+{
+ GLuint i;
+ GLint shift = ctx->Pixel.IndexShift;
+ GLint offset = ctx->Pixel.IndexOffset;
+ if (shift > 0) {
+ for (i=0;i<n;i++) {
+ stencil[i] = (stencil[i] << shift) + offset;
+ }
+ }
+ else if (shift < 0) {
+ shift = -shift;
+ for (i=0;i<n;i++) {
+ stencil[i] = (stencil[i] >> shift) + offset;
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ stencil[i] = stencil[i] + offset;
+ }
+ }
+
+}
+
+
+void
+_mesa_map_stencil( const GLcontext *ctx, GLuint n, GLstencil stencil[] )
+{
+ GLuint mask = ctx->Pixel.MapStoSsize - 1;
+ GLuint i;
+ for (i=0;i<n;i++) {
+ stencil[i] = ctx->Pixel.MapStoS[ stencil[i] & mask ];
+ }
+}
+
+
+
+/*
+ * This function converts an array of GLchan colors to GLfloat colors.
+ * Most importantly, it undoes the non-uniform quantization of pixel
+ * values introduced when we convert shallow (< 8 bit) pixel values
+ * to GLubytes in the ctx->Driver.ReadRGBASpan() functions.
+ * This fixes a number of OpenGL conformance failures when running on
+ * 16bpp displays, for example.
+ */
+void
+_mesa_chan_to_float_span(const GLcontext *ctx, GLuint n,
+ CONST GLchan rgba[][4], GLfloat rgbaf[][4])
+{
+#if CHAN_TYPE == GL_FLOAT
+ MEMCPY(rgbaf, rgba, n * 4 * sizeof(GLfloat));
+#else
+ const GLuint rShift = CHAN_BITS - ctx->Visual.redBits;
+ const GLuint gShift = CHAN_BITS - ctx->Visual.greenBits;
+ const GLuint bShift = CHAN_BITS - ctx->Visual.blueBits;
+ GLuint aShift;
+ const GLfloat rScale = 1.0F / (GLfloat) ((1 << ctx->Visual.redBits ) - 1);
+ const GLfloat gScale = 1.0F / (GLfloat) ((1 << ctx->Visual.greenBits) - 1);
+ const GLfloat bScale = 1.0F / (GLfloat) ((1 << ctx->Visual.blueBits ) - 1);
+ GLfloat aScale;
+ GLuint i;
+
+ if (ctx->Visual.alphaBits > 0) {
+ aShift = CHAN_BITS - ctx->Visual.alphaBits;
+ aScale = 1.0F / (GLfloat) ((1 << ctx->Visual.alphaBits) - 1);
+ }
+ else {
+ aShift = 0;
+ aScale = 1.0F / CHAN_MAXF;
+ }
+
+ for (i = 0; i < n; i++) {
+ const GLint r = rgba[i][RCOMP] >> rShift;
+ const GLint g = rgba[i][GCOMP] >> gShift;
+ const GLint b = rgba[i][BCOMP] >> bShift;
+ const GLint a = rgba[i][ACOMP] >> aShift;
+ rgbaf[i][RCOMP] = (GLfloat) r * rScale;
+ rgbaf[i][GCOMP] = (GLfloat) g * gScale;
+ rgbaf[i][BCOMP] = (GLfloat) b * bScale;
+ rgbaf[i][ACOMP] = (GLfloat) a * aScale;
+ }
+#endif
+}
+
+/**********************************************************************/
+/***** State Management *****/
+/**********************************************************************/
+
+/*
+ * Return a bitmask of IMAGE_*_BIT flags which to indicate which
+ * pixel transfer operations are enabled.
+ */
+static void
+update_image_transfer_state(GLcontext *ctx)
+{
+ GLuint mask = 0;
+
+ if (ctx->Pixel.RedScale != 1.0F || ctx->Pixel.RedBias != 0.0F ||
+ ctx->Pixel.GreenScale != 1.0F || ctx->Pixel.GreenBias != 0.0F ||
+ ctx->Pixel.BlueScale != 1.0F || ctx->Pixel.BlueBias != 0.0F ||
+ ctx->Pixel.AlphaScale != 1.0F || ctx->Pixel.AlphaBias != 0.0F)
+ mask |= IMAGE_SCALE_BIAS_BIT;
+
+ if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset)
+ mask |= IMAGE_SHIFT_OFFSET_BIT;
+
+ if (ctx->Pixel.MapColorFlag)
+ mask |= IMAGE_MAP_COLOR_BIT;
+
+ if (ctx->Pixel.ColorTableEnabled)
+ mask |= IMAGE_COLOR_TABLE_BIT;
+
+ if (ctx->Pixel.Convolution1DEnabled ||
+ ctx->Pixel.Convolution2DEnabled ||
+ ctx->Pixel.Separable2DEnabled) {
+ mask |= IMAGE_CONVOLUTION_BIT;
+ if (ctx->Pixel.PostConvolutionScale[0] != 1.0F ||
+ ctx->Pixel.PostConvolutionScale[1] != 1.0F ||
+ ctx->Pixel.PostConvolutionScale[2] != 1.0F ||
+ ctx->Pixel.PostConvolutionScale[3] != 1.0F ||
+ ctx->Pixel.PostConvolutionBias[0] != 0.0F ||
+ ctx->Pixel.PostConvolutionBias[1] != 0.0F ||
+ ctx->Pixel.PostConvolutionBias[2] != 0.0F ||
+ ctx->Pixel.PostConvolutionBias[3] != 0.0F) {
+ mask |= IMAGE_POST_CONVOLUTION_SCALE_BIAS;
+ }
+ }
+
+ if (ctx->Pixel.PostConvolutionColorTableEnabled)
+ mask |= IMAGE_POST_CONVOLUTION_COLOR_TABLE_BIT;
+
+ if (ctx->ColorMatrixStack.Top->type != MATRIX_IDENTITY ||
+ 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)
+ mask |= IMAGE_COLOR_MATRIX_BIT;
+
+ if (ctx->Pixel.PostColorMatrixColorTableEnabled)
+ mask |= IMAGE_POST_COLOR_MATRIX_COLOR_TABLE_BIT;
+
+ if (ctx->Pixel.HistogramEnabled)
+ mask |= IMAGE_HISTOGRAM_BIT;
+
+ if (ctx->Pixel.MinMaxEnabled)
+ mask |= IMAGE_MIN_MAX_BIT;
+
+ ctx->_ImageTransferState = mask;
+}
+
+
+void _mesa_update_pixel( GLcontext *ctx, GLuint new_state )
+{
+ if (new_state & _NEW_COLOR_MATRIX)
+ _math_matrix_analyse( ctx->ColorMatrixStack.Top );
+
+ /* References ColorMatrix.type (derived above).
+ */
+ if (new_state & _IMAGE_NEW_TRANSFER_STATE)
+ update_image_transfer_state(ctx);
+}
+
+
+/**********************************************************************/
+/***** Initialization *****/
+/**********************************************************************/
+
+
+/**
+ * Initialize the context's PIXEL attribute group.
+ */
+void
+_mesa_init_pixel( GLcontext *ctx )
+{
+ int i;
+
+ /* Pixel group */
+ 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.DepthBias = 0.0;
+ ctx->Pixel.DepthScale = 1.0;
+ ctx->Pixel.IndexOffset = 0;
+ ctx->Pixel.IndexShift = 0;
+ ctx->Pixel.ZoomX = 1.0;
+ ctx->Pixel.ZoomY = 1.0;
+ ctx->Pixel.MapColorFlag = GL_FALSE;
+ ctx->Pixel.MapStencilFlag = GL_FALSE;
+ ctx->Pixel.MapStoSsize = 1;
+ ctx->Pixel.MapItoIsize = 1;
+ ctx->Pixel.MapItoRsize = 1;
+ ctx->Pixel.MapItoGsize = 1;
+ ctx->Pixel.MapItoBsize = 1;
+ ctx->Pixel.MapItoAsize = 1;
+ ctx->Pixel.MapRtoRsize = 1;
+ ctx->Pixel.MapGtoGsize = 1;
+ ctx->Pixel.MapBtoBsize = 1;
+ ctx->Pixel.MapAtoAsize = 1;
+ ctx->Pixel.MapStoS[0] = 0;
+ ctx->Pixel.MapItoI[0] = 0.0;
+ ctx->Pixel.MapItoR[0] = 0.0;
+ ctx->Pixel.MapItoG[0] = 0.0;
+ ctx->Pixel.MapItoB[0] = 0.0;
+ ctx->Pixel.MapItoA[0] = 0.0;
+ ctx->Pixel.MapItoR8[0] = 0;
+ ctx->Pixel.MapItoG8[0] = 0;
+ ctx->Pixel.MapItoB8[0] = 0;
+ ctx->Pixel.MapItoA8[0] = 0;
+ ctx->Pixel.MapRtoR[0] = 0.0;
+ 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);
+ ASSIGN_4V(ctx->Pixel.PCCTscale, 1.0, 1.0, 1.0, 1.0);
+ ASSIGN_4V(ctx->Pixel.PCCTbias, 0.0, 0.0, 0.0, 0.0);
+ ASSIGN_4V(ctx->Pixel.PCMCTscale, 1.0, 1.0, 1.0, 1.0);
+ ASSIGN_4V(ctx->Pixel.PCMCTbias, 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);
+ }
+ for (i = 0; i < MAX_CONVOLUTION_WIDTH * MAX_CONVOLUTION_WIDTH * 4; i++) {
+ ctx->Convolution1D.Filter[i] = 0.0;
+ ctx->Convolution2D.Filter[i] = 0.0;
+ ctx->Separable2D.Filter[i] = 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);
+ /* GL_SGI_texture_color_table */
+ ASSIGN_4V(ctx->Pixel.TextureColorTableScale, 1.0, 1.0, 1.0, 1.0);
+ ASSIGN_4V(ctx->Pixel.TextureColorTableBias, 0.0, 0.0, 0.0, 0.0);
+
+ /* Pixel transfer */
+ ctx->Pack.Alignment = 4;
+ ctx->Pack.RowLength = 0;
+ ctx->Pack.ImageHeight = 0;
+ ctx->Pack.SkipPixels = 0;
+ ctx->Pack.SkipRows = 0;
+ ctx->Pack.SkipImages = 0;
+ ctx->Pack.SwapBytes = GL_FALSE;
+ ctx->Pack.LsbFirst = GL_FALSE;
+ ctx->Pack.ClientStorage = GL_FALSE;
+ ctx->Pack.Invert = GL_FALSE;
+#if FEATURE_EXT_pixel_buffer_object
+ ctx->Pack.BufferObj = ctx->Array.NullBufferObj;
+#endif
+ ctx->Unpack.Alignment = 4;
+ ctx->Unpack.RowLength = 0;
+ ctx->Unpack.ImageHeight = 0;
+ ctx->Unpack.SkipPixels = 0;
+ ctx->Unpack.SkipRows = 0;
+ ctx->Unpack.SkipImages = 0;
+ ctx->Unpack.SwapBytes = GL_FALSE;
+ ctx->Unpack.LsbFirst = GL_FALSE;
+ ctx->Unpack.ClientStorage = GL_FALSE;
+ ctx->Unpack.Invert = GL_FALSE;
+#if FEATURE_EXT_pixel_buffer_object
+ ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+#endif
+
+ /*
+ * _mesa_unpack_image() returns image data in this format. When we
+ * execute image commands (glDrawPixels(), glTexImage(), etc) from
+ * within display lists we have to be sure to set the current
+ * unpacking parameters to these values!
+ */
+ ctx->DefaultPacking.Alignment = 1;
+ ctx->DefaultPacking.RowLength = 0;
+ ctx->DefaultPacking.SkipPixels = 0;
+ ctx->DefaultPacking.SkipRows = 0;
+ ctx->DefaultPacking.ImageHeight = 0;
+ ctx->DefaultPacking.SkipImages = 0;
+ ctx->DefaultPacking.SwapBytes = GL_FALSE;
+ ctx->DefaultPacking.LsbFirst = GL_FALSE;
+ ctx->DefaultPacking.ClientStorage = GL_FALSE;
+ ctx->DefaultPacking.Invert = GL_FALSE;
+#if FEATURE_EXT_pixel_buffer_object
+ ctx->DefaultPacking.BufferObj = ctx->Array.NullBufferObj;
+#endif
+
+ if (ctx->Visual.doubleBufferMode) {
+ ctx->Pixel.ReadBuffer = GL_BACK;
+ }
+ else {
+ ctx->Pixel.ReadBuffer = GL_FRONT;
+ }
+
+ /* Miscellaneous */
+ ctx->_ImageTransferState = 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/pixel.h b/nx-X11/extras/Mesa/src/mesa/main/pixel.h
new file mode 100644
index 000000000..9eef0cff5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/pixel.h
@@ -0,0 +1,153 @@
+/**
+ * \file pixel.h
+ * Pixel operations.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef PIXEL_H
+#define PIXEL_H
+
+
+#include "mtypes.h"
+
+
+/** \name API functions */
+/*@{*/
+
+extern void GLAPIENTRY
+_mesa_GetPixelMapfv( GLenum map, GLfloat *values );
+
+extern void GLAPIENTRY
+_mesa_GetPixelMapuiv( GLenum map, GLuint *values );
+
+extern void GLAPIENTRY
+_mesa_GetPixelMapusv( GLenum map, GLushort *values );
+
+extern void GLAPIENTRY
+_mesa_PixelMapfv( GLenum map, GLsizei mapsize, const GLfloat *values );
+
+extern void GLAPIENTRY
+_mesa_PixelMapuiv(GLenum map, GLsizei mapsize, const GLuint *values );
+
+extern void GLAPIENTRY
+_mesa_PixelMapusv(GLenum map, GLsizei mapsize, const GLushort *values );
+
+extern void GLAPIENTRY
+_mesa_PixelStoref( GLenum pname, GLfloat param );
+
+
+extern void GLAPIENTRY
+_mesa_PixelStorei( GLenum pname, GLint param );
+
+extern void GLAPIENTRY
+_mesa_PixelTransferf( GLenum pname, GLfloat param );
+
+extern void GLAPIENTRY
+_mesa_PixelTransferi( GLenum pname, GLint param );
+
+extern void GLAPIENTRY
+_mesa_PixelZoom( GLfloat xfactor, GLfloat yfactor );
+
+/*@}*/
+
+
+/** \name Pixel processing functions */
+/*@{*/
+
+extern void
+_mesa_scale_and_bias_rgba(GLuint n, GLfloat rgba[][4],
+ GLfloat rScale, GLfloat gScale,
+ GLfloat bScale, GLfloat aScale,
+ GLfloat rBias, GLfloat gBias,
+ GLfloat bBias, GLfloat aBias);
+
+extern void
+_mesa_map_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]);
+
+
+extern void
+_mesa_transform_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]);
+
+
+extern void
+_mesa_lookup_rgba_float(const struct gl_color_table *table,
+ GLuint n, GLfloat rgba[][4]);
+
+extern void
+_mesa_lookup_rgba_chan(const struct gl_color_table *table,
+ GLuint n, GLchan rgba[][4]);
+
+
+extern void
+_mesa_shift_and_offset_ci(const GLcontext *ctx, GLuint n,
+ GLuint indexes[]);
+
+
+extern void
+_mesa_map_ci(const GLcontext *ctx, GLuint n, GLuint index[]);
+
+
+extern void
+_mesa_map_ci_to_rgba_chan(const GLcontext *ctx,
+ GLuint n, const GLuint index[],
+ GLchan rgba[][4]);
+
+
+extern void
+_mesa_map_ci_to_rgba(const GLcontext *ctx,
+ GLuint n, const GLuint index[], GLfloat rgba[][4]);
+
+
+extern void
+_mesa_map_ci8_to_rgba(const GLcontext *ctx,
+ GLuint n, const GLubyte index[],
+ GLchan rgba[][4]);
+
+
+extern void
+_mesa_shift_and_offset_stencil(const GLcontext *ctx, GLuint n,
+ GLstencil indexes[]);
+
+
+extern void
+_mesa_map_stencil(const GLcontext *ctx, GLuint n, GLstencil index[]);
+
+
+extern void
+_mesa_chan_to_float_span(const GLcontext *ctx, GLuint n,
+ CONST GLchan rgba[][4], GLfloat rgbaf[][4]);
+
+
+extern void
+_mesa_update_pixel( GLcontext *ctx, GLuint newstate );
+
+extern void
+_mesa_init_pixel( GLcontext * ctx );
+
+/*@}*/
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/points.c b/nx-X11/extras/Mesa/src/mesa/main/points.c
new file mode 100644
index 000000000..aa36fb628
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/points.c
@@ -0,0 +1,294 @@
+/**
+ * \file points.c
+ * Point operations.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "points.h"
+#include "texstate.h"
+#include "mtypes.h"
+
+
+/**
+ * Set current point size.
+ * \param size point diameter in pixels
+ * \sa glPointSize().
+ */
+void GLAPIENTRY
+_mesa_PointSize( GLfloat size )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (size <= 0.0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPointSize" );
+ return;
+ }
+
+ if (ctx->Point.Size == size)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_POINT);
+ ctx->Point.Size = size;
+
+ if (ctx->Driver.PointSize)
+ ctx->Driver.PointSize(ctx, size);
+}
+
+
+#if _HAVE_FULL_GL
+
+/*
+ * Added by GL_NV_point_sprite
+ */
+void GLAPIENTRY
+_mesa_PointParameteriNV( GLenum pname, GLint param )
+{
+ const GLfloat value = (GLfloat) param;
+ _mesa_PointParameterfvEXT(pname, &value);
+}
+
+
+/*
+ * Added by GL_NV_point_sprite
+ */
+void GLAPIENTRY
+_mesa_PointParameterivNV( GLenum pname, const GLint *params )
+{
+ const GLfloat value = (GLfloat) params[0];
+ _mesa_PointParameterfvEXT(pname, &value);
+}
+
+
+
+/*
+ * Same for both GL_EXT_point_parameters and GL_ARB_point_parameters.
+ */
+void GLAPIENTRY
+_mesa_PointParameterfEXT( GLenum pname, GLfloat param)
+{
+ _mesa_PointParameterfvEXT(pname, &param);
+}
+
+
+
+/*
+ * Same for both GL_EXT_point_parameters and GL_ARB_point_parameters.
+ */
+void GLAPIENTRY
+_mesa_PointParameterfvEXT( GLenum pname, const GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ switch (pname) {
+ case GL_DISTANCE_ATTENUATION_EXT:
+ if (ctx->Extensions.EXT_point_parameters) {
+ if (TEST_EQ_3V(ctx->Point.Params, params))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POINT);
+ COPY_3V(ctx->Point.Params, params);
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glPointParameterf[v]{EXT,ARB}(pname)");
+ return;
+ }
+ break;
+ case GL_POINT_SIZE_MIN_EXT:
+ if (ctx->Extensions.EXT_point_parameters) {
+ if (params[0] < 0.0F) {
+ _mesa_error( ctx, GL_INVALID_VALUE,
+ "glPointParameterf[v]{EXT,ARB}(param)" );
+ return;
+ }
+ if (ctx->Point.MinSize == params[0])
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POINT);
+ ctx->Point.MinSize = params[0];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glPointParameterf[v]{EXT,ARB}(pname)");
+ return;
+ }
+ break;
+ case GL_POINT_SIZE_MAX_EXT:
+ if (ctx->Extensions.EXT_point_parameters) {
+ if (params[0] < 0.0F) {
+ _mesa_error( ctx, GL_INVALID_VALUE,
+ "glPointParameterf[v]{EXT,ARB}(param)" );
+ return;
+ }
+ if (ctx->Point.MaxSize == params[0])
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POINT);
+ ctx->Point.MaxSize = params[0];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glPointParameterf[v]{EXT,ARB}(pname)");
+ return;
+ }
+ break;
+ case GL_POINT_FADE_THRESHOLD_SIZE_EXT:
+ if (ctx->Extensions.EXT_point_parameters) {
+ if (params[0] < 0.0F) {
+ _mesa_error( ctx, GL_INVALID_VALUE,
+ "glPointParameterf[v]{EXT,ARB}(param)" );
+ return;
+ }
+ if (ctx->Point.Threshold == params[0])
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POINT);
+ ctx->Point.Threshold = params[0];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glPointParameterf[v]{EXT,ARB}(pname)");
+ return;
+ }
+ break;
+ case GL_POINT_SPRITE_R_MODE_NV:
+ /* This is one area where ARB_point_sprite and NV_point_sprite
+ * differ. In ARB_point_sprite the POINT_SPRITE_R_MODE is
+ * always ZERO. NV_point_sprite adds the S and R modes.
+ */
+ if (ctx->Extensions.NV_point_sprite) {
+ GLenum value = (GLenum) params[0];
+ if (value != GL_ZERO && value != GL_S && value != GL_R) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glPointParameterf[v]{EXT,ARB}(param)");
+ return;
+ }
+ if (ctx->Point.SpriteRMode == value)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POINT);
+ ctx->Point.SpriteRMode = value;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glPointParameterf[v]{EXT,ARB}(pname)");
+ return;
+ }
+ break;
+ case GL_POINT_SPRITE_COORD_ORIGIN:
+ if (ctx->Extensions.ARB_point_sprite) {
+ GLenum value = (GLenum) params[0];
+ if (value != GL_LOWER_LEFT && value != GL_UPPER_LEFT) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glPointParameterf[v]{EXT,ARB}(param)");
+ return;
+ }
+ if (ctx->Point.SpriteOrigin == value)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POINT);
+ ctx->Point.SpriteOrigin = value;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glPointParameterf[v]{EXT,ARB}(pname)");
+ return;
+ }
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM,
+ "glPointParameterf[v]{EXT,ARB}(pname)" );
+ return;
+ }
+
+ if (ctx->Driver.PointParameterfv)
+ (*ctx->Driver.PointParameterfv)(ctx, pname, params);
+}
+#endif
+
+
+
+/**
+ * Update derived point-related state.
+ */
+void
+_mesa_update_point(GLcontext *ctx)
+{
+ /* clamp to user-specified limits now, clamp to ctx->Const.Min/Max
+ * limits during rasterization.
+ */
+ ctx->Point._Size = CLAMP(ctx->Point.Size,
+ ctx->Point.MinSize,
+ ctx->Point.MaxSize);
+
+ if (ctx->Point._Size == 1.0F)
+ ctx->_TriangleCaps &= ~DD_POINT_SIZE;
+ else
+ ctx->_TriangleCaps |= DD_POINT_SIZE;
+
+ ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0 ||
+ ctx->Point.Params[1] != 0.0 ||
+ ctx->Point.Params[2] != 0.0);
+
+ if (ctx->Point._Attenuated)
+ ctx->_TriangleCaps |= DD_POINT_ATTEN;
+ else
+ ctx->_TriangleCaps &= ~DD_POINT_ATTEN;
+}
+
+
+
+/**
+ * Initialize the context point state.
+ *
+ * \param ctx GL context.
+ *
+ * Initializes __GLcontextRec::Point and point related constants in
+ * __GLcontextRec::Const.
+ */
+void
+_mesa_init_point(GLcontext *ctx)
+{
+ GLuint i;
+
+ ctx->Point.SmoothFlag = GL_FALSE;
+ ctx->Point.Size = 1.0;
+ ctx->Point._Size = 1.0;
+ ctx->Point.Params[0] = 1.0;
+ ctx->Point.Params[1] = 0.0;
+ ctx->Point.Params[2] = 0.0;
+ ctx->Point._Attenuated = GL_FALSE;
+ ctx->Point.MinSize = 0.0;
+ ctx->Point.MaxSize
+ = MAX2(ctx->Const.MaxPointSize, ctx->Const.MaxPointSizeAA);
+ ctx->Point.Threshold = 1.0;
+ ctx->Point.PointSprite = GL_FALSE; /* GL_ARB/NV_point_sprite */
+ ctx->Point.SpriteRMode = GL_ZERO; /* GL_NV_point_sprite (only!) */
+ ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */
+ for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
+ ctx->Point.CoordReplace[i] = GL_FALSE; /* GL_ARB/NV_point_sprite */
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/points.h b/nx-X11/extras/Mesa/src/mesa/main/points.h
new file mode 100644
index 000000000..56acd9ee5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/points.h
@@ -0,0 +1,60 @@
+/**
+ * \file points.h
+ * Point operations.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef POINTS_H
+#define POINTS_H
+
+
+#include "mtypes.h"
+
+
+extern void GLAPIENTRY
+_mesa_PointSize( GLfloat size );
+
+extern void GLAPIENTRY
+_mesa_PointParameteriNV( GLenum pname, GLint param );
+
+extern void GLAPIENTRY
+_mesa_PointParameterivNV( GLenum pname, const GLint *params );
+
+extern void GLAPIENTRY
+_mesa_PointParameterfEXT( GLenum pname, GLfloat param );
+
+extern void GLAPIENTRY
+_mesa_PointParameterfvEXT( GLenum pname, const GLfloat *params );
+
+extern void
+_mesa_update_point(GLcontext *ctx);
+
+extern void
+_mesa_init_point( GLcontext * ctx );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/polygon.c b/nx-X11/extras/Mesa/src/mesa/main/polygon.c
new file mode 100644
index 000000000..b771408cf
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/polygon.c
@@ -0,0 +1,383 @@
+/**
+ * \file polygon.c
+ * Polygon operations.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "bufferobj.h"
+#include "context.h"
+#include "image.h"
+#include "enums.h"
+#include "macros.h"
+#include "polygon.h"
+#include "mtypes.h"
+
+
+/**
+ * Specify whether to cull front- or back-facing facets.
+ *
+ * \param mode culling mode.
+ *
+ * \sa glCullFace().
+ *
+ * Verifies the parameter and updates gl_polygon_attrib::CullFaceMode. On
+ * change, flushes the vertices and notifies the driver via
+ * the dd_function_table::CullFace callback.
+ */
+void GLAPIENTRY
+_mesa_CullFace( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE&VERBOSE_API)
+ _mesa_debug(ctx, "glCullFace %s\n", _mesa_lookup_enum_by_nr(mode));
+
+ if (mode!=GL_FRONT && mode!=GL_BACK && mode!=GL_FRONT_AND_BACK) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glCullFace" );
+ return;
+ }
+
+ if (ctx->Polygon.CullFaceMode == mode)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_POLYGON);
+ ctx->Polygon.CullFaceMode = mode;
+
+ if (ctx->Driver.CullFace)
+ ctx->Driver.CullFace( ctx, mode );
+}
+
+
+/**
+ * Define front- and back-facing
+ *
+ * \param mode orientation of front-facing polygons.
+ *
+ * \sa glFrontFace().
+ *
+ * Verifies the parameter and updates gl_polygon_attrib::FrontFace. On change
+ * flushes the vertices and notifies the driver via
+ * the dd_function_table::FrontFace callback.
+ */
+void GLAPIENTRY
+_mesa_FrontFace( GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE&VERBOSE_API)
+ _mesa_debug(ctx, "glFrontFace %s\n", _mesa_lookup_enum_by_nr(mode));
+
+ if (mode!=GL_CW && mode!=GL_CCW) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glFrontFace" );
+ return;
+ }
+
+ if (ctx->Polygon.FrontFace == mode)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_POLYGON);
+ ctx->Polygon.FrontFace = mode;
+
+ ctx->Polygon._FrontBit = (GLboolean) (mode == GL_CW);
+
+ if (ctx->Driver.FrontFace)
+ ctx->Driver.FrontFace( ctx, mode );
+}
+
+
+/**
+ * Set the polygon rasterization mode.
+ *
+ * \param face the polygons which \p mode applies to.
+ * \param mode how polygons should be rasterized.
+ *
+ * \sa glPolygonMode().
+ *
+ * Verifies the parameters and updates gl_polygon_attrib::FrontMode and
+ * gl_polygon_attrib::BackMode. On change flushes the vertices and notifies the
+ * driver via the dd_function_table::PolygonMode callback.
+ */
+void GLAPIENTRY
+_mesa_PolygonMode( GLenum face, GLenum mode )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE&VERBOSE_API)
+ _mesa_debug(ctx, "glPolygonMode %s %s\n",
+ _mesa_lookup_enum_by_nr(face),
+ _mesa_lookup_enum_by_nr(mode));
+
+ if (mode!=GL_POINT && mode!=GL_LINE && mode!=GL_FILL) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(mode)" );
+ return;
+ }
+
+ switch (face) {
+ case GL_FRONT:
+ if (ctx->Polygon.FrontMode == mode)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POLYGON);
+ ctx->Polygon.FrontMode = mode;
+ break;
+ case GL_FRONT_AND_BACK:
+ if (ctx->Polygon.FrontMode == mode &&
+ ctx->Polygon.BackMode == mode)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POLYGON);
+ ctx->Polygon.FrontMode = mode;
+ ctx->Polygon.BackMode = mode;
+ break;
+ case GL_BACK:
+ if (ctx->Polygon.BackMode == mode)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POLYGON);
+ ctx->Polygon.BackMode = mode;
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glPolygonMode(face)" );
+ return;
+ }
+
+ ctx->_TriangleCaps &= ~DD_TRI_UNFILLED;
+ if (ctx->Polygon.FrontMode!=GL_FILL || ctx->Polygon.BackMode!=GL_FILL)
+ ctx->_TriangleCaps |= DD_TRI_UNFILLED;
+
+ if (ctx->Driver.PolygonMode) {
+ (*ctx->Driver.PolygonMode)( ctx, face, mode );
+ }
+}
+
+#if _HAVE_FULL_GL
+
+
+/**
+ * This routine updates the ctx->Polygon.Stipple state.
+ * If we're getting the stipple data from a PBO, we map the buffer
+ * in order to access the data.
+ * In any case, we obey the current pixel unpacking parameters when fetching
+ * the stipple data.
+ *
+ * In the future, this routine should be used as a fallback, called via
+ * ctx->Driver.PolygonStipple(). We'll have to update all the DRI drivers
+ * too.
+ */
+void
+_mesa_polygon_stipple(GLcontext *ctx, const GLubyte *pattern)
+{
+ if (ctx->Unpack.BufferObj->Name) {
+ /* Get/unpack the stipple pattern from a PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(2, &ctx->Unpack, 32, 32, 1,
+ GL_COLOR_INDEX, GL_BITMAP, pattern)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glPolygonStipple(bad PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ GL_READ_ONLY_ARB,
+ ctx->Unpack.BufferObj);
+ if (!buf) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glPolygonStipple(PBO mapped)");
+ return;
+ }
+ buf = ADD_POINTERS(buf, pattern);
+ _mesa_unpack_polygon_stipple(buf, ctx->PolygonStipple, &ctx->Unpack);
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ ctx->Unpack.BufferObj);
+ }
+ else {
+ /* Get/unpack the stipple pattern from user memory */
+ _mesa_unpack_polygon_stipple(pattern, ctx->PolygonStipple, &ctx->Unpack);
+ }
+}
+
+
+/**
+ * Called by glPolygonStipple.
+ */
+void GLAPIENTRY
+_mesa_PolygonStipple( const GLubyte *pattern )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE&VERBOSE_API)
+ _mesa_debug(ctx, "glPolygonStipple\n");
+
+ FLUSH_VERTICES(ctx, _NEW_POLYGONSTIPPLE);
+
+ _mesa_polygon_stipple(ctx, pattern);
+
+ if (ctx->Driver.PolygonStipple)
+ ctx->Driver.PolygonStipple(ctx, pattern);
+}
+
+
+/**
+ * Called by glPolygonStipple.
+ */
+void GLAPIENTRY
+_mesa_GetPolygonStipple( GLubyte *dest )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE&VERBOSE_API)
+ _mesa_debug(ctx, "glGetPolygonStipple\n");
+
+ /* XXX someday we may put this code into a separate function and call
+ * it with ctx->Driver.GetPolygonStipple().
+ */
+ if (ctx->Pack.BufferObj->Name) {
+ /* Put/pack the stipple pattern into a PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(2, &ctx->Pack, 32, 32, 1,
+ GL_COLOR_INDEX, GL_BITMAP, dest)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetPolygonStipple(bad PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ GL_WRITE_ONLY_ARB,
+ ctx->Pack.BufferObj);
+ if (!buf) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetPolygonStipple(PBO mapped)");
+ return;
+ }
+ buf = ADD_POINTERS(buf, dest);
+ _mesa_pack_polygon_stipple(ctx->PolygonStipple, buf, &ctx->Pack);
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ ctx->Pack.BufferObj);
+ }
+ else {
+ /* Put/pack the stipple pattern into user memory */
+ _mesa_pack_polygon_stipple(ctx->PolygonStipple, dest, &ctx->Pack);
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_PolygonOffset( GLfloat factor, GLfloat units )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE&VERBOSE_API)
+ _mesa_debug(ctx, "glPolygonOffset %f %f\n", factor, units);
+
+ if (ctx->Polygon.OffsetFactor == factor &&
+ ctx->Polygon.OffsetUnits == units)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_POLYGON);
+ ctx->Polygon.OffsetFactor = factor;
+ ctx->Polygon.OffsetUnits = units;
+
+ if (ctx->Driver.PolygonOffset)
+ ctx->Driver.PolygonOffset( ctx, factor, units );
+}
+
+
+void GLAPIENTRY
+_mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ /* XXX mult by DepthMaxF here??? */
+ _mesa_PolygonOffset(factor, bias * ctx->DrawBuffer->_DepthMaxF );
+}
+
+#endif
+
+
+/**********************************************************************/
+/** \name State Management */
+/*@{*/
+
+/*
+ * Check polygon state and set DD_TRI_CULL_FRONT_BACK and/or DD_TRI_OFFSET
+ * in ctx->_TriangleCaps if needed.
+ */
+void _mesa_update_polygon( GLcontext *ctx )
+{
+ ctx->_TriangleCaps &= ~(DD_TRI_CULL_FRONT_BACK | DD_TRI_OFFSET);
+
+ if (ctx->Polygon.CullFlag && ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK)
+ ctx->_TriangleCaps |= DD_TRI_CULL_FRONT_BACK;
+
+ /* Any Polygon offsets enabled? */
+ if (ctx->Polygon.OffsetPoint ||
+ ctx->Polygon.OffsetLine ||
+ ctx->Polygon.OffsetFill) {
+ ctx->_TriangleCaps |= DD_TRI_OFFSET;
+ }
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Initialization */
+/*@{*/
+
+/**
+ * Initialize the context polygon state.
+ *
+ * \param ctx GL context.
+ *
+ * Initializes __GLcontextRec::Polygon and __GLcontextRec::PolygonStipple
+ * attribute groups.
+ */
+void _mesa_init_polygon( GLcontext * ctx )
+{
+ /* Polygon group */
+ ctx->Polygon.CullFlag = GL_FALSE;
+ ctx->Polygon.CullFaceMode = GL_BACK;
+ ctx->Polygon.FrontFace = GL_CCW;
+ ctx->Polygon._FrontBit = 0;
+ ctx->Polygon.FrontMode = GL_FILL;
+ ctx->Polygon.BackMode = GL_FILL;
+ ctx->Polygon.SmoothFlag = GL_FALSE;
+ ctx->Polygon.StippleFlag = GL_FALSE;
+ ctx->Polygon.OffsetFactor = 0.0F;
+ ctx->Polygon.OffsetUnits = 0.0F;
+ ctx->Polygon.OffsetPoint = GL_FALSE;
+ ctx->Polygon.OffsetLine = GL_FALSE;
+ ctx->Polygon.OffsetFill = GL_FALSE;
+
+
+ /* Polygon Stipple group */
+ MEMSET( ctx->PolygonStipple, 0xff, 32*sizeof(GLuint) );
+}
+
+/*@}*/
diff --git a/nx-X11/extras/Mesa/src/mesa/main/polygon.h b/nx-X11/extras/Mesa/src/mesa/main/polygon.h
new file mode 100644
index 000000000..2550ed168
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/polygon.h
@@ -0,0 +1,69 @@
+/**
+ * \file polygon.h
+ * Polygon operations.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef POLYGON_H
+#define POLYGON_H
+
+
+#include "mtypes.h"
+
+
+extern void
+_mesa_polygon_stipple(GLcontext *ctx, const GLubyte *pattern);
+
+
+extern void GLAPIENTRY
+_mesa_CullFace( GLenum mode );
+
+extern void GLAPIENTRY
+_mesa_FrontFace( GLenum mode );
+
+extern void GLAPIENTRY
+_mesa_PolygonMode( GLenum face, GLenum mode );
+
+extern void GLAPIENTRY
+_mesa_PolygonOffset( GLfloat factor, GLfloat units );
+
+extern void GLAPIENTRY
+_mesa_PolygonOffsetEXT( GLfloat factor, GLfloat bias );
+
+extern void GLAPIENTRY
+_mesa_PolygonStipple( const GLubyte *mask );
+
+extern void GLAPIENTRY
+_mesa_GetPolygonStipple( GLubyte *mask );
+
+extern void
+_mesa_update_polygon( GLcontext *ctx );
+
+extern void
+_mesa_init_polygon( GLcontext * ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/rastpos.c b/nx-X11/extras/Mesa/src/mesa/main/rastpos.c
new file mode 100644
index 000000000..507eb9f98
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/rastpos.c
@@ -0,0 +1,1001 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file rastpos.c
+ * Raster position operations.
+ */
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "feedback.h"
+#include "light.h"
+#include "macros.h"
+#include "rastpos.h"
+#include "state.h"
+#include "simple_list.h"
+#include "mtypes.h"
+
+#include "math/m_matrix.h"
+
+
+/**
+ * Clip a point against the view volume.
+ *
+ * \param v vertex vector describing the point to clip.
+ *
+ * \return zero if outside view volume, or one if inside.
+ */
+static GLuint
+viewclip_point( const GLfloat v[] )
+{
+ if ( v[0] > v[3] || v[0] < -v[3]
+ || v[1] > v[3] || v[1] < -v[3]
+ || v[2] > v[3] || v[2] < -v[3] ) {
+ return 0;
+ }
+ else {
+ return 1;
+ }
+}
+
+
+/**
+ * Clip a point against the far/near Z clipping planes.
+ *
+ * \param v vertex vector describing the point to clip.
+ *
+ * \return zero if outside view volume, or one if inside.
+ */
+static GLuint
+viewclip_point_z( const GLfloat v[] )
+{
+ if (v[2] > v[3] || v[2] < -v[3] ) {
+ return 0;
+ }
+ else {
+ return 1;
+ }
+}
+
+
+/**
+ * Clip a point against the user clipping planes.
+ *
+ * \param ctx GL context.
+ * \param v vertex vector describing the point to clip.
+ *
+ * \return zero if the point was clipped, or one otherwise.
+ */
+static GLuint
+userclip_point( GLcontext *ctx, const GLfloat v[] )
+{
+ GLuint p;
+
+ for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
+ GLfloat dot = v[0] * ctx->Transform._ClipUserPlane[p][0]
+ + v[1] * ctx->Transform._ClipUserPlane[p][1]
+ + v[2] * ctx->Transform._ClipUserPlane[p][2]
+ + v[3] * ctx->Transform._ClipUserPlane[p][3];
+ if (dot < 0.0F) {
+ return 0;
+ }
+ }
+ }
+
+ return 1;
+}
+
+
+/**
+ * This has been split off to allow the normal shade routines to
+ * get a little closer to the vertex buffer, and to use the
+ * GLvector objects directly.
+ * \param ctx the context
+ * \param vertex vertex location
+ * \param normal normal vector
+ * \param Rcolor returned color
+ * \param Rspec returned specular color (if separate specular enabled)
+ * \param Rindex returned color index
+ */
+static void
+shade_rastpos(GLcontext *ctx,
+ const GLfloat vertex[4],
+ const GLfloat normal[3],
+ GLfloat Rcolor[4],
+ GLfloat Rspec[4],
+ GLfloat *Rindex)
+{
+ GLfloat (*base)[3] = ctx->Light._BaseColor;
+ struct gl_light *light;
+ GLfloat diffuseColor[4], specularColor[4];
+ GLfloat diffuse = 0, specular = 0;
+
+ if (!ctx->_ShineTable[0] || !ctx->_ShineTable[1])
+ _mesa_validate_all_lighting_tables( ctx );
+
+ COPY_3V(diffuseColor, base[0]);
+ diffuseColor[3] = CLAMP(
+ ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3], 0.0F, 1.0F );
+ ASSIGN_4V(specularColor, 0.0, 0.0, 0.0, 0.0);
+
+ foreach (light, &ctx->Light.EnabledList) {
+ GLfloat n_dot_h;
+ GLfloat attenuation = 1.0;
+ GLfloat VP[3];
+ GLfloat n_dot_VP;
+ GLfloat *h;
+ GLfloat diffuseContrib[3], specularContrib[3];
+ GLboolean normalized;
+
+ if (!(light->_Flags & LIGHT_POSITIONAL)) {
+ COPY_3V(VP, light->_VP_inf_norm);
+ attenuation = light->_VP_inf_spot_attenuation;
+ }
+ else {
+ GLfloat d;
+
+ SUB_3V(VP, light->_Position, vertex);
+ d = (GLfloat) LEN_3FV( VP );
+
+ if ( d > 1e-6) {
+ GLfloat invd = 1.0F / d;
+ SELF_SCALE_SCALAR_3V(VP, invd);
+ }
+ attenuation = 1.0F / (light->ConstantAttenuation + d *
+ (light->LinearAttenuation + d *
+ light->QuadraticAttenuation));
+
+ if (light->_Flags & LIGHT_SPOT) {
+ GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
+
+ if (PV_dot_dir<light->_CosCutoff) {
+ continue;
+ }
+ else {
+ double x = PV_dot_dir * (EXP_TABLE_SIZE-1);
+ int k = (int) x;
+ GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0]
+ + (x-k)*light->_SpotExpTable[k][1]);
+ attenuation *= spot;
+ }
+ }
+ }
+
+ if (attenuation < 1e-3)
+ continue;
+
+ n_dot_VP = DOT3( normal, VP );
+
+ if (n_dot_VP < 0.0F) {
+ ACC_SCALE_SCALAR_3V(diffuseColor, attenuation, light->_MatAmbient[0]);
+ continue;
+ }
+
+ COPY_3V(diffuseContrib, light->_MatAmbient[0]);
+ ACC_SCALE_SCALAR_3V(diffuseContrib, n_dot_VP, light->_MatDiffuse[0]);
+ diffuse += n_dot_VP * light->_dli * attenuation;
+ ASSIGN_3V(specularContrib, 0.0, 0.0, 0.0);
+
+ {
+ if (ctx->Light.Model.LocalViewer) {
+ GLfloat v[3];
+ COPY_3V(v, vertex);
+ NORMALIZE_3FV(v);
+ SUB_3V(VP, VP, v);
+ h = VP;
+ normalized = 0;
+ }
+ else if (light->_Flags & LIGHT_POSITIONAL) {
+ h = VP;
+ ACC_3V(h, ctx->_EyeZDir);
+ normalized = 0;
+ }
+ else {
+ h = light->_h_inf_norm;
+ normalized = 1;
+ }
+
+ n_dot_h = DOT3(normal, h);
+
+ if (n_dot_h > 0.0F) {
+ GLfloat (*mat)[4] = ctx->Light.Material.Attrib;
+ GLfloat spec_coef;
+ GLfloat shininess = mat[MAT_ATTRIB_FRONT_SHININESS][0];
+
+ if (!normalized) {
+ n_dot_h *= n_dot_h;
+ n_dot_h /= LEN_SQUARED_3FV( h );
+ shininess *= .5;
+ }
+
+ GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec_coef );
+
+ if (spec_coef > 1.0e-10) {
+ if (ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR) {
+ ACC_SCALE_SCALAR_3V( specularContrib, spec_coef,
+ light->_MatSpecular[0]);
+ }
+ else {
+ ACC_SCALE_SCALAR_3V( diffuseContrib, spec_coef,
+ light->_MatSpecular[0]);
+ }
+ specular += spec_coef * light->_sli * attenuation;
+ }
+ }
+ }
+
+ ACC_SCALE_SCALAR_3V( diffuseColor, attenuation, diffuseContrib );
+ ACC_SCALE_SCALAR_3V( specularColor, attenuation, specularContrib );
+ }
+
+ if (ctx->Visual.rgbMode) {
+ Rcolor[0] = CLAMP(diffuseColor[0], 0.0F, 1.0F);
+ Rcolor[1] = CLAMP(diffuseColor[1], 0.0F, 1.0F);
+ Rcolor[2] = CLAMP(diffuseColor[2], 0.0F, 1.0F);
+ Rcolor[3] = CLAMP(diffuseColor[3], 0.0F, 1.0F);
+ Rspec[0] = CLAMP(specularColor[0], 0.0F, 1.0F);
+ Rspec[1] = CLAMP(specularColor[1], 0.0F, 1.0F);
+ Rspec[2] = CLAMP(specularColor[2], 0.0F, 1.0F);
+ Rspec[3] = CLAMP(specularColor[3], 0.0F, 1.0F);
+ }
+ else {
+ GLfloat *ind = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_INDEXES];
+ GLfloat d_a = ind[MAT_INDEX_DIFFUSE] - ind[MAT_INDEX_AMBIENT];
+ GLfloat s_a = ind[MAT_INDEX_SPECULAR] - ind[MAT_INDEX_AMBIENT];
+ GLfloat i = (ind[MAT_INDEX_AMBIENT]
+ + diffuse * (1.0F-specular) * d_a
+ + specular * s_a);
+ if (i > ind[MAT_INDEX_SPECULAR]) {
+ i = ind[MAT_INDEX_SPECULAR];
+ }
+ *Rindex = i;
+ }
+}
+
+
+/**
+ * Do texgen needed for glRasterPos.
+ * \param ctx rendering context
+ * \param vObj object-space vertex coordinate
+ * \param vEye eye-space vertex coordinate
+ * \param normal vertex normal
+ * \param unit texture unit number
+ * \param texcoord incoming texcoord and resulting texcoord
+ */
+static void
+compute_texgen(GLcontext *ctx, const GLfloat vObj[4], const GLfloat vEye[4],
+ const GLfloat normal[3], GLuint unit, GLfloat texcoord[4])
+{
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+ /* always compute sphere map terms, just in case */
+ GLfloat u[3], two_nu, rx, ry, rz, m, mInv;
+ COPY_3V(u, vEye);
+ NORMALIZE_3FV(u);
+ two_nu = 2.0F * DOT3(normal, u);
+ rx = u[0] - normal[0] * two_nu;
+ ry = u[1] - normal[1] * two_nu;
+ rz = u[2] - normal[2] * two_nu;
+ m = rx * rx + ry * ry + (rz + 1.0F) * (rz + 1.0F);
+ if (m > 0.0F)
+ mInv = 0.5F * _mesa_inv_sqrtf(m);
+ else
+ mInv = 0.0F;
+
+ if (texUnit->TexGenEnabled & S_BIT) {
+ switch (texUnit->GenModeS) {
+ case GL_OBJECT_LINEAR:
+ texcoord[0] = DOT4(vObj, texUnit->ObjectPlaneS);
+ break;
+ case GL_EYE_LINEAR:
+ texcoord[0] = DOT4(vEye, texUnit->EyePlaneS);
+ break;
+ case GL_SPHERE_MAP:
+ texcoord[0] = rx * mInv + 0.5F;
+ break;
+ case GL_REFLECTION_MAP:
+ texcoord[0] = rx;
+ break;
+ case GL_NORMAL_MAP:
+ texcoord[0] = normal[0];
+ break;
+ default:
+ _mesa_problem(ctx, "Bad S texgen in compute_texgen()");
+ return;
+ }
+ }
+
+ if (texUnit->TexGenEnabled & T_BIT) {
+ switch (texUnit->GenModeT) {
+ case GL_OBJECT_LINEAR:
+ texcoord[1] = DOT4(vObj, texUnit->ObjectPlaneT);
+ break;
+ case GL_EYE_LINEAR:
+ texcoord[1] = DOT4(vEye, texUnit->EyePlaneT);
+ break;
+ case GL_SPHERE_MAP:
+ texcoord[1] = ry * mInv + 0.5F;
+ break;
+ case GL_REFLECTION_MAP:
+ texcoord[1] = ry;
+ break;
+ case GL_NORMAL_MAP:
+ texcoord[1] = normal[1];
+ break;
+ default:
+ _mesa_problem(ctx, "Bad T texgen in compute_texgen()");
+ return;
+ }
+ }
+
+ if (texUnit->TexGenEnabled & R_BIT) {
+ switch (texUnit->GenModeR) {
+ case GL_OBJECT_LINEAR:
+ texcoord[2] = DOT4(vObj, texUnit->ObjectPlaneR);
+ break;
+ case GL_EYE_LINEAR:
+ texcoord[2] = DOT4(vEye, texUnit->EyePlaneR);
+ break;
+ case GL_REFLECTION_MAP:
+ texcoord[2] = rz;
+ break;
+ case GL_NORMAL_MAP:
+ texcoord[2] = normal[2];
+ break;
+ default:
+ _mesa_problem(ctx, "Bad R texgen in compute_texgen()");
+ return;
+ }
+ }
+
+ if (texUnit->TexGenEnabled & Q_BIT) {
+ switch (texUnit->GenModeQ) {
+ case GL_OBJECT_LINEAR:
+ texcoord[3] = DOT4(vObj, texUnit->ObjectPlaneQ);
+ break;
+ case GL_EYE_LINEAR:
+ texcoord[3] = DOT4(vEye, texUnit->EyePlaneQ);
+ break;
+ default:
+ _mesa_problem(ctx, "Bad Q texgen in compute_texgen()");
+ return;
+ }
+ }
+}
+
+
+
+/**
+ * Set the raster position for pixel operations.
+ *
+ * All glRasterPos command call this function to update the current
+ * raster position.
+ *
+ * \param ctx GL context.
+ * \param x x coordinate for the raster position.
+ * \param y y coordinate for the raster position.
+ * \param z z coordinate for the raster position.
+ * \param w w coordinate for the raster position.
+ *
+ * \sa Called by _mesa_RasterPos4f().
+ *
+ * Flushes the vertices, transforms and clips the vertex coordinates, and
+ * finally sets the current raster position and associated data in
+ * __GLcontextRec::Current. When in selection mode calls
+ * _mesa_update_hitflag() with the current raster position.
+ */
+static void
+raster_pos4f(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ FLUSH_CURRENT(ctx, 0);
+
+ if (ctx->NewState)
+ _mesa_update_state( ctx );
+
+ if (ctx->VertexProgram._Enabled) {
+ /* XXX implement this */
+ _mesa_problem(ctx, "Vertex programs not implemented for glRasterPos");
+ return;
+ }
+ else {
+ GLfloat obj[4], eye[4], clip[4], ndc[3], d;
+ GLfloat *norm, eyenorm[3];
+ GLfloat *objnorm = ctx->Current.Attrib[VERT_ATTRIB_NORMAL];
+
+ ASSIGN_4V( obj, x, y, z, w );
+ /* apply modelview matrix: eye = MV * obj */
+ TRANSFORM_POINT( eye, ctx->ModelviewMatrixStack.Top->m, obj );
+ /* apply projection matrix: clip = Proj * eye */
+ TRANSFORM_POINT( clip, ctx->ProjectionMatrixStack.Top->m, eye );
+
+ /* clip to view volume */
+ if (ctx->Transform.RasterPositionUnclipped) {
+ /* GL_IBM_rasterpos_clip: only clip against Z */
+ if (viewclip_point_z(clip) == 0) {
+ ctx->Current.RasterPosValid = GL_FALSE;
+ return;
+ }
+ }
+ else if (viewclip_point(clip) == 0) {
+ /* Normal OpenGL behaviour */
+ ctx->Current.RasterPosValid = GL_FALSE;
+ return;
+ }
+
+ /* clip to user clipping planes */
+ if (ctx->Transform.ClipPlanesEnabled && !userclip_point(ctx, clip)) {
+ ctx->Current.RasterPosValid = GL_FALSE;
+ return;
+ }
+
+ /* ndc = clip / W */
+ d = (clip[3] == 0.0F) ? 1.0F : 1.0F / clip[3];
+ ndc[0] = clip[0] * d;
+ ndc[1] = clip[1] * d;
+ ndc[2] = clip[2] * d;
+ /* wincoord = viewport_mapping(ndc) */
+ ctx->Current.RasterPos[0] = (ndc[0] * ctx->Viewport._WindowMap.m[MAT_SX]
+ + ctx->Viewport._WindowMap.m[MAT_TX]);
+ ctx->Current.RasterPos[1] = (ndc[1] * ctx->Viewport._WindowMap.m[MAT_SY]
+ + ctx->Viewport._WindowMap.m[MAT_TY]);
+ ctx->Current.RasterPos[2] = (ndc[2] * ctx->Viewport._WindowMap.m[MAT_SZ]
+ + ctx->Viewport._WindowMap.m[MAT_TZ])
+ / ctx->DrawBuffer->_DepthMaxF;
+ ctx->Current.RasterPos[3] = clip[3];
+
+ /* compute raster distance */
+ if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
+ ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0];
+ else
+ ctx->Current.RasterDistance =
+ SQRTF( eye[0]*eye[0] + eye[1]*eye[1] + eye[2]*eye[2] );
+
+ /* compute transformed normal vector (for lighting or texgen) */
+ if (ctx->_NeedEyeCoords) {
+ const GLfloat *inv = ctx->ModelviewMatrixStack.Top->inv;
+ TRANSFORM_NORMAL( eyenorm, objnorm, inv );
+ norm = eyenorm;
+ }
+ else {
+ norm = objnorm;
+ }
+
+ /* update raster color */
+ if (ctx->Light.Enabled) {
+ /* lighting */
+ shade_rastpos( ctx, obj, norm,
+ ctx->Current.RasterColor,
+ ctx->Current.RasterSecondaryColor,
+ &ctx->Current.RasterIndex );
+ }
+ else {
+ /* use current color or index */
+ if (ctx->Visual.rgbMode) {
+ COPY_4FV(ctx->Current.RasterColor,
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0]);
+ COPY_4FV(ctx->Current.RasterSecondaryColor,
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR1]);
+ }
+ else {
+ ctx->Current.RasterIndex = ctx->Current.Index;
+ }
+ }
+
+ /* texture coords */
+ {
+ GLuint u;
+ for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
+ GLfloat tc[4];
+ COPY_4V(tc, ctx->Current.Attrib[VERT_ATTRIB_TEX0 + u]);
+ if (ctx->Texture.Unit[u].TexGenEnabled) {
+ compute_texgen(ctx, obj, eye, norm, u, tc);
+ }
+ TRANSFORM_POINT(ctx->Current.RasterTexCoords[u],
+ ctx->TextureMatrixStack[u].Top->m, tc);
+ }
+ }
+
+ ctx->Current.RasterPosValid = GL_TRUE;
+ }
+
+ if (ctx->RenderMode == GL_SELECT) {
+ _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] );
+ }
+}
+
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos2d(GLdouble x, GLdouble y)
+{
+ _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos2f(GLfloat x, GLfloat y)
+{
+ _mesa_RasterPos4f(x, y, 0.0F, 1.0F);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos2i(GLint x, GLint y)
+{
+ _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos2s(GLshort x, GLshort y)
+{
+ _mesa_RasterPos4f(x, y, 0.0F, 1.0F);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos3d(GLdouble x, GLdouble y, GLdouble z)
+{
+ _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos3f(GLfloat x, GLfloat y, GLfloat z)
+{
+ _mesa_RasterPos4f(x, y, z, 1.0F);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos3i(GLint x, GLint y, GLint z)
+{
+ _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos3s(GLshort x, GLshort y, GLshort z)
+{
+ _mesa_RasterPos4f(x, y, z, 1.0F);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
+}
+
+/** Calls raster_pos4f() */
+void GLAPIENTRY
+_mesa_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ raster_pos4f(ctx, x, y, z, w);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos4i(GLint x, GLint y, GLint z, GLint w)
+{
+ _mesa_RasterPos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w)
+{
+ _mesa_RasterPos4f(x, y, z, w);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos2dv(const GLdouble *v)
+{
+ _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos2fv(const GLfloat *v)
+{
+ _mesa_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos2iv(const GLint *v)
+{
+ _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos2sv(const GLshort *v)
+{
+ _mesa_RasterPos4f(v[0], v[1], 0.0F, 1.0F);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos3dv(const GLdouble *v)
+{
+ _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos3fv(const GLfloat *v)
+{
+ _mesa_RasterPos4f(v[0], v[1], v[2], 1.0F);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos3iv(const GLint *v)
+{
+ _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos3sv(const GLshort *v)
+{
+ _mesa_RasterPos4f(v[0], v[1], v[2], 1.0F);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos4dv(const GLdouble *v)
+{
+ _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
+ (GLfloat) v[2], (GLfloat) v[3]);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos4fv(const GLfloat *v)
+{
+ _mesa_RasterPos4f(v[0], v[1], v[2], v[3]);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos4iv(const GLint *v)
+{
+ _mesa_RasterPos4f((GLfloat) v[0], (GLfloat) v[1],
+ (GLfloat) v[2], (GLfloat) v[3]);
+}
+
+/** Calls _mesa_RasterPos4f() */
+void GLAPIENTRY
+_mesa_RasterPos4sv(const GLshort *v)
+{
+ _mesa_RasterPos4f(v[0], v[1], v[2], v[3]);
+}
+
+
+/**********************************************************************/
+/*** GL_ARB_window_pos / GL_MESA_window_pos ***/
+/**********************************************************************/
+
+#if FEATURE_windowpos
+/**
+ * All glWindowPosMESA and glWindowPosARB commands call this function to
+ * update the current raster position.
+ */
+static void
+window_pos3f(GLfloat x, GLfloat y, GLfloat z)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat z2;
+
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+ FLUSH_CURRENT(ctx, 0);
+
+ z2 = CLAMP(z, 0.0F, 1.0F) * (ctx->Viewport.Far - ctx->Viewport.Near)
+ + ctx->Viewport.Near;
+
+ /* set raster position */
+ ctx->Current.RasterPos[0] = x;
+ ctx->Current.RasterPos[1] = y;
+ ctx->Current.RasterPos[2] = z2;
+ ctx->Current.RasterPos[3] = 1.0F;
+
+ ctx->Current.RasterPosValid = GL_TRUE;
+
+ if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT)
+ ctx->Current.RasterDistance = ctx->Current.Attrib[VERT_ATTRIB_FOG][0];
+ else
+ ctx->Current.RasterDistance = 0.0;
+
+ /* raster color = current color or index */
+ if (ctx->Visual.rgbMode) {
+ ctx->Current.RasterColor[0]
+ = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0], 0.0F, 1.0F);
+ ctx->Current.RasterColor[1]
+ = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1], 0.0F, 1.0F);
+ ctx->Current.RasterColor[2]
+ = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2], 0.0F, 1.0F);
+ ctx->Current.RasterColor[3]
+ = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3], 0.0F, 1.0F);
+ ctx->Current.RasterSecondaryColor[0]
+ = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][0], 0.0F, 1.0F);
+ ctx->Current.RasterSecondaryColor[1]
+ = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][1], 0.0F, 1.0F);
+ ctx->Current.RasterSecondaryColor[2]
+ = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][2], 0.0F, 1.0F);
+ ctx->Current.RasterSecondaryColor[3]
+ = CLAMP(ctx->Current.Attrib[VERT_ATTRIB_COLOR1][3], 0.0F, 1.0F);
+ }
+ else {
+ ctx->Current.RasterIndex = ctx->Current.Index;
+ }
+
+ /* raster texcoord = current texcoord */
+ {
+ GLuint texSet;
+ for (texSet = 0; texSet < ctx->Const.MaxTextureCoordUnits; texSet++) {
+ COPY_4FV( ctx->Current.RasterTexCoords[texSet],
+ ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texSet] );
+ }
+ }
+
+ if (ctx->RenderMode==GL_SELECT) {
+ _mesa_update_hitflag( ctx, ctx->Current.RasterPos[2] );
+ }
+}
+
+
+/* This is just to support the GL_MESA_window_pos version */
+static void
+window_pos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ window_pos3f(x, y, z);
+ ctx->Current.RasterPos[3] = w;
+}
+
+
+void GLAPIENTRY
+_mesa_WindowPos2dMESA(GLdouble x, GLdouble y)
+{
+ window_pos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos2fMESA(GLfloat x, GLfloat y)
+{
+ window_pos4f(x, y, 0.0F, 1.0F);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos2iMESA(GLint x, GLint y)
+{
+ window_pos4f((GLfloat) x, (GLfloat) y, 0.0F, 1.0F);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos2sMESA(GLshort x, GLshort y)
+{
+ window_pos4f(x, y, 0.0F, 1.0F);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
+{
+ window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z)
+{
+ window_pos4f(x, y, z, 1.0F);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos3iMESA(GLint x, GLint y, GLint z)
+{
+ window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, 1.0F);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos3sMESA(GLshort x, GLshort y, GLshort z)
+{
+ window_pos4f(x, y, z, 1.0F);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ window_pos4f(x, y, z, w);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w)
+{
+ window_pos4f((GLfloat) x, (GLfloat) y, (GLfloat) z, (GLfloat) w);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w)
+{
+ window_pos4f(x, y, z, w);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos2dvMESA(const GLdouble *v)
+{
+ window_pos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos2fvMESA(const GLfloat *v)
+{
+ window_pos4f(v[0], v[1], 0.0F, 1.0F);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos2ivMESA(const GLint *v)
+{
+ window_pos4f((GLfloat) v[0], (GLfloat) v[1], 0.0F, 1.0F);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos2svMESA(const GLshort *v)
+{
+ window_pos4f(v[0], v[1], 0.0F, 1.0F);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos3dvMESA(const GLdouble *v)
+{
+ window_pos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos3fvMESA(const GLfloat *v)
+{
+ window_pos4f(v[0], v[1], v[2], 1.0);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos3ivMESA(const GLint *v)
+{
+ window_pos4f((GLfloat) v[0], (GLfloat) v[1], (GLfloat) v[2], 1.0F);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos3svMESA(const GLshort *v)
+{
+ window_pos4f(v[0], v[1], v[2], 1.0F);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos4dvMESA(const GLdouble *v)
+{
+ window_pos4f((GLfloat) v[0], (GLfloat) v[1],
+ (GLfloat) v[2], (GLfloat) v[3]);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos4fvMESA(const GLfloat *v)
+{
+ window_pos4f(v[0], v[1], v[2], v[3]);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos4ivMESA(const GLint *v)
+{
+ window_pos4f((GLfloat) v[0], (GLfloat) v[1],
+ (GLfloat) v[2], (GLfloat) v[3]);
+}
+
+void GLAPIENTRY
+_mesa_WindowPos4svMESA(const GLshort *v)
+{
+ window_pos4f(v[0], v[1], v[2], v[3]);
+}
+
+#endif
+
+#if 0
+
+/*
+ * OpenGL implementation of glWindowPos*MESA()
+ */
+void glWindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+ GLfloat fx, fy;
+
+ /* Push current matrix mode and viewport attributes */
+ glPushAttrib( GL_TRANSFORM_BIT | GL_VIEWPORT_BIT );
+
+ /* Setup projection parameters */
+ glMatrixMode( GL_PROJECTION );
+ glPushMatrix();
+ glLoadIdentity();
+ glMatrixMode( GL_MODELVIEW );
+ glPushMatrix();
+ glLoadIdentity();
+
+ glDepthRange( z, z );
+ glViewport( (int) x - 1, (int) y - 1, 2, 2 );
+
+ /* set the raster (window) position */
+ fx = x - (int) x;
+ fy = y - (int) y;
+ glRasterPos4f( fx, fy, 0.0, w );
+
+ /* restore matrices, viewport and matrix mode */
+ glPopMatrix();
+ glMatrixMode( GL_PROJECTION );
+ glPopMatrix();
+
+ glPopAttrib();
+}
+
+#endif
+
+
+/**********************************************************************/
+/** \name Initialization */
+/**********************************************************************/
+/*@{*/
+
+/**
+ * Initialize the context current raster position information.
+ *
+ * \param ctx GL context.
+ *
+ * Initialize the current raster position information in
+ * __GLcontextRec::Current, and adds the extension entry points to the
+ * dispatcher.
+ */
+void _mesa_init_rastpos( GLcontext * ctx )
+{
+ int i;
+
+ ASSIGN_4V( ctx->Current.RasterPos, 0.0, 0.0, 0.0, 1.0 );
+ ctx->Current.RasterDistance = 0.0;
+ ASSIGN_4V( ctx->Current.RasterColor, 1.0, 1.0, 1.0, 1.0 );
+ ctx->Current.RasterIndex = 1.0;
+ for (i=0; i<MAX_TEXTURE_UNITS; i++)
+ ASSIGN_4V( ctx->Current.RasterTexCoords[i], 0.0, 0.0, 0.0, 1.0 );
+ ctx->Current.RasterPosValid = GL_TRUE;
+}
+
+/*@}*/
diff --git a/nx-X11/extras/Mesa/src/mesa/main/rastpos.h b/nx-X11/extras/Mesa/src/mesa/main/rastpos.h
new file mode 100644
index 000000000..363f86ad8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/rastpos.h
@@ -0,0 +1,193 @@
+/**
+ * \file rastpos.h
+ * Raster position operations.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef RASTPOS_H
+#define RASTPOS_H
+
+
+#include "glheader.h"
+
+
+extern void GLAPIENTRY
+_mesa_RasterPos2d(GLdouble x, GLdouble y);
+
+extern void GLAPIENTRY
+_mesa_RasterPos2f(GLfloat x, GLfloat y);
+
+extern void GLAPIENTRY
+_mesa_RasterPos2i(GLint x, GLint y);
+
+extern void GLAPIENTRY
+_mesa_RasterPos2s(GLshort x, GLshort y);
+
+extern void GLAPIENTRY
+_mesa_RasterPos3d(GLdouble x, GLdouble y, GLdouble z);
+
+extern void GLAPIENTRY
+_mesa_RasterPos3f(GLfloat x, GLfloat y, GLfloat z);
+
+extern void GLAPIENTRY
+_mesa_RasterPos3i(GLint x, GLint y, GLint z);
+
+extern void GLAPIENTRY
+_mesa_RasterPos3s(GLshort x, GLshort y, GLshort z);
+
+extern void GLAPIENTRY
+_mesa_RasterPos4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+
+extern void GLAPIENTRY
+_mesa_RasterPos4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+
+extern void GLAPIENTRY
+_mesa_RasterPos4i(GLint x, GLint y, GLint z, GLint w);
+
+extern void GLAPIENTRY
+_mesa_RasterPos4s(GLshort x, GLshort y, GLshort z, GLshort w);
+
+extern void GLAPIENTRY
+_mesa_RasterPos2dv(const GLdouble *v);
+
+extern void GLAPIENTRY
+_mesa_RasterPos2fv(const GLfloat *v);
+
+extern void GLAPIENTRY
+_mesa_RasterPos2iv(const GLint *v);
+
+extern void GLAPIENTRY
+_mesa_RasterPos2sv(const GLshort *v);
+
+extern void GLAPIENTRY
+_mesa_RasterPos3dv(const GLdouble *v);
+
+extern void GLAPIENTRY
+_mesa_RasterPos3fv(const GLfloat *v);
+
+extern void GLAPIENTRY
+_mesa_RasterPos3iv(const GLint *v);
+
+extern void GLAPIENTRY
+_mesa_RasterPos3sv(const GLshort *v);
+
+extern void GLAPIENTRY
+_mesa_RasterPos4dv(const GLdouble *v);
+
+extern void GLAPIENTRY
+_mesa_RasterPos4fv(const GLfloat *v);
+
+extern void GLAPIENTRY
+_mesa_RasterPos4iv(const GLint *v);
+
+extern void GLAPIENTRY
+_mesa_RasterPos4sv(const GLshort *v);
+
+
+/**********************************************************************/
+/** \name GL_MESA_window_pos */
+/**********************************************************************/
+/*@{*/
+
+extern void GLAPIENTRY
+_mesa_WindowPos2dMESA(GLdouble x, GLdouble y);
+
+extern void GLAPIENTRY
+_mesa_WindowPos2fMESA(GLfloat x, GLfloat y);
+
+extern void GLAPIENTRY
+_mesa_WindowPos2iMESA(GLint x, GLint y);
+
+extern void GLAPIENTRY
+_mesa_WindowPos2sMESA(GLshort x, GLshort y);
+
+extern void GLAPIENTRY
+_mesa_WindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z);
+
+extern void GLAPIENTRY
+_mesa_WindowPos3fMESA(GLfloat x, GLfloat y, GLfloat z);
+
+extern void GLAPIENTRY
+_mesa_WindowPos3iMESA(GLint x, GLint y, GLint z);
+
+extern void GLAPIENTRY
+_mesa_WindowPos3sMESA(GLshort x, GLshort y, GLshort z);
+
+extern void GLAPIENTRY
+_mesa_WindowPos4dMESA(GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+
+extern void GLAPIENTRY
+_mesa_WindowPos4fMESA(GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+
+extern void GLAPIENTRY
+_mesa_WindowPos4iMESA(GLint x, GLint y, GLint z, GLint w);
+
+extern void GLAPIENTRY
+_mesa_WindowPos4sMESA(GLshort x, GLshort y, GLshort z, GLshort w);
+
+extern void GLAPIENTRY
+_mesa_WindowPos2dvMESA(const GLdouble *v);
+
+extern void GLAPIENTRY
+_mesa_WindowPos2fvMESA(const GLfloat *v);
+
+extern void GLAPIENTRY
+_mesa_WindowPos2ivMESA(const GLint *v);
+
+extern void GLAPIENTRY
+_mesa_WindowPos2svMESA(const GLshort *v);
+
+extern void GLAPIENTRY
+_mesa_WindowPos3dvMESA(const GLdouble *v);
+
+extern void GLAPIENTRY
+_mesa_WindowPos3fvMESA(const GLfloat *v);
+
+extern void GLAPIENTRY
+_mesa_WindowPos3ivMESA(const GLint *v);
+
+extern void GLAPIENTRY
+_mesa_WindowPos3svMESA(const GLshort *v);
+
+extern void GLAPIENTRY
+_mesa_WindowPos4dvMESA(const GLdouble *v);
+
+extern void GLAPIENTRY
+_mesa_WindowPos4fvMESA(const GLfloat *v);
+
+extern void GLAPIENTRY
+_mesa_WindowPos4ivMESA(const GLint *v);
+
+extern void GLAPIENTRY
+_mesa_WindowPos4svMESA(const GLshort *v);
+
+extern void
+_mesa_init_rastpos( GLcontext * ctx );
+
+/*@}*/
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/renderbuffer.c b/nx-X11/extras/Mesa/src/mesa/main/renderbuffer.c
new file mode 100644
index 000000000..42e94a31f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/renderbuffer.c
@@ -0,0 +1,1869 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * Functions for allocating/managing renderbuffers.
+ * Also, routines for reading/writing software-based renderbuffer data as
+ * ubytes, ushorts, uints, etc.
+ *
+ * The 'alpha8' renderbuffer is interesting. It's used to add a software-based
+ * alpha channel to RGB renderbuffers. This is done by wrapping the RGB
+ * renderbuffer with the alpha renderbuffer. We can do this because of the
+ * OO-nature of renderbuffers.
+ *
+ * Down the road we'll use this for run-time support of 8, 16 and 32-bit
+ * color channels. For example, Mesa may use 32-bit/float color channels
+ * internally (swrast) and use wrapper renderbuffers to convert 32-bit
+ * values down to 16 or 8-bit values for whatever kind of framebuffer we have.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "mtypes.h"
+#include "fbobject.h"
+#include "renderbuffer.h"
+
+
+#define COLOR_INDEX32 0x424243
+
+
+/*
+ * Routines for get/put values in common buffer formats follow.
+ * Someday add support for arbitrary row stride to make them more
+ * flexible.
+ */
+
+/**********************************************************************
+ * Functions for buffers of 1 X GLushort values.
+ * Typically stencil.
+ */
+
+static void *
+get_pointer_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint x, GLint y)
+{
+ if (!rb->Data)
+ return NULL;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ return (GLubyte *) rb->Data + y * rb->Width + x;
+}
+
+
+static void
+get_row_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const GLubyte *src = (const GLubyte *) rb->Data + y * rb->Width + x;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ _mesa_memcpy(values, src, count * sizeof(GLubyte));
+}
+
+
+static void
+get_values_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLubyte *dst = (GLubyte *) values;
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ const GLubyte *src = (GLubyte *) rb->Data + y[i] * rb->Width + x[i];
+ dst[i] = *src;
+ }
+}
+
+
+static void
+put_row_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ const GLubyte *src = (const GLubyte *) values;
+ GLubyte *dst = (GLubyte *) rb->Data + y * rb->Width + x;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = src[i];
+ }
+ }
+ }
+ else {
+ _mesa_memcpy(dst, values, count * sizeof(GLubyte));
+ }
+}
+
+
+static void
+put_mono_row_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ const GLubyte val = *((const GLubyte *) value);
+ GLubyte *dst = (GLubyte *) rb->Data + y * rb->Width + x;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = val;
+ }
+ }
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ dst[i] = val;
+ }
+ }
+}
+
+
+static void
+put_values_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[],
+ const void *values, const GLubyte *mask)
+{
+ const GLubyte *src = (const GLubyte *) values;
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->Width + x[i];
+ *dst = src[i];
+ }
+ }
+}
+
+
+static void
+put_mono_values_ubyte(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ const GLubyte val = *((const GLubyte *) value);
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLubyte *dst = (GLubyte *) rb->Data + y[i] * rb->Width + x[i];
+ *dst = val;
+ }
+ }
+}
+
+
+/**********************************************************************
+ * Functions for buffers of 1 X GLushort values.
+ * Typically depth/Z.
+ */
+
+static void *
+get_pointer_ushort(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint x, GLint y)
+{
+ if (!rb->Data)
+ return NULL;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ ASSERT(rb->Width > 0);
+ return (GLushort *) rb->Data + y * rb->Width + x;
+}
+
+
+static void
+get_row_ushort(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const void *src = rb->GetPointer(ctx, rb, x, y);
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ _mesa_memcpy(values, src, count * sizeof(GLushort));
+}
+
+
+static void
+get_values_ushort(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLushort *dst = (GLushort *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ for (i = 0; i < count; i++) {
+ const GLushort *src = (GLushort *) rb->Data + y[i] * rb->Width + x[i];
+ dst[i] = *src;
+ }
+}
+
+
+static void
+put_row_ushort(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ const GLushort *src = (const GLushort *) values;
+ GLushort *dst = (GLushort *) rb->Data + y * rb->Width + x;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = src[i];
+ }
+ }
+ }
+ else {
+ _mesa_memcpy(dst, src, count * sizeof(GLushort));
+ }
+}
+
+
+static void
+put_mono_row_ushort(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ const GLushort val = *((const GLushort *) value);
+ GLushort *dst = (GLushort *) rb->Data + y * rb->Width + x;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = val;
+ }
+ }
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ dst[i] = val;
+ }
+ }
+}
+
+
+static void
+put_values_ushort(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask)
+{
+ const GLushort *src = (const GLushort *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i];
+ *dst = src[i];
+ }
+ }
+}
+
+
+static void
+put_mono_values_ushort(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ const GLushort val = *((const GLushort *) value);
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i];
+ *dst = val;
+ }
+ }
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ GLushort *dst = (GLushort *) rb->Data + y[i] * rb->Width + x[i];
+ *dst = val;
+ }
+ }
+}
+
+
+/**********************************************************************
+ * Functions for buffers of 1 X GLuint values.
+ * Typically depth/Z or color index.
+ */
+
+static void *
+get_pointer_uint(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint x, GLint y)
+{
+ if (!rb->Data)
+ return NULL;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ return (GLuint *) rb->Data + y * rb->Width + x;
+}
+
+
+static void
+get_row_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const void *src = rb->GetPointer(ctx, rb, x, y);
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ _mesa_memcpy(values, src, count * sizeof(GLuint));
+}
+
+
+static void
+get_values_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLuint *dst = (GLuint *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ for (i = 0; i < count; i++) {
+ const GLuint *src = (GLuint *) rb->Data + y[i] * rb->Width + x[i];
+ dst[i] = *src;
+ }
+}
+
+
+static void
+put_row_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ const GLuint *src = (const GLuint *) values;
+ GLuint *dst = (GLuint *) rb->Data + y * rb->Width + x;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = src[i];
+ }
+ }
+ }
+ else {
+ _mesa_memcpy(dst, src, count * sizeof(GLuint));
+ }
+}
+
+
+static void
+put_mono_row_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ const GLuint val = *((const GLuint *) value);
+ GLuint *dst = (GLuint *) rb->Data + y * rb->Width + x;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i] = val;
+ }
+ }
+}
+
+
+static void
+put_values_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask)
+{
+ const GLuint *src = (const GLuint *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLuint *dst = (GLuint *) rb->Data + y[i] * rb->Width + x[i];
+ *dst = src[i];
+ }
+ }
+}
+
+
+static void
+put_mono_values_uint(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *value,
+ const GLubyte *mask)
+{
+ const GLuint val = *((const GLuint *) value);
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLuint *dst = (GLuint *) rb->Data + y[i] * rb->Width + x[i];
+ *dst = val;
+ }
+ }
+}
+
+
+/**********************************************************************
+ * Functions for buffers of 3 X GLubyte (or GLbyte) values.
+ * Typically color buffers.
+ * NOTE: the incoming and outgoing colors are RGBA! We ignore incoming
+ * alpha values and return 255 for outgoing alpha values.
+ */
+
+static void *
+get_pointer_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint x, GLint y)
+{
+ /* No direct access since this buffer is RGB but caller will be
+ * treating it as if it were RGBA.
+ */
+ return NULL;
+}
+
+
+static void
+get_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const GLubyte *src = (const GLubyte *) rb->Data + 3 * (y * rb->Width + x);
+ GLubyte *dst = (GLubyte *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ dst[i * 4 + 0] = src[i * 3 + 0];
+ dst[i * 4 + 1] = src[i * 3 + 1];
+ dst[i * 4 + 2] = src[i * 3 + 2];
+ dst[i * 4 + 3] = 255;
+ }
+}
+
+
+static void
+get_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLubyte *dst = (GLubyte *) values;
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ const GLubyte *src
+ = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]);
+ dst[i * 4 + 0] = src[0];
+ dst[i * 4 + 1] = src[1];
+ dst[i * 4 + 2] = src[2];
+ dst[i * 4 + 3] = 255;
+ }
+}
+
+
+static void
+put_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ /* note: incoming values are RGB+A! */
+ const GLubyte *src = (const GLubyte *) values;
+ GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x);
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i * 3 + 0] = src[i * 4 + 0];
+ dst[i * 3 + 1] = src[i * 4 + 1];
+ dst[i * 3 + 2] = src[i * 4 + 2];
+ }
+ }
+}
+
+
+static void
+put_row_rgb_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ /* note: incoming values are RGB+A! */
+ const GLubyte *src = (const GLubyte *) values;
+ GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x);
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i * 3 + 0] = src[i * 3 + 0];
+ dst[i * 3 + 1] = src[i * 3 + 1];
+ dst[i * 3 + 2] = src[i * 3 + 2];
+ }
+ }
+}
+
+
+static void
+put_mono_row_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ /* note: incoming value is RGB+A! */
+ const GLubyte val0 = ((const GLubyte *) value)[0];
+ const GLubyte val1 = ((const GLubyte *) value)[1];
+ const GLubyte val2 = ((const GLubyte *) value)[2];
+ GLubyte *dst = (GLubyte *) rb->Data + 3 * (y * rb->Width + x);
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ if (!mask && val0 == val1 && val1 == val2) {
+ /* optimized case */
+ _mesa_memset(dst, val0, 3 * count);
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i * 3 + 0] = val0;
+ dst[i * 3 + 1] = val1;
+ dst[i * 3 + 2] = val2;
+ }
+ }
+ }
+}
+
+
+static void
+put_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask)
+{
+ /* note: incoming values are RGB+A! */
+ const GLubyte *src = (const GLubyte *) values;
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]);
+ dst[0] = src[i * 4 + 0];
+ dst[1] = src[i * 4 + 1];
+ dst[2] = src[i * 4 + 2];
+ }
+ }
+}
+
+
+static void
+put_mono_values_ubyte3(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ /* note: incoming value is RGB+A! */
+ const GLubyte val0 = ((const GLubyte *) value)[0];
+ const GLubyte val1 = ((const GLubyte *) value)[1];
+ const GLubyte val2 = ((const GLubyte *) value)[2];
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLubyte *dst = (GLubyte *) rb->Data + 3 * (y[i] * rb->Width + x[i]);
+ dst[0] = val0;
+ dst[1] = val1;
+ dst[2] = val2;
+ }
+ }
+}
+
+
+/**********************************************************************
+ * Functions for buffers of 4 X GLubyte (or GLbyte) values.
+ * Typically color buffers.
+ */
+
+static void *
+get_pointer_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint x, GLint y)
+{
+ if (!rb->Data)
+ return NULL;
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ return (GLubyte *) rb->Data + 4 * (y * rb->Width + x);
+}
+
+
+static void
+get_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const GLbyte *src = (const GLbyte *) rb->Data + 4 * (y * rb->Width + x);
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ _mesa_memcpy(values, src, 4 * count * sizeof(GLbyte));
+}
+
+
+static void
+get_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ /* treat 4*GLubyte as 1*GLuint */
+ GLuint *dst = (GLuint *) values;
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ const GLuint *src = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]);
+ dst[i] = *src;
+ }
+}
+
+
+static void
+put_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ /* treat 4*GLubyte as 1*GLuint */
+ const GLuint *src = (const GLuint *) values;
+ GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x);
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = src[i];
+ }
+ }
+ }
+ else {
+ _mesa_memcpy(dst, src, 4 * count * sizeof(GLubyte));
+ }
+}
+
+
+static void
+put_row_rgb_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ /* Store RGB values in RGBA buffer */
+ const GLubyte *src = (const GLubyte *) values;
+ GLubyte *dst = (GLubyte *) rb->Data + 4 * (y * rb->Width + x);
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i * 4 + 0] = src[i * 3 + 0];
+ dst[i * 4 + 1] = src[i * 3 + 1];
+ dst[i * 4 + 2] = src[i * 3 + 2];
+ dst[i * 4 + 3] = 0xff;
+ }
+ }
+}
+
+
+static void
+put_mono_row_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ /* treat 4*GLubyte as 1*GLuint */
+ const GLuint val = *((const GLuint *) value);
+ GLuint *dst = (GLuint *) rb->Data + (y * rb->Width + x);
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ if (!mask && val == 0) {
+ /* common case */
+ _mesa_bzero(dst, count * 4 * sizeof(GLubyte));
+ }
+ else {
+ /* general case */
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = val;
+ }
+ }
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ dst[i] = val;
+ }
+ }
+ }
+}
+
+
+static void
+put_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask)
+{
+ /* treat 4*GLubyte as 1*GLuint */
+ const GLuint *src = (const GLuint *) values;
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]);
+ *dst = src[i];
+ }
+ }
+}
+
+
+static void
+put_mono_values_ubyte4(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ /* treat 4*GLubyte as 1*GLuint */
+ const GLuint val = *((const GLuint *) value);
+ GLuint i;
+ assert(rb->DataType == GL_UNSIGNED_BYTE);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLuint *dst = (GLuint *) rb->Data + (y[i] * rb->Width + x[i]);
+ *dst = val;
+ }
+ }
+}
+
+
+/**********************************************************************
+ * Functions for buffers of 4 X GLushort (or GLshort) values.
+ * Typically accum buffer.
+ */
+
+static void *
+get_pointer_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint x, GLint y)
+{
+ if (!rb->Data)
+ return NULL;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ return (GLushort *) rb->Data + 4 * (y * rb->Width + x);
+}
+
+
+static void
+get_row_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const GLshort *src = (const GLshort *) rb->Data + 4 * (y * rb->Width + x);
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ _mesa_memcpy(values, src, 4 * count * sizeof(GLshort));
+}
+
+
+static void
+get_values_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLushort *dst = (GLushort *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ for (i = 0; i < count; i++) {
+ const GLushort *src
+ = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]);
+ dst[i] = *src;
+ }
+}
+
+
+static void
+put_row_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ const GLushort *src = (const GLushort *) values;
+ GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x);
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i * 4 + 0] = src[i * 4 + 0];
+ dst[i * 4 + 1] = src[i * 4 + 1];
+ dst[i * 4 + 2] = src[i * 4 + 2];
+ dst[i * 4 + 3] = src[i * 4 + 3];
+ }
+ }
+ }
+ else {
+ _mesa_memcpy(dst, src, 4 * count * sizeof(GLushort));
+ }
+}
+
+
+static void
+put_row_rgb_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ /* Put RGB values in RGBA buffer */
+ const GLushort *src = (const GLushort *) values;
+ GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x);
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i * 4 + 0] = src[i * 3 + 0];
+ dst[i * 4 + 1] = src[i * 3 + 1];
+ dst[i * 4 + 2] = src[i * 3 + 2];
+ dst[i * 4 + 3] = 0xffff;
+ }
+ }
+ }
+ else {
+ _mesa_memcpy(dst, src, 4 * count * sizeof(GLushort));
+ }
+}
+
+
+static void
+put_mono_row_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ const GLushort val0 = ((const GLushort *) value)[0];
+ const GLushort val1 = ((const GLushort *) value)[1];
+ const GLushort val2 = ((const GLushort *) value)[2];
+ const GLushort val3 = ((const GLushort *) value)[3];
+ GLushort *dst = (GLushort *) rb->Data + 4 * (y * rb->Width + x);
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ if (!mask && val0 == 0 && val1 == 0 && val2 == 0 && val3 == 0) {
+ /* common case for clearing accum buffer */
+ _mesa_bzero(dst, count * 4 * sizeof(GLushort));
+ }
+ else {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i * 4 + 0] = val0;
+ dst[i * 4 + 1] = val1;
+ dst[i * 4 + 2] = val2;
+ dst[i * 4 + 3] = val3;
+ }
+ }
+ }
+}
+
+
+static void
+put_values_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask)
+{
+ const GLushort *src = (const GLushort *) values;
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLushort *dst = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]);
+ dst[0] = src[i * 4 + 0];
+ dst[1] = src[i * 4 + 1];
+ dst[2] = src[i * 4 + 2];
+ dst[3] = src[i * 4 + 3];
+ }
+ }
+}
+
+
+static void
+put_mono_values_ushort4(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ const GLushort val0 = ((const GLushort *) value)[0];
+ const GLushort val1 = ((const GLushort *) value)[1];
+ const GLushort val2 = ((const GLushort *) value)[2];
+ const GLushort val3 = ((const GLushort *) value)[3];
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLushort *dst = (GLushort *) rb->Data + 4 * (y[i] * rb->Width + x[i]);
+ dst[0] = val0;
+ dst[1] = val1;
+ dst[2] = val2;
+ dst[3] = val3;
+ }
+ }
+}
+
+
+
+/**
+ * This is a software fallback for the gl_renderbuffer->AllocStorage
+ * function.
+ * Device drivers will typically override this function for the buffers
+ * which it manages (typically color buffers, Z and stencil).
+ * Other buffers (like software accumulation and aux buffers) which the driver
+ * doesn't manage can be handled with this function.
+ *
+ * This one multi-purpose function can allocate stencil, depth, accum, color
+ * or color-index buffers!
+ *
+ * This function also plugs in the appropriate GetPointer, Get/PutRow and
+ * Get/PutValues functions.
+ */
+static GLboolean
+soft_renderbuffer_storage(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ GLuint pixelSize;
+
+ switch (internalFormat) {
+ 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:
+ rb->_BaseFormat = GL_RGB;
+ rb->DataType = GL_UNSIGNED_BYTE;
+ rb->GetPointer = get_pointer_ubyte3;
+ rb->GetRow = get_row_ubyte3;
+ rb->GetValues = get_values_ubyte3;
+ rb->PutRow = put_row_ubyte3;
+ rb->PutRowRGB = put_row_rgb_ubyte3;
+ rb->PutMonoRow = put_mono_row_ubyte3;
+ rb->PutValues = put_values_ubyte3;
+ rb->PutMonoValues = put_mono_values_ubyte3;
+ rb->ComponentSizes[0] = 8 * sizeof(GLubyte);
+ rb->ComponentSizes[1] = 8 * sizeof(GLubyte);
+ rb->ComponentSizes[2] = 8 * sizeof(GLubyte);
+ rb->ComponentSizes[3] = 0;
+ pixelSize = 3 * sizeof(GLchan);
+ break;
+ case GL_RGBA:
+ case GL_RGBA2:
+ case GL_RGBA4:
+ case GL_RGB5_A1:
+ case GL_RGBA8:
+ rb->_BaseFormat = GL_RGBA;
+ rb->DataType = GL_UNSIGNED_BYTE;
+ rb->GetPointer = get_pointer_ubyte4;
+ rb->GetRow = get_row_ubyte4;
+ rb->GetValues = get_values_ubyte4;
+ rb->PutRow = put_row_ubyte4;
+ rb->PutRowRGB = put_row_rgb_ubyte4;
+ rb->PutMonoRow = put_mono_row_ubyte4;
+ rb->PutValues = put_values_ubyte4;
+ rb->PutMonoValues = put_mono_values_ubyte4;
+ rb->ComponentSizes[0] = 8 * sizeof(GLubyte);
+ rb->ComponentSizes[1] = 8 * sizeof(GLubyte);
+ rb->ComponentSizes[2] = 8 * sizeof(GLubyte);
+ rb->ComponentSizes[3] = 8 * sizeof(GLubyte);
+ pixelSize = 4 * sizeof(GLubyte);
+ break;
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ rb->_BaseFormat = GL_RGBA;
+ rb->DataType = GL_UNSIGNED_SHORT;
+ rb->GetPointer = get_pointer_ushort4;
+ rb->GetRow = get_row_ushort4;
+ rb->GetValues = get_values_ushort4;
+ rb->PutRow = put_row_ushort4;
+ rb->PutRowRGB = put_row_rgb_ushort4;
+ rb->PutMonoRow = put_mono_row_ushort4;
+ rb->PutValues = put_values_ushort4;
+ rb->PutMonoValues = put_mono_values_ushort4;
+ rb->ComponentSizes[0] = 8 * sizeof(GLushort);
+ rb->ComponentSizes[1] = 8 * sizeof(GLushort);
+ rb->ComponentSizes[2] = 8 * sizeof(GLushort);
+ rb->ComponentSizes[3] = 8 * sizeof(GLushort);
+ pixelSize = 4 * sizeof(GLushort);
+ break;
+#if 00
+ case ALPHA8:
+ rb->_BaseFormat = GL_RGBA; /* Yes, not GL_ALPHA! */
+ rb->DataType = GL_UNSIGNED_BYTE;
+ rb->GetPointer = get_pointer_alpha8;
+ rb->GetRow = get_row_alpha8;
+ rb->GetValues = get_values_alpha8;
+ rb->PutRow = put_row_alpha8;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_alpha8;
+ rb->PutValues = put_values_alpha8;
+ rb->PutMonoValues = put_mono_values_alpha8;
+ rb->ComponentSizes[0] = 0; /*red*/
+ rb->ComponentSizes[1] = 0; /*green*/
+ rb->ComponentSizes[2] = 0; /*blue*/
+ rb->ComponentSizes[3] = 8 * sizeof(GLubyte);
+ pixelSize = sizeof(GLubyte);
+ break;
+#endif
+ case GL_STENCIL_INDEX:
+ case GL_STENCIL_INDEX1_EXT:
+ case GL_STENCIL_INDEX4_EXT:
+ case GL_STENCIL_INDEX8_EXT:
+ rb->_BaseFormat = GL_STENCIL_INDEX;
+ rb->DataType = GL_UNSIGNED_BYTE;
+ rb->GetPointer = get_pointer_ubyte;
+ rb->GetRow = get_row_ubyte;
+ rb->GetValues = get_values_ubyte;
+ rb->PutRow = put_row_ubyte;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_ubyte;
+ rb->PutValues = put_values_ubyte;
+ rb->PutMonoValues = put_mono_values_ubyte;
+ rb->ComponentSizes[0] = 8 * sizeof(GLubyte);
+ pixelSize = sizeof(GLubyte);
+ break;
+ case GL_STENCIL_INDEX16_EXT:
+ rb->_BaseFormat = GL_STENCIL_INDEX;
+ rb->DataType = GL_UNSIGNED_SHORT;
+ rb->GetPointer = get_pointer_ushort;
+ rb->GetRow = get_row_ushort;
+ rb->GetValues = get_values_ushort;
+ rb->PutRow = put_row_ushort;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_ushort;
+ rb->PutValues = put_values_ushort;
+ rb->PutMonoValues = put_mono_values_ushort;
+ rb->ComponentSizes[0] = 8 * sizeof(GLushort);
+ pixelSize = sizeof(GLushort);
+ break;
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT16:
+ rb->_BaseFormat = GL_DEPTH_COMPONENT;
+ rb->DataType = GL_UNSIGNED_SHORT;
+ rb->GetPointer = get_pointer_ushort;
+ rb->GetRow = get_row_ushort;
+ rb->GetValues = get_values_ushort;
+ rb->PutRow = put_row_ushort;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_ushort;
+ rb->PutValues = put_values_ushort;
+ rb->PutMonoValues = put_mono_values_ushort;
+ rb->ComponentSizes[0] = 8 * sizeof(GLushort);
+ pixelSize = sizeof(GLushort);
+ break;
+ case GL_DEPTH_COMPONENT24:
+ case GL_DEPTH_COMPONENT32:
+ rb->_BaseFormat = GL_DEPTH_COMPONENT;
+ rb->DataType = GL_UNSIGNED_INT;
+ rb->GetPointer = get_pointer_uint;
+ rb->GetRow = get_row_uint;
+ rb->GetValues = get_values_uint;
+ rb->PutRow = put_row_uint;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_uint;
+ rb->PutValues = put_values_uint;
+ rb->PutMonoValues = put_mono_values_uint;
+ rb->ComponentSizes[0] = 8 * sizeof(GLuint);
+ pixelSize = sizeof(GLuint);
+ break;
+ case GL_COLOR_INDEX8_EXT:
+ rb->_BaseFormat = GL_COLOR_INDEX;
+ rb->DataType = GL_UNSIGNED_BYTE;
+ rb->GetPointer = get_pointer_ubyte;
+ rb->GetRow = get_row_ubyte;
+ rb->GetValues = get_values_ubyte;
+ rb->PutRow = put_row_ubyte;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_ubyte;
+ rb->PutValues = put_values_ubyte;
+ rb->PutMonoValues = put_mono_values_ubyte;
+ rb->ComponentSizes[0] = 8 * sizeof(GLubyte);
+ pixelSize = sizeof(GLubyte);
+ break;
+ case GL_COLOR_INDEX16_EXT:
+ rb->_BaseFormat = GL_COLOR_INDEX;
+ rb->DataType = GL_UNSIGNED_SHORT;
+ rb->GetPointer = get_pointer_ushort;
+ rb->GetRow = get_row_ushort;
+ rb->GetValues = get_values_ushort;
+ rb->PutRow = put_row_ushort;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_ushort;
+ rb->PutValues = put_values_ushort;
+ rb->PutMonoValues = put_mono_values_ushort;
+ rb->ComponentSizes[0] = 8 * sizeof(GLushort);
+ pixelSize = sizeof(GLushort);
+ break;
+ case COLOR_INDEX32:
+ rb->_BaseFormat = GL_COLOR_INDEX;
+ rb->DataType = GL_UNSIGNED_INT;
+ rb->GetPointer = get_pointer_uint;
+ rb->GetRow = get_row_uint;
+ rb->GetValues = get_values_uint;
+ rb->PutRow = put_row_uint;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = put_mono_row_uint;
+ rb->PutValues = put_values_uint;
+ rb->PutMonoValues = put_mono_values_uint;
+ rb->ComponentSizes[0] = 8 * sizeof(GLuint);
+ pixelSize = sizeof(GLuint);
+ break;
+ default:
+ _mesa_problem(ctx, "Bad internalFormat in soft_renderbuffer_storage");
+ return GL_FALSE;
+ }
+
+ ASSERT(rb->DataType);
+ ASSERT(rb->GetPointer);
+ ASSERT(rb->GetRow);
+ ASSERT(rb->GetValues);
+ ASSERT(rb->PutRow);
+ ASSERT(rb->PutMonoRow);
+ ASSERT(rb->PutValues);
+ ASSERT(rb->PutMonoValues);
+ ASSERT(rb->ComponentSizes[0] > 0);
+
+ /* free old buffer storage */
+ if (rb->Data)
+ _mesa_free(rb->Data);
+
+ /* allocate new buffer storage */
+ rb->Data = _mesa_malloc(width * height * pixelSize);
+ if (rb->Data == NULL) {
+ rb->Width = 0;
+ rb->Height = 0;
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "software renderbuffer allocation");
+ return GL_FALSE;
+ }
+
+ rb->Width = width;
+ rb->Height = height;
+ rb->InternalFormat = internalFormat;
+
+ return GL_TRUE;
+}
+
+
+/**********************************************************************/
+/**********************************************************************/
+/**********************************************************************/
+
+
+/**
+ * Here we utilize the gl_renderbuffer->Wrapper field to put an alpha
+ * buffer wrapper around an existing RGB renderbuffer (hw or sw).
+ *
+ * When PutRow is called (for example), we store the alpha values in
+ * this buffer, then pass on the PutRow call to the wrapped RGB
+ * buffer.
+ */
+
+
+static GLboolean
+alloc_storage_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb,
+ GLenum internalFormat, GLuint width, GLuint height)
+{
+ ASSERT(arb != arb->Wrapped);
+
+ /* first, pass the call to the wrapped RGB buffer */
+ if (!arb->Wrapped->AllocStorage(ctx, arb->Wrapped, internalFormat,
+ width, height)) {
+ return GL_FALSE;
+ }
+
+ /* next, resize my alpha buffer */
+ if (arb->Data) {
+ _mesa_free(arb->Data);
+ }
+
+ arb->Data = _mesa_malloc(width * height * sizeof(GLubyte));
+ if (arb->Data == NULL) {
+ arb->Width = 0;
+ arb->Height = 0;
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "software alpha buffer allocation");
+ return GL_FALSE;
+ }
+
+ arb->Width = width;
+ arb->Height = height;
+ arb->InternalFormat = internalFormat;
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Delete an alpha_renderbuffer object, as well as the wrapped RGB buffer.
+ */
+static void
+delete_renderbuffer_alpha8(struct gl_renderbuffer *arb)
+{
+ if (arb->Data) {
+ _mesa_free(arb->Data);
+ }
+ ASSERT(arb->Wrapped);
+ ASSERT(arb != arb->Wrapped);
+ arb->Wrapped->Delete(arb->Wrapped);
+ arb->Wrapped = NULL;
+ _mesa_free(arb);
+}
+
+
+static void *
+get_pointer_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb,
+ GLint x, GLint y)
+{
+ return NULL; /* don't allow direct access! */
+}
+
+
+static void
+get_row_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ /* NOTE: 'values' is RGBA format! */
+ const GLubyte *src = (const GLubyte *) arb->Data + y * arb->Width + x;
+ GLubyte *dst = (GLubyte *) values;
+ GLuint i;
+ ASSERT(arb != arb->Wrapped);
+ ASSERT(arb->DataType == GL_UNSIGNED_BYTE);
+ /* first, pass the call to the wrapped RGB buffer */
+ arb->Wrapped->GetRow(ctx, arb->Wrapped, count, x, y, values);
+ /* second, fill in alpha values from this buffer! */
+ for (i = 0; i < count; i++) {
+ dst[i * 4 + 3] = src[i];
+ }
+}
+
+
+static void
+get_values_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ GLubyte *dst = (GLubyte *) values;
+ GLuint i;
+ ASSERT(arb != arb->Wrapped);
+ ASSERT(arb->DataType == GL_UNSIGNED_BYTE);
+ /* first, pass the call to the wrapped RGB buffer */
+ arb->Wrapped->GetValues(ctx, arb->Wrapped, count, x, y, values);
+ /* second, fill in alpha values from this buffer! */
+ for (i = 0; i < count; i++) {
+ const GLubyte *src = (GLubyte *) arb->Data + y[i] * arb->Width + x[i];
+ dst[i * 4 + 3] = *src;
+ }
+}
+
+
+static void
+put_row_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ const GLubyte *src = (const GLubyte *) values;
+ GLubyte *dst = (GLubyte *) arb->Data + y * arb->Width + x;
+ GLuint i;
+ ASSERT(arb != arb->Wrapped);
+ ASSERT(arb->DataType == GL_UNSIGNED_BYTE);
+ /* first, pass the call to the wrapped RGB buffer */
+ arb->Wrapped->PutRow(ctx, arb->Wrapped, count, x, y, values, mask);
+ /* second, store alpha in our buffer */
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i] = src[i * 4 + 3];
+ }
+ }
+}
+
+
+static void
+put_row_rgb_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ const GLubyte *src = (const GLubyte *) values;
+ GLubyte *dst = (GLubyte *) arb->Data + y * arb->Width + x;
+ GLuint i;
+ ASSERT(arb != arb->Wrapped);
+ ASSERT(arb->DataType == GL_UNSIGNED_BYTE);
+ /* first, pass the call to the wrapped RGB buffer */
+ arb->Wrapped->PutRowRGB(ctx, arb->Wrapped, count, x, y, values, mask);
+ /* second, store alpha in our buffer */
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ dst[i] = src[i * 4 + 3];
+ }
+ }
+}
+
+
+static void
+put_mono_row_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ const GLubyte val = ((const GLubyte *) value)[3];
+ GLubyte *dst = (GLubyte *) arb->Data + y * arb->Width + x;
+ ASSERT(arb != arb->Wrapped);
+ ASSERT(arb->DataType == GL_UNSIGNED_BYTE);
+ /* first, pass the call to the wrapped RGB buffer */
+ arb->Wrapped->PutMonoRow(ctx, arb->Wrapped, count, x, y, value, mask);
+ /* second, store alpha in our buffer */
+ if (mask) {
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ dst[i] = val;
+ }
+ }
+ }
+ else {
+ _mesa_memset(dst, val, count);
+ }
+}
+
+
+static void
+put_values_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb, GLuint count,
+ const GLint x[], const GLint y[],
+ const void *values, const GLubyte *mask)
+{
+ const GLubyte *src = (const GLubyte *) values;
+ GLuint i;
+ ASSERT(arb != arb->Wrapped);
+ ASSERT(arb->DataType == GL_UNSIGNED_BYTE);
+ /* first, pass the call to the wrapped RGB buffer */
+ arb->Wrapped->PutValues(ctx, arb->Wrapped, count, x, y, values, mask);
+ /* second, store alpha in our buffer */
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLubyte *dst = (GLubyte *) arb->Data + y[i] * arb->Width + x[i];
+ *dst = src[i * 4 + 3];
+ }
+ }
+}
+
+
+static void
+put_mono_values_alpha8(GLcontext *ctx, struct gl_renderbuffer *arb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ const GLubyte val = ((const GLubyte *) value)[3];
+ GLuint i;
+ ASSERT(arb != arb->Wrapped);
+ ASSERT(arb->DataType == GL_UNSIGNED_BYTE);
+ /* first, pass the call to the wrapped RGB buffer */
+ arb->Wrapped->PutValues(ctx, arb->Wrapped, count, x, y, value, mask);
+ /* second, store alpha in our buffer */
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ GLubyte *dst = (GLubyte *) arb->Data + y[i] * arb->Width + x[i];
+ *dst = val;
+ }
+ }
+}
+
+
+
+/**********************************************************************/
+/**********************************************************************/
+/**********************************************************************/
+
+
+/**
+ * Default GetPointer routine. Always return NULL to indicate that
+ * direct buffer access is not supported.
+ */
+static void *
+nop_get_pointer(GLcontext *ctx, struct gl_renderbuffer *rb, GLint x, GLint y)
+{
+ return NULL;
+}
+
+
+/**
+ * Initialize the fields of a gl_renderbuffer to default values.
+ */
+void
+_mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name)
+{
+ rb->Name = name;
+ rb->RefCount = 1;
+ rb->Delete = _mesa_delete_renderbuffer;
+
+ /* The rest of these should be set later by the caller of this function or
+ * the AllocStorage method:
+ */
+ rb->AllocStorage = NULL;
+
+ rb->Width = 0;
+ rb->Height = 0;
+ rb->InternalFormat = GL_NONE;
+ rb->_BaseFormat = GL_NONE;
+ rb->DataType = GL_NONE;
+ rb->ComponentSizes[0] = 0;
+ rb->ComponentSizes[1] = 0;
+ rb->ComponentSizes[2] = 0;
+ rb->ComponentSizes[3] = 0;
+ rb->Data = NULL;
+
+ /* Point back to ourself so that we don't have to check for Wrapped==NULL
+ * all over the drivers.
+ */
+ rb->Wrapped = rb;
+
+ rb->GetPointer = nop_get_pointer;
+ rb->GetRow = NULL;
+ rb->GetValues = NULL;
+ rb->PutRow = NULL;
+ rb->PutRowRGB = NULL;
+ rb->PutMonoRow = NULL;
+ rb->PutValues = NULL;
+ rb->PutMonoValues = NULL;
+}
+
+
+/**
+ * Allocate a new gl_renderbuffer object. This can be used for user-created
+ * renderbuffers or window-system renderbuffers.
+ */
+struct gl_renderbuffer *
+_mesa_new_renderbuffer(GLcontext *ctx, GLuint name)
+{
+ struct gl_renderbuffer *rb = CALLOC_STRUCT(gl_renderbuffer);
+ if (rb) {
+ _mesa_init_renderbuffer(rb, name);
+ }
+ return rb;
+}
+
+
+/**
+ * Delete a gl_framebuffer.
+ * This is the default function for framebuffer->Delete().
+ */
+void
+_mesa_delete_renderbuffer(struct gl_renderbuffer *rb)
+{
+ if (rb->Data) {
+ _mesa_free(rb->Data);
+ }
+ _mesa_free(rb);
+}
+
+
+/**
+ * Allocate a software-based renderbuffer. This is called via the
+ * ctx->Driver.NewRenderbuffer() function when the user creates a new
+ * renderbuffer.
+ */
+struct gl_renderbuffer *
+_mesa_new_soft_renderbuffer(GLcontext *ctx, GLuint name)
+{
+ struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name);
+ if (rb) {
+ rb->AllocStorage = soft_renderbuffer_storage;
+ /* Normally, one would setup the PutRow, GetRow, etc functions here.
+ * But we're doing that in the soft_renderbuffer_storage() function
+ * instead.
+ */
+ }
+ return rb;
+}
+
+
+/**
+ * Add software-based color renderbuffers to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ */
+GLboolean
+_mesa_add_color_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint rgbBits, GLuint alphaBits,
+ GLboolean frontLeft, GLboolean backLeft,
+ GLboolean frontRight, GLboolean backRight)
+{
+ GLuint b;
+
+ if (rgbBits > 16 || alphaBits > 16) {
+ _mesa_problem(ctx,
+ "Unsupported bit depth in _mesa_add_color_renderbuffers");
+ return GL_FALSE;
+ }
+
+ assert(MAX_COLOR_ATTACHMENTS >= 4);
+
+ for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) {
+ struct gl_renderbuffer *rb;
+
+ if (b == BUFFER_FRONT_LEFT && !frontLeft)
+ continue;
+ else if (b == BUFFER_BACK_LEFT && !backLeft)
+ continue;
+ else if (b == BUFFER_FRONT_RIGHT && !frontRight)
+ continue;
+ else if (b == BUFFER_BACK_RIGHT && !backRight)
+ continue;
+
+ assert(fb->Attachment[b].Renderbuffer == NULL);
+
+ rb = _mesa_new_renderbuffer(ctx, 0);
+ if (!rb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating color buffer");
+ return GL_FALSE;
+ }
+
+ if (rgbBits <= 8) {
+ if (alphaBits)
+ rb->InternalFormat = GL_RGBA8;
+ else
+ rb->InternalFormat = GL_RGB8;
+ }
+ else {
+ assert(rgbBits <= 16);
+ if (alphaBits)
+ rb->InternalFormat = GL_RGBA16;
+ else
+ rb->InternalFormat = GL_RGBA16; /* don't really have RGB16 yet */
+ }
+
+ rb->AllocStorage = soft_renderbuffer_storage;
+ _mesa_add_renderbuffer(fb, b, rb);
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Add software-based color index renderbuffers to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ */
+GLboolean
+_mesa_add_color_index_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint indexBits,
+ GLboolean frontLeft, GLboolean backLeft,
+ GLboolean frontRight, GLboolean backRight)
+{
+ GLuint b;
+
+ if (indexBits > 8) {
+ _mesa_problem(ctx,
+ "Unsupported bit depth in _mesa_add_color_renderbuffers");
+ return GL_FALSE;
+ }
+
+ assert(MAX_COLOR_ATTACHMENTS >= 4);
+
+ for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) {
+ struct gl_renderbuffer *rb;
+
+ if (b == BUFFER_FRONT_LEFT && !frontLeft)
+ continue;
+ else if (b == BUFFER_BACK_LEFT && !backLeft)
+ continue;
+ else if (b == BUFFER_FRONT_RIGHT && !frontRight)
+ continue;
+ else if (b == BUFFER_BACK_RIGHT && !backRight)
+ continue;
+
+ assert(fb->Attachment[b].Renderbuffer == NULL);
+
+ rb = _mesa_new_renderbuffer(ctx, 0);
+ if (!rb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating color buffer");
+ return GL_FALSE;
+ }
+
+ if (indexBits <= 8) {
+ /* only support GLuint for now */
+ /*rb->InternalFormat = GL_COLOR_INDEX8_EXT;*/
+ rb->InternalFormat = COLOR_INDEX32;
+ }
+ else {
+ rb->InternalFormat = COLOR_INDEX32;
+ }
+ rb->AllocStorage = soft_renderbuffer_storage;
+ _mesa_add_renderbuffer(fb, b, rb);
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Add software-based alpha renderbuffers to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ */
+GLboolean
+_mesa_add_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint alphaBits,
+ GLboolean frontLeft, GLboolean backLeft,
+ GLboolean frontRight, GLboolean backRight)
+{
+ GLuint b;
+
+ /* for window system framebuffers only! */
+ assert(fb->Name == 0);
+
+ if (alphaBits > 8) {
+ _mesa_problem(ctx,
+ "Unsupported bit depth in _mesa_add_alpha_renderbuffers");
+ return GL_FALSE;
+ }
+
+ assert(MAX_COLOR_ATTACHMENTS >= 4);
+
+ /* Wrap each of the RGB color buffers with an alpha renderbuffer.
+ */
+ for (b = BUFFER_FRONT_LEFT; b <= BUFFER_BACK_RIGHT; b++) {
+ struct gl_renderbuffer *arb;
+
+ if (b == BUFFER_FRONT_LEFT && !frontLeft)
+ continue;
+ else if (b == BUFFER_BACK_LEFT && !backLeft)
+ continue;
+ else if (b == BUFFER_FRONT_RIGHT && !frontRight)
+ continue;
+ else if (b == BUFFER_BACK_RIGHT && !backRight)
+ continue;
+
+ /* the RGB buffer to wrap must already exist!! */
+ assert(fb->Attachment[b].Renderbuffer);
+
+ /* only GLubyte supported for now */
+ assert(fb->Attachment[b].Renderbuffer->DataType == GL_UNSIGNED_BYTE);
+
+ /* allocate alpha renderbuffer */
+ arb = _mesa_new_renderbuffer(ctx, 0);
+ if (!arb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating alpha buffer");
+ return GL_FALSE;
+ }
+
+ /* wrap the alpha renderbuffer around the RGB renderbuffer */
+ arb->Wrapped = fb->Attachment[b].Renderbuffer;
+
+ /* Set up my alphabuffer fields and plug in my functions.
+ * The functions will put/get the alpha values from/to RGBA arrays
+ * and then call the wrapped buffer's functions to handle the RGB
+ * values.
+ */
+ arb->InternalFormat = arb->Wrapped->InternalFormat;
+ arb->_BaseFormat = arb->Wrapped->_BaseFormat;
+ arb->DataType = arb->Wrapped->DataType;
+ arb->AllocStorage = alloc_storage_alpha8;
+ arb->Delete = delete_renderbuffer_alpha8;
+ arb->GetPointer = get_pointer_alpha8;
+ arb->GetRow = get_row_alpha8;
+ arb->GetValues = get_values_alpha8;
+ arb->PutRow = put_row_alpha8;
+ arb->PutRowRGB = put_row_rgb_alpha8;
+ arb->PutMonoRow = put_mono_row_alpha8;
+ arb->PutValues = put_values_alpha8;
+ arb->PutMonoValues = put_mono_values_alpha8;
+
+ /* clear the pointer to avoid assertion/sanity check failure later */
+ fb->Attachment[b].Renderbuffer = NULL;
+
+ /* plug the alpha renderbuffer into the colorbuffer attachment */
+ _mesa_add_renderbuffer(fb, b, arb);
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Add a software-based depth renderbuffer to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ */
+GLboolean
+_mesa_add_depth_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint depthBits)
+{
+ struct gl_renderbuffer *rb;
+
+ if (depthBits > 32) {
+ _mesa_problem(ctx,
+ "Unsupported depthBits in _mesa_add_depth_renderbuffer");
+ return GL_FALSE;
+ }
+
+ assert(fb->Attachment[BUFFER_DEPTH].Renderbuffer == NULL);
+
+ rb = _mesa_new_renderbuffer(ctx, 0);
+ if (!rb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating depth buffer");
+ return GL_FALSE;
+ }
+
+ if (depthBits <= 16) {
+ rb->InternalFormat = GL_DEPTH_COMPONENT16;
+ }
+ else {
+ rb->InternalFormat = GL_DEPTH_COMPONENT32;
+ }
+
+ rb->AllocStorage = soft_renderbuffer_storage;
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, rb);
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Add a software-based stencil renderbuffer to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ */
+GLboolean
+_mesa_add_stencil_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint stencilBits)
+{
+ struct gl_renderbuffer *rb;
+
+ if (stencilBits > 16) {
+ _mesa_problem(ctx,
+ "Unsupported stencilBits in _mesa_add_stencil_renderbuffer");
+ return GL_FALSE;
+ }
+
+ assert(fb->Attachment[BUFFER_STENCIL].Renderbuffer == NULL);
+
+ rb = _mesa_new_renderbuffer(ctx, 0);
+ if (!rb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating stencil buffer");
+ return GL_FALSE;
+ }
+
+ if (stencilBits <= 8) {
+ rb->InternalFormat = GL_STENCIL_INDEX8_EXT;
+ }
+ else {
+ /* not really supported (see s_stencil.c code) */
+ rb->InternalFormat = GL_STENCIL_INDEX16_EXT;
+ }
+
+ rb->AllocStorage = soft_renderbuffer_storage;
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, rb);
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Add a software-based accumulation renderbuffer to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ */
+GLboolean
+_mesa_add_accum_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint redBits, GLuint greenBits,
+ GLuint blueBits, GLuint alphaBits)
+{
+ struct gl_renderbuffer *rb;
+
+ if (redBits > 16 || greenBits > 16 || blueBits > 16 || alphaBits > 16) {
+ _mesa_problem(ctx,
+ "Unsupported accumBits in _mesa_add_accum_renderbuffer");
+ return GL_FALSE;
+ }
+
+ assert(fb->Attachment[BUFFER_ACCUM].Renderbuffer == NULL);
+
+ rb = _mesa_new_renderbuffer(ctx, 0);
+ if (!rb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating accum buffer");
+ return GL_FALSE;
+ }
+
+ rb->InternalFormat = GL_RGBA16;
+ rb->AllocStorage = soft_renderbuffer_storage;
+ _mesa_add_renderbuffer(fb, BUFFER_ACCUM, rb);
+
+ return GL_TRUE;
+}
+
+
+
+/**
+ * Add a software-based accumulation renderbuffer to the given framebuffer.
+ * This is a helper routine for device drivers when creating a
+ * window system framebuffer (not a user-created render/framebuffer).
+ * Once this function is called, you can basically forget about this
+ * renderbuffer; core Mesa will handle all the buffer management and
+ * rendering!
+ *
+ * NOTE: color-index aux buffers not supported.
+ */
+GLboolean
+_mesa_add_aux_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint colorBits, GLuint numBuffers)
+{
+ GLuint i;
+
+ if (colorBits > 16) {
+ _mesa_problem(ctx,
+ "Unsupported accumBits in _mesa_add_aux_renderbuffers");
+ return GL_FALSE;
+ }
+
+ assert(numBuffers < MAX_AUX_BUFFERS);
+
+ for (i = 0; i < numBuffers; i++) {
+ struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, 0);
+
+ assert(fb->Attachment[BUFFER_AUX0 + i].Renderbuffer == NULL);
+
+ if (!rb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "Allocating accum buffer");
+ return GL_FALSE;
+ }
+
+ if (colorBits <= 8) {
+ rb->InternalFormat = GL_RGBA8;
+ }
+ else {
+ rb->InternalFormat = GL_RGBA16;
+ }
+
+ rb->AllocStorage = soft_renderbuffer_storage;
+ _mesa_add_renderbuffer(fb, BUFFER_AUX0 + i, rb);
+ }
+ return GL_TRUE;
+}
+
+
+
+/**
+ * Attach a renderbuffer to a framebuffer.
+ */
+void
+_mesa_add_renderbuffer(struct gl_framebuffer *fb,
+ GLuint bufferName, struct gl_renderbuffer *rb)
+{
+ assert(fb);
+ assert(rb);
+ /* there should be no previous renderbuffer on this attachment point! */
+ assert(fb->Attachment[bufferName].Renderbuffer == NULL);
+ assert(bufferName < BUFFER_COUNT);
+
+ /* winsys vs. user-created buffer cross check */
+ if (fb->Name) {
+ assert(rb->Name);
+ }
+ else {
+ assert(!rb->Name);
+ }
+
+ fb->Attachment[bufferName].Type = GL_RENDERBUFFER_EXT;
+ fb->Attachment[bufferName].Complete = GL_TRUE;
+ fb->Attachment[bufferName].Renderbuffer = rb;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/renderbuffer.h b/nx-X11/extras/Mesa/src/mesa/main/renderbuffer.h
new file mode 100644
index 000000000..5c11de7c8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/renderbuffer.h
@@ -0,0 +1,84 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef RENDERBUFFER_H
+#define RENDERBUFFER_H
+
+
+extern void
+_mesa_init_renderbuffer(struct gl_renderbuffer *rb, GLuint name);
+
+extern struct gl_renderbuffer *
+_mesa_new_renderbuffer(GLcontext *ctx, GLuint name);
+
+extern void
+_mesa_delete_renderbuffer(struct gl_renderbuffer *rb);
+
+
+extern struct gl_renderbuffer *
+_mesa_new_soft_renderbuffer(GLcontext *ctx, GLuint name);
+
+
+extern GLboolean
+_mesa_add_color_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint rgbBits, GLuint alphaBits,
+ GLboolean frontLeft, GLboolean backLeft,
+ GLboolean frontRight, GLboolean backRight);
+
+extern GLboolean
+_mesa_add_color_index_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint indexBits,
+ GLboolean frontLeft, GLboolean backLeft,
+ GLboolean frontRight, GLboolean backRight);
+
+extern GLboolean
+_mesa_add_alpha_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint alphaBits,
+ GLboolean frontLeft, GLboolean backLeft,
+ GLboolean frontRight, GLboolean backRight);
+
+extern GLboolean
+_mesa_add_depth_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint depthBits);
+
+extern GLboolean
+_mesa_add_stencil_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint stencilBits);
+
+
+extern GLboolean
+_mesa_add_accum_renderbuffer(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint redBits, GLuint greenBits,
+ GLuint blueBits, GLuint alphaBits);
+
+extern GLboolean
+_mesa_add_aux_renderbuffers(GLcontext *ctx, struct gl_framebuffer *fb,
+ GLuint bits, GLuint numBuffers);
+
+extern void
+_mesa_add_renderbuffer(struct gl_framebuffer *fb,
+ GLuint bufferName, struct gl_renderbuffer *rb);
+
+#endif /* RENDERBUFFER_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/main/simple_list.h b/nx-X11/extras/Mesa/src/mesa/main/simple_list.h
new file mode 100644
index 000000000..63475f6f7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/simple_list.h
@@ -0,0 +1,197 @@
+/**
+ * \file simple_list.h
+ * Simple macros for type-safe, intrusive lists.
+ *
+ * Intended to work with a list sentinal which is created as an empty
+ * list. Insert & delete are O(1).
+ *
+ * \author
+ * (C) 1997, Keith Whitwell
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef _SIMPLE_LIST_H
+#define _SIMPLE_LIST_H
+
+/**
+ * Remove an element from list.
+ *
+ * \param elem element to remove.
+ */
+#define remove_from_list(elem) \
+do { \
+ (elem)->next->prev = (elem)->prev; \
+ (elem)->prev->next = (elem)->next; \
+} while (0)
+
+/**
+ * Insert an element to the list head.
+ *
+ * \param list list.
+ * \param elem element to insert.
+ */
+#define insert_at_head(list, elem) \
+do { \
+ (elem)->prev = list; \
+ (elem)->next = (list)->next; \
+ (list)->next->prev = elem; \
+ (list)->next = elem; \
+} while(0)
+
+/**
+ * Insert an element to the list tail.
+ *
+ * \param list list.
+ * \param elem element to insert.
+ */
+#define insert_at_tail(list, elem) \
+do { \
+ (elem)->next = list; \
+ (elem)->prev = (list)->prev; \
+ (list)->prev->next = elem; \
+ (list)->prev = elem; \
+} while(0)
+
+/**
+ * Move an element to the list head.
+ *
+ * \param list list.
+ * \param elem element to move.
+ */
+#define move_to_head(list, elem) \
+do { \
+ remove_from_list(elem); \
+ insert_at_head(list, elem); \
+} while (0)
+
+/**
+ * Move an element to the list tail.
+ *
+ * \param list list.
+ * \param elem element to move.
+ */
+#define move_to_tail(list, elem) \
+do { \
+ remove_from_list(elem); \
+ insert_at_tail(list, elem); \
+} while (0)
+
+/**
+ * Make a empty list empty.
+ *
+ * \param sentinal list (sentinal element).
+ */
+#define make_empty_list(sentinal) \
+do { \
+ (sentinal)->next = sentinal; \
+ (sentinal)->prev = sentinal; \
+} while (0)
+
+/**
+ * Get list first element.
+ *
+ * \param list list.
+ *
+ * \return pointer to first element.
+ */
+#define first_elem(list) ((list)->next)
+
+/**
+ * Get list last element.
+ *
+ * \param list list.
+ *
+ * \return pointer to last element.
+ */
+#define last_elem(list) ((list)->prev)
+
+/**
+ * Get next element.
+ *
+ * \param elem element.
+ *
+ * \return pointer to next element.
+ */
+#define next_elem(elem) ((elem)->next)
+
+/**
+ * Get previous element.
+ *
+ * \param elem element.
+ *
+ * \return pointer to previous element.
+ */
+#define prev_elem(elem) ((elem)->prev)
+
+/**
+ * Test whether element is at end of the list.
+ *
+ * \param list list.
+ * \param elem element.
+ *
+ * \return non-zero if element is at end of list, or zero otherwise.
+ */
+#define at_end(list, elem) ((elem) == (list))
+
+/**
+ * Test if a list is empty.
+ *
+ * \param list list.
+ *
+ * \return non-zero if list empty, or zero otherwise.
+ */
+#define is_empty_list(list) ((list)->next == (list))
+
+/**
+ * Walk through the elements of a list.
+ *
+ * \param ptr pointer to the current element.
+ * \param list list.
+ *
+ * \note It should be followed by a { } block or a single statement, as in a \c
+ * for loop.
+ */
+#define foreach(ptr, list) \
+ for( ptr=(list)->next ; ptr!=list ; ptr=(ptr)->next )
+
+/**
+ * Walk through the elements of a list.
+ *
+ * Same as #foreach but lets you unlink the current value during a list
+ * traversal. Useful for freeing a list, element by element.
+ *
+ * \param ptr pointer to the current element.
+ * \param t temporary pointer.
+ * \param list list.
+ *
+ * \note It should be followed by a { } block or a single statement, as in a \c
+ * for loop.
+ */
+#define foreach_s(ptr, t, list) \
+ for(ptr=(list)->next,t=(ptr)->next; list != ptr; ptr=t, t=(t)->next)
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/state.c b/nx-X11/extras/Mesa/src/mesa/main/state.c
new file mode 100644
index 000000000..9ab2c5fb8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/state.c
@@ -0,0 +1,1040 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file state.c
+ * State management.
+ *
+ * This file manages recalculation of derived values in the __GLcontextRec.
+ * Also, this is where we initialize the API dispatch table.
+ */
+
+#include "glheader.h"
+#include "accum.h"
+#include "api_loopback.h"
+#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
+#include "arbprogram.h"
+#endif
+#if FEATURE_ATI_fragment_shader
+#include "atifragshader.h"
+#endif
+#include "attrib.h"
+#include "blend.h"
+#if FEATURE_ARB_vertex_buffer_object
+#include "bufferobj.h"
+#endif
+#include "buffers.h"
+#include "clip.h"
+#include "colortab.h"
+#include "context.h"
+#include "convolve.h"
+#include "depth.h"
+#include "dlist.h"
+#include "drawpix.h"
+#include "enable.h"
+#include "eval.h"
+#include "get.h"
+#include "feedback.h"
+#include "fog.h"
+#if FEATURE_EXT_framebuffer_object
+#include "fbobject.h"
+#endif
+#include "framebuffer.h"
+#include "hint.h"
+#include "histogram.h"
+#include "imports.h"
+#include "light.h"
+#include "lines.h"
+#include "macros.h"
+#include "matrix.h"
+#if FEATURE_ARB_occlusion_query
+#include "occlude.h"
+#endif
+#include "pixel.h"
+#include "points.h"
+#include "polygon.h"
+#include "rastpos.h"
+#include "state.h"
+#include "stencil.h"
+#include "teximage.h"
+#include "texobj.h"
+#include "texstate.h"
+#include "mtypes.h"
+#include "varray.h"
+#if FEATURE_NV_vertex_program
+#include "nvprogram.h"
+#endif
+#if FEATURE_NV_fragment_program
+#include "nvfragprog.h"
+#include "nvprogram.h"
+#include "program.h"
+#include "texenvprogram.h"
+#endif
+#if FEATURE_ARB_shader_objects
+#include "shaderobjects.h"
+#endif
+#include "debug.h"
+#include "dispatch.h"
+
+
+
+/**
+ * Initialize a dispatch table with pointers to Mesa's immediate-mode
+ * commands.
+ *
+ * Pointers to glBegin()/glEnd() object commands and a few others
+ * are provided via the GLvertexformat interface.
+ *
+ * \param ctx GL context to which \c exec belongs.
+ * \param exec dispatch table.
+ */
+void
+_mesa_init_exec_table(struct _glapi_table *exec)
+{
+#if _HAVE_FULL_GL
+ _mesa_loopback_init_api_table( exec );
+#endif
+
+ /* load the dispatch slots we understand */
+ SET_AlphaFunc(exec, _mesa_AlphaFunc);
+ SET_BlendFunc(exec, _mesa_BlendFunc);
+ SET_Clear(exec, _mesa_Clear);
+ SET_ClearColor(exec, _mesa_ClearColor);
+ SET_ClearStencil(exec, _mesa_ClearStencil);
+ SET_ColorMask(exec, _mesa_ColorMask);
+ SET_CullFace(exec, _mesa_CullFace);
+ SET_Disable(exec, _mesa_Disable);
+ SET_DrawBuffer(exec, _mesa_DrawBuffer);
+ SET_Enable(exec, _mesa_Enable);
+ SET_Finish(exec, _mesa_Finish);
+ SET_Flush(exec, _mesa_Flush);
+ SET_FrontFace(exec, _mesa_FrontFace);
+ SET_Frustum(exec, _mesa_Frustum);
+ SET_GetError(exec, _mesa_GetError);
+ SET_GetFloatv(exec, _mesa_GetFloatv);
+ SET_GetString(exec, _mesa_GetString);
+ SET_InitNames(exec, _mesa_InitNames);
+ SET_LineStipple(exec, _mesa_LineStipple);
+ SET_LineWidth(exec, _mesa_LineWidth);
+ SET_LoadIdentity(exec, _mesa_LoadIdentity);
+ SET_LoadMatrixf(exec, _mesa_LoadMatrixf);
+ SET_LoadName(exec, _mesa_LoadName);
+ SET_LogicOp(exec, _mesa_LogicOp);
+ SET_MatrixMode(exec, _mesa_MatrixMode);
+ SET_MultMatrixf(exec, _mesa_MultMatrixf);
+ SET_Ortho(exec, _mesa_Ortho);
+ SET_PixelStorei(exec, _mesa_PixelStorei);
+ SET_PopMatrix(exec, _mesa_PopMatrix);
+ SET_PopName(exec, _mesa_PopName);
+ SET_PushMatrix(exec, _mesa_PushMatrix);
+ SET_PushName(exec, _mesa_PushName);
+ SET_RasterPos2f(exec, _mesa_RasterPos2f);
+ SET_RasterPos2fv(exec, _mesa_RasterPos2fv);
+ SET_RasterPos2i(exec, _mesa_RasterPos2i);
+ SET_RasterPos2iv(exec, _mesa_RasterPos2iv);
+ SET_ReadBuffer(exec, _mesa_ReadBuffer);
+ SET_RenderMode(exec, _mesa_RenderMode);
+ SET_Rotatef(exec, _mesa_Rotatef);
+ SET_Scalef(exec, _mesa_Scalef);
+ SET_Scissor(exec, _mesa_Scissor);
+ SET_SelectBuffer(exec, _mesa_SelectBuffer);
+ SET_ShadeModel(exec, _mesa_ShadeModel);
+ SET_StencilFunc(exec, _mesa_StencilFunc);
+ SET_StencilMask(exec, _mesa_StencilMask);
+ SET_StencilOp(exec, _mesa_StencilOp);
+ SET_TexEnvfv(exec, _mesa_TexEnvfv);
+ SET_TexEnvi(exec, _mesa_TexEnvi);
+ SET_TexImage2D(exec, _mesa_TexImage2D);
+ SET_TexParameteri(exec, _mesa_TexParameteri);
+ SET_Translatef(exec, _mesa_Translatef);
+ SET_Viewport(exec, _mesa_Viewport);
+#if _HAVE_FULL_GL
+ SET_Accum(exec, _mesa_Accum);
+ SET_Bitmap(exec, _mesa_Bitmap);
+ SET_CallList(exec, _mesa_CallList);
+ SET_CallLists(exec, _mesa_CallLists);
+ SET_ClearAccum(exec, _mesa_ClearAccum);
+ SET_ClearDepth(exec, _mesa_ClearDepth);
+ SET_ClearIndex(exec, _mesa_ClearIndex);
+ SET_ClipPlane(exec, _mesa_ClipPlane);
+ SET_ColorMaterial(exec, _mesa_ColorMaterial);
+ SET_CopyPixels(exec, _mesa_CopyPixels);
+ SET_CullParameterfvEXT(exec, _mesa_CullParameterfvEXT);
+ SET_CullParameterdvEXT(exec, _mesa_CullParameterdvEXT);
+ SET_DeleteLists(exec, _mesa_DeleteLists);
+ SET_DepthFunc(exec, _mesa_DepthFunc);
+ SET_DepthMask(exec, _mesa_DepthMask);
+ SET_DepthRange(exec, _mesa_DepthRange);
+ SET_DrawPixels(exec, _mesa_DrawPixels);
+ SET_EndList(exec, _mesa_EndList);
+ SET_FeedbackBuffer(exec, _mesa_FeedbackBuffer);
+ SET_FogCoordPointerEXT(exec, _mesa_FogCoordPointerEXT);
+ SET_Fogf(exec, _mesa_Fogf);
+ SET_Fogfv(exec, _mesa_Fogfv);
+ SET_Fogi(exec, _mesa_Fogi);
+ SET_Fogiv(exec, _mesa_Fogiv);
+ SET_GenLists(exec, _mesa_GenLists);
+ SET_GetClipPlane(exec, _mesa_GetClipPlane);
+ SET_GetBooleanv(exec, _mesa_GetBooleanv);
+ SET_GetDoublev(exec, _mesa_GetDoublev);
+ SET_GetIntegerv(exec, _mesa_GetIntegerv);
+ SET_GetLightfv(exec, _mesa_GetLightfv);
+ SET_GetLightiv(exec, _mesa_GetLightiv);
+ SET_GetMapdv(exec, _mesa_GetMapdv);
+ SET_GetMapfv(exec, _mesa_GetMapfv);
+ SET_GetMapiv(exec, _mesa_GetMapiv);
+ SET_GetMaterialfv(exec, _mesa_GetMaterialfv);
+ SET_GetMaterialiv(exec, _mesa_GetMaterialiv);
+ SET_GetPixelMapfv(exec, _mesa_GetPixelMapfv);
+ SET_GetPixelMapuiv(exec, _mesa_GetPixelMapuiv);
+ SET_GetPixelMapusv(exec, _mesa_GetPixelMapusv);
+ SET_GetPolygonStipple(exec, _mesa_GetPolygonStipple);
+ SET_GetTexEnvfv(exec, _mesa_GetTexEnvfv);
+ SET_GetTexEnviv(exec, _mesa_GetTexEnviv);
+ SET_GetTexLevelParameterfv(exec, _mesa_GetTexLevelParameterfv);
+ SET_GetTexLevelParameteriv(exec, _mesa_GetTexLevelParameteriv);
+ SET_GetTexParameterfv(exec, _mesa_GetTexParameterfv);
+ SET_GetTexParameteriv(exec, _mesa_GetTexParameteriv);
+ SET_GetTexGendv(exec, _mesa_GetTexGendv);
+ SET_GetTexGenfv(exec, _mesa_GetTexGenfv);
+ SET_GetTexGeniv(exec, _mesa_GetTexGeniv);
+ SET_GetTexImage(exec, _mesa_GetTexImage);
+ SET_Hint(exec, _mesa_Hint);
+ SET_IndexMask(exec, _mesa_IndexMask);
+ SET_IsEnabled(exec, _mesa_IsEnabled);
+ SET_IsList(exec, _mesa_IsList);
+ SET_LightModelf(exec, _mesa_LightModelf);
+ SET_LightModelfv(exec, _mesa_LightModelfv);
+ SET_LightModeli(exec, _mesa_LightModeli);
+ SET_LightModeliv(exec, _mesa_LightModeliv);
+ SET_Lightf(exec, _mesa_Lightf);
+ SET_Lightfv(exec, _mesa_Lightfv);
+ SET_Lighti(exec, _mesa_Lighti);
+ SET_Lightiv(exec, _mesa_Lightiv);
+ SET_ListBase(exec, _mesa_ListBase);
+ SET_LoadMatrixd(exec, _mesa_LoadMatrixd);
+ SET_Map1d(exec, _mesa_Map1d);
+ SET_Map1f(exec, _mesa_Map1f);
+ SET_Map2d(exec, _mesa_Map2d);
+ SET_Map2f(exec, _mesa_Map2f);
+ SET_MapGrid1d(exec, _mesa_MapGrid1d);
+ SET_MapGrid1f(exec, _mesa_MapGrid1f);
+ SET_MapGrid2d(exec, _mesa_MapGrid2d);
+ SET_MapGrid2f(exec, _mesa_MapGrid2f);
+ SET_MultMatrixd(exec, _mesa_MultMatrixd);
+ SET_NewList(exec, _mesa_NewList);
+ SET_PassThrough(exec, _mesa_PassThrough);
+ SET_PixelMapfv(exec, _mesa_PixelMapfv);
+ SET_PixelMapuiv(exec, _mesa_PixelMapuiv);
+ SET_PixelMapusv(exec, _mesa_PixelMapusv);
+ SET_PixelStoref(exec, _mesa_PixelStoref);
+ SET_PixelTransferf(exec, _mesa_PixelTransferf);
+ SET_PixelTransferi(exec, _mesa_PixelTransferi);
+ SET_PixelZoom(exec, _mesa_PixelZoom);
+ SET_PointSize(exec, _mesa_PointSize);
+ SET_PolygonMode(exec, _mesa_PolygonMode);
+ SET_PolygonOffset(exec, _mesa_PolygonOffset);
+ SET_PolygonStipple(exec, _mesa_PolygonStipple);
+ SET_PopAttrib(exec, _mesa_PopAttrib);
+ SET_PushAttrib(exec, _mesa_PushAttrib);
+ SET_RasterPos2d(exec, _mesa_RasterPos2d);
+ SET_RasterPos2dv(exec, _mesa_RasterPos2dv);
+ SET_RasterPos2s(exec, _mesa_RasterPos2s);
+ SET_RasterPos2sv(exec, _mesa_RasterPos2sv);
+ SET_RasterPos3d(exec, _mesa_RasterPos3d);
+ SET_RasterPos3dv(exec, _mesa_RasterPos3dv);
+ SET_RasterPos3f(exec, _mesa_RasterPos3f);
+ SET_RasterPos3fv(exec, _mesa_RasterPos3fv);
+ SET_RasterPos3i(exec, _mesa_RasterPos3i);
+ SET_RasterPos3iv(exec, _mesa_RasterPos3iv);
+ SET_RasterPos3s(exec, _mesa_RasterPos3s);
+ SET_RasterPos3sv(exec, _mesa_RasterPos3sv);
+ SET_RasterPos4d(exec, _mesa_RasterPos4d);
+ SET_RasterPos4dv(exec, _mesa_RasterPos4dv);
+ SET_RasterPos4f(exec, _mesa_RasterPos4f);
+ SET_RasterPos4fv(exec, _mesa_RasterPos4fv);
+ SET_RasterPos4i(exec, _mesa_RasterPos4i);
+ SET_RasterPos4iv(exec, _mesa_RasterPos4iv);
+ SET_RasterPos4s(exec, _mesa_RasterPos4s);
+ SET_RasterPos4sv(exec, _mesa_RasterPos4sv);
+ SET_ReadPixels(exec, _mesa_ReadPixels);
+ SET_Rotated(exec, _mesa_Rotated);
+ SET_Scaled(exec, _mesa_Scaled);
+ SET_SecondaryColorPointerEXT(exec, _mesa_SecondaryColorPointerEXT);
+ SET_TexEnvf(exec, _mesa_TexEnvf);
+ SET_TexEnviv(exec, _mesa_TexEnviv);
+ SET_TexGend(exec, _mesa_TexGend);
+ SET_TexGendv(exec, _mesa_TexGendv);
+ SET_TexGenf(exec, _mesa_TexGenf);
+ SET_TexGenfv(exec, _mesa_TexGenfv);
+ SET_TexGeni(exec, _mesa_TexGeni);
+ SET_TexGeniv(exec, _mesa_TexGeniv);
+ SET_TexImage1D(exec, _mesa_TexImage1D);
+ SET_TexParameterf(exec, _mesa_TexParameterf);
+ SET_TexParameterfv(exec, _mesa_TexParameterfv);
+ SET_TexParameteriv(exec, _mesa_TexParameteriv);
+ SET_Translated(exec, _mesa_Translated);
+#endif
+
+ /* 1.1 */
+ SET_BindTexture(exec, _mesa_BindTexture);
+ SET_DeleteTextures(exec, _mesa_DeleteTextures);
+ SET_GenTextures(exec, _mesa_GenTextures);
+#if _HAVE_FULL_GL
+ SET_AreTexturesResident(exec, _mesa_AreTexturesResident);
+ SET_AreTexturesResidentEXT(exec, _mesa_AreTexturesResident);
+ SET_ColorPointer(exec, _mesa_ColorPointer);
+ SET_CopyTexImage1D(exec, _mesa_CopyTexImage1D);
+ SET_CopyTexImage2D(exec, _mesa_CopyTexImage2D);
+ SET_CopyTexSubImage1D(exec, _mesa_CopyTexSubImage1D);
+ SET_CopyTexSubImage2D(exec, _mesa_CopyTexSubImage2D);
+ SET_DisableClientState(exec, _mesa_DisableClientState);
+ SET_EdgeFlagPointer(exec, _mesa_EdgeFlagPointer);
+ SET_EnableClientState(exec, _mesa_EnableClientState);
+ SET_GenTexturesEXT(exec, _mesa_GenTextures);
+ SET_GetPointerv(exec, _mesa_GetPointerv);
+ SET_IndexPointer(exec, _mesa_IndexPointer);
+ SET_InterleavedArrays(exec, _mesa_InterleavedArrays);
+ SET_IsTexture(exec, _mesa_IsTexture);
+ SET_IsTextureEXT(exec, _mesa_IsTexture);
+ SET_NormalPointer(exec, _mesa_NormalPointer);
+ SET_PopClientAttrib(exec, _mesa_PopClientAttrib);
+ SET_PrioritizeTextures(exec, _mesa_PrioritizeTextures);
+ SET_PushClientAttrib(exec, _mesa_PushClientAttrib);
+ SET_TexCoordPointer(exec, _mesa_TexCoordPointer);
+ SET_TexSubImage1D(exec, _mesa_TexSubImage1D);
+ SET_TexSubImage2D(exec, _mesa_TexSubImage2D);
+ SET_VertexPointer(exec, _mesa_VertexPointer);
+#endif
+
+ /* 1.2 */
+#if _HAVE_FULL_GL
+ SET_CopyTexSubImage3D(exec, _mesa_CopyTexSubImage3D);
+ SET_TexImage3D(exec, _mesa_TexImage3D);
+ SET_TexSubImage3D(exec, _mesa_TexSubImage3D);
+#endif
+
+ /* OpenGL 1.2 GL_ARB_imaging */
+#if _HAVE_FULL_GL
+ SET_BlendColor(exec, _mesa_BlendColor);
+ SET_BlendEquation(exec, _mesa_BlendEquation);
+ SET_BlendEquationSeparateEXT(exec, _mesa_BlendEquationSeparateEXT);
+ SET_ColorSubTable(exec, _mesa_ColorSubTable);
+ SET_ColorTable(exec, _mesa_ColorTable);
+ SET_ColorTableParameterfv(exec, _mesa_ColorTableParameterfv);
+ SET_ColorTableParameteriv(exec, _mesa_ColorTableParameteriv);
+ SET_ConvolutionFilter1D(exec, _mesa_ConvolutionFilter1D);
+ SET_ConvolutionFilter2D(exec, _mesa_ConvolutionFilter2D);
+ SET_ConvolutionParameterf(exec, _mesa_ConvolutionParameterf);
+ SET_ConvolutionParameterfv(exec, _mesa_ConvolutionParameterfv);
+ SET_ConvolutionParameteri(exec, _mesa_ConvolutionParameteri);
+ SET_ConvolutionParameteriv(exec, _mesa_ConvolutionParameteriv);
+ SET_CopyColorSubTable(exec, _mesa_CopyColorSubTable);
+ SET_CopyColorTable(exec, _mesa_CopyColorTable);
+ SET_CopyConvolutionFilter1D(exec, _mesa_CopyConvolutionFilter1D);
+ SET_CopyConvolutionFilter2D(exec, _mesa_CopyConvolutionFilter2D);
+ SET_GetColorTable(exec, _mesa_GetColorTable);
+ SET_GetColorTableEXT(exec, _mesa_GetColorTable);
+ SET_GetColorTableParameterfv(exec, _mesa_GetColorTableParameterfv);
+ SET_GetColorTableParameterfvEXT(exec, _mesa_GetColorTableParameterfv);
+ SET_GetColorTableParameteriv(exec, _mesa_GetColorTableParameteriv);
+ SET_GetColorTableParameterivEXT(exec, _mesa_GetColorTableParameteriv);
+ SET_GetConvolutionFilter(exec, _mesa_GetConvolutionFilter);
+ SET_GetConvolutionFilterEXT(exec, _mesa_GetConvolutionFilter);
+ SET_GetConvolutionParameterfv(exec, _mesa_GetConvolutionParameterfv);
+ SET_GetConvolutionParameterfvEXT(exec, _mesa_GetConvolutionParameterfv);
+ SET_GetConvolutionParameteriv(exec, _mesa_GetConvolutionParameteriv);
+ SET_GetConvolutionParameterivEXT(exec, _mesa_GetConvolutionParameteriv);
+ SET_GetHistogram(exec, _mesa_GetHistogram);
+ SET_GetHistogramEXT(exec, _mesa_GetHistogram);
+ SET_GetHistogramParameterfv(exec, _mesa_GetHistogramParameterfv);
+ SET_GetHistogramParameterfvEXT(exec, _mesa_GetHistogramParameterfv);
+ SET_GetHistogramParameteriv(exec, _mesa_GetHistogramParameteriv);
+ SET_GetHistogramParameterivEXT(exec, _mesa_GetHistogramParameteriv);
+ SET_GetMinmax(exec, _mesa_GetMinmax);
+ SET_GetMinmaxEXT(exec, _mesa_GetMinmax);
+ SET_GetMinmaxParameterfv(exec, _mesa_GetMinmaxParameterfv);
+ SET_GetMinmaxParameterfvEXT(exec, _mesa_GetMinmaxParameterfv);
+ SET_GetMinmaxParameteriv(exec, _mesa_GetMinmaxParameteriv);
+ SET_GetMinmaxParameterivEXT(exec, _mesa_GetMinmaxParameteriv);
+ SET_GetSeparableFilter(exec, _mesa_GetSeparableFilter);
+ SET_GetSeparableFilterEXT(exec, _mesa_GetSeparableFilter);
+ SET_Histogram(exec, _mesa_Histogram);
+ SET_Minmax(exec, _mesa_Minmax);
+ SET_ResetHistogram(exec, _mesa_ResetHistogram);
+ SET_ResetMinmax(exec, _mesa_ResetMinmax);
+ SET_SeparableFilter2D(exec, _mesa_SeparableFilter2D);
+#endif
+
+ /* OpenGL 2.0 */
+ SET_StencilFuncSeparate(exec, _mesa_StencilFuncSeparate);
+ SET_StencilMaskSeparate(exec, _mesa_StencilMaskSeparate);
+ SET_StencilOpSeparate(exec, _mesa_StencilOpSeparate);
+
+ /* 2. GL_EXT_blend_color */
+#if 0
+/* SET_BlendColorEXT(exec, _mesa_BlendColorEXT); */
+#endif
+
+ /* 3. GL_EXT_polygon_offset */
+#if _HAVE_FULL_GL
+ SET_PolygonOffsetEXT(exec, _mesa_PolygonOffsetEXT);
+#endif
+
+ /* 6. GL_EXT_texture3d */
+#if 0
+/* SET_CopyTexSubImage3DEXT(exec, _mesa_CopyTexSubImage3D); */
+/* SET_TexImage3DEXT(exec, _mesa_TexImage3DEXT); */
+/* SET_TexSubImage3DEXT(exec, _mesa_TexSubImage3D); */
+#endif
+
+ /* 11. GL_EXT_histogram */
+#if _HAVE_FULL_GL
+ SET_GetHistogramEXT(exec, _mesa_GetHistogram);
+ SET_GetHistogramParameterfvEXT(exec, _mesa_GetHistogramParameterfv);
+ SET_GetHistogramParameterivEXT(exec, _mesa_GetHistogramParameteriv);
+ SET_GetMinmaxEXT(exec, _mesa_GetMinmax);
+ SET_GetMinmaxParameterfvEXT(exec, _mesa_GetMinmaxParameterfv);
+ SET_GetMinmaxParameterivEXT(exec, _mesa_GetMinmaxParameteriv);
+#endif
+
+ /* ?. GL_SGIX_pixel_texture */
+#if _HAVE_FULL_GL
+ SET_PixelTexGenSGIX(exec, _mesa_PixelTexGenSGIX);
+#endif
+
+ /* 15. GL_SGIS_pixel_texture */
+#if _HAVE_FULL_GL
+ SET_PixelTexGenParameteriSGIS(exec, _mesa_PixelTexGenParameteriSGIS);
+ SET_PixelTexGenParameterivSGIS(exec, _mesa_PixelTexGenParameterivSGIS);
+ SET_PixelTexGenParameterfSGIS(exec, _mesa_PixelTexGenParameterfSGIS);
+ SET_PixelTexGenParameterfvSGIS(exec, _mesa_PixelTexGenParameterfvSGIS);
+ SET_GetPixelTexGenParameterivSGIS(exec, _mesa_GetPixelTexGenParameterivSGIS);
+ SET_GetPixelTexGenParameterfvSGIS(exec, _mesa_GetPixelTexGenParameterfvSGIS);
+#endif
+
+ /* 30. GL_EXT_vertex_array */
+#if _HAVE_FULL_GL
+ SET_ColorPointerEXT(exec, _mesa_ColorPointerEXT);
+ SET_EdgeFlagPointerEXT(exec, _mesa_EdgeFlagPointerEXT);
+ SET_IndexPointerEXT(exec, _mesa_IndexPointerEXT);
+ SET_NormalPointerEXT(exec, _mesa_NormalPointerEXT);
+ SET_TexCoordPointerEXT(exec, _mesa_TexCoordPointerEXT);
+ SET_VertexPointerEXT(exec, _mesa_VertexPointerEXT);
+#endif
+
+ /* 37. GL_EXT_blend_minmax */
+#if 0
+ SET_BlendEquationEXT(exec, _mesa_BlendEquationEXT);
+#endif
+
+ /* 54. GL_EXT_point_parameters */
+#if _HAVE_FULL_GL
+ SET_PointParameterfEXT(exec, _mesa_PointParameterfEXT);
+ SET_PointParameterfvEXT(exec, _mesa_PointParameterfvEXT);
+#endif
+
+ /* 78. GL_EXT_paletted_texture */
+#if 0
+ SET_ColorTableEXT(exec, _mesa_ColorTableEXT);
+ SET_ColorSubTableEXT(exec, _mesa_ColorSubTableEXT);
+#endif
+#if _HAVE_FULL_GL
+ SET_GetColorTableEXT(exec, _mesa_GetColorTable);
+ SET_GetColorTableParameterfvEXT(exec, _mesa_GetColorTableParameterfv);
+ SET_GetColorTableParameterivEXT(exec, _mesa_GetColorTableParameteriv);
+#endif
+
+ /* 97. GL_EXT_compiled_vertex_array */
+#if _HAVE_FULL_GL
+ SET_LockArraysEXT(exec, _mesa_LockArraysEXT);
+ SET_UnlockArraysEXT(exec, _mesa_UnlockArraysEXT);
+#endif
+
+ /* 148. GL_EXT_multi_draw_arrays */
+#if _HAVE_FULL_GL
+ SET_MultiDrawArraysEXT(exec, _mesa_MultiDrawArraysEXT);
+ SET_MultiDrawElementsEXT(exec, _mesa_MultiDrawElementsEXT);
+#endif
+
+ /* 173. GL_INGR_blend_func_separate */
+#if _HAVE_FULL_GL
+ SET_BlendFuncSeparateEXT(exec, _mesa_BlendFuncSeparateEXT);
+#endif
+
+ /* 196. GL_MESA_resize_buffers */
+#if _HAVE_FULL_GL
+ SET_ResizeBuffersMESA(exec, _mesa_ResizeBuffersMESA);
+#endif
+
+ /* 197. GL_MESA_window_pos */
+#if _HAVE_FULL_GL
+ SET_WindowPos2dMESA(exec, _mesa_WindowPos2dMESA);
+ SET_WindowPos2dvMESA(exec, _mesa_WindowPos2dvMESA);
+ SET_WindowPos2fMESA(exec, _mesa_WindowPos2fMESA);
+ SET_WindowPos2fvMESA(exec, _mesa_WindowPos2fvMESA);
+ SET_WindowPos2iMESA(exec, _mesa_WindowPos2iMESA);
+ SET_WindowPos2ivMESA(exec, _mesa_WindowPos2ivMESA);
+ SET_WindowPos2sMESA(exec, _mesa_WindowPos2sMESA);
+ SET_WindowPos2svMESA(exec, _mesa_WindowPos2svMESA);
+ SET_WindowPos3dMESA(exec, _mesa_WindowPos3dMESA);
+ SET_WindowPos3dvMESA(exec, _mesa_WindowPos3dvMESA);
+ SET_WindowPos3fMESA(exec, _mesa_WindowPos3fMESA);
+ SET_WindowPos3fvMESA(exec, _mesa_WindowPos3fvMESA);
+ SET_WindowPos3iMESA(exec, _mesa_WindowPos3iMESA);
+ SET_WindowPos3ivMESA(exec, _mesa_WindowPos3ivMESA);
+ SET_WindowPos3sMESA(exec, _mesa_WindowPos3sMESA);
+ SET_WindowPos3svMESA(exec, _mesa_WindowPos3svMESA);
+ SET_WindowPos4dMESA(exec, _mesa_WindowPos4dMESA);
+ SET_WindowPos4dvMESA(exec, _mesa_WindowPos4dvMESA);
+ SET_WindowPos4fMESA(exec, _mesa_WindowPos4fMESA);
+ SET_WindowPos4fvMESA(exec, _mesa_WindowPos4fvMESA);
+ SET_WindowPos4iMESA(exec, _mesa_WindowPos4iMESA);
+ SET_WindowPos4ivMESA(exec, _mesa_WindowPos4ivMESA);
+ SET_WindowPos4sMESA(exec, _mesa_WindowPos4sMESA);
+ SET_WindowPos4svMESA(exec, _mesa_WindowPos4svMESA);
+#endif
+
+ /* 200. GL_IBM_multimode_draw_arrays */
+#if _HAVE_FULL_GL
+ SET_MultiModeDrawArraysIBM(exec, _mesa_MultiModeDrawArraysIBM);
+ SET_MultiModeDrawElementsIBM(exec, _mesa_MultiModeDrawElementsIBM);
+#endif
+
+ /* 233. GL_NV_vertex_program */
+#if FEATURE_NV_vertex_program
+ SET_BindProgramNV(exec, _mesa_BindProgram);
+ SET_DeleteProgramsNV(exec, _mesa_DeletePrograms);
+ SET_ExecuteProgramNV(exec, _mesa_ExecuteProgramNV);
+ SET_GenProgramsNV(exec, _mesa_GenPrograms);
+ SET_AreProgramsResidentNV(exec, _mesa_AreProgramsResidentNV);
+ SET_RequestResidentProgramsNV(exec, _mesa_RequestResidentProgramsNV);
+ SET_GetProgramParameterfvNV(exec, _mesa_GetProgramParameterfvNV);
+ SET_GetProgramParameterdvNV(exec, _mesa_GetProgramParameterdvNV);
+ SET_GetProgramivNV(exec, _mesa_GetProgramivNV);
+ SET_GetProgramStringNV(exec, _mesa_GetProgramStringNV);
+ SET_GetTrackMatrixivNV(exec, _mesa_GetTrackMatrixivNV);
+ SET_GetVertexAttribdvNV(exec, _mesa_GetVertexAttribdvNV);
+ SET_GetVertexAttribfvNV(exec, _mesa_GetVertexAttribfvNV);
+ SET_GetVertexAttribivNV(exec, _mesa_GetVertexAttribivNV);
+ SET_GetVertexAttribPointervNV(exec, _mesa_GetVertexAttribPointervNV);
+ SET_IsProgramNV(exec, _mesa_IsProgram);
+ SET_LoadProgramNV(exec, _mesa_LoadProgramNV);
+ SET_ProgramParameter4dNV(exec, _mesa_ProgramParameter4dNV);
+ SET_ProgramParameter4dvNV(exec, _mesa_ProgramParameter4dvNV);
+ SET_ProgramParameter4fNV(exec, _mesa_ProgramParameter4fNV);
+ SET_ProgramParameter4fvNV(exec, _mesa_ProgramParameter4fvNV);
+ SET_ProgramParameters4dvNV(exec, _mesa_ProgramParameters4dvNV);
+ SET_ProgramParameters4fvNV(exec, _mesa_ProgramParameters4fvNV);
+ SET_TrackMatrixNV(exec, _mesa_TrackMatrixNV);
+ SET_VertexAttribPointerNV(exec, _mesa_VertexAttribPointerNV);
+ /* glVertexAttrib*NV functions handled in api_loopback.c */
+#endif
+
+ /* 282. GL_NV_fragment_program */
+#if FEATURE_NV_fragment_program
+ SET_ProgramNamedParameter4fNV(exec, _mesa_ProgramNamedParameter4fNV);
+ SET_ProgramNamedParameter4dNV(exec, _mesa_ProgramNamedParameter4dNV);
+ SET_ProgramNamedParameter4fvNV(exec, _mesa_ProgramNamedParameter4fvNV);
+ SET_ProgramNamedParameter4dvNV(exec, _mesa_ProgramNamedParameter4dvNV);
+ SET_GetProgramNamedParameterfvNV(exec, _mesa_GetProgramNamedParameterfvNV);
+ SET_GetProgramNamedParameterdvNV(exec, _mesa_GetProgramNamedParameterdvNV);
+ SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB);
+ SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB);
+ SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB);
+ SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB);
+ SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB);
+ SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB);
+#endif
+
+ /* 262. GL_NV_point_sprite */
+#if _HAVE_FULL_GL
+ SET_PointParameteriNV(exec, _mesa_PointParameteriNV);
+ SET_PointParameterivNV(exec, _mesa_PointParameterivNV);
+#endif
+
+ /* 268. GL_EXT_stencil_two_side */
+#if _HAVE_FULL_GL
+ SET_ActiveStencilFaceEXT(exec, _mesa_ActiveStencilFaceEXT);
+#endif
+
+ /* ???. GL_EXT_depth_bounds_test */
+ SET_DepthBoundsEXT(exec, _mesa_DepthBoundsEXT);
+
+ /* ARB 1. GL_ARB_multitexture */
+#if _HAVE_FULL_GL
+ SET_ActiveTextureARB(exec, _mesa_ActiveTextureARB);
+ SET_ClientActiveTextureARB(exec, _mesa_ClientActiveTextureARB);
+#endif
+
+ /* ARB 3. GL_ARB_transpose_matrix */
+#if _HAVE_FULL_GL
+ SET_LoadTransposeMatrixdARB(exec, _mesa_LoadTransposeMatrixdARB);
+ SET_LoadTransposeMatrixfARB(exec, _mesa_LoadTransposeMatrixfARB);
+ SET_MultTransposeMatrixdARB(exec, _mesa_MultTransposeMatrixdARB);
+ SET_MultTransposeMatrixfARB(exec, _mesa_MultTransposeMatrixfARB);
+#endif
+
+ /* ARB 5. GL_ARB_multisample */
+#if _HAVE_FULL_GL
+ SET_SampleCoverageARB(exec, _mesa_SampleCoverageARB);
+#endif
+
+ /* ARB 12. GL_ARB_texture_compression */
+#if _HAVE_FULL_GL
+ SET_CompressedTexImage3DARB(exec, _mesa_CompressedTexImage3DARB);
+ SET_CompressedTexImage2DARB(exec, _mesa_CompressedTexImage2DARB);
+ SET_CompressedTexImage1DARB(exec, _mesa_CompressedTexImage1DARB);
+ SET_CompressedTexSubImage3DARB(exec, _mesa_CompressedTexSubImage3DARB);
+ SET_CompressedTexSubImage2DARB(exec, _mesa_CompressedTexSubImage2DARB);
+ SET_CompressedTexSubImage1DARB(exec, _mesa_CompressedTexSubImage1DARB);
+ SET_GetCompressedTexImageARB(exec, _mesa_GetCompressedTexImageARB);
+#endif
+
+ /* ARB 14. GL_ARB_point_parameters */
+ /* reuse EXT_point_parameters functions */
+
+ /* ARB 26. GL_ARB_vertex_program */
+ /* ARB 27. GL_ARB_fragment_program */
+#if FEATURE_ARB_vertex_program || FEATURE_ARB_fragment_program
+ /* glVertexAttrib1sARB aliases glVertexAttrib1sNV */
+ /* glVertexAttrib1fARB aliases glVertexAttrib1fNV */
+ /* glVertexAttrib1dARB aliases glVertexAttrib1dNV */
+ /* glVertexAttrib2sARB aliases glVertexAttrib2sNV */
+ /* glVertexAttrib2fARB aliases glVertexAttrib2fNV */
+ /* glVertexAttrib2dARB aliases glVertexAttrib2dNV */
+ /* glVertexAttrib3sARB aliases glVertexAttrib3sNV */
+ /* glVertexAttrib3fARB aliases glVertexAttrib3fNV */
+ /* glVertexAttrib3dARB aliases glVertexAttrib3dNV */
+ /* glVertexAttrib4sARB aliases glVertexAttrib4sNV */
+ /* glVertexAttrib4fARB aliases glVertexAttrib4fNV */
+ /* glVertexAttrib4dARB aliases glVertexAttrib4dNV */
+ /* glVertexAttrib4NubARB aliases glVertexAttrib4NubNV */
+ /* glVertexAttrib1svARB aliases glVertexAttrib1svNV */
+ /* glVertexAttrib1fvARB aliases glVertexAttrib1fvNV */
+ /* glVertexAttrib1dvARB aliases glVertexAttrib1dvNV */
+ /* glVertexAttrib2svARB aliases glVertexAttrib2svNV */
+ /* glVertexAttrib2fvARB aliases glVertexAttrib2fvNV */
+ /* glVertexAttrib2dvARB aliases glVertexAttrib2dvNV */
+ /* glVertexAttrib3svARB aliases glVertexAttrib3svNV */
+ /* glVertexAttrib3fvARB aliases glVertexAttrib3fvNV */
+ /* glVertexAttrib3dvARB aliases glVertexAttrib3dvNV */
+ /* glVertexAttrib4svARB aliases glVertexAttrib4svNV */
+ /* glVertexAttrib4fvARB aliases glVertexAttrib4fvNV */
+ /* glVertexAttrib4dvARB aliases glVertexAttrib4dvNV */
+ /* glVertexAttrib4NubvARB aliases glVertexAttrib4NubvNV */
+ /* glVertexAttrib4bvARB handled in api_loopback.c */
+ /* glVertexAttrib4ivARB handled in api_loopback.c */
+ /* glVertexAttrib4ubvARB handled in api_loopback.c */
+ /* glVertexAttrib4usvARB handled in api_loopback.c */
+ /* glVertexAttrib4uivARB handled in api_loopback.c */
+ /* glVertexAttrib4NbvARB handled in api_loopback.c */
+ /* glVertexAttrib4NsvARB handled in api_loopback.c */
+ /* glVertexAttrib4NivARB handled in api_loopback.c */
+ /* glVertexAttrib4NusvARB handled in api_loopback.c */
+ /* glVertexAttrib4NuivARB handled in api_loopback.c */
+ SET_VertexAttribPointerARB(exec, _mesa_VertexAttribPointerARB);
+ SET_EnableVertexAttribArrayARB(exec, _mesa_EnableVertexAttribArrayARB);
+ SET_DisableVertexAttribArrayARB(exec, _mesa_DisableVertexAttribArrayARB);
+ SET_ProgramStringARB(exec, _mesa_ProgramStringARB);
+ /* glBindProgramARB aliases glBindProgramNV */
+ /* glDeleteProgramsARB aliases glDeleteProgramsNV */
+ /* glGenProgramsARB aliases glGenProgramsNV */
+ /* glIsProgramARB aliases glIsProgramNV */
+ SET_GetVertexAttribdvARB(exec, _mesa_GetVertexAttribdvARB);
+ SET_GetVertexAttribfvARB(exec, _mesa_GetVertexAttribfvARB);
+ SET_GetVertexAttribivARB(exec, _mesa_GetVertexAttribivARB);
+ /* glGetVertexAttribPointervARB aliases glGetVertexAttribPointervNV */
+ SET_ProgramEnvParameter4dARB(exec, _mesa_ProgramEnvParameter4dARB);
+ SET_ProgramEnvParameter4dvARB(exec, _mesa_ProgramEnvParameter4dvARB);
+ SET_ProgramEnvParameter4fARB(exec, _mesa_ProgramEnvParameter4fARB);
+ SET_ProgramEnvParameter4fvARB(exec, _mesa_ProgramEnvParameter4fvARB);
+ SET_ProgramLocalParameter4dARB(exec, _mesa_ProgramLocalParameter4dARB);
+ SET_ProgramLocalParameter4dvARB(exec, _mesa_ProgramLocalParameter4dvARB);
+ SET_ProgramLocalParameter4fARB(exec, _mesa_ProgramLocalParameter4fARB);
+ SET_ProgramLocalParameter4fvARB(exec, _mesa_ProgramLocalParameter4fvARB);
+ SET_GetProgramEnvParameterdvARB(exec, _mesa_GetProgramEnvParameterdvARB);
+ SET_GetProgramEnvParameterfvARB(exec, _mesa_GetProgramEnvParameterfvARB);
+ SET_GetProgramLocalParameterdvARB(exec, _mesa_GetProgramLocalParameterdvARB);
+ SET_GetProgramLocalParameterfvARB(exec, _mesa_GetProgramLocalParameterfvARB);
+ SET_GetProgramivARB(exec, _mesa_GetProgramivARB);
+ SET_GetProgramStringARB(exec, _mesa_GetProgramStringARB);
+#endif
+
+ /* ARB 28. GL_ARB_vertex_buffer_object */
+#if FEATURE_ARB_vertex_buffer_object
+ SET_BindBufferARB(exec, _mesa_BindBufferARB);
+ SET_BufferDataARB(exec, _mesa_BufferDataARB);
+ SET_BufferSubDataARB(exec, _mesa_BufferSubDataARB);
+ SET_DeleteBuffersARB(exec, _mesa_DeleteBuffersARB);
+ SET_GenBuffersARB(exec, _mesa_GenBuffersARB);
+ SET_GetBufferParameterivARB(exec, _mesa_GetBufferParameterivARB);
+ SET_GetBufferPointervARB(exec, _mesa_GetBufferPointervARB);
+ SET_GetBufferSubDataARB(exec, _mesa_GetBufferSubDataARB);
+ SET_IsBufferARB(exec, _mesa_IsBufferARB);
+ SET_MapBufferARB(exec, _mesa_MapBufferARB);
+ SET_UnmapBufferARB(exec, _mesa_UnmapBufferARB);
+#endif
+
+ /* ARB 29. GL_ARB_occlusion_query */
+#if FEATURE_ARB_occlusion_query
+ SET_GenQueriesARB(exec, _mesa_GenQueriesARB);
+ SET_DeleteQueriesARB(exec, _mesa_DeleteQueriesARB);
+ SET_IsQueryARB(exec, _mesa_IsQueryARB);
+ SET_BeginQueryARB(exec, _mesa_BeginQueryARB);
+ SET_EndQueryARB(exec, _mesa_EndQueryARB);
+ SET_GetQueryivARB(exec, _mesa_GetQueryivARB);
+ SET_GetQueryObjectivARB(exec, _mesa_GetQueryObjectivARB);
+ SET_GetQueryObjectuivARB(exec, _mesa_GetQueryObjectuivARB);
+#endif
+
+ /* ARB 37. GL_ARB_draw_buffers */
+ SET_DrawBuffersARB(exec, _mesa_DrawBuffersARB);
+
+#if FEATURE_ARB_shader_objects
+ SET_DeleteObjectARB(exec, _mesa_DeleteObjectARB);
+ SET_GetHandleARB(exec, _mesa_GetHandleARB);
+ SET_DetachObjectARB(exec, _mesa_DetachObjectARB);
+ SET_CreateShaderObjectARB(exec, _mesa_CreateShaderObjectARB);
+ SET_ShaderSourceARB(exec, _mesa_ShaderSourceARB);
+ SET_CompileShaderARB(exec, _mesa_CompileShaderARB);
+ SET_CreateProgramObjectARB(exec, _mesa_CreateProgramObjectARB);
+ SET_AttachObjectARB(exec, _mesa_AttachObjectARB);
+ SET_LinkProgramARB(exec, _mesa_LinkProgramARB);
+ SET_UseProgramObjectARB(exec, _mesa_UseProgramObjectARB);
+ SET_ValidateProgramARB(exec, _mesa_ValidateProgramARB);
+ SET_Uniform1fARB(exec, _mesa_Uniform1fARB);
+ SET_Uniform2fARB(exec, _mesa_Uniform2fARB);
+ SET_Uniform3fARB(exec, _mesa_Uniform3fARB);
+ SET_Uniform4fARB(exec, _mesa_Uniform4fARB);
+ SET_Uniform1iARB(exec, _mesa_Uniform1iARB);
+ SET_Uniform2iARB(exec, _mesa_Uniform2iARB);
+ SET_Uniform3iARB(exec, _mesa_Uniform3iARB);
+ SET_Uniform4iARB(exec, _mesa_Uniform4iARB);
+ SET_Uniform1fvARB(exec, _mesa_Uniform1fvARB);
+ SET_Uniform2fvARB(exec, _mesa_Uniform2fvARB);
+ SET_Uniform3fvARB(exec, _mesa_Uniform3fvARB);
+ SET_Uniform4fvARB(exec, _mesa_Uniform4fvARB);
+ SET_Uniform1ivARB(exec, _mesa_Uniform1ivARB);
+ SET_Uniform2ivARB(exec, _mesa_Uniform2ivARB);
+ SET_Uniform3ivARB(exec, _mesa_Uniform3ivARB);
+ SET_Uniform4ivARB(exec, _mesa_Uniform4ivARB);
+ SET_UniformMatrix2fvARB(exec, _mesa_UniformMatrix2fvARB);
+ SET_UniformMatrix3fvARB(exec, _mesa_UniformMatrix3fvARB);
+ SET_UniformMatrix4fvARB(exec, _mesa_UniformMatrix4fvARB);
+ SET_GetObjectParameterfvARB(exec, _mesa_GetObjectParameterfvARB);
+ SET_GetObjectParameterivARB(exec, _mesa_GetObjectParameterivARB);
+ SET_GetInfoLogARB(exec, _mesa_GetInfoLogARB);
+ SET_GetAttachedObjectsARB(exec, _mesa_GetAttachedObjectsARB);
+ SET_GetUniformLocationARB(exec, _mesa_GetUniformLocationARB);
+ SET_GetActiveUniformARB(exec, _mesa_GetActiveUniformARB);
+ SET_GetUniformfvARB(exec, _mesa_GetUniformfvARB);
+ SET_GetUniformivARB(exec, _mesa_GetUniformivARB);
+ SET_GetShaderSourceARB(exec, _mesa_GetShaderSourceARB);
+#endif /* FEATURE_ARB_shader_objects */
+
+#if FEATURE_ARB_vertex_shader
+ SET_BindAttribLocationARB(exec, _mesa_BindAttribLocationARB);
+ SET_GetActiveAttribARB(exec, _mesa_GetActiveAttribARB);
+ SET_GetAttribLocationARB(exec, _mesa_GetAttribLocationARB);
+#endif /* FEATURE_ARB_vertex_shader */
+
+ /* GL_ATI_fragment_shader */
+#if FEATURE_ATI_fragment_shader
+ SET_GenFragmentShadersATI(exec, _mesa_GenFragmentShadersATI);
+ SET_BindFragmentShaderATI(exec, _mesa_BindFragmentShaderATI);
+ SET_DeleteFragmentShaderATI(exec, _mesa_DeleteFragmentShaderATI);
+ SET_BeginFragmentShaderATI(exec, _mesa_BeginFragmentShaderATI);
+ SET_EndFragmentShaderATI(exec, _mesa_EndFragmentShaderATI);
+ SET_PassTexCoordATI(exec, _mesa_PassTexCoordATI);
+ SET_SampleMapATI(exec, _mesa_SampleMapATI);
+ SET_ColorFragmentOp1ATI(exec, _mesa_ColorFragmentOp1ATI);
+ SET_ColorFragmentOp2ATI(exec, _mesa_ColorFragmentOp2ATI);
+ SET_ColorFragmentOp3ATI(exec, _mesa_ColorFragmentOp3ATI);
+ SET_AlphaFragmentOp1ATI(exec, _mesa_AlphaFragmentOp1ATI);
+ SET_AlphaFragmentOp2ATI(exec, _mesa_AlphaFragmentOp2ATI);
+ SET_AlphaFragmentOp3ATI(exec, _mesa_AlphaFragmentOp3ATI);
+ SET_SetFragmentShaderConstantATI(exec, _mesa_SetFragmentShaderConstantATI);
+#endif
+
+#if FEATURE_EXT_framebuffer_object
+ SET_IsRenderbufferEXT(exec, _mesa_IsRenderbufferEXT);
+ SET_BindRenderbufferEXT(exec, _mesa_BindRenderbufferEXT);
+ SET_DeleteRenderbuffersEXT(exec, _mesa_DeleteRenderbuffersEXT);
+ SET_GenRenderbuffersEXT(exec, _mesa_GenRenderbuffersEXT);
+ SET_RenderbufferStorageEXT(exec, _mesa_RenderbufferStorageEXT);
+ SET_GetRenderbufferParameterivEXT(exec, _mesa_GetRenderbufferParameterivEXT);
+ SET_IsFramebufferEXT(exec, _mesa_IsFramebufferEXT);
+ SET_BindFramebufferEXT(exec, _mesa_BindFramebufferEXT);
+ SET_DeleteFramebuffersEXT(exec, _mesa_DeleteFramebuffersEXT);
+ SET_GenFramebuffersEXT(exec, _mesa_GenFramebuffersEXT);
+ SET_CheckFramebufferStatusEXT(exec, _mesa_CheckFramebufferStatusEXT);
+ SET_FramebufferTexture1DEXT(exec, _mesa_FramebufferTexture1DEXT);
+ SET_FramebufferTexture2DEXT(exec, _mesa_FramebufferTexture2DEXT);
+ SET_FramebufferTexture3DEXT(exec, _mesa_FramebufferTexture3DEXT);
+ SET_FramebufferRenderbufferEXT(exec, _mesa_FramebufferRenderbufferEXT);
+ SET_GetFramebufferAttachmentParameterivEXT(exec, _mesa_GetFramebufferAttachmentParameterivEXT);
+ SET_GenerateMipmapEXT(exec, _mesa_GenerateMipmapEXT);
+#endif
+}
+
+
+
+/**********************************************************************/
+/** \name State update logic */
+/*@{*/
+
+
+static void
+update_separate_specular( GLcontext *ctx )
+{
+ if (NEED_SECONDARY_COLOR(ctx))
+ ctx->_TriangleCaps |= DD_SEPARATE_SPECULAR;
+ else
+ ctx->_TriangleCaps &= ~DD_SEPARATE_SPECULAR;
+}
+
+
+/**
+ * Update state dependent on vertex arrays.
+ */
+static void
+update_arrays( GLcontext *ctx )
+{
+ GLuint i, min;
+
+ /* find min of _MaxElement values for all enabled arrays */
+
+ /* 0 */
+ if (ctx->VertexProgram._Enabled
+ && ctx->Array.VertexAttrib[VERT_ATTRIB_POS].Enabled) {
+ min = ctx->Array.VertexAttrib[VERT_ATTRIB_POS]._MaxElement;
+ }
+ else if (ctx->Array.Vertex.Enabled) {
+ min = ctx->Array.Vertex._MaxElement;
+ }
+ else {
+ /* can't draw anything without vertex positions! */
+ min = 0;
+ }
+
+ /* 1 */
+ if (ctx->VertexProgram._Enabled
+ && ctx->Array.VertexAttrib[VERT_ATTRIB_WEIGHT].Enabled) {
+ min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_WEIGHT]._MaxElement);
+ }
+ /* no conventional vertex weight array */
+
+ /* 2 */
+ if (ctx->VertexProgram._Enabled
+ && ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL].Enabled) {
+ min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_NORMAL]._MaxElement);
+ }
+ else if (ctx->Array.Normal.Enabled) {
+ min = MIN2(min, ctx->Array.Normal._MaxElement);
+ }
+
+ /* 3 */
+ if (ctx->VertexProgram._Enabled
+ && ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR0].Enabled) {
+ min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR0]._MaxElement);
+ }
+ else if (ctx->Array.Color.Enabled) {
+ min = MIN2(min, ctx->Array.Color._MaxElement);
+ }
+
+ /* 4 */
+ if (ctx->VertexProgram._Enabled
+ && ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR1].Enabled) {
+ min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_COLOR1]._MaxElement);
+ }
+ else if (ctx->Array.SecondaryColor.Enabled) {
+ min = MIN2(min, ctx->Array.SecondaryColor._MaxElement);
+ }
+
+ /* 5 */
+ if (ctx->VertexProgram._Enabled
+ && ctx->Array.VertexAttrib[VERT_ATTRIB_FOG].Enabled) {
+ min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_FOG]._MaxElement);
+ }
+ else if (ctx->Array.FogCoord.Enabled) {
+ min = MIN2(min, ctx->Array.FogCoord._MaxElement);
+ }
+
+ /* 6 */
+ if (ctx->VertexProgram._Enabled
+ && ctx->Array.VertexAttrib[VERT_ATTRIB_SIX].Enabled) {
+ min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_SIX]._MaxElement);
+ }
+
+ /* 7 */
+ if (ctx->VertexProgram._Enabled
+ && ctx->Array.VertexAttrib[VERT_ATTRIB_SEVEN].Enabled) {
+ min = MIN2(min, ctx->Array.VertexAttrib[VERT_ATTRIB_SEVEN]._MaxElement);
+ }
+
+ /* 8..15 */
+ for (i = VERT_ATTRIB_TEX0; i < VERT_ATTRIB_MAX; i++) {
+ if (ctx->VertexProgram._Enabled
+ && ctx->Array.VertexAttrib[i].Enabled) {
+ min = MIN2(min, ctx->Array.VertexAttrib[i]._MaxElement);
+ }
+ else if (i - VERT_ATTRIB_TEX0 < ctx->Const.MaxTextureCoordUnits
+ && ctx->Array.TexCoord[i - VERT_ATTRIB_TEX0].Enabled) {
+ min = MIN2(min, ctx->Array.TexCoord[i - VERT_ATTRIB_TEX0]._MaxElement);
+ }
+ }
+
+ if (ctx->Array.Index.Enabled) {
+ min = MIN2(min, ctx->Array.Index._MaxElement);
+ }
+
+ if (ctx->Array.EdgeFlag.Enabled) {
+ min = MIN2(min, ctx->Array.EdgeFlag._MaxElement);
+ }
+
+ /* _MaxElement is one past the last legal array element */
+ ctx->Array._MaxElement = min;
+}
+
+
+/**
+ * Update derived vertex/fragment program state.
+ */
+static void
+update_program(GLcontext *ctx)
+{
+ /* For now, just set the _Enabled (really enabled) flags.
+ * In the future we may have to check other state to be sure we really
+ * have a runable program or shader.
+ */
+ ctx->VertexProgram._Enabled = ctx->VertexProgram.Enabled
+ && ctx->VertexProgram.Current->Instructions;
+ ctx->FragmentProgram._Enabled = ctx->FragmentProgram.Enabled
+ && ctx->FragmentProgram.Current->Instructions;
+ ctx->ATIFragmentShader._Enabled = ctx->ATIFragmentShader.Enabled
+ && ctx->ATIFragmentShader.Current->Instructions;
+
+ ctx->FragmentProgram._Current = ctx->FragmentProgram.Current;
+ ctx->FragmentProgram._Active = ctx->FragmentProgram._Enabled;
+
+ if (ctx->_MaintainTexEnvProgram && !ctx->FragmentProgram._Enabled) {
+ if (!ctx->_TexEnvProgram)
+ ctx->_TexEnvProgram = (struct fragment_program *)
+ ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
+
+ ctx->FragmentProgram._Current = ctx->_TexEnvProgram;
+ ctx->FragmentProgram._Active = GL_TRUE;
+ }
+}
+
+
+/**
+ * If __GLcontextRec::NewState is non-zero then this function \b must be called
+ * before rendering any primitive. Basically, function pointers and
+ * miscellaneous flags are updated to reflect the current state of the state
+ * machine.
+ *
+ * Calls dd_function_table::UpdateState to perform any internal state
+ * management necessary.
+ *
+ * \sa _mesa_update_modelview_project(), _mesa_update_texture(),
+ * _mesa_update_buffer_bounds(), _mesa_update_polygon(),
+ * _mesa_update_lighting() and _mesa_update_tnl_spaces().
+ */
+void
+_mesa_update_state( GLcontext *ctx )
+{
+ GLuint new_state = ctx->NewState;
+
+ if (MESA_VERBOSE & VERBOSE_STATE)
+ _mesa_print_state("_mesa_update_state", new_state);
+
+ if (new_state & _NEW_PROGRAM)
+ update_program( ctx );
+
+ if (new_state & (_NEW_MODELVIEW|_NEW_PROJECTION))
+ _mesa_update_modelview_project( ctx, new_state );
+
+ if (new_state & (_NEW_PROGRAM|_NEW_TEXTURE|_NEW_TEXTURE_MATRIX))
+ _mesa_update_texture( ctx, new_state );
+
+ if (new_state & (_NEW_BUFFERS | _NEW_COLOR | _NEW_PIXEL))
+ _mesa_update_framebuffer(ctx);
+
+ if (new_state & (_NEW_SCISSOR | _NEW_BUFFERS | _NEW_VIEWPORT))
+ _mesa_update_draw_buffer_bounds( ctx );
+
+ if (new_state & _NEW_POINT)
+ _mesa_update_point( ctx );
+
+ if (new_state & _NEW_POLYGON)
+ _mesa_update_polygon( ctx );
+
+ if (new_state & _NEW_LIGHT)
+ _mesa_update_lighting( ctx );
+
+ if (new_state & _IMAGE_NEW_TRANSFER_STATE)
+ _mesa_update_pixel( ctx, new_state );
+
+ if (new_state & _DD_NEW_SEPARATE_SPECULAR)
+ update_separate_specular( ctx );
+
+ if (new_state & (_NEW_ARRAY | _NEW_PROGRAM))
+ update_arrays( ctx );
+
+ if (ctx->_MaintainTexEnvProgram) {
+ if (new_state & (_NEW_TEXTURE | _DD_NEW_SEPARATE_SPECULAR | _NEW_FOG))
+ _mesa_UpdateTexEnvProgram(ctx);
+ }
+
+ /* ctx->_NeedEyeCoords is now up to date.
+ *
+ * If the truth value of this variable has changed, update for the
+ * new lighting space and recompute the positions of lights and the
+ * normal transform.
+ *
+ * If the lighting space hasn't changed, may still need to recompute
+ * light positions & normal transforms for other reasons.
+ */
+ if (new_state & _MESA_NEW_NEED_EYE_COORDS)
+ _mesa_update_tnl_spaces( ctx, new_state );
+
+ /*
+ * Give the driver a chance to act upon the new_state flags.
+ * The driver might plug in different span functions, for example.
+ * Also, this is where the driver can invalidate the state of any
+ * active modules (such as swrast_setup, swrast, tnl, etc).
+ *
+ * Set ctx->NewState to zero to avoid recursion if
+ * Driver.UpdateState() has to call FLUSH_VERTICES(). (fixed?)
+ */
+ new_state = ctx->NewState;
+ ctx->NewState = 0;
+ ctx->Driver.UpdateState(ctx, new_state);
+ ctx->Array.NewState = 0;
+}
+
+/*@}*/
diff --git a/nx-X11/extras/Mesa/src/mesa/main/state.h b/nx-X11/extras/Mesa/src/mesa/main/state.h
new file mode 100644
index 000000000..58cfcc414
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/state.h
@@ -0,0 +1,43 @@
+/**
+ * \file state.h
+ * State management.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef STATE_H
+#define STATE_H
+
+#include "mtypes.h"
+
+extern void
+_mesa_init_exec_table(struct _glapi_table *exec);
+
+extern void
+_mesa_update_state( GLcontext *ctx );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/stencil.c b/nx-X11/extras/Mesa/src/mesa/main/stencil.c
new file mode 100644
index 000000000..dfda4aa8f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/stencil.c
@@ -0,0 +1,466 @@
+/**
+ * \file stencil.c
+ * Stencil operations.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "depth.h"
+#include "macros.h"
+#include "stencil.h"
+#include "mtypes.h"
+#include "enable.h"
+
+
+/**
+ * Set the clear value for the stencil buffer.
+ *
+ * \param s clear value.
+ *
+ * \sa glClearStencil().
+ *
+ * Updates gl_stencil_attrib::Clear. On change
+ * flushes the vertices and notifies the driver via
+ * the dd_function_table::ClearStencil callback.
+ */
+void GLAPIENTRY
+_mesa_ClearStencil( GLint s )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (ctx->Stencil.Clear == (GLstencil) s)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_STENCIL);
+ ctx->Stencil.Clear = (GLstencil) s;
+
+ if (ctx->Driver.ClearStencil) {
+ (*ctx->Driver.ClearStencil)( ctx, s );
+ }
+}
+
+
+/**
+ * Set the function and reference value for stencil testing.
+ *
+ * \param func test function.
+ * \param ref reference value.
+ * \param mask bitmask.
+ *
+ * \sa glStencilFunc().
+ *
+ * Verifies the parameters and updates the respective values in
+ * __GLcontextRec::Stencil. On change flushes the vertices and notifies the
+ * driver via the dd_function_table::StencilFunc callback.
+ */
+void GLAPIENTRY
+_mesa_StencilFunc( GLenum func, GLint ref, GLuint mask )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ const GLint face = ctx->Stencil.ActiveFace;
+ GLint maxref;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ switch (func) {
+ case GL_NEVER:
+ case GL_LESS:
+ case GL_LEQUAL:
+ case GL_GREATER:
+ case GL_GEQUAL:
+ case GL_EQUAL:
+ case GL_NOTEQUAL:
+ case GL_ALWAYS:
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glStencilFunc" );
+ return;
+ }
+
+ maxref = (1 << STENCIL_BITS) - 1;
+ ref = (GLstencil) CLAMP( ref, 0, maxref );
+
+ if (ctx->Stencil.Function[face] == func &&
+ ctx->Stencil.ValueMask[face] == (GLstencil) mask &&
+ ctx->Stencil.Ref[face] == ref)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_STENCIL);
+ ctx->Stencil.Function[face] = func;
+ ctx->Stencil.Ref[face] = ref;
+ ctx->Stencil.ValueMask[face] = (GLstencil) mask;
+
+ if (ctx->Driver.StencilFunc) {
+ (*ctx->Driver.StencilFunc)( ctx, func, ref, mask );
+ }
+}
+
+
+/**
+ * Set the stencil writing mask.
+ *
+ * \param mask bit-mask to enable/disable writing of individual bits in the
+ * stencil planes.
+ *
+ * \sa glStencilMask().
+ *
+ * Updates gl_stencil_attrib::WriteMask. On change flushes the vertices and
+ * notifies the driver via the dd_function_table::StencilMask callback.
+ */
+void GLAPIENTRY
+_mesa_StencilMask( GLuint mask )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ const GLint face = ctx->Stencil.ActiveFace;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (ctx->Stencil.WriteMask[face] == (GLstencil) mask)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_STENCIL);
+ ctx->Stencil.WriteMask[face] = (GLstencil) mask;
+
+ if (ctx->Driver.StencilMask) {
+ (*ctx->Driver.StencilMask)( ctx, mask );
+ }
+}
+
+
+/**
+ * Set the stencil test actions.
+ *
+ * \param fail action to take when stencil test fails.
+ * \param zfail action to take when stencil test passes, but the depth test fails.
+ * \param zpass action to take when stencil test passes and the depth test
+ * passes (or depth testing is not enabled).
+ *
+ * \sa glStencilOp().
+ *
+ * Verifies the parameters and updates the respective fields in
+ * __GLcontextRec::Stencil. On change flushes the vertices and notifies the
+ * driver via the dd_function_table::StencilOp callback.
+ */
+void GLAPIENTRY
+_mesa_StencilOp(GLenum fail, GLenum zfail, GLenum zpass)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ const GLint face = ctx->Stencil.ActiveFace;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ switch (fail) {
+ case GL_KEEP:
+ case GL_ZERO:
+ case GL_REPLACE:
+ case GL_INCR:
+ case GL_DECR:
+ case GL_INVERT:
+ break;
+ case GL_INCR_WRAP_EXT:
+ case GL_DECR_WRAP_EXT:
+ if (ctx->Extensions.EXT_stencil_wrap) {
+ break;
+ }
+ /* FALL-THROUGH */
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp");
+ return;
+ }
+ switch (zfail) {
+ case GL_KEEP:
+ case GL_ZERO:
+ case GL_REPLACE:
+ case GL_INCR:
+ case GL_DECR:
+ case GL_INVERT:
+ break;
+ case GL_INCR_WRAP_EXT:
+ case GL_DECR_WRAP_EXT:
+ if (ctx->Extensions.EXT_stencil_wrap) {
+ break;
+ }
+ /* FALL-THROUGH */
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp");
+ return;
+ }
+ switch (zpass) {
+ case GL_KEEP:
+ case GL_ZERO:
+ case GL_REPLACE:
+ case GL_INCR:
+ case GL_DECR:
+ case GL_INVERT:
+ break;
+ case GL_INCR_WRAP_EXT:
+ case GL_DECR_WRAP_EXT:
+ if (ctx->Extensions.EXT_stencil_wrap) {
+ break;
+ }
+ /* FALL-THROUGH */
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOp");
+ return;
+ }
+
+ if (ctx->Stencil.ZFailFunc[face] == zfail &&
+ ctx->Stencil.ZPassFunc[face] == zpass &&
+ ctx->Stencil.FailFunc[face] == fail)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_STENCIL);
+ ctx->Stencil.ZFailFunc[face] = zfail;
+ ctx->Stencil.ZPassFunc[face] = zpass;
+ ctx->Stencil.FailFunc[face] = fail;
+
+ if (ctx->Driver.StencilOp) {
+ (*ctx->Driver.StencilOp)(ctx, fail, zfail, zpass);
+ }
+}
+
+
+
+#if _HAVE_FULL_GL
+/* GL_EXT_stencil_two_side */
+void GLAPIENTRY
+_mesa_ActiveStencilFaceEXT(GLenum face)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (face == GL_FRONT || face == GL_BACK) {
+ FLUSH_VERTICES(ctx, _NEW_STENCIL);
+ ctx->Stencil.ActiveFace = (face == GL_FRONT) ? 0 : 1;
+ }
+
+ if (ctx->Driver.ActiveStencilFace) {
+ (*ctx->Driver.ActiveStencilFace)( ctx, (GLuint) ctx->Stencil.ActiveFace );
+ }
+}
+#endif
+
+
+
+/**
+ * OpenGL 2.0 function.
+ * \todo Make StencilOp() call this function. And eventually remove the
+ * ctx->Driver.StencilOp function and use ctx->Driver.StencilOpSeparate
+ * instead.
+ */
+void GLAPIENTRY
+_mesa_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(face)");
+ return;
+ }
+
+ switch (fail) {
+ case GL_KEEP:
+ case GL_ZERO:
+ case GL_REPLACE:
+ case GL_INCR:
+ case GL_DECR:
+ case GL_INVERT:
+ break;
+ case GL_INCR_WRAP_EXT:
+ case GL_DECR_WRAP_EXT:
+ if (ctx->Extensions.EXT_stencil_wrap) {
+ break;
+ }
+ /* FALL-THROUGH */
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(fail)");
+ return;
+ }
+ switch (zfail) {
+ case GL_KEEP:
+ case GL_ZERO:
+ case GL_REPLACE:
+ case GL_INCR:
+ case GL_DECR:
+ case GL_INVERT:
+ break;
+ case GL_INCR_WRAP_EXT:
+ case GL_DECR_WRAP_EXT:
+ if (ctx->Extensions.EXT_stencil_wrap) {
+ break;
+ }
+ /* FALL-THROUGH */
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(zfail)");
+ return;
+ }
+ switch (zpass) {
+ case GL_KEEP:
+ case GL_ZERO:
+ case GL_REPLACE:
+ case GL_INCR:
+ case GL_DECR:
+ case GL_INVERT:
+ break;
+ case GL_INCR_WRAP_EXT:
+ case GL_DECR_WRAP_EXT:
+ if (ctx->Extensions.EXT_stencil_wrap) {
+ break;
+ }
+ /* FALL-THROUGH */
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glStencilOpSeparate(zpass)");
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_STENCIL);
+
+ if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
+ ctx->Stencil.FailFunc[0] = fail;
+ ctx->Stencil.ZFailFunc[0] = zfail;
+ ctx->Stencil.ZPassFunc[0] = zpass;
+ }
+ if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
+ ctx->Stencil.FailFunc[1] = fail;
+ ctx->Stencil.ZFailFunc[1] = zfail;
+ ctx->Stencil.ZPassFunc[1] = zpass;
+ }
+
+ if (ctx->Driver.StencilOpSeparate) {
+ ctx->Driver.StencilOpSeparate(ctx, face, fail, zfail, zpass);
+ }
+}
+
+
+/* OpenGL 2.0 */
+void GLAPIENTRY
+_mesa_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint maxref;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFuncSeparate(face)");
+ return;
+ }
+
+ switch (func) {
+ case GL_NEVER:
+ case GL_LESS:
+ case GL_LEQUAL:
+ case GL_GREATER:
+ case GL_GEQUAL:
+ case GL_EQUAL:
+ case GL_NOTEQUAL:
+ case GL_ALWAYS:
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glStencilFuncSeparate(func)");
+ return;
+ }
+
+ maxref = (1 << STENCIL_BITS) - 1;
+ ref = (GLstencil) CLAMP(ref, 0, maxref);
+
+ FLUSH_VERTICES(ctx, _NEW_STENCIL);
+
+ if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
+ ctx->Stencil.Function[0] = func;
+ ctx->Stencil.Ref[0] = ref;
+ ctx->Stencil.ValueMask[0] = (GLstencil) mask;
+ }
+ if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
+ ctx->Stencil.Function[1] = func;
+ ctx->Stencil.Ref[1] = ref;
+ ctx->Stencil.ValueMask[1] = (GLstencil) mask;
+ }
+
+ if (ctx->Driver.StencilFuncSeparate) {
+ ctx->Driver.StencilFuncSeparate(ctx, face, func, ref, mask);
+ }
+}
+
+
+/* OpenGL 2.0 */
+void GLAPIENTRY
+_mesa_StencilMaskSeparate(GLenum face, GLuint mask)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (face != GL_FRONT && face != GL_BACK && face != GL_FRONT_AND_BACK) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glStencilaMaskSeparate(face)");
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_STENCIL);
+
+ if (face == GL_FRONT || face == GL_FRONT_AND_BACK) {
+ ctx->Stencil.WriteMask[0] = (GLstencil) mask;
+ }
+ if (face == GL_BACK || face == GL_FRONT_AND_BACK) {
+ ctx->Stencil.WriteMask[1] = (GLstencil) mask;
+ }
+
+ if (ctx->Driver.StencilMaskSeparate) {
+ ctx->Driver.StencilMaskSeparate(ctx, face, mask);
+ }
+}
+
+
+/**
+ * Initialize the context stipple state.
+ *
+ * \param ctx GL context.
+ *
+ * Initializes __GLcontextRec::Stencil attribute group.
+ */
+void _mesa_init_stencil( GLcontext * ctx )
+{
+
+ /* Stencil group */
+ ctx->Stencil.Enabled = GL_FALSE;
+ ctx->Stencil.TestTwoSide = GL_FALSE;
+ ctx->Stencil.ActiveFace = 0; /* 0 = GL_FRONT, 1 = GL_BACK */
+ ctx->Stencil.Function[0] = GL_ALWAYS;
+ ctx->Stencil.Function[1] = GL_ALWAYS;
+ ctx->Stencil.FailFunc[0] = GL_KEEP;
+ ctx->Stencil.FailFunc[1] = GL_KEEP;
+ ctx->Stencil.ZPassFunc[0] = GL_KEEP;
+ ctx->Stencil.ZPassFunc[1] = GL_KEEP;
+ ctx->Stencil.ZFailFunc[0] = GL_KEEP;
+ ctx->Stencil.ZFailFunc[1] = GL_KEEP;
+ ctx->Stencil.Ref[0] = 0;
+ ctx->Stencil.Ref[1] = 0;
+ ctx->Stencil.ValueMask[0] = STENCIL_MAX;
+ ctx->Stencil.ValueMask[1] = STENCIL_MAX;
+ ctx->Stencil.WriteMask[0] = STENCIL_MAX;
+ ctx->Stencil.WriteMask[1] = STENCIL_MAX;
+ ctx->Stencil.Clear = 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/stencil.h b/nx-X11/extras/Mesa/src/mesa/main/stencil.h
new file mode 100644
index 000000000..ec2927cfd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/stencil.h
@@ -0,0 +1,73 @@
+/**
+ * \file stencil.h
+ * Stencil operations.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef STENCIL_H
+#define STENCIL_H
+
+
+#include "mtypes.h"
+
+
+extern void GLAPIENTRY
+_mesa_ClearStencil( GLint s );
+
+
+extern void GLAPIENTRY
+_mesa_StencilFunc( GLenum func, GLint ref, GLuint mask );
+
+
+extern void GLAPIENTRY
+_mesa_StencilMask( GLuint mask );
+
+
+extern void GLAPIENTRY
+_mesa_StencilOp( GLenum fail, GLenum zfail, GLenum zpass );
+
+
+extern void GLAPIENTRY
+_mesa_ActiveStencilFaceEXT(GLenum face);
+
+
+extern void GLAPIENTRY
+_mesa_StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass);
+
+
+extern void GLAPIENTRY
+_mesa_StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask);
+
+
+extern void GLAPIENTRY
+_mesa_StencilMaskSeparate(GLenum face, GLuint mask);
+
+
+extern void
+_mesa_init_stencil( GLcontext * ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/texcompress.c b/nx-X11/extras/Mesa/src/mesa/main/texcompress.c
new file mode 100644
index 000000000..d18b1d0b4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/texcompress.c
@@ -0,0 +1,254 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file texcompress.c
+ * Helper functions for texture compression.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "colormac.h"
+#include "context.h"
+#include "image.h"
+#include "texcompress.h"
+#include "texformat.h"
+#include "texstore.h"
+
+/**
+ * Get the list of supported internal compression formats.
+ *
+ * \param ctx GL context.
+ * \param formats the resulting format list (may be NULL).
+ *
+ * \return number of formats.
+ */
+GLuint
+_mesa_get_compressed_formats( GLcontext *ctx, GLint *formats )
+{
+ GLuint n = 0;
+ if (ctx->Extensions.ARB_texture_compression) {
+ if (ctx->Extensions.TDFX_texture_compression_FXT1) {
+ if (formats) {
+ formats[n++] = GL_COMPRESSED_RGB_FXT1_3DFX;
+ formats[n++] = GL_COMPRESSED_RGBA_FXT1_3DFX;
+ }
+ else {
+ n += 2;
+ }
+ }
+ if (ctx->Extensions.EXT_texture_compression_s3tc) {
+ if (formats) {
+ formats[n++] = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
+ /* Skip this one because it has a restriction (all transparent
+ * pixels become black). See the texture compressions spec for
+ * a detailed explanation. This is what NVIDIA does.
+ formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
+ */
+ formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
+ formats[n++] = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
+ }
+ else {
+ n += 3;
+ }
+ }
+ if (ctx->Extensions.S3_s3tc) {
+ if (formats) {
+ formats[n++] = GL_RGB_S3TC;
+ formats[n++] = GL_RGB4_S3TC;
+ formats[n++] = GL_RGBA_S3TC;
+ formats[n++] = GL_RGBA4_S3TC;
+ }
+ else {
+ n += 4;
+ }
+ }
+ }
+ return n;
+}
+
+
+
+/**
+ * Return number of bytes needed to store a texture of the given size
+ * using the specified compressed format.
+ * This is called via the ctx->Driver.CompressedTextureSize function,
+ * unless a device driver overrides it.
+ *
+ * \param width texture width in texels.
+ * \param height texture height in texels.
+ * \param depth texture depth in texels.
+ * \param format - one of the specific compressed texture formats
+ *
+ * \return size in bytes, or zero if bad format
+ */
+GLuint
+_mesa_compressed_texture_size( GLcontext *ctx,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format )
+{
+ GLuint size;
+
+ ASSERT(depth == 1);
+ (void) depth;
+
+ switch (format) {
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ /* round up width to next multiple of 8, height to next multiple of 4 */
+ width = (width + 7) & ~7;
+ height = (height + 3) & ~3;
+ /* 16 bytes per 8x4 tile of RGB[A] texels */
+ size = width * height / 2;
+ /* Textures smaller than 8x4 will effectively be made into 8x4 and
+ * take 16 bytes.
+ */
+ if (size < 16)
+ size = 16;
+ return size;
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ /* round up width, height to next multiple of 4 */
+ width = (width + 3) & ~3;
+ height = (height + 3) & ~3;
+ /* 8 bytes per 4x4 tile of RGB[A] texels */
+ size = width * height / 2;
+ /* Textures smaller than 4x4 will effectively be made into 4x4 and
+ * take 8 bytes.
+ */
+ if (size < 8)
+ size = 8;
+ return size;
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ /* round up width, height to next multiple of 4 */
+ width = (width + 3) & ~3;
+ height = (height + 3) & ~3;
+ /* 16 bytes per 4x4 tile of RGBA texels */
+ size = width * height; /* simple! */
+ /* Textures smaller than 4x4 will effectively be made into 4x4 and
+ * take 16 bytes.
+ */
+ if (size < 16)
+ size = 16;
+ return size;
+ default:
+ _mesa_problem(ctx, "bad texformat in compressed_texture_size");
+ return 0;
+ }
+}
+
+
+/*
+ * Compute the bytes per row in a compressed texture image.
+ * We use this for computing the destination address for sub-texture updates.
+ * \param format one of the specific texture compression formats
+ * \param width image width in pixels
+ * \return stride, in bytes, between rows for compressed image
+ */
+GLint
+_mesa_compressed_row_stride(GLenum format, GLsizei width)
+{
+ GLint stride;
+
+ switch (format) {
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ stride = ((width + 7) / 8) * 16; /* 16 bytes per 8x4 tile */
+ break;
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ stride = ((width + 3) / 4) * 8; /* 8 bytes per 4x4 tile */
+ break;
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ stride = ((width + 3) / 4) * 16; /* 16 bytes per 4x4 tile */
+ break;
+ default:
+ return 0;
+ }
+
+ return stride;
+}
+
+
+/*
+ * Return the address of the pixel at (col, row, img) in a
+ * compressed texture image.
+ * \param col, row, img - image position (3D)
+ * \param format - compressed image format
+ * \param width - image width
+ * \param image - the image address
+ * \return address of pixel at (row, col)
+ */
+GLubyte *
+_mesa_compressed_image_address(GLint col, GLint row, GLint img,
+ GLenum format,
+ GLsizei width, const GLubyte *image)
+{
+ GLubyte *addr;
+
+ (void) img;
+
+ /* We try to spot a "complete" subtexture "above" ROW, COL;
+ * this texture is given by appropriate rounding of WIDTH x ROW.
+ * Then we just add the amount left (usually on the left).
+ *
+ * Example for X*Y microtiles (Z bytes each)
+ * offset = Z * (((width + X - 1) / X) * (row / Y) + col / X);
+ */
+
+ switch (format) {
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ addr = (GLubyte *) image + 16 * (((width + 7) / 8) * (row / 4) + col / 8);
+ break;
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ addr = (GLubyte *) image + 8 * (((width + 3) / 4) * (row / 4) + col / 4);
+ break;
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ addr = (GLubyte *) image + 16 * (((width + 3) / 4) * (row / 4) + col / 4);
+ break;
+ default:
+ return NULL;
+ }
+
+ return addr;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/texcompress.h b/nx-X11/extras/Mesa/src/mesa/main/texcompress.h
new file mode 100644
index 000000000..500741454
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/texcompress.h
@@ -0,0 +1,65 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef TEXCOMPRESS_H
+#define TEXCOMPRESS_H
+
+#include "mtypes.h"
+
+#if _HAVE_FULL_GL
+extern GLuint
+_mesa_get_compressed_formats( GLcontext *ctx, GLint *formats );
+
+extern GLuint
+_mesa_compressed_texture_size( GLcontext *ctx,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format );
+
+extern GLint
+_mesa_compressed_row_stride(GLenum format, GLsizei width);
+
+
+extern GLubyte *
+_mesa_compressed_image_address(GLint col, GLint row, GLint img,
+ GLenum format,
+ GLsizei width, const GLubyte *image);
+
+
+extern void
+_mesa_init_texture_s3tc( GLcontext *ctx );
+
+extern void
+_mesa_init_texture_fxt1( GLcontext *ctx );
+
+
+
+#else
+#define _mesa_get_compressed_formats( c, f ) 0
+#define _mesa_compressed_texture_size( c, w, h, d, f ) 0
+#define _mesa_compressed_row_stride( f, w) 0
+#define _mesa_compressed_image_address(c, r, i, f, w, i2 ) 0
+#define _mesa_compress_teximage( c, w, h, sF, s, sRS, dF, d, drs ) ((void)0)
+#endif
+
+#endif /* TEXCOMPRESS_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/main/texcompress_fxt1.c b/nx-X11/extras/Mesa/src/mesa/main/texcompress_fxt1.c
new file mode 100644
index 000000000..d5e2c790f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/texcompress_fxt1.c
@@ -0,0 +1,1663 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file texcompress_fxt1.c
+ * GL_EXT_texture_compression_fxt1 support.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "colormac.h"
+#include "context.h"
+#include "convolve.h"
+#include "image.h"
+#include "texcompress.h"
+#include "texformat.h"
+#include "texstore.h"
+
+
+static GLint
+fxt1_encode (GLuint width, GLuint height, GLint comps,
+ const void *source, GLint srcRowStride,
+ void *dest, GLint destRowStride);
+
+void
+fxt1_decode_1 (const void *texture, GLint stride,
+ GLint i, GLint j, GLubyte *rgba);
+
+
+/**
+ * Called during context initialization.
+ */
+void
+_mesa_init_texture_fxt1( GLcontext *ctx )
+{
+ (void) ctx;
+}
+
+
+/**
+ * Called via TexFormat->StoreImage to store an RGB_FXT1 texture.
+ */
+static GLboolean
+texstore_rgb_fxt1(STORE_PARAMS)
+{
+ const GLchan *pixels;
+ GLint srcRowStride;
+ GLubyte *dst;
+ const GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
+ const GLchan *tempImage = NULL;
+
+ ASSERT(dstFormat == &_mesa_texformat_rgb_fxt1);
+ ASSERT(dstXoffset % 8 == 0);
+ ASSERT(dstYoffset % 4 == 0);
+ ASSERT(dstZoffset == 0);
+ (void) dstZoffset; (void) dstImageStride;
+
+ if (srcFormat != GL_RGB ||
+ srcType != CHAN_TYPE ||
+ ctx->_ImageTransferState ||
+ srcPacking->SwapBytes) {
+ /* convert image to RGB/GLchan */
+ tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ if (!tempImage)
+ return GL_FALSE; /* out of memory */
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ pixels = tempImage;
+ srcRowStride = 3 * srcWidth;
+ srcFormat = GL_RGB;
+ }
+ else {
+ pixels = (const GLchan *) srcAddr;
+ srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
+ srcType) / sizeof(GLchan);
+ }
+
+ dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
+ GL_COMPRESSED_RGB_FXT1_3DFX,
+ texWidth, (GLubyte *) dstAddr);
+
+ fxt1_encode(srcWidth, srcHeight, 3, pixels, srcRowStride,
+ dst, dstRowStride);
+
+ if (tempImage)
+ _mesa_free((void*) tempImage);
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Called via TexFormat->StoreImage to store an RGBA_FXT1 texture.
+ */
+static GLboolean
+texstore_rgba_fxt1(STORE_PARAMS)
+{
+ const GLchan *pixels;
+ GLint srcRowStride;
+ GLubyte *dst;
+ GLint texWidth = dstRowStride * 8 / 16; /* a bit of a hack */
+ const GLchan *tempImage = NULL;
+
+ ASSERT(dstFormat == &_mesa_texformat_rgba_fxt1);
+ ASSERT(dstXoffset % 8 == 0);
+ ASSERT(dstYoffset % 4 == 0);
+ ASSERT(dstZoffset == 0);
+ (void) dstZoffset; (void) dstImageStride;
+
+ if (srcFormat != GL_RGBA ||
+ srcType != CHAN_TYPE ||
+ ctx->_ImageTransferState ||
+ srcPacking->SwapBytes) {
+ /* convert image to RGBA/GLchan */
+ tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ if (!tempImage)
+ return GL_FALSE; /* out of memory */
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ pixels = tempImage;
+ srcRowStride = 4 * srcWidth;
+ srcFormat = GL_RGBA;
+ }
+ else {
+ pixels = (const GLchan *) srcAddr;
+ srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
+ srcType) / sizeof(GLchan);
+ }
+
+ dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
+ GL_COMPRESSED_RGBA_FXT1_3DFX,
+ texWidth, (GLubyte *) dstAddr);
+
+ fxt1_encode(srcWidth, srcHeight, 4, pixels, srcRowStride,
+ dst, dstRowStride);
+
+ if (tempImage)
+ _mesa_free((void*) tempImage);
+
+ return GL_TRUE;
+}
+
+
+static void
+fetch_texel_2d_rgba_fxt1( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ (void) k;
+ fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, texel);
+}
+
+
+static void
+fetch_texel_2d_f_rgba_fxt1( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ /* just sample as GLchan and convert to float here */
+ GLchan rgba[4];
+ (void) k;
+ fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, rgba);
+ texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
+ texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
+ texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
+ texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
+}
+
+
+static void
+fetch_texel_2d_rgb_fxt1( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ (void) k;
+ fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, texel);
+ texel[ACOMP] = 255;
+}
+
+
+static void
+fetch_texel_2d_f_rgb_fxt1( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ /* just sample as GLchan and convert to float here */
+ GLchan rgba[4];
+ (void) k;
+ fxt1_decode_1(texImage->Data, texImage->RowStride, i, j, rgba);
+ texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
+ texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
+ texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
+ texel[ACOMP] = 1.0F;
+}
+
+
+
+const struct gl_texture_format _mesa_texformat_rgb_fxt1 = {
+ MESA_FORMAT_RGB_FXT1, /* MesaFormat */
+ GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 4, /*approx*/ /* RedBits */
+ 4, /*approx*/ /* GreenBits */
+ 4, /*approx*/ /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 0, /* TexelBytes */
+ texstore_rgb_fxt1, /* StoreTexImageFunc */
+ NULL, /*impossible*/ /* FetchTexel1D */
+ fetch_texel_2d_rgb_fxt1, /* FetchTexel2D */
+ NULL, /*impossible*/ /* FetchTexel3D */
+ NULL, /*impossible*/ /* FetchTexel1Df */
+ fetch_texel_2d_f_rgb_fxt1, /* FetchTexel2Df */
+ NULL, /*impossible*/ /* FetchTexel3Df */
+};
+
+const struct gl_texture_format _mesa_texformat_rgba_fxt1 = {
+ MESA_FORMAT_RGBA_FXT1, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 4, /*approx*/ /* RedBits */
+ 4, /*approx*/ /* GreenBits */
+ 4, /*approx*/ /* BlueBits */
+ 1, /*approx*/ /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 0, /* TexelBytes */
+ texstore_rgba_fxt1, /* StoreTexImageFunc */
+ NULL, /*impossible*/ /* FetchTexel1D */
+ fetch_texel_2d_rgba_fxt1, /* FetchTexel2D */
+ NULL, /*impossible*/ /* FetchTexel3D */
+ NULL, /*impossible*/ /* FetchTexel1Df */
+ fetch_texel_2d_f_rgba_fxt1, /* FetchTexel2Df */
+ NULL, /*impossible*/ /* FetchTexel3Df */
+};
+
+
+/***************************************************************************\
+ * FXT1 encoder
+ *
+ * The encoder was built by reversing the decoder,
+ * and is vaguely based on Texus2 by 3dfx. Note that this code
+ * is merely a proof of concept, since it is highly UNoptimized;
+ * moreover, it is sub-optimal due to initial conditions passed
+ * to Lloyd's algorithm (the interpolation modes are even worse).
+\***************************************************************************/
+
+
+#define MAX_COMP 4 /* ever needed maximum number of components in texel */
+#define MAX_VECT 4 /* ever needed maximum number of base vectors to find */
+#define N_TEXELS 32 /* number of texels in a block (always 32) */
+#define LL_N_REP 50 /* number of iterations in lloyd's vq */
+#define LL_RMS_D 10 /* fault tolerance (maximum delta) */
+#define LL_RMS_E 255 /* fault tolerance (maximum error) */
+#define ALPHA_TS 2 /* alpha threshold: (255 - ALPHA_TS) deemed opaque */
+#define ISTBLACK(v) (*((GLuint *)(v)) == 0)
+
+
+/*
+ * Define a 64-bit unsigned integer type and macros
+ */
+#if defined(__GNUC__) && !defined(__cplusplus)
+
+#define FX64_NATIVE 1
+
+typedef unsigned long long Fx64;
+
+#define FX64_MOV32(a, b) a = b
+#define FX64_OR32(a, b) a |= b
+#define FX64_SHL(a, c) a <<= c
+
+#else /* !__GNUC__ */
+
+#define FX64_NATIVE 0
+
+typedef struct {
+ GLuint lo, hi;
+} Fx64;
+
+#define FX64_MOV32(a, b) a.lo = b
+#define FX64_OR32(a, b) a.lo |= b
+
+#define FX64_SHL(a, c) \
+ do { \
+ if ((c) >= 32) { \
+ a.hi = a.lo << ((c) - 32); \
+ a.lo = 0; \
+ } else { \
+ a.hi = (a.hi << (c)) | (a.lo >> (32 - (c))); \
+ a.lo <<= (c); \
+ } \
+ } while (0)
+
+#endif /* !__GNUC__ */
+
+
+#define F(i) (GLfloat)1 /* can be used to obtain an oblong metric: 0.30 / 0.59 / 0.11 */
+#define SAFECDOT 1 /* for paranoids */
+
+#define MAKEIVEC(NV, NC, IV, B, V0, V1) \
+ do { \
+ /* compute interpolation vector */ \
+ GLfloat d2 = 0.0F; \
+ GLfloat rd2; \
+ \
+ for (i = 0; i < NC; i++) { \
+ IV[i] = (V1[i] - V0[i]) * F(i); \
+ d2 += IV[i] * IV[i]; \
+ } \
+ rd2 = (GLfloat)NV / d2; \
+ B = 0; \
+ for (i = 0; i < NC; i++) { \
+ IV[i] *= F(i); \
+ B -= IV[i] * V0[i]; \
+ IV[i] *= rd2; \
+ } \
+ B = B * rd2 + 0.5f; \
+ } while (0)
+
+#define CALCCDOT(TEXEL, NV, NC, IV, B, V)\
+ do { \
+ GLfloat dot = 0.0F; \
+ for (i = 0; i < NC; i++) { \
+ dot += V[i] * IV[i]; \
+ } \
+ TEXEL = (GLint)(dot + B); \
+ if (SAFECDOT) { \
+ if (TEXEL < 0) { \
+ TEXEL = 0; \
+ } else if (TEXEL > NV) { \
+ TEXEL = NV; \
+ } \
+ } \
+ } while (0)
+
+
+static GLint
+fxt1_bestcol (GLfloat vec[][MAX_COMP], GLint nv,
+ GLubyte input[MAX_COMP], GLint nc)
+{
+ GLint i, j, best = -1;
+ GLfloat err = 1e9; /* big enough */
+
+ for (j = 0; j < nv; j++) {
+ GLfloat e = 0.0F;
+ for (i = 0; i < nc; i++) {
+ e += (vec[j][i] - input[i]) * (vec[j][i] - input[i]);
+ }
+ if (e < err) {
+ err = e;
+ best = j;
+ }
+ }
+
+ return best;
+}
+
+
+static GLint
+fxt1_worst (GLfloat vec[MAX_COMP],
+ GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n)
+{
+ GLint i, k, worst = -1;
+ GLfloat err = -1.0F; /* small enough */
+
+ for (k = 0; k < n; k++) {
+ GLfloat e = 0.0F;
+ for (i = 0; i < nc; i++) {
+ e += (vec[i] - input[k][i]) * (vec[i] - input[k][i]);
+ }
+ if (e > err) {
+ err = e;
+ worst = k;
+ }
+ }
+
+ return worst;
+}
+
+
+static GLint
+fxt1_variance (GLdouble variance[MAX_COMP],
+ GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n)
+{
+ GLint i, k, best = 0;
+ GLint sx, sx2;
+ GLdouble var, maxvar = -1; /* small enough */
+ GLdouble teenth = 1.0 / n;
+
+ for (i = 0; i < nc; i++) {
+ sx = sx2 = 0;
+ for (k = 0; k < n; k++) {
+ GLint t = input[k][i];
+ sx += t;
+ sx2 += t * t;
+ }
+ var = sx2 * teenth - sx * sx * teenth * teenth;
+ if (maxvar < var) {
+ maxvar = var;
+ best = i;
+ }
+ if (variance) {
+ variance[i] = var;
+ }
+ }
+
+ return best;
+}
+
+
+static GLint
+fxt1_choose (GLfloat vec[][MAX_COMP], GLint nv,
+ GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n)
+{
+#if 0
+ /* Choose colors from a grid.
+ */
+ GLint i, j;
+
+ for (j = 0; j < nv; j++) {
+ GLint m = j * (n - 1) / (nv - 1);
+ for (i = 0; i < nc; i++) {
+ vec[j][i] = input[m][i];
+ }
+ }
+#else
+ /* Our solution here is to find the darkest and brightest colors in
+ * the 8x4 tile and use those as the two representative colors.
+ * There are probably better algorithms to use (histogram-based).
+ */
+ GLint i, j, k;
+ GLint minSum = 2000; /* big enough */
+ GLint maxSum = -1; /* small enough */
+ GLint minCol = 0; /* phoudoin: silent compiler! */
+ GLint maxCol = 0; /* phoudoin: silent compiler! */
+
+ struct {
+ GLint flag;
+ GLint key;
+ GLint freq;
+ GLint idx;
+ } hist[N_TEXELS];
+ GLint lenh = 0;
+
+ memset(hist, 0, sizeof(hist));
+
+ for (k = 0; k < n; k++) {
+ GLint l;
+ GLint key = 0;
+ GLint sum = 0;
+ for (i = 0; i < nc; i++) {
+ key <<= 8;
+ key |= input[k][i];
+ sum += input[k][i];
+ }
+ for (l = 0; l < n; l++) {
+ if (!hist[l].flag) {
+ /* alloc new slot */
+ hist[l].flag = !0;
+ hist[l].key = key;
+ hist[l].freq = 1;
+ hist[l].idx = k;
+ lenh = l + 1;
+ break;
+ } else if (hist[l].key == key) {
+ hist[l].freq++;
+ break;
+ }
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minCol = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxCol = k;
+ }
+ }
+
+ if (lenh <= nv) {
+ for (j = 0; j < lenh; j++) {
+ for (i = 0; i < nc; i++) {
+ vec[j][i] = (GLfloat)input[hist[j].idx][i];
+ }
+ }
+ for (; j < nv; j++) {
+ for (i = 0; i < nc; i++) {
+ vec[j][i] = vec[0][i];
+ }
+ }
+ return 0;
+ }
+
+ for (j = 0; j < nv; j++) {
+ for (i = 0; i < nc; i++) {
+ vec[j][i] = ((nv - 1 - j) * input[minCol][i] + j * input[maxCol][i] + (nv - 1) / 2) / (GLfloat)(nv - 1);
+ }
+ }
+#endif
+
+ return !0;
+}
+
+
+static GLint
+fxt1_lloyd (GLfloat vec[][MAX_COMP], GLint nv,
+ GLubyte input[N_TEXELS][MAX_COMP], GLint nc, GLint n)
+{
+ /* Use the generalized lloyd's algorithm for VQ:
+ * find 4 color vectors.
+ *
+ * for each sample color
+ * sort to nearest vector.
+ *
+ * replace each vector with the centroid of it's matching colors.
+ *
+ * repeat until RMS doesn't improve.
+ *
+ * if a color vector has no samples, or becomes the same as another
+ * vector, replace it with the color which is farthest from a sample.
+ *
+ * vec[][MAX_COMP] initial vectors and resulting colors
+ * nv number of resulting colors required
+ * input[N_TEXELS][MAX_COMP] input texels
+ * nc number of components in input / vec
+ * n number of input samples
+ */
+
+ GLint sum[MAX_VECT][MAX_COMP]; /* used to accumulate closest texels */
+ GLint cnt[MAX_VECT]; /* how many times a certain vector was chosen */
+ GLfloat error, lasterror = 1e9;
+
+ GLint i, j, k, rep;
+
+ /* the quantizer */
+ for (rep = 0; rep < LL_N_REP; rep++) {
+ /* reset sums & counters */
+ for (j = 0; j < nv; j++) {
+ for (i = 0; i < nc; i++) {
+ sum[j][i] = 0;
+ }
+ cnt[j] = 0;
+ }
+ error = 0;
+
+ /* scan whole block */
+ for (k = 0; k < n; k++) {
+#if 1
+ GLint best = -1;
+ GLfloat err = 1e9; /* big enough */
+ /* determine best vector */
+ for (j = 0; j < nv; j++) {
+ GLfloat e = (vec[j][0] - input[k][0]) * (vec[j][0] - input[k][0]) +
+ (vec[j][1] - input[k][1]) * (vec[j][1] - input[k][1]) +
+ (vec[j][2] - input[k][2]) * (vec[j][2] - input[k][2]);
+ if (nc == 4) {
+ e += (vec[j][3] - input[k][3]) * (vec[j][3] - input[k][3]);
+ }
+ if (e < err) {
+ err = e;
+ best = j;
+ }
+ }
+#else
+ GLint best = fxt1_bestcol(vec, nv, input[k], nc, &err);
+#endif
+ /* add in closest color */
+ for (i = 0; i < nc; i++) {
+ sum[best][i] += input[k][i];
+ }
+ /* mark this vector as used */
+ cnt[best]++;
+ /* accumulate error */
+ error += err;
+ }
+
+ /* check RMS */
+ if ((error < LL_RMS_E) ||
+ ((error < lasterror) && ((lasterror - error) < LL_RMS_D))) {
+ return !0; /* good match */
+ }
+ lasterror = error;
+
+ /* move each vector to the barycenter of its closest colors */
+ for (j = 0; j < nv; j++) {
+ if (cnt[j]) {
+ GLfloat div = 1.0F / cnt[j];
+ for (i = 0; i < nc; i++) {
+ vec[j][i] = div * sum[j][i];
+ }
+ } else {
+ /* this vec has no samples or is identical with a previous vec */
+ GLint worst = fxt1_worst(vec[j], input, nc, n);
+ for (i = 0; i < nc; i++) {
+ vec[j][i] = input[worst][i];
+ }
+ }
+ }
+ }
+
+ return 0; /* could not converge fast enough */
+}
+
+
+static void
+fxt1_quantize_CHROMA (GLuint *cc,
+ GLubyte input[N_TEXELS][MAX_COMP])
+{
+ const GLint n_vect = 4; /* 4 base vectors to find */
+ const GLint n_comp = 3; /* 3 components: R, G, B */
+ GLfloat vec[MAX_VECT][MAX_COMP];
+ GLint i, j, k;
+ Fx64 hi; /* high quadword */
+ GLuint lohi, lolo; /* low quadword: hi dword, lo dword */
+
+ if (fxt1_choose(vec, n_vect, input, n_comp, N_TEXELS) != 0) {
+ fxt1_lloyd(vec, n_vect, input, n_comp, N_TEXELS);
+ }
+
+ FX64_MOV32(hi, 4); /* cc-chroma = "010" + unused bit */
+ for (j = n_vect - 1; j >= 0; j--) {
+ for (i = 0; i < n_comp; i++) {
+ /* add in colors */
+ FX64_SHL(hi, 5);
+ FX64_OR32(hi, (GLuint)(vec[j][i] / 8.0F));
+ }
+ }
+ ((Fx64 *)cc)[1] = hi;
+
+ lohi = lolo = 0;
+ /* right microtile */
+ for (k = N_TEXELS - 1; k >= N_TEXELS/2; k--) {
+ lohi <<= 2;
+ lohi |= fxt1_bestcol(vec, n_vect, input[k], n_comp);
+ }
+ /* left microtile */
+ for (; k >= 0; k--) {
+ lolo <<= 2;
+ lolo |= fxt1_bestcol(vec, n_vect, input[k], n_comp);
+ }
+ cc[1] = lohi;
+ cc[0] = lolo;
+}
+
+
+static void
+fxt1_quantize_ALPHA0 (GLuint *cc,
+ GLubyte input[N_TEXELS][MAX_COMP],
+ GLubyte reord[N_TEXELS][MAX_COMP], GLint n)
+{
+ const GLint n_vect = 3; /* 3 base vectors to find */
+ const GLint n_comp = 4; /* 4 components: R, G, B, A */
+ GLfloat vec[MAX_VECT][MAX_COMP];
+ GLint i, j, k;
+ Fx64 hi; /* high quadword */
+ GLuint lohi, lolo; /* low quadword: hi dword, lo dword */
+
+ /* the last vector indicates zero */
+ for (i = 0; i < n_comp; i++) {
+ vec[n_vect][i] = 0;
+ }
+
+ /* the first n texels in reord are guaranteed to be non-zero */
+ if (fxt1_choose(vec, n_vect, reord, n_comp, n) != 0) {
+ fxt1_lloyd(vec, n_vect, reord, n_comp, n);
+ }
+
+ FX64_MOV32(hi, 6); /* alpha = "011" + lerp = 0 */
+ for (j = n_vect - 1; j >= 0; j--) {
+ /* add in alphas */
+ FX64_SHL(hi, 5);
+ FX64_OR32(hi, (GLuint)(vec[j][ACOMP] / 8.0F));
+ }
+ for (j = n_vect - 1; j >= 0; j--) {
+ for (i = 0; i < n_comp - 1; i++) {
+ /* add in colors */
+ FX64_SHL(hi, 5);
+ FX64_OR32(hi, (GLuint)(vec[j][i] / 8.0F));
+ }
+ }
+ ((Fx64 *)cc)[1] = hi;
+
+ lohi = lolo = 0;
+ /* right microtile */
+ for (k = N_TEXELS - 1; k >= N_TEXELS/2; k--) {
+ lohi <<= 2;
+ lohi |= fxt1_bestcol(vec, n_vect + 1, input[k], n_comp);
+ }
+ /* left microtile */
+ for (; k >= 0; k--) {
+ lolo <<= 2;
+ lolo |= fxt1_bestcol(vec, n_vect + 1, input[k], n_comp);
+ }
+ cc[1] = lohi;
+ cc[0] = lolo;
+}
+
+
+static void
+fxt1_quantize_ALPHA1 (GLuint *cc,
+ GLubyte input[N_TEXELS][MAX_COMP])
+{
+ const GLint n_vect = 3; /* highest vector number in each microtile */
+ const GLint n_comp = 4; /* 4 components: R, G, B, A */
+ GLfloat vec[1 + 1 + 1][MAX_COMP]; /* 1.5 extrema for each sub-block */
+ GLfloat b, iv[MAX_COMP]; /* interpolation vector */
+ GLint i, j, k;
+ Fx64 hi; /* high quadword */
+ GLuint lohi, lolo; /* low quadword: hi dword, lo dword */
+
+ GLint minSum;
+ GLint maxSum;
+ GLint minColL = 0, maxColL = 0;
+ GLint minColR = 0, maxColR = 0;
+ GLint sumL = 0, sumR = 0;
+
+ /* Our solution here is to find the darkest and brightest colors in
+ * the 4x4 tile and use those as the two representative colors.
+ * There are probably better algorithms to use (histogram-based).
+ */
+ minSum = 2000; /* big enough */
+ maxSum = -1; /* small enough */
+ for (k = 0; k < N_TEXELS / 2; k++) {
+ GLint sum = 0;
+ for (i = 0; i < n_comp; i++) {
+ sum += input[k][i];
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minColL = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxColL = k;
+ }
+ sumL += sum;
+ }
+ minSum = 2000; /* big enough */
+ maxSum = -1; /* small enough */
+ for (; k < N_TEXELS; k++) {
+ GLint sum = 0;
+ for (i = 0; i < n_comp; i++) {
+ sum += input[k][i];
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minColR = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxColR = k;
+ }
+ sumR += sum;
+ }
+
+ /* choose the common vector (yuck!) */
+ {
+ GLint j1, j2;
+ GLint v1 = 0, v2 = 0;
+ GLfloat err = 1e9; /* big enough */
+ GLfloat tv[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */
+ for (i = 0; i < n_comp; i++) {
+ tv[0][i] = input[minColL][i];
+ tv[1][i] = input[maxColL][i];
+ tv[2][i] = input[minColR][i];
+ tv[3][i] = input[maxColR][i];
+ }
+ for (j1 = 0; j1 < 2; j1++) {
+ for (j2 = 2; j2 < 4; j2++) {
+ GLfloat e = 0.0F;
+ for (i = 0; i < n_comp; i++) {
+ e += (tv[j1][i] - tv[j2][i]) * (tv[j1][i] - tv[j2][i]);
+ }
+ if (e < err) {
+ err = e;
+ v1 = j1;
+ v2 = j2;
+ }
+ }
+ }
+ for (i = 0; i < n_comp; i++) {
+ vec[0][i] = tv[1 - v1][i];
+ vec[1][i] = (tv[v1][i] * sumL + tv[v2][i] * sumR) / (sumL + sumR);
+ vec[2][i] = tv[5 - v2][i];
+ }
+ }
+
+ /* left microtile */
+ cc[0] = 0;
+ if (minColL != maxColL) {
+ /* compute interpolation vector */
+ MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]);
+
+ /* add in texels */
+ lolo = 0;
+ for (k = N_TEXELS / 2 - 1; k >= 0; k--) {
+ GLint texel;
+ /* interpolate color */
+ CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
+ /* add in texel */
+ lolo <<= 2;
+ lolo |= texel;
+ }
+
+ cc[0] = lolo;
+ }
+
+ /* right microtile */
+ cc[1] = 0;
+ if (minColR != maxColR) {
+ /* compute interpolation vector */
+ MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[1]);
+
+ /* add in texels */
+ lohi = 0;
+ for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) {
+ GLint texel;
+ /* interpolate color */
+ CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
+ /* add in texel */
+ lohi <<= 2;
+ lohi |= texel;
+ }
+
+ cc[1] = lohi;
+ }
+
+ FX64_MOV32(hi, 7); /* alpha = "011" + lerp = 1 */
+ for (j = n_vect - 1; j >= 0; j--) {
+ /* add in alphas */
+ FX64_SHL(hi, 5);
+ FX64_OR32(hi, (GLuint)(vec[j][ACOMP] / 8.0F));
+ }
+ for (j = n_vect - 1; j >= 0; j--) {
+ for (i = 0; i < n_comp - 1; i++) {
+ /* add in colors */
+ FX64_SHL(hi, 5);
+ FX64_OR32(hi, (GLuint)(vec[j][i] / 8.0F));
+ }
+ }
+ ((Fx64 *)cc)[1] = hi;
+}
+
+
+static void
+fxt1_quantize_HI (GLuint *cc,
+ GLubyte input[N_TEXELS][MAX_COMP],
+ GLubyte reord[N_TEXELS][MAX_COMP], GLint n)
+{
+ const GLint n_vect = 6; /* highest vector number */
+ const GLint n_comp = 3; /* 3 components: R, G, B */
+ GLfloat b = 0.0F; /* phoudoin: silent compiler! */
+ GLfloat iv[MAX_COMP]; /* interpolation vector */
+ GLint i, k;
+ GLuint hihi; /* high quadword: hi dword */
+
+ GLint minSum = 2000; /* big enough */
+ GLint maxSum = -1; /* small enough */
+ GLint minCol = 0; /* phoudoin: silent compiler! */
+ GLint maxCol = 0; /* phoudoin: silent compiler! */
+
+ /* Our solution here is to find the darkest and brightest colors in
+ * the 8x4 tile and use those as the two representative colors.
+ * There are probably better algorithms to use (histogram-based).
+ */
+ for (k = 0; k < n; k++) {
+ GLint sum = 0;
+ for (i = 0; i < n_comp; i++) {
+ sum += reord[k][i];
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minCol = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxCol = k;
+ }
+ }
+
+ hihi = 0; /* cc-hi = "00" */
+ for (i = 0; i < n_comp; i++) {
+ /* add in colors */
+ hihi <<= 5;
+ hihi |= reord[maxCol][i] >> 3;
+ }
+ for (i = 0; i < n_comp; i++) {
+ /* add in colors */
+ hihi <<= 5;
+ hihi |= reord[minCol][i] >> 3;
+ }
+ cc[3] = hihi;
+ cc[0] = cc[1] = cc[2] = 0;
+
+ /* compute interpolation vector */
+ if (minCol != maxCol) {
+ MAKEIVEC(n_vect, n_comp, iv, b, reord[minCol], reord[maxCol]);
+ }
+
+ /* add in texels */
+ for (k = N_TEXELS - 1; k >= 0; k--) {
+ GLint t = k * 3;
+ GLuint *kk = (GLuint *)((char *)cc + t / 8);
+ GLint texel = n_vect + 1; /* transparent black */
+
+ if (!ISTBLACK(input[k])) {
+ if (minCol != maxCol) {
+ /* interpolate color */
+ CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
+ /* add in texel */
+ kk[0] |= texel << (t & 7);
+ }
+ } else {
+ /* add in texel */
+ kk[0] |= texel << (t & 7);
+ }
+ }
+}
+
+
+static void
+fxt1_quantize_MIXED1 (GLuint *cc,
+ GLubyte input[N_TEXELS][MAX_COMP])
+{
+ const GLint n_vect = 2; /* highest vector number in each microtile */
+ const GLint n_comp = 3; /* 3 components: R, G, B */
+ GLubyte vec[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */
+ GLfloat b, iv[MAX_COMP]; /* interpolation vector */
+ GLint i, j, k;
+ Fx64 hi; /* high quadword */
+ GLuint lohi, lolo; /* low quadword: hi dword, lo dword */
+
+ GLint minSum;
+ GLint maxSum;
+ GLint minColL = 0, maxColL = -1;
+ GLint minColR = 0, maxColR = -1;
+
+ /* Our solution here is to find the darkest and brightest colors in
+ * the 4x4 tile and use those as the two representative colors.
+ * There are probably better algorithms to use (histogram-based).
+ */
+ minSum = 2000; /* big enough */
+ maxSum = -1; /* small enough */
+ for (k = 0; k < N_TEXELS / 2; k++) {
+ if (!ISTBLACK(input[k])) {
+ GLint sum = 0;
+ for (i = 0; i < n_comp; i++) {
+ sum += input[k][i];
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minColL = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxColL = k;
+ }
+ }
+ }
+ minSum = 2000; /* big enough */
+ maxSum = -1; /* small enough */
+ for (; k < N_TEXELS; k++) {
+ if (!ISTBLACK(input[k])) {
+ GLint sum = 0;
+ for (i = 0; i < n_comp; i++) {
+ sum += input[k][i];
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minColR = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxColR = k;
+ }
+ }
+ }
+
+ /* left microtile */
+ if (maxColL == -1) {
+ /* all transparent black */
+ cc[0] = ~0u;
+ for (i = 0; i < n_comp; i++) {
+ vec[0][i] = 0;
+ vec[1][i] = 0;
+ }
+ } else {
+ cc[0] = 0;
+ for (i = 0; i < n_comp; i++) {
+ vec[0][i] = input[minColL][i];
+ vec[1][i] = input[maxColL][i];
+ }
+ if (minColL != maxColL) {
+ /* compute interpolation vector */
+ MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]);
+
+ /* add in texels */
+ lolo = 0;
+ for (k = N_TEXELS / 2 - 1; k >= 0; k--) {
+ GLint texel = n_vect + 1; /* transparent black */
+ if (!ISTBLACK(input[k])) {
+ /* interpolate color */
+ CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
+ }
+ /* add in texel */
+ lolo <<= 2;
+ lolo |= texel;
+ }
+ cc[0] = lolo;
+ }
+ }
+
+ /* right microtile */
+ if (maxColR == -1) {
+ /* all transparent black */
+ cc[1] = ~0u;
+ for (i = 0; i < n_comp; i++) {
+ vec[2][i] = 0;
+ vec[3][i] = 0;
+ }
+ } else {
+ cc[1] = 0;
+ for (i = 0; i < n_comp; i++) {
+ vec[2][i] = input[minColR][i];
+ vec[3][i] = input[maxColR][i];
+ }
+ if (minColR != maxColR) {
+ /* compute interpolation vector */
+ MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[3]);
+
+ /* add in texels */
+ lohi = 0;
+ for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) {
+ GLint texel = n_vect + 1; /* transparent black */
+ if (!ISTBLACK(input[k])) {
+ /* interpolate color */
+ CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
+ }
+ /* add in texel */
+ lohi <<= 2;
+ lohi |= texel;
+ }
+ cc[1] = lohi;
+ }
+ }
+
+ FX64_MOV32(hi, 9 | (vec[3][GCOMP] & 4) | ((vec[1][GCOMP] >> 1) & 2)); /* chroma = "1" */
+ for (j = 2 * 2 - 1; j >= 0; j--) {
+ for (i = 0; i < n_comp; i++) {
+ /* add in colors */
+ FX64_SHL(hi, 5);
+ FX64_OR32(hi, vec[j][i] >> 3);
+ }
+ }
+ ((Fx64 *)cc)[1] = hi;
+}
+
+
+static void
+fxt1_quantize_MIXED0 (GLuint *cc,
+ GLubyte input[N_TEXELS][MAX_COMP])
+{
+ const GLint n_vect = 3; /* highest vector number in each microtile */
+ const GLint n_comp = 3; /* 3 components: R, G, B */
+ GLubyte vec[2 * 2][MAX_COMP]; /* 2 extrema for each sub-block */
+ GLfloat b, iv[MAX_COMP]; /* interpolation vector */
+ GLint i, j, k;
+ Fx64 hi; /* high quadword */
+ GLuint lohi, lolo; /* low quadword: hi dword, lo dword */
+
+ GLint minColL = 0, maxColL = 0;
+ GLint minColR = 0, maxColR = 0;
+#if 0
+ GLint minSum;
+ GLint maxSum;
+
+ /* Our solution here is to find the darkest and brightest colors in
+ * the 4x4 tile and use those as the two representative colors.
+ * There are probably better algorithms to use (histogram-based).
+ */
+ minSum = 2000; /* big enough */
+ maxSum = -1; /* small enough */
+ for (k = 0; k < N_TEXELS / 2; k++) {
+ GLint sum = 0;
+ for (i = 0; i < n_comp; i++) {
+ sum += input[k][i];
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minColL = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxColL = k;
+ }
+ }
+ minSum = 2000; /* big enough */
+ maxSum = -1; /* small enough */
+ for (; k < N_TEXELS; k++) {
+ GLint sum = 0;
+ for (i = 0; i < n_comp; i++) {
+ sum += input[k][i];
+ }
+ if (minSum > sum) {
+ minSum = sum;
+ minColR = k;
+ }
+ if (maxSum < sum) {
+ maxSum = sum;
+ maxColR = k;
+ }
+ }
+#else
+ GLint minVal;
+ GLint maxVal;
+ GLint maxVarL = fxt1_variance(NULL, input, n_comp, N_TEXELS / 2);
+ GLint maxVarR = fxt1_variance(NULL, &input[N_TEXELS / 2], n_comp, N_TEXELS / 2);
+
+ /* Scan the channel with max variance for lo & hi
+ * and use those as the two representative colors.
+ */
+ minVal = 2000; /* big enough */
+ maxVal = -1; /* small enough */
+ for (k = 0; k < N_TEXELS / 2; k++) {
+ GLint t = input[k][maxVarL];
+ if (minVal > t) {
+ minVal = t;
+ minColL = k;
+ }
+ if (maxVal < t) {
+ maxVal = t;
+ maxColL = k;
+ }
+ }
+ minVal = 2000; /* big enough */
+ maxVal = -1; /* small enough */
+ for (; k < N_TEXELS; k++) {
+ GLint t = input[k][maxVarR];
+ if (minVal > t) {
+ minVal = t;
+ minColR = k;
+ }
+ if (maxVal < t) {
+ maxVal = t;
+ maxColR = k;
+ }
+ }
+#endif
+
+ /* left microtile */
+ cc[0] = 0;
+ for (i = 0; i < n_comp; i++) {
+ vec[0][i] = input[minColL][i];
+ vec[1][i] = input[maxColL][i];
+ }
+ if (minColL != maxColL) {
+ /* compute interpolation vector */
+ MAKEIVEC(n_vect, n_comp, iv, b, vec[0], vec[1]);
+
+ /* add in texels */
+ lolo = 0;
+ for (k = N_TEXELS / 2 - 1; k >= 0; k--) {
+ GLint texel;
+ /* interpolate color */
+ CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
+ /* add in texel */
+ lolo <<= 2;
+ lolo |= texel;
+ }
+
+ /* funky encoding for LSB of green */
+ if ((GLint)((lolo >> 1) & 1) != (((vec[1][GCOMP] ^ vec[0][GCOMP]) >> 2) & 1)) {
+ for (i = 0; i < n_comp; i++) {
+ vec[1][i] = input[minColL][i];
+ vec[0][i] = input[maxColL][i];
+ }
+ lolo = ~lolo;
+ }
+
+ cc[0] = lolo;
+ }
+
+ /* right microtile */
+ cc[1] = 0;
+ for (i = 0; i < n_comp; i++) {
+ vec[2][i] = input[minColR][i];
+ vec[3][i] = input[maxColR][i];
+ }
+ if (minColR != maxColR) {
+ /* compute interpolation vector */
+ MAKEIVEC(n_vect, n_comp, iv, b, vec[2], vec[3]);
+
+ /* add in texels */
+ lohi = 0;
+ for (k = N_TEXELS - 1; k >= N_TEXELS / 2; k--) {
+ GLint texel;
+ /* interpolate color */
+ CALCCDOT(texel, n_vect, n_comp, iv, b, input[k]);
+ /* add in texel */
+ lohi <<= 2;
+ lohi |= texel;
+ }
+
+ /* funky encoding for LSB of green */
+ if ((GLint)((lohi >> 1) & 1) != (((vec[3][GCOMP] ^ vec[2][GCOMP]) >> 2) & 1)) {
+ for (i = 0; i < n_comp; i++) {
+ vec[3][i] = input[minColR][i];
+ vec[2][i] = input[maxColR][i];
+ }
+ lohi = ~lohi;
+ }
+
+ cc[1] = lohi;
+ }
+
+ FX64_MOV32(hi, 8 | (vec[3][GCOMP] & 4) | ((vec[1][GCOMP] >> 1) & 2)); /* chroma = "1" */
+ for (j = 2 * 2 - 1; j >= 0; j--) {
+ for (i = 0; i < n_comp; i++) {
+ /* add in colors */
+ FX64_SHL(hi, 5);
+ FX64_OR32(hi, vec[j][i] >> 3);
+ }
+ }
+ ((Fx64 *)cc)[1] = hi;
+}
+
+
+static void
+fxt1_quantize (GLuint *cc, const GLubyte *lines[], GLint comps)
+{
+ GLint trualpha;
+ GLubyte reord[N_TEXELS][MAX_COMP];
+
+ GLubyte input[N_TEXELS][MAX_COMP];
+ GLint i, k, l;
+
+ if (comps == 3) {
+ /* make the whole block opaque */
+ memset(input, -1, sizeof(input));
+ }
+
+ /* 8 texels each line */
+ for (l = 0; l < 4; l++) {
+ for (k = 0; k < 4; k++) {
+ for (i = 0; i < comps; i++) {
+ input[k + l * 4][i] = *lines[l]++;
+ }
+ }
+ for (; k < 8; k++) {
+ for (i = 0; i < comps; i++) {
+ input[k + l * 4 + 12][i] = *lines[l]++;
+ }
+ }
+ }
+
+ /* block layout:
+ * 00, 01, 02, 03, 08, 09, 0a, 0b
+ * 10, 11, 12, 13, 18, 19, 1a, 1b
+ * 04, 05, 06, 07, 0c, 0d, 0e, 0f
+ * 14, 15, 16, 17, 1c, 1d, 1e, 1f
+ */
+
+ /* [dBorca]
+ * stupidity flows forth from this
+ */
+ l = N_TEXELS;
+ trualpha = 0;
+ if (comps == 4) {
+ /* skip all transparent black texels */
+ l = 0;
+ for (k = 0; k < N_TEXELS; k++) {
+ /* test all components against 0 */
+ if (!ISTBLACK(input[k])) {
+ /* texel is not transparent black */
+ COPY_4UBV(reord[l], input[k]);
+ if (reord[l][ACOMP] < (255 - ALPHA_TS)) {
+ /* non-opaque texel */
+ trualpha = !0;
+ }
+ l++;
+ }
+ }
+ }
+
+#if 0
+ if (trualpha) {
+ fxt1_quantize_ALPHA0(cc, input, reord, l);
+ } else if (l == 0) {
+ cc[0] = cc[1] = cc[2] = -1;
+ cc[3] = 0;
+ } else if (l < N_TEXELS) {
+ fxt1_quantize_HI(cc, input, reord, l);
+ } else {
+ fxt1_quantize_CHROMA(cc, input);
+ }
+ (void)fxt1_quantize_ALPHA1;
+ (void)fxt1_quantize_MIXED1;
+ (void)fxt1_quantize_MIXED0;
+#else
+ if (trualpha) {
+ fxt1_quantize_ALPHA1(cc, input);
+ } else if (l == 0) {
+ cc[0] = cc[1] = cc[2] = ~0u;
+ cc[3] = 0;
+ } else if (l < N_TEXELS) {
+ fxt1_quantize_MIXED1(cc, input);
+ } else {
+ fxt1_quantize_MIXED0(cc, input);
+ }
+ (void)fxt1_quantize_ALPHA0;
+ (void)fxt1_quantize_HI;
+ (void)fxt1_quantize_CHROMA;
+#endif
+}
+
+
+static GLint
+fxt1_encode (GLuint width, GLuint height, GLint comps,
+ const void *source, GLint srcRowStride,
+ void *dest, GLint destRowStride)
+{
+ GLuint x, y;
+ const GLubyte *data;
+ GLuint *encoded = (GLuint *)dest;
+ GLubyte *newSource = NULL;
+
+ /* Replicate image if width is not M8 or height is not M4 */
+ if ((width & 7) | (height & 3)) {
+ GLint newWidth = (width + 7) & ~7;
+ GLint newHeight = (height + 3) & ~3;
+ newSource = (GLubyte *)
+ _mesa_malloc(comps * newWidth * newHeight * sizeof(GLubyte *));
+ _mesa_upscale_teximage2d(width, height, newWidth, newHeight,
+ comps, (const GLchan *) source,
+ srcRowStride, newSource);
+ source = newSource;
+ width = newWidth;
+ height = newHeight;
+ srcRowStride = comps * newWidth;
+ }
+
+ data = (const GLubyte *) source;
+ destRowStride = (destRowStride - width * 2) / 4;
+ for (y = 0; y < height; y += 4) {
+ GLuint offs = 0 + (y + 0) * srcRowStride;
+ for (x = 0; x < width; x += 8) {
+ const GLubyte *lines[4];
+ lines[0] = &data[offs];
+ lines[1] = lines[0] + srcRowStride;
+ lines[2] = lines[1] + srcRowStride;
+ lines[3] = lines[2] + srcRowStride;
+ offs += 8 * comps;
+ fxt1_quantize(encoded, lines, comps);
+ /* 128 bits per 8x4 block */
+ encoded += 4;
+ }
+ encoded += destRowStride;
+ }
+
+ if (newSource != NULL) {
+ _mesa_free(newSource);
+ }
+
+ return 0;
+}
+
+
+/***************************************************************************\
+ * FXT1 decoder
+ *
+ * The decoder is based on GL_3DFX_texture_compression_FXT1
+ * specification and serves as a concept for the encoder.
+\***************************************************************************/
+
+
+/* lookup table for scaling 5 bit colors up to 8 bits */
+static const GLubyte _rgb_scale_5[] = {
+ 0, 8, 16, 25, 33, 41, 49, 58,
+ 66, 74, 82, 90, 99, 107, 115, 123,
+ 132, 140, 148, 156, 165, 173, 181, 189,
+ 197, 206, 214, 222, 230, 239, 247, 255
+};
+
+/* lookup table for scaling 6 bit colors up to 8 bits */
+static const GLubyte _rgb_scale_6[] = {
+ 0, 4, 8, 12, 16, 20, 24, 28,
+ 32, 36, 40, 45, 49, 53, 57, 61,
+ 65, 69, 73, 77, 81, 85, 89, 93,
+ 97, 101, 105, 109, 113, 117, 121, 125,
+ 130, 134, 138, 142, 146, 150, 154, 158,
+ 162, 166, 170, 174, 178, 182, 186, 190,
+ 194, 198, 202, 206, 210, 215, 219, 223,
+ 227, 231, 235, 239, 243, 247, 251, 255
+};
+
+
+#define CC_SEL(cc, which) (((GLuint *)(cc))[(which) / 32] >> ((which) & 31))
+#define UP5(c) _rgb_scale_5[(c) & 31]
+#define UP6(c, b) _rgb_scale_6[(((c) & 31) << 1) | ((b) & 1)]
+#define LERP(n, t, c0, c1) (((n) - (t)) * (c0) + (t) * (c1) + (n) / 2) / (n)
+#define ZERO_4UBV(v) *((GLuint *)(v)) = 0
+
+
+static void
+fxt1_decode_1HI (const GLubyte *code, GLint t, GLubyte *rgba)
+{
+ const GLuint *cc;
+
+ t *= 3;
+ cc = (const GLuint *)(code + t / 8);
+ t = (cc[0] >> (t & 7)) & 7;
+
+ if (t == 7) {
+ ZERO_4UBV(rgba);
+ } else {
+ cc = (const GLuint *)(code + 12);
+ if (t == 0) {
+ rgba[BCOMP] = UP5(CC_SEL(cc, 0));
+ rgba[GCOMP] = UP5(CC_SEL(cc, 5));
+ rgba[RCOMP] = UP5(CC_SEL(cc, 10));
+ } else if (t == 6) {
+ rgba[BCOMP] = UP5(CC_SEL(cc, 15));
+ rgba[GCOMP] = UP5(CC_SEL(cc, 20));
+ rgba[RCOMP] = UP5(CC_SEL(cc, 25));
+ } else {
+ rgba[BCOMP] = LERP(6, t, UP5(CC_SEL(cc, 0)), UP5(CC_SEL(cc, 15)));
+ rgba[GCOMP] = LERP(6, t, UP5(CC_SEL(cc, 5)), UP5(CC_SEL(cc, 20)));
+ rgba[RCOMP] = LERP(6, t, UP5(CC_SEL(cc, 10)), UP5(CC_SEL(cc, 25)));
+ }
+ rgba[ACOMP] = 255;
+ }
+}
+
+
+static void
+fxt1_decode_1CHROMA (const GLubyte *code, GLint t, GLubyte *rgba)
+{
+ const GLuint *cc;
+ GLuint kk;
+
+ cc = (const GLuint *)code;
+ if (t & 16) {
+ cc++;
+ t &= 15;
+ }
+ t = (cc[0] >> (t * 2)) & 3;
+
+ t *= 15;
+ cc = (const GLuint *)(code + 8 + t / 8);
+ kk = cc[0] >> (t & 7);
+ rgba[BCOMP] = UP5(kk);
+ rgba[GCOMP] = UP5(kk >> 5);
+ rgba[RCOMP] = UP5(kk >> 10);
+ rgba[ACOMP] = 255;
+}
+
+
+static void
+fxt1_decode_1MIXED (const GLubyte *code, GLint t, GLubyte *rgba)
+{
+ const GLuint *cc;
+ GLuint col[2][3];
+ GLint glsb, selb;
+
+ cc = (const GLuint *)code;
+ if (t & 16) {
+ t &= 15;
+ t = (cc[1] >> (t * 2)) & 3;
+ /* col 2 */
+ col[0][BCOMP] = (*(const GLuint *)(code + 11)) >> 6;
+ col[0][GCOMP] = CC_SEL(cc, 99);
+ col[0][RCOMP] = CC_SEL(cc, 104);
+ /* col 3 */
+ col[1][BCOMP] = CC_SEL(cc, 109);
+ col[1][GCOMP] = CC_SEL(cc, 114);
+ col[1][RCOMP] = CC_SEL(cc, 119);
+ glsb = CC_SEL(cc, 126);
+ selb = CC_SEL(cc, 33);
+ } else {
+ t = (cc[0] >> (t * 2)) & 3;
+ /* col 0 */
+ col[0][BCOMP] = CC_SEL(cc, 64);
+ col[0][GCOMP] = CC_SEL(cc, 69);
+ col[0][RCOMP] = CC_SEL(cc, 74);
+ /* col 1 */
+ col[1][BCOMP] = CC_SEL(cc, 79);
+ col[1][GCOMP] = CC_SEL(cc, 84);
+ col[1][RCOMP] = CC_SEL(cc, 89);
+ glsb = CC_SEL(cc, 125);
+ selb = CC_SEL(cc, 1);
+ }
+
+ if (CC_SEL(cc, 124) & 1) {
+ /* alpha[0] == 1 */
+
+ if (t == 3) {
+ ZERO_4UBV(rgba);
+ } else {
+ if (t == 0) {
+ rgba[BCOMP] = UP5(col[0][BCOMP]);
+ rgba[GCOMP] = UP5(col[0][GCOMP]);
+ rgba[RCOMP] = UP5(col[0][RCOMP]);
+ } else if (t == 2) {
+ rgba[BCOMP] = UP5(col[1][BCOMP]);
+ rgba[GCOMP] = UP6(col[1][GCOMP], glsb);
+ rgba[RCOMP] = UP5(col[1][RCOMP]);
+ } else {
+ rgba[BCOMP] = (UP5(col[0][BCOMP]) + UP5(col[1][BCOMP])) / 2;
+ rgba[GCOMP] = (UP5(col[0][GCOMP]) + UP6(col[1][GCOMP], glsb)) / 2;
+ rgba[RCOMP] = (UP5(col[0][RCOMP]) + UP5(col[1][RCOMP])) / 2;
+ }
+ rgba[ACOMP] = 255;
+ }
+ } else {
+ /* alpha[0] == 0 */
+
+ if (t == 0) {
+ rgba[BCOMP] = UP5(col[0][BCOMP]);
+ rgba[GCOMP] = UP6(col[0][GCOMP], glsb ^ selb);
+ rgba[RCOMP] = UP5(col[0][RCOMP]);
+ } else if (t == 3) {
+ rgba[BCOMP] = UP5(col[1][BCOMP]);
+ rgba[GCOMP] = UP6(col[1][GCOMP], glsb);
+ rgba[RCOMP] = UP5(col[1][RCOMP]);
+ } else {
+ rgba[BCOMP] = LERP(3, t, UP5(col[0][BCOMP]), UP5(col[1][BCOMP]));
+ rgba[GCOMP] = LERP(3, t, UP6(col[0][GCOMP], glsb ^ selb),
+ UP6(col[1][GCOMP], glsb));
+ rgba[RCOMP] = LERP(3, t, UP5(col[0][RCOMP]), UP5(col[1][RCOMP]));
+ }
+ rgba[ACOMP] = 255;
+ }
+}
+
+
+static void
+fxt1_decode_1ALPHA (const GLubyte *code, GLint t, GLubyte *rgba)
+{
+ const GLuint *cc;
+
+ cc = (const GLuint *)code;
+ if (CC_SEL(cc, 124) & 1) {
+ /* lerp == 1 */
+ GLuint col0[4];
+
+ if (t & 16) {
+ t &= 15;
+ t = (cc[1] >> (t * 2)) & 3;
+ /* col 2 */
+ col0[BCOMP] = (*(const GLuint *)(code + 11)) >> 6;
+ col0[GCOMP] = CC_SEL(cc, 99);
+ col0[RCOMP] = CC_SEL(cc, 104);
+ col0[ACOMP] = CC_SEL(cc, 119);
+ } else {
+ t = (cc[0] >> (t * 2)) & 3;
+ /* col 0 */
+ col0[BCOMP] = CC_SEL(cc, 64);
+ col0[GCOMP] = CC_SEL(cc, 69);
+ col0[RCOMP] = CC_SEL(cc, 74);
+ col0[ACOMP] = CC_SEL(cc, 109);
+ }
+
+ if (t == 0) {
+ rgba[BCOMP] = UP5(col0[BCOMP]);
+ rgba[GCOMP] = UP5(col0[GCOMP]);
+ rgba[RCOMP] = UP5(col0[RCOMP]);
+ rgba[ACOMP] = UP5(col0[ACOMP]);
+ } else if (t == 3) {
+ rgba[BCOMP] = UP5(CC_SEL(cc, 79));
+ rgba[GCOMP] = UP5(CC_SEL(cc, 84));
+ rgba[RCOMP] = UP5(CC_SEL(cc, 89));
+ rgba[ACOMP] = UP5(CC_SEL(cc, 114));
+ } else {
+ rgba[BCOMP] = LERP(3, t, UP5(col0[BCOMP]), UP5(CC_SEL(cc, 79)));
+ rgba[GCOMP] = LERP(3, t, UP5(col0[GCOMP]), UP5(CC_SEL(cc, 84)));
+ rgba[RCOMP] = LERP(3, t, UP5(col0[RCOMP]), UP5(CC_SEL(cc, 89)));
+ rgba[ACOMP] = LERP(3, t, UP5(col0[ACOMP]), UP5(CC_SEL(cc, 114)));
+ }
+ } else {
+ /* lerp == 0 */
+
+ if (t & 16) {
+ cc++;
+ t &= 15;
+ }
+ t = (cc[0] >> (t * 2)) & 3;
+
+ if (t == 3) {
+ ZERO_4UBV(rgba);
+ } else {
+ GLuint kk;
+ cc = (const GLuint *)code;
+ rgba[ACOMP] = UP5(cc[3] >> (t * 5 + 13));
+ t *= 15;
+ cc = (const GLuint *)(code + 8 + t / 8);
+ kk = cc[0] >> (t & 7);
+ rgba[BCOMP] = UP5(kk);
+ rgba[GCOMP] = UP5(kk >> 5);
+ rgba[RCOMP] = UP5(kk >> 10);
+ }
+ }
+}
+
+
+void
+fxt1_decode_1 (const void *texture, GLint stride, /* in pixels */
+ GLint i, GLint j, GLubyte *rgba)
+{
+ static void (*decode_1[]) (const GLubyte *, GLint, GLubyte *) = {
+ fxt1_decode_1HI, /* cc-high = "00?" */
+ fxt1_decode_1HI, /* cc-high = "00?" */
+ fxt1_decode_1CHROMA, /* cc-chroma = "010" */
+ fxt1_decode_1ALPHA, /* alpha = "011" */
+ fxt1_decode_1MIXED, /* mixed = "1??" */
+ fxt1_decode_1MIXED, /* mixed = "1??" */
+ fxt1_decode_1MIXED, /* mixed = "1??" */
+ fxt1_decode_1MIXED /* mixed = "1??" */
+ };
+
+ const GLubyte *code = (const GLubyte *)texture +
+ ((j / 4) * (stride / 8) + (i / 8)) * 16;
+ GLint mode = CC_SEL(code, 125);
+ GLint t = i & 7;
+
+ if (t & 4) {
+ t += 12;
+ }
+ t += (j & 3) * 4;
+
+ decode_1[mode](code, t, rgba);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/texcompress_s3tc.c b/nx-X11/extras/Mesa/src/mesa/main/texcompress_s3tc.c
new file mode 100644
index 000000000..44ab9e2ac
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/texcompress_s3tc.c
@@ -0,0 +1,555 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file texcompress_s3tc.c
+ * GL_EXT_texture_compression_s3tc support.
+ */
+
+#ifndef USE_EXTERNAL_DXTN_LIB
+#define USE_EXTERNAL_DXTN_LIB 0
+#endif
+
+#include "glheader.h"
+#include "imports.h"
+#include "colormac.h"
+#include "context.h"
+#include "convolve.h"
+#include "image.h"
+#include "texcompress.h"
+#include "texformat.h"
+#include "texstore.h"
+
+#if USE_EXTERNAL_DXTN_LIB
+#ifdef __MINGW32__
+/* no dlopen */
+#define DXTN_EXT "dxtn.dll"
+#define DXTN_PREFIX ""
+#define dlopen(name, mode) LoadLibrary(name)
+#define dlsym(hndl, proc) GetProcAddress(hndl, proc)
+#define dlclose(hndl) FreeLibrary(hndl)
+#elif defined(__DJGPP__)
+/* has dlopen, but doesn't like the names */
+#include <dlfcn.h>
+#define DXTN_EXT "dxtn.dxe"
+#define DXTN_PREFIX "_"
+#else
+/* happiness */
+#include <dlfcn.h>
+#define DXTN_EXT "libtxc_dxtn.so"
+#define DXTN_PREFIX ""
+#endif
+#endif /* USE_EXTERNAL_DXTN_LIB */
+
+typedef void (*dxtFetchTexelFuncExt)( GLint srcRowstride, GLubyte *pixdata, GLint col, GLint row, GLvoid *texelOut );
+dxtFetchTexelFuncExt fetch_ext_rgb_dxt1 = NULL;
+dxtFetchTexelFuncExt fetch_ext_rgba_dxt1 = NULL;
+dxtFetchTexelFuncExt fetch_ext_rgba_dxt3 = NULL;
+dxtFetchTexelFuncExt fetch_ext_rgba_dxt5 = NULL;
+
+typedef void (*dxtCompressTexFuncExt)(GLint srccomps, GLint width, GLint height, const GLubyte *srcPixData, GLenum destformat, GLubyte *dest, GLint dstRowStride);
+dxtCompressTexFuncExt ext_tx_compress_dxtn = NULL;
+
+void *dxtlibhandle = NULL;
+
+void
+_mesa_init_texture_s3tc( GLcontext *ctx )
+{
+ /* called during context initialization */
+ ctx->Mesa_DXTn = GL_FALSE;
+#if USE_EXTERNAL_DXTN_LIB
+ if (!dxtlibhandle) {
+ dxtlibhandle = dlopen (DXTN_EXT, RTLD_LAZY | RTLD_GLOBAL);
+ if (!dxtlibhandle) {
+ _mesa_warning(ctx, "couldn't open " DXTN_EXT ", software DXTn "
+ "compression/decompression unavailable\n");
+ }
+ else {
+ /* the fetch functions are not per context! Might be problematic... */
+ fetch_ext_rgb_dxt1 = (dxtFetchTexelFuncExt)dlsym(dxtlibhandle, DXTN_PREFIX "fetch_2d_texel_rgb_dxt1");
+ if (fetch_ext_rgb_dxt1 != NULL) {
+ fetch_ext_rgba_dxt1 = (dxtFetchTexelFuncExt)dlsym(dxtlibhandle, DXTN_PREFIX "fetch_2d_texel_rgba_dxt1");
+ }
+ if (fetch_ext_rgba_dxt1 != NULL) {
+ fetch_ext_rgba_dxt3 = (dxtFetchTexelFuncExt)dlsym(dxtlibhandle, DXTN_PREFIX "fetch_2d_texel_rgba_dxt3");
+ }
+ if (fetch_ext_rgba_dxt3 != NULL) {
+ fetch_ext_rgba_dxt5 = (dxtFetchTexelFuncExt)dlsym(dxtlibhandle, DXTN_PREFIX "fetch_2d_texel_rgba_dxt5");
+ }
+ if (fetch_ext_rgba_dxt5 != NULL) {
+ ext_tx_compress_dxtn = (dxtCompressTexFuncExt)dlsym(dxtlibhandle, DXTN_PREFIX "tx_compress_dxtn");
+ }
+
+ if (ext_tx_compress_dxtn == NULL) {
+ _mesa_warning(ctx, "couldn't reference all symbols in "
+ DXTN_EXT ", software DXTn compression/decompression "
+ "unavailable\n");
+ fetch_ext_rgb_dxt1 = NULL;
+ fetch_ext_rgba_dxt1 = NULL;
+ fetch_ext_rgba_dxt3 = NULL;
+ fetch_ext_rgba_dxt5 = NULL;
+ ext_tx_compress_dxtn = NULL;
+ dlclose(dxtlibhandle);
+ dxtlibhandle = NULL;
+ }
+ }
+ }
+ if (dxtlibhandle) {
+ ctx->Mesa_DXTn = GL_TRUE;
+ _mesa_warning(ctx, "software DXTn compression/decompression available\n");
+ }
+#else
+ (void) ctx;
+#endif
+}
+
+/**
+ * Called via TexFormat->StoreImage to store an RGB_DXT1 texture.
+ */
+static GLboolean
+texstore_rgb_dxt1(STORE_PARAMS)
+{
+ const GLchan *pixels;
+ GLint srcRowStride;
+ GLubyte *dst;
+ const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
+ const GLchan *tempImage = NULL;
+
+ ASSERT(dstFormat == &_mesa_texformat_rgb_dxt1);
+ ASSERT(dstXoffset % 4 == 0);
+ ASSERT(dstYoffset % 4 == 0);
+ ASSERT(dstZoffset % 4 == 0);
+ (void) dstZoffset; (void) dstImageStride;
+
+ if (srcFormat != GL_RGB ||
+ srcType != CHAN_TYPE ||
+ ctx->_ImageTransferState ||
+ srcPacking->SwapBytes) {
+ /* convert image to RGB/GLchan */
+ tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ if (!tempImage)
+ return GL_FALSE; /* out of memory */
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ pixels = tempImage;
+ srcRowStride = 3 * srcWidth;
+ srcFormat = GL_RGB;
+ }
+ else {
+ pixels = (const GLchan *) srcAddr;
+ srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
+ srcType) / sizeof(GLchan);
+ }
+
+ dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
+ GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
+ texWidth, (GLubyte *) dstAddr);
+
+ if (ext_tx_compress_dxtn) {
+ (*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, dst, dstRowStride);
+ }
+ else {
+ _mesa_problem(ctx, "external dxt library not available");
+ }
+
+ if (tempImage)
+ _mesa_free((void *) tempImage);
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Called via TexFormat->StoreImage to store an RGBA_DXT1 texture.
+ */
+static GLboolean
+texstore_rgba_dxt1(STORE_PARAMS)
+{
+ const GLchan *pixels;
+ GLint srcRowStride;
+ GLubyte *dst;
+ const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
+ const GLchan *tempImage = NULL;
+
+ ASSERT(dstFormat == &_mesa_texformat_rgba_dxt1);
+ ASSERT(dstXoffset % 4 == 0);
+ ASSERT(dstYoffset % 4 == 0);
+ ASSERT(dstZoffset % 4 == 0);
+ (void) dstZoffset; (void) dstImageStride;
+
+ if (srcFormat != GL_RGBA ||
+ srcType != CHAN_TYPE ||
+ ctx->_ImageTransferState ||
+ srcPacking->SwapBytes) {
+ /* convert image to RGBA/GLchan */
+ tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ if (!tempImage)
+ return GL_FALSE; /* out of memory */
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ pixels = tempImage;
+ srcRowStride = 4 * srcWidth;
+ srcFormat = GL_RGBA;
+ }
+ else {
+ pixels = (const GLchan *) srcAddr;
+ srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
+ srcType) / sizeof(GLchan);
+ }
+
+ dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
+ GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
+ texWidth, (GLubyte *) dstAddr);
+ if (ext_tx_compress_dxtn) {
+ (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, dst, dstRowStride);
+ }
+ else {
+ _mesa_problem(ctx, "external dxt library not available");
+ }
+
+ if (tempImage)
+ _mesa_free((void*) tempImage);
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Called via TexFormat->StoreImage to store an RGBA_DXT3 texture.
+ */
+static GLboolean
+texstore_rgba_dxt3(STORE_PARAMS)
+{
+ const GLchan *pixels;
+ GLint srcRowStride;
+ GLubyte *dst;
+ const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
+ const GLchan *tempImage = NULL;
+
+ ASSERT(dstFormat == &_mesa_texformat_rgba_dxt3);
+ ASSERT(dstXoffset % 4 == 0);
+ ASSERT(dstYoffset % 4 == 0);
+ ASSERT(dstZoffset % 4 == 0);
+ (void) dstZoffset; (void) dstImageStride;
+
+ if (srcFormat != GL_RGBA ||
+ srcType != CHAN_TYPE ||
+ ctx->_ImageTransferState ||
+ srcPacking->SwapBytes) {
+ /* convert image to RGBA/GLchan */
+ tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ if (!tempImage)
+ return GL_FALSE; /* out of memory */
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ pixels = tempImage;
+ srcRowStride = 4 * srcWidth;
+ }
+ else {
+ pixels = (const GLchan *) srcAddr;
+ srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
+ srcType) / sizeof(GLchan);
+ }
+
+ dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
+ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
+ texWidth, (GLubyte *) dstAddr);
+ if (ext_tx_compress_dxtn) {
+ (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, dst, dstRowStride);
+ }
+ else {
+ _mesa_problem(ctx, "external dxt library not available");
+ }
+
+ if (tempImage)
+ _mesa_free((void *) tempImage);
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Called via TexFormat->StoreImage to store an RGBA_DXT5 texture.
+ */
+static GLboolean
+texstore_rgba_dxt5(STORE_PARAMS)
+{
+ const GLchan *pixels;
+ GLint srcRowStride;
+ GLubyte *dst;
+ const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
+ const GLchan *tempImage = NULL;
+
+ ASSERT(dstFormat == &_mesa_texformat_rgba_dxt5);
+ ASSERT(dstXoffset % 4 == 0);
+ ASSERT(dstYoffset % 4 == 0);
+ ASSERT(dstZoffset % 4 == 0);
+ (void) dstZoffset; (void) dstImageStride;
+
+ if (srcFormat != GL_RGBA ||
+ srcType != CHAN_TYPE ||
+ ctx->_ImageTransferState ||
+ srcPacking->SwapBytes) {
+ /* convert image to RGBA/GLchan */
+ tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ if (!tempImage)
+ return GL_FALSE; /* out of memory */
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ pixels = tempImage;
+ srcRowStride = 4 * srcWidth;
+ }
+ else {
+ pixels = (const GLchan *) srcAddr;
+ srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
+ srcType) / sizeof(GLchan);
+ }
+
+ dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
+ GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
+ texWidth, (GLubyte *) dstAddr);
+ if (ext_tx_compress_dxtn) {
+ (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, dst, dstRowStride);
+ }
+ else {
+ _mesa_problem(ctx, "external dxt library not available");
+ }
+
+ if (tempImage)
+ _mesa_free((void *) tempImage);
+
+ return GL_TRUE;
+}
+
+
+static void
+fetch_texel_2d_rgb_dxt1( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ (void) k;
+ if (fetch_ext_rgb_dxt1) {
+ ASSERT (sizeof(GLchan) == sizeof(GLubyte));
+ (*fetch_ext_rgb_dxt1)((texImage)->RowStride, (GLubyte *)(texImage)->Data, i, j, texel);
+ }
+ else _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n");
+}
+
+
+static void
+fetch_texel_2d_f_rgb_dxt1( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ /* just sample as GLchan and convert to float here */
+ GLchan rgba[4];
+ fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba);
+ texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
+ texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
+ texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
+ texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
+}
+
+
+static void
+fetch_texel_2d_rgba_dxt1( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ (void) k;
+ if (fetch_ext_rgba_dxt1) {
+ (*fetch_ext_rgba_dxt1)((texImage)->RowStride, (GLubyte *)(texImage)->Data, i, j, texel);
+ }
+ else _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n");
+}
+
+
+static void
+fetch_texel_2d_f_rgba_dxt1( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ /* just sample as GLchan and convert to float here */
+ GLchan rgba[4];
+ fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba);
+ texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
+ texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
+ texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
+ texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
+}
+
+
+static void
+fetch_texel_2d_rgba_dxt3( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ (void) k;
+ if (fetch_ext_rgba_dxt3) {
+ ASSERT (sizeof(GLchan) == sizeof(GLubyte));
+ (*fetch_ext_rgba_dxt3)((texImage)->RowStride, (GLubyte *)(texImage)->Data, i, j, texel);
+ }
+ else _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n");
+}
+
+
+static void
+fetch_texel_2d_f_rgba_dxt3( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ /* just sample as GLchan and convert to float here */
+ GLchan rgba[4];
+ fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba);
+ texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
+ texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
+ texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
+ texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
+}
+
+
+static void
+fetch_texel_2d_rgba_dxt5( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ (void) k;
+ if (fetch_ext_rgba_dxt5) {
+ (*fetch_ext_rgba_dxt5)((texImage)->RowStride, (GLubyte *)(texImage)->Data, i, j, texel);
+ }
+ else _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n");
+}
+
+
+static void
+fetch_texel_2d_f_rgba_dxt5( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ /* just sample as GLchan and convert to float here */
+ GLchan rgba[4];
+ fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba);
+ texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
+ texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
+ texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
+ texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
+}
+
+
+const struct gl_texture_format _mesa_texformat_rgb_dxt1 = {
+ MESA_FORMAT_RGB_DXT1, /* MesaFormat */
+ GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 4, /*approx*/ /* RedBits */
+ 4, /*approx*/ /* GreenBits */
+ 4, /*approx*/ /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 0, /* TexelBytes */
+ texstore_rgb_dxt1, /* StoreTexImageFunc */
+ NULL, /*impossible*/ /* FetchTexel1D */
+ fetch_texel_2d_rgb_dxt1, /* FetchTexel2D */
+ NULL, /*impossible*/ /* FetchTexel3D */
+ NULL, /*impossible*/ /* FetchTexel1Df */
+ fetch_texel_2d_f_rgb_dxt1, /* FetchTexel2Df */
+ NULL, /*impossible*/ /* FetchTexel3Df */
+};
+
+const struct gl_texture_format _mesa_texformat_rgba_dxt1 = {
+ MESA_FORMAT_RGBA_DXT1, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 4, /*approx*/ /* RedBits */
+ 4, /*approx*/ /* GreenBits */
+ 4, /*approx*/ /* BlueBits */
+ 1, /*approx*/ /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 0, /* TexelBytes */
+ texstore_rgba_dxt1, /* StoreTexImageFunc */
+ NULL, /*impossible*/ /* FetchTexel1D */
+ fetch_texel_2d_rgba_dxt1, /* FetchTexel2D */
+ NULL, /*impossible*/ /* FetchTexel3D */
+ NULL, /*impossible*/ /* FetchTexel1Df */
+ fetch_texel_2d_f_rgba_dxt1, /* FetchTexel2Df */
+ NULL, /*impossible*/ /* FetchTexel3Df */
+};
+
+const struct gl_texture_format _mesa_texformat_rgba_dxt3 = {
+ MESA_FORMAT_RGBA_DXT3, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 4, /*approx*/ /* RedBits */
+ 4, /*approx*/ /* GreenBits */
+ 4, /*approx*/ /* BlueBits */
+ 4, /*approx*/ /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 0, /* TexelBytes */
+ texstore_rgba_dxt3, /* StoreTexImageFunc */
+ NULL, /*impossible*/ /* FetchTexel1D */
+ fetch_texel_2d_rgba_dxt3, /* FetchTexel2D */
+ NULL, /*impossible*/ /* FetchTexel3D */
+ NULL, /*impossible*/ /* FetchTexel1Df */
+ fetch_texel_2d_f_rgba_dxt3, /* FetchTexel2Df */
+ NULL, /*impossible*/ /* FetchTexel3Df */
+};
+
+const struct gl_texture_format _mesa_texformat_rgba_dxt5 = {
+ MESA_FORMAT_RGBA_DXT5, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 4,/*approx*/ /* RedBits */
+ 4,/*approx*/ /* GreenBits */
+ 4,/*approx*/ /* BlueBits */
+ 4,/*approx*/ /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 0, /* TexelBytes */
+ texstore_rgba_dxt5, /* StoreTexImageFunc */
+ NULL, /*impossible*/ /* FetchTexel1D */
+ fetch_texel_2d_rgba_dxt5, /* FetchTexel2D */
+ NULL, /*impossible*/ /* FetchTexel3D */
+ NULL, /*impossible*/ /* FetchTexel1Df */
+ fetch_texel_2d_f_rgba_dxt5, /* FetchTexel2Df */
+ NULL, /*impossible*/ /* FetchTexel3Df */
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/main/texenvprogram.c b/nx-X11/extras/Mesa/src/mesa/main/texenvprogram.c
new file mode 100644
index 000000000..4cb97469a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/texenvprogram.c
@@ -0,0 +1,1165 @@
+/**************************************************************************
+ *
+ * Copyright 2003 Tungsten Graphics, 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 TUNGSTEN GRAPHICS 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.
+ *
+ **************************************************************************/
+
+#include "glheader.h"
+#include "macros.h"
+#include "enums.h"
+#include "texenvprogram.h"
+
+#include "shader/program.h"
+#include "shader/nvfragprog.h"
+#include "shader/arbfragparse.h"
+
+
+#define DISASSEM (MESA_VERBOSE & VERBOSE_DISASSEM)
+
+struct mode_opt {
+ unsigned Source:4;
+ unsigned Operand:3;
+};
+
+struct state_key {
+ GLuint enabled_units;
+ unsigned separate_specular:1;
+ unsigned fog_enabled:1;
+ unsigned fog_mode:2;
+
+ struct {
+ unsigned enabled:1;
+ unsigned source_index:3;
+ unsigned ScaleShiftRGB:2;
+ unsigned ScaleShiftA:2;
+
+ unsigned NumArgsRGB:2;
+ unsigned ModeRGB:4;
+ struct mode_opt OptRGB[3];
+
+ unsigned NumArgsA:2;
+ unsigned ModeA:4;
+ struct mode_opt OptA[3];
+ } unit[8];
+};
+
+#define FOG_LINEAR 0
+#define FOG_EXP 1
+#define FOG_EXP2 2
+#define FOG_UNKNOWN 3
+
+static GLuint translate_fog_mode( GLenum mode )
+{
+ switch (mode) {
+ case GL_LINEAR: return FOG_LINEAR;
+ case GL_EXP: return FOG_EXP;
+ case GL_EXP2: return FOG_EXP2;
+ default: return FOG_UNKNOWN;
+ }
+}
+
+#define OPR_SRC_COLOR 0
+#define OPR_ONE_MINUS_SRC_COLOR 1
+#define OPR_SRC_ALPHA 2
+#define OPR_ONE_MINUS_SRC_ALPHA 3
+#define OPR_ZERO 4
+#define OPR_ONE 5
+#define OPR_UNKNOWN 7
+
+static GLuint translate_operand( GLenum operand )
+{
+ switch (operand) {
+ case GL_SRC_COLOR: return OPR_SRC_COLOR;
+ case GL_ONE_MINUS_SRC_COLOR: return OPR_ONE_MINUS_SRC_COLOR;
+ case GL_SRC_ALPHA: return OPR_SRC_ALPHA;
+ case GL_ONE_MINUS_SRC_ALPHA: return OPR_ONE_MINUS_SRC_ALPHA;
+ case GL_ZERO: return OPR_ZERO;
+ case GL_ONE: return OPR_ONE;
+ default: return OPR_UNKNOWN;
+ }
+}
+
+#define SRC_TEXTURE 0
+#define SRC_TEXTURE0 1
+#define SRC_TEXTURE1 2
+#define SRC_TEXTURE2 3
+#define SRC_TEXTURE3 4
+#define SRC_TEXTURE4 5
+#define SRC_TEXTURE5 6
+#define SRC_TEXTURE6 7
+#define SRC_TEXTURE7 8
+#define SRC_CONSTANT 9
+#define SRC_PRIMARY_COLOR 10
+#define SRC_PREVIOUS 11
+#define SRC_UNKNOWN 15
+
+static GLuint translate_source( GLenum src )
+{
+ switch (src) {
+ case GL_TEXTURE: return SRC_TEXTURE;
+ case GL_TEXTURE0:
+ case GL_TEXTURE1:
+ case GL_TEXTURE2:
+ case GL_TEXTURE3:
+ case GL_TEXTURE4:
+ case GL_TEXTURE5:
+ case GL_TEXTURE6:
+ case GL_TEXTURE7: return SRC_TEXTURE0 + (src - GL_TEXTURE0);
+ case GL_CONSTANT: return SRC_CONSTANT;
+ case GL_PRIMARY_COLOR: return SRC_PRIMARY_COLOR;
+ case GL_PREVIOUS: return SRC_PREVIOUS;
+ default: return SRC_UNKNOWN;
+ }
+}
+
+#define MODE_REPLACE 0
+#define MODE_MODULATE 1
+#define MODE_ADD 2
+#define MODE_ADD_SIGNED 3
+#define MODE_INTERPOLATE 4
+#define MODE_SUBTRACT 5
+#define MODE_DOT3_RGB 6
+#define MODE_DOT3_RGB_EXT 7
+#define MODE_DOT3_RGBA 8
+#define MODE_DOT3_RGBA_EXT 9
+#define MODE_MODULATE_ADD_ATI 10
+#define MODE_MODULATE_SIGNED_ADD_ATI 11
+#define MODE_MODULATE_SUBTRACT_ATI 12
+#define MODE_UNKNOWN 15
+
+static GLuint translate_mode( GLenum mode )
+{
+ switch (mode) {
+ case GL_REPLACE: return MODE_REPLACE;
+ case GL_MODULATE: return MODE_MODULATE;
+ case GL_ADD: return MODE_ADD;
+ case GL_ADD_SIGNED: return MODE_ADD_SIGNED;
+ case GL_INTERPOLATE: return MODE_INTERPOLATE;
+ case GL_SUBTRACT: return MODE_SUBTRACT;
+ case GL_DOT3_RGB: return MODE_DOT3_RGB;
+ case GL_DOT3_RGB_EXT: return MODE_DOT3_RGB_EXT;
+ case GL_DOT3_RGBA: return MODE_DOT3_RGBA;
+ case GL_DOT3_RGBA_EXT: return MODE_DOT3_RGBA_EXT;
+ case GL_MODULATE_ADD_ATI: return MODE_MODULATE_ADD_ATI;
+ case GL_MODULATE_SIGNED_ADD_ATI: return MODE_MODULATE_SIGNED_ADD_ATI;
+ case GL_MODULATE_SUBTRACT_ATI: return MODE_MODULATE_SUBTRACT_ATI;
+ default: return MODE_UNKNOWN;
+ }
+}
+
+#define TEXTURE_UNKNOWN_INDEX 7
+static GLuint translate_tex_src_bit( GLuint bit )
+{
+ switch (bit) {
+ case TEXTURE_1D_BIT: return TEXTURE_1D_INDEX;
+ case TEXTURE_2D_BIT: return TEXTURE_2D_INDEX;
+ case TEXTURE_RECT_BIT: return TEXTURE_RECT_INDEX;
+ case TEXTURE_3D_BIT: return TEXTURE_3D_INDEX;
+ case TEXTURE_CUBE_BIT: return TEXTURE_CUBE_INDEX;
+ default: return TEXTURE_UNKNOWN_INDEX;
+ }
+}
+
+static struct state_key *make_state_key( GLcontext *ctx )
+{
+ struct state_key *key = CALLOC_STRUCT(state_key);
+ GLuint i, j;
+
+ for (i=0;i<MAX_TEXTURE_UNITS;i++) {
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
+
+ if (!texUnit->_ReallyEnabled)
+ continue;
+
+ key->unit[i].enabled = 1;
+ key->enabled_units |= (1<<i);
+
+ key->unit[i].source_index =
+ translate_tex_src_bit(texUnit->_ReallyEnabled);
+
+ key->unit[i].NumArgsRGB = texUnit->_CurrentCombine->_NumArgsRGB;
+ key->unit[i].NumArgsA = texUnit->_CurrentCombine->_NumArgsA;
+
+ key->unit[i].ModeRGB =
+ translate_mode(texUnit->_CurrentCombine->ModeRGB);
+ key->unit[i].ModeA =
+ translate_mode(texUnit->_CurrentCombine->ModeA);
+
+ key->unit[i].ScaleShiftRGB = texUnit->_CurrentCombine->ScaleShiftRGB;
+ key->unit[i].ScaleShiftA = texUnit->_CurrentCombine->ScaleShiftRGB;
+
+ for (j=0;j<3;j++) {
+ key->unit[i].OptRGB[j].Operand =
+ translate_operand(texUnit->_CurrentCombine->OperandRGB[j]);
+ key->unit[i].OptA[j].Operand =
+ translate_operand(texUnit->_CurrentCombine->OperandA[j]);
+ key->unit[i].OptRGB[j].Source =
+ translate_source(texUnit->_CurrentCombine->SourceRGB[j]);
+ key->unit[i].OptA[j].Source =
+ translate_source(texUnit->_CurrentCombine->SourceA[j]);
+ }
+ }
+
+ if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR)
+ key->separate_specular = 1;
+
+ if (ctx->Fog.Enabled) {
+ key->fog_enabled = 1;
+ key->fog_mode = translate_fog_mode(ctx->Fog.Mode);
+ }
+
+ return key;
+}
+
+/* Use uregs to represent registers internally, translate to Mesa's
+ * expected formats on emit.
+ *
+ * NOTE: These are passed by value extensively in this file rather
+ * than as usual by pointer reference. If this disturbs you, try
+ * remembering they are just 32bits in size.
+ *
+ * GCC is smart enough to deal with these dword-sized structures in
+ * much the same way as if I had defined them as dwords and was using
+ * macros to access and set the fields. This is much nicer and easier
+ * to evolve.
+ */
+struct ureg {
+ GLuint file:4;
+ GLuint idx:8;
+ GLuint negatebase:1;
+ GLuint abs:1;
+ GLuint negateabs:1;
+ GLuint swz:12;
+ GLuint pad:5;
+};
+
+const static struct ureg undef = {
+ ~0,
+ ~0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0
+};
+
+#define X 0
+#define Y 1
+#define Z 2
+#define W 3
+
+/* State used to build the fragment program:
+ */
+struct texenv_fragment_program {
+ struct fragment_program *program;
+ GLcontext *ctx;
+ struct state_key *state;
+
+ GLuint alu_temps; /* Track texture indirections, see spec. */
+ GLuint temps_output; /* Track texture indirections, see spec. */
+
+ GLuint temp_in_use; /* Tracks temporary regs which are in
+ * use.
+ */
+
+
+ GLboolean error;
+
+ struct ureg src_texture[MAX_TEXTURE_UNITS];
+ /* Reg containing each texture unit's sampled texture color,
+ * else undef.
+ */
+
+ struct ureg src_previous; /* Reg containing color from previous
+ * stage. May need to be decl'd.
+ */
+
+ GLuint last_tex_stage; /* Number of last enabled texture unit */
+
+ struct ureg half;
+ struct ureg one;
+ struct ureg zero;
+};
+
+
+
+static struct ureg make_ureg(GLuint file, GLuint idx)
+{
+ struct ureg reg;
+ reg.file = file;
+ reg.idx = idx;
+ reg.negatebase = 0;
+ reg.abs = 0;
+ reg.negateabs = 0;
+ reg.swz = SWIZZLE_NOOP;
+ reg.pad = 0;
+ return reg;
+}
+
+static struct ureg swizzle( struct ureg reg, int x, int y, int z, int w )
+{
+ reg.swz = MAKE_SWIZZLE4(GET_SWZ(reg.swz, x),
+ GET_SWZ(reg.swz, y),
+ GET_SWZ(reg.swz, z),
+ GET_SWZ(reg.swz, w));
+
+ return reg;
+}
+
+static struct ureg swizzle1( struct ureg reg, int x )
+{
+ return swizzle(reg, x, x, x, x);
+}
+
+static struct ureg negate( struct ureg reg )
+{
+ reg.negatebase ^= 1;
+ return reg;
+}
+
+static GLboolean is_undef( struct ureg reg )
+{
+ return reg.file == 0xf;
+}
+
+
+static struct ureg get_temp( struct texenv_fragment_program *p )
+{
+ int bit;
+
+ /* First try and reuse temps which have been used already:
+ */
+ bit = ffs( ~p->temp_in_use & p->alu_temps );
+
+ /* Then any unused temporary:
+ */
+ if (!bit)
+ bit = ffs( ~p->temp_in_use );
+
+ if (!bit) {
+ _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__);
+ exit(1);
+ }
+
+ p->temp_in_use |= 1<<(bit-1);
+ return make_ureg(PROGRAM_TEMPORARY, (bit-1));
+}
+
+static struct ureg get_tex_temp( struct texenv_fragment_program *p )
+{
+ int bit;
+
+ /* First try to find availble temp not previously used (to avoid
+ * starting a new texture indirection). According to the spec, the
+ * ~p->temps_output isn't necessary, but will keep it there for
+ * now:
+ */
+ bit = ffs( ~p->temp_in_use & ~p->alu_temps & ~p->temps_output );
+
+ /* Then any unused temporary:
+ */
+ if (!bit)
+ bit = ffs( ~p->temp_in_use );
+
+ if (!bit) {
+ _mesa_problem(NULL, "%s: out of temporaries\n", __FILE__);
+ exit(1);
+ }
+
+ p->temp_in_use |= 1<<(bit-1);
+ return make_ureg(PROGRAM_TEMPORARY, (bit-1));
+}
+
+
+static void release_temps( struct texenv_fragment_program *p )
+{
+ GLuint max_temp = p->ctx->Const.MaxFragmentProgramTemps;
+
+ /* KW: To support tex_env_crossbar, don't release the registers in
+ * temps_output.
+ */
+ if (max_temp >= sizeof(int) * 8)
+ p->temp_in_use = p->temps_output;
+ else
+ p->temp_in_use = ~((1<<max_temp)-1) | p->temps_output;
+}
+
+
+static struct ureg register_param6( struct texenv_fragment_program *p,
+ GLint s0,
+ GLint s1,
+ GLint s2,
+ GLint s3,
+ GLint s4,
+ GLint s5)
+{
+ GLint tokens[6];
+ GLuint idx;
+ tokens[0] = s0;
+ tokens[1] = s1;
+ tokens[2] = s2;
+ tokens[3] = s3;
+ tokens[4] = s4;
+ tokens[5] = s5;
+ idx = _mesa_add_state_reference( p->program->Parameters, tokens );
+ return make_ureg(PROGRAM_STATE_VAR, idx);
+}
+
+
+#define register_param1(p,s0) register_param6(p,s0,0,0,0,0,0)
+#define register_param2(p,s0,s1) register_param6(p,s0,s1,0,0,0,0)
+#define register_param3(p,s0,s1,s2) register_param6(p,s0,s1,s2,0,0,0)
+#define register_param4(p,s0,s1,s2,s3) register_param6(p,s0,s1,s2,s3,0,0)
+
+
+static struct ureg register_input( struct texenv_fragment_program *p, GLuint input )
+{
+ p->program->InputsRead |= (1<<input);
+ return make_ureg(PROGRAM_INPUT, input);
+}
+
+
+static void emit_arg( struct fp_src_register *reg,
+ struct ureg ureg )
+{
+ reg->File = ureg.file;
+ reg->Index = ureg.idx;
+ reg->Swizzle = ureg.swz;
+ reg->NegateBase = ureg.negatebase;
+ reg->Abs = ureg.abs;
+ reg->NegateAbs = ureg.negateabs;
+}
+
+static void emit_dst( struct fp_dst_register *dst,
+ struct ureg ureg, GLuint mask )
+{
+ dst->File = ureg.file;
+ dst->Index = ureg.idx;
+ dst->WriteMask = mask;
+ dst->CondMask = 0;
+ dst->CondSwizzle = 0;
+}
+
+static struct fp_instruction *
+emit_op(struct texenv_fragment_program *p,
+ GLuint op,
+ struct ureg dest,
+ GLuint mask,
+ GLuint saturate,
+ struct ureg src0,
+ struct ureg src1,
+ struct ureg src2 )
+{
+ GLuint nr = p->program->Base.NumInstructions++;
+ struct fp_instruction *inst = &p->program->Instructions[nr];
+
+ memset(inst, 0, sizeof(*inst));
+ inst->Opcode = op;
+
+ emit_arg( &inst->SrcReg[0], src0 );
+ emit_arg( &inst->SrcReg[1], src1 );
+ emit_arg( &inst->SrcReg[2], src2 );
+
+ inst->Saturate = saturate;
+
+ emit_dst( &inst->DstReg, dest, mask );
+
+ /* Accounting for indirection tracking:
+ */
+ if (dest.file == PROGRAM_TEMPORARY)
+ p->temps_output |= 1 << dest.idx;
+
+ return inst;
+}
+
+
+static struct ureg emit_arith( struct texenv_fragment_program *p,
+ GLuint op,
+ struct ureg dest,
+ GLuint mask,
+ GLuint saturate,
+ struct ureg src0,
+ struct ureg src1,
+ struct ureg src2 )
+{
+ emit_op(p, op, dest, mask, saturate, src0, src1, src2);
+
+ /* Accounting for indirection tracking:
+ */
+ if (src0.file == PROGRAM_TEMPORARY)
+ p->alu_temps |= 1 << src0.idx;
+
+ if (!is_undef(src1) && src1.file == PROGRAM_TEMPORARY)
+ p->alu_temps |= 1 << src1.idx;
+
+ if (!is_undef(src2) && src2.file == PROGRAM_TEMPORARY)
+ p->alu_temps |= 1 << src2.idx;
+
+ if (dest.file == PROGRAM_TEMPORARY)
+ p->alu_temps |= 1 << dest.idx;
+
+ p->program->NumAluInstructions++;
+ return dest;
+}
+
+static struct ureg emit_texld( struct texenv_fragment_program *p,
+ GLuint op,
+ struct ureg dest,
+ GLuint destmask,
+ GLuint tex_unit,
+ GLuint tex_idx,
+ struct ureg coord )
+{
+ struct fp_instruction *inst = emit_op( p, op,
+ dest, destmask,
+ 0, /* don't saturate? */
+ coord, /* arg 0? */
+ undef,
+ undef);
+
+ inst->TexSrcIdx = tex_idx;
+ inst->TexSrcUnit = tex_unit;
+
+ p->program->NumTexInstructions++;
+
+ /* Is this a texture indirection?
+ */
+ if ((coord.file == PROGRAM_TEMPORARY &&
+ (p->temps_output & (1<<coord.idx))) ||
+ (dest.file == PROGRAM_TEMPORARY &&
+ (p->alu_temps & (1<<dest.idx)))) {
+ p->program->NumTexIndirections++;
+ p->temps_output = 1<<coord.idx;
+ p->alu_temps = 0;
+ assert(0); /* KW: texture env crossbar */
+ }
+
+ return dest;
+}
+
+
+static struct ureg register_const4f( struct texenv_fragment_program *p,
+ GLfloat s0,
+ GLfloat s1,
+ GLfloat s2,
+ GLfloat s3)
+{
+ GLfloat values[4];
+ GLuint idx;
+ values[0] = s0;
+ values[1] = s1;
+ values[2] = s2;
+ values[3] = s3;
+ idx = _mesa_add_unnamed_constant( p->program->Parameters, values );
+ return make_ureg(PROGRAM_STATE_VAR, idx);
+}
+
+#define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0)
+#define register_const1f(p, s0) register_const4f(p, s0, 0, 0, 1)
+#define register_const2f(p, s0, s1) register_const4f(p, s0, s1, 0, 1)
+#define register_const3f(p, s0, s1, s2) register_const4f(p, s0, s1, s2, 1)
+
+
+
+
+static struct ureg get_one( struct texenv_fragment_program *p )
+{
+ if (is_undef(p->one))
+ p->one = register_scalar_const(p, 1.0);
+ return p->one;
+}
+
+static struct ureg get_half( struct texenv_fragment_program *p )
+{
+ if (is_undef(p->half))
+ p->one = register_scalar_const(p, 0.5);
+ return p->half;
+}
+
+static struct ureg get_zero( struct texenv_fragment_program *p )
+{
+ if (is_undef(p->zero))
+ p->one = register_scalar_const(p, 0.0);
+ return p->zero;
+}
+
+
+
+
+
+static void program_error( struct texenv_fragment_program *p, const char *msg )
+{
+ _mesa_problem(NULL, msg);
+ p->error = 1;
+}
+
+static struct ureg get_source( struct texenv_fragment_program *p,
+ GLuint src, GLuint unit )
+{
+ switch (src) {
+ case SRC_TEXTURE:
+ assert(!is_undef(p->src_texture[unit]));
+ return p->src_texture[unit];
+
+ case SRC_TEXTURE0:
+ case SRC_TEXTURE1:
+ case SRC_TEXTURE2:
+ case SRC_TEXTURE3:
+ case SRC_TEXTURE4:
+ case SRC_TEXTURE5:
+ case SRC_TEXTURE6:
+ case SRC_TEXTURE7:
+ assert(!is_undef(p->src_texture[src - SRC_TEXTURE0]));
+ return p->src_texture[src - SRC_TEXTURE0];
+
+ case SRC_CONSTANT:
+ return register_param2(p, STATE_TEXENV_COLOR, unit);
+
+ case SRC_PRIMARY_COLOR:
+ return register_input(p, FRAG_ATTRIB_COL0);
+
+ case SRC_PREVIOUS:
+ default:
+ if (is_undef(p->src_previous))
+ return register_input(p, FRAG_ATTRIB_COL0);
+ else
+ return p->src_previous;
+ }
+}
+
+static struct ureg emit_combine_source( struct texenv_fragment_program *p,
+ GLuint mask,
+ GLuint unit,
+ GLuint source,
+ GLuint operand )
+{
+ struct ureg arg, src, one;
+
+ src = get_source(p, source, unit);
+
+ switch (operand) {
+ case OPR_ONE_MINUS_SRC_COLOR:
+ /* Get unused tmp,
+ * Emit tmp = 1.0 - arg.xyzw
+ */
+ arg = get_temp( p );
+ one = get_one( p );
+ return emit_arith( p, FP_OPCODE_SUB, arg, mask, 0, one, src, undef);
+
+ case OPR_SRC_ALPHA:
+ if (mask == WRITEMASK_W)
+ return src;
+ else
+ return swizzle1( src, W );
+ case OPR_ONE_MINUS_SRC_ALPHA:
+ /* Get unused tmp,
+ * Emit tmp = 1.0 - arg.wwww
+ */
+ arg = get_temp(p);
+ one = get_one(p);
+ return emit_arith(p, FP_OPCODE_SUB, arg, mask, 0,
+ one, swizzle1(src, W), undef);
+ case OPR_ZERO:
+ return get_zero(p);
+ case OPR_ONE:
+ return get_one(p);
+ case OPR_SRC_COLOR:
+ default:
+ return src;
+ }
+}
+
+static GLboolean args_match( struct state_key *key, GLuint unit )
+{
+ int i, nr = key->unit[unit].NumArgsRGB;
+
+ for (i = 0 ; i < nr ; i++) {
+ if (key->unit[unit].OptA[i].Source != key->unit[unit].OptRGB[i].Source)
+ return GL_FALSE;
+
+ switch(key->unit[unit].OptA[i].Operand) {
+ case OPR_SRC_ALPHA:
+ switch(key->unit[unit].OptRGB[i].Operand) {
+ case OPR_SRC_COLOR:
+ case OPR_SRC_ALPHA:
+ break;
+ default:
+ return GL_FALSE;
+ }
+ break;
+ case OPR_ONE_MINUS_SRC_ALPHA:
+ switch(key->unit[unit].OptRGB[i].Operand) {
+ case OPR_ONE_MINUS_SRC_COLOR:
+ case OPR_ONE_MINUS_SRC_ALPHA:
+ break;
+ default:
+ return GL_FALSE;
+ }
+ break;
+ default:
+ return GL_FALSE; /* impossible */
+ }
+ }
+
+ return GL_TRUE;
+}
+
+static struct ureg emit_combine( struct texenv_fragment_program *p,
+ struct ureg dest,
+ GLuint mask,
+ GLuint saturate,
+ GLuint unit,
+ GLuint nr,
+ GLuint mode,
+ struct mode_opt *opt)
+{
+ struct ureg src[3];
+ struct ureg tmp, half;
+ int i;
+
+ for (i = 0; i < nr; i++)
+ src[i] = emit_combine_source( p, mask, unit, opt[i].Source, opt[i].Operand );
+
+ switch (mode) {
+ case MODE_REPLACE:
+ if (mask == WRITEMASK_XYZW && !saturate)
+ return src[0];
+ else
+ return emit_arith( p, FP_OPCODE_MOV, dest, mask, saturate, src[0], undef, undef );
+ case MODE_MODULATE:
+ return emit_arith( p, FP_OPCODE_MUL, dest, mask, saturate,
+ src[0], src[1], undef );
+ case MODE_ADD:
+ return emit_arith( p, FP_OPCODE_ADD, dest, mask, saturate,
+ src[0], src[1], undef );
+ case MODE_ADD_SIGNED:
+ /* tmp = arg0 + arg1
+ * result = tmp - .5
+ */
+ half = get_half(p);
+ emit_arith( p, FP_OPCODE_ADD, tmp, mask, 0, src[0], src[1], undef );
+ emit_arith( p, FP_OPCODE_SUB, dest, mask, saturate, tmp, half, undef );
+ return dest;
+ case MODE_INTERPOLATE:
+ /* Arg0 * (Arg2) + Arg1 * (1-Arg2) -- note arguments are reordered:
+ */
+ return emit_arith( p, FP_OPCODE_LRP, dest, mask, saturate, src[2], src[0], src[1] );
+
+ case MODE_SUBTRACT:
+ return emit_arith( p, FP_OPCODE_SUB, dest, mask, saturate, src[0], src[1], undef );
+
+ case MODE_DOT3_RGBA:
+ case MODE_DOT3_RGBA_EXT:
+ case MODE_DOT3_RGB_EXT:
+ case MODE_DOT3_RGB: {
+ struct ureg tmp0 = get_temp( p );
+ struct ureg tmp1 = get_temp( p );
+ struct ureg neg1 = register_scalar_const(p, -1);
+ struct ureg two = register_scalar_const(p, 2);
+
+ /* tmp0 = 2*src0 - 1
+ * tmp1 = 2*src1 - 1
+ *
+ * dst = tmp0 dot3 tmp1
+ */
+ emit_arith( p, FP_OPCODE_MAD, tmp0, WRITEMASK_XYZW, 0,
+ two, src[0], neg1);
+
+ if (memcmp(&src[0], &src[1], sizeof(struct ureg)) == 0)
+ tmp1 = tmp0;
+ else
+ emit_arith( p, FP_OPCODE_MAD, tmp1, WRITEMASK_XYZW, 0,
+ two, src[1], neg1);
+ emit_arith( p, FP_OPCODE_DP3, dest, mask, saturate, tmp0, tmp1, undef);
+ return dest;
+ }
+ case MODE_MODULATE_ADD_ATI:
+ /* Arg0 * Arg2 + Arg1 */
+ return emit_arith( p, FP_OPCODE_MAD, dest, mask, saturate,
+ src[0], src[2], src[1] );
+ case MODE_MODULATE_SIGNED_ADD_ATI: {
+ /* Arg0 * Arg2 + Arg1 - 0.5 */
+ struct ureg tmp0 = get_temp(p);
+ half = get_half(p);
+ emit_arith( p, FP_OPCODE_MAD, tmp0, mask, 0, src[0], src[2], src[1] );
+ emit_arith( p, FP_OPCODE_SUB, dest, mask, saturate, tmp0, half, undef );
+ return dest;
+ }
+ case MODE_MODULATE_SUBTRACT_ATI:
+ /* Arg0 * Arg2 - Arg1 */
+ emit_arith( p, FP_OPCODE_MAD, dest, mask, 0, src[0], src[2], negate(src[1]) );
+ return dest;
+ default:
+ return src[0];
+ }
+}
+
+
+static struct ureg emit_texenv( struct texenv_fragment_program *p, int unit )
+{
+ struct state_key *key = p->state;
+ GLuint saturate = (unit < p->last_tex_stage);
+ GLuint rgb_shift, alpha_shift;
+ struct ureg out, shift;
+ struct ureg dest;
+
+ if (!key->unit[unit].enabled) {
+ return get_source(p, SRC_PREVIOUS, 0);
+ }
+
+ switch (key->unit[unit].ModeRGB) {
+ case MODE_DOT3_RGB_EXT:
+ alpha_shift = key->unit[unit].ScaleShiftA;
+ rgb_shift = 0;
+ break;
+ case MODE_DOT3_RGBA_EXT:
+ alpha_shift = 0;
+ rgb_shift = 0;
+ break;
+ default:
+ rgb_shift = key->unit[unit].ScaleShiftRGB;
+ alpha_shift = key->unit[unit].ScaleShiftA;
+ break;
+ }
+
+ /* If this is the very last calculation, emit direct to output reg:
+ */
+ if (key->separate_specular ||
+ unit != p->last_tex_stage ||
+ alpha_shift ||
+ rgb_shift)
+ dest = get_temp( p );
+ else
+ dest = make_ureg(PROGRAM_OUTPUT, FRAG_OUTPUT_COLR);
+
+ /* Emit the RGB and A combine ops
+ */
+ if (key->unit[unit].ModeRGB == key->unit[unit].ModeA &&
+ args_match(key, unit)) {
+ out = emit_combine( p, dest, WRITEMASK_XYZW, saturate,
+ unit,
+ key->unit[unit].NumArgsRGB,
+ key->unit[unit].ModeRGB,
+ key->unit[unit].OptRGB);
+ }
+ else if (key->unit[unit].ModeRGB == MODE_DOT3_RGBA_EXT ||
+ key->unit[unit].ModeA == MODE_DOT3_RGBA) {
+
+ out = emit_combine( p, dest, WRITEMASK_XYZW, saturate,
+ unit,
+ key->unit[unit].NumArgsRGB,
+ key->unit[unit].ModeRGB,
+ key->unit[unit].OptRGB);
+ }
+ else {
+ /* Need to do something to stop from re-emitting identical
+ * argument calculations here:
+ */
+ out = emit_combine( p, dest, WRITEMASK_XYZ, saturate,
+ unit,
+ key->unit[unit].NumArgsRGB,
+ key->unit[unit].ModeRGB,
+ key->unit[unit].OptRGB);
+ out = emit_combine( p, dest, WRITEMASK_W, saturate,
+ unit,
+ key->unit[unit].NumArgsA,
+ key->unit[unit].ModeA,
+ key->unit[unit].OptA);
+ }
+
+ /* Deal with the final shift:
+ */
+ if (alpha_shift || rgb_shift) {
+ if (rgb_shift == alpha_shift) {
+ shift = register_scalar_const(p, 1<<rgb_shift);
+ }
+ else {
+ shift = register_const4f(p,
+ 1<<rgb_shift,
+ 1<<rgb_shift,
+ 1<<rgb_shift,
+ 1<<alpha_shift);
+ }
+ return emit_arith( p, FP_OPCODE_MUL, dest, WRITEMASK_XYZW,
+ saturate, out, shift, undef );
+ }
+ else
+ return out;
+}
+
+
+
+static void load_texture( struct texenv_fragment_program *p, GLuint unit )
+{
+ if (is_undef(p->src_texture[unit])) {
+ GLuint dim = p->state->unit[unit].source_index;
+ struct ureg texcoord = register_input(p, FRAG_ATTRIB_TEX0+unit);
+ struct ureg tmp = get_tex_temp( p );
+
+ if (dim == TEXTURE_UNKNOWN_INDEX)
+ program_error(p, "TexSrcBit");
+
+ /* TODO: Use D0_MASK_XY where possible.
+ */
+ p->src_texture[unit] = emit_texld( p, FP_OPCODE_TXP,
+ tmp, WRITEMASK_XYZW,
+ unit, dim, texcoord );
+ }
+}
+
+static GLboolean load_texenv_source( struct texenv_fragment_program *p,
+ GLuint src, GLuint unit )
+{
+ switch (src) {
+ case SRC_TEXTURE:
+ load_texture(p, unit);
+ break;
+
+ case SRC_TEXTURE0:
+ case SRC_TEXTURE1:
+ case SRC_TEXTURE2:
+ case SRC_TEXTURE3:
+ case SRC_TEXTURE4:
+ case SRC_TEXTURE5:
+ case SRC_TEXTURE6:
+ case SRC_TEXTURE7:
+ if (!p->state->unit[src - SRC_TEXTURE0].enabled)
+ return GL_FALSE;
+ load_texture(p, src - SRC_TEXTURE0);
+ break;
+
+ default:
+ break;
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean load_texunit_sources( struct texenv_fragment_program *p, int unit )
+{
+ struct state_key *key = p->state;
+ int i, nr = key->unit[unit].NumArgsRGB;
+ for (i = 0; i < nr; i++) {
+ if (!load_texenv_source( p, key->unit[unit].OptRGB[i].Source, unit) ||
+ !load_texenv_source( p, key->unit[unit].OptA[i].Source, unit ))
+ return GL_FALSE;
+ }
+ return GL_TRUE;
+}
+
+static void create_new_program(struct state_key *key, GLcontext *ctx,
+ struct fragment_program *program)
+{
+ struct texenv_fragment_program p;
+ GLuint unit;
+ struct ureg cf, out;
+
+ _mesa_memset(&p, 0, sizeof(p));
+ p.ctx = ctx;
+ p.state = key;
+ p.program = program;
+
+ p.program->Instructions = MALLOC(sizeof(struct fp_instruction) * 100);
+ p.program->Base.NumInstructions = 0;
+ p.program->Base.Target = GL_FRAGMENT_PROGRAM_ARB;
+ p.program->NumTexIndirections = 1; /* correct? */
+ p.program->NumTexInstructions = 0;
+ p.program->NumAluInstructions = 0;
+ p.program->Base.String = 0;
+ p.program->Base.NumInstructions =
+ p.program->Base.NumTemporaries =
+ p.program->Base.NumParameters =
+ p.program->Base.NumAttributes = p.program->Base.NumAddressRegs = 0;
+ p.program->Parameters = _mesa_new_parameter_list();
+
+ p.program->InputsRead = 0;
+ p.program->OutputsWritten = 1 << FRAG_OUTPUT_COLR;
+
+ for (unit = 0; unit < MAX_TEXTURE_UNITS; unit++)
+ p.src_texture[unit] = undef;
+
+ p.src_previous = undef;
+ p.last_tex_stage = 0;
+ release_temps(&p);
+
+ if (key->enabled_units) {
+ /* First pass - to support texture_env_crossbar, first identify
+ * all referenced texture sources and emit texld instructions
+ * for each:
+ */
+ for (unit = 0 ; unit < ctx->Const.MaxTextureUnits ; unit++)
+ if (key->unit[unit].enabled) {
+ if (load_texunit_sources( &p, unit ))
+ p.last_tex_stage = unit;
+ }
+
+ /* Second pass - emit combine instructions to build final color:
+ */
+ for (unit = 0 ; unit < ctx->Const.MaxTextureUnits; unit++)
+ if (key->enabled_units & (1<<unit)) {
+ p.src_previous = emit_texenv( &p, unit );
+ release_temps(&p); /* release all temps */
+ }
+ }
+
+ cf = get_source( &p, SRC_PREVIOUS, 0 );
+ out = make_ureg( PROGRAM_OUTPUT, FRAG_OUTPUT_COLR );
+
+ if (key->separate_specular) {
+ /* Emit specular add.
+ */
+ struct ureg s = register_input(&p, FRAG_ATTRIB_COL1);
+ emit_arith( &p, FP_OPCODE_ADD, out, WRITEMASK_XYZ, 0, cf, s, undef );
+ }
+ else if (memcmp(&cf, &out, sizeof(cf)) != 0) {
+ /* Will wind up in here if no texture enabled or a couple of
+ * other scenarios (GL_REPLACE for instance).
+ */
+ emit_arith( &p, FP_OPCODE_MOV, out, WRITEMASK_XYZW, 0, cf, undef, undef );
+ }
+
+ /* Finish up:
+ */
+ emit_arith( &p, FP_OPCODE_END, undef, WRITEMASK_XYZW, 0, undef, undef, undef);
+
+ if (key->fog_enabled) {
+ /* Pull fog mode from GLcontext, the value in the state key is
+ * a reduced value and not what is expected in FogOption
+ */
+ p.program->FogOption = ctx->Fog.Mode;
+ } else
+ p.program->FogOption = GL_NONE;
+
+ if (p.program->NumTexIndirections > ctx->Const.MaxFragmentProgramTexIndirections)
+ program_error(&p, "Exceeded max nr indirect texture lookups");
+
+ if (p.program->NumTexInstructions > ctx->Const.MaxFragmentProgramTexInstructions)
+ program_error(&p, "Exceeded max TEX instructions");
+
+ if (p.program->NumAluInstructions > ctx->Const.MaxFragmentProgramAluInstructions)
+ program_error(&p, "Exceeded max ALU instructions");
+
+
+ /* Notify driver the fragment program has (actually) changed.
+ */
+ if (ctx->Driver.ProgramStringNotify || DISASSEM) {
+ if (ctx->Driver.ProgramStringNotify)
+ ctx->Driver.ProgramStringNotify( ctx, GL_FRAGMENT_PROGRAM_ARB,
+ &p.program->Base );
+
+ if (DISASSEM) {
+ _mesa_debug_fp_inst(p.program->NumTexInstructions + p.program->NumAluInstructions,
+ p.program->Instructions);
+ _mesa_printf("\n");
+ }
+
+ }
+
+}
+
+static void *search_cache( struct texenvprog_cache *cache,
+ GLuint hash,
+ const void *key,
+ GLuint keysize)
+{
+ struct texenvprog_cache *c;
+
+ for (c = cache; c; c = c->next) {
+ if (c->hash == hash && memcmp(c->key, key, keysize) == 0)
+ return c->data;
+ }
+
+ return NULL;
+}
+
+static void cache_item( struct texenvprog_cache **cache,
+ GLuint hash,
+ void *key,
+ void *data )
+{
+ struct texenvprog_cache *c = MALLOC(sizeof(*c));
+ c->hash = hash;
+ c->key = key;
+ c->data = data;
+ c->next = *cache;
+ *cache = c;
+}
+
+static GLuint hash_key( struct state_key *key )
+{
+ GLuint *ikey = (GLuint *)key;
+ GLuint hash = 0, i;
+
+ /* I'm sure this can be improved on, but speed is important:
+ */
+ for (i = 0; i < sizeof(*key)/sizeof(GLuint); i++)
+ hash ^= ikey[i];
+
+ return hash;
+}
+
+void _mesa_UpdateTexEnvProgram( GLcontext *ctx )
+{
+ struct state_key *key;
+ GLuint hash;
+
+ if (ctx->FragmentProgram._Enabled)
+ return;
+
+ key = make_state_key(ctx);
+ hash = hash_key(key);
+
+ ctx->FragmentProgram._Current = ctx->_TexEnvProgram =
+ (struct fragment_program *)
+ search_cache(ctx->Texture.env_fp_cache, hash, key, sizeof(*key));
+
+ if (!ctx->_TexEnvProgram) {
+ if (0) _mesa_printf("Building new texenv proggy for key %x\n", hash);
+
+ ctx->FragmentProgram._Current = ctx->_TexEnvProgram =
+ (struct fragment_program *)
+ ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0);
+
+ create_new_program(key, ctx, ctx->_TexEnvProgram);
+
+ cache_item(&ctx->Texture.env_fp_cache, hash, key, ctx->_TexEnvProgram);
+ } else {
+ FREE(key);
+ if (0) _mesa_printf("Found existing texenv program for key %x\n", hash);
+ }
+
+}
+
+void _mesa_TexEnvProgramCacheDestroy( GLcontext *ctx )
+{
+ struct texenvprog_cache *a, *tmp;
+
+ for (a = ctx->Texture.env_fp_cache; a; a = tmp) {
+ tmp = a->next;
+ FREE(a->key);
+ FREE(a->data);
+ FREE(a);
+ }
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/main/texenvprogram.h b/nx-X11/extras/Mesa/src/mesa/main/texenvprogram.h
new file mode 100644
index 000000000..30c8cca38
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/texenvprogram.h
@@ -0,0 +1,40 @@
+/**
+ * \file texenvprogram.h
+ * Texture state management.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef TEXENVPROGRAM_H
+#define TEXENVPROGRAM_H
+
+
+#include "mtypes.h"
+
+extern void _mesa_UpdateTexEnvProgram( GLcontext *ctx );
+extern void _mesa_TexEnvProgramCacheDestroy( GLcontext *ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/texformat.c b/nx-X11/extras/Mesa/src/mesa/main/texformat.c
new file mode 100644
index 000000000..878a10bb7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/texformat.c
@@ -0,0 +1,1314 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file texformat.c
+ * Texture formats.
+ *
+ * \author Gareth Hughes
+ */
+
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "image.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "texformat.h"
+#include "teximage.h"
+#include "texstate.h"
+#include "texstore.h"
+
+
+
+/* Texel fetch routines for all supported formats
+ */
+#define DIM 1
+#include "texformat_tmp.h"
+
+#define DIM 2
+#include "texformat_tmp.h"
+
+#define DIM 3
+#include "texformat_tmp.h"
+
+/**
+ * Null texel fetch function.
+ *
+ * Have to have this so the FetchTexel function pointer is never NULL.
+ */
+static void fetch_null_texel( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ (void) texImage; (void) i; (void) j; (void) k;
+ texel[RCOMP] = 0;
+ texel[GCOMP] = 0;
+ texel[BCOMP] = 0;
+ texel[ACOMP] = 0;
+ _mesa_warning(NULL, "fetch_null_texel() called!");
+}
+
+static void fetch_null_texelf( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ (void) texImage; (void) i; (void) j; (void) k;
+ texel[RCOMP] = 0.0;
+ texel[GCOMP] = 0.0;
+ texel[BCOMP] = 0.0;
+ texel[ACOMP] = 0.0;
+ _mesa_warning(NULL, "fetch_null_texelf() called!");
+}
+
+static void store_null_texel(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ /* no-op */
+}
+
+
+
+/***************************************************************/
+/** \name Default GLchan-based formats */
+/*@{*/
+
+const struct gl_texture_format _mesa_texformat_rgba = {
+ MESA_FORMAT_RGBA, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ CHAN_BITS, /* RedBits */
+ CHAN_BITS, /* GreenBits */
+ CHAN_BITS, /* BlueBits */
+ CHAN_BITS, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 4 * sizeof(GLchan), /* TexelBytes */
+ _mesa_texstore_rgba, /* StoreTexImageFunc */
+ fetch_texel_1d_rgba, /* FetchTexel1D */
+ fetch_texel_2d_rgba, /* FetchTexel2D */
+ fetch_texel_3d_rgba, /* FetchTexel3D */
+ fetch_texel_1d_f_rgba, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgba, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgba, /* FetchTexel3Df */
+ store_texel_rgba /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_rgb = {
+ MESA_FORMAT_RGB, /* MesaFormat */
+ GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ CHAN_BITS, /* RedBits */
+ CHAN_BITS, /* GreenBits */
+ CHAN_BITS, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 3 * sizeof(GLchan), /* TexelBytes */
+ _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_rgb, /* FetchTexel1D */
+ fetch_texel_2d_rgb, /* FetchTexel2D */
+ fetch_texel_3d_rgb, /* FetchTexel3D */
+ fetch_texel_1d_f_rgb, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgb, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgb, /* FetchTexel3Df */
+ store_texel_rgb /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_alpha = {
+ MESA_FORMAT_ALPHA, /* MesaFormat */
+ GL_ALPHA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ CHAN_BITS, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ sizeof(GLchan), /* TexelBytes */
+ _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_alpha, /* FetchTexel1D */
+ fetch_texel_2d_alpha, /* FetchTexel2D */
+ fetch_texel_3d_alpha, /* FetchTexel3D */
+ fetch_texel_1d_f_alpha, /* FetchTexel1Df */
+ fetch_texel_2d_f_alpha, /* FetchTexel2Df */
+ fetch_texel_3d_f_alpha, /* FetchTexel3Df */
+ store_texel_alpha /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_luminance = {
+ MESA_FORMAT_LUMINANCE, /* MesaFormat */
+ GL_LUMINANCE, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ CHAN_BITS, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ sizeof(GLchan), /* TexelBytes */
+ _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_luminance, /* FetchTexel1D */
+ fetch_texel_2d_luminance, /* FetchTexel2D */
+ fetch_texel_3d_luminance, /* FetchTexel3D */
+ fetch_texel_1d_f_luminance, /* FetchTexel1Df */
+ fetch_texel_2d_f_luminance, /* FetchTexel2Df */
+ fetch_texel_3d_f_luminance, /* FetchTexel3Df */
+ store_texel_luminance /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_luminance_alpha = {
+ MESA_FORMAT_LUMINANCE_ALPHA, /* MesaFormat */
+ GL_LUMINANCE_ALPHA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ CHAN_BITS, /* AlphaBits */
+ CHAN_BITS, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2 * sizeof(GLchan), /* TexelBytes */
+ _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_luminance_alpha, /* FetchTexel1D */
+ fetch_texel_2d_luminance_alpha, /* FetchTexel2D */
+ fetch_texel_3d_luminance_alpha, /* FetchTexel3D */
+ fetch_texel_1d_f_luminance_alpha, /* FetchTexel1Df */
+ fetch_texel_2d_f_luminance_alpha, /* FetchTexel2Df */
+ fetch_texel_3d_f_luminance_alpha, /* FetchTexel3Df */
+ store_texel_luminance_alpha /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_intensity = {
+ MESA_FORMAT_INTENSITY, /* MesaFormat */
+ GL_INTENSITY, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ CHAN_BITS, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ sizeof(GLchan), /* TexelBytes */
+ _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_intensity, /* FetchTexel1D */
+ fetch_texel_2d_intensity, /* FetchTexel2D */
+ fetch_texel_3d_intensity, /* FetchTexel3D */
+ fetch_texel_1d_f_intensity, /* FetchTexel1Df */
+ fetch_texel_2d_f_intensity, /* FetchTexel2Df */
+ fetch_texel_3d_f_intensity, /* FetchTexel3Df */
+ store_texel_intensity /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_depth_component_float32 = {
+ MESA_FORMAT_DEPTH_COMPONENT_FLOAT32, /* MesaFormat */
+ GL_DEPTH_COMPONENT, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ sizeof(GLfloat) * 8, /* DepthBits */
+ sizeof(GLfloat), /* TexelBytes */
+ _mesa_texstore_depth_component_float32,/* StoreTexImageFunc */
+ fetch_null_texel, /* FetchTexel1D */
+ fetch_null_texel, /* FetchTexel1D */
+ fetch_null_texel, /* FetchTexel1D */
+ fetch_texel_1d_f_depth_component_f32,/* FetchTexel1Df */
+ fetch_texel_2d_f_depth_component_f32,/* FetchTexel2Df */
+ fetch_texel_3d_f_depth_component_f32,/* FetchTexel3Df */
+ store_texel_depth_component_f32 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_depth_component16 = {
+ MESA_FORMAT_DEPTH_COMPONENT16, /* MesaFormat */
+ GL_DEPTH_COMPONENT, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ sizeof(GLushort) * 8, /* DepthBits */
+ sizeof(GLushort), /* TexelBytes */
+ _mesa_texstore_depth_component16, /* StoreTexImageFunc */
+ fetch_null_texel, /* FetchTexel1D */
+ fetch_null_texel, /* FetchTexel1D */
+ fetch_null_texel, /* FetchTexel1D */
+ fetch_texel_1d_f_depth_component16, /* FetchTexel1Df */
+ fetch_texel_2d_f_depth_component16, /* FetchTexel2Df */
+ fetch_texel_3d_f_depth_component16, /* FetchTexel3Df */
+ store_texel_depth_component16 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_rgba_float32 = {
+ MESA_FORMAT_RGBA_FLOAT32, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 8 * sizeof(GLfloat), /* RedBits */
+ 8 * sizeof(GLfloat), /* GreenBits */
+ 8 * sizeof(GLfloat), /* BlueBits */
+ 8 * sizeof(GLfloat), /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 4 * sizeof(GLfloat), /* TexelBytes */
+ _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
+ fetch_texel_1d_rgba_f32, /* FetchTexel1D */
+ fetch_texel_2d_rgba_f32, /* FetchTexel1D */
+ fetch_texel_3d_rgba_f32, /* FetchTexel1D */
+ fetch_texel_1d_f_rgba_f32, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgba_f32, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgba_f32, /* FetchTexel3Df */
+ store_texel_rgba_f32 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_rgba_float16 = {
+ MESA_FORMAT_RGBA_FLOAT16, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 8 * sizeof(GLhalfARB), /* RedBits */
+ 8 * sizeof(GLhalfARB), /* GreenBits */
+ 8 * sizeof(GLhalfARB), /* BlueBits */
+ 8 * sizeof(GLhalfARB), /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 4 * sizeof(GLhalfARB), /* TexelBytes */
+ _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
+ fetch_texel_1d_rgba_f16, /* FetchTexel1D */
+ fetch_texel_2d_rgba_f16, /* FetchTexel1D */
+ fetch_texel_3d_rgba_f16, /* FetchTexel1D */
+ fetch_texel_1d_f_rgba_f16, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgba_f16, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgba_f16, /* FetchTexel3Df */
+ store_texel_rgba_f16 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_rgb_float32 = {
+ MESA_FORMAT_RGB_FLOAT32, /* MesaFormat */
+ GL_RGB, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 8 * sizeof(GLfloat), /* RedBits */
+ 8 * sizeof(GLfloat), /* GreenBits */
+ 8 * sizeof(GLfloat), /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 3 * sizeof(GLfloat), /* TexelBytes */
+ _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_rgb_f32, /* FetchTexel1D */
+ fetch_texel_2d_rgb_f32, /* FetchTexel1D */
+ fetch_texel_3d_rgb_f32, /* FetchTexel1D */
+ fetch_texel_1d_f_rgb_f32, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgb_f32, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgb_f32, /* FetchTexel3Df */
+ store_texel_rgb_f32 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_rgb_float16 = {
+ MESA_FORMAT_RGB_FLOAT16, /* MesaFormat */
+ GL_RGB, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 8 * sizeof(GLhalfARB), /* RedBits */
+ 8 * sizeof(GLhalfARB), /* GreenBits */
+ 8 * sizeof(GLhalfARB), /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 3 * sizeof(GLhalfARB), /* TexelBytes */
+ _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_rgb_f16, /* FetchTexel1D */
+ fetch_texel_2d_rgb_f16, /* FetchTexel1D */
+ fetch_texel_3d_rgb_f16, /* FetchTexel1D */
+ fetch_texel_1d_f_rgb_f16, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgb_f16, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgb_f16, /* FetchTexel3Df */
+ store_texel_rgb_f16 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_alpha_float32 = {
+ MESA_FORMAT_ALPHA_FLOAT32, /* MesaFormat */
+ GL_ALPHA, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 8 * sizeof(GLfloat), /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 1 * sizeof(GLfloat), /* TexelBytes */
+ _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_alpha_f32, /* FetchTexel1D */
+ fetch_texel_2d_alpha_f32, /* FetchTexel1D */
+ fetch_texel_3d_alpha_f32, /* FetchTexel1D */
+ fetch_texel_1d_f_alpha_f32, /* FetchTexel1Df */
+ fetch_texel_2d_f_alpha_f32, /* FetchTexel2Df */
+ fetch_texel_3d_f_alpha_f32, /* FetchTexel3Df */
+ store_texel_alpha_f32 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_alpha_float16 = {
+ MESA_FORMAT_ALPHA_FLOAT16, /* MesaFormat */
+ GL_ALPHA, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 8 * sizeof(GLhalfARB), /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 1 * sizeof(GLhalfARB), /* TexelBytes */
+ _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_alpha_f16, /* FetchTexel1D */
+ fetch_texel_2d_alpha_f16, /* FetchTexel1D */
+ fetch_texel_3d_alpha_f16, /* FetchTexel1D */
+ fetch_texel_1d_f_alpha_f16, /* FetchTexel1Df */
+ fetch_texel_2d_f_alpha_f16, /* FetchTexel2Df */
+ fetch_texel_3d_f_alpha_f16, /* FetchTexel3Df */
+ store_texel_alpha_f16 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_luminance_float32 = {
+ MESA_FORMAT_LUMINANCE_FLOAT32, /* MesaFormat */
+ GL_LUMINANCE, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 8 * sizeof(GLfloat), /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 1 * sizeof(GLfloat), /* TexelBytes */
+ _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_luminance_f32, /* FetchTexel1D */
+ fetch_texel_2d_luminance_f32, /* FetchTexel2D */
+ fetch_texel_3d_luminance_f32, /* FetchTexel3D */
+ fetch_texel_1d_f_luminance_f32, /* FetchTexel1Df */
+ fetch_texel_2d_f_luminance_f32, /* FetchTexel2Df */
+ fetch_texel_3d_f_luminance_f32, /* FetchTexel3Df */
+ store_texel_luminance_f32 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_luminance_float16 = {
+ MESA_FORMAT_LUMINANCE_FLOAT16, /* MesaFormat */
+ GL_LUMINANCE, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 8 * sizeof(GLhalfARB), /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 1 * sizeof(GLhalfARB), /* TexelBytes */
+ _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_luminance_f16, /* FetchTexel1D */
+ fetch_texel_2d_luminance_f16, /* FetchTexel2D */
+ fetch_texel_3d_luminance_f16, /* FetchTexel3D */
+ fetch_texel_1d_f_luminance_f16, /* FetchTexel1Df */
+ fetch_texel_2d_f_luminance_f16, /* FetchTexel2Df */
+ fetch_texel_3d_f_luminance_f16, /* FetchTexel3Df */
+ store_texel_luminance_f16 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_luminance_alpha_float32 = {
+ MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, /* MesaFormat */
+ GL_LUMINANCE_ALPHA, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 8 * sizeof(GLfloat), /* AlphaBits */
+ 8 * sizeof(GLfloat), /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2 * sizeof(GLfloat), /* TexelBytes */
+ _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
+ fetch_texel_1d_luminance_alpha_f32, /* FetchTexel1D */
+ fetch_texel_2d_luminance_alpha_f32, /* FetchTexel2D */
+ fetch_texel_3d_luminance_alpha_f32, /* FetchTexel3D */
+ fetch_texel_1d_f_luminance_alpha_f32,/* FetchTexel1Df */
+ fetch_texel_2d_f_luminance_alpha_f32,/* FetchTexel2Df */
+ fetch_texel_3d_f_luminance_alpha_f32,/* FetchTexel3Df */
+ store_texel_luminance_alpha_f32 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_luminance_alpha_float16 = {
+ MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, /* MesaFormat */
+ GL_LUMINANCE_ALPHA, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 8 * sizeof(GLhalfARB), /* AlphaBits */
+ 8 * sizeof(GLhalfARB), /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2 * sizeof(GLhalfARB), /* TexelBytes */
+ _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
+ fetch_texel_1d_luminance_alpha_f16, /* FetchTexel1D */
+ fetch_texel_2d_luminance_alpha_f16, /* FetchTexel2D */
+ fetch_texel_3d_luminance_alpha_f16, /* FetchTexel3D */
+ fetch_texel_1d_f_luminance_alpha_f16,/* FetchTexel1Df */
+ fetch_texel_2d_f_luminance_alpha_f16,/* FetchTexel2Df */
+ fetch_texel_3d_f_luminance_alpha_f16,/* FetchTexel3Df */
+ store_texel_luminance_alpha_f16 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_intensity_float32 = {
+ MESA_FORMAT_INTENSITY_FLOAT32, /* MesaFormat */
+ GL_INTENSITY, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 8 * sizeof(GLfloat), /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 1 * sizeof(GLfloat), /* TexelBytes */
+ _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_intensity_f32, /* FetchTexel1D */
+ fetch_texel_2d_intensity_f32, /* FetchTexel2D */
+ fetch_texel_3d_intensity_f32, /* FetchTexel3D */
+ fetch_texel_1d_f_intensity_f32, /* FetchTexel1Df */
+ fetch_texel_2d_f_intensity_f32, /* FetchTexel2Df */
+ fetch_texel_3d_f_intensity_f32, /* FetchTexel3Df */
+ store_texel_intensity_f32 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_intensity_float16 = {
+ MESA_FORMAT_INTENSITY_FLOAT16, /* MesaFormat */
+ GL_INTENSITY, /* BaseFormat */
+ GL_FLOAT, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 8 * sizeof(GLhalfARB), /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 1 * sizeof(GLhalfARB), /* TexelBytes */
+ _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_intensity_f16, /* FetchTexel1D */
+ fetch_texel_2d_intensity_f16, /* FetchTexel2D */
+ fetch_texel_3d_intensity_f16, /* FetchTexel3D */
+ fetch_texel_1d_f_intensity_f16, /* FetchTexel1Df */
+ fetch_texel_2d_f_intensity_f16, /* FetchTexel2Df */
+ fetch_texel_3d_f_intensity_f16, /* FetchTexel3Df */
+ store_texel_intensity_f16 /* StoreTexel */
+};
+
+
+/*@}*/
+
+
+/***************************************************************/
+/** \name Hardware formats */
+/*@{*/
+
+const struct gl_texture_format _mesa_texformat_rgba8888 = {
+ MESA_FORMAT_RGBA8888, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 8, /* RedBits */
+ 8, /* GreenBits */
+ 8, /* BlueBits */
+ 8, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 4, /* TexelBytes */
+ _mesa_texstore_rgba8888, /* StoreTexImageFunc */
+ fetch_texel_1d_rgba8888, /* FetchTexel1D */
+ fetch_texel_2d_rgba8888, /* FetchTexel2D */
+ fetch_texel_3d_rgba8888, /* FetchTexel3D */
+ fetch_texel_1d_f_rgba8888, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgba8888, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgba8888, /* FetchTexel3Df */
+ store_texel_rgba8888 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_rgba8888_rev = {
+ MESA_FORMAT_RGBA8888_REV, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 8, /* RedBits */
+ 8, /* GreenBits */
+ 8, /* BlueBits */
+ 8, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 4, /* TexelBytes */
+ _mesa_texstore_rgba8888, /* StoreTexImageFunc */
+ fetch_texel_1d_rgba8888_rev, /* FetchTexel1D */
+ fetch_texel_2d_rgba8888_rev, /* FetchTexel2D */
+ fetch_texel_3d_rgba8888_rev, /* FetchTexel3D */
+ fetch_texel_1d_f_rgba8888_rev, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgba8888_rev, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgba8888_rev, /* FetchTexel3Df */
+ store_texel_rgba8888_rev /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_argb8888 = {
+ MESA_FORMAT_ARGB8888, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 8, /* RedBits */
+ 8, /* GreenBits */
+ 8, /* BlueBits */
+ 8, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 4, /* TexelBytes */
+ _mesa_texstore_argb8888, /* StoreTexImageFunc */
+ fetch_texel_1d_argb8888, /* FetchTexel1D */
+ fetch_texel_2d_argb8888, /* FetchTexel2D */
+ fetch_texel_3d_argb8888, /* FetchTexel3D */
+ fetch_texel_1d_f_argb8888, /* FetchTexel1Df */
+ fetch_texel_2d_f_argb8888, /* FetchTexel2Df */
+ fetch_texel_3d_f_argb8888, /* FetchTexel3Df */
+ store_texel_argb8888 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_argb8888_rev = {
+ MESA_FORMAT_ARGB8888_REV, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 8, /* RedBits */
+ 8, /* GreenBits */
+ 8, /* BlueBits */
+ 8, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 4, /* TexelBytes */
+ _mesa_texstore_argb8888, /* StoreTexImageFunc */
+ fetch_texel_1d_argb8888_rev, /* FetchTexel1D */
+ fetch_texel_2d_argb8888_rev, /* FetchTexel2D */
+ fetch_texel_3d_argb8888_rev, /* FetchTexel3D */
+ fetch_texel_1d_f_argb8888_rev, /* FetchTexel1Df */
+ fetch_texel_2d_f_argb8888_rev, /* FetchTexel2Df */
+ fetch_texel_3d_f_argb8888_rev, /* FetchTexel3Df */
+ store_texel_argb8888_rev /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_rgb888 = {
+ MESA_FORMAT_RGB888, /* MesaFormat */
+ GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 8, /* RedBits */
+ 8, /* GreenBits */
+ 8, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 3, /* TexelBytes */
+ _mesa_texstore_rgb888, /* StoreTexImageFunc */
+ fetch_texel_1d_rgb888, /* FetchTexel1D */
+ fetch_texel_2d_rgb888, /* FetchTexel2D */
+ fetch_texel_3d_rgb888, /* FetchTexel3D */
+ fetch_texel_1d_f_rgb888, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgb888, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgb888, /* FetchTexel3Df */
+ store_texel_rgb888 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_bgr888 = {
+ MESA_FORMAT_BGR888, /* MesaFormat */
+ GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 8, /* RedBits */
+ 8, /* GreenBits */
+ 8, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 3, /* TexelBytes */
+ _mesa_texstore_bgr888, /* StoreTexImageFunc */
+ fetch_texel_1d_bgr888, /* FetchTexel1D */
+ fetch_texel_2d_bgr888, /* FetchTexel2D */
+ fetch_texel_3d_bgr888, /* FetchTexel3D */
+ fetch_texel_1d_f_bgr888, /* FetchTexel1Df */
+ fetch_texel_2d_f_bgr888, /* FetchTexel2Df */
+ fetch_texel_3d_f_bgr888, /* FetchTexel3Df */
+ store_texel_bgr888 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_rgb565 = {
+ MESA_FORMAT_RGB565, /* MesaFormat */
+ GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 5, /* RedBits */
+ 6, /* GreenBits */
+ 5, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2, /* TexelBytes */
+ _mesa_texstore_rgb565, /* StoreTexImageFunc */
+ fetch_texel_1d_rgb565, /* FetchTexel1D */
+ fetch_texel_2d_rgb565, /* FetchTexel2D */
+ fetch_texel_3d_rgb565, /* FetchTexel3D */
+ fetch_texel_1d_f_rgb565, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgb565, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgb565, /* FetchTexel3Df */
+ store_texel_rgb565 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_rgb565_rev = {
+ MESA_FORMAT_RGB565_REV, /* MesaFormat */
+ GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 5, /* RedBits */
+ 6, /* GreenBits */
+ 5, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2, /* TexelBytes */
+ _mesa_texstore_rgb565, /* StoreTexImageFunc */
+ fetch_texel_1d_rgb565_rev, /* FetchTexel1D */
+ fetch_texel_2d_rgb565_rev, /* FetchTexel2D */
+ fetch_texel_3d_rgb565_rev, /* FetchTexel3D */
+ fetch_texel_1d_f_rgb565_rev, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgb565_rev, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgb565_rev, /* FetchTexel3Df */
+ store_texel_rgb565_rev /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_argb4444 = {
+ MESA_FORMAT_ARGB4444, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 4, /* RedBits */
+ 4, /* GreenBits */
+ 4, /* BlueBits */
+ 4, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2, /* TexelBytes */
+ _mesa_texstore_argb4444, /* StoreTexImageFunc */
+ fetch_texel_1d_argb4444, /* FetchTexel1D */
+ fetch_texel_2d_argb4444, /* FetchTexel2D */
+ fetch_texel_3d_argb4444, /* FetchTexel3D */
+ fetch_texel_1d_f_argb4444, /* FetchTexel1Df */
+ fetch_texel_2d_f_argb4444, /* FetchTexel2Df */
+ fetch_texel_3d_f_argb4444, /* FetchTexel3Df */
+ store_texel_argb4444 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_argb4444_rev = {
+ MESA_FORMAT_ARGB4444_REV, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 4, /* RedBits */
+ 4, /* GreenBits */
+ 4, /* BlueBits */
+ 4, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2, /* TexelBytes */
+ _mesa_texstore_argb4444, /* StoreTexImageFunc */
+ fetch_texel_1d_argb4444_rev, /* FetchTexel1D */
+ fetch_texel_2d_argb4444_rev, /* FetchTexel2D */
+ fetch_texel_3d_argb4444_rev, /* FetchTexel3D */
+ fetch_texel_1d_f_argb4444_rev, /* FetchTexel1Df */
+ fetch_texel_2d_f_argb4444_rev, /* FetchTexel2Df */
+ fetch_texel_3d_f_argb4444_rev, /* FetchTexel3Df */
+ store_texel_argb4444_rev /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_argb1555 = {
+ MESA_FORMAT_ARGB1555, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 5, /* RedBits */
+ 5, /* GreenBits */
+ 5, /* BlueBits */
+ 1, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2, /* TexelBytes */
+ _mesa_texstore_argb1555, /* StoreTexImageFunc */
+ fetch_texel_1d_argb1555, /* FetchTexel1D */
+ fetch_texel_2d_argb1555, /* FetchTexel2D */
+ fetch_texel_3d_argb1555, /* FetchTexel3D */
+ fetch_texel_1d_f_argb1555, /* FetchTexel1Df */
+ fetch_texel_2d_f_argb1555, /* FetchTexel2Df */
+ fetch_texel_3d_f_argb1555, /* FetchTexel3Df */
+ store_texel_argb1555 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_argb1555_rev = {
+ MESA_FORMAT_ARGB1555_REV, /* MesaFormat */
+ GL_RGBA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 5, /* RedBits */
+ 5, /* GreenBits */
+ 5, /* BlueBits */
+ 1, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2, /* TexelBytes */
+ _mesa_texstore_argb1555, /* StoreTexImageFunc */
+ fetch_texel_1d_argb1555_rev, /* FetchTexel1D */
+ fetch_texel_2d_argb1555_rev, /* FetchTexel2D */
+ fetch_texel_3d_argb1555_rev, /* FetchTexel3D */
+ fetch_texel_1d_f_argb1555_rev, /* FetchTexel1Df */
+ fetch_texel_2d_f_argb1555_rev, /* FetchTexel2Df */
+ fetch_texel_3d_f_argb1555_rev, /* FetchTexel3Df */
+ store_texel_argb1555_rev /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_al88 = {
+ MESA_FORMAT_AL88, /* MesaFormat */
+ GL_LUMINANCE_ALPHA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 8, /* AlphaBits */
+ 8, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2, /* TexelBytes */
+ _mesa_texstore_al88, /* StoreTexImageFunc */
+ fetch_texel_1d_al88, /* FetchTexel1D */
+ fetch_texel_2d_al88, /* FetchTexel2D */
+ fetch_texel_3d_al88, /* FetchTexel3D */
+ fetch_texel_1d_f_al88, /* FetchTexel1Df */
+ fetch_texel_2d_f_al88, /* FetchTexel2Df */
+ fetch_texel_3d_f_al88, /* FetchTexel3Df */
+ store_texel_al88 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_al88_rev = {
+ MESA_FORMAT_AL88_REV, /* MesaFormat */
+ GL_LUMINANCE_ALPHA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 8, /* AlphaBits */
+ 8, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2, /* TexelBytes */
+ _mesa_texstore_al88, /* StoreTexImageFunc */
+ fetch_texel_1d_al88_rev, /* FetchTexel1D */
+ fetch_texel_2d_al88_rev, /* FetchTexel2D */
+ fetch_texel_3d_al88_rev, /* FetchTexel3D */
+ fetch_texel_1d_f_al88_rev, /* FetchTexel1Df */
+ fetch_texel_2d_f_al88_rev, /* FetchTexel2Df */
+ fetch_texel_3d_f_al88_rev, /* FetchTexel3Df */
+ store_texel_al88_rev /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_rgb332 = {
+ MESA_FORMAT_RGB332, /* MesaFormat */
+ GL_RGB, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 3, /* RedBits */
+ 3, /* GreenBits */
+ 2, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 1, /* TexelBytes */
+ _mesa_texstore_rgb332, /* StoreTexImageFunc */
+ fetch_texel_1d_rgb332, /* FetchTexel1D */
+ fetch_texel_2d_rgb332, /* FetchTexel2D */
+ fetch_texel_3d_rgb332, /* FetchTexel3D */
+ fetch_texel_1d_f_rgb332, /* FetchTexel1Df */
+ fetch_texel_2d_f_rgb332, /* FetchTexel2Df */
+ fetch_texel_3d_f_rgb332, /* FetchTexel3Df */
+ store_texel_rgb332 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_a8 = {
+ MESA_FORMAT_A8, /* MesaFormat */
+ GL_ALPHA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 8, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 1, /* TexelBytes */
+ _mesa_texstore_a8, /* StoreTexImageFunc */
+ fetch_texel_1d_a8, /* FetchTexel1D */
+ fetch_texel_2d_a8, /* FetchTexel2D */
+ fetch_texel_3d_a8, /* FetchTexel3D */
+ fetch_texel_1d_f_a8, /* FetchTexel1Df */
+ fetch_texel_2d_f_a8, /* FetchTexel2Df */
+ fetch_texel_3d_f_a8, /* FetchTexel3Df */
+ store_texel_a8 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_l8 = {
+ MESA_FORMAT_L8, /* MesaFormat */
+ GL_LUMINANCE, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 8, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 1, /* TexelBytes */
+ _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_l8, /* FetchTexel1D */
+ fetch_texel_2d_l8, /* FetchTexel2D */
+ fetch_texel_3d_l8, /* FetchTexel3D */
+ fetch_texel_1d_f_l8, /* FetchTexel1Df */
+ fetch_texel_2d_f_l8, /* FetchTexel2Df */
+ fetch_texel_3d_f_l8, /* FetchTexel3Df */
+ store_texel_l8 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_i8 = {
+ MESA_FORMAT_I8, /* MesaFormat */
+ GL_INTENSITY, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 8, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 1, /* TexelBytes */
+ _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
+ fetch_texel_1d_i8, /* FetchTexel1D */
+ fetch_texel_2d_i8, /* FetchTexel2D */
+ fetch_texel_3d_i8, /* FetchTexel3D */
+ fetch_texel_1d_f_i8, /* FetchTexel1Df */
+ fetch_texel_2d_f_i8, /* FetchTexel2Df */
+ fetch_texel_3d_f_i8, /* FetchTexel3Df */
+ store_texel_i8 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_ci8 = {
+ MESA_FORMAT_CI8, /* MesaFormat */
+ GL_COLOR_INDEX, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 8, /* IndexBits */
+ 0, /* DepthBits */
+ 1, /* TexelBytes */
+ _mesa_texstore_ci8, /* StoreTexImageFunc */
+ fetch_texel_1d_ci8, /* FetchTexel1D */
+ fetch_texel_2d_ci8, /* FetchTexel2D */
+ fetch_texel_3d_ci8, /* FetchTexel3D */
+ fetch_texel_1d_f_ci8, /* FetchTexel1Df */
+ fetch_texel_2d_f_ci8, /* FetchTexel2Df */
+ fetch_texel_3d_f_ci8, /* FetchTexel3Df */
+ store_texel_ci8 /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_ycbcr = {
+ MESA_FORMAT_YCBCR, /* MesaFormat */
+ GL_YCBCR_MESA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2, /* TexelBytes */
+ _mesa_texstore_ycbcr, /* StoreTexImageFunc */
+ fetch_texel_1d_ycbcr, /* FetchTexel1D */
+ fetch_texel_2d_ycbcr, /* FetchTexel2D */
+ fetch_texel_3d_ycbcr, /* FetchTexel3D */
+ fetch_texel_1d_f_ycbcr, /* FetchTexel1Df */
+ fetch_texel_2d_f_ycbcr, /* FetchTexel2Df */
+ fetch_texel_3d_f_ycbcr, /* FetchTexel3Df */
+ store_texel_ycbcr /* StoreTexel */
+};
+
+const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
+ MESA_FORMAT_YCBCR_REV, /* MesaFormat */
+ GL_YCBCR_MESA, /* BaseFormat */
+ GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 2, /* TexelBytes */
+ _mesa_texstore_ycbcr, /* StoreTexImageFunc */
+ fetch_texel_1d_ycbcr_rev, /* FetchTexel1D */
+ fetch_texel_2d_ycbcr_rev, /* FetchTexel2D */
+ fetch_texel_3d_ycbcr_rev, /* FetchTexel3D */
+ fetch_texel_1d_f_ycbcr_rev, /* FetchTexel1Df */
+ fetch_texel_2d_f_ycbcr_rev, /* FetchTexel2Df */
+ fetch_texel_3d_f_ycbcr_rev, /* FetchTexel3Df */
+ store_texel_ycbcr_rev /* StoreTexel */
+};
+
+/*@}*/
+
+
+/***************************************************************/
+/** \name Null format (useful for proxy textures) */
+/*@{*/
+
+const struct gl_texture_format _mesa_null_texformat = {
+ -1, /* MesaFormat */
+ 0, /* BaseFormat */
+ GL_NONE, /* DataType */
+ 0, /* RedBits */
+ 0, /* GreenBits */
+ 0, /* BlueBits */
+ 0, /* AlphaBits */
+ 0, /* LuminanceBits */
+ 0, /* IntensityBits */
+ 0, /* IndexBits */
+ 0, /* DepthBits */
+ 0, /* TexelBytes */
+ NULL, /* StoreTexImageFunc */
+ fetch_null_texel, /* FetchTexel1D */
+ fetch_null_texel, /* FetchTexel2D */
+ fetch_null_texel, /* FetchTexel3D */
+ fetch_null_texelf, /* FetchTexel1Df */
+ fetch_null_texelf, /* FetchTexel2Df */
+ fetch_null_texelf, /* FetchTexel3Df */
+ store_null_texel /* StoreTexel */
+};
+
+/*@}*/
+
+
+/**
+ * Choose an appropriate texture format given the format, type and
+ * internalFormat parameters passed to glTexImage().
+ *
+ * \param ctx the GL context.
+ * \param internalFormat user's prefered internal texture format.
+ * \param format incoming image pixel format.
+ * \param type incoming image data type.
+ *
+ * \return a pointer to a gl_texture_format object which describes the
+ * choosen texture format, or NULL on failure.
+ *
+ * This is called via dd_function_table::ChooseTextureFormat. Hardware drivers
+ * will typically override this function with a specialized version.
+ */
+const struct gl_texture_format *
+_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type )
+{
+ (void) format;
+ (void) type;
+
+ switch (internalFormat) {
+ /* RGBA formats */
+ case 4:
+ case GL_RGBA:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ return &_mesa_texformat_rgba;
+ case GL_RGBA8:
+ return &_mesa_texformat_rgba8888;
+ case GL_RGB5_A1:
+ return &_mesa_texformat_argb1555;
+ case GL_RGBA2:
+ return &_mesa_texformat_argb4444_rev; /* just to test another format*/
+ case GL_RGBA4:
+ return &_mesa_texformat_argb4444;
+
+ /* RGB formats */
+ case 3:
+ case GL_RGB:
+ case GL_RGB10:
+ case GL_RGB12:
+ case GL_RGB16:
+ return &_mesa_texformat_rgb;
+ case GL_RGB8:
+ return &_mesa_texformat_rgb888;
+ case GL_R3_G3_B2:
+ return &_mesa_texformat_rgb332;
+ case GL_RGB4:
+ return &_mesa_texformat_rgb565_rev; /* just to test another format */
+ case GL_RGB5:
+ return &_mesa_texformat_rgb565;
+
+ /* Alpha formats */
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ return &_mesa_texformat_alpha;
+ case GL_ALPHA8:
+ return &_mesa_texformat_a8;
+
+ /* Luminance formats */
+ case 1:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE4:
+ case GL_LUMINANCE12:
+ case GL_LUMINANCE16:
+ return &_mesa_texformat_luminance;
+ case GL_LUMINANCE8:
+ return &_mesa_texformat_l8;
+
+ /* Luminance/Alpha formats */
+ case 2:
+ case GL_LUMINANCE_ALPHA:
+ case GL_LUMINANCE4_ALPHA4:
+ case GL_LUMINANCE6_ALPHA2:
+ case GL_LUMINANCE12_ALPHA4:
+ case GL_LUMINANCE12_ALPHA12:
+ case GL_LUMINANCE16_ALPHA16:
+ return &_mesa_texformat_luminance_alpha;
+ case GL_LUMINANCE8_ALPHA8:
+ return &_mesa_texformat_al88;
+
+ case GL_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ return &_mesa_texformat_intensity;
+ case GL_INTENSITY8:
+ return &_mesa_texformat_i8;
+
+ case GL_COLOR_INDEX:
+ case GL_COLOR_INDEX1_EXT:
+ case GL_COLOR_INDEX2_EXT:
+ case GL_COLOR_INDEX4_EXT:
+ case GL_COLOR_INDEX12_EXT:
+ case GL_COLOR_INDEX16_EXT:
+ case GL_COLOR_INDEX8_EXT:
+ return &_mesa_texformat_ci8;
+
+ default:
+ ; /* fallthrough */
+ }
+
+ if (ctx->Extensions.SGIX_depth_texture ||
+ ctx->Extensions.ARB_depth_texture) {
+ switch (internalFormat) {
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT24_SGIX:
+ case GL_DEPTH_COMPONENT32_SGIX:
+ return &_mesa_texformat_depth_component_float32;
+ case GL_DEPTH_COMPONENT16_SGIX:
+ return &_mesa_texformat_depth_component16;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.ARB_texture_compression) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_ALPHA_ARB:
+ return &_mesa_texformat_alpha;
+ case GL_COMPRESSED_LUMINANCE_ARB:
+ return &_mesa_texformat_luminance;
+ case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
+ return &_mesa_texformat_luminance_alpha;
+ case GL_COMPRESSED_INTENSITY_ARB:
+ return &_mesa_texformat_intensity;
+ case GL_COMPRESSED_RGB_ARB:
+ if (ctx->Extensions.TDFX_texture_compression_FXT1)
+ return &_mesa_texformat_rgb_fxt1;
+ else if (ctx->Extensions.EXT_texture_compression_s3tc ||
+ ctx->Extensions.S3_s3tc)
+ return &_mesa_texformat_rgb_dxt1;
+ else
+ return &_mesa_texformat_rgb;
+ case GL_COMPRESSED_RGBA_ARB:
+ if (ctx->Extensions.TDFX_texture_compression_FXT1)
+ return &_mesa_texformat_rgba_fxt1;
+ else if (ctx->Extensions.EXT_texture_compression_s3tc ||
+ ctx->Extensions.S3_s3tc)
+ return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1, see spec */
+ else
+ return &_mesa_texformat_rgba;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.MESA_ycbcr_texture) {
+ if (internalFormat == GL_YCBCR_MESA) {
+ if (type == GL_UNSIGNED_SHORT_8_8_MESA)
+ return &_mesa_texformat_ycbcr;
+ else
+ return &_mesa_texformat_ycbcr_rev;
+ }
+ }
+
+ if (ctx->Extensions.TDFX_texture_compression_FXT1) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ return &_mesa_texformat_rgb_fxt1;
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ return &_mesa_texformat_rgba_fxt1;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.EXT_texture_compression_s3tc) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgb_dxt1;
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ return &_mesa_texformat_rgba_dxt1;
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ return &_mesa_texformat_rgba_dxt3;
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ return &_mesa_texformat_rgba_dxt5;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.S3_s3tc) {
+ switch (internalFormat) {
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ return &_mesa_texformat_rgb_dxt1;
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ return &_mesa_texformat_rgba_dxt3;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.ARB_texture_float) {
+ switch (internalFormat) {
+ case GL_ALPHA16F_ARB:
+ return &_mesa_texformat_alpha_float16;
+ case GL_ALPHA32F_ARB:
+ return &_mesa_texformat_alpha_float32;
+ case GL_LUMINANCE16F_ARB:
+ return &_mesa_texformat_luminance_float16;
+ case GL_LUMINANCE32F_ARB:
+ return &_mesa_texformat_luminance_float32;
+ case GL_LUMINANCE_ALPHA16F_ARB:
+ return &_mesa_texformat_luminance_alpha_float16;
+ case GL_LUMINANCE_ALPHA32F_ARB:
+ return &_mesa_texformat_luminance_alpha_float32;
+ case GL_INTENSITY16F_ARB:
+ return &_mesa_texformat_intensity_float16;
+ case GL_INTENSITY32F_ARB:
+ return &_mesa_texformat_intensity_float32;
+ case GL_RGB16F_ARB:
+ return &_mesa_texformat_rgb_float16;
+ case GL_RGB32F_ARB:
+ return &_mesa_texformat_rgb_float32;
+ case GL_RGBA16F_ARB:
+ return &_mesa_texformat_rgba_float16;
+ case GL_RGBA32F_ARB:
+ return &_mesa_texformat_rgba_float32;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
+ return NULL;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/texformat.h b/nx-X11/extras/Mesa/src/mesa/main/texformat.h
new file mode 100644
index 000000000..35522d621
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/texformat.h
@@ -0,0 +1,229 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file texformat.h
+ * Texture formats definitions.
+ *
+ * \author Gareth Hughes
+ */
+
+
+#ifndef TEXFORMAT_H
+#define TEXFORMAT_H
+
+
+#include "mtypes.h"
+
+
+/**
+ * Mesa internal texture image formats.
+ * All texture images are stored in one of these formats.
+ *
+ * NOTE: when you add a new format, be sure to update the do_row()
+ * function in texstore.c used for auto mipmap generation.
+ */
+enum _format {
+ /**
+ * \name Hardware-friendly formats.
+ *
+ * Drivers can override the default formats and convert texture images to
+ * one of these as required. The driver's
+ * dd_function_table::ChooseTextureFormat function will choose one of these
+ * formats.
+ *
+ * \note In the default case, some of these formats will be duplicates of
+ * the generic formats listed below. However, these formats guarantee their
+ * internal component sizes, while GLchan may vary between GLubyte, GLushort
+ * and GLfloat.
+ */
+ /*@{*/
+ /* msb <------ TEXEL BITS -----------> lsb */
+ /* ---- ---- ---- ---- ---- ---- ---- ---- */
+ MESA_FORMAT_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
+ MESA_FORMAT_RGBA8888_REV, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
+ MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
+ MESA_FORMAT_ARGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
+ MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */
+ MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */
+ MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */
+ MESA_FORMAT_RGB565_REV, /* GGGB BBBB RRRR RGGG */
+ MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */
+ MESA_FORMAT_ARGB4444_REV, /* GGGG BBBB AAAA RRRR */
+ MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */
+ MESA_FORMAT_ARGB1555_REV, /* GGGB BBBB ARRR RRGG */
+ MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */
+ MESA_FORMAT_AL88_REV, /* LLLL LLLL AAAA AAAA */
+ MESA_FORMAT_RGB332, /* RRRG GGBB */
+ MESA_FORMAT_A8, /* AAAA AAAA */
+ MESA_FORMAT_L8, /* LLLL LLLL */
+ MESA_FORMAT_I8, /* IIII IIII */
+ MESA_FORMAT_CI8, /* CCCC CCCC */
+ MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */
+ MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */
+ /*@}*/
+
+ /**
+ * \name Compressed texture formats.
+ */
+ /*@{*/
+ MESA_FORMAT_RGB_FXT1,
+ MESA_FORMAT_RGBA_FXT1,
+ MESA_FORMAT_RGB_DXT1,
+ MESA_FORMAT_RGBA_DXT1,
+ MESA_FORMAT_RGBA_DXT3,
+ MESA_FORMAT_RGBA_DXT5,
+ /*@}*/
+
+ /**
+ * \name Generic GLchan-based formats.
+ *
+ * Software-oriented texture formats. Texels are arrays of GLchan
+ * values so there are no byte order issues.
+ *
+ * \note Because these are based on the GLchan data type, one cannot assume
+ * 8 bits per channel with these formats. If you require GLubyte channels,
+ * use one of the hardware formats above.
+ */
+ /*@{*/
+ MESA_FORMAT_RGBA,
+ MESA_FORMAT_RGB,
+ MESA_FORMAT_ALPHA,
+ MESA_FORMAT_LUMINANCE,
+ MESA_FORMAT_LUMINANCE_ALPHA,
+ MESA_FORMAT_INTENSITY,
+ /*@}*/
+
+ /**
+ * Depth textures
+ */
+ /*@{*/
+ MESA_FORMAT_DEPTH_COMPONENT_FLOAT32,
+ MESA_FORMAT_DEPTH_COMPONENT16,
+ /*@}*/
+
+ /**
+ * \name Floating point texture formats.
+ */
+ /*@{*/
+ MESA_FORMAT_RGBA_FLOAT32,
+ MESA_FORMAT_RGBA_FLOAT16,
+ MESA_FORMAT_RGB_FLOAT32,
+ MESA_FORMAT_RGB_FLOAT16,
+ MESA_FORMAT_ALPHA_FLOAT32,
+ MESA_FORMAT_ALPHA_FLOAT16,
+ MESA_FORMAT_LUMINANCE_FLOAT32,
+ MESA_FORMAT_LUMINANCE_FLOAT16,
+ MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
+ MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
+ MESA_FORMAT_INTENSITY_FLOAT32,
+ MESA_FORMAT_INTENSITY_FLOAT16
+ /*@}*/
+};
+
+
+/** GLchan-valued formats */
+/*@{*/
+extern const struct gl_texture_format _mesa_texformat_rgba;
+extern const struct gl_texture_format _mesa_texformat_rgb;
+extern const struct gl_texture_format _mesa_texformat_alpha;
+extern const struct gl_texture_format _mesa_texformat_luminance;
+extern const struct gl_texture_format _mesa_texformat_luminance_alpha;
+extern const struct gl_texture_format _mesa_texformat_intensity;
+/*@}*/
+
+/** Depth textures */
+/*@{*/
+extern const struct gl_texture_format _mesa_texformat_depth_component_float32;
+extern const struct gl_texture_format _mesa_texformat_depth_component16;
+/*@}*/
+
+/** Floating point texture formats */
+/*@{*/
+extern const struct gl_texture_format _mesa_texformat_rgba_float32;
+extern const struct gl_texture_format _mesa_texformat_rgba_float16;
+extern const struct gl_texture_format _mesa_texformat_rgb_float32;
+extern const struct gl_texture_format _mesa_texformat_rgb_float16;
+extern const struct gl_texture_format _mesa_texformat_alpha_float32;
+extern const struct gl_texture_format _mesa_texformat_alpha_float16;
+extern const struct gl_texture_format _mesa_texformat_luminance_float32;
+extern const struct gl_texture_format _mesa_texformat_luminance_float16;
+extern const struct gl_texture_format _mesa_texformat_luminance_alpha_float32;
+extern const struct gl_texture_format _mesa_texformat_luminance_alpha_float16;
+extern const struct gl_texture_format _mesa_texformat_intensity_float32;
+extern const struct gl_texture_format _mesa_texformat_intensity_float16;
+/*@}*/
+
+/** \name Assorted hardware-friendly formats */
+/*@{*/
+extern const struct gl_texture_format _mesa_texformat_rgba8888;
+extern const struct gl_texture_format _mesa_texformat_rgba8888_rev;
+extern const struct gl_texture_format _mesa_texformat_argb8888;
+extern const struct gl_texture_format _mesa_texformat_argb8888_rev;
+extern const struct gl_texture_format _mesa_texformat_rgb888;
+extern const struct gl_texture_format _mesa_texformat_bgr888;
+extern const struct gl_texture_format _mesa_texformat_rgb565;
+extern const struct gl_texture_format _mesa_texformat_rgb565_rev;
+extern const struct gl_texture_format _mesa_texformat_argb4444;
+extern const struct gl_texture_format _mesa_texformat_argb4444_rev;
+extern const struct gl_texture_format _mesa_texformat_argb1555;
+extern const struct gl_texture_format _mesa_texformat_argb1555_rev;
+extern const struct gl_texture_format _mesa_texformat_al88;
+extern const struct gl_texture_format _mesa_texformat_al88_rev;
+extern const struct gl_texture_format _mesa_texformat_rgb332;
+extern const struct gl_texture_format _mesa_texformat_a8;
+extern const struct gl_texture_format _mesa_texformat_l8;
+extern const struct gl_texture_format _mesa_texformat_i8;
+extern const struct gl_texture_format _mesa_texformat_ci8;
+
+/*@}*/
+
+/** \name YCbCr formats */
+/*@{*/
+extern const struct gl_texture_format _mesa_texformat_ycbcr;
+extern const struct gl_texture_format _mesa_texformat_ycbcr_rev;
+/*@}*/
+
+/** \name Compressed formats */
+/*@{*/
+extern const struct gl_texture_format _mesa_texformat_rgb_fxt1;
+extern const struct gl_texture_format _mesa_texformat_rgba_fxt1;
+extern const struct gl_texture_format _mesa_texformat_rgb_dxt1;
+extern const struct gl_texture_format _mesa_texformat_rgba_dxt1;
+extern const struct gl_texture_format _mesa_texformat_rgba_dxt3;
+extern const struct gl_texture_format _mesa_texformat_rgba_dxt5;
+/*@}*/
+
+/** \name The null format */
+/*@{*/
+extern const struct gl_texture_format _mesa_null_texformat;
+/*@}*/
+
+
+extern const struct gl_texture_format *
+_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/texformat_tmp.h b/nx-X11/extras/Mesa/src/mesa/main/texformat_tmp.h
new file mode 100644
index 000000000..22531d826
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/texformat_tmp.h
@@ -0,0 +1,1762 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3.2
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file texformat_tmp.h
+ * Texel fetch functions template.
+ *
+ * This template file is used by texformat.c to generate texel fetch functions
+ * for 1-D, 2-D and 3-D texture images.
+ *
+ * It should be expanded by defining \p DIM as the number texture dimensions
+ * (1, 2 or 3). According to the value of \p DIM a series of macros is defined
+ * for the texel lookup in the gl_texture_image::Data.
+ *
+ * \sa texformat.c and FetchTexel.
+ *
+ * \author Gareth Hughes
+ * \author Brian Paul
+ */
+
+
+#if DIM == 1
+
+#define CHAN_ADDR( t, i, j, k, sz ) \
+ ((void) (j), (void) (k), \
+ ((GLchan *)(t)->Data + (i) * (sz)))
+#define UBYTE_ADDR( t, i, j, k, sz ) \
+ ((void) (j), (void) (k), \
+ ((GLubyte *)(t)->Data + (i) * (sz)))
+#define USHORT_ADDR( t, i, j, k ) \
+ ((void) (j), (void) (k), \
+ ((GLushort *)(t)->Data + (i)))
+#define UINT_ADDR( t, i, j, k ) \
+ ((void) (j), (void) (k), \
+ ((GLuint *)(t)->Data + (i)))
+#define FLOAT_ADDR( t, i, j, k, sz ) \
+ ((void) (j), (void) (k), \
+ ((GLfloat *)(t)->Data + (i) * (sz)))
+#define HALF_ADDR( t, i, j, k, sz ) \
+ ((void) (j), (void) (k), \
+ ((GLhalfARB *)(t)->Data + (i) * (sz)))
+
+#define FETCH(x) fetch_texel_1d_##x
+
+#elif DIM == 2
+
+#define CHAN_ADDR( t, i, j, k, sz ) \
+ ((void) (k), \
+ ((GLchan *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz)))
+#define UBYTE_ADDR( t, i, j, k, sz ) \
+ ((void) (k), \
+ ((GLubyte *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz)))
+#define USHORT_ADDR( t, i, j, k ) \
+ ((void) (k), \
+ ((GLushort *)(t)->Data + ((t)->RowStride * (j) + (i))))
+#define UINT_ADDR( t, i, j, k ) \
+ ((void) (k), \
+ ((GLuint *)(t)->Data + ((t)->RowStride * (j) + (i))))
+#define FLOAT_ADDR( t, i, j, k, sz ) \
+ ((void) (k), \
+ ((GLfloat *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz)))
+#define HALF_ADDR( t, i, j, k, sz ) \
+ ((void) (k), \
+ ((GLhalfARB *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz)))
+
+#define FETCH(x) fetch_texel_2d_##x
+
+#elif DIM == 3
+
+#define CHAN_ADDR( t, i, j, k, sz ) \
+ (GLchan *)(t)->Data + (((t)->Height * (k) + (j)) * \
+ (t)->RowStride + (i)) * (sz)
+#define UBYTE_ADDR( t, i, j, k, sz ) \
+ ((GLubyte *)(t)->Data + (((t)->Height * (k) + (j)) * \
+ (t)->RowStride + (i)) * (sz))
+#define USHORT_ADDR( t, i, j, k ) \
+ ((GLushort *)(t)->Data + (((t)->Height * (k) + (j)) * \
+ (t)->RowStride + (i)))
+#define UINT_ADDR( t, i, j, k ) \
+ ((GLuint *)(t)->Data + (((t)->Height * (k) + (j)) * \
+ (t)->RowStride + (i)))
+#define FLOAT_ADDR( t, i, j, k, sz ) \
+ ((GLfloat *)(t)->Data + (((t)->Height * (k) + (j)) * \
+ (t)->RowStride + (i)) * (sz))
+#define HALF_ADDR( t, i, j, k, sz ) \
+ ((GLhalfARB *)(t)->Data + (((t)->Height * (k) + (j)) * \
+ (t)->RowStride + (i)) * (sz))
+
+#define FETCH(x) fetch_texel_3d_##x
+
+#else
+#error illegal number of texture dimensions
+#endif
+
+
+/* MESA_FORMAT_RGBA **********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RGBA texture, returning 4 GLchans */
+static void FETCH(rgba)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 4 );
+ COPY_CHAN4( texel, src );
+}
+
+/* Fetch texel from 1D, 2D or 3D RGBA texture, returning 4 GLfloats */
+static void FETCH(f_rgba)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 4 );
+ texel[RCOMP] = CHAN_TO_FLOAT(src[0]);
+ texel[GCOMP] = CHAN_TO_FLOAT(src[1]);
+ texel[BCOMP] = CHAN_TO_FLOAT(src[2]);
+ texel[ACOMP] = CHAN_TO_FLOAT(src[3]);
+}
+
+#if DIM == 3
+/* Store a GLchan RGBA texel */
+static void store_texel_rgba(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLchan *rgba = (const GLchan *) texel;
+ GLchan *dst = CHAN_ADDR(texImage, i, j, k, 4);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+ dst[3] = rgba[ACOMP];
+}
+#endif
+
+/* MESA_FORMAT_RGB ***********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RGB texture, returning 4 GLchans */
+static void FETCH(rgb)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 3 );
+ texel[RCOMP] = src[0];
+ texel[GCOMP] = src[1];
+ texel[BCOMP] = src[2];
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch texel from 1D, 2D or 3D RGB texture, returning 4 GLfloats */
+static void FETCH(f_rgb)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 3 );
+ texel[RCOMP] = CHAN_TO_FLOAT(src[0]);
+ texel[GCOMP] = CHAN_TO_FLOAT(src[1]);
+ texel[BCOMP] = CHAN_TO_FLOAT(src[2]);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLchan *rgba = (const GLchan *) texel;
+ GLchan *dst = CHAN_ADDR(texImage, i, j, k, 3);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+}
+#endif
+
+/* MESA_FORMAT_ALPHA *********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D ALPHA texture, returning 4 GLchans */
+static void FETCH(alpha)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0;
+ texel[ACOMP] = src[0];
+}
+
+/* Fetch texel from 1D, 2D or 3D ALPHA texture, returning 4 GLfloats */
+static void FETCH(f_alpha)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0.0;
+ texel[ACOMP] = CHAN_TO_FLOAT(src[0]);
+}
+
+#if DIM == 3
+static void store_texel_alpha(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLchan *rgba = (const GLchan *) texel;
+ GLchan *dst = CHAN_ADDR(texImage, i, j, k, 1);
+ dst[0] = rgba[ACOMP];
+}
+#endif
+
+/* MESA_FORMAT_LUMINANCE *****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D LUMIN texture, returning 4 GLchans */
+static void FETCH(luminance)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = src[0];
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch texel from 1D, 2D or 3D LUMIN texture, returning 4 GLfloats */
+static void FETCH(f_luminance)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = CHAN_TO_FLOAT(src[0]);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_luminance(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLchan *rgba = (const GLchan *) texel;
+ GLchan *dst = CHAN_ADDR(texImage, i, j, k, 1);
+ dst[0] = rgba[RCOMP];
+}
+#endif
+
+/* MESA_FORMAT_LUMINANCE_ALPHA ***********************************************/
+
+/* Fetch texel from 1D, 2D or 3D L_A texture, returning 4 GLchans */
+static void FETCH(luminance_alpha)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 2 );
+ texel[RCOMP] = src[0];
+ texel[GCOMP] = src[0];
+ texel[BCOMP] = src[0];
+ texel[ACOMP] = src[1];
+}
+
+/* Fetch texel from 1D, 2D or 3D L_A texture, returning 4 GLfloats */
+static void FETCH(f_luminance_alpha)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 2 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = CHAN_TO_FLOAT(src[0]);
+ texel[ACOMP] = CHAN_TO_FLOAT(src[1]);
+}
+
+#if DIM == 3
+static void store_texel_luminance_alpha(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLchan *rgba = (const GLchan *) texel;
+ GLchan *dst = CHAN_ADDR(texImage, i, j, k, 2);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[ACOMP];
+}
+#endif
+
+/* MESA_FORMAT_INTENSITY *****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D INT. texture, returning 4 GLchans */
+static void FETCH(intensity)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] = src[0];
+ texel[GCOMP] = src[0];
+ texel[BCOMP] = src[0];
+ texel[ACOMP] = src[0];
+}
+
+/* Fetch texel from 1D, 2D or 3D INT. texture, returning 4 GLfloats */
+static void FETCH(f_intensity)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLchan *src = CHAN_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = CHAN_TO_FLOAT(src[0]);
+}
+
+#if DIM == 3
+static void store_texel_intensity(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLchan *rgba = (const GLchan *) texel;
+ GLchan *dst = CHAN_ADDR(texImage, i, j, k, 1);
+ dst[0] = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_DEPTH_COMPONENT_F32 *******************************************/
+
+/* Fetch depth texel from 1D, 2D or 3D float32 DEPTH texture,
+ * returning 1 GLfloat.
+ * Note: no GLchan version of this function.
+ */
+static void FETCH(f_depth_component_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 1 );
+ texel[0] = src[0];
+}
+
+#if DIM == 3
+static void store_texel_depth_component_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *depth = (const GLfloat *) texel;
+ GLfloat *dst = FLOAT_ADDR(texImage, i, j, k, 1);
+ dst[0] = *depth;
+}
+#endif
+
+
+/* MESA_FORMAT_DEPTH_COMPONENT16 *********************************************/
+
+/* Fetch depth texel from 1D, 2D or 3D float32 DEPTH texture,
+ * returning 1 GLfloat.
+ * Note: no GLchan version of this function.
+ */
+static void FETCH(f_depth_component16)(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
+ texel[0] = src[0] * (1.0F / 65535.0F);
+}
+
+#if DIM == 3
+static void store_texel_depth_component16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLushort *depth = (const GLushort *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ dst[0] = *depth;
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA_F32 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, returning 4 GLchans.
+ */
+static void FETCH(rgba_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 4 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], src[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(texel[GCOMP], src[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(texel[BCOMP], src[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], src[3]);
+}
+
+/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT32 texture, returning 4 GLfloats.
+ */
+static void FETCH(f_rgba_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 4 );
+ texel[RCOMP] = src[0];
+ texel[GCOMP] = src[1];
+ texel[BCOMP] = src[2];
+ texel[ACOMP] = src[3];
+}
+
+#if DIM == 3
+static void store_texel_rgba_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *depth = (const GLfloat *) texel;
+ GLfloat *dst = FLOAT_ADDR(texImage, i, j, k, 1);
+ dst[0] = depth[RCOMP];
+ dst[1] = depth[GCOMP];
+ dst[2] = depth[BCOMP];
+ dst[3] = depth[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA_F16 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(rgba_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 4 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], _mesa_half_to_float(src[0]));
+ UNCLAMPED_FLOAT_TO_CHAN(texel[GCOMP], _mesa_half_to_float(src[1]));
+ UNCLAMPED_FLOAT_TO_CHAN(texel[BCOMP], _mesa_half_to_float(src[2]));
+ UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], _mesa_half_to_float(src[3]));
+}
+
+/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_rgba_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 4 );
+ texel[RCOMP] = _mesa_half_to_float(src[0]);
+ texel[GCOMP] = _mesa_half_to_float(src[1]);
+ texel[BCOMP] = _mesa_half_to_float(src[2]);
+ texel[ACOMP] = _mesa_half_to_float(src[3]);
+}
+
+#if DIM == 3
+static void store_texel_rgba_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *depth = (const GLfloat *) texel;
+ GLhalfARB *dst = HALF_ADDR(texImage, i, j, k, 1);
+ dst[0] = _mesa_float_to_half(*depth);
+}
+#endif
+
+/* MESA_FORMAT_RGB_F32 *******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RGB_FLOAT32 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(rgb_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 3 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], src[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(texel[GCOMP], src[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(texel[BCOMP], src[2]);
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch texel from 1D, 2D or 3D RGB_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_rgb_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 3 );
+ texel[RCOMP] = src[0];
+ texel[GCOMP] = src[1];
+ texel[BCOMP] = src[2];
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *depth = (const GLfloat *) texel;
+ GLfloat *dst = FLOAT_ADDR(texImage, i, j, k, 1);
+ dst[0] = *depth;
+}
+#endif
+
+
+/* MESA_FORAMT_RGB_F16 *******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D RGBA_FLOAT16 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(rgb_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 3 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], _mesa_half_to_float(src[0]));
+ UNCLAMPED_FLOAT_TO_CHAN(texel[GCOMP], _mesa_half_to_float(src[1]));
+ UNCLAMPED_FLOAT_TO_CHAN(texel[BCOMP], _mesa_half_to_float(src[2]));
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch texel from 1D, 2D or 3D RGB_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_rgb_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 3 );
+ texel[RCOMP] = _mesa_half_to_float(src[0]);
+ texel[GCOMP] = _mesa_half_to_float(src[1]);
+ texel[BCOMP] = _mesa_half_to_float(src[2]);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *depth = (const GLfloat *) texel;
+ GLhalfARB *dst = HALF_ADDR(texImage, i, j, k, 1);
+ dst[0] = _mesa_float_to_half(*depth);
+}
+#endif
+
+
+/* MESA_FORMAT_ALPHA_F32 *****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT32 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(alpha_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0;
+ UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], src[0]);
+}
+
+/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_alpha_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = src[0];
+}
+
+#if DIM == 3
+static void store_texel_alpha_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLfloat *dst = FLOAT_ADDR(texImage, i, j, k, 1);
+ dst[0] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_ALPHA_F32 *****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT16 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(alpha_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0;
+ UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], _mesa_half_to_float(src[0]));
+}
+
+/* Fetch texel from 1D, 2D or 3D ALPHA_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_alpha_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0.0F;
+ texel[ACOMP] = _mesa_half_to_float(src[0]);
+}
+
+#if DIM == 3
+static void store_texel_alpha_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLhalfARB *dst = HALF_ADDR(texImage, i, j, k, 1);
+ dst[0] = _mesa_float_to_half(rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_LUMINANCE_F32 *************************************************/
+
+/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(luminance_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 1 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], src[0]);
+ texel[GCOMP] =
+ texel[BCOMP] = texel[RCOMP];
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_luminance_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = src[0];
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_luminance_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLfloat *dst = FLOAT_ADDR(texImage, i, j, k, 1);
+ dst[0] = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_LUMINANCE_F16 *************************************************/
+
+/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(luminance_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 1 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], _mesa_half_to_float(src[0]));
+ texel[GCOMP] =
+ texel[BCOMP] = texel[RCOMP];
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch texel from 1D, 2D or 3D LUMINANCE_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_luminance_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = _mesa_half_to_float(src[0]);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_luminance_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLhalfARB *dst = HALF_ADDR(texImage, i, j, k, 1);
+ dst[0] = _mesa_float_to_half(rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_LUMINANCE_ALPHA_F32 *******************************************/
+
+/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(luminance_alpha_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 2 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], src[0]);
+ texel[GCOMP] =
+ texel[BCOMP] = texel[RCOMP];
+ UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], src[1]);
+}
+
+/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_luminance_alpha_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 2 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = src[0];
+ texel[ACOMP] = src[1];
+}
+
+#if DIM == 3
+static void store_texel_luminance_alpha_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLfloat *dst = FLOAT_ADDR(texImage, i, j, k, 2);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_LUMINANCE_ALPHA_F16 *******************************************/
+
+/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(luminance_alpha_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 2 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], _mesa_half_to_float(src[0]));
+ texel[GCOMP] =
+ texel[BCOMP] = texel[RCOMP];
+ UNCLAMPED_FLOAT_TO_CHAN(texel[ACOMP], _mesa_half_to_float(src[1]));
+}
+
+/* Fetch texel from 1D, 2D or 3D LUMINANCE_ALPHA_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_luminance_alpha_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 2 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = _mesa_half_to_float(src[0]);
+ texel[ACOMP] = _mesa_half_to_float(src[1]);
+}
+
+#if DIM == 3
+static void store_texel_luminance_alpha_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLhalfARB *dst = HALF_ADDR(texImage, i, j, k, 2);
+ dst[0] = _mesa_float_to_half(rgba[RCOMP]);
+ dst[1] = _mesa_float_to_half(rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_INTENSITY_F32 *************************************************/
+
+/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(intensity_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 1 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], src[0]);
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = texel[RCOMP];
+}
+
+/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT32 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_intensity_f32)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLfloat *src = FLOAT_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = src[0];
+}
+
+#if DIM == 3
+static void store_texel_intensity_f32(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLfloat *dst = FLOAT_ADDR(texImage, i, j, k, 1);
+ dst[0] = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_INTENSITY_F16 *************************************************/
+
+/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture,
+ * returning 4 GLchans.
+ */
+static void FETCH(intensity_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 1 );
+ UNCLAMPED_FLOAT_TO_CHAN(texel[RCOMP], _mesa_half_to_float(src[0]));
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = texel[RCOMP];
+}
+
+/* Fetch texel from 1D, 2D or 3D INTENSITY_FLOAT16 texture,
+ * returning 4 GLfloats.
+ */
+static void FETCH(f_intensity_f16)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLhalfARB *src = HALF_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = _mesa_half_to_float(src[0]);
+}
+
+#if DIM == 3
+static void store_texel_intensity_f16(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLfloat *rgba = (const GLfloat *) texel;
+ GLhalfARB *dst = HALF_ADDR(texImage, i, j, k, 1);
+ dst[0] = _mesa_float_to_half(rgba[RCOMP]);
+}
+#endif
+
+
+
+
+/*
+ * Begin Hardware formats
+ */
+
+/* MESA_FORMAT_RGBA8888 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLchans */
+static void FETCH(rgba8888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLuint s = *UINT_ADDR( texImage, i, j, k );
+ texel[RCOMP] = UBYTE_TO_CHAN( (s >> 24) );
+ texel[GCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff );
+ texel[BCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff );
+ texel[ACOMP] = UBYTE_TO_CHAN( (s ) & 0xff );
+}
+
+/* Fetch texel from 1D, 2D or 3D rgba8888 texture, return 4 GLfloats */
+static void FETCH(f_rgba8888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *UINT_ADDR( texImage, i, j, k );
+ texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 24) );
+ texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+ texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
+ texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
+}
+
+#if DIM == 3
+static void store_texel_rgba8888(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = UINT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RGBA888_REV ***************************************************/
+
+/* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLchans */
+static void FETCH(rgba8888_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLuint s = *UINT_ADDR( texImage, i, j, k );
+ texel[RCOMP] = UBYTE_TO_CHAN( (s ) & 0xff );
+ texel[GCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff );
+ texel[BCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff );
+ texel[ACOMP] = UBYTE_TO_CHAN( (s >> 24) );
+}
+
+/* Fetch texel from 1D, 2D or 3D abgr8888 texture, return 4 GLfloats */
+static void FETCH(f_rgba8888_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *UINT_ADDR( texImage, i, j, k );
+ texel[RCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
+ texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
+ texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+ texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) );
+}
+
+#if DIM == 3
+static void store_texel_rgba8888_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = UINT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_8888_REV(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB8888 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLchans */
+static void FETCH(argb8888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLuint s = *UINT_ADDR( texImage, i, j, k );
+ texel[RCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff );
+ texel[GCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff );
+ texel[BCOMP] = UBYTE_TO_CHAN( (s ) & 0xff );
+ texel[ACOMP] = UBYTE_TO_CHAN( (s >> 24) );
+}
+
+/* Fetch texel from 1D, 2D or 3D argb8888 texture, return 4 GLfloats */
+static void FETCH(f_argb8888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *UINT_ADDR( texImage, i, j, k );
+ texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+ texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
+ texel[BCOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
+ texel[ACOMP] = UBYTE_TO_FLOAT( (s >> 24) );
+}
+
+#if DIM == 3
+static void store_texel_argb8888(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = UINT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB8888_REV **************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLchans */
+static void FETCH(argb8888_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLuint s = *UINT_ADDR( texImage, i, j, k );
+ texel[RCOMP] = UBYTE_TO_CHAN( (s >> 8) & 0xff );
+ texel[GCOMP] = UBYTE_TO_CHAN( (s >> 16) & 0xff );
+ texel[BCOMP] = UBYTE_TO_CHAN( (s >> 24) );
+ texel[ACOMP] = UBYTE_TO_CHAN( (s ) & 0xff );
+}
+
+/* Fetch texel from 1D, 2D or 3D argb8888_rev texture, return 4 GLfloats */
+static void FETCH(f_argb8888_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLuint s = *UINT_ADDR( texImage, i, j, k );
+ texel[RCOMP] = UBYTE_TO_FLOAT( (s >> 8) & 0xff );
+ texel[GCOMP] = UBYTE_TO_FLOAT( (s >> 16) & 0xff );
+ texel[BCOMP] = UBYTE_TO_FLOAT( (s >> 24) );
+ texel[ACOMP] = UBYTE_TO_FLOAT( (s ) & 0xff );
+}
+
+#if DIM == 3
+static void store_texel_argb8888_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLuint *dst = UINT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_8888(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RGB888 ********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLchans */
+static void FETCH(rgb888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 3 );
+ texel[RCOMP] = UBYTE_TO_CHAN( src[2] );
+ texel[GCOMP] = UBYTE_TO_CHAN( src[1] );
+ texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch texel from 1D, 2D or 3D rgb888 texture, return 4 GLfloats */
+static void FETCH(f_rgb888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 3 );
+ texel[RCOMP] = UBYTE_TO_FLOAT( src[2] );
+ texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
+ texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb888(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = UBYTE_ADDR(texImage, i, j, k, 3);
+ dst[0] = rgba[RCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[BCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_BGR888 ********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLchans */
+static void FETCH(bgr888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 3 );
+ texel[RCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[GCOMP] = UBYTE_TO_CHAN( src[1] );
+ texel[BCOMP] = UBYTE_TO_CHAN( src[2] );
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch texel from 1D, 2D or 3D bgr888 texture, return 4 GLfloats */
+static void FETCH(f_bgr888)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 3 );
+ texel[RCOMP] = UBYTE_TO_FLOAT( src[0] );
+ texel[GCOMP] = UBYTE_TO_FLOAT( src[1] );
+ texel[BCOMP] = UBYTE_TO_FLOAT( src[2] );
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_bgr888(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = UBYTE_ADDR(texImage, i, j, k, 3);
+ dst[0] = rgba[BCOMP];
+ dst[1] = rgba[GCOMP];
+ dst[2] = rgba[RCOMP];
+}
+#endif
+
+
+/* use color expansion like (g << 2) | (g >> 4) (does somewhat random rounding)
+ instead of slow (g << 2) * 255 / 252 (always rounds down) */
+
+/* MESA_FORMAT_RGB565 ********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLchans */
+static void FETCH(rgb565)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
+ const GLushort s = *src;
+ texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) );
+ texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) | ((s >> 9) & 0x3) );
+ texel[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) );
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch texel from 1D, 2D or 3D rgb565 texture, return 4 GLfloats */
+static void FETCH(f_rgb565)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
+ const GLushort s = *src;
+ texel[RCOMP] = ((s >> 8) & 0xf8) * (1.0F / 248.0F);
+ texel[GCOMP] = ((s >> 3) & 0xfc) * (1.0F / 252.0F);
+ texel[BCOMP] = ((s << 3) & 0xf8) * (1.0F / 248.0F);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb565(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_565(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RGB565_REV ****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLchans */
+static void FETCH(rgb565_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
+ const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */
+ texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) | ((s >> 13) & 0x7) );
+ texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) | ((s >> 9) & 0x3) );
+ texel[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) );
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch texel from 1D, 2D or 3D rgb565_rev texture, return 4 GLfloats */
+static void FETCH(f_rgb565_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
+ const GLushort s = (*src >> 8) | (*src << 8); /* byte swap */
+ texel[RCOMP] = ((s >> 8) & 0xf8) * (1.0F / 248.0F);
+ texel[GCOMP] = ((s >> 3) & 0xfc) * (1.0F / 252.0F);
+ texel[BCOMP] = ((s << 3) & 0xf8) * (1.0F / 248.0F);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb565_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_565(rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB4444 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb444 texture, return 4 GLchans */
+static void FETCH(argb4444)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
+ const GLushort s = *src;
+ texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) | ((s >> 4) & 0xf0) );
+ texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) | ((s ) & 0xf0) );
+ texel[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) | ((s << 4) & 0xf0) );
+ texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) | ((s >> 8) & 0xf0) );
+}
+
+/* Fetch texel from 1D, 2D or 3D argb4444 texture, return 4 GLfloats */
+static void FETCH(f_argb4444)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
+ const GLushort s = *src;
+ texel[RCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F);
+ texel[GCOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F);
+ texel[BCOMP] = ((s ) & 0xf) * (1.0F / 15.0F);
+ texel[ACOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
+}
+
+#if DIM == 3
+static void store_texel_argb4444(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_4444(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB4444_REV **************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLchans */
+static void FETCH(argb4444_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLushort s = *USHORT_ADDR( texImage, i, j, k );
+ texel[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) | ((s << 4) & 0xf0) );
+ texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) | ((s >> 8) & 0xf0) );
+ texel[BCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) | ((s >> 4) & 0xf0) );
+ texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) | ((s ) & 0xf0) );
+}
+
+/* Fetch texel from 1D, 2D or 3D argb4444_rev texture, return 4 GLfloats */
+static void FETCH(f_argb4444_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort s = *USHORT_ADDR( texImage, i, j, k );
+ texel[RCOMP] = ((s ) & 0xf) * (1.0F / 15.0F);
+ texel[GCOMP] = ((s >> 12) & 0xf) * (1.0F / 15.0F);
+ texel[BCOMP] = ((s >> 8) & 0xf) * (1.0F / 15.0F);
+ texel[ACOMP] = ((s >> 4) & 0xf) * (1.0F / 15.0F);
+}
+
+#if DIM == 3
+static void store_texel_argb4444_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_4444(rgba[ACOMP], rgba[BCOMP], rgba[GCOMP], rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB1555 ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLchans */
+static void FETCH(argb1555)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
+ const GLushort s = *src;
+ texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 7) & 0xf8) | ((s >> 12) & 0x7) );
+ texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 2) & 0xf8) | ((s >> 7) & 0x7) );
+ texel[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) );
+ texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 );
+}
+
+/* Fetch texel from 1D, 2D or 3D argb1555 texture, return 4 GLfloats */
+static void FETCH(f_argb1555)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
+ const GLushort s = *src;
+ texel[RCOMP] = ((s >> 10) & 0x1f) * (1.0F / 31.0F);
+ texel[GCOMP] = ((s >> 5) & 0x1f) * (1.0F / 31.0F);
+ texel[BCOMP] = ((s ) & 0x1f) * (1.0F / 31.0F);
+ texel[ACOMP] = ((s >> 15) & 0x01);
+}
+
+#if DIM == 3
+static void store_texel_argb1555(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_1555(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_ARGB1555_REV **************************************************/
+
+/* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLchans */
+static void FETCH(argb1555_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
+ const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */
+ texel[RCOMP] = UBYTE_TO_CHAN( ((s >> 7) & 0xf8) | ((s >> 12) & 0x7) );
+ texel[GCOMP] = UBYTE_TO_CHAN( ((s >> 2) & 0xf8) | ((s >> 7) & 0x7) );
+ texel[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) | ((s >> 2) & 0x7) );
+ texel[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 );
+}
+
+/* Fetch texel from 1D, 2D or 3D argb1555_rev texture, return 4 GLfloats */
+static void FETCH(f_argb1555_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src = USHORT_ADDR( texImage, i, j, k );
+ const GLushort s = (*src << 8) | (*src >> 8); /* byteswap */
+ texel[RCOMP] = ((s >> 10) & 0x1f) * (1.0F / 31.0F);
+ texel[GCOMP] = ((s >> 5) & 0x1f) * (1.0F / 31.0F);
+ texel[BCOMP] = ((s ) & 0x1f) * (1.0F / 31.0F);
+ texel[ACOMP] = ((s >> 15) & 0x01);
+}
+
+#if DIM == 3
+static void store_texel_argb1555_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_1555_REV(rgba[ACOMP], rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_AL88 **********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLchans */
+static void FETCH(al88)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLushort s = *USHORT_ADDR( texImage, i, j, k );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = UBYTE_TO_CHAN( s & 0xff );
+ texel[ACOMP] = UBYTE_TO_CHAN( s >> 8 );
+}
+
+/* Fetch texel from 1D, 2D or 3D al88 texture, return 4 GLfloats */
+static void FETCH(f_al88)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort s = *USHORT_ADDR( texImage, i, j, k );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = UBYTE_TO_FLOAT( s & 0xff );
+ texel[ACOMP] = UBYTE_TO_FLOAT( s >> 8 );
+}
+
+#if DIM == 3
+static void store_texel_al88(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_88(rgba[ACOMP], rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_AL88_REV ******************************************************/
+
+/* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLchans */
+static void FETCH(al88_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLushort s = *USHORT_ADDR( texImage, i, j, k );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = UBYTE_TO_CHAN( s >> 8 );
+ texel[ACOMP] = UBYTE_TO_CHAN( s & 0xff );
+}
+
+/* Fetch texel from 1D, 2D or 3D al88_rev texture, return 4 GLfloats */
+static void FETCH(f_al88_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort s = *USHORT_ADDR( texImage, i, j, k );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = UBYTE_TO_FLOAT( s >> 8 );
+ texel[ACOMP] = UBYTE_TO_FLOAT( s & 0xff );
+}
+
+#if DIM == 3
+static void store_texel_al88_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLushort *dst = USHORT_ADDR(texImage, i, j, k);
+ *dst = PACK_COLOR_88(rgba[RCOMP], rgba[ACOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_RGB332 ********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */
+static void FETCH(rgb332)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ static const GLubyte lut2to8[4] = {0, 85, 170, 255};
+ static const GLubyte lut3to8[8] = {0, 36, 73, 109, 146, 182, 219, 255};
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
+ const GLubyte s = *src;
+ texel[RCOMP] = UBYTE_TO_CHAN( lut3to8[(s >> 5) & 0x7] );
+ texel[GCOMP] = UBYTE_TO_CHAN( lut3to8[(s >> 2) & 0x7] );
+ texel[BCOMP] = UBYTE_TO_CHAN( lut2to8[(s ) & 0x3] );
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLfloats */
+static void FETCH(f_rgb332)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
+ const GLubyte s = *src;
+ texel[RCOMP] = ((s ) & 0xe0) * (1.0F / 224.0F);
+ texel[GCOMP] = ((s << 3) & 0xe0) * (1.0F / 224.0F);
+ texel[BCOMP] = ((s << 6) & 0xc0) * (1.0F / 192.0F);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_rgb332(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = UBYTE_ADDR(texImage, i, j, k, 1);
+ *dst = PACK_COLOR_332(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_A8 ************************************************************/
+
+/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLchans */
+static void FETCH(a8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0;
+ texel[ACOMP] = UBYTE_TO_CHAN( src[0] );
+}
+
+/* Fetch texel from 1D, 2D or 3D a8 texture, return 4 GLfloats */
+static void FETCH(f_a8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0.0;
+ texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
+}
+
+#if DIM == 3
+static void store_texel_a8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = UBYTE_ADDR(texImage, i, j, k, 1);
+ *dst = rgba[ACOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_L8 ************************************************************/
+
+/* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLchans */
+static void FETCH(l8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = UBYTE_TO_CHAN( src[0] );
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch texel from 1D, 2D or 3D l8 texture, return 4 GLfloats */
+static void FETCH(f_l8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = UBYTE_TO_FLOAT( src[0] );
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_l8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = UBYTE_ADDR(texImage, i, j, k, 1);
+ *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_I8 ************************************************************/
+
+/* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLchans */
+static void FETCH(i8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = UBYTE_TO_CHAN( src[0] );
+}
+
+/* Fetch texel from 1D, 2D or 3D i8 texture, return 4 GLfloats */
+static void FETCH(f_i8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = UBYTE_TO_FLOAT( src[0] );
+}
+
+#if DIM == 3
+static void store_texel_i8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *rgba = (const GLubyte *) texel;
+ GLubyte *dst = UBYTE_ADDR(texImage, i, j, k, 1);
+ *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_CI8 ***********************************************************/
+
+/* Fetch CI texel from 1D, 2D or 3D ci8 texture, lookup the index in a
+ * color table, and return 4 GLchans.
+ */
+static void FETCH(ci8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLubyte *src = UBYTE_ADDR( texImage, i, j, k, 1 );
+ const struct gl_color_table *palette;
+ const GLchan *table;
+ GLuint index;
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->Texture.SharedPalette) {
+ palette = &ctx->Texture.Palette;
+ }
+ else {
+ palette = &texImage->TexObject->Palette;
+ }
+ if (palette->Size == 0)
+ return; /* undefined results */
+ ASSERT(palette->Type != GL_FLOAT);
+ table = (const GLchan *) palette->Table;
+
+ /* Mask the index against size of palette to avoid going out of bounds */
+ index = (*src) & (palette->Size - 1);
+
+ switch (palette->Format) {
+ case GL_ALPHA:
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = 0;
+ texel[ACOMP] = table[index];
+ return;
+ case GL_LUMINANCE:
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = table[index];
+ texel[ACOMP] = CHAN_MAX;
+ break;
+ case GL_INTENSITY:
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] =
+ texel[ACOMP] = table[index];
+ return;
+ case GL_LUMINANCE_ALPHA:
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = table[index * 2 + 0];
+ texel[ACOMP] = table[index * 2 + 1];
+ return;
+ case GL_RGB:
+ texel[RCOMP] = table[index * 3 + 0];
+ texel[GCOMP] = table[index * 3 + 1];
+ texel[BCOMP] = table[index * 3 + 2];
+ texel[ACOMP] = CHAN_MAX;
+ return;
+ case GL_RGBA:
+ texel[RCOMP] = table[index * 4 + 0];
+ texel[GCOMP] = table[index * 4 + 1];
+ texel[BCOMP] = table[index * 4 + 2];
+ texel[ACOMP] = table[index * 4 + 3];
+ return;
+ default:
+ _mesa_problem(ctx, "Bad palette format in palette_sample");
+ }
+}
+
+
+/* Fetch CI texel from 1D, 2D or 3D ci8 texture, lookup the index in a
+ * color table, and return 4 GLfloats.
+ */
+static void FETCH(f_ci8)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ GLchan rgba[4];
+ /* Sample as GLchan */
+ FETCH(ci8)(texImage, i, j, k, rgba);
+ /* and return as floats */
+ texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
+ texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
+ texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
+ texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
+}
+
+#if DIM == 3
+static void store_texel_ci8(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ const GLubyte *index = (const GLubyte *) texel;
+ GLubyte *dst = UBYTE_ADDR(texImage, i, j, k, 1);
+ *dst = *index;
+}
+#endif
+
+
+/* MESA_FORMAT_YCBCR *********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLchans */
+/* We convert YCbCr to RGB here */
+/* XXX this may break if GLchan != GLubyte */
+static void FETCH(ycbcr)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLushort *src0 = USHORT_ADDR( texImage, (i & ~1), j, k ); /* even */
+ const GLushort *src1 = src0 + 1; /* odd */
+ const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */
+ const GLubyte cb = *src0 & 0xff; /* chroma U */
+ const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */
+ const GLubyte cr = *src1 & 0xff; /* chroma V */
+ GLint r, g, b;
+ if (i & 1) {
+ /* odd pixel: use y1,cr,cb */
+ r = (GLint) (1.164 * (y1-16) + 1.596 * (cr-128));
+ g = (GLint) (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
+ b = (GLint) (1.164 * (y1-16) + 2.018 * (cb-128));
+ }
+ else {
+ /* even pixel: use y0,cr,cb */
+ r = (GLint) (1.164 * (y0-16) + 1.596 * (cr-128));
+ g = (GLint) (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
+ b = (GLint) (1.164 * (y0-16) + 2.018 * (cb-128));
+ }
+ texel[RCOMP] = CLAMP(r, 0, CHAN_MAX);
+ texel[GCOMP] = CLAMP(g, 0, CHAN_MAX);
+ texel[BCOMP] = CLAMP(b, 0, CHAN_MAX);
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLfloats */
+/* We convert YCbCr to RGB here */
+static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src0 = USHORT_ADDR( texImage, (i & ~1), j, k ); /* even */
+ const GLushort *src1 = src0 + 1; /* odd */
+ const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */
+ const GLubyte cb = *src0 & 0xff; /* chroma U */
+ const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */
+ const GLubyte cr = *src1 & 0xff; /* chroma V */
+ GLfloat r, g, b;
+ if (i & 1) {
+ /* odd pixel: use y1,cr,cb */
+ r = (1.164 * (y1-16) + 1.596 * (cr-128));
+ g = (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
+ b = (1.164 * (y1-16) + 2.018 * (cb-128));
+ }
+ else {
+ /* even pixel: use y0,cr,cb */
+ r = (1.164 * (y0-16) + 1.596 * (cr-128));
+ g = (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
+ b = (1.164 * (y0-16) + 2.018 * (cb-128));
+ }
+ /* XXX remove / 255 here by tweaking arithmetic above */
+ r /= 255.0;
+ g /= 255.0;
+ b /= 255.0;
+ /* XXX should we really clamp??? */
+ texel[RCOMP] = CLAMP(r, 0.0, 1.0);
+ texel[GCOMP] = CLAMP(g, 0.0, 1.0);
+ texel[BCOMP] = CLAMP(b, 0.0, 1.0);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_ycbcr(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ /* XXX to do */
+}
+#endif
+
+
+/* MESA_FORMAT_YCBCR_REV *****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLchans */
+/* We convert YCbCr to RGB here */
+/* XXX this may break if GLchan != GLubyte */
+static void FETCH(ycbcr_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLchan *texel )
+{
+ const GLushort *src0 = USHORT_ADDR( texImage, (i & ~1), j, k ); /* even */
+ const GLushort *src1 = src0 + 1; /* odd */
+ const GLubyte y0 = *src0 & 0xff; /* luminance */
+ const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */
+ const GLubyte y1 = *src1 & 0xff; /* luminance */
+ const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */
+ GLint r, g, b;
+ if (i & 1) {
+ /* odd pixel: use y1,cr,cb */
+ r = (GLint) (1.164 * (y1-16) + 1.596 * (cr-128));
+ g = (GLint) (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
+ b = (GLint) (1.164 * (y1-16) + 2.018 * (cb-128));
+ }
+ else {
+ /* even pixel: use y0,cr,cb */
+ r = (GLint) (1.164 * (y0-16) + 1.596 * (cr-128));
+ g = (GLint) (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
+ b = (GLint) (1.164 * (y0-16) + 2.018 * (cb-128));
+ }
+ texel[RCOMP] = CLAMP(r, 0, CHAN_MAX);
+ texel[GCOMP] = CLAMP(g, 0, CHAN_MAX);
+ texel[BCOMP] = CLAMP(b, 0, CHAN_MAX);
+ texel[ACOMP] = CHAN_MAX;
+}
+
+/* Fetch texel from 1D, 2D or 3D ycbcr_rev texture, return 4 GLfloats */
+/* We convert YCbCr to RGB here */
+static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel )
+{
+ const GLushort *src0 = USHORT_ADDR( texImage, (i & ~1), j, k ); /* even */
+ const GLushort *src1 = src0 + 1; /* odd */
+ const GLubyte y0 = *src0 & 0xff; /* luminance */
+ const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */
+ const GLubyte y1 = *src1 & 0xff; /* luminance */
+ const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */
+ GLfloat r, g, b;
+ if (i & 1) {
+ /* odd pixel: use y1,cr,cb */
+ r = (1.164 * (y1-16) + 1.596 * (cr-128));
+ g = (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
+ b = (1.164 * (y1-16) + 2.018 * (cb-128));
+ }
+ else {
+ /* even pixel: use y0,cr,cb */
+ r = (1.164 * (y0-16) + 1.596 * (cr-128));
+ g = (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
+ b = (1.164 * (y0-16) + 2.018 * (cb-128));
+ }
+ /* XXX remove / 255 here by tweaking arithmetic above */
+ r /= 255.0;
+ g /= 255.0;
+ b /= 255.0;
+ /* XXX should we really clamp??? */
+ texel[RCOMP] = CLAMP(r, 0.0, 1.0);
+ texel[GCOMP] = CLAMP(g, 0.0, 1.0);
+ texel[BCOMP] = CLAMP(b, 0.0, 1.0);
+ texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_ycbcr_rev(struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, const void *texel)
+{
+ /* XXX to do */
+}
+#endif
+
+
+
+#undef CHAN_ADDR
+#undef UBYTE_ADDR
+#undef USHORT_ADDR
+#undef UINT_ADDR
+#undef FLOAT_ADDR
+#undef HALF_ADDR
+#undef FETCH
+#undef DIM
diff --git a/nx-X11/extras/Mesa/src/mesa/main/teximage.c b/nx-X11/extras/Mesa/src/mesa/main/teximage.c
new file mode 100644
index 000000000..d4d023acd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/teximage.c
@@ -0,0 +1,3330 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file teximage.c
+ * Texture images manipulation functions.
+ *
+ * \note Mesa's native texture data type is GLchan. Native formats are
+ * GL_ALPHA, GL_LUMINANCE, GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, GL_RGBA, and
+ * GL_COLOR_INDEX.
+ *
+ * \note Device drivers are free to implement any internal format they want.
+ */
+
+
+#include "glheader.h"
+#include "bufferobj.h"
+#include "context.h"
+#include "convolve.h"
+#include "image.h"
+#include "imports.h"
+#include "macros.h"
+#include "state.h"
+#include "texcompress.h"
+#include "texformat.h"
+#include "teximage.h"
+#include "texstate.h"
+#include "texstore.h"
+#include "mtypes.h"
+
+
+/**
+ * We allocate texture memory on 512-byte boundaries so we can use MMX/SSE
+ * elsewhere.
+ */
+void *
+_mesa_alloc_texmemory(GLsizei bytes)
+{
+ return _mesa_align_malloc(bytes, 512);
+}
+
+
+/**
+ * Free texture memory allocated with _mesa_alloc_texmemory()
+ */
+void
+_mesa_free_texmemory(void *m)
+{
+ _mesa_align_free(m);
+}
+
+
+
+
+#if 0
+static void PrintTexture(GLcontext *ctx, const struct gl_texture_image *img)
+{
+#if CHAN_TYPE == GL_FLOAT
+ _mesa_problem(NULL, "PrintTexture doesn't support float channels");
+#else
+ GLuint i, j, c;
+ const GLchan *data = (const GLchan *) img->Data;
+
+ if (!data) {
+ _mesa_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:
+ _mesa_problem(NULL, "error in PrintTexture\n");
+ return;
+ }
+
+ for (i = 0; i < img->Height; i++) {
+ for (j = 0; j < img->Width; j++) {
+ if (c==1)
+ _mesa_printf("%02x ", data[0]);
+ else if (c==2)
+ _mesa_printf("%02x%02x ", data[0], data[1]);
+ else if (c==3)
+ _mesa_printf("%02x%02x%02x ", data[0], data[1], data[2]);
+ else if (c==4)
+ _mesa_printf("%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]);
+ data += (img->RowStride - img->Width) * c;
+ }
+ _mesa_printf("\n");
+ }
+#endif
+}
+#endif
+
+
+/*
+ * Compute floor(log_base_2(n)).
+ * If n < 0 return -1.
+ */
+static int
+logbase2( int n )
+{
+ GLint i = 1;
+ GLint log2 = 0;
+
+ if (n < 0)
+ return -1;
+
+ if (n == 0)
+ return 0;
+
+ while ( n > i ) {
+ i *= 2;
+ log2++;
+ }
+ if (i != n) {
+ return log2 - 1;
+ }
+ else {
+ return log2;
+ }
+}
+
+
+
+/**
+ * Return the simple base format for a given internal texture format.
+ * For example, given GL_LUMINANCE12_ALPHA4, return GL_LUMINANCE_ALPHA.
+ *
+ * \param ctx GL context.
+ * \param internalFormat the internal texture format token or 1, 2, 3, or 4.
+ *
+ * \return the corresponding \u base internal format (GL_ALPHA, GL_LUMINANCE,
+ * GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA), or -1 if invalid enum.
+ *
+ * This is the format which is used during texture application (i.e. the
+ * texture format and env mode determine the arithmetic used.
+ */
+GLint
+_mesa_base_tex_format( GLcontext *ctx, GLint internalFormat )
+{
+ switch (internalFormat) {
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ 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:
+ 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 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:
+ 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:
+ ; /* fallthrough */
+ }
+
+ if (ctx->Extensions.EXT_paletted_texture) {
+ switch (internalFormat) {
+ 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:
+ return GL_COLOR_INDEX;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.SGIX_depth_texture ||
+ ctx->Extensions.ARB_depth_texture) {
+ switch (internalFormat) {
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT16_SGIX:
+ case GL_DEPTH_COMPONENT24_SGIX:
+ case GL_DEPTH_COMPONENT32_SGIX:
+ return GL_DEPTH_COMPONENT;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.ARB_texture_compression) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_ALPHA:
+ return GL_ALPHA;
+ case GL_COMPRESSED_LUMINANCE:
+ return GL_LUMINANCE;
+ case GL_COMPRESSED_LUMINANCE_ALPHA:
+ return GL_LUMINANCE_ALPHA;
+ case GL_COMPRESSED_INTENSITY:
+ return GL_INTENSITY;
+ case GL_COMPRESSED_RGB:
+ return GL_RGB;
+ case GL_COMPRESSED_RGBA:
+ return GL_RGBA;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.TDFX_texture_compression_FXT1) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ return GL_RGB;
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ return GL_RGBA;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.EXT_texture_compression_s3tc) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
+ return GL_RGB;
+ case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
+ return GL_RGBA;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.S3_s3tc) {
+ switch (internalFormat) {
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ return GL_RGB;
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ return GL_RGBA;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.MESA_ycbcr_texture) {
+ if (internalFormat == GL_YCBCR_MESA)
+ return GL_YCBCR_MESA;
+ }
+
+ if (ctx->Extensions.ARB_texture_float) {
+ switch (internalFormat) {
+ case GL_ALPHA16F_ARB:
+ case GL_ALPHA32F_ARB:
+ return GL_ALPHA;
+ case GL_RGBA16F_ARB:
+ case GL_RGBA32F_ARB:
+ return GL_RGBA;
+ case GL_RGB16F_ARB:
+ case GL_RGB32F_ARB:
+ return GL_RGB;
+ case GL_INTENSITY16F_ARB:
+ case GL_INTENSITY32F_ARB:
+ return GL_INTENSITY;
+ case GL_LUMINANCE16F_ARB:
+ case GL_LUMINANCE32F_ARB:
+ return GL_LUMINANCE;
+ case GL_LUMINANCE_ALPHA16F_ARB:
+ case GL_LUMINANCE_ALPHA32F_ARB:
+ return GL_LUMINANCE_ALPHA;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ return -1; /* error */
+}
+
+
+/**
+ * Test if the given image format is a color/RGBA format (i.e., not color
+ * index, depth, stencil, etc).
+ * \param format the image format value (may by an internal texture format)
+ * \return GL_TRUE if its a color/RGBA format, GL_FALSE otherwise.
+ */
+static GLboolean
+is_color_format(GLenum format)
+{
+ switch (format) {
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_ALPHA4:
+ case GL_ALPHA8:
+ case GL_ALPHA12:
+ case GL_ALPHA16:
+ 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_INTENSITY:
+ case GL_INTENSITY4:
+ case GL_INTENSITY8:
+ case GL_INTENSITY12:
+ case GL_INTENSITY16:
+ case 3:
+ case GL_RGB:
+ case GL_BGR:
+ 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_ABGR_EXT:
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_RGBA2:
+ case GL_RGBA4:
+ case GL_RGB5_A1:
+ case GL_RGBA8:
+ case GL_RGB10_A2:
+ case GL_RGBA12:
+ case GL_RGBA16:
+ /* float texture formats */
+ case GL_ALPHA16F_ARB:
+ case GL_ALPHA32F_ARB:
+ case GL_LUMINANCE16F_ARB:
+ case GL_LUMINANCE32F_ARB:
+ case GL_LUMINANCE_ALPHA16F_ARB:
+ case GL_LUMINANCE_ALPHA32F_ARB:
+ case GL_INTENSITY16F_ARB:
+ case GL_INTENSITY32F_ARB:
+ case GL_RGB16F_ARB:
+ case GL_RGB32F_ARB:
+ case GL_RGBA16F_ARB:
+ case GL_RGBA32F_ARB:
+ /* compressed formats */
+ case GL_COMPRESSED_ALPHA:
+ case GL_COMPRESSED_LUMINANCE:
+ case GL_COMPRESSED_LUMINANCE_ALPHA:
+ case GL_COMPRESSED_INTENSITY:
+ case GL_COMPRESSED_RGB:
+ case GL_COMPRESSED_RGBA:
+ case GL_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ 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;
+ case GL_YCBCR_MESA: /* not considered to be RGB */
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given image format is a color index format.
+ */
+static GLboolean
+is_index_format(GLenum format)
+{
+ switch (format) {
+ 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:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given image format is a depth component format.
+ */
+static GLboolean
+is_depth_format(GLenum format)
+{
+ switch (format) {
+ case GL_DEPTH_COMPONENT16_ARB:
+ case GL_DEPTH_COMPONENT24_ARB:
+ case GL_DEPTH_COMPONENT32_ARB:
+ case GL_DEPTH_COMPONENT:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if the given image format is a YCbCr format.
+ */
+static GLboolean
+is_ycbcr_format(GLenum format)
+{
+ switch (format) {
+ case GL_YCBCR_MESA:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test if it is a supported compressed format.
+ *
+ * \param internalFormat the internal format token provided by the user.
+ *
+ * \ret GL_TRUE if \p internalFormat is a supported compressed format, or
+ * GL_FALSE otherwise.
+ *
+ * Currently only GL_COMPRESSED_RGB_FXT1_3DFX and GL_COMPRESSED_RGBA_FXT1_3DFX
+ * are supported.
+ */
+static GLboolean
+is_compressed_format(GLcontext *ctx, GLenum internalFormat)
+{
+ (void) ctx;
+ switch (internalFormat) {
+ case GL_COMPRESSED_RGB_FXT1_3DFX:
+ case GL_COMPRESSED_RGBA_FXT1_3DFX:
+ 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_RGB_S3TC:
+ case GL_RGB4_S3TC:
+ case GL_RGBA_S3TC:
+ case GL_RGBA4_S3TC:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Store a gl_texture_image pointer in a gl_texture_object structure
+ * according to the target and level parameters.
+ *
+ * \param tObj texture object.
+ * \param target texture target.
+ * \param level image level.
+ * \param texImage texture image.
+ *
+ * This was basically prompted by the introduction of cube maps.
+ */
+void
+_mesa_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_1D:
+ case GL_TEXTURE_2D:
+ case GL_TEXTURE_3D:
+ tObj->Image[0][level] = texImage;
+ break;
+ 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:
+ {
+ GLuint face = ((GLuint) target -
+ (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X);
+ tObj->Image[face][level] = texImage;
+ }
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ ASSERT(level == 0);
+ tObj->Image[0][level] = texImage;
+ break;
+ default:
+ _mesa_problem(NULL, "bad target in _mesa_set_tex_image()");
+ return;
+ }
+ /* Set the 'back' pointer */
+ texImage->TexObject = tObj;
+}
+
+
+/**
+ * Allocate a texture image structure.
+ *
+ * Called via ctx->Driver.NewTextureImage() unless overriden by a device
+ * driver.
+ *
+ * \return a pointer to gl_texture_image struct with all fields initialized to
+ * zero.
+ */
+struct gl_texture_image *
+_mesa_new_texture_image( GLcontext *ctx )
+{
+ (void) ctx;
+ return CALLOC_STRUCT(gl_texture_image);
+}
+
+
+/**
+ * Free texture image data.
+ * This function is a fallback called via ctx->Driver.FreeTexImageData().
+ *
+ * \param teximage texture image.
+ *
+ * Free the texture image data if it's not marked as client data.
+ */
+void
+_mesa_free_texture_image_data(GLcontext *ctx,
+ struct gl_texture_image *texImage)
+{
+ if (texImage->Data && !texImage->IsClientData) {
+ /* free the old texture data */
+ _mesa_free_texmemory(texImage->Data);
+ }
+
+ texImage->Data = NULL;
+}
+
+
+/**
+ * Free texture image.
+ *
+ * \param teximage texture image.
+ *
+ * Free the texture image structure and the associated image data.
+ */
+void
+_mesa_delete_texture_image( GLcontext *ctx, struct gl_texture_image *texImage )
+{
+ if (texImage->Data) {
+ ctx->Driver.FreeTexImageData( ctx, texImage );
+ }
+ ASSERT(texImage->Data == NULL);
+ FREE( texImage );
+}
+
+
+/**
+ * Test if a target is a proxy target.
+ *
+ * \param target texture target.
+ *
+ * \return GL_TRUE if the target is a proxy target, GL_FALSE otherwise.
+ */
+static GLboolean
+is_proxy_target(GLenum target)
+{
+ return (target == GL_PROXY_TEXTURE_1D ||
+ target == GL_PROXY_TEXTURE_2D ||
+ target == GL_PROXY_TEXTURE_3D ||
+ target == GL_PROXY_TEXTURE_CUBE_MAP_ARB ||
+ target == GL_PROXY_TEXTURE_RECTANGLE_NV);
+}
+
+
+/**
+ * Get the texture object that corresponds to the target of the given texture unit.
+ *
+ * \param ctx GL context.
+ * \param texUnit texture unit.
+ * \param target texture target.
+ *
+ * \return pointer to the texture object on success, or NULL on failure.
+ *
+ * \sa gl_texture_unit.
+ */
+struct gl_texture_object *
+_mesa_select_tex_object(GLcontext *ctx, const struct gl_texture_unit *texUnit,
+ GLenum target)
+{
+ switch (target) {
+ case GL_TEXTURE_1D:
+ return texUnit->Current1D;
+ case GL_PROXY_TEXTURE_1D:
+ return ctx->Texture.Proxy1D;
+ case GL_TEXTURE_2D:
+ return texUnit->Current2D;
+ case GL_PROXY_TEXTURE_2D:
+ return ctx->Texture.Proxy2D;
+ case GL_TEXTURE_3D:
+ return texUnit->Current3D;
+ 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:
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ return ctx->Extensions.ARB_texture_cube_map
+ ? texUnit->CurrentCubeMap : NULL;
+ case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
+ return ctx->Extensions.ARB_texture_cube_map
+ ? ctx->Texture.ProxyCubeMap : NULL;
+ case GL_TEXTURE_RECTANGLE_NV:
+ return ctx->Extensions.NV_texture_rectangle
+ ? texUnit->CurrentRect : NULL;
+ case GL_PROXY_TEXTURE_RECTANGLE_NV:
+ return ctx->Extensions.NV_texture_rectangle
+ ? ctx->Texture.ProxyRect : NULL;
+ default:
+ _mesa_problem(NULL, "bad target in _mesa_select_tex_object()");
+ return NULL;
+ }
+}
+
+
+/**
+ * Get the texture image struct which corresponds to target and level
+ * of the given texture unit.
+ *
+ * \param ctx GL context.
+ * \param texUnit texture unit.
+ * \param target texture target.
+ * \param level image level.
+ *
+ * \return pointer to the texture image structure on success, or NULL on failure.
+ *
+ * \sa gl_texture_unit.
+ */
+struct gl_texture_image *
+_mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit,
+ GLenum target, GLint level)
+{
+ ASSERT(texUnit);
+ ASSERT(level < MAX_TEXTURE_LEVELS);
+ switch (target) {
+ case GL_TEXTURE_1D:
+ return texUnit->Current1D->Image[0][level];
+ case GL_PROXY_TEXTURE_1D:
+ return ctx->Texture.Proxy1D->Image[0][level];
+ case GL_TEXTURE_2D:
+ return texUnit->Current2D->Image[0][level];
+ case GL_PROXY_TEXTURE_2D:
+ return ctx->Texture.Proxy2D->Image[0][level];
+ case GL_TEXTURE_3D:
+ return texUnit->Current3D->Image[0][level];
+ case GL_PROXY_TEXTURE_3D:
+ return ctx->Texture.Proxy3D->Image[0][level];
+ 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:
+ if (ctx->Extensions.ARB_texture_cube_map) {
+ GLuint face = ((GLuint) target -
+ (GLuint) GL_TEXTURE_CUBE_MAP_POSITIVE_X);
+ return texUnit->CurrentCubeMap->Image[face][level];
+ }
+ else
+ return NULL;
+ case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
+ if (ctx->Extensions.ARB_texture_cube_map)
+ return ctx->Texture.ProxyCubeMap->Image[0][level];
+ else
+ return NULL;
+ case GL_TEXTURE_RECTANGLE_NV:
+ if (ctx->Extensions.NV_texture_rectangle) {
+ ASSERT(level == 0);
+ return texUnit->CurrentRect->Image[0][level];
+ }
+ else {
+ return NULL;
+ }
+ case GL_PROXY_TEXTURE_RECTANGLE_NV:
+ if (ctx->Extensions.NV_texture_rectangle) {
+ ASSERT(level == 0);
+ return ctx->Texture.ProxyRect->Image[0][level];
+ }
+ else {
+ return NULL;
+ }
+ default:
+ _mesa_problem(ctx, "bad target in _mesa_select_tex_image()");
+ return NULL;
+ }
+}
+
+
+/**
+ * Like _mesa_select_tex_image() but if the image doesn't exist, allocate
+ * it and install it. Only return NULL if passed a bad parameter or run
+ * out of memory.
+ */
+struct gl_texture_image *
+_mesa_get_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit,
+ GLenum target, GLint level)
+{
+ struct gl_texture_image *texImage;
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ if (!texImage) {
+ struct gl_texture_object *texObj;
+ texImage = ctx->Driver.NewTextureImage(ctx);
+ if (!texImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "texture image allocation");
+ return NULL;
+ }
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ ASSERT(texObj);
+ _mesa_set_tex_image(texObj, target, level, texImage);
+ }
+ return texImage;
+}
+
+
+/**
+ * Return pointer to the specified proxy texture image.
+ * Note that proxy textures are per-context, not per-texture unit.
+ * \return pointer to texture image or NULL if invalid target, invalid
+ * level, or out of memory.
+ */
+struct gl_texture_image *
+_mesa_get_proxy_tex_image(GLcontext *ctx, GLenum target, GLint level)
+{
+ struct gl_texture_image *texImage;
+
+ if (level < 0 )
+ return NULL;
+
+ switch (target) {
+ case GL_PROXY_TEXTURE_1D:
+ if (level >= ctx->Const.MaxTextureLevels)
+ return NULL;
+ texImage = ctx->Texture.Proxy1D->Image[0][level];
+ if (!texImage) {
+ texImage = ctx->Driver.NewTextureImage(ctx);
+ if (!texImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
+ return NULL;
+ }
+ ctx->Texture.Proxy1D->Image[0][level] = texImage;
+ /* Set the 'back' pointer */
+ texImage->TexObject = ctx->Texture.Proxy1D;
+ }
+ return texImage;
+ case GL_PROXY_TEXTURE_2D:
+ if (level >= ctx->Const.MaxTextureLevels)
+ return NULL;
+ texImage = ctx->Texture.Proxy2D->Image[0][level];
+ if (!texImage) {
+ texImage = ctx->Driver.NewTextureImage(ctx);
+ if (!texImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
+ return NULL;
+ }
+ ctx->Texture.Proxy2D->Image[0][level] = texImage;
+ /* Set the 'back' pointer */
+ texImage->TexObject = ctx->Texture.Proxy2D;
+ }
+ return texImage;
+ case GL_PROXY_TEXTURE_3D:
+ if (level >= ctx->Const.Max3DTextureLevels)
+ return NULL;
+ texImage = ctx->Texture.Proxy3D->Image[0][level];
+ if (!texImage) {
+ texImage = ctx->Driver.NewTextureImage(ctx);
+ if (!texImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
+ return NULL;
+ }
+ ctx->Texture.Proxy3D->Image[0][level] = texImage;
+ /* Set the 'back' pointer */
+ texImage->TexObject = ctx->Texture.Proxy3D;
+ }
+ return texImage;
+ case GL_PROXY_TEXTURE_CUBE_MAP:
+ if (level >= ctx->Const.MaxCubeTextureLevels)
+ return NULL;
+ texImage = ctx->Texture.ProxyCubeMap->Image[0][level];
+ if (!texImage) {
+ texImage = ctx->Driver.NewTextureImage(ctx);
+ if (!texImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
+ return NULL;
+ }
+ ctx->Texture.ProxyCubeMap->Image[0][level] = texImage;
+ /* Set the 'back' pointer */
+ texImage->TexObject = ctx->Texture.ProxyCubeMap;
+ }
+ return texImage;
+ case GL_PROXY_TEXTURE_RECTANGLE_NV:
+ if (level > 0)
+ return NULL;
+ texImage = ctx->Texture.ProxyRect->Image[0][level];
+ if (!texImage) {
+ texImage = ctx->Driver.NewTextureImage(ctx);
+ if (!texImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "proxy texture allocation");
+ return NULL;
+ }
+ ctx->Texture.ProxyRect->Image[0][level] = texImage;
+ /* Set the 'back' pointer */
+ texImage->TexObject = ctx->Texture.ProxyRect;
+ }
+ return texImage;
+ default:
+ return NULL;
+ }
+}
+
+
+/**
+ * Get the maximum number of allowed mipmap levels.
+ *
+ * \param ctx GL context.
+ * \param target texture target.
+ *
+ * \return the maximum number of allowed mipmap levels for the given
+ * texture target, or zero if passed a bad target.
+ *
+ * \sa gl_constants.
+ */
+GLint
+_mesa_max_texture_levels(GLcontext *ctx, GLenum target)
+{
+ switch (target) {
+ case GL_TEXTURE_1D:
+ case GL_PROXY_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_PROXY_TEXTURE_2D:
+ return ctx->Const.MaxTextureLevels;
+ case GL_TEXTURE_3D:
+ case GL_PROXY_TEXTURE_3D:
+ return ctx->Const.Max3DTextureLevels;
+ 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:
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
+ return ctx->Const.MaxCubeTextureLevels;
+ case GL_TEXTURE_RECTANGLE_NV:
+ case GL_PROXY_TEXTURE_RECTANGLE_NV:
+ return 1;
+ default:
+ return 0; /* bad target */
+ }
+}
+
+
+
+#if 000 /* not used anymore */
+/*
+ * 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.
+ */
+static GLubyte *
+make_null_texture(GLint width, GLint height, GLint depth, GLenum format)
+{
+ const GLint components = _mesa_components_in_format(format);
+ const GLint numPixels = width * height * depth;
+ GLubyte *data = (GLubyte *) MALLOC(numPixels * components * sizeof(GLubyte));
+
+#ifdef DEBUG
+ /*
+ * Let's see if anyone finds this. If glTexImage2D() is called with
+ * a NULL image pointer then load the texture image with something
+ * interesting instead of leaving it indeterminate.
+ */
+ if (data) {
+ static const char message[8][32] = {
+ " X X XXXXX XXX X ",
+ " XX XX X X X X X ",
+ " X X X X X X X ",
+ " X X XXXX XXX XXXXX ",
+ " X X X X X X ",
+ " X X X X X X X ",
+ " X X XXXXX XXX X X ",
+ " "
+ };
+
+ GLubyte *imgPtr = data;
+ GLint h, i, j, k;
+ for (h = 0; h < depth; h++) {
+ for (i = 0; i < height; i++) {
+ GLint srcRow = 7 - (i % 8);
+ for (j = 0; j < width; j++) {
+ GLint srcCol = j % 32;
+ GLubyte texel = (message[srcRow][srcCol]=='X') ? 255 : 70;
+ for (k = 0; k < components; k++) {
+ *imgPtr++ = texel;
+ }
+ }
+ }
+ }
+ }
+#endif
+
+ return data;
+}
+#endif
+
+
+
+/**
+ * Reset the fields of a gl_texture_image struct to zero.
+ *
+ * \param img texture image structure.
+ *
+ * This is called when a proxy texture test fails, we set all the
+ * image members (except DriverData) to zero.
+ * It's also used in glTexImage[123]D as a safeguard to be sure all
+ * required fields get initialized properly by the Driver.TexImage[123]D
+ * functions.
+ */
+static void
+clear_teximage_fields(struct gl_texture_image *img)
+{
+ ASSERT(img);
+ img->Format = 0;
+ img->IntFormat = 0;
+ img->Border = 0;
+ img->Width = 0;
+ img->Height = 0;
+ img->Depth = 0;
+ img->RowStride = 0;
+ img->Width2 = 0;
+ img->Height2 = 0;
+ img->Depth2 = 0;
+ img->WidthLog2 = 0;
+ img->HeightLog2 = 0;
+ img->DepthLog2 = 0;
+ img->Data = NULL;
+ img->TexFormat = &_mesa_null_texformat;
+ img->FetchTexelc = NULL;
+ img->FetchTexelf = NULL;
+ img->IsCompressed = 0;
+ img->CompressedSize = 0;
+}
+
+
+/**
+ * Initialize basic fields of the gl_texture_image struct.
+ *
+ * \param ctx GL context.
+ * \param target texture target.
+ * \param img texture image structure to be initialized.
+ * \param width image width.
+ * \param height image height.
+ * \param depth image depth.
+ * \param border image border.
+ * \param internalFormat internal format.
+ *
+ * Fills in the fields of \p img with the given information.
+ * Note: width, height and depth include the border.
+ */
+void
+_mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
+ struct gl_texture_image *img,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLint border, GLenum internalFormat)
+{
+ ASSERT(img);
+ img->Format = _mesa_base_tex_format( ctx, internalFormat );
+ ASSERT(img->Format > 0);
+ img->IntFormat = internalFormat;
+ img->Border = border;
+ img->Width = width;
+ img->Height = height;
+ img->Depth = depth;
+ img->RowStride = width;
+ 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 = width - 2 * border; /*1 << img->WidthLog2;*/
+ img->Height2 = height - 2 * border; /*1 << img->HeightLog2;*/
+ img->Depth2 = depth - 2 * border; /*1 << img->DepthLog2;*/
+ img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
+ img->IsCompressed = is_compressed_format(ctx, internalFormat);
+ if (img->IsCompressed)
+ img->CompressedSize = ctx->Driver.CompressedTextureSize(ctx, width,
+ height, depth, internalFormat);
+ else
+ img->CompressedSize = 0;
+
+ if ((width == 1 || _mesa_bitcount(width - 2 * border) == 1) &&
+ (height == 1 || _mesa_bitcount(height - 2 * border) == 1) &&
+ (depth == 1 || _mesa_bitcount(depth - 2 * border) == 1))
+ img->_IsPowerOfTwo = GL_TRUE;
+ else
+ img->_IsPowerOfTwo = GL_FALSE;
+
+ /* Compute Width/Height/DepthScale for mipmap lod computation */
+ if (target == GL_TEXTURE_RECTANGLE_NV) {
+ /* scale = 1.0 since texture coords directly map to texels */
+ img->WidthScale = 1.0;
+ img->HeightScale = 1.0;
+ img->DepthScale = 1.0;
+ }
+ else {
+ img->WidthScale = (GLfloat) img->Width;
+ img->HeightScale = (GLfloat) img->Height;
+ img->DepthScale = (GLfloat) img->Depth;
+ }
+}
+
+
+/**
+ * This is the fallback for Driver.TestProxyTexImage(). Test the texture
+ * level, width, height and depth against the ctx->Const limits for textures.
+ *
+ * A hardware driver might override this function if, for example, the
+ * max 3D texture size is 512x512x64 (i.e. not a cube).
+ *
+ * \param target one of GL_PROXY_TEXTURE_1D, GL_PROXY_TEXTURE_2D,
+ * GL_PROXY_TEXTURE_3D, GL_PROXY_TEXTURE_RECTANGLE_NV,
+ * GL_PROXY_TEXTURE_CUBE_MAP_ARB.
+ * \param level as passed to glTexImage
+ * \param internalFormat as passed to glTexImage
+ * \param format as passed to glTexImage
+ * \param type as passed to glTexImage
+ * \param width as passed to glTexImage
+ * \param height as passed to glTexImage
+ * \param depth as passed to glTexImage
+ * \param border as passed to glTexImage
+ * \return GL_TRUE if the image is acceptable, GL_FALSE if not acceptable.
+ */
+GLboolean
+_mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat, GLenum format, GLenum type,
+ GLint width, GLint height, GLint depth, GLint border)
+{
+ GLint maxSize;
+
+ (void) internalFormat;
+ (void) format;
+ (void) type;
+
+ switch (target) {
+ case GL_PROXY_TEXTURE_1D:
+ maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
+ if (width < 2 * border || width > 2 + maxSize ||
+ (!ctx->Extensions.ARB_texture_non_power_of_two &&
+ _mesa_bitcount(width - 2 * border) != 1) ||
+ level >= ctx->Const.MaxTextureLevels) {
+ /* bad width or level */
+ return GL_FALSE;
+ }
+ return GL_TRUE;
+ case GL_PROXY_TEXTURE_2D:
+ maxSize = 1 << (ctx->Const.MaxTextureLevels - 1);
+ if (width < 2 * border || width > 2 + maxSize ||
+ (!ctx->Extensions.ARB_texture_non_power_of_two &&
+ _mesa_bitcount(width - 2 * border) != 1) ||
+ height < 2 * border || height > 2 + maxSize ||
+ (!ctx->Extensions.ARB_texture_non_power_of_two &&
+ _mesa_bitcount(height - 2 * border) != 1) ||
+ level >= ctx->Const.MaxTextureLevels) {
+ /* bad width or height or level */
+ return GL_FALSE;
+ }
+ return GL_TRUE;
+ case GL_PROXY_TEXTURE_3D:
+ maxSize = 1 << (ctx->Const.Max3DTextureLevels - 1);
+ if (width < 2 * border || width > 2 + maxSize ||
+ (!ctx->Extensions.ARB_texture_non_power_of_two &&
+ _mesa_bitcount(width - 2 * border) != 1) ||
+ height < 2 * border || height > 2 + maxSize ||
+ (!ctx->Extensions.ARB_texture_non_power_of_two &&
+ _mesa_bitcount(height - 2 * border) != 1) ||
+ depth < 2 * border || depth > 2 + maxSize ||
+ (!ctx->Extensions.ARB_texture_non_power_of_two &&
+ _mesa_bitcount(depth - 2 * border) != 1) ||
+ level >= ctx->Const.Max3DTextureLevels) {
+ /* bad width or height or depth or level */
+ return GL_FALSE;
+ }
+ return GL_TRUE;
+ case GL_PROXY_TEXTURE_RECTANGLE_NV:
+ if (width < 1 || width > ctx->Const.MaxTextureRectSize ||
+ height < 1 || height > ctx->Const.MaxTextureRectSize ||
+ level != 0) {
+ /* bad width or height or level */
+ return GL_FALSE;
+ }
+ return GL_TRUE;
+ case GL_PROXY_TEXTURE_CUBE_MAP_ARB:
+ maxSize = 1 << (ctx->Const.MaxCubeTextureLevels - 1);
+ if (width < 2 * border || width > 2 + maxSize ||
+ (!ctx->Extensions.ARB_texture_non_power_of_two &&
+ _mesa_bitcount(width - 2 * border) != 1) ||
+ height < 2 * border || height > 2 + maxSize ||
+ (!ctx->Extensions.ARB_texture_non_power_of_two &&
+ _mesa_bitcount(height - 2 * border) != 1) ||
+ level >= ctx->Const.MaxCubeTextureLevels) {
+ /* bad width or height */
+ return GL_FALSE;
+ }
+ return GL_TRUE;
+ default:
+ _mesa_problem(ctx, "Invalid target in _mesa_test_proxy_teximage");
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * Test the glTexImage[123]D() parameters for errors.
+ *
+ * \param ctx GL context.
+ * \param target texture target given by the user.
+ * \param level image level given by the user.
+ * \param internalFormat internal format given by the user.
+ * \param format pixel data format given by the user.
+ * \param type pixel data type given by the user.
+ * \param dimensions texture image dimensions (must be 1, 2 or 3).
+ * \param width image width given by the user.
+ * \param height image height given by the user.
+ * \param depth image depth given by the user.
+ * \param border image border given by the user.
+ *
+ * \return GL_TRUE if an error was detected, or GL_FALSE if no errors.
+ *
+ * Verifies each of the parameters against the constants specified in
+ * __GLcontextRec::Const and the supported extensions, and according to the
+ * OpenGL specification.
+ */
+static GLboolean
+texture_error_check( GLcontext *ctx, GLenum target,
+ GLint level, GLint internalFormat,
+ GLenum format, GLenum type,
+ GLuint dimensions,
+ GLint width, GLint height,
+ GLint depth, GLint border )
+{
+ const GLboolean isProxy = is_proxy_target(target);
+ GLboolean sizeOK;
+ GLboolean colorFormat, indexFormat;
+
+ /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */
+ if (level < 0 || level >= MAX_TEXTURE_LEVELS) {
+ if (!isProxy) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexImage%dD(level=%d)", dimensions, level);
+ }
+ return GL_TRUE;
+ }
+
+ /* Check border */
+ if (border < 0 || border > 1 ||
+ ((target == GL_TEXTURE_RECTANGLE_NV ||
+ target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) {
+ if (!isProxy) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexImage%dD(border=%d)", dimensions, border);
+ }
+ return GL_TRUE;
+ }
+
+ if (width < 0 || height < 0 || depth < 0) {
+ if (!isProxy) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexImage%dD(width, height or depth < 0)", dimensions);
+ }
+ return GL_TRUE;
+ }
+
+ /* Check target and call ctx->Driver.TestProxyTexImage() to check the
+ * level, width, height and depth.
+ */
+ if (dimensions == 1) {
+ if (target == GL_PROXY_TEXTURE_1D || target == GL_TEXTURE_1D) {
+ sizeOK = ctx->Driver.TestProxyTexImage(ctx, GL_PROXY_TEXTURE_1D,
+ level, internalFormat,
+ format, type,
+ width, 1, 1, border);
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage1D(target)" );
+ return GL_TRUE;
+ }
+ }
+ else if (dimensions == 2) {
+ if (target == GL_PROXY_TEXTURE_2D || target == GL_TEXTURE_2D) {
+ sizeOK = ctx->Driver.TestProxyTexImage(ctx, GL_PROXY_TEXTURE_2D,
+ level, internalFormat,
+ format, type,
+ width, height, 1, border);
+ }
+ else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB ||
+ (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) {
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)");
+ return GL_TRUE;
+ }
+ sizeOK = (width == height) &&
+ ctx->Driver.TestProxyTexImage(ctx, GL_PROXY_TEXTURE_CUBE_MAP_ARB,
+ level, internalFormat, format, type,
+ width, height, 1, border);
+ }
+ else if (target == GL_PROXY_TEXTURE_RECTANGLE_NV ||
+ target == GL_TEXTURE_RECTANGLE_NV) {
+ if (!ctx->Extensions.NV_texture_rectangle) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)");
+ return GL_TRUE;
+ }
+ sizeOK = ctx->Driver.TestProxyTexImage(ctx,
+ GL_PROXY_TEXTURE_RECTANGLE_NV,
+ level, internalFormat,
+ format, type,
+ width, height, 1, border);
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage2D(target)");
+ return GL_TRUE;
+ }
+ }
+ else if (dimensions == 3) {
+ if (target == GL_PROXY_TEXTURE_3D || target == GL_TEXTURE_3D) {
+ sizeOK = ctx->Driver.TestProxyTexImage(ctx, GL_PROXY_TEXTURE_3D,
+ level, internalFormat,
+ format, type,
+ width, height, depth, border);
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage3D(target)" );
+ return GL_TRUE;
+ }
+ }
+ else {
+ _mesa_problem( ctx, "bad dims in texture_error_check" );
+ return GL_TRUE;
+ }
+
+ if (!sizeOK) {
+ if (!isProxy) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexImage%dD(level=%d, width=%d, height=%d, depth=%d)",
+ dimensions, level, width, height, depth);
+ }
+ return GL_TRUE;
+ }
+
+ /* Check internalFormat */
+ if (_mesa_base_tex_format(ctx, internalFormat) < 0) {
+ if (!isProxy) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexImage%dD(internalFormat=0x%x)",
+ dimensions, internalFormat);
+ }
+ return GL_TRUE;
+ }
+
+ /* Check incoming image format and type */
+ if (!_mesa_is_legal_format_and_type(ctx, 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) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTexImage%dD(format or type)", dimensions);
+ }
+ return GL_TRUE;
+ }
+
+ /* make sure internal format and format basically agree */
+ colorFormat = is_color_format(format);
+ indexFormat = is_index_format(format);
+ if ((is_color_format(internalFormat) && !colorFormat && !indexFormat) ||
+ (is_index_format(internalFormat) && !indexFormat) ||
+ (is_depth_format(internalFormat) != is_depth_format(format)) ||
+ (is_ycbcr_format(internalFormat) != is_ycbcr_format(format))) {
+ if (!isProxy)
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTexImage(internalFormat/format)");
+ return GL_TRUE;
+ }
+
+ /* additional checks for ycbcr textures */
+ if (internalFormat == GL_YCBCR_MESA) {
+ ASSERT(ctx->Extensions.MESA_ycbcr_texture);
+ if (type != GL_UNSIGNED_SHORT_8_8_MESA &&
+ type != GL_UNSIGNED_SHORT_8_8_REV_MESA) {
+ char message[100];
+ _mesa_sprintf(message,
+ "glTexImage%d(format/type YCBCR mismatch", dimensions);
+ _mesa_error(ctx, GL_INVALID_ENUM, message);
+ return GL_TRUE; /* error */
+ }
+ if (target != GL_TEXTURE_2D &&
+ target != GL_PROXY_TEXTURE_2D &&
+ target != GL_TEXTURE_RECTANGLE_NV &&
+ target != GL_PROXY_TEXTURE_RECTANGLE_NV) {
+ if (!isProxy)
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTexImage(target)");
+ return GL_TRUE;
+ }
+ if (border != 0) {
+ if (!isProxy) {
+ char message[100];
+ _mesa_sprintf(message,
+ "glTexImage%d(format=GL_YCBCR_MESA and border=%d)",
+ dimensions, border);
+ _mesa_error(ctx, GL_INVALID_VALUE, message);
+ }
+ return GL_TRUE;
+ }
+ }
+
+ /* additional checks for depth textures */
+ if (_mesa_base_tex_format(ctx, internalFormat) == GL_DEPTH_COMPONENT) {
+ /* Only 1D and 2D textures supported */
+ if (target != GL_TEXTURE_1D &&
+ target != GL_PROXY_TEXTURE_1D &&
+ target != GL_TEXTURE_2D &&
+ target != GL_PROXY_TEXTURE_2D) {
+ if (!isProxy)
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexImage(target/internalFormat)");
+ return GL_TRUE;
+ }
+ }
+
+ /* additional checks for compressed textures */
+ if (is_compressed_format(ctx, internalFormat)) {
+ if (target == GL_TEXTURE_2D || target == GL_PROXY_TEXTURE_2D) {
+ /* OK */
+ }
+ else if (ctx->Extensions.ARB_texture_cube_map &&
+ (target == GL_PROXY_TEXTURE_CUBE_MAP ||
+ (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))) {
+ /* OK */
+ }
+ else {
+ if (!isProxy) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexImage%d(target)", dimensions);
+ return GL_TRUE;
+ }
+ }
+ if (border != 0) {
+ if (!isProxy) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTexImage%D(border!=0)", dimensions);
+ }
+ return GL_TRUE;
+ }
+ }
+
+ /* if we get here, the parameters are OK */
+ return GL_FALSE;
+}
+
+
+/**
+ * Test glTexSubImage[123]D() parameters for errors.
+ *
+ * \param ctx GL context.
+ * \param dimensions texture image dimensions (must be 1, 2 or 3).
+ * \param target texture target given by the user.
+ * \param level image level given by the user.
+ * \param xoffset sub-image x offset given by the user.
+ * \param yoffset sub-image y offset given by the user.
+ * \param zoffset sub-image z offset given by the user.
+ * \param format pixel data format given by the user.
+ * \param type pixel data type given by the user.
+ * \param width image width given by the user.
+ * \param height image height given by the user.
+ * \param depth image depth given by the user.
+ *
+ * \return GL_TRUE if an error was detected, or GL_FALSE if no errors.
+ *
+ * Verifies each of the parameters against the constants specified in
+ * __GLcontextRec::Const and the supported extensions, and according to the
+ * OpenGL specification.
+ */
+static GLboolean
+subtexture_error_check( GLcontext *ctx, GLuint dimensions,
+ GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLint width, GLint height, GLint depth,
+ GLenum format, GLenum type )
+{
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ struct gl_texture_image *destTex;
+
+ /* Check target */
+ if (dimensions == 1) {
+ if (target != GL_TEXTURE_1D) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage1D(target)" );
+ return GL_TRUE;
+ }
+ }
+ else if (dimensions == 2) {
+ if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
+ target <=GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) {
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" );
+ return GL_TRUE;
+ }
+ }
+ else if (ctx->Extensions.NV_texture_rectangle &&
+ target == GL_TEXTURE_RECTANGLE_NV) {
+ if (!ctx->Extensions.NV_texture_rectangle) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" );
+ return GL_TRUE;
+ }
+ }
+ else if (target != GL_TEXTURE_2D) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" );
+ return GL_TRUE;
+ }
+ }
+ else if (dimensions == 3) {
+ if (target != GL_TEXTURE_3D) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexSubImage3D(target)" );
+ return GL_TRUE;
+ }
+ }
+ else {
+ _mesa_problem( ctx, "invalid dims in texture_error_check" );
+ return GL_TRUE;
+ }
+
+ /* Basic level check */
+ if (level < 0 || level >= MAX_TEXTURE_LEVELS) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTexSubImage2D(level=%d)", level);
+ return GL_TRUE;
+ }
+
+ if (width < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexSubImage%dD(width=%d)", dimensions, width);
+ return GL_TRUE;
+ }
+ if (height < 0 && dimensions > 1) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexSubImage%dD(height=%d)", dimensions, height);
+ return GL_TRUE;
+ }
+ if (depth < 0 && dimensions > 2) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glTexSubImage%dD(depth=%d)", dimensions, depth);
+ return GL_TRUE;
+ }
+
+ destTex = _mesa_select_tex_image(ctx, texUnit, target, level);
+
+ if (!destTex) {
+ /* undefined image level */
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glTexSubImage%dD", dimensions);
+ return GL_TRUE;
+ }
+
+ if (xoffset < -((GLint)destTex->Border)) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(xoffset)",
+ dimensions);
+ return GL_TRUE;
+ }
+ if (xoffset + width > (GLint) (destTex->Width + destTex->Border)) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(xoffset+width)",
+ dimensions);
+ return GL_TRUE;
+ }
+ if (dimensions > 1) {
+ if (yoffset < -((GLint)destTex->Border)) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(yoffset)",
+ dimensions);
+ return GL_TRUE;
+ }
+ if (yoffset + height > (GLint) (destTex->Height + destTex->Border)) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage%dD(yoffset+height)",
+ dimensions);
+ return GL_TRUE;
+ }
+ }
+ if (dimensions > 2) {
+ if (zoffset < -((GLint)destTex->Border)) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset)");
+ return GL_TRUE;
+ }
+ if (zoffset + depth > (GLint) (destTex->Depth + destTex->Border)) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glTexSubImage3D(zoffset+depth)");
+ return GL_TRUE;
+ }
+ }
+
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexSubImage%dD(format or type)", dimensions);
+ return GL_TRUE;
+ }
+
+ if (destTex->IsCompressed) {
+ const struct gl_texture_unit *texUnit;
+ const struct gl_texture_image *texImage;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+
+ if (target == GL_TEXTURE_2D || target == GL_PROXY_TEXTURE_2D) {
+ /* OK */
+ }
+ else if (ctx->Extensions.ARB_texture_cube_map &&
+ (target == GL_PROXY_TEXTURE_CUBE_MAP ||
+ (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z))) {
+ /* OK */
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexSubImage%D(target)", dimensions);
+ return GL_TRUE;
+ }
+ /* offset must be multiple of 4 */
+ if ((xoffset & 3) || (yoffset & 3)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTexSubImage%D(xoffset or yoffset)", dimensions);
+ return GL_TRUE;
+ }
+ /* size must be multiple of 4 or equal to whole texture size */
+ if ((width & 3) && (GLuint) width != texImage->Width) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTexSubImage%D(width)", dimensions);
+ return GL_TRUE;
+ }
+ if ((height & 3) && (GLuint) height != texImage->Height) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glTexSubImage%D(width)", dimensions);
+ return GL_TRUE;
+ }
+ }
+
+ return GL_FALSE;
+}
+
+
+/**
+ * Test glCopyTexImage[12]D() parameters for errors.
+ *
+ * \param ctx GL context.
+ * \param dimensions texture image dimensions (must be 1, 2 or 3).
+ * \param target texture target given by the user.
+ * \param level image level given by the user.
+ * \param internalFormat internal format given by the user.
+ * \param width image width given by the user.
+ * \param height image height given by the user.
+ * \param depth image depth given by the user.
+ * \param border texture border.
+ *
+ * \return GL_TRUE if an error was detected, or GL_FALSE if no errors.
+ *
+ * Verifies each of the parameters against the constants specified in
+ * __GLcontextRec::Const and the supported extensions, and according to the
+ * OpenGL specification.
+ */
+static GLboolean
+copytexture_error_check( GLcontext *ctx, GLuint dimensions,
+ GLenum target, GLint level, GLint internalFormat,
+ GLint width, GLint height, GLint border )
+{
+ GLenum format, type;
+ GLboolean sizeOK;
+
+ /* Basic level check (more checking in ctx->Driver.TestProxyTexImage) */
+ if (level < 0 || level >= MAX_TEXTURE_LEVELS) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexImage%dD(level=%d)", dimensions, level);
+ return GL_TRUE;
+ }
+
+ /* Check border */
+ if (border < 0 || border > 1 ||
+ ((target == GL_TEXTURE_RECTANGLE_NV ||
+ target == GL_PROXY_TEXTURE_RECTANGLE_NV) && border != 0)) {
+ return GL_TRUE;
+ }
+
+ /* The format and type aren't really significant here, but we need to pass
+ * something to TestProxyTexImage().
+ */
+ format = _mesa_base_tex_format(ctx, internalFormat);
+ type = GL_FLOAT;
+
+ /* Check target and call ctx->Driver.TestProxyTexImage() to check the
+ * level, width, height and depth.
+ */
+ if (dimensions == 1) {
+ if (target == GL_TEXTURE_1D) {
+ sizeOK = ctx->Driver.TestProxyTexImage(ctx, GL_PROXY_TEXTURE_1D,
+ level, internalFormat,
+ format, type,
+ width, 1, 1, border);
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexImage1D(target)" );
+ return GL_TRUE;
+ }
+ }
+ else if (dimensions == 2) {
+ if (target == GL_TEXTURE_2D) {
+ sizeOK = ctx->Driver.TestProxyTexImage(ctx, GL_PROXY_TEXTURE_2D,
+ level, internalFormat,
+ format, type,
+ width, height, 1, border);
+ }
+ else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) {
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" );
+ return GL_TRUE;
+ }
+ sizeOK = (width == height) &&
+ ctx->Driver.TestProxyTexImage(ctx, GL_PROXY_TEXTURE_CUBE_MAP_ARB,
+ level, internalFormat, format, type,
+ width, height, 1, border);
+ }
+ else if (target == GL_TEXTURE_RECTANGLE_NV) {
+ if (!ctx->Extensions.NV_texture_rectangle) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" );
+ return GL_TRUE;
+ }
+ sizeOK = ctx->Driver.TestProxyTexImage(ctx,
+ GL_PROXY_TEXTURE_RECTANGLE_NV,
+ level, internalFormat,
+ format, type,
+ width, height, 1, border);
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" );
+ return GL_TRUE;
+ }
+ }
+ else {
+ _mesa_problem(ctx, "invalid dimensions in copytexture_error_check");
+ return GL_TRUE;
+ }
+
+ if (!sizeOK) {
+ if (dimensions == 1) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexImage1D(width=%d)", width);
+ }
+ else {
+ ASSERT(dimensions == 2);
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexImage2D(width=%d, height=%d)", width, height);
+ }
+ return GL_TRUE;
+ }
+
+ if (_mesa_base_tex_format(ctx, internalFormat) < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexImage%dD(internalFormat)", dimensions);
+ return GL_TRUE;
+ }
+
+ if (is_compressed_format(ctx, internalFormat)) {
+ if (target != GL_TEXTURE_2D) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyTexImage%d(target)", dimensions);
+ return GL_TRUE;
+ }
+ if (border != 0) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyTexImage%D(border!=0)", dimensions);
+ return GL_TRUE;
+ }
+ }
+
+ /* if we get here, the parameters are OK */
+ return GL_FALSE;
+}
+
+
+/**
+ * Test glCopyTexImage[12]D() parameters for errors.
+ *
+ * \param ctx GL context.
+ * \param dimensions texture image dimensions (must be 1, 2 or 3).
+ * \param target texture target given by the user.
+ * \param level image level given by the user.
+ * \param xoffset sub-image x offset given by the user.
+ * \param yoffset sub-image y offset given by the user.
+ * \param zoffset sub-image z offset given by the user.
+ * \param width image width given by the user.
+ * \param height image height given by the user.
+ *
+ * \return GL_TRUE if an error was detected, or GL_FALSE if no errors.
+ *
+ * Verifies each of the parameters against the constants specified in
+ * __GLcontextRec::Const and the supported extensions, and according to the
+ * OpenGL specification.
+ */
+static GLboolean
+copytexsubimage_error_check( GLcontext *ctx, GLuint dimensions,
+ GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height )
+{
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ struct gl_texture_image *teximage;
+
+ /* Check target */
+ if (dimensions == 1) {
+ if (target != GL_TEXTURE_1D) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage1D(target)" );
+ return GL_TRUE;
+ }
+ }
+ else if (dimensions == 2) {
+ if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) {
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" );
+ return GL_TRUE;
+ }
+ }
+ else if (target == GL_TEXTURE_RECTANGLE_NV) {
+ if (!ctx->Extensions.NV_texture_rectangle) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" );
+ return GL_TRUE;
+ }
+ }
+ else if (target != GL_TEXTURE_2D) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" );
+ return GL_TRUE;
+ }
+ }
+ else if (dimensions == 3) {
+ if (target != GL_TEXTURE_3D) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage3D(target)" );
+ return GL_TRUE;
+ }
+ }
+
+ /* Check level */
+ if (level < 0 || level >= MAX_TEXTURE_LEVELS) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(level=%d)", dimensions, level);
+ return GL_TRUE;
+ }
+
+ /* Check size */
+ if (width < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(width=%d)", dimensions, width);
+ return GL_TRUE;
+ }
+ if (dimensions > 1 && height < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(height=%d)", dimensions, height);
+ return GL_TRUE;
+ }
+
+ teximage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ if (!teximage) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCopyTexSubImage%dD(undefined texture level: %d)",
+ dimensions, level);
+ return GL_TRUE;
+ }
+
+ if (xoffset < -((GLint)teximage->Border)) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(xoffset=%d)", dimensions, xoffset);
+ return GL_TRUE;
+ }
+ if (xoffset + width > (GLint) (teximage->Width + teximage->Border)) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(xoffset+width)", dimensions);
+ return GL_TRUE;
+ }
+ if (dimensions > 1) {
+ if (yoffset < -((GLint)teximage->Border)) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(yoffset=%d)", dimensions, yoffset);
+ return GL_TRUE;
+ }
+ /* NOTE: we're adding the border here, not subtracting! */
+ if (yoffset + height > (GLint) (teximage->Height + teximage->Border)) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(yoffset+height)", dimensions);
+ return GL_TRUE;
+ }
+ }
+
+ if (dimensions > 2) {
+ if (zoffset < -((GLint)teximage->Border)) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(zoffset)", dimensions);
+ return GL_TRUE;
+ }
+ if (zoffset > (GLint) (teximage->Depth + teximage->Border)) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%dD(zoffset+depth)", dimensions);
+ return GL_TRUE;
+ }
+ }
+
+ if (teximage->IsCompressed) {
+ if (target != GL_TEXTURE_2D) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyTexSubImage%d(target)", dimensions);
+ return GL_TRUE;
+ }
+ /* offset must be multiple of 4 */
+ if ((xoffset & 3) || (yoffset & 3)) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%D(xoffset or yoffset)", dimensions);
+ return GL_TRUE;
+ }
+ /* size must be multiple of 4 */
+ if ((width & 3) != 0 && (GLuint) width != teximage->Width) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%D(width)", dimensions);
+ return GL_TRUE;
+ }
+ if ((height & 3) != 0 && (GLuint) height != teximage->Height) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glCopyTexSubImage%D(height)", dimensions);
+ return GL_TRUE;
+ }
+ }
+
+ if (teximage->IntFormat == GL_YCBCR_MESA) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glCopyTexSubImage2D");
+ return GL_TRUE;
+ }
+
+ /* if we get here, the parameters are OK */
+ return GL_FALSE;
+}
+
+
+/**
+ * Get texture image. Called by glGetTexImage.
+ *
+ * \param target texture target.
+ * \param level image level.
+ * \param format pixel data format for returned image.
+ * \param type pixel data type for returned image.
+ * \param pixels returned pixel data.
+ */
+void GLAPIENTRY
+_mesa_GetTexImage( GLenum target, GLint level, GLenum format,
+ GLenum type, GLvoid *pixels )
+{
+ const struct gl_texture_unit *texUnit;
+ const struct gl_texture_object *texObj;
+ const struct gl_texture_image *texImage;
+ GLint maxLevels = 0;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ texUnit = &(ctx->Texture.Unit[ctx->Texture.CurrentUnit]);
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ if (!texObj || is_proxy_target(target)) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(target)");
+ return;
+ }
+
+ maxLevels = _mesa_max_texture_levels(ctx, target);
+ ASSERT(maxLevels > 0); /* 0 indicates bad target, caught above */
+
+ if (level < 0 || level >= maxLevels) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexImage(level)" );
+ return;
+ }
+
+ if (_mesa_sizeof_packed_type(type) <= 0) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(type)" );
+ return;
+ }
+
+ if (_mesa_components_in_format(format) <= 0 ||
+ format == GL_STENCIL_INDEX) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexImage(format)" );
+ return;
+ }
+
+ if (!ctx->Extensions.EXT_paletted_texture && is_index_format(format)) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)");
+ }
+
+ if (!ctx->Extensions.SGIX_depth_texture &&
+ !ctx->Extensions.ARB_depth_texture && is_depth_format(format)) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)");
+ }
+
+ if (!ctx->Extensions.MESA_ycbcr_texture && is_ycbcr_format(format)) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexImage(format)");
+ }
+
+ if (!pixels)
+ return;
+
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ if (!texImage) {
+ /* invalid mipmap level, not an error */
+ return;
+ }
+
+ /* Make sure the requested image format is compatible with the
+ * texture's format. We let the colorformat-indexformat go through,
+ * because the texelfetcher will dequantize to full rgba.
+ */
+ if (is_color_format(format)
+ && !is_color_format(texImage->TexFormat->BaseFormat)
+ && !is_index_format(texImage->TexFormat->BaseFormat)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)");
+ return;
+ }
+ else if (is_index_format(format)
+ && !is_index_format(texImage->TexFormat->BaseFormat)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)");
+ return;
+ }
+ else if (is_depth_format(format)
+ && !is_depth_format(texImage->TexFormat->BaseFormat)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)");
+ return;
+ }
+ else if (is_ycbcr_format(format)
+ && !is_ycbcr_format(texImage->TexFormat->BaseFormat)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetTexImage(format mismatch)");
+ return;
+ }
+
+ /* typically, this will call _mesa_get_teximage() */
+ ctx->Driver.GetTexImage(ctx, target, level, format, type, pixels,
+ texObj, texImage);
+}
+
+
+
+/*
+ * Called from the API. Note that width includes the border.
+ */
+void GLAPIENTRY
+_mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat,
+ GLsizei width, GLint border, GLenum format,
+ GLenum type, const GLvoid *pixels )
+{
+ GLsizei postConvWidth = width;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (is_color_format(internalFormat)) {
+ _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL);
+ }
+
+ if (target == GL_TEXTURE_1D) {
+ /* non-proxy target */
+ 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, postConvWidth, 1, 1, border)) {
+ return; /* error was recorded */
+ }
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ texImage = _mesa_get_tex_image(ctx, texUnit, target, level);
+
+ if (!texImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
+ return;
+ }
+ else if (texImage->Data) {
+ ctx->Driver.FreeTexImageData( ctx, texImage );
+ }
+ ASSERT(texImage->Data == NULL);
+ clear_teximage_fields(texImage); /* not really needed, but helpful */
+ _mesa_init_teximage_fields(ctx, target, texImage,
+ postConvWidth, 1, 1,
+ border, internalFormat);
+
+ if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ _mesa_update_state(ctx);
+
+ ASSERT(ctx->Driver.TexImage1D);
+
+ /* Give the texture to the driver! <pixels> may be null! */
+ (*ctx->Driver.TexImage1D)(ctx, target, level, internalFormat,
+ width, border, format, type, pixels,
+ &ctx->Unpack, texObj, texImage);
+
+ ASSERT(texImage->TexFormat);
+
+ /* If driver didn't explicitly set this, use the defaults */
+ if (!texImage->FetchTexelc)
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel1D;
+ if (!texImage->FetchTexelf)
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel1Df;
+ ASSERT(texImage->FetchTexelc);
+ ASSERT(texImage->FetchTexelf);
+
+ /* state update */
+ texObj->Complete = GL_FALSE;
+ ctx->NewState |= _NEW_TEXTURE;
+ }
+ else if (target == GL_PROXY_TEXTURE_1D) {
+ /* Proxy texture: check for errors and update proxy state */
+ struct gl_texture_image *texImage;
+ texImage = _mesa_get_proxy_tex_image(ctx, target, level);
+ if (texture_error_check(ctx, target, level, internalFormat,
+ format, type, 1, postConvWidth, 1, 1, border)) {
+ /* when error, clear all proxy texture image parameters */
+ if (texImage)
+ clear_teximage_fields(texImage);
+ }
+ else {
+ /* no error, set the tex image parameters */
+ ASSERT(texImage);
+ _mesa_init_teximage_fields(ctx, target, texImage,
+ postConvWidth, 1, 1,
+ border, internalFormat);
+ texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
+ internalFormat, format, type);
+ }
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage1D(target)" );
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat,
+ GLsizei width, GLsizei height, GLint border,
+ GLenum format, GLenum type,
+ const GLvoid *pixels )
+{
+ GLsizei postConvWidth = width, postConvHeight = height;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (is_color_format(internalFormat)) {
+ _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth,
+ &postConvHeight);
+ }
+
+ if (target == GL_TEXTURE_2D ||
+ (ctx->Extensions.ARB_texture_cube_map &&
+ target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) ||
+ (ctx->Extensions.NV_texture_rectangle &&
+ target == GL_TEXTURE_RECTANGLE_NV)) {
+ /* non-proxy target */
+ 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, postConvWidth, postConvHeight,
+ 1, border)) {
+ return; /* error was recorded */
+ }
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ texImage = _mesa_get_tex_image(ctx, texUnit, target, level);
+ if (!texImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+ else if (texImage->Data) {
+ ctx->Driver.FreeTexImageData( ctx, texImage );
+ }
+ ASSERT(texImage->Data == NULL);
+ clear_teximage_fields(texImage); /* not really needed, but helpful */
+ _mesa_init_teximage_fields(ctx, target, texImage,
+ postConvWidth, postConvHeight, 1,
+ border, internalFormat);
+
+ if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ _mesa_update_state(ctx);
+
+ ASSERT(ctx->Driver.TexImage2D);
+
+ /* Give the texture to the driver! <pixels> may be null! */
+ (*ctx->Driver.TexImage2D)(ctx, target, level, internalFormat,
+ width, height, border, format, type, pixels,
+ &ctx->Unpack, texObj, texImage);
+
+ ASSERT(texImage->TexFormat);
+
+ /* If driver didn't explicitly set these, use the defaults */
+ if (!texImage->FetchTexelc)
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel2D;
+ if (!texImage->FetchTexelf)
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df;
+ ASSERT(texImage->FetchTexelc);
+ ASSERT(texImage->FetchTexelf);
+
+ /* state update */
+ texObj->Complete = GL_FALSE;
+ ctx->NewState |= _NEW_TEXTURE;
+ }
+ else if (target == GL_PROXY_TEXTURE_2D ||
+ (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB &&
+ ctx->Extensions.ARB_texture_cube_map) ||
+ (target == GL_PROXY_TEXTURE_RECTANGLE_NV &&
+ ctx->Extensions.NV_texture_rectangle)) {
+ /* Proxy texture: check for errors and update proxy state */
+ struct gl_texture_image *texImage;
+ texImage = _mesa_get_proxy_tex_image(ctx, target, level);
+ if (texture_error_check(ctx, target, level, internalFormat,
+ format, type, 2, postConvWidth, postConvHeight,
+ 1, border)) {
+ /* when error, clear all proxy texture image parameters */
+ if (texImage)
+ clear_teximage_fields(ctx->Texture.Proxy2D->Image[0][level]);
+ }
+ else {
+ /* no error, set the tex image parameters */
+ _mesa_init_teximage_fields(ctx, target, texImage,
+ postConvWidth, postConvHeight, 1,
+ border, internalFormat);
+ texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
+ internalFormat, format, type);
+ }
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage2D(target)" );
+ return;
+ }
+}
+
+
+/*
+ * Called by the API or display list executor.
+ * Note that width and height include the border.
+ */
+void GLAPIENTRY
+_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);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (target == GL_TEXTURE_3D) {
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ /* non-proxy target */
+
+ if (texture_error_check(ctx, target, level, (GLint) internalFormat,
+ format, type, 3, width, height, depth, border)) {
+ return; /* error was recorded */
+ }
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ texImage = _mesa_get_tex_image(ctx, texUnit, target, level);
+ if (!texImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
+ return;
+ }
+ else if (texImage->Data) {
+ ctx->Driver.FreeTexImageData( ctx, texImage );
+ }
+ ASSERT(texImage->Data == NULL);
+ clear_teximage_fields(texImage); /* not really needed, but helpful */
+ _mesa_init_teximage_fields(ctx, target, texImage,
+ width, height, depth,
+ border, internalFormat);
+
+ if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ _mesa_update_state(ctx);
+
+ ASSERT(ctx->Driver.TexImage3D);
+
+ /* Give the texture to the driver! <pixels> may be null! */
+ (*ctx->Driver.TexImage3D)(ctx, target, level, internalFormat,
+ width, height, depth, border, format, type,
+ pixels, &ctx->Unpack, texObj, texImage);
+
+ ASSERT(texImage->TexFormat);
+
+ /* If driver didn't explicitly set these, use the defaults */
+ if (!texImage->FetchTexelc)
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel3D;
+ if (!texImage->FetchTexelf)
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel3Df;
+ ASSERT(texImage->FetchTexelc);
+ ASSERT(texImage->FetchTexelf);
+
+ /* state update */
+ texObj->Complete = GL_FALSE;
+ ctx->NewState |= _NEW_TEXTURE;
+ }
+ else if (target == GL_PROXY_TEXTURE_3D) {
+ /* Proxy texture: check for errors and update proxy state */
+ struct gl_texture_image *texImage;
+ texImage = _mesa_get_proxy_tex_image(ctx, target, level);
+ if (texture_error_check(ctx, target, level, internalFormat,
+ format, type, 3, width, height, depth, border)) {
+ /* when error, clear all proxy texture image parameters */
+ if (texImage)
+ clear_teximage_fields(texImage);
+ }
+ else {
+ /* no error, set the tex image parameters */
+ _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
+ border, internalFormat);
+ texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
+ internalFormat, format, type);
+ }
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexImage3D(target)" );
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_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,
+ depth, border, format, type, pixels);
+}
+
+
+
+void GLAPIENTRY
+_mesa_TexSubImage1D( GLenum target, GLint level,
+ GLint xoffset, GLsizei width,
+ GLenum format, GLenum type,
+ const GLvoid *pixels )
+{
+ GLsizei postConvWidth = width;
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ _mesa_update_state(ctx);
+
+ /* XXX should test internal format */
+ if (is_color_format(format)) {
+ _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL);
+ }
+
+ if (subtexture_error_check(ctx, 1, target, level, xoffset, 0, 0,
+ postConvWidth, 1, 1, format, type)) {
+ return; /* error was detected */
+ }
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ assert(texImage);
+
+ if (width == 0)
+ return; /* no-op, not an error */
+
+ /* If we have a border, xoffset=-1 is legal. Bias by border width */
+ xoffset += texImage->Border;
+
+ ASSERT(ctx->Driver.TexSubImage1D);
+ (*ctx->Driver.TexSubImage1D)(ctx, target, level, xoffset, width,
+ format, type, pixels, &ctx->Unpack,
+ texObj, texImage);
+ ctx->NewState |= _NEW_TEXTURE;
+}
+
+
+void GLAPIENTRY
+_mesa_TexSubImage2D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *pixels )
+{
+ GLsizei postConvWidth = width, postConvHeight = height;
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ _mesa_update_state(ctx);
+
+ /* XXX should test internal format */
+ if (is_color_format(format)) {
+ _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth,
+ &postConvHeight);
+ }
+
+ if (subtexture_error_check(ctx, 2, target, level, xoffset, yoffset, 0,
+ postConvWidth, postConvHeight, 1, format, type)) {
+ return; /* error was detected */
+ }
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ assert(texImage);
+
+ if (width == 0 || height == 0)
+ return; /* no-op, not an error */
+
+ /* If we have a border, xoffset=-1 is legal. Bias by border width */
+ xoffset += texImage->Border;
+ yoffset += texImage->Border;
+
+ ASSERT(ctx->Driver.TexSubImage2D);
+ (*ctx->Driver.TexSubImage2D)(ctx, target, level, xoffset, yoffset,
+ width, height, format, type, pixels,
+ &ctx->Unpack, texObj, texImage);
+ ctx->NewState |= _NEW_TEXTURE;
+}
+
+
+
+void GLAPIENTRY
+_mesa_TexSubImage3D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type,
+ const GLvoid *pixels )
+{
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ _mesa_update_state(ctx);
+
+ if (subtexture_error_check(ctx, 3, target, level, xoffset, yoffset, zoffset,
+ width, height, depth, format, type)) {
+ return; /* error was detected */
+ }
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ assert(texImage);
+
+ if (width == 0 || height == 0 || height == 0)
+ return; /* no-op, not an error */
+
+ /* If we have a border, xoffset=-1 is legal. Bias by border width */
+ xoffset += texImage->Border;
+ yoffset += texImage->Border;
+ zoffset += texImage->Border;
+
+ ASSERT(ctx->Driver.TexSubImage3D);
+ (*ctx->Driver.TexSubImage3D)(ctx, target, level,
+ xoffset, yoffset, zoffset,
+ width, height, depth,
+ format, type, pixels,
+ &ctx->Unpack, texObj, texImage );
+ ctx->NewState |= _NEW_TEXTURE;
+}
+
+
+
+void GLAPIENTRY
+_mesa_CopyTexImage1D( GLenum target, GLint level,
+ GLenum internalFormat,
+ GLint x, GLint y,
+ GLsizei width, GLint border )
+{
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GLsizei postConvWidth = width;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ _mesa_update_state(ctx);
+
+ if (is_color_format(internalFormat)) {
+ _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL);
+ }
+
+ if (copytexture_error_check(ctx, 1, target, level, internalFormat,
+ postConvWidth, 1, border))
+ return;
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ texImage = _mesa_get_tex_image(ctx, texUnit, target, level);
+ if (!texImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage1D");
+ return;
+ }
+ else if (texImage->Data) {
+ ctx->Driver.FreeTexImageData( ctx, texImage );
+ }
+ ASSERT(texImage->Data == NULL);
+
+ clear_teximage_fields(texImage); /* not really needed, but helpful */
+ _mesa_init_teximage_fields(ctx, target, texImage, postConvWidth, 1, 1,
+ border, internalFormat);
+
+
+ ASSERT(ctx->Driver.CopyTexImage1D);
+ (*ctx->Driver.CopyTexImage1D)(ctx, target, level, internalFormat,
+ x, y, width, border);
+
+ ASSERT(texImage->TexFormat);
+
+ /* If driver didn't explicitly set these, use the defaults */
+ if (!texImage->FetchTexelc)
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel1D;
+ if (!texImage->FetchTexelf)
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel1Df;
+ ASSERT(texImage->FetchTexelc);
+ ASSERT(texImage->FetchTexelf);
+
+ /* state update */
+ texObj->Complete = GL_FALSE;
+ ctx->NewState |= _NEW_TEXTURE;
+}
+
+
+
+void GLAPIENTRY
+_mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLint border )
+{
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GLsizei postConvWidth = width, postConvHeight = height;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ _mesa_update_state(ctx);
+
+ if (is_color_format(internalFormat)) {
+ _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth,
+ &postConvHeight);
+ }
+
+ if (copytexture_error_check(ctx, 2, target, level, internalFormat,
+ postConvWidth, postConvHeight, border))
+ return;
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ texImage = _mesa_get_tex_image(ctx, texUnit, target, level);
+ if (!texImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D");
+ return;
+ }
+ else if (texImage->Data) {
+ ctx->Driver.FreeTexImageData( ctx, texImage );
+ }
+ ASSERT(texImage->Data == NULL);
+
+ clear_teximage_fields(texImage); /* not really needed, but helpful */
+ _mesa_init_teximage_fields(ctx, target, texImage,
+ postConvWidth, postConvHeight, 1,
+ border, internalFormat);
+
+ ASSERT(ctx->Driver.CopyTexImage2D);
+ (*ctx->Driver.CopyTexImage2D)(ctx, target, level, internalFormat,
+ x, y, width, height, border);
+
+ ASSERT(texImage->TexFormat);
+
+ /* If driver didn't explicitly set these, use the defaults */
+ if (!texImage->FetchTexelc)
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel2D;
+ if (!texImage->FetchTexelf)
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df;
+ ASSERT(texImage->FetchTexelc);
+ ASSERT(texImage->FetchTexelf);
+
+ /* state update */
+ texObj->Complete = GL_FALSE;
+ ctx->NewState |= _NEW_TEXTURE;
+}
+
+
+
+void GLAPIENTRY
+_mesa_CopyTexSubImage1D( GLenum target, GLint level,
+ GLint xoffset, GLint x, GLint y, GLsizei width )
+{
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_image *texImage;
+ GLsizei postConvWidth = width;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ _mesa_update_state(ctx);
+
+ /* XXX should test internal format */
+ _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL);
+
+ if (copytexsubimage_error_check(ctx, 1, target, level,
+ xoffset, 0, 0, postConvWidth, 1))
+ return;
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ ASSERT(texImage);
+
+ /* If we have a border, xoffset=-1 is legal. Bias by border width */
+ xoffset += texImage->Border;
+
+ ASSERT(ctx->Driver.CopyTexSubImage1D);
+ (*ctx->Driver.CopyTexSubImage1D)(ctx, target, level, xoffset, x, y, width);
+ ctx->NewState |= _NEW_TEXTURE;
+}
+
+
+
+void GLAPIENTRY
+_mesa_CopyTexSubImage2D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint x, GLint y, GLsizei width, GLsizei height )
+{
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_image *texImage;
+ GLsizei postConvWidth = width, postConvHeight = height;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ _mesa_update_state(ctx);
+
+ /* XXX should test internal format */
+ _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, &postConvHeight);
+
+ if (copytexsubimage_error_check(ctx, 2, target, level, xoffset, yoffset, 0,
+ postConvWidth, postConvHeight))
+ return;
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ ASSERT(texImage);
+
+ /* If we have a border, xoffset=-1 is legal. Bias by border width */
+ xoffset += texImage->Border;
+ yoffset += texImage->Border;
+
+ ASSERT(ctx->Driver.CopyTexSubImage2D);
+ (*ctx->Driver.CopyTexSubImage2D)(ctx, target, level,
+ xoffset, yoffset, x, y, width, height);
+ ctx->NewState |= _NEW_TEXTURE;
+}
+
+
+
+void GLAPIENTRY
+_mesa_CopyTexSubImage3D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLint x, GLint y, GLsizei width, GLsizei height )
+{
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_image *texImage;
+ GLsizei postConvWidth = width, postConvHeight = height;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (ctx->NewState & _IMAGE_NEW_TRANSFER_STATE)
+ _mesa_update_state(ctx);
+
+ /* XXX should test internal format */
+ _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth, &postConvHeight);
+
+ if (copytexsubimage_error_check(ctx, 3, target, level, xoffset, yoffset,
+ zoffset, postConvWidth, postConvHeight))
+ return;
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ ASSERT(texImage);
+
+ /* If we have a border, xoffset=-1 is legal. Bias by border width */
+ xoffset += texImage->Border;
+ yoffset += texImage->Border;
+ zoffset += texImage->Border;
+
+ ASSERT(ctx->Driver.CopyTexSubImage3D);
+ (*ctx->Driver.CopyTexSubImage3D)(ctx, target, level,
+ xoffset, yoffset, zoffset,
+ x, y, width, height);
+ ctx->NewState |= _NEW_TEXTURE;
+}
+
+
+
+
+/**********************************************************************/
+/****** Compressed Textures ******/
+/**********************************************************************/
+
+
+/**
+ * Error checking for glCompressedTexImage[123]D().
+ * \return error code or GL_NO_ERROR.
+ */
+static GLenum
+compressed_texture_error_check(GLcontext *ctx, GLint dimensions,
+ GLenum target, GLint level,
+ GLenum internalFormat, GLsizei width,
+ GLsizei height, GLsizei depth, GLint border,
+ GLsizei imageSize)
+{
+ GLint expectedSize, maxLevels = 0, maxTextureSize;
+
+ if (dimensions == 1) {
+ /* 1D compressed textures not allowed */
+ return GL_INVALID_ENUM;
+ }
+ else if (dimensions == 2) {
+ if (target == GL_PROXY_TEXTURE_2D) {
+ maxLevels = ctx->Const.MaxTextureLevels;
+ }
+ else if (target == GL_TEXTURE_2D) {
+ maxLevels = ctx->Const.MaxTextureLevels;
+ }
+ else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
+ if (!ctx->Extensions.ARB_texture_cube_map)
+ return GL_INVALID_ENUM; /*target*/
+ maxLevels = ctx->Const.MaxCubeTextureLevels;
+ }
+ else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) {
+ if (!ctx->Extensions.ARB_texture_cube_map)
+ return GL_INVALID_ENUM; /*target*/
+ maxLevels = ctx->Const.MaxCubeTextureLevels;
+ }
+ else {
+ return GL_INVALID_ENUM; /*target*/
+ }
+ }
+ else if (dimensions == 3) {
+ /* 3D compressed textures not allowed */
+ return GL_INVALID_ENUM;
+ }
+
+ maxTextureSize = 1 << (maxLevels - 1);
+
+ if (!is_compressed_format(ctx, internalFormat))
+ return GL_INVALID_ENUM;
+
+ if (_mesa_base_tex_format(ctx, internalFormat) < 0)
+ return GL_INVALID_ENUM;
+
+ if (border != 0)
+ return GL_INVALID_VALUE;
+
+ /*
+ * XXX We should probably use the proxy texture error check function here.
+ */
+ if (width < 1 || width > maxTextureSize ||
+ (!ctx->Extensions.ARB_texture_non_power_of_two && _mesa_bitcount(width) != 1))
+ return GL_INVALID_VALUE;
+
+ if ((height < 1 || height > maxTextureSize ||
+ (!ctx->Extensions.ARB_texture_non_power_of_two && _mesa_bitcount(height) != 1))
+ && dimensions > 1)
+ return GL_INVALID_VALUE;
+
+ if ((depth < 1 || depth > maxTextureSize ||
+ (!ctx->Extensions.ARB_texture_non_power_of_two && _mesa_bitcount(depth) != 1))
+ && dimensions > 2)
+ return GL_INVALID_VALUE;
+
+ /* For cube map, width must equal height */
+ if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB && width != height)
+ return GL_INVALID_VALUE;
+
+ if (level < 0 || level >= maxLevels)
+ return GL_INVALID_VALUE;
+
+ expectedSize = ctx->Driver.CompressedTextureSize(ctx, width, height, depth,
+ internalFormat);
+ if (expectedSize != imageSize)
+ return GL_INVALID_VALUE;
+
+ return GL_NO_ERROR;
+}
+
+
+/**
+ * Error checking for glCompressedTexSubImage[123]D().
+ * \warning There are some bad assumptions here about the size of compressed
+ * texture tiles (multiple of 4) used to test the validity of the
+ * offset and size parameters.
+ * \return error code or GL_NO_ERROR.
+ */
+static GLenum
+compressed_subtexture_error_check(GLcontext *ctx, GLint dimensions,
+ GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLsizei imageSize)
+{
+ GLint expectedSize, maxLevels = 0, maxTextureSize;
+ (void) zoffset;
+
+ if (dimensions == 1) {
+ /* 1D compressed textures not allowed */
+ return GL_INVALID_ENUM;
+ }
+ else if (dimensions == 2) {
+ if (target == GL_PROXY_TEXTURE_2D) {
+ maxLevels = ctx->Const.MaxTextureLevels;
+ }
+ else if (target == GL_TEXTURE_2D) {
+ maxLevels = ctx->Const.MaxTextureLevels;
+ }
+ else if (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB) {
+ if (!ctx->Extensions.ARB_texture_cube_map)
+ return GL_INVALID_ENUM; /*target*/
+ maxLevels = ctx->Const.MaxCubeTextureLevels;
+ }
+ else if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) {
+ if (!ctx->Extensions.ARB_texture_cube_map)
+ return GL_INVALID_ENUM; /*target*/
+ maxLevels = ctx->Const.MaxCubeTextureLevels;
+ }
+ else {
+ return GL_INVALID_ENUM; /*target*/
+ }
+ }
+ else if (dimensions == 3) {
+ /* 3D compressed textures not allowed */
+ return GL_INVALID_ENUM;
+ }
+
+ maxTextureSize = 1 << (maxLevels - 1);
+
+ if (!is_compressed_format(ctx, format))
+ return GL_INVALID_ENUM;
+
+ if (width < 1 || width > maxTextureSize)
+ return GL_INVALID_VALUE;
+
+ if ((height < 1 || height > maxTextureSize)
+ && dimensions > 1)
+ return GL_INVALID_VALUE;
+
+ if (level < 0 || level >= maxLevels)
+ return GL_INVALID_VALUE;
+
+ /* XXX these tests are specific to the compressed format.
+ * this code should be generalized in some way.
+ */
+ if ((xoffset & 3) != 0 || (yoffset & 3) != 0)
+ return GL_INVALID_VALUE;
+
+ if ((width & 3) != 0 && width != 2 && width != 1)
+ return GL_INVALID_VALUE;
+
+ if ((height & 3) != 0 && height != 2 && height != 1)
+ return GL_INVALID_VALUE;
+
+ expectedSize = ctx->Driver.CompressedTextureSize(ctx, width, height, depth,
+ format);
+ if (expectedSize != imageSize)
+ return GL_INVALID_VALUE;
+
+ return GL_NO_ERROR;
+}
+
+
+
+void GLAPIENTRY
+_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);
+
+ if (target == GL_TEXTURE_1D) {
+ /* non-proxy target */
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GLenum error = compressed_texture_error_check(ctx, 1, target, level,
+ internalFormat, width, 1, 1, border, imageSize);
+ if (error) {
+ _mesa_error(ctx, error, "glCompressedTexImage1D");
+ return;
+ }
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ texImage = _mesa_get_tex_image(ctx, texUnit, target, level);
+ if (!texImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1D");
+ return;
+ }
+ else if (texImage->Data) {
+ ctx->Driver.FreeTexImageData( ctx, texImage );
+ }
+ ASSERT(texImage->Data == NULL);
+
+ _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1,
+ border, internalFormat);
+
+ ASSERT(ctx->Driver.CompressedTexImage1D);
+ (*ctx->Driver.CompressedTexImage1D)(ctx, target, level,
+ internalFormat, width, border,
+ imageSize, data,
+ texObj, texImage);
+
+ /* state update */
+ texObj->Complete = GL_FALSE;
+ ctx->NewState |= _NEW_TEXTURE;
+ }
+ else if (target == GL_PROXY_TEXTURE_1D) {
+ /* Proxy texture: check for errors and update proxy state */
+ GLenum error = compressed_texture_error_check(ctx, 1, target, level,
+ internalFormat, width, 1, 1, border, imageSize);
+ if (!error) {
+ ASSERT(ctx->Driver.TestProxyTexImage);
+ error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level,
+ internalFormat, GL_NONE, GL_NONE,
+ width, 1, 1, border);
+ }
+ if (error) {
+ /* if error, clear all proxy texture image parameters */
+ struct gl_texture_image *texImage;
+ texImage = _mesa_get_proxy_tex_image(ctx, target, level);
+ if (texImage)
+ clear_teximage_fields(texImage);
+ }
+ else {
+ /* store the teximage parameters */
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_image *texImage;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ _mesa_init_teximage_fields(ctx, target, texImage, width, 1, 1,
+ border, internalFormat);
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage1D(target)");
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_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);
+
+ if (target == GL_TEXTURE_2D ||
+ (ctx->Extensions.ARB_texture_cube_map &&
+ target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB &&
+ target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) {
+ /* non-proxy target */
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GLenum error = compressed_texture_error_check(ctx, 2, target, level,
+ internalFormat, width, height, 1, border, imageSize);
+ if (error) {
+ _mesa_error(ctx, error, "glCompressedTexImage2D");
+ return;
+ }
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ texImage = _mesa_get_tex_image(ctx, texUnit, target, level);
+ if (!texImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2D");
+ return;
+ }
+ else if (texImage->Data) {
+ ctx->Driver.FreeTexImageData( ctx, texImage );
+ }
+ ASSERT(texImage->Data == NULL);
+
+ _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
+ border, internalFormat);
+
+ ASSERT(ctx->Driver.CompressedTexImage2D);
+ (*ctx->Driver.CompressedTexImage2D)(ctx, target, level,
+ internalFormat, width, height,
+ border, imageSize, data,
+ texObj, texImage);
+
+ /* state update */
+ texObj->Complete = GL_FALSE;
+ ctx->NewState |= _NEW_TEXTURE;
+ }
+ else if (target == GL_PROXY_TEXTURE_2D ||
+ (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB &&
+ ctx->Extensions.ARB_texture_cube_map)) {
+ /* Proxy texture: check for errors and update proxy state */
+ GLenum error = compressed_texture_error_check(ctx, 2, target, level,
+ internalFormat, width, height, 1, border, imageSize);
+ if (!error) {
+ ASSERT(ctx->Driver.TestProxyTexImage);
+ error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level,
+ internalFormat, GL_NONE, GL_NONE,
+ width, height, 1, border);
+ }
+ if (error) {
+ /* if error, clear all proxy texture image parameters */
+ struct gl_texture_image *texImage;
+ texImage = _mesa_get_proxy_tex_image(ctx, target, level);
+ if (texImage)
+ clear_teximage_fields(texImage);
+ }
+ else {
+ /* store the teximage parameters */
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_image *texImage;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ _mesa_init_teximage_fields(ctx, target, texImage, width, height, 1,
+ border, internalFormat);
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage2D(target)");
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_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);
+
+ if (target == GL_TEXTURE_3D) {
+ /* non-proxy target */
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GLenum error = compressed_texture_error_check(ctx, 3, target, level,
+ internalFormat, width, height, depth, border, imageSize);
+ if (error) {
+ _mesa_error(ctx, error, "glCompressedTexImage3D");
+ return;
+ }
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ texImage = _mesa_get_tex_image(ctx, texUnit, target, level);
+ if (!texImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3D");
+ return;
+ }
+ else if (texImage->Data) {
+ ctx->Driver.FreeTexImageData( ctx, texImage );
+ }
+ ASSERT(texImage->Data == NULL);
+
+ _mesa_init_teximage_fields(ctx, target, texImage, width, height, depth,
+ border, internalFormat);
+
+ ASSERT(ctx->Driver.CompressedTexImage3D);
+ (*ctx->Driver.CompressedTexImage3D)(ctx, target, level,
+ internalFormat,
+ width, height, depth,
+ border, imageSize, data,
+ texObj, texImage);
+
+ /* state update */
+ texObj->Complete = GL_FALSE;
+ ctx->NewState |= _NEW_TEXTURE;
+ }
+ else if (target == GL_PROXY_TEXTURE_3D) {
+ /* Proxy texture: check for errors and update proxy state */
+ GLenum error = compressed_texture_error_check(ctx, 3, target, level,
+ internalFormat, width, height, depth, border, imageSize);
+ if (!error) {
+ ASSERT(ctx->Driver.TestProxyTexImage);
+ error = !(*ctx->Driver.TestProxyTexImage)(ctx, target, level,
+ internalFormat, GL_NONE, GL_NONE,
+ width, height, depth, border);
+ }
+ if (error) {
+ /* if error, clear all proxy texture image parameters */
+ struct gl_texture_image *texImage;
+ texImage = _mesa_get_proxy_tex_image(ctx, target, level);
+ if (texImage)
+ clear_teximage_fields(texImage);
+ }
+ else {
+ /* store the teximage parameters */
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_image *texImage;
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ _mesa_init_teximage_fields(ctx, target, texImage, width, height,
+ depth, border, internalFormat);
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glCompressedTexImage3D(target)");
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
+ GLsizei width, GLenum format,
+ GLsizei imageSize, const GLvoid *data)
+{
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GLenum error;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ error = compressed_subtexture_error_check(ctx, 1, target, level,
+ xoffset, 0, 0, width, 1, 1, format, imageSize);
+ if (error) {
+ _mesa_error(ctx, error, "glCompressedTexSubImage1D");
+ return;
+ }
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ assert(texImage);
+
+ if ((GLint) format != texImage->IntFormat) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCompressedTexSubImage1D(format)");
+ return;
+ }
+
+ if ((width == 1 || width == 2) && (GLuint) width != texImage->Width) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glCompressedTexSubImage1D(width)");
+ return;
+ }
+
+ if (width == 0)
+ return; /* no-op, not an error */
+
+ if (ctx->Driver.CompressedTexSubImage1D) {
+ (*ctx->Driver.CompressedTexSubImage1D)(ctx, target, level,
+ xoffset, width,
+ format, imageSize, data,
+ texObj, texImage);
+ }
+ ctx->NewState |= _NEW_TEXTURE;
+}
+
+
+void GLAPIENTRY
+_mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
+ GLint yoffset, GLsizei width, GLsizei height,
+ GLenum format, GLsizei imageSize,
+ const GLvoid *data)
+{
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GLenum error;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ error = compressed_subtexture_error_check(ctx, 2, target, level,
+ xoffset, yoffset, 0, width, height, 1, format, imageSize);
+ if (error) {
+ /* XXX proxy target? */
+ _mesa_error(ctx, error, "glCompressedTexSubImage2D");
+ return;
+ }
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ assert(texImage);
+
+ if ((GLint) format != texImage->IntFormat) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCompressedTexSubImage2D(format)");
+ return;
+ }
+
+ if (((width == 1 || width == 2) && (GLuint) width != texImage->Width) ||
+ ((height == 1 || height == 2) && (GLuint) height != texImage->Height)) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glCompressedTexSubImage2D(size)");
+ return;
+ }
+
+ if (width == 0 || height == 0)
+ return; /* no-op, not an error */
+
+ if (ctx->Driver.CompressedTexSubImage2D) {
+ (*ctx->Driver.CompressedTexSubImage2D)(ctx, target, level,
+ xoffset, yoffset, width, height,
+ format, imageSize, data,
+ texObj, texImage);
+ }
+ ctx->NewState |= _NEW_TEXTURE;
+}
+
+
+void GLAPIENTRY
+_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)
+{
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GLenum error;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ error = compressed_subtexture_error_check(ctx, 3, target, level,
+ xoffset, yoffset, zoffset, width, height, depth, format, imageSize);
+ if (error) {
+ _mesa_error(ctx, error, "glCompressedTexSubImage2D");
+ return;
+ }
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ assert(texImage);
+
+ if ((GLint) format != texImage->IntFormat) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glCompressedTexSubImage3D(format)");
+ return;
+ }
+
+ if (((width == 1 || width == 2) && (GLuint) width != texImage->Width) ||
+ ((height == 1 || height == 2) && (GLuint) height != texImage->Height) ||
+ ((depth == 1 || depth == 2) && (GLuint) depth != texImage->Depth)) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glCompressedTexSubImage3D(size)");
+ return;
+ }
+
+ if (width == 0 || height == 0 || depth == 0)
+ return; /* no-op, not an error */
+
+ if (ctx->Driver.CompressedTexSubImage3D) {
+ (*ctx->Driver.CompressedTexSubImage3D)(ctx, target, level,
+ xoffset, yoffset, zoffset,
+ width, height, depth,
+ format, imageSize, data,
+ texObj, texImage);
+ }
+ ctx->NewState |= _NEW_TEXTURE;
+}
+
+
+void GLAPIENTRY
+_mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img)
+{
+ const struct gl_texture_unit *texUnit;
+ const struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ GLint maxLevels;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ if (!texObj) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImageARB");
+ return;
+ }
+
+ maxLevels = _mesa_max_texture_levels(ctx, target);
+ ASSERT(maxLevels > 0); /* 0 indicates bad target, caught above */
+
+ if (level < 0 || level >= maxLevels) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetCompressedTexImageARB(level)");
+ return;
+ }
+
+ if (is_proxy_target(target)) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImageARB(target)");
+ return;
+ }
+
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ if (!texImage) {
+ /* probably invalid mipmap level */
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetCompressedTexImageARB(level)");
+ return;
+ }
+
+ if (!texImage->IsCompressed) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetCompressedTexImageARB");
+ return;
+ }
+
+ /* this typically calls _mesa_get_compressed_teximage() */
+ ctx->Driver.GetCompressedTexImage(ctx, target, level, img, texObj,texImage);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/teximage.h b/nx-X11/extras/Mesa/src/mesa/main/teximage.h
new file mode 100644
index 000000000..45c851e5c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/teximage.h
@@ -0,0 +1,239 @@
+/**
+ * \file teximage.h
+ * Texture images manipulation functions.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef TEXIMAGE_H
+#define TEXIMAGE_H
+
+
+#include "mtypes.h"
+
+
+extern void *
+_mesa_alloc_texmemory(GLsizei bytes);
+
+extern void
+_mesa_free_texmemory(void *m);
+
+
+/** \name Internal functions */
+/*@{*/
+
+extern GLint
+_mesa_base_tex_format( GLcontext *ctx, GLint internalFormat );
+
+
+extern struct gl_texture_image *
+_mesa_new_texture_image( GLcontext *ctx );
+
+
+extern void
+_mesa_delete_texture_image( GLcontext *ctx, struct gl_texture_image *teximage );
+
+
+extern void
+_mesa_free_texture_image_data( GLcontext *ctx,
+ struct gl_texture_image *texImage );
+
+
+extern void
+_mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
+ struct gl_texture_image *img,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLint border, GLenum internalFormat);
+
+
+extern void
+_mesa_set_tex_image(struct gl_texture_object *tObj,
+ GLenum target, GLint level,
+ struct gl_texture_image *texImage);
+
+
+extern struct gl_texture_object *
+_mesa_select_tex_object(GLcontext *ctx, const 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 struct gl_texture_image *
+_mesa_get_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit,
+ GLenum target, GLint level);
+
+
+extern struct gl_texture_image *
+_mesa_get_proxy_tex_image(GLcontext *ctx, GLenum target, GLint level);
+
+
+extern GLint
+_mesa_max_texture_levels(GLcontext *ctx, GLenum target);
+
+
+extern GLboolean
+_mesa_test_proxy_teximage(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat, GLenum format, GLenum type,
+ GLint width, GLint height, GLint depth, GLint border);
+
+/*@}*/
+
+
+/** \name API entry point functions */
+/*@{*/
+
+extern void GLAPIENTRY
+_mesa_TexImage1D( GLenum target, GLint level, GLint internalformat,
+ GLsizei width, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels );
+
+
+extern void GLAPIENTRY
+_mesa_TexImage2D( GLenum target, GLint level, GLint internalformat,
+ GLsizei width, GLsizei height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels );
+
+
+extern void GLAPIENTRY
+_mesa_TexImage3D( GLenum target, GLint level, GLint internalformat,
+ GLsizei width, GLsizei height, GLsizei depth, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels );
+
+
+extern void GLAPIENTRY
+_mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLint border, GLenum format, GLenum type,
+ const GLvoid *pixels );
+
+
+extern void GLAPIENTRY
+_mesa_GetTexImage( GLenum target, GLint level,
+ GLenum format, GLenum type, GLvoid *pixels );
+
+
+extern void GLAPIENTRY
+_mesa_TexSubImage1D( GLenum target, GLint level, GLint xoffset,
+ GLsizei width,
+ GLenum format, GLenum type,
+ const GLvoid *pixels );
+
+
+extern void GLAPIENTRY
+_mesa_TexSubImage2D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *pixels );
+
+
+extern void GLAPIENTRY
+_mesa_TexSubImage3D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type,
+ const GLvoid *pixels );
+
+
+extern void GLAPIENTRY
+_mesa_CopyTexImage1D( GLenum target, GLint level, GLenum internalformat,
+ GLint x, GLint y, GLsizei width, GLint border );
+
+
+extern void GLAPIENTRY
+_mesa_CopyTexImage2D( GLenum target, GLint level,
+ GLenum internalformat, GLint x, GLint y,
+ GLsizei width, GLsizei height, GLint border );
+
+
+extern void GLAPIENTRY
+_mesa_CopyTexSubImage1D( GLenum target, GLint level, GLint xoffset,
+ GLint x, GLint y, GLsizei width );
+
+
+extern void GLAPIENTRY
+_mesa_CopyTexSubImage2D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint x, GLint y, GLsizei width, GLsizei height );
+
+
+extern void GLAPIENTRY
+_mesa_CopyTexSubImage3D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLint x, GLint y, GLsizei width, GLsizei height );
+
+
+
+extern void GLAPIENTRY
+_mesa_CompressedTexImage1DARB(GLenum target, GLint level,
+ GLenum internalformat, GLsizei width,
+ GLint border, GLsizei imageSize,
+ const GLvoid *data);
+
+extern void GLAPIENTRY
+_mesa_CompressedTexImage2DARB(GLenum target, GLint level,
+ GLenum internalformat, GLsizei width,
+ GLsizei height, GLint border, GLsizei imageSize,
+ const GLvoid *data);
+
+extern void GLAPIENTRY
+_mesa_CompressedTexImage3DARB(GLenum target, GLint level,
+ GLenum internalformat, GLsizei width,
+ GLsizei height, GLsizei depth, GLint border,
+ GLsizei imageSize, const GLvoid *data);
+
+#ifdef VMS
+#define _mesa_CompressedTexSubImage1DARB _mesa_CompressedTexSubImage1DAR
+#define _mesa_CompressedTexSubImage2DARB _mesa_CompressedTexSubImage2DAR
+#define _mesa_CompressedTexSubImage3DARB _mesa_CompressedTexSubImage3DAR
+#endif
+extern void GLAPIENTRY
+_mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
+ GLsizei width, GLenum format,
+ GLsizei imageSize, const GLvoid *data);
+
+extern void GLAPIENTRY
+_mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
+ GLint yoffset, GLsizei width, GLsizei height,
+ GLenum format, GLsizei imageSize,
+ const GLvoid *data);
+
+extern void GLAPIENTRY
+_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 GLAPIENTRY
+_mesa_GetCompressedTexImageARB(GLenum target, GLint lod, GLvoid *img);
+
+/*@}*/
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/texobj.c b/nx-X11/extras/Mesa/src/mesa/main/texobj.c
new file mode 100644
index 000000000..5594cd938
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/texobj.c
@@ -0,0 +1,1000 @@
+/**
+ * \file texobj.c
+ * Texture object management.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "colortab.h"
+#include "context.h"
+#include "enums.h"
+#include "hash.h"
+#include "imports.h"
+#include "macros.h"
+#include "teximage.h"
+#include "texstate.h"
+#include "texobj.h"
+#include "mtypes.h"
+
+
+/**********************************************************************/
+/** \name Internal functions */
+/*@{*/
+
+/**
+ * Allocate and initialize a new texture object. But don't put it into the
+ * texture object hash table.
+ *
+ * Called via ctx->Driver.NewTextureObject, unless overridden by a device
+ * driver.
+ *
+ * \param shared the shared GL state structure to contain the texture object
+ * \param name integer name for the texture object
+ * \param target either GL_TEXTURE_1D, GL_TEXTURE_2D, GL_TEXTURE_3D,
+ * GL_TEXTURE_CUBE_MAP_ARB or GL_TEXTURE_RECTANGLE_NV. zero is ok for the sake
+ * of GenTextures()
+ *
+ * \return pointer to new texture object.
+ */
+struct gl_texture_object *
+_mesa_new_texture_object( GLcontext *ctx, GLuint name, GLenum target )
+{
+ struct gl_texture_object *obj;
+ (void) ctx;
+ obj = MALLOC_STRUCT(gl_texture_object);
+ _mesa_initialize_texture_object(obj, name, target);
+ return obj;
+}
+
+
+/**
+ * Initialize a new texture object to default values.
+ * \param obj the texture object
+ * \param name the texture name
+ * \param target the texture target
+ */
+void
+_mesa_initialize_texture_object( struct gl_texture_object *obj,
+ GLuint name, GLenum target )
+{
+ ASSERT(target == 0 ||
+ target == GL_TEXTURE_1D ||
+ target == GL_TEXTURE_2D ||
+ target == GL_TEXTURE_3D ||
+ target == GL_TEXTURE_CUBE_MAP_ARB ||
+ target == GL_TEXTURE_RECTANGLE_NV);
+
+ _mesa_bzero(obj, sizeof(*obj));
+ /* init the non-zero fields */
+ _glthread_INIT_MUTEX(obj->Mutex);
+ obj->RefCount = 1;
+ obj->Name = name;
+ obj->Target = target;
+ obj->Priority = 1.0F;
+ if (target == GL_TEXTURE_RECTANGLE_NV) {
+ obj->WrapS = GL_CLAMP_TO_EDGE;
+ obj->WrapT = GL_CLAMP_TO_EDGE;
+ obj->WrapR = GL_CLAMP_TO_EDGE;
+ obj->MinFilter = GL_LINEAR;
+ }
+ else {
+ obj->WrapS = GL_REPEAT;
+ obj->WrapT = GL_REPEAT;
+ obj->WrapR = GL_REPEAT;
+ obj->MinFilter = GL_NEAREST_MIPMAP_LINEAR;
+ }
+ obj->MagFilter = GL_LINEAR;
+ obj->MinLod = -1000.0;
+ obj->MaxLod = 1000.0;
+ obj->LodBias = 0.0;
+ obj->BaseLevel = 0;
+ obj->MaxLevel = 1000;
+ obj->MaxAnisotropy = 1.0;
+ obj->CompareFlag = GL_FALSE; /* SGIX_shadow */
+ obj->CompareOperator = GL_TEXTURE_LEQUAL_R_SGIX; /* SGIX_shadow */
+ obj->CompareMode = GL_NONE; /* ARB_shadow */
+ obj->CompareFunc = GL_LEQUAL; /* ARB_shadow */
+ obj->DepthMode = GL_LUMINANCE; /* ARB_depth_texture */
+ obj->ShadowAmbient = 0.0F; /* ARB/SGIX_shadow_ambient */
+ _mesa_init_colortable(&obj->Palette);
+}
+
+
+/**
+ * Deallocate a texture object struct. It should have already been
+ * removed from the texture object pool.
+ *
+ * \param shared the shared GL state to which the object belongs.
+ * \param texOjb the texture object to delete.
+ */
+void
+_mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *texObj )
+{
+ GLuint i, face;
+
+ (void) ctx;
+
+ _mesa_free_colortable_data(&texObj->Palette);
+
+ /* free the texture images */
+ for (face = 0; face < 6; face++) {
+ for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
+ if (texObj->Image[face][i]) {
+ _mesa_delete_texture_image( ctx, texObj->Image[face][i] );
+ }
+ }
+ }
+
+ /* destroy the mutex -- it may have allocated memory (eg on bsd) */
+ _glthread_DESTROY_MUTEX(texObj->Mutex);
+
+ /* free this object */
+ _mesa_free(texObj);
+}
+
+
+
+
+/**
+ * Copy texture object state from one texture object to another.
+ * Use for glPush/PopAttrib.
+ *
+ * \param dest destination texture object.
+ * \param src source texture object.
+ */
+void
+_mesa_copy_texture_object( struct gl_texture_object *dest,
+ const struct gl_texture_object *src )
+{
+ dest->Name = src->Name;
+ dest->Priority = src->Priority;
+ dest->BorderColor[0] = src->BorderColor[0];
+ dest->BorderColor[1] = src->BorderColor[1];
+ dest->BorderColor[2] = src->BorderColor[2];
+ dest->BorderColor[3] = src->BorderColor[3];
+ dest->WrapS = src->WrapS;
+ dest->WrapT = src->WrapT;
+ dest->WrapR = src->WrapR;
+ dest->MinFilter = src->MinFilter;
+ dest->MagFilter = src->MagFilter;
+ dest->MinLod = src->MinLod;
+ dest->MaxLod = src->MaxLod;
+ dest->LodBias = src->LodBias;
+ dest->BaseLevel = src->BaseLevel;
+ dest->MaxLevel = src->MaxLevel;
+ dest->MaxAnisotropy = src->MaxAnisotropy;
+ dest->CompareFlag = src->CompareFlag;
+ dest->CompareOperator = src->CompareOperator;
+ dest->ShadowAmbient = src->ShadowAmbient;
+ dest->CompareMode = src->CompareMode;
+ dest->CompareFunc = src->CompareFunc;
+ dest->DepthMode = src->DepthMode;
+ dest->_MaxLevel = src->_MaxLevel;
+ dest->_MaxLambda = src->_MaxLambda;
+ dest->GenerateMipmap = src->GenerateMipmap;
+ dest->Palette = src->Palette;
+ dest->Complete = src->Complete;
+ dest->_IsPowerOfTwo = src->_IsPowerOfTwo;
+}
+
+
+/**
+ * Report why a texture object is incomplete.
+ *
+ * \param t texture object.
+ * \param why string describing why it's incomplete.
+ *
+ * \note For debug purposes only.
+ */
+#if 0
+static void
+incomplete(const struct gl_texture_object *t, const char *why)
+{
+ _mesa_printf("Texture Obj %d incomplete because: %s\n", t->Name, why);
+}
+#else
+#define incomplete(t, why)
+#endif
+
+
+/**
+ * Examine a texture object to determine if it is complete.
+ *
+ * The gl_texture_object::Complete flag will be set to GL_TRUE or GL_FALSE
+ * accordingly.
+ *
+ * \param ctx GL context.
+ * \param t texture object.
+ *
+ * According to the texture target, verifies that each of the mipmaps is
+ * present and has the expected size.
+ */
+void
+_mesa_test_texobj_completeness( const GLcontext *ctx,
+ struct gl_texture_object *t )
+{
+ const GLint baseLevel = t->BaseLevel;
+ GLint maxLog2 = 0, maxLevels = 0;
+
+ t->Complete = GL_TRUE; /* be optimistic */
+ t->_IsPowerOfTwo = GL_TRUE; /* may be set FALSE below */
+
+ /* Always need the base level image */
+ if (!t->Image[0][baseLevel]) {
+ char s[100];
+ sprintf(s, "obj %p (%d) Image[baseLevel=%d] == NULL",
+ (void *) t, t->Name, baseLevel);
+ incomplete(t, s);
+ t->Complete = GL_FALSE;
+ return;
+ }
+
+ /* Check width/height/depth for zero */
+ if (t->Image[0][baseLevel]->Width == 0 ||
+ t->Image[0][baseLevel]->Height == 0 ||
+ t->Image[0][baseLevel]->Depth == 0) {
+ incomplete(t, "texture width = 0");
+ t->Complete = GL_FALSE;
+ return;
+ }
+
+ /* Compute _MaxLevel */
+ if (t->Target == GL_TEXTURE_1D) {
+ maxLog2 = t->Image[0][baseLevel]->WidthLog2;
+ maxLevels = ctx->Const.MaxTextureLevels;
+ }
+ else if (t->Target == GL_TEXTURE_2D) {
+ maxLog2 = MAX2(t->Image[0][baseLevel]->WidthLog2,
+ t->Image[0][baseLevel]->HeightLog2);
+ maxLevels = ctx->Const.MaxTextureLevels;
+ }
+ else if (t->Target == GL_TEXTURE_3D) {
+ GLint max = MAX2(t->Image[0][baseLevel]->WidthLog2,
+ t->Image[0][baseLevel]->HeightLog2);
+ maxLog2 = MAX2(max, (GLint)(t->Image[0][baseLevel]->DepthLog2));
+ maxLevels = ctx->Const.Max3DTextureLevels;
+ }
+ else if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) {
+ maxLog2 = MAX2(t->Image[0][baseLevel]->WidthLog2,
+ t->Image[0][baseLevel]->HeightLog2);
+ maxLevels = ctx->Const.MaxCubeTextureLevels;
+ }
+ else if (t->Target == GL_TEXTURE_RECTANGLE_NV) {
+ maxLog2 = 0; /* not applicable */
+ maxLevels = 1; /* no mipmapping */
+ }
+ else {
+ _mesa_problem(ctx, "Bad t->Target in _mesa_test_texobj_completeness");
+ return;
+ }
+
+ ASSERT(maxLevels > 0);
+
+ t->_MaxLevel = baseLevel + maxLog2;
+ t->_MaxLevel = MIN2(t->_MaxLevel, t->MaxLevel);
+ t->_MaxLevel = MIN2(t->_MaxLevel, maxLevels - 1);
+
+ /* Compute _MaxLambda = q - b (see the 1.2 spec) used during mipmapping */
+ t->_MaxLambda = (GLfloat) (t->_MaxLevel - t->BaseLevel);
+
+ if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) {
+ /* make sure that all six cube map level 0 images are the same size */
+ const GLuint w = t->Image[0][baseLevel]->Width2;
+ const GLuint h = t->Image[0][baseLevel]->Height2;
+ GLuint face;
+ for (face = 1; face < 6; face++) {
+ if (t->Image[face][baseLevel] == NULL ||
+ t->Image[face][baseLevel]->Width2 != w ||
+ t->Image[face][baseLevel]->Height2 != h) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "Non-quare cubemap image");
+ return;
+ }
+ }
+ }
+
+ /* check for non power of two */
+ if (!t->Image[0][baseLevel]->_IsPowerOfTwo) {
+ t->_IsPowerOfTwo = GL_FALSE;
+ }
+
+ /* extra checking for mipmaps */
+ if (t->MinFilter != GL_NEAREST && t->MinFilter != GL_LINEAR) {
+ /*
+ * Mipmapping: determine if we have a complete set of mipmaps
+ */
+ GLint i;
+ GLint minLevel = baseLevel;
+ GLint maxLevel = t->_MaxLevel;
+
+ if (minLevel > maxLevel) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "minLevel > maxLevel");
+ return;
+ }
+
+ /* Test dimension-independent attributes */
+ for (i = minLevel; i <= maxLevel; i++) {
+ if (t->Image[0][i]) {
+ if (t->Image[0][i]->TexFormat != t->Image[0][baseLevel]->TexFormat) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "Format[i] != Format[baseLevel]");
+ return;
+ }
+ if (t->Image[0][i]->Border != t->Image[0][baseLevel]->Border) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "Border[i] != Border[baseLevel]");
+ return;
+ }
+ }
+ }
+
+ /* Test things which depend on number of texture image dimensions */
+ if (t->Target == GL_TEXTURE_1D) {
+ /* Test 1-D mipmaps */
+ GLuint width = t->Image[0][baseLevel]->Width2;
+ for (i = baseLevel + 1; i < maxLevels; i++) {
+ if (width > 1) {
+ width /= 2;
+ }
+ if (i >= minLevel && i <= maxLevel) {
+ if (!t->Image[0][i]) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "1D Image[0][i] == NULL");
+ return;
+ }
+ if (t->Image[0][i]->Width2 != width ) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "1D Image[0][i] bad width");
+ return;
+ }
+ }
+ if (width == 1) {
+ return; /* found smallest needed mipmap, all done! */
+ }
+ }
+ }
+ else if (t->Target == GL_TEXTURE_2D) {
+ /* Test 2-D mipmaps */
+ GLuint width = t->Image[0][baseLevel]->Width2;
+ GLuint height = t->Image[0][baseLevel]->Height2;
+ for (i = baseLevel + 1; i < maxLevels; i++) {
+ if (width > 1) {
+ width /= 2;
+ }
+ if (height > 1) {
+ height /= 2;
+ }
+ if (i >= minLevel && i <= maxLevel) {
+ if (!t->Image[0][i]) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "2D Image[0][i] == NULL");
+ return;
+ }
+ if (t->Image[0][i]->Width2 != width) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "2D Image[0][i] bad width");
+ return;
+ }
+ if (t->Image[0][i]->Height2 != height) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "2D Image[0][i] bad height");
+ return;
+ }
+ if (width==1 && height==1) {
+ return; /* found smallest needed mipmap, all done! */
+ }
+ }
+ }
+ }
+ else if (t->Target == GL_TEXTURE_3D) {
+ /* Test 3-D mipmaps */
+ GLuint width = t->Image[0][baseLevel]->Width2;
+ GLuint height = t->Image[0][baseLevel]->Height2;
+ GLuint depth = t->Image[0][baseLevel]->Depth2;
+ for (i = baseLevel + 1; i < maxLevels; i++) {
+ if (width > 1) {
+ width /= 2;
+ }
+ if (height > 1) {
+ height /= 2;
+ }
+ if (depth > 1) {
+ depth /= 2;
+ }
+ if (i >= minLevel && i <= maxLevel) {
+ if (!t->Image[0][i]) {
+ incomplete(t, "3D Image[0][i] == NULL");
+ t->Complete = GL_FALSE;
+ return;
+ }
+ if (t->Image[0][i]->Format == GL_DEPTH_COMPONENT) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "GL_DEPTH_COMPONENT only works with 1/2D tex");
+ return;
+ }
+ if (t->Image[0][i]->Width2 != width) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "3D Image[0][i] bad width");
+ return;
+ }
+ if (t->Image[0][i]->Height2 != height) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "3D Image[0][i] bad height");
+ return;
+ }
+ if (t->Image[0][i]->Depth2 != depth) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "3D Image[0][i] bad depth");
+ return;
+ }
+ }
+ if (width == 1 && height == 1 && depth == 1) {
+ return; /* found smallest needed mipmap, all done! */
+ }
+ }
+ }
+ else if (t->Target == GL_TEXTURE_CUBE_MAP_ARB) {
+ /* make sure 6 cube faces are consistant */
+ GLuint width = t->Image[0][baseLevel]->Width2;
+ GLuint height = t->Image[0][baseLevel]->Height2;
+ for (i = baseLevel + 1; i < maxLevels; i++) {
+ if (width > 1) {
+ width /= 2;
+ }
+ if (height > 1) {
+ height /= 2;
+ }
+ if (i >= minLevel && i <= maxLevel) {
+ GLuint face;
+ for (face = 0; face < 6; face++) {
+ /* check that we have images defined */
+ if (!t->Image[face][i]) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "CubeMap Image[n][i] == NULL");
+ return;
+ }
+ /* Don't support GL_DEPTH_COMPONENT for cube maps */
+ if (t->Image[face][i]->Format == GL_DEPTH_COMPONENT) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "GL_DEPTH_COMPONENT only works with 1/2D tex");
+ return;
+ }
+ /* check that all six images have same size */
+ if (t->Image[face][i]->Width2!=width ||
+ t->Image[face][i]->Height2!=height) {
+ t->Complete = GL_FALSE;
+ incomplete(t, "CubeMap Image[n][i] bad size");
+ return;
+ }
+ }
+ }
+ if (width == 1 && height == 1) {
+ return; /* found smallest needed mipmap, all done! */
+ }
+ }
+ }
+ else if (t->Target == GL_TEXTURE_RECTANGLE_NV) {
+ /* XXX special checking? */
+ }
+ else {
+ /* Target = ??? */
+ _mesa_problem(ctx, "Bug in gl_test_texture_object_completeness\n");
+ }
+ }
+}
+
+/*@}*/
+
+
+/***********************************************************************/
+/** \name API functions */
+/*@{*/
+
+/**
+ * Texture name generation lock.
+ *
+ * Used by _mesa_GenTextures() to guarantee that the generation and allocation
+ * of texture IDs is atomic.
+ */
+_glthread_DECLARE_STATIC_MUTEX(GenTexturesLock);
+
+/**
+ * Generate texture names.
+ *
+ * \param n number of texture names to be generated.
+ * \param textures an array in which will hold the generated texture names.
+ *
+ * \sa glGenTextures().
+ *
+ * While holding the GenTexturesLock lock, calls _mesa_HashFindFreeKeyBlock()
+ * to find a block of free texture IDs which are stored in \p textures.
+ * Corresponding empty texture objects are also generated.
+ */
+void GLAPIENTRY
+_mesa_GenTextures( GLsizei n, GLuint *textures )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint first;
+ GLint i;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (n < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glGenTextures" );
+ return;
+ }
+
+ if (!textures)
+ return;
+
+ /*
+ * This must be atomic (generation and allocation of texture IDs)
+ */
+ _glthread_LOCK_MUTEX(GenTexturesLock);
+
+ first = _mesa_HashFindFreeKeyBlock(ctx->Shared->TexObjects, n);
+
+ /* Allocate new, empty texture objects */
+ for (i = 0; i < n; i++) {
+ struct gl_texture_object *texObj;
+ GLuint name = first + i;
+ GLenum target = 0;
+ texObj = (*ctx->Driver.NewTextureObject)( ctx, name, target);
+ if (!texObj) {
+ _glthread_UNLOCK_MUTEX(GenTexturesLock);
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenTextures");
+ return;
+ }
+
+ /* insert into hash table */
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+ _mesa_HashInsert(ctx->Shared->TexObjects, texObj->Name, texObj);
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+
+ textures[i] = name;
+ }
+
+ _glthread_UNLOCK_MUTEX(GenTexturesLock);
+}
+
+
+/**
+ * Delete named textures.
+ *
+ * \param n number of textures to be deleted.
+ * \param textures array of texture IDs to be deleted.
+ *
+ * \sa glDeleteTextures().
+ *
+ * If we're about to delete a texture that's currently bound to any
+ * texture unit, unbind the texture first. Decrement the reference
+ * count on the texture object and delete it if it's zero.
+ * Recall that texture objects can be shared among several rendering
+ * contexts.
+ */
+void GLAPIENTRY
+_mesa_DeleteTextures( GLsizei n, const GLuint *textures)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i;
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx); /* too complex */
+
+ if (!textures)
+ return;
+
+ for (i = 0; i < n; i++) {
+ if (textures[i] > 0) {
+ struct gl_texture_object *delObj = (struct gl_texture_object *)
+ _mesa_HashLookup(ctx->Shared->TexObjects, textures[i]);
+ if (delObj) {
+ /* First check if this texture is currently bound.
+ * If so, unbind it and decrement the reference count.
+ * XXX all RefCount accesses should be protected by a mutex.
+ */
+ GLuint u;
+ for (u = 0; u < MAX_TEXTURE_IMAGE_UNITS; u++) {
+ struct gl_texture_unit *unit = &ctx->Texture.Unit[u];
+ if (delObj == unit->Current1D) {
+ unit->Current1D = ctx->Shared->Default1D;
+ ctx->Shared->Default1D->RefCount++;
+ delObj->RefCount--;
+ if (delObj == unit->_Current)
+ unit->_Current = unit->Current1D;
+ }
+ else if (delObj == unit->Current2D) {
+ unit->Current2D = ctx->Shared->Default2D;
+ ctx->Shared->Default2D->RefCount++;
+ delObj->RefCount--;
+ if (delObj == unit->_Current)
+ unit->_Current = unit->Current2D;
+ }
+ else if (delObj == unit->Current3D) {
+ unit->Current3D = ctx->Shared->Default3D;
+ ctx->Shared->Default3D->RefCount++;
+ delObj->RefCount--;
+ if (delObj == unit->_Current)
+ unit->_Current = unit->Current3D;
+ }
+ else if (delObj == unit->CurrentCubeMap) {
+ unit->CurrentCubeMap = ctx->Shared->DefaultCubeMap;
+ ctx->Shared->DefaultCubeMap->RefCount++;
+ delObj->RefCount--;
+ if (delObj == unit->_Current)
+ unit->_Current = unit->CurrentCubeMap;
+ }
+ else if (delObj == unit->CurrentRect) {
+ unit->CurrentRect = ctx->Shared->DefaultRect;
+ ctx->Shared->DefaultRect->RefCount++;
+ delObj->RefCount--;
+ if (delObj == unit->_Current)
+ unit->_Current = unit->CurrentRect;
+ }
+ }
+ ctx->NewState |= _NEW_TEXTURE;
+
+ /* The texture _name_ is now free for re-use.
+ * Remove it from the hash table now.
+ */
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+ _mesa_HashRemove(ctx->Shared->TexObjects, delObj->Name);
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+
+ /* The actual texture object will not be freed until it's no
+ * longer bound in any context.
+ * XXX all RefCount accesses should be protected by a mutex.
+ */
+ delObj->RefCount--;
+ if (delObj->RefCount == 0) {
+ ASSERT(delObj->Name != 0); /* Never delete default tex objs */
+ ASSERT(ctx->Driver.DeleteTexture);
+ (*ctx->Driver.DeleteTexture)(ctx, delObj);
+ }
+ }
+ }
+ }
+}
+
+
+/**
+ * Bind a named texture to a texturing target.
+ *
+ * \param target texture target.
+ * \param texName texture name.
+ *
+ * \sa glBindTexture().
+ *
+ * Determines the old texture object bound and returns immediately if rebinding
+ * the same texture. Get the current texture which is either a default texture
+ * if name is null, a named texture from the hash, or a new texture if the
+ * given texture name is new. Increments its reference count, binds it, and
+ * calls dd_function_table::BindTexture. Decrements the old texture reference
+ * count and deletes it if it reaches zero.
+ */
+void GLAPIENTRY
+_mesa_BindTexture( GLenum target, GLuint texName )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint unit = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *oldTexObj;
+ struct gl_texture_object *newTexObj = NULL;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
+ _mesa_debug(ctx, "glBindTexture %s %d\n",
+ _mesa_lookup_enum_by_nr(target), (GLint) texName);
+
+ /*
+ * Get pointer to currently bound texture object (oldTexObj)
+ */
+ switch (target) {
+ case GL_TEXTURE_1D:
+ oldTexObj = texUnit->Current1D;
+ break;
+ case GL_TEXTURE_2D:
+ oldTexObj = texUnit->Current2D;
+ break;
+ case GL_TEXTURE_3D:
+ oldTexObj = texUnit->Current3D;
+ break;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" );
+ return;
+ }
+ oldTexObj = texUnit->CurrentCubeMap;
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ if (!ctx->Extensions.NV_texture_rectangle) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" );
+ return;
+ }
+ oldTexObj = texUnit->CurrentRect;
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" );
+ return;
+ }
+
+ if (oldTexObj->Name == texName)
+ /* XXX this might be wrong. If the texobj is in use by another
+ * context and a texobj parameter was changed, this might be our
+ * only chance to update this context's hardware state.
+ */
+ return; /* rebinding the same texture- no change */
+
+ /*
+ * Get pointer to new texture object (newTexObj)
+ */
+ if (texName == 0) {
+ /* newTexObj = a default texture object */
+ switch (target) {
+ case GL_TEXTURE_1D:
+ newTexObj = ctx->Shared->Default1D;
+ break;
+ case GL_TEXTURE_2D:
+ newTexObj = ctx->Shared->Default2D;
+ break;
+ case GL_TEXTURE_3D:
+ newTexObj = ctx->Shared->Default3D;
+ break;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ newTexObj = ctx->Shared->DefaultCubeMap;
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ newTexObj = ctx->Shared->DefaultRect;
+ break;
+ default:
+ ; /* Bad targets are caught above */
+ }
+ }
+ else {
+ /* non-default texture object */
+ const struct _mesa_HashTable *hash = ctx->Shared->TexObjects;
+ newTexObj = (struct gl_texture_object *) _mesa_HashLookup(hash, texName);
+ if (newTexObj) {
+ /* error checking */
+ if (newTexObj->Target != 0 && newTexObj->Target != target) {
+ /* the named texture object's dimensions don't match the target */
+ _mesa_error( ctx, GL_INVALID_OPERATION,
+ "glBindTexture(wrong dimensionality)" );
+ return;
+ }
+ if (newTexObj->Target == 0 && target == GL_TEXTURE_RECTANGLE_NV) {
+ /* have to init wrap and filter state here - kind of klunky */
+ newTexObj->WrapS = GL_CLAMP_TO_EDGE;
+ newTexObj->WrapT = GL_CLAMP_TO_EDGE;
+ newTexObj->WrapR = GL_CLAMP_TO_EDGE;
+ newTexObj->MinFilter = GL_LINEAR;
+ if (ctx->Driver.TexParameter) {
+ static const GLfloat fparam_wrap[1] = {(GLfloat) GL_CLAMP_TO_EDGE};
+ static const GLfloat fparam_filter[1] = {(GLfloat) GL_LINEAR};
+ (*ctx->Driver.TexParameter)( ctx, target, newTexObj, GL_TEXTURE_WRAP_S, fparam_wrap );
+ (*ctx->Driver.TexParameter)( ctx, target, newTexObj, GL_TEXTURE_WRAP_T, fparam_wrap );
+ (*ctx->Driver.TexParameter)( ctx, target, newTexObj, GL_TEXTURE_WRAP_R, fparam_wrap );
+ (*ctx->Driver.TexParameter)( ctx, target, newTexObj, GL_TEXTURE_MIN_FILTER, fparam_filter );
+ }
+ }
+ }
+ else {
+ /* if this is a new texture id, allocate a texture object now */
+ newTexObj = (*ctx->Driver.NewTextureObject)(ctx, texName, target);
+ if (!newTexObj) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindTexture");
+ return;
+ }
+
+ /* and insert it into hash table */
+ _glthread_LOCK_MUTEX(ctx->Shared->Mutex);
+ _mesa_HashInsert(ctx->Shared->TexObjects, texName, newTexObj);
+ _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
+ }
+ newTexObj->Target = target;
+ }
+
+ /* XXX all RefCount accesses should be protected by a mutex. */
+ newTexObj->RefCount++;
+
+ /* do the actual binding, but first flush outstanding vertices:
+ */
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+
+ switch (target) {
+ case GL_TEXTURE_1D:
+ texUnit->Current1D = newTexObj;
+ break;
+ case GL_TEXTURE_2D:
+ texUnit->Current2D = newTexObj;
+ break;
+ case GL_TEXTURE_3D:
+ texUnit->Current3D = newTexObj;
+ break;
+ case GL_TEXTURE_CUBE_MAP_ARB:
+ texUnit->CurrentCubeMap = newTexObj;
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ texUnit->CurrentRect = newTexObj;
+ break;
+ default:
+ _mesa_problem(ctx, "bad target in BindTexture");
+ return;
+ }
+
+ /* Pass BindTexture call to device driver */
+ if (ctx->Driver.BindTexture)
+ (*ctx->Driver.BindTexture)( ctx, target, newTexObj );
+
+ /* Decrement the reference count on the old texture and check if it's
+ * time to delete it.
+ */
+ /* XXX all RefCount accesses should be protected by a mutex. */
+ oldTexObj->RefCount--;
+ ASSERT(oldTexObj->RefCount >= 0);
+ if (oldTexObj->RefCount == 0) {
+ ASSERT(oldTexObj->Name != 0);
+ ASSERT(ctx->Driver.DeleteTexture);
+ (*ctx->Driver.DeleteTexture)( ctx, oldTexObj );
+ }
+}
+
+
+/**
+ * Set texture priorities.
+ *
+ * \param n number of textures.
+ * \param texName texture names.
+ * \param priorities corresponding texture priorities.
+ *
+ * \sa glPrioritizeTextures().
+ *
+ * Looks up each texture in the hash, clamps the corresponding priority between
+ * 0.0 and 1.0, and calls dd_function_table::PrioritizeTexture.
+ */
+void GLAPIENTRY
+_mesa_PrioritizeTextures( GLsizei n, const GLuint *texName,
+ const GLclampf *priorities )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i;
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (n < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glPrioritizeTextures" );
+ return;
+ }
+
+ if (!priorities)
+ return;
+
+ for (i = 0; i < n; i++) {
+ if (texName[i] > 0) {
+ struct gl_texture_object *t = (struct gl_texture_object *)
+ _mesa_HashLookup(ctx->Shared->TexObjects, texName[i]);
+ if (t) {
+ t->Priority = CLAMP( priorities[i], 0.0F, 1.0F );
+ if (ctx->Driver.PrioritizeTexture)
+ ctx->Driver.PrioritizeTexture( ctx, t, t->Priority );
+ }
+ }
+ }
+
+ ctx->NewState |= _NEW_TEXTURE;
+}
+
+/**
+ * See if textures are loaded in texture memory.
+ *
+ * \param n number of textures to query.
+ * \param texName array with the texture names.
+ * \param residences array which will hold the residence status.
+ *
+ * \return GL_TRUE if all textures are resident and \p residences is left unchanged,
+ *
+ * \sa glAreTexturesResident().
+ *
+ * Looks up each texture in the hash and calls
+ * dd_function_table::IsTextureResident.
+ */
+GLboolean GLAPIENTRY
+_mesa_AreTexturesResident(GLsizei n, const GLuint *texName,
+ GLboolean *residences)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLboolean allResident = GL_TRUE;
+ GLint i, j;
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+
+ if (n < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident(n)");
+ return GL_FALSE;
+ }
+
+ if (!texName || !residences)
+ return GL_FALSE;
+
+ for (i = 0; i < n; i++) {
+ struct gl_texture_object *t;
+ if (texName[i] == 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident");
+ return GL_FALSE;
+ }
+ t = (struct gl_texture_object *)
+ _mesa_HashLookup(ctx->Shared->TexObjects, texName[i]);
+ if (!t) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glAreTexturesResident");
+ return GL_FALSE;
+ }
+ if (!ctx->Driver.IsTextureResident ||
+ ctx->Driver.IsTextureResident(ctx, t)) {
+ /* The texture is resident */
+ if (!allResident)
+ residences[i] = GL_TRUE;
+ }
+ else {
+ /* The texture is not resident */
+ if (allResident) {
+ allResident = GL_FALSE;
+ for (j = 0; j < i; j++)
+ residences[j] = GL_TRUE;
+ }
+ residences[i] = GL_FALSE;
+ }
+ }
+
+ return allResident;
+}
+
+/**
+ * See if a name corresponds to a texture.
+ *
+ * \param texture texture name.
+ *
+ * \return GL_TRUE if texture name corresponds to a texture, or GL_FALSE
+ * otherwise.
+ *
+ * \sa glIsTexture().
+ *
+ * Calls _mesa_HashLookup().
+ */
+GLboolean GLAPIENTRY
+_mesa_IsTexture( GLuint texture )
+{
+ struct gl_texture_object *t;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+
+ if (!texture)
+ return GL_FALSE;
+
+ t = (struct gl_texture_object *)
+ _mesa_HashLookup(ctx->Shared->TexObjects, texture);
+
+ /* IsTexture is true only after object has been bound once. */
+ return t && t->Target;
+}
+
+/*@}*/
diff --git a/nx-X11/extras/Mesa/src/mesa/main/texobj.h b/nx-X11/extras/Mesa/src/mesa/main/texobj.h
new file mode 100644
index 000000000..d00bf70a0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/texobj.h
@@ -0,0 +1,95 @@
+/**
+ * \file texobj.h
+ * Texture object management.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef TEXTOBJ_H
+#define TEXTOBJ_H
+
+
+#include "mtypes.h"
+
+
+/**
+ * \name Internal functions
+ */
+/*@{*/
+
+extern struct gl_texture_object *
+_mesa_new_texture_object( GLcontext *ctx, GLuint name, GLenum target );
+
+extern void
+_mesa_initialize_texture_object( struct gl_texture_object *obj,
+ GLuint name, GLenum target );
+
+extern void
+_mesa_delete_texture_object( GLcontext *ctx, struct gl_texture_object *obj );
+
+extern void
+_mesa_copy_texture_object( struct gl_texture_object *dest,
+ const struct gl_texture_object *src );
+
+extern void
+_mesa_test_texobj_completeness( const GLcontext *ctx,
+ struct gl_texture_object *obj );
+
+/*@}*/
+
+
+/**
+ * \name API functions
+ */
+/*@{*/
+
+extern void GLAPIENTRY
+_mesa_GenTextures( GLsizei n, GLuint *textures );
+
+
+extern void GLAPIENTRY
+_mesa_DeleteTextures( GLsizei n, const GLuint *textures );
+
+
+extern void GLAPIENTRY
+_mesa_BindTexture( GLenum target, GLuint texture );
+
+
+extern void GLAPIENTRY
+_mesa_PrioritizeTextures( GLsizei n, const GLuint *textures,
+ const GLclampf *priorities );
+
+
+extern GLboolean GLAPIENTRY
+_mesa_AreTexturesResident( GLsizei n, const GLuint *textures,
+ GLboolean *residences );
+
+extern GLboolean GLAPIENTRY
+_mesa_IsTexture( GLuint texture );
+
+/*@}*/
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/texrender.c b/nx-X11/extras/Mesa/src/mesa/main/texrender.c
new file mode 100644
index 000000000..92f3f7377
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/texrender.c
@@ -0,0 +1,226 @@
+
+#include "context.h"
+#include "fbobject.h"
+#include "texrender.h"
+#include "renderbuffer.h"
+
+
+/*
+ * Render-to-texture code for GL_EXT_framebuffer_object
+ */
+
+
+/**
+ * Derived from gl_renderbuffer class
+ */
+struct texture_renderbuffer
+{
+ struct gl_renderbuffer Base; /* Base class object */
+ struct gl_texture_image *TexImage;
+ StoreTexelFunc Store;
+ GLint Zoffset;
+};
+
+
+
+static void
+texture_get_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, void *values)
+{
+ const struct texture_renderbuffer *trb
+ = (const struct texture_renderbuffer *) rb;
+ const GLint z = trb->Zoffset;
+ GLchan *rgbaOut = (GLchan *) values;
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ trb->TexImage->FetchTexelc(trb->TexImage, x + i, y, z, rgbaOut + 4 * i);
+ }
+}
+
+static void
+texture_get_values(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], void *values)
+{
+ const struct texture_renderbuffer *trb
+ = (const struct texture_renderbuffer *) rb;
+ const GLint z = trb->Zoffset;
+ GLchan *rgbaOut = (GLchan *) values;
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ trb->TexImage->FetchTexelc(trb->TexImage, x[i], y[i], z,
+ rgbaOut + 4 * i);
+ }
+}
+
+static void
+texture_put_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *values, const GLubyte *mask)
+{
+ const struct texture_renderbuffer *trb
+ = (const struct texture_renderbuffer *) rb;
+ const GLint z = trb->Zoffset;
+ const GLchan *rgba = (const GLchan *) values;
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ trb->Store(trb->TexImage, x + i, y, z, rgba);
+ }
+ rgba += 4;
+ }
+}
+
+static void
+texture_put_mono_row(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ GLint x, GLint y, const void *value, const GLubyte *mask)
+{
+ const struct texture_renderbuffer *trb
+ = (const struct texture_renderbuffer *) rb;
+ const GLint z = trb->Zoffset;
+ const GLchan *rgba = (const GLchan *) value;
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ trb->Store(trb->TexImage, x + i, y, z, rgba);
+ }
+ }
+}
+
+static void
+texture_put_values(GLcontext *ctx, struct gl_renderbuffer *rb, GLuint count,
+ const GLint x[], const GLint y[], const void *values,
+ const GLubyte *mask)
+{
+ const struct texture_renderbuffer *trb
+ = (const struct texture_renderbuffer *) rb;
+ const GLint z = trb->Zoffset;
+ const GLchan *rgba = (const GLchan *) values;
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ trb->Store(trb->TexImage, x[i], y[i], z, rgba);
+ }
+ rgba += 4;
+ }
+}
+
+static void
+texture_put_mono_values(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte *mask)
+{
+ const struct texture_renderbuffer *trb
+ = (const struct texture_renderbuffer *) rb;
+ const GLint z = trb->Zoffset;
+ const GLchan *rgba = (const GLchan *) value;
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+ trb->Store(trb->TexImage, x[i], y[i], z, rgba);
+ }
+ }
+}
+
+
+static void
+delete_texture_wrapper(struct gl_renderbuffer *rb)
+{
+ _mesa_free(rb);
+}
+
+
+/**
+ * If a render buffer attachment specifies a texture image, we'll use
+ * this function to make a gl_renderbuffer wrapper around the texture image.
+ * This allows other parts of Mesa to access the texture image as if it
+ * was a renderbuffer.
+ */
+static void
+wrap_texture(GLcontext *ctx, struct gl_renderbuffer_attachment *att)
+{
+ struct texture_renderbuffer *trb;
+ const GLuint name = 0;
+
+ ASSERT(att->Type == GL_TEXTURE);
+ ASSERT(att->Renderbuffer == NULL);
+ /*
+ ASSERT(att->Complete);
+ */
+
+ trb = CALLOC_STRUCT(texture_renderbuffer);
+ if (!trb) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "wrap_texture");
+ return;
+ }
+
+ _mesa_init_renderbuffer(&trb->Base, name);
+
+ trb->TexImage = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
+ assert(trb->TexImage);
+
+ trb->Store = trb->TexImage->TexFormat->StoreTexel;
+ assert(trb->Store);
+
+ trb->Zoffset = att->Zoffset;
+
+ trb->Base.Width = trb->TexImage->Width;
+ trb->Base.Height = trb->TexImage->Height;
+ trb->Base.InternalFormat = trb->TexImage->IntFormat; /* XXX fix? */
+ trb->Base._BaseFormat = trb->TexImage->TexFormat->BaseFormat;
+#if 0
+ /* fix/avoid this assertion someday */
+ assert(trb->Base._BaseFormat == GL_RGB ||
+ trb->Base._BaseFormat == GL_RGBA ||
+ trb->Base._BaseFormat == GL_DEPTH_COMPONENT);
+#endif
+ trb->Base.DataType = GL_UNSIGNED_BYTE; /* XXX fix! */
+ trb->Base.Data = trb->TexImage->Data;
+
+ trb->Base.GetRow = texture_get_row;
+ trb->Base.GetValues = texture_get_values;
+ trb->Base.PutRow = texture_put_row;
+ trb->Base.PutMonoRow = texture_put_mono_row;
+ trb->Base.PutValues = texture_put_values;
+ trb->Base.PutMonoValues = texture_put_mono_values;
+
+ trb->Base.Delete = delete_texture_wrapper;
+ trb->Base.AllocStorage = NULL; /* illegal! */
+
+ /* XXX fix these */
+ if (trb->Base._BaseFormat == GL_DEPTH_COMPONENT) {
+ trb->Base.ComponentSizes[3] = trb->TexImage->TexFormat->DepthBits;
+ }
+ else {
+ trb->Base.ComponentSizes[0] = trb->TexImage->TexFormat->RedBits;
+ trb->Base.ComponentSizes[1] = trb->TexImage->TexFormat->GreenBits;
+ trb->Base.ComponentSizes[2] = trb->TexImage->TexFormat->BlueBits;
+ trb->Base.ComponentSizes[3] = trb->TexImage->TexFormat->AlphaBits;
+ }
+
+ att->Renderbuffer = &(trb->Base);
+}
+
+
+
+/**
+ * Software fallback for ctx->Driver.RenderbufferTexture.
+ * This is called via the glRenderbufferTexture1D/2D/3D() functions.
+ * If we're unbinding a texture, texObj will be NULL.
+ * The framebuffer of interest is ctx->DrawBuffer.
+ * \sa _mesa_framebuffer_renderbuffer
+ */
+void
+_mesa_renderbuffer_texture(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_texture_object *texObj,
+ GLenum texTarget, GLuint level, GLuint zoffset)
+{
+ if (texObj) {
+ _mesa_set_texture_attachment(ctx, att, texObj,
+ texTarget, level, zoffset);
+
+ wrap_texture(ctx, att);
+ }
+ else {
+ _mesa_remove_attachment(ctx, att);
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/texrender.h b/nx-X11/extras/Mesa/src/mesa/main/texrender.h
new file mode 100644
index 000000000..6d8bc9641
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/texrender.h
@@ -0,0 +1,12 @@
+#ifndef TEXRENDER_H
+#define TEXRENDER_H
+
+
+extern void
+_mesa_renderbuffer_texture(GLcontext *ctx,
+ struct gl_renderbuffer_attachment *att,
+ struct gl_texture_object *texObj,
+ GLenum texTarget, GLuint level, GLuint zoffset);
+
+
+#endif /* TEXRENDER_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/main/texstate.c b/nx-X11/extras/Mesa/src/mesa/main/texstate.c
new file mode 100644
index 000000000..8ac41a277
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/texstate.c
@@ -0,0 +1,3271 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file texstate.c
+ *
+ * Texture state handling.
+ */
+
+#include "glheader.h"
+#include "colormac.h"
+#include "colortab.h"
+#include "context.h"
+#include "enums.h"
+#include "extensions.h"
+#include "macros.h"
+#include "nvfragprog.h"
+#include "texobj.h"
+#include "teximage.h"
+#include "texstate.h"
+#include "texenvprogram.h"
+#include "mtypes.h"
+#include "math/m_xform.h"
+#include "math/m_matrix.h"
+
+
+
+#ifdef SPECIALCAST
+/* Needed for an Amiga compiler */
+#define ENUM_TO_FLOAT(X) ((GLfloat)(GLint)(X))
+#define ENUM_TO_DOUBLE(X) ((GLdouble)(GLint)(X))
+#else
+/* all other compilers */
+#define ENUM_TO_FLOAT(X) ((GLfloat)(X))
+#define ENUM_TO_DOUBLE(X) ((GLdouble)(X))
+#endif
+
+/**
+ * Default texture combine environment state. This is used to initialize
+ * a context's texture units and as the basis for converting "classic"
+ * texture environmnets to ARB_texture_env_combine style values.
+ */
+static const struct gl_tex_env_combine_state default_combine_state = {
+ GL_MODULATE, GL_MODULATE,
+ { GL_TEXTURE, GL_PREVIOUS, GL_CONSTANT },
+ { GL_TEXTURE, GL_PREVIOUS, GL_CONSTANT },
+ { GL_SRC_COLOR, GL_SRC_COLOR, GL_SRC_ALPHA },
+ { GL_SRC_ALPHA, GL_SRC_ALPHA, GL_SRC_ALPHA },
+ 0, 0,
+ 2, 2
+};
+
+
+void
+_mesa_copy_texture_state( const GLcontext *src, GLcontext *dst )
+{
+ GLuint i;
+
+ ASSERT(src);
+ ASSERT(dst);
+
+ dst->Texture.CurrentUnit = src->Texture.CurrentUnit;
+ dst->Texture._GenFlags = src->Texture._GenFlags;
+ dst->Texture._TexGenEnabled = src->Texture._TexGenEnabled;
+ dst->Texture._TexMatEnabled = src->Texture._TexMatEnabled;
+ dst->Texture.SharedPalette = src->Texture.SharedPalette;
+
+ /* per-unit state */
+ for (i = 0; i < src->Const.MaxTextureUnits; i++) {
+ dst->Texture.Unit[i].Enabled = src->Texture.Unit[i].Enabled;
+ dst->Texture.Unit[i].EnvMode = src->Texture.Unit[i].EnvMode;
+ COPY_4V(dst->Texture.Unit[i].EnvColor, src->Texture.Unit[i].EnvColor);
+ dst->Texture.Unit[i].TexGenEnabled = src->Texture.Unit[i].TexGenEnabled;
+ dst->Texture.Unit[i].GenModeS = src->Texture.Unit[i].GenModeS;
+ dst->Texture.Unit[i].GenModeT = src->Texture.Unit[i].GenModeT;
+ dst->Texture.Unit[i].GenModeR = src->Texture.Unit[i].GenModeR;
+ dst->Texture.Unit[i].GenModeQ = src->Texture.Unit[i].GenModeQ;
+ dst->Texture.Unit[i]._GenBitS = src->Texture.Unit[i]._GenBitS;
+ dst->Texture.Unit[i]._GenBitT = src->Texture.Unit[i]._GenBitT;
+ dst->Texture.Unit[i]._GenBitR = src->Texture.Unit[i]._GenBitR;
+ dst->Texture.Unit[i]._GenBitQ = src->Texture.Unit[i]._GenBitQ;
+ dst->Texture.Unit[i]._GenFlags = src->Texture.Unit[i]._GenFlags;
+ COPY_4V(dst->Texture.Unit[i].ObjectPlaneS, src->Texture.Unit[i].ObjectPlaneS);
+ COPY_4V(dst->Texture.Unit[i].ObjectPlaneT, src->Texture.Unit[i].ObjectPlaneT);
+ COPY_4V(dst->Texture.Unit[i].ObjectPlaneR, src->Texture.Unit[i].ObjectPlaneR);
+ COPY_4V(dst->Texture.Unit[i].ObjectPlaneQ, src->Texture.Unit[i].ObjectPlaneQ);
+ COPY_4V(dst->Texture.Unit[i].EyePlaneS, src->Texture.Unit[i].EyePlaneS);
+ COPY_4V(dst->Texture.Unit[i].EyePlaneT, src->Texture.Unit[i].EyePlaneT);
+ COPY_4V(dst->Texture.Unit[i].EyePlaneR, src->Texture.Unit[i].EyePlaneR);
+ COPY_4V(dst->Texture.Unit[i].EyePlaneQ, src->Texture.Unit[i].EyePlaneQ);
+ dst->Texture.Unit[i].LodBias = src->Texture.Unit[i].LodBias;
+
+ /* GL_EXT_texture_env_combine */
+ dst->Texture.Unit[i].Combine.ModeRGB = src->Texture.Unit[i].Combine.ModeRGB;
+ dst->Texture.Unit[i].Combine.ModeA = src->Texture.Unit[i].Combine.ModeA;
+ COPY_3V(dst->Texture.Unit[i].Combine.SourceRGB, src->Texture.Unit[i].Combine.SourceRGB);
+ COPY_3V(dst->Texture.Unit[i].Combine.SourceA, src->Texture.Unit[i].Combine.SourceA);
+ COPY_3V(dst->Texture.Unit[i].Combine.OperandRGB, src->Texture.Unit[i].Combine.OperandRGB);
+ COPY_3V(dst->Texture.Unit[i].Combine.OperandA, src->Texture.Unit[i].Combine.OperandA);
+ dst->Texture.Unit[i].Combine.ScaleShiftRGB = src->Texture.Unit[i].Combine.ScaleShiftRGB;
+ dst->Texture.Unit[i].Combine.ScaleShiftA = src->Texture.Unit[i].Combine.ScaleShiftA;
+
+ /* texture object state */
+ _mesa_copy_texture_object(dst->Texture.Unit[i].Current1D,
+ src->Texture.Unit[i].Current1D);
+ _mesa_copy_texture_object(dst->Texture.Unit[i].Current2D,
+ src->Texture.Unit[i].Current2D);
+ _mesa_copy_texture_object(dst->Texture.Unit[i].Current3D,
+ src->Texture.Unit[i].Current3D);
+ _mesa_copy_texture_object(dst->Texture.Unit[i].CurrentCubeMap,
+ src->Texture.Unit[i].CurrentCubeMap);
+ _mesa_copy_texture_object(dst->Texture.Unit[i].CurrentRect,
+ src->Texture.Unit[i].CurrentRect);
+ }
+}
+
+
+/*
+ * For debugging
+ */
+void
+_mesa_print_texunit_state( GLcontext *ctx, GLuint unit )
+{
+ const struct gl_texture_unit *texUnit = ctx->Texture.Unit + unit;
+ _mesa_printf("Texture Unit %d\n", unit);
+ _mesa_printf(" GL_TEXTURE_ENV_MODE = %s\n", _mesa_lookup_enum_by_nr(texUnit->EnvMode));
+ _mesa_printf(" GL_COMBINE_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeRGB));
+ _mesa_printf(" GL_COMBINE_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.ModeA));
+ _mesa_printf(" GL_SOURCE0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[0]));
+ _mesa_printf(" GL_SOURCE1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[1]));
+ _mesa_printf(" GL_SOURCE2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceRGB[2]));
+ _mesa_printf(" GL_SOURCE0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[0]));
+ _mesa_printf(" GL_SOURCE1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[1]));
+ _mesa_printf(" GL_SOURCE2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.SourceA[2]));
+ _mesa_printf(" GL_OPERAND0_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[0]));
+ _mesa_printf(" GL_OPERAND1_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[1]));
+ _mesa_printf(" GL_OPERAND2_RGB = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandRGB[2]));
+ _mesa_printf(" GL_OPERAND0_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[0]));
+ _mesa_printf(" GL_OPERAND1_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[1]));
+ _mesa_printf(" GL_OPERAND2_ALPHA = %s\n", _mesa_lookup_enum_by_nr(texUnit->Combine.OperandA[2]));
+ _mesa_printf(" GL_RGB_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftRGB);
+ _mesa_printf(" GL_ALPHA_SCALE = %d\n", 1 << texUnit->Combine.ScaleShiftA);
+ _mesa_printf(" GL_TEXTURE_ENV_COLOR = (%f, %f, %f, %f)\n", texUnit->EnvColor[0], texUnit->EnvColor[1], texUnit->EnvColor[2], texUnit->EnvColor[3]);
+}
+
+
+
+/**********************************************************************/
+/* Texture Environment */
+/**********************************************************************/
+
+/**
+ * Convert "classic" texture environment to ARB_texture_env_combine style
+ * environments.
+ *
+ * \param state texture_env_combine state vector to be filled-in.
+ * \param mode Classic texture environment mode (i.e., \c GL_REPLACE,
+ * \c GL_BLEND, \c GL_DECAL, etc.).
+ * \param texBaseFormat Base format of the texture associated with the
+ * texture unit.
+ */
+static void
+calculate_derived_texenv( struct gl_tex_env_combine_state *state,
+ GLenum mode, GLenum texBaseFormat )
+{
+ GLenum mode_rgb;
+ GLenum mode_a;
+
+ *state = default_combine_state;
+
+ switch (texBaseFormat) {
+ case GL_ALPHA:
+ state->SourceRGB[0] = GL_PREVIOUS;
+ break;
+
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ case GL_RGBA:
+ break;
+
+ case GL_LUMINANCE:
+ case GL_RGB:
+ case GL_YCBCR_MESA:
+ state->SourceA[0] = GL_PREVIOUS;
+ break;
+
+ default:
+ _mesa_problem(NULL, "Invalid texBaseFormat in calculate_derived_texenv");
+ return;
+ }
+
+ switch (mode) {
+ case GL_REPLACE:
+ case GL_MODULATE:
+ mode_rgb = (texBaseFormat == GL_ALPHA) ? GL_REPLACE : mode;
+ mode_a = mode;
+ break;
+
+ case GL_DECAL:
+ mode_rgb = GL_INTERPOLATE;
+ mode_a = GL_REPLACE;
+
+ state->SourceA[0] = GL_PREVIOUS;
+
+ /* Having alpha / luminance / intensity textures replace using the
+ * incoming fragment color matches the definition in NV_texture_shader.
+ * The 1.5 spec simply marks these as "undefined".
+ */
+ switch (texBaseFormat) {
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ state->SourceRGB[0] = GL_PREVIOUS;
+ break;
+ case GL_RGB:
+ case GL_YCBCR_MESA:
+ mode_rgb = GL_REPLACE;
+ break;
+ case GL_RGBA:
+ state->SourceRGB[2] = GL_TEXTURE;
+ break;
+ }
+ break;
+
+ case GL_BLEND:
+ mode_rgb = GL_INTERPOLATE;
+ mode_a = GL_MODULATE;
+
+ switch (texBaseFormat) {
+ case GL_ALPHA:
+ mode_rgb = GL_REPLACE;
+ break;
+ case GL_INTENSITY:
+ mode_a = GL_INTERPOLATE;
+ state->SourceA[0] = GL_CONSTANT;
+ state->OperandA[2] = GL_SRC_ALPHA;
+ /* FALLTHROUGH */
+ case GL_LUMINANCE:
+ case GL_RGB:
+ case GL_LUMINANCE_ALPHA:
+ case GL_RGBA:
+ case GL_YCBCR_MESA:
+ state->SourceRGB[2] = GL_TEXTURE;
+ state->SourceA[2] = GL_TEXTURE;
+ state->SourceRGB[0] = GL_CONSTANT;
+ state->OperandRGB[2] = GL_SRC_COLOR;
+ break;
+ }
+ break;
+
+ case GL_ADD:
+ mode_rgb = (texBaseFormat == GL_ALPHA) ? GL_REPLACE : GL_ADD;
+ mode_a = (texBaseFormat == GL_INTENSITY) ? GL_ADD : GL_MODULATE;
+ break;
+
+ default:
+ _mesa_problem(NULL,
+ "Invalid texture env mode in calculate_derived_texenv");
+ return;
+ }
+
+ state->ModeRGB = (state->SourceRGB[0] != GL_PREVIOUS)
+ ? mode_rgb : GL_REPLACE;
+ state->ModeA = (state->SourceA[0] != GL_PREVIOUS)
+ ? mode_a : GL_REPLACE;
+}
+
+
+void GLAPIENTRY
+_mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+#define TE_ERROR(errCode, msg, value) \
+ _mesa_error(ctx, errCode, msg, _mesa_lookup_enum_by_nr(value));
+
+ if (target == GL_TEXTURE_ENV) {
+ switch (pname) {
+ case GL_TEXTURE_ENV_MODE:
+ {
+ const GLenum mode = (GLenum) (GLint) *param;
+ if (texUnit->EnvMode == mode)
+ return;
+ if (mode == GL_MODULATE ||
+ mode == GL_BLEND ||
+ mode == GL_DECAL ||
+ mode == GL_REPLACE ||
+ (mode == GL_ADD && ctx->Extensions.EXT_texture_env_add) ||
+ (mode == GL_COMBINE &&
+ (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine))) {
+ /* legal */
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->EnvMode = mode;
+ }
+ else {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
+ return;
+ }
+ }
+ break;
+ case GL_TEXTURE_ENV_COLOR:
+ {
+ GLfloat tmp[4];
+ tmp[0] = CLAMP( param[0], 0.0F, 1.0F );
+ tmp[1] = CLAMP( param[1], 0.0F, 1.0F );
+ tmp[2] = CLAMP( param[2], 0.0F, 1.0F );
+ tmp[3] = CLAMP( param[3], 0.0F, 1.0F );
+ if (TEST_EQ_4V(tmp, texUnit->EnvColor))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ COPY_4FV(texUnit->EnvColor, tmp);
+ }
+ break;
+ case GL_COMBINE_RGB:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ const GLenum mode = (GLenum) (GLint) *param;
+ if (texUnit->Combine.ModeRGB == mode)
+ return;
+ switch (mode) {
+ case GL_REPLACE:
+ case GL_MODULATE:
+ case GL_ADD:
+ case GL_ADD_SIGNED:
+ case GL_INTERPOLATE:
+ /* OK */
+ break;
+ case GL_SUBTRACT:
+ if (!ctx->Extensions.ARB_texture_env_combine) {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
+ return;
+ }
+ break;
+ case GL_DOT3_RGB_EXT:
+ case GL_DOT3_RGBA_EXT:
+ if (!ctx->Extensions.EXT_texture_env_dot3) {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
+ return;
+ }
+ break;
+ case GL_DOT3_RGB:
+ case GL_DOT3_RGBA:
+ if (!ctx->Extensions.ARB_texture_env_dot3) {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
+ return;
+ }
+ break;
+ case GL_MODULATE_ADD_ATI:
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ case GL_MODULATE_SUBTRACT_ATI:
+ if (!ctx->Extensions.ATI_texture_env_combine3) {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
+ return;
+ }
+ break;
+ default:
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
+ return;
+ }
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->Combine.ModeRGB = mode;
+ }
+ else {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
+ return;
+ }
+ break;
+ case GL_COMBINE_ALPHA:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ const GLenum mode = (GLenum) (GLint) *param;
+ if (texUnit->Combine.ModeA == mode)
+ return;
+ switch (mode) {
+ case GL_REPLACE:
+ case GL_MODULATE:
+ case GL_ADD:
+ case GL_ADD_SIGNED:
+ case GL_INTERPOLATE:
+ /* OK */
+ break;
+ case GL_SUBTRACT:
+ if (!ctx->Extensions.ARB_texture_env_combine) {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
+ return;
+ }
+ break;
+ case GL_MODULATE_ADD_ATI:
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ case GL_MODULATE_SUBTRACT_ATI:
+ if (!ctx->Extensions.ATI_texture_env_combine3) {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
+ return;
+ }
+ break;
+ default:
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", mode);
+ return;
+ }
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->Combine.ModeA = mode;
+ }
+ else {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
+ return;
+ }
+ break;
+ case GL_SOURCE0_RGB:
+ case GL_SOURCE1_RGB:
+ case GL_SOURCE2_RGB:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ const GLenum source = (GLenum) (GLint) *param;
+ const GLuint s = pname - GL_SOURCE0_RGB;
+ if (texUnit->Combine.SourceRGB[s] == source)
+ return;
+ if (source == GL_TEXTURE ||
+ source == GL_CONSTANT ||
+ source == GL_PRIMARY_COLOR ||
+ source == GL_PREVIOUS ||
+ (ctx->Extensions.ARB_texture_env_crossbar &&
+ source >= GL_TEXTURE0 &&
+ source < GL_TEXTURE0 + ctx->Const.MaxTextureUnits) ||
+ (ctx->Extensions.ATI_texture_env_combine3 &&
+ (source == GL_ZERO || source == GL_ONE))) {
+ /* legal */
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->Combine.SourceRGB[s] = source;
+ }
+ else {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", source);
+ return;
+ }
+ }
+ else {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
+ return;
+ }
+ break;
+ case GL_SOURCE0_ALPHA:
+ case GL_SOURCE1_ALPHA:
+ case GL_SOURCE2_ALPHA:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ const GLenum source = (GLenum) (GLint) *param;
+ const GLuint s = pname - GL_SOURCE0_ALPHA;
+ if (texUnit->Combine.SourceA[s] == source)
+ return;
+ if (source == GL_TEXTURE ||
+ source == GL_CONSTANT ||
+ source == GL_PRIMARY_COLOR ||
+ source == GL_PREVIOUS ||
+ (ctx->Extensions.ARB_texture_env_crossbar &&
+ source >= GL_TEXTURE0 &&
+ source < GL_TEXTURE0 + ctx->Const.MaxTextureUnits) ||
+ (ctx->Extensions.ATI_texture_env_combine3 &&
+ (source == GL_ZERO || source == GL_ONE))) {
+ /* legal */
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->Combine.SourceA[s] = source;
+ }
+ else {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", source);
+ return;
+ }
+ }
+ else {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
+ return;
+ }
+ break;
+ case GL_OPERAND0_RGB:
+ case GL_OPERAND1_RGB:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ const GLenum operand = (GLenum) (GLint) *param;
+ const GLuint s = pname - GL_OPERAND0_RGB;
+ if (texUnit->Combine.OperandRGB[s] == operand)
+ return;
+ switch (operand) {
+ case GL_SRC_COLOR:
+ case GL_ONE_MINUS_SRC_COLOR:
+ case GL_SRC_ALPHA:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->Combine.OperandRGB[s] = operand;
+ break;
+ default:
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", operand);
+ return;
+ }
+ }
+ else {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
+ return;
+ }
+ break;
+ case GL_OPERAND0_ALPHA:
+ case GL_OPERAND1_ALPHA:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ const GLenum operand = (GLenum) (GLint) *param;
+ if (texUnit->Combine.OperandA[pname-GL_OPERAND0_ALPHA] == operand)
+ return;
+ switch (operand) {
+ case GL_SRC_ALPHA:
+ case GL_ONE_MINUS_SRC_ALPHA:
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->Combine.OperandA[pname-GL_OPERAND0_ALPHA] = operand;
+ break;
+ default:
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", operand);
+ return;
+ }
+ }
+ else {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
+ return;
+ }
+ break;
+ case GL_OPERAND2_RGB:
+ if (ctx->Extensions.ARB_texture_env_combine) {
+ const GLenum operand = (GLenum) (GLint) *param;
+ if (texUnit->Combine.OperandRGB[2] == operand)
+ return;
+ switch (operand) {
+ case GL_SRC_COLOR: /* ARB combine only */
+ case GL_ONE_MINUS_SRC_COLOR: /* ARB combine only */
+ case GL_SRC_ALPHA:
+ case GL_ONE_MINUS_SRC_ALPHA: /* ARB combine only */
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->Combine.OperandRGB[2] = operand;
+ break;
+ default:
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", operand);
+ return;
+ }
+ }
+ else if (ctx->Extensions.EXT_texture_env_combine) {
+ const GLenum operand = (GLenum) (GLint) *param;
+ if (texUnit->Combine.OperandRGB[2] == operand)
+ return;
+ /* operand must be GL_SRC_ALPHA which is the initial value - thus
+ don't need to actually compare the operand to the possible value */
+ else {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", operand);
+ return;
+ }
+ }
+ else {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
+ return;
+ }
+ break;
+ case GL_OPERAND2_ALPHA:
+ if (ctx->Extensions.ARB_texture_env_combine) {
+ const GLenum operand = (GLenum) (GLint) *param;
+ if (texUnit->Combine.OperandA[2] == operand)
+ return;
+ switch (operand) {
+ case GL_SRC_ALPHA:
+ case GL_ONE_MINUS_SRC_ALPHA: /* ARB combine only */
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->Combine.OperandA[2] = operand;
+ break;
+ default:
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", operand);
+ return;
+ }
+ }
+ else if (ctx->Extensions.EXT_texture_env_combine) {
+ const GLenum operand = (GLenum) (GLint) *param;
+ if (texUnit->Combine.OperandA[2] == operand)
+ return;
+ /* operand must be GL_SRC_ALPHA which is the initial value - thus
+ don't need to actually compare the operand to the possible value */
+ else {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(param=%s)", operand);
+ return;
+ }
+ }
+ else {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
+ return;
+ }
+ break;
+ case GL_RGB_SCALE:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ GLuint newshift;
+ if (*param == 1.0) {
+ newshift = 0;
+ }
+ else if (*param == 2.0) {
+ newshift = 1;
+ }
+ else if (*param == 4.0) {
+ newshift = 2;
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_VALUE,
+ "glTexEnv(GL_RGB_SCALE not 1, 2 or 4)" );
+ return;
+ }
+ if (texUnit->Combine.ScaleShiftRGB == newshift)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->Combine.ScaleShiftRGB = newshift;
+ }
+ else {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
+ return;
+ }
+ break;
+ case GL_ALPHA_SCALE:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ GLuint newshift;
+ if (*param == 1.0) {
+ newshift = 0;
+ }
+ else if (*param == 2.0) {
+ newshift = 1;
+ }
+ else if (*param == 4.0) {
+ newshift = 2;
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_VALUE,
+ "glTexEnv(GL_ALPHA_SCALE not 1, 2 or 4)" );
+ return;
+ }
+ if (texUnit->Combine.ScaleShiftA == newshift)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->Combine.ScaleShiftA = newshift;
+ }
+ else {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
+ return;
+ }
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" );
+ return;
+ }
+ }
+ else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) {
+ /* GL_EXT_texture_lod_bias */
+ if (!ctx->Extensions.EXT_texture_lod_bias) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)", target );
+ return;
+ }
+ if (pname == GL_TEXTURE_LOD_BIAS_EXT) {
+ if (texUnit->LodBias == param[0])
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->LodBias = param[0];
+ }
+ else {
+ TE_ERROR(GL_INVALID_ENUM, "glTexEnv(pname=%s)", pname);
+ return;
+ }
+ }
+ else if (target == GL_POINT_SPRITE_NV) {
+ /* GL_ARB_point_sprite / GL_NV_point_sprite */
+ if (!ctx->Extensions.NV_point_sprite
+ && !ctx->Extensions.ARB_point_sprite) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)", target );
+ return;
+ }
+ if (pname == GL_COORD_REPLACE_NV) {
+ const GLenum value = (GLenum) param[0];
+ if (value == GL_TRUE || value == GL_FALSE) {
+ /* It's kind of weird to set point state via glTexEnv,
+ * but that's what the spec calls for.
+ */
+ const GLboolean state = (GLboolean) value;
+ if (ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] == state)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_POINT);
+ ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] = state;
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", value);
+ return;
+ }
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname=0x%x)", pname );
+ return;
+ }
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(target=0x%x)",target );
+ return;
+ }
+
+ if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE))
+ _mesa_debug(ctx, "glTexEnv %s %s %.1f(%s) ...\n",
+ _mesa_lookup_enum_by_nr(target),
+ _mesa_lookup_enum_by_nr(pname),
+ *param,
+ _mesa_lookup_enum_by_nr((GLenum) (GLint) *param));
+
+ /* Tell device driver about the new texture environment */
+ if (ctx->Driver.TexEnv) {
+ (*ctx->Driver.TexEnv)( ctx, target, pname, param );
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_TexEnvf( GLenum target, GLenum pname, GLfloat param )
+{
+ _mesa_TexEnvfv( target, pname, &param );
+}
+
+
+
+void GLAPIENTRY
+_mesa_TexEnvi( GLenum target, GLenum pname, GLint param )
+{
+ GLfloat p[4];
+ p[0] = (GLfloat) param;
+ p[1] = p[2] = p[3] = 0.0;
+ _mesa_TexEnvfv( target, pname, p );
+}
+
+
+void GLAPIENTRY
+_mesa_TexEnviv( GLenum target, GLenum pname, const GLint *param )
+{
+ GLfloat p[4];
+ if (pname == GL_TEXTURE_ENV_COLOR) {
+ p[0] = INT_TO_FLOAT( param[0] );
+ p[1] = INT_TO_FLOAT( param[1] );
+ p[2] = INT_TO_FLOAT( param[2] );
+ p[3] = INT_TO_FLOAT( param[3] );
+ }
+ else {
+ p[0] = (GLfloat) param[0];
+ p[1] = p[2] = p[3] = 0; /* init to zero, just to be safe */
+ }
+ _mesa_TexEnvfv( target, pname, p );
+}
+
+
+void GLAPIENTRY
+_mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target == GL_TEXTURE_ENV) {
+ switch (pname) {
+ case GL_TEXTURE_ENV_MODE:
+ *params = ENUM_TO_FLOAT(texUnit->EnvMode);
+ break;
+ case GL_TEXTURE_ENV_COLOR:
+ COPY_4FV( params, texUnit->EnvColor );
+ break;
+ case GL_COMBINE_RGB:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLfloat) texUnit->Combine.ModeRGB;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ }
+ break;
+ case GL_COMBINE_ALPHA:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLfloat) texUnit->Combine.ModeA;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ }
+ break;
+ case GL_SOURCE0_RGB:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLfloat) texUnit->Combine.SourceRGB[0];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ }
+ break;
+ case GL_SOURCE1_RGB:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLfloat) texUnit->Combine.SourceRGB[1];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ }
+ break;
+ case GL_SOURCE2_RGB:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLfloat) texUnit->Combine.SourceRGB[2];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ }
+ break;
+ case GL_SOURCE0_ALPHA:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLfloat) texUnit->Combine.SourceA[0];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ }
+ break;
+ case GL_SOURCE1_ALPHA:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLfloat) texUnit->Combine.SourceA[1];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ }
+ break;
+ case GL_SOURCE2_ALPHA:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLfloat) texUnit->Combine.SourceA[2];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ }
+ break;
+ case GL_OPERAND0_RGB:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLfloat) texUnit->Combine.OperandRGB[0];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ }
+ break;
+ case GL_OPERAND1_RGB:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLfloat) texUnit->Combine.OperandRGB[1];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ }
+ break;
+ case GL_OPERAND2_RGB:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLfloat) texUnit->Combine.OperandRGB[2];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ }
+ break;
+ case GL_OPERAND0_ALPHA:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLfloat) texUnit->Combine.OperandA[0];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ }
+ break;
+ case GL_OPERAND1_ALPHA:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLfloat) texUnit->Combine.OperandA[1];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ }
+ break;
+ case GL_OPERAND2_ALPHA:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLfloat) texUnit->Combine.OperandA[2];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ }
+ break;
+ case GL_RGB_SCALE:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ if (texUnit->Combine.ScaleShiftRGB == 0)
+ *params = 1.0;
+ else if (texUnit->Combine.ScaleShiftRGB == 1)
+ *params = 2.0;
+ else
+ *params = 4.0;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ return;
+ }
+ break;
+ case GL_ALPHA_SCALE:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ if (texUnit->Combine.ScaleShiftA == 0)
+ *params = 1.0;
+ else if (texUnit->Combine.ScaleShiftA == 1)
+ *params = 2.0;
+ else
+ *params = 4.0;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)");
+ return;
+ }
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname=0x%x)", pname);
+ }
+ }
+ else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) {
+ /* GL_EXT_texture_lod_bias */
+ if (!ctx->Extensions.EXT_texture_lod_bias) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" );
+ return;
+ }
+ if (pname == GL_TEXTURE_LOD_BIAS_EXT) {
+ *params = texUnit->LodBias;
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" );
+ return;
+ }
+ }
+ else if (target == GL_POINT_SPRITE_NV) {
+ /* GL_ARB_point_sprite / GL_NV_point_sprite */
+ if (!ctx->Extensions.NV_point_sprite
+ && !ctx->Extensions.ARB_point_sprite) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" );
+ return;
+ }
+ if (pname == GL_COORD_REPLACE_NV) {
+ *params = (GLfloat) ctx->Point.CoordReplace[ctx->Texture.CurrentUnit];
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" );
+ return;
+ }
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(target)" );
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target == GL_TEXTURE_ENV) {
+ switch (pname) {
+ case GL_TEXTURE_ENV_MODE:
+ *params = (GLint) texUnit->EnvMode;
+ break;
+ case GL_TEXTURE_ENV_COLOR:
+ params[0] = FLOAT_TO_INT( texUnit->EnvColor[0] );
+ params[1] = FLOAT_TO_INT( texUnit->EnvColor[1] );
+ params[2] = FLOAT_TO_INT( texUnit->EnvColor[2] );
+ params[3] = FLOAT_TO_INT( texUnit->EnvColor[3] );
+ break;
+ case GL_COMBINE_RGB:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLint) texUnit->Combine.ModeRGB;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_COMBINE_ALPHA:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLint) texUnit->Combine.ModeA;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE0_RGB:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLint) texUnit->Combine.SourceRGB[0];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE1_RGB:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLint) texUnit->Combine.SourceRGB[1];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE2_RGB:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLint) texUnit->Combine.SourceRGB[2];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE0_ALPHA:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLint) texUnit->Combine.SourceA[0];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE1_ALPHA:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLint) texUnit->Combine.SourceA[1];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_SOURCE2_ALPHA:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLint) texUnit->Combine.SourceA[2];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND0_RGB:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLint) texUnit->Combine.OperandRGB[0];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND1_RGB:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLint) texUnit->Combine.OperandRGB[1];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND2_RGB:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLint) texUnit->Combine.OperandRGB[2];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND0_ALPHA:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLint) texUnit->Combine.OperandA[0];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND1_ALPHA:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLint) texUnit->Combine.OperandA[1];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_OPERAND2_ALPHA:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ *params = (GLint) texUnit->Combine.OperandA[2];
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ }
+ break;
+ case GL_RGB_SCALE:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ if (texUnit->Combine.ScaleShiftRGB == 0)
+ *params = 1;
+ else if (texUnit->Combine.ScaleShiftRGB == 1)
+ *params = 2;
+ else
+ *params = 4;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ return;
+ }
+ break;
+ case GL_ALPHA_SCALE:
+ if (ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine) {
+ if (texUnit->Combine.ScaleShiftA == 0)
+ *params = 1;
+ else if (texUnit->Combine.ScaleShiftA == 1)
+ *params = 2;
+ else
+ *params = 4;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)");
+ return;
+ }
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname=0x%x)",
+ pname);
+ }
+ }
+ else if (target == GL_TEXTURE_FILTER_CONTROL_EXT) {
+ /* GL_EXT_texture_lod_bias */
+ if (!ctx->Extensions.EXT_texture_lod_bias) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" );
+ return;
+ }
+ if (pname == GL_TEXTURE_LOD_BIAS_EXT) {
+ *params = (GLint) texUnit->LodBias;
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" );
+ return;
+ }
+ }
+ else if (target == GL_POINT_SPRITE_NV) {
+ /* GL_ARB_point_sprite / GL_NV_point_sprite */
+ if (!ctx->Extensions.NV_point_sprite
+ && !ctx->Extensions.ARB_point_sprite) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" );
+ return;
+ }
+ if (pname == GL_COORD_REPLACE_NV) {
+ *params = (GLint) ctx->Point.CoordReplace[ctx->Texture.CurrentUnit];
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" );
+ return;
+ }
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(target)" );
+ return;
+ }
+}
+
+
+
+
+/**********************************************************************/
+/* Texture Parameters */
+/**********************************************************************/
+
+static GLboolean
+_mesa_validate_texture_wrap_mode(GLcontext * ctx,
+ GLenum target, GLenum eparam)
+{
+ const struct gl_extensions * const e = & ctx->Extensions;
+
+ if (eparam == GL_CLAMP || eparam == GL_CLAMP_TO_EDGE ||
+ (eparam == GL_CLAMP_TO_BORDER && e->ARB_texture_border_clamp)) {
+ /* any texture target */
+ return GL_TRUE;
+ }
+ else if (target != GL_TEXTURE_RECTANGLE_NV &&
+ (eparam == GL_REPEAT ||
+ (eparam == GL_MIRRORED_REPEAT &&
+ e->ARB_texture_mirrored_repeat) ||
+ (eparam == GL_MIRROR_CLAMP_EXT &&
+ (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp)) ||
+ (eparam == GL_MIRROR_CLAMP_TO_EDGE_EXT &&
+ (e->ATI_texture_mirror_once || e->EXT_texture_mirror_clamp)) ||
+ (eparam == GL_MIRROR_CLAMP_TO_BORDER_EXT &&
+ (e->EXT_texture_mirror_clamp)))) {
+ /* non-rectangle texture */
+ return GL_TRUE;
+ }
+
+ _mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
+ return GL_FALSE;
+}
+
+
+void GLAPIENTRY
+_mesa_TexParameterf( GLenum target, GLenum pname, GLfloat param )
+{
+ _mesa_TexParameterfv(target, pname, &param);
+}
+
+
+void GLAPIENTRY
+_mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ GLenum eparam = (GLenum) (GLint) params[0];
+ struct gl_texture_object *texObj;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE))
+ _mesa_debug(ctx, "glTexParameter %s %s %.1f(%s)...\n",
+ _mesa_lookup_enum_by_nr(target),
+ _mesa_lookup_enum_by_nr(pname),
+ *params,
+ _mesa_lookup_enum_by_nr(eparam));
+
+
+ switch (target) {
+ case GL_TEXTURE_1D:
+ texObj = texUnit->Current1D;
+ break;
+ case GL_TEXTURE_2D:
+ texObj = texUnit->Current2D;
+ break;
+ case GL_TEXTURE_3D:
+ texObj = texUnit->Current3D;
+ break;
+ case GL_TEXTURE_CUBE_MAP:
+ if (!ctx->Extensions.ARB_texture_cube_map) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(target)" );
+ return;
+ }
+ texObj = texUnit->CurrentCubeMap;
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ if (!ctx->Extensions.NV_texture_rectangle) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(target)" );
+ return;
+ }
+ texObj = texUnit->CurrentRect;
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexParameter(target)" );
+ return;
+ }
+
+ switch (pname) {
+ case GL_TEXTURE_MIN_FILTER:
+ /* A small optimization */
+ if (texObj->MinFilter == eparam)
+ return;
+ if (eparam==GL_NEAREST || eparam==GL_LINEAR) {
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->MinFilter = eparam;
+ }
+ else if ((eparam==GL_NEAREST_MIPMAP_NEAREST ||
+ eparam==GL_LINEAR_MIPMAP_NEAREST ||
+ eparam==GL_NEAREST_MIPMAP_LINEAR ||
+ eparam==GL_LINEAR_MIPMAP_LINEAR) &&
+ texObj->Target != GL_TEXTURE_RECTANGLE_NV) {
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->MinFilter = eparam;
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
+ return;
+ }
+ break;
+ case GL_TEXTURE_MAG_FILTER:
+ /* A small optimization */
+ if (texObj->MagFilter == eparam)
+ return;
+
+ if (eparam==GL_NEAREST || eparam==GL_LINEAR) {
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->MagFilter = eparam;
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
+ return;
+ }
+ break;
+ case GL_TEXTURE_WRAP_S:
+ if (texObj->WrapS == eparam)
+ return;
+ if (_mesa_validate_texture_wrap_mode(ctx, texObj->Target, eparam)) {
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->WrapS = eparam;
+ }
+ else {
+ return;
+ }
+ break;
+ case GL_TEXTURE_WRAP_T:
+ if (texObj->WrapT == eparam)
+ return;
+ if (_mesa_validate_texture_wrap_mode(ctx, texObj->Target, eparam)) {
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->WrapT = eparam;
+ }
+ else {
+ return;
+ }
+ break;
+ case GL_TEXTURE_WRAP_R:
+ if (texObj->WrapR == eparam)
+ return;
+ if (_mesa_validate_texture_wrap_mode(ctx, texObj->Target, eparam)) {
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->WrapR = eparam;
+ }
+ else {
+ return;
+ }
+ break;
+ case GL_TEXTURE_BORDER_COLOR:
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->BorderColor[RCOMP] = params[0];
+ texObj->BorderColor[GCOMP] = params[1];
+ texObj->BorderColor[BCOMP] = params[2];
+ texObj->BorderColor[ACOMP] = params[3];
+ UNCLAMPED_FLOAT_TO_CHAN(texObj->_BorderChan[RCOMP], params[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(texObj->_BorderChan[GCOMP], params[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(texObj->_BorderChan[BCOMP], params[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(texObj->_BorderChan[ACOMP], params[3]);
+ break;
+ case GL_TEXTURE_MIN_LOD:
+ if (texObj->MinLod == params[0])
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->MinLod = params[0];
+ break;
+ case GL_TEXTURE_MAX_LOD:
+ if (texObj->MaxLod == params[0])
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->MaxLod = params[0];
+ break;
+ case GL_TEXTURE_BASE_LEVEL:
+ if (params[0] < 0.0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
+ return;
+ }
+ if (target == GL_TEXTURE_RECTANGLE_NV && params[0] != 0.0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
+ return;
+ }
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->BaseLevel = (GLint) params[0];
+ break;
+ case GL_TEXTURE_MAX_LEVEL:
+ if (params[0] < 0.0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
+ return;
+ }
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->MaxLevel = (GLint) params[0];
+ break;
+ case GL_TEXTURE_PRIORITY:
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->Priority = CLAMP( params[0], 0.0F, 1.0F );
+ break;
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+ if (ctx->Extensions.EXT_texture_filter_anisotropic) {
+ if (params[0] < 1.0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glTexParameter(param)" );
+ return;
+ }
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ /* clamp to max, that's what NVIDIA does */
+ texObj->MaxAnisotropy = MIN2(params[0],
+ ctx->Const.MaxTextureMaxAnisotropy);
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(pname=GL_TEXTURE_MAX_ANISOTROPY_EXT)");
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_SGIX:
+ if (ctx->Extensions.SGIX_shadow) {
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->CompareFlag = params[0] ? GL_TRUE : GL_FALSE;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(pname=GL_TEXTURE_COMPARE_SGIX)");
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_OPERATOR_SGIX:
+ if (ctx->Extensions.SGIX_shadow) {
+ GLenum op = (GLenum) params[0];
+ if (op == GL_TEXTURE_LEQUAL_R_SGIX ||
+ op == GL_TEXTURE_GEQUAL_R_SGIX) {
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->CompareOperator = op;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTexParameter(param)");
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(pname=GL_TEXTURE_COMPARE_OPERATOR_SGIX)");
+ return;
+ }
+ break;
+ case GL_SHADOW_AMBIENT_SGIX: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
+ if (ctx->Extensions.SGIX_shadow_ambient) {
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->ShadowAmbient = CLAMP(params[0], 0.0F, 1.0F);
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(pname=GL_SHADOW_AMBIENT_SGIX)");
+ return;
+ }
+ break;
+ case GL_GENERATE_MIPMAP_SGIS:
+ if (ctx->Extensions.SGIS_generate_mipmap) {
+ texObj->GenerateMipmap = params[0] ? GL_TRUE : GL_FALSE;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(pname=GL_GENERATE_MIPMAP_SGIS)");
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_MODE_ARB:
+ if (ctx->Extensions.ARB_shadow) {
+ const GLenum mode = (GLenum) params[0];
+ if (mode == GL_NONE || mode == GL_COMPARE_R_TO_TEXTURE_ARB) {
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->CompareMode = mode;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(bad GL_TEXTURE_COMPARE_MODE_ARB: 0x%x)", mode);
+ return;
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(pname=GL_TEXTURE_COMPARE_MODE_ARB)");
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_FUNC_ARB:
+ if (ctx->Extensions.ARB_shadow) {
+ const GLenum func = (GLenum) params[0];
+ if (func == GL_LEQUAL || func == GL_GEQUAL) {
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->CompareFunc = func;
+ }
+ else if (ctx->Extensions.EXT_shadow_funcs &&
+ (func == GL_EQUAL ||
+ func == GL_NOTEQUAL ||
+ func == GL_LESS ||
+ func == GL_GREATER ||
+ func == GL_ALWAYS ||
+ func == GL_NEVER)) {
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->CompareFunc = func;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(bad GL_TEXTURE_COMPARE_FUNC_ARB)");
+ return;
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(pname=GL_TEXTURE_COMPARE_FUNC_ARB)");
+ return;
+ }
+ break;
+ case GL_DEPTH_TEXTURE_MODE_ARB:
+ if (ctx->Extensions.ARB_depth_texture) {
+ const GLenum result = (GLenum) params[0];
+ if (result == GL_LUMINANCE || result == GL_INTENSITY
+ || result == GL_ALPHA) {
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->DepthMode = result;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(bad GL_DEPTH_TEXTURE_MODE_ARB)");
+ return;
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(pname=GL_DEPTH_TEXTURE_MODE_ARB)");
+ return;
+ }
+ break;
+ case GL_TEXTURE_LOD_BIAS:
+ /* NOTE: this is really part of OpenGL 1.4, not EXT_texture_lod_bias*/
+ if (ctx->Extensions.EXT_texture_lod_bias) {
+ if (texObj->LodBias != params[0]) {
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texObj->LodBias = params[0];
+ }
+ }
+ break;
+
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glTexParameter(pname=0x%x)", pname);
+ return;
+ }
+
+ texObj->Complete = GL_FALSE;
+
+ if (ctx->Driver.TexParameter) {
+ (*ctx->Driver.TexParameter)( ctx, target, texObj, pname, params );
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_TexParameteri( GLenum target, GLenum pname, GLint param )
+{
+ GLfloat fparam[4];
+ if (pname == GL_TEXTURE_PRIORITY)
+ fparam[0] = INT_TO_FLOAT(param);
+ else
+ fparam[0] = (GLfloat) param;
+ fparam[1] = fparam[2] = fparam[3] = 0.0;
+ _mesa_TexParameterfv(target, pname, fparam);
+}
+
+
+void GLAPIENTRY
+_mesa_TexParameteriv( GLenum target, GLenum pname, const GLint *params )
+{
+ GLfloat fparam[4];
+ if (pname == GL_TEXTURE_BORDER_COLOR) {
+ fparam[0] = INT_TO_FLOAT(params[0]);
+ fparam[1] = INT_TO_FLOAT(params[1]);
+ fparam[2] = INT_TO_FLOAT(params[2]);
+ fparam[3] = INT_TO_FLOAT(params[3]);
+ }
+ else {
+ if (pname == GL_TEXTURE_PRIORITY)
+ fparam[0] = INT_TO_FLOAT(params[0]);
+ else
+ fparam[0] = (GLfloat) params[0];
+ fparam[1] = fparam[2] = fparam[3] = 0.0F;
+ }
+ _mesa_TexParameterfv(target, pname, fparam);
+}
+
+
+void GLAPIENTRY
+_mesa_GetTexLevelParameterfv( GLenum target, GLint level,
+ GLenum pname, GLfloat *params )
+{
+ GLint iparam;
+ _mesa_GetTexLevelParameteriv( target, level, pname, &iparam );
+ *params = (GLfloat) iparam;
+}
+
+
+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:
+ case GL_PROXY_TEXTURE_CUBE_MAP:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ return ctx->Extensions.ARB_texture_cube_map ? 2 : 0;
+ case GL_TEXTURE_RECTANGLE_NV:
+ case GL_PROXY_TEXTURE_RECTANGLE_NV:
+ return ctx->Extensions.NV_texture_rectangle ? 2 : 0;
+ default:
+ _mesa_problem(ctx, "bad target in _mesa_tex_target_dimensions()");
+ return 0;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetTexLevelParameteriv( GLenum target, GLint level,
+ GLenum pname, GLint *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ const struct gl_texture_image *img = NULL;
+ GLuint dimensions;
+ GLboolean isProxy;
+ GLint maxLevels;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ /* this will catch bad target values */
+ dimensions = tex_image_dimensions(ctx, target); /* 1, 2 or 3 */
+ if (dimensions == 0) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)");
+ return;
+ }
+
+ switch (target) {
+ case GL_TEXTURE_1D:
+ case GL_PROXY_TEXTURE_1D:
+ case GL_TEXTURE_2D:
+ case GL_PROXY_TEXTURE_2D:
+ maxLevels = ctx->Const.MaxTextureLevels;
+ break;
+ case GL_TEXTURE_3D:
+ case GL_PROXY_TEXTURE_3D:
+ maxLevels = ctx->Const.Max3DTextureLevels;
+ break;
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z:
+ case GL_PROXY_TEXTURE_CUBE_MAP:
+ maxLevels = ctx->Const.MaxCubeTextureLevels;
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ case GL_PROXY_TEXTURE_RECTANGLE_NV:
+ maxLevels = 1;
+ break;
+ default:
+ _mesa_problem(ctx, "switch in _mesa_GetTexLevelParameter");
+ return;
+ }
+
+ if (level < 0 || level >= maxLevels) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glGetTexLevelParameter[if]v" );
+ return;
+ }
+
+ img = _mesa_select_tex_image(ctx, texUnit, target, level);
+ if (!img || !img->TexFormat) {
+ /* undefined texture image */
+ if (pname == GL_TEXTURE_COMPONENTS)
+ *params = 1;
+ else
+ *params = 0;
+ return;
+ }
+
+ isProxy = (target == GL_PROXY_TEXTURE_1D) ||
+ (target == GL_PROXY_TEXTURE_2D) ||
+ (target == GL_PROXY_TEXTURE_3D) ||
+ (target == GL_PROXY_TEXTURE_CUBE_MAP) ||
+ (target == GL_PROXY_TEXTURE_RECTANGLE_NV);
+
+ switch (pname) {
+ case GL_TEXTURE_WIDTH:
+ *params = img->Width;
+ return;
+ case GL_TEXTURE_HEIGHT:
+ *params = img->Height;
+ return;
+ case GL_TEXTURE_DEPTH:
+ *params = img->Depth;
+ return;
+ case GL_TEXTURE_INTERNAL_FORMAT:
+ *params = img->IntFormat;
+ return;
+ case GL_TEXTURE_BORDER:
+ *params = img->Border;
+ return;
+ case GL_TEXTURE_RED_SIZE:
+ if (img->Format == GL_RGB || img->Format == GL_RGBA)
+ *params = img->TexFormat->RedBits;
+ else
+ *params = 0;
+ return;
+ case GL_TEXTURE_GREEN_SIZE:
+ if (img->Format == GL_RGB || img->Format == GL_RGBA)
+ *params = img->TexFormat->GreenBits;
+ else
+ *params = 0;
+ return;
+ case GL_TEXTURE_BLUE_SIZE:
+ if (img->Format == GL_RGB || img->Format == GL_RGBA)
+ *params = img->TexFormat->BlueBits;
+ else
+ *params = 0;
+ return;
+ case GL_TEXTURE_ALPHA_SIZE:
+ if (img->Format == GL_ALPHA || img->Format == GL_LUMINANCE_ALPHA ||
+ img->Format == GL_RGBA)
+ *params = img->TexFormat->AlphaBits;
+ else
+ *params = 0;
+ return;
+ case GL_TEXTURE_INTENSITY_SIZE:
+ if (img->Format != GL_INTENSITY)
+ *params = 0;
+ else if (img->TexFormat->IntensityBits > 0)
+ *params = img->TexFormat->IntensityBits;
+ else /* intensity probably stored as rgb texture */
+ *params = MIN2(img->TexFormat->RedBits, img->TexFormat->GreenBits);
+ return;
+ case GL_TEXTURE_LUMINANCE_SIZE:
+ if (img->Format != GL_LUMINANCE &&
+ img->Format != GL_LUMINANCE_ALPHA)
+ *params = 0;
+ else if (img->TexFormat->LuminanceBits > 0)
+ *params = img->TexFormat->LuminanceBits;
+ else /* luminance probably stored as rgb texture */
+ *params = MIN2(img->TexFormat->RedBits, img->TexFormat->GreenBits);
+ return;
+ case GL_TEXTURE_INDEX_SIZE_EXT:
+ if (img->Format == GL_COLOR_INDEX)
+ *params = img->TexFormat->IndexBits;
+ else
+ *params = 0;
+ return;
+ case GL_TEXTURE_DEPTH_SIZE_ARB:
+ if (ctx->Extensions.SGIX_depth_texture ||
+ ctx->Extensions.ARB_depth_texture)
+ *params = img->TexFormat->DepthBits;
+ else
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ return;
+
+ /* GL_ARB_texture_compression */
+ case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
+ if (ctx->Extensions.ARB_texture_compression) {
+ if (img->IsCompressed && !isProxy)
+ *params = img->CompressedSize;
+ else
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
+ case GL_TEXTURE_COMPRESSED:
+ if (ctx->Extensions.ARB_texture_compression) {
+ *params = (GLint) img->IsCompressed;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
+
+ /* GL_ARB_texture_float */
+ case GL_TEXTURE_RED_TYPE_ARB:
+ if (ctx->Extensions.ARB_texture_float) {
+ *params = img->TexFormat->RedBits ? img->TexFormat->DataType : GL_NONE;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
+ case GL_TEXTURE_GREEN_TYPE_ARB:
+ if (ctx->Extensions.ARB_texture_float) {
+ *params = img->TexFormat->GreenBits ? img->TexFormat->DataType : GL_NONE;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
+ case GL_TEXTURE_BLUE_TYPE_ARB:
+ if (ctx->Extensions.ARB_texture_float) {
+ *params = img->TexFormat->BlueBits ? img->TexFormat->DataType : GL_NONE;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
+ case GL_TEXTURE_ALPHA_TYPE_ARB:
+ if (ctx->Extensions.ARB_texture_float) {
+ *params = img->TexFormat->AlphaBits ? img->TexFormat->DataType : GL_NONE;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
+ case GL_TEXTURE_LUMINANCE_TYPE_ARB:
+ if (ctx->Extensions.ARB_texture_float) {
+ *params = img->TexFormat->LuminanceBits ? img->TexFormat->DataType : GL_NONE;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
+ case GL_TEXTURE_INTENSITY_TYPE_ARB:
+ if (ctx->Extensions.ARB_texture_float) {
+ *params = img->TexFormat->IntensityBits ? img->TexFormat->DataType : GL_NONE;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
+ case GL_TEXTURE_DEPTH_TYPE_ARB:
+ if (ctx->Extensions.ARB_texture_float) {
+ *params = img->TexFormat->DepthBits ? img->TexFormat->DataType : GL_NONE;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+ return;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetTexLevelParameter[if]v(pname)");
+ }
+}
+
+
+
+void GLAPIENTRY
+_mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ struct gl_texture_object *obj;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ obj = _mesa_select_tex_object(ctx, texUnit, target);
+ if (!obj) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)");
+ return;
+ }
+
+ switch (pname) {
+ case GL_TEXTURE_MAG_FILTER:
+ *params = ENUM_TO_FLOAT(obj->MagFilter);
+ return;
+ case GL_TEXTURE_MIN_FILTER:
+ *params = ENUM_TO_FLOAT(obj->MinFilter);
+ return;
+ case GL_TEXTURE_WRAP_S:
+ *params = ENUM_TO_FLOAT(obj->WrapS);
+ return;
+ case GL_TEXTURE_WRAP_T:
+ *params = ENUM_TO_FLOAT(obj->WrapT);
+ return;
+ case GL_TEXTURE_WRAP_R:
+ *params = ENUM_TO_FLOAT(obj->WrapR);
+ return;
+ case GL_TEXTURE_BORDER_COLOR:
+ params[0] = CLAMP(obj->BorderColor[0], 0.0F, 1.0F);
+ params[1] = CLAMP(obj->BorderColor[1], 0.0F, 1.0F);
+ params[2] = CLAMP(obj->BorderColor[2], 0.0F, 1.0F);
+ params[3] = CLAMP(obj->BorderColor[3], 0.0F, 1.0F);
+ return;
+ case GL_TEXTURE_RESIDENT:
+ {
+ GLboolean resident;
+ if (ctx->Driver.IsTextureResident)
+ resident = ctx->Driver.IsTextureResident(ctx, obj);
+ else
+ resident = GL_TRUE;
+ *params = ENUM_TO_FLOAT(resident);
+ }
+ return;
+ case GL_TEXTURE_PRIORITY:
+ *params = obj->Priority;
+ return;
+ case GL_TEXTURE_MIN_LOD:
+ *params = obj->MinLod;
+ return;
+ case GL_TEXTURE_MAX_LOD:
+ *params = obj->MaxLod;
+ return;
+ case GL_TEXTURE_BASE_LEVEL:
+ *params = (GLfloat) obj->BaseLevel;
+ return;
+ case GL_TEXTURE_MAX_LEVEL:
+ *params = (GLfloat) obj->MaxLevel;
+ return;
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+ if (ctx->Extensions.EXT_texture_filter_anisotropic) {
+ *params = obj->MaxAnisotropy;
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_SGIX:
+ if (ctx->Extensions.SGIX_shadow) {
+ *params = (GLfloat) obj->CompareFlag;
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_OPERATOR_SGIX:
+ if (ctx->Extensions.SGIX_shadow) {
+ *params = (GLfloat) obj->CompareOperator;
+ return;
+ }
+ break;
+ case GL_SHADOW_AMBIENT_SGIX: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
+ if (ctx->Extensions.SGIX_shadow_ambient) {
+ *params = obj->ShadowAmbient;
+ return;
+ }
+ break;
+ case GL_GENERATE_MIPMAP_SGIS:
+ if (ctx->Extensions.SGIS_generate_mipmap) {
+ *params = (GLfloat) obj->GenerateMipmap;
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_MODE_ARB:
+ if (ctx->Extensions.ARB_shadow) {
+ *params = (GLfloat) obj->CompareMode;
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_FUNC_ARB:
+ if (ctx->Extensions.ARB_shadow) {
+ *params = (GLfloat) obj->CompareFunc;
+ return;
+ }
+ break;
+ case GL_DEPTH_TEXTURE_MODE_ARB:
+ if (ctx->Extensions.ARB_depth_texture) {
+ *params = (GLfloat) obj->DepthMode;
+ return;
+ }
+ break;
+ case GL_TEXTURE_LOD_BIAS:
+ if (ctx->Extensions.EXT_texture_lod_bias) {
+ *params = obj->LodBias;
+ return;
+ }
+ break;
+ default:
+ ; /* silence warnings */
+ }
+ /* If we get here, pname was an unrecognized enum */
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(pname=0x%x)",
+ pname);
+}
+
+
+void GLAPIENTRY
+_mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ struct gl_texture_object *obj;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ obj = _mesa_select_tex_object(ctx, texUnit, target);
+ if (!obj) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(target)");
+ return;
+ }
+
+ switch (pname) {
+ case GL_TEXTURE_MAG_FILTER:
+ *params = (GLint) obj->MagFilter;
+ return;
+ case GL_TEXTURE_MIN_FILTER:
+ *params = (GLint) obj->MinFilter;
+ return;
+ case GL_TEXTURE_WRAP_S:
+ *params = (GLint) obj->WrapS;
+ return;
+ case GL_TEXTURE_WRAP_T:
+ *params = (GLint) obj->WrapT;
+ return;
+ case GL_TEXTURE_WRAP_R:
+ *params = (GLint) obj->WrapR;
+ return;
+ case GL_TEXTURE_BORDER_COLOR:
+ {
+ GLfloat b[4];
+ b[0] = CLAMP(obj->BorderColor[0], 0.0F, 1.0F);
+ b[1] = CLAMP(obj->BorderColor[1], 0.0F, 1.0F);
+ b[2] = CLAMP(obj->BorderColor[2], 0.0F, 1.0F);
+ b[3] = CLAMP(obj->BorderColor[3], 0.0F, 1.0F);
+ params[0] = FLOAT_TO_INT(b[0]);
+ params[1] = FLOAT_TO_INT(b[1]);
+ params[2] = FLOAT_TO_INT(b[2]);
+ params[3] = FLOAT_TO_INT(b[3]);
+ }
+ return;
+ case GL_TEXTURE_RESIDENT:
+ {
+ GLboolean resident;
+ if (ctx->Driver.IsTextureResident)
+ resident = ctx->Driver.IsTextureResident(ctx, obj);
+ else
+ resident = GL_TRUE;
+ *params = (GLint) resident;
+ }
+ return;
+ case GL_TEXTURE_PRIORITY:
+ *params = FLOAT_TO_INT(obj->Priority);
+ return;
+ case GL_TEXTURE_MIN_LOD:
+ *params = (GLint) obj->MinLod;
+ return;
+ case GL_TEXTURE_MAX_LOD:
+ *params = (GLint) obj->MaxLod;
+ return;
+ case GL_TEXTURE_BASE_LEVEL:
+ *params = obj->BaseLevel;
+ return;
+ case GL_TEXTURE_MAX_LEVEL:
+ *params = obj->MaxLevel;
+ return;
+ case GL_TEXTURE_MAX_ANISOTROPY_EXT:
+ if (ctx->Extensions.EXT_texture_filter_anisotropic) {
+ *params = (GLint) obj->MaxAnisotropy;
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_SGIX:
+ if (ctx->Extensions.SGIX_shadow) {
+ *params = (GLint) obj->CompareFlag;
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_OPERATOR_SGIX:
+ if (ctx->Extensions.SGIX_shadow) {
+ *params = (GLint) obj->CompareOperator;
+ return;
+ }
+ break;
+ case GL_SHADOW_AMBIENT_SGIX: /* aka GL_TEXTURE_COMPARE_FAIL_VALUE_ARB */
+ if (ctx->Extensions.SGIX_shadow_ambient) {
+ *params = (GLint) FLOAT_TO_INT(obj->ShadowAmbient);
+ return;
+ }
+ break;
+ case GL_GENERATE_MIPMAP_SGIS:
+ if (ctx->Extensions.SGIS_generate_mipmap) {
+ *params = (GLint) obj->GenerateMipmap;
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_MODE_ARB:
+ if (ctx->Extensions.ARB_shadow) {
+ *params = (GLint) obj->CompareMode;
+ return;
+ }
+ break;
+ case GL_TEXTURE_COMPARE_FUNC_ARB:
+ if (ctx->Extensions.ARB_shadow) {
+ *params = (GLint) obj->CompareFunc;
+ return;
+ }
+ break;
+ case GL_DEPTH_TEXTURE_MODE_ARB:
+ if (ctx->Extensions.ARB_depth_texture) {
+ *params = (GLint) obj->DepthMode;
+ return;
+ }
+ break;
+ case GL_TEXTURE_LOD_BIAS:
+ if (ctx->Extensions.EXT_texture_lod_bias) {
+ *params = (GLint) obj->LodBias;
+ return;
+ }
+ break;
+ default:
+ ; /* silence warnings */
+ }
+ /* If we get here, pname was an unrecognized enum */
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(pname=0x%x)", pname);
+}
+
+
+
+
+/**********************************************************************/
+/* Texture Coord Generation */
+/**********************************************************************/
+
+#if FEATURE_texgen
+void GLAPIENTRY
+_mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint tUnit = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[tUnit];
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE))
+ _mesa_debug(ctx, "glTexGen %s %s %.1f(%s)...\n",
+ _mesa_lookup_enum_by_nr(coord),
+ _mesa_lookup_enum_by_nr(pname),
+ *params,
+ _mesa_lookup_enum_by_nr((GLenum) (GLint) *params));
+
+ switch (coord) {
+ case GL_S:
+ if (pname==GL_TEXTURE_GEN_MODE) {
+ GLenum mode = (GLenum) (GLint) *params;
+ GLuint bits;
+ switch (mode) {
+ case GL_OBJECT_LINEAR:
+ bits = TEXGEN_OBJ_LINEAR;
+ break;
+ case GL_EYE_LINEAR:
+ bits = TEXGEN_EYE_LINEAR;
+ break;
+ case GL_REFLECTION_MAP_NV:
+ bits = TEXGEN_REFLECTION_MAP_NV;
+ break;
+ case GL_NORMAL_MAP_NV:
+ bits = TEXGEN_NORMAL_MAP_NV;
+ break;
+ case GL_SPHERE_MAP:
+ bits = TEXGEN_SPHERE_MAP;
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
+ return;
+ }
+ if (texUnit->GenModeS == mode)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->GenModeS = mode;
+ texUnit->_GenBitS = bits;
+ }
+ else if (pname==GL_OBJECT_PLANE) {
+ if (TEST_EQ_4V(texUnit->ObjectPlaneS, params))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->ObjectPlaneS[0] = params[0];
+ texUnit->ObjectPlaneS[1] = params[1];
+ texUnit->ObjectPlaneS[2] = params[2];
+ texUnit->ObjectPlaneS[3] = params[3];
+ }
+ else if (pname==GL_EYE_PLANE) {
+ GLfloat tmp[4];
+
+ /* Transform plane equation by the inverse modelview matrix */
+ if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) {
+ _math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
+ }
+ _mesa_transform_vector( tmp, params, ctx->ModelviewMatrixStack.Top->inv );
+ if (TEST_EQ_4V(texUnit->EyePlaneS, tmp))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ COPY_4FV(texUnit->EyePlaneS, tmp);
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" );
+ return;
+ }
+ break;
+ case GL_T:
+ if (pname==GL_TEXTURE_GEN_MODE) {
+ GLenum mode = (GLenum) (GLint) *params;
+ GLuint bitt;
+ switch (mode) {
+ case GL_OBJECT_LINEAR:
+ bitt = TEXGEN_OBJ_LINEAR;
+ break;
+ case GL_EYE_LINEAR:
+ bitt = TEXGEN_EYE_LINEAR;
+ break;
+ case GL_REFLECTION_MAP_NV:
+ bitt = TEXGEN_REFLECTION_MAP_NV;
+ break;
+ case GL_NORMAL_MAP_NV:
+ bitt = TEXGEN_NORMAL_MAP_NV;
+ break;
+ case GL_SPHERE_MAP:
+ bitt = TEXGEN_SPHERE_MAP;
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
+ return;
+ }
+ if (texUnit->GenModeT == mode)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->GenModeT = mode;
+ texUnit->_GenBitT = bitt;
+ }
+ else if (pname==GL_OBJECT_PLANE) {
+ if (TEST_EQ_4V(texUnit->ObjectPlaneT, params))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->ObjectPlaneT[0] = params[0];
+ texUnit->ObjectPlaneT[1] = params[1];
+ texUnit->ObjectPlaneT[2] = params[2];
+ texUnit->ObjectPlaneT[3] = params[3];
+ }
+ else if (pname==GL_EYE_PLANE) {
+ GLfloat tmp[4];
+ /* Transform plane equation by the inverse modelview matrix */
+ if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) {
+ _math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
+ }
+ _mesa_transform_vector( tmp, params, ctx->ModelviewMatrixStack.Top->inv );
+ if (TEST_EQ_4V(texUnit->EyePlaneT, tmp))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ COPY_4FV(texUnit->EyePlaneT, tmp);
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" );
+ return;
+ }
+ break;
+ case GL_R:
+ if (pname==GL_TEXTURE_GEN_MODE) {
+ GLenum mode = (GLenum) (GLint) *params;
+ GLuint bitr;
+ switch (mode) {
+ case GL_OBJECT_LINEAR:
+ bitr = TEXGEN_OBJ_LINEAR;
+ break;
+ case GL_REFLECTION_MAP_NV:
+ bitr = TEXGEN_REFLECTION_MAP_NV;
+ break;
+ case GL_NORMAL_MAP_NV:
+ bitr = TEXGEN_NORMAL_MAP_NV;
+ break;
+ case GL_EYE_LINEAR:
+ bitr = TEXGEN_EYE_LINEAR;
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
+ return;
+ }
+ if (texUnit->GenModeR == mode)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->GenModeR = mode;
+ texUnit->_GenBitR = bitr;
+ }
+ else if (pname==GL_OBJECT_PLANE) {
+ if (TEST_EQ_4V(texUnit->ObjectPlaneR, params))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->ObjectPlaneR[0] = params[0];
+ texUnit->ObjectPlaneR[1] = params[1];
+ texUnit->ObjectPlaneR[2] = params[2];
+ texUnit->ObjectPlaneR[3] = params[3];
+ }
+ else if (pname==GL_EYE_PLANE) {
+ GLfloat tmp[4];
+ /* Transform plane equation by the inverse modelview matrix */
+ if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) {
+ _math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
+ }
+ _mesa_transform_vector( tmp, params, ctx->ModelviewMatrixStack.Top->inv );
+ if (TEST_EQ_4V(texUnit->EyePlaneR, tmp))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ COPY_4FV(texUnit->EyePlaneR, tmp);
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" );
+ return;
+ }
+ break;
+ case GL_Q:
+ if (pname==GL_TEXTURE_GEN_MODE) {
+ GLenum mode = (GLenum) (GLint) *params;
+ GLuint bitq;
+ switch (mode) {
+ case GL_OBJECT_LINEAR:
+ bitq = TEXGEN_OBJ_LINEAR;
+ break;
+ case GL_EYE_LINEAR:
+ bitq = TEXGEN_EYE_LINEAR;
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" );
+ return;
+ }
+ if (texUnit->GenModeQ == mode)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->GenModeQ = mode;
+ texUnit->_GenBitQ = bitq;
+ }
+ else if (pname==GL_OBJECT_PLANE) {
+ if (TEST_EQ_4V(texUnit->ObjectPlaneQ, params))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ texUnit->ObjectPlaneQ[0] = params[0];
+ texUnit->ObjectPlaneQ[1] = params[1];
+ texUnit->ObjectPlaneQ[2] = params[2];
+ texUnit->ObjectPlaneQ[3] = params[3];
+ }
+ else if (pname==GL_EYE_PLANE) {
+ GLfloat tmp[4];
+ /* Transform plane equation by the inverse modelview matrix */
+ if (_math_matrix_is_dirty(ctx->ModelviewMatrixStack.Top)) {
+ _math_matrix_analyse( ctx->ModelviewMatrixStack.Top );
+ }
+ _mesa_transform_vector( tmp, params, ctx->ModelviewMatrixStack.Top->inv );
+ if (TEST_EQ_4V(texUnit->EyePlaneQ, tmp))
+ return;
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+ COPY_4FV(texUnit->EyePlaneQ, tmp);
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(pname)" );
+ return;
+ }
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexGenfv(coord)" );
+ return;
+ }
+
+ if (ctx->Driver.TexGen)
+ ctx->Driver.TexGen( ctx, coord, pname, params );
+}
+
+
+void GLAPIENTRY
+_mesa_TexGeniv(GLenum coord, GLenum pname, const GLint *params )
+{
+ GLfloat p[4];
+ p[0] = (GLfloat) params[0];
+ if (pname == GL_TEXTURE_GEN_MODE) {
+ p[1] = p[2] = p[3] = 0.0F;
+ }
+ else {
+ p[1] = (GLfloat) params[1];
+ p[2] = (GLfloat) params[2];
+ p[3] = (GLfloat) params[3];
+ }
+ _mesa_TexGenfv(coord, pname, p);
+}
+
+
+void GLAPIENTRY
+_mesa_TexGend(GLenum coord, GLenum pname, GLdouble param )
+{
+ GLfloat p = (GLfloat) param;
+ _mesa_TexGenfv( coord, pname, &p );
+}
+
+
+void GLAPIENTRY
+_mesa_TexGendv(GLenum coord, GLenum pname, const GLdouble *params )
+{
+ GLfloat p[4];
+ p[0] = (GLfloat) params[0];
+ if (pname == GL_TEXTURE_GEN_MODE) {
+ p[1] = p[2] = p[3] = 0.0F;
+ }
+ else {
+ p[1] = (GLfloat) params[1];
+ p[2] = (GLfloat) params[2];
+ p[3] = (GLfloat) params[3];
+ }
+ _mesa_TexGenfv( coord, pname, p );
+}
+
+
+void GLAPIENTRY
+_mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param )
+{
+ _mesa_TexGenfv(coord, pname, &param);
+}
+
+
+void GLAPIENTRY
+_mesa_TexGeni( GLenum coord, GLenum pname, GLint param )
+{
+ _mesa_TexGeniv( coord, pname, &param );
+}
+
+
+
+void GLAPIENTRY
+_mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint tUnit = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[tUnit];
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ switch (coord) {
+ case GL_S:
+ if (pname==GL_TEXTURE_GEN_MODE) {
+ params[0] = ENUM_TO_DOUBLE(texUnit->GenModeS);
+ }
+ else if (pname==GL_OBJECT_PLANE) {
+ COPY_4V( params, texUnit->ObjectPlaneS );
+ }
+ else if (pname==GL_EYE_PLANE) {
+ COPY_4V( params, texUnit->EyePlaneS );
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" );
+ return;
+ }
+ break;
+ case GL_T:
+ if (pname==GL_TEXTURE_GEN_MODE) {
+ params[0] = ENUM_TO_DOUBLE(texUnit->GenModeT);
+ }
+ else if (pname==GL_OBJECT_PLANE) {
+ COPY_4V( params, texUnit->ObjectPlaneT );
+ }
+ else if (pname==GL_EYE_PLANE) {
+ COPY_4V( params, texUnit->EyePlaneT );
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" );
+ return;
+ }
+ break;
+ case GL_R:
+ if (pname==GL_TEXTURE_GEN_MODE) {
+ params[0] = ENUM_TO_DOUBLE(texUnit->GenModeR);
+ }
+ else if (pname==GL_OBJECT_PLANE) {
+ COPY_4V( params, texUnit->ObjectPlaneR );
+ }
+ else if (pname==GL_EYE_PLANE) {
+ COPY_4V( params, texUnit->EyePlaneR );
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" );
+ return;
+ }
+ break;
+ case GL_Q:
+ if (pname==GL_TEXTURE_GEN_MODE) {
+ params[0] = ENUM_TO_DOUBLE(texUnit->GenModeQ);
+ }
+ else if (pname==GL_OBJECT_PLANE) {
+ COPY_4V( params, texUnit->ObjectPlaneQ );
+ }
+ else if (pname==GL_EYE_PLANE) {
+ COPY_4V( params, texUnit->EyePlaneQ );
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(pname)" );
+ return;
+ }
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGendv(coord)" );
+ return;
+ }
+}
+
+
+
+void GLAPIENTRY
+_mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint tUnit = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[tUnit];
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ switch (coord) {
+ case GL_S:
+ if (pname==GL_TEXTURE_GEN_MODE) {
+ params[0] = ENUM_TO_FLOAT(texUnit->GenModeS);
+ }
+ else if (pname==GL_OBJECT_PLANE) {
+ COPY_4V( params, texUnit->ObjectPlaneS );
+ }
+ else if (pname==GL_EYE_PLANE) {
+ COPY_4V( params, texUnit->EyePlaneS );
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" );
+ return;
+ }
+ break;
+ case GL_T:
+ if (pname==GL_TEXTURE_GEN_MODE) {
+ params[0] = ENUM_TO_FLOAT(texUnit->GenModeT);
+ }
+ else if (pname==GL_OBJECT_PLANE) {
+ COPY_4V( params, texUnit->ObjectPlaneT );
+ }
+ else if (pname==GL_EYE_PLANE) {
+ COPY_4V( params, texUnit->EyePlaneT );
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" );
+ return;
+ }
+ break;
+ case GL_R:
+ if (pname==GL_TEXTURE_GEN_MODE) {
+ params[0] = ENUM_TO_FLOAT(texUnit->GenModeR);
+ }
+ else if (pname==GL_OBJECT_PLANE) {
+ COPY_4V( params, texUnit->ObjectPlaneR );
+ }
+ else if (pname==GL_EYE_PLANE) {
+ COPY_4V( params, texUnit->EyePlaneR );
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" );
+ return;
+ }
+ break;
+ case GL_Q:
+ if (pname==GL_TEXTURE_GEN_MODE) {
+ params[0] = ENUM_TO_FLOAT(texUnit->GenModeQ);
+ }
+ else if (pname==GL_OBJECT_PLANE) {
+ COPY_4V( params, texUnit->ObjectPlaneQ );
+ }
+ else if (pname==GL_EYE_PLANE) {
+ COPY_4V( params, texUnit->EyePlaneQ );
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(pname)" );
+ return;
+ }
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGenfv(coord)" );
+ return;
+ }
+}
+
+
+
+void GLAPIENTRY
+_mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint tUnit = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[tUnit];
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ switch (coord) {
+ case GL_S:
+ if (pname==GL_TEXTURE_GEN_MODE) {
+ params[0] = texUnit->GenModeS;
+ }
+ else if (pname==GL_OBJECT_PLANE) {
+ params[0] = (GLint) texUnit->ObjectPlaneS[0];
+ params[1] = (GLint) texUnit->ObjectPlaneS[1];
+ params[2] = (GLint) texUnit->ObjectPlaneS[2];
+ params[3] = (GLint) texUnit->ObjectPlaneS[3];
+ }
+ else if (pname==GL_EYE_PLANE) {
+ params[0] = (GLint) texUnit->EyePlaneS[0];
+ params[1] = (GLint) texUnit->EyePlaneS[1];
+ params[2] = (GLint) texUnit->EyePlaneS[2];
+ params[3] = (GLint) texUnit->EyePlaneS[3];
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" );
+ return;
+ }
+ break;
+ case GL_T:
+ if (pname==GL_TEXTURE_GEN_MODE) {
+ params[0] = texUnit->GenModeT;
+ }
+ else if (pname==GL_OBJECT_PLANE) {
+ params[0] = (GLint) texUnit->ObjectPlaneT[0];
+ params[1] = (GLint) texUnit->ObjectPlaneT[1];
+ params[2] = (GLint) texUnit->ObjectPlaneT[2];
+ params[3] = (GLint) texUnit->ObjectPlaneT[3];
+ }
+ else if (pname==GL_EYE_PLANE) {
+ params[0] = (GLint) texUnit->EyePlaneT[0];
+ params[1] = (GLint) texUnit->EyePlaneT[1];
+ params[2] = (GLint) texUnit->EyePlaneT[2];
+ params[3] = (GLint) texUnit->EyePlaneT[3];
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" );
+ return;
+ }
+ break;
+ case GL_R:
+ if (pname==GL_TEXTURE_GEN_MODE) {
+ params[0] = texUnit->GenModeR;
+ }
+ else if (pname==GL_OBJECT_PLANE) {
+ params[0] = (GLint) texUnit->ObjectPlaneR[0];
+ params[1] = (GLint) texUnit->ObjectPlaneR[1];
+ params[2] = (GLint) texUnit->ObjectPlaneR[2];
+ params[3] = (GLint) texUnit->ObjectPlaneR[3];
+ }
+ else if (pname==GL_EYE_PLANE) {
+ params[0] = (GLint) texUnit->EyePlaneR[0];
+ params[1] = (GLint) texUnit->EyePlaneR[1];
+ params[2] = (GLint) texUnit->EyePlaneR[2];
+ params[3] = (GLint) texUnit->EyePlaneR[3];
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" );
+ return;
+ }
+ break;
+ case GL_Q:
+ if (pname==GL_TEXTURE_GEN_MODE) {
+ params[0] = texUnit->GenModeQ;
+ }
+ else if (pname==GL_OBJECT_PLANE) {
+ params[0] = (GLint) texUnit->ObjectPlaneQ[0];
+ params[1] = (GLint) texUnit->ObjectPlaneQ[1];
+ params[2] = (GLint) texUnit->ObjectPlaneQ[2];
+ params[3] = (GLint) texUnit->ObjectPlaneQ[3];
+ }
+ else if (pname==GL_EYE_PLANE) {
+ params[0] = (GLint) texUnit->EyePlaneQ[0];
+ params[1] = (GLint) texUnit->EyePlaneQ[1];
+ params[2] = (GLint) texUnit->EyePlaneQ[2];
+ params[3] = (GLint) texUnit->EyePlaneQ[3];
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(pname)" );
+ return;
+ }
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexGeniv(coord)" );
+ return;
+ }
+}
+#endif
+
+/* GL_ARB_multitexture */
+void GLAPIENTRY
+_mesa_ActiveTextureARB( GLenum target )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ const GLuint texUnit = target - GL_TEXTURE0;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
+ _mesa_debug(ctx, "glActiveTexture %s\n",
+ _mesa_lookup_enum_by_nr(target));
+
+ /* Cater for texture unit 0 is first, therefore use >= */
+ if (texUnit >= ctx->Const.MaxTextureUnits) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glActiveTexture(target)");
+ return;
+ }
+
+ if (ctx->Texture.CurrentUnit == texUnit)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_TEXTURE);
+
+ ctx->Texture.CurrentUnit = texUnit;
+ if (ctx->Transform.MatrixMode == GL_TEXTURE) {
+ /* update current stack pointer */
+ ctx->CurrentStack = &ctx->TextureMatrixStack[texUnit];
+ }
+
+ if (ctx->Driver.ActiveTexture) {
+ (*ctx->Driver.ActiveTexture)( ctx, (GLuint) texUnit );
+ }
+}
+
+
+/* GL_ARB_multitexture */
+void GLAPIENTRY
+_mesa_ClientActiveTextureARB( GLenum target )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint texUnit = target - GL_TEXTURE0;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (texUnit > ctx->Const.MaxTextureUnits) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glClientActiveTexture(target)");
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_ARRAY);
+ ctx->Array.ActiveTexture = texUnit;
+}
+
+
+
+/**********************************************************************/
+/* Pixel Texgen Extensions */
+/**********************************************************************/
+
+void GLAPIENTRY
+_mesa_PixelTexGenSGIX(GLenum mode)
+{
+ GLenum newRgbSource, newAlphaSource;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ switch (mode) {
+ case GL_NONE:
+ newRgbSource = GL_PIXEL_GROUP_COLOR_SGIS;
+ newAlphaSource = GL_PIXEL_GROUP_COLOR_SGIS;
+ break;
+ case GL_ALPHA:
+ newRgbSource = GL_PIXEL_GROUP_COLOR_SGIS;
+ newAlphaSource = GL_CURRENT_RASTER_COLOR;
+ break;
+ case GL_RGB:
+ newRgbSource = GL_CURRENT_RASTER_COLOR;
+ newAlphaSource = GL_PIXEL_GROUP_COLOR_SGIS;
+ break;
+ case GL_RGBA:
+ newRgbSource = GL_CURRENT_RASTER_COLOR;
+ newAlphaSource = GL_CURRENT_RASTER_COLOR;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glPixelTexGenSGIX(mode)");
+ return;
+ }
+
+ if (newRgbSource == ctx->Pixel.FragmentRgbSource &&
+ newAlphaSource == ctx->Pixel.FragmentAlphaSource)
+ return;
+
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.FragmentRgbSource = newRgbSource;
+ ctx->Pixel.FragmentAlphaSource = newAlphaSource;
+}
+
+
+void GLAPIENTRY
+_mesa_PixelTexGenParameterfSGIS(GLenum target, GLfloat value)
+{
+ _mesa_PixelTexGenParameteriSGIS(target, (GLint) value);
+}
+
+
+void GLAPIENTRY
+_mesa_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value)
+{
+ _mesa_PixelTexGenParameteriSGIS(target, (GLint) *value);
+}
+
+
+void GLAPIENTRY
+_mesa_PixelTexGenParameteriSGIS(GLenum target, GLint value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (value != GL_CURRENT_RASTER_COLOR && value != GL_PIXEL_GROUP_COLOR_SGIS) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glPixelTexGenParameterSGIS(value)");
+ return;
+ }
+
+ switch (target) {
+ case GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS:
+ if (ctx->Pixel.FragmentRgbSource == (GLenum) value)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.FragmentRgbSource = (GLenum) value;
+ break;
+ case GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS:
+ if (ctx->Pixel.FragmentAlphaSource == (GLenum) value)
+ return;
+ FLUSH_VERTICES(ctx, _NEW_PIXEL);
+ ctx->Pixel.FragmentAlphaSource = (GLenum) value;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glPixelTexGenParameterSGIS(target)");
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_PixelTexGenParameterivSGIS(GLenum target, const GLint *value)
+{
+ _mesa_PixelTexGenParameteriSGIS(target, *value);
+}
+
+
+void GLAPIENTRY
+_mesa_GetPixelTexGenParameterfvSGIS(GLenum target, GLfloat *value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target == GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS) {
+ *value = (GLfloat) ctx->Pixel.FragmentRgbSource;
+ }
+ else if (target == GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS) {
+ *value = (GLfloat) ctx->Pixel.FragmentAlphaSource;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelTexGenParameterfvSGIS(target)");
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetPixelTexGenParameterivSGIS(GLenum target, GLint *value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target == GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS) {
+ *value = (GLint) ctx->Pixel.FragmentRgbSource;
+ }
+ else if (target == GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS) {
+ *value = (GLint) ctx->Pixel.FragmentAlphaSource;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetPixelTexGenParameterivSGIS(target)");
+ }
+}
+
+
+
+/**********************************************************************/
+/***** State management *****/
+/**********************************************************************/
+
+
+/**
+ * \note This routine refers to derived texture attribute values to
+ * compute the ENABLE_TEXMAT flags, but is only called on
+ * _NEW_TEXTURE_MATRIX. On changes to _NEW_TEXTURE, the ENABLE_TEXMAT
+ * flags are updated by _mesa_update_textures(), below.
+ *
+ * \param ctx GL context.
+ */
+static void
+update_texture_matrices( GLcontext *ctx )
+{
+ GLuint i;
+
+ ctx->Texture._TexMatEnabled = 0;
+
+ for (i=0; i < ctx->Const.MaxTextureUnits; i++) {
+ if (_math_matrix_is_dirty(ctx->TextureMatrixStack[i].Top)) {
+ _math_matrix_analyse( ctx->TextureMatrixStack[i].Top );
+
+ if (ctx->Texture.Unit[i]._ReallyEnabled &&
+ ctx->TextureMatrixStack[i].Top->type != MATRIX_IDENTITY)
+ ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(i);
+
+ if (ctx->Driver.TextureMatrix)
+ ctx->Driver.TextureMatrix( ctx, i, ctx->TextureMatrixStack[i].Top);
+ }
+ }
+}
+
+
+
+
+/**
+ * \note This routine refers to derived texture matrix values to
+ * compute the ENABLE_TEXMAT flags, but is only called on
+ * _NEW_TEXTURE. On changes to _NEW_TEXTURE_MATRIX, the ENABLE_TEXMAT
+ * flags are updated by _mesa_update_texture_matrices, above.
+ *
+ * \param ctx GL context.
+ */
+static void
+update_texture_state( GLcontext *ctx )
+{
+ GLuint unit;
+
+ ctx->NewState |= _NEW_TEXTURE; /* TODO: only set this if there are
+ * actual changes.
+ */
+
+ ctx->Texture._EnabledUnits = 0;
+ ctx->Texture._GenFlags = 0;
+ ctx->Texture._TexMatEnabled = 0;
+ ctx->Texture._TexGenEnabled = 0;
+
+ /* Update texture unit state.
+ * XXX this loop should probably be broken into separate loops for
+ * texture coord units and texture image units.
+ */
+ for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ GLuint enableBits;
+
+ texUnit->_Current = NULL;
+ texUnit->_ReallyEnabled = 0;
+ texUnit->_GenFlags = 0;
+
+ /* Get the bitmask of texture enables */
+ if (ctx->FragmentProgram._Enabled) {
+ enableBits = ctx->FragmentProgram.Current->TexturesUsed[unit];
+ }
+ else {
+ if (!texUnit->Enabled)
+ continue;
+ enableBits = texUnit->Enabled;
+ }
+
+ /* Look for the highest-priority texture target that's enabled and
+ * complete. That's the one we'll use for texturing. If we're using
+ * a fragment program we're guaranteed that bitcount(enabledBits) <= 1.
+ */
+ if (enableBits & TEXTURE_CUBE_BIT) {
+ struct gl_texture_object *texObj = texUnit->CurrentCubeMap;
+ if (!texObj->Complete) {
+ _mesa_test_texobj_completeness(ctx, texObj);
+ }
+ if (texObj->Complete) {
+ texUnit->_ReallyEnabled = TEXTURE_CUBE_BIT;
+ texUnit->_Current = texObj;
+ }
+ }
+
+ if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_3D_BIT)) {
+ struct gl_texture_object *texObj = texUnit->Current3D;
+ if (!texObj->Complete) {
+ _mesa_test_texobj_completeness(ctx, texObj);
+ }
+ if (texObj->Complete) {
+ texUnit->_ReallyEnabled = TEXTURE_3D_BIT;
+ texUnit->_Current = texObj;
+ }
+ }
+
+ if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_RECT_BIT)) {
+ struct gl_texture_object *texObj = texUnit->CurrentRect;
+ if (!texObj->Complete) {
+ _mesa_test_texobj_completeness(ctx, texObj);
+ }
+ if (texObj->Complete) {
+ texUnit->_ReallyEnabled = TEXTURE_RECT_BIT;
+ texUnit->_Current = texObj;
+ }
+ }
+
+ if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_2D_BIT)) {
+ struct gl_texture_object *texObj = texUnit->Current2D;
+ if (!texObj->Complete) {
+ _mesa_test_texobj_completeness(ctx, texObj);
+ }
+ if (texObj->Complete) {
+ texUnit->_ReallyEnabled = TEXTURE_2D_BIT;
+ texUnit->_Current = texObj;
+ }
+ }
+
+ if (!texUnit->_ReallyEnabled && (enableBits & TEXTURE_1D_BIT)) {
+ struct gl_texture_object *texObj = texUnit->Current1D;
+ if (!texObj->Complete) {
+ _mesa_test_texobj_completeness(ctx, texObj);
+ }
+ if (texObj->Complete) {
+ texUnit->_ReallyEnabled = TEXTURE_1D_BIT;
+ texUnit->_Current = texObj;
+ }
+ }
+
+ if (!texUnit->_ReallyEnabled) {
+ continue;
+ }
+
+ if (texUnit->_ReallyEnabled)
+ ctx->Texture._EnabledUnits |= (1 << unit);
+
+ if (texUnit->EnvMode == GL_COMBINE) {
+ texUnit->_CurrentCombine = & texUnit->Combine;
+ }
+ else {
+ GLenum format = texUnit->_Current->Image[0][0]->Format;
+ if (format == GL_COLOR_INDEX) {
+ format = GL_RGBA; /* a bit of a hack */
+ }
+ else if (format == GL_DEPTH_COMPONENT) {
+ format = texUnit->_Current->DepthMode;
+ }
+ calculate_derived_texenv(&texUnit->_EnvMode, texUnit->EnvMode, format);
+ texUnit->_CurrentCombine = & texUnit->_EnvMode;
+ }
+
+ switch (texUnit->_CurrentCombine->ModeRGB) {
+ case GL_REPLACE:
+ texUnit->_CurrentCombine->_NumArgsRGB = 1;
+ break;
+ case GL_MODULATE:
+ case GL_ADD:
+ case GL_ADD_SIGNED:
+ case GL_SUBTRACT:
+ case GL_DOT3_RGB:
+ case GL_DOT3_RGBA:
+ case GL_DOT3_RGB_EXT:
+ case GL_DOT3_RGBA_EXT:
+ texUnit->_CurrentCombine->_NumArgsRGB = 2;
+ break;
+ case GL_INTERPOLATE:
+ case GL_MODULATE_ADD_ATI:
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ case GL_MODULATE_SUBTRACT_ATI:
+ texUnit->_CurrentCombine->_NumArgsRGB = 3;
+ break;
+ default:
+ texUnit->_CurrentCombine->_NumArgsRGB = 0;
+ _mesa_problem(ctx, "invalid RGB combine mode in update_texture_state");
+ return;
+ }
+
+ switch (texUnit->_CurrentCombine->ModeA) {
+ case GL_REPLACE:
+ texUnit->_CurrentCombine->_NumArgsA = 1;
+ break;
+ case GL_MODULATE:
+ case GL_ADD:
+ case GL_ADD_SIGNED:
+ case GL_SUBTRACT:
+ texUnit->_CurrentCombine->_NumArgsA = 2;
+ break;
+ case GL_INTERPOLATE:
+ case GL_MODULATE_ADD_ATI:
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ case GL_MODULATE_SUBTRACT_ATI:
+ texUnit->_CurrentCombine->_NumArgsA = 3;
+ break;
+ default:
+ texUnit->_CurrentCombine->_NumArgsA = 0;
+ _mesa_problem(ctx, "invalid Alpha combine mode in update_texture_state");
+ break;
+ }
+
+ if (texUnit->TexGenEnabled) {
+ if (texUnit->TexGenEnabled & S_BIT) {
+ texUnit->_GenFlags |= texUnit->_GenBitS;
+ }
+ if (texUnit->TexGenEnabled & T_BIT) {
+ texUnit->_GenFlags |= texUnit->_GenBitT;
+ }
+ if (texUnit->TexGenEnabled & Q_BIT) {
+ texUnit->_GenFlags |= texUnit->_GenBitQ;
+ }
+ if (texUnit->TexGenEnabled & R_BIT) {
+ texUnit->_GenFlags |= texUnit->_GenBitR;
+ }
+
+ ctx->Texture._TexGenEnabled |= ENABLE_TEXGEN(unit);
+ ctx->Texture._GenFlags |= texUnit->_GenFlags;
+ }
+
+ if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY)
+ ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit);
+ }
+
+ ctx->Texture._EnabledCoordUnits = ctx->Texture._EnabledUnits;
+ /* Fragment programs may need texture coordinates but not the
+ * corresponding texture images.
+ */
+ if (ctx->FragmentProgram._Enabled) {
+ ctx->Texture._EnabledCoordUnits |=
+ (ctx->FragmentProgram.Current->InputsRead >> FRAG_ATTRIB_TEX0);
+ }
+}
+
+
+void _mesa_update_texture( GLcontext *ctx, GLuint new_state )
+{
+ if (new_state & _NEW_TEXTURE_MATRIX)
+ update_texture_matrices( ctx );
+
+ if (new_state & (_NEW_TEXTURE | _NEW_PROGRAM))
+ update_texture_state( ctx );
+}
+
+/**********************************************************************/
+/***** Initialization *****/
+/**********************************************************************/
+
+/**
+ * Allocate the proxy textures for the given context.
+ *
+ * \param ctx the context to allocate proxies for.
+ *
+ * \return GL_TRUE on success, or GL_FALSE on failure
+ *
+ * If run out of memory part way through the allocations, clean up and return
+ * GL_FALSE.
+ */
+static GLboolean
+alloc_proxy_textures( GLcontext *ctx )
+{
+ ctx->Texture.Proxy1D = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_1D);
+ if (!ctx->Texture.Proxy1D)
+ goto cleanup;
+
+ ctx->Texture.Proxy2D = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_2D);
+ if (!ctx->Texture.Proxy2D)
+ goto cleanup;
+
+ ctx->Texture.Proxy3D = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_3D);
+ if (!ctx->Texture.Proxy3D)
+ goto cleanup;
+
+ ctx->Texture.ProxyCubeMap = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_CUBE_MAP_ARB);
+ if (!ctx->Texture.ProxyCubeMap)
+ goto cleanup;
+
+ ctx->Texture.ProxyRect = (*ctx->Driver.NewTextureObject)(ctx, 0, GL_TEXTURE_RECTANGLE_NV);
+ if (!ctx->Texture.ProxyRect)
+ goto cleanup;
+
+ return GL_TRUE;
+
+ cleanup:
+ if (ctx->Texture.Proxy1D)
+ (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1D);
+ if (ctx->Texture.Proxy2D)
+ (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy2D);
+ if (ctx->Texture.Proxy3D)
+ (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy3D);
+ if (ctx->Texture.ProxyCubeMap)
+ (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.ProxyCubeMap);
+ if (ctx->Texture.ProxyRect)
+ (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.ProxyRect);
+ return GL_FALSE;
+}
+
+
+/**
+ * Initialize a texture unit.
+ *
+ * \param ctx GL context.
+ * \param unit texture unit number to be initialized.
+ */
+static void
+init_texture_unit( GLcontext *ctx, GLuint unit )
+{
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+
+ texUnit->EnvMode = GL_MODULATE;
+ ASSIGN_4V( texUnit->EnvColor, 0.0, 0.0, 0.0, 0.0 );
+
+ texUnit->Combine = default_combine_state;
+ texUnit->_EnvMode = default_combine_state;
+ texUnit->_CurrentCombine = & texUnit->_EnvMode;
+
+ texUnit->TexGenEnabled = 0;
+ texUnit->GenModeS = GL_EYE_LINEAR;
+ texUnit->GenModeT = GL_EYE_LINEAR;
+ texUnit->GenModeR = GL_EYE_LINEAR;
+ texUnit->GenModeQ = GL_EYE_LINEAR;
+ texUnit->_GenBitS = TEXGEN_EYE_LINEAR;
+ texUnit->_GenBitT = TEXGEN_EYE_LINEAR;
+ texUnit->_GenBitR = TEXGEN_EYE_LINEAR;
+ texUnit->_GenBitQ = TEXGEN_EYE_LINEAR;
+
+ /* Yes, these plane coefficients are correct! */
+ ASSIGN_4V( texUnit->ObjectPlaneS, 1.0, 0.0, 0.0, 0.0 );
+ ASSIGN_4V( texUnit->ObjectPlaneT, 0.0, 1.0, 0.0, 0.0 );
+ ASSIGN_4V( texUnit->ObjectPlaneR, 0.0, 0.0, 0.0, 0.0 );
+ ASSIGN_4V( texUnit->ObjectPlaneQ, 0.0, 0.0, 0.0, 0.0 );
+ ASSIGN_4V( texUnit->EyePlaneS, 1.0, 0.0, 0.0, 0.0 );
+ ASSIGN_4V( texUnit->EyePlaneT, 0.0, 1.0, 0.0, 0.0 );
+ ASSIGN_4V( texUnit->EyePlaneR, 0.0, 0.0, 0.0, 0.0 );
+ ASSIGN_4V( texUnit->EyePlaneQ, 0.0, 0.0, 0.0, 0.0 );
+
+ texUnit->Current1D = ctx->Shared->Default1D;
+ texUnit->Current2D = ctx->Shared->Default2D;
+ texUnit->Current3D = ctx->Shared->Default3D;
+ texUnit->CurrentCubeMap = ctx->Shared->DefaultCubeMap;
+ texUnit->CurrentRect = ctx->Shared->DefaultRect;
+}
+
+
+GLboolean _mesa_init_texture( GLcontext * ctx )
+{
+ int i;
+
+ assert(MAX_TEXTURE_LEVELS >= MAX_3D_TEXTURE_LEVELS);
+ assert(MAX_TEXTURE_LEVELS >= MAX_CUBE_TEXTURE_LEVELS);
+
+ /* Effectively bind the default textures to all texture units */
+ ctx->Shared->Default1D->RefCount += MAX_TEXTURE_UNITS;
+ ctx->Shared->Default2D->RefCount += MAX_TEXTURE_UNITS;
+ ctx->Shared->Default3D->RefCount += MAX_TEXTURE_UNITS;
+ ctx->Shared->DefaultCubeMap->RefCount += MAX_TEXTURE_UNITS;
+ ctx->Shared->DefaultRect->RefCount += MAX_TEXTURE_UNITS;
+
+ /* Texture group */
+ ctx->Texture.CurrentUnit = 0; /* multitexture */
+ ctx->Texture._EnabledUnits = 0;
+ for (i=0; i<MAX_TEXTURE_UNITS; i++)
+ init_texture_unit( ctx, i );
+ ctx->Texture.SharedPalette = GL_FALSE;
+ _mesa_init_colortable(&ctx->Texture.Palette);
+
+ /* Allocate proxy textures */
+ if (!alloc_proxy_textures( ctx ))
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
+void _mesa_free_texture_data( GLcontext *ctx )
+{
+ int i;
+
+ /* Free proxy texture objects */
+ (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy1D );
+ (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy2D );
+ (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.Proxy3D );
+ (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.ProxyCubeMap );
+ (ctx->Driver.DeleteTexture)(ctx, ctx->Texture.ProxyRect );
+
+ for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
+ _mesa_free_colortable_data( &ctx->Texture.Unit[i].ColorTable );
+
+ _mesa_TexEnvProgramCacheDestroy( ctx );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/texstate.h b/nx-X11/extras/Mesa/src/mesa/main/texstate.h
new file mode 100644
index 000000000..7cc3d2c19
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/texstate.h
@@ -0,0 +1,192 @@
+/**
+ * \file texstate.h
+ * Texture state management.
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef TEXSTATE_H
+#define TEXSTATE_H
+
+
+#include "mtypes.h"
+
+
+extern void
+_mesa_copy_texture_state( const GLcontext *src, GLcontext *dst );
+
+extern void
+_mesa_print_texunit_state( GLcontext *ctx, GLuint unit );
+
+
+/**
+ * \name Called from API
+ */
+/*@{*/
+
+extern void GLAPIENTRY
+_mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params );
+
+extern void GLAPIENTRY
+_mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params );
+
+extern void GLAPIENTRY
+_mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params );
+
+extern void GLAPIENTRY
+_mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params );
+
+extern void GLAPIENTRY
+_mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params );
+
+extern void GLAPIENTRY
+_mesa_GetTexLevelParameterfv( GLenum target, GLint level,
+ GLenum pname, GLfloat *params );
+
+extern void GLAPIENTRY
+_mesa_GetTexLevelParameteriv( GLenum target, GLint level,
+ GLenum pname, GLint *params );
+
+extern void GLAPIENTRY
+_mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params );
+
+extern void GLAPIENTRY
+_mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params );
+
+
+extern void GLAPIENTRY
+_mesa_TexEnvf( GLenum target, GLenum pname, GLfloat param );
+
+extern void GLAPIENTRY
+_mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param );
+
+extern void GLAPIENTRY
+_mesa_TexEnvi( GLenum target, GLenum pname, GLint param );
+
+extern void GLAPIENTRY
+_mesa_TexEnviv( GLenum target, GLenum pname, const GLint *param );
+
+
+extern void GLAPIENTRY
+_mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params );
+
+extern void GLAPIENTRY
+_mesa_TexParameterf( GLenum target, GLenum pname, GLfloat param );
+
+
+extern void GLAPIENTRY
+_mesa_TexParameteri( GLenum target, GLenum pname, GLint param );
+
+extern void GLAPIENTRY
+_mesa_TexParameteriv( GLenum target, GLenum pname, const GLint *params );
+
+
+extern void GLAPIENTRY
+_mesa_TexGend( GLenum coord, GLenum pname, GLdouble param );
+
+extern void GLAPIENTRY
+_mesa_TexGendv( GLenum coord, GLenum pname, const GLdouble *params );
+
+extern void GLAPIENTRY
+_mesa_TexGenf( GLenum coord, GLenum pname, GLfloat param );
+
+extern void GLAPIENTRY
+_mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params );
+
+extern void GLAPIENTRY
+_mesa_TexGeni( GLenum coord, GLenum pname, GLint param );
+
+extern void GLAPIENTRY
+_mesa_TexGeniv( GLenum coord, GLenum pname, const GLint *params );
+
+
+/*
+ * GL_ARB_multitexture
+ */
+extern void GLAPIENTRY
+_mesa_ActiveTextureARB( GLenum target );
+
+extern void GLAPIENTRY
+_mesa_ClientActiveTextureARB( GLenum target );
+
+
+/*
+ * Pixel Texture Extensions
+ */
+
+extern void GLAPIENTRY
+_mesa_PixelTexGenSGIX(GLenum mode);
+
+extern void GLAPIENTRY
+_mesa_PixelTexGenParameterfSGIS(GLenum target, GLfloat value);
+
+#ifdef VMS
+#define _mesa_PixelTexGenParameterfvSGIS _mesa_PixelTexGenParameterfv
+#endif
+extern void GLAPIENTRY
+_mesa_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value);
+
+extern void GLAPIENTRY
+_mesa_PixelTexGenParameteriSGIS(GLenum target, GLint value);
+
+#ifdef VMS
+#define _mesa_PixelTexGenParameterivSGIS _mesa_PixelTexGenParameteriv
+#endif
+extern void GLAPIENTRY
+_mesa_PixelTexGenParameterivSGIS(GLenum target, const GLint *value);
+
+#ifdef VMS
+#define _mesa_GetPixelTexGenParameterfvSGIS _mesa_GetPixelTexGenParameterfv
+#endif
+extern void GLAPIENTRY
+_mesa_GetPixelTexGenParameterfvSGIS(GLenum target, GLfloat *value);
+
+#ifdef VMS
+#define _mesa_GetPixelTexGenParameterivSGIS _mesa_GetPixelTexGenParameteriv
+#endif
+extern void GLAPIENTRY
+_mesa_GetPixelTexGenParameterivSGIS(GLenum target, GLint *value);
+
+/*@}*/
+
+
+/**
+ * \name Initialization, state maintenance
+ */
+/*@{*/
+
+extern void
+_mesa_update_texture( GLcontext *ctx, GLuint new_state );
+
+extern GLboolean
+_mesa_init_texture( GLcontext *ctx );
+
+extern void
+_mesa_free_texture_data( GLcontext *ctx );
+
+/*@}*/
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/texstore.c b/nx-X11/extras/Mesa/src/mesa/main/texstore.c
new file mode 100644
index 000000000..af1bbf57e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/texstore.c
@@ -0,0 +1,4055 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Authors:
+ * Brian Paul
+ */
+
+/*
+ * The GL texture image functions in teximage.c basically just do
+ * error checking and data structure allocation. They in turn call
+ * device driver functions which actually copy/convert/store the user's
+ * texture image data.
+ *
+ * However, most device drivers will be able to use the fallback functions
+ * in this file. That is, most drivers will have the following bit of
+ * code:
+ * ctx->Driver.TexImage1D = _mesa_store_teximage1d;
+ * ctx->Driver.TexImage2D = _mesa_store_teximage2d;
+ * ctx->Driver.TexImage3D = _mesa_store_teximage3d;
+ * etc...
+ *
+ * Texture image processing is actually kind of complicated. We have to do:
+ * Format/type conversions
+ * pixel unpacking
+ * pixel transfer (scale, bais, lookup, convolution!, etc)
+ *
+ * These functions can handle most everything, including processing full
+ * images and sub-images.
+ */
+
+
+#include "glheader.h"
+#include "bufferobj.h"
+#include "colormac.h"
+#include "context.h"
+#include "convolve.h"
+#include "image.h"
+#include "macros.h"
+#include "imports.h"
+#include "texcompress.h"
+#include "texformat.h"
+#include "teximage.h"
+#include "texstore.h"
+
+
+static const GLint ZERO = 4, ONE = 5;
+
+static GLboolean can_swizzle(GLenum logicalBaseFormat)
+{
+ switch (logicalBaseFormat) {
+ case GL_RGBA:
+ case GL_RGB:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/**
+ * When promoting texture formats (see below) we need to compute the
+ * mapping of dest components back to source components.
+ * This function does that.
+ * \param logicalBaseFormat the logical format of the texture
+ * \param textureBaseFormat the final texture format
+ * \return map[4] the four mapping values
+ */
+static void
+compute_component_mapping(GLenum logicalBaseFormat, GLenum textureBaseFormat,
+ GLubyte map[6])
+{
+ map[ZERO] = ZERO;
+ map[ONE] = ONE;
+
+ /* compute mapping from dest components back to src components */
+ switch (textureBaseFormat) {
+ case GL_RGB:
+ case GL_RGBA:
+ switch (logicalBaseFormat) {
+ case GL_LUMINANCE:
+ map[0] = map[1] = map[2] = 0;
+ if (textureBaseFormat == GL_RGBA)
+ map[3] = ONE;
+ break;
+ case GL_ALPHA:
+ ASSERT(textureBaseFormat == GL_RGBA);
+ map[0] = map[1] = map[2] = ZERO;
+ map[3] = 0;
+ break;
+ case GL_INTENSITY:
+ map[0] = map[1] = map[2] = 0;
+ if (textureBaseFormat == GL_RGBA)
+ map[3] = 0;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ ASSERT(textureBaseFormat == GL_RGBA);
+ map[0] = map[1] = map[2] = 0;
+ map[3] = 1;
+ break;
+ case GL_RGB:
+ ASSERT(textureBaseFormat == GL_RGBA);
+ map[0] = 0;
+ map[1] = 1;
+ map[2] = 2;
+ map[3] = ONE;
+ break;
+ case GL_RGBA:
+ ASSERT(textureBaseFormat == GL_RGBA);
+ map[0] = 0;
+ map[1] = 1;
+ map[2] = 2;
+ map[3] = 3;
+ break;
+ default:
+ _mesa_problem(NULL, "Unexpected logicalBaseFormat");
+ map[0] = map[1] = map[2] = map[3] = 0;
+ }
+ break;
+ case GL_LUMINANCE_ALPHA:
+ switch (logicalBaseFormat) {
+ case GL_LUMINANCE:
+ map[0] = 0;
+ map[1] = ONE;
+ break;
+ case GL_ALPHA:
+ map[0] = ZERO;
+ map[1] = 0;
+ break;
+ case GL_INTENSITY:
+ map[0] = 0;
+ map[1] = 0;
+ break;
+ default:
+ _mesa_problem(NULL, "Unexpected logicalBaseFormat");
+ map[0] = map[1] = 0;
+ }
+ break;
+ default:
+ _mesa_problem(NULL, "Unexpected logicalBaseFormat");
+ map[0] = map[1] = 0;
+ break;
+ }
+}
+
+
+/**
+ * Make a temporary (color) texture image with GLfloat components.
+ * Apply all needed pixel unpacking and pixel transfer operations.
+ * Note that there are both logicalBaseFormat and textureBaseFormat parameters.
+ * Suppose the user specifies GL_LUMINANCE as the internal texture format
+ * but the graphics hardware doesn't support luminance textures. So, might
+ * use an RGB hardware format instead.
+ * If logicalBaseFormat != textureBaseFormat we have some extra work to do.
+ *
+ * \param ctx the rendering context
+ * \param dims image dimensions: 1, 2 or 3
+ * \param logicalBaseFormat basic texture derived from the user's
+ * internal texture format value
+ * \param textureBaseFormat the actual basic format of the texture
+ * \param srcWidth source image width
+ * \param srcHeight source image height
+ * \param srcDepth source image depth
+ * \param srcFormat source image format
+ * \param srcType source image type
+ * \param srcAddr source image address
+ * \param srcPacking source image pixel packing
+ * \return resulting image with format = textureBaseFormat and type = GLfloat.
+ */
+static GLfloat *
+make_temp_float_image(GLcontext *ctx, GLuint dims,
+ GLenum logicalBaseFormat,
+ GLenum textureBaseFormat,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *srcAddr,
+ const struct gl_pixelstore_attrib *srcPacking)
+{
+ GLuint transferOps = ctx->_ImageTransferState;
+ GLfloat *tempImage;
+
+ ASSERT(dims >= 1 && dims <= 3);
+
+ ASSERT(logicalBaseFormat == GL_RGBA ||
+ logicalBaseFormat == GL_RGB ||
+ logicalBaseFormat == GL_LUMINANCE_ALPHA ||
+ logicalBaseFormat == GL_LUMINANCE ||
+ logicalBaseFormat == GL_ALPHA ||
+ logicalBaseFormat == GL_INTENSITY ||
+ logicalBaseFormat == GL_COLOR_INDEX ||
+ logicalBaseFormat == GL_DEPTH_COMPONENT);
+
+ ASSERT(textureBaseFormat == GL_RGBA ||
+ textureBaseFormat == GL_RGB ||
+ textureBaseFormat == GL_LUMINANCE_ALPHA ||
+ textureBaseFormat == GL_LUMINANCE ||
+ textureBaseFormat == GL_ALPHA ||
+ textureBaseFormat == GL_INTENSITY ||
+ textureBaseFormat == GL_COLOR_INDEX ||
+ textureBaseFormat == GL_DEPTH_COMPONENT);
+
+ /* conventional color image */
+
+ if ((dims == 1 && ctx->Pixel.Convolution1DEnabled) ||
+ (dims >= 2 && ctx->Pixel.Convolution2DEnabled) ||
+ (dims >= 2 && ctx->Pixel.Separable2DEnabled)) {
+ /* need image convolution */
+ const GLuint preConvTransferOps
+ = (transferOps & IMAGE_PRE_CONVOLUTION_BITS) | IMAGE_CLAMP_BIT;
+ const GLuint postConvTransferOps
+ = (transferOps & IMAGE_POST_CONVOLUTION_BITS) | IMAGE_CLAMP_BIT;
+ GLint img, row;
+ GLint convWidth, convHeight;
+ GLfloat *convImage;
+
+ /* pre-convolution image buffer (3D) */
+ tempImage = (GLfloat *) _mesa_malloc(srcWidth * srcHeight * srcDepth
+ * 4 * sizeof(GLfloat));
+ if (!tempImage)
+ return NULL;
+
+ /* post-convolution image buffer (2D) */
+ convImage = (GLfloat *) _mesa_malloc(srcWidth * srcHeight
+ * 4 * sizeof(GLfloat));
+ if (!convImage) {
+ _mesa_free(tempImage);
+ return NULL;
+ }
+
+ /* loop over 3D image slices */
+ for (img = 0; img < srcDepth; img++) {
+ GLfloat *dst = tempImage + img * (srcWidth * srcHeight * 4);
+
+ /* unpack and do transfer ops up to convolution */
+ for (row = 0; row < srcHeight; row++) {
+ const GLvoid *src = _mesa_image_address(dims, srcPacking,
+ srcAddr, srcWidth, srcHeight,
+ srcFormat, srcType, img, row, 0);
+ _mesa_unpack_color_span_float(ctx, srcWidth, GL_RGBA, dst,
+ srcFormat, srcType, src,
+ srcPacking,
+ preConvTransferOps);
+ dst += srcWidth * 4;
+ }
+
+ /* do convolution */
+ {
+ GLfloat *src = tempImage + img * (srcWidth * srcHeight * 4);
+ convWidth = srcWidth;
+ convHeight = srcHeight;
+ if (dims == 1) {
+ ASSERT(ctx->Pixel.Convolution1DEnabled);
+ _mesa_convolve_1d_image(ctx, &convWidth, src, convImage);
+ }
+ else {
+ if (ctx->Pixel.Convolution2DEnabled) {
+ _mesa_convolve_2d_image(ctx, &convWidth, &convHeight,
+ src, convImage);
+ }
+ else {
+ ASSERT(ctx->Pixel.Separable2DEnabled);
+ _mesa_convolve_sep_image(ctx, &convWidth, &convHeight,
+ src, convImage);
+ }
+ }
+ }
+
+ /* do post-convolution transfer and pack into tempImage */
+ {
+ const GLint logComponents
+ = _mesa_components_in_format(logicalBaseFormat);
+ const GLfloat *src = convImage;
+ GLfloat *dst = tempImage + img * (convWidth * convHeight * 4);
+ for (row = 0; row < convHeight; row++) {
+ _mesa_pack_rgba_span_float(ctx, convWidth,
+ (const GLfloat (*)[4]) src,
+ logicalBaseFormat, GL_FLOAT,
+ dst, &ctx->DefaultPacking,
+ postConvTransferOps);
+ src += convWidth * 4;
+ dst += convWidth * logComponents;
+ }
+ }
+ } /* loop over 3D image slices */
+
+ _mesa_free(convImage);
+
+ /* might need these below */
+ srcWidth = convWidth;
+ srcHeight = convHeight;
+ }
+ else {
+ /* no convolution */
+ const GLint components = _mesa_components_in_format(logicalBaseFormat);
+ const GLint srcStride = _mesa_image_row_stride(srcPacking,
+ srcWidth, srcFormat, srcType);
+ GLfloat *dst;
+ GLint img, row;
+
+ tempImage = (GLfloat *) _mesa_malloc(srcWidth * srcHeight * srcDepth
+ * components * sizeof(GLfloat));
+ if (!tempImage)
+ return NULL;
+
+ dst = tempImage;
+ for (img = 0; img < srcDepth; img++) {
+ const GLubyte *src
+ = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
+ srcWidth, srcHeight,
+ srcFormat, srcType,
+ img, 0, 0);
+ for (row = 0; row < srcHeight; row++) {
+ _mesa_unpack_color_span_float(ctx, srcWidth, logicalBaseFormat,
+ dst, srcFormat, srcType, src,
+ srcPacking, transferOps);
+ dst += srcWidth * components;
+ src += srcStride;
+ }
+ }
+ }
+
+ if (logicalBaseFormat != textureBaseFormat) {
+ /* more work */
+ GLint texComponents = _mesa_components_in_format(textureBaseFormat);
+ GLint logComponents = _mesa_components_in_format(logicalBaseFormat);
+ GLfloat *newImage;
+ GLint i, n;
+ GLubyte map[6];
+
+ /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */
+ ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA ||
+ textureBaseFormat == GL_LUMINANCE_ALPHA);
+
+ /* The actual texture format should have at least as many components
+ * as the logical texture format.
+ */
+ ASSERT(texComponents >= logComponents);
+
+ newImage = (GLfloat *) _mesa_malloc(srcWidth * srcHeight * srcDepth
+ * texComponents * sizeof(GLfloat));
+ if (!newImage) {
+ _mesa_free(tempImage);
+ return NULL;
+ }
+
+ compute_component_mapping(logicalBaseFormat, textureBaseFormat, map);
+
+ n = srcWidth * srcHeight * srcDepth;
+ for (i = 0; i < n; i++) {
+ GLint k;
+ for (k = 0; k < texComponents; k++) {
+ GLint j = map[k];
+ if (j == ZERO)
+ newImage[i * texComponents + k] = 0.0F;
+ else if (j == ONE)
+ newImage[i * texComponents + k] = 1.0F;
+ else
+ newImage[i * texComponents + k] = tempImage[i * logComponents + j];
+ }
+ }
+
+ _mesa_free(tempImage);
+ tempImage = newImage;
+ }
+
+ return tempImage;
+}
+
+
+/**
+ * Make a temporary (color) texture image with GLchan components.
+ * Apply all needed pixel unpacking and pixel transfer operations.
+ * Note that there are both logicalBaseFormat and textureBaseFormat parameters.
+ * Suppose the user specifies GL_LUMINANCE as the internal texture format
+ * but the graphics hardware doesn't support luminance textures. So, might
+ * use an RGB hardware format instead.
+ * If logicalBaseFormat != textureBaseFormat we have some extra work to do.
+ *
+ * \param ctx the rendering context
+ * \param dims image dimensions: 1, 2 or 3
+ * \param logicalBaseFormat basic texture derived from the user's
+ * internal texture format value
+ * \param textureBaseFormat the actual basic format of the texture
+ * \param srcWidth source image width
+ * \param srcHeight source image height
+ * \param srcDepth source image depth
+ * \param srcFormat source image format
+ * \param srcType source image type
+ * \param srcAddr source image address
+ * \param srcPacking source image pixel packing
+ * \return resulting image with format = textureBaseFormat and type = GLchan.
+ */
+GLchan *
+_mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims,
+ GLenum logicalBaseFormat,
+ GLenum textureBaseFormat,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *srcAddr,
+ const struct gl_pixelstore_attrib *srcPacking)
+{
+ GLuint transferOps = ctx->_ImageTransferState;
+ const GLint components = _mesa_components_in_format(logicalBaseFormat);
+ GLboolean freeSrcImage = GL_FALSE;
+ GLint img, row;
+ GLchan *tempImage, *dst;
+
+ ASSERT(dims >= 1 && dims <= 3);
+
+ ASSERT(logicalBaseFormat == GL_RGBA ||
+ logicalBaseFormat == GL_RGB ||
+ logicalBaseFormat == GL_LUMINANCE_ALPHA ||
+ logicalBaseFormat == GL_LUMINANCE ||
+ logicalBaseFormat == GL_ALPHA ||
+ logicalBaseFormat == GL_INTENSITY);
+
+ ASSERT(textureBaseFormat == GL_RGBA ||
+ textureBaseFormat == GL_RGB ||
+ textureBaseFormat == GL_LUMINANCE_ALPHA ||
+ textureBaseFormat == GL_LUMINANCE ||
+ textureBaseFormat == GL_ALPHA ||
+ textureBaseFormat == GL_INTENSITY);
+
+ if ((dims == 1 && ctx->Pixel.Convolution1DEnabled) ||
+ (dims >= 2 && ctx->Pixel.Convolution2DEnabled) ||
+ (dims >= 2 && ctx->Pixel.Separable2DEnabled)) {
+ /* get convolved image */
+ GLfloat *convImage = make_temp_float_image(ctx, dims,
+ logicalBaseFormat,
+ logicalBaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType,
+ srcAddr, srcPacking);
+ if (!convImage)
+ return NULL;
+ /* the convolved image is our new source image */
+ srcAddr = convImage;
+ srcFormat = logicalBaseFormat;
+ srcType = GL_FLOAT;
+ srcPacking = &ctx->DefaultPacking;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ transferOps = 0;
+ freeSrcImage = GL_TRUE;
+ }
+
+ /* unpack and transfer the source image */
+ tempImage = (GLchan *) _mesa_malloc(srcWidth * srcHeight * srcDepth
+ * components * sizeof(GLchan));
+ if (!tempImage)
+ return NULL;
+
+ dst = tempImage;
+ for (img = 0; img < srcDepth; img++) {
+ const GLint srcStride = _mesa_image_row_stride(srcPacking,
+ srcWidth, srcFormat,
+ srcType);
+ const GLubyte *src
+ = (const GLubyte *) _mesa_image_address(dims, srcPacking, srcAddr,
+ srcWidth, srcHeight,
+ srcFormat, srcType,
+ img, 0, 0);
+ for (row = 0; row < srcHeight; row++) {
+ _mesa_unpack_color_span_chan(ctx, srcWidth, logicalBaseFormat, dst,
+ srcFormat, srcType, src, srcPacking,
+ transferOps);
+ dst += srcWidth * components;
+ src += srcStride;
+ }
+ }
+
+ /* If we made a temporary image for convolution, free it here */
+ if (freeSrcImage) {
+ _mesa_free((void *) srcAddr);
+ }
+
+ if (logicalBaseFormat != textureBaseFormat) {
+ /* one more conversion step */
+ GLint texComponents = _mesa_components_in_format(textureBaseFormat);
+ GLint logComponents = _mesa_components_in_format(logicalBaseFormat);
+ GLchan *newImage;
+ GLint i, n;
+ GLubyte map[6];
+
+ /* we only promote up to RGB, RGBA and LUMINANCE_ALPHA formats for now */
+ ASSERT(textureBaseFormat == GL_RGB || textureBaseFormat == GL_RGBA ||
+ textureBaseFormat == GL_LUMINANCE_ALPHA);
+
+ /* The actual texture format should have at least as many components
+ * as the logical texture format.
+ */
+ ASSERT(texComponents >= logComponents);
+
+ newImage = (GLchan *) _mesa_malloc(srcWidth * srcHeight * srcDepth
+ * texComponents * sizeof(GLchan));
+ if (!newImage) {
+ _mesa_free(tempImage);
+ return NULL;
+ }
+
+ compute_component_mapping(logicalBaseFormat, textureBaseFormat, map);
+
+ n = srcWidth * srcHeight * srcDepth;
+ for (i = 0; i < n; i++) {
+ GLint k;
+ for (k = 0; k < texComponents; k++) {
+ GLint j = map[k];
+ if (j == ZERO)
+ newImage[i * texComponents + k] = 0;
+ else if (j == ONE)
+ newImage[i * texComponents + k] = CHAN_MAX;
+ else
+ newImage[i * texComponents + k] = tempImage[i * logComponents + j];
+ }
+ }
+
+ _mesa_free(tempImage);
+ tempImage = newImage;
+ }
+
+ return tempImage;
+}
+
+
+/**
+ * Copy GLubyte pixels from <src> to <dst> with swizzling.
+ * \param dst destination pixels
+ * \param dstComponents number of color components in destination pixels
+ * \param src source pixels
+ * \param srcComponents number of color components in source pixels
+ * \param map the swizzle mapping
+ * \param count number of pixels to copy/swizzle.
+ */
+static void
+swizzle_copy(GLubyte *dst, GLuint dstComponents, const GLubyte *src,
+ GLuint srcComponents, const GLubyte *map, GLuint count)
+{
+ GLubyte tmp[8];
+ GLint i;
+
+ tmp[ZERO] = 0x0;
+ tmp[ONE] = 0xff;
+
+ switch (dstComponents) {
+ case 4:
+ for (i = 0; i < count; i++) {
+ COPY_4UBV(tmp, src);
+ src += srcComponents;
+ dst[0] = tmp[map[0]];
+ dst[1] = tmp[map[1]];
+ dst[2] = tmp[map[2]];
+ dst[3] = tmp[map[3]];
+ dst += 4;
+ }
+ break;
+ case 3:
+ for (i = 0; i < count; i++) {
+ COPY_4UBV(tmp, src);
+ src += srcComponents;
+ dst[0] = tmp[map[0]];
+ dst[1] = tmp[map[1]];
+ dst[2] = tmp[map[2]];
+ dst += 3;
+ }
+ break;
+ case 2:
+ for (i = 0; i < count; i++) {
+ COPY_4UBV(tmp, src);
+ src += srcComponents;
+ dst[0] = tmp[map[0]];
+ dst[1] = tmp[map[1]];
+ dst += 2;
+ }
+ break;
+ }
+}
+
+
+/**
+ * Transfer a GLubyte texture image with component swizzling.
+ */
+static void
+_mesa_swizzle_ubyte_image(GLcontext *ctx,
+ GLuint dimensions,
+ GLenum srcFormat,
+ const GLubyte *dstmap, GLint dstComponents,
+
+ GLvoid *dstAddr,
+ GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
+ GLint dstRowStride, GLint dstImageStride,
+
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ const GLvoid *srcAddr,
+ const struct gl_pixelstore_attrib *srcPacking )
+{
+ GLint srcComponents = _mesa_components_in_format(srcFormat);
+ GLubyte srcmap[6], map[4];
+ GLint i;
+
+ const GLint srcRowStride =
+ _mesa_image_row_stride(srcPacking, srcWidth,
+ srcFormat, GL_UNSIGNED_BYTE);
+ const GLint srcImageStride
+ = _mesa_image_image_stride(srcPacking, srcWidth, srcHeight, srcFormat,
+ GL_UNSIGNED_BYTE);
+ const GLubyte *srcImage
+ = (const GLubyte *) _mesa_image_address(dimensions, srcPacking, srcAddr,
+ srcWidth, srcHeight, srcFormat,
+ GL_UNSIGNED_BYTE, 0, 0, 0);
+
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstComponents;
+
+ compute_component_mapping(srcFormat, GL_RGBA, srcmap);
+
+ for (i = 0; i < 4; i++)
+ map[i] = srcmap[dstmap[i]];
+
+ if (srcRowStride == srcWidth * srcComponents &&
+ (srcImageStride == srcWidth * srcHeight * srcComponents ||
+ srcDepth == 1)) {
+ swizzle_copy(dstImage, dstComponents, srcImage, srcComponents, map,
+ srcWidth * srcHeight * srcDepth);
+ }
+ else {
+ GLint img, row;
+ for (img = 0; img < srcDepth; img++) {
+ const GLubyte *srcRow = srcImage;
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ swizzle_copy(dstRow, dstComponents, srcRow, srcComponents, map, srcWidth);
+ dstRow += dstRowStride;
+ srcRow += srcRowStride;
+ }
+ srcImage += srcImageStride;
+ dstImage += dstImageStride;
+ }
+ }
+}
+
+
+/**
+ * Teximage storage routine for when a simple memcpy will do.
+ * No pixel transfer operations or special texel encodings allowed.
+ * 1D, 2D and 3D images supported.
+ */
+static void
+memcpy_texture(GLcontext *ctx,
+ GLuint dimensions,
+ const struct gl_texture_format *dstFormat,
+ GLvoid *dstAddr,
+ GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
+ GLint dstRowStride, GLint dstImageStride,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *srcAddr,
+ const struct gl_pixelstore_attrib *srcPacking)
+{
+ const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth,
+ srcFormat, srcType);
+ const GLint srcImageStride = _mesa_image_image_stride(srcPacking,
+ srcWidth, srcHeight, srcFormat, srcType);
+ const GLubyte *srcImage = (const GLubyte *) _mesa_image_address(dimensions,
+ srcPacking, srcAddr, srcWidth, srcHeight, srcFormat, srcType, 0, 0, 0);
+ const GLint bytesPerRow = srcWidth * dstFormat->TexelBytes;
+ const GLint bytesPerImage = srcHeight * bytesPerRow;
+ const GLint bytesPerTexture = srcDepth * bytesPerImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+
+ if (dstRowStride == srcRowStride &&
+ dstRowStride == bytesPerRow &&
+ ((dstImageStride == srcImageStride &&
+ dstImageStride == bytesPerImage) ||
+ (srcDepth == 1))) {
+ /* one big memcpy */
+ ctx->Driver.TextureMemCpy(dstImage, srcImage, bytesPerTexture);
+ }
+ else {
+ GLint img, row;
+ for (img = 0; img < srcDepth; img++) {
+ const GLubyte *srcRow = srcImage;
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ ctx->Driver.TextureMemCpy(dstRow, srcRow, bytesPerRow);
+ dstRow += dstRowStride;
+ srcRow += srcRowStride;
+ }
+ srcImage += srcImageStride;
+ dstImage += dstImageStride;
+ }
+ }
+}
+
+
+
+/**
+ * Store an image in any of the formats:
+ * _mesa_texformat_rgba
+ * _mesa_texformat_rgb
+ * _mesa_texformat_alpha
+ * _mesa_texformat_luminance
+ * _mesa_texformat_luminance_alpha
+ * _mesa_texformat_intensity
+ *
+ * \param dims either 1 or 2 or 3
+ * \param baseInternalFormat user-specified base internal format
+ * \param dstFormat destination Mesa texture format
+ * \param dstAddr destination image address
+ * \param dstX/Y/Zoffset destination x/y/z offset (ala TexSubImage), in texels
+ * \param dstRowStride destination image row stride, in bytes
+ * \param dstImageStride destination image layer stride, in bytes
+ * \param srcWidth/Height/Depth source image size, in pixels
+ * \param srcFormat incoming image format
+ * \param srcType incoming image data type
+ * \param srcAddr source image address
+ * \param srcPacking source image packing parameters
+ */
+GLboolean
+_mesa_texstore_rgba(GLcontext *ctx, GLuint dims,
+ GLenum baseInternalFormat,
+ const struct gl_texture_format *dstFormat,
+ GLvoid *dstAddr,
+ GLint dstXoffset, GLint dstYoffset, GLint dstZoffset,
+ GLint dstRowStride, GLint dstImageStride,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *srcAddr,
+ const struct gl_pixelstore_attrib *srcPacking)
+{
+ const GLint components = _mesa_components_in_format(baseInternalFormat);
+
+ ASSERT(dstFormat == &_mesa_texformat_rgba ||
+ dstFormat == &_mesa_texformat_rgb ||
+ dstFormat == &_mesa_texformat_alpha ||
+ dstFormat == &_mesa_texformat_luminance ||
+ dstFormat == &_mesa_texformat_luminance_alpha ||
+ dstFormat == &_mesa_texformat_intensity);
+ ASSERT(baseInternalFormat == GL_RGBA ||
+ baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_ALPHA ||
+ baseInternalFormat == GL_LUMINANCE ||
+ baseInternalFormat == GL_LUMINANCE_ALPHA ||
+ baseInternalFormat == GL_INTENSITY);
+ ASSERT(dstFormat->TexelBytes == components * sizeof(GLchan));
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == srcFormat &&
+ srcType == CHAN_TYPE) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ dstFormat == &_mesa_texformat_rgb &&
+ srcFormat == GL_RGBA &&
+ srcType == CHAN_TYPE) {
+ /* extract RGB from RGBA */
+ int img, row, col;
+ GLchan *dstImage = (GLchan *) (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ for (img = 0; img < srcDepth; img++) {
+ const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
+ srcWidth, srcFormat, srcType);
+ GLchan *srcRow = (GLchan *) _mesa_image_address(dims, srcPacking,
+ srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
+ GLchan *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col * 3 + RCOMP] = srcRow[col * 4 + RCOMP];
+ dstRow[col * 3 + GCOMP] = srcRow[col * 4 + GCOMP];
+ dstRow[col * 3 + BCOMP] = srcRow[col * 4 + BCOMP];
+ }
+ dstRow += dstRowStride;
+ srcRow = (GLchan *) ((GLubyte *) srcRow + srcRowStride);
+ }
+ dstImage += dstImageStride;
+ }
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLint bytesPerRow;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ bytesPerRow = srcWidth * components * sizeof(GLchan);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ _mesa_memcpy(dstRow, src, bytesPerRow);
+ dstRow += dstRowStride;
+ src += srcWidth * components;
+ }
+ dstImage += dstImageStride;
+ }
+
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+/**
+ * Store a floating point depth component texture image.
+ */
+GLboolean
+_mesa_texstore_depth_component_float32(STORE_PARAMS)
+{
+ (void) dims;
+ ASSERT(dstFormat == &_mesa_texformat_depth_component_float32);
+ ASSERT(dstFormat->TexelBytes == sizeof(GLfloat));
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_DEPTH_COMPONENT &&
+ srcFormat == GL_DEPTH_COMPONENT &&
+ srcType == GL_FLOAT) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row;
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ const GLvoid *src = _mesa_image_address(dims, srcPacking,
+ srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
+ _mesa_unpack_depth_span(ctx, srcWidth, (GLfloat *) dstRow,
+ srcType, src, srcPacking);
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ }
+ return GL_TRUE;
+}
+
+
+/**
+ * Store a 16-bit integer depth component texture image.
+ */
+GLboolean
+_mesa_texstore_depth_component16(STORE_PARAMS)
+{
+ (void) dims;
+ ASSERT(dstFormat == &_mesa_texformat_depth_component16);
+ ASSERT(dstFormat->TexelBytes == sizeof(GLushort));
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_DEPTH_COMPONENT &&
+ srcFormat == GL_DEPTH_COMPONENT &&
+ srcType == GL_UNSIGNED_SHORT) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLfloat depthTemp[MAX_WIDTH];
+ const GLvoid *src = _mesa_image_address(dims, srcPacking,
+ srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
+ GLushort *dst16 = (GLushort *) dstRow;
+ _mesa_unpack_depth_span(ctx, srcWidth, depthTemp,
+ srcType, src, srcPacking);
+ for (col = 0; col < srcWidth; col++) {
+ dst16[col] = (GLushort) (depthTemp[col] * 65535.0F);
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ }
+ return GL_TRUE;
+}
+
+
+/**
+ * Store an rgb565 or rgb565_rev texture image.
+ */
+GLboolean
+_mesa_texstore_rgb565(STORE_PARAMS)
+{
+ ASSERT(dstFormat == &_mesa_texformat_rgb565 ||
+ dstFormat == &_mesa_texformat_rgb565_rev);
+ ASSERT(dstFormat->TexelBytes == 2);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ dstFormat == &_mesa_texformat_rgb565 &&
+ baseInternalFormat == GL_RGB &&
+ srcFormat == GL_RGB &&
+ srcType == GL_UNSIGNED_SHORT_5_6_5) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGB &&
+ srcFormat == GL_RGB &&
+ srcType == GL_UNSIGNED_BYTE &&
+ dims == 2) {
+ /* do optimized tex store */
+ const GLint srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth,
+ srcFormat, srcType);
+ const GLubyte *src = (const GLubyte *)
+ _mesa_image_address(dims, srcPacking, srcAddr, srcWidth, srcHeight,
+ srcFormat, srcType, 0, 0, 0);
+ GLubyte *dst = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint row, col;
+ for (row = 0; row < srcHeight; row++) {
+ const GLubyte *srcUB = (const GLubyte *) src;
+ GLushort *dstUS = (GLushort *) dst;
+ /* check for byteswapped format */
+ if (dstFormat == &_mesa_texformat_rgb565) {
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_565( srcUB[0], srcUB[1], srcUB[2] );
+ srcUB += 3;
+ }
+ }
+ else {
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_565_REV( srcUB[0], srcUB[1], srcUB[2] );
+ srcUB += 3;
+ }
+ }
+ dst += dstRowStride;
+ src += srcRowStride;
+ }
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLushort *dstUS = (GLushort *) dstRow;
+ /* check for byteswapped format */
+ if (dstFormat == &_mesa_texformat_rgb565) {
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_565( CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]) );
+ src += 3;
+ }
+ }
+ else {
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_565_REV( CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]) );
+ src += 3;
+ }
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
+_mesa_texstore_rgba8888(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ (void)littleEndian;
+ ASSERT(dstFormat == &_mesa_texformat_rgba8888 ||
+ dstFormat == &_mesa_texformat_rgba8888_rev);
+ ASSERT(dstFormat->TexelBytes == 4);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ dstFormat == &_mesa_texformat_rgba8888 &&
+ baseInternalFormat == GL_RGBA &&
+ ((srcFormat == GL_RGBA && srcType == GL_UNSIGNED_INT_8_8_8_8) ||
+ (srcFormat == GL_ABGR_EXT && srcType == GL_UNSIGNED_INT_8_8_8_8_REV))) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+#if 0
+ else if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ srcType == GL_UNSIGNED_BYTE &&
+ dstFormat == &_mesa_texformat_rgba8888 &&
+ littleEndian &&
+ /* Three texture formats involved: srcFormat,
+ * baseInternalFormat and destFormat (GL_RGBA). Only two
+ * may differ. _mesa_swizzle_ubyte_image can't handle two
+ * propagations at once correctly. */
+ (srcFormat == baseInternalFormat ||
+ baseInternalFormat == GL_RGBA) &&
+ can_swizzle(srcFormat)) {
+ GLubyte dstmap[4];
+
+ /* dstmap - how to swizzle from GL_RGBA to dst format:
+ *
+ * FIXME - add !litteEndian and _rev varients:
+ */
+ dstmap[3] = 0;
+ dstmap[2] = 1;
+ dstmap[1] = 2;
+ dstmap[0] = 3;
+
+ _mesa_swizzle_ubyte_image(ctx, dims,
+ srcFormat,
+ dstmap, 4,
+ dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcAddr,
+ srcPacking);
+ }
+#endif
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLuint *dstUI = (GLuint *) dstRow;
+ if (dstFormat == &_mesa_texformat_rgba8888) {
+ for (col = 0; col < srcWidth; col++) {
+ dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]),
+ CHAN_TO_UBYTE(src[ACOMP]) );
+ src += 4;
+ }
+ }
+ else {
+ for (col = 0; col < srcWidth; col++) {
+ dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]),
+ CHAN_TO_UBYTE(src[ACOMP]) );
+ src += 4;
+ }
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
+_mesa_texstore_argb8888(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ ASSERT(dstFormat == &_mesa_texformat_argb8888 ||
+ dstFormat == &_mesa_texformat_argb8888_rev);
+ ASSERT(dstFormat->TexelBytes == 4);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ dstFormat == &_mesa_texformat_argb8888 &&
+ baseInternalFormat == GL_RGBA &&
+ srcFormat == GL_BGRA &&
+ ((srcType == GL_UNSIGNED_BYTE && littleEndian) ||
+ srcType == GL_UNSIGNED_INT_8_8_8_8_REV)) {
+ /* simple memcpy path (little endian) */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ dstFormat == &_mesa_texformat_argb8888_rev &&
+ baseInternalFormat == GL_RGBA &&
+ srcFormat == GL_BGRA &&
+ ((srcType == GL_UNSIGNED_BYTE && !littleEndian) ||
+ srcType == GL_UNSIGNED_INT_8_8_8_8)) {
+ /* simple memcpy path (big endian) */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ dstFormat == &_mesa_texformat_argb8888 &&
+ srcFormat == GL_RGB &&
+ srcType == GL_UNSIGNED_BYTE) {
+
+ int img, row, col;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ for (img = 0; img < srcDepth; img++) {
+ const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
+ srcWidth, srcFormat, srcType);
+ GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
+ srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col * 4 + 0] = srcRow[col * 3 + BCOMP];
+ dstRow[col * 4 + 1] = srcRow[col * 3 + GCOMP];
+ dstRow[col * 4 + 2] = srcRow[col * 3 + RCOMP];
+ dstRow[col * 4 + 3] = 0xff;
+ }
+ dstRow += dstRowStride;
+ srcRow += srcRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ }
+ else if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ dstFormat == &_mesa_texformat_argb8888 &&
+ srcFormat == GL_RGBA &&
+ srcType == GL_UNSIGNED_BYTE) {
+
+ int img, row, col;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ for (img = 0; img < srcDepth; img++) {
+ const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
+ srcWidth, srcFormat, srcType);
+ GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
+ srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col * 4 + 0] = srcRow[col * 4 + BCOMP];
+ dstRow[col * 4 + 1] = srcRow[col * 4 + GCOMP];
+ dstRow[col * 4 + 2] = srcRow[col * 4 + RCOMP];
+ dstRow[col * 4 + 3] = srcRow[col * 4 + ACOMP];
+ }
+ dstRow += dstRowStride;
+ srcRow += srcRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ }
+ else if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ dstFormat == &_mesa_texformat_argb8888 &&
+ srcType == GL_UNSIGNED_BYTE &&
+ littleEndian &&
+ /* Three texture formats involved: srcFormat,
+ * baseInternalFormat and destFormat (GL_RGBA). Only two
+ * may differ. _mesa_swizzle_ubyte_image can't handle two
+ * propagations at once correctly. */
+ (srcFormat == baseInternalFormat ||
+ baseInternalFormat == GL_RGBA) &&
+ can_swizzle(srcFormat)) {
+
+ GLubyte dstmap[4];
+
+ /* dstmap - how to swizzle from GL_RGBA to dst format:
+ */
+ dstmap[3] = 3; /* alpha */
+ dstmap[2] = 0; /* red */
+ dstmap[1] = 1; /* green */
+ dstmap[0] = 2; /* blue */
+
+ _mesa_swizzle_ubyte_image(ctx, dims,
+ srcFormat,
+ dstmap, 4,
+ dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcAddr,
+ srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLuint *dstUI = (GLuint *) dstRow;
+ if (dstFormat == &_mesa_texformat_argb8888) {
+ for (col = 0; col < srcWidth; col++) {
+ dstUI[col] = PACK_COLOR_8888( CHAN_TO_UBYTE(src[ACOMP]),
+ CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]) );
+ src += 4;
+ }
+ }
+ else {
+ for (col = 0; col < srcWidth; col++) {
+ dstUI[col] = PACK_COLOR_8888_REV( CHAN_TO_UBYTE(src[ACOMP]),
+ CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]) );
+ src += 4;
+ }
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
+_mesa_texstore_rgb888(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ ASSERT(dstFormat == &_mesa_texformat_rgb888);
+ ASSERT(dstFormat->TexelBytes == 3);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGB &&
+ srcFormat == GL_BGR &&
+ srcType == GL_UNSIGNED_BYTE &&
+ littleEndian) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ srcFormat == GL_RGBA &&
+ srcType == GL_UNSIGNED_BYTE) {
+ /* extract RGB from RGBA */
+ int img, row, col;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ for (img = 0; img < srcDepth; img++) {
+ const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
+ srcWidth, srcFormat, srcType);
+ GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
+ srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col * 3 + 0] = srcRow[col * 4 + BCOMP];
+ dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP];
+ dstRow[col * 3 + 2] = srcRow[col * 4 + RCOMP];
+ }
+ dstRow += dstRowStride;
+ srcRow += srcRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = (const GLchan *) tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+#if 0
+ if (littleEndian) {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]);
+ dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]);
+ dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]);
+ srcUB += 3;
+ }
+ }
+ else {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col * 3 + 0] = srcUB[BCOMP];
+ dstRow[col * 3 + 1] = srcUB[GCOMP];
+ dstRow[col * 3 + 2] = srcUB[RCOMP];
+ srcUB += 3;
+ }
+ }
+#else
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[BCOMP]);
+ dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]);
+ dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[RCOMP]);
+ src += 3;
+ }
+#endif
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
+_mesa_texstore_bgr888(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ ASSERT(dstFormat == &_mesa_texformat_bgr888);
+ ASSERT(dstFormat->TexelBytes == 3);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGB &&
+ srcFormat == GL_RGB &&
+ srcType == GL_UNSIGNED_BYTE &&
+ littleEndian) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ srcFormat == GL_RGBA &&
+ srcType == GL_UNSIGNED_BYTE) {
+ /* extract BGR from RGBA */
+ int img, row, col;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ for (img = 0; img < srcDepth; img++) {
+ const GLint srcRowStride = _mesa_image_row_stride(srcPacking,
+ srcWidth, srcFormat, srcType);
+ GLubyte *srcRow = (GLubyte *) _mesa_image_address(dims, srcPacking,
+ srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, 0, 0);
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col * 3 + 0] = srcRow[col * 4 + RCOMP];
+ dstRow[col * 3 + 1] = srcRow[col * 4 + GCOMP];
+ dstRow[col * 3 + 2] = srcRow[col * 4 + BCOMP];
+ }
+ dstRow += dstRowStride;
+ srcRow += srcRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = (const GLchan *) tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col * 3 + 0] = CHAN_TO_UBYTE(src[RCOMP]);
+ dstRow[col * 3 + 1] = CHAN_TO_UBYTE(src[GCOMP]);
+ dstRow[col * 3 + 2] = CHAN_TO_UBYTE(src[BCOMP]);
+ src += 3;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
+_mesa_texstore_argb4444(STORE_PARAMS)
+{
+ ASSERT(dstFormat == &_mesa_texformat_argb4444 ||
+ dstFormat == &_mesa_texformat_argb4444_rev);
+ ASSERT(dstFormat->TexelBytes == 2);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ dstFormat == &_mesa_texformat_argb4444 &&
+ baseInternalFormat == GL_RGBA &&
+ srcFormat == GL_BGRA &&
+ srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLushort *dstUS = (GLushort *) dstRow;
+ if (dstFormat == &_mesa_texformat_argb4444) {
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_4444( CHAN_TO_UBYTE(src[ACOMP]),
+ CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]) );
+ src += 4;
+ }
+ }
+ else {
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_4444_REV( CHAN_TO_UBYTE(src[ACOMP]),
+ CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]) );
+ src += 4;
+ }
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+
+GLboolean
+_mesa_texstore_argb1555(STORE_PARAMS)
+{
+ ASSERT(dstFormat == &_mesa_texformat_argb1555 ||
+ dstFormat == &_mesa_texformat_argb1555_rev);
+ ASSERT(dstFormat->TexelBytes == 2);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ dstFormat == &_mesa_texformat_argb1555 &&
+ baseInternalFormat == GL_RGBA &&
+ srcFormat == GL_BGRA &&
+ srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src =tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLushort *dstUS = (GLushort *) dstRow;
+ if (dstFormat == &_mesa_texformat_argb1555) {
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_1555( CHAN_TO_UBYTE(src[ACOMP]),
+ CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]) );
+ src += 4;
+ }
+ }
+ else {
+ for (col = 0; col < srcWidth; col++) {
+ dstUS[col] = PACK_COLOR_1555_REV( CHAN_TO_UBYTE(src[ACOMP]),
+ CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]) );
+ src += 4;
+ }
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
+_mesa_texstore_al88(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+
+ ASSERT(dstFormat == &_mesa_texformat_al88 ||
+ dstFormat == &_mesa_texformat_al88_rev);
+ ASSERT(dstFormat->TexelBytes == 2);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ dstFormat == &_mesa_texformat_al88 &&
+ baseInternalFormat == GL_LUMINANCE_ALPHA &&
+ srcFormat == GL_LUMINANCE_ALPHA &&
+ srcType == GL_UNSIGNED_BYTE &&
+ littleEndian) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLushort *dstUS = (GLushort *) dstRow;
+ if (dstFormat == &_mesa_texformat_al88) {
+ for (col = 0; col < srcWidth; col++) {
+ /* src[0] is luminance, src[1] is alpha */
+ dstUS[col] = PACK_COLOR_88( CHAN_TO_UBYTE(src[1]),
+ CHAN_TO_UBYTE(src[0]) );
+ src += 2;
+ }
+ }
+ else {
+ for (col = 0; col < srcWidth; col++) {
+ /* src[0] is luminance, src[1] is alpha */
+ dstUS[col] = PACK_COLOR_88_REV( CHAN_TO_UBYTE(src[1]),
+ CHAN_TO_UBYTE(src[0]) );
+ src += 2;
+ }
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+GLboolean
+_mesa_texstore_rgb332(STORE_PARAMS)
+{
+ ASSERT(dstFormat == &_mesa_texformat_rgb332);
+ ASSERT(dstFormat->TexelBytes == 1);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == GL_RGB &&
+ srcFormat == GL_RGB && srcType == GL_UNSIGNED_BYTE_3_3_2) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col] = PACK_COLOR_332( CHAN_TO_UBYTE(src[RCOMP]),
+ CHAN_TO_UBYTE(src[GCOMP]),
+ CHAN_TO_UBYTE(src[BCOMP]) );
+ src += 3;
+ }
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+/**
+ * Texstore for _mesa_texformat_a8, _mesa_texformat_l8, _mesa_texformat_i8.
+ */
+GLboolean
+_mesa_texstore_a8(STORE_PARAMS)
+{
+ ASSERT(dstFormat == &_mesa_texformat_a8 ||
+ dstFormat == &_mesa_texformat_l8 ||
+ dstFormat == &_mesa_texformat_i8);
+ ASSERT(dstFormat->TexelBytes == 1);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == srcFormat &&
+ srcType == GL_UNSIGNED_BYTE) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLchan *tempImage = _mesa_make_temp_chan_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLchan *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row, col;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ for (col = 0; col < srcWidth; col++) {
+ dstRow[col] = CHAN_TO_UBYTE(src[col]);
+ }
+ dstRow += dstRowStride;
+ src += srcWidth;
+ }
+ dstImage += dstImageStride;
+ }
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+
+GLboolean
+_mesa_texstore_ci8(STORE_PARAMS)
+{
+ (void) dims; (void) baseInternalFormat;
+ ASSERT(dstFormat == &_mesa_texformat_ci8);
+ ASSERT(dstFormat->TexelBytes == 1);
+ ASSERT(baseInternalFormat == GL_COLOR_INDEX);
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ srcFormat == GL_COLOR_INDEX &&
+ srcType == GL_UNSIGNED_BYTE) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row;
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ const GLvoid *src = _mesa_image_address(dims, srcPacking,
+ srcAddr, srcWidth, srcHeight, srcFormat, srcType, img, row, 0);
+ _mesa_unpack_index_span(ctx, srcWidth, GL_UNSIGNED_BYTE, dstRow,
+ srcType, src, srcPacking,
+ ctx->_ImageTransferState);
+ dstRow += dstRowStride;
+ }
+ dstImage += dstImageStride;
+ }
+ }
+ return GL_TRUE;
+}
+
+
+/**
+ * Texstore for _mesa_texformat_ycbcr or _mesa_texformat_ycbcr_rev.
+ */
+GLboolean
+_mesa_texstore_ycbcr(STORE_PARAMS)
+{
+ const GLuint ui = 1;
+ const GLubyte littleEndian = *((const GLubyte *) &ui);
+ (void) ctx; (void) dims; (void) baseInternalFormat;
+
+ ASSERT((dstFormat == &_mesa_texformat_ycbcr) ||
+ (dstFormat == &_mesa_texformat_ycbcr_rev));
+ ASSERT(dstFormat->TexelBytes == 2);
+ ASSERT(ctx->Extensions.MESA_ycbcr_texture);
+ ASSERT(srcFormat == GL_YCBCR_MESA);
+ ASSERT((srcType == GL_UNSIGNED_SHORT_8_8_MESA) ||
+ (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA));
+ ASSERT(baseInternalFormat == GL_YCBCR_MESA);
+
+ /* always just memcpy since no pixel transfer ops apply */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+
+ /* Check if we need byte swapping */
+ /* XXX the logic here _might_ be wrong */
+ if (srcPacking->SwapBytes ^
+ (srcType == GL_UNSIGNED_SHORT_8_8_REV_MESA) ^
+ (dstFormat == &_mesa_texformat_ycbcr_rev) ^
+ !littleEndian) {
+ GLubyte *pImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row;
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *pRow = pImage;
+ for (row = 0; row < srcHeight; row++) {
+ _mesa_swap2((GLushort *) pRow, srcWidth);
+ pRow += dstRowStride;
+ }
+ pImage += dstImageStride;
+ }
+ }
+ return GL_TRUE;
+}
+
+
+
+
+/**
+ * Store an image in any of the formats:
+ * _mesa_texformat_rgba_float32
+ * _mesa_texformat_rgb_float32
+ * _mesa_texformat_alpha_float32
+ * _mesa_texformat_luminance_float32
+ * _mesa_texformat_luminance_alpha_float32
+ * _mesa_texformat_intensity_float32
+ */
+GLboolean
+_mesa_texstore_rgba_float32(STORE_PARAMS)
+{
+ const GLint components = _mesa_components_in_format(baseInternalFormat);
+
+ ASSERT(dstFormat == &_mesa_texformat_rgba_float32 ||
+ dstFormat == &_mesa_texformat_rgb_float32 ||
+ dstFormat == &_mesa_texformat_alpha_float32 ||
+ dstFormat == &_mesa_texformat_luminance_float32 ||
+ dstFormat == &_mesa_texformat_luminance_alpha_float32 ||
+ dstFormat == &_mesa_texformat_intensity_float32);
+ ASSERT(baseInternalFormat == GL_RGBA ||
+ baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_ALPHA ||
+ baseInternalFormat == GL_LUMINANCE ||
+ baseInternalFormat == GL_LUMINANCE_ALPHA ||
+ baseInternalFormat == GL_INTENSITY);
+ ASSERT(dstFormat->TexelBytes == components * sizeof(GLfloat));
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == srcFormat &&
+ srcType == GL_FLOAT) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLfloat *tempImage = make_temp_float_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLfloat *src = tempImage;
+ GLint bytesPerRow;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ bytesPerRow = srcWidth * components * sizeof(GLfloat);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dst = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ _mesa_memcpy(dst, src, bytesPerRow);
+ dst += dstRowStride;
+ src += srcWidth * components;
+ }
+ dstImage += dstImageStride;
+ }
+
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+/**
+ * As above, but store 16-bit floats.
+ */
+GLboolean
+_mesa_texstore_rgba_float16(STORE_PARAMS)
+{
+ const GLint components = _mesa_components_in_format(baseInternalFormat);
+
+ ASSERT(dstFormat == &_mesa_texformat_rgba_float16 ||
+ dstFormat == &_mesa_texformat_rgb_float16 ||
+ dstFormat == &_mesa_texformat_alpha_float16 ||
+ dstFormat == &_mesa_texformat_luminance_float16 ||
+ dstFormat == &_mesa_texformat_luminance_alpha_float16 ||
+ dstFormat == &_mesa_texformat_intensity_float16);
+ ASSERT(baseInternalFormat == GL_RGBA ||
+ baseInternalFormat == GL_RGB ||
+ baseInternalFormat == GL_ALPHA ||
+ baseInternalFormat == GL_LUMINANCE ||
+ baseInternalFormat == GL_LUMINANCE_ALPHA ||
+ baseInternalFormat == GL_INTENSITY);
+ ASSERT(dstFormat->TexelBytes == components * sizeof(GLhalfARB));
+
+ if (!ctx->_ImageTransferState &&
+ !srcPacking->SwapBytes &&
+ baseInternalFormat == srcFormat &&
+ srcType == GL_HALF_FLOAT_ARB) {
+ /* simple memcpy path */
+ memcpy_texture(ctx, dims,
+ dstFormat, dstAddr, dstXoffset, dstYoffset, dstZoffset,
+ dstRowStride, dstImageStride,
+ srcWidth, srcHeight, srcDepth, srcFormat, srcType,
+ srcAddr, srcPacking);
+ }
+ else {
+ /* general path */
+ const GLfloat *tempImage = make_temp_float_image(ctx, dims,
+ baseInternalFormat,
+ dstFormat->BaseFormat,
+ srcWidth, srcHeight, srcDepth,
+ srcFormat, srcType, srcAddr,
+ srcPacking);
+ const GLfloat *src = tempImage;
+ GLubyte *dstImage = (GLubyte *) dstAddr
+ + dstZoffset * dstImageStride
+ + dstYoffset * dstRowStride
+ + dstXoffset * dstFormat->TexelBytes;
+ GLint img, row;
+ if (!tempImage)
+ return GL_FALSE;
+ _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
+ for (img = 0; img < srcDepth; img++) {
+ GLubyte *dstRow = dstImage;
+ for (row = 0; row < srcHeight; row++) {
+ GLhalfARB *dstTexel = (GLhalfARB *) dstRow;
+ GLint i;
+ for (i = 0; i < srcWidth * components; i++) {
+ dstTexel[i] = _mesa_float_to_half(src[i]);
+ }
+ dstRow += dstRowStride;
+ src += srcWidth * components;
+ }
+ dstImage += dstImageStride;
+ }
+
+ _mesa_free((void *) tempImage);
+ }
+ return GL_TRUE;
+}
+
+
+
+/**
+ * Check if an unpack PBO is active prior to fetching a texture image.
+ * If so, do bounds checking and map the buffer into main memory.
+ * Any errors detected will be recorded.
+ * The caller _must_ call _mesa_unmap_teximage_pbo() too!
+ */
+const GLvoid *
+_mesa_validate_pbo_teximage(GLcontext *ctx, GLuint dimensions,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *unpack,
+ const char *funcName)
+{
+ GLubyte *buf;
+
+ if (unpack->BufferObj->Name == 0) {
+ /* no PBO */
+ return pixels;
+ }
+ if (!_mesa_validate_pbo_access(dimensions, unpack, width, height, depth,
+ format, type, pixels)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access");
+ return NULL;
+ }
+
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ GL_READ_ONLY_ARB, unpack->BufferObj);
+ if (!buf) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped");
+ return NULL;
+ }
+
+ return ADD_POINTERS(buf, pixels);
+}
+
+
+/**
+ * Check if an unpack PBO is active prior to fetching a compressed texture
+ * image.
+ * If so, do bounds checking and map the buffer into main memory.
+ * Any errors detected will be recorded.
+ * The caller _must_ call _mesa_unmap_teximage_pbo() too!
+ */
+const GLvoid *
+_mesa_validate_pbo_compressed_teximage(GLcontext *ctx,
+ GLsizei imageSize, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ const char *funcName)
+{
+ GLubyte *buf;
+
+ if (packing->BufferObj->Name == 0) {
+ /* not using a PBO - return pointer unchanged */
+ return pixels;
+ }
+ if ((const GLubyte *) pixels + imageSize >
+ (const GLubyte *)(uintptr_t) packing->BufferObj->Size) {
+ /* out of bounds read! */
+ _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(invalid PBO access");
+ return NULL;
+ }
+
+ buf = (GLubyte*) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ GL_READ_ONLY_ARB, packing->BufferObj);
+ if (!buf) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, funcName, "(PBO is mapped");
+ return NULL;
+ }
+
+ return ADD_POINTERS(buf, pixels);
+}
+
+
+/**
+ * This function must be called after either of the validate_pbo_*_teximage()
+ * functions. It unmaps the PBO buffer if it was mapped earlier.
+ */
+void
+_mesa_unmap_teximage_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *unpack)
+{
+ if (unpack->BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ unpack->BufferObj);
+ }
+}
+
+
+/*
+ * This is the software fallback for Driver.TexImage1D()
+ * and Driver.CopyTexImage1D().
+ * \sa _mesa_store_teximage2d()
+ */
+void
+_mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ GLint postConvWidth = width;
+ GLint sizeInBytes;
+ (void) border;
+
+ if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) {
+ _mesa_adjust_image_for_convolution(ctx, 1, &postConvWidth, NULL);
+ }
+
+ /* choose the texture format */
+ assert(ctx->Driver.ChooseTextureFormat);
+ texImage->TexFormat = ctx->Driver.ChooseTextureFormat(ctx, internalFormat,
+ format, type);
+ assert(texImage->TexFormat);
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel1D;
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel1Df;
+
+ /* allocate memory */
+ if (texImage->IsCompressed)
+ sizeInBytes = texImage->CompressedSize;
+ else
+ sizeInBytes = postConvWidth * texImage->TexFormat->TexelBytes;
+ texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
+ if (!texImage->Data) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
+ return;
+ }
+
+ pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type,
+ pixels, packing, "glTexImage1D");
+ if (!pixels) {
+ /* Note: we check for a NULL image pointer here, _after_ we allocated
+ * memory for the texture. That's what the GL spec calls for.
+ */
+ return;
+ }
+ else {
+ const GLint dstRowStride = 0, dstImageStride = 0;
+ GLboolean success;
+ ASSERT(texImage->TexFormat->StoreImage);
+ success = texImage->TexFormat->StoreImage(ctx, 1, texImage->Format,
+ texImage->TexFormat,
+ texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride, dstImageStride,
+ width, 1, 1,
+ format, type, pixels, packing);
+ if (!success) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
+ }
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target,
+ &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
+ texObj);
+ }
+
+ _mesa_unmap_teximage_pbo(ctx, packing);
+}
+
+
+/**
+ * This is the software fallback for Driver.TexImage2D()
+ * and Driver.CopyTexImage2D().
+ * We store the image in heap memory. We know nothing about on-board
+ * VRAM here. But since most DRI drivers rely on keeping a copy of all
+ * textures in main memory, this routine will typically be used by
+ * hardware drivers too.
+ *
+ * Reasons why a driver might override this function:
+ * - Special memory allocation needs (VRAM, AGP, etc)
+ * - Unusual row/image strides or padding
+ * - Special housekeeping
+ * - Using VRAM-based Pixel Buffer Objects
+ */
+void
+_mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ GLint postConvWidth = width, postConvHeight = height;
+ GLint texelBytes, sizeInBytes;
+ (void) border;
+
+ if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) {
+ _mesa_adjust_image_for_convolution(ctx, 2, &postConvWidth,
+ &postConvHeight);
+ }
+
+ /* choose the texture format */
+ assert(ctx->Driver.ChooseTextureFormat);
+ texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
+ internalFormat, format, type);
+ assert(texImage->TexFormat);
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel2D;
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df;
+
+ texelBytes = texImage->TexFormat->TexelBytes;
+
+ /* allocate memory */
+ if (texImage->IsCompressed)
+ sizeInBytes = texImage->CompressedSize;
+ else
+ sizeInBytes = postConvWidth * postConvHeight * texelBytes;
+ texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
+ if (!texImage->Data) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ return;
+ }
+
+ pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type,
+ pixels, packing, "glTexImage2D");
+ if (!pixels) {
+ /* Note: we check for a NULL image pointer here, _after_ we allocated
+ * memory for the texture. That's what the GL spec calls for.
+ */
+ return;
+ }
+ else {
+ GLint dstRowStride, dstImageStride = 0;
+ GLboolean success;
+ if (texImage->IsCompressed) {
+ dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,width);
+ }
+ else {
+ dstRowStride = postConvWidth * texImage->TexFormat->TexelBytes;
+ }
+ ASSERT(texImage->TexFormat->StoreImage);
+ success = texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat,
+ texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride, dstImageStride,
+ width, height, 1,
+ format, type, pixels, packing);
+ if (!success) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
+ }
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target,
+ &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
+ texObj);
+ }
+
+ _mesa_unmap_teximage_pbo(ctx, packing);
+}
+
+
+
+/**
+ * This is the software fallback for Driver.TexImage3D()
+ * and Driver.CopyTexImage3D().
+ * \sa _mesa_store_teximage2d()
+ */
+void
+_mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint depth, GLint border,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ GLint texelBytes, sizeInBytes;
+ (void) border;
+
+ /* choose the texture format */
+ assert(ctx->Driver.ChooseTextureFormat);
+ texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
+ internalFormat, format, type);
+ assert(texImage->TexFormat);
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel3D;
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel3Df;
+
+ texelBytes = texImage->TexFormat->TexelBytes;
+
+ /* allocate memory */
+ if (texImage->IsCompressed)
+ sizeInBytes = texImage->CompressedSize;
+ else
+ sizeInBytes = width * height * depth * texelBytes;
+ texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
+ if (!texImage->Data) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
+ return;
+ }
+
+ pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format,
+ type, pixels, packing, "glTexImage3D");
+ if (!pixels) {
+ /* Note: we check for a NULL image pointer here, _after_ we allocated
+ * memory for the texture. That's what the GL spec calls for.
+ */
+ return;
+ }
+ else {
+ GLint dstRowStride, dstImageStride;
+ GLboolean success;
+ if (texImage->IsCompressed) {
+ dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,width);
+ dstImageStride = 0;
+ }
+ else {
+ dstRowStride = width * texImage->TexFormat->TexelBytes;
+ dstImageStride = dstRowStride * height;
+ }
+ ASSERT(texImage->TexFormat->StoreImage);
+ success = texImage->TexFormat->StoreImage(ctx, 3, texImage->Format,
+ texImage->TexFormat,
+ texImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride, dstImageStride,
+ width, height, depth,
+ format, type, pixels, packing);
+ if (!success) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
+ }
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target,
+ &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
+ texObj);
+ }
+
+ _mesa_unmap_teximage_pbo(ctx, packing);
+}
+
+
+
+
+/*
+ * This is the software fallback for Driver.TexSubImage1D()
+ * and Driver.CopyTexSubImage1D().
+ */
+void
+_mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint width,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ pixels = _mesa_validate_pbo_teximage(ctx, 1, width, 1, 1, format, type,
+ pixels, packing, "glTexSubImage1D");
+ if (!pixels)
+ return;
+
+ {
+ const GLint dstRowStride = 0, dstImageStride = 0;
+ GLboolean success;
+ ASSERT(texImage->TexFormat->StoreImage);
+ success = texImage->TexFormat->StoreImage(ctx, 1, texImage->Format,
+ texImage->TexFormat,
+ texImage->Data,
+ xoffset, 0, 0, /* offsets */
+ dstRowStride, dstImageStride,
+ width, 1, 1,
+ format, type, pixels, packing);
+ if (!success) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
+ }
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target,
+ &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
+ texObj);
+ }
+
+ _mesa_unmap_teximage_pbo(ctx, packing);
+}
+
+
+
+/**
+ * This is the software fallback for Driver.TexSubImage2D()
+ * and Driver.CopyTexSubImage2D().
+ */
+void
+_mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint width, GLint height,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ pixels = _mesa_validate_pbo_teximage(ctx, 2, width, height, 1, format, type,
+ pixels, packing, "glTexSubImage2D");
+ if (!pixels)
+ return;
+
+ {
+ GLint dstRowStride = 0, dstImageStride = 0;
+ GLboolean success;
+ if (texImage->IsCompressed) {
+ dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
+ texImage->Width);
+ }
+ else {
+ dstRowStride = texImage->Width * texImage->TexFormat->TexelBytes;
+ }
+ ASSERT(texImage->TexFormat->StoreImage);
+ success = texImage->TexFormat->StoreImage(ctx, 2, texImage->Format,
+ texImage->TexFormat,
+ texImage->Data,
+ xoffset, yoffset, 0,
+ dstRowStride, dstImageStride,
+ width, height, 1,
+ format, type, pixels, packing);
+ if (!success) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
+ }
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target,
+ &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
+ texObj);
+ }
+
+ _mesa_unmap_teximage_pbo(ctx, packing);
+}
+
+
+/*
+ * This is the software fallback for Driver.TexSubImage3D().
+ * and Driver.CopyTexSubImage3D().
+ */
+void
+_mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLint width, GLint height, GLint depth,
+ GLenum format, GLenum type, const void *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ pixels = _mesa_validate_pbo_teximage(ctx, 3, width, height, depth, format,
+ type, pixels, packing,
+ "glTexSubImage3D");
+ if (!pixels)
+ return;
+
+ {
+ GLint dstRowStride, dstImageStride;
+ GLboolean success;
+ if (texImage->IsCompressed) {
+ dstRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
+ texImage->Width);
+ dstImageStride = 0; /* XXX fix */
+ }
+ else {
+ dstRowStride = texImage->Width * texImage->TexFormat->TexelBytes;
+ dstImageStride = dstRowStride * texImage->Height;
+ }
+ ASSERT(texImage->TexFormat->StoreImage);
+ success = texImage->TexFormat->StoreImage(ctx, 3, texImage->Format,
+ texImage->TexFormat,
+ texImage->Data,
+ xoffset, yoffset, zoffset,
+ dstRowStride, dstImageStride,
+ width, height, depth,
+ format, type, pixels, packing);
+ if (!success) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D");
+ }
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target,
+ &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
+ texObj);
+ }
+
+ _mesa_unmap_teximage_pbo(ctx, packing);
+}
+
+
+/*
+ * Fallback for Driver.CompressedTexImage1D()
+ */
+void
+_mesa_store_compressed_teximage1d(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ /* this space intentionally left blank */
+ (void) ctx;
+ (void) target; (void) level;
+ (void) internalFormat;
+ (void) width; (void) border;
+ (void) imageSize; (void) data;
+ (void) texObj;
+ (void) texImage;
+}
+
+
+
+/*
+ * Fallback for Driver.CompressedTexImage2D()
+ */
+void
+_mesa_store_compressed_teximage2d(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ (void) width; (void) height; (void) border;
+
+ /* This is pretty simple, basically just do a memcpy without worrying
+ * about the usual image unpacking or image transfer operations.
+ */
+ ASSERT(texObj);
+ ASSERT(texImage);
+ ASSERT(texImage->Width > 0);
+ ASSERT(texImage->Height > 0);
+ ASSERT(texImage->Depth == 1);
+ ASSERT(texImage->Data == NULL); /* was freed in glCompressedTexImage2DARB */
+
+ /* choose the texture format */
+ assert(ctx->Driver.ChooseTextureFormat);
+ texImage->TexFormat = (*ctx->Driver.ChooseTextureFormat)(ctx,
+ internalFormat, 0, 0);
+ assert(texImage->TexFormat);
+ texImage->FetchTexelc = texImage->TexFormat->FetchTexel2D;
+ texImage->FetchTexelf = texImage->TexFormat->FetchTexel2Df;
+
+ /* allocate storage */
+ texImage->Data = _mesa_alloc_texmemory(imageSize);
+ if (!texImage->Data) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB");
+ return;
+ }
+
+ data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data,
+ &ctx->Unpack,
+ "glCompressedTexImage2D");
+ if (!data)
+ return;
+
+ /* copy the data */
+ ASSERT(texImage->CompressedSize == (GLuint) imageSize);
+ MEMCPY(texImage->Data, data, imageSize);
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target,
+ &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
+ texObj);
+ }
+
+ _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack);
+}
+
+
+
+/*
+ * Fallback for Driver.CompressedTexImage3D()
+ */
+void
+_mesa_store_compressed_teximage3d(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint depth,
+ GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ /* this space intentionally left blank */
+ (void) ctx;
+ (void) target; (void) level;
+ (void) internalFormat;
+ (void) width; (void) height; (void) depth;
+ (void) border;
+ (void) imageSize; (void) data;
+ (void) texObj;
+ (void) texImage;
+}
+
+
+
+/**
+ * Fallback for Driver.CompressedTexSubImage1D()
+ */
+void
+_mesa_store_compressed_texsubimage1d(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)
+{
+ /* this space intentionally left blank */
+ (void) ctx;
+ (void) target; (void) level;
+ (void) xoffset; (void) width;
+ (void) format;
+ (void) imageSize; (void) data;
+ (void) texObj;
+ (void) texImage;
+}
+
+
+/**
+ * Fallback for Driver.CompressedTexSubImage2D()
+ */
+void
+_mesa_store_compressed_texsubimage2d(GLcontext *ctx, GLenum target,
+ GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ GLint bytesPerRow, destRowStride, srcRowStride;
+ GLint i, rows;
+ GLubyte *dest;
+ const GLubyte *src;
+ (void) format;
+
+ /* these should have been caught sooner */
+ ASSERT((width & 3) == 0 || width == 2 || width == 1);
+ ASSERT((height & 3) == 0 || height == 2 || height == 1);
+ ASSERT((xoffset & 3) == 0);
+ ASSERT((yoffset & 3) == 0);
+
+ data = _mesa_validate_pbo_compressed_teximage(ctx, imageSize, data,
+ &ctx->Unpack,
+ "glCompressedTexSubImage2D");
+ if (!data)
+ return;
+
+ srcRowStride = _mesa_compressed_row_stride(texImage->IntFormat, width);
+ src = (const GLubyte *) data;
+
+ destRowStride = _mesa_compressed_row_stride(texImage->IntFormat,
+ texImage->Width);
+ dest = _mesa_compressed_image_address(xoffset, yoffset, 0,
+ texImage->IntFormat,
+ texImage->Width,
+ (GLubyte*) texImage->Data);
+
+ bytesPerRow = srcRowStride;
+ rows = height / 4;
+
+ for (i = 0; i < rows; i++) {
+ MEMCPY(dest, src, bytesPerRow);
+ dest += destRowStride;
+ src += srcRowStride;
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target,
+ &ctx->Texture.Unit[ctx->Texture.CurrentUnit],
+ texObj);
+ }
+
+ _mesa_unmap_teximage_pbo(ctx, &ctx->Unpack);
+}
+
+
+/**
+ * Fallback for Driver.CompressedTexSubImage3D()
+ */
+void
+_mesa_store_compressed_texsubimage3d(GLcontext *ctx, GLenum target,
+ GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
+{
+ /* this space intentionally left blank */
+ (void) ctx;
+ (void) target; (void) level;
+ (void) xoffset; (void) yoffset; (void) zoffset;
+ (void) width; (void) height; (void) depth;
+ (void) format;
+ (void) imageSize; (void) data;
+ (void) texObj;
+ (void) texImage;
+}
+
+
+/*
+ * Average together two rows of a source image to produce a single new
+ * row in the dest image. It's legal for the two source rows to point
+ * to the same data. The source width must be equal to either the
+ * dest width or two times the dest width.
+ */
+static void
+do_row(const struct gl_texture_format *format, GLint srcWidth,
+ const GLvoid *srcRowA, const GLvoid *srcRowB,
+ GLint dstWidth, GLvoid *dstRow)
+{
+ const GLuint k0 = (srcWidth == dstWidth) ? 0 : 1;
+ const GLuint colStride = (srcWidth == dstWidth) ? 1 : 2;
+
+ /* This assertion is no longer valid with non-power-of-2 textures
+ assert(srcWidth == dstWidth || srcWidth == 2 * dstWidth);
+ */
+
+ switch (format->MesaFormat) {
+ case MESA_FORMAT_RGBA:
+ {
+ GLuint i, j, k;
+ const GLchan (*rowA)[4] = (const GLchan (*)[4]) srcRowA;
+ const GLchan (*rowB)[4] = (const GLchan (*)[4]) srcRowB;
+ GLchan (*dst)[4] = (GLchan (*)[4]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i][0] = (rowA[j][0] + rowA[k][0] +
+ rowB[j][0] + rowB[k][0]) / 4;
+ dst[i][1] = (rowA[j][1] + rowA[k][1] +
+ rowB[j][1] + rowB[k][1]) / 4;
+ dst[i][2] = (rowA[j][2] + rowA[k][2] +
+ rowB[j][2] + rowB[k][2]) / 4;
+ dst[i][3] = (rowA[j][3] + rowA[k][3] +
+ rowB[j][3] + rowB[k][3]) / 4;
+ }
+ }
+ return;
+ case MESA_FORMAT_RGB:
+ {
+ GLuint i, j, k;
+ const GLchan (*rowA)[3] = (const GLchan (*)[3]) srcRowA;
+ const GLchan (*rowB)[3] = (const GLchan (*)[3]) srcRowB;
+ GLchan (*dst)[3] = (GLchan (*)[3]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i][0] = (rowA[j][0] + rowA[k][0] +
+ rowB[j][0] + rowB[k][0]) / 4;
+ dst[i][1] = (rowA[j][1] + rowA[k][1] +
+ rowB[j][1] + rowB[k][1]) / 4;
+ dst[i][2] = (rowA[j][2] + rowA[k][2] +
+ rowB[j][2] + rowB[k][2]) / 4;
+ }
+ }
+ return;
+ case MESA_FORMAT_ALPHA:
+ case MESA_FORMAT_LUMINANCE:
+ case MESA_FORMAT_INTENSITY:
+ {
+ GLuint i, j, k;
+ const GLchan *rowA = (const GLchan *) srcRowA;
+ const GLchan *rowB = (const GLchan *) srcRowB;
+ GLchan *dst = (GLchan *) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) / 4;
+ }
+ }
+ return;
+ case MESA_FORMAT_LUMINANCE_ALPHA:
+ {
+ GLuint i, j, k;
+ const GLchan (*rowA)[2] = (const GLchan (*)[2]) srcRowA;
+ const GLchan (*rowB)[2] = (const GLchan (*)[2]) srcRowB;
+ GLchan (*dst)[2] = (GLchan (*)[2]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i][0] = (rowA[j][0] + rowA[k][0] +
+ rowB[j][0] + rowB[k][0]) / 4;
+ dst[i][1] = (rowA[j][1] + rowA[k][1] +
+ rowB[j][1] + rowB[k][1]) / 4;
+ }
+ }
+ return;
+ case MESA_FORMAT_DEPTH_COMPONENT_FLOAT32:
+ {
+ GLuint i, j, k;
+ const GLfloat *rowA = (const GLfloat *) srcRowA;
+ const GLfloat *rowB = (const GLfloat *) srcRowB;
+ GLfloat *dst = (GLfloat *) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) * 0.25F;
+ }
+ }
+ return;
+ case MESA_FORMAT_DEPTH_COMPONENT16:
+ {
+ GLuint i, j, k;
+ const GLushort *rowA = (const GLushort *) srcRowA;
+ const GLushort *rowB = (const GLushort *) srcRowB;
+ GLushort *dst = (GLushort *) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) / 4;
+ }
+ }
+ return;
+ /* Begin hardware formats */
+ case MESA_FORMAT_RGBA8888:
+ case MESA_FORMAT_RGBA8888_REV:
+ case MESA_FORMAT_ARGB8888:
+ case MESA_FORMAT_ARGB8888_REV:
+ {
+ GLuint i, j, k;
+ const GLubyte (*rowA)[4] = (const GLubyte (*)[4]) srcRowA;
+ const GLubyte (*rowB)[4] = (const GLubyte (*)[4]) srcRowB;
+ GLubyte (*dst)[4] = (GLubyte (*)[4]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i][0] = (rowA[j][0] + rowA[k][0] +
+ rowB[j][0] + rowB[k][0]) / 4;
+ dst[i][1] = (rowA[j][1] + rowA[k][1] +
+ rowB[j][1] + rowB[k][1]) / 4;
+ dst[i][2] = (rowA[j][2] + rowA[k][2] +
+ rowB[j][2] + rowB[k][2]) / 4;
+ dst[i][3] = (rowA[j][3] + rowA[k][3] +
+ rowB[j][3] + rowB[k][3]) / 4;
+ }
+ }
+ return;
+ case MESA_FORMAT_RGB888:
+ case MESA_FORMAT_BGR888:
+ {
+ GLuint i, j, k;
+ const GLubyte (*rowA)[3] = (const GLubyte (*)[3]) srcRowA;
+ const GLubyte (*rowB)[3] = (const GLubyte (*)[3]) srcRowB;
+ GLubyte (*dst)[3] = (GLubyte (*)[3]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i][0] = (rowA[j][0] + rowA[k][0] +
+ rowB[j][0] + rowB[k][0]) / 4;
+ dst[i][1] = (rowA[j][1] + rowA[k][1] +
+ rowB[j][1] + rowB[k][1]) / 4;
+ dst[i][2] = (rowA[j][2] + rowA[k][2] +
+ rowB[j][2] + rowB[k][2]) / 4;
+ }
+ }
+ return;
+ case MESA_FORMAT_RGB565:
+ case MESA_FORMAT_RGB565_REV:
+ {
+ GLuint i, j, k;
+ const GLushort *rowA = (const GLushort *) srcRowA;
+ const GLushort *rowB = (const GLushort *) srcRowB;
+ GLushort *dst = (GLushort *) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ const GLint rowAr0 = rowA[j] & 0x1f;
+ const GLint rowAr1 = rowA[k] & 0x1f;
+ const GLint rowBr0 = rowB[j] & 0x1f;
+ const GLint rowBr1 = rowB[k] & 0x1f;
+ const GLint rowAg0 = (rowA[j] >> 5) & 0x3f;
+ const GLint rowAg1 = (rowA[k] >> 5) & 0x3f;
+ const GLint rowBg0 = (rowB[j] >> 5) & 0x3f;
+ const GLint rowBg1 = (rowB[k] >> 5) & 0x3f;
+ const GLint rowAb0 = (rowA[j] >> 11) & 0x1f;
+ const GLint rowAb1 = (rowA[k] >> 11) & 0x1f;
+ const GLint rowBb0 = (rowB[j] >> 11) & 0x1f;
+ const GLint rowBb1 = (rowB[k] >> 11) & 0x1f;
+ const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2;
+ const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2;
+ const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2;
+ dst[i] = (blue << 11) | (green << 5) | red;
+ }
+ }
+ return;
+ case MESA_FORMAT_ARGB4444:
+ case MESA_FORMAT_ARGB4444_REV:
+ {
+ GLuint i, j, k;
+ const GLushort *rowA = (const GLushort *) srcRowA;
+ const GLushort *rowB = (const GLushort *) srcRowB;
+ GLushort *dst = (GLushort *) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ const GLint rowAr0 = rowA[j] & 0xf;
+ const GLint rowAr1 = rowA[k] & 0xf;
+ const GLint rowBr0 = rowB[j] & 0xf;
+ const GLint rowBr1 = rowB[k] & 0xf;
+ const GLint rowAg0 = (rowA[j] >> 4) & 0xf;
+ const GLint rowAg1 = (rowA[k] >> 4) & 0xf;
+ const GLint rowBg0 = (rowB[j] >> 4) & 0xf;
+ const GLint rowBg1 = (rowB[k] >> 4) & 0xf;
+ const GLint rowAb0 = (rowA[j] >> 8) & 0xf;
+ const GLint rowAb1 = (rowA[k] >> 8) & 0xf;
+ const GLint rowBb0 = (rowB[j] >> 8) & 0xf;
+ const GLint rowBb1 = (rowB[k] >> 8) & 0xf;
+ const GLint rowAa0 = (rowA[j] >> 12) & 0xf;
+ const GLint rowAa1 = (rowA[k] >> 12) & 0xf;
+ const GLint rowBa0 = (rowB[j] >> 12) & 0xf;
+ const GLint rowBa1 = (rowB[k] >> 12) & 0xf;
+ const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2;
+ const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2;
+ const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2;
+ const GLint alpha = (rowAa0 + rowAa1 + rowBa0 + rowBa1) >> 2;
+ dst[i] = (alpha << 12) | (blue << 8) | (green << 4) | red;
+ }
+ }
+ return;
+ case MESA_FORMAT_ARGB1555:
+ case MESA_FORMAT_ARGB1555_REV: /* XXX broken? */
+ {
+ GLuint i, j, k;
+ const GLushort *rowA = (const GLushort *) srcRowA;
+ const GLushort *rowB = (const GLushort *) srcRowB;
+ GLushort *dst = (GLushort *) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ const GLint rowAr0 = rowA[j] & 0x1f;
+ const GLint rowAr1 = rowA[k] & 0x1f;
+ const GLint rowBr0 = rowB[j] & 0x1f;
+ const GLint rowBr1 = rowB[k] & 0xf;
+ const GLint rowAg0 = (rowA[j] >> 5) & 0x1f;
+ const GLint rowAg1 = (rowA[k] >> 5) & 0x1f;
+ const GLint rowBg0 = (rowB[j] >> 5) & 0x1f;
+ const GLint rowBg1 = (rowB[k] >> 5) & 0x1f;
+ const GLint rowAb0 = (rowA[j] >> 10) & 0x1f;
+ const GLint rowAb1 = (rowA[k] >> 10) & 0x1f;
+ const GLint rowBb0 = (rowB[j] >> 10) & 0x1f;
+ const GLint rowBb1 = (rowB[k] >> 10) & 0x1f;
+ const GLint rowAa0 = (rowA[j] >> 15) & 0x1;
+ const GLint rowAa1 = (rowA[k] >> 15) & 0x1;
+ const GLint rowBa0 = (rowB[j] >> 15) & 0x1;
+ const GLint rowBa1 = (rowB[k] >> 15) & 0x1;
+ const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2;
+ const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2;
+ const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2;
+ const GLint alpha = (rowAa0 + rowAa1 + rowBa0 + rowBa1) >> 2;
+ dst[i] = (alpha << 15) | (blue << 10) | (green << 5) | red;
+ }
+ }
+ return;
+ case MESA_FORMAT_AL88:
+ case MESA_FORMAT_AL88_REV:
+ {
+ GLuint i, j, k;
+ const GLubyte (*rowA)[2] = (const GLubyte (*)[2]) srcRowA;
+ const GLubyte (*rowB)[2] = (const GLubyte (*)[2]) srcRowB;
+ GLubyte (*dst)[2] = (GLubyte (*)[2]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i][0] = (rowA[j][0] + rowA[k][0] +
+ rowB[j][0] + rowB[k][0]) >> 2;
+ dst[i][1] = (rowA[j][1] + rowA[k][1] +
+ rowB[j][1] + rowB[k][1]) >> 2;
+ }
+ }
+ return;
+ case MESA_FORMAT_RGB332:
+ {
+ GLuint i, j, k;
+ const GLubyte *rowA = (const GLubyte *) srcRowA;
+ const GLubyte *rowB = (const GLubyte *) srcRowB;
+ GLubyte *dst = (GLubyte *) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ const GLint rowAr0 = rowA[j] & 0x3;
+ const GLint rowAr1 = rowA[k] & 0x3;
+ const GLint rowBr0 = rowB[j] & 0x3;
+ const GLint rowBr1 = rowB[k] & 0x3;
+ const GLint rowAg0 = (rowA[j] >> 2) & 0x7;
+ const GLint rowAg1 = (rowA[k] >> 2) & 0x7;
+ const GLint rowBg0 = (rowB[j] >> 2) & 0x7;
+ const GLint rowBg1 = (rowB[k] >> 2) & 0x7;
+ const GLint rowAb0 = (rowA[j] >> 5) & 0x7;
+ const GLint rowAb1 = (rowA[k] >> 5) & 0x7;
+ const GLint rowBb0 = (rowB[j] >> 5) & 0x7;
+ const GLint rowBb1 = (rowB[k] >> 5) & 0x7;
+ const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2;
+ const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2;
+ const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2;
+ dst[i] = (blue << 5) | (green << 2) | red;
+ }
+ }
+ return;
+ case MESA_FORMAT_A8:
+ case MESA_FORMAT_L8:
+ case MESA_FORMAT_I8:
+ case MESA_FORMAT_CI8:
+ {
+ GLuint i, j, k;
+ const GLubyte *rowA = (const GLubyte *) srcRowA;
+ const GLubyte *rowB = (const GLubyte *) srcRowB;
+ GLubyte *dst = (GLubyte *) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) >> 2;
+ }
+ }
+ return;
+ case MESA_FORMAT_RGBA_FLOAT32:
+ {
+ GLuint i, j, k;
+ const GLfloat (*rowA)[4] = (const GLfloat (*)[4]) srcRowA;
+ const GLfloat (*rowB)[4] = (const GLfloat (*)[4]) srcRowB;
+ GLfloat (*dst)[4] = (GLfloat (*)[4]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i][0] = (rowA[j][0] + rowA[k][0] +
+ rowB[j][0] + rowB[k][0]) * 0.25F;
+ dst[i][1] = (rowA[j][1] + rowA[k][1] +
+ rowB[j][1] + rowB[k][1]) * 0.25F;
+ dst[i][2] = (rowA[j][2] + rowA[k][2] +
+ rowB[j][2] + rowB[k][2]) * 0.25F;
+ dst[i][3] = (rowA[j][3] + rowA[k][3] +
+ rowB[j][3] + rowB[k][3]) * 0.25F;
+ }
+ }
+ return;
+ case MESA_FORMAT_RGBA_FLOAT16:
+ {
+ GLuint i, j, k, comp;
+ const GLhalfARB (*rowA)[4] = (const GLhalfARB (*)[4]) srcRowA;
+ const GLhalfARB (*rowB)[4] = (const GLhalfARB (*)[4]) srcRowB;
+ GLhalfARB (*dst)[4] = (GLhalfARB (*)[4]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ for (comp = 0; comp < 4; comp++) {
+ GLfloat aj, ak, bj, bk;
+ aj = _mesa_half_to_float(rowA[j][comp]);
+ ak = _mesa_half_to_float(rowA[k][comp]);
+ bj = _mesa_half_to_float(rowB[j][comp]);
+ bk = _mesa_half_to_float(rowB[k][comp]);
+ dst[i][comp] = _mesa_float_to_half((aj + ak + bj + bk) * 0.25F);
+ }
+ }
+ }
+ return;
+ case MESA_FORMAT_RGB_FLOAT32:
+ {
+ GLuint i, j, k;
+ const GLfloat (*rowA)[3] = (const GLfloat (*)[3]) srcRowA;
+ const GLfloat (*rowB)[3] = (const GLfloat (*)[3]) srcRowB;
+ GLfloat (*dst)[3] = (GLfloat (*)[3]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i][0] = (rowA[j][0] + rowA[k][0] +
+ rowB[j][0] + rowB[k][0]) * 0.25F;
+ dst[i][1] = (rowA[j][1] + rowA[k][1] +
+ rowB[j][1] + rowB[k][1]) * 0.25F;
+ dst[i][2] = (rowA[j][2] + rowA[k][2] +
+ rowB[j][2] + rowB[k][2]) * 0.25F;
+ }
+ }
+ return;
+ case MESA_FORMAT_RGB_FLOAT16:
+ {
+ GLuint i, j, k, comp;
+ const GLhalfARB (*rowA)[3] = (const GLhalfARB (*)[3]) srcRowA;
+ const GLhalfARB (*rowB)[3] = (const GLhalfARB (*)[3]) srcRowB;
+ GLhalfARB (*dst)[3] = (GLhalfARB (*)[3]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ for (comp = 0; comp < 3; comp++) {
+ GLfloat aj, ak, bj, bk;
+ aj = _mesa_half_to_float(rowA[j][comp]);
+ ak = _mesa_half_to_float(rowA[k][comp]);
+ bj = _mesa_half_to_float(rowB[j][comp]);
+ bk = _mesa_half_to_float(rowB[k][comp]);
+ dst[i][comp] = _mesa_float_to_half((aj + ak + bj + bk) * 0.25F);
+ }
+ }
+ }
+ return;
+ case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
+ {
+ GLuint i, j, k;
+ const GLfloat (*rowA)[2] = (const GLfloat (*)[2]) srcRowA;
+ const GLfloat (*rowB)[2] = (const GLfloat (*)[2]) srcRowB;
+ GLfloat (*dst)[2] = (GLfloat (*)[2]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i][0] = (rowA[j][0] + rowA[k][0] +
+ rowB[j][0] + rowB[k][0]) * 0.25F;
+ dst[i][1] = (rowA[j][1] + rowA[k][1] +
+ rowB[j][1] + rowB[k][1]) * 0.25F;
+ }
+ }
+ return;
+ case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16:
+ {
+ GLuint i, j, k, comp;
+ const GLhalfARB (*rowA)[2] = (const GLhalfARB (*)[2]) srcRowA;
+ const GLhalfARB (*rowB)[2] = (const GLhalfARB (*)[2]) srcRowB;
+ GLhalfARB (*dst)[2] = (GLhalfARB (*)[2]) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ for (comp = 0; comp < 2; comp++) {
+ GLfloat aj, ak, bj, bk;
+ aj = _mesa_half_to_float(rowA[j][comp]);
+ ak = _mesa_half_to_float(rowA[k][comp]);
+ bj = _mesa_half_to_float(rowB[j][comp]);
+ bk = _mesa_half_to_float(rowB[k][comp]);
+ dst[i][comp] = _mesa_float_to_half((aj + ak + bj + bk) * 0.25F);
+ }
+ }
+ }
+ return;
+ case MESA_FORMAT_ALPHA_FLOAT32:
+ case MESA_FORMAT_LUMINANCE_FLOAT32:
+ case MESA_FORMAT_INTENSITY_FLOAT32:
+ {
+ GLuint i, j, k;
+ const GLfloat *rowA = (const GLfloat *) srcRowA;
+ const GLfloat *rowB = (const GLfloat *) srcRowB;
+ GLfloat *dst = (GLfloat *) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) * 0.25F;
+ }
+ }
+ return;
+ case MESA_FORMAT_ALPHA_FLOAT16:
+ case MESA_FORMAT_LUMINANCE_FLOAT16:
+ case MESA_FORMAT_INTENSITY_FLOAT16:
+ {
+ GLuint i, j, k;
+ const GLhalfARB *rowA = (const GLhalfARB *) srcRowA;
+ const GLhalfARB *rowB = (const GLhalfARB *) srcRowB;
+ GLhalfARB *dst = (GLhalfARB *) dstRow;
+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
+ i++, j += colStride, k += colStride) {
+ GLfloat aj, ak, bj, bk;
+ aj = _mesa_half_to_float(rowA[j]);
+ ak = _mesa_half_to_float(rowA[k]);
+ bj = _mesa_half_to_float(rowB[j]);
+ bk = _mesa_half_to_float(rowB[k]);
+ dst[i] = _mesa_float_to_half((aj + ak + bj + bk) * 0.25F);
+ }
+ }
+ return;
+
+ default:
+ _mesa_problem(NULL, "bad format in do_row()");
+ }
+}
+
+
+/*
+ * These functions generate a 1/2-size mipmap image from a source image.
+ * Texture borders are handled by copying or averaging the source image's
+ * border texels, depending on the scale-down factor.
+ */
+
+static void
+make_1d_mipmap(const struct gl_texture_format *format, GLint border,
+ GLint srcWidth, const GLubyte *srcPtr,
+ GLint dstWidth, GLubyte *dstPtr)
+{
+ const GLint bpt = format->TexelBytes;
+ const GLubyte *src;
+ GLubyte *dst;
+
+ /* skip the border pixel, if any */
+ src = srcPtr + border * bpt;
+ dst = dstPtr + border * bpt;
+
+ /* we just duplicate the input row, kind of hack, saves code */
+ do_row(format, srcWidth - 2 * border, src, src,
+ dstWidth - 2 * border, dst);
+
+ if (border) {
+ /* copy left-most pixel from source */
+ MEMCPY(dstPtr, srcPtr, bpt);
+ /* copy right-most pixel from source */
+ MEMCPY(dstPtr + (dstWidth - 1) * bpt,
+ srcPtr + (srcWidth - 1) * bpt,
+ bpt);
+ }
+}
+
+
+static void
+make_2d_mipmap(const struct gl_texture_format *format, GLint border,
+ GLint srcWidth, GLint srcHeight, const GLubyte *srcPtr,
+ GLint dstWidth, GLint dstHeight, GLubyte *dstPtr)
+{
+ const GLint bpt = format->TexelBytes;
+ const GLint srcWidthNB = srcWidth - 2 * border; /* sizes w/out border */
+ const GLint dstWidthNB = dstWidth - 2 * border;
+ const GLint dstHeightNB = dstHeight - 2 * border;
+ const GLint srcRowStride = bpt * srcWidth;
+ const GLint dstRowStride = bpt * dstWidth;
+ const GLubyte *srcA, *srcB;
+ GLubyte *dst;
+ GLint row;
+
+ /* Compute src and dst pointers, skipping any border */
+ srcA = srcPtr + border * ((srcWidth + 1) * bpt);
+ if (srcHeight > 1)
+ srcB = srcA + srcRowStride;
+ else
+ srcB = srcA;
+ dst = dstPtr + border * ((dstWidth + 1) * bpt);
+
+ for (row = 0; row < dstHeightNB; row++) {
+ do_row(format, srcWidthNB, srcA, srcB,
+ dstWidthNB, dst);
+ srcA += 2 * srcRowStride;
+ srcB += 2 * srcRowStride;
+ dst += dstRowStride;
+ }
+
+ /* This is ugly but probably won't be used much */
+ if (border > 0) {
+ /* fill in dest border */
+ /* lower-left border pixel */
+ MEMCPY(dstPtr, srcPtr, bpt);
+ /* lower-right border pixel */
+ MEMCPY(dstPtr + (dstWidth - 1) * bpt,
+ srcPtr + (srcWidth - 1) * bpt, bpt);
+ /* upper-left border pixel */
+ MEMCPY(dstPtr + dstWidth * (dstHeight - 1) * bpt,
+ srcPtr + srcWidth * (srcHeight - 1) * bpt, bpt);
+ /* upper-right border pixel */
+ MEMCPY(dstPtr + (dstWidth * dstHeight - 1) * bpt,
+ srcPtr + (srcWidth * srcHeight - 1) * bpt, bpt);
+ /* lower border */
+ do_row(format, srcWidthNB,
+ srcPtr + bpt,
+ srcPtr + bpt,
+ dstWidthNB, dstPtr + bpt);
+ /* upper border */
+ do_row(format, srcWidthNB,
+ srcPtr + (srcWidth * (srcHeight - 1) + 1) * bpt,
+ srcPtr + (srcWidth * (srcHeight - 1) + 1) * bpt,
+ dstWidthNB,
+ dstPtr + (dstWidth * (dstHeight - 1) + 1) * bpt);
+ /* left and right borders */
+ if (srcHeight == dstHeight) {
+ /* copy border pixel from src to dst */
+ for (row = 1; row < srcHeight; row++) {
+ MEMCPY(dstPtr + dstWidth * row * bpt,
+ srcPtr + srcWidth * row * bpt, bpt);
+ MEMCPY(dstPtr + (dstWidth * row + dstWidth - 1) * bpt,
+ srcPtr + (srcWidth * row + srcWidth - 1) * bpt, bpt);
+ }
+ }
+ else {
+ /* average two src pixels each dest pixel */
+ for (row = 0; row < dstHeightNB; row += 2) {
+ do_row(format, 1,
+ srcPtr + (srcWidth * (row * 2 + 1)) * bpt,
+ srcPtr + (srcWidth * (row * 2 + 2)) * bpt,
+ 1, dstPtr + (dstWidth * row + 1) * bpt);
+ do_row(format, 1,
+ srcPtr + (srcWidth * (row * 2 + 1) + srcWidth - 1) * bpt,
+ srcPtr + (srcWidth * (row * 2 + 2) + srcWidth - 1) * bpt,
+ 1, dstPtr + (dstWidth * row + 1 + dstWidth - 1) * bpt);
+ }
+ }
+ }
+}
+
+
+static void
+make_3d_mipmap(const struct gl_texture_format *format, GLint border,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ const GLubyte *srcPtr,
+ GLint dstWidth, GLint dstHeight, GLint dstDepth,
+ GLubyte *dstPtr)
+{
+ const GLint bpt = format->TexelBytes;
+ const GLint srcWidthNB = srcWidth - 2 * border; /* sizes w/out border */
+ const GLint srcDepthNB = srcDepth - 2 * border;
+ const GLint dstWidthNB = dstWidth - 2 * border;
+ const GLint dstHeightNB = dstHeight - 2 * border;
+ const GLint dstDepthNB = dstDepth - 2 * border;
+ GLvoid *tmpRowA, *tmpRowB;
+ GLint img, row;
+ GLint bytesPerSrcImage, bytesPerDstImage;
+ GLint bytesPerSrcRow, bytesPerDstRow;
+ GLint srcImageOffset, srcRowOffset;
+
+ (void) srcDepthNB; /* silence warnings */
+
+ /* Need two temporary row buffers */
+ tmpRowA = _mesa_malloc(srcWidth * bpt);
+ if (!tmpRowA)
+ return;
+ tmpRowB = _mesa_malloc(srcWidth * bpt);
+ if (!tmpRowB) {
+ _mesa_free(tmpRowA);
+ return;
+ }
+
+ bytesPerSrcImage = srcWidth * srcHeight * bpt;
+ bytesPerDstImage = dstWidth * dstHeight * bpt;
+
+ bytesPerSrcRow = srcWidth * bpt;
+ bytesPerDstRow = dstWidth * bpt;
+
+ /* Offset between adjacent src images to be averaged together */
+ srcImageOffset = (srcDepth == dstDepth) ? 0 : bytesPerSrcImage;
+
+ /* Offset between adjacent src rows to be averaged together */
+ srcRowOffset = (srcHeight == dstHeight) ? 0 : srcWidth * bpt;
+
+ /*
+ * Need to average together up to 8 src pixels for each dest pixel.
+ * Break that down into 3 operations:
+ * 1. take two rows from source image and average them together.
+ * 2. take two rows from next source image and average them together.
+ * 3. take the two averaged rows and average them for the final dst row.
+ */
+
+ /*
+ _mesa_printf("mip3d %d x %d x %d -> %d x %d x %d\n",
+ srcWidth, srcHeight, srcDepth, dstWidth, dstHeight, dstDepth);
+ */
+
+ for (img = 0; img < dstDepthNB; img++) {
+ /* first source image pointer, skipping border */
+ const GLubyte *imgSrcA = srcPtr
+ + (bytesPerSrcImage + bytesPerSrcRow + border) * bpt * border
+ + img * (bytesPerSrcImage + srcImageOffset);
+ /* second source image pointer, skipping border */
+ const GLubyte *imgSrcB = imgSrcA + srcImageOffset;
+ /* address of the dest image, skipping border */
+ GLubyte *imgDst = dstPtr
+ + (bytesPerDstImage + bytesPerDstRow + border) * bpt * border
+ + img * bytesPerDstImage;
+
+ /* setup the four source row pointers and the dest row pointer */
+ const GLubyte *srcImgARowA = imgSrcA;
+ const GLubyte *srcImgARowB = imgSrcA + srcRowOffset;
+ const GLubyte *srcImgBRowA = imgSrcB;
+ const GLubyte *srcImgBRowB = imgSrcB + srcRowOffset;
+ GLubyte *dstImgRow = imgDst;
+
+ for (row = 0; row < dstHeightNB; row++) {
+ /* Average together two rows from first src image */
+ do_row(format, srcWidthNB, srcImgARowA, srcImgARowB,
+ srcWidthNB, tmpRowA);
+ /* Average together two rows from second src image */
+ do_row(format, srcWidthNB, srcImgBRowA, srcImgBRowB,
+ srcWidthNB, tmpRowB);
+ /* Average together the temp rows to make the final row */
+ do_row(format, srcWidthNB, tmpRowA, tmpRowB,
+ dstWidthNB, dstImgRow);
+ /* advance to next rows */
+ srcImgARowA += bytesPerSrcRow + srcRowOffset;
+ srcImgARowB += bytesPerSrcRow + srcRowOffset;
+ srcImgBRowA += bytesPerSrcRow + srcRowOffset;
+ srcImgBRowB += bytesPerSrcRow + srcRowOffset;
+ dstImgRow += bytesPerDstRow;
+ }
+ }
+
+ _mesa_free(tmpRowA);
+ _mesa_free(tmpRowB);
+
+ /* Luckily we can leverage the make_2d_mipmap() function here! */
+ if (border > 0) {
+ /* do front border image */
+ make_2d_mipmap(format, 1, srcWidth, srcHeight, srcPtr,
+ dstWidth, dstHeight, dstPtr);
+ /* do back border image */
+ make_2d_mipmap(format, 1, srcWidth, srcHeight,
+ srcPtr + bytesPerSrcImage * (srcDepth - 1),
+ dstWidth, dstHeight,
+ dstPtr + bytesPerDstImage * (dstDepth - 1));
+ /* do four remaining border edges that span the image slices */
+ if (srcDepth == dstDepth) {
+ /* just copy border pixels from src to dst */
+ for (img = 0; img < dstDepthNB; img++) {
+ const GLubyte *src;
+ GLubyte *dst;
+
+ /* do border along [img][row=0][col=0] */
+ src = srcPtr + (img + 1) * bytesPerSrcImage;
+ dst = dstPtr + (img + 1) * bytesPerDstImage;
+ MEMCPY(dst, src, bpt);
+
+ /* do border along [img][row=dstHeight-1][col=0] */
+ src = srcPtr + (img * 2 + 1) * bytesPerSrcImage
+ + (srcHeight - 1) * bytesPerSrcRow;
+ dst = dstPtr + (img + 1) * bytesPerDstImage
+ + (dstHeight - 1) * bytesPerDstRow;
+ MEMCPY(dst, src, bpt);
+
+ /* do border along [img][row=0][col=dstWidth-1] */
+ src = srcPtr + (img * 2 + 1) * bytesPerSrcImage
+ + (srcWidth - 1) * bpt;
+ dst = dstPtr + (img + 1) * bytesPerDstImage
+ + (dstWidth - 1) * bpt;
+ MEMCPY(dst, src, bpt);
+
+ /* do border along [img][row=dstHeight-1][col=dstWidth-1] */
+ src = srcPtr + (img * 2 + 1) * bytesPerSrcImage
+ + (bytesPerSrcImage - bpt);
+ dst = dstPtr + (img + 1) * bytesPerDstImage
+ + (bytesPerDstImage - bpt);
+ MEMCPY(dst, src, bpt);
+ }
+ }
+ else {
+ /* average border pixels from adjacent src image pairs */
+ ASSERT(srcDepthNB == 2 * dstDepthNB);
+ for (img = 0; img < dstDepthNB; img++) {
+ const GLubyte *src;
+ GLubyte *dst;
+
+ /* do border along [img][row=0][col=0] */
+ src = srcPtr + (img * 2 + 1) * bytesPerSrcImage;
+ dst = dstPtr + (img + 1) * bytesPerDstImage;
+ do_row(format, 1, src, src + srcImageOffset, 1, dst);
+
+ /* do border along [img][row=dstHeight-1][col=0] */
+ src = srcPtr + (img * 2 + 1) * bytesPerSrcImage
+ + (srcHeight - 1) * bytesPerSrcRow;
+ dst = dstPtr + (img + 1) * bytesPerDstImage
+ + (dstHeight - 1) * bytesPerDstRow;
+ do_row(format, 1, src, src + srcImageOffset, 1, dst);
+
+ /* do border along [img][row=0][col=dstWidth-1] */
+ src = srcPtr + (img * 2 + 1) * bytesPerSrcImage
+ + (srcWidth - 1) * bpt;
+ dst = dstPtr + (img + 1) * bytesPerDstImage
+ + (dstWidth - 1) * bpt;
+ do_row(format, 1, src, src + srcImageOffset, 1, dst);
+
+ /* do border along [img][row=dstHeight-1][col=dstWidth-1] */
+ src = srcPtr + (img * 2 + 1) * bytesPerSrcImage
+ + (bytesPerSrcImage - bpt);
+ dst = dstPtr + (img + 1) * bytesPerDstImage
+ + (bytesPerDstImage - bpt);
+ do_row(format, 1, src, src + srcImageOffset, 1, dst);
+ }
+ }
+ }
+}
+
+
+/*
+ * For GL_SGIX_generate_mipmap:
+ * Generate a complete set of mipmaps from texObj's base-level image.
+ * Stop at texObj's MaxLevel or when we get to the 1x1 texture.
+ */
+void
+_mesa_generate_mipmap(GLcontext *ctx, GLenum target,
+ const struct gl_texture_unit *texUnit,
+ struct gl_texture_object *texObj)
+{
+ const struct gl_texture_image *srcImage;
+ const struct gl_texture_format *convertFormat;
+ const GLubyte *srcData = NULL;
+ GLubyte *dstData = NULL;
+ GLint level, maxLevels;
+
+ ASSERT(texObj);
+ /* XXX choose cube map face here??? */
+ srcImage = texObj->Image[0][texObj->BaseLevel];
+ ASSERT(srcImage);
+
+ maxLevels = _mesa_max_texture_levels(ctx, texObj->Target);
+ ASSERT(maxLevels > 0); /* bad target */
+
+ /* Find convertFormat - the format that do_row() will process */
+ if (srcImage->IsCompressed) {
+ /* setup for compressed textures */
+ GLuint row;
+ GLint components, size;
+ GLchan *dst;
+
+ assert(texObj->Target == GL_TEXTURE_2D);
+
+ if (srcImage->Format == GL_RGB) {
+ convertFormat = &_mesa_texformat_rgb;
+ components = 3;
+ }
+ else if (srcImage->Format == GL_RGBA) {
+ convertFormat = &_mesa_texformat_rgba;
+ components = 4;
+ }
+ else {
+ _mesa_problem(ctx, "bad srcImage->Format in _mesa_generate_mipmaps");
+ return;
+ }
+
+ /* allocate storage for uncompressed GL_RGB or GL_RGBA images */
+ size = _mesa_bytes_per_pixel(srcImage->Format, CHAN_TYPE)
+ * srcImage->Width * srcImage->Height * srcImage->Depth + 20;
+ /* 20 extra bytes, just be safe when calling last FetchTexel */
+ srcData = (GLubyte *) _mesa_malloc(size);
+ if (!srcData) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "generate mipmaps");
+ return;
+ }
+ dstData = (GLubyte *) _mesa_malloc(size / 2); /* 1/4 would probably be OK */
+ if (!dstData) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "generate mipmaps");
+ _mesa_free((void *) srcData);
+ return;
+ }
+
+ /* decompress base image here */
+ dst = (GLchan *) srcData;
+ for (row = 0; row < srcImage->Height; row++) {
+ GLuint col;
+ for (col = 0; col < srcImage->Width; col++) {
+ srcImage->FetchTexelc(srcImage, col, row, 0, dst);
+ dst += components;
+ }
+ }
+ }
+ else {
+ /* uncompressed */
+ convertFormat = srcImage->TexFormat;
+ }
+
+ for (level = texObj->BaseLevel; level < texObj->MaxLevel
+ && level < maxLevels - 1; level++) {
+ /* generate image[level+1] from image[level] */
+ const struct gl_texture_image *srcImage;
+ struct gl_texture_image *dstImage;
+ GLint srcWidth, srcHeight, srcDepth;
+ GLint dstWidth, dstHeight, dstDepth;
+ GLint border, bytesPerTexel;
+
+ /* get src image parameters */
+ srcImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ ASSERT(srcImage);
+ srcWidth = srcImage->Width;
+ srcHeight = srcImage->Height;
+ srcDepth = srcImage->Depth;
+ border = srcImage->Border;
+
+ /* compute next (level+1) image size */
+ if (srcWidth - 2 * border > 1) {
+ dstWidth = (srcWidth - 2 * border) / 2 + 2 * border;
+ }
+ else {
+ dstWidth = srcWidth; /* can't go smaller */
+ }
+ if (srcHeight - 2 * border > 1) {
+ dstHeight = (srcHeight - 2 * border) / 2 + 2 * border;
+ }
+ else {
+ dstHeight = srcHeight; /* can't go smaller */
+ }
+ if (srcDepth - 2 * border > 1) {
+ dstDepth = (srcDepth - 2 * border) / 2 + 2 * border;
+ }
+ else {
+ dstDepth = srcDepth; /* can't go smaller */
+ }
+
+ if (dstWidth == srcWidth &&
+ dstHeight == srcHeight &&
+ dstDepth == srcDepth) {
+ /* all done */
+ if (srcImage->IsCompressed) {
+ _mesa_free((void *) srcData);
+ _mesa_free(dstData);
+ }
+ return;
+ }
+
+ /* get dest gl_texture_image */
+ dstImage = _mesa_get_tex_image(ctx, texUnit, target, level + 1);
+ if (!dstImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
+ return;
+ }
+
+ /* Free old image data */
+ if (dstImage->Data)
+ ctx->Driver.FreeTexImageData(ctx, dstImage);
+
+ /* initialize new image */
+ _mesa_init_teximage_fields(ctx, target, dstImage, dstWidth, dstHeight,
+ dstDepth, border, srcImage->IntFormat);
+ dstImage->DriverData = NULL;
+ dstImage->TexFormat = srcImage->TexFormat;
+ dstImage->FetchTexelc = srcImage->FetchTexelc;
+ dstImage->FetchTexelf = srcImage->FetchTexelf;
+ ASSERT(dstImage->TexFormat);
+ ASSERT(dstImage->FetchTexelc);
+ ASSERT(dstImage->FetchTexelf);
+
+ /* Alloc new teximage data buffer.
+ * Setup src and dest data pointers.
+ */
+ if (dstImage->IsCompressed) {
+ ASSERT(dstImage->CompressedSize > 0); /* set by init_teximage_fields*/
+ dstImage->Data = _mesa_alloc_texmemory(dstImage->CompressedSize);
+ if (!dstImage->Data) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
+ return;
+ }
+ /* srcData and dstData are already set */
+ ASSERT(srcData);
+ ASSERT(dstData);
+ }
+ else {
+ bytesPerTexel = srcImage->TexFormat->TexelBytes;
+ ASSERT(dstWidth * dstHeight * dstDepth * bytesPerTexel > 0);
+ dstImage->Data = _mesa_alloc_texmemory(dstWidth * dstHeight
+ * dstDepth * bytesPerTexel);
+ if (!dstImage->Data) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
+ return;
+ }
+ srcData = (const GLubyte *) srcImage->Data;
+ dstData = (GLubyte *) dstImage->Data;
+ }
+
+ /*
+ * We use simple 2x2 averaging to compute the next mipmap level.
+ */
+ switch (target) {
+ case GL_TEXTURE_1D:
+ make_1d_mipmap(convertFormat, border,
+ srcWidth, srcData,
+ dstWidth, dstData);
+ break;
+ case GL_TEXTURE_2D:
+ 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:
+ make_2d_mipmap(convertFormat, border,
+ srcWidth, srcHeight, srcData,
+ dstWidth, dstHeight, dstData);
+ break;
+ case GL_TEXTURE_3D:
+ make_3d_mipmap(convertFormat, border,
+ srcWidth, srcHeight, srcDepth, srcData,
+ dstWidth, dstHeight, dstDepth, dstData);
+ break;
+ case GL_TEXTURE_RECTANGLE_NV:
+ /* no mipmaps, do nothing */
+ break;
+ default:
+ _mesa_problem(ctx, "bad dimensions in _mesa_generate_mipmaps");
+ return;
+ }
+
+ if (dstImage->IsCompressed) {
+ GLubyte *temp;
+ /* compress image from dstData into dstImage->Data */
+ const GLenum srcFormat = convertFormat->BaseFormat;
+ GLint dstRowStride = _mesa_compressed_row_stride(srcImage->IntFormat,
+ dstWidth);
+ ASSERT(srcFormat == GL_RGB || srcFormat == GL_RGBA);
+ dstImage->TexFormat->StoreImage(ctx, 2, dstImage->Format,
+ dstImage->TexFormat,
+ dstImage->Data,
+ 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride, 0, /* strides */
+ dstWidth, dstHeight, 1, /* size */
+ srcFormat, CHAN_TYPE,
+ dstData, /* src data, actually */
+ &ctx->DefaultPacking);
+ /* swap src and dest pointers */
+ temp = (GLubyte *) srcData;
+ srcData = dstData;
+ dstData = temp;
+ }
+
+ } /* loop over mipmap levels */
+}
+
+
+/**
+ * Helper function for drivers which need to rescale texture images to
+ * certain aspect ratios.
+ * Nearest filtering only (for broken hardware that can't support
+ * all aspect ratios). This can be made a lot faster, but I don't
+ * really care enough...
+ */
+void
+_mesa_rescale_teximage2d (GLuint bytesPerPixel,
+ GLuint srcStrideInPixels,
+ GLuint dstRowStride,
+ GLint srcWidth, GLint srcHeight,
+ GLint dstWidth, GLint dstHeight,
+ const GLvoid *srcImage, GLvoid *dstImage)
+{
+ GLint row, col;
+
+#define INNER_LOOP( TYPE, HOP, WOP ) \
+ for ( row = 0 ; row < dstHeight ; row++ ) { \
+ GLint srcRow = row HOP hScale; \
+ for ( col = 0 ; col < dstWidth ; col++ ) { \
+ GLint srcCol = col WOP wScale; \
+ dst[col] = src[srcRow * srcStrideInPixels + srcCol]; \
+ } \
+ dst = (TYPE *) ((GLubyte *) dst + dstRowStride); \
+ } \
+
+#define RESCALE_IMAGE( TYPE ) \
+do { \
+ const TYPE *src = (const TYPE *)srcImage; \
+ TYPE *dst = (TYPE *)dstImage; \
+ \
+ if ( srcHeight < dstHeight ) { \
+ const GLint hScale = dstHeight / srcHeight; \
+ if ( srcWidth < dstWidth ) { \
+ const GLint wScale = dstWidth / srcWidth; \
+ INNER_LOOP( TYPE, /, / ); \
+ } \
+ else { \
+ const GLint wScale = srcWidth / dstWidth; \
+ INNER_LOOP( TYPE, /, * ); \
+ } \
+ } \
+ else { \
+ const GLint hScale = srcHeight / dstHeight; \
+ if ( srcWidth < dstWidth ) { \
+ const GLint wScale = dstWidth / srcWidth; \
+ INNER_LOOP( TYPE, *, / ); \
+ } \
+ else { \
+ const GLint wScale = srcWidth / dstWidth; \
+ INNER_LOOP( TYPE, *, * ); \
+ } \
+ } \
+} while (0)
+
+ switch ( bytesPerPixel ) {
+ case 4:
+ RESCALE_IMAGE( GLuint );
+ break;
+
+ case 2:
+ RESCALE_IMAGE( GLushort );
+ break;
+
+ case 1:
+ RESCALE_IMAGE( GLubyte );
+ break;
+ default:
+ _mesa_problem(NULL,"unexpected bytes/pixel in _mesa_rescale_teximage2d");
+ }
+}
+
+
+/**
+ * Upscale an image by replication, not (typical) stretching.
+ * We use this when the image width or height is less than a
+ * certain size (4, 8) and we need to upscale an image.
+ */
+void
+_mesa_upscale_teximage2d (GLsizei inWidth, GLsizei inHeight,
+ GLsizei outWidth, GLsizei outHeight,
+ GLint comps, const GLchan *src, GLint srcRowStride,
+ GLchan *dest )
+{
+ GLint i, j, k;
+
+ ASSERT(outWidth >= inWidth);
+ ASSERT(outHeight >= inHeight);
+#if 0
+ ASSERT(inWidth == 1 || inWidth == 2 || inHeight == 1 || inHeight == 2);
+ ASSERT((outWidth & 3) == 0);
+ ASSERT((outHeight & 3) == 0);
+#endif
+
+ for (i = 0; i < outHeight; i++) {
+ const GLint ii = i % inHeight;
+ for (j = 0; j < outWidth; j++) {
+ const GLint jj = j % inWidth;
+ for (k = 0; k < comps; k++) {
+ dest[(i * outWidth + j) * comps + k]
+ = src[ii * srcRowStride + jj * comps + k];
+ }
+ }
+ }
+}
+
+
+
+/**
+ * This is the software fallback for Driver.GetTexImage().
+ * All error checking will have been done before this routine is called.
+ */
+void
+_mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level,
+ GLenum format, GLenum type, GLvoid *pixels,
+ const struct gl_texture_object *texObj,
+ const struct gl_texture_image *texImage)
+{
+ GLuint dimensions = (target == GL_TEXTURE_3D) ? 3 : 2;
+
+ if (ctx->Pack.BufferObj->Name) {
+ /* pack texture image into a PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(dimensions, &ctx->Pack, texImage->Width,
+ texImage->Height, texImage->Depth,
+ format, type, pixels)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetTexImage(invalid PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ GL_WRITE_ONLY_ARB,
+ ctx->Pack.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,"glGetTexImage(PBO is mapped)");
+ return;
+ }
+ pixels = ADD_POINTERS(buf, pixels);
+ }
+ else if (!pixels) {
+ /* not an error */
+ return;
+ }
+
+ {
+ const GLint width = texImage->Width;
+ const GLint height = texImage->Height;
+ const GLint depth = texImage->Depth;
+ GLint img, row;
+ for (img = 0; img < depth; img++) {
+ for (row = 0; row < height; row++) {
+ /* compute destination address in client memory */
+ GLvoid *dest = _mesa_image_address( dimensions, &ctx->Pack, pixels,
+ width, height, format, type,
+ img, row, 0);
+ assert(dest);
+
+ if (format == GL_COLOR_INDEX) {
+ GLuint indexRow[MAX_WIDTH];
+ GLint col;
+ /* Can't use FetchTexel here because that returns RGBA */
+ if (texImage->TexFormat->IndexBits == 8) {
+ const GLubyte *src = (const GLubyte *) texImage->Data;
+ for (col = 0; col < width; col++) {
+ indexRow[col] = src[texImage->Width *
+ (img * texImage->Height + row) + col];
+ }
+ }
+ else if (texImage->TexFormat->IndexBits == 16) {
+ const GLushort *src = (const GLushort *) texImage->Data;
+ for (col = 0; col < width; col++) {
+ indexRow[col] = src[texImage->Width *
+ (img * texImage->Height + row) + col];
+ }
+ }
+ else {
+ _mesa_problem(ctx,
+ "Color index problem in _mesa_GetTexImage");
+ }
+ _mesa_pack_index_span(ctx, width, type, dest,
+ indexRow, &ctx->Pack,
+ 0 /* no image transfer */);
+ }
+ else if (format == GL_DEPTH_COMPONENT) {
+ GLfloat depthRow[MAX_WIDTH];
+ GLint col;
+ for (col = 0; col < width; col++) {
+ (*texImage->FetchTexelf)(texImage, col, row, img,
+ depthRow + col);
+ }
+ _mesa_pack_depth_span(ctx, width, dest, type,
+ depthRow, &ctx->Pack);
+ }
+ else if (format == GL_YCBCR_MESA) {
+ /* No pixel transfer */
+ const GLint rowstride = texImage->RowStride;
+ MEMCPY(dest,
+ (const GLushort *) texImage->Data + row * rowstride,
+ width * sizeof(GLushort));
+ /* check for byte swapping */
+ if ((texImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR
+ && type == GL_UNSIGNED_SHORT_8_8_REV_MESA) ||
+ (texImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR_REV
+ && type == GL_UNSIGNED_SHORT_8_8_MESA)) {
+ if (!ctx->Pack.SwapBytes)
+ _mesa_swap2((GLushort *) dest, width);
+ }
+ else if (ctx->Pack.SwapBytes) {
+ _mesa_swap2((GLushort *) dest, width);
+ }
+ }
+ else {
+ /* general case: convert row to RGBA format */
+ GLfloat rgba[MAX_WIDTH][4];
+ GLint col;
+ for (col = 0; col < width; col++) {
+ (*texImage->FetchTexelf)(texImage, col, row, img, rgba[col]);
+ }
+ _mesa_pack_rgba_span_float(ctx, width,
+ (const GLfloat (*)[4]) rgba,
+ format, type, dest, &ctx->Pack,
+ 0 /* no image transfer */);
+ } /* format */
+ } /* row */
+ } /* img */
+ }
+
+ if (ctx->Pack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ ctx->Pack.BufferObj);
+ }
+}
+
+
+
+/**
+ * This is the software fallback for Driver.GetCompressedTexImage().
+ * All error checking will have been done before this routine is called.
+ */
+void
+_mesa_get_compressed_teximage(GLcontext *ctx, GLenum target, GLint level,
+ GLvoid *img,
+ const struct gl_texture_object *texObj,
+ const struct gl_texture_image *texImage)
+{
+ if (ctx->Pack.BufferObj->Name) {
+ /* pack texture image into a PBO */
+ GLubyte *buf;
+ if ((const GLubyte *) img + texImage->CompressedSize >
+ (const GLubyte *) ctx->Pack.BufferObj->Size) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetCompressedTexImage(invalid PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ GL_WRITE_ONLY_ARB,
+ ctx->Pack.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetCompressedTexImage(PBO is mapped)");
+ return;
+ }
+ img = ADD_POINTERS(buf, img);
+ }
+ else if (!img) {
+ /* not an error */
+ return;
+ }
+
+ /* just memcpy, no pixelstore or pixel transfer */
+ MEMCPY(img, texImage->Data, texImage->CompressedSize);
+
+ if (ctx->Pack.BufferObj->Name) {
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ ctx->Pack.BufferObj);
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/texstore.h b/nx-X11/extras/Mesa/src/mesa/main/texstore.h
new file mode 100644
index 000000000..0b91f20e3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/texstore.h
@@ -0,0 +1,261 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file texstore.h
+ * Texture image storage routines.
+ *
+ * \author Brian Paul
+ */
+
+
+#ifndef TEXSTORE_H
+#define TEXSTORE_H
+
+
+#include "mtypes.h"
+
+/* Macro just to save some typing */
+#define STORE_PARAMS \
+ GLcontext *ctx, GLuint dims, \
+ GLenum baseInternalFormat, \
+ const struct gl_texture_format *dstFormat, \
+ GLvoid *dstAddr, \
+ GLint dstXoffset, GLint dstYoffset, GLint dstZoffset, \
+ GLint dstRowStride, GLint dstImageStride, \
+ GLint srcWidth, GLint srcHeight, GLint srcDepth, \
+ GLenum srcFormat, GLenum srcType, \
+ const GLvoid *srcAddr, \
+ const struct gl_pixelstore_attrib *srcPacking
+
+
+extern GLboolean _mesa_texstore_rgba(STORE_PARAMS);
+extern GLboolean _mesa_texstore_color_index(STORE_PARAMS);
+extern GLboolean _mesa_texstore_depth_component16(STORE_PARAMS);
+extern GLboolean _mesa_texstore_depth_component_float32(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgba8888(STORE_PARAMS);
+extern GLboolean _mesa_texstore_argb8888(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgb888(STORE_PARAMS);
+extern GLboolean _mesa_texstore_bgr888(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgb565(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgb565_rev(STORE_PARAMS);
+extern GLboolean _mesa_texstore_argb4444(STORE_PARAMS);
+extern GLboolean _mesa_texstore_argb4444_rev(STORE_PARAMS);
+extern GLboolean _mesa_texstore_argb1555(STORE_PARAMS);
+extern GLboolean _mesa_texstore_argb1555_rev(STORE_PARAMS);
+extern GLboolean _mesa_texstore_al88(STORE_PARAMS);
+extern GLboolean _mesa_texstore_al88_rev(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgb332(STORE_PARAMS);
+extern GLboolean _mesa_texstore_a8(STORE_PARAMS);
+extern GLboolean _mesa_texstore_ci8(STORE_PARAMS);
+extern GLboolean _mesa_texstore_ycbcr(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgba_float32(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgba_float16(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgb_fxt1(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgba_fxt1(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgb_dxt1(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgba_dxt1(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgba_dxt3(STORE_PARAMS);
+extern GLboolean _mesa_texstore_rgba_dxt5(STORE_PARAMS);
+
+
+extern GLchan *
+_mesa_make_temp_chan_image(GLcontext *ctx, GLuint dims,
+ GLenum logicalBaseFormat,
+ GLenum textureBaseFormat,
+ GLint srcWidth, GLint srcHeight, GLint srcDepth,
+ GLenum srcFormat, GLenum srcType,
+ const GLvoid *srcAddr,
+ const struct gl_pixelstore_attrib *srcPacking);
+
+
+extern void
+_mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+
+
+extern void
+_mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+
+
+extern void
+_mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint depth, GLint border,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+
+
+extern void
+_mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint width,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+
+
+extern void
+_mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint width, GLint 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 void
+_mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLint width, GLint 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);
+
+
+extern void
+_mesa_store_compressed_teximage1d(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+
+extern void
+_mesa_store_compressed_teximage2d(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+
+extern void
+_mesa_store_compressed_teximage3d(GLcontext *ctx, GLenum target, GLint level,
+ GLint internalFormat,
+ GLint width, GLint height, GLint depth,
+ GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+
+
+extern void
+_mesa_store_compressed_texsubimage1d(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);
+
+extern void
+_mesa_store_compressed_texsubimage2d(GLcontext *ctx, GLenum target,
+ GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+
+extern void
+_mesa_store_compressed_texsubimage3d(GLcontext *ctx, GLenum target,
+ GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+
+
+extern void
+_mesa_generate_mipmap(GLcontext *ctx, GLenum target,
+ const struct gl_texture_unit *texUnit,
+ struct gl_texture_object *texObj);
+
+
+extern void
+_mesa_rescale_teximage2d(GLuint bytesPerPixel,
+ GLuint srcStrideInPixels,
+ GLuint dstRowStride,
+ GLint srcWidth, GLint srcHeight,
+ GLint dstWidth, GLint dstHeight,
+ const GLvoid *srcImage, GLvoid *dstImage);
+
+extern void
+_mesa_upscale_teximage2d(GLsizei inWidth, GLsizei inHeight,
+ GLsizei outWidth, GLsizei outHeight,
+ GLint comps, const GLchan *src, GLint srcRowStride,
+ GLchan *dest);
+
+
+extern void
+_mesa_get_teximage(GLcontext *ctx, GLenum target, GLint level,
+ GLenum format, GLenum type, GLvoid *pixels,
+ const struct gl_texture_object *texObj,
+ const struct gl_texture_image *texImage);
+
+
+extern void
+_mesa_get_compressed_teximage(GLcontext *ctx, GLenum target, GLint level,
+ GLvoid *img,
+ const struct gl_texture_object *texObj,
+ const struct gl_texture_image *texImage);
+
+extern const GLvoid *
+_mesa_validate_pbo_teximage(GLcontext *ctx, GLuint dimensions,
+ GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *unpack,
+ const char *funcName);
+
+extern const GLvoid *
+_mesa_validate_pbo_compressed_teximage(GLcontext *ctx,
+ GLsizei imageSize, const GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing,
+ const char *funcName);
+
+extern void
+_mesa_unmap_teximage_pbo(GLcontext *ctx,
+ const struct gl_pixelstore_attrib *unpack);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/varray.c b/nx-X11/extras/Mesa/src/mesa/main/varray.c
new file mode 100644
index 000000000..6781b6981
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/varray.c
@@ -0,0 +1,994 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "bufferobj.h"
+#include "context.h"
+#include "enable.h"
+#include "enums.h"
+#include "dlist.h"
+#include "texstate.h"
+#include "mtypes.h"
+#include "varray.h"
+#include "dispatch.h"
+
+#ifndef GL_BOOLEAN
+#define GL_BOOLEAN 0x9999
+#endif
+
+
+/**
+ * Update the fields of a vertex array structure.
+ * We need to do a few special things for arrays that live in
+ * vertex buffer objects.
+ */
+static void
+update_array(GLcontext *ctx, struct gl_client_array *array,
+ GLuint dirtyFlag, GLsizei elementSize,
+ GLint size, GLenum type,
+ GLsizei stride, GLboolean normalized, const GLvoid *ptr)
+{
+ array->Size = size;
+ array->Type = type;
+ array->Stride = stride;
+ array->StrideB = stride ? stride : elementSize;
+ array->Normalized = normalized;
+ array->Ptr = (const GLubyte *) ptr;
+#if FEATURE_ARB_vertex_buffer_object
+ array->BufferObj->RefCount--;
+ if (array->BufferObj->RefCount <= 0) {
+ ASSERT(array->BufferObj->Name);
+ _mesa_remove_buffer_object( ctx, array->BufferObj );
+ (*ctx->Driver.DeleteBuffer)( ctx, array->BufferObj );
+ }
+ array->BufferObj = ctx->Array.ArrayBufferObj;
+ array->BufferObj->RefCount++;
+ /* Compute the index of the last array element that's inside the buffer.
+ * Later in glDrawArrays we'll check if start + count > _MaxElement to
+ * be sure we won't go out of bounds.
+ */
+ if (ctx->Array.ArrayBufferObj->Name)
+ array->_MaxElement = ((GLsizeiptrARB) ctx->Array.ArrayBufferObj->Size
+ - (GLsizeiptrARB) array->Ptr) / array->StrideB;
+ else
+#endif
+ array->_MaxElement = 2 * 1000 * 1000 * 1000; /* just a big number */
+
+ ctx->NewState |= _NEW_ARRAY;
+ ctx->Array.NewState |= dirtyFlag;
+}
+
+
+void GLAPIENTRY
+_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
+{
+ GLsizei elementSize;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (size < 2 || size > 4) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glVertexPointer(size)" );
+ return;
+ }
+ if (stride < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glVertexPointer(stride)" );
+ return;
+ }
+
+ if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
+ _mesa_debug(ctx, "glVertexPointer( sz %d type %s stride %d )\n", size,
+ _mesa_lookup_enum_by_nr( type ), stride);
+
+ /* always need to check that <type> is legal */
+ switch (type) {
+ case GL_SHORT:
+ elementSize = size * sizeof(GLshort);
+ break;
+ case GL_INT:
+ elementSize = size * sizeof(GLint);
+ break;
+ case GL_FLOAT:
+ elementSize = size * sizeof(GLfloat);
+ break;
+ case GL_DOUBLE:
+ elementSize = size * sizeof(GLdouble);
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexPointer(type)" );
+ return;
+ }
+
+ update_array(ctx, &ctx->Array.Vertex, _NEW_ARRAY_VERTEX,
+ elementSize, size, type, stride, GL_FALSE, ptr);
+
+ if (ctx->Driver.VertexPointer)
+ ctx->Driver.VertexPointer( ctx, size, type, stride, ptr );
+}
+
+
+void GLAPIENTRY
+_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
+{
+ GLsizei elementSize;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (stride < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glNormalPointer(stride)" );
+ return;
+ }
+
+ if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
+ _mesa_debug(ctx, "glNormalPointer( type %s stride %d )\n",
+ _mesa_lookup_enum_by_nr( type ), stride);
+
+ switch (type) {
+ case GL_BYTE:
+ elementSize = 3 * sizeof(GLbyte);
+ break;
+ case GL_SHORT:
+ elementSize = 3 * sizeof(GLshort);
+ break;
+ case GL_INT:
+ elementSize = 3 * sizeof(GLint);
+ break;
+ case GL_FLOAT:
+ elementSize = 3 * sizeof(GLfloat);
+ break;
+ case GL_DOUBLE:
+ elementSize = 3 * sizeof(GLdouble);
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glNormalPointer(type)" );
+ return;
+ }
+
+ update_array(ctx, &ctx->Array.Normal, _NEW_ARRAY_NORMAL,
+ elementSize, 3, type, stride, GL_FALSE, ptr);
+
+ if (ctx->Driver.NormalPointer)
+ ctx->Driver.NormalPointer( ctx, type, stride, ptr );
+}
+
+
+void GLAPIENTRY
+_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
+{
+ GLsizei elementSize;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (size < 3 || size > 4) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" );
+ return;
+ }
+ if (stride < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glColorPointer(stride)" );
+ return;
+ }
+
+ if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
+ _mesa_debug(ctx, "glColorPointer( sz %d type %s stride %d )\n", size,
+ _mesa_lookup_enum_by_nr( type ), stride);
+
+ switch (type) {
+ case GL_BYTE:
+ elementSize = size * sizeof(GLbyte);
+ break;
+ case GL_UNSIGNED_BYTE:
+ elementSize = size * sizeof(GLubyte);
+ break;
+ case GL_SHORT:
+ elementSize = size * sizeof(GLshort);
+ break;
+ case GL_UNSIGNED_SHORT:
+ elementSize = size * sizeof(GLushort);
+ break;
+ case GL_INT:
+ elementSize = size * sizeof(GLint);
+ break;
+ case GL_UNSIGNED_INT:
+ elementSize = size * sizeof(GLuint);
+ break;
+ case GL_FLOAT:
+ elementSize = size * sizeof(GLfloat);
+ break;
+ case GL_DOUBLE:
+ elementSize = size * sizeof(GLdouble);
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glColorPointer(type)" );
+ return;
+ }
+
+ update_array(ctx, &ctx->Array.Color, _NEW_ARRAY_COLOR0,
+ elementSize, size, type, stride, GL_FALSE, ptr);
+
+ if (ctx->Driver.ColorPointer)
+ ctx->Driver.ColorPointer( ctx, size, type, stride, ptr );
+}
+
+
+void GLAPIENTRY
+_mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr)
+{
+ GLint elementSize;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (stride < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glFogCoordPointer(stride)" );
+ return;
+ }
+
+ switch (type) {
+ case GL_FLOAT:
+ elementSize = sizeof(GLfloat);
+ break;
+ case GL_DOUBLE:
+ elementSize = sizeof(GLdouble);
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glFogCoordPointer(type)" );
+ return;
+ }
+
+ update_array(ctx, &ctx->Array.FogCoord, _NEW_ARRAY_FOGCOORD,
+ elementSize, 1, type, stride, GL_FALSE, ptr);
+
+ if (ctx->Driver.FogCoordPointer)
+ ctx->Driver.FogCoordPointer( ctx, type, stride, ptr );
+}
+
+
+void GLAPIENTRY
+_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr)
+{
+ GLsizei elementSize;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (stride < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glIndexPointer(stride)" );
+ return;
+ }
+
+ switch (type) {
+ case GL_UNSIGNED_BYTE:
+ elementSize = sizeof(GLubyte);
+ break;
+ case GL_SHORT:
+ elementSize = sizeof(GLshort);
+ break;
+ case GL_INT:
+ elementSize = sizeof(GLint);
+ break;
+ case GL_FLOAT:
+ elementSize = sizeof(GLfloat);
+ break;
+ case GL_DOUBLE:
+ elementSize = sizeof(GLdouble);
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glIndexPointer(type)" );
+ return;
+ }
+
+ update_array(ctx, &ctx->Array.Index, _NEW_ARRAY_INDEX,
+ elementSize, 1, type, stride, GL_FALSE, ptr);
+
+ if (ctx->Driver.IndexPointer)
+ ctx->Driver.IndexPointer( ctx, type, stride, ptr );
+}
+
+
+void GLAPIENTRY
+_mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr)
+{
+ GLsizei elementSize;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (size != 3 && size != 4) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(size)" );
+ return;
+ }
+ if (stride < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glSecondaryColorPointer(stride)" );
+ return;
+ }
+
+ if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
+ _mesa_debug(ctx, "glSecondaryColorPointer( sz %d type %s stride %d )\n",
+ size, _mesa_lookup_enum_by_nr( type ), stride);
+
+ switch (type) {
+ case GL_BYTE:
+ elementSize = size * sizeof(GLbyte);
+ break;
+ case GL_UNSIGNED_BYTE:
+ elementSize = size * sizeof(GLubyte);
+ break;
+ case GL_SHORT:
+ elementSize = size * sizeof(GLshort);
+ break;
+ case GL_UNSIGNED_SHORT:
+ elementSize = size * sizeof(GLushort);
+ break;
+ case GL_INT:
+ elementSize = size * sizeof(GLint);
+ break;
+ case GL_UNSIGNED_INT:
+ elementSize = size * sizeof(GLuint);
+ break;
+ case GL_FLOAT:
+ elementSize = size * sizeof(GLfloat);
+ break;
+ case GL_DOUBLE:
+ elementSize = size * sizeof(GLdouble);
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glSecondaryColorPointer(type)" );
+ return;
+ }
+
+ update_array(ctx, &ctx->Array.SecondaryColor, _NEW_ARRAY_COLOR1,
+ elementSize, size, type, stride, GL_FALSE, ptr);
+
+ if (ctx->Driver.SecondaryColorPointer)
+ ctx->Driver.SecondaryColorPointer( ctx, size, type, stride, ptr );
+}
+
+
+void GLAPIENTRY
+_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
+ const GLvoid *ptr)
+{
+ GLint elementSize;
+ GET_CURRENT_CONTEXT(ctx);
+ const GLuint unit = ctx->Array.ActiveTexture;
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (size < 1 || size > 4) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(size)" );
+ return;
+ }
+ if (stride < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glTexCoordPointer(stride)" );
+ return;
+ }
+
+ if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
+ _mesa_debug(ctx, "glTexCoordPointer(unit %u sz %d type %s stride %d)\n",
+ unit, size, _mesa_lookup_enum_by_nr( type ), stride);
+
+ /* always need to check that <type> is legal */
+ switch (type) {
+ case GL_SHORT:
+ elementSize = size * sizeof(GLshort);
+ break;
+ case GL_INT:
+ elementSize = size * sizeof(GLint);
+ break;
+ case GL_FLOAT:
+ elementSize = size * sizeof(GLfloat);
+ break;
+ case GL_DOUBLE:
+ elementSize = size * sizeof(GLdouble);
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glTexCoordPointer(type)" );
+ return;
+ }
+
+ update_array(ctx, &ctx->Array.TexCoord[unit], _NEW_ARRAY_TEXCOORD(unit),
+ elementSize, size, type, stride, GL_FALSE, ptr);
+
+ if (ctx->Driver.TexCoordPointer)
+ ctx->Driver.TexCoordPointer( ctx, size, type, stride, ptr );
+}
+
+
+void GLAPIENTRY
+_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (stride < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glEdgeFlagPointer(stride)" );
+ return;
+ }
+
+ update_array(ctx, &ctx->Array.EdgeFlag, _NEW_ARRAY_EDGEFLAG,
+ sizeof(GLboolean), 1, GL_BOOLEAN, stride, GL_FALSE, ptr);
+
+ if (ctx->Driver.EdgeFlagPointer)
+ ctx->Driver.EdgeFlagPointer( ctx, stride, ptr );
+}
+
+
+#if FEATURE_NV_vertex_program
+void GLAPIENTRY
+_mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr)
+{
+ GLsizei elementSize;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (index >= VERT_ATTRIB_MAX) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(index)");
+ return;
+ }
+
+ if (size < 1 || size > 4) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size)");
+ return;
+ }
+
+ if (stride < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(stride)");
+ return;
+ }
+
+ if (type == GL_UNSIGNED_BYTE && size != 4) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerNV(size!=4)");
+ return;
+ }
+
+ /* check for valid 'type' and compute StrideB right away */
+ switch (type) {
+ case GL_UNSIGNED_BYTE:
+ elementSize = size * sizeof(GLubyte);
+ break;
+ case GL_SHORT:
+ elementSize = size * sizeof(GLshort);
+ break;
+ case GL_FLOAT:
+ elementSize = size * sizeof(GLfloat);
+ break;
+ case GL_DOUBLE:
+ elementSize = size * sizeof(GLdouble);
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerNV(type)" );
+ return;
+ }
+
+ update_array(ctx, &ctx->Array.VertexAttrib[index], _NEW_ARRAY_ATTRIB(index),
+ elementSize, size, type, stride, GL_FALSE, ptr);
+
+ if (ctx->Driver.VertexAttribPointer)
+ ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
+}
+#endif
+
+
+#if FEATURE_ARB_vertex_program
+void GLAPIENTRY
+_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
+ GLboolean normalized,
+ GLsizei stride, const GLvoid *ptr)
+{
+ GLsizei elementSize;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (index >= ctx->Const.MaxVertexProgramAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(index)");
+ return;
+ }
+
+ if (size < 1 || size > 4) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size)");
+ return;
+ }
+
+ if (stride < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(stride)");
+ return;
+ }
+
+ if (type == GL_UNSIGNED_BYTE && size != 4) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glVertexAttribPointerARB(size!=4)");
+ return;
+ }
+
+ /* check for valid 'type' and compute StrideB right away */
+ /* NOTE: more types are supported here than in the NV extension */
+ switch (type) {
+ case GL_BYTE:
+ elementSize = size * sizeof(GLbyte);
+ break;
+ case GL_UNSIGNED_BYTE:
+ elementSize = size * sizeof(GLubyte);
+ break;
+ case GL_SHORT:
+ elementSize = size * sizeof(GLshort);
+ break;
+ case GL_UNSIGNED_SHORT:
+ elementSize = size * sizeof(GLushort);
+ break;
+ case GL_INT:
+ elementSize = size * sizeof(GLint);
+ break;
+ case GL_UNSIGNED_INT:
+ elementSize = size * sizeof(GLuint);
+ break;
+ case GL_FLOAT:
+ elementSize = size * sizeof(GLfloat);
+ break;
+ case GL_DOUBLE:
+ elementSize = size * sizeof(GLdouble);
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttribPointerARB(type)" );
+ return;
+ }
+
+ update_array(ctx, &ctx->Array.VertexAttrib[index], _NEW_ARRAY_ATTRIB(index),
+ elementSize, size, type, stride, normalized, ptr);
+
+ /* XXX fix
+ if (ctx->Driver.VertexAttribPointer)
+ ctx->Driver.VertexAttribPointer( ctx, index, size, type, stride, ptr );
+ */
+}
+#endif
+
+
+void GLAPIENTRY
+_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid *ptr)
+{
+ (void) count;
+ _mesa_VertexPointer(size, type, stride, ptr);
+}
+
+
+void GLAPIENTRY
+_mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
+ const GLvoid *ptr)
+{
+ (void) count;
+ _mesa_NormalPointer(type, stride, ptr);
+}
+
+
+void GLAPIENTRY
+_mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count,
+ const GLvoid *ptr)
+{
+ (void) count;
+ _mesa_ColorPointer(size, type, stride, ptr);
+}
+
+
+void GLAPIENTRY
+_mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
+ const GLvoid *ptr)
+{
+ (void) count;
+ _mesa_IndexPointer(type, stride, ptr);
+}
+
+
+void GLAPIENTRY
+_mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid *ptr)
+{
+ (void) count;
+ _mesa_TexCoordPointer(size, type, stride, ptr);
+}
+
+
+void GLAPIENTRY
+_mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr)
+{
+ (void) count;
+ _mesa_EdgeFlagPointer(stride, ptr);
+}
+
+
+void GLAPIENTRY
+_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLboolean tflag, cflag, nflag; /* enable/disable flags */
+ GLint tcomps, ccomps, vcomps; /* components per texcoord, color, vertex */
+ GLenum ctype = 0; /* color type */
+ GLint coffset = 0, noffset = 0, voffset;/* color, normal, vertex offsets */
+ const GLint toffset = 0; /* always zero */
+ GLint defstride; /* default stride */
+ GLint c, f;
+
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ f = sizeof(GLfloat);
+ c = f * ((4 * sizeof(GLubyte) + (f - 1)) / f);
+
+ if (stride < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glInterleavedArrays(stride)" );
+ return;
+ }
+
+ switch (format) {
+ case GL_V2F:
+ tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE;
+ tcomps = 0; ccomps = 0; vcomps = 2;
+ voffset = 0;
+ defstride = 2*f;
+ break;
+ case GL_V3F:
+ tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_FALSE;
+ tcomps = 0; ccomps = 0; vcomps = 3;
+ voffset = 0;
+ defstride = 3*f;
+ break;
+ case GL_C4UB_V2F:
+ tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
+ tcomps = 0; ccomps = 4; vcomps = 2;
+ ctype = GL_UNSIGNED_BYTE;
+ coffset = 0;
+ voffset = c;
+ defstride = c + 2*f;
+ break;
+ case GL_C4UB_V3F:
+ tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
+ tcomps = 0; ccomps = 4; vcomps = 3;
+ ctype = GL_UNSIGNED_BYTE;
+ coffset = 0;
+ voffset = c;
+ defstride = c + 3*f;
+ break;
+ case GL_C3F_V3F:
+ tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_FALSE;
+ tcomps = 0; ccomps = 3; vcomps = 3;
+ ctype = GL_FLOAT;
+ coffset = 0;
+ voffset = 3*f;
+ defstride = 6*f;
+ break;
+ case GL_N3F_V3F:
+ tflag = GL_FALSE; cflag = GL_FALSE; nflag = GL_TRUE;
+ tcomps = 0; ccomps = 0; vcomps = 3;
+ noffset = 0;
+ voffset = 3*f;
+ defstride = 6*f;
+ break;
+ case GL_C4F_N3F_V3F:
+ tflag = GL_FALSE; cflag = GL_TRUE; nflag = GL_TRUE;
+ tcomps = 0; ccomps = 4; vcomps = 3;
+ ctype = GL_FLOAT;
+ coffset = 0;
+ noffset = 4*f;
+ voffset = 7*f;
+ defstride = 10*f;
+ break;
+ case GL_T2F_V3F:
+ tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE;
+ tcomps = 2; ccomps = 0; vcomps = 3;
+ voffset = 2*f;
+ defstride = 5*f;
+ break;
+ case GL_T4F_V4F:
+ tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_FALSE;
+ tcomps = 4; ccomps = 0; vcomps = 4;
+ voffset = 4*f;
+ defstride = 8*f;
+ break;
+ case GL_T2F_C4UB_V3F:
+ tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE;
+ tcomps = 2; ccomps = 4; vcomps = 3;
+ ctype = GL_UNSIGNED_BYTE;
+ coffset = 2*f;
+ voffset = c+2*f;
+ defstride = c+5*f;
+ break;
+ case GL_T2F_C3F_V3F:
+ tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_FALSE;
+ tcomps = 2; ccomps = 3; vcomps = 3;
+ ctype = GL_FLOAT;
+ coffset = 2*f;
+ voffset = 5*f;
+ defstride = 8*f;
+ break;
+ case GL_T2F_N3F_V3F:
+ tflag = GL_TRUE; cflag = GL_FALSE; nflag = GL_TRUE;
+ tcomps = 2; ccomps = 0; vcomps = 3;
+ noffset = 2*f;
+ voffset = 5*f;
+ defstride = 8*f;
+ break;
+ case GL_T2F_C4F_N3F_V3F:
+ tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE;
+ tcomps = 2; ccomps = 4; vcomps = 3;
+ ctype = GL_FLOAT;
+ coffset = 2*f;
+ noffset = 6*f;
+ voffset = 9*f;
+ defstride = 12*f;
+ break;
+ case GL_T4F_C4F_N3F_V4F:
+ tflag = GL_TRUE; cflag = GL_TRUE; nflag = GL_TRUE;
+ tcomps = 4; ccomps = 4; vcomps = 4;
+ ctype = GL_FLOAT;
+ coffset = 4*f;
+ noffset = 8*f;
+ voffset = 11*f;
+ defstride = 15*f;
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glInterleavedArrays(format)" );
+ return;
+ }
+
+ if (stride==0) {
+ stride = defstride;
+ }
+
+ _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY );
+ _mesa_DisableClientState( GL_INDEX_ARRAY );
+
+ /* Texcoords */
+ if (tflag) {
+ _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY );
+ _mesa_TexCoordPointer( tcomps, GL_FLOAT, stride,
+ (GLubyte *) pointer + toffset );
+ }
+ else {
+ _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY );
+ }
+
+ /* Color */
+ if (cflag) {
+ _mesa_EnableClientState( GL_COLOR_ARRAY );
+ _mesa_ColorPointer( ccomps, ctype, stride,
+ (GLubyte *) pointer + coffset );
+ }
+ else {
+ _mesa_DisableClientState( GL_COLOR_ARRAY );
+ }
+
+
+ /* Normals */
+ if (nflag) {
+ _mesa_EnableClientState( GL_NORMAL_ARRAY );
+ _mesa_NormalPointer( GL_FLOAT, stride, (GLubyte *) pointer + noffset );
+ }
+ else {
+ _mesa_DisableClientState( GL_NORMAL_ARRAY );
+ }
+
+ /* Vertices */
+ _mesa_EnableClientState( GL_VERTEX_ARRAY );
+ _mesa_VertexPointer( vcomps, GL_FLOAT, stride,
+ (GLubyte *) pointer + voffset );
+}
+
+
+void GLAPIENTRY
+_mesa_LockArraysEXT(GLint first, GLsizei count)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glLockArrays %d %d\n", first, count);
+
+ if (first == 0 && count > 0 &&
+ count <= (GLint) ctx->Const.MaxArrayLockSize) {
+ ctx->Array.LockFirst = first;
+ ctx->Array.LockCount = count;
+ }
+ else {
+ ctx->Array.LockFirst = 0;
+ ctx->Array.LockCount = 0;
+ }
+
+ ctx->NewState |= _NEW_ARRAY;
+ ctx->Array.NewState |= _NEW_ARRAY_ALL;
+
+ if (ctx->Driver.LockArraysEXT)
+ ctx->Driver.LockArraysEXT( ctx, first, count );
+}
+
+
+void GLAPIENTRY
+_mesa_UnlockArraysEXT( void )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(ctx, "glUnlockArrays\n");
+
+ ctx->Array.LockFirst = 0;
+ ctx->Array.LockCount = 0;
+ ctx->NewState |= _NEW_ARRAY;
+ ctx->Array.NewState |= _NEW_ARRAY_ALL;
+
+ if (ctx->Driver.UnlockArraysEXT)
+ ctx->Driver.UnlockArraysEXT( ctx );
+}
+
+
+/* GL_EXT_multi_draw_arrays */
+/* Somebody forgot to spec the first and count parameters as const! <sigh> */
+void GLAPIENTRY
+_mesa_MultiDrawArraysEXT( GLenum mode, GLint *first,
+ GLsizei *count, GLsizei primcount )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i;
+
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ for (i = 0; i < primcount; i++) {
+ if (count[i] > 0) {
+ CALL_DrawArrays(ctx->Exec, (mode, first[i], count[i]));
+ }
+ }
+}
+
+
+/* GL_EXT_multi_draw_arrays */
+void GLAPIENTRY
+_mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type,
+ const GLvoid **indices, GLsizei primcount )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i;
+
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ for (i = 0; i < primcount; i++) {
+ if (count[i] > 0) {
+ CALL_DrawElements(ctx->Exec, (mode, count[i], type, indices[i]));
+ }
+ }
+}
+
+
+/* GL_IBM_multimode_draw_arrays */
+void GLAPIENTRY
+_mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first,
+ const GLsizei * count,
+ GLsizei primcount, GLint modestride )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i;
+
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ for ( i = 0 ; i < primcount ; i++ ) {
+ if ( count[i] > 0 ) {
+ GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride));
+ CALL_DrawArrays(ctx->Exec, ( m, first[i], count[i] ));
+ }
+ }
+}
+
+
+/* GL_IBM_multimode_draw_arrays */
+void GLAPIENTRY
+_mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count,
+ GLenum type, const GLvoid * const * indices,
+ GLsizei primcount, GLint modestride )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i;
+
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ /* XXX not sure about ARB_vertex_buffer_object handling here */
+
+ for ( i = 0 ; i < primcount ; i++ ) {
+ if ( count[i] > 0 ) {
+ GLenum m = *((GLenum *) ((GLubyte *) mode + i * modestride));
+ CALL_DrawElements(ctx->Exec, ( m, count[i], type, indices[i] ));
+ }
+ }
+}
+
+
+/**********************************************************************/
+/***** Initialization *****/
+/**********************************************************************/
+
+void
+_mesa_init_varray( GLcontext * ctx )
+{
+ GLuint i;
+
+ /* Vertex arrays */
+ ctx->Array.Vertex.Size = 4;
+ ctx->Array.Vertex.Type = GL_FLOAT;
+ ctx->Array.Vertex.Stride = 0;
+ ctx->Array.Vertex.StrideB = 0;
+ ctx->Array.Vertex.Ptr = NULL;
+ ctx->Array.Vertex.Enabled = GL_FALSE;
+ ctx->Array.Vertex.Flags = CA_CLIENT_DATA;
+ ctx->Array.Normal.Type = GL_FLOAT;
+ ctx->Array.Normal.Stride = 0;
+ ctx->Array.Normal.StrideB = 0;
+ ctx->Array.Normal.Ptr = NULL;
+ ctx->Array.Normal.Enabled = GL_FALSE;
+ ctx->Array.Normal.Flags = CA_CLIENT_DATA;
+ ctx->Array.Color.Size = 4;
+ ctx->Array.Color.Type = GL_FLOAT;
+ ctx->Array.Color.Stride = 0;
+ ctx->Array.Color.StrideB = 0;
+ ctx->Array.Color.Ptr = NULL;
+ ctx->Array.Color.Enabled = GL_FALSE;
+ ctx->Array.Color.Flags = CA_CLIENT_DATA;
+ ctx->Array.SecondaryColor.Size = 4;
+ ctx->Array.SecondaryColor.Type = GL_FLOAT;
+ ctx->Array.SecondaryColor.Stride = 0;
+ ctx->Array.SecondaryColor.StrideB = 0;
+ ctx->Array.SecondaryColor.Ptr = NULL;
+ ctx->Array.SecondaryColor.Enabled = GL_FALSE;
+ ctx->Array.SecondaryColor.Flags = CA_CLIENT_DATA;
+ ctx->Array.FogCoord.Size = 1;
+ ctx->Array.FogCoord.Type = GL_FLOAT;
+ ctx->Array.FogCoord.Stride = 0;
+ ctx->Array.FogCoord.StrideB = 0;
+ ctx->Array.FogCoord.Ptr = NULL;
+ ctx->Array.FogCoord.Enabled = GL_FALSE;
+ ctx->Array.FogCoord.Flags = CA_CLIENT_DATA;
+ ctx->Array.Index.Type = GL_FLOAT;
+ ctx->Array.Index.Stride = 0;
+ ctx->Array.Index.StrideB = 0;
+ ctx->Array.Index.Ptr = NULL;
+ ctx->Array.Index.Enabled = GL_FALSE;
+ ctx->Array.Index.Flags = CA_CLIENT_DATA;
+ for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
+ ctx->Array.TexCoord[i].Size = 4;
+ ctx->Array.TexCoord[i].Type = GL_FLOAT;
+ ctx->Array.TexCoord[i].Stride = 0;
+ ctx->Array.TexCoord[i].StrideB = 0;
+ ctx->Array.TexCoord[i].Ptr = NULL;
+ ctx->Array.TexCoord[i].Enabled = GL_FALSE;
+ ctx->Array.TexCoord[i].Flags = CA_CLIENT_DATA;
+ }
+ ctx->Array.EdgeFlag.Stride = 0;
+ ctx->Array.EdgeFlag.StrideB = 0;
+ ctx->Array.EdgeFlag.Ptr = NULL;
+ ctx->Array.EdgeFlag.Enabled = GL_FALSE;
+ ctx->Array.EdgeFlag.Flags = CA_CLIENT_DATA;
+ ctx->Array.ActiveTexture = 0; /* GL_ARB_multitexture */
+ for (i = 0; i < VERT_ATTRIB_MAX; i++) {
+ ctx->Array.VertexAttrib[i].Size = 4;
+ ctx->Array.VertexAttrib[i].Type = GL_FLOAT;
+ ctx->Array.VertexAttrib[i].Stride = 0;
+ ctx->Array.VertexAttrib[i].StrideB = 0;
+ ctx->Array.VertexAttrib[i].Ptr = NULL;
+ ctx->Array.VertexAttrib[i].Enabled = GL_FALSE;
+ ctx->Array.VertexAttrib[i].Flags = CA_CLIENT_DATA;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/varray.h b/nx-X11/extras/Mesa/src/mesa/main/varray.h
new file mode 100644
index 000000000..3589735f6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/varray.h
@@ -0,0 +1,160 @@
+/**
+ * \file varray.h
+ * Vertex arrays.
+ *
+ * \if subset
+ * (No-op)
+ *
+ * \endif
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef VARRAY_H
+#define VARRAY_H
+
+
+#include "mtypes.h"
+
+#if _HAVE_FULL_GL
+
+extern void GLAPIENTRY
+_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride,
+ const GLvoid *ptr);
+
+extern void GLAPIENTRY
+_mesa_UnlockArraysEXT( void );
+
+extern void GLAPIENTRY
+_mesa_LockArraysEXT(GLint first, GLsizei count);
+
+
+extern void GLAPIENTRY
+_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr);
+
+
+extern void GLAPIENTRY
+_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr);
+
+
+extern void GLAPIENTRY
+_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr);
+
+
+extern void GLAPIENTRY
+_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride,
+ const GLvoid *ptr);
+
+
+extern void GLAPIENTRY
+_mesa_EdgeFlagPointer(GLsizei stride, const GLvoid *ptr);
+
+
+extern void GLAPIENTRY
+_mesa_VertexPointerEXT(GLint size, GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid *ptr);
+
+
+extern void GLAPIENTRY
+_mesa_NormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
+ const GLvoid *ptr);
+
+
+extern void GLAPIENTRY
+_mesa_ColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLsizei count,
+ const GLvoid *ptr);
+
+
+extern void GLAPIENTRY
+_mesa_IndexPointerEXT(GLenum type, GLsizei stride, GLsizei count,
+ const GLvoid *ptr);
+
+
+extern void GLAPIENTRY
+_mesa_TexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid *ptr);
+
+
+extern void GLAPIENTRY
+_mesa_EdgeFlagPointerEXT(GLsizei stride, GLsizei count, const GLboolean *ptr);
+
+
+extern void GLAPIENTRY
+_mesa_FogCoordPointerEXT(GLenum type, GLsizei stride, const GLvoid *ptr);
+
+
+extern void GLAPIENTRY
+_mesa_SecondaryColorPointerEXT(GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr);
+
+
+extern void GLAPIENTRY
+_mesa_VertexAttribPointerNV(GLuint index, GLint size, GLenum type,
+ GLsizei stride, const GLvoid *pointer);
+
+
+extern void GLAPIENTRY
+_mesa_VertexAttribPointerARB(GLuint index, GLint size, GLenum type,
+ GLboolean normalized, GLsizei stride,
+ const GLvoid *pointer);
+
+
+extern void GLAPIENTRY
+_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer);
+
+
+extern void GLAPIENTRY
+_mesa_MultiDrawArraysEXT( GLenum mode, GLint *first,
+ GLsizei *count, GLsizei primcount );
+
+extern void GLAPIENTRY
+_mesa_MultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type,
+ const GLvoid **indices, GLsizei primcount );
+
+
+extern void GLAPIENTRY
+_mesa_MultiModeDrawArraysIBM( const GLenum * mode, const GLint * first,
+ const GLsizei * count,
+ GLsizei primcount, GLint modestride );
+
+
+extern void GLAPIENTRY
+_mesa_MultiModeDrawElementsIBM( const GLenum * mode, const GLsizei * count,
+ GLenum type, const GLvoid * const * indices,
+ GLsizei primcount, GLint modestride );
+
+
+extern void
+_mesa_init_varray( GLcontext * ctx );
+
+#else
+
+/** No-op */
+#define _mesa_init_varray( c ) ((void)0)
+
+#endif
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/version.h b/nx-X11/extras/Mesa/src/mesa/main/version.h
new file mode 100644
index 000000000..af20a0d0a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/version.h
@@ -0,0 +1,52 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4.1
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef VERSION_H
+#define VERSION_H
+
+
+/* Mesa version */
+#define MESA_MAJOR 6
+#define MESA_MINOR 4
+#define MESA_PATCH 1
+#define MESA_VERSION_STRING "6.4.1"
+
+/* To make version comparison easy */
+#define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+#define MESA_VERSION_CODE MESA_VERSION(MESA_MAJOR, MESA_MINOR, MESA_PATCH)
+
+
+/* OpenGL API version */
+#define OPENGL_MAJOR 1
+#define OPENGL_MINOR 5
+#define OPENGL_PATCH 0
+#define OPENGL_VERSION_STRING "1.5"
+
+/* To make version comparison easy */
+#define OPENGL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
+#define OPENGL_VERSION_CODE OPENGL_VERSION(OPENGL_MAJOR, OPENGL_MINOR, OPENGL_PATCH)
+
+
+#endif /* VERSION_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/main/vsnprintf.c b/nx-X11/extras/Mesa/src/mesa/main/vsnprintf.c
new file mode 100644
index 000000000..ab6c740d7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/vsnprintf.c
@@ -0,0 +1,165 @@
+/*
+ * Revision 12: http://theos.com/~deraadt/snprintf.c
+ *
+ * Copyright (c) 1997 Theo de Raadt
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __VMS
+# include <sys/param.h>
+#endif
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <signal.h>
+#include <stdio.h>
+#if __STDC__
+#include <stdarg.h>
+#include <stdlib.h>
+#else
+#include <varargs.h>
+#endif
+#include <setjmp.h>
+#include <unistd.h>
+#include <string.h>
+
+#ifndef roundup
+#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
+#endif
+
+#ifdef __sgi
+#define size_t ssize_t
+#endif
+
+static int pgsize;
+static char *curobj;
+static int caught;
+static sigjmp_buf bail;
+
+#define EXTRABYTES 2 /* XXX: why 2? you don't want to know */
+
+static char *
+msetup(str, n)
+ char *str;
+ size_t n;
+{
+ char *e;
+
+ if (n == 0)
+ return NULL;
+ if (pgsize == 0)
+ pgsize = getpagesize();
+ curobj = (char *)malloc(n + EXTRABYTES + pgsize * 2);
+ if (curobj == NULL)
+ return NULL;
+ e = curobj + n + EXTRABYTES;
+ e = (char *)roundup((unsigned long)e, pgsize);
+ if (mprotect(e, pgsize, PROT_NONE) == -1) {
+ free(curobj);
+ curobj = NULL;
+ return NULL;
+ }
+ e = e - n - EXTRABYTES;
+ *e = '\0';
+ return (e);
+}
+
+static void
+ mcatch( int a )
+{
+ siglongjmp(bail, 1);
+}
+
+static void
+mcleanup(str, n, p)
+ char *str;
+ size_t n;
+ char *p;
+{
+ strncpy(str, p, n-1);
+ str[n-1] = '\0';
+ if (mprotect((caddr_t)(p + n + EXTRABYTES), pgsize,
+ PROT_READ|PROT_WRITE|PROT_EXEC) == -1)
+ mprotect((caddr_t)(p + n + EXTRABYTES), pgsize,
+ PROT_READ|PROT_WRITE);
+ free(curobj);
+}
+
+int
+#if __STDC__
+vsnprintf(char *str, size_t n, char const *fmt, va_list ap)
+#else
+vsnprintf(str, n, fmt, ap)
+ char *str;
+ size_t n;
+ char *fmt;
+ char *ap;
+#endif
+{
+ struct sigaction osa, nsa;
+ char *p;
+ int ret = n + 1; /* if we bail, indicated we overflowed */
+
+ memset(&nsa, 0, sizeof nsa);
+ nsa.sa_handler = mcatch;
+ sigemptyset(&nsa.sa_mask);
+
+ p = msetup(str, n);
+ if (p == NULL) {
+ *str = '\0';
+ return 0;
+ }
+ if (sigsetjmp(bail, 1) == 0) {
+ if (sigaction(SIGSEGV, &nsa, &osa) == -1) {
+ mcleanup(str, n, p);
+ return (0);
+ }
+ ret = vsprintf(p, fmt, ap);
+ }
+ mcleanup(str, n, p);
+ (void) sigaction(SIGSEGV, &osa, NULL);
+ return (ret);
+}
+
+int
+#if __STDC__
+snprintf(char *str, size_t n, char const *fmt, ...)
+#else
+snprintf(str, n, fmt, va_alist)
+ char *str;
+ size_t n;
+ char *fmt;
+ va_dcl
+#endif
+{
+ va_list ap;
+#if __STDC__
+ va_start(ap, fmt);
+#else
+ va_start(ap);
+#endif
+
+ return (vsnprintf(str, n, fmt, ap));
+ va_end(ap);
+}
+
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/main/vtxfmt.c b/nx-X11/extras/Mesa/src/mesa/main/vtxfmt.c
new file mode 100644
index 000000000..b3c639829
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/vtxfmt.c
@@ -0,0 +1,185 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Gareth Hughes
+ */
+
+#include "glheader.h"
+#include "api_loopback.h"
+#include "context.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "state.h"
+#include "vtxfmt.h"
+
+
+/* The neutral vertex format. This wraps all tnl module functions,
+ * verifying that the currently-installed module is valid and then
+ * installing the function pointers in a lazy fashion. It records the
+ * function pointers that have been swapped out, which allows a fast
+ * restoration of the neutral module in almost all cases -- a typical
+ * app might only require 4-6 functions to be modified from the neutral
+ * baseline, and only restoring these is certainly preferable to doing
+ * the entire module's 60 or so function pointers.
+ */
+
+#define PRE_LOOPBACK( FUNC ) \
+{ \
+ GET_CURRENT_CONTEXT(ctx); \
+ struct gl_tnl_module * const tnl = &(ctx->TnlModule); \
+ const int tmp_offset = _gloffset_ ## FUNC ; \
+ \
+ ASSERT( tnl->Current ); \
+ ASSERT( tnl->SwapCount < NUM_VERTEX_FORMAT_ENTRIES ); \
+ ASSERT( tmp_offset >= 0 ); \
+ \
+ /* Save the swapped function's dispatch entry so it can be */ \
+ /* restored later. */ \
+ tnl->Swapped[tnl->SwapCount].location = & (((_glapi_proc *)ctx->Exec)[tmp_offset]); \
+ tnl->Swapped[tnl->SwapCount].function = (_glapi_proc)TAG(FUNC); \
+ tnl->SwapCount++; \
+ \
+ if ( 0 ) \
+ _mesa_debug(ctx, " swapping gl" #FUNC"...\n" ); \
+ \
+ /* Install the tnl function pointer. */ \
+ SET_ ## FUNC(ctx->Exec, tnl->Current->FUNC); \
+}
+
+#define TAG(x) neutral_##x
+#include "vtxfmt_tmp.h"
+
+
+
+static void
+install_vtxfmt( struct _glapi_table *tab, const GLvertexformat *vfmt )
+{
+ SET_ArrayElement(tab, vfmt->ArrayElement);
+ SET_Color3f(tab, vfmt->Color3f);
+ SET_Color3fv(tab, vfmt->Color3fv);
+ SET_Color4f(tab, vfmt->Color4f);
+ SET_Color4fv(tab, vfmt->Color4fv);
+ SET_EdgeFlag(tab, vfmt->EdgeFlag);
+ SET_EdgeFlagv(tab, vfmt->EdgeFlagv);
+ SET_EvalCoord1f(tab, vfmt->EvalCoord1f);
+ SET_EvalCoord1fv(tab, vfmt->EvalCoord1fv);
+ SET_EvalCoord2f(tab, vfmt->EvalCoord2f);
+ SET_EvalCoord2fv(tab, vfmt->EvalCoord2fv);
+ SET_EvalPoint1(tab, vfmt->EvalPoint1);
+ SET_EvalPoint2(tab, vfmt->EvalPoint2);
+ SET_FogCoordfEXT(tab, vfmt->FogCoordfEXT);
+ SET_FogCoordfvEXT(tab, vfmt->FogCoordfvEXT);
+ SET_Indexf(tab, vfmt->Indexf);
+ SET_Indexfv(tab, vfmt->Indexfv);
+ SET_Materialfv(tab, vfmt->Materialfv);
+ SET_MultiTexCoord1fARB(tab, vfmt->MultiTexCoord1fARB);
+ SET_MultiTexCoord1fvARB(tab, vfmt->MultiTexCoord1fvARB);
+ SET_MultiTexCoord2fARB(tab, vfmt->MultiTexCoord2fARB);
+ SET_MultiTexCoord2fvARB(tab, vfmt->MultiTexCoord2fvARB);
+ SET_MultiTexCoord3fARB(tab, vfmt->MultiTexCoord3fARB);
+ SET_MultiTexCoord3fvARB(tab, vfmt->MultiTexCoord3fvARB);
+ SET_MultiTexCoord4fARB(tab, vfmt->MultiTexCoord4fARB);
+ SET_MultiTexCoord4fvARB(tab, vfmt->MultiTexCoord4fvARB);
+ SET_Normal3f(tab, vfmt->Normal3f);
+ SET_Normal3fv(tab, vfmt->Normal3fv);
+ SET_SecondaryColor3fEXT(tab, vfmt->SecondaryColor3fEXT);
+ SET_SecondaryColor3fvEXT(tab, vfmt->SecondaryColor3fvEXT);
+ SET_TexCoord1f(tab, vfmt->TexCoord1f);
+ SET_TexCoord1fv(tab, vfmt->TexCoord1fv);
+ SET_TexCoord2f(tab, vfmt->TexCoord2f);
+ SET_TexCoord2fv(tab, vfmt->TexCoord2fv);
+ SET_TexCoord3f(tab, vfmt->TexCoord3f);
+ SET_TexCoord3fv(tab, vfmt->TexCoord3fv);
+ SET_TexCoord4f(tab, vfmt->TexCoord4f);
+ SET_TexCoord4fv(tab, vfmt->TexCoord4fv);
+ SET_Vertex2f(tab, vfmt->Vertex2f);
+ SET_Vertex2fv(tab, vfmt->Vertex2fv);
+ SET_Vertex3f(tab, vfmt->Vertex3f);
+ SET_Vertex3fv(tab, vfmt->Vertex3fv);
+ SET_Vertex4f(tab, vfmt->Vertex4f);
+ SET_Vertex4fv(tab, vfmt->Vertex4fv);
+ SET_CallList(tab, vfmt->CallList);
+ SET_CallLists(tab, vfmt->CallLists);
+ SET_Begin(tab, vfmt->Begin);
+ SET_End(tab, vfmt->End);
+ SET_VertexAttrib1fNV(tab, vfmt->VertexAttrib1fNV);
+ SET_VertexAttrib1fvNV(tab, vfmt->VertexAttrib1fvNV);
+ SET_VertexAttrib2fNV(tab, vfmt->VertexAttrib2fNV);
+ SET_VertexAttrib2fvNV(tab, vfmt->VertexAttrib2fvNV);
+ SET_VertexAttrib3fNV(tab, vfmt->VertexAttrib3fNV);
+ SET_VertexAttrib3fvNV(tab, vfmt->VertexAttrib3fvNV);
+ SET_VertexAttrib4fNV(tab, vfmt->VertexAttrib4fNV);
+ SET_VertexAttrib4fvNV(tab, vfmt->VertexAttrib4fvNV);
+ SET_VertexAttrib1fARB(tab, vfmt->VertexAttrib1fARB);
+ SET_VertexAttrib1fvARB(tab, vfmt->VertexAttrib1fvARB);
+ SET_VertexAttrib2fARB(tab, vfmt->VertexAttrib2fARB);
+ SET_VertexAttrib2fvARB(tab, vfmt->VertexAttrib2fvARB);
+ SET_VertexAttrib3fARB(tab, vfmt->VertexAttrib3fARB);
+ SET_VertexAttrib3fvARB(tab, vfmt->VertexAttrib3fvARB);
+ SET_VertexAttrib4fARB(tab, vfmt->VertexAttrib4fARB);
+ SET_VertexAttrib4fvARB(tab, vfmt->VertexAttrib4fvARB);
+ SET_Rectf(tab, vfmt->Rectf);
+ SET_DrawArrays(tab, vfmt->DrawArrays);
+ SET_DrawElements(tab, vfmt->DrawElements);
+ SET_DrawRangeElements(tab, vfmt->DrawRangeElements);
+ SET_EvalMesh1(tab, vfmt->EvalMesh1);
+ SET_EvalMesh2(tab, vfmt->EvalMesh2);
+ ASSERT(tab->EvalMesh2);
+}
+
+
+void _mesa_init_exec_vtxfmt( GLcontext *ctx )
+{
+ install_vtxfmt( ctx->Exec, &neutral_vtxfmt );
+ ctx->TnlModule.SwapCount = 0;
+}
+
+
+void _mesa_install_exec_vtxfmt( GLcontext *ctx, const GLvertexformat *vfmt )
+{
+ ctx->TnlModule.Current = vfmt;
+ _mesa_restore_exec_vtxfmt( ctx );
+}
+
+
+void _mesa_install_save_vtxfmt( GLcontext *ctx, const GLvertexformat *vfmt )
+{
+ install_vtxfmt( ctx->Save, vfmt );
+}
+
+
+void _mesa_restore_exec_vtxfmt( GLcontext *ctx )
+{
+ struct gl_tnl_module *tnl = &(ctx->TnlModule);
+ GLuint i;
+
+ /* Restore the neutral tnl module wrapper.
+ */
+ for ( i = 0 ; i < tnl->SwapCount ; i++ ) {
+ *(tnl->Swapped[i].location) = tnl->Swapped[i].function;
+ }
+
+ tnl->SwapCount = 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/main/vtxfmt.h b/nx-X11/extras/Mesa/src/mesa/main/vtxfmt.h
new file mode 100644
index 000000000..76f108e02
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/vtxfmt.h
@@ -0,0 +1,43 @@
+/**
+ * \file vtxfmt.h
+ *
+ * \author Keith Whitwell <keith@tungstengraphics.com>
+ * \author Gareth Hughes
+ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef _VTXFMT_H_
+#define _VTXFMT_H_
+
+extern void _mesa_init_exec_vtxfmt( GLcontext *ctx );
+
+extern void _mesa_install_exec_vtxfmt( GLcontext *ctx, const GLvertexformat *vfmt );
+extern void _mesa_install_save_vtxfmt( GLcontext *ctx, const GLvertexformat *vfmt );
+
+extern void _mesa_restore_exec_vtxfmt( GLcontext *ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/main/vtxfmt_tmp.h b/nx-X11/extras/Mesa/src/mesa/main/vtxfmt_tmp.h
new file mode 100644
index 000000000..2a0fdde46
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/main/vtxfmt_tmp.h
@@ -0,0 +1,537 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ *
+ * Authors:
+ * Gareth Hughes
+ */
+
+#ifndef PRE_LOOPBACK
+#define PRE_LOOPBACK( FUNC )
+#endif
+
+#include "dispatch.h"
+#include "glapioffsets.h"
+
+static void GLAPIENTRY TAG(ArrayElement)( GLint i )
+{
+ PRE_LOOPBACK( ArrayElement );
+ CALL_ArrayElement(GET_DISPATCH(), ( i ));
+}
+
+static void GLAPIENTRY TAG(Color3f)( GLfloat r, GLfloat g, GLfloat b )
+{
+ PRE_LOOPBACK( Color3f );
+ CALL_Color3f(GET_DISPATCH(), ( r, g, b ));
+}
+
+static void GLAPIENTRY TAG(Color3fv)( const GLfloat *v )
+{
+ PRE_LOOPBACK( Color3fv );
+ CALL_Color3fv(GET_DISPATCH(), ( v ));
+}
+
+static void GLAPIENTRY TAG(Color4f)( GLfloat r, GLfloat g, GLfloat b, GLfloat a )
+{
+ PRE_LOOPBACK( Color4f );
+ CALL_Color4f(GET_DISPATCH(), ( r, g, b, a ));
+}
+
+static void GLAPIENTRY TAG(Color4fv)( const GLfloat *v )
+{
+ PRE_LOOPBACK( Color4fv );
+ CALL_Color4fv(GET_DISPATCH(), ( v ));
+}
+
+static void GLAPIENTRY TAG(EdgeFlag)( GLboolean e )
+{
+ PRE_LOOPBACK( EdgeFlag );
+ CALL_EdgeFlag(GET_DISPATCH(), ( e ));
+}
+
+static void GLAPIENTRY TAG(EdgeFlagv)( const GLboolean *v )
+{
+ PRE_LOOPBACK( EdgeFlagv );
+ CALL_EdgeFlagv(GET_DISPATCH(), ( v ));
+}
+
+static void GLAPIENTRY TAG(EvalCoord1f)( GLfloat s )
+{
+ PRE_LOOPBACK( EvalCoord1f );
+ CALL_EvalCoord1f(GET_DISPATCH(), ( s ));
+}
+
+static void GLAPIENTRY TAG(EvalCoord1fv)( const GLfloat *v )
+{
+ PRE_LOOPBACK( EvalCoord1fv );
+ CALL_EvalCoord1fv(GET_DISPATCH(), ( v ));
+}
+
+static void GLAPIENTRY TAG(EvalCoord2f)( GLfloat s, GLfloat t )
+{
+ PRE_LOOPBACK( EvalCoord2f );
+ CALL_EvalCoord2f(GET_DISPATCH(), ( s, t ));
+}
+
+static void GLAPIENTRY TAG(EvalCoord2fv)( const GLfloat *v )
+{
+ PRE_LOOPBACK( EvalCoord2fv );
+ CALL_EvalCoord2fv(GET_DISPATCH(), ( v ));
+}
+
+static void GLAPIENTRY TAG(EvalPoint1)( GLint i )
+{
+ PRE_LOOPBACK( EvalPoint1 );
+ CALL_EvalPoint1(GET_DISPATCH(), ( i ));
+}
+
+static void GLAPIENTRY TAG(EvalPoint2)( GLint i, GLint j )
+{
+ PRE_LOOPBACK( EvalPoint2 );
+ CALL_EvalPoint2(GET_DISPATCH(), ( i, j ));
+}
+
+static void GLAPIENTRY TAG(FogCoordfEXT)( GLfloat f )
+{
+ PRE_LOOPBACK( FogCoordfEXT );
+ CALL_FogCoordfEXT(GET_DISPATCH(), ( f ));
+}
+
+static void GLAPIENTRY TAG(FogCoordfvEXT)( const GLfloat *v )
+{
+ PRE_LOOPBACK( FogCoordfvEXT );
+ CALL_FogCoordfvEXT(GET_DISPATCH(), ( v ));
+}
+
+static void GLAPIENTRY TAG(Indexf)( GLfloat f )
+{
+ PRE_LOOPBACK( Indexf );
+ CALL_Indexf(GET_DISPATCH(), ( f ));
+}
+
+static void GLAPIENTRY TAG(Indexfv)( const GLfloat *v )
+{
+ PRE_LOOPBACK( Indexfv );
+ CALL_Indexfv(GET_DISPATCH(), ( v ));
+}
+
+static void GLAPIENTRY TAG(Materialfv)( GLenum face, GLenum pname, const GLfloat *v )
+{
+ PRE_LOOPBACK( Materialfv );
+ CALL_Materialfv(GET_DISPATCH(), ( face, pname, v ));
+}
+
+static void GLAPIENTRY TAG(MultiTexCoord1fARB)( GLenum target, GLfloat a )
+{
+ PRE_LOOPBACK( MultiTexCoord1fARB );
+ CALL_MultiTexCoord1fARB(GET_DISPATCH(), ( target, a ));
+}
+
+static void GLAPIENTRY TAG(MultiTexCoord1fvARB)( GLenum target, const GLfloat *tc )
+{
+ PRE_LOOPBACK( MultiTexCoord1fvARB );
+ CALL_MultiTexCoord1fvARB(GET_DISPATCH(), ( target, tc ));
+}
+
+static void GLAPIENTRY TAG(MultiTexCoord2fARB)( GLenum target, GLfloat s, GLfloat t )
+{
+ PRE_LOOPBACK( MultiTexCoord2fARB );
+ CALL_MultiTexCoord2fARB(GET_DISPATCH(), ( target, s, t ));
+}
+
+static void GLAPIENTRY TAG(MultiTexCoord2fvARB)( GLenum target, const GLfloat *tc )
+{
+ PRE_LOOPBACK( MultiTexCoord2fvARB );
+ CALL_MultiTexCoord2fvARB(GET_DISPATCH(), ( target, tc ));
+}
+
+static void GLAPIENTRY TAG(MultiTexCoord3fARB)( GLenum target, GLfloat s,
+ GLfloat t, GLfloat r )
+{
+ PRE_LOOPBACK( MultiTexCoord3fARB );
+ CALL_MultiTexCoord3fARB(GET_DISPATCH(), ( target, s, t, r ));
+}
+
+static void GLAPIENTRY TAG(MultiTexCoord3fvARB)( GLenum target, const GLfloat *tc )
+{
+ PRE_LOOPBACK( MultiTexCoord3fvARB );
+ CALL_MultiTexCoord3fvARB(GET_DISPATCH(), ( target, tc ));
+}
+
+static void GLAPIENTRY TAG(MultiTexCoord4fARB)( GLenum target, GLfloat s,
+ GLfloat t, GLfloat r, GLfloat q )
+{
+ PRE_LOOPBACK( MultiTexCoord4fARB );
+ CALL_MultiTexCoord4fARB(GET_DISPATCH(), ( target, s, t, r, q ));
+}
+
+static void GLAPIENTRY TAG(MultiTexCoord4fvARB)( GLenum target, const GLfloat *tc )
+{
+ PRE_LOOPBACK( MultiTexCoord4fvARB );
+ CALL_MultiTexCoord4fvARB(GET_DISPATCH(), ( target, tc ));
+}
+
+static void GLAPIENTRY TAG(Normal3f)( GLfloat x, GLfloat y, GLfloat z )
+{
+ PRE_LOOPBACK( Normal3f );
+ CALL_Normal3f(GET_DISPATCH(), ( x, y, z ));
+}
+
+static void GLAPIENTRY TAG(Normal3fv)( const GLfloat *v )
+{
+ PRE_LOOPBACK( Normal3fv );
+ CALL_Normal3fv(GET_DISPATCH(), ( v ));
+}
+
+static void GLAPIENTRY TAG(SecondaryColor3fEXT)( GLfloat r, GLfloat g, GLfloat b )
+{
+ PRE_LOOPBACK( SecondaryColor3fEXT );
+ CALL_SecondaryColor3fEXT(GET_DISPATCH(), ( r, g, b ));
+}
+
+static void GLAPIENTRY TAG(SecondaryColor3fvEXT)( const GLfloat *v )
+{
+ PRE_LOOPBACK( SecondaryColor3fvEXT );
+ CALL_SecondaryColor3fvEXT(GET_DISPATCH(), ( v ));
+}
+
+static void GLAPIENTRY TAG(TexCoord1f)( GLfloat s )
+{
+ PRE_LOOPBACK( TexCoord1f );
+ CALL_TexCoord1f(GET_DISPATCH(), ( s ));
+}
+
+static void GLAPIENTRY TAG(TexCoord1fv)( const GLfloat *tc )
+{
+ PRE_LOOPBACK( TexCoord1fv );
+ CALL_TexCoord1fv(GET_DISPATCH(), ( tc ));
+}
+
+static void GLAPIENTRY TAG(TexCoord2f)( GLfloat s, GLfloat t )
+{
+ PRE_LOOPBACK( TexCoord2f );
+ CALL_TexCoord2f(GET_DISPATCH(), ( s, t ));
+}
+
+static void GLAPIENTRY TAG(TexCoord2fv)( const GLfloat *tc )
+{
+ PRE_LOOPBACK( TexCoord2fv );
+ CALL_TexCoord2fv(GET_DISPATCH(), ( tc ));
+}
+
+static void GLAPIENTRY TAG(TexCoord3f)( GLfloat s, GLfloat t, GLfloat r )
+{
+ PRE_LOOPBACK( TexCoord3f );
+ CALL_TexCoord3f(GET_DISPATCH(), ( s, t, r ));
+}
+
+static void GLAPIENTRY TAG(TexCoord3fv)( const GLfloat *tc )
+{
+ PRE_LOOPBACK( TexCoord3fv );
+ CALL_TexCoord3fv(GET_DISPATCH(), ( tc ));
+}
+
+static void GLAPIENTRY TAG(TexCoord4f)( GLfloat s, GLfloat t, GLfloat r, GLfloat q )
+{
+ PRE_LOOPBACK( TexCoord4f );
+ CALL_TexCoord4f(GET_DISPATCH(), ( s, t, r, q ));
+}
+
+static void GLAPIENTRY TAG(TexCoord4fv)( const GLfloat *tc )
+{
+ PRE_LOOPBACK( TexCoord4fv );
+ CALL_TexCoord4fv(GET_DISPATCH(), ( tc ));
+}
+
+static void GLAPIENTRY TAG(Vertex2f)( GLfloat x, GLfloat y )
+{
+ PRE_LOOPBACK( Vertex2f );
+ CALL_Vertex2f(GET_DISPATCH(), ( x, y ));
+}
+
+static void GLAPIENTRY TAG(Vertex2fv)( const GLfloat *v )
+{
+ PRE_LOOPBACK( Vertex2fv );
+ CALL_Vertex2fv(GET_DISPATCH(), ( v ));
+}
+
+static void GLAPIENTRY TAG(Vertex3f)( GLfloat x, GLfloat y, GLfloat z )
+{
+ PRE_LOOPBACK( Vertex3f );
+ CALL_Vertex3f(GET_DISPATCH(), ( x, y, z ));
+}
+
+static void GLAPIENTRY TAG(Vertex3fv)( const GLfloat *v )
+{
+ PRE_LOOPBACK( Vertex3fv );
+ CALL_Vertex3fv(GET_DISPATCH(), ( v ));
+}
+
+static void GLAPIENTRY TAG(Vertex4f)( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+ PRE_LOOPBACK( Vertex4f );
+ CALL_Vertex4f(GET_DISPATCH(), ( x, y, z, w ));
+}
+
+static void GLAPIENTRY TAG(Vertex4fv)( const GLfloat *v )
+{
+ PRE_LOOPBACK( Vertex4fv );
+ CALL_Vertex4fv(GET_DISPATCH(), ( v ));
+}
+
+static void GLAPIENTRY TAG(CallList)( GLuint i )
+{
+ PRE_LOOPBACK( CallList );
+ CALL_CallList(GET_DISPATCH(), ( i ));
+}
+
+static void GLAPIENTRY TAG(CallLists)( GLsizei sz, GLenum type, const GLvoid *v )
+{
+ PRE_LOOPBACK( CallLists );
+ CALL_CallLists(GET_DISPATCH(), ( sz, type, v ));
+}
+
+static void GLAPIENTRY TAG(Begin)( GLenum mode )
+{
+ PRE_LOOPBACK( Begin );
+ CALL_Begin(GET_DISPATCH(), ( mode ));
+}
+
+static void GLAPIENTRY TAG(End)( void )
+{
+ PRE_LOOPBACK( End );
+ CALL_End(GET_DISPATCH(), ());
+}
+
+static void GLAPIENTRY TAG(Rectf)( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
+{
+ PRE_LOOPBACK( Rectf );
+ CALL_Rectf(GET_DISPATCH(), ( x1, y1, x2, y2 ));
+}
+
+static void GLAPIENTRY TAG(DrawArrays)( GLenum mode, GLint start, GLsizei count )
+{
+ PRE_LOOPBACK( DrawArrays );
+ CALL_DrawArrays(GET_DISPATCH(), ( mode, start, count ));
+}
+
+static void GLAPIENTRY TAG(DrawElements)( GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices )
+{
+ PRE_LOOPBACK( DrawElements );
+ CALL_DrawElements(GET_DISPATCH(), ( mode, count, type, indices ));
+}
+
+static void GLAPIENTRY TAG(DrawRangeElements)( GLenum mode, GLuint start,
+ GLuint end, GLsizei count,
+ GLenum type, const GLvoid *indices )
+{
+ PRE_LOOPBACK( DrawRangeElements );
+ CALL_DrawRangeElements(GET_DISPATCH(), ( mode, start, end, count, type, indices ));
+}
+
+static void GLAPIENTRY TAG(EvalMesh1)( GLenum mode, GLint i1, GLint i2 )
+{
+ PRE_LOOPBACK( EvalMesh1 );
+ CALL_EvalMesh1(GET_DISPATCH(), ( mode, i1, i2 ));
+}
+
+static void GLAPIENTRY TAG(EvalMesh2)( GLenum mode, GLint i1, GLint i2,
+ GLint j1, GLint j2 )
+{
+ PRE_LOOPBACK( EvalMesh2 );
+ CALL_EvalMesh2(GET_DISPATCH(), ( mode, i1, i2, j1, j2 ));
+}
+
+static void GLAPIENTRY TAG(VertexAttrib1fNV)( GLuint index, GLfloat x )
+{
+ PRE_LOOPBACK( VertexAttrib1fNV );
+ CALL_VertexAttrib1fNV(GET_DISPATCH(), ( index, x ));
+}
+
+static void GLAPIENTRY TAG(VertexAttrib1fvNV)( GLuint index, const GLfloat *v )
+{
+ PRE_LOOPBACK( VertexAttrib1fvNV );
+ CALL_VertexAttrib1fvNV(GET_DISPATCH(), ( index, v ));
+}
+
+static void GLAPIENTRY TAG(VertexAttrib2fNV)( GLuint index, GLfloat x, GLfloat y )
+{
+ PRE_LOOPBACK( VertexAttrib2fNV );
+ CALL_VertexAttrib2fNV(GET_DISPATCH(), ( index, x, y ));
+}
+
+static void GLAPIENTRY TAG(VertexAttrib2fvNV)( GLuint index, const GLfloat *v )
+{
+ PRE_LOOPBACK( VertexAttrib2fvNV );
+ CALL_VertexAttrib2fvNV(GET_DISPATCH(), ( index, v ));
+}
+
+static void GLAPIENTRY TAG(VertexAttrib3fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z )
+{
+ PRE_LOOPBACK( VertexAttrib3fNV );
+ CALL_VertexAttrib3fNV(GET_DISPATCH(), ( index, x, y, z ));
+}
+
+static void GLAPIENTRY TAG(VertexAttrib3fvNV)( GLuint index, const GLfloat *v )
+{
+ PRE_LOOPBACK( VertexAttrib3fvNV );
+ CALL_VertexAttrib3fvNV(GET_DISPATCH(), ( index, v ));
+}
+
+static void GLAPIENTRY TAG(VertexAttrib4fNV)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+ PRE_LOOPBACK( VertexAttrib4fNV );
+ CALL_VertexAttrib4fNV(GET_DISPATCH(), ( index, x, y, z, w ));
+}
+
+static void GLAPIENTRY TAG(VertexAttrib4fvNV)( GLuint index, const GLfloat *v )
+{
+ PRE_LOOPBACK( VertexAttrib4fvNV );
+ CALL_VertexAttrib4fvNV(GET_DISPATCH(), ( index, v ));
+}
+
+
+static void GLAPIENTRY TAG(VertexAttrib1fARB)( GLuint index, GLfloat x )
+{
+ PRE_LOOPBACK( VertexAttrib1fARB );
+ CALL_VertexAttrib1fARB(GET_DISPATCH(), ( index, x ));
+}
+
+static void GLAPIENTRY TAG(VertexAttrib1fvARB)( GLuint index, const GLfloat *v )
+{
+ PRE_LOOPBACK( VertexAttrib1fvARB );
+ CALL_VertexAttrib1fvARB(GET_DISPATCH(), ( index, v ));
+}
+
+static void GLAPIENTRY TAG(VertexAttrib2fARB)( GLuint index, GLfloat x, GLfloat y )
+{
+ PRE_LOOPBACK( VertexAttrib2fARB );
+ CALL_VertexAttrib2fARB(GET_DISPATCH(), ( index, x, y ));
+}
+
+static void GLAPIENTRY TAG(VertexAttrib2fvARB)( GLuint index, const GLfloat *v )
+{
+ PRE_LOOPBACK( VertexAttrib2fvARB );
+ CALL_VertexAttrib2fvARB(GET_DISPATCH(), ( index, v ));
+}
+
+static void GLAPIENTRY TAG(VertexAttrib3fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z )
+{
+ PRE_LOOPBACK( VertexAttrib3fARB );
+ CALL_VertexAttrib3fARB(GET_DISPATCH(), ( index, x, y, z ));
+}
+
+static void GLAPIENTRY TAG(VertexAttrib3fvARB)( GLuint index, const GLfloat *v )
+{
+ PRE_LOOPBACK( VertexAttrib3fvARB );
+ CALL_VertexAttrib3fvARB(GET_DISPATCH(), ( index, v ));
+}
+
+static void GLAPIENTRY TAG(VertexAttrib4fARB)( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+ PRE_LOOPBACK( VertexAttrib4fARB );
+ CALL_VertexAttrib4fARB(GET_DISPATCH(), ( index, x, y, z, w ));
+}
+
+static void GLAPIENTRY TAG(VertexAttrib4fvARB)( GLuint index, const GLfloat *v )
+{
+ PRE_LOOPBACK( VertexAttrib4fvARB );
+ CALL_VertexAttrib4fvARB(GET_DISPATCH(), ( index, v ));
+}
+
+
+static GLvertexformat TAG(vtxfmt) = {
+ TAG(ArrayElement),
+ TAG(Color3f),
+ TAG(Color3fv),
+ TAG(Color4f),
+ TAG(Color4fv),
+ TAG(EdgeFlag),
+ TAG(EdgeFlagv),
+ TAG(EvalCoord1f),
+ TAG(EvalCoord1fv),
+ TAG(EvalCoord2f),
+ TAG(EvalCoord2fv),
+ TAG(EvalPoint1),
+ TAG(EvalPoint2),
+ TAG(FogCoordfEXT),
+ TAG(FogCoordfvEXT),
+ TAG(Indexf),
+ TAG(Indexfv),
+ TAG(Materialfv),
+ TAG(MultiTexCoord1fARB),
+ TAG(MultiTexCoord1fvARB),
+ TAG(MultiTexCoord2fARB),
+ TAG(MultiTexCoord2fvARB),
+ TAG(MultiTexCoord3fARB),
+ TAG(MultiTexCoord3fvARB),
+ TAG(MultiTexCoord4fARB),
+ TAG(MultiTexCoord4fvARB),
+ TAG(Normal3f),
+ TAG(Normal3fv),
+ TAG(SecondaryColor3fEXT),
+ TAG(SecondaryColor3fvEXT),
+ TAG(TexCoord1f),
+ TAG(TexCoord1fv),
+ TAG(TexCoord2f),
+ TAG(TexCoord2fv),
+ TAG(TexCoord3f),
+ TAG(TexCoord3fv),
+ TAG(TexCoord4f),
+ TAG(TexCoord4fv),
+ TAG(Vertex2f),
+ TAG(Vertex2fv),
+ TAG(Vertex3f),
+ TAG(Vertex3fv),
+ TAG(Vertex4f),
+ TAG(Vertex4fv),
+ TAG(CallList),
+ TAG(CallLists),
+ TAG(Begin),
+ TAG(End),
+ TAG(VertexAttrib1fNV),
+ TAG(VertexAttrib1fvNV),
+ TAG(VertexAttrib2fNV),
+ TAG(VertexAttrib2fvNV),
+ TAG(VertexAttrib3fNV),
+ TAG(VertexAttrib3fvNV),
+ TAG(VertexAttrib4fNV),
+ TAG(VertexAttrib4fvNV),
+ TAG(VertexAttrib1fARB),
+ TAG(VertexAttrib1fvARB),
+ TAG(VertexAttrib2fARB),
+ TAG(VertexAttrib2fvARB),
+ TAG(VertexAttrib3fARB),
+ TAG(VertexAttrib3fvARB),
+ TAG(VertexAttrib4fARB),
+ TAG(VertexAttrib4fvARB),
+ TAG(Rectf),
+ TAG(DrawArrays),
+ TAG(DrawElements),
+ TAG(DrawRangeElements),
+ TAG(EvalMesh1),
+ TAG(EvalMesh2)
+};
+
+#undef TAG
+#undef PRE_LOOPBACK
diff --git a/nx-X11/extras/Mesa/src/mesa/math/descrip.mms b/nx-X11/extras/Mesa/src/mesa/math/descrip.mms
new file mode 100644
index 000000000..86eaf0e46
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/descrip.mms
@@ -0,0 +1,45 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+# Last revision : 16 June 2003
+
+.first
+ define gl [---.include.gl]
+ define math [-.math]
+
+.include [---]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [---.include],[-.main],[-.glapi]
+LIBDIR = [---.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)
+
+SOURCES = m_debug_clip.c m_debug_norm.c m_debug_xform.c m_eval.c m_matrix.c\
+ m_translate.c m_vector.c m_xform.c
+
+OBJECTS = m_debug_clip.obj,m_debug_norm.obj,m_debug_xform.obj,m_eval.obj,\
+ m_matrix.obj,m_translate.obj,m_vector.obj,m_xform.obj
+
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+ @ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
+
+clean :
+ purge
+ delete *.obj;*
+
+m_debug_clip.obj : m_debug_clip.c
+m_debug_norm.obj : m_debug_norm.c
+m_debug_xform.obj : m_debug_xform.c
+m_eval.obj : m_eval.c
+m_matrix.obj : m_matrix.c
+m_translate.obj : m_translate.c
+m_vector.obj : m_vector.c
+m_xform.obj : m_xform.c
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_clip_tmp.h b/nx-X11/extras/Mesa/src/mesa/math/m_clip_tmp.h
new file mode 100644
index 000000000..f3a589be0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_clip_tmp.h
@@ -0,0 +1,243 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.2
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+/*
+ * New (3.1) transformation code written by Keith Whitwell.
+ */
+
+
+/* KW: a clever asm implementation would nestle integer versions
+ * of the outcode calculation underneath the division. Gcc won't
+ * do this, strangely enough, so I only do the divide in
+ * the case where the cliptest passes. This isn't essential,
+ * and an asm implementation needn't replicate that behaviour.
+ *
+ * \param clip_vec vector of incoming clip-space coords
+ * \param proj_vec vector of resultant NDC-space projected coords
+ * \param clipMask resulting array of clip flags
+ * \param orMask bitwise-OR of clipMask values
+ * \param andMask bitwise-AND of clipMask values
+ * \return proj_vec pointer
+ */
+static GLvector4f * _XFORMAPI TAG(cliptest_points4)( GLvector4f *clip_vec,
+ GLvector4f *proj_vec,
+ GLubyte clipMask[],
+ GLubyte *orMask,
+ GLubyte *andMask )
+{
+ const GLuint stride = clip_vec->stride;
+ const GLfloat *from = (GLfloat *)clip_vec->start;
+ const GLuint count = clip_vec->count;
+ GLuint c = 0;
+ GLfloat (*vProj)[4] = (GLfloat (*)[4])proj_vec->start;
+ GLubyte tmpAndMask = *andMask;
+ GLubyte tmpOrMask = *orMask;
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat cx = from[0];
+ const GLfloat cy = from[1];
+ const GLfloat cz = from[2];
+ const GLfloat cw = from[3];
+#if defined(macintosh) || defined(__powerpc__)
+ /* on powerpc cliptest is 17% faster in this way. */
+ GLuint mask;
+ mask = (((cw < cx) << CLIP_RIGHT_SHIFT));
+ mask |= (((cw < -cx) << CLIP_LEFT_SHIFT));
+ mask |= (((cw < cy) << CLIP_TOP_SHIFT));
+ mask |= (((cw < -cy) << CLIP_BOTTOM_SHIFT));
+ mask |= (((cw < cz) << CLIP_FAR_SHIFT));
+ mask |= (((cw < -cz) << CLIP_NEAR_SHIFT));
+#else /* !defined(macintosh)) */
+ GLubyte mask = 0;
+ if (-cx + cw < 0) mask |= CLIP_RIGHT_BIT;
+ if ( cx + cw < 0) mask |= CLIP_LEFT_BIT;
+ if (-cy + cw < 0) mask |= CLIP_TOP_BIT;
+ if ( cy + cw < 0) mask |= CLIP_BOTTOM_BIT;
+ if (-cz + cw < 0) mask |= CLIP_FAR_BIT;
+ if ( cz + cw < 0) mask |= CLIP_NEAR_BIT;
+#endif /* defined(macintosh) */
+
+ clipMask[i] = mask;
+ if (mask) {
+ c++;
+ tmpAndMask &= mask;
+ tmpOrMask |= mask;
+ vProj[i][0] = 0;
+ vProj[i][1] = 0;
+ vProj[i][2] = 0;
+ vProj[i][3] = 1;
+ } else {
+ GLfloat oow = 1.0F / cw;
+ vProj[i][0] = cx * oow;
+ vProj[i][1] = cy * oow;
+ vProj[i][2] = cz * oow;
+ vProj[i][3] = oow;
+ }
+ }
+
+ *orMask = tmpOrMask;
+ *andMask = (GLubyte) (c < count ? 0 : tmpAndMask);
+
+ proj_vec->flags |= VEC_SIZE_4;
+ proj_vec->size = 4;
+ proj_vec->count = clip_vec->count;
+ return proj_vec;
+}
+
+
+
+/*
+ * \param clip_vec vector of incoming clip-space coords
+ * \param proj_vec vector of resultant NDC-space projected coords
+ * \param clipMask resulting array of clip flags
+ * \param orMask bitwise-OR of clipMask values
+ * \param andMask bitwise-AND of clipMask values
+ * \return clip_vec pointer
+ */
+static GLvector4f * _XFORMAPI TAG(cliptest_np_points4)( GLvector4f *clip_vec,
+ GLvector4f *proj_vec,
+ GLubyte clipMask[],
+ GLubyte *orMask,
+ GLubyte *andMask )
+{
+ const GLuint stride = clip_vec->stride;
+ const GLuint count = clip_vec->count;
+ const GLfloat *from = (GLfloat *)clip_vec->start;
+ GLuint c = 0;
+ GLubyte tmpAndMask = *andMask;
+ GLubyte tmpOrMask = *orMask;
+ GLuint i;
+ (void) proj_vec;
+ STRIDE_LOOP {
+ const GLfloat cx = from[0];
+ const GLfloat cy = from[1];
+ const GLfloat cz = from[2];
+ const GLfloat cw = from[3];
+#if defined(macintosh) || defined(__powerpc__)
+ /* on powerpc cliptest is 17% faster in this way. */
+ GLuint mask;
+ mask = (((cw < cx) << CLIP_RIGHT_SHIFT));
+ mask |= (((cw < -cx) << CLIP_LEFT_SHIFT));
+ mask |= (((cw < cy) << CLIP_TOP_SHIFT));
+ mask |= (((cw < -cy) << CLIP_BOTTOM_SHIFT));
+ mask |= (((cw < cz) << CLIP_FAR_SHIFT));
+ mask |= (((cw < -cz) << CLIP_NEAR_SHIFT));
+#else /* !defined(macintosh)) */
+ GLubyte mask = 0;
+ if (-cx + cw < 0) mask |= CLIP_RIGHT_BIT;
+ if ( cx + cw < 0) mask |= CLIP_LEFT_BIT;
+ if (-cy + cw < 0) mask |= CLIP_TOP_BIT;
+ if ( cy + cw < 0) mask |= CLIP_BOTTOM_BIT;
+ if (-cz + cw < 0) mask |= CLIP_FAR_BIT;
+ if ( cz + cw < 0) mask |= CLIP_NEAR_BIT;
+#endif /* defined(macintosh) */
+
+ clipMask[i] = mask;
+ if (mask) {
+ c++;
+ tmpAndMask &= mask;
+ tmpOrMask |= mask;
+ }
+ }
+
+ *orMask = tmpOrMask;
+ *andMask = (GLubyte) (c < count ? 0 : tmpAndMask);
+ return clip_vec;
+}
+
+
+static GLvector4f * _XFORMAPI TAG(cliptest_points3)( GLvector4f *clip_vec,
+ GLvector4f *proj_vec,
+ GLubyte clipMask[],
+ GLubyte *orMask,
+ GLubyte *andMask )
+{
+ const GLuint stride = clip_vec->stride;
+ const GLuint count = clip_vec->count;
+ const GLfloat *from = (GLfloat *)clip_vec->start;
+ GLubyte tmpOrMask = *orMask;
+ GLubyte tmpAndMask = *andMask;
+ GLuint i;
+ (void) proj_vec;
+ STRIDE_LOOP {
+ const GLfloat cx = from[0], cy = from[1], cz = from[2];
+ GLubyte mask = 0;
+ if (cx > 1.0) mask |= CLIP_RIGHT_BIT;
+ else if (cx < -1.0) mask |= CLIP_LEFT_BIT;
+ if (cy > 1.0) mask |= CLIP_TOP_BIT;
+ else if (cy < -1.0) mask |= CLIP_BOTTOM_BIT;
+ if (cz > 1.0) mask |= CLIP_FAR_BIT;
+ else if (cz < -1.0) mask |= CLIP_NEAR_BIT;
+ clipMask[i] = mask;
+ tmpOrMask |= mask;
+ tmpAndMask &= mask;
+ }
+
+ *orMask = tmpOrMask;
+ *andMask = tmpAndMask;
+ return clip_vec;
+}
+
+
+static GLvector4f * _XFORMAPI TAG(cliptest_points2)( GLvector4f *clip_vec,
+ GLvector4f *proj_vec,
+ GLubyte clipMask[],
+ GLubyte *orMask,
+ GLubyte *andMask )
+{
+ const GLuint stride = clip_vec->stride;
+ const GLuint count = clip_vec->count;
+ const GLfloat *from = (GLfloat *)clip_vec->start;
+ GLubyte tmpOrMask = *orMask;
+ GLubyte tmpAndMask = *andMask;
+ GLuint i;
+ (void) proj_vec;
+ STRIDE_LOOP {
+ const GLfloat cx = from[0], cy = from[1];
+ GLubyte mask = 0;
+ if (cx > 1.0) mask |= CLIP_RIGHT_BIT;
+ else if (cx < -1.0) mask |= CLIP_LEFT_BIT;
+ if (cy > 1.0) mask |= CLIP_TOP_BIT;
+ else if (cy < -1.0) mask |= CLIP_BOTTOM_BIT;
+ clipMask[i] = mask;
+ tmpOrMask |= mask;
+ tmpAndMask &= mask;
+ }
+
+ *orMask = tmpOrMask;
+ *andMask = tmpAndMask;
+ return clip_vec;
+}
+
+
+static void TAG(init_c_cliptest)( void )
+{
+ _mesa_clip_tab[4] = TAG(cliptest_points4);
+ _mesa_clip_tab[3] = TAG(cliptest_points3);
+ _mesa_clip_tab[2] = TAG(cliptest_points2);
+
+ _mesa_clip_np_tab[4] = TAG(cliptest_np_points4);
+ _mesa_clip_np_tab[3] = TAG(cliptest_points3);
+ _mesa_clip_np_tab[2] = TAG(cliptest_points2);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_copy_tmp.h b/nx-X11/extras/Mesa/src/mesa/math/m_copy_tmp.h
new file mode 100644
index 000000000..07ab1f7b2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_copy_tmp.h
@@ -0,0 +1,86 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * New (3.1) transformation code written by Keith Whitwell.
+ */
+
+
+#define COPY_FUNC( BITS ) \
+static void TAG2(copy, BITS)( GLvector4f *to, const GLvector4f *f ) \
+{ \
+ GLfloat (*t)[4] = (GLfloat (*)[4])to->start; \
+ GLfloat *from = f->start; \
+ GLuint stride = f->stride; \
+ GLuint count = to->count; \
+ GLuint i; \
+ \
+ if (BITS) \
+ STRIDE_LOOP { \
+ if (BITS&1) t[i][0] = from[0]; \
+ if (BITS&2) t[i][1] = from[1]; \
+ if (BITS&4) t[i][2] = from[2]; \
+ if (BITS&8) t[i][3] = from[3]; \
+ } \
+}
+
+/* We got them all here:
+ */
+COPY_FUNC( 0x0 ) /* noop */
+COPY_FUNC( 0x1 )
+COPY_FUNC( 0x2 )
+COPY_FUNC( 0x3 )
+COPY_FUNC( 0x4 )
+COPY_FUNC( 0x5 )
+COPY_FUNC( 0x6 )
+COPY_FUNC( 0x7 )
+COPY_FUNC( 0x8 )
+COPY_FUNC( 0x9 )
+COPY_FUNC( 0xa )
+COPY_FUNC( 0xb )
+COPY_FUNC( 0xc )
+COPY_FUNC( 0xd )
+COPY_FUNC( 0xe )
+COPY_FUNC( 0xf )
+
+static void TAG2(init_copy, 0)( void )
+{
+ _mesa_copy_tab[0x0] = TAG2(copy, 0x0);
+ _mesa_copy_tab[0x1] = TAG2(copy, 0x1);
+ _mesa_copy_tab[0x2] = TAG2(copy, 0x2);
+ _mesa_copy_tab[0x3] = TAG2(copy, 0x3);
+ _mesa_copy_tab[0x4] = TAG2(copy, 0x4);
+ _mesa_copy_tab[0x5] = TAG2(copy, 0x5);
+ _mesa_copy_tab[0x6] = TAG2(copy, 0x6);
+ _mesa_copy_tab[0x7] = TAG2(copy, 0x7);
+ _mesa_copy_tab[0x8] = TAG2(copy, 0x8);
+ _mesa_copy_tab[0x9] = TAG2(copy, 0x9);
+ _mesa_copy_tab[0xa] = TAG2(copy, 0xa);
+ _mesa_copy_tab[0xb] = TAG2(copy, 0xb);
+ _mesa_copy_tab[0xc] = TAG2(copy, 0xc);
+ _mesa_copy_tab[0xd] = TAG2(copy, 0xd);
+ _mesa_copy_tab[0xe] = TAG2(copy, 0xe);
+ _mesa_copy_tab[0xf] = TAG2(copy, 0xf);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_debug.h b/nx-X11/extras/Mesa/src/mesa/math/m_debug.h
new file mode 100644
index 000000000..6476b6de2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_debug.h
@@ -0,0 +1,42 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Gareth Hughes
+ */
+
+#ifndef __M_DEBUG_H__
+#define __M_DEBUG_H__
+
+extern void _math_test_all_transform_functions( char *description );
+extern void _math_test_all_normal_transform_functions( char *description );
+extern void _math_test_all_cliptest_functions( char *description );
+
+/* Deprecated?
+ */
+extern void _math_test_all_vertex_functions( char *description );
+
+extern char *mesa_profile;
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_debug_clip.c b/nx-X11/extras/Mesa/src/mesa/math/m_debug_clip.c
new file mode 100644
index 000000000..ae8108b88
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_debug_clip.c
@@ -0,0 +1,371 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Gareth Hughes
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+
+#include "m_matrix.h"
+#include "m_xform.h"
+
+#include "m_debug.h"
+#include "m_debug_util.h"
+
+#ifdef __UNIXOS2__
+/* The linker doesn't like empty files */
+static char dummy;
+#endif
+
+#ifdef DEBUG /* This code only used for debugging */
+
+static clip_func *clip_tab[2] = {
+ _mesa_clip_tab,
+ _mesa_clip_np_tab
+};
+static char *cnames[2] = {
+ "_mesa_clip_tab",
+ "_mesa_clip_np_tab"
+};
+#ifdef RUN_DEBUG_BENCHMARK
+static char *cstrings[2] = {
+ "clip, perspective divide",
+ "clip, no divide"
+};
+#endif
+
+
+/* =============================================================
+ * Reference cliptests
+ */
+
+static GLvector4f *ref_cliptest_points4( GLvector4f *clip_vec,
+ GLvector4f *proj_vec,
+ GLubyte clipMask[],
+ GLubyte *orMask,
+ GLubyte *andMask )
+{
+ const GLuint stride = clip_vec->stride;
+ const GLuint count = clip_vec->count;
+ const GLfloat *from = (GLfloat *)clip_vec->start;
+ GLuint c = 0;
+ GLfloat (*vProj)[4] = (GLfloat (*)[4])proj_vec->start;
+ GLubyte tmpAndMask = *andMask;
+ GLubyte tmpOrMask = *orMask;
+ GLuint i;
+ for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) ) {
+ const GLfloat cx = from[0];
+ const GLfloat cy = from[1];
+ const GLfloat cz = from[2];
+ const GLfloat cw = from[3];
+ GLubyte mask = 0;
+ if ( -cx + cw < 0 ) mask |= CLIP_RIGHT_BIT;
+ if ( cx + cw < 0 ) mask |= CLIP_LEFT_BIT;
+ if ( -cy + cw < 0 ) mask |= CLIP_TOP_BIT;
+ if ( cy + cw < 0 ) mask |= CLIP_BOTTOM_BIT;
+ if ( -cz + cw < 0 ) mask |= CLIP_FAR_BIT;
+ if ( cz + cw < 0 ) mask |= CLIP_NEAR_BIT;
+ clipMask[i] = mask;
+ if ( mask ) {
+ c++;
+ tmpAndMask &= mask;
+ tmpOrMask |= mask;
+ vProj[i][0] = 0;
+ vProj[i][1] = 0;
+ vProj[i][2] = 0;
+ vProj[i][3] = 1;
+ } else {
+ GLfloat oow = 1.0F / cw;
+ vProj[i][0] = cx * oow;
+ vProj[i][1] = cy * oow;
+ vProj[i][2] = cz * oow;
+ vProj[i][3] = oow;
+ }
+ }
+
+ *orMask = tmpOrMask;
+ *andMask = (GLubyte) (c < count ? 0 : tmpAndMask);
+
+ proj_vec->flags |= VEC_SIZE_4;
+ proj_vec->size = 4;
+ proj_vec->count = clip_vec->count;
+ return proj_vec;
+}
+
+/* Keep these here for now, even though we don't use them...
+ */
+static GLvector4f *ref_cliptest_points3( GLvector4f *clip_vec,
+ GLvector4f *proj_vec,
+ GLubyte clipMask[],
+ GLubyte *orMask,
+ GLubyte *andMask )
+{
+ const GLuint stride = clip_vec->stride;
+ const GLuint count = clip_vec->count;
+ const GLfloat *from = (GLfloat *)clip_vec->start;
+
+ GLubyte tmpOrMask = *orMask;
+ GLubyte tmpAndMask = *andMask;
+ GLuint i;
+ for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) ) {
+ const GLfloat cx = from[0], cy = from[1], cz = from[2];
+ GLubyte mask = 0;
+ if ( cx > 1.0 ) mask |= CLIP_RIGHT_BIT;
+ else if ( cx < -1.0 ) mask |= CLIP_LEFT_BIT;
+ if ( cy > 1.0 ) mask |= CLIP_TOP_BIT;
+ else if ( cy < -1.0 ) mask |= CLIP_BOTTOM_BIT;
+ if ( cz > 1.0 ) mask |= CLIP_FAR_BIT;
+ else if ( cz < -1.0 ) mask |= CLIP_NEAR_BIT;
+ clipMask[i] = mask;
+ tmpOrMask |= mask;
+ tmpAndMask &= mask;
+ }
+
+ *orMask = tmpOrMask;
+ *andMask = tmpAndMask;
+ return clip_vec;
+}
+
+static GLvector4f * ref_cliptest_points2( GLvector4f *clip_vec,
+ GLvector4f *proj_vec,
+ GLubyte clipMask[],
+ GLubyte *orMask,
+ GLubyte *andMask )
+{
+ const GLuint stride = clip_vec->stride;
+ const GLuint count = clip_vec->count;
+ const GLfloat *from = (GLfloat *)clip_vec->start;
+
+ GLubyte tmpOrMask = *orMask;
+ GLubyte tmpAndMask = *andMask;
+ GLuint i;
+ for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) ) {
+ const GLfloat cx = from[0], cy = from[1];
+ GLubyte mask = 0;
+ if ( cx > 1.0 ) mask |= CLIP_RIGHT_BIT;
+ else if ( cx < -1.0 ) mask |= CLIP_LEFT_BIT;
+ if ( cy > 1.0 ) mask |= CLIP_TOP_BIT;
+ else if ( cy < -1.0 ) mask |= CLIP_BOTTOM_BIT;
+ clipMask[i] = mask;
+ tmpOrMask |= mask;
+ tmpAndMask &= mask;
+ }
+
+ *orMask = tmpOrMask;
+ *andMask = tmpAndMask;
+ return clip_vec;
+}
+
+static clip_func ref_cliptest[5] = {
+ 0,
+ 0,
+ ref_cliptest_points2,
+ ref_cliptest_points3,
+ ref_cliptest_points4
+};
+
+
+/* =============================================================
+ * Cliptest tests
+ */
+
+ALIGN16(static GLfloat, s[TEST_COUNT][4]);
+ALIGN16(static GLfloat, d[TEST_COUNT][4]);
+ALIGN16(static GLfloat, r[TEST_COUNT][4]);
+
+
+static int test_cliptest_function( clip_func func, int np,
+ int psize, long *cycles )
+{
+ GLvector4f source[1], dest[1], ref[1];
+ GLubyte dm[TEST_COUNT], dco, dca;
+ GLubyte rm[TEST_COUNT], rco, rca;
+ int i, j;
+#ifdef RUN_DEBUG_BENCHMARK
+ int cycle_i; /* the counter for the benchmarks we run */
+#endif
+
+ (void) cycles;
+
+ if ( psize > 4 ) {
+ _mesa_problem( NULL, "test_cliptest_function called with psize > 4\n" );
+ return 0;
+ }
+
+ for ( i = 0 ; i < TEST_COUNT ; i++) {
+ ASSIGN_4V( d[i], 0.0, 0.0, 0.0, 1.0 );
+ ASSIGN_4V( s[i], 0.0, 0.0, 0.0, 1.0 );
+ for ( j = 0 ; j < psize ; j++ )
+ s[i][j] = rnd();
+ }
+
+ source->data = (GLfloat(*)[4])s;
+ source->start = (GLfloat *)s;
+ source->count = TEST_COUNT;
+ source->stride = sizeof(s[0]);
+ source->size = 4;
+ source->flags = 0;
+
+ dest->data = (GLfloat(*)[4])d;
+ dest->start = (GLfloat *)d;
+ dest->count = TEST_COUNT;
+ dest->stride = sizeof(float[4]);
+ dest->size = 0;
+ dest->flags = 0;
+
+ ref->data = (GLfloat(*)[4])r;
+ ref->start = (GLfloat *)r;
+ ref->count = TEST_COUNT;
+ ref->stride = sizeof(float[4]);
+ ref->size = 0;
+ ref->flags = 0;
+
+ dco = rco = 0;
+ dca = rca = CLIP_ALL_BITS;
+
+ ref_cliptest[psize]( source, ref, rm, &rco, &rca );
+
+ if ( mesa_profile ) {
+ BEGIN_RACE( *cycles );
+ func( source, dest, dm, &dco, &dca );
+ END_RACE( *cycles );
+ }
+ else {
+ func( source, dest, dm, &dco, &dca );
+ }
+
+ if ( dco != rco ) {
+ _mesa_printf( "\n-----------------------------\n" );
+ _mesa_printf( "dco = 0x%02x rco = 0x%02x\n", dco, rco );
+ return 0;
+ }
+ if ( dca != rca ) {
+ _mesa_printf( "\n-----------------------------\n" );
+ _mesa_printf( "dca = 0x%02x rca = 0x%02x\n", dca, rca );
+ return 0;
+ }
+ for ( i = 0 ; i < TEST_COUNT ; i++ ) {
+ if ( dm[i] != rm[i] ) {
+ _mesa_printf( "\n-----------------------------\n" );
+ _mesa_printf( "(i = %i)\n", i );
+ _mesa_printf( "dm = 0x%02x rm = 0x%02x\n", dm[i], rm[i] );
+ return 0;
+ }
+ }
+
+ /* Only verify output on projected points4 case. FIXME: Do we need
+ * to test other cases?
+ */
+ if ( np || psize < 4 )
+ return 1;
+
+ for ( i = 0 ; i < TEST_COUNT ; i++ ) {
+ for ( j = 0 ; j < 4 ; j++ ) {
+ if ( significand_match( d[i][j], r[i][j] ) < REQUIRED_PRECISION ) {
+ _mesa_printf( "\n-----------------------------\n" );
+ _mesa_printf( "(i = %i, j = %i) dm = 0x%02x rm = 0x%02x\n",
+ i, j, dm[i], rm[i] );
+ _mesa_printf( "%f \t %f \t [diff = %e - %i bit missed]\n",
+ d[i][0], r[i][0], r[i][0]-d[i][0],
+ MAX_PRECISION - significand_match( d[i][0], r[i][0] ) );
+ _mesa_printf( "%f \t %f \t [diff = %e - %i bit missed]\n",
+ d[i][1], r[i][1], r[i][1]-d[i][1],
+ MAX_PRECISION - significand_match( d[i][1], r[i][1] ) );
+ _mesa_printf( "%f \t %f \t [diff = %e - %i bit missed]\n",
+ d[i][2], r[i][2], r[i][2]-d[i][2],
+ MAX_PRECISION - significand_match( d[i][2], r[i][2] ) );
+ _mesa_printf( "%f \t %f \t [diff = %e - %i bit missed]\n",
+ d[i][3], r[i][3], r[i][3]-d[i][3],
+ MAX_PRECISION - significand_match( d[i][3], r[i][3] ) );
+ return 0;
+ }
+ }
+ }
+
+ return 1;
+}
+
+void _math_test_all_cliptest_functions( char *description )
+{
+ int np, psize;
+ long benchmark_tab[2][4];
+ static int first_time = 1;
+
+ if ( first_time ) {
+ first_time = 0;
+ mesa_profile = _mesa_getenv( "MESA_PROFILE" );
+ }
+
+#ifdef RUN_DEBUG_BENCHMARK
+ if ( mesa_profile ) {
+ if ( !counter_overhead ) {
+ INIT_COUNTER();
+ _mesa_printf( "counter overhead: %ld cycles\n\n", counter_overhead );
+ }
+ _mesa_printf( "cliptest results after hooking in %s functions:\n", description );
+ }
+#endif
+
+#ifdef RUN_DEBUG_BENCHMARK
+ if ( mesa_profile ) {
+ _mesa_printf( "\n\t" );
+ for ( psize = 2 ; psize <= 4 ; psize++ ) {
+ _mesa_printf( " p%d\t", psize );
+ }
+ _mesa_printf( "\n--------------------------------------------------------\n\t" );
+ }
+#endif
+
+ for ( np = 0 ; np < 2 ; np++ ) {
+ for ( psize = 2 ; psize <= 4 ; psize++ ) {
+ clip_func func = clip_tab[np][psize];
+ long *cycles = &(benchmark_tab[np][psize-1]);
+
+ if ( test_cliptest_function( func, np, psize, cycles ) == 0 ) {
+ char buf[100];
+ _mesa_sprintf( buf, "%s[%d] failed test (%s)",
+ cnames[np], psize, description );
+ _mesa_problem( NULL, buf );
+ }
+#ifdef RUN_DEBUG_BENCHMARK
+ if ( mesa_profile )
+ _mesa_printf( " %li\t", benchmark_tab[np][psize-1] );
+#endif
+ }
+#ifdef RUN_DEBUG_BENCHMARK
+ if ( mesa_profile )
+ _mesa_printf( " | [%s]\n\t", cstrings[np] );
+#endif
+ }
+#ifdef RUN_DEBUG_BENCHMARK
+ if ( mesa_profile )
+ _mesa_printf( "\n" );
+#endif
+}
+
+
+#endif /* DEBUG */
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_debug_norm.c b/nx-X11/extras/Mesa/src/mesa/math/m_debug_norm.c
new file mode 100644
index 000000000..e40399855
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_debug_norm.c
@@ -0,0 +1,384 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ *
+ * Authors:
+ * Gareth Hughes
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+
+#include "m_matrix.h"
+#include "m_xform.h"
+
+#include "m_debug.h"
+#include "m_debug_util.h"
+
+
+#ifdef __UNIXOS2__
+/* The linker doesn't like empty files */
+static char dummy;
+#endif
+
+#ifdef DEBUG /* This code only used for debugging */
+
+
+static int m_norm_identity[16] = {
+ ONE, NIL, NIL, NIL,
+ NIL, ONE, NIL, NIL,
+ NIL, NIL, ONE, NIL,
+ NIL, NIL, NIL, NIL
+};
+static int m_norm_general[16] = {
+ VAR, VAR, VAR, NIL,
+ VAR, VAR, VAR, NIL,
+ VAR, VAR, VAR, NIL,
+ NIL, NIL, NIL, NIL
+};
+static int m_norm_no_rot[16] = {
+ VAR, NIL, NIL, NIL,
+ NIL, VAR, NIL, NIL,
+ NIL, NIL, VAR, NIL,
+ NIL, NIL, NIL, NIL
+};
+static int *norm_templates[8] = {
+ m_norm_no_rot,
+ m_norm_no_rot,
+ m_norm_no_rot,
+ m_norm_general,
+ m_norm_general,
+ m_norm_general,
+ m_norm_identity,
+ m_norm_identity
+};
+static int norm_types[8] = {
+ NORM_TRANSFORM_NO_ROT,
+ NORM_TRANSFORM_NO_ROT | NORM_RESCALE,
+ NORM_TRANSFORM_NO_ROT | NORM_NORMALIZE,
+ NORM_TRANSFORM,
+ NORM_TRANSFORM | NORM_RESCALE,
+ NORM_TRANSFORM | NORM_NORMALIZE,
+ NORM_RESCALE,
+ NORM_NORMALIZE
+};
+static int norm_scale_types[8] = { /* rescale factor */
+ NIL, /* NIL disables rescaling */
+ VAR,
+ NIL,
+ NIL,
+ VAR,
+ NIL,
+ VAR,
+ NIL
+};
+static int norm_normalize_types[8] = { /* normalizing ?? (no = 0) */
+ 0,
+ 0,
+ 1,
+ 0,
+ 0,
+ 1,
+ 0,
+ 1
+};
+static char *norm_strings[8] = {
+ "NORM_TRANSFORM_NO_ROT",
+ "NORM_TRANSFORM_NO_ROT | NORM_RESCALE",
+ "NORM_TRANSFORM_NO_ROT | NORM_NORMALIZE",
+ "NORM_TRANSFORM",
+ "NORM_TRANSFORM | NORM_RESCALE",
+ "NORM_TRANSFORM | NORM_NORMALIZE",
+ "NORM_RESCALE",
+ "NORM_NORMALIZE"
+};
+
+
+/* =============================================================
+ * Reference transformations
+ */
+
+static void ref_norm_transform_rescale( const GLmatrix *mat,
+ GLfloat scale,
+ const GLvector4f *in,
+ const GLfloat *lengths,
+ GLvector4f *dest )
+{
+ GLuint i;
+ const GLfloat *s = in->start;
+ const GLfloat *m = mat->inv;
+ GLfloat (*out)[4] = (GLfloat (*)[4]) dest->start;
+
+ (void) lengths;
+
+ for ( i = 0 ; i < in->count ; i++ ) {
+ GLfloat t[3];
+
+ TRANSFORM_NORMAL( t, s, m );
+ SCALE_SCALAR_3V( out[i], scale, t );
+
+ s = (GLfloat *)((char *)s + in->stride);
+ }
+}
+
+static void ref_norm_transform_normalize( const GLmatrix *mat,
+ GLfloat scale,
+ const GLvector4f *in,
+ const GLfloat *lengths,
+ GLvector4f *dest )
+{
+ GLuint i;
+ const GLfloat *s = in->start;
+ const GLfloat *m = mat->inv;
+ GLfloat (*out)[4] = (GLfloat (*)[4]) dest->start;
+
+ for ( i = 0 ; i < in->count ; i++ ) {
+ GLfloat t[3];
+
+ TRANSFORM_NORMAL( t, s, m );
+
+ if ( !lengths ) {
+ GLfloat len = LEN_SQUARED_3FV( t );
+ if ( len > 1e-20 ) {
+ /* Hmmm, don't know how we could test the precalculated
+ * length case...
+ */
+ scale = 1.0 / sqrt( len );
+ SCALE_SCALAR_3V( out[i], scale, t );
+ } else {
+ out[i][0] = out[i][1] = out[i][2] = 0;
+ }
+ } else {
+ scale = lengths[i];;
+ SCALE_SCALAR_3V( out[i], scale, t );
+ }
+
+ s = (GLfloat *)((char *)s + in->stride);
+ }
+}
+
+
+/* =============================================================
+ * Normal transformation tests
+ */
+
+static void init_matrix( GLfloat *m )
+{
+ m[0] = 63.0; m[4] = 43.0; m[ 8] = 29.0; m[12] = 43.0;
+ m[1] = 55.0; m[5] = 17.0; m[ 9] = 31.0; m[13] = 7.0;
+ m[2] = 44.0; m[6] = 9.0; m[10] = 7.0; m[14] = 3.0;
+ m[3] = 11.0; m[7] = 23.0; m[11] = 91.0; m[15] = 9.0;
+}
+
+
+static int test_norm_function( normal_func func, int mtype, long *cycles )
+{
+ GLvector4f source[1], dest[1], dest2[1], ref[1], ref2[1];
+ GLmatrix mat[1];
+ GLfloat s[TEST_COUNT][5], d[TEST_COUNT][4], r[TEST_COUNT][4];
+ GLfloat d2[TEST_COUNT][4], r2[TEST_COUNT][4], length[TEST_COUNT];
+ GLfloat scale;
+ GLfloat *m;
+ int i, j;
+#ifdef RUN_DEBUG_BENCHMARK
+ int cycle_i; /* the counter for the benchmarks we run */
+#endif
+
+ (void) cycles;
+
+ mat->m = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 );
+ mat->inv = m = mat->m;
+
+ init_matrix( m );
+
+ scale = 1.0F + rnd () * norm_scale_types[mtype];
+
+ for ( i = 0 ; i < 4 ; i++ ) {
+ for ( j = 0 ; j < 4 ; j++ ) {
+ switch ( norm_templates[mtype][i * 4 + j] ) {
+ case NIL:
+ m[j * 4 + i] = 0.0;
+ break;
+ case ONE:
+ m[j * 4 + i] = 1.0;
+ break;
+ case NEG:
+ m[j * 4 + i] = -1.0;
+ break;
+ case VAR:
+ break;
+ default:
+ abort();
+ }
+ }
+ }
+
+ for ( i = 0 ; i < TEST_COUNT ; i++ ) {
+ ASSIGN_3V( d[i], 0.0, 0.0, 0.0 );
+ ASSIGN_3V( s[i], 0.0, 0.0, 0.0 );
+ ASSIGN_3V( d2[i], 0.0, 0.0, 0.0 );
+ for ( j = 0 ; j < 3 ; j++ )
+ s[i][j] = rnd();
+ length[i] = 1 / sqrt( LEN_SQUARED_3FV( s[i] ) );
+ }
+
+ source->data = (GLfloat(*)[4]) s;
+ source->start = (GLfloat *) s;
+ source->count = TEST_COUNT;
+ source->stride = sizeof(s[0]);
+ source->flags = 0;
+
+ dest->data = d;
+ dest->start = (GLfloat *) d;
+ dest->count = TEST_COUNT;
+ dest->stride = sizeof(float[4]);
+ dest->flags = 0;
+
+ dest2->data = d2;
+ dest2->start = (GLfloat *) d2;
+ dest2->count = TEST_COUNT;
+ dest2->stride = sizeof(float[4]);
+ dest2->flags = 0;
+
+ ref->data = r;
+ ref->start = (GLfloat *) r;
+ ref->count = TEST_COUNT;
+ ref->stride = sizeof(float[4]);
+ ref->flags = 0;
+
+ ref2->data = r2;
+ ref2->start = (GLfloat *) r2;
+ ref2->count = TEST_COUNT;
+ ref2->stride = sizeof(float[4]);
+ ref2->flags = 0;
+
+ if ( norm_normalize_types[mtype] == 0 ) {
+ ref_norm_transform_rescale( mat, scale, source, NULL, ref );
+ } else {
+ ref_norm_transform_normalize( mat, scale, source, NULL, ref );
+ ref_norm_transform_normalize( mat, scale, source, length, ref2 );
+ }
+
+ if ( mesa_profile ) {
+ BEGIN_RACE( *cycles );
+ func( mat, scale, source, NULL, dest );
+ END_RACE( *cycles );
+ func( mat, scale, source, length, dest2 );
+ } else {
+ func( mat, scale, source, NULL, dest );
+ func( mat, scale, source, length, dest2 );
+ }
+
+ for ( i = 0 ; i < TEST_COUNT ; i++ ) {
+ for ( j = 0 ; j < 3 ; j++ ) {
+ if ( significand_match( d[i][j], r[i][j] ) < REQUIRED_PRECISION ) {
+ _mesa_printf( "-----------------------------\n" );
+ _mesa_printf( "(i = %i, j = %i)\n", i, j );
+ _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
+ d[i][0], r[i][0], r[i][0]/d[i][0],
+ MAX_PRECISION - significand_match( d[i][0], r[i][0] ) );
+ _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
+ d[i][1], r[i][1], r[i][1]/d[i][1],
+ MAX_PRECISION - significand_match( d[i][1], r[i][1] ) );
+ _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
+ d[i][2], r[i][2], r[i][2]/d[i][2],
+ MAX_PRECISION - significand_match( d[i][2], r[i][2] ) );
+ return 0;
+ }
+
+ if ( norm_normalize_types[mtype] != 0 ) {
+ if ( significand_match( d2[i][j], r2[i][j] ) < REQUIRED_PRECISION ) {
+ _mesa_printf( "------------------- precalculated length case ------\n" );
+ _mesa_printf( "(i = %i, j = %i)\n", i, j );
+ _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
+ d2[i][0], r2[i][0], r2[i][0]/d2[i][0],
+ MAX_PRECISION - significand_match( d2[i][0], r2[i][0] ) );
+ _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
+ d2[i][1], r2[i][1], r2[i][1]/d2[i][1],
+ MAX_PRECISION - significand_match( d2[i][1], r2[i][1] ) );
+ _mesa_printf( "%f \t %f \t [ratio = %e - %i bit missed]\n",
+ d2[i][2], r2[i][2], r2[i][2]/d2[i][2],
+ MAX_PRECISION - significand_match( d2[i][2], r2[i][2] ) );
+ return 0;
+ }
+ }
+ }
+ }
+
+ ALIGN_FREE( mat->m );
+ return 1;
+}
+
+void _math_test_all_normal_transform_functions( char *description )
+{
+ int mtype;
+ long benchmark_tab[0xf];
+ static int first_time = 1;
+
+ if ( first_time ) {
+ first_time = 0;
+ mesa_profile = getenv( "MESA_PROFILE" );
+ }
+
+#ifdef RUN_DEBUG_BENCHMARK
+ if ( mesa_profile ) {
+ if ( !counter_overhead ) {
+ INIT_COUNTER();
+ _mesa_printf( "counter overhead: %ld cycles\n\n", counter_overhead );
+ }
+ _mesa_printf( "normal transform results after hooking in %s functions:\n",
+ description );
+ _mesa_printf( "\n-------------------------------------------------------\n" );
+ }
+#endif
+
+ for ( mtype = 0 ; mtype < 8 ; mtype++ ) {
+ normal_func func = _mesa_normal_tab[norm_types[mtype]];
+ long *cycles = &benchmark_tab[mtype];
+
+ if ( test_norm_function( func, mtype, cycles ) == 0 ) {
+ char buf[100];
+ _mesa_sprintf( buf, "_mesa_normal_tab[0][%s] failed test (%s)",
+ norm_strings[mtype], description );
+ _mesa_problem( NULL, buf );
+ }
+
+#ifdef RUN_DEBUG_BENCHMARK
+ if ( mesa_profile ) {
+ _mesa_printf( " %li\t", benchmark_tab[mtype] );
+ _mesa_printf( " | [%s]\n", norm_strings[mtype] );
+ }
+#endif
+ }
+#ifdef RUN_DEBUG_BENCHMARK
+ if ( mesa_profile ) {
+ _mesa_printf( "\n" );
+ fflush( stdout );
+ }
+#endif
+}
+
+
+#endif /* DEBUG */
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_debug_util.h b/nx-X11/extras/Mesa/src/mesa/math/m_debug_util.h
new file mode 100644
index 000000000..1b7d742a8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_debug_util.h
@@ -0,0 +1,320 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ *
+ * Authors:
+ * Gareth Hughes
+ */
+
+#ifndef __M_DEBUG_UTIL_H__
+#define __M_DEBUG_UTIL_H__
+
+
+#ifdef DEBUG /* This code only used for debugging */
+
+
+/* Comment this out to deactivate the cycle counter.
+ * NOTE: it works only on CPUs which know the 'rdtsc' command (586 or higher)
+ * (hope, you don't try to debug Mesa on a 386 ;)
+ */
+#if defined(__GNUC__) && \
+ ((defined(__i386__) && defined(USE_X86_ASM)) || \
+ (defined(__sparc__) && defined(USE_SPARC_ASM)))
+#define RUN_DEBUG_BENCHMARK
+#endif
+
+#define TEST_COUNT 128 /* size of the tested vector array */
+
+#define REQUIRED_PRECISION 10 /* allow 4 bits to miss */
+#define MAX_PRECISION 24 /* max. precision possible */
+
+
+#ifdef RUN_DEBUG_BENCHMARK
+/* Overhead of profiling counter in cycles. Automatically adjusted to
+ * your machine at run time - counter initialization should give very
+ * consistent results.
+ */
+extern long counter_overhead;
+
+/* This is the value of the environment variable MESA_PROFILE, and is
+ * used to determine if we should benchmark the functions as well as
+ * verify their correctness.
+ */
+extern char *mesa_profile;
+
+/* Modify the the number of tests if you like.
+ * We take the minimum of all results, because every error should be
+ * positive (time used by other processes, task switches etc).
+ * It is assumed that all calculations are done in the cache.
+ */
+
+#if defined(__i386__)
+
+#if 1 /* PPro, PII, PIII version */
+
+/* Profiling on the P6 architecture requires a little more work, due to
+ * the internal out-of-order execution. We must perform a serializing
+ * 'cpuid' instruction before and after the 'rdtsc' instructions to make
+ * sure no other uops are executed when we sample the timestamp counter.
+ */
+#define INIT_COUNTER() \
+ do { \
+ int cycle_i; \
+ counter_overhead = LONG_MAX; \
+ for ( cycle_i = 0 ; cycle_i < 8 ; cycle_i++ ) { \
+ long cycle_tmp1 = 0, cycle_tmp2 = 0; \
+ __asm__ __volatile__ ( "push %%ebx \n" \
+ "xor %%eax, %%eax \n" \
+ "cpuid \n" \
+ "rdtsc \n" \
+ "mov %%eax, %0 \n" \
+ "xor %%eax, %%eax \n" \
+ "cpuid \n" \
+ "pop %%ebx \n" \
+ "push %%ebx \n" \
+ "xor %%eax, %%eax \n" \
+ "cpuid \n" \
+ "rdtsc \n" \
+ "mov %%eax, %1 \n" \
+ "xor %%eax, %%eax \n" \
+ "cpuid \n" \
+ "pop %%ebx \n" \
+ : "=m" (cycle_tmp1), "=m" (cycle_tmp2) \
+ : : "eax", "ecx", "edx" ); \
+ if ( counter_overhead > (cycle_tmp2 - cycle_tmp1) ) { \
+ counter_overhead = cycle_tmp2 - cycle_tmp1; \
+ } \
+ } \
+ } while (0)
+
+#define BEGIN_RACE(x) \
+ x = LONG_MAX; \
+ for ( cycle_i = 0 ; cycle_i < 10 ; cycle_i++ ) { \
+ long cycle_tmp1 = 0, cycle_tmp2 = 0; \
+ __asm__ __volatile__ ( "push %%ebx \n" \
+ "xor %%eax, %%eax \n" \
+ "cpuid \n" \
+ "rdtsc \n" \
+ "mov %%eax, %0 \n" \
+ "xor %%eax, %%eax \n" \
+ "cpuid \n" \
+ "pop %%ebx \n" \
+ : "=m" (cycle_tmp1) \
+ : : "eax", "ecx", "edx" );
+
+#define END_RACE(x) \
+ __asm__ __volatile__ ( "push %%ebx \n" \
+ "xor %%eax, %%eax \n" \
+ "cpuid \n" \
+ "rdtsc \n" \
+ "mov %%eax, %0 \n" \
+ "xor %%eax, %%eax \n" \
+ "cpuid \n" \
+ "pop %%ebx \n" \
+ : "=m" (cycle_tmp2) \
+ : : "eax", "ecx", "edx" ); \
+ if ( x > (cycle_tmp2 - cycle_tmp1) ) { \
+ x = cycle_tmp2 - cycle_tmp1; \
+ } \
+ } \
+ x -= counter_overhead;
+
+#else /* PPlain, PMMX version */
+
+/* To ensure accurate results, we stall the pipelines with the
+ * non-pairable 'cdq' instruction. This ensures all the code being
+ * profiled is complete when the 'rdtsc' instruction executes.
+ */
+#define INIT_COUNTER(x) \
+ do { \
+ int cycle_i; \
+ x = LONG_MAX; \
+ for ( cycle_i = 0 ; cycle_i < 32 ; cycle_i++ ) { \
+ long cycle_tmp1, cycle_tmp2, dummy; \
+ __asm__ ( "mov %%eax, %0" : "=a" (cycle_tmp1) ); \
+ __asm__ ( "mov %%eax, %0" : "=a" (cycle_tmp2) ); \
+ __asm__ ( "cdq" ); \
+ __asm__ ( "cdq" ); \
+ __asm__ ( "rdtsc" : "=a" (cycle_tmp1), "=d" (dummy) ); \
+ __asm__ ( "cdq" ); \
+ __asm__ ( "cdq" ); \
+ __asm__ ( "rdtsc" : "=a" (cycle_tmp2), "=d" (dummy) ); \
+ if ( x > (cycle_tmp2 - cycle_tmp1) ) \
+ x = cycle_tmp2 - cycle_tmp1; \
+ } \
+ } while (0)
+
+#define BEGIN_RACE(x) \
+ x = LONG_MAX; \
+ for ( cycle_i = 0 ; cycle_i < 16 ; cycle_i++ ) { \
+ long cycle_tmp1, cycle_tmp2, dummy; \
+ __asm__ ( "mov %%eax, %0" : "=a" (cycle_tmp1) ); \
+ __asm__ ( "mov %%eax, %0" : "=a" (cycle_tmp2) ); \
+ __asm__ ( "cdq" ); \
+ __asm__ ( "cdq" ); \
+ __asm__ ( "rdtsc" : "=a" (cycle_tmp1), "=d" (dummy) );
+
+
+#define END_RACE(x) \
+ __asm__ ( "cdq" ); \
+ __asm__ ( "cdq" ); \
+ __asm__ ( "rdtsc" : "=a" (cycle_tmp2), "=d" (dummy) ); \
+ if ( x > (cycle_tmp2 - cycle_tmp1) ) \
+ x = cycle_tmp2 - cycle_tmp1; \
+ } \
+ x -= counter_overhead;
+
+#endif
+
+#elif defined(__amd64__)
+
+#define rdtscll(val) do { \
+ unsigned int a,d; \
+ __asm__ volatile("rdtsc" : "=a" (a), "=d" (d)); \
+ (val) = ((unsigned long)a) | (((unsigned long)d)<<32); \
+} while(0)
+
+/* Copied from i386 PIII version */
+#define INIT_COUNTER() \
+ do { \
+ int cycle_i; \
+ counter_overhead = LONG_MAX; \
+ for ( cycle_i = 0 ; cycle_i < 16 ; cycle_i++ ) { \
+ unsigned long cycle_tmp1, cycle_tmp2; \
+ rdtscll(cycle_tmp1); \
+ rdtscll(cycle_tmp2); \
+ if ( counter_overhead > (cycle_tmp2 - cycle_tmp1) ) { \
+ counter_overhead = cycle_tmp2 - cycle_tmp1; \
+ } \
+ } \
+ } while (0)
+
+
+#define BEGIN_RACE(x) \
+ x = LONG_MAX; \
+ for ( cycle_i = 0 ; cycle_i < 10 ; cycle_i++ ) { \
+ unsigned long cycle_tmp1, cycle_tmp2; \
+ rdtscll(cycle_tmp1); \
+
+#define END_RACE(x) \
+ rdtscll(cycle_tmp2); \
+ if ( x > (cycle_tmp2 - cycle_tmp1) ) { \
+ x = cycle_tmp2 - cycle_tmp1; \
+ } \
+ } \
+ x -= counter_overhead;
+
+#elif defined(__sparc__)
+
+#define INIT_COUNTER() \
+ do { counter_overhead = 5; } while(0)
+
+#define BEGIN_RACE(x) \
+x = LONG_MAX; \
+for (cycle_i = 0; cycle_i <10; cycle_i++) { \
+ register long cycle_tmp1 asm("l0"); \
+ register long cycle_tmp2 asm("l1"); \
+ /* rd %tick, %l0 */ \
+ __asm__ __volatile__ (".word 0xa1410000" : "=r" (cycle_tmp1)); /* save timestamp */
+
+#define END_RACE(x) \
+ /* rd %tick, %l1 */ \
+ __asm__ __volatile__ (".word 0xa3410000" : "=r" (cycle_tmp2)); \
+ if (x > (cycle_tmp2-cycle_tmp1)) x = cycle_tmp2 - cycle_tmp1; \
+} \
+x -= counter_overhead;
+
+#else
+#error Your processor is not supported for RUN_XFORM_BENCHMARK
+#endif
+
+#else
+
+#define BEGIN_RACE(x)
+#define END_RACE(x)
+
+#endif
+
+
+/* =============================================================
+ * Helper functions
+ */
+
+static GLfloat rnd( void )
+{
+ GLfloat f = (GLfloat)rand() / (GLfloat)RAND_MAX;
+ GLfloat gran = (GLfloat)(1 << 13);
+
+ f = (GLfloat)(GLint)(f * gran) / gran;
+
+ return f * 2.0 - 1.0;
+}
+
+static int significand_match( GLfloat a, GLfloat b )
+{
+ GLfloat d = a - b;
+ int a_ex, b_ex, d_ex;
+
+ if ( d == 0.0F ) {
+ return MAX_PRECISION; /* Exact match */
+ }
+
+ if ( a == 0.0F || b == 0.0F ) {
+ /* It would probably be better to check if the
+ * non-zero number is denormalized and return
+ * the index of the highest set bit here.
+ */
+ return 0;
+ }
+
+ FREXPF( a, &a_ex );
+ FREXPF( b, &b_ex );
+ FREXPF( d, &d_ex );
+
+ if ( a_ex < b_ex ) {
+ return a_ex - d_ex;
+ } else {
+ return b_ex - d_ex;
+ }
+}
+
+enum { NIL = 0, ONE = 1, NEG = -1, VAR = 2 };
+
+/* Ensure our arrays are correctly aligned.
+ */
+#if defined(__GNUC__)
+# define ALIGN16(type, array) type array __attribute__ ((aligned (16)))
+#elif defined(__MSC__)
+# define ALIGN16(type, array) type array __declspec(align(16)) /* GH: Does this work? */
+#elif defined(__WATCOMC__)
+# define ALIGN16(type, array) /* Watcom does not support this */
+#elif defined(__xlC__)
+# define ALIGN16(type, array) type __align (16) array
+#else
+# warning "ALIGN16 will not 16-byte align!\n"
+# define ALIGN16
+#endif
+
+
+#endif /* DEBUG */
+
+#endif /* __M_DEBUG_UTIL_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_debug_xform.c b/nx-X11/extras/Mesa/src/mesa/math/m_debug_xform.c
new file mode 100644
index 000000000..d8250f246
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_debug_xform.c
@@ -0,0 +1,338 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+/*
+ * Updated for P6 architecture by Gareth Hughes.
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+
+#include "m_matrix.h"
+#include "m_xform.h"
+
+#include "m_debug.h"
+#include "m_debug_util.h"
+
+#ifdef __UNIXOS2__
+/* The linker doesn't like empty files */
+static char dummy;
+#endif
+
+#ifdef DEBUG /* This code only used for debugging */
+
+
+/* Overhead of profiling counter in cycles. Automatically adjusted to
+ * your machine at run time - counter initialization should give very
+ * consistent results.
+ */
+long counter_overhead = 0;
+
+/* This is the value of the environment variable MESA_PROFILE, and is
+ * used to determine if we should benchmark the functions as well as
+ * verify their correctness.
+ */
+char *mesa_profile = NULL;
+
+
+static int m_general[16] = {
+ VAR, VAR, VAR, VAR,
+ VAR, VAR, VAR, VAR,
+ VAR, VAR, VAR, VAR,
+ VAR, VAR, VAR, VAR
+};
+static int m_identity[16] = {
+ ONE, NIL, NIL, NIL,
+ NIL, ONE, NIL, NIL,
+ NIL, NIL, ONE, NIL,
+ NIL, NIL, NIL, ONE
+};
+static int m_2d[16] = {
+ VAR, VAR, NIL, VAR,
+ VAR, VAR, NIL, VAR,
+ NIL, NIL, ONE, NIL,
+ NIL, NIL, NIL, ONE
+};
+static int m_2d_no_rot[16] = {
+ VAR, NIL, NIL, VAR,
+ NIL, VAR, NIL, VAR,
+ NIL, NIL, ONE, NIL,
+ NIL, NIL, NIL, ONE
+};
+static int m_3d[16] = {
+ VAR, VAR, VAR, VAR,
+ VAR, VAR, VAR, VAR,
+ VAR, VAR, VAR, VAR,
+ NIL, NIL, NIL, ONE
+};
+static int m_3d_no_rot[16] = {
+ VAR, NIL, NIL, VAR,
+ NIL, VAR, NIL, VAR,
+ NIL, NIL, VAR, VAR,
+ NIL, NIL, NIL, ONE
+};
+static int m_perspective[16] = {
+ VAR, NIL, VAR, NIL,
+ NIL, VAR, VAR, NIL,
+ NIL, NIL, VAR, VAR,
+ NIL, NIL, NEG, NIL
+};
+static int *templates[7] = {
+ m_general,
+ m_identity,
+ m_3d_no_rot,
+ m_perspective,
+ m_2d,
+ m_2d_no_rot,
+ m_3d
+};
+static enum GLmatrixtype mtypes[7] = {
+ MATRIX_GENERAL,
+ MATRIX_IDENTITY,
+ MATRIX_3D_NO_ROT,
+ MATRIX_PERSPECTIVE,
+ MATRIX_2D,
+ MATRIX_2D_NO_ROT,
+ MATRIX_3D
+};
+static char *mstrings[7] = {
+ "MATRIX_GENERAL",
+ "MATRIX_IDENTITY",
+ "MATRIX_3D_NO_ROT",
+ "MATRIX_PERSPECTIVE",
+ "MATRIX_2D",
+ "MATRIX_2D_NO_ROT",
+ "MATRIX_3D"
+};
+
+
+/* =============================================================
+ * Reference transformations
+ */
+
+static void ref_transform( GLvector4f *dst,
+ const GLmatrix *mat,
+ const GLvector4f *src )
+{
+ GLuint i;
+ GLfloat *s = (GLfloat *)src->start;
+ GLfloat (*d)[4] = (GLfloat (*)[4])dst->start;
+ const GLfloat *m = mat->m;
+
+ for ( i = 0 ; i < src->count ; i++ ) {
+ TRANSFORM_POINT( d[i], m, s );
+ s = (GLfloat *)((char *)s + src->stride);
+ }
+}
+
+
+/* =============================================================
+ * Vertex transformation tests
+ */
+
+static void init_matrix( GLfloat *m )
+{
+ m[0] = 63.0; m[4] = 43.0; m[ 8] = 29.0; m[12] = 43.0;
+ m[1] = 55.0; m[5] = 17.0; m[ 9] = 31.0; m[13] = 7.0;
+ m[2] = 44.0; m[6] = 9.0; m[10] = 7.0; m[14] = 3.0;
+ m[3] = 11.0; m[7] = 23.0; m[11] = 91.0; m[15] = 9.0;
+}
+
+ALIGN16(static GLfloat, s[TEST_COUNT][4]);
+ALIGN16(static GLfloat, d[TEST_COUNT][4]);
+ALIGN16(static GLfloat, r[TEST_COUNT][4]);
+
+static int test_transform_function( transform_func func, int psize,
+ int mtype, unsigned long *cycles )
+{
+ GLvector4f source[1], dest[1], ref[1];
+ GLmatrix mat[1];
+ GLfloat *m;
+ int i, j;
+#ifdef RUN_DEBUG_BENCHMARK
+ int cycle_i; /* the counter for the benchmarks we run */
+#endif
+
+ (void) cycles;
+
+ if ( psize > 4 ) {
+ _mesa_problem( NULL, "test_transform_function called with psize > 4\n" );
+ return 0;
+ }
+
+ mat->m = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 );
+ mat->type = mtypes[mtype];
+
+ m = mat->m;
+ ASSERT( ((long)m & 15) == 0 );
+
+ init_matrix( m );
+
+ for ( i = 0 ; i < 4 ; i++ ) {
+ for ( j = 0 ; j < 4 ; j++ ) {
+ switch ( templates[mtype][i * 4 + j] ) {
+ case NIL:
+ m[j * 4 + i] = 0.0;
+ break;
+ case ONE:
+ m[j * 4 + i] = 1.0;
+ break;
+ case NEG:
+ m[j * 4 + i] = -1.0;
+ break;
+ case VAR:
+ break;
+ default:
+ abort();
+ }
+ }
+ }
+
+ for ( i = 0 ; i < TEST_COUNT ; i++) {
+ ASSIGN_4V( d[i], 0.0, 0.0, 0.0, 1.0 );
+ ASSIGN_4V( s[i], 0.0, 0.0, 0.0, 1.0 );
+ for ( j = 0 ; j < psize ; j++ )
+ s[i][j] = rnd();
+ }
+
+ source->data = (GLfloat(*)[4])s;
+ source->start = (GLfloat *)s;
+ source->count = TEST_COUNT;
+ source->stride = sizeof(s[0]);
+ source->size = 4;
+ source->flags = 0;
+
+ dest->data = (GLfloat(*)[4])d;
+ dest->start = (GLfloat *)d;
+ dest->count = TEST_COUNT;
+ dest->stride = sizeof(float[4]);
+ dest->size = 0;
+ dest->flags = 0;
+
+ ref->data = (GLfloat(*)[4])r;
+ ref->start = (GLfloat *)r;
+ ref->count = TEST_COUNT;
+ ref->stride = sizeof(float[4]);
+ ref->size = 0;
+ ref->flags = 0;
+
+ ref_transform( ref, mat, source );
+
+ if ( mesa_profile ) {
+ BEGIN_RACE( *cycles );
+ func( dest, mat->m, source );
+ END_RACE( *cycles );
+ }
+ else {
+ func( dest, mat->m, source );
+ }
+
+ for ( i = 0 ; i < TEST_COUNT ; i++ ) {
+ for ( j = 0 ; j < 4 ; j++ ) {
+ if ( significand_match( d[i][j], r[i][j] ) < REQUIRED_PRECISION ) {
+ _mesa_printf("-----------------------------\n" );
+ _mesa_printf("(i = %i, j = %i)\n", i, j );
+ _mesa_printf("%f \t %f \t [diff = %e - %i bit missed]\n",
+ d[i][0], r[i][0], r[i][0]-d[i][0],
+ MAX_PRECISION - significand_match( d[i][0], r[i][0] ) );
+ _mesa_printf("%f \t %f \t [diff = %e - %i bit missed]\n",
+ d[i][1], r[i][1], r[i][1]-d[i][1],
+ MAX_PRECISION - significand_match( d[i][1], r[i][1] ) );
+ _mesa_printf("%f \t %f \t [diff = %e - %i bit missed]\n",
+ d[i][2], r[i][2], r[i][2]-d[i][2],
+ MAX_PRECISION - significand_match( d[i][2], r[i][2] ) );
+ _mesa_printf("%f \t %f \t [diff = %e - %i bit missed]\n",
+ d[i][3], r[i][3], r[i][3]-d[i][3],
+ MAX_PRECISION - significand_match( d[i][3], r[i][3] ) );
+ return 0;
+ }
+ }
+ }
+
+ ALIGN_FREE( mat->m );
+ return 1;
+}
+
+void _math_test_all_transform_functions( char *description )
+{
+ int psize, mtype;
+ unsigned long benchmark_tab[4][7];
+ static int first_time = 1;
+
+ if ( first_time ) {
+ first_time = 0;
+ mesa_profile = getenv( "MESA_PROFILE" );
+ }
+
+#ifdef RUN_DEBUG_BENCHMARK
+ if ( mesa_profile ) {
+ if ( !counter_overhead ) {
+ INIT_COUNTER();
+ _mesa_printf("counter overhead: %lu cycles\n\n", counter_overhead );
+ }
+ _mesa_printf("transform results after hooking in %s functions:\n", description );
+ }
+#endif
+
+#ifdef RUN_DEBUG_BENCHMARK
+ if ( mesa_profile ) {
+ _mesa_printf("\n" );
+ for ( psize = 1 ; psize <= 4 ; psize++ ) {
+ _mesa_printf(" p%d\t", psize );
+ }
+ _mesa_printf("\n--------------------------------------------------------\n" );
+ }
+#endif
+
+ for ( mtype = 0 ; mtype < 7 ; mtype++ ) {
+ for ( psize = 1 ; psize <= 4 ; psize++ ) {
+ transform_func func = _mesa_transform_tab[psize][mtypes[mtype]];
+ unsigned long *cycles = &(benchmark_tab[psize-1][mtype]);
+
+ if ( test_transform_function( func, psize, mtype, cycles ) == 0 ) {
+ char buf[100];
+ _mesa_sprintf(buf, "_mesa_transform_tab[0][%d][%s] failed test (%s)",
+ psize, mstrings[mtype], description );
+ _mesa_problem( NULL, buf );
+ }
+#ifdef RUN_DEBUG_BENCHMARK
+ if ( mesa_profile )
+ _mesa_printf(" %li\t", benchmark_tab[psize-1][mtype] );
+#endif
+ }
+#ifdef RUN_DEBUG_BENCHMARK
+ if ( mesa_profile )
+ _mesa_printf(" | [%s]\n", mstrings[mtype] );
+#endif
+ }
+#ifdef RUN_DEBUG_BENCHMARK
+ if ( mesa_profile )
+ _mesa_printf( "\n" );
+#endif
+}
+
+
+#endif /* DEBUG */
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_dotprod_tmp.h b/nx-X11/extras/Mesa/src/mesa/math/m_dotprod_tmp.h
new file mode 100644
index 000000000..03e65af6c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_dotprod_tmp.h
@@ -0,0 +1,102 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * New (3.1) transformation code written by Keith Whitwell.
+ */
+
+
+/* Note - respects the stride of the output vector.
+ */
+static void TAG(dotprod_vec2)( GLfloat *out,
+ GLuint outstride,
+ const GLvector4f *coord_vec,
+ const GLfloat plane[4] )
+{
+ GLuint stride = coord_vec->stride;
+ GLfloat *coord = coord_vec->start;
+ GLuint count = coord_vec->count;
+
+ GLuint i;
+
+ const GLfloat plane0 = plane[0], plane1 = plane[1], plane3 = plane[3];
+
+ for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(out,outstride)) {
+ *out = (coord[0] * plane0 +
+ coord[1] * plane1 +
+ plane3);
+ }
+}
+
+static void TAG(dotprod_vec3)( GLfloat *out,
+ GLuint outstride,
+ const GLvector4f *coord_vec,
+ const GLfloat plane[4] )
+{
+ GLuint stride = coord_vec->stride;
+ GLfloat *coord = coord_vec->start;
+ GLuint count = coord_vec->count;
+
+ GLuint i;
+
+ const GLfloat plane0 = plane[0], plane1 = plane[1], plane2 = plane[2];
+ const GLfloat plane3 = plane[3];
+
+ for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(out,outstride)) {
+ *out = (coord[0] * plane0 +
+ coord[1] * plane1 +
+ coord[2] * plane2 +
+ plane3);
+ }
+}
+
+static void TAG(dotprod_vec4)( GLfloat *out,
+ GLuint outstride,
+ const GLvector4f *coord_vec,
+ const GLfloat plane[4] )
+{
+ GLuint stride = coord_vec->stride;
+ GLfloat *coord = coord_vec->start;
+ GLuint count = coord_vec->count;
+ GLuint i;
+
+ const GLfloat plane0 = plane[0], plane1 = plane[1], plane2 = plane[2];
+ const GLfloat plane3 = plane[3];
+
+ for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(out,outstride)) {
+ *out = (coord[0] * plane0 +
+ coord[1] * plane1 +
+ coord[2] * plane2 +
+ coord[3] * plane3);
+ }
+}
+
+
+static void TAG(init_dotprod)( void )
+{
+ _mesa_dotprod_tab[2] = TAG(dotprod_vec2);
+ _mesa_dotprod_tab[3] = TAG(dotprod_vec3);
+ _mesa_dotprod_tab[4] = TAG(dotprod_vec4);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_eval.c b/nx-X11/extras/Mesa/src/mesa/math/m_eval.c
new file mode 100644
index 000000000..42ffd4133
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_eval.c
@@ -0,0 +1,461 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+
+/*
+ * eval.c was written by
+ * Bernd Barsuhn (bdbarsuh@cip.informatik.uni-erlangen.de) and
+ * Volker Weiss (vrweiss@cip.informatik.uni-erlangen.de).
+ *
+ * My original implementation of evaluators was simplistic and didn't
+ * compute surface normal vectors properly. Bernd and Volker applied
+ * used more sophisticated methods to get better results.
+ *
+ * Thanks guys!
+ */
+
+
+#include "glheader.h"
+#include "config.h"
+#include "m_eval.h"
+
+static GLfloat inv_tab[MAX_EVAL_ORDER];
+
+
+
+/*
+ * Horner scheme for Bezier curves
+ *
+ * Bezier curves can be computed via a Horner scheme.
+ * Horner is numerically less stable than the de Casteljau
+ * algorithm, but it is faster. For curves of degree n
+ * the complexity of Horner is O(n) and de Casteljau is O(n^2).
+ * Since stability is not important for displaying curve
+ * points I decided to use the Horner scheme.
+ *
+ * A cubic Bezier curve with control points b0, b1, b2, b3 can be
+ * written as
+ *
+ * (([3] [3] ) [3] ) [3]
+ * c(t) = (([0]*s*b0 + [1]*t*b1)*s + [2]*t^2*b2)*s + [3]*t^2*b3
+ *
+ * [n]
+ * where s=1-t and the binomial coefficients [i]. These can
+ * be computed iteratively using the identity:
+ *
+ * [n] [n ] [n]
+ * [i] = (n-i+1)/i * [i-1] and [0] = 1
+ */
+
+
+void
+_math_horner_bezier_curve(const GLfloat * cp, GLfloat * out, GLfloat t,
+ GLuint dim, GLuint order)
+{
+ GLfloat s, powert, bincoeff;
+ GLuint i, k;
+
+ if (order >= 2) {
+ bincoeff = (GLfloat) (order - 1);
+ s = 1.0F - t;
+
+ for (k = 0; k < dim; k++)
+ out[k] = s * cp[k] + bincoeff * t * cp[dim + k];
+
+ for (i = 2, cp += 2 * dim, powert = t * t; i < order;
+ i++, powert *= t, cp += dim) {
+ bincoeff *= (GLfloat) (order - i);
+ bincoeff *= inv_tab[i];
+
+ for (k = 0; k < dim; k++)
+ out[k] = s * out[k] + bincoeff * powert * cp[k];
+ }
+ }
+ else { /* order=1 -> constant curve */
+
+ for (k = 0; k < dim; k++)
+ out[k] = cp[k];
+ }
+}
+
+/*
+ * Tensor product Bezier surfaces
+ *
+ * Again the Horner scheme is used to compute a point on a
+ * TP Bezier surface. First a control polygon for a curve
+ * on the surface in one parameter direction is computed,
+ * then the point on the curve for the other parameter
+ * direction is evaluated.
+ *
+ * To store the curve control polygon additional storage
+ * for max(uorder,vorder) points is needed in the
+ * control net cn.
+ */
+
+void
+_math_horner_bezier_surf(GLfloat * cn, GLfloat * out, GLfloat u, GLfloat v,
+ GLuint dim, GLuint uorder, GLuint vorder)
+{
+ GLfloat *cp = cn + uorder * vorder * dim;
+ GLuint i, uinc = vorder * dim;
+
+ if (vorder > uorder) {
+ if (uorder >= 2) {
+ GLfloat s, poweru, bincoeff;
+ GLuint j, k;
+
+ /* Compute the control polygon for the surface-curve in u-direction */
+ for (j = 0; j < vorder; j++) {
+ GLfloat *ucp = &cn[j * dim];
+
+ /* Each control point is the point for parameter u on a */
+ /* curve defined by the control polygons in u-direction */
+ bincoeff = (GLfloat) (uorder - 1);
+ s = 1.0F - u;
+
+ for (k = 0; k < dim; k++)
+ cp[j * dim + k] = s * ucp[k] + bincoeff * u * ucp[uinc + k];
+
+ for (i = 2, ucp += 2 * uinc, poweru = u * u; i < uorder;
+ i++, poweru *= u, ucp += uinc) {
+ bincoeff *= (GLfloat) (uorder - i);
+ bincoeff *= inv_tab[i];
+
+ for (k = 0; k < dim; k++)
+ cp[j * dim + k] =
+ s * cp[j * dim + k] + bincoeff * poweru * ucp[k];
+ }
+ }
+
+ /* Evaluate curve point in v */
+ _math_horner_bezier_curve(cp, out, v, dim, vorder);
+ }
+ else /* uorder=1 -> cn defines a curve in v */
+ _math_horner_bezier_curve(cn, out, v, dim, vorder);
+ }
+ else { /* vorder <= uorder */
+
+ if (vorder > 1) {
+ GLuint i;
+
+ /* Compute the control polygon for the surface-curve in u-direction */
+ for (i = 0; i < uorder; i++, cn += uinc) {
+ /* For constant i all cn[i][j] (j=0..vorder) are located */
+ /* on consecutive memory locations, so we can use */
+ /* horner_bezier_curve to compute the control points */
+
+ _math_horner_bezier_curve(cn, &cp[i * dim], v, dim, vorder);
+ }
+
+ /* Evaluate curve point in u */
+ _math_horner_bezier_curve(cp, out, u, dim, uorder);
+ }
+ else /* vorder=1 -> cn defines a curve in u */
+ _math_horner_bezier_curve(cn, out, u, dim, uorder);
+ }
+}
+
+/*
+ * The direct de Casteljau algorithm is used when a point on the
+ * surface and the tangent directions spanning the tangent plane
+ * should be computed (this is needed to compute normals to the
+ * surface). In this case the de Casteljau algorithm approach is
+ * nicer because a point and the partial derivatives can be computed
+ * at the same time. To get the correct tangent length du and dv
+ * must be multiplied with the (u2-u1)/uorder-1 and (v2-v1)/vorder-1.
+ * Since only the directions are needed, this scaling step is omitted.
+ *
+ * De Casteljau needs additional storage for uorder*vorder
+ * values in the control net cn.
+ */
+
+void
+_math_de_casteljau_surf(GLfloat * cn, GLfloat * out, GLfloat * du,
+ GLfloat * dv, GLfloat u, GLfloat v, GLuint dim,
+ GLuint uorder, GLuint vorder)
+{
+ GLfloat *dcn = cn + uorder * vorder * dim;
+ GLfloat us = 1.0F - u, vs = 1.0F - v;
+ GLuint h, i, j, k;
+ GLuint minorder = uorder < vorder ? uorder : vorder;
+ GLuint uinc = vorder * dim;
+ GLuint dcuinc = vorder;
+
+ /* Each component is evaluated separately to save buffer space */
+ /* This does not drasticaly decrease the performance of the */
+ /* algorithm. If additional storage for (uorder-1)*(vorder-1) */
+ /* points would be available, the components could be accessed */
+ /* in the innermost loop which could lead to less cache misses. */
+
+#define CN(I,J,K) cn[(I)*uinc+(J)*dim+(K)]
+#define DCN(I, J) dcn[(I)*dcuinc+(J)]
+ if (minorder < 3) {
+ if (uorder == vorder) {
+ for (k = 0; k < dim; k++) {
+ /* Derivative direction in u */
+ du[k] = vs * (CN(1, 0, k) - CN(0, 0, k)) +
+ v * (CN(1, 1, k) - CN(0, 1, k));
+
+ /* Derivative direction in v */
+ dv[k] = us * (CN(0, 1, k) - CN(0, 0, k)) +
+ u * (CN(1, 1, k) - CN(1, 0, k));
+
+ /* bilinear de Casteljau step */
+ out[k] = us * (vs * CN(0, 0, k) + v * CN(0, 1, k)) +
+ u * (vs * CN(1, 0, k) + v * CN(1, 1, k));
+ }
+ }
+ else if (minorder == uorder) {
+ for (k = 0; k < dim; k++) {
+ /* bilinear de Casteljau step */
+ DCN(1, 0) = CN(1, 0, k) - CN(0, 0, k);
+ DCN(0, 0) = us * CN(0, 0, k) + u * CN(1, 0, k);
+
+ for (j = 0; j < vorder - 1; j++) {
+ /* for the derivative in u */
+ DCN(1, j + 1) = CN(1, j + 1, k) - CN(0, j + 1, k);
+ DCN(1, j) = vs * DCN(1, j) + v * DCN(1, j + 1);
+
+ /* for the `point' */
+ DCN(0, j + 1) = us * CN(0, j + 1, k) + u * CN(1, j + 1, k);
+ DCN(0, j) = vs * DCN(0, j) + v * DCN(0, j + 1);
+ }
+
+ /* remaining linear de Casteljau steps until the second last step */
+ for (h = minorder; h < vorder - 1; h++)
+ for (j = 0; j < vorder - h; j++) {
+ /* for the derivative in u */
+ DCN(1, j) = vs * DCN(1, j) + v * DCN(1, j + 1);
+
+ /* for the `point' */
+ DCN(0, j) = vs * DCN(0, j) + v * DCN(0, j + 1);
+ }
+
+ /* derivative direction in v */
+ dv[k] = DCN(0, 1) - DCN(0, 0);
+
+ /* derivative direction in u */
+ du[k] = vs * DCN(1, 0) + v * DCN(1, 1);
+
+ /* last linear de Casteljau step */
+ out[k] = vs * DCN(0, 0) + v * DCN(0, 1);
+ }
+ }
+ else { /* minorder == vorder */
+
+ for (k = 0; k < dim; k++) {
+ /* bilinear de Casteljau step */
+ DCN(0, 1) = CN(0, 1, k) - CN(0, 0, k);
+ DCN(0, 0) = vs * CN(0, 0, k) + v * CN(0, 1, k);
+ for (i = 0; i < uorder - 1; i++) {
+ /* for the derivative in v */
+ DCN(i + 1, 1) = CN(i + 1, 1, k) - CN(i + 1, 0, k);
+ DCN(i, 1) = us * DCN(i, 1) + u * DCN(i + 1, 1);
+
+ /* for the `point' */
+ DCN(i + 1, 0) = vs * CN(i + 1, 0, k) + v * CN(i + 1, 1, k);
+ DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0);
+ }
+
+ /* remaining linear de Casteljau steps until the second last step */
+ for (h = minorder; h < uorder - 1; h++)
+ for (i = 0; i < uorder - h; i++) {
+ /* for the derivative in v */
+ DCN(i, 1) = us * DCN(i, 1) + u * DCN(i + 1, 1);
+
+ /* for the `point' */
+ DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0);
+ }
+
+ /* derivative direction in u */
+ du[k] = DCN(1, 0) - DCN(0, 0);
+
+ /* derivative direction in v */
+ dv[k] = us * DCN(0, 1) + u * DCN(1, 1);
+
+ /* last linear de Casteljau step */
+ out[k] = us * DCN(0, 0) + u * DCN(1, 0);
+ }
+ }
+ }
+ else if (uorder == vorder) {
+ for (k = 0; k < dim; k++) {
+ /* first bilinear de Casteljau step */
+ for (i = 0; i < uorder - 1; i++) {
+ DCN(i, 0) = us * CN(i, 0, k) + u * CN(i + 1, 0, k);
+ for (j = 0; j < vorder - 1; j++) {
+ DCN(i, j + 1) = us * CN(i, j + 1, k) + u * CN(i + 1, j + 1, k);
+ DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1);
+ }
+ }
+
+ /* remaining bilinear de Casteljau steps until the second last step */
+ for (h = 2; h < minorder - 1; h++)
+ for (i = 0; i < uorder - h; i++) {
+ DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0);
+ for (j = 0; j < vorder - h; j++) {
+ DCN(i, j + 1) = us * DCN(i, j + 1) + u * DCN(i + 1, j + 1);
+ DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1);
+ }
+ }
+
+ /* derivative direction in u */
+ du[k] = vs * (DCN(1, 0) - DCN(0, 0)) + v * (DCN(1, 1) - DCN(0, 1));
+
+ /* derivative direction in v */
+ dv[k] = us * (DCN(0, 1) - DCN(0, 0)) + u * (DCN(1, 1) - DCN(1, 0));
+
+ /* last bilinear de Casteljau step */
+ out[k] = us * (vs * DCN(0, 0) + v * DCN(0, 1)) +
+ u * (vs * DCN(1, 0) + v * DCN(1, 1));
+ }
+ }
+ else if (minorder == uorder) {
+ for (k = 0; k < dim; k++) {
+ /* first bilinear de Casteljau step */
+ for (i = 0; i < uorder - 1; i++) {
+ DCN(i, 0) = us * CN(i, 0, k) + u * CN(i + 1, 0, k);
+ for (j = 0; j < vorder - 1; j++) {
+ DCN(i, j + 1) = us * CN(i, j + 1, k) + u * CN(i + 1, j + 1, k);
+ DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1);
+ }
+ }
+
+ /* remaining bilinear de Casteljau steps until the second last step */
+ for (h = 2; h < minorder - 1; h++)
+ for (i = 0; i < uorder - h; i++) {
+ DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0);
+ for (j = 0; j < vorder - h; j++) {
+ DCN(i, j + 1) = us * DCN(i, j + 1) + u * DCN(i + 1, j + 1);
+ DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1);
+ }
+ }
+
+ /* last bilinear de Casteljau step */
+ DCN(2, 0) = DCN(1, 0) - DCN(0, 0);
+ DCN(0, 0) = us * DCN(0, 0) + u * DCN(1, 0);
+ for (j = 0; j < vorder - 1; j++) {
+ /* for the derivative in u */
+ DCN(2, j + 1) = DCN(1, j + 1) - DCN(0, j + 1);
+ DCN(2, j) = vs * DCN(2, j) + v * DCN(2, j + 1);
+
+ /* for the `point' */
+ DCN(0, j + 1) = us * DCN(0, j + 1) + u * DCN(1, j + 1);
+ DCN(0, j) = vs * DCN(0, j) + v * DCN(0, j + 1);
+ }
+
+ /* remaining linear de Casteljau steps until the second last step */
+ for (h = minorder; h < vorder - 1; h++)
+ for (j = 0; j < vorder - h; j++) {
+ /* for the derivative in u */
+ DCN(2, j) = vs * DCN(2, j) + v * DCN(2, j + 1);
+
+ /* for the `point' */
+ DCN(0, j) = vs * DCN(0, j) + v * DCN(0, j + 1);
+ }
+
+ /* derivative direction in v */
+ dv[k] = DCN(0, 1) - DCN(0, 0);
+
+ /* derivative direction in u */
+ du[k] = vs * DCN(2, 0) + v * DCN(2, 1);
+
+ /* last linear de Casteljau step */
+ out[k] = vs * DCN(0, 0) + v * DCN(0, 1);
+ }
+ }
+ else { /* minorder == vorder */
+
+ for (k = 0; k < dim; k++) {
+ /* first bilinear de Casteljau step */
+ for (i = 0; i < uorder - 1; i++) {
+ DCN(i, 0) = us * CN(i, 0, k) + u * CN(i + 1, 0, k);
+ for (j = 0; j < vorder - 1; j++) {
+ DCN(i, j + 1) = us * CN(i, j + 1, k) + u * CN(i + 1, j + 1, k);
+ DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1);
+ }
+ }
+
+ /* remaining bilinear de Casteljau steps until the second last step */
+ for (h = 2; h < minorder - 1; h++)
+ for (i = 0; i < uorder - h; i++) {
+ DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0);
+ for (j = 0; j < vorder - h; j++) {
+ DCN(i, j + 1) = us * DCN(i, j + 1) + u * DCN(i + 1, j + 1);
+ DCN(i, j) = vs * DCN(i, j) + v * DCN(i, j + 1);
+ }
+ }
+
+ /* last bilinear de Casteljau step */
+ DCN(0, 2) = DCN(0, 1) - DCN(0, 0);
+ DCN(0, 0) = vs * DCN(0, 0) + v * DCN(0, 1);
+ for (i = 0; i < uorder - 1; i++) {
+ /* for the derivative in v */
+ DCN(i + 1, 2) = DCN(i + 1, 1) - DCN(i + 1, 0);
+ DCN(i, 2) = us * DCN(i, 2) + u * DCN(i + 1, 2);
+
+ /* for the `point' */
+ DCN(i + 1, 0) = vs * DCN(i + 1, 0) + v * DCN(i + 1, 1);
+ DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0);
+ }
+
+ /* remaining linear de Casteljau steps until the second last step */
+ for (h = minorder; h < uorder - 1; h++)
+ for (i = 0; i < uorder - h; i++) {
+ /* for the derivative in v */
+ DCN(i, 2) = us * DCN(i, 2) + u * DCN(i + 1, 2);
+
+ /* for the `point' */
+ DCN(i, 0) = us * DCN(i, 0) + u * DCN(i + 1, 0);
+ }
+
+ /* derivative direction in u */
+ du[k] = DCN(1, 0) - DCN(0, 0);
+
+ /* derivative direction in v */
+ dv[k] = us * DCN(0, 2) + u * DCN(1, 2);
+
+ /* last linear de Casteljau step */
+ out[k] = us * DCN(0, 0) + u * DCN(1, 0);
+ }
+ }
+#undef DCN
+#undef CN
+}
+
+
+/*
+ * Do one-time initialization for evaluators.
+ */
+void
+_math_init_eval(void)
+{
+ GLuint i;
+
+ /* KW: precompute 1/x for useful x.
+ */
+ for (i = 1; i < MAX_EVAL_ORDER; i++)
+ inv_tab[i] = 1.0F / i;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_eval.h b/nx-X11/extras/Mesa/src/mesa/math/m_eval.h
new file mode 100644
index 000000000..a23cbd402
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_eval.h
@@ -0,0 +1,103 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _M_EVAL_H
+#define _M_EVAL_H
+
+#include "glheader.h"
+
+void _math_init_eval( void );
+
+
+/*
+ * Horner scheme for Bezier curves
+ *
+ * Bezier curves can be computed via a Horner scheme.
+ * Horner is numerically less stable than the de Casteljau
+ * algorithm, but it is faster. For curves of degree n
+ * the complexity of Horner is O(n) and de Casteljau is O(n^2).
+ * Since stability is not important for displaying curve
+ * points I decided to use the Horner scheme.
+ *
+ * A cubic Bezier curve with control points b0, b1, b2, b3 can be
+ * written as
+ *
+ * (([3] [3] ) [3] ) [3]
+ * c(t) = (([0]*s*b0 + [1]*t*b1)*s + [2]*t^2*b2)*s + [3]*t^2*b3
+ *
+ * [n]
+ * where s=1-t and the binomial coefficients [i]. These can
+ * be computed iteratively using the identity:
+ *
+ * [n] [n ] [n]
+ * [i] = (n-i+1)/i * [i-1] and [0] = 1
+ */
+
+
+void
+_math_horner_bezier_curve(const GLfloat *cp, GLfloat *out, GLfloat t,
+ GLuint dim, GLuint order);
+
+
+/*
+ * Tensor product Bezier surfaces
+ *
+ * Again the Horner scheme is used to compute a point on a
+ * TP Bezier surface. First a control polygon for a curve
+ * on the surface in one parameter direction is computed,
+ * then the point on the curve for the other parameter
+ * direction is evaluated.
+ *
+ * To store the curve control polygon additional storage
+ * for max(uorder,vorder) points is needed in the
+ * control net cn.
+ */
+
+void
+_math_horner_bezier_surf(GLfloat *cn, GLfloat *out, GLfloat u, GLfloat v,
+ GLuint dim, GLuint uorder, GLuint vorder);
+
+
+/*
+ * The direct de Casteljau algorithm is used when a point on the
+ * surface and the tangent directions spanning the tangent plane
+ * should be computed (this is needed to compute normals to the
+ * surface). In this case the de Casteljau algorithm approach is
+ * nicer because a point and the partial derivatives can be computed
+ * at the same time. To get the correct tangent length du and dv
+ * must be multiplied with the (u2-u1)/uorder-1 and (v2-v1)/vorder-1.
+ * Since only the directions are needed, this scaling step is omitted.
+ *
+ * De Casteljau needs additional storage for uorder*vorder
+ * values in the control net cn.
+ */
+
+void
+_math_de_casteljau_surf(GLfloat *cn, GLfloat *out, GLfloat *du, GLfloat *dv,
+ GLfloat u, GLfloat v, GLuint dim,
+ GLuint uorder, GLuint vorder);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_matrix.c b/nx-X11/extras/Mesa/src/mesa/math/m_matrix.c
new file mode 100644
index 000000000..408db9b96
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_matrix.c
@@ -0,0 +1,1622 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file m_matrix.c
+ * Matrix operations.
+ *
+ * \note
+ * -# 4x4 transformation matrices are stored in memory in column major order.
+ * -# Points/vertices are to be thought of as column vectors.
+ * -# Transformation of a point p by a matrix M is: p' = M * p
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "macros.h"
+#include "imports.h"
+
+#include "m_matrix.h"
+
+
+/**
+ * \defgroup MatFlags MAT_FLAG_XXX-flags
+ *
+ * Bitmasks to indicate different kinds of 4x4 matrices in GLmatrix::flags
+ * It would be nice to make all these flags private to m_matrix.c
+ */
+/*@{*/
+#define MAT_FLAG_IDENTITY 0 /**< is an identity matrix flag.
+ * (Not actually used - the identity
+ * matrix is identified by the absense
+ * of all other flags.)
+ */
+#define MAT_FLAG_GENERAL 0x1 /**< is a general matrix flag */
+#define MAT_FLAG_ROTATION 0x2 /**< is a rotation matrix flag */
+#define MAT_FLAG_TRANSLATION 0x4 /**< is a translation matrix flag */
+#define MAT_FLAG_UNIFORM_SCALE 0x8 /**< is an uniform scaling matrix flag */
+#define MAT_FLAG_GENERAL_SCALE 0x10 /**< is a general scaling matrix flag */
+#define MAT_FLAG_GENERAL_3D 0x20 /**< general 3D matrix flag */
+#define MAT_FLAG_PERSPECTIVE 0x40 /**< is a perspective proj matrix flag */
+#define MAT_FLAG_SINGULAR 0x80 /**< is a singular matrix flag */
+#define MAT_DIRTY_TYPE 0x100 /**< matrix type is dirty */
+#define MAT_DIRTY_FLAGS 0x200 /**< matrix flags are dirty */
+#define MAT_DIRTY_INVERSE 0x400 /**< matrix inverse is dirty */
+
+/** angle preserving matrix flags mask */
+#define MAT_FLAGS_ANGLE_PRESERVING (MAT_FLAG_ROTATION | \
+ MAT_FLAG_TRANSLATION | \
+ MAT_FLAG_UNIFORM_SCALE)
+
+/** geometry related matrix flags mask */
+#define MAT_FLAGS_GEOMETRY (MAT_FLAG_GENERAL | \
+ MAT_FLAG_ROTATION | \
+ MAT_FLAG_TRANSLATION | \
+ MAT_FLAG_UNIFORM_SCALE | \
+ MAT_FLAG_GENERAL_SCALE | \
+ MAT_FLAG_GENERAL_3D | \
+ MAT_FLAG_PERSPECTIVE | \
+ MAT_FLAG_SINGULAR)
+
+/** length preserving matrix flags mask */
+#define MAT_FLAGS_LENGTH_PRESERVING (MAT_FLAG_ROTATION | \
+ MAT_FLAG_TRANSLATION)
+
+
+/** 3D (non-perspective) matrix flags mask */
+#define MAT_FLAGS_3D (MAT_FLAG_ROTATION | \
+ MAT_FLAG_TRANSLATION | \
+ MAT_FLAG_UNIFORM_SCALE | \
+ MAT_FLAG_GENERAL_SCALE | \
+ MAT_FLAG_GENERAL_3D)
+
+/** dirty matrix flags mask */
+#define MAT_DIRTY (MAT_DIRTY_TYPE | \
+ MAT_DIRTY_FLAGS | \
+ MAT_DIRTY_INVERSE)
+
+/*@}*/
+
+
+/**
+ * Test geometry related matrix flags.
+ *
+ * \param mat a pointer to a GLmatrix structure.
+ * \param a flags mask.
+ *
+ * \returns non-zero if all geometry related matrix flags are contained within
+ * the mask, or zero otherwise.
+ */
+#define TEST_MAT_FLAGS(mat, a) \
+ ((MAT_FLAGS_GEOMETRY & (~(a)) & ((mat)->flags) ) == 0)
+
+
+
+/**
+ * Names of the corresponding GLmatrixtype values.
+ */
+static const char *types[] = {
+ "MATRIX_GENERAL",
+ "MATRIX_IDENTITY",
+ "MATRIX_3D_NO_ROT",
+ "MATRIX_PERSPECTIVE",
+ "MATRIX_2D",
+ "MATRIX_2D_NO_ROT",
+ "MATRIX_3D"
+};
+
+
+/**
+ * Identity matrix.
+ */
+static GLfloat Identity[16] = {
+ 1.0, 0.0, 0.0, 0.0,
+ 0.0, 1.0, 0.0, 0.0,
+ 0.0, 0.0, 1.0, 0.0,
+ 0.0, 0.0, 0.0, 1.0
+};
+
+
+
+/**********************************************************************/
+/** \name Matrix multiplication */
+/*@{*/
+
+#define A(row,col) a[(col<<2)+row]
+#define B(row,col) b[(col<<2)+row]
+#define P(row,col) product[(col<<2)+row]
+
+/**
+ * Perform a full 4x4 matrix multiplication.
+ *
+ * \param a matrix.
+ * \param b matrix.
+ * \param product will receive the product of \p a and \p b.
+ *
+ * \warning Is assumed that \p product != \p b. \p product == \p a is allowed.
+ *
+ * \note KW: 4*16 = 64 multiplications
+ *
+ * \author This \c matmul was contributed by Thomas Malik
+ */
+static void matmul4( GLfloat *product, const GLfloat *a, const GLfloat *b )
+{
+ GLint i;
+ for (i = 0; i < 4; i++) {
+ const GLfloat ai0=A(i,0), ai1=A(i,1), ai2=A(i,2), ai3=A(i,3);
+ P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0) + ai3 * B(3,0);
+ P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1) + ai3 * B(3,1);
+ P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2) + ai3 * B(3,2);
+ P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3 * B(3,3);
+ }
+}
+
+/**
+ * Multiply two matrices known to occupy only the top three rows, such
+ * as typical model matrices, and orthogonal matrices.
+ *
+ * \param a matrix.
+ * \param b matrix.
+ * \param product will receive the product of \p a and \p b.
+ */
+static void matmul34( GLfloat *product, const GLfloat *a, const GLfloat *b )
+{
+ GLint i;
+ for (i = 0; i < 3; i++) {
+ const GLfloat ai0=A(i,0), ai1=A(i,1), ai2=A(i,2), ai3=A(i,3);
+ P(i,0) = ai0 * B(0,0) + ai1 * B(1,0) + ai2 * B(2,0);
+ P(i,1) = ai0 * B(0,1) + ai1 * B(1,1) + ai2 * B(2,1);
+ P(i,2) = ai0 * B(0,2) + ai1 * B(1,2) + ai2 * B(2,2);
+ P(i,3) = ai0 * B(0,3) + ai1 * B(1,3) + ai2 * B(2,3) + ai3;
+ }
+ P(3,0) = 0;
+ P(3,1) = 0;
+ P(3,2) = 0;
+ P(3,3) = 1;
+}
+
+#undef A
+#undef B
+#undef P
+
+/**
+ * Multiply a matrix by an array of floats with known properties.
+ *
+ * \param mat pointer to a GLmatrix structure containing the left multiplication
+ * matrix, and that will receive the product result.
+ * \param m right multiplication matrix array.
+ * \param flags flags of the matrix \p m.
+ *
+ * Joins both flags and marks the type and inverse as dirty. Calls matmul34()
+ * if both matrices are 3D, or matmul4() otherwise.
+ */
+static void matrix_multf( GLmatrix *mat, const GLfloat *m, GLuint flags )
+{
+ mat->flags |= (flags | MAT_DIRTY_TYPE | MAT_DIRTY_INVERSE);
+
+ if (TEST_MAT_FLAGS(mat, MAT_FLAGS_3D))
+ matmul34( mat->m, mat->m, m );
+ else
+ matmul4( mat->m, mat->m, m );
+}
+
+/**
+ * Matrix multiplication.
+ *
+ * \param dest destination matrix.
+ * \param a left matrix.
+ * \param b right matrix.
+ *
+ * Joins both flags and marks the type and inverse as dirty. Calls matmul34()
+ * if both matrices are 3D, or matmul4() otherwise.
+ */
+void
+_math_matrix_mul_matrix( GLmatrix *dest, const GLmatrix *a, const GLmatrix *b )
+{
+ dest->flags = (a->flags |
+ b->flags |
+ MAT_DIRTY_TYPE |
+ MAT_DIRTY_INVERSE);
+
+ if (TEST_MAT_FLAGS(dest, MAT_FLAGS_3D))
+ matmul34( dest->m, a->m, b->m );
+ else
+ matmul4( dest->m, a->m, b->m );
+}
+
+/**
+ * Matrix multiplication.
+ *
+ * \param dest left and destination matrix.
+ * \param m right matrix array.
+ *
+ * Marks the matrix flags with general flag, and type and inverse dirty flags.
+ * Calls matmul4() for the multiplication.
+ */
+void
+_math_matrix_mul_floats( GLmatrix *dest, const GLfloat *m )
+{
+ dest->flags |= (MAT_FLAG_GENERAL |
+ MAT_DIRTY_TYPE |
+ MAT_DIRTY_INVERSE |
+ MAT_DIRTY_FLAGS);
+
+ matmul4( dest->m, dest->m, m );
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Matrix output */
+/*@{*/
+
+/**
+ * Print a matrix array.
+ *
+ * \param m matrix array.
+ *
+ * Called by _math_matrix_print() to print a matrix or its inverse.
+ */
+static void print_matrix_floats( const GLfloat m[16] )
+{
+ int i;
+ for (i=0;i<4;i++) {
+ _mesa_debug(NULL,"\t%f %f %f %f\n", m[i], m[4+i], m[8+i], m[12+i] );
+ }
+}
+
+/**
+ * Dumps the contents of a GLmatrix structure.
+ *
+ * \param m pointer to the GLmatrix structure.
+ */
+void
+_math_matrix_print( const GLmatrix *m )
+{
+ _mesa_debug(NULL, "Matrix type: %s, flags: %x\n", types[m->type], m->flags);
+ print_matrix_floats(m->m);
+ _mesa_debug(NULL, "Inverse: \n");
+ if (m->inv) {
+ GLfloat prod[16];
+ print_matrix_floats(m->inv);
+ matmul4(prod, m->m, m->inv);
+ _mesa_debug(NULL, "Mat * Inverse:\n");
+ print_matrix_floats(prod);
+ }
+ else {
+ _mesa_debug(NULL, " - not available\n");
+ }
+}
+
+/*@}*/
+
+
+/**
+ * References an element of 4x4 matrix.
+ *
+ * \param m matrix array.
+ * \param c column of the desired element.
+ * \param r row of the desired element.
+ *
+ * \return value of the desired element.
+ *
+ * Calculate the linear storage index of the element and references it.
+ */
+#define MAT(m,r,c) (m)[(c)*4+(r)]
+
+
+/**********************************************************************/
+/** \name Matrix inversion */
+/*@{*/
+
+/**
+ * Swaps the values of two floating pointer variables.
+ *
+ * Used by invert_matrix_general() to swap the row pointers.
+ */
+#define SWAP_ROWS(a, b) { GLfloat *_tmp = a; (a)=(b); (b)=_tmp; }
+
+/**
+ * Compute inverse of 4x4 transformation matrix.
+ *
+ * \param mat pointer to a GLmatrix structure. The matrix inverse will be
+ * stored in the GLmatrix::inv attribute.
+ *
+ * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix).
+ *
+ * \author
+ * Code contributed by Jacques Leroy jle@star.be
+ *
+ * Calculates the inverse matrix by performing the gaussian matrix reduction
+ * with partial pivoting followed by back/substitution with the loops manually
+ * unrolled.
+ */
+static GLboolean invert_matrix_general( GLmatrix *mat )
+{
+ const GLfloat *m = mat->m;
+ GLfloat *out = mat->inv;
+ GLfloat wtmp[4][8];
+ GLfloat m0, m1, m2, m3, s;
+ GLfloat *r0, *r1, *r2, *r3;
+
+ r0 = wtmp[0], r1 = wtmp[1], r2 = wtmp[2], r3 = wtmp[3];
+
+ r0[0] = MAT(m,0,0), r0[1] = MAT(m,0,1),
+ r0[2] = MAT(m,0,2), r0[3] = MAT(m,0,3),
+ r0[4] = 1.0, r0[5] = r0[6] = r0[7] = 0.0,
+
+ r1[0] = MAT(m,1,0), r1[1] = MAT(m,1,1),
+ r1[2] = MAT(m,1,2), r1[3] = MAT(m,1,3),
+ r1[5] = 1.0, r1[4] = r1[6] = r1[7] = 0.0,
+
+ r2[0] = MAT(m,2,0), r2[1] = MAT(m,2,1),
+ r2[2] = MAT(m,2,2), r2[3] = MAT(m,2,3),
+ r2[6] = 1.0, r2[4] = r2[5] = r2[7] = 0.0,
+
+ r3[0] = MAT(m,3,0), r3[1] = MAT(m,3,1),
+ r3[2] = MAT(m,3,2), r3[3] = MAT(m,3,3),
+ r3[7] = 1.0, r3[4] = r3[5] = r3[6] = 0.0;
+
+ /* choose pivot - or die */
+ if (fabs(r3[0])>fabs(r2[0])) SWAP_ROWS(r3, r2);
+ if (fabs(r2[0])>fabs(r1[0])) SWAP_ROWS(r2, r1);
+ if (fabs(r1[0])>fabs(r0[0])) SWAP_ROWS(r1, r0);
+ if (0.0 == r0[0]) return GL_FALSE;
+
+ /* eliminate first variable */
+ m1 = r1[0]/r0[0]; m2 = r2[0]/r0[0]; m3 = r3[0]/r0[0];
+ s = r0[1]; r1[1] -= m1 * s; r2[1] -= m2 * s; r3[1] -= m3 * s;
+ s = r0[2]; r1[2] -= m1 * s; r2[2] -= m2 * s; r3[2] -= m3 * s;
+ s = r0[3]; r1[3] -= m1 * s; r2[3] -= m2 * s; r3[3] -= m3 * s;
+ s = r0[4];
+ if (s != 0.0) { r1[4] -= m1 * s; r2[4] -= m2 * s; r3[4] -= m3 * s; }
+ s = r0[5];
+ if (s != 0.0) { r1[5] -= m1 * s; r2[5] -= m2 * s; r3[5] -= m3 * s; }
+ s = r0[6];
+ if (s != 0.0) { r1[6] -= m1 * s; r2[6] -= m2 * s; r3[6] -= m3 * s; }
+ s = r0[7];
+ if (s != 0.0) { r1[7] -= m1 * s; r2[7] -= m2 * s; r3[7] -= m3 * s; }
+
+ /* choose pivot - or die */
+ if (fabs(r3[1])>fabs(r2[1])) SWAP_ROWS(r3, r2);
+ if (fabs(r2[1])>fabs(r1[1])) SWAP_ROWS(r2, r1);
+ if (0.0 == r1[1]) return GL_FALSE;
+
+ /* eliminate second variable */
+ m2 = r2[1]/r1[1]; m3 = r3[1]/r1[1];
+ r2[2] -= m2 * r1[2]; r3[2] -= m3 * r1[2];
+ r2[3] -= m2 * r1[3]; r3[3] -= m3 * r1[3];
+ s = r1[4]; if (0.0 != s) { r2[4] -= m2 * s; r3[4] -= m3 * s; }
+ s = r1[5]; if (0.0 != s) { r2[5] -= m2 * s; r3[5] -= m3 * s; }
+ s = r1[6]; if (0.0 != s) { r2[6] -= m2 * s; r3[6] -= m3 * s; }
+ s = r1[7]; if (0.0 != s) { r2[7] -= m2 * s; r3[7] -= m3 * s; }
+
+ /* choose pivot - or die */
+ if (fabs(r3[2])>fabs(r2[2])) SWAP_ROWS(r3, r2);
+ if (0.0 == r2[2]) return GL_FALSE;
+
+ /* eliminate third variable */
+ m3 = r3[2]/r2[2];
+ r3[3] -= m3 * r2[3], r3[4] -= m3 * r2[4],
+ r3[5] -= m3 * r2[5], r3[6] -= m3 * r2[6],
+ r3[7] -= m3 * r2[7];
+
+ /* last check */
+ if (0.0 == r3[3]) return GL_FALSE;
+
+ s = 1.0F/r3[3]; /* now back substitute row 3 */
+ r3[4] *= s; r3[5] *= s; r3[6] *= s; r3[7] *= s;
+
+ m2 = r2[3]; /* now back substitute row 2 */
+ s = 1.0F/r2[2];
+ r2[4] = s * (r2[4] - r3[4] * m2), r2[5] = s * (r2[5] - r3[5] * m2),
+ r2[6] = s * (r2[6] - r3[6] * m2), r2[7] = s * (r2[7] - r3[7] * m2);
+ m1 = r1[3];
+ r1[4] -= r3[4] * m1, r1[5] -= r3[5] * m1,
+ r1[6] -= r3[6] * m1, r1[7] -= r3[7] * m1;
+ m0 = r0[3];
+ r0[4] -= r3[4] * m0, r0[5] -= r3[5] * m0,
+ r0[6] -= r3[6] * m0, r0[7] -= r3[7] * m0;
+
+ m1 = r1[2]; /* now back substitute row 1 */
+ s = 1.0F/r1[1];
+ r1[4] = s * (r1[4] - r2[4] * m1), r1[5] = s * (r1[5] - r2[5] * m1),
+ r1[6] = s * (r1[6] - r2[6] * m1), r1[7] = s * (r1[7] - r2[7] * m1);
+ m0 = r0[2];
+ r0[4] -= r2[4] * m0, r0[5] -= r2[5] * m0,
+ r0[6] -= r2[6] * m0, r0[7] -= r2[7] * m0;
+
+ m0 = r0[1]; /* now back substitute row 0 */
+ s = 1.0F/r0[0];
+ r0[4] = s * (r0[4] - r1[4] * m0), r0[5] = s * (r0[5] - r1[5] * m0),
+ r0[6] = s * (r0[6] - r1[6] * m0), r0[7] = s * (r0[7] - r1[7] * m0);
+
+ MAT(out,0,0) = r0[4]; MAT(out,0,1) = r0[5],
+ MAT(out,0,2) = r0[6]; MAT(out,0,3) = r0[7],
+ MAT(out,1,0) = r1[4]; MAT(out,1,1) = r1[5],
+ MAT(out,1,2) = r1[6]; MAT(out,1,3) = r1[7],
+ MAT(out,2,0) = r2[4]; MAT(out,2,1) = r2[5],
+ MAT(out,2,2) = r2[6]; MAT(out,2,3) = r2[7],
+ MAT(out,3,0) = r3[4]; MAT(out,3,1) = r3[5],
+ MAT(out,3,2) = r3[6]; MAT(out,3,3) = r3[7];
+
+ return GL_TRUE;
+}
+#undef SWAP_ROWS
+
+/**
+ * Compute inverse of a general 3d transformation matrix.
+ *
+ * \param mat pointer to a GLmatrix structure. The matrix inverse will be
+ * stored in the GLmatrix::inv attribute.
+ *
+ * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix).
+ *
+ * \author Adapted from graphics gems II.
+ *
+ * Calculates the inverse of the upper left by first calculating its
+ * determinant and multiplying it to the symmetric adjust matrix of each
+ * element. Finally deals with the translation part by transforming the
+ * original translation vector using by the calculated submatrix inverse.
+ */
+static GLboolean invert_matrix_3d_general( GLmatrix *mat )
+{
+ const GLfloat *in = mat->m;
+ GLfloat *out = mat->inv;
+ GLfloat pos, neg, t;
+ GLfloat det;
+
+ /* Calculate the determinant of upper left 3x3 submatrix and
+ * determine if the matrix is singular.
+ */
+ pos = neg = 0.0;
+ t = MAT(in,0,0) * MAT(in,1,1) * MAT(in,2,2);
+ if (t >= 0.0) pos += t; else neg += t;
+
+ t = MAT(in,1,0) * MAT(in,2,1) * MAT(in,0,2);
+ if (t >= 0.0) pos += t; else neg += t;
+
+ t = MAT(in,2,0) * MAT(in,0,1) * MAT(in,1,2);
+ if (t >= 0.0) pos += t; else neg += t;
+
+ t = -MAT(in,2,0) * MAT(in,1,1) * MAT(in,0,2);
+ if (t >= 0.0) pos += t; else neg += t;
+
+ t = -MAT(in,1,0) * MAT(in,0,1) * MAT(in,2,2);
+ if (t >= 0.0) pos += t; else neg += t;
+
+ t = -MAT(in,0,0) * MAT(in,2,1) * MAT(in,1,2);
+ if (t >= 0.0) pos += t; else neg += t;
+
+ det = pos + neg;
+
+ if (det*det < 1e-25)
+ return GL_FALSE;
+
+ det = 1.0F / det;
+ MAT(out,0,0) = ( (MAT(in,1,1)*MAT(in,2,2) - MAT(in,2,1)*MAT(in,1,2) )*det);
+ MAT(out,0,1) = (- (MAT(in,0,1)*MAT(in,2,2) - MAT(in,2,1)*MAT(in,0,2) )*det);
+ MAT(out,0,2) = ( (MAT(in,0,1)*MAT(in,1,2) - MAT(in,1,1)*MAT(in,0,2) )*det);
+ MAT(out,1,0) = (- (MAT(in,1,0)*MAT(in,2,2) - MAT(in,2,0)*MAT(in,1,2) )*det);
+ MAT(out,1,1) = ( (MAT(in,0,0)*MAT(in,2,2) - MAT(in,2,0)*MAT(in,0,2) )*det);
+ MAT(out,1,2) = (- (MAT(in,0,0)*MAT(in,1,2) - MAT(in,1,0)*MAT(in,0,2) )*det);
+ MAT(out,2,0) = ( (MAT(in,1,0)*MAT(in,2,1) - MAT(in,2,0)*MAT(in,1,1) )*det);
+ MAT(out,2,1) = (- (MAT(in,0,0)*MAT(in,2,1) - MAT(in,2,0)*MAT(in,0,1) )*det);
+ MAT(out,2,2) = ( (MAT(in,0,0)*MAT(in,1,1) - MAT(in,1,0)*MAT(in,0,1) )*det);
+
+ /* Do the translation part */
+ MAT(out,0,3) = - (MAT(in,0,3) * MAT(out,0,0) +
+ MAT(in,1,3) * MAT(out,0,1) +
+ MAT(in,2,3) * MAT(out,0,2) );
+ MAT(out,1,3) = - (MAT(in,0,3) * MAT(out,1,0) +
+ MAT(in,1,3) * MAT(out,1,1) +
+ MAT(in,2,3) * MAT(out,1,2) );
+ MAT(out,2,3) = - (MAT(in,0,3) * MAT(out,2,0) +
+ MAT(in,1,3) * MAT(out,2,1) +
+ MAT(in,2,3) * MAT(out,2,2) );
+
+ return GL_TRUE;
+}
+
+/**
+ * Compute inverse of a 3d transformation matrix.
+ *
+ * \param mat pointer to a GLmatrix structure. The matrix inverse will be
+ * stored in the GLmatrix::inv attribute.
+ *
+ * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix).
+ *
+ * If the matrix is not an angle preserving matrix then calls
+ * invert_matrix_3d_general for the actual calculation. Otherwise calculates
+ * the inverse matrix analyzing and inverting each of the scaling, rotation and
+ * translation parts.
+ */
+static GLboolean invert_matrix_3d( GLmatrix *mat )
+{
+ const GLfloat *in = mat->m;
+ GLfloat *out = mat->inv;
+
+ if (!TEST_MAT_FLAGS(mat, MAT_FLAGS_ANGLE_PRESERVING)) {
+ return invert_matrix_3d_general( mat );
+ }
+
+ if (mat->flags & MAT_FLAG_UNIFORM_SCALE) {
+ GLfloat scale = (MAT(in,0,0) * MAT(in,0,0) +
+ MAT(in,0,1) * MAT(in,0,1) +
+ MAT(in,0,2) * MAT(in,0,2));
+
+ if (scale == 0.0)
+ return GL_FALSE;
+
+ scale = 1.0F / scale;
+
+ /* Transpose and scale the 3 by 3 upper-left submatrix. */
+ MAT(out,0,0) = scale * MAT(in,0,0);
+ MAT(out,1,0) = scale * MAT(in,0,1);
+ MAT(out,2,0) = scale * MAT(in,0,2);
+ MAT(out,0,1) = scale * MAT(in,1,0);
+ MAT(out,1,1) = scale * MAT(in,1,1);
+ MAT(out,2,1) = scale * MAT(in,1,2);
+ MAT(out,0,2) = scale * MAT(in,2,0);
+ MAT(out,1,2) = scale * MAT(in,2,1);
+ MAT(out,2,2) = scale * MAT(in,2,2);
+ }
+ else if (mat->flags & MAT_FLAG_ROTATION) {
+ /* Transpose the 3 by 3 upper-left submatrix. */
+ MAT(out,0,0) = MAT(in,0,0);
+ MAT(out,1,0) = MAT(in,0,1);
+ MAT(out,2,0) = MAT(in,0,2);
+ MAT(out,0,1) = MAT(in,1,0);
+ MAT(out,1,1) = MAT(in,1,1);
+ MAT(out,2,1) = MAT(in,1,2);
+ MAT(out,0,2) = MAT(in,2,0);
+ MAT(out,1,2) = MAT(in,2,1);
+ MAT(out,2,2) = MAT(in,2,2);
+ }
+ else {
+ /* pure translation */
+ MEMCPY( out, Identity, sizeof(Identity) );
+ MAT(out,0,3) = - MAT(in,0,3);
+ MAT(out,1,3) = - MAT(in,1,3);
+ MAT(out,2,3) = - MAT(in,2,3);
+ return GL_TRUE;
+ }
+
+ if (mat->flags & MAT_FLAG_TRANSLATION) {
+ /* Do the translation part */
+ MAT(out,0,3) = - (MAT(in,0,3) * MAT(out,0,0) +
+ MAT(in,1,3) * MAT(out,0,1) +
+ MAT(in,2,3) * MAT(out,0,2) );
+ MAT(out,1,3) = - (MAT(in,0,3) * MAT(out,1,0) +
+ MAT(in,1,3) * MAT(out,1,1) +
+ MAT(in,2,3) * MAT(out,1,2) );
+ MAT(out,2,3) = - (MAT(in,0,3) * MAT(out,2,0) +
+ MAT(in,1,3) * MAT(out,2,1) +
+ MAT(in,2,3) * MAT(out,2,2) );
+ }
+ else {
+ MAT(out,0,3) = MAT(out,1,3) = MAT(out,2,3) = 0.0;
+ }
+
+ return GL_TRUE;
+}
+
+/**
+ * Compute inverse of an identity transformation matrix.
+ *
+ * \param mat pointer to a GLmatrix structure. The matrix inverse will be
+ * stored in the GLmatrix::inv attribute.
+ *
+ * \return always GL_TRUE.
+ *
+ * Simply copies Identity into GLmatrix::inv.
+ */
+static GLboolean invert_matrix_identity( GLmatrix *mat )
+{
+ MEMCPY( mat->inv, Identity, sizeof(Identity) );
+ return GL_TRUE;
+}
+
+/**
+ * Compute inverse of a no-rotation 3d transformation matrix.
+ *
+ * \param mat pointer to a GLmatrix structure. The matrix inverse will be
+ * stored in the GLmatrix::inv attribute.
+ *
+ * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix).
+ *
+ * Calculates the
+ */
+static GLboolean invert_matrix_3d_no_rot( GLmatrix *mat )
+{
+ const GLfloat *in = mat->m;
+ GLfloat *out = mat->inv;
+
+ if (MAT(in,0,0) == 0 || MAT(in,1,1) == 0 || MAT(in,2,2) == 0 )
+ return GL_FALSE;
+
+ MEMCPY( out, Identity, 16 * sizeof(GLfloat) );
+ MAT(out,0,0) = 1.0F / MAT(in,0,0);
+ MAT(out,1,1) = 1.0F / MAT(in,1,1);
+ MAT(out,2,2) = 1.0F / MAT(in,2,2);
+
+ if (mat->flags & MAT_FLAG_TRANSLATION) {
+ MAT(out,0,3) = - (MAT(in,0,3) * MAT(out,0,0));
+ MAT(out,1,3) = - (MAT(in,1,3) * MAT(out,1,1));
+ MAT(out,2,3) = - (MAT(in,2,3) * MAT(out,2,2));
+ }
+
+ return GL_TRUE;
+}
+
+/**
+ * Compute inverse of a no-rotation 2d transformation matrix.
+ *
+ * \param mat pointer to a GLmatrix structure. The matrix inverse will be
+ * stored in the GLmatrix::inv attribute.
+ *
+ * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix).
+ *
+ * Calculates the inverse matrix by applying the inverse scaling and
+ * translation to the identity matrix.
+ */
+static GLboolean invert_matrix_2d_no_rot( GLmatrix *mat )
+{
+ const GLfloat *in = mat->m;
+ GLfloat *out = mat->inv;
+
+ if (MAT(in,0,0) == 0 || MAT(in,1,1) == 0)
+ return GL_FALSE;
+
+ MEMCPY( out, Identity, 16 * sizeof(GLfloat) );
+ MAT(out,0,0) = 1.0F / MAT(in,0,0);
+ MAT(out,1,1) = 1.0F / MAT(in,1,1);
+
+ if (mat->flags & MAT_FLAG_TRANSLATION) {
+ MAT(out,0,3) = - (MAT(in,0,3) * MAT(out,0,0));
+ MAT(out,1,3) = - (MAT(in,1,3) * MAT(out,1,1));
+ }
+
+ return GL_TRUE;
+}
+
+#if 0
+/* broken */
+static GLboolean invert_matrix_perspective( GLmatrix *mat )
+{
+ const GLfloat *in = mat->m;
+ GLfloat *out = mat->inv;
+
+ if (MAT(in,2,3) == 0)
+ return GL_FALSE;
+
+ MEMCPY( out, Identity, 16 * sizeof(GLfloat) );
+
+ MAT(out,0,0) = 1.0F / MAT(in,0,0);
+ MAT(out,1,1) = 1.0F / MAT(in,1,1);
+
+ MAT(out,0,3) = MAT(in,0,2);
+ MAT(out,1,3) = MAT(in,1,2);
+
+ MAT(out,2,2) = 0;
+ MAT(out,2,3) = -1;
+
+ MAT(out,3,2) = 1.0F / MAT(in,2,3);
+ MAT(out,3,3) = MAT(in,2,2) * MAT(out,3,2);
+
+ return GL_TRUE;
+}
+#endif
+
+/**
+ * Matrix inversion function pointer type.
+ */
+typedef GLboolean (*inv_mat_func)( GLmatrix *mat );
+
+/**
+ * Table of the matrix inversion functions according to the matrix type.
+ */
+static inv_mat_func inv_mat_tab[7] = {
+ invert_matrix_general,
+ invert_matrix_identity,
+ invert_matrix_3d_no_rot,
+#if 0
+ /* Don't use this function for now - it fails when the projection matrix
+ * is premultiplied by a translation (ala Chromium's tilesort SPU).
+ */
+ invert_matrix_perspective,
+#else
+ invert_matrix_general,
+#endif
+ invert_matrix_3d, /* lazy! */
+ invert_matrix_2d_no_rot,
+ invert_matrix_3d
+};
+
+/**
+ * Compute inverse of a transformation matrix.
+ *
+ * \param mat pointer to a GLmatrix structure. The matrix inverse will be
+ * stored in the GLmatrix::inv attribute.
+ *
+ * \return GL_TRUE for success, GL_FALSE for failure (\p singular matrix).
+ *
+ * Calls the matrix inversion function in inv_mat_tab corresponding to the
+ * given matrix type. In case of failure, updates the MAT_FLAG_SINGULAR flag,
+ * and copies the identity matrix into GLmatrix::inv.
+ */
+static GLboolean matrix_invert( GLmatrix *mat )
+{
+ if (inv_mat_tab[mat->type](mat)) {
+ mat->flags &= ~MAT_FLAG_SINGULAR;
+ return GL_TRUE;
+ } else {
+ mat->flags |= MAT_FLAG_SINGULAR;
+ MEMCPY( mat->inv, Identity, sizeof(Identity) );
+ return GL_FALSE;
+ }
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Matrix generation */
+/*@{*/
+
+/**
+ * Generate a 4x4 transformation matrix from glRotate parameters, and
+ * post-multiply the input matrix by it.
+ *
+ * \author
+ * This function was contributed by Erich Boleyn (erich@uruk.org).
+ * Optimizations contributed by Rudolf Opalla (rudi@khm.de).
+ */
+void
+_math_matrix_rotate( GLmatrix *mat,
+ GLfloat angle, GLfloat x, GLfloat y, GLfloat z )
+{
+ GLfloat xx, yy, zz, xy, yz, zx, xs, ys, zs, one_c, s, c;
+ GLfloat m[16];
+ GLboolean optimized;
+
+ s = (GLfloat) sin( angle * DEG2RAD );
+ c = (GLfloat) cos( angle * DEG2RAD );
+
+ MEMCPY(m, Identity, sizeof(GLfloat)*16);
+ optimized = GL_FALSE;
+
+#define M(row,col) m[col*4+row]
+
+ if (x == 0.0F) {
+ if (y == 0.0F) {
+ if (z != 0.0F) {
+ optimized = GL_TRUE;
+ /* rotate only around z-axis */
+ M(0,0) = c;
+ M(1,1) = c;
+ if (z < 0.0F) {
+ M(0,1) = s;
+ M(1,0) = -s;
+ }
+ else {
+ M(0,1) = -s;
+ M(1,0) = s;
+ }
+ }
+ }
+ else if (z == 0.0F) {
+ optimized = GL_TRUE;
+ /* rotate only around y-axis */
+ M(0,0) = c;
+ M(2,2) = c;
+ if (y < 0.0F) {
+ M(0,2) = -s;
+ M(2,0) = s;
+ }
+ else {
+ M(0,2) = s;
+ M(2,0) = -s;
+ }
+ }
+ }
+ else if (y == 0.0F) {
+ if (z == 0.0F) {
+ optimized = GL_TRUE;
+ /* rotate only around x-axis */
+ M(1,1) = c;
+ M(2,2) = c;
+ if (x < 0.0F) {
+ M(1,2) = s;
+ M(2,1) = -s;
+ }
+ else {
+ M(1,2) = -s;
+ M(2,1) = s;
+ }
+ }
+ }
+
+ if (!optimized) {
+ const GLfloat mag = SQRTF(x * x + y * y + z * z);
+
+ if (mag <= 1.0e-4) {
+ /* no rotation, leave mat as-is */
+ return;
+ }
+
+ x /= mag;
+ y /= mag;
+ z /= mag;
+
+
+ /*
+ * Arbitrary axis rotation matrix.
+ *
+ * This is composed of 5 matrices, Rz, Ry, T, Ry', Rz', multiplied
+ * like so: Rz * Ry * T * Ry' * Rz'. T is the final rotation
+ * (which is about the X-axis), and the two composite transforms
+ * Ry' * Rz' and Rz * Ry are (respectively) the rotations necessary
+ * from the arbitrary axis to the X-axis then back. They are
+ * all elementary rotations.
+ *
+ * Rz' is a rotation about the Z-axis, to bring the axis vector
+ * into the x-z plane. Then Ry' is applied, rotating about the
+ * Y-axis to bring the axis vector parallel with the X-axis. The
+ * rotation about the X-axis is then performed. Ry and Rz are
+ * simply the respective inverse transforms to bring the arbitrary
+ * axis back to it's original orientation. The first transforms
+ * Rz' and Ry' are considered inverses, since the data from the
+ * arbitrary axis gives you info on how to get to it, not how
+ * to get away from it, and an inverse must be applied.
+ *
+ * The basic calculation used is to recognize that the arbitrary
+ * axis vector (x, y, z), since it is of unit length, actually
+ * represents the sines and cosines of the angles to rotate the
+ * X-axis to the same orientation, with theta being the angle about
+ * Z and phi the angle about Y (in the order described above)
+ * as follows:
+ *
+ * cos ( theta ) = x / sqrt ( 1 - z^2 )
+ * sin ( theta ) = y / sqrt ( 1 - z^2 )
+ *
+ * cos ( phi ) = sqrt ( 1 - z^2 )
+ * sin ( phi ) = z
+ *
+ * Note that cos ( phi ) can further be inserted to the above
+ * formulas:
+ *
+ * cos ( theta ) = x / cos ( phi )
+ * sin ( theta ) = y / sin ( phi )
+ *
+ * ...etc. Because of those relations and the standard trigonometric
+ * relations, it is pssible to reduce the transforms down to what
+ * is used below. It may be that any primary axis chosen will give the
+ * same results (modulo a sign convention) using thie method.
+ *
+ * Particularly nice is to notice that all divisions that might
+ * have caused trouble when parallel to certain planes or
+ * axis go away with care paid to reducing the expressions.
+ * After checking, it does perform correctly under all cases, since
+ * in all the cases of division where the denominator would have
+ * been zero, the numerator would have been zero as well, giving
+ * the expected result.
+ */
+
+ xx = x * x;
+ yy = y * y;
+ zz = z * z;
+ xy = x * y;
+ yz = y * z;
+ zx = z * x;
+ xs = x * s;
+ ys = y * s;
+ zs = z * s;
+ one_c = 1.0F - c;
+
+ /* We already hold the identity-matrix so we can skip some statements */
+ M(0,0) = (one_c * xx) + c;
+ M(0,1) = (one_c * xy) - zs;
+ M(0,2) = (one_c * zx) + ys;
+/* M(0,3) = 0.0F; */
+
+ M(1,0) = (one_c * xy) + zs;
+ M(1,1) = (one_c * yy) + c;
+ M(1,2) = (one_c * yz) - xs;
+/* M(1,3) = 0.0F; */
+
+ M(2,0) = (one_c * zx) - ys;
+ M(2,1) = (one_c * yz) + xs;
+ M(2,2) = (one_c * zz) + c;
+/* M(2,3) = 0.0F; */
+
+/*
+ M(3,0) = 0.0F;
+ M(3,1) = 0.0F;
+ M(3,2) = 0.0F;
+ M(3,3) = 1.0F;
+*/
+ }
+#undef M
+
+ matrix_multf( mat, m, MAT_FLAG_ROTATION );
+}
+
+/**
+ * Apply a perspective projection matrix.
+ *
+ * \param mat matrix to apply the projection.
+ * \param left left clipping plane coordinate.
+ * \param right right clipping plane coordinate.
+ * \param bottom bottom clipping plane coordinate.
+ * \param top top clipping plane coordinate.
+ * \param nearval distance to the near clipping plane.
+ * \param farval distance to the far clipping plane.
+ *
+ * Creates the projection matrix and multiplies it with \p mat, marking the
+ * MAT_FLAG_PERSPECTIVE flag.
+ */
+void
+_math_matrix_frustum( GLmatrix *mat,
+ GLfloat left, GLfloat right,
+ GLfloat bottom, GLfloat top,
+ GLfloat nearval, GLfloat farval )
+{
+ GLfloat x, y, a, b, c, d;
+ GLfloat m[16];
+
+ x = (2.0F*nearval) / (right-left);
+ y = (2.0F*nearval) / (top-bottom);
+ a = (right+left) / (right-left);
+ b = (top+bottom) / (top-bottom);
+ c = -(farval+nearval) / ( farval-nearval);
+ d = -(2.0F*farval*nearval) / (farval-nearval); /* error? */
+
+#define M(row,col) m[col*4+row]
+ M(0,0) = x; M(0,1) = 0.0F; M(0,2) = a; M(0,3) = 0.0F;
+ M(1,0) = 0.0F; M(1,1) = y; M(1,2) = b; M(1,3) = 0.0F;
+ M(2,0) = 0.0F; M(2,1) = 0.0F; M(2,2) = c; M(2,3) = d;
+ M(3,0) = 0.0F; M(3,1) = 0.0F; M(3,2) = -1.0F; M(3,3) = 0.0F;
+#undef M
+
+ matrix_multf( mat, m, MAT_FLAG_PERSPECTIVE );
+}
+
+/**
+ * Apply an orthographic projection matrix.
+ *
+ * \param mat matrix to apply the projection.
+ * \param left left clipping plane coordinate.
+ * \param right right clipping plane coordinate.
+ * \param bottom bottom clipping plane coordinate.
+ * \param top top clipping plane coordinate.
+ * \param nearval distance to the near clipping plane.
+ * \param farval distance to the far clipping plane.
+ *
+ * Creates the projection matrix and multiplies it with \p mat, marking the
+ * MAT_FLAG_GENERAL_SCALE and MAT_FLAG_TRANSLATION flags.
+ */
+void
+_math_matrix_ortho( GLmatrix *mat,
+ GLfloat left, GLfloat right,
+ GLfloat bottom, GLfloat top,
+ GLfloat nearval, GLfloat farval )
+{
+ GLfloat m[16];
+
+#define M(row,col) m[col*4+row]
+ M(0,0) = 2.0F / (right-left);
+ M(0,1) = 0.0F;
+ M(0,2) = 0.0F;
+ M(0,3) = -(right+left) / (right-left);
+
+ M(1,0) = 0.0F;
+ M(1,1) = 2.0F / (top-bottom);
+ M(1,2) = 0.0F;
+ M(1,3) = -(top+bottom) / (top-bottom);
+
+ M(2,0) = 0.0F;
+ M(2,1) = 0.0F;
+ M(2,2) = -2.0F / (farval-nearval);
+ M(2,3) = -(farval+nearval) / (farval-nearval);
+
+ M(3,0) = 0.0F;
+ M(3,1) = 0.0F;
+ M(3,2) = 0.0F;
+ M(3,3) = 1.0F;
+#undef M
+
+ matrix_multf( mat, m, (MAT_FLAG_GENERAL_SCALE|MAT_FLAG_TRANSLATION));
+}
+
+/**
+ * Multiply a matrix with a general scaling matrix.
+ *
+ * \param mat matrix.
+ * \param x x axis scale factor.
+ * \param y y axis scale factor.
+ * \param z z axis scale factor.
+ *
+ * Multiplies in-place the elements of \p mat by the scale factors. Checks if
+ * the scales factors are roughly the same, marking the MAT_FLAG_UNIFORM_SCALE
+ * flag, or MAT_FLAG_GENERAL_SCALE. Marks the MAT_DIRTY_TYPE and
+ * MAT_DIRTY_INVERSE dirty flags.
+ */
+void
+_math_matrix_scale( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z )
+{
+ GLfloat *m = mat->m;
+ m[0] *= x; m[4] *= y; m[8] *= z;
+ m[1] *= x; m[5] *= y; m[9] *= z;
+ m[2] *= x; m[6] *= y; m[10] *= z;
+ m[3] *= x; m[7] *= y; m[11] *= z;
+
+ if (fabs(x - y) < 1e-8 && fabs(x - z) < 1e-8)
+ mat->flags |= MAT_FLAG_UNIFORM_SCALE;
+ else
+ mat->flags |= MAT_FLAG_GENERAL_SCALE;
+
+ mat->flags |= (MAT_DIRTY_TYPE |
+ MAT_DIRTY_INVERSE);
+}
+
+/**
+ * Multiply a matrix with a translation matrix.
+ *
+ * \param mat matrix.
+ * \param x translation vector x coordinate.
+ * \param y translation vector y coordinate.
+ * \param z translation vector z coordinate.
+ *
+ * Adds the translation coordinates to the elements of \p mat in-place. Marks
+ * the MAT_FLAG_TRANSLATION flag, and the MAT_DIRTY_TYPE and MAT_DIRTY_INVERSE
+ * dirty flags.
+ */
+void
+_math_matrix_translate( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z )
+{
+ GLfloat *m = mat->m;
+ m[12] = m[0] * x + m[4] * y + m[8] * z + m[12];
+ m[13] = m[1] * x + m[5] * y + m[9] * z + m[13];
+ m[14] = m[2] * x + m[6] * y + m[10] * z + m[14];
+ m[15] = m[3] * x + m[7] * y + m[11] * z + m[15];
+
+ mat->flags |= (MAT_FLAG_TRANSLATION |
+ MAT_DIRTY_TYPE |
+ MAT_DIRTY_INVERSE);
+}
+
+
+/**
+ * Set matrix to do viewport and depthrange mapping.
+ * Transforms Normalized Device Coords to window/Z values.
+ */
+void
+_math_matrix_viewport(GLmatrix *m, GLint x, GLint y, GLint width, GLint height,
+ GLfloat zNear, GLfloat zFar, GLfloat depthMax)
+{
+ m->m[MAT_SX] = (GLfloat) width / 2.0F;
+ m->m[MAT_TX] = m->m[MAT_SX] + x;
+ m->m[MAT_SY] = (GLfloat) height / 2.0F;
+ m->m[MAT_TY] = m->m[MAT_SY] + y;
+ m->m[MAT_SZ] = depthMax * ((zFar - zNear) / 2.0F);
+ m->m[MAT_TZ] = depthMax * ((zFar - zNear) / 2.0F + zNear);
+ m->flags = MAT_FLAG_GENERAL_SCALE | MAT_FLAG_TRANSLATION;
+ m->type = MATRIX_3D_NO_ROT;
+}
+
+
+/**
+ * Set a matrix to the identity matrix.
+ *
+ * \param mat matrix.
+ *
+ * Copies ::Identity into \p GLmatrix::m, and into GLmatrix::inv if not NULL.
+ * Sets the matrix type to identity, and clear the dirty flags.
+ */
+void
+_math_matrix_set_identity( GLmatrix *mat )
+{
+ MEMCPY( mat->m, Identity, 16*sizeof(GLfloat) );
+
+ if (mat->inv)
+ MEMCPY( mat->inv, Identity, 16*sizeof(GLfloat) );
+
+ mat->type = MATRIX_IDENTITY;
+ mat->flags &= ~(MAT_DIRTY_FLAGS|
+ MAT_DIRTY_TYPE|
+ MAT_DIRTY_INVERSE);
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Matrix analysis */
+/*@{*/
+
+#define ZERO(x) (1<<x)
+#define ONE(x) (1<<(x+16))
+
+#define MASK_NO_TRX (ZERO(12) | ZERO(13) | ZERO(14))
+#define MASK_NO_2D_SCALE ( ONE(0) | ONE(5))
+
+#define MASK_IDENTITY ( ONE(0) | ZERO(4) | ZERO(8) | ZERO(12) |\
+ ZERO(1) | ONE(5) | ZERO(9) | ZERO(13) |\
+ ZERO(2) | ZERO(6) | ONE(10) | ZERO(14) |\
+ ZERO(3) | ZERO(7) | ZERO(11) | ONE(15) )
+
+#define MASK_2D_NO_ROT ( ZERO(4) | ZERO(8) | \
+ ZERO(1) | ZERO(9) | \
+ ZERO(2) | ZERO(6) | ONE(10) | ZERO(14) |\
+ ZERO(3) | ZERO(7) | ZERO(11) | ONE(15) )
+
+#define MASK_2D ( ZERO(8) | \
+ ZERO(9) | \
+ ZERO(2) | ZERO(6) | ONE(10) | ZERO(14) |\
+ ZERO(3) | ZERO(7) | ZERO(11) | ONE(15) )
+
+
+#define MASK_3D_NO_ROT ( ZERO(4) | ZERO(8) | \
+ ZERO(1) | ZERO(9) | \
+ ZERO(2) | ZERO(6) | \
+ ZERO(3) | ZERO(7) | ZERO(11) | ONE(15) )
+
+#define MASK_3D ( \
+ \
+ \
+ ZERO(3) | ZERO(7) | ZERO(11) | ONE(15) )
+
+
+#define MASK_PERSPECTIVE ( ZERO(4) | ZERO(12) |\
+ ZERO(1) | ZERO(13) |\
+ ZERO(2) | ZERO(6) | \
+ ZERO(3) | ZERO(7) | ZERO(15) )
+
+#define SQ(x) ((x)*(x))
+
+/**
+ * Determine type and flags from scratch.
+ *
+ * \param mat matrix.
+ *
+ * This is expensive enough to only want to do it once.
+ */
+static void analyse_from_scratch( GLmatrix *mat )
+{
+ const GLfloat *m = mat->m;
+ GLuint mask = 0;
+ GLuint i;
+
+ for (i = 0 ; i < 16 ; i++) {
+ if (m[i] == 0.0) mask |= (1<<i);
+ }
+
+ if (m[0] == 1.0F) mask |= (1<<16);
+ if (m[5] == 1.0F) mask |= (1<<21);
+ if (m[10] == 1.0F) mask |= (1<<26);
+ if (m[15] == 1.0F) mask |= (1<<31);
+
+ mat->flags &= ~MAT_FLAGS_GEOMETRY;
+
+ /* Check for translation - no-one really cares
+ */
+ if ((mask & MASK_NO_TRX) != MASK_NO_TRX)
+ mat->flags |= MAT_FLAG_TRANSLATION;
+
+ /* Do the real work
+ */
+ if (mask == (GLuint) MASK_IDENTITY) {
+ mat->type = MATRIX_IDENTITY;
+ }
+ else if ((mask & MASK_2D_NO_ROT) == (GLuint) MASK_2D_NO_ROT) {
+ mat->type = MATRIX_2D_NO_ROT;
+
+ if ((mask & MASK_NO_2D_SCALE) != MASK_NO_2D_SCALE)
+ mat->flags |= MAT_FLAG_GENERAL_SCALE;
+ }
+ else if ((mask & MASK_2D) == (GLuint) MASK_2D) {
+ GLfloat mm = DOT2(m, m);
+ GLfloat m4m4 = DOT2(m+4,m+4);
+ GLfloat mm4 = DOT2(m,m+4);
+
+ mat->type = MATRIX_2D;
+
+ /* Check for scale */
+ if (SQ(mm-1) > SQ(1e-6) ||
+ SQ(m4m4-1) > SQ(1e-6))
+ mat->flags |= MAT_FLAG_GENERAL_SCALE;
+
+ /* Check for rotation */
+ if (SQ(mm4) > SQ(1e-6))
+ mat->flags |= MAT_FLAG_GENERAL_3D;
+ else
+ mat->flags |= MAT_FLAG_ROTATION;
+
+ }
+ else if ((mask & MASK_3D_NO_ROT) == (GLuint) MASK_3D_NO_ROT) {
+ mat->type = MATRIX_3D_NO_ROT;
+
+ /* Check for scale */
+ if (SQ(m[0]-m[5]) < SQ(1e-6) &&
+ SQ(m[0]-m[10]) < SQ(1e-6)) {
+ if (SQ(m[0]-1.0) > SQ(1e-6)) {
+ mat->flags |= MAT_FLAG_UNIFORM_SCALE;
+ }
+ }
+ else {
+ mat->flags |= MAT_FLAG_GENERAL_SCALE;
+ }
+ }
+ else if ((mask & MASK_3D) == (GLuint) MASK_3D) {
+ GLfloat c1 = DOT3(m,m);
+ GLfloat c2 = DOT3(m+4,m+4);
+ GLfloat c3 = DOT3(m+8,m+8);
+ GLfloat d1 = DOT3(m, m+4);
+ GLfloat cp[3];
+
+ mat->type = MATRIX_3D;
+
+ /* Check for scale */
+ if (SQ(c1-c2) < SQ(1e-6) && SQ(c1-c3) < SQ(1e-6)) {
+ if (SQ(c1-1.0) > SQ(1e-6))
+ mat->flags |= MAT_FLAG_UNIFORM_SCALE;
+ /* else no scale at all */
+ }
+ else {
+ mat->flags |= MAT_FLAG_GENERAL_SCALE;
+ }
+
+ /* Check for rotation */
+ if (SQ(d1) < SQ(1e-6)) {
+ CROSS3( cp, m, m+4 );
+ SUB_3V( cp, cp, (m+8) );
+ if (LEN_SQUARED_3FV(cp) < SQ(1e-6))
+ mat->flags |= MAT_FLAG_ROTATION;
+ else
+ mat->flags |= MAT_FLAG_GENERAL_3D;
+ }
+ else {
+ mat->flags |= MAT_FLAG_GENERAL_3D; /* shear, etc */
+ }
+ }
+ else if ((mask & MASK_PERSPECTIVE) == MASK_PERSPECTIVE && m[11]==-1.0F) {
+ mat->type = MATRIX_PERSPECTIVE;
+ mat->flags |= MAT_FLAG_GENERAL;
+ }
+ else {
+ mat->type = MATRIX_GENERAL;
+ mat->flags |= MAT_FLAG_GENERAL;
+ }
+}
+
+/**
+ * Analyze a matrix given that its flags are accurate.
+ *
+ * This is the more common operation, hopefully.
+ */
+static void analyse_from_flags( GLmatrix *mat )
+{
+ const GLfloat *m = mat->m;
+
+ if (TEST_MAT_FLAGS(mat, 0)) {
+ mat->type = MATRIX_IDENTITY;
+ }
+ else if (TEST_MAT_FLAGS(mat, (MAT_FLAG_TRANSLATION |
+ MAT_FLAG_UNIFORM_SCALE |
+ MAT_FLAG_GENERAL_SCALE))) {
+ if ( m[10]==1.0F && m[14]==0.0F ) {
+ mat->type = MATRIX_2D_NO_ROT;
+ }
+ else {
+ mat->type = MATRIX_3D_NO_ROT;
+ }
+ }
+ else if (TEST_MAT_FLAGS(mat, MAT_FLAGS_3D)) {
+ if ( m[ 8]==0.0F
+ && m[ 9]==0.0F
+ && m[2]==0.0F && m[6]==0.0F && m[10]==1.0F && m[14]==0.0F) {
+ mat->type = MATRIX_2D;
+ }
+ else {
+ mat->type = MATRIX_3D;
+ }
+ }
+ else if ( m[4]==0.0F && m[12]==0.0F
+ && m[1]==0.0F && m[13]==0.0F
+ && m[2]==0.0F && m[6]==0.0F
+ && m[3]==0.0F && m[7]==0.0F && m[11]==-1.0F && m[15]==0.0F) {
+ mat->type = MATRIX_PERSPECTIVE;
+ }
+ else {
+ mat->type = MATRIX_GENERAL;
+ }
+}
+
+/**
+ * Analyze and update a matrix.
+ *
+ * \param mat matrix.
+ *
+ * If the matrix type is dirty then calls either analyse_from_scratch() or
+ * analyse_from_flags() to determine its type, according to whether the flags
+ * are dirty or not, respectively. If the matrix has an inverse and it's dirty
+ * then calls matrix_invert(). Finally clears the dirty flags.
+ */
+void
+_math_matrix_analyse( GLmatrix *mat )
+{
+ if (mat->flags & MAT_DIRTY_TYPE) {
+ if (mat->flags & MAT_DIRTY_FLAGS)
+ analyse_from_scratch( mat );
+ else
+ analyse_from_flags( mat );
+ }
+
+ if (mat->inv && (mat->flags & MAT_DIRTY_INVERSE)) {
+ matrix_invert( mat );
+ }
+
+ mat->flags &= ~(MAT_DIRTY_FLAGS|
+ MAT_DIRTY_TYPE|
+ MAT_DIRTY_INVERSE);
+}
+
+/*@}*/
+
+
+/**
+ * Test if the given matrix preserves vector lengths.
+ */
+GLboolean
+_math_matrix_is_length_preserving( const GLmatrix *m )
+{
+ return TEST_MAT_FLAGS( m, MAT_FLAGS_LENGTH_PRESERVING);
+}
+
+
+/**
+ * Test if the given matrix does any rotation.
+ * (or perhaps if the upper-left 3x3 is non-identity)
+ */
+GLboolean
+_math_matrix_has_rotation( const GLmatrix *m )
+{
+ if (m->flags & (MAT_FLAG_GENERAL |
+ MAT_FLAG_ROTATION |
+ MAT_FLAG_GENERAL_3D |
+ MAT_FLAG_PERSPECTIVE))
+ return GL_TRUE;
+ else
+ return GL_FALSE;
+}
+
+
+GLboolean
+_math_matrix_is_general_scale( const GLmatrix *m )
+{
+ return (m->flags & MAT_FLAG_GENERAL_SCALE) ? GL_TRUE : GL_FALSE;
+}
+
+
+GLboolean
+_math_matrix_is_dirty( const GLmatrix *m )
+{
+ return (m->flags & MAT_DIRTY) ? GL_TRUE : GL_FALSE;
+}
+
+
+/**********************************************************************/
+/** \name Matrix setup */
+/*@{*/
+
+/**
+ * Copy a matrix.
+ *
+ * \param to destination matrix.
+ * \param from source matrix.
+ *
+ * Copies all fields in GLmatrix, creating an inverse array if necessary.
+ */
+void
+_math_matrix_copy( GLmatrix *to, const GLmatrix *from )
+{
+ MEMCPY( to->m, from->m, sizeof(Identity) );
+ to->flags = from->flags;
+ to->type = from->type;
+
+ if (to->inv != 0) {
+ if (from->inv == 0) {
+ matrix_invert( to );
+ }
+ else {
+ MEMCPY(to->inv, from->inv, sizeof(GLfloat)*16);
+ }
+ }
+}
+
+/**
+ * Loads a matrix array into GLmatrix.
+ *
+ * \param m matrix array.
+ * \param mat matrix.
+ *
+ * Copies \p m into GLmatrix::m and marks the MAT_FLAG_GENERAL and MAT_DIRTY
+ * flags.
+ */
+void
+_math_matrix_loadf( GLmatrix *mat, const GLfloat *m )
+{
+ MEMCPY( mat->m, m, 16*sizeof(GLfloat) );
+ mat->flags = (MAT_FLAG_GENERAL | MAT_DIRTY);
+}
+
+/**
+ * Matrix constructor.
+ *
+ * \param m matrix.
+ *
+ * Initialize the GLmatrix fields.
+ */
+void
+_math_matrix_ctr( GLmatrix *m )
+{
+ m->m = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 );
+ if (m->m)
+ MEMCPY( m->m, Identity, sizeof(Identity) );
+ m->inv = NULL;
+ m->type = MATRIX_IDENTITY;
+ m->flags = 0;
+}
+
+/**
+ * Matrix destructor.
+ *
+ * \param m matrix.
+ *
+ * Frees the data in a GLmatrix.
+ */
+void
+_math_matrix_dtr( GLmatrix *m )
+{
+ if (m->m) {
+ ALIGN_FREE( m->m );
+ m->m = NULL;
+ }
+ if (m->inv) {
+ ALIGN_FREE( m->inv );
+ m->inv = NULL;
+ }
+}
+
+/**
+ * Allocate a matrix inverse.
+ *
+ * \param m matrix.
+ *
+ * Allocates the matrix inverse, GLmatrix::inv, and sets it to Identity.
+ */
+void
+_math_matrix_alloc_inv( GLmatrix *m )
+{
+ if (!m->inv) {
+ m->inv = (GLfloat *) ALIGN_MALLOC( 16 * sizeof(GLfloat), 16 );
+ if (m->inv)
+ MEMCPY( m->inv, Identity, 16 * sizeof(GLfloat) );
+ }
+}
+
+/*@}*/
+
+
+/**********************************************************************/
+/** \name Matrix transpose */
+/*@{*/
+
+/**
+ * Transpose a GLfloat matrix.
+ *
+ * \param to destination array.
+ * \param from source array.
+ */
+void
+_math_transposef( GLfloat to[16], const GLfloat from[16] )
+{
+ to[0] = from[0];
+ to[1] = from[4];
+ to[2] = from[8];
+ to[3] = from[12];
+ to[4] = from[1];
+ to[5] = from[5];
+ to[6] = from[9];
+ to[7] = from[13];
+ to[8] = from[2];
+ to[9] = from[6];
+ to[10] = from[10];
+ to[11] = from[14];
+ to[12] = from[3];
+ to[13] = from[7];
+ to[14] = from[11];
+ to[15] = from[15];
+}
+
+/**
+ * Transpose a GLdouble matrix.
+ *
+ * \param to destination array.
+ * \param from source array.
+ */
+void
+_math_transposed( GLdouble to[16], const GLdouble from[16] )
+{
+ to[0] = from[0];
+ to[1] = from[4];
+ to[2] = from[8];
+ to[3] = from[12];
+ to[4] = from[1];
+ to[5] = from[5];
+ to[6] = from[9];
+ to[7] = from[13];
+ to[8] = from[2];
+ to[9] = from[6];
+ to[10] = from[10];
+ to[11] = from[14];
+ to[12] = from[3];
+ to[13] = from[7];
+ to[14] = from[11];
+ to[15] = from[15];
+}
+
+/**
+ * Transpose a GLdouble matrix and convert to GLfloat.
+ *
+ * \param to destination array.
+ * \param from source array.
+ */
+void
+_math_transposefd( GLfloat to[16], const GLdouble from[16] )
+{
+ to[0] = (GLfloat) from[0];
+ to[1] = (GLfloat) from[4];
+ to[2] = (GLfloat) from[8];
+ to[3] = (GLfloat) from[12];
+ to[4] = (GLfloat) from[1];
+ to[5] = (GLfloat) from[5];
+ to[6] = (GLfloat) from[9];
+ to[7] = (GLfloat) from[13];
+ to[8] = (GLfloat) from[2];
+ to[9] = (GLfloat) from[6];
+ to[10] = (GLfloat) from[10];
+ to[11] = (GLfloat) from[14];
+ to[12] = (GLfloat) from[3];
+ to[13] = (GLfloat) from[7];
+ to[14] = (GLfloat) from[11];
+ to[15] = (GLfloat) from[15];
+}
+
+/*@}*/
+
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_matrix.h b/nx-X11/extras/Mesa/src/mesa/math/m_matrix.h
new file mode 100644
index 000000000..e8303f3ac
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_matrix.h
@@ -0,0 +1,195 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file math/m_matrix.h
+ * Defines basic structures for matrix-handling.
+ */
+
+#ifndef _M_MATRIX_H
+#define _M_MATRIX_H
+
+
+
+/**
+ * \name Symbolic names to some of the entries in the matrix
+ *
+ * These are handy for the viewport mapping, which is expressed as a matrix.
+ */
+/*@{*/
+#define MAT_SX 0
+#define MAT_SY 5
+#define MAT_SZ 10
+#define MAT_TX 12
+#define MAT_TY 13
+#define MAT_TZ 14
+/*@}*/
+
+
+/**
+ * Different kinds of 4x4 transformation matrices.
+ * We use these to select specific optimized vertex transformation routines.
+ */
+enum GLmatrixtype {
+ MATRIX_GENERAL, /**< general 4x4 matrix */
+ MATRIX_IDENTITY, /**< identity matrix */
+ MATRIX_3D_NO_ROT, /**< orthogonal projection and others... */
+ MATRIX_PERSPECTIVE, /**< perspective projection matrix */
+ MATRIX_2D, /**< 2-D transformation */
+ MATRIX_2D_NO_ROT, /**< 2-D scale & translate only */
+ MATRIX_3D /**< 3-D transformation */
+} ;
+
+/**
+ * Matrix type to represent 4x4 transformation matrices.
+ */
+typedef struct {
+ GLfloat *m; /**< 16 matrix elements (16-byte aligned) */
+ GLfloat *inv; /**< optional 16-element inverse (16-byte aligned) */
+ GLuint flags; /**< possible values determined by (of \link
+ * MatFlags MAT_FLAG_* flags\endlink)
+ */
+ enum GLmatrixtype type;
+} GLmatrix;
+
+
+
+
+extern void
+_math_matrix_ctr( GLmatrix *m );
+
+extern void
+_math_matrix_dtr( GLmatrix *m );
+
+extern void
+_math_matrix_alloc_inv( GLmatrix *m );
+
+extern void
+_math_matrix_mul_matrix( GLmatrix *dest, const GLmatrix *a, const GLmatrix *b );
+
+extern void
+_math_matrix_mul_floats( GLmatrix *dest, const GLfloat *b );
+
+extern void
+_math_matrix_loadf( GLmatrix *mat, const GLfloat *m );
+
+extern void
+_math_matrix_translate( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z );
+
+extern void
+_math_matrix_rotate( GLmatrix *m, GLfloat angle,
+ GLfloat x, GLfloat y, GLfloat z );
+
+extern void
+_math_matrix_scale( GLmatrix *mat, GLfloat x, GLfloat y, GLfloat z );
+
+extern void
+_math_matrix_ortho( GLmatrix *mat,
+ GLfloat left, GLfloat right,
+ GLfloat bottom, GLfloat top,
+ GLfloat nearval, GLfloat farval );
+
+extern void
+_math_matrix_frustum( GLmatrix *mat,
+ GLfloat left, GLfloat right,
+ GLfloat bottom, GLfloat top,
+ GLfloat nearval, GLfloat farval );
+
+extern void
+_math_matrix_viewport(GLmatrix *m, GLint x, GLint y, GLint width, GLint height,
+ GLfloat zNear, GLfloat zFar, GLfloat depthMax);
+
+extern void
+_math_matrix_set_identity( GLmatrix *dest );
+
+extern void
+_math_matrix_copy( GLmatrix *to, const GLmatrix *from );
+
+extern void
+_math_matrix_analyse( GLmatrix *mat );
+
+extern void
+_math_matrix_print( const GLmatrix *m );
+
+extern GLboolean
+_math_matrix_is_length_preserving( const GLmatrix *m );
+
+extern GLboolean
+_math_matrix_has_rotation( const GLmatrix *m );
+
+extern GLboolean
+_math_matrix_is_general_scale( const GLmatrix *m );
+
+extern GLboolean
+_math_matrix_is_dirty( const GLmatrix *m );
+
+
+/**
+ * \name Related functions that don't actually operate on GLmatrix structs
+ */
+/*@{*/
+
+extern void
+_math_transposef( GLfloat to[16], const GLfloat from[16] );
+
+extern void
+_math_transposed( GLdouble to[16], const GLdouble from[16] );
+
+extern void
+_math_transposefd( GLfloat to[16], const GLdouble from[16] );
+
+
+/*
+ * Transform a point (column vector) by a matrix: Q = M * P
+ */
+#define TRANSFORM_POINT( Q, M, P ) \
+ Q[0] = M[0] * P[0] + M[4] * P[1] + M[8] * P[2] + M[12] * P[3]; \
+ Q[1] = M[1] * P[0] + M[5] * P[1] + M[9] * P[2] + M[13] * P[3]; \
+ Q[2] = M[2] * P[0] + M[6] * P[1] + M[10] * P[2] + M[14] * P[3]; \
+ Q[3] = M[3] * P[0] + M[7] * P[1] + M[11] * P[2] + M[15] * P[3];
+
+
+#define TRANSFORM_POINT3( Q, M, P ) \
+ Q[0] = M[0] * P[0] + M[4] * P[1] + M[8] * P[2] + M[12]; \
+ Q[1] = M[1] * P[0] + M[5] * P[1] + M[9] * P[2] + M[13]; \
+ Q[2] = M[2] * P[0] + M[6] * P[1] + M[10] * P[2] + M[14]; \
+ Q[3] = M[3] * P[0] + M[7] * P[1] + M[11] * P[2] + M[15];
+
+
+/*
+ * Transform a normal (row vector) by a matrix: [NX NY NZ] = N * MAT
+ */
+#define TRANSFORM_NORMAL( TO, N, MAT ) \
+do { \
+ TO[0] = N[0] * MAT[0] + N[1] * MAT[1] + N[2] * MAT[2]; \
+ TO[1] = N[0] * MAT[4] + N[1] * MAT[5] + N[2] * MAT[6]; \
+ TO[2] = N[0] * MAT[8] + N[1] * MAT[9] + N[2] * MAT[10]; \
+} while (0)
+
+
+/*@}*/
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_norm_tmp.h b/nx-X11/extras/Mesa/src/mesa/math/m_norm_tmp.h
new file mode 100644
index 000000000..a20cb0501
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_norm_tmp.h
@@ -0,0 +1,390 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+/*
+ * New (3.1) transformation code written by Keith Whitwell.
+ */
+
+/* Functions to tranform a vector of normals. This includes applying
+ * the transformation matrix, rescaling and normalization.
+ */
+
+/*
+ * mat - the 4x4 transformation matrix
+ * scale - uniform scale factor of the transformation matrix (not always used)
+ * in - the source vector of normals
+ * lengths - length of each incoming normal (may be NULL) (a display list
+ * optimization)
+ * dest - the destination vector of normals
+ */
+static void _XFORMAPI
+TAG(transform_normalize_normals)( const GLmatrix *mat,
+ GLfloat scale,
+ const GLvector4f *in,
+ const GLfloat *lengths,
+ GLvector4f *dest )
+{
+ GLfloat (*out)[4] = (GLfloat (*)[4])dest->start;
+ const GLfloat *from = in->start;
+ const GLuint stride = in->stride;
+ const GLuint count = in->count;
+ const GLfloat *m = mat->inv;
+ GLfloat m0 = m[0], m4 = m[4], m8 = m[8];
+ GLfloat m1 = m[1], m5 = m[5], m9 = m[9];
+ GLfloat m2 = m[2], m6 = m[6], m10 = m[10];
+ GLuint i;
+
+ if (!lengths) {
+ STRIDE_LOOP {
+ GLfloat tx, ty, tz;
+ {
+ const GLfloat ux = from[0], uy = from[1], uz = from[2];
+ tx = ux * m0 + uy * m1 + uz * m2;
+ ty = ux * m4 + uy * m5 + uz * m6;
+ tz = ux * m8 + uy * m9 + uz * m10;
+ }
+ {
+ GLdouble len = tx*tx + ty*ty + tz*tz;
+ if (len > 1e-20) {
+ GLfloat scale = INV_SQRTF(len);
+ out[i][0] = tx * scale;
+ out[i][1] = ty * scale;
+ out[i][2] = tz * scale;
+ }
+ else {
+ out[i][0] = out[i][1] = out[i][2] = 0;
+ }
+ }
+ }
+ }
+ else {
+ if (scale != 1.0) {
+ m0 *= scale, m4 *= scale, m8 *= scale;
+ m1 *= scale, m5 *= scale, m9 *= scale;
+ m2 *= scale, m6 *= scale, m10 *= scale;
+ }
+
+ STRIDE_LOOP {
+ GLfloat tx, ty, tz;
+ {
+ const GLfloat ux = from[0], uy = from[1], uz = from[2];
+ tx = ux * m0 + uy * m1 + uz * m2;
+ ty = ux * m4 + uy * m5 + uz * m6;
+ tz = ux * m8 + uy * m9 + uz * m10;
+ }
+ {
+ GLfloat len = lengths[i];
+ out[i][0] = tx * len;
+ out[i][1] = ty * len;
+ out[i][2] = tz * len;
+ }
+ }
+ }
+ dest->count = in->count;
+}
+
+
+static void _XFORMAPI
+TAG(transform_normalize_normals_no_rot)( const GLmatrix *mat,
+ GLfloat scale,
+ const GLvector4f *in,
+ const GLfloat *lengths,
+ GLvector4f *dest )
+{
+ GLfloat (*out)[4] = (GLfloat (*)[4])dest->start;
+ const GLfloat *from = in->start;
+ const GLuint stride = in->stride;
+ const GLuint count = in->count;
+ const GLfloat *m = mat->inv;
+ GLfloat m0 = m[0];
+ GLfloat m5 = m[5];
+ GLfloat m10 = m[10];
+ GLuint i;
+
+ if (!lengths) {
+ STRIDE_LOOP {
+ GLfloat tx, ty, tz;
+ {
+ const GLfloat ux = from[0], uy = from[1], uz = from[2];
+ tx = ux * m0 ;
+ ty = uy * m5 ;
+ tz = uz * m10;
+ }
+ {
+ GLdouble len = tx*tx + ty*ty + tz*tz;
+ if (len > 1e-20) {
+ GLfloat scale = INV_SQRTF(len);
+ out[i][0] = tx * scale;
+ out[i][1] = ty * scale;
+ out[i][2] = tz * scale;
+ }
+ else {
+ out[i][0] = out[i][1] = out[i][2] = 0;
+ }
+ }
+ }
+ }
+ else {
+ m0 *= scale;
+ m5 *= scale;
+ m10 *= scale;
+
+ STRIDE_LOOP {
+ GLfloat tx, ty, tz;
+ {
+ const GLfloat ux = from[0], uy = from[1], uz = from[2];
+ tx = ux * m0 ;
+ ty = uy * m5 ;
+ tz = uz * m10;
+ }
+ {
+ GLfloat len = lengths[i];
+ out[i][0] = tx * len;
+ out[i][1] = ty * len;
+ out[i][2] = tz * len;
+ }
+ }
+ }
+ dest->count = in->count;
+}
+
+
+static void _XFORMAPI
+TAG(transform_rescale_normals_no_rot)( const GLmatrix *mat,
+ GLfloat scale,
+ const GLvector4f *in,
+ const GLfloat *lengths,
+ GLvector4f *dest )
+{
+ GLfloat (*out)[4] = (GLfloat (*)[4])dest->start;
+ const GLfloat *from = in->start;
+ const GLuint stride = in->stride;
+ const GLuint count = in->count;
+ const GLfloat *m = mat->inv;
+ const GLfloat m0 = scale*m[0];
+ const GLfloat m5 = scale*m[5];
+ const GLfloat m10 = scale*m[10];
+ GLuint i;
+
+ (void) lengths;
+
+ STRIDE_LOOP {
+ GLfloat ux = from[0], uy = from[1], uz = from[2];
+ out[i][0] = ux * m0;
+ out[i][1] = uy * m5;
+ out[i][2] = uz * m10;
+ }
+ dest->count = in->count;
+}
+
+
+static void _XFORMAPI
+TAG(transform_rescale_normals)( const GLmatrix *mat,
+ GLfloat scale,
+ const GLvector4f *in,
+ const GLfloat *lengths,
+ GLvector4f *dest )
+{
+ GLfloat (*out)[4] = (GLfloat (*)[4])dest->start;
+ const GLfloat *from = in->start;
+ const GLuint stride = in->stride;
+ const GLuint count = in->count;
+ /* Since we are unlikely to have < 3 vertices in the buffer,
+ * it makes sense to pre-multiply by scale.
+ */
+ const GLfloat *m = mat->inv;
+ const GLfloat m0 = scale*m[0], m4 = scale*m[4], m8 = scale*m[8];
+ const GLfloat m1 = scale*m[1], m5 = scale*m[5], m9 = scale*m[9];
+ const GLfloat m2 = scale*m[2], m6 = scale*m[6], m10 = scale*m[10];
+ GLuint i;
+
+ (void) lengths;
+
+ STRIDE_LOOP {
+ GLfloat ux = from[0], uy = from[1], uz = from[2];
+ out[i][0] = ux * m0 + uy * m1 + uz * m2;
+ out[i][1] = ux * m4 + uy * m5 + uz * m6;
+ out[i][2] = ux * m8 + uy * m9 + uz * m10;
+ }
+ dest->count = in->count;
+}
+
+
+static void _XFORMAPI
+TAG(transform_normals_no_rot)( const GLmatrix *mat,
+ GLfloat scale,
+ const GLvector4f *in,
+ const GLfloat *lengths,
+ GLvector4f *dest )
+{
+ GLfloat (*out)[4] = (GLfloat (*)[4])dest->start;
+ const GLfloat *from = in->start;
+ const GLuint stride = in->stride;
+ const GLuint count = in->count;
+ const GLfloat *m = mat->inv;
+ const GLfloat m0 = m[0];
+ const GLfloat m5 = m[5];
+ const GLfloat m10 = m[10];
+ GLuint i;
+
+ (void) scale;
+ (void) lengths;
+
+ STRIDE_LOOP {
+ GLfloat ux = from[0], uy = from[1], uz = from[2];
+ out[i][0] = ux * m0;
+ out[i][1] = uy * m5;
+ out[i][2] = uz * m10;
+ }
+ dest->count = in->count;
+}
+
+
+static void _XFORMAPI
+TAG(transform_normals)( const GLmatrix *mat,
+ GLfloat scale,
+ const GLvector4f *in,
+ const GLfloat *lengths,
+ GLvector4f *dest )
+{
+ GLfloat (*out)[4] = (GLfloat (*)[4])dest->start;
+ const GLfloat *from = in->start;
+ const GLuint stride = in->stride;
+ const GLuint count = in->count;
+ const GLfloat *m = mat->inv;
+ const GLfloat m0 = m[0], m4 = m[4], m8 = m[8];
+ const GLfloat m1 = m[1], m5 = m[5], m9 = m[9];
+ const GLfloat m2 = m[2], m6 = m[6], m10 = m[10];
+ GLuint i;
+
+ (void) scale;
+ (void) lengths;
+
+ STRIDE_LOOP {
+ GLfloat ux = from[0], uy = from[1], uz = from[2];
+ out[i][0] = ux * m0 + uy * m1 + uz * m2;
+ out[i][1] = ux * m4 + uy * m5 + uz * m6;
+ out[i][2] = ux * m8 + uy * m9 + uz * m10;
+ }
+ dest->count = in->count;
+}
+
+
+static void _XFORMAPI
+TAG(normalize_normals)( const GLmatrix *mat,
+ GLfloat scale,
+ const GLvector4f *in,
+ const GLfloat *lengths,
+ GLvector4f *dest )
+{
+ GLfloat (*out)[4] = (GLfloat (*)[4])dest->start;
+ const GLfloat *from = in->start;
+ const GLuint stride = in->stride;
+ const GLuint count = in->count;
+ GLuint i;
+
+ (void) mat;
+ (void) scale;
+
+ if (lengths) {
+ STRIDE_LOOP {
+ const GLfloat x = from[0], y = from[1], z = from[2];
+ GLfloat invlen = lengths[i];
+ out[i][0] = x * invlen;
+ out[i][1] = y * invlen;
+ out[i][2] = z * invlen;
+ }
+ }
+ else {
+ STRIDE_LOOP {
+ const GLfloat x = from[0], y = from[1], z = from[2];
+ GLdouble len = x * x + y * y + z * z;
+ if (len > 1e-50) {
+ len = INV_SQRTF(len);
+ out[i][0] = (GLfloat)(x * len);
+ out[i][1] = (GLfloat)(y * len);
+ out[i][2] = (GLfloat)(z * len);
+ }
+ else {
+ out[i][0] = x;
+ out[i][1] = y;
+ out[i][2] = z;
+ }
+ }
+ }
+ dest->count = in->count;
+}
+
+
+static void _XFORMAPI
+TAG(rescale_normals)( const GLmatrix *mat,
+ GLfloat scale,
+ const GLvector4f *in,
+ const GLfloat *lengths,
+ GLvector4f *dest )
+{
+ GLfloat (*out)[4] = (GLfloat (*)[4])dest->start;
+ const GLfloat *from = in->start;
+ const GLuint stride = in->stride;
+ const GLuint count = in->count;
+ GLuint i;
+
+ (void) mat;
+ (void) lengths;
+
+ STRIDE_LOOP {
+ SCALE_SCALAR_3V( out[i], scale, from );
+ }
+ dest->count = in->count;
+}
+
+
+static void _XFORMAPI
+TAG(init_c_norm_transform)( void )
+{
+ _mesa_normal_tab[NORM_TRANSFORM_NO_ROT] =
+ TAG(transform_normals_no_rot);
+
+ _mesa_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_RESCALE] =
+ TAG(transform_rescale_normals_no_rot);
+
+ _mesa_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_NORMALIZE] =
+ TAG(transform_normalize_normals_no_rot);
+
+ _mesa_normal_tab[NORM_TRANSFORM] =
+ TAG(transform_normals);
+
+ _mesa_normal_tab[NORM_TRANSFORM | NORM_RESCALE] =
+ TAG(transform_rescale_normals);
+
+ _mesa_normal_tab[NORM_TRANSFORM | NORM_NORMALIZE] =
+ TAG(transform_normalize_normals);
+
+ _mesa_normal_tab[NORM_RESCALE] =
+ TAG(rescale_normals);
+
+ _mesa_normal_tab[NORM_NORMALIZE] =
+ TAG(normalize_normals);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_trans_tmp.h b/nx-X11/extras/Mesa/src/mesa/math/m_trans_tmp.h
new file mode 100644
index 000000000..c1f0f7674
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_trans_tmp.h
@@ -0,0 +1,287 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+/*
+ * New (3.1) transformation code written by Keith Whitwell.
+ */
+
+
+/* KW: This file also included by tnl/trans_elt.c to build code
+ * specific to the implementation of array-elements in the
+ * tnl module.
+ */
+
+
+#ifdef DEST_4F
+static void DEST_4F( GLfloat (*t)[4],
+ CONST void *ptr,
+ GLuint stride,
+ ARGS )
+{
+ const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
+ const GLubyte *first = f;
+ GLuint i;
+
+ (void) first;
+ (void) start;
+ for (i = DST_START ; i < n ; i++, NEXT_F) {
+ CHECK {
+ NEXT_F2;
+ if (SZ >= 1) t[i][0] = TRX_4F(f, 0);
+ if (SZ >= 2) t[i][1] = TRX_4F(f, 1);
+ if (SZ >= 3) t[i][2] = TRX_4F(f, 2);
+ if (SZ == 4) t[i][3] = TRX_4F(f, 3); else t[i][3] = 1.0;
+ }
+ }
+}
+#endif
+
+
+
+#ifdef DEST_4FC
+static void DEST_4FC( GLfloat (*t)[4],
+ CONST void *ptr,
+ GLuint stride,
+ ARGS )
+{
+ const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
+ const GLubyte *first = f;
+ GLuint i;
+
+ (void) first;
+ (void) start;
+ for (i = DST_START ; i < n ; i++, NEXT_F) {
+ CHECK {
+ NEXT_F2;
+ if (SZ >= 1) t[i][0] = TRX_4FC(f, 0);
+ if (SZ >= 2) t[i][1] = TRX_4FC(f, 1);
+ if (SZ >= 3) t[i][2] = TRX_4FC(f, 2);
+ if (SZ == 4) t[i][3] = TRX_4FC(f, 3); else t[i][3] = 1.0;
+ }
+ }
+}
+#endif
+
+
+#ifdef DEST_3F
+static void DEST_3F( GLfloat (*t)[3],
+ CONST void *ptr,
+ GLuint stride,
+ ARGS )
+{
+ const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
+ const GLubyte *first = f;
+ GLuint i;
+ (void) first;
+ (void) start;
+ for (i = DST_START ; i < n ; i++, NEXT_F) {
+ CHECK {
+ NEXT_F2;
+ t[i][0] = TRX_3F(f, 0);
+ t[i][1] = TRX_3F(f, 1);
+ t[i][2] = TRX_3F(f, 2);
+ }
+ }
+}
+#endif
+
+#ifdef DEST_1F
+static void DEST_1F( GLfloat *t,
+ CONST void *ptr,
+ GLuint stride,
+ ARGS )
+{
+ const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
+ const GLubyte *first = f;
+ GLuint i;
+ (void) first;
+ (void) start;
+ for (i = DST_START ; i < n ; i++, NEXT_F) {
+ CHECK {
+ NEXT_F2;
+ t[i] = TRX_1F(f, 0);
+ }
+ }
+}
+#endif
+
+#ifdef DEST_4UB
+static void DEST_4UB( GLubyte (*t)[4],
+ CONST void *ptr,
+ GLuint stride,
+ ARGS )
+{
+ const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
+ const GLubyte *first = f;
+ GLuint i;
+ (void) start;
+ (void) first;
+ for (i = DST_START ; i < n ; i++, NEXT_F) {
+ CHECK {
+ NEXT_F2;
+ if (SZ >= 1) TRX_UB(t[i][0], f, 0);
+ if (SZ >= 2) TRX_UB(t[i][1], f, 1);
+ if (SZ >= 3) TRX_UB(t[i][2], f, 2);
+ if (SZ == 4) TRX_UB(t[i][3], f, 3); else t[i][3] = 255;
+ }
+ }
+}
+#endif
+
+
+#ifdef DEST_4US
+static void DEST_4US( GLushort (*t)[4],
+ CONST void *ptr,
+ GLuint stride,
+ ARGS )
+{
+ const GLubyte *f = (GLubyte *) ((GLubyte *) ptr + SRC_START * stride);
+ const GLubyte *first = f;
+ GLuint i;
+ (void) start;
+ (void) first;
+ for (i = DST_START ; i < n ; i++, NEXT_F) {
+ CHECK {
+ NEXT_F2;
+ if (SZ >= 1) TRX_US(t[i][0], f, 0);
+ if (SZ >= 2) TRX_US(t[i][1], f, 1);
+ if (SZ >= 3) TRX_US(t[i][2], f, 2);
+ if (SZ == 4) TRX_US(t[i][3], f, 3); else t[i][3] = 65535;
+ }
+ }
+}
+#endif
+
+
+#ifdef DEST_1UB
+static void DEST_1UB( GLubyte *t,
+ CONST void *ptr,
+ GLuint stride,
+ ARGS )
+{
+ const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
+ const GLubyte *first = f;
+ GLuint i;
+ (void) start;
+ (void) first;
+ for (i = DST_START ; i < n ; i++, NEXT_F) {
+ CHECK {
+ NEXT_F2;
+ TRX_UB(t[i], f, 0);
+ }
+ }
+}
+#endif
+
+
+#ifdef DEST_1UI
+static void DEST_1UI( GLuint *t,
+ CONST void *ptr,
+ GLuint stride,
+ ARGS )
+{
+ const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
+ const GLubyte *first = f;
+ GLuint i;
+ (void) start;
+ (void) first;
+
+ for (i = DST_START ; i < n ; i++, NEXT_F) {
+ CHECK {
+ NEXT_F2;
+ t[i] = TRX_UI(f, 0);
+ }
+ }
+}
+#endif
+
+
+static void INIT(void)
+{
+#ifdef DEST_1UI
+ ASSERT(SZ == 1);
+ TAB(_1ui)[SRC_IDX] = DEST_1UI;
+#endif
+#ifdef DEST_1UB
+ ASSERT(SZ == 1);
+ TAB(_1ub)[SRC_IDX] = DEST_1UB;
+#endif
+#ifdef DEST_1F
+ ASSERT(SZ == 1);
+ TAB(_1f)[SRC_IDX] = DEST_1F;
+#endif
+#ifdef DEST_3F
+ ASSERT(SZ == 3);
+ TAB(_3f)[SRC_IDX] = DEST_3F;
+#endif
+#ifdef DEST_4UB
+ TAB(_4ub)[SZ][SRC_IDX] = DEST_4UB;
+#endif
+#ifdef DEST_4US
+ TAB(_4us)[SZ][SRC_IDX] = DEST_4US;
+#endif
+#ifdef DEST_4F
+ TAB(_4f)[SZ][SRC_IDX] = DEST_4F;
+#endif
+#ifdef DEST_4FC
+ TAB(_4fc)[SZ][SRC_IDX] = DEST_4FC;
+#endif
+
+}
+
+
+#ifdef INIT
+#undef INIT
+#endif
+#ifdef DEST_1UI
+#undef DEST_1UI
+#endif
+#ifdef DEST_1UB
+#undef DEST_1UB
+#endif
+#ifdef DEST_4UB
+#undef DEST_4UB
+#endif
+#ifdef DEST_4US
+#undef DEST_4US
+#endif
+#ifdef DEST_3F
+#undef DEST_3F
+#endif
+#ifdef DEST_4F
+#undef DEST_4F
+#endif
+#ifdef DEST_4FC
+#undef DEST_4FC
+#endif
+#ifdef DEST_1F
+#undef DEST_1F
+#endif
+#ifdef SZ
+#undef SZ
+#endif
+#ifdef TAG
+#undef TAG
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_translate.c b/nx-X11/extras/Mesa/src/mesa/math/m_translate.c
new file mode 100644
index 000000000..1bce0f3a0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_translate.c
@@ -0,0 +1,718 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+/*
+ * New (3.1) transformation code written by Keith Whitwell.
+ */
+
+
+#include "glheader.h"
+#include "mtypes.h" /* GLchan hack */
+#include "colormac.h"
+
+#include "m_translate.h"
+
+
+
+typedef void (*trans_1f_func)(GLfloat *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLuint start,
+ GLuint n );
+
+typedef void (*trans_1ui_func)(GLuint *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLuint start,
+ GLuint n );
+
+typedef void (*trans_1ub_func)(GLubyte *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLuint start,
+ GLuint n );
+
+typedef void (*trans_4ub_func)(GLubyte (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLuint start,
+ GLuint n );
+
+typedef void (*trans_4us_func)(GLushort (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLuint start,
+ GLuint n );
+
+typedef void (*trans_4f_func)(GLfloat (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLuint start,
+ GLuint n );
+
+typedef void (*trans_3f_func)(GLfloat (*to)[3],
+ CONST void *ptr,
+ GLuint stride,
+ GLuint start,
+ GLuint n );
+
+
+
+
+#define TYPE_IDX(t) ((t) & 0xf)
+#define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */
+
+
+/* This macro is used on other systems, so undefine it for this module */
+
+#undef CHECK
+
+static trans_1f_func _math_trans_1f_tab[MAX_TYPES];
+static trans_1ui_func _math_trans_1ui_tab[MAX_TYPES];
+static trans_1ub_func _math_trans_1ub_tab[MAX_TYPES];
+static trans_3f_func _math_trans_3f_tab[MAX_TYPES];
+static trans_4ub_func _math_trans_4ub_tab[5][MAX_TYPES];
+static trans_4us_func _math_trans_4us_tab[5][MAX_TYPES];
+static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES];
+static trans_4f_func _math_trans_4fc_tab[5][MAX_TYPES];
+
+
+#define PTR_ELT(ptr, elt) (((SRC *)ptr)[elt])
+
+
+#define TAB(x) _math_trans##x##_tab
+#define ARGS GLuint start, GLuint n
+#define SRC_START start
+#define DST_START 0
+#define STRIDE stride
+#define NEXT_F f += stride
+#define NEXT_F2
+#define CHECK
+
+
+
+
+/* GL_BYTE
+ */
+#define SRC GLbyte
+#define SRC_IDX TYPE_IDX(GL_BYTE)
+#define TRX_3F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
+#define TRX_4F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
+#define TRX_4FC(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
+#define TRX_UB(ub, f,n) ub = BYTE_TO_UBYTE( PTR_ELT(f,n) )
+#define TRX_US(ch, f,n) ch = BYTE_TO_USHORT( PTR_ELT(f,n) )
+#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
+
+
+#define SZ 4
+#define INIT init_trans_4_GLbyte_raw
+#define DEST_4F trans_4_GLbyte_4f_raw
+#define DEST_4FC trans_4_GLbyte_4fc_raw
+#define DEST_4UB trans_4_GLbyte_4ub_raw
+#define DEST_4US trans_4_GLbyte_4us_raw
+#include "m_trans_tmp.h"
+
+#define SZ 3
+#define INIT init_trans_3_GLbyte_raw
+#define DEST_4F trans_3_GLbyte_4f_raw
+#define DEST_4FC trans_3_GLbyte_4fc_raw
+#define DEST_4UB trans_3_GLbyte_4ub_raw
+#define DEST_4US trans_3_GLbyte_4us_raw
+#define DEST_3F trans_3_GLbyte_3f_raw
+#include "m_trans_tmp.h"
+
+#define SZ 2
+#define INIT init_trans_2_GLbyte_raw
+#define DEST_4F trans_2_GLbyte_4f_raw
+#define DEST_4FC trans_2_GLbyte_4fc_raw
+#include "m_trans_tmp.h"
+
+#define SZ 1
+#define INIT init_trans_1_GLbyte_raw
+#define DEST_4F trans_1_GLbyte_4f_raw
+#define DEST_4FC trans_1_GLbyte_4fc_raw
+#define DEST_1UB trans_1_GLbyte_1ub_raw
+#define DEST_1UI trans_1_GLbyte_1ui_raw
+#include "m_trans_tmp.h"
+
+#undef SRC
+#undef TRX_3F
+#undef TRX_4F
+#undef TRX_4FC
+#undef TRX_UB
+#undef TRX_US
+#undef TRX_UI
+#undef SRC_IDX
+
+
+/* GL_UNSIGNED_BYTE
+ */
+#define SRC GLubyte
+#define SRC_IDX TYPE_IDX(GL_UNSIGNED_BYTE)
+#define TRX_3F(f,n) UBYTE_TO_FLOAT(PTR_ELT(f,n))
+#define TRX_4F(f,n) UBYTE_TO_FLOAT(PTR_ELT(f,n))
+#define TRX_4FC(f,n) UBYTE_TO_FLOAT(PTR_ELT(f,n))
+#define TRX_UB(ub, f,n) ub = PTR_ELT(f,n)
+#define TRX_US(us, f,n) us = UBYTE_TO_USHORT(PTR_ELT(f,n))
+#define TRX_UI(f,n) (GLuint)PTR_ELT(f,n)
+
+/* 4ub->4ub handled in special case below.
+ */
+#define SZ 4
+#define INIT init_trans_4_GLubyte_raw
+#define DEST_4F trans_4_GLubyte_4f_raw
+#define DEST_4FC trans_4_GLubyte_4fc_raw
+#define DEST_4US trans_4_GLubyte_4us_raw
+#include "m_trans_tmp.h"
+
+
+#define SZ 3
+#define INIT init_trans_3_GLubyte_raw
+#define DEST_4UB trans_3_GLubyte_4ub_raw
+#define DEST_4US trans_3_GLubyte_4us_raw
+#define DEST_3F trans_3_GLubyte_3f_raw
+#define DEST_4F trans_3_GLubyte_4f_raw
+#define DEST_4FC trans_3_GLubyte_4fc_raw
+#include "m_trans_tmp.h"
+
+
+#define SZ 1
+#define INIT init_trans_1_GLubyte_raw
+#define DEST_1UI trans_1_GLubyte_1ui_raw
+#define DEST_1UB trans_1_GLubyte_1ub_raw
+#include "m_trans_tmp.h"
+
+#undef SRC
+#undef SRC_IDX
+#undef TRX_3F
+#undef TRX_4F
+#undef TRX_4FC
+#undef TRX_UB
+#undef TRX_US
+#undef TRX_UI
+
+
+/* GL_SHORT
+ */
+#define SRC GLshort
+#define SRC_IDX TYPE_IDX(GL_SHORT)
+#define TRX_3F(f,n) SHORT_TO_FLOAT( PTR_ELT(f,n) )
+#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
+#define TRX_4FC(f,n) (GLfloat)( PTR_ELT(f,n) )
+#define TRX_UB(ub, f,n) ub = SHORT_TO_UBYTE(PTR_ELT(f,n))
+#define TRX_US(us, f,n) us = SHORT_TO_USHORT(PTR_ELT(f,n))
+#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
+
+
+#define SZ 4
+#define INIT init_trans_4_GLshort_raw
+#define DEST_4F trans_4_GLshort_4f_raw
+#define DEST_4FC trans_4_GLshort_4fc_raw
+#define DEST_4UB trans_4_GLshort_4ub_raw
+#define DEST_4US trans_4_GLshort_4us_raw
+#include "m_trans_tmp.h"
+
+#define SZ 3
+#define INIT init_trans_3_GLshort_raw
+#define DEST_4F trans_3_GLshort_4f_raw
+#define DEST_4FC trans_3_GLshort_4fc_raw
+#define DEST_4UB trans_3_GLshort_4ub_raw
+#define DEST_4US trans_3_GLshort_4us_raw
+#define DEST_3F trans_3_GLshort_3f_raw
+#include "m_trans_tmp.h"
+
+#define SZ 2
+#define INIT init_trans_2_GLshort_raw
+#define DEST_4F trans_2_GLshort_4f_raw
+#define DEST_4FC trans_2_GLshort_4fc_raw
+#include "m_trans_tmp.h"
+
+#define SZ 1
+#define INIT init_trans_1_GLshort_raw
+#define DEST_4F trans_1_GLshort_4f_raw
+#define DEST_4FC trans_1_GLshort_4fc_raw
+#define DEST_1UB trans_1_GLshort_1ub_raw
+#define DEST_1UI trans_1_GLshort_1ui_raw
+#include "m_trans_tmp.h"
+
+
+#undef SRC
+#undef SRC_IDX
+#undef TRX_3F
+#undef TRX_4F
+#undef TRX_4FC
+#undef TRX_UB
+#undef TRX_US
+#undef TRX_UI
+
+
+/* GL_UNSIGNED_SHORT
+ */
+#define SRC GLushort
+#define SRC_IDX TYPE_IDX(GL_UNSIGNED_SHORT)
+#define TRX_3F(f,n) USHORT_TO_FLOAT( PTR_ELT(f,n) )
+#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
+#define TRX_4FC(f,n) (GLfloat)( PTR_ELT(f,n) )
+#define TRX_UB(ub,f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 8)
+#define TRX_US(us,f,n) us = (GLushort) (PTR_ELT(f,n) >> 8)
+#define TRX_UI(f,n) (GLuint) PTR_ELT(f,n)
+
+
+#define SZ 4
+#define INIT init_trans_4_GLushort_raw
+#define DEST_4F trans_4_GLushort_4f_raw
+#define DEST_4FC trans_4_GLushort_4fc_raw
+#define DEST_4UB trans_4_GLushort_4ub_raw
+#define DEST_4US trans_4_GLushort_4us_raw
+#include "m_trans_tmp.h"
+
+#define SZ 3
+#define INIT init_trans_3_GLushort_raw
+#define DEST_4F trans_3_GLushort_4f_raw
+#define DEST_4FC trans_3_GLushort_4fc_raw
+#define DEST_4UB trans_3_GLushort_4ub_raw
+#define DEST_4US trans_3_GLushort_4us_raw
+#define DEST_3F trans_3_GLushort_3f_raw
+#include "m_trans_tmp.h"
+
+#define SZ 2
+#define INIT init_trans_2_GLushort_raw
+#define DEST_4F trans_2_GLushort_4f_raw
+#define DEST_4FC trans_2_GLushort_4fc_raw
+#include "m_trans_tmp.h"
+
+#define SZ 1
+#define INIT init_trans_1_GLushort_raw
+#define DEST_4F trans_1_GLushort_4f_raw
+#define DEST_4FC trans_1_GLushort_4fc_raw
+#define DEST_1UB trans_1_GLushort_1ub_raw
+#define DEST_1UI trans_1_GLushort_1ui_raw
+#include "m_trans_tmp.h"
+
+#undef SRC
+#undef SRC_IDX
+#undef TRX_3F
+#undef TRX_4F
+#undef TRX_4FC
+#undef TRX_UB
+#undef TRX_US
+#undef TRX_UI
+
+
+/* GL_INT
+ */
+#define SRC GLint
+#define SRC_IDX TYPE_IDX(GL_INT)
+#define TRX_3F(f,n) INT_TO_FLOAT( PTR_ELT(f,n) )
+#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
+#define TRX_4FC(f,n) (GLfloat)( PTR_ELT(f,n) )
+#define TRX_UB(ub, f,n) ub = INT_TO_UBYTE(PTR_ELT(f,n))
+#define TRX_US(us, f,n) us = INT_TO_USHORT(PTR_ELT(f,n))
+#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
+
+
+#define SZ 4
+#define INIT init_trans_4_GLint_raw
+#define DEST_4F trans_4_GLint_4f_raw
+#define DEST_4FC trans_4_GLint_4fc_raw
+#define DEST_4UB trans_4_GLint_4ub_raw
+#define DEST_4US trans_4_GLint_4us_raw
+#include "m_trans_tmp.h"
+
+#define SZ 3
+#define INIT init_trans_3_GLint_raw
+#define DEST_4F trans_3_GLint_4f_raw
+#define DEST_4FC trans_3_GLint_4fc_raw
+#define DEST_4UB trans_3_GLint_4ub_raw
+#define DEST_4US trans_3_GLint_4us_raw
+#define DEST_3F trans_3_GLint_3f_raw
+#include "m_trans_tmp.h"
+
+#define SZ 2
+#define INIT init_trans_2_GLint_raw
+#define DEST_4F trans_2_GLint_4f_raw
+#define DEST_4FC trans_2_GLint_4fc_raw
+#include "m_trans_tmp.h"
+
+#define SZ 1
+#define INIT init_trans_1_GLint_raw
+#define DEST_4F trans_1_GLint_4f_raw
+#define DEST_4FC trans_1_GLint_4fc_raw
+#define DEST_1UB trans_1_GLint_1ub_raw
+#define DEST_1UI trans_1_GLint_1ui_raw
+#include "m_trans_tmp.h"
+
+
+#undef SRC
+#undef SRC_IDX
+#undef TRX_3F
+#undef TRX_4F
+#undef TRX_4FC
+#undef TRX_UB
+#undef TRX_US
+#undef TRX_UI
+
+
+/* GL_UNSIGNED_INT
+ */
+#define SRC GLuint
+#define SRC_IDX TYPE_IDX(GL_UNSIGNED_INT)
+#define TRX_3F(f,n) INT_TO_FLOAT( PTR_ELT(f,n) )
+#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
+#define TRX_4FC(f,n) (GLfloat)( PTR_ELT(f,n) )
+#define TRX_UB(ub, f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 24)
+#define TRX_US(us, f,n) us = (GLshort) (PTR_ELT(f,n) >> 16)
+#define TRX_UI(f,n) PTR_ELT(f,n)
+
+
+#define SZ 4
+#define INIT init_trans_4_GLuint_raw
+#define DEST_4F trans_4_GLuint_4f_raw
+#define DEST_4FC trans_4_GLuint_4fc_raw
+#define DEST_4UB trans_4_GLuint_4ub_raw
+#define DEST_4US trans_4_GLuint_4us_raw
+#include "m_trans_tmp.h"
+
+#define SZ 3
+#define INIT init_trans_3_GLuint_raw
+#define DEST_4F trans_3_GLuint_4f_raw
+#define DEST_4FC trans_3_GLuint_4fc_raw
+#define DEST_4UB trans_3_GLuint_4ub_raw
+#define DEST_4US trans_3_GLuint_4us_raw
+#define DEST_3F trans_3_GLuint_3f_raw
+#include "m_trans_tmp.h"
+
+#define SZ 2
+#define INIT init_trans_2_GLuint_raw
+#define DEST_4F trans_2_GLuint_4f_raw
+#define DEST_4FC trans_2_GLuint_4fc_raw
+#include "m_trans_tmp.h"
+
+#define SZ 1
+#define INIT init_trans_1_GLuint_raw
+#define DEST_4F trans_1_GLuint_4f_raw
+#define DEST_4FC trans_1_GLuint_4fc_raw
+#define DEST_1UB trans_1_GLuint_1ub_raw
+#define DEST_1UI trans_1_GLuint_1ui_raw
+#include "m_trans_tmp.h"
+
+#undef SRC
+#undef SRC_IDX
+#undef TRX_3F
+#undef TRX_4F
+#undef TRX_4FC
+#undef TRX_UB
+#undef TRX_US
+#undef TRX_UI
+
+
+/* GL_DOUBLE
+ */
+#define SRC GLdouble
+#define SRC_IDX TYPE_IDX(GL_DOUBLE)
+#define TRX_3F(f,n) (GLfloat) PTR_ELT(f,n)
+#define TRX_4F(f,n) (GLfloat) PTR_ELT(f,n)
+#define TRX_4FC(f,n) (GLfloat) PTR_ELT(f,n)
+#define TRX_UB(ub,f,n) UNCLAMPED_FLOAT_TO_UBYTE(ub, PTR_ELT(f,n))
+#define TRX_US(us,f,n) UNCLAMPED_FLOAT_TO_USHORT(us, PTR_ELT(f,n))
+#define TRX_UI(f,n) (GLuint) (GLint) PTR_ELT(f,n)
+#define TRX_1F(f,n) (GLfloat) PTR_ELT(f,n)
+
+
+#define SZ 4
+#define INIT init_trans_4_GLdouble_raw
+#define DEST_4F trans_4_GLdouble_4f_raw
+#define DEST_4FC trans_4_GLdouble_4fc_raw
+#define DEST_4UB trans_4_GLdouble_4ub_raw
+#define DEST_4US trans_4_GLdouble_4us_raw
+#include "m_trans_tmp.h"
+
+#define SZ 3
+#define INIT init_trans_3_GLdouble_raw
+#define DEST_4F trans_3_GLdouble_4f_raw
+#define DEST_4FC trans_3_GLdouble_4fc_raw
+#define DEST_4UB trans_3_GLdouble_4ub_raw
+#define DEST_4US trans_3_GLdouble_4us_raw
+#define DEST_3F trans_3_GLdouble_3f_raw
+#include "m_trans_tmp.h"
+
+#define SZ 2
+#define INIT init_trans_2_GLdouble_raw
+#define DEST_4F trans_2_GLdouble_4f_raw
+#define DEST_4FC trans_2_GLdouble_4fc_raw
+#include "m_trans_tmp.h"
+
+#define SZ 1
+#define INIT init_trans_1_GLdouble_raw
+#define DEST_4F trans_1_GLdouble_4f_raw
+#define DEST_4FC trans_1_GLdouble_4fc_raw
+#define DEST_1UB trans_1_GLdouble_1ub_raw
+#define DEST_1UI trans_1_GLdouble_1ui_raw
+#define DEST_1F trans_1_GLdouble_1f_raw
+#include "m_trans_tmp.h"
+
+#undef SRC
+#undef SRC_IDX
+
+/* GL_FLOAT
+ */
+#define SRC GLfloat
+#define SRC_IDX TYPE_IDX(GL_FLOAT)
+#define SZ 4
+#define INIT init_trans_4_GLfloat_raw
+#define DEST_4UB trans_4_GLfloat_4ub_raw
+#define DEST_4US trans_4_GLfloat_4us_raw
+#define DEST_4F trans_4_GLfloat_4f_raw
+#define DEST_4FC trans_4_GLfloat_4fc_raw
+#include "m_trans_tmp.h"
+
+#define SZ 3
+#define INIT init_trans_3_GLfloat_raw
+#define DEST_4F trans_3_GLfloat_4f_raw
+#define DEST_4FC trans_3_GLfloat_4fc_raw
+#define DEST_4UB trans_3_GLfloat_4ub_raw
+#define DEST_4US trans_3_GLfloat_4us_raw
+#define DEST_3F trans_3_GLfloat_3f_raw
+#include "m_trans_tmp.h"
+
+#define SZ 2
+#define INIT init_trans_2_GLfloat_raw
+#define DEST_4F trans_2_GLfloat_4f_raw
+#define DEST_4FC trans_2_GLfloat_4fc_raw
+#include "m_trans_tmp.h"
+
+#define SZ 1
+#define INIT init_trans_1_GLfloat_raw
+#define DEST_4F trans_1_GLfloat_4f_raw
+#define DEST_4FC trans_1_GLfloat_4fc_raw
+#define DEST_1UB trans_1_GLfloat_1ub_raw
+#define DEST_1UI trans_1_GLfloat_1ui_raw
+#define DEST_1F trans_1_GLfloat_1f_raw
+
+#include "m_trans_tmp.h"
+
+#undef SRC
+#undef SRC_IDX
+#undef TRX_3F
+#undef TRX_4F
+#undef TRX_4FC
+#undef TRX_UB
+#undef TRX_US
+#undef TRX_UI
+
+
+static void trans_4_GLubyte_4ub_raw(GLubyte (*t)[4],
+ CONST void *Ptr,
+ GLuint stride,
+ ARGS )
+{
+ const GLubyte *f = (GLubyte *) Ptr + SRC_START * stride;
+ GLuint i;
+
+ if (((((uintptr_t) f | (uintptr_t) stride)) & 3L) == 0L) {
+ /* Aligned.
+ */
+ for (i = DST_START ; i < n ; i++, f += stride) {
+ COPY_4UBV( t[i], f );
+ }
+ } else {
+ for (i = DST_START ; i < n ; i++, f += stride) {
+ t[i][0] = f[0];
+ t[i][1] = f[1];
+ t[i][2] = f[2];
+ t[i][3] = f[3];
+ }
+ }
+}
+
+
+static void init_translate_raw(void)
+{
+ MEMSET( TAB(_1ui), 0, sizeof(TAB(_1ui)) );
+ MEMSET( TAB(_1ub), 0, sizeof(TAB(_1ub)) );
+ MEMSET( TAB(_3f), 0, sizeof(TAB(_3f)) );
+ MEMSET( TAB(_4ub), 0, sizeof(TAB(_4ub)) );
+ MEMSET( TAB(_4us), 0, sizeof(TAB(_4us)) );
+ MEMSET( TAB(_4f), 0, sizeof(TAB(_4f)) );
+ MEMSET( TAB(_4fc), 0, sizeof(TAB(_4fc)) );
+
+ init_trans_4_GLbyte_raw();
+ init_trans_3_GLbyte_raw();
+ init_trans_2_GLbyte_raw();
+ init_trans_1_GLbyte_raw();
+ init_trans_1_GLubyte_raw();
+ init_trans_3_GLubyte_raw();
+ init_trans_4_GLubyte_raw();
+ init_trans_4_GLshort_raw();
+ init_trans_3_GLshort_raw();
+ init_trans_2_GLshort_raw();
+ init_trans_1_GLshort_raw();
+ init_trans_4_GLushort_raw();
+ init_trans_3_GLushort_raw();
+ init_trans_2_GLushort_raw();
+ init_trans_1_GLushort_raw();
+ init_trans_4_GLint_raw();
+ init_trans_3_GLint_raw();
+ init_trans_2_GLint_raw();
+ init_trans_1_GLint_raw();
+ init_trans_4_GLuint_raw();
+ init_trans_3_GLuint_raw();
+ init_trans_2_GLuint_raw();
+ init_trans_1_GLuint_raw();
+ init_trans_4_GLdouble_raw();
+ init_trans_3_GLdouble_raw();
+ init_trans_2_GLdouble_raw();
+ init_trans_1_GLdouble_raw();
+ init_trans_4_GLfloat_raw();
+ init_trans_3_GLfloat_raw();
+ init_trans_2_GLfloat_raw();
+ init_trans_1_GLfloat_raw();
+
+ TAB(_4ub)[4][TYPE_IDX(GL_UNSIGNED_BYTE)] = trans_4_GLubyte_4ub_raw;
+}
+
+
+#undef TAB
+#ifdef CLASS
+#undef CLASS
+#endif
+#undef ARGS
+#undef CHECK
+#undef SRC_START
+#undef DST_START
+#undef NEXT_F
+#undef NEXT_F2
+
+
+
+
+
+void _math_init_translate( void )
+{
+ init_translate_raw();
+}
+
+
+
+void _math_trans_1f(GLfloat *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint start,
+ GLuint n )
+{
+ _math_trans_1f_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
+}
+
+void _math_trans_1ui(GLuint *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint start,
+ GLuint n )
+{
+ _math_trans_1ui_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
+}
+
+void _math_trans_1ub(GLubyte *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint start,
+ GLuint n )
+{
+ _math_trans_1ub_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
+}
+
+
+void _math_trans_4ub(GLubyte (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint size,
+ GLuint start,
+ GLuint n )
+{
+ _math_trans_4ub_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
+}
+
+void _math_trans_4chan( GLchan (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint size,
+ GLuint start,
+ GLuint n )
+{
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ _math_trans_4ub( to, ptr, stride, type, size, start, n );
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ _math_trans_4us( to, ptr, stride, type, size, start, n );
+#elif CHAN_TYPE == GL_FLOAT
+ _math_trans_4fc( to, ptr, stride, type, size, start, n );
+#endif
+}
+
+void _math_trans_4us(GLushort (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint size,
+ GLuint start,
+ GLuint n )
+{
+ _math_trans_4us_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
+}
+
+void _math_trans_4f(GLfloat (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint size,
+ GLuint start,
+ GLuint n )
+{
+ _math_trans_4f_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
+}
+
+void _math_trans_4fc(GLfloat (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint size,
+ GLuint start,
+ GLuint n )
+{
+ _math_trans_4fc_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
+}
+
+void _math_trans_3f(GLfloat (*to)[3],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint start,
+ GLuint n )
+{
+ _math_trans_3f_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_translate.h b/nx-X11/extras/Mesa/src/mesa/math/m_translate.h
new file mode 100644
index 000000000..527c7063d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_translate.h
@@ -0,0 +1,106 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef _M_TRANSLATE_H_
+#define _M_TRANSLATE_H_
+
+#include "config.h"
+#include "mtypes.h" /* hack for GLchan */
+
+
+
+extern void _math_trans_1f(GLfloat *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint start,
+ GLuint n );
+
+extern void _math_trans_1ui(GLuint *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint start,
+ GLuint n );
+
+extern void _math_trans_1ub(GLubyte *to,
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint start,
+ GLuint n );
+
+extern void _math_trans_4ub(GLubyte (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint size,
+ GLuint start,
+ GLuint n );
+
+extern void _math_trans_4chan( GLchan (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint size,
+ GLuint start,
+ GLuint n );
+
+extern void _math_trans_4us(GLushort (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint size,
+ GLuint start,
+ GLuint n );
+
+extern void _math_trans_4f(GLfloat (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint size,
+ GLuint start,
+ GLuint n );
+
+extern void _math_trans_4fc(GLfloat (*to)[4],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint size,
+ GLuint start,
+ GLuint n );
+
+extern void _math_trans_3f(GLfloat (*to)[3],
+ CONST void *ptr,
+ GLuint stride,
+ GLenum type,
+ GLuint start,
+ GLuint n );
+
+extern void _math_init_translate( void );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_vector.c b/nx-X11/extras/Mesa/src/mesa/math/m_vector.c
new file mode 100644
index 000000000..3ad81d468
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_vector.c
@@ -0,0 +1,190 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * New (3.1) transformation code written by Keith Whitwell.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "macros.h"
+#include "imports.h"
+
+#include "m_vector.h"
+
+
+
+/*
+ * Given a vector [count][4] of floats, set all the [][elt] values
+ * to 0 (if elt = 0, 1, 2) or 1.0 (if elt = 3).
+ */
+void _mesa_vector4f_clean_elem( GLvector4f *vec, GLuint count, GLuint elt )
+{
+ static const GLubyte elem_bits[4] = {
+ VEC_DIRTY_0,
+ VEC_DIRTY_1,
+ VEC_DIRTY_2,
+ VEC_DIRTY_3
+ };
+ static const GLfloat clean[4] = { 0, 0, 0, 1 };
+ const GLfloat v = clean[elt];
+ GLfloat (*data)[4] = (GLfloat (*)[4])vec->start;
+ GLuint i;
+
+ for (i = 0 ; i < count ; i++)
+ data[i][elt] = v;
+
+ vec->flags &= ~elem_bits[elt];
+}
+
+static const GLubyte size_bits[5] = {
+ 0,
+ VEC_SIZE_1,
+ VEC_SIZE_2,
+ VEC_SIZE_3,
+ VEC_SIZE_4,
+};
+
+
+
+/*
+ * Initialize GLvector objects.
+ * Input: v - the vector object to initialize.
+ * flags - bitwise-OR of VEC_* flags
+ * storage - pointer to storage for the vector's data
+ */
+
+
+void _mesa_vector4f_init( GLvector4f *v, GLuint flags, GLfloat (*storage)[4] )
+{
+ v->stride = 4 * sizeof(GLfloat);
+ v->size = 2; /* may change: 2-4 for vertices and 1-4 for texcoords */
+ v->data = storage;
+ v->start = (GLfloat *) storage;
+ v->count = 0;
+ v->flags = size_bits[4] | flags ;
+}
+
+
+
+
+/*
+ * Initialize GLvector objects and allocate storage.
+ * Input: v - the vector object
+ * sz - unused????
+ * flags - bitwise-OR of VEC_* flags
+ * count - number of elements to allocate in vector
+ * alignment - desired memory alignment for the data (in bytes)
+ */
+
+
+void _mesa_vector4f_alloc( GLvector4f *v, GLuint flags, GLuint count,
+ GLuint alignment )
+{
+ v->stride = 4 * sizeof(GLfloat);
+ v->size = 2;
+ v->storage = ALIGN_MALLOC( count * 4 * sizeof(GLfloat), alignment );
+ v->start = (GLfloat *) v->storage;
+ v->data = (GLfloat (*)[4]) v->storage;
+ v->count = 0;
+ v->flags = size_bits[4] | flags | VEC_MALLOC ;
+}
+
+
+
+
+/*
+ * Vector deallocation. Free whatever memory is pointed to by the
+ * vector's storage field if the VEC_MALLOC flag is set.
+ * DO NOT free the GLvector object itself, though.
+ */
+
+
+void _mesa_vector4f_free( GLvector4f *v )
+{
+ if (v->flags & VEC_MALLOC) {
+ ALIGN_FREE( v->storage );
+ v->data = NULL;
+ v->start = NULL;
+ v->storage = NULL;
+ v->flags &= ~VEC_MALLOC;
+ }
+}
+
+
+/*
+ * For debugging
+ */
+void _mesa_vector4f_print( GLvector4f *v, GLubyte *cullmask, GLboolean culling )
+{
+ GLfloat c[4] = { 0, 0, 0, 1 };
+ const char *templates[5] = {
+ "%d:\t0, 0, 0, 1\n",
+ "%d:\t%f, 0, 0, 1\n",
+ "%d:\t%f, %f, 0, 1\n",
+ "%d:\t%f, %f, %f, 1\n",
+ "%d:\t%f, %f, %f, %f\n"
+ };
+
+ const char *t = templates[v->size];
+ GLfloat *d = (GLfloat *)v->data;
+ GLuint j, i = 0, count;
+
+ _mesa_printf("data-start\n");
+ for ( ; d != v->start ; STRIDE_F(d, v->stride), i++)
+ _mesa_printf(t, i, d[0], d[1], d[2], d[3]);
+
+ _mesa_printf("start-count(%u)\n", v->count);
+ count = i + v->count;
+
+ if (culling) {
+ for ( ; i < count ; STRIDE_F(d, v->stride), i++)
+ if (cullmask[i])
+ _mesa_printf(t, i, d[0], d[1], d[2], d[3]);
+ }
+ else {
+ for ( ; i < count ; STRIDE_F(d, v->stride), i++)
+ _mesa_printf(t, i, d[0], d[1], d[2], d[3]);
+ }
+
+ for (j = v->size ; j < 4; j++) {
+ if ((v->flags & (1<<j)) == 0) {
+
+ _mesa_printf("checking col %u is clean as advertised ", j);
+
+ for (i = 0, d = (GLfloat *) v->data ;
+ i < count && d[j] == c[j] ;
+ i++, STRIDE_F(d, v->stride)) {};
+
+ if (i == count)
+ _mesa_printf(" --> ok\n");
+ else
+ _mesa_printf(" --> Failed at %u ******\n", i);
+ }
+ }
+}
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_vector.h b/nx-X11/extras/Mesa/src/mesa/math/m_vector.h
new file mode 100644
index 000000000..222b47f6e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_vector.h
@@ -0,0 +1,95 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * New (3.1) transformation code written by Keith Whitwell.
+ */
+
+
+#ifndef _M_VECTOR_H_
+#define _M_VECTOR_H_
+
+#include "glheader.h"
+#include "mtypes.h" /* hack for GLchan */
+
+
+#define VEC_DIRTY_0 0x1
+#define VEC_DIRTY_1 0x2
+#define VEC_DIRTY_2 0x4
+#define VEC_DIRTY_3 0x8
+#define VEC_MALLOC 0x10 /* storage field points to self-allocated mem*/
+#define VEC_NOT_WRITEABLE 0x40 /* writable elements to hold clipped data */
+#define VEC_BAD_STRIDE 0x100 /* matches tnl's prefered stride */
+
+
+#define VEC_SIZE_1 VEC_DIRTY_0
+#define VEC_SIZE_2 (VEC_DIRTY_0|VEC_DIRTY_1)
+#define VEC_SIZE_3 (VEC_DIRTY_0|VEC_DIRTY_1|VEC_DIRTY_2)
+#define VEC_SIZE_4 (VEC_DIRTY_0|VEC_DIRTY_1|VEC_DIRTY_2|VEC_DIRTY_3)
+
+
+
+/* Wrap all the information about vectors up in a struct. Has
+ * additional fields compared to the other vectors to help us track of
+ * different vertex sizes, and whether we need to clean columns out
+ * because they contain non-(0,0,0,1) values.
+ *
+ * The start field is used to reserve data for copied vertices at the
+ * end of _mesa_transform_vb, and avoids the need for a multiplication in
+ * the transformation routines.
+ */
+typedef struct {
+ GLfloat (*data)[4]; /* may be malloc'd or point to client data */
+ GLfloat *start; /* points somewhere inside of <data> */
+ GLuint count; /* size of the vector (in elements) */
+ GLuint stride; /* stride from one element to the next (in bytes) */
+ GLuint size; /* 2-4 for vertices and 1-4 for texcoords */
+ GLuint flags; /* which columns are dirty */
+ void *storage; /* self-allocated storage */
+} GLvector4f;
+
+
+extern void _mesa_vector4f_init( GLvector4f *v, GLuint flags,
+ GLfloat (*storage)[4] );
+extern void _mesa_vector4f_alloc( GLvector4f *v, GLuint flags,
+ GLuint count, GLuint alignment );
+extern void _mesa_vector4f_free( GLvector4f *v );
+extern void _mesa_vector4f_print( GLvector4f *v, GLubyte *, GLboolean );
+extern void _mesa_vector4f_clean_elem( GLvector4f *vec, GLuint nr, GLuint elt );
+
+
+
+
+
+/*
+ * Given vector <v>, return a pointer (cast to <type *> to the <i>-th element.
+ *
+ * End up doing a lot of slow imuls if not careful.
+ */
+#define VEC_ELT( v, type, i ) \
+ ( (type *) ( ((GLbyte *) ((v)->data)) + (i) * (v)->stride) )
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_xform.c b/nx-X11/extras/Mesa/src/mesa/math/m_xform.c
new file mode 100644
index 000000000..5366e3498
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_xform.c
@@ -0,0 +1,230 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+
+/*
+ * Matrix/vertex/vector transformation stuff
+ *
+ *
+ * NOTES:
+ * 1. 4x4 transformation matrices are stored in memory in column major order.
+ * 2. Points/vertices are to be thought of as column vectors.
+ * 3. Transformation of a point p by a matrix M is: p' = M * p
+ */
+
+#include "glheader.h"
+#include "macros.h"
+
+#include "m_eval.h"
+#include "m_matrix.h"
+#include "m_translate.h"
+#include "m_xform.h"
+#include "mathmod.h"
+
+
+#ifdef DEBUG
+#include "m_debug.h"
+#endif
+
+#ifdef USE_X86_ASM
+#include "x86/common_x86_asm.h"
+#endif
+
+#ifdef USE_X86_64_ASM
+#include "x86-64/x86-64.h"
+#endif
+
+#ifdef USE_SPARC_ASM
+#include "sparc/sparc.h"
+#endif
+
+#ifdef USE_PPC_ASM
+#include "ppc/common_ppc_features.h"
+#endif
+
+clip_func _mesa_clip_tab[5];
+clip_func _mesa_clip_np_tab[5];
+dotprod_func _mesa_dotprod_tab[5];
+vec_copy_func _mesa_copy_tab[0x10];
+normal_func _mesa_normal_tab[0xf];
+transform_func *_mesa_transform_tab[5];
+
+
+/* Raw data format used for:
+ * - Object-to-eye transform prior to culling, although this too
+ * could be culled under some circumstances.
+ * - Eye-to-clip transform (via the function above).
+ * - Cliptesting
+ * - And everything else too, if culling happens to be disabled.
+ *
+ * GH: It's used for everything now, as clipping/culling is done
+ * elsewhere (most often by the driver itself).
+ */
+#define TAG(x) x
+#define TAG2(x,y) x##y
+#define STRIDE_LOOP for ( i = 0 ; i < count ; i++, STRIDE_F(from, stride) )
+#define LOOP for ( i = 0 ; i < n ; i++ )
+#define ARGS
+#include "m_xform_tmp.h"
+#include "m_clip_tmp.h"
+#include "m_norm_tmp.h"
+#include "m_dotprod_tmp.h"
+#include "m_copy_tmp.h"
+#undef TAG
+#undef TAG2
+#undef LOOP
+#undef ARGS
+
+
+
+
+GLvector4f *_mesa_project_points( GLvector4f *proj_vec,
+ const GLvector4f *clip_vec )
+{
+ const GLuint stride = clip_vec->stride;
+ const GLfloat *from = (GLfloat *)clip_vec->start;
+ const GLuint count = clip_vec->count;
+ GLfloat (*vProj)[4] = (GLfloat (*)[4])proj_vec->start;
+ GLuint i;
+
+ for (i = 0 ; i < count ; i++, STRIDE_F(from, stride))
+ {
+ GLfloat oow = 1.0F / from[3];
+ vProj[i][3] = oow;
+ vProj[i][0] = from[0] * oow;
+ vProj[i][1] = from[1] * oow;
+ vProj[i][2] = from[2] * oow;
+ }
+
+ proj_vec->flags |= VEC_SIZE_4;
+ proj_vec->size = 3;
+ proj_vec->count = clip_vec->count;
+ return proj_vec;
+}
+
+
+
+
+
+
+/*
+ * Transform a 4-element row vector (1x4 matrix) by a 4x4 matrix. This
+ * function is used for transforming clipping plane equations and spotlight
+ * directions.
+ * Mathematically, u = v * m.
+ * Input: v - input vector
+ * m - transformation matrix
+ * Output: u - transformed vector
+ */
+void _mesa_transform_vector( GLfloat u[4], const GLfloat v[4], const GLfloat m[16] )
+{
+ GLfloat v0=v[0], v1=v[1], v2=v[2], v3=v[3];
+#define M(row,col) m[row + col*4]
+ u[0] = v0 * M(0,0) + v1 * M(1,0) + v2 * M(2,0) + v3 * M(3,0);
+ u[1] = v0 * M(0,1) + v1 * M(1,1) + v2 * M(2,1) + v3 * M(3,1);
+ u[2] = v0 * M(0,2) + v1 * M(1,2) + v2 * M(2,2) + v3 * M(3,2);
+ u[3] = v0 * M(0,3) + v1 * M(1,3) + v2 * M(2,3) + v3 * M(3,3);
+#undef M
+}
+
+
+/* Useful for one-off point transformations, as in clipping.
+ * Note that because the matrix isn't analysed we do too many
+ * multiplies, and that the result is always 4-clean.
+ */
+void _mesa_transform_point_sz( GLfloat Q[4], const GLfloat M[16],
+ const GLfloat P[4], GLuint sz )
+{
+ if (Q == P)
+ return;
+
+ if (sz == 4)
+ {
+ Q[0] = M[0] * P[0] + M[4] * P[1] + M[8] * P[2] + M[12] * P[3];
+ Q[1] = M[1] * P[0] + M[5] * P[1] + M[9] * P[2] + M[13] * P[3];
+ Q[2] = M[2] * P[0] + M[6] * P[1] + M[10] * P[2] + M[14] * P[3];
+ Q[3] = M[3] * P[0] + M[7] * P[1] + M[11] * P[2] + M[15] * P[3];
+ }
+ else if (sz == 3)
+ {
+ Q[0] = M[0] * P[0] + M[4] * P[1] + M[8] * P[2] + M[12];
+ Q[1] = M[1] * P[0] + M[5] * P[1] + M[9] * P[2] + M[13];
+ Q[2] = M[2] * P[0] + M[6] * P[1] + M[10] * P[2] + M[14];
+ Q[3] = M[3] * P[0] + M[7] * P[1] + M[11] * P[2] + M[15];
+ }
+ else if (sz == 2)
+ {
+ Q[0] = M[0] * P[0] + M[4] * P[1] + M[12];
+ Q[1] = M[1] * P[0] + M[5] * P[1] + M[13];
+ Q[2] = M[2] * P[0] + M[6] * P[1] + M[14];
+ Q[3] = M[3] * P[0] + M[7] * P[1] + M[15];
+ }
+ else if (sz == 1)
+ {
+ Q[0] = M[0] * P[0] + M[12];
+ Q[1] = M[1] * P[0] + M[13];
+ Q[2] = M[2] * P[0] + M[14];
+ Q[3] = M[3] * P[0] + M[15];
+ }
+}
+
+
+/*
+ * This is called only once. It initializes several tables with pointers
+ * to optimized transformation functions. This is where we can test for
+ * AMD 3Dnow! capability, Intel SSE, etc. and hook in the right code.
+ */
+void
+_math_init_transformation( void )
+{
+ init_c_transformations();
+ init_c_norm_transform();
+ init_c_cliptest();
+ init_copy0();
+ init_dotprod();
+
+#ifdef DEBUG
+ _math_test_all_transform_functions( "default" );
+ _math_test_all_normal_transform_functions( "default" );
+ _math_test_all_cliptest_functions( "default" );
+#endif
+
+#ifdef USE_X86_ASM
+ _mesa_init_all_x86_transform_asm();
+#elif defined( USE_SPARC_ASM )
+ _mesa_init_all_sparc_transform_asm();
+#elif defined( USE_PPC_ASM )
+ _mesa_init_all_ppc_transform_asm();
+#elif defined( USE_X86_64_ASM )
+ _mesa_init_all_x86_64_transform_asm();
+#endif
+}
+
+void
+_math_init( void )
+{
+ _math_init_transformation();
+ _math_init_translate();
+ _math_init_eval();
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_xform.h b/nx-X11/extras/Mesa/src/mesa/math/m_xform.h
new file mode 100644
index 000000000..63f1062fc
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_xform.h
@@ -0,0 +1,185 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef _M_XFORM_H
+#define _M_XFORM_H
+
+
+#include "glheader.h"
+#include "config.h"
+#include "math/m_vector.h"
+#include "math/m_matrix.h"
+
+#ifdef USE_X86_ASM
+#define _XFORMAPI _ASMAPI
+#define _XFORMAPIP _ASMAPIP
+#else
+#define _XFORMAPI
+#define _XFORMAPIP *
+#endif
+
+
+extern void
+_mesa_transform_vector(GLfloat u[4], CONST GLfloat v[4], CONST GLfloat m[16]);
+
+
+extern void
+_math_init_transformation(void);
+
+
+/* KW: Clip functions now do projective divide as well. The projected
+ * coordinates are very useful to us because they let us cull
+ * backfaces and eliminate vertices from lighting, fogging, etc
+ * calculations. Despite the fact that this divide could be done one
+ * day in hardware, we would still have a reason to want to do it here
+ * as long as those other calculations remain in software.
+ *
+ * Clipping is a convenient place to do the divide on x86 as it should be
+ * possible to overlap with integer outcode calculations.
+ *
+ * There are two cases where we wouldn't want to do the divide in cliptest:
+ * - When we aren't clipping. We still might want to cull backfaces
+ * so the divide should be done elsewhere. This currently never
+ * happens.
+ *
+ * - When culling isn't likely to help us, such as when the GL culling
+ * is disabled and we not lighting or are only lighting
+ * one-sided. In this situation, backface determination provides
+ * us with no useful information. A tricky case to detect is when
+ * all input data is already culled, although hopefully the
+ * application wouldn't turn on culling in such cases.
+ *
+ * We supply a buffer to hold the [x/w,y/w,z/w,1/w] values which
+ * are the result of the projection. This is only used in the
+ * 4-vector case - in other cases, we just use the clip coordinates
+ * as the projected coordinates - they are identical.
+ *
+ * This is doubly convenient because it means the Win[] array is now
+ * of the same stride as all the others, so I can now turn map_vertices
+ * into a straight-forward matrix transformation, with asm acceleration
+ * automatically available.
+ */
+
+/* Vertex buffer clipping flags
+ */
+#define CLIP_RIGHT_SHIFT 0
+#define CLIP_LEFT_SHIFT 1
+#define CLIP_TOP_SHIFT 2
+#define CLIP_BOTTOM_SHIFT 3
+#define CLIP_NEAR_SHIFT 4
+#define CLIP_FAR_SHIFT 5
+
+#define CLIP_RIGHT_BIT 0x01
+#define CLIP_LEFT_BIT 0x02
+#define CLIP_TOP_BIT 0x04
+#define CLIP_BOTTOM_BIT 0x08
+#define CLIP_NEAR_BIT 0x10
+#define CLIP_FAR_BIT 0x20
+#define CLIP_USER_BIT 0x40
+#define CLIP_CULL_BIT 0x80
+#define CLIP_ALL_BITS 0x3f
+
+
+typedef GLvector4f * (_XFORMAPIP clip_func)( GLvector4f *vClip,
+ GLvector4f *vProj,
+ GLubyte clipMask[],
+ GLubyte *orMask,
+ GLubyte *andMask );
+
+typedef void (*dotprod_func)( GLfloat *out,
+ GLuint out_stride,
+ CONST GLvector4f *coord_vec,
+ CONST GLfloat plane[4] );
+
+typedef void (*vec_copy_func)( GLvector4f *to,
+ CONST GLvector4f *from );
+
+
+
+/*
+ * Functions for transformation of normals in the VB.
+ */
+typedef void (_NORMAPIP normal_func)( CONST GLmatrix *mat,
+ GLfloat scale,
+ CONST GLvector4f *in,
+ CONST GLfloat lengths[],
+ GLvector4f *dest );
+
+
+/* Flags for selecting a normal transformation function.
+ */
+#define NORM_RESCALE 0x1 /* apply the scale factor */
+#define NORM_NORMALIZE 0x2 /* normalize */
+#define NORM_TRANSFORM 0x4 /* apply the transformation matrix */
+#define NORM_TRANSFORM_NO_ROT 0x8 /* apply the transformation matrix */
+
+
+
+
+/* KW: New versions of the transform function allow a mask array
+ * specifying that individual vector transform should be skipped
+ * when the mask byte is zero. This is always present as a
+ * parameter, to allow a unified interface.
+ */
+typedef void (_XFORMAPIP transform_func)( GLvector4f *to_vec,
+ CONST GLfloat m[16],
+ CONST GLvector4f *from_vec );
+
+
+extern GLvector4f *_mesa_project_points( GLvector4f *to,
+ CONST GLvector4f *from );
+
+extern void _mesa_transform_bounds3( GLubyte *orMask, GLubyte *andMask,
+ CONST GLfloat m[16],
+ CONST GLfloat src[][3] );
+
+extern void _mesa_transform_bounds2( GLubyte *orMask, GLubyte *andMask,
+ CONST GLfloat m[16],
+ CONST GLfloat src[][3] );
+
+
+extern dotprod_func _mesa_dotprod_tab[5];
+extern vec_copy_func _mesa_copy_tab[0x10];
+extern vec_copy_func _mesa_copy_clean_tab[5];
+extern clip_func _mesa_clip_tab[5];
+extern clip_func _mesa_clip_np_tab[5];
+extern normal_func _mesa_normal_tab[0xf];
+
+/* Use of 2 layers of linked 1-dimensional arrays to reduce
+ * cost of lookup.
+ */
+extern transform_func *_mesa_transform_tab[5];
+
+
+extern void _mesa_transform_point_sz( GLfloat Q[4], CONST GLfloat M[16],
+ CONST GLfloat P[4], GLuint sz );
+
+
+#define TransformRaw( to, mat, from ) \
+ ( _mesa_transform_tab[(from)->size][(mat)->type]( to, (mat)->m, from ), \
+ (to) )
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/math/m_xform_tmp.h b/nx-X11/extras/Mesa/src/mesa/math/m_xform_tmp.h
new file mode 100644
index 000000000..e93837725
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/m_xform_tmp.h
@@ -0,0 +1,810 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * New (3.1) transformation code written by Keith Whitwell.
+ */
+
+
+/*----------------------------------------------------------------------
+ * Begin Keith's new code
+ *
+ *----------------------------------------------------------------------
+ */
+
+/* KW: Fixed stride, now measured in bytes as is the OpenGL array stride.
+ */
+
+/* KW: These are now parameterized to produce two versions, one
+ * which transforms all incoming points, and a second which
+ * takes notice of a cullmask array, and only transforms
+ * unculled vertices.
+ */
+
+/* KW: 1-vectors can sneak into the texture pipeline via the array
+ * interface. These functions are here because I want consistant
+ * treatment of the vertex sizes and a lazy strategy for
+ * cleaning unused parts of the vector, and so as not to exclude
+ * them from the vertex array interface.
+ *
+ * Under our current analysis of matrices, there is no way that
+ * the product of a matrix and a 1-vector can remain a 1-vector,
+ * with the exception of the identity transform.
+ */
+
+/* KW: No longer zero-pad outgoing vectors. Now that external
+ * vectors can get into the pipeline we cannot ever assume
+ * that there is more to a vector than indicated by its
+ * size.
+ */
+
+/* KW: Now uses clipmask and a flag to allow us to skip both/either
+ * cliped and/or culled vertices.
+ */
+
+/* GH: Not any more -- it's easier (and faster) to just process the
+ * entire vector. Clipping and culling are handled further down
+ * the pipe, most often during or after the conversion to some
+ * driver-specific vertex format.
+ */
+
+static void _XFORMAPI
+TAG(transform_points1_general)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m12 = m[12];
+ const GLfloat m1 = m[1], m13 = m[13];
+ const GLfloat m2 = m[2], m14 = m[14];
+ const GLfloat m3 = m[3], m15 = m[15];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0];
+ to[i][0] = m0 * ox + m12;
+ to[i][1] = m1 * ox + m13;
+ to[i][2] = m2 * ox + m14;
+ to[i][3] = m3 * ox + m15;
+ }
+ to_vec->size = 4;
+ to_vec->flags |= VEC_SIZE_4;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points1_identity)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLuint count = from_vec->count;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint i;
+ (void) m;
+ if (to_vec == from_vec) return;
+ STRIDE_LOOP {
+ to[i][0] = from[0];
+ }
+ to_vec->size = 1;
+ to_vec->flags |= VEC_SIZE_1;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points1_2d)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m1 = m[1];
+ const GLfloat m12 = m[12], m13 = m[13];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0];
+ to[i][0] = m0 * ox + m12;
+ to[i][1] = m1 * ox + m13;
+ }
+ to_vec->size = 2;
+ to_vec->flags |= VEC_SIZE_2;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points1_2d_no_rot)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m12 = m[12], m13 = m[13];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0];
+ to[i][0] = m0 * ox + m12;
+ to[i][1] = m13;
+ }
+ to_vec->size = 2;
+ to_vec->flags |= VEC_SIZE_2;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points1_3d)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m1 = m[1], m2 = m[2];
+ const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0];
+ to[i][0] = m0 * ox + m12;
+ to[i][1] = m1 * ox + m13;
+ to[i][2] = m2 * ox + m14;
+ }
+ to_vec->size = 3;
+ to_vec->flags |= VEC_SIZE_3;
+ to_vec->count = from_vec->count;
+}
+
+
+static void _XFORMAPI
+TAG(transform_points1_3d_no_rot)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0];
+ const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0];
+ to[i][0] = m0 * ox + m12;
+ to[i][1] = m13;
+ to[i][2] = m14;
+ }
+ to_vec->size = 3;
+ to_vec->flags |= VEC_SIZE_3;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points1_perspective)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m14 = m[14];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0];
+ to[i][0] = m0 * ox ;
+ to[i][1] = 0 ;
+ to[i][2] = m14;
+ to[i][3] = 0;
+ }
+ to_vec->size = 4;
+ to_vec->flags |= VEC_SIZE_4;
+ to_vec->count = from_vec->count;
+}
+
+
+
+
+/* 2-vectors, which are a lot more relevant than 1-vectors, are
+ * present early in the geometry pipeline and throughout the
+ * texture pipeline.
+ */
+static void _XFORMAPI
+TAG(transform_points2_general)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m4 = m[4], m12 = m[12];
+ const GLfloat m1 = m[1], m5 = m[5], m13 = m[13];
+ const GLfloat m2 = m[2], m6 = m[6], m14 = m[14];
+ const GLfloat m3 = m[3], m7 = m[7], m15 = m[15];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1];
+ to[i][0] = m0 * ox + m4 * oy + m12;
+ to[i][1] = m1 * ox + m5 * oy + m13;
+ to[i][2] = m2 * ox + m6 * oy + m14;
+ to[i][3] = m3 * ox + m7 * oy + m15;
+ }
+ to_vec->size = 4;
+ to_vec->flags |= VEC_SIZE_4;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points2_identity)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ GLuint i;
+ (void) m;
+ if (to_vec == from_vec) return;
+ STRIDE_LOOP {
+ to[i][0] = from[0];
+ to[i][1] = from[1];
+ }
+ to_vec->size = 2;
+ to_vec->flags |= VEC_SIZE_2;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points2_2d)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5];
+ const GLfloat m12 = m[12], m13 = m[13];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1];
+ to[i][0] = m0 * ox + m4 * oy + m12;
+ to[i][1] = m1 * ox + m5 * oy + m13;
+ }
+ to_vec->size = 2;
+ to_vec->flags |= VEC_SIZE_2;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points2_2d_no_rot)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1];
+ to[i][0] = m0 * ox + m12;
+ to[i][1] = m5 * oy + m13;
+ }
+ to_vec->size = 2;
+ to_vec->flags |= VEC_SIZE_2;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points2_3d)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5];
+ const GLfloat m6 = m[6], m12 = m[12], m13 = m[13], m14 = m[14];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1];
+ to[i][0] = m0 * ox + m4 * oy + m12;
+ to[i][1] = m1 * ox + m5 * oy + m13;
+ to[i][2] = m2 * ox + m6 * oy + m14;
+ }
+ to_vec->size = 3;
+ to_vec->flags |= VEC_SIZE_3;
+ to_vec->count = from_vec->count;
+}
+
+
+/* I would actually say this was a fairly important function, from
+ * a texture transformation point of view.
+ */
+static void _XFORMAPI
+TAG(transform_points2_3d_no_rot)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m5 = m[5];
+ const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1];
+ to[i][0] = m0 * ox + m12;
+ to[i][1] = m5 * oy + m13;
+ to[i][2] = m14;
+ }
+ if (m14 == 0) {
+ to_vec->size = 2;
+ to_vec->flags |= VEC_SIZE_2;
+ } else {
+ to_vec->size = 3;
+ to_vec->flags |= VEC_SIZE_3;
+ }
+ to_vec->count = from_vec->count;
+}
+
+
+static void _XFORMAPI
+TAG(transform_points2_perspective)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m5 = m[5], m14 = m[14];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1];
+ to[i][0] = m0 * ox ;
+ to[i][1] = m5 * oy ;
+ to[i][2] = m14;
+ to[i][3] = 0;
+ }
+ to_vec->size = 4;
+ to_vec->flags |= VEC_SIZE_4;
+ to_vec->count = from_vec->count;
+}
+
+
+
+static void _XFORMAPI
+TAG(transform_points3_general)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12];
+ const GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13];
+ const GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14];
+ const GLfloat m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1], oz = from[2];
+ to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12;
+ to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13;
+ to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14;
+ to[i][3] = m3 * ox + m7 * oy + m11 * oz + m15;
+ }
+ to_vec->size = 4;
+ to_vec->flags |= VEC_SIZE_4;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points3_identity)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ GLuint i;
+ (void) m;
+ if (to_vec == from_vec) return;
+ STRIDE_LOOP {
+ to[i][0] = from[0];
+ to[i][1] = from[1];
+ to[i][2] = from[2];
+ }
+ to_vec->size = 3;
+ to_vec->flags |= VEC_SIZE_3;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points3_2d)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5];
+ const GLfloat m12 = m[12], m13 = m[13];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1], oz = from[2];
+ to[i][0] = m0 * ox + m4 * oy + m12 ;
+ to[i][1] = m1 * ox + m5 * oy + m13 ;
+ to[i][2] = + oz ;
+ }
+ to_vec->size = 3;
+ to_vec->flags |= VEC_SIZE_3;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points3_2d_no_rot)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1], oz = from[2];
+ to[i][0] = m0 * ox + m12 ;
+ to[i][1] = m5 * oy + m13 ;
+ to[i][2] = + oz ;
+ }
+ to_vec->size = 3;
+ to_vec->flags |= VEC_SIZE_3;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points3_3d)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5];
+ const GLfloat m6 = m[6], m8 = m[8], m9 = m[9], m10 = m[10];
+ const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1], oz = from[2];
+ to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12 ;
+ to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13 ;
+ to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14 ;
+ }
+ to_vec->size = 3;
+ to_vec->flags |= VEC_SIZE_3;
+ to_vec->count = from_vec->count;
+}
+
+/* previously known as ortho...
+ */
+static void _XFORMAPI
+TAG(transform_points3_3d_no_rot)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m5 = m[5];
+ const GLfloat m10 = m[10], m12 = m[12], m13 = m[13], m14 = m[14];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1], oz = from[2];
+ to[i][0] = m0 * ox + m12 ;
+ to[i][1] = m5 * oy + m13 ;
+ to[i][2] = m10 * oz + m14 ;
+ }
+ to_vec->size = 3;
+ to_vec->flags |= VEC_SIZE_3;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points3_perspective)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m5 = m[5], m8 = m[8], m9 = m[9];
+ const GLfloat m10 = m[10], m14 = m[14];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1], oz = from[2];
+ to[i][0] = m0 * ox + m8 * oz ;
+ to[i][1] = m5 * oy + m9 * oz ;
+ to[i][2] = m10 * oz + m14 ;
+ to[i][3] = -oz ;
+ }
+ to_vec->size = 4;
+ to_vec->flags |= VEC_SIZE_4;
+ to_vec->count = from_vec->count;
+}
+
+
+
+static void _XFORMAPI
+TAG(transform_points4_general)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12];
+ const GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13];
+ const GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14];
+ const GLfloat m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
+ to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12 * ow;
+ to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13 * ow;
+ to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14 * ow;
+ to[i][3] = m3 * ox + m7 * oy + m11 * oz + m15 * ow;
+ }
+ to_vec->size = 4;
+ to_vec->flags |= VEC_SIZE_4;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points4_identity)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ GLuint i;
+ (void) m;
+ if (to_vec == from_vec) return;
+ STRIDE_LOOP {
+ to[i][0] = from[0];
+ to[i][1] = from[1];
+ to[i][2] = from[2];
+ to[i][3] = from[3];
+ }
+ to_vec->size = 4;
+ to_vec->flags |= VEC_SIZE_4;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points4_2d)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5];
+ const GLfloat m12 = m[12], m13 = m[13];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
+ to[i][0] = m0 * ox + m4 * oy + m12 * ow;
+ to[i][1] = m1 * ox + m5 * oy + m13 * ow;
+ to[i][2] = + oz ;
+ to[i][3] = ow;
+ }
+ to_vec->size = 4;
+ to_vec->flags |= VEC_SIZE_4;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points4_2d_no_rot)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
+ to[i][0] = m0 * ox + m12 * ow;
+ to[i][1] = m5 * oy + m13 * ow;
+ to[i][2] = + oz ;
+ to[i][3] = ow;
+ }
+ to_vec->size = 4;
+ to_vec->flags |= VEC_SIZE_4;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points4_3d)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5];
+ const GLfloat m6 = m[6], m8 = m[8], m9 = m[9], m10 = m[10];
+ const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
+ to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12 * ow;
+ to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13 * ow;
+ to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14 * ow;
+ to[i][3] = ow;
+ }
+ to_vec->size = 4;
+ to_vec->flags |= VEC_SIZE_4;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points4_3d_no_rot)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m5 = m[5];
+ const GLfloat m10 = m[10], m12 = m[12], m13 = m[13], m14 = m[14];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
+ to[i][0] = m0 * ox + m12 * ow;
+ to[i][1] = m5 * oy + m13 * ow;
+ to[i][2] = m10 * oz + m14 * ow;
+ to[i][3] = ow;
+ }
+ to_vec->size = 4;
+ to_vec->flags |= VEC_SIZE_4;
+ to_vec->count = from_vec->count;
+}
+
+static void _XFORMAPI
+TAG(transform_points4_perspective)( GLvector4f *to_vec,
+ const GLfloat m[16],
+ const GLvector4f *from_vec )
+{
+ const GLuint stride = from_vec->stride;
+ GLfloat *from = from_vec->start;
+ GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
+ GLuint count = from_vec->count;
+ const GLfloat m0 = m[0], m5 = m[5], m8 = m[8], m9 = m[9];
+ const GLfloat m10 = m[10], m14 = m[14];
+ GLuint i;
+ STRIDE_LOOP {
+ const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
+ to[i][0] = m0 * ox + m8 * oz ;
+ to[i][1] = m5 * oy + m9 * oz ;
+ to[i][2] = m10 * oz + m14 * ow ;
+ to[i][3] = -oz ;
+ }
+ to_vec->size = 4;
+ to_vec->flags |= VEC_SIZE_4;
+ to_vec->count = from_vec->count;
+}
+
+static transform_func TAG(transform_tab_1)[7];
+static transform_func TAG(transform_tab_2)[7];
+static transform_func TAG(transform_tab_3)[7];
+static transform_func TAG(transform_tab_4)[7];
+
+/* Similar functions could be called several times, with more highly
+ * optimized routines overwriting the arrays. This only occurs during
+ * startup.
+ */
+static void _XFORMAPI TAG(init_c_transformations)( void )
+{
+#define TAG_TAB _mesa_transform_tab
+#define TAG_TAB_1 TAG(transform_tab_1)
+#define TAG_TAB_2 TAG(transform_tab_2)
+#define TAG_TAB_3 TAG(transform_tab_3)
+#define TAG_TAB_4 TAG(transform_tab_4)
+
+ TAG_TAB[1] = TAG_TAB_1;
+ TAG_TAB[2] = TAG_TAB_2;
+ TAG_TAB[3] = TAG_TAB_3;
+ TAG_TAB[4] = TAG_TAB_4;
+
+ /* 1-D points (ie texcoords) */
+ TAG_TAB_1[MATRIX_GENERAL] = TAG(transform_points1_general);
+ TAG_TAB_1[MATRIX_IDENTITY] = TAG(transform_points1_identity);
+ TAG_TAB_1[MATRIX_3D_NO_ROT] = TAG(transform_points1_3d_no_rot);
+ TAG_TAB_1[MATRIX_PERSPECTIVE] = TAG(transform_points1_perspective);
+ TAG_TAB_1[MATRIX_2D] = TAG(transform_points1_2d);
+ TAG_TAB_1[MATRIX_2D_NO_ROT] = TAG(transform_points1_2d_no_rot);
+ TAG_TAB_1[MATRIX_3D] = TAG(transform_points1_3d);
+
+ /* 2-D points */
+ TAG_TAB_2[MATRIX_GENERAL] = TAG(transform_points2_general);
+ TAG_TAB_2[MATRIX_IDENTITY] = TAG(transform_points2_identity);
+ TAG_TAB_2[MATRIX_3D_NO_ROT] = TAG(transform_points2_3d_no_rot);
+ TAG_TAB_2[MATRIX_PERSPECTIVE] = TAG(transform_points2_perspective);
+ TAG_TAB_2[MATRIX_2D] = TAG(transform_points2_2d);
+ TAG_TAB_2[MATRIX_2D_NO_ROT] = TAG(transform_points2_2d_no_rot);
+ TAG_TAB_2[MATRIX_3D] = TAG(transform_points2_3d);
+
+ /* 3-D points */
+ TAG_TAB_3[MATRIX_GENERAL] = TAG(transform_points3_general);
+ TAG_TAB_3[MATRIX_IDENTITY] = TAG(transform_points3_identity);
+ TAG_TAB_3[MATRIX_3D_NO_ROT] = TAG(transform_points3_3d_no_rot);
+ TAG_TAB_3[MATRIX_PERSPECTIVE] = TAG(transform_points3_perspective);
+ TAG_TAB_3[MATRIX_2D] = TAG(transform_points3_2d);
+ TAG_TAB_3[MATRIX_2D_NO_ROT] = TAG(transform_points3_2d_no_rot);
+ TAG_TAB_3[MATRIX_3D] = TAG(transform_points3_3d);
+
+ /* 4-D points */
+ TAG_TAB_4[MATRIX_GENERAL] = TAG(transform_points4_general);
+ TAG_TAB_4[MATRIX_IDENTITY] = TAG(transform_points4_identity);
+ TAG_TAB_4[MATRIX_3D_NO_ROT] = TAG(transform_points4_3d_no_rot);
+ TAG_TAB_4[MATRIX_PERSPECTIVE] = TAG(transform_points4_perspective);
+ TAG_TAB_4[MATRIX_2D] = TAG(transform_points4_2d);
+ TAG_TAB_4[MATRIX_2D_NO_ROT] = TAG(transform_points4_2d_no_rot);
+ TAG_TAB_4[MATRIX_3D] = TAG(transform_points4_3d);
+
+#undef TAG_TAB
+#undef TAG_TAB_1
+#undef TAG_TAB_2
+#undef TAG_TAB_3
+#undef TAG_TAB_4
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/math/mathmod.h b/nx-X11/extras/Mesa/src/mesa/math/mathmod.h
new file mode 100644
index 000000000..6fbaaea94
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/math/mathmod.h
@@ -0,0 +1,41 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+
+/**
+ * \mainpage Mesa Math Module
+ *
+ * This module contains math-related utility functions for transforming
+ * vertices, translating arrays of numbers from one data type to another,
+ * evaluating curved surfaces, etc.
+ */
+
+
+#ifndef _MESA_MATH_H_
+#define _MESA_MATH_H_
+
+extern void _math_init( void );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/ppc/common_ppc.c b/nx-X11/extras/Mesa/src/mesa/ppc/common_ppc.c
new file mode 100644
index 000000000..13526df78
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/ppc/common_ppc.c
@@ -0,0 +1,88 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file common_ppc.c
+ * Check CPU capabilities & initialize optimized funtions for this particular
+ * processor.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+
+#ifdef USE_PPC_ASM
+#include <elf.h>
+#endif
+
+unsigned long _mesa_ppc_cpu_features = 0;
+
+/**
+ * Detect CPU features and install optimized transform and lighting routines.
+ * Currently, CPU features are only detected. The optimized routines have
+ * yet to be written.
+ *
+ * \bug
+ * This routine is highly specific to Linux kernel 2.6. I'm still waiting
+ * to hear back from the glibc folk on how to do this "right".
+ */
+
+void _mesa_init_all_ppc_transform_asm( void )
+{
+#ifdef USE_PPC_ASM
+ const pid_t my_pid = getpid();
+ char file_name[32];
+ FILE * f;
+#ifdef __powerpc64__
+ Elf64_auxv_t v;
+#else
+ Elf32_auxv_t v;
+#endif
+
+ sprintf( file_name, "/proc/%u/auxv", (unsigned) my_pid );
+ f = fopen( file_name, "rb" );
+ if ( f != NULL ) {
+ while( 1 ) {
+ ssize_t elem = fread( & v, sizeof( v ), 1, f );
+
+ if ( elem < 1 ) {
+ break;
+ }
+
+ if ( v.a_type == AT_HWCAP ) {
+ _mesa_ppc_cpu_features = v.a_un.a_val;
+ break;
+ }
+ }
+
+ fclose( f );
+ }
+
+# ifndef USE_VMX_ASM
+ _mesa_ppc_cpu_features &= ~PPC_FEATURES_HAS_ALTIVEC;
+# endif
+#endif
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/ppc/common_ppc_features.h b/nx-X11/extras/Mesa/src/mesa/ppc/common_ppc_features.h
new file mode 100644
index 000000000..4d46ca04c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/ppc/common_ppc_features.h
@@ -0,0 +1,51 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file common_ppc_features.h
+ * Interface for determining which CPU features were detected.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#ifndef COMMON_PPC_FEATURES_H
+#define COMMON_PPC_FEATURES_H
+
+#ifdef USE_PPC_ASM
+#include <asm/cputable.h>
+
+extern unsigned long _mesa_ppc_cpu_features;
+
+
+/* The PPC_FEATURE_* values come from asm/cputable.h. Should we define
+ * versions of them here if that file does not exist? This will only
+ * matter once these code paths are supported on non-Linux platforms.
+ */
+
+#define cpu_has_64 ((_mesa_ppc_cpu_features & PPC_FEATURE_64) != 0)
+#define cpu_has_vmx ((_mesa_ppc_cpu_features & PPC_FEATURE_HAS_ALTIVEC) != 0)
+#define cpu_has_fpu ((_mesa_ppc_cpu_features & PPC_FEATURE_HAS_FPU) != 0)
+
+#endif /* USE_PPC_ASM */
+#endif /* COMMON_PPC_FEATURES_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/arbfragparse.c b/nx-X11/extras/Mesa/src/mesa/shader/arbfragparse.c
new file mode 100644
index 000000000..237c348ba
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/arbfragparse.c
@@ -0,0 +1,229 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.2
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+#define DEBUG_FP 0
+
+/**
+ * \file arbfragparse.c
+ * ARB_fragment_program parser.
+ * \author Karl Rasche
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "imports.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "program.h"
+#include "arbprogparse.h"
+#include "arbfragparse.h"
+
+void
+_mesa_debug_fp_inst(GLint num, struct fp_instruction *fp)
+{
+ GLint a;
+
+ static const char *opcode_string[] = {
+ "ABS", /* ARB_f_p only */
+ "ADD",
+ "CMP", /* ARB_f_p only */
+ "COS",
+ "DDX", /* NV_f_p only */
+ "DDY", /* NV_f_p only */
+ "DP3",
+ "DP4",
+ "DPH", /* ARB_f_p only */
+ "DST",
+ "END", /* private opcode */
+ "EX2",
+ "FLR",
+ "FRC",
+ "KIL", /* ARB_f_p only */
+ "KIL_NV", /* NV_f_p only */
+ "LG2",
+ "LIT",
+ "LRP",
+ "MAD",
+ "MAX",
+ "MIN",
+ "MOV",
+ "MUL",
+ "PK2H", /* NV_f_p only */
+ "PK2US", /* NV_f_p only */
+ "PK4B", /* NV_f_p only */
+ "PK4UB", /* NV_f_p only */
+ "POW",
+ "PRINT", /* Mesa only */
+ "RCP",
+ "RFL", /* NV_f_p only */
+ "RSQ",
+ "SCS", /* ARB_f_p only */
+ "SEQ", /* NV_f_p only */
+ "SFL", /* NV_f_p only */
+ "SGE", /* NV_f_p only */
+ "SGT", /* NV_f_p only */
+ "SIN",
+ "SLE", /* NV_f_p only */
+ "SLT",
+ "SNE", /* NV_f_p only */
+ "STR", /* NV_f_p only */
+ "SUB",
+ "SWZ", /* ARB_f_p only */
+ "TEX",
+ "TXB", /* ARB_f_p only */
+ "TXD", /* NV_f_p only */
+ "TXP", /* ARB_f_p only */
+ "TXP_NV", /* NV_f_p only */
+ "UP2H", /* NV_f_p only */
+ "UP2US", /* NV_f_p only */
+ "UP4B", /* NV_f_p only */
+ "UP4UB", /* NV_f_p only */
+ "X2D", /* NV_f_p only - 2d mat mul */
+ "XPD", /* ARB_f_p only - cross product */
+ };
+
+ static const char *file_string[] = {
+ "TEMP",
+ "INPUT",
+ "OUTPUT",
+ "LOCAL",
+ "ENV",
+ "NAMED",
+ "STATE",
+ "WRITE_ONLY",
+ "ADDR"
+ };
+
+ static const char swz[] = "xyzw01??";
+
+ for (a=0; a<num; a++) {
+ _mesa_printf("%s", opcode_string[fp[a].Opcode]);
+
+ if (fp[a].Saturate)
+ _mesa_printf("_SAT");
+
+ if (fp[a].DstReg.File != 0xf) {
+ if (fp[a].DstReg.WriteMask != 0xf ||
+ fp[a].SrcReg[0].NegateBase)
+ _mesa_printf(" %s[%d].%s%s%s%s ", file_string[fp[a].DstReg.File], fp[a].DstReg.Index,
+ GET_BIT(fp[a].DstReg.WriteMask, 0) ? "x" : "",
+ GET_BIT(fp[a].DstReg.WriteMask, 1) ? "y" : "",
+ GET_BIT(fp[a].DstReg.WriteMask, 2) ? "z" : "",
+ GET_BIT(fp[a].DstReg.WriteMask, 3) ? "w" : "");
+ else
+ _mesa_printf(" %s[%d] ", file_string[fp[a].DstReg.File], fp[a].DstReg.Index);
+ }
+
+ if (fp[a].SrcReg[0].File != 0xf) {
+ if (fp[a].SrcReg[0].Swizzle != SWIZZLE_NOOP ||
+ fp[a].SrcReg[0].NegateBase)
+ _mesa_printf("%s[%d].%s%c%c%c%c ", file_string[fp[a].SrcReg[0].File], fp[a].SrcReg[0].Index,
+ fp[a].SrcReg[0].NegateBase ? "-" : "",
+ swz[GET_SWZ(fp[a].SrcReg[0].Swizzle, 0)],
+ swz[GET_SWZ(fp[a].SrcReg[0].Swizzle, 1)],
+ swz[GET_SWZ(fp[a].SrcReg[0].Swizzle, 2)],
+ swz[GET_SWZ(fp[a].SrcReg[0].Swizzle, 3)]);
+ else
+ _mesa_printf("%s[%d] ", file_string[fp[a].SrcReg[0].File], fp[a].SrcReg[0].Index);
+ }
+
+ if (fp[a].SrcReg[1].File != 0xf) {
+ if (fp[a].SrcReg[1].Swizzle != SWIZZLE_NOOP ||
+ fp[a].SrcReg[1].NegateBase)
+ _mesa_printf("%s[%d].%s%c%c%c%c ", file_string[fp[a].SrcReg[1].File], fp[a].SrcReg[1].Index,
+ fp[a].SrcReg[1].NegateBase ? "-" : "",
+ swz[GET_SWZ(fp[a].SrcReg[1].Swizzle, 0)],
+ swz[GET_SWZ(fp[a].SrcReg[1].Swizzle, 1)],
+ swz[GET_SWZ(fp[a].SrcReg[1].Swizzle, 2)],
+ swz[GET_SWZ(fp[a].SrcReg[1].Swizzle, 3)]);
+ else
+ _mesa_printf("%s[%d] ", file_string[fp[a].SrcReg[1].File], fp[a].SrcReg[1].Index);
+ }
+
+ if (fp[a].SrcReg[2].File != 0xf) {
+ if (fp[a].SrcReg[2].Swizzle != SWIZZLE_NOOP ||
+ fp[a].SrcReg[2].NegateBase)
+ _mesa_printf("%s[%d].%s%c%c%c%c ", file_string[fp[a].SrcReg[2].File], fp[a].SrcReg[2].Index,
+ fp[a].SrcReg[1].NegateBase ? "-" : "",
+ swz[GET_SWZ(fp[a].SrcReg[2].Swizzle, 0)],
+ swz[GET_SWZ(fp[a].SrcReg[2].Swizzle, 1)],
+ swz[GET_SWZ(fp[a].SrcReg[2].Swizzle, 2)],
+ swz[GET_SWZ(fp[a].SrcReg[2].Swizzle, 3)]);
+ else
+ _mesa_printf("%s[%d] ", file_string[fp[a].SrcReg[2].File], fp[a].SrcReg[2].Index);
+ }
+
+ _mesa_printf("\n");
+ }
+}
+
+
+void
+_mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
+ const GLubyte * str, GLsizei len,
+ struct fragment_program *program)
+{
+ GLuint i;
+ struct arb_program ap;
+ (void) target;
+
+ /* set the program target before parsing */
+ ap.Base.Target = GL_FRAGMENT_PROGRAM_ARB;
+
+ if (!_mesa_parse_arb_program(ctx, str, len, &ap)) {
+ /* Error in the program. Just return. */
+ return;
+ }
+
+ /* Copy the relevant contents of the arb_program struct into the
+ * fragment_program struct.
+ */
+ program->Base.String = ap.Base.String;
+ program->Base.NumInstructions = ap.Base.NumInstructions;
+ program->Base.NumTemporaries = ap.Base.NumTemporaries;
+ program->Base.NumParameters = ap.Base.NumParameters;
+ program->Base.NumAttributes = ap.Base.NumAttributes;
+ program->Base.NumAddressRegs = ap.Base.NumAddressRegs;
+ program->NumAluInstructions = ap.NumAluInstructions;
+ program->NumTexInstructions = ap.NumTexInstructions;
+ program->NumTexIndirections = ap.NumTexIndirections;
+
+ program->InputsRead = ap.InputsRead;
+ program->OutputsWritten = ap.OutputsWritten;
+ for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
+ program->TexturesUsed[i] = ap.TexturesUsed[i];
+
+ if (program->Parameters) {
+ /* free previous program's parameters */
+ _mesa_free_parameter_list(program->Parameters);
+ }
+ program->Parameters = ap.Parameters;
+ program->FogOption = ap.FogOption;
+
+#if DEBUG_FP
+ _mesa_debug_fp_inst(ap.Base.NumInstructions, ap.FPInstructions);
+#endif
+
+ program->Instructions = ap.FPInstructions;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/arbfragparse.h b/nx-X11/extras/Mesa/src/mesa/shader/arbfragparse.h
new file mode 100644
index 000000000..0d3e69fa8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/arbfragparse.h
@@ -0,0 +1,39 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef ARBFRAGPARSE_H
+#define ARBFRAGPARSE_H
+
+#include "mtypes.h"
+
+extern void
+_mesa_parse_arb_fragment_program(GLcontext * ctx, GLenum target,
+ const GLubyte * str, GLsizei len,
+ struct fragment_program *program);
+
+extern void
+_mesa_debug_fp_inst(GLint num, struct fp_instruction *fp);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/arbprogparse.c b/nx-X11/extras/Mesa/src/mesa/shader/arbprogparse.c
new file mode 100644
index 000000000..57891b234
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/arbprogparse.c
@@ -0,0 +1,4134 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#define DEBUG_PARSING 0
+
+/**
+ * \file arbprogparse.c
+ * ARB_*_program parser core
+ * \author Karl Rasche
+ */
+
+#include "mtypes.h"
+#include "glheader.h"
+#include "context.h"
+#include "hash.h"
+#include "imports.h"
+#include "macros.h"
+#include "program.h"
+#include "nvvertprog.h"
+#include "nvfragprog.h"
+#include "arbprogparse.h"
+#include "grammar_mesa.h"
+
+#include "dispatch.h"
+
+#ifndef __extension__
+#if !defined(__GNUC__) || (__GNUC__ < 2) || \
+ ((__GNUC__ == 2) && (__GNUC_MINOR__ <= 7))
+# define __extension__
+#endif
+#endif
+
+/* TODO:
+ * Fragment Program Stuff:
+ * -----------------------------------------------------
+ *
+ * - things from Michal's email
+ * + overflow on atoi
+ * + not-overflowing floats (don't use parse_integer..)
+ * + can remove range checking in arbparse.c
+ *
+ * - check all limits of number of various variables
+ * + parameters
+ *
+ * - test! test! test!
+ *
+ * Vertex Program Stuff:
+ * -----------------------------------------------------
+ * - Optimize param array usage and count limits correctly, see spec,
+ * section 2.14.3.7
+ * + Record if an array is reference absolutly or relatively (or both)
+ * + For absolute arrays, store a bitmap of accesses
+ * + For single parameters, store an access flag
+ * + After parsing, make a parameter cleanup and merging pass, where
+ * relative arrays are layed out first, followed by abs arrays, and
+ * finally single state.
+ * + Remap offsets for param src and dst registers
+ * + Now we can properly count parameter usage
+ *
+ * - Multiple state binding errors in param arrays (see spec, just before
+ * section 2.14.3.3)
+ * - grep for XXX
+ *
+ * Mesa Stuff
+ * -----------------------------------------------------
+ * - User clipping planes vs. PositionInvariant
+ * - Is it sufficient to just multiply by the mvp to transform in the
+ * PositionInvariant case? Or do we need something more involved?
+ *
+ * - vp_src swizzle is GLubyte, fp_src swizzle is GLuint
+ * - fetch state listed in program_parameters list
+ * + WTF should this go???
+ * + currently in nvvertexec.c and s_nvfragprog.c
+ *
+ * - allow for multiple address registers (and fetch address regs properly)
+ *
+ * Cosmetic Stuff
+ * -----------------------------------------------------
+ * - remove any leftover unused grammer.c stuff (dict_ ?)
+ * - fix grammer.c error handling so its not static
+ * - #ifdef around stuff pertaining to extentions
+ *
+ * Outstanding Questions:
+ * -----------------------------------------------------
+ * - ARB_matrix_palette / ARB_vertex_blend -- not supported
+ * what gets hacked off because of this:
+ * + VERTEX_ATTRIB_MATRIXINDEX
+ * + VERTEX_ATTRIB_WEIGHT
+ * + MATRIX_MODELVIEW
+ * + MATRIX_PALETTE
+ *
+ * - When can we fetch env/local params from their own register files, and
+ * when to we have to fetch them into the main state register file?
+ * (think arrays)
+ *
+ * Grammar Changes:
+ * -----------------------------------------------------
+ */
+
+/* Changes since moving the file to shader directory
+
+2004-III-4 ------------------------------------------------------------
+- added #include "grammar_mesa.h"
+- removed grammar specific code part (it resides now in grammar.c)
+- added GL_ARB_fragment_program_shadow tokens
+- modified #include "arbparse_syn.h"
+- major changes inside _mesa_parse_arb_program()
+- check the program string for '\0' characters
+- copy the program string to a one-byte-longer location to have
+ it null-terminated
+- position invariance test (not writing to result.position) moved
+ to syntax part
+*/
+
+typedef GLubyte *production;
+
+/**
+ * This is the text describing the rules to parse the grammar
+ */
+__extension__ static char arb_grammar_text[] =
+#include "arbprogram_syn.h"
+;
+
+/**
+ * These should match up with the values defined in arbprogram.syn
+ */
+
+/*
+ Changes:
+ - changed and merged V_* and F_* opcode values to OP_*.
+ - added GL_ARB_fragment_program_shadow specific tokens (michal)
+*/
+#define REVISION 0x09
+
+/* program type */
+#define FRAGMENT_PROGRAM 0x01
+#define VERTEX_PROGRAM 0x02
+
+/* program section */
+#define OPTION 0x01
+#define INSTRUCTION 0x02
+#define DECLARATION 0x03
+#define END 0x04
+
+/* GL_ARB_fragment_program option */
+#define ARB_PRECISION_HINT_FASTEST 0x00
+#define ARB_PRECISION_HINT_NICEST 0x01
+#define ARB_FOG_EXP 0x02
+#define ARB_FOG_EXP2 0x03
+#define ARB_FOG_LINEAR 0x04
+
+/* GL_ARB_vertex_program option */
+#define ARB_POSITION_INVARIANT 0x05
+
+/* GL_ARB_fragment_program_shadow option */
+#define ARB_FRAGMENT_PROGRAM_SHADOW 0x06
+
+/* GL_ARB_draw_buffers option */
+#define ARB_DRAW_BUFFERS 0x07
+
+/* GL_ARB_fragment_program instruction class */
+#define OP_ALU_INST 0x00
+#define OP_TEX_INST 0x01
+
+/* GL_ARB_vertex_program instruction class */
+/* OP_ALU_INST */
+
+/* GL_ARB_fragment_program instruction type */
+#define OP_ALU_VECTOR 0x00
+#define OP_ALU_SCALAR 0x01
+#define OP_ALU_BINSC 0x02
+#define OP_ALU_BIN 0x03
+#define OP_ALU_TRI 0x04
+#define OP_ALU_SWZ 0x05
+#define OP_TEX_SAMPLE 0x06
+#define OP_TEX_KIL 0x07
+
+/* GL_ARB_vertex_program instruction type */
+#define OP_ALU_ARL 0x08
+/* OP_ALU_VECTOR */
+/* OP_ALU_SCALAR */
+/* OP_ALU_BINSC */
+/* OP_ALU_BIN */
+/* OP_ALU_TRI */
+/* OP_ALU_SWZ */
+
+/* GL_ARB_fragment_program instruction code */
+#define OP_ABS 0x00
+#define OP_ABS_SAT 0x1B
+#define OP_FLR 0x09
+#define OP_FLR_SAT 0x26
+#define OP_FRC 0x0A
+#define OP_FRC_SAT 0x27
+#define OP_LIT 0x0C
+#define OP_LIT_SAT 0x2A
+#define OP_MOV 0x11
+#define OP_MOV_SAT 0x30
+#define OP_COS 0x1F
+#define OP_COS_SAT 0x20
+#define OP_EX2 0x07
+#define OP_EX2_SAT 0x25
+#define OP_LG2 0x0B
+#define OP_LG2_SAT 0x29
+#define OP_RCP 0x14
+#define OP_RCP_SAT 0x33
+#define OP_RSQ 0x15
+#define OP_RSQ_SAT 0x34
+#define OP_SIN 0x38
+#define OP_SIN_SAT 0x39
+#define OP_SCS 0x35
+#define OP_SCS_SAT 0x36
+#define OP_POW 0x13
+#define OP_POW_SAT 0x32
+#define OP_ADD 0x01
+#define OP_ADD_SAT 0x1C
+#define OP_DP3 0x03
+#define OP_DP3_SAT 0x21
+#define OP_DP4 0x04
+#define OP_DP4_SAT 0x22
+#define OP_DPH 0x05
+#define OP_DPH_SAT 0x23
+#define OP_DST 0x06
+#define OP_DST_SAT 0x24
+#define OP_MAX 0x0F
+#define OP_MAX_SAT 0x2E
+#define OP_MIN 0x10
+#define OP_MIN_SAT 0x2F
+#define OP_MUL 0x12
+#define OP_MUL_SAT 0x31
+#define OP_SGE 0x16
+#define OP_SGE_SAT 0x37
+#define OP_SLT 0x17
+#define OP_SLT_SAT 0x3A
+#define OP_SUB 0x18
+#define OP_SUB_SAT 0x3B
+#define OP_XPD 0x1A
+#define OP_XPD_SAT 0x43
+#define OP_CMP 0x1D
+#define OP_CMP_SAT 0x1E
+#define OP_LRP 0x2B
+#define OP_LRP_SAT 0x2C
+#define OP_MAD 0x0E
+#define OP_MAD_SAT 0x2D
+#define OP_SWZ 0x19
+#define OP_SWZ_SAT 0x3C
+#define OP_TEX 0x3D
+#define OP_TEX_SAT 0x3E
+#define OP_TXB 0x3F
+#define OP_TXB_SAT 0x40
+#define OP_TXP 0x41
+#define OP_TXP_SAT 0x42
+#define OP_KIL 0x28
+
+/* GL_ARB_vertex_program instruction code */
+#define OP_ARL 0x02
+/* OP_ABS */
+/* OP_FLR */
+/* OP_FRC */
+/* OP_LIT */
+/* OP_MOV */
+/* OP_EX2 */
+#define OP_EXP 0x08
+/* OP_LG2 */
+#define OP_LOG 0x0D
+/* OP_RCP */
+/* OP_RSQ */
+/* OP_POW */
+/* OP_ADD */
+/* OP_DP3 */
+/* OP_DP4 */
+/* OP_DPH */
+/* OP_DST */
+/* OP_MAX */
+/* OP_MIN */
+/* OP_MUL */
+/* OP_SGE */
+/* OP_SLT */
+/* OP_SUB */
+/* OP_XPD */
+/* OP_MAD */
+/* OP_SWZ */
+
+/* fragment attribute binding */
+#define FRAGMENT_ATTRIB_COLOR 0x01
+#define FRAGMENT_ATTRIB_TEXCOORD 0x02
+#define FRAGMENT_ATTRIB_FOGCOORD 0x03
+#define FRAGMENT_ATTRIB_POSITION 0x04
+
+/* vertex attribute binding */
+#define VERTEX_ATTRIB_POSITION 0x01
+#define VERTEX_ATTRIB_WEIGHT 0x02
+#define VERTEX_ATTRIB_NORMAL 0x03
+#define VERTEX_ATTRIB_COLOR 0x04
+#define VERTEX_ATTRIB_FOGCOORD 0x05
+#define VERTEX_ATTRIB_TEXCOORD 0x06
+#define VERTEX_ATTRIB_MATRIXINDEX 0x07
+#define VERTEX_ATTRIB_GENERIC 0x08
+
+/* fragment result binding */
+#define FRAGMENT_RESULT_COLOR 0x01
+#define FRAGMENT_RESULT_DEPTH 0x02
+
+/* vertex result binding */
+#define VERTEX_RESULT_POSITION 0x01
+#define VERTEX_RESULT_COLOR 0x02
+#define VERTEX_RESULT_FOGCOORD 0x03
+#define VERTEX_RESULT_POINTSIZE 0x04
+#define VERTEX_RESULT_TEXCOORD 0x05
+
+/* texture target */
+#define TEXTARGET_1D 0x01
+#define TEXTARGET_2D 0x02
+#define TEXTARGET_3D 0x03
+#define TEXTARGET_RECT 0x04
+#define TEXTARGET_CUBE 0x05
+/* GL_ARB_fragment_program_shadow */
+#define TEXTARGET_SHADOW1D 0x06
+#define TEXTARGET_SHADOW2D 0x07
+#define TEXTARGET_SHADOWRECT 0x08
+
+/* face type */
+#define FACE_FRONT 0x00
+#define FACE_BACK 0x01
+
+/* color type */
+#define COLOR_PRIMARY 0x00
+#define COLOR_SECONDARY 0x01
+
+/* component */
+#define COMPONENT_X 0x00
+#define COMPONENT_Y 0x01
+#define COMPONENT_Z 0x02
+#define COMPONENT_W 0x03
+#define COMPONENT_0 0x04
+#define COMPONENT_1 0x05
+
+/* array index type */
+#define ARRAY_INDEX_ABSOLUTE 0x00
+#define ARRAY_INDEX_RELATIVE 0x01
+
+/* matrix name */
+#define MATRIX_MODELVIEW 0x01
+#define MATRIX_PROJECTION 0x02
+#define MATRIX_MVP 0x03
+#define MATRIX_TEXTURE 0x04
+#define MATRIX_PALETTE 0x05
+#define MATRIX_PROGRAM 0x06
+
+/* matrix modifier */
+#define MATRIX_MODIFIER_IDENTITY 0x00
+#define MATRIX_MODIFIER_INVERSE 0x01
+#define MATRIX_MODIFIER_TRANSPOSE 0x02
+#define MATRIX_MODIFIER_INVTRANS 0x03
+
+/* constant type */
+#define CONSTANT_SCALAR 0x01
+#define CONSTANT_VECTOR 0x02
+
+/* program param type */
+#define PROGRAM_PARAM_ENV 0x01
+#define PROGRAM_PARAM_LOCAL 0x02
+
+/* register type */
+#define REGISTER_ATTRIB 0x01
+#define REGISTER_PARAM 0x02
+#define REGISTER_RESULT 0x03
+#define REGISTER_ESTABLISHED_NAME 0x04
+
+/* param binding */
+#define PARAM_NULL 0x00
+#define PARAM_ARRAY_ELEMENT 0x01
+#define PARAM_STATE_ELEMENT 0x02
+#define PARAM_PROGRAM_ELEMENT 0x03
+#define PARAM_PROGRAM_ELEMENTS 0x04
+#define PARAM_CONSTANT 0x05
+
+/* param state property */
+#define STATE_MATERIAL_PARSER 0x01
+#define STATE_LIGHT_PARSER 0x02
+#define STATE_LIGHT_MODEL 0x03
+#define STATE_LIGHT_PROD 0x04
+#define STATE_FOG 0x05
+#define STATE_MATRIX_ROWS 0x06
+/* GL_ARB_fragment_program */
+#define STATE_TEX_ENV 0x07
+#define STATE_DEPTH 0x08
+/* GL_ARB_vertex_program */
+#define STATE_TEX_GEN 0x09
+#define STATE_CLIP_PLANE 0x0A
+#define STATE_POINT 0x0B
+
+/* state material property */
+#define MATERIAL_AMBIENT 0x01
+#define MATERIAL_DIFFUSE 0x02
+#define MATERIAL_SPECULAR 0x03
+#define MATERIAL_EMISSION 0x04
+#define MATERIAL_SHININESS 0x05
+
+/* state light property */
+#define LIGHT_AMBIENT 0x01
+#define LIGHT_DIFFUSE 0x02
+#define LIGHT_SPECULAR 0x03
+#define LIGHT_POSITION 0x04
+#define LIGHT_ATTENUATION 0x05
+#define LIGHT_HALF 0x06
+#define LIGHT_SPOT_DIRECTION 0x07
+
+/* state light model property */
+#define LIGHT_MODEL_AMBIENT 0x01
+#define LIGHT_MODEL_SCENECOLOR 0x02
+
+/* state light product property */
+#define LIGHT_PROD_AMBIENT 0x01
+#define LIGHT_PROD_DIFFUSE 0x02
+#define LIGHT_PROD_SPECULAR 0x03
+
+/* state texture environment property */
+#define TEX_ENV_COLOR 0x01
+
+/* state texture generation coord property */
+#define TEX_GEN_EYE 0x01
+#define TEX_GEN_OBJECT 0x02
+
+/* state fog property */
+#define FOG_COLOR 0x01
+#define FOG_PARAMS 0x02
+
+/* state depth property */
+#define DEPTH_RANGE 0x01
+
+/* state point parameters property */
+#define POINT_SIZE 0x01
+#define POINT_ATTENUATION 0x02
+
+/* declaration */
+#define ATTRIB 0x01
+#define PARAM 0x02
+#define TEMP 0x03
+#define OUTPUT 0x04
+#define ALIAS 0x05
+/* GL_ARB_vertex_program */
+#define ADDRESS 0x06
+
+/*-----------------------------------------------------------------------
+ * From here on down is the semantic checking portion
+ *
+ */
+
+/**
+ * Variable Table Handling functions
+ */
+typedef enum
+{
+ vt_none,
+ vt_address,
+ vt_attrib,
+ vt_param,
+ vt_temp,
+ vt_output,
+ vt_alias
+} var_type;
+
+
+/*
+ * Setting an explicit field for each of the binding properties is a bit wasteful
+ * of space, but it should be much more clear when reading later on..
+ */
+struct var_cache
+{
+ GLubyte *name;
+ var_type type;
+ GLuint address_binding; /* The index of the address register we should
+ * be using */
+ GLuint attrib_binding; /* For type vt_attrib, see nvfragprog.h for values */
+ GLuint attrib_binding_idx; /* The index into the attrib register file corresponding
+ * to the state in attrib_binding */
+ GLuint attrib_is_generic; /* If the attrib was specified through a generic
+ * vertex attrib */
+ GLuint temp_binding; /* The index of the temp register we are to use */
+ GLuint output_binding; /* For type vt_output, see nvfragprog.h for values */
+ GLuint output_binding_idx; /* This is the index into the result register file
+ * corresponding to the bound result state */
+ struct var_cache *alias_binding; /* For type vt_alias, points to the var_cache entry
+ * that this is aliased to */
+ GLuint param_binding_type; /* {PROGRAM_STATE_VAR, PROGRAM_LOCAL_PARAM,
+ * PROGRAM_ENV_PARAM} */
+ GLuint param_binding_begin; /* This is the offset into the program_parameter_list where
+ * the tokens representing our bound state (or constants)
+ * start */
+ GLuint param_binding_length; /* This is how many entries in the the program_parameter_list
+ * we take up with our state tokens or constants. Note that
+ * this is _not_ the same as the number of param registers
+ * we eventually use */
+ struct var_cache *next;
+};
+
+static GLvoid
+var_cache_create (struct var_cache **va)
+{
+ *va = (struct var_cache *) _mesa_malloc (sizeof (struct var_cache));
+ if (*va) {
+ (**va).name = NULL;
+ (**va).type = vt_none;
+ (**va).attrib_binding = ~0;
+ (**va).attrib_is_generic = 0;
+ (**va).temp_binding = ~0;
+ (**va).output_binding = ~0;
+ (**va).output_binding_idx = ~0;
+ (**va).param_binding_type = ~0;
+ (**va).param_binding_begin = ~0;
+ (**va).param_binding_length = ~0;
+ (**va).alias_binding = NULL;
+ (**va).next = NULL;
+ }
+}
+
+static GLvoid
+var_cache_destroy (struct var_cache **va)
+{
+ if (*va) {
+ var_cache_destroy (&(**va).next);
+ _mesa_free (*va);
+ *va = NULL;
+ }
+}
+
+static GLvoid
+var_cache_append (struct var_cache **va, struct var_cache *nv)
+{
+ if (*va)
+ var_cache_append (&(**va).next, nv);
+ else
+ *va = nv;
+}
+
+static struct var_cache *
+var_cache_find (struct var_cache *va, GLubyte * name)
+{
+ /*struct var_cache *first = va;*/
+
+ while (va) {
+ if (!strcmp ( (const char*) name, (const char*) va->name)) {
+ if (va->type == vt_alias)
+ return va->alias_binding;
+ return va;
+ }
+
+ va = va->next;
+ }
+
+ return NULL;
+}
+
+/**
+ * constructs an integer from 4 GLubytes in LE format
+ */
+static GLuint
+parse_position (GLubyte ** inst)
+{
+ GLuint value;
+
+ value = (GLuint) (*(*inst)++);
+ value += (GLuint) (*(*inst)++) * 0x100;
+ value += (GLuint) (*(*inst)++) * 0x10000;
+ value += (GLuint) (*(*inst)++) * 0x1000000;
+
+ return value;
+}
+
+/**
+ * This will, given a string, lookup the string as a variable name in the
+ * var cache. If the name is found, the var cache node corresponding to the
+ * var name is returned. If it is not found, a new entry is allocated
+ *
+ * \param I Points into the binary array where the string identifier begins
+ * \param found 1 if the string was found in the var_cache, 0 if it was allocated
+ * \return The location on the var_cache corresponding the the string starting at I
+ */
+static struct var_cache *
+parse_string (GLubyte ** inst, struct var_cache **vc_head,
+ struct arb_program *Program, GLuint * found)
+{
+ GLubyte *i = *inst;
+ struct var_cache *va = NULL;
+ (void) Program;
+
+ *inst += _mesa_strlen ((char *) i) + 1;
+
+ va = var_cache_find (*vc_head, i);
+
+ if (va) {
+ *found = 1;
+ return va;
+ }
+
+ *found = 0;
+ var_cache_create (&va);
+ va->name = i;
+
+ var_cache_append (vc_head, va);
+
+ return va;
+}
+
+static char *
+parse_string_without_adding (GLubyte ** inst, struct arb_program *Program)
+{
+ GLubyte *i = *inst;
+ (void) Program;
+
+ *inst += _mesa_strlen ((char *) i) + 1;
+
+ return (char *) i;
+}
+
+/**
+ * \return -1 if we parse '-', return 1 otherwise
+ */
+static GLint
+parse_sign (GLubyte ** inst)
+{
+ /*return *(*inst)++ != '+'; */
+
+ if (**inst == '-') {
+ (*inst)++;
+ return -1;
+ }
+ else if (**inst == '+') {
+ (*inst)++;
+ return 1;
+ }
+
+ return 1;
+}
+
+/**
+ * parses and returns signed integer
+ */
+static GLint
+parse_integer (GLubyte ** inst, struct arb_program *Program)
+{
+ GLint sign;
+ GLint value;
+
+ /* check if *inst points to '+' or '-'
+ * if yes, grab the sign and increment *inst
+ */
+ sign = parse_sign (inst);
+
+ /* now check if *inst points to 0
+ * if yes, increment the *inst and return the default value
+ */
+ if (**inst == 0) {
+ (*inst)++;
+ return 0;
+ }
+
+ /* parse the integer as you normally would do it */
+ value = _mesa_atoi (parse_string_without_adding (inst, Program));
+
+ /* now, after terminating 0 there is a position
+ * to parse it - parse_position()
+ */
+ Program->Position = parse_position (inst);
+
+ return value * sign;
+}
+
+/**
+ Accumulate this string of digits, and return them as
+ a large integer represented in floating point (for range).
+ If scale is not NULL, also accumulates a power-of-ten
+ integer scale factor that represents the number of digits
+ in the string.
+*/
+static GLdouble
+parse_float_string(GLubyte ** inst, struct arb_program *Program, GLdouble *scale)
+{
+ GLdouble value = 0.0;
+ GLdouble oscale = 1.0;
+
+ if (**inst == 0) { /* this string of digits is empty-- do nothing */
+ (*inst)++;
+ }
+ else { /* nonempty string-- parse out the digits */
+ while (**inst >= '0' && **inst <= '9') {
+ GLubyte digit = *((*inst)++);
+ value = value * 10.0 + (GLint) (digit - '0');
+ oscale *= 10.0;
+ }
+ assert(**inst == 0); /* integer string should end with 0 */
+ (*inst)++; /* skip over terminating 0 */
+ Program->Position = parse_position(inst); /* skip position (from integer) */
+ }
+ if (scale)
+ *scale = oscale;
+ return value;
+}
+
+/**
+ Parse an unsigned floating-point number from this stream of tokenized
+ characters. Example floating-point formats supported:
+ 12.34
+ 12
+ 0.34
+ .34
+ 12.34e-4
+ */
+static GLfloat
+parse_float (GLubyte ** inst, struct arb_program *Program)
+{
+ GLint exponent;
+ GLdouble whole, fraction, fracScale = 1.0;
+
+ whole = parse_float_string(inst, Program, 0);
+ fraction = parse_float_string(inst, Program, &fracScale);
+
+ /* Parse signed exponent */
+ exponent = parse_integer(inst, Program); /* This is the exponent */
+
+ /* Assemble parts of floating-point number: */
+ return (GLfloat) ((whole + fraction / fracScale) *
+ _mesa_pow(10.0, (GLfloat) exponent));
+}
+
+
+/**
+ */
+static GLfloat
+parse_signed_float (GLubyte ** inst, struct arb_program *Program)
+{
+ GLint sign = parse_sign (inst);
+ GLfloat value = parse_float (inst, Program);
+ return value * sign;
+}
+
+/**
+ * This picks out a constant value from the parsed array. The constant vector is r
+ * returned in the *values array, which should be of length 4.
+ *
+ * \param values - The 4 component vector with the constant value in it
+ */
+static GLvoid
+parse_constant (GLubyte ** inst, GLfloat *values, struct arb_program *Program,
+ GLboolean use)
+{
+ GLuint components, i;
+
+
+ switch (*(*inst)++) {
+ case CONSTANT_SCALAR:
+ if (use == GL_TRUE) {
+ values[0] =
+ values[1] =
+ values[2] = values[3] = parse_float (inst, Program);
+ }
+ else {
+ values[0] =
+ values[1] =
+ values[2] = values[3] = parse_signed_float (inst, Program);
+ }
+
+ break;
+ case CONSTANT_VECTOR:
+ values[0] = values[1] = values[2] = 0;
+ values[3] = 1;
+ components = *(*inst)++;
+ for (i = 0; i < components; i++) {
+ values[i] = parse_signed_float (inst, Program);
+ }
+ break;
+ }
+}
+
+/**
+ * \param offset The offset from the address register that we should
+ * address
+ *
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_relative_offset (GLcontext *ctx, GLubyte **inst, struct arb_program *Program,
+ GLint *offset)
+{
+ *offset = parse_integer(inst, Program);
+ return 0;
+}
+
+/**
+ * \param color 0 if color type is primary, 1 if color type is secondary
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_color_type (GLcontext * ctx, GLubyte ** inst, struct arb_program *Program,
+ GLint * color)
+{
+ (void) ctx; (void) Program;
+ *color = *(*inst)++ != COLOR_PRIMARY;
+ return 0;
+}
+
+/**
+ * Get an integer corresponding to a generic vertex attribute.
+ *
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_generic_attrib_num(GLcontext *ctx, GLubyte ** inst,
+ struct arb_program *Program, GLuint *attrib)
+{
+ GLint i = parse_integer(inst, Program);
+
+ if ((i < 0) || (i > MAX_VERTEX_PROGRAM_ATTRIBS))
+ {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Invalid generic vertex attribute index");
+ _mesa_error (ctx, GL_INVALID_OPERATION, "Invalid generic vertex attribute index");
+
+ return 1;
+ }
+
+ *attrib = (GLuint) i;
+
+ return 0;
+}
+
+
+/**
+ * \param color The index of the color buffer to write into
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_output_color_num (GLcontext * ctx, GLubyte ** inst,
+ struct arb_program *Program, GLuint * color)
+{
+ GLint i = parse_integer (inst, Program);
+
+ if ((i < 0) || (i >= (int)ctx->Const.MaxDrawBuffers)) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Invalid draw buffer index");
+ _mesa_error (ctx, GL_INVALID_OPERATION, "Invalid draw buffer index");
+ return 1;
+ }
+
+ *color = (GLuint) i;
+ return 0;
+}
+
+
+/**
+ * \param coord The texture unit index
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_texcoord_num (GLcontext * ctx, GLubyte ** inst,
+ struct arb_program *Program, GLuint * coord)
+{
+ GLint i = parse_integer (inst, Program);
+
+ if ((i < 0) || (i >= (int)ctx->Const.MaxTextureUnits)) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Invalid texture unit index");
+ _mesa_error (ctx, GL_INVALID_OPERATION, "Invalid texture unit index");
+ return 1;
+ }
+
+ *coord = (GLuint) i;
+ return 0;
+}
+
+/**
+ * \param coord The weight index
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_weight_num (GLcontext * ctx, GLubyte ** inst, struct arb_program *Program,
+ GLint * coord)
+{
+ *coord = parse_integer (inst, Program);
+
+ if ((*coord < 0) || (*coord >= 1)) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Invalid weight index");
+ _mesa_error (ctx, GL_INVALID_OPERATION, "Invalid weight index");
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * \param coord The clip plane index
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_clipplane_num (GLcontext * ctx, GLubyte ** inst,
+ struct arb_program *Program, GLint * coord)
+{
+ *coord = parse_integer (inst, Program);
+
+ if ((*coord < 0) || (*coord >= (GLint) ctx->Const.MaxClipPlanes)) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Invalid clip plane index");
+ _mesa_error (ctx, GL_INVALID_OPERATION, "Invalid clip plane index");
+ return 1;
+ }
+
+ return 0;
+}
+
+
+/**
+ * \return 0 on front face, 1 on back face
+ */
+static GLuint
+parse_face_type (GLubyte ** inst)
+{
+ switch (*(*inst)++) {
+ case FACE_FRONT:
+ return 0;
+
+ case FACE_BACK:
+ return 1;
+ }
+ return 0;
+}
+
+
+/**
+ * Given a matrix and a modifier token on the binary array, return tokens
+ * that _mesa_fetch_state() [program.c] can understand.
+ *
+ * \param matrix - the matrix we are talking about
+ * \param matrix_idx - the index of the matrix we have (for texture & program matricies)
+ * \param matrix_modifier - the matrix modifier (trans, inv, etc)
+ * \return 0 on sucess, 1 on failure
+ */
+static GLuint
+parse_matrix (GLcontext * ctx, GLubyte ** inst, struct arb_program *Program,
+ GLint * matrix, GLint * matrix_idx, GLint * matrix_modifier)
+{
+ GLubyte mat = *(*inst)++;
+
+ *matrix_idx = 0;
+
+ switch (mat) {
+ case MATRIX_MODELVIEW:
+ *matrix = STATE_MODELVIEW;
+ *matrix_idx = parse_integer (inst, Program);
+ if (*matrix_idx > 0) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "ARB_vertex_blend not supported\n");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "ARB_vertex_blend not supported\n");
+ return 1;
+ }
+ break;
+
+ case MATRIX_PROJECTION:
+ *matrix = STATE_PROJECTION;
+ break;
+
+ case MATRIX_MVP:
+ *matrix = STATE_MVP;
+ break;
+
+ case MATRIX_TEXTURE:
+ *matrix = STATE_TEXTURE;
+ *matrix_idx = parse_integer (inst, Program);
+ if (*matrix_idx >= (GLint) ctx->Const.MaxTextureUnits) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Invalid Texture Unit");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Invalid Texture Unit: %d", *matrix_idx);
+ return 1;
+ }
+ break;
+
+ /* This is not currently supported (ARB_matrix_palette) */
+ case MATRIX_PALETTE:
+ *matrix_idx = parse_integer (inst, Program);
+ _mesa_set_program_error (ctx, Program->Position,
+ "ARB_matrix_palette not supported\n");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "ARB_matrix_palette not supported\n");
+ return 1;
+ break;
+
+ case MATRIX_PROGRAM:
+ *matrix = STATE_PROGRAM;
+ *matrix_idx = parse_integer (inst, Program);
+ if (*matrix_idx >= (GLint) ctx->Const.MaxProgramMatrices) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Invalid Program Matrix");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Invalid Program Matrix: %d", *matrix_idx);
+ return 1;
+ }
+ break;
+ }
+
+ switch (*(*inst)++) {
+ case MATRIX_MODIFIER_IDENTITY:
+ *matrix_modifier = 0;
+ break;
+ case MATRIX_MODIFIER_INVERSE:
+ *matrix_modifier = STATE_MATRIX_INVERSE;
+ break;
+ case MATRIX_MODIFIER_TRANSPOSE:
+ *matrix_modifier = STATE_MATRIX_TRANSPOSE;
+ break;
+ case MATRIX_MODIFIER_INVTRANS:
+ *matrix_modifier = STATE_MATRIX_INVTRANS;
+ break;
+ }
+
+ return 0;
+}
+
+
+/**
+ * This parses a state string (rather, the binary version of it) into
+ * a 6-token sequence as described in _mesa_fetch_state() [program.c]
+ *
+ * \param inst - the start in the binary arry to start working from
+ * \param state_tokens - the storage for the 6-token state description
+ * \return - 0 on sucess, 1 on error
+ */
+static GLuint
+parse_state_single_item (GLcontext * ctx, GLubyte ** inst,
+ struct arb_program *Program, GLint * state_tokens)
+{
+ switch (*(*inst)++) {
+ case STATE_MATERIAL_PARSER:
+ state_tokens[0] = STATE_MATERIAL;
+ state_tokens[1] = parse_face_type (inst);
+ switch (*(*inst)++) {
+ case MATERIAL_AMBIENT:
+ state_tokens[2] = STATE_AMBIENT;
+ break;
+ case MATERIAL_DIFFUSE:
+ state_tokens[2] = STATE_DIFFUSE;
+ break;
+ case MATERIAL_SPECULAR:
+ state_tokens[2] = STATE_SPECULAR;
+ break;
+ case MATERIAL_EMISSION:
+ state_tokens[2] = STATE_EMISSION;
+ break;
+ case MATERIAL_SHININESS:
+ state_tokens[2] = STATE_SHININESS;
+ break;
+ }
+ break;
+
+ case STATE_LIGHT_PARSER:
+ state_tokens[0] = STATE_LIGHT;
+ state_tokens[1] = parse_integer (inst, Program);
+
+ /* Check the value of state_tokens[1] against the # of lights */
+ if (state_tokens[1] >= (GLint) ctx->Const.MaxLights) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Invalid Light Number");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Invalid Light Number: %d", state_tokens[1]);
+ return 1;
+ }
+
+ switch (*(*inst)++) {
+ case LIGHT_AMBIENT:
+ state_tokens[2] = STATE_AMBIENT;
+ break;
+ case LIGHT_DIFFUSE:
+ state_tokens[2] = STATE_DIFFUSE;
+ break;
+ case LIGHT_SPECULAR:
+ state_tokens[2] = STATE_SPECULAR;
+ break;
+ case LIGHT_POSITION:
+ state_tokens[2] = STATE_POSITION;
+ break;
+ case LIGHT_ATTENUATION:
+ state_tokens[2] = STATE_ATTENUATION;
+ break;
+ case LIGHT_HALF:
+ state_tokens[2] = STATE_HALF;
+ break;
+ case LIGHT_SPOT_DIRECTION:
+ state_tokens[2] = STATE_SPOT_DIRECTION;
+ break;
+ }
+ break;
+
+ case STATE_LIGHT_MODEL:
+ switch (*(*inst)++) {
+ case LIGHT_MODEL_AMBIENT:
+ state_tokens[0] = STATE_LIGHTMODEL_AMBIENT;
+ break;
+ case LIGHT_MODEL_SCENECOLOR:
+ state_tokens[0] = STATE_LIGHTMODEL_SCENECOLOR;
+ state_tokens[1] = parse_face_type (inst);
+ break;
+ }
+ break;
+
+ case STATE_LIGHT_PROD:
+ state_tokens[0] = STATE_LIGHTPROD;
+ state_tokens[1] = parse_integer (inst, Program);
+
+ /* Check the value of state_tokens[1] against the # of lights */
+ if (state_tokens[1] >= (GLint) ctx->Const.MaxLights) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Invalid Light Number");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Invalid Light Number: %d", state_tokens[1]);
+ return 1;
+ }
+
+ state_tokens[2] = parse_face_type (inst);
+ switch (*(*inst)++) {
+ case LIGHT_PROD_AMBIENT:
+ state_tokens[3] = STATE_AMBIENT;
+ break;
+ case LIGHT_PROD_DIFFUSE:
+ state_tokens[3] = STATE_DIFFUSE;
+ break;
+ case LIGHT_PROD_SPECULAR:
+ state_tokens[3] = STATE_SPECULAR;
+ break;
+ }
+ break;
+
+
+ case STATE_FOG:
+ switch (*(*inst)++) {
+ case FOG_COLOR:
+ state_tokens[0] = STATE_FOG_COLOR;
+ break;
+ case FOG_PARAMS:
+ state_tokens[0] = STATE_FOG_PARAMS;
+ break;
+ }
+ break;
+
+ case STATE_TEX_ENV:
+ state_tokens[1] = parse_integer (inst, Program);
+ switch (*(*inst)++) {
+ case TEX_ENV_COLOR:
+ state_tokens[0] = STATE_TEXENV_COLOR;
+ break;
+ }
+ break;
+
+ case STATE_TEX_GEN:
+ {
+ GLuint type, coord;
+
+ state_tokens[0] = STATE_TEXGEN;
+ /*state_tokens[1] = parse_integer (inst, Program);*/ /* Texture Unit */
+
+ if (parse_texcoord_num (ctx, inst, Program, &coord))
+ return 1;
+ state_tokens[1] = coord;
+
+ /* EYE or OBJECT */
+ type = *(*inst++);
+
+ /* 0 - s, 1 - t, 2 - r, 3 - q */
+ coord = *(*inst++);
+
+ if (type == TEX_GEN_EYE) {
+ switch (coord) {
+ case COMPONENT_X:
+ state_tokens[2] = STATE_TEXGEN_EYE_S;
+ break;
+ case COMPONENT_Y:
+ state_tokens[2] = STATE_TEXGEN_EYE_T;
+ break;
+ case COMPONENT_Z:
+ state_tokens[2] = STATE_TEXGEN_EYE_R;
+ break;
+ case COMPONENT_W:
+ state_tokens[2] = STATE_TEXGEN_EYE_Q;
+ break;
+ }
+ }
+ else {
+ switch (coord) {
+ case COMPONENT_X:
+ state_tokens[2] = STATE_TEXGEN_OBJECT_S;
+ break;
+ case COMPONENT_Y:
+ state_tokens[2] = STATE_TEXGEN_OBJECT_T;
+ break;
+ case COMPONENT_Z:
+ state_tokens[2] = STATE_TEXGEN_OBJECT_R;
+ break;
+ case COMPONENT_W:
+ state_tokens[2] = STATE_TEXGEN_OBJECT_Q;
+ break;
+ }
+ }
+ }
+ break;
+
+ case STATE_DEPTH:
+ switch (*(*inst)++) {
+ case DEPTH_RANGE:
+ state_tokens[0] = STATE_DEPTH_RANGE;
+ break;
+ }
+ break;
+
+ case STATE_CLIP_PLANE:
+ state_tokens[0] = STATE_CLIPPLANE;
+ state_tokens[1] = parse_integer (inst, Program);
+ if (parse_clipplane_num (ctx, inst, Program, &state_tokens[1]))
+ return 1;
+ break;
+
+ case STATE_POINT:
+ switch (*(*inst++)) {
+ case POINT_SIZE:
+ state_tokens[0] = STATE_POINT_SIZE;
+ break;
+
+ case POINT_ATTENUATION:
+ state_tokens[0] = STATE_POINT_ATTENUATION;
+ break;
+ }
+ break;
+
+ /* XXX: I think this is the correct format for a matrix row */
+ case STATE_MATRIX_ROWS:
+ state_tokens[0] = STATE_MATRIX;
+ if (parse_matrix
+ (ctx, inst, Program, &state_tokens[1], &state_tokens[2],
+ &state_tokens[5]))
+ return 1;
+
+ state_tokens[3] = parse_integer (inst, Program); /* The first row to grab */
+
+ if ((**inst) != 0) { /* Either the last row, 0 */
+ state_tokens[4] = parse_integer (inst, Program);
+ if (state_tokens[4] < state_tokens[3]) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Second matrix index less than the first");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Second matrix index (%d) less than the first (%d)",
+ state_tokens[4], state_tokens[3]);
+ return 1;
+ }
+ }
+ else {
+ state_tokens[4] = state_tokens[3];
+ (*inst)++;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+/**
+ * This parses a state string (rather, the binary version of it) into
+ * a 6-token similar for the state fetching code in program.c
+ *
+ * One might ask, why fetch these parameters into just like you fetch
+ * state when they are already stored in other places?
+ *
+ * Because of array offsets -> We can stick env/local parameters in the
+ * middle of a parameter array and then index someplace into the array
+ * when we execute.
+ *
+ * One optimization might be to only do this for the cases where the
+ * env/local parameters end up inside of an array, and leave the
+ * single parameters (or arrays of pure env/local pareameters) in their
+ * respective register files.
+ *
+ * For ENV parameters, the format is:
+ * state_tokens[0] = STATE_FRAGMENT_PROGRAM / STATE_VERTEX_PROGRAM
+ * state_tokens[1] = STATE_ENV
+ * state_tokens[2] = the parameter index
+ *
+ * for LOCAL parameters, the format is:
+ * state_tokens[0] = STATE_FRAGMENT_PROGRAM / STATE_VERTEX_PROGRAM
+ * state_tokens[1] = STATE_LOCAL
+ * state_tokens[2] = the parameter index
+ *
+ * \param inst - the start in the binary arry to start working from
+ * \param state_tokens - the storage for the 6-token state description
+ * \return - 0 on sucess, 1 on failure
+ */
+static GLuint
+parse_program_single_item (GLcontext * ctx, GLubyte ** inst,
+ struct arb_program *Program, GLint * state_tokens)
+{
+ if (Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB)
+ state_tokens[0] = STATE_FRAGMENT_PROGRAM;
+ else
+ state_tokens[0] = STATE_VERTEX_PROGRAM;
+
+
+ switch (*(*inst)++) {
+ case PROGRAM_PARAM_ENV:
+ state_tokens[1] = STATE_ENV;
+ state_tokens[2] = parse_integer (inst, Program);
+
+ /* Check state_tokens[2] against the number of ENV parameters available */
+ if (((Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) &&
+ (state_tokens[2] >= (GLint) ctx->Const.MaxFragmentProgramEnvParams))
+ ||
+ ((Program->Base.Target == GL_VERTEX_PROGRAM_ARB) &&
+ (state_tokens[2] >= (GLint) ctx->Const.MaxVertexProgramEnvParams))) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Invalid Program Env Parameter");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Invalid Program Env Parameter: %d",
+ state_tokens[2]);
+ return 1;
+ }
+
+ break;
+
+ case PROGRAM_PARAM_LOCAL:
+ state_tokens[1] = STATE_LOCAL;
+ state_tokens[2] = parse_integer (inst, Program);
+
+ /* Check state_tokens[2] against the number of LOCAL parameters available */
+ if (((Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) &&
+ (state_tokens[2] >= (GLint) ctx->Const.MaxFragmentProgramLocalParams))
+ ||
+ ((Program->Base.Target == GL_VERTEX_PROGRAM_ARB) &&
+ (state_tokens[2] >= (GLint) ctx->Const.MaxVertexProgramLocalParams))) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Invalid Program Local Parameter");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Invalid Program Local Parameter: %d",
+ state_tokens[2]);
+ return 1;
+ }
+ break;
+ }
+
+ return 0;
+}
+
+/**
+ * For ARB_vertex_program, programs are not allowed to use both an explicit
+ * vertex attribute and a generic vertex attribute corresponding to the same
+ * state. See section 2.14.3.1 of the GL_ARB_vertex_program spec.
+ *
+ * This will walk our var_cache and make sure that nobody does anything fishy.
+ *
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+generic_attrib_check(struct var_cache *vc_head)
+{
+ int a;
+ struct var_cache *curr;
+ GLboolean explicitAttrib[MAX_VERTEX_PROGRAM_ATTRIBS],
+ genericAttrib[MAX_VERTEX_PROGRAM_ATTRIBS];
+
+ for (a=0; a<MAX_VERTEX_PROGRAM_ATTRIBS; a++) {
+ explicitAttrib[a] = GL_FALSE;
+ genericAttrib[a] = GL_FALSE;
+ }
+
+ curr = vc_head;
+ while (curr) {
+ if (curr->type == vt_attrib) {
+ if (curr->attrib_is_generic)
+ genericAttrib[ curr->attrib_binding_idx ] = GL_TRUE;
+ else
+ explicitAttrib[ curr->attrib_binding_idx ] = GL_TRUE;
+ }
+
+ curr = curr->next;
+ }
+
+ for (a=0; a<MAX_VERTEX_PROGRAM_ATTRIBS; a++) {
+ if ((explicitAttrib[a]) && (genericAttrib[a]))
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * This will handle the binding side of an ATTRIB var declaration
+ *
+ * \param binding - the fragment input register state, defined in nvfragprog.h
+ * \param binding_idx - the index in the attrib register file that binding is associated with
+ * \return returns 0 on sucess, 1 on error
+ *
+ * See nvfragparse.c for attrib register file layout
+ */
+static GLuint
+parse_attrib_binding (GLcontext * ctx, GLubyte ** inst,
+ struct arb_program *Program, GLuint * binding,
+ GLuint * binding_idx, GLuint *is_generic)
+{
+ GLuint texcoord;
+ GLint coord;
+ GLint err = 0;
+
+ *is_generic = 0;
+ if (Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) {
+ switch (*(*inst)++) {
+ case FRAGMENT_ATTRIB_COLOR:
+ err = parse_color_type (ctx, inst, Program, &coord);
+ *binding = FRAG_ATTRIB_COL0 + coord;
+ *binding_idx = 1 + coord;
+ break;
+
+ case FRAGMENT_ATTRIB_TEXCOORD:
+ err = parse_texcoord_num (ctx, inst, Program, &texcoord);
+ *binding = FRAG_ATTRIB_TEX0 + texcoord;
+ *binding_idx = 4 + texcoord;
+ break;
+
+ case FRAGMENT_ATTRIB_FOGCOORD:
+ *binding = FRAG_ATTRIB_FOGC;
+ *binding_idx = 3;
+ break;
+
+ case FRAGMENT_ATTRIB_POSITION:
+ *binding = FRAG_ATTRIB_WPOS;
+ *binding_idx = 0;
+ break;
+
+ default:
+ err = 1;
+ break;
+ }
+ }
+ else {
+ switch (*(*inst)++) {
+ case VERTEX_ATTRIB_POSITION:
+ *binding = VERT_ATTRIB_POS;
+ *binding_idx = 0;
+ break;
+
+ case VERTEX_ATTRIB_WEIGHT:
+ {
+ GLint weight;
+
+ err = parse_weight_num (ctx, inst, Program, &weight);
+ *binding = VERT_ATTRIB_WEIGHT;
+ *binding_idx = 1;
+ }
+ _mesa_set_program_error (ctx, Program->Position,
+ "ARB_vertex_blend not supported\n");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "ARB_vertex_blend not supported\n");
+ return 1;
+ break;
+
+ case VERTEX_ATTRIB_NORMAL:
+ *binding = VERT_ATTRIB_NORMAL;
+ *binding_idx = 2;
+ break;
+
+ case VERTEX_ATTRIB_COLOR:
+ {
+ GLint color;
+
+ err = parse_color_type (ctx, inst, Program, &color);
+ if (color) {
+ *binding = VERT_ATTRIB_COLOR1;
+ *binding_idx = 4;
+ }
+ else {
+ *binding = VERT_ATTRIB_COLOR0;
+ *binding_idx = 3;
+ }
+ }
+ break;
+
+ case VERTEX_ATTRIB_FOGCOORD:
+ *binding = VERT_ATTRIB_FOG;
+ *binding_idx = 5;
+ break;
+
+ case VERTEX_ATTRIB_TEXCOORD:
+ {
+ GLuint unit;
+
+ err = parse_texcoord_num (ctx, inst, Program, &unit);
+ *binding = VERT_ATTRIB_TEX0 + unit;
+ *binding_idx = 8 + unit;
+ }
+ break;
+
+ /* It looks like we don't support this at all, atm */
+ case VERTEX_ATTRIB_MATRIXINDEX:
+ parse_integer (inst, Program);
+ _mesa_set_program_error (ctx, Program->Position,
+ "ARB_palette_matrix not supported");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "ARB_palette_matrix not supported");
+ return 1;
+ break;
+
+ case VERTEX_ATTRIB_GENERIC:
+ {
+ GLuint attrib;
+
+ if (!parse_generic_attrib_num(ctx, inst, Program, &attrib)) {
+ *is_generic = 1;
+ switch (attrib) {
+ case 0:
+ *binding = VERT_ATTRIB_POS;
+ break;
+ case 1:
+ *binding = VERT_ATTRIB_WEIGHT;
+ break;
+ case 2:
+ *binding = VERT_ATTRIB_NORMAL;
+ break;
+ case 3:
+ *binding = VERT_ATTRIB_COLOR0;
+ break;
+ case 4:
+ *binding = VERT_ATTRIB_COLOR1;
+ break;
+ case 5:
+ *binding = VERT_ATTRIB_FOG;
+ break;
+ case 6:
+ break;
+ case 7:
+ break;
+ default:
+ *binding = VERT_ATTRIB_TEX0 + (attrib-8);
+ break;
+ }
+ *binding_idx = attrib;
+ }
+ }
+ break;
+
+ default:
+ err = 1;
+ break;
+ }
+ }
+
+ /* Can this even happen? */
+ if (err) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Bad attribute binding");
+ _mesa_error (ctx, GL_INVALID_OPERATION, "Bad attribute binding");
+ }
+
+ Program->InputsRead |= (1 << *binding_idx);
+
+ return err;
+}
+
+/**
+ * This translates between a binary token for an output variable type
+ * and the mesa token for the same thing.
+ *
+ *
+ * XXX: What is the 'name' for vertex program state? -> do we need it?
+ * I don't think we do;
+ *
+ * See nvfragprog.h for definitions
+ *
+ * \param inst - The parsed tokens
+ * \param binding - The name of the state we are binding too
+ * \param binding_idx - The index into the result register file that this is bound too
+ *
+ * See nvfragparse.c for the register file layout for fragment programs
+ * See nvvertparse.c for the register file layout for vertex programs
+ */
+static GLuint
+parse_result_binding (GLcontext * ctx, GLubyte ** inst, GLuint * binding,
+ GLuint * binding_idx, struct arb_program *Program)
+{
+ GLuint b, out_color;
+
+ switch (*(*inst)++) {
+ case FRAGMENT_RESULT_COLOR:
+ /* for frag programs, this is FRAGMENT_RESULT_COLOR */
+ if (Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) {
+ /* This gets result of the color buffer we're supposed to
+ * draw into
+ */
+ parse_output_color_num(ctx, inst, Program, &out_color);
+
+ *binding = FRAG_OUTPUT_COLR;
+
+ /* XXX: We're ignoring the color buffer for now. */
+ *binding_idx = 0;
+ }
+ /* for vtx programs, this is VERTEX_RESULT_POSITION */
+ else {
+ *binding_idx = 0;
+ }
+ break;
+
+ case FRAGMENT_RESULT_DEPTH:
+ /* for frag programs, this is FRAGMENT_RESULT_DEPTH */
+ if (Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) {
+ *binding = FRAG_OUTPUT_DEPR;
+ *binding_idx = 2;
+ }
+ /* for vtx programs, this is VERTEX_RESULT_COLOR */
+ else {
+ GLint color_type;
+ GLuint face_type = parse_face_type(inst);
+ GLint color_type_ret = parse_color_type(ctx, inst, Program, &color_type);
+
+ /* back face */
+ if (face_type) {
+ if (color_type_ret) return 1;
+
+ /* secondary color */
+ if (color_type) {
+ *binding_idx = 4;
+ }
+ /* primary color */
+ else {
+ *binding_idx = 3;
+ }
+ }
+ /* front face */
+ else {
+ /* secondary color */
+ if (color_type) {
+ *binding_idx = 2;
+ }
+ /* primary color */
+ else {
+ *binding_idx = 1;
+ }
+ }
+ }
+ break;
+
+ case VERTEX_RESULT_FOGCOORD:
+ *binding_idx = 5;
+ break;
+
+ case VERTEX_RESULT_POINTSIZE:
+ *binding_idx = 6;
+ break;
+
+ case VERTEX_RESULT_TEXCOORD:
+ if (parse_texcoord_num (ctx, inst, Program, &b))
+ return 1;
+ *binding_idx = 7 + b;
+ break;
+ }
+
+ Program->OutputsWritten |= (1 << *binding_idx);
+
+ return 0;
+}
+
+/**
+ * This handles the declaration of ATTRIB variables
+ *
+ * XXX: Still needs
+ * parse_vert_attrib_binding(), or something like that
+ *
+ * \return 0 on sucess, 1 on error
+ */
+static GLint
+parse_attrib (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
+ struct arb_program *Program)
+{
+ GLuint found;
+ char *error_msg;
+ struct var_cache *attrib_var;
+
+ attrib_var = parse_string (inst, vc_head, Program, &found);
+ Program->Position = parse_position (inst);
+ if (found) {
+ error_msg = (char *)
+ _mesa_malloc (_mesa_strlen ((char *) attrib_var->name) + 40);
+ _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s",
+ attrib_var->name);
+
+ _mesa_set_program_error (ctx, Program->Position, error_msg);
+ _mesa_error (ctx, GL_INVALID_OPERATION, error_msg);
+
+ _mesa_free (error_msg);
+ return 1;
+ }
+
+ attrib_var->type = vt_attrib;
+
+ /* I think this is ok now - karl */
+ /* XXX: */
+ /*if (Program->type == GL_FRAGMENT_PROGRAM_ARB) */
+ {
+ if (parse_attrib_binding
+ (ctx, inst, Program, &attrib_var->attrib_binding,
+ &attrib_var->attrib_binding_idx, &attrib_var->attrib_is_generic))
+ return 1;
+ if (generic_attrib_check(*vc_head)) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Cannot use both a generic vertex attribute and a specific attribute of the same type");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Cannot use both a generic vertex attribute and a specific attribute of the same type");
+ return 1;
+ }
+
+ }
+
+ Program->Base.NumAttributes++;
+ return 0;
+}
+
+/**
+ * \param use -- TRUE if we're called when declaring implicit parameters,
+ * FALSE if we're declaraing variables. This has to do with
+ * if we get a signed or unsigned float for scalar constants
+ */
+static GLuint
+parse_param_elements (GLcontext * ctx, GLubyte ** inst,
+ struct var_cache *param_var,
+ struct arb_program *Program, GLboolean use)
+{
+ GLint idx;
+ GLuint err;
+ GLint state_tokens[6];
+ GLfloat const_values[4];
+
+ err = 0;
+
+ switch (*(*inst)++) {
+ case PARAM_STATE_ELEMENT:
+
+ if (parse_state_single_item (ctx, inst, Program, state_tokens))
+ return 1;
+
+ /* If we adding STATE_MATRIX that has multiple rows, we need to
+ * unroll it and call _mesa_add_state_reference() for each row
+ */
+ if ((state_tokens[0] == STATE_MATRIX)
+ && (state_tokens[3] != state_tokens[4])) {
+ GLint row;
+ GLint first_row = state_tokens[3];
+ GLint last_row = state_tokens[4];
+
+ for (row = first_row; row <= last_row; row++) {
+ state_tokens[3] = state_tokens[4] = row;
+
+ idx =
+ _mesa_add_state_reference (Program->Parameters,
+ state_tokens);
+ if (param_var->param_binding_begin == ~0U)
+ param_var->param_binding_begin = idx;
+ param_var->param_binding_length++;
+ Program->Base.NumParameters++;
+ }
+ }
+ else {
+ idx =
+ _mesa_add_state_reference (Program->Parameters, state_tokens);
+ if (param_var->param_binding_begin == ~0U)
+ param_var->param_binding_begin = idx;
+ param_var->param_binding_length++;
+ Program->Base.NumParameters++;
+ }
+ break;
+
+ case PARAM_PROGRAM_ELEMENT:
+
+ if (parse_program_single_item (ctx, inst, Program, state_tokens))
+ return 1;
+ idx = _mesa_add_state_reference (Program->Parameters, state_tokens);
+ if (param_var->param_binding_begin == ~0U)
+ param_var->param_binding_begin = idx;
+ param_var->param_binding_length++;
+ Program->Base.NumParameters++;
+
+ /* Check if there is more: 0 -> we're done, else its an integer */
+ if (**inst) {
+ GLuint out_of_range, new_idx;
+ GLuint start_idx = state_tokens[2] + 1;
+ GLuint end_idx = parse_integer (inst, Program);
+
+ out_of_range = 0;
+ if (Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) {
+ if (((state_tokens[1] == STATE_ENV)
+ && (end_idx >= ctx->Const.MaxFragmentProgramEnvParams))
+ || ((state_tokens[1] == STATE_LOCAL)
+ && (end_idx >=
+ ctx->Const.MaxFragmentProgramLocalParams)))
+ out_of_range = 1;
+ }
+ else {
+ if (((state_tokens[1] == STATE_ENV)
+ && (end_idx >= ctx->Const.MaxVertexProgramEnvParams))
+ || ((state_tokens[1] == STATE_LOCAL)
+ && (end_idx >=
+ ctx->Const.MaxVertexProgramLocalParams)))
+ out_of_range = 1;
+ }
+ if (out_of_range) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Invalid Program Parameter");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Invalid Program Parameter: %d", end_idx);
+ return 1;
+ }
+
+ for (new_idx = start_idx; new_idx <= end_idx; new_idx++) {
+ state_tokens[2] = new_idx;
+ idx =
+ _mesa_add_state_reference (Program->Parameters,
+ state_tokens);
+ param_var->param_binding_length++;
+ Program->Base.NumParameters++;
+ }
+ }
+ else
+ {
+ (*inst)++;
+ }
+ break;
+
+ case PARAM_CONSTANT:
+ parse_constant (inst, const_values, Program, use);
+ idx =
+ _mesa_add_named_constant (Program->Parameters,
+ (char *) param_var->name, const_values);
+ if (param_var->param_binding_begin == ~0U)
+ param_var->param_binding_begin = idx;
+ param_var->param_binding_length++;
+ Program->Base.NumParameters++;
+ break;
+
+ default:
+ _mesa_set_program_error (ctx, Program->Position,
+ "Unexpected token in parse_param_elements()");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Unexpected token in parse_param_elements()");
+ return 1;
+ }
+
+ /* Make sure we haven't blown past our parameter limits */
+ if (((Program->Base.Target == GL_VERTEX_PROGRAM_ARB) &&
+ (Program->Base.NumParameters >=
+ ctx->Const.MaxVertexProgramLocalParams))
+ || ((Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB)
+ && (Program->Base.NumParameters >=
+ ctx->Const.MaxFragmentProgramLocalParams))) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Too many parameter variables");
+ _mesa_error (ctx, GL_INVALID_OPERATION, "Too many parameter variables");
+ return 1;
+ }
+
+ return err;
+}
+
+/**
+ * This picks out PARAM program parameter bindings.
+ *
+ * XXX: This needs to be stressed & tested
+ *
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_param (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
+ struct arb_program *Program)
+{
+ GLuint found, err;
+ GLint specified_length;
+ char *error_msg;
+ struct var_cache *param_var;
+
+ err = 0;
+ param_var = parse_string (inst, vc_head, Program, &found);
+ Program->Position = parse_position (inst);
+
+ if (found) {
+ error_msg = (char *) _mesa_malloc (_mesa_strlen ((char *) param_var->name) + 40);
+ _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s",
+ param_var->name);
+
+ _mesa_set_program_error (ctx, Program->Position, error_msg);
+ _mesa_error (ctx, GL_INVALID_OPERATION, error_msg);
+
+ _mesa_free (error_msg);
+ return 1;
+ }
+
+ specified_length = parse_integer (inst, Program);
+
+ if (specified_length < 0) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Negative parameter array length");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Negative parameter array length: %d", specified_length);
+ return 1;
+ }
+
+ param_var->type = vt_param;
+ param_var->param_binding_length = 0;
+
+ /* Right now, everything is shoved into the main state register file.
+ *
+ * In the future, it would be nice to leave things ENV/LOCAL params
+ * in their respective register files, if possible
+ */
+ param_var->param_binding_type = PROGRAM_STATE_VAR;
+
+ /* Remember to:
+ * * - add each guy to the parameter list
+ * * - increment the param_var->param_binding_len
+ * * - store the param_var->param_binding_begin for the first one
+ * * - compare the actual len to the specified len at the end
+ */
+ while (**inst != PARAM_NULL) {
+ if (parse_param_elements (ctx, inst, param_var, Program, GL_FALSE))
+ return 1;
+ }
+
+ /* Test array length here! */
+ if (specified_length) {
+ if (specified_length != (int)param_var->param_binding_length) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Declared parameter array length does not match parameter list");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Declared parameter array length does not match parameter list");
+ }
+ }
+
+ (*inst)++;
+
+ return 0;
+}
+
+/**
+ *
+ */
+static GLuint
+parse_param_use (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
+ struct arb_program *Program, struct var_cache **new_var)
+{
+ struct var_cache *param_var;
+
+ /* First, insert a dummy entry into the var_cache */
+ var_cache_create (&param_var);
+ param_var->name = (GLubyte *) _mesa_strdup (" ");
+ param_var->type = vt_param;
+
+ param_var->param_binding_length = 0;
+ /* Don't fill in binding_begin; We use the default value of -1
+ * to tell if its already initialized, elsewhere.
+ *
+ * param_var->param_binding_begin = 0;
+ */
+ param_var->param_binding_type = PROGRAM_STATE_VAR;
+
+ var_cache_append (vc_head, param_var);
+
+ /* Then fill it with juicy parameter goodness */
+ if (parse_param_elements (ctx, inst, param_var, Program, GL_TRUE))
+ return 1;
+
+ *new_var = param_var;
+
+ return 0;
+}
+
+
+/**
+ * This handles the declaration of TEMP variables
+ *
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_temp (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
+ struct arb_program *Program)
+{
+ GLuint found;
+ struct var_cache *temp_var;
+ char *error_msg;
+
+ while (**inst != 0) {
+ temp_var = parse_string (inst, vc_head, Program, &found);
+ Program->Position = parse_position (inst);
+ if (found) {
+ error_msg = (char *)
+ _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40);
+ _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s",
+ temp_var->name);
+
+ _mesa_set_program_error (ctx, Program->Position, error_msg);
+ _mesa_error (ctx, GL_INVALID_OPERATION, error_msg);
+
+ _mesa_free (error_msg);
+ return 1;
+ }
+
+ temp_var->type = vt_temp;
+
+ if (((Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) &&
+ (Program->Base.NumTemporaries >=
+ ctx->Const.MaxFragmentProgramTemps))
+ || ((Program->Base.Target == GL_VERTEX_PROGRAM_ARB)
+ && (Program->Base.NumTemporaries >=
+ ctx->Const.MaxVertexProgramTemps))) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Too many TEMP variables declared");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Too many TEMP variables declared");
+ return 1;
+ }
+
+ temp_var->temp_binding = Program->Base.NumTemporaries;
+ Program->Base.NumTemporaries++;
+ }
+ (*inst)++;
+
+ return 0;
+}
+
+/**
+ * This handles variables of the OUTPUT variety
+ *
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_output (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
+ struct arb_program *Program)
+{
+ GLuint found;
+ struct var_cache *output_var;
+
+ output_var = parse_string (inst, vc_head, Program, &found);
+ Program->Position = parse_position (inst);
+ if (found) {
+ char *error_msg;
+ error_msg = (char *)
+ _mesa_malloc (_mesa_strlen ((char *) output_var->name) + 40);
+ _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s",
+ output_var->name);
+
+ _mesa_set_program_error (ctx, Program->Position, error_msg);
+ _mesa_error (ctx, GL_INVALID_OPERATION, error_msg);
+
+ _mesa_free (error_msg);
+ return 1;
+ }
+
+ output_var->type = vt_output;
+ return parse_result_binding (ctx, inst, &output_var->output_binding,
+ &output_var->output_binding_idx, Program);
+}
+
+/**
+ * This handles variables of the ALIAS kind
+ *
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_alias (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
+ struct arb_program *Program)
+{
+ GLuint found;
+ struct var_cache *temp_var;
+ char *error_msg;
+
+
+ temp_var = parse_string (inst, vc_head, Program, &found);
+ Program->Position = parse_position (inst);
+
+ if (found) {
+ error_msg = (char *)
+ _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40);
+ _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s",
+ temp_var->name);
+
+ _mesa_set_program_error (ctx, Program->Position, error_msg);
+ _mesa_error (ctx, GL_INVALID_OPERATION, error_msg);
+
+ _mesa_free (error_msg);
+ return 1;
+ }
+
+ temp_var->type = vt_alias;
+ temp_var->alias_binding = parse_string (inst, vc_head, Program, &found);
+ Program->Position = parse_position (inst);
+
+ if (!found)
+ {
+ error_msg = (char *)
+ _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40);
+ _mesa_sprintf (error_msg, "Alias value %s is not defined",
+ temp_var->alias_binding->name);
+
+ _mesa_set_program_error (ctx, Program->Position, error_msg);
+ _mesa_error (ctx, GL_INVALID_OPERATION, error_msg);
+
+ _mesa_free (error_msg);
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ * This handles variables of the ADDRESS kind
+ *
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_address (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
+ struct arb_program *Program)
+{
+ GLuint found;
+ struct var_cache *temp_var;
+ char *error_msg;
+
+ while (**inst != 0) {
+ temp_var = parse_string (inst, vc_head, Program, &found);
+ Program->Position = parse_position (inst);
+ if (found) {
+ error_msg = (char *)
+ _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40);
+ _mesa_sprintf (error_msg, "Duplicate Varible Declaration: %s",
+ temp_var->name);
+
+ _mesa_set_program_error (ctx, Program->Position, error_msg);
+ _mesa_error (ctx, GL_INVALID_OPERATION, error_msg);
+
+ _mesa_free (error_msg);
+ return 1;
+ }
+
+ temp_var->type = vt_address;
+
+ if (Program->Base.NumAddressRegs >=
+ ctx->Const.MaxVertexProgramAddressRegs) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Too many ADDRESS variables declared");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Too many ADDRESS variables declared");
+ return 1;
+ }
+
+ temp_var->address_binding = Program->Base.NumAddressRegs;
+ Program->Base.NumAddressRegs++;
+ }
+ (*inst)++;
+
+ return 0;
+}
+
+/**
+ * Parse a program declaration
+ *
+ * \return 0 on sucess, 1 on error
+ */
+static GLint
+parse_declaration (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
+ struct arb_program *Program)
+{
+ GLint err = 0;
+
+ switch (*(*inst)++) {
+ case ADDRESS:
+ err = parse_address (ctx, inst, vc_head, Program);
+ break;
+
+ case ALIAS:
+ err = parse_alias (ctx, inst, vc_head, Program);
+ break;
+
+ case ATTRIB:
+ err = parse_attrib (ctx, inst, vc_head, Program);
+ break;
+
+ case OUTPUT:
+ err = parse_output (ctx, inst, vc_head, Program);
+ break;
+
+ case PARAM:
+ err = parse_param (ctx, inst, vc_head, Program);
+ break;
+
+ case TEMP:
+ err = parse_temp (ctx, inst, vc_head, Program);
+ break;
+ }
+
+ return err;
+}
+
+/**
+ * Handle the parsing out of a masked destination register
+ *
+ * If we are a vertex program, make sure we don't write to
+ * result.position of we have specified that the program is
+ * position invariant
+ *
+ * \param File - The register file we write to
+ * \param Index - The register index we write to
+ * \param WriteMask - The mask controlling which components we write (1->write)
+ *
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_masked_dst_reg (GLcontext * ctx, GLubyte ** inst,
+ struct var_cache **vc_head, struct arb_program *Program,
+ GLint * File, GLint * Index, GLint *WriteMask)
+{
+ GLuint result, tmp;
+ struct var_cache *dst;
+
+ /* We either have a result register specified, or a
+ * variable that may or may not be writable
+ */
+ switch (*(*inst)++) {
+ case REGISTER_RESULT:
+ if (parse_result_binding
+ (ctx, inst, &result, (GLuint *) Index, Program))
+ return 1;
+ *File = PROGRAM_OUTPUT;
+ break;
+
+ case REGISTER_ESTABLISHED_NAME:
+ dst = parse_string (inst, vc_head, Program, &result);
+ Program->Position = parse_position (inst);
+
+ /* If the name has never been added to our symbol table, we're hosed */
+ if (!result) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "0: Undefined variable");
+ _mesa_error (ctx, GL_INVALID_OPERATION, "0: Undefined variable: %s",
+ dst->name);
+ return 1;
+ }
+
+ switch (dst->type) {
+ case vt_output:
+ *File = PROGRAM_OUTPUT;
+ *Index = dst->output_binding_idx;
+ break;
+
+ case vt_temp:
+ *File = PROGRAM_TEMPORARY;
+ *Index = dst->temp_binding;
+ break;
+
+ /* If the var type is not vt_output or vt_temp, no go */
+ default:
+ _mesa_set_program_error (ctx, Program->Position,
+ "Destination register is read only");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Destination register is read only: %s",
+ dst->name);
+ return 1;
+ }
+ break;
+
+ default:
+ _mesa_set_program_error (ctx, Program->Position,
+ "Unexpected opcode in parse_masked_dst_reg()");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Unexpected opcode in parse_masked_dst_reg()");
+ return 1;
+ }
+
+
+ /* Position invariance test */
+ /* This test is done now in syntax portion - when position invariance OPTION
+ is specified, "result.position" rule is disabled so there is no way
+ to write the position
+ */
+ /*if ((Program->HintPositionInvariant) && (*File == PROGRAM_OUTPUT) &&
+ (*Index == 0)) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Vertex program specified position invariance and wrote vertex position");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Vertex program specified position invariance and wrote vertex position");
+ }*/
+
+ /* And then the mask.
+ * w,a -> bit 0
+ * z,b -> bit 1
+ * y,g -> bit 2
+ * x,r -> bit 3
+ *
+ * ==> Need to reverse the order of bits for this!
+ */
+ tmp = (GLint) *(*inst)++;
+ *WriteMask = (((tmp>>3) & 0x1) |
+ ((tmp>>1) & 0x2) |
+ ((tmp<<1) & 0x4) |
+ ((tmp<<3) & 0x8));
+
+ return 0;
+}
+
+
+/**
+ * Handle the parsing of a address register
+ *
+ * \param Index - The register index we write to
+ *
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_address_reg (GLcontext * ctx, GLubyte ** inst,
+ struct var_cache **vc_head,
+ struct arb_program *Program, GLint * Index)
+{
+ struct var_cache *dst;
+ GLuint result;
+ (void) Index;
+
+ dst = parse_string (inst, vc_head, Program, &result);
+ Program->Position = parse_position (inst);
+
+ /* If the name has never been added to our symbol table, we're hosed */
+ if (!result) {
+ _mesa_set_program_error (ctx, Program->Position, "Undefined variable");
+ _mesa_error (ctx, GL_INVALID_OPERATION, "Undefined variable: %s",
+ dst->name);
+ return 1;
+ }
+
+ if (dst->type != vt_address) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Variable is not of type ADDRESS");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Variable: %s is not of type ADDRESS", dst->name);
+ return 1;
+ }
+
+ return 0;
+}
+
+#if 0 /* unused */
+/**
+ * Handle the parsing out of a masked address register
+ *
+ * \param Index - The register index we write to
+ * \param WriteMask - The mask controlling which components we write (1->write)
+ *
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_masked_address_reg (GLcontext * ctx, GLubyte ** inst,
+ struct var_cache **vc_head,
+ struct arb_program *Program, GLint * Index,
+ GLboolean * WriteMask)
+{
+ if (parse_address_reg (ctx, inst, vc_head, Program, Index))
+ return 1;
+
+ /* This should be 0x8 */
+ (*inst)++;
+
+ /* Writemask of .x is implied */
+ WriteMask[0] = 1;
+ WriteMask[1] = WriteMask[2] = WriteMask[3] = 0;
+
+ return 0;
+}
+#endif
+
+/**
+ * Parse out a swizzle mask.
+ *
+ * The values in the input stream are:
+ * COMPONENT_X -> x/r
+ * COMPONENT_Y -> y/g
+ * COMPONENT_Z-> z/b
+ * COMPONENT_W-> w/a
+ *
+ * The values in the output mask are:
+ * 0 -> x/r
+ * 1 -> y/g
+ * 2 -> z/b
+ * 3 -> w/a
+ *
+ * The len parameter allows us to grab 4 components for a vector
+ * swizzle, or just 1 component for a scalar src register selection
+ */
+static GLuint
+parse_swizzle_mask (GLubyte ** inst, GLubyte * mask, GLint len)
+{
+ GLint a;
+
+ for (a = 0; a < 4; a++)
+ mask[a] = a;
+
+ for (a = 0; a < len; a++) {
+ switch (*(*inst)++) {
+ case COMPONENT_X:
+ mask[a] = 0;
+ break;
+
+ case COMPONENT_Y:
+ mask[a] = 1;
+ break;
+
+ case COMPONENT_Z:
+ mask[a] = 2;
+ break;
+
+ case COMPONENT_W:
+ mask[a] = 3;
+ break;
+ }
+ }
+
+ return 0;
+}
+
+/**
+ */
+static GLuint
+parse_extended_swizzle_mask(GLubyte **inst, GLubyte *mask, GLubyte *negate)
+{
+ GLint a;
+ GLubyte swz;
+
+ *negate = 0x0;
+ for (a = 0; a < 4; a++) {
+ if (parse_sign (inst) == -1)
+ *negate |= (1 << a);
+
+ swz = *(*inst)++;
+
+ switch (swz) {
+ case COMPONENT_0:
+ mask[a] = SWIZZLE_ZERO;
+ break;
+ case COMPONENT_1:
+ mask[a] = SWIZZLE_ONE;
+ break;
+ case COMPONENT_X:
+ mask[a] = SWIZZLE_X;
+ break;
+ case COMPONENT_Y:
+ mask[a] = SWIZZLE_Y;
+ break;
+ case COMPONENT_Z:
+ mask[a] = SWIZZLE_Z;
+ break;
+ case COMPONENT_W:
+ mask[a] = SWIZZLE_W;
+ break;
+
+ }
+#if 0
+ if (swz == 0)
+ mask[a] = SWIZZLE_ZERO;
+ else if (swz == 1)
+ mask[a] = SWIZZLE_ONE;
+ else
+ mask[a] = swz - 2;
+#endif
+
+ }
+
+ return 0;
+}
+
+
+static GLuint
+parse_src_reg (GLcontext * ctx, GLubyte ** inst, struct var_cache **vc_head,
+ struct arb_program *Program, GLint * File, GLint * Index,
+ GLboolean *IsRelOffset )
+{
+ struct var_cache *src;
+ GLuint binding_state, binding_idx, is_generic, found;
+ GLint offset;
+
+ *IsRelOffset = 0;
+
+ /* And the binding for the src */
+ switch (*(*inst)++) {
+ case REGISTER_ATTRIB:
+ if (parse_attrib_binding
+ (ctx, inst, Program, &binding_state, &binding_idx, &is_generic))
+ return 1;
+ *File = PROGRAM_INPUT;
+ *Index = binding_idx;
+
+ /* We need to insert a dummy variable into the var_cache so we can
+ * catch generic vertex attrib aliasing errors
+ */
+ var_cache_create(&src);
+ src->type = vt_attrib;
+ src->name = (GLubyte *)_mesa_strdup("Dummy Attrib Variable");
+ src->attrib_binding = binding_state;
+ src->attrib_binding_idx = binding_idx;
+ src->attrib_is_generic = is_generic;
+ var_cache_append(vc_head, src);
+ if (generic_attrib_check(*vc_head)) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Cannot use both a generic vertex attribute and a specific attribute of the same type");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Cannot use both a generic vertex attribute and a specific attribute of the same type");
+ return 1;
+ }
+ break;
+
+ case REGISTER_PARAM:
+ switch (**inst) {
+ case PARAM_ARRAY_ELEMENT:
+ (*inst)++;
+ src = parse_string (inst, vc_head, Program, &found);
+ Program->Position = parse_position (inst);
+
+ if (!found) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "2: Undefined variable");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "2: Undefined variable: %s", src->name);
+ return 1;
+ }
+
+ *File = src->param_binding_type;
+
+ switch (*(*inst)++) {
+ case ARRAY_INDEX_ABSOLUTE:
+ offset = parse_integer (inst, Program);
+
+ if ((offset < 0)
+ || (offset >= (int)src->param_binding_length)) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Index out of range");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Index %d out of range for %s", offset,
+ src->name);
+ return 1;
+ }
+
+ *Index = src->param_binding_begin + offset;
+ break;
+
+ case ARRAY_INDEX_RELATIVE:
+ {
+ GLint addr_reg_idx, rel_off;
+
+ /* First, grab the address regiseter */
+ if (parse_address_reg (ctx, inst, vc_head, Program, &addr_reg_idx))
+ return 1;
+
+ /* And the .x */
+ ((*inst)++);
+ ((*inst)++);
+ ((*inst)++);
+ ((*inst)++);
+
+ /* Then the relative offset */
+ if (parse_relative_offset(ctx, inst, Program, &rel_off)) return 1;
+
+ /* And store it properly */
+ *Index = src->param_binding_begin + rel_off;
+ *IsRelOffset = 1;
+ }
+ break;
+ }
+ break;
+
+ default:
+
+ if (parse_param_use (ctx, inst, vc_head, Program, &src))
+ return 1;
+
+ *File = src->param_binding_type;
+ *Index = src->param_binding_begin;
+ break;
+ }
+ break;
+
+ case REGISTER_ESTABLISHED_NAME:
+
+ src = parse_string (inst, vc_head, Program, &found);
+ Program->Position = parse_position (inst);
+
+ /* If the name has never been added to our symbol table, we're hosed */
+ if (!found) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "3: Undefined variable");
+ _mesa_error (ctx, GL_INVALID_OPERATION, "3: Undefined variable: %s",
+ src->name);
+ return 1;
+ }
+
+ switch (src->type) {
+ case vt_attrib:
+ *File = PROGRAM_INPUT;
+ *Index = src->attrib_binding_idx;
+ break;
+
+ /* XXX: We have to handle offsets someplace in here! -- or are those above? */
+ case vt_param:
+ *File = src->param_binding_type;
+ *Index = src->param_binding_begin;
+ break;
+
+ case vt_temp:
+ *File = PROGRAM_TEMPORARY;
+ *Index = src->temp_binding;
+ break;
+
+ /* If the var type is vt_output no go */
+ default:
+ _mesa_set_program_error (ctx, Program->Position,
+ "destination register is read only");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "destination register is read only: %s",
+ src->name);
+ return 1;
+ }
+ break;
+
+ default:
+ _mesa_set_program_error (ctx, Program->Position,
+ "Unknown token in parse_src_reg");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Unknown token in parse_src_reg");
+ return 1;
+ }
+
+ return 0;
+}
+
+/**
+ */
+static GLuint
+parse_fp_vector_src_reg (GLcontext * ctx, GLubyte ** inst,
+ struct var_cache **vc_head, struct arb_program *Program,
+ struct fp_src_register *reg )
+{
+
+ GLint File;
+ GLint Index;
+ GLboolean Negate;
+ GLubyte Swizzle[4];
+ GLboolean IsRelOffset;
+
+ /* Grab the sign */
+ Negate = (parse_sign (inst) == -1) ? 0xf : 0x0;
+
+ /* And the src reg */
+ if (parse_src_reg (ctx, inst, vc_head, Program, &File, &Index, &IsRelOffset))
+ return 1;
+
+ /* finally, the swizzle */
+ parse_swizzle_mask (inst, Swizzle, 4);
+
+ reg->File = File;
+ reg->Index = Index;
+ reg->Abs = 0; /* NV only */
+ reg->NegateAbs = 0; /* NV only */
+ reg->NegateBase = Negate;
+ reg->Swizzle = (Swizzle[0] << 0 |
+ Swizzle[1] << 3 |
+ Swizzle[2] << 6 |
+ Swizzle[3] << 9);
+
+ return 0;
+}
+
+
+static GLuint
+parse_fp_dst_reg(GLcontext * ctx, GLubyte ** inst,
+ struct var_cache **vc_head, struct arb_program *Program,
+ struct fp_dst_register *reg )
+{
+ GLint file, idx, mask;
+
+ if (parse_masked_dst_reg (ctx, inst, vc_head, Program, &file, &idx, &mask))
+ return 1;
+
+ reg->CondMask = 0; /* NV only */
+ reg->CondSwizzle = 0; /* NV only */
+ reg->File = file;
+ reg->Index = idx;
+ reg->WriteMask = mask;
+ return 0;
+}
+
+
+
+static GLuint
+parse_fp_scalar_src_reg (GLcontext * ctx, GLubyte ** inst,
+ struct var_cache **vc_head, struct arb_program *Program,
+ struct fp_src_register *reg )
+{
+
+ GLint File;
+ GLint Index;
+ GLboolean Negate;
+ GLubyte Swizzle[4];
+ GLboolean IsRelOffset;
+
+ /* Grab the sign */
+ Negate = (parse_sign (inst) == -1) ? 0x1 : 0x0;
+
+ /* And the src reg */
+ if (parse_src_reg (ctx, inst, vc_head, Program, &File, &Index, &IsRelOffset))
+ return 1;
+
+ /* finally, the swizzle */
+ parse_swizzle_mask (inst, Swizzle, 1);
+
+ reg->File = File;
+ reg->Index = Index;
+ reg->Abs = 0; /* NV only */
+ reg->NegateAbs = 0; /* NV only */
+ reg->NegateBase = Negate;
+ reg->Swizzle = (Swizzle[0] << 0);
+
+ return 0;
+}
+
+
+/**
+ * This is a big mother that handles getting opcodes into the instruction
+ * and handling the src & dst registers for fragment program instructions
+ */
+static GLuint
+parse_fp_instruction (GLcontext * ctx, GLubyte ** inst,
+ struct var_cache **vc_head, struct arb_program *Program,
+ struct fp_instruction *fp)
+{
+ GLint a;
+ GLuint texcoord;
+ GLubyte instClass, type, code;
+ GLboolean rel;
+
+ /* No condition codes in ARB_fp */
+ fp->UpdateCondRegister = 0;
+
+ /* Record the position in the program string for debugging */
+ fp->StringPos = Program->Position;
+
+ fp->Data = NULL;
+
+ fp->DstReg.File = 0xf; /* mark as undef */
+ fp->SrcReg[0].File = 0xf; /* mark as undef */
+ fp->SrcReg[1].File = 0xf; /* mark as undef */
+ fp->SrcReg[2].File = 0xf; /* mark as undef */
+
+ /* OP_ALU_INST or OP_TEX_INST */
+ instClass = *(*inst)++;
+
+ /* OP_ALU_{VECTOR, SCALAR, BINSC, BIN, TRI, SWZ},
+ * OP_TEX_{SAMPLE, KIL}
+ */
+ type = *(*inst)++;
+
+ /* The actual opcode name */
+ code = *(*inst)++;
+
+ /* Increment the correct count */
+ switch (instClass) {
+ case OP_ALU_INST:
+ Program->NumAluInstructions++;
+ break;
+ case OP_TEX_INST:
+ Program->NumTexInstructions++;
+ break;
+ }
+
+ fp->Saturate = 0;
+ fp->Precision = FLOAT32;
+
+ fp->DstReg.CondMask = COND_TR;
+
+ switch (type) {
+ case OP_ALU_VECTOR:
+ switch (code) {
+ case OP_ABS_SAT:
+ fp->Saturate = 1;
+ case OP_ABS:
+ fp->Opcode = FP_OPCODE_ABS;
+ break;
+
+ case OP_FLR_SAT:
+ fp->Saturate = 1;
+ case OP_FLR:
+ fp->Opcode = FP_OPCODE_FLR;
+ break;
+
+ case OP_FRC_SAT:
+ fp->Saturate = 1;
+ case OP_FRC:
+ fp->Opcode = FP_OPCODE_FRC;
+ break;
+
+ case OP_LIT_SAT:
+ fp->Saturate = 1;
+ case OP_LIT:
+ fp->Opcode = FP_OPCODE_LIT;
+ break;
+
+ case OP_MOV_SAT:
+ fp->Saturate = 1;
+ case OP_MOV:
+ fp->Opcode = FP_OPCODE_MOV;
+ break;
+ }
+
+ if (parse_fp_dst_reg (ctx, inst, vc_head, Program, &fp->DstReg))
+ return 1;
+
+ if (parse_fp_vector_src_reg(ctx, inst, vc_head, Program, &fp->SrcReg[0]))
+ return 1;
+ break;
+
+ case OP_ALU_SCALAR:
+ switch (code) {
+ case OP_COS_SAT:
+ fp->Saturate = 1;
+ case OP_COS:
+ fp->Opcode = FP_OPCODE_COS;
+ break;
+
+ case OP_EX2_SAT:
+ fp->Saturate = 1;
+ case OP_EX2:
+ fp->Opcode = FP_OPCODE_EX2;
+ break;
+
+ case OP_LG2_SAT:
+ fp->Saturate = 1;
+ case OP_LG2:
+ fp->Opcode = FP_OPCODE_LG2;
+ break;
+
+ case OP_RCP_SAT:
+ fp->Saturate = 1;
+ case OP_RCP:
+ fp->Opcode = FP_OPCODE_RCP;
+ break;
+
+ case OP_RSQ_SAT:
+ fp->Saturate = 1;
+ case OP_RSQ:
+ fp->Opcode = FP_OPCODE_RSQ;
+ break;
+
+ case OP_SIN_SAT:
+ fp->Saturate = 1;
+ case OP_SIN:
+ fp->Opcode = FP_OPCODE_SIN;
+ break;
+
+ case OP_SCS_SAT:
+ fp->Saturate = 1;
+ case OP_SCS:
+
+ fp->Opcode = FP_OPCODE_SCS;
+ break;
+ }
+
+ if (parse_fp_dst_reg (ctx, inst, vc_head, Program, &fp->DstReg))
+ return 1;
+
+ if (parse_fp_scalar_src_reg(ctx, inst, vc_head, Program, &fp->SrcReg[0]))
+ return 1;
+ break;
+
+ case OP_ALU_BINSC:
+ switch (code) {
+ case OP_POW_SAT:
+ fp->Saturate = 1;
+ case OP_POW:
+ fp->Opcode = FP_OPCODE_POW;
+ break;
+ }
+
+ if (parse_fp_dst_reg(ctx, inst, vc_head, Program, &fp->DstReg))
+ return 1;
+
+ for (a = 0; a < 2; a++) {
+ if (parse_fp_scalar_src_reg(ctx, inst, vc_head, Program, &fp->SrcReg[a]))
+ return 1;
+ }
+ break;
+
+
+ case OP_ALU_BIN:
+ switch (code) {
+ case OP_ADD_SAT:
+ fp->Saturate = 1;
+ case OP_ADD:
+ fp->Opcode = FP_OPCODE_ADD;
+ break;
+
+ case OP_DP3_SAT:
+ fp->Saturate = 1;
+ case OP_DP3:
+ fp->Opcode = FP_OPCODE_DP3;
+ break;
+
+ case OP_DP4_SAT:
+ fp->Saturate = 1;
+ case OP_DP4:
+ fp->Opcode = FP_OPCODE_DP4;
+ break;
+
+ case OP_DPH_SAT:
+ fp->Saturate = 1;
+ case OP_DPH:
+ fp->Opcode = FP_OPCODE_DPH;
+ break;
+
+ case OP_DST_SAT:
+ fp->Saturate = 1;
+ case OP_DST:
+ fp->Opcode = FP_OPCODE_DST;
+ break;
+
+ case OP_MAX_SAT:
+ fp->Saturate = 1;
+ case OP_MAX:
+ fp->Opcode = FP_OPCODE_MAX;
+ break;
+
+ case OP_MIN_SAT:
+ fp->Saturate = 1;
+ case OP_MIN:
+ fp->Opcode = FP_OPCODE_MIN;
+ break;
+
+ case OP_MUL_SAT:
+ fp->Saturate = 1;
+ case OP_MUL:
+ fp->Opcode = FP_OPCODE_MUL;
+ break;
+
+ case OP_SGE_SAT:
+ fp->Saturate = 1;
+ case OP_SGE:
+ fp->Opcode = FP_OPCODE_SGE;
+ break;
+
+ case OP_SLT_SAT:
+ fp->Saturate = 1;
+ case OP_SLT:
+ fp->Opcode = FP_OPCODE_SLT;
+ break;
+
+ case OP_SUB_SAT:
+ fp->Saturate = 1;
+ case OP_SUB:
+ fp->Opcode = FP_OPCODE_SUB;
+ break;
+
+ case OP_XPD_SAT:
+ fp->Saturate = 1;
+ case OP_XPD:
+ fp->Opcode = FP_OPCODE_XPD;
+ break;
+ }
+
+ if (parse_fp_dst_reg (ctx, inst, vc_head, Program, &fp->DstReg))
+ return 1;
+ for (a = 0; a < 2; a++) {
+ if (parse_fp_vector_src_reg(ctx, inst, vc_head, Program, &fp->SrcReg[a]))
+ return 1;
+ }
+ break;
+
+ case OP_ALU_TRI:
+ switch (code) {
+ case OP_CMP_SAT:
+ fp->Saturate = 1;
+ case OP_CMP:
+ fp->Opcode = FP_OPCODE_CMP;
+ break;
+
+ case OP_LRP_SAT:
+ fp->Saturate = 1;
+ case OP_LRP:
+ fp->Opcode = FP_OPCODE_LRP;
+ break;
+
+ case OP_MAD_SAT:
+ fp->Saturate = 1;
+ case OP_MAD:
+ fp->Opcode = FP_OPCODE_MAD;
+ break;
+ }
+
+ if (parse_fp_dst_reg (ctx, inst, vc_head, Program, &fp->DstReg))
+ return 1;
+
+ for (a = 0; a < 3; a++) {
+ if (parse_fp_vector_src_reg(ctx, inst, vc_head, Program, &fp->SrcReg[a]))
+ return 1;
+ }
+ break;
+
+ case OP_ALU_SWZ:
+ switch (code) {
+ case OP_SWZ_SAT:
+ fp->Saturate = 1;
+ case OP_SWZ:
+ fp->Opcode = FP_OPCODE_SWZ;
+ break;
+ }
+ if (parse_fp_dst_reg (ctx, inst, vc_head, Program, &fp->DstReg))
+ return 1;
+
+ {
+ GLubyte Swizzle[4]; /* FP's swizzle mask is a GLubyte, while VP's is GLuint */
+ GLubyte negateMask;
+ GLint File, Index;
+
+ if (parse_src_reg(ctx, inst, vc_head, Program, &File, &Index, &rel))
+ return 1;
+ parse_extended_swizzle_mask (inst, Swizzle, &negateMask);
+ fp->SrcReg[0].File = File;
+ fp->SrcReg[0].Index = Index;
+ fp->SrcReg[0].NegateBase = negateMask;
+ fp->SrcReg[0].Swizzle = (Swizzle[0] << 0 |
+ Swizzle[1] << 3 |
+ Swizzle[2] << 6 |
+ Swizzle[3] << 9);
+ }
+ break;
+
+ case OP_TEX_SAMPLE:
+ switch (code) {
+ case OP_TEX_SAT:
+ fp->Saturate = 1;
+ case OP_TEX:
+ fp->Opcode = FP_OPCODE_TEX;
+ break;
+
+ case OP_TXP_SAT:
+ fp->Saturate = 1;
+ case OP_TXP:
+ fp->Opcode = FP_OPCODE_TXP;
+ break;
+
+ case OP_TXB_SAT:
+ fp->Saturate = 1;
+ case OP_TXB:
+ fp->Opcode = FP_OPCODE_TXB;
+ break;
+ }
+
+ if (parse_fp_dst_reg (ctx, inst, vc_head, Program, &fp->DstReg))
+ return 1;
+
+ if (parse_fp_vector_src_reg(ctx, inst, vc_head, Program, &fp->SrcReg[0]))
+ return 1;
+
+ /* texImageUnit */
+ if (parse_texcoord_num (ctx, inst, Program, &texcoord))
+ return 1;
+ fp->TexSrcUnit = texcoord;
+
+ /* texTarget */
+ switch (*(*inst)++) {
+ case TEXTARGET_1D:
+ fp->TexSrcIdx = TEXTURE_1D_INDEX;
+ break;
+ case TEXTARGET_2D:
+ fp->TexSrcIdx = TEXTURE_2D_INDEX;
+ break;
+ case TEXTARGET_3D:
+ fp->TexSrcIdx = TEXTURE_3D_INDEX;
+ break;
+ case TEXTARGET_RECT:
+ fp->TexSrcIdx = TEXTURE_RECT_INDEX;
+ break;
+ case TEXTARGET_CUBE:
+ fp->TexSrcIdx = TEXTURE_CUBE_INDEX;
+ break;
+ case TEXTARGET_SHADOW1D:
+ case TEXTARGET_SHADOW2D:
+ case TEXTARGET_SHADOWRECT:
+ /* TODO ARB_fragment_program_shadow code */
+ break;
+ }
+ Program->TexturesUsed[texcoord] |= (1<<fp->TexSrcIdx);
+ break;
+
+ case OP_TEX_KIL:
+ if (parse_fp_vector_src_reg(ctx, inst, vc_head, Program, &fp->SrcReg[0]))
+ return 1;
+ fp->Opcode = FP_OPCODE_KIL;
+ break;
+ }
+
+ return 0;
+}
+
+static GLuint
+parse_vp_dst_reg(GLcontext * ctx, GLubyte ** inst,
+ struct var_cache **vc_head, struct arb_program *Program,
+ struct vp_dst_register *reg )
+{
+ GLint file, idx, mask;
+
+ if (parse_masked_dst_reg(ctx, inst, vc_head, Program, &file, &idx, &mask))
+ return 1;
+
+ reg->File = file;
+ reg->Index = idx;
+ reg->WriteMask = mask;
+ return 0;
+}
+
+/**
+ * Handle the parsing out of a masked address register
+ *
+ * \param Index - The register index we write to
+ * \param WriteMask - The mask controlling which components we write (1->write)
+ *
+ * \return 0 on sucess, 1 on error
+ */
+static GLuint
+parse_vp_address_reg (GLcontext * ctx, GLubyte ** inst,
+ struct var_cache **vc_head,
+ struct arb_program *Program,
+ struct vp_dst_register *reg)
+{
+ GLint idx;
+
+ if (parse_address_reg (ctx, inst, vc_head, Program, &idx))
+ return 1;
+
+ /* This should be 0x8 */
+ (*inst)++;
+
+ reg->File = PROGRAM_ADDRESS;
+ reg->Index = idx;
+
+ /* Writemask of .x is implied */
+ reg->WriteMask = 0x1;
+ return 0;
+}
+
+/**
+ */
+static GLuint
+parse_vp_vector_src_reg (GLcontext * ctx, GLubyte ** inst,
+ struct var_cache **vc_head, struct arb_program *Program,
+ struct vp_src_register *reg )
+{
+
+ GLint File;
+ GLint Index;
+ GLboolean Negate;
+ GLubyte Swizzle[4];
+ GLboolean IsRelOffset;
+
+ /* Grab the sign */
+ Negate = (parse_sign (inst) == -1) ? 0xf : 0x0;
+
+ /* And the src reg */
+ if (parse_src_reg (ctx, inst, vc_head, Program, &File, &Index, &IsRelOffset))
+ return 1;
+
+ /* finally, the swizzle */
+ parse_swizzle_mask (inst, Swizzle, 4);
+
+ reg->File = File;
+ reg->Index = Index;
+ reg->Swizzle = ((Swizzle[0] << 0) |
+ (Swizzle[1] << 3) |
+ (Swizzle[2] << 6) |
+ (Swizzle[3] << 9));
+ reg->Negate = Negate;
+ reg->RelAddr = IsRelOffset;
+ return 0;
+}
+
+
+static GLuint
+parse_vp_scalar_src_reg (GLcontext * ctx, GLubyte ** inst,
+ struct var_cache **vc_head, struct arb_program *Program,
+ struct vp_src_register *reg )
+{
+
+ GLint File;
+ GLint Index;
+ GLboolean Negate;
+ GLubyte Swizzle[4];
+ GLboolean IsRelOffset;
+
+ /* Grab the sign */
+ Negate = (parse_sign (inst) == -1) ? 0x1 : 0x0;
+
+ /* And the src reg */
+ if (parse_src_reg (ctx, inst, vc_head, Program, &File, &Index, &IsRelOffset))
+ return 1;
+
+ /* finally, the swizzle */
+ parse_swizzle_mask (inst, Swizzle, 1);
+
+ reg->File = File;
+ reg->Index = Index;
+ reg->Swizzle = (Swizzle[0] << 0);
+ reg->Negate = Negate;
+ reg->RelAddr = IsRelOffset;
+ return 0;
+}
+
+
+/**
+ * This is a big mother that handles getting opcodes into the instruction
+ * and handling the src & dst registers for vertex program instructions
+ */
+static GLuint
+parse_vp_instruction (GLcontext * ctx, GLubyte ** inst,
+ struct var_cache **vc_head, struct arb_program *Program,
+ struct vp_instruction *vp)
+{
+ GLint a;
+ GLubyte type, code;
+
+ /* OP_ALU_{ARL, VECTOR, SCALAR, BINSC, BIN, TRI, SWZ} */
+ type = *(*inst)++;
+
+ /* The actual opcode name */
+ code = *(*inst)++;
+
+ /* Record the position in the program string for debugging */
+ vp->StringPos = Program->Position;
+ vp->Data = NULL;
+ vp->SrcReg[0].RelAddr = vp->SrcReg[1].RelAddr = vp->SrcReg[2].RelAddr = 0;
+ vp->SrcReg[0].Swizzle = SWIZZLE_NOOP;
+ vp->SrcReg[1].Swizzle = SWIZZLE_NOOP;
+ vp->SrcReg[2].Swizzle = SWIZZLE_NOOP;
+ vp->SrcReg[3].Swizzle = SWIZZLE_NOOP;
+ vp->DstReg.WriteMask = 0xf;
+
+ switch (type) {
+ /* XXX: */
+ case OP_ALU_ARL:
+ vp->Opcode = VP_OPCODE_ARL;
+
+ /* Remember to set SrcReg.RelAddr; */
+
+ /* Get the masked address register [dst] */
+ if (parse_vp_address_reg(ctx, inst, vc_head, Program, &vp->DstReg))
+ return 1;
+
+ vp->DstReg.File = PROGRAM_ADDRESS;
+
+ /* Get a scalar src register */
+ if (parse_vp_scalar_src_reg(ctx, inst, vc_head, Program, &vp->SrcReg[0]))
+ return 1;
+
+ break;
+
+ case OP_ALU_VECTOR:
+ switch (code) {
+ case OP_ABS:
+ vp->Opcode = VP_OPCODE_ABS;
+ break;
+ case OP_FLR:
+ vp->Opcode = VP_OPCODE_FLR;
+ break;
+ case OP_FRC:
+ vp->Opcode = VP_OPCODE_FRC;
+ break;
+ case OP_LIT:
+ vp->Opcode = VP_OPCODE_LIT;
+ break;
+ case OP_MOV:
+ vp->Opcode = VP_OPCODE_MOV;
+ break;
+ }
+
+ if (parse_vp_dst_reg(ctx, inst, vc_head, Program, &vp->DstReg))
+ return 1;
+
+ if (parse_vp_vector_src_reg(ctx, inst, vc_head, Program, &vp->SrcReg[0]))
+ return 1;
+ break;
+
+ case OP_ALU_SCALAR:
+ switch (code) {
+ case OP_EX2:
+ vp->Opcode = VP_OPCODE_EX2;
+ break;
+ case OP_EXP:
+ vp->Opcode = VP_OPCODE_EXP;
+ break;
+ case OP_LG2:
+ vp->Opcode = VP_OPCODE_LG2;
+ break;
+ case OP_LOG:
+ vp->Opcode = VP_OPCODE_LOG;
+ break;
+ case OP_RCP:
+ vp->Opcode = VP_OPCODE_RCP;
+ break;
+ case OP_RSQ:
+ vp->Opcode = VP_OPCODE_RSQ;
+ break;
+ }
+ if (parse_vp_dst_reg(ctx, inst, vc_head, Program, &vp->DstReg))
+ return 1;
+
+ if (parse_vp_scalar_src_reg(ctx, inst, vc_head, Program, &vp->SrcReg[0]))
+ return 1;
+ break;
+
+ case OP_ALU_BINSC:
+ switch (code) {
+ case OP_POW:
+ vp->Opcode = VP_OPCODE_POW;
+ break;
+ }
+ if (parse_vp_dst_reg(ctx, inst, vc_head, Program, &vp->DstReg))
+ return 1;
+
+ for (a = 0; a < 2; a++) {
+ if (parse_vp_scalar_src_reg(ctx, inst, vc_head, Program, &vp->SrcReg[a]))
+ return 1;
+ }
+ break;
+
+ case OP_ALU_BIN:
+ switch (code) {
+ case OP_ADD:
+ vp->Opcode = VP_OPCODE_ADD;
+ break;
+ case OP_DP3:
+ vp->Opcode = VP_OPCODE_DP3;
+ break;
+ case OP_DP4:
+ vp->Opcode = VP_OPCODE_DP4;
+ break;
+ case OP_DPH:
+ vp->Opcode = VP_OPCODE_DPH;
+ break;
+ case OP_DST:
+ vp->Opcode = VP_OPCODE_DST;
+ break;
+ case OP_MAX:
+ vp->Opcode = VP_OPCODE_MAX;
+ break;
+ case OP_MIN:
+ vp->Opcode = VP_OPCODE_MIN;
+ break;
+ case OP_MUL:
+ vp->Opcode = VP_OPCODE_MUL;
+ break;
+ case OP_SGE:
+ vp->Opcode = VP_OPCODE_SGE;
+ break;
+ case OP_SLT:
+ vp->Opcode = VP_OPCODE_SLT;
+ break;
+ case OP_SUB:
+ vp->Opcode = VP_OPCODE_SUB;
+ break;
+ case OP_XPD:
+ vp->Opcode = VP_OPCODE_XPD;
+ break;
+ }
+ if (parse_vp_dst_reg(ctx, inst, vc_head, Program, &vp->DstReg))
+ return 1;
+
+ for (a = 0; a < 2; a++) {
+ if (parse_vp_vector_src_reg(ctx, inst, vc_head, Program, &vp->SrcReg[a]))
+ return 1;
+ }
+ break;
+
+ case OP_ALU_TRI:
+ switch (code) {
+ case OP_MAD:
+ vp->Opcode = VP_OPCODE_MAD;
+ break;
+ }
+
+ if (parse_vp_dst_reg(ctx, inst, vc_head, Program, &vp->DstReg))
+ return 1;
+
+ for (a = 0; a < 3; a++) {
+ if (parse_vp_vector_src_reg(ctx, inst, vc_head, Program, &vp->SrcReg[a]))
+ return 1;
+ }
+ break;
+
+ case OP_ALU_SWZ:
+ switch (code) {
+ case OP_SWZ:
+ vp->Opcode = VP_OPCODE_SWZ;
+ break;
+ }
+ {
+ GLubyte Swizzle[4]; /* FP's swizzle mask is a GLubyte, while VP's is GLuint */
+ GLubyte Negate[4];
+ GLboolean RelAddr;
+ GLint File, Index;
+
+ if (parse_vp_dst_reg(ctx, inst, vc_head, Program, &vp->DstReg))
+ return 1;
+
+ if (parse_src_reg(ctx, inst, vc_head, Program, &File, &Index, &RelAddr))
+ return 1;
+ parse_extended_swizzle_mask (inst, Swizzle, Negate);
+ vp->SrcReg[0].File = File;
+ vp->SrcReg[0].Index = Index;
+ vp->SrcReg[0].Negate = (Negate[0] << 0 |
+ Negate[1] << 1 |
+ Negate[2] << 2 |
+ Negate[3] << 3);
+ vp->SrcReg[0].Swizzle = (Swizzle[0] << 0 |
+ Swizzle[1] << 3 |
+ Swizzle[2] << 6 |
+ Swizzle[3] << 9);
+ vp->SrcReg[0].RelAddr = RelAddr;
+ }
+ break;
+ }
+ return 0;
+}
+
+#if DEBUG_PARSING
+
+static GLvoid
+print_state_token (GLint token)
+{
+ switch (token) {
+ case STATE_MATERIAL:
+ fprintf (stderr, "STATE_MATERIAL ");
+ break;
+ case STATE_LIGHT:
+ fprintf (stderr, "STATE_LIGHT ");
+ break;
+
+ case STATE_LIGHTMODEL_AMBIENT:
+ fprintf (stderr, "STATE_AMBIENT ");
+ break;
+
+ case STATE_LIGHTMODEL_SCENECOLOR:
+ fprintf (stderr, "STATE_SCENECOLOR ");
+ break;
+
+ case STATE_LIGHTPROD:
+ fprintf (stderr, "STATE_LIGHTPROD ");
+ break;
+
+ case STATE_TEXGEN:
+ fprintf (stderr, "STATE_TEXGEN ");
+ break;
+
+ case STATE_FOG_COLOR:
+ fprintf (stderr, "STATE_FOG_COLOR ");
+ break;
+
+ case STATE_FOG_PARAMS:
+ fprintf (stderr, "STATE_FOG_PARAMS ");
+ break;
+
+ case STATE_CLIPPLANE:
+ fprintf (stderr, "STATE_CLIPPLANE ");
+ break;
+
+ case STATE_POINT_SIZE:
+ fprintf (stderr, "STATE_POINT_SIZE ");
+ break;
+
+ case STATE_POINT_ATTENUATION:
+ fprintf (stderr, "STATE_ATTENUATION ");
+ break;
+
+ case STATE_MATRIX:
+ fprintf (stderr, "STATE_MATRIX ");
+ break;
+
+ case STATE_MODELVIEW:
+ fprintf (stderr, "STATE_MODELVIEW ");
+ break;
+
+ case STATE_PROJECTION:
+ fprintf (stderr, "STATE_PROJECTION ");
+ break;
+
+ case STATE_MVP:
+ fprintf (stderr, "STATE_MVP ");
+ break;
+
+ case STATE_TEXTURE:
+ fprintf (stderr, "STATE_TEXTURE ");
+ break;
+
+ case STATE_PROGRAM:
+ fprintf (stderr, "STATE_PROGRAM ");
+ break;
+
+ case STATE_MATRIX_INVERSE:
+ fprintf (stderr, "STATE_INVERSE ");
+ break;
+
+ case STATE_MATRIX_TRANSPOSE:
+ fprintf (stderr, "STATE_TRANSPOSE ");
+ break;
+
+ case STATE_MATRIX_INVTRANS:
+ fprintf (stderr, "STATE_INVTRANS ");
+ break;
+
+ case STATE_AMBIENT:
+ fprintf (stderr, "STATE_AMBIENT ");
+ break;
+
+ case STATE_DIFFUSE:
+ fprintf (stderr, "STATE_DIFFUSE ");
+ break;
+
+ case STATE_SPECULAR:
+ fprintf (stderr, "STATE_SPECULAR ");
+ break;
+
+ case STATE_EMISSION:
+ fprintf (stderr, "STATE_EMISSION ");
+ break;
+
+ case STATE_SHININESS:
+ fprintf (stderr, "STATE_SHININESS ");
+ break;
+
+ case STATE_HALF:
+ fprintf (stderr, "STATE_HALF ");
+ break;
+
+ case STATE_POSITION:
+ fprintf (stderr, "STATE_POSITION ");
+ break;
+
+ case STATE_ATTENUATION:
+ fprintf (stderr, "STATE_ATTENUATION ");
+ break;
+
+ case STATE_SPOT_DIRECTION:
+ fprintf (stderr, "STATE_DIRECTION ");
+ break;
+
+ case STATE_TEXGEN_EYE_S:
+ fprintf (stderr, "STATE_TEXGEN_EYE_S ");
+ break;
+
+ case STATE_TEXGEN_EYE_T:
+ fprintf (stderr, "STATE_TEXGEN_EYE_T ");
+ break;
+
+ case STATE_TEXGEN_EYE_R:
+ fprintf (stderr, "STATE_TEXGEN_EYE_R ");
+ break;
+
+ case STATE_TEXGEN_EYE_Q:
+ fprintf (stderr, "STATE_TEXGEN_EYE_Q ");
+ break;
+
+ case STATE_TEXGEN_OBJECT_S:
+ fprintf (stderr, "STATE_TEXGEN_EYE_S ");
+ break;
+
+ case STATE_TEXGEN_OBJECT_T:
+ fprintf (stderr, "STATE_TEXGEN_OBJECT_T ");
+ break;
+
+ case STATE_TEXGEN_OBJECT_R:
+ fprintf (stderr, "STATE_TEXGEN_OBJECT_R ");
+ break;
+
+ case STATE_TEXGEN_OBJECT_Q:
+ fprintf (stderr, "STATE_TEXGEN_OBJECT_Q ");
+ break;
+
+ case STATE_TEXENV_COLOR:
+ fprintf (stderr, "STATE_TEXENV_COLOR ");
+ break;
+
+ case STATE_DEPTH_RANGE:
+ fprintf (stderr, "STATE_DEPTH_RANGE ");
+ break;
+
+ case STATE_VERTEX_PROGRAM:
+ fprintf (stderr, "STATE_VERTEX_PROGRAM ");
+ break;
+
+ case STATE_FRAGMENT_PROGRAM:
+ fprintf (stderr, "STATE_FRAGMENT_PROGRAM ");
+ break;
+
+ case STATE_ENV:
+ fprintf (stderr, "STATE_ENV ");
+ break;
+
+ case STATE_LOCAL:
+ fprintf (stderr, "STATE_LOCAL ");
+ break;
+
+ }
+ fprintf (stderr, "[%d] ", token);
+}
+
+
+static GLvoid
+debug_variables (GLcontext * ctx, struct var_cache *vc_head,
+ struct arb_program *Program)
+{
+ struct var_cache *vc;
+ GLint a, b;
+
+ fprintf (stderr, "debug_variables, vc_head: %x\n", vc_head);
+
+ /* First of all, print out the contents of the var_cache */
+ vc = vc_head;
+ while (vc) {
+ fprintf (stderr, "[%x]\n", vc);
+ switch (vc->type) {
+ case vt_none:
+ fprintf (stderr, "UNDEFINED %s\n", vc->name);
+ break;
+ case vt_attrib:
+ fprintf (stderr, "ATTRIB %s\n", vc->name);
+ fprintf (stderr, " binding: 0x%x\n", vc->attrib_binding);
+ break;
+ case vt_param:
+ fprintf (stderr, "PARAM %s begin: %d len: %d\n", vc->name,
+ vc->param_binding_begin, vc->param_binding_length);
+ b = vc->param_binding_begin;
+ for (a = 0; a < vc->param_binding_length; a++) {
+ fprintf (stderr, "%s\n",
+ Program->Parameters->Parameters[a + b].Name);
+ if (Program->Parameters->Parameters[a + b].Type == STATE) {
+ print_state_token (Program->Parameters->Parameters[a + b].
+ StateIndexes[0]);
+ print_state_token (Program->Parameters->Parameters[a + b].
+ StateIndexes[1]);
+ print_state_token (Program->Parameters->Parameters[a + b].
+ StateIndexes[2]);
+ print_state_token (Program->Parameters->Parameters[a + b].
+ StateIndexes[3]);
+ print_state_token (Program->Parameters->Parameters[a + b].
+ StateIndexes[4]);
+ print_state_token (Program->Parameters->Parameters[a + b].
+ StateIndexes[5]);
+ }
+ else
+ fprintf (stderr, "%f %f %f %f\n",
+ Program->Parameters->Parameters[a + b].Values[0],
+ Program->Parameters->Parameters[a + b].Values[1],
+ Program->Parameters->Parameters[a + b].Values[2],
+ Program->Parameters->Parameters[a + b].Values[3]);
+ }
+ break;
+ case vt_temp:
+ fprintf (stderr, "TEMP %s\n", vc->name);
+ fprintf (stderr, " binding: 0x%x\n", vc->temp_binding);
+ break;
+ case vt_output:
+ fprintf (stderr, "OUTPUT %s\n", vc->name);
+ fprintf (stderr, " binding: 0x%x\n", vc->output_binding);
+ break;
+ case vt_alias:
+ fprintf (stderr, "ALIAS %s\n", vc->name);
+ fprintf (stderr, " binding: 0x%x (%s)\n",
+ vc->alias_binding, vc->alias_binding->name);
+ break;
+ }
+ vc = vc->next;
+ }
+}
+
+#endif
+
+
+/**
+ * The main loop for parsing a fragment or vertex program
+ *
+ * \return GL_TRUE on success, GL_FALSE on error.
+ */
+static GLboolean
+parse_arb_program(GLcontext * ctx, GLubyte * inst, struct var_cache **vc_head,
+ struct arb_program *Program)
+{
+ GLint err = 0;
+
+ Program->MajorVersion = (GLuint) * inst++;
+ Program->MinorVersion = (GLuint) * inst++;
+
+ while (*inst != END) {
+ switch (*inst++) {
+
+ case OPTION:
+ switch (*inst++) {
+ case ARB_PRECISION_HINT_FASTEST:
+ Program->PrecisionOption = GL_FASTEST;
+ break;
+
+ case ARB_PRECISION_HINT_NICEST:
+ Program->PrecisionOption = GL_NICEST;
+ break;
+
+ case ARB_FOG_EXP:
+ Program->FogOption = GL_EXP;
+ break;
+
+ case ARB_FOG_EXP2:
+ Program->FogOption = GL_EXP2;
+ break;
+
+ case ARB_FOG_LINEAR:
+ Program->FogOption = GL_LINEAR;
+ break;
+
+ case ARB_POSITION_INVARIANT:
+ if (Program->Base.Target == GL_VERTEX_PROGRAM_ARB)
+ Program->HintPositionInvariant = 1;
+ break;
+
+ case ARB_FRAGMENT_PROGRAM_SHADOW:
+ if (Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) {
+ /* TODO ARB_fragment_program_shadow code */
+ }
+ break;
+
+ case ARB_DRAW_BUFFERS:
+ if (Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) {
+ /* do nothing for now */
+ }
+ break;
+ }
+ break;
+
+ case INSTRUCTION:
+ Program->Position = parse_position (&inst);
+
+ if (Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) {
+
+ /* Check the instruction count
+ * XXX: Does END count as an instruction?
+ */
+ if (Program->Base.NumInstructions+1 == MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Max instruction count exceeded!");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Max instruction count exceeded!");
+ }
+
+ /* Realloc Program->FPInstructions */
+ Program->FPInstructions =
+ (struct fp_instruction *) _mesa_realloc (Program->FPInstructions,
+ Program->Base.NumInstructions*sizeof(struct fp_instruction),
+ (Program->Base.NumInstructions+1)*sizeof (struct fp_instruction));
+
+ /* parse the current instruction */
+ err = parse_fp_instruction (ctx, &inst, vc_head, Program,
+ &Program->FPInstructions[Program->Base.NumInstructions]);
+
+ }
+ else {
+ /* Check the instruction count
+ * XXX: Does END count as an instruction?
+ */
+ if (Program->Base.NumInstructions+1 == MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS) {
+ _mesa_set_program_error (ctx, Program->Position,
+ "Max instruction count exceeded!");
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Max instruction count exceeded!");
+ }
+
+ /* Realloc Program->VPInstructions */
+ Program->VPInstructions =
+ (struct vp_instruction *) _mesa_realloc (Program->VPInstructions,
+ Program->Base.NumInstructions*sizeof(struct vp_instruction),
+ (Program->Base.NumInstructions +1)*sizeof(struct vp_instruction));
+
+ /* parse the current instruction */
+ err = parse_vp_instruction (ctx, &inst, vc_head, Program,
+ &Program->VPInstructions[Program->Base.NumInstructions]);
+ }
+
+ /* increment Program->Base.NumInstructions */
+ Program->Base.NumInstructions++;
+ break;
+
+ case DECLARATION:
+ err = parse_declaration (ctx, &inst, vc_head, Program);
+ break;
+
+ default:
+ break;
+ }
+
+ if (err)
+ break;
+ }
+
+ /* Finally, tag on an OPCODE_END instruction */
+ if (Program->Base.Target == GL_FRAGMENT_PROGRAM_ARB) {
+ Program->FPInstructions =
+ (struct fp_instruction *) _mesa_realloc (Program->FPInstructions,
+ Program->Base.NumInstructions*sizeof(struct fp_instruction),
+ (Program->Base.NumInstructions+1)*sizeof(struct fp_instruction));
+
+ Program->FPInstructions[Program->Base.NumInstructions].Opcode = FP_OPCODE_END;
+ Program->FPInstructions[Program->Base.NumInstructions].Saturate = 0;
+ Program->FPInstructions[Program->Base.NumInstructions].DstReg.File = 0xf;
+ Program->FPInstructions[Program->Base.NumInstructions].SrcReg[0].File = 0xf;
+ Program->FPInstructions[Program->Base.NumInstructions].SrcReg[1].File = 0xf;
+ Program->FPInstructions[Program->Base.NumInstructions].SrcReg[2].File = 0xf;
+ /* YYY Wrong Position in program, whatever, at least not random -> crash
+ Program->Position = parse_position (&inst);
+ */
+ Program->FPInstructions[Program->Base.NumInstructions].StringPos = Program->Position;
+ Program->FPInstructions[Program->Base.NumInstructions].Data = NULL;
+ }
+ else {
+ Program->VPInstructions =
+ (struct vp_instruction *) _mesa_realloc (Program->VPInstructions,
+ Program->Base.NumInstructions*sizeof(struct vp_instruction),
+ (Program->Base.NumInstructions+1)*sizeof(struct vp_instruction));
+
+ Program->VPInstructions[Program->Base.NumInstructions].Opcode = VP_OPCODE_END;
+ /* YYY Wrong Position in program, whatever, at least not random -> crash
+ Program->Position = parse_position (&inst);
+ */
+ Program->VPInstructions[Program->Base.NumInstructions].StringPos = Program->Position;
+ Program->VPInstructions[Program->Base.NumInstructions].Data = NULL;
+ }
+
+ /* increment Program->Base.NumInstructions */
+ Program->Base.NumInstructions++;
+
+ return err;
+}
+
+/* XXX temporary */
+__extension__ static char core_grammar_text[] =
+#include "grammar_syn.h"
+;
+
+static int set_reg8 (GLcontext *ctx, grammar id, const byte *name, byte value)
+{
+ char error_msg[300];
+ GLint error_pos;
+
+ if (grammar_set_reg8 (id, name, value))
+ return 0;
+
+ grammar_get_last_error ((byte *) error_msg, 300, &error_pos);
+ _mesa_set_program_error (ctx, error_pos, error_msg);
+ _mesa_error (ctx, GL_INVALID_OPERATION, "Grammar Register Error");
+ return 1;
+}
+
+static int extension_is_supported (const GLubyte *ext)
+{
+ const GLubyte *extensions = CALL_GetString(GET_DISPATCH(), (GL_EXTENSIONS));
+ const GLubyte *end = extensions + _mesa_strlen ((const char *) extensions);
+ const GLint ext_len = (GLint)_mesa_strlen ((const char *) ext);
+
+ while (extensions < end)
+ {
+ const GLubyte *name_end = (const GLubyte *) strchr ((const char *) extensions, ' ');
+ if (name_end == NULL)
+ name_end = end;
+ if (name_end - extensions == ext_len && _mesa_strncmp ((const char *) ext,
+ (const char *) extensions, ext_len) == 0)
+ return 1;
+ extensions = name_end + 1;
+ }
+
+ return 0;
+}
+
+static int enable_ext (GLcontext *ctx, grammar id, const byte *name, const byte *extname)
+{
+ if (extension_is_supported (extname))
+ if (set_reg8 (ctx, id, name, 0x01))
+ return 1;
+ return 0;
+}
+
+/**
+ * This kicks everything off.
+ *
+ * \param ctx - The GL Context
+ * \param str - The program string
+ * \param len - The program string length
+ * \param program - The arb_program struct to return all the parsed info in
+ * \return GL_TRUE on sucess, GL_FALSE on error
+ */
+GLboolean
+_mesa_parse_arb_program (GLcontext * ctx, const GLubyte * str, GLsizei len,
+ struct arb_program * program)
+{
+ GLint a, err, error_pos;
+ char error_msg[300];
+ GLuint parsed_len;
+ struct var_cache *vc_head;
+ grammar arbprogram_syn_id;
+ GLubyte *parsed, *inst;
+ GLubyte *strz = NULL;
+ static int arbprogram_syn_is_ok = 0; /* XXX temporary */
+
+ /* Reset error state */
+ _mesa_set_program_error(ctx, -1, NULL);
+
+#if DEBUG_PARSING
+ fprintf (stderr, "Loading grammar text!\n");
+#endif
+
+ /* check if the arb_grammar_text (arbprogram.syn) is syntactically correct */
+ if (!arbprogram_syn_is_ok) {
+ grammar grammar_syn_id;
+ GLint err;
+ GLuint parsed_len;
+ byte *parsed;
+
+ grammar_syn_id = grammar_load_from_text ((byte *) core_grammar_text);
+ if (grammar_syn_id == 0) {
+ grammar_get_last_error ((byte *) error_msg, 300, &error_pos);
+ _mesa_set_program_error (ctx, error_pos, error_msg);
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Error loading grammar rule set");
+ return GL_FALSE;
+ }
+
+ err = grammar_check (grammar_syn_id, (byte *) arb_grammar_text, &parsed, &parsed_len);
+
+ /* NOTE: we can't destroy grammar_syn_id right here because
+ * grammar_destroy() can reset the last error
+ */
+ if (err == 0) {
+ grammar_get_last_error ((byte *) error_msg, 300, &error_pos);
+ _mesa_set_program_error (ctx, error_pos, error_msg);
+ _mesa_error (ctx, GL_INVALID_OPERATION, "Error loading grammar rule set");
+
+ grammar_destroy (grammar_syn_id);
+ return GL_FALSE;
+ }
+
+ grammar_destroy (grammar_syn_id);
+
+ arbprogram_syn_is_ok = 1;
+ }
+
+ /* create the grammar object */
+ arbprogram_syn_id = grammar_load_from_text ((byte *) arb_grammar_text);
+ if (arbprogram_syn_id == 0) {
+ grammar_get_last_error ((GLubyte *) error_msg, 300, &error_pos);
+ _mesa_set_program_error (ctx, error_pos, error_msg);
+ _mesa_error (ctx, GL_INVALID_OPERATION,
+ "Error loading grammer rule set");
+ return GL_FALSE;
+ }
+
+ /* Set program_target register value */
+ if (set_reg8 (ctx, arbprogram_syn_id, (byte *) "program_target",
+ program->Base.Target == GL_FRAGMENT_PROGRAM_ARB ? 0x10 : 0x20)) {
+ grammar_destroy (arbprogram_syn_id);
+ return GL_FALSE;
+ }
+
+ /* Enable all active extensions */
+ if (enable_ext (ctx, arbprogram_syn_id,
+ (byte *) "vertex_blend", (byte *) "GL_ARB_vertex_blend") ||
+ enable_ext (ctx, arbprogram_syn_id,
+ (byte *) "vertex_blend", (byte *) "GL_EXT_vertex_weighting") ||
+ enable_ext (ctx, arbprogram_syn_id,
+ (byte *) "matrix_palette", (byte *) "GL_ARB_matrix_palette") ||
+ enable_ext (ctx, arbprogram_syn_id,
+ (byte *) "point_parameters", (byte *) "GL_ARB_point_parameters") ||
+ enable_ext (ctx, arbprogram_syn_id,
+ (byte *) "point_parameters", (byte *) "GL_EXT_point_parameters") ||
+ enable_ext (ctx, arbprogram_syn_id,
+ (byte *) "secondary_color", (byte *) "GL_EXT_secondary_color") ||
+ enable_ext (ctx, arbprogram_syn_id,
+ (byte *) "fog_coord", (byte *) "GL_EXT_fog_coord") ||
+ enable_ext (ctx, arbprogram_syn_id,
+ (byte *) "texture_rectangle", (byte *) "GL_ARB_texture_rectangle") ||
+ enable_ext (ctx, arbprogram_syn_id,
+ (byte *) "texture_rectangle", (byte *) "GL_EXT_texture_rectangle") ||
+ enable_ext (ctx, arbprogram_syn_id,
+ (byte *) "texture_rectangle", (byte *) "GL_NV_texture_rectangle") ||
+ enable_ext (ctx, arbprogram_syn_id,
+ (byte *) "fragment_program_shadow", (byte *) "GL_ARB_fragment_program_shadow") ||
+ enable_ext (ctx, arbprogram_syn_id,
+ (byte *) "draw_buffers", (byte *) "GL_ARB_draw_buffers")) {
+ grammar_destroy (arbprogram_syn_id);
+ return GL_FALSE;
+ }
+
+ /* check for NULL character occurences */
+ {
+ int i;
+ for (i = 0; i < len; i++)
+ if (str[i] == '\0') {
+ _mesa_set_program_error (ctx, i, "invalid character");
+ _mesa_error (ctx, GL_INVALID_OPERATION, "Lexical Error");
+
+ grammar_destroy (arbprogram_syn_id);
+ return GL_FALSE;
+ }
+ }
+
+ /* copy the program string to a null-terminated string */
+ strz = (GLubyte *) _mesa_malloc (len + 1);
+ if (!strz) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glprogramStringARB");
+ return GL_FALSE;
+ }
+ _mesa_memcpy (strz, str, len);
+ strz[len] = '\0';
+
+#if DEBUG_PARSING
+ printf ("Checking Grammar!\n");
+#endif
+ /* do a fast check on program string - initial production buffer is 4K */
+ err = grammar_fast_check (arbprogram_syn_id, strz, &parsed, &parsed_len, 0x1000);
+
+ /* Syntax parse error */
+ if (err == 0) {
+ _mesa_free (strz);
+ grammar_get_last_error ((GLubyte *) error_msg, 300, &error_pos);
+ _mesa_set_program_error (ctx, error_pos, error_msg);
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glProgramStringARB(syntax error)");
+
+ /* useful for debugging */
+ if (0) {
+ int line, col;
+ char *s;
+ printf("Program: %s\n", (char *) strz);
+ printf("Error Pos: %d\n", ctx->Program.ErrorPos);
+ s = (char *) _mesa_find_line_column(strz, strz+ctx->Program.ErrorPos, &line, &col);
+ printf("line %d col %d: %s\n", line, col, s);
+ }
+
+ grammar_destroy (arbprogram_syn_id);
+ return 1;
+ }
+
+#if DEBUG_PARSING
+ printf ("Destroying grammer dict [parse retval: %d]\n", err);
+#endif
+ grammar_destroy (arbprogram_syn_id);
+
+ /* Initialize the arb_program struct */
+ program->Base.String = strz;
+ program->Base.NumInstructions =
+ program->Base.NumTemporaries =
+ program->Base.NumParameters =
+ program->Base.NumAttributes = program->Base.NumAddressRegs = 0;
+ program->Parameters = _mesa_new_parameter_list ();
+ program->InputsRead = 0;
+ program->OutputsWritten = 0;
+ program->Position = 0;
+ program->MajorVersion = program->MinorVersion = 0;
+ program->PrecisionOption = GL_DONT_CARE;
+ program->FogOption = GL_NONE;
+ program->HintPositionInvariant = GL_FALSE;
+ for (a = 0; a < MAX_TEXTURE_IMAGE_UNITS; a++)
+ program->TexturesUsed[a] = 0;
+ program->NumAluInstructions =
+ program->NumTexInstructions =
+ program->NumTexIndirections = 0;
+
+ program->FPInstructions = NULL;
+ program->VPInstructions = NULL;
+
+ vc_head = NULL;
+ err = GL_FALSE;
+
+ /* Start examining the tokens in the array */
+ inst = parsed;
+
+ /* Check the grammer rev */
+ if (*inst++ != REVISION) {
+ _mesa_set_program_error (ctx, 0, "Grammar version mismatch");
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glProgramStringARB(Grammar verison mismatch)");
+ err = GL_TRUE;
+ }
+ else {
+ /* ignore program target */
+ inst++;
+
+ err = parse_arb_program (ctx, inst, &vc_head, program);
+#if DEBUG_PARSING
+ fprintf (stderr, "Symantic analysis returns %d [1 is bad!]\n", err);
+#endif
+ }
+
+ /*debug_variables(ctx, vc_head, program); */
+
+ /* We're done with the parsed binary array */
+ var_cache_destroy (&vc_head);
+
+ _mesa_free (parsed);
+#if DEBUG_PARSING
+ printf ("_mesa_parse_arb_program() done\n");
+#endif
+
+ return !err;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/arbprogparse.h b/nx-X11/extras/Mesa/src/mesa/shader/arbprogparse.h
new file mode 100644
index 000000000..ececfafa8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/arbprogparse.h
@@ -0,0 +1,75 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef ARBPROGPARSE_H
+#define ARBPROGPARSE_H
+
+#include "context.h"
+#include "mtypes.h"
+#include "nvvertprog.h"
+#include "nvfragprog.h"
+
+/**
+ * This is basically a union of the vertex_program and fragment_program
+ * structs that we can use to parse the program into
+ *
+ * XXX: this should go into mtypes.h?
+ */
+struct arb_program
+{
+ struct program Base;
+ struct program_parameter_list *Parameters;
+ GLuint InputsRead;
+ GLuint OutputsWritten;
+
+ GLuint Position; /* Just used for error reporting while parsing */
+ GLuint MajorVersion;
+ GLuint MinorVersion;
+
+ /* ARB_vertex_program specifics */
+ struct vp_instruction *VPInstructions;
+
+ /* Options currently recognized by the parser */
+ /* ARB_fp */
+ GLenum PrecisionOption; /* GL_DONT_CARE, GL_NICEST or GL_FASTEST */
+ GLenum FogOption; /* GL_NONE, GL_LINEAR, GL_EXP or GL_EXP2 */
+
+ /* ARB_fp & _vp */
+ GLboolean HintPositionInvariant;
+
+ /* ARB_fragment_program specifics */
+ struct fp_instruction *FPInstructions;
+ GLuint TexturesUsed[MAX_TEXTURE_IMAGE_UNITS];
+ GLuint NumAluInstructions;
+ GLuint NumTexInstructions;
+ GLuint NumTexIndirections;
+};
+
+
+extern GLboolean
+_mesa_parse_arb_program( GLcontext *ctx, const GLubyte *str, GLsizei len,
+ struct arb_program *program );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/arbprogram.c b/nx-X11/extras/Mesa/src/mesa/shader/arbprogram.c
new file mode 100644
index 000000000..43baab4b0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/arbprogram.c
@@ -0,0 +1,724 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file arbprogram.c
+ * ARB_vertex/fragment_program state management functions.
+ * \author Brian Paul
+ */
+
+
+#include "glheader.h"
+#include "arbprogram.h"
+#include "arbfragparse.h"
+#include "arbvertparse.h"
+#include "context.h"
+#include "imports.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "nvprogram.h"
+#include "nvfragparse.h"
+#include "nvfragprog.h"
+#include "nvvertparse.h"
+#include "nvvertprog.h"
+
+
+void GLAPIENTRY
+_mesa_EnableVertexAttribArrayARB(GLuint index)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (index >= ctx->Const.MaxVertexProgramAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glEnableVertexAttribArrayARB(index)");
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_ARRAY);
+ ctx->Array.VertexAttrib[index].Enabled = GL_TRUE;
+ ctx->Array._Enabled |= _NEW_ARRAY_ATTRIB(index);
+ ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index);
+}
+
+
+void GLAPIENTRY
+_mesa_DisableVertexAttribArrayARB(GLuint index)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (index >= ctx->Const.MaxVertexProgramAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glEnableVertexAttribArrayARB(index)");
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_ARRAY);
+ ctx->Array.VertexAttrib[index].Enabled = GL_FALSE;
+ ctx->Array._Enabled &= ~_NEW_ARRAY_ATTRIB(index);
+ ctx->Array.NewState |= _NEW_ARRAY_ATTRIB(index);
+}
+
+
+void GLAPIENTRY
+_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params)
+{
+ GLfloat fparams[4];
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ _mesa_GetVertexAttribfvARB(index, pname, fparams);
+ if (ctx->ErrorValue == GL_NO_ERROR) {
+ if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
+ COPY_4V(params, fparams);
+ }
+ else {
+ params[0] = fparams[0];
+ }
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (index == 0 || index >= MAX_VERTEX_PROGRAM_ATTRIBS) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribfvARB(index)");
+ return;
+ }
+
+ switch (pname) {
+ case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB:
+ params[0] = (GLfloat) ctx->Array.VertexAttrib[index].Enabled;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB:
+ params[0] = (GLfloat) ctx->Array.VertexAttrib[index].Size;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB:
+ params[0] = (GLfloat) ctx->Array.VertexAttrib[index].Stride;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB:
+ params[0] = (GLfloat) ctx->Array.VertexAttrib[index].Type;
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB:
+ params[0] = ctx->Array.VertexAttrib[index].Normalized;
+ break;
+ case GL_CURRENT_VERTEX_ATTRIB_ARB:
+ FLUSH_CURRENT(ctx, 0);
+ /* XXX should read:
+ COPY_4V(params, ctx->Current.Attrib[VERT_ATTRIB_GENERIC0 + index]);
+ */
+ COPY_4V(params, ctx->Current.Attrib[index]);
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB:
+ if (!ctx->Extensions.ARB_vertex_buffer_object) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribfvARB(pname)");
+ return;
+ }
+ params[0] = (GLfloat) ctx->Array.VertexAttrib[index].BufferObj->Name;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribfvARB(pname)");
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params)
+{
+ GLfloat fparams[4];
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ _mesa_GetVertexAttribfvARB(index, pname, fparams);
+ if (ctx->ErrorValue == GL_NO_ERROR) {
+ if (pname == GL_CURRENT_VERTEX_ATTRIB_ARB) {
+ COPY_4V_CAST(params, fparams, GLint); /* float to int */
+ }
+ else {
+ params[0] = (GLint) fparams[0];
+ }
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (index >= ctx->Const.MaxVertexProgramAttribs) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribPointerARB(index)");
+ return;
+ }
+
+ if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribPointerARB(pname)");
+ return;
+ }
+
+ *pointer = (GLvoid *) ctx->Array.VertexAttrib[index].Ptr;;
+}
+
+
+void GLAPIENTRY
+_mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
+ const GLvoid *string)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+
+ if (target == GL_VERTEX_PROGRAM_ARB
+ && ctx->Extensions.ARB_vertex_program) {
+ struct vertex_program *prog = ctx->VertexProgram.Current;
+ if (format != GL_PROGRAM_FORMAT_ASCII_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glProgramStringARB(format)");
+ return;
+ }
+ _mesa_parse_arb_vertex_program(ctx, target, (const GLubyte *) string,
+ len, prog);
+
+ if (ctx->Driver.ProgramStringNotify)
+ ctx->Driver.ProgramStringNotify( ctx, target, &prog->Base );
+ }
+ else if (target == GL_FRAGMENT_PROGRAM_ARB
+ && ctx->Extensions.ARB_fragment_program) {
+ struct fragment_program *prog = ctx->FragmentProgram.Current;
+ if (format != GL_PROGRAM_FORMAT_ASCII_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glProgramStringARB(format)");
+ return;
+ }
+ _mesa_parse_arb_fragment_program(ctx, target, (const GLubyte *) string,
+ len, prog);
+
+ if (ctx->Driver.ProgramStringNotify)
+ ctx->Driver.ProgramStringNotify( ctx, target, &prog->Base );
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glProgramStringARB(target)");
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_ProgramEnvParameter4dARB(GLenum target, GLuint index,
+ GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ _mesa_ProgramEnvParameter4fARB(target, index, (GLfloat) x, (GLfloat) y,
+ (GLfloat) z, (GLfloat) w);
+}
+
+
+void GLAPIENTRY
+_mesa_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
+ const GLdouble *params)
+{
+ _mesa_ProgramEnvParameter4fARB(target, index, (GLfloat) params[0],
+ (GLfloat) params[1], (GLfloat) params[2],
+ (GLfloat) params[3]);
+}
+
+
+void GLAPIENTRY
+_mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index,
+ GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+
+ if (target == GL_FRAGMENT_PROGRAM_ARB
+ && ctx->Extensions.ARB_fragment_program) {
+ if (index >= ctx->Const.MaxFragmentProgramEnvParams) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter(index)");
+ return;
+ }
+ ASSIGN_4V(ctx->FragmentProgram.Parameters[index], x, y, z, w);
+ }
+ else if (target == GL_VERTEX_PROGRAM_ARB
+ && ctx->Extensions.ARB_vertex_program) {
+ if (index >= ctx->Const.MaxVertexProgramEnvParams) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glProgramEnvParameter(index)");
+ return;
+ }
+ ASSIGN_4V(ctx->VertexProgram.Parameters[index], x, y, z, w);
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glProgramEnvParameter(target)");
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
+ const GLfloat *params)
+{
+ _mesa_ProgramEnvParameter4fARB(target, index, params[0], params[1],
+ params[2], params[3]);
+}
+
+
+void GLAPIENTRY
+_mesa_GetProgramEnvParameterdvARB(GLenum target, GLuint index,
+ GLdouble *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat fparams[4];
+
+ _mesa_GetProgramEnvParameterfvARB(target, index, fparams);
+ if (ctx->ErrorValue == GL_NO_ERROR) {
+ params[0] = fparams[0];
+ params[1] = fparams[1];
+ params[2] = fparams[2];
+ params[3] = fparams[3];
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetProgramEnvParameterfvARB(GLenum target, GLuint index,
+ GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+
+ if (!ctx->_CurrentProgram)
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target == GL_FRAGMENT_PROGRAM_ARB
+ && ctx->Extensions.ARB_fragment_program) {
+ if (index >= ctx->Const.MaxFragmentProgramEnvParams) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramEnvParameter(index)");
+ return;
+ }
+ COPY_4V(params, ctx->FragmentProgram.Parameters[index]);
+ }
+ else if (target == GL_VERTEX_PROGRAM_ARB
+ && ctx->Extensions.ARB_vertex_program) {
+ if (index >= ctx->Const.MaxVertexProgramEnvParams) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramEnvParameter(index)");
+ return;
+ }
+ COPY_4V(params, ctx->VertexProgram.Parameters[index]);
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramEnvParameter(target)");
+ return;
+ }
+}
+
+
+/**
+ * Note, this function is also used by the GL_NV_fragment_program extension.
+ */
+void GLAPIENTRY
+_mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index,
+ GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct program *prog;
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+
+ if ((target == GL_FRAGMENT_PROGRAM_NV
+ && ctx->Extensions.NV_fragment_program) ||
+ (target == GL_FRAGMENT_PROGRAM_ARB
+ && ctx->Extensions.ARB_fragment_program)) {
+ if (index >= ctx->Const.MaxFragmentProgramLocalParams) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameterARB");
+ return;
+ }
+ prog = &(ctx->FragmentProgram.Current->Base);
+ }
+ else if (target == GL_VERTEX_PROGRAM_ARB
+ && ctx->Extensions.ARB_vertex_program) {
+ if (index >= ctx->Const.MaxVertexProgramLocalParams) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glProgramLocalParameterARB");
+ return;
+ }
+ prog = &(ctx->VertexProgram.Current->Base);
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glProgramLocalParameterARB");
+ return;
+ }
+
+ ASSERT(index < MAX_PROGRAM_LOCAL_PARAMS);
+ prog->LocalParams[index][0] = x;
+ prog->LocalParams[index][1] = y;
+ prog->LocalParams[index][2] = z;
+ prog->LocalParams[index][3] = w;
+}
+
+
+/**
+ * Note, this function is also used by the GL_NV_fragment_program extension.
+ */
+void GLAPIENTRY
+_mesa_ProgramLocalParameter4fvARB(GLenum target, GLuint index,
+ const GLfloat *params)
+{
+ _mesa_ProgramLocalParameter4fARB(target, index, params[0], params[1],
+ params[2], params[3]);
+}
+
+
+/**
+ * Note, this function is also used by the GL_NV_fragment_program extension.
+ */
+void GLAPIENTRY
+_mesa_ProgramLocalParameter4dARB(GLenum target, GLuint index,
+ GLdouble x, GLdouble y,
+ GLdouble z, GLdouble w)
+{
+ _mesa_ProgramLocalParameter4fARB(target, index, (GLfloat) x, (GLfloat) y,
+ (GLfloat) z, (GLfloat) w);
+}
+
+
+/**
+ * Note, this function is also used by the GL_NV_fragment_program extension.
+ */
+void GLAPIENTRY
+_mesa_ProgramLocalParameter4dvARB(GLenum target, GLuint index,
+ const GLdouble *params)
+{
+ _mesa_ProgramLocalParameter4fARB(target, index,
+ (GLfloat) params[0], (GLfloat) params[1],
+ (GLfloat) params[2], (GLfloat) params[3]);
+}
+
+
+/**
+ * Note, this function is also used by the GL_NV_fragment_program extension.
+ */
+void GLAPIENTRY
+_mesa_GetProgramLocalParameterfvARB(GLenum target, GLuint index,
+ GLfloat *params)
+{
+ const struct program *prog;
+ GLuint maxParams;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target == GL_VERTEX_PROGRAM_ARB
+ && ctx->Extensions.ARB_vertex_program) {
+ prog = &(ctx->VertexProgram.Current->Base);
+ maxParams = ctx->Const.MaxVertexProgramLocalParams;
+ }
+ else if (target == GL_FRAGMENT_PROGRAM_ARB
+ && ctx->Extensions.ARB_fragment_program) {
+ prog = &(ctx->FragmentProgram.Current->Base);
+ maxParams = ctx->Const.MaxFragmentProgramLocalParams;
+ }
+ else if (target == GL_FRAGMENT_PROGRAM_NV
+ && ctx->Extensions.NV_fragment_program) {
+ prog = &(ctx->FragmentProgram.Current->Base);
+ maxParams = MAX_NV_FRAGMENT_PROGRAM_PARAMS;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetProgramLocalParameterARB(target)");
+ return;
+ }
+
+ if (index >= maxParams) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetProgramLocalParameterARB(index)");
+ return;
+ }
+
+ ASSERT(prog);
+ ASSERT(index < MAX_PROGRAM_LOCAL_PARAMS);
+ COPY_4V(params, prog->LocalParams[index]);
+}
+
+
+/**
+ * Note, this function is also used by the GL_NV_fragment_program extension.
+ */
+void GLAPIENTRY
+_mesa_GetProgramLocalParameterdvARB(GLenum target, GLuint index,
+ GLdouble *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat floatParams[4];
+ _mesa_GetProgramLocalParameterfvARB(target, index, floatParams);
+ if (ctx->ErrorValue == GL_NO_ERROR) {
+ COPY_4V(params, floatParams);
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params)
+{
+ struct program *prog;
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->_CurrentProgram)
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target == GL_VERTEX_PROGRAM_ARB
+ && ctx->Extensions.ARB_vertex_program) {
+ prog = &(ctx->VertexProgram.Current->Base);
+ }
+ else if (target == GL_FRAGMENT_PROGRAM_ARB
+ && ctx->Extensions.ARB_fragment_program) {
+ prog = &(ctx->FragmentProgram.Current->Base);
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(target)");
+ return;
+ }
+
+ ASSERT(prog);
+
+ switch (pname) {
+ case GL_PROGRAM_LENGTH_ARB:
+ *params = prog->String ? (GLint)_mesa_strlen((char *) prog->String) : 0;
+ break;
+ case GL_PROGRAM_FORMAT_ARB:
+ *params = prog->Format;
+ break;
+ case GL_PROGRAM_BINDING_ARB:
+ *params = prog->Id;
+ break;
+ case GL_PROGRAM_INSTRUCTIONS_ARB:
+ *params = prog->NumInstructions;
+ break;
+ case GL_MAX_PROGRAM_INSTRUCTIONS_ARB:
+ if (target == GL_VERTEX_PROGRAM_ARB)
+ *params = ctx->Const.MaxVertexProgramInstructions;
+ else
+ *params = ctx->Const.MaxFragmentProgramInstructions;
+ break;
+ case GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB:
+ *params = prog->NumInstructions;
+ break;
+ case GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB:
+ if (target == GL_VERTEX_PROGRAM_ARB)
+ *params = ctx->Const.MaxVertexProgramInstructions;
+ else
+ *params = ctx->Const.MaxFragmentProgramInstructions;
+ break;
+ case GL_PROGRAM_TEMPORARIES_ARB:
+ *params = prog->NumTemporaries;
+ break;
+ case GL_MAX_PROGRAM_TEMPORARIES_ARB:
+ if (target == GL_VERTEX_PROGRAM_ARB)
+ *params = ctx->Const.MaxVertexProgramTemps;
+ else
+ *params = ctx->Const.MaxFragmentProgramTemps;
+ break;
+ case GL_PROGRAM_NATIVE_TEMPORARIES_ARB:
+ /* XXX same as GL_PROGRAM_TEMPORARIES_ARB? */
+ *params = prog->NumTemporaries;
+ break;
+ case GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB:
+ /* XXX same as GL_MAX_PROGRAM_TEMPORARIES_ARB? */
+ if (target == GL_VERTEX_PROGRAM_ARB)
+ *params = ctx->Const.MaxVertexProgramTemps;
+ else
+ *params = ctx->Const.MaxFragmentProgramTemps;
+ break;
+ case GL_PROGRAM_PARAMETERS_ARB:
+ *params = prog->NumParameters;
+ break;
+ case GL_MAX_PROGRAM_PARAMETERS_ARB:
+ if (target == GL_VERTEX_PROGRAM_ARB)
+ *params = ctx->Const.MaxVertexProgramLocalParams;
+ else
+ *params = ctx->Const.MaxFragmentProgramLocalParams;
+ break;
+ case GL_PROGRAM_NATIVE_PARAMETERS_ARB:
+ /* XXX same as GL_MAX_PROGRAM_PARAMETERS_ARB? */
+ *params = prog->NumParameters;
+ break;
+ case GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB:
+ /* XXX same as GL_MAX_PROGRAM_PARAMETERS_ARB? */
+ if (target == GL_VERTEX_PROGRAM_ARB)
+ *params = ctx->Const.MaxVertexProgramLocalParams;
+ else
+ *params = ctx->Const.MaxFragmentProgramLocalParams;
+ break;
+ case GL_PROGRAM_ATTRIBS_ARB:
+ *params = prog->NumAttributes;
+ break;
+ case GL_MAX_PROGRAM_ATTRIBS_ARB:
+ if (target == GL_VERTEX_PROGRAM_ARB)
+ *params = ctx->Const.MaxVertexProgramAttribs;
+ else
+ *params = ctx->Const.MaxFragmentProgramAttribs;
+ break;
+ case GL_PROGRAM_NATIVE_ATTRIBS_ARB:
+ /* XXX same as GL_PROGRAM_ATTRIBS_ARB? */
+ *params = prog->NumAttributes;
+ break;
+ case GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB:
+ /* XXX same as GL_MAX_PROGRAM_ATTRIBS_ARB? */
+ if (target == GL_VERTEX_PROGRAM_ARB)
+ *params = ctx->Const.MaxVertexProgramAttribs;
+ else
+ *params = ctx->Const.MaxFragmentProgramAttribs;
+ break;
+ case GL_PROGRAM_ADDRESS_REGISTERS_ARB:
+ *params = prog->NumAddressRegs;
+ break;
+ case GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB:
+ if (target == GL_VERTEX_PROGRAM_ARB)
+ *params = ctx->Const.MaxVertexProgramAddressRegs;
+ else
+ *params = ctx->Const.MaxFragmentProgramAddressRegs;
+ break;
+ case GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB:
+ /* XXX same as GL_PROGRAM_ADDRESS_REGISTERS_ARB? */
+ *params = prog->NumAddressRegs;
+ break;
+ case GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB:
+ /* XXX same as GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB? */
+ if (target == GL_VERTEX_PROGRAM_ARB)
+ *params = ctx->Const.MaxVertexProgramAddressRegs;
+ else
+ *params = ctx->Const.MaxFragmentProgramAddressRegs;
+ break;
+ case GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB:
+ if (target == GL_VERTEX_PROGRAM_ARB)
+ *params = ctx->Const.MaxVertexProgramLocalParams;
+ else
+ *params = ctx->Const.MaxFragmentProgramLocalParams;
+ break;
+ case GL_MAX_PROGRAM_ENV_PARAMETERS_ARB:
+ if (target == GL_VERTEX_PROGRAM_ARB)
+ *params = ctx->Const.MaxVertexProgramEnvParams;
+ else
+ *params = ctx->Const.MaxFragmentProgramEnvParams;
+ break;
+ case GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB:
+ if (ctx->Driver.IsProgramNative)
+ *params = ctx->Driver.IsProgramNative( ctx, target, prog );
+ else
+ *params = GL_TRUE;
+ break;
+
+ /*
+ * The following apply to fragment programs only.
+ */
+ case GL_PROGRAM_ALU_INSTRUCTIONS_ARB:
+ case GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB:
+ if (target != GL_FRAGMENT_PROGRAM_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(target)");
+ return;
+ }
+ *params = ctx->FragmentProgram.Current->NumAluInstructions;
+ break;
+ case GL_PROGRAM_TEX_INSTRUCTIONS_ARB:
+ case GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB:
+ if (target != GL_FRAGMENT_PROGRAM_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(target)");
+ return;
+ }
+ *params = ctx->FragmentProgram.Current->NumTexInstructions;
+ break;
+ case GL_PROGRAM_TEX_INDIRECTIONS_ARB:
+ case GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB:
+ if (target != GL_FRAGMENT_PROGRAM_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(target)");
+ return;
+ }
+ *params = ctx->FragmentProgram.Current->NumTexIndirections;
+ break;
+ case GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB:
+ case GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB:
+ if (target != GL_FRAGMENT_PROGRAM_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(target)");
+ return;
+ }
+ *params = ctx->Const.MaxFragmentProgramAluInstructions;
+ break;
+ case GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB:
+ case GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB:
+ if (target != GL_FRAGMENT_PROGRAM_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(target)");
+ return;
+ }
+ *params = ctx->Const.MaxFragmentProgramTexInstructions;
+ break;
+ case GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB:
+ case GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB:
+ if (target != GL_FRAGMENT_PROGRAM_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(target)");
+ return;
+ }
+ *params = ctx->Const.MaxFragmentProgramTexIndirections;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivARB(pname)");
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_GetProgramStringARB(GLenum target, GLenum pname, GLvoid *string)
+{
+ struct program *prog;
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->_CurrentProgram)
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target == GL_VERTEX_PROGRAM_ARB) {
+ prog = &(ctx->VertexProgram.Current->Base);
+ }
+ else if (target == GL_FRAGMENT_PROGRAM_ARB) {
+ prog = &(ctx->FragmentProgram.Current->Base);
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramStringARB(target)");
+ return;
+ }
+
+ ASSERT(prog);
+
+ if (pname != GL_PROGRAM_STRING_ARB) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramStringARB(pname)");
+ return;
+ }
+
+ MEMCPY(string, prog->String, _mesa_strlen((char *) prog->String));
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/arbprogram.h b/nx-X11/extras/Mesa/src/mesa/shader/arbprogram.h
new file mode 100644
index 000000000..e1b99ab68
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/arbprogram.h
@@ -0,0 +1,128 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef ARBPROGRAM_H
+#define ARBPROGRAM_H
+
+
+extern void GLAPIENTRY
+_mesa_EnableVertexAttribArrayARB(GLuint index);
+
+
+extern void GLAPIENTRY
+_mesa_DisableVertexAttribArrayARB(GLuint index);
+
+
+extern void GLAPIENTRY
+_mesa_GetVertexAttribdvARB(GLuint index, GLenum pname, GLdouble *params);
+
+
+extern void GLAPIENTRY
+_mesa_GetVertexAttribfvARB(GLuint index, GLenum pname, GLfloat *params);
+
+
+extern void GLAPIENTRY
+_mesa_GetVertexAttribivARB(GLuint index, GLenum pname, GLint *params);
+
+
+extern void GLAPIENTRY
+_mesa_GetVertexAttribPointervARB(GLuint index, GLenum pname, GLvoid **pointer);
+
+
+extern void GLAPIENTRY
+_mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
+ const GLvoid *string);
+
+
+extern void GLAPIENTRY
+_mesa_ProgramEnvParameter4dARB(GLenum target, GLuint index,
+ GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+
+
+extern void GLAPIENTRY
+_mesa_ProgramEnvParameter4dvARB(GLenum target, GLuint index,
+ const GLdouble *params);
+
+
+extern void GLAPIENTRY
+_mesa_ProgramEnvParameter4fARB(GLenum target, GLuint index,
+ GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+
+
+extern void GLAPIENTRY
+_mesa_ProgramEnvParameter4fvARB(GLenum target, GLuint index,
+ const GLfloat *params);
+
+
+extern void GLAPIENTRY
+_mesa_ProgramLocalParameter4dARB(GLenum target, GLuint index,
+ GLdouble x, GLdouble y,
+ GLdouble z, GLdouble w);
+
+
+extern void GLAPIENTRY
+_mesa_ProgramLocalParameter4dvARB(GLenum target, GLuint index,
+ const GLdouble *params);
+
+
+extern void GLAPIENTRY
+_mesa_ProgramLocalParameter4fARB(GLenum target, GLuint index,
+ GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+
+
+extern void GLAPIENTRY
+_mesa_ProgramLocalParameter4fvARB(GLenum target, GLuint index,
+ const GLfloat *params);
+
+
+extern void GLAPIENTRY
+_mesa_GetProgramEnvParameterdvARB(GLenum target, GLuint index,
+ GLdouble *params);
+
+
+extern void GLAPIENTRY
+_mesa_GetProgramEnvParameterfvARB(GLenum target, GLuint index,
+ GLfloat *params);
+
+
+extern void GLAPIENTRY
+_mesa_GetProgramLocalParameterdvARB(GLenum target, GLuint index,
+ GLdouble *params);
+
+
+extern void GLAPIENTRY
+_mesa_GetProgramLocalParameterfvARB(GLenum target, GLuint index,
+ GLfloat *params);
+
+
+extern void GLAPIENTRY
+_mesa_GetProgramivARB(GLenum target, GLenum pname, GLint *params);
+
+
+extern void GLAPIENTRY
+_mesa_GetProgramStringARB(GLenum target, GLenum pname, GLvoid *string);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/arbprogram.syn b/nx-X11/extras/Mesa/src/mesa/shader/arbprogram.syn
new file mode 100644
index 000000000..6ab0f2693
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/arbprogram.syn
@@ -0,0 +1,2786 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.2
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+ /**
+ * \file arbprogram.syn
+ * ARB_fragment/vertex_program syntax
+ * \author Michal Krol
+ */
+
+.syntax program;
+
+/*
+ This value must be incremented every time emit code values or structure of the production
+ array changes. This value is placed at the beginning of the production array. The loader
+ compares the value with its REVISION value. If they do not match, the loader is not up
+ to date.
+*/
+.emtcode REVISION 0x09
+
+/* program type */
+.emtcode FRAGMENT_PROGRAM 0x01
+.emtcode VERTEX_PROGRAM 0x02
+
+/* program section */
+.emtcode OPTION 0x01
+.emtcode INSTRUCTION 0x02
+.emtcode DECLARATION 0x03
+.emtcode END 0x04
+
+/* GL_ARB_fragment_program option */
+.emtcode ARB_PRECISION_HINT_FASTEST 0x00
+.emtcode ARB_PRECISION_HINT_NICEST 0x01
+.emtcode ARB_FOG_EXP 0x02
+.emtcode ARB_FOG_EXP2 0x03
+.emtcode ARB_FOG_LINEAR 0x04
+
+/* GL_ARB_vertex_program option */
+.emtcode ARB_POSITION_INVARIANT 0x05
+
+/* GL_ARB_fragment_program_shadow option */
+.emtcode ARB_FRAGMENT_PROGRAM_SHADOW 0x06
+
+/* GL_ARB_draw_buffers option */
+.emtcode ARB_DRAW_BUFFERS 0x07
+
+/* GL_ARB_fragment_program instruction class */
+.emtcode OP_ALU_INST 0x00
+.emtcode OP_TEX_INST 0x01
+
+/* GL_ARB_vertex_program instruction class */
+/* OP_ALU_INST */
+
+/* GL_ARB_fragment_program instruction type */
+.emtcode OP_ALU_VECTOR 0x00
+.emtcode OP_ALU_SCALAR 0x01
+.emtcode OP_ALU_BINSC 0x02
+.emtcode OP_ALU_BIN 0x03
+.emtcode OP_ALU_TRI 0x04
+.emtcode OP_ALU_SWZ 0x05
+.emtcode OP_TEX_SAMPLE 0x06
+.emtcode OP_TEX_KIL 0x07
+
+/* GL_ARB_vertex_program instruction type */
+.emtcode OP_ALU_ARL 0x08
+/* OP_ALU_VECTOR */
+/* OP_ALU_SCALAR */
+/* OP_ALU_BINSC */
+/* OP_ALU_BIN */
+/* OP_ALU_TRI */
+/* OP_ALU_SWZ */
+
+/* GL_ARB_fragment_program instruction code */
+.emtcode OP_ABS 0x00
+.emtcode OP_ABS_SAT 0x1B
+.emtcode OP_FLR 0x09
+.emtcode OP_FLR_SAT 0x26
+.emtcode OP_FRC 0x0A
+.emtcode OP_FRC_SAT 0x27
+.emtcode OP_LIT 0x0C
+.emtcode OP_LIT_SAT 0x2A
+.emtcode OP_MOV 0x11
+.emtcode OP_MOV_SAT 0x30
+.emtcode OP_COS 0x1F
+.emtcode OP_COS_SAT 0x20
+.emtcode OP_EX2 0x07
+.emtcode OP_EX2_SAT 0x25
+.emtcode OP_LG2 0x0B
+.emtcode OP_LG2_SAT 0x29
+.emtcode OP_RCP 0x14
+.emtcode OP_RCP_SAT 0x33
+.emtcode OP_RSQ 0x15
+.emtcode OP_RSQ_SAT 0x34
+.emtcode OP_SIN 0x38
+.emtcode OP_SIN_SAT 0x39
+.emtcode OP_SCS 0x35
+.emtcode OP_SCS_SAT 0x36
+.emtcode OP_POW 0x13
+.emtcode OP_POW_SAT 0x32
+.emtcode OP_ADD 0x01
+.emtcode OP_ADD_SAT 0x1C
+.emtcode OP_DP3 0x03
+.emtcode OP_DP3_SAT 0x21
+.emtcode OP_DP4 0x04
+.emtcode OP_DP4_SAT 0x22
+.emtcode OP_DPH 0x05
+.emtcode OP_DPH_SAT 0x23
+.emtcode OP_DST 0x06
+.emtcode OP_DST_SAT 0x24
+.emtcode OP_MAX 0x0F
+.emtcode OP_MAX_SAT 0x2E
+.emtcode OP_MIN 0x10
+.emtcode OP_MIN_SAT 0x2F
+.emtcode OP_MUL 0x12
+.emtcode OP_MUL_SAT 0x31
+.emtcode OP_SGE 0x16
+.emtcode OP_SGE_SAT 0x37
+.emtcode OP_SLT 0x17
+.emtcode OP_SLT_SAT 0x3A
+.emtcode OP_SUB 0x18
+.emtcode OP_SUB_SAT 0x3B
+.emtcode OP_XPD 0x1A
+.emtcode OP_XPD_SAT 0x43
+.emtcode OP_CMP 0x1D
+.emtcode OP_CMP_SAT 0x1E
+.emtcode OP_LRP 0x2B
+.emtcode OP_LRP_SAT 0x2C
+.emtcode OP_MAD 0x0E
+.emtcode OP_MAD_SAT 0x2D
+.emtcode OP_SWZ 0x19
+.emtcode OP_SWZ_SAT 0x3C
+.emtcode OP_TEX 0x3D
+.emtcode OP_TEX_SAT 0x3E
+.emtcode OP_TXB 0x3F
+.emtcode OP_TXB_SAT 0x40
+.emtcode OP_TXP 0x41
+.emtcode OP_TXP_SAT 0x42
+.emtcode OP_KIL 0x28
+
+/* GL_ARB_vertex_program instruction code */
+.emtcode OP_ARL 0x02
+/* OP_ABS */
+/* OP_FLR */
+/* OP_FRC */
+/* OP_LIT */
+/* OP_MOV */
+/* OP_EX2 */
+.emtcode OP_EXP 0x08
+/* OP_LG2 */
+.emtcode OP_LOG 0x0D
+/* OP_RCP */
+/* OP_RSQ */
+/* OP_POW */
+/* OP_ADD */
+/* OP_DP3 */
+/* OP_DP4 */
+/* OP_DPH */
+/* OP_DST */
+/* OP_MAX */
+/* OP_MIN */
+/* OP_MUL */
+/* OP_SGE */
+/* OP_SLT */
+/* OP_SUB */
+/* OP_XPD */
+/* OP_MAD */
+/* OP_SWZ */
+
+/* fragment attribute binding */
+.emtcode FRAGMENT_ATTRIB_COLOR 0x01
+.emtcode FRAGMENT_ATTRIB_TEXCOORD 0x02
+.emtcode FRAGMENT_ATTRIB_FOGCOORD 0x03
+.emtcode FRAGMENT_ATTRIB_POSITION 0x04
+
+/* vertex attribute binding */
+.emtcode VERTEX_ATTRIB_POSITION 0x01
+.emtcode VERTEX_ATTRIB_WEIGHT 0x02
+.emtcode VERTEX_ATTRIB_NORMAL 0x03
+.emtcode VERTEX_ATTRIB_COLOR 0x04
+.emtcode VERTEX_ATTRIB_FOGCOORD 0x05
+.emtcode VERTEX_ATTRIB_TEXCOORD 0x06
+.emtcode VERTEX_ATTRIB_MATRIXINDEX 0x07
+.emtcode VERTEX_ATTRIB_GENERIC 0x08
+
+/* fragment result binding */
+.emtcode FRAGMENT_RESULT_COLOR 0x01
+.emtcode FRAGMENT_RESULT_DEPTH 0x02
+
+/* vertex result binding */
+.emtcode VERTEX_RESULT_POSITION 0x01
+.emtcode VERTEX_RESULT_COLOR 0x02
+.emtcode VERTEX_RESULT_FOGCOORD 0x03
+.emtcode VERTEX_RESULT_POINTSIZE 0x04
+.emtcode VERTEX_RESULT_TEXCOORD 0x05
+
+/* texture target */
+.emtcode TEXTARGET_1D 0x01
+.emtcode TEXTARGET_2D 0x02
+.emtcode TEXTARGET_3D 0x03
+.emtcode TEXTARGET_RECT 0x04
+.emtcode TEXTARGET_CUBE 0x05
+/* GL_ARB_fragment_program_shadow */
+.emtcode TEXTARGET_SHADOW1D 0x06
+.emtcode TEXTARGET_SHADOW2D 0x07
+.emtcode TEXTARGET_SHADOWRECT 0x08
+
+/* face type */
+.emtcode FACE_FRONT 0x00
+.emtcode FACE_BACK 0x01
+
+/* color type */
+.emtcode COLOR_PRIMARY 0x00
+.emtcode COLOR_SECONDARY 0x01
+
+/* component */
+.emtcode COMPONENT_X 0x00
+.emtcode COMPONENT_Y 0x01
+.emtcode COMPONENT_Z 0x02
+.emtcode COMPONENT_W 0x03
+.emtcode COMPONENT_0 0x04
+.emtcode COMPONENT_1 0x05
+
+/* array index type */
+.emtcode ARRAY_INDEX_ABSOLUTE 0x00
+.emtcode ARRAY_INDEX_RELATIVE 0x01
+
+/* matrix name */
+.emtcode MATRIX_MODELVIEW 0x01
+.emtcode MATRIX_PROJECTION 0x02
+.emtcode MATRIX_MVP 0x03
+.emtcode MATRIX_TEXTURE 0x04
+.emtcode MATRIX_PALETTE 0x05
+.emtcode MATRIX_PROGRAM 0x06
+
+/* matrix modifier */
+.emtcode MATRIX_MODIFIER_IDENTITY 0x00
+.emtcode MATRIX_MODIFIER_INVERSE 0x01
+.emtcode MATRIX_MODIFIER_TRANSPOSE 0x02
+.emtcode MATRIX_MODIFIER_INVTRANS 0x03
+
+/* constant type */
+.emtcode CONSTANT_SCALAR 0x01
+.emtcode CONSTANT_VECTOR 0x02
+
+/* program param type */
+.emtcode PROGRAM_PARAM_ENV 0x01
+.emtcode PROGRAM_PARAM_LOCAL 0x02
+
+/* register type */
+.emtcode REGISTER_ATTRIB 0x01
+.emtcode REGISTER_PARAM 0x02
+.emtcode REGISTER_RESULT 0x03
+.emtcode REGISTER_ESTABLISHED_NAME 0x04
+
+/* param binding */
+.emtcode PARAM_NULL 0x00
+.emtcode PARAM_ARRAY_ELEMENT 0x01
+.emtcode PARAM_STATE_ELEMENT 0x02
+.emtcode PARAM_PROGRAM_ELEMENT 0x03
+.emtcode PARAM_PROGRAM_ELEMENTS 0x04
+.emtcode PARAM_CONSTANT 0x05
+
+/* param state property */
+.emtcode STATE_MATERIAL 0x01
+.emtcode STATE_LIGHT 0x02
+.emtcode STATE_LIGHT_MODEL 0x03
+.emtcode STATE_LIGHT_PROD 0x04
+.emtcode STATE_FOG 0x05
+.emtcode STATE_MATRIX_ROWS 0x06
+/* GL_ARB_fragment_program */
+.emtcode STATE_TEX_ENV 0x07
+.emtcode STATE_DEPTH 0x08
+/* GL_ARB_vertex_program */
+.emtcode STATE_TEX_GEN 0x09
+.emtcode STATE_CLIP_PLANE 0x0A
+.emtcode STATE_POINT 0x0B
+
+/* state material property */
+.emtcode MATERIAL_AMBIENT 0x01
+.emtcode MATERIAL_DIFFUSE 0x02
+.emtcode MATERIAL_SPECULAR 0x03
+.emtcode MATERIAL_EMISSION 0x04
+.emtcode MATERIAL_SHININESS 0x05
+
+/* state light property */
+.emtcode LIGHT_AMBIENT 0x01
+.emtcode LIGHT_DIFFUSE 0x02
+.emtcode LIGHT_SPECULAR 0x03
+.emtcode LIGHT_POSITION 0x04
+.emtcode LIGHT_ATTENUATION 0x05
+.emtcode LIGHT_HALF 0x06
+.emtcode LIGHT_SPOT_DIRECTION 0x07
+
+/* state light model property */
+.emtcode LIGHT_MODEL_AMBIENT 0x01
+.emtcode LIGHT_MODEL_SCENECOLOR 0x02
+
+/* state light product property */
+.emtcode LIGHT_PROD_AMBIENT 0x01
+.emtcode LIGHT_PROD_DIFFUSE 0x02
+.emtcode LIGHT_PROD_SPECULAR 0x03
+
+/* state texture environment property */
+.emtcode TEX_ENV_COLOR 0x01
+
+/* state texture generation coord property */
+.emtcode TEX_GEN_EYE 0x01
+.emtcode TEX_GEN_OBJECT 0x02
+
+/* state fog property */
+.emtcode FOG_COLOR 0x01
+.emtcode FOG_PARAMS 0x02
+
+/* state depth property */
+.emtcode DEPTH_RANGE 0x01
+
+/* state point parameters property */
+.emtcode POINT_SIZE 0x01
+.emtcode POINT_ATTENUATION 0x02
+
+/* declaration */
+.emtcode ATTRIB 0x01
+.emtcode PARAM 0x02
+.emtcode TEMP 0x03
+.emtcode OUTPUT 0x04
+.emtcode ALIAS 0x05
+/* GL_ARB_vertex_program */
+.emtcode ADDRESS 0x06
+
+/* error messages */
+.errtext UNKNOWN_PROGRAM_SIGNATURE "1001: '$e_signature$': unknown program signature"
+.errtext MISSING_END_OR_INVALID_STATEMENT "1002: '$e_statement$': invalid statement"
+.errtext CODE_AFTER_END "1003: '$e_statement$': code after 'END' keyword"
+.errtext INVALID_PROGRAM_OPTION "1004: '$e_identifier$': invalid program option"
+.errtext EXT_SWIZ_COMP_EXPECTED "1005: extended swizzle component expected but '$e_token$' found"
+.errtext TEX_TARGET_EXPECTED "1006: texture target expected but '$e_token$' found"
+.errtext TEXTURE_EXPECTED "1007: 'texture' expected but '$e_identifier$' found"
+.errtext SOURCE_REGISTER_EXPECTED "1008: source register expected but '$e_token$' found"
+.errtext DESTINATION_REGISTER_EXPECTED "1009: destination register expected but '$e_token$' found"
+.errtext INVALID_ADDRESS_COMPONENT "1010: '$e_identifier$': invalid address component"
+.errtext INVALID_ADDRESS_WRITEMASK "1011: '$e_identifier$': invalid address writemask"
+.errtext INVALID_COMPONENT "1012: '$e_charordigit$': invalid component"
+.errtext INVALID_SUFFIX "1013: '$e_identifier$': invalid suffix"
+.errtext INVALID_WRITEMASK "1014: '$e_identifier$': invalid writemask"
+.errtext FRAGMENT_EXPECTED "1015: 'fragment' expected but '$e_identifier$' found"
+.errtext VERTEX_EXPECTED "1016: 'vertex' expected but '$e_identifier$' found"
+.errtext INVALID_FRAGMENT_PROPERTY "1017: '$e_identifier$': invalid fragment property"
+.errtext INVALID_VERTEX_PROPERTY "1018: '$e_identifier$': invalid vertex property"
+.errtext INVALID_STATE_PROPERTY "1019: '$e_identifier$': invalid state property"
+.errtext INVALID_MATERIAL_PROPERTY "1020: '$e_identifier$': invalid material property"
+.errtext INVALID_LIGHT_PROPERTY "1021: '$e_identifier$': invalid light property"
+.errtext INVALID_SPOT_PROPERTY "1022: '$e_identifier$': invalid spot property"
+.errtext INVALID_LIGHTMODEL_PROPERTY "1023: '$e_identifier$': invalid light model property"
+.errtext INVALID_LIGHTPROD_PROPERTY "1024: '$e_identifier$': invalid light product property"
+.errtext INVALID_TEXENV_PROPERTY "1025: '$e_identifier$': invalid texture environment property"
+.errtext INVALID_TEXGEN_PROPERTY "1026: '$e_identifier$': invalid texture generating property"
+.errtext INVALID_TEXGEN_COORD "1027: '$e_identifier$': invalid texture generating coord"
+.errtext INVALID_FOG_PROPERTY "1028: '$e_identifier$': invalid fog property"
+.errtext INVALID_DEPTH_PROPERTY "1029: '$e_identifier$': invalid depth property"
+.errtext INVALID_CLIPPLANE_PROPERTY "1030: '$e_identifier$': invalid clip plane property"
+.errtext INVALID_POINT_PROPERTY "1031: '$e_identifier$': invalid point property"
+.errtext MATRIX_ROW_SELECTOR_OR_MODIFIER_EXPECTED "1032: matrix row selector or modifier expected but '$e_token$' found"
+.errtext INVALID_MATRIX_NAME "1033: '$e_identifier$': invalid matrix name"
+.errtext INVALID_PROGRAM_PROPERTY "1034: '$e_identifier$': invalid program property"
+.errtext RESULT_EXPECTED "1035: 'result' expected but '$e_token$' found"
+.errtext INVALID_RESULT_PROPERTY "1036: '$e_identifier$': invalid result property"
+.errtext INVALID_FACE_PROPERTY "1037: '$e_identifier$': invalid face property"
+.errtext INVALID_COLOR_PROPERTY "1038: '$e_identifier$': invalid color property"
+.errtext IDENTIFIER_EXPECTED "1039: identifier expected but '$e_token$' found"
+.errtext RESERVED_KEYWORD "1040: use of reserved keyword as an identifier"
+.errtext INTEGER_EXPECTED "1041: integer value expected but '$e_token$' found"
+.errtext MISSING_SEMICOLON "1042: ';' expected but '$e_token$' found"
+.errtext MISSING_COMMA "1043: ',' expected but '$e_token$' found"
+.errtext MISSING_LBRACKET "1044: '[' expected but '$e_token$' found"
+.errtext MISSING_RBRACKET "1045: ']' expected but '$e_token$' found"
+.errtext MISSING_DOT "1046: '.' expected but '$e_token$' found"
+.errtext MISSING_EQUAL "1047: '=' expected but '$e_token$' found"
+.errtext MISSING_LBRACE "1048: '{' expected but '$e_token$' found"
+.errtext MISSING_RBRACE "1049: '}' expected but '$e_token$' found"
+.errtext MISSING_DOTDOT "1050: '..' expected but '$e_token$' found"
+.errtext MISSING_FRACTION_OR_EXPONENT "1051: missing fraction part or exponent"
+.errtext MISSING_DOT_OR_EXPONENT "1052: missing '.' or exponent"
+.errtext EXPONENT_VALUE_EXPECTED "1053: exponent value expected"
+.errtext INTEGER_OUT_OF_RANGE "1054: integer value out of range"
+.errtext OPERATION_NEEDS_DESTINATION_VARIABLE "1055: operation needs destination variable"
+.errtext OPERATION_NEEDS_SOURCE_VARIABLE "1056: operation needs source variable"
+.errtext ADDRESS_REGISTER_EXPECTED "1057: address register expected but '$e_token$' found"
+.errtext ADDRESS_REGISTER_OR_INTEGER_EXPECTED "1058: address register or integer literal expected but '$e_token$' found"
+
+/* extension presence condition registers */
+
+/* GL_ARB_vertex_blend */
+/* GL_EXT_vertex_weighting */
+.regbyte vertex_blend 0x00
+
+/* GL_ARB_matrix_palette */
+.regbyte matrix_palette 0x00
+
+/* GL_ARB_point_parameters */
+/* GL_EXT_point_parameters */
+.regbyte point_parameters 0x00
+
+/* GL_EXT_secondary_color */
+.regbyte secondary_color 0x00
+
+/* GL_EXT_fog_coord */
+.regbyte fog_coord 0x00
+
+/* GL_EXT_texture_rectangle */
+/* GL_NV_texture_rectangle */
+.regbyte texture_rectangle 0x00
+
+/* GL_ARB_fragment_program_shadow */
+.regbyte fragment_program_shadow 0x00
+
+/* GL_ARB_draw_buffers */
+.regbyte draw_buffers 0x00
+
+/* option presence condition registers */
+/* they are all initially set to zero - when a particular OPTION is encountered, the appropriate */
+/* register is set to 1 to indicate that the OPTION was specified. */
+
+/* GL_ARB_fragment_program */
+.regbyte ARB_precision_hint_fastest 0x00
+.regbyte ARB_precision_hint_nicest 0x00
+.regbyte ARB_fog_exp 0x00
+.regbyte ARB_fog_exp2 0x00
+.regbyte ARB_fog_linear 0x00
+
+/* GL_ARB_vertex_program */
+.regbyte ARB_position_invariant 0x00
+
+/* GL_ARB_fragment_program_shadow */
+.regbyte ARB_fragment_program_shadow 0x00
+
+/* GL_ARB_draw_buffers */
+.regbyte ARB_draw_buffers 0x00
+
+/* program target condition register */
+/* this syntax script deals with two program targets - VERTEX_PROGRAM and FRAGMENT_PROGRAM. */
+/* to distinguish between them we need a register that will store for us the current target. */
+/* the client will typically set the register to apropriate value before parsing a particular */
+/* program. the mapping between program targets and their values is listed below. */
+/* */
+/* program target register value */
+/* ---------------------------------------------- */
+/* FRAGMENT_PROGRAM 0x10 */
+/* VERTEX_PROGRAM 0x20 */
+/* */
+/* the initial value of the register is 0 to catch potential errors with not setting the register */
+/* with the proper value. */
+.regbyte program_target 0x00
+
+/*
+ <program> ::= <optionSequence> <statementSequence> "END"
+*/
+program
+ programs .error UNKNOWN_PROGRAM_SIGNATURE .emit REVISION;
+programs
+ .if (program_target == 0x10) frag_program_1_0 .emit FRAGMENT_PROGRAM .emit 0x01 .emit 0x00 .or
+ .if (program_target == 0x20) vert_program_1_0 .emit VERTEX_PROGRAM .emit 0x01 .emit 0x00;
+frag_program_1_0
+ '!' .and '!' .and 'A' .and 'R' .and 'B' .and 'f' .and 'p' .and '1' .and '.' .and '0' .and
+ optional_space .and fp_optionSequence .and fp_statementSequence .and
+ "END" .error MISSING_END_OR_INVALID_STATEMENT .emit END .and optional_space .and
+ '\0' .error CODE_AFTER_END;
+vert_program_1_0
+ '!' .and '!' .and 'A' .and 'R' .and 'B' .and 'v' .and 'p' .and '1' .and '.' .and '0' .and
+ optional_space .and vp_optionSequence .and vp_statementSequence .and
+ "END" .error MISSING_END_OR_INVALID_STATEMENT .emit END .and optional_space .and
+ '\0' .error CODE_AFTER_END;
+
+/*
+ <optionSequence> ::= <optionSequence> <option>
+ | ""
+*/
+fp_optionSequence
+ .loop fp_option;
+vp_optionSequence
+ .loop vp_option;
+
+/*
+ <option> ::= "OPTION" <identifier> ";"
+
+NOTE: options ARB_precision_hint_nicest and ARB_precision_hint_fastest are exclusive. When one of
+ these options is encountered, the other one is automatically disabled.
+ the same applies to options ARB_fog_exp, ARB_fog_exp2 and ARB_fog_linear.
+*/
+fp_option
+ "OPTION" .emit OPTION .and space .error IDENTIFIER_EXPECTED .and
+ fp_optionString .error INVALID_PROGRAM_OPTION .and semicolon;
+vp_option
+ "OPTION" .emit OPTION .and space .error IDENTIFIER_EXPECTED .and
+ vp_optionString .error INVALID_PROGRAM_OPTION .and semicolon;
+fp_optionString
+ .if (ARB_precision_hint_nicest == 0x00) "ARB_precision_hint_fastest"
+ .emit ARB_PRECISION_HINT_FASTEST .load ARB_precision_hint_fastest 0x01 .or
+ .if (ARB_precision_hint_fastest == 0x00) "ARB_precision_hint_nicest"
+ .emit ARB_PRECISION_HINT_NICEST .load ARB_precision_hint_nicest 0x01 .or
+ fp_ARB_fog_exp .emit ARB_FOG_EXP .load ARB_fog_exp 0x01 .or
+ fp_ARB_fog_exp2 .emit ARB_FOG_EXP2 .load ARB_fog_exp2 0x01 .or
+ fp_ARB_fog_linear .emit ARB_FOG_LINEAR .load ARB_fog_linear 0x01 .or
+ .if (fragment_program_shadow != 0x00) "ARB_fragment_program_shadow"
+ .emit ARB_FRAGMENT_PROGRAM_SHADOW .load ARB_fragment_program_shadow 0x01 .or
+ .if (draw_buffers != 0x00) "ARB_draw_buffers" .emit ARB_DRAW_BUFFERS
+ .load ARB_draw_buffers 0x01;
+vp_optionString
+ "ARB_position_invariant" .emit ARB_POSITION_INVARIANT .load ARB_position_invariant 0x01;
+fp_ARB_fog_exp
+ .if (ARB_fog_exp2 == 0x00) .true .and .if (ARB_fog_linear == 0x00) "ARB_fog_exp";
+fp_ARB_fog_exp2
+ .if (ARB_fog_exp == 0x00) .true .and .if (ARB_fog_linear == 0x00) "ARB_fog_exp2";
+fp_ARB_fog_linear
+ .if (ARB_fog_exp == 0x00) .true .and .if (ARB_fog_exp2 == 0x00) "ARB_fog_linear";
+
+/*
+ <statementSequence> ::= <statementSequence> <statement>
+ | ""
+*/
+fp_statementSequence
+ .loop fp_statement;
+vp_statementSequence
+ .loop vp_statement;
+
+/*
+ <statement> ::= <instruction> ";"
+ | <namingStatement> ";"
+
+NOTE: ".emit $" in the definitions below means that we output instruction position (offset of
+ the first character of instruction) for program debugging purposes.
+*/
+fp_statement
+ fp_statement_1 .or fp_statement_2;
+vp_statement
+ vp_statement_1 .or vp_statement_2;
+fp_statement_1
+ fp_instruction .emit INSTRUCTION .emit $ .and semicolon;
+fp_statement_2
+ fp_namingStatement .emit DECLARATION .and semicolon;
+vp_statement_1
+ vp_instruction .emit INSTRUCTION .emit $ .and semicolon;
+vp_statement_2
+ vp_namingStatement .emit DECLARATION .and semicolon;
+
+/*
+fragment program
+ <instruction> ::= <ALUInstruction>
+ | <TexInstruction>
+
+vertex program
+ <instruction> ::= <ARL_instruction>
+ | <VECTORop_instruction>
+ | <SCALARop_instruction>
+ | <BINSCop_instruction>
+ | <BINop_instruction>
+ | <TRIop_instruction>
+ | <SWZ_instruction>
+*/
+fp_instruction
+ ALUInstruction .emit OP_ALU_INST .or
+ TexInstruction .emit OP_TEX_INST;
+vp_instruction
+ ARL_instruction .emit OP_ALU_ARL .or
+ vp_VECTORop_instruction .emit OP_ALU_VECTOR .or
+ vp_SCALARop_instruction .emit OP_ALU_SCALAR .or
+ vp_BINSCop_instruction .emit OP_ALU_BINSC .or
+ vp_BINop_instruction .emit OP_ALU_BIN .or
+ vp_TRIop_instruction .emit OP_ALU_TRI .or
+ vp_SWZ_instruction .emit OP_ALU_SWZ;
+
+/*
+fragment program
+ <ALUInstruction> ::= <VECTORop_instruction>
+ | <SCALARop_instruction>
+ | <BINSCop_instruction>
+ | <BINop_instruction>
+ | <TRIop_instruction>
+ | <SWZ_instruction>
+*/
+ALUInstruction
+ fp_VECTORop_instruction .emit OP_ALU_VECTOR .or
+ fp_SCALARop_instruction .emit OP_ALU_SCALAR .or
+ fp_BINSCop_instruction .emit OP_ALU_BINSC .or
+ fp_BINop_instruction .emit OP_ALU_BIN .or
+ fp_TRIop_instruction .emit OP_ALU_TRI .or
+ fp_SWZ_instruction .emit OP_ALU_SWZ;
+
+/*
+fragment program
+ <TexInstruction> ::= <SAMPLE_instruction>
+ | <KIL_instruction>
+*/
+TexInstruction
+ SAMPLE_instruction .emit OP_TEX_SAMPLE .or
+ KIL_instruction .emit OP_TEX_KIL;
+
+/*
+vertex program
+ <ARL_instruction> ::= "ARL" <maskedAddrReg> "," <scalarSrcReg>
+*/
+ARL_instruction
+ "ARL" .emit OP_ARL .and space_dst .and maskedAddrReg .and comma .and vp_scalarSrcReg;
+
+/*
+fragment program
+ <VECTORop_instruction> ::= <VECTORop> <maskedDstReg> ","
+ <vectorSrcReg>
+
+vertex program
+ <VECTORop_instruction> ::= <VECTORop> <maskedDstReg> "," <swizzleSrcReg>
+*/
+fp_VECTORop_instruction
+ fp_VECTORop .and space_dst .and fp_maskedDstReg .and comma .and vectorSrcReg;
+vp_VECTORop_instruction
+ vp_VECTORop .and space_dst .and vp_maskedDstReg .and comma .and swizzleSrcReg;
+
+/*
+fragment program
+ <VECTORop> ::= "ABS" | "ABS_SAT"
+ | "FLR" | "FLR_SAT"
+ | "FRC" | "FRC_SAT"
+ | "LIT" | "LIT_SAT"
+ | "MOV" | "MOV_SAT"
+
+vertex program
+ <VECTORop> ::= "ABS"
+ | "FLR"
+ | "FRC"
+ | "LIT"
+ | "MOV"
+*/
+fp_VECTORop
+ "ABS" .emit OP_ABS .or "ABS_SAT" .emit OP_ABS_SAT .or
+ "FLR" .emit OP_FLR .or "FLR_SAT" .emit OP_FLR_SAT .or
+ "FRC" .emit OP_FRC .or "FRC_SAT" .emit OP_FRC_SAT .or
+ "LIT" .emit OP_LIT .or "LIT_SAT" .emit OP_LIT_SAT .or
+ "MOV" .emit OP_MOV .or "MOV_SAT" .emit OP_MOV_SAT;
+vp_VECTORop
+ "ABS" .emit OP_ABS .or
+ "FLR" .emit OP_FLR .or
+ "FRC" .emit OP_FRC .or
+ "LIT" .emit OP_LIT .or
+ "MOV" .emit OP_MOV;
+
+/*
+ <SCALARop_instruction> ::= <SCALARop> <maskedDstReg> "," <scalarSrcReg>
+*/
+fp_SCALARop_instruction
+ fp_SCALARop .and space_dst .and fp_maskedDstReg .and comma .and fp_scalarSrcReg;
+vp_SCALARop_instruction
+ vp_SCALARop .and space_dst .and vp_maskedDstReg .and comma .and vp_scalarSrcReg;
+
+/*
+fragment program
+ <SCALARop> ::= "COS" | "COS_SAT"
+ | "EX2" | "EX2_SAT"
+ | "LG2" | "LG2_SAT"
+ | "RCP" | "RCP_SAT"
+ | "RSQ" | "RSQ_SAT"
+ | "SIN" | "SIN_SAT"
+ | "SCS" | "SCS_SAT"
+
+vertex program
+ <SCALARop> ::= "EX2"
+ | "EXP"
+ | "LG2"
+ | "LOG"
+ | "RCP"
+ | "RSQ"
+*/
+fp_SCALARop
+ "COS" .emit OP_COS .or "COS_SAT" .emit OP_COS_SAT .or
+ "EX2" .emit OP_EX2 .or "EX2_SAT" .emit OP_EX2_SAT .or
+ "LG2" .emit OP_LG2 .or "LG2_SAT" .emit OP_LG2_SAT .or
+ "RCP" .emit OP_RCP .or "RCP_SAT" .emit OP_RCP_SAT .or
+ "RSQ" .emit OP_RSQ .or "RSQ_SAT" .emit OP_RSQ_SAT .or
+ "SIN" .emit OP_SIN .or "SIN_SAT" .emit OP_SIN_SAT .or
+ "SCS" .emit OP_SCS .or "SCS_SAT" .emit OP_SCS_SAT;
+vp_SCALARop
+ "EX2" .emit OP_EX2 .or
+ "EXP" .emit OP_EXP .or
+ "LG2" .emit OP_LG2 .or
+ "LOG" .emit OP_LOG .or
+ "RCP" .emit OP_RCP .or
+ "RSQ" .emit OP_RSQ;
+
+/*
+ <BINSCop_instruction> ::= <BINSCop> <maskedDstReg> "," <scalarSrcReg> ","
+ <scalarSrcReg>
+*/
+fp_BINSCop_instruction
+ fp_BINSCop .and space_dst .and fp_maskedDstReg .and comma .and fp_scalarSrcReg .and comma .and
+ fp_scalarSrcReg;
+vp_BINSCop_instruction
+ vp_BINSCop .and space_dst .and vp_maskedDstReg .and comma .and vp_scalarSrcReg .and comma .and
+ vp_scalarSrcReg;
+
+/*
+fragment program
+ <BINSCop> ::= "POW" | "POW_SAT"
+
+vertex program
+ <BINSCop> ::= "POW"
+*/
+fp_BINSCop
+ "POW" .emit OP_POW .or "POW_SAT" .emit OP_POW_SAT;
+vp_BINSCop
+ "POW" .emit OP_POW;
+
+/*
+fragment program
+ <BINop_instruction> ::= <BINop> <maskedDstReg> ","
+ <vectorSrcReg> "," <vectorSrcReg>
+
+vertex program
+ <BINop_instruction> ::= <BINop> <maskedDstReg> ","
+ <swizzleSrcReg> "," <swizzleSrcReg>
+*/
+fp_BINop_instruction
+ fp_BINop .and space_dst .and fp_maskedDstReg .and comma .and vectorSrcReg .and comma .and
+ vectorSrcReg;
+vp_BINop_instruction
+ vp_BINop .and space_dst .and vp_maskedDstReg .and comma .and swizzleSrcReg .and comma .and
+ swizzleSrcReg;
+
+/*
+fragment program
+ <BINop> ::= "ADD" | "ADD_SAT"
+ | "DP3" | "DP3_SAT"
+ | "DP4" | "DP4_SAT"
+ | "DPH" | "DPH_SAT"
+ | "DST" | "DST_SAT"
+ | "MAX" | "MAX_SAT"
+ | "MIN" | "MIN_SAT"
+ | "MUL" | "MUL_SAT"
+ | "SGE" | "SGE_SAT"
+ | "SLT" | "SLT_SAT"
+ | "SUB" | "SUB_SAT"
+ | "XPD" | "XPD_SAT"
+
+vertex program
+ <BINop> ::= "ADD"
+ | "DP3"
+ | "DP4"
+ | "DPH"
+ | "DST"
+ | "MAX"
+ | "MIN"
+ | "MUL"
+ | "SGE"
+ | "SLT"
+ | "SUB"
+ | "XPD"
+*/
+fp_BINop
+ "ADD" .emit OP_ADD .or "ADD_SAT" .emit OP_ADD_SAT .or
+ "DP3" .emit OP_DP3 .or "DP3_SAT" .emit OP_DP3_SAT .or
+ "DP4" .emit OP_DP4 .or "DP4_SAT" .emit OP_DP4_SAT .or
+ "DPH" .emit OP_DPH .or "DPH_SAT" .emit OP_DPH_SAT .or
+ "DST" .emit OP_DST .or "DST_SAT" .emit OP_DST_SAT .or
+ "MAX" .emit OP_MAX .or "MAX_SAT" .emit OP_MAX_SAT .or
+ "MIN" .emit OP_MIN .or "MIN_SAT" .emit OP_MIN_SAT .or
+ "MUL" .emit OP_MUL .or "MUL_SAT" .emit OP_MUL_SAT .or
+ "SGE" .emit OP_SGE .or "SGE_SAT" .emit OP_SGE_SAT .or
+ "SLT" .emit OP_SLT .or "SLT_SAT" .emit OP_SLT_SAT .or
+ "SUB" .emit OP_SUB .or "SUB_SAT" .emit OP_SUB_SAT .or
+ "XPD" .emit OP_XPD .or "XPD_SAT" .emit OP_XPD_SAT;
+vp_BINop
+ "ADD" .emit OP_ADD .or
+ "DP3" .emit OP_DP3 .or
+ "DP4" .emit OP_DP4 .or
+ "DPH" .emit OP_DPH .or
+ "DST" .emit OP_DST .or
+ "MAX" .emit OP_MAX .or
+ "MIN" .emit OP_MIN .or
+ "MUL" .emit OP_MUL .or
+ "SGE" .emit OP_SGE .or
+ "SLT" .emit OP_SLT .or
+ "SUB" .emit OP_SUB .or
+ "XPD" .emit OP_XPD;
+
+/*
+fragment program
+ <TRIop_instruction> ::= <TRIop> <maskedDstReg> ","
+ <vectorSrcReg> "," <vectorSrcReg> ","
+ <vectorSrcReg>
+
+vertex program
+ <TRIop_instruction> ::= <TRIop> <maskedDstReg> ","
+ <swizzleSrcReg> "," <swizzleSrcReg> ","
+ <swizzleSrcReg>
+*/
+fp_TRIop_instruction
+ fp_TRIop .and space_dst .and fp_maskedDstReg .and comma .and vectorSrcReg .and comma .and
+ vectorSrcReg .and comma .and vectorSrcReg;
+vp_TRIop_instruction
+ vp_TRIop .and space_dst .and vp_maskedDstReg .and comma .and swizzleSrcReg .and comma .and
+ swizzleSrcReg .and comma .and swizzleSrcReg;
+
+/*
+fragment program
+ <TRIop> ::= "CMP" | "CMP_SAT"
+ | "LRP" | "LRP_SAT"
+ | "MAD" | "MAD_SAT"
+
+vertex program
+ <TRIop> ::= "MAD"
+*/
+fp_TRIop
+ "CMP" .emit OP_CMP .or "CMP_SAT" .emit OP_CMP_SAT .or
+ "LRP" .emit OP_LRP .or "LRP_SAT" .emit OP_LRP_SAT .or
+ "MAD" .emit OP_MAD .or "MAD_SAT" .emit OP_MAD_SAT;
+vp_TRIop
+ "MAD" .emit OP_MAD;
+
+/*
+fragment program
+ <SWZ_instruction> ::= <SWZop> <maskedDstReg> ","
+ <srcReg> "," <extendedSwizzle>
+
+vertex program
+ <SWZ_instruction> ::= "SWZ" <maskedDstReg> "," <srcReg> ","
+ <extendedSwizzle>
+*/
+fp_SWZ_instruction
+ SWZop .and space_dst .and fp_maskedDstReg .and comma .and fp_srcReg .and comma .and
+ fp_extendedSwizzle .error EXT_SWIZ_COMP_EXPECTED;
+vp_SWZ_instruction
+ "SWZ" .emit OP_SWZ .and space_dst .and vp_maskedDstReg .and comma .and vp_srcReg .and comma .and
+ vp_extendedSwizzle .error EXT_SWIZ_COMP_EXPECTED;
+
+/*
+fragment program
+ <SWZop> ::= "SWZ" | "SWZ_SAT"
+*/
+SWZop
+ "SWZ" .emit OP_SWZ .or "SWZ_SAT" .emit OP_SWZ_SAT;
+
+/*
+fragment program
+ <SAMPLE_instruction> ::= <SAMPLEop> <maskedDstReg> ","
+ <vectorSrcReg> "," <texImageUnit> ","
+ <texTarget>
+*/
+SAMPLE_instruction
+ SAMPLEop .and space_dst .and fp_maskedDstReg .and comma .and vectorSrcReg .and comma .and
+ texImageUnit .and comma .and texTarget .error TEX_TARGET_EXPECTED;
+
+/*
+fragment program
+ <SAMPLEop> ::= "TEX" | "TEX_SAT"
+ | "TXP" | "TXP_SAT"
+ | "TXB" | "TXB_SAT"
+*/
+SAMPLEop
+ "TEX" .emit OP_TEX .or "TEX_SAT" .emit OP_TEX_SAT .or
+ "TXB" .emit OP_TXB .or "TXB_SAT" .emit OP_TXB_SAT .or
+ "TXP" .emit OP_TXP .or "TXP_SAT" .emit OP_TXP_SAT;
+
+/*
+fragment program
+ <KIL_instruction> ::= "KIL" <vectorSrcReg>
+*/
+KIL_instruction
+ "KIL" .emit OP_KIL .and space_src .and vectorSrcReg;
+
+/*
+fragment program
+ <texImageUnit> ::= "texture" <optTexImageUnitNum>
+*/
+texImageUnit
+ "texture" .error TEXTURE_EXPECTED .and optTexImageUnitNum;
+
+/*
+fragment program
+ <texTarget> ::= "1D"
+ | "2D"
+ | "3D"
+ | "CUBE"
+ | "RECT"
+ | <shadowTarget> (if option ARB_fragment_program_shadow present)
+*/
+texTarget
+ "1D" .emit TEXTARGET_1D .or
+ "2D" .emit TEXTARGET_2D .or
+ "3D" .emit TEXTARGET_3D .or
+ .if (texture_rectangle != 0x00) "RECT" .emit TEXTARGET_RECT .or
+ "CUBE" .emit TEXTARGET_CUBE .or
+ .if (ARB_fragment_program_shadow != 0x00) shadowTarget;
+
+/*
+GL_ARB_fragment_program_shadow
+ <shadowTarget> ::= "SHADOW1D"
+ | "SHADOW2D"
+ | "SHADOWRECT"
+*/
+shadowTarget
+ "SHADOW1D" .emit TEXTARGET_SHADOW1D .or
+ "SHADOW2D" .emit TEXTARGET_SHADOW2D .or
+ .if (texture_rectangle != 0x00) "SHADOWRECT" .emit TEXTARGET_SHADOWRECT;
+
+/*
+fragment program
+ <optTexImageUnitNum> ::= ""
+ | "[" <texImageUnitNum> "]"
+*/
+optTexImageUnitNum
+ optTexImageUnitNum_1 .or .true .emit 0x00;
+optTexImageUnitNum_1
+ lbracket_ne .and texImageUnitNum .and rbracket;
+
+/*
+fragment program
+ <texImageUnitNum> ::= <integer> from 0 to
+ MAX_TEXTURE_IMAGE_UNITS_ARB-1
+*/
+texImageUnitNum
+ integer;
+
+/*
+ <scalarSrcReg> ::= <optionalSign> <srcReg> <scalarSuffix>
+*/
+fp_scalarSrcReg
+ optionalSign .and fp_srcReg .and fp_scalarSuffix;
+vp_scalarSrcReg
+ optionalSign .and vp_srcReg .and vp_scalarSuffix;
+
+/*
+vertex program
+ <swizzleSrcReg> ::= <optionalSign> <srcReg> <swizzleSuffix>
+*/
+swizzleSrcReg
+ optionalSign .and vp_srcReg .and swizzleSuffix;
+
+/*
+fragment program
+ <vectorSrcReg> ::= <optionalSign> <srcReg> <optionalSuffix>
+*/
+vectorSrcReg
+ optionalSign .and fp_srcReg .and optionalSuffix;
+
+/*
+ <maskedDstReg> ::= <dstReg> <optionalMask>
+*/
+fp_maskedDstReg
+ fp_dstReg .and fp_optionalMask;
+vp_maskedDstReg
+ vp_dstReg .and vp_optionalMask;
+
+/*
+vertex program
+ <maskedAddrReg> ::= <addrReg> <addrWriteMask>
+*/
+maskedAddrReg
+ addrReg .error ADDRESS_REGISTER_EXPECTED .and addrWriteMask;
+
+/*
+fragment program
+ <extendedSwizzle> ::= <xyzwExtendedSwizzle>
+ | <rgbaExtendedSwizzle>
+
+vertex program
+ <extendedSwizzle> ::= <extSwizComp> "," <extSwizComp> ","
+ <extSwizComp> "," <extSwizComp>
+
+NOTE: do NOT change the order of <rgbaExtendedSwizzle> and <xyzwExtendedSwizzle> rulez
+*/
+fp_extendedSwizzle
+ rgbaExtendedSwizzle .or xyzwExtendedSwizzle;
+vp_extendedSwizzle
+ extSwizComp .and comma .and
+ extSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
+ extSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
+ extSwizComp .error EXT_SWIZ_COMP_EXPECTED;
+
+/*
+fragment program
+ <xyzwExtendedSwizzle> ::= <xyzwExtSwizComp> "," <xyzwExtSwizComp> ","
+ <xyzwExtSwizComp> "," <xyzwExtSwizComp>
+*/
+xyzwExtendedSwizzle
+ xyzwExtSwizComp .and comma .and
+ xyzwExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
+ xyzwExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
+ xyzwExtSwizComp .error EXT_SWIZ_COMP_EXPECTED;
+
+/*
+fragment program
+ <rgbaExtendedSwizzle> ::= <rgbaExtSwizComp> "," <rgbaExtSwizComp> ","
+ <rgbaExtSwizComp> "," <rgbaExtSwizComp>
+*/
+rgbaExtendedSwizzle
+ rgbaExtendedSwizzle_1 .or rgbaExtendedSwizzle_2 .or rgbaExtendedSwizzle_3 .or
+ rgbaExtendedSwizzle_4;
+rgbaExtendedSwizzle_1
+ rgbaExtSwizComp_digit .and comma .and rgbaExtSwizComp_digit .and comma .and
+ rgbaExtSwizComp_digit .and comma .and rgbaExtSwizComp;
+rgbaExtendedSwizzle_2
+ rgbaExtSwizComp_digit .and comma .and rgbaExtSwizComp_digit .and comma .and
+ rgbaExtSwizComp_alpha .and comma .and rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED;
+rgbaExtendedSwizzle_3
+ rgbaExtSwizComp_digit .and comma .and rgbaExtSwizComp_alpha .and comma .and
+ rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
+ rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED;
+rgbaExtendedSwizzle_4
+ rgbaExtSwizComp_alpha .and comma .and
+ rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
+ rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and
+ rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED;
+
+/*
+fragment program
+ <xyzwExtSwizComp> ::= <optionalSign> <xyzwExtSwizSel>
+*/
+xyzwExtSwizComp
+ optionalSign .and xyzwExtSwizSel;
+
+/*
+fragment program
+ <rgbaExtSwizComp> ::= <optionalSign> <rgbaExtSwizSel>
+*/
+rgbaExtSwizComp
+ optionalSign .and rgbaExtSwizSel;
+rgbaExtSwizComp_digit
+ optionalSign .and rgbaExtSwizSel_digit;
+rgbaExtSwizComp_alpha
+ optionalSign .and rgbaExtSwizSel_alpha;
+
+/*
+vertex program
+ <extSwizComp> ::= <optionalSign> <extSwizSel>
+*/
+extSwizComp
+ optionalSign .and extSwizSel;
+
+/*
+fragment program
+ <xyzwExtSwizSel> ::= "0"
+ | "1"
+ | <xyzwComponent>
+*/
+xyzwExtSwizSel
+ "0" .emit COMPONENT_0 .or "1" .emit COMPONENT_1 .or xyzwComponent_single;
+
+/*
+fragment program
+ <rgbaExtSwizSel> ::= "0"
+ | "1"
+ | <rgbaComponent>
+*/
+rgbaExtSwizSel
+ rgbaExtSwizSel_digit .or rgbaExtSwizSel_alpha;
+rgbaExtSwizSel_digit
+ "0" .emit COMPONENT_0 .or "1" .emit COMPONENT_1;
+rgbaExtSwizSel_alpha
+ rgbaComponent_single;
+
+/*
+vertex program
+ <extSwizSel> ::= "0"
+ | "1"
+ | <component>
+*/
+extSwizSel
+ "0" .emit COMPONENT_0 .or "1" .emit COMPONENT_1 .or vp_component_single;
+
+/*
+fragment program
+ <srcReg> ::= <fragmentAttribReg>
+ | <temporaryReg>
+ | <progParamReg>
+
+vertex program
+ <srcReg> ::= <vertexAttribReg>
+ | <temporaryReg>
+ | <progParamReg>
+*/
+fp_srcReg
+ fp_srcReg_1 .error SOURCE_REGISTER_EXPECTED;
+vp_srcReg
+ vp_srcReg_1 .error SOURCE_REGISTER_EXPECTED;
+fp_srcReg_1
+ fragmentAttribReg .emit REGISTER_ATTRIB .or
+ fp_progParamReg .emit REGISTER_PARAM .or
+ fp_temporaryReg .emit REGISTER_ESTABLISHED_NAME;
+vp_srcReg_1
+ vertexAttribReg .emit REGISTER_ATTRIB .or
+ vp_progParamReg .emit REGISTER_PARAM .or
+ vp_temporaryReg .emit REGISTER_ESTABLISHED_NAME;
+
+/*
+fragment program
+ <dstReg> ::= <temporaryReg>
+ | <fragmentResultReg>
+
+vertex program
+ <dstReg> ::= <temporaryReg>
+ | <vertexResultReg>
+*/
+fp_dstReg
+ fp_dstReg_1 .error DESTINATION_REGISTER_EXPECTED;
+vp_dstReg
+ vp_dstReg_1 .error DESTINATION_REGISTER_EXPECTED;
+fp_dstReg_1
+ fragmentResultReg .emit REGISTER_RESULT .or
+ fp_temporaryReg .emit REGISTER_ESTABLISHED_NAME;
+vp_dstReg_1
+ vertexResultReg .emit REGISTER_RESULT .or
+ vp_temporaryReg .emit REGISTER_ESTABLISHED_NAME;
+
+/*
+fragment program
+ <fragmentAttribReg> ::= <establishedName>
+ | <fragAttribBinding>
+
+NOTE: <establishedName> is driven by <temporaryReg> rule at the end of <srcReg>
+*/
+fragmentAttribReg
+ /*fp_establishedName .or */fragAttribBinding;
+
+/*
+vertex program
+ <vertexAttribReg> ::= <establishedName>
+ | <vtxAttribBinding>
+
+NOTE: <establishedName> is driven by <temporaryReg> rule at the end of <srcReg>
+*/
+vertexAttribReg
+ vtxAttribBinding;
+
+/*
+ <temporaryReg> ::= <establishedName>
+*/
+fp_temporaryReg
+ fp_establishedName_no_error_on_identifier;
+vp_temporaryReg
+ vp_establishedName_no_error_on_identifier;
+
+/*
+fragment program
+ <progParamReg> ::= <progParamSingle>
+ | <progParamArray> "[" <progParamArrayAbs> "]"
+ | <paramSingleItemUse>
+
+vertex program
+ <progParamReg> ::= <progParamSingle>
+ | <progParamArray> "[" <progParamArrayMem> "]"
+ | <paramSingleItemUse>
+*/
+fp_progParamReg
+ fp_paramSingleItemUse .or fp_progParamReg_1 .or fp_progParamSingle;
+vp_progParamReg
+ vp_paramSingleItemUse .or vp_progParamReg_1 .or vp_progParamSingle;
+fp_progParamReg_1
+ fp_progParamArray .emit PARAM_ARRAY_ELEMENT .and lbracket_ne .and progParamArrayAbs .and
+ rbracket;
+vp_progParamReg_1
+ vp_progParamArray .emit PARAM_ARRAY_ELEMENT .and lbracket_ne .and progParamArrayMem .and
+ rbracket;
+
+/*
+ <progParamSingle> ::= <establishedName>
+
+NOTE: <establishedName> is driven by <temporaryReg> rule at the end of <srcReg>
+*/
+fp_progParamSingle
+ .false;
+vp_progParamSingle
+ .false;
+
+/*
+ <progParamArray> ::= <establishedName>
+*/
+fp_progParamArray
+ fp_establishedName_no_error_on_identifier;
+vp_progParamArray
+ vp_establishedName_no_error_on_identifier;
+
+/*
+vertex program
+ <progParamArrayMem> ::= <progParamArrayAbs>
+ | <progParamArrayRel>
+*/
+progParamArrayMem
+ progParamArrayAbs .or progParamArrayRel;
+
+/*
+ <progParamArrayAbs> ::= <integer>
+*/
+progParamArrayAbs
+ integer_ne .emit ARRAY_INDEX_ABSOLUTE;
+
+/*
+vertex program
+ <progParamArrayRel> ::= <addrReg> <addrComponent> <addrRegRelOffset>
+*/
+progParamArrayRel
+ addrReg .error ADDRESS_REGISTER_OR_INTEGER_EXPECTED .emit ARRAY_INDEX_RELATIVE .and
+ addrComponent .and addrRegRelOffset;
+
+/*
+vertex program
+ <addrRegRelOffset> ::= ""
+ | "+" <addrRegPosOffset>
+ | "-" <addrRegNegOffset>
+*/
+addrRegRelOffset
+ addrRegRelOffset_1 .or addrRegRelOffset_2 .or .true .emit 0x00;
+addrRegRelOffset_1
+ plus_ne .and addrRegPosOffset;
+addrRegRelOffset_2
+ minus_ne .and addrRegNegOffset;
+
+/*
+vertex program
+ <addrRegPosOffset> ::= <integer> from 0 to 63
+*/
+addrRegPosOffset
+ integer_0_63;
+
+/*
+vertex program
+ <addrRegNegOffset> ::= <integer> from 0 to 64
+*/
+addrRegNegOffset
+ integer_0_64;
+
+/*
+fragment program
+ <fragmentResultReg> ::= <establishedName>
+ | <resultBinding>
+
+NOTE: <establishedName> is driven by <temporaryReg> rule at the end of <dstReg>
+*/
+fragmentResultReg
+ fp_resultBinding;
+
+/*
+vertex program
+ <vertexResultReg> ::= <establishedName>
+ | <resultBinding>
+
+NOTE: <establishedName> is driven by <temporaryReg> rule at the end of <dstReg>
+*/
+vertexResultReg
+ vp_resultBinding;
+
+/*
+vertex program
+ <addrReg> ::= <establishedName>
+*/
+addrReg
+ vp_establishedName_no_error_on_identifier;
+
+/*
+vertex program
+ <addrComponent> ::= "." "x"
+*/
+addrComponent
+ dot .and "x" .error INVALID_ADDRESS_COMPONENT .emit COMPONENT_X .emit COMPONENT_X
+ .emit COMPONENT_X .emit COMPONENT_X;
+
+/*
+vertex program
+ <addrWriteMask> ::= "." "x"
+*/
+addrWriteMask
+ dot .and "x" .error INVALID_ADDRESS_WRITEMASK .emit 0x08;
+
+/*
+ <scalarSuffix> ::= "." <component>
+*/
+fp_scalarSuffix
+ dot .and fp_component_single .error INVALID_COMPONENT;
+vp_scalarSuffix
+ dot .and vp_component_single .error INVALID_COMPONENT;
+
+/*
+vertex program
+ <swizzleSuffix> ::= ""
+ | "." <component>
+ | "." <component> <component>
+ <component> <component>
+*/
+swizzleSuffix
+ swizzleSuffix_1 .or
+ .true .emit COMPONENT_X .emit COMPONENT_Y .emit COMPONENT_Z .emit COMPONENT_W;
+swizzleSuffix_1
+ dot_ne .and swizzleSuffix_2 .error INVALID_SUFFIX;
+swizzleSuffix_2
+ swizzleSuffix_3 .or swizzleSuffix_4;
+swizzleSuffix_3
+ vp_component_multi .and vp_component_multi .and vp_component_multi .error INVALID_COMPONENT .and
+ vp_component_multi .error INVALID_COMPONENT;
+swizzleSuffix_4
+ "x" .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .or
+ "y" .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .or
+ "z" .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .or
+ "w" .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W;
+
+/*
+fragment program
+ <optionalSuffix> ::= ""
+ | "." <component>
+ | "." <xyzwComponent> <xyzwComponent>
+ <xyzwComponent> <xyzwComponent>
+ | "." <rgbaComponent> <rgbaComponent>
+ <rgbaComponent> <rgbaComponent>
+*/
+optionalSuffix
+ optionalSuffix_1 .or
+ .true .emit COMPONENT_X .emit COMPONENT_Y .emit COMPONENT_Z .emit COMPONENT_W;
+optionalSuffix_1
+ dot_ne .and optionalSuffix_2 .error INVALID_SUFFIX;
+optionalSuffix_2
+ optionalSuffix_3 .or optionalSuffix_4 .or optionalSuffix_5;
+optionalSuffix_3
+ xyzwComponent_multi .and xyzwComponent_multi .and
+ xyzwComponent_multi .error INVALID_COMPONENT .and xyzwComponent_multi .error INVALID_COMPONENT;
+optionalSuffix_4
+ rgbaComponent_multi .and rgbaComponent_multi .and
+ rgbaComponent_multi .error INVALID_COMPONENT .and rgbaComponent_multi .error INVALID_COMPONENT;
+optionalSuffix_5
+ "x" .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .or
+ "y" .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .or
+ "z" .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .or
+ "w" .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W .or
+ "r" .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .or
+ "g" .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .or
+ "b" .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .or
+ "a" .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W;
+
+/*
+fragment program
+ <component> ::= <xyzwComponent>
+ | <rgbaComponent>
+
+vertex program
+ <component> ::= "x"
+ | "y"
+ | "z"
+ | "w"
+*/
+fp_component_single
+ xyzwComponent_single .or rgbaComponent_single;
+vp_component_multi
+ 'x' .emit COMPONENT_X .or 'y' .emit COMPONENT_Y .or 'z' .emit COMPONENT_Z .or
+ 'w' .emit COMPONENT_W;
+vp_component_single
+ "x" .emit COMPONENT_X .or "y" .emit COMPONENT_Y .or "z" .emit COMPONENT_Z .or
+ "w" .emit COMPONENT_W;
+
+/*
+fragment program
+ <xyzwComponent> ::= "x" | "y" | "z" | "w"
+*/
+xyzwComponent_multi
+ 'x' .emit COMPONENT_X .or 'y' .emit COMPONENT_Y .or 'z' .emit COMPONENT_Z .or
+ 'w' .emit COMPONENT_W;
+xyzwComponent_single
+ "x" .emit COMPONENT_X .or "y" .emit COMPONENT_Y .or "z" .emit COMPONENT_Z .or
+ "w" .emit COMPONENT_W;
+
+/*
+fragment program
+ <rgbaComponent> ::= "r" | "g" | "b" | "a"
+*/
+rgbaComponent_multi
+ 'r' .emit COMPONENT_X .or 'g' .emit COMPONENT_Y .or 'b' .emit COMPONENT_Z .or
+ 'a' .emit COMPONENT_W;
+rgbaComponent_single
+ "r" .emit COMPONENT_X .or "g" .emit COMPONENT_Y .or "b" .emit COMPONENT_Z .or
+ "a" .emit COMPONENT_W;
+
+/*
+fragment program
+ <optionalMask> ::= ""
+ | <xyzwMask>
+ | <rgbaMask>
+
+vertex program
+ <optionalMask> ::= ""
+ | "." "x"
+ | "." "y"
+ | "." "xy"
+ | "." "z"
+ | "." "xz"
+ | "." "yz"
+ | "." "xyz"
+ | "." "w"
+ | "." "xw"
+ | "." "yw"
+ | "." "xyw"
+ | "." "zw"
+ | "." "xzw"
+ | "." "yzw"
+ | "." "xyzw"
+
+NOTE: do NOT change the order of <rgbaMask> and <xyzwMask> rulez
+*/
+fp_optionalMask
+ rgbaMask .or xyzwMask .or .true .emit 0x0F;
+vp_optionalMask
+ xyzwMask .or .true .emit 0x0F;
+
+/*
+fragment program
+ <xyzwMask> ::= "." "x"
+ | "." "y"
+ | "." "xy"
+ | "." "z"
+ | "." "xz"
+ | "." "yz"
+ | "." "xyz"
+ | "." "w"
+ | "." "xw"
+ | "." "yw"
+ | "." "xyw"
+ | "." "zw"
+ | "." "xzw"
+ | "." "yzw"
+ | "." "xyzw"
+
+NOTE: <xyzwMask> is also referenced by the vertex program symbol <optionalMask>.
+*/
+xyzwMask
+ dot_ne .and xyzwMask_1 .error INVALID_WRITEMASK;
+xyzwMask_1
+ "xyzw" .emit 0x0F .or "xyz" .emit 0x0E .or "xyw" .emit 0x0D .or "xy" .emit 0x0C .or
+ "xzw" .emit 0x0B .or "xz" .emit 0x0A .or "xw" .emit 0x09 .or "x" .emit 0x08 .or
+ "yzw" .emit 0x07 .or "yz" .emit 0x06 .or "yw" .emit 0x05 .or "y" .emit 0x04 .or
+ "zw" .emit 0x03 .or "z" .emit 0x02 .or "w" .emit 0x01;
+
+/*
+fragment program
+ <rgbaMask> ::= "." "r"
+ | "." "g"
+ | "." "rg"
+ | "." "b"
+ | "." "rb"
+ | "." "gb"
+ | "." "rgb"
+ | "." "a"
+ | "." "ra"
+ | "." "ga"
+ | "." "rga"
+ | "." "ba"
+ | "." "rba"
+ | "." "gba"
+ | "." "rgba"
+*/
+rgbaMask
+ dot_ne .and rgbaMask_1;
+rgbaMask_1
+ "rgba" .emit 0x0F .or "rgb" .emit 0x0E .or "rga" .emit 0x0D .or "rg" .emit 0x0C .or
+ "rba" .emit 0x0B .or "rb" .emit 0x0A .or "ra" .emit 0x09 .or "r" .emit 0x08 .or
+ "gba" .emit 0x07 .or "gb" .emit 0x06 .or "ga" .emit 0x05 .or "g" .emit 0x04 .or
+ "ba" .emit 0x03 .or "b" .emit 0x02 .or "a" .emit 0x01;
+
+/*
+fragment program
+ <namingStatement> ::= <ATTRIB_statement>
+ | <PARAM_statement>
+ | <TEMP_statement>
+ | <OUTPUT_statement>
+ | <ALIAS_statement>
+
+vertex program
+ <namingStatement> ::= <ATTRIB_statement>
+ | <PARAM_statement>
+ | <TEMP_statement>
+ | <ADDRESS_statement>
+ | <OUTPUT_statement>
+ | <ALIAS_statement>
+*/
+fp_namingStatement
+ fp_ATTRIB_statement .emit ATTRIB .or
+ fp_PARAM_statement .emit PARAM .or
+ fp_TEMP_statement .emit TEMP .or
+ fp_OUTPUT_statement .emit OUTPUT .or
+ fp_ALIAS_statement .emit ALIAS;
+vp_namingStatement
+ vp_ATTRIB_statement .emit ATTRIB .or
+ vp_PARAM_statement .emit PARAM .or
+ vp_TEMP_statement .emit TEMP .or
+ ADDRESS_statement .emit ADDRESS .or
+ vp_OUTPUT_statement .emit OUTPUT .or
+ vp_ALIAS_statement .emit ALIAS;
+
+/*
+fragment program
+ <ATTRIB_statement> ::= "ATTRIB" <establishName> "="
+ <fragAttribBinding>
+
+vertex program
+ <ATTRIB_statement> ::= "ATTRIB" <establishName> "="
+ <vtxAttribBinding>
+*/
+fp_ATTRIB_statement
+ "ATTRIB" .and space .and fp_establishName .and equal .and
+ fragAttribBinding .error FRAGMENT_EXPECTED;
+vp_ATTRIB_statement
+ "ATTRIB" .and space .and vp_establishName .and equal .and
+ vtxAttribBinding .error VERTEX_EXPECTED;
+
+/*
+fragment program
+ <fragAttribBinding> ::= "fragment" "." <fragAttribItem>
+*/
+fragAttribBinding
+ "fragment" .and dot .and fragAttribItem .error INVALID_FRAGMENT_PROPERTY;
+
+/*
+vertex program
+ <vtxAttribBinding> ::= "vertex" "." <vtxAttribItem>
+*/
+vtxAttribBinding
+ "vertex" .and dot .and vtxAttribItem .error INVALID_VERTEX_PROPERTY;
+
+/*
+fragment program
+ <fragAttribItem> ::= "color" <optColorType>
+ | "texcoord" <optTexCoordNum>
+ | "fogcoord"
+ | "position"
+*/
+fragAttribItem
+ fragAttribItem_1 .emit FRAGMENT_ATTRIB_COLOR .or
+ fragAttribItem_2 .emit FRAGMENT_ATTRIB_TEXCOORD .or
+ .if (fog_coord != 0x00) "fogcoord" .emit FRAGMENT_ATTRIB_FOGCOORD .or
+ "position" .emit FRAGMENT_ATTRIB_POSITION;
+fragAttribItem_1
+ "color" .and optColorType;
+fragAttribItem_2
+ "texcoord" .and optTexCoordNum;
+
+/*
+vertex program
+ <vtxAttribItem> ::= "position"
+ | "weight" <vtxOptWeightNum>
+ | "normal"
+ | "color" <optColorType>
+ | "fogcoord"
+ | "texcoord" <optTexCoordNum>
+ | "matrixindex" "[" <vtxWeightNum> "]"
+ | "attrib" "[" <vtxAttribNum> "]"
+*/
+vtxAttribItem
+ "position" .emit VERTEX_ATTRIB_POSITION .or
+ .if (vertex_blend != 0x00) vtxAttribItem_1 .emit VERTEX_ATTRIB_WEIGHT .or
+ "normal" .emit VERTEX_ATTRIB_NORMAL .or
+ vtxAttribItem_2 .emit VERTEX_ATTRIB_COLOR .or
+ "fogcoord" .emit VERTEX_ATTRIB_FOGCOORD .or
+ vtxAttribItem_3 .emit VERTEX_ATTRIB_TEXCOORD .or
+ .if (matrix_palette != 0x00) vtxAttribItem_4 .emit VERTEX_ATTRIB_MATRIXINDEX .or
+ vtxAttribItem_5 .emit VERTEX_ATTRIB_GENERIC;
+vtxAttribItem_1
+ "weight" .and vtxOptWeightNum;
+vtxAttribItem_2
+ "color" .and optColorType;
+vtxAttribItem_3
+ "texcoord" .and optTexCoordNum;
+vtxAttribItem_4
+ "matrixindex" .and lbracket .and vtxWeightNum .and rbracket;
+vtxAttribItem_5
+ "attrib" .and lbracket .and vtxAttribNum .and rbracket;
+
+/*
+vertex program
+ <vtxAttribNum> ::= <integer> from 0 to MAX_VERTEX_ATTRIBS_ARB-1
+*/
+vtxAttribNum
+ integer;
+
+/*
+vertex program
+ <vtxOptWeightNum> ::= ""
+ | "[" <vtxWeightNum> "]"
+*/
+vtxOptWeightNum
+ vtxOptWeightNum_1 .or .true .emit 0x00;
+vtxOptWeightNum_1
+ lbracket_ne .and vtxWeightNum .and rbracket;
+
+/*
+vertex program
+ <vtxWeightNum> ::= <integer> from 0 to MAX_VERTEX_UNITS_ARB-1,
+ must be divisible by four
+*/
+vtxWeightNum
+ integer;
+
+/*
+ <PARAM_statement> ::= <PARAM_singleStmt>
+ | <PARAM_multipleStmt>
+*/
+fp_PARAM_statement
+ fp_PARAM_multipleStmt .or fp_PARAM_singleStmt;
+vp_PARAM_statement
+ vp_PARAM_multipleStmt .or vp_PARAM_singleStmt;
+
+/*
+ <PARAM_singleStmt> ::= "PARAM" <establishName> <paramSingleInit>
+*/
+fp_PARAM_singleStmt
+ "PARAM" .and space .and fp_establishName .and .true .emit 0x00 .and fp_paramSingleInit .and
+ .true .emit PARAM_NULL;
+vp_PARAM_singleStmt
+ "PARAM" .and space .and vp_establishName .and .true .emit 0x00 .and vp_paramSingleInit .and
+ .true .emit PARAM_NULL;
+
+/*
+ <PARAM_multipleStmt> ::= "PARAM" <establishName> "[" <optArraySize> "]"
+ <paramMultipleInit>
+*/
+fp_PARAM_multipleStmt
+ "PARAM" .and space .and fp_establishName .and lbracket_ne .and optArraySize .and rbracket .and
+ fp_paramMultipleInit .and .true .emit PARAM_NULL;
+vp_PARAM_multipleStmt
+ "PARAM" .and space .and vp_establishName .and lbracket_ne .and optArraySize .and rbracket .and
+ vp_paramMultipleInit .and .true .emit PARAM_NULL;
+
+/*
+ <optArraySize> ::= ""
+ | <integer> from 1 to MAX_PROGRAM_PARAMETERS_ARB
+ (maximum number of allowed program
+ parameter bindings)
+*/
+optArraySize
+ optional_integer;
+
+/*
+ <paramSingleInit> ::= "=" <paramSingleItemDecl>
+*/
+fp_paramSingleInit
+ equal .and fp_paramSingleItemDecl;
+vp_paramSingleInit
+ equal .and vp_paramSingleItemDecl;
+
+/*
+ <paramMultipleInit> ::= "=" "{" <paramMultInitList> "}"
+*/
+fp_paramMultipleInit
+ equal .and lbrace .and fp_paramMultInitList .and rbrace;
+vp_paramMultipleInit
+ equal .and lbrace .and vp_paramMultInitList .and rbrace;
+
+/*
+ <paramMultInitList> ::= <paramMultipleItem>
+ | <paramMultipleItem> "," <paramMultiInitList>
+*/
+fp_paramMultInitList
+ fp_paramMultInitList_1 .or fp_paramMultipleItem;
+vp_paramMultInitList
+ vp_paramMultInitList_1 .or vp_paramMultipleItem;
+fp_paramMultInitList_1
+ fp_paramMultipleItem .and comma_ne .and fp_paramMultInitList;
+vp_paramMultInitList_1
+ vp_paramMultipleItem .and comma_ne .and vp_paramMultInitList;
+
+/*
+ <paramSingleItemDecl> ::= <stateSingleItem>
+ | <programSingleItem>
+ | <paramConstDecl>
+*/
+fp_paramSingleItemDecl
+ fp_stateSingleItem .emit PARAM_STATE_ELEMENT .or
+ programSingleItem .emit PARAM_PROGRAM_ELEMENT .or
+ paramConstDecl .emit PARAM_CONSTANT;
+vp_paramSingleItemDecl
+ vp_stateSingleItem .emit PARAM_STATE_ELEMENT .or
+ programSingleItem .emit PARAM_PROGRAM_ELEMENT .or
+ paramConstDecl .emit PARAM_CONSTANT;
+
+/*
+ <paramSingleItemUse> ::= <stateSingleItem>
+ | <programSingleItem>
+ | <paramConstUse>
+*/
+fp_paramSingleItemUse
+ fp_stateSingleItem .emit PARAM_STATE_ELEMENT .or
+ programSingleItem .emit PARAM_PROGRAM_ELEMENT .or
+ paramConstUse .emit PARAM_CONSTANT;
+vp_paramSingleItemUse
+ vp_stateSingleItem .emit PARAM_STATE_ELEMENT .or
+ programSingleItem .emit PARAM_PROGRAM_ELEMENT .or
+ paramConstUse .emit PARAM_CONSTANT;
+
+/*
+ <paramMultipleItem> ::= <stateMultipleItem>
+ | <programMultipleItem>
+ | <paramConstDecl>
+*/
+fp_paramMultipleItem
+ fp_stateMultipleItem .emit PARAM_STATE_ELEMENT .or
+ programMultipleItem .emit PARAM_PROGRAM_ELEMENT .or
+ paramConstDecl .emit PARAM_CONSTANT;
+vp_paramMultipleItem
+ vp_stateMultipleItem .emit PARAM_STATE_ELEMENT .or
+ programMultipleItem .emit PARAM_PROGRAM_ELEMENT .or
+ paramConstDecl .emit PARAM_CONSTANT;
+
+/*
+ <stateMultipleItem> ::= <stateSingleItem>
+ | "state" "." <stateMatrixRows>
+*/
+fp_stateMultipleItem
+ stateMultipleItem_1 .or fp_stateSingleItem;
+vp_stateMultipleItem
+ stateMultipleItem_1 .or vp_stateSingleItem;
+stateMultipleItem_1
+ "state" .and dot .and stateMatrixRows .emit STATE_MATRIX_ROWS;
+
+/*
+fragment program
+ <stateSingleItem> ::= "state" "." <stateMaterialItem>
+ | "state" "." <stateLightItem>
+ | "state" "." <stateLightModelItem>
+ | "state" "." <stateLightProdItem>
+ | "state" "." <stateTexEnvItem>
+ | "state" "." <stateFogItem>
+ | "state" "." <stateDepthItem>
+ | "state" "." <stateMatrixRow>
+
+vertex program
+ <stateSingleItem> ::= "state" "." <stateMaterialItem>
+ | "state" "." <stateLightItem>
+ | "state" "." <stateLightModelItem>
+ | "state" "." <stateLightProdItem>
+ | "state" "." <stateTexGenItem>
+ | "state" "." <stateFogItem>
+ | "state" "." <stateClipPlaneItem>
+ | "state" "." <statePointItem>
+ | "state" "." <stateMatrixRow>
+*/
+fp_stateSingleItem
+ "state" .and dot .and fp_stateSingleItem_1 .error INVALID_STATE_PROPERTY;
+vp_stateSingleItem
+ "state" .and dot .and vp_stateSingleItem_1 .error INVALID_STATE_PROPERTY;
+fp_stateSingleItem_1
+ stateSingleItem_1 .or stateSingleItem_2 .or stateSingleItem_3 .or stateSingleItem_4 .or
+ stateSingleItem_5 .or stateSingleItem_7 .or stateSingleItem_8 .or stateSingleItem_11;
+vp_stateSingleItem_1
+ stateSingleItem_1 .or stateSingleItem_2 .or stateSingleItem_3 .or stateSingleItem_4 .or
+ stateSingleItem_6 .or stateSingleItem_7 .or stateSingleItem_9 .or stateSingleItem_10 .or
+ stateSingleItem_11;
+stateSingleItem_1
+ stateMaterialItem .emit STATE_MATERIAL;
+stateSingleItem_2
+ stateLightItem .emit STATE_LIGHT;
+stateSingleItem_3
+ stateLightModelItem .emit STATE_LIGHT_MODEL;
+stateSingleItem_4
+ stateLightProdItem .emit STATE_LIGHT_PROD;
+stateSingleItem_5
+ stateTexEnvItem .emit STATE_TEX_ENV;
+stateSingleItem_6
+ stateTexGenItem .emit STATE_TEX_GEN;
+stateSingleItem_7
+ stateFogItem .emit STATE_FOG;
+stateSingleItem_8
+ stateDepthItem .emit STATE_DEPTH;
+stateSingleItem_9
+ stateClipPlaneItem .emit STATE_CLIP_PLANE;
+stateSingleItem_10
+ statePointItem .emit STATE_POINT;
+stateSingleItem_11
+ stateMatrixRow .emit STATE_MATRIX_ROWS;
+
+/*
+ <stateMaterialItem> ::= "material" <optFaceType> "." <stateMatProperty>
+*/
+stateMaterialItem
+ "material" .and optFaceType .and dot .and stateMatProperty .error INVALID_MATERIAL_PROPERTY;
+
+/*
+ <stateMatProperty> ::= "ambient"
+ | "diffuse"
+ | "specular"
+ | "emission"
+ | "shininess"
+*/
+stateMatProperty
+ "ambient" .emit MATERIAL_AMBIENT .or
+ "diffuse" .emit MATERIAL_DIFFUSE .or
+ "specular" .emit MATERIAL_SPECULAR .or
+ "emission" .emit MATERIAL_EMISSION .or
+ "shininess" .emit MATERIAL_SHININESS;
+
+/*
+ <stateLightItem> ::= "light" "[" <stateLightNumber> "]" "."
+ <stateLightProperty>
+*/
+stateLightItem
+ "light" .and lbracket .and stateLightNumber .and rbracket .and dot .and
+ stateLightProperty .error INVALID_LIGHT_PROPERTY;
+
+/*
+ <stateLightProperty> ::= "ambient"
+ | "diffuse"
+ | "specular"
+ | "position"
+ | "attenuation"
+ | "spot" "." <stateSpotProperty>
+ | "half"
+*/
+stateLightProperty
+ "ambient" .emit LIGHT_AMBIENT .or
+ "diffuse" .emit LIGHT_DIFFUSE .or
+ "specular" .emit LIGHT_SPECULAR .or
+ "position" .emit LIGHT_POSITION .or
+ "attenuation" .emit LIGHT_ATTENUATION .or
+ stateLightProperty_1 .emit LIGHT_SPOT_DIRECTION .or
+ "half" .emit LIGHT_HALF;
+stateLightProperty_1
+ "spot" .and dot .and stateSpotProperty .error INVALID_SPOT_PROPERTY;
+
+/*
+ <stateSpotProperty> ::= "direction"
+*/
+stateSpotProperty
+ "direction";
+
+/*
+ <stateLightModelItem> ::= "lightmodel" <stateLModProperty>
+*/
+stateLightModelItem
+ "lightmodel" .and stateLModProperty .error INVALID_LIGHTMODEL_PROPERTY;
+
+/*
+ <stateLModProperty> ::= "." "ambient"
+ | <optFaceType> "." "scenecolor"
+*/
+stateLModProperty
+ stateLModProperty_1 .or stateLModProperty_2;
+stateLModProperty_1
+ dot .and "ambient" .emit LIGHT_MODEL_AMBIENT;
+stateLModProperty_2
+ stateLModProperty_3 .emit LIGHT_MODEL_SCENECOLOR;
+stateLModProperty_3
+ optFaceType .and dot .and "scenecolor";
+
+/*
+ <stateLightProdItem> ::= "lightprod" "[" <stateLightNumber> "]"
+ <optFaceType> "." <stateLProdProperty>
+*/
+stateLightProdItem
+ "lightprod" .and lbracket .and stateLightNumber .and rbracket .and optFaceType .and dot .and
+ stateLProdProperty .error INVALID_LIGHTPROD_PROPERTY;
+
+/*
+ <stateLProdProperty> ::= "ambient"
+ | "diffuse"
+ | "specular"
+*/
+stateLProdProperty
+ "ambient" .emit LIGHT_PROD_AMBIENT .or
+ "diffuse" .emit LIGHT_PROD_DIFFUSE .or
+ "specular" .emit LIGHT_PROD_SPECULAR;
+
+/*
+ <stateLightNumber> ::= <integer> from 0 to MAX_LIGHTS-1
+*/
+stateLightNumber
+ integer;
+
+/*
+fragment program
+ <stateTexEnvItem> ::= "texenv" <optLegacyTexUnitNum> "."
+ <stateTexEnvProperty>
+*/
+stateTexEnvItem
+ "texenv" .and optLegacyTexUnitNum .and dot .and
+ stateTexEnvProperty .error INVALID_TEXENV_PROPERTY;
+
+/*
+fragment program
+ <stateTexEnvProperty> ::= "color"
+*/
+stateTexEnvProperty
+ "color" .emit TEX_ENV_COLOR;
+
+/*
+fragment program
+ <optLegacyTexUnitNum> ::= ""
+ | "[" <legacyTexUnitNum> "]"
+
+NOTE: <optLegaceTexUnitNum> is not optional.
+*/
+optLegacyTexUnitNum
+ lbracket_ne .and legacyTexUnitNum .and rbracket;
+
+/*
+fragment program
+ <legacyTexUnitNum> ::= <integer> from 0 to MAX_TEXTURE_UNITS-1
+*/
+legacyTexUnitNum
+ integer;
+
+/*
+vertex program
+ <stateTexGenItem> ::= "texgen" <optTexCoordNum> "."
+ <stateTexGenType> "." <stateTexGenCoord>
+*/
+stateTexGenItem
+ "texgen" .and optTexCoordNum .and dot .and stateTexGenType .error INVALID_TEXGEN_PROPERTY .and
+ dot .and stateTexGenCoord .error INVALID_TEXGEN_COORD;
+
+/*
+vertex program
+ <stateTexGenType> ::= "eye"
+ | "object"
+*/
+stateTexGenType
+ "eye" .emit TEX_GEN_EYE .or
+ "object" .emit TEX_GEN_OBJECT;
+
+/*
+vertex program
+ <stateTexGenCoord> ::= "s"
+ | "t"
+ | "r"
+ | "q"
+*/
+stateTexGenCoord
+ "s" .emit COMPONENT_X .or
+ "t" .emit COMPONENT_Y .or
+ "r" .emit COMPONENT_Z .or
+ "q" .emit COMPONENT_W;
+
+/*
+ <stateFogItem> ::= "fog" "." <stateFogProperty>
+*/
+stateFogItem
+ "fog" .and dot .and stateFogProperty .error INVALID_FOG_PROPERTY;
+
+/*
+ <stateFogProperty> ::= "color"
+ | "params"
+*/
+stateFogProperty
+ "color" .emit FOG_COLOR .or
+ "params" .emit FOG_PARAMS;
+
+/*
+fragment program
+ <stateDepthItem> ::= "depth" "." <stateDepthProperty>
+*/
+stateDepthItem
+ "depth" .and dot .and stateDepthProperty .error INVALID_DEPTH_PROPERTY;
+
+/*
+fragment program
+ <stateDepthProperty> ::= "range"
+*/
+stateDepthProperty
+ "range" .emit DEPTH_RANGE;
+
+/*
+vertex program
+ <stateClipPlaneItem> ::= "clip" "[" <stateClipPlaneNum> "]" "." "plane"
+*/
+stateClipPlaneItem
+ "clip" .and lbracket .and stateClipPlaneNum .and rbracket .and dot .and
+ "plane" .error INVALID_CLIPPLANE_PROPERTY;
+
+/*
+vertex program
+ <stateClipPlaneNum> ::= <integer> from 0 to MAX_CLIP_PLANES-1
+*/
+stateClipPlaneNum
+ integer;
+
+/*
+vertex program
+ <statePointItem> ::= "point" "." <statePointProperty>
+*/
+statePointItem
+ "point" .and dot .and statePointProperty .error INVALID_POINT_PROPERTY;
+
+/*
+vertex program
+ <statePointProperty> ::= "size"
+ | "attenuation"
+*/
+statePointProperty
+ "size" .emit POINT_SIZE .or
+ .if (point_parameters != 0x00) "attenuation" .emit POINT_ATTENUATION;
+
+/*
+ <stateMatrixRow> ::= <stateMatrixItem> "." "row" "["
+ <stateMatrixRowNum> "]"
+*/
+stateMatrixRow
+ stateMatrixItem .and dot .and "row" .error MATRIX_ROW_SELECTOR_OR_MODIFIER_EXPECTED .and
+ lbracket .and stateMatrixRowNum .and rbracket .emit 0x0;
+
+/*
+ <stateMatrixRows> ::= <stateMatrixItem> <optMatrixRows>
+*/
+stateMatrixRows
+ stateMatrixItem .and optMatrixRows;
+
+/*
+ <optMatrixRows> ::= ""
+ | "." "row" "[" <stateMatrixRowNum> ".."
+ <stateMatrixRowNum> "]"
+*/
+optMatrixRows
+ optMatrixRows_1 .or .true .emit 0x0 .emit '3' .emit 0x0 .emit $;
+optMatrixRows_1
+ dot_ne .and "row" .error MATRIX_ROW_SELECTOR_OR_MODIFIER_EXPECTED .and lbracket .and
+ stateMatrixRowNum .and dotdot .and stateMatrixRowNum .and rbracket;
+
+/*
+ <stateMatrixItem> ::= "matrix" "." <stateMatrixName>
+ <stateOptMatModifier>
+*/
+stateMatrixItem
+ "matrix" .and dot .and stateMatrixName .error INVALID_MATRIX_NAME .and stateOptMatModifier;
+
+/*
+ <stateOptMatModifier> ::= ""
+ | "." <stateMatModifier>
+*/
+stateOptMatModifier
+ stateOptMatModifier_1 .or .true .emit MATRIX_MODIFIER_IDENTITY;
+stateOptMatModifier_1
+ dot_ne .and stateMatModifier;
+
+/*
+ <stateMatModifier> ::= "inverse"
+ | "transpose"
+ | "invtrans"
+*/
+stateMatModifier
+ "inverse" .emit MATRIX_MODIFIER_INVERSE .or
+ "transpose" .emit MATRIX_MODIFIER_TRANSPOSE .or
+ "invtrans" .emit MATRIX_MODIFIER_INVTRANS;
+
+/*
+ <stateMatrixRowNum> ::= <integer> from 0 to 3
+*/
+stateMatrixRowNum
+ integer_0_3;
+
+/*
+ <stateMatrixName> ::= "modelview" <stateOptModMatNum>
+ | "projection"
+ | "mvp"
+ | "texture" <optTexCoordNum>
+ | "palette" "[" <statePaletteMatNum> "]"
+ | "program" "[" <stateProgramMatNum> "]"
+*/
+stateMatrixName
+ stateMatrixName_1_1 .emit MATRIX_MODELVIEW .or
+ "projection" .emit MATRIX_PROJECTION .or
+ "mvp" .emit MATRIX_MVP .or
+ stateMatrixName_1_2 .emit MATRIX_TEXTURE .or
+ .if (matrix_palette != 0x00) stateMatrixName_1_3 .emit MATRIX_PALETTE .or
+ stateMatrixName_1_4 .emit MATRIX_PROGRAM;
+stateMatrixName_1_1
+ "modelview" .and stateOptModMatNum;
+stateMatrixName_1_2
+ "texture" .and optTexCoordNum;
+stateMatrixName_1_3
+ "palette" .and lbracket .and statePaletteMatNum .and rbracket;
+stateMatrixName_1_4
+ "program" .and lbracket .and stateProgramMatNum .and rbracket;
+
+/*
+ <stateOptModMatNum> ::= ""
+ | "[" <stateModMatNum> "]"
+*/
+stateOptModMatNum
+ .if (vertex_blend != 0x00) stateOptModMatNum_1 .or
+ .true .emit 0x00;
+stateOptModMatNum_1
+ lbracket_ne .and stateModMatNum .and rbracket;
+
+/*
+ <stateModMatNum> ::= <integer> from 0 to MAX_VERTEX_UNITS_ARB-1
+*/
+stateModMatNum
+ integer;
+
+/*
+ <optTexCoordNum> ::= ""
+ | "[" <texCoordNum> "]"
+*/
+optTexCoordNum
+ optTexCoordNum_1 .or .true .emit 0x00;
+optTexCoordNum_1
+ lbracket_ne .and texCoordNum .and rbracket;
+
+/*
+ <texCoordNum> ::= <integer> from 0 to MAX_TEXTURE_COORDS_ARB-1
+*/
+texCoordNum
+ integer;
+
+/*
+ <statePaletteMatNum> ::= <integer> from 0 to MAX_PALETTE_MATRICES_ARB-1
+*/
+statePaletteMatNum
+ integer;
+
+/*
+ <stateProgramMatNum> ::= <integer> from 0 to MAX_PROGRAM_MATRICES_ARB-1
+*/
+stateProgramMatNum
+ integer;
+
+/*
+ <programSingleItem> ::= <progEnvParam>
+ | <progLocalParam>
+
+NOTE: <programSingleItem> has been modified for correct error handling. If program property
+ is neither "env" nor "local" INVALID_PROGRAM_PROPERTY is generated.
+*/
+programSingleItem
+ "program" .and dot .and programSingleItem_1 .error INVALID_PROGRAM_PROPERTY;
+programSingleItem_1
+ progEnvParam .or progLocalParam;
+
+/*
+ <programMultipleItem> ::= <progEnvParams>
+ | <progLocalParams>
+
+NOTE: <programMultipleItem> has been modified for correct error handling. If program property
+ is neither "env" nor "local" INVALID_PROGRAM_PROPERTY is generated.
+*/
+programMultipleItem
+ "program" .and dot .and programMultipleItem_1 .error INVALID_PROGRAM_PROPERTY;
+programMultipleItem_1
+ progEnvParams .or progLocalParams;
+
+/*
+ <progEnvParams> ::= "program" "." "env"
+ "[" <progEnvParamNums> "]"
+
+NOTE: "program" "." has been moved to <programMultipleItem>.
+*/
+progEnvParams
+ "env" .emit PROGRAM_PARAM_ENV .and lbracket .and progEnvParamNums .and rbracket;
+
+/*
+ <progEnvParamNums> ::= <progEnvParamNum>
+ | <progEnvParamNum> ".." <progEnvParamNum>
+*/
+progEnvParamNums
+ progEnvParamNums_1 .or progEnvParamNums_2;
+progEnvParamNums_1
+ progEnvParamNum .and dotdot_ne .and progEnvParamNum;
+progEnvParamNums_2
+ progEnvParamNum .and .true .emit 0x00;
+
+/*
+ <progEnvParam> ::= "program" "." "env"
+ "[" <progEnvParamNum> "]"
+
+NOTE: "program" "." has been moved to <programSingleItem>.
+*/
+progEnvParam
+ "env" .emit PROGRAM_PARAM_ENV .and lbracket .and progEnvParamNum .and rbracket .emit 0x00;
+
+/*
+ <progLocalParams> ::= "program" "." "local"
+ "[" <progLocalParamNums> "]"
+
+NOTE: "program" "." has been moved to <programMultipleItem>.
+*/
+progLocalParams
+ "local" .emit PROGRAM_PARAM_LOCAL .and lbracket .and progLocalParamNums .and rbracket;
+
+/*
+ <progLocalParamNums> ::= <progLocalParamNum>
+ | <progLocalParamNum> ".." <progLocalParamNum>
+*/
+progLocalParamNums
+ progLocalParamNums_1 .or progLocalParamNums_2;
+progLocalParamNums_1
+ progLocalParamNum .and dotdot_ne .and progLocalParamNum;
+progLocalParamNums_2
+ progLocalParamNum .and .true .emit 0x00;
+
+/*
+ <progLocalParam> ::= "program" "." "local"
+ "[" <progLocalParamNum> "]"
+
+NOTE: "program" "." has been moved to <programSingleItem>.
+*/
+progLocalParam
+ "local" .emit PROGRAM_PARAM_LOCAL .and lbracket .and progLocalParamNum .and rbracket .emit 0x00;
+
+/*
+ <progEnvParamNum> ::= <integer> from 0 to
+ MAX_PROGRAM_ENV_PARAMETERS_ARB - 1
+*/
+progEnvParamNum
+ integer;
+
+/*
+ <progLocalParamNum> ::= <integer> from 0 to
+ MAX_PROGRAM_LOCAL_PARAMETERS_ARB - 1
+*/
+progLocalParamNum
+ integer;
+
+/*
+ <paramConstDecl> ::= <paramConstScalarDecl>
+ | <paramConstVector>
+*/
+paramConstDecl
+ paramConstScalarDecl .emit CONSTANT_SCALAR .or paramConstVector .emit CONSTANT_VECTOR;
+
+/*
+ <paramConstUse> ::= <paramConstScalarUse>
+ | <paramConstVector>
+*/
+paramConstUse
+ paramConstScalarUse .emit CONSTANT_SCALAR .or paramConstVector .emit CONSTANT_VECTOR;
+
+/*
+ <paramConstScalarDecl> ::= <signedFloatConstant>
+*/
+paramConstScalarDecl
+ signedFloatConstant;
+
+/*
+ <paramConstScalarUse> ::= <floatConstant>
+*/
+paramConstScalarUse
+ floatConstant;
+
+/*
+ <paramConstVector> ::= "{" <signedFloatConstant> "}"
+ | "{" <signedFloatConstant> ","
+ <signedFloatConstant> "}"
+ | "{" <signedFloatConstant> ","
+ <signedFloatConstant> ","
+ <signedFloatConstant> "}"
+ | "{" <signedFloatConstant> ","
+ <signedFloatConstant> ","
+ <signedFloatConstant> ","
+ <signedFloatConstant> "}"
+*/
+paramConstVector
+ paramConstVector_4 .emit 0x04 .or paramConstVector_3 .emit 0x03 .or
+ paramConstVector_2 .emit 0x02 .or paramConstVector_1 .emit 0x01;
+paramConstVector_1
+ lbrace_ne .and signedFloatConstant .and rbrace;
+paramConstVector_2
+ lbrace_ne .and signedFloatConstant .and comma_ne .and signedFloatConstant .and rbrace;
+paramConstVector_3
+ lbrace_ne .and signedFloatConstant .and comma_ne .and signedFloatConstant .and comma_ne .and
+ signedFloatConstant .and rbrace;
+paramConstVector_4
+ lbrace_ne .and signedFloatConstant .and comma_ne .and signedFloatConstant .and comma_ne .and
+ signedFloatConstant .and comma_ne .and signedFloatConstant .and rbrace;
+
+/*
+ <signedFloatConstant> ::= <optionalSign> <floatConstant>
+*/
+signedFloatConstant
+ optionalSign .and floatConstant;
+
+/*
+ <floatConstant> ::= see text
+ The <floatConstant> rule matches a floating-point constant consisting
+ of an integer part, a decimal point, a fraction part, an "e" or
+ "E", and an optionally signed integer exponent. The integer and
+ fraction parts both consist of a sequence of one or more digits ("0"
+ through "9"). Either the integer part or the fraction parts (not
+ both) may be missing; either the decimal point or the "e" (or "E")
+ and the exponent (not both) may be missing.
+*/
+floatConstant
+ float;
+
+/*
+ <optionalSign> ::= ""
+ | "-"
+ | "+"
+*/
+optionalSign
+ optional_sign_ne;
+
+/*
+ <TEMP_statement> ::= "TEMP" <varNameList>
+*/
+fp_TEMP_statement
+ "TEMP" .and space .and fp_varNameList .and .true .emit 0x00;
+vp_TEMP_statement
+ "TEMP" .and space .and vp_varNameList .and .true .emit 0x00;
+
+/*
+vertex program
+ <ADDRESS_statement> ::= "ADDRESS" <varNameList>
+*/
+ADDRESS_statement
+ "ADDRESS" .and space .and vp_varNameList .and .true .emit 0x00;
+
+/*
+ <varNameList> ::= <establishName>
+ | <establishName> "," <varNameList>
+*/
+fp_varNameList
+ fp_varNameList_1 .or fp_establishName;
+vp_varNameList
+ vp_varNameList_1 .or vp_establishName;
+fp_varNameList_1
+ fp_establishName .and comma_ne .and fp_varNameList;
+vp_varNameList_1
+ vp_establishName .and comma_ne .and vp_varNameList;
+
+/*
+ <OUTPUT_statement> ::= "OUTPUT" <establishName> "="
+ <resultBinding>
+*/
+fp_OUTPUT_statement
+ "OUTPUT" .and space .and fp_establishName .and equal .and
+ fp_resultBinding .error RESULT_EXPECTED;
+vp_OUTPUT_statement
+ "OUTPUT" .and space .and vp_establishName .and equal .and
+ vp_resultBinding .error RESULT_EXPECTED;
+
+/*
+fragment program
+ <resultBinding> ::= "result" "." "color"
+ | "result" "." "color" <optOutputColorNum> (if option ARB_draw_buffers present)
+ | "result" "." "depth"
+
+vertex program
+ <resultBinding> ::= "result" "." "position"
+ | "result" "." <resultColBinding>
+ | "result" "." "fogcoord"
+ | "result" "." "pointsize"
+ | "result" "." "texcoord" <optTexCoordNum>
+*/
+fp_resultBinding
+ "result" .and dot .and fp_resultBinding_1 .error INVALID_RESULT_PROPERTY;
+vp_resultBinding
+ "result" .and dot .and vp_resultBinding_1 .error INVALID_RESULT_PROPERTY;
+fp_resultBinding_1
+ fp_resultBinding_2 .emit FRAGMENT_RESULT_COLOR .or
+ "depth" .emit FRAGMENT_RESULT_DEPTH;
+fp_resultBinding_2
+ "color" .and optOutputColorNum;
+vp_resultBinding_1
+ .if (ARB_position_invariant == 0x00) "position" .emit VERTEX_RESULT_POSITION .or
+ resultColBinding .emit VERTEX_RESULT_COLOR .or
+ "fogcoord" .emit VERTEX_RESULT_FOGCOORD .or
+ "pointsize" .emit VERTEX_RESULT_POINTSIZE .or
+ vp_resultBinding_2 .emit VERTEX_RESULT_TEXCOORD;
+vp_resultBinding_2
+ "texcoord" .and optTexCoordNum;
+
+/*
+GL_ARB_draw_buffers
+ <optOutputColorNum> ::= ""
+ | "[" <outputColorNum> "]"
+*/
+optOutputColorNum
+ .if (ARB_draw_buffers != 0x00) optOutputColorNum_1 .or .true .emit 0x00;
+optOutputColorNum_1
+ lbracket_ne .and outputColorNum .and rbracket;
+
+/*
+GL_ARB_draw_buffers
+ <outputColorNum> ::= <integer> from 0 to MAX_DRAW_BUFFERS_ARB-1
+*/
+outputColorNum
+ integer;
+
+/*
+vertex program
+ <resultColBinding> ::= "color" <optFaceType> <optColorType>
+*/
+resultColBinding
+ "color" .and optFaceType .and optColorType;
+
+/*
+ <optFaceType> ::= ""
+ | "." "front"
+ | "." "back"
+*/
+optFaceType
+ FaceType .or .true .emit FACE_FRONT;
+FaceType
+ dot_ne .and FaceProperty;
+FaceProperty
+ "front" .emit FACE_FRONT .or "back" .emit FACE_BACK;
+
+/*
+ <optColorType> ::= ""
+ | "." "primary"
+ | "." "secondary"
+*/
+optColorType
+ ColorType .or .true .emit COLOR_PRIMARY;
+ColorType
+ dot_ne .and ColorProperty;
+ColorProperty
+ "primary" .emit COLOR_PRIMARY .or
+ .if (secondary_color != 0x00) "secondary" .emit COLOR_SECONDARY;
+
+/*
+ <ALIAS_statement> ::= "ALIAS" <establishName> "="
+ <establishedName>
+*/
+fp_ALIAS_statement
+ "ALIAS" .and fp_ALIAS_statement_1 .error IDENTIFIER_EXPECTED .and equal .and fp_establishedName;
+vp_ALIAS_statement
+ "ALIAS" .and vp_ALIAS_statement_1 .error IDENTIFIER_EXPECTED .and equal .and vp_establishedName;
+fp_ALIAS_statement_1
+ space .and fp_establishName;
+vp_ALIAS_statement_1
+ space .and vp_establishName;
+
+/*
+ <establishName> ::= <identifier>
+*/
+fp_establishName
+ fp_identifier;
+vp_establishName
+ vp_identifier;
+
+/*
+ <establishedName> ::= <identifier>
+*/
+fp_establishedName
+ fp_identifier;
+vp_establishedName
+ vp_identifier;
+fp_establishedName_no_error_on_identifier
+ fp_identifier_ne;
+vp_establishedName_no_error_on_identifier
+ vp_identifier_ne;
+
+/*
+fragment program
+ <identifier> ::= see text
+ The <identifier> rule matches a sequence of one or more letters ("A"
+ through "Z", "a" through "z"), digits ("0" through "9), underscores
+ ("_"), or dollar signs ("$"); the first character must not be a
+ number. Upper and lower case letters are considered different
+ (names are case-sensitive). The following strings are reserved
+ keywords and may not be used as identifiers:
+
+ ABS, ABS_SAT, ADD, ADD_SAT, ALIAS, ATTRIB, CMP, CMP_SAT, COS,
+ COS_SAT, DP3, DP3_SAT, DP4, DP4_SAT, DPH, DPH_SAT, DST, DST_SAT,
+ END, EX2, EX2_SAT, FLR, FLR_SAT, FRC, FRC_SAT, KIL, LG2,
+ LG2_SAT, LIT, LIT_SAT, LRP, LRP_SAT, MAD, MAD_SAT, MAX, MAX_SAT,
+ MIN, MIN_SAT, MOV, MOV_SAT, MUL, MUL_SAT, OPTION, OUTPUT, PARAM,
+ POW, POW_SAT, RCP, RCP_SAT, RSQ, RSQ_SAT, SIN, SIN_SAT, SCS,
+ SCS_SAT, SGE, SGE_SAT, SLT, SLT_SAT, SUB, SUB_SAT, SWZ, SWZ_SAT,
+ TEMP, TEX, TEX_SAT, TXB, TXB_SAT, TXP, TXP_SAT, XPD, XPD_SAT,
+ fragment, program, result, state, and texture.
+
+vertex program
+ <identifier> ::= see text
+ The <identifier> rule matches a sequence of one or more letters ("A"
+ through "Z", "a" through "z"), digits ("0" through "9), underscores ("_"),
+ or dollar signs ("$"); the first character must not be a number. Upper
+ and lower case letters are considered different (names are
+ case-sensitive). The following strings are reserved keywords and may not
+ be used as identifiers:
+
+ ABS, ADD, ADDRESS, ALIAS, ARL, ATTRIB, DP3, DP4, DPH, DST, END, EX2,
+ EXP, FLR, FRC, LG2, LIT, LOG, MAD, MAX, MIN, MOV, MUL, OPTION, OUTPUT,
+ PARAM, POW, RCP, RSQ, SGE, SLT, SUB, SWZ, TEMP, XPD, program, result,
+ state, and vertex.
+*/
+fp_identifier
+ fp_identifier_ne .error IDENTIFIER_EXPECTED;
+vp_identifier
+ vp_identifier_ne .error IDENTIFIER_EXPECTED;
+fp_identifier_ne
+ fp_not_reserved_identifier .and identifier_ne;
+vp_identifier_ne
+ vp_not_reserved_identifier .and identifier_ne;
+
+fp_not_reserved_identifier
+ fp_not_reserved_identifier_1 .or .true;
+fp_not_reserved_identifier_1
+ fp_reserved_identifier .and .false .error RESERVED_KEYWORD;
+vp_not_reserved_identifier
+ vp_not_reserved_identifier_1 .or .true;
+vp_not_reserved_identifier_1
+ vp_reserved_identifier .and .false .error RESERVED_KEYWORD;
+
+fp_reserved_identifier
+ "ABS" .or "ABS_SAT" .or "ADD" .or "ADD_SAT" .or "ALIAS" .or "ATTRIB" .or "CMP" .or "CMP_SAT" .or
+ "COS" .or "COS_SAT" .or "DP3" .or "DP3_SAT" .or "DP4" .or "DP4_SAT" .or "DPH" .or "DPH_SAT" .or
+ "DST" .or "DST_SAT" .or "END" .or "EX2" .or "EX2_SAT" .or "FLR" .or "FLR_SAT" .or "FRC" .or
+ "FRC_SAT" .or "KIL" .or "LG2" .or "LG2_SAT" .or "LIT" .or "LIT_SAT" .or "LRP" .or "LRP_SAT" .or
+ "MAD" .or "MAD_SAT" .or "MAX" .or "MAX_SAT" .or "MIN" .or "MIN_SAT" .or "MOV" .or "MOV_SAT" .or
+ "MUL" .or "MUL_SAT" .or "OPTION" .or "OUTPUT" .or "PARAM" .or "POW" .or "POW_SAT" .or "RCP" .or
+ "RCP_SAT" .or "RSQ" .or "RSQ_SAT" .or "SIN" .or "SIN_SAT" .or "SCS" .or "SCS_SAT" .or "SGE" .or
+ "SGE_SAT" .or "SLT" .or "SLT_SAT" .or "SUB" .or "SUB_SAT" .or "SWZ" .or "SWZ_SAT" .or "TEMP" .or
+ "TEX" .or "TEX_SAT" .or "TXB" .or "TXB_SAT" .or "TXP" .or "TXP_SAT" .or "XPD" .or "XPD_SAT" .or
+ "fragment" .or "program" .or "result" .or "state" .or "texture";
+vp_reserved_identifier
+ "ABS" .or "ADD" .or "ADDRESS" .or "ALIAS" .or "ARL" .or "ATTRIB" .or "DP3" .or "DP4" .or
+ "DPH" .or "DST" .or "END" .or "EX2" .or "EXP" .or "FLR" .or "FRC" .or "LG2" .or "LIT" .or
+ "LOG" .or "MAD" .or "MAX" .or "MIN" .or "MOV" .or "MUL" .or "OPTION" .or "OUTPUT" .or
+ "PARAM" .or "POW" .or "RCP" .or "RSQ" .or "SGE" .or "SLT" .or "SUB" .or "SWZ" .or "TEMP" .or
+ "XPD" .or "program" .or "result" .or "state" .or "vertex";
+
+/*
+ The <integer> rule matches an integer constant. The integer consists
+ of a sequence of one or more digits ("0" through "9").
+*/
+integer
+ integer_ne .error INTEGER_EXPECTED;
+
+zero
+ '0';
+
+leading_zeroes
+ .loop zero;
+
+no_digit
+ no_digit_1 .or .true;
+no_digit_1
+ digit10 .and .false .error INTEGER_OUT_OF_RANGE;
+
+all_zeroes
+ all_zeroes_1 .or no_digit_1;
+all_zeroes_1
+ '0' .and .loop zero .and no_digit;
+
+integer_0_3
+ integer_0_3_1 .error INTEGER_EXPECTED .and .true .emit 0x00 .emit $;
+integer_0_3_1
+ integer_0_3_2 .or all_zeroes .emit '0';
+integer_0_3_2 /* [1, 3] */
+ leading_zeroes .and '1'-'3' .emit * .and no_digit;
+
+integer_0_63
+ integer_0_63_1 .error INTEGER_EXPECTED .and .true .emit 0x00 .emit $;
+integer_0_63_1
+ integer_0_63_2 .or integer_0_63_3 .or integer_0_63_4 .or integer_0_63_5 .or
+ all_zeroes .emit '0';
+integer_0_63_2 /* [7, 9] */
+ leading_zeroes .and '7'-'9' .emit * .and no_digit;
+integer_0_63_3 /* [10, 59] */
+ leading_zeroes .and '1'-'5' .emit * .and '0'-'9' .emit * .and no_digit;
+integer_0_63_4 /* [60, 63] */
+ leading_zeroes .and '6' .emit * .and '0'-'3' .emit * .and no_digit;
+integer_0_63_5 /* [1, 6] */
+ leading_zeroes .and '1'-'6' .emit * .and no_digit;
+
+integer_0_64
+ integer_0_64_1 .error INTEGER_EXPECTED .and .true .emit 0x00 .emit $;
+integer_0_64_1
+ integer_0_64_2 .or integer_0_64_3 .or integer_0_64_4 .or integer_0_64_5 .or
+ all_zeroes .emit '0';
+integer_0_64_2 /* [7, 9] */
+ leading_zeroes .and '7'-'9' .emit * .and no_digit;
+integer_0_64_3 /* [10, 59] */
+ leading_zeroes .and '1'-'5' .emit * .and '0'-'9' .emit * .and no_digit;
+integer_0_64_4 /* [60, 64] */
+ leading_zeroes .and '6' .emit * .and '0'-'4' .emit * .and no_digit;
+integer_0_64_5 /* [1, 6] */
+ leading_zeroes .and '1'-'6' .emit * .and no_digit;
+
+optional_space
+ space .or .true;
+
+space_dst
+ space .error OPERATION_NEEDS_DESTINATION_VARIABLE;
+
+space_src
+ space .error OPERATION_NEEDS_SOURCE_VARIABLE;
+
+space
+ single_space .and .loop single_space;
+
+single_space
+ white_char .or comment_block;
+
+white_char
+ ' ' .or '\t' .or '\n' .or '\r';
+
+comment_block
+ '#' .and .loop comment_char .and new_line;
+
+/* All ASCII characters except '\r', '\n' and '\0' */
+comment_char
+ '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
+
+new_line
+ '\n' .or crlf .or '\0';
+
+crlf
+ '\r' .and '\n';
+
+semicolon
+ optional_space .and ';' .error MISSING_SEMICOLON .and optional_space;
+
+comma
+ optional_space .and ',' .error MISSING_COMMA .and optional_space;
+
+comma_ne
+ optional_space .and ',' .and optional_space;
+
+lbracket
+ optional_space .and '[' .error MISSING_LBRACKET .and optional_space;
+
+lbracket_ne
+ optional_space .and '[' .and optional_space;
+
+rbracket
+ optional_space .and ']' .error MISSING_RBRACKET .and optional_space;
+
+dot
+ optional_space .and '.' .error MISSING_DOT .and optional_space;
+
+dot_ne
+ optional_space .and '.' .and optional_space;
+
+equal
+ optional_space .and '=' .error MISSING_EQUAL .and optional_space;
+
+lbrace
+ optional_space .and '{' .error MISSING_LBRACE .and optional_space;
+
+lbrace_ne
+ optional_space .and '{' .and optional_space;
+
+rbrace
+ optional_space .and '}' .error MISSING_RBRACE .and optional_space;
+
+dotdot
+ optional_space .and '.' .and '.' .error MISSING_DOTDOT .and optional_space;
+
+dotdot_ne
+ optional_space .and '.' .and '.' .and optional_space;
+
+/*
+ The definition below accepts the following floating point number formats:
+ .99 .99e99 99. 99.99 99.99e99 99.e99 99e99
+ Also 99 format was considered and accepted because of a large number of existing program
+ strings with such a format.
+*/
+float
+ float_1 .or float_2 .or float_legacy;
+float_1
+ '.' .emit 0x00 .and integer_ne .error MISSING_FRACTION_OR_EXPONENT .and optional_exponent;
+float_2
+ integer_ne .and float_3;
+float_3
+ float_4 .or float_5;
+float_4
+ '.' .and optional_integer .and optional_exponent;
+float_5
+ exponent .emit 0x00;
+float_legacy
+ integer_ne .and .true .emit 0x00 .emit 0x00;
+
+/*
+ Below is a correct version of <float> definiton.
+*/
+/*
+float
+ float_1 .or float_2;
+float_1
+ '.' .emit 0x00 .and integer_ne .error MISSING_FRACTION_OR_EXPONENT .and optional_exponent;
+float_2
+ integer_ne .and float_3 .error MISSING_DOT_OR_EXPONENT;
+float_3
+ float_4 .or float_5;
+float_4
+ '.' .and optional_integer .and optional_exponent;
+float_5
+ exponent .emit 0x00;
+*/
+
+integer_ne
+ integer_ne_1 .and .true .emit 0x00 .emit $;
+integer_ne_1
+ digit10 .emit * .and .loop digit10 .emit *;
+
+optional_integer
+ integer_ne .or .true .emit 0x00;
+
+/*
+NOTE: If exponent part is omited we treat it as if it was "E+1".
+*/
+optional_exponent
+ exponent .or .true .emit 0x00;
+
+exponent
+ exponent_1 .and optional_sign_ne .and integer_ne .error EXPONENT_VALUE_EXPECTED;
+exponent_1
+ 'e' .or 'E';
+
+optional_sign_ne
+ minus_ne .or plus_ne .or .true;
+
+plus_ne
+ optional_space .and '+' .and optional_space;
+
+minus_ne
+ optional_space .and '-' .emit '-' .and optional_space;
+
+identifier_ne
+ first_idchar .emit * .and .loop follow_idchar .emit * .and .true .emit 0x00 .emit $;
+
+follow_idchar
+ first_idchar .or digit10;
+
+first_idchar
+ 'a'-'z' .or 'A'-'Z' .or '_' .or '$';
+
+digit10
+ '0'-'9';
+
+/*
+ string filtering - if a string is encountered in grammar ("blabla"), the symbol below is
+ executed to create the string. The symbol must not throw any errors and emit bytes - it should
+ stop if it encounters invalid character. After this the resulting string (from starting
+ position up to the invalid character (but without it) is compared with the grammar string.
+*/
+.string __string_filter;
+
+__string_filter
+ .loop __identifier_char;
+
+__identifier_char
+ 'a'-'z' .or 'A'-'Z' .or '_' .or '$' .or '0'-'9';
+
+/*
+ error token filtering
+*/
+e_signature
+ e_signature_char .and .loop e_signature_char;
+e_signature_char
+ '!' .or '.' .or 'A'-'Z' .or 'a'-'z' .or '0'-'9';
+
+e_statement
+ .loop e_statement_not_term;
+/* All ASCII characters to one of '\r', '\n', '\0' and ';' */
+e_statement_not_term
+ '\x3C'-'\xFF' .or '\x0E'-'\x3A' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
+
+e_identifier
+ e_identifier_first .and .loop e_identifier_next;
+e_identifier_first
+ 'a'-'z' .or 'A'-'Z' .or '_' .or '$';
+e_identifier_next
+ e_identifier_first .or '0'-'9';
+
+e_token
+ e_identifier .or e_token_number .or '[' .or ']' .or '.' .or '{' .or '}' .or '=' .or '+' .or
+ '-' .or ',' .or ';';
+e_token_number
+ e_token_digit .and .loop e_token_digit;
+e_token_digit
+ '0'-'9';
+
+e_charordigit
+ 'A'-'Z' .or 'a'-'z' .or '0'-'9';
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/arbprogram_syn.h b/nx-X11/extras/Mesa/src/mesa/shader/arbprogram_syn.h
new file mode 100644
index 000000000..c67afc67d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/arbprogram_syn.h
@@ -0,0 +1,1327 @@
+".syntax program;\n"
+".emtcode REVISION 0x09\n"
+".emtcode FRAGMENT_PROGRAM 0x01\n"
+".emtcode VERTEX_PROGRAM 0x02\n"
+".emtcode OPTION 0x01\n"
+".emtcode INSTRUCTION 0x02\n"
+".emtcode DECLARATION 0x03\n"
+".emtcode END 0x04\n"
+".emtcode ARB_PRECISION_HINT_FASTEST 0x00\n"
+".emtcode ARB_PRECISION_HINT_NICEST 0x01\n"
+".emtcode ARB_FOG_EXP 0x02\n"
+".emtcode ARB_FOG_EXP2 0x03\n"
+".emtcode ARB_FOG_LINEAR 0x04\n"
+".emtcode ARB_POSITION_INVARIANT 0x05\n"
+".emtcode ARB_FRAGMENT_PROGRAM_SHADOW 0x06\n"
+".emtcode ARB_DRAW_BUFFERS 0x07\n"
+".emtcode OP_ALU_INST 0x00\n"
+".emtcode OP_TEX_INST 0x01\n"
+".emtcode OP_ALU_VECTOR 0x00\n"
+".emtcode OP_ALU_SCALAR 0x01\n"
+".emtcode OP_ALU_BINSC 0x02\n"
+".emtcode OP_ALU_BIN 0x03\n"
+".emtcode OP_ALU_TRI 0x04\n"
+".emtcode OP_ALU_SWZ 0x05\n"
+".emtcode OP_TEX_SAMPLE 0x06\n"
+".emtcode OP_TEX_KIL 0x07\n"
+".emtcode OP_ALU_ARL 0x08\n"
+".emtcode OP_ABS 0x00\n"
+".emtcode OP_ABS_SAT 0x1B\n"
+".emtcode OP_FLR 0x09\n"
+".emtcode OP_FLR_SAT 0x26\n"
+".emtcode OP_FRC 0x0A\n"
+".emtcode OP_FRC_SAT 0x27\n"
+".emtcode OP_LIT 0x0C\n"
+".emtcode OP_LIT_SAT 0x2A\n"
+".emtcode OP_MOV 0x11\n"
+".emtcode OP_MOV_SAT 0x30\n"
+".emtcode OP_COS 0x1F\n"
+".emtcode OP_COS_SAT 0x20\n"
+".emtcode OP_EX2 0x07\n"
+".emtcode OP_EX2_SAT 0x25\n"
+".emtcode OP_LG2 0x0B\n"
+".emtcode OP_LG2_SAT 0x29\n"
+".emtcode OP_RCP 0x14\n"
+".emtcode OP_RCP_SAT 0x33\n"
+".emtcode OP_RSQ 0x15\n"
+".emtcode OP_RSQ_SAT 0x34\n"
+".emtcode OP_SIN 0x38\n"
+".emtcode OP_SIN_SAT 0x39\n"
+".emtcode OP_SCS 0x35\n"
+".emtcode OP_SCS_SAT 0x36\n"
+".emtcode OP_POW 0x13\n"
+".emtcode OP_POW_SAT 0x32\n"
+".emtcode OP_ADD 0x01\n"
+".emtcode OP_ADD_SAT 0x1C\n"
+".emtcode OP_DP3 0x03\n"
+".emtcode OP_DP3_SAT 0x21\n"
+".emtcode OP_DP4 0x04\n"
+".emtcode OP_DP4_SAT 0x22\n"
+".emtcode OP_DPH 0x05\n"
+".emtcode OP_DPH_SAT 0x23\n"
+".emtcode OP_DST 0x06\n"
+".emtcode OP_DST_SAT 0x24\n"
+".emtcode OP_MAX 0x0F\n"
+".emtcode OP_MAX_SAT 0x2E\n"
+".emtcode OP_MIN 0x10\n"
+".emtcode OP_MIN_SAT 0x2F\n"
+".emtcode OP_MUL 0x12\n"
+".emtcode OP_MUL_SAT 0x31\n"
+".emtcode OP_SGE 0x16\n"
+".emtcode OP_SGE_SAT 0x37\n"
+".emtcode OP_SLT 0x17\n"
+".emtcode OP_SLT_SAT 0x3A\n"
+".emtcode OP_SUB 0x18\n"
+".emtcode OP_SUB_SAT 0x3B\n"
+".emtcode OP_XPD 0x1A\n"
+".emtcode OP_XPD_SAT 0x43\n"
+".emtcode OP_CMP 0x1D\n"
+".emtcode OP_CMP_SAT 0x1E\n"
+".emtcode OP_LRP 0x2B\n"
+".emtcode OP_LRP_SAT 0x2C\n"
+".emtcode OP_MAD 0x0E\n"
+".emtcode OP_MAD_SAT 0x2D\n"
+".emtcode OP_SWZ 0x19\n"
+".emtcode OP_SWZ_SAT 0x3C\n"
+".emtcode OP_TEX 0x3D\n"
+".emtcode OP_TEX_SAT 0x3E\n"
+".emtcode OP_TXB 0x3F\n"
+".emtcode OP_TXB_SAT 0x40\n"
+".emtcode OP_TXP 0x41\n"
+".emtcode OP_TXP_SAT 0x42\n"
+".emtcode OP_KIL 0x28\n"
+".emtcode OP_ARL 0x02\n"
+".emtcode OP_EXP 0x08\n"
+".emtcode OP_LOG 0x0D\n"
+".emtcode FRAGMENT_ATTRIB_COLOR 0x01\n"
+".emtcode FRAGMENT_ATTRIB_TEXCOORD 0x02\n"
+".emtcode FRAGMENT_ATTRIB_FOGCOORD 0x03\n"
+".emtcode FRAGMENT_ATTRIB_POSITION 0x04\n"
+".emtcode VERTEX_ATTRIB_POSITION 0x01\n"
+".emtcode VERTEX_ATTRIB_WEIGHT 0x02\n"
+".emtcode VERTEX_ATTRIB_NORMAL 0x03\n"
+".emtcode VERTEX_ATTRIB_COLOR 0x04\n"
+".emtcode VERTEX_ATTRIB_FOGCOORD 0x05\n"
+".emtcode VERTEX_ATTRIB_TEXCOORD 0x06\n"
+".emtcode VERTEX_ATTRIB_MATRIXINDEX 0x07\n"
+".emtcode VERTEX_ATTRIB_GENERIC 0x08\n"
+".emtcode FRAGMENT_RESULT_COLOR 0x01\n"
+".emtcode FRAGMENT_RESULT_DEPTH 0x02\n"
+".emtcode VERTEX_RESULT_POSITION 0x01\n"
+".emtcode VERTEX_RESULT_COLOR 0x02\n"
+".emtcode VERTEX_RESULT_FOGCOORD 0x03\n"
+".emtcode VERTEX_RESULT_POINTSIZE 0x04\n"
+".emtcode VERTEX_RESULT_TEXCOORD 0x05\n"
+".emtcode TEXTARGET_1D 0x01\n"
+".emtcode TEXTARGET_2D 0x02\n"
+".emtcode TEXTARGET_3D 0x03\n"
+".emtcode TEXTARGET_RECT 0x04\n"
+".emtcode TEXTARGET_CUBE 0x05\n"
+".emtcode TEXTARGET_SHADOW1D 0x06\n"
+".emtcode TEXTARGET_SHADOW2D 0x07\n"
+".emtcode TEXTARGET_SHADOWRECT 0x08\n"
+".emtcode FACE_FRONT 0x00\n"
+".emtcode FACE_BACK 0x01\n"
+".emtcode COLOR_PRIMARY 0x00\n"
+".emtcode COLOR_SECONDARY 0x01\n"
+".emtcode COMPONENT_X 0x00\n"
+".emtcode COMPONENT_Y 0x01\n"
+".emtcode COMPONENT_Z 0x02\n"
+".emtcode COMPONENT_W 0x03\n"
+".emtcode COMPONENT_0 0x04\n"
+".emtcode COMPONENT_1 0x05\n"
+".emtcode ARRAY_INDEX_ABSOLUTE 0x00\n"
+".emtcode ARRAY_INDEX_RELATIVE 0x01\n"
+".emtcode MATRIX_MODELVIEW 0x01\n"
+".emtcode MATRIX_PROJECTION 0x02\n"
+".emtcode MATRIX_MVP 0x03\n"
+".emtcode MATRIX_TEXTURE 0x04\n"
+".emtcode MATRIX_PALETTE 0x05\n"
+".emtcode MATRIX_PROGRAM 0x06\n"
+".emtcode MATRIX_MODIFIER_IDENTITY 0x00\n"
+".emtcode MATRIX_MODIFIER_INVERSE 0x01\n"
+".emtcode MATRIX_MODIFIER_TRANSPOSE 0x02\n"
+".emtcode MATRIX_MODIFIER_INVTRANS 0x03\n"
+".emtcode CONSTANT_SCALAR 0x01\n"
+".emtcode CONSTANT_VECTOR 0x02\n"
+".emtcode PROGRAM_PARAM_ENV 0x01\n"
+".emtcode PROGRAM_PARAM_LOCAL 0x02\n"
+".emtcode REGISTER_ATTRIB 0x01\n"
+".emtcode REGISTER_PARAM 0x02\n"
+".emtcode REGISTER_RESULT 0x03\n"
+".emtcode REGISTER_ESTABLISHED_NAME 0x04\n"
+".emtcode PARAM_NULL 0x00\n"
+".emtcode PARAM_ARRAY_ELEMENT 0x01\n"
+".emtcode PARAM_STATE_ELEMENT 0x02\n"
+".emtcode PARAM_PROGRAM_ELEMENT 0x03\n"
+".emtcode PARAM_PROGRAM_ELEMENTS 0x04\n"
+".emtcode PARAM_CONSTANT 0x05\n"
+".emtcode STATE_MATERIAL 0x01\n"
+".emtcode STATE_LIGHT 0x02\n"
+".emtcode STATE_LIGHT_MODEL 0x03\n"
+".emtcode STATE_LIGHT_PROD 0x04\n"
+".emtcode STATE_FOG 0x05\n"
+".emtcode STATE_MATRIX_ROWS 0x06\n"
+".emtcode STATE_TEX_ENV 0x07\n"
+".emtcode STATE_DEPTH 0x08\n"
+".emtcode STATE_TEX_GEN 0x09\n"
+".emtcode STATE_CLIP_PLANE 0x0A\n"
+".emtcode STATE_POINT 0x0B\n"
+".emtcode MATERIAL_AMBIENT 0x01\n"
+".emtcode MATERIAL_DIFFUSE 0x02\n"
+".emtcode MATERIAL_SPECULAR 0x03\n"
+".emtcode MATERIAL_EMISSION 0x04\n"
+".emtcode MATERIAL_SHININESS 0x05\n"
+".emtcode LIGHT_AMBIENT 0x01\n"
+".emtcode LIGHT_DIFFUSE 0x02\n"
+".emtcode LIGHT_SPECULAR 0x03\n"
+".emtcode LIGHT_POSITION 0x04\n"
+".emtcode LIGHT_ATTENUATION 0x05\n"
+".emtcode LIGHT_HALF 0x06\n"
+".emtcode LIGHT_SPOT_DIRECTION 0x07\n"
+".emtcode LIGHT_MODEL_AMBIENT 0x01\n"
+".emtcode LIGHT_MODEL_SCENECOLOR 0x02\n"
+".emtcode LIGHT_PROD_AMBIENT 0x01\n"
+".emtcode LIGHT_PROD_DIFFUSE 0x02\n"
+".emtcode LIGHT_PROD_SPECULAR 0x03\n"
+".emtcode TEX_ENV_COLOR 0x01\n"
+".emtcode TEX_GEN_EYE 0x01\n"
+".emtcode TEX_GEN_OBJECT 0x02\n"
+".emtcode FOG_COLOR 0x01\n"
+".emtcode FOG_PARAMS 0x02\n"
+".emtcode DEPTH_RANGE 0x01\n"
+".emtcode POINT_SIZE 0x01\n"
+".emtcode POINT_ATTENUATION 0x02\n"
+".emtcode ATTRIB 0x01\n"
+".emtcode PARAM 0x02\n"
+".emtcode TEMP 0x03\n"
+".emtcode OUTPUT 0x04\n"
+".emtcode ALIAS 0x05\n"
+".emtcode ADDRESS 0x06\n"
+".errtext UNKNOWN_PROGRAM_SIGNATURE \"1001: '$e_signature$': unknown program signature\"\n"
+".errtext MISSING_END_OR_INVALID_STATEMENT \"1002: '$e_statement$': invalid statement\"\n"
+".errtext CODE_AFTER_END \"1003: '$e_statement$': code after 'END' keyword\"\n"
+".errtext INVALID_PROGRAM_OPTION \"1004: '$e_identifier$': invalid program option\"\n"
+".errtext EXT_SWIZ_COMP_EXPECTED \"1005: extended swizzle component expected but '$e_token$' found\"\n"
+".errtext TEX_TARGET_EXPECTED \"1006: texture target expected but '$e_token$' found\"\n"
+".errtext TEXTURE_EXPECTED \"1007: 'texture' expected but '$e_identifier$' found\"\n"
+".errtext SOURCE_REGISTER_EXPECTED \"1008: source register expected but '$e_token$' found\"\n"
+".errtext DESTINATION_REGISTER_EXPECTED \"1009: destination register expected but '$e_token$' found\"\n"
+".errtext INVALID_ADDRESS_COMPONENT \"1010: '$e_identifier$': invalid address component\"\n"
+".errtext INVALID_ADDRESS_WRITEMASK \"1011: '$e_identifier$': invalid address writemask\"\n"
+".errtext INVALID_COMPONENT \"1012: '$e_charordigit$': invalid component\"\n"
+".errtext INVALID_SUFFIX \"1013: '$e_identifier$': invalid suffix\"\n"
+".errtext INVALID_WRITEMASK \"1014: '$e_identifier$': invalid writemask\"\n"
+".errtext FRAGMENT_EXPECTED \"1015: 'fragment' expected but '$e_identifier$' found\"\n"
+".errtext VERTEX_EXPECTED \"1016: 'vertex' expected but '$e_identifier$' found\"\n"
+".errtext INVALID_FRAGMENT_PROPERTY \"1017: '$e_identifier$': invalid fragment property\"\n"
+".errtext INVALID_VERTEX_PROPERTY \"1018: '$e_identifier$': invalid vertex property\"\n"
+".errtext INVALID_STATE_PROPERTY \"1019: '$e_identifier$': invalid state property\"\n"
+".errtext INVALID_MATERIAL_PROPERTY \"1020: '$e_identifier$': invalid material property\"\n"
+".errtext INVALID_LIGHT_PROPERTY \"1021: '$e_identifier$': invalid light property\"\n"
+".errtext INVALID_SPOT_PROPERTY \"1022: '$e_identifier$': invalid spot property\"\n"
+".errtext INVALID_LIGHTMODEL_PROPERTY \"1023: '$e_identifier$': invalid light model property\"\n"
+".errtext INVALID_LIGHTPROD_PROPERTY \"1024: '$e_identifier$': invalid light product property\"\n"
+".errtext INVALID_TEXENV_PROPERTY \"1025: '$e_identifier$': invalid texture environment property\"\n"
+".errtext INVALID_TEXGEN_PROPERTY \"1026: '$e_identifier$': invalid texture generating property\"\n"
+".errtext INVALID_TEXGEN_COORD \"1027: '$e_identifier$': invalid texture generating coord\"\n"
+".errtext INVALID_FOG_PROPERTY \"1028: '$e_identifier$': invalid fog property\"\n"
+".errtext INVALID_DEPTH_PROPERTY \"1029: '$e_identifier$': invalid depth property\"\n"
+".errtext INVALID_CLIPPLANE_PROPERTY \"1030: '$e_identifier$': invalid clip plane property\"\n"
+".errtext INVALID_POINT_PROPERTY \"1031: '$e_identifier$': invalid point property\"\n"
+".errtext MATRIX_ROW_SELECTOR_OR_MODIFIER_EXPECTED \"1032: matrix row selector or modifier expected but '$e_token$' found\"\n"
+".errtext INVALID_MATRIX_NAME \"1033: '$e_identifier$': invalid matrix name\"\n"
+".errtext INVALID_PROGRAM_PROPERTY \"1034: '$e_identifier$': invalid program property\"\n"
+".errtext RESULT_EXPECTED \"1035: 'result' expected but '$e_token$' found\"\n"
+".errtext INVALID_RESULT_PROPERTY \"1036: '$e_identifier$': invalid result property\"\n"
+".errtext INVALID_FACE_PROPERTY \"1037: '$e_identifier$': invalid face property\"\n"
+".errtext INVALID_COLOR_PROPERTY \"1038: '$e_identifier$': invalid color property\"\n"
+".errtext IDENTIFIER_EXPECTED \"1039: identifier expected but '$e_token$' found\"\n"
+".errtext RESERVED_KEYWORD \"1040: use of reserved keyword as an identifier\"\n"
+".errtext INTEGER_EXPECTED \"1041: integer value expected but '$e_token$' found\"\n"
+".errtext MISSING_SEMICOLON \"1042: ';' expected but '$e_token$' found\"\n"
+".errtext MISSING_COMMA \"1043: ',' expected but '$e_token$' found\"\n"
+".errtext MISSING_LBRACKET \"1044: '[' expected but '$e_token$' found\"\n"
+".errtext MISSING_RBRACKET \"1045: ']' expected but '$e_token$' found\"\n"
+".errtext MISSING_DOT \"1046: '.' expected but '$e_token$' found\"\n"
+".errtext MISSING_EQUAL \"1047: '=' expected but '$e_token$' found\"\n"
+".errtext MISSING_LBRACE \"1048: '{' expected but '$e_token$' found\"\n"
+".errtext MISSING_RBRACE \"1049: '}' expected but '$e_token$' found\"\n"
+".errtext MISSING_DOTDOT \"1050: '..' expected but '$e_token$' found\"\n"
+".errtext MISSING_FRACTION_OR_EXPONENT \"1051: missing fraction part or exponent\"\n"
+".errtext MISSING_DOT_OR_EXPONENT \"1052: missing '.' or exponent\"\n"
+".errtext EXPONENT_VALUE_EXPECTED \"1053: exponent value expected\"\n"
+".errtext INTEGER_OUT_OF_RANGE \"1054: integer value out of range\"\n"
+".errtext OPERATION_NEEDS_DESTINATION_VARIABLE \"1055: operation needs destination variable\"\n"
+".errtext OPERATION_NEEDS_SOURCE_VARIABLE \"1056: operation needs source variable\"\n"
+".errtext ADDRESS_REGISTER_EXPECTED \"1057: address register expected but '$e_token$' found\"\n"
+".errtext ADDRESS_REGISTER_OR_INTEGER_EXPECTED \"1058: address register or integer literal expected but '$e_token$' found\"\n"
+".regbyte vertex_blend 0x00\n"
+".regbyte matrix_palette 0x00\n"
+".regbyte point_parameters 0x00\n"
+".regbyte secondary_color 0x00\n"
+".regbyte fog_coord 0x00\n"
+".regbyte texture_rectangle 0x00\n"
+".regbyte fragment_program_shadow 0x00\n"
+".regbyte draw_buffers 0x00\n"
+".regbyte ARB_precision_hint_fastest 0x00\n"
+".regbyte ARB_precision_hint_nicest 0x00\n"
+".regbyte ARB_fog_exp 0x00\n"
+".regbyte ARB_fog_exp2 0x00\n"
+".regbyte ARB_fog_linear 0x00\n"
+".regbyte ARB_position_invariant 0x00\n"
+".regbyte ARB_fragment_program_shadow 0x00\n"
+".regbyte ARB_draw_buffers 0x00\n"
+".regbyte program_target 0x00\n"
+"program\n"
+" programs .error UNKNOWN_PROGRAM_SIGNATURE .emit REVISION;\n"
+"programs\n"
+" .if (program_target == 0x10) frag_program_1_0 .emit FRAGMENT_PROGRAM .emit 0x01 .emit 0x00 .or\n"
+" .if (program_target == 0x20) vert_program_1_0 .emit VERTEX_PROGRAM .emit 0x01 .emit 0x00;\n"
+"frag_program_1_0\n"
+" '!' .and '!' .and 'A' .and 'R' .and 'B' .and 'f' .and 'p' .and '1' .and '.' .and '0' .and\n"
+" optional_space .and fp_optionSequence .and fp_statementSequence .and\n"
+" \"END\" .error MISSING_END_OR_INVALID_STATEMENT .emit END .and optional_space .and\n"
+" '\\0' .error CODE_AFTER_END;\n"
+"vert_program_1_0\n"
+" '!' .and '!' .and 'A' .and 'R' .and 'B' .and 'v' .and 'p' .and '1' .and '.' .and '0' .and\n"
+" optional_space .and vp_optionSequence .and vp_statementSequence .and\n"
+" \"END\" .error MISSING_END_OR_INVALID_STATEMENT .emit END .and optional_space .and\n"
+" '\\0' .error CODE_AFTER_END;\n"
+"fp_optionSequence\n"
+" .loop fp_option;\n"
+"vp_optionSequence\n"
+" .loop vp_option;\n"
+"fp_option\n"
+" \"OPTION\" .emit OPTION .and space .error IDENTIFIER_EXPECTED .and\n"
+" fp_optionString .error INVALID_PROGRAM_OPTION .and semicolon;\n"
+"vp_option\n"
+" \"OPTION\" .emit OPTION .and space .error IDENTIFIER_EXPECTED .and\n"
+" vp_optionString .error INVALID_PROGRAM_OPTION .and semicolon;\n"
+"fp_optionString\n"
+" .if (ARB_precision_hint_nicest == 0x00) \"ARB_precision_hint_fastest\"\n"
+" .emit ARB_PRECISION_HINT_FASTEST .load ARB_precision_hint_fastest 0x01 .or\n"
+" .if (ARB_precision_hint_fastest == 0x00) \"ARB_precision_hint_nicest\"\n"
+" .emit ARB_PRECISION_HINT_NICEST .load ARB_precision_hint_nicest 0x01 .or\n"
+" fp_ARB_fog_exp .emit ARB_FOG_EXP .load ARB_fog_exp 0x01 .or\n"
+" fp_ARB_fog_exp2 .emit ARB_FOG_EXP2 .load ARB_fog_exp2 0x01 .or\n"
+" fp_ARB_fog_linear .emit ARB_FOG_LINEAR .load ARB_fog_linear 0x01 .or\n"
+" .if (fragment_program_shadow != 0x00) \"ARB_fragment_program_shadow\"\n"
+" .emit ARB_FRAGMENT_PROGRAM_SHADOW .load ARB_fragment_program_shadow 0x01 .or\n"
+" .if (draw_buffers != 0x00) \"ARB_draw_buffers\" .emit ARB_DRAW_BUFFERS\n"
+" .load ARB_draw_buffers 0x01;\n"
+"vp_optionString\n"
+" \"ARB_position_invariant\" .emit ARB_POSITION_INVARIANT .load ARB_position_invariant 0x01;\n"
+"fp_ARB_fog_exp\n"
+" .if (ARB_fog_exp2 == 0x00) .true .and .if (ARB_fog_linear == 0x00) \"ARB_fog_exp\";\n"
+"fp_ARB_fog_exp2\n"
+" .if (ARB_fog_exp == 0x00) .true .and .if (ARB_fog_linear == 0x00) \"ARB_fog_exp2\";\n"
+"fp_ARB_fog_linear\n"
+" .if (ARB_fog_exp == 0x00) .true .and .if (ARB_fog_exp2 == 0x00) \"ARB_fog_linear\";\n"
+"fp_statementSequence\n"
+" .loop fp_statement;\n"
+"vp_statementSequence\n"
+" .loop vp_statement;\n"
+"fp_statement\n"
+" fp_statement_1 .or fp_statement_2;\n"
+"vp_statement\n"
+" vp_statement_1 .or vp_statement_2;\n"
+"fp_statement_1\n"
+" fp_instruction .emit INSTRUCTION .emit $ .and semicolon;\n"
+"fp_statement_2\n"
+" fp_namingStatement .emit DECLARATION .and semicolon;\n"
+"vp_statement_1\n"
+" vp_instruction .emit INSTRUCTION .emit $ .and semicolon;\n"
+"vp_statement_2\n"
+" vp_namingStatement .emit DECLARATION .and semicolon;\n"
+"fp_instruction\n"
+" ALUInstruction .emit OP_ALU_INST .or\n"
+" TexInstruction .emit OP_TEX_INST;\n"
+"vp_instruction\n"
+" ARL_instruction .emit OP_ALU_ARL .or\n"
+" vp_VECTORop_instruction .emit OP_ALU_VECTOR .or\n"
+" vp_SCALARop_instruction .emit OP_ALU_SCALAR .or\n"
+" vp_BINSCop_instruction .emit OP_ALU_BINSC .or\n"
+" vp_BINop_instruction .emit OP_ALU_BIN .or\n"
+" vp_TRIop_instruction .emit OP_ALU_TRI .or\n"
+" vp_SWZ_instruction .emit OP_ALU_SWZ;\n"
+"ALUInstruction\n"
+" fp_VECTORop_instruction .emit OP_ALU_VECTOR .or\n"
+" fp_SCALARop_instruction .emit OP_ALU_SCALAR .or\n"
+" fp_BINSCop_instruction .emit OP_ALU_BINSC .or\n"
+" fp_BINop_instruction .emit OP_ALU_BIN .or\n"
+" fp_TRIop_instruction .emit OP_ALU_TRI .or\n"
+" fp_SWZ_instruction .emit OP_ALU_SWZ;\n"
+"TexInstruction\n"
+" SAMPLE_instruction .emit OP_TEX_SAMPLE .or\n"
+" KIL_instruction .emit OP_TEX_KIL;\n"
+"ARL_instruction\n"
+" \"ARL\" .emit OP_ARL .and space_dst .and maskedAddrReg .and comma .and vp_scalarSrcReg;\n"
+"fp_VECTORop_instruction\n"
+" fp_VECTORop .and space_dst .and fp_maskedDstReg .and comma .and vectorSrcReg;\n"
+"vp_VECTORop_instruction\n"
+" vp_VECTORop .and space_dst .and vp_maskedDstReg .and comma .and swizzleSrcReg;\n"
+"fp_VECTORop\n"
+" \"ABS\" .emit OP_ABS .or \"ABS_SAT\" .emit OP_ABS_SAT .or\n"
+" \"FLR\" .emit OP_FLR .or \"FLR_SAT\" .emit OP_FLR_SAT .or\n"
+" \"FRC\" .emit OP_FRC .or \"FRC_SAT\" .emit OP_FRC_SAT .or\n"
+" \"LIT\" .emit OP_LIT .or \"LIT_SAT\" .emit OP_LIT_SAT .or\n"
+" \"MOV\" .emit OP_MOV .or \"MOV_SAT\" .emit OP_MOV_SAT;\n"
+"vp_VECTORop\n"
+" \"ABS\" .emit OP_ABS .or\n"
+" \"FLR\" .emit OP_FLR .or\n"
+" \"FRC\" .emit OP_FRC .or\n"
+" \"LIT\" .emit OP_LIT .or\n"
+" \"MOV\" .emit OP_MOV;\n"
+"fp_SCALARop_instruction\n"
+" fp_SCALARop .and space_dst .and fp_maskedDstReg .and comma .and fp_scalarSrcReg;\n"
+"vp_SCALARop_instruction\n"
+" vp_SCALARop .and space_dst .and vp_maskedDstReg .and comma .and vp_scalarSrcReg;\n"
+"fp_SCALARop\n"
+" \"COS\" .emit OP_COS .or \"COS_SAT\" .emit OP_COS_SAT .or\n"
+" \"EX2\" .emit OP_EX2 .or \"EX2_SAT\" .emit OP_EX2_SAT .or\n"
+" \"LG2\" .emit OP_LG2 .or \"LG2_SAT\" .emit OP_LG2_SAT .or\n"
+" \"RCP\" .emit OP_RCP .or \"RCP_SAT\" .emit OP_RCP_SAT .or\n"
+" \"RSQ\" .emit OP_RSQ .or \"RSQ_SAT\" .emit OP_RSQ_SAT .or\n"
+" \"SIN\" .emit OP_SIN .or \"SIN_SAT\" .emit OP_SIN_SAT .or\n"
+" \"SCS\" .emit OP_SCS .or \"SCS_SAT\" .emit OP_SCS_SAT;\n"
+"vp_SCALARop\n"
+" \"EX2\" .emit OP_EX2 .or\n"
+" \"EXP\" .emit OP_EXP .or\n"
+" \"LG2\" .emit OP_LG2 .or\n"
+" \"LOG\" .emit OP_LOG .or\n"
+" \"RCP\" .emit OP_RCP .or\n"
+" \"RSQ\" .emit OP_RSQ;\n"
+"fp_BINSCop_instruction\n"
+" fp_BINSCop .and space_dst .and fp_maskedDstReg .and comma .and fp_scalarSrcReg .and comma .and\n"
+" fp_scalarSrcReg;\n"
+"vp_BINSCop_instruction\n"
+" vp_BINSCop .and space_dst .and vp_maskedDstReg .and comma .and vp_scalarSrcReg .and comma .and\n"
+" vp_scalarSrcReg;\n"
+"fp_BINSCop\n"
+" \"POW\" .emit OP_POW .or \"POW_SAT\" .emit OP_POW_SAT;\n"
+"vp_BINSCop\n"
+" \"POW\" .emit OP_POW;\n"
+"fp_BINop_instruction\n"
+" fp_BINop .and space_dst .and fp_maskedDstReg .and comma .and vectorSrcReg .and comma .and\n"
+" vectorSrcReg;\n"
+"vp_BINop_instruction\n"
+" vp_BINop .and space_dst .and vp_maskedDstReg .and comma .and swizzleSrcReg .and comma .and\n"
+" swizzleSrcReg;\n"
+"fp_BINop\n"
+" \"ADD\" .emit OP_ADD .or \"ADD_SAT\" .emit OP_ADD_SAT .or\n"
+" \"DP3\" .emit OP_DP3 .or \"DP3_SAT\" .emit OP_DP3_SAT .or\n"
+" \"DP4\" .emit OP_DP4 .or \"DP4_SAT\" .emit OP_DP4_SAT .or\n"
+" \"DPH\" .emit OP_DPH .or \"DPH_SAT\" .emit OP_DPH_SAT .or\n"
+" \"DST\" .emit OP_DST .or \"DST_SAT\" .emit OP_DST_SAT .or\n"
+" \"MAX\" .emit OP_MAX .or \"MAX_SAT\" .emit OP_MAX_SAT .or\n"
+" \"MIN\" .emit OP_MIN .or \"MIN_SAT\" .emit OP_MIN_SAT .or\n"
+" \"MUL\" .emit OP_MUL .or \"MUL_SAT\" .emit OP_MUL_SAT .or\n"
+" \"SGE\" .emit OP_SGE .or \"SGE_SAT\" .emit OP_SGE_SAT .or\n"
+" \"SLT\" .emit OP_SLT .or \"SLT_SAT\" .emit OP_SLT_SAT .or\n"
+" \"SUB\" .emit OP_SUB .or \"SUB_SAT\" .emit OP_SUB_SAT .or\n"
+" \"XPD\" .emit OP_XPD .or \"XPD_SAT\" .emit OP_XPD_SAT;\n"
+"vp_BINop\n"
+" \"ADD\" .emit OP_ADD .or\n"
+" \"DP3\" .emit OP_DP3 .or\n"
+" \"DP4\" .emit OP_DP4 .or\n"
+" \"DPH\" .emit OP_DPH .or\n"
+" \"DST\" .emit OP_DST .or\n"
+" \"MAX\" .emit OP_MAX .or\n"
+" \"MIN\" .emit OP_MIN .or\n"
+" \"MUL\" .emit OP_MUL .or\n"
+" \"SGE\" .emit OP_SGE .or\n"
+" \"SLT\" .emit OP_SLT .or\n"
+" \"SUB\" .emit OP_SUB .or\n"
+" \"XPD\" .emit OP_XPD;\n"
+"fp_TRIop_instruction\n"
+" fp_TRIop .and space_dst .and fp_maskedDstReg .and comma .and vectorSrcReg .and comma .and\n"
+" vectorSrcReg .and comma .and vectorSrcReg;\n"
+"vp_TRIop_instruction\n"
+" vp_TRIop .and space_dst .and vp_maskedDstReg .and comma .and swizzleSrcReg .and comma .and\n"
+" swizzleSrcReg .and comma .and swizzleSrcReg;\n"
+"fp_TRIop\n"
+" \"CMP\" .emit OP_CMP .or \"CMP_SAT\" .emit OP_CMP_SAT .or\n"
+" \"LRP\" .emit OP_LRP .or \"LRP_SAT\" .emit OP_LRP_SAT .or\n"
+" \"MAD\" .emit OP_MAD .or \"MAD_SAT\" .emit OP_MAD_SAT;\n"
+"vp_TRIop\n"
+" \"MAD\" .emit OP_MAD;\n"
+"fp_SWZ_instruction\n"
+" SWZop .and space_dst .and fp_maskedDstReg .and comma .and fp_srcReg .and comma .and\n"
+" fp_extendedSwizzle .error EXT_SWIZ_COMP_EXPECTED;\n"
+"vp_SWZ_instruction\n"
+" \"SWZ\" .emit OP_SWZ .and space_dst .and vp_maskedDstReg .and comma .and vp_srcReg .and comma .and\n"
+" vp_extendedSwizzle .error EXT_SWIZ_COMP_EXPECTED;\n"
+"SWZop\n"
+" \"SWZ\" .emit OP_SWZ .or \"SWZ_SAT\" .emit OP_SWZ_SAT;\n"
+"SAMPLE_instruction\n"
+" SAMPLEop .and space_dst .and fp_maskedDstReg .and comma .and vectorSrcReg .and comma .and\n"
+" texImageUnit .and comma .and texTarget .error TEX_TARGET_EXPECTED;\n"
+"SAMPLEop\n"
+" \"TEX\" .emit OP_TEX .or \"TEX_SAT\" .emit OP_TEX_SAT .or\n"
+" \"TXB\" .emit OP_TXB .or \"TXB_SAT\" .emit OP_TXB_SAT .or\n"
+" \"TXP\" .emit OP_TXP .or \"TXP_SAT\" .emit OP_TXP_SAT;\n"
+"KIL_instruction\n"
+" \"KIL\" .emit OP_KIL .and space_src .and vectorSrcReg;\n"
+"texImageUnit\n"
+" \"texture\" .error TEXTURE_EXPECTED .and optTexImageUnitNum;\n"
+"texTarget\n"
+" \"1D\" .emit TEXTARGET_1D .or\n"
+" \"2D\" .emit TEXTARGET_2D .or\n"
+" \"3D\" .emit TEXTARGET_3D .or\n"
+" .if (texture_rectangle != 0x00) \"RECT\" .emit TEXTARGET_RECT .or\n"
+" \"CUBE\" .emit TEXTARGET_CUBE .or\n"
+" .if (ARB_fragment_program_shadow != 0x00) shadowTarget;\n"
+"shadowTarget\n"
+" \"SHADOW1D\" .emit TEXTARGET_SHADOW1D .or\n"
+" \"SHADOW2D\" .emit TEXTARGET_SHADOW2D .or\n"
+" .if (texture_rectangle != 0x00) \"SHADOWRECT\" .emit TEXTARGET_SHADOWRECT;\n"
+"optTexImageUnitNum\n"
+" optTexImageUnitNum_1 .or .true .emit 0x00;\n"
+"optTexImageUnitNum_1\n"
+" lbracket_ne .and texImageUnitNum .and rbracket;\n"
+"texImageUnitNum\n"
+" integer;\n"
+"fp_scalarSrcReg\n"
+" optionalSign .and fp_srcReg .and fp_scalarSuffix;\n"
+"vp_scalarSrcReg\n"
+" optionalSign .and vp_srcReg .and vp_scalarSuffix;\n"
+"swizzleSrcReg\n"
+" optionalSign .and vp_srcReg .and swizzleSuffix;\n"
+"vectorSrcReg\n"
+" optionalSign .and fp_srcReg .and optionalSuffix;\n"
+"fp_maskedDstReg\n"
+" fp_dstReg .and fp_optionalMask;\n"
+"vp_maskedDstReg\n"
+" vp_dstReg .and vp_optionalMask;\n"
+"maskedAddrReg\n"
+" addrReg .error ADDRESS_REGISTER_EXPECTED .and addrWriteMask;\n"
+"fp_extendedSwizzle\n"
+" rgbaExtendedSwizzle .or xyzwExtendedSwizzle;\n"
+"vp_extendedSwizzle\n"
+" extSwizComp .and comma .and\n"
+" extSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and\n"
+" extSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and\n"
+" extSwizComp .error EXT_SWIZ_COMP_EXPECTED;\n"
+"xyzwExtendedSwizzle\n"
+" xyzwExtSwizComp .and comma .and\n"
+" xyzwExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and\n"
+" xyzwExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and\n"
+" xyzwExtSwizComp .error EXT_SWIZ_COMP_EXPECTED;\n"
+"rgbaExtendedSwizzle\n"
+" rgbaExtendedSwizzle_1 .or rgbaExtendedSwizzle_2 .or rgbaExtendedSwizzle_3 .or\n"
+" rgbaExtendedSwizzle_4;\n"
+"rgbaExtendedSwizzle_1\n"
+" rgbaExtSwizComp_digit .and comma .and rgbaExtSwizComp_digit .and comma .and\n"
+" rgbaExtSwizComp_digit .and comma .and rgbaExtSwizComp;\n"
+"rgbaExtendedSwizzle_2\n"
+" rgbaExtSwizComp_digit .and comma .and rgbaExtSwizComp_digit .and comma .and\n"
+" rgbaExtSwizComp_alpha .and comma .and rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED;\n"
+"rgbaExtendedSwizzle_3\n"
+" rgbaExtSwizComp_digit .and comma .and rgbaExtSwizComp_alpha .and comma .and\n"
+" rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and\n"
+" rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED;\n"
+"rgbaExtendedSwizzle_4\n"
+" rgbaExtSwizComp_alpha .and comma .and \n"
+"rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and\n"
+" rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED .and comma .and\n"
+" rgbaExtSwizComp .error EXT_SWIZ_COMP_EXPECTED;\n"
+"xyzwExtSwizComp\n"
+" optionalSign .and xyzwExtSwizSel;\n"
+"rgbaExtSwizComp\n"
+" optionalSign .and rgbaExtSwizSel;\n"
+"rgbaExtSwizComp_digit\n"
+" optionalSign .and rgbaExtSwizSel_digit;\n"
+"rgbaExtSwizComp_alpha\n"
+" optionalSign .and rgbaExtSwizSel_alpha;\n"
+"extSwizComp\n"
+" optionalSign .and extSwizSel;\n"
+"xyzwExtSwizSel\n"
+" \"0\" .emit COMPONENT_0 .or \"1\" .emit COMPONENT_1 .or xyzwComponent_single;\n"
+"rgbaExtSwizSel\n"
+" rgbaExtSwizSel_digit .or rgbaExtSwizSel_alpha;\n"
+"rgbaExtSwizSel_digit\n"
+" \"0\" .emit COMPONENT_0 .or \"1\" .emit COMPONENT_1;\n"
+"rgbaExtSwizSel_alpha\n"
+" rgbaComponent_single;\n"
+"extSwizSel\n"
+" \"0\" .emit COMPONENT_0 .or \"1\" .emit COMPONENT_1 .or vp_component_single;\n"
+"fp_srcReg\n"
+" fp_srcReg_1 .error SOURCE_REGISTER_EXPECTED;\n"
+"vp_srcReg\n"
+" vp_srcReg_1 .error SOURCE_REGISTER_EXPECTED;\n"
+"fp_srcReg_1\n"
+" fragmentAttribReg .emit REGISTER_ATTRIB .or\n"
+" fp_progParamReg .emit REGISTER_PARAM .or\n"
+" fp_temporaryReg .emit REGISTER_ESTABLISHED_NAME;\n"
+"vp_srcReg_1\n"
+" vertexAttribReg .emit REGISTER_ATTRIB .or\n"
+" vp_progParamReg .emit REGISTER_PARAM .or\n"
+" vp_temporaryReg .emit REGISTER_ESTABLISHED_NAME;\n"
+"fp_dstReg\n"
+" fp_dstReg_1 .error DESTINATION_REGISTER_EXPECTED;\n"
+"vp_dstReg\n"
+" vp_dstReg_1 .error DESTINATION_REGISTER_EXPECTED;\n"
+"fp_dstReg_1\n"
+" fragmentResultReg .emit REGISTER_RESULT .or\n"
+" fp_temporaryReg .emit REGISTER_ESTABLISHED_NAME;\n"
+"vp_dstReg_1\n"
+" vertexResultReg .emit REGISTER_RESULT .or\n"
+" vp_temporaryReg .emit REGISTER_ESTABLISHED_NAME;\n"
+"fragmentAttribReg\n"
+" fragAttribBinding;\n"
+"vertexAttribReg\n"
+" vtxAttribBinding;\n"
+"fp_temporaryReg\n"
+" fp_establishedName_no_error_on_identifier;\n"
+"vp_temporaryReg\n"
+" vp_establishedName_no_error_on_identifier;\n"
+"fp_progParamReg\n"
+" fp_paramSingleItemUse .or fp_progParamReg_1 .or fp_progParamSingle;\n"
+"vp_progParamReg\n"
+" vp_paramSingleItemUse .or vp_progParamReg_1 .or vp_progParamSingle;\n"
+"fp_progParamReg_1\n"
+" fp_progParamArray .emit PARAM_ARRAY_ELEMENT .and lbracket_ne .and progParamArrayAbs .and\n"
+" rbracket;\n"
+"vp_progParamReg_1\n"
+" vp_progParamArray .emit PARAM_ARRAY_ELEMENT .and lbracket_ne .and progParamArrayMem .and\n"
+" rbracket;\n"
+"fp_progParamSingle\n"
+" .false;\n"
+"vp_progParamSingle\n"
+" .false;\n"
+"fp_progParamArray\n"
+" fp_establishedName_no_error_on_identifier;\n"
+"vp_progParamArray\n"
+" vp_establishedName_no_error_on_identifier;\n"
+"progParamArrayMem\n"
+" progParamArrayAbs .or progParamArrayRel;\n"
+"progParamArrayAbs\n"
+" integer_ne .emit ARRAY_INDEX_ABSOLUTE;\n"
+"progParamArrayRel\n"
+" addrReg .error ADDRESS_REGISTER_OR_INTEGER_EXPECTED .emit ARRAY_INDEX_RELATIVE .and\n"
+" addrComponent .and addrRegRelOffset;\n"
+"addrRegRelOffset\n"
+" addrRegRelOffset_1 .or addrRegRelOffset_2 .or .true .emit 0x00;\n"
+"addrRegRelOffset_1\n"
+" plus_ne .and addrRegPosOffset;\n"
+"addrRegRelOffset_2\n"
+" minus_ne .and addrRegNegOffset;\n"
+"addrRegPosOffset\n"
+" integer_0_63;\n"
+"addrRegNegOffset\n"
+" integer_0_64;\n"
+"fragmentResultReg\n"
+" fp_resultBinding;\n"
+"vertexResultReg\n"
+" vp_resultBinding;\n"
+"addrReg\n"
+" vp_establishedName_no_error_on_identifier;\n"
+"addrComponent\n"
+" dot .and \"x\" .error INVALID_ADDRESS_COMPONENT .emit COMPONENT_X .emit COMPONENT_X\n"
+" .emit COMPONENT_X .emit COMPONENT_X;\n"
+"addrWriteMask\n"
+" dot .and \"x\" .error INVALID_ADDRESS_WRITEMASK .emit 0x08;\n"
+"fp_scalarSuffix\n"
+" dot .and fp_component_single .error INVALID_COMPONENT;\n"
+"vp_scalarSuffix\n"
+" dot .and vp_component_single .error INVALID_COMPONENT;\n"
+"swizzleSuffix\n"
+" swizzleSuffix_1 .or\n"
+" .true .emit COMPONENT_X .emit COMPONENT_Y .emit COMPONENT_Z .emit COMPONENT_W;\n"
+"swizzleSuffix_1\n"
+" dot_ne .and swizzleSuffix_2 .error INVALID_SUFFIX;\n"
+"swizzleSuffix_2\n"
+" swizzleSuffix_3 .or swizzleSuffix_4;\n"
+"swizzleSuffix_3\n"
+" vp_component_multi .and vp_component_multi .and vp_component_multi .error INVALID_COMPONENT .and\n"
+" vp_component_multi .error INVALID_COMPONENT;\n"
+"swizzleSuffix_4\n"
+" \"x\" .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .or\n"
+" \"y\" .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .or\n"
+" \"z\" .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .or\n"
+" \"w\" .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W;\n"
+"optionalSuffix\n"
+" optionalSuffix_1 .or\n"
+" .true .emit COMPONENT_X .emit COMPONENT_Y .emit COMPONENT_Z .emit COMPONENT_W;\n"
+"optionalSuffix_1\n"
+" dot_ne .and optionalSuffix_2 .error INVALID_SUFFIX;\n"
+"optionalSuffix_2\n"
+" optionalSuffix_3 .or optionalSuffix_4 .or optionalSuffix_5;\n"
+"optionalSuffix_3\n"
+" xyzwComponent_multi .and xyzwComponent_multi .and\n"
+" xyzwComponent_multi .error INVALID_COMPONENT .and xyzwComponent_multi .error INVALID_COMPONENT;\n"
+"optionalSuffix_4\n"
+" rgbaComponent_multi .and rgbaComponent_multi .and\n"
+" rgbaComponent_multi .error INVALID_COMPONENT .and rgbaComponent_multi .error INVALID_COMPONENT;\n"
+"optionalSuffix_5\n"
+" \"x\" .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .or\n"
+" \"y\" .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .or\n"
+" \"z\" .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .or\n"
+" \"w\" .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W .or\n"
+" \"r\" .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .emit COMPONENT_X .or\n"
+" \"g\" .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .emit COMPONENT_Y .or\n"
+" \"b\" .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .emit COMPONENT_Z .or\n"
+" \"a\" .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W .emit COMPONENT_W;\n"
+"fp_component_single\n"
+" xyzwComponent_single .or rgbaComponent_single;\n"
+"vp_component_multi\n"
+" 'x' .emit COMPONENT_X .or 'y' .emit COMPONENT_Y .or 'z' .emit COMPONENT_Z .or\n"
+" 'w' .emit COMPONENT_W;\n"
+"vp_component_single\n"
+" \"x\" .emit COMPONENT_X .or \"y\" .emit COMPONENT_Y .or \"z\" .emit COMPONENT_Z .or\n"
+" \"w\" .emit COMPONENT_W;\n"
+"xyzwComponent_multi\n"
+" 'x' .emit COMPONENT_X .or 'y' .emit COMPONENT_Y .or 'z' .emit COMPONENT_Z .or\n"
+" 'w' .emit COMPONENT_W;\n"
+"xyzwComponent_single\n"
+" \"x\" .emit COMPONENT_X .or \"y\" .emit COMPONENT_Y .or \"z\" .emit COMPONENT_Z .or\n"
+" \"w\" .emit COMPONENT_W;\n"
+"rgbaComponent_multi\n"
+" 'r' .emit COMPONENT_X .or 'g' .emit COMPONENT_Y .or 'b' .emit COMPONENT_Z .or\n"
+" 'a' .emit COMPONENT_W;\n"
+"rgbaComponent_single\n"
+" \"r\" .emit COMPONENT_X .or \"g\" .emit COMPONENT_Y .or \"b\" .emit COMPONENT_Z .or\n"
+" \"a\" .emit COMPONENT_W;\n"
+"fp_optionalMask\n"
+" rgbaMask .or xyzwMask .or .true .emit 0x0F;\n"
+"vp_optionalMask\n"
+" xyzwMask .or .true .emit 0x0F;\n"
+"xyzwMask\n"
+" dot_ne .and xyzwMask_1 .error INVALID_WRITEMASK;\n"
+"xyzwMask_1\n"
+" \"xyzw\" .emit 0x0F .or \"xyz\" .emit 0x0E .or \"xyw\" .emit 0x0D .or \"xy\" .emit 0x0C .or\n"
+" \"xzw\" .emit 0x0B .or \"xz\" .emit 0x0A .or \"xw\" .emit 0x09 .or \"x\" .emit 0x08 .or\n"
+" \"yzw\" .emit 0x07 .or \"yz\" .emit 0x06 .or \"yw\" .emit 0x05 .or \"y\" .emit 0x04 .or\n"
+" \"zw\" .emit 0x03 .or \"z\" .emit 0x02 .or \"w\" .emit 0x01;\n"
+"rgbaMask\n"
+" dot_ne .and rgbaMask_1;\n"
+"rgbaMask_1\n"
+" \"rgba\" .emit 0x0F .or \"rgb\" .emit 0x0E .or \"rga\" .emit 0x0D .or \"rg\" .emit 0x0C .or\n"
+" \"rba\" .emit 0x0B .or \"rb\" .emit 0x0A .or \"ra\" .emit 0x09 .or \"r\" .emit 0x08 .or\n"
+" \"gba\" .emit 0x07 .or \"gb\" .emit 0x06 .or \"ga\" .emit 0x05 .or \"g\" .emit 0x04 .or\n"
+" \"ba\" .emit 0x03 .or \"b\" .emit 0x02 .or \"a\" .emit 0x01;\n"
+"fp_namingStatement\n"
+" fp_ATTRIB_statement .emit ATTRIB .or\n"
+" fp_PARAM_statement .emit PARAM .or\n"
+" fp_TEMP_statement .emit TEMP .or\n"
+" fp_OUTPUT_statement .emit OUTPUT .or\n"
+" fp_ALIAS_statement .emit ALIAS;\n"
+"vp_namingStatement\n"
+" vp_ATTRIB_statement .emit ATTRIB .or\n"
+" vp_PARAM_statement .emit PARAM .or\n"
+" vp_TEMP_statement .emit TEMP .or\n"
+" ADDRESS_statement .emit ADDRESS .or\n"
+" vp_OUTPUT_statement .emit OUTPUT .or\n"
+" vp_ALIAS_statement .emit ALIAS;\n"
+"fp_ATTRIB_statement\n"
+" \"ATTRIB\" .and space .and fp_establishName .and equal .and\n"
+" fragAttribBinding .error FRAGMENT_EXPECTED;\n"
+"vp_ATTRIB_statement\n"
+" \"ATTRIB\" .and space .and vp_establishName .and equal .and\n"
+" vtxAttribBinding .error VERTEX_EXPECTED;\n"
+"fragAttribBinding\n"
+" \"fragment\" .and dot .and fragAttribItem .error INVALID_FRAGMENT_PROPERTY;\n"
+"vtxAttribBinding\n"
+" \"vertex\" .and dot .and vtxAttribItem .error INVALID_VERTEX_PROPERTY;\n"
+"fragAttribItem\n"
+" fragAttribItem_1 .emit FRAGMENT_ATTRIB_COLOR .or\n"
+" fragAttribItem_2 .emit FRAGMENT_ATTRIB_TEXCOORD .or\n"
+" .if (fog_coord != 0x00) \"fogcoord\" .emit FRAGMENT_ATTRIB_FOGCOORD .or\n"
+" \"position\" .emit FRAGMENT_ATTRIB_POSITION;\n"
+"fragAttribItem_1\n"
+" \"color\" .and optColorType;\n"
+"fragAttribItem_2\n"
+" \"texcoord\" .and optTexCoordNum;\n"
+"vtxAttribItem\n"
+" \"position\" .emit VERTEX_ATTRIB_POSITION .or\n"
+" .if (vertex_blend != 0x00) vtxAttribItem_1 .emit VERTEX_ATTRIB_WEIGHT .or\n"
+" \"normal\" .emit VERTEX_ATTRIB_NORMAL .or\n"
+" vtxAttribItem_2 .emit VERTEX_ATTRIB_COLOR .or\n"
+" \"fogcoord\" .emit VERTEX_ATTRIB_FOGCOORD .or\n"
+" vtxAttribItem_3 .emit VERTEX_ATTRIB_TEXCOORD .or\n"
+" .if (matrix_palette != 0x00) vtxAttribItem_4 .emit VERTEX_ATTRIB_MATRIXINDEX .or\n"
+" vtxAttribItem_5 .emit VERTEX_ATTRIB_GENERIC;\n"
+"vtxAttribItem_1\n"
+" \"weight\" .and vtxOptWeightNum;\n"
+"vtxAttribItem_2\n"
+" \"color\" .and optColorType;\n"
+"vtxAttribItem_3\n"
+" \"texcoord\" .and optTexCoordNum;\n"
+"vtxAttribItem_4\n"
+" \"matrixindex\" .and lbracket .and vtxWeightNum .and rbracket;\n"
+"vtxAttribItem_5\n"
+" \"attrib\" .and lbracket .and vtxAttribNum .and rbracket;\n"
+"vtxAttribNum\n"
+" integer;\n"
+"vtxOptWeightNum\n"
+" vtxOptWeightNum_1 .or .true .emit 0x00;\n"
+"vtxOptWeightNum_1\n"
+" lbracket_ne .and vtxWeightNum .and rbracket;\n"
+"vtxWeightNum\n"
+" integer;\n"
+"fp_PARAM_statement\n"
+" fp_PARAM_multipleStmt .or fp_PARAM_singleStmt;\n"
+"vp_PARAM_statement\n"
+" vp_PARAM_multipleStmt .or vp_PARAM_singleStmt;\n"
+"fp_PARAM_singleStmt\n"
+" \"PARAM\" .and space .and fp_establishName .and .true .emit 0x00 .and fp_paramSingleInit .and\n"
+" .true .emit PARAM_NULL;\n"
+"vp_PARAM_singleStmt\n"
+" \"PARAM\" .and space .and vp_establishName .and .true .emit 0x00 .and vp_paramSingleInit .and\n"
+" .true .emit PARAM_NULL;\n"
+"fp_PARAM_multipleStmt\n"
+" \"PARAM\" .and space .and fp_establishName .and lbracket_ne .and optArraySize .and rbracket .and\n"
+" fp_paramMultipleInit .and .true .emit PARAM_NULL;\n"
+"vp_PARAM_multipleStmt\n"
+" \"PARAM\" .and space .and vp_establishName .and lbracket_ne .and optArraySize .and rbracket .and\n"
+" vp_paramMultipleInit .and .true .emit PARAM_NULL;\n"
+"optArraySize\n"
+" optional_integer;\n"
+"fp_paramSingleInit\n"
+" equal .and fp_paramSingleItemDecl;\n"
+"vp_paramSingleInit\n"
+" equal .and vp_paramSingleItemDecl;\n"
+"fp_paramMultipleInit\n"
+" equal .and lbrace .and fp_paramMultInitList .and rbrace;\n"
+"vp_paramMultipleInit\n"
+" equal .and lbrace .and vp_paramMultInitList .and rbrace;\n"
+"fp_paramMultInitList\n"
+" fp_paramMultInitList_1 .or fp_paramMultipleItem;\n"
+"vp_paramMultInitList\n"
+" vp_paramMultInitList_1 .or vp_paramMultipleItem;\n"
+"fp_paramMultInitList_1\n"
+" fp_paramMultipleItem .and comma_ne .and fp_paramMultInitList;\n"
+"vp_paramMultInitList_1\n"
+" vp_paramMultipleItem .and comma_ne .and vp_paramMultInitList;\n"
+"fp_paramSingleItemDecl\n"
+" fp_stateSingleItem .emit PARAM_STATE_ELEMENT .or\n"
+" programSingleItem .emit PARAM_PROGRAM_ELEMENT .or\n"
+" paramConstDecl .emit PARAM_CONSTANT;\n"
+"vp_paramSingleItemDecl\n"
+" vp_stateSingleItem .emit PARAM_STATE_ELEMENT .or\n"
+" programSingleItem .emit PARAM_PROGRAM_ELEMENT .or\n"
+" paramConstDecl .emit PARAM_CONSTANT;\n"
+"fp_paramSingleItemUse\n"
+" fp_stateSingleItem .emit PARAM_STATE_ELEMENT .or\n"
+" programSingleItem .emit PARAM_PROGRAM_ELEMENT .or\n"
+" paramConstUse .emit PARAM_CONSTANT;\n"
+"vp_paramSingleItemUse\n"
+" vp_stateSingleItem .emit PARAM_STATE_ELEMENT .or\n"
+" programSingleItem .emit PARAM_PROGRAM_ELEMENT .or\n"
+" paramConstUse .emit PARAM_CONSTANT;\n"
+"fp_paramMultipleItem\n"
+" fp_stateMultipleItem .emit PARAM_STATE_ELEMENT .or\n"
+" programMultipleItem .emit PARAM_PROGRAM_ELEMENT .or\n"
+" paramConstDecl .emit PARAM_CONSTANT;\n"
+"vp_paramMultipleItem\n"
+" vp_stateMultipleItem .emit PARAM_STATE_ELEMENT .or\n"
+" programMultipleItem .emit PARAM_PROGRAM_ELEMENT .or\n"
+" paramConstDecl .emit PARAM_CONSTANT;\n"
+"fp_stateMultipleItem\n"
+" stateMultipleItem_1 .or fp_stateSingleItem;\n"
+"vp_stateMultipleItem\n"
+" stateMultipleItem_1 .or vp_stateSingleItem;\n"
+"stateMultipleItem_1\n"
+" \"state\" .and dot .and stateMatrixRows .emit STATE_MATRIX_ROWS;\n"
+"fp_stateSingleItem\n"
+" \"state\" .and dot .and fp_stateSingleItem_1 .error INVALID_STATE_PROPERTY;\n"
+"vp_stateSingleItem\n"
+" \"state\" .and dot .and vp_stateSingleItem_1 .error INVALID_STATE_PROPERTY;\n"
+"fp_stateSingleItem_1\n"
+" stateSingleItem_1 .or stateSingleItem_2 .or stateSingleItem_3 .or stateSingleItem_4 .or\n"
+" stateSingleItem_5 .or stateSingleItem_7 .or stateSingleItem_8 .or stateSingleItem_11;\n"
+"vp_stateSingleItem_1\n"
+" stateSingleItem_1 .or stateSingleItem_2 .or stateSingleItem_3 .or stateSingleItem_4 .or\n"
+" stateSingleItem_6 .or stateSingleItem_7 .or stateSingleItem_9 .or stateSingleItem_10 .or\n"
+" stateSingleItem_11;\n"
+"stateSingleItem_1\n"
+" stateMaterialItem .emit STATE_MATERIAL;\n"
+"stateSingleItem_2\n"
+" stateLightItem .emit STATE_LIGHT;\n"
+"stateSingleItem_3\n"
+" stateLightModelItem .emit STATE_LIGHT_MODEL;\n"
+"stateSingleItem_4\n"
+" stateLightProdItem .emit STATE_LIGHT_PROD;\n"
+"stateSingleItem_5\n"
+" stateTexEnvItem .emit STATE_TEX_ENV;\n"
+"stateSingleItem_6\n"
+" stateTexGenItem .emit STATE_TEX_GEN;\n"
+"stateSingleItem_7\n"
+" stateFogItem .emit STATE_FOG;\n"
+"stateSingleItem_8\n"
+" stateDepthItem .emit STATE_DEPTH;\n"
+"stateSingleItem_9\n"
+" stateClipPlaneItem .emit STATE_CLIP_PLANE;\n"
+"stateSingleItem_10\n"
+" statePointItem .emit STATE_POINT;\n"
+"stateSingleItem_11\n"
+" stateMatrixRow .emit STATE_MATRIX_ROWS;\n"
+"stateMaterialItem\n"
+" \"material\" .and optFaceType .and dot .and stateMatProperty .error INVALID_MATERIAL_PROPERTY;\n"
+"stateMatProperty\n"
+" \"ambient\" .emit MATERIAL_AMBIENT .or\n"
+" \"diffuse\" .emit MATERIAL_DIFFUSE .or\n"
+" \"specular\" .emit MATERIAL_SPECULAR .or\n"
+" \"emission\" .emit MATERIAL_EMISSION .or\n"
+" \"shininess\" .emit MATERIAL_SHININESS;\n"
+"stateLightItem\n"
+" \"light\" .and lbracket .and stateLightNumber .and rbracket .and dot .and\n"
+" stateLightProperty .error INVALID_LIGHT_PROPERTY;\n"
+"stateLightProperty\n"
+" \"ambient\" .emit LIGHT_AMBIENT .or\n"
+" \"diffuse\" .emit LIGHT_DIFFUSE .or\n"
+" \"specular\" .emit LIGHT_SPECULAR .or\n"
+" \"position\" .emit LIGHT_POSITION .or\n"
+" \"attenuation\" .emit LIGHT_ATTENUATION .or\n"
+" stateLightProperty_1 .emit LIGHT_SPOT_DIRECTION .or\n"
+" \"half\" .emit LIGHT_HALF;\n"
+"stateLightProperty_1\n"
+" \"spot\" .and dot .and stateSpotProperty .error INVALID_SPOT_PROPERTY;\n"
+"stateSpotProperty\n"
+" \"direction\";\n"
+"stateLightModelItem\n"
+" \"lightmodel\" .and stateLModProperty .error INVALID_LIGHTMODEL_PROPERTY;\n"
+"stateLModProperty\n"
+" stateLModProperty_1 .or stateLModProperty_2;\n"
+"stateLModProperty_1\n"
+" dot .and \"ambient\" .emit LIGHT_MODEL_AMBIENT;\n"
+"stateLModProperty_2\n"
+" stateLModProperty_3 .emit LIGHT_MODEL_SCENECOLOR;\n"
+"stateLModProperty_3\n"
+" optFaceType .and dot .and \"scenecolor\";\n"
+"stateLightProdItem\n"
+" \"lightprod\" .and lbracket .and stateLightNumber .and rbracket .and optFaceType .and dot .and\n"
+" stateLProdProperty .error INVALID_LIGHTPROD_PROPERTY;\n"
+"stateLProdProperty\n"
+" \"ambient\" .emit LIGHT_PROD_AMBIENT .or\n"
+" \"diffuse\" .emit LIGHT_PROD_DIFFUSE .or\n"
+" \"specular\" .emit LIGHT_PROD_SPECULAR;\n"
+"stateLightNumber\n"
+" integer;\n"
+"stateTexEnvItem\n"
+" \"texenv\" .and optLegacyTexUnitNum .and dot .and\n"
+" stateTexEnvProperty .error INVALID_TEXENV_PROPERTY;\n"
+"stateTexEnvProperty\n"
+" \"color\" .emit TEX_ENV_COLOR;\n"
+"optLegacyTexUnitNum\n"
+" lbracket_ne .and legacyTexUnitNum .and rbracket;\n"
+"legacyTexUnitNum\n"
+" integer;\n"
+"stateTexGenItem\n"
+" \"texgen\" .and optTexCoordNum .and dot .and stateTexGenType .error INVALID_TEXGEN_PROPERTY .and\n"
+" dot .and stateTexGenCoord .error INVALID_TEXGEN_COORD;\n"
+"stateTexGenType\n"
+" \"eye\" .emit TEX_GEN_EYE .or\n"
+" \"object\" .emit TEX_GEN_OBJECT;\n"
+"stateTexGenCoord\n"
+" \"s\" .emit COMPONENT_X .or\n"
+" \"t\" .emit COMPONENT_Y .or\n"
+" \"r\" .emit COMPONENT_Z .or\n"
+" \"q\" .emit COMPONENT_W;\n"
+"stateFogItem\n"
+" \"fog\" .and dot .and stateFogProperty .error INVALID_FOG_PROPERTY;\n"
+"stateFogProperty\n"
+" \"color\" .emit FOG_COLOR .or\n"
+" \"params\" .emit FOG_PARAMS;\n"
+"stateDepthItem\n"
+" \"depth\" .and dot .and stateDepthProperty .error INVALID_DEPTH_PROPERTY;\n"
+"stateDepthProperty\n"
+" \"range\" .emit DEPTH_RANGE;\n"
+"stateClipPlaneItem\n"
+" \"clip\" .and lbracket .and stateClipPlaneNum .and rbracket .and dot .and\n"
+" \"plane\" .error INVALID_CLIPPLANE_PROPERTY;\n"
+"stateClipPlaneNum\n"
+" integer;\n"
+"statePointItem\n"
+" \"point\" .and dot .and statePointProperty .error INVALID_POINT_PROPERTY;\n"
+"statePointProperty\n"
+" \"size\" .emit POINT_SIZE .or\n"
+" .if (point_parameters != 0x00) \"attenuation\" .emit POINT_ATTENUATION;\n"
+"stateMatrixRow\n"
+" stateMatrixItem .and dot .and \"row\" .error MATRIX_ROW_SELECTOR_OR_MODIFIER_EXPECTED .and\n"
+" lbracket .and stateMatrixRowNum .and rbracket .emit 0x0;\n"
+"stateMatrixRows\n"
+" stateMatrixItem .and optMatrixRows;\n"
+"optMatrixRows\n"
+" optMatrixRows_1 .or .true .emit 0x0 .emit '3' .emit 0x0 .emit $;\n"
+"optMatrixRows_1\n"
+" dot_ne .and \"row\" .error MATRIX_ROW_SELECTOR_OR_MODIFIER_EXPECTED .and lbracket .and\n"
+" stateMatrixRowNum .and dotdot .and stateMatrixRowNum .and rbracket;\n"
+"stateMatrixItem\n"
+" \"matrix\" .and dot .and stateMatrixName .error INVALID_MATRIX_NAME .and stateOptMatModifier;\n"
+"stateOptMatModifier\n"
+" stateOptMatModifier_1 .or .true .emit MATRIX_MODIFIER_IDENTITY;\n"
+"stateOptMatModifier_1\n"
+" dot_ne .and stateMatModifier;\n"
+"stateMatModifier\n"
+" \"inverse\" .emit MATRIX_MODIFIER_INVERSE .or\n"
+" \"transpose\" .emit MATRIX_MODIFIER_TRANSPOSE .or\n"
+" \"invtrans\" .emit MATRIX_MODIFIER_INVTRANS;\n"
+"stateMatrixRowNum\n"
+" integer_0_3;\n"
+"stateMatrixName\n"
+" stateMatrixName_1_1 .emit MATRIX_MODELVIEW .or\n"
+" \"projection\" .emit MATRIX_PROJECTION .or\n"
+" \"mvp\" .emit MATRIX_MVP .or\n"
+" stateMatrixName_1_2 .emit MATRIX_TEXTURE .or\n"
+" .if (matrix_palette != 0x00) stateMatrixName_1_3 .emit MATRIX_PALETTE .or\n"
+" stateMatrixName_1_4 .emit MATRIX_PROGRAM;\n"
+"stateMatrixName_1_1\n"
+" \"modelview\" .and stateOptModMatNum;\n"
+"stateMatrixName_1_2\n"
+" \"texture\" .and optTexCoordNum;\n"
+"stateMatrixName_1_3\n"
+" \"palette\" .and lbracket .and statePaletteMatNum .and rbracket;\n"
+"stateMatrixName_1_4\n"
+" \"program\" .and lbracket .and stateProgramMatNum .and rbracket;\n"
+"stateOptModMatNum\n"
+" .if (vertex_blend != 0x00) stateOptModMatNum_1 .or\n"
+" .true .emit 0x00;\n"
+"stateOptModMatNum_1\n"
+" lbracket_ne .and stateModMatNum .and rbracket;\n"
+"stateModMatNum\n"
+" integer;\n"
+"optTexCoordNum\n"
+" optTexCoordNum_1 .or .true .emit 0x00;\n"
+"optTexCoordNum_1\n"
+" lbracket_ne .and texCoordNum .and rbracket;\n"
+"texCoordNum\n"
+" integer;\n"
+"statePaletteMatNum\n"
+" integer;\n"
+"stateProgramMatNum\n"
+" integer;\n"
+"programSingleItem\n"
+" \"program\" .and dot .and programSingleItem_1 .error INVALID_PROGRAM_PROPERTY;\n"
+"programSingleItem_1\n"
+" progEnvParam .or progLocalParam;\n"
+"programMultipleItem\n"
+" \"program\" .and dot .and programMultipleItem_1 .error INVALID_PROGRAM_PROPERTY;\n"
+"programMultipleItem_1\n"
+" progEnvParams .or progLocalParams;\n"
+"progEnvParams\n"
+" \"env\" .emit PROGRAM_PARAM_ENV .and lbracket .and progEnvParamNums .and rbracket;\n"
+"progEnvParamNums\n"
+" progEnvParamNums_1 .or progEnvParamNums_2;\n"
+"progEnvParamNums_1\n"
+" progEnvParamNum .and dotdot_ne .and progEnvParamNum;\n"
+"progEnvParamNums_2\n"
+" progEnvParamNum .and .true .emit 0x00;\n"
+"progEnvParam\n"
+" \"env\" .emit PROGRAM_PARAM_ENV .and lbracket .and progEnvParamNum .and rbracket .emit 0x00;\n"
+"progLocalParams\n"
+" \"local\" .emit PROGRAM_PARAM_LOCAL .and lbracket .and progLocalParamNums .and rbracket;\n"
+"progLocalParamNums\n"
+" progLocalParamNums_1 .or progLocalParamNums_2;\n"
+"progLocalParamNums_1\n"
+" progLocalParamNum .and dotdot_ne .and progLocalParamNum;\n"
+"progLocalParamNums_2\n"
+" progLocalParamNum .and .true .emit 0x00;\n"
+"progLocalParam\n"
+" \"local\" .emit PROGRAM_PARAM_LOCAL .and lbracket .and progLocalParamNum .and rbracket .emit 0x00;\n"
+"progEnvParamNum\n"
+" integer;\n"
+"progLocalParamNum\n"
+" integer;\n"
+"paramConstDecl\n"
+" paramConstScalarDecl .emit CONSTANT_SCALAR .or paramConstVector .emit CONSTANT_VECTOR;\n"
+"paramConstUse\n"
+" paramConstScalarUse .emit CONSTANT_SCALAR .or paramConstVector .emit CONSTANT_VECTOR;\n"
+"paramConstScalarDecl\n"
+" signedFloatConstant;\n"
+"paramConstScalarUse\n"
+" floatConstant;\n"
+"paramConstVector\n"
+" paramConstVector_4 .emit 0x04 .or paramConstVector_3 .emit 0x03 .or\n"
+" paramConstVector_2 .emit 0x02 .or paramConstVector_1 .emit 0x01;\n"
+"paramConstVector_1\n"
+" lbrace_ne .and signedFloatConstant .and rbrace;\n"
+"paramConstVector_2\n"
+" lbrace_ne .and signedFloatConstant .and comma_ne .and signedFloatConstant .and rbrace;\n"
+"paramConstVector_3\n"
+" lbrace_ne .and signedFloatConstant .and comma_ne .and signedFloatConstant .and comma_ne .and\n"
+" signedFloatConstant .and rbrace;\n"
+"paramConstVector_4\n"
+" lbrace_ne .and signedFloatConstant .and comma_ne .and signedFloatConstant .and comma_ne .and\n"
+" signedFloatConstant .and comma_ne .and signedFloatConstant .and rbrace;\n"
+"signedFloatConstant\n"
+" optionalSign .and floatConstant;\n"
+"floatConstant\n"
+" float;\n"
+"optionalSign\n"
+" optional_sign_ne;\n"
+"fp_TEMP_statement\n"
+" \"TEMP\" .and space .and fp_varNameList .and .true .emit 0x00;\n"
+"vp_TEMP_statement\n"
+" \"TEMP\" .and space .and vp_varNameList .and .true .emit 0x00;\n"
+"ADDRESS_statement\n"
+" \"ADDRESS\" .and space .and vp_varNameList .and .true .emit 0x00;\n"
+"fp_varNameList\n"
+" fp_varNameList_1 .or fp_establishName;\n"
+"vp_varNameList\n"
+" vp_varNameList_1 .or vp_establishName;\n"
+"fp_varNameList_1\n"
+" fp_establishName .and comma_ne .and fp_varNameList;\n"
+"vp_varNameList_1\n"
+" vp_establishName .and comma_ne .and vp_varNameList;\n"
+"fp_OUTPUT_statement\n"
+" \"OUTPUT\" .and space .and fp_establishName .and equal .and\n"
+" fp_resultBinding .error RESULT_EXPECTED;\n"
+"vp_OUTPUT_statement\n"
+" \"OUTPUT\" .and space .and vp_establishName .and equal .and\n"
+" vp_resultBinding .error RESULT_EXPECTED;\n"
+"fp_resultBinding\n"
+" \"result\" .and dot .and fp_resultBinding_1 .error INVALID_RESULT_PROPERTY;\n"
+"vp_resultBinding\n"
+" \"result\" .and dot .and vp_resultBinding_1 .error INVALID_RESULT_PROPERTY;\n"
+"fp_resultBinding_1\n"
+" fp_resultBinding_2 .emit FRAGMENT_RESULT_COLOR .or\n"
+" \"depth\" .emit FRAGMENT_RESULT_DEPTH;\n"
+"fp_resultBinding_2\n"
+" \"color\" .and optOutputColorNum;\n"
+"vp_resultBinding_1\n"
+" .if (ARB_position_invariant == 0x00) \"position\" .emit VERTEX_RESULT_POSITION .or\n"
+" resultColBinding .emit VERTEX_RESULT_COLOR .or\n"
+" \"fogcoord\" .emit VERTEX_RESULT_FOGCOORD .or\n"
+" \"pointsize\" .emit VERTEX_RESULT_POINTSIZE .or\n"
+" vp_resultBinding_2 .emit VERTEX_RESULT_TEXCOORD;\n"
+"vp_resultBinding_2\n"
+" \"texcoord\" .and optTexCoordNum;\n"
+"optOutputColorNum\n"
+" .if (ARB_draw_buffers != 0x00) optOutputColorNum_1 .or .true .emit 0x00;\n"
+"optOutputColorNum_1\n"
+" lbracket_ne .and outputColorNum .and rbracket;\n"
+"outputColorNum\n"
+" integer;\n"
+"resultColBinding\n"
+" \"color\" .and optFaceType .and optColorType;\n"
+"optFaceType\n"
+" FaceType .or .true .emit FACE_FRONT;\n"
+"FaceType\n"
+" dot_ne .and FaceProperty;\n"
+"FaceProperty\n"
+" \"front\" .emit FACE_FRONT .or \"back\" .emit FACE_BACK;\n"
+"optColorType\n"
+" ColorType .or .true .emit COLOR_PRIMARY;\n"
+"ColorType\n"
+" dot_ne .and ColorProperty;\n"
+"ColorProperty\n"
+" \"primary\" .emit COLOR_PRIMARY .or\n"
+" .if (secondary_color != 0x00) \"secondary\" .emit COLOR_SECONDARY;\n"
+"fp_ALIAS_statement\n"
+" \"ALIAS\" .and fp_ALIAS_statement_1 .error IDENTIFIER_EXPECTED .and equal .and fp_establishedName;\n"
+"vp_ALIAS_statement\n"
+" \"ALIAS\" .and vp_ALIAS_statement_1 .error IDENTIFIER_EXPECTED .and equal .and vp_establishedName;\n"
+"fp_ALIAS_statement_1\n"
+" space .and fp_establishName;\n"
+"vp_ALIAS_statement_1\n"
+" space .and vp_establishName;\n"
+"fp_establishName\n"
+" fp_identifier;\n"
+"vp_establishName\n"
+" vp_identifier;\n"
+"fp_establishedName\n"
+" fp_identifier;\n"
+"vp_establishedName\n"
+" vp_identifier;\n"
+"fp_establishedName_no_error_on_identifier\n"
+" fp_identifier_ne;\n"
+"vp_establishedName_no_error_on_identifier\n"
+" vp_identifier_ne;\n"
+"fp_identifier\n"
+" fp_identifier_ne .error IDENTIFIER_EXPECTED;\n"
+"vp_identifier\n"
+" vp_identifier_ne .error IDENTIFIER_EXPECTED;\n"
+"fp_identifier_ne\n"
+" fp_not_reserved_identifier .and identifier_ne;\n"
+"vp_identifier_ne\n"
+" vp_not_reserved_identifier .and identifier_ne;\n"
+"fp_not_reserved_identifier\n"
+" fp_not_reserved_identifier_1 .or .true;\n"
+"fp_not_reserved_identifier_1\n"
+" fp_reserved_identifier .and .false .error RESERVED_KEYWORD;\n"
+"vp_not_reserved_identifier\n"
+" vp_not_reserved_identifier_1 .or .true;\n"
+"vp_not_reserved_identifier_1\n"
+" vp_reserved_identifier .and .false .error RESERVED_KEYWORD;\n"
+"fp_reserved_identifier\n"
+" \"ABS\" .or \"ABS_SAT\" .or \"ADD\" .or \"ADD_SAT\" .or \"ALIAS\" .or \"ATTRIB\" .or \"CMP\" .or \"CMP_SAT\" .or\n"
+" \"COS\" .or \"COS_SAT\" .or \"DP3\" .or \"DP3_SAT\" .or \"DP4\" .or \"DP4_SAT\" .or \"DPH\" .or \"DPH_SAT\" .or\n"
+" \"DST\" .or \"DST_SAT\" .or \"END\" .or \"EX2\" .or \"EX2_SAT\" .or \"FLR\" .or \"FLR_SAT\" .or \"FRC\" .or\n"
+" \"FRC_SAT\" .or \"KIL\" .or \"LG2\" .or \"LG2_SAT\" .or \"LIT\" .or \"LIT_SAT\" .or \"LRP\" .or \"LRP_SAT\" .or\n"
+" \"MAD\" .or \"MAD_SAT\" .or \"MAX\" .or \"MAX_SAT\" .or \"MIN\" .or \"MIN_SAT\" .or \"MOV\" .or \"MOV_SAT\" .or\n"
+" \"MUL\" .or \"MUL_SAT\" .or \"OPTION\" .or \"OUTPUT\" .or \"PARAM\" .or \"POW\" .or \"POW_SAT\" .or \"RCP\" .or\n"
+" \"RCP_SAT\" .or \"RSQ\" .or \"RSQ_SAT\" .or \"SIN\" .or \"SIN_SAT\" .or \"SCS\" .or \"SCS_SAT\" .or \"SGE\" .or\n"
+" \"SGE_SAT\" .or \"SLT\" .or \"SLT_SAT\" .or \"SUB\" .or \"SUB_SAT\" .or \"SWZ\" .or \"SWZ_SAT\" .or \"TEMP\" .or\n"
+" \"TEX\" .or \"TEX_SAT\" .or \"TXB\" .or \"TXB_SAT\" .or \"TXP\" .or \"TXP_SAT\" .or \"XPD\" .or \"XPD_SAT\" .or\n"
+" \"fragment\" .or \"program\" .or \"result\" .or \"state\" .or \"texture\";\n"
+"vp_reserved_identifier\n"
+" \"ABS\" .or \"ADD\" .or \"ADDRESS\" .or \"ALIAS\" .or \"ARL\" .or \"ATTRIB\" .or \"DP3\" .or \"DP4\" .or\n"
+" \"DPH\" .or \"DST\" .or \"END\" .or \"EX2\" .or \"EXP\" .or \"FLR\" .or \"FRC\" .or \"LG2\" .or \"LIT\" .or\n"
+" \"LOG\" .or \"MAD\" .or \"MAX\" .or \"MIN\" .or \"MOV\" .or \"MUL\" .or \"OPTION\" .or \"OUTPUT\" .or\n"
+" \"PARAM\" .or \"POW\" .or \"RCP\" .or \"RSQ\" .or \"SGE\" .or \"SLT\" .or \"SUB\" .or \"SWZ\" .or \"TEMP\" .or\n"
+" \"XPD\" .or \"program\" .or \"result\" .or \"state\" .or \"vertex\";\n"
+"integer\n"
+" integer_ne .error INTEGER_EXPECTED;\n"
+"zero\n"
+" '0';\n"
+"leading_zeroes\n"
+" .loop zero;\n"
+"no_digit\n"
+" no_digit_1 .or .true;\n"
+"no_digit_1\n"
+" digit10 .and .false .error INTEGER_OUT_OF_RANGE;\n"
+"all_zeroes\n"
+" all_zeroes_1 .or no_digit_1;\n"
+"all_zeroes_1\n"
+" '0' .and .loop zero .and no_digit;\n"
+"integer_0_3\n"
+" integer_0_3_1 .error INTEGER_EXPECTED .and .true .emit 0x00 .emit $;\n"
+"integer_0_3_1\n"
+" integer_0_3_2 .or all_zeroes .emit '0';\n"
+"integer_0_3_2 \n"
+" leading_zeroes .and '1'-'3' .emit * .and no_digit;\n"
+"integer_0_63\n"
+" integer_0_63_1 .error INTEGER_EXPECTED .and .true .emit 0x00 .emit $;\n"
+"integer_0_63_1\n"
+" integer_0_63_2 .or integer_0_63_3 .or integer_0_63_4 .or integer_0_63_5 .or\n"
+" all_zeroes .emit '0';\n"
+"integer_0_63_2 \n"
+" leading_zeroes .and '7'-'9' .emit * .and no_digit;\n"
+"integer_0_63_3 \n"
+" leading_zeroes .and '1'-'5' .emit * .and '0'-'9' .emit * .and no_digit;\n"
+"integer_0_63_4 \n"
+" leading_zeroes .and '6' .emit * .and '0'-'3' .emit * .and no_digit;\n"
+"integer_0_63_5 \n"
+" leading_zeroes .and '1'-'6' .emit * .and no_digit;\n"
+"integer_0_64\n"
+" integer_0_64_1 .error INTEGER_EXPECTED .and .true .emit 0x00 .emit $;\n"
+"integer_0_64_1\n"
+" integer_0_64_2 .or integer_0_64_3 .or integer_0_64_4 .or integer_0_64_5 .or\n"
+" all_zeroes .emit '0';\n"
+"integer_0_64_2 \n"
+" leading_zeroes .and '7'-'9' .emit * .and no_digit;\n"
+"integer_0_64_3 \n"
+" leading_zeroes .and '1'-'5' .emit * .and '0'-'9' .emit * .and no_digit;\n"
+"integer_0_64_4 \n"
+" leading_zeroes .and '6' .emit * .and '0'-'4' .emit * .and no_digit;\n"
+"integer_0_64_5 \n"
+" leading_zeroes .and '1'-'6' .emit * .and no_digit;\n"
+"optional_space\n"
+" space .or .true;\n"
+"space_dst\n"
+" space .error OPERATION_NEEDS_DESTINATION_VARIABLE;\n"
+"space_src\n"
+" space .error OPERATION_NEEDS_SOURCE_VARIABLE;\n"
+"space\n"
+" single_space .and .loop single_space;\n"
+"single_space\n"
+" white_char .or comment_block;\n"
+"white_char\n"
+" ' ' .or '\\t' .or '\\n' .or '\\r';\n"
+"comment_block\n"
+" '#' .and .loop comment_char .and new_line;\n"
+"comment_char\n"
+" '\\x0E'-'\\xFF' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
+"new_line\n"
+" '\\n' .or crlf .or '\\0';\n"
+"crlf\n"
+" '\\r' .and '\\n';\n"
+"semicolon\n"
+" optional_space .and ';' .error MISSING_SEMICOLON .and optional_space;\n"
+"comma\n"
+" optional_space .and ',' .error MISSING_COMMA .and optional_space;\n"
+"comma_ne\n"
+" optional_space .and ',' .and optional_space;\n"
+"lbracket\n"
+" optional_space .and '[' .error MISSING_LBRACKET .and optional_space;\n"
+"lbracket_ne\n"
+" optional_space .and '[' .and optional_space;\n"
+"rbracket\n"
+" optional_space .and ']' .error MISSING_RBRACKET .and optional_space;\n"
+"dot\n"
+" optional_space .and '.' .error MISSING_DOT .and optional_space;\n"
+"dot_ne\n"
+" optional_space .and '.' .and optional_space;\n"
+"equal\n"
+" optional_space .and '=' .error MISSING_EQUAL .and optional_space;\n"
+"lbrace\n"
+" optional_space .and '{' .error MISSING_LBRACE .and optional_space;\n"
+"lbrace_ne\n"
+" optional_space .and '{' .and optional_space;\n"
+"rbrace\n"
+" optional_space .and '}' .error MISSING_RBRACE .and optional_space;\n"
+"dotdot\n"
+" optional_space .and '.' .and '.' .error MISSING_DOTDOT .and optional_space;\n"
+"dotdot_ne\n"
+" optional_space .and '.' .and '.' .and optional_space;\n"
+"float\n"
+" float_1 .or float_2 .or float_legacy;\n"
+"float_1\n"
+" '.' .emit 0x00 .and integer_ne .error MISSING_FRACTION_OR_EXPONENT .and optional_exponent;\n"
+"float_2\n"
+" integer_ne .and float_3;\n"
+"float_3\n"
+" float_4 .or float_5;\n"
+"float_4\n"
+" '.' .and optional_integer .and optional_exponent;\n"
+"float_5\n"
+" exponent .emit 0x00;\n"
+"float_legacy\n"
+" integer_ne .and .true .emit 0x00 .emit 0x00;\n"
+"integer_ne\n"
+" integer_ne_1 .and .true .emit 0x00 .emit $;\n"
+"integer_ne_1\n"
+" digit10 .emit * .and .loop digit10 .emit *;\n"
+"optional_integer\n"
+" integer_ne .or .true .emit 0x00;\n"
+"optional_exponent\n"
+" exponent .or .true .emit 0x00;\n"
+"exponent\n"
+" exponent_1 .and optional_sign_ne .and integer_ne .error EXPONENT_VALUE_EXPECTED;\n"
+"exponent_1\n"
+" 'e' .or 'E';\n"
+"optional_sign_ne\n"
+" minus_ne .or plus_ne .or .true;\n"
+"plus_ne\n"
+" optional_space .and '+' .and optional_space;\n"
+"minus_ne\n"
+" optional_space .and '-' .emit '-' .and optional_space;\n"
+"identifier_ne\n"
+" first_idchar .emit * .and .loop follow_idchar .emit * .and .true .emit 0x00 .emit $;\n"
+"follow_idchar\n"
+" first_idchar .or digit10;\n"
+"first_idchar\n"
+" 'a'-'z' .or 'A'-'Z' .or '_' .or '$';\n"
+"digit10\n"
+" '0'-'9';\n"
+".string __string_filter;\n"
+"__string_filter\n"
+" .loop __identifier_char;\n"
+"__identifier_char\n"
+" 'a'-'z' .or 'A'-'Z' .or '_' .or '$' .or '0'-'9';\n"
+"e_signature\n"
+" e_signature_char .and .loop e_signature_char;\n"
+"e_signature_char\n"
+" '!' .or '.' .or 'A'-'Z' .or 'a'-'z' .or '0'-'9';\n"
+"e_statement\n"
+" .loop e_statement_not_term;\n"
+"e_statement_not_term\n"
+" '\\x3C'-'\\xFF' .or '\\x0E'-'\\x3A' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
+"e_identifier\n"
+" e_identifier_first .and .loop e_identifier_next;\n"
+"e_identifier_first\n"
+" 'a'-'z' .or 'A'-'Z' .or '_' .or '$';\n"
+"e_identifier_next\n"
+" e_identifier_first .or '0'-'9';\n"
+"e_token\n"
+" e_identifier .or e_token_number .or '[' .or ']' .or '.' .or '{' .or '}' .or '=' .or '+' .or\n"
+" '-' .or ',' .or ';';\n"
+"e_token_number\n"
+" e_token_digit .and .loop e_token_digit;\n"
+"e_token_digit\n"
+" '0'-'9';\n"
+"e_charordigit\n"
+" 'A'-'Z' .or 'a'-'z' .or '0'-'9';\n"
+""
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/arbvertparse.c b/nx-X11/extras/Mesa/src/mesa/shader/arbvertparse.c
new file mode 100644
index 000000000..5d1ad3de2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/arbvertparse.c
@@ -0,0 +1,207 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.2
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+#define DEBUG_VP 0
+
+/**
+ * \file arbvertparse.c
+ * ARB_vertex_program parser.
+ * \author Karl Rasche
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "arbvertparse.h"
+#include "hash.h"
+#include "imports.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "program.h"
+#include "nvprogram.h"
+#include "nvvertparse.h"
+#include "nvvertprog.h"
+
+#include "arbprogparse.h"
+
+
+/**
+ * XXX this is probably redundant. We've already got code like this
+ * in the nvvertparse.c file. Combine/clean-up someday.
+ */
+void _mesa_debug_vp_inst(GLint num, struct vp_instruction *vp)
+{
+ GLint a;
+ static const char *opcode_string[] = {
+ "ABS",
+ "ADD",
+ "ARL",
+ "DP3",
+ "DP4",
+ "DPH",
+ "DST",
+ "END", /* Placeholder */
+ "EX2", /* ARB only */
+ "EXP",
+ "FLR", /* ARB */
+ "FRC", /* ARB */
+ "LG2", /* ARB only */
+ "LIT",
+ "LOG",
+ "MAD",
+ "MAX",
+ "MIN",
+ "MOV",
+ "MUL",
+ "POW", /* ARB only */
+ "PRINT", /* Mesa only */
+ "RCC",
+ "RCP",
+ "RSQ",
+ "SGE",
+ "SLT",
+ "SUB",
+ "SWZ", /* ARB only */
+ "XPD" /* ARB only */
+ };
+
+ static const char *file_string[] = {
+ "TEMP",
+ "INPUT",
+ "OUTPUT",
+ "LOCAL",
+ "ENV",
+ "NAMED",
+ "STATE",
+ "WRITE_ONLY",
+ "ADDR"
+ };
+
+ static const char swz[] = "xyzw01??";
+
+ for (a=0; a<num; a++) {
+ _mesa_printf("%s", opcode_string[vp[a].Opcode]);
+
+ if (vp[a].DstReg.File != 0xf) {
+ if (vp[a].DstReg.WriteMask != 0xf)
+ _mesa_printf(" %s[%d].%s%s%s%s ", file_string[vp[a].DstReg.File], vp[a].DstReg.Index,
+ GET_BIT(vp[a].DstReg.WriteMask, 0) ? "x" : "",
+ GET_BIT(vp[a].DstReg.WriteMask, 1) ? "y" : "",
+ GET_BIT(vp[a].DstReg.WriteMask, 2) ? "z" : "",
+ GET_BIT(vp[a].DstReg.WriteMask, 3) ? "w" : "");
+ else
+ _mesa_printf(" %s[%d] ", file_string[vp[a].DstReg.File], vp[a].DstReg.Index);
+ }
+
+ if (vp[a].SrcReg[0].File != 0xf) {
+ if (vp[a].SrcReg[0].Swizzle != SWIZZLE_NOOP ||
+ vp[a].SrcReg[0].Negate)
+ _mesa_printf("%s[%d].%s%c%c%c%c ", file_string[vp[a].SrcReg[0].File], vp[a].SrcReg[0].Index,
+ vp[a].SrcReg[0].Negate ? "-" : "",
+ swz[GET_SWZ(vp[a].SrcReg[0].Swizzle, 0)],
+ swz[GET_SWZ(vp[a].SrcReg[0].Swizzle, 1)],
+ swz[GET_SWZ(vp[a].SrcReg[0].Swizzle, 2)],
+ swz[GET_SWZ(vp[a].SrcReg[0].Swizzle, 3)]);
+ else
+ _mesa_printf("%s[%d] ", file_string[vp[a].SrcReg[0].File], vp[a].SrcReg[0].Index);
+ }
+
+ if (vp[a].SrcReg[1].File != 0xf) {
+ if (vp[a].SrcReg[1].Swizzle != SWIZZLE_NOOP ||
+ vp[a].SrcReg[1].Negate)
+ _mesa_printf("%s[%d].%s%c%c%c%c ", file_string[vp[a].SrcReg[1].File], vp[a].SrcReg[1].Index,
+ vp[a].SrcReg[1].Negate ? "-" : "",
+ swz[GET_SWZ(vp[a].SrcReg[1].Swizzle, 0)],
+ swz[GET_SWZ(vp[a].SrcReg[1].Swizzle, 1)],
+ swz[GET_SWZ(vp[a].SrcReg[1].Swizzle, 2)],
+ swz[GET_SWZ(vp[a].SrcReg[1].Swizzle, 3)]);
+ else
+ _mesa_printf("%s[%d] ", file_string[vp[a].SrcReg[1].File], vp[a].SrcReg[1].Index);
+ }
+
+ if (vp[a].SrcReg[2].File != 0xf) {
+ if (vp[a].SrcReg[2].Swizzle != SWIZZLE_NOOP ||
+ vp[a].SrcReg[2].Negate)
+ _mesa_printf("%s[%d].%s%c%c%c%c ", file_string[vp[a].SrcReg[2].File], vp[a].SrcReg[2].Index,
+ vp[a].SrcReg[2].Negate ? "-" : "",
+ swz[GET_SWZ(vp[a].SrcReg[2].Swizzle, 0)],
+ swz[GET_SWZ(vp[a].SrcReg[2].Swizzle, 1)],
+ swz[GET_SWZ(vp[a].SrcReg[2].Swizzle, 2)],
+ swz[GET_SWZ(vp[a].SrcReg[2].Swizzle, 3)]);
+ else
+ _mesa_printf("%s[%d] ", file_string[vp[a].SrcReg[2].File], vp[a].SrcReg[2].Index);
+ }
+
+ _mesa_printf("\n");
+ }
+}
+
+
+/**
+ * Parse the vertex program string. If success, update the given
+ * vertex_program object with the new program. Else, leave the vertex_program
+ * object unchanged.
+ */
+void
+_mesa_parse_arb_vertex_program(GLcontext * ctx, GLenum target,
+ const GLubyte * str, GLsizei len,
+ struct vertex_program *program)
+{
+ struct arb_program ap;
+ (void) target;
+
+ /* set the program target before parsing */
+ ap.Base.Target = GL_VERTEX_PROGRAM_ARB;
+
+ if (!_mesa_parse_arb_program(ctx, str, len, &ap)) {
+ /* Error in the program. Just return. */
+ return;
+ }
+
+ /* Copy the relevant contents of the arb_program struct into the
+ * vertex_program struct.
+ */
+ program->Base.String = ap.Base.String;
+ program->Base.NumInstructions = ap.Base.NumInstructions;
+ program->Base.NumTemporaries = ap.Base.NumTemporaries;
+ program->Base.NumParameters = ap.Base.NumParameters;
+ program->Base.NumAttributes = ap.Base.NumAttributes;
+ program->Base.NumAddressRegs = ap.Base.NumAddressRegs;
+
+ program->IsPositionInvariant = ap.HintPositionInvariant;
+ program->InputsRead = ap.InputsRead;
+ program->OutputsWritten = ap.OutputsWritten;
+
+ if (program->Parameters) {
+ /* free previous program's parameters */
+ _mesa_free_parameter_list(program->Parameters);
+ }
+ program->Parameters = ap.Parameters;
+
+ program->Instructions = ap.VPInstructions;
+
+#if DEBUG_VP
+ _mesa_debug_vp_inst(ap.Base.NumInstructions, ap.VPInstructions);
+#endif
+
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/arbvertparse.h b/nx-X11/extras/Mesa/src/mesa/shader/arbvertparse.h
new file mode 100644
index 000000000..f2ac1570b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/arbvertparse.h
@@ -0,0 +1,36 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef ARBVERTPARSE_H
+#define ARBVERTPARSE_H
+
+extern void
+_mesa_parse_arb_vertex_program(GLcontext * ctx, GLenum target,
+ const GLubyte * str, GLsizei len,
+ struct vertex_program *program);
+
+extern void
+_mesa_debug_vp_inst(GLint num, struct vp_instruction *vp);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/asmopcodes.reg b/nx-X11/extras/Mesa/src/mesa/shader/asmopcodes.reg
new file mode 100644
index 000000000..efd8918f2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/asmopcodes.reg
@@ -0,0 +1,78 @@
+/* */
+/* ARB program opcode registry */
+/* each instruction code has its own unique number */
+/* this registry exists to ensure that this relation retains */
+/* */
+
+/* GL_ARB_vertex_program */
+ABS 0x00
+ADD 0x01
+ARL 0x02
+DP3 0x03
+DP4 0x04
+DPH 0x05
+DST 0x06
+EX2 0x07
+EXP 0x08
+FLR 0x09
+FRC 0x0A
+LG2 0x0B
+LIT 0x0C
+LOG 0x0D
+MAD 0x0E
+MAX 0x0F
+MIN 0x10
+MOV 0x11
+MUL 0x12
+POW 0x13
+RCP 0x14
+RSQ 0x15
+SGE 0x16
+SLT 0x17
+SUB 0x18
+SWZ 0x19
+XPD 0x1A
+
+/* GL_ARB_fragment_program */
+ABS_SAT 0x1B
+ADD_SAT 0x1C
+CMP 0x1D
+CMP_SAT 0x1E
+COS 0x1F
+COS_SAT 0x20
+DP3_SAT 0x21
+DP4_SAT 0x22
+DPH_SAT 0x23
+DST_SAT 0x24
+EX2_SAT 0x25
+FLR_SAT 0x26
+FRC_SAT 0x27
+KIL 0x28
+LG2_SAT 0x29
+LIT_SAT 0x2A
+LRP 0x2B
+LRP_SAT 0x2C
+MAD_SAT 0x2D
+MAX_SAT 0x2E
+MIN_SAT 0x2F
+MOV_SAT 0x30
+MUL_SAT 0x31
+POW_SAT 0x32
+RCP_SAT 0x33
+RSQ_SAT 0x34
+SCS 0x35
+SCS_SAT 0x36
+SGE_SAT 0x37
+SIN 0x38
+SIN_SAT 0x39
+SLT_SAT 0x3A
+SUB_SAT 0x3B
+SWZ_SAT 0x3C
+TEX 0x3D
+TEX_SAT 0x3E
+TXB 0x3F
+TXB_SAT 0x40
+TXP 0x41
+TXP_SAT 0x42
+XPD_SAT 0x43
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/atifragshader.c b/nx-X11/extras/Mesa/src/mesa/shader/atifragshader.c
new file mode 100644
index 000000000..d8df8f518
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/atifragshader.c
@@ -0,0 +1,439 @@
+/**
+ * \file atifragshader.c
+ * \author David Airlie
+ * Copyright (C) 2004 David Airlie 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
+ * DAVID AIRLIE 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.
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "hash.h"
+#include "imports.h"
+#include "macros.h"
+#include "enums.h"
+#include "mtypes.h"
+#include "atifragshader.h"
+
+#define MESA_DEBUG_ATI_FS 0
+
+extern struct program _mesa_DummyProgram;
+
+static void
+new_inst(struct ati_fragment_shader *prog)
+{
+ prog->Base.NumInstructions++;
+}
+
+#if MESA_DEBUG_ATI_FS
+static char *
+create_dst_mod_str(GLuint mod)
+{
+ static char ret_str[1024];
+
+ _mesa_memset(ret_str, 0, 1024);
+ if (mod & GL_2X_BIT_ATI)
+ _mesa_strncat(ret_str, "|2X", 1024);
+
+ if (mod & GL_4X_BIT_ATI)
+ _mesa_strncat(ret_str, "|4X", 1024);
+
+ if (mod & GL_8X_BIT_ATI)
+ _mesa_strncat(ret_str, "|8X", 1024);
+ if (mod & GL_HALF_BIT_ATI)
+ _mesa_strncat(ret_str, "|HA", 1024);
+ if (mod & GL_QUARTER_BIT_ATI)
+ _mesa_strncat(ret_str, "|QU", 1024);
+ if (mod & GL_EIGHTH_BIT_ATI)
+ _mesa_strncat(ret_str, "|EI", 1024);
+
+ if (mod & GL_SATURATE_BIT_ATI)
+ _mesa_strncat(ret_str, "|SAT", 1024);
+
+ if (_mesa_strlen(ret_str) == 0)
+ _mesa_strncat(ret_str, "NONE", 1024);
+ return ret_str;
+}
+
+static char *atifs_ops[] = {"ColorFragmentOp1ATI", "ColorFragmentOp2ATI", "ColorFragmentOp3ATI",
+ "AlphaFragmentOp1ATI", "AlphaFragmentOp2ATI", "AlphaFragmentOp3ATI" };
+
+static void debug_op(GLint optype, GLuint arg_count, GLenum op, GLuint dst,
+ GLuint dstMask, GLuint dstMod, GLuint arg1,
+ GLuint arg1Rep, GLuint arg1Mod, GLuint arg2,
+ GLuint arg2Rep, GLuint arg2Mod, GLuint arg3,
+ GLuint arg3Rep, GLuint arg3Mod)
+{
+ char *op_name;
+
+ op_name = atifs_ops[(arg_count-1)+(optype?3:0)];
+
+ fprintf(stderr, "%s(%s, %s", op_name, _mesa_lookup_enum_by_nr(op),
+ _mesa_lookup_enum_by_nr(dst));
+ if (!optype)
+ fprintf(stderr, ", %d", dstMask);
+
+ fprintf(stderr, ", %s", create_dst_mod_str(dstMod));
+
+ fprintf(stderr, ", %s, %s, %d", _mesa_lookup_enum_by_nr(arg1),
+ _mesa_lookup_enum_by_nr(arg1Rep), arg1Mod);
+ if (arg_count>1)
+ fprintf(stderr, ", %s, %s, %d", _mesa_lookup_enum_by_nr(arg2),
+ _mesa_lookup_enum_by_nr(arg2Rep), arg2Mod);
+ if (arg_count>2)
+ fprintf(stderr, ", %s, %s, %d", _mesa_lookup_enum_by_nr(arg3),
+ _mesa_lookup_enum_by_nr(arg3Rep), arg3Mod);
+
+ fprintf(stderr,")\n");
+
+}
+#endif
+
+GLuint GLAPIENTRY
+_mesa_GenFragmentShadersATI(GLuint range)
+{
+ GLuint first;
+ GLuint i;
+ GET_CURRENT_CONTEXT(ctx);
+
+ first = _mesa_HashFindFreeKeyBlock(ctx->Shared->Programs, range);
+ for (i = 0; i < range; i++) {
+ _mesa_HashInsert(ctx->Shared->Programs, first + i, &_mesa_DummyProgram);
+ }
+
+ return first;
+}
+
+void GLAPIENTRY
+_mesa_BindFragmentShaderATI(GLuint id)
+{
+ struct program *prog;
+ GET_CURRENT_CONTEXT(ctx);
+ struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current;
+
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+
+ if (curProg->Base.Id == id) {
+ return;
+ }
+
+ if (curProg->Base.Id != 0) {
+ curProg->Base.RefCount--;
+ if (curProg->Base.RefCount <= 0) {
+ _mesa_HashRemove(ctx->Shared->Programs, id);
+ }
+ }
+
+ /* Go bind */
+ if (id == 0) {
+ prog = ctx->Shared->DefaultFragmentShader;
+ }
+ else {
+ prog = (struct program *) _mesa_HashLookup(ctx->Shared->Programs, id);
+ if (!prog || prog == &_mesa_DummyProgram) {
+ /* allocate a new program now */
+ prog = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_SHADER_ATI, id);
+ if (!prog) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindFragmentShaderATI");
+ return;
+ }
+ _mesa_HashInsert(ctx->Shared->Programs, id, prog);
+ }
+
+ }
+
+ /* do actual bind */
+ ctx->ATIFragmentShader.Current = (struct ati_fragment_shader *) prog;
+
+ ASSERT(ctx->ATIFragmentShader.Current);
+ if (prog)
+ prog->RefCount++;
+
+ /*if (ctx->Driver.BindProgram)
+ ctx->Driver.BindProgram(ctx, target, prog); */
+}
+
+void GLAPIENTRY
+_mesa_DeleteFragmentShaderATI(GLuint id)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (id != 0) {
+ struct program *prog = (struct program *)
+ _mesa_HashLookup(ctx->Shared->Programs, id);
+ if (prog == &_mesa_DummyProgram) {
+ _mesa_HashRemove(ctx->Shared->Programs, id);
+ }
+ else if (prog) {
+ if (ctx->ATIFragmentShader.Current &&
+ ctx->ATIFragmentShader.Current->Base.Id == id) {
+ _mesa_BindFragmentShaderATI(0);
+ }
+ }
+#if 0
+ if (!prog->DeletePending) {
+ prog->DeletePending = GL_TRUE;
+ prog->RefCount--;
+ }
+ if (prog->RefCount <= 0) {
+ _mesa_HashRemove(ctx->Shared->Programs, id);
+ ctx->Driver.DeleteProgram(ctx, prog);
+ }
+#else
+ /* The ID is immediately available for re-use now */
+ _mesa_HashRemove(ctx->Shared->Programs, id);
+ prog->RefCount--;
+ if (prog->RefCount <= 0) {
+ ctx->Driver.DeleteProgram(ctx, prog);
+ }
+#endif
+ }
+}
+
+void GLAPIENTRY
+_mesa_BeginFragmentShaderATI(void)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ /* malloc the instructions here - not sure if the best place but its
+ a start */
+ ctx->ATIFragmentShader.Current->Instructions =
+ (struct atifs_instruction *)
+ _mesa_calloc(sizeof(struct atifs_instruction) * MAX_NUM_PASSES_ATI *
+ MAX_NUM_INSTRUCTIONS_PER_PASS_ATI * 2);
+
+ ctx->ATIFragmentShader.Current->cur_pass = 0;
+ ctx->ATIFragmentShader.Compiling = 1;
+}
+
+void GLAPIENTRY
+_mesa_EndFragmentShaderATI(void)
+{
+ GET_CURRENT_CONTEXT(ctx);
+#if MESA_DEBUG_ATI_FS
+ struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current;
+ GLint i;
+#endif
+
+ ctx->ATIFragmentShader.Compiling = 0;
+ ctx->ATIFragmentShader.Current->NumPasses = ctx->ATIFragmentShader.Current->cur_pass;
+ ctx->ATIFragmentShader.Current->cur_pass=0;
+#if MESA_DEBUG_ATI_FS
+ for (i = 0; i < curProg->Base.NumInstructions; i++) {
+ GLuint op0 = curProg->Instructions[i].Opcode[0];
+ GLuint op1 = curProg->Instructions[i].Opcode[1];
+ const char *op0_enum = op0 > 5 ? _mesa_lookup_enum_by_nr(op0) : "0";
+ const char *op1_enum = op1 > 5 ? _mesa_lookup_enum_by_nr(op1) : "0";
+ GLuint count0 = curProg->Instructions[i].ArgCount[0];
+ GLuint count1 = curProg->Instructions[i].ArgCount[1];
+
+ fprintf(stderr, "%2d %04X %s %d %04X %s %d\n", i, op0, op0_enum, count0,
+ op1, op1_enum, count1);
+ }
+#endif
+}
+
+void GLAPIENTRY
+_mesa_PassTexCoordATI(GLuint dst, GLuint coord, GLenum swizzle)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current;
+ GLint ci;
+ struct atifs_instruction *curI;
+
+ if (ctx->ATIFragmentShader.Current->cur_pass==1)
+ ctx->ATIFragmentShader.Current->cur_pass=2;
+
+ new_inst(curProg);
+ ci = curProg->Base.NumInstructions - 1;
+ /* some validation
+ if ((swizzle != GL_SWIZZLE_STR_ATI) ||
+ (swizzle != GL_SWIZZLE_STQ_ATI) ||
+ (swizzle != GL_SWIZZLE_STR_DR_ATI) ||
+ (swizzle != GL_SWIZZLE_STQ_DQ_ATI))
+ */
+
+ /* add the instructions */
+ curI = &curProg->Instructions[ci];
+
+ curI->Opcode[0] = ATI_FRAGMENT_SHADER_PASS_OP;
+ curI->DstReg[0].Index = dst;
+ curI->SrcReg[0][0].Index = coord;
+ curI->DstReg[0].Swizzle = swizzle;
+
+#if MESA_DEBUG_ATI_FS
+ _mesa_debug(ctx, "%s(%s, %s, %s)\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(dst), _mesa_lookup_enum_by_nr(coord),
+ _mesa_lookup_enum_by_nr(swizzle));
+#endif
+}
+
+void GLAPIENTRY
+_mesa_SampleMapATI(GLuint dst, GLuint interp, GLenum swizzle)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current;
+ GLint ci;
+ struct atifs_instruction *curI;
+
+ if (ctx->ATIFragmentShader.Current->cur_pass==1)
+ ctx->ATIFragmentShader.Current->cur_pass=2;
+
+
+ new_inst(curProg);
+
+ ci = curProg->Base.NumInstructions - 1;
+ /* add the instructions */
+ curI = &curProg->Instructions[ci];
+
+ curI->Opcode[0] = ATI_FRAGMENT_SHADER_SAMPLE_OP;
+ curI->DstReg[0].Index = dst;
+ curI->DstReg[0].Swizzle = swizzle;
+
+ curI->SrcReg[0][0].Index = interp;
+
+#if MESA_DEBUG_ATI_FS
+ _mesa_debug(ctx, "%s(%s, %s, %s)\n", __FUNCTION__,
+ _mesa_lookup_enum_by_nr(dst), _mesa_lookup_enum_by_nr(interp),
+ _mesa_lookup_enum_by_nr(swizzle));
+#endif
+}
+
+static void
+_mesa_FragmentOpXATI(GLint optype, GLuint arg_count, GLenum op, GLuint dst,
+ GLuint dstMask, GLuint dstMod, GLuint arg1,
+ GLuint arg1Rep, GLuint arg1Mod, GLuint arg2,
+ GLuint arg2Rep, GLuint arg2Mod, GLuint arg3,
+ GLuint arg3Rep, GLuint arg3Mod)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current;
+ GLint ci;
+ struct atifs_instruction *curI;
+
+ if (ctx->ATIFragmentShader.Current->cur_pass==0)
+ ctx->ATIFragmentShader.Current->cur_pass=1;
+
+ /* decide whether this is a new instruction or not ... all color instructions are new */
+ if (optype == 0)
+ new_inst(curProg);
+
+ ci = curProg->Base.NumInstructions - 1;
+
+ /* add the instructions */
+ curI = &curProg->Instructions[ci];
+
+ curI->Opcode[optype] = op;
+
+ curI->SrcReg[optype][0].Index = arg1;
+ curI->SrcReg[optype][0].argRep = arg1Rep;
+ curI->SrcReg[optype][0].argMod = arg1Mod;
+ curI->ArgCount[optype] = arg_count;
+
+ if (arg2) {
+ curI->SrcReg[optype][1].Index = arg2;
+ curI->SrcReg[optype][1].argRep = arg2Rep;
+ curI->SrcReg[optype][1].argMod = arg2Mod;
+ }
+
+ if (arg3) {
+ curI->SrcReg[optype][2].Index = arg3;
+ curI->SrcReg[optype][2].argRep = arg3Rep;
+ curI->SrcReg[optype][2].argMod = arg3Mod;
+ }
+
+ curI->DstReg[optype].Index = dst;
+ curI->DstReg[optype].dstMod = dstMod;
+ curI->DstReg[optype].dstMask = dstMask;
+
+#if MESA_DEBUG_ATI_FS
+ debug_op(optype, arg_count, op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod);
+#endif
+
+}
+
+void GLAPIENTRY
+_mesa_ColorFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMask,
+ GLuint dstMod, GLuint arg1, GLuint arg1Rep,
+ GLuint arg1Mod)
+{
+ _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_COLOR_OP, 1, op, dst, dstMask,
+ dstMod, arg1, arg1Rep, arg1Mod, 0, 0, 0, 0, 0, 0);
+}
+
+void GLAPIENTRY
+_mesa_ColorFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMask,
+ GLuint dstMod, GLuint arg1, GLuint arg1Rep,
+ GLuint arg1Mod, GLuint arg2, GLuint arg2Rep,
+ GLuint arg2Mod)
+{
+ _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_COLOR_OP, 2, op, dst, dstMask,
+ dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep,
+ arg2Mod, 0, 0, 0);
+}
+
+void GLAPIENTRY
+_mesa_ColorFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMask,
+ GLuint dstMod, GLuint arg1, GLuint arg1Rep,
+ GLuint arg1Mod, GLuint arg2, GLuint arg2Rep,
+ GLuint arg2Mod, GLuint arg3, GLuint arg3Rep,
+ GLuint arg3Mod)
+{
+ _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_COLOR_OP, 3, op, dst, dstMask,
+ dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep,
+ arg2Mod, arg3, arg3Rep, arg3Mod);
+}
+
+void GLAPIENTRY
+_mesa_AlphaFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1,
+ GLuint arg1Rep, GLuint arg1Mod)
+{
+ _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_ALPHA_OP, 1, op, dst, 0, dstMod,
+ arg1, arg1Rep, arg1Mod, 0, 0, 0, 0, 0, 0);
+}
+
+void GLAPIENTRY
+_mesa_AlphaFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1,
+ GLuint arg1Rep, GLuint arg1Mod, GLuint arg2,
+ GLuint arg2Rep, GLuint arg2Mod)
+{
+ _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_ALPHA_OP, 2, op, dst, 0, dstMod,
+ arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, 0, 0,
+ 0);
+}
+
+void GLAPIENTRY
+_mesa_AlphaFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1,
+ GLuint arg1Rep, GLuint arg1Mod, GLuint arg2,
+ GLuint arg2Rep, GLuint arg2Mod, GLuint arg3,
+ GLuint arg3Rep, GLuint arg3Mod)
+{
+ _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_ALPHA_OP, 3, op, dst, 0, dstMod,
+ arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3,
+ arg3Rep, arg3Mod);
+}
+
+void GLAPIENTRY
+_mesa_SetFragmentShaderConstantATI(GLuint dst, const GLfloat * value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint dstindex = dst - GL_CON_0_ATI;
+ struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current;
+
+ COPY_4V(curProg->Constants[dstindex], value);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/atifragshader.h b/nx-X11/extras/Mesa/src/mesa/shader/atifragshader.h
new file mode 100644
index 000000000..82ac4746b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/atifragshader.h
@@ -0,0 +1,105 @@
+/*
+ * Mesa 3-D graphics library ATI Fragment Shader
+ *
+ * Copyright (C) 2004 David Airlie All Rights Reserved.
+ *
+ */
+
+#ifndef ATIFRAGSHADER_H
+#define ATIFRAGSHADER_H
+
+#define MAX_NUM_INSTRUCTIONS_PER_PASS_ATI 8
+#define MAX_NUM_PASSES_ATI 2
+#define MAX_NUM_FRAGMENT_REGISTERS_ATI 6
+
+struct ati_fs_opcode_st
+{
+ GLenum opcode;
+ GLint num_src_args;
+};
+
+extern struct ati_fs_opcode_st ati_fs_opcodes[];
+
+struct atifragshader_src_register
+{
+ GLuint Index;
+ GLuint argRep;
+ GLuint argMod;
+};
+
+struct atifragshader_dst_register
+{
+ GLuint Index;
+ GLuint dstMod;
+ GLuint dstMask;
+ GLuint Swizzle;
+};
+
+#define ATI_FRAGMENT_SHADER_COLOR_OP 0
+#define ATI_FRAGMENT_SHADER_ALPHA_OP 1
+#define ATI_FRAGMENT_SHADER_PASS_OP 2
+#define ATI_FRAGMENT_SHADER_SAMPLE_OP 3
+
+/* two opcodes - one for color/one for alpha - also pass/sample */
+/* up to three source registers for most ops */
+struct atifs_instruction
+{
+ GLenum Opcode[2];
+ GLuint ArgCount[2];
+ struct atifragshader_src_register SrcReg[2][3];
+ struct atifragshader_dst_register DstReg[2];
+};
+
+extern GLuint GLAPIENTRY _mesa_GenFragmentShadersATI(GLuint range);
+
+extern void GLAPIENTRY _mesa_BindFragmentShaderATI(GLuint id);
+
+extern void GLAPIENTRY _mesa_DeleteFragmentShaderATI(GLuint id);
+
+extern void GLAPIENTRY _mesa_BeginFragmentShaderATI(void);
+
+extern void GLAPIENTRY _mesa_EndFragmentShaderATI(void);
+
+extern void GLAPIENTRY
+_mesa_PassTexCoordATI(GLuint dst, GLuint coord, GLenum swizzle);
+
+extern void GLAPIENTRY
+_mesa_SampleMapATI(GLuint dst, GLuint interp, GLenum swizzle);
+
+extern void GLAPIENTRY
+_mesa_ColorFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMask,
+ GLuint dstMod, GLuint arg1, GLuint arg1Rep,
+ GLuint arg1Mod);
+
+extern void GLAPIENTRY
+_mesa_ColorFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMask,
+ GLuint dstMod, GLuint arg1, GLuint arg1Rep,
+ GLuint arg1Mod, GLuint arg2, GLuint arg2Rep,
+ GLuint arg2Mod);
+
+extern void GLAPIENTRY
+_mesa_ColorFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMask,
+ GLuint dstMod, GLuint arg1, GLuint arg1Rep,
+ GLuint arg1Mod, GLuint arg2, GLuint arg2Rep,
+ GLuint arg2Mod, GLuint arg3, GLuint arg3Rep,
+ GLuint arg3Mod);
+
+extern void GLAPIENTRY
+_mesa_AlphaFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1,
+ GLuint arg1Rep, GLuint arg1Mod);
+
+extern void GLAPIENTRY
+_mesa_AlphaFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1,
+ GLuint arg1Rep, GLuint arg1Mod, GLuint arg2,
+ GLuint arg2Rep, GLuint arg2Mod);
+
+extern void GLAPIENTRY
+_mesa_AlphaFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1,
+ GLuint arg1Rep, GLuint arg1Mod, GLuint arg2,
+ GLuint arg2Rep, GLuint arg2Mod, GLuint arg3,
+ GLuint arg3Rep, GLuint arg3Mod);
+
+extern void GLAPIENTRY
+_mesa_SetFragmentShaderConstantATI(GLuint dst, const GLfloat * value);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/descrip.mms b/nx-X11/extras/Mesa/src/mesa/shader/descrip.mms
new file mode 100644
index 000000000..e52479c9a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/descrip.mms
@@ -0,0 +1,83 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+# Last revision : 1 June 2005
+
+.first
+ define gl [---.include.gl]
+ define math [-.math]
+ define swrast [-.swrast]
+ define array_cache [-.array_cache]
+
+.include [---]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [---.include],[.grammar],[-.main],[-.glapi],[.slang]
+LIBDIR = [---.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)
+
+SOURCES = \
+ atifragshader.c \
+ arbfragparse.c \
+ arbprogparse.c \
+ arbprogram.c \
+ arbvertparse.c \
+ nvfragparse.c \
+ nvprogram.c \
+ nvvertexec.c \
+ nvvertparse.c \
+ program.c \
+ shaderobjects.c \
+ shaderobjects_3dlabs.c
+
+OBJECTS = \
+ atifragshader.obj,\
+ arbfragparse.obj,\
+ arbprogparse.obj,\
+ arbprogram.obj,\
+ arbvertparse.obj,\
+ nvfragparse.obj,\
+ nvprogram.obj,\
+ nvvertexec.obj,\
+ nvvertparse.obj,\
+ program.obj,\
+ shaderobjects.obj,\
+ shaderobjects_3dlabs.obj
+
+
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+all :
+ $(MMS)$(MMSQUALIFIERS) $(LIBDIR)$(GL_LIB)
+ set def [.slang]
+ $(MMS)$(MMSQUALIFIERS)
+ set def [-.grammar]
+ $(MMS)$(MMSQUALIFIERS)
+ set def [-]
+
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+ @ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
+
+clean :
+ purge
+ delete *.obj;*
+
+atifragshader.obj : atifragshader.c
+arbfragparse.obj : arbfragparse.c
+arbprogparse.obj : arbprogparse.c
+arbprogram.obj : arbprogram.c
+arbvertparse.obj : arbvertparse.c
+nvfragparse.obj : nvfragparse.c
+nvprogram.obj : nvprogram.c
+nvvertexec.obj : nvvertexec.c
+nvvertparse.obj : nvvertparse.c
+program.obj : program.c
+shaderobjects.obj : shaderobjects.c
+ cc$(CFLAGS)/nowarn shaderobjects.c
+shaderobjects_3dlabs.obj : shaderobjects_3dlabs.c
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/grammar/descrip.mms b/nx-X11/extras/Mesa/src/mesa/shader/grammar/descrip.mms
new file mode 100644
index 000000000..b6736af15
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/grammar/descrip.mms
@@ -0,0 +1,41 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+# Last revision : 1 June 2005
+
+.first
+ define gl [----.include.gl]
+ define math [--.math]
+ define swrast [--.swrast]
+ define array_cache [--.array_cache]
+
+.include [----]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [----.include],[],[--.main],[--.glapi],[-.slang]
+LIBDIR = [----.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)
+
+SOURCES = grammar_mesa.c
+
+OBJECTS = grammar_mesa.obj
+
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+all :
+ $(MMS)$(MMSQUALIFIERS) $(LIBDIR)$(GL_LIB)
+
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+ @ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
+
+clean :
+ purge
+ delete *.obj;*
+
+grammar_mesa.obj : grammar_mesa.c grammar.c
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar.c b/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar.c
new file mode 100644
index 000000000..0b767c02c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar.c
@@ -0,0 +1,3148 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.2
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file grammar.c
+ * syntax parsing engine
+ * \author Michal Krol
+ */
+
+#ifndef GRAMMAR_PORT_BUILD
+#error Do not build this file directly, build your grammar_XXX.c instead, which includes this file
+#endif
+
+/*
+*/
+
+/*
+ INTRODUCTION
+ ------------
+
+ The task is to check the syntax of an input string. Input string is a stream of ASCII
+ characters terminated with a null-character ('\0'). Checking it using C language is
+ difficult and hard to implement without bugs. It is hard to maintain and make changes when
+ the syntax changes.
+
+ This is because of a high redundancy of the C code. Large blocks of code are duplicated with
+ only small changes. Even use of macros does not solve the problem because macros cannot
+ erase the complexity of the problem.
+
+ The resolution is to create a new language that will be highly oriented to our task. Once
+ we describe a particular syntax, we are done. We can then focus on the code that implements
+ the language. The size and complexity of it is relatively small than the code that directly
+ checks the syntax.
+
+ First, we must implement our new language. Here, the language is implemented in C, but it
+ could also be implemented in any other language. The code is listed below. We must take
+ a good care that it is bug free. This is simple because the code is simple and clean.
+
+ Next, we must describe the syntax of our new language in itself. Once created and checked
+ manually that it is correct, we can use it to check another scripts.
+
+ Note that our new language loading code does not have to check the syntax. It is because we
+ assume that the script describing itself is correct, and other scripts can be syntactically
+ checked by the former script. The loading code must only do semantic checking which leads us to
+ simple resolving references.
+
+ THE LANGUAGE
+ ------------
+
+ Here I will describe the syntax of the new language (further called "Synek"). It is mainly a
+ sequence of declarations terminated by a semicolon. The declaration consists of a symbol,
+ which is an identifier, and its definition. A definition is in turn a sequence of specifiers
+ connected with ".and" or ".or" operator. These operators cannot be mixed together in a one
+ definition. Specifier can be a symbol, string, character, character range or a special
+ keyword ".true" or ".false".
+
+ On the very beginning of the script there is a declaration of a root symbol and is in the form:
+ .syntax <root_symbol>;
+ The <root_symbol> must be on of the symbols in declaration sequence. The syntax is correct if
+ the root symbol evaluates to true. A symbol evaluates to true if the definition associated with
+ the symbol evaluates to true. Definition evaluation depends on the operator used to connect
+ specifiers in the definition. If ".and" operator is used, definition evaluates to true if and
+ only if all the specifiers evaluate to true. If ".or" operator is used, definition evalutes to
+ true if any of the specifiers evaluates to true. If definition contains only one specifier,
+ it is evaluated as if it was connected with ".true" keyword by ".and" operator.
+
+ If specifier is a ".true" keyword, it always evaluates to true.
+
+ If specifier is a ".false" keyword, it always evaluates to false. Specifier evaluates to false
+ when it does not evaluate to true.
+
+ Character range specifier is in the form:
+ '<first_character>' - '<second_character>'
+ If specifier is a character range, it evaluates to true if character in the stream is greater
+ or equal to <first_character> and less or equal to <second_character>. In that situation
+ the stream pointer is advanced to point to next character in the stream. All C-style escape
+ sequences are supported although trigraph sequences are not. The comparisions are performed
+ on 8-bit unsigned integers.
+
+ Character specifier is in the form:
+ '<single_character>'
+ It evaluates to true if the following character range specifier evaluates to true:
+ '<single_character>' - '<single_character>'
+
+ String specifier is in the form:
+ "<string>"
+ Let N be the number of characters in <string>. Let <string>[i] designate i-th character in
+ <string>. Then the string specifier evaluates to true if and only if for i in the range [0, N)
+ the following character specifier evaluates to true:
+ '<string>[i]'
+ If <string>[i] is a quotation mark, '<string>[i]' is replaced with '\<string>[i]'.
+
+ Symbol specifier can be optionally preceded by a ".loop" keyword in the form:
+ .loop <symbol> (1)
+ where <symbol> is defined as follows:
+ <symbol> <definition>; (2)
+ Construction (1) is replaced by the following code:
+ <symbol$1>
+ and declaration (2) is replaced by the following:
+ <symbol$1> <symbol$2> .or .true;
+ <symbol$2> <symbol> .and <symbol$1>;
+ <symbol> <definition>;
+
+ Synek supports also a register mechanizm. User can, in its SYN file, declare a number of
+ registers that can be accessed in the syn body. Each reg has its name and a default value.
+ The register is one byte wide. The C code can change the default value by calling
+ grammar_set_reg8() with grammar id, register name and a new value. As we know, each rule is
+ a sequence of specifiers joined with .and or .or operator. And now each specifier can be
+ prefixed with a condition expression in a form ".if (<reg_name> <operator> <hex_literal>)"
+ where <operator> can be == or !=. If the condition evaluates to false, the specifier
+ evaluates to .false. Otherwise it evalutes to the specifier.
+
+ ESCAPE SEQUENCES
+ ----------------
+
+ Synek supports all escape sequences in character specifiers. The mapping table is listed below.
+ All occurences of the characters in the first column are replaced with the corresponding
+ character in the second column.
+
+ Escape sequence Represents
+ ------------------------------------------------------------------------------------------------
+ \a Bell (alert)
+ \b Backspace
+ \f Formfeed
+ \n New line
+ \r Carriage return
+ \t Horizontal tab
+ \v Vertical tab
+ \' Single quotation mark
+ \" Double quotation mark
+ \\ Backslash
+ \? Literal question mark
+ \ooo ASCII character in octal notation
+ \xhhh ASCII character in hexadecimal notation
+ ------------------------------------------------------------------------------------------------
+
+ RAISING ERRORS
+ --------------
+
+ Any specifier can be followed by a special construction that is executed when the specifier
+ evaluates to false. The construction is in the form:
+ .error <ERROR_TEXT>
+ <ERROR_TEXT> is an identifier declared earlier by error text declaration. The declaration is
+ in the form:
+ .errtext <ERROR_TEXT> "<error_desc>"
+ When specifier evaluates to false and this construction is present, parsing is stopped
+ immediately and <error_desc> is returned as a result of parsing. The error position is also
+ returned and it is meant as an offset from the beggining of the stream to the character that
+ was valid so far. Example:
+
+ (**** syntax script ****)
+
+ .syntax program;
+ .errtext MISSING_SEMICOLON "missing ';'"
+ program declaration .and .loop space .and ';' .error MISSING_SEMICOLON .and
+ .loop space .and '\0';
+ declaration "declare" .and .loop space .and identifier;
+ space ' ';
+
+ (**** sample code ****)
+
+ declare foo ,
+
+ In the example above checking the sample code will result in error message "missing ';'" and
+ error position 12. The sample code is not correct. Note the presence of '\0' specifier to
+ assure that there is no code after semicolon - only spaces.
+ <error_desc> can optionally contain identifier surrounded by dollar signs $. In such a case,
+ the identifier and dollar signs are replaced by a string retrieved by invoking symbol with
+ the identifier name. The starting position is the error position. The lenght of the resulting
+ string is the position after invoking the symbol.
+
+ PRODUCTION
+ ----------
+
+ Synek not only checks the syntax but it can also produce (emit) bytes associated with specifiers
+ that evaluate to true. That is, every specifier and optional error construction can be followed
+ by a number of emit constructions that are in the form:
+ .emit <parameter>
+ <paramater> can be a HEX number, identifier, a star * or a dollar $. HEX number is preceded by
+ 0x or 0X. If <parameter> is an identifier, it must be earlier declared by emit code declaration
+ in the form:
+ .emtcode <identifier> <hex_number>
+
+ When given specifier evaluates to true, all emits associated with the specifier are output
+ in order they were declared. A star means that last-read character should be output instead
+ of constant value. Example:
+
+ (**** syntax script ****)
+
+ .syntax foobar;
+ .emtcode WORD_FOO 0x01
+ .emtcode WORD_BAR 0x02
+ foobar FOO .emit WORD_FOO .or BAR .emit WORD_BAR .or .true .emit 0x00;
+ FOO "foo" .and SPACE;
+ BAR "bar" .and SPACE;
+ SPACE ' ' .or '\0';
+
+ (**** sample text 1 ****)
+
+ foo
+
+ (**** sample text 2 ****)
+
+ foobar
+
+ For both samples the result will be one-element array. For first sample text it will be
+ value 1, for second - 0. Note that every text will be accepted because of presence of
+ .true as an alternative.
+
+ Another example:
+
+ (**** syntax script ****)
+
+ .syntax declaration;
+ .emtcode VARIABLE 0x01
+ declaration "declare" .and .loop space .and
+ identifier .emit VARIABLE .and (1)
+ .true .emit 0x00 .and (2)
+ .loop space .and ';';
+ space ' ' .or '\t';
+ identifier .loop id_char .emit *; (3)
+ id_char 'a'-'z' .or 'A'-'Z' .or '_';
+
+ (**** sample code ****)
+
+ declare fubar;
+
+ In specifier (1) symbol <identifier> is followed by .emit VARIABLE. If it evaluates to
+ true, VARIABLE constant and then production of the symbol is output. Specifier (2) is used
+ to terminate the string with null to signal when the string ends. Specifier (3) outputs
+ all characters that make declared identifier. The result of sample code will be the
+ following array:
+ { 1, 'f', 'u', 'b', 'a', 'r', 0 }
+
+ If .emit is followed by dollar $, it means that current position should be output. Current
+ position is a 32-bit unsigned integer distance from the very beginning of the parsed string to
+ first character consumed by the specifier associated with the .emit instruction. Current
+ position is stored in the output buffer in Little-Endian convention (the lowest byte comes
+ first).
+*/
+
+static void mem_free (void **);
+
+/*
+ internal error messages
+*/
+static const byte *OUT_OF_MEMORY = (byte *) "internal error 1001: out of physical memory";
+static const byte *UNRESOLVED_REFERENCE = (byte *) "internal error 1002: unresolved reference '$'";
+static const byte *INVALID_GRAMMAR_ID = (byte *) "internal error 1003: invalid grammar object";
+static const byte *INVALID_REGISTER_NAME = (byte *) "internal error 1004: invalid register name: '$'";
+/*static const byte *DUPLICATE_IDENTIFIER = (byte *) "internal error 1005: identifier '$' already defined";*/
+static const byte *UNREFERENCED_IDENTIFIER =(byte *) "internal error 1006: unreferenced identifier '$'";
+
+static const byte *error_message = NULL; /* points to one of the error messages above */
+static byte *error_param = NULL; /* this is inserted into error_message in place of $ */
+static int error_position = -1;
+
+static byte *unknown = (byte *) "???";
+
+static void clear_last_error (void)
+{
+ /* reset error message */
+ error_message = NULL;
+
+ /* free error parameter - if error_param is a "???" don't free it - it's static */
+ if (error_param != unknown)
+ mem_free ((void **) (void *) &error_param);
+ else
+ error_param = NULL;
+
+ /* reset error position */
+ error_position = -1;
+}
+
+static void set_last_error (const byte *msg, byte *param, int pos)
+{
+ /* error message can be set only once */
+ if (error_message != NULL)
+ {
+ mem_free ((void **) (void *) &param);
+ return;
+ }
+
+ error_message = msg;
+
+ /* if param is NULL, set error_param to unknown ("???") */
+ /* note: do not try to strdup the "???" - it may be that we are here because of */
+ /* out of memory error so strdup can fail */
+ if (param != NULL)
+ error_param = param;
+ else
+ error_param = unknown;
+
+ error_position = pos;
+}
+
+/*
+ memory management routines
+*/
+static void *mem_alloc (size_t size)
+{
+ void *ptr = grammar_alloc_malloc (size);
+ if (ptr == NULL)
+ set_last_error (OUT_OF_MEMORY, NULL, -1);
+ return ptr;
+}
+
+static void *mem_copy (void *dst, const void *src, size_t size)
+{
+ return grammar_memory_copy (dst, src, size);
+}
+
+static void mem_free (void **ptr)
+{
+ grammar_alloc_free (*ptr);
+ *ptr = NULL;
+}
+
+static void *mem_realloc (void *ptr, size_t old_size, size_t new_size)
+{
+ void *ptr2 = grammar_alloc_realloc (ptr, old_size, new_size);
+ if (ptr2 == NULL)
+ set_last_error (OUT_OF_MEMORY, NULL, -1);
+ return ptr2;
+}
+
+static byte *str_copy_n (byte *dst, const byte *src, size_t max_len)
+{
+ return grammar_string_copy_n (dst, src, max_len);
+}
+
+static byte *str_duplicate (const byte *str)
+{
+ byte *new_str = grammar_string_duplicate (str);
+ if (new_str == NULL)
+ set_last_error (OUT_OF_MEMORY, NULL, -1);
+ return new_str;
+}
+
+static int str_equal (const byte *str1, const byte *str2)
+{
+ return grammar_string_compare (str1, str2) == 0;
+}
+
+static int str_equal_n (const byte *str1, const byte *str2, unsigned int n)
+{
+ return grammar_string_compare_n (str1, str2, n) == 0;
+}
+
+static unsigned int str_length (const byte *str)
+{
+ return grammar_string_length (str);
+}
+
+/*
+ useful macros
+*/
+#define GRAMMAR_IMPLEMENT_LIST_APPEND(_Ty)\
+ static void _Ty##_append (_Ty **x, _Ty *nx) {\
+ while (*x) x = &(**x).next;\
+ *x = nx;\
+ }
+
+/*
+ string to byte map typedef
+*/
+typedef struct map_byte_
+{
+ byte *key;
+ byte data;
+ struct map_byte_ *next;
+} map_byte;
+
+static void map_byte_create (map_byte **ma)
+{
+ *ma = (map_byte *) mem_alloc (sizeof (map_byte));
+ if (*ma)
+ {
+ (**ma).key = NULL;
+ (**ma).data = '\0';
+ (**ma).next = NULL;
+ }
+}
+
+static void map_byte_destroy (map_byte **ma)
+{
+ if (*ma)
+ {
+ map_byte_destroy (&(**ma).next);
+ mem_free ((void **) &(**ma).key);
+ mem_free ((void **) ma);
+ }
+}
+
+GRAMMAR_IMPLEMENT_LIST_APPEND(map_byte)
+
+/*
+ searches the map for the specified key,
+ returns pointer to the element with the specified key if it exists
+ returns NULL otherwise
+*/
+static map_byte *map_byte_locate (map_byte **ma, const byte *key)
+{
+ while (*ma)
+ {
+ if (str_equal ((**ma).key, key))
+ return *ma;
+
+ ma = &(**ma).next;
+ }
+
+ set_last_error (UNRESOLVED_REFERENCE, str_duplicate (key), -1);
+ return NULL;
+}
+
+/*
+ searches the map for specified key,
+ if the key is matched, *data is filled with data associated with the key,
+ returns 0 if the key is matched,
+ returns 1 otherwise
+*/
+static int map_byte_find (map_byte **ma, const byte *key, byte *data)
+{
+ map_byte *found = map_byte_locate (ma, key);
+ if (found != NULL)
+ {
+ *data = found->data;
+
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ regbyte context typedef
+
+ Each regbyte consists of its name and a default value. These are static and created at
+ grammar script compile-time, for example the following line:
+ .regbyte vertex_blend 0x00
+ adds a new regbyte named "vertex_blend" to the static list and initializes it to 0.
+ When the script is executed, this regbyte can be accessed by name for read and write. When a
+ particular regbyte is written, a new regbyte_ctx entry is added to the top of the regbyte_ctx
+ stack. The new entry contains information abot which regbyte it references and its new value.
+ When a given regbyte is accessed for read, the stack is searched top-down to find an
+ entry that references the regbyte. The first matching entry is used to return the current
+ value it holds. If no entry is found, the default value is returned.
+*/
+typedef struct regbyte_ctx_
+{
+ map_byte *m_regbyte;
+ byte m_current_value;
+ struct regbyte_ctx_ *m_prev;
+} regbyte_ctx;
+
+static void regbyte_ctx_create (regbyte_ctx **re)
+{
+ *re = (regbyte_ctx *) mem_alloc (sizeof (regbyte_ctx));
+ if (*re)
+ {
+ (**re).m_regbyte = NULL;
+ (**re).m_prev = NULL;
+ }
+}
+
+static void regbyte_ctx_destroy (regbyte_ctx **re)
+{
+ if (*re)
+ {
+ mem_free ((void **) re);
+ }
+}
+
+static byte regbyte_ctx_extract (regbyte_ctx **re, map_byte *reg)
+{
+ /* first lookup in the register stack */
+ while (*re != NULL)
+ {
+ if ((**re).m_regbyte == reg)
+ return (**re).m_current_value;
+
+ re = &(**re).m_prev;
+ }
+
+ /* if not found - return the default value */
+ return reg->data;
+}
+
+/*
+ emit type typedef
+*/
+typedef enum emit_type_
+{
+ et_byte, /* explicit number */
+ et_stream, /* eaten character */
+ et_position /* current position */
+} emit_type;
+
+/*
+ emit destination typedef
+*/
+typedef enum emit_dest_
+{
+ ed_output, /* write to the output buffer */
+ ed_regbyte /* write a particular regbyte */
+} emit_dest;
+
+/*
+ emit typedef
+*/
+typedef struct emit_
+{
+ emit_dest m_emit_dest;
+ emit_type m_emit_type; /* ed_output */
+ byte m_byte; /* et_byte */
+ map_byte *m_regbyte; /* ed_regbyte */
+ byte *m_regname; /* ed_regbyte - temporary */
+ struct emit_ *m_next;
+} emit;
+
+static void emit_create (emit **em)
+{
+ *em = (emit *) mem_alloc (sizeof (emit));
+ if (*em)
+ {
+ (**em).m_emit_dest = ed_output;
+ (**em).m_emit_type = et_byte;
+ (**em).m_byte = '\0';
+ (**em).m_regbyte = NULL;
+ (**em).m_regname = NULL;
+ (**em).m_next = NULL;
+ }
+}
+
+static void emit_destroy (emit **em)
+{
+ if (*em)
+ {
+ emit_destroy (&(**em).m_next);
+ mem_free ((void **) &(**em).m_regname);
+ mem_free ((void **) em);
+ }
+}
+
+static unsigned int emit_size (emit *_E)
+{
+ unsigned int n = 0;
+
+ while (_E != NULL)
+ {
+ if (_E->m_emit_dest == ed_output)
+ {
+ if (_E->m_emit_type == et_position)
+ n += 4; /* position is a 32-bit unsigned integer */
+ else
+ n++;
+ }
+ _E = _E->m_next;
+ }
+
+ return n;
+}
+
+static int emit_push (emit *_E, byte *_P, byte c, unsigned int _Pos, regbyte_ctx **_Ctx)
+{
+ while (_E != NULL)
+ {
+ if (_E->m_emit_dest == ed_output)
+ {
+ if (_E->m_emit_type == et_byte)
+ *_P++ = _E->m_byte;
+ else if (_E->m_emit_type == et_stream)
+ *_P++ = c;
+ else /* _Em->type == et_position */
+ {
+ *_P++ = (byte) (_Pos);
+ *_P++ = (byte) (_Pos >> 8);
+ *_P++ = (byte) (_Pos >> 16);
+ *_P++ = (byte) (_Pos >> 24);
+ }
+ }
+ else
+ {
+ regbyte_ctx *new_rbc;
+ regbyte_ctx_create (&new_rbc);
+ if (new_rbc == NULL)
+ return 1;
+
+ new_rbc->m_prev = *_Ctx;
+ new_rbc->m_regbyte = _E->m_regbyte;
+ *_Ctx = new_rbc;
+
+ if (_E->m_emit_type == et_byte)
+ new_rbc->m_current_value = _E->m_byte;
+ else if (_E->m_emit_type == et_stream)
+ new_rbc->m_current_value = c;
+ }
+
+ _E = _E->m_next;
+ }
+
+ return 0;
+}
+
+/*
+ error typedef
+*/
+typedef struct error_
+{
+ byte *m_text;
+ byte *m_token_name;
+ struct rule_ *m_token;
+} error;
+
+static void error_create (error **er)
+{
+ *er = (error *) mem_alloc (sizeof (error));
+ if (*er)
+ {
+ (**er).m_text = NULL;
+ (**er).m_token_name = NULL;
+ (**er).m_token = NULL;
+ }
+}
+
+static void error_destroy (error **er)
+{
+ if (*er)
+ {
+ mem_free ((void **) &(**er).m_text);
+ mem_free ((void **) &(**er).m_token_name);
+ mem_free ((void **) er);
+ }
+}
+
+struct dict_;
+static byte *error_get_token (error *, struct dict_ *, const byte *, unsigned int);
+
+/*
+ condition operand type typedef
+*/
+typedef enum cond_oper_type_
+{
+ cot_byte, /* constant 8-bit unsigned integer */
+ cot_regbyte /* pointer to byte register containing the current value */
+} cond_oper_type;
+
+/*
+ condition operand typedef
+*/
+typedef struct cond_oper_
+{
+ cond_oper_type m_type;
+ byte m_byte; /* cot_byte */
+ map_byte *m_regbyte; /* cot_regbyte */
+ byte *m_regname; /* cot_regbyte - temporary */
+} cond_oper;
+
+/*
+ condition type typedef
+*/
+typedef enum cond_type_
+{
+ ct_equal,
+ ct_not_equal
+} cond_type;
+
+/*
+ condition typedef
+*/
+typedef struct cond_
+{
+ cond_type m_type;
+ cond_oper m_operands[2];
+} cond;
+
+static void cond_create (cond **co)
+{
+ *co = (cond *) mem_alloc (sizeof (cond));
+ if (*co)
+ {
+ (**co).m_operands[0].m_regname = NULL;
+ (**co).m_operands[1].m_regname = NULL;
+ }
+}
+
+static void cond_destroy (cond **co)
+{
+ if (*co)
+ {
+ mem_free ((void **) &(**co).m_operands[0].m_regname);
+ mem_free ((void **) &(**co).m_operands[1].m_regname);
+ mem_free ((void **) co);
+ }
+}
+
+/*
+ specifier type typedef
+*/
+typedef enum spec_type_
+{
+ st_false,
+ st_true,
+ st_byte,
+ st_byte_range,
+ st_string,
+ st_identifier,
+ st_identifier_loop,
+ st_debug
+} spec_type;
+
+/*
+ specifier typedef
+*/
+typedef struct spec_
+{
+ spec_type m_spec_type;
+ byte m_byte[2]; /* st_byte, st_byte_range */
+ byte *m_string; /* st_string */
+ struct rule_ *m_rule; /* st_identifier, st_identifier_loop */
+ emit *m_emits;
+ error *m_errtext;
+ cond *m_cond;
+ struct spec_ *next;
+} spec;
+
+static void spec_create (spec **sp)
+{
+ *sp = (spec *) mem_alloc (sizeof (spec));
+ if (*sp)
+ {
+ (**sp).m_spec_type = st_false;
+ (**sp).m_byte[0] = '\0';
+ (**sp).m_byte[1] = '\0';
+ (**sp).m_string = NULL;
+ (**sp).m_rule = NULL;
+ (**sp).m_emits = NULL;
+ (**sp).m_errtext = NULL;
+ (**sp).m_cond = NULL;
+ (**sp).next = NULL;
+ }
+}
+
+static void spec_destroy (spec **sp)
+{
+ if (*sp)
+ {
+ spec_destroy (&(**sp).next);
+ emit_destroy (&(**sp).m_emits);
+ error_destroy (&(**sp).m_errtext);
+ mem_free ((void **) &(**sp).m_string);
+ cond_destroy (&(**sp).m_cond);
+ mem_free ((void **) sp);
+ }
+}
+
+GRAMMAR_IMPLEMENT_LIST_APPEND(spec)
+
+/*
+ operator typedef
+*/
+typedef enum oper_
+{
+ op_none,
+ op_and,
+ op_or
+} oper;
+
+/*
+ rule typedef
+*/
+typedef struct rule_
+{
+ oper m_oper;
+ spec *m_specs;
+ struct rule_ *next;
+ int m_referenced;
+} rule;
+
+static void rule_create (rule **ru)
+{
+ *ru = (rule *) mem_alloc (sizeof (rule));
+ if (*ru)
+ {
+ (**ru).m_oper = op_none;
+ (**ru).m_specs = NULL;
+ (**ru).next = NULL;
+ (**ru).m_referenced = 0;
+ }
+}
+
+static void rule_destroy (rule **ru)
+{
+ if (*ru)
+ {
+ rule_destroy (&(**ru).next);
+ spec_destroy (&(**ru).m_specs);
+ mem_free ((void **) ru);
+ }
+}
+
+GRAMMAR_IMPLEMENT_LIST_APPEND(rule)
+
+/*
+ returns unique grammar id
+*/
+static grammar next_valid_grammar_id (void)
+{
+ static grammar id = 0;
+
+ return ++id;
+}
+
+/*
+ dictionary typedef
+*/
+typedef struct dict_
+{
+ rule *m_rulez;
+ rule *m_syntax;
+ rule *m_string;
+ map_byte *m_regbytes;
+ grammar m_id;
+ struct dict_ *next;
+} dict;
+
+static void dict_create (dict **di)
+{
+ *di = (dict *) mem_alloc (sizeof (dict));
+ if (*di)
+ {
+ (**di).m_rulez = NULL;
+ (**di).m_syntax = NULL;
+ (**di).m_string = NULL;
+ (**di).m_regbytes = NULL;
+ (**di).m_id = next_valid_grammar_id ();
+ (**di).next = NULL;
+ }
+}
+
+static void dict_destroy (dict **di)
+{
+ if (*di)
+ {
+ rule_destroy (&(**di).m_rulez);
+ map_byte_destroy (&(**di).m_regbytes);
+ mem_free ((void **) di);
+ }
+}
+
+GRAMMAR_IMPLEMENT_LIST_APPEND(dict)
+
+static void dict_find (dict **di, grammar key, dict **data)
+{
+ while (*di)
+ {
+ if ((**di).m_id == key)
+ {
+ *data = *di;
+ return;
+ }
+
+ di = &(**di).next;
+ }
+
+ *data = NULL;
+}
+
+static dict *g_dicts = NULL;
+
+/*
+ byte array typedef
+*/
+typedef struct barray_
+{
+ byte *data;
+ unsigned int len;
+} barray;
+
+static void barray_create (barray **ba)
+{
+ *ba = (barray *) mem_alloc (sizeof (barray));
+ if (*ba)
+ {
+ (**ba).data = NULL;
+ (**ba).len = 0;
+ }
+}
+
+static void barray_destroy (barray **ba)
+{
+ if (*ba)
+ {
+ mem_free ((void **) &(**ba).data);
+ mem_free ((void **) ba);
+ }
+}
+
+/*
+ reallocates byte array to requested size,
+ returns 0 on success,
+ returns 1 otherwise
+*/
+static int barray_resize (barray **ba, unsigned int nlen)
+{
+ byte *new_pointer;
+
+ if (nlen == 0)
+ {
+ mem_free ((void **) &(**ba).data);
+ (**ba).data = NULL;
+ (**ba).len = 0;
+
+ return 0;
+ }
+ else
+ {
+ new_pointer = (byte *) mem_realloc ((**ba).data, (**ba).len * sizeof (byte),
+ nlen * sizeof (byte));
+ if (new_pointer)
+ {
+ (**ba).data = new_pointer;
+ (**ba).len = nlen;
+
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+/*
+ adds byte array pointed by *nb to the end of array pointed by *ba,
+ returns 0 on success,
+ returns 1 otherwise
+*/
+static int barray_append (barray **ba, barray **nb)
+{
+ const unsigned int len = (**ba).len;
+
+ if (barray_resize (ba, (**ba).len + (**nb).len))
+ return 1;
+
+ mem_copy ((**ba).data + len, (**nb).data, (**nb).len);
+
+ return 0;
+}
+
+/*
+ adds emit chain pointed by em to the end of array pointed by *ba,
+ returns 0 on success,
+ returns 1 otherwise
+*/
+static int barray_push (barray **ba, emit *em, byte c, unsigned int pos, regbyte_ctx **rbc)
+{
+ unsigned int count = emit_size (em);
+
+ if (barray_resize (ba, (**ba).len + count))
+ return 1;
+
+ return emit_push (em, (**ba).data + ((**ba).len - count), c, pos, rbc);
+}
+
+/*
+ byte pool typedef
+*/
+typedef struct bytepool_
+{
+ byte *_F;
+ unsigned int _Siz;
+} bytepool;
+
+static void bytepool_destroy (bytepool **by)
+{
+ if (*by != NULL)
+ {
+ mem_free ((void **) &(**by)._F);
+ mem_free ((void **) by);
+ }
+}
+
+static void bytepool_create (bytepool **by, int len)
+{
+ *by = (bytepool *) (mem_alloc (sizeof (bytepool)));
+ if (*by != NULL)
+ {
+ (**by)._F = (byte *) (mem_alloc (sizeof (byte) * len));
+ (**by)._Siz = len;
+
+ if ((**by)._F == NULL)
+ bytepool_destroy (by);
+ }
+}
+
+static int bytepool_reserve (bytepool *by, unsigned int n)
+{
+ byte *_P;
+
+ if (n <= by->_Siz)
+ return 0;
+
+ /* byte pool can only grow and at least by doubling its size */
+ n = n >= by->_Siz * 2 ? n : by->_Siz * 2;
+
+ /* reallocate the memory and adjust pointers to the new memory location */
+ _P = (byte *) (mem_realloc (by->_F, sizeof (byte) * by->_Siz, sizeof (byte) * n));
+ if (_P != NULL)
+ {
+ by->_F = _P;
+ by->_Siz = n;
+ return 0;
+ }
+
+ return 1;
+}
+
+/*
+ string to string map typedef
+*/
+typedef struct map_str_
+{
+ byte *key;
+ byte *data;
+ struct map_str_ *next;
+} map_str;
+
+static void map_str_create (map_str **ma)
+{
+ *ma = (map_str *) mem_alloc (sizeof (map_str));
+ if (*ma)
+ {
+ (**ma).key = NULL;
+ (**ma).data = NULL;
+ (**ma).next = NULL;
+ }
+}
+
+static void map_str_destroy (map_str **ma)
+{
+ if (*ma)
+ {
+ map_str_destroy (&(**ma).next);
+ mem_free ((void **) &(**ma).key);
+ mem_free ((void **) &(**ma).data);
+ mem_free ((void **) ma);
+ }
+}
+
+GRAMMAR_IMPLEMENT_LIST_APPEND(map_str)
+
+/*
+ searches the map for specified key,
+ if the key is matched, *data is filled with data associated with the key,
+ returns 0 if the key is matched,
+ returns 1 otherwise
+*/
+static int map_str_find (map_str **ma, const byte *key, byte **data)
+{
+ while (*ma)
+ {
+ if (str_equal ((**ma).key, key))
+ {
+ *data = str_duplicate ((**ma).data);
+ if (*data == NULL)
+ return 1;
+
+ return 0;
+ }
+
+ ma = &(**ma).next;
+ }
+
+ set_last_error (UNRESOLVED_REFERENCE, str_duplicate (key), -1);
+ return 1;
+}
+
+/*
+ string to rule map typedef
+*/
+typedef struct map_rule_
+{
+ byte *key;
+ rule *data;
+ struct map_rule_ *next;
+} map_rule;
+
+static void map_rule_create (map_rule **ma)
+{
+ *ma = (map_rule *) mem_alloc (sizeof (map_rule));
+ if (*ma)
+ {
+ (**ma).key = NULL;
+ (**ma).data = NULL;
+ (**ma).next = NULL;
+ }
+}
+
+static void map_rule_destroy (map_rule **ma)
+{
+ if (*ma)
+ {
+ map_rule_destroy (&(**ma).next);
+ mem_free ((void **) &(**ma).key);
+ mem_free ((void **) ma);
+ }
+}
+
+GRAMMAR_IMPLEMENT_LIST_APPEND(map_rule)
+
+/*
+ searches the map for specified key,
+ if the key is matched, *data is filled with data associated with the key,
+ returns 0 if the is matched,
+ returns 1 otherwise
+*/
+static int map_rule_find (map_rule **ma, const byte *key, rule **data)
+{
+ while (*ma)
+ {
+ if (str_equal ((**ma).key, key))
+ {
+ *data = (**ma).data;
+
+ return 0;
+ }
+
+ ma = &(**ma).next;
+ }
+
+ set_last_error (UNRESOLVED_REFERENCE, str_duplicate (key), -1);
+ return 1;
+}
+
+/*
+ returns 1 if given character is a white space,
+ returns 0 otherwise
+*/
+static int is_space (byte c)
+{
+ return c == ' ' || c == '\t' || c == '\n' || c == '\r';
+}
+
+/*
+ advances text pointer by 1 if character pointed by *text is a space,
+ returns 1 if a space has been eaten,
+ returns 0 otherwise
+*/
+static int eat_space (const byte **text)
+{
+ if (is_space (**text))
+ {
+ (*text)++;
+
+ return 1;
+ }
+
+ return 0;
+}
+
+/*
+ returns 1 if text points to C-style comment start string,
+ returns 0 otherwise
+*/
+static int is_comment_start (const byte *text)
+{
+ return text[0] == '/' && text[1] == '*';
+}
+
+/*
+ advances text pointer to first character after C-style comment block - if any,
+ returns 1 if C-style comment block has been encountered and eaten,
+ returns 0 otherwise
+*/
+static int eat_comment (const byte **text)
+{
+ if (is_comment_start (*text))
+ {
+ /* *text points to comment block - skip two characters to enter comment body */
+ *text += 2;
+ /* skip any character except consecutive '*' and '/' */
+ while (!((*text)[0] == '*' && (*text)[1] == '/'))
+ (*text)++;
+ /* skip those two terminating characters */
+ *text += 2;
+
+ return 1;
+ }
+
+ return 0;
+}
+
+/*
+ advances text pointer to first character that is neither space nor C-style comment block
+*/
+static void eat_spaces (const byte **text)
+{
+ while (eat_space (text) || eat_comment (text))
+ ;
+}
+
+/*
+ resizes string pointed by *ptr to successfully add character c to the end of the string,
+ returns 0 on success,
+ returns 1 otherwise
+*/
+static int string_grow (byte **ptr, unsigned int *len, byte c)
+{
+ /* reallocate the string in 16-byte increments */
+ if ((*len & 0x0F) == 0x0F || *ptr == NULL)
+ {
+ byte *tmp = (byte *) mem_realloc (*ptr, ((*len + 1) & ~0x0F) * sizeof (byte),
+ ((*len + 1 + 0x10) & ~0x0F) * sizeof (byte));
+ if (tmp == NULL)
+ return 1;
+
+ *ptr = tmp;
+ }
+
+ if (c)
+ {
+ /* append given character */
+ (*ptr)[*len] = c;
+ (*len)++;
+ }
+ (*ptr)[*len] = '\0';
+
+ return 0;
+}
+
+/*
+ returns 1 if given character is a valid identifier character a-z, A-Z, 0-9 or _
+ returns 0 otherwise
+*/
+static int is_identifier (byte c)
+{
+ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_';
+}
+
+/*
+ copies characters from *text to *id until non-identifier character is encountered,
+ assumes that *id points to NULL object - caller is responsible for later freeing the string,
+ text pointer is advanced to point past the copied identifier,
+ returns 0 if identifier was successfully copied,
+ returns 1 otherwise
+*/
+static int get_identifier (const byte **text, byte **id)
+{
+ const byte *t = *text;
+ byte *p = NULL;
+ unsigned int len = 0;
+
+ if (string_grow (&p, &len, '\0'))
+ return 1;
+
+ /* loop while next character in buffer is valid for identifiers */
+ while (is_identifier (*t))
+ {
+ if (string_grow (&p, &len, *t++))
+ {
+ mem_free ((void **) (void *) &p);
+ return 1;
+ }
+ }
+
+ *text = t;
+ *id = p;
+
+ return 0;
+}
+
+/*
+ converts sequence of DEC digits pointed by *text until non-DEC digit is encountered,
+ advances text pointer past the converted sequence,
+ returns the converted value
+*/
+static unsigned int dec_convert (const byte **text)
+{
+ unsigned int value = 0;
+
+ while (**text >= '0' && **text <= '9')
+ {
+ value = value * 10 + **text - '0';
+ (*text)++;
+ }
+
+ return value;
+}
+
+/*
+ returns 1 if given character is HEX digit 0-9, A-F or a-f,
+ returns 0 otherwise
+*/
+static int is_hex (byte c)
+{
+ return (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f');
+}
+
+/*
+ returns value of passed character as if it was HEX digit
+*/
+static unsigned int hex2dec (byte c)
+{
+ if (c >= '0' && c <= '9')
+ return c - '0';
+ if (c >= 'A' && c <= 'F')
+ return c - 'A' + 10;
+ return c - 'a' + 10;
+}
+
+/*
+ converts sequence of HEX digits pointed by *text until non-HEX digit is encountered,
+ advances text pointer past the converted sequence,
+ returns the converted value
+*/
+static unsigned int hex_convert (const byte **text)
+{
+ unsigned int value = 0;
+
+ while (is_hex (**text))
+ {
+ value = value * 0x10 + hex2dec (**text);
+ (*text)++;
+ }
+
+ return value;
+}
+
+/*
+ returns 1 if given character is OCT digit 0-7,
+ returns 0 otherwise
+*/
+static int is_oct (byte c)
+{
+ return c >= '0' && c <= '7';
+}
+
+/*
+ returns value of passed character as if it was OCT digit
+*/
+static int oct2dec (byte c)
+{
+ return c - '0';
+}
+
+static byte get_escape_sequence (const byte **text)
+{
+ int value = 0;
+
+ /* skip '\' character */
+ (*text)++;
+
+ switch (*(*text)++)
+ {
+ case '\'':
+ return '\'';
+ case '"':
+ return '\"';
+ case '?':
+ return '\?';
+ case '\\':
+ return '\\';
+ case 'a':
+ return '\a';
+ case 'b':
+ return '\b';
+ case 'f':
+ return '\f';
+ case 'n':
+ return '\n';
+ case 'r':
+ return '\r';
+ case 't':
+ return '\t';
+ case 'v':
+ return '\v';
+ case 'x':
+ return (byte) hex_convert (text);
+ }
+
+ (*text)--;
+ if (is_oct (**text))
+ {
+ value = oct2dec (*(*text)++);
+ if (is_oct (**text))
+ {
+ value = value * 010 + oct2dec (*(*text)++);
+ if (is_oct (**text))
+ value = value * 010 + oct2dec (*(*text)++);
+ }
+ }
+
+ return (byte) value;
+}
+
+/*
+ copies characters from *text to *str until " or ' character is encountered,
+ assumes that *str points to NULL object - caller is responsible for later freeing the string,
+ assumes that *text points to " or ' character that starts the string,
+ text pointer is advanced to point past the " or ' character,
+ returns 0 if string was successfully copied,
+ returns 1 otherwise
+*/
+static int get_string (const byte **text, byte **str)
+{
+ const byte *t = *text;
+ byte *p = NULL;
+ unsigned int len = 0;
+ byte term_char;
+
+ if (string_grow (&p, &len, '\0'))
+ return 1;
+
+ /* read " or ' character that starts the string */
+ term_char = *t++;
+ /* while next character is not the terminating character */
+ while (*t && *t != term_char)
+ {
+ byte c;
+
+ if (*t == '\\')
+ c = get_escape_sequence (&t);
+ else
+ c = *t++;
+
+ if (string_grow (&p, &len, c))
+ {
+ mem_free ((void **) (void *) &p);
+ return 1;
+ }
+ }
+ /* skip " or ' character that ends the string */
+ t++;
+
+ *text = t;
+ *str = p;
+ return 0;
+}
+
+/*
+ gets emit code, the syntax is:
+ ".emtcode" " " <symbol> " " (("0x" | "0X") <hex_value>) | <dec_value> | <character>
+ assumes that *text already points to <symbol>,
+ returns 0 if emit code is successfully read,
+ returns 1 otherwise
+*/
+static int get_emtcode (const byte **text, map_byte **ma)
+{
+ const byte *t = *text;
+ map_byte *m = NULL;
+
+ map_byte_create (&m);
+ if (m == NULL)
+ return 1;
+
+ if (get_identifier (&t, &m->key))
+ {
+ map_byte_destroy (&m);
+ return 1;
+ }
+ eat_spaces (&t);
+
+ if (*t == '\'')
+ {
+ byte *c;
+
+ if (get_string (&t, &c))
+ {
+ map_byte_destroy (&m);
+ return 1;
+ }
+
+ m->data = (byte) c[0];
+ mem_free ((void **) (void *) &c);
+ }
+ else if (t[0] == '0' && (t[1] == 'x' || t[1] == 'X'))
+ {
+ /* skip HEX "0x" or "0X" prefix */
+ t += 2;
+ m->data = (byte) hex_convert (&t);
+ }
+ else
+ {
+ m->data = (byte) dec_convert (&t);
+ }
+
+ eat_spaces (&t);
+
+ *text = t;
+ *ma = m;
+ return 0;
+}
+
+/*
+ gets regbyte declaration, the syntax is:
+ ".regbyte" " " <symbol> " " (("0x" | "0X") <hex_value>) | <dec_value> | <character>
+ assumes that *text already points to <symbol>,
+ returns 0 if regbyte is successfully read,
+ returns 1 otherwise
+*/
+static int get_regbyte (const byte **text, map_byte **ma)
+{
+ /* pass it to the emtcode parser as it has the same syntax starting at <symbol> */
+ return get_emtcode (text, ma);
+}
+
+/*
+ returns 0 on success,
+ returns 1 otherwise
+*/
+static int get_errtext (const byte **text, map_str **ma)
+{
+ const byte *t = *text;
+ map_str *m = NULL;
+
+ map_str_create (&m);
+ if (m == NULL)
+ return 1;
+
+ if (get_identifier (&t, &m->key))
+ {
+ map_str_destroy (&m);
+ return 1;
+ }
+ eat_spaces (&t);
+
+ if (get_string (&t, &m->data))
+ {
+ map_str_destroy (&m);
+ return 1;
+ }
+ eat_spaces (&t);
+
+ *text = t;
+ *ma = m;
+ return 0;
+}
+
+/*
+ returns 0 on success,
+ returns 1 otherwise,
+*/
+static int get_error (const byte **text, error **er, map_str *maps)
+{
+ const byte *t = *text;
+ byte *temp = NULL;
+
+ if (*t != '.')
+ return 0;
+
+ t++;
+ if (get_identifier (&t, &temp))
+ return 1;
+ eat_spaces (&t);
+
+ if (!str_equal ((byte *) "error", temp))
+ {
+ mem_free ((void **) (void *) &temp);
+ return 0;
+ }
+
+ mem_free ((void **) (void *) &temp);
+
+ error_create (er);
+ if (*er == NULL)
+ return 1;
+
+ if (*t == '\"')
+ {
+ if (get_string (&t, &(**er).m_text))
+ {
+ error_destroy (er);
+ return 1;
+ }
+ eat_spaces (&t);
+ }
+ else
+ {
+ if (get_identifier (&t, &temp))
+ {
+ error_destroy (er);
+ return 1;
+ }
+ eat_spaces (&t);
+
+ if (map_str_find (&maps, temp, &(**er).m_text))
+ {
+ mem_free ((void **) (void *) &temp);
+ error_destroy (er);
+ return 1;
+ }
+
+ mem_free ((void **) (void *) &temp);
+ }
+
+ /* try to extract "token" from "...$token$..." */
+ {
+ byte *processed = NULL;
+ unsigned int len = 0, i = 0;
+
+ if (string_grow (&processed, &len, '\0'))
+ {
+ error_destroy (er);
+ return 1;
+ }
+
+ while (i < str_length ((**er).m_text))
+ {
+ /* check if the dollar sign is repeated - if so skip it */
+ if ((**er).m_text[i] == '$' && (**er).m_text[i + 1] == '$')
+ {
+ if (string_grow (&processed, &len, '$'))
+ {
+ mem_free ((void **) (void *) &processed);
+ error_destroy (er);
+ return 1;
+ }
+
+ i += 2;
+ }
+ else if ((**er).m_text[i] != '$')
+ {
+ if (string_grow (&processed, &len, (**er).m_text[i]))
+ {
+ mem_free ((void **) (void *) &processed);
+ error_destroy (er);
+ return 1;
+ }
+
+ i++;
+ }
+ else
+ {
+ if (string_grow (&processed, &len, '$'))
+ {
+ mem_free ((void **) (void *) &processed);
+ error_destroy (er);
+ return 1;
+ }
+
+ {
+ /* length of token being extracted */
+ unsigned int tlen = 0;
+
+ if (string_grow (&(**er).m_token_name, &tlen, '\0'))
+ {
+ mem_free ((void **) (void *) &processed);
+ error_destroy (er);
+ return 1;
+ }
+
+ /* skip the dollar sign */
+ i++;
+
+ while ((**er).m_text[i] != '$')
+ {
+ if (string_grow (&(**er).m_token_name, &tlen, (**er).m_text[i]))
+ {
+ mem_free ((void **) (void *) &processed);
+ error_destroy (er);
+ return 1;
+ }
+
+ i++;
+ }
+
+ /* skip the dollar sign */
+ i++;
+ }
+ }
+ }
+
+ mem_free ((void **) &(**er).m_text);
+ (**er).m_text = processed;
+ }
+
+ *text = t;
+ return 0;
+}
+
+/*
+ returns 0 on success,
+ returns 1 otherwise,
+*/
+static int get_emits (const byte **text, emit **em, map_byte *mapb)
+{
+ const byte *t = *text;
+ byte *temp = NULL;
+ emit *e = NULL;
+ emit_dest dest;
+
+ if (*t != '.')
+ return 0;
+
+ t++;
+ if (get_identifier (&t, &temp))
+ return 1;
+ eat_spaces (&t);
+
+ /* .emit */
+ if (str_equal ((byte *) "emit", temp))
+ dest = ed_output;
+ /* .load */
+ else if (str_equal ((byte *) "load", temp))
+ dest = ed_regbyte;
+ else
+ {
+ mem_free ((void **) (void *) &temp);
+ return 0;
+ }
+
+ mem_free ((void **) (void *) &temp);
+
+ emit_create (&e);
+ if (e == NULL)
+ return 1;
+
+ e->m_emit_dest = dest;
+
+ if (dest == ed_regbyte)
+ {
+ if (get_identifier (&t, &e->m_regname))
+ {
+ emit_destroy (&e);
+ return 1;
+ }
+ eat_spaces (&t);
+ }
+
+ /* 0xNN */
+ if (*t == '0' && (t[1] == 'x' || t[1] == 'X'))
+ {
+ t += 2;
+ e->m_byte = (byte) hex_convert (&t);
+
+ e->m_emit_type = et_byte;
+ }
+ /* NNN */
+ else if (*t >= '0' && *t <= '9')
+ {
+ e->m_byte = (byte) dec_convert (&t);
+
+ e->m_emit_type = et_byte;
+ }
+ /* * */
+ else if (*t == '*')
+ {
+ t++;
+
+ e->m_emit_type = et_stream;
+ }
+ /* $ */
+ else if (*t == '$')
+ {
+ t++;
+
+ e->m_emit_type = et_position;
+ }
+ /* 'c' */
+ else if (*t == '\'')
+ {
+ if (get_string (&t, &temp))
+ {
+ emit_destroy (&e);
+ return 1;
+ }
+ e->m_byte = (byte) temp[0];
+
+ mem_free ((void **) (void *) &temp);
+
+ e->m_emit_type = et_byte;
+ }
+ else
+ {
+ if (get_identifier (&t, &temp))
+ {
+ emit_destroy (&e);
+ return 1;
+ }
+
+ if (map_byte_find (&mapb, temp, &e->m_byte))
+ {
+ mem_free ((void **) (void *) &temp);
+ emit_destroy (&e);
+ return 1;
+ }
+
+ mem_free ((void **) (void *) &temp);
+
+ e->m_emit_type = et_byte;
+ }
+
+ eat_spaces (&t);
+
+ if (get_emits (&t, &e->m_next, mapb))
+ {
+ emit_destroy (&e);
+ return 1;
+ }
+
+ *text = t;
+ *em = e;
+ return 0;
+}
+
+/*
+ returns 0 on success,
+ returns 1 otherwise,
+*/
+static int get_spec (const byte **text, spec **sp, map_str *maps, map_byte *mapb)
+{
+ const byte *t = *text;
+ spec *s = NULL;
+
+ spec_create (&s);
+ if (s == NULL)
+ return 1;
+
+ /* first - read optional .if statement */
+ if (*t == '.')
+ {
+ const byte *u = t;
+ byte *keyword = NULL;
+
+ /* skip the dot */
+ u++;
+
+ if (get_identifier (&u, &keyword))
+ {
+ spec_destroy (&s);
+ return 1;
+ }
+
+ /* .if */
+ if (str_equal ((byte *) "if", keyword))
+ {
+ cond_create (&s->m_cond);
+ if (s->m_cond == NULL)
+ {
+ spec_destroy (&s);
+ return 1;
+ }
+
+ /* skip the left paren */
+ eat_spaces (&u);
+ u++;
+
+ /* get the left operand */
+ eat_spaces (&u);
+ if (get_identifier (&u, &s->m_cond->m_operands[0].m_regname))
+ {
+ spec_destroy (&s);
+ return 1;
+ }
+ s->m_cond->m_operands[0].m_type = cot_regbyte;
+
+ /* get the operator (!= or ==) */
+ eat_spaces (&u);
+ if (*u == '!')
+ s->m_cond->m_type = ct_not_equal;
+ else
+ s->m_cond->m_type = ct_equal;
+ u += 2;
+ eat_spaces (&u);
+
+ if (u[0] == '0' && (u[1] == 'x' || u[1] == 'X'))
+ {
+ /* skip the 0x prefix */
+ u += 2;
+
+ /* get the right operand */
+ s->m_cond->m_operands[1].m_byte = hex_convert (&u);
+ s->m_cond->m_operands[1].m_type = cot_byte;
+ }
+ else /*if (*u >= '0' && *u <= '9')*/
+ {
+ /* get the right operand */
+ s->m_cond->m_operands[1].m_byte = dec_convert (&u);
+ s->m_cond->m_operands[1].m_type = cot_byte;
+ }
+
+ /* skip the right paren */
+ eat_spaces (&u);
+ u++;
+
+ eat_spaces (&u);
+
+ t = u;
+ }
+
+ mem_free ((void **) (void *) &keyword);
+ }
+
+ if (*t == '\'')
+ {
+ byte *temp = NULL;
+
+ if (get_string (&t, &temp))
+ {
+ spec_destroy (&s);
+ return 1;
+ }
+ eat_spaces (&t);
+
+ if (*t == '-')
+ {
+ byte *temp2 = NULL;
+
+ /* skip the '-' character */
+ t++;
+ eat_spaces (&t);
+
+ if (get_string (&t, &temp2))
+ {
+ mem_free ((void **) (void *) &temp);
+ spec_destroy (&s);
+ return 1;
+ }
+ eat_spaces (&t);
+
+ s->m_spec_type = st_byte_range;
+ s->m_byte[0] = *temp;
+ s->m_byte[1] = *temp2;
+
+ mem_free ((void **) (void *) &temp2);
+ }
+ else
+ {
+ s->m_spec_type = st_byte;
+ *s->m_byte = *temp;
+ }
+
+ mem_free ((void **) (void *) &temp);
+ }
+ else if (*t == '"')
+ {
+ if (get_string (&t, &s->m_string))
+ {
+ spec_destroy (&s);
+ return 1;
+ }
+ eat_spaces (&t);
+
+ s->m_spec_type = st_string;
+ }
+ else if (*t == '.')
+ {
+ byte *keyword = NULL;
+
+ /* skip the dot */
+ t++;
+
+ if (get_identifier (&t, &keyword))
+ {
+ spec_destroy (&s);
+ return 1;
+ }
+ eat_spaces (&t);
+
+ /* .true */
+ if (str_equal ((byte *) "true", keyword))
+ {
+ s->m_spec_type = st_true;
+ }
+ /* .false */
+ else if (str_equal ((byte *) "false", keyword))
+ {
+ s->m_spec_type = st_false;
+ }
+ /* .debug */
+ else if (str_equal ((byte *) "debug", keyword))
+ {
+ s->m_spec_type = st_debug;
+ }
+ /* .loop */
+ else if (str_equal ((byte *) "loop", keyword))
+ {
+ if (get_identifier (&t, &s->m_string))
+ {
+ mem_free ((void **) (void *) &keyword);
+ spec_destroy (&s);
+ return 1;
+ }
+ eat_spaces (&t);
+
+ s->m_spec_type = st_identifier_loop;
+ }
+ mem_free ((void **) (void *) &keyword);
+ }
+ else
+ {
+ if (get_identifier (&t, &s->m_string))
+ {
+ spec_destroy (&s);
+ return 1;
+ }
+ eat_spaces (&t);
+
+ s->m_spec_type = st_identifier;
+ }
+
+ if (get_error (&t, &s->m_errtext, maps))
+ {
+ spec_destroy (&s);
+ return 1;
+ }
+
+ if (get_emits (&t, &s->m_emits, mapb))
+ {
+ spec_destroy (&s);
+ return 1;
+ }
+
+ *text = t;
+ *sp = s;
+ return 0;
+}
+
+/*
+ returns 0 on success,
+ returns 1 otherwise,
+*/
+static int get_rule (const byte **text, rule **ru, map_str *maps, map_byte *mapb)
+{
+ const byte *t = *text;
+ rule *r = NULL;
+
+ rule_create (&r);
+ if (r == NULL)
+ return 1;
+
+ if (get_spec (&t, &r->m_specs, maps, mapb))
+ {
+ rule_destroy (&r);
+ return 1;
+ }
+
+ while (*t != ';')
+ {
+ byte *op = NULL;
+ spec *sp = NULL;
+
+ /* skip the dot that precedes "and" or "or" */
+ t++;
+
+ /* read "and" or "or" keyword */
+ if (get_identifier (&t, &op))
+ {
+ rule_destroy (&r);
+ return 1;
+ }
+ eat_spaces (&t);
+
+ if (r->m_oper == op_none)
+ {
+ /* .and */
+ if (str_equal ((byte *) "and", op))
+ r->m_oper = op_and;
+ /* .or */
+ else
+ r->m_oper = op_or;
+ }
+
+ mem_free ((void **) (void *) &op);
+
+ if (get_spec (&t, &sp, maps, mapb))
+ {
+ rule_destroy (&r);
+ return 1;
+ }
+
+ spec_append (&r->m_specs, sp);
+ }
+
+ /* skip the semicolon */
+ t++;
+ eat_spaces (&t);
+
+ *text = t;
+ *ru = r;
+ return 0;
+}
+
+/*
+ returns 0 on success,
+ returns 1 otherwise,
+*/
+static int update_dependency (map_rule *mapr, byte *symbol, rule **ru)
+{
+ if (map_rule_find (&mapr, symbol, ru))
+ return 1;
+
+ (**ru).m_referenced = 1;
+
+ return 0;
+}
+
+/*
+ returns 0 on success,
+ returns 1 otherwise,
+*/
+static int update_dependencies (dict *di, map_rule *mapr, byte **syntax_symbol,
+ byte **string_symbol, map_byte *regbytes)
+{
+ rule *rulez = di->m_rulez;
+
+ /* update dependecies for the root and lexer symbols */
+ if (update_dependency (mapr, *syntax_symbol, &di->m_syntax) ||
+ (*string_symbol != NULL && update_dependency (mapr, *string_symbol, &di->m_string)))
+ return 1;
+
+ mem_free ((void **) syntax_symbol);
+ mem_free ((void **) string_symbol);
+
+ /* update dependecies for the rest of the rules */
+ while (rulez)
+ {
+ spec *sp = rulez->m_specs;
+
+ /* iterate through all the specifiers */
+ while (sp)
+ {
+ /* update dependency for identifier */
+ if (sp->m_spec_type == st_identifier || sp->m_spec_type == st_identifier_loop)
+ {
+ if (update_dependency (mapr, sp->m_string, &sp->m_rule))
+ return 1;
+
+ mem_free ((void **) &sp->m_string);
+ }
+
+ /* some errtexts reference to a rule */
+ if (sp->m_errtext && sp->m_errtext->m_token_name)
+ {
+ if (update_dependency (mapr, sp->m_errtext->m_token_name, &sp->m_errtext->m_token))
+ return 1;
+
+ mem_free ((void **) &sp->m_errtext->m_token_name);
+ }
+
+ /* update dependency for condition */
+ if (sp->m_cond)
+ {
+ int i;
+ for (i = 0; i < 2; i++)
+ if (sp->m_cond->m_operands[i].m_type == cot_regbyte)
+ {
+ sp->m_cond->m_operands[i].m_regbyte = map_byte_locate (&regbytes,
+ sp->m_cond->m_operands[i].m_regname);
+
+ if (sp->m_cond->m_operands[i].m_regbyte == NULL)
+ return 1;
+
+ mem_free ((void **) &sp->m_cond->m_operands[i].m_regname);
+ }
+ }
+
+ /* update dependency for all .load instructions */
+ if (sp->m_emits)
+ {
+ emit *em = sp->m_emits;
+ while (em != NULL)
+ {
+ if (em->m_emit_dest == ed_regbyte)
+ {
+ em->m_regbyte = map_byte_locate (&regbytes, em->m_regname);
+
+ if (em->m_regbyte == NULL)
+ return 1;
+
+ mem_free ((void **) &em->m_regname);
+ }
+
+ em = em->m_next;
+ }
+ }
+
+ sp = sp->next;
+ }
+
+ rulez = rulez->next;
+ }
+
+ /* check for unreferenced symbols */
+ rulez = di->m_rulez;
+ while (rulez != NULL)
+ {
+ if (!rulez->m_referenced)
+ {
+ map_rule *ma = mapr;
+ while (ma)
+ {
+ if (ma->data == rulez)
+ {
+ set_last_error (UNREFERENCED_IDENTIFIER, str_duplicate (ma->key), -1);
+ return 1;
+ }
+ ma = ma->next;
+ }
+ }
+ rulez = rulez->next;
+ }
+
+ return 0;
+}
+
+static int satisfies_condition (cond *co, regbyte_ctx *ctx)
+{
+ byte values[2];
+ int i;
+
+ if (co == NULL)
+ return 1;
+
+ for (i = 0; i < 2; i++)
+ switch (co->m_operands[i].m_type)
+ {
+ case cot_byte:
+ values[i] = co->m_operands[i].m_byte;
+ break;
+ case cot_regbyte:
+ values[i] = regbyte_ctx_extract (&ctx, co->m_operands[i].m_regbyte);
+ break;
+ }
+
+ switch (co->m_type)
+ {
+ case ct_equal:
+ return values[0] == values[1];
+ case ct_not_equal:
+ return values[0] != values[1];
+ }
+
+ return 0;
+}
+
+static void free_regbyte_ctx_stack (regbyte_ctx *top, regbyte_ctx *limit)
+{
+ while (top != limit)
+ {
+ regbyte_ctx *rbc = top->m_prev;
+ regbyte_ctx_destroy (&top);
+ top = rbc;
+ }
+}
+
+typedef enum match_result_
+{
+ mr_not_matched, /* the examined string does not match */
+ mr_matched, /* the examined string matches */
+ mr_error_raised, /* mr_not_matched + error has been raised */
+ mr_dont_emit, /* used by identifier loops only */
+ mr_internal_error /* an internal error has occured such as out of memory */
+} match_result;
+
+/*
+ This function does the main job. It parses the text and generates output data.
+*/
+static match_result match (dict *di, const byte *text, unsigned int *index, rule *ru, barray **ba,
+ int filtering_string, regbyte_ctx **rbc)
+{
+ unsigned int ind = *index;
+ match_result status = mr_not_matched;
+ spec *sp = ru->m_specs;
+ regbyte_ctx *ctx = *rbc;
+
+ /* for every specifier in the rule */
+ while (sp)
+ {
+ unsigned int i, len, save_ind = ind;
+ barray *array = NULL;
+
+ if (satisfies_condition (sp->m_cond, ctx))
+ {
+ switch (sp->m_spec_type)
+ {
+ case st_identifier:
+ barray_create (&array);
+ if (array == NULL)
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ return mr_internal_error;
+ }
+
+ status = match (di, text, &ind, sp->m_rule, &array, filtering_string, &ctx);
+
+ if (status == mr_internal_error)
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ barray_destroy (&array);
+ return mr_internal_error;
+ }
+ break;
+ case st_string:
+ len = str_length (sp->m_string);
+
+ /* prefilter the stream */
+ if (!filtering_string && di->m_string)
+ {
+ barray *ba;
+ unsigned int filter_index = 0;
+ match_result result;
+ regbyte_ctx *null_ctx = NULL;
+
+ barray_create (&ba);
+ if (ba == NULL)
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ return mr_internal_error;
+ }
+
+ result = match (di, text + ind, &filter_index, di->m_string, &ba, 1, &null_ctx);
+
+ if (result == mr_internal_error)
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ barray_destroy (&ba);
+ return mr_internal_error;
+ }
+
+ if (result != mr_matched)
+ {
+ barray_destroy (&ba);
+ status = mr_not_matched;
+ break;
+ }
+
+ barray_destroy (&ba);
+
+ if (filter_index != len || !str_equal_n (sp->m_string, text + ind, len))
+ {
+ status = mr_not_matched;
+ break;
+ }
+
+ status = mr_matched;
+ ind += len;
+ }
+ else
+ {
+ status = mr_matched;
+ for (i = 0; status == mr_matched && i < len; i++)
+ if (text[ind + i] != sp->m_string[i])
+ status = mr_not_matched;
+
+ if (status == mr_matched)
+ ind += len;
+ }
+ break;
+ case st_byte:
+ status = text[ind] == *sp->m_byte ? mr_matched : mr_not_matched;
+ if (status == mr_matched)
+ ind++;
+ break;
+ case st_byte_range:
+ status = (text[ind] >= sp->m_byte[0] && text[ind] <= sp->m_byte[1]) ?
+ mr_matched : mr_not_matched;
+ if (status == mr_matched)
+ ind++;
+ break;
+ case st_true:
+ status = mr_matched;
+ break;
+ case st_false:
+ status = mr_not_matched;
+ break;
+ case st_debug:
+ status = ru->m_oper == op_and ? mr_matched : mr_not_matched;
+ break;
+ case st_identifier_loop:
+ barray_create (&array);
+ if (array == NULL)
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ return mr_internal_error;
+ }
+
+ status = mr_dont_emit;
+ for (;;)
+ {
+ match_result result;
+
+ save_ind = ind;
+ result = match (di, text, &ind, sp->m_rule, &array, filtering_string, &ctx);
+
+ if (result == mr_error_raised)
+ {
+ status = result;
+ break;
+ }
+ else if (result == mr_matched)
+ {
+ if (barray_push (ba, sp->m_emits, text[ind - 1], save_ind, &ctx) ||
+ barray_append (ba, &array))
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ barray_destroy (&array);
+ return mr_internal_error;
+ }
+ barray_destroy (&array);
+ barray_create (&array);
+ if (array == NULL)
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ return mr_internal_error;
+ }
+ }
+ else if (result == mr_internal_error)
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ barray_destroy (&array);
+ return mr_internal_error;
+ }
+ else
+ break;
+ }
+ break;
+ }
+ }
+ else
+ {
+ status = mr_not_matched;
+ }
+
+ if (status == mr_error_raised)
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ barray_destroy (&array);
+
+ return mr_error_raised;
+ }
+
+ if (ru->m_oper == op_and && status != mr_matched && status != mr_dont_emit)
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ barray_destroy (&array);
+
+ if (sp->m_errtext)
+ {
+ set_last_error (sp->m_errtext->m_text, error_get_token (sp->m_errtext, di, text,
+ ind), ind);
+
+ return mr_error_raised;
+ }
+
+ return mr_not_matched;
+ }
+
+ if (status == mr_matched)
+ {
+ if (sp->m_emits)
+ if (barray_push (ba, sp->m_emits, text[ind - 1], save_ind, &ctx))
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ barray_destroy (&array);
+ return mr_internal_error;
+ }
+
+ if (array)
+ if (barray_append (ba, &array))
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ barray_destroy (&array);
+ return mr_internal_error;
+ }
+ }
+
+ barray_destroy (&array);
+
+ /* if the rule operator is a logical or, we pick up the first matching specifier */
+ if (ru->m_oper == op_or && (status == mr_matched || status == mr_dont_emit))
+ {
+ *index = ind;
+ *rbc = ctx;
+ return mr_matched;
+ }
+
+ sp = sp->next;
+ }
+
+ /* everything went fine - all specifiers match up */
+ if (ru->m_oper == op_and && (status == mr_matched || status == mr_dont_emit))
+ {
+ *index = ind;
+ *rbc = ctx;
+ return mr_matched;
+ }
+
+ free_regbyte_ctx_stack (ctx, *rbc);
+ return mr_not_matched;
+}
+
+static match_result fast_match (dict *di, const byte *text, unsigned int *index, rule *ru, int *_PP, bytepool *_BP,
+ int filtering_string, regbyte_ctx **rbc)
+{
+ unsigned int ind = *index;
+ int _P = filtering_string ? 0 : *_PP;
+ int _P2;
+ match_result status = mr_not_matched;
+ spec *sp = ru->m_specs;
+ regbyte_ctx *ctx = *rbc;
+
+ /* for every specifier in the rule */
+ while (sp)
+ {
+ unsigned int i, len, save_ind = ind;
+
+ _P2 = _P + (sp->m_emits ? emit_size (sp->m_emits) : 0);
+ if (bytepool_reserve (_BP, _P2))
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ return mr_internal_error;
+ }
+
+ if (satisfies_condition (sp->m_cond, ctx))
+ {
+ switch (sp->m_spec_type)
+ {
+ case st_identifier:
+ status = fast_match (di, text, &ind, sp->m_rule, &_P2, _BP, filtering_string, &ctx);
+
+ if (status == mr_internal_error)
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ return mr_internal_error;
+ }
+ break;
+ case st_string:
+ len = str_length (sp->m_string);
+
+ /* prefilter the stream */
+ if (!filtering_string && di->m_string)
+ {
+ unsigned int filter_index = 0;
+ match_result result;
+ regbyte_ctx *null_ctx = NULL;
+
+ result = fast_match (di, text + ind, &filter_index, di->m_string, NULL, _BP, 1, &null_ctx);
+
+ if (result == mr_internal_error)
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ return mr_internal_error;
+ }
+
+ if (result != mr_matched)
+ {
+ status = mr_not_matched;
+ break;
+ }
+
+ if (filter_index != len || !str_equal_n (sp->m_string, text + ind, len))
+ {
+ status = mr_not_matched;
+ break;
+ }
+
+ status = mr_matched;
+ ind += len;
+ }
+ else
+ {
+ status = mr_matched;
+ for (i = 0; status == mr_matched && i < len; i++)
+ if (text[ind + i] != sp->m_string[i])
+ status = mr_not_matched;
+
+ if (status == mr_matched)
+ ind += len;
+ }
+ break;
+ case st_byte:
+ status = text[ind] == *sp->m_byte ? mr_matched : mr_not_matched;
+ if (status == mr_matched)
+ ind++;
+ break;
+ case st_byte_range:
+ status = (text[ind] >= sp->m_byte[0] && text[ind] <= sp->m_byte[1]) ?
+ mr_matched : mr_not_matched;
+ if (status == mr_matched)
+ ind++;
+ break;
+ case st_true:
+ status = mr_matched;
+ break;
+ case st_false:
+ status = mr_not_matched;
+ break;
+ case st_debug:
+ status = ru->m_oper == op_and ? mr_matched : mr_not_matched;
+ break;
+ case st_identifier_loop:
+ status = mr_dont_emit;
+ for (;;)
+ {
+ match_result result;
+
+ save_ind = ind;
+ result = fast_match (di, text, &ind, sp->m_rule, &_P2, _BP, filtering_string, &ctx);
+
+ if (result == mr_error_raised)
+ {
+ status = result;
+ break;
+ }
+ else if (result == mr_matched)
+ {
+ if (!filtering_string)
+ {
+ if (sp->m_emits != NULL)
+ {
+ if (emit_push (sp->m_emits, _BP->_F + _P, text[ind - 1], save_ind, &ctx))
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ return mr_internal_error;
+ }
+ }
+
+ _P = _P2;
+ _P2 += sp->m_emits ? emit_size (sp->m_emits) : 0;
+ if (bytepool_reserve (_BP, _P2))
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ return mr_internal_error;
+ }
+ }
+ }
+ else if (result == mr_internal_error)
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ return mr_internal_error;
+ }
+ else
+ break;
+ }
+ break;
+ }
+ }
+ else
+ {
+ status = mr_not_matched;
+ }
+
+ if (status == mr_error_raised)
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+
+ return mr_error_raised;
+ }
+
+ if (ru->m_oper == op_and && status != mr_matched && status != mr_dont_emit)
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+
+ if (sp->m_errtext)
+ {
+ set_last_error (sp->m_errtext->m_text, error_get_token (sp->m_errtext, di, text,
+ ind), ind);
+
+ return mr_error_raised;
+ }
+
+ return mr_not_matched;
+ }
+
+ if (status == mr_matched)
+ {
+ if (sp->m_emits != NULL)
+ if (emit_push (sp->m_emits, _BP->_F + _P, text[ind - 1], save_ind, &ctx))
+ {
+ free_regbyte_ctx_stack (ctx, *rbc);
+ return mr_internal_error;
+ }
+
+ _P = _P2;
+ }
+
+ /* if the rule operator is a logical or, we pick up the first matching specifier */
+ if (ru->m_oper == op_or && (status == mr_matched || status == mr_dont_emit))
+ {
+ *index = ind;
+ *rbc = ctx;
+ if (!filtering_string)
+ *_PP = _P;
+ return mr_matched;
+ }
+
+ sp = sp->next;
+ }
+
+ /* everything went fine - all specifiers match up */
+ if (ru->m_oper == op_and && (status == mr_matched || status == mr_dont_emit))
+ {
+ *index = ind;
+ *rbc = ctx;
+ if (!filtering_string)
+ *_PP = _P;
+ return mr_matched;
+ }
+
+ free_regbyte_ctx_stack (ctx, *rbc);
+ return mr_not_matched;
+}
+
+static byte *error_get_token (error *er, dict *di, const byte *text, unsigned int ind)
+{
+ byte *str = NULL;
+
+ if (er->m_token)
+ {
+ barray *ba;
+ unsigned int filter_index = 0;
+ regbyte_ctx *ctx = NULL;
+
+ barray_create (&ba);
+ if (ba != NULL)
+ {
+ if (match (di, text + ind, &filter_index, er->m_token, &ba, 0, &ctx) == mr_matched &&
+ filter_index)
+ {
+ str = (byte *) mem_alloc (filter_index + 1);
+ if (str != NULL)
+ {
+ str_copy_n (str, text + ind, filter_index);
+ str[filter_index] = '\0';
+ }
+ }
+ barray_destroy (&ba);
+ }
+ }
+
+ return str;
+}
+
+typedef struct grammar_load_state_
+{
+ dict *di;
+ byte *syntax_symbol;
+ byte *string_symbol;
+ map_str *maps;
+ map_byte *mapb;
+ map_rule *mapr;
+} grammar_load_state;
+
+static void grammar_load_state_create (grammar_load_state **gr)
+{
+ *gr = (grammar_load_state *) mem_alloc (sizeof (grammar_load_state));
+ if (*gr)
+ {
+ (**gr).di = NULL;
+ (**gr).syntax_symbol = NULL;
+ (**gr).string_symbol = NULL;
+ (**gr).maps = NULL;
+ (**gr).mapb = NULL;
+ (**gr).mapr = NULL;
+ }
+}
+
+static void grammar_load_state_destroy (grammar_load_state **gr)
+{
+ if (*gr)
+ {
+ dict_destroy (&(**gr).di);
+ mem_free ((void **) &(**gr).syntax_symbol);
+ mem_free ((void **) &(**gr).string_symbol);
+ map_str_destroy (&(**gr).maps);
+ map_byte_destroy (&(**gr).mapb);
+ map_rule_destroy (&(**gr).mapr);
+ mem_free ((void **) gr);
+ }
+}
+
+/*
+ the API
+*/
+
+grammar grammar_load_from_text (const byte *text)
+{
+ grammar_load_state *g = NULL;
+ grammar id = 0;
+
+ clear_last_error ();
+
+ grammar_load_state_create (&g);
+ if (g == NULL)
+ return 0;
+
+ dict_create (&g->di);
+ if (g->di == NULL)
+ {
+ grammar_load_state_destroy (&g);
+ return 0;
+ }
+
+ eat_spaces (&text);
+
+ /* skip ".syntax" keyword */
+ text += 7;
+ eat_spaces (&text);
+
+ /* retrieve root symbol */
+ if (get_identifier (&text, &g->syntax_symbol))
+ {
+ grammar_load_state_destroy (&g);
+ return 0;
+ }
+ eat_spaces (&text);
+
+ /* skip semicolon */
+ text++;
+ eat_spaces (&text);
+
+ while (*text)
+ {
+ byte *symbol = NULL;
+ int is_dot = *text == '.';
+
+ if (is_dot)
+ text++;
+
+ if (get_identifier (&text, &symbol))
+ {
+ grammar_load_state_destroy (&g);
+ return 0;
+ }
+ eat_spaces (&text);
+
+ /* .emtcode */
+ if (is_dot && str_equal (symbol, (byte *) "emtcode"))
+ {
+ map_byte *ma = NULL;
+
+ mem_free ((void **) (void *) &symbol);
+
+ if (get_emtcode (&text, &ma))
+ {
+ grammar_load_state_destroy (&g);
+ return 0;
+ }
+
+ map_byte_append (&g->mapb, ma);
+ }
+ /* .regbyte */
+ else if (is_dot && str_equal (symbol, (byte *) "regbyte"))
+ {
+ map_byte *ma = NULL;
+
+ mem_free ((void **) (void *) &symbol);
+
+ if (get_regbyte (&text, &ma))
+ {
+ grammar_load_state_destroy (&g);
+ return 0;
+ }
+
+ map_byte_append (&g->di->m_regbytes, ma);
+ }
+ /* .errtext */
+ else if (is_dot && str_equal (symbol, (byte *) "errtext"))
+ {
+ map_str *ma = NULL;
+
+ mem_free ((void **) (void *) &symbol);
+
+ if (get_errtext (&text, &ma))
+ {
+ grammar_load_state_destroy (&g);
+ return 0;
+ }
+
+ map_str_append (&g->maps, ma);
+ }
+ /* .string */
+ else if (is_dot && str_equal (symbol, (byte *) "string"))
+ {
+ mem_free ((void **) (void *) &symbol);
+
+ if (g->di->m_string != NULL)
+ {
+ grammar_load_state_destroy (&g);
+ return 0;
+ }
+
+ if (get_identifier (&text, &g->string_symbol))
+ {
+ grammar_load_state_destroy (&g);
+ return 0;
+ }
+
+ /* skip semicolon */
+ eat_spaces (&text);
+ text++;
+ eat_spaces (&text);
+ }
+ else
+ {
+ rule *ru = NULL;
+ map_rule *ma = NULL;
+
+ if (get_rule (&text, &ru, g->maps, g->mapb))
+ {
+ grammar_load_state_destroy (&g);
+ return 0;
+ }
+
+ rule_append (&g->di->m_rulez, ru);
+
+ /* if a rule consist of only one specifier, give it an ".and" operator */
+ if (ru->m_oper == op_none)
+ ru->m_oper = op_and;
+
+ map_rule_create (&ma);
+ if (ma == NULL)
+ {
+ grammar_load_state_destroy (&g);
+ return 0;
+ }
+
+ ma->key = symbol;
+ ma->data = ru;
+ map_rule_append (&g->mapr, ma);
+ }
+ }
+
+ if (update_dependencies (g->di, g->mapr, &g->syntax_symbol, &g->string_symbol,
+ g->di->m_regbytes))
+ {
+ grammar_load_state_destroy (&g);
+ return 0;
+ }
+
+ dict_append (&g_dicts, g->di);
+ id = g->di->m_id;
+ g->di = NULL;
+
+ grammar_load_state_destroy (&g);
+
+ return id;
+}
+
+int grammar_set_reg8 (grammar id, const byte *name, byte value)
+{
+ dict *di = NULL;
+ map_byte *reg = NULL;
+
+ clear_last_error ();
+
+ dict_find (&g_dicts, id, &di);
+ if (di == NULL)
+ {
+ set_last_error (INVALID_GRAMMAR_ID, NULL, -1);
+ return 0;
+ }
+
+ reg = map_byte_locate (&di->m_regbytes, name);
+ if (reg == NULL)
+ {
+ set_last_error (INVALID_REGISTER_NAME, str_duplicate (name), -1);
+ return 0;
+ }
+
+ reg->data = value;
+ return 1;
+}
+
+/*
+ internal checking function used by both grammar_check and grammar_fast_check functions
+*/
+static int _grammar_check (grammar id, const byte *text, byte **prod, unsigned int *size,
+ unsigned int estimate_prod_size, int use_fast_path)
+{
+ dict *di = NULL;
+ unsigned int index = 0;
+
+ clear_last_error ();
+
+ dict_find (&g_dicts, id, &di);
+ if (di == NULL)
+ {
+ set_last_error (INVALID_GRAMMAR_ID, NULL, -1);
+ return 0;
+ }
+
+ *prod = NULL;
+ *size = 0;
+
+ if (use_fast_path)
+ {
+ regbyte_ctx *rbc = NULL;
+ bytepool *bp = NULL;
+ int _P = 0;
+
+ bytepool_create (&bp, estimate_prod_size);
+ if (bp == NULL)
+ return 0;
+
+ if (fast_match (di, text, &index, di->m_syntax, &_P, bp, 0, &rbc) != mr_matched)
+ {
+ bytepool_destroy (&bp);
+ free_regbyte_ctx_stack (rbc, NULL);
+ return 0;
+ }
+
+ free_regbyte_ctx_stack (rbc, NULL);
+
+ *prod = bp->_F;
+ *size = _P;
+ bp->_F = NULL;
+ bytepool_destroy (&bp);
+ }
+ else
+ {
+ regbyte_ctx *rbc = NULL;
+ barray *ba = NULL;
+
+ barray_create (&ba);
+ if (ba == NULL)
+ return 0;
+
+ if (match (di, text, &index, di->m_syntax, &ba, 0, &rbc) != mr_matched)
+ {
+ barray_destroy (&ba);
+ free_regbyte_ctx_stack (rbc, NULL);
+ return 0;
+ }
+
+ free_regbyte_ctx_stack (rbc, NULL);
+
+ *prod = (byte *) mem_alloc (ba->len * sizeof (byte));
+ if (*prod == NULL)
+ {
+ barray_destroy (&ba);
+ return 0;
+ }
+
+ mem_copy (*prod, ba->data, ba->len * sizeof (byte));
+ *size = ba->len;
+ barray_destroy (&ba);
+ }
+
+ return 1;
+}
+
+int grammar_check (grammar id, const byte *text, byte **prod, unsigned int *size)
+{
+ return _grammar_check (id, text, prod, size, 0, 0);
+}
+
+int grammar_fast_check (grammar id, const byte *text, byte **prod, unsigned int *size,
+ unsigned int estimate_prod_size)
+{
+ return _grammar_check (id, text, prod, size, estimate_prod_size, 1);
+}
+
+int grammar_destroy (grammar id)
+{
+ dict **di = &g_dicts;
+
+ clear_last_error ();
+
+ while (*di != NULL)
+ {
+ if ((**di).m_id == id)
+ {
+ dict *tmp = *di;
+ *di = (**di).next;
+ dict_destroy (&tmp);
+ return 1;
+ }
+
+ di = &(**di).next;
+ }
+
+ set_last_error (INVALID_GRAMMAR_ID, NULL, -1);
+ return 0;
+}
+
+static void append_character (const char x, byte *text, int *dots_made, int *len, int size)
+{
+ if (*dots_made == 0)
+ {
+ if (*len < size - 1)
+ {
+ text[(*len)++] = x;
+ text[*len] = '\0';
+ }
+ else
+ {
+ int i;
+ for (i = 0; i < 3; i++)
+ if (--(*len) >= 0)
+ text[*len] = '.';
+ *dots_made = 1;
+ }
+ }
+}
+
+void grammar_get_last_error (byte *text, unsigned int size, int *pos)
+{
+ int len = 0, dots_made = 0;
+ const byte *p = error_message;
+
+ *text = '\0';
+
+ if (p)
+ {
+ while (*p)
+ {
+ if (*p == '$')
+ {
+ const byte *r = error_param;
+
+ while (*r)
+ {
+ append_character (*r++, text, &dots_made, &len, (int) size);
+ }
+
+ p++;
+ }
+ else
+ {
+ append_character (*p++, text, &dots_made, &len, size);
+ }
+ }
+ }
+
+ *pos = error_position;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar.h b/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar.h
new file mode 100644
index 000000000..591e38aef
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar.h
@@ -0,0 +1,103 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.2
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef GRAMMAR_H
+#define GRAMMAR_H
+
+
+#ifndef GRAMMAR_PORT_INCLUDE
+#error Do not include this file directly, include your grammar_XXX.h instead
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void grammar_alloc_free (void *);
+void *grammar_alloc_malloc (size_t);
+void *grammar_alloc_realloc (void *, size_t, size_t);
+void *grammar_memory_copy (void *, const void *, size_t);
+int grammar_string_compare (const byte *, const byte *);
+int grammar_string_compare_n (const byte *, const byte *, size_t);
+byte *grammar_string_copy (byte *, const byte *);
+byte *grammar_string_copy_n (byte *, const byte *, size_t);
+byte *grammar_string_duplicate (const byte *);
+unsigned int grammar_string_length (const byte *);
+
+/*
+ loads grammar script from null-terminated ASCII <text>
+ returns unique grammar id to grammar object
+ returns 0 if an error occurs (call grammar_get_last_error to retrieve the error text)
+*/
+grammar grammar_load_from_text (const byte *text);
+
+/*
+ sets a new <value> to a register <name> for grammar <id>
+ returns 0 on error (call grammar_get_last_error to retrieve the error text)
+ returns 1 on success
+*/
+int grammar_set_reg8 (grammar id, const byte *name, byte value);
+
+/*
+ this function is obsolete, use only for debugging purposes
+
+ checks if a null-terminated <text> matches given grammar <id>
+ returns 0 on error (call grammar_get_last_error to retrieve the error text)
+ returns 1 on success, the <prod> points to newly allocated buffer with production and <size>
+ is filled with the production size
+ call grammar_alloc_free to free the memory block pointed by <prod>
+*/
+int grammar_check (grammar id, const byte *text, byte **prod, unsigned int *size);
+
+/*
+ does the same what grammar_check does but much more (approx. 4 times) faster
+ use this function instead of grammar_check
+ <estimate_prod_size> is a hint - the initial production buffer size will be of this size,
+ but if more room is needed it will be safely resized; set it to 0x1000 or so
+*/
+int grammar_fast_check (grammar id, const byte *text, byte **prod, unsigned int *size,
+ unsigned int estimate_prod_size);
+
+/*
+ destroys grammar object identified by <id>
+ returns 0 on error (call grammar_get_last_error to retrieve the error text)
+ returns 1 on success
+*/
+int grammar_destroy (grammar id);
+
+/*
+ retrieves last grammar error reported either by grammar_load_from_text, grammar_check
+ or grammar_destroy
+ the user allocated <text> buffer receives error description, <pos> points to error position,
+ <size> is the size of the text buffer to fill in - it must be at least 4 bytes long,
+*/
+void grammar_get_last_error (byte *text, unsigned int size, int *pos);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar.syn b/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar.syn
new file mode 100644
index 000000000..5d99f65bf
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar.syn
@@ -0,0 +1,567 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.2
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+ /**
+ * \file grammar.syn
+ * syntax of .syn script - used to validate other syntax files
+ * \author Michal Krol
+ */
+
+.syntax grammar;
+
+/* declaration */
+.emtcode DECLARATION_END 0
+.emtcode DECLARATION_EMITCODE 1
+.emtcode DECLARATION_ERRORTEXT 2
+.emtcode DECLARATION_REGBYTE 3
+.emtcode DECLARATION_LEXER 4
+.emtcode DECLARATION_RULE 5
+
+/* specifier */
+.emtcode SPECIFIER_END 0
+.emtcode SPECIFIER_AND_TAG 1
+.emtcode SPECIFIER_OR_TAG 2
+.emtcode SPECIFIER_CHARACTER_RANGE 3
+.emtcode SPECIFIER_CHARACTER 4
+.emtcode SPECIFIER_STRING 5
+.emtcode SPECIFIER_IDENTIFIER 6
+.emtcode SPECIFIER_TRUE 7
+.emtcode SPECIFIER_FALSE 8
+.emtcode SPECIFIER_DEBUG 9
+
+/* identifier */
+.emtcode IDENTIFIER_SIMPLE 0
+.emtcode IDENTIFIER_LOOP 1
+
+/* error */
+.emtcode ERROR_NOT_PRESENT 0
+.emtcode ERROR_PRESENT 1
+
+/* emit */
+.emtcode EMIT_NULL 0
+.emtcode EMIT_INTEGER 1
+.emtcode EMIT_IDENTIFIER 2
+.emtcode EMIT_CHARACTER 3
+.emtcode EMIT_LAST_CHARACTER 4
+.emtcode EMIT_CURRENT_POSITION 5
+
+.errtext INVALID_GRAMMAR "internal error 2001: invalid grammar script"
+.errtext SYNTAX_EXPECTED "internal error 2002: '.syntax' keyword expected"
+.errtext IDENTIFIER_EXPECTED "internal error 2003: identifier expected"
+.errtext MISSING_SEMICOLON "internal error 2004: missing ';'"
+.errtext INTEGER_EXPECTED "internal error 2005: integer value expected"
+.errtext STRING_EXPECTED "internal error 2006: string expected"
+
+/*
+ <grammar> ::= ".syntax" <identifier> ";" <declaration_list>
+*/
+grammar
+ grammar_1 .error INVALID_GRAMMAR;
+grammar_1
+ optional_space .and ".syntax" .error SYNTAX_EXPECTED .and space .and identifier .and
+ semicolon .and declaration_list .and optional_space .and '\0' .emit DECLARATION_END;
+
+/*
+ <optional_space> ::= <space>
+ | ""
+*/
+optional_space
+ space .or .true;
+
+/*
+ <space> ::= <single_space> <single_space>*
+*/
+space
+ single_space .and .loop single_space;
+
+/*
+ <single_space> ::= <white_char>
+ | <comment_block>
+*/
+single_space
+ white_char .or comment_block;
+
+/*
+ <white_char> ::= " "
+ | "\t"
+ | "\n"
+ | "\r"
+*/
+white_char
+ ' ' .or '\t' .or '\n' .or '\r';
+
+/*
+ <comment_block> ::= "/" "*" <comment_rest>
+*/
+comment_block
+ '/' .and '*' .and comment_rest;
+
+/*
+ <comment_rest> ::= <comment_char_no_star>* <comment_end>
+ | <comment_char_no_star>* "*" <comment_rest>
+*/
+comment_rest
+ .loop comment_char_no_star .and comment_rest_1;
+comment_rest_1
+ comment_end .or comment_rest_2;
+comment_rest_2
+ '*' .and comment_rest;
+
+/*
+ <comment_char_no_star> ::= All ASCII characters except "*" and "\0"
+*/
+comment_char_no_star
+ '\x2B'-'\xFF' .or '\x01'-'\x29';
+
+/*
+ <comment_end> ::= "*" "/"
+*/
+comment_end
+ '*' .and '/';
+
+/*
+ <identifier> ::= <identifier>
+*/
+identifier
+ identifier_ne .error IDENTIFIER_EXPECTED;
+
+/*
+ <identifier_ne> ::= <first_idchar> <follow_idchar>*
+*/
+identifier_ne
+ first_idchar .emit * .and .loop follow_idchar .emit * .and .true .emit '\0';
+
+/*
+ <first_idchar> ::= "a"-"z"
+ | "A"-"Z"
+ | "_"
+*/
+first_idchar
+ 'a'-'z' .or 'A'-'Z' .or '_';
+
+/*
+ <follow_idchar> ::= <first_idchar>
+ | <digit_dec>
+*/
+follow_idchar
+ first_idchar .or digit_dec;
+
+/*
+ <digit_dec> ::= "0"-"9"
+*/
+digit_dec
+ '0'-'9';
+
+/*
+ <semicolon> ::= ";"
+*/
+semicolon
+ optional_space .and ';' .error MISSING_SEMICOLON .and optional_space;
+
+/*
+ <declaration_list> ::= <declaration>
+ | <declaration_list> <declaration>
+*/
+declaration_list
+ declaration .and .loop declaration;
+
+/*
+ <declaration> ::= <emitcode_definition>
+ | <errortext_definition>
+ | <lexer_definition>
+ | <rule_definition>
+*/
+declaration
+ emitcode_definition .emit DECLARATION_EMITCODE .or
+ errortext_definition .emit DECLARATION_ERRORTEXT .or
+ regbyte_definition .emit DECLARATION_REGBYTE .or
+ lexer_definition .emit DECLARATION_LEXER .or
+ rule_definition .emit DECLARATION_RULE;
+
+/*
+ <emitcode_definition> ::= ".emtcode" <identifier> <integer>
+*/
+emitcode_definition
+ ".emtcode" .and space .and identifier .and space .and integer .and space_or_null;
+
+/*
+ <integer> ::= <integer_ne>
+*/
+integer
+ integer_ne .error INTEGER_EXPECTED;
+
+/*
+ <integer_ne> ::= <hex_integer>
+ | <dec_integer>
+*/
+integer_ne
+ hex_integer .emit 0x10 .or dec_integer .emit 10;
+
+/*
+ <hex_integer> :: <hex_prefix> <digit_hex> <digit_hex>*
+*/
+hex_integer
+ hex_prefix .and digit_hex .emit * .and .loop digit_hex .emit * .and .true .emit '\0';
+
+/*
+ <hex_prefix> ::= "0x"
+ | "0X"
+*/
+hex_prefix
+ '0' .and hex_prefix_1;
+hex_prefix_1
+ 'x' .or 'X';
+
+/*
+ <digit_hex> ::= "0"-"9"
+ | "a"-"f"
+ | "A"-"F"
+*/
+digit_hex
+ '0'-'9' .or 'a'-'f' .or 'A'-'F';
+
+/*
+ <dec_integer> :: <digit_dec> <digit_dec>*
+*/
+dec_integer
+ digit_dec .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
+
+/*
+ <space_or_null> ::= <space>
+ | "\0"
+*/
+space_or_null
+ space .or '\0';
+
+/*
+ <errortext_definition> ::= ".errtext" <identifier> <string>
+*/
+errortext_definition
+ ".errtext" .and space .and identifier .and space .and string .and space_or_null;
+
+/*
+ <string> ::= <string_ne>
+*/
+string
+ string_ne .error STRING_EXPECTED;
+
+/*
+ <string_ne> ::= "\"" <string_char_double_quotes> "\""
+*/
+string_ne
+ '"' .and .loop string_char_double_quotes .and '"' .emit '\0';
+
+/*
+ <string_char_double_quotes> ::= <escape_sequence>
+ | <string_char>
+ | "\'"
+*/
+string_char_double_quotes
+ escape_sequence .or string_char .emit * .or '\'' .emit *;
+
+/*
+ <string_char> ::= All ASCII characters except "\'", "\"", "\n", "\r",
+ "\0" and "\\"
+*/
+string_char
+ '\x5D'-'\xFF' .or '\x28'-'\x5B' .or '\x23'-'\x26' .or '\x0E'-'\x21' .or '\x0B'-'\x0C' .or
+ '\x01'-'\x09';
+
+/*
+ <escape_sequence> ::= "\\" <escape_code>
+*/
+escape_sequence
+ '\\' .emit * .and escape_code;
+
+/*
+ <escape_code> ::= <simple_escape_code>
+ | <hex_escape_code>
+ | <oct_escape_code>
+*/
+escape_code
+ simple_escape_code .emit * .or hex_escape_code .or oct_escape_code;
+
+/*
+ <simple_escape_code> ::= "\'"
+ | "\""
+ | "?"
+ | "\\"
+ | "a"
+ | "b"
+ | "f"
+ | "n"
+ | "r"
+ | "t"
+ | "v"
+*/
+simple_escape_code
+ '\'' .or '"' .or '?' .or '\\' .or 'a' .or 'b' .or 'f' .or 'n' .or 'r' .or 't' .or 'v';
+
+/*
+ <hex_escape_code> ::= "x" <digit_hex> <digit_hex>*
+*/
+hex_escape_code
+ 'x' .emit * .and digit_hex .emit * .and .loop digit_hex .emit *;
+
+/*
+ <oct_escape_code> ::= <digit_oct> <optional_digit_oct> <optional_digit_oct>
+*/
+oct_escape_code
+ digit_oct .emit * .and optional_digit_oct .and optional_digit_oct;
+
+/*
+ <digit_oct> ::= "0"-"7"
+*/
+digit_oct
+ '0'-'7';
+
+/*
+ <optional_digit_oct> ::= <digit_oct>
+ | ""
+*/
+optional_digit_oct
+ digit_oct .emit * .or .true;
+
+/*
+ <regbyte_definition> ::= ".regbyte" <identifier> <integer>
+*/
+regbyte_definition
+ ".regbyte" .and space .and identifier .and space .and integer .and space_or_null;
+
+/*
+ <lexer_definition> ::= ".string" <identifier> ";"
+*/
+lexer_definition
+ ".string" .and space .and identifier .and semicolon;
+
+/*
+ <rule_definition> ::= <identifier_ne> <definition>
+*/
+rule_definition
+ identifier_ne .and space .and definition;
+
+/*
+ <definition> ::= <specifier> <optional_specifiers_and_or> ";"
+*/
+definition
+ specifier .and optional_specifiers_and_or .and semicolon .emit SPECIFIER_END;
+
+/*
+ <optional_specifiers_and_or> ::= <and_specifiers>
+ | <or_specifiers>
+ | ""
+*/
+optional_specifiers_and_or
+ and_specifiers .emit SPECIFIER_AND_TAG .or or_specifiers .emit SPECIFIER_OR_TAG .or .true;
+
+/*
+ <specifier> ::= <specifier_condition> <specifier_rule>
+*/
+specifier
+ specifier_condition .and optional_space .and specifier_rule;
+
+/*
+ <specifier_condition> ::= ".if" "(" <left_operand> <operator> <right_operand> ")"
+*/
+specifier_condition
+ specifier_condition_1 .or .true;
+specifier_condition_1
+ ".if" .and optional_space .and '(' .and optional_space .and left_operand .and operator .and
+ right_operand .and optional_space .and ')';
+
+/*
+ <left_operand> ::= <identifier>
+*/
+left_operand
+ identifier;
+
+/*
+ <operator> ::= "!="
+ | "=="
+*/
+operator
+ operator_1 .or operator_2;
+operator_1
+ optional_space .and '!' .and '=' .and optional_space;
+operator_2
+ optional_space .and '=' .and '=' .and optional_space;
+
+/*
+ <right_operand> ::= <integer>
+*/
+right_operand
+ integer;
+
+/*
+ <specifier_rule> ::= <character_range> <optional_error> <emit>*
+ | <character> <optional_error> <emit>*
+ | <string> <optional_error> <emit>*
+ | ".true" <optional_error> <emit>*
+ | ".false" <optional_error> <emit>*
+ | ".debug" <optional_error> <emit>*
+ | <advanced_identifier> <optional_error> <emit>*
+*/
+specifier_rule
+ specifier_rule_1 .and optional_error .and .loop emit .and .true .emit EMIT_NULL;
+specifier_rule_1
+ character_range .emit SPECIFIER_CHARACTER_RANGE .or
+ character .emit SPECIFIER_CHARACTER .or
+ string_ne .emit SPECIFIER_STRING .or
+ ".true" .emit SPECIFIER_TRUE .or
+ ".false" .emit SPECIFIER_FALSE .or
+ ".debug" .emit SPECIFIER_DEBUG .or
+ advanced_identifier .emit SPECIFIER_IDENTIFIER;
+
+/*
+ <character> ::= "\'" <string_char_single_quotes "\'"
+*/
+character
+ '\'' .and string_char_single_quotes .and '\'' .emit '\0';
+
+/*
+ <string_char_single_quotes> ::= <escape_sequence>
+ | <string_char>
+ | "\""
+*/
+string_char_single_quotes
+ escape_sequence .or string_char .emit * .or '"' .emit *;
+
+/*
+ <character_range> ::= <character> "-" <character>
+*/
+character_range
+ character .and optional_space .and '-' .and optional_space .and character;
+
+/*
+ <advanced_identifier> ::= <optional_loop> <identifier>
+*/
+advanced_identifier
+ optional_loop .and identifier;
+
+/*
+ <optional_loop> ::= ".loop"
+ | ""
+*/
+optional_loop
+ optional_loop_1 .emit IDENTIFIER_LOOP .or .true .emit IDENTIFIER_SIMPLE;
+optional_loop_1
+ ".loop" .and space;
+
+/*
+ <optional_error> ::= <error>
+ | ""
+*/
+optional_error
+ error .emit ERROR_PRESENT .or .true .emit ERROR_NOT_PRESENT;
+
+/*
+ <error> :: ".error" <identifier>
+*/
+error
+ space .and ".error" .and space .and identifier;
+
+/*
+ <emit> ::= <emit_output>
+ | <emit_regbyte>
+*/
+emit
+ emit_output .or emit_regbyte;
+
+/*
+ <emit_output> ::= ".emit" <emit_param>
+*/
+emit_output
+ space .and ".emit" .and space .and emit_param;
+
+/*
+ <emit_param> ::= <integer>
+ | <identifier>
+ | <character>
+ | "*"
+ | "$"
+*/
+emit_param
+ integer_ne .emit EMIT_INTEGER .or
+ identifier_ne .emit EMIT_IDENTIFIER .or
+ character .emit EMIT_CHARACTER .or
+ '*' .emit EMIT_LAST_CHARACTER .or
+ '$' .emit EMIT_CURRENT_POSITION;
+
+/*
+ <emit_regbyte> ::= ".load" <identifier> <emit_param>
+*/
+emit_regbyte
+ space .and ".load" .and space .and identifier .and space .and emit_param;
+
+/*
+ <and_specifiers> ::= <and_specifier> <and_specifier>*
+*/
+and_specifiers
+ and_specifier .and .loop and_specifier;
+
+/*
+ <or_specifiers> ::= <or_specifier> <or_specifier>*
+*/
+or_specifiers
+ or_specifier .and .loop or_specifier;
+
+/*
+ <and_specifier> ::= ".and" <specifier>
+*/
+and_specifier
+ space .and ".and" .and space .and specifier;
+
+/*
+ <or_specifier> ::= ".or" <specifier>
+*/
+or_specifier
+ space .and ".or" .and space .and specifier;
+
+
+.string __string_filter;
+
+/*
+ <__string_filter> ::= <__first_identifier_char> <__next_identifier_char>*
+*/
+__string_filter
+ __first_identifier_char .and .loop __next_identifier_char;
+
+/*
+ <__first_identifier_char> ::= "a"-"z"
+ | "A"-"Z"
+ | "_"
+ | "."
+*/
+__first_identifier_char
+ 'a'-'z' .or 'A'-'Z' .or '_' .or '.';
+
+/*
+ <__next_identifier_char> ::= "a"-"z"
+ | "A"-"Z"
+ | "_"
+ | "0"-"9"
+*/
+__next_identifier_char
+ 'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_crt.c b/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_crt.c
new file mode 100755
index 000000000..8db87358c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_crt.c
@@ -0,0 +1,64 @@
+#include "grammar_crt.h"
+
+#define GRAMMAR_PORT_BUILD 1
+#include "grammar.c"
+#undef GRAMMAR_PORT_BUILD
+
+
+void grammar_alloc_free (void *ptr)
+{
+ free (ptr);
+}
+
+void *grammar_alloc_malloc (unsigned int size)
+{
+ return malloc (size);
+}
+
+void *grammar_alloc_realloc (void *ptr, unsigned int old_size, unsigned int size)
+{
+ return realloc (ptr, size);
+}
+
+void *grammar_memory_copy (void *dst, const void * src, unsigned int size)
+{
+ return memcpy (dst, src, size);
+}
+
+int grammar_string_compare (const byte *str1, const byte *str2)
+{
+ return strcmp ((const char *) str1, (const char *) str2);
+}
+
+int grammar_string_compare_n (const byte *str1, const byte *str2, unsigned int n)
+{
+ return strncmp ((const char *) str1, (const char *) str2, n);
+}
+
+byte *grammar_string_copy (byte *dst, const byte *src)
+{
+ return (byte *) strcpy ((char *) dst, (const char *) src);
+}
+
+byte *grammar_string_copy_n (byte *dst, const byte *src, unsigned int n)
+{
+ return (byte *) strncpy ((char *) dst, (const char *) src, n);
+}
+
+unsigned int grammar_string_length (const byte *str)
+{
+ return strlen ((const char *) str);
+}
+
+byte *grammar_string_duplicate (const byte *src)
+{
+ const unsigned int size = grammar_string_length (src);
+ byte *str = grammar_alloc_malloc (size + 1);
+ if (str != NULL)
+ {
+ grammar_memory_copy (str, src, size);
+ str[size] = '\0';
+ }
+ return str;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_crt.h b/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_crt.h
new file mode 100755
index 000000000..f0827ce96
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_crt.h
@@ -0,0 +1,20 @@
+#ifndef GRAMMAR_CRT_H
+#define GRAMMAR_CRT_H
+
+
+#include <stdlib.h>
+#include <malloc.h>
+#include <string.h>
+
+
+typedef unsigned long grammar;
+typedef unsigned char byte;
+
+
+#define GRAMMAR_PORT_INCLUDE 1
+#include "grammar.h"
+#undef GRAMMAR_PORT_INCLUDE
+
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_mesa.c b/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_mesa.c
new file mode 100644
index 000000000..eb962505b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_mesa.c
@@ -0,0 +1,87 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file grammar_mesa.c
+ * mesa3d port to syntax parsing engine
+ * \author Michal Krol
+ */
+
+#include "grammar_mesa.h"
+
+#define GRAMMAR_PORT_BUILD 1
+#include "grammar.c"
+#undef GRAMMAR_PORT_BUILD
+
+
+void grammar_alloc_free (void *ptr)
+{
+ _mesa_free (ptr);
+}
+
+void *grammar_alloc_malloc (size_t size)
+{
+ return _mesa_malloc (size);
+}
+
+void *grammar_alloc_realloc (void *ptr, size_t old_size, size_t size)
+{
+ return _mesa_realloc (ptr, old_size, size);
+}
+
+void *grammar_memory_copy (void *dst, const void * src, size_t size)
+{
+ return _mesa_memcpy (dst, src, size);
+}
+
+int grammar_string_compare (const byte *str1, const byte *str2)
+{
+ return _mesa_strcmp ((const char *) str1, (const char *) str2);
+}
+
+int grammar_string_compare_n (const byte *str1, const byte *str2, size_t n)
+{
+ return _mesa_strncmp ((const char *) str1, (const char *) str2, n);
+}
+
+byte *grammar_string_copy (byte *dst, const byte *src)
+{
+ return (byte *) _mesa_strcpy ((char *) dst, (const char *) src);
+}
+
+byte *grammar_string_copy_n (byte *dst, const byte *src, size_t n)
+{
+ return (byte *) _mesa_strncpy ((char *) dst, (const char *) src, n);
+}
+
+byte *grammar_string_duplicate (const byte *src)
+{
+ return (byte *) _mesa_strdup ((const char *) src);
+}
+
+unsigned int grammar_string_length (const byte *str)
+{
+ return (unsigned int)_mesa_strlen ((const char *) str);
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_mesa.h b/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_mesa.h
new file mode 100644
index 000000000..c14033a9d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_mesa.h
@@ -0,0 +1,43 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef GRAMMAR_MESA_H
+#define GRAMMAR_MESA_H
+
+
+#include "imports.h"
+/* NOTE: include Mesa 3-D specific headers here */
+
+
+typedef GLuint grammar;
+typedef GLubyte byte;
+
+
+#define GRAMMAR_PORT_INCLUDE 1
+#include "grammar.h"
+#undef GRAMMAR_PORT_INCLUDE
+
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_syn.h b/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_syn.h
new file mode 100644
index 000000000..840a1ab62
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/grammar/grammar_syn.h
@@ -0,0 +1,202 @@
+".syntax grammar;\n"
+".emtcode DECLARATION_END 0\n"
+".emtcode DECLARATION_EMITCODE 1\n"
+".emtcode DECLARATION_ERRORTEXT 2\n"
+".emtcode DECLARATION_REGBYTE 3\n"
+".emtcode DECLARATION_LEXER 4\n"
+".emtcode DECLARATION_RULE 5\n"
+".emtcode SPECIFIER_END 0\n"
+".emtcode SPECIFIER_AND_TAG 1\n"
+".emtcode SPECIFIER_OR_TAG 2\n"
+".emtcode SPECIFIER_CHARACTER_RANGE 3\n"
+".emtcode SPECIFIER_CHARACTER 4\n"
+".emtcode SPECIFIER_STRING 5\n"
+".emtcode SPECIFIER_IDENTIFIER 6\n"
+".emtcode SPECIFIER_TRUE 7\n"
+".emtcode SPECIFIER_FALSE 8\n"
+".emtcode SPECIFIER_DEBUG 9\n"
+".emtcode IDENTIFIER_SIMPLE 0\n"
+".emtcode IDENTIFIER_LOOP 1\n"
+".emtcode ERROR_NOT_PRESENT 0\n"
+".emtcode ERROR_PRESENT 1\n"
+".emtcode EMIT_NULL 0\n"
+".emtcode EMIT_INTEGER 1\n"
+".emtcode EMIT_IDENTIFIER 2\n"
+".emtcode EMIT_CHARACTER 3\n"
+".emtcode EMIT_LAST_CHARACTER 4\n"
+".emtcode EMIT_CURRENT_POSITION 5\n"
+".errtext INVALID_GRAMMAR \"internal error 2001: invalid grammar script\"\n"
+".errtext SYNTAX_EXPECTED \"internal error 2002: '.syntax' keyword expected\"\n"
+".errtext IDENTIFIER_EXPECTED \"internal error 2003: identifier expected\"\n"
+".errtext MISSING_SEMICOLON \"internal error 2004: missing ';'\"\n"
+".errtext INTEGER_EXPECTED \"internal error 2005: integer value expected\"\n"
+".errtext STRING_EXPECTED \"internal error 2006: string expected\"\n"
+"grammar\n"
+" grammar_1 .error INVALID_GRAMMAR;\n"
+"grammar_1\n"
+" optional_space .and \".syntax\" .error SYNTAX_EXPECTED .and space .and identifier .and\n"
+" semicolon .and declaration_list .and optional_space .and '\\0' .emit DECLARATION_END;\n"
+"optional_space\n"
+" space .or .true;\n"
+"space\n"
+" single_space .and .loop single_space;\n"
+"single_space\n"
+" white_char .or comment_block;\n"
+"white_char\n"
+" ' ' .or '\\t' .or '\\n' .or '\\r';\n"
+"comment_block\n"
+" '/' .and '*' .and comment_rest;\n"
+"comment_rest\n"
+" .loop comment_char_no_star .and comment_rest_1;\n"
+"comment_rest_1\n"
+" comment_end .or comment_rest_2;\n"
+"comment_rest_2\n"
+" '*' .and comment_rest;\n"
+"comment_char_no_star\n"
+" '\\x2B'-'\\xFF' .or '\\x01'-'\\x29';\n"
+"comment_end\n"
+" '*' .and '/';\n"
+"identifier\n"
+" identifier_ne .error IDENTIFIER_EXPECTED;\n"
+"identifier_ne\n"
+" first_idchar .emit * .and .loop follow_idchar .emit * .and .true .emit '\\0';\n"
+"first_idchar\n"
+" 'a'-'z' .or 'A'-'Z' .or '_';\n"
+"follow_idchar\n"
+" first_idchar .or digit_dec;\n"
+"digit_dec\n"
+" '0'-'9';\n"
+"semicolon\n"
+" optional_space .and ';' .error MISSING_SEMICOLON .and optional_space;\n"
+"declaration_list\n"
+" declaration .and .loop declaration;\n"
+"declaration\n"
+" emitcode_definition .emit DECLARATION_EMITCODE .or\n"
+" errortext_definition .emit DECLARATION_ERRORTEXT .or\n"
+" regbyte_definition .emit DECLARATION_REGBYTE .or\n"
+" lexer_definition .emit DECLARATION_LEXER .or\n"
+" rule_definition .emit DECLARATION_RULE;\n"
+"emitcode_definition\n"
+" \".emtcode\" .and space .and identifier .and space .and integer .and space_or_null;\n"
+"integer\n"
+" integer_ne .error INTEGER_EXPECTED;\n"
+"integer_ne\n"
+" hex_integer .emit 0x10 .or dec_integer .emit 10;\n"
+"hex_integer\n"
+" hex_prefix .and digit_hex .emit * .and .loop digit_hex .emit * .and .true .emit '\\0';\n"
+"hex_prefix\n"
+" '0' .and hex_prefix_1;\n"
+"hex_prefix_1\n"
+" 'x' .or 'X';\n"
+"digit_hex\n"
+" '0'-'9' .or 'a'-'f' .or 'A'-'F';\n"
+"dec_integer\n"
+" digit_dec .emit * .and .loop digit_dec .emit * .and .true .emit '\\0';\n"
+"space_or_null\n"
+" space .or '\\0';\n"
+"errortext_definition\n"
+" \".errtext\" .and space .and identifier .and space .and string .and space_or_null;\n"
+"string\n"
+" string_ne .error STRING_EXPECTED;\n"
+"string_ne\n"
+" '\"' .and .loop string_char_double_quotes .and '\"' .emit '\\0';\n"
+"string_char_double_quotes\n"
+" escape_sequence .or string_char .emit * .or '\\'' .emit *;\n"
+"string_char\n"
+" '\\x5D'-'\\xFF' .or '\\x28'-'\\x5B' .or '\\x23'-'\\x26' .or '\\x0E'-'\\x21' .or '\\x0B'-'\\x0C' .or\n"
+" '\\x01'-'\\x09';\n"
+"escape_sequence\n"
+" '\\\\' .emit * .and escape_code;\n"
+"escape_code\n"
+" simple_escape_code .emit * .or hex_escape_code .or oct_escape_code;\n"
+"simple_escape_code\n"
+" '\\'' .or '\"' .or '?' .or '\\\\' .or 'a' .or 'b' .or 'f' .or 'n' .or 'r' .or 't' .or 'v';\n"
+"hex_escape_code\n"
+" 'x' .emit * .and digit_hex .emit * .and .loop digit_hex .emit *;\n"
+"oct_escape_code\n"
+" digit_oct .emit * .and optional_digit_oct .and optional_digit_oct;\n"
+"digit_oct\n"
+" '0'-'7';\n"
+"optional_digit_oct\n"
+" digit_oct .emit * .or .true;\n"
+"regbyte_definition\n"
+" \".regbyte\" .and space .and identifier .and space .and integer .and space_or_null;\n"
+"lexer_definition\n"
+" \".string\" .and space .and identifier .and semicolon;\n"
+"rule_definition\n"
+" identifier_ne .and space .and definition;\n"
+"definition\n"
+" specifier .and optional_specifiers_and_or .and semicolon .emit SPECIFIER_END;\n"
+"optional_specifiers_and_or\n"
+" and_specifiers .emit SPECIFIER_AND_TAG .or or_specifiers .emit SPECIFIER_OR_TAG .or .true;\n"
+"specifier\n"
+" specifier_condition .and optional_space .and specifier_rule;\n"
+"specifier_condition\n"
+" specifier_condition_1 .or .true;\n"
+"specifier_condition_1\n"
+" \".if\" .and optional_space .and '(' .and optional_space .and left_operand .and operator .and\n"
+" right_operand .and optional_space .and ')';\n"
+"left_operand\n"
+" identifier;\n"
+"operator\n"
+" operator_1 .or operator_2;\n"
+"operator_1\n"
+" optional_space .and '!' .and '=' .and optional_space;\n"
+"operator_2\n"
+" optional_space .and '=' .and '=' .and optional_space;\n"
+"right_operand\n"
+" integer;\n"
+"specifier_rule\n"
+" specifier_rule_1 .and optional_error .and .loop emit .and .true .emit EMIT_NULL;\n"
+"specifier_rule_1\n"
+" character_range .emit SPECIFIER_CHARACTER_RANGE .or\n"
+" character .emit SPECIFIER_CHARACTER .or\n"
+" string_ne .emit SPECIFIER_STRING .or\n"
+" \".true\" .emit SPECIFIER_TRUE .or\n"
+" \".false\" .emit SPECIFIER_FALSE .or\n"
+" \".debug\" .emit SPECIFIER_DEBUG .or\n"
+" advanced_identifier .emit SPECIFIER_IDENTIFIER;\n"
+"character\n"
+" '\\'' .and string_char_single_quotes .and '\\'' .emit '\\0';\n"
+"string_char_single_quotes\n"
+" escape_sequence .or string_char .emit * .or '\"' .emit *;\n"
+"character_range\n"
+" character .and optional_space .and '-' .and optional_space .and character;\n"
+"advanced_identifier\n"
+" optional_loop .and identifier;\n"
+"optional_loop\n"
+" optional_loop_1 .emit IDENTIFIER_LOOP .or .true .emit IDENTIFIER_SIMPLE;\n"
+"optional_loop_1\n"
+" \".loop\" .and space;\n"
+"optional_error\n"
+" error .emit ERROR_PRESENT .or .true .emit ERROR_NOT_PRESENT;\n"
+"error\n"
+" space .and \".error\" .and space .and identifier;\n"
+"emit\n"
+" emit_output .or emit_regbyte;\n"
+"emit_output\n"
+" space .and \".emit\" .and space .and emit_param;\n"
+"emit_param\n"
+" integer_ne .emit EMIT_INTEGER .or\n"
+" identifier_ne .emit EMIT_IDENTIFIER .or\n"
+" character .emit EMIT_CHARACTER .or\n"
+" '*' .emit EMIT_LAST_CHARACTER .or\n"
+" '$' .emit EMIT_CURRENT_POSITION;\n"
+"emit_regbyte\n"
+" space .and \".load\" .and space .and identifier .and space .and emit_param;\n"
+"and_specifiers\n"
+" and_specifier .and .loop and_specifier;\n"
+"or_specifiers\n"
+" or_specifier .and .loop or_specifier;\n"
+"and_specifier\n"
+" space .and \".and\" .and space .and specifier;\n"
+"or_specifier\n"
+" space .and \".or\" .and space .and specifier;\n"
+".string __string_filter;\n"
+"__string_filter\n"
+" __first_identifier_char .and .loop __next_identifier_char;\n"
+"__first_identifier_char\n"
+" 'a'-'z' .or 'A'-'Z' .or '_' .or '.';\n"
+"__next_identifier_char\n"
+" 'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';\n"
+""
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/nvfragparse.c b/nx-X11/extras/Mesa/src/mesa/shader/nvfragparse.c
new file mode 100644
index 000000000..cd1aa35bf
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/nvfragparse.c
@@ -0,0 +1,1826 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file nvfragparse.c
+ * NVIDIA fragment program parser.
+ * \author Brian Paul
+ */
+
+/*
+ * Regarding GL_NV_fragment_program:
+ *
+ * Portions of this software may use or implement intellectual
+ * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims
+ * any and all warranties with respect to such intellectual property,
+ * including any use thereof or modifications thereto.
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "hash.h"
+#include "imports.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "nvfragprog.h"
+#include "nvfragparse.h"
+#include "nvprogram.h"
+#include "program.h"
+
+
+#define INPUT_1V 1
+#define INPUT_2V 2
+#define INPUT_3V 3
+#define INPUT_1S 4
+#define INPUT_2S 5
+#define INPUT_CC 6
+#define INPUT_1V_T 7 /* one source vector, plus textureId */
+#define INPUT_3V_T 8 /* one source vector, plus textureId */
+#define INPUT_NONE 9
+#define INPUT_1V_S 10 /* a string and a vector register */
+#define OUTPUT_V 20
+#define OUTPUT_S 21
+#define OUTPUT_NONE 22
+
+/* IRIX defines some of these */
+#undef _R
+#undef _H
+#undef _X
+#undef _C
+#undef _S
+
+/* Optional suffixes */
+#define _R FLOAT32 /* float */
+#define _H FLOAT16 /* half-float */
+#define _X FIXED12 /* fixed */
+#define _C 0x08 /* set cond codes */
+#define _S 0x10 /* saturate, clamp result to [0,1] */
+
+struct instruction_pattern {
+ const char *name;
+ enum fp_opcode opcode;
+ GLuint inputs;
+ GLuint outputs;
+ GLuint suffixes;
+};
+
+static const struct instruction_pattern Instructions[] = {
+ { "ADD", FP_OPCODE_ADD, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "COS", FP_OPCODE_COS, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
+ { "DDX", FP_OPCODE_DDX, INPUT_1V, OUTPUT_V, _R | _H | _C | _S },
+ { "DDY", FP_OPCODE_DDY, INPUT_1V, OUTPUT_V, _R | _H | _C | _S },
+ { "DP3", FP_OPCODE_DP3, INPUT_2V, OUTPUT_S, _R | _H | _X | _C | _S },
+ { "DP4", FP_OPCODE_DP4, INPUT_2V, OUTPUT_S, _R | _H | _X | _C | _S },
+ { "DST", FP_OPCODE_DP4, INPUT_2V, OUTPUT_V, _R | _H | _C | _S },
+ { "EX2", FP_OPCODE_DP4, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
+ { "FLR", FP_OPCODE_FLR, INPUT_1V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "FRC", FP_OPCODE_FRC, INPUT_1V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "KIL", FP_OPCODE_KIL_NV, INPUT_CC, OUTPUT_NONE, 0 },
+ { "LG2", FP_OPCODE_LG2, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
+ { "LIT", FP_OPCODE_LIT, INPUT_1V, OUTPUT_V, _R | _H | _C | _S },
+ { "LRP", FP_OPCODE_LRP, INPUT_3V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "MAD", FP_OPCODE_MAD, INPUT_3V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "MAX", FP_OPCODE_MAX, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "MIN", FP_OPCODE_MIN, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "MOV", FP_OPCODE_MOV, INPUT_1V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "MUL", FP_OPCODE_MUL, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "PK2H", FP_OPCODE_PK2H, INPUT_1V, OUTPUT_S, 0 },
+ { "PK2US", FP_OPCODE_PK2US, INPUT_1V, OUTPUT_S, 0 },
+ { "PK4B", FP_OPCODE_PK4B, INPUT_1V, OUTPUT_S, 0 },
+ { "PK4UB", FP_OPCODE_PK4UB, INPUT_1V, OUTPUT_S, 0 },
+ { "POW", FP_OPCODE_POW, INPUT_2S, OUTPUT_S, _R | _H | _C | _S },
+ { "RCP", FP_OPCODE_RCP, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
+ { "RFL", FP_OPCODE_RFL, INPUT_2V, OUTPUT_V, _R | _H | _C | _S },
+ { "RSQ", FP_OPCODE_RSQ, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
+ { "SEQ", FP_OPCODE_SEQ, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "SFL", FP_OPCODE_SFL, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "SGE", FP_OPCODE_SGE, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "SGT", FP_OPCODE_SGT, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "SIN", FP_OPCODE_SIN, INPUT_1S, OUTPUT_S, _R | _H | _C | _S },
+ { "SLE", FP_OPCODE_SLE, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "SLT", FP_OPCODE_SLT, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "SNE", FP_OPCODE_SNE, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "STR", FP_OPCODE_STR, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "SUB", FP_OPCODE_SUB, INPUT_2V, OUTPUT_V, _R | _H | _X | _C | _S },
+ { "TEX", FP_OPCODE_TEX, INPUT_1V_T, OUTPUT_V, _C | _S },
+ { "TXD", FP_OPCODE_TXD, INPUT_3V_T, OUTPUT_V, _C | _S },
+ { "TXP", FP_OPCODE_TXP_NV, INPUT_1V_T, OUTPUT_V, _C | _S },
+ { "UP2H", FP_OPCODE_UP2H, INPUT_1S, OUTPUT_V, _C | _S },
+ { "UP2US", FP_OPCODE_UP2US, INPUT_1S, OUTPUT_V, _C | _S },
+ { "UP4B", FP_OPCODE_UP4B, INPUT_1S, OUTPUT_V, _C | _S },
+ { "UP4UB", FP_OPCODE_UP4UB, INPUT_1S, OUTPUT_V, _C | _S },
+ { "X2D", FP_OPCODE_X2D, INPUT_3V, OUTPUT_V, _R | _H | _C | _S },
+ { "PRINT", FP_OPCODE_PRINT, INPUT_1V_S, OUTPUT_NONE, 0 },
+ { NULL, (enum fp_opcode) -1, 0, 0, 0 }
+};
+
+
+/*
+ * Information needed or computed during parsing.
+ * Remember, we can't modify the target program object until we've
+ * _successfully_ parsed the program text.
+ */
+struct parse_state {
+ GLcontext *ctx;
+ const GLubyte *start; /* start of program string */
+ const GLubyte *pos; /* current position */
+ const GLubyte *curLine;
+ struct fragment_program *program; /* current program */
+
+ struct program_parameter_list *parameters;
+
+ GLuint numInst; /* number of instructions parsed */
+ GLuint inputsRead; /* bitmask of input registers used */
+ GLuint outputsWritten; /* bitmask of 1 << FRAG_OUTPUT_* bits */
+ GLuint texturesUsed[MAX_TEXTURE_IMAGE_UNITS];
+};
+
+
+
+/*
+ * Called whenever we find an error during parsing.
+ */
+static void
+record_error(struct parse_state *parseState, const char *msg, int lineNo)
+{
+#ifdef DEBUG
+ GLint line, column;
+ const GLubyte *lineStr;
+ lineStr = _mesa_find_line_column(parseState->start,
+ parseState->pos, &line, &column);
+ _mesa_debug(parseState->ctx,
+ "nvfragparse.c(%d): line %d, column %d:%s (%s)\n",
+ lineNo, line, column, (char *) lineStr, msg);
+ _mesa_free((void *) lineStr);
+#else
+ (void) lineNo;
+#endif
+
+ /* Check that no error was already recorded. Only record the first one. */
+ if (parseState->ctx->Program.ErrorString[0] == 0) {
+ _mesa_set_program_error(parseState->ctx,
+ parseState->pos - parseState->start,
+ msg);
+ }
+}
+
+
+#define RETURN_ERROR \
+do { \
+ record_error(parseState, "Unexpected end of input.", __LINE__); \
+ return GL_FALSE; \
+} while(0)
+
+#define RETURN_ERROR1(msg) \
+do { \
+ record_error(parseState, msg, __LINE__); \
+ return GL_FALSE; \
+} while(0)
+
+#define RETURN_ERROR2(msg1, msg2) \
+do { \
+ char err[1000]; \
+ _mesa_sprintf(err, "%s %s", msg1, msg2); \
+ record_error(parseState, err, __LINE__); \
+ return GL_FALSE; \
+} while(0)
+
+
+
+
+/*
+ * Search a list of instruction structures for a match.
+ */
+static struct instruction_pattern
+MatchInstruction(const GLubyte *token)
+{
+ const struct instruction_pattern *inst;
+ struct instruction_pattern result;
+
+ for (inst = Instructions; inst->name; inst++) {
+ if (_mesa_strncmp((const char *) token, inst->name, 3) == 0) {
+ /* matched! */
+ int i = 3;
+ result = *inst;
+ result.suffixes = 0;
+ /* look at suffix */
+ if (token[i] == 'R') {
+ result.suffixes |= _R;
+ i++;
+ }
+ else if (token[i] == 'H') {
+ result.suffixes |= _H;
+ i++;
+ }
+ else if (token[i] == 'X') {
+ result.suffixes |= _X;
+ i++;
+ }
+ if (token[i] == 'C') {
+ result.suffixes |= _C;
+ i++;
+ }
+ if (token[i] == '_' && token[i+1] == 'S' &&
+ token[i+2] == 'A' && token[i+3] == 'T') {
+ result.suffixes |= _S;
+ }
+ return result;
+ }
+ }
+ result.opcode = (enum fp_opcode) -1;
+ return result;
+}
+
+
+
+
+/**********************************************************************/
+
+
+static GLboolean IsLetter(GLubyte b)
+{
+ return (b >= 'a' && b <= 'z') ||
+ (b >= 'A' && b <= 'Z') ||
+ (b == '_') ||
+ (b == '$');
+}
+
+
+static GLboolean IsDigit(GLubyte b)
+{
+ return b >= '0' && b <= '9';
+}
+
+
+static GLboolean IsWhitespace(GLubyte b)
+{
+ return b == ' ' || b == '\t' || b == '\n' || b == '\r';
+}
+
+
+/**
+ * Starting at 'str' find the next token. A token can be an integer,
+ * an identifier or punctuation symbol.
+ * \return <= 0 we found an error, else, return number of characters parsed.
+ */
+static GLint
+GetToken(struct parse_state *parseState, GLubyte *token)
+{
+ const GLubyte *str = parseState->pos;
+ GLint i = 0, j = 0;
+
+ token[0] = 0;
+
+ /* skip whitespace and comments */
+ while (str[i] && (IsWhitespace(str[i]) || str[i] == '#')) {
+ if (str[i] == '#') {
+ /* skip comment */
+ while (str[i] && (str[i] != '\n' && str[i] != '\r')) {
+ i++;
+ }
+ if (str[i] == '\n' || str[i] == '\r')
+ parseState->curLine = str + i + 1;
+ }
+ else {
+ /* skip whitespace */
+ if (str[i] == '\n' || str[i] == '\r')
+ parseState->curLine = str + i + 1;
+ i++;
+ }
+ }
+
+ if (str[i] == 0)
+ return -i;
+
+ /* try matching an integer */
+ while (str[i] && IsDigit(str[i])) {
+ token[j++] = str[i++];
+ }
+ if (j > 0 || !str[i]) {
+ token[j] = 0;
+ return i;
+ }
+
+ /* try matching an identifier */
+ if (IsLetter(str[i])) {
+ while (str[i] && (IsLetter(str[i]) || IsDigit(str[i]))) {
+ token[j++] = str[i++];
+ }
+ token[j] = 0;
+ return i;
+ }
+
+ /* punctuation character */
+ if (str[i]) {
+ token[0] = str[i++];
+ token[1] = 0;
+ return i;
+ }
+
+ /* end of input */
+ token[0] = 0;
+ return i;
+}
+
+
+/**
+ * Get next token from input stream and increment stream pointer past token.
+ */
+static GLboolean
+Parse_Token(struct parse_state *parseState, GLubyte *token)
+{
+ GLint i;
+ i = GetToken(parseState, token);
+ if (i <= 0) {
+ parseState->pos += (-i);
+ return GL_FALSE;
+ }
+ parseState->pos += i;
+ return GL_TRUE;
+}
+
+
+/**
+ * Get next token from input stream but don't increment stream pointer.
+ */
+static GLboolean
+Peek_Token(struct parse_state *parseState, GLubyte *token)
+{
+ GLint i, len;
+ i = GetToken(parseState, token);
+ if (i <= 0) {
+ parseState->pos += (-i);
+ return GL_FALSE;
+ }
+ len = (GLint)_mesa_strlen((const char *) token);
+ parseState->pos += (i - len);
+ return GL_TRUE;
+}
+
+
+/**********************************************************************/
+
+static const char *InputRegisters[MAX_NV_FRAGMENT_PROGRAM_INPUTS + 1] = {
+ "WPOS", "COL0", "COL1", "FOGC",
+ "TEX0", "TEX1", "TEX2", "TEX3", "TEX4", "TEX5", "TEX6", "TEX7", NULL
+};
+
+static const char *OutputRegisters[MAX_NV_FRAGMENT_PROGRAM_OUTPUTS + 1] = {
+ "COLR", "COLH",
+ /* These are only allows for register combiners */
+ /*
+ "TEX0", "TEX1", "TEX2", "TEX3",
+ */
+ "DEPR", NULL
+};
+
+
+
+
+/**********************************************************************/
+
+/**
+ * Try to match 'pattern' as the next token after any whitespace/comments.
+ */
+static GLboolean
+Parse_String(struct parse_state *parseState, const char *pattern)
+{
+ const GLubyte *m;
+ GLint i;
+
+ /* skip whitespace and comments */
+ while (IsWhitespace(*parseState->pos) || *parseState->pos == '#') {
+ if (*parseState->pos == '#') {
+ while (*parseState->pos && (*parseState->pos != '\n' && *parseState->pos != '\r')) {
+ parseState->pos += 1;
+ }
+ if (*parseState->pos == '\n' || *parseState->pos == '\r')
+ parseState->curLine = parseState->pos + 1;
+ }
+ else {
+ /* skip whitespace */
+ if (*parseState->pos == '\n' || *parseState->pos == '\r')
+ parseState->curLine = parseState->pos + 1;
+ parseState->pos += 1;
+ }
+ }
+
+ /* Try to match the pattern */
+ m = parseState->pos;
+ for (i = 0; pattern[i]; i++) {
+ if (*m != (GLubyte) pattern[i])
+ return GL_FALSE;
+ m += 1;
+ }
+ parseState->pos = m;
+
+ return GL_TRUE; /* success */
+}
+
+
+static GLboolean
+Parse_Identifier(struct parse_state *parseState, GLubyte *ident)
+{
+ if (!Parse_Token(parseState, ident))
+ RETURN_ERROR;
+ if (IsLetter(ident[0]))
+ return GL_TRUE;
+ else
+ RETURN_ERROR1("Expected an identfier");
+}
+
+
+/**
+ * Parse a floating point constant, or a defined symbol name.
+ * [+/-]N[.N[eN]]
+ * Output: number[0 .. 3] will get the value.
+ */
+static GLboolean
+Parse_ScalarConstant(struct parse_state *parseState, GLfloat *number)
+{
+ char *end = NULL;
+
+ *number = (GLfloat) _mesa_strtod((const char *) parseState->pos, &end);
+
+ if (end && end > (char *) parseState->pos) {
+ /* got a number */
+ parseState->pos = (GLubyte *) end;
+ number[1] = *number;
+ number[2] = *number;
+ number[3] = *number;
+ return GL_TRUE;
+ }
+ else {
+ /* should be an identifier */
+ GLubyte ident[100];
+ const GLfloat *constant;
+ if (!Parse_Identifier(parseState, ident))
+ RETURN_ERROR1("Expected an identifier");
+ constant = _mesa_lookup_parameter_value(parseState->parameters,
+ -1, (const char *) ident);
+ /* XXX Check that it's a constant and not a parameter */
+ if (!constant) {
+ RETURN_ERROR1("Undefined symbol");
+ }
+ else {
+ COPY_4V(number, constant);
+ return GL_TRUE;
+ }
+ }
+}
+
+
+
+/**
+ * Parse a vector constant, one of:
+ * { float }
+ * { float, float }
+ * { float, float, float }
+ * { float, float, float, float }
+ */
+static GLboolean
+Parse_VectorConstant(struct parse_state *parseState, GLfloat *vec)
+{
+ /* "{" was already consumed */
+
+ ASSIGN_4V(vec, 0.0, 0.0, 0.0, 1.0);
+
+ if (!Parse_ScalarConstant(parseState, vec+0)) /* X */
+ return GL_FALSE;
+
+ if (Parse_String(parseState, "}")) {
+ return GL_TRUE;
+ }
+
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR1("Expected comma in vector constant");
+
+ if (!Parse_ScalarConstant(parseState, vec+1)) /* Y */
+ return GL_FALSE;
+
+ if (Parse_String(parseState, "}")) {
+ return GL_TRUE;
+ }
+
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR1("Expected comma in vector constant");
+
+ if (!Parse_ScalarConstant(parseState, vec+2)) /* Z */
+ return GL_FALSE;
+
+ if (Parse_String(parseState, "}")) {
+ return GL_TRUE;
+ }
+
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR1("Expected comma in vector constant");
+
+ if (!Parse_ScalarConstant(parseState, vec+3)) /* W */
+ return GL_FALSE;
+
+ if (!Parse_String(parseState, "}"))
+ RETURN_ERROR1("Expected closing brace in vector constant");
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Parse <number>, <varname> or {a, b, c, d}.
+ * Return number of values in the vector or scalar, or zero if parse error.
+ */
+static GLuint
+Parse_VectorOrScalarConstant(struct parse_state *parseState, GLfloat *vec)
+{
+ if (Parse_String(parseState, "{")) {
+ return Parse_VectorConstant(parseState, vec);
+ }
+ else {
+ GLboolean b = Parse_ScalarConstant(parseState, vec);
+ if (b) {
+ vec[1] = vec[2] = vec[3] = vec[0];
+ }
+ return b;
+ }
+}
+
+
+/**
+ * Parse a texture image source:
+ * [TEX0 | TEX1 | .. | TEX15] , [1D | 2D | 3D | CUBE | RECT]
+ */
+static GLboolean
+Parse_TextureImageId(struct parse_state *parseState,
+ GLubyte *texUnit, GLubyte *texTargetBit)
+{
+ GLubyte imageSrc[100];
+ GLint unit;
+
+ if (!Parse_Token(parseState, imageSrc))
+ RETURN_ERROR;
+
+ if (imageSrc[0] != 'T' ||
+ imageSrc[1] != 'E' ||
+ imageSrc[2] != 'X') {
+ RETURN_ERROR1("Expected TEX# source");
+ }
+ unit = _mesa_atoi((const char *) imageSrc + 3);
+ if ((unit < 0 || unit > MAX_TEXTURE_IMAGE_UNITS) ||
+ (unit == 0 && (imageSrc[3] != '0' || imageSrc[4] != 0))) {
+ RETURN_ERROR1("Invalied TEX# source index");
+ }
+ *texUnit = unit;
+
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR1("Expected ,");
+
+ if (Parse_String(parseState, "1D")) {
+ *texTargetBit = TEXTURE_1D_BIT;
+ }
+ else if (Parse_String(parseState, "2D")) {
+ *texTargetBit = TEXTURE_2D_BIT;
+ }
+ else if (Parse_String(parseState, "3D")) {
+ *texTargetBit = TEXTURE_3D_BIT;
+ }
+ else if (Parse_String(parseState, "CUBE")) {
+ *texTargetBit = TEXTURE_CUBE_BIT;
+ }
+ else if (Parse_String(parseState, "RECT")) {
+ *texTargetBit = TEXTURE_RECT_BIT;
+ }
+ else {
+ RETURN_ERROR1("Invalid texture target token");
+ }
+
+ /* update record of referenced texture units */
+ parseState->texturesUsed[*texUnit] |= *texTargetBit;
+ if (_mesa_bitcount(parseState->texturesUsed[*texUnit]) > 1) {
+ RETURN_ERROR1("Only one texture target can be used per texture unit.");
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Parse a scalar suffix like .x, .y, .z or .w or parse a swizzle suffix
+ * like .wxyz, .xxyy, etc and return the swizzle indexes.
+ */
+static GLboolean
+Parse_SwizzleSuffix(const GLubyte *token, GLuint swizzle[4])
+{
+ if (token[1] == 0) {
+ /* single letter swizzle (scalar) */
+ if (token[0] == 'x')
+ ASSIGN_4V(swizzle, 0, 0, 0, 0);
+ else if (token[0] == 'y')
+ ASSIGN_4V(swizzle, 1, 1, 1, 1);
+ else if (token[0] == 'z')
+ ASSIGN_4V(swizzle, 2, 2, 2, 2);
+ else if (token[0] == 'w')
+ ASSIGN_4V(swizzle, 3, 3, 3, 3);
+ else
+ return GL_FALSE;
+ }
+ else {
+ /* 4-component swizzle (vector) */
+ GLint k;
+ for (k = 0; token[k] && k < 4; k++) {
+ if (token[k] == 'x')
+ swizzle[k] = 0;
+ else if (token[k] == 'y')
+ swizzle[k] = 1;
+ else if (token[k] == 'z')
+ swizzle[k] = 2;
+ else if (token[k] == 'w')
+ swizzle[k] = 3;
+ else
+ return GL_FALSE;
+ }
+ if (k != 4)
+ return GL_FALSE;
+ }
+ return GL_TRUE;
+}
+
+
+static GLboolean
+Parse_CondCodeMask(struct parse_state *parseState,
+ struct fp_dst_register *dstReg)
+{
+ if (Parse_String(parseState, "EQ"))
+ dstReg->CondMask = COND_EQ;
+ else if (Parse_String(parseState, "GE"))
+ dstReg->CondMask = COND_GE;
+ else if (Parse_String(parseState, "GT"))
+ dstReg->CondMask = COND_GT;
+ else if (Parse_String(parseState, "LE"))
+ dstReg->CondMask = COND_LE;
+ else if (Parse_String(parseState, "LT"))
+ dstReg->CondMask = COND_LT;
+ else if (Parse_String(parseState, "NE"))
+ dstReg->CondMask = COND_NE;
+ else if (Parse_String(parseState, "TR"))
+ dstReg->CondMask = COND_TR;
+ else if (Parse_String(parseState, "FL"))
+ dstReg->CondMask = COND_FL;
+ else
+ RETURN_ERROR1("Invalid condition code mask");
+
+ /* look for optional .xyzw swizzle */
+ if (Parse_String(parseState, ".")) {
+ GLubyte token[100];
+ GLuint swz[4];
+
+ if (!Parse_Token(parseState, token)) /* get xyzw suffix */
+ RETURN_ERROR;
+
+ if (!Parse_SwizzleSuffix(token, swz))
+ RETURN_ERROR1("Invalid swizzle suffix");
+
+ dstReg->CondSwizzle = MAKE_SWIZZLE(swz);
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Parse a temporary register: Rnn or Hnn
+ */
+static GLboolean
+Parse_TempReg(struct parse_state *parseState, GLint *tempRegNum)
+{
+ GLubyte token[100];
+
+ /* Should be 'R##' or 'H##' */
+ if (!Parse_Token(parseState, token))
+ RETURN_ERROR;
+ if (token[0] != 'R' && token[0] != 'H')
+ RETURN_ERROR1("Expected R## or H##");
+
+ if (IsDigit(token[1])) {
+ GLint reg = _mesa_atoi((const char *) (token + 1));
+ if (token[0] == 'H')
+ reg += 32;
+ if (reg >= MAX_NV_FRAGMENT_PROGRAM_TEMPS)
+ RETURN_ERROR1("Invalid temporary register name");
+ *tempRegNum = reg;
+ }
+ else {
+ RETURN_ERROR1("Invalid temporary register name");
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Parse a write-only dummy register: RC or HC.
+ */
+static GLboolean
+Parse_DummyReg(struct parse_state *parseState, GLint *regNum)
+{
+ if (Parse_String(parseState, "RC")) {
+ *regNum = 0;
+ }
+ else if (Parse_String(parseState, "HC")) {
+ *regNum = 1;
+ }
+ else {
+ RETURN_ERROR1("Invalid write-only register name");
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Parse a program local parameter register "p[##]"
+ */
+static GLboolean
+Parse_ProgramParamReg(struct parse_state *parseState, GLint *regNum)
+{
+ GLubyte token[100];
+
+ if (!Parse_String(parseState, "p["))
+ RETURN_ERROR1("Expected p[");
+
+ if (!Parse_Token(parseState, token))
+ RETURN_ERROR;
+
+ if (IsDigit(token[0])) {
+ /* a numbered program parameter register */
+ GLint reg = _mesa_atoi((const char *) token);
+ if (reg >= MAX_NV_FRAGMENT_PROGRAM_PARAMS)
+ RETURN_ERROR1("Invalid constant program number");
+ *regNum = reg;
+ }
+ else {
+ RETURN_ERROR;
+ }
+
+ if (!Parse_String(parseState, "]"))
+ RETURN_ERROR1("Expected ]");
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Parse f[name] - fragment input register
+ */
+static GLboolean
+Parse_FragReg(struct parse_state *parseState, GLint *tempRegNum)
+{
+ GLubyte token[100];
+ GLint j;
+
+ /* Match 'f[' */
+ if (!Parse_String(parseState, "f["))
+ RETURN_ERROR1("Expected f[");
+
+ /* get <name> and look for match */
+ if (!Parse_Token(parseState, token)) {
+ RETURN_ERROR;
+ }
+ for (j = 0; InputRegisters[j]; j++) {
+ if (_mesa_strcmp((const char *) token, InputRegisters[j]) == 0) {
+ *tempRegNum = j;
+ parseState->inputsRead |= (1 << j);
+ break;
+ }
+ }
+ if (!InputRegisters[j]) {
+ /* unknown input register label */
+ RETURN_ERROR2("Invalid register name", token);
+ }
+
+ /* Match '[' */
+ if (!Parse_String(parseState, "]"))
+ RETURN_ERROR1("Expected ]");
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+Parse_OutputReg(struct parse_state *parseState, GLint *outputRegNum)
+{
+ GLubyte token[100];
+ GLint j;
+
+ /* Match "o[" */
+ if (!Parse_String(parseState, "o["))
+ RETURN_ERROR1("Expected o[");
+
+ /* Get output reg name */
+ if (!Parse_Token(parseState, token))
+ RETURN_ERROR;
+
+ /* try to match an output register name */
+ for (j = 0; OutputRegisters[j]; j++) {
+ if (_mesa_strcmp((const char *) token, OutputRegisters[j]) == 0) {
+ static GLuint bothColors = (1 << FRAG_OUTPUT_COLR) | (1 << FRAG_OUTPUT_COLH);
+ *outputRegNum = j;
+ parseState->outputsWritten |= (1 << j);
+ if ((parseState->outputsWritten & bothColors) == bothColors) {
+ RETURN_ERROR1("Illegal to write to both o[COLR] and o[COLH]");
+ }
+ break;
+ }
+ }
+ if (!OutputRegisters[j])
+ RETURN_ERROR1("Invalid output register name");
+
+ /* Match ']' */
+ if (!Parse_String(parseState, "]"))
+ RETURN_ERROR1("Expected ]");
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+Parse_MaskedDstReg(struct parse_state *parseState,
+ struct fp_dst_register *dstReg)
+{
+ GLubyte token[100];
+ GLint idx;
+
+ /* Dst reg can be R<n>, H<n>, o[n], RC or HC */
+ if (!Peek_Token(parseState, token))
+ RETURN_ERROR;
+
+ if (_mesa_strcmp((const char *) token, "RC") == 0 ||
+ _mesa_strcmp((const char *) token, "HC") == 0) {
+ /* a write-only register */
+ dstReg->File = PROGRAM_WRITE_ONLY;
+ if (!Parse_DummyReg(parseState, &idx))
+ RETURN_ERROR;
+ dstReg->Index = idx;
+ }
+ else if (token[0] == 'R' || token[0] == 'H') {
+ /* a temporary register */
+ dstReg->File = PROGRAM_TEMPORARY;
+ if (!Parse_TempReg(parseState, &idx))
+ RETURN_ERROR;
+ dstReg->Index = idx;
+ }
+ else if (token[0] == 'o') {
+ /* an output register */
+ dstReg->File = PROGRAM_OUTPUT;
+ if (!Parse_OutputReg(parseState, &idx))
+ RETURN_ERROR;
+ dstReg->Index = idx;
+ }
+ else {
+ RETURN_ERROR1("Invalid destination register name");
+ }
+
+ /* Parse optional write mask */
+ if (Parse_String(parseState, ".")) {
+ /* got a mask */
+ GLint k = 0;
+
+ if (!Parse_Token(parseState, token)) /* get xyzw writemask */
+ RETURN_ERROR;
+
+ dstReg->WriteMask = 0;
+
+ if (token[k] == 'x') {
+ dstReg->WriteMask |= WRITEMASK_X;
+ k++;
+ }
+ if (token[k] == 'y') {
+ dstReg->WriteMask |= WRITEMASK_Y;
+ k++;
+ }
+ if (token[k] == 'z') {
+ dstReg->WriteMask |= WRITEMASK_Z;
+ k++;
+ }
+ if (token[k] == 'w') {
+ dstReg->WriteMask |= WRITEMASK_W;
+ k++;
+ }
+ if (k == 0) {
+ RETURN_ERROR1("Invalid writemask character");
+ }
+
+ }
+ else {
+ dstReg->WriteMask = WRITEMASK_XYZW;
+ }
+
+ /* optional condition code mask */
+ if (Parse_String(parseState, "(")) {
+ /* ("EQ" | "GE" | "GT" | "LE" | "LT" | "NE" | "TR" | "FL".x|y|z|w) */
+ /* ("EQ" | "GE" | "GT" | "LE" | "LT" | "NE" | "TR" | "FL".[xyzw]) */
+ if (!Parse_CondCodeMask(parseState, dstReg))
+ RETURN_ERROR;
+
+ if (!Parse_String(parseState, ")")) /* consume ")" */
+ RETURN_ERROR1("Expected )");
+
+ return GL_TRUE;
+ }
+ else {
+ /* no cond code mask */
+ dstReg->CondMask = COND_TR;
+ dstReg->CondSwizzle = SWIZZLE_NOOP;
+ return GL_TRUE;
+ }
+}
+
+
+/**
+ * Parse a vector source (register, constant, etc):
+ * <vectorSrc> ::= <absVectorSrc>
+ * | <baseVectorSrc>
+ * <absVectorSrc> ::= <negate> "|" <baseVectorSrc> "|"
+ */
+static GLboolean
+Parse_VectorSrc(struct parse_state *parseState,
+ struct fp_src_register *srcReg)
+{
+ GLfloat sign = 1.0F;
+ GLubyte token[100];
+ GLint idx;
+
+ /*
+ * First, take care of +/- and absolute value stuff.
+ */
+ if (Parse_String(parseState, "-"))
+ sign = -1.0F;
+ else if (Parse_String(parseState, "+"))
+ sign = +1.0F;
+
+ if (Parse_String(parseState, "|")) {
+ srcReg->Abs = GL_TRUE;
+ srcReg->NegateAbs = (sign < 0.0F) ? GL_TRUE : GL_FALSE;
+
+ if (Parse_String(parseState, "-"))
+ srcReg->NegateBase = GL_TRUE;
+ else if (Parse_String(parseState, "+"))
+ srcReg->NegateBase = GL_FALSE;
+ else
+ srcReg->NegateBase = GL_FALSE;
+ }
+ else {
+ srcReg->Abs = GL_FALSE;
+ srcReg->NegateAbs = GL_FALSE;
+ srcReg->NegateBase = (sign < 0.0F) ? GL_TRUE : GL_FALSE;
+ }
+
+ /* This should be the real src vector/register name */
+ if (!Peek_Token(parseState, token))
+ RETURN_ERROR;
+
+ /* Src reg can be Rn, Hn, f[n], p[n], a named parameter, a scalar
+ * literal or vector literal.
+ */
+ if (token[0] == 'R' || token[0] == 'H') {
+ srcReg->File = PROGRAM_TEMPORARY;
+ if (!Parse_TempReg(parseState, &idx))
+ RETURN_ERROR;
+ srcReg->Index = idx;
+ }
+ else if (token[0] == 'f') {
+ /* XXX this might be an identier! */
+ srcReg->File = PROGRAM_INPUT;
+ if (!Parse_FragReg(parseState, &idx))
+ RETURN_ERROR;
+ srcReg->Index = idx;
+ }
+ else if (token[0] == 'p') {
+ /* XXX this might be an identier! */
+ srcReg->File = PROGRAM_LOCAL_PARAM;
+ if (!Parse_ProgramParamReg(parseState, &idx))
+ RETURN_ERROR;
+ srcReg->Index = idx;
+ }
+ else if (IsLetter(token[0])){
+ GLubyte ident[100];
+ GLint paramIndex;
+ if (!Parse_Identifier(parseState, ident))
+ RETURN_ERROR;
+ paramIndex = _mesa_lookup_parameter_index(parseState->parameters,
+ -1, (const char *) ident);
+ if (paramIndex < 0) {
+ RETURN_ERROR2("Undefined constant or parameter: ", ident);
+ }
+ srcReg->File = PROGRAM_NAMED_PARAM;
+ srcReg->Index = paramIndex;
+ }
+ else if (IsDigit(token[0]) || token[0] == '-' || token[0] == '+' || token[0] == '.'){
+ /* literal scalar constant */
+ GLfloat values[4];
+ GLuint paramIndex;
+ if (!Parse_ScalarConstant(parseState, values))
+ RETURN_ERROR;
+ paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values);
+ srcReg->File = PROGRAM_NAMED_PARAM;
+ srcReg->Index = paramIndex;
+ }
+ else if (token[0] == '{'){
+ /* literal vector constant */
+ GLfloat values[4];
+ GLuint paramIndex;
+ (void) Parse_String(parseState, "{");
+ if (!Parse_VectorConstant(parseState, values))
+ RETURN_ERROR;
+ paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values);
+ srcReg->File = PROGRAM_NAMED_PARAM;
+ srcReg->Index = paramIndex;
+ }
+ else {
+ RETURN_ERROR2("Invalid source register name", token);
+ }
+
+ /* init swizzle fields */
+ srcReg->Swizzle = SWIZZLE_NOOP;
+
+ /* Look for optional swizzle suffix */
+ if (Parse_String(parseState, ".")) {
+ GLuint swz[4];
+
+ if (!Parse_Token(parseState, token))
+ RETURN_ERROR;
+
+ if (!Parse_SwizzleSuffix(token, swz))
+ RETURN_ERROR1("Invalid swizzle suffix");
+
+ srcReg->Swizzle = MAKE_SWIZZLE(swz);
+ }
+
+ /* Finish absolute value */
+ if (srcReg->Abs && !Parse_String(parseState, "|")) {
+ RETURN_ERROR1("Expected |");
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+Parse_ScalarSrcReg(struct parse_state *parseState,
+ struct fp_src_register *srcReg)
+{
+ GLubyte token[100];
+ GLfloat sign = 1.0F;
+ GLboolean needSuffix = GL_TRUE;
+ GLint idx;
+
+ /*
+ * First, take care of +/- and absolute value stuff.
+ */
+ if (Parse_String(parseState, "-"))
+ sign = -1.0F;
+ else if (Parse_String(parseState, "+"))
+ sign = +1.0F;
+
+ if (Parse_String(parseState, "|")) {
+ srcReg->Abs = GL_TRUE;
+ srcReg->NegateAbs = (sign < 0.0F) ? GL_TRUE : GL_FALSE;
+
+ if (Parse_String(parseState, "-"))
+ srcReg->NegateBase = GL_TRUE;
+ else if (Parse_String(parseState, "+"))
+ srcReg->NegateBase = GL_FALSE;
+ else
+ srcReg->NegateBase = GL_FALSE;
+ }
+ else {
+ srcReg->Abs = GL_FALSE;
+ srcReg->NegateAbs = GL_FALSE;
+ srcReg->NegateBase = (sign < 0.0F) ? GL_TRUE : GL_FALSE;
+ }
+
+ if (!Peek_Token(parseState, token))
+ RETURN_ERROR;
+
+ /* Src reg can be R<n>, H<n> or a named fragment attrib */
+ if (token[0] == 'R' || token[0] == 'H') {
+ srcReg->File = PROGRAM_TEMPORARY;
+ if (!Parse_TempReg(parseState, &idx))
+ RETURN_ERROR;
+ srcReg->Index = idx;
+ }
+ else if (token[0] == 'f') {
+ srcReg->File = PROGRAM_INPUT;
+ if (!Parse_FragReg(parseState, &idx))
+ RETURN_ERROR;
+ srcReg->Index = idx;
+ }
+ else if (token[0] == '{') {
+ /* vector literal */
+ GLfloat values[4];
+ GLuint paramIndex;
+ (void) Parse_String(parseState, "{");
+ if (!Parse_VectorConstant(parseState, values))
+ RETURN_ERROR;
+ paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values);
+ srcReg->File = PROGRAM_NAMED_PARAM;
+ srcReg->Index = paramIndex;
+ }
+ else if (IsDigit(token[0])) {
+ /* scalar literal */
+ GLfloat values[4];
+ GLuint paramIndex;
+ if (!Parse_ScalarConstant(parseState, values))
+ RETURN_ERROR;
+ paramIndex = _mesa_add_unnamed_constant(parseState->parameters, values);
+ srcReg->Index = paramIndex;
+ srcReg->File = PROGRAM_NAMED_PARAM;
+ needSuffix = GL_FALSE;
+ }
+ else {
+ RETURN_ERROR2("Invalid scalar source argument", token);
+ }
+
+ srcReg->Swizzle = 0;
+ if (needSuffix) {
+ /* parse .[xyzw] suffix */
+ if (!Parse_String(parseState, "."))
+ RETURN_ERROR1("Expected .");
+
+ if (!Parse_Token(parseState, token))
+ RETURN_ERROR;
+
+ if (token[0] == 'x' && token[1] == 0) {
+ srcReg->Swizzle = 0;
+ }
+ else if (token[0] == 'y' && token[1] == 0) {
+ srcReg->Swizzle = 1;
+ }
+ else if (token[0] == 'z' && token[1] == 0) {
+ srcReg->Swizzle = 2;
+ }
+ else if (token[0] == 'w' && token[1] == 0) {
+ srcReg->Swizzle = 3;
+ }
+ else {
+ RETURN_ERROR1("Invalid scalar source suffix");
+ }
+ }
+
+ /* Finish absolute value */
+ if (srcReg->Abs && !Parse_String(parseState, "|")) {
+ RETURN_ERROR1("Expected |");
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+Parse_PrintInstruction(struct parse_state *parseState,
+ struct fp_instruction *inst)
+{
+ const GLubyte *str;
+ GLubyte *msg;
+ GLuint len;
+ GLint idx;
+
+ /* The first argument is a literal string 'just like this' */
+ if (!Parse_String(parseState, "'"))
+ RETURN_ERROR1("Expected '");
+
+ str = parseState->pos;
+ for (len = 0; str[len] != '\''; len++) /* find closing quote */
+ ;
+ parseState->pos += len + 1;
+ msg = _mesa_malloc(len + 1);
+
+ _mesa_memcpy(msg, str, len);
+ msg[len] = 0;
+ inst->Data = msg;
+
+ if (Parse_String(parseState, ",")) {
+ /* got an optional register to print */
+ GLubyte token[100];
+ GetToken(parseState, token);
+ if (token[0] == 'o') {
+ /* dst reg */
+ if (!Parse_OutputReg(parseState, &idx))
+ RETURN_ERROR;
+ inst->SrcReg[0].Index = idx;
+ inst->SrcReg[0].File = PROGRAM_OUTPUT;
+ }
+ else {
+ /* src reg */
+ if (!Parse_VectorSrc(parseState, &inst->SrcReg[0]))
+ RETURN_ERROR;
+ }
+ }
+ else {
+ /* File = 0 indicates no register to print */
+ inst->SrcReg[0].File = PROGRAM_UNDEFINED;
+ }
+
+ inst->SrcReg[0].Swizzle = SWIZZLE_NOOP;
+ inst->SrcReg[0].NegateBase = GL_FALSE;
+ inst->SrcReg[0].Abs = GL_FALSE;
+ inst->SrcReg[0].NegateAbs = GL_FALSE;
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+Parse_InstructionSequence(struct parse_state *parseState,
+ struct fp_instruction program[])
+{
+ while (1) {
+ struct fp_instruction *inst = program + parseState->numInst;
+ struct instruction_pattern instMatch;
+ GLubyte token[100];
+
+ /* Initialize the instruction */
+ inst->SrcReg[0].File = PROGRAM_UNDEFINED;
+ inst->SrcReg[1].File = PROGRAM_UNDEFINED;
+ inst->SrcReg[2].File = PROGRAM_UNDEFINED;
+ inst->DstReg.File = PROGRAM_UNDEFINED;
+ inst->DstReg.CondSwizzle = SWIZZLE_NOOP;
+ inst->Data = NULL;
+
+ /* special instructions */
+ if (Parse_String(parseState, "DEFINE")) {
+ GLubyte id[100];
+ GLfloat value[7]; /* yes, 7 to be safe */
+ if (!Parse_Identifier(parseState, id))
+ RETURN_ERROR;
+ /* XXX make sure id is not a reserved identifer, like R9 */
+ if (!Parse_String(parseState, "="))
+ RETURN_ERROR1("Expected =");
+ if (!Parse_VectorOrScalarConstant(parseState, value))
+ RETURN_ERROR;
+ if (!Parse_String(parseState, ";"))
+ RETURN_ERROR1("Expected ;");
+ if (_mesa_lookup_parameter_index(parseState->parameters,
+ -1, (const char *) id) >= 0) {
+ RETURN_ERROR2(id, "already defined");
+ }
+ _mesa_add_named_parameter(parseState->parameters,
+ (const char *) id, value);
+ }
+ else if (Parse_String(parseState, "DECLARE")) {
+ GLubyte id[100];
+ GLfloat value[7] = {0, 0, 0, 0, 0, 0, 0}; /* yes, to be safe */
+ if (!Parse_Identifier(parseState, id))
+ RETURN_ERROR;
+ /* XXX make sure id is not a reserved identifer, like R9 */
+ if (Parse_String(parseState, "=")) {
+ if (!Parse_VectorOrScalarConstant(parseState, value))
+ RETURN_ERROR;
+ }
+ if (!Parse_String(parseState, ";"))
+ RETURN_ERROR1("Expected ;");
+ if (_mesa_lookup_parameter_index(parseState->parameters,
+ -1, (const char *) id) >= 0) {
+ RETURN_ERROR2(id, "already declared");
+ }
+ _mesa_add_named_parameter(parseState->parameters,
+ (const char *) id, value);
+ }
+ else if (Parse_String(parseState, "END")) {
+ inst->Opcode = FP_OPCODE_END;
+ inst->StringPos = parseState->curLine - parseState->start;
+ assert(inst->StringPos >= 0);
+ parseState->numInst++;
+ if (Parse_Token(parseState, token)) {
+ RETURN_ERROR1("Code after END opcode.");
+ }
+ break;
+ }
+ else {
+ /* general/arithmetic instruction */
+
+ /* get token */
+ if (!Parse_Token(parseState, token)) {
+ RETURN_ERROR1("Missing END instruction.");
+ }
+
+ /* try to find matching instuction */
+ instMatch = MatchInstruction(token);
+ if (instMatch.opcode < 0) {
+ /* bad instruction name */
+ RETURN_ERROR2("Unexpected token: ", token);
+ }
+
+ inst->Opcode = instMatch.opcode;
+ inst->Precision = instMatch.suffixes & (_R | _H | _X);
+ inst->Saturate = (instMatch.suffixes & (_S)) ? GL_TRUE : GL_FALSE;
+ inst->UpdateCondRegister = (instMatch.suffixes & (_C)) ? GL_TRUE : GL_FALSE;
+ inst->StringPos = parseState->curLine - parseState->start;
+ assert(inst->StringPos >= 0);
+
+ /*
+ * parse the input and output operands
+ */
+ if (instMatch.outputs == OUTPUT_S || instMatch.outputs == OUTPUT_V) {
+ if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
+ RETURN_ERROR;
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR1("Expected ,");
+ }
+ else if (instMatch.outputs == OUTPUT_NONE) {
+ if (instMatch.opcode == FP_OPCODE_KIL_NV) {
+ /* This is a little weird, the cond code info is in
+ * the dest register.
+ */
+ if (!Parse_CondCodeMask(parseState, &inst->DstReg))
+ RETURN_ERROR;
+ }
+ else {
+ ASSERT(instMatch.opcode == FP_OPCODE_PRINT);
+ }
+ }
+
+ if (instMatch.inputs == INPUT_1V) {
+ if (!Parse_VectorSrc(parseState, &inst->SrcReg[0]))
+ RETURN_ERROR;
+ }
+ else if (instMatch.inputs == INPUT_2V) {
+ if (!Parse_VectorSrc(parseState, &inst->SrcReg[0]))
+ RETURN_ERROR;
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR1("Expected ,");
+ if (!Parse_VectorSrc(parseState, &inst->SrcReg[1]))
+ RETURN_ERROR;
+ }
+ else if (instMatch.inputs == INPUT_3V) {
+ if (!Parse_VectorSrc(parseState, &inst->SrcReg[0]))
+ RETURN_ERROR;
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR1("Expected ,");
+ if (!Parse_VectorSrc(parseState, &inst->SrcReg[1]))
+ RETURN_ERROR;
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR1("Expected ,");
+ if (!Parse_VectorSrc(parseState, &inst->SrcReg[2]))
+ RETURN_ERROR;
+ }
+ else if (instMatch.inputs == INPUT_1S) {
+ if (!Parse_ScalarSrcReg(parseState, &inst->SrcReg[0]))
+ RETURN_ERROR;
+ }
+ else if (instMatch.inputs == INPUT_2S) {
+ if (!Parse_ScalarSrcReg(parseState, &inst->SrcReg[0]))
+ RETURN_ERROR;
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR1("Expected ,");
+ if (!Parse_ScalarSrcReg(parseState, &inst->SrcReg[1]))
+ RETURN_ERROR;
+ }
+ else if (instMatch.inputs == INPUT_CC) {
+ /* XXX to-do */
+ }
+ else if (instMatch.inputs == INPUT_1V_T) {
+ GLubyte unit, idx;
+ if (!Parse_VectorSrc(parseState, &inst->SrcReg[0]))
+ RETURN_ERROR;
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR1("Expected ,");
+ if (!Parse_TextureImageId(parseState, &unit, &idx))
+ RETURN_ERROR;
+ inst->TexSrcUnit = unit;
+ inst->TexSrcIdx = idx;
+ }
+ else if (instMatch.inputs == INPUT_3V_T) {
+ GLubyte unit, idx;
+ if (!Parse_VectorSrc(parseState, &inst->SrcReg[0]))
+ RETURN_ERROR;
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR1("Expected ,");
+ if (!Parse_VectorSrc(parseState, &inst->SrcReg[1]))
+ RETURN_ERROR;
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR1("Expected ,");
+ if (!Parse_VectorSrc(parseState, &inst->SrcReg[2]))
+ RETURN_ERROR;
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR1("Expected ,");
+ if (!Parse_TextureImageId(parseState, &unit, &idx))
+ RETURN_ERROR;
+ inst->TexSrcUnit = unit;
+ inst->TexSrcIdx = idx;
+ }
+ else if (instMatch.inputs == INPUT_1V_S) {
+ if (!Parse_PrintInstruction(parseState, inst))
+ RETURN_ERROR;
+ }
+
+ /* end of statement semicolon */
+ if (!Parse_String(parseState, ";"))
+ RETURN_ERROR1("Expected ;");
+
+ parseState->numInst++;
+
+ if (parseState->numInst >= MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS)
+ RETURN_ERROR1("Program too long");
+ }
+ }
+ return GL_TRUE;
+}
+
+
+
+/**
+ * Parse/compile the 'str' returning the compiled 'program'.
+ * ctx->Program.ErrorPos will be -1 if successful. Otherwise, ErrorPos
+ * indicates the position of the error in 'str'.
+ */
+void
+_mesa_parse_nv_fragment_program(GLcontext *ctx, GLenum dstTarget,
+ const GLubyte *str, GLsizei len,
+ struct fragment_program *program)
+{
+ struct parse_state parseState;
+ struct fp_instruction instBuffer[MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS];
+ struct fp_instruction *newInst;
+ GLenum target;
+ GLubyte *programString;
+
+ /* Make a null-terminated copy of the program string */
+ programString = (GLubyte *) MALLOC(len + 1);
+ if (!programString) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
+ return;
+ }
+ MEMCPY(programString, str, len);
+ programString[len] = 0;
+
+ /* Get ready to parse */
+ _mesa_bzero(&parseState, sizeof(struct parse_state));
+ parseState.ctx = ctx;
+ parseState.start = programString;
+ parseState.program = program;
+ parseState.numInst = 0;
+ parseState.curLine = programString;
+ parseState.parameters = _mesa_new_parameter_list();
+
+ /* Reset error state */
+ _mesa_set_program_error(ctx, -1, NULL);
+
+ /* check the program header */
+ if (_mesa_strncmp((const char *) programString, "!!FP1.0", 7) == 0) {
+ target = GL_FRAGMENT_PROGRAM_NV;
+ parseState.pos = programString + 7;
+ }
+ else if (_mesa_strncmp((const char *) programString, "!!FCP1.0", 8) == 0) {
+ /* fragment / register combiner program - not supported */
+ _mesa_set_program_error(ctx, 0, "Invalid fragment program header");
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV(bad header)");
+ return;
+ }
+ else {
+ /* invalid header */
+ _mesa_set_program_error(ctx, 0, "Invalid fragment program header");
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV(bad header)");
+ return;
+ }
+
+ /* make sure target and header match */
+ if (target != dstTarget) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glLoadProgramNV(target mismatch 0x%x != 0x%x)",
+ target, dstTarget);
+ return;
+ }
+
+ if (Parse_InstructionSequence(&parseState, instBuffer)) {
+ GLuint u;
+ /* successful parse! */
+
+ if (parseState.outputsWritten == 0) {
+ /* must write at least one output! */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "Invalid fragment program - no outputs written.");
+ return;
+ }
+
+ /* copy the compiled instructions */
+ assert(parseState.numInst <= MAX_NV_FRAGMENT_PROGRAM_INSTRUCTIONS);
+ newInst = (struct fp_instruction *)
+ MALLOC(parseState.numInst * sizeof(struct fp_instruction));
+ if (!newInst) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
+ return; /* out of memory */
+ }
+ MEMCPY(newInst, instBuffer,
+ parseState.numInst * sizeof(struct fp_instruction));
+
+ /* install the program */
+ program->Base.Target = target;
+ if (program->Base.String) {
+ FREE(program->Base.String);
+ }
+ program->Base.String = programString;
+ program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB;
+ if (program->Instructions) {
+ FREE(program->Instructions);
+ }
+ program->Instructions = newInst;
+ program->InputsRead = parseState.inputsRead;
+ program->OutputsWritten = parseState.outputsWritten;
+ for (u = 0; u < ctx->Const.MaxTextureImageUnits; u++)
+ program->TexturesUsed[u] = parseState.texturesUsed[u];
+
+ /* save program parameters */
+ program->Parameters = parseState.parameters;
+
+ /* allocate registers for declared program parameters */
+#if 00
+ _mesa_assign_program_registers(&(program->SymbolTable));
+#endif
+
+#ifdef DEBUG_foo
+ _mesa_printf("--- glLoadProgramNV(%d) result ---\n", program->Base.Id);
+ _mesa_print_nv_fragment_program(program);
+ _mesa_printf("----------------------------------\n");
+#endif
+ }
+ else {
+ /* Error! */
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV");
+ /* NOTE: _mesa_set_program_error would have been called already */
+ }
+}
+
+
+static void
+PrintSrcReg(const struct fragment_program *program,
+ const struct fp_src_register *src)
+{
+ static const char comps[5] = "xyzw";
+
+ if (src->NegateAbs) {
+ _mesa_printf("-");
+ }
+ if (src->Abs) {
+ _mesa_printf("|");
+ }
+ if (src->NegateBase) {
+ _mesa_printf("-");
+ }
+ if (src->File == PROGRAM_NAMED_PARAM) {
+ if (program->Parameters->Parameters[src->Index].Type == CONSTANT) {
+ _mesa_printf("{%g, %g, %g, %g}",
+ program->Parameters->ParameterValues[src->Index][0],
+ program->Parameters->ParameterValues[src->Index][1],
+ program->Parameters->ParameterValues[src->Index][2],
+ program->Parameters->ParameterValues[src->Index][3]);
+ }
+ else {
+ ASSERT(program->Parameters->Parameters[src->Index].Type
+ == NAMED_PARAMETER);
+ _mesa_printf("%s", program->Parameters->Parameters[src->Index].Name);
+ }
+ }
+ else if (src->File == PROGRAM_OUTPUT) {
+ _mesa_printf("o[%s]", OutputRegisters[src->Index]);
+ }
+ else if (src->File == PROGRAM_INPUT) {
+ _mesa_printf("f[%s]", InputRegisters[src->Index]);
+ }
+ else if (src->File == PROGRAM_LOCAL_PARAM) {
+ _mesa_printf("p[%d]", src->Index);
+ }
+ else if (src->File == PROGRAM_TEMPORARY) {
+ if (src->Index >= 32)
+ _mesa_printf("H%d", src->Index);
+ else
+ _mesa_printf("R%d", src->Index);
+ }
+ else if (src->File == PROGRAM_WRITE_ONLY) {
+ _mesa_printf("%cC", "HR"[src->Index]);
+ }
+ else {
+ _mesa_problem(NULL, "Invalid fragment register %d", src->Index);
+ return;
+ }
+ if (GET_SWZ(src->Swizzle, 0) == GET_SWZ(src->Swizzle, 1) &&
+ GET_SWZ(src->Swizzle, 0) == GET_SWZ(src->Swizzle, 2) &&
+ GET_SWZ(src->Swizzle, 0) == GET_SWZ(src->Swizzle, 3)) {
+ _mesa_printf(".%c", comps[GET_SWZ(src->Swizzle, 0)]);
+ }
+ else if (src->Swizzle != SWIZZLE_NOOP) {
+ _mesa_printf(".%c%c%c%c",
+ comps[GET_SWZ(src->Swizzle, 0)],
+ comps[GET_SWZ(src->Swizzle, 1)],
+ comps[GET_SWZ(src->Swizzle, 2)],
+ comps[GET_SWZ(src->Swizzle, 3)]);
+ }
+ if (src->Abs) {
+ _mesa_printf("|");
+ }
+}
+
+static void
+PrintTextureSrc(const struct fp_instruction *inst)
+{
+ _mesa_printf("TEX%d, ", inst->TexSrcUnit);
+ switch (inst->TexSrcIdx) {
+ case TEXTURE_1D_INDEX:
+ _mesa_printf("1D");
+ break;
+ case TEXTURE_2D_INDEX:
+ _mesa_printf("2D");
+ break;
+ case TEXTURE_3D_INDEX:
+ _mesa_printf("3D");
+ break;
+ case TEXTURE_RECT_INDEX:
+ _mesa_printf("RECT");
+ break;
+ case TEXTURE_CUBE_INDEX:
+ _mesa_printf("CUBE");
+ break;
+ default:
+ _mesa_problem(NULL, "Invalid textue target in PrintTextureSrc");
+ }
+}
+
+static void
+PrintCondCode(const struct fp_dst_register *dst)
+{
+ static const char *comps = "xyzw";
+ static const char *ccString[] = {
+ "??", "GT", "EQ", "LT", "UN", "GE", "LE", "NE", "TR", "FL", "??"
+ };
+
+ _mesa_printf("%s", ccString[dst->CondMask]);
+ if (GET_SWZ(dst->CondSwizzle, 0) == GET_SWZ(dst->CondSwizzle, 1) &&
+ GET_SWZ(dst->CondSwizzle, 0) == GET_SWZ(dst->CondSwizzle, 2) &&
+ GET_SWZ(dst->CondSwizzle, 0) == GET_SWZ(dst->CondSwizzle, 3)) {
+ _mesa_printf(".%c", comps[GET_SWZ(dst->CondSwizzle, 0)]);
+ }
+ else if (dst->CondSwizzle != SWIZZLE_NOOP) {
+ _mesa_printf(".%c%c%c%c",
+ comps[GET_SWZ(dst->CondSwizzle, 0)],
+ comps[GET_SWZ(dst->CondSwizzle, 1)],
+ comps[GET_SWZ(dst->CondSwizzle, 2)],
+ comps[GET_SWZ(dst->CondSwizzle, 3)]);
+ }
+}
+
+
+static void
+PrintDstReg(const struct fp_dst_register *dst)
+{
+ if (dst->File == PROGRAM_OUTPUT) {
+ _mesa_printf("o[%s]", OutputRegisters[dst->Index]);
+ }
+ else if (dst->File == PROGRAM_TEMPORARY) {
+ if (dst->Index >= 32)
+ _mesa_printf("H%d", dst->Index);
+ else
+ _mesa_printf("R%d", dst->Index);
+ }
+ else if (dst->File == PROGRAM_LOCAL_PARAM) {
+ _mesa_printf("p[%d]", dst->Index);
+ }
+ else if (dst->File == PROGRAM_WRITE_ONLY) {
+ _mesa_printf("%cC", "HR"[dst->Index]);
+ }
+ else {
+ _mesa_printf("???");
+ }
+
+ if (dst->WriteMask != 0 && dst->WriteMask != 0xf) {
+ _mesa_printf(".");
+ if (dst->WriteMask & 0x1)
+ _mesa_printf("x");
+ if (dst->WriteMask & 0x2)
+ _mesa_printf("y");
+ if (dst->WriteMask & 0x4)
+ _mesa_printf("z");
+ if (dst->WriteMask & 0x8)
+ _mesa_printf("w");
+ }
+
+ if (dst->CondMask != COND_TR ||
+ dst->CondSwizzle != SWIZZLE_NOOP) {
+ _mesa_printf(" (");
+ PrintCondCode(dst);
+ _mesa_printf(")");
+ }
+}
+
+
+/**
+ * Print (unparse) the given vertex program. Just for debugging.
+ */
+void
+_mesa_print_nv_fragment_program(const struct fragment_program *program)
+{
+ const struct fp_instruction *inst;
+
+ for (inst = program->Instructions; inst->Opcode != FP_OPCODE_END; inst++) {
+ int i;
+ for (i = 0; Instructions[i].name; i++) {
+ if (inst->Opcode == Instructions[i].opcode) {
+ /* print instruction name */
+ _mesa_printf("%s", Instructions[i].name);
+ if (inst->Precision == FLOAT16)
+ _mesa_printf("H");
+ else if (inst->Precision == FIXED12)
+ _mesa_printf("X");
+ if (inst->UpdateCondRegister)
+ _mesa_printf("C");
+ if (inst->Saturate)
+ _mesa_printf("_SAT");
+ _mesa_printf(" ");
+
+ if (Instructions[i].inputs == INPUT_CC) {
+ PrintCondCode(&inst->DstReg);
+ }
+ else if (Instructions[i].outputs == OUTPUT_V ||
+ Instructions[i].outputs == OUTPUT_S) {
+ /* print dest register */
+ PrintDstReg(&inst->DstReg);
+ _mesa_printf(", ");
+ }
+
+ /* print source register(s) */
+ if (Instructions[i].inputs == INPUT_1V ||
+ Instructions[i].inputs == INPUT_1S) {
+ PrintSrcReg(program, &inst->SrcReg[0]);
+ }
+ else if (Instructions[i].inputs == INPUT_2V ||
+ Instructions[i].inputs == INPUT_2S) {
+ PrintSrcReg(program, &inst->SrcReg[0]);
+ _mesa_printf(", ");
+ PrintSrcReg(program, &inst->SrcReg[1]);
+ }
+ else if (Instructions[i].inputs == INPUT_3V) {
+ PrintSrcReg(program, &inst->SrcReg[0]);
+ _mesa_printf(", ");
+ PrintSrcReg(program, &inst->SrcReg[1]);
+ _mesa_printf(", ");
+ PrintSrcReg(program, &inst->SrcReg[2]);
+ }
+ else if (Instructions[i].inputs == INPUT_1V_T) {
+ PrintSrcReg(program, &inst->SrcReg[0]);
+ _mesa_printf(", ");
+ PrintTextureSrc(inst);
+ }
+ else if (Instructions[i].inputs == INPUT_3V_T) {
+ PrintSrcReg(program, &inst->SrcReg[0]);
+ _mesa_printf(", ");
+ PrintSrcReg(program, &inst->SrcReg[1]);
+ _mesa_printf(", ");
+ PrintSrcReg(program, &inst->SrcReg[2]);
+ _mesa_printf(", ");
+ PrintTextureSrc(inst);
+ }
+ _mesa_printf(";\n");
+ break;
+ }
+ }
+ if (!Instructions[i].name) {
+ _mesa_printf("Invalid opcode %d\n", inst->Opcode);
+ }
+ }
+ _mesa_printf("END\n");
+}
+
+
+const char *
+_mesa_nv_fragment_input_register_name(GLuint i)
+{
+ ASSERT(i < MAX_NV_FRAGMENT_PROGRAM_INPUTS);
+ return InputRegisters[i];
+}
+
+
+const char *
+_mesa_nv_fragment_output_register_name(GLuint i)
+{
+ ASSERT(i < MAX_NV_FRAGMENT_PROGRAM_OUTPUTS);
+ return OutputRegisters[i];
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/nvfragparse.h b/nx-X11/extras/Mesa/src/mesa/shader/nvfragparse.h
new file mode 100644
index 000000000..849a7fbc7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/nvfragparse.h
@@ -0,0 +1,52 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2002 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.
+ *
+ * Authors:
+ * Brian Paul
+ */
+
+
+#ifndef NVFRAGPARSE_H
+#define NVFRAGPARSE_H
+
+
+extern void
+_mesa_parse_nv_fragment_program(GLcontext *ctx, GLenum target,
+ const GLubyte *str, GLsizei len,
+ struct fragment_program *program);
+
+
+extern void
+_mesa_print_nv_fragment_program(const struct fragment_program *program);
+
+
+extern const char *
+_mesa_nv_fragment_input_register_name(GLuint i);
+
+
+extern const char *
+_mesa_nv_fragment_output_register_name(GLuint i);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/nvfragprog.h b/nx-X11/extras/Mesa/src/mesa/shader/nvfragprog.h
new file mode 100644
index 000000000..a7149cfdb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/nvfragprog.h
@@ -0,0 +1,168 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+/* Private fragment program types and constants only used by files
+ * related to fragment programs.
+ *
+ * XXX TO-DO: Rename this file "fragprog.h" since it's not NV-specific.
+ */
+
+
+#ifndef NVFRAGPROG_H
+#define NVFRAGPROG_H
+
+#include "config.h"
+#include "mtypes.h"
+
+/* output registers */
+#define FRAG_OUTPUT_COLR 0
+#define FRAG_OUTPUT_COLH 1
+#define FRAG_OUTPUT_DEPR 2
+
+
+/* condition codes */
+#define COND_GT 1 /* greater than zero */
+#define COND_EQ 2 /* equal to zero */
+#define COND_LT 3 /* less than zero */
+#define COND_UN 4 /* unordered (NaN) */
+#define COND_GE 5 /* greater then or equal to zero */
+#define COND_LE 6 /* less then or equal to zero */
+#define COND_NE 7 /* not equal to zero */
+#define COND_TR 8 /* always true */
+#define COND_FL 9 /* always false */
+
+
+/* instruction precision */
+#define FLOAT32 0x1
+#define FLOAT16 0x2
+#define FIXED12 0x4
+
+
+/* Fragment program instruction opcodes */
+enum fp_opcode {
+ FP_OPCODE_ABS, /* ARB_f_p only */
+ FP_OPCODE_ADD,
+ FP_OPCODE_CMP, /* ARB_f_p only */
+ FP_OPCODE_COS,
+ FP_OPCODE_DDX, /* NV_f_p only */
+ FP_OPCODE_DDY, /* NV_f_p only */
+ FP_OPCODE_DP3,
+ FP_OPCODE_DP4,
+ FP_OPCODE_DPH, /* ARB_f_p only */
+ FP_OPCODE_DST,
+ FP_OPCODE_END, /* private opcode */
+ FP_OPCODE_EX2,
+ FP_OPCODE_FLR,
+ FP_OPCODE_FRC,
+ FP_OPCODE_KIL, /* ARB_f_p only */
+ FP_OPCODE_KIL_NV, /* NV_f_p only */
+ FP_OPCODE_LG2,
+ FP_OPCODE_LIT,
+ FP_OPCODE_LRP,
+ FP_OPCODE_MAD,
+ FP_OPCODE_MAX,
+ FP_OPCODE_MIN,
+ FP_OPCODE_MOV,
+ FP_OPCODE_MUL,
+ FP_OPCODE_PK2H, /* NV_f_p only */
+ FP_OPCODE_PK2US, /* NV_f_p only */
+ FP_OPCODE_PK4B, /* NV_f_p only */
+ FP_OPCODE_PK4UB, /* NV_f_p only */
+ FP_OPCODE_POW,
+ FP_OPCODE_PRINT, /* Mesa only */
+ FP_OPCODE_RCP,
+ FP_OPCODE_RFL, /* NV_f_p only */
+ FP_OPCODE_RSQ,
+ FP_OPCODE_SCS, /* ARB_f_p only */
+ FP_OPCODE_SEQ, /* NV_f_p only */
+ FP_OPCODE_SFL, /* NV_f_p only */
+ FP_OPCODE_SGE, /* NV_f_p only */
+ FP_OPCODE_SGT, /* NV_f_p only */
+ FP_OPCODE_SIN,
+ FP_OPCODE_SLE, /* NV_f_p only */
+ FP_OPCODE_SLT,
+ FP_OPCODE_SNE, /* NV_f_p only */
+ FP_OPCODE_STR, /* NV_f_p only */
+ FP_OPCODE_SUB,
+ FP_OPCODE_SWZ, /* ARB_f_p only */
+ FP_OPCODE_TEX,
+ FP_OPCODE_TXB, /* ARB_f_p only */
+ FP_OPCODE_TXD, /* NV_f_p only */
+ FP_OPCODE_TXP, /* ARB_f_p only */
+ FP_OPCODE_TXP_NV, /* NV_f_p only */
+ FP_OPCODE_UP2H, /* NV_f_p only */
+ FP_OPCODE_UP2US, /* NV_f_p only */
+ FP_OPCODE_UP4B, /* NV_f_p only */
+ FP_OPCODE_UP4UB, /* NV_f_p only */
+ FP_OPCODE_X2D, /* NV_f_p only - 2d mat mul */
+ FP_OPCODE_XPD /* ARB_f_p only - cross product */
+};
+
+
+/* Instruction source register */
+struct fp_src_register
+{
+ GLuint File:4;
+ GLuint Index:8;
+ GLuint Swizzle:12;
+ GLuint NegateBase:4; /* ARB: negate/extended negate.
+ NV: negate before absolute value? */
+ GLuint Abs:1; /* NV: take absolute value? */
+ GLuint NegateAbs:1; /* NV: negate after absolute value? */
+};
+
+
+/* Instruction destination register */
+struct fp_dst_register
+{
+ GLuint File:4;
+ GLuint Index:8;
+ GLuint WriteMask:4;
+ GLuint CondMask:4; /* NV: enough bits? */
+ GLuint CondSwizzle:12; /* NV: enough bits? */
+};
+
+
+/* Fragment program instruction */
+struct fp_instruction
+{
+ GLuint Opcode:6;
+ GLuint Saturate:1;
+ GLuint UpdateCondRegister:1; /* NV */
+ GLuint Precision:2; /* NV: unused/unneeded? */
+ GLuint TexSrcUnit:4; /* texture unit for TEX, TXD, TXP instructions */
+ GLuint TexSrcIdx:3; /* TEXTURE_1D,2D,3D,CUBE,RECT_INDEX source target */
+
+#if FEATURE_MESA_program_debug
+ GLint StringPos:15; /* enough bits? */
+#endif
+
+ void *Data; /* some arbitrary data, only used for PRINT instruction now */
+ struct fp_src_register SrcReg[3];
+ struct fp_dst_register DstReg;
+};
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/nvprogram.c b/nx-X11/extras/Mesa/src/mesa/shader/nvprogram.c
new file mode 100644
index 000000000..4b8930176
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/nvprogram.c
@@ -0,0 +1,869 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file nvprogram.c
+ * NVIDIA vertex/fragment program state management functions.
+ * \author Brian Paul
+ */
+
+/*
+ * Regarding GL_NV_fragment/vertex_program, GL_NV_vertex_program1_1, etc:
+ *
+ * Portions of this software may use or implement intellectual
+ * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims
+ * any and all warranties with respect to such intellectual property,
+ * including any use thereof or modifications thereto.
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "hash.h"
+#include "imports.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "nvfragparse.h"
+#include "nvfragprog.h"
+#include "nvvertexec.h"
+#include "nvvertparse.h"
+#include "nvvertprog.h"
+#include "nvprogram.h"
+#include "program.h"
+
+
+
+/**
+ * Execute a vertex state program.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params)
+{
+ struct vertex_program *vprog;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target != GL_VERTEX_STATE_PROGRAM_NV) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glExecuteProgramNV");
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+
+ vprog = (struct vertex_program *)
+ _mesa_HashLookup(ctx->Shared->Programs, id);
+
+ if (!vprog || vprog->Base.Target != GL_VERTEX_STATE_PROGRAM_NV) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glExecuteProgramNV");
+ return;
+ }
+
+ _mesa_init_vp_per_vertex_registers(ctx);
+ _mesa_init_vp_per_primitive_registers(ctx);
+ COPY_4V(ctx->VertexProgram.Inputs[VERT_ATTRIB_POS], params);
+ _mesa_exec_vertex_program(ctx, vprog);
+}
+
+
+/**
+ * Determine if a set of programs is resident in hardware.
+ * \note Not compiled into display lists.
+ * \note Called from the GL API dispatcher.
+ */
+GLboolean GLAPIENTRY _mesa_AreProgramsResidentNV(GLsizei n, const GLuint *ids,
+ GLboolean *residences)
+{
+ GLint i, j;
+ GLboolean allResident = GL_TRUE;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+
+ if (n < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glAreProgramsResidentNV(n)");
+ return GL_FALSE;
+ }
+
+ for (i = 0; i < n; i++) {
+ const struct program *prog;
+ if (ids[i] == 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glAreProgramsResidentNV");
+ return GL_FALSE;
+ }
+ prog = (const struct program *)
+ _mesa_HashLookup(ctx->Shared->Programs, ids[i]);
+ if (!prog) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glAreProgramsResidentNV");
+ return GL_FALSE;
+ }
+ if (prog->Resident) {
+ if (!allResident)
+ residences[i] = GL_TRUE;
+ }
+ else {
+ if (allResident) {
+ allResident = GL_FALSE;
+ for (j = 0; j < i; j++)
+ residences[j] = GL_TRUE;
+ }
+ residences[i] = GL_FALSE;
+ }
+ }
+
+ return allResident;
+}
+
+
+/**
+ * Request that a set of programs be resident in hardware.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_RequestResidentProgramsNV(GLsizei n, const GLuint *ids)
+{
+ GLint i;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (n < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glRequestResidentProgramsNV(n)");
+ return;
+ }
+
+ /* just error checking for now */
+ for (i = 0; i < n; i++) {
+ struct program *prog;
+
+ if (ids[i] == 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glRequestResidentProgramsNV(id)");
+ return;
+ }
+
+ prog = (struct program *) _mesa_HashLookup(ctx->Shared->Programs, ids[i]);
+ if (!prog) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glRequestResidentProgramsNV(id)");
+ return;
+ }
+
+ /* XXX this is really a hardware thing we should hook out */
+ prog->Resident = GL_TRUE;
+ }
+}
+
+
+/**
+ * Get a program parameter register.
+ * \note Not compiled into display lists.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_GetProgramParameterfvNV(GLenum target, GLuint index,
+ GLenum pname, GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target == GL_VERTEX_PROGRAM_NV) {
+ if (pname == GL_PROGRAM_PARAMETER_NV) {
+ if (index < MAX_NV_VERTEX_PROGRAM_PARAMS) {
+ COPY_4V(params, ctx->VertexProgram.Parameters[index]);
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetProgramParameterfvNV(index)");
+ return;
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterfvNV(pname)");
+ return;
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterfvNV(target)");
+ return;
+ }
+}
+
+
+/**
+ * Get a program parameter register.
+ * \note Not compiled into display lists.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_GetProgramParameterdvNV(GLenum target, GLuint index,
+ GLenum pname, GLdouble *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target == GL_VERTEX_PROGRAM_NV) {
+ if (pname == GL_PROGRAM_PARAMETER_NV) {
+ if (index < MAX_NV_VERTEX_PROGRAM_PARAMS) {
+ COPY_4V(params, ctx->VertexProgram.Parameters[index]);
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetProgramParameterdvNV(index)");
+ return;
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterdvNV(pname)");
+ return;
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramParameterdvNV(target)");
+ return;
+ }
+}
+
+
+/**
+ * Get a program attribute.
+ * \note Not compiled into display lists.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_GetProgramivNV(GLuint id, GLenum pname, GLint *params)
+{
+ struct program *prog;
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->_CurrentProgram)
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ prog = (struct program *) _mesa_HashLookup(ctx->Shared->Programs, id);
+ if (!prog) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramivNV");
+ return;
+ }
+
+ switch (pname) {
+ case GL_PROGRAM_TARGET_NV:
+ *params = prog->Target;
+ return;
+ case GL_PROGRAM_LENGTH_NV:
+ *params = prog->String ?(GLint)_mesa_strlen((char *) prog->String) : 0;
+ return;
+ case GL_PROGRAM_RESIDENT_NV:
+ *params = prog->Resident;
+ return;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramivNV(pname)");
+ return;
+ }
+}
+
+
+/**
+ * Get the program source code.
+ * \note Not compiled into display lists.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_GetProgramStringNV(GLuint id, GLenum pname, GLubyte *program)
+{
+ struct program *prog;
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->_CurrentProgram)
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (pname != GL_PROGRAM_STRING_NV) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramStringNV(pname)");
+ return;
+ }
+
+ prog = (struct program *) _mesa_HashLookup(ctx->Shared->Programs, id);
+ if (!prog) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramStringNV");
+ return;
+ }
+
+ if (prog->String) {
+ MEMCPY(program, prog->String, _mesa_strlen((char *) prog->String));
+ }
+ else {
+ program[0] = 0;
+ }
+}
+
+
+/**
+ * Get matrix tracking information.
+ * \note Not compiled into display lists.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_GetTrackMatrixivNV(GLenum target, GLuint address,
+ GLenum pname, GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target == GL_VERTEX_PROGRAM_NV
+ && ctx->Extensions.NV_vertex_program) {
+ GLuint i;
+
+ if ((address & 0x3) || address >= MAX_NV_VERTEX_PROGRAM_PARAMS) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetTrackMatrixivNV(address)");
+ return;
+ }
+
+ i = address / 4;
+
+ switch (pname) {
+ case GL_TRACK_MATRIX_NV:
+ params[0] = (GLint) ctx->VertexProgram.TrackMatrix[i];
+ return;
+ case GL_TRACK_MATRIX_TRANSFORM_NV:
+ params[0] = (GLint) ctx->VertexProgram.TrackMatrixTransform[i];
+ return;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTrackMatrixivNV");
+ return;
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetTrackMatrixivNV");
+ return;
+ }
+}
+
+
+/**
+ * Get a vertex (or vertex array) attribute.
+ * \note Not compiled into display lists.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_GetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (index == 0 || index >= MAX_NV_VERTEX_PROGRAM_INPUTS) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribdvNV(index)");
+ return;
+ }
+
+ switch (pname) {
+ case GL_ATTRIB_ARRAY_SIZE_NV:
+ params[0] = ctx->Array.VertexAttrib[index].Size;
+ break;
+ case GL_ATTRIB_ARRAY_STRIDE_NV:
+ params[0] = ctx->Array.VertexAttrib[index].Stride;
+ break;
+ case GL_ATTRIB_ARRAY_TYPE_NV:
+ params[0] = ctx->Array.VertexAttrib[index].Type;
+ break;
+ case GL_CURRENT_ATTRIB_NV:
+ FLUSH_CURRENT(ctx, 0);
+ COPY_4V(params, ctx->Current.Attrib[index]);
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV");
+ return;
+ }
+}
+
+/**
+ * Get a vertex (or vertex array) attribute.
+ * \note Not compiled into display lists.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_GetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (index == 0 || index >= MAX_NV_VERTEX_PROGRAM_INPUTS) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribdvNV(index)");
+ return;
+ }
+
+ switch (pname) {
+ case GL_ATTRIB_ARRAY_SIZE_NV:
+ params[0] = (GLfloat) ctx->Array.VertexAttrib[index].Size;
+ break;
+ case GL_ATTRIB_ARRAY_STRIDE_NV:
+ params[0] = (GLfloat) ctx->Array.VertexAttrib[index].Stride;
+ break;
+ case GL_ATTRIB_ARRAY_TYPE_NV:
+ params[0] = (GLfloat) ctx->Array.VertexAttrib[index].Type;
+ break;
+ case GL_CURRENT_ATTRIB_NV:
+ FLUSH_CURRENT(ctx, 0);
+ COPY_4V(params, ctx->Current.Attrib[index]);
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV");
+ return;
+ }
+}
+
+/**
+ * Get a vertex (or vertex array) attribute.
+ * \note Not compiled into display lists.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_GetVertexAttribivNV(GLuint index, GLenum pname, GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (index == 0 || index >= MAX_NV_VERTEX_PROGRAM_INPUTS) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribdvNV(index)");
+ return;
+ }
+
+ switch (pname) {
+ case GL_ATTRIB_ARRAY_SIZE_NV:
+ params[0] = ctx->Array.VertexAttrib[index].Size;
+ break;
+ case GL_ATTRIB_ARRAY_STRIDE_NV:
+ params[0] = ctx->Array.VertexAttrib[index].Stride;
+ break;
+ case GL_ATTRIB_ARRAY_TYPE_NV:
+ params[0] = ctx->Array.VertexAttrib[index].Type;
+ break;
+ case GL_CURRENT_ATTRIB_NV:
+ FLUSH_CURRENT(ctx, 0);
+ params[0] = (GLint) ctx->Current.Attrib[index][0];
+ params[1] = (GLint) ctx->Current.Attrib[index][1];
+ params[2] = (GLint) ctx->Current.Attrib[index][2];
+ params[3] = (GLint) ctx->Current.Attrib[index][3];
+ break;
+ case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB:
+ if (!ctx->Extensions.ARB_vertex_buffer_object) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV");
+ return;
+ }
+ params[0] = ctx->Array.VertexAttrib[index].BufferObj->Name;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribdvNV");
+ return;
+ }
+}
+
+
+/**
+ * Get a vertex array attribute pointer.
+ * \note Not compiled into display lists.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_GetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid **pointer)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (index >= MAX_NV_VERTEX_PROGRAM_INPUTS) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetVertexAttribPointerNV(index)");
+ return;
+ }
+
+ if (pname != GL_ATTRIB_ARRAY_POINTER_NV) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetVertexAttribPointerNV(pname)");
+ return;
+ }
+
+ *pointer = (GLvoid *) ctx->Array.VertexAttrib[index].Ptr;;
+}
+
+
+
+/**
+ * Load/parse/compile a program.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len,
+ const GLubyte *program)
+{
+ struct program *prog;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (id == 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glLoadProgramNV(id)");
+ return;
+ }
+
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+
+ prog = (struct program *) _mesa_HashLookup(ctx->Shared->Programs, id);
+
+ if (prog && prog->Target != 0 && prog->Target != target) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV(target)");
+ return;
+ }
+
+ if ((target == GL_VERTEX_PROGRAM_NV ||
+ target == GL_VERTEX_STATE_PROGRAM_NV)
+ && ctx->Extensions.NV_vertex_program) {
+ struct vertex_program *vprog = (struct vertex_program *) prog;
+ if (!vprog || prog == &_mesa_DummyProgram) {
+ vprog = (struct vertex_program *)
+ ctx->Driver.NewProgram(ctx, target, id);
+ if (!vprog) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
+ return;
+ }
+ _mesa_HashInsert(ctx->Shared->Programs, id, vprog);
+ }
+ _mesa_parse_nv_vertex_program(ctx, target, program, len, vprog);
+ }
+ else if (target == GL_FRAGMENT_PROGRAM_NV
+ && ctx->Extensions.NV_fragment_program) {
+ struct fragment_program *fprog = (struct fragment_program *) prog;
+ if (!fprog || prog == &_mesa_DummyProgram) {
+ fprog = (struct fragment_program *)
+ ctx->Driver.NewProgram(ctx, target, id);
+ if (!fprog) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
+ return;
+ }
+ _mesa_HashInsert(ctx->Shared->Programs, id, fprog);
+ }
+ _mesa_parse_nv_fragment_program(ctx, target, program, len, fprog);
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glLoadProgramNV(target)");
+ }
+}
+
+
+
+/**
+ * Set a program parameter register.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_ProgramParameter4dNV(GLenum target, GLuint index,
+ GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ _mesa_ProgramParameter4fNV(target, index,
+ (GLfloat)x, (GLfloat)y, (GLfloat)z, (GLfloat)w);
+}
+
+
+/**
+ * Set a program parameter register.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_ProgramParameter4dvNV(GLenum target, GLuint index,
+ const GLdouble *params)
+{
+ _mesa_ProgramParameter4fNV(target, index,
+ (GLfloat)params[0], (GLfloat)params[1],
+ (GLfloat)params[2], (GLfloat)params[3]);
+}
+
+
+/**
+ * Set a program parameter register.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_ProgramParameter4fNV(GLenum target, GLuint index,
+ GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) {
+ if (index < MAX_NV_VERTEX_PROGRAM_PARAMS) {
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+ ASSIGN_4V(ctx->VertexProgram.Parameters[index], x, y, z, w);
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glProgramParameterNV(index)");
+ return;
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameterNV");
+ return;
+ }
+}
+
+
+/**
+ * Set a program parameter register.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_ProgramParameter4fvNV(GLenum target, GLuint index,
+ const GLfloat *params)
+{
+ _mesa_ProgramParameter4fNV(target, index,
+ params[0], params[1], params[2], params[3]);
+}
+
+
+
+/**
+ * Set a sequence of program parameter registers.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_ProgramParameters4dvNV(GLenum target, GLuint index,
+ GLuint num, const GLdouble *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) {
+ GLuint i;
+ if (index + num > MAX_NV_VERTEX_PROGRAM_PARAMS) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glProgramParameters4dvNV");
+ return;
+ }
+ for (i = 0; i < num; i++) {
+ ctx->VertexProgram.Parameters[index + i][0] = (GLfloat) params[0];
+ ctx->VertexProgram.Parameters[index + i][1] = (GLfloat) params[1];
+ ctx->VertexProgram.Parameters[index + i][2] = (GLfloat) params[2];
+ ctx->VertexProgram.Parameters[index + i][3] = (GLfloat) params[3];
+ params += 4;
+ };
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameters4dvNV");
+ return;
+ }
+}
+
+
+/**
+ * Set a sequence of program parameter registers.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_ProgramParameters4fvNV(GLenum target, GLuint index,
+ GLuint num, const GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) {
+ GLuint i;
+ if (index + num > MAX_NV_VERTEX_PROGRAM_PARAMS) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glProgramParameters4fvNV");
+ return;
+ }
+ for (i = 0; i < num; i++) {
+ COPY_4V(ctx->VertexProgram.Parameters[index + i], params);
+ params += 4;
+ };
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glProgramParameters4fvNV");
+ return;
+ }
+}
+
+
+
+/**
+ * Setup tracking of matrices into program parameter registers.
+ * \note Called from the GL API dispatcher.
+ */
+void GLAPIENTRY
+_mesa_TrackMatrixNV(GLenum target, GLuint address,
+ GLenum matrix, GLenum transform)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+
+ if (target == GL_VERTEX_PROGRAM_NV && ctx->Extensions.NV_vertex_program) {
+ if (address & 0x3) {
+ /* addr must be multiple of four */
+ _mesa_error(ctx, GL_INVALID_VALUE, "glTrackMatrixNV(address)");
+ return;
+ }
+
+ switch (matrix) {
+ case GL_NONE:
+ case GL_MODELVIEW:
+ case GL_PROJECTION:
+ case GL_TEXTURE:
+ case GL_COLOR:
+ case GL_MODELVIEW_PROJECTION_NV:
+ case GL_MATRIX0_NV:
+ case GL_MATRIX1_NV:
+ case GL_MATRIX2_NV:
+ case GL_MATRIX3_NV:
+ case GL_MATRIX4_NV:
+ case GL_MATRIX5_NV:
+ case GL_MATRIX6_NV:
+ case GL_MATRIX7_NV:
+ /* OK, fallthrough */
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTrackMatrixNV(matrix)");
+ return;
+ }
+
+ switch (transform) {
+ case GL_IDENTITY_NV:
+ case GL_INVERSE_NV:
+ case GL_TRANSPOSE_NV:
+ case GL_INVERSE_TRANSPOSE_NV:
+ /* OK, fallthrough */
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTrackMatrixNV(transform)");
+ return;
+ }
+
+ ctx->VertexProgram.TrackMatrix[address / 4] = matrix;
+ ctx->VertexProgram.TrackMatrixTransform[address / 4] = transform;
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glTrackMatrixNV(target)");
+ return;
+ }
+}
+
+
+void GLAPIENTRY
+_mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name,
+ GLfloat x, GLfloat y, GLfloat z, GLfloat w)
+{
+ struct program *prog;
+ struct fragment_program *fragProg;
+ GLfloat *v;
+
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+
+ prog = (struct program *) _mesa_HashLookup(ctx->Shared->Programs, id);
+ if (!prog || prog->Target != GL_FRAGMENT_PROGRAM_NV) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glProgramNamedParameterNV");
+ return;
+ }
+
+ if (len <= 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glProgramNamedParameterNV(len)");
+ return;
+ }
+
+ fragProg = (struct fragment_program *) prog;
+ v = _mesa_lookup_parameter_value(fragProg->Parameters, len, (char *) name);
+ if (v) {
+ v[0] = x;
+ v[1] = y;
+ v[2] = z;
+ v[3] = w;
+ return;
+ }
+
+ _mesa_error(ctx, GL_INVALID_VALUE, "glProgramNamedParameterNV(name)");
+}
+
+
+void GLAPIENTRY
+_mesa_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte *name,
+ const float v[])
+{
+ _mesa_ProgramNamedParameter4fNV(id, len, name, v[0], v[1], v[2], v[3]);
+}
+
+
+void GLAPIENTRY
+_mesa_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte *name,
+ GLdouble x, GLdouble y, GLdouble z, GLdouble w)
+{
+ _mesa_ProgramNamedParameter4fNV(id, len, name, (GLfloat)x, (GLfloat)y,
+ (GLfloat)z, (GLfloat)w);
+}
+
+
+void GLAPIENTRY
+_mesa_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte *name,
+ const double v[])
+{
+ _mesa_ProgramNamedParameter4fNV(id, len, name,
+ (GLfloat)v[0], (GLfloat)v[1],
+ (GLfloat)v[2], (GLfloat)v[3]);
+}
+
+
+void GLAPIENTRY
+_mesa_GetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte *name,
+ GLfloat *params)
+{
+ struct program *prog;
+ struct fragment_program *fragProg;
+ const GLfloat *v;
+
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (!ctx->_CurrentProgram)
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ prog = (struct program *) _mesa_HashLookup(ctx->Shared->Programs, id);
+ if (!prog || prog->Target != GL_FRAGMENT_PROGRAM_NV) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramNamedParameterNV");
+ return;
+ }
+
+ if (len <= 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramNamedParameterNV");
+ return;
+ }
+
+ fragProg = (struct fragment_program *) prog;
+ v = _mesa_lookup_parameter_value(fragProg->Parameters, len, (char *) name);
+ if (v) {
+ params[0] = v[0];
+ params[1] = v[1];
+ params[2] = v[2];
+ params[3] = v[3];
+ return;
+ }
+
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramNamedParameterNV");
+}
+
+
+void GLAPIENTRY
+_mesa_GetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte *name,
+ GLdouble *params)
+{
+ GLfloat floatParams[4];
+ _mesa_GetProgramNamedParameterfvNV(id, len, name, floatParams);
+ COPY_4V(params, floatParams);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/nvprogram.h b/nx-X11/extras/Mesa/src/mesa/shader/nvprogram.h
new file mode 100644
index 000000000..dcea7727e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/nvprogram.h
@@ -0,0 +1,119 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ *
+ * Authors:
+ * Brian Paul
+ */
+
+
+#ifndef NVPROGRAM_H
+#define NVPROGRAM_H
+
+
+extern void GLAPIENTRY
+_mesa_ExecuteProgramNV(GLenum target, GLuint id, const GLfloat *params);
+
+extern GLboolean GLAPIENTRY
+_mesa_AreProgramsResidentNV(GLsizei n, const GLuint *ids, GLboolean *residences);
+
+extern void GLAPIENTRY
+_mesa_RequestResidentProgramsNV(GLsizei n, const GLuint *ids);
+
+extern void GLAPIENTRY
+_mesa_GetProgramParameterfvNV(GLenum target, GLuint index, GLenum pname, GLfloat *params);
+
+extern void GLAPIENTRY
+_mesa_GetProgramParameterdvNV(GLenum target, GLuint index, GLenum pname, GLdouble *params);
+
+extern void GLAPIENTRY
+_mesa_GetProgramivNV(GLuint id, GLenum pname, GLint *params);
+
+extern void GLAPIENTRY
+_mesa_GetProgramStringNV(GLuint id, GLenum pname, GLubyte *program);
+
+extern void GLAPIENTRY
+_mesa_GetTrackMatrixivNV(GLenum target, GLuint address, GLenum pname, GLint *params);
+
+extern void GLAPIENTRY
+_mesa_GetVertexAttribdvNV(GLuint index, GLenum pname, GLdouble *params);
+
+extern void GLAPIENTRY
+_mesa_GetVertexAttribfvNV(GLuint index, GLenum pname, GLfloat *params);
+
+extern void GLAPIENTRY
+_mesa_GetVertexAttribivNV(GLuint index, GLenum pname, GLint *params);
+
+extern void GLAPIENTRY
+_mesa_GetVertexAttribPointervNV(GLuint index, GLenum pname, GLvoid **pointer);
+
+extern void GLAPIENTRY
+_mesa_LoadProgramNV(GLenum target, GLuint id, GLsizei len, const GLubyte *program);
+
+extern void GLAPIENTRY
+_mesa_ProgramParameter4dNV(GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+
+extern void GLAPIENTRY
+_mesa_ProgramParameter4dvNV(GLenum target, GLuint index, const GLdouble *params);
+
+extern void GLAPIENTRY
+_mesa_ProgramParameter4fNV(GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+
+extern void GLAPIENTRY
+_mesa_ProgramParameter4fvNV(GLenum target, GLuint index, const GLfloat *params);
+
+extern void GLAPIENTRY
+_mesa_ProgramParameters4dvNV(GLenum target, GLuint index, GLuint num, const GLdouble *params);
+
+extern void GLAPIENTRY
+_mesa_ProgramParameters4fvNV(GLenum target, GLuint index, GLuint num, const GLfloat *params);
+
+extern void GLAPIENTRY
+_mesa_TrackMatrixNV(GLenum target, GLuint address, GLenum matrix, GLenum transform);
+
+
+extern void GLAPIENTRY
+_mesa_ProgramNamedParameter4fNV(GLuint id, GLsizei len, const GLubyte *name,
+ GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+
+extern void GLAPIENTRY
+_mesa_ProgramNamedParameter4fvNV(GLuint id, GLsizei len, const GLubyte *name,
+ const float v[]);
+
+extern void GLAPIENTRY
+_mesa_ProgramNamedParameter4dNV(GLuint id, GLsizei len, const GLubyte *name,
+ GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+
+extern void GLAPIENTRY
+_mesa_ProgramNamedParameter4dvNV(GLuint id, GLsizei len, const GLubyte *name,
+ const double v[]);
+
+extern void GLAPIENTRY
+_mesa_GetProgramNamedParameterfvNV(GLuint id, GLsizei len, const GLubyte *name,
+ GLfloat *params);
+
+extern void GLAPIENTRY
+_mesa_GetProgramNamedParameterdvNV(GLuint id, GLsizei len, const GLubyte *name,
+ GLdouble *params);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/nvvertexec.c b/nx-X11/extras/Mesa/src/mesa/shader/nvvertexec.c
new file mode 100644
index 000000000..dd5959688
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/nvvertexec.c
@@ -0,0 +1,851 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file nvvertexec.c
+ * Code to execute vertex programs.
+ * \author Brian Paul
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "imports.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "nvvertexec.h"
+#include "nvvertprog.h"
+#include "program.h"
+#include "math/m_matrix.h"
+
+
+static const GLfloat ZeroVec[4] = { 0.0F, 0.0F, 0.0F, 0.0F };
+
+
+/**
+ * Load/initialize the vertex program registers which need to be set
+ * per-vertex.
+ */
+void
+_mesa_init_vp_per_vertex_registers(GLcontext *ctx)
+{
+ /* Input registers get initialized from the current vertex attribs */
+ MEMCPY(ctx->VertexProgram.Inputs, ctx->Current.Attrib,
+ VERT_ATTRIB_MAX * 4 * sizeof(GLfloat));
+
+ if (ctx->VertexProgram.Current->IsNVProgram) {
+ GLuint i;
+ /* Output/result regs are initialized to [0,0,0,1] */
+ for (i = 0; i < MAX_NV_VERTEX_PROGRAM_OUTPUTS; i++) {
+ ASSIGN_4V(ctx->VertexProgram.Outputs[i], 0.0F, 0.0F, 0.0F, 1.0F);
+ }
+ /* Temp regs are initialized to [0,0,0,0] */
+ for (i = 0; i < MAX_NV_VERTEX_PROGRAM_TEMPS; i++) {
+ ASSIGN_4V(ctx->VertexProgram.Temporaries[i], 0.0F, 0.0F, 0.0F, 0.0F);
+ }
+ ASSIGN_4V(ctx->VertexProgram.AddressReg, 0, 0, 0, 0);
+ }
+}
+
+
+
+/**
+ * Copy the 16 elements of a matrix into four consecutive program
+ * registers starting at 'pos'.
+ */
+static void
+load_matrix(GLfloat registers[][4], GLuint pos, const GLfloat mat[16])
+{
+ GLuint i;
+ for (i = 0; i < 4; i++) {
+ registers[pos + i][0] = mat[0 + i];
+ registers[pos + i][1] = mat[4 + i];
+ registers[pos + i][2] = mat[8 + i];
+ registers[pos + i][3] = mat[12 + i];
+ }
+}
+
+
+/**
+ * As above, but transpose the matrix.
+ */
+static void
+load_transpose_matrix(GLfloat registers[][4], GLuint pos,
+ const GLfloat mat[16])
+{
+ MEMCPY(registers[pos], mat, 16 * sizeof(GLfloat));
+}
+
+
+/**
+ * Load program parameter registers with tracked matrices (if NV program)
+ * or GL state values (if ARB program).
+ * This needs to be done per glBegin/glEnd, not per-vertex.
+ */
+void
+_mesa_init_vp_per_primitive_registers(GLcontext *ctx)
+{
+ if (ctx->VertexProgram.Current->IsNVProgram) {
+ GLuint i;
+
+ for (i = 0; i < MAX_NV_VERTEX_PROGRAM_PARAMS / 4; i++) {
+ /* point 'mat' at source matrix */
+ GLmatrix *mat;
+ if (ctx->VertexProgram.TrackMatrix[i] == GL_MODELVIEW) {
+ mat = ctx->ModelviewMatrixStack.Top;
+ }
+ else if (ctx->VertexProgram.TrackMatrix[i] == GL_PROJECTION) {
+ mat = ctx->ProjectionMatrixStack.Top;
+ }
+ else if (ctx->VertexProgram.TrackMatrix[i] == GL_TEXTURE) {
+ mat = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top;
+ }
+ else if (ctx->VertexProgram.TrackMatrix[i] == GL_COLOR) {
+ mat = ctx->ColorMatrixStack.Top;
+ }
+ else if (ctx->VertexProgram.TrackMatrix[i]==GL_MODELVIEW_PROJECTION_NV) {
+ /* XXX verify the combined matrix is up to date */
+ mat = &ctx->_ModelProjectMatrix;
+ }
+ else if (ctx->VertexProgram.TrackMatrix[i] >= GL_MATRIX0_NV &&
+ ctx->VertexProgram.TrackMatrix[i] <= GL_MATRIX7_NV) {
+ GLuint n = ctx->VertexProgram.TrackMatrix[i] - GL_MATRIX0_NV;
+ ASSERT(n < MAX_PROGRAM_MATRICES);
+ mat = ctx->ProgramMatrixStack[n].Top;
+ }
+ else {
+ /* no matrix is tracked, but we leave the register values as-is */
+ assert(ctx->VertexProgram.TrackMatrix[i] == GL_NONE);
+ continue;
+ }
+
+ /* load the matrix */
+ if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_IDENTITY_NV) {
+ load_matrix(ctx->VertexProgram.Parameters, i*4, mat->m);
+ }
+ else if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_INVERSE_NV) {
+ _math_matrix_analyse(mat); /* update the inverse */
+ ASSERT(!_math_matrix_is_dirty(mat));
+ load_matrix(ctx->VertexProgram.Parameters, i*4, mat->inv);
+ }
+ else if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_TRANSPOSE_NV) {
+ load_transpose_matrix(ctx->VertexProgram.Parameters, i*4, mat->m);
+ }
+ else {
+ assert(ctx->VertexProgram.TrackMatrixTransform[i]
+ == GL_INVERSE_TRANSPOSE_NV);
+ _math_matrix_analyse(mat); /* update the inverse */
+ ASSERT(!_math_matrix_is_dirty(mat));
+ load_transpose_matrix(ctx->VertexProgram.Parameters, i*4, mat->inv);
+ }
+ }
+ }
+ else {
+ /* Using and ARB vertex program */
+ if (ctx->VertexProgram.Current->Parameters) {
+ /* Grab the state GL state and put into registers */
+ _mesa_load_state_parameters(ctx,
+ ctx->VertexProgram.Current->Parameters);
+ }
+ }
+}
+
+
+
+/**
+ * For debugging. Dump the current vertex program machine registers.
+ */
+void
+_mesa_dump_vp_state( const struct gl_vertex_program_state *state )
+{
+ int i;
+ _mesa_printf("VertexIn:\n");
+ for (i = 0; i < MAX_NV_VERTEX_PROGRAM_INPUTS; i++) {
+ _mesa_printf("%d: %f %f %f %f ", i,
+ state->Inputs[i][0],
+ state->Inputs[i][1],
+ state->Inputs[i][2],
+ state->Inputs[i][3]);
+ }
+ _mesa_printf("\n");
+
+ _mesa_printf("VertexOut:\n");
+ for (i = 0; i < MAX_NV_VERTEX_PROGRAM_OUTPUTS; i++) {
+ _mesa_printf("%d: %f %f %f %f ", i,
+ state->Outputs[i][0],
+ state->Outputs[i][1],
+ state->Outputs[i][2],
+ state->Outputs[i][3]);
+ }
+ _mesa_printf("\n");
+
+ _mesa_printf("Registers:\n");
+ for (i = 0; i < MAX_NV_VERTEX_PROGRAM_TEMPS; i++) {
+ _mesa_printf("%d: %f %f %f %f ", i,
+ state->Temporaries[i][0],
+ state->Temporaries[i][1],
+ state->Temporaries[i][2],
+ state->Temporaries[i][3]);
+ }
+ _mesa_printf("\n");
+
+ _mesa_printf("Parameters:\n");
+ for (i = 0; i < MAX_NV_VERTEX_PROGRAM_PARAMS; i++) {
+ _mesa_printf("%d: %f %f %f %f ", i,
+ state->Parameters[i][0],
+ state->Parameters[i][1],
+ state->Parameters[i][2],
+ state->Parameters[i][3]);
+ }
+ _mesa_printf("\n");
+}
+
+
+
+/**
+ * Return a pointer to the 4-element float vector specified by the given
+ * source register.
+ */
+static INLINE const GLfloat *
+get_register_pointer( const struct vp_src_register *source,
+ const struct gl_vertex_program_state *state )
+{
+ if (source->RelAddr) {
+ const GLint reg = source->Index + state->AddressReg[0];
+ ASSERT( (source->File == PROGRAM_ENV_PARAM) ||
+ (source->File == PROGRAM_STATE_VAR) );
+ if (reg < 0 || reg > MAX_NV_VERTEX_PROGRAM_PARAMS)
+ return ZeroVec;
+ else if (source->File == PROGRAM_ENV_PARAM)
+ return state->Parameters[reg];
+ else
+ return state->Current->Parameters->ParameterValues[reg];
+ }
+ else {
+ switch (source->File) {
+ case PROGRAM_TEMPORARY:
+ ASSERT(source->Index < MAX_NV_VERTEX_PROGRAM_TEMPS);
+ return state->Temporaries[source->Index];
+ case PROGRAM_INPUT:
+ ASSERT(source->Index < MAX_NV_VERTEX_PROGRAM_INPUTS);
+ return state->Inputs[source->Index];
+ case PROGRAM_OUTPUT:
+ /* This is only needed for the PRINT instruction */
+ ASSERT(source->Index < MAX_NV_VERTEX_PROGRAM_OUTPUTS);
+ return state->Outputs[source->Index];
+ case PROGRAM_LOCAL_PARAM:
+ ASSERT(source->Index < MAX_PROGRAM_LOCAL_PARAMS);
+ return state->Current->Base.LocalParams[source->Index];
+ case PROGRAM_ENV_PARAM:
+ ASSERT(source->Index < MAX_NV_VERTEX_PROGRAM_PARAMS);
+ return state->Parameters[source->Index];
+ case PROGRAM_STATE_VAR:
+ ASSERT(source->Index < state->Current->Parameters->NumParameters);
+ return state->Current->Parameters->ParameterValues[source->Index];
+ default:
+ _mesa_problem(NULL,
+ "Bad source register file in get_register_pointer");
+ return NULL;
+ }
+ }
+ return NULL;
+}
+
+
+/**
+ * Fetch a 4-element float vector from the given source register.
+ * Apply swizzling and negating as needed.
+ */
+static INLINE void
+fetch_vector4( const struct vp_src_register *source,
+ const struct gl_vertex_program_state *state,
+ GLfloat result[4] )
+{
+ const GLfloat *src = get_register_pointer(source, state);
+
+ if (source->Negate) {
+ result[0] = -src[GET_SWZ(source->Swizzle, 0)];
+ result[1] = -src[GET_SWZ(source->Swizzle, 1)];
+ result[2] = -src[GET_SWZ(source->Swizzle, 2)];
+ result[3] = -src[GET_SWZ(source->Swizzle, 3)];
+ }
+ else {
+ result[0] = src[GET_SWZ(source->Swizzle, 0)];
+ result[1] = src[GET_SWZ(source->Swizzle, 1)];
+ result[2] = src[GET_SWZ(source->Swizzle, 2)];
+ result[3] = src[GET_SWZ(source->Swizzle, 3)];
+ }
+}
+
+
+
+/**
+ * As above, but only return result[0] element.
+ */
+static INLINE void
+fetch_vector1( const struct vp_src_register *source,
+ const struct gl_vertex_program_state *state,
+ GLfloat result[4] )
+{
+ const GLfloat *src = get_register_pointer(source, state);
+
+ if (source->Negate) {
+ result[0] = -src[GET_SWZ(source->Swizzle, 0)];
+ }
+ else {
+ result[0] = src[GET_SWZ(source->Swizzle, 0)];
+ }
+}
+
+
+/**
+ * Store 4 floats into a register.
+ */
+static void
+store_vector4( const struct vp_dst_register *dest,
+ struct gl_vertex_program_state *state,
+ const GLfloat value[4] )
+{
+ GLfloat *dst;
+ switch (dest->File) {
+ case PROGRAM_TEMPORARY:
+ dst = state->Temporaries[dest->Index];
+ break;
+ case PROGRAM_OUTPUT:
+ dst = state->Outputs[dest->Index];
+ break;
+ case PROGRAM_ENV_PARAM:
+ {
+ /* a slight hack */
+ GET_CURRENT_CONTEXT(ctx);
+ dst = ctx->VertexProgram.Parameters[dest->Index];
+ }
+ break;
+ default:
+ _mesa_problem(NULL, "Invalid register file in store_vector4(file=%d)",
+ dest->File);
+ return;
+ }
+
+ if (dest->WriteMask & WRITEMASK_X)
+ dst[0] = value[0];
+ if (dest->WriteMask & WRITEMASK_Y)
+ dst[1] = value[1];
+ if (dest->WriteMask & WRITEMASK_Z)
+ dst[2] = value[2];
+ if (dest->WriteMask & WRITEMASK_W)
+ dst[3] = value[3];
+}
+
+
+/**
+ * Set x to positive or negative infinity.
+ */
+#if defined(USE_IEEE) || defined(_WIN32)
+#define SET_POS_INFINITY(x) ( *((GLuint *) (void *)&x) = 0x7F800000 )
+#define SET_NEG_INFINITY(x) ( *((GLuint *) (void *)&x) = 0xFF800000 )
+#elif defined(VMS)
+#define SET_POS_INFINITY(x) x = __MAXFLOAT
+#define SET_NEG_INFINITY(x) x = -__MAXFLOAT
+#else
+#define SET_POS_INFINITY(x) x = (GLfloat) HUGE_VAL
+#define SET_NEG_INFINITY(x) x = (GLfloat) -HUGE_VAL
+#endif
+
+#define SET_FLOAT_BITS(x, bits) ((fi_type *) (void *) &(x))->i = bits
+
+
+/**
+ * Execute the given vertex program
+ */
+void
+_mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program)
+{
+ struct gl_vertex_program_state *state = &ctx->VertexProgram;
+ const struct vp_instruction *inst;
+
+ ctx->_CurrentProgram = GL_VERTEX_PROGRAM_ARB; /* or NV, doesn't matter */
+
+ /* If the program is position invariant, multiply the input
+ * position and the MVP matrix and stick it into the output pos slot
+ */
+ if (ctx->VertexProgram.Current->IsPositionInvariant) {
+ TRANSFORM_POINT( ctx->VertexProgram.Outputs[0],
+ ctx->_ModelProjectMatrix.m,
+ ctx->VertexProgram.Inputs[0]);
+
+ /* XXX: This could go elsewhere */
+ ctx->VertexProgram.Current->OutputsWritten |= 0x1;
+ }
+ for (inst = program->Instructions; ; inst++) {
+
+ if (ctx->VertexProgram.CallbackEnabled &&
+ ctx->VertexProgram.Callback) {
+ ctx->VertexProgram.CurrentPosition = inst->StringPos;
+ ctx->VertexProgram.Callback(program->Base.Target,
+ ctx->VertexProgram.CallbackData);
+ }
+
+ switch (inst->Opcode) {
+ case VP_OPCODE_MOV:
+ {
+ GLfloat t[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ store_vector4( &inst->DstReg, state, t );
+ }
+ break;
+ case VP_OPCODE_LIT:
+ {
+ const GLfloat epsilon = 1.0F / 256.0F; /* per NV spec */
+ GLfloat t[4], lit[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ t[0] = MAX2(t[0], 0.0F);
+ t[1] = MAX2(t[1], 0.0F);
+ t[3] = CLAMP(t[3], -(128.0F - epsilon), (128.0F - epsilon));
+ lit[0] = 1.0;
+ lit[1] = t[0];
+ lit[2] = (t[0] > 0.0) ? (GLfloat) _mesa_pow(t[1], t[3]) : 0.0F;
+ lit[3] = 1.0;
+ store_vector4( &inst->DstReg, state, lit );
+ }
+ break;
+ case VP_OPCODE_RCP:
+ {
+ GLfloat t[4];
+ fetch_vector1( &inst->SrcReg[0], state, t );
+ if (t[0] != 1.0F)
+ t[0] = 1.0F / t[0]; /* div by zero is infinity! */
+ t[1] = t[2] = t[3] = t[0];
+ store_vector4( &inst->DstReg, state, t );
+ }
+ break;
+ case VP_OPCODE_RSQ:
+ {
+ GLfloat t[4];
+ fetch_vector1( &inst->SrcReg[0], state, t );
+ t[0] = INV_SQRTF(FABSF(t[0]));
+ t[1] = t[2] = t[3] = t[0];
+ store_vector4( &inst->DstReg, state, t );
+ }
+ break;
+ case VP_OPCODE_EXP:
+ {
+ GLfloat t[4], q[4], floor_t0;
+ fetch_vector1( &inst->SrcReg[0], state, t );
+ floor_t0 = (float) floor(t[0]);
+ if (floor_t0 > FLT_MAX_EXP) {
+ SET_POS_INFINITY(q[0]);
+ SET_POS_INFINITY(q[2]);
+ }
+ else if (floor_t0 < FLT_MIN_EXP) {
+ q[0] = 0.0F;
+ q[2] = 0.0F;
+ }
+ else {
+#ifdef USE_IEEE
+ GLint ii = (GLint) floor_t0;
+ ii = (ii < 23) + 0x3f800000;
+ SET_FLOAT_BITS(q[0], ii);
+ q[0] = *((GLfloat *) (void *)&ii);
+#else
+ q[0] = (GLfloat) pow(2.0, floor_t0);
+#endif
+ q[2] = (GLfloat) (q[0] * LOG2(q[1]));
+ }
+ q[1] = t[0] - floor_t0;
+ q[3] = 1.0F;
+ store_vector4( &inst->DstReg, state, q );
+ }
+ break;
+ case VP_OPCODE_LOG:
+ {
+ GLfloat t[4], q[4], abs_t0;
+ fetch_vector1( &inst->SrcReg[0], state, t );
+ abs_t0 = (GLfloat) fabs(t[0]);
+ if (abs_t0 != 0.0F) {
+ /* Since we really can't handle infinite values on VMS
+ * like other OSes we'll use __MAXFLOAT to represent
+ * infinity. This may need some tweaking.
+ */
+#ifdef VMS
+ if (abs_t0 == __MAXFLOAT)
+#else
+ if (IS_INF_OR_NAN(abs_t0))
+#endif
+ {
+ SET_POS_INFINITY(q[0]);
+ q[1] = 1.0F;
+ SET_POS_INFINITY(q[2]);
+ }
+ else {
+ int exponent;
+ double mantissa = frexp(t[0], &exponent);
+ q[0] = (GLfloat) (exponent - 1);
+ q[1] = (GLfloat) (2.0 * mantissa); /* map [.5, 1) -> [1, 2) */
+ q[2] = (GLfloat) (q[0] + LOG2(q[1]));
+ }
+ }
+ else {
+ SET_NEG_INFINITY(q[0]);
+ q[1] = 1.0F;
+ SET_NEG_INFINITY(q[2]);
+ }
+ q[3] = 1.0;
+ store_vector4( &inst->DstReg, state, q );
+ }
+ break;
+ case VP_OPCODE_MUL:
+ {
+ GLfloat t[4], u[4], prod[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ fetch_vector4( &inst->SrcReg[1], state, u );
+ prod[0] = t[0] * u[0];
+ prod[1] = t[1] * u[1];
+ prod[2] = t[2] * u[2];
+ prod[3] = t[3] * u[3];
+ store_vector4( &inst->DstReg, state, prod );
+ }
+ break;
+ case VP_OPCODE_ADD:
+ {
+ GLfloat t[4], u[4], sum[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ fetch_vector4( &inst->SrcReg[1], state, u );
+ sum[0] = t[0] + u[0];
+ sum[1] = t[1] + u[1];
+ sum[2] = t[2] + u[2];
+ sum[3] = t[3] + u[3];
+ store_vector4( &inst->DstReg, state, sum );
+ }
+ break;
+ case VP_OPCODE_DP3:
+ {
+ GLfloat t[4], u[4], dot[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ fetch_vector4( &inst->SrcReg[1], state, u );
+ dot[0] = t[0] * u[0] + t[1] * u[1] + t[2] * u[2];
+ dot[1] = dot[2] = dot[3] = dot[0];
+ store_vector4( &inst->DstReg, state, dot );
+ }
+ break;
+ case VP_OPCODE_DP4:
+ {
+ GLfloat t[4], u[4], dot[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ fetch_vector4( &inst->SrcReg[1], state, u );
+ dot[0] = t[0] * u[0] + t[1] * u[1] + t[2] * u[2] + t[3] * u[3];
+ dot[1] = dot[2] = dot[3] = dot[0];
+ store_vector4( &inst->DstReg, state, dot );
+ }
+ break;
+ case VP_OPCODE_DST:
+ {
+ GLfloat t[4], u[4], dst[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ fetch_vector4( &inst->SrcReg[1], state, u );
+ dst[0] = 1.0F;
+ dst[1] = t[1] * u[1];
+ dst[2] = t[2];
+ dst[3] = u[3];
+ store_vector4( &inst->DstReg, state, dst );
+ }
+ break;
+ case VP_OPCODE_MIN:
+ {
+ GLfloat t[4], u[4], min[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ fetch_vector4( &inst->SrcReg[1], state, u );
+ min[0] = (t[0] < u[0]) ? t[0] : u[0];
+ min[1] = (t[1] < u[1]) ? t[1] : u[1];
+ min[2] = (t[2] < u[2]) ? t[2] : u[2];
+ min[3] = (t[3] < u[3]) ? t[3] : u[3];
+ store_vector4( &inst->DstReg, state, min );
+ }
+ break;
+ case VP_OPCODE_MAX:
+ {
+ GLfloat t[4], u[4], max[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ fetch_vector4( &inst->SrcReg[1], state, u );
+ max[0] = (t[0] > u[0]) ? t[0] : u[0];
+ max[1] = (t[1] > u[1]) ? t[1] : u[1];
+ max[2] = (t[2] > u[2]) ? t[2] : u[2];
+ max[3] = (t[3] > u[3]) ? t[3] : u[3];
+ store_vector4( &inst->DstReg, state, max );
+ }
+ break;
+ case VP_OPCODE_SLT:
+ {
+ GLfloat t[4], u[4], slt[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ fetch_vector4( &inst->SrcReg[1], state, u );
+ slt[0] = (t[0] < u[0]) ? 1.0F : 0.0F;
+ slt[1] = (t[1] < u[1]) ? 1.0F : 0.0F;
+ slt[2] = (t[2] < u[2]) ? 1.0F : 0.0F;
+ slt[3] = (t[3] < u[3]) ? 1.0F : 0.0F;
+ store_vector4( &inst->DstReg, state, slt );
+ }
+ break;
+ case VP_OPCODE_SGE:
+ {
+ GLfloat t[4], u[4], sge[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ fetch_vector4( &inst->SrcReg[1], state, u );
+ sge[0] = (t[0] >= u[0]) ? 1.0F : 0.0F;
+ sge[1] = (t[1] >= u[1]) ? 1.0F : 0.0F;
+ sge[2] = (t[2] >= u[2]) ? 1.0F : 0.0F;
+ sge[3] = (t[3] >= u[3]) ? 1.0F : 0.0F;
+ store_vector4( &inst->DstReg, state, sge );
+ }
+ break;
+ case VP_OPCODE_MAD:
+ {
+ GLfloat t[4], u[4], v[4], sum[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ fetch_vector4( &inst->SrcReg[1], state, u );
+ fetch_vector4( &inst->SrcReg[2], state, v );
+ sum[0] = t[0] * u[0] + v[0];
+ sum[1] = t[1] * u[1] + v[1];
+ sum[2] = t[2] * u[2] + v[2];
+ sum[3] = t[3] * u[3] + v[3];
+ store_vector4( &inst->DstReg, state, sum );
+ }
+ break;
+ case VP_OPCODE_ARL:
+ {
+ GLfloat t[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ state->AddressReg[0] = (GLint) floor(t[0]);
+ }
+ break;
+ case VP_OPCODE_DPH:
+ {
+ GLfloat t[4], u[4], dot[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ fetch_vector4( &inst->SrcReg[1], state, u );
+ dot[0] = t[0] * u[0] + t[1] * u[1] + t[2] * u[2] + u[3];
+ dot[1] = dot[2] = dot[3] = dot[0];
+ store_vector4( &inst->DstReg, state, dot );
+ }
+ break;
+ case VP_OPCODE_RCC:
+ {
+ GLfloat t[4], u;
+ fetch_vector1( &inst->SrcReg[0], state, t );
+ if (t[0] == 1.0F)
+ u = 1.0F;
+ else
+ u = 1.0F / t[0];
+ if (u > 0.0F) {
+ if (u > 1.884467e+019F) {
+ u = 1.884467e+019F; /* IEEE 32-bit binary value 0x5F800000 */
+ }
+ else if (u < 5.42101e-020F) {
+ u = 5.42101e-020F; /* IEEE 32-bit binary value 0x1F800000 */
+ }
+ }
+ else {
+ if (u < -1.884467e+019F) {
+ u = -1.884467e+019F; /* IEEE 32-bit binary value 0xDF800000 */
+ }
+ else if (u > -5.42101e-020F) {
+ u = -5.42101e-020F; /* IEEE 32-bit binary value 0x9F800000 */
+ }
+ }
+ t[0] = t[1] = t[2] = t[3] = u;
+ store_vector4( &inst->DstReg, state, t );
+ }
+ break;
+ case VP_OPCODE_SUB: /* GL_NV_vertex_program1_1 */
+ {
+ GLfloat t[4], u[4], sum[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ fetch_vector4( &inst->SrcReg[1], state, u );
+ sum[0] = t[0] - u[0];
+ sum[1] = t[1] - u[1];
+ sum[2] = t[2] - u[2];
+ sum[3] = t[3] - u[3];
+ store_vector4( &inst->DstReg, state, sum );
+ }
+ break;
+ case VP_OPCODE_ABS: /* GL_NV_vertex_program1_1 */
+ {
+ GLfloat t[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ if (t[0] < 0.0) t[0] = -t[0];
+ if (t[1] < 0.0) t[1] = -t[1];
+ if (t[2] < 0.0) t[2] = -t[2];
+ if (t[3] < 0.0) t[3] = -t[3];
+ store_vector4( &inst->DstReg, state, t );
+ }
+ break;
+ case VP_OPCODE_FLR: /* GL_ARB_vertex_program */
+ {
+ GLfloat t[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ t[0] = FLOORF(t[0]);
+ t[1] = FLOORF(t[1]);
+ t[2] = FLOORF(t[2]);
+ t[3] = FLOORF(t[3]);
+ store_vector4( &inst->DstReg, state, t );
+ }
+ break;
+ case VP_OPCODE_FRC: /* GL_ARB_vertex_program */
+ {
+ GLfloat t[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ t[0] = t[0] - FLOORF(t[0]);
+ t[1] = t[1] - FLOORF(t[1]);
+ t[2] = t[2] - FLOORF(t[2]);
+ t[3] = t[3] - FLOORF(t[3]);
+ store_vector4( &inst->DstReg, state, t );
+ }
+ break;
+ case VP_OPCODE_EX2: /* GL_ARB_vertex_program */
+ {
+ GLfloat t[4];
+ fetch_vector1( &inst->SrcReg[0], state, t );
+ t[0] = t[1] = t[2] = t[3] = (GLfloat)_mesa_pow(2.0, t[0]);
+ store_vector4( &inst->DstReg, state, t );
+ }
+ break;
+ case VP_OPCODE_LG2: /* GL_ARB_vertex_program */
+ {
+ GLfloat t[4];
+ fetch_vector1( &inst->SrcReg[0], state, t );
+ t[0] = t[1] = t[2] = t[3] = LOG2(t[0]);
+ store_vector4( &inst->DstReg, state, t );
+ }
+ break;
+ case VP_OPCODE_POW: /* GL_ARB_vertex_program */
+ {
+ GLfloat t[4], u[4];
+ fetch_vector1( &inst->SrcReg[0], state, t );
+ fetch_vector1( &inst->SrcReg[1], state, u );
+ t[0] = t[1] = t[2] = t[3] = (GLfloat)_mesa_pow(t[0], u[0]);
+ store_vector4( &inst->DstReg, state, t );
+ }
+ break;
+ case VP_OPCODE_XPD: /* GL_ARB_vertex_program */
+ {
+ GLfloat t[4], u[4], cross[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ fetch_vector4( &inst->SrcReg[1], state, u );
+ cross[0] = t[1] * u[2] - t[2] * u[1];
+ cross[1] = t[2] * u[0] - t[0] * u[2];
+ cross[2] = t[0] * u[1] - t[1] * u[0];
+ store_vector4( &inst->DstReg, state, cross );
+ }
+ break;
+ case VP_OPCODE_SWZ: /* GL_ARB_vertex_program */
+ {
+ const struct vp_src_register *source = &inst->SrcReg[0];
+ const GLfloat *src = get_register_pointer(source, state);
+ GLfloat result[4];
+ GLuint i;
+
+ /* do extended swizzling here */
+ for (i = 0; i < 4; i++) {
+ if (GET_SWZ(source->Swizzle, i) == SWIZZLE_ZERO)
+ result[i] = 0.0;
+ else if (GET_SWZ(source->Swizzle, i) == SWIZZLE_ONE)
+ result[i] = 1.0;
+ else
+ result[i] = src[GET_SWZ(source->Swizzle, i)];
+ if (source->Negate & (1 << i))
+ result[i] = -result[i];
+ }
+ store_vector4( &inst->DstReg, state, result );
+ }
+ break;
+ case VP_OPCODE_PRINT:
+ if (inst->SrcReg[0].File) {
+ GLfloat t[4];
+ fetch_vector4( &inst->SrcReg[0], state, t );
+ _mesa_printf("%s%g, %g, %g, %g\n",
+ (char *) inst->Data, t[0], t[1], t[2], t[3]);
+ }
+ else {
+ _mesa_printf("%s\n", (char *) inst->Data);
+ }
+ break;
+ case VP_OPCODE_END:
+ ctx->_CurrentProgram = 0;
+ return;
+ default:
+ /* bad instruction opcode */
+ _mesa_problem(ctx, "Bad VP Opcode in _mesa_exec_vertex_program");
+ ctx->_CurrentProgram = 0;
+ return;
+ } /* switch */
+ } /* for */
+
+ ctx->_CurrentProgram = 0;
+}
+
+
+
+/**
+Thoughts on vertex program optimization:
+
+The obvious thing to do is to compile the vertex program into X86/SSE/3DNow!
+assembly code. That will probably be a lot of work.
+
+Another approach might be to replace the vp_instruction->Opcode field with
+a pointer to a specialized C function which executes the instruction.
+In particular we can write functions which skip swizzling, negating,
+masking, relative addressing, etc. when they're not needed.
+
+For example:
+
+void simple_add( struct vp_instruction *inst )
+{
+ GLfloat *sum = machine->Registers[inst->DstReg.Register];
+ GLfloat *a = machine->Registers[inst->SrcReg[0].Register];
+ GLfloat *b = machine->Registers[inst->SrcReg[1].Register];
+ sum[0] = a[0] + b[0];
+ sum[1] = a[1] + b[1];
+ sum[2] = a[2] + b[2];
+ sum[3] = a[3] + b[3];
+}
+
+*/
+
+/*
+
+KW:
+
+A first step would be to 'vectorize' the programs in the same way as
+the normal transformation code in the tnl module. Thus each opcode
+takes zero or more input vectors (registers) and produces one or more
+output vectors.
+
+These operations would intially be coded in C, with machine-specific
+assembly following, as is currently the case for matrix
+transformations in the math/ directory. The preprocessing scheme for
+selecting simpler operations Brian describes above would also work
+here.
+
+This should give reasonable performance without excessive effort.
+
+*/
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/nvvertexec.h b/nx-X11/extras/Mesa/src/mesa/shader/nvvertexec.h
new file mode 100644
index 000000000..cdf1bd588
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/nvvertexec.h
@@ -0,0 +1,43 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ *
+ * Authors:
+ * Brian Paul
+ */
+
+#ifndef NVVERTEXEC_H
+#define NVVERTEXEC_H
+
+extern void
+_mesa_init_vp_per_vertex_registers(GLcontext *ctx);
+
+extern void
+_mesa_init_vp_per_primitive_registers(GLcontext *ctx);
+
+extern void
+_mesa_exec_vertex_program(GLcontext *ctx, const struct vertex_program *program);
+
+extern void
+_mesa_dump_vp_state( const struct gl_vertex_program_state *state );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/nvvertparse.c b/nx-X11/extras/Mesa/src/mesa/shader/nvvertparse.c
new file mode 100644
index 000000000..33bc2004a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/nvvertparse.c
@@ -0,0 +1,1603 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file nvvertparse.c
+ * NVIDIA vertex program parser.
+ * \author Brian Paul
+ */
+
+/*
+ * Regarding GL_NV_vertex_program, GL_NV_vertex_program1_1:
+ *
+ * Portions of this software may use or implement intellectual
+ * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims
+ * any and all warranties with respect to such intellectual property,
+ * including any use thereof or modifications thereto.
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "hash.h"
+#include "imports.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "nvprogram.h"
+#include "nvvertparse.h"
+#include "nvvertprog.h"
+#include "program.h"
+
+
+/**
+ * Current parsing state. This structure is passed among the parsing
+ * functions and keeps track of the current parser position and various
+ * program attributes.
+ */
+struct parse_state {
+ GLcontext *ctx;
+ const GLubyte *start;
+ const GLubyte *pos;
+ const GLubyte *curLine;
+ GLboolean isStateProgram;
+ GLboolean isPositionInvariant;
+ GLboolean isVersion1_1;
+ GLuint inputsRead;
+ GLuint outputsWritten;
+ GLboolean anyProgRegsWritten;
+ GLuint numInst; /* number of instructions parsed */
+};
+
+
+/*
+ * Called whenever we find an error during parsing.
+ */
+static void
+record_error(struct parse_state *parseState, const char *msg, int lineNo)
+{
+#ifdef DEBUG
+ GLint line, column;
+ const GLubyte *lineStr;
+ lineStr = _mesa_find_line_column(parseState->start,
+ parseState->pos, &line, &column);
+ _mesa_debug(parseState->ctx,
+ "nvfragparse.c(%d): line %d, column %d:%s (%s)\n",
+ lineNo, line, column, (char *) lineStr, msg);
+ _mesa_free((void *) lineStr);
+#else
+ (void) lineNo;
+#endif
+
+ /* Check that no error was already recorded. Only record the first one. */
+ if (parseState->ctx->Program.ErrorString[0] == 0) {
+ _mesa_set_program_error(parseState->ctx,
+ parseState->pos - parseState->start,
+ msg);
+ }
+}
+
+
+#define RETURN_ERROR \
+do { \
+ record_error(parseState, "Unexpected end of input.", __LINE__); \
+ return GL_FALSE; \
+} while(0)
+
+#define RETURN_ERROR1(msg) \
+do { \
+ record_error(parseState, msg, __LINE__); \
+ return GL_FALSE; \
+} while(0)
+
+#define RETURN_ERROR2(msg1, msg2) \
+do { \
+ char err[1000]; \
+ _mesa_sprintf(err, "%s %s", msg1, msg2); \
+ record_error(parseState, err, __LINE__); \
+ return GL_FALSE; \
+} while(0)
+
+
+
+
+
+static GLboolean IsLetter(GLubyte b)
+{
+ return (b >= 'a' && b <= 'z') || (b >= 'A' && b <= 'Z');
+}
+
+
+static GLboolean IsDigit(GLubyte b)
+{
+ return b >= '0' && b <= '9';
+}
+
+
+static GLboolean IsWhitespace(GLubyte b)
+{
+ return b == ' ' || b == '\t' || b == '\n' || b == '\r';
+}
+
+
+/**
+ * Starting at 'str' find the next token. A token can be an integer,
+ * an identifier or punctuation symbol.
+ * \return <= 0 we found an error, else, return number of characters parsed.
+ */
+static GLint
+GetToken(struct parse_state *parseState, GLubyte *token)
+{
+ const GLubyte *str = parseState->pos;
+ GLint i = 0, j = 0;
+
+ token[0] = 0;
+
+ /* skip whitespace and comments */
+ while (str[i] && (IsWhitespace(str[i]) || str[i] == '#')) {
+ if (str[i] == '#') {
+ /* skip comment */
+ while (str[i] && (str[i] != '\n' && str[i] != '\r')) {
+ i++;
+ }
+ if (str[i] == '\n' || str[i] == '\r')
+ parseState->curLine = str + i + 1;
+ }
+ else {
+ /* skip whitespace */
+ if (str[i] == '\n' || str[i] == '\r')
+ parseState->curLine = str + i + 1;
+ i++;
+ }
+ }
+
+ if (str[i] == 0)
+ return -i;
+
+ /* try matching an integer */
+ while (str[i] && IsDigit(str[i])) {
+ token[j++] = str[i++];
+ }
+ if (j > 0 || !str[i]) {
+ token[j] = 0;
+ return i;
+ }
+
+ /* try matching an identifier */
+ if (IsLetter(str[i])) {
+ while (str[i] && (IsLetter(str[i]) || IsDigit(str[i]))) {
+ token[j++] = str[i++];
+ }
+ token[j] = 0;
+ return i;
+ }
+
+ /* punctuation character */
+ if (str[i]) {
+ token[0] = str[i++];
+ token[1] = 0;
+ return i;
+ }
+
+ /* end of input */
+ token[0] = 0;
+ return i;
+}
+
+
+/**
+ * Get next token from input stream and increment stream pointer past token.
+ */
+static GLboolean
+Parse_Token(struct parse_state *parseState, GLubyte *token)
+{
+ GLint i;
+ i = GetToken(parseState, token);
+ if (i <= 0) {
+ parseState->pos += (-i);
+ return GL_FALSE;
+ }
+ parseState->pos += i;
+ return GL_TRUE;
+}
+
+
+/**
+ * Get next token from input stream but don't increment stream pointer.
+ */
+static GLboolean
+Peek_Token(struct parse_state *parseState, GLubyte *token)
+{
+ GLint i, len;
+ i = GetToken(parseState, token);
+ if (i <= 0) {
+ parseState->pos += (-i);
+ return GL_FALSE;
+ }
+ len = (GLint)_mesa_strlen((const char *) token);
+ parseState->pos += (i - len);
+ return GL_TRUE;
+}
+
+
+/**
+ * Try to match 'pattern' as the next token after any whitespace/comments.
+ * Advance the current parsing position only if we match the pattern.
+ * \return GL_TRUE if pattern is matched, GL_FALSE otherwise.
+ */
+static GLboolean
+Parse_String(struct parse_state *parseState, const char *pattern)
+{
+ const GLubyte *m;
+ GLint i;
+
+ /* skip whitespace and comments */
+ while (IsWhitespace(*parseState->pos) || *parseState->pos == '#') {
+ if (*parseState->pos == '#') {
+ while (*parseState->pos && (*parseState->pos != '\n' && *parseState->pos != '\r')) {
+ parseState->pos += 1;
+ }
+ if (*parseState->pos == '\n' || *parseState->pos == '\r')
+ parseState->curLine = parseState->pos + 1;
+ }
+ else {
+ /* skip whitespace */
+ if (*parseState->pos == '\n' || *parseState->pos == '\r')
+ parseState->curLine = parseState->pos + 1;
+ parseState->pos += 1;
+ }
+ }
+
+ /* Try to match the pattern */
+ m = parseState->pos;
+ for (i = 0; pattern[i]; i++) {
+ if (*m != (GLubyte) pattern[i])
+ return GL_FALSE;
+ m += 1;
+ }
+ parseState->pos = m;
+
+ return GL_TRUE; /* success */
+}
+
+
+/**********************************************************************/
+
+static const char *InputRegisters[MAX_NV_VERTEX_PROGRAM_INPUTS + 1] = {
+ "OPOS", "WGHT", "NRML", "COL0", "COL1", "FOGC", "6", "7",
+ "TEX0", "TEX1", "TEX2", "TEX3", "TEX4", "TEX5", "TEX6", "TEX7", NULL
+};
+
+static const char *OutputRegisters[MAX_NV_VERTEX_PROGRAM_OUTPUTS + 1] = {
+ "HPOS", "COL0", "COL1", "BFC0", "BFC1", "FOGC", "PSIZ",
+ "TEX0", "TEX1", "TEX2", "TEX3", "TEX4", "TEX5", "TEX6", "TEX7", NULL
+};
+
+/* NOTE: the order here must match opcodes in nvvertprog.h */
+static const char *Opcodes[] = {
+ "MOV", "LIT", "RCP", "RSQ", "EXP", "LOG", "MUL", "ADD", "DP3", "DP4",
+ "DST", "MIN", "MAX", "SLT", "SGE", "MAD", "ARL", "DPH", "RCC", "SUB",
+ "ABS", "END",
+ /* GL_ARB_vertex_program */
+ "FLR", "FRC", "EX2", "LG2", "POW", "XPD", "SWZ",
+ /* Mesa-specific */
+ "PRINT",
+ NULL
+};
+
+
+
+/**
+ * Parse a temporary register: Rnn
+ */
+static GLboolean
+Parse_TempReg(struct parse_state *parseState, GLint *tempRegNum)
+{
+ GLubyte token[100];
+
+ /* Should be 'R##' */
+ if (!Parse_Token(parseState, token))
+ RETURN_ERROR;
+ if (token[0] != 'R')
+ RETURN_ERROR1("Expected R##");
+
+ if (IsDigit(token[1])) {
+ GLint reg = _mesa_atoi((char *) (token + 1));
+ if (reg >= MAX_NV_VERTEX_PROGRAM_TEMPS)
+ RETURN_ERROR1("Bad temporary register name");
+ *tempRegNum = reg;
+ }
+ else {
+ RETURN_ERROR1("Bad temporary register name");
+ }
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Parse address register "A0.x"
+ */
+static GLboolean
+Parse_AddrReg(struct parse_state *parseState)
+{
+ /* match 'A0' */
+ if (!Parse_String(parseState, "A0"))
+ RETURN_ERROR;
+
+ /* match '.' */
+ if (!Parse_String(parseState, "."))
+ RETURN_ERROR;
+
+ /* match 'x' */
+ if (!Parse_String(parseState, "x"))
+ RETURN_ERROR;
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Parse absolute program parameter register "c[##]"
+ */
+static GLboolean
+Parse_AbsParamReg(struct parse_state *parseState, GLint *regNum)
+{
+ GLubyte token[100];
+
+ if (!Parse_String(parseState, "c"))
+ RETURN_ERROR;
+
+ if (!Parse_String(parseState, "["))
+ RETURN_ERROR;
+
+ if (!Parse_Token(parseState, token))
+ RETURN_ERROR;
+
+ if (IsDigit(token[0])) {
+ /* a numbered program parameter register */
+ GLint reg = _mesa_atoi((char *) token);
+ if (reg >= MAX_NV_VERTEX_PROGRAM_PARAMS)
+ RETURN_ERROR1("Bad program parameter number");
+ *regNum = reg;
+ }
+ else {
+ RETURN_ERROR;
+ }
+
+ if (!Parse_String(parseState, "]"))
+ RETURN_ERROR;
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+Parse_ParamReg(struct parse_state *parseState, struct vp_src_register *srcReg)
+{
+ GLubyte token[100];
+
+ if (!Parse_String(parseState, "c"))
+ RETURN_ERROR;
+
+ if (!Parse_String(parseState, "["))
+ RETURN_ERROR;
+
+ if (!Peek_Token(parseState, token))
+ RETURN_ERROR;
+
+ if (IsDigit(token[0])) {
+ /* a numbered program parameter register */
+ GLint reg;
+ (void) Parse_Token(parseState, token);
+ reg = _mesa_atoi((char *) token);
+ if (reg >= MAX_NV_VERTEX_PROGRAM_PARAMS)
+ RETURN_ERROR1("Bad program parameter number");
+ srcReg->File = PROGRAM_ENV_PARAM;
+ srcReg->Index = reg;
+ }
+ else if (_mesa_strcmp((const char *) token, "A0") == 0) {
+ /* address register "A0.x" */
+ if (!Parse_AddrReg(parseState))
+ RETURN_ERROR;
+
+ srcReg->RelAddr = GL_TRUE;
+ srcReg->File = PROGRAM_ENV_PARAM;
+ /* Look for +/-N offset */
+ if (!Peek_Token(parseState, token))
+ RETURN_ERROR;
+
+ if (token[0] == '-' || token[0] == '+') {
+ const GLubyte sign = token[0];
+ (void) Parse_Token(parseState, token); /* consume +/- */
+
+ /* an integer should be next */
+ if (!Parse_Token(parseState, token))
+ RETURN_ERROR;
+
+ if (IsDigit(token[0])) {
+ const GLint k = _mesa_atoi((char *) token);
+ if (sign == '-') {
+ if (k > 64)
+ RETURN_ERROR1("Bad address offset");
+ srcReg->Index = -k;
+ }
+ else {
+ if (k > 63)
+ RETURN_ERROR1("Bad address offset");
+ srcReg->Index = k;
+ }
+ }
+ else {
+ RETURN_ERROR;
+ }
+ }
+ else {
+ /* probably got a ']', catch it below */
+ }
+ }
+ else {
+ RETURN_ERROR;
+ }
+
+ /* Match closing ']' */
+ if (!Parse_String(parseState, "]"))
+ RETURN_ERROR;
+
+ return GL_TRUE;
+}
+
+
+/**
+ * Parse v[#] or v[<name>]
+ */
+static GLboolean
+Parse_AttribReg(struct parse_state *parseState, GLint *tempRegNum)
+{
+ GLubyte token[100];
+ GLint j;
+
+ /* Match 'v' */
+ if (!Parse_String(parseState, "v"))
+ RETURN_ERROR;
+
+ /* Match '[' */
+ if (!Parse_String(parseState, "["))
+ RETURN_ERROR;
+
+ /* match number or named register */
+ if (!Parse_Token(parseState, token))
+ RETURN_ERROR;
+
+ if (parseState->isStateProgram && token[0] != '0')
+ RETURN_ERROR1("Only v[0] accessible in vertex state programs");
+
+ if (IsDigit(token[0])) {
+ GLint reg = _mesa_atoi((char *) token);
+ if (reg >= MAX_NV_VERTEX_PROGRAM_INPUTS)
+ RETURN_ERROR1("Bad vertex attribute register name");
+ *tempRegNum = reg;
+ }
+ else {
+ for (j = 0; InputRegisters[j]; j++) {
+ if (_mesa_strcmp((const char *) token, InputRegisters[j]) == 0) {
+ *tempRegNum = j;
+ break;
+ }
+ }
+ if (!InputRegisters[j]) {
+ /* unknown input register label */
+ RETURN_ERROR2("Bad register name", token);
+ }
+ }
+
+ /* Match '[' */
+ if (!Parse_String(parseState, "]"))
+ RETURN_ERROR;
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+Parse_OutputReg(struct parse_state *parseState, GLint *outputRegNum)
+{
+ GLubyte token[100];
+ GLint start, j;
+
+ /* Match 'o' */
+ if (!Parse_String(parseState, "o"))
+ RETURN_ERROR;
+
+ /* Match '[' */
+ if (!Parse_String(parseState, "["))
+ RETURN_ERROR;
+
+ /* Get output reg name */
+ if (!Parse_Token(parseState, token))
+ RETURN_ERROR;
+
+ if (parseState->isPositionInvariant)
+ start = 1; /* skip HPOS register name */
+ else
+ start = 0;
+
+ /* try to match an output register name */
+ for (j = start; OutputRegisters[j]; j++) {
+ if (_mesa_strcmp((const char *) token, OutputRegisters[j]) == 0) {
+ *outputRegNum = j;
+ break;
+ }
+ }
+ if (!OutputRegisters[j])
+ RETURN_ERROR1("Unrecognized output register name");
+
+ /* Match ']' */
+ if (!Parse_String(parseState, "]"))
+ RETURN_ERROR1("Expected ]");
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+Parse_MaskedDstReg(struct parse_state *parseState, struct vp_dst_register *dstReg)
+{
+ GLubyte token[100];
+ GLint idx;
+
+ /* Dst reg can be R<n> or o[n] */
+ if (!Peek_Token(parseState, token))
+ RETURN_ERROR;
+
+ if (token[0] == 'R') {
+ /* a temporary register */
+ dstReg->File = PROGRAM_TEMPORARY;
+ if (!Parse_TempReg(parseState, &idx))
+ RETURN_ERROR;
+ dstReg->Index = idx;
+ }
+ else if (!parseState->isStateProgram && token[0] == 'o') {
+ /* an output register */
+ dstReg->File = PROGRAM_OUTPUT;
+ if (!Parse_OutputReg(parseState, &idx))
+ RETURN_ERROR;
+ dstReg->Index = idx;
+ }
+ else if (parseState->isStateProgram && token[0] == 'c' &&
+ parseState->isStateProgram) {
+ /* absolute program parameter register */
+ /* Only valid for vertex state programs */
+ dstReg->File = PROGRAM_ENV_PARAM;
+ if (!Parse_AbsParamReg(parseState, &idx))
+ RETURN_ERROR;
+ dstReg->Index = idx;
+ }
+ else {
+ RETURN_ERROR1("Bad destination register name");
+ }
+
+ /* Parse optional write mask */
+ if (!Peek_Token(parseState, token))
+ RETURN_ERROR;
+
+ if (token[0] == '.') {
+ /* got a mask */
+ GLint k = 0;
+
+ if (!Parse_String(parseState, "."))
+ RETURN_ERROR;
+
+ if (!Parse_Token(parseState, token))
+ RETURN_ERROR;
+
+ dstReg->WriteMask = 0;
+
+ if (token[k] == 'x') {
+ dstReg->WriteMask |= WRITEMASK_X;
+ k++;
+ }
+ if (token[k] == 'y') {
+ dstReg->WriteMask |= WRITEMASK_Y;
+ k++;
+ }
+ if (token[k] == 'z') {
+ dstReg->WriteMask |= WRITEMASK_Z;
+ k++;
+ }
+ if (token[k] == 'w') {
+ dstReg->WriteMask |= WRITEMASK_W;
+ k++;
+ }
+ if (k == 0) {
+ RETURN_ERROR1("Bad writemask character");
+ }
+ return GL_TRUE;
+ }
+ else {
+ dstReg->WriteMask = WRITEMASK_XYZW;
+ return GL_TRUE;
+ }
+}
+
+
+static GLboolean
+Parse_SwizzleSrcReg(struct parse_state *parseState, struct vp_src_register *srcReg)
+{
+ GLubyte token[100];
+ GLint idx;
+
+ srcReg->RelAddr = GL_FALSE;
+
+ /* check for '-' */
+ if (!Peek_Token(parseState, token))
+ RETURN_ERROR;
+ if (token[0] == '-') {
+ (void) Parse_String(parseState, "-");
+ srcReg->Negate = GL_TRUE;
+ if (!Peek_Token(parseState, token))
+ RETURN_ERROR;
+ }
+ else {
+ srcReg->Negate = GL_FALSE;
+ }
+
+ /* Src reg can be R<n>, c[n], c[n +/- offset], or a named vertex attrib */
+ if (token[0] == 'R') {
+ srcReg->File = PROGRAM_TEMPORARY;
+ if (!Parse_TempReg(parseState, &idx))
+ RETURN_ERROR;
+ srcReg->Index = idx;
+ }
+ else if (token[0] == 'c') {
+ if (!Parse_ParamReg(parseState, srcReg))
+ RETURN_ERROR;
+ }
+ else if (token[0] == 'v') {
+ srcReg->File = PROGRAM_INPUT;
+ if (!Parse_AttribReg(parseState, &idx))
+ RETURN_ERROR;
+ srcReg->Index = idx;
+ }
+ else {
+ RETURN_ERROR2("Bad source register name", token);
+ }
+
+ /* init swizzle fields */
+ srcReg->Swizzle = SWIZZLE_NOOP;
+
+ /* Look for optional swizzle suffix */
+ if (!Peek_Token(parseState, token))
+ RETURN_ERROR;
+ if (token[0] == '.') {
+ (void) Parse_String(parseState, "."); /* consume . */
+
+ if (!Parse_Token(parseState, token))
+ RETURN_ERROR;
+
+ if (token[1] == 0) {
+ /* single letter swizzle */
+ if (token[0] == 'x')
+ srcReg->Swizzle = MAKE_SWIZZLE4(0, 0, 0, 0);
+ else if (token[0] == 'y')
+ srcReg->Swizzle = MAKE_SWIZZLE4(1, 1, 1, 1);
+ else if (token[0] == 'z')
+ srcReg->Swizzle = MAKE_SWIZZLE4(2, 2, 2, 2);
+ else if (token[0] == 'w')
+ srcReg->Swizzle = MAKE_SWIZZLE4(3, 3, 3, 3);
+ else
+ RETURN_ERROR1("Expected x, y, z, or w");
+ }
+ else {
+ /* 2, 3 or 4-component swizzle */
+ GLint k;
+ for (k = 0; token[k] && k < 5; k++) {
+ if (token[k] == 'x')
+ srcReg->Swizzle |= 0 << (k*3);
+ else if (token[k] == 'y')
+ srcReg->Swizzle |= 1 << (k*3);
+ else if (token[k] == 'z')
+ srcReg->Swizzle |= 2 << (k*3);
+ else if (token[k] == 'w')
+ srcReg->Swizzle |= 3 << (k*3);
+ else
+ RETURN_ERROR;
+ }
+ if (k >= 5)
+ RETURN_ERROR;
+ }
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+Parse_ScalarSrcReg(struct parse_state *parseState, struct vp_src_register *srcReg)
+{
+ GLubyte token[100];
+ GLint idx;
+
+ srcReg->RelAddr = GL_FALSE;
+
+ /* check for '-' */
+ if (!Peek_Token(parseState, token))
+ RETURN_ERROR;
+ if (token[0] == '-') {
+ srcReg->Negate = GL_TRUE;
+ (void) Parse_String(parseState, "-"); /* consume '-' */
+ if (!Peek_Token(parseState, token))
+ RETURN_ERROR;
+ }
+ else {
+ srcReg->Negate = GL_FALSE;
+ }
+
+ /* Src reg can be R<n>, c[n], c[n +/- offset], or a named vertex attrib */
+ if (token[0] == 'R') {
+ srcReg->File = PROGRAM_TEMPORARY;
+ if (!Parse_TempReg(parseState, &idx))
+ RETURN_ERROR;
+ srcReg->Index = idx;
+ }
+ else if (token[0] == 'c') {
+ if (!Parse_ParamReg(parseState, srcReg))
+ RETURN_ERROR;
+ }
+ else if (token[0] == 'v') {
+ srcReg->File = PROGRAM_INPUT;
+ if (!Parse_AttribReg(parseState, &idx))
+ RETURN_ERROR;
+ srcReg->Index = idx;
+ }
+ else {
+ RETURN_ERROR2("Bad source register name", token);
+ }
+
+ /* Look for .[xyzw] suffix */
+ if (!Parse_String(parseState, "."))
+ RETURN_ERROR;
+
+ if (!Parse_Token(parseState, token))
+ RETURN_ERROR;
+
+ if (token[0] == 'x' && token[1] == 0) {
+ srcReg->Swizzle = 0;
+ }
+ else if (token[0] == 'y' && token[1] == 0) {
+ srcReg->Swizzle = 1;
+ }
+ else if (token[0] == 'z' && token[1] == 0) {
+ srcReg->Swizzle = 2;
+ }
+ else if (token[0] == 'w' && token[1] == 0) {
+ srcReg->Swizzle = 3;
+ }
+ else {
+ RETURN_ERROR1("Bad scalar source suffix");
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLint
+Parse_UnaryOpInstruction(struct parse_state *parseState,
+ struct vp_instruction *inst, enum vp_opcode opcode)
+{
+ if (opcode == VP_OPCODE_ABS && !parseState->isVersion1_1)
+ RETURN_ERROR1("ABS illegal for vertex program 1.0");
+
+ inst->Opcode = opcode;
+ inst->StringPos = parseState->curLine - parseState->start;
+
+ /* dest reg */
+ if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
+ RETURN_ERROR;
+
+ /* comma */
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR;
+
+ /* src arg */
+ if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[0]))
+ RETURN_ERROR;
+
+ /* semicolon */
+ if (!Parse_String(parseState, ";"))
+ RETURN_ERROR;
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+Parse_BiOpInstruction(struct parse_state *parseState,
+ struct vp_instruction *inst, enum vp_opcode opcode)
+{
+ if (opcode == VP_OPCODE_DPH && !parseState->isVersion1_1)
+ RETURN_ERROR1("DPH illegal for vertex program 1.0");
+ if (opcode == VP_OPCODE_SUB && !parseState->isVersion1_1)
+ RETURN_ERROR1("SUB illegal for vertex program 1.0");
+
+ inst->Opcode = opcode;
+ inst->StringPos = parseState->curLine - parseState->start;
+
+ /* dest reg */
+ if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
+ RETURN_ERROR;
+
+ /* comma */
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR;
+
+ /* first src arg */
+ if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[0]))
+ RETURN_ERROR;
+
+ /* comma */
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR;
+
+ /* second src arg */
+ if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[1]))
+ RETURN_ERROR;
+
+ /* semicolon */
+ if (!Parse_String(parseState, ";"))
+ RETURN_ERROR;
+
+ /* make sure we don't reference more than one program parameter register */
+ if (inst->SrcReg[0].File == PROGRAM_ENV_PARAM &&
+ inst->SrcReg[1].File == PROGRAM_ENV_PARAM &&
+ inst->SrcReg[0].Index != inst->SrcReg[1].Index)
+ RETURN_ERROR1("Can't reference two program parameter registers");
+
+ /* make sure we don't reference more than one vertex attribute register */
+ if (inst->SrcReg[0].File == PROGRAM_INPUT &&
+ inst->SrcReg[1].File == PROGRAM_INPUT &&
+ inst->SrcReg[0].Index != inst->SrcReg[1].Index)
+ RETURN_ERROR1("Can't reference two vertex attribute registers");
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+Parse_TriOpInstruction(struct parse_state *parseState,
+ struct vp_instruction *inst, enum vp_opcode opcode)
+{
+ inst->Opcode = opcode;
+ inst->StringPos = parseState->curLine - parseState->start;
+
+ /* dest reg */
+ if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
+ RETURN_ERROR;
+
+ /* comma */
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR;
+
+ /* first src arg */
+ if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[0]))
+ RETURN_ERROR;
+
+ /* comma */
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR;
+
+ /* second src arg */
+ if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[1]))
+ RETURN_ERROR;
+
+ /* comma */
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR;
+
+ /* third src arg */
+ if (!Parse_SwizzleSrcReg(parseState, &inst->SrcReg[2]))
+ RETURN_ERROR;
+
+ /* semicolon */
+ if (!Parse_String(parseState, ";"))
+ RETURN_ERROR;
+
+ /* make sure we don't reference more than one program parameter register */
+ if ((inst->SrcReg[0].File == PROGRAM_ENV_PARAM &&
+ inst->SrcReg[1].File == PROGRAM_ENV_PARAM &&
+ inst->SrcReg[0].Index != inst->SrcReg[1].Index) ||
+ (inst->SrcReg[0].File == PROGRAM_ENV_PARAM &&
+ inst->SrcReg[2].File == PROGRAM_ENV_PARAM &&
+ inst->SrcReg[0].Index != inst->SrcReg[2].Index) ||
+ (inst->SrcReg[1].File == PROGRAM_ENV_PARAM &&
+ inst->SrcReg[2].File == PROGRAM_ENV_PARAM &&
+ inst->SrcReg[1].Index != inst->SrcReg[2].Index))
+ RETURN_ERROR1("Can only reference one program register");
+
+ /* make sure we don't reference more than one vertex attribute register */
+ if ((inst->SrcReg[0].File == PROGRAM_INPUT &&
+ inst->SrcReg[1].File == PROGRAM_INPUT &&
+ inst->SrcReg[0].Index != inst->SrcReg[1].Index) ||
+ (inst->SrcReg[0].File == PROGRAM_INPUT &&
+ inst->SrcReg[2].File == PROGRAM_INPUT &&
+ inst->SrcReg[0].Index != inst->SrcReg[2].Index) ||
+ (inst->SrcReg[1].File == PROGRAM_INPUT &&
+ inst->SrcReg[2].File == PROGRAM_INPUT &&
+ inst->SrcReg[1].Index != inst->SrcReg[2].Index))
+ RETURN_ERROR1("Can only reference one input register");
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+Parse_ScalarInstruction(struct parse_state *parseState,
+ struct vp_instruction *inst, enum vp_opcode opcode)
+{
+ if (opcode == VP_OPCODE_RCC && !parseState->isVersion1_1)
+ RETURN_ERROR1("RCC illegal for vertex program 1.0");
+
+ inst->Opcode = opcode;
+ inst->StringPos = parseState->curLine - parseState->start;
+
+ /* dest reg */
+ if (!Parse_MaskedDstReg(parseState, &inst->DstReg))
+ RETURN_ERROR;
+
+ /* comma */
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR;
+
+ /* first src arg */
+ if (!Parse_ScalarSrcReg(parseState, &inst->SrcReg[0]))
+ RETURN_ERROR;
+
+ /* semicolon */
+ if (!Parse_String(parseState, ";"))
+ RETURN_ERROR;
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+Parse_AddressInstruction(struct parse_state *parseState, struct vp_instruction *inst)
+{
+ inst->Opcode = VP_OPCODE_ARL;
+ inst->StringPos = parseState->curLine - parseState->start;
+
+ /* dest A0 reg */
+ if (!Parse_AddrReg(parseState))
+ RETURN_ERROR;
+
+ /* comma */
+ if (!Parse_String(parseState, ","))
+ RETURN_ERROR;
+
+ /* parse src reg */
+ if (!Parse_ScalarSrcReg(parseState, &inst->SrcReg[0]))
+ RETURN_ERROR;
+
+ /* semicolon */
+ if (!Parse_String(parseState, ";"))
+ RETURN_ERROR;
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+Parse_EndInstruction(struct parse_state *parseState, struct vp_instruction *inst)
+{
+ GLubyte token[100];
+
+ inst->Opcode = VP_OPCODE_END;
+ inst->StringPos = parseState->curLine - parseState->start;
+
+ /* this should fail! */
+ if (Parse_Token(parseState, token))
+ RETURN_ERROR2("Unexpected token after END:", token);
+ else
+ return GL_TRUE;
+}
+
+
+/**
+ * The PRINT instruction is Mesa-specific and is meant as a debugging aid for
+ * the vertex program developer.
+ * The NV_vertex_program extension grammar is modified as follows:
+ *
+ * <instruction> ::= <ARL-instruction>
+ * | ...
+ * | <PRINT-instruction>
+ *
+ * <PRINT-instruction> ::= "PRINT" <string literal>
+ * | "PRINT" <string literal> "," <srcReg>
+ * | "PRINT" <string literal> "," <dstReg>
+ */
+static GLboolean
+Parse_PrintInstruction(struct parse_state *parseState, struct vp_instruction *inst)
+{
+ const GLubyte *str;
+ GLubyte *msg;
+ GLuint len;
+ GLubyte token[100];
+ struct vp_src_register *srcReg = &inst->SrcReg[0];
+ GLint idx;
+
+ inst->Opcode = VP_OPCODE_PRINT;
+ inst->StringPos = parseState->curLine - parseState->start;
+
+ /* The first argument is a literal string 'just like this' */
+ if (!Parse_String(parseState, "'"))
+ RETURN_ERROR;
+
+ str = parseState->pos;
+ for (len = 0; str[len] != '\''; len++) /* find closing quote */
+ ;
+ parseState->pos += len + 1;
+ msg = _mesa_malloc(len + 1);
+
+ _mesa_memcpy(msg, str, len);
+ msg[len] = 0;
+ inst->Data = msg;
+
+ /* comma */
+ if (Parse_String(parseState, ",")) {
+
+ /* The second argument is a register name */
+ if (!Peek_Token(parseState, token))
+ RETURN_ERROR;
+
+ srcReg->RelAddr = GL_FALSE;
+ srcReg->Negate = GL_FALSE;
+ srcReg->Swizzle = SWIZZLE_NOOP;
+
+ /* Register can be R<n>, c[n], c[n +/- offset], a named vertex attrib,
+ * or an o[n] output register.
+ */
+ if (token[0] == 'R') {
+ srcReg->File = PROGRAM_TEMPORARY;
+ if (!Parse_TempReg(parseState, &idx))
+ RETURN_ERROR;
+ srcReg->Index = idx;
+ }
+ else if (token[0] == 'c') {
+ srcReg->File = PROGRAM_ENV_PARAM;
+ if (!Parse_ParamReg(parseState, srcReg))
+ RETURN_ERROR;
+ }
+ else if (token[0] == 'v') {
+ srcReg->File = PROGRAM_INPUT;
+ if (!Parse_AttribReg(parseState, &idx))
+ RETURN_ERROR;
+ srcReg->Index = idx;
+ }
+ else if (token[0] == 'o') {
+ srcReg->File = PROGRAM_OUTPUT;
+ if (!Parse_OutputReg(parseState, &idx))
+ RETURN_ERROR;
+ srcReg->Index = idx;
+ }
+ else {
+ RETURN_ERROR2("Bad source register name", token);
+ }
+ }
+ else {
+ srcReg->File = 0;
+ }
+
+ /* semicolon */
+ if (!Parse_String(parseState, ";"))
+ RETURN_ERROR;
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+Parse_OptionSequence(struct parse_state *parseState,
+ struct vp_instruction program[])
+{
+ (void) program;
+ while (1) {
+ if (!Parse_String(parseState, "OPTION"))
+ return GL_TRUE; /* ok, not an OPTION statement */
+ if (Parse_String(parseState, "NV_position_invariant")) {
+ parseState->isPositionInvariant = GL_TRUE;
+ }
+ else {
+ RETURN_ERROR1("unexpected OPTION statement");
+ }
+ if (!Parse_String(parseState, ";"))
+ return GL_FALSE;
+ }
+}
+
+
+static GLboolean
+Parse_InstructionSequence(struct parse_state *parseState,
+ struct vp_instruction program[])
+{
+ while (1) {
+ struct vp_instruction *inst = program + parseState->numInst;
+
+ /* Initialize the instruction */
+ inst->SrcReg[0].File = PROGRAM_UNDEFINED;
+ inst->SrcReg[1].File = PROGRAM_UNDEFINED;
+ inst->SrcReg[2].File = PROGRAM_UNDEFINED;
+ inst->DstReg.File = PROGRAM_UNDEFINED;
+ inst->Data = NULL;
+
+ if (Parse_String(parseState, "MOV")) {
+ if (!Parse_UnaryOpInstruction(parseState, inst, VP_OPCODE_MOV))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "LIT")) {
+ if (!Parse_UnaryOpInstruction(parseState, inst, VP_OPCODE_LIT))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "ABS")) {
+ if (!Parse_UnaryOpInstruction(parseState, inst, VP_OPCODE_ABS))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "MUL")) {
+ if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_MUL))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "ADD")) {
+ if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_ADD))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "DP3")) {
+ if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_DP3))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "DP4")) {
+ if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_DP4))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "DST")) {
+ if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_DST))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "MIN")) {
+ if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_MIN))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "MAX")) {
+ if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_MAX))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "SLT")) {
+ if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_SLT))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "SGE")) {
+ if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_SGE))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "DPH")) {
+ if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_DPH))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "SUB")) {
+ if (!Parse_BiOpInstruction(parseState, inst, VP_OPCODE_SUB))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "MAD")) {
+ if (!Parse_TriOpInstruction(parseState, inst, VP_OPCODE_MAD))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "RCP")) {
+ if (!Parse_ScalarInstruction(parseState, inst, VP_OPCODE_RCP))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "RSQ")) {
+ if (!Parse_ScalarInstruction(parseState, inst, VP_OPCODE_RSQ))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "EXP")) {
+ if (!Parse_ScalarInstruction(parseState, inst, VP_OPCODE_EXP))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "LOG")) {
+ if (!Parse_ScalarInstruction(parseState, inst, VP_OPCODE_LOG))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "RCC")) {
+ if (!Parse_ScalarInstruction(parseState, inst, VP_OPCODE_RCC))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "ARL")) {
+ if (!Parse_AddressInstruction(parseState, inst))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "PRINT")) {
+ if (!Parse_PrintInstruction(parseState, inst))
+ RETURN_ERROR;
+ }
+ else if (Parse_String(parseState, "END")) {
+ if (!Parse_EndInstruction(parseState, inst))
+ RETURN_ERROR;
+ else {
+ parseState->numInst++;
+ return GL_TRUE; /* all done */
+ }
+ }
+ else {
+ /* bad instruction name */
+ RETURN_ERROR1("Unexpected token");
+ }
+
+ /* examine input/output registers */
+ if (inst->DstReg.File == PROGRAM_OUTPUT)
+ parseState->outputsWritten |= (1 << inst->DstReg.Index);
+ else if (inst->DstReg.File == PROGRAM_ENV_PARAM)
+ parseState->anyProgRegsWritten = GL_TRUE;
+
+ if (inst->SrcReg[0].File == PROGRAM_INPUT)
+ parseState->inputsRead |= (1 << inst->SrcReg[0].Index);
+ if (inst->SrcReg[1].File == PROGRAM_INPUT)
+ parseState->inputsRead |= (1 << inst->SrcReg[1].Index);
+ if (inst->SrcReg[2].File == PROGRAM_INPUT)
+ parseState->inputsRead |= (1 << inst->SrcReg[2].Index);
+
+ parseState->numInst++;
+
+ if (parseState->numInst >= MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS)
+ RETURN_ERROR1("Program too long");
+ }
+
+ RETURN_ERROR;
+}
+
+
+static GLboolean
+Parse_Program(struct parse_state *parseState,
+ struct vp_instruction instBuffer[])
+{
+ if (parseState->isVersion1_1) {
+ if (!Parse_OptionSequence(parseState, instBuffer)) {
+ return GL_FALSE;
+ }
+ }
+ return Parse_InstructionSequence(parseState, instBuffer);
+}
+
+
+/**
+ * Parse/compile the 'str' returning the compiled 'program'.
+ * ctx->Program.ErrorPos will be -1 if successful. Otherwise, ErrorPos
+ * indicates the position of the error in 'str'.
+ */
+void
+_mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum dstTarget,
+ const GLubyte *str, GLsizei len,
+ struct vertex_program *program)
+{
+ struct parse_state parseState;
+ struct vp_instruction instBuffer[MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS];
+ struct vp_instruction *newInst;
+ GLenum target;
+ GLubyte *programString;
+
+ /* Make a null-terminated copy of the program string */
+ programString = (GLubyte *) MALLOC(len + 1);
+ if (!programString) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
+ return;
+ }
+ MEMCPY(programString, str, len);
+ programString[len] = 0;
+
+ /* Get ready to parse */
+ parseState.ctx = ctx;
+ parseState.start = programString;
+ parseState.isPositionInvariant = GL_FALSE;
+ parseState.isVersion1_1 = GL_FALSE;
+ parseState.numInst = 0;
+ parseState.inputsRead = 0;
+ parseState.outputsWritten = 0;
+ parseState.anyProgRegsWritten = GL_FALSE;
+
+ /* Reset error state */
+ _mesa_set_program_error(ctx, -1, NULL);
+
+ /* check the program header */
+ if (_mesa_strncmp((const char *) programString, "!!VP1.0", 7) == 0) {
+ target = GL_VERTEX_PROGRAM_NV;
+ parseState.pos = programString + 7;
+ parseState.isStateProgram = GL_FALSE;
+ }
+ else if (_mesa_strncmp((const char *) programString, "!!VP1.1", 7) == 0) {
+ target = GL_VERTEX_PROGRAM_NV;
+ parseState.pos = programString + 7;
+ parseState.isStateProgram = GL_FALSE;
+ parseState.isVersion1_1 = GL_TRUE;
+ }
+ else if (_mesa_strncmp((const char *) programString, "!!VSP1.0", 8) == 0) {
+ target = GL_VERTEX_STATE_PROGRAM_NV;
+ parseState.pos = programString + 8;
+ parseState.isStateProgram = GL_TRUE;
+ }
+ else {
+ /* invalid header */
+ ctx->Program.ErrorPos = 0;
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV(bad header)");
+ return;
+ }
+
+ /* make sure target and header match */
+ if (target != dstTarget) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glLoadProgramNV(target mismatch)");
+ return;
+ }
+
+
+ if (Parse_Program(&parseState, instBuffer)) {
+ /* successful parse! */
+
+ if (parseState.isStateProgram) {
+ if (!parseState.anyProgRegsWritten) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glLoadProgramNV(c[#] not written)");
+ return;
+ }
+ }
+ else {
+ if (!parseState.isPositionInvariant &&
+ !(parseState.outputsWritten & 1)) {
+ /* bit 1 = HPOS register */
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glLoadProgramNV(HPOS not written)");
+ return;
+ }
+ }
+
+ /* copy the compiled instructions */
+ assert(parseState.numInst <= MAX_NV_VERTEX_PROGRAM_INSTRUCTIONS);
+ newInst = (struct vp_instruction *)
+ MALLOC(parseState.numInst * sizeof(struct vp_instruction));
+ if (!newInst) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glLoadProgramNV");
+ FREE(programString);
+ return; /* out of memory */
+ }
+ MEMCPY(newInst, instBuffer,
+ parseState.numInst * sizeof(struct vp_instruction));
+
+ /* install the program */
+ program->Base.Target = target;
+ if (program->Base.String) {
+ FREE(program->Base.String);
+ }
+ program->Base.String = programString;
+ program->Base.Format = GL_PROGRAM_FORMAT_ASCII_ARB;
+ if (program->Instructions) {
+ FREE(program->Instructions);
+ }
+ program->Instructions = newInst;
+ program->InputsRead = parseState.inputsRead;
+ program->OutputsWritten = parseState.outputsWritten;
+ program->IsPositionInvariant = parseState.isPositionInvariant;
+ program->IsNVProgram = GL_TRUE;
+
+#ifdef DEBUG_foo
+ _mesa_printf("--- glLoadProgramNV result ---\n");
+ _mesa_print_nv_vertex_program(program);
+ _mesa_printf("------------------------------\n");
+#endif
+ }
+ else {
+ /* Error! */
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glLoadProgramNV");
+ /* NOTE: _mesa_set_program_error would have been called already */
+ /* GL_NV_vertex_program isn't supposed to set the error string
+ * so we reset it here.
+ */
+ _mesa_set_program_error(ctx, ctx->Program.ErrorPos, NULL);
+ }
+}
+
+
+static void
+PrintSrcReg(const struct vp_src_register *src)
+{
+ static const char comps[5] = "xyzw";
+ if (src->Negate)
+ _mesa_printf("-");
+ if (src->RelAddr) {
+ if (src->Index > 0)
+ _mesa_printf("c[A0.x + %d]", src->Index);
+ else if (src->Index < 0)
+ _mesa_printf("c[A0.x - %d]", -src->Index);
+ else
+ _mesa_printf("c[A0.x]");
+ }
+ else if (src->File == PROGRAM_OUTPUT) {
+ _mesa_printf("o[%s]", OutputRegisters[src->Index]);
+ }
+ else if (src->File == PROGRAM_INPUT) {
+ _mesa_printf("v[%s]", InputRegisters[src->Index]);
+ }
+ else if (src->File == PROGRAM_ENV_PARAM) {
+ _mesa_printf("c[%d]", src->Index);
+ }
+ else {
+ ASSERT(src->File == PROGRAM_TEMPORARY);
+ _mesa_printf("R%d", src->Index);
+ }
+
+ if (GET_SWZ(src->Swizzle, 0) == GET_SWZ(src->Swizzle, 1) &&
+ GET_SWZ(src->Swizzle, 0) == GET_SWZ(src->Swizzle, 2) &&
+ GET_SWZ(src->Swizzle, 0) == GET_SWZ(src->Swizzle, 3)) {
+ _mesa_printf(".%c", comps[GET_SWZ(src->Swizzle, 0)]);
+ }
+ else if (src->Swizzle != SWIZZLE_NOOP) {
+ _mesa_printf(".%c%c%c%c",
+ comps[GET_SWZ(src->Swizzle, 0)],
+ comps[GET_SWZ(src->Swizzle, 1)],
+ comps[GET_SWZ(src->Swizzle, 2)],
+ comps[GET_SWZ(src->Swizzle, 3)]);
+ }
+}
+
+
+static void
+PrintDstReg(const struct vp_dst_register *dst)
+{
+ if (dst->File == PROGRAM_OUTPUT) {
+ _mesa_printf("o[%s]", OutputRegisters[dst->Index]);
+ }
+ else if (dst->File == PROGRAM_INPUT) {
+ _mesa_printf("v[%s]", InputRegisters[dst->Index]);
+ }
+ else if (dst->File == PROGRAM_ENV_PARAM) {
+ _mesa_printf("c[%d]", dst->Index);
+ }
+ else {
+ ASSERT(dst->File == PROGRAM_TEMPORARY);
+ _mesa_printf("R%d", dst->Index);
+ }
+
+ if (dst->WriteMask != 0 && dst->WriteMask != 0xf) {
+ _mesa_printf(".");
+ if (dst->WriteMask & 0x1)
+ _mesa_printf("x");
+ if (dst->WriteMask & 0x2)
+ _mesa_printf("y");
+ if (dst->WriteMask & 0x4)
+ _mesa_printf("z");
+ if (dst->WriteMask & 0x8)
+ _mesa_printf("w");
+ }
+}
+
+
+/**
+ * Print a single NVIDIA vertex program instruction.
+ */
+void
+_mesa_print_nv_vertex_instruction(const struct vp_instruction *inst)
+{
+ switch (inst->Opcode) {
+ case VP_OPCODE_MOV:
+ case VP_OPCODE_LIT:
+ case VP_OPCODE_RCP:
+ case VP_OPCODE_RSQ:
+ case VP_OPCODE_EXP:
+ case VP_OPCODE_LOG:
+ case VP_OPCODE_RCC:
+ case VP_OPCODE_ABS:
+ _mesa_printf("%s ", Opcodes[(int) inst->Opcode]);
+ PrintDstReg(&inst->DstReg);
+ _mesa_printf(", ");
+ PrintSrcReg(&inst->SrcReg[0]);
+ _mesa_printf(";\n");
+ break;
+ case VP_OPCODE_MUL:
+ case VP_OPCODE_ADD:
+ case VP_OPCODE_DP3:
+ case VP_OPCODE_DP4:
+ case VP_OPCODE_DST:
+ case VP_OPCODE_MIN:
+ case VP_OPCODE_MAX:
+ case VP_OPCODE_SLT:
+ case VP_OPCODE_SGE:
+ case VP_OPCODE_DPH:
+ case VP_OPCODE_SUB:
+ _mesa_printf("%s ", Opcodes[(int) inst->Opcode]);
+ PrintDstReg(&inst->DstReg);
+ _mesa_printf(", ");
+ PrintSrcReg(&inst->SrcReg[0]);
+ _mesa_printf(", ");
+ PrintSrcReg(&inst->SrcReg[1]);
+ _mesa_printf(";\n");
+ break;
+ case VP_OPCODE_MAD:
+ _mesa_printf("MAD ");
+ PrintDstReg(&inst->DstReg);
+ _mesa_printf(", ");
+ PrintSrcReg(&inst->SrcReg[0]);
+ _mesa_printf(", ");
+ PrintSrcReg(&inst->SrcReg[1]);
+ _mesa_printf(", ");
+ PrintSrcReg(&inst->SrcReg[2]);
+ _mesa_printf(";\n");
+ break;
+ case VP_OPCODE_ARL:
+ _mesa_printf("ARL A0.x, ");
+ PrintSrcReg(&inst->SrcReg[0]);
+ _mesa_printf(";\n");
+ break;
+ case VP_OPCODE_PRINT:
+ _mesa_printf("PRINT '%s'", inst->Data);
+ if (inst->SrcReg[0].File) {
+ _mesa_printf(", ");
+ PrintSrcReg(&inst->SrcReg[0]);
+ _mesa_printf(";\n");
+ }
+ else {
+ _mesa_printf("\n");
+ }
+ break;
+ case VP_OPCODE_END:
+ _mesa_printf("END\n");
+ break;
+ default:
+ _mesa_printf("BAD INSTRUCTION\n");
+ }
+}
+
+
+/**
+ * Print (unparse) the given vertex program. Just for debugging.
+ */
+void
+_mesa_print_nv_vertex_program(const struct vertex_program *program)
+{
+ const struct vp_instruction *inst;
+
+ for (inst = program->Instructions; ; inst++) {
+ _mesa_print_nv_vertex_instruction(inst);
+ if (inst->Opcode == VP_OPCODE_END)
+ return;
+ }
+}
+
+
+const char *
+_mesa_nv_vertex_input_register_name(GLuint i)
+{
+ ASSERT(i < MAX_NV_VERTEX_PROGRAM_INPUTS);
+ return InputRegisters[i];
+}
+
+
+const char *
+_mesa_nv_vertex_output_register_name(GLuint i)
+{
+ ASSERT(i < MAX_NV_VERTEX_PROGRAM_OUTPUTS);
+ return OutputRegisters[i];
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/nvvertparse.h b/nx-X11/extras/Mesa/src/mesa/shader/nvvertparse.h
new file mode 100644
index 000000000..205885f45
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/nvvertparse.h
@@ -0,0 +1,50 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ *
+ * Authors:
+ * Brian Paul
+ */
+
+
+#ifndef NVVERTPARSE_H
+#define NVVERTPARSE_H
+
+
+extern void
+_mesa_parse_nv_vertex_program(GLcontext *ctx, GLenum target,
+ const GLubyte *str, GLsizei len,
+ struct vertex_program *program);
+
+extern void
+_mesa_print_nv_vertex_instruction(const struct vp_instruction *inst);
+
+extern void
+_mesa_print_nv_vertex_program(const struct vertex_program *program);
+
+extern const char *
+_mesa_nv_vertex_input_register_name(GLuint i);
+
+extern const char *
+_mesa_nv_vertex_output_register_name(GLuint i);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/nvvertprog.h b/nx-X11/extras/Mesa/src/mesa/shader/nvvertprog.h
new file mode 100644
index 000000000..b8dbe3631
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/nvvertprog.h
@@ -0,0 +1,111 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3.1
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/* Private vertex program types and constants only used by files
+ * related to vertex programs.
+ *
+ * XXX TO-DO: Rename this file "vertprog.h" since it's not NV-specific.
+ */
+
+
+#ifndef NVVERTPROG_H
+#define NVVERTPROG_H
+
+
+/* Vertex program opcodes */
+enum vp_opcode
+{
+ VP_OPCODE_ABS,
+ VP_OPCODE_ADD,
+ VP_OPCODE_ARL,
+ VP_OPCODE_DP3,
+ VP_OPCODE_DP4,
+ VP_OPCODE_DPH,
+ VP_OPCODE_DST,
+ VP_OPCODE_END, /* Placeholder */
+ VP_OPCODE_EX2, /* ARB only */
+ VP_OPCODE_EXP,
+ VP_OPCODE_FLR, /* ARB */
+ VP_OPCODE_FRC, /* ARB */
+ VP_OPCODE_LG2, /* ARB only */
+ VP_OPCODE_LIT,
+ VP_OPCODE_LOG,
+ VP_OPCODE_MAD,
+ VP_OPCODE_MAX,
+ VP_OPCODE_MIN,
+ VP_OPCODE_MOV,
+ VP_OPCODE_MUL,
+ VP_OPCODE_POW, /* ARB only */
+ VP_OPCODE_PRINT, /* Mesa only */
+ VP_OPCODE_RCC,
+ VP_OPCODE_RCP,
+ VP_OPCODE_RSQ,
+ VP_OPCODE_SGE,
+ VP_OPCODE_SLT,
+ VP_OPCODE_SUB,
+ VP_OPCODE_SWZ, /* ARB only */
+ VP_OPCODE_XPD, /* ARB only */
+
+ VP_MAX_OPCODE
+};
+
+
+
+/* Instruction source register */
+struct vp_src_register
+{
+ GLuint File:4; /* one of the PROGRAM_* register file values */
+ GLint Index:9; /* may be negative for relative addressing */
+ GLuint Swizzle:12;
+ GLuint Negate:4; /* ARB requires component-wise negation. */
+ GLuint RelAddr:1;
+ GLuint pad:2;
+};
+
+
+/* Instruction destination register */
+struct vp_dst_register
+{
+ GLuint File:4; /* one of the PROGRAM_* register file values */
+ GLuint Index:8;
+ GLuint WriteMask:4;
+ GLuint pad:16;
+};
+
+
+/* Vertex program instruction */
+struct vp_instruction
+{
+ GLshort Opcode;
+#if FEATURE_MESA_program_debug
+ GLshort StringPos;
+#endif
+ void *Data; /* some arbitrary data, only used for PRINT instruction now */
+ struct vp_src_register SrcReg[3];
+ struct vp_dst_register DstReg;
+};
+
+
+#endif /* VERTPROG_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/program.c b/nx-X11/extras/Mesa/src/mesa/shader/program.c
new file mode 100644
index 000000000..0ccc741dd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/program.c
@@ -0,0 +1,1405 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.2
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file program.c
+ * Vertex and fragment program support functions.
+ * \author Brian Paul
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "hash.h"
+#include "imports.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "program.h"
+#include "nvfragparse.h"
+#include "nvfragprog.h"
+#include "nvvertparse.h"
+#include "nvvertprog.h"
+
+
+/**********************************************************************/
+/* Utility functions */
+/**********************************************************************/
+
+
+/* A pointer to this dummy program is put into the hash table when
+ * glGenPrograms is called.
+ */
+struct program _mesa_DummyProgram;
+
+
+/**
+ * Init context's vertex/fragment program state
+ */
+void
+_mesa_init_program(GLcontext *ctx)
+{
+ GLuint i;
+
+ ctx->Program.ErrorPos = -1;
+ ctx->Program.ErrorString = _mesa_strdup("");
+
+#if FEATURE_NV_vertex_program || FEATURE_ARB_vertex_program
+ ctx->VertexProgram.Enabled = GL_FALSE;
+ ctx->VertexProgram.PointSizeEnabled = GL_FALSE;
+ ctx->VertexProgram.TwoSideEnabled = GL_FALSE;
+ ctx->VertexProgram.Current = (struct vertex_program *) ctx->Shared->DefaultVertexProgram;
+ assert(ctx->VertexProgram.Current);
+ ctx->VertexProgram.Current->Base.RefCount++;
+ for (i = 0; i < MAX_NV_VERTEX_PROGRAM_PARAMS / 4; i++) {
+ ctx->VertexProgram.TrackMatrix[i] = GL_NONE;
+ ctx->VertexProgram.TrackMatrixTransform[i] = GL_IDENTITY_NV;
+ }
+#endif
+
+#if FEATURE_NV_fragment_program || FEATURE_ARB_fragment_program
+ ctx->FragmentProgram.Enabled = GL_FALSE;
+ ctx->FragmentProgram.Current = (struct fragment_program *) ctx->Shared->DefaultFragmentProgram;
+ assert(ctx->FragmentProgram.Current);
+ ctx->FragmentProgram.Current->Base.RefCount++;
+#endif
+
+#if FEATURE_ATI_fragment_shader
+ ctx->ATIFragmentShader.Enabled = GL_FALSE;
+ ctx->ATIFragmentShader.Current = (struct ati_fragment_shader *) ctx->Shared->DefaultFragmentShader;
+ assert(ctx->ATIFragmentShader.Current);
+ ctx->ATIFragmentShader.Current->Base.RefCount++;
+#endif
+}
+
+
+/**
+ * Free a context's vertex/fragment program state
+ */
+void
+_mesa_free_program_data(GLcontext *ctx)
+{
+#if FEATURE_NV_vertex_program
+ if (ctx->VertexProgram.Current) {
+ ctx->VertexProgram.Current->Base.RefCount--;
+ if (ctx->VertexProgram.Current->Base.RefCount <= 0)
+ ctx->Driver.DeleteProgram(ctx, &(ctx->VertexProgram.Current->Base));
+ }
+#endif
+#if FEATURE_NV_fragment_program
+ if (ctx->FragmentProgram.Current) {
+ ctx->FragmentProgram.Current->Base.RefCount--;
+ if (ctx->FragmentProgram.Current->Base.RefCount <= 0)
+ ctx->Driver.DeleteProgram(ctx, &(ctx->FragmentProgram.Current->Base));
+ }
+#endif
+#if FEATURE_ATI_fragment_shader
+ if (ctx->ATIFragmentShader.Current) {
+ ctx->ATIFragmentShader.Current->Base.RefCount--;
+ if (ctx->ATIFragmentShader.Current->Base.RefCount <= 0)
+ ctx->Driver.DeleteProgram(ctx, &(ctx->ATIFragmentShader.Current->Base));
+ }
+#endif
+ _mesa_free((void *) ctx->Program.ErrorString);
+}
+
+
+
+
+/**
+ * Set the vertex/fragment program error state (position and error string).
+ * This is generally called from within the parsers.
+ */
+void
+_mesa_set_program_error(GLcontext *ctx, GLint pos, const char *string)
+{
+ ctx->Program.ErrorPos = pos;
+ _mesa_free((void *) ctx->Program.ErrorString);
+ if (!string)
+ string = "";
+ ctx->Program.ErrorString = _mesa_strdup(string);
+}
+
+
+/**
+ * Find the line number and column for 'pos' within 'string'.
+ * Return a copy of the line which contains 'pos'. Free the line with
+ * _mesa_free().
+ * \param string the program string
+ * \param pos the position within the string
+ * \param line returns the line number corresponding to 'pos'.
+ * \param col returns the column number corresponding to 'pos'.
+ * \return copy of the line containing 'pos'.
+ */
+const GLubyte *
+_mesa_find_line_column(const GLubyte *string, const GLubyte *pos,
+ GLint *line, GLint *col)
+{
+ const GLubyte *lineStart = string;
+ const GLubyte *p = string;
+ GLubyte *s;
+ int len;
+
+ *line = 1;
+
+ while (p != pos) {
+ if (*p == (GLubyte) '\n') {
+ (*line)++;
+ lineStart = p + 1;
+ }
+ p++;
+ }
+
+ *col = (pos - lineStart) + 1;
+
+ /* return copy of this line */
+ while (*p != 0 && *p != '\n')
+ p++;
+ len = p - lineStart;
+ s = (GLubyte *) _mesa_malloc(len + 1);
+ _mesa_memcpy(s, lineStart, len);
+ s[len] = 0;
+
+ return s;
+}
+
+
+/**
+ * Initialize a new vertex/fragment program object.
+ */
+static struct program *
+_mesa_init_program_struct( GLcontext *ctx, struct program *prog,
+ GLenum target, GLuint id)
+{
+ (void) ctx;
+ if (prog) {
+ prog->Id = id;
+ prog->Target = target;
+ prog->Resident = GL_TRUE;
+ prog->RefCount = 1;
+ }
+
+ return prog;
+}
+
+
+/**
+ * Initialize a new fragment program object.
+ */
+struct program *
+_mesa_init_fragment_program( GLcontext *ctx, struct fragment_program *prog,
+ GLenum target, GLuint id)
+{
+ if (prog)
+ return _mesa_init_program_struct( ctx, &prog->Base, target, id );
+ else
+ return NULL;
+}
+
+
+/**
+ * Initialize a new vertex program object.
+ */
+struct program *
+_mesa_init_vertex_program( GLcontext *ctx, struct vertex_program *prog,
+ GLenum target, GLuint id)
+{
+ if (prog)
+ return _mesa_init_program_struct( ctx, &prog->Base, target, id );
+ else
+ return NULL;
+}
+
+/**
+ * Initialize a new ATI fragment shader object.
+ */
+struct program *
+_mesa_init_ati_fragment_shader( GLcontext *ctx,
+ struct ati_fragment_shader *prog,
+ GLenum target, GLuint id )
+{
+ if (prog)
+ return _mesa_init_program_struct( ctx, &prog->Base, target, id );
+ else
+ return NULL;
+}
+
+
+
+/**
+ * Allocate and initialize a new fragment/vertex program object but
+ * don't put it into the program hash table. Called via
+ * ctx->Driver.NewProgram. May be overridden (ie. replaced) by a
+ * device driver function to implement OO deriviation with additional
+ * types not understood by this function.
+ *
+ * \param ctx context
+ * \param id program id/number
+ * \param target program target/type
+ * \return pointer to new program object
+ */
+struct program *
+_mesa_new_program(GLcontext *ctx, GLenum target, GLuint id)
+{
+ switch (target) {
+ case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */
+ return _mesa_init_vertex_program( ctx, CALLOC_STRUCT(vertex_program),
+ target, id );
+ case GL_FRAGMENT_PROGRAM_NV:
+ case GL_FRAGMENT_PROGRAM_ARB:
+ return _mesa_init_fragment_program( ctx, CALLOC_STRUCT(fragment_program),
+ target, id );
+ case GL_FRAGMENT_SHADER_ATI:
+ return _mesa_init_ati_fragment_shader( ctx, CALLOC_STRUCT(ati_fragment_shader),
+ target, id );
+
+ default:
+ _mesa_problem(ctx, "bad target in _mesa_new_program");
+ return NULL;
+ }
+}
+
+
+/**
+ * Delete a program and remove it from the hash table, ignoring the
+ * reference count.
+ * Called via ctx->Driver.DeleteProgram. May be wrapped (OO deriviation)
+ * by a device driver function.
+ */
+void
+_mesa_delete_program(GLcontext *ctx, struct program *prog)
+{
+ (void) ctx;
+ ASSERT(prog);
+
+ if (prog->String)
+ _mesa_free(prog->String);
+ if (prog->Target == GL_VERTEX_PROGRAM_NV ||
+ prog->Target == GL_VERTEX_STATE_PROGRAM_NV) {
+ struct vertex_program *vprog = (struct vertex_program *) prog;
+ if (vprog->Instructions) {
+ GLuint i;
+ for (i = 0; i < vprog->Base.NumInstructions; i++) {
+ if (vprog->Instructions[i].Data)
+ _mesa_free(vprog->Instructions[i].Data);
+ }
+ _mesa_free(vprog->Instructions);
+ }
+ if (vprog->Parameters)
+ _mesa_free_parameter_list(vprog->Parameters);
+ }
+ else if (prog->Target == GL_FRAGMENT_PROGRAM_NV ||
+ prog->Target == GL_FRAGMENT_PROGRAM_ARB) {
+ struct fragment_program *fprog = (struct fragment_program *) prog;
+ if (fprog->Instructions) {
+ GLuint i;
+ for (i = 0; i < fprog->Base.NumInstructions; i++) {
+ if (fprog->Instructions[i].Data)
+ _mesa_free(fprog->Instructions[i].Data);
+ }
+ _mesa_free(fprog->Instructions);
+ }
+ if (fprog->Parameters)
+ _mesa_free_parameter_list(fprog->Parameters);
+ }
+ else if (prog->Target == GL_FRAGMENT_SHADER_ATI) {
+ struct ati_fragment_shader *atifs = (struct ati_fragment_shader *)prog;
+ if (atifs->Instructions)
+ _mesa_free(atifs->Instructions);
+ }
+
+ _mesa_free(prog);
+}
+
+
+
+/**********************************************************************/
+/* Program parameter functions */
+/**********************************************************************/
+
+struct program_parameter_list *
+_mesa_new_parameter_list(void)
+{
+ return (struct program_parameter_list *)
+ _mesa_calloc(sizeof(struct program_parameter_list));
+}
+
+
+/**
+ * Free a parameter list and all its parameters
+ */
+void
+_mesa_free_parameter_list(struct program_parameter_list *paramList)
+{
+ _mesa_free_parameters(paramList);
+ _mesa_free(paramList->Parameters);
+ if (paramList->ParameterValues)
+ ALIGN_FREE(paramList->ParameterValues);
+ _mesa_free(paramList);
+}
+
+
+/**
+ * Free all the parameters in the given list, but don't free the
+ * paramList structure itself.
+ */
+void
+_mesa_free_parameters(struct program_parameter_list *paramList)
+{
+ GLuint i;
+ for (i = 0; i < paramList->NumParameters; i++) {
+ if (paramList->Parameters[i].Name)
+ _mesa_free((void *) paramList->Parameters[i].Name);
+ }
+ paramList->NumParameters = 0;
+}
+
+
+/**
+ * Helper function used by the functions below.
+ */
+static GLint
+add_parameter(struct program_parameter_list *paramList,
+ const char *name, const GLfloat values[4],
+ enum parameter_type type)
+{
+ const GLuint n = paramList->NumParameters;
+
+ if (n == paramList->Size) {
+ GLfloat (*tmp)[4];
+
+ paramList->Size *= 2;
+ if (!paramList->Size)
+ paramList->Size = 8;
+
+ paramList->Parameters = (struct program_parameter *)
+ _mesa_realloc(paramList->Parameters,
+ n * sizeof(struct program_parameter),
+ paramList->Size * sizeof(struct program_parameter));
+
+ tmp = paramList->ParameterValues;
+ paramList->ParameterValues = ALIGN_MALLOC(paramList->Size * 4 * sizeof(GLfloat), 16);
+ if (tmp) {
+ _mesa_memcpy(paramList->ParameterValues, tmp,
+ n * 4 * sizeof(GLfloat));
+ ALIGN_FREE(tmp);
+ }
+ }
+
+ if (!paramList->Parameters ||
+ !paramList->ParameterValues) {
+ /* out of memory */
+ paramList->NumParameters = 0;
+ paramList->Size = 0;
+ return -1;
+ }
+ else {
+ paramList->NumParameters = n + 1;
+
+ _mesa_memset(&paramList->Parameters[n], 0,
+ sizeof(struct program_parameter));
+
+ paramList->Parameters[n].Name = name ? _mesa_strdup(name) : NULL;
+ paramList->Parameters[n].Type = type;
+ if (values)
+ COPY_4V(paramList->ParameterValues[n], values);
+ return (GLint) n;
+ }
+}
+
+
+/**
+ * Add a new named program parameter (Ex: NV_fragment_program DEFINE statement)
+ * \return index of the new entry in the parameter list
+ */
+GLint
+_mesa_add_named_parameter(struct program_parameter_list *paramList,
+ const char *name, const GLfloat values[4])
+{
+ return add_parameter(paramList, name, values, NAMED_PARAMETER);
+}
+
+
+/**
+ * Add a new unnamed constant to the parameter list.
+ * \param paramList - the parameter list
+ * \param values - four float values
+ * \return index of the new parameter.
+ */
+GLint
+_mesa_add_named_constant(struct program_parameter_list *paramList,
+ const char *name, const GLfloat values[4])
+{
+ return add_parameter(paramList, name, values, CONSTANT);
+}
+
+
+/**
+ * Add a new unnamed constant to the parameter list.
+ * \param paramList - the parameter list
+ * \param values - four float values
+ * \return index of the new parameter.
+ */
+GLint
+_mesa_add_unnamed_constant(struct program_parameter_list *paramList,
+ const GLfloat values[4])
+{
+ return add_parameter(paramList, NULL, values, CONSTANT);
+}
+
+
+/**
+ * Add a new state reference to the parameter list.
+ * \param paramList - the parameter list
+ * \param state - an array of 6 state tokens
+ *
+ * \return index of the new parameter.
+ */
+GLint
+_mesa_add_state_reference(struct program_parameter_list *paramList,
+ GLint *stateTokens)
+{
+ /* XXX Should we parse <stateString> here and produce the parameter's
+ * list of STATE_* tokens here, or in the parser?
+ */
+ GLint a, idx;
+
+ idx = add_parameter(paramList, NULL, NULL, STATE);
+
+ for (a=0; a<6; a++)
+ paramList->Parameters[idx].StateIndexes[a] = (enum state_index) stateTokens[a];
+
+ return idx;
+}
+
+
+/**
+ * Lookup a parameter value by name in the given parameter list.
+ * \return pointer to the float[4] values.
+ */
+GLfloat *
+_mesa_lookup_parameter_value(struct program_parameter_list *paramList,
+ GLsizei nameLen, const char *name)
+{
+ GLuint i;
+
+ if (!paramList)
+ return NULL;
+
+ if (nameLen == -1) {
+ /* name is null-terminated */
+ for (i = 0; i < paramList->NumParameters; i++) {
+ if (paramList->Parameters[i].Name &&
+ _mesa_strcmp(paramList->Parameters[i].Name, name) == 0)
+ return paramList->ParameterValues[i];
+ }
+ }
+ else {
+ /* name is not null-terminated, use nameLen */
+ for (i = 0; i < paramList->NumParameters; i++) {
+ if (paramList->Parameters[i].Name &&
+ _mesa_strncmp(paramList->Parameters[i].Name, name, nameLen) == 0
+ && _mesa_strlen(paramList->Parameters[i].Name) == (size_t)nameLen)
+ return paramList->ParameterValues[i];
+ }
+ }
+ return NULL;
+}
+
+
+/**
+ * Lookup a parameter index by name in the given parameter list.
+ * \return index of parameter in the list.
+ */
+GLint
+_mesa_lookup_parameter_index(struct program_parameter_list *paramList,
+ GLsizei nameLen, const char *name)
+{
+ GLint i;
+
+ if (!paramList)
+ return -1;
+
+ if (nameLen == -1) {
+ /* name is null-terminated */
+ for (i = 0; i < (GLint) paramList->NumParameters; i++) {
+ if (paramList->Parameters[i].Name &&
+ _mesa_strcmp(paramList->Parameters[i].Name, name) == 0)
+ return i;
+ }
+ }
+ else {
+ /* name is not null-terminated, use nameLen */
+ for (i = 0; i < (GLint) paramList->NumParameters; i++) {
+ if (paramList->Parameters[i].Name &&
+ _mesa_strncmp(paramList->Parameters[i].Name, name, nameLen) == 0
+ && _mesa_strlen(paramList->Parameters[i].Name) == (size_t)nameLen)
+ return i;
+ }
+ }
+ return -1;
+}
+
+
+/**
+ * Use the list of tokens in the state[] array to find global GL state
+ * and return it in <value>. Usually, four values are returned in <value>
+ * but matrix queries may return as many as 16 values.
+ * This function is used for ARB vertex/fragment programs.
+ * The program parser will produce the state[] values.
+ */
+static void
+_mesa_fetch_state(GLcontext *ctx, const enum state_index state[],
+ GLfloat *value)
+{
+ switch (state[0]) {
+ case STATE_MATERIAL:
+ {
+ /* state[1] is either 0=front or 1=back side */
+ const GLuint face = (GLuint) state[1];
+ /* state[2] is the material attribute */
+ switch (state[2]) {
+ case STATE_AMBIENT:
+ if (face == 0)
+ COPY_4V(value, ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_AMBIENT]);
+ else
+ COPY_4V(value, ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_AMBIENT]);
+ return;
+ case STATE_DIFFUSE:
+ if (face == 0)
+ COPY_4V(value, ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE]);
+ else
+ COPY_4V(value, ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE]);
+ return;
+ case STATE_SPECULAR:
+ if (face == 0)
+ COPY_4V(value, ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SPECULAR]);
+ else
+ COPY_4V(value, ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_SPECULAR]);
+ return;
+ case STATE_EMISSION:
+ if (face == 0)
+ COPY_4V(value, ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_EMISSION]);
+ else
+ COPY_4V(value, ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_EMISSION]);
+ return;
+ case STATE_SHININESS:
+ if (face == 0)
+ value[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SHININESS][0];
+ else
+ value[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_SHININESS][0];
+ value[1] = 0.0F;
+ value[2] = 0.0F;
+ value[3] = 1.0F;
+ return;
+ default:
+ _mesa_problem(ctx, "Invalid material state in fetch_state");
+ return;
+ }
+ }
+ case STATE_LIGHT:
+ {
+ /* state[1] is the light number */
+ const GLuint ln = (GLuint) state[1];
+ /* state[2] is the light attribute */
+ switch (state[2]) {
+ case STATE_AMBIENT:
+ COPY_4V(value, ctx->Light.Light[ln].Ambient);
+ return;
+ case STATE_DIFFUSE:
+ COPY_4V(value, ctx->Light.Light[ln].Diffuse);
+ return;
+ case STATE_SPECULAR:
+ COPY_4V(value, ctx->Light.Light[ln].Specular);
+ return;
+ case STATE_POSITION:
+ COPY_4V(value, ctx->Light.Light[ln].EyePosition);
+ return;
+ case STATE_ATTENUATION:
+ value[0] = ctx->Light.Light[ln].ConstantAttenuation;
+ value[1] = ctx->Light.Light[ln].LinearAttenuation;
+ value[2] = ctx->Light.Light[ln].QuadraticAttenuation;
+ value[3] = ctx->Light.Light[ln].SpotExponent;
+ return;
+ case STATE_SPOT_DIRECTION:
+ COPY_3V(value, ctx->Light.Light[ln].EyeDirection);
+ value[3] = ctx->Light.Light[ln]._CosCutoff;
+ return;
+ case STATE_HALF:
+ {
+ GLfloat eye_z[] = {0, 0, 1};
+
+ /* Compute infinite half angle vector:
+ * half-vector = light_position + (0, 0, 1)
+ * and then normalize. w = 0
+ *
+ * light.EyePosition.w should be 0 for infinite lights.
+ */
+ ADD_3V(value, eye_z, ctx->Light.Light[ln].EyePosition);
+ NORMALIZE_3FV(value);
+ value[3] = 0;
+ }
+ return;
+ case STATE_POSITION_NORMALIZED:
+ COPY_4V(value, ctx->Light.Light[ln].EyePosition);
+ NORMALIZE_3FV( value );
+ return;
+ default:
+ _mesa_problem(ctx, "Invalid light state in fetch_state");
+ return;
+ }
+ }
+ case STATE_LIGHTMODEL_AMBIENT:
+ COPY_4V(value, ctx->Light.Model.Ambient);
+ return;
+ case STATE_LIGHTMODEL_SCENECOLOR:
+ if (state[1] == 0) {
+ /* front */
+ GLint i;
+ for (i = 0; i < 3; i++) {
+ value[i] = ctx->Light.Model.Ambient[i]
+ * ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_AMBIENT][i]
+ + ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_EMISSION][i];
+ }
+ value[3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
+ }
+ else {
+ /* back */
+ GLint i;
+ for (i = 0; i < 3; i++) {
+ value[i] = ctx->Light.Model.Ambient[i]
+ * ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_AMBIENT][i]
+ + ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_EMISSION][i];
+ }
+ value[3] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+ }
+ return;
+ case STATE_LIGHTPROD:
+ {
+ const GLuint ln = (GLuint) state[1];
+ const GLuint face = (GLuint) state[2];
+ GLint i;
+ ASSERT(face == 0 || face == 1);
+ switch (state[3]) {
+ case STATE_AMBIENT:
+ for (i = 0; i < 3; i++) {
+ value[i] = ctx->Light.Light[ln].Ambient[i] *
+ ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_AMBIENT+face][i];
+ }
+ /* [3] = material alpha */
+ value[3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE+face][3];
+ return;
+ case STATE_DIFFUSE:
+ for (i = 0; i < 3; i++) {
+ value[i] = ctx->Light.Light[ln].Diffuse[i] *
+ ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE+face][i];
+ }
+ /* [3] = material alpha */
+ value[3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE+face][3];
+ return;
+ case STATE_SPECULAR:
+ for (i = 0; i < 3; i++) {
+ value[i] = ctx->Light.Light[ln].Specular[i] *
+ ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SPECULAR+face][i];
+ }
+ /* [3] = material alpha */
+ value[3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE+face][3];
+ return;
+ default:
+ _mesa_problem(ctx, "Invalid lightprod state in fetch_state");
+ return;
+ }
+ }
+ case STATE_TEXGEN:
+ {
+ /* state[1] is the texture unit */
+ const GLuint unit = (GLuint) state[1];
+ /* state[2] is the texgen attribute */
+ switch (state[2]) {
+ case STATE_TEXGEN_EYE_S:
+ COPY_4V(value, ctx->Texture.Unit[unit].EyePlaneS);
+ return;
+ case STATE_TEXGEN_EYE_T:
+ COPY_4V(value, ctx->Texture.Unit[unit].EyePlaneT);
+ return;
+ case STATE_TEXGEN_EYE_R:
+ COPY_4V(value, ctx->Texture.Unit[unit].EyePlaneR);
+ return;
+ case STATE_TEXGEN_EYE_Q:
+ COPY_4V(value, ctx->Texture.Unit[unit].EyePlaneQ);
+ return;
+ case STATE_TEXGEN_OBJECT_S:
+ COPY_4V(value, ctx->Texture.Unit[unit].ObjectPlaneS);
+ return;
+ case STATE_TEXGEN_OBJECT_T:
+ COPY_4V(value, ctx->Texture.Unit[unit].ObjectPlaneT);
+ return;
+ case STATE_TEXGEN_OBJECT_R:
+ COPY_4V(value, ctx->Texture.Unit[unit].ObjectPlaneR);
+ return;
+ case STATE_TEXGEN_OBJECT_Q:
+ COPY_4V(value, ctx->Texture.Unit[unit].ObjectPlaneQ);
+ return;
+ default:
+ _mesa_problem(ctx, "Invalid texgen state in fetch_state");
+ return;
+ }
+ }
+ case STATE_TEXENV_COLOR:
+ {
+ /* state[1] is the texture unit */
+ const GLuint unit = (GLuint) state[1];
+ COPY_4V(value, ctx->Texture.Unit[unit].EnvColor);
+ }
+ return;
+ case STATE_FOG_COLOR:
+ COPY_4V(value, ctx->Fog.Color);
+ return;
+ case STATE_FOG_PARAMS:
+ value[0] = ctx->Fog.Density;
+ value[1] = ctx->Fog.Start;
+ value[2] = ctx->Fog.End;
+ value[3] = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
+ return;
+ case STATE_CLIPPLANE:
+ {
+ const GLuint plane = (GLuint) state[1];
+ COPY_4V(value, ctx->Transform.EyeUserPlane[plane]);
+ }
+ return;
+ case STATE_POINT_SIZE:
+ value[0] = ctx->Point.Size;
+ value[1] = ctx->Point.MinSize;
+ value[2] = ctx->Point.MaxSize;
+ value[3] = ctx->Point.Threshold;
+ return;
+ case STATE_POINT_ATTENUATION:
+ value[0] = ctx->Point.Params[0];
+ value[1] = ctx->Point.Params[1];
+ value[2] = ctx->Point.Params[2];
+ value[3] = 1.0F;
+ return;
+ case STATE_MATRIX:
+ {
+ /* state[1] = modelview, projection, texture, etc. */
+ /* state[2] = which texture matrix or program matrix */
+ /* state[3] = first column to fetch */
+ /* state[4] = last column to fetch */
+ /* state[5] = transpose, inverse or invtrans */
+
+ const GLmatrix *matrix;
+ const enum state_index mat = state[1];
+ const GLuint index = (GLuint) state[2];
+ const GLuint first = (GLuint) state[3];
+ const GLuint last = (GLuint) state[4];
+ const enum state_index modifier = state[5];
+ const GLfloat *m;
+ GLuint row, i;
+ if (mat == STATE_MODELVIEW) {
+ matrix = ctx->ModelviewMatrixStack.Top;
+ }
+ else if (mat == STATE_PROJECTION) {
+ matrix = ctx->ProjectionMatrixStack.Top;
+ }
+ else if (mat == STATE_MVP) {
+ matrix = &ctx->_ModelProjectMatrix;
+ }
+ else if (mat == STATE_TEXTURE) {
+ matrix = ctx->TextureMatrixStack[index].Top;
+ }
+ else if (mat == STATE_PROGRAM) {
+ matrix = ctx->ProgramMatrixStack[index].Top;
+ }
+ else {
+ _mesa_problem(ctx, "Bad matrix name in _mesa_fetch_state()");
+ return;
+ }
+ if (modifier == STATE_MATRIX_INVERSE ||
+ modifier == STATE_MATRIX_INVTRANS) {
+ /* Be sure inverse is up to date:
+ */
+ _math_matrix_analyse( (GLmatrix*) matrix );
+ m = matrix->inv;
+ }
+ else {
+ m = matrix->m;
+ }
+ if (modifier == STATE_MATRIX_TRANSPOSE ||
+ modifier == STATE_MATRIX_INVTRANS) {
+ for (i = 0, row = first; row <= last; row++) {
+ value[i++] = m[row * 4 + 0];
+ value[i++] = m[row * 4 + 1];
+ value[i++] = m[row * 4 + 2];
+ value[i++] = m[row * 4 + 3];
+ }
+ }
+ else {
+ for (i = 0, row = first; row <= last; row++) {
+ value[i++] = m[row + 0];
+ value[i++] = m[row + 4];
+ value[i++] = m[row + 8];
+ value[i++] = m[row + 12];
+ }
+ }
+ }
+ return;
+ case STATE_DEPTH_RANGE:
+ value[0] = ctx->Viewport.Near; /* near */
+ value[1] = ctx->Viewport.Far; /* far */
+ value[2] = ctx->Viewport.Far - ctx->Viewport.Near; /* far - near */
+ value[3] = 0;
+ return;
+ case STATE_FRAGMENT_PROGRAM:
+ {
+ /* state[1] = {STATE_ENV, STATE_LOCAL} */
+ /* state[2] = parameter index */
+ const int idx = (int) state[2];
+ switch (state[1]) {
+ case STATE_ENV:
+ COPY_4V(value, ctx->FragmentProgram.Parameters[idx]);
+ break;
+ case STATE_LOCAL:
+ COPY_4V(value, ctx->FragmentProgram.Current->Base.LocalParams[idx]);
+ break;
+ default:
+ _mesa_problem(ctx, "Bad state switch in _mesa_fetch_state()");
+ return;
+ }
+ }
+ return;
+
+ case STATE_VERTEX_PROGRAM:
+ {
+ /* state[1] = {STATE_ENV, STATE_LOCAL} */
+ /* state[2] = parameter index */
+ const int idx = (int) state[2];
+ switch (state[1]) {
+ case STATE_ENV:
+ COPY_4V(value, ctx->VertexProgram.Parameters[idx]);
+ break;
+ case STATE_LOCAL:
+ COPY_4V(value, ctx->VertexProgram.Current->Base.LocalParams[idx]);
+ break;
+ default:
+ _mesa_problem(ctx, "Bad state switch in _mesa_fetch_state()");
+ return;
+ }
+ }
+ return;
+
+ case STATE_INTERNAL:
+ {
+ switch (state[1]) {
+ case STATE_NORMAL_SCALE:
+ ASSIGN_4V(value, ctx->_ModelViewInvScale, 0, 0, 1);
+ break;
+ default:
+ _mesa_problem(ctx, "Bad state switch in _mesa_fetch_state()");
+ return;
+ }
+ }
+ return;
+
+ default:
+ _mesa_problem(ctx, "Invalid state in _mesa_fetch_state");
+ return;
+ }
+}
+
+
+/**
+ * Loop over all the parameters in a parameter list. If the parameter
+ * is a GL state reference, look up the current value of that state
+ * variable and put it into the parameter's Value[4] array.
+ * This would be called at glBegin time when using a fragment program.
+ */
+void
+_mesa_load_state_parameters(GLcontext *ctx,
+ struct program_parameter_list *paramList)
+{
+ GLuint i;
+
+ if (!paramList)
+ return;
+
+ for (i = 0; i < paramList->NumParameters; i++) {
+ if (paramList->Parameters[i].Type == STATE) {
+ _mesa_fetch_state(ctx,
+ paramList->Parameters[i].StateIndexes,
+ paramList->ParameterValues[i]);
+ }
+ }
+}
+
+
+
+/**********************************************************************/
+/* API functions */
+/**********************************************************************/
+
+
+/**
+ * Bind a program (make it current)
+ * \note Called from the GL API dispatcher by both glBindProgramNV
+ * and glBindProgramARB.
+ */
+void GLAPIENTRY
+_mesa_BindProgram(GLenum target, GLuint id)
+{
+ struct program *prog;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+
+ if ((target == GL_VERTEX_PROGRAM_NV
+ && ctx->Extensions.NV_vertex_program) ||
+ (target == GL_VERTEX_PROGRAM_ARB
+ && ctx->Extensions.ARB_vertex_program)) {
+ /*** Vertex program binding ***/
+ struct vertex_program *curProg = ctx->VertexProgram.Current;
+ if (curProg->Base.Id == id) {
+ /* binding same program - no change */
+ return;
+ }
+ if (curProg->Base.Id != 0) {
+ /* decrement refcount on previously bound vertex program */
+ curProg->Base.RefCount--;
+ /* and delete if refcount goes below one */
+ if (curProg->Base.RefCount <= 0) {
+ /* the program ID was already removed from the hash table */
+ ctx->Driver.DeleteProgram(ctx, &(curProg->Base));
+ }
+ }
+ }
+ else if ((target == GL_FRAGMENT_PROGRAM_NV
+ && ctx->Extensions.NV_fragment_program) ||
+ (target == GL_FRAGMENT_PROGRAM_ARB
+ && ctx->Extensions.ARB_fragment_program)) {
+ /*** Fragment program binding ***/
+ struct fragment_program *curProg = ctx->FragmentProgram.Current;
+ if (curProg->Base.Id == id) {
+ /* binding same program - no change */
+ return;
+ }
+ if (curProg->Base.Id != 0) {
+ /* decrement refcount on previously bound fragment program */
+ curProg->Base.RefCount--;
+ /* and delete if refcount goes below one */
+ if (curProg->Base.RefCount <= 0) {
+ /* the program ID was already removed from the hash table */
+ ctx->Driver.DeleteProgram(ctx, &(curProg->Base));
+ }
+ }
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glBindProgramNV/ARB(target)");
+ return;
+ }
+
+ /* NOTE: binding to a non-existant program is not an error.
+ * That's supposed to be caught in glBegin.
+ */
+ if (id == 0) {
+ /* Bind default program */
+ prog = NULL;
+ if (target == GL_VERTEX_PROGRAM_NV || target == GL_VERTEX_PROGRAM_ARB)
+ prog = ctx->Shared->DefaultVertexProgram;
+ else
+ prog = ctx->Shared->DefaultFragmentProgram;
+ }
+ else {
+ /* Bind user program */
+ prog = (struct program *) _mesa_HashLookup(ctx->Shared->Programs, id);
+ if (!prog || prog == &_mesa_DummyProgram) {
+ /* allocate a new program now */
+ prog = ctx->Driver.NewProgram(ctx, target, id);
+ if (!prog) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindProgramNV/ARB");
+ return;
+ }
+ _mesa_HashInsert(ctx->Shared->Programs, id, prog);
+ }
+ else if (prog->Target != target) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBindProgramNV/ARB(target mismatch)");
+ return;
+ }
+ }
+
+ /* bind now */
+ if (target == GL_VERTEX_PROGRAM_NV || target == GL_VERTEX_PROGRAM_ARB) {
+ ctx->VertexProgram.Current = (struct vertex_program *) prog;
+ }
+ else if (target == GL_FRAGMENT_PROGRAM_NV || target == GL_FRAGMENT_PROGRAM_ARB) {
+ ctx->FragmentProgram.Current = (struct fragment_program *) prog;
+ }
+
+ /* Never null pointers */
+ ASSERT(ctx->VertexProgram.Current);
+ ASSERT(ctx->FragmentProgram.Current);
+
+ if (prog)
+ prog->RefCount++;
+
+ if (ctx->Driver.BindProgram)
+ ctx->Driver.BindProgram(ctx, target, prog);
+}
+
+
+/**
+ * Delete a list of programs.
+ * \note Not compiled into display lists.
+ * \note Called by both glDeleteProgramsNV and glDeleteProgramsARB.
+ */
+void GLAPIENTRY
+_mesa_DeletePrograms(GLsizei n, const GLuint *ids)
+{
+ GLint i;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx);
+
+ if (n < 0) {
+ _mesa_error( ctx, GL_INVALID_VALUE, "glDeleteProgramsNV" );
+ return;
+ }
+
+ for (i = 0; i < n; i++) {
+ if (ids[i] != 0) {
+ struct program *prog = (struct program *)
+ _mesa_HashLookup(ctx->Shared->Programs, ids[i]);
+ if (prog == &_mesa_DummyProgram) {
+ _mesa_HashRemove(ctx->Shared->Programs, ids[i]);
+ }
+ else if (prog) {
+ /* Unbind program if necessary */
+ if (prog->Target == GL_VERTEX_PROGRAM_NV ||
+ prog->Target == GL_VERTEX_STATE_PROGRAM_NV) {
+ if (ctx->VertexProgram.Current &&
+ ctx->VertexProgram.Current->Base.Id == ids[i]) {
+ /* unbind this currently bound program */
+ _mesa_BindProgram(prog->Target, 0);
+ }
+ }
+ else if (prog->Target == GL_FRAGMENT_PROGRAM_NV ||
+ prog->Target == GL_FRAGMENT_PROGRAM_ARB) {
+ if (ctx->FragmentProgram.Current &&
+ ctx->FragmentProgram.Current->Base.Id == ids[i]) {
+ /* unbind this currently bound program */
+ _mesa_BindProgram(prog->Target, 0);
+ }
+ }
+ else {
+ _mesa_problem(ctx, "bad target in glDeleteProgramsNV");
+ return;
+ }
+ /* The ID is immediately available for re-use now */
+ _mesa_HashRemove(ctx->Shared->Programs, ids[i]);
+ prog->RefCount--;
+ if (prog->RefCount <= 0) {
+ ctx->Driver.DeleteProgram(ctx, prog);
+ }
+ }
+ }
+ }
+}
+
+
+/**
+ * Generate a list of new program identifiers.
+ * \note Not compiled into display lists.
+ * \note Called by both glGenProgramsNV and glGenProgramsARB.
+ */
+void GLAPIENTRY
+_mesa_GenPrograms(GLsizei n, GLuint *ids)
+{
+ GLuint first;
+ GLuint i;
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END(ctx);
+
+ if (n < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glGenPrograms");
+ return;
+ }
+
+ if (!ids)
+ return;
+
+ first = _mesa_HashFindFreeKeyBlock(ctx->Shared->Programs, n);
+
+ /* Insert pointer to dummy program as placeholder */
+ for (i = 0; i < (GLuint) n; i++) {
+ _mesa_HashInsert(ctx->Shared->Programs, first + i, &_mesa_DummyProgram);
+ }
+
+ /* Return the program names */
+ for (i = 0; i < (GLuint) n; i++) {
+ ids[i] = first + i;
+ }
+}
+
+
+/**
+ * Determine if id names a vertex or fragment program.
+ * \note Not compiled into display lists.
+ * \note Called from both glIsProgramNV and glIsProgramARB.
+ * \param id is the program identifier
+ * \return GL_TRUE if id is a program, else GL_FALSE.
+ */
+GLboolean GLAPIENTRY
+_mesa_IsProgram(GLuint id)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE);
+
+ if (id == 0)
+ return GL_FALSE;
+
+ if (_mesa_HashLookup(ctx->Shared->Programs, id))
+ return GL_TRUE;
+ else
+ return GL_FALSE;
+}
+
+
+
+/**********************************************************************/
+/* GL_MESA_program_debug extension */
+/**********************************************************************/
+
+
+/* XXX temporary */
+GLAPI void GLAPIENTRY
+glProgramCallbackMESA(GLenum target, GLprogramcallbackMESA callback,
+ GLvoid *data)
+{
+ _mesa_ProgramCallbackMESA(target, callback, data);
+}
+
+
+void
+_mesa_ProgramCallbackMESA(GLenum target, GLprogramcallbackMESA callback,
+ GLvoid *data)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ switch (target) {
+ case GL_FRAGMENT_PROGRAM_ARB:
+ if (!ctx->Extensions.ARB_fragment_program) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glProgramCallbackMESA(target)");
+ return;
+ }
+ ctx->FragmentProgram.Callback = callback;
+ ctx->FragmentProgram.CallbackData = data;
+ break;
+ case GL_FRAGMENT_PROGRAM_NV:
+ if (!ctx->Extensions.NV_fragment_program) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glProgramCallbackMESA(target)");
+ return;
+ }
+ ctx->FragmentProgram.Callback = callback;
+ ctx->FragmentProgram.CallbackData = data;
+ break;
+ case GL_VERTEX_PROGRAM_ARB: /* == GL_VERTEX_PROGRAM_NV */
+ if (!ctx->Extensions.ARB_vertex_program &&
+ !ctx->Extensions.NV_vertex_program) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glProgramCallbackMESA(target)");
+ return;
+ }
+ ctx->VertexProgram.Callback = callback;
+ ctx->VertexProgram.CallbackData = data;
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM, "glProgramCallbackMESA(target)");
+ return;
+ }
+}
+
+
+/* XXX temporary */
+GLAPI void GLAPIENTRY
+glGetProgramRegisterfvMESA(GLenum target,
+ GLsizei len, const GLubyte *registerName,
+ GLfloat *v)
+{
+ _mesa_GetProgramRegisterfvMESA(target, len, registerName, v);
+}
+
+
+void
+_mesa_GetProgramRegisterfvMESA(GLenum target,
+ GLsizei len, const GLubyte *registerName,
+ GLfloat *v)
+{
+ char reg[1000];
+ GET_CURRENT_CONTEXT(ctx);
+
+ /* We _should_ be inside glBegin/glEnd */
+#if 0
+ if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramRegisterfvMESA");
+ return;
+ }
+#endif
+
+ /* make null-terminated copy of registerName */
+ len = MIN2((unsigned int) len, sizeof(reg) - 1);
+ _mesa_memcpy(reg, registerName, len);
+ reg[len] = 0;
+
+ switch (target) {
+ case GL_VERTEX_PROGRAM_NV:
+ if (!ctx->Extensions.ARB_vertex_program &&
+ !ctx->Extensions.NV_vertex_program) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetProgramRegisterfvMESA(target)");
+ return;
+ }
+ if (!ctx->VertexProgram._Enabled) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetProgramRegisterfvMESA");
+ return;
+ }
+ /* GL_NV_vertex_program */
+ if (reg[0] == 'R') {
+ /* Temp register */
+ GLint i = _mesa_atoi(reg + 1);
+ if (i >= (GLint)ctx->Const.MaxVertexProgramTemps) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetProgramRegisterfvMESA(registerName)");
+ return;
+ }
+ COPY_4V(v, ctx->VertexProgram.Temporaries[i]);
+ }
+ else if (reg[0] == 'v' && reg[1] == '[') {
+ /* Vertex Input attribute */
+ GLuint i;
+ for (i = 0; i < ctx->Const.MaxVertexProgramAttribs; i++) {
+ const char *name = _mesa_nv_vertex_input_register_name(i);
+ char number[10];
+ sprintf(number, "%d", i);
+ if (_mesa_strncmp(reg + 2, name, 4) == 0 ||
+ _mesa_strncmp(reg + 2, number, _mesa_strlen(number)) == 0) {
+ COPY_4V(v, ctx->VertexProgram.Inputs[i]);
+ return;
+ }
+ }
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetProgramRegisterfvMESA(registerName)");
+ return;
+ }
+ else if (reg[0] == 'o' && reg[1] == '[') {
+ /* Vertex output attribute */
+ }
+ /* GL_ARB_vertex_program */
+ else if (_mesa_strncmp(reg, "vertex.", 7) == 0) {
+
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetProgramRegisterfvMESA(registerName)");
+ return;
+ }
+ break;
+ case GL_FRAGMENT_PROGRAM_ARB:
+ if (!ctx->Extensions.ARB_fragment_program) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetProgramRegisterfvMESA(target)");
+ return;
+ }
+ if (!ctx->FragmentProgram._Enabled) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetProgramRegisterfvMESA");
+ return;
+ }
+ /* XXX to do */
+ break;
+ case GL_FRAGMENT_PROGRAM_NV:
+ if (!ctx->Extensions.NV_fragment_program) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetProgramRegisterfvMESA(target)");
+ return;
+ }
+ if (!ctx->FragmentProgram._Enabled) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glGetProgramRegisterfvMESA");
+ return;
+ }
+ if (reg[0] == 'R') {
+ /* Temp register */
+ GLint i = _mesa_atoi(reg + 1);
+ if (i >= (GLint)ctx->Const.MaxFragmentProgramTemps) {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetProgramRegisterfvMESA(registerName)");
+ return;
+ }
+ COPY_4V(v, ctx->FragmentProgram.Machine.Temporaries[i]);
+ }
+ else if (reg[0] == 'f' && reg[1] == '[') {
+ /* Fragment input attribute */
+ GLuint i;
+ for (i = 0; i < ctx->Const.MaxFragmentProgramAttribs; i++) {
+ const char *name = _mesa_nv_fragment_input_register_name(i);
+ if (_mesa_strncmp(reg + 2, name, 4) == 0) {
+ COPY_4V(v, ctx->FragmentProgram.Machine.Inputs[i]);
+ return;
+ }
+ }
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetProgramRegisterfvMESA(registerName)");
+ return;
+ }
+ else if (_mesa_strcmp(reg, "o[COLR]") == 0) {
+ /* Fragment output color */
+ COPY_4V(v, ctx->FragmentProgram.Machine.Outputs[FRAG_OUTPUT_COLR]);
+ }
+ else if (_mesa_strcmp(reg, "o[COLH]") == 0) {
+ /* Fragment output color */
+ COPY_4V(v, ctx->FragmentProgram.Machine.Outputs[FRAG_OUTPUT_COLH]);
+ }
+ else if (_mesa_strcmp(reg, "o[DEPR]") == 0) {
+ /* Fragment output depth */
+ COPY_4V(v, ctx->FragmentProgram.Machine.Outputs[FRAG_OUTPUT_DEPR]);
+ }
+ else {
+ /* try user-defined identifiers */
+ const GLfloat *value = _mesa_lookup_parameter_value(
+ ctx->FragmentProgram.Current->Parameters, -1, reg);
+ if (value) {
+ COPY_4V(v, value);
+ }
+ else {
+ _mesa_error(ctx, GL_INVALID_VALUE,
+ "glGetProgramRegisterfvMESA(registerName)");
+ return;
+ }
+ }
+ break;
+ default:
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glGetProgramRegisterfvMESA(target)");
+ return;
+ }
+
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/program.h b/nx-X11/extras/Mesa/src/mesa/shader/program.h
new file mode 100644
index 000000000..87590ceea
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/program.h
@@ -0,0 +1,298 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file program.c
+ * Vertex and fragment program support functions.
+ * \author Brian Paul
+ */
+
+
+/**
+ * \mainpage Mesa vertex and fragment program module
+ *
+ * This module or directory contains most of the code for vertex and
+ * fragment programs and shaders, including state management, parsers,
+ * and (some) software routines for executing programs
+ */
+
+#ifndef PROGRAM_H
+#define PROGRAM_H
+
+#include "mtypes.h"
+
+
+/* for GL_ARB_v_p and GL_ARB_f_p SWZ instruction */
+#define SWIZZLE_X 0
+#define SWIZZLE_Y 1
+#define SWIZZLE_Z 2
+#define SWIZZLE_W 3
+#define SWIZZLE_ZERO 4 /* keep these values together: KW */
+#define SWIZZLE_ONE 5 /* keep these values together: KW */
+
+#define MAKE_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<3) | ((c)<<6) | ((d)<<9))
+#define MAKE_SWIZZLE(x) MAKE_SWIZZLE4((x)[0], (x)[1], (x)[2], (x)[3])
+#define SWIZZLE_NOOP MAKE_SWIZZLE4(0,1,2,3)
+#define GET_SWZ(swz, idx) (((swz) >> ((idx)*3)) & 0x7)
+#define GET_BIT(msk, idx) (((msk) >> (idx)) & 0x1)
+
+
+#define WRITEMASK_X 0x1
+#define WRITEMASK_Y 0x2
+#define WRITEMASK_XY 0x3
+#define WRITEMASK_Z 0x4
+#define WRITEMASK_XZ 0x5
+#define WRITEMASK_YZ 0x6
+#define WRITEMASK_XYZ 0x7
+#define WRITEMASK_W 0x8
+#define WRITEMASK_XW 0x9
+#define WRITEMASK_YW 0xa
+#define WRITEMASK_XYW 0xb
+#define WRITEMASK_ZW 0xc
+#define WRITEMASK_XZW 0xd
+#define WRITEMASK_YZW 0xe
+#define WRITEMASK_XYZW 0xf
+
+
+extern struct program _mesa_DummyProgram;
+
+
+/*
+ * Internal functions
+ */
+
+extern void
+_mesa_init_program(GLcontext *ctx);
+
+extern void
+_mesa_free_program_data(GLcontext *ctx);
+
+extern void
+_mesa_set_program_error(GLcontext *ctx, GLint pos, const char *string);
+
+extern const GLubyte *
+_mesa_find_line_column(const GLubyte *string, const GLubyte *pos,
+ GLint *line, GLint *col);
+
+
+extern struct program *
+_mesa_init_vertex_program(GLcontext *ctx,
+ struct vertex_program *prog,
+ GLenum target, GLuint id);
+
+extern struct program *
+_mesa_init_fragment_program(GLcontext *ctx,
+ struct fragment_program *prog,
+ GLenum target, GLuint id);
+
+extern struct program *
+_mesa_init_ati_fragment_shader(GLcontext *ctx,
+ struct ati_fragment_shader *prog,
+ GLenum target, GLuint id );
+
+extern struct program *
+_mesa_new_program(GLcontext *ctx, GLenum target, GLuint id);
+
+extern void
+_mesa_delete_program(GLcontext *ctx, struct program *prog);
+
+
+
+/*
+ * Used for describing GL state referenced from inside ARB vertex and
+ * fragment programs.
+ * A string such as "state.light[0].ambient" gets translated into a
+ * sequence of tokens such as [ STATE_LIGHT, 0, STATE_AMBIENT ].
+ */
+enum state_index {
+ STATE_MATERIAL,
+
+ STATE_LIGHT,
+ STATE_LIGHTMODEL_AMBIENT,
+ STATE_LIGHTMODEL_SCENECOLOR,
+ STATE_LIGHTPROD,
+
+ STATE_TEXGEN,
+
+ STATE_FOG_COLOR,
+ STATE_FOG_PARAMS,
+
+ STATE_CLIPPLANE,
+
+ STATE_POINT_SIZE,
+ STATE_POINT_ATTENUATION,
+
+ STATE_MATRIX,
+ STATE_MODELVIEW,
+ STATE_PROJECTION,
+ STATE_MVP,
+ STATE_TEXTURE,
+ STATE_PROGRAM,
+ STATE_MATRIX_INVERSE,
+ STATE_MATRIX_TRANSPOSE,
+ STATE_MATRIX_INVTRANS,
+
+ STATE_AMBIENT,
+ STATE_DIFFUSE,
+ STATE_SPECULAR,
+ STATE_EMISSION,
+ STATE_SHININESS,
+ STATE_HALF,
+
+ STATE_POSITION,
+ STATE_ATTENUATION,
+ STATE_SPOT_DIRECTION,
+
+ STATE_TEXGEN_EYE_S,
+ STATE_TEXGEN_EYE_T,
+ STATE_TEXGEN_EYE_R,
+ STATE_TEXGEN_EYE_Q,
+ STATE_TEXGEN_OBJECT_S,
+ STATE_TEXGEN_OBJECT_T,
+ STATE_TEXGEN_OBJECT_R,
+ STATE_TEXGEN_OBJECT_Q,
+
+ STATE_TEXENV_COLOR,
+
+ STATE_DEPTH_RANGE,
+
+ STATE_VERTEX_PROGRAM,
+ STATE_FRAGMENT_PROGRAM,
+
+ STATE_ENV,
+ STATE_LOCAL,
+
+ STATE_INTERNAL, /* Mesa additions */
+ STATE_NORMAL_SCALE,
+ STATE_POSITION_NORMALIZED
+};
+
+
+
+/*
+ * Named program parameters
+ * Used for NV_fragment_program "DEFINE"d constants and "DECLARE"d parameters,
+ * and ARB_fragment_program global state references. For the later, Name
+ * might be "state.light[0].diffuse", for example.
+ */
+
+enum parameter_type
+{
+ NAMED_PARAMETER,
+ CONSTANT,
+ STATE
+};
+
+
+struct program_parameter
+{
+ const char *Name; /* Null-terminated */
+ enum parameter_type Type;
+ enum state_index StateIndexes[6]; /* Global state reference */
+};
+
+
+struct program_parameter_list
+{
+ GLuint Size;
+ GLuint NumParameters;
+ struct program_parameter *Parameters;
+ GLfloat (*ParameterValues)[4];
+};
+
+
+/*
+ * Program parameter functions
+ */
+
+extern struct program_parameter_list *
+_mesa_new_parameter_list(void);
+
+extern void
+_mesa_free_parameter_list(struct program_parameter_list *paramList);
+
+extern void
+_mesa_free_parameters(struct program_parameter_list *paramList);
+
+extern GLint
+_mesa_add_named_parameter(struct program_parameter_list *paramList,
+ const char *name, const GLfloat values[4]);
+
+extern GLint
+_mesa_add_named_constant(struct program_parameter_list *paramList,
+ const char *name, const GLfloat values[4]);
+
+extern GLint
+_mesa_add_unnamed_constant(struct program_parameter_list *paramList,
+ const GLfloat values[4]);
+
+extern GLint
+_mesa_add_state_reference(struct program_parameter_list *paramList,
+ GLint *stateTokens);
+
+extern GLfloat *
+_mesa_lookup_parameter_value(struct program_parameter_list *paramList,
+ GLsizei nameLen, const char *name);
+
+extern GLint
+_mesa_lookup_parameter_index(struct program_parameter_list *paramList,
+ GLsizei nameLen, const char *name);
+
+extern void
+_mesa_load_state_parameters(GLcontext *ctx,
+ struct program_parameter_list *paramList);
+
+
+/*
+ * API functions
+ */
+
+extern void GLAPIENTRY
+_mesa_BindProgram(GLenum target, GLuint id);
+
+extern void GLAPIENTRY
+_mesa_DeletePrograms(GLsizei n, const GLuint *ids);
+
+extern void GLAPIENTRY
+_mesa_GenPrograms(GLsizei n, GLuint *ids);
+
+extern GLboolean GLAPIENTRY
+_mesa_IsProgram(GLuint id);
+
+
+
+/*
+ * GL_MESA_program_debug
+ */
+
+extern void
+_mesa_ProgramCallbackMESA(GLenum target, GLprogramcallbackMESA callback,
+ GLvoid *data);
+
+extern void
+_mesa_GetProgramRegisterfvMESA(GLenum target, GLsizei len,
+ const GLubyte *registerName, GLfloat *v);
+
+
+#endif /* PROGRAM_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/shaderobjects.c b/nx-X11/extras/Mesa/src/mesa/shader/shaderobjects.c
new file mode 100644
index 000000000..ac8ff1af4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/shaderobjects.c
@@ -0,0 +1,1182 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2004-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file shaderobjects.c
+ * ARB_shader_objects state management functions
+ * \author Michal Krol
+ */
+
+
+#include "glheader.h"
+#include "shaderobjects.h"
+#include "shaderobjects_3dlabs.h"
+#include "context.h"
+#include "macros.h"
+#include "hash.h"
+
+
+void GLAPIENTRY
+_mesa_DeleteObjectARB (GLhandleARB obj)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unk;
+ struct gl2_generic_intf **gen;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, obj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unk == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glDeleteObjectARB");
+ return;
+ }
+
+ gen = (struct gl2_generic_intf **) (**unk).QueryInterface (unk, UIID_GENERIC);
+ if (gen == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glDeleteObjectARB");
+ return;
+ }
+
+ (**gen).Delete (gen);
+ (**gen)._unknown.Release ((struct gl2_unknown_intf **) gen);
+}
+
+GLhandleARB GLAPIENTRY
+_mesa_GetHandleARB (GLenum pname)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ switch (pname)
+ {
+ case GL_PROGRAM_OBJECT_ARB:
+ if (ctx->ShaderObjects.current_program != NULL)
+ return (**ctx->ShaderObjects.current_program)._container._generic.GetName (
+ (struct gl2_generic_intf **) ctx->ShaderObjects.current_program);
+ break;
+ }
+
+ return 0;
+}
+
+void GLAPIENTRY
+_mesa_DetachObjectARB (GLhandleARB containerObj, GLhandleARB attachedObj)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unkc, **unka;
+ struct gl2_container_intf **con;
+ struct gl2_generic_intf **att;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unkc = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, containerObj);
+ unka = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, attachedObj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unkc == NULL || unka == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glDetachObjectARB");
+ return;
+ }
+
+ con = (struct gl2_container_intf **) (**unkc).QueryInterface (unkc, UIID_CONTAINER);
+ if (con == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glDetachObjectARB");
+ return;
+ }
+
+ att = (struct gl2_generic_intf **) (**unka).QueryInterface (unka, UIID_GENERIC);
+ if (att == NULL)
+ {
+ (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);
+ _mesa_error (ctx, GL_INVALID_VALUE, "glDetachObjectARB");
+ return;
+ }
+
+ if ((**con).Detach (con, att) == GL_FALSE)
+ {
+ (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);
+ (**att)._unknown.Release ((struct gl2_unknown_intf **) att);
+ return;
+ }
+
+ (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);
+ (**att)._unknown.Release ((struct gl2_unknown_intf **) att);
+}
+
+GLhandleARB GLAPIENTRY
+_mesa_CreateShaderObjectARB (GLenum shaderType)
+{
+ return _mesa_3dlabs_create_shader_object (shaderType);
+}
+
+void GLAPIENTRY
+_mesa_ShaderSourceARB (GLhandleARB shaderObj, GLsizei count, const GLcharARB **string,
+ const GLint *length)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unk;
+ struct gl2_shader_intf **sha;
+ GLint *offsets;
+ GLsizei i;
+ GLcharARB *source;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, shaderObj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unk == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glShaderSourceARB");
+ return;
+ }
+
+ sha = (struct gl2_shader_intf **) (**unk).QueryInterface (unk, UIID_SHADER);
+ if (sha == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glShaderSourceARB");
+ return;
+ }
+
+ /* this array holds offsets of where the appropriate string ends, thus the last
+ element will be set to the total length of the source code */
+ offsets = (GLint *) _mesa_malloc (count * sizeof (GLint));
+ if (offsets == NULL)
+ {
+ (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);
+ _mesa_error (ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB");
+ return;
+ }
+
+ for (i = 0; i < count; i++)
+ {
+ if (length == NULL || length[i] < 0)
+ offsets[i] = _mesa_strlen (string[i]);
+ else
+ offsets[i] = length[i];
+ /* accumulate string lengths */
+ if (i > 0)
+ offsets[i] += offsets[i - 1];
+ }
+
+ source = (GLcharARB *) _mesa_malloc ((offsets[count - 1] + 1) * sizeof (GLcharARB));
+ if (source == NULL)
+ {
+ _mesa_free ((void *) offsets);
+ (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);
+ _mesa_error (ctx, GL_OUT_OF_MEMORY, "glShaderSourceARB");
+ return;
+ }
+
+ for (i = 0; i < count; i++)
+ {
+ GLint start = (i > 0) ? offsets[i - 1] : 0;
+ _mesa_memcpy (source + start, string[i], (offsets[i] - start) * sizeof (GLcharARB));
+ }
+ source[offsets[count - 1]] = '\0';
+
+ (**sha).SetSource (sha, source, offsets, count);
+ (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);
+}
+
+void GLAPIENTRY
+_mesa_CompileShaderARB (GLhandleARB shaderObj)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unk;
+ struct gl2_shader_intf **sha;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, shaderObj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unk == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glCompileShaderARB");
+ return;
+ }
+
+ sha = (struct gl2_shader_intf **) (**unk).QueryInterface (unk, UIID_SHADER);
+ if (sha == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glCompileShaderARB");
+ return;
+ }
+
+ (**sha).Compile (sha);
+ (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);
+}
+
+GLhandleARB GLAPIENTRY
+_mesa_CreateProgramObjectARB (void)
+{
+ return _mesa_3dlabs_create_program_object ();
+}
+
+void GLAPIENTRY
+_mesa_AttachObjectARB (GLhandleARB containerObj, GLhandleARB obj)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unkc, **unka;
+ struct gl2_container_intf **con;
+ struct gl2_generic_intf **att;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unkc = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, containerObj);
+ unka = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, obj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unkc == NULL || unka == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glAttachObjectARB");
+ return;
+ }
+
+ con = (struct gl2_container_intf **) (**unkc).QueryInterface (unkc, UIID_CONTAINER);
+ if (con == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glAttachObjectARB");
+ return;
+ }
+
+ att = (struct gl2_generic_intf **) (**unka).QueryInterface (unka, UIID_GENERIC);
+ if (att == NULL)
+ {
+ (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);
+ _mesa_error (ctx, GL_INVALID_VALUE, "glAttachObjectARB");
+ return;
+ }
+
+ if (!(**con).Attach (con, att))
+ {
+ (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);
+ (**att)._unknown.Release ((struct gl2_unknown_intf **) att);
+ return;
+ }
+
+ (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);
+ (**att)._unknown.Release ((struct gl2_unknown_intf **) att);
+}
+
+void GLAPIENTRY
+_mesa_LinkProgramARB (GLhandleARB programObj)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unk;
+ struct gl2_program_intf **pro;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unk == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glLinkProgramARB");
+ return;
+ }
+
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
+ if (pro == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glLinkProgramARB");
+ return;
+ }
+
+ if (pro == ctx->ShaderObjects.current_program)
+ {
+ /* TODO re-install executable program */
+ }
+
+ (**pro).Link (pro);
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+}
+
+void GLAPIENTRY
+_mesa_UseProgramObjectARB (GLhandleARB programObj)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_program_intf **pro;
+
+ if (programObj == 0)
+ {
+ pro = NULL;
+ }
+ else
+ {
+ struct gl2_unknown_intf **unk;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unk == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glUseProgramObjectARB");
+ return;
+ }
+
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
+ if (pro == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUseProgramObjectARB");
+ return;
+ }
+
+ if ((**pro).GetLinkStatus (pro) == GL_FALSE)
+ {
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUseProgramObjectARB");
+ return;
+ }
+ }
+
+ if (ctx->ShaderObjects.current_program != NULL)
+ {
+ (**ctx->ShaderObjects.current_program)._container._generic._unknown.Release (
+ (struct gl2_unknown_intf **) ctx->ShaderObjects.current_program);
+ }
+
+ ctx->ShaderObjects.current_program = pro;
+}
+
+void GLAPIENTRY
+_mesa_ValidateProgramARB (GLhandleARB programObj)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unk;
+ struct gl2_program_intf **pro;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unk == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glValidateProgramARB");
+ return;
+ }
+
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
+ if (pro == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glValidateProgramARB");
+ return;
+ }
+
+ (**pro).Validate (pro);
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+}
+
+/*
+Errors TODO
+
+ The error INVALID_OPERATION is generated by the Uniform*ARB if the
+ number of values loaded results in exceeding the declared extent of a
+ uniform.
+
+ The error INVALID_OPERATION is generated by the Uniform*ARB commands if
+ the size does not match the size of the uniform declared in the shader.
+
+ The error INVALID_OPERATION is generated by the Uniform*ARB commands if
+ the type does not match the type of the uniform declared in the shader,
+ if the uniform is not of type Boolean.
+
+ The error INVALID_OPERATION is generated by the Uniform*ARB commands if
+ <location> does not exist for the program object currently in use.
+
+ The error INVALID_OPERATION is generated if a uniform command other than
+ Uniform1i{v}ARB is used to load a sampler value.
+
+
+*/
+
+void GLAPIENTRY
+_mesa_Uniform1fARB (GLint location, GLfloat v0)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1fARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_Uniform2fARB (GLint location, GLfloat v0, GLfloat v1)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2fARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_Uniform3fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3fARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_Uniform4fARB (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4fARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_Uniform1iARB (GLint location, GLint v0)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1iARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_Uniform2iARB (GLint location, GLint v0, GLint v1)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2iARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_Uniform3iARB (GLint location, GLint v0, GLint v1, GLint v2)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3iARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_Uniform4iARB (GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4iARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_Uniform1fvARB (GLint location, GLsizei count, const GLfloat *value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1fvARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_Uniform2fvARB (GLint location, GLsizei count, const GLfloat *value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2fvARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_Uniform3fvARB (GLint location, GLsizei count, const GLfloat *value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3fvARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_Uniform4fvARB (GLint location, GLsizei count, const GLfloat *value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4fvARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_Uniform1ivARB (GLint location, GLsizei count, const GLint *value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform1ivARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_Uniform2ivARB (GLint location, GLsizei count, const GLint *value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform2ivARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_Uniform3ivARB (GLint location, GLsizei count, const GLint *value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform3ivARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_Uniform4ivARB (GLint location, GLsizei count, const GLint *value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniform4ivARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_UniformMatrix2fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix2fvARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_UniformMatrix3fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix3fvARB");
+ return;
+ }
+}
+
+void GLAPIENTRY
+_mesa_UniformMatrix4fvARB (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if (ctx->ShaderObjects.current_program == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glUniformMatrix4fvARB");
+ return;
+ }
+}
+
+static GLboolean
+_mesa_get_object_parameter (GLhandleARB obj, GLenum pname, GLvoid *params, GLboolean *integral,
+ GLint *size)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unk;
+ struct gl2_generic_intf **gen;
+ struct gl2_shader_intf **sha;
+ struct gl2_program_intf **pro;
+ GLint *ipar = (GLint *) params;
+ /*GLfloat *fpar = (GLfloat *) params;*/
+ GLboolean success = GL_TRUE;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, obj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unk == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetObjectParameterivARB");
+ return GL_FALSE;
+ }
+
+ gen = (struct gl2_generic_intf **) (**unk).QueryInterface (unk, UIID_GENERIC);
+ if (gen == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
+ return GL_FALSE;
+ }
+
+ sha = (struct gl2_shader_intf **) (**unk).QueryInterface (unk, UIID_SHADER);
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
+
+ /* set default values */
+ *integral = GL_TRUE; /* indicates param type, TRUE: GLint, FALSE: GLfloat */
+ *size = 1; /* param array size */
+
+ switch (pname)
+ {
+ case GL_OBJECT_TYPE_ARB:
+ *ipar = (**gen).GetType (gen);
+ break;
+ case GL_OBJECT_SUBTYPE_ARB:
+ if (sha != NULL)
+ *ipar = (**sha).GetSubType (sha);
+ else {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
+ success = GL_FALSE;
+ }
+ break;
+ case GL_OBJECT_DELETE_STATUS_ARB:
+ *ipar = (**gen).GetDeleteStatus (gen);
+ break;
+ case GL_OBJECT_COMPILE_STATUS_ARB:
+ if (sha != NULL)
+ *ipar = (**sha).GetCompileStatus (sha);
+ else {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
+ success = GL_FALSE;
+ }
+ break;
+ case GL_OBJECT_LINK_STATUS_ARB:
+ if (pro != NULL)
+ *ipar = (**pro).GetLinkStatus (pro);
+ else {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
+ success = GL_FALSE;
+ }
+ break;
+ case GL_OBJECT_VALIDATE_STATUS_ARB:
+ if (pro != NULL)
+ *ipar = (**pro).GetValidateStatus (pro);
+ else {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
+ success = GL_FALSE;
+ }
+ break;
+ case GL_OBJECT_INFO_LOG_LENGTH_ARB:
+ {
+ const GLcharARB *info = (**gen).GetInfoLog (gen);
+ if (info == NULL)
+ *ipar = 0;
+ else
+ *ipar = _mesa_strlen (info) + 1;
+ }
+ break;
+ case GL_OBJECT_ATTACHED_OBJECTS_ARB:
+ if (pro != NULL)
+ *ipar = (**pro)._container.GetAttachedCount ((struct gl2_container_intf **) pro);
+ else {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
+ success = GL_FALSE;
+ }
+ break;
+ case GL_OBJECT_ACTIVE_UNIFORMS_ARB:
+ if (pro != NULL)
+ *ipar = 0; /* TODO */
+ else {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
+ success = GL_FALSE;
+ }
+ break;
+ case GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB:
+ if (pro != NULL)
+ *ipar = 0; /* TODO */
+ else {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
+ success = GL_FALSE;
+ }
+ break;
+ case GL_OBJECT_SHADER_SOURCE_LENGTH_ARB:
+ if (sha != NULL) {
+ const GLcharARB *src = (**sha).GetSource (sha);
+ if (src == NULL)
+ *ipar = 0;
+ else
+ *ipar = _mesa_strlen (src) + 1;
+ } else {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetObjectParameterivARB");
+ success = GL_FALSE;
+ }
+ break;
+ default:
+ _mesa_error (ctx, GL_INVALID_ENUM, "glGetObjectParameterivARB");
+ success = GL_FALSE;
+ break;
+ }
+
+ (**gen)._unknown.Release ((struct gl2_unknown_intf **) gen);
+ if (sha != NULL)
+ (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);
+ if (pro != NULL)
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+
+ return success;
+}
+
+void GLAPIENTRY
+_mesa_GetObjectParameterfvARB (GLhandleARB obj, GLenum pname, GLfloat *params)
+{
+ GLboolean integral;
+ GLint size, i;
+
+ assert (sizeof (GLfloat) == sizeof (GLint));
+
+ if (_mesa_get_object_parameter (obj, pname, (GLvoid *) params, &integral, &size) != GL_FALSE)
+ if (integral != GL_FALSE)
+ for (i = 0; i < size; i++)
+ params[i] = (GLfloat) ((GLint *) params)[i];
+}
+
+void GLAPIENTRY
+_mesa_GetObjectParameterivARB (GLhandleARB obj, GLenum pname, GLint *params)
+{
+ GLboolean integral;
+ GLint size, i;
+
+ assert (sizeof (GLfloat) == sizeof (GLint));
+
+ if (_mesa_get_object_parameter (obj, pname, (GLvoid *) params, &integral, &size) != GL_FALSE)
+ if (integral == GL_FALSE)
+ for (i = 0; i < size; i++)
+ params[i] = (GLint) ((GLfloat *) params)[i];
+}
+
+static void
+_mesa_get_string (const GLcharARB *src, GLsizei maxLength, GLsizei *length, GLcharARB *str)
+{
+ GLsizei len;
+
+ if (src == NULL)
+ src = "";
+
+ len = _mesa_strlen (src);
+ if (len > maxLength)
+ {
+ len = maxLength;
+ /* allocate space for null termination */
+ if (len > 0)
+ len--;
+ }
+
+ _mesa_memcpy (str, src, len * sizeof (GLcharARB));
+ if (maxLength > 0)
+ str[len] = '\0';
+
+ if (length != NULL)
+ *length = len;
+}
+
+void GLAPIENTRY
+_mesa_GetInfoLogARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unk;
+ struct gl2_generic_intf **gen;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, obj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unk == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetInfoLogARB");
+ return;
+ }
+
+ gen = (struct gl2_generic_intf **) (**unk).QueryInterface (unk, UIID_GENERIC);
+ if (gen == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetInfoLogARB");
+ return;
+ }
+
+ _mesa_get_string ((**gen).GetInfoLog (gen), maxLength, length, infoLog);
+
+ (**gen)._unknown.Release ((struct gl2_unknown_intf **) gen);
+}
+
+void GLAPIENTRY
+_mesa_GetAttachedObjectsARB (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unk;
+ struct gl2_container_intf **con;
+ GLsizei cnt, i;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, containerObj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unk == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetAttachedObjectsARB");
+ return;
+ }
+
+ con = (struct gl2_container_intf **) (**unk).QueryInterface (unk, UIID_CONTAINER);
+ if (con == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetAttachedObjectsARB");
+ return;
+ }
+
+ cnt = (**con).GetAttachedCount (con);
+ if (cnt > maxCount)
+ cnt = maxCount;
+
+ for (i = 0; i < cnt; i++)
+ {
+ struct gl2_generic_intf **x = (**con).GetAttached (con, i);
+ obj[i] = (**x).GetName (x);
+ (**x)._unknown.Release ((struct gl2_unknown_intf **) x);
+ }
+
+ (**con)._generic._unknown.Release ((struct gl2_unknown_intf **) con);
+
+ if (count != NULL)
+ *count = cnt;
+}
+
+GLint GLAPIENTRY
+_mesa_GetUniformLocationARB (GLhandleARB programObj, const GLcharARB *name)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unk;
+ struct gl2_program_intf **pro;
+ GLint loc = -1;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unk == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetUniformLocationARB");
+ return -1;
+ }
+
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
+ if (pro == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetUniformLocationARB");
+ return -1;
+ }
+
+ if ((**pro).GetLinkStatus (pro) == GL_FALSE)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetUniformLocationARB");
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+ return -1;
+ }
+
+ /* TODO */
+
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+ return loc;
+}
+
+void GLAPIENTRY
+_mesa_GetActiveUniformARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unk;
+ struct gl2_program_intf **pro;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unk == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetActiveUniformARB");
+ return;
+ }
+
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
+ if (pro == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetActiveUniformARB");
+ return;
+ }
+
+/* if (index >= val (OBJECT_ACTIVE_ATTRIBUTES_ARB))
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetActiveUniformARB");
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+ return;
+ }*/
+
+ /* TODO */
+
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+}
+
+void GLAPIENTRY
+_mesa_GetUniformfvARB (GLhandleARB programObj, GLint location, GLfloat *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unk;
+ struct gl2_program_intf **pro;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unk == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetUniformfvARB");
+ return;
+ }
+
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
+ if (pro == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetUniformfvARB");
+ return;
+ }
+
+ if ((**pro).GetLinkStatus (pro) == GL_FALSE)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetUniformfvARB");
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+ return;
+ }
+
+ /* TODO validate location (OPERATION) */
+
+ /* TODO */
+
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+}
+
+void GLAPIENTRY
+_mesa_GetUniformivARB (GLhandleARB programObj, GLint location, GLint *params)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unk;
+ struct gl2_program_intf **pro;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unk == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetUniformivARB");
+ return;
+ }
+
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
+ if (pro == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetUniformivARB");
+ return;
+ }
+
+ if ((**pro).GetLinkStatus (pro) == GL_FALSE)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetUniformivARB");
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+ return;
+ }
+
+ /* TODO validate location (GL_INVALID_OPERATION) */
+
+ /* TODO */
+
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+}
+
+void GLAPIENTRY
+_mesa_GetShaderSourceARB (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unk;
+ struct gl2_shader_intf **sha;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, obj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unk == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetShaderSourceARB");
+ return;
+ }
+
+ sha = (struct gl2_shader_intf **) (**unk).QueryInterface (unk, UIID_SHADER);
+ if (sha == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "glGetShaderSourceARB");
+ return;
+ }
+
+ _mesa_get_string ((**sha).GetSource (sha), maxLength, length, source);
+
+ (**sha)._generic._unknown.Release ((struct gl2_unknown_intf **) sha);
+}
+
+/* GL_ARB_vertex_shader */
+
+void GLAPIENTRY
+_mesa_BindAttribLocationARB (GLhandleARB programObj, GLuint index, const GLcharARB *name)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unk;
+ struct gl2_program_intf **pro;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unk == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glBindAttribLocationARB");
+ return;
+ }
+
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
+ if (pro == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glBindAttribLocationARB");
+ return;
+ }
+
+ /* TODO */
+
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+}
+
+void GLAPIENTRY
+_mesa_GetActiveAttribARB (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unk;
+ struct gl2_program_intf **pro;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unk == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetActiveAttribARB");
+ return;
+ }
+
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
+ if (pro == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetActiveAttribARB");
+ return;
+ }
+
+ /* TODO */
+
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+}
+
+GLint GLAPIENTRY
+_mesa_GetAttribLocationARB (GLhandleARB programObj, const GLcharARB *name)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **unk;
+ struct gl2_program_intf **pro;
+ GLint loc = 0;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ unk = (struct gl2_unknown_intf **) _mesa_HashLookup (ctx->Shared->GL2Objects, programObj);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ if (unk == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetAttribLocationARB");
+ return 0;
+ }
+
+ pro = (struct gl2_program_intf **) (**unk).QueryInterface (unk, UIID_PROGRAM);
+ if (pro == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_VALUE, "glGetAttribLocationARB");
+ return 0;
+ }
+
+ /* TODO */
+
+ (**pro)._container._generic._unknown.Release ((struct gl2_unknown_intf **) pro);
+ return loc;
+}
+
+void
+_mesa_init_shaderobjects (GLcontext *ctx)
+{
+ ctx->ShaderObjects.current_program = NULL;
+
+ _mesa_init_shaderobjects_3dlabs (ctx);
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/shaderobjects.h b/nx-X11/extras/Mesa/src/mesa/shader/shaderobjects.h
new file mode 100644
index 000000000..7f0f0706a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/shaderobjects.h
@@ -0,0 +1,168 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2004-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef SHADEROBJECTS_H
+#define SHADEROBJECTS_H
+
+#include "mtypes.h"
+
+#if FEATURE_ARB_shader_objects
+
+extern void GLAPIENTRY
+_mesa_DeleteObjectARB(GLhandleARB obj);
+
+extern GLhandleARB GLAPIENTRY
+_mesa_GetHandleARB(GLenum pname);
+
+extern void GLAPIENTRY
+_mesa_DetachObjectARB (GLhandleARB, GLhandleARB);
+
+extern GLhandleARB GLAPIENTRY
+_mesa_CreateShaderObjectARB (GLenum);
+
+extern void GLAPIENTRY
+_mesa_ShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *);
+
+extern void GLAPIENTRY
+_mesa_CompileShaderARB (GLhandleARB);
+
+extern GLhandleARB GLAPIENTRY
+_mesa_CreateProgramObjectARB (void);
+
+extern void GLAPIENTRY
+_mesa_AttachObjectARB (GLhandleARB, GLhandleARB);
+
+extern void GLAPIENTRY
+_mesa_LinkProgramARB (GLhandleARB);
+
+extern void GLAPIENTRY
+_mesa_UseProgramObjectARB (GLhandleARB);
+
+extern void GLAPIENTRY
+_mesa_ValidateProgramARB (GLhandleARB);
+
+extern void GLAPIENTRY
+_mesa_Uniform1fARB (GLint, GLfloat);
+
+extern void GLAPIENTRY
+_mesa_Uniform2fARB (GLint, GLfloat, GLfloat);
+
+extern void GLAPIENTRY
+_mesa_Uniform3fARB (GLint, GLfloat, GLfloat, GLfloat);
+
+extern void GLAPIENTRY
+_mesa_Uniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat);
+
+extern void GLAPIENTRY
+_mesa_Uniform1iARB (GLint, GLint);
+
+extern void GLAPIENTRY
+_mesa_Uniform2iARB (GLint, GLint, GLint);
+
+extern void GLAPIENTRY
+_mesa_Uniform3iARB (GLint, GLint, GLint, GLint);
+
+extern void GLAPIENTRY
+_mesa_Uniform4iARB (GLint, GLint, GLint, GLint, GLint);
+
+extern void GLAPIENTRY
+_mesa_Uniform1fvARB (GLint, GLsizei, const GLfloat *);
+
+extern void GLAPIENTRY
+_mesa_Uniform2fvARB (GLint, GLsizei, const GLfloat *);
+
+extern void GLAPIENTRY
+_mesa_Uniform3fvARB (GLint, GLsizei, const GLfloat *);
+
+extern void GLAPIENTRY
+_mesa_Uniform4fvARB (GLint, GLsizei, const GLfloat *);
+
+extern void GLAPIENTRY
+_mesa_Uniform1ivARB (GLint, GLsizei, const GLint *);
+
+extern void GLAPIENTRY
+_mesa_Uniform2ivARB (GLint, GLsizei, const GLint *);
+
+extern void GLAPIENTRY
+_mesa_Uniform3ivARB (GLint, GLsizei, const GLint *);
+
+extern void GLAPIENTRY
+_mesa_Uniform4ivARB (GLint, GLsizei, const GLint *);
+
+extern void GLAPIENTRY
+_mesa_UniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *);
+
+extern void GLAPIENTRY
+_mesa_UniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *);
+
+extern void GLAPIENTRY
+_mesa_UniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *);
+
+extern void GLAPIENTRY
+_mesa_GetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *);
+
+extern void GLAPIENTRY
+_mesa_GetObjectParameterivARB (GLhandleARB, GLenum, GLint *);
+
+extern void GLAPIENTRY
+_mesa_GetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *);
+
+extern void GLAPIENTRY
+_mesa_GetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *);
+
+extern GLint GLAPIENTRY
+_mesa_GetUniformLocationARB (GLhandleARB, const GLcharARB *);
+
+extern void GLAPIENTRY
+_mesa_GetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *);
+
+extern void GLAPIENTRY
+_mesa_GetUniformfvARB (GLhandleARB, GLint, GLfloat *);
+
+extern void GLAPIENTRY
+_mesa_GetUniformivARB (GLhandleARB, GLint, GLint *);
+
+extern void GLAPIENTRY
+_mesa_GetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *);
+
+#if FEATURE_ARB_vertex_shader
+
+extern void GLAPIENTRY
+_mesa_BindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *);
+
+extern void GLAPIENTRY
+_mesa_GetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *);
+
+extern GLint GLAPIENTRY
+_mesa_GetAttribLocationARB (GLhandleARB, const GLcharARB *);
+
+#endif
+
+extern void
+_mesa_init_shaderobjects (GLcontext *ctx);
+
+#endif
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/shaderobjects_3dlabs.c b/nx-X11/extras/Mesa/src/mesa/shader/shaderobjects_3dlabs.c
new file mode 100755
index 000000000..f03f65d70
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/shaderobjects_3dlabs.c
@@ -0,0 +1,1052 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file shaderobjects_3dlabs.c
+ * shader objects definitions for 3dlabs compiler
+ * \author Michal Krol
+ */
+
+/* Set this to 1 when we are ready to use 3dlabs' front-end */
+#define USE_3DLABS_FRONTEND 0
+
+#include "glheader.h"
+#include "shaderobjects.h"
+#include "shaderobjects_3dlabs.h"
+#include "context.h"
+#include "macros.h"
+#include "hash.h"
+
+#if USE_3DLABS_FRONTEND
+#include "slang_mesa.h"
+#include "Public/ShaderLang.h"
+#else
+#include "slang_compile.h"
+#endif
+
+struct gl2_unknown_obj
+{
+ GLuint reference_count;
+ void (* _destructor) (struct gl2_unknown_intf **);
+};
+
+struct gl2_unknown_impl
+{
+ struct gl2_unknown_intf *_vftbl;
+ struct gl2_unknown_obj _obj;
+};
+
+static void
+_unknown_destructor (struct gl2_unknown_intf **intf)
+{
+}
+
+static void
+_unknown_AddRef (struct gl2_unknown_intf **intf)
+{
+ struct gl2_unknown_impl *impl = (struct gl2_unknown_impl *) intf;
+
+ impl->_obj.reference_count++;
+}
+
+static void
+_unknown_Release (struct gl2_unknown_intf **intf)
+{
+ struct gl2_unknown_impl *impl = (struct gl2_unknown_impl *) intf;
+
+ impl->_obj.reference_count--;
+ if (impl->_obj.reference_count == 0)
+ {
+ impl->_obj._destructor (intf);
+ _mesa_free ((void *) intf);
+ }
+}
+
+static struct gl2_unknown_intf **
+_unknown_QueryInterface (struct gl2_unknown_intf **intf, enum gl2_uiid uiid)
+{
+ if (uiid == UIID_UNKNOWN)
+ {
+ (**intf).AddRef (intf);
+ return intf;
+ }
+ return NULL;
+}
+
+static struct gl2_unknown_intf _unknown_vftbl = {
+ _unknown_AddRef,
+ _unknown_Release,
+ _unknown_QueryInterface
+};
+
+static void
+_unknown_constructor (struct gl2_unknown_impl *impl)
+{
+ impl->_vftbl = &_unknown_vftbl;
+ impl->_obj.reference_count = 1;
+ impl->_obj._destructor = _unknown_destructor;
+}
+
+struct gl2_unkinner_obj
+{
+ struct gl2_unknown_intf **unkouter;
+};
+
+struct gl2_unkinner_impl
+{
+ struct gl2_unknown_intf *_vftbl;
+ struct gl2_unkinner_obj _obj;
+};
+
+static void
+_unkinner_destructor (struct gl2_unknown_intf **intf)
+{
+}
+
+static void
+_unkinner_AddRef (struct gl2_unknown_intf **intf)
+{
+ struct gl2_unkinner_impl *impl = (struct gl2_unkinner_impl *) intf;
+
+ (**impl->_obj.unkouter).AddRef (impl->_obj.unkouter);
+}
+
+static void
+_unkinner_Release (struct gl2_unknown_intf **intf)
+{
+ struct gl2_unkinner_impl *impl = (struct gl2_unkinner_impl *) intf;
+
+ (**impl->_obj.unkouter).Release (impl->_obj.unkouter);
+}
+
+static struct gl2_unknown_intf **
+_unkinner_QueryInterface (struct gl2_unknown_intf **intf, enum gl2_uiid uiid)
+{
+ struct gl2_unkinner_impl *impl = (struct gl2_unkinner_impl *) intf;
+
+ return (**impl->_obj.unkouter).QueryInterface (impl->_obj.unkouter, uiid);
+}
+
+static struct gl2_unknown_intf _unkinner_vftbl = {
+ _unkinner_AddRef,
+ _unkinner_Release,
+ _unkinner_QueryInterface
+};
+
+static void
+_unkinner_constructor (struct gl2_unkinner_impl *impl, struct gl2_unknown_intf **outer)
+{
+ impl->_vftbl = &_unkinner_vftbl;
+ impl->_obj.unkouter = outer;
+}
+
+struct gl2_generic_obj
+{
+ struct gl2_unknown_obj _unknown;
+ GLhandleARB name;
+ GLboolean delete_status;
+ GLcharARB *info_log;
+};
+
+struct gl2_generic_impl
+{
+ struct gl2_generic_intf *_vftbl;
+ struct gl2_generic_obj _obj;
+};
+
+static void
+_generic_destructor (struct gl2_unknown_intf **intf)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_generic_impl *impl = (struct gl2_generic_impl *) intf;
+
+ _mesa_free ((void *) impl->_obj.info_log);
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ _mesa_HashRemove (ctx->Shared->GL2Objects, impl->_obj.name);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+
+ _unknown_destructor (intf);
+}
+
+static struct gl2_unknown_intf **
+_generic_QueryInterface (struct gl2_unknown_intf **intf, enum gl2_uiid uiid)
+{
+ if (uiid == UIID_GENERIC)
+ {
+ (**intf).AddRef (intf);
+ return intf;
+ }
+ return _unknown_QueryInterface (intf, uiid);
+}
+
+static void
+_generic_Delete (struct gl2_generic_intf **intf)
+{
+ struct gl2_generic_impl *impl = (struct gl2_generic_impl *) intf;
+
+ if (impl->_obj.delete_status == GL_FALSE)
+ {
+ impl->_obj.delete_status = GL_TRUE;
+ (**intf)._unknown.Release ((struct gl2_unknown_intf **) intf);
+ }
+}
+
+static GLhandleARB
+_generic_GetName (struct gl2_generic_intf **intf)
+{
+ struct gl2_generic_impl *impl = (struct gl2_generic_impl *) intf;
+
+ return impl->_obj.name;
+}
+
+static GLboolean
+_generic_GetDeleteStatus (struct gl2_generic_intf **intf)
+{
+ struct gl2_generic_impl *impl = (struct gl2_generic_impl *) intf;
+
+ return impl->_obj.delete_status;
+}
+
+static const GLcharARB *
+_generic_GetInfoLog (struct gl2_generic_intf **intf)
+{
+ struct gl2_generic_impl *impl = (struct gl2_generic_impl *) intf;
+
+ return impl->_obj.info_log;
+}
+
+static struct gl2_generic_intf _generic_vftbl = {
+ {
+ _unknown_AddRef,
+ _unknown_Release,
+ _generic_QueryInterface
+ },
+ _generic_Delete,
+ NULL, /* abstract GetType */
+ _generic_GetName,
+ _generic_GetDeleteStatus,
+ _generic_GetInfoLog
+};
+
+static void
+_generic_constructor (struct gl2_generic_impl *impl)
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ _unknown_constructor ((struct gl2_unknown_impl *) impl);
+ impl->_vftbl = &_generic_vftbl;
+ impl->_obj._unknown._destructor = _generic_destructor;
+ impl->_obj.delete_status = GL_FALSE;
+ impl->_obj.info_log = NULL;
+
+ _glthread_LOCK_MUTEX (ctx->Shared->Mutex);
+ impl->_obj.name = _mesa_HashFindFreeKeyBlock (ctx->Shared->GL2Objects, 1);
+ _mesa_HashInsert (ctx->Shared->GL2Objects, impl->_obj.name, (void *) impl);
+ _glthread_UNLOCK_MUTEX (ctx->Shared->Mutex);
+}
+
+struct gl2_container_obj
+{
+ struct gl2_generic_obj _generic;
+ struct gl2_generic_intf ***attached;
+ GLuint attached_count;
+};
+
+struct gl2_container_impl
+{
+ struct gl2_container_intf *_vftbl;
+ struct gl2_container_obj _obj;
+};
+
+static void
+_container_destructor (struct gl2_unknown_intf **intf)
+{
+ struct gl2_container_impl *impl = (struct gl2_container_impl *) intf;
+ GLuint i;
+
+ for (i = 0; i < impl->_obj.attached_count; i++)
+ {
+ struct gl2_generic_intf **x = impl->_obj.attached[i];
+ (**x)._unknown.Release ((struct gl2_unknown_intf **) x);
+ }
+
+ _generic_destructor (intf);
+}
+
+static struct gl2_unknown_intf **
+_container_QueryInterface (struct gl2_unknown_intf **intf, enum gl2_uiid uiid)
+{
+ if (uiid == UIID_CONTAINER)
+ {
+ (**intf).AddRef (intf);
+ return intf;
+ }
+ return _generic_QueryInterface (intf, uiid);
+}
+
+static GLboolean
+_container_Attach (struct gl2_container_intf **intf, struct gl2_generic_intf **att)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_container_impl *impl = (struct gl2_container_impl *) intf;
+ GLuint i;
+
+ for (i = 0; i < impl->_obj.attached_count; i++)
+ if (impl->_obj.attached[i] == att)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "_container_Attach");
+ return GL_FALSE;
+ }
+
+ impl->_obj.attached = (struct gl2_generic_intf ***) _mesa_realloc (impl->_obj.attached,
+ impl->_obj.attached_count * sizeof (*impl->_obj.attached), (impl->_obj.attached_count + 1) *
+ sizeof (*impl->_obj.attached));
+ if (impl->_obj.attached == NULL)
+ return GL_FALSE;
+
+ impl->_obj.attached[impl->_obj.attached_count] = att;
+ impl->_obj.attached_count++;
+ (**att)._unknown.AddRef ((struct gl2_unknown_intf **) att);
+ return GL_TRUE;
+}
+
+static GLboolean
+_container_Detach (struct gl2_container_intf **intf, struct gl2_generic_intf **att)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_container_impl *impl = (struct gl2_container_impl *) intf;
+ GLuint i, j;
+
+ for (i = 0; i < impl->_obj.attached_count; i++)
+ if (impl->_obj.attached[i] == att)
+ {
+ for (j = i; j < impl->_obj.attached_count - 1; j++)
+ impl->_obj.attached[j] = impl->_obj.attached[j + 1];
+ impl->_obj.attached = (struct gl2_generic_intf ***) _mesa_realloc (impl->_obj.attached,
+ impl->_obj.attached_count * sizeof (*impl->_obj.attached),
+ (impl->_obj.attached_count - 1) * sizeof (*impl->_obj.attached));
+ impl->_obj.attached_count--;
+ (**att)._unknown.Release ((struct gl2_unknown_intf **) att);
+ return GL_TRUE;
+ }
+
+ _mesa_error (ctx, GL_INVALID_OPERATION, "_container_Detach");
+ return GL_FALSE;
+}
+
+static GLsizei
+_container_GetAttachedCount (struct gl2_container_intf **intf)
+{
+ struct gl2_container_impl *impl = (struct gl2_container_impl *) intf;
+
+ return impl->_obj.attached_count;
+}
+
+static struct gl2_generic_intf **
+_container_GetAttached (struct gl2_container_intf **intf, GLuint index)
+{
+ struct gl2_container_impl *impl = (struct gl2_container_impl *) intf;
+
+ (**impl->_obj.attached[index])._unknown.AddRef (
+ (struct gl2_unknown_intf **)impl->_obj.attached[index]);
+ return impl->_obj.attached[index];
+}
+
+static struct gl2_container_intf _container_vftbl = {
+ {
+ {
+ _unknown_AddRef,
+ _unknown_Release,
+ _container_QueryInterface
+ },
+ _generic_Delete,
+ NULL, /* abstract GetType */
+ _generic_GetName,
+ _generic_GetDeleteStatus,
+ _generic_GetInfoLog
+ },
+ _container_Attach,
+ _container_Detach,
+ _container_GetAttachedCount,
+ _container_GetAttached
+};
+
+static void
+_container_constructor (struct gl2_container_impl *impl)
+{
+ _generic_constructor ((struct gl2_generic_impl *) impl);
+ impl->_vftbl = &_container_vftbl;
+ impl->_obj._generic._unknown._destructor = _container_destructor;
+ impl->_obj.attached = NULL;
+ impl->_obj.attached_count = 0;
+}
+
+struct gl2_3dlabs_shhandle_obj
+{
+ struct gl2_unkinner_obj _unknown;
+#if USE_3DLABS_FRONTEND
+ ShHandle handle;
+#endif
+};
+
+struct gl2_3dlabs_shhandle_impl
+{
+ struct gl2_3dlabs_shhandle_intf *_vftbl;
+ struct gl2_3dlabs_shhandle_obj _obj;
+};
+
+static void
+_3dlabs_shhandle_destructor (struct gl2_unknown_intf **intf)
+{
+#if USE_3DLABS_FRONTEND
+ struct gl2_3dlabs_shhandle_impl *impl = (struct gl2_3dlabs_shhandle_impl *) intf;
+ ShDestruct (impl->_obj.handle);
+#endif
+ _unkinner_destructor (intf);
+}
+
+static GLvoid *
+_3dlabs_shhandle_GetShHandle (struct gl2_3dlabs_shhandle_intf **intf)
+{
+#if USE_3DLABS_FRONTEND
+ struct gl2_3dlabs_shhandle_impl *impl = (struct gl2_3dlabs_shhandle_impl *) intf;
+ return impl->_obj.handle;
+#else
+ return NULL;
+#endif
+}
+
+static struct gl2_3dlabs_shhandle_intf _3dlabs_shhandle_vftbl = {
+ {
+ _unkinner_AddRef,
+ _unkinner_Release,
+ _unkinner_QueryInterface
+ },
+ _3dlabs_shhandle_GetShHandle
+};
+
+static void
+_3dlabs_shhandle_constructor (struct gl2_3dlabs_shhandle_impl *impl, struct gl2_unknown_intf **outer)
+{
+ _unkinner_constructor ((struct gl2_unkinner_impl *) impl, outer);
+ impl->_vftbl = &_3dlabs_shhandle_vftbl;
+#if USE_3DLABS_FRONTEND
+ impl->_obj.handle = NULL;
+#endif
+}
+
+struct gl2_shader_obj
+{
+ struct gl2_generic_obj _generic;
+ struct gl2_3dlabs_shhandle_impl _3dlabs_shhandle;
+ GLboolean compile_status;
+ GLcharARB *source;
+ GLint *offsets;
+ GLsizei offset_count;
+};
+
+struct gl2_shader_impl
+{
+ struct gl2_shader_intf *_vftbl;
+ struct gl2_shader_obj _obj;
+};
+
+static void
+_shader_destructor (struct gl2_unknown_intf **intf)
+{
+ struct gl2_shader_impl *impl = (struct gl2_shader_impl *) intf;
+
+ _mesa_free ((void *) impl->_obj.source);
+ _mesa_free ((void *) impl->_obj.offsets);
+ _3dlabs_shhandle_destructor ((struct gl2_unknown_intf **) &impl->_obj._3dlabs_shhandle._vftbl);
+ _generic_destructor (intf);
+}
+
+static struct gl2_unknown_intf **
+_shader_QueryInterface (struct gl2_unknown_intf **intf, enum gl2_uiid uiid)
+{
+#if USE_3DLABS_FRONTEND
+ struct gl2_shader_impl *impl = (struct gl2_shader_impl *) intf;
+#endif
+
+ if (uiid == UIID_SHADER)
+ {
+ (**intf).AddRef (intf);
+ return intf;
+ }
+#if USE_3DLABS_FRONTEND
+ if (uiid == UIID_3DLABS_SHHANDLE)
+ {
+ (**intf).AddRef (intf);
+ return (struct gl2_unknown_intf **) &impl->_obj._3dlabs_shhandle._vftbl;
+ }
+#endif
+ return _generic_QueryInterface (intf, uiid);
+}
+
+static GLenum
+_shader_GetType (struct gl2_generic_intf **intf)
+{
+ return GL_SHADER_OBJECT_ARB;
+}
+
+static GLboolean
+_shader_GetCompileStatus (struct gl2_shader_intf **intf)
+{
+ struct gl2_shader_impl *impl = (struct gl2_shader_impl *) intf;
+
+ return impl->_obj.compile_status;
+}
+
+static GLvoid
+_shader_SetSource (struct gl2_shader_intf **intf, GLcharARB *src, GLint *off, GLsizei cnt)
+{
+ struct gl2_shader_impl *impl = (struct gl2_shader_impl *) intf;
+
+ _mesa_free ((void *) impl->_obj.source);
+ impl->_obj.source = src;
+ _mesa_free ((void *) impl->_obj.offsets);
+ impl->_obj.offsets = off;
+ impl->_obj.offset_count = cnt;
+}
+
+static const GLcharARB *
+_shader_GetSource (struct gl2_shader_intf **intf)
+{
+ struct gl2_shader_impl *impl = (struct gl2_shader_impl *) intf;
+
+ return impl->_obj.source;
+}
+
+static GLvoid
+_shader_Compile (struct gl2_shader_intf **intf)
+{
+ struct gl2_shader_impl *impl = (struct gl2_shader_impl *) intf;
+#if USE_3DLABS_FRONTEND
+ char **strings;
+ TBuiltInResource res;
+#else
+ slang_translation_unit unit;
+ slang_unit_type type;
+ slang_info_log info_log;
+#endif
+
+ impl->_obj.compile_status = GL_FALSE;
+ _mesa_free ((void *) impl->_obj._generic.info_log);
+ impl->_obj._generic.info_log = NULL;
+
+#if USE_3DLABS_FRONTEND
+ /* 3dlabs compiler expects us to feed it with null-terminated string array,
+ we've got only one big string with offsets, so we must split it; but when
+ there's only one string to deal with, we pass its address directly */
+
+ if (impl->_obj.offset_count <= 1)
+ strings = &impl->_obj.source;
+ else
+ {
+ GLsizei i, offset = 0;
+
+ strings = (char **) _mesa_malloc (impl->_obj.offset_count * sizeof (char *));
+ if (strings == NULL)
+ return;
+
+ for (i = 0; i < impl->_obj.offset_count; i++)
+ {
+ GLsizei size = impl->_obj.offsets[i] - offset;
+
+ strings[i] = (char *) _mesa_malloc ((size + 1) * sizeof (char));
+ if (strings[i] == NULL)
+ {
+ GLsizei j;
+
+ for (j = 0; j < i; j++)
+ _mesa_free (strings[j]);
+ _mesa_free (strings);
+ return;
+ }
+
+ _mesa_memcpy (strings[i], impl->_obj.source + offset, size * sizeof (char));
+ strings[i][size] = '\0';
+ offset = impl->_obj.offsets[i];
+ }
+ }
+
+ /* TODO set these fields to some REAL numbers */
+ res.maxLights = 8;
+ res.maxClipPlanes = 6;
+ res.maxTextureUnits = 2;
+ res.maxTextureCoords = 2;
+ res.maxVertexAttribs = 8;
+ res.maxVertexUniformComponents = 64;
+ res.maxVaryingFloats = 8;
+ res.maxVertexTextureImageUnits = 2;
+ res.maxCombinedTextureImageUnits = 2;
+ res.maxTextureImageUnits = 2;
+ res.maxFragmentUniformComponents = 64;
+ res.maxDrawBuffers = 1;
+
+ if (ShCompile (impl->_obj._3dlabs_shhandle._obj.handle, strings, impl->_obj.offset_count,
+ EShOptFull, &res, 0))
+ impl->_obj.compile_status = GL_TRUE;
+ if (impl->_obj.offset_count > 1)
+ {
+ GLsizei i;
+
+ for (i = 0; i < impl->_obj.offset_count; i++)
+ _mesa_free (strings[i]);
+ _mesa_free (strings);
+ }
+
+ impl->_obj._generic.info_log = _mesa_strdup (ShGetInfoLog (
+ impl->_obj._3dlabs_shhandle._obj.handle));
+#else
+ if (impl->_vftbl->GetSubType (intf) == GL_FRAGMENT_SHADER)
+ type = slang_unit_fragment_shader;
+ else
+ type = slang_unit_vertex_shader;
+ slang_info_log_construct (&info_log);
+ if (_slang_compile (impl->_obj.source, &unit, type, &info_log))
+ {
+ impl->_obj.compile_status = GL_TRUE;
+ }
+ if (info_log.text != NULL)
+ impl->_obj._generic.info_log = _mesa_strdup (info_log.text);
+ else
+ impl->_obj._generic.info_log = _mesa_strdup ("");
+ slang_info_log_destruct (&info_log);
+#endif
+}
+
+static struct gl2_shader_intf _shader_vftbl = {
+ {
+ {
+ _unknown_AddRef,
+ _unknown_Release,
+ _shader_QueryInterface
+ },
+ _generic_Delete,
+ _shader_GetType,
+ _generic_GetName,
+ _generic_GetDeleteStatus,
+ _generic_GetInfoLog
+ },
+ NULL, /* abstract GetSubType */
+ _shader_GetCompileStatus,
+ _shader_SetSource,
+ _shader_GetSource,
+ _shader_Compile
+};
+
+static void
+_shader_constructor (struct gl2_shader_impl *impl)
+{
+ _generic_constructor ((struct gl2_generic_impl *) impl);
+ _3dlabs_shhandle_constructor (&impl->_obj._3dlabs_shhandle, (struct gl2_unknown_intf **)
+ &impl->_vftbl);
+ impl->_vftbl = &_shader_vftbl;
+ impl->_obj._generic._unknown._destructor = _shader_destructor;
+ impl->_obj.compile_status = GL_FALSE;
+ impl->_obj.source = NULL;
+ impl->_obj.offsets = NULL;
+ impl->_obj.offset_count = 0;
+}
+
+struct gl2_program_obj
+{
+ struct gl2_container_obj _container;
+ GLboolean link_status;
+ GLboolean validate_status;
+#if USE_3DLABS_FRONTEND
+ ShHandle linker;
+ ShHandle uniforms;
+#endif
+};
+
+struct gl2_program_impl
+{
+ struct gl2_program_intf *_vftbl;
+ struct gl2_program_obj _obj;
+};
+
+static void
+_program_destructor (struct gl2_unknown_intf **intf)
+{
+#if USE_3DLABS_FRONTEND
+ struct gl2_program_impl *impl = (struct gl2_program_impl *) intf;
+
+ ShDestruct (impl->_obj.linker);
+ ShDestruct (impl->_obj.uniforms);
+#endif
+ _container_destructor (intf);
+}
+
+static struct gl2_unknown_intf **
+_program_QueryInterface (struct gl2_unknown_intf **intf, enum gl2_uiid uiid)
+{
+ if (uiid == UIID_PROGRAM)
+ {
+ (**intf).AddRef (intf);
+ return intf;
+ }
+ return _container_QueryInterface (intf, uiid);
+}
+
+static GLenum
+_program_GetType (struct gl2_generic_intf **intf)
+{
+ return GL_PROGRAM_OBJECT_ARB;
+}
+
+static GLboolean
+_program_Attach (struct gl2_container_intf **intf, struct gl2_generic_intf **att)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ struct gl2_unknown_intf **sha;
+
+ sha = (**att)._unknown.QueryInterface ((struct gl2_unknown_intf **) att, UIID_SHADER);
+ if (sha == NULL)
+ {
+ _mesa_error (ctx, GL_INVALID_OPERATION, "_program_Attach");
+ return GL_FALSE;
+ }
+
+ (**sha).Release (sha);
+ return _container_Attach (intf, att);
+}
+
+static GLboolean
+_program_GetLinkStatus (struct gl2_program_intf **intf)
+{
+ struct gl2_program_impl *impl = (struct gl2_program_impl *) intf;
+
+ return impl->_obj.link_status;
+}
+
+static GLboolean
+_program_GetValidateStatus (struct gl2_program_intf **intf)
+{
+ struct gl2_program_impl *impl = (struct gl2_program_impl *) intf;
+
+ return impl->_obj.validate_status;
+}
+
+static GLvoid
+_program_Link (struct gl2_program_intf **intf)
+{
+ struct gl2_program_impl *impl = (struct gl2_program_impl *) intf;
+#if USE_3DLABS_FRONTEND
+ ShHandle *handles;
+ GLuint i;
+#endif
+
+ impl->_obj.link_status = GL_FALSE;
+ _mesa_free ((void *) impl->_obj._container._generic.info_log);
+ impl->_obj._container._generic.info_log = NULL;
+
+#if USE_3DLABS_FRONTEND
+ handles = (ShHandle *) _mesa_malloc (impl->_obj._container.attached_count * sizeof (ShHandle));
+ if (handles == NULL)
+ return;
+
+ for (i = 0; i < impl->_obj._container.attached_count; i++)
+ {
+ struct gl2_generic_intf **gen = impl->_obj._container.attached[i];
+ struct gl2_3dlabs_shhandle_intf **sh;
+
+ sh = (struct gl2_3dlabs_shhandle_intf **) (**gen)._unknown.QueryInterface (
+ (struct gl2_unknown_intf **) gen, UIID_3DLABS_SHHANDLE);
+ if (sh != NULL)
+ {
+ handles[i] = (**sh).GetShHandle (sh);
+ (**sh)._unknown.Release ((struct gl2_unknown_intf **) sh);
+ }
+ else
+ {
+ _mesa_free (handles);
+ return;
+ }
+ }
+
+ if (ShLink (impl->_obj.linker, handles, impl->_obj._container.attached_count,
+ impl->_obj.uniforms, NULL, NULL))
+ impl->_obj.link_status = GL_TRUE;
+
+ impl->_obj._container._generic.info_log = _mesa_strdup (ShGetInfoLog (impl->_obj.linker));
+#endif
+}
+
+static GLvoid
+_program_Validate (struct gl2_program_intf **intf)
+{
+ struct gl2_program_impl *impl = (struct gl2_program_impl *) intf;
+
+ impl->_obj.validate_status = GL_FALSE;
+ _mesa_free ((void *) impl->_obj._container._generic.info_log);
+ impl->_obj._container._generic.info_log = NULL;
+
+ /* TODO validate */
+}
+
+static struct gl2_program_intf _program_vftbl = {
+ {
+ {
+ {
+ _unknown_AddRef,
+ _unknown_Release,
+ _program_QueryInterface
+ },
+ _generic_Delete,
+ _program_GetType,
+ _generic_GetName,
+ _generic_GetDeleteStatus,
+ _generic_GetInfoLog
+ },
+ _program_Attach,
+ _container_Detach,
+ _container_GetAttachedCount,
+ _container_GetAttached
+ },
+ _program_GetLinkStatus,
+ _program_GetValidateStatus,
+ _program_Link,
+ _program_Validate
+};
+
+static void
+_program_constructor (struct gl2_program_impl *impl)
+{
+ _container_constructor ((struct gl2_container_impl *) impl);
+ impl->_vftbl = &_program_vftbl;
+ impl->_obj._container._generic._unknown._destructor = _program_destructor;
+ impl->_obj.link_status = GL_FALSE;
+ impl->_obj.validate_status = GL_FALSE;
+#if USE_3DLABS_FRONTEND
+ impl->_obj.linker = ShConstructLinker (EShExVertexFragment, 0);
+ impl->_obj.uniforms = ShConstructUniformMap ();
+#endif
+}
+
+struct gl2_fragment_shader_obj
+{
+ struct gl2_shader_obj _shader;
+};
+
+struct gl2_fragment_shader_impl
+{
+ struct gl2_fragment_shader_intf *_vftbl;
+ struct gl2_fragment_shader_obj _obj;
+};
+
+static void
+_fragment_shader_destructor (struct gl2_unknown_intf **intf)
+{
+ struct gl2_fragment_shader_impl *impl = (struct gl2_fragment_shader_impl *) intf;
+
+ (void) impl;
+ /* TODO free fragment shader data */
+
+ _shader_destructor (intf);
+}
+
+static struct gl2_unknown_intf **
+_fragment_shader_QueryInterface (struct gl2_unknown_intf **intf, enum gl2_uiid uiid)
+{
+ if (uiid == UIID_FRAGMENT_SHADER)
+ {
+ (**intf).AddRef (intf);
+ return intf;
+ }
+ return _shader_QueryInterface (intf, uiid);
+}
+
+static GLenum
+_fragment_shader_GetSubType (struct gl2_shader_intf **intf)
+{
+ return GL_FRAGMENT_SHADER_ARB;
+}
+
+static struct gl2_fragment_shader_intf _fragment_shader_vftbl = {
+ {
+ {
+ {
+ _unknown_AddRef,
+ _unknown_Release,
+ _fragment_shader_QueryInterface
+ },
+ _generic_Delete,
+ _shader_GetType,
+ _generic_GetName,
+ _generic_GetDeleteStatus,
+ _generic_GetInfoLog
+ },
+ _fragment_shader_GetSubType,
+ _shader_GetCompileStatus,
+ _shader_SetSource,
+ _shader_GetSource,
+ _shader_Compile
+ }
+};
+
+static void
+_fragment_shader_constructor (struct gl2_fragment_shader_impl *impl)
+{
+ _shader_constructor ((struct gl2_shader_impl *) impl);
+ impl->_vftbl = &_fragment_shader_vftbl;
+ impl->_obj._shader._generic._unknown._destructor = _fragment_shader_destructor;
+#if USE_3DLABS_FRONTEND
+ impl->_obj._shader._3dlabs_shhandle._obj.handle = ShConstructCompiler (EShLangFragment, 0);
+#endif
+}
+
+struct gl2_vertex_shader_obj
+{
+ struct gl2_shader_obj _shader;
+};
+
+struct gl2_vertex_shader_impl
+{
+ struct gl2_vertex_shader_intf *_vftbl;
+ struct gl2_vertex_shader_obj _obj;
+};
+
+static void
+_vertex_shader_destructor (struct gl2_unknown_intf **intf)
+{
+ struct gl2_vertex_shader_impl *impl = (struct gl2_vertex_shader_impl *) intf;
+
+ (void) impl;
+ /* TODO free vertex shader data */
+
+ _shader_destructor (intf);
+}
+
+static struct gl2_unknown_intf **
+_vertex_shader_QueryInterface (struct gl2_unknown_intf **intf, enum gl2_uiid uiid)
+{
+ if (uiid == UIID_VERTEX_SHADER)
+ {
+ (**intf).AddRef (intf);
+ return intf;
+ }
+ return _shader_QueryInterface (intf, uiid);
+}
+
+static GLenum
+_vertex_shader_GetSubType (struct gl2_shader_intf **intf)
+{
+ return GL_VERTEX_SHADER_ARB;
+}
+
+static struct gl2_vertex_shader_intf _vertex_shader_vftbl = {
+ {
+ {
+ {
+ _unknown_AddRef,
+ _unknown_Release,
+ _vertex_shader_QueryInterface
+ },
+ _generic_Delete,
+ _shader_GetType,
+ _generic_GetName,
+ _generic_GetDeleteStatus,
+ _generic_GetInfoLog
+ },
+ _vertex_shader_GetSubType,
+ _shader_GetCompileStatus,
+ _shader_SetSource,
+ _shader_GetSource,
+ _shader_Compile
+ }
+};
+
+static void
+_vertex_shader_constructor (struct gl2_vertex_shader_impl *impl)
+{
+ _shader_constructor ((struct gl2_shader_impl *) impl);
+ impl->_vftbl = &_vertex_shader_vftbl;
+ impl->_obj._shader._generic._unknown._destructor = _vertex_shader_destructor;
+#if USE_3DLABS_FRONTEND
+ impl->_obj._shader._3dlabs_shhandle._obj.handle = ShConstructCompiler (EShLangVertex, 0);
+#endif
+}
+
+GLhandleARB
+_mesa_3dlabs_create_shader_object (GLenum shaderType)
+{
+ switch (shaderType)
+ {
+ case GL_FRAGMENT_SHADER_ARB:
+ {
+ struct gl2_fragment_shader_impl *x = (struct gl2_fragment_shader_impl *)
+ _mesa_malloc (sizeof (struct gl2_fragment_shader_impl));
+
+ if (x != NULL)
+ {
+ _fragment_shader_constructor (x);
+ return x->_obj._shader._generic.name;
+ }
+ }
+ break;
+ case GL_VERTEX_SHADER_ARB:
+ {
+ struct gl2_vertex_shader_impl *x = (struct gl2_vertex_shader_impl *)
+ _mesa_malloc (sizeof (struct gl2_vertex_shader_impl));
+
+ if (x != NULL)
+ {
+ _vertex_shader_constructor (x);
+ return x->_obj._shader._generic.name;
+ }
+ }
+ break;
+ }
+
+ return 0;
+}
+
+GLhandleARB
+_mesa_3dlabs_create_program_object (void)
+{
+ struct gl2_program_impl *x = (struct gl2_program_impl *)
+ _mesa_malloc (sizeof (struct gl2_program_impl));
+
+ if (x != NULL)
+ {
+ _program_constructor (x);
+ return x->_obj._container._generic.name;
+ }
+
+ return 0;
+}
+
+void
+_mesa_init_shaderobjects_3dlabs (GLcontext *ctx)
+{
+#if USE_3DLABS_FRONTEND
+ _glslang_3dlabs_InitProcess ();
+ _glslang_3dlabs_ShInitialize ();
+#endif
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/shaderobjects_3dlabs.h b/nx-X11/extras/Mesa/src/mesa/shader/shaderobjects_3dlabs.h
new file mode 100755
index 000000000..4cb8cf454
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/shaderobjects_3dlabs.h
@@ -0,0 +1,40 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef SHADEROBJECTS_3DLABS_H
+#define SHADEROBJECTS_3DLABS_H
+
+#include "mtypes.h"
+
+extern GLhandleARB
+_mesa_3dlabs_create_shader_object (GLenum);
+
+extern GLhandleARB
+_mesa_3dlabs_create_program_object (void);
+
+extern void
+_mesa_init_shaderobjects_3dlabs (GLcontext *ctx);
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/BaseTypes.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/BaseTypes.h
new file mode 100755
index 000000000..c5bf8de17
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/BaseTypes.h
@@ -0,0 +1,133 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#ifndef _BASICTYPES_INCLUDED_
+#define _BASICTYPES_INCLUDED_
+
+//
+// Basic type. Arrays, vectors, etc., are orthogonal to this.
+//
+enum TBasicType {
+ EbtVoid,
+ EbtFloat,
+ EbtInt,
+ EbtBool,
+ EbtSampler1D,
+ EbtSampler2D,
+ EbtSampler3D,
+ EbtSamplerCube,
+ EbtSampler1DShadow,
+ EbtSampler2DShadow,
+ EbtStruct,
+ EbtAddress
+};
+
+__inline bool IsSampler(TBasicType type)
+{
+ return type >= EbtSampler1D && type <= EbtSampler2DShadow;
+}
+
+//
+// Qualifiers and built-ins. These are mainly used to see what can be read
+// or written, and by the machine dependent translator to know which registers
+// to allocate variables in. Since built-ins tend to go to different registers
+// than varying or uniform, it makes sense they are peers, not sub-classes.
+//
+enum TQualifier {
+ EvqTemporary, // For temporaries (within a function), read/write
+ EvqGlobal, // For globals read/write
+ EvqConst, // User defined constants and non-output parameters in functions
+ EvqAttribute, // Readonly
+ EvqVaryingIn, // readonly, fragment shaders only
+ EvqVaryingOut, // vertex shaders only read/write
+ EvqUniform, // Readonly, vertex and fragment
+
+ // pack/unpack input and output
+ EvqInput,
+ EvqOutput,
+
+ // parameters
+ EvqIn,
+ EvqOut,
+ EvqInOut,
+ EvqConstReadOnly,
+
+ // built-ins written by vertex shader
+ EvqPosition,
+ EvqPointSize,
+ EvqClipVertex,
+
+ // built-ins read by fragment shader
+ EvqFace,
+ EvqFragCoord,
+
+ // built-ins written by fragment shader
+ EvqFragColor,
+ EvqFragDepth,
+
+ // end of list
+ EvqLast
+};
+
+//
+// This is just for debug print out, carried along with the definitions above.
+//
+__inline const char* getQualifierString(TQualifier q)
+{
+ switch (q) {
+ case EvqTemporary: return "Temporary"; break;
+ case EvqGlobal: return "Global"; break;
+ case EvqConst: return "const"; break;
+ case EvqConstReadOnly: return "const"; break;
+ case EvqAttribute: return "attribute"; break;
+ case EvqVaryingIn: return "varying"; break;
+ case EvqVaryingOut: return "varying"; break;
+ case EvqUniform: return "uniform"; break;
+ case EvqIn: return "in"; break;
+ case EvqOut: return "out"; break;
+ case EvqInOut: return "inout"; break;
+ case EvqInput: return "input"; break;
+ case EvqOutput: return "output"; break;
+ case EvqPosition: return "Position"; break;
+ case EvqPointSize: return "PointSize"; break;
+ case EvqClipVertex: return "ClipVertex"; break;
+ case EvqFace: return "Face"; break;
+ case EvqFragCoord: return "FragCoord"; break;
+ case EvqFragColor: return "FragColor"; break;
+ case EvqFragDepth: return "FragDepth"; break;
+ default: return "unknown qualifier";
+ }
+}
+
+#endif // _BASICTYPES_INCLUDED_
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/Common.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/Common.h
new file mode 100755
index 000000000..4a9c0d34a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/Common.h
@@ -0,0 +1,288 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#ifndef _COMMON_INCLUDED_
+#define _COMMON_INCLUDED_
+
+#ifdef _WIN32
+ #include <basetsd.h>
+#elif defined (solaris)
+ #include <sys/int_types.h>
+ #define UINT_PTR uintptr_t
+#else
+ #include <stdint.h>
+ #define UINT_PTR uintptr_t
+#endif
+
+/* windows only pragma */
+#ifdef _MSC_VER
+ #pragma warning(disable : 4786) // Don't warn about too long identifiers
+ #pragma warning(disable : 4514) // unused inline method
+ #pragma warning(disable : 4201) // nameless union
+#endif
+
+//
+// Doing the push and pop below for warnings does not leave the warning state
+// the way it was. This seems like a defect in the compiler. We would like
+// to do this, but since it does not work correctly right now, it is turned
+// off.
+//
+//??#pragma warning(push, 3)
+
+ #include <set>
+ #include <vector>
+ #include <map>
+ #include <list>
+ #include <string>
+ #include <stdio.h>
+
+//??#pragma warning(pop)
+
+typedef int TSourceLoc;
+
+#include <assert.h>
+#include "PoolAlloc.h"
+
+//
+// Put POOL_ALLOCATOR_NEW_DELETE in base classes to make them use this scheme.
+//
+#define POOL_ALLOCATOR_NEW_DELETE(A) \
+ void* operator new(size_t s) { return (A).allocate(s); } \
+ void* operator new(size_t, void *_Where) { return (_Where); } \
+ void operator delete(void*) { } \
+ void operator delete(void *, void *) { } \
+ void* operator new[](size_t s) { return (A).allocate(s); } \
+ void* operator new[](size_t, void *_Where) { return (_Where); } \
+ void operator delete[](void*) { } \
+ void operator delete[](void *, void *) { }
+
+#ifdef _M_AMD64
+//
+// The current version of STL that comes with the PSDK (as required for the AMD64 compiler)
+// has a very old version of the STL which is very out of date. As a result, various additions needed
+// making to it to get the compilers compiling!
+//
+
+//
+// A new version of the Map template class - the operator[] now returns the correct type reference
+//
+template <class _K, class _Ty, class _Pr = std::less<_K>, class _A = std::allocator<_Ty> >
+class TBaseMap : public std::map <_K, _Ty, _Pr, _A >
+{
+public :
+ _Ty& operator[] (const _K& _Kv)
+ {
+ iterator _P = insert(value_type(_Kv, _Ty())).first;
+ return ((*_P).second);
+ }
+
+ explicit TBaseMap(const _Pr& _Pred = _Pr(), const _A& _Al = _A())
+ : std::map<_K, _Ty, _Pr, _A >(_Pred, _Al) {};
+
+
+};
+
+//
+// A new version of the List template class - the begin function now checks for NULL to eliminate access violations
+//
+template <class _Ty, class _A = std::allocator<_Ty> >
+class TBaseList : public std::list <_Ty, _A >
+{
+public :
+ iterator begin()
+ {
+ return (iterator(_Head == 0 ? 0 : _Acc::_Next(_Head)));
+ }
+
+ const_iterator begin() const
+ {
+ return (const_iterator(_Head == 0 ? 0 : _Acc::_Next(_Head)));
+ }
+
+ //
+ // These are required - apparently!
+ //
+ explicit TBaseList(const _A& _Al = _A())
+ : std::list<_Ty, _A >(_Al) {};
+ explicit TBaseList(size_type _N, const _Ty& _V = _Ty(), const _A& _Al = _A())
+ : std::list<_Ty, _A >(N, _V, _Al) {};
+
+};
+
+//
+// A new version of the set class - this defines the required insert method
+//
+template<class _K, class _Pr = std::less<_K>, class _A = std::allocator<_K> >
+class TBaseSet : public std::set <_K, _Pr, _A>
+{
+public :
+
+ //
+ // This method wasn't defined
+ //
+ template<class _Iter>
+ void insert(_Iter _First, _Iter _Last)
+ { // insert [_First, _Last)
+ for (; _First != _Last; ++_First)
+ this->insert(*_First);
+ }
+
+ //
+ // These methods were not resolved if I declared the previous method??
+ //
+ _Pairib insert(const value_type& _X)
+ {
+ _Imp::_Pairib _Ans = _Tr.insert(_X);
+ return (_Pairib(_Ans.first, _Ans.second));
+ }
+
+ iterator insert(iterator _P, const value_type& _X)
+ {
+ return (_Tr.insert((_Imp::iterator&)_P, _X));
+ }
+
+ void insert(_It _F, _It _L)
+ {
+ for (; _F != _L; ++_F)
+ _Tr.insert(*_F);
+ }
+
+};
+
+#else
+
+#define TBaseMap std::map
+#define TBaseList std::list
+#define TBaseSet std::set
+
+#endif //_M_AMD64
+
+//
+// Pool version of string.
+//
+typedef pool_allocator<char> TStringAllocator;
+typedef std::basic_string <char, std::char_traits<char>, TStringAllocator > TString;
+inline TString* NewPoolTString(const char* s)
+{
+ void* memory = GlobalPoolAllocator.allocate(sizeof(TString));
+ return new(memory) TString(s);
+}
+
+//
+// Pool allocator versions of vectors, lists, and maps
+//
+template <class T> class TVector : public std::vector<T, pool_allocator<T> > {
+public:
+ typedef typename std::vector<T, pool_allocator<T> >::size_type size_type;
+ TVector() : std::vector<T, pool_allocator<T> >() {}
+ TVector(const pool_allocator<T>& a) : std::vector<T, pool_allocator<T> >(a) {}
+ TVector(size_type i): std::vector<T, pool_allocator<T> >(i) {}
+};
+
+template <class T> class TList : public TBaseList <T, pool_allocator<T> > {
+public:
+ typedef typename TBaseList<T, pool_allocator<T> >::size_type size_type;
+ TList() : TBaseList<T, pool_allocator<T> >() {}
+ TList(const pool_allocator<T>& a) : TBaseList<T, pool_allocator<T> >(a) {}
+ TList(size_type i): TBaseList<T, pool_allocator<T> >(i) {}
+};
+
+// This is called TStlSet, because TSet is taken by an existing compiler class.
+template <class T, class CMP> class TStlSet : public std::set<T, CMP, pool_allocator<T> > {
+ // No pool allocator versions of constructors in std::set.
+};
+
+
+template <class K, class D, class CMP = std::less<K> > class TMap :
+ public TBaseMap<K, D, CMP, pool_allocator<std::pair<K, D> > > {
+public:
+ typedef pool_allocator<std::pair <K, D> > tAllocator;
+
+ TMap() : TBaseMap<K, D, CMP, tAllocator >() {}
+/*
+ TMap(const tAllocator& a) : TBaseMap<K, D, CMP, tAllocator >(key_compare(), a) {}
+*/
+ TMap(const tAllocator& a) : TBaseMap<K, D, CMP, tAllocator >() {}
+};
+
+//
+// Persistent string memory. Should only be used for strings that survive
+// across compiles/links.
+//
+typedef std::basic_string<char> TPersistString;
+
+//
+// templatized min and max functions.
+//
+template <class T> T Min(const T a, const T b) { return a < b ? a : b; }
+template <class T> T Max(const T a, const T b) { return a > b ? a : b; }
+
+//
+// Create a TString object from an integer.
+//
+inline const TString String(const int i, const int base = 10)
+{
+ char text[16]; // 32 bit ints are at most 10 digits in base 10
+
+ #ifdef _WIN32
+ itoa(i, text, base);
+ #else
+ // we assume base 10 for all cases
+ sprintf(text, "%d", i);
+ #endif
+
+ return text;
+}
+
+const unsigned int SourceLocLineMask = 0xffff;
+const unsigned int SourceLocStringShift = 16;
+
+__inline TPersistString FormatSourceLoc(const TSourceLoc loc)
+{
+ char locText[64];
+
+ int string = loc >> SourceLocStringShift;
+ int line = loc & SourceLocLineMask;
+
+ if (line)
+ sprintf(locText, "%d:%d", string, line);
+ else
+ sprintf(locText, "%d:? ", string);
+
+ return TPersistString(locText);
+}
+typedef TMap<TString, TString> TPragmaTable;
+typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator;
+
+#endif // _COMMON_INCLUDED_
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/ConstantUnion.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/ConstantUnion.h
new file mode 100755
index 000000000..a60ae114f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/ConstantUnion.h
@@ -0,0 +1,50 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#ifndef _CONSTANT_UNION_INCLUDED_
+#define _CONSTANT_UNION_INCLUDED_
+
+
+class constUnion {
+public:
+
+ POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
+ union {
+ int iConst; // used for ivec
+ bool bConst; // used for bvec
+ float fConst; // used for vec, mat
+ } ;
+};
+
+#endif // _CONSTANT_UNION_INCLUDED_
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/InfoSink.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/InfoSink.h
new file mode 100755
index 000000000..14d44a34a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/InfoSink.h
@@ -0,0 +1,135 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#ifndef _INFOSINK_INCLUDED_
+#define _INFOSINK_INCLUDED_
+
+#include "../Include/Common.h"
+#include <math.h>
+
+//
+// TPrefixType is used to centralize how info log messages start.
+// See below.
+//
+enum TPrefixType {
+ EPrefixNone,
+ EPrefixWarning,
+ EPrefixError,
+ EPrefixInternalError,
+ EPrefixUnimplemented
+};
+
+enum TOutputStream {
+ ENull = 0,
+ EDebugger = 0x01,
+ EStdOut = 0x02,
+ EString = 0x04
+};
+//
+// Encapsulate info logs for all objects that have them.
+//
+// The methods are a general set of tools for getting a variety of
+// messages and types inserted into the log.
+//
+class TInfoSinkBase {
+public:
+ TInfoSinkBase() : outputStream(4) {}
+ void erase() { sink.erase(); }
+ TInfoSinkBase& operator<<(const TPersistString& t) { append(t); return *this; }
+ TInfoSinkBase& operator<<(char c) { append(1, c); return *this; }
+ TInfoSinkBase& operator<<(const char* s) { append(s); return *this; }
+ TInfoSinkBase& operator<<(int n) { append(String(n)); return *this; }
+ TInfoSinkBase& operator<<(const unsigned int n) { append(String(n)); return *this; }
+ TInfoSinkBase& operator<<(float n) { char buf[40];
+ sprintf(buf, (fabs(n) > 1e-8 && fabs(n) < 1e8) || n == 0.0f ?
+ "%f" : "%g", n);
+ append(buf);
+ return *this; }
+ TInfoSinkBase& operator+(const TPersistString& t) { append(t); return *this; }
+ TInfoSinkBase& operator+(const TString& t) { append(t); return *this; }
+ TInfoSinkBase& operator<<(const TString& t) { append(t); return *this; }
+ TInfoSinkBase& operator+(const char* s) { append(s); return *this; }
+ const char* c_str() const { return sink.c_str(); }
+ void prefix(TPrefixType message) {
+ switch(message) {
+ case EPrefixNone: break;
+ case EPrefixWarning: append("WARNING: "); break;
+ case EPrefixError: append("ERROR: "); break;
+ case EPrefixInternalError: append("INTERNAL ERROR: "); break;
+ case EPrefixUnimplemented: append("UNIMPLEMENTED: "); break;
+ default: append("UNKOWN ERROR: "); break;
+ }
+ }
+ void location(TSourceLoc loc) {
+ append(FormatSourceLoc(loc).c_str());
+ append(": ");
+ }
+ void message(TPrefixType message, const char* s) {
+ prefix(message);
+ append(s);
+ append("\n");
+ }
+ void message(TPrefixType message, const char* s, TSourceLoc loc) {
+ prefix(message);
+ location(loc);
+ append(s);
+ append("\n");
+ }
+
+ void setOutputStream(int output = 4)
+ {
+ outputStream = output;
+ }
+
+protected:
+ void append(const char *s);
+
+ void append(int count, char c);
+ void append(const TPersistString& t);
+ void append(const TString& t);
+
+ void checkMem(size_t growth) { if (sink.capacity() < sink.size() + growth + 2)
+ sink.reserve(sink.capacity() + sink.capacity() / 2); }
+ void appendToStream(const char* s);
+ TPersistString sink;
+ int outputStream;
+};
+
+class TInfoSink {
+public:
+ TInfoSinkBase info;
+ TInfoSinkBase debug;
+};
+
+#endif // _INFOSINK_INCLUDED_
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/InitializeGlobals.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/InitializeGlobals.h
new file mode 100755
index 000000000..3d9a42a2b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/InitializeGlobals.h
@@ -0,0 +1,43 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#ifndef __INITIALIZE_GLOBALS_INCLUDED_
+#define __INITIALIZE_GLOBALS_INCLUDED_
+
+void InitializeGlobalPools();
+void FreeGlobalPools();
+bool InitializePoolIndex();
+void FreePoolIndex();
+
+#endif // __INITIALIZE_GLOBALS_INCLUDED_
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/InitializeParseContext.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/InitializeParseContext.h
new file mode 100755
index 000000000..7d565b313
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/InitializeParseContext.h
@@ -0,0 +1,44 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#ifndef __INITIALIZE_PARSE_CONTEXT_INCLUDED_
+#define __INITIALIZE_PARSE_CONTEXT_INCLUDED_
+#include "osinclude.h"
+
+bool InitializeParseContextIndex();
+bool InitializeGlobalParseContext();
+bool FreeParseContext();
+bool FreeParseContextIndex();
+
+#endif // __INITIALIZE_PARSE_CONTEXT_INCLUDED_
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/PoolAlloc.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/PoolAlloc.h
new file mode 100755
index 000000000..e224d3b86
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/PoolAlloc.h
@@ -0,0 +1,346 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#ifndef _POOLALLOC_INCLUDED_
+#define _POOLALLOC_INCLUDED_
+
+#ifdef _DEBUG
+# define GUARD_BLOCKS // define to enable guard block sanity checking
+#endif
+
+//
+// This header defines an allocator that can be used to efficiently
+// allocate a large number of small requests for heap memory, with the
+// intention that they are not individually deallocated, but rather
+// collectively deallocated at one time.
+//
+// This simultaneously
+//
+// * Makes each individual allocation much more efficient; the
+// typical allocation is trivial.
+// * Completely avoids the cost of doing individual deallocation.
+// * Saves the trouble of tracking down and plugging a large class of leaks.
+//
+// Individual classes can use this allocator by supplying their own
+// new and delete methods.
+//
+// STL containers can use this allocator by using the pool_allocator
+// class as the allocator (second) template argument.
+//
+
+#include <stddef.h>
+#include <vector>
+
+// If we are using guard blocks, we must track each indivual
+// allocation. If we aren't using guard blocks, these
+// never get instantiated, so won't have any impact.
+//
+
+class TAllocation {
+public:
+ TAllocation(size_t size, unsigned char* mem, TAllocation* prev = 0) :
+ size(size), mem(mem), prevAlloc(prev) {
+ // Allocations are bracketed:
+ // [allocationHeader][initialGuardBlock][userData][finalGuardBlock]
+ // This would be cleaner with if (guardBlockSize)..., but that
+ // makes the compiler print warnings about 0 length memsets,
+ // even with the if() protecting them.
+# ifdef GUARD_BLOCKS
+ memset(preGuard(), guardBlockBeginVal, guardBlockSize);
+ memset(data(), userDataFill, size);
+ memset(postGuard(), guardBlockEndVal, guardBlockSize);
+# endif
+ }
+
+ void check() const {
+ checkGuardBlock(preGuard(), guardBlockBeginVal, "before");
+ checkGuardBlock(postGuard(), guardBlockEndVal, "after");
+ }
+
+ void checkAllocList() const;
+
+ // Return total size needed to accomodate user buffer of 'size',
+ // plus our tracking data.
+ inline static size_t allocationSize(size_t size) {
+ return size + 2 * guardBlockSize + headerSize();
+ }
+
+ // Offset from surrounding buffer to get to user data buffer.
+ inline static unsigned char* offsetAllocation(unsigned char* m) {
+ return m + guardBlockSize + headerSize();
+ }
+
+private:
+ void checkGuardBlock(unsigned char* blockMem, unsigned char val, char* locText) const;
+
+ // Find offsets to pre and post guard blocks, and user data buffer
+ unsigned char* preGuard() const { return mem + headerSize(); }
+ unsigned char* data() const { return preGuard() + guardBlockSize; }
+ unsigned char* postGuard() const { return data() + size; }
+
+ size_t size; // size of the user data area
+ unsigned char* mem; // beginning of our allocation (pts to header)
+ TAllocation* prevAlloc; // prior allocation in the chain
+
+ // Support MSVC++ 6.0
+ const static unsigned char guardBlockBeginVal;
+ const static unsigned char guardBlockEndVal;
+ const static unsigned char userDataFill;
+
+# ifdef GUARD_BLOCKS
+ const static size_t guardBlockSize;
+ inline static size_t headerSize() { return sizeof(TAllocation); }
+# else
+ const static size_t guardBlockSize;
+ inline static size_t headerSize() { return 0; }
+# endif
+};
+
+//
+// There are several stacks. One is to track the pushing and popping
+// of the user, and not yet implemented. The others are simply a
+// repositories of free pages or used pages.
+//
+// Page stacks are linked together with a simple header at the beginning
+// of each allocation obtained from the underlying OS. Multi-page allocations
+// are returned to the OS. Individual page allocations are kept for future
+// re-use.
+//
+// The "page size" used is not, nor must it match, the underlying OS
+// page size. But, having it be about that size or equal to a set of
+// pages is likely most optimal.
+//
+class TPoolAllocator {
+public:
+ TPoolAllocator(bool global = false, int growthIncrement = 8*1024, int allocationAlignment = 16);
+
+ //
+ // Don't call the destructor just to free up the memory, call pop()
+ //
+ ~TPoolAllocator();
+
+ //
+ // Call push() to establish a new place to pop memory too. Does not
+ // have to be called to get things started.
+ //
+ void push();
+
+ //
+ // Call pop() to free all memory allocated since the last call to push(),
+ // or if no last call to push, frees all memory since first allocation.
+ //
+ void pop();
+
+ //
+ // Call popAll() to free all memory allocated.
+ //
+ void popAll();
+
+ //
+ // Call allocate() to actually acquire memory. Returns 0 if no memory
+ // available, otherwise a properly aligned pointer to 'numBytes' of memory.
+ //
+ void* allocate(size_t numBytes);
+
+ //
+ // There is no deallocate. The point of this class is that
+ // deallocation can be skipped by the user of it, as the model
+ // of use is to simultaneously deallocate everything at once
+ // by calling pop(), and to not have to solve memory leak problems.
+ //
+
+protected:
+ friend struct tHeader;
+
+ struct tHeader {
+ tHeader(tHeader* nextPage, size_t pageCount) :
+#ifdef GUARD_BLOCKS
+ lastAllocation(0),
+#endif
+ nextPage(nextPage), pageCount(pageCount) { }
+
+ ~tHeader() {
+#ifdef GUARD_BLOCKS
+ if (lastAllocation)
+ lastAllocation->checkAllocList();
+#endif
+ }
+
+ tHeader* nextPage;
+ size_t pageCount;
+#ifdef GUARD_BLOCKS
+ TAllocation* lastAllocation;
+#endif
+ };
+
+ struct tAllocState {
+ size_t offset;
+ tHeader* page;
+ };
+ typedef std::vector<tAllocState> tAllocStack;
+
+ // Track allocations if and only if we're using guard blocks
+ void* initializeAllocation(tHeader* block, unsigned char* memory, size_t numBytes) {
+# ifdef GUARD_BLOCKS
+ new(memory) TAllocation(numBytes, memory, block->lastAllocation);
+ block->lastAllocation = reinterpret_cast<TAllocation*>(memory);
+# endif
+
+ // This is optimized entirely away if GUARD_BLOCKS is not defined.
+ return TAllocation::offsetAllocation(memory);
+ }
+
+ bool global; // should be true if this object is globally scoped
+ size_t pageSize; // granularity of allocation from the OS
+ size_t alignment; // all returned allocations will be aligned at
+ // this granularity, which will be a power of 2
+ size_t alignmentMask;
+ size_t headerSkip; // amount of memory to skip to make room for the
+ // header (basically, size of header, rounded
+ // up to make it aligned
+ size_t currentPageOffset; // next offset in top of inUseList to allocate from
+ tHeader* freeList; // list of popped memory
+ tHeader* inUseList; // list of all memory currently being used
+ tAllocStack stack; // stack of where to allocate from, to partition pool
+
+ int numCalls; // just an interesting statistic
+ size_t totalBytes; // just an interesting statistic
+private:
+ TPoolAllocator& operator=(const TPoolAllocator&); // dont allow assignment operator
+ TPoolAllocator(const TPoolAllocator&); // dont allow default copy constructor
+};
+
+
+//
+// There could potentially be many pools with pops happening at
+// different times. But a simple use is to have a global pop
+// with everyone using the same global allocator.
+//
+typedef TPoolAllocator* PoolAllocatorPointer;
+extern TPoolAllocator& GetGlobalPoolAllocator();
+#define GlobalPoolAllocator GetGlobalPoolAllocator()
+struct TThreadGlobalPools
+{
+ TPoolAllocator* globalPoolAllocator;
+};
+
+//
+// This STL compatible allocator is intended to be used as the allocator
+// parameter to templatized STL containers, like vector and map.
+//
+// It will use the pools for allocation, and not
+// do any deallocation, but will still do destruction.
+//
+template<class T>
+class pool_allocator {
+public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef T *pointer;
+ typedef const T *const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef T value_type;
+ template<class Other>
+ struct rebind {
+ typedef pool_allocator<Other> other;
+ };
+ pointer address(reference x) const { return &x; }
+ const_pointer address(const_reference x) const { return &x; }
+
+#ifdef USING_SGI_STL
+ pool_allocator() { }
+#else
+ pool_allocator() : allocator(GlobalPoolAllocator) { }
+ pool_allocator(TPoolAllocator& a) : allocator(a) { }
+ pool_allocator(const pool_allocator<T>& p) : allocator(p.allocator) { }
+#endif
+
+#if defined(_MSC_VER) && _MSC_VER >= 1300
+ template<class Other>
+#ifdef USING_SGI_STL
+ pool_allocator(const pool_allocator<Other>& p) /*: allocator(p.getAllocator())*/ { }
+#else
+ pool_allocator(const pool_allocator<Other>& p) : allocator(p.getAllocator()) { }
+#endif
+#endif
+
+#ifndef _WIN32
+ template<class Other>
+ pool_allocator(const pool_allocator<Other>& p) : allocator(p.getAllocator()) { }
+#endif
+
+#ifdef USING_SGI_STL
+ static pointer allocate(size_type n) {
+ return reinterpret_cast<pointer>(getAllocator().allocate(n)); }
+ pointer allocate(size_type n, const void*) {
+ return reinterpret_cast<pointer>(getAllocator().allocate(n)); }
+
+ static void deallocate(void*, size_type) { }
+ static void deallocate(pointer, size_type) { }
+#else
+ pointer allocate(size_type n) {
+ return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T))); }
+ pointer allocate(size_type n, const void*) {
+ return reinterpret_cast<pointer>(getAllocator().allocate(n * sizeof(T))); }
+
+ void deallocate(void*, size_type) { }
+ void deallocate(pointer, size_type) { }
+#endif
+
+ pointer _Charalloc(size_t n) {
+ return reinterpret_cast<pointer>(getAllocator().allocate(n)); }
+
+ void construct(pointer p, const T& val) { new ((void *)p) T(val); }
+ void destroy(pointer p) { p->T::~T(); }
+
+ bool operator==(const pool_allocator& rhs) const { return &getAllocator() == &rhs.getAllocator(); }
+ bool operator!=(const pool_allocator& rhs) const { return &getAllocator() != &rhs.getAllocator(); }
+
+ size_type max_size() const { return static_cast<size_type>(-1) / sizeof(T); }
+ size_type max_size(int size) const { return static_cast<size_type>(-1) / size; }
+
+#ifdef USING_SGI_STL
+ //void setAllocator(TPoolAllocator* a) { allocator = a; }
+ static TPoolAllocator& getAllocator() { return GlobalPoolAllocator; }
+#else
+ void setAllocator(TPoolAllocator* a) { allocator = *a; }
+ TPoolAllocator& getAllocator() const { return allocator; }
+
+protected:
+ TPoolAllocator& allocator;
+#endif
+};
+
+#endif // _POOLALLOC_INCLUDED_
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/ResourceLimits.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/ResourceLimits.h
new file mode 100755
index 000000000..ef24244c2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/ResourceLimits.h
@@ -0,0 +1,61 @@
+/*
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#ifndef _RESOURCE_LIMITS_INCLUDED_
+#define _RESOURCE_LIMITS_INCLUDED_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct TBuiltInResource_ {
+ int maxLights;
+ int maxClipPlanes;
+ int maxTextureUnits;
+ int maxTextureCoords;
+ int maxVertexAttribs;
+ int maxVertexUniformComponents;
+ int maxVaryingFloats;
+ int maxVertexTextureImageUnits;
+ int maxCombinedTextureImageUnits;
+ int maxTextureImageUnits;
+ int maxFragmentUniformComponents;
+ int maxDrawBuffers;
+} TBuiltInResource;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _RESOURCE_LIMITS_INCLUDED_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/ShHandle.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/ShHandle.h
new file mode 100755
index 000000000..82c0314f3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/ShHandle.h
@@ -0,0 +1,177 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#ifndef _SHHANDLE_INCLUDED_
+#define _SHHANDLE_INCLUDED_
+
+//
+// Machine independent part of the compiler private objects
+// sent as ShHandle to the driver.
+//
+// This should not be included by driver code.
+//
+
+#define SH_EXPORTING
+#include "../Public/ShaderLangExt.h"
+#include "InfoSink.h"
+
+class TCompiler;
+class TLinker;
+class TUniformMap;
+namespace Lf {
+ class TBindingList;
+ class TLinker;
+ class TLibrary;
+}
+
+//
+// The base class used to back handles returned to the driver.
+//
+class TShHandleBase {
+public:
+ TShHandleBase() { }
+ virtual ~TShHandleBase() { }
+ virtual TCompiler* getAsCompiler() { return 0; }
+ virtual TLinker* getAsLinker() { return 0; }
+ virtual Lf::TLinker* getAsNewLinker() { return 0; }
+ virtual TUniformMap* getAsUniformMap() { return 0; }
+ virtual Lf::TBindingList* getAsBindingList() { return 0; }
+ virtual Lf::TLibrary* getAsLibrary() { return 0; }
+};
+//
+// The base class for the machine dependent linker to derive from
+// for managing where uniforms live.
+//
+class TUniformMap : public TShHandleBase {
+public:
+ TUniformMap() { }
+ virtual ~TUniformMap() { }
+ virtual TUniformMap* getAsUniformMap() { return this; }
+ virtual int getLocation(const char* name) = 0;
+ virtual TInfoSink& getInfoSink() { return infoSink; }
+ TInfoSink infoSink;
+};
+
+class TIntermNode;
+
+//
+// The base class for the machine dependent compiler to derive from
+// for managing object code from the compile.
+//
+class TCompiler : public TShHandleBase {
+public:
+ TCompiler(EShLanguage l, TInfoSink& sink) : infoSink(sink) , language(l), haveValidObjectCode(false) { }
+ virtual ~TCompiler() { }
+ EShLanguage getLanguage() { return language; }
+ virtual TInfoSink& getInfoSink() { return infoSink; }
+
+ virtual bool compile(TIntermNode* root) = 0;
+
+ virtual TCompiler* getAsCompiler() { return this; }
+ virtual bool linkable() { return haveValidObjectCode; }
+
+ TInfoSink& infoSink;
+protected:
+ EShLanguage language;
+ bool haveValidObjectCode;
+};
+
+//
+// Link operations are base on a list of compile results...
+//
+typedef TVector<TCompiler*> TCompilerList;
+typedef TVector<TShHandleBase*> THandleList;
+
+//
+// The base class for the machine dependent linker to derive from
+// to manage the resulting executable.
+//
+
+class TLinker : public TShHandleBase {
+public:
+ TLinker(EShExecutable e, TInfoSink& iSink) :
+ infoSink(iSink),
+ executable(e),
+ haveReturnableObjectCode(false),
+ appAttributeBindings(0),
+ fixedAttributeBindings(0),
+ excludedAttributes(0),
+ excludedCount(0),
+ uniformBindings(0) { }
+ virtual TLinker* getAsLinker() { return this; }
+ virtual ~TLinker() { }
+ virtual bool link(TCompilerList&, TUniformMap*) = 0;
+ virtual bool link(THandleList&) { return false; }
+ virtual void setAppAttributeBindings(const ShBindingTable* t) { appAttributeBindings = t; }
+ virtual void setFixedAttributeBindings(const ShBindingTable* t) { fixedAttributeBindings = t; }
+ virtual void getAttributeBindings(ShBindingTable const **t) const = 0;
+ virtual void setExcludedAttributes(const int* attributes, int count) { excludedAttributes = attributes; excludedCount = count; }
+ virtual ShBindingTable* getUniformBindings() const { return uniformBindings; }
+ virtual const void* getObjectCode() const { return 0; } // a real compiler would be returning object code here
+ virtual TInfoSink& getInfoSink() { return infoSink; }
+ TInfoSink& infoSink;
+protected:
+ EShExecutable executable;
+ bool haveReturnableObjectCode; // true when objectCode is acceptable to send to driver
+
+ const ShBindingTable* appAttributeBindings;
+ const ShBindingTable* fixedAttributeBindings;
+ const int* excludedAttributes;
+ int excludedCount;
+ ShBindingTable* uniformBindings; // created by the linker
+};
+
+//
+// This is the interface between the machine independent code
+// and the machine dependent code.
+//
+// The machine dependent code should derive from the classes
+// above. Then Construct*() and Delete*() will create and
+// destroy the machine dependent objects, which contain the
+// above machine independent information.
+//
+TCompiler* ConstructCompiler(EShLanguage, int);
+
+TShHandleBase* ConstructLinker(EShExecutable, int);
+TShHandleBase* ConstructBindings();
+TShHandleBase* ConstructLibrary();
+void DeleteLinker(TShHandleBase*);
+
+TUniformMap* ConstructUniformMap();
+void DeleteCompiler(TCompiler*);
+
+void DeleteUniformMap(TUniformMap*);
+void freeTargetDependentData(void*);
+
+#endif // _SHHANDLE_INCLUDED_
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/Types.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/Types.h
new file mode 100755
index 000000000..9415879af
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/Types.h
@@ -0,0 +1,297 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#ifndef _TYPES_INCLUDED
+#define _TYPES_INCLUDED
+
+#include "../Include/Common.h"
+#include "../Include/BaseTypes.h"
+
+//
+// Need to have association of line numbers to types in a list for building structs.
+//
+class TType;
+struct TTypeLine {
+ TType* type;
+ int line;
+};
+typedef TVector<TTypeLine> TTypeList;
+
+inline TTypeList* NewPoolTTypeList()
+{
+ void* memory = GlobalPoolAllocator.allocate(sizeof(TTypeList));
+ return new(memory) TTypeList;
+}
+
+//
+// This is a workaround for a problem with the yacc stack, It can't have
+// types that the compiler thinks non-trivial constructors. It should
+// just be used while recognizing the grammar, not anything else. Pointers
+// could be used, but also trying to avoid lots of memory management overhead.
+//
+// Not as bad as it looks, there is no actual assumption that the fields
+// match up or are name the same or anything like that.
+//
+class TPublicType {
+public:
+ TBasicType type;
+ TQualifier qualifier;
+ int size; // size of vector or matrix, not size of array
+ bool matrix;
+ bool array;
+ TType* userDef;
+ int line;
+};
+
+typedef std::map<TTypeList*, TTypeList*> TStructureMap;
+typedef std::map<TTypeList*, TTypeList*>::iterator TStructureMapIterator;
+//
+// Base class for things that have a type.
+//
+class TType {
+public:
+ POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
+ explicit TType(TBasicType t, TQualifier q = EvqTemporary, int s = 1, bool m = false, bool a = false) :
+ type(t), qualifier(q), size(s), matrix(m), array(a), arraySize(0), structure(0),
+ structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), typeName(0), mangled(0)
+ { }
+ explicit TType(TPublicType p) :
+ type(p.type), qualifier(p.qualifier), size(p.size), matrix(p.matrix), array(p.array), arraySize(0),
+ structure(0), structureSize(0), maxArraySize(0), arrayInformationType(0), fieldName(0), typeName(0), mangled(0)
+ {
+ if (p.userDef) {
+ structure = p.userDef->getStruct();
+ structureSize = setStructSize(p.userDef->getStruct());
+ typeName = NewPoolTString(p.userDef->getTypeName().c_str());
+ }
+ }
+ explicit TType(TTypeList* userDef, TString n) :
+ type(EbtStruct), qualifier(EvqTemporary), size(1), matrix(false), array(false), arraySize(0),
+ structure(userDef), maxArraySize(0), arrayInformationType(0), fieldName(0), mangled(0) {
+ structureSize = setStructSize(userDef);
+ typeName = NewPoolTString(n.c_str());
+ }
+ explicit TType() {}
+ virtual ~TType() {}
+
+ TType (const TType& type) { *this = type; }
+
+ void copyType(const TType& copyOf, TStructureMap& remapper)
+ {
+ type = copyOf.type;
+ qualifier = copyOf.qualifier;
+ size = copyOf.size;
+ matrix = copyOf.matrix;
+ array = copyOf.array;
+ arraySize = copyOf.arraySize;
+
+ TStructureMapIterator iter;
+ if (copyOf.structure) {
+ if ((iter = remapper.find(structure)) == remapper.end()) {
+ // create the new structure here
+ structure = NewPoolTTypeList();
+ for (unsigned int i = 0; i < copyOf.structure->size(); ++i) {
+ TTypeLine typeLine;
+ typeLine.line = (*copyOf.structure)[i].line;
+ typeLine.type = (*copyOf.structure)[i].type->clone(remapper);
+ structure->push_back(typeLine);
+ }
+ } else {
+ structure = iter->second;
+ }
+ } else
+ structure = 0;
+
+ fieldName = 0;
+ if (copyOf.fieldName)
+ fieldName = NewPoolTString(copyOf.fieldName->c_str());
+ typeName = 0;
+ if (copyOf.typeName)
+ typeName = NewPoolTString(copyOf.typeName->c_str());
+
+ mangled = 0;
+ if (copyOf.mangled)
+ mangled = NewPoolTString(copyOf.mangled->c_str());
+
+ structureSize = copyOf.structureSize;
+ maxArraySize = copyOf.maxArraySize;
+ assert (copyOf.arrayInformationType == 0);
+ arrayInformationType = 0; // arrayInformationType should not be set for builtIn symbol table level
+ }
+
+ TType* clone(TStructureMap& remapper)
+ {
+ TType *newType = new TType();
+ newType->copyType(*this, remapper);
+
+ return newType;
+ }
+
+ int setStructSize(TTypeList* userDef)
+ {
+ int stSize = 0;
+ for (TTypeList::iterator tl = userDef->begin(); tl != userDef->end(); tl++) {
+ if (((*tl).type)->isArray()) {
+ if (((*tl).type)->getStruct()) {
+ int structSize = setStructSize(((*tl).type)->getStruct());
+ stSize += structSize * ((*tl).type)->getArraySize();
+ } else {
+ stSize += ((*tl).type)->getInstanceSize() * ((*tl).type)->getArraySize();
+ }
+ } else if (((*tl).type)->isMatrix() || ((*tl).type)->isVector()){
+ stSize += ((*tl).type)->getInstanceSize();
+ } else if (((*tl).type)->getStruct()) {
+ //?? We should actually be calling getStructSize() function and not setStructSize. This problem occurs in case
+ // of nested/embedded structs.
+ stSize += setStructSize(((*tl).type)->getStruct());
+ } else
+ stSize += 1;
+ }
+ structureSize = stSize;
+ return stSize;
+ }
+
+ virtual void setType(TBasicType t, int s, bool m, bool a, int aS = 0)
+ { type = t; size = s; matrix = m; array = a; arraySize = aS; }
+ virtual void setType(TBasicType t, int s, bool m, TType* userDef = 0)
+ { type = t;
+ size = s;
+ matrix = m;
+ if (userDef)
+ structure = userDef->getStruct();
+ // leave array information intact.
+ }
+ virtual void setTypeName(const TString& n) { typeName = NewPoolTString(n.c_str()); }
+ virtual void setFieldName(const TString& n) { fieldName = NewPoolTString(n.c_str()); }
+ virtual const TString& getTypeName() const
+ {
+ assert (typeName);
+ return *typeName;
+ }
+
+ virtual const TString& getFieldName() const
+ {
+ assert (fieldName);
+ return *fieldName;
+ }
+
+ virtual TBasicType getBasicType() const { return type; }
+ virtual TQualifier getQualifier() const { return qualifier; }
+ virtual void changeQualifier(TQualifier q) { qualifier = q; }
+
+ // One-dimensional size of single instance type
+ virtual int getNominalSize() const { return size; }
+
+ // Full-dimensional size of single instance of type
+ virtual int getInstanceSize() const
+ {
+ if (matrix)
+ return size * size;
+ else
+ return size;
+ }
+
+ virtual bool isMatrix() const { return matrix ? true : false; }
+ virtual bool isArray() const { return array ? true : false; }
+ int getArraySize() const { return arraySize; }
+ void setArraySize(int s) { array = true; arraySize = s; }
+ void setMaxArraySize (int s) { maxArraySize = s; }
+ int getMaxArraySize () const { return maxArraySize; }
+ void setArrayInformationType(TType* t) { arrayInformationType = t; }
+ TType* getArrayInformationType() { return arrayInformationType; }
+ virtual bool isVector() const { return size > 1 && !matrix; }
+ static char* getBasicString(TBasicType t) {
+ switch (t) {
+ case EbtVoid: return "void"; break;
+ case EbtFloat: return "float"; break;
+ case EbtInt: return "int"; break;
+ case EbtBool: return "bool"; break;
+ case EbtSampler1D: return "sampler1D"; break;
+ case EbtSampler2D: return "sampler2D"; break;
+ case EbtSampler3D: return "sampler3D"; break;
+ case EbtSamplerCube: return "samplerCube"; break;
+ case EbtSampler1DShadow: return "sampler1DShadow"; break;
+ case EbtSampler2DShadow: return "sampler2DShadow"; break;
+ case EbtStruct: return "structure"; break;
+ default: return "unknown type";
+ }
+ }
+ const char* getBasicString() const { return TType::getBasicString(type); }
+ const char* getQualifierString() const { return ::getQualifierString(qualifier); }
+ TTypeList* getStruct() { return structure; }
+ int getStructSize() const { return structureSize; }
+ TTypeList* getStruct() const { return structure; }
+ TString& getMangledName() {
+ if (!mangled) {
+ mangled = NewPoolTString("");
+ buildMangledName(*mangled);
+ *mangled+=';';
+ }
+
+ return *mangled;
+ }
+ bool operator==(const TType& right) const {
+ return type == right.type &&
+ size == right.size &&
+ matrix == right.matrix &&
+ array == right.array &&
+ structure == right.structure;
+ // don't check the qualifier, it's not ever what's being sought after
+ }
+ bool operator!=(const TType& right) const {
+ return !operator==(right);
+ }
+ TString getCompleteString() const;
+
+protected:
+ void buildMangledName(TString&);
+
+ TBasicType type : 6;
+ TQualifier qualifier : 7;
+ int size : 8; // size of vector or matrix, not size of array
+ unsigned int matrix : 1;
+ unsigned int array : 1;
+
+ int arraySize;
+ TTypeList* structure; // 0 unless this is a struct
+ int structureSize;
+ int maxArraySize;
+ TType* arrayInformationType;
+ TString *fieldName; // for structure field names
+ TString *typeName; // for structure field type name
+ TString *mangled;
+
+};
+
+#endif // _TYPES_INCLUDED_
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/intermediate.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/intermediate.h
new file mode 100755
index 000000000..13e22c274
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/Include/intermediate.h
@@ -0,0 +1,516 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+//
+// Definition of the in-memory high-level intermediate representation
+// of shaders. This is a tree that parser creates.
+//
+// Nodes in the tree are defined as a hierarchy of classes derived from
+// TIntermNode. Each is a node in a tree. There is no preset branching factor;
+// each node can have it's own type of list of children.
+//
+
+#ifndef __INTERMEDIATE_H
+#define __INTERMEDIATE_H
+
+#include "../Include/Common.h"
+#include "../Include/Types.h"
+#include "../Include/ConstantUnion.h"
+
+//
+// Operators used by the high-level (parse tree) representation.
+//
+enum TOperator {
+ EOpNull, // if in a node, should only mean a node is still being built
+ EOpSequence, // denotes a list of statements, or parameters, etc.
+ EOpFunctionCall,
+ EOpFunction, // For function definition
+ EOpParameters, // an aggregate listing the parameters to a function
+
+ //
+ // Unary operators
+ //
+
+ EOpNegative,
+ EOpLogicalNot,
+ EOpVectorLogicalNot,
+ EOpBitwiseNot,
+
+ EOpPostIncrement,
+ EOpPostDecrement,
+ EOpPreIncrement,
+ EOpPreDecrement,
+
+ EOpConvIntToBool,
+ EOpConvFloatToBool,
+ EOpConvBoolToFloat,
+ EOpConvIntToFloat,
+ EOpConvFloatToInt,
+ EOpConvBoolToInt,
+
+ //
+ // binary operations
+ //
+
+ EOpAdd,
+ EOpSub,
+ EOpMul,
+ EOpDiv,
+ EOpMod,
+ EOpRightShift,
+ EOpLeftShift,
+ EOpAnd,
+ EOpInclusiveOr,
+ EOpExclusiveOr,
+ EOpEqual,
+ EOpNotEqual,
+ EOpVectorEqual,
+ EOpVectorNotEqual,
+ EOpLessThan,
+ EOpGreaterThan,
+ EOpLessThanEqual,
+ EOpGreaterThanEqual,
+ EOpComma,
+
+ EOpVectorTimesScalar,
+ EOpVectorTimesMatrix,
+ EOpMatrixTimesVector,
+ EOpMatrixTimesScalar,
+
+ EOpLogicalOr,
+ EOpLogicalXor,
+ EOpLogicalAnd,
+
+ EOpIndexDirect,
+ EOpIndexIndirect,
+ EOpIndexDirectStruct,
+
+ EOpVectorSwizzle,
+
+ //
+ // Built-in functions potentially mapped to operators
+ //
+
+ EOpRadians,
+ EOpDegrees,
+ EOpSin,
+ EOpCos,
+ EOpTan,
+ EOpAsin,
+ EOpAcos,
+ EOpAtan,
+
+ EOpPow,
+ EOpExp,
+ EOpLog,
+ EOpExp2,
+ EOpLog2,
+ EOpSqrt,
+ EOpInverseSqrt,
+
+ EOpAbs,
+ EOpSign,
+ EOpFloor,
+ EOpCeil,
+ EOpFract,
+ EOpMin,
+ EOpMax,
+ EOpClamp,
+ EOpMix,
+ EOpStep,
+ EOpSmoothStep,
+
+ EOpLength,
+ EOpDistance,
+ EOpDot,
+ EOpCross,
+ EOpNormalize,
+ EOpFaceForward,
+ EOpReflect,
+ EOpRefract,
+
+ EOpDPdx, // Fragment only
+ EOpDPdy, // Fragment only
+ EOpFwidth, // Fragment only
+
+ EOpMatrixTimesMatrix,
+
+ EOpAny,
+ EOpAll,
+
+ EOpItof, // pack/unpack only
+ EOpFtoi, // pack/unpack only
+ EOpSkipPixels, // pack/unpack only
+ EOpReadInput, // unpack only
+ EOpWritePixel, // unpack only
+ EOpBitmapLsb, // unpack only
+ EOpBitmapMsb, // unpack only
+ EOpWriteOutput, // pack only
+ EOpReadPixel, // pack only
+
+ //
+ // Branch
+ //
+
+ EOpKill, // Fragment only
+ EOpReturn,
+ EOpBreak,
+ EOpContinue,
+
+ //
+ // Constructors
+ //
+
+ EOpConstructInt,
+ EOpConstructBool,
+ EOpConstructFloat,
+ EOpConstructVec2,
+ EOpConstructVec3,
+ EOpConstructVec4,
+ EOpConstructBVec2,
+ EOpConstructBVec3,
+ EOpConstructBVec4,
+ EOpConstructIVec2,
+ EOpConstructIVec3,
+ EOpConstructIVec4,
+ EOpConstructMat2,
+ EOpConstructMat3,
+ EOpConstructMat4,
+ EOpConstructStruct,
+
+ //
+ // moves
+ //
+
+ EOpAssign,
+ EOpAddAssign,
+ EOpSubAssign,
+ EOpMulAssign,
+ EOpVectorTimesMatrixAssign,
+ EOpVectorTimesScalarAssign,
+ EOpMatrixTimesScalarAssign,
+ EOpMatrixTimesMatrixAssign,
+ EOpDivAssign,
+ EOpModAssign,
+ EOpAndAssign,
+ EOpInclusiveOrAssign,
+ EOpExclusiveOrAssign,
+ EOpLeftShiftAssign,
+ EOpRightShiftAssign
+};
+
+class TIntermTraverser;
+class TIntermAggregate;
+class TIntermBinary;
+class TIntermConstantUnion;
+class TIntermSelection;
+class TIntermTyped;
+class TIntermSymbol;
+class TInfoSink;
+
+//
+// Base class for the tree nodes
+//
+class TIntermNode {
+public:
+ POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
+
+ TIntermNode() : line(0) {}
+ virtual TSourceLoc getLine() const { return line; }
+ virtual void setLine(TSourceLoc l) { line = l; }
+ virtual void traverse(TIntermTraverser*) = 0;
+ virtual TIntermTyped* getAsTyped() { return 0; }
+ virtual TIntermConstantUnion* getAsConstantUnion() { return 0; }
+ virtual TIntermAggregate* getAsAggregate() { return 0; }
+ virtual TIntermBinary* getAsBinaryNode() { return 0; }
+ virtual TIntermSelection* getAsSelectionNode() { return 0; }
+ virtual TIntermSymbol* getAsSymbolNode() { return 0; }
+ virtual ~TIntermNode() { }
+protected:
+ TSourceLoc line;
+};
+
+//
+// This is just to help yacc.
+//
+struct TIntermNodePair {
+ TIntermNode* node1;
+ TIntermNode* node2;
+};
+
+class TIntermSymbol;
+class TIntermBinary;
+
+//
+// Intermediate class for nodes that have a type.
+//
+class TIntermTyped : public TIntermNode {
+public:
+ TIntermTyped(const TType& t) : type(t) { }
+ virtual TIntermTyped* getAsTyped() { return this; }
+ virtual void setType(const TType& t) { type = t; }
+ virtual TType getType() const { return type; }
+ virtual TType* getTypePointer() { return &type; }
+
+ virtual TBasicType getBasicType() const { return type.getBasicType(); }
+ virtual TQualifier getQualifier() const { return type.getQualifier(); }
+ virtual int getNominalSize() const { return type.getNominalSize(); }
+ virtual int getSize() const { return type.getInstanceSize(); }
+ virtual bool isMatrix() const { return type.isMatrix(); }
+ virtual bool isArray() const { return type.isArray(); }
+ virtual bool isVector() const { return type.isVector(); }
+ const char* getBasicString() const { return type.getBasicString(); }
+ const char* getQualifierString() const { return type.getQualifierString(); }
+ TString getCompleteString() const { return type.getCompleteString(); }
+
+protected:
+ TType type;
+};
+
+//
+// Handle for, do-while, and while loops.
+//
+class TIntermLoop : public TIntermNode {
+public:
+ TIntermLoop(TIntermNode* aBody, TIntermTyped* aTest, TIntermTyped* aTerminal, bool testFirst) :
+ body(aBody),
+ test(aTest),
+ terminal(aTerminal),
+ first(testFirst) { }
+ virtual void traverse(TIntermTraverser*);
+ TIntermNode* getBody() { return body; }
+ TIntermTyped* getTest() { return test; }
+ TIntermTyped* getTerminal() { return terminal; }
+ bool testFirst() { return first; }
+protected:
+ TIntermNode* body; // code to loop over
+ TIntermTyped* test; // exit condition associated with loop, could be 0 for 'for' loops
+ TIntermTyped* terminal; // exists for for-loops
+ bool first; // true for while and for, not for do-while
+};
+
+//
+// Handle break, continue, return, and kill.
+//
+class TIntermBranch : public TIntermNode {
+public:
+ TIntermBranch(TOperator op, TIntermTyped* e) :
+ flowOp(op),
+ expression(e) { }
+ virtual void traverse(TIntermTraverser*);
+ TOperator getFlowOp() { return flowOp; }
+ TIntermTyped* getExpression() { return expression; }
+protected:
+ TOperator flowOp;
+ TIntermTyped* expression; // non-zero except for "return exp;" statements
+};
+
+//
+// Nodes that correspond to symbols or constants in the source code.
+//
+class TIntermSymbol : public TIntermTyped {
+public:
+ // if symbol is initialized as symbol(sym), the memory comes from the poolallocator of sym. If sym comes from
+ // per process globalpoolallocator, then it causes increased memory usage per compile
+ // it is essential to use "symbol = sym" to assign to symbol
+ TIntermSymbol(int i, const TString& sym, const TType& t) :
+ TIntermTyped(t), id(i) { symbol = sym;}
+ virtual int getId() const { return id; }
+ virtual const TString& getSymbol() const { return symbol; }
+ virtual void traverse(TIntermTraverser*);
+ virtual TIntermSymbol* getAsSymbolNode() { return this; }
+protected:
+ int id;
+ TString symbol;
+};
+
+class TIntermConstantUnion : public TIntermTyped {
+public:
+ TIntermConstantUnion(constUnion *unionPointer, const TType& t) : TIntermTyped(t), unionArrayPointer(unionPointer) { }
+ constUnion* getUnionArrayPointer() const { return unionArrayPointer; }
+ void setUnionArrayPointer(constUnion *c) { unionArrayPointer = c; }
+ virtual TIntermConstantUnion* getAsConstantUnion() { return this; }
+ virtual void traverse(TIntermTraverser* );
+ virtual TIntermTyped* fold(TOperator, TIntermTyped*, TInfoSink&, bool);
+protected:
+ constUnion *unionArrayPointer;
+};
+
+//
+// Intermediate class for node types that hold operators.
+//
+class TIntermOperator : public TIntermTyped {
+public:
+ TOperator getOp() { return op; }
+ bool modifiesState() const;
+ bool isConstructor() const;
+ virtual bool promote(TInfoSink&) { return true; }
+protected:
+ TIntermOperator(TOperator o) : TIntermTyped(TType(EbtFloat)), op(o) {}
+ TIntermOperator(TOperator o, TType& t) : TIntermTyped(t), op(o) {}
+ TOperator op;
+};
+
+//
+// Nodes for all the basic binary math operators.
+//
+class TIntermBinary : public TIntermOperator {
+public:
+ TIntermBinary(TOperator o) : TIntermOperator(o) {}
+ virtual void traverse(TIntermTraverser*);
+ virtual void setLeft(TIntermTyped* n) { left = n; }
+ virtual void setRight(TIntermTyped* n) { right = n; }
+ virtual TIntermTyped* getLeft() const { return left; }
+ virtual TIntermTyped* getRight() const { return right; }
+ virtual TIntermBinary* getAsBinaryNode() { return this; }
+ virtual bool promote(TInfoSink&);
+protected:
+ TIntermTyped* left;
+ TIntermTyped* right;
+};
+
+//
+// Nodes for unary math operators.
+//
+class TIntermUnary : public TIntermOperator {
+public:
+ TIntermUnary(TOperator o, TType& t) : TIntermOperator(o, t), operand(0) {}
+ TIntermUnary(TOperator o) : TIntermOperator(o), operand(0) {}
+ virtual void traverse(TIntermTraverser*);
+ virtual void setOperand(TIntermTyped* o) { operand = o; }
+ virtual TIntermTyped* getOperand() { return operand; }
+ virtual bool promote(TInfoSink&);
+protected:
+ TIntermTyped* operand;
+};
+
+typedef TVector<TIntermNode*> TIntermSequence;
+typedef TVector<int> TQualifierList;
+//
+// Nodes that operate on an arbitrary sized set of children.
+//
+class TIntermAggregate : public TIntermOperator {
+public:
+ TIntermAggregate() : TIntermOperator(EOpNull), userDefined(false), pragmaTable(0) { }
+ TIntermAggregate(TOperator o) : TIntermOperator(o), pragmaTable(0) { }
+ ~TIntermAggregate() { delete pragmaTable; }
+ virtual TIntermAggregate* getAsAggregate() { return this; }
+ virtual void setOperator(TOperator o) { op = o; }
+ virtual TIntermSequence& getSequence() { return sequence; }
+ virtual void setName(const TString& n) { name = n; }
+ virtual const TString& getName() const { return name; }
+ virtual void traverse(TIntermTraverser*);
+ virtual void setUserDefined() { userDefined = true; }
+ virtual bool isUserDefined() { return userDefined; }
+ virtual TQualifierList& getQualifier() { return qualifier; }
+ void setOptimize(bool o) { optimize = o; }
+ void setDebug(bool d) { debug = d; }
+ bool getOptimize() { return optimize; }
+ bool getDebug() { return debug; }
+ void addToPragmaTable(const TPragmaTable& pTable);
+ const TPragmaTable& getPragmaTable() const { return *pragmaTable; }
+protected:
+ TIntermAggregate(const TIntermAggregate&); // disallow copy constructor
+ TIntermAggregate& operator=(const TIntermAggregate&); // disallow assignment operator
+ TIntermSequence sequence;
+ TQualifierList qualifier;
+ TString name;
+ bool userDefined; // used for user defined function names
+ bool optimize;
+ bool debug;
+ TPragmaTable *pragmaTable;
+};
+
+//
+// For if tests. Simplified since there is no switch statement.
+//
+class TIntermSelection : public TIntermTyped {
+public:
+ TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB) :
+ TIntermTyped(TType(EbtVoid)), condition(cond), trueBlock(trueB), falseBlock(falseB) {}
+ TIntermSelection(TIntermTyped* cond, TIntermNode* trueB, TIntermNode* falseB, const TType& type) :
+ TIntermTyped(type), condition(cond), trueBlock(trueB), falseBlock(falseB) {}
+ virtual void traverse(TIntermTraverser*);
+ virtual TIntermNode* getCondition() const { return condition; }
+ virtual TIntermNode* getTrueBlock() const { return trueBlock; }
+ virtual TIntermNode* getFalseBlock() const { return falseBlock; }
+ virtual TIntermSelection* getAsSelectionNode() { return this; }
+protected:
+ TIntermTyped* condition;
+ TIntermNode* trueBlock;
+ TIntermNode* falseBlock;
+};
+
+//
+// For traversing the tree. User should derive from this,
+// put their traversal specific data in it, and then pass
+// it to a Traverse method.
+//
+// When using this, just fill in the methods for nodes you want visited.
+// Return false from a pre-visit to skip visiting that node's subtree.
+//
+class TIntermTraverser {
+public:
+ POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
+
+ TIntermTraverser() :
+ visitSymbol(0),
+ visitConstantUnion(0),
+ visitBinary(0),
+ visitUnary(0),
+ visitSelection(0),
+ visitAggregate(0),
+ visitLoop(0),
+ visitBranch(0),
+ depth(0),
+ preVisit(true),
+ postVisit(false),
+ rightToLeft(false) {}
+
+ void (*visitSymbol)(TIntermSymbol*, TIntermTraverser*);
+ void (*visitConstantUnion)(TIntermConstantUnion*, TIntermTraverser*);
+ bool (*visitBinary)(bool preVisit, TIntermBinary*, TIntermTraverser*);
+ bool (*visitUnary)(bool preVisit, TIntermUnary*, TIntermTraverser*);
+ bool (*visitSelection)(bool preVisit, TIntermSelection*, TIntermTraverser*);
+ bool (*visitAggregate)(bool preVisit, TIntermAggregate*, TIntermTraverser*);
+ bool (*visitLoop)(bool preVisit, TIntermLoop*, TIntermTraverser*);
+ bool (*visitBranch)(bool preVisit, TIntermBranch*, TIntermTraverser*);
+
+ int depth;
+ bool preVisit;
+ bool postVisit;
+ bool rightToLeft;
+};
+
+#endif // __INTERMEDIATE_H
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Gen_glslang.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Gen_glslang.cpp
new file mode 100755
index 000000000..3b741048d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Gen_glslang.cpp
@@ -0,0 +1,2942 @@
+#line 2 "Gen_glslang.cpp"
+/* A lexical scanner generated by flex */
+
+/* Scanner skeleton version:
+ * $Header: /cvs/xorg/xc/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Gen_glslang.cpp,v 1.1.1.1 2005/07/31 16:46:33 ajax Exp $
+ */
+
+#define FLEX_SCANNER
+#define YY_FLEX_MAJOR_VERSION 2
+#define YY_FLEX_MINOR_VERSION 5
+
+#include <stdio.h>
+#include <unistd.h>
+
+
+/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
+#ifdef c_plusplus
+#ifndef __cplusplus
+#define __cplusplus
+#endif
+#endif
+
+
+#ifdef __cplusplus
+
+#include <stdlib.h>
+
+/* Use prototypes in function declarations. */
+#define YY_USE_PROTOS
+
+/* The "const" storage-class-modifier is valid. */
+#define YY_USE_CONST
+
+#else /* ! __cplusplus */
+
+#if __STDC__
+
+#define YY_USE_PROTOS
+#define YY_USE_CONST
+
+#endif /* __STDC__ */
+#endif /* ! __cplusplus */
+
+#ifdef __TURBOC__
+ #pragma warn -rch
+ #pragma warn -use
+#include <io.h>
+#include <stdlib.h>
+#define YY_USE_CONST
+#define YY_USE_PROTOS
+#endif
+
+#ifdef YY_USE_CONST
+#define yyconst const
+#else
+#define yyconst
+#endif
+
+
+#ifdef YY_USE_PROTOS
+#define YY_PROTO(proto) proto
+#else
+#define YY_PROTO(proto) ()
+#endif
+
+/* Returned upon end-of-file. */
+#define YY_NULL 0
+
+/* Promotes a possibly negative, possibly signed char to an unsigned
+ * integer for use as an array index. If the signed char is negative,
+ * we want to instead treat it as an 8-bit unsigned char, hence the
+ * double cast.
+ */
+#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+
+/* Enter a start condition. This macro really ought to take a parameter,
+ * but we do it the disgusting crufty way forced on us by the ()-less
+ * definition of BEGIN.
+ */
+#define BEGIN yy_start = 1 + 2 *
+
+/* Translate the current start state into a value that can be later handed
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
+ * compatibility.
+ */
+#define YY_START ((yy_start - 1) / 2)
+#define YYSTATE YY_START
+
+/* Action number for EOF rule of a given start state. */
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+
+/* Special action meaning "start processing a new file". */
+#define YY_NEW_FILE yyrestart( yyin )
+
+#define YY_END_OF_BUFFER_CHAR 0
+
+/* Size of default input buffer. */
+#define YY_BUF_SIZE 16384
+
+typedef struct yy_buffer_state *YY_BUFFER_STATE;
+
+extern int yyleng;
+extern FILE *yyin, *yyout;
+
+#define EOB_ACT_CONTINUE_SCAN 0
+#define EOB_ACT_END_OF_FILE 1
+#define EOB_ACT_LAST_MATCH 2
+
+/* The funky do-while in the following #define is used to turn the definition
+ * int a single C statement (which needs a semi-colon terminator). This
+ * avoids problems with code like:
+ *
+ * if ( condition_holds )
+ * yyless( 5 );
+ * else
+ * do_something_else();
+ *
+ * Prior to using the do-while the compiler would get upset at the
+ * "else" because it interpreted the "if" statement as being all
+ * done when it reached the ';' after the yyless() call.
+ */
+
+/* Return all but the first 'n' matched characters back to the input stream. */
+
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ *yy_cp = yy_hold_char; \
+ YY_RESTORE_YY_MORE_OFFSET \
+ yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
+ YY_DO_BEFORE_ACTION; /* set up yytext again */ \
+ } \
+ while ( 0 )
+
+#define unput(c) yyunput( c, yytext_ptr )
+
+/* The following is because we cannot portably get our hands on size_t
+ * (without autoconf's help, which isn't available because we want
+ * flex-generated scanners to compile on their own).
+ */
+typedef unsigned int yy_size_t;
+
+
+struct yy_buffer_state
+ {
+ FILE *yy_input_file;
+
+ char *yy_ch_buf; /* input buffer */
+ char *yy_buf_pos; /* current position in input buffer */
+
+ /* Size of input buffer in bytes, not including room for EOB
+ * characters.
+ */
+ yy_size_t yy_buf_size;
+
+ /* Number of characters read into yy_ch_buf, not including EOB
+ * characters.
+ */
+ int yy_n_chars;
+
+ /* Whether we "own" the buffer - i.e., we know we created it,
+ * and can realloc() it to grow it, and should free() it to
+ * delete it.
+ */
+ int yy_is_our_buffer;
+
+ /* Whether this is an "interactive" input source; if so, and
+ * if we're using stdio for input, then we want to use getc()
+ * instead of fread(), to make sure we stop fetching input after
+ * each newline.
+ */
+ int yy_is_interactive;
+
+ /* Whether we're considered to be at the beginning of a line.
+ * If so, '^' rules will be active on the next match, otherwise
+ * not.
+ */
+ int yy_at_bol;
+
+ /* Whether to try to fill the input buffer when we reach the
+ * end of it.
+ */
+ int yy_fill_buffer;
+
+ int yy_buffer_status;
+#define YY_BUFFER_NEW 0
+#define YY_BUFFER_NORMAL 1
+ /* When an EOF's been seen but there's still some text to process
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
+ * shouldn't try reading from the input source any more. We might
+ * still have a bunch of tokens to match, though, because of
+ * possible backing-up.
+ *
+ * When we actually see the EOF, we change the status to "new"
+ * (via yyrestart()), so that the user can continue scanning by
+ * just pointing yyin at a new input file.
+ */
+#define YY_BUFFER_EOF_PENDING 2
+ };
+
+static YY_BUFFER_STATE yy_current_buffer = 0;
+
+/* We provide macros for accessing buffer states in case in the
+ * future we want to put the buffer states in a more general
+ * "scanner state".
+ */
+#define YY_CURRENT_BUFFER yy_current_buffer
+
+
+/* yy_hold_char holds the character lost when yytext is formed. */
+static char yy_hold_char;
+
+static int yy_n_chars; /* number of characters read into yy_ch_buf */
+
+
+int yyleng;
+
+/* Points to current character in buffer. */
+static char *yy_c_buf_p = (char *) 0;
+static int yy_init = 1; /* whether we need to initialize */
+static int yy_start = 0; /* start state number */
+
+/* Flag which is used to allow yywrap()'s to do buffer switches
+ * instead of setting up a fresh yyin. A bit of a hack ...
+ */
+static int yy_did_buffer_switch_on_eof;
+
+void yyrestart YY_PROTO(( FILE *input_file ));
+
+void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
+void yy_load_buffer_state YY_PROTO(( void ));
+YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
+void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
+void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
+#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
+
+YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
+YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
+YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
+
+static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
+static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
+static void yy_flex_free YY_PROTO(( void * ));
+
+#define yy_new_buffer yy_create_buffer
+
+#define yy_set_interactive(is_interactive) \
+ { \
+ if ( ! yy_current_buffer ) \
+ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+ yy_current_buffer->yy_is_interactive = is_interactive; \
+ }
+
+#define yy_set_bol(at_bol) \
+ { \
+ if ( ! yy_current_buffer ) \
+ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
+ yy_current_buffer->yy_at_bol = at_bol; \
+ }
+
+#define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
+
+
+#define yywrap() 1
+#define YY_SKIP_YYWRAP
+typedef unsigned char YY_CHAR;
+FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
+typedef int yy_state_type;
+extern char *yytext;
+#define yytext_ptr yytext
+
+static yy_state_type yy_get_previous_state YY_PROTO(( void ));
+static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
+static int yy_get_next_buffer YY_PROTO(( void ));
+static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
+
+/* Done after the current pattern has been matched and before the
+ * corresponding action - sets up yytext.
+ */
+#define YY_DO_BEFORE_ACTION \
+ yytext_ptr = yy_bp; \
+ yyleng = (int) (yy_cp - yy_bp); \
+ yy_hold_char = *yy_cp; \
+ *yy_cp = '\0'; \
+ yy_c_buf_p = yy_cp;
+
+#define YY_NUM_RULES 144
+#define YY_END_OF_BUFFER 145
+static yyconst short int yy_accept[428] =
+ { 0,
+ 0, 0, 0, 0, 145, 143, 142, 142, 127, 133,
+ 138, 122, 123, 131, 130, 119, 128, 126, 132, 143,
+ 143, 120, 116, 134, 121, 135, 139, 143, 124, 125,
+ 137, 143, 143, 143, 143, 143, 143, 143, 143, 143,
+ 143, 143, 143, 143, 143, 143, 143, 143, 143, 143,
+ 143, 117, 136, 118, 129, 141, 144, 143, 143, 113,
+ 99, 118, 107, 102, 97, 105, 95, 106, 96, 0,
+ 94, 0, 98, 90, 0, 0, 0, 125, 117, 124,
+ 114, 110, 112, 111, 115, 86, 103, 109, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 8, 0,
+
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 11, 13, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 104, 108, 140,
+ 93, 0, 1, 92, 0, 0, 88, 89, 0, 100,
+ 101, 0, 0, 43, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 9, 0, 0, 0, 0, 0, 0, 0, 17,
+ 0, 0, 0, 0, 0, 14, 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, 87, 86, 0, 19, 0, 0,
+ 83, 0, 0, 0, 0, 0, 0, 0, 12, 46,
+ 0, 0, 0, 0, 0, 51, 65, 0, 0, 0,
+ 0, 0, 0, 62, 24, 25, 26, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 49, 20, 0, 0, 0, 0, 0, 0, 27, 28,
+ 29, 18, 0, 0, 140, 0, 0, 92, 0, 0,
+ 0, 0, 6, 33, 34, 35, 44, 3, 0, 0,
+ 0, 0, 76, 77, 78, 0, 21, 66, 16, 73,
+
+ 74, 75, 70, 71, 72, 0, 15, 68, 0, 30,
+ 31, 32, 0, 0, 0, 0, 0, 0, 0, 63,
+ 0, 0, 0, 0, 0, 0, 0, 45, 0, 85,
+ 0, 0, 10, 0, 0, 91, 0, 0, 0, 0,
+ 64, 59, 54, 0, 0, 0, 69, 50, 57, 23,
+ 0, 82, 58, 42, 52, 0, 0, 0, 0, 0,
+ 0, 93, 92, 0, 0, 53, 22, 0, 0, 0,
+ 0, 0, 0, 47, 4, 0, 5, 0, 0, 7,
+ 60, 0, 0, 55, 0, 0, 0, 0, 48, 67,
+ 56, 2, 61, 84, 36, 37, 38, 0, 0, 0,
+
+ 0, 0, 0, 0, 0, 0, 0, 39, 0, 0,
+ 0, 0, 0, 79, 0, 80, 0, 0, 0, 40,
+ 0, 41, 0, 0, 0, 81, 0
+ } ;
+
+static yyconst int yy_ec[256] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
+ 2, 2, 4, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 2, 5, 1, 1, 1, 6, 7, 1, 8,
+ 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
+ 19, 20, 21, 21, 21, 22, 22, 23, 24, 25,
+ 26, 27, 28, 1, 29, 29, 30, 31, 32, 29,
+ 33, 33, 33, 33, 33, 33, 33, 33, 33, 33,
+ 33, 34, 35, 33, 33, 33, 33, 36, 33, 33,
+ 37, 1, 38, 39, 33, 1, 40, 41, 42, 43,
+
+ 44, 45, 46, 47, 48, 33, 49, 50, 51, 52,
+ 53, 54, 33, 55, 56, 57, 58, 59, 60, 61,
+ 62, 63, 64, 65, 66, 67, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1
+ } ;
+
+static yyconst int yy_meta[68] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
+ 2, 2, 1, 1, 1, 1, 1, 1, 2, 2,
+ 2, 2, 3, 3, 3, 3, 1, 1, 1, 2,
+ 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 1, 1, 1, 1
+ } ;
+
+static yyconst short int yy_base[432] =
+ { 0,
+ 0, 0, 67, 0, 678, 679, 679, 679, 651, 109,
+ 130, 679, 679, 650, 127, 679, 126, 124, 139, 151,
+ 671, 647, 679, 151, 647, 121, 679, 668, 679, 679,
+ 124, 147, 154, 155, 158, 171, 174, 157, 156, 184,
+ 175, 160, 178, 162, 176, 181, 190, 197, 193, 195,
+ 179, 679, 193, 679, 679, 679, 679, 656, 666, 679,
+ 679, 679, 679, 679, 679, 679, 679, 679, 679, 665,
+ 679, 665, 679, 246, 663, 662, 0, 679, 679, 679,
+ 639, 679, 679, 679, 638, 253, 679, 679, 612, 605,
+ 608, 616, 615, 602, 617, 604, 610, 598, 595, 608,
+
+ 595, 592, 592, 598, 586, 593, 590, 600, 586, 592,
+ 597, 679, 136, 596, 587, 581, 586, 588, 578, 592,
+ 592, 575, 580, 577, 566, 200, 580, 576, 578, 567,
+ 570, 136, 575, 567, 579, 203, 572, 679, 679, 263,
+ 275, 616, 679, 282, 614, 311, 318, 325, 613, 679,
+ 679, 612, 611, 679, 559, 563, 572, 569, 553, 553,
+ 200, 568, 565, 565, 563, 560, 552, 558, 545, 556,
+ 559, 679, 556, 544, 551, 553, 546, 535, 534, 547,
+ 548, 543, 268, 544, 535, 532, 536, 534, 525, 528,
+ 526, 536, 522, 520, 520, 522, 519, 530, 529, 201,
+
+ 524, 519, 508, 290, 526, 528, 517, 562, 561, 337,
+ 560, 349, 356, 559, 0, 363, 514, 679, 512, 293,
+ 679, 504, 502, 510, 499, 516, 505, 297, 679, 679,
+ 499, 509, 509, 494, 368, 679, 679, 371, 498, 492,
+ 491, 492, 374, 679, 679, 679, 679, 490, 495, 486,
+ 499, 494, 486, 490, 482, 485, 489, 494, 493, 484,
+ 679, 679, 490, 479, 479, 484, 483, 480, 679, 679,
+ 679, 679, 470, 482, 379, 386, 521, 393, 400, 520,
+ 422, 482, 679, 679, 679, 679, 679, 679, 470, 471,
+ 465, 475, 679, 679, 679, 466, 679, 679, 679, 679,
+
+ 679, 679, 679, 679, 679, 473, 679, 679, 471, 679,
+ 679, 679, 461, 466, 456, 469, 469, 458, 465, 679,
+ 463, 465, 449, 458, 464, 459, 447, 679, 449, 679,
+ 448, 451, 679, 429, 448, 679, 440, 439, 439, 452,
+ 679, 454, 679, 453, 452, 439, 679, 679, 679, 679,
+ 435, 679, 679, 679, 679, 432, 443, 436, 442, 439,
+ 434, 679, 679, 426, 438, 679, 679, 431, 438, 437,
+ 419, 441, 418, 679, 679, 418, 679, 413, 412, 679,
+ 679, 411, 410, 679, 422, 405, 404, 376, 679, 679,
+ 679, 679, 679, 679, 397, 242, 397, 389, 382, 384,
+
+ 380, 380, 379, 324, 321, 321, 310, 679, 308, 292,
+ 282, 266, 268, 285, 265, 679, 246, 258, 229, 679,
+ 221, 679, 199, 145, 131, 679, 679, 471, 179, 473,
+ 475
+ } ;
+
+static yyconst short int yy_def[432] =
+ { 0,
+ 427, 1, 427, 3, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 428, 427, 427, 427, 427, 429, 427, 427, 427,
+ 427, 427, 427, 427, 427, 430, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 431,
+ 427, 428, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 429, 430, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 431, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 0, 427, 427, 427,
+ 427
+ } ;
+
+static yyconst short int yy_nxt[747] =
+ { 0,
+ 6, 7, 8, 7, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 21, 21, 21,
+ 21, 21, 22, 23, 24, 25, 26, 27, 28, 28,
+ 28, 28, 28, 28, 28, 28, 29, 30, 31, 32,
+ 33, 34, 35, 36, 37, 38, 39, 40, 28, 41,
+ 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,
+ 28, 28, 28, 52, 53, 54, 55, 6, 56, 57,
+ 56, 6, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 58, 6, 6, 6, 6, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 59, 59, 59, 59, 59,
+
+ 59, 59, 59, 6, 6, 6, 59, 59, 59, 59,
+ 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
+ 59, 59, 59, 59, 59, 59, 59, 59, 59, 59,
+ 6, 6, 6, 6, 61, 62, 63, 66, 68, 70,
+ 70, 70, 70, 70, 70, 70, 84, 85, 71, 87,
+ 86, 69, 67, 72, 74, 64, 79, 86, 86, 86,
+ 86, 86, 88, 86, 73, 86, 75, 75, 75, 75,
+ 75, 75, 76, 80, 86, 81, 82, 86, 86, 86,
+ 149, 86, 86, 200, 86, 177, 77, 86, 178, 179,
+ 426, 201, 180, 86, 94, 110, 86, 425, 86, 116,
+
+ 86, 97, 89, 90, 95, 98, 91, 96, 92, 109,
+ 99, 77, 93, 104, 111, 120, 100, 117, 138, 119,
+ 101, 105, 102, 106, 122, 137, 107, 115, 112, 123,
+ 118, 103, 108, 121, 134, 113, 124, 125, 135, 193,
+ 128, 424, 114, 129, 132, 264, 126, 136, 133, 127,
+ 205, 130, 206, 265, 194, 223, 224, 139, 131, 144,
+ 423, 145, 145, 145, 145, 145, 145, 145, 152, 152,
+ 152, 152, 152, 152, 152, 400, 401, 146, 208, 208,
+ 208, 208, 208, 208, 208, 245, 246, 247, 422, 146,
+ 70, 70, 70, 70, 70, 70, 70, 211, 211, 211,
+
+ 211, 211, 211, 211, 421, 420, 210, 269, 270, 271,
+ 284, 285, 286, 212, 293, 294, 295, 419, 210, 418,
+ 417, 213, 416, 213, 415, 212, 214, 214, 214, 214,
+ 214, 214, 214, 75, 75, 75, 75, 75, 75, 76,
+ 76, 76, 76, 76, 76, 76, 76, 276, 414, 276,
+ 413, 412, 277, 277, 277, 277, 277, 277, 277, 279,
+ 411, 279, 410, 409, 280, 280, 280, 280, 280, 280,
+ 280, 214, 214, 214, 214, 214, 214, 214, 152, 152,
+ 152, 152, 152, 152, 152, 300, 301, 302, 303, 304,
+ 305, 310, 311, 312, 208, 208, 208, 208, 208, 208,
+
+ 208, 277, 277, 277, 277, 277, 277, 277, 211, 211,
+ 211, 211, 211, 211, 211, 280, 280, 280, 280, 280,
+ 280, 280, 408, 407, 212, 336, 406, 405, 404, 403,
+ 402, 399, 362, 398, 397, 396, 212, 214, 214, 214,
+ 214, 214, 214, 214, 277, 277, 277, 277, 277, 277,
+ 277, 363, 395, 394, 393, 392, 391, 385, 386, 387,
+ 390, 389, 384, 280, 280, 280, 280, 280, 280, 280,
+ 388, 142, 142, 142, 153, 153, 209, 209, 383, 382,
+ 381, 380, 379, 378, 377, 376, 375, 374, 373, 372,
+ 371, 370, 369, 368, 367, 366, 365, 364, 361, 360,
+
+ 359, 358, 357, 356, 355, 354, 353, 352, 351, 350,
+ 349, 348, 347, 346, 345, 344, 343, 342, 341, 340,
+ 339, 338, 337, 335, 334, 333, 332, 331, 330, 329,
+ 328, 327, 326, 325, 324, 323, 322, 321, 320, 319,
+ 318, 317, 316, 315, 314, 313, 309, 308, 307, 306,
+ 299, 298, 297, 296, 292, 291, 290, 289, 288, 287,
+ 283, 282, 281, 278, 275, 275, 274, 273, 272, 268,
+ 267, 266, 263, 262, 261, 260, 259, 258, 257, 256,
+ 255, 254, 253, 252, 251, 250, 249, 248, 244, 243,
+ 242, 241, 240, 239, 238, 237, 236, 235, 234, 233,
+
+ 232, 231, 230, 229, 228, 227, 226, 225, 222, 221,
+ 220, 219, 218, 217, 216, 216, 215, 74, 143, 207,
+ 204, 203, 202, 199, 198, 197, 196, 195, 192, 191,
+ 190, 189, 188, 187, 186, 185, 184, 183, 182, 181,
+ 176, 175, 174, 173, 172, 171, 170, 169, 168, 167,
+ 166, 165, 164, 163, 162, 161, 160, 159, 158, 157,
+ 156, 155, 154, 151, 150, 148, 147, 143, 141, 140,
+ 72, 86, 83, 78, 74, 65, 60, 427, 5, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427
+ } ;
+
+static yyconst short int yy_chk[747] =
+ { 0,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 3, 3, 3, 3, 10, 10, 11, 15, 17, 18,
+ 18, 18, 18, 18, 18, 18, 26, 26, 19, 31,
+ 32, 17, 15, 19, 20, 11, 24, 33, 34, 39,
+ 38, 35, 31, 42, 19, 44, 20, 20, 20, 20,
+ 20, 20, 20, 24, 36, 24, 24, 37, 41, 45,
+ 429, 43, 51, 132, 46, 113, 20, 40, 113, 113,
+ 425, 132, 113, 47, 34, 39, 49, 424, 50, 42,
+
+ 48, 35, 32, 32, 34, 35, 33, 34, 33, 38,
+ 35, 20, 33, 37, 39, 45, 35, 43, 53, 44,
+ 36, 37, 36, 37, 46, 51, 37, 41, 40, 47,
+ 43, 36, 37, 45, 50, 40, 47, 47, 50, 126,
+ 48, 423, 40, 48, 49, 200, 47, 50, 49, 47,
+ 136, 48, 136, 200, 126, 161, 161, 53, 48, 74,
+ 421, 74, 74, 74, 74, 74, 74, 74, 86, 86,
+ 86, 86, 86, 86, 86, 396, 396, 74, 140, 140,
+ 140, 140, 140, 140, 140, 183, 183, 183, 419, 74,
+ 141, 141, 141, 141, 141, 141, 141, 144, 144, 144,
+
+ 144, 144, 144, 144, 418, 417, 141, 204, 204, 204,
+ 220, 220, 220, 144, 228, 228, 228, 415, 141, 414,
+ 413, 146, 412, 146, 411, 144, 146, 146, 146, 146,
+ 146, 146, 146, 147, 147, 147, 147, 147, 147, 147,
+ 148, 148, 148, 148, 148, 148, 148, 210, 410, 210,
+ 409, 407, 210, 210, 210, 210, 210, 210, 210, 212,
+ 406, 212, 405, 404, 212, 212, 212, 212, 212, 212,
+ 212, 213, 213, 213, 213, 213, 213, 213, 216, 216,
+ 216, 216, 216, 216, 216, 235, 235, 235, 238, 238,
+ 238, 243, 243, 243, 275, 275, 275, 275, 275, 275,
+
+ 275, 276, 276, 276, 276, 276, 276, 276, 278, 278,
+ 278, 278, 278, 278, 278, 279, 279, 279, 279, 279,
+ 279, 279, 403, 402, 278, 281, 401, 400, 399, 398,
+ 397, 395, 334, 388, 387, 386, 278, 281, 281, 281,
+ 281, 281, 281, 281, 334, 334, 334, 334, 334, 334,
+ 334, 335, 385, 383, 382, 379, 378, 372, 372, 372,
+ 376, 373, 371, 335, 335, 335, 335, 335, 335, 335,
+ 372, 428, 428, 428, 430, 430, 431, 431, 370, 369,
+ 368, 365, 364, 361, 360, 359, 358, 357, 356, 351,
+ 346, 345, 344, 342, 340, 339, 338, 337, 332, 331,
+
+ 329, 327, 326, 325, 324, 323, 322, 321, 319, 318,
+ 317, 316, 315, 314, 313, 309, 306, 296, 292, 291,
+ 290, 289, 282, 280, 277, 274, 273, 268, 267, 266,
+ 265, 264, 263, 260, 259, 258, 257, 256, 255, 254,
+ 253, 252, 251, 250, 249, 248, 242, 241, 240, 239,
+ 234, 233, 232, 231, 227, 226, 225, 224, 223, 222,
+ 219, 217, 214, 211, 209, 208, 207, 206, 205, 203,
+ 202, 201, 199, 198, 197, 196, 195, 194, 193, 192,
+ 191, 190, 189, 188, 187, 186, 185, 184, 182, 181,
+ 180, 179, 178, 177, 176, 175, 174, 173, 171, 170,
+
+ 169, 168, 167, 166, 165, 164, 163, 162, 160, 159,
+ 158, 157, 156, 155, 153, 152, 149, 145, 142, 137,
+ 135, 134, 133, 131, 130, 129, 128, 127, 125, 124,
+ 123, 122, 121, 120, 119, 118, 117, 116, 115, 114,
+ 111, 110, 109, 108, 107, 106, 105, 104, 103, 102,
+ 101, 100, 99, 98, 97, 96, 95, 94, 93, 92,
+ 91, 90, 89, 85, 81, 76, 75, 72, 70, 59,
+ 58, 28, 25, 22, 21, 14, 9, 5, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
+ 427, 427, 427, 427, 427, 427
+ } ;
+
+static yy_state_type yy_last_accepting_state;
+static char *yy_last_accepting_cpos;
+
+/* The intent behind this definition is that it'll catch
+ * any uses of REJECT which flex missed.
+ */
+#define REJECT reject_used_but_not_detected
+#define yymore() yymore_used_but_not_detected
+#define YY_MORE_ADJ 0
+#define YY_RESTORE_YY_MORE_OFFSET
+char *yytext;
+#line 1 "glslang.l"
+#define INITIAL 0
+/*
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+*/
+/* Based on
+ANSI C grammar, Lex specification
+
+In 1985, Jeff Lee published this Lex specification together with a Yacc
+grammar for the April 30, 1985 ANSI C draft. Tom Stockfisch reposted
+both to net.sources in 1987; that original, as mentioned in the answer
+to question 17.25 of the comp.lang.c FAQ, can be ftp'ed from ftp.uu.net,
+file usenet/net.sources/ansi.c.grammar.Z.
+
+I intend to keep this version as close to the current C Standard grammar
+as possible; please let me know if you discover discrepancies.
+
+Jutta Degener, 1995
+*/
+#define YY_NO_UNPUT 1
+#line 59 "glslang.l"
+#include <stdio.h>
+#include <stdlib.h>
+#include "ParseHelper.h"
+#include "glslang_tab.h"
+
+/* windows only pragma */
+#ifdef _MSC_VER
+#pragma warning(disable : 4102)
+#endif
+
+int yy_input(char* buf, int max_size);
+TSourceLoc yylineno;
+
+#ifdef _WIN32
+ extern int yyparse(TParseContext&);
+ #define YY_DECL int yylex(YYSTYPE* pyylval, TParseContext& parseContext)
+#else
+ extern int yyparse(void*);
+ #define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)
+ #define parseContext (*((TParseContext*)(parseContextLocal)))
+#endif
+
+#define YY_INPUT(buf,result,max_size) (result = yy_input(buf, max_size))
+
+#define YY_NEVER_INTERACTIVE 1
+#define FIELDS 1
+
+#line 753 "Gen_glslang.cpp"
+
+/* Macros after this point can all be overridden by user definitions in
+ * section 1.
+ */
+
+#ifndef YY_SKIP_YYWRAP
+#ifdef __cplusplus
+extern "C" int yywrap YY_PROTO(( void ));
+#else
+extern int yywrap YY_PROTO(( void ));
+#endif
+#endif
+
+#ifndef YY_NO_UNPUT
+static void yyunput YY_PROTO(( int c, char *buf_ptr ));
+#endif
+
+#ifndef yytext_ptr
+static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
+#endif
+
+#ifdef YY_NEED_STRLEN
+static int yy_flex_strlen YY_PROTO(( yyconst char * ));
+#endif
+
+#ifndef YY_NO_INPUT
+#ifdef __cplusplus
+static int yyinput YY_PROTO(( void ));
+#else
+static int input YY_PROTO(( void ));
+#endif
+#endif
+
+#if YY_STACK_USED
+static int yy_start_stack_ptr = 0;
+static int yy_start_stack_depth = 0;
+static int *yy_start_stack = 0;
+#ifndef YY_NO_PUSH_STATE
+static void yy_push_state YY_PROTO(( int new_state ));
+#endif
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state YY_PROTO(( void ));
+#endif
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state YY_PROTO(( void ));
+#endif
+
+#else
+#define YY_NO_PUSH_STATE 1
+#define YY_NO_POP_STATE 1
+#define YY_NO_TOP_STATE 1
+#endif
+
+#ifdef YY_MALLOC_DECL
+YY_MALLOC_DECL
+#else
+#if __STDC__
+#ifndef __cplusplus
+#include <stdlib.h>
+#endif
+#else
+/* Just try to get by without declaring the routines. This will fail
+ * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
+ * or sizeof(void*) != sizeof(int).
+ */
+#endif
+#endif
+
+/* Amount of stuff to slurp up with each read. */
+#ifndef YY_READ_BUF_SIZE
+#define YY_READ_BUF_SIZE 8192
+#endif
+
+/* Copy whatever the last rule matched to the standard output. */
+
+#ifndef ECHO
+/* This used to be an fputs(), but since the string might contain NUL's,
+ * we now use fwrite().
+ */
+#define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
+#endif
+
+/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
+ * is returned in "result".
+ */
+#ifndef YY_INPUT
+#define YY_INPUT(buf,result,max_size) \
+ if ( yy_current_buffer->yy_is_interactive ) \
+ { \
+ int c = '*', n; \
+ for ( n = 0; n < max_size && \
+ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+ buf[n] = (char) c; \
+ if ( c == '\n' ) \
+ buf[n++] = (char) c; \
+ if ( c == EOF && ferror( yyin ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
+ result = n; \
+ } \
+ else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
+ && ferror( yyin ) ) \
+ YY_FATAL_ERROR( "input in flex scanner failed" );
+#endif
+
+/* No semi-colon after return; correct usage is to write "yyterminate();" -
+ * we don't want an extra ';' after the "return" because that will cause
+ * some compilers to complain about unreachable statements.
+ */
+#ifndef yyterminate
+#define yyterminate() return YY_NULL
+#endif
+
+/* Number of entries by which start-condition stack grows. */
+#ifndef YY_START_STACK_INCR
+#define YY_START_STACK_INCR 25
+#endif
+
+/* Report a fatal error. */
+#ifndef YY_FATAL_ERROR
+#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
+#endif
+
+/* Default declaration of generated scanner - a define so the user can
+ * easily add parameters.
+ */
+#ifndef YY_DECL
+#define YY_DECL int yylex YY_PROTO(( void ))
+#endif
+
+/* Code executed at the beginning of each rule, after yytext and yyleng
+ * have been set up.
+ */
+#ifndef YY_USER_ACTION
+#define YY_USER_ACTION
+#endif
+
+/* Code executed at the end of each rule. */
+#ifndef YY_BREAK
+#define YY_BREAK break;
+#endif
+
+#define YY_RULE_SETUP \
+ YY_USER_ACTION
+
+YY_DECL
+ {
+ register yy_state_type yy_current_state;
+ register char *yy_cp, *yy_bp;
+ register int yy_act;
+
+#line 91 "glslang.l"
+
+#line 906 "Gen_glslang.cpp"
+
+ if ( yy_init )
+ {
+ yy_init = 0;
+
+#ifdef YY_USER_INIT
+ YY_USER_INIT;
+#endif
+
+ if ( ! yy_start )
+ yy_start = 1; /* first start state */
+
+ if ( ! yyin )
+ yyin = stdin;
+
+ if ( ! yyout )
+ yyout = stdout;
+
+ if ( ! yy_current_buffer )
+ yy_current_buffer =
+ yy_create_buffer( yyin, YY_BUF_SIZE );
+
+ yy_load_buffer_state();
+ }
+
+ while ( 1 ) /* loops until end-of-file is reached */
+ {
+ yy_cp = yy_c_buf_p;
+
+ /* Support of yytext. */
+ *yy_cp = yy_hold_char;
+
+ /* yy_bp points to the position in yy_ch_buf of the start of
+ * the current run.
+ */
+ yy_bp = yy_cp;
+
+ yy_current_state = yy_start;
+yy_match:
+ do
+ {
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+ if ( yy_accept[yy_current_state] )
+ {
+ yy_last_accepting_state = yy_current_state;
+ yy_last_accepting_cpos = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 428 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ ++yy_cp;
+ }
+ while ( yy_base[yy_current_state] != 679 );
+
+yy_find_action:
+ yy_act = yy_accept[yy_current_state];
+ if ( yy_act == 0 )
+ { /* have to back up */
+ yy_cp = yy_last_accepting_cpos;
+ yy_current_state = yy_last_accepting_state;
+ yy_act = yy_accept[yy_current_state];
+ }
+
+ YY_DO_BEFORE_ACTION;
+
+
+do_action: /* This label is used only to access EOF actions. */
+
+
+ switch ( yy_act )
+ { /* beginning of action switch */
+ case 0: /* must back up */
+ /* undo the effects of YY_DO_BEFORE_ACTION */
+ *yy_cp = yy_hold_char;
+ yy_cp = yy_last_accepting_cpos;
+ yy_current_state = yy_last_accepting_state;
+ goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 92 "glslang.l"
+{ /* ?? carriage and/or line-feed? */ };
+ YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 94 "glslang.l"
+{ pyylval->lex.line = yylineno; return(ATTRIBUTE); }
+ YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 95 "glslang.l"
+{ pyylval->lex.line = yylineno; return(CONST_QUAL); }
+ YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 96 "glslang.l"
+{ pyylval->lex.line = yylineno; return(UNIFORM); }
+ YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 97 "glslang.l"
+{ pyylval->lex.line = yylineno; return(VARYING); }
+ YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 99 "glslang.l"
+{ pyylval->lex.line = yylineno; return(BREAK); }
+ YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 100 "glslang.l"
+{ pyylval->lex.line = yylineno; return(CONTINUE); }
+ YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 101 "glslang.l"
+{ pyylval->lex.line = yylineno; return(DO); }
+ YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 102 "glslang.l"
+{ pyylval->lex.line = yylineno; return(FOR); }
+ YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 103 "glslang.l"
+{ pyylval->lex.line = yylineno; return(WHILE); }
+ YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 105 "glslang.l"
+{ pyylval->lex.line = yylineno; return(IF); }
+ YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 106 "glslang.l"
+{ pyylval->lex.line = yylineno; return(ELSE); }
+ YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 108 "glslang.l"
+{ pyylval->lex.line = yylineno; return(IN_QUAL); }
+ YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 109 "glslang.l"
+{ pyylval->lex.line = yylineno; return(OUT_QUAL); }
+ YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 110 "glslang.l"
+{ pyylval->lex.line = yylineno; return(INOUT_QUAL); }
+ YY_BREAK
+case 16:
+YY_RULE_SETUP
+#line 112 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(FLOAT_TYPE); }
+ YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 113 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(INT_TYPE); }
+ YY_BREAK
+case 18:
+YY_RULE_SETUP
+#line 114 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(VOID_TYPE); }
+ YY_BREAK
+case 19:
+YY_RULE_SETUP
+#line 115 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(BOOL_TYPE); }
+ YY_BREAK
+case 20:
+YY_RULE_SETUP
+#line 116 "glslang.l"
+{ pyylval->lex.line = yylineno; pyylval->lex.b = true; return(BOOLCONSTANT); }
+ YY_BREAK
+case 21:
+YY_RULE_SETUP
+#line 117 "glslang.l"
+{ pyylval->lex.line = yylineno; pyylval->lex.b = false; return(BOOLCONSTANT); }
+ YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 119 "glslang.l"
+{ pyylval->lex.line = yylineno; return(DISCARD); }
+ YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 120 "glslang.l"
+{ pyylval->lex.line = yylineno; return(RETURN); }
+ YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 122 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX2); }
+ YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 123 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX3); }
+ YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 124 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX4); }
+ YY_BREAK
+case 27:
+YY_RULE_SETUP
+#line 126 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC2); }
+ YY_BREAK
+case 28:
+YY_RULE_SETUP
+#line 127 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC3); }
+ YY_BREAK
+case 29:
+YY_RULE_SETUP
+#line 128 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC4); }
+ YY_BREAK
+case 30:
+YY_RULE_SETUP
+#line 129 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC2); }
+ YY_BREAK
+case 31:
+YY_RULE_SETUP
+#line 130 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC3); }
+ YY_BREAK
+case 32:
+YY_RULE_SETUP
+#line 131 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC4); }
+ YY_BREAK
+case 33:
+YY_RULE_SETUP
+#line 132 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC2); }
+ YY_BREAK
+case 34:
+YY_RULE_SETUP
+#line 133 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC3); }
+ YY_BREAK
+case 35:
+YY_RULE_SETUP
+#line 134 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC4); }
+ YY_BREAK
+case 36:
+YY_RULE_SETUP
+#line 136 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1D; }
+ YY_BREAK
+case 37:
+YY_RULE_SETUP
+#line 137 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2D; }
+ YY_BREAK
+case 38:
+YY_RULE_SETUP
+#line 138 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER3D; }
+ YY_BREAK
+case 39:
+YY_RULE_SETUP
+#line 139 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLERCUBE; }
+ YY_BREAK
+case 40:
+YY_RULE_SETUP
+#line 140 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1DSHADOW; }
+ YY_BREAK
+case 41:
+YY_RULE_SETUP
+#line 141 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DSHADOW; }
+ YY_BREAK
+case 42:
+YY_RULE_SETUP
+#line 143 "glslang.l"
+{ pyylval->lex.line = yylineno; return(STRUCT); }
+ YY_BREAK
+case 43:
+YY_RULE_SETUP
+#line 145 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 44:
+YY_RULE_SETUP
+#line 147 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 45:
+YY_RULE_SETUP
+#line 148 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 46:
+YY_RULE_SETUP
+#line 149 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 47:
+YY_RULE_SETUP
+#line 150 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 48:
+YY_RULE_SETUP
+#line 151 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 49:
+YY_RULE_SETUP
+#line 152 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 50:
+YY_RULE_SETUP
+#line 153 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 51:
+YY_RULE_SETUP
+#line 155 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 52:
+YY_RULE_SETUP
+#line 156 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 53:
+YY_RULE_SETUP
+#line 157 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 54:
+YY_RULE_SETUP
+#line 159 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 55:
+YY_RULE_SETUP
+#line 160 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 56:
+YY_RULE_SETUP
+#line 161 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 57:
+YY_RULE_SETUP
+#line 162 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 58:
+YY_RULE_SETUP
+#line 163 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 59:
+YY_RULE_SETUP
+#line 164 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 60:
+YY_RULE_SETUP
+#line 165 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 61:
+YY_RULE_SETUP
+#line 166 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 62:
+YY_RULE_SETUP
+#line 168 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 63:
+YY_RULE_SETUP
+#line 169 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 64:
+YY_RULE_SETUP
+#line 170 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 65:
+YY_RULE_SETUP
+#line 171 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 66:
+YY_RULE_SETUP
+#line 172 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 67:
+YY_RULE_SETUP
+#line 173 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 68:
+YY_RULE_SETUP
+#line 175 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 69:
+YY_RULE_SETUP
+#line 176 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 70:
+YY_RULE_SETUP
+#line 178 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 71:
+YY_RULE_SETUP
+#line 179 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 72:
+YY_RULE_SETUP
+#line 180 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 73:
+YY_RULE_SETUP
+#line 181 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 74:
+YY_RULE_SETUP
+#line 182 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 75:
+YY_RULE_SETUP
+#line 183 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 76:
+YY_RULE_SETUP
+#line 184 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 77:
+YY_RULE_SETUP
+#line 185 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 78:
+YY_RULE_SETUP
+#line 186 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 79:
+YY_RULE_SETUP
+#line 188 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 80:
+YY_RULE_SETUP
+#line 189 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 81:
+YY_RULE_SETUP
+#line 190 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 82:
+YY_RULE_SETUP
+#line 192 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 83:
+YY_RULE_SETUP
+#line 193 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 84:
+YY_RULE_SETUP
+#line 195 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 85:
+YY_RULE_SETUP
+#line 196 "glslang.l"
+{ PaReservedWord(); return 0; }
+ YY_BREAK
+case 86:
+YY_RULE_SETUP
+#line 198 "glslang.l"
+{
+ pyylval->lex.line = yylineno;
+ pyylval->lex.string = NewPoolTString(yytext);
+ return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol);
+}
+ YY_BREAK
+case 87:
+YY_RULE_SETUP
+#line 204 "glslang.l"
+{ pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
+ YY_BREAK
+case 88:
+YY_RULE_SETUP
+#line 205 "glslang.l"
+{ pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
+ YY_BREAK
+case 89:
+YY_RULE_SETUP
+#line 206 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;}
+ YY_BREAK
+case 90:
+YY_RULE_SETUP
+#line 207 "glslang.l"
+{ pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
+ YY_BREAK
+case 91:
+YY_RULE_SETUP
+#line 209 "glslang.l"
+{ pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }
+ YY_BREAK
+case 92:
+YY_RULE_SETUP
+#line 210 "glslang.l"
+{ pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }
+ YY_BREAK
+case 93:
+YY_RULE_SETUP
+#line 211 "glslang.l"
+{ pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }
+ YY_BREAK
+case 94:
+YY_RULE_SETUP
+#line 213 "glslang.l"
+{ int ret = PaParseComment(pyylval->lex.line, parseContext); if (!ret) return ret; }
+ YY_BREAK
+case 95:
+YY_RULE_SETUP
+#line 215 "glslang.l"
+{ pyylval->lex.line = yylineno; return(ADD_ASSIGN); }
+ YY_BREAK
+case 96:
+YY_RULE_SETUP
+#line 216 "glslang.l"
+{ pyylval->lex.line = yylineno; return(SUB_ASSIGN); }
+ YY_BREAK
+case 97:
+YY_RULE_SETUP
+#line 217 "glslang.l"
+{ pyylval->lex.line = yylineno; return(MUL_ASSIGN); }
+ YY_BREAK
+case 98:
+YY_RULE_SETUP
+#line 218 "glslang.l"
+{ pyylval->lex.line = yylineno; return(DIV_ASSIGN); }
+ YY_BREAK
+case 99:
+YY_RULE_SETUP
+#line 219 "glslang.l"
+{ pyylval->lex.line = yylineno; return(MOD_ASSIGN); }
+ YY_BREAK
+case 100:
+YY_RULE_SETUP
+#line 220 "glslang.l"
+{ pyylval->lex.line = yylineno; return(LEFT_ASSIGN); }
+ YY_BREAK
+case 101:
+YY_RULE_SETUP
+#line 221 "glslang.l"
+{ pyylval->lex.line = yylineno; return(RIGHT_ASSIGN); }
+ YY_BREAK
+case 102:
+YY_RULE_SETUP
+#line 222 "glslang.l"
+{ pyylval->lex.line = yylineno; return(AND_ASSIGN); }
+ YY_BREAK
+case 103:
+YY_RULE_SETUP
+#line 223 "glslang.l"
+{ pyylval->lex.line = yylineno; return(XOR_ASSIGN); }
+ YY_BREAK
+case 104:
+YY_RULE_SETUP
+#line 224 "glslang.l"
+{ pyylval->lex.line = yylineno; return(OR_ASSIGN); }
+ YY_BREAK
+case 105:
+YY_RULE_SETUP
+#line 226 "glslang.l"
+{ pyylval->lex.line = yylineno; return(INC_OP); }
+ YY_BREAK
+case 106:
+YY_RULE_SETUP
+#line 227 "glslang.l"
+{ pyylval->lex.line = yylineno; return(DEC_OP); }
+ YY_BREAK
+case 107:
+YY_RULE_SETUP
+#line 228 "glslang.l"
+{ pyylval->lex.line = yylineno; return(AND_OP); }
+ YY_BREAK
+case 108:
+YY_RULE_SETUP
+#line 229 "glslang.l"
+{ pyylval->lex.line = yylineno; return(OR_OP); }
+ YY_BREAK
+case 109:
+YY_RULE_SETUP
+#line 230 "glslang.l"
+{ pyylval->lex.line = yylineno; return(XOR_OP); }
+ YY_BREAK
+case 110:
+YY_RULE_SETUP
+#line 231 "glslang.l"
+{ pyylval->lex.line = yylineno; return(LE_OP); }
+ YY_BREAK
+case 111:
+YY_RULE_SETUP
+#line 232 "glslang.l"
+{ pyylval->lex.line = yylineno; return(GE_OP); }
+ YY_BREAK
+case 112:
+YY_RULE_SETUP
+#line 233 "glslang.l"
+{ pyylval->lex.line = yylineno; return(EQ_OP); }
+ YY_BREAK
+case 113:
+YY_RULE_SETUP
+#line 234 "glslang.l"
+{ pyylval->lex.line = yylineno; return(NE_OP); }
+ YY_BREAK
+case 114:
+YY_RULE_SETUP
+#line 235 "glslang.l"
+{ pyylval->lex.line = yylineno; return(LEFT_OP); }
+ YY_BREAK
+case 115:
+YY_RULE_SETUP
+#line 236 "glslang.l"
+{ pyylval->lex.line = yylineno; return(RIGHT_OP); }
+ YY_BREAK
+case 116:
+YY_RULE_SETUP
+#line 237 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(SEMICOLON); }
+ YY_BREAK
+case 117:
+YY_RULE_SETUP
+#line 238 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(LEFT_BRACE); }
+ YY_BREAK
+case 118:
+YY_RULE_SETUP
+#line 239 "glslang.l"
+{ pyylval->lex.line = yylineno; return(RIGHT_BRACE); }
+ YY_BREAK
+case 119:
+YY_RULE_SETUP
+#line 240 "glslang.l"
+{ pyylval->lex.line = yylineno; if (parseContext.inTypeParen) parseContext.lexAfterType = false; return(COMMA); }
+ YY_BREAK
+case 120:
+YY_RULE_SETUP
+#line 241 "glslang.l"
+{ pyylval->lex.line = yylineno; return(COLON); }
+ YY_BREAK
+case 121:
+YY_RULE_SETUP
+#line 242 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(EQUAL); }
+ YY_BREAK
+case 122:
+YY_RULE_SETUP
+#line 243 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.lexAfterType = false; parseContext.inTypeParen = true; return(LEFT_PAREN); }
+ YY_BREAK
+case 123:
+YY_RULE_SETUP
+#line 244 "glslang.l"
+{ pyylval->lex.line = yylineno; parseContext.inTypeParen = false; return(RIGHT_PAREN); }
+ YY_BREAK
+case 124:
+YY_RULE_SETUP
+#line 245 "glslang.l"
+{ pyylval->lex.line = yylineno; return(LEFT_BRACKET); }
+ YY_BREAK
+case 125:
+YY_RULE_SETUP
+#line 246 "glslang.l"
+{ pyylval->lex.line = yylineno; return(RIGHT_BRACKET); }
+ YY_BREAK
+case 126:
+YY_RULE_SETUP
+#line 247 "glslang.l"
+{ BEGIN(FIELDS); return(DOT); }
+ YY_BREAK
+case 127:
+YY_RULE_SETUP
+#line 248 "glslang.l"
+{ pyylval->lex.line = yylineno; return(BANG); }
+ YY_BREAK
+case 128:
+YY_RULE_SETUP
+#line 249 "glslang.l"
+{ pyylval->lex.line = yylineno; return(DASH); }
+ YY_BREAK
+case 129:
+YY_RULE_SETUP
+#line 250 "glslang.l"
+{ pyylval->lex.line = yylineno; return(TILDE); }
+ YY_BREAK
+case 130:
+YY_RULE_SETUP
+#line 251 "glslang.l"
+{ pyylval->lex.line = yylineno; return(PLUS); }
+ YY_BREAK
+case 131:
+YY_RULE_SETUP
+#line 252 "glslang.l"
+{ pyylval->lex.line = yylineno; return(STAR); }
+ YY_BREAK
+case 132:
+YY_RULE_SETUP
+#line 253 "glslang.l"
+{ pyylval->lex.line = yylineno; return(SLASH); }
+ YY_BREAK
+case 133:
+YY_RULE_SETUP
+#line 254 "glslang.l"
+{ pyylval->lex.line = yylineno; return(PERCENT); }
+ YY_BREAK
+case 134:
+YY_RULE_SETUP
+#line 255 "glslang.l"
+{ pyylval->lex.line = yylineno; return(LEFT_ANGLE); }
+ YY_BREAK
+case 135:
+YY_RULE_SETUP
+#line 256 "glslang.l"
+{ pyylval->lex.line = yylineno; return(RIGHT_ANGLE); }
+ YY_BREAK
+case 136:
+YY_RULE_SETUP
+#line 257 "glslang.l"
+{ pyylval->lex.line = yylineno; return(VERTICAL_BAR); }
+ YY_BREAK
+case 137:
+YY_RULE_SETUP
+#line 258 "glslang.l"
+{ pyylval->lex.line = yylineno; return(CARET); }
+ YY_BREAK
+case 138:
+YY_RULE_SETUP
+#line 259 "glslang.l"
+{ pyylval->lex.line = yylineno; return(AMPERSAND); }
+ YY_BREAK
+case 139:
+YY_RULE_SETUP
+#line 260 "glslang.l"
+{ pyylval->lex.line = yylineno; return(QUESTION); }
+ YY_BREAK
+case 140:
+YY_RULE_SETUP
+#line 262 "glslang.l"
+{
+BEGIN(INITIAL);
+ pyylval->lex.line = yylineno;
+ pyylval->lex.string = NewPoolTString(yytext);
+ return FIELD_SELECTION; }
+ YY_BREAK
+case 141:
+YY_RULE_SETUP
+#line 267 "glslang.l"
+{}
+ YY_BREAK
+case 142:
+YY_RULE_SETUP
+#line 269 "glslang.l"
+{ }
+ YY_BREAK
+case YY_STATE_EOF(INITIAL):
+case YY_STATE_EOF(FIELDS):
+#line 270 "glslang.l"
+{ (&parseContext)->AfterEOF = true; yy_delete_buffer(YY_CURRENT_BUFFER); yyterminate();}
+ YY_BREAK
+case 143:
+YY_RULE_SETUP
+#line 271 "glslang.l"
+{ parseContext.infoSink.info << "FLEX: Unknown char " << yytext << "\n";
+ return 0; }
+ YY_BREAK
+case 144:
+YY_RULE_SETUP
+#line 274 "glslang.l"
+ECHO;
+ YY_BREAK
+#line 1723 "Gen_glslang.cpp"
+
+ case YY_END_OF_BUFFER:
+ {
+ /* Amount of text matched not including the EOB char. */
+ int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
+
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
+ *yy_cp = yy_hold_char;
+ YY_RESTORE_YY_MORE_OFFSET
+
+ if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
+ {
+ /* We're scanning a new file or input source. It's
+ * possible that this happened because the user
+ * just pointed yyin at a new source and called
+ * yylex(). If so, then we have to assure
+ * consistency between yy_current_buffer and our
+ * globals. Here is the right place to do so, because
+ * this is the first action (other than possibly a
+ * back-up) that will match for the new input source.
+ */
+ yy_n_chars = yy_current_buffer->yy_n_chars;
+ yy_current_buffer->yy_input_file = yyin;
+ yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
+ }
+
+ /* Note that here we test for yy_c_buf_p "<=" to the position
+ * of the first EOB in the buffer, since yy_c_buf_p will
+ * already have been incremented past the NUL character
+ * (since all states make transitions on EOB to the
+ * end-of-buffer state). Contrast this with the test
+ * in input().
+ */
+ if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+ { /* This was really a NUL. */
+ yy_state_type yy_next_state;
+
+ yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state();
+
+ /* Okay, we're now positioned to make the NUL
+ * transition. We couldn't have
+ * yy_get_previous_state() go ahead and do it
+ * for us because it doesn't know how to deal
+ * with the possibility of jamming (and we don't
+ * want to build jamming into it because then it
+ * will run more slowly).
+ */
+
+ yy_next_state = yy_try_NUL_trans( yy_current_state );
+
+ yy_bp = yytext_ptr + YY_MORE_ADJ;
+
+ if ( yy_next_state )
+ {
+ /* Consume the NUL. */
+ yy_cp = ++yy_c_buf_p;
+ yy_current_state = yy_next_state;
+ goto yy_match;
+ }
+
+ else
+ {
+ yy_cp = yy_c_buf_p;
+ goto yy_find_action;
+ }
+ }
+
+ else switch ( yy_get_next_buffer() )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ yy_did_buffer_switch_on_eof = 0;
+
+ if ( yywrap() )
+ {
+ /* Note: because we've taken care in
+ * yy_get_next_buffer() to have set up
+ * yytext, we can now set up
+ * yy_c_buf_p so that if some total
+ * hoser (like flex itself) wants to
+ * call the scanner after we return the
+ * YY_NULL, it'll still work - another
+ * YY_NULL will get returned.
+ */
+ yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
+
+ yy_act = YY_STATE_EOF(YY_START);
+ goto do_action;
+ }
+
+ else
+ {
+ if ( ! yy_did_buffer_switch_on_eof )
+ YY_NEW_FILE;
+ }
+ break;
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ yy_c_buf_p =
+ yytext_ptr + yy_amount_of_matched_text;
+
+ yy_current_state = yy_get_previous_state();
+
+ yy_cp = yy_c_buf_p;
+ yy_bp = yytext_ptr + YY_MORE_ADJ;
+ goto yy_match;
+
+ case EOB_ACT_LAST_MATCH:
+ yy_c_buf_p =
+ &yy_current_buffer->yy_ch_buf[yy_n_chars];
+
+ yy_current_state = yy_get_previous_state();
+
+ yy_cp = yy_c_buf_p;
+ yy_bp = yytext_ptr + YY_MORE_ADJ;
+ goto yy_find_action;
+ }
+ break;
+ }
+
+ default:
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--no action found" );
+ } /* end of action switch */
+ } /* end of scanning one token */
+ } /* end of yylex */
+
+
+/* yy_get_next_buffer - try to read in a new buffer
+ *
+ * Returns a code representing an action:
+ * EOB_ACT_LAST_MATCH -
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
+ * EOB_ACT_END_OF_FILE - end of file
+ */
+
+static int yy_get_next_buffer()
+ {
+ register char *dest = yy_current_buffer->yy_ch_buf;
+ register char *source = yytext_ptr;
+ register int number_to_move, i;
+ int ret_val;
+
+ if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
+ YY_FATAL_ERROR(
+ "fatal flex scanner internal error--end of buffer missed" );
+
+ if ( yy_current_buffer->yy_fill_buffer == 0 )
+ { /* Don't try to fill the buffer, so this is an EOF. */
+ if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
+ {
+ /* We matched a single character, the EOB, so
+ * treat this as a final EOF.
+ */
+ return EOB_ACT_END_OF_FILE;
+ }
+
+ else
+ {
+ /* We matched some text prior to the EOB, first
+ * process it.
+ */
+ return EOB_ACT_LAST_MATCH;
+ }
+ }
+
+ /* Try to read more data. */
+
+ /* First move last chars to start of buffer. */
+ number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
+
+ for ( i = 0; i < number_to_move; ++i )
+ *(dest++) = *(source++);
+
+ if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+ yy_current_buffer->yy_n_chars = yy_n_chars = 0;
+
+ else
+ {
+ int num_to_read =
+ yy_current_buffer->yy_buf_size - number_to_move - 1;
+
+ while ( num_to_read <= 0 )
+ { /* Not enough room in the buffer - grow it. */
+#ifdef YY_USES_REJECT
+ YY_FATAL_ERROR(
+"input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
+#else
+
+ /* just a shorter name for the current buffer */
+ YY_BUFFER_STATE b = yy_current_buffer;
+
+ int yy_c_buf_p_offset =
+ (int) (yy_c_buf_p - b->yy_ch_buf);
+
+ if ( b->yy_is_our_buffer )
+ {
+ int new_size = b->yy_buf_size * 2;
+
+ if ( new_size <= 0 )
+ b->yy_buf_size += b->yy_buf_size / 8;
+ else
+ b->yy_buf_size *= 2;
+
+ b->yy_ch_buf = (char *)
+ /* Include room in for 2 EOB chars. */
+ yy_flex_realloc( (void *) b->yy_ch_buf,
+ b->yy_buf_size + 2 );
+ }
+ else
+ /* Can't grow it, we don't own it. */
+ b->yy_ch_buf = 0;
+
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR(
+ "fatal error - scanner input buffer overflow" );
+
+ yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
+
+ num_to_read = yy_current_buffer->yy_buf_size -
+ number_to_move - 1;
+#endif
+ }
+
+ if ( num_to_read > YY_READ_BUF_SIZE )
+ num_to_read = YY_READ_BUF_SIZE;
+
+ /* Read in more data. */
+ YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
+ yy_n_chars, num_to_read );
+
+ yy_current_buffer->yy_n_chars = yy_n_chars;
+ }
+
+ if ( yy_n_chars == 0 )
+ {
+ if ( number_to_move == YY_MORE_ADJ )
+ {
+ ret_val = EOB_ACT_END_OF_FILE;
+ yyrestart( yyin );
+ }
+
+ else
+ {
+ ret_val = EOB_ACT_LAST_MATCH;
+ yy_current_buffer->yy_buffer_status =
+ YY_BUFFER_EOF_PENDING;
+ }
+ }
+
+ else
+ ret_val = EOB_ACT_CONTINUE_SCAN;
+
+ yy_n_chars += number_to_move;
+ yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
+ yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
+
+ yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
+
+ return ret_val;
+ }
+
+
+/* yy_get_previous_state - get the state just before the EOB char was reached */
+
+static yy_state_type yy_get_previous_state()
+ {
+ register yy_state_type yy_current_state;
+ register char *yy_cp;
+
+ yy_current_state = yy_start;
+
+ for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
+ {
+ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
+ if ( yy_accept[yy_current_state] )
+ {
+ yy_last_accepting_state = yy_current_state;
+ yy_last_accepting_cpos = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 428 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ }
+
+ return yy_current_state;
+ }
+
+
+/* yy_try_NUL_trans - try to make a transition on the NUL character
+ *
+ * synopsis
+ * next_state = yy_try_NUL_trans( current_state );
+ */
+
+#ifdef YY_USE_PROTOS
+static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
+#else
+static yy_state_type yy_try_NUL_trans( yy_current_state )
+yy_state_type yy_current_state;
+#endif
+ {
+ register int yy_is_jam;
+ register char *yy_cp = yy_c_buf_p;
+
+ register YY_CHAR yy_c = 1;
+ if ( yy_accept[yy_current_state] )
+ {
+ yy_last_accepting_state = yy_current_state;
+ yy_last_accepting_cpos = yy_cp;
+ }
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+ {
+ yy_current_state = (int) yy_def[yy_current_state];
+ if ( yy_current_state >= 428 )
+ yy_c = yy_meta[(unsigned int) yy_c];
+ }
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+ yy_is_jam = (yy_current_state == 427);
+
+ return yy_is_jam ? 0 : yy_current_state;
+ }
+
+
+#ifndef YY_NO_UNPUT
+#ifdef YY_USE_PROTOS
+static void yyunput( int c, register char *yy_bp )
+#else
+static void yyunput( c, yy_bp )
+int c;
+register char *yy_bp;
+#endif
+ {
+ register char *yy_cp = yy_c_buf_p;
+
+ /* undo effects of setting up yytext */
+ *yy_cp = yy_hold_char;
+
+ if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+ { /* need to shift things up to make room */
+ /* +2 for EOB chars. */
+ register int number_to_move = yy_n_chars + 2;
+ register char *dest = &yy_current_buffer->yy_ch_buf[
+ yy_current_buffer->yy_buf_size + 2];
+ register char *source =
+ &yy_current_buffer->yy_ch_buf[number_to_move];
+
+ while ( source > yy_current_buffer->yy_ch_buf )
+ *--dest = *--source;
+
+ yy_cp += (int) (dest - source);
+ yy_bp += (int) (dest - source);
+ yy_current_buffer->yy_n_chars =
+ yy_n_chars = yy_current_buffer->yy_buf_size;
+
+ if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+ YY_FATAL_ERROR( "flex scanner push-back overflow" );
+ }
+
+ *--yy_cp = (char) c;
+
+
+ yytext_ptr = yy_bp;
+ yy_hold_char = *yy_cp;
+ yy_c_buf_p = yy_cp;
+ }
+#endif /* ifndef YY_NO_UNPUT */
+
+
+#ifdef __cplusplus
+static int yyinput()
+#else
+static int input()
+#endif
+ {
+ int c;
+
+ *yy_c_buf_p = yy_hold_char;
+
+ if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
+ {
+ /* yy_c_buf_p now points to the character we want to return.
+ * If this occurs *before* the EOB characters, then it's a
+ * valid NUL; if not, then we've hit the end of the buffer.
+ */
+ if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
+ /* This was really a NUL. */
+ *yy_c_buf_p = '\0';
+
+ else
+ { /* need more input */
+ int offset = yy_c_buf_p - yytext_ptr;
+ ++yy_c_buf_p;
+
+ switch ( yy_get_next_buffer() )
+ {
+ case EOB_ACT_LAST_MATCH:
+ /* This happens because yy_g_n_b()
+ * sees that we've accumulated a
+ * token and flags that we need to
+ * try matching the token before
+ * proceeding. But for input(),
+ * there's no matching to consider.
+ * So convert the EOB_ACT_LAST_MATCH
+ * to EOB_ACT_END_OF_FILE.
+ */
+
+ /* Reset buffer status. */
+ yyrestart( yyin );
+
+ /* fall through */
+
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( yywrap() )
+ return EOF;
+
+ if ( ! yy_did_buffer_switch_on_eof )
+ YY_NEW_FILE;
+#ifdef __cplusplus
+ return yyinput();
+#else
+ return input();
+#endif
+ }
+
+ case EOB_ACT_CONTINUE_SCAN:
+ yy_c_buf_p = yytext_ptr + offset;
+ break;
+ }
+ }
+ }
+
+ c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
+ *yy_c_buf_p = '\0'; /* preserve yytext */
+ yy_hold_char = *++yy_c_buf_p;
+
+
+ return c;
+ }
+
+
+#ifdef YY_USE_PROTOS
+void yyrestart( FILE *input_file )
+#else
+void yyrestart( input_file )
+FILE *input_file;
+#endif
+ {
+ if ( ! yy_current_buffer )
+ yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
+
+ yy_init_buffer( yy_current_buffer, input_file );
+ yy_load_buffer_state();
+ }
+
+
+#ifdef YY_USE_PROTOS
+void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
+#else
+void yy_switch_to_buffer( new_buffer )
+YY_BUFFER_STATE new_buffer;
+#endif
+ {
+ if ( yy_current_buffer == new_buffer )
+ return;
+
+ if ( yy_current_buffer )
+ {
+ /* Flush out information for old buffer. */
+ *yy_c_buf_p = yy_hold_char;
+ yy_current_buffer->yy_buf_pos = yy_c_buf_p;
+ yy_current_buffer->yy_n_chars = yy_n_chars;
+ }
+
+ yy_current_buffer = new_buffer;
+ yy_load_buffer_state();
+
+ /* We don't actually know whether we did this switch during
+ * EOF (yywrap()) processing, but the only time this flag
+ * is looked at is after yywrap() is called, so it's safe
+ * to go ahead and always set it.
+ */
+ yy_did_buffer_switch_on_eof = 1;
+ }
+
+
+#ifdef YY_USE_PROTOS
+void yy_load_buffer_state( void )
+#else
+void yy_load_buffer_state()
+#endif
+ {
+ yy_n_chars = yy_current_buffer->yy_n_chars;
+ yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
+ yyin = yy_current_buffer->yy_input_file;
+ yy_hold_char = *yy_c_buf_p;
+ }
+
+
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
+#else
+YY_BUFFER_STATE yy_create_buffer( file, size )
+FILE *file;
+int size;
+#endif
+ {
+ YY_BUFFER_STATE b;
+
+ b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_buf_size = size;
+
+ /* yy_ch_buf has to be 2 characters longer than the size given because
+ * we need to put in 2 end-of-buffer characters.
+ */
+ b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
+ if ( ! b->yy_ch_buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
+
+ b->yy_is_our_buffer = 1;
+
+ yy_init_buffer( b, file );
+
+ return b;
+ }
+
+
+#ifdef YY_USE_PROTOS
+void yy_delete_buffer( YY_BUFFER_STATE b )
+#else
+void yy_delete_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+ {
+ if ( ! b )
+ return;
+
+ if ( b == yy_current_buffer )
+ yy_current_buffer = (YY_BUFFER_STATE) 0;
+
+ if ( b->yy_is_our_buffer )
+ yy_flex_free( (void *) b->yy_ch_buf );
+
+ yy_flex_free( (void *) b );
+ }
+
+
+
+#ifdef YY_USE_PROTOS
+void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
+#else
+void yy_init_buffer( b, file )
+YY_BUFFER_STATE b;
+FILE *file;
+#endif
+
+
+ {
+ yy_flush_buffer( b );
+
+ b->yy_input_file = file;
+ b->yy_fill_buffer = 1;
+
+#if YY_ALWAYS_INTERACTIVE
+ b->yy_is_interactive = 1;
+#else
+#if YY_NEVER_INTERACTIVE
+ b->yy_is_interactive = 0;
+#else
+ b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
+#endif
+#endif
+ }
+
+
+#ifdef YY_USE_PROTOS
+void yy_flush_buffer( YY_BUFFER_STATE b )
+#else
+void yy_flush_buffer( b )
+YY_BUFFER_STATE b;
+#endif
+
+ {
+ if ( ! b )
+ return;
+
+ b->yy_n_chars = 0;
+
+ /* We always need two end-of-buffer characters. The first causes
+ * a transition to the end-of-buffer state. The second causes
+ * a jam in that state.
+ */
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
+
+ b->yy_buf_pos = &b->yy_ch_buf[0];
+
+ b->yy_at_bol = 1;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ if ( b == yy_current_buffer )
+ yy_load_buffer_state();
+ }
+
+
+#ifndef YY_NO_SCAN_BUFFER
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
+#else
+YY_BUFFER_STATE yy_scan_buffer( base, size )
+char *base;
+yy_size_t size;
+#endif
+ {
+ YY_BUFFER_STATE b;
+
+ if ( size < 2 ||
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
+ /* They forgot to leave room for the EOB's. */
+ return 0;
+
+ b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
+ if ( ! b )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
+
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
+ b->yy_buf_pos = b->yy_ch_buf = base;
+ b->yy_is_our_buffer = 0;
+ b->yy_input_file = 0;
+ b->yy_n_chars = b->yy_buf_size;
+ b->yy_is_interactive = 0;
+ b->yy_at_bol = 1;
+ b->yy_fill_buffer = 0;
+ b->yy_buffer_status = YY_BUFFER_NEW;
+
+ yy_switch_to_buffer( b );
+
+ return b;
+ }
+#endif
+
+
+#ifndef YY_NO_SCAN_STRING
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
+#else
+YY_BUFFER_STATE yy_scan_string( yy_str )
+yyconst char *yy_str;
+#endif
+ {
+ int len;
+ for ( len = 0; yy_str[len]; ++len )
+ ;
+
+ return yy_scan_bytes( yy_str, len );
+ }
+#endif
+
+
+#ifndef YY_NO_SCAN_BYTES
+#ifdef YY_USE_PROTOS
+YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
+#else
+YY_BUFFER_STATE yy_scan_bytes( bytes, len )
+yyconst char *bytes;
+int len;
+#endif
+ {
+ YY_BUFFER_STATE b;
+ char *buf;
+ yy_size_t n;
+ int i;
+
+ /* Get memory for full buffer, including space for trailing EOB's. */
+ n = len + 2;
+ buf = (char *) yy_flex_alloc( n );
+ if ( ! buf )
+ YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
+
+ for ( i = 0; i < len; ++i )
+ buf[i] = bytes[i];
+
+ buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
+
+ b = yy_scan_buffer( buf, n );
+ if ( ! b )
+ YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
+
+ /* It's okay to grow etc. this buffer, and we should throw it
+ * away when we're done.
+ */
+ b->yy_is_our_buffer = 1;
+
+ return b;
+ }
+#endif
+
+
+#ifndef YY_NO_PUSH_STATE
+#ifdef YY_USE_PROTOS
+static void yy_push_state( int new_state )
+#else
+static void yy_push_state( new_state )
+int new_state;
+#endif
+ {
+ if ( yy_start_stack_ptr >= yy_start_stack_depth )
+ {
+ yy_size_t new_size;
+
+ yy_start_stack_depth += YY_START_STACK_INCR;
+ new_size = yy_start_stack_depth * sizeof( int );
+
+ if ( ! yy_start_stack )
+ yy_start_stack = (int *) yy_flex_alloc( new_size );
+
+ else
+ yy_start_stack = (int *) yy_flex_realloc(
+ (void *) yy_start_stack, new_size );
+
+ if ( ! yy_start_stack )
+ YY_FATAL_ERROR(
+ "out of memory expanding start-condition stack" );
+ }
+
+ yy_start_stack[yy_start_stack_ptr++] = YY_START;
+
+ BEGIN(new_state);
+ }
+#endif
+
+
+#ifndef YY_NO_POP_STATE
+static void yy_pop_state()
+ {
+ if ( --yy_start_stack_ptr < 0 )
+ YY_FATAL_ERROR( "start-condition stack underflow" );
+
+ BEGIN(yy_start_stack[yy_start_stack_ptr]);
+ }
+#endif
+
+
+#ifndef YY_NO_TOP_STATE
+static int yy_top_state()
+ {
+ return yy_start_stack[yy_start_stack_ptr - 1];
+ }
+#endif
+
+#ifndef YY_EXIT_FAILURE
+#define YY_EXIT_FAILURE 2
+#endif
+
+#ifdef YY_USE_PROTOS
+static void yy_fatal_error( yyconst char msg[] )
+#else
+static void yy_fatal_error( msg )
+char msg[];
+#endif
+ {
+ (void) fprintf( stderr, "%s\n", msg );
+ exit( YY_EXIT_FAILURE );
+ }
+
+
+
+/* Redefine yyless() so it works in section 3 code. */
+
+#undef yyless
+#define yyless(n) \
+ do \
+ { \
+ /* Undo effects of setting up yytext. */ \
+ yytext[yyleng] = yy_hold_char; \
+ yy_c_buf_p = yytext + n; \
+ yy_hold_char = *yy_c_buf_p; \
+ *yy_c_buf_p = '\0'; \
+ yyleng = n; \
+ } \
+ while ( 0 )
+
+
+/* Internal utility routines. */
+
+#ifndef yytext_ptr
+#ifdef YY_USE_PROTOS
+static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
+#else
+static void yy_flex_strncpy( s1, s2, n )
+char *s1;
+yyconst char *s2;
+int n;
+#endif
+ {
+ register int i;
+ for ( i = 0; i < n; ++i )
+ s1[i] = s2[i];
+ }
+#endif
+
+#ifdef YY_NEED_STRLEN
+#ifdef YY_USE_PROTOS
+static int yy_flex_strlen( yyconst char *s )
+#else
+static int yy_flex_strlen( s )
+yyconst char *s;
+#endif
+ {
+ register int n;
+ for ( n = 0; s[n]; ++n )
+ ;
+
+ return n;
+ }
+#endif
+
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_alloc( yy_size_t size )
+#else
+static void *yy_flex_alloc( size )
+yy_size_t size;
+#endif
+ {
+ return (void *) malloc( size );
+ }
+
+#ifdef YY_USE_PROTOS
+static void *yy_flex_realloc( void *ptr, yy_size_t size )
+#else
+static void *yy_flex_realloc( ptr, size )
+void *ptr;
+yy_size_t size;
+#endif
+ {
+ /* The cast to (char *) in the following accommodates both
+ * implementations that use char* generic pointers, and those
+ * that use void* generic pointers. It works with the latter
+ * because both ANSI C and C++ allow castless assignment from
+ * any pointer type to void*, and deal with argument conversions
+ * as though doing an assignment.
+ */
+ return (void *) realloc( (char *) ptr, size );
+ }
+
+#ifdef YY_USE_PROTOS
+static void yy_flex_free( void *ptr )
+#else
+static void yy_flex_free( ptr )
+void *ptr;
+#endif
+ {
+ free( ptr );
+ }
+
+#if YY_MAIN
+int main()
+ {
+ yylex();
+ return 0;
+ }
+#endif
+#line 274 "glslang.l"
+
+
+
+//Including Pre-processor.
+extern "C" {
+ #include "./preprocessor/preprocess.h"
+}
+
+//
+// The YY_INPUT macro just calls this. Maybe this could be just put into
+// the macro directly.
+//
+
+int yy_input(char* buf, int max_size)
+{
+ char *char_token =NULL;
+ int len;
+
+ if ((len = yylex_CPP(buf, max_size)) == 0)
+ return 0;
+ if (len >= max_size)
+ YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
+
+ buf[len] = ' ';
+ return len+1;
+}
+
+
+//
+// Parse an array of strings using yyparse. We set up globals used by
+// yywrap.
+//
+// Returns 0 for success, as per yyparse().
+//
+int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext& parseContextLocal)
+{
+ int argv0len;
+ ScanFromString(argv[0]);
+
+ //Storing the Current Compiler Parse context into the cpp structure.
+ cpp->pC = (void*)&parseContextLocal;
+
+ if (!argv || argc == 0 || !argv[0])
+ return 1;
+
+ if (!strLen) {
+ argv0len = (int) strlen(argv[0]);
+ strLen = &argv0len;
+ }
+ yyrestart(0);
+ (&parseContextLocal)->AfterEOF = false;
+ cpp->PaWhichStr = 0;
+ cpp->PaArgv = argv;
+ cpp->PaArgc = argc;
+ cpp->PaStrLen = strLen;
+ yylineno = 1;
+
+ if (*cpp->PaStrLen >= 0) {
+ int ret;
+ #ifdef _WIN32
+ ret = yyparse(parseContextLocal);
+ #else
+ ret = yyparse((void*)(&parseContextLocal));
+ #endif
+ if (cpp->CompileError == 1 || parseContextLocal.recoveredFromError || parseContextLocal.numErrors > 0)
+ return 1;
+ else
+ return 0;
+ }
+ else
+ return 0;
+}
+
+void yyerror(char *s)
+{
+ if (((TParseContext *)cpp->pC)->AfterEOF) {
+ if (cpp->tokensBeforeEOF == 1) {
+ GlobalParseContext->error(yylineno, "syntax error", "pre-mature EOF", s, "");
+ GlobalParseContext->recover();
+ }
+ } else {
+ GlobalParseContext->error(yylineno, "syntax error", yytext, s, "");
+ GlobalParseContext->recover();
+ }
+}
+
+void PaReservedWord()
+{
+ GlobalParseContext->error(yylineno, "Reserved word.", yytext, "", "");
+ GlobalParseContext->recover();
+}
+
+int PaIdentOrType(TString& id, TParseContext& parseContextLocal, TSymbol*& symbol)
+{
+ symbol = parseContextLocal.symbolTable.find(id);
+ if (parseContextLocal.lexAfterType == false && symbol && symbol->isVariable()) {
+ TVariable* variable = static_cast<TVariable*>(symbol);
+ if (variable->isUserType()) {
+ parseContextLocal.lexAfterType = true;
+ return TYPE_NAME;
+ }
+ }
+
+ return IDENTIFIER;
+}
+
+int PaParseComment(int &lineno, TParseContext& parseContextLocal)
+{
+ int transitionFlag = 0;
+ int nextChar;
+
+ while (transitionFlag != 2) {
+ nextChar = yyinput();
+ if (nextChar == '\n')
+ lineno++;
+ switch (nextChar) {
+ case '*' :
+ transitionFlag = 1;
+ break;
+ case '/' : /* if star is the previous character, then it is the end of comment */
+ if (transitionFlag == 1) {
+ return 1 ;
+ }
+ break;
+ case EOF :
+ /* Raise error message here */
+ parseContextLocal.error(yylineno, "End of shader found before end of comment.", "", "", "");
+ GlobalParseContext->recover();
+ return YY_NULL;
+ default : /* Any other character will be a part of the comment */
+ transitionFlag = 0;
+ }
+ }
+ return 1;
+}
+
+extern "C" {
+
+void CPPDebugLogMsg(const char *msg)
+{
+ ((TParseContext *)cpp->pC)->infoSink.debug.message(EPrefixNone, msg);
+}
+
+void CPPWarningToInfoLog(const char *msg)
+{
+ ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg, yylineno);
+}
+
+void CPPShInfoLogMsg(const char *msg)
+{
+ ((TParseContext *)cpp->pC)->error(yylineno,"", "",msg,"");
+ GlobalParseContext->recover();
+}
+
+void CPPErrorToInfoLog(char *msg)
+{
+ ((TParseContext *)cpp->pC)->error(yylineno,"syntax error", "",msg,"");
+ GlobalParseContext->recover();
+}
+
+void SetLineNumber(int line)
+{
+ yylineno &= ~SourceLocLineMask;
+ yylineno |= line;
+}
+
+void SetStringNumber(int string)
+{
+ yylineno = (string << SourceLocStringShift) | (yylineno & SourceLocLineMask);
+}
+
+int GetStringNumber(void)
+{
+ return yylineno >> 16;
+}
+
+int GetLineNumber(void)
+{
+ return yylineno & SourceLocLineMask;
+}
+
+void IncLineNumber(void)
+{
+ if ((yylineno & SourceLocLineMask) <= SourceLocLineMask)
+ ++yylineno;
+}
+
+void DecLineNumber(void)
+{
+ if ((yylineno & SourceLocLineMask) > 0)
+ --yylineno;
+}
+
+void HandlePragma(const char **tokens, int numTokens)
+{
+ if (!strcmp(tokens[0], "optimize")) {
+ if (numTokens != 4) {
+ CPPShInfoLogMsg("optimize pragma syntax is incorrect");
+ return;
+ }
+
+ if (strcmp(tokens[1], "(")) {
+ CPPShInfoLogMsg("\"(\" expected after 'optimize' keyword");
+ return;
+ }
+
+ if (!strcmp(tokens[2], "on"))
+ ((TParseContext *)cpp->pC)->contextPragma.optimize = true;
+ else if (!strcmp(tokens[2], "off"))
+ ((TParseContext *)cpp->pC)->contextPragma.optimize = false;
+ else {
+ CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma");
+ return;
+ }
+
+ if (strcmp(tokens[3], ")")) {
+ CPPShInfoLogMsg("\")\" expected to end 'optimize' pragma");
+ return;
+ }
+ } else if (!strcmp(tokens[0], "debug")) {
+ if (numTokens != 4) {
+ CPPShInfoLogMsg("debug pragma syntax is incorrect");
+ return;
+ }
+
+ if (strcmp(tokens[1], "(")) {
+ CPPShInfoLogMsg("\"(\" expected after 'debug' keyword");
+ return;
+ }
+
+ if (!strcmp(tokens[2], "on"))
+ ((TParseContext *)cpp->pC)->contextPragma.debug = true;
+ else if (!strcmp(tokens[2], "off"))
+ ((TParseContext *)cpp->pC)->contextPragma.debug = false;
+ else {
+ CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma");
+ return;
+ }
+
+ if (strcmp(tokens[3], ")")) {
+ CPPShInfoLogMsg("\")\" expected to end 'debug' pragma");
+ return;
+ }
+ } else {
+ /*
+ // implementation specific pragma
+ // use ((TParseContext *)cpp->pC)->contextPragma.pragmaTable to store the information about pragma
+ // For now, just ignore the pragma that the implementation cannot recognize
+ // An Example of one such implementation for a pragma that has a syntax like
+ // #pragma pragmaname(pragmavalue)
+ // This implementation stores the current pragmavalue against the pragma name in pragmaTable.
+ if (numTokens == 4 && !strcmp(tokens[1], "(") && !strcmp(tokens[3], ")")) {
+ TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable;
+ TPragmaTable::iterator iter;
+ iter = pragmaTable.find(TString(tokens[0]));
+ if (iter != pragmaTable.end()) {
+ iter->second = tokens[2];
+ } else {
+ pragmaTable[tokens[0]] = tokens[2];
+ }
+ }
+ */
+ }
+}
+
+void StoreStr(char *string)
+{
+ TString strSrc;
+ strSrc = TString(string);
+
+ ((TParseContext *)cpp->pC)->HashErrMsg = ((TParseContext *)cpp->pC)->HashErrMsg + " " + strSrc;
+}
+
+const char* GetStrfromTStr(void)
+{
+ cpp->ErrMsg = (((TParseContext *)cpp->pC)->HashErrMsg).c_str();
+ return cpp->ErrMsg;
+}
+
+void ResetTString(void)
+{
+ ((TParseContext *)cpp->pC)->HashErrMsg = "";
+}
+
+TBehavior GetBehavior(const char* behavior)
+{
+ if (!strcmp("require", behavior))
+ return EBhRequire;
+ else if (!strcmp("enable", behavior))
+ return EBhEnable;
+ else if (!strcmp("disable", behavior))
+ return EBhDisable;
+ else if (!strcmp("warn", behavior))
+ return EBhWarn;
+ else {
+ CPPShInfoLogMsg((TString("behavior '") + behavior + "' is not supported").c_str());
+ return EBhDisable;
+ }
+}
+
+void updateExtensionBehavior(const char* extName, const char* behavior)
+{
+ TBehavior behaviorVal = GetBehavior(behavior);
+ TMap<TString, TBehavior>:: iterator iter;
+ TString msg;
+
+ // special cased for all extension
+ if (!strcmp(extName, "all")) {
+ if (behaviorVal == EBhRequire || behaviorVal == EBhEnable) {
+ CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior");
+ return;
+ } else {
+ for (iter = ((TParseContext *)cpp->pC)->extensionBehavior.begin(); iter != ((TParseContext *)cpp->pC)->extensionBehavior.end(); ++iter)
+ iter->second = behaviorVal;
+ }
+ } else {
+ iter = ((TParseContext *)cpp->pC)->extensionBehavior.find(TString(extName));
+ if (iter == ((TParseContext *)cpp->pC)->extensionBehavior.end()) {
+ switch (behaviorVal) {
+ case EBhRequire:
+ CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str());
+ break;
+ case EBhEnable:
+ case EBhWarn:
+ case EBhDisable:
+ msg = TString("extension '") + extName + "' is not supported";
+ ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno);
+ break;
+ }
+ return;
+ } else
+ iter->second = behaviorVal;
+ }
+}
+
+}
+
+void setInitialState()
+{
+ yy_start = 1;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Gen_glslang_tab.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Gen_glslang_tab.cpp
new file mode 100755
index 000000000..69aa60872
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Gen_glslang_tab.cpp
@@ -0,0 +1,4354 @@
+/* A Bison parser, made by GNU Bison 1.875. */
+
+/* Skeleton parser for Yacc-like parsing with Bison,
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* As a special exception, when this file is copied by Bison into a
+ Bison output file, you may use that output file without restriction.
+ This special exception was added by the Free Software Foundation
+ in version 1.24 of Bison. */
+
+/* Written by Richard Stallman by simplifying the original so called
+ ``semantic'' parser. */
+
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
+/* Identify Bison output. */
+#define YYBISON 1
+
+/* Skeleton name. */
+#define YYSKELETON_NAME "yacc.c"
+
+/* Pure parsers. */
+#define YYPURE 1
+
+/* Using locations. */
+#define YYLSP_NEEDED 0
+
+
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ ATTRIBUTE = 258,
+ CONST_QUAL = 259,
+ BOOL_TYPE = 260,
+ FLOAT_TYPE = 261,
+ INT_TYPE = 262,
+ BREAK = 263,
+ CONTINUE = 264,
+ DO = 265,
+ ELSE = 266,
+ FOR = 267,
+ IF = 268,
+ DISCARD = 269,
+ RETURN = 270,
+ BVEC2 = 271,
+ BVEC3 = 272,
+ BVEC4 = 273,
+ IVEC2 = 274,
+ IVEC3 = 275,
+ IVEC4 = 276,
+ VEC2 = 277,
+ VEC3 = 278,
+ VEC4 = 279,
+ MATRIX2 = 280,
+ MATRIX3 = 281,
+ MATRIX4 = 282,
+ IN_QUAL = 283,
+ OUT_QUAL = 284,
+ INOUT_QUAL = 285,
+ UNIFORM = 286,
+ VARYING = 287,
+ STRUCT = 288,
+ VOID_TYPE = 289,
+ WHILE = 290,
+ SAMPLER1D = 291,
+ SAMPLER2D = 292,
+ SAMPLER3D = 293,
+ SAMPLERCUBE = 294,
+ SAMPLER1DSHADOW = 295,
+ SAMPLER2DSHADOW = 296,
+ IDENTIFIER = 297,
+ TYPE_NAME = 298,
+ FLOATCONSTANT = 299,
+ INTCONSTANT = 300,
+ BOOLCONSTANT = 301,
+ FIELD_SELECTION = 302,
+ LEFT_OP = 303,
+ RIGHT_OP = 304,
+ INC_OP = 305,
+ DEC_OP = 306,
+ LE_OP = 307,
+ GE_OP = 308,
+ EQ_OP = 309,
+ NE_OP = 310,
+ AND_OP = 311,
+ OR_OP = 312,
+ XOR_OP = 313,
+ MUL_ASSIGN = 314,
+ DIV_ASSIGN = 315,
+ ADD_ASSIGN = 316,
+ MOD_ASSIGN = 317,
+ LEFT_ASSIGN = 318,
+ RIGHT_ASSIGN = 319,
+ AND_ASSIGN = 320,
+ XOR_ASSIGN = 321,
+ OR_ASSIGN = 322,
+ SUB_ASSIGN = 323,
+ LEFT_PAREN = 324,
+ RIGHT_PAREN = 325,
+ LEFT_BRACKET = 326,
+ RIGHT_BRACKET = 327,
+ LEFT_BRACE = 328,
+ RIGHT_BRACE = 329,
+ DOT = 330,
+ COMMA = 331,
+ COLON = 332,
+ EQUAL = 333,
+ SEMICOLON = 334,
+ BANG = 335,
+ DASH = 336,
+ TILDE = 337,
+ PLUS = 338,
+ STAR = 339,
+ SLASH = 340,
+ PERCENT = 341,
+ LEFT_ANGLE = 342,
+ RIGHT_ANGLE = 343,
+ VERTICAL_BAR = 344,
+ CARET = 345,
+ AMPERSAND = 346,
+ QUESTION = 347
+ };
+#endif
+#define ATTRIBUTE 258
+#define CONST_QUAL 259
+#define BOOL_TYPE 260
+#define FLOAT_TYPE 261
+#define INT_TYPE 262
+#define BREAK 263
+#define CONTINUE 264
+#define DO 265
+#define ELSE 266
+#define FOR 267
+#define IF 268
+#define DISCARD 269
+#define RETURN 270
+#define BVEC2 271
+#define BVEC3 272
+#define BVEC4 273
+#define IVEC2 274
+#define IVEC3 275
+#define IVEC4 276
+#define VEC2 277
+#define VEC3 278
+#define VEC4 279
+#define MATRIX2 280
+#define MATRIX3 281
+#define MATRIX4 282
+#define IN_QUAL 283
+#define OUT_QUAL 284
+#define INOUT_QUAL 285
+#define UNIFORM 286
+#define VARYING 287
+#define STRUCT 288
+#define VOID_TYPE 289
+#define WHILE 290
+#define SAMPLER1D 291
+#define SAMPLER2D 292
+#define SAMPLER3D 293
+#define SAMPLERCUBE 294
+#define SAMPLER1DSHADOW 295
+#define SAMPLER2DSHADOW 296
+#define IDENTIFIER 297
+#define TYPE_NAME 298
+#define FLOATCONSTANT 299
+#define INTCONSTANT 300
+#define BOOLCONSTANT 301
+#define FIELD_SELECTION 302
+#define LEFT_OP 303
+#define RIGHT_OP 304
+#define INC_OP 305
+#define DEC_OP 306
+#define LE_OP 307
+#define GE_OP 308
+#define EQ_OP 309
+#define NE_OP 310
+#define AND_OP 311
+#define OR_OP 312
+#define XOR_OP 313
+#define MUL_ASSIGN 314
+#define DIV_ASSIGN 315
+#define ADD_ASSIGN 316
+#define MOD_ASSIGN 317
+#define LEFT_ASSIGN 318
+#define RIGHT_ASSIGN 319
+#define AND_ASSIGN 320
+#define XOR_ASSIGN 321
+#define OR_ASSIGN 322
+#define SUB_ASSIGN 323
+#define LEFT_PAREN 324
+#define RIGHT_PAREN 325
+#define LEFT_BRACKET 326
+#define RIGHT_BRACKET 327
+#define LEFT_BRACE 328
+#define RIGHT_BRACE 329
+#define DOT 330
+#define COMMA 331
+#define COLON 332
+#define EQUAL 333
+#define SEMICOLON 334
+#define BANG 335
+#define DASH 336
+#define TILDE 337
+#define PLUS 338
+#define STAR 339
+#define SLASH 340
+#define PERCENT 341
+#define LEFT_ANGLE 342
+#define RIGHT_ANGLE 343
+#define VERTICAL_BAR 344
+#define CARET 345
+#define AMPERSAND 346
+#define QUESTION 347
+
+
+
+
+/* Copy the first part of user declarations. */
+#line 39 "glslang.y"
+
+
+/* Based on:
+ANSI C Yacc grammar
+
+In 1985, Jeff Lee published his Yacc grammar (which is accompanied by a
+matching Lex specification) for the April 30, 1985 draft version of the
+ANSI C standard. Tom Stockfisch reposted it to net.sources in 1987; that
+original, as mentioned in the answer to question 17.25 of the comp.lang.c
+FAQ, can be ftp'ed from ftp.uu.net, file usenet/net.sources/ansi.c.grammar.Z.
+
+I intend to keep this version as close to the current C Standard grammar as
+possible; please let me know if you discover discrepancies.
+
+Jutta Degener, 1995
+*/
+
+#include "SymbolTable.h"
+#include "ParseHelper.h"
+#include "../Public/ShaderLang.h"
+
+#ifdef _WIN32
+ #define YYPARSE_PARAM parseContext
+ #define YYPARSE_PARAM_DECL TParseContext&
+ #define YY_DECL int yylex(YYSTYPE* pyylval, TParseContext& parseContext)
+ #define YYLEX_PARAM parseContext
+#else
+ #define YYPARSE_PARAM parseContextLocal
+ #define parseContext (*((TParseContext*)(parseContextLocal)))
+ #define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)
+ #define YYLEX_PARAM (void*)(parseContextLocal)
+ extern void yyerror(char*);
+#endif
+
+#define FRAG_VERT_ONLY(S, L) { \
+ if (parseContext.language != EShLangFragment && \
+ parseContext.language != EShLangVertex) { \
+ parseContext.error(L, " supported in vertex/fragment shaders only ", S, "", ""); \
+ parseContext.recover(); \
+ } \
+}
+
+#define VERTEX_ONLY(S, L) { \
+ if (parseContext.language != EShLangVertex) { \
+ parseContext.error(L, " supported in vertex shaders only ", S, "", ""); \
+ parseContext.recover(); \
+ } \
+}
+
+#define FRAG_ONLY(S, L) { \
+ if (parseContext.language != EShLangFragment) { \
+ parseContext.error(L, " supported in fragment shaders only ", S, "", ""); \
+ parseContext.recover(); \
+ } \
+}
+
+#define PACK_ONLY(S, L) { \
+ if (parseContext.language != EShLangPack) { \
+ parseContext.error(L, " supported in pack shaders only ", S, "", ""); \
+ parseContext.recover(); \
+ } \
+}
+
+#define UNPACK_ONLY(S, L) { \
+ if (parseContext.language != EShLangUnpack) { \
+ parseContext.error(L, " supported in unpack shaders only ", S, "", ""); \
+ parseContext.recover(); \
+ } \
+}
+
+#define PACK_UNPACK_ONLY(S, L) { \
+ if (parseContext.language != EShLangUnpack && \
+ parseContext.language != EShLangPack) { \
+ parseContext.error(L, " supported in pack/unpack shaders only ", S, "", ""); \
+ parseContext.recover(); \
+ } \
+}
+
+
+/* Enabling traces. */
+#ifndef YYDEBUG
+# define YYDEBUG 1
+#endif
+
+/* Enabling verbose error messages. */
+#ifdef YYERROR_VERBOSE
+# undef YYERROR_VERBOSE
+# define YYERROR_VERBOSE 1
+#else
+# define YYERROR_VERBOSE 0
+#endif
+
+#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
+#line 117 "glslang.y"
+typedef union YYSTYPE {
+ struct {
+ TSourceLoc line;
+ union {
+ TString *string;
+ float f;
+ int i;
+ bool b;
+ };
+ TSymbol* symbol;
+ } lex;
+ struct {
+ TSourceLoc line;
+ TOperator op;
+ union {
+ TIntermNode* intermNode;
+ TIntermNodePair nodePair;
+ TIntermTyped* intermTypedNode;
+ TIntermAggregate* intermAggregate;
+ };
+ union {
+ TPublicType type;
+ TQualifier qualifier;
+ TFunction* function;
+ TParameter param;
+ TTypeLine typeLine;
+ TTypeList* typeList;
+ };
+ } interm;
+} YYSTYPE;
+/* Line 191 of yacc.c. */
+#line 369 "glslang.tab.c"
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
+
+
+
+/* Copy the second part of user declarations. */
+#line 148 "glslang.y"
+
+#ifndef _WIN32
+ extern int yylex(YYSTYPE*, void*);
+#endif
+
+
+/* Line 214 of yacc.c. */
+#line 386 "glslang.tab.c"
+
+#if ! defined (yyoverflow) || YYERROR_VERBOSE
+
+/* The parser invokes alloca or malloc; define the necessary symbols. */
+
+# if YYSTACK_USE_ALLOCA
+# define YYSTACK_ALLOC alloca
+# else
+# ifndef YYSTACK_USE_ALLOCA
+# if defined (alloca) || defined (_ALLOCA_H)
+# define YYSTACK_ALLOC alloca
+# else
+# ifdef __GNUC__
+# define YYSTACK_ALLOC __builtin_alloca
+# endif
+# endif
+# endif
+# endif
+
+# ifdef YYSTACK_ALLOC
+ /* Pacify GCC's `empty if-body' warning. */
+# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
+# else
+# if defined (__STDC__) || defined (__cplusplus)
+# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# endif
+# define YYSTACK_ALLOC malloc
+# define YYSTACK_FREE free
+# endif
+#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
+
+
+#if (! defined (yyoverflow) \
+ && (! defined (__cplusplus) \
+ || (YYSTYPE_IS_TRIVIAL)))
+
+/* A type that is properly aligned for any stack member. */
+union yyalloc
+{
+ short yyss;
+ YYSTYPE yyvs;
+ };
+
+/* The size of the maximum gap between one aligned stack and the next. */
+# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
+
+/* The size of an array large to enough to hold all stacks, each with
+ N elements. */
+# define YYSTACK_BYTES(N) \
+ ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
+ + YYSTACK_GAP_MAXIMUM)
+
+/* Copy COUNT objects from FROM to TO. The source and destination do
+ not overlap. */
+# ifndef YYCOPY
+# if 1 < __GNUC__
+# define YYCOPY(To, From, Count) \
+ __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
+# else
+# define YYCOPY(To, From, Count) \
+ do \
+ { \
+ register YYSIZE_T yyi; \
+ for (yyi = 0; yyi < (Count); yyi++) \
+ (To)[yyi] = (From)[yyi]; \
+ } \
+ while (0)
+# endif
+# endif
+
+/* Relocate STACK from its old location to the new one. The
+ local variables YYSIZE and YYSTACKSIZE give the old and new number of
+ elements in the stack, and YYPTR gives the new location of the
+ stack. Advance YYPTR to a properly aligned location for the next
+ stack. */
+# define YYSTACK_RELOCATE(Stack) \
+ do \
+ { \
+ YYSIZE_T yynewbytes; \
+ YYCOPY (&yyptr->Stack, Stack, yysize); \
+ Stack = &yyptr->Stack; \
+ yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+ yyptr += yynewbytes / sizeof (*yyptr); \
+ } \
+ while (0)
+
+#endif
+
+#if defined (__STDC__) || defined (__cplusplus)
+ typedef signed char yysigned_char;
+#else
+ typedef short yysigned_char;
+#endif
+
+/* YYFINAL -- State number of the termination state. */
+#define YYFINAL 59
+/* YYLAST -- Last index in YYTABLE. */
+#define YYLAST 1231
+
+/* YYNTOKENS -- Number of terminals. */
+#define YYNTOKENS 93
+/* YYNNTS -- Number of nonterminals. */
+#define YYNNTS 75
+/* YYNRULES -- Number of rules. */
+#define YYNRULES 214
+/* YYNRULES -- Number of states. */
+#define YYNSTATES 331
+
+/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
+#define YYUNDEFTOK 2
+#define YYMAXUTOK 347
+
+#define YYTRANSLATE(YYX) \
+ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
+
+/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
+static const unsigned char yytranslate[] =
+{
+ 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
+ 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
+ 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
+ 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
+ 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
+ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
+ 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
+ 85, 86, 87, 88, 89, 90, 91, 92
+};
+
+#if YYDEBUG
+/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
+ YYRHS. */
+static const unsigned short yyprhs[] =
+{
+ 0, 0, 3, 5, 7, 9, 11, 13, 17, 19,
+ 24, 26, 30, 33, 36, 38, 40, 43, 46, 49,
+ 51, 54, 58, 61, 63, 65, 67, 69, 71, 73,
+ 75, 77, 79, 81, 83, 85, 87, 89, 91, 93,
+ 95, 97, 99, 102, 105, 108, 110, 112, 114, 116,
+ 118, 122, 126, 130, 132, 136, 140, 142, 146, 150,
+ 152, 156, 160, 164, 168, 170, 174, 178, 180, 184,
+ 186, 190, 192, 196, 198, 202, 204, 208, 210, 214,
+ 216, 222, 224, 228, 230, 232, 234, 236, 238, 240,
+ 242, 244, 246, 248, 250, 252, 256, 258, 261, 264,
+ 267, 269, 271, 274, 278, 282, 285, 291, 295, 298,
+ 302, 305, 306, 308, 310, 312, 314, 319, 321, 325,
+ 331, 338, 344, 346, 349, 354, 360, 365, 367, 370,
+ 372, 374, 376, 378, 380, 382, 384, 386, 388, 390,
+ 392, 394, 396, 398, 400, 402, 404, 406, 408, 410,
+ 412, 414, 416, 418, 420, 422, 424, 426, 432, 437,
+ 439, 442, 446, 448, 452, 454, 459, 461, 463, 465,
+ 467, 469, 471, 473, 475, 477, 480, 481, 482, 488,
+ 490, 492, 495, 499, 501, 504, 506, 509, 515, 519,
+ 521, 523, 528, 529, 536, 537, 546, 547, 555, 557,
+ 559, 561, 562, 565, 569, 572, 575, 578, 582, 585,
+ 587, 590, 592, 594, 595
+};
+
+/* YYRHS -- A `-1'-separated list of the rules' RHS. */
+static const short yyrhs[] =
+{
+ 164, 0, -1, 42, -1, 94, -1, 45, -1, 44,
+ -1, 46, -1, 69, 121, 70, -1, 95, -1, 96,
+ 71, 97, 72, -1, 98, -1, 96, 75, 47, -1,
+ 96, 50, -1, 96, 51, -1, 121, -1, 99, -1,
+ 101, 70, -1, 100, 70, -1, 102, 34, -1, 102,
+ -1, 102, 119, -1, 101, 76, 119, -1, 103, 69,
+ -1, 104, -1, 42, -1, 6, -1, 7, -1, 5,
+ -1, 22, -1, 23, -1, 24, -1, 16, -1, 17,
+ -1, 18, -1, 19, -1, 20, -1, 21, -1, 25,
+ -1, 26, -1, 27, -1, 43, -1, 96, -1, 50,
+ 105, -1, 51, 105, -1, 106, 105, -1, 83, -1,
+ 81, -1, 80, -1, 82, -1, 105, -1, 107, 84,
+ 105, -1, 107, 85, 105, -1, 107, 86, 105, -1,
+ 107, -1, 108, 83, 107, -1, 108, 81, 107, -1,
+ 108, -1, 109, 48, 108, -1, 109, 49, 108, -1,
+ 109, -1, 110, 87, 109, -1, 110, 88, 109, -1,
+ 110, 52, 109, -1, 110, 53, 109, -1, 110, -1,
+ 111, 54, 110, -1, 111, 55, 110, -1, 111, -1,
+ 112, 91, 111, -1, 112, -1, 113, 90, 112, -1,
+ 113, -1, 114, 89, 113, -1, 114, -1, 115, 56,
+ 114, -1, 115, -1, 116, 58, 115, -1, 116, -1,
+ 117, 57, 116, -1, 117, -1, 117, 92, 121, 77,
+ 119, -1, 118, -1, 105, 120, 119, -1, 78, -1,
+ 59, -1, 60, -1, 62, -1, 61, -1, 68, -1,
+ 63, -1, 64, -1, 65, -1, 66, -1, 67, -1,
+ 119, -1, 121, 76, 119, -1, 118, -1, 124, 79,
+ -1, 132, 79, -1, 125, 70, -1, 127, -1, 126,
+ -1, 127, 129, -1, 126, 76, 129, -1, 134, 42,
+ 69, -1, 136, 42, -1, 136, 42, 71, 122, 72,
+ -1, 135, 130, 128, -1, 130, 128, -1, 135, 130,
+ 131, -1, 130, 131, -1, -1, 28, -1, 29, -1,
+ 30, -1, 136, -1, 136, 71, 122, 72, -1, 133,
+ -1, 132, 76, 42, -1, 132, 76, 42, 71, 72,
+ -1, 132, 76, 42, 71, 122, 72, -1, 132, 76,
+ 42, 78, 142, -1, 134, -1, 134, 42, -1, 134,
+ 42, 71, 72, -1, 134, 42, 71, 122, 72, -1,
+ 134, 42, 78, 142, -1, 136, -1, 135, 136, -1,
+ 4, -1, 3, -1, 32, -1, 31, -1, 34, -1,
+ 6, -1, 7, -1, 5, -1, 22, -1, 23, -1,
+ 24, -1, 16, -1, 17, -1, 18, -1, 19, -1,
+ 20, -1, 21, -1, 25, -1, 26, -1, 27, -1,
+ 36, -1, 37, -1, 38, -1, 39, -1, 40, -1,
+ 41, -1, 137, -1, 43, -1, 33, 42, 73, 138,
+ 74, -1, 33, 73, 138, 74, -1, 139, -1, 138,
+ 139, -1, 136, 140, 79, -1, 141, -1, 140, 76,
+ 141, -1, 42, -1, 42, 71, 122, 72, -1, 119,
+ -1, 123, -1, 146, -1, 145, -1, 143, -1, 152,
+ -1, 153, -1, 156, -1, 163, -1, 73, 74, -1,
+ -1, -1, 73, 147, 151, 148, 74, -1, 150, -1,
+ 145, -1, 73, 74, -1, 73, 151, 74, -1, 144,
+ -1, 151, 144, -1, 79, -1, 121, 79, -1, 13,
+ 69, 121, 70, 154, -1, 144, 11, 144, -1, 144,
+ -1, 121, -1, 134, 42, 78, 142, -1, -1, 35,
+ 69, 157, 155, 70, 149, -1, -1, 10, 158, 144,
+ 35, 69, 121, 70, 79, -1, -1, 12, 69, 159,
+ 160, 162, 70, 149, -1, 152, -1, 143, -1, 155,
+ -1, -1, 161, 79, -1, 161, 79, 121, -1, 9,
+ 79, -1, 8, 79, -1, 15, 79, -1, 15, 121,
+ 79, -1, 14, 79, -1, 165, -1, 164, 165, -1,
+ 166, -1, 123, -1, -1, 124, 167, 150, -1
+};
+
+/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
+static const unsigned short yyrline[] =
+{
+ 0, 210, 210, 245, 248, 261, 266, 271, 277, 280,
+ 348, 351, 460, 470, 483, 491, 586, 590, 597, 601,
+ 608, 614, 623, 629, 640, 656, 657, 658, 659, 660,
+ 661, 662, 663, 664, 665, 666, 667, 668, 669, 670,
+ 671, 682, 685, 695, 705, 727, 728, 729, 730, 736,
+ 737, 746, 755, 767, 768, 776, 787, 788, 797, 809,
+ 810, 820, 830, 840, 853, 854, 864, 877, 878, 890,
+ 891, 903, 904, 916, 917, 930, 931, 944, 945, 958,
+ 959, 976, 977, 990, 991, 992, 993, 994, 995, 996,
+ 997, 998, 999, 1000, 1004, 1007, 1018, 1026, 1027, 1035,
+ 1071, 1074, 1081, 1089, 1110, 1129, 1140, 1167, 1172, 1182,
+ 1187, 1197, 1200, 1203, 1206, 1212, 1217, 1235, 1238, 1246,
+ 1254, 1262, 1284, 1288, 1297, 1306, 1315, 1405, 1408, 1425,
+ 1429, 1436, 1444, 1453, 1458, 1463, 1468, 1479, 1484, 1489,
+ 1494, 1499, 1504, 1509, 1514, 1519, 1524, 1530, 1536, 1542,
+ 1548, 1554, 1560, 1566, 1572, 1578, 1583, 1596, 1606, 1614,
+ 1617, 1632, 1650, 1654, 1660, 1665, 1681, 1685, 1689, 1690,
+ 1696, 1697, 1698, 1699, 1700, 1704, 1705, 1705, 1705, 1713,
+ 1714, 1719, 1722, 1730, 1733, 1739, 1740, 1744, 1752, 1756,
+ 1766, 1771, 1788, 1788, 1793, 1793, 1800, 1800, 1813, 1816,
+ 1822, 1825, 1831, 1835, 1842, 1849, 1856, 1863, 1874, 1883,
+ 1887, 1894, 1897, 1903, 1903
+};
+#endif
+
+#if YYDEBUG || YYERROR_VERBOSE
+/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
+ First, the terminals, then, starting at YYNTOKENS, nonterminals. */
+static const char *const yytname[] =
+{
+ "$end", "error", "$undefined", "ATTRIBUTE", "CONST_QUAL", "BOOL_TYPE",
+ "FLOAT_TYPE", "INT_TYPE", "BREAK", "CONTINUE", "DO", "ELSE", "FOR",
+ "IF", "DISCARD", "RETURN", "BVEC2", "BVEC3", "BVEC4", "IVEC2", "IVEC3",
+ "IVEC4", "VEC2", "VEC3", "VEC4", "MATRIX2", "MATRIX3", "MATRIX4",
+ "IN_QUAL", "OUT_QUAL", "INOUT_QUAL", "UNIFORM", "VARYING", "STRUCT",
+ "VOID_TYPE", "WHILE", "SAMPLER1D", "SAMPLER2D", "SAMPLER3D",
+ "SAMPLERCUBE", "SAMPLER1DSHADOW", "SAMPLER2DSHADOW", "IDENTIFIER",
+ "TYPE_NAME", "FLOATCONSTANT", "INTCONSTANT", "BOOLCONSTANT",
+ "FIELD_SELECTION", "LEFT_OP", "RIGHT_OP", "INC_OP", "DEC_OP", "LE_OP",
+ "GE_OP", "EQ_OP", "NE_OP", "AND_OP", "OR_OP", "XOR_OP", "MUL_ASSIGN",
+ "DIV_ASSIGN", "ADD_ASSIGN", "MOD_ASSIGN", "LEFT_ASSIGN", "RIGHT_ASSIGN",
+ "AND_ASSIGN", "XOR_ASSIGN", "OR_ASSIGN", "SUB_ASSIGN", "LEFT_PAREN",
+ "RIGHT_PAREN", "LEFT_BRACKET", "RIGHT_BRACKET", "LEFT_BRACE",
+ "RIGHT_BRACE", "DOT", "COMMA", "COLON", "EQUAL", "SEMICOLON", "BANG",
+ "DASH", "TILDE", "PLUS", "STAR", "SLASH", "PERCENT", "LEFT_ANGLE",
+ "RIGHT_ANGLE", "VERTICAL_BAR", "CARET", "AMPERSAND", "QUESTION",
+ "$accept", "variable_identifier", "primary_expression",
+ "postfix_expression", "integer_expression", "function_call",
+ "function_call_generic", "function_call_header_no_parameters",
+ "function_call_header_with_parameters", "function_call_header",
+ "function_identifier", "constructor_identifier", "unary_expression",
+ "unary_operator", "multiplicative_expression", "additive_expression",
+ "shift_expression", "relational_expression", "equality_expression",
+ "and_expression", "exclusive_or_expression", "inclusive_or_expression",
+ "logical_and_expression", "logical_xor_expression",
+ "logical_or_expression", "conditional_expression",
+ "assignment_expression", "assignment_operator", "expression",
+ "constant_expression", "declaration", "function_prototype",
+ "function_declarator", "function_header_with_parameters",
+ "function_header", "parameter_declarator", "parameter_declaration",
+ "parameter_qualifier", "parameter_type_specifier",
+ "init_declarator_list", "single_declaration", "fully_specified_type",
+ "type_qualifier", "type_specifier", "struct_specifier",
+ "struct_declaration_list", "struct_declaration",
+ "struct_declarator_list", "struct_declarator", "initializer",
+ "declaration_statement", "statement", "simple_statement",
+ "compound_statement", "@1", "@2", "statement_no_new_scope",
+ "compound_statement_no_new_scope", "statement_list",
+ "expression_statement", "selection_statement",
+ "selection_rest_statement", "condition", "iteration_statement", "@3",
+ "@4", "@5", "for_init_statement", "conditionopt", "for_rest_statement",
+ "jump_statement", "translation_unit", "external_declaration",
+ "function_definition", "@6", 0
+};
+#endif
+
+# ifdef YYPRINT
+/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
+ token YYLEX-NUM. */
+static const unsigned short yytoknum[] =
+{
+ 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
+ 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
+ 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
+ 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
+ 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
+ 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
+ 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
+ 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
+ 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
+ 345, 346, 347
+};
+# endif
+
+/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
+static const unsigned char yyr1[] =
+{
+ 0, 93, 94, 95, 95, 95, 95, 95, 96, 96,
+ 96, 96, 96, 96, 97, 98, 99, 99, 100, 100,
+ 101, 101, 102, 103, 103, 104, 104, 104, 104, 104,
+ 104, 104, 104, 104, 104, 104, 104, 104, 104, 104,
+ 104, 105, 105, 105, 105, 106, 106, 106, 106, 107,
+ 107, 107, 107, 108, 108, 108, 109, 109, 109, 110,
+ 110, 110, 110, 110, 111, 111, 111, 112, 112, 113,
+ 113, 114, 114, 115, 115, 116, 116, 117, 117, 118,
+ 118, 119, 119, 120, 120, 120, 120, 120, 120, 120,
+ 120, 120, 120, 120, 121, 121, 122, 123, 123, 124,
+ 125, 125, 126, 126, 127, 128, 128, 129, 129, 129,
+ 129, 130, 130, 130, 130, 131, 131, 132, 132, 132,
+ 132, 132, 133, 133, 133, 133, 133, 134, 134, 135,
+ 135, 135, 135, 136, 136, 136, 136, 136, 136, 136,
+ 136, 136, 136, 136, 136, 136, 136, 136, 136, 136,
+ 136, 136, 136, 136, 136, 136, 136, 137, 137, 138,
+ 138, 139, 140, 140, 141, 141, 142, 143, 144, 144,
+ 145, 145, 145, 145, 145, 146, 147, 148, 146, 149,
+ 149, 150, 150, 151, 151, 152, 152, 153, 154, 154,
+ 155, 155, 157, 156, 158, 156, 159, 156, 160, 160,
+ 161, 161, 162, 162, 163, 163, 163, 163, 163, 164,
+ 164, 165, 165, 167, 166
+};
+
+/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
+static const unsigned char yyr2[] =
+{
+ 0, 2, 1, 1, 1, 1, 1, 3, 1, 4,
+ 1, 3, 2, 2, 1, 1, 2, 2, 2, 1,
+ 2, 3, 2, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 2, 2, 2, 1, 1, 1, 1, 1,
+ 3, 3, 3, 1, 3, 3, 1, 3, 3, 1,
+ 3, 3, 3, 3, 1, 3, 3, 1, 3, 1,
+ 3, 1, 3, 1, 3, 1, 3, 1, 3, 1,
+ 5, 1, 3, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 3, 1, 2, 2, 2,
+ 1, 1, 2, 3, 3, 2, 5, 3, 2, 3,
+ 2, 0, 1, 1, 1, 1, 4, 1, 3, 5,
+ 6, 5, 1, 2, 4, 5, 4, 1, 2, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 5, 4, 1,
+ 2, 3, 1, 3, 1, 4, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 2, 0, 0, 5, 1,
+ 1, 2, 3, 1, 2, 1, 2, 5, 3, 1,
+ 1, 4, 0, 6, 0, 8, 0, 7, 1, 1,
+ 1, 0, 2, 3, 2, 2, 2, 3, 2, 1,
+ 2, 1, 1, 0, 3
+};
+
+/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
+ STATE-NUM when YYTABLE doesn't specify something else to do. Zero
+ means the default is an error. */
+static const unsigned char yydefact[] =
+{
+ 0, 130, 129, 136, 134, 135, 140, 141, 142, 143,
+ 144, 145, 137, 138, 139, 146, 147, 148, 132, 131,
+ 0, 133, 149, 150, 151, 152, 153, 154, 156, 212,
+ 213, 0, 101, 111, 0, 117, 122, 0, 127, 155,
+ 0, 209, 211, 0, 0, 97, 0, 99, 111, 112,
+ 113, 114, 102, 0, 111, 0, 98, 123, 128, 1,
+ 210, 0, 0, 0, 159, 0, 214, 103, 108, 110,
+ 115, 0, 118, 104, 0, 0, 0, 164, 0, 162,
+ 158, 160, 136, 134, 135, 0, 0, 194, 0, 0,
+ 0, 0, 140, 141, 142, 143, 144, 145, 137, 138,
+ 139, 146, 147, 148, 0, 2, 156, 5, 4, 6,
+ 0, 0, 0, 176, 181, 185, 47, 46, 48, 45,
+ 3, 8, 41, 10, 15, 0, 0, 19, 0, 23,
+ 49, 0, 53, 56, 59, 64, 67, 69, 71, 73,
+ 75, 77, 79, 81, 94, 0, 167, 0, 170, 183,
+ 169, 168, 0, 171, 172, 173, 174, 105, 0, 107,
+ 109, 0, 0, 27, 25, 26, 31, 32, 33, 34,
+ 35, 36, 28, 29, 30, 37, 38, 39, 40, 124,
+ 49, 96, 0, 166, 126, 157, 0, 0, 161, 205,
+ 204, 0, 196, 0, 208, 206, 0, 192, 42, 43,
+ 0, 175, 0, 12, 13, 0, 0, 17, 16, 0,
+ 18, 20, 22, 84, 85, 87, 86, 89, 90, 91,
+ 92, 93, 88, 83, 0, 44, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 186, 182, 184,
+ 0, 0, 119, 0, 121, 125, 0, 163, 0, 0,
+ 0, 207, 0, 7, 177, 0, 14, 11, 21, 82,
+ 50, 51, 52, 55, 54, 57, 58, 62, 63, 60,
+ 61, 65, 66, 68, 70, 72, 74, 76, 78, 0,
+ 95, 0, 116, 120, 165, 0, 199, 198, 201, 0,
+ 190, 0, 0, 0, 9, 0, 106, 0, 200, 0,
+ 0, 189, 187, 0, 0, 178, 80, 0, 202, 0,
+ 0, 0, 180, 193, 179, 0, 203, 197, 188, 191,
+ 195
+};
+
+/* YYDEFGOTO[NTERM-NUM]. */
+static const short yydefgoto[] =
+{
+ -1, 120, 121, 122, 265, 123, 124, 125, 126, 127,
+ 128, 129, 130, 131, 132, 133, 134, 135, 136, 137,
+ 138, 139, 140, 141, 142, 143, 144, 224, 145, 182,
+ 146, 147, 31, 32, 33, 68, 52, 53, 69, 34,
+ 35, 36, 37, 38, 39, 63, 64, 78, 79, 184,
+ 148, 149, 150, 151, 202, 303, 323, 324, 152, 153,
+ 154, 312, 302, 155, 262, 191, 259, 298, 309, 310,
+ 156, 40, 41, 42, 46
+};
+
+/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+ STATE-NUM. */
+#define YYPACT_NINF -297
+static const short yypact[] =
+{
+ 1149, -297, -297, -297, -297, -297, -297, -297, -297, -297,
+ -297, -297, -297, -297, -297, -297, -297, -297, -297, -297,
+ -27, -297, -297, -297, -297, -297, -297, -297, -297, -297,
+ -42, -28, -32, 4, 18, -297, 19, 1188, -297, -297,
+ 1108, -297, -297, -10, 1188, -297, -3, -297, 36, -297,
+ -297, -297, -297, 1188, 83, 33, -297, -9, -297, -297,
+ -297, 1188, 39, 1025, -297, 235, -297, -297, -297, -297,
+ -18, 1188, -52, -297, 685, 957, 1064, -17, 20, -297,
+ -297, -297, 29, 45, 63, 21, 23, -297, 75, 77,
+ 66, 753, 78, 79, 81, 82, 84, 85, 87, 89,
+ 90, 91, 93, 94, 95, 96, 97, -297, -297, -297,
+ 957, 957, 957, 120, -297, -297, -297, -297, -297, -297,
+ -297, -297, 5, -297, -297, 98, 1, 821, 100, -297,
+ 57, 957, 42, -56, 37, -40, 76, 61, 80, 106,
+ 111, 138, -41, -297, -297, 30, -297, -42, -297, -297,
+ -297, -297, 316, -297, -297, -297, -297, 127, 957, -297,
+ -297, 889, 957, -297, -297, -297, -297, -297, -297, -297,
+ -297, -297, -297, -297, -297, -297, -297, -297, -297, -297,
+ -297, -297, 128, -297, -297, -297, 957, 39, -297, -297,
+ -297, 397, -297, 957, -297, -297, 31, -297, -297, -297,
+ 3, -297, 397, -297, -297, 957, 152, -297, -297, 957,
+ -297, -297, -297, -297, -297, -297, -297, -297, -297, -297,
+ -297, -297, -297, -297, 957, -297, 957, 957, 957, 957,
+ 957, 957, 957, 957, 957, 957, 957, 957, 957, 957,
+ 957, 957, 957, 957, 957, 957, 957, -297, -297, -297,
+ 957, 129, -297, 130, -297, -297, 131, -297, 169, 549,
+ 12, -297, 617, -297, 397, 133, 134, -297, -297, -297,
+ -297, -297, -297, 42, 42, -56, -56, 37, 37, 37,
+ 37, -40, -40, 76, 61, 80, 106, 111, 138, 60,
+ -297, 135, -297, -297, -297, 137, -297, -297, 617, 397,
+ 134, 167, 141, 140, -297, 957, -297, 957, -297, 136,
+ 142, 205, -297, 143, 478, -297, -297, 13, 957, 478,
+ 397, 957, -297, -297, -297, 139, 134, -297, -297, -297,
+ -297
+};
+
+/* YYPGOTO[NTERM-NUM]. */
+static const short yypgoto[] =
+{
+ -297, -297, -297, -297, -297, -297, -297, -297, -297, -297,
+ -297, -297, -53, -297, -91, -89, -143, -97, -20, -16,
+ -21, -15, -14, -22, -297, -57, -75, -297, -90, -155,
+ 9, 10, -297, -297, -297, 154, 175, 172, 160, -297,
+ -297, -257, -19, -33, -297, 171, -4, -297, 46, -160,
+ -25, -107, -296, -297, -297, -297, -84, 190, 35, 6,
+ -297, -297, -35, -297, -297, -297, -297, -297, -297, -297,
+ -297, -297, 224, -297, -297
+};
+
+/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
+ positive, shift that token. If negative, reduce the rule which
+ number is the opposite. If zero, do what YYDEFACT says.
+ If YYTABLE_NINF, syntax error. */
+#define YYTABLE_NINF -101
+static const short yytable[] =
+{
+ 183, 196, 254, 251, 58, 301, 253, 1, 2, 29,
+ 30, 62, 233, 234, 54, 43, 244, 181, 322, 161,
+ 70, 180, 200, 322, 157, 229, 162, 230, 62, 54,
+ 62, 256, 49, 50, 51, 18, 19, 45, 70, 1,
+ 2, 301, 47, 62, 48, 249, 44, 235, 236, 29,
+ 30, 245, 211, 158, 186, 203, 204, 198, 199, 81,
+ 73, 57, 74, 61, 49, 50, 51, 18, 19, 75,
+ 65, 208, 81, 263, -100, 72, 205, 209, 225, 246,
+ 206, 77, 299, 325, 258, 231, 232, 183, 246, 246,
+ 277, 278, 279, 280, 55, 291, 187, 56, -27, 188,
+ 189, 181, 190, 260, 181, 180, 246, 246, 180, 247,
+ 261, 49, 50, 51, -25, 266, 213, 214, 215, 216,
+ 217, 218, 219, 220, 221, 222, 226, 227, 228, 181,
+ 237, 238, -26, 180, 268, 223, 246, 305, 273, 274,
+ 281, 282, 275, 276, 192, 194, 193, -31, -32, 269,
+ -33, -34, 239, -35, -36, 289, -28, 249, -29, -30,
+ -37, 329, -38, -39, 197, -24, -40, 242, 207, 212,
+ 240, 290, 300, 270, 271, 272, 180, 180, 180, 180,
+ 180, 180, 180, 180, 180, 180, 180, 180, 180, 180,
+ 180, 180, 311, 181, 201, 241, 243, 180, 250, 267,
+ 255, 292, 293, 294, 295, 304, 307, 306, 300, 313,
+ 246, 314, 319, 328, 315, 318, 320, 317, 330, 283,
+ 285, 321, 288, 67, 284, 159, 71, 286, 326, 287,
+ 316, 160, 76, 257, 296, 327, 66, 264, 1, 2,
+ 82, 83, 84, 85, 86, 87, 183, 88, 89, 90,
+ 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,
+ 101, 102, 103, 308, 60, 297, 18, 19, 20, 21,
+ 104, 22, 23, 24, 25, 26, 27, 105, 106, 107,
+ 108, 109, 0, 0, 0, 110, 111, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 112, 0, 0, 0, 113, 114,
+ 0, 0, 0, 0, 115, 116, 117, 118, 119, 1,
+ 2, 82, 83, 84, 85, 86, 87, 0, 88, 89,
+ 90, 91, 92, 93, 94, 95, 96, 97, 98, 99,
+ 100, 101, 102, 103, 0, 0, 0, 18, 19, 20,
+ 21, 104, 22, 23, 24, 25, 26, 27, 105, 106,
+ 107, 108, 109, 0, 0, 0, 110, 111, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 112, 0, 0, 0, 113,
+ 248, 0, 0, 0, 0, 115, 116, 117, 118, 119,
+ 1, 2, 82, 83, 84, 85, 86, 87, 0, 88,
+ 89, 90, 91, 92, 93, 94, 95, 96, 97, 98,
+ 99, 100, 101, 102, 103, 0, 0, 0, 18, 19,
+ 20, 21, 104, 22, 23, 24, 25, 26, 27, 105,
+ 106, 107, 108, 109, 0, 0, 0, 110, 111, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 112, 0, 0, 0,
+ 113, 0, 0, 0, 0, 0, 115, 116, 117, 118,
+ 119, 1, 2, 82, 83, 84, 85, 86, 87, 0,
+ 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
+ 98, 99, 100, 101, 102, 103, 0, 0, 0, 18,
+ 19, 20, 21, 104, 22, 23, 24, 25, 26, 27,
+ 105, 106, 107, 108, 109, 0, 0, 0, 110, 111,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 112, 0, 0,
+ 0, 65, 1, 2, 82, 83, 84, 115, 116, 117,
+ 118, 119, 0, 0, 0, 92, 93, 94, 95, 96,
+ 97, 98, 99, 100, 101, 102, 103, 0, 0, 0,
+ 18, 19, 20, 21, 0, 22, 23, 24, 25, 26,
+ 27, 105, 106, 107, 108, 109, 0, 0, 0, 110,
+ 111, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 112, 0,
+ 1, 2, 82, 83, 84, 0, 0, 0, 115, 116,
+ 117, 118, 119, 92, 93, 94, 95, 96, 97, 98,
+ 99, 100, 101, 102, 103, 0, 0, 0, 18, 19,
+ 20, 21, 0, 22, 23, 24, 25, 26, 27, 105,
+ 106, 107, 108, 109, 0, 0, 0, 110, 111, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 112, 0, 0, 0,
+ 163, 164, 165, 0, 0, 0, 0, 116, 117, 118,
+ 119, 166, 167, 168, 169, 170, 171, 172, 173, 174,
+ 175, 176, 177, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 105, 178, 107,
+ 108, 109, 0, 0, 0, 110, 111, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 112, 0, 0, 179, 163, 164,
+ 165, 0, 0, 0, 0, 116, 117, 118, 119, 166,
+ 167, 168, 169, 170, 171, 172, 173, 174, 175, 176,
+ 177, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 105, 178, 107, 108, 109,
+ 0, 0, 0, 110, 111, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 112, 0, 0, 0, 163, 164, 165, 0,
+ 0, 0, 195, 116, 117, 118, 119, 166, 167, 168,
+ 169, 170, 171, 172, 173, 174, 175, 176, 177, 0,
+ 0, 0, 0, 0, 0, 210, 0, 0, 0, 0,
+ 0, 0, 0, 105, 178, 107, 108, 109, 0, 0,
+ 0, 110, 111, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 112, 0, 0, 0, 163, 164, 165, 0, 0, 0,
+ 0, 116, 117, 118, 119, 166, 167, 168, 169, 170,
+ 171, 172, 173, 174, 175, 176, 177, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 105, 178, 107, 108, 109, 0, 0, 0, 110,
+ 111, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 112, 0,
+ 0, 252, 163, 164, 165, 0, 0, 0, 0, 116,
+ 117, 118, 119, 166, 167, 168, 169, 170, 171, 172,
+ 173, 174, 175, 176, 177, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 105,
+ 178, 107, 108, 109, 0, 0, 0, 110, 111, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 112, 0, 0, 0,
+ 3, 4, 5, 0, 0, 0, 0, 116, 117, 118,
+ 119, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 0, 0, 0, 0, 0, 20, 21,
+ 0, 22, 23, 24, 25, 26, 27, 0, 28, 3,
+ 4, 5, 0, 0, 0, 0, 0, 0, 0, 0,
+ 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 0, 0, 0, 0, 0, 20, 21, 80,
+ 22, 23, 24, 25, 26, 27, 0, 28, 59, 0,
+ 0, 1, 2, 3, 4, 5, 0, 0, 0, 0,
+ 0, 0, 0, 0, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 0, 0, 185, 18,
+ 19, 20, 21, 0, 22, 23, 24, 25, 26, 27,
+ 0, 28, 1, 2, 3, 4, 5, 0, 0, 0,
+ 0, 0, 0, 0, 0, 6, 7, 8, 9, 10,
+ 11, 12, 13, 14, 15, 16, 17, 0, 0, 0,
+ 18, 19, 20, 21, 0, 22, 23, 24, 25, 26,
+ 27, 0, 28, 3, 4, 5, 0, 0, 0, 0,
+ 0, 0, 0, 0, 6, 7, 8, 9, 10, 11,
+ 12, 13, 14, 15, 16, 17, 0, 0, 0, 0,
+ 0, 20, 21, 0, 22, 23, 24, 25, 26, 27,
+ 0, 28
+};
+
+static const short yycheck[] =
+{
+ 75, 91, 162, 158, 37, 262, 161, 3, 4, 0,
+ 0, 44, 52, 53, 33, 42, 57, 74, 314, 71,
+ 53, 74, 112, 319, 42, 81, 78, 83, 61, 48,
+ 63, 186, 28, 29, 30, 31, 32, 79, 71, 3,
+ 4, 298, 70, 76, 76, 152, 73, 87, 88, 40,
+ 40, 92, 127, 71, 71, 50, 51, 110, 111, 63,
+ 69, 42, 71, 73, 28, 29, 30, 31, 32, 78,
+ 73, 70, 76, 70, 70, 42, 71, 76, 131, 76,
+ 75, 42, 70, 70, 191, 48, 49, 162, 76, 76,
+ 233, 234, 235, 236, 76, 250, 76, 79, 69, 79,
+ 79, 158, 79, 193, 161, 158, 76, 76, 161, 79,
+ 79, 28, 29, 30, 69, 205, 59, 60, 61, 62,
+ 63, 64, 65, 66, 67, 68, 84, 85, 86, 186,
+ 54, 55, 69, 186, 209, 78, 76, 77, 229, 230,
+ 237, 238, 231, 232, 69, 79, 69, 69, 69, 224,
+ 69, 69, 91, 69, 69, 245, 69, 264, 69, 69,
+ 69, 321, 69, 69, 69, 69, 69, 56, 70, 69,
+ 90, 246, 262, 226, 227, 228, 229, 230, 231, 232,
+ 233, 234, 235, 236, 237, 238, 239, 240, 241, 242,
+ 243, 244, 299, 250, 74, 89, 58, 250, 71, 47,
+ 72, 72, 72, 72, 35, 72, 69, 72, 298, 42,
+ 76, 70, 70, 320, 74, 79, 11, 307, 79, 239,
+ 241, 78, 244, 48, 240, 71, 54, 242, 318, 243,
+ 305, 71, 61, 187, 259, 319, 46, 202, 3, 4,
+ 5, 6, 7, 8, 9, 10, 321, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, 298, 40, 259, 31, 32, 33, 34,
+ 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
+ 45, 46, -1, -1, -1, 50, 51, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 69, -1, -1, -1, 73, 74,
+ -1, -1, -1, -1, 79, 80, 81, 82, 83, 3,
+ 4, 5, 6, 7, 8, 9, 10, -1, 12, 13,
+ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, -1, -1, -1, 31, 32, 33,
+ 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
+ 44, 45, 46, -1, -1, -1, 50, 51, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 69, -1, -1, -1, 73,
+ 74, -1, -1, -1, -1, 79, 80, 81, 82, 83,
+ 3, 4, 5, 6, 7, 8, 9, 10, -1, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
+ 23, 24, 25, 26, 27, -1, -1, -1, 31, 32,
+ 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
+ 43, 44, 45, 46, -1, -1, -1, 50, 51, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 69, -1, -1, -1,
+ 73, -1, -1, -1, -1, -1, 79, 80, 81, 82,
+ 83, 3, 4, 5, 6, 7, 8, 9, 10, -1,
+ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
+ 22, 23, 24, 25, 26, 27, -1, -1, -1, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
+ 42, 43, 44, 45, 46, -1, -1, -1, 50, 51,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 69, -1, -1,
+ -1, 73, 3, 4, 5, 6, 7, 79, 80, 81,
+ 82, 83, -1, -1, -1, 16, 17, 18, 19, 20,
+ 21, 22, 23, 24, 25, 26, 27, -1, -1, -1,
+ 31, 32, 33, 34, -1, 36, 37, 38, 39, 40,
+ 41, 42, 43, 44, 45, 46, -1, -1, -1, 50,
+ 51, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, 69, -1,
+ 3, 4, 5, 6, 7, -1, -1, -1, 79, 80,
+ 81, 82, 83, 16, 17, 18, 19, 20, 21, 22,
+ 23, 24, 25, 26, 27, -1, -1, -1, 31, 32,
+ 33, 34, -1, 36, 37, 38, 39, 40, 41, 42,
+ 43, 44, 45, 46, -1, -1, -1, 50, 51, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 69, -1, -1, -1,
+ 5, 6, 7, -1, -1, -1, -1, 80, 81, 82,
+ 83, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, 42, 43, 44,
+ 45, 46, -1, -1, -1, 50, 51, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, 69, -1, -1, 72, 5, 6,
+ 7, -1, -1, -1, -1, 80, 81, 82, 83, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
+ 27, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, 42, 43, 44, 45, 46,
+ -1, -1, -1, 50, 51, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, 69, -1, -1, -1, 5, 6, 7, -1,
+ -1, -1, 79, 80, 81, 82, 83, 16, 17, 18,
+ 19, 20, 21, 22, 23, 24, 25, 26, 27, -1,
+ -1, -1, -1, -1, -1, 34, -1, -1, -1, -1,
+ -1, -1, -1, 42, 43, 44, 45, 46, -1, -1,
+ -1, 50, 51, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ 69, -1, -1, -1, 5, 6, 7, -1, -1, -1,
+ -1, 80, 81, 82, 83, 16, 17, 18, 19, 20,
+ 21, 22, 23, 24, 25, 26, 27, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, 42, 43, 44, 45, 46, -1, -1, -1, 50,
+ 51, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, 69, -1,
+ -1, 72, 5, 6, 7, -1, -1, -1, -1, 80,
+ 81, 82, 83, 16, 17, 18, 19, 20, 21, 22,
+ 23, 24, 25, 26, 27, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, 42,
+ 43, 44, 45, 46, -1, -1, -1, 50, 51, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, 69, -1, -1, -1,
+ 5, 6, 7, -1, -1, -1, -1, 80, 81, 82,
+ 83, 16, 17, 18, 19, 20, 21, 22, 23, 24,
+ 25, 26, 27, -1, -1, -1, -1, -1, 33, 34,
+ -1, 36, 37, 38, 39, 40, 41, -1, 43, 5,
+ 6, 7, -1, -1, -1, -1, -1, -1, -1, -1,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
+ 26, 27, -1, -1, -1, -1, -1, 33, 34, 74,
+ 36, 37, 38, 39, 40, 41, -1, 43, 0, -1,
+ -1, 3, 4, 5, 6, 7, -1, -1, -1, -1,
+ -1, -1, -1, -1, 16, 17, 18, 19, 20, 21,
+ 22, 23, 24, 25, 26, 27, -1, -1, 74, 31,
+ 32, 33, 34, -1, 36, 37, 38, 39, 40, 41,
+ -1, 43, 3, 4, 5, 6, 7, -1, -1, -1,
+ -1, -1, -1, -1, -1, 16, 17, 18, 19, 20,
+ 21, 22, 23, 24, 25, 26, 27, -1, -1, -1,
+ 31, 32, 33, 34, -1, 36, 37, 38, 39, 40,
+ 41, -1, 43, 5, 6, 7, -1, -1, -1, -1,
+ -1, -1, -1, -1, 16, 17, 18, 19, 20, 21,
+ 22, 23, 24, 25, 26, 27, -1, -1, -1, -1,
+ -1, 33, 34, -1, 36, 37, 38, 39, 40, 41,
+ -1, 43
+};
+
+/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+ symbol of state STATE-NUM. */
+static const unsigned char yystos[] =
+{
+ 0, 3, 4, 5, 6, 7, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, 26, 27, 31, 32,
+ 33, 34, 36, 37, 38, 39, 40, 41, 43, 123,
+ 124, 125, 126, 127, 132, 133, 134, 135, 136, 137,
+ 164, 165, 166, 42, 73, 79, 167, 70, 76, 28,
+ 29, 30, 129, 130, 135, 76, 79, 42, 136, 0,
+ 165, 73, 136, 138, 139, 73, 150, 129, 128, 131,
+ 136, 130, 42, 69, 71, 78, 138, 42, 140, 141,
+ 74, 139, 5, 6, 7, 8, 9, 10, 12, 13,
+ 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
+ 24, 25, 26, 27, 35, 42, 43, 44, 45, 46,
+ 50, 51, 69, 73, 74, 79, 80, 81, 82, 83,
+ 94, 95, 96, 98, 99, 100, 101, 102, 103, 104,
+ 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
+ 115, 116, 117, 118, 119, 121, 123, 124, 143, 144,
+ 145, 146, 151, 152, 153, 156, 163, 42, 71, 128,
+ 131, 71, 78, 5, 6, 7, 16, 17, 18, 19,
+ 20, 21, 22, 23, 24, 25, 26, 27, 43, 72,
+ 105, 118, 122, 119, 142, 74, 71, 76, 79, 79,
+ 79, 158, 69, 69, 79, 79, 121, 69, 105, 105,
+ 121, 74, 147, 50, 51, 71, 75, 70, 70, 76,
+ 34, 119, 69, 59, 60, 61, 62, 63, 64, 65,
+ 66, 67, 68, 78, 120, 105, 84, 85, 86, 81,
+ 83, 48, 49, 52, 53, 87, 88, 54, 55, 91,
+ 90, 89, 56, 58, 57, 92, 76, 79, 74, 144,
+ 71, 122, 72, 122, 142, 72, 122, 141, 144, 159,
+ 121, 79, 157, 70, 151, 97, 121, 47, 119, 119,
+ 105, 105, 105, 107, 107, 108, 108, 109, 109, 109,
+ 109, 110, 110, 111, 112, 113, 114, 115, 116, 121,
+ 119, 122, 72, 72, 72, 35, 143, 152, 160, 70,
+ 121, 134, 155, 148, 72, 77, 72, 69, 155, 161,
+ 162, 144, 154, 42, 70, 74, 119, 121, 79, 70,
+ 11, 78, 145, 149, 150, 70, 121, 149, 144, 142,
+ 79
+};
+
+#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
+# define YYSIZE_T __SIZE_TYPE__
+#endif
+#if ! defined (YYSIZE_T) && defined (size_t)
+# define YYSIZE_T size_t
+#endif
+#if ! defined (YYSIZE_T)
+# if defined (__STDC__) || defined (__cplusplus)
+# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
+# define YYSIZE_T size_t
+# endif
+#endif
+#if ! defined (YYSIZE_T)
+# define YYSIZE_T unsigned int
+#endif
+
+#define yyerrok (yyerrstatus = 0)
+#define yyclearin (yychar = YYEMPTY)
+#define YYEMPTY (-2)
+#define YYEOF 0
+
+#define YYACCEPT goto yyacceptlab
+#define YYABORT goto yyabortlab
+#define YYERROR goto yyerrlab1
+
+
+/* Like YYERROR except do call yyerror. This remains here temporarily
+ to ease the transition to the new meaning of YYERROR, for GCC.
+ Once GCC version 2 has supplanted version 1, this can go. */
+
+#define YYFAIL goto yyerrlab
+
+#define YYRECOVERING() (!!yyerrstatus)
+
+#define YYBACKUP(Token, Value) \
+do \
+ if (yychar == YYEMPTY && yylen == 1) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ yytoken = YYTRANSLATE (yychar); \
+ YYPOPSTACK; \
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror ("syntax error: cannot back up");\
+ YYERROR; \
+ } \
+while (0)
+
+#define YYTERROR 1
+#define YYERRCODE 256
+
+/* YYLLOC_DEFAULT -- Compute the default location (before the actions
+ are run). */
+
+#ifndef YYLLOC_DEFAULT
+# define YYLLOC_DEFAULT(Current, Rhs, N) \
+ Current.first_line = Rhs[1].first_line; \
+ Current.first_column = Rhs[1].first_column; \
+ Current.last_line = Rhs[N].last_line; \
+ Current.last_column = Rhs[N].last_column;
+#endif
+
+/* YYLEX -- calling `yylex' with the right arguments. */
+
+#ifdef YYLEX_PARAM
+# define YYLEX yylex (&yylval, YYLEX_PARAM)
+#else
+# define YYLEX yylex (&yylval)
+#endif
+
+/* Enable debugging if requested. */
+#if YYDEBUG
+
+# ifndef YYFPRINTF
+# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
+# define YYFPRINTF fprintf
+# endif
+
+# define YYDPRINTF(Args) \
+do { \
+ if (yydebug) \
+ YYFPRINTF Args; \
+} while (0)
+
+# define YYDSYMPRINT(Args) \
+do { \
+ if (yydebug) \
+ yysymprint Args; \
+} while (0)
+
+# define YYDSYMPRINTF(Title, Token, Value, Location) \
+do { \
+ if (yydebug) \
+ { \
+ YYFPRINTF (stderr, "%s ", Title); \
+ yysymprint (stderr, \
+ Token, Value); \
+ YYFPRINTF (stderr, "\n"); \
+ } \
+} while (0)
+
+/*------------------------------------------------------------------.
+| yy_stack_print -- Print the state stack from its BOTTOM up to its |
+| TOP (cinluded). |
+`------------------------------------------------------------------*/
+
+#if defined (__STDC__) || defined (__cplusplus)
+static void
+yy_stack_print (short *bottom, short *top)
+#else
+static void
+yy_stack_print (bottom, top)
+ short *bottom;
+ short *top;
+#endif
+{
+ YYFPRINTF (stderr, "Stack now");
+ for (/* Nothing. */; bottom <= top; ++bottom)
+ YYFPRINTF (stderr, " %d", *bottom);
+ YYFPRINTF (stderr, "\n");
+}
+
+# define YY_STACK_PRINT(Bottom, Top) \
+do { \
+ if (yydebug) \
+ yy_stack_print ((Bottom), (Top)); \
+} while (0)
+
+
+/*------------------------------------------------.
+| Report that the YYRULE is going to be reduced. |
+`------------------------------------------------*/
+
+#if defined (__STDC__) || defined (__cplusplus)
+static void
+yy_reduce_print (int yyrule)
+#else
+static void
+yy_reduce_print (yyrule)
+ int yyrule;
+#endif
+{
+ int yyi;
+ unsigned int yylineno = yyrline[yyrule];
+ YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
+ yyrule - 1, yylineno);
+ /* Print the symbols being reduced, and their result. */
+ for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
+ YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
+ YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
+}
+
+# define YY_REDUCE_PRINT(Rule) \
+do { \
+ if (yydebug) \
+ yy_reduce_print (Rule); \
+} while (0)
+
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
+int yydebug;
+#else /* !YYDEBUG */
+# define YYDPRINTF(Args)
+# define YYDSYMPRINT(Args)
+# define YYDSYMPRINTF(Title, Token, Value, Location)
+# define YY_STACK_PRINT(Bottom, Top)
+# define YY_REDUCE_PRINT(Rule)
+#endif /* !YYDEBUG */
+
+
+/* YYINITDEPTH -- initial size of the parser's stacks. */
+#ifndef YYINITDEPTH
+# define YYINITDEPTH 200
+#endif
+
+/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
+ if the built-in stack extension method is used).
+
+ Do not make this value too large; the results are undefined if
+ SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
+ evaluated with infinite-precision integer arithmetic. */
+
+#if YYMAXDEPTH == 0
+# undef YYMAXDEPTH
+#endif
+
+#ifndef YYMAXDEPTH
+# define YYMAXDEPTH 10000
+#endif
+
+
+
+#if YYERROR_VERBOSE
+
+# ifndef yystrlen
+# if defined (__GLIBC__) && defined (_STRING_H)
+# define yystrlen strlen
+# else
+/* Return the length of YYSTR. */
+static YYSIZE_T
+# if defined (__STDC__) || defined (__cplusplus)
+yystrlen (const char *yystr)
+# else
+yystrlen (yystr)
+ const char *yystr;
+# endif
+{
+ register const char *yys = yystr;
+
+ while (*yys++ != '\0')
+ continue;
+
+ return yys - yystr - 1;
+}
+# endif
+# endif
+
+# ifndef yystpcpy
+# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
+# define yystpcpy stpcpy
+# else
+/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
+ YYDEST. */
+static char *
+# if defined (__STDC__) || defined (__cplusplus)
+yystpcpy (char *yydest, const char *yysrc)
+# else
+yystpcpy (yydest, yysrc)
+ char *yydest;
+ const char *yysrc;
+# endif
+{
+ register char *yyd = yydest;
+ register const char *yys = yysrc;
+
+ while ((*yyd++ = *yys++) != '\0')
+ continue;
+
+ return yyd - 1;
+}
+# endif
+# endif
+
+#endif /* !YYERROR_VERBOSE */
+
+
+
+#if YYDEBUG
+/*--------------------------------.
+| Print this symbol on YYOUTPUT. |
+`--------------------------------*/
+
+#if defined (__STDC__) || defined (__cplusplus)
+static void
+yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
+#else
+static void
+yysymprint (yyoutput, yytype, yyvaluep)
+ FILE *yyoutput;
+ int yytype;
+ YYSTYPE *yyvaluep;
+#endif
+{
+ /* Pacify ``unused variable'' warnings. */
+ (void) yyvaluep;
+
+ if (yytype < YYNTOKENS)
+ {
+ YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
+# ifdef YYPRINT
+ YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
+# endif
+ }
+ else
+ YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+
+ switch (yytype)
+ {
+ default:
+ break;
+ }
+ YYFPRINTF (yyoutput, ")");
+}
+
+#endif /* ! YYDEBUG */
+/*-----------------------------------------------.
+| Release the memory associated to this symbol. |
+`-----------------------------------------------*/
+
+#if defined (__STDC__) || defined (__cplusplus)
+static void
+yydestruct (int yytype, YYSTYPE *yyvaluep)
+#else
+static void
+yydestruct (yytype, yyvaluep)
+ int yytype;
+ YYSTYPE *yyvaluep;
+#endif
+{
+ /* Pacify ``unused variable'' warnings. */
+ (void) yyvaluep;
+
+ switch (yytype)
+ {
+
+ default:
+ break;
+ }
+}
+
+
+/* Prevent warnings from -Wmissing-prototypes. */
+
+#ifdef YYPARSE_PARAM
+# if defined (__STDC__) || defined (__cplusplus)
+int yyparse (void *YYPARSE_PARAM);
+# else
+int yyparse ();
+# endif
+#else /* ! YYPARSE_PARAM */
+#if defined (__STDC__) || defined (__cplusplus)
+int yyparse (void);
+#else
+int yyparse ();
+#endif
+#endif /* ! YYPARSE_PARAM */
+
+
+
+
+
+
+/*----------.
+| yyparse. |
+`----------*/
+
+#ifdef YYPARSE_PARAM
+# if defined (__STDC__) || defined (__cplusplus)
+int yyparse (void *YYPARSE_PARAM)
+# else
+int yyparse (YYPARSE_PARAM)
+ void *YYPARSE_PARAM;
+# endif
+#else /* ! YYPARSE_PARAM */
+#if defined (__STDC__) || defined (__cplusplus)
+int
+yyparse (void)
+#else
+int
+yyparse ()
+
+#endif
+#endif
+{
+ /* The lookahead symbol. */
+int yychar;
+
+/* The semantic value of the lookahead symbol. */
+YYSTYPE yylval;
+
+/* Number of syntax errors so far. */
+int yynerrs;
+
+ register int yystate;
+ register int yyn;
+ int yyresult;
+ /* Number of tokens to shift before error messages enabled. */
+ int yyerrstatus;
+ /* Lookahead token as an internal (translated) token number. */
+ int yytoken = 0;
+
+ /* Three stacks and their tools:
+ `yyss': related to states,
+ `yyvs': related to semantic values,
+ `yyls': related to locations.
+
+ Refer to the stacks thru separate pointers, to allow yyoverflow
+ to reallocate them elsewhere. */
+
+ /* The state stack. */
+ short yyssa[YYINITDEPTH];
+ short *yyss = yyssa;
+ register short *yyssp;
+
+ /* The semantic value stack. */
+ YYSTYPE yyvsa[YYINITDEPTH];
+ YYSTYPE *yyvs = yyvsa;
+ register YYSTYPE *yyvsp;
+
+
+
+#define YYPOPSTACK (yyvsp--, yyssp--)
+
+ YYSIZE_T yystacksize = YYINITDEPTH;
+
+ /* The variables used to return semantic value and location from the
+ action routines. */
+ YYSTYPE yyval;
+
+
+ /* When reducing, the number of symbols on the RHS of the reduced
+ rule. */
+ int yylen;
+
+ YYDPRINTF ((stderr, "Starting parse\n"));
+
+ yystate = 0;
+ yyerrstatus = 0;
+ yynerrs = 0;
+ yychar = YYEMPTY; /* Cause a token to be read. */
+
+ /* Initialize stack pointers.
+ Waste one element of value and location stack
+ so that they stay on the same level as the state stack.
+ The wasted elements are never initialized. */
+
+ yyssp = yyss;
+ yyvsp = yyvs;
+
+ goto yysetstate;
+
+/*------------------------------------------------------------.
+| yynewstate -- Push a new state, which is found in yystate. |
+`------------------------------------------------------------*/
+ yynewstate:
+ /* In all cases, when you get here, the value and location stacks
+ have just been pushed. so pushing a state here evens the stacks.
+ */
+ yyssp++;
+
+ yysetstate:
+ *yyssp = yystate;
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ {
+ /* Get the current used size of the three stacks, in elements. */
+ YYSIZE_T yysize = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+ {
+ /* Give user a chance to reallocate the stack. Use copies of
+ these so that the &'s don't force the real ones into
+ memory. */
+ YYSTYPE *yyvs1 = yyvs;
+ short *yyss1 = yyss;
+
+
+ /* Each stack pointer address is followed by the size of the
+ data in use in that stack, in bytes. This used to be a
+ conditional around just the two extra args, but that might
+ be undefined if yyoverflow is a macro. */
+ yyoverflow ("parser stack overflow",
+ &yyss1, yysize * sizeof (*yyssp),
+ &yyvs1, yysize * sizeof (*yyvsp),
+
+ &yystacksize);
+
+ yyss = yyss1;
+ yyvs = yyvs1;
+ }
+#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+ goto yyoverflowlab;
+# else
+ /* Extend the stack our own way. */
+ if (YYMAXDEPTH <= yystacksize)
+ goto yyoverflowlab;
+ yystacksize *= 2;
+ if (YYMAXDEPTH < yystacksize)
+ yystacksize = YYMAXDEPTH;
+
+ {
+ short *yyss1 = yyss;
+ union yyalloc *yyptr =
+ (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+ if (! yyptr)
+ goto yyoverflowlab;
+ YYSTACK_RELOCATE (yyss);
+ YYSTACK_RELOCATE (yyvs);
+
+# undef YYSTACK_RELOCATE
+ if (yyss1 != yyssa)
+ YYSTACK_FREE (yyss1);
+ }
+# endif
+#endif /* no yyoverflow */
+
+ yyssp = yyss + yysize - 1;
+ yyvsp = yyvs + yysize - 1;
+
+
+ YYDPRINTF ((stderr, "Stack size increased to %lu\n",
+ (unsigned long int) yystacksize));
+
+ if (yyss + yystacksize - 1 <= yyssp)
+ YYABORT;
+ }
+
+ YYDPRINTF ((stderr, "Entering state %d\n", yystate));
+
+ goto yybackup;
+
+/*-----------.
+| yybackup. |
+`-----------*/
+yybackup:
+
+/* Do appropriate processing given the current state. */
+/* Read a lookahead token if we need one and don't already have one. */
+/* yyresume: */
+
+ /* First try to decide what to do without reference to lookahead token. */
+
+ yyn = yypact[yystate];
+ if (yyn == YYPACT_NINF)
+ goto yydefault;
+
+ /* Not known => get a lookahead token if don't already have one. */
+
+ /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
+ if (yychar == YYEMPTY)
+ {
+ YYDPRINTF ((stderr, "Reading a token: "));
+ yychar = YYLEX;
+ }
+
+ if (yychar <= YYEOF)
+ {
+ yychar = yytoken = YYEOF;
+ YYDPRINTF ((stderr, "Now at end of input.\n"));
+ }
+ else
+ {
+ yytoken = YYTRANSLATE (yychar);
+ YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
+ }
+
+ /* If the proper action on seeing token YYTOKEN is to reduce or to
+ detect an error, take that action. */
+ yyn += yytoken;
+ if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
+ goto yydefault;
+ yyn = yytable[yyn];
+ if (yyn <= 0)
+ {
+ if (yyn == 0 || yyn == YYTABLE_NINF)
+ goto yyerrlab;
+ yyn = -yyn;
+ goto yyreduce;
+ }
+
+ if (yyn == YYFINAL)
+ YYACCEPT;
+
+ /* Shift the lookahead token. */
+ YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
+
+ /* Discard the token being shifted unless it is eof. */
+ if (yychar != YYEOF)
+ yychar = YYEMPTY;
+
+ *++yyvsp = yylval;
+
+
+ /* Count tokens shifted since error; after three, turn off error
+ status. */
+ if (yyerrstatus)
+ yyerrstatus--;
+
+ yystate = yyn;
+ goto yynewstate;
+
+
+/*-----------------------------------------------------------.
+| yydefault -- do the default action for the current state. |
+`-----------------------------------------------------------*/
+yydefault:
+ yyn = yydefact[yystate];
+ if (yyn == 0)
+ goto yyerrlab;
+ goto yyreduce;
+
+
+/*-----------------------------.
+| yyreduce -- Do a reduction. |
+`-----------------------------*/
+yyreduce:
+ /* yyn is the number of a rule to reduce with. */
+ yylen = yyr2[yyn];
+
+ /* If YYLEN is nonzero, implement the default value of the action:
+ `$$ = $1'.
+
+ Otherwise, the following line sets YYVAL to garbage.
+ This behavior is undocumented and Bison
+ users should not rely upon it. Assigning to YYVAL
+ unconditionally makes the parser a bit smaller, and it avoids a
+ GCC warning that YYVAL may be used uninitialized. */
+ yyval = yyvsp[1-yylen];
+
+
+ YY_REDUCE_PRINT (yyn);
+ switch (yyn)
+ {
+ case 2:
+#line 210 "glslang.y"
+ {
+ // The symbol table search was done in the lexical phase
+ const TSymbol* symbol = yyvsp[0].lex.symbol;
+ const TVariable* variable;
+ if (symbol == 0) {
+ parseContext.error(yyvsp[0].lex.line, "undeclared identifier", yyvsp[0].lex.string->c_str(), "");
+ parseContext.recover();
+ TType type(EbtFloat);
+ TVariable* fakeVariable = new TVariable(yyvsp[0].lex.string, type);
+ parseContext.symbolTable.insert(*fakeVariable);
+ variable = fakeVariable;
+ } else {
+ // This identifier can only be a variable type symbol
+ if (! symbol->isVariable()) {
+ parseContext.error(yyvsp[0].lex.line, "variable expected", yyvsp[0].lex.string->c_str(), "");
+ parseContext.recover();
+ }
+ variable = static_cast<const TVariable*>(symbol);
+ }
+
+ // don't delete $1.string, it's used by error recovery, and the pool
+ // pop will reclaim the memory
+
+ if (variable->getType().getQualifier() == EvqConst ) {
+ constUnion* constArray = variable->getConstPointer();
+ TType t(variable->getType());
+ yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(constArray, t, yyvsp[0].lex.line);
+ } else
+ yyval.interm.intermTypedNode = parseContext.intermediate.addSymbol(variable->getUniqueId(),
+ variable->getName(),
+ variable->getType(), yyvsp[0].lex.line);
+ ;}
+ break;
+
+ case 3:
+#line 245 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
+ ;}
+ break;
+
+ case 4:
+#line 248 "glslang.y"
+ {
+ //
+ // INT_TYPE is only 16-bit plus sign bit for vertex/fragment shaders,
+ // check for overflow for constants
+ //
+ if (abs(yyvsp[0].lex.i) >= (1 << 16)) {
+ parseContext.error(yyvsp[0].lex.line, " integer constant overflow", "", "");
+ parseContext.recover();
+ }
+ constUnion *unionArray = new constUnion[1];
+ unionArray->iConst = yyvsp[0].lex.i;
+ yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), yyvsp[0].lex.line);
+ ;}
+ break;
+
+ case 5:
+#line 261 "glslang.y"
+ {
+ constUnion *unionArray = new constUnion[1];
+ unionArray->fConst = yyvsp[0].lex.f;
+ yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), yyvsp[0].lex.line);
+ ;}
+ break;
+
+ case 6:
+#line 266 "glslang.y"
+ {
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = yyvsp[0].lex.b;
+ yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[0].lex.line);
+ ;}
+ break;
+
+ case 7:
+#line 271 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = yyvsp[-1].interm.intermTypedNode;
+ ;}
+ break;
+
+ case 8:
+#line 277 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
+ ;}
+ break;
+
+ case 9:
+#line 280 "glslang.y"
+ {
+ if (!yyvsp[-3].interm.intermTypedNode->isArray() && !yyvsp[-3].interm.intermTypedNode->isMatrix() && !yyvsp[-3].interm.intermTypedNode->isVector()) {
+ if (yyvsp[-3].interm.intermTypedNode->getAsSymbolNode())
+ parseContext.error(yyvsp[-2].lex.line, " left of '[' is not of type array, matrix, or vector ", yyvsp[-3].interm.intermTypedNode->getAsSymbolNode()->getSymbol().c_str(), "");
+ else
+ parseContext.error(yyvsp[-2].lex.line, " left of '[' is not of type array, matrix, or vector ", "expression", "");
+ parseContext.recover();
+ }
+ if (yyvsp[-3].interm.intermTypedNode->getType().getQualifier() == EvqConst && !yyvsp[-3].interm.intermTypedNode->isArray() && yyvsp[-1].interm.intermTypedNode->getQualifier() == EvqConst) {
+ if (yyvsp[-3].interm.intermTypedNode->isVector()) { // constant folding for vectors
+ TVectorFields fields;
+ fields.num = 1;
+ fields.offsets[0] = yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst; // need to do it this way because v.xy sends fields integer array
+ yyval.interm.intermTypedNode = parseContext.addConstVectorNode(fields, yyvsp[-3].interm.intermTypedNode, yyvsp[-2].lex.line);
+ } else if (yyvsp[-3].interm.intermTypedNode->isMatrix()) { // constant folding for matrices
+ yyval.interm.intermTypedNode = parseContext.addConstMatrixNode(yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst, yyvsp[-3].interm.intermTypedNode, yyvsp[-2].lex.line);
+ }
+ } else {
+ if (yyvsp[-1].interm.intermTypedNode->getQualifier() == EvqConst) {
+ if ((yyvsp[-3].interm.intermTypedNode->isVector() || yyvsp[-3].interm.intermTypedNode->isMatrix()) && yyvsp[-3].interm.intermTypedNode->getType().getNominalSize() <= yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst && !yyvsp[-3].interm.intermTypedNode->isArray() ) {
+ parseContext.error(yyvsp[-2].lex.line, "", "[", "field selection out of range '%d'", yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst);
+ parseContext.recover();
+ } else {
+ if (yyvsp[-3].interm.intermTypedNode->isArray()) {
+ if (yyvsp[-3].interm.intermTypedNode->getType().getArraySize() == 0) {
+ if (yyvsp[-3].interm.intermTypedNode->getType().getMaxArraySize() <= yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst) {
+ if (parseContext.arraySetMaxSize(yyvsp[-3].interm.intermTypedNode->getAsSymbolNode(), yyvsp[-3].interm.intermTypedNode->getTypePointer(), yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst, true, yyvsp[-2].lex.line))
+ parseContext.recover();
+ } else {
+ if (parseContext.arraySetMaxSize(yyvsp[-3].interm.intermTypedNode->getAsSymbolNode(), yyvsp[-3].interm.intermTypedNode->getTypePointer(), 0, false, yyvsp[-2].lex.line))
+ parseContext.recover();
+ }
+ } else if ( yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst >= yyvsp[-3].interm.intermTypedNode->getType().getArraySize()) {
+ parseContext.error(yyvsp[-2].lex.line, "", "[", "array index out of range '%d'", yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst);
+ parseContext.recover();
+ }
+ }
+ yyval.interm.intermTypedNode = parseContext.intermediate.addIndex(EOpIndexDirect, yyvsp[-3].interm.intermTypedNode, yyvsp[-1].interm.intermTypedNode, yyvsp[-2].lex.line);
+ }
+ } else {
+ if (yyvsp[-3].interm.intermTypedNode->isArray() && yyvsp[-3].interm.intermTypedNode->getType().getArraySize() == 0) {
+ parseContext.error(yyvsp[-2].lex.line, "", "[", "array must be redeclared with a size before being indexed with a variable");
+ parseContext.recover();
+ }
+
+ yyval.interm.intermTypedNode = parseContext.intermediate.addIndex(EOpIndexIndirect, yyvsp[-3].interm.intermTypedNode, yyvsp[-1].interm.intermTypedNode, yyvsp[-2].lex.line);
+ }
+ }
+ if (yyval.interm.intermTypedNode == 0) {
+ constUnion *unionArray = new constUnion[1];
+ unionArray->fConst = 0.0;
+ yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), yyvsp[-2].lex.line);
+ } else if (yyvsp[-3].interm.intermTypedNode->isArray()) {
+ if (yyvsp[-3].interm.intermTypedNode->getType().getStruct())
+ yyval.interm.intermTypedNode->setType(TType(yyvsp[-3].interm.intermTypedNode->getType().getStruct(), yyvsp[-3].interm.intermTypedNode->getType().getTypeName()));
+ else
+ yyval.interm.intermTypedNode->setType(TType(yyvsp[-3].interm.intermTypedNode->getBasicType(), EvqTemporary, yyvsp[-3].interm.intermTypedNode->getNominalSize(), yyvsp[-3].interm.intermTypedNode->isMatrix()));
+ } else if (yyvsp[-3].interm.intermTypedNode->isMatrix() && yyvsp[-3].interm.intermTypedNode->getType().getQualifier() == EvqConst)
+ yyval.interm.intermTypedNode->setType(TType(yyvsp[-3].interm.intermTypedNode->getBasicType(), EvqConst, yyvsp[-3].interm.intermTypedNode->getNominalSize()));
+ else if (yyvsp[-3].interm.intermTypedNode->isMatrix())
+ yyval.interm.intermTypedNode->setType(TType(yyvsp[-3].interm.intermTypedNode->getBasicType(), EvqTemporary, yyvsp[-3].interm.intermTypedNode->getNominalSize()));
+ else if (yyvsp[-3].interm.intermTypedNode->isVector() && yyvsp[-3].interm.intermTypedNode->getType().getQualifier() == EvqConst)
+ yyval.interm.intermTypedNode->setType(TType(yyvsp[-3].interm.intermTypedNode->getBasicType(), EvqConst));
+ else if (yyvsp[-3].interm.intermTypedNode->isVector())
+ yyval.interm.intermTypedNode->setType(TType(yyvsp[-3].interm.intermTypedNode->getBasicType(), EvqTemporary));
+ else
+ yyval.interm.intermTypedNode->setType(yyvsp[-3].interm.intermTypedNode->getType());
+ ;}
+ break;
+
+ case 10:
+#line 348 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
+ ;}
+ break;
+
+ case 11:
+#line 351 "glslang.y"
+ {
+ if (yyvsp[-2].interm.intermTypedNode->isArray()) {
+ parseContext.error(yyvsp[0].lex.line, "cannot apply dot operator to an array", ".", "");
+ parseContext.recover();
+ }
+
+ if (yyvsp[-2].interm.intermTypedNode->isVector()) {
+ TVectorFields fields;
+ if (! parseContext.parseVectorFields(*yyvsp[0].lex.string, yyvsp[-2].interm.intermTypedNode->getNominalSize(), fields, yyvsp[0].lex.line)) {
+ fields.num = 1;
+ fields.offsets[0] = 0;
+ parseContext.recover();
+ }
+
+ if (yyvsp[-2].interm.intermTypedNode->getType().getQualifier() == EvqConst) { // constant folding for vector fields
+ yyval.interm.intermTypedNode = parseContext.addConstVectorNode(fields, yyvsp[-2].interm.intermTypedNode, yyvsp[0].lex.line);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
+ }
+ else
+ yyval.interm.intermTypedNode->setType(TType(yyvsp[-2].interm.intermTypedNode->getBasicType(), EvqConst, (int) (*yyvsp[0].lex.string).size()));
+ } else {
+ if (fields.num == 1) {
+ constUnion *unionArray = new constUnion[1];
+ unionArray->iConst = fields.offsets[0];
+ TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), yyvsp[0].lex.line);
+ yyval.interm.intermTypedNode = parseContext.intermediate.addIndex(EOpIndexDirect, yyvsp[-2].interm.intermTypedNode, index, yyvsp[-1].lex.line);
+ yyval.interm.intermTypedNode->setType(TType(yyvsp[-2].interm.intermTypedNode->getBasicType()));
+ } else {
+ TString vectorString = *yyvsp[0].lex.string;
+ TIntermTyped* index = parseContext.intermediate.addSwizzle(fields, yyvsp[0].lex.line);
+ yyval.interm.intermTypedNode = parseContext.intermediate.addIndex(EOpVectorSwizzle, yyvsp[-2].interm.intermTypedNode, index, yyvsp[-1].lex.line);
+ yyval.interm.intermTypedNode->setType(TType(yyvsp[-2].interm.intermTypedNode->getBasicType(),EvqTemporary, (int) vectorString.size()));
+ }
+ }
+ } else if (yyvsp[-2].interm.intermTypedNode->isMatrix()) {
+ TMatrixFields fields;
+ if (! parseContext.parseMatrixFields(*yyvsp[0].lex.string, yyvsp[-2].interm.intermTypedNode->getNominalSize(), fields, yyvsp[0].lex.line)) {
+ fields.wholeRow = false;
+ fields.wholeCol = false;
+ fields.row = 0;
+ fields.col = 0;
+ parseContext.recover();
+ }
+
+ if (fields.wholeRow || fields.wholeCol) {
+ parseContext.error(yyvsp[-1].lex.line, " non-scalar fields not implemented yet", ".", "");
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->iConst = 0;
+ TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), yyvsp[0].lex.line);
+ yyval.interm.intermTypedNode = parseContext.intermediate.addIndex(EOpIndexDirect, yyvsp[-2].interm.intermTypedNode, index, yyvsp[-1].lex.line);
+ yyval.interm.intermTypedNode->setType(TType(yyvsp[-2].interm.intermTypedNode->getBasicType(), EvqTemporary, yyvsp[-2].interm.intermTypedNode->getNominalSize()));
+ } else {
+ constUnion *unionArray = new constUnion[1];
+ unionArray->iConst = fields.col * yyvsp[-2].interm.intermTypedNode->getNominalSize() + fields.row;
+ TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), yyvsp[0].lex.line);
+ yyval.interm.intermTypedNode = parseContext.intermediate.addIndex(EOpIndexDirect, yyvsp[-2].interm.intermTypedNode, index, yyvsp[-1].lex.line);
+ yyval.interm.intermTypedNode->setType(TType(yyvsp[-2].interm.intermTypedNode->getBasicType()));
+ }
+ } else if (yyvsp[-2].interm.intermTypedNode->getBasicType() == EbtStruct) {
+ bool fieldFound = false;
+ TTypeList* fields = yyvsp[-2].interm.intermTypedNode->getType().getStruct();
+ if (fields == 0) {
+ parseContext.error(yyvsp[-1].lex.line, "structure has no fields", "Internal Error", "");
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
+ } else {
+ unsigned int i;
+ for (i = 0; i < fields->size(); ++i) {
+ if ((*fields)[i].type->getFieldName() == *yyvsp[0].lex.string) {
+ fieldFound = true;
+ break;
+ }
+ }
+ if (fieldFound) {
+ if (yyvsp[-2].interm.intermTypedNode->getType().getQualifier() == EvqConst) {
+ yyval.interm.intermTypedNode = parseContext.addConstStruct(*yyvsp[0].lex.string, yyvsp[-2].interm.intermTypedNode, yyvsp[-1].lex.line);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
+ }
+ else {
+ yyval.interm.intermTypedNode->setType(*(*fields)[i].type);
+ // change the qualifier of the return type, not of the structure field
+ // as the structure definition is shared between various structures.
+ yyval.interm.intermTypedNode->getTypePointer()->changeQualifier(EvqConst);
+ }
+ } else {
+ constUnion *unionArray = new constUnion[1];
+ unionArray->iConst = i;
+ TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), yyvsp[0].lex.line);
+ yyval.interm.intermTypedNode = parseContext.intermediate.addIndex(EOpIndexDirectStruct, yyvsp[-2].interm.intermTypedNode, index, yyvsp[-1].lex.line);
+ yyval.interm.intermTypedNode->setType(*(*fields)[i].type);
+ }
+ } else {
+ parseContext.error(yyvsp[-1].lex.line, " no such field in structure", yyvsp[0].lex.string->c_str(), "");
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
+ }
+ }
+ } else {
+ parseContext.error(yyvsp[-1].lex.line, " field selection requires structure, vector, or matrix on left hand side", yyvsp[0].lex.string->c_str(), "");
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
+ }
+ // don't delete $3.string, it's from the pool
+ ;}
+ break;
+
+ case 12:
+#line 460 "glslang.y"
+ {
+ if (parseContext.lValueErrorCheck(yyvsp[0].lex.line, "++", yyvsp[-1].interm.intermTypedNode))
+ parseContext.recover();
+ yyval.interm.intermTypedNode = parseContext.intermediate.addUnaryMath(EOpPostIncrement, yyvsp[-1].interm.intermTypedNode, yyvsp[0].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.unaryOpError(yyvsp[0].lex.line, "++", yyvsp[-1].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-1].interm.intermTypedNode;
+ }
+ ;}
+ break;
+
+ case 13:
+#line 470 "glslang.y"
+ {
+ if (parseContext.lValueErrorCheck(yyvsp[0].lex.line, "--", yyvsp[-1].interm.intermTypedNode))
+ parseContext.recover();
+ yyval.interm.intermTypedNode = parseContext.intermediate.addUnaryMath(EOpPostDecrement, yyvsp[-1].interm.intermTypedNode, yyvsp[0].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.unaryOpError(yyvsp[0].lex.line, "--", yyvsp[-1].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-1].interm.intermTypedNode;
+ }
+ ;}
+ break;
+
+ case 14:
+#line 483 "glslang.y"
+ {
+ if (parseContext.integerErrorCheck(yyvsp[0].interm.intermTypedNode, "[]"))
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
+ ;}
+ break;
+
+ case 15:
+#line 491 "glslang.y"
+ {
+ TFunction* fnCall = yyvsp[0].interm.function;
+ TOperator op = fnCall->getBuiltInOp();
+
+ if (op != EOpNull) {
+ //
+ // Then this should be a constructor.
+ //
+ TType type(EbtVoid); // use this to get the type back
+ if (parseContext.constructorErrorCheck(yyvsp[0].interm.line, yyvsp[0].interm.intermNode, *fnCall, op, &type)) {
+ yyval.interm.intermTypedNode = 0;
+ } else {
+ //
+ // It's a constructor, of type 'type'.
+ //
+ yyval.interm.intermTypedNode = parseContext.addConstructor(yyvsp[0].interm.intermNode, &type, op, fnCall, yyvsp[0].interm.line);
+ }
+
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.recover();
+ yyval.interm.intermTypedNode = parseContext.intermediate.setAggregateOperator(0, op, yyvsp[0].interm.line);
+ }
+ yyval.interm.intermTypedNode->setType(type);
+ } else {
+ //
+ // Not a constructor. Find it in the symbol table.
+ //
+ const TFunction* fnCandidate;
+ bool builtIn;
+ fnCandidate = parseContext.findFunction(yyvsp[0].interm.line, fnCall, &builtIn);
+ if (fnCandidate) {
+ //
+ // A declared function. But, it might still map to a built-in
+ // operation.
+ //
+ op = fnCandidate->getBuiltInOp();
+ if (builtIn && op != EOpNull) {
+ //
+ // A function call mapped to a built-in operation.
+ //
+ if (fnCandidate->getParamCount() == 1) {
+ //
+ // Treat it like a built-in unary operator.
+ //
+ yyval.interm.intermTypedNode = parseContext.intermediate.addUnaryMath(op, yyvsp[0].interm.intermNode, 0, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.error(yyvsp[0].interm.intermNode->getLine(), " wrong operand type", "Internal Error",
+ "built in unary operator function. Type: %s",
+ static_cast<TIntermTyped*>(yyvsp[0].interm.intermNode)->getCompleteString().c_str());
+ YYERROR;
+ }
+ } else {
+ yyval.interm.intermTypedNode = parseContext.intermediate.setAggregateOperator(yyvsp[0].interm.intermAggregate, op, yyvsp[0].interm.line);
+ }
+ } else {
+ // This is a real function call
+
+ yyval.interm.intermTypedNode = parseContext.intermediate.setAggregateOperator(yyvsp[0].interm.intermAggregate, EOpFunctionCall, yyvsp[0].interm.line);
+ yyval.interm.intermTypedNode->setType(fnCandidate->getReturnType());
+
+ // this is how we know whether the given function is a builtIn function or a user defined function
+ // if builtIn == false, it's a userDefined -> could be an overloaded builtIn function also
+ // if builtIn == true, it's definitely a builtIn function with EOpNull
+ if (!builtIn)
+ yyval.interm.intermTypedNode->getAsAggregate()->setUserDefined();
+ yyval.interm.intermTypedNode->getAsAggregate()->setName(fnCandidate->getMangledName());
+
+ TQualifier qual;
+ TQualifierList& qualifierList = yyval.interm.intermTypedNode->getAsAggregate()->getQualifier();
+ for (int i = 0; i < fnCandidate->getParamCount(); ++i) {
+ qual = (*fnCandidate)[i].type->getQualifier();
+ if (qual == EvqOut || qual == EvqInOut) {
+ if (parseContext.lValueErrorCheck(yyval.interm.intermTypedNode->getLine(), "assign", yyval.interm.intermTypedNode->getAsAggregate()->getSequence()[i]->getAsTyped())) {
+ parseContext.error(yyvsp[0].interm.intermNode->getLine(), "Constant value cannot be passed for 'out' or 'inout' parameters.", "Error", "");
+ parseContext.recover();
+ }
+ }
+ qualifierList.push_back(qual);
+ }
+ }
+ yyval.interm.intermTypedNode->setType(fnCandidate->getReturnType());
+ } else {
+ // error message was put out by PaFindFunction()
+ // Put on a dummy node for error recovery
+ constUnion *unionArray = new constUnion[1];
+ unionArray->fConst = 0.0;
+ yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), yyvsp[0].interm.line);
+ parseContext.recover();
+ }
+ }
+ delete fnCall;
+ ;}
+ break;
+
+ case 16:
+#line 586 "glslang.y"
+ {
+ yyval.interm = yyvsp[-1].interm;
+ yyval.interm.line = yyvsp[0].lex.line;
+ ;}
+ break;
+
+ case 17:
+#line 590 "glslang.y"
+ {
+ yyval.interm = yyvsp[-1].interm;
+ yyval.interm.line = yyvsp[0].lex.line;
+ ;}
+ break;
+
+ case 18:
+#line 597 "glslang.y"
+ {
+ yyval.interm.function = yyvsp[-1].interm.function;
+ yyval.interm.intermNode = 0;
+ ;}
+ break;
+
+ case 19:
+#line 601 "glslang.y"
+ {
+ yyval.interm.function = yyvsp[0].interm.function;
+ yyval.interm.intermNode = 0;
+ ;}
+ break;
+
+ case 20:
+#line 608 "glslang.y"
+ {
+ TParameter param = { 0, new TType(yyvsp[0].interm.intermTypedNode->getType()) };
+ yyvsp[-1].interm.function->addParameter(param);
+ yyval.interm.function = yyvsp[-1].interm.function;
+ yyval.interm.intermNode = yyvsp[0].interm.intermTypedNode;
+ ;}
+ break;
+
+ case 21:
+#line 614 "glslang.y"
+ {
+ TParameter param = { 0, new TType(yyvsp[0].interm.intermTypedNode->getType()) };
+ yyvsp[-2].interm.function->addParameter(param);
+ yyval.interm.function = yyvsp[-2].interm.function;
+ yyval.interm.intermNode = parseContext.intermediate.growAggregate(yyvsp[-2].interm.intermNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line);
+ ;}
+ break;
+
+ case 22:
+#line 623 "glslang.y"
+ {
+ yyval.interm.function = yyvsp[-1].interm.function;
+ ;}
+ break;
+
+ case 23:
+#line 629 "glslang.y"
+ {
+ if (yyvsp[0].interm.op == EOpConstructStruct) {
+ TString tempString = "";
+ TFunction *function = new TFunction(&tempString, *(yyvsp[0].interm.type.userDef), yyvsp[0].interm.op);
+ yyval.interm.function = function;
+ }
+ else {
+ TFunction *function = new TFunction(yyvsp[0].interm.op);
+ yyval.interm.function = function;
+ }
+ ;}
+ break;
+
+ case 24:
+#line 640 "glslang.y"
+ {
+ if (parseContext.reservedErrorCheck(yyvsp[0].lex.line, *yyvsp[0].lex.string))
+ parseContext.recover();
+ TType type(EbtVoid);
+ TFunction *function = new TFunction(yyvsp[0].lex.string, type);
+ yyval.interm.function = function;
+ ;}
+ break;
+
+ case 25:
+#line 656 "glslang.y"
+ { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructFloat; ;}
+ break;
+
+ case 26:
+#line 657 "glslang.y"
+ { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructInt; ;}
+ break;
+
+ case 27:
+#line 658 "glslang.y"
+ { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructBool; ;}
+ break;
+
+ case 28:
+#line 659 "glslang.y"
+ { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructVec2; ;}
+ break;
+
+ case 29:
+#line 660 "glslang.y"
+ { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructVec3; ;}
+ break;
+
+ case 30:
+#line 661 "glslang.y"
+ { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructVec4; ;}
+ break;
+
+ case 31:
+#line 662 "glslang.y"
+ { FRAG_VERT_ONLY("bvec2", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructBVec2; ;}
+ break;
+
+ case 32:
+#line 663 "glslang.y"
+ { FRAG_VERT_ONLY("bvec3", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructBVec3; ;}
+ break;
+
+ case 33:
+#line 664 "glslang.y"
+ { FRAG_VERT_ONLY("bvec4", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructBVec4; ;}
+ break;
+
+ case 34:
+#line 665 "glslang.y"
+ { FRAG_VERT_ONLY("ivec2", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructIVec2; ;}
+ break;
+
+ case 35:
+#line 666 "glslang.y"
+ { FRAG_VERT_ONLY("ivec3", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructIVec3; ;}
+ break;
+
+ case 36:
+#line 667 "glslang.y"
+ { FRAG_VERT_ONLY("ivec4", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructIVec4; ;}
+ break;
+
+ case 37:
+#line 668 "glslang.y"
+ { FRAG_VERT_ONLY("mat2", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructMat2; ;}
+ break;
+
+ case 38:
+#line 669 "glslang.y"
+ { FRAG_VERT_ONLY("mat3", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructMat3; ;}
+ break;
+
+ case 39:
+#line 670 "glslang.y"
+ { FRAG_VERT_ONLY("mat4", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpConstructMat4; ;}
+ break;
+
+ case 40:
+#line 671 "glslang.y"
+ {
+ TType& structure = static_cast<TVariable*>(yyvsp[0].lex.symbol)->getType();
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtStruct, qual, 1, false, false, &structure, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ yyval.interm.line = yyvsp[0].lex.line;
+ yyval.interm.op = EOpConstructStruct;
+ ;}
+ break;
+
+ case 41:
+#line 682 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
+ ;}
+ break;
+
+ case 42:
+#line 685 "glslang.y"
+ {
+ if (parseContext.lValueErrorCheck(yyvsp[-1].lex.line, "++", yyvsp[0].interm.intermTypedNode))
+ parseContext.recover();
+ yyval.interm.intermTypedNode = parseContext.intermediate.addUnaryMath(EOpPreIncrement, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.unaryOpError(yyvsp[-1].lex.line, "++", yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
+ }
+ ;}
+ break;
+
+ case 43:
+#line 695 "glslang.y"
+ {
+ if (parseContext.lValueErrorCheck(yyvsp[-1].lex.line, "--", yyvsp[0].interm.intermTypedNode))
+ parseContext.recover();
+ yyval.interm.intermTypedNode = parseContext.intermediate.addUnaryMath(EOpPreDecrement, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.unaryOpError(yyvsp[-1].lex.line, "--", yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
+ }
+ ;}
+ break;
+
+ case 44:
+#line 705 "glslang.y"
+ {
+ if (yyvsp[-1].interm.op != EOpNull) {
+ yyval.interm.intermTypedNode = parseContext.intermediate.addUnaryMath(yyvsp[-1].interm.op, yyvsp[0].interm.intermTypedNode, yyvsp[-1].interm.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ char* errorOp = "";
+ switch(yyvsp[-1].interm.op) {
+ case EOpNegative: errorOp = "-"; break;
+ case EOpLogicalNot: errorOp = "!"; break;
+ case EOpBitwiseNot: errorOp = "~"; break;
+ default: break;
+ }
+ parseContext.unaryOpError(yyvsp[-1].interm.line, errorOp, yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
+ }
+ } else
+ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
+ ;}
+ break;
+
+ case 45:
+#line 727 "glslang.y"
+ { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpNull; ;}
+ break;
+
+ case 46:
+#line 728 "glslang.y"
+ { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpNegative; ;}
+ break;
+
+ case 47:
+#line 729 "glslang.y"
+ { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpLogicalNot; ;}
+ break;
+
+ case 48:
+#line 730 "glslang.y"
+ { PACK_UNPACK_ONLY("~", yyvsp[0].lex.line);
+ yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpBitwiseNot; ;}
+ break;
+
+ case 49:
+#line 736 "glslang.y"
+ { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
+ break;
+
+ case 50:
+#line 737 "glslang.y"
+ {
+ FRAG_VERT_ONLY("*", yyvsp[-1].lex.line);
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpMul, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, "*", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
+ }
+ ;}
+ break;
+
+ case 51:
+#line 746 "glslang.y"
+ {
+ FRAG_VERT_ONLY("/", yyvsp[-1].lex.line);
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpDiv, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, "/", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
+ }
+ ;}
+ break;
+
+ case 52:
+#line 755 "glslang.y"
+ {
+ PACK_UNPACK_ONLY("%", yyvsp[-1].lex.line);
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpMod, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, "%", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
+ }
+ ;}
+ break;
+
+ case 53:
+#line 767 "glslang.y"
+ { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
+ break;
+
+ case 54:
+#line 768 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpAdd, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, "+", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
+ }
+ ;}
+ break;
+
+ case 55:
+#line 776 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpSub, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, "-", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
+ }
+ ;}
+ break;
+
+ case 56:
+#line 787 "glslang.y"
+ { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
+ break;
+
+ case 57:
+#line 788 "glslang.y"
+ {
+ PACK_UNPACK_ONLY("<<", yyvsp[-1].lex.line);
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpLeftShift, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, "<<", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
+ }
+ ;}
+ break;
+
+ case 58:
+#line 797 "glslang.y"
+ {
+ PACK_UNPACK_ONLY(">>", yyvsp[-1].lex.line);
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpRightShift, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, ">>", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
+ }
+ ;}
+ break;
+
+ case 59:
+#line 809 "glslang.y"
+ { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
+ break;
+
+ case 60:
+#line 810 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpLessThan, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, "<", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
+ }
+ ;}
+ break;
+
+ case 61:
+#line 820 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpGreaterThan, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, ">", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
+ }
+ ;}
+ break;
+
+ case 62:
+#line 830 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpLessThanEqual, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, "<=", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
+ }
+ ;}
+ break;
+
+ case 63:
+#line 840 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpGreaterThanEqual, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, ">=", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
+ }
+ ;}
+ break;
+
+ case 64:
+#line 853 "glslang.y"
+ { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
+ break;
+
+ case 65:
+#line 854 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpEqual, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, "==", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
+ }
+ ;}
+ break;
+
+ case 66:
+#line 864 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpNotEqual, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, "!=", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
+ }
+ ;}
+ break;
+
+ case 67:
+#line 877 "glslang.y"
+ { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
+ break;
+
+ case 68:
+#line 878 "glslang.y"
+ {
+ PACK_UNPACK_ONLY("&", yyvsp[-1].lex.line);
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpAnd, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, "&", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
+ }
+ ;}
+ break;
+
+ case 69:
+#line 890 "glslang.y"
+ { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
+ break;
+
+ case 70:
+#line 891 "glslang.y"
+ {
+ PACK_UNPACK_ONLY("^", yyvsp[-1].lex.line);
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpExclusiveOr, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, "^", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
+ }
+ ;}
+ break;
+
+ case 71:
+#line 903 "glslang.y"
+ { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
+ break;
+
+ case 72:
+#line 904 "glslang.y"
+ {
+ PACK_UNPACK_ONLY("|", yyvsp[-1].lex.line);
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpInclusiveOr, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, "|", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
+ }
+ ;}
+ break;
+
+ case 73:
+#line 916 "glslang.y"
+ { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
+ break;
+
+ case 74:
+#line 917 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpLogicalAnd, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, "&&", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
+ }
+ ;}
+ break;
+
+ case 75:
+#line 930 "glslang.y"
+ { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
+ break;
+
+ case 76:
+#line 931 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpLogicalXor, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, "^^", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
+ }
+ ;}
+ break;
+
+ case 77:
+#line 944 "glslang.y"
+ { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
+ break;
+
+ case 78:
+#line 945 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = parseContext.intermediate.addBinaryMath(EOpLogicalOr, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line, parseContext.symbolTable);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, "||", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ yyval.interm.intermTypedNode = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), yyvsp[-1].lex.line);
+ }
+ ;}
+ break;
+
+ case 79:
+#line 958 "glslang.y"
+ { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
+ break;
+
+ case 80:
+#line 959 "glslang.y"
+ {
+ if (parseContext.boolErrorCheck(yyvsp[-3].lex.line, yyvsp[-4].interm.intermTypedNode))
+ parseContext.recover();
+
+ yyval.interm.intermTypedNode = parseContext.intermediate.addSelection(yyvsp[-4].interm.intermTypedNode, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-3].lex.line);
+ if (yyvsp[-2].interm.intermTypedNode->getType() != yyvsp[0].interm.intermTypedNode->getType())
+ yyval.interm.intermTypedNode = 0;
+
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-3].lex.line, ":", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
+ }
+ ;}
+ break;
+
+ case 81:
+#line 976 "glslang.y"
+ { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
+ break;
+
+ case 82:
+#line 977 "glslang.y"
+ {
+ if (parseContext.lValueErrorCheck(yyvsp[-1].interm.line, "assign", yyvsp[-2].interm.intermTypedNode))
+ parseContext.recover();
+ yyval.interm.intermTypedNode = parseContext.intermediate.addAssign(yyvsp[-1].interm.op, yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].interm.line);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.assignError(yyvsp[-1].interm.line, "assign", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[-2].interm.intermTypedNode;
+ }
+ ;}
+ break;
+
+ case 83:
+#line 990 "glslang.y"
+ { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpAssign; ;}
+ break;
+
+ case 84:
+#line 991 "glslang.y"
+ { FRAG_VERT_ONLY("*=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpMulAssign; ;}
+ break;
+
+ case 85:
+#line 992 "glslang.y"
+ { FRAG_VERT_ONLY("/=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpDivAssign; ;}
+ break;
+
+ case 86:
+#line 993 "glslang.y"
+ { PACK_UNPACK_ONLY("%=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpModAssign; ;}
+ break;
+
+ case 87:
+#line 994 "glslang.y"
+ { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpAddAssign; ;}
+ break;
+
+ case 88:
+#line 995 "glslang.y"
+ { yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpSubAssign; ;}
+ break;
+
+ case 89:
+#line 996 "glslang.y"
+ { PACK_UNPACK_ONLY("<<=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpLeftShiftAssign; ;}
+ break;
+
+ case 90:
+#line 997 "glslang.y"
+ { PACK_UNPACK_ONLY("<<=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpRightShiftAssign; ;}
+ break;
+
+ case 91:
+#line 998 "glslang.y"
+ { PACK_UNPACK_ONLY("&=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpAndAssign; ;}
+ break;
+
+ case 92:
+#line 999 "glslang.y"
+ { PACK_UNPACK_ONLY("^=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpExclusiveOrAssign; ;}
+ break;
+
+ case 93:
+#line 1000 "glslang.y"
+ { PACK_UNPACK_ONLY("|=", yyvsp[0].lex.line); yyval.interm.line = yyvsp[0].lex.line; yyval.interm.op = EOpInclusiveOrAssign; ;}
+ break;
+
+ case 94:
+#line 1004 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
+ ;}
+ break;
+
+ case 95:
+#line 1007 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = parseContext.intermediate.addComma(yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.intermTypedNode, yyvsp[-1].lex.line);
+ if (yyval.interm.intermTypedNode == 0) {
+ parseContext.binaryOpError(yyvsp[-1].lex.line, ",", yyvsp[-2].interm.intermTypedNode->getCompleteString(), yyvsp[0].interm.intermTypedNode->getCompleteString());
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
+ }
+ ;}
+ break;
+
+ case 96:
+#line 1018 "glslang.y"
+ {
+ if (parseContext.constErrorCheck(yyvsp[0].interm.intermTypedNode))
+ parseContext.recover();
+ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
+ ;}
+ break;
+
+ case 97:
+#line 1026 "glslang.y"
+ { yyval.interm.intermNode = 0; ;}
+ break;
+
+ case 98:
+#line 1027 "glslang.y"
+ {
+ if (yyvsp[-1].interm.intermAggregate)
+ yyvsp[-1].interm.intermAggregate->setOperator(EOpSequence);
+ yyval.interm.intermNode = yyvsp[-1].interm.intermAggregate;
+ ;}
+ break;
+
+ case 99:
+#line 1035 "glslang.y"
+ {
+ //
+ // Multiple declarations of the same function are allowed.
+ //
+ // If this is a definition, the definition production code will check for redefinitions
+ // (we don't know at this point if it's a definition or not).
+ //
+ // Redeclarations are allowed. But, return types and parameter qualifiers must match.
+ //
+ TFunction* prevDec = static_cast<TFunction*>(parseContext.symbolTable.find(yyvsp[-1].interm.function->getMangledName()));
+ if (prevDec) {
+ if (prevDec->getReturnType() != yyvsp[-1].interm.function->getReturnType()) {
+ parseContext.error(yyvsp[0].lex.line, "overloaded functions must have the same return type", yyvsp[-1].interm.function->getReturnType().getBasicString(), "");
+ parseContext.recover();
+ }
+ for (int i = 0; i < prevDec->getParamCount(); ++i) {
+ if ((*prevDec)[i].type->getQualifier() != (*yyvsp[-1].interm.function)[i].type->getQualifier()) {
+ parseContext.error(yyvsp[0].lex.line, "overloaded functions must have the same parameter qualifiers", (*yyvsp[-1].interm.function)[i].type->getQualifierString(), "");
+ parseContext.recover();
+ }
+ }
+ }
+
+ //
+ // If this is a redeclaration, it could also be a definition,
+ // in which case, we want to use the variable names from this one, and not the one that's
+ // being redeclared. So, pass back up this declaration, not the one in the symbol table.
+ //
+ yyval.interm.function = yyvsp[-1].interm.function;
+ yyval.interm.line = yyvsp[0].lex.line;
+
+ parseContext.symbolTable.insert(*yyval.interm.function);
+ ;}
+ break;
+
+ case 100:
+#line 1071 "glslang.y"
+ {
+ yyval.interm.function = yyvsp[0].interm.function;
+ ;}
+ break;
+
+ case 101:
+#line 1074 "glslang.y"
+ {
+ yyval.interm.function = yyvsp[0].interm.function;
+ ;}
+ break;
+
+ case 102:
+#line 1081 "glslang.y"
+ {
+ // Add the parameter
+ yyval.interm.function = yyvsp[-1].interm.function;
+ if (yyvsp[0].interm.param.type->getBasicType() != EbtVoid)
+ yyvsp[-1].interm.function->addParameter(yyvsp[0].interm.param);
+ else
+ delete yyvsp[0].interm.param.type;
+ ;}
+ break;
+
+ case 103:
+#line 1089 "glslang.y"
+ {
+ //
+ // Only first parameter of one-parameter functions can be void
+ // The check for named parameters not being void is done in parameter_declarator
+ //
+ if (yyvsp[0].interm.param.type->getBasicType() == EbtVoid) {
+ //
+ // This parameter > first is void
+ //
+ parseContext.error(yyvsp[-1].lex.line, "cannot be an argument type except for '(void)'", "void", "");
+ parseContext.recover();
+ delete yyvsp[0].interm.param.type;
+ } else {
+ // Add the parameter
+ yyval.interm.function = yyvsp[-2].interm.function;
+ yyvsp[-2].interm.function->addParameter(yyvsp[0].interm.param);
+ }
+ ;}
+ break;
+
+ case 104:
+#line 1110 "glslang.y"
+ {
+ if (yyvsp[-2].interm.type.qualifier != EvqGlobal && yyvsp[-2].interm.type.qualifier != EvqTemporary) {
+ parseContext.error(yyvsp[-1].lex.line, "no qualifiers allowed for function return", getQualifierString(yyvsp[-2].interm.type.qualifier), "");
+ parseContext.recover();
+ }
+ // make sure a sampler is not involved as well...
+ if (parseContext.structQualifierErrorCheck(yyvsp[-1].lex.line, yyvsp[-2].interm.type))
+ parseContext.recover();
+
+ // Add the function as a prototype after parsing it (we do not support recursion)
+ TFunction *function;
+ TType type(yyvsp[-2].interm.type);
+ function = new TFunction(yyvsp[-1].lex.string, type);
+ yyval.interm.function = function;
+ ;}
+ break;
+
+ case 105:
+#line 1129 "glslang.y"
+ {
+ if (yyvsp[-1].interm.type.type == EbtVoid) {
+ parseContext.error(yyvsp[0].lex.line, "illegal use of type 'void'", yyvsp[0].lex.string->c_str(), "");
+ parseContext.recover();
+ }
+ if (parseContext.reservedErrorCheck(yyvsp[0].lex.line, *yyvsp[0].lex.string))
+ parseContext.recover();
+ TParameter param = {yyvsp[0].lex.string, new TType(yyvsp[-1].interm.type)};
+ yyval.interm.line = yyvsp[0].lex.line;
+ yyval.interm.param = param;
+ ;}
+ break;
+
+ case 106:
+#line 1140 "glslang.y"
+ {
+ // Check that we can make an array out of this type
+ if (yyvsp[-4].interm.type.array) {
+ parseContext.error(yyvsp[-2].lex.line, "cannot declare arrays of this type", TType(yyvsp[-4].interm.type).getCompleteString().c_str(), "");
+ parseContext.recover();
+ }
+ if (parseContext.reservedErrorCheck(yyvsp[-3].lex.line, *yyvsp[-3].lex.string))
+ parseContext.recover();
+ yyvsp[-4].interm.type.array = true;
+ TType* type = new TType(yyvsp[-4].interm.type);
+ if (yyvsp[-1].interm.intermTypedNode->getAsConstantUnion())
+ type->setArraySize(yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst);
+ TParameter param = { yyvsp[-3].lex.string, type };
+ yyval.interm.line = yyvsp[-3].lex.line;
+ yyval.interm.param = param;
+ ;}
+ break;
+
+ case 107:
+#line 1167 "glslang.y"
+ {
+ yyval.interm = yyvsp[0].interm;
+ if (parseContext.paramErrorCheck(yyvsp[0].interm.line, yyvsp[-2].interm.type.qualifier, yyvsp[-1].interm.qualifier, yyval.interm.param.type))
+ parseContext.recover();
+ ;}
+ break;
+
+ case 108:
+#line 1172 "glslang.y"
+ {
+ yyval.interm = yyvsp[0].interm;
+ if (parseContext.parameterSamplerErrorCheck(yyvsp[0].interm.line, yyvsp[-1].interm.qualifier, *yyvsp[0].interm.param.type))
+ parseContext.recover();
+ if (parseContext.paramErrorCheck(yyvsp[0].interm.line, EvqTemporary, yyvsp[-1].interm.qualifier, yyval.interm.param.type))
+ parseContext.recover();
+ ;}
+ break;
+
+ case 109:
+#line 1182 "glslang.y"
+ {
+ yyval.interm = yyvsp[0].interm;
+ if (parseContext.paramErrorCheck(yyvsp[0].interm.line, yyvsp[-2].interm.type.qualifier, yyvsp[-1].interm.qualifier, yyval.interm.param.type))
+ parseContext.recover();
+ ;}
+ break;
+
+ case 110:
+#line 1187 "glslang.y"
+ {
+ yyval.interm = yyvsp[0].interm;
+ if (parseContext.parameterSamplerErrorCheck(yyvsp[0].interm.line, yyvsp[-1].interm.qualifier, *yyvsp[0].interm.param.type))
+ parseContext.recover();
+ if (parseContext.paramErrorCheck(yyvsp[0].interm.line, EvqTemporary, yyvsp[-1].interm.qualifier, yyval.interm.param.type))
+ parseContext.recover();
+ ;}
+ break;
+
+ case 111:
+#line 1197 "glslang.y"
+ {
+ yyval.interm.qualifier = EvqIn;
+ ;}
+ break;
+
+ case 112:
+#line 1200 "glslang.y"
+ {
+ yyval.interm.qualifier = EvqIn;
+ ;}
+ break;
+
+ case 113:
+#line 1203 "glslang.y"
+ {
+ yyval.interm.qualifier = EvqOut;
+ ;}
+ break;
+
+ case 114:
+#line 1206 "glslang.y"
+ {
+ yyval.interm.qualifier = EvqInOut;
+ ;}
+ break;
+
+ case 115:
+#line 1212 "glslang.y"
+ {
+ TParameter param = { 0, new TType(yyvsp[0].interm.type) };
+ yyval.interm.param = param;
+
+ ;}
+ break;
+
+ case 116:
+#line 1217 "glslang.y"
+ {
+ // Check that we can make an array out of this type
+ if (yyvsp[-3].interm.type.array) {
+ parseContext.error(yyvsp[-2].lex.line, "cannot declare arrays of this type", TType(yyvsp[-3].interm.type).getCompleteString().c_str(), "");
+ parseContext.recover();
+ }
+ yyvsp[-3].interm.type.array = true;
+ TType* type = new TType(yyvsp[-3].interm.type);
+ if (yyvsp[-1].interm.intermTypedNode->getAsConstantUnion())
+ type->setArraySize(yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst);
+
+ TParameter param = { 0, type };
+ yyval.interm.line = yyvsp[-2].lex.line;
+ yyval.interm.param = param;
+ ;}
+ break;
+
+ case 117:
+#line 1235 "glslang.y"
+ {
+ yyval.interm = yyvsp[0].interm;
+ ;}
+ break;
+
+ case 118:
+#line 1238 "glslang.y"
+ {
+ yyval.interm = yyvsp[-2].interm;
+ if (parseContext.structQualifierErrorCheck(yyvsp[0].lex.line, yyvsp[-2].interm.type))
+ parseContext.recover();
+
+ if (parseContext.nonInitErrorCheck(yyvsp[0].lex.line, *yyvsp[0].lex.string, yyval.interm.type))
+ parseContext.recover();
+ ;}
+ break;
+
+ case 119:
+#line 1246 "glslang.y"
+ {
+ yyval.interm = yyvsp[-4].interm;
+ if (parseContext.structQualifierErrorCheck(yyvsp[-2].lex.line, yyvsp[-4].interm.type))
+ parseContext.recover();
+
+ if (parseContext.arrayErrorCheck(yyvsp[-1].lex.line, *yyvsp[-2].lex.string, yyval.interm.type, 0))
+ parseContext.recover();
+ ;}
+ break;
+
+ case 120:
+#line 1254 "glslang.y"
+ {
+ yyval.interm = yyvsp[-5].interm;
+ if (parseContext.structQualifierErrorCheck(yyvsp[-3].lex.line, yyvsp[-5].interm.type))
+ parseContext.recover();
+
+ if (parseContext.arrayErrorCheck(yyvsp[-2].lex.line, *yyvsp[-3].lex.string, yyval.interm.type, yyvsp[-1].interm.intermTypedNode))
+ parseContext.recover();
+ ;}
+ break;
+
+ case 121:
+#line 1262 "glslang.y"
+ {
+ yyval.interm = yyvsp[-4].interm;
+ if (parseContext.structQualifierErrorCheck(yyvsp[-2].lex.line, yyvsp[-4].interm.type))
+ parseContext.recover();
+
+ TIntermNode* intermNode;
+ if (!parseContext.executeInitializer(yyvsp[-2].lex.line, *yyvsp[-2].lex.string, yyvsp[-4].interm.type, yyvsp[0].interm.intermTypedNode, intermNode)) {
+ //
+ // build the intermediate representation
+ //
+ if (intermNode)
+ yyval.interm.intermAggregate = parseContext.intermediate.growAggregate(yyvsp[-4].interm.intermNode, intermNode, yyvsp[-1].lex.line);
+ else
+ yyval.interm.intermAggregate = yyvsp[-4].interm.intermAggregate;
+ } else {
+ parseContext.recover();
+ yyval.interm.intermAggregate = 0;
+ }
+ ;}
+ break;
+
+ case 122:
+#line 1284 "glslang.y"
+ {
+ yyval.interm.type = yyvsp[0].interm.type;
+ yyval.interm.intermAggregate = 0;
+ ;}
+ break;
+
+ case 123:
+#line 1288 "glslang.y"
+ {
+ yyval.interm.intermAggregate = 0;
+ yyval.interm.type = yyvsp[-1].interm.type;
+ if (parseContext.structQualifierErrorCheck(yyvsp[0].lex.line, yyvsp[-1].interm.type))
+ parseContext.recover();
+
+ if (parseContext.nonInitErrorCheck(yyvsp[0].lex.line, *yyvsp[0].lex.string, yyval.interm.type))
+ parseContext.recover();
+ ;}
+ break;
+
+ case 124:
+#line 1297 "glslang.y"
+ {
+ yyval.interm.intermAggregate = 0;
+ yyval.interm.type = yyvsp[-3].interm.type;
+ if (parseContext.structQualifierErrorCheck(yyvsp[-2].lex.line, yyvsp[-3].interm.type))
+ parseContext.recover();
+
+ if (parseContext.arrayErrorCheck(yyvsp[-1].lex.line, *yyvsp[-2].lex.string, yyval.interm.type, 0))
+ parseContext.recover();
+ ;}
+ break;
+
+ case 125:
+#line 1306 "glslang.y"
+ {
+ yyval.interm.intermAggregate = 0;
+ yyval.interm.type = yyvsp[-4].interm.type;
+ if (parseContext.structQualifierErrorCheck(yyvsp[-3].lex.line, yyvsp[-4].interm.type))
+ parseContext.recover();
+
+ if (parseContext.arrayErrorCheck(yyvsp[-2].lex.line, *yyvsp[-3].lex.string, yyval.interm.type, yyvsp[-1].interm.intermTypedNode))
+ parseContext.recover();
+ ;}
+ break;
+
+ case 126:
+#line 1315 "glslang.y"
+ {
+ yyval.interm.type = yyvsp[-3].interm.type;
+ if (parseContext.structQualifierErrorCheck(yyvsp[-2].lex.line, yyvsp[-3].interm.type))
+ parseContext.recover();
+
+ TIntermNode* intermNode;
+ if (!parseContext.executeInitializer(yyvsp[-2].lex.line, *yyvsp[-2].lex.string, yyvsp[-3].interm.type, yyvsp[0].interm.intermTypedNode, intermNode)) {
+ //
+ // Build intermediate representation
+ //
+ if (intermNode)
+ yyval.interm.intermAggregate = parseContext.intermediate.makeAggregate(intermNode, yyvsp[-1].lex.line);
+ else
+ yyval.interm.intermAggregate = 0;
+ } else {
+ parseContext.recover();
+ yyval.interm.intermAggregate = 0;
+ }
+ ;}
+ break;
+
+ case 127:
+#line 1405 "glslang.y"
+ {
+ yyval.interm.type = yyvsp[0].interm.type;
+ ;}
+ break;
+
+ case 128:
+#line 1408 "glslang.y"
+ {
+ TPublicType t = { yyvsp[0].interm.type.type, yyvsp[-1].interm.type.qualifier, yyvsp[0].interm.type.size, yyvsp[0].interm.type.matrix, false, yyvsp[0].interm.type.userDef, 0 };
+ if (yyvsp[-1].interm.type.qualifier == EvqAttribute &&
+ (yyvsp[0].interm.type.type == EbtBool || yyvsp[0].interm.type.type == EbtInt)) {
+ parseContext.error(yyvsp[0].interm.type.line, "cannot be bool or int", getQualifierString(yyvsp[-1].interm.type.qualifier), "");
+ parseContext.recover();
+ }
+ if ((yyvsp[-1].interm.type.qualifier == EvqVaryingIn || yyvsp[-1].interm.type.qualifier == EvqVaryingOut) &&
+ (yyvsp[0].interm.type.type == EbtBool || yyvsp[0].interm.type.type == EbtInt)) {
+ parseContext.error(yyvsp[0].interm.type.line, "cannot be bool or int", getQualifierString(yyvsp[-1].interm.type.qualifier), "");
+ parseContext.recover();
+ }
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 129:
+#line 1425 "glslang.y"
+ {
+ TPublicType t = { EbtVoid, EvqConst, 1, false, false, 0 };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 130:
+#line 1429 "glslang.y"
+ {
+ VERTEX_ONLY("attribute", yyvsp[0].lex.line);
+ if (parseContext.globalErrorCheck(yyvsp[0].lex.line, parseContext.symbolTable.atGlobalLevel(), "attribute"))
+ parseContext.recover();
+ TPublicType t = { EbtVoid, EvqAttribute, 1, false, false, 0 };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 131:
+#line 1436 "glslang.y"
+ {
+ if (parseContext.globalErrorCheck(yyvsp[0].lex.line, parseContext.symbolTable.atGlobalLevel(), "varying"))
+ parseContext.recover();
+ TPublicType t = { EbtVoid, EvqVaryingIn, 1, false, false, 0 };
+ if (parseContext.language == EShLangVertex)
+ t.qualifier = EvqVaryingOut;
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 132:
+#line 1444 "glslang.y"
+ {
+ if (parseContext.globalErrorCheck(yyvsp[0].lex.line, parseContext.symbolTable.atGlobalLevel(), "uniform"))
+ parseContext.recover();
+ TPublicType t = { EbtVoid, EvqUniform, 1, false, false, 0 };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 133:
+#line 1453 "glslang.y"
+ {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtVoid, qual, 1, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 134:
+#line 1458 "glslang.y"
+ {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtFloat, qual, 1, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 135:
+#line 1463 "glslang.y"
+ {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtInt, qual, 1, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 136:
+#line 1468 "glslang.y"
+ {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtBool, qual, 1, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 137:
+#line 1479 "glslang.y"
+ {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtFloat, qual, 2, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 138:
+#line 1484 "glslang.y"
+ {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtFloat, qual, 3, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 139:
+#line 1489 "glslang.y"
+ {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtFloat, qual, 4, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 140:
+#line 1494 "glslang.y"
+ {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtBool, qual, 2, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 141:
+#line 1499 "glslang.y"
+ {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtBool, qual, 3, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 142:
+#line 1504 "glslang.y"
+ {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtBool, qual, 4, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 143:
+#line 1509 "glslang.y"
+ {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtInt, qual, 2, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 144:
+#line 1514 "glslang.y"
+ {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtInt, qual, 3, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 145:
+#line 1519 "glslang.y"
+ {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtInt, qual, 4, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 146:
+#line 1524 "glslang.y"
+ {
+ FRAG_VERT_ONLY("mat2", yyvsp[0].lex.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtFloat, qual, 2, true, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 147:
+#line 1530 "glslang.y"
+ {
+ FRAG_VERT_ONLY("mat3", yyvsp[0].lex.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtFloat, qual, 3, true, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 148:
+#line 1536 "glslang.y"
+ {
+ FRAG_VERT_ONLY("mat4", yyvsp[0].lex.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtFloat, qual, 4, true, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 149:
+#line 1542 "glslang.y"
+ {
+ FRAG_VERT_ONLY("sampler1D", yyvsp[0].lex.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtSampler1D, qual, 1, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 150:
+#line 1548 "glslang.y"
+ {
+ FRAG_VERT_ONLY("sampler2D", yyvsp[0].lex.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtSampler2D, qual, 1, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 151:
+#line 1554 "glslang.y"
+ {
+ FRAG_VERT_ONLY("sampler3D", yyvsp[0].lex.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtSampler3D, qual, 1, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 152:
+#line 1560 "glslang.y"
+ {
+ FRAG_VERT_ONLY("samplerCube", yyvsp[0].lex.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtSamplerCube, qual, 1, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 153:
+#line 1566 "glslang.y"
+ {
+ FRAG_VERT_ONLY("sampler1DShadow", yyvsp[0].lex.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtSampler1DShadow, qual, 1, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 154:
+#line 1572 "glslang.y"
+ {
+ FRAG_VERT_ONLY("sampler2DShadow", yyvsp[0].lex.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtSampler2DShadow, qual, 1, false, false, 0, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 155:
+#line 1578 "glslang.y"
+ {
+ FRAG_VERT_ONLY("struct", yyvsp[0].interm.type.line);
+ yyval.interm.type = yyvsp[0].interm.type;
+ yyval.interm.type.qualifier = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ ;}
+ break;
+
+ case 156:
+#line 1583 "glslang.y"
+ {
+ //
+ // This is for user defined type names. The lexical phase looked up the
+ // type.
+ //
+ TType& structure = static_cast<TVariable*>(yyvsp[0].lex.symbol)->getType();
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtStruct, qual, 1, false, false, &structure, yyvsp[0].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 157:
+#line 1596 "glslang.y"
+ {
+ TType* structure = new TType(yyvsp[-1].interm.typeList, *yyvsp[-3].lex.string);
+ TVariable* userTypeDef = new TVariable(yyvsp[-3].lex.string, *structure, true);
+ if (! parseContext.symbolTable.insert(*userTypeDef)) {
+ parseContext.error(yyvsp[-3].lex.line, "redefinition", yyvsp[-3].lex.string->c_str(), "struct");
+ parseContext.recover();
+ }
+ TPublicType t = { EbtStruct, EvqTemporary, 1, false, false, structure, yyvsp[-4].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 158:
+#line 1606 "glslang.y"
+ {
+ TType* structure = new TType(yyvsp[-1].interm.typeList, TString(""));
+ TPublicType t = { EbtStruct, EvqTemporary, 1, false, false, structure, yyvsp[-3].lex.line };
+ yyval.interm.type = t;
+ ;}
+ break;
+
+ case 159:
+#line 1614 "glslang.y"
+ {
+ yyval.interm.typeList = yyvsp[0].interm.typeList;
+ ;}
+ break;
+
+ case 160:
+#line 1617 "glslang.y"
+ {
+ yyval.interm.typeList = yyvsp[-1].interm.typeList;
+ for (unsigned int i = 0; i < yyvsp[0].interm.typeList->size(); ++i) {
+ for (unsigned int j = 0; j < yyval.interm.typeList->size(); ++j) {
+ if ((*yyval.interm.typeList)[j].type->getFieldName() == (*yyvsp[0].interm.typeList)[i].type->getFieldName()) {
+ parseContext.error((*yyvsp[0].interm.typeList)[i].line, "duplicate field name in structure:", "struct", (*yyvsp[0].interm.typeList)[i].type->getFieldName().c_str());
+ parseContext.recover();
+ }
+ }
+ yyval.interm.typeList->push_back((*yyvsp[0].interm.typeList)[i]);
+ }
+ ;}
+ break;
+
+ case 161:
+#line 1632 "glslang.y"
+ {
+ yyval.interm.typeList = yyvsp[-1].interm.typeList;
+
+ if (parseContext.voidErrorCheck(yyvsp[-2].interm.type.line, (*yyvsp[-1].interm.typeList)[0].type->getFieldName(), yyvsp[-2].interm.type)) {
+ parseContext.recover();
+ }
+ for (unsigned int i = 0; i < yyval.interm.typeList->size(); ++i) {
+ //
+ // Careful not to replace already know aspects of type, like array-ness
+ //
+ (*yyval.interm.typeList)[i].type->setType(yyvsp[-2].interm.type.type, yyvsp[-2].interm.type.size, yyvsp[-2].interm.type.matrix, yyvsp[-2].interm.type.userDef);
+ if (yyvsp[-2].interm.type.userDef)
+ (*yyval.interm.typeList)[i].type->setTypeName(yyvsp[-2].interm.type.userDef->getTypeName());
+ }
+ ;}
+ break;
+
+ case 162:
+#line 1650 "glslang.y"
+ {
+ yyval.interm.typeList = NewPoolTTypeList();
+ yyval.interm.typeList->push_back(yyvsp[0].interm.typeLine);
+ ;}
+ break;
+
+ case 163:
+#line 1654 "glslang.y"
+ {
+ yyval.interm.typeList->push_back(yyvsp[0].interm.typeLine);
+ ;}
+ break;
+
+ case 164:
+#line 1660 "glslang.y"
+ {
+ yyval.interm.typeLine.type = new TType(EbtVoid);
+ yyval.interm.typeLine.line = yyvsp[0].lex.line;
+ yyval.interm.typeLine.type->setFieldName(*yyvsp[0].lex.string);
+ ;}
+ break;
+
+ case 165:
+#line 1665 "glslang.y"
+ {
+ yyval.interm.typeLine.type = new TType(EbtVoid);
+ yyval.interm.typeLine.line = yyvsp[-3].lex.line;
+ yyval.interm.typeLine.type->setFieldName(*yyvsp[-3].lex.string);
+
+ if (yyvsp[-1].interm.intermTypedNode->getAsConstantUnion() == 0 || yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getBasicType() != EbtInt ||
+ yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst <= 0) {
+ parseContext.error(yyvsp[-2].lex.line, "structure field array size must be a positive integer", yyvsp[-3].lex.string->c_str(), "");
+ parseContext.recover();
+ } else {
+ yyval.interm.typeLine.type->setArraySize(yyvsp[-1].interm.intermTypedNode->getAsConstantUnion()->getUnionArrayPointer()->iConst);
+ }
+ ;}
+ break;
+
+ case 166:
+#line 1681 "glslang.y"
+ { yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode; ;}
+ break;
+
+ case 167:
+#line 1685 "glslang.y"
+ { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
+ break;
+
+ case 168:
+#line 1689 "glslang.y"
+ { yyval.interm.intermNode = yyvsp[0].interm.intermAggregate; ;}
+ break;
+
+ case 169:
+#line 1690 "glslang.y"
+ { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
+ break;
+
+ case 170:
+#line 1696 "glslang.y"
+ { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
+ break;
+
+ case 171:
+#line 1697 "glslang.y"
+ { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
+ break;
+
+ case 172:
+#line 1698 "glslang.y"
+ { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
+ break;
+
+ case 173:
+#line 1699 "glslang.y"
+ { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
+ break;
+
+ case 174:
+#line 1700 "glslang.y"
+ { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
+ break;
+
+ case 175:
+#line 1704 "glslang.y"
+ { yyval.interm.intermAggregate = 0; ;}
+ break;
+
+ case 176:
+#line 1705 "glslang.y"
+ { parseContext.symbolTable.push(); ;}
+ break;
+
+ case 177:
+#line 1705 "glslang.y"
+ { parseContext.symbolTable.pop(); ;}
+ break;
+
+ case 178:
+#line 1705 "glslang.y"
+ {
+ if (yyvsp[-2].interm.intermAggregate != 0)
+ yyvsp[-2].interm.intermAggregate->setOperator(EOpSequence);
+ yyval.interm.intermAggregate = yyvsp[-2].interm.intermAggregate;
+ ;}
+ break;
+
+ case 179:
+#line 1713 "glslang.y"
+ { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
+ break;
+
+ case 180:
+#line 1714 "glslang.y"
+ { yyval.interm.intermNode = yyvsp[0].interm.intermNode; ;}
+ break;
+
+ case 181:
+#line 1719 "glslang.y"
+ {
+ yyval.interm.intermNode = 0;
+ ;}
+ break;
+
+ case 182:
+#line 1722 "glslang.y"
+ {
+ if (yyvsp[-1].interm.intermAggregate)
+ yyvsp[-1].interm.intermAggregate->setOperator(EOpSequence);
+ yyval.interm.intermNode = yyvsp[-1].interm.intermAggregate;
+ ;}
+ break;
+
+ case 183:
+#line 1730 "glslang.y"
+ {
+ yyval.interm.intermAggregate = parseContext.intermediate.makeAggregate(yyvsp[0].interm.intermNode, 0);
+ ;}
+ break;
+
+ case 184:
+#line 1733 "glslang.y"
+ {
+ yyval.interm.intermAggregate = parseContext.intermediate.growAggregate(yyvsp[-1].interm.intermAggregate, yyvsp[0].interm.intermNode, 0);
+ ;}
+ break;
+
+ case 185:
+#line 1739 "glslang.y"
+ { yyval.interm.intermNode = 0; ;}
+ break;
+
+ case 186:
+#line 1740 "glslang.y"
+ { yyval.interm.intermNode = static_cast<TIntermNode*>(yyvsp[-1].interm.intermTypedNode); ;}
+ break;
+
+ case 187:
+#line 1744 "glslang.y"
+ {
+ if (parseContext.boolErrorCheck(yyvsp[-4].lex.line, yyvsp[-2].interm.intermTypedNode))
+ parseContext.recover();
+ yyval.interm.intermNode = parseContext.intermediate.addSelection(yyvsp[-2].interm.intermTypedNode, yyvsp[0].interm.nodePair, yyvsp[-4].lex.line);
+ ;}
+ break;
+
+ case 188:
+#line 1752 "glslang.y"
+ {
+ yyval.interm.nodePair.node1 = yyvsp[-2].interm.intermNode;
+ yyval.interm.nodePair.node2 = yyvsp[0].interm.intermNode;
+ ;}
+ break;
+
+ case 189:
+#line 1756 "glslang.y"
+ {
+ yyval.interm.nodePair.node1 = yyvsp[0].interm.intermNode;
+ yyval.interm.nodePair.node2 = 0;
+ ;}
+ break;
+
+ case 190:
+#line 1766 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
+ if (parseContext.boolErrorCheck(yyvsp[0].interm.intermTypedNode->getLine(), yyvsp[0].interm.intermTypedNode))
+ parseContext.recover();
+ ;}
+ break;
+
+ case 191:
+#line 1771 "glslang.y"
+ {
+ TIntermNode* intermNode;
+ if (parseContext.structQualifierErrorCheck(yyvsp[-2].lex.line, yyvsp[-3].interm.type))
+ parseContext.recover();
+ if (parseContext.boolErrorCheck(yyvsp[-2].lex.line, yyvsp[-3].interm.type))
+ parseContext.recover();
+
+ if (!parseContext.executeInitializer(yyvsp[-2].lex.line, *yyvsp[-2].lex.string, yyvsp[-3].interm.type, yyvsp[0].interm.intermTypedNode, intermNode))
+ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
+ else {
+ parseContext.recover();
+ yyval.interm.intermTypedNode = 0;
+ }
+ ;}
+ break;
+
+ case 192:
+#line 1788 "glslang.y"
+ { parseContext.symbolTable.push(); ++parseContext.loopNestingLevel; ;}
+ break;
+
+ case 193:
+#line 1788 "glslang.y"
+ {
+ parseContext.symbolTable.pop();
+ yyval.interm.intermNode = parseContext.intermediate.addLoop(yyvsp[0].interm.intermNode, yyvsp[-2].interm.intermTypedNode, 0, true, yyvsp[-5].lex.line);
+ --parseContext.loopNestingLevel;
+ ;}
+ break;
+
+ case 194:
+#line 1793 "glslang.y"
+ { ++parseContext.loopNestingLevel; ;}
+ break;
+
+ case 195:
+#line 1793 "glslang.y"
+ {
+ if (parseContext.boolErrorCheck(yyvsp[0].lex.line, yyvsp[-2].interm.intermTypedNode))
+ parseContext.recover();
+
+ yyval.interm.intermNode = parseContext.intermediate.addLoop(yyvsp[-5].interm.intermNode, yyvsp[-2].interm.intermTypedNode, 0, false, yyvsp[-4].lex.line);
+ --parseContext.loopNestingLevel;
+ ;}
+ break;
+
+ case 196:
+#line 1800 "glslang.y"
+ { parseContext.symbolTable.push(); ++parseContext.loopNestingLevel; ;}
+ break;
+
+ case 197:
+#line 1800 "glslang.y"
+ {
+ parseContext.symbolTable.pop();
+ yyval.interm.intermNode = parseContext.intermediate.makeAggregate(yyvsp[-3].interm.intermNode, yyvsp[-5].lex.line);
+ yyval.interm.intermNode = parseContext.intermediate.growAggregate(
+ yyval.interm.intermNode,
+ parseContext.intermediate.addLoop(yyvsp[0].interm.intermNode, reinterpret_cast<TIntermTyped*>(yyvsp[-2].interm.nodePair.node1), reinterpret_cast<TIntermTyped*>(yyvsp[-2].interm.nodePair.node2), true, yyvsp[-6].lex.line),
+ yyvsp[-6].lex.line);
+ yyval.interm.intermNode->getAsAggregate()->setOperator(EOpSequence);
+ --parseContext.loopNestingLevel;
+ ;}
+ break;
+
+ case 198:
+#line 1813 "glslang.y"
+ {
+ yyval.interm.intermNode = yyvsp[0].interm.intermNode;
+ ;}
+ break;
+
+ case 199:
+#line 1816 "glslang.y"
+ {
+ yyval.interm.intermNode = yyvsp[0].interm.intermNode;
+ ;}
+ break;
+
+ case 200:
+#line 1822 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = yyvsp[0].interm.intermTypedNode;
+ ;}
+ break;
+
+ case 201:
+#line 1825 "glslang.y"
+ {
+ yyval.interm.intermTypedNode = 0;
+ ;}
+ break;
+
+ case 202:
+#line 1831 "glslang.y"
+ {
+ yyval.interm.nodePair.node1 = yyvsp[-1].interm.intermTypedNode;
+ yyval.interm.nodePair.node2 = 0;
+ ;}
+ break;
+
+ case 203:
+#line 1835 "glslang.y"
+ {
+ yyval.interm.nodePair.node1 = yyvsp[-2].interm.intermTypedNode;
+ yyval.interm.nodePair.node2 = yyvsp[0].interm.intermTypedNode;
+ ;}
+ break;
+
+ case 204:
+#line 1842 "glslang.y"
+ {
+ if (parseContext.loopNestingLevel <= 0) {
+ parseContext.error(yyvsp[-1].lex.line, "continue statement only allowed in loops", "", "");
+ parseContext.recover();
+ }
+ yyval.interm.intermNode = parseContext.intermediate.addBranch(EOpContinue, yyvsp[-1].lex.line);
+ ;}
+ break;
+
+ case 205:
+#line 1849 "glslang.y"
+ {
+ if (parseContext.loopNestingLevel <= 0) {
+ parseContext.error(yyvsp[-1].lex.line, "break statement only allowed in loops", "", "");
+ parseContext.recover();
+ }
+ yyval.interm.intermNode = parseContext.intermediate.addBranch(EOpBreak, yyvsp[-1].lex.line);
+ ;}
+ break;
+
+ case 206:
+#line 1856 "glslang.y"
+ {
+ yyval.interm.intermNode = parseContext.intermediate.addBranch(EOpReturn, yyvsp[-1].lex.line);
+ if (parseContext.currentFunctionType->getBasicType() != EbtVoid) {
+ parseContext.error(yyvsp[-1].lex.line, "non-void function must return a value", "return", "");
+ parseContext.recover();
+ }
+ ;}
+ break;
+
+ case 207:
+#line 1863 "glslang.y"
+ {
+ yyval.interm.intermNode = parseContext.intermediate.addBranch(EOpReturn, yyvsp[-1].interm.intermTypedNode, yyvsp[-2].lex.line);
+ parseContext.functionReturnsValue = true;
+ if (parseContext.currentFunctionType->getBasicType() == EbtVoid) {
+ parseContext.error(yyvsp[-2].lex.line, "void function cannot return a value", "return", "");
+ parseContext.recover();
+ } else if (*(parseContext.currentFunctionType) != yyvsp[-1].interm.intermTypedNode->getType()) {
+ parseContext.error(yyvsp[-2].lex.line, "function return is not matching type:", "return", "");
+ parseContext.recover();
+ }
+ ;}
+ break;
+
+ case 208:
+#line 1874 "glslang.y"
+ {
+ FRAG_ONLY("discard", yyvsp[-1].lex.line);
+ yyval.interm.intermNode = parseContext.intermediate.addBranch(EOpKill, yyvsp[-1].lex.line);
+ ;}
+ break;
+
+ case 209:
+#line 1883 "glslang.y"
+ {
+ yyval.interm.intermNode = yyvsp[0].interm.intermNode;
+ parseContext.treeRoot = yyval.interm.intermNode;
+ ;}
+ break;
+
+ case 210:
+#line 1887 "glslang.y"
+ {
+ yyval.interm.intermNode = parseContext.intermediate.growAggregate(yyvsp[-1].interm.intermNode, yyvsp[0].interm.intermNode, 0);
+ parseContext.treeRoot = yyval.interm.intermNode;
+ ;}
+ break;
+
+ case 211:
+#line 1894 "glslang.y"
+ {
+ yyval.interm.intermNode = yyvsp[0].interm.intermNode;
+ ;}
+ break;
+
+ case 212:
+#line 1897 "glslang.y"
+ {
+ yyval.interm.intermNode = yyvsp[0].interm.intermNode;
+ ;}
+ break;
+
+ case 213:
+#line 1903 "glslang.y"
+ {
+ TFunction& function = *(yyvsp[0].interm.function);
+ TFunction* prevDec = static_cast<TFunction*>(parseContext.symbolTable.find(function.getMangledName()));
+ //
+ // Note: 'prevDec' could be 'function' if this is the first time we've seen function
+ // as it would have just been put in the symbol table. Otherwise, we're looking up
+ // an earlier occurance.
+ //
+ if (prevDec->isDefined()) {
+ //
+ // Then this function already has a body.
+ //
+ parseContext.error(yyvsp[0].interm.line, "function already has a body", function.getName().c_str(), "");
+ parseContext.recover();
+ }
+ prevDec->setDefined();
+
+ //
+ // Raise error message if main function takes any parameters or return anything other than void
+ //
+ if (function.getName() == "main") {
+ if (function.getParamCount() > 0) {
+ parseContext.error(yyvsp[0].interm.line, "function cannot take any parameter(s)", function.getName().c_str(), "");
+ parseContext.recover();
+ }
+ if (function.getReturnType().getBasicType() != EbtVoid) {
+ parseContext.error(yyvsp[0].interm.line, "", function.getReturnType().getBasicString(), "main function cannot return a value" );
+ parseContext.recover();
+ }
+ }
+
+ //
+ // New symbol table scope for body of function plus its arguments
+ //
+ parseContext.symbolTable.push();
+
+ //
+ // Remember the return type for later checking for RETURN statements.
+ //
+ parseContext.currentFunctionType = &(prevDec->getReturnType());
+ parseContext.functionReturnsValue = false;
+
+ //
+ // Insert parameters into the symbol table.
+ // If the parameter has no name, it's not an error, just don't insert it
+ // (could be used for unused args).
+ //
+ // Also, accumulate the list of parameters into the HIL, so lower level code
+ // knows where to find parameters.
+ //
+ TIntermAggregate* paramNodes = new TIntermAggregate;
+ for (int i = 0; i < function.getParamCount(); i++) {
+ TParameter& param = function[i];
+ if (param.name != 0) {
+ TVariable *variable = new TVariable(param.name, *param.type);
+ //
+ // Insert the parameters with name in the symbol table.
+ //
+ if (! parseContext.symbolTable.insert(*variable)) {
+ parseContext.error(yyvsp[0].interm.line, "redefinition", variable->getName().c_str(), "");
+ parseContext.recover();
+ delete variable;
+ }
+ //
+ // Transfer ownership of name pointer to symbol table.
+ //
+ param.name = 0;
+
+ //
+ // Add the parameter to the HIL
+ //
+ paramNodes = parseContext.intermediate.growAggregate(
+ paramNodes,
+ parseContext.intermediate.addSymbol(variable->getUniqueId(),
+ variable->getName(),
+ variable->getType(), yyvsp[0].interm.line),
+ yyvsp[0].interm.line);
+ } else {
+ paramNodes = parseContext.intermediate.growAggregate(paramNodes, parseContext.intermediate.addSymbol(0, "", *param.type, yyvsp[0].interm.line), yyvsp[0].interm.line);
+ }
+ }
+ parseContext.intermediate.setAggregateOperator(paramNodes, EOpParameters, yyvsp[0].interm.line);
+ yyvsp[0].interm.intermAggregate = paramNodes;
+ parseContext.loopNestingLevel = 0;
+ ;}
+ break;
+
+ case 214:
+#line 1988 "glslang.y"
+ {
+ //?? Check that all paths return a value if return type != void ?
+ // May be best done as post process phase on intermediate code
+ if (parseContext.currentFunctionType->getBasicType() != EbtVoid && ! parseContext.functionReturnsValue) {
+ parseContext.error(yyvsp[-2].interm.line, "function does not return a value:", "", yyvsp[-2].interm.function->getName().c_str());
+ parseContext.recover();
+ }
+ parseContext.symbolTable.pop();
+ yyval.interm.intermNode = parseContext.intermediate.growAggregate(yyvsp[-2].interm.intermAggregate, yyvsp[0].interm.intermNode, 0);
+ parseContext.intermediate.setAggregateOperator(yyval.interm.intermNode, EOpFunction, yyvsp[-2].interm.line);
+ yyval.interm.intermNode->getAsAggregate()->setName(yyvsp[-2].interm.function->getMangledName().c_str());
+ yyval.interm.intermNode->getAsAggregate()->setType(yyvsp[-2].interm.function->getReturnType());
+
+ // store the pragma information for debug and optimize and other vendor specific
+ // information. This information can be queried from the parse tree
+ yyval.interm.intermNode->getAsAggregate()->setOptimize(parseContext.contextPragma.optimize);
+ yyval.interm.intermNode->getAsAggregate()->setDebug(parseContext.contextPragma.debug);
+ yyval.interm.intermNode->getAsAggregate()->addToPragmaTable(parseContext.contextPragma.pragmaTable);
+ ;}
+ break;
+
+
+ }
+
+/* Line 999 of yacc.c. */
+#line 4158 "glslang.tab.c"
+
+ yyvsp -= yylen;
+ yyssp -= yylen;
+
+
+ YY_STACK_PRINT (yyss, yyssp);
+
+ *++yyvsp = yyval;
+
+
+ /* Now `shift' the result of the reduction. Determine what state
+ that goes to, based on the state we popped back to and the rule
+ number reduced by. */
+
+ yyn = yyr1[yyn];
+
+ yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
+ if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+ yystate = yytable[yystate];
+ else
+ yystate = yydefgoto[yyn - YYNTOKENS];
+
+ goto yynewstate;
+
+
+/*------------------------------------.
+| yyerrlab -- here on detecting error |
+`------------------------------------*/
+yyerrlab:
+ /* If not already recovering from an error, report this error. */
+ if (!yyerrstatus)
+ {
+ ++yynerrs;
+#if YYERROR_VERBOSE
+ yyn = yypact[yystate];
+
+ if (YYPACT_NINF < yyn && yyn < YYLAST)
+ {
+ YYSIZE_T yysize = 0;
+ int yytype = YYTRANSLATE (yychar);
+ char *yymsg;
+ int yyx, yycount;
+
+ yycount = 0;
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. */
+ for (yyx = yyn < 0 ? -yyn : 0;
+ yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+ yysize += yystrlen (yytname[yyx]) + 15, yycount++;
+ yysize += yystrlen ("syntax error, unexpected ") + 1;
+ yysize += yystrlen (yytname[yytype]);
+ yymsg = (char *) YYSTACK_ALLOC (yysize);
+ if (yymsg != 0)
+ {
+ char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
+ yyp = yystpcpy (yyp, yytname[yytype]);
+
+ if (yycount < 5)
+ {
+ yycount = 0;
+ for (yyx = yyn < 0 ? -yyn : 0;
+ yyx < (int) (sizeof (yytname) / sizeof (char *));
+ yyx++)
+ if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
+ {
+ const char *yyq = ! yycount ? ", expecting " : " or ";
+ yyp = yystpcpy (yyp, yyq);
+ yyp = yystpcpy (yyp, yytname[yyx]);
+ yycount++;
+ }
+ }
+ yyerror (yymsg);
+ YYSTACK_FREE (yymsg);
+ }
+ else
+ yyerror ("syntax error; also virtual memory exhausted");
+ }
+ else
+#endif /* YYERROR_VERBOSE */
+ yyerror ("syntax error");
+ }
+
+
+
+ if (yyerrstatus == 3)
+ {
+ /* If just tried and failed to reuse lookahead token after an
+ error, discard it. */
+
+ /* Return failure if at end of input. */
+ if (yychar == YYEOF)
+ {
+ /* Pop the error token. */
+ YYPOPSTACK;
+ /* Pop the rest of the stack. */
+ while (yyss < yyssp)
+ {
+ YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
+ yydestruct (yystos[*yyssp], yyvsp);
+ YYPOPSTACK;
+ }
+ YYABORT;
+ }
+
+ YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
+ yydestruct (yytoken, &yylval);
+ yychar = YYEMPTY;
+
+ }
+
+ /* Else will try to reuse lookahead token after shifting the error
+ token. */
+ goto yyerrlab1;
+
+
+/*----------------------------------------------------.
+| yyerrlab1 -- error raised explicitly by an action. |
+`----------------------------------------------------*/
+yyerrlab1:
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
+
+ for (;;)
+ {
+ yyn = yypact[yystate];
+ if (yyn != YYPACT_NINF)
+ {
+ yyn += YYTERROR;
+ if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+ {
+ yyn = yytable[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
+
+ /* Pop the current state because it cannot handle the error token. */
+ if (yyssp == yyss)
+ YYABORT;
+
+ YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
+ yydestruct (yystos[yystate], yyvsp);
+ yyvsp--;
+ yystate = *--yyssp;
+
+ YY_STACK_PRINT (yyss, yyssp);
+ }
+
+ if (yyn == YYFINAL)
+ YYACCEPT;
+
+ YYDPRINTF ((stderr, "Shifting error token, "));
+
+ *++yyvsp = yylval;
+
+
+ yystate = yyn;
+ goto yynewstate;
+
+
+/*-------------------------------------.
+| yyacceptlab -- YYACCEPT comes here. |
+`-------------------------------------*/
+yyacceptlab:
+ yyresult = 0;
+ goto yyreturn;
+
+/*-----------------------------------.
+| yyabortlab -- YYABORT comes here. |
+`-----------------------------------*/
+yyabortlab:
+ yyresult = 1;
+ goto yyreturn;
+
+#ifndef yyoverflow
+/*----------------------------------------------.
+| yyoverflowlab -- parser overflow comes here. |
+`----------------------------------------------*/
+yyoverflowlab:
+ yyerror ("parser stack overflow");
+ yyresult = 2;
+ /* Fall through. */
+#endif
+
+yyreturn:
+#ifndef yyoverflow
+ if (yyss != yyssa)
+ YYSTACK_FREE (yyss);
+#endif
+ return yyresult;
+}
+
+
+#line 209 "glslang.y"
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/InfoSink.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/InfoSink.cpp
new file mode 100755
index 000000000..9a1aaa26f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/InfoSink.cpp
@@ -0,0 +1,107 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#include "Include/InfoSink.h"
+
+#ifdef _WIN32
+ #include <windows.h>
+#endif
+
+void TInfoSinkBase::append(const char *s)
+{
+ if (outputStream & EString) {
+ checkMem(strlen(s));
+ sink.append(s);
+ }
+
+#ifdef _WIN32
+ if (outputStream & EDebugger)
+ OutputDebugString(s);
+#endif
+
+ if (outputStream & EStdOut)
+ fprintf(stdout, "%s", s);
+}
+
+void TInfoSinkBase::append(int count, char c)
+{
+ if (outputStream & EString) {
+ checkMem(count);
+ sink.append(count, c);
+ }
+
+#ifdef _WIN32
+ if (outputStream & EDebugger) {
+ char str[2];
+ str[0] = c;
+ str[1] = '\0';
+ OutputDebugString(str);
+ }
+#endif
+
+ if (outputStream & EStdOut)
+ fprintf(stdout, "%c", c);
+}
+
+void TInfoSinkBase::append(const TPersistString& t)
+{
+ if (outputStream & EString) {
+ checkMem(t.size());
+ sink.append(t);
+ }
+
+#ifdef _WIN32
+ if (outputStream & EDebugger)
+ OutputDebugString(t.c_str());
+#endif
+
+ if (outputStream & EStdOut)
+ fprintf(stdout, "%s", t.c_str());
+}
+
+void TInfoSinkBase::append(const TString& t)
+{
+ if (outputStream & EString) {
+ checkMem(t.size());
+ sink.append(t.c_str());
+ }
+
+#ifdef _WIN32
+ if (outputStream & EDebugger)
+ OutputDebugString(t.c_str());
+#endif
+
+ if (outputStream & EStdOut)
+ fprintf(stdout, "%s", t.c_str());
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Initialize.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Initialize.cpp
new file mode 100755
index 000000000..0913e531a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Initialize.cpp
@@ -0,0 +1,948 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+//
+// Create strings that declare built-in definitions, add built-ins that
+// cannot be expressed in the files, and establish mappings between
+// built-in functions and operators.
+//
+
+#include "../Include/intermediate.h"
+#include "Initialize.h"
+
+void TBuiltIns::initialize()
+{
+ //
+ // Initialize all the built-in strings for parsing.
+ //
+ TString BuiltInFunctions;
+ TString BuiltInFunctionsVertex;
+ TString BuiltInFunctionsFragment;
+ TString StandardVertexVaryings;
+ TString StandardFragmentVaryings;
+ TString StandardVertexAttributes;
+ TString StandardUniforms;
+
+ {
+ //============================================================================
+ //
+ // Prototypes for built-in functions seen by both vertex and fragment shaders.
+ //
+ //============================================================================
+
+ TString& s = BuiltInFunctions;
+
+ //
+ // Angle and Trigonometric Functions.
+ //
+ s.append(TString("float radians(float degrees);"));
+ s.append(TString("vec2 radians(vec2 degrees);"));
+ s.append(TString("vec3 radians(vec3 degrees);"));
+ s.append(TString("vec4 radians(vec4 degrees);"));
+
+ s.append(TString("float degrees(float radians);"));
+ s.append(TString("vec2 degrees(vec2 radians);"));
+ s.append(TString("vec3 degrees(vec3 radians);"));
+ s.append(TString("vec4 degrees(vec4 radians);"));
+
+ s.append(TString("float sin(float angle);"));
+ s.append(TString("vec2 sin(vec2 angle);"));
+ s.append(TString("vec3 sin(vec3 angle);"));
+ s.append(TString("vec4 sin(vec4 angle);"));
+
+ s.append(TString("float cos(float angle);"));
+ s.append(TString("vec2 cos(vec2 angle);"));
+ s.append(TString("vec3 cos(vec3 angle);"));
+ s.append(TString("vec4 cos(vec4 angle);"));
+
+ s.append(TString("float tan(float angle);"));
+ s.append(TString("vec2 tan(vec2 angle);"));
+ s.append(TString("vec3 tan(vec3 angle);"));
+ s.append(TString("vec4 tan(vec4 angle);"));
+
+ s.append(TString("float asin(float x);"));
+ s.append(TString("vec2 asin(vec2 x);"));
+ s.append(TString("vec3 asin(vec3 x);"));
+ s.append(TString("vec4 asin(vec4 x);"));
+
+ s.append(TString("float acos(float x);"));
+ s.append(TString("vec2 acos(vec2 x);"));
+ s.append(TString("vec3 acos(vec3 x);"));
+ s.append(TString("vec4 acos(vec4 x);"));
+
+ s.append(TString("float atan(float y, float x);"));
+ s.append(TString("vec2 atan(vec2 y, vec2 x);"));
+ s.append(TString("vec3 atan(vec3 y, vec3 x);"));
+ s.append(TString("vec4 atan(vec4 y, vec4 x);"));
+
+ s.append(TString("float atan(float y_over_x);"));
+ s.append(TString("vec2 atan(vec2 y_over_x);"));
+ s.append(TString("vec3 atan(vec3 y_over_x);"));
+ s.append(TString("vec4 atan(vec4 y_over_x);"));
+
+ //
+ // Exponential Functions.
+ //
+ s.append(TString("float pow(float x, float y);"));
+ s.append(TString("vec2 pow(vec2 x, vec2 y);"));
+ s.append(TString("vec3 pow(vec3 x, vec3 y);"));
+ s.append(TString("vec4 pow(vec4 x, vec4 y);"));
+
+ s.append(TString("float exp(float x);"));
+ s.append(TString("vec2 exp(vec2 x);"));
+ s.append(TString("vec3 exp(vec3 x);"));
+ s.append(TString("vec4 exp(vec4 x);"));
+
+ s.append(TString("float log(float x);"));
+ s.append(TString("vec2 log(vec2 x);"));
+ s.append(TString("vec3 log(vec3 x);"));
+ s.append(TString("vec4 log(vec4 x);"));
+
+ s.append(TString("float exp2(float x);"));
+ s.append(TString("vec2 exp2(vec2 x);"));
+ s.append(TString("vec3 exp2(vec3 x);"));
+ s.append(TString("vec4 exp2(vec4 x);"));
+
+ s.append(TString("float log2(float x);"));
+ s.append(TString("vec2 log2(vec2 x);"));
+ s.append(TString("vec3 log2(vec3 x);"));
+ s.append(TString("vec4 log2(vec4 x);"));
+
+ s.append(TString("float sqrt(float x);"));
+ s.append(TString("vec2 sqrt(vec2 x);"));
+ s.append(TString("vec3 sqrt(vec3 x);"));
+ s.append(TString("vec4 sqrt(vec4 x);"));
+
+ s.append(TString("float inversesqrt(float x);"));
+ s.append(TString("vec2 inversesqrt(vec2 x);"));
+ s.append(TString("vec3 inversesqrt(vec3 x);"));
+ s.append(TString("vec4 inversesqrt(vec4 x);"));
+
+ //
+ // Common Functions.
+ //
+ s.append(TString("float abs(float x);"));
+ s.append(TString("vec2 abs(vec2 x);"));
+ s.append(TString("vec3 abs(vec3 x);"));
+ s.append(TString("vec4 abs(vec4 x);"));
+
+ s.append(TString("float sign(float x);"));
+ s.append(TString("vec2 sign(vec2 x);"));
+ s.append(TString("vec3 sign(vec3 x);"));
+ s.append(TString("vec4 sign(vec4 x);"));
+
+ s.append(TString("float floor(float x);"));
+ s.append(TString("vec2 floor(vec2 x);"));
+ s.append(TString("vec3 floor(vec3 x);"));
+ s.append(TString("vec4 floor(vec4 x);"));
+
+ s.append(TString("float ceil(float x);"));
+ s.append(TString("vec2 ceil(vec2 x);"));
+ s.append(TString("vec3 ceil(vec3 x);"));
+ s.append(TString("vec4 ceil(vec4 x);"));
+
+ s.append(TString("float fract(float x);"));
+ s.append(TString("vec2 fract(vec2 x);"));
+ s.append(TString("vec3 fract(vec3 x);"));
+ s.append(TString("vec4 fract(vec4 x);"));
+
+ s.append(TString("float mod(float x, float y);"));
+ s.append(TString("vec2 mod(vec2 x, float y);"));
+ s.append(TString("vec3 mod(vec3 x, float y);"));
+ s.append(TString("vec4 mod(vec4 x, float y);"));
+ s.append(TString("vec2 mod(vec2 x, vec2 y);"));
+ s.append(TString("vec3 mod(vec3 x, vec3 y);"));
+ s.append(TString("vec4 mod(vec4 x, vec4 y);"));
+
+ s.append(TString("float min(float x, float y);"));
+ s.append(TString("vec2 min(vec2 x, float y);"));
+ s.append(TString("vec3 min(vec3 x, float y);"));
+ s.append(TString("vec4 min(vec4 x, float y);"));
+ s.append(TString("vec2 min(vec2 x, vec2 y);"));
+ s.append(TString("vec3 min(vec3 x, vec3 y);"));
+ s.append(TString("vec4 min(vec4 x, vec4 y);"));
+
+ s.append(TString("float max(float x, float y);"));
+ s.append(TString("vec2 max(vec2 x, float y);"));
+ s.append(TString("vec3 max(vec3 x, float y);"));
+ s.append(TString("vec4 max(vec4 x, float y);"));
+ s.append(TString("vec2 max(vec2 x, vec2 y);"));
+ s.append(TString("vec3 max(vec3 x, vec3 y);"));
+ s.append(TString("vec4 max(vec4 x, vec4 y);"));
+
+ s.append(TString("float clamp(float x, float minVal, float maxVal);"));
+ s.append(TString("vec2 clamp(vec2 x, float minVal, float maxVal);"));
+ s.append(TString("vec3 clamp(vec3 x, float minVal, float maxVal);"));
+ s.append(TString("vec4 clamp(vec4 x, float minVal, float maxVal);"));
+ s.append(TString("vec2 clamp(vec2 x, vec2 minVal, vec2 maxVal);"));
+ s.append(TString("vec3 clamp(vec3 x, vec3 minVal, vec3 maxVal);"));
+ s.append(TString("vec4 clamp(vec4 x, vec4 minVal, vec4 maxVal);"));
+
+ s.append(TString("float mix(float x, float y, float a);"));
+ s.append(TString("vec2 mix(vec2 x, vec2 y, float a);"));
+ s.append(TString("vec3 mix(vec3 x, vec3 y, float a);"));
+ s.append(TString("vec4 mix(vec4 x, vec4 y, float a);"));
+ s.append(TString("vec2 mix(vec2 x, vec2 y, vec2 a);"));
+ s.append(TString("vec3 mix(vec3 x, vec3 y, vec3 a);"));
+ s.append(TString("vec4 mix(vec4 x, vec4 y, vec4 a);"));
+
+ s.append(TString("float step(float edge, float x);"));
+ s.append(TString("vec2 step(vec2 edge, vec2 x);"));
+ s.append(TString("vec3 step(vec3 edge, vec3 x);"));
+ s.append(TString("vec4 step(vec4 edge, vec4 x);"));
+ s.append(TString("vec2 step(float edge, vec2 x);"));
+ s.append(TString("vec3 step(float edge, vec3 x);"));
+ s.append(TString("vec4 step(float edge, vec4 x);"));
+
+ s.append(TString("float smoothstep(float edge0, float edge1, float x);"));
+ s.append(TString("vec2 smoothstep(vec2 edge0, vec2 edge1, vec2 x);"));
+ s.append(TString("vec3 smoothstep(vec3 edge0, vec3 edge1, vec3 x);"));
+ s.append(TString("vec4 smoothstep(vec4 edge0, vec4 edge1, vec4 x);"));
+ s.append(TString("vec2 smoothstep(float edge0, float edge1, vec2 x);"));
+ s.append(TString("vec3 smoothstep(float edge0, float edge1, vec3 x);"));
+ s.append(TString("vec4 smoothstep(float edge0, float edge1, vec4 x);"));
+
+ //
+ // Geometric Functions.
+ //
+ s.append(TString("float length(float x);"));
+ s.append(TString("float length(vec2 x);"));
+ s.append(TString("float length(vec3 x);"));
+ s.append(TString("float length(vec4 x);"));
+
+ s.append(TString("float distance(float p0, float p1);"));
+ s.append(TString("float distance(vec2 p0, vec2 p1);"));
+ s.append(TString("float distance(vec3 p0, vec3 p1);"));
+ s.append(TString("float distance(vec4 p0, vec4 p1);"));
+
+ s.append(TString("float dot(float x, float y);"));
+ s.append(TString("float dot(vec2 x, vec2 y);"));
+ s.append(TString("float dot(vec3 x, vec3 y);"));
+ s.append(TString("float dot(vec4 x, vec4 y);"));
+
+ s.append(TString("vec3 cross(vec3 x, vec3 y);"));
+ s.append(TString("float normalize(float x);"));
+ s.append(TString("vec2 normalize(vec2 x);"));
+ s.append(TString("vec3 normalize(vec3 x);"));
+ s.append(TString("vec4 normalize(vec4 x);"));
+
+ s.append(TString("float faceforward(float N, float I, float Nref);"));
+ s.append(TString("vec2 faceforward(vec2 N, vec2 I, vec2 Nref);"));
+ s.append(TString("vec3 faceforward(vec3 N, vec3 I, vec3 Nref);"));
+ s.append(TString("vec4 faceforward(vec4 N, vec4 I, vec4 Nref);"));
+
+ s.append(TString("float reflect(float I, float N);"));
+ s.append(TString("vec2 reflect(vec2 I, vec2 N);"));
+ s.append(TString("vec3 reflect(vec3 I, vec3 N);"));
+ s.append(TString("vec4 reflect(vec4 I, vec4 N);"));
+
+ s.append(TString("float refract(float I, float N, float eta);"));
+ s.append(TString("vec2 refract(vec2 I, vec2 N, float eta);"));
+ s.append(TString("vec3 refract(vec3 I, vec3 N, float eta);"));
+ s.append(TString("vec4 refract(vec4 I, vec4 N, float eta);"));
+
+ //
+ // Matrix Functions.
+ //
+ s.append(TString("mat2 matrixCompMult(mat2 x, mat2 y);"));
+ s.append(TString("mat3 matrixCompMult(mat3 x, mat3 y);"));
+ s.append(TString("mat4 matrixCompMult(mat4 x, mat4 y);"));
+
+ //
+ // Vector relational functions.
+ //
+ s.append(TString("bvec2 lessThan(vec2 x, vec2 y);"));
+ s.append(TString("bvec3 lessThan(vec3 x, vec3 y);"));
+ s.append(TString("bvec4 lessThan(vec4 x, vec4 y);"));
+
+ s.append(TString("bvec2 lessThan(ivec2 x, ivec2 y);"));
+ s.append(TString("bvec3 lessThan(ivec3 x, ivec3 y);"));
+ s.append(TString("bvec4 lessThan(ivec4 x, ivec4 y);"));
+
+ s.append(TString("bvec2 lessThanEqual(vec2 x, vec2 y);"));
+ s.append(TString("bvec3 lessThanEqual(vec3 x, vec3 y);"));
+ s.append(TString("bvec4 lessThanEqual(vec4 x, vec4 y);"));
+
+ s.append(TString("bvec2 lessThanEqual(ivec2 x, ivec2 y);"));
+ s.append(TString("bvec3 lessThanEqual(ivec3 x, ivec3 y);"));
+ s.append(TString("bvec4 lessThanEqual(ivec4 x, ivec4 y);"));
+
+ s.append(TString("bvec2 greaterThan(vec2 x, vec2 y);"));
+ s.append(TString("bvec3 greaterThan(vec3 x, vec3 y);"));
+ s.append(TString("bvec4 greaterThan(vec4 x, vec4 y);"));
+
+ s.append(TString("bvec2 greaterThan(ivec2 x, ivec2 y);"));
+ s.append(TString("bvec3 greaterThan(ivec3 x, ivec3 y);"));
+ s.append(TString("bvec4 greaterThan(ivec4 x, ivec4 y);"));
+
+ s.append(TString("bvec2 greaterThanEqual(vec2 x, vec2 y);"));
+ s.append(TString("bvec3 greaterThanEqual(vec3 x, vec3 y);"));
+ s.append(TString("bvec4 greaterThanEqual(vec4 x, vec4 y);"));
+
+ s.append(TString("bvec2 greaterThanEqual(ivec2 x, ivec2 y);"));
+ s.append(TString("bvec3 greaterThanEqual(ivec3 x, ivec3 y);"));
+ s.append(TString("bvec4 greaterThanEqual(ivec4 x, ivec4 y);"));
+
+ s.append(TString("bvec2 equal(vec2 x, vec2 y);"));
+ s.append(TString("bvec3 equal(vec3 x, vec3 y);"));
+ s.append(TString("bvec4 equal(vec4 x, vec4 y);"));
+
+ s.append(TString("bvec2 equal(ivec2 x, ivec2 y);"));
+ s.append(TString("bvec3 equal(ivec3 x, ivec3 y);"));
+ s.append(TString("bvec4 equal(ivec4 x, ivec4 y);"));
+
+ s.append(TString("bvec2 equal(bvec2 x, bvec2 y);"));
+ s.append(TString("bvec3 equal(bvec3 x, bvec3 y);"));
+ s.append(TString("bvec4 equal(bvec4 x, bvec4 y);"));
+
+ s.append(TString("bvec2 notEqual(vec2 x, vec2 y);"));
+ s.append(TString("bvec3 notEqual(vec3 x, vec3 y);"));
+ s.append(TString("bvec4 notEqual(vec4 x, vec4 y);"));
+
+ s.append(TString("bvec2 notEqual(ivec2 x, ivec2 y);"));
+ s.append(TString("bvec3 notEqual(ivec3 x, ivec3 y);"));
+ s.append(TString("bvec4 notEqual(ivec4 x, ivec4 y);"));
+
+ s.append(TString("bvec2 notEqual(bvec2 x, bvec2 y);"));
+ s.append(TString("bvec3 notEqual(bvec3 x, bvec3 y);"));
+ s.append(TString("bvec4 notEqual(bvec4 x, bvec4 y);"));
+
+ s.append(TString("bool any(bvec2 x);"));
+ s.append(TString("bool any(bvec3 x);"));
+ s.append(TString("bool any(bvec4 x);"));
+
+ s.append(TString("bool all(bvec2 x);"));
+ s.append(TString("bool all(bvec3 x);"));
+ s.append(TString("bool all(bvec4 x);"));
+
+ s.append(TString("bvec2 not(bvec2 x);"));
+ s.append(TString("bvec3 not(bvec3 x);"));
+ s.append(TString("bvec4 not(bvec4 x);"));
+
+ //
+ // Texture Functions.
+ //
+ s.append(TString("vec4 texture1D(sampler1D sampler, float coord);"));
+ s.append(TString("vec4 texture1DProj(sampler1D sampler, vec2 coord);"));
+ s.append(TString("vec4 texture1DProj(sampler1D sampler, vec4 coord);"));
+
+ s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord);"));
+ s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord);"));
+ s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord);"));
+
+ s.append(TString("vec4 texture3D(sampler3D sampler, vec3 coord);"));
+ s.append(TString("vec4 texture3DProj(sampler3D sampler, vec4 coord);"));
+
+ s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord);"));
+
+ s.append(TString("vec4 shadow1D(sampler1DShadow sampler, vec3 coord);"));
+
+ s.append(TString("vec4 shadow2D(sampler2DShadow sampler, vec3 coord);"));
+
+ s.append(TString("vec4 shadow1DProj(sampler1DShadow sampler, vec4 coord);"));
+
+ s.append(TString("vec4 shadow2DProj(sampler2DShadow sampler, vec4 coord);"));
+
+
+ //
+ // Noise functions.
+ //
+ s.append(TString("float noise1(float x);"));
+ s.append(TString("float noise1(vec2 x);"));
+ s.append(TString("float noise1(vec3 x);"));
+ s.append(TString("float noise1(vec4 x);"));
+
+ s.append(TString("vec2 noise2(float x);"));
+ s.append(TString("vec2 noise2(vec2 x);"));
+ s.append(TString("vec2 noise2(vec3 x);"));
+ s.append(TString("vec2 noise2(vec4 x);"));
+
+ s.append(TString("vec3 noise3(float x);"));
+ s.append(TString("vec3 noise3(vec2 x);"));
+ s.append(TString("vec3 noise3(vec3 x);"));
+ s.append(TString("vec3 noise3(vec4 x);"));
+
+ s.append(TString("vec4 noise4(float x);"));
+ s.append(TString("vec4 noise4(vec2 x);"));
+ s.append(TString("vec4 noise4(vec3 x);"));
+ s.append(TString("vec4 noise4(vec4 x);"));
+
+ s.append(TString("\n"));
+ }
+ {
+ //============================================================================
+ //
+ // Prototypes for built-in functions seen by vertex shaders only.
+ //
+ //============================================================================
+
+ TString& s = BuiltInFunctionsVertex;
+
+ //
+ // Geometric Functions.
+ //
+ s.append(TString("vec4 ftransform();"));
+
+ //
+ // Texture Functions.
+ //
+ s.append(TString("vec4 texture1DLod(sampler1D sampler, float coord, float lod);"));
+ s.append(TString("vec4 texture1DProjLod(sampler1D sampler, vec2 coord, float lod);"));
+ s.append(TString("vec4 texture1DProjLod(sampler1D sampler, vec4 coord, float lod);"));
+
+ s.append(TString("vec4 texture2DLod(sampler2D sampler, vec2 coord, float lod);"));
+ s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec3 coord, float lod);"));
+ s.append(TString("vec4 texture2DProjLod(sampler2D sampler, vec4 coord, float lod);"));
+
+ s.append(TString("vec4 texture3DLod(sampler3D sampler, vec3 coord, float lod);"));
+ s.append(TString("vec4 texture3DProjLod(sampler3D sampler, vec4 coord, float lod);"));
+ s.append(TString("vec4 textureCubeLod(samplerCube sampler, vec3 coord, float lod);"));
+
+ s.append(TString("vec4 shadow1DLod(sampler1DShadow sampler, vec3 coord, float lod);"));
+ s.append(TString("vec4 shadow2DLod(sampler2DShadow sampler, vec3 coord, float lod);"));
+ s.append(TString("vec4 shadow1DProjLod(sampler1DShadow sampler, vec4 coord, float lod);"));
+ s.append(TString("vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod);"));
+
+ s.append(TString("\n"));
+ }
+ {
+ //============================================================================
+ //
+ // Prototypes for built-in functions seen by fragment shaders only.
+ //
+ //============================================================================
+
+ TString& s = BuiltInFunctionsFragment;
+
+ //
+ // Texture Functions.
+ //
+ s.append(TString("vec4 texture1D(sampler1D sampler, float coord, float bias);"));
+ s.append(TString("vec4 texture1DProj(sampler1D sampler, vec2 coord, float bias);"));
+ s.append(TString("vec4 texture1DProj(sampler1D sampler, vec4 coord, float bias);"));
+
+ s.append(TString("vec4 texture2D(sampler2D sampler, vec2 coord, float bias);"));
+ s.append(TString("vec4 texture2DProj(sampler2D sampler, vec3 coord, float bias);"));
+ s.append(TString("vec4 texture2DProj(sampler2D sampler, vec4 coord, float bias);"));
+
+ s.append(TString("vec4 texture3D(sampler3D sampler, vec3 coord, float bias);"));
+ s.append(TString("vec4 texture3DProj(sampler3D sampler, vec4 coord, float bias);"));
+ s.append(TString("vec4 textureCube(samplerCube sampler, vec3 coord, float bias);"));
+
+ s.append(TString("vec4 shadow1D(sampler1DShadow sampler, vec3 coord, float bias);"));
+ s.append(TString("vec4 shadow2D(sampler2DShadow sampler, vec3 coord, float bias);"));
+ s.append(TString("vec4 shadow1DProj(sampler1DShadow sampler, vec4 coord, float bias);"));
+ s.append(TString("vec4 shadow2DProj(sampler2DShadow sampler, vec4 coord, float bias);"));
+
+ s.append(TString("float dFdx(float p);"));
+ s.append(TString("vec2 dFdx(vec2 p);"));
+ s.append(TString("vec3 dFdx(vec3 p);"));
+ s.append(TString("vec4 dFdx(vec4 p);"));
+
+ s.append(TString("float dFdy(float p);"));
+ s.append(TString("vec2 dFdy(vec2 p);"));
+ s.append(TString("vec3 dFdy(vec3 p);"));
+ s.append(TString("vec4 dFdy(vec4 p);"));
+
+ s.append(TString("float fwidth(float p);"));
+ s.append(TString("vec2 fwidth(vec2 p);"));
+ s.append(TString("vec3 fwidth(vec3 p);"));
+ s.append(TString("vec4 fwidth(vec4 p);"));
+
+ s.append(TString("\n"));
+ }
+ {
+ //============================================================================
+ //
+ // Standard Uniforms
+ //
+ //============================================================================
+
+ TString& s = StandardUniforms;
+
+
+ //
+ // OpenGL'uniform' state. Page numbers are in reference to version
+ // 1.4 of the OpenGL specification.
+ //
+
+ //
+ // Matrix state. p. 31, 32, 37, 39, 40.
+ //
+ s.append(TString("uniform mat4 gl_ModelViewMatrix;"));
+ s.append(TString("uniform mat4 gl_ProjectionMatrix;"));
+ s.append(TString("uniform mat4 gl_ModelViewProjectionMatrix;"));
+
+ //
+ // Derived matrix state that provides inverse and transposed versions
+ // of the matrices above.
+ //
+ s.append(TString("uniform mat3 gl_NormalMatrix;"));
+
+ s.append(TString("uniform mat4 gl_ModelViewMatrixInverse;"));
+ s.append(TString("uniform mat4 gl_ProjectionMatrixInverse;"));
+ s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixInverse;"));
+
+ s.append(TString("uniform mat4 gl_ModelViewMatrixTranspose;"));
+ s.append(TString("uniform mat4 gl_ProjectionMatrixTranspose;"));
+ s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixTranspose;"));
+
+ s.append(TString("uniform mat4 gl_ModelViewMatrixInverseTranspose;"));
+ s.append(TString("uniform mat4 gl_ProjectionMatrixInverseTranspose;"));
+ s.append(TString("uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;"));
+
+ //
+ // Normal scaling p. 39.
+ //
+ s.append(TString("uniform float gl_NormalScale;"));
+
+ //
+ // Depth range in window coordinates, p. 33
+ //
+ s.append(TString("struct gl_DepthRangeParameters {"));
+ s.append(TString(" float near;")); // n
+ s.append(TString(" float far;")); // f
+ s.append(TString(" float diff;")); // f - n
+ s.append(TString("};"));
+ s.append(TString("uniform gl_DepthRangeParameters gl_DepthRange;"));
+
+
+ //
+ // Point Size, p. 66, 67.
+ //
+ s.append(TString("struct gl_PointParameters {"));
+ s.append(TString(" float size;"));
+ s.append(TString(" float sizeMin;"));
+ s.append(TString(" float sizeMax;"));
+ s.append(TString(" float fadeThresholdSize;"));
+ s.append(TString(" float distanceConstantAttenuation;"));
+ s.append(TString(" float distanceLinearAttenuation;"));
+ s.append(TString(" float distanceQuadraticAttenuation;"));
+ s.append(TString("};"));
+
+ s.append(TString("uniform gl_PointParameters gl_Point;"));
+
+ //
+ // Material State p. 50, 55.
+ //
+ s.append(TString("struct gl_MaterialParameters {"));
+ s.append(TString(" vec4 emission;")); // Ecm
+ s.append(TString(" vec4 ambient;")); // Acm
+ s.append(TString(" vec4 diffuse;")); // Dcm
+ s.append(TString(" vec4 specular;")); // Scm
+ s.append(TString(" float shininess;")); // Srm
+ s.append(TString("};"));
+ s.append(TString("uniform gl_MaterialParameters gl_FrontMaterial;"));
+ s.append(TString("uniform gl_MaterialParameters gl_BackMaterial;"));
+
+ //
+ // Light State p 50, 53, 55.
+ //
+
+ s.append(TString("struct gl_LightSourceParameters {"));
+ s.append(TString(" vec4 ambient;")); // Acli
+ s.append(TString(" vec4 diffuse;")); // Dcli
+ s.append(TString(" vec4 specular;")); // Scli
+ s.append(TString(" vec4 position;")); // Ppli
+ s.append(TString(" vec4 halfVector;")); // Derived: Hi
+ s.append(TString(" vec3 spotDirection;")); // Sdli
+ s.append(TString(" float spotExponent;")); // Srli
+ s.append(TString(" float spotCutoff;")); // Crli
+ // (range: [0.0,90.0], 180.0)
+ s.append(TString(" float spotCosCutoff;")); // Derived: cos(Crli)
+ // (range: [1.0,0.0],-1.0)
+ s.append(TString(" float constantAttenuation;")); // K0
+ s.append(TString(" float linearAttenuation;")); // K1
+ s.append(TString(" float quadraticAttenuation;"));// K2
+ s.append(TString("};"));
+
+
+ s.append(TString("struct gl_LightModelParameters {"));
+ s.append(TString(" vec4 ambient;")); // Acs
+ s.append(TString("};"));
+
+ s.append(TString("uniform gl_LightModelParameters gl_LightModel;"));
+
+ //
+ // Derived state from products of light and material.
+ //
+
+ s.append(TString("struct gl_LightModelProducts {"));
+ s.append(TString(" vec4 sceneColor;")); // Derived. Ecm + Acm * Acs
+ s.append(TString("};"));
+
+ s.append(TString("uniform gl_LightModelProducts gl_FrontLightModelProduct;"));
+ s.append(TString("uniform gl_LightModelProducts gl_BackLightModelProduct;"));
+
+ s.append(TString("struct gl_LightProducts {"));
+ s.append(TString(" vec4 ambient;")); // Acm * Acli
+ s.append(TString(" vec4 diffuse;")); // Dcm * Dcli
+ s.append(TString(" vec4 specular;")); // Scm * Scli
+ s.append(TString("};"));
+
+
+
+
+ //
+ // Fog p. 161
+ //
+ s.append(TString("struct gl_FogParameters {"));
+ s.append(TString(" vec4 color;"));
+ s.append(TString(" float density;"));
+ s.append(TString(" float start;"));
+ s.append(TString(" float end;"));
+ s.append(TString(" float scale;")); // 1 / (gl_FogEnd - gl_FogStart)
+ s.append(TString("};"));
+
+ s.append(TString("uniform gl_FogParameters gl_Fog;"));
+
+ s.append(TString("\n"));
+ }
+ {
+ //============================================================================
+ //
+ // Vertex attributes, p. 19.
+ //
+ //============================================================================
+
+ TString& s = StandardVertexAttributes;
+
+ s.append(TString("attribute vec4 gl_Color;"));
+ s.append(TString("attribute vec4 gl_SecondaryColor;"));
+ s.append(TString("attribute vec3 gl_Normal;"));
+ s.append(TString("attribute vec4 gl_Vertex;"));
+ s.append(TString("attribute vec4 gl_MultiTexCoord0;"));
+ s.append(TString("attribute vec4 gl_MultiTexCoord1;"));
+ s.append(TString("attribute vec4 gl_MultiTexCoord2;"));
+ s.append(TString("attribute vec4 gl_MultiTexCoord3;"));
+ s.append(TString("attribute vec4 gl_MultiTexCoord4;"));
+ s.append(TString("attribute vec4 gl_MultiTexCoord5;"));
+ s.append(TString("attribute vec4 gl_MultiTexCoord6;"));
+ s.append(TString("attribute vec4 gl_MultiTexCoord7;"));
+ s.append(TString("attribute float gl_FogCoord;"));
+
+ s.append(TString("\n"));
+ }
+ {
+ //============================================================================
+ //
+ // Define the output varying interface from the vertex shader.
+ //
+ //============================================================================
+
+ TString& s = StandardVertexVaryings;
+
+ s.append(TString("varying vec4 gl_FrontColor;"));
+ s.append(TString("varying vec4 gl_BackColor;"));
+ s.append(TString("varying vec4 gl_FrontSecondaryColor;"));
+ s.append(TString("varying vec4 gl_BackSecondaryColor;"));
+ s.append(TString("varying vec4 gl_TexCoord[];"));
+ s.append(TString("varying float gl_FogFragCoord;"));
+
+ s.append(TString("\n"));
+ }
+ {
+ //============================================================================
+ //
+ // Define the input varying interface to the fragment shader.
+ //
+ //============================================================================
+
+ TString& s = StandardFragmentVaryings;
+
+ s.append(TString("varying vec4 gl_Color;"));
+ s.append(TString("varying vec4 gl_SecondaryColor;"));
+ s.append(TString("varying vec4 gl_TexCoord[];"));
+ s.append(TString("varying float gl_FogFragCoord;"));
+
+ s.append(TString("\n"));
+ }
+
+ builtInStrings[EShLangFragment].push_back(BuiltInFunctions.c_str());
+ builtInStrings[EShLangFragment].push_back(BuiltInFunctionsFragment);
+ builtInStrings[EShLangFragment].push_back(StandardUniforms);
+ builtInStrings[EShLangFragment].push_back(StandardFragmentVaryings);
+
+ builtInStrings[EShLangVertex].push_back(BuiltInFunctions);
+ builtInStrings[EShLangVertex].push_back(BuiltInFunctionsVertex);
+ builtInStrings[EShLangVertex].push_back(StandardVertexVaryings);
+ builtInStrings[EShLangVertex].push_back(StandardVertexAttributes);
+ builtInStrings[EShLangVertex].push_back(StandardUniforms);
+}
+
+
+void TBuiltIns::initialize(const TBuiltInResource &resources)
+{
+ //
+ // Initialize all the built-in strings for parsing.
+ //
+ TString StandardUniforms;
+
+ {
+ //============================================================================
+ //
+ // Standard Uniforms
+ //
+ //============================================================================
+
+ TString& s = StandardUniforms;
+
+ //
+ // Implementation dependent constants. The example values below
+ // are the minimum values allowed for these maximums.
+ //
+ char builtInConstant[80];
+ sprintf(builtInConstant, "const int gl_MaxLights = %d;", resources.maxLights); // GL 1.0
+ s.append(TString(builtInConstant));
+
+ sprintf(builtInConstant, "const int gl_MaxClipPlanes = %d;", resources.maxClipPlanes); // GL 1.0
+ s.append(TString(builtInConstant));
+
+ sprintf(builtInConstant, "const int gl_MaxTextureUnits = %d;", resources.maxTextureUnits); // GL 1.2
+ s.append(TString(builtInConstant));
+
+ sprintf(builtInConstant, "const int gl_MaxTextureCoords = %d;", resources.maxTextureCoords); // ARB_fragment_program
+ s.append(TString(builtInConstant));
+
+ sprintf(builtInConstant, "const int gl_MaxVertexAttribs = %d;", resources.maxVertexAttribs); // ARB_vertex_shader
+ s.append(TString(builtInConstant));
+
+ sprintf(builtInConstant, "const int gl_MaxVertexUniformComponents = %d;", resources.maxVertexUniformComponents); // ARB_vertex_shader
+ s.append(TString(builtInConstant));
+
+ sprintf(builtInConstant, "const int gl_MaxVaryingFloats = %d;", resources.maxVaryingFloats); // ARB_vertex_shader
+ s.append(TString(builtInConstant));
+
+ sprintf(builtInConstant, "const int gl_MaxVertexTextureImageUnits = %d;", resources.maxVertexTextureImageUnits); // ARB_vertex_shader
+ s.append(TString(builtInConstant));
+
+ sprintf(builtInConstant, "const int gl_MaxCombinedTextureImageUnits = %d;", resources.maxCombinedTextureImageUnits); // ARB_vertex_shader
+ s.append(TString(builtInConstant));
+
+ sprintf(builtInConstant, "const int gl_MaxTextureImageUnits = %d;", resources.maxTextureImageUnits); // ARB_fragment_shader
+ s.append(TString(builtInConstant));
+
+ sprintf(builtInConstant, "const int gl_MaxFragmentUniformComponents = %d;", resources.maxFragmentUniformComponents); // ARB_fragment_shader
+ s.append(TString(builtInConstant));
+
+ sprintf(builtInConstant, "const int gl_MaxDrawBuffers = %d;", resources.maxDrawBuffers); // proposed ARB_draw_buffers
+ s.append(TString(builtInConstant));
+
+ //
+ // OpenGL'uniform' state. Page numbers are in reference to version
+ // 1.4 of the OpenGL specification.
+ //
+
+ //
+ // Matrix state. p. 31, 32, 37, 39, 40.
+ //
+ s.append(TString("uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];"));
+
+ //
+ // Derived matrix state that provides inverse and transposed versions
+ // of the matrices above.
+ //
+ s.append(TString("uniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords];"));
+
+ s.append(TString("uniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords];"));
+
+ s.append(TString("uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];"));
+
+ //
+ // Clip planes p. 42.
+ //
+ s.append(TString("uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];"));
+
+ //
+ // Light State p 50, 53, 55.
+ //
+ s.append(TString("uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];"));
+
+ //
+ // Derived state from products of light.
+ //
+ s.append(TString("uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];"));
+ s.append(TString("uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];"));
+
+ //
+ // Textureg Environment and Generation, p. 152, p. 40-42.
+ //
+ s.append(TString("uniform vec4 gl_TextureEnvColor[gl_MaxTextureImageUnits];"));
+ s.append(TString("uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];"));
+ s.append(TString("uniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];"));
+ s.append(TString("uniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];"));
+ s.append(TString("uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];"));
+ s.append(TString("uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];"));
+ s.append(TString("uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];"));
+ s.append(TString("uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];"));
+ s.append(TString("uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];"));
+
+ s.append(TString("\n"));
+ }
+
+ builtInStrings[EShLangFragment].push_back(StandardUniforms);
+ builtInStrings[EShLangVertex].push_back(StandardUniforms);
+}
+
+void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable)
+{
+ //
+ // First, insert some special built-in variables that are not in
+ // the built-in header files.
+ //
+ switch(language) {
+
+ case EShLangFragment: {
+ symbolTable.insert(*new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtBool, EvqFace, 1)));
+ symbolTable.insert(*new TVariable(NewPoolTString("gl_FragCoord"), TType(EbtFloat, EvqFragCoord, 4)));
+ symbolTable.insert(*new TVariable(NewPoolTString("gl_FragColor"), TType(EbtFloat, EvqFragColor, 4)));
+ symbolTable.insert(*new TVariable(NewPoolTString("gl_FragDepth"), TType(EbtFloat, EvqFragDepth, 1)));
+
+ }
+ break;
+
+ case EShLangVertex:
+ symbolTable.insert(*new TVariable(NewPoolTString("gl_Position"), TType(EbtFloat, EvqPosition, 4)));
+ symbolTable.insert(*new TVariable(NewPoolTString("gl_PointSize"), TType(EbtFloat, EvqPointSize, 1)));
+ symbolTable.insert(*new TVariable(NewPoolTString("gl_ClipVertex"), TType(EbtFloat, EvqClipVertex, 4)));
+ break;
+ default: break;
+ }
+
+ //
+ // Next, identify which built-ins from the already loaded headers have
+ // a mapping to an operator. Those that are not identified as such are
+ // expected to be resolved through a library of functions, versus as
+ // operations.
+ //
+ symbolTable.relateToOperator("not", EOpVectorLogicalNot);
+
+ symbolTable.relateToOperator("matrixCompMult", EOpMul);
+ symbolTable.relateToOperator("mod", EOpMod);
+
+ symbolTable.relateToOperator("equal", EOpVectorEqual);
+ symbolTable.relateToOperator("notEqual", EOpVectorNotEqual);
+ symbolTable.relateToOperator("lessThan", EOpLessThan);
+ symbolTable.relateToOperator("greaterThan", EOpGreaterThan);
+ symbolTable.relateToOperator("lessThanEqual", EOpLessThanEqual);
+ symbolTable.relateToOperator("greaterThanEqual", EOpGreaterThanEqual);
+
+ symbolTable.relateToOperator("radians", EOpRadians);
+ symbolTable.relateToOperator("degrees", EOpDegrees);
+ symbolTable.relateToOperator("sin", EOpSin);
+ symbolTable.relateToOperator("cos", EOpCos);
+ symbolTable.relateToOperator("tan", EOpTan);
+ symbolTable.relateToOperator("asin", EOpAsin);
+ symbolTable.relateToOperator("acos", EOpAcos);
+ symbolTable.relateToOperator("atan", EOpAtan);
+
+ symbolTable.relateToOperator("pow", EOpPow);
+ symbolTable.relateToOperator("exp2", EOpExp2);
+ symbolTable.relateToOperator("log", EOpLog);
+ symbolTable.relateToOperator("exp", EOpExp);
+ symbolTable.relateToOperator("log2", EOpLog2);
+ symbolTable.relateToOperator("sqrt", EOpSqrt);
+ symbolTable.relateToOperator("inversesqrt", EOpInverseSqrt);
+
+ symbolTable.relateToOperator("abs", EOpAbs);
+ symbolTable.relateToOperator("sign", EOpSign);
+ symbolTable.relateToOperator("floor", EOpFloor);
+ symbolTable.relateToOperator("ceil", EOpCeil);
+ symbolTable.relateToOperator("fract", EOpFract);
+ symbolTable.relateToOperator("min", EOpMin);
+ symbolTable.relateToOperator("max", EOpMax);
+ symbolTable.relateToOperator("clamp", EOpClamp);
+ symbolTable.relateToOperator("mix", EOpMix);
+ symbolTable.relateToOperator("step", EOpStep);
+ symbolTable.relateToOperator("smoothstep", EOpSmoothStep);
+
+ symbolTable.relateToOperator("length", EOpLength);
+ symbolTable.relateToOperator("distance", EOpDistance);
+ symbolTable.relateToOperator("dot", EOpDot);
+ symbolTable.relateToOperator("cross", EOpCross);
+ symbolTable.relateToOperator("normalize", EOpNormalize);
+ symbolTable.relateToOperator("forward", EOpFaceForward);
+ symbolTable.relateToOperator("reflect", EOpReflect);
+ symbolTable.relateToOperator("refract", EOpRefract);
+
+ symbolTable.relateToOperator("any", EOpAny);
+ symbolTable.relateToOperator("all", EOpAll);
+
+ switch(language) {
+
+ case EShLangVertex:
+ break;
+
+ case EShLangFragment:
+ symbolTable.relateToOperator("dFdx", EOpDPdx);
+ symbolTable.relateToOperator("dFdy", EOpDPdy);
+ symbolTable.relateToOperator("fwidth", EOpFwidth);
+
+ break;
+
+ case EShLangPack:
+ case EShLangUnpack:
+ symbolTable.relateToOperator("itof", EOpItof);
+ symbolTable.relateToOperator("ftoi", EOpFtoi);
+ symbolTable.relateToOperator("skipPixels", EOpSkipPixels);
+ symbolTable.relateToOperator("readInput", EOpReadInput);
+ symbolTable.relateToOperator("writePixel", EOpWritePixel);
+ symbolTable.relateToOperator("bitmapLSB", EOpBitmapLsb);
+ symbolTable.relateToOperator("bitmapMSB", EOpBitmapMsb);
+ symbolTable.relateToOperator("writeOutput", EOpWriteOutput);
+ symbolTable.relateToOperator("readPixel", EOpReadPixel);
+ break;
+ default: assert (false && "Language not supported");
+ }
+}
+
+void IdentifyBuiltIns(EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources)
+{
+ //
+ // First, insert some special built-in variables that are not in
+ // the built-in header files.
+ //
+ switch(language) {
+
+ case EShLangFragment: {
+ // Set up gl_FragData. The array size.
+ TType fragData(EbtFloat, EvqFragColor, 4, false, true);
+ fragData.setArraySize(resources.maxDrawBuffers);
+ symbolTable.insert(*new TVariable(NewPoolTString("gl_FragData"), fragData));
+ }
+ break;
+
+ default: break;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Initialize.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Initialize.h
new file mode 100755
index 000000000..b273f06ca
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Initialize.h
@@ -0,0 +1,58 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#ifndef _INITIALIZE_INCLUDED_
+#define _INITIALIZE_INCLUDED_
+
+#include "Include/ResourceLimits.h"
+#include "../Include/Common.h"
+#include "../Include/ShHandle.h"
+#include "SymbolTable.h"
+
+typedef TVector<TString> TBuiltInStrings;
+
+class TBuiltIns {
+public:
+ POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
+ void initialize();
+ void initialize(const TBuiltInResource& resources);
+ TBuiltInStrings* getBuiltInStrings() { return builtInStrings; }
+protected:
+ TBuiltInStrings builtInStrings[EShLangCount];
+};
+
+void IdentifyBuiltIns(EShLanguage, TSymbolTable&);
+void IdentifyBuiltIns(EShLanguage, TSymbolTable&, const TBuiltInResource &resources);
+
+#endif // _INITIALIZE_INCLUDED_
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/IntermTraverse.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/IntermTraverse.cpp
new file mode 100755
index 000000000..da77806dd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/IntermTraverse.cpp
@@ -0,0 +1,243 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#include "../Include/intermediate.h"
+
+//
+// Traverse the intermediate representation tree, and
+// call a node type specific function for each node.
+// Done recursively through the member function Traverse().
+// Node types can be skipped if their function to call is 0,
+// but their subtree will still be traversed.
+// Nodes with children can have their whole subtree skipped
+// if preVisit is turned on and the type specific function
+// returns false.
+//
+// preVisit, postVisit, and rightToLeft control what order
+// nodes are visited in.
+//
+
+//
+// Traversal functions for terminals are straighforward....
+//
+void TIntermSymbol::traverse(TIntermTraverser* it)
+{
+ if (it->visitSymbol)
+ it->visitSymbol(this, it);
+}
+
+void TIntermConstantUnion::traverse(TIntermTraverser* it)
+{
+ if (it->visitConstantUnion)
+ it->visitConstantUnion(this, it);
+}
+
+//
+// Traverse a binary node.
+//
+void TIntermBinary::traverse(TIntermTraverser* it)
+{
+ bool visit = true;
+
+ //
+ // visit the node before children if pre-visiting.
+ //
+ if (it->preVisit && it->visitBinary)
+ visit = it->visitBinary(true, this, it);
+
+ //
+ // Visit the children, in the right order.
+ //
+ if (visit) {
+ ++it->depth;
+ if (it->rightToLeft) {
+ if (right)
+ right->traverse(it);
+ if (left)
+ left->traverse(it);
+ } else {
+ if (left)
+ left->traverse(it);
+ if (right)
+ right->traverse(it);
+ }
+ --it->depth;
+ }
+
+ //
+ // Visit the node after the children, if requested and the traversal
+ // hasn't been cancelled yet.
+ //
+ if (visit && it->postVisit && it->visitBinary)
+ it->visitBinary(false, this, it);
+}
+
+//
+// Traverse a unary node. Same comments in binary node apply here.
+//
+void TIntermUnary::traverse(TIntermTraverser* it)
+{
+ bool visit = true;
+
+ if (it->preVisit && it->visitUnary)
+ visit = it->visitUnary(true, this, it);
+
+ if (visit) {
+ ++it->depth;
+ operand->traverse(it);
+ --it->depth;
+ }
+
+ if (visit && it->postVisit && it->visitUnary)
+ it->visitUnary(false, this, it);
+}
+
+//
+// Traverse an aggregate node. Same comments in binary node apply here.
+//
+void TIntermAggregate::traverse(TIntermTraverser* it)
+{
+ bool visit = true;
+
+ if (it->preVisit && it->visitAggregate)
+ visit = it->visitAggregate(true, this, it);
+
+ if (visit) {
+ ++it->depth;
+
+ TIntermSequence::iterator sit;
+ if (it->rightToLeft) {
+ sit = sequence.end();
+ while (sit != sequence.begin()) {
+ --sit;
+ (*sit)->traverse(it);
+ }
+ } else {
+ for (sit = sequence.begin(); sit != sequence.end(); ++sit)
+ (*sit)->traverse(it);
+ }
+
+ --it->depth;
+ }
+
+ if (visit && it->postVisit && it->visitAggregate)
+ it->visitAggregate(false, this, it);
+}
+
+//
+// Traverse a selection node. Same comments in binary node apply here.
+//
+void TIntermSelection::traverse(TIntermTraverser* it)
+{
+ bool visit = true;
+
+ if (it->preVisit && it->visitSelection)
+ visit = it->visitSelection(true, this, it);
+
+ if (visit) {
+ ++it->depth;
+ if (it->rightToLeft) {
+ if (falseBlock)
+ falseBlock->traverse(it);
+ if (trueBlock)
+ trueBlock->traverse(it);
+ condition->traverse(it);
+ } else {
+ condition->traverse(it);
+ if (trueBlock)
+ trueBlock->traverse(it);
+ if (falseBlock)
+ falseBlock->traverse(it);
+ }
+ --it->depth;
+ }
+
+ if (visit && it->postVisit && it->visitSelection)
+ it->visitSelection(false, this, it);
+}
+
+//
+// Traverse a loop node. Same comments in binary node apply here.
+//
+void TIntermLoop::traverse(TIntermTraverser* it)
+{
+ bool visit = true;
+
+ if (it->preVisit && it->visitLoop)
+ visit = it->visitLoop(true, this, it);
+
+ if (visit) {
+ ++it->depth;
+ if (it->rightToLeft) {
+ if (terminal)
+ terminal->traverse(it);
+ if (body)
+ body->traverse(it);
+ if (test)
+ test->traverse(it);
+ } else {
+ if (test)
+ test->traverse(it);
+ if (body)
+ body->traverse(it);
+ if (terminal)
+ terminal->traverse(it);
+ }
+ --it->depth;
+ }
+
+ if (visit && it->postVisit && it->visitLoop)
+ it->visitLoop(false, this, it);
+}
+
+//
+// Traverse a branch node. Same comments in binary node apply here.
+//
+void TIntermBranch::traverse(TIntermTraverser* it)
+{
+ bool visit = true;
+
+ if (it->preVisit && it->visitBranch)
+ visit = it->visitBranch(true, this, it);
+
+ if (visit && expression) {
+ ++it->depth;
+ expression->traverse(it);
+ --it->depth;
+ }
+
+ if (visit && it->postVisit && it->visitBranch)
+ it->visitBranch(false, this, it);
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Intermediate.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Intermediate.cpp
new file mode 100755
index 000000000..056fe17de
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/Intermediate.cpp
@@ -0,0 +1,2110 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+//
+// Build the intermediate representation.
+//
+
+#include "../Include/ShHandle.h"
+#include "localintermediate.h"
+#include "QualifierAlive.h"
+#include "RemoveTree.h"
+#include <float.h>
+
+////////////////////////////////////////////////////////////////////////////
+//
+// First set of functions are to help build the intermediate representation.
+// These functions are not member functions of the nodes.
+// They are called from parser productions.
+//
+/////////////////////////////////////////////////////////////////////////////
+
+//
+// Add a terminal node for an identifier in an expression.
+//
+// Returns the added node.
+//
+TIntermSymbol* TIntermediate::addSymbol(int id, const TString& name, const TType& type, TSourceLoc line)
+{
+ TIntermSymbol* node = new TIntermSymbol(id, name, type);
+ node->setLine(line);
+
+ return node;
+}
+
+//
+// Connect two nodes with a new parent that does a binary operation on the nodes.
+//
+// Returns the added node.
+//
+TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc line, TSymbolTable& symbolTable)
+{
+ switch (op) {
+ case EOpLessThan:
+ case EOpGreaterThan:
+ case EOpLessThanEqual:
+ case EOpGreaterThanEqual:
+ if (left->getType().isMatrix() || left->getType().isArray() || left->getType().isVector() || left->getType().getBasicType() == EbtStruct) {
+ return 0;
+ }
+ break;
+ case EOpLogicalOr:
+ case EOpLogicalXor:
+ case EOpLogicalAnd:
+ if (left->getType().getBasicType() != EbtBool || left->getType().isMatrix() || left->getType().isArray() || left->getType().isVector()) {
+ return 0;
+ }
+ break;
+ case EOpAdd:
+ case EOpSub:
+ case EOpDiv:
+ case EOpMul:
+ if (left->getType().getBasicType() == EbtStruct || left->getType().getBasicType() == EbtBool)
+ return 0;
+ default: break;
+ }
+
+ //
+ // First try converting the children to compatible types.
+ //
+
+ if (!(left->getType().getStruct() && right->getType().getStruct())) {
+ TIntermTyped* child = addConversion(op, left->getType(), right);
+ if (child)
+ right = child;
+ else {
+ child = addConversion(op, right->getType(), left);
+ if (child)
+ left = child;
+ else
+ return 0;
+ }
+ } else {
+ if (left->getType() != right->getType())
+ return 0;
+ }
+
+
+ //
+ // Need a new node holding things together then. Make
+ // one and promote it to the right type.
+ //
+ TIntermBinary* node = new TIntermBinary(op);
+ if (line == 0)
+ line = right->getLine();
+ node->setLine(line);
+
+ node->setLeft(left);
+ node->setRight(right);
+ if (! node->promote(infoSink))
+ return 0;
+
+ TIntermConstantUnion *leftTempConstant = left->getAsConstantUnion();
+ TIntermConstantUnion *rightTempConstant = right->getAsConstantUnion();
+
+ if (leftTempConstant)
+ leftTempConstant = copyConstUnion(left->getAsConstantUnion())->getAsConstantUnion();
+
+ if (rightTempConstant)
+ rightTempConstant = copyConstUnion(right->getAsConstantUnion())->getAsConstantUnion();
+
+ if (right->getType().getQualifier() == EvqConst && left->getType().getQualifier() == EvqConst) {
+ if (right->getAsAggregate()) {
+ rightTempConstant = changeAggrToTempConst(right->getAsAggregate(), symbolTable, line);
+ if (rightTempConstant->getUnionArrayPointer() == 0)
+ return 0;
+ }
+
+ if (left->getAsAggregate()) {
+ leftTempConstant = changeAggrToTempConst(left->getAsAggregate(), symbolTable, line);
+ if (leftTempConstant->getUnionArrayPointer() == 0)
+ return 0;
+ }
+ }
+
+ //
+ // See if we can fold constants.
+ //
+
+ TIntermTyped* typedReturnNode = 0;
+ if ( leftTempConstant && rightTempConstant) {
+ if (leftTempConstant->getSize() == 1 && rightTempConstant->getSize() > 1)
+ typedReturnNode = rightTempConstant->fold(node->getOp(), leftTempConstant, infoSink, false);
+ else
+ typedReturnNode = leftTempConstant->fold(node->getOp(), rightTempConstant, infoSink, true);
+
+ if (typedReturnNode)
+ return typedReturnNode;
+ else {
+ node->setLeft(leftTempConstant);
+ node->setRight(rightTempConstant);
+ }
+ } else if (leftTempConstant) {
+ node->setLeft(copyConstUnion(leftTempConstant));
+ } else if (rightTempConstant) {
+ node->setRight(rightTempConstant);
+ }
+
+ return node;
+}
+
+//
+// Connect two nodes through an assignment.
+//
+// Returns the added node.
+//
+TIntermTyped* TIntermediate::addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc line)
+{
+ //
+ // Like adding binary math, except the conversion can only go
+ // from right to left.
+ //
+ TIntermBinary* node = new TIntermBinary(op);
+ if (line == 0)
+ line = left->getLine();
+ node->setLine(line);
+
+ if (right->getAsConstantUnion()) { // if the right node of assignment is a TempConstant node, allocate its own new space and remove the pointer to the symbol table value
+ right = copyConstUnion(right->getAsConstantUnion()) ;
+ if (right == 0)
+ return 0;
+ }
+
+ TIntermTyped* child = addConversion(op, left->getType(), right);
+ if (child == 0)
+ return 0;
+
+ node->setLeft(left);
+ node->setRight(child);
+ if (! node->promote(infoSink))
+ return 0;
+
+ return node;
+}
+
+//
+// Connect two nodes through an index operator, where the left node is the base
+// of an array or struct, and the right node is a direct or indirect offset.
+//
+// Returns the added node.
+// The caller should set the type of the returned node.
+//
+TIntermTyped* TIntermediate::addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc line)
+{
+ TIntermBinary* node = new TIntermBinary(op);
+ if (line == 0)
+ line = index->getLine();
+ node->setLine(line);
+ node->setLeft(base);
+ node->setRight(index);
+
+ // caller should set the type
+
+ return node;
+}
+
+//
+// Add one node as the parent of another that it operates on.
+//
+// Returns the added node.
+//
+TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermNode* childNode, TSourceLoc line, TSymbolTable& symbolTable)
+{
+ TIntermUnary* node;
+ TIntermTyped* child = childNode->getAsTyped();
+
+ if (child == 0) {
+ infoSink.info.message(EPrefixInternalError, "Bad type in AddUnaryMath", line);
+ return 0;
+ }
+
+ switch (op) {
+ case EOpLogicalNot:
+ if (child->getType().getBasicType() != EbtBool || child->getType().isMatrix() || child->getType().isArray() || child->getType().isVector()) {
+ return 0;
+ }
+ break;
+
+ case EOpPostIncrement:
+ case EOpPreIncrement:
+ case EOpPostDecrement:
+ case EOpPreDecrement:
+ case EOpNegative:
+ if (child->getType().getBasicType() == EbtStruct)
+ return 0;
+ default: break;
+ }
+
+ //
+ // Do we need to promote the operand?
+ //
+ // Note: Implicit promotions were removed from the language.
+ //
+ TBasicType newType = EbtVoid;
+ switch (op) {
+ case EOpConstructInt: newType = EbtInt; break;
+ case EOpConstructBool: newType = EbtBool; break;
+ case EOpConstructFloat: newType = EbtFloat; break;
+ default: break;
+ }
+
+ if (newType != EbtVoid) {
+ child = addConversion(op, TType(newType, EvqTemporary, child->getNominalSize(),
+ child->isMatrix(),
+ child->isArray()),
+ child);
+ if (child == 0)
+ return 0;
+ }
+
+ //
+ // For constructors, we are now done, it's all in the conversion.
+ //
+ switch (op) {
+ case EOpConstructInt:
+ case EOpConstructBool:
+ case EOpConstructFloat:
+ return child;
+ default: break;
+ }
+
+ if (child->getAsConstantUnion())
+ child = copyConstUnion(child->getAsConstantUnion());
+
+ if (child->getAsAggregate() && child->getType().getQualifier() == EvqConst) {
+ child = changeAggrToTempConst(child->getAsAggregate(), symbolTable, line);
+ if (child->getAsConstantUnion()->getUnionArrayPointer() == 0)
+ return 0;
+ }
+
+ TIntermConstantUnion *childTempConstant = child->getAsConstantUnion();
+
+ //
+ // Make a new node for the operator.
+ //
+ node = new TIntermUnary(op);
+ if (line == 0)
+ line = child->getLine();
+ node->setLine(line);
+ node->setOperand(child);
+
+ if (! node->promote(infoSink))
+ return 0;
+
+ if (childTempConstant) {
+ TIntermTyped* newChild = childTempConstant->fold(op, 0, infoSink, true);
+
+ if (newChild) {
+ return newChild;
+ }
+ }
+
+ return node;
+}
+
+//
+// This is the safe way to change the operator on an aggregate, as it
+// does lots of error checking and fixing. Especially for establishing
+// a function call's operation on it's set of parameters. Sequences
+// of instructions are also aggregates, but they just direnctly set
+// their operator to EOpSequence.
+//
+// Returns an aggregate node, which could be the one passed in if
+// it was already an aggregate.
+//
+TIntermAggregate* TIntermediate::setAggregateOperator(TIntermNode* node, TOperator op, TSourceLoc line)
+{
+ TIntermAggregate* aggNode;
+
+ //
+ // Make sure we have an aggregate. If not turn it into one.
+ //
+ if (node) {
+ aggNode = node->getAsAggregate();
+ if (aggNode == 0 || aggNode->getOp() != EOpNull) {
+ //
+ // Make an aggregate containing this node.
+ //
+ aggNode = new TIntermAggregate();
+ aggNode->getSequence().push_back(node);
+ if (line == 0)
+ line = node->getLine();
+ }
+ } else
+ aggNode = new TIntermAggregate();
+
+ //
+ // Set the operator.
+ //
+ aggNode->setOperator(op);
+ if (line != 0)
+ aggNode->setLine(line);
+
+ return aggNode;
+}
+
+//
+// Convert one type to another.
+//
+// Returns the node representing the conversion, which could be the same
+// node passed in if no conversion was needed.
+//
+// Return 0 if a conversion can't be done.
+//
+TIntermTyped* TIntermediate::addConversion(TOperator op, const TType& type, TIntermTyped* node)
+{
+ //
+ // Does the base type allow operation?
+ //
+ switch (node->getBasicType()) {
+ case EbtVoid:
+ case EbtSampler1D:
+ case EbtSampler2D:
+ case EbtSampler3D:
+ case EbtSamplerCube:
+ case EbtSampler1DShadow:
+ case EbtSampler2DShadow:
+ return 0;
+ default: break;
+ }
+
+ //
+ // Otherwise, if types are identical, no problem
+ //
+ if (type == node->getType())
+ return node;
+
+ //
+ // If one's a structure, then no conversions.
+ //
+ if (type.getStruct() || node->getType().getStruct())
+ return 0;
+
+ TBasicType promoteTo;
+
+ switch (op) {
+ //
+ // Explicit conversions
+ //
+ case EOpConstructBool:
+ promoteTo = EbtBool;
+ break;
+ case EOpConstructFloat:
+ promoteTo = EbtFloat;
+ break;
+ case EOpConstructInt:
+ promoteTo = EbtInt;
+ break;
+ default:
+ //
+ // implicit conversions were removed from the language.
+ //
+ if (type.getBasicType() != node->getType().getBasicType())
+ return 0;
+ //
+ // Size and structure could still differ, but that's
+ // handled by operator promotion.
+ //
+ return node;
+ }
+
+ //
+ // Do conversion.
+ //
+ bool allConstant = true;
+ // check to see if there is an aggregate node
+ if (node->getAsAggregate()) {
+ if (node->getAsAggregate()->getOp() != EOpFunctionCall) {
+ // if the aggregate node is a constructor or a comma operator, look at its children, if they are constant
+ // convert them into the right type
+ TIntermSequence &sequenceVector = node->getAsAggregate()->getSequence() ;
+ for (TIntermSequence::iterator p = sequenceVector.begin();
+ p != sequenceVector.end(); p++) {
+ if (!(*p)->getAsTyped()->getAsConstantUnion())
+ allConstant = false;
+ }
+ } else
+ allConstant = false;
+ }
+ if (allConstant && node->getAsAggregate()) { // we can do the constant folding here as all the nodes of the aggregate are const
+ TIntermSequence &sequenceVector = node->getAsAggregate()->getSequence() ;
+ for (TIntermSequence::iterator p = sequenceVector.begin();
+ p != sequenceVector.end(); p++) {
+ TIntermTyped* newNode = 0;
+ constUnion *unionArray = new constUnion[1];
+
+ switch (promoteTo) {
+ case EbtFloat:
+ switch ((*p)->getAsTyped()->getType().getBasicType()) {
+
+ case EbtInt:
+ unionArray->fConst = static_cast<float>((*p)->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->iConst);
+ newNode = addConstantUnion(unionArray, TType(EbtFloat, EvqConst), node->getLine()); break;
+ case EbtBool:
+ unionArray->fConst = static_cast<float>((*p)->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->bConst);
+ newNode = newNode = addConstantUnion(unionArray, TType(EbtFloat, EvqConst), node->getLine()); break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());
+ return 0;
+ }
+ break;
+ case EbtInt:
+ switch ((*p)->getAsTyped()->getType().getBasicType()) {
+ case EbtFloat:
+ unionArray->iConst = static_cast<int>((*p)->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->fConst);
+ newNode = addConstantUnion(unionArray, TType(EbtInt, EvqConst), node->getLine());
+ break;
+ case EbtBool:
+ unionArray->iConst = static_cast<int>((*p)->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->bConst);
+ newNode = addConstantUnion(unionArray, TType(EbtInt, EvqConst), node->getLine());
+ break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());
+ return 0;
+ }
+ break;
+ case EbtBool:
+ switch ((*p)->getAsTyped()->getType().getBasicType()) {
+ case EbtFloat:
+ unionArray->bConst = (*p)->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->fConst != 0.0 ;
+ newNode = addConstantUnion(unionArray, TType(EbtBool, EvqConst), node->getLine());
+ break;
+ case EbtInt:
+ unionArray->bConst = (*p)->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->iConst != 0 ;
+ newNode = addConstantUnion(unionArray, TType(EbtBool, EvqConst), node->getLine());
+ break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());
+ return 0;
+ }
+ break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());
+ return 0;
+ }
+ if (newNode) {
+ sequenceVector.erase(p);
+ sequenceVector.insert(p, newNode);
+ }
+ }
+ return node->getAsAggregate();
+ } else if (node->getAsConstantUnion()) {
+
+ return (promoteConstantUnion(promoteTo, node->getAsConstantUnion()));
+ } else {
+
+ //
+ // Add a new newNode for the conversion.
+ //
+ TIntermUnary* newNode = 0;
+
+ TOperator newOp = EOpNull;
+ switch (promoteTo) {
+ case EbtFloat:
+ switch (node->getBasicType()) {
+ case EbtInt: newOp = EOpConvIntToFloat; break;
+ case EbtBool: newOp = EOpConvBoolToFloat; break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());
+ return 0;
+ }
+ break;
+ case EbtBool:
+ switch (node->getBasicType()) {
+ case EbtInt: newOp = EOpConvIntToBool; break;
+ case EbtFloat: newOp = EOpConvFloatToBool; break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());
+ return 0;
+ }
+ break;
+ case EbtInt:
+ switch (node->getBasicType()) {
+ case EbtBool: newOp = EOpConvBoolToInt; break;
+ case EbtFloat: newOp = EOpConvFloatToInt; break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Bad promotion node", node->getLine());
+ return 0;
+ }
+ break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Bad promotion type", node->getLine());
+ return 0;
+ }
+
+ TType type(promoteTo, EvqTemporary, node->getNominalSize(), node->isMatrix(), node->isArray());
+ newNode = new TIntermUnary(newOp, type);
+ newNode->setLine(node->getLine());
+ newNode->setOperand(node);
+
+ return newNode;
+ }
+}
+
+//
+// Safe way to combine two nodes into an aggregate. Works with null pointers,
+// a node that's not a aggregate yet, etc.
+//
+// Returns the resulting aggregate, unless 0 was passed in for
+// both existing nodes.
+//
+TIntermAggregate* TIntermediate::growAggregate(TIntermNode* left, TIntermNode* right, TSourceLoc line)
+{
+ if (left == 0 && right == 0)
+ return 0;
+
+ TIntermAggregate* aggNode = 0;
+ if (left)
+ aggNode = left->getAsAggregate();
+ if (!aggNode || aggNode->getOp() != EOpNull) {
+ aggNode = new TIntermAggregate;
+ if (left)
+ aggNode->getSequence().push_back(left);
+ }
+
+ if (right)
+ aggNode->getSequence().push_back(right);
+
+ if (line != 0)
+ aggNode->setLine(line);
+
+ return aggNode;
+}
+
+//
+// Turn an existing node into an aggregate.
+//
+// Returns an aggregate, unless 0 was passed in for the existing node.
+//
+TIntermAggregate* TIntermediate::makeAggregate(TIntermNode* node, TSourceLoc line)
+{
+ if (node == 0)
+ return 0;
+
+ TIntermAggregate* aggNode = new TIntermAggregate;
+ aggNode->getSequence().push_back(node);
+
+ if (line != 0)
+ aggNode->setLine(line);
+ else
+ aggNode->setLine(node->getLine());
+
+ return aggNode;
+}
+
+//
+// For "if" test nodes. There are three children; a condition,
+// a true path, and a false path. The two paths are in the
+// nodePair.
+//
+// Returns the selection node created.
+//
+TIntermNode* TIntermediate::addSelection(TIntermTyped* cond, TIntermNodePair nodePair, TSourceLoc line)
+{
+ //
+ // For compile time constant selections, prune the code and
+ // test now.
+ //
+
+ if (cond->getAsTyped() && cond->getAsTyped()->getAsConstantUnion()) {
+ if (cond->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->bConst)
+ return nodePair.node1;
+ else
+ return nodePair.node2;
+ }
+
+ TIntermSelection* node = new TIntermSelection(cond, nodePair.node1, nodePair.node2);
+ node->setLine(line);
+
+ return node;
+}
+
+
+TIntermTyped* TIntermediate::addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc line)
+{
+ if (left->getType().getQualifier() == EvqConst && right->getType().getQualifier() == EvqConst) {
+ return right;
+ } else {
+ TIntermTyped *commaAggregate = growAggregate(left, right, line);
+ commaAggregate->getAsAggregate()->setOperator(EOpComma);
+ commaAggregate->setType(right->getType());
+ commaAggregate->getTypePointer()->changeQualifier(EvqTemporary);
+ return commaAggregate;
+ }
+}
+
+//
+// For "?:" test nodes. There are three children; a condition,
+// a true path, and a false path. The two paths are specified
+// as separate parameters.
+//
+// Returns the selection node created, or 0 if one could not be.
+//
+TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc line)
+{
+ //
+ // Get compatible types.
+ //
+ TIntermTyped* child = addConversion(EOpSequence, trueBlock->getType(), falseBlock);
+ if (child)
+ falseBlock = child;
+ else {
+ child = addConversion(EOpSequence, falseBlock->getType(), trueBlock);
+ if (child)
+ trueBlock = child;
+ else
+ return 0;
+ }
+
+ //
+ // See if condition is constant, and select now.
+ //
+
+ if (cond->getAsConstantUnion()) {
+ if (cond->getAsConstantUnion()->getUnionArrayPointer()->bConst)
+ return trueBlock;
+ else
+ return falseBlock;
+ }
+
+ //
+ // Make a selection node.
+ //
+ TIntermSelection* node = new TIntermSelection(cond, trueBlock, falseBlock, trueBlock->getType());
+ node->setLine(line);
+
+ return node;
+}
+
+//
+// Constant terminal nodes. Has a union that contains bool, float or int constants
+//
+// Returns the constant union node created.
+//
+
+TIntermConstantUnion* TIntermediate::addConstantUnion(constUnion* unionArrayPointer, const TType& t, TSourceLoc line)
+{
+ TIntermConstantUnion* node = new TIntermConstantUnion(unionArrayPointer, t);
+ node->setLine(line);
+
+ return node;
+}
+
+TIntermTyped* TIntermediate::addSwizzle(TVectorFields& fields, TSourceLoc line)
+{
+
+ TIntermAggregate* node = new TIntermAggregate(EOpSequence);
+
+ node->setLine(line);
+ TIntermConstantUnion* constIntNode;
+ TIntermSequence &sequenceVector = node->getSequence();
+ constUnion* unionArray;
+
+ for (int i = 0; i < fields.num; i++) {
+ unionArray = new constUnion[1];
+ unionArray->iConst = fields.offsets[i];
+ constIntNode = addConstantUnion(unionArray, TType(EbtInt, EvqConst), line);
+ sequenceVector.push_back(constIntNode);
+ }
+
+ return node;
+}
+
+//
+// Create loop nodes.
+//
+TIntermNode* TIntermediate::addLoop(TIntermNode* body, TIntermTyped* test, TIntermTyped* terminal, bool testFirst, TSourceLoc line)
+{
+ TIntermNode* node = new TIntermLoop(body, test, terminal, testFirst);
+ node->setLine(line);
+
+ return node;
+}
+
+//
+// Add branches.
+//
+TIntermBranch* TIntermediate::addBranch(TOperator branchOp, TSourceLoc line)
+{
+ return addBranch(branchOp, 0, line);
+}
+
+TIntermBranch* TIntermediate::addBranch(TOperator branchOp, TIntermTyped* expression, TSourceLoc line)
+{
+ TIntermBranch* node = new TIntermBranch(branchOp, expression);
+ node->setLine(line);
+
+ return node;
+}
+
+//
+// This is to be executed once the final root is put on top by the parsing
+// process.
+//
+bool TIntermediate::postProcess(TIntermNode* root, EShLanguage language)
+{
+ if (root == 0)
+ return true;
+
+ //
+ // First, finish off the top level sequence, if any
+ //
+ TIntermAggregate* aggRoot = root->getAsAggregate();
+ if (aggRoot && aggRoot->getOp() == EOpNull)
+ aggRoot->setOperator(EOpSequence);
+
+ return true;
+}
+
+//
+// This deletes the tree.
+//
+void TIntermediate::remove(TIntermNode* root)
+{
+ if (root)
+ RemoveAllTreeNodes(root);
+}
+
+////////////////////////////////////////////////////////////////
+//
+// Member functions of the nodes used for building the tree.
+//
+////////////////////////////////////////////////////////////////
+
+//
+// Say whether or not an operation node changes the value of a variable.
+//
+// Returns true if state is modified.
+//
+bool TIntermOperator::modifiesState() const
+{
+ switch (op) {
+ case EOpPostIncrement:
+ case EOpPostDecrement:
+ case EOpPreIncrement:
+ case EOpPreDecrement:
+ case EOpAssign:
+ case EOpAddAssign:
+ case EOpSubAssign:
+ case EOpMulAssign:
+ case EOpVectorTimesMatrixAssign:
+ case EOpVectorTimesScalarAssign:
+ case EOpMatrixTimesScalarAssign:
+ case EOpMatrixTimesMatrixAssign:
+ case EOpDivAssign:
+ case EOpModAssign:
+ case EOpAndAssign:
+ case EOpInclusiveOrAssign:
+ case EOpExclusiveOrAssign:
+ case EOpLeftShiftAssign:
+ case EOpRightShiftAssign:
+ return true;
+ default:
+ return false;
+ }
+}
+
+//
+// returns true if the operator is for one of the constructors
+//
+bool TIntermOperator::isConstructor() const
+{
+ switch (op) {
+ case EOpConstructVec2:
+ case EOpConstructVec3:
+ case EOpConstructVec4:
+ case EOpConstructMat2:
+ case EOpConstructMat3:
+ case EOpConstructMat4:
+ case EOpConstructFloat:
+ case EOpConstructIVec2:
+ case EOpConstructIVec3:
+ case EOpConstructIVec4:
+ case EOpConstructInt:
+ case EOpConstructBVec2:
+ case EOpConstructBVec3:
+ case EOpConstructBVec4:
+ case EOpConstructBool:
+ case EOpConstructStruct:
+ return true;
+ default:
+ return false;
+ }
+}
+//
+// Make sure the type of a unary operator is appropriate for its
+// combination of operation and operand type.
+//
+// Returns false in nothing makes sense.
+//
+bool TIntermUnary::promote(TInfoSink&)
+{
+ switch (op) {
+ case EOpLogicalNot:
+ if (operand->getBasicType() != EbtBool)
+ return false;
+ break;
+ case EOpBitwiseNot:
+ if (operand->getBasicType() != EbtInt)
+ return false;
+ break;
+ case EOpNegative:
+ case EOpPostIncrement:
+ case EOpPostDecrement:
+ case EOpPreIncrement:
+ case EOpPreDecrement:
+ if (operand->getBasicType() == EbtBool)
+ return false;
+ break;
+
+ // operators for built-ins are already type checked against their prototype
+ case EOpAny:
+ case EOpAll:
+ case EOpVectorLogicalNot:
+ return true;
+
+ default:
+ if (operand->getBasicType() != EbtFloat)
+ return false;
+ }
+
+ setType(operand->getType());
+
+ return true;
+}
+
+//
+// Establishes the type of the resultant operation, as well as
+// makes the operator the correct one for the operands.
+//
+// Returns false if operator can't work on operands.
+//
+bool TIntermBinary::promote(TInfoSink& infoSink)
+{
+ int size = left->getNominalSize();
+ if (right->getNominalSize() > size)
+ size = right->getNominalSize();
+
+ TBasicType type = left->getBasicType();
+
+ //
+ // Don't operate on arrays.
+ //
+ if (left->isArray() || right->isArray())
+ return false;
+
+ //
+ // Base assumption: just make the type the same as the left
+ // operand. Then only deviations from this need be coded.
+ //
+ setType(TType(type, EvqTemporary, left->getNominalSize(), left->isMatrix()));
+
+ //
+ // All scalars. Code after this test assumes this case is removed!
+ //
+ if (size == 1) {
+
+ switch (op) {
+
+ //
+ // Promote to conditional
+ //
+ case EOpEqual:
+ case EOpNotEqual:
+ case EOpLessThan:
+ case EOpGreaterThan:
+ case EOpLessThanEqual:
+ case EOpGreaterThanEqual:
+ setType(TType(EbtBool));
+ break;
+
+ //
+ // And and Or operate on conditionals
+ //
+ case EOpLogicalAnd:
+ case EOpLogicalOr:
+ if (left->getBasicType() != EbtBool || right->getBasicType() != EbtBool)
+ return false;
+ setType(TType(EbtBool));
+ break;
+
+ //
+ // Check for integer only operands.
+ //
+ case EOpMod:
+ case EOpRightShift:
+ case EOpLeftShift:
+ case EOpAnd:
+ case EOpInclusiveOr:
+ case EOpExclusiveOr:
+ if (left->getBasicType() != EbtInt || right->getBasicType() != EbtInt)
+ return false;
+ break;
+ case EOpModAssign:
+ case EOpAndAssign:
+ case EOpInclusiveOrAssign:
+ case EOpExclusiveOrAssign:
+ case EOpLeftShiftAssign:
+ case EOpRightShiftAssign:
+ if (left->getBasicType() != EbtInt || right->getBasicType() != EbtInt)
+ return false;
+ // fall through
+
+ //
+ // Everything else should have matching types
+ //
+ default:
+ if (left->getBasicType() != right->getBasicType() ||
+ left->isMatrix() != right->isMatrix())
+ return false;
+ }
+
+ return true;
+ }
+
+ //
+ // Are the sizes compatible?
+ //
+ if ( left->getNominalSize() != size && left->getNominalSize() != 1 ||
+ right->getNominalSize() != size && right->getNominalSize() != 1)
+ return false;
+
+ //
+ // Can these two operands be combined?
+ //
+ switch (op) {
+ case EOpMul:
+ if (!left->isMatrix() && right->isMatrix()) {
+ if (left->isVector())
+ op = EOpVectorTimesMatrix;
+ else {
+ op = EOpMatrixTimesScalar;
+ setType(TType(type, EvqTemporary, size, true));
+ }
+ } else if (left->isMatrix() && !right->isMatrix()) {
+ if (right->isVector()) {
+ op = EOpMatrixTimesVector;
+ setType(TType(type, EvqTemporary, size, false));
+ } else {
+ op = EOpMatrixTimesScalar;
+ }
+ } else if (left->isMatrix() && right->isMatrix()) {
+ op = EOpMatrixTimesMatrix;
+ } else if (!left->isMatrix() && !right->isMatrix()) {
+ if (left->isVector() && right->isVector()) {
+ // leave as component product
+ } else if (left->isVector() || right->isVector()) {
+ op = EOpVectorTimesScalar;
+ setType(TType(type, EvqTemporary, size, false));
+ }
+ } else {
+ infoSink.info.message(EPrefixInternalError, "Missing elses", getLine());
+ return false;
+ }
+ break;
+ case EOpMulAssign:
+ if (!left->isMatrix() && right->isMatrix()) {
+ if (left->isVector())
+ op = EOpVectorTimesMatrixAssign;
+ else {
+ return false;
+ }
+ } else if (left->isMatrix() && !right->isMatrix()) {
+ if (right->isVector()) {
+ return false;
+ } else {
+ op = EOpMatrixTimesScalarAssign;
+ }
+ } else if (left->isMatrix() && right->isMatrix()) {
+ op = EOpMatrixTimesMatrixAssign;
+ } else if (!left->isMatrix() && !right->isMatrix()) {
+ if (left->isVector() && right->isVector()) {
+ // leave as component product
+ } else if (left->isVector() || right->isVector()) {
+ if (! left->isVector())
+ return false;
+ op = EOpVectorTimesScalarAssign;
+ setType(TType(type, EvqTemporary, size, false));
+ }
+ } else {
+ infoSink.info.message(EPrefixInternalError, "Missing elses", getLine());
+ return false;
+ }
+ break;
+ case EOpAssign:
+ if (left->getNominalSize() != right->getNominalSize())
+ return false;
+ // fall through
+ case EOpAdd:
+ case EOpSub:
+ case EOpDiv:
+ case EOpMod:
+ case EOpAddAssign:
+ case EOpSubAssign:
+ case EOpDivAssign:
+ case EOpModAssign:
+ if (left->isMatrix() && right->isVector() ||
+ left->isVector() && right->isMatrix() ||
+ left->getBasicType() != right->getBasicType())
+ return false;
+ setType(TType(type, EvqTemporary, size, left->isMatrix() || right->isMatrix()));
+ break;
+
+ case EOpEqual:
+ case EOpNotEqual:
+ case EOpLessThan:
+ case EOpGreaterThan:
+ case EOpLessThanEqual:
+ case EOpGreaterThanEqual:
+ if (left->isMatrix() && right->isVector() ||
+ left->isVector() && right->isMatrix() ||
+ left->getBasicType() != right->getBasicType())
+ return false;
+ setType(TType(EbtBool));
+ break;
+
+default:
+ return false;
+ }
+
+ //
+ // One more check for assignment. The Resulting type has to match the left operand.
+ //
+ switch (op) {
+ case EOpAssign:
+ case EOpAddAssign:
+ case EOpSubAssign:
+ case EOpMulAssign:
+ case EOpDivAssign:
+ case EOpModAssign:
+ case EOpAndAssign:
+ case EOpInclusiveOrAssign:
+ case EOpExclusiveOrAssign:
+ case EOpLeftShiftAssign:
+ case EOpRightShiftAssign:
+ if (getType() != left->getType())
+ return false;
+ break;
+ default:
+ break;
+ }
+
+ return true;
+}
+
+bool compareStructure(const TType& leftNodeType, constUnion* rightUnionArray, constUnion* leftUnionArray, int& index)
+{
+ TTypeList* fields = leftNodeType.getStruct();
+
+ size_t structSize = fields->size();
+
+ for (size_t j = 0; j < structSize; j++) {
+ int size = (*fields)[j].type->getInstanceSize();
+ for (int i = 0; i < size; i++) {
+ switch ((*fields)[j].type->getBasicType()) {
+ case EbtFloat:
+ if (leftUnionArray[index].fConst != rightUnionArray[index].fConst)
+ return false;
+ index++;
+ break;
+ case EbtInt:
+ if (leftUnionArray[index].iConst != rightUnionArray[index].iConst)
+ return false;
+ index++;
+ break;
+ case EbtBool:
+ if (leftUnionArray[index].bConst != rightUnionArray[index].bConst)
+ return false;
+ index++;
+ break;
+ case EbtStruct:
+ if (!compareStructure(*(*fields)[j].type, rightUnionArray, leftUnionArray, index))
+ return false;
+ break;
+ default:
+ assert(true && "Cannot compare");
+ break;
+ }
+
+ }
+ }
+ return true;
+}
+
+//
+// The fold functions see if an operation on a constant can be done in place,
+// without generating run-time code.
+//
+// Returns the node to keep using, which may or may not be the node passed in.
+//
+
+TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNode, TInfoSink& infoSink, bool leftOperand)
+{
+ constUnion *unionArray = this->getUnionArrayPointer();
+
+ if (constantNode) {
+ if (constantNode->getAsConstantUnion() && constantNode->getSize() == 1 && constantNode->getType().getBasicType() != EbtStruct
+ && this->getSize() > 1) {
+ TIntermConstantUnion *node = constantNode->getAsConstantUnion();
+ TIntermConstantUnion *newNode;
+ constUnion* tempConstArray;
+ switch(op) {
+ case EOpAdd:
+ tempConstArray = new constUnion[this->getSize()];
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ switch (this->getType().getBasicType()) {
+ case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst + node->getUnionArrayPointer()->fConst; break;
+ case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst + node->getUnionArrayPointer()->iConst; break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"+\"", this->getLine());
+ return 0;
+ }
+ }
+ }
+ break;
+ case EOpMatrixTimesScalar:
+ case EOpVectorTimesScalar:
+ tempConstArray = new constUnion[this->getSize()];
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ switch (this->getType().getBasicType()) {
+ case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst * node->getUnionArrayPointer()->fConst; break;
+ case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst * node->getUnionArrayPointer()->iConst; break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"*\"", this->getLine());
+ return 0;
+ }
+ }
+ }
+ break;
+ case EOpSub:
+ tempConstArray = new constUnion[this->getSize()];
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ switch (this->getType().getBasicType()) {
+ case EbtFloat:
+ if (leftOperand)
+ tempConstArray[i].fConst = unionArray[i].fConst - node->getUnionArrayPointer()->fConst;
+ else
+ tempConstArray[i].fConst = node->getUnionArrayPointer()->fConst - unionArray[i].fConst;
+ break;
+
+ case EbtInt:
+ if (leftOperand)
+ tempConstArray[i].iConst = unionArray[i].iConst - node->getUnionArrayPointer()->iConst;
+ else
+ tempConstArray[i].iConst = node->getUnionArrayPointer()->iConst - unionArray[i].iConst;
+ break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"-\"", this->getLine());
+ return 0;
+ }
+ }
+ }
+ break;
+
+ case EOpDiv:
+ tempConstArray = new constUnion[this->getSize()];
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ switch (this->getType().getBasicType()) {
+ case EbtFloat:
+ if (leftOperand) {
+ if (node->getUnionArrayPointer()->fConst == 0.0) {
+ infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
+ tempConstArray[i].fConst = FLT_MAX;
+ } else
+ tempConstArray[i].fConst = unionArray[i].fConst / node->getUnionArrayPointer()->fConst;
+ } else {
+ if (unionArray[i].fConst == 0.0) {
+ infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
+ tempConstArray[i].fConst = FLT_MAX;
+ } else
+ tempConstArray[i].fConst = node->getUnionArrayPointer()->fConst / unionArray[i].fConst;
+ }
+ break;
+
+ case EbtInt:
+ if (leftOperand) {
+ if (node->getUnionArrayPointer()->iConst == 0) {
+ infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
+ tempConstArray[i].iConst = INT_MAX;
+ } else
+ tempConstArray[i].iConst = unionArray[i].iConst / node->getUnionArrayPointer()->iConst;
+ } else {
+ if (unionArray[i].iConst == 0) {
+ infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
+ tempConstArray[i].iConst = INT_MAX;
+ } else
+ tempConstArray[i].iConst = node->getUnionArrayPointer()->iConst / unionArray[i].iConst;
+ }
+ break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", this->getLine());
+ return 0;
+ }
+ }
+ }
+ break;
+
+ case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
+ tempConstArray = new constUnion[this->getSize()];
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ switch (this->getType().getBasicType()) {
+ case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst && node->getUnionArrayPointer()->bConst; break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"&&\"", this->getLine());
+ return 0;
+ }
+ }
+ }
+ break;
+
+ case EOpLogicalXor: // this code is written for possible future use, will not get executed currently
+ tempConstArray = new constUnion[this->getSize()];
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ switch (this->getType().getBasicType()) {
+ case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst ^ node->getUnionArrayPointer()->bConst; break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"^^\"", this->getLine());
+ return 0;
+ }
+ }
+ }
+ break;
+
+ case EOpLogicalOr: // this code is written for possible future use, will not get executed currently
+ tempConstArray = new constUnion[this->getSize()];
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ switch (this->getType().getBasicType()) {
+ case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst || node->getUnionArrayPointer()->bConst; break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"||\"", this->getLine());
+ return 0;
+ }
+ }
+ }
+ break;
+
+ default:
+ infoSink.info.message(EPrefixInternalError, "Invalid operator for constant folding", this->getLine());
+ return 0;
+ }
+ newNode = new TIntermConstantUnion(tempConstArray, this->getType());
+ newNode->setLine(this->getLine());
+
+ return newNode;
+ } else if (constantNode->getAsConstantUnion() && (this->getSize() > 1 || this->getType().getBasicType() == EbtStruct)) {
+ TIntermConstantUnion *node = constantNode->getAsConstantUnion();
+ constUnion *rightUnionArray = node->getUnionArrayPointer();
+ constUnion* tempConstArray = 0;
+ TIntermConstantUnion *tempNode;
+ int index = 0;
+ bool boolNodeFlag = false;
+ switch(op) {
+ case EOpAdd:
+ tempConstArray = new constUnion[this->getSize()];
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ switch (this->getType().getBasicType()) {
+ case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst + rightUnionArray[i].fConst; break;
+ case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst + rightUnionArray[i].iConst; break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"+\"", this->getLine());
+ return 0;
+ }
+ }
+ }
+ break;
+ case EOpSub:
+ tempConstArray = new constUnion[this->getSize()];
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ switch (this->getType().getBasicType()) {
+ case EbtFloat:
+ if (leftOperand)
+ tempConstArray[i].fConst = unionArray[i].fConst - rightUnionArray[i].fConst;
+ else
+ tempConstArray[i].fConst = rightUnionArray[i].fConst - unionArray[i].fConst;
+ break;
+
+ case EbtInt:
+ if (leftOperand)
+ tempConstArray[i].iConst = unionArray[i].iConst - rightUnionArray[i].iConst;
+ else
+ tempConstArray[i].iConst = rightUnionArray[i].iConst - unionArray[i].iConst;
+ break;
+
+ default:
+ infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"-\"", this->getLine());
+ return 0;
+ }
+ }
+ }
+ break;
+ case EOpMul:
+ if (this->isVector()) { // two vectors multiplied together
+ int size = this->getSize();
+ tempConstArray = new constUnion[size];
+
+ for (int i = 0; i < size; i++) {
+ switch (this->getType().getBasicType()) {
+ case EbtFloat: tempConstArray[i].fConst = unionArray[i].fConst * rightUnionArray[i].fConst; break;
+ case EbtInt: tempConstArray[i].iConst = unionArray[i].iConst * rightUnionArray[i].iConst; break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for vector multiply", this->getLine());
+ return 0;
+ }
+ }
+ }
+ break;
+ case EOpMatrixTimesMatrix:
+ if (this->getType().getBasicType() != EbtFloat || node->getBasicType() != EbtFloat) {
+ infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for matrix multiply", this->getLine());
+ return 0;
+ }
+ {// support MSVC++6.0
+ int size = this->getNominalSize();
+ tempConstArray = new constUnion[size*size];
+ for (int row = 0; row < size; row++) {
+ for (int column = 0; column < size; column++) {
+ tempConstArray[size * column + row].fConst = 0.0;
+ for (int i = 0; i < size; i++) {
+ tempConstArray[size * column + row].fConst += unionArray[i * size + row].fConst * (rightUnionArray[column * size + i].fConst);
+ }
+ }
+ }
+ }
+ break;
+ case EOpDiv:
+ tempConstArray = new constUnion[this->getSize()];
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ switch (this->getType().getBasicType()) {
+ case EbtFloat:
+ if (leftOperand) {
+ if (rightUnionArray[i].fConst == 0.0) {
+ infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
+ tempConstArray[i].fConst = FLT_MAX;
+ } else
+ tempConstArray[i].fConst = unionArray[i].fConst / rightUnionArray[i].fConst;
+ } else {
+ if (unionArray[i].fConst == 0.0) {
+ infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
+ tempConstArray[i].fConst = FLT_MAX;
+ } else
+ tempConstArray[i].fConst = rightUnionArray[i].fConst / unionArray[i].fConst;
+ }
+ break;
+
+ case EbtInt:
+ if (leftOperand) {
+ if (rightUnionArray[i].iConst == 0) {
+ infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
+ tempConstArray[i].iConst = INT_MAX;
+ } else
+ tempConstArray[i].iConst = unionArray[i].iConst / rightUnionArray[i].iConst;
+ } else {
+ if (unionArray[i].iConst == 0) {
+ infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
+ tempConstArray[i].iConst = INT_MAX;
+ } else
+ tempConstArray[i].iConst = rightUnionArray[i].iConst / unionArray[i].iConst;
+ }
+ break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"/\"", this->getLine());
+ return 0;
+ }
+ }
+ }
+ break;
+
+ case EOpMatrixTimesVector:
+ if (node->getBasicType() != EbtFloat) {
+ infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for matrix times vector", this->getLine());
+ return 0;
+ }
+ tempConstArray = new constUnion[this->getNominalSize()];
+
+ {// support MSVC++6.0
+ for (int size = this->getNominalSize(), i = 0; i < size; i++) {
+ tempConstArray[i].fConst = 0.0;
+ for (int j = 0; j < size; j++) {
+ tempConstArray[i].fConst += ((unionArray[j*size + i].fConst) * rightUnionArray[j].fConst);
+ }
+ }
+ }
+
+ tempNode = new TIntermConstantUnion(tempConstArray, node->getType());
+ tempNode->setLine(this->getLine());
+
+ return tempNode;
+
+ case EOpVectorTimesMatrix:
+ if (this->getType().getBasicType() != EbtFloat) {
+ infoSink.info.message(EPrefixInternalError, "Constant Folding cannot be done for vector times matrix", this->getLine());
+ return 0;
+ }
+
+ tempConstArray = new constUnion[this->getNominalSize()];
+ {// support MSVC++6.0
+ for (int size = this->getNominalSize(), i = 0; i < size; i++) {
+ tempConstArray[i].fConst = 0.0;
+ for (int j = 0; j < size; j++) {
+ tempConstArray[i].fConst += ((unionArray[j].fConst) * rightUnionArray[i*size + j].fConst);
+ }
+ }
+ }
+ break;
+
+ case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
+ tempConstArray = new constUnion[this->getSize()];
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ switch (this->getType().getBasicType()) {
+ case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst && rightUnionArray[i].bConst; break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"&&\"", this->getLine());
+ return 0;
+ }
+ }
+ }
+ break;
+
+ case EOpLogicalXor: // this code is written for possible future use, will not get executed currently
+ tempConstArray = new constUnion[this->getSize()];
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ switch (this->getType().getBasicType()) {
+ case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst ^ rightUnionArray[i].bConst; break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"^^\"", this->getLine());
+ return 0;
+ }
+ }
+ }
+ break;
+
+ case EOpLogicalOr: // this code is written for possible future use, will not get executed currently
+ tempConstArray = new constUnion[this->getSize()];
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ switch (this->getType().getBasicType()) {
+ case EbtBool: tempConstArray[i].bConst = unionArray[i].bConst || rightUnionArray[i].bConst; break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"||\"", this->getLine());
+ return 0;
+ }
+ }
+ }
+ break;
+
+ case EOpEqual:
+
+ switch (this->getType().getBasicType()) {
+ case EbtFloat:
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ if (unionArray[i].fConst != rightUnionArray[i].fConst) {
+ boolNodeFlag = true;
+ break; // break out of for loop
+ }
+ }
+ }
+ break;
+
+ case EbtInt:
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ if (unionArray[i].iConst != rightUnionArray[i].iConst) {
+ boolNodeFlag = true;
+ break; // break out of for loop
+ }
+ }
+ }
+ break;
+ case EbtBool:
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ if (unionArray[i].bConst != rightUnionArray[i].bConst) {
+ boolNodeFlag = true;
+ break; // break out of for loop
+ }
+ }
+ }
+ break;
+ case EbtStruct:
+ if (!compareStructure(node->getType(), node->getUnionArrayPointer(), unionArray, index))
+ boolNodeFlag = true;
+ break;
+
+ default:
+ infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"==\"", this->getLine());
+ return 0;
+ }
+
+ tempConstArray = new constUnion[1];
+ if (!boolNodeFlag) {
+ tempConstArray->bConst = true;
+ }
+ else {
+ tempConstArray->bConst = false;
+ }
+
+ tempNode = new TIntermConstantUnion(tempConstArray, TType(EbtBool, EvqConst));
+ tempNode->setLine(this->getLine());
+
+ return tempNode;
+
+ case EOpNotEqual:
+ switch (this->getType().getBasicType()) {
+ case EbtFloat:
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ if (unionArray[i].fConst == rightUnionArray[i].fConst) {
+ boolNodeFlag = true;
+ break; // break out of for loop
+ }
+ }
+ }
+ break;
+
+ case EbtInt:
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ if (unionArray[i].iConst == rightUnionArray[i].iConst) {
+ boolNodeFlag = true;
+ break; // break out of for loop
+ }
+ }
+ }
+ break;
+ case EbtBool:
+ {// support MSVC++6.0
+ for (int i = 0; i < this->getSize(); i++) {
+ if (unionArray[i].bConst == rightUnionArray[i].bConst) {
+ boolNodeFlag = true;
+ break; // break out of for loop
+ }
+ }
+ }
+ break;
+ case EbtStruct:
+ if (compareStructure(node->getType(), node->getUnionArrayPointer(), unionArray, index))
+ boolNodeFlag = true;
+ break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Constant folding cannot be done for \"!=\"", this->getLine());
+ return 0;
+ }
+
+ tempConstArray = new constUnion[1];
+ if (!boolNodeFlag) {
+ tempConstArray->bConst = true;
+ }
+ else {
+ tempConstArray->bConst = false;
+ }
+
+ tempNode = new TIntermConstantUnion(tempConstArray, TType(EbtBool, EvqConst));
+ tempNode->setLine(this->getLine());
+
+ return tempNode;
+
+ default:
+ infoSink.info.message(EPrefixInternalError, "Invalid operator for constant folding", this->getLine());
+ return 0;
+ }
+ tempNode = new TIntermConstantUnion(tempConstArray, this->getType());
+ tempNode->setLine(this->getLine());
+
+ return tempNode;
+ } else if (this->getSize() == 1 && this->getType().getBasicType() != EbtStruct
+ && constantNode->getSize() == 1 && constantNode->getType().getBasicType() != EbtStruct ) { // scalar constant folding
+ constUnion *unionArray = new constUnion[1];
+ TIntermConstantUnion* newNode = 0;
+
+ switch (this->getType().getBasicType()) {
+ case EbtInt:
+ {
+ //
+ // Dealing with two operands, us and constant.
+ //
+ // Do Binary operations.
+ //
+ int rightValue = constantNode->getAsConstantUnion()->getUnionArrayPointer()->iConst;
+ int leftValue = this->getUnionArrayPointer()->iConst;
+ //int line = this->getLine();
+
+ switch(op) {
+ //?? add constant intrinsics
+ case EOpAdd: unionArray->iConst = leftValue + rightValue; break;
+ case EOpSub: unionArray->iConst = leftValue - rightValue; break;
+ case EOpMul: unionArray->iConst = leftValue * rightValue; break;
+ case EOpDiv:
+ if (rightValue == 0) {
+ infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
+ unionArray->iConst = INT_MAX;
+ } else
+ unionArray->iConst = leftValue / rightValue; break;
+
+ case EOpMod: unionArray->iConst = leftValue % rightValue; break;
+
+ case EOpRightShift: unionArray->iConst = leftValue >> rightValue; break;
+ case EOpLeftShift: unionArray->iConst = leftValue << rightValue; break;
+
+ case EOpAnd: unionArray->iConst = leftValue & rightValue; break;
+ case EOpInclusiveOr: unionArray->iConst = leftValue | rightValue; break;
+ case EOpExclusiveOr: unionArray->iConst = leftValue ^ rightValue; break;
+
+ // the following assume it's okay to have memory leaks
+ case EOpEqual:
+ unionArray->bConst = leftValue == rightValue;
+ newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst));
+ break;
+ case EOpNotEqual:
+ unionArray->bConst = leftValue != rightValue;
+ newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst));
+ break;
+ case EOpLessThan:
+ unionArray->bConst = leftValue < rightValue;
+ newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst));
+ break;
+ case EOpGreaterThan:
+ unionArray->bConst = leftValue > rightValue;
+ newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst));
+ break;
+ case EOpLessThanEqual:
+ unionArray->bConst = leftValue <= rightValue;
+ newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst));
+ break;
+ case EOpGreaterThanEqual:
+ unionArray->bConst = leftValue >= rightValue;
+ newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst));
+ break;
+
+ default:
+ //infoSink.info.message(EPrefixInternalError, "Binary operation not folded into constant int", line);
+ return 0;
+ }
+ if (!newNode) {
+ newNode = new TIntermConstantUnion(unionArray, TType(EbtInt, EvqConst));
+ }
+ newNode->setLine(constantNode->getLine());
+ return newNode;
+ }
+ case EbtFloat:
+ {
+ float rightValue = constantNode->getAsConstantUnion()->getUnionArrayPointer()->fConst;
+ float leftValue = this->getUnionArrayPointer()->fConst;
+
+ switch(op) {
+ //?? add constant intrinsics
+ case EOpAdd: unionArray->fConst = leftValue + rightValue; break;
+ case EOpSub: unionArray->fConst = leftValue - rightValue; break;
+ case EOpMul: unionArray->fConst = leftValue * rightValue; break;
+ case EOpDiv:
+ if (rightValue == 0.0) {
+ infoSink.info.message(EPrefixWarning, "Divide by zero error during constant folding", this->getLine());
+ unionArray->fConst = FLT_MAX;
+ } else
+ unionArray->fConst = leftValue / rightValue; break;
+
+ // the following assume it's okay to have memory leaks (cleaned up by pool allocator)
+ case EOpEqual:
+ unionArray->bConst = leftValue == rightValue;
+ newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst));
+ break;
+ case EOpNotEqual:
+ unionArray->bConst = leftValue != rightValue;
+ newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst));
+ break;
+ case EOpLessThan:
+ unionArray->bConst = leftValue < rightValue;
+ newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst));
+ break;
+ case EOpGreaterThan:
+ unionArray->bConst = leftValue > rightValue;
+ newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst));
+ break;
+ case EOpLessThanEqual:
+ unionArray->bConst = leftValue <= rightValue;
+ newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst));
+ break;
+ case EOpGreaterThanEqual:
+ unionArray->bConst = leftValue >= rightValue;
+ newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst));
+ break;
+
+ default:
+ //infoSink.info.message(EPrefixInternalError, "Binary operation not folded into constant float", line);
+ return 0;
+ }
+ if (!newNode) {
+ newNode = new TIntermConstantUnion(unionArray, TType(EbtFloat, EvqConst));
+ }
+ newNode->setLine(constantNode->getLine());
+ return newNode;
+ }
+ case EbtBool:
+ {
+ bool rightValue = constantNode->getAsConstantUnion()->getUnionArrayPointer()->bConst;
+ bool leftValue = this->getUnionArrayPointer()->bConst;
+
+ switch(op) {
+ //?? add constant intrinsics
+ case EOpLogicalAnd: unionArray->bConst = leftValue & rightValue; break;
+ case EOpLogicalXor: unionArray->bConst = leftValue ^ rightValue; break;
+ case EOpLogicalOr: unionArray->bConst = leftValue | rightValue; break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Binary operator cannot be folded into constant bool", line);
+ return 0;
+ }
+ newNode = new TIntermConstantUnion(unionArray, TType(EbtBool, EvqConst));
+ newNode->setLine(constantNode->getLine());
+ return newNode;
+ }
+ default:
+ infoSink.info.message(EPrefixInternalError, "Cannot fold constant", this->getLine());
+ return 0;
+ }
+ }
+ } else {
+ //
+ // Do unary operations
+ //
+ TIntermConstantUnion *newNode = 0;
+ constUnion* tempConstArray = new constUnion[this->getSize()];
+ if (this->getSize() > 1) {
+ for (int i = 0; i < this->getSize(); i++) {
+ switch(op) {
+ case EOpNegative:
+ switch (this->getType().getBasicType()) {
+ case EbtFloat: tempConstArray[i].fConst = -(unionArray[i].fConst); break;
+ case EbtInt: tempConstArray[i].iConst = -(unionArray[i].iConst); break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Unary operation not folded into constant", this->getLine());
+ return 0;
+ }
+ break;
+ case EOpLogicalNot: // this code is written for possible future use, will not get executed currently
+ switch (this->getType().getBasicType()) {
+ case EbtBool: tempConstArray[i].bConst = !(unionArray[i].bConst); break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Unary operation not folded into constant", this->getLine());
+ return 0;
+ }
+ break;
+ default:
+ return 0;
+ }
+ }
+ newNode = new TIntermConstantUnion(tempConstArray, this->getType());
+ newNode->setLine(this->getLine());
+ return newNode;
+ } else {
+ switch(op) {
+ //?? add constant intrinsics
+ case EOpNegative:
+ switch (this->getType().getBasicType()) {
+ case EbtInt:
+ tempConstArray->iConst = -(this->getUnionArrayPointer()->iConst);
+ newNode = new TIntermConstantUnion(tempConstArray, TType(EbtInt, EvqConst));
+ break;
+ case EbtFloat:
+ tempConstArray->fConst = -(this->getUnionArrayPointer()->fConst);
+ newNode = new TIntermConstantUnion(tempConstArray, TType(EbtFloat, EvqConst));
+ break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Unary operation not folded into constant", line);
+ return 0;
+ }
+ break;
+ case EOpLogicalNot:
+ switch (this->getType().getBasicType()) {
+ case EbtBool:
+ tempConstArray->bConst = !this->getUnionArrayPointer()->bConst;
+ newNode = new TIntermConstantUnion(tempConstArray, TType(EbtBool, EvqConst));
+ break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Unary operation not folded into constant", line);
+ return 0;
+ }
+ break;
+ default:
+ return 0;
+ }
+ newNode->setLine(this->getLine());
+ return newNode;
+
+ }
+ }
+
+ return this;
+}
+
+TIntermConstantUnion* TIntermediate::changeAggrToTempConst(TIntermAggregate* node, TSymbolTable& symbolTable, TSourceLoc line)
+{
+ constUnion* unionArray = new constUnion[node->getType().getInstanceSize()];
+ bool returnVal;
+
+ if (node->getSequence().size() == 1 && node->getSequence()[0]->getAsTyped()->getAsConstantUnion()) {
+ returnVal = parseConstTree(line, node, unionArray, node->getOp(), symbolTable, node->getType(), true);
+ }
+ else {
+ returnVal = parseConstTree(line, node, unionArray, node->getOp(), symbolTable, node->getType());
+ }
+
+ if (returnVal)
+ unionArray = 0;
+
+ return (addConstantUnion(unionArray, node->getType(), node->getLine()));
+}
+
+TIntermTyped* TIntermediate::copyConstUnion(TIntermConstantUnion* node)
+{
+ constUnion *unionArray = node->getUnionArrayPointer();
+
+ if (!unionArray)
+ return 0;
+
+ int size;
+ if (node->getType().getBasicType() == EbtStruct)
+ //?? We should actually be calling getStructSize() function and not setStructSize. This problem occurs in case
+ // of nested/embedded structs.
+ size = node->getType().setStructSize(node->getType().getStruct());
+ //size = node->getType().getStructSize();
+ else
+ size = node->getType().getInstanceSize();
+
+ constUnion *newSpace = new constUnion[size];
+
+ for (int i = 0; i < size; i++)
+ newSpace[i] = unionArray[i];
+
+ node->setUnionArrayPointer(newSpace);
+ return node;
+}
+
+TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermConstantUnion* node)
+{
+ constUnion *rightUnionArray = node->getUnionArrayPointer();
+ int size = node->getType().getInstanceSize();
+
+ constUnion *leftUnionArray = new constUnion[size];
+
+ for (int i=0; i < size; i++) {
+
+ switch (promoteTo) {
+ case EbtFloat:
+ switch (node->getType().getBasicType()) {
+ case EbtInt:
+ (leftUnionArray[i]).fConst = static_cast<float>(rightUnionArray[i].iConst);
+ break;
+ case EbtBool:
+ (leftUnionArray[i]).fConst = static_cast<float>(rightUnionArray[i].bConst);
+ break;
+ case EbtFloat:
+ (leftUnionArray[i]).fConst = rightUnionArray[i].fConst;
+ break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Cannot promote", node->getLine());
+ return 0;
+ }
+ break;
+ case EbtInt:
+ switch (node->getType().getBasicType()) {
+ case EbtInt:
+ (leftUnionArray[i]).iConst = rightUnionArray[i].iConst;
+ break;
+ case EbtBool:
+ (leftUnionArray[i]).iConst = static_cast<int>(rightUnionArray[i].bConst);
+ break;
+ case EbtFloat:
+ (leftUnionArray[i]).iConst = static_cast<int>(rightUnionArray[i].fConst);
+ break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Cannot promote", node->getLine());
+ return 0;
+ }
+ break;
+ case EbtBool:
+ switch (node->getType().getBasicType()) {
+ case EbtInt:
+ (leftUnionArray[i]).bConst = rightUnionArray[i].iConst != 0;
+ break;
+ case EbtBool:
+ (leftUnionArray[i]).bConst = rightUnionArray[i].bConst;
+ break;
+ case EbtFloat:
+ (leftUnionArray[i]).bConst = rightUnionArray[i].fConst != 0.0;
+ break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Cannot promote", node->getLine());
+ return 0;
+ }
+
+ break;
+ default:
+ infoSink.info.message(EPrefixInternalError, "Incorrect data type found", node->getLine());
+ return 0;
+ }
+
+ }
+
+ const TType& t = node->getType();
+
+ return addConstantUnion(leftUnionArray, TType(promoteTo, t.getQualifier(), t.getNominalSize(), t.isMatrix(), t.isArray()), node->getLine());
+}
+
+//
+// This method inserts the child nodes into the parent node at the given location specified
+// by parentNodeIter. offset tells the integer offset into the parent vector that points to
+// the child node. sequenceVector is the parent vector.
+// Returns reference to the last inserted child node
+// increments the offset based on the number of child nodes added
+//
+void TIntermediate::removeChildNode(TIntermSequence &parentSequence, TType& parentType, int& offset, TIntermSequence::iterator& parentNodeIter, TIntermAggregate* child)
+{
+ if (!child)
+ return;
+
+ parentNodeIter = parentSequence.begin() + offset;
+
+ TIntermSequence& childSequence = child->getSequence();
+ int oldSize = static_cast<int>(parentSequence.size());
+ if (childSequence.size() == 1) {
+ if (!removeMatrixConstNode(parentSequence, parentType, child, offset)) {
+ for (int i = 0; i < child->getType().getInstanceSize(); i++) {
+ constUnion* constantUnion = new constUnion[1];
+ *constantUnion = *(childSequence[0]->getAsConstantUnion()->getUnionArrayPointer());
+ TIntermConstantUnion *constant = new TIntermConstantUnion(constantUnion,
+ childSequence[0]->getAsConstantUnion()->getType());
+ constant->setLine(child->getLine());
+ parentNodeIter = parentSequence.begin() + offset;
+ parentSequence.insert(parentNodeIter, constant);
+ }
+ }
+ } else
+ parentSequence.insert(parentNodeIter, childSequence.begin(), childSequence.end());
+
+ int newSize = static_cast<int>(parentSequence.size());
+ offset = offset + newSize - oldSize;
+ parentNodeIter = parentSequence.begin() + offset;
+ parentNodeIter = parentSequence.erase(parentNodeIter);
+ offset--;
+ parentNodeIter--;
+}
+
+//
+// The parent has only one child node. This method is not implemented
+// for parent that is a structure
+//
+TIntermTyped* TIntermediate::removeChildNode(TIntermTyped* parent, TType* parentType, TIntermAggregate* child)
+{
+ TIntermTyped* resultNode = 0;
+
+ if (parentType->getInstanceSize() == 1) {
+ resultNode = child->getSequence()[0]->getAsTyped();
+ } else {
+ int size = parentType->getInstanceSize();
+ TIntermSequence& parentSequence = parent->getAsAggregate()->getSequence();
+ TIntermSequence& childSequence = child->getSequence();
+
+ if (childSequence.size() == 1) {
+ if (!removeMatrixConstNode(parentSequence, *parentType, child, 1))
+ parentSequence.push_back(child->getSequence()[0]);
+ } else {
+ for (int i = 0; i < size; i++) {
+ parentSequence.push_back(child->getSequence()[i]);
+ }
+ }
+ parentSequence.erase(parentSequence.begin());
+
+ return parent;
+ }
+
+ return resultNode;
+}
+
+bool TIntermediate::removeMatrixConstNode(TIntermSequence &parentSequence, TType& parentType, TIntermAggregate* child, int offset)
+{
+ if (!child)
+ return false;
+
+ TIntermSequence::iterator parentNodeIter;
+ TIntermSequence &childSequence = child->getSequence();
+
+ switch (child->getOp()) {
+ case EOpConstructMat2:
+ case EOpConstructMat3:
+ case EOpConstructMat4:
+ {// support MSVC++6.0
+ for (int i = 0; i < child->getType().getInstanceSize(); i++) {
+ constUnion* constantUnion = new constUnion[1];
+ if (i % (child->getType().getNominalSize() + 1) == 0) {
+ *constantUnion = *(childSequence[0]->getAsConstantUnion()->getUnionArrayPointer());
+ } else {
+ switch (parentType.getBasicType()) {
+ case EbtInt: constantUnion->iConst = 0; break;
+ case EbtFloat: constantUnion->fConst = 0.0; break;
+ case EbtBool: constantUnion->bConst = false; break;
+ default: ; /* default added by BrianP */
+ }
+ }
+ TIntermConstantUnion *constant = new TIntermConstantUnion(constantUnion,
+ childSequence[0]->getAsConstantUnion()->getType());
+ constant->setLine(child->getLine());
+ parentNodeIter = parentSequence.begin() + offset + i;
+ parentSequence.insert(parentNodeIter, constant);
+ }
+ }
+ return true;
+ default:
+ return false;
+ }
+}
+
+void TIntermAggregate::addToPragmaTable(const TPragmaTable& pTable)
+{
+ assert (!pragmaTable);
+ pragmaTable = new TPragmaTable();
+ *pragmaTable = pTable;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/MMap.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/MMap.h
new file mode 100755
index 000000000..66703cdd9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/MMap.h
@@ -0,0 +1,84 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#ifndef _MMAP_INCLUDED_
+#define _MMAP_INCLUDED_
+
+//
+// Encapsulate memory mapped files
+//
+
+class TMMap {
+public:
+ TMMap(const char* fileName) :
+ fSize(-1), // -1 is the error value returned by GetFileSize()
+ fp(NULL),
+ fBuff(0) // 0 is the error value returned by MapViewOfFile()
+ {
+ if ((fp = fopen(fileName, "r")) == NULL)
+ return;
+ char c = getc(fp);
+ fSize = 0;
+ while (c != EOF) {
+ fSize++;
+ c = getc(fp);
+ }
+ if (c == EOF)
+ fSize++;
+ rewind(fp);
+ fBuff = (char*)malloc(sizeof(char) * fSize);
+ int count = 0;
+ c = getc(fp);
+ while (c != EOF) {
+ fBuff[count++] = c;
+ c = getc(fp);
+ }
+ fBuff[count++] = c;
+ }
+
+ char* getData() { return fBuff; }
+ int getSize() { return fSize; }
+
+ ~TMMap() {
+ if (fp != NULL)
+ fclose(fp);
+ }
+
+private:
+ int fSize; // size of file to map in
+ FILE *fp;
+ char* fBuff; // the actual data;
+};
+
+#endif // _MMAP_INCLUDED_
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/ParseHelper.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/ParseHelper.cpp
new file mode 100755
index 000000000..cfc42746a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/ParseHelper.cpp
@@ -0,0 +1,1452 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#include "ParseHelper.h"
+#include "Include/InitializeParseContext.h"
+#include "osinclude.h"
+#include <stdarg.h>
+///////////////////////////////////////////////////////////////////////
+//
+// Sub- vector and matrix fields
+//
+////////////////////////////////////////////////////////////////////////
+
+//
+// Look at a '.' field selector string and change it into offsets
+// for a vector.
+//
+bool TParseContext::parseVectorFields(const TString& compString, int vecSize, TVectorFields& fields, int line)
+{
+ fields.num = (int) compString.size();
+ if (fields.num > 4) {
+ error(line, "illegal vector field selection", compString.c_str(), "");
+ return false;
+ }
+
+ enum {
+ exyzw,
+ ergba,
+ estpq
+ } fieldSet[4];
+
+ for (int i = 0; i < fields.num; ++i) {
+ switch (compString[i]) {
+ case 'x':
+ fields.offsets[i] = 0;
+ fieldSet[i] = exyzw;
+ break;
+ case 'r':
+ fields.offsets[i] = 0;
+ fieldSet[i] = ergba;
+ break;
+ case 's':
+ fields.offsets[i] = 0;
+ fieldSet[i] = estpq;
+ break;
+ case 'y':
+ fields.offsets[i] = 1;
+ fieldSet[i] = exyzw;
+ break;
+ case 'g':
+ fields.offsets[i] = 1;
+ fieldSet[i] = ergba;
+ break;
+ case 't':
+ fields.offsets[i] = 1;
+ fieldSet[i] = estpq;
+ break;
+ case 'z':
+ fields.offsets[i] = 2;
+ fieldSet[i] = exyzw;
+ break;
+ case 'b':
+ fields.offsets[i] = 2;
+ fieldSet[i] = ergba;
+ break;
+ case 'p':
+ fields.offsets[i] = 2;
+ fieldSet[i] = estpq;
+ break;
+
+ case 'w':
+ fields.offsets[i] = 3;
+ fieldSet[i] = exyzw;
+ break;
+ case 'a':
+ fields.offsets[i] = 3;
+ fieldSet[i] = ergba;
+ break;
+ case 'q':
+ fields.offsets[i] = 3;
+ fieldSet[i] = estpq;
+ break;
+ default:
+ error(line, "illegal vector field selection", compString.c_str(), "");
+ return false;
+ }
+ }
+
+ for (int i = 0; i < fields.num; ++i) {
+ if (fields.offsets[i] >= vecSize) {
+ error(line, "vector field selection out of range", compString.c_str(), "");
+ return false;
+ }
+
+ if (i > 0) {
+ if (fieldSet[i] != fieldSet[i-1]) {
+ error(line, "illegal - vector component fields not from the same set", compString.c_str(), "");
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+
+//
+// Look at a '.' field selector string and change it into offsets
+// for a matrix.
+//
+bool TParseContext::parseMatrixFields(const TString& compString, int matSize, TMatrixFields& fields, int line)
+{
+ fields.wholeRow = false;
+ fields.wholeCol = false;
+ fields.row = -1;
+ fields.col = -1;
+
+ if (compString.size() != 2) {
+ error(line, "illegal length of matrix field selection", compString.c_str(), "");
+ return false;
+ }
+
+ if (compString[0] == '_') {
+ if (compString[1] < '0' || compString[1] > '3') {
+ error(line, "illegal matrix field selection", compString.c_str(), "");
+ return false;
+ }
+ fields.wholeCol = true;
+ fields.col = compString[1] - '0';
+ } else if (compString[1] == '_') {
+ if (compString[0] < '0' || compString[0] > '3') {
+ error(line, "illegal matrix field selection", compString.c_str(), "");
+ return false;
+ }
+ fields.wholeRow = true;
+ fields.row = compString[0] - '0';
+ } else {
+ if (compString[0] < '0' || compString[0] > '3' ||
+ compString[1] < '0' || compString[1] > '3') {
+ error(line, "illegal matrix field selection", compString.c_str(), "");
+ return false;
+ }
+ fields.row = compString[0] - '0';
+ fields.col = compString[1] - '0';
+ }
+
+ if (fields.row >= matSize || fields.col >= matSize) {
+ error(line, "matrix field selection out of range", compString.c_str(), "");
+ return false;
+ }
+
+ return true;
+}
+
+///////////////////////////////////////////////////////////////////////
+//
+// Errors
+//
+////////////////////////////////////////////////////////////////////////
+
+//
+// Track whether errors have occurred.
+//
+void TParseContext::recover()
+{
+ recoveredFromError = true;
+}
+
+//
+// Used by flex/bison to output all syntax and parsing errors.
+//
+void C_DECL TParseContext::error(TSourceLoc nLine, const char *szReason, const char *szToken,
+ const char *szExtraInfoFormat, ...)
+{
+ char szExtraInfo[400];
+ va_list marker;
+
+ va_start(marker, szExtraInfoFormat);
+
+ _vsnprintf(szExtraInfo, sizeof(szExtraInfo), szExtraInfoFormat, marker);
+
+ /* VC++ format: file(linenum) : error #: 'token' : extrainfo */
+ infoSink.info.prefix(EPrefixError);
+ infoSink.info.location(nLine);
+ infoSink.info << "'" << szToken << "' : " << szReason << " " << szExtraInfo << "\n";
+
+ va_end(marker);
+
+ ++numErrors;
+}
+
+//
+// Same error message for all places assignments don't work.
+//
+void TParseContext::assignError(int line, const char* op, TString left, TString right)
+{
+ error(line, "", op, "cannot convert from '%s' to '%s'",
+ right.c_str(), left.c_str());
+}
+
+//
+// Same error message for all places unary operations don't work.
+//
+void TParseContext::unaryOpError(int line, char* op, TString operand)
+{
+ error(line, " wrong operand type", op,
+ "no operation '%s' exists that takes an operand of type %s (or there is no acceptable conversion)",
+ op, operand.c_str());
+}
+
+//
+// Same error message for all binary operations don't work.
+//
+void TParseContext::binaryOpError(int line, char* op, TString left, TString right)
+{
+ error(line, " wrong operand types ", op,
+ "no operation '%s' exists that takes a left-hand operand of type '%s' and "
+ "a right operand of type '%s' (or there is no acceptable conversion)",
+ op, left.c_str(), right.c_str());
+}
+
+//
+// Both test and if necessary, spit out an error, to see if the node is really
+// an l-value that can be operated on this way.
+//
+// Returns true if the was an error.
+//
+bool TParseContext::lValueErrorCheck(int line, char* op, TIntermTyped* node)
+{
+ TIntermSymbol* symNode = node->getAsSymbolNode();
+ TIntermBinary* binaryNode = node->getAsBinaryNode();
+
+ if (binaryNode) {
+ bool errorReturn;
+
+ switch(binaryNode->getOp()) {
+ case EOpIndexDirect:
+ case EOpIndexIndirect:
+ case EOpIndexDirectStruct:
+ return lValueErrorCheck(line, op, binaryNode->getLeft());
+ case EOpVectorSwizzle:
+ errorReturn = lValueErrorCheck(line, op, binaryNode->getLeft());
+ if (!errorReturn) {
+ int offset[4] = {0,0,0,0};
+
+ TIntermTyped* rightNode = binaryNode->getRight();
+ TIntermAggregate *aggrNode = rightNode->getAsAggregate();
+
+ for (TIntermSequence::iterator p = aggrNode->getSequence().begin();
+ p != aggrNode->getSequence().end(); p++) {
+ int value = (*p)->getAsTyped()->getAsConstantUnion()->getUnionArrayPointer()->iConst;
+ offset[value]++;
+ if (offset[value] > 1) {
+ error(line, " l-value of swizzle cannot have duplicate components", op, "", "");
+
+ return true;
+ }
+ }
+ }
+
+ return errorReturn;
+ default:
+ break;
+ }
+ error(line, " l-value required", op, "", "");
+
+ return true;
+ }
+
+
+ const char* symbol = 0;
+ if (symNode != 0)
+ symbol = symNode->getSymbol().c_str();
+
+ char* message = 0;
+ switch (node->getQualifier()) {
+ case EvqConst: message = "can't modify a const"; break;
+ case EvqConstReadOnly: message = "can't modify a const"; break;
+ case EvqAttribute: message = "can't modify an attribute"; break;
+ case EvqUniform: message = "can't modify a uniform"; break;
+ case EvqVaryingIn: message = "can't modify a varying"; break;
+ case EvqInput: message = "can't modify an input"; break;
+ case EvqFace: message = "can't modify gl_FrontFace"; break;
+ case EvqFragCoord: message = "can't modify gl_FragCoord"; break;
+ default:
+
+ //
+ // Type that can't be written to?
+ //
+ switch (node->getBasicType()) {
+ case EbtSampler1D:
+ case EbtSampler2D:
+ case EbtSampler3D:
+ case EbtSamplerCube:
+ case EbtSampler1DShadow:
+ case EbtSampler2DShadow:
+ message = "can't modify a sampler";
+ break;
+ case EbtVoid:
+ message = "can't modify void";
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (message == 0 && binaryNode == 0 && symNode == 0) {
+ error(line, " l-value required", op, "", "");
+
+ return true;
+ }
+
+
+ //
+ // Everything else is okay, no error.
+ //
+ if (message == 0)
+ return false;
+
+ //
+ // If we get here, we have an error and a message.
+ //
+ if (symNode)
+ error(line, " l-value required", op, "\"%s\" (%s)", symbol, message);
+ else
+ error(line, " l-value required", op, "(%s)", message);
+
+ return true;
+}
+
+//
+// Both test, and if necessary spit out an error, to see if the node is really
+// a constant.
+//
+// Returns true if the was an error.
+//
+bool TParseContext::constErrorCheck(TIntermTyped* node)
+{
+ if (node->getQualifier() == EvqConst)
+ return false;
+
+ error(node->getLine(), "constant expression required", "", "");
+
+ return true;
+}
+
+//
+// Both test, and if necessary spit out an error, to see if the node is really
+// an integer.
+//
+// Returns true if the was an error.
+//
+bool TParseContext::integerErrorCheck(TIntermTyped* node, char* token)
+{
+ if (node->getBasicType() == EbtInt && node->getNominalSize() == 1)
+ return false;
+
+ error(node->getLine(), "integer expression required", token, "");
+
+ return true;
+}
+
+//
+// Both test, and if necessary spit out an error, to see if we are currently
+// globally scoped.
+//
+// Returns true if the was an error.
+//
+bool TParseContext::globalErrorCheck(int line, bool global, char* token)
+{
+ if (global)
+ return false;
+
+ error(line, "only allowed at global scope", token, "");
+
+ return true;
+}
+
+//
+// For now, keep it simple: if it starts "gl_", it's reserved, independent
+// of scope. Except, if the symbol table is at the built-in push-level,
+// which is when we are parsing built-ins.
+//
+// Returns true if there was an error.
+//
+bool TParseContext::reservedErrorCheck(int line, const TString& identifier)
+{
+ if (symbolTable.atBuiltInLevel() ||
+ identifier.substr(0, 3) != TString("gl_"))
+ return false;
+
+ error(line, "reserved built-in name", "gl_", "");
+
+ return true;
+}
+
+//
+// Make sure there is enough data provided to the constructor to build
+// something of the type of the constructor. Also returns the type of
+// the constructor.
+//
+// Returns true if there was an error in construction.
+//
+bool TParseContext::constructorErrorCheck(int line, TIntermNode* node, TFunction& function, TOperator op, TType* type)
+{
+ switch(op) {
+ case EOpConstructInt: *type = TType(EbtInt); break;
+ case EOpConstructBool: *type = TType(EbtBool); break;
+ case EOpConstructFloat: *type = TType(EbtFloat); break;
+ case EOpConstructVec2: *type = TType(EbtFloat, EvqTemporary, 2); break;
+ case EOpConstructVec3: *type = TType(EbtFloat, EvqTemporary, 3); break;
+ case EOpConstructVec4: *type = TType(EbtFloat, EvqTemporary, 4); break;
+ case EOpConstructBVec2: *type = TType(EbtBool, EvqTemporary, 2); break;
+ case EOpConstructBVec3: *type = TType(EbtBool, EvqTemporary, 3); break;
+ case EOpConstructBVec4: *type = TType(EbtBool, EvqTemporary, 4); break;
+ case EOpConstructIVec2: *type = TType(EbtInt, EvqTemporary, 2); break;
+ case EOpConstructIVec3: *type = TType(EbtInt, EvqTemporary, 3); break;
+ case EOpConstructIVec4: *type = TType(EbtInt, EvqTemporary, 4); break;
+ case EOpConstructMat2: *type = TType(EbtFloat, EvqTemporary, 2, true); break;
+ case EOpConstructMat3: *type = TType(EbtFloat, EvqTemporary, 3, true); break;
+ case EOpConstructMat4: *type = TType(EbtFloat, EvqTemporary, 4, true); break;
+ case EOpConstructStruct: *type = TType(function.getReturnType().getStruct(), function.getReturnType().getTypeName()); break;
+ default:
+ error(line, "expected constructor", "Internal Error", "");
+ return true;
+ }
+
+ bool constructingMatrix = false;
+ switch(op) {
+ case EOpConstructMat2:
+ case EOpConstructMat3:
+ case EOpConstructMat4:
+ constructingMatrix = true;
+ break;
+ default:
+ break;
+ }
+
+ //
+ // Note: It's okay to have too many components available, but not okay to have unused
+ // arguments. 'full' will go to true when enough args have been seen. If we loop
+ // again, there is an extra argument, so 'overfull' will become true.
+ //
+
+ int size = 0;
+ bool constType = true;
+ bool full = false;
+ bool overFull = false;
+ bool matrixInMatrix = false;
+ for (int i = 0; i < function.getParamCount(); ++i) {
+ size += function[i].type->getInstanceSize();
+ if (constructingMatrix && function[i].type->isMatrix())
+ matrixInMatrix = true;
+ if (full)
+ overFull = true;
+ if (op != EOpConstructStruct && size >= type->getInstanceSize())
+ full = true;
+ if (function[i].type->getQualifier() != EvqConst)
+ constType = false;
+ }
+
+ if (constType)
+ type->changeQualifier(EvqConst);
+
+ if (matrixInMatrix) {
+ error(line, "constructing matrix from matrix", "constructor", "(reserved)");
+ return true;
+ }
+
+ if (overFull) {
+ error(line, "too many arguments", "constructor", "");
+ return true;
+ }
+
+ if (size != 1 && size < type->getInstanceSize() || (size < 1) && op == EOpConstructStruct) {
+ error(line, "not enough data provided for construction", "constructor", "");
+ return true;
+ }
+
+ TIntermTyped* typed = node->getAsTyped();
+ if (typed == 0) {
+ error(line, "constructor argument does not have a type", "constructor", "");
+ return true;
+ }
+ if (op != EOpConstructStruct && IsSampler(typed->getBasicType())) {
+ error(line, "cannot convert a sampler", "constructor", "");
+ return true;
+ }
+ if (typed->getBasicType() == EbtVoid) {
+ error(line, "cannot convert a void", "constructor", "");
+ return true;
+ }
+
+ return false;
+}
+
+// This function checks to see if a void variable has been declared and raise an error message for such a case
+//
+// returns true in case of an error
+//
+bool TParseContext::voidErrorCheck(int line, const TString& identifier, const TPublicType& pubType)
+{
+ if (pubType.type == EbtVoid) {
+ error(line, "illegal use of type 'void'", identifier.c_str(), "");
+ return true;
+ }
+
+ return false;
+}
+
+// This function checks to see if the node (for the expression) contains a scalar boolean expression or not
+//
+// returns true in case of an error
+//
+bool TParseContext::boolErrorCheck(int line, const TIntermTyped* type)
+{
+ if (type->getBasicType() != EbtBool || type->isArray() || type->isMatrix() || type->isVector()) {
+ error(line, "boolean expression expected", "", "");
+ return true;
+ }
+
+ return false;
+}
+
+// This function checks to see if the node (for the expression) contains a scalar boolean expression or not
+//
+// returns true in case of an error
+//
+bool TParseContext::boolErrorCheck(int line, const TPublicType& pType)
+{
+ if (pType.type != EbtBool || pType.array || pType.matrix || (pType.size > 1)) {
+ error(line, "boolean expression expected", "", "");
+ return true;
+ }
+
+ return false;
+}
+
+bool TParseContext::samplerErrorCheck(int line, const TPublicType& pType, const char* reason)
+{
+ if (pType.type == EbtStruct) {
+ if (containsSampler(*pType.userDef)) {
+ error(line, reason, TType::getBasicString(pType.type), "(structure contains a sampler)");
+
+ return true;
+ }
+
+ return false;
+ } else if (IsSampler(pType.type)) {
+ error(line, reason, TType::getBasicString(pType.type), "");
+
+ return true;
+ }
+
+ return false;
+}
+
+bool TParseContext::structQualifierErrorCheck(int line, const TPublicType& pType)
+{
+ if ((pType.qualifier == EvqVaryingIn || pType.qualifier == EvqVaryingOut || pType.qualifier == EvqAttribute) &&
+ pType.type == EbtStruct) {
+ error(line, "cannot be used with a structure", getQualifierString(pType.qualifier), "");
+
+ return true;
+ }
+
+ if (pType.qualifier != EvqUniform && samplerErrorCheck(line, pType, "samplers must be uniform"))
+ return true;
+
+ return false;
+}
+
+bool TParseContext::parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type)
+{
+ if ((qualifier == EvqOut || qualifier == EvqInOut) &&
+ type.getBasicType() != EbtStruct && IsSampler(type.getBasicType())) {
+ error(line, "samplers cannot be output parameters", type.getBasicString(), "");
+ return true;
+ }
+
+ return false;
+}
+
+bool TParseContext::containsSampler(TType& type)
+{
+ if (IsSampler(type.getBasicType()))
+ return true;
+
+ if (type.getBasicType() == EbtStruct) {
+ TTypeList& structure = *type.getStruct();
+ for (unsigned int i = 0; i < structure.size(); ++i) {
+ if (containsSampler(*structure[i].type))
+ return true;
+ }
+ }
+
+ return false;
+}
+
+bool TParseContext::insertBuiltInArrayAtGlobalLevel()
+{
+ TString *name = NewPoolTString("gl_TexCoord");
+ TSymbol* symbol = symbolTable.find(*name);
+ if (!symbol) {
+ error(0, "INTERNAL ERROR finding symbol", name->c_str(), "");
+ return true;
+ }
+ TVariable* variable = static_cast<TVariable*>(symbol);
+
+ TVariable* newVariable = new TVariable(name, variable->getType());
+
+ if (! symbolTable.insert(*newVariable)) {
+ delete newVariable;
+ error(0, "INTERNAL ERROR inserting new symbol", name->c_str(), "");
+ return true;
+ }
+
+ return false;
+}
+
+//
+// Do all the semantic checking for declaring an array, with and
+// without a size, and make the right changes to the symbol table.
+//
+// size == 0 means no specified size.
+//
+// Returns true if there was an error.
+//
+bool TParseContext::arrayErrorCheck(int line, TString& identifier, TPublicType type, TIntermTyped* size)
+{
+ //
+ // Don't check for reserved word use until after we know it's not in the symbol table,
+ // because reserved arrays can be redeclared.
+ //
+
+ //
+ // Can the type be an array?
+ //
+ if (type.array || type.qualifier == EvqAttribute || type.qualifier == EvqConst) {
+ error(line, "cannot declare arrays of this type", TType(type).getCompleteString().c_str(), "");
+ return true;
+ }
+ type.array = true;
+
+ //
+ // size will be 0 if there is no size declared, otherwise it contains the size
+ // declared.
+ //
+ TIntermConstantUnion* constant = 0;
+ if (size) {
+ constant = size->getAsConstantUnion();
+ if (constant == 0 || constant->getBasicType() != EbtInt || constant->getUnionArrayPointer()->iConst <= 0) {
+ error(line, "array size must be a positive integer", identifier.c_str(), "");
+ return true;
+ }
+ }
+
+ bool builtIn = false;
+ bool sameScope = false;
+ TSymbol* symbol = symbolTable.find(identifier, &builtIn, &sameScope);
+ if (symbol == 0 || !sameScope) {
+ if (reservedErrorCheck(line, identifier))
+ return true;
+
+ TVariable* variable = new TVariable(&identifier, TType(type));
+
+ if (size)
+ variable->getType().setArraySize(constant->getUnionArrayPointer()->iConst);
+
+ if (! symbolTable.insert(*variable)) {
+ delete variable;
+ error(line, "INTERNAL ERROR inserting new symbol", identifier.c_str(), "");
+ return true;
+ }
+ } else {
+ if (! symbol->isVariable()) {
+ error(line, "variable expected", identifier.c_str(), "");
+ return true;
+ }
+
+ TVariable* variable = static_cast<TVariable*>(symbol);
+ if (! variable->getType().isArray()) {
+ error(line, "redeclaring non-array as array", identifier.c_str(), "");
+ return true;
+ }
+ if (variable->getType().getArraySize() > 0) {
+ error(line, "redeclaration of array with size", identifier.c_str(), "");
+ return true;
+ }
+
+ if (variable->getType() != TType(type)) {
+ error(line, "redeclaration of array with a different type", identifier.c_str(), "");
+ return true;
+ }
+
+ TType* t = variable->getArrayInformationType();
+ while (t != 0) {
+ if (t->getMaxArraySize() > constant->getUnionArrayPointer()->iConst) {
+ error(line, "higher index value already used for the array", identifier.c_str(), "");
+ return true;
+ }
+ t->setArraySize(constant->getUnionArrayPointer()->iConst);
+ t = t->getArrayInformationType();
+ }
+
+ if (size)
+ variable->getType().setArraySize(constant->getUnionArrayPointer()->iConst);
+ }
+
+ if (voidErrorCheck(line, identifier, type))
+ return true;
+
+ return false;
+}
+
+bool TParseContext::arraySetMaxSize(TIntermSymbol *node, TType* type, int size, bool updateFlag, TSourceLoc line)
+{
+ bool builtIn = false;
+ TSymbol* symbol = symbolTable.find(node->getSymbol(), &builtIn);
+ if (symbol == 0) {
+ error(line, " undeclared identifier", node->getSymbol().c_str(), "");
+ return true;
+ }
+ TVariable* variable = static_cast<TVariable*>(symbol);
+
+ type->setArrayInformationType(variable->getArrayInformationType());
+ variable->updateArrayInformationType(type);
+
+ // we dont want to update the maxArraySize when this flag is not set, we just want to include this
+ // node type in the chain of node types so that its updated when a higher maxArraySize comes in.
+ if (!updateFlag)
+ return false;
+
+ size++;
+ variable->getType().setMaxArraySize(size);
+ type->setMaxArraySize(size);
+ TType* tt = type;
+
+ while(tt->getArrayInformationType() != 0) {
+ tt = tt->getArrayInformationType();
+ tt->setMaxArraySize(size);
+ }
+
+ return false;
+}
+
+//
+// Do semantic checking for a variable declaration that has no initializer,
+// and update the symbol table.
+//
+// Returns true if there was an error.
+//
+bool TParseContext::nonInitErrorCheck(int line, TString& identifier, TPublicType& type)
+{
+ if (reservedErrorCheck(line, identifier))
+ recover();
+
+ //
+ // Make the qualifier make sense, error is issued in a little bit.
+ //
+ bool constError = false;
+ if (type.qualifier == EvqConst) {
+ type.qualifier = EvqTemporary;
+ constError = true;
+ }
+
+ TVariable* variable = new TVariable(&identifier, TType(type));
+
+ if (! symbolTable.insert(*variable)) {
+ error(line, "redefinition", variable->getName().c_str(), "");
+ delete variable;
+ return true;
+ }
+ if (constError) {
+ error(line, "variables with qualifier 'const' must be initialized", identifier.c_str(), "");
+ return true;
+ }
+
+ if (voidErrorCheck(line, identifier, type))
+ return true;
+
+ return false;
+}
+
+bool TParseContext::paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type)
+{
+ if (qualifier != EvqConst && qualifier != EvqTemporary) {
+ error(line, "qualifier not allowed on function parameter", getQualifierString(qualifier), "");
+ return true;
+ }
+ if (qualifier == EvqConst && paramQualifier != EvqIn) {
+ error(line, "qualifier not allowed with ", getQualifierString(qualifier), getQualifierString(paramQualifier));
+ return true;
+ }
+
+ if (qualifier == EvqConst)
+ type->changeQualifier(EvqConstReadOnly);
+ else
+ type->changeQualifier(paramQualifier);
+
+ return false;
+}
+
+/////////////////////////////////////////////////////////////////////////////////
+//
+// Non-Errors.
+//
+/////////////////////////////////////////////////////////////////////////////////
+
+//
+// Look up a function name in the symbol table, and make sure it is a function.
+//
+// Return the function symbol if found, otherwise 0.
+//
+const TFunction* TParseContext::findFunction(int line, TFunction* call, bool *builtIn)
+{
+ const TSymbol* symbol = symbolTable.find(call->getMangledName(), builtIn);
+
+ if (symbol == 0) {
+ error(line, "no matching overloaded function found", call->getName().c_str(), "");
+ return 0;
+ }
+
+ if (! symbol->isFunction()) {
+ error(line, "function name expected", call->getName().c_str(), "");
+ return 0;
+ }
+
+ const TFunction* function = static_cast<const TFunction*>(symbol);
+
+ return function;
+}
+//
+// Initializers show up in several places in the grammar. Have one set of
+// code to handle them here.
+//
+bool TParseContext::executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType,
+ TIntermTyped* initializer, TIntermNode*& intermNode)
+{
+ if (reservedErrorCheck(line, identifier))
+ return true;
+
+ if (voidErrorCheck(line, identifier, pType))
+ return true;
+
+ //
+ // add variable to symbol table
+ //
+ TVariable* variable = new TVariable(&identifier, TType(pType));
+ if (! symbolTable.insert(*variable)) {
+ error(line, "redefinition", variable->getName().c_str(), "");
+ return true;
+ // don't delete variable, it's used by error recovery, and the pool
+ // pop will take care of the memory
+ }
+
+ //
+ // identifier must be of type constant, a global, or a temporary
+ //
+ TQualifier qualifier = variable->getType().getQualifier();
+ if ((qualifier != EvqTemporary) && (qualifier != EvqGlobal) && (qualifier != EvqConst)) {
+ error(line, " cannot initialize this type of qualifier ", variable->getType().getQualifierString(), "");
+ return true;
+ }
+ //
+ // test for and propagate constant
+ //
+
+ if (qualifier == EvqConst) {
+ if (qualifier != initializer->getType().getQualifier()) {
+ error(line, " assigning non-constant to", "=", "'%s'", variable->getType().getCompleteString().c_str());
+ variable->getType().changeQualifier(EvqTemporary);
+ return true;
+ }
+ if (TType(pType) != initializer->getType()) {
+ error(line, " non-matching types for const initializer ",
+ variable->getType().getQualifierString(), "");
+ variable->getType().changeQualifier(EvqTemporary);
+ return true;
+ }
+ if (initializer->getAsConstantUnion()) {
+ constUnion* unionArray = variable->getConstPointer();
+
+ if (pType.size == 1 && TType(pType).getBasicType() != EbtStruct) {
+ switch (pType.type ) {
+ case EbtInt:
+ unionArray->iConst = (initializer->getAsConstantUnion()->getUnionArrayPointer())[0].iConst;
+ break;
+ case EbtFloat:
+ unionArray->fConst = (initializer->getAsConstantUnion()->getUnionArrayPointer())[0].fConst;
+ break;
+ case EbtBool:
+ unionArray->bConst = (initializer->getAsConstantUnion()->getUnionArrayPointer())[0].bConst;
+ break;
+ default:
+ error(line, " cannot initialize constant of this type", "", "");
+ return true;
+ }
+ } else {
+ variable->shareConstPointer(initializer->getAsConstantUnion()->getUnionArrayPointer());
+ }
+ } else if (initializer->getAsAggregate()) {
+ bool returnVal = false;
+ constUnion* unionArray = variable->getConstPointer();
+ if (initializer->getAsAggregate()->getSequence().size() == 1 && initializer->getAsAggregate()->getSequence()[0]->getAsTyped()->getAsConstantUnion()) {
+ returnVal = intermediate.parseConstTree(line, initializer, unionArray, initializer->getAsAggregate()->getOp(), symbolTable, variable->getType(), true);
+ }
+ else {
+ returnVal = intermediate.parseConstTree(line, initializer, unionArray, initializer->getAsAggregate()->getOp(), symbolTable, variable->getType());
+ }
+ intermNode = 0;
+ constUnion *arrayUnion = unionArray;
+ if (returnVal) {
+ arrayUnion = 0;
+ variable->getType().changeQualifier(EvqTemporary);
+ }
+ return returnVal;
+ } else if (initializer->getAsSymbolNode()) {
+ const TSymbol* symbol = symbolTable.find(initializer->getAsSymbolNode()->getSymbol());
+ const TVariable* tVar = static_cast<const TVariable*>(symbol);
+
+ constUnion* constArray = tVar->getConstPointer();
+ variable->shareConstPointer(constArray);
+ } else {
+ error(line, " assigning non-constant to", "=", "'%s'", variable->getType().getCompleteString().c_str());
+ variable->getType().changeQualifier(EvqTemporary);
+ return true;
+ }
+ }
+
+ if (qualifier != EvqConst) {
+ TIntermSymbol* intermSymbol = intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), line);
+ intermNode = intermediate.addAssign(EOpAssign, intermSymbol, initializer, line);
+ if (intermNode == 0) {
+ assignError(line, "=", intermSymbol->getCompleteString(), initializer->getCompleteString());
+ return true;
+ }
+ } else
+ intermNode = 0;
+
+ return false;
+}
+
+//
+// This method checks to see if the given aggregate node has all its children nodes as constants
+// This method does not test if structure members are constant
+//
+bool TParseContext::canNodeBeRemoved(TIntermNode* childNode)
+{
+ TIntermAggregate *aggrNode = childNode->getAsAggregate();
+ if (!aggrNode)
+ return false;
+
+ if (!aggrNode->isConstructor() || aggrNode->getOp() == EOpConstructStruct)
+ return false;
+
+ bool allConstant = true;
+
+ // check if all the child nodes are constants so that they can be inserted into
+ // the parent node
+ if (aggrNode) {
+ TIntermSequence &childSequenceVector = aggrNode->getSequence() ;
+ for (TIntermSequence::iterator p = childSequenceVector.begin();
+ p != childSequenceVector.end(); p++) {
+ if (!(*p)->getAsTyped()->getAsConstantUnion())
+ return false;
+ }
+ }
+
+ return allConstant;
+}
+
+// This function is used to test for the correctness of the parameters passed to various constructor functions
+// and also convert them to the right datatype if it is allowed and required.
+//
+// Returns 0 for an error or the constructed node (aggregate or typed) for no error.
+//
+TIntermTyped* TParseContext::addConstructor(TIntermNode* node, TType* type, TOperator op, TFunction* fnCall, TSourceLoc line)
+{
+ if (node == 0)
+ return 0;
+
+ TIntermAggregate* aggrNode = node->getAsAggregate();
+
+ TTypeList::iterator list;
+ TTypeList* structure = 0; // Store the information (vector) about the return type of the structure.
+ if (op == EOpConstructStruct) {
+ const TType& ttype = fnCall->getReturnType();
+ structure = ttype.getStruct();
+ list = (*structure).begin();
+ }
+
+ bool singleArg;
+ if (aggrNode) {
+ if (aggrNode->getOp() != EOpNull || aggrNode->getSequence().size() == 1)
+ singleArg = true;
+ else
+ singleArg = false;
+ } else
+ singleArg = true;
+
+ TIntermTyped *newNode;
+ if (singleArg) {
+ if (op == EOpConstructStruct) {
+ // If structure constructor is being called for only one parameter inside the structure,
+ // we need to call constructStruct function once.
+ if (structure->size() != 1) {
+ error(line, "Number of constructor parameters does not match the number of structure fields", "constructor", "");
+
+ return 0;
+ } else
+ return constructStruct(node, (*list).type, 1, node->getLine(), false);
+ } else {
+ newNode = constructBuiltIn(type, op, node, node->getLine(), false);
+ if (newNode && newNode->getAsAggregate()) {
+ if (canNodeBeRemoved(newNode->getAsAggregate()->getSequence()[0])) {
+ TIntermAggregate* returnAggNode = newNode->getAsAggregate()->getSequence()[0]->getAsAggregate();
+ newNode = intermediate.removeChildNode(newNode, type, returnAggNode);
+ }
+ }
+ return newNode;
+ }
+ }
+
+ //
+ // Handle list of arguments.
+ //
+ TIntermSequence &sequenceVector = aggrNode->getSequence() ; // Stores the information about the parameter to the constructor
+ // if the structure constructor contains more than one parameter, then construct
+ // each parameter
+ if (op == EOpConstructStruct) {
+ if (structure->size() != sequenceVector.size()) { // If the number of parameters to the constructor does not match the expected number of parameters
+ error(line, "Number of constructor parameters does not match the number of structure fields", "constructor", "");
+
+ return 0;
+ }
+ }
+
+ int paramCount = 0; // keeps a track of the constructor parameter number being checked
+
+ // for each parameter to the constructor call, check to see if the right type is passed or convert them
+ // to the right type if possible (and allowed).
+ // for structure constructors, just check if the right type is passed, no conversion is allowed.
+
+ for (TIntermSequence::iterator p = sequenceVector.begin();
+ p != sequenceVector.end(); p++, paramCount++) {
+ bool move = false;
+ if (op == EOpConstructStruct) {
+ newNode = constructStruct(*p, (list[paramCount]).type, paramCount+1, node->getLine(), true);
+ if (newNode)
+ move = true;
+ } else {
+ newNode = constructBuiltIn(type, op, *p, node->getLine(), true);
+
+ if (newNode) {
+ if (canNodeBeRemoved(newNode))
+ intermediate.removeChildNode(sequenceVector, *type, paramCount, p, newNode->getAsAggregate());
+ else
+ move = true;
+ }
+ }
+ if (move) {
+ sequenceVector.erase(p);
+ sequenceVector.insert(p, newNode);
+ }
+ }
+
+ return intermediate.setAggregateOperator(aggrNode, op, line);
+}
+
+// Function for constructor implementation. Calls addUnaryMath with appropriate EOp value
+// for the parameter to the constructor (passed to this function). Essentially, it converts
+// the parameter types correctly. If a constructor expects an int (like ivec2) and is passed a
+// float, then float is converted to int.
+//
+// Returns 0 for an error or the constructed node.
+//
+TIntermTyped* TParseContext::constructBuiltIn(TType* type, TOperator op, TIntermNode* node, TSourceLoc line, bool subset)
+{
+ TIntermTyped* newNode;
+ TOperator basicOp;
+
+ //
+ // First, convert types as needed.
+ //
+ switch (op) {
+ case EOpConstructVec2:
+ case EOpConstructVec3:
+ case EOpConstructVec4:
+ case EOpConstructMat2:
+ case EOpConstructMat3:
+ case EOpConstructMat4:
+ case EOpConstructFloat:
+ basicOp = EOpConstructFloat;
+ break;
+
+ case EOpConstructIVec2:
+ case EOpConstructIVec3:
+ case EOpConstructIVec4:
+ case EOpConstructInt:
+ basicOp = EOpConstructInt;
+ break;
+
+ case EOpConstructBVec2:
+ case EOpConstructBVec3:
+ case EOpConstructBVec4:
+ case EOpConstructBool:
+ basicOp = EOpConstructBool;
+ break;
+
+ default:
+ error(line, "unsupported construction", "", "");
+ recover();
+
+ return 0;
+ }
+ newNode = intermediate.addUnaryMath(basicOp, node, node->getLine(), symbolTable);
+ if (newNode == 0) {
+ error(line, "can't convert", "constructor", "");
+ return 0;
+ }
+
+ //
+ // Now, if there still isn't an operation to do the construction, and we need one, add one.
+ //
+
+ // Otherwise, skip out early.
+ if (subset || newNode != node && newNode->getType() == *type)
+ return newNode;
+
+ // setAggregateOperator will insert a new node for the constructor, as needed.
+ return intermediate.setAggregateOperator(newNode, op, line);
+}
+
+// This function tests for the type of the parameters to the structures constructors. Raises
+// an error message if the expected type does not match the parameter passed to the constructor.
+//
+// Returns 0 for an error or the input node itself if the expected and the given parameter types match.
+//
+TIntermTyped* TParseContext::constructStruct(TIntermNode* node, TType* type, int paramCount, TSourceLoc line, bool subset)
+{
+ if (*type == node->getAsTyped()->getType()) {
+ if (subset)
+ return node->getAsTyped();
+ else
+ return intermediate.setAggregateOperator(node->getAsTyped(), EOpConstructStruct, line);
+ } else {
+ error(line, "", "constructor", "cannot convert parameter %d from '%s' to '%s'", paramCount,
+ node->getAsTyped()->getType().getBasicString(), type->getBasicString());
+ recover();
+ }
+
+ return 0;
+}
+
+//
+// This function returns the tree representation for the vector field(s) being accessed from contant vector.
+// If only one component of vector is accessed (v.x or v[0] where v is a contant vector), then a contant node is
+// returned, else an aggregate node is returned (for v.xy). The input to this function could either be the symbol
+// node or it could be the intermediate tree representation of accessing fields in a constant structure or column of
+// a constant matrix.
+//
+TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTyped* node, TSourceLoc line)
+{
+ TIntermTyped* typedNode;
+ TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
+ TIntermAggregate* aggregateNode = node->getAsAggregate();
+
+ constUnion *unionArray;
+ if (tempConstantNode) {
+ unionArray = tempConstantNode->getUnionArrayPointer();
+
+ if (!unionArray) { // this error message should never be raised
+ infoSink.info.message(EPrefixInternalError, "constUnion not initialized in addConstVectorNode function", line);
+ recover();
+
+ return node;
+ }
+ } else if (aggregateNode) { // if an aggregate node is present, the value has to be taken from the parse tree
+ // for a case like vec(4).xz
+ unionArray = new constUnion[aggregateNode->getType().getInstanceSize()];
+
+ bool returnVal = false;
+ if (aggregateNode->getAsAggregate()->getSequence().size() == 1 && aggregateNode->getAsAggregate()->getSequence()[0]->getAsTyped()->getAsConstantUnion()) {
+ returnVal = intermediate.parseConstTree(line, aggregateNode, unionArray, aggregateNode->getOp(), symbolTable, aggregateNode->getType(), true);
+ }
+ else {
+ returnVal = intermediate.parseConstTree(line, aggregateNode, unionArray, aggregateNode->getOp(), symbolTable, aggregateNode->getType());
+ }
+
+ if (returnVal)
+ return 0;
+
+ } else { // The node has to be either a symbol node or an aggregate node or a tempConstant node, else, its an error
+ error(line, "No aggregate or constant union node available", "Internal Error", "");
+ recover();
+
+ return 0;
+ }
+
+ constUnion* constArray = new constUnion[fields.num];
+
+ for (int i = 0; i < fields.num; i++) {
+ if (fields.offsets[i] >= node->getType().getInstanceSize()) {
+ error(line, "", "[", "vector field selection out of range '%d'", fields.offsets[i]);
+ recover();
+ fields.offsets[i] = 0;
+ }
+
+ constArray[i] = unionArray[fields.offsets[i]];
+
+ }
+ typedNode = intermediate.addConstantUnion(constArray, node->getType(), line);
+ return typedNode;
+}
+
+//
+// This function returns the column being accessed from a constant matrix. The values are retrieved from
+// the symbol table and parse-tree is built for a vector (each column of a matrix is a vector). The input
+// to the function could either be a symbol node (m[0] where m is a constant matrix)that represents a
+// constant matrix or it could be the tree representation of the constant matrix (s.m1[0] where s is a constant structure)
+//
+TIntermTyped* TParseContext::addConstMatrixNode(int index, TIntermTyped* node, TSourceLoc line)
+{
+ TIntermTyped* typedNode;
+ TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
+ TIntermAggregate* aggregateNode = node->getAsAggregate();
+
+ if (index >= node->getType().getNominalSize()) {
+ error(line, "", "[", "matrix field selection out of range '%d'", index);
+ recover();
+ index = 0;
+ }
+
+ if (tempConstantNode) {
+ constUnion* unionArray = tempConstantNode->getUnionArrayPointer();
+ int size = tempConstantNode->getType().getNominalSize();
+ typedNode = intermediate.addConstantUnion(&unionArray[size*index], tempConstantNode->getType(), line);
+ } else if (aggregateNode) {
+ // for a case like mat4(5)[0]
+ constUnion* unionArray = new constUnion[aggregateNode->getType().getInstanceSize()];
+ int size = aggregateNode->getType().getNominalSize();
+
+ bool returnVal = false;
+ if (aggregateNode->getAsAggregate()->getSequence().size() == 1 && aggregateNode->getAsAggregate()->getSequence()[0]->getAsTyped()->getAsConstantUnion()) {
+ returnVal = intermediate.parseConstTree(line, aggregateNode, unionArray, aggregateNode->getOp(), symbolTable, aggregateNode->getType(), true);
+ }
+ else {
+ returnVal = intermediate.parseConstTree(line, aggregateNode, unionArray, aggregateNode->getOp(), symbolTable, aggregateNode->getType());
+ }
+
+ if (!returnVal)
+ typedNode = intermediate.addConstantUnion(&unionArray[size*index], aggregateNode->getType(), line);
+ else
+ return 0;
+
+ } else {
+ error(line, "No Aggregate or Constant Union node available", "Internal Error", "");
+ recover();
+
+ return 0;
+ }
+
+ return typedNode;
+}
+
+//
+// This function returns the value of a particular field inside a constant structure from the symbol table.
+// If there is an embedded/nested struct, it appropriately calls addConstStructNested or addConstStructFromAggr
+// function and returns the parse-tree with the values of the embedded/nested struct.
+//
+TIntermTyped* TParseContext::addConstStruct(TString& identifier, TIntermTyped* node, TSourceLoc line)
+{
+ TTypeList* fields = node->getType().getStruct();
+ TIntermTyped *typedNode;
+ int instanceSize = 0;
+ unsigned int index = 0;
+ TIntermConstantUnion *tempConstantNode = node->getAsConstantUnion();
+ TIntermAggregate* aggregateNode = node->getAsAggregate();
+
+ for ( index = 0; index < fields->size(); ++index) {
+ if ((*fields)[index].type->getFieldName() == identifier) {
+ break;
+ } else {
+ if ((*fields)[index].type->getStruct())
+ //?? We should actually be calling getStructSize() function and not setStructSize. This problem occurs in case
+ // of nested/embedded structs.
+ instanceSize += (*fields)[index].type->setStructSize((*fields)[index].type->getStruct());
+ else
+ instanceSize += (*fields)[index].type->getInstanceSize();
+ }
+ }
+
+ if (tempConstantNode) {
+ constUnion* constArray = tempConstantNode->getUnionArrayPointer();
+
+ typedNode = intermediate.addConstantUnion(constArray+instanceSize, tempConstantNode->getType(), line); // type will be changed in the calling function
+ } else if (aggregateNode) {
+ // for a case like constStruct(1,v3).i where structure fields is int i and vec3 v3.
+
+ constUnion* unionArray = new constUnion[aggregateNode->getType().getStructSize()];
+
+ bool returnVal = false;
+ if (aggregateNode->getAsAggregate()->getSequence().size() == 1 && aggregateNode->getAsAggregate()->getSequence()[0]->getAsTyped()->getAsConstantUnion()) {
+ returnVal = intermediate.parseConstTree(line, aggregateNode, unionArray, aggregateNode->getOp(), symbolTable, aggregateNode->getType(), true);
+ }
+ else {
+ returnVal = intermediate.parseConstTree(line, aggregateNode, unionArray, aggregateNode->getOp(), symbolTable, aggregateNode->getType());
+ }
+
+ if (!returnVal)
+ typedNode = intermediate.addConstantUnion(unionArray+instanceSize, aggregateNode->getType(), line);
+ else
+ return 0;
+
+ } else {
+ error(line, "No Aggregate or Constant Union node available", "Internal Error", "");
+ recover();
+
+ return 0;
+ }
+
+ return typedNode;
+}
+
+//
+// Initialize all supported extensions to disable
+//
+void TParseContext::initializeExtensionBehavior()
+{
+ //
+ // example code: extensionBehavior["test"] = EDisable; // where "test" is the name of
+ // supported extension
+ //
+}
+
+OS_TLSIndex GlobalParseContextIndex = OS_INVALID_TLS_INDEX;
+
+bool InitializeParseContextIndex()
+{
+ if (GlobalParseContextIndex != OS_INVALID_TLS_INDEX) {
+ assert(0 && "InitializeParseContextIndex(): Parse Context already initalised");
+ return false;
+ }
+
+ //
+ // Allocate a TLS index.
+ //
+ GlobalParseContextIndex = OS_AllocTLSIndex();
+
+ if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {
+ assert(0 && "InitializeParseContextIndex(): Parse Context already initalised");
+ return false;
+ }
+
+ return true;
+}
+
+bool InitializeGlobalParseContext()
+{
+ if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {
+ assert(0 && "InitializeGlobalParseContext(): Parse Context index not initalised");
+ return false;
+ }
+
+ TThreadParseContext *lpParseContext = static_cast<TThreadParseContext *>(OS_GetTLSValue(GlobalParseContextIndex));
+ if (lpParseContext != 0) {
+ assert(0 && "InitializeParseContextIndex(): Parse Context already initalised");
+ return false;
+ }
+
+ TThreadParseContext *lpThreadData = new TThreadParseContext();
+ if (lpThreadData == 0) {
+ assert(0 && "InitializeGlobalParseContext(): Unable to create thread parse context");
+ return false;
+ }
+
+ lpThreadData->lpGlobalParseContext = 0;
+ OS_SetTLSValue(GlobalParseContextIndex, lpThreadData);
+
+ return true;
+}
+
+TParseContextPointer& GetGlobalParseContext()
+{
+ //
+ // Minimal error checking for speed
+ //
+
+ TThreadParseContext *lpParseContext = static_cast<TThreadParseContext *>(OS_GetTLSValue(GlobalParseContextIndex));
+
+ return lpParseContext->lpGlobalParseContext;
+}
+
+bool FreeParseContext()
+{
+ if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {
+ assert(0 && "FreeParseContext(): Parse Context index not initalised");
+ return false;
+ }
+
+ TThreadParseContext *lpParseContext = static_cast<TThreadParseContext *>(OS_GetTLSValue(GlobalParseContextIndex));
+ if (lpParseContext)
+ delete lpParseContext;
+
+ return true;
+}
+
+bool FreeParseContextIndex()
+{
+ OS_TLSIndex tlsiIndex = GlobalParseContextIndex;
+
+ if (GlobalParseContextIndex == OS_INVALID_TLS_INDEX) {
+ assert(0 && "FreeParseContextIndex(): Parse Context index not initalised");
+ return false;
+ }
+
+ GlobalParseContextIndex = OS_INVALID_TLS_INDEX;
+
+ return OS_FreeTLSIndex(tlsiIndex);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/ParseHelper.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/ParseHelper.h
new file mode 100755
index 000000000..00552b855
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/ParseHelper.h
@@ -0,0 +1,143 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+#ifndef _PARSER_HELPER_INCLUDED_
+#define _PARSER_HELPER_INCLUDED_
+
+#include "../Include/ShHandle.h"
+#include "SymbolTable.h"
+#include "localintermediate.h"
+
+struct TMatrixFields {
+ bool wholeRow;
+ bool wholeCol;
+ int row;
+ int col;
+};
+
+typedef enum {
+ EBhRequire,
+ EBhEnable,
+ EBhWarn,
+ EBhDisable
+} TBehavior;
+
+struct TPragma {
+ TPragma(bool o, bool d) : optimize(o), debug(d) { }
+ bool optimize;
+ bool debug;
+ TPragmaTable pragmaTable;
+};
+
+//
+// The following are extra variables needed during parsing, grouped together so
+// they can be passed to the parser without needing a global.
+//
+struct TParseContext {
+ TParseContext(TSymbolTable& symt, TIntermediate& interm, EShLanguage L, TInfoSink& is) :
+ intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0),
+ recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0),
+ inTypeParen(false), contextPragma(true, false) { }
+ TIntermediate& intermediate; // to hold and build a parse tree
+ TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed
+ TInfoSink& infoSink;
+ EShLanguage language; // vertex or fragment language (future: pack or unpack)
+ TIntermNode* treeRoot; // root of parse tree being created
+ bool recoveredFromError; // true if a parse error has occurred, but we continue to parse
+ int numErrors;
+ bool lexAfterType; // true if we've recognized a type, so can only be looking for an identifier
+ int loopNestingLevel; // 0 if outside all loops
+ bool inTypeParen; // true if in parentheses, looking only for an identifier
+ const TType* currentFunctionType; // the return type of the function that's currently being parsed
+ bool functionReturnsValue; // true if a non-void function has a return
+ TMap<TString, TBehavior> extensionBehavior;
+ void initializeExtensionBehavior();
+
+ void C_DECL error(TSourceLoc, const char *szReason, const char *szToken,
+ const char *szExtraInfoFormat, ...);
+ bool reservedErrorCheck(int line, const TString& identifier);
+ void recover();
+
+ bool parseVectorFields(const TString&, int vecSize, TVectorFields&, int line);
+ bool parseMatrixFields(const TString&, int matSize, TMatrixFields&, int line);
+ void assignError(int line, const char* op, TString left, TString right);
+ void unaryOpError(int line, char* op, TString operand);
+ void binaryOpError(int line, char* op, TString left, TString right);
+ bool lValueErrorCheck(int line, char* op, TIntermTyped*);
+ bool constErrorCheck(TIntermTyped* node);
+ bool integerErrorCheck(TIntermTyped* node, char* token);
+ bool globalErrorCheck(int line, bool global, char* token);
+ bool constructorErrorCheck(int line, TIntermNode*, TFunction&, TOperator, TType*);
+ bool arrayErrorCheck(int line, TString& identifier, TPublicType type, TIntermTyped* size);
+ bool insertBuiltInArrayAtGlobalLevel();
+ bool voidErrorCheck(int, const TString&, const TPublicType&);
+ bool boolErrorCheck(int, const TIntermTyped*);
+ bool boolErrorCheck(int, const TPublicType&);
+ bool samplerErrorCheck(int line, const TPublicType& pType, const char* reason);
+ bool structQualifierErrorCheck(int line, const TPublicType& pType);
+ bool parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type);
+ bool containsSampler(TType& type);
+ bool nonInitErrorCheck(int line, TString& identifier, TPublicType& type);
+ bool paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type);
+ const TFunction* findFunction(int line, TFunction* pfnCall, bool *builtIn = 0);
+ bool executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType,
+ TIntermTyped* initializer, TIntermNode*& intermNode);
+ bool canNodeBeRemoved(TIntermNode*);
+ TIntermTyped* addConstructor(TIntermNode*, TType*, TOperator, TFunction*, TSourceLoc);
+ TIntermTyped* constructStruct(TIntermNode*, TType*, int, TSourceLoc, bool subset);
+ TIntermTyped* constructBuiltIn(TType*, TOperator, TIntermNode*, TSourceLoc, bool subset);
+ TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, TSourceLoc);
+ TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc);
+ TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc);
+ bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc);
+ struct TPragma contextPragma;
+ TString HashErrMsg;
+ bool AfterEOF;
+};
+
+int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext&);
+void PaReservedWord();
+int PaIdentOrType(TString& id, TParseContext&, TSymbol*&);
+int PaParseComment(int &lineno, TParseContext&);
+void setInitialState();
+
+typedef TParseContext* TParseContextPointer;
+extern TParseContextPointer& GetGlobalParseContext();
+#define GlobalParseContext GetGlobalParseContext()
+
+typedef struct TThreadParseContextRec
+{
+ TParseContext *lpGlobalParseContext;
+} TThreadParseContext;
+
+#endif // _PARSER_HELPER_INCLUDED_
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/PoolAlloc.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/PoolAlloc.cpp
new file mode 100755
index 000000000..ba717fce1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/PoolAlloc.cpp
@@ -0,0 +1,349 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#include "../Include/PoolAlloc.h"
+#include "../Include/Common.h"
+
+#include "Include/InitializeGlobals.h"
+#include "osinclude.h"
+
+OS_TLSIndex PoolIndex;
+
+void InitializeGlobalPools()
+{
+ TThreadGlobalPools* globalPools= static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));
+ if (globalPools)
+ return;
+
+ TPoolAllocator *globalPoolAllocator = new TPoolAllocator(true);
+
+ TThreadGlobalPools* threadData = new TThreadGlobalPools();
+
+ threadData->globalPoolAllocator = globalPoolAllocator;
+
+ OS_SetTLSValue(PoolIndex, threadData);
+ globalPoolAllocator->push();
+}
+
+void FreeGlobalPools()
+{
+ // Release the allocated memory for this thread.
+ TThreadGlobalPools* globalPools= static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));
+ if (!globalPools)
+ return;
+
+ GlobalPoolAllocator.popAll();
+ delete &GlobalPoolAllocator;
+ delete globalPools;
+}
+
+bool InitializePoolIndex()
+{
+ // Allocate a TLS index.
+ if ((PoolIndex = OS_AllocTLSIndex()) == OS_INVALID_TLS_INDEX)
+ return false;
+
+ return true;
+}
+
+void FreePoolIndex()
+{
+ // Release the TLS index.
+ OS_FreeTLSIndex(PoolIndex);
+}
+
+TPoolAllocator& GetGlobalPoolAllocator()
+{
+ TThreadGlobalPools* threadData = static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));
+
+ return *threadData->globalPoolAllocator;
+}
+
+void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator)
+{
+ TThreadGlobalPools* threadData = static_cast<TThreadGlobalPools*>(OS_GetTLSValue(PoolIndex));
+
+ threadData->globalPoolAllocator = poolAllocator;
+}
+
+//
+// Implement the functionality of the TPoolAllocator class, which
+// is documented in PoolAlloc.h.
+//
+TPoolAllocator::TPoolAllocator(bool g, int growthIncrement, int allocationAlignment) :
+ global(g),
+ pageSize(growthIncrement),
+ alignment(allocationAlignment),
+ freeList(0),
+ inUseList(0),
+ numCalls(0)
+{
+ //
+ // Don't allow page sizes we know are smaller than all common
+ // OS page sizes.
+ //
+ if (pageSize < 4*1024)
+ pageSize = 4*1024;
+
+ //
+ // A large currentPageOffset indicates a new page needs to
+ // be obtained to allocate memory.
+ //
+ currentPageOffset = pageSize;
+
+ //
+ // Adjust alignment to be at least pointer aligned and
+ // power of 2.
+ //
+ size_t minAlign = sizeof(void*);
+ alignment &= ~(minAlign - 1);
+ if (alignment < minAlign)
+ alignment = minAlign;
+ size_t a = 1;
+ while (a < alignment)
+ a <<= 1;
+ alignment = a;
+ alignmentMask = a - 1;
+
+ //
+ // Align header skip
+ //
+ headerSkip = minAlign;
+ if (headerSkip < sizeof(tHeader)) {
+ headerSkip = (sizeof(tHeader) + alignmentMask) & ~alignmentMask;
+ }
+
+ //
+ // Put a marker at the beginning of the stack. We won't
+ // pop() past this.
+ //
+ tAllocState start = { currentPageOffset, 0 };
+ stack.push_back(start);
+}
+
+TPoolAllocator::~TPoolAllocator()
+{
+ if (!global) {
+ //
+ // Then we know that this object is not being
+ // allocated after other, globally scoped objects
+ // that depend on it. So we can delete the "in use" memory.
+ //
+ while (inUseList) {
+ tHeader* next = inUseList->nextPage;
+ inUseList->~tHeader();
+ delete [] reinterpret_cast<char*>(inUseList);
+ inUseList = next;
+ }
+ }
+
+ //
+ // Always delete the free list memory - it can't be being
+ // (correctly) referenced, whether the pool allocator was
+ // global or not. We should not check the guard blocks
+ // here, because we did it already when the block was
+ // placed into the free list.
+ //
+ while (freeList) {
+ tHeader* next = freeList->nextPage;
+ delete [] reinterpret_cast<char*>(freeList);
+ freeList = next;
+ }
+}
+
+// Support MSVC++ 6.0
+const unsigned char TAllocation::guardBlockBeginVal = 0xfb;
+const unsigned char TAllocation::guardBlockEndVal = 0xfe;
+const unsigned char TAllocation::userDataFill = 0xcd;
+
+# ifdef GUARD_BLOCKS
+ const size_t TAllocation::guardBlockSize = 16;
+# else
+ const size_t TAllocation::guardBlockSize = 0;
+# endif
+
+//
+// Check a single guard block for damage
+//
+void TAllocation::checkGuardBlock(unsigned char* blockMem, unsigned char val, char* locText) const
+{
+ for (int x = 0; x < guardBlockSize; x++) {
+ if (blockMem[x] != val) {
+ char assertMsg[80];
+
+ // We don't print the assert message. It's here just to be helpful.
+ sprintf(assertMsg, "PoolAlloc: Damage %s %u byte allocation at 0x%p\n",
+ locText, size, data());
+ assert(0 && "PoolAlloc: Damage in guard block");
+ }
+ }
+}
+
+
+void TPoolAllocator::push()
+{
+ tAllocState state = { currentPageOffset, inUseList };
+
+ stack.push_back(state);
+
+ //
+ // Indicate there is no current page to allocate from.
+ //
+ currentPageOffset = pageSize;
+}
+
+//
+// Do a mass-deallocation of all the individual allocations
+// that have occurred since the last push(), or since the
+// last pop(), or since the object's creation.
+//
+// The deallocated pages are saved for future allocations.
+//
+void TPoolAllocator::pop()
+{
+ if (stack.size() < 1)
+ return;
+
+ tHeader* page = stack.back().page;
+ currentPageOffset = stack.back().offset;
+
+ while (inUseList != page) {
+ // invoke destructor to free allocation list
+ inUseList->~tHeader();
+
+ tHeader* nextInUse = inUseList->nextPage;
+ if (inUseList->pageCount > 1)
+ delete [] reinterpret_cast<char*>(inUseList);
+ else {
+ inUseList->nextPage = freeList;
+ freeList = inUseList;
+ }
+ inUseList = nextInUse;
+ }
+
+ stack.pop_back();
+}
+
+//
+// Do a mass-deallocation of all the individual allocations
+// that have occurred.
+//
+void TPoolAllocator::popAll()
+{
+ while (stack.size() > 0)
+ pop();
+}
+
+void* TPoolAllocator::allocate(size_t numBytes)
+{
+ // If we are using guard blocks, all allocations are bracketed by
+ // them: [guardblock][allocation][guardblock]. numBytes is how
+ // much memory the caller asked for. allocationSize is the total
+ // size including guard blocks. In release build,
+ // guardBlockSize=0 and this all gets optimized away.
+ size_t allocationSize = TAllocation::allocationSize(numBytes);
+
+ //
+ // Just keep some interesting statistics.
+ //
+ ++numCalls;
+ totalBytes += numBytes;
+
+ //
+ // Do the allocation, most likely case first, for efficiency.
+ // This step could be moved to be inline sometime.
+ //
+ if (currentPageOffset + allocationSize <= pageSize) {
+ //
+ // Safe to allocate from currentPageOffset.
+ //
+ unsigned char* memory = reinterpret_cast<unsigned char *>(inUseList) + currentPageOffset;
+ currentPageOffset += allocationSize;
+ currentPageOffset = (currentPageOffset + alignmentMask) & ~alignmentMask;
+
+ return initializeAllocation(inUseList, memory, numBytes);
+ }
+
+ if (allocationSize + headerSkip > pageSize) {
+ //
+ // Do a multi-page allocation. Don't mix these with the others.
+ // The OS is efficient and allocating and free-ing multiple pages.
+ //
+ size_t numBytesToAlloc = allocationSize + headerSkip;
+ tHeader* memory = reinterpret_cast<tHeader*>(::new char[numBytesToAlloc]);
+ if (memory == 0)
+ return 0;
+
+ // Use placement-new to initialize header
+ new(memory) tHeader(inUseList, (numBytesToAlloc + pageSize - 1) / pageSize);
+ inUseList = memory;
+
+ currentPageOffset = pageSize; // make next allocation come from a new page
+
+ // No guard blocks for multi-page allocations (yet)
+ return reinterpret_cast<void*>(reinterpret_cast<UINT_PTR>(memory) + headerSkip);
+ }
+
+ //
+ // Need a simple page to allocate from.
+ //
+ tHeader* memory;
+ if (freeList) {
+ memory = freeList;
+ freeList = freeList->nextPage;
+ } else {
+ memory = reinterpret_cast<tHeader*>(::new char[pageSize]);
+ if (memory == 0)
+ return 0;
+ }
+
+ // Use placement-new to initialize header
+ new(memory) tHeader(inUseList, 1);
+ inUseList = memory;
+
+ unsigned char* ret = reinterpret_cast<unsigned char *>(inUseList) + headerSkip;
+ currentPageOffset = (headerSkip + allocationSize + alignmentMask) & ~alignmentMask;
+
+ return initializeAllocation(inUseList, ret, numBytes);
+}
+
+
+//
+// Check all allocations in a list for damage by calling check on each.
+//
+void TAllocation::checkAllocList() const
+{
+ for (const TAllocation* alloc = this; alloc != 0; alloc = alloc->prevAlloc)
+ alloc->check();
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/QualifierAlive.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/QualifierAlive.cpp
new file mode 100755
index 000000000..2897f48b1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/QualifierAlive.cpp
@@ -0,0 +1,91 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#include "../Include/intermediate.h"
+
+class TAliveTraverser : public TIntermTraverser {
+public:
+ TAliveTraverser(TQualifier q) : TIntermTraverser(), found(false), qualifier(q)
+ {
+ visitSymbol = AliveSymbol;
+ visitSelection = AliveSelection;
+ rightToLeft = true;
+ }
+ bool wasFound() { return found; }
+protected:
+ bool found;
+ TQualifier qualifier;
+
+ friend void AliveSymbol(TIntermSymbol*, TIntermTraverser*);
+ friend bool AliveSelection(bool, TIntermSelection*, TIntermTraverser*);
+};
+
+//
+// Report whether or not a variable of the given qualifier type
+// is guaranteed written. Not always possible to determine if
+// it is written conditionally.
+//
+// ?? It does not do this well yet, this is just a place holder
+// that simply determines if it was reference at all, anywhere.
+//
+bool QualifierWritten(TIntermNode* node, TQualifier qualifier)
+{
+ TAliveTraverser it(qualifier);
+
+ if (node)
+ node->traverse(&it);
+
+ return it.wasFound();
+}
+
+void AliveSymbol(TIntermSymbol* node, TIntermTraverser* it)
+{
+ TAliveTraverser* lit = static_cast<TAliveTraverser*>(it);
+
+ //
+ // If it's what we're looking for, record it.
+ //
+ if (node->getQualifier() == lit->qualifier)
+ lit->found = true;
+}
+
+bool AliveSelection(bool preVisit, TIntermSelection* node, TIntermTraverser* it)
+{
+ TAliveTraverser* lit = static_cast<TAliveTraverser*>(it);
+
+ if (lit->wasFound())
+ return false;
+
+ return true;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/QualifierAlive.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/QualifierAlive.h
new file mode 100755
index 000000000..73e902cd0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/QualifierAlive.h
@@ -0,0 +1,35 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+bool QualifierWritten(TIntermNode* root, TQualifier);
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/RemoveTree.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/RemoveTree.cpp
new file mode 100755
index 000000000..2435a485b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/RemoveTree.cpp
@@ -0,0 +1,98 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#include "../Include/intermediate.h"
+#include "RemoveTree.h"
+//
+// Code to recursively delete the intermediate tree.
+//
+
+void RemoveSymbol(TIntermSymbol* node, TIntermTraverser* it)
+{
+ delete node;
+}
+
+bool RemoveBinary(bool /*preVisit*/ , TIntermBinary* node, TIntermTraverser*)
+{
+ delete node;
+
+ return true;
+}
+
+bool RemoveUnary(bool /*preVisit */, TIntermUnary* node, TIntermTraverser*)
+{
+ delete node;
+
+ return true;
+}
+
+bool RemoveAggregate(bool /*preVisit*/ , TIntermAggregate* node, TIntermTraverser*)
+{
+ delete node;
+
+ return true;
+}
+
+bool RemoveSelection(bool /*preVisit*/ , TIntermSelection* node, TIntermTraverser*)
+{
+ delete node;
+
+ return true;
+}
+
+void RemoveConstantUnion(TIntermConstantUnion* node, TIntermTraverser*)
+{
+ delete node;
+}
+
+//
+// Entry point.
+//
+void RemoveAllTreeNodes(TIntermNode* root)
+{
+ TIntermTraverser it;
+
+ it.visitAggregate = RemoveAggregate;
+ it.visitBinary = RemoveBinary;
+ it.visitConstantUnion = RemoveConstantUnion;
+ it.visitSelection = RemoveSelection;
+ it.visitSymbol = RemoveSymbol;
+ it.visitUnary = RemoveUnary;
+
+ it.preVisit = false;
+ it.postVisit = true;
+
+ root->traverse(&it);
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/RemoveTree.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/RemoveTree.h
new file mode 100755
index 000000000..171092f1a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/RemoveTree.h
@@ -0,0 +1,35 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+void RemoveAllTreeNodes(TIntermNode*);
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/ShaderLang.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/ShaderLang.cpp
new file mode 100755
index 000000000..3f37e15f3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/ShaderLang.cpp
@@ -0,0 +1,607 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+//
+// Implement the top-level of interface to the compiler/linker,
+// as defined in ShaderLang.h
+//
+#include "SymbolTable.h"
+#include "ParseHelper.h"
+#include "../Include/ShHandle.h"
+#include "Initialisation.h"
+
+#define SH_EXPORTING
+#include "../Public/ShaderLangExt.h"
+
+#include "Include/ResourceLimits.h"
+#include "Initialize.h"
+
+extern "C" int InitPreprocessor(void);
+extern "C" int FinalizePreprocessor(void);
+extern void SetGlobalPoolAllocatorPtr(TPoolAllocator* poolAllocator);
+
+bool generateBuiltInSymbolTable(const TBuiltInResource* resources, TInfoSink&, TSymbolTable*, EShLanguage language = EShLangCount);
+bool initializeSymbolTable(TBuiltInStrings* BuiltInStrings, EShLanguage language, TInfoSink& infoSink, const TBuiltInResource *resources, TSymbolTable*);
+
+//
+// A symbol table for each language. Each has a different
+// set of built-ins, and we want to preserve that from
+// compile to compile.
+//
+TSymbolTable SymbolTables[EShLangCount];
+
+TPoolAllocator* PerProcessGPA = 0;
+//
+// This is the platform independent interface between an OGL driver
+// and the shading language compiler/linker.
+//
+
+//
+// Driver must call this first, once, before doing any other
+// compiler/linker operations.
+//
+int ShInitialize()
+{
+ TInfoSink infoSink;
+ bool ret = true;
+
+ if (!InitProcess())
+ return 0;
+
+ // This method should be called once per process. If its called by multiple threads, then
+ // we need to have thread synchronization code around the initialization of per process
+ // global pool allocator
+ if (!PerProcessGPA) {
+ TPoolAllocator *builtInPoolAllocator = new TPoolAllocator(true);
+ builtInPoolAllocator->push();
+ TPoolAllocator* gPoolAllocator = &GlobalPoolAllocator;
+ SetGlobalPoolAllocatorPtr(builtInPoolAllocator);
+
+ TSymbolTable symTables[EShLangCount];
+ generateBuiltInSymbolTable(0, infoSink, symTables);
+
+ PerProcessGPA = new TPoolAllocator(true);
+ PerProcessGPA->push();
+ SetGlobalPoolAllocatorPtr(PerProcessGPA);
+
+ SymbolTables[EShLangVertex].copyTable(symTables[EShLangVertex]);
+ SymbolTables[EShLangFragment].copyTable(symTables[EShLangFragment]);
+
+ SetGlobalPoolAllocatorPtr(gPoolAllocator);
+
+ symTables[EShLangVertex].pop();
+ symTables[EShLangFragment].pop();
+
+ builtInPoolAllocator->popAll();
+ delete builtInPoolAllocator;
+
+ }
+
+ return ret ? 1 : 0;
+}
+
+//
+// Driver calls these to create and destroy compiler/linker
+// objects.
+//
+
+ShHandle ShConstructCompiler(const EShLanguage language, int debugOptions)
+{
+ if (!InitThread())
+ return 0;
+
+ TShHandleBase* base = static_cast<TShHandleBase*>(ConstructCompiler(language, debugOptions));
+
+ return reinterpret_cast<void*>(base);
+}
+
+ShHandle ShConstructLinker(const EShExecutable executable, int debugOptions)
+{
+ if (!InitThread())
+ return 0;
+
+ TShHandleBase* base = static_cast<TShHandleBase*>(ConstructLinker(executable, debugOptions));
+
+ return reinterpret_cast<void*>(base);
+}
+
+ShHandle ShConstructUniformMap()
+{
+ if (!InitThread())
+ return 0;
+
+ TShHandleBase* base = static_cast<TShHandleBase*>(ConstructUniformMap());
+
+ return reinterpret_cast<void*>(base);
+}
+
+void ShDestruct(ShHandle handle)
+{
+ if (handle == 0)
+ return;
+
+ TShHandleBase* base = static_cast<TShHandleBase*>(handle);
+
+ if (base->getAsCompiler())
+ DeleteCompiler(base->getAsCompiler());
+ else if (base->getAsLinker())
+ DeleteLinker(base->getAsLinker());
+ else if (base->getAsUniformMap())
+ DeleteUniformMap(base->getAsUniformMap());
+}
+
+//
+// Cleanup symbol tables
+//
+int __fastcall ShFinalize()
+{
+ if (PerProcessGPA) {
+ PerProcessGPA->popAll();
+ delete PerProcessGPA;
+ }
+ return 1;
+}
+
+//
+// This function should be called only once by the Master Dll. Currently, this is being called for each thread
+// which is incorrect. This is required to keep the Sh interface working for now and will eventually be called
+// from master dll once.
+//
+bool generateBuiltInSymbolTable(const TBuiltInResource* resources, TInfoSink& infoSink, TSymbolTable* symbolTables, EShLanguage language)
+{
+ TBuiltIns builtIns;
+
+ if (resources) {
+ builtIns.initialize(*resources);
+ initializeSymbolTable(builtIns.getBuiltInStrings(), language, infoSink, resources, symbolTables);
+ } else {
+ builtIns.initialize();
+ initializeSymbolTable(builtIns.getBuiltInStrings(), EShLangVertex, infoSink, resources, symbolTables);
+ initializeSymbolTable(builtIns.getBuiltInStrings(), EShLangFragment, infoSink, resources, symbolTables);
+ }
+
+ return true;
+}
+
+bool initializeSymbolTable(TBuiltInStrings* BuiltInStrings, EShLanguage language, TInfoSink& infoSink, const TBuiltInResource* resources, TSymbolTable* symbolTables)
+{
+ TIntermediate intermediate(infoSink);
+ TSymbolTable* symbolTable;
+
+ if (resources)
+ symbolTable = symbolTables;
+ else
+ symbolTable = &symbolTables[language];
+
+ TParseContext parseContext(*symbolTable, intermediate, language, infoSink);
+
+ GlobalParseContext = &parseContext;
+
+ setInitialState();
+
+ assert (symbolTable->isEmpty() || symbolTable->atSharedBuiltInLevel());
+
+ //
+ // Parse the built-ins. This should only happen once per
+ // language symbol table.
+ //
+ // Push the symbol table to give it an initial scope. This
+ // push should not have a corresponding pop, so that built-ins
+ // are preserved, and the test for an empty table fails.
+ //
+
+ symbolTable->push();
+
+ //Initialize the Preprocessor
+ int ret = InitPreprocessor();
+ if (ret) {
+ infoSink.info.message(EPrefixInternalError, "Unable to intialize the Preprocessor");
+ return false;
+ }
+
+ for (TBuiltInStrings::iterator i = BuiltInStrings[parseContext.language].begin();
+ i != BuiltInStrings[parseContext.language].end();
+ ++i) {
+ const char* builtInShaders[1];
+ int builtInLengths[1];
+
+ builtInShaders[0] = (*i).c_str();
+ builtInLengths[0] = (int) (*i).size();
+
+ if (PaParseStrings(const_cast<char**>(builtInShaders), builtInLengths, 1, parseContext) != 0) {
+ infoSink.info.message(EPrefixInternalError, "Unable to parse built-ins");
+ return false;
+ }
+ }
+
+ if (resources) {
+ IdentifyBuiltIns(parseContext.language, *symbolTable, *resources);
+ } else {
+ IdentifyBuiltIns(parseContext.language, *symbolTable);
+ }
+
+ FinalizePreprocessor();
+
+ return true;
+}
+
+
+//
+// Do an actual compile on the given strings. The result is left
+// in the given compile object.
+//
+// Return: The return value of ShCompile is really boolean, indicating
+// success or failure.
+//
+int ShCompile(
+ const ShHandle handle,
+ const char* const shaderStrings[],
+ const int numStrings,
+ const EShOptimizationLevel optLevel,
+ const TBuiltInResource* resources,
+ int debugOptions
+ )
+{
+ if (!InitThread())
+ return 0;
+
+ if (handle == 0)
+ return 0;
+
+ TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
+ TCompiler* compiler = base->getAsCompiler();
+ if (compiler == 0)
+ return 0;
+
+ GlobalPoolAllocator.push();
+ compiler->infoSink.info.erase();
+ compiler->infoSink.debug.erase();
+
+ if (numStrings == 0)
+ return 1;
+
+ TIntermediate intermediate(compiler->infoSink);
+ TSymbolTable symbolTable(SymbolTables[compiler->getLanguage()]);
+
+ generateBuiltInSymbolTable(resources, compiler->infoSink, &symbolTable, compiler->getLanguage());
+
+ TParseContext parseContext(symbolTable, intermediate, compiler->getLanguage(), compiler->infoSink);
+ parseContext.initializeExtensionBehavior();
+
+ GlobalParseContext = &parseContext;
+
+ setInitialState();
+
+ InitPreprocessor();
+ //
+ // Parse the application's shaders. All the following symbol table
+ // work will be throw-away, so push a new allocation scope that can
+ // be thrown away, then push a scope for the current shader's globals.
+ //
+ bool success = true;
+
+ symbolTable.push();
+ if (!symbolTable.atGlobalLevel())
+ parseContext.infoSink.info.message(EPrefixInternalError, "Wrong symbol table level");
+
+ if (parseContext.insertBuiltInArrayAtGlobalLevel())
+ success = false;
+
+ int ret = PaParseStrings(const_cast<char**>(shaderStrings), 0, numStrings, parseContext);
+ if (ret)
+ success = false;
+
+ if (success && parseContext.treeRoot) {
+ if (optLevel == EShOptNoGeneration)
+ parseContext.infoSink.info.message(EPrefixNone, "No errors. No code generation or linking was requested.");
+ else {
+ success = intermediate.postProcess(parseContext.treeRoot, parseContext.language);
+
+ if (success) {
+
+ if (debugOptions & EDebugOpIntermediate)
+ intermediate.outputTree(parseContext.treeRoot);
+
+ //
+ // Call the machine dependent compiler
+ //
+ if (! compiler->compile(parseContext.treeRoot))
+ success = false;
+ }
+ }
+ } else if (!success) {
+ parseContext.infoSink.info.prefix(EPrefixError);
+ parseContext.infoSink.info << parseContext.numErrors << " compilation errors. No code generated.\n\n";
+ success = false;
+ if (debugOptions & EDebugOpIntermediate)
+ intermediate.outputTree(parseContext.treeRoot);
+ }
+
+ intermediate.remove(parseContext.treeRoot);
+
+ //
+ // Ensure symbol table is returned to the built-in level,
+ // throwing away all but the built-ins.
+ //
+ while (! symbolTable.atSharedBuiltInLevel())
+ symbolTable.pop();
+
+ FinalizePreprocessor();
+ //
+ // Throw away all the temporary memory used by the compilation process.
+ //
+ GlobalPoolAllocator.pop();
+
+ return success ? 1 : 0;
+}
+
+//
+// Do an actual link on the given compile objects.
+//
+// Return: The return value of is really boolean, indicating
+// success or failure.
+//
+int ShLink(
+ const ShHandle linkHandle,
+ const ShHandle compHandles[],
+ const int numHandles,
+ ShHandle uniformMapHandle,
+ short int** uniformsAccessed,
+ int* numUniformsAccessed)
+
+{
+ if (!InitThread())
+ return 0;
+
+ TShHandleBase* base = reinterpret_cast<TShHandleBase*>(linkHandle);
+ TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
+ if (linker == 0)
+ return 0;
+
+ int returnValue;
+ GlobalPoolAllocator.push();
+ returnValue = ShLinkExt(linkHandle, compHandles, numHandles);
+ GlobalPoolAllocator.pop();
+
+ if (returnValue)
+ return 1;
+
+ return 0;
+}
+//
+// This link method will be eventually used once the ICD supports the new linker interface
+//
+int ShLinkExt(
+ const ShHandle linkHandle,
+ const ShHandle compHandles[],
+ const int numHandles)
+{
+ if (linkHandle == 0 || numHandles == 0)
+ return 0;
+
+ THandleList cObjects;
+
+ {// support MSVC++6.0
+ for (int i = 0; i < numHandles; ++i) {
+ if (compHandles[i] == 0)
+ return 0;
+ TShHandleBase* base = reinterpret_cast<TShHandleBase*>(compHandles[i]);
+ if (base->getAsLinker()) {
+ cObjects.push_back(base->getAsLinker());
+ }
+ if (base->getAsCompiler())
+ cObjects.push_back(base->getAsCompiler());
+
+
+ if (cObjects[i] == 0)
+ return 0;
+ }
+ }
+
+ TShHandleBase* base = reinterpret_cast<TShHandleBase*>(linkHandle);
+ TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
+
+ if (linker == 0)
+ return 0;
+
+ linker->infoSink.info.erase();
+
+ {// support MSVC++6.0
+ for (int i = 0; i < numHandles; ++i) {
+ if (cObjects[i]->getAsCompiler()) {
+ if (! cObjects[i]->getAsCompiler()->linkable()) {
+ linker->infoSink.info.message(EPrefixError, "Not all shaders have valid object code.");
+ return 0;
+ }
+ }
+ }
+ }
+
+ bool ret = linker->link(cObjects);
+
+ return ret ? 1 : 0;
+}
+
+//
+// ShSetEncrpytionMethod is a place-holder for specifying
+// how source code is encrypted.
+//
+void ShSetEncryptionMethod(ShHandle handle)
+{
+ if (handle == 0)
+ return;
+}
+
+//
+// Return any compiler/linker/uniformmap log of messages for the application.
+//
+const char* ShGetInfoLog(const ShHandle handle)
+{
+ if (!InitThread())
+ return 0;
+
+ if (handle == 0)
+ return 0;
+
+ TShHandleBase* base = static_cast<TShHandleBase*>(handle);
+ TInfoSink* infoSink;
+
+ if (base->getAsCompiler())
+ infoSink = &(base->getAsCompiler()->getInfoSink());
+ else if (base->getAsLinker())
+ infoSink = &(base->getAsLinker()->getInfoSink());
+
+ infoSink->info << infoSink->debug.c_str();
+ return infoSink->info.c_str();
+}
+
+//
+// Return the resulting binary code from the link process. Structure
+// is machine dependent.
+//
+const void* ShGetExecutable(const ShHandle handle)
+{
+ if (!InitThread())
+ return 0;
+
+ if (handle == 0)
+ return 0;
+
+ TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
+
+ TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
+ if (linker == 0)
+ return 0;
+
+ return linker->getObjectCode();
+}
+
+//
+// Let the linker know where the application said it's attributes are bound.
+// The linker does not use these values, they are remapped by the ICD or
+// hardware. It just needs them to know what's aliased.
+//
+// Return: The return value of is really boolean, indicating
+// success or failure.
+//
+// This is to preserve the old linker API, P20 code can use the generic
+// ShConstructBinding() and ShAddBinding() APIs
+//
+int ShSetVirtualAttributeBindings(const ShHandle handle, const ShBindingTable* table)
+{
+ if (!InitThread())
+ return 0;
+
+ if (handle == 0)
+ return 0;
+
+ TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
+ TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
+
+ if (linker == 0)
+ return 0;
+
+ linker->setAppAttributeBindings(table);
+
+ return 1;
+}
+
+//
+// Let the linker know where the predefined attributes have to live.
+// This is to preserve the old linker API, P20 code can use the generic
+// ShConstructBinding() and ShAddBinding() APIs
+//
+int ShSetFixedAttributeBindings(const ShHandle handle, const ShBindingTable* table)
+{
+ if (!InitThread())
+ return 0;
+
+ if (handle == 0)
+ return 0;
+
+ TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
+ TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
+
+ if (linker == 0)
+ return 0;
+
+ linker->setFixedAttributeBindings(table);
+ return 1;
+}
+
+//
+// Some attribute locations are off-limits to the linker...
+//
+int ShExcludeAttributes(const ShHandle handle, int *attributes, int count)
+{
+ if (!InitThread())
+ return 0;
+
+ if (handle == 0)
+ return 0;
+
+ TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
+ TLinker* linker = static_cast<TLinker*>(base->getAsLinker());
+ if (linker == 0)
+ return 0;
+
+ linker->setExcludedAttributes(attributes, count);
+
+ return 1;
+}
+
+//
+// Return the index for OpenGL to use for knowing where a uniform lives.
+//
+// Return: The return value of is really boolean, indicating
+// success or failure.
+//
+// We dont have to change this code for now since the TUniformMap being
+// passed back to ICD by the linker is the same as being used for the old P10 linker
+//
+int ShGetUniformLocation(const ShHandle handle, const char* name)
+{
+ if (!InitThread())
+ return 0;
+
+ if (handle == 0)
+ return -1;
+
+ TShHandleBase* base = reinterpret_cast<TShHandleBase*>(handle);
+ TUniformMap* uniformMap= base->getAsUniformMap();
+ if (uniformMap == 0)
+ return -1;
+
+ return uniformMap->getLocation(name);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/SymbolTable.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/SymbolTable.cpp
new file mode 100755
index 000000000..0e052c2ea
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/SymbolTable.cpp
@@ -0,0 +1,235 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+//
+// Symbol table for parsing. Most functionaliy and main ideas
+// are documented in the header file.
+//
+
+#include "SymbolTable.h"
+
+//
+// TType helper function needs a place to live.
+//
+
+//
+// Recursively generate mangled names.
+//
+void TType::buildMangledName(TString& mangledName)
+{
+ if (isMatrix())
+ mangledName += 'm';
+ else if (isVector())
+ mangledName += 'v';
+
+ switch (type) {
+ case EbtFloat: mangledName += 'f'; break;
+ case EbtInt: mangledName += 'i'; break;
+ case EbtBool: mangledName += 'b'; break;
+ case EbtSampler1D: mangledName += "s1"; break;
+ case EbtSampler2D: mangledName += "s2"; break;
+ case EbtSampler3D: mangledName += "s3"; break;
+ case EbtSamplerCube: mangledName += "sC"; break;
+ case EbtSampler1DShadow: mangledName += "sS1"; break;
+ case EbtSampler2DShadow: mangledName += "sS2"; break;
+ case EbtStruct:
+ mangledName += "struct-";
+ if (typeName)
+ mangledName += *typeName;
+ {// support MSVC++6.0
+ for (unsigned int i = 0; i < structure->size(); ++i) {
+ mangledName += '-';
+ (*structure)[i].type->buildMangledName(mangledName);
+ }
+ }
+ default:
+ break;
+ }
+
+ mangledName += static_cast<char>('0' + getNominalSize());
+ if (isArray()) {
+ char buf[10];
+ sprintf(buf, "%d", arraySize);
+ mangledName += '[';
+ mangledName += buf;
+ mangledName += ']';
+ }
+}
+
+//
+// Dump functions.
+//
+
+void TVariable::dump(TInfoSink& infoSink) const
+{
+ infoSink.debug << getName().c_str() << ": " << type.getQualifierString() << " " << type.getBasicString();
+ if (type.isArray()) {
+ infoSink.debug << "[0]";
+ }
+ infoSink.debug << "\n";
+}
+
+void TFunction::dump(TInfoSink &infoSink) const
+{
+ infoSink.debug << getName().c_str() << ": " << returnType.getBasicString() << " " << getMangledName().c_str() << "\n";
+}
+
+void TSymbolTableLevel::dump(TInfoSink &infoSink) const
+{
+ tLevel::const_iterator it;
+ for (it = level.begin(); it != level.end(); ++it)
+ (*it).second->dump(infoSink);
+}
+
+void TSymbolTable::dump(TInfoSink &infoSink) const
+{
+ for (int level = currentLevel(); level >= 0; --level) {
+ infoSink.debug << "LEVEL " << level << "\n";
+ table[level]->dump(infoSink);
+ }
+}
+
+//
+// Functions have buried pointers to delete.
+//
+TFunction::~TFunction()
+{
+ for (TParamList::iterator i = parameters.begin(); i != parameters.end(); ++i)
+ delete (*i).type;
+}
+
+//
+// Symbol table levels are a map of pointers to symbols that have to be deleted.
+//
+TSymbolTableLevel::~TSymbolTableLevel()
+{
+ for (tLevel::iterator it = level.begin(); it != level.end(); ++it)
+ delete (*it).second;
+}
+
+//
+// Change all function entries in the table with the non-mangled name
+// to be related to the provided built-in operation. This is a low
+// performance operation, and only intended for symbol tables that
+// live across a large number of compiles.
+//
+void TSymbolTableLevel::relateToOperator(const char* name, TOperator op)
+{
+ tLevel::iterator it;
+ for (it = level.begin(); it != level.end(); ++it) {
+ if ((*it).second->isFunction()) {
+ TFunction* function = static_cast<TFunction*>((*it).second);
+ if (function->getName() == name)
+ function->relateToOperator(op);
+ }
+ }
+}
+
+
+TSymbol::TSymbol(const TSymbol& copyOf)
+{
+ name = NewPoolTString(copyOf.name->c_str());
+ uniqueId = copyOf.uniqueId;
+}
+
+TVariable::TVariable(const TVariable& copyOf, TStructureMap& remapper) : TSymbol(copyOf)
+{
+ type.copyType(copyOf.type, remapper);
+ userType = copyOf.userType;
+ // for builtIn symbol table level, unionArray and arrayInformation pointers should be NULL
+ assert(copyOf.arrayInformationType == 0);
+ arrayInformationType = 0;
+
+ if (copyOf.unionArray) {
+ assert(!copyOf.type.getStruct());
+ assert(copyOf.type.getInstanceSize() == 1);
+ unionArray = new constUnion[1];
+ switch (type.getBasicType()) {
+ case EbtFloat: unionArray[0].fConst = copyOf.unionArray[0].fConst; break;
+ case EbtInt: unionArray[0].iConst = copyOf.unionArray[0].iConst; break;
+ case EbtBool: unionArray[0].bConst = copyOf.unionArray[0].bConst; break;
+ default:
+ assert (false && "Unknown type");
+ }
+ } else
+ unionArray = 0;
+}
+
+TVariable* TVariable::clone(TStructureMap& remapper)
+{
+ TVariable *variable = new TVariable(*this, remapper);
+
+ return variable;
+}
+
+TFunction::TFunction(const TFunction& copyOf, TStructureMap& remapper) : TSymbol(copyOf)
+{
+ for (unsigned int i = 0; i < copyOf.parameters.size(); ++i) {
+ TParameter param;
+ parameters.push_back(param);
+ parameters.back().copyParam(copyOf.parameters[i], remapper);
+ }
+
+ returnType.copyType(copyOf.returnType, remapper);
+ mangledName = copyOf.mangledName;
+ op = copyOf.op;
+ defined = copyOf.defined;
+}
+
+TFunction* TFunction::clone(TStructureMap& remapper)
+{
+ TFunction *function = new TFunction(*this, remapper);
+
+ return function;
+}
+
+TSymbolTableLevel* TSymbolTableLevel::clone(TStructureMap& remapper)
+{
+ TSymbolTableLevel *symTableLevel = new TSymbolTableLevel();
+ tLevel::iterator iter;
+ for (iter = level.begin(); iter != level.end(); ++iter) {
+ symTableLevel->insert(*iter->second->clone(remapper));
+ }
+
+ return symTableLevel;
+}
+
+void TSymbolTable::copyTable(const TSymbolTable& copyOf)
+{
+ TStructureMap remapper;
+ uniqueId = copyOf.uniqueId;
+ for (unsigned int i = 0; i < copyOf.table.size(); ++i) {
+ table.push_back(copyOf.table[i]->clone(remapper));
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/SymbolTable.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/SymbolTable.h
new file mode 100755
index 000000000..7e4ff6824
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/SymbolTable.h
@@ -0,0 +1,320 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#ifndef _SYMBOL_TABLE_INCLUDED_
+#define _SYMBOL_TABLE_INCLUDED_
+
+//
+// Symbol table for parsing. Has these design characteristics:
+//
+// * Same symbol table can be used to compile many shaders, to preserve
+// effort of creating and loading with the large numbers of built-in
+// symbols.
+//
+// * Name mangling will be used to give each function a unique name
+// so that symbol table lookups are never ambiguous. This allows
+// a simpler symbol table structure.
+//
+// * Pushing and popping of scope, so symbol table will really be a stack
+// of symbol tables. Searched from the top, with new inserts going into
+// the top.
+//
+// * Constants: Compile time constant symbols will keep their values
+// in the symbol table. The parser can substitute constants at parse
+// time, including doing constant folding and constant propagation.
+//
+// * No temporaries: Temporaries made from operations (+, --, .xy, etc.)
+// are tracked in the intermediate representation, not the symbol table.
+//
+
+#include "Include/Common.h"
+#include "Include/intermediate.h"
+#include "Include/InfoSink.h"
+
+//
+// Symbol base class. (Can build functions or variables out of these...)
+//
+class TSymbol {
+public:
+ POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
+ TSymbol(const TString *n) : name(n) { }
+ virtual ~TSymbol() { /* don't delete name, it's from the pool */ }
+ const TString& getName() const { return *name; }
+ virtual const TString& getMangledName() const { return getName(); }
+ virtual bool isFunction() const { return false; }
+ virtual bool isVariable() const { return false; }
+ void setUniqueId(int id) { uniqueId = id; }
+ int getUniqueId() const { return uniqueId; }
+ virtual void dump(TInfoSink &infoSink) const = 0;
+ TSymbol(const TSymbol&);
+ virtual TSymbol* clone(TStructureMap& remapper) = 0;
+
+protected:
+ const TString *name;
+ unsigned int uniqueId; // For real comparing during code generation
+};
+
+//
+// Variable class, meaning a symbol that's not a function.
+//
+// There could be a separate class heirarchy for Constant variables;
+// Only one of int, bool, or float, (or none) is correct for
+// any particular use, but it's easy to do this way, and doesn't
+// seem worth having separate classes, and "getConst" can't simply return
+// different values for different types polymorphically, so this is
+// just simple and pragmatic.
+//
+class TVariable : public TSymbol {
+public:
+ TVariable(const TString *name, const TType& t, bool uT = false ) : TSymbol(name), type(t), userType(uT), unionArray(0), arrayInformationType(0) { }
+ virtual ~TVariable() { }
+ virtual bool isVariable() const { return true; }
+ TType& getType() { return type; }
+ const TType& getType() const { return type; }
+ bool isUserType() const { return userType; }
+ void changeQualifier(TQualifier qualifier) { type.changeQualifier(qualifier); }
+ void updateArrayInformationType(TType *t) { arrayInformationType = t; }
+ TType* getArrayInformationType() { return arrayInformationType; }
+
+ virtual void dump(TInfoSink &infoSink) const;
+
+ constUnion* getConstPointer() {
+ if (!unionArray) {
+ if (!type.getStruct())
+ unionArray = new constUnion[type.getInstanceSize()];
+ else
+ unionArray = new constUnion[type.getStructSize()];
+ }
+ return unionArray;
+ }
+
+ constUnion* getConstPointer() const { return unionArray; }
+
+ void shareConstPointer( constUnion *constArray)
+ {
+ delete unionArray;
+ unionArray = constArray;
+ }
+ TVariable(const TVariable&, TStructureMap& remapper); // copy constructor
+ virtual TVariable* clone(TStructureMap& remapper);
+
+protected:
+ TType type;
+ bool userType;
+ // we are assuming that Pool Allocator will free the memory allocated to unionArray
+ // when this object is destroyed
+ constUnion *unionArray;
+ TType *arrayInformationType; // this is used for updating maxArraySize in all the references to a given symbol
+};
+
+//
+// The function sub-class of symbols and the parser will need to
+// share this definition of a function parameter.
+//
+struct TParameter {
+ TString *name;
+ TType* type;
+ void copyParam(const TParameter& param, TStructureMap& remapper) {
+ name = NewPoolTString(param.name->c_str());
+ type = param.type->clone(remapper);
+ }
+};
+
+//
+// The function sub-class of a symbol.
+//
+class TFunction : public TSymbol {
+public:
+ TFunction(TOperator o) :
+ TSymbol(0),
+ returnType(TType(EbtVoid)),
+ op(o),
+ defined(false) { }
+ TFunction(const TString *name, TType& retType, TOperator tOp = EOpNull) :
+ TSymbol(name),
+ returnType(retType),
+ mangledName(*name + '('),
+ op(tOp),
+ defined(false) { }
+ virtual ~TFunction();
+ virtual bool isFunction() const { return true; }
+
+ void addParameter(TParameter& p)
+ {
+ parameters.push_back(p);
+ mangledName = mangledName + p.type->getMangledName();
+ }
+
+ const TString& getMangledName() const { return mangledName; }
+ const TType& getReturnType() const { return returnType; }
+ void relateToOperator(TOperator o) { op = o; }
+ TOperator getBuiltInOp() const { return op; }
+ void setDefined() { defined = true; }
+ bool isDefined() { return defined; }
+
+ int getParamCount() const { return static_cast<int>(parameters.size()); }
+ TParameter& operator [](int i) { return parameters[i]; }
+ const TParameter& operator [](int i) const { return parameters[i]; }
+
+ virtual void dump(TInfoSink &infoSink) const;
+ TFunction(const TFunction&, TStructureMap& remapper);
+ virtual TFunction* clone(TStructureMap& remapper);
+
+protected:
+ typedef TVector<TParameter> TParamList;
+ TParamList parameters;
+ TType returnType;
+ TString mangledName;
+ TOperator op;
+ bool defined;
+};
+
+
+class TSymbolTableLevel {
+public:
+ POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
+ TSymbolTableLevel() { }
+ ~TSymbolTableLevel();
+
+ bool insert(TSymbol& symbol)
+ {
+ //
+ // returning true means symbol was added to the table
+ //
+ tInsertResult result;
+ result = level.insert(tLevelPair(symbol.getMangledName(), &symbol));
+
+ return result.second;
+ }
+
+ TSymbol* find(const TString& name) const
+ {
+ tLevel::const_iterator it = level.find(name);
+ if (it == level.end())
+ return 0;
+ else
+ return (*it).second;
+ }
+
+ void relateToOperator(const char* name, TOperator op);
+ void dump(TInfoSink &infoSink) const;
+ TSymbolTableLevel* clone(TStructureMap& remapper);
+
+protected:
+ typedef std::map<TString, TSymbol*, std::less<TString>, pool_allocator<std::pair<const TString, TSymbol*> > > tLevel;
+ typedef const tLevel::value_type tLevelPair;
+ typedef std::pair<tLevel::iterator, bool> tInsertResult;
+
+ tLevel level;
+};
+
+class TSymbolTable {
+public:
+ TSymbolTable() : uniqueId(0)
+ {
+ //
+ // The symbol table cannot be used until push() is called, but
+ // the lack of an initial call to push() can be used to detect
+ // that the symbol table has not been preloaded with built-ins.
+ //
+ }
+
+ TSymbolTable(TSymbolTable& symTable)
+ {
+ table.push_back(symTable.table[0]);
+ uniqueId = symTable.uniqueId;
+ }
+
+ ~TSymbolTable()
+ {
+ // level 0 is always built In symbols, so we never pop that out
+ while (table.size() > 1)
+ pop();
+ }
+
+ //
+ // When the symbol table is initialized with the built-ins, there should
+ // 'push' calls, so that built-ins are at level 0 and the shader
+ // globals are at level 1.
+ //
+ bool isEmpty() { return table.size() == 0; }
+ bool atBuiltInLevel() { return atSharedBuiltInLevel() || atDynamicBuiltInLevel(); }
+ bool atSharedBuiltInLevel() { return table.size() == 1; }
+ bool atGlobalLevel() { return table.size() <= 3; }
+ void push() {
+ table.push_back(new TSymbolTableLevel);
+ }
+
+ void pop() {
+ delete table[currentLevel()];
+ table.pop_back();
+ }
+
+ bool insert(TSymbol& symbol)
+ {
+ symbol.setUniqueId(++uniqueId);
+ return table[currentLevel()]->insert(symbol);
+ }
+
+ TSymbol* find(const TString& name, bool* builtIn = 0, bool *sameScope = 0)
+ {
+ int level = currentLevel();
+ TSymbol* symbol;
+ do {
+ symbol = table[level]->find(name);
+ --level;
+ } while (symbol == 0 && level >= 0);
+ level++;
+ if (builtIn)
+ *builtIn = level == 0;
+ if (sameScope)
+ *sameScope = level == currentLevel();
+ return symbol;
+ }
+
+ TSymbolTableLevel* getGlobalLevel() { assert (table.size() >= 3); return table[2]; }
+ void relateToOperator(const char* name, TOperator op) { table[0]->relateToOperator(name, op); }
+ int getMaxSymbolId() { return uniqueId; }
+ void dump(TInfoSink &infoSink) const;
+ void copyTable(const TSymbolTable& copyOf);
+
+protected:
+ int currentLevel() const { return static_cast<int>(table.size()) - 1; }
+ bool atDynamicBuiltInLevel() { return table.size() == 2; }
+
+ std::vector<TSymbolTableLevel*> table;
+ int uniqueId; // for unique identification in code generation
+};
+
+#endif // _SYMBOL_TABLE_INCLUDED_
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/glslang.l b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/glslang.l
new file mode 100644
index 000000000..f6cd3ca66
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/glslang.l
@@ -0,0 +1,614 @@
+/*
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+*/
+/* Based on
+ANSI C grammar, Lex specification
+
+In 1985, Jeff Lee published this Lex specification together with a Yacc
+grammar for the April 30, 1985 ANSI C draft. Tom Stockfisch reposted
+both to net.sources in 1987; that original, as mentioned in the answer
+to question 17.25 of the comp.lang.c FAQ, can be ftp'ed from ftp.uu.net,
+file usenet/net.sources/ansi.c.grammar.Z.
+
+I intend to keep this version as close to the current C Standard grammar
+as possible; please let me know if you discover discrepancies.
+
+Jutta Degener, 1995
+*/
+
+D [0-9]
+L [a-zA-Z_]
+H [a-fA-F0-9]
+E [Ee][+-]?{D}+
+O [0-7]
+
+%option nounput
+%{
+#include <stdio.h>
+#include <stdlib.h>
+#include "ParseHelper.h"
+#include "glslang_tab.h"
+
+/* windows only pragma */
+#ifdef _MSC_VER
+#pragma warning(disable : 4102)
+#endif
+
+int yy_input(char* buf, int max_size);
+TSourceLoc yylineno;
+
+#ifdef _WIN32
+ extern int yyparse(TParseContext&);
+ #define YY_DECL int yylex(YYSTYPE* pyylval, TParseContext& parseContext)
+#else
+ extern int yyparse(void*);
+ #define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)
+ #define parseContext (*((TParseContext*)(parseContextLocal)))
+#endif
+
+#define YY_INPUT(buf,result,max_size) (result = yy_input(buf, max_size))
+
+%}
+
+%option noyywrap
+%option never-interactive
+%option outfile="Gen_glslang.cpp"
+%x FIELDS
+
+
+%%
+<*>"//"[^\n]*"\n" { /* ?? carriage and/or line-feed? */ };
+
+"attribute" { pyylval->lex.line = yylineno; return(ATTRIBUTE); }
+"const" { pyylval->lex.line = yylineno; return(CONST_QUAL); }
+"uniform" { pyylval->lex.line = yylineno; return(UNIFORM); }
+"varying" { pyylval->lex.line = yylineno; return(VARYING); }
+
+"break" { pyylval->lex.line = yylineno; return(BREAK); }
+"continue" { pyylval->lex.line = yylineno; return(CONTINUE); }
+"do" { pyylval->lex.line = yylineno; return(DO); }
+"for" { pyylval->lex.line = yylineno; return(FOR); }
+"while" { pyylval->lex.line = yylineno; return(WHILE); }
+
+"if" { pyylval->lex.line = yylineno; return(IF); }
+"else" { pyylval->lex.line = yylineno; return(ELSE); }
+
+"in" { pyylval->lex.line = yylineno; return(IN_QUAL); }
+"out" { pyylval->lex.line = yylineno; return(OUT_QUAL); }
+"inout" { pyylval->lex.line = yylineno; return(INOUT_QUAL); }
+
+"float" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(FLOAT_TYPE); }
+"int" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(INT_TYPE); }
+"void" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(VOID_TYPE); }
+"bool" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(BOOL_TYPE); }
+"true" { pyylval->lex.line = yylineno; pyylval->lex.b = true; return(BOOLCONSTANT); }
+"false" { pyylval->lex.line = yylineno; pyylval->lex.b = false; return(BOOLCONSTANT); }
+
+"discard" { pyylval->lex.line = yylineno; return(DISCARD); }
+"return" { pyylval->lex.line = yylineno; return(RETURN); }
+
+"mat2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX2); }
+"mat3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX3); }
+"mat4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return(MATRIX4); }
+
+"vec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC2); }
+"vec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC3); }
+"vec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (VEC4); }
+"ivec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC2); }
+"ivec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC3); }
+"ivec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (IVEC4); }
+"bvec2" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC2); }
+"bvec3" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC3); }
+"bvec4" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return (BVEC4); }
+
+"sampler1D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1D; }
+"sampler2D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2D; }
+"sampler3D" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER3D; }
+"samplerCube" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLERCUBE; }
+"sampler1DShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER1DSHADOW; }
+"sampler2DShadow" { pyylval->lex.line = yylineno; parseContext.lexAfterType = true; return SAMPLER2DSHADOW; }
+
+"struct" { pyylval->lex.line = yylineno; return(STRUCT); }
+
+"asm" { PaReservedWord(); return 0; }
+
+"class" { PaReservedWord(); return 0; }
+"union" { PaReservedWord(); return 0; }
+"enum" { PaReservedWord(); return 0; }
+"typedef" { PaReservedWord(); return 0; }
+"template" { PaReservedWord(); return 0; }
+"this" { PaReservedWord(); return 0; }
+"packed" { PaReservedWord(); return 0; }
+
+"goto" { PaReservedWord(); return 0; }
+"switch" { PaReservedWord(); return 0; }
+"default" { PaReservedWord(); return 0; }
+
+"inline" { PaReservedWord(); return 0; }
+"noinline" { PaReservedWord(); return 0; }
+"volatile" { PaReservedWord(); return 0; }
+"public" { PaReservedWord(); return 0; }
+"static" { PaReservedWord(); return 0; }
+"extern" { PaReservedWord(); return 0; }
+"external" { PaReservedWord(); return 0; }
+"interface" { PaReservedWord(); return 0; }
+
+"long" { PaReservedWord(); return 0; }
+"short" { PaReservedWord(); return 0; }
+"double" { PaReservedWord(); return 0; }
+"half" { PaReservedWord(); return 0; }
+"fixed" { PaReservedWord(); return 0; }
+"unsigned" { PaReservedWord(); return 0; }
+
+"input" { PaReservedWord(); return 0; }
+"output" { PaReservedWord(); return 0; }
+
+"hvec2" { PaReservedWord(); return 0; }
+"hvec3" { PaReservedWord(); return 0; }
+"hvec4" { PaReservedWord(); return 0; }
+"fvec2" { PaReservedWord(); return 0; }
+"fvec3" { PaReservedWord(); return 0; }
+"fvec4" { PaReservedWord(); return 0; }
+"dvec2" { PaReservedWord(); return 0; }
+"dvec3" { PaReservedWord(); return 0; }
+"dvec4" { PaReservedWord(); return 0; }
+
+"sampler2DRect" { PaReservedWord(); return 0; }
+"sampler3DRect" { PaReservedWord(); return 0; }
+"sampler2DRectShadow" { PaReservedWord(); return 0; }
+
+"sizeof" { PaReservedWord(); return 0; }
+"cast" { PaReservedWord(); return 0; }
+
+"namespace" { PaReservedWord(); return 0; }
+"using" { PaReservedWord(); return 0; }
+
+{L}({L}|{D})* {
+ pyylval->lex.line = yylineno;
+ pyylval->lex.string = NewPoolTString(yytext);
+ return PaIdentOrType(*pyylval->lex.string, parseContext, pyylval->lex.symbol);
+}
+
+0[xX]{H}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
+0{O}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
+0{D}+ { pyylval->lex.line = yylineno; parseContext.error(yylineno, "Invalid Octal number.", yytext, "", ""); parseContext.recover(); return 0;}
+{D}+ { pyylval->lex.line = yylineno; pyylval->lex.i = strtol(yytext, 0, 0); return(INTCONSTANT); }
+
+{D}+{E} { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }
+{D}+"."{D}*({E})? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }
+"."{D}+({E})? { pyylval->lex.line = yylineno; pyylval->lex.f = static_cast<float>(atof(yytext)); return(FLOATCONSTANT); }
+
+"/*" { int ret = PaParseComment(pyylval->lex.line, parseContext); if (!ret) return ret; }
+
+"+=" { pyylval->lex.line = yylineno; return(ADD_ASSIGN); }
+"-=" { pyylval->lex.line = yylineno; return(SUB_ASSIGN); }
+"*=" { pyylval->lex.line = yylineno; return(MUL_ASSIGN); }
+"/=" { pyylval->lex.line = yylineno; return(DIV_ASSIGN); }
+"%=" { pyylval->lex.line = yylineno; return(MOD_ASSIGN); }
+"<<=" { pyylval->lex.line = yylineno; return(LEFT_ASSIGN); }
+">>=" { pyylval->lex.line = yylineno; return(RIGHT_ASSIGN); }
+"&=" { pyylval->lex.line = yylineno; return(AND_ASSIGN); }
+"^=" { pyylval->lex.line = yylineno; return(XOR_ASSIGN); }
+"|=" { pyylval->lex.line = yylineno; return(OR_ASSIGN); }
+
+"++" { pyylval->lex.line = yylineno; return(INC_OP); }
+"--" { pyylval->lex.line = yylineno; return(DEC_OP); }
+"&&" { pyylval->lex.line = yylineno; return(AND_OP); }
+"||" { pyylval->lex.line = yylineno; return(OR_OP); }
+"^^" { pyylval->lex.line = yylineno; return(XOR_OP); }
+"<=" { pyylval->lex.line = yylineno; return(LE_OP); }
+">=" { pyylval->lex.line = yylineno; return(GE_OP); }
+"==" { pyylval->lex.line = yylineno; return(EQ_OP); }
+"!=" { pyylval->lex.line = yylineno; return(NE_OP); }
+"<<" { pyylval->lex.line = yylineno; return(LEFT_OP); }
+">>" { pyylval->lex.line = yylineno; return(RIGHT_OP); }
+";" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(SEMICOLON); }
+("{"|"<%") { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(LEFT_BRACE); }
+("}"|"%>") { pyylval->lex.line = yylineno; return(RIGHT_BRACE); }
+"," { pyylval->lex.line = yylineno; if (parseContext.inTypeParen) parseContext.lexAfterType = false; return(COMMA); }
+":" { pyylval->lex.line = yylineno; return(COLON); }
+"=" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; return(EQUAL); }
+"(" { pyylval->lex.line = yylineno; parseContext.lexAfterType = false; parseContext.inTypeParen = true; return(LEFT_PAREN); }
+")" { pyylval->lex.line = yylineno; parseContext.inTypeParen = false; return(RIGHT_PAREN); }
+("["|"<:") { pyylval->lex.line = yylineno; return(LEFT_BRACKET); }
+("]"|":>") { pyylval->lex.line = yylineno; return(RIGHT_BRACKET); }
+"." { BEGIN(FIELDS); return(DOT); }
+"!" { pyylval->lex.line = yylineno; return(BANG); }
+"-" { pyylval->lex.line = yylineno; return(DASH); }
+"~" { pyylval->lex.line = yylineno; return(TILDE); }
+"+" { pyylval->lex.line = yylineno; return(PLUS); }
+"*" { pyylval->lex.line = yylineno; return(STAR); }
+"/" { pyylval->lex.line = yylineno; return(SLASH); }
+"%" { pyylval->lex.line = yylineno; return(PERCENT); }
+"<" { pyylval->lex.line = yylineno; return(LEFT_ANGLE); }
+">" { pyylval->lex.line = yylineno; return(RIGHT_ANGLE); }
+"|" { pyylval->lex.line = yylineno; return(VERTICAL_BAR); }
+"^" { pyylval->lex.line = yylineno; return(CARET); }
+"&" { pyylval->lex.line = yylineno; return(AMPERSAND); }
+"?" { pyylval->lex.line = yylineno; return(QUESTION); }
+
+<FIELDS>{L}({L}|{D})* {
+BEGIN(INITIAL);
+ pyylval->lex.line = yylineno;
+ pyylval->lex.string = NewPoolTString(yytext);
+ return FIELD_SELECTION; }
+<FIELDS>[ \t\v\f\r] {}
+
+[ \t\v\n\f\r] { }
+<*><<EOF>> { (&parseContext)->AfterEOF = true; yy_delete_buffer(YY_CURRENT_BUFFER); yyterminate();}
+<*>. { parseContext.infoSink.info << "FLEX: Unknown char " << yytext << "\n";
+ return 0; }
+
+%%
+
+
+//Including Pre-processor.
+extern "C" {
+ #include "./preprocessor/preprocess.h"
+}
+
+//
+// The YY_INPUT macro just calls this. Maybe this could be just put into
+// the macro directly.
+//
+
+int yy_input(char* buf, int max_size)
+{
+ char *char_token =NULL;
+ int len;
+
+ if ((len = yylex_CPP(buf, max_size)) == 0)
+ return 0;
+ if (len >= max_size)
+ YY_FATAL_ERROR( "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
+
+ buf[len] = ' ';
+ return len+1;
+}
+
+
+//
+// Parse an array of strings using yyparse. We set up globals used by
+// yywrap.
+//
+// Returns 0 for success, as per yyparse().
+//
+int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext& parseContextLocal)
+{
+ int argv0len;
+ ScanFromString(argv[0]);
+
+ //Storing the Current Compiler Parse context into the cpp structure.
+ cpp->pC = (void*)&parseContextLocal;
+
+ if (!argv || argc == 0 || !argv[0])
+ return 1;
+
+ if (!strLen) {
+ argv0len = (int) strlen(argv[0]);
+ strLen = &argv0len;
+ }
+ yyrestart(0);
+ (&parseContextLocal)->AfterEOF = false;
+ cpp->PaWhichStr = 0;
+ cpp->PaArgv = argv;
+ cpp->PaArgc = argc;
+ cpp->PaStrLen = strLen;
+ yylineno = 1;
+
+ if (*cpp->PaStrLen >= 0) {
+ int ret;
+ #ifdef _WIN32
+ ret = yyparse(parseContextLocal);
+ #else
+ ret = yyparse((void*)(&parseContextLocal));
+ #endif
+ if (cpp->CompileError == 1 || parseContextLocal.recoveredFromError || parseContextLocal.numErrors > 0)
+ return 1;
+ else
+ return 0;
+ }
+ else
+ return 0;
+}
+
+void yyerror(char *s)
+{
+ if (((TParseContext *)cpp->pC)->AfterEOF) {
+ if (cpp->tokensBeforeEOF == 1) {
+ GlobalParseContext->error(yylineno, "syntax error", "pre-mature EOF", s, "");
+ GlobalParseContext->recover();
+ }
+ } else {
+ GlobalParseContext->error(yylineno, "syntax error", yytext, s, "");
+ GlobalParseContext->recover();
+ }
+}
+
+void PaReservedWord()
+{
+ GlobalParseContext->error(yylineno, "Reserved word.", yytext, "", "");
+ GlobalParseContext->recover();
+}
+
+int PaIdentOrType(TString& id, TParseContext& parseContextLocal, TSymbol*& symbol)
+{
+ symbol = parseContextLocal.symbolTable.find(id);
+ if (parseContextLocal.lexAfterType == false && symbol && symbol->isVariable()) {
+ TVariable* variable = static_cast<TVariable*>(symbol);
+ if (variable->isUserType()) {
+ parseContextLocal.lexAfterType = true;
+ return TYPE_NAME;
+ }
+ }
+
+ return IDENTIFIER;
+}
+
+int PaParseComment(int &lineno, TParseContext& parseContextLocal)
+{
+ int transitionFlag = 0;
+ int nextChar;
+
+ while (transitionFlag != 2) {
+ nextChar = yyinput();
+ if (nextChar == '\n')
+ lineno++;
+ switch (nextChar) {
+ case '*' :
+ transitionFlag = 1;
+ break;
+ case '/' : /* if star is the previous character, then it is the end of comment */
+ if (transitionFlag == 1) {
+ return 1 ;
+ }
+ break;
+ case EOF :
+ /* Raise error message here */
+ parseContextLocal.error(yylineno, "End of shader found before end of comment.", "", "", "");
+ GlobalParseContext->recover();
+ return YY_NULL;
+ default : /* Any other character will be a part of the comment */
+ transitionFlag = 0;
+ }
+ }
+ return 1;
+}
+
+extern "C" {
+
+void CPPDebugLogMsg(const char *msg)
+{
+ ((TParseContext *)cpp->pC)->infoSink.debug.message(EPrefixNone, msg);
+}
+
+void CPPWarningToInfoLog(const char *msg)
+{
+ ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg, yylineno);
+}
+
+void CPPShInfoLogMsg(const char *msg)
+{
+ ((TParseContext *)cpp->pC)->error(yylineno,"", "",msg,"");
+ GlobalParseContext->recover();
+}
+
+void CPPErrorToInfoLog(char *msg)
+{
+ ((TParseContext *)cpp->pC)->error(yylineno,"syntax error", "",msg,"");
+ GlobalParseContext->recover();
+}
+
+void SetLineNumber(int line)
+{
+ yylineno &= ~SourceLocLineMask;
+ yylineno |= line;
+}
+
+void SetStringNumber(int string)
+{
+ yylineno = (string << SourceLocStringShift) | (yylineno & SourceLocLineMask);
+}
+
+int GetStringNumber(void)
+{
+ return yylineno >> 16;
+}
+
+int GetLineNumber(void)
+{
+ return yylineno & SourceLocLineMask;
+}
+
+void IncLineNumber(void)
+{
+ if ((yylineno & SourceLocLineMask) <= SourceLocLineMask)
+ ++yylineno;
+}
+
+void DecLineNumber(void)
+{
+ if ((yylineno & SourceLocLineMask) > 0)
+ --yylineno;
+}
+
+void HandlePragma(const char **tokens, int numTokens)
+{
+ if (!strcmp(tokens[0], "optimize")) {
+ if (numTokens != 4) {
+ CPPShInfoLogMsg("optimize pragma syntax is incorrect");
+ return;
+ }
+
+ if (strcmp(tokens[1], "(")) {
+ CPPShInfoLogMsg("\"(\" expected after 'optimize' keyword");
+ return;
+ }
+
+ if (!strcmp(tokens[2], "on"))
+ ((TParseContext *)cpp->pC)->contextPragma.optimize = true;
+ else if (!strcmp(tokens[2], "off"))
+ ((TParseContext *)cpp->pC)->contextPragma.optimize = false;
+ else {
+ CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'optimize' pragma");
+ return;
+ }
+
+ if (strcmp(tokens[3], ")")) {
+ CPPShInfoLogMsg("\")\" expected to end 'optimize' pragma");
+ return;
+ }
+ } else if (!strcmp(tokens[0], "debug")) {
+ if (numTokens != 4) {
+ CPPShInfoLogMsg("debug pragma syntax is incorrect");
+ return;
+ }
+
+ if (strcmp(tokens[1], "(")) {
+ CPPShInfoLogMsg("\"(\" expected after 'debug' keyword");
+ return;
+ }
+
+ if (!strcmp(tokens[2], "on"))
+ ((TParseContext *)cpp->pC)->contextPragma.debug = true;
+ else if (!strcmp(tokens[2], "off"))
+ ((TParseContext *)cpp->pC)->contextPragma.debug = false;
+ else {
+ CPPShInfoLogMsg("\"on\" or \"off\" expected after '(' for 'debug' pragma");
+ return;
+ }
+
+ if (strcmp(tokens[3], ")")) {
+ CPPShInfoLogMsg("\")\" expected to end 'debug' pragma");
+ return;
+ }
+ } else {
+ /*
+ // implementation specific pragma
+ // use ((TParseContext *)cpp->pC)->contextPragma.pragmaTable to store the information about pragma
+ // For now, just ignore the pragma that the implementation cannot recognize
+ // An Example of one such implementation for a pragma that has a syntax like
+ // #pragma pragmaname(pragmavalue)
+ // This implementation stores the current pragmavalue against the pragma name in pragmaTable.
+ if (numTokens == 4 && !strcmp(tokens[1], "(") && !strcmp(tokens[3], ")")) {
+ TPragmaTable& pragmaTable = ((TParseContext *)cpp->pC)->contextPragma.pragmaTable;
+ TPragmaTable::iterator iter;
+ iter = pragmaTable.find(TString(tokens[0]));
+ if (iter != pragmaTable.end()) {
+ iter->second = tokens[2];
+ } else {
+ pragmaTable[tokens[0]] = tokens[2];
+ }
+ }
+ */
+ }
+}
+
+void StoreStr(char *string)
+{
+ TString strSrc;
+ strSrc = TString(string);
+
+ ((TParseContext *)cpp->pC)->HashErrMsg = ((TParseContext *)cpp->pC)->HashErrMsg + " " + strSrc;
+}
+
+const char* GetStrfromTStr(void)
+{
+ cpp->ErrMsg = (((TParseContext *)cpp->pC)->HashErrMsg).c_str();
+ return cpp->ErrMsg;
+}
+
+void ResetTString(void)
+{
+ ((TParseContext *)cpp->pC)->HashErrMsg = "";
+}
+
+TBehavior GetBehavior(const char* behavior)
+{
+ if (!strcmp("require", behavior))
+ return EBhRequire;
+ else if (!strcmp("enable", behavior))
+ return EBhEnable;
+ else if (!strcmp("disable", behavior))
+ return EBhDisable;
+ else if (!strcmp("warn", behavior))
+ return EBhWarn;
+ else {
+ CPPShInfoLogMsg((TString("behavior '") + behavior + "' is not supported").c_str());
+ return EBhDisable;
+ }
+}
+
+void updateExtensionBehavior(const char* extName, const char* behavior)
+{
+ TBehavior behaviorVal = GetBehavior(behavior);
+ TMap<TString, TBehavior>:: iterator iter;
+ TString msg;
+
+ // special cased for all extension
+ if (!strcmp(extName, "all")) {
+ if (behaviorVal == EBhRequire || behaviorVal == EBhEnable) {
+ CPPShInfoLogMsg("extension 'all' cannot have 'require' or 'enable' behavior");
+ return;
+ } else {
+ for (iter = ((TParseContext *)cpp->pC)->extensionBehavior.begin(); iter != ((TParseContext *)cpp->pC)->extensionBehavior.end(); ++iter)
+ iter->second = behaviorVal;
+ }
+ } else {
+ iter = ((TParseContext *)cpp->pC)->extensionBehavior.find(TString(extName));
+ if (iter == ((TParseContext *)cpp->pC)->extensionBehavior.end()) {
+ switch (behaviorVal) {
+ case EBhRequire:
+ CPPShInfoLogMsg((TString("extension '") + extName + "' is not supported").c_str());
+ break;
+ case EBhEnable:
+ case EBhWarn:
+ case EBhDisable:
+ msg = TString("extension '") + extName + "' is not supported";
+ ((TParseContext *)cpp->pC)->infoSink.info.message(EPrefixWarning, msg.c_str(), yylineno);
+ break;
+ }
+ return;
+ } else
+ iter->second = behaviorVal;
+ }
+}
+
+}
+
+void setInitialState()
+{
+ yy_start = 1;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/glslang.y b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/glslang.y
new file mode 100644
index 000000000..d2dc1db37
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/glslang.y
@@ -0,0 +1,2009 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+/**
+ * This is bison grammar and production code for parsing the OpenGL 2.0 shading
+ * languages.
+ */
+%{
+
+/* Based on:
+ANSI C Yacc grammar
+
+In 1985, Jeff Lee published his Yacc grammar (which is accompanied by a
+matching Lex specification) for the April 30, 1985 draft version of the
+ANSI C standard. Tom Stockfisch reposted it to net.sources in 1987; that
+original, as mentioned in the answer to question 17.25 of the comp.lang.c
+FAQ, can be ftp'ed from ftp.uu.net, file usenet/net.sources/ansi.c.grammar.Z.
+
+I intend to keep this version as close to the current C Standard grammar as
+possible; please let me know if you discover discrepancies.
+
+Jutta Degener, 1995
+*/
+
+#include "SymbolTable.h"
+#include "ParseHelper.h"
+#include "../Public/ShaderLang.h"
+
+#ifdef _WIN32
+ #define YYPARSE_PARAM parseContext
+ #define YYPARSE_PARAM_DECL TParseContext&
+ #define YY_DECL int yylex(YYSTYPE* pyylval, TParseContext& parseContext)
+ #define YYLEX_PARAM parseContext
+#else
+ #define YYPARSE_PARAM parseContextLocal
+ #define parseContext (*((TParseContext*)(parseContextLocal)))
+ #define YY_DECL int yylex(YYSTYPE* pyylval, void* parseContextLocal)
+ #define YYLEX_PARAM (void*)(parseContextLocal)
+ extern void yyerror(char*);
+#endif
+
+#define FRAG_VERT_ONLY(S, L) { \
+ if (parseContext.language != EShLangFragment && \
+ parseContext.language != EShLangVertex) { \
+ parseContext.error(L, " supported in vertex/fragment shaders only ", S, "", ""); \
+ parseContext.recover(); \
+ } \
+}
+
+#define VERTEX_ONLY(S, L) { \
+ if (parseContext.language != EShLangVertex) { \
+ parseContext.error(L, " supported in vertex shaders only ", S, "", ""); \
+ parseContext.recover(); \
+ } \
+}
+
+#define FRAG_ONLY(S, L) { \
+ if (parseContext.language != EShLangFragment) { \
+ parseContext.error(L, " supported in fragment shaders only ", S, "", ""); \
+ parseContext.recover(); \
+ } \
+}
+
+#define PACK_ONLY(S, L) { \
+ if (parseContext.language != EShLangPack) { \
+ parseContext.error(L, " supported in pack shaders only ", S, "", ""); \
+ parseContext.recover(); \
+ } \
+}
+
+#define UNPACK_ONLY(S, L) { \
+ if (parseContext.language != EShLangUnpack) { \
+ parseContext.error(L, " supported in unpack shaders only ", S, "", ""); \
+ parseContext.recover(); \
+ } \
+}
+
+#define PACK_UNPACK_ONLY(S, L) { \
+ if (parseContext.language != EShLangUnpack && \
+ parseContext.language != EShLangPack) { \
+ parseContext.error(L, " supported in pack/unpack shaders only ", S, "", ""); \
+ parseContext.recover(); \
+ } \
+}
+%}
+%union {
+ struct {
+ TSourceLoc line;
+ union {
+ TString *string;
+ float f;
+ int i;
+ bool b;
+ };
+ TSymbol* symbol;
+ } lex;
+ struct {
+ TSourceLoc line;
+ TOperator op;
+ union {
+ TIntermNode* intermNode;
+ TIntermNodePair nodePair;
+ TIntermTyped* intermTypedNode;
+ TIntermAggregate* intermAggregate;
+ };
+ union {
+ TPublicType type;
+ TQualifier qualifier;
+ TFunction* function;
+ TParameter param;
+ TTypeLine typeLine;
+ TTypeList* typeList;
+ };
+ } interm;
+}
+
+%{
+#ifndef _WIN32
+ extern int yylex(YYSTYPE*, void*);
+#endif
+%}
+
+%pure_parser /* Just in case is called from multiple threads */
+%expect 1 /* One shift reduce conflict because of if | else */
+%token <lex> ATTRIBUTE CONST_QUAL BOOL_TYPE FLOAT_TYPE INT_TYPE
+%token <lex> BREAK CONTINUE DO ELSE FOR IF DISCARD RETURN
+%token <lex> BVEC2 BVEC3 BVEC4 IVEC2 IVEC3 IVEC4 VEC2 VEC3 VEC4
+%token <lex> MATRIX2 MATRIX3 MATRIX4 IN_QUAL OUT_QUAL INOUT_QUAL UNIFORM VARYING
+%token <lex> STRUCT VOID_TYPE WHILE
+%token <lex> SAMPLER1D SAMPLER2D SAMPLER3D SAMPLERCUBE SAMPLER1DSHADOW SAMPLER2DSHADOW
+
+%token <lex> IDENTIFIER TYPE_NAME FLOATCONSTANT INTCONSTANT BOOLCONSTANT
+%token <lex> FIELD_SELECTION
+%token <lex> LEFT_OP RIGHT_OP
+%token <lex> INC_OP DEC_OP LE_OP GE_OP EQ_OP NE_OP
+%token <lex> AND_OP OR_OP XOR_OP MUL_ASSIGN DIV_ASSIGN ADD_ASSIGN
+%token <lex> MOD_ASSIGN LEFT_ASSIGN RIGHT_ASSIGN AND_ASSIGN XOR_ASSIGN OR_ASSIGN
+%token <lex> SUB_ASSIGN
+
+%token <lex> LEFT_PAREN RIGHT_PAREN LEFT_BRACKET RIGHT_BRACKET LEFT_BRACE RIGHT_BRACE DOT
+%token <lex> COMMA COLON EQUAL SEMICOLON BANG DASH TILDE PLUS STAR SLASH PERCENT
+%token <lex> LEFT_ANGLE RIGHT_ANGLE VERTICAL_BAR CARET AMPERSAND QUESTION
+
+%type <interm> assignment_operator constructor_identifier unary_operator
+%type <interm.intermTypedNode> variable_identifier primary_expression postfix_expression
+%type <interm.intermTypedNode> expression integer_expression assignment_expression
+%type <interm.intermTypedNode> unary_expression multiplicative_expression additive_expression
+%type <interm.intermTypedNode> relational_expression equality_expression
+%type <interm.intermTypedNode> conditional_expression constant_expression
+%type <interm.intermTypedNode> logical_or_expression logical_xor_expression logical_and_expression
+%type <interm.intermTypedNode> shift_expression and_expression exclusive_or_expression inclusive_or_expression
+%type <interm.intermTypedNode> function_call initializer condition conditionopt
+
+%type <interm.intermNode> translation_unit function_definition
+%type <interm.intermNode> statement simple_statement
+%type <interm.intermAggregate> statement_list compound_statement
+%type <interm.intermNode> declaration_statement selection_statement expression_statement
+%type <interm.intermNode> declaration external_declaration
+%type <interm.intermNode> for_init_statement compound_statement_no_new_scope
+%type <interm.nodePair> selection_rest_statement for_rest_statement
+%type <interm.intermNode> iteration_statement jump_statement statement_no_new_scope
+%type <interm> single_declaration init_declarator_list
+
+%type <interm> parameter_declaration parameter_declarator parameter_type_specifier
+%type <interm.qualifier> parameter_qualifier
+
+%type <interm.type> type_qualifier fully_specified_type type_specifier
+%type <interm.type> struct_specifier
+%type <interm.typeLine> struct_declarator
+%type <interm.typeList> struct_declarator_list struct_declaration struct_declaration_list
+%type <interm.function> function_header function_declarator function_identifier
+%type <interm.function> function_header_with_parameters function_call_header
+%type <interm> function_call_header_with_parameters function_call_header_no_parameters function_call_generic function_prototype
+
+%start translation_unit
+%%
+
+variable_identifier
+ : IDENTIFIER {
+ // The symbol table search was done in the lexical phase
+ const TSymbol* symbol = $1.symbol;
+ const TVariable* variable;
+ if (symbol == 0) {
+ parseContext.error($1.line, "undeclared identifier", $1.string->c_str(), "");
+ parseContext.recover();
+ TType type(EbtFloat);
+ TVariable* fakeVariable = new TVariable($1.string, type);
+ parseContext.symbolTable.insert(*fakeVariable);
+ variable = fakeVariable;
+ } else {
+ // This identifier can only be a variable type symbol
+ if (! symbol->isVariable()) {
+ parseContext.error($1.line, "variable expected", $1.string->c_str(), "");
+ parseContext.recover();
+ }
+ variable = static_cast<const TVariable*>(symbol);
+ }
+
+ // don't delete $1.string, it's used by error recovery, and the pool
+ // pop will reclaim the memory
+
+ if (variable->getType().getQualifier() == EvqConst ) {
+ constUnion* constArray = variable->getConstPointer();
+ TType t(variable->getType());
+ $$ = parseContext.intermediate.addConstantUnion(constArray, t, $1.line);
+ } else
+ $$ = parseContext.intermediate.addSymbol(variable->getUniqueId(),
+ variable->getName(),
+ variable->getType(), $1.line);
+ }
+ ;
+
+primary_expression
+ : variable_identifier {
+ $$ = $1;
+ }
+ | INTCONSTANT {
+ //
+ // INT_TYPE is only 16-bit plus sign bit for vertex/fragment shaders,
+ // check for overflow for constants
+ //
+ if (abs($1.i) >= (1 << 16)) {
+ parseContext.error($1.line, " integer constant overflow", "", "");
+ parseContext.recover();
+ }
+ constUnion *unionArray = new constUnion[1];
+ unionArray->iConst = $1.i;
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $1.line);
+ }
+ | FLOATCONSTANT {
+ constUnion *unionArray = new constUnion[1];
+ unionArray->fConst = $1.f;
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.line);
+ }
+ | BOOLCONSTANT {
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = $1.b;
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $1.line);
+ }
+ | LEFT_PAREN expression RIGHT_PAREN {
+ $$ = $2;
+ }
+ ;
+
+postfix_expression
+ : primary_expression {
+ $$ = $1;
+ }
+ | postfix_expression LEFT_BRACKET integer_expression RIGHT_BRACKET {
+ if (!$1->isArray() && !$1->isMatrix() && !$1->isVector()) {
+ if ($1->getAsSymbolNode())
+ parseContext.error($2.line, " left of '[' is not of type array, matrix, or vector ", $1->getAsSymbolNode()->getSymbol().c_str(), "");
+ else
+ parseContext.error($2.line, " left of '[' is not of type array, matrix, or vector ", "expression", "");
+ parseContext.recover();
+ }
+ if ($1->getType().getQualifier() == EvqConst && !$1->isArray() && $3->getQualifier() == EvqConst) {
+ if ($1->isVector()) { // constant folding for vectors
+ TVectorFields fields;
+ fields.num = 1;
+ fields.offsets[0] = $3->getAsConstantUnion()->getUnionArrayPointer()->iConst; // need to do it this way because v.xy sends fields integer array
+ $$ = parseContext.addConstVectorNode(fields, $1, $2.line);
+ } else if ($1->isMatrix()) { // constant folding for matrices
+ $$ = parseContext.addConstMatrixNode($3->getAsConstantUnion()->getUnionArrayPointer()->iConst, $1, $2.line);
+ }
+ } else {
+ if ($3->getQualifier() == EvqConst) {
+ if (($1->isVector() || $1->isMatrix()) && $1->getType().getNominalSize() <= $3->getAsConstantUnion()->getUnionArrayPointer()->iConst && !$1->isArray() ) {
+ parseContext.error($2.line, "", "[", "field selection out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->iConst);
+ parseContext.recover();
+ } else {
+ if ($1->isArray()) {
+ if ($1->getType().getArraySize() == 0) {
+ if ($1->getType().getMaxArraySize() <= $3->getAsConstantUnion()->getUnionArrayPointer()->iConst) {
+ if (parseContext.arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), $3->getAsConstantUnion()->getUnionArrayPointer()->iConst, true, $2.line))
+ parseContext.recover();
+ } else {
+ if (parseContext.arraySetMaxSize($1->getAsSymbolNode(), $1->getTypePointer(), 0, false, $2.line))
+ parseContext.recover();
+ }
+ } else if ( $3->getAsConstantUnion()->getUnionArrayPointer()->iConst >= $1->getType().getArraySize()) {
+ parseContext.error($2.line, "", "[", "array index out of range '%d'", $3->getAsConstantUnion()->getUnionArrayPointer()->iConst);
+ parseContext.recover();
+ }
+ }
+ $$ = parseContext.intermediate.addIndex(EOpIndexDirect, $1, $3, $2.line);
+ }
+ } else {
+ if ($1->isArray() && $1->getType().getArraySize() == 0) {
+ parseContext.error($2.line, "", "[", "array must be redeclared with a size before being indexed with a variable");
+ parseContext.recover();
+ }
+
+ $$ = parseContext.intermediate.addIndex(EOpIndexIndirect, $1, $3, $2.line);
+ }
+ }
+ if ($$ == 0) {
+ constUnion *unionArray = new constUnion[1];
+ unionArray->fConst = 0.0;
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $2.line);
+ } else if ($1->isArray()) {
+ if ($1->getType().getStruct())
+ $$->setType(TType($1->getType().getStruct(), $1->getType().getTypeName()));
+ else
+ $$->setType(TType($1->getBasicType(), EvqTemporary, $1->getNominalSize(), $1->isMatrix()));
+ } else if ($1->isMatrix() && $1->getType().getQualifier() == EvqConst)
+ $$->setType(TType($1->getBasicType(), EvqConst, $1->getNominalSize()));
+ else if ($1->isMatrix())
+ $$->setType(TType($1->getBasicType(), EvqTemporary, $1->getNominalSize()));
+ else if ($1->isVector() && $1->getType().getQualifier() == EvqConst)
+ $$->setType(TType($1->getBasicType(), EvqConst));
+ else if ($1->isVector())
+ $$->setType(TType($1->getBasicType(), EvqTemporary));
+ else
+ $$->setType($1->getType());
+ }
+ | function_call {
+ $$ = $1;
+ }
+ | postfix_expression DOT FIELD_SELECTION {
+ if ($1->isArray()) {
+ parseContext.error($3.line, "cannot apply dot operator to an array", ".", "");
+ parseContext.recover();
+ }
+
+ if ($1->isVector()) {
+ TVectorFields fields;
+ if (! parseContext.parseVectorFields(*$3.string, $1->getNominalSize(), fields, $3.line)) {
+ fields.num = 1;
+ fields.offsets[0] = 0;
+ parseContext.recover();
+ }
+
+ if ($1->getType().getQualifier() == EvqConst) { // constant folding for vector fields
+ $$ = parseContext.addConstVectorNode(fields, $1, $3.line);
+ if ($$ == 0) {
+ parseContext.recover();
+ $$ = $1;
+ }
+ else
+ $$->setType(TType($1->getBasicType(), EvqConst, (int) (*$3.string).size()));
+ } else {
+ if (fields.num == 1) {
+ constUnion *unionArray = new constUnion[1];
+ unionArray->iConst = fields.offsets[0];
+ TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $3.line);
+ $$ = parseContext.intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
+ $$->setType(TType($1->getBasicType()));
+ } else {
+ TString vectorString = *$3.string;
+ TIntermTyped* index = parseContext.intermediate.addSwizzle(fields, $3.line);
+ $$ = parseContext.intermediate.addIndex(EOpVectorSwizzle, $1, index, $2.line);
+ $$->setType(TType($1->getBasicType(),EvqTemporary, (int) vectorString.size()));
+ }
+ }
+ } else if ($1->isMatrix()) {
+ TMatrixFields fields;
+ if (! parseContext.parseMatrixFields(*$3.string, $1->getNominalSize(), fields, $3.line)) {
+ fields.wholeRow = false;
+ fields.wholeCol = false;
+ fields.row = 0;
+ fields.col = 0;
+ parseContext.recover();
+ }
+
+ if (fields.wholeRow || fields.wholeCol) {
+ parseContext.error($2.line, " non-scalar fields not implemented yet", ".", "");
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->iConst = 0;
+ TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $3.line);
+ $$ = parseContext.intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
+ $$->setType(TType($1->getBasicType(), EvqTemporary, $1->getNominalSize()));
+ } else {
+ constUnion *unionArray = new constUnion[1];
+ unionArray->iConst = fields.col * $1->getNominalSize() + fields.row;
+ TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $3.line);
+ $$ = parseContext.intermediate.addIndex(EOpIndexDirect, $1, index, $2.line);
+ $$->setType(TType($1->getBasicType()));
+ }
+ } else if ($1->getBasicType() == EbtStruct) {
+ bool fieldFound = false;
+ TTypeList* fields = $1->getType().getStruct();
+ if (fields == 0) {
+ parseContext.error($2.line, "structure has no fields", "Internal Error", "");
+ parseContext.recover();
+ $$ = $1;
+ } else {
+ unsigned int i;
+ for (i = 0; i < fields->size(); ++i) {
+ if ((*fields)[i].type->getFieldName() == *$3.string) {
+ fieldFound = true;
+ break;
+ }
+ }
+ if (fieldFound) {
+ if ($1->getType().getQualifier() == EvqConst) {
+ $$ = parseContext.addConstStruct(*$3.string, $1, $2.line);
+ if ($$ == 0) {
+ parseContext.recover();
+ $$ = $1;
+ }
+ else {
+ $$->setType(*(*fields)[i].type);
+ // change the qualifier of the return type, not of the structure field
+ // as the structure definition is shared between various structures.
+ $$->getTypePointer()->changeQualifier(EvqConst);
+ }
+ } else {
+ constUnion *unionArray = new constUnion[1];
+ unionArray->iConst = i;
+ TIntermTyped* index = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $3.line);
+ $$ = parseContext.intermediate.addIndex(EOpIndexDirectStruct, $1, index, $2.line);
+ $$->setType(*(*fields)[i].type);
+ }
+ } else {
+ parseContext.error($2.line, " no such field in structure", $3.string->c_str(), "");
+ parseContext.recover();
+ $$ = $1;
+ }
+ }
+ } else {
+ parseContext.error($2.line, " field selection requires structure, vector, or matrix on left hand side", $3.string->c_str(), "");
+ parseContext.recover();
+ $$ = $1;
+ }
+ // don't delete $3.string, it's from the pool
+ }
+ | postfix_expression INC_OP {
+ if (parseContext.lValueErrorCheck($2.line, "++", $1))
+ parseContext.recover();
+ $$ = parseContext.intermediate.addUnaryMath(EOpPostIncrement, $1, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.unaryOpError($2.line, "++", $1->getCompleteString());
+ parseContext.recover();
+ $$ = $1;
+ }
+ }
+ | postfix_expression DEC_OP {
+ if (parseContext.lValueErrorCheck($2.line, "--", $1))
+ parseContext.recover();
+ $$ = parseContext.intermediate.addUnaryMath(EOpPostDecrement, $1, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.unaryOpError($2.line, "--", $1->getCompleteString());
+ parseContext.recover();
+ $$ = $1;
+ }
+ }
+ ;
+
+integer_expression
+ : expression {
+ if (parseContext.integerErrorCheck($1, "[]"))
+ parseContext.recover();
+ $$ = $1;
+ }
+ ;
+
+function_call
+ : function_call_generic {
+ TFunction* fnCall = $1.function;
+ TOperator op = fnCall->getBuiltInOp();
+
+ if (op != EOpNull) {
+ //
+ // Then this should be a constructor.
+ //
+ TType type(EbtVoid); // use this to get the type back
+ if (parseContext.constructorErrorCheck($1.line, $1.intermNode, *fnCall, op, &type)) {
+ $$ = 0;
+ } else {
+ //
+ // It's a constructor, of type 'type'.
+ //
+ $$ = parseContext.addConstructor($1.intermNode, &type, op, fnCall, $1.line);
+ }
+
+ if ($$ == 0) {
+ parseContext.recover();
+ $$ = parseContext.intermediate.setAggregateOperator(0, op, $1.line);
+ }
+ $$->setType(type);
+ } else {
+ //
+ // Not a constructor. Find it in the symbol table.
+ //
+ const TFunction* fnCandidate;
+ bool builtIn;
+ fnCandidate = parseContext.findFunction($1.line, fnCall, &builtIn);
+ if (fnCandidate) {
+ //
+ // A declared function. But, it might still map to a built-in
+ // operation.
+ //
+ op = fnCandidate->getBuiltInOp();
+ if (builtIn && op != EOpNull) {
+ //
+ // A function call mapped to a built-in operation.
+ //
+ if (fnCandidate->getParamCount() == 1) {
+ //
+ // Treat it like a built-in unary operator.
+ //
+ $$ = parseContext.intermediate.addUnaryMath(op, $1.intermNode, 0, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.error($1.intermNode->getLine(), " wrong operand type", "Internal Error",
+ "built in unary operator function. Type: %s",
+ static_cast<TIntermTyped*>($1.intermNode)->getCompleteString().c_str());
+ YYERROR;
+ }
+ } else {
+ $$ = parseContext.intermediate.setAggregateOperator($1.intermAggregate, op, $1.line);
+ }
+ } else {
+ // This is a real function call
+
+ $$ = parseContext.intermediate.setAggregateOperator($1.intermAggregate, EOpFunctionCall, $1.line);
+ $$->setType(fnCandidate->getReturnType());
+
+ // this is how we know whether the given function is a builtIn function or a user defined function
+ // if builtIn == false, it's a userDefined -> could be an overloaded builtIn function also
+ // if builtIn == true, it's definitely a builtIn function with EOpNull
+ if (!builtIn)
+ $$->getAsAggregate()->setUserDefined();
+ $$->getAsAggregate()->setName(fnCandidate->getMangledName());
+
+ TQualifier qual;
+ TQualifierList& qualifierList = $$->getAsAggregate()->getQualifier();
+ for (int i = 0; i < fnCandidate->getParamCount(); ++i) {
+ qual = (*fnCandidate)[i].type->getQualifier();
+ if (qual == EvqOut || qual == EvqInOut) {
+ if (parseContext.lValueErrorCheck($$->getLine(), "assign", $$->getAsAggregate()->getSequence()[i]->getAsTyped())) {
+ parseContext.error($1.intermNode->getLine(), "Constant value cannot be passed for 'out' or 'inout' parameters.", "Error", "");
+ parseContext.recover();
+ }
+ }
+ qualifierList.push_back(qual);
+ }
+ }
+ $$->setType(fnCandidate->getReturnType());
+ } else {
+ // error message was put out by PaFindFunction()
+ // Put on a dummy node for error recovery
+ constUnion *unionArray = new constUnion[1];
+ unionArray->fConst = 0.0;
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.line);
+ parseContext.recover();
+ }
+ }
+ delete fnCall;
+ }
+ ;
+
+function_call_generic
+ : function_call_header_with_parameters RIGHT_PAREN {
+ $$ = $1;
+ $$.line = $2.line;
+ }
+ | function_call_header_no_parameters RIGHT_PAREN {
+ $$ = $1;
+ $$.line = $2.line;
+ }
+ ;
+
+function_call_header_no_parameters
+ : function_call_header VOID_TYPE {
+ $$.function = $1;
+ $$.intermNode = 0;
+ }
+ | function_call_header {
+ $$.function = $1;
+ $$.intermNode = 0;
+ }
+ ;
+
+function_call_header_with_parameters
+ : function_call_header assignment_expression {
+ TParameter param = { 0, new TType($2->getType()) };
+ $1->addParameter(param);
+ $$.function = $1;
+ $$.intermNode = $2;
+ }
+ | function_call_header_with_parameters COMMA assignment_expression {
+ TParameter param = { 0, new TType($3->getType()) };
+ $1.function->addParameter(param);
+ $$.function = $1.function;
+ $$.intermNode = parseContext.intermediate.growAggregate($1.intermNode, $3, $2.line);
+ }
+ ;
+
+function_call_header
+ : function_identifier LEFT_PAREN {
+ $$ = $1;
+ }
+ ;
+
+function_identifier
+ : constructor_identifier {
+ if ($1.op == EOpConstructStruct) {
+ TString tempString = "";
+ TFunction *function = new TFunction(&tempString, *($1.type.userDef), $1.op);
+ $$ = function;
+ }
+ else {
+ TFunction *function = new TFunction($1.op);
+ $$ = function;
+ }
+ }
+ | IDENTIFIER {
+ if (parseContext.reservedErrorCheck($1.line, *$1.string))
+ parseContext.recover();
+ TType type(EbtVoid);
+ TFunction *function = new TFunction($1.string, type);
+ $$ = function;
+ }
+ ;
+
+// Grammar Note: Constructors look like functions, but lexical anaylsis recognized most of them as keywords.
+
+//
+// Don't go through the symbol table for constructors.
+// Their parameters will be verified algorithmically.
+//
+constructor_identifier
+ : FLOAT_TYPE { $$.line = $1.line; $$.op = EOpConstructFloat; }
+ | INT_TYPE { $$.line = $1.line; $$.op = EOpConstructInt; }
+ | BOOL_TYPE { $$.line = $1.line; $$.op = EOpConstructBool; }
+ | VEC2 { $$.line = $1.line; $$.op = EOpConstructVec2; }
+ | VEC3 { $$.line = $1.line; $$.op = EOpConstructVec3; }
+ | VEC4 { $$.line = $1.line; $$.op = EOpConstructVec4; }
+ | BVEC2 { FRAG_VERT_ONLY("bvec2", $1.line); $$.line = $1.line; $$.op = EOpConstructBVec2; }
+ | BVEC3 { FRAG_VERT_ONLY("bvec3", $1.line); $$.line = $1.line; $$.op = EOpConstructBVec3; }
+ | BVEC4 { FRAG_VERT_ONLY("bvec4", $1.line); $$.line = $1.line; $$.op = EOpConstructBVec4; }
+ | IVEC2 { FRAG_VERT_ONLY("ivec2", $1.line); $$.line = $1.line; $$.op = EOpConstructIVec2; }
+ | IVEC3 { FRAG_VERT_ONLY("ivec3", $1.line); $$.line = $1.line; $$.op = EOpConstructIVec3; }
+ | IVEC4 { FRAG_VERT_ONLY("ivec4", $1.line); $$.line = $1.line; $$.op = EOpConstructIVec4; }
+ | MATRIX2 { FRAG_VERT_ONLY("mat2", $1.line); $$.line = $1.line; $$.op = EOpConstructMat2; }
+ | MATRIX3 { FRAG_VERT_ONLY("mat3", $1.line); $$.line = $1.line; $$.op = EOpConstructMat3; }
+ | MATRIX4 { FRAG_VERT_ONLY("mat4", $1.line); $$.line = $1.line; $$.op = EOpConstructMat4; }
+ | TYPE_NAME {
+ TType& structure = static_cast<TVariable*>($1.symbol)->getType();
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtStruct, qual, 1, false, false, &structure, $1.line };
+ $$.type = t;
+ $$.line = $1.line;
+ $$.op = EOpConstructStruct;
+ }
+ ;
+
+unary_expression
+ : postfix_expression {
+ $$ = $1;
+ }
+ | INC_OP unary_expression {
+ if (parseContext.lValueErrorCheck($1.line, "++", $2))
+ parseContext.recover();
+ $$ = parseContext.intermediate.addUnaryMath(EOpPreIncrement, $2, $1.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.unaryOpError($1.line, "++", $2->getCompleteString());
+ parseContext.recover();
+ $$ = $2;
+ }
+ }
+ | DEC_OP unary_expression {
+ if (parseContext.lValueErrorCheck($1.line, "--", $2))
+ parseContext.recover();
+ $$ = parseContext.intermediate.addUnaryMath(EOpPreDecrement, $2, $1.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.unaryOpError($1.line, "--", $2->getCompleteString());
+ parseContext.recover();
+ $$ = $2;
+ }
+ }
+ | unary_operator unary_expression {
+ if ($1.op != EOpNull) {
+ $$ = parseContext.intermediate.addUnaryMath($1.op, $2, $1.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ char* errorOp = "";
+ switch($1.op) {
+ case EOpNegative: errorOp = "-"; break;
+ case EOpLogicalNot: errorOp = "!"; break;
+ case EOpBitwiseNot: errorOp = "~"; break;
+ default: break;
+ }
+ parseContext.unaryOpError($1.line, errorOp, $2->getCompleteString());
+ parseContext.recover();
+ $$ = $2;
+ }
+ } else
+ $$ = $2;
+ }
+ ;
+// Grammar Note: No traditional style type casts.
+
+unary_operator
+ : PLUS { $$.line = $1.line; $$.op = EOpNull; }
+ | DASH { $$.line = $1.line; $$.op = EOpNegative; }
+ | BANG { $$.line = $1.line; $$.op = EOpLogicalNot; }
+ | TILDE { PACK_UNPACK_ONLY("~", $1.line);
+ $$.line = $1.line; $$.op = EOpBitwiseNot; }
+ ;
+// Grammar Note: No '*' or '&' unary ops. Pointers are not supported.
+
+multiplicative_expression
+ : unary_expression { $$ = $1; }
+ | multiplicative_expression STAR unary_expression {
+ FRAG_VERT_ONLY("*", $2.line);
+ $$ = parseContext.intermediate.addBinaryMath(EOpMul, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, "*", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ $$ = $1;
+ }
+ }
+ | multiplicative_expression SLASH unary_expression {
+ FRAG_VERT_ONLY("/", $2.line);
+ $$ = parseContext.intermediate.addBinaryMath(EOpDiv, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, "/", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ $$ = $1;
+ }
+ }
+ | multiplicative_expression PERCENT unary_expression {
+ PACK_UNPACK_ONLY("%", $2.line);
+ $$ = parseContext.intermediate.addBinaryMath(EOpMod, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, "%", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ $$ = $1;
+ }
+ }
+ ;
+
+additive_expression
+ : multiplicative_expression { $$ = $1; }
+ | additive_expression PLUS multiplicative_expression {
+ $$ = parseContext.intermediate.addBinaryMath(EOpAdd, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, "+", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ $$ = $1;
+ }
+ }
+ | additive_expression DASH multiplicative_expression {
+ $$ = parseContext.intermediate.addBinaryMath(EOpSub, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, "-", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ $$ = $1;
+ }
+ }
+ ;
+
+shift_expression
+ : additive_expression { $$ = $1; }
+ | shift_expression LEFT_OP additive_expression {
+ PACK_UNPACK_ONLY("<<", $2.line);
+ $$ = parseContext.intermediate.addBinaryMath(EOpLeftShift, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, "<<", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ $$ = $1;
+ }
+ }
+ | shift_expression RIGHT_OP additive_expression {
+ PACK_UNPACK_ONLY(">>", $2.line);
+ $$ = parseContext.intermediate.addBinaryMath(EOpRightShift, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, ">>", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ $$ = $1;
+ }
+ }
+ ;
+
+relational_expression
+ : shift_expression { $$ = $1; }
+ | relational_expression LEFT_ANGLE shift_expression {
+ $$ = parseContext.intermediate.addBinaryMath(EOpLessThan, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, "<", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
+ }
+ }
+ | relational_expression RIGHT_ANGLE shift_expression {
+ $$ = parseContext.intermediate.addBinaryMath(EOpGreaterThan, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, ">", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
+ }
+ }
+ | relational_expression LE_OP shift_expression {
+ $$ = parseContext.intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, "<=", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
+ }
+ }
+ | relational_expression GE_OP shift_expression {
+ $$ = parseContext.intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, ">=", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
+ }
+ }
+ ;
+
+equality_expression
+ : relational_expression { $$ = $1; }
+ | equality_expression EQ_OP relational_expression {
+ $$ = parseContext.intermediate.addBinaryMath(EOpEqual, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, "==", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
+ }
+ }
+ | equality_expression NE_OP relational_expression {
+ $$ = parseContext.intermediate.addBinaryMath(EOpNotEqual, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, "!=", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
+ }
+ }
+ ;
+
+and_expression
+ : equality_expression { $$ = $1; }
+ | and_expression AMPERSAND equality_expression {
+ PACK_UNPACK_ONLY("&", $2.line);
+ $$ = parseContext.intermediate.addBinaryMath(EOpAnd, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, "&", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ $$ = $1;
+ }
+ }
+ ;
+
+exclusive_or_expression
+ : and_expression { $$ = $1; }
+ | exclusive_or_expression CARET and_expression {
+ PACK_UNPACK_ONLY("^", $2.line);
+ $$ = parseContext.intermediate.addBinaryMath(EOpExclusiveOr, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, "^", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ $$ = $1;
+ }
+ }
+ ;
+
+inclusive_or_expression
+ : exclusive_or_expression { $$ = $1; }
+ | inclusive_or_expression VERTICAL_BAR exclusive_or_expression {
+ PACK_UNPACK_ONLY("|", $2.line);
+ $$ = parseContext.intermediate.addBinaryMath(EOpInclusiveOr, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, "|", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ $$ = $1;
+ }
+ }
+ ;
+
+logical_and_expression
+ : inclusive_or_expression { $$ = $1; }
+ | logical_and_expression AND_OP inclusive_or_expression {
+ $$ = parseContext.intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, "&&", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
+ }
+ }
+ ;
+
+logical_xor_expression
+ : logical_and_expression { $$ = $1; }
+ | logical_xor_expression XOR_OP logical_and_expression {
+ $$ = parseContext.intermediate.addBinaryMath(EOpLogicalXor, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, "^^", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
+ }
+ }
+ ;
+
+logical_or_expression
+ : logical_xor_expression { $$ = $1; }
+ | logical_or_expression OR_OP logical_xor_expression {
+ $$ = parseContext.intermediate.addBinaryMath(EOpLogicalOr, $1, $3, $2.line, parseContext.symbolTable);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, "||", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ constUnion *unionArray = new constUnion[1];
+ unionArray->bConst = false;
+ $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.line);
+ }
+ }
+ ;
+
+conditional_expression
+ : logical_or_expression { $$ = $1; }
+ | logical_or_expression QUESTION expression COLON assignment_expression {
+ if (parseContext.boolErrorCheck($2.line, $1))
+ parseContext.recover();
+
+ $$ = parseContext.intermediate.addSelection($1, $3, $5, $2.line);
+ if ($3->getType() != $5->getType())
+ $$ = 0;
+
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, ":", $3->getCompleteString(), $5->getCompleteString());
+ parseContext.recover();
+ $$ = $5;
+ }
+ }
+ ;
+
+assignment_expression
+ : conditional_expression { $$ = $1; }
+ | unary_expression assignment_operator assignment_expression {
+ if (parseContext.lValueErrorCheck($2.line, "assign", $1))
+ parseContext.recover();
+ $$ = parseContext.intermediate.addAssign($2.op, $1, $3, $2.line);
+ if ($$ == 0) {
+ parseContext.assignError($2.line, "assign", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ $$ = $1;
+ }
+ }
+ ;
+
+assignment_operator
+ : EQUAL { $$.line = $1.line; $$.op = EOpAssign; }
+ | MUL_ASSIGN { FRAG_VERT_ONLY("*=", $1.line); $$.line = $1.line; $$.op = EOpMulAssign; }
+ | DIV_ASSIGN { FRAG_VERT_ONLY("/=", $1.line); $$.line = $1.line; $$.op = EOpDivAssign; }
+ | MOD_ASSIGN { PACK_UNPACK_ONLY("%=", $1.line); $$.line = $1.line; $$.op = EOpModAssign; }
+ | ADD_ASSIGN { $$.line = $1.line; $$.op = EOpAddAssign; }
+ | SUB_ASSIGN { $$.line = $1.line; $$.op = EOpSubAssign; }
+ | LEFT_ASSIGN { PACK_UNPACK_ONLY("<<=", $1.line); $$.line = $1.line; $$.op = EOpLeftShiftAssign; }
+ | RIGHT_ASSIGN { PACK_UNPACK_ONLY("<<=", $1.line); $$.line = $1.line; $$.op = EOpRightShiftAssign; }
+ | AND_ASSIGN { PACK_UNPACK_ONLY("&=", $1.line); $$.line = $1.line; $$.op = EOpAndAssign; }
+ | XOR_ASSIGN { PACK_UNPACK_ONLY("^=", $1.line); $$.line = $1.line; $$.op = EOpExclusiveOrAssign; }
+ | OR_ASSIGN { PACK_UNPACK_ONLY("|=", $1.line); $$.line = $1.line; $$.op = EOpInclusiveOrAssign; }
+ ;
+
+expression
+ : assignment_expression {
+ $$ = $1;
+ }
+ | expression COMMA assignment_expression {
+ $$ = parseContext.intermediate.addComma($1, $3, $2.line);
+ if ($$ == 0) {
+ parseContext.binaryOpError($2.line, ",", $1->getCompleteString(), $3->getCompleteString());
+ parseContext.recover();
+ $$ = $3;
+ }
+ }
+ ;
+
+constant_expression
+ : conditional_expression {
+ if (parseContext.constErrorCheck($1))
+ parseContext.recover();
+ $$ = $1;
+ }
+ ;
+
+declaration
+ : function_prototype SEMICOLON { $$ = 0; }
+ | init_declarator_list SEMICOLON {
+ if ($1.intermAggregate)
+ $1.intermAggregate->setOperator(EOpSequence);
+ $$ = $1.intermAggregate;
+ }
+ ;
+
+function_prototype
+ : function_declarator RIGHT_PAREN {
+ //
+ // Multiple declarations of the same function are allowed.
+ //
+ // If this is a definition, the definition production code will check for redefinitions
+ // (we don't know at this point if it's a definition or not).
+ //
+ // Redeclarations are allowed. But, return types and parameter qualifiers must match.
+ //
+ TFunction* prevDec = static_cast<TFunction*>(parseContext.symbolTable.find($1->getMangledName()));
+ if (prevDec) {
+ if (prevDec->getReturnType() != $1->getReturnType()) {
+ parseContext.error($2.line, "overloaded functions must have the same return type", $1->getReturnType().getBasicString(), "");
+ parseContext.recover();
+ }
+ for (int i = 0; i < prevDec->getParamCount(); ++i) {
+ if ((*prevDec)[i].type->getQualifier() != (*$1)[i].type->getQualifier()) {
+ parseContext.error($2.line, "overloaded functions must have the same parameter qualifiers", (*$1)[i].type->getQualifierString(), "");
+ parseContext.recover();
+ }
+ }
+ }
+
+ //
+ // If this is a redeclaration, it could also be a definition,
+ // in which case, we want to use the variable names from this one, and not the one that's
+ // being redeclared. So, pass back up this declaration, not the one in the symbol table.
+ //
+ $$.function = $1;
+ $$.line = $2.line;
+
+ parseContext.symbolTable.insert(*$$.function);
+ }
+ ;
+
+function_declarator
+ : function_header {
+ $$ = $1;
+ }
+ | function_header_with_parameters {
+ $$ = $1;
+ }
+ ;
+
+
+function_header_with_parameters
+ : function_header parameter_declaration {
+ // Add the parameter
+ $$ = $1;
+ if ($2.param.type->getBasicType() != EbtVoid)
+ $1->addParameter($2.param);
+ else
+ delete $2.param.type;
+ }
+ | function_header_with_parameters COMMA parameter_declaration {
+ //
+ // Only first parameter of one-parameter functions can be void
+ // The check for named parameters not being void is done in parameter_declarator
+ //
+ if ($3.param.type->getBasicType() == EbtVoid) {
+ //
+ // This parameter > first is void
+ //
+ parseContext.error($2.line, "cannot be an argument type except for '(void)'", "void", "");
+ parseContext.recover();
+ delete $3.param.type;
+ } else {
+ // Add the parameter
+ $$ = $1;
+ $1->addParameter($3.param);
+ }
+ }
+ ;
+
+function_header
+ : fully_specified_type IDENTIFIER LEFT_PAREN {
+ if ($1.qualifier != EvqGlobal && $1.qualifier != EvqTemporary) {
+ parseContext.error($2.line, "no qualifiers allowed for function return", getQualifierString($1.qualifier), "");
+ parseContext.recover();
+ }
+ // make sure a sampler is not involved as well...
+ if (parseContext.structQualifierErrorCheck($2.line, $1))
+ parseContext.recover();
+
+ // Add the function as a prototype after parsing it (we do not support recursion)
+ TFunction *function;
+ TType type($1);
+ function = new TFunction($2.string, type);
+ $$ = function;
+ }
+ ;
+
+parameter_declarator
+ // Type + name
+ : type_specifier IDENTIFIER {
+ if ($1.type == EbtVoid) {
+ parseContext.error($2.line, "illegal use of type 'void'", $2.string->c_str(), "");
+ parseContext.recover();
+ }
+ if (parseContext.reservedErrorCheck($2.line, *$2.string))
+ parseContext.recover();
+ TParameter param = {$2.string, new TType($1)};
+ $$.line = $2.line;
+ $$.param = param;
+ }
+ | type_specifier IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {
+ // Check that we can make an array out of this type
+ if ($1.array) {
+ parseContext.error($3.line, "cannot declare arrays of this type", TType($1).getCompleteString().c_str(), "");
+ parseContext.recover();
+ }
+ if (parseContext.reservedErrorCheck($2.line, *$2.string))
+ parseContext.recover();
+ $1.array = true;
+ TType* type = new TType($1);
+ if ($4->getAsConstantUnion())
+ type->setArraySize($4->getAsConstantUnion()->getUnionArrayPointer()->iConst);
+ TParameter param = { $2.string, type };
+ $$.line = $2.line;
+ $$.param = param;
+ }
+ ;
+
+parameter_declaration
+ //
+ // The only parameter qualifier a parameter can have are
+ // IN_QUAL, OUT_QUAL, INOUT_QUAL, or CONST.
+ //
+
+ //
+ // Type + name
+ //
+ : type_qualifier parameter_qualifier parameter_declarator {
+ $$ = $3;
+ if (parseContext.paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type))
+ parseContext.recover();
+ }
+ | parameter_qualifier parameter_declarator {
+ $$ = $2;
+ if (parseContext.parameterSamplerErrorCheck($2.line, $1, *$2.param.type))
+ parseContext.recover();
+ if (parseContext.paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type))
+ parseContext.recover();
+ }
+ //
+ // Only type
+ //
+ | type_qualifier parameter_qualifier parameter_type_specifier {
+ $$ = $3;
+ if (parseContext.paramErrorCheck($3.line, $1.qualifier, $2, $$.param.type))
+ parseContext.recover();
+ }
+ | parameter_qualifier parameter_type_specifier {
+ $$ = $2;
+ if (parseContext.parameterSamplerErrorCheck($2.line, $1, *$2.param.type))
+ parseContext.recover();
+ if (parseContext.paramErrorCheck($2.line, EvqTemporary, $1, $$.param.type))
+ parseContext.recover();
+ }
+ ;
+
+parameter_qualifier
+ : /* empty */ {
+ $$ = EvqIn;
+ }
+ | IN_QUAL {
+ $$ = EvqIn;
+ }
+ | OUT_QUAL {
+ $$ = EvqOut;
+ }
+ | INOUT_QUAL {
+ $$ = EvqInOut;
+ }
+ ;
+
+parameter_type_specifier
+ : type_specifier {
+ TParameter param = { 0, new TType($1) };
+ $$.param = param;
+
+ }
+ | type_specifier LEFT_BRACKET constant_expression RIGHT_BRACKET {
+ // Check that we can make an array out of this type
+ if ($1.array) {
+ parseContext.error($2.line, "cannot declare arrays of this type", TType($1).getCompleteString().c_str(), "");
+ parseContext.recover();
+ }
+ $1.array = true;
+ TType* type = new TType($1);
+ if ($3->getAsConstantUnion())
+ type->setArraySize($3->getAsConstantUnion()->getUnionArrayPointer()->iConst);
+
+ TParameter param = { 0, type };
+ $$.line = $2.line;
+ $$.param = param;
+ }
+ ;
+
+init_declarator_list
+ : single_declaration {
+ $$ = $1;
+ }
+ | init_declarator_list COMMA IDENTIFIER {
+ $$ = $1;
+ if (parseContext.structQualifierErrorCheck($3.line, $1.type))
+ parseContext.recover();
+
+ if (parseContext.nonInitErrorCheck($3.line, *$3.string, $$.type))
+ parseContext.recover();
+ }
+ | init_declarator_list COMMA IDENTIFIER LEFT_BRACKET RIGHT_BRACKET {
+ $$ = $1;
+ if (parseContext.structQualifierErrorCheck($3.line, $1.type))
+ parseContext.recover();
+
+ if (parseContext.arrayErrorCheck($4.line, *$3.string, $$.type, 0))
+ parseContext.recover();
+ }
+ | init_declarator_list COMMA IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {
+ $$ = $1;
+ if (parseContext.structQualifierErrorCheck($3.line, $1.type))
+ parseContext.recover();
+
+ if (parseContext.arrayErrorCheck($4.line, *$3.string, $$.type, $5))
+ parseContext.recover();
+ }
+ | init_declarator_list COMMA IDENTIFIER EQUAL initializer {
+ $$ = $1;
+ if (parseContext.structQualifierErrorCheck($3.line, $1.type))
+ parseContext.recover();
+
+ TIntermNode* intermNode;
+ if (!parseContext.executeInitializer($3.line, *$3.string, $1.type, $5, intermNode)) {
+ //
+ // build the intermediate representation
+ //
+ if (intermNode)
+ $$.intermAggregate = parseContext.intermediate.growAggregate($1.intermNode, intermNode, $4.line);
+ else
+ $$.intermAggregate = $1.intermAggregate;
+ } else {
+ parseContext.recover();
+ $$.intermAggregate = 0;
+ }
+ }
+ ;
+
+single_declaration
+ : fully_specified_type {
+ $$.type = $1;
+ $$.intermAggregate = 0;
+ }
+ | fully_specified_type IDENTIFIER {
+ $$.intermAggregate = 0;
+ $$.type = $1;
+ if (parseContext.structQualifierErrorCheck($2.line, $1))
+ parseContext.recover();
+
+ if (parseContext.nonInitErrorCheck($2.line, *$2.string, $$.type))
+ parseContext.recover();
+ }
+ | fully_specified_type IDENTIFIER LEFT_BRACKET RIGHT_BRACKET {
+ $$.intermAggregate = 0;
+ $$.type = $1;
+ if (parseContext.structQualifierErrorCheck($2.line, $1))
+ parseContext.recover();
+
+ if (parseContext.arrayErrorCheck($3.line, *$2.string, $$.type, 0))
+ parseContext.recover();
+ }
+ | fully_specified_type IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {
+ $$.intermAggregate = 0;
+ $$.type = $1;
+ if (parseContext.structQualifierErrorCheck($2.line, $1))
+ parseContext.recover();
+
+ if (parseContext.arrayErrorCheck($3.line, *$2.string, $$.type, $4))
+ parseContext.recover();
+ }
+ | fully_specified_type IDENTIFIER EQUAL initializer {
+ $$.type = $1;
+ if (parseContext.structQualifierErrorCheck($2.line, $1))
+ parseContext.recover();
+
+ TIntermNode* intermNode;
+ if (!parseContext.executeInitializer($2.line, *$2.string, $1, $4, intermNode)) {
+ //
+ // Build intermediate representation
+ //
+ if (intermNode)
+ $$.intermAggregate = parseContext.intermediate.makeAggregate(intermNode, $3.line);
+ else
+ $$.intermAggregate = 0;
+ } else {
+ parseContext.recover();
+ $$.intermAggregate = 0;
+ }
+ }
+
+//
+// Place holder for the pack/unpack languages.
+//
+// | buffer_specifier {
+// $$.intermAggregate = 0;
+// }
+ ;
+
+// Grammar Note: No 'enum', or 'typedef'.
+
+//
+// Place holder for the pack/unpack languages.
+//
+//%type <interm> buffer_declaration
+//%type <interm.type> buffer_specifier input_or_output buffer_declaration_list
+//buffer_specifier
+// : input_or_output LEFT_BRACE buffer_declaration_list RIGHT_BRACE {
+// }
+// ;
+//
+//input_or_output
+// : INPUT {
+// if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "input"))
+// parseContext.recover();
+// UNPACK_ONLY("input", $1.line);
+// $$.qualifier = EvqInput;
+// }
+// | OUTPUT {
+// if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "output"))
+// parseContext.recover();
+// PACK_ONLY("output", $1.line);
+// $$.qualifier = EvqOutput;
+// }
+// ;
+
+//
+// Place holder for the pack/unpack languages.
+//
+//buffer_declaration_list
+// : buffer_declaration {
+// }
+// | buffer_declaration_list buffer_declaration {
+// }
+// ;
+
+//
+// Input/output semantics:
+// float must be 16 or 32 bits
+// float alignment restrictions?
+// check for only one input and only one output
+// sum of bitfields has to be multiple of 32
+//
+
+//
+// Place holder for the pack/unpack languages.
+//
+//buffer_declaration
+// : type_specifier IDENTIFIER COLON constant_expression SEMICOLON {
+// if (parseContext.reservedErrorCheck($2.line, *$2.string, parseContext))
+// parseContext.recover();
+// $$.variable = new TVariable($2.string, $1);
+// if (! parseContext.symbolTable.insert(*$$.variable)) {
+// parseContext.error($2.line, "redefinition", $$.variable->getName().c_str(), "");
+// parseContext.recover();
+// // don't have to delete $$.variable, the pool pop will take care of it
+// }
+// }
+// ;
+
+fully_specified_type
+ : type_specifier {
+ $$ = $1;
+ }
+ | type_qualifier type_specifier {
+ TPublicType t = { $2.type, $1.qualifier, $2.size, $2.matrix, false, $2.userDef, 0 };
+ if ($1.qualifier == EvqAttribute &&
+ ($2.type == EbtBool || $2.type == EbtInt)) {
+ parseContext.error($2.line, "cannot be bool or int", getQualifierString($1.qualifier), "");
+ parseContext.recover();
+ }
+ if (($1.qualifier == EvqVaryingIn || $1.qualifier == EvqVaryingOut) &&
+ ($2.type == EbtBool || $2.type == EbtInt)) {
+ parseContext.error($2.line, "cannot be bool or int", getQualifierString($1.qualifier), "");
+ parseContext.recover();
+ }
+ $$ = t;
+ }
+ ;
+
+type_qualifier
+ : CONST_QUAL {
+ TPublicType t = { EbtVoid, EvqConst, 1, false, false, 0 };
+ $$ = t;
+ }
+ | ATTRIBUTE {
+ VERTEX_ONLY("attribute", $1.line);
+ if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "attribute"))
+ parseContext.recover();
+ TPublicType t = { EbtVoid, EvqAttribute, 1, false, false, 0 };
+ $$ = t;
+ }
+ | VARYING {
+ if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "varying"))
+ parseContext.recover();
+ TPublicType t = { EbtVoid, EvqVaryingIn, 1, false, false, 0 };
+ if (parseContext.language == EShLangVertex)
+ t.qualifier = EvqVaryingOut;
+ $$ = t;
+ }
+ | UNIFORM {
+ if (parseContext.globalErrorCheck($1.line, parseContext.symbolTable.atGlobalLevel(), "uniform"))
+ parseContext.recover();
+ TPublicType t = { EbtVoid, EvqUniform, 1, false, false, 0 };
+ $$ = t;
+ }
+ ;
+
+type_specifier
+ : VOID_TYPE {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtVoid, qual, 1, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | FLOAT_TYPE {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtFloat, qual, 1, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | INT_TYPE {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtInt, qual, 1, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | BOOL_TYPE {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtBool, qual, 1, false, false, 0, $1.line };
+ $$ = t;
+ }
+// | UNSIGNED INT_TYPE {
+// PACK_UNPACK_ONLY("unsigned", $1.line);
+// TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+// TPublicType t = { EbtInt, qual, 1, false, false, 0, $1.line };
+// $$ = t;
+// }
+ | VEC2 {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtFloat, qual, 2, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | VEC3 {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtFloat, qual, 3, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | VEC4 {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtFloat, qual, 4, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | BVEC2 {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtBool, qual, 2, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | BVEC3 {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtBool, qual, 3, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | BVEC4 {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtBool, qual, 4, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | IVEC2 {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtInt, qual, 2, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | IVEC3 {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtInt, qual, 3, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | IVEC4 {
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtInt, qual, 4, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | MATRIX2 {
+ FRAG_VERT_ONLY("mat2", $1.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtFloat, qual, 2, true, false, 0, $1.line };
+ $$ = t;
+ }
+ | MATRIX3 {
+ FRAG_VERT_ONLY("mat3", $1.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtFloat, qual, 3, true, false, 0, $1.line };
+ $$ = t;
+ }
+ | MATRIX4 {
+ FRAG_VERT_ONLY("mat4", $1.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtFloat, qual, 4, true, false, 0, $1.line };
+ $$ = t;
+ }
+ | SAMPLER1D {
+ FRAG_VERT_ONLY("sampler1D", $1.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtSampler1D, qual, 1, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | SAMPLER2D {
+ FRAG_VERT_ONLY("sampler2D", $1.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtSampler2D, qual, 1, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | SAMPLER3D {
+ FRAG_VERT_ONLY("sampler3D", $1.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtSampler3D, qual, 1, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | SAMPLERCUBE {
+ FRAG_VERT_ONLY("samplerCube", $1.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtSamplerCube, qual, 1, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | SAMPLER1DSHADOW {
+ FRAG_VERT_ONLY("sampler1DShadow", $1.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtSampler1DShadow, qual, 1, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | SAMPLER2DSHADOW {
+ FRAG_VERT_ONLY("sampler2DShadow", $1.line);
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtSampler2DShadow, qual, 1, false, false, 0, $1.line };
+ $$ = t;
+ }
+ | struct_specifier {
+ FRAG_VERT_ONLY("struct", $1.line);
+ $$ = $1;
+ $$.qualifier = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ }
+ | TYPE_NAME {
+ //
+ // This is for user defined type names. The lexical phase looked up the
+ // type.
+ //
+ TType& structure = static_cast<TVariable*>($1.symbol)->getType();
+ TQualifier qual = parseContext.symbolTable.atGlobalLevel() ? EvqGlobal : EvqTemporary;
+ TPublicType t = { EbtStruct, qual, 1, false, false, &structure, $1.line };
+ $$ = t;
+ }
+ ;
+
+struct_specifier
+ : STRUCT IDENTIFIER LEFT_BRACE struct_declaration_list RIGHT_BRACE {
+ TType* structure = new TType($4, *$2.string);
+ TVariable* userTypeDef = new TVariable($2.string, *structure, true);
+ if (! parseContext.symbolTable.insert(*userTypeDef)) {
+ parseContext.error($2.line, "redefinition", $2.string->c_str(), "struct");
+ parseContext.recover();
+ }
+ TPublicType t = { EbtStruct, EvqTemporary, 1, false, false, structure, $1.line };
+ $$ = t;
+ }
+ | STRUCT LEFT_BRACE struct_declaration_list RIGHT_BRACE {
+ TType* structure = new TType($3, TString(""));
+ TPublicType t = { EbtStruct, EvqTemporary, 1, false, false, structure, $1.line };
+ $$ = t;
+ }
+ ;
+
+struct_declaration_list
+ : struct_declaration {
+ $$ = $1;
+ }
+ | struct_declaration_list struct_declaration {
+ $$ = $1;
+ for (unsigned int i = 0; i < $2->size(); ++i) {
+ for (unsigned int j = 0; j < $$->size(); ++j) {
+ if ((*$$)[j].type->getFieldName() == (*$2)[i].type->getFieldName()) {
+ parseContext.error((*$2)[i].line, "duplicate field name in structure:", "struct", (*$2)[i].type->getFieldName().c_str());
+ parseContext.recover();
+ }
+ }
+ $$->push_back((*$2)[i]);
+ }
+ }
+ ;
+
+struct_declaration
+ : type_specifier struct_declarator_list SEMICOLON {
+ $$ = $2;
+
+ if (parseContext.voidErrorCheck($1.line, (*$2)[0].type->getFieldName(), $1)) {
+ parseContext.recover();
+ }
+ for (unsigned int i = 0; i < $$->size(); ++i) {
+ //
+ // Careful not to replace already know aspects of type, like array-ness
+ //
+ (*$$)[i].type->setType($1.type, $1.size, $1.matrix, $1.userDef);
+ if ($1.userDef)
+ (*$$)[i].type->setTypeName($1.userDef->getTypeName());
+ }
+ }
+ ;
+
+struct_declarator_list
+ : struct_declarator {
+ $$ = NewPoolTTypeList();
+ $$->push_back($1);
+ }
+ | struct_declarator_list COMMA struct_declarator {
+ $$->push_back($3);
+ }
+ ;
+
+struct_declarator
+ : IDENTIFIER {
+ $$.type = new TType(EbtVoid);
+ $$.line = $1.line;
+ $$.type->setFieldName(*$1.string);
+ }
+ | IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {
+ $$.type = new TType(EbtVoid);
+ $$.line = $1.line;
+ $$.type->setFieldName(*$1.string);
+
+ if ($3->getAsConstantUnion() == 0 || $3->getAsConstantUnion()->getBasicType() != EbtInt ||
+ $3->getAsConstantUnion()->getUnionArrayPointer()->iConst <= 0) {
+ parseContext.error($2.line, "structure field array size must be a positive integer", $1.string->c_str(), "");
+ parseContext.recover();
+ } else {
+ $$.type->setArraySize($3->getAsConstantUnion()->getUnionArrayPointer()->iConst);
+ }
+ }
+ ;
+
+initializer
+ : assignment_expression { $$ = $1; }
+ ;
+
+declaration_statement
+ : declaration { $$ = $1; }
+ ;
+
+statement
+ : compound_statement { $$ = $1; }
+ | simple_statement { $$ = $1; }
+ ;
+
+// Grammar Note: No labeled statements; 'goto' is not supported.
+
+simple_statement
+ : declaration_statement { $$ = $1; }
+ | expression_statement { $$ = $1; }
+ | selection_statement { $$ = $1; }
+ | iteration_statement { $$ = $1; }
+ | jump_statement { $$ = $1; }
+ ;
+
+compound_statement
+ : LEFT_BRACE RIGHT_BRACE { $$ = 0; }
+ | LEFT_BRACE { parseContext.symbolTable.push(); } statement_list { parseContext.symbolTable.pop(); } RIGHT_BRACE {
+ if ($3 != 0)
+ $3->setOperator(EOpSequence);
+ $$ = $3;
+ }
+ ;
+
+statement_no_new_scope
+ : compound_statement_no_new_scope { $$ = $1; }
+ | simple_statement { $$ = $1; }
+ ;
+
+compound_statement_no_new_scope
+ // Statement that doesn't create a new scope, for selection_statement, iteration_statement
+ : LEFT_BRACE RIGHT_BRACE {
+ $$ = 0;
+ }
+ | LEFT_BRACE statement_list RIGHT_BRACE {
+ if ($2)
+ $2->setOperator(EOpSequence);
+ $$ = $2;
+ }
+ ;
+
+statement_list
+ : statement {
+ $$ = parseContext.intermediate.makeAggregate($1, 0);
+ }
+ | statement_list statement {
+ $$ = parseContext.intermediate.growAggregate($1, $2, 0);
+ }
+ ;
+
+expression_statement
+ : SEMICOLON { $$ = 0; }
+ | expression SEMICOLON { $$ = static_cast<TIntermNode*>($1); }
+ ;
+
+selection_statement
+ : IF LEFT_PAREN expression RIGHT_PAREN selection_rest_statement {
+ if (parseContext.boolErrorCheck($1.line, $3))
+ parseContext.recover();
+ $$ = parseContext.intermediate.addSelection($3, $5, $1.line);
+ }
+ ;
+
+selection_rest_statement
+ : statement ELSE statement {
+ $$.node1 = $1;
+ $$.node2 = $3;
+ }
+ | statement {
+ $$.node1 = $1;
+ $$.node2 = 0;
+ }
+ ;
+
+// Grammar Note: No 'switch'. Switch statements not supported.
+
+condition
+ // In 1996 c++ draft, conditions can include single declarations
+ : expression {
+ $$ = $1;
+ if (parseContext.boolErrorCheck($1->getLine(), $1))
+ parseContext.recover();
+ }
+ | fully_specified_type IDENTIFIER EQUAL initializer {
+ TIntermNode* intermNode;
+ if (parseContext.structQualifierErrorCheck($2.line, $1))
+ parseContext.recover();
+ if (parseContext.boolErrorCheck($2.line, $1))
+ parseContext.recover();
+
+ if (!parseContext.executeInitializer($2.line, *$2.string, $1, $4, intermNode))
+ $$ = $4;
+ else {
+ parseContext.recover();
+ $$ = 0;
+ }
+ }
+ ;
+
+iteration_statement
+ : WHILE LEFT_PAREN { parseContext.symbolTable.push(); ++parseContext.loopNestingLevel; } condition RIGHT_PAREN statement_no_new_scope {
+ parseContext.symbolTable.pop();
+ $$ = parseContext.intermediate.addLoop($6, $4, 0, true, $1.line);
+ --parseContext.loopNestingLevel;
+ }
+ | DO { ++parseContext.loopNestingLevel; } statement WHILE LEFT_PAREN expression RIGHT_PAREN SEMICOLON {
+ if (parseContext.boolErrorCheck($8.line, $6))
+ parseContext.recover();
+
+ $$ = parseContext.intermediate.addLoop($3, $6, 0, false, $4.line);
+ --parseContext.loopNestingLevel;
+ }
+ | FOR LEFT_PAREN { parseContext.symbolTable.push(); ++parseContext.loopNestingLevel; } for_init_statement for_rest_statement RIGHT_PAREN statement_no_new_scope {
+ parseContext.symbolTable.pop();
+ $$ = parseContext.intermediate.makeAggregate($4, $2.line);
+ $$ = parseContext.intermediate.growAggregate(
+ $$,
+ parseContext.intermediate.addLoop($7, reinterpret_cast<TIntermTyped*>($5.node1), reinterpret_cast<TIntermTyped*>($5.node2), true, $1.line),
+ $1.line);
+ $$->getAsAggregate()->setOperator(EOpSequence);
+ --parseContext.loopNestingLevel;
+ }
+ ;
+
+for_init_statement
+ : expression_statement {
+ $$ = $1;
+ }
+ | declaration_statement {
+ $$ = $1;
+ }
+ ;
+
+conditionopt
+ : condition {
+ $$ = $1;
+ }
+ | /* May be null */ {
+ $$ = 0;
+ }
+ ;
+
+for_rest_statement
+ : conditionopt SEMICOLON {
+ $$.node1 = $1;
+ $$.node2 = 0;
+ }
+ | conditionopt SEMICOLON expression {
+ $$.node1 = $1;
+ $$.node2 = $3;
+ }
+ ;
+
+jump_statement
+ : CONTINUE SEMICOLON {
+ if (parseContext.loopNestingLevel <= 0) {
+ parseContext.error($1.line, "continue statement only allowed in loops", "", "");
+ parseContext.recover();
+ }
+ $$ = parseContext.intermediate.addBranch(EOpContinue, $1.line);
+ }
+ | BREAK SEMICOLON {
+ if (parseContext.loopNestingLevel <= 0) {
+ parseContext.error($1.line, "break statement only allowed in loops", "", "");
+ parseContext.recover();
+ }
+ $$ = parseContext.intermediate.addBranch(EOpBreak, $1.line);
+ }
+ | RETURN SEMICOLON {
+ $$ = parseContext.intermediate.addBranch(EOpReturn, $1.line);
+ if (parseContext.currentFunctionType->getBasicType() != EbtVoid) {
+ parseContext.error($1.line, "non-void function must return a value", "return", "");
+ parseContext.recover();
+ }
+ }
+ | RETURN expression SEMICOLON {
+ $$ = parseContext.intermediate.addBranch(EOpReturn, $2, $1.line);
+ parseContext.functionReturnsValue = true;
+ if (parseContext.currentFunctionType->getBasicType() == EbtVoid) {
+ parseContext.error($1.line, "void function cannot return a value", "return", "");
+ parseContext.recover();
+ } else if (*(parseContext.currentFunctionType) != $2->getType()) {
+ parseContext.error($1.line, "function return is not matching type:", "return", "");
+ parseContext.recover();
+ }
+ }
+ | DISCARD SEMICOLON {
+ FRAG_ONLY("discard", $1.line);
+ $$ = parseContext.intermediate.addBranch(EOpKill, $1.line);
+ }
+ ;
+
+// Grammar Note: No 'goto'. Gotos are not supported.
+
+translation_unit
+ : external_declaration {
+ $$ = $1;
+ parseContext.treeRoot = $$;
+ }
+ | translation_unit external_declaration {
+ $$ = parseContext.intermediate.growAggregate($1, $2, 0);
+ parseContext.treeRoot = $$;
+ }
+ ;
+
+external_declaration
+ : function_definition {
+ $$ = $1;
+ }
+ | declaration {
+ $$ = $1;
+ }
+ ;
+
+function_definition
+ : function_prototype {
+ TFunction& function = *($1.function);
+ TFunction* prevDec = static_cast<TFunction*>(parseContext.symbolTable.find(function.getMangledName()));
+ //
+ // Note: 'prevDec' could be 'function' if this is the first time we've seen function
+ // as it would have just been put in the symbol table. Otherwise, we're looking up
+ // an earlier occurance.
+ //
+ if (prevDec->isDefined()) {
+ //
+ // Then this function already has a body.
+ //
+ parseContext.error($1.line, "function already has a body", function.getName().c_str(), "");
+ parseContext.recover();
+ }
+ prevDec->setDefined();
+
+ //
+ // Raise error message if main function takes any parameters or return anything other than void
+ //
+ if (function.getName() == "main") {
+ if (function.getParamCount() > 0) {
+ parseContext.error($1.line, "function cannot take any parameter(s)", function.getName().c_str(), "");
+ parseContext.recover();
+ }
+ if (function.getReturnType().getBasicType() != EbtVoid) {
+ parseContext.error($1.line, "", function.getReturnType().getBasicString(), "main function cannot return a value" );
+ parseContext.recover();
+ }
+ }
+
+ //
+ // New symbol table scope for body of function plus its arguments
+ //
+ parseContext.symbolTable.push();
+
+ //
+ // Remember the return type for later checking for RETURN statements.
+ //
+ parseContext.currentFunctionType = &(prevDec->getReturnType());
+ parseContext.functionReturnsValue = false;
+
+ //
+ // Insert parameters into the symbol table.
+ // If the parameter has no name, it's not an error, just don't insert it
+ // (could be used for unused args).
+ //
+ // Also, accumulate the list of parameters into the HIL, so lower level code
+ // knows where to find parameters.
+ //
+ TIntermAggregate* paramNodes = new TIntermAggregate;
+ for (int i = 0; i < function.getParamCount(); i++) {
+ TParameter& param = function[i];
+ if (param.name != 0) {
+ TVariable *variable = new TVariable(param.name, *param.type);
+ //
+ // Insert the parameters with name in the symbol table.
+ //
+ if (! parseContext.symbolTable.insert(*variable)) {
+ parseContext.error($1.line, "redefinition", variable->getName().c_str(), "");
+ parseContext.recover();
+ delete variable;
+ }
+ //
+ // Transfer ownership of name pointer to symbol table.
+ //
+ param.name = 0;
+
+ //
+ // Add the parameter to the HIL
+ //
+ paramNodes = parseContext.intermediate.growAggregate(
+ paramNodes,
+ parseContext.intermediate.addSymbol(variable->getUniqueId(),
+ variable->getName(),
+ variable->getType(), $1.line),
+ $1.line);
+ } else {
+ paramNodes = parseContext.intermediate.growAggregate(paramNodes, parseContext.intermediate.addSymbol(0, "", *param.type, $1.line), $1.line);
+ }
+ }
+ parseContext.intermediate.setAggregateOperator(paramNodes, EOpParameters, $1.line);
+ $1.intermAggregate = paramNodes;
+ parseContext.loopNestingLevel = 0;
+ }
+ compound_statement_no_new_scope {
+ //?? Check that all paths return a value if return type != void ?
+ // May be best done as post process phase on intermediate code
+ if (parseContext.currentFunctionType->getBasicType() != EbtVoid && ! parseContext.functionReturnsValue) {
+ parseContext.error($1.line, "function does not return a value:", "", $1.function->getName().c_str());
+ parseContext.recover();
+ }
+ parseContext.symbolTable.pop();
+ $$ = parseContext.intermediate.growAggregate($1.intermAggregate, $3, 0);
+ parseContext.intermediate.setAggregateOperator($$, EOpFunction, $1.line);
+ $$->getAsAggregate()->setName($1.function->getMangledName().c_str());
+ $$->getAsAggregate()->setType($1.function->getReturnType());
+
+ // store the pragma information for debug and optimize and other vendor specific
+ // information. This information can be queried from the parse tree
+ $$->getAsAggregate()->setOptimize(parseContext.contextPragma.optimize);
+ $$->getAsAggregate()->setDebug(parseContext.contextPragma.debug);
+ $$->getAsAggregate()->addToPragmaTable(parseContext.contextPragma.pragmaTable);
+ }
+ ;
+
+%%
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/glslang_tab.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/glslang_tab.h
new file mode 100755
index 000000000..97d827fe9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/glslang_tab.h
@@ -0,0 +1,260 @@
+/* A Bison parser, made by GNU Bison 1.875. */
+
+/* Skeleton parser for Yacc-like parsing with Bison,
+ Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA. */
+
+/* As a special exception, when this file is copied by Bison into a
+ Bison output file, you may use that output file without restriction.
+ This special exception was added by the Free Software Foundation
+ in version 1.24 of Bison. */
+
+/* Tokens. */
+#ifndef YYTOKENTYPE
+# define YYTOKENTYPE
+ /* Put the tokens into the symbol table, so that GDB and other debuggers
+ know about them. */
+ enum yytokentype {
+ ATTRIBUTE = 258,
+ CONST_QUAL = 259,
+ BOOL_TYPE = 260,
+ FLOAT_TYPE = 261,
+ INT_TYPE = 262,
+ BREAK = 263,
+ CONTINUE = 264,
+ DO = 265,
+ ELSE = 266,
+ FOR = 267,
+ IF = 268,
+ DISCARD = 269,
+ RETURN = 270,
+ BVEC2 = 271,
+ BVEC3 = 272,
+ BVEC4 = 273,
+ IVEC2 = 274,
+ IVEC3 = 275,
+ IVEC4 = 276,
+ VEC2 = 277,
+ VEC3 = 278,
+ VEC4 = 279,
+ MATRIX2 = 280,
+ MATRIX3 = 281,
+ MATRIX4 = 282,
+ IN_QUAL = 283,
+ OUT_QUAL = 284,
+ INOUT_QUAL = 285,
+ UNIFORM = 286,
+ VARYING = 287,
+ STRUCT = 288,
+ VOID_TYPE = 289,
+ WHILE = 290,
+ SAMPLER1D = 291,
+ SAMPLER2D = 292,
+ SAMPLER3D = 293,
+ SAMPLERCUBE = 294,
+ SAMPLER1DSHADOW = 295,
+ SAMPLER2DSHADOW = 296,
+ IDENTIFIER = 297,
+ TYPE_NAME = 298,
+ FLOATCONSTANT = 299,
+ INTCONSTANT = 300,
+ BOOLCONSTANT = 301,
+ FIELD_SELECTION = 302,
+ LEFT_OP = 303,
+ RIGHT_OP = 304,
+ INC_OP = 305,
+ DEC_OP = 306,
+ LE_OP = 307,
+ GE_OP = 308,
+ EQ_OP = 309,
+ NE_OP = 310,
+ AND_OP = 311,
+ OR_OP = 312,
+ XOR_OP = 313,
+ MUL_ASSIGN = 314,
+ DIV_ASSIGN = 315,
+ ADD_ASSIGN = 316,
+ MOD_ASSIGN = 317,
+ LEFT_ASSIGN = 318,
+ RIGHT_ASSIGN = 319,
+ AND_ASSIGN = 320,
+ XOR_ASSIGN = 321,
+ OR_ASSIGN = 322,
+ SUB_ASSIGN = 323,
+ LEFT_PAREN = 324,
+ RIGHT_PAREN = 325,
+ LEFT_BRACKET = 326,
+ RIGHT_BRACKET = 327,
+ LEFT_BRACE = 328,
+ RIGHT_BRACE = 329,
+ DOT = 330,
+ COMMA = 331,
+ COLON = 332,
+ EQUAL = 333,
+ SEMICOLON = 334,
+ BANG = 335,
+ DASH = 336,
+ TILDE = 337,
+ PLUS = 338,
+ STAR = 339,
+ SLASH = 340,
+ PERCENT = 341,
+ LEFT_ANGLE = 342,
+ RIGHT_ANGLE = 343,
+ VERTICAL_BAR = 344,
+ CARET = 345,
+ AMPERSAND = 346,
+ QUESTION = 347
+ };
+#endif
+#define ATTRIBUTE 258
+#define CONST_QUAL 259
+#define BOOL_TYPE 260
+#define FLOAT_TYPE 261
+#define INT_TYPE 262
+#define BREAK 263
+#define CONTINUE 264
+#define DO 265
+#define ELSE 266
+#define FOR 267
+#define IF 268
+#define DISCARD 269
+#define RETURN 270
+#define BVEC2 271
+#define BVEC3 272
+#define BVEC4 273
+#define IVEC2 274
+#define IVEC3 275
+#define IVEC4 276
+#define VEC2 277
+#define VEC3 278
+#define VEC4 279
+#define MATRIX2 280
+#define MATRIX3 281
+#define MATRIX4 282
+#define IN_QUAL 283
+#define OUT_QUAL 284
+#define INOUT_QUAL 285
+#define UNIFORM 286
+#define VARYING 287
+#define STRUCT 288
+#define VOID_TYPE 289
+#define WHILE 290
+#define SAMPLER1D 291
+#define SAMPLER2D 292
+#define SAMPLER3D 293
+#define SAMPLERCUBE 294
+#define SAMPLER1DSHADOW 295
+#define SAMPLER2DSHADOW 296
+#define IDENTIFIER 297
+#define TYPE_NAME 298
+#define FLOATCONSTANT 299
+#define INTCONSTANT 300
+#define BOOLCONSTANT 301
+#define FIELD_SELECTION 302
+#define LEFT_OP 303
+#define RIGHT_OP 304
+#define INC_OP 305
+#define DEC_OP 306
+#define LE_OP 307
+#define GE_OP 308
+#define EQ_OP 309
+#define NE_OP 310
+#define AND_OP 311
+#define OR_OP 312
+#define XOR_OP 313
+#define MUL_ASSIGN 314
+#define DIV_ASSIGN 315
+#define ADD_ASSIGN 316
+#define MOD_ASSIGN 317
+#define LEFT_ASSIGN 318
+#define RIGHT_ASSIGN 319
+#define AND_ASSIGN 320
+#define XOR_ASSIGN 321
+#define OR_ASSIGN 322
+#define SUB_ASSIGN 323
+#define LEFT_PAREN 324
+#define RIGHT_PAREN 325
+#define LEFT_BRACKET 326
+#define RIGHT_BRACKET 327
+#define LEFT_BRACE 328
+#define RIGHT_BRACE 329
+#define DOT 330
+#define COMMA 331
+#define COLON 332
+#define EQUAL 333
+#define SEMICOLON 334
+#define BANG 335
+#define DASH 336
+#define TILDE 337
+#define PLUS 338
+#define STAR 339
+#define SLASH 340
+#define PERCENT 341
+#define LEFT_ANGLE 342
+#define RIGHT_ANGLE 343
+#define VERTICAL_BAR 344
+#define CARET 345
+#define AMPERSAND 346
+#define QUESTION 347
+
+
+
+
+#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
+#line 117 "glslang.y"
+typedef union YYSTYPE {
+ struct {
+ TSourceLoc line;
+ union {
+ TString *string;
+ float f;
+ int i;
+ bool b;
+ };
+ TSymbol* symbol;
+ } lex;
+ struct {
+ TSourceLoc line;
+ TOperator op;
+ union {
+ TIntermNode* intermNode;
+ TIntermNodePair nodePair;
+ TIntermTyped* intermTypedNode;
+ TIntermAggregate* intermAggregate;
+ };
+ union {
+ TPublicType type;
+ TQualifier qualifier;
+ TFunction* function;
+ TParameter param;
+ TTypeLine typeLine;
+ TTypeList* typeList;
+ };
+ } interm;
+} YYSTYPE;
+/* Line 1240 of yacc.c. */
+#line 251 "glslang.tab.h"
+# define yystype YYSTYPE /* obsolescent; will be withdrawn */
+# define YYSTYPE_IS_DECLARED 1
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
+
+
+
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/intermOut.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/intermOut.cpp
new file mode 100755
index 000000000..e75608c45
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/intermOut.cpp
@@ -0,0 +1,496 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#include "localintermediate.h"
+#include "../Include/ShHandle.h"
+
+//
+// Two purposes:
+// 1. Show an example of how to iterate tree. Functions can
+// also directly call Traverse() on children themselves to
+// have finer grained control over the process than shown here.
+// See the last function for how to get started.
+// 2. Print out a text based description of the tree.
+//
+
+//
+// Use this class to carry along data from node to node in
+// the traversal
+//
+class TOutputTraverser : public TIntermTraverser {
+public:
+ TOutputTraverser(TInfoSink& i) : infoSink(i) { }
+ TInfoSink& infoSink;
+};
+
+TString TType::getCompleteString() const
+{
+ char buf[100];
+ char *p = &buf[0];
+
+ if (qualifier != EvqTemporary && qualifier != EvqGlobal)
+ p += sprintf(p, "%s ", getQualifierString());
+ if (array)
+ p += sprintf(p, "array of ");
+ if (matrix)
+ p += sprintf(p, "%dX%d matrix of ", size, size);
+ else if (size > 1)
+ p += sprintf(p, "%d-component vector of ", size);
+
+ sprintf(p, "%s", getBasicString());
+
+ return TString(buf);
+}
+
+//
+// Helper functions for printing, not part of traversing.
+//
+
+void OutputTreeText(TInfoSink& infoSink, TIntermNode* node, const int depth)
+{
+ int i;
+
+ infoSink.debug << FormatSourceLoc(node->getLine());
+
+ for (i = 0; i < depth; ++i)
+ infoSink.debug << " ";
+}
+
+//
+// The rest of the file are the traversal functions. The last one
+// is the one that starts the traversal.
+//
+// Return true from interior nodes to have the external traversal
+// continue on to children. If you process children yourself,
+// return false.
+//
+
+void OutputSymbol(TIntermSymbol* node, TIntermTraverser* it)
+{
+ TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
+
+ OutputTreeText(oit->infoSink, node, oit->depth);
+
+ char buf[100];
+ sprintf(buf, "'%s' (%s)\n",
+ node->getSymbol().c_str(),
+ node->getCompleteString().c_str());
+
+ oit->infoSink.debug << buf;
+}
+
+bool OutputBinary(bool /* preVisit */, TIntermBinary* node, TIntermTraverser* it)
+{
+ TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
+ TInfoSink& out = oit->infoSink;
+
+ OutputTreeText(out, node, oit->depth);
+
+ switch (node->getOp()) {
+ case EOpAssign: out.debug << "move second child to first child"; break;
+ case EOpAddAssign: out.debug << "add second child into first child"; break;
+ case EOpSubAssign: out.debug << "subtract second child into first child"; break;
+ case EOpMulAssign: out.debug << "multiply second child into first child"; break;
+ case EOpVectorTimesMatrixAssign: out.debug << "matrix mult second child into first child"; break;
+ case EOpVectorTimesScalarAssign: out.debug << "vector scale second child into first child"; break;
+ case EOpMatrixTimesScalarAssign: out.debug << "matrix scale second child into first child"; break;
+ case EOpMatrixTimesMatrixAssign: out.debug << "matrix mult second child into first child"; break;
+ case EOpDivAssign: out.debug << "divide second child into first child"; break;
+ case EOpModAssign: out.debug << "mod second child into first child"; break;
+ case EOpAndAssign: out.debug << "and second child into first child"; break;
+ case EOpInclusiveOrAssign: out.debug << "or second child into first child"; break;
+ case EOpExclusiveOrAssign: out.debug << "exclusive or second child into first child"; break;
+ case EOpLeftShiftAssign: out.debug << "left shift second child into first child"; break;
+ case EOpRightShiftAssign: out.debug << "right shift second child into first child"; break;
+
+ case EOpIndexDirect: out.debug << "direct index"; break;
+ case EOpIndexIndirect: out.debug << "indirect index"; break;
+ case EOpIndexDirectStruct: out.debug << "direct index for structure"; break;
+ case EOpVectorSwizzle: out.debug << "vector swizzle"; break;
+
+ case EOpAdd: out.debug << "add"; break;
+ case EOpSub: out.debug << "subtract"; break;
+ case EOpMul: out.debug << "component-wise multiply"; break;
+ case EOpDiv: out.debug << "divide"; break;
+ case EOpMod: out.debug << "mod"; break;
+ case EOpRightShift: out.debug << "right-shift"; break;
+ case EOpLeftShift: out.debug << "left-shift"; break;
+ case EOpAnd: out.debug << "bitwise and"; break;
+ case EOpInclusiveOr: out.debug << "inclusive-or"; break;
+ case EOpExclusiveOr: out.debug << "exclusive-or"; break;
+ case EOpEqual: out.debug << "Compare Equal"; break;
+ case EOpNotEqual: out.debug << "Compare Not Equal"; break;
+ case EOpLessThan: out.debug << "Compare Less Than"; break;
+ case EOpGreaterThan: out.debug << "Compare Greater Than"; break;
+ case EOpLessThanEqual: out.debug << "Compare Less Than or Equal"; break;
+ case EOpGreaterThanEqual: out.debug << "Compare Greater Than or Equal"; break;
+
+ case EOpVectorTimesScalar: out.debug << "vector-scale"; break;
+ case EOpVectorTimesMatrix: out.debug << "vector-times-matrix"; break;
+ case EOpMatrixTimesVector: out.debug << "matrix-times-vector"; break;
+ case EOpMatrixTimesScalar: out.debug << "matrix-scale"; break;
+ case EOpMatrixTimesMatrix: out.debug << "matrix-multiply"; break;
+
+ case EOpLogicalOr: out.debug << "logical-or"; break;
+ case EOpLogicalXor: out.debug << "logical-xor"; break;
+ case EOpLogicalAnd: out.debug << "logical-and"; break;
+ default: out.debug << "<unknown op>";
+ }
+
+ out.debug << " (" << node->getCompleteString() << ")";
+
+ out.debug << "\n";
+
+ return true;
+}
+
+bool OutputUnary(bool /* preVisit */, TIntermUnary* node, TIntermTraverser* it)
+{
+ TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
+ TInfoSink& out = oit->infoSink;
+
+ OutputTreeText(out, node, oit->depth);
+
+ switch (node->getOp()) {
+ case EOpNegative: out.debug << "Negate value"; break;
+ case EOpVectorLogicalNot:
+ case EOpLogicalNot: out.debug << "Negate conditional"; break;
+ case EOpBitwiseNot: out.debug << "Bitwise not"; break;
+
+ case EOpPostIncrement: out.debug << "Post-Increment"; break;
+ case EOpPostDecrement: out.debug << "Post-Decrement"; break;
+ case EOpPreIncrement: out.debug << "Pre-Increment"; break;
+ case EOpPreDecrement: out.debug << "Pre-Decrement"; break;
+
+ case EOpConvIntToBool: out.debug << "Convert int to bool"; break;
+ case EOpConvFloatToBool:out.debug << "Convert float to bool";break;
+ case EOpConvBoolToFloat:out.debug << "Convert bool to float";break;
+ case EOpConvIntToFloat: out.debug << "Convert int to float"; break;
+ case EOpConvFloatToInt: out.debug << "Convert float to int"; break;
+ case EOpConvBoolToInt: out.debug << "Convert bool to int"; break;
+
+ case EOpRadians: out.debug << "radians"; break;
+ case EOpDegrees: out.debug << "degrees"; break;
+ case EOpSin: out.debug << "sine"; break;
+ case EOpCos: out.debug << "cosine"; break;
+ case EOpTan: out.debug << "tangent"; break;
+ case EOpAsin: out.debug << "arc sine"; break;
+ case EOpAcos: out.debug << "arc cosine"; break;
+ case EOpAtan: out.debug << "arc tangent"; break;
+
+ case EOpExp: out.debug << "exp"; break;
+ case EOpLog: out.debug << "log"; break;
+ case EOpExp2: out.debug << "exp2"; break;
+ case EOpLog2: out.debug << "log2"; break;
+ case EOpSqrt: out.debug << "sqrt"; break;
+ case EOpInverseSqrt: out.debug << "inverse sqrt"; break;
+
+ case EOpAbs: out.debug << "Absolute value"; break;
+ case EOpSign: out.debug << "Sign"; break;
+ case EOpFloor: out.debug << "Floor"; break;
+ case EOpCeil: out.debug << "Ceiling"; break;
+ case EOpFract: out.debug << "Fraction"; break;
+
+ case EOpLength: out.debug << "length"; break;
+ case EOpNormalize: out.debug << "normalize"; break;
+ case EOpDPdx: out.debug << "dPdx"; break;
+ case EOpDPdy: out.debug << "dPdy"; break;
+ case EOpFwidth: out.debug << "fwidth"; break;
+
+ case EOpAny: out.debug << "any"; break;
+ case EOpAll: out.debug << "all"; break;
+
+ default: out.debug.message(EPrefixError, "Bad unary op");
+ }
+
+ out.debug << " (" << node->getCompleteString() << ")";
+
+ out.debug << "\n";
+
+ return true;
+}
+
+bool OutputAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTraverser* it)
+{
+ TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
+ TInfoSink& out = oit->infoSink;
+
+ if (node->getOp() == EOpNull) {
+ out.debug.message(EPrefixError, "node is still EOpNull!");
+ return true;
+ }
+
+ OutputTreeText(out, node, oit->depth);
+
+ switch (node->getOp()) {
+ case EOpSequence: out.debug << "Sequence\n"; return true;
+ case EOpComma: out.debug << "Comma\n"; return true;
+ case EOpFunction: out.debug << "Function Definition: " << node->getName(); break;
+ case EOpFunctionCall: out.debug << "Function Call: " << node->getName(); break;
+ case EOpParameters: out.debug << "Function Parameters: "; break;
+
+ case EOpConstructFloat: out.debug << "Construct float"; break;
+ case EOpConstructVec2: out.debug << "Construct vec2"; break;
+ case EOpConstructVec3: out.debug << "Construct vec3"; break;
+ case EOpConstructVec4: out.debug << "Construct vec4"; break;
+ case EOpConstructBool: out.debug << "Construct bool"; break;
+ case EOpConstructBVec2: out.debug << "Construct bvec2"; break;
+ case EOpConstructBVec3: out.debug << "Construct bvec3"; break;
+ case EOpConstructBVec4: out.debug << "Construct bvec4"; break;
+ case EOpConstructInt: out.debug << "Construct int"; break;
+ case EOpConstructIVec2: out.debug << "Construct ivec2"; break;
+ case EOpConstructIVec3: out.debug << "Construct ivec3"; break;
+ case EOpConstructIVec4: out.debug << "Construct ivec4"; break;
+ case EOpConstructMat2: out.debug << "Construct mat2"; break;
+ case EOpConstructMat3: out.debug << "Construct mat3"; break;
+ case EOpConstructMat4: out.debug << "Construct mat4"; break;
+ case EOpConstructStruct: out.debug << "Construct structure"; break;
+
+ case EOpLessThan: out.debug << "Compare Less Than"; break;
+ case EOpGreaterThan: out.debug << "Compare Greater Than"; break;
+ case EOpLessThanEqual: out.debug << "Compare Less Than or Equal"; break;
+ case EOpGreaterThanEqual: out.debug << "Compare Greater Than or Equal"; break;
+ case EOpVectorEqual: out.debug << "Equal"; break;
+ case EOpVectorNotEqual: out.debug << "NotEqual"; break;
+
+ case EOpMod: out.debug << "mod"; break;
+ case EOpPow: out.debug << "pow"; break;
+
+ case EOpAtan: out.debug << "arc tangent"; break;
+
+ case EOpMin: out.debug << "min"; break;
+ case EOpMax: out.debug << "max"; break;
+ case EOpClamp: out.debug << "clamp"; break;
+ case EOpMix: out.debug << "mix"; break;
+ case EOpStep: out.debug << "step"; break;
+ case EOpSmoothStep: out.debug << "smoothstep"; break;
+
+ case EOpDistance: out.debug << "distance"; break;
+ case EOpDot: out.debug << "dot-product"; break;
+ case EOpCross: out.debug << "cross-product"; break;
+ case EOpFaceForward: out.debug << "face-forward"; break;
+ case EOpReflect: out.debug << "reflect"; break;
+ case EOpRefract: out.debug << "refract"; break;
+ case EOpMul: out.debug << "component-wise multiply"; break;
+
+ case EOpItof: out.debug << "itof"; break;
+ case EOpFtoi: out.debug << "ftoi"; break;
+ case EOpSkipPixels: out.debug << "skipPixels"; break;
+ case EOpReadInput: out.debug << "readInput"; break;
+ case EOpWritePixel: out.debug << "writePixel"; break;
+ case EOpBitmapLsb: out.debug << "bitmapLSB"; break;
+ case EOpBitmapMsb: out.debug << "bitmapMSB"; break;
+ case EOpWriteOutput: out.debug << "writeOutput"; break;
+ case EOpReadPixel: out.debug << "readPixel"; break;
+
+ default: out.debug.message(EPrefixError, "Bad aggregation op");
+ }
+
+ if (node->getOp() != EOpSequence && node->getOp() != EOpParameters)
+ out.debug << " (" << node->getCompleteString() << ")";
+
+ out.debug << "\n";
+
+ return true;
+}
+
+bool OutputSelection(bool /* preVisit */, TIntermSelection* node, TIntermTraverser* it)
+{
+ TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
+ TInfoSink& out = oit->infoSink;
+
+ OutputTreeText(out, node, oit->depth);
+
+ out.debug << "Test condition and select";
+ out.debug << " (" << node->getCompleteString() << ")\n";
+
+ ++oit->depth;
+
+ OutputTreeText(oit->infoSink, node, oit->depth);
+ out.debug << "Condition\n";
+ node->getCondition()->traverse(it);
+
+ OutputTreeText(oit->infoSink, node, oit->depth);
+ if (node->getTrueBlock()) {
+ out.debug << "true case\n";
+ node->getTrueBlock()->traverse(it);
+ } else
+ out.debug << "true case is null\n";
+
+ if (node->getFalseBlock()) {
+ OutputTreeText(oit->infoSink, node, oit->depth);
+ out.debug << "false case\n";
+ node->getFalseBlock()->traverse(it);
+ }
+
+ --oit->depth;
+
+ return false;
+}
+
+void OutputConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
+{
+ TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
+ TInfoSink& out = oit->infoSink;
+
+ int size = 0;
+ if (node->getType().getBasicType() == EbtStruct)
+ size = node->getType().getStructSize();
+ else
+ size = node->getType().getInstanceSize();
+
+ for (int i = 0; i < size; i++) {
+ OutputTreeText(out, node, oit->depth);
+ switch (node->getType().getBasicType()) {
+ case EbtBool:
+ if (node->getUnionArrayPointer()[i].bConst)
+ out.debug << "true";
+ else
+ out.debug << "false";
+
+ out.debug << " (" << "const bool" << ")";
+
+ out.debug << "\n";
+ break;
+ case EbtFloat:
+ {
+ char buf[300];
+ sprintf(buf, "%f (%s)", node->getUnionArrayPointer()[i].fConst, "const float");
+
+ out.debug << buf << "\n";
+ }
+ break;
+ case EbtInt:
+ {
+ char buf[300];
+ sprintf(buf, "%d (%s)", node->getUnionArrayPointer()[i].iConst, "const int");
+
+ out.debug << buf << "\n";
+ break;
+ }
+ default:
+ out.info.message(EPrefixInternalError, "Unknown constant", node->getLine());
+ break;
+ }
+ }
+}
+
+bool OutputLoop(bool /* preVisit */, TIntermLoop* node, TIntermTraverser* it)
+{
+ TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
+ TInfoSink& out = oit->infoSink;
+
+ OutputTreeText(out, node, oit->depth);
+
+ out.debug << "Loop with condition ";
+ if (! node->testFirst())
+ out.debug << "not ";
+ out.debug << "tested first\n";
+
+ ++oit->depth;
+
+ OutputTreeText(oit->infoSink, node, oit->depth);
+ if (node->getTest()) {
+ out.debug << "Loop Condition\n";
+ node->getTest()->traverse(it);
+ } else
+ out.debug << "No loop condition\n";
+
+ OutputTreeText(oit->infoSink, node, oit->depth);
+ if (node->getBody()) {
+ out.debug << "Loop Body\n";
+ node->getBody()->traverse(it);
+ } else
+ out.debug << "No loop body\n";
+
+ if (node->getTerminal()) {
+ OutputTreeText(oit->infoSink, node, oit->depth);
+ out.debug << "Loop Terminal Expression\n";
+ node->getTerminal()->traverse(it);
+ }
+
+ --oit->depth;
+
+ return false;
+}
+
+bool OutputBranch(bool /* previsit*/, TIntermBranch* node, TIntermTraverser* it)
+{
+ TOutputTraverser* oit = static_cast<TOutputTraverser*>(it);
+ TInfoSink& out = oit->infoSink;
+
+ OutputTreeText(out, node, oit->depth);
+
+ switch (node->getFlowOp()) {
+ case EOpKill: out.debug << "Branch: Kill"; break;
+ case EOpBreak: out.debug << "Branch: Break"; break;
+ case EOpContinue: out.debug << "Branch: Continue"; break;
+ case EOpReturn: out.debug << "Branch: Return"; break;
+ default: out.debug << "Branch: Unknown Branch"; break;
+ }
+
+ if (node->getExpression()) {
+ out.debug << " with expression\n";
+ ++oit->depth;
+ node->getExpression()->traverse(it);
+ --oit->depth;
+ } else
+ out.debug << "\n";
+
+ return false;
+}
+
+//
+// This function is the one to call externally to start the traversal.
+// Individual functions can be initialized to 0 to skip processing of that
+// type of node. It's children will still be processed.
+//
+void TIntermediate::outputTree(TIntermNode* root)
+{
+ if (root == 0)
+ return;
+
+ TOutputTraverser it(infoSink);
+
+ it.visitAggregate = OutputAggregate;
+ it.visitBinary = OutputBinary;
+ it.visitConstantUnion = OutputConstantUnion;
+ it.visitSelection = OutputSelection;
+ it.visitSymbol = OutputSymbol;
+ it.visitUnary = OutputUnary;
+ it.visitLoop = OutputLoop;
+ it.visitBranch = OutputBranch;
+
+ root->traverse(&it);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/localintermediate.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/localintermediate.h
new file mode 100755
index 000000000..5b4e5ea11
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/localintermediate.h
@@ -0,0 +1,91 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#ifndef _LOCAL_INTERMEDIATE_INCLUDED_
+#define _LOCAL_INTERMEDIATE_INCLUDED_
+
+#include "../Include/intermediate.h"
+#include "../Public/ShaderLang.h"
+#include "SymbolTable.h"
+
+struct TVectorFields {
+ int offsets[4];
+ int num;
+};
+
+//
+// Set of helper functions to help parse and build the tree.
+//
+class TInfoSink;
+class TIntermediate {
+public:
+ POOL_ALLOCATOR_NEW_DELETE(GlobalPoolAllocator)
+
+ TIntermediate(TInfoSink& i) : infoSink(i) { }
+ TIntermSymbol* addSymbol(int Id, const TString&, const TType&, TSourceLoc);
+ TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*);
+ TIntermTyped* addBinaryMath(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc, TSymbolTable&);
+ TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
+ TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc);
+ TIntermTyped* addUnaryMath(TOperator op, TIntermNode* child, TSourceLoc, TSymbolTable&);
+ TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right, TSourceLoc);
+ TIntermAggregate* makeAggregate(TIntermNode* node, TSourceLoc);
+ TIntermAggregate* setAggregateOperator(TIntermNode*, TOperator, TSourceLoc);
+ TIntermNode* addSelection(TIntermTyped* cond, TIntermNodePair code, TSourceLoc);
+ TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);
+ TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
+ TIntermConstantUnion* addConstantUnion(constUnion*, const TType&, TSourceLoc);
+ TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
+ TIntermTyped* copyConstUnion(TIntermConstantUnion*) ;
+ TIntermConstantUnion* changeAggrToTempConst(TIntermAggregate*, TSymbolTable&, TSourceLoc );
+ bool parseConstTree(TSourceLoc, TIntermNode*, constUnion*, TOperator, TSymbolTable&, TType, bool singleConstantParam = false);
+ TIntermNode* addLoop(TIntermNode*, TIntermTyped*, TIntermTyped*, bool testFirst, TSourceLoc);
+ TIntermBranch* addBranch(TOperator, TSourceLoc);
+ TIntermBranch* addBranch(TOperator, TIntermTyped*, TSourceLoc);
+ TIntermTyped* addSwizzle(TVectorFields&, TSourceLoc);
+ bool postProcess(TIntermNode*, EShLanguage);
+ void remove(TIntermNode*);
+ void outputTree(TIntermNode*);
+ void removeChildNode(TIntermSequence&, TType&, int&, TIntermSequence::iterator&, TIntermAggregate*);
+ TIntermTyped* removeChildNode(TIntermTyped*, TType*, TIntermAggregate*);
+ bool removeMatrixConstNode(TIntermSequence&, TType&, TIntermAggregate*, int);
+
+protected:
+ TInfoSink& infoSink;
+
+private:
+ void operator=(TIntermediate&); // prevent assignments
+};
+
+#endif // _LOCAL_INTERMEDIATE_INCLUDED_
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/parseConst.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/parseConst.cpp
new file mode 100755
index 000000000..1ea91b3c5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/parseConst.cpp
@@ -0,0 +1,344 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#include "ParseHelper.h"
+
+//
+// Use this class to carry along data from node to node in
+// the traversal
+//
+class TConstTraverser : public TIntermTraverser {
+public:
+ TConstTraverser(constUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, TSymbolTable& symTable, TType& t) : unionArray(cUnion), type(t),
+ constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), symbolTable(symTable), error(false), isMatrix(false), matrixSize(0) { index = 0; tOp = EOpNull;}
+ int index ;
+ constUnion *unionArray;
+ TOperator tOp;
+ TType type;
+ TOperator constructorType;
+ bool singleConstantParam;
+ TInfoSink& infoSink;
+ TSymbolTable& symbolTable;
+ bool error;
+ int size; // size of the constructor ( 4 for vec4)
+ bool isMatrix;
+ int matrixSize; // dimension of the matrix (nominal size and not the instance size)
+};
+
+//
+// The rest of the file are the traversal functions. The last one
+// is the one that starts the traversal.
+//
+// Return true from interior nodes to have the external traversal
+// continue on to children. If you process children yourself,
+// return false.
+//
+
+void ParseSymbol(TIntermSymbol* node, TIntermTraverser* it)
+{
+ TConstTraverser* oit = static_cast<TConstTraverser*>(it);
+ TQualifier qualifier = node->getType().getQualifier();
+ constUnion* unionArray = oit->unionArray;
+ int instanceSize;
+ if (oit->type.getBasicType() == EbtStruct)
+ instanceSize = oit->type.getStructSize();
+ else
+ instanceSize = oit->type.getInstanceSize();
+
+ if (oit->index >= instanceSize)
+ return;
+
+ if (qualifier != EvqConst) {
+ char buf[200];
+ sprintf(buf, "'constructor' : assigning non-constant to %s", oit->type.getCompleteString().c_str());
+ oit->infoSink.info.message(EPrefixError, buf, node->getLine());
+ oit->error = true;
+ return ;
+ }
+ TSymbol* symbol = oit->symbolTable.find(node->getSymbol());
+ TVariable* tVar = static_cast<TVariable*>(symbol);
+
+ constUnion* constArray = tVar->getConstPointer();
+ if (!constArray) {
+ char buf[200];
+ sprintf(buf, "'constructor' : constant '%s' has not been initialized correctly", node->getSymbol().c_str());
+ oit->infoSink.info.message(EPrefixError, buf, node->getLine());
+ oit->error = true;
+ return;
+ }
+ int symbolSize;
+
+ if (tVar->getType().getBasicType() == EbtStruct)
+ symbolSize = tVar->getType().getStructSize();
+ else
+ symbolSize = tVar->getType().getInstanceSize();
+
+ // for constructors such as ivec4(vec4), if vec4 is a symbol node, then the appropriate conversion is required as the
+ // types do not match
+ for (int i = 0; i < symbolSize; i++) {
+ if (oit->index >= instanceSize)
+ return;
+ if (tVar->getType().getBasicType() == oit->type.getBasicType() || oit->type.getBasicType() == EbtStruct)
+ (unionArray[oit->index]) = constArray[i];
+ else {
+ switch (tVar->getType().getBasicType()) {
+ case EbtFloat:
+ switch (oit->type.getBasicType()) {
+ case EbtInt: unionArray[oit->index].iConst = static_cast<int> (constArray[i].fConst); break;
+ case EbtBool: unionArray[oit->index].bConst = constArray[i].fConst != 0.0; break;
+ default: oit->infoSink.info.message(EPrefixInternalError, "Incorrect type, cannot parse symbol", node->getLine()); break;
+ }
+ break;
+ case EbtInt:
+ switch (oit->type.getBasicType()) {
+ case EbtFloat: unionArray[oit->index].fConst = static_cast<float>(constArray[i].iConst); break;
+ case EbtBool: unionArray[oit->index].bConst = constArray[i].iConst != 0 ; break;
+ default: oit->infoSink.info.message(EPrefixInternalError, "Incorrect type, cannot parse symbol", node->getLine()); break;
+ }
+ break;
+ case EbtBool:
+ switch (oit->type.getBasicType()) {
+ case EbtFloat: unionArray[oit->index].fConst = static_cast<float>(constArray[i].bConst); break;
+ case EbtInt: unionArray[oit->index].iConst = static_cast<int> (constArray[i].bConst); break;
+ default: oit->infoSink.info.message(EPrefixInternalError, "Incorrect type, cannot parse symbol", node->getLine()); break;
+ }
+ break;
+ default: oit->infoSink.info.message(EPrefixInternalError, "Incorrect type, cannot parse symbol", node->getLine()); break;
+ }
+ }
+ (oit->index)++;
+ }
+}
+
+bool ParseBinary(bool /* preVisit */, TIntermBinary* node, TIntermTraverser* it)
+{
+ TConstTraverser* oit = static_cast<TConstTraverser*>(it);
+
+ TQualifier qualifier = node->getType().getQualifier();
+
+ if (qualifier != EvqConst) {
+ char buf[200];
+ sprintf(buf, "'constructor' : assigning non-constant to %s", oit->type.getCompleteString().c_str());
+ oit->infoSink.info.message(EPrefixError, buf, node->getLine());
+ oit->error = true;
+ return false;
+ }
+
+ oit->infoSink.info.message(EPrefixInternalError, "Binary Node found in constant constructor", node->getLine());
+
+ return false;
+}
+
+bool ParseUnary(bool /* preVisit */, TIntermUnary* node, TIntermTraverser* it)
+{
+ TConstTraverser* oit = static_cast<TConstTraverser*>(it);
+
+ char buf[200];
+ sprintf(buf, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str());
+ oit->infoSink.info.message(EPrefixError, buf, node->getLine());
+ oit->error = true;
+ return false;
+}
+
+bool ParseAggregate(bool /* preVisit */, TIntermAggregate* node, TIntermTraverser* it)
+{
+ TConstTraverser* oit = static_cast<TConstTraverser*>(it);
+
+ if (!node->isConstructor() && node->getOp() != EOpComma) {
+ char buf[200];
+ sprintf(buf, "'constructor' : assigning non-constant to '%s'", oit->type.getCompleteString().c_str());
+ oit->infoSink.info.message(EPrefixError, buf, node->getLine());
+ oit->error = true;
+ return false;
+ }
+
+ if (node->getSequence().size() == 0) {
+ oit->error = true;
+ return false;
+ }
+
+ bool flag = node->getSequence().size() == 1 && node->getSequence()[0]->getAsTyped()->getAsConstantUnion();
+ if (flag)
+ {
+ oit->singleConstantParam = true;
+ oit->constructorType = node->getOp();
+ if (node->getType().getBasicType() == EbtStruct)
+ oit->size = node->getType().getStructSize();
+ else
+ oit->size = node->getType().getInstanceSize();
+ if (node->getType().isMatrix()) {
+ oit->isMatrix = true;
+ oit->matrixSize = node->getType().getNominalSize();
+ }
+ }
+
+ for (TIntermSequence::iterator p = node->getSequence().begin();
+ p != node->getSequence().end(); p++) {
+
+ if (node->getOp() == EOpComma)
+ oit->index = 0;
+
+ (*p)->traverse(oit);
+ }
+ if (flag)
+ {
+ oit->singleConstantParam = false;
+ oit->constructorType = EOpNull;
+ oit->size = 0;
+ oit->isMatrix = false;
+ oit->matrixSize = 0;
+ }
+ return false;
+}
+
+bool ParseSelection(bool /* preVisit */, TIntermSelection* node, TIntermTraverser* it)
+{
+ TConstTraverser* oit = static_cast<TConstTraverser*>(it);
+ oit->infoSink.info.message(EPrefixInternalError, "Selection Node found in constant constructor", node->getLine());
+ oit->error = true;
+ return false;
+}
+
+void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
+{
+ TConstTraverser* oit = static_cast<TConstTraverser*>(it);
+ constUnion* leftUnionArray = oit->unionArray;
+ int instanceSize;
+ if (oit->type.getBasicType() == EbtStruct)
+ instanceSize = oit->type.getStructSize();
+ else
+ instanceSize = oit->type.getInstanceSize();
+
+ if (oit->index >= instanceSize)
+ return;
+
+ if (!oit->singleConstantParam) {
+ int size;
+ if (node->getType().getBasicType() == EbtStruct)
+ size = node->getType().getStructSize();
+ else
+ size = node->getType().getInstanceSize();
+
+ constUnion *rightUnionArray = node->getUnionArrayPointer();
+ for (int i=0; i < size; i++) {
+ if (oit->index >= instanceSize)
+ return;
+ leftUnionArray[oit->index] = rightUnionArray[i];
+
+ (oit->index)++;
+ }
+ } else {
+ int size, totalSize, matrixSize;
+ bool isMatrix = false;
+ size = oit->size;
+ matrixSize = oit->matrixSize;
+ isMatrix = oit->isMatrix;
+ totalSize = oit->index + size ;
+ constUnion *rightUnionArray = node->getUnionArrayPointer();
+ if (!isMatrix) {
+ int count = 0;
+ for (int i = oit->index; i < totalSize; i++) {
+ if (i >= instanceSize)
+ return;
+
+ leftUnionArray[i] = rightUnionArray[count];
+
+ (oit->index)++;
+ if (node->getType().getBasicType() == EbtStruct && node->getType().getStructSize() > 1 ||
+ node->getType().getBasicType() != EbtStruct && node->getType().getInstanceSize() > 1)
+ count++;
+ }
+ } else { // for matrix constructors
+ int count = 0;
+ int index = oit->index;
+ for (int i = index; i < totalSize; i++) {
+ if (i >= instanceSize)
+ return;
+ if (index - i == 0 || (i - index) % (matrixSize + 1) == 0 )
+ leftUnionArray[i] = rightUnionArray[count];
+ else
+ leftUnionArray[i].fConst = 0.0;
+
+ (oit->index)++;
+ if (node->getType().getBasicType() == EbtStruct && node->getType().getStructSize() > 1 ||
+ node->getType().getBasicType() != EbtStruct && node->getType().getInstanceSize() > 1)
+ count++;
+ }
+ }
+ }
+}
+
+bool ParseLoop(bool /* preVisit */, TIntermLoop* node, TIntermTraverser* it)
+{
+ TConstTraverser* oit = static_cast<TConstTraverser*>(it);
+ oit->infoSink.info.message(EPrefixInternalError, "Loop Node found in constant constructor", node->getLine());
+ oit->error = true;
+ return false;
+}
+
+bool ParseBranch(bool /* previsit*/, TIntermBranch* node, TIntermTraverser* it)
+{
+ TConstTraverser* oit = static_cast<TConstTraverser*>(it);
+ oit->infoSink.info.message(EPrefixInternalError, "Branch Node found in constant constructor", node->getLine());
+ oit->error = true;
+ return false;
+}
+
+//
+// This function is the one to call externally to start the traversal.
+// Individual functions can be initialized to 0 to skip processing of that
+// type of node. It's children will still be processed.
+//
+bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, constUnion* unionArray, TOperator constructorType, TSymbolTable& symbolTable, TType t, bool singleConstantParam)
+{
+ if (root == 0)
+ return false;
+
+ TConstTraverser it(unionArray, singleConstantParam, constructorType, infoSink, symbolTable, t);
+
+ it.visitAggregate = ParseAggregate;
+ it.visitBinary = ParseBinary;
+ it.visitConstantUnion = ParseConstantUnion;
+ it.visitSelection = ParseSelection;
+ it.visitSymbol = ParseSymbol;
+ it.visitUnary = ParseUnary;
+ it.visitLoop = ParseLoop;
+ it.visitBranch = ParseBranch;
+
+ root->traverse(&it);
+ if (it.error)
+ return true;
+ else
+ return false;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/atom.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/atom.c
new file mode 100755
index 000000000..b409c99bb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/atom.c
@@ -0,0 +1,768 @@
+/* */
+/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
+/*All rights reserved. */
+/* */
+/*Redistribution and use in source and binary forms, with or without */
+/*modification, are permitted provided that the following conditions */
+/*are met: */
+/* */
+/* Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* */
+/* Redistributions in binary form must reproduce the above */
+/* copyright notice, this list of conditions and the following */
+/* disclaimer in the documentation and/or other materials provided */
+/* with the distribution. */
+/* */
+/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
+/* contributors may be used to endorse or promote products derived */
+/* from this software without specific prior written permission. */
+/* */
+/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
+/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
+/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
+/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
+/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
+/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
+/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
+/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
+/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
+/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/*POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+
+/* */
+/* atom.c */
+/* */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "slglobals.h"
+
+#undef malloc
+#undef realloc
+#undef free
+
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+/*//////////////////////////////////////// String table: ////////////////////////////////////// */
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+
+static const struct {
+ int val;
+ const char *str;
+} tokens[] = {
+ { CPP_AND_OP, "&&" },
+ { CPP_AND_ASSIGN, "&=" },
+ { CPP_SUB_ASSIGN, "-=" },
+ { CPP_MOD_ASSIGN, "%=" },
+ { CPP_ADD_ASSIGN, "+=" },
+ { CPP_DIV_ASSIGN, "/=" },
+ { CPP_MUL_ASSIGN, "*=" },
+ { CPP_RIGHT_BRACKET, ":>" },
+ { CPP_EQ_OP, "==" },
+ { CPP_XOR_OP, "^^" },
+ { CPP_XOR_ASSIGN, "^=" },
+ { CPP_FLOATCONSTANT, "<float-const>" },
+ { CPP_GE_OP, ">=" },
+ { CPP_RIGHT_OP, ">>" },
+ { CPP_RIGHT_ASSIGN, ">>=" },
+ { CPP_IDENTIFIER, "<ident>" },
+ { CPP_INTCONSTANT, "<int-const>" },
+ { CPP_LE_OP, "<=" },
+ { CPP_LEFT_OP, "<<" },
+ { CPP_LEFT_ASSIGN, "<<=" },
+ { CPP_LEFT_BRACKET, "<:" },
+ { CPP_LEFT_BRACE, "<%" },
+ { CPP_DEC_OP, "--" },
+ { CPP_RIGHT_BRACE, "%>" },
+ { CPP_NE_OP, "!=" },
+ { CPP_OR_OP, "||" },
+ { CPP_OR_ASSIGN, "|=" },
+ { CPP_INC_OP, "++" },
+ { CPP_STRCONSTANT, "<string-const>" },
+ { CPP_TYPEIDENTIFIER, "<type-ident>" },
+};
+
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+/*//////////////////////////////////////// String table: ////////////////////////////////////// */
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+
+#define INIT_STRING_TABLE_SIZE 16384
+
+typedef struct StringTable_Rec {
+ char *strings;
+ int nextFree;
+ int size;
+} StringTable;
+
+/*
+ * InitStringTable() - Initialize the string table.
+ *
+ */
+
+static int InitStringTable(StringTable *stable)
+{
+ stable->strings = (char *) malloc(INIT_STRING_TABLE_SIZE);
+ if (!stable->strings)
+ return 0;
+ /* Zero-th offset means "empty" so don't use it. */
+ stable->nextFree = 1;
+ stable->size = INIT_STRING_TABLE_SIZE;
+ return 1;
+} /* InitStringTable */
+
+/*
+ * FreeStringTable() - Free the string table.
+ *
+ */
+
+static void FreeStringTable(StringTable *stable)
+{
+ if (stable->strings)
+ free(stable->strings);
+ stable->strings = NULL;
+ stable->nextFree = 0;
+ stable->size = 0;
+} /* FreeStringTable */
+
+/*
+ * HashString() - Hash a string with the base hash function.
+ *
+ */
+
+static int HashString(const char *s)
+{
+ int hval = 0;
+
+ while (*s) {
+ hval = (hval*13507 + *s*197) ^ (hval >> 2);
+ s++;
+ }
+ return hval & 0x7fffffff;
+} /* HashString */
+
+/*
+ * HashString2() - Hash a string with the incrimenting hash function.
+ *
+ */
+
+static int HashString2(const char *s)
+{
+ int hval = 0;
+
+ while (*s) {
+ hval = (hval*729 + *s*37) ^ (hval >> 1);
+ s++;
+ }
+ return hval;
+} /* HashString2 */
+
+/*
+ * AddString() - Add a string to a string table. Return it's offset.
+ *
+ */
+
+static int AddString(StringTable *stable, const char *s)
+{
+ int len, loc;
+ char *str;
+
+ len = (int) strlen(s);
+ if (stable->nextFree + len + 1 >= stable->size) {
+ assert(stable->size < 1000000);
+ str = (char *) malloc(stable->size*2);
+ memcpy(str, stable->strings, stable->size);
+ free(stable->strings);
+ stable->strings = str;
+ }
+ loc = stable->nextFree;
+ strcpy(&stable->strings[loc], s);
+ stable->nextFree += len + 1;
+ return loc;
+} /* AddString */
+
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+/*///////////////////////////////////////// Hash table: /////////////////////////////////////// */
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+
+#define INIT_HASH_TABLE_SIZE 2047
+#define HASH_TABLE_MAX_COLLISIONS 3
+
+typedef struct HashEntry_Rec {
+ int index; /* String table offset of string representation */
+ int value; /* Atom (symbol) value */
+} HashEntry;
+
+typedef struct HashTable_Rec {
+ HashEntry *entry;
+ int size;
+ int entries;
+ int counts[HASH_TABLE_MAX_COLLISIONS + 1];
+} HashTable;
+
+/*
+ * InitHashTable() - Initialize the hash table.
+ *
+ */
+
+static int InitHashTable(HashTable *htable, int fsize)
+{
+ int ii;
+
+ htable->entry = (HashEntry *) malloc(sizeof(HashEntry)*fsize);
+ if (!htable->entry)
+ return 0;
+ htable->size = fsize;
+ for (ii = 0; ii < fsize; ii++) {
+ htable->entry[ii].index = 0;
+ htable->entry[ii].value = 0;
+ }
+ htable->entries = 0;
+ for (ii = 0; ii <= HASH_TABLE_MAX_COLLISIONS; ii++)
+ htable->counts[ii] = 0;
+ return 1;
+} /* InitHashTable */
+
+/*
+ * FreeHashTable() - Free the hash table.
+ *
+ */
+
+static void FreeHashTable(HashTable *htable)
+{
+ if (htable->entry)
+ free(htable->entry);
+ htable->entry = NULL;
+ htable->size = 0;
+ htable->entries = 0;
+} /* FreeHashTable */
+
+/*
+ * Empty() - See if a hash table entry is empty.
+ *
+ */
+
+static int Empty(HashTable *htable, int hashloc)
+{
+ assert(hashloc >= 0 && hashloc < htable->size);
+ if (htable->entry[hashloc].index == 0) {
+ return 1;
+ } else {
+ return 0;
+ }
+} /* Empty */
+
+/*
+ * Match() - See if a hash table entry is matches a string.
+ *
+ */
+
+static int Match(HashTable *htable, StringTable *stable, const char *s, int hashloc)
+{
+ int strloc;
+
+ strloc = htable->entry[hashloc].index;
+ if (!strcmp(s, &stable->strings[strloc])) {
+ return 1;
+ } else {
+ return 0;
+ }
+} /* Match */
+
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+/*///////////////////////////////////////// Atom table: /////////////////////////////////////// */
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+
+#define INIT_ATOM_TABLE_SIZE 1024
+
+
+struct AtomTable_Rec {
+ StringTable stable; /* String table. */
+ HashTable htable; /* Hashes string to atom number and token value. Multiple strings can */
+ /* have the same token value but each unique string is a unique atom. */
+ int *amap; /* Maps atom value to offset in string table. Atoms all map to unique */
+ /* strings except for some undefined values in the lower, fixed part */
+ /* of the atom table that map to "<undefined>". The lowest 256 atoms */
+ /* correspond to single character ASCII values except for alphanumeric */
+ /* characters and '_', which can be other tokens. Next come the */
+ /* language tokens with their atom values equal to the token value. */
+ /* Then come predefined atoms, followed by user specified identifiers. */
+ int *arev; /* Reversed atom for symbol table use. */
+ int nextFree;
+ int size;
+};
+
+static AtomTable latable = { { 0 } };
+AtomTable *atable = &latable;
+
+static int AddAtomFixed(AtomTable *atable, const char *s, int atom);
+
+/*
+ * GrowAtomTable() - Grow the atom table to at least "size" if it's smaller.
+ *
+ */
+
+static int GrowAtomTable(AtomTable *atable, int size)
+{
+ int *newmap, *newrev;
+
+ if (atable->size < size) {
+ if (atable->amap) {
+ newmap = realloc(atable->amap, sizeof(int)*size);
+ newrev = realloc(atable->arev, sizeof(int)*size);
+ } else {
+ newmap = malloc(sizeof(int)*size);
+ newrev = malloc(sizeof(int)*size);
+ atable->size = 0;
+ }
+ if (!newmap || !newrev) {
+ /* failed to grow -- error */
+ if (newmap)
+ atable->amap = newmap;
+ if (newrev)
+ atable->amap = newrev;
+ return -1;
+ }
+ memset(&newmap[atable->size], 0, (size - atable->size) * sizeof(int));
+ memset(&newrev[atable->size], 0, (size - atable->size) * sizeof(int));
+ atable->amap = newmap;
+ atable->arev = newrev;
+ atable->size = size;
+ }
+ return 0;
+} /* GrowAtomTable */
+
+/*
+ * lReverse() - Reverse the bottom 20 bits of a 32 bit int.
+ *
+ */
+
+static int lReverse(int fval)
+{
+ unsigned int in = fval;
+ int result = 0, cnt = 0;
+
+ while(in) {
+ result <<= 1;
+ result |= in&1;
+ in >>= 1;
+ cnt++;
+ }
+
+ /* Don't use all 31 bits. One million atoms is plenty and sometimes the */
+ /* upper bits are used for other things. */
+
+ if (cnt < 20)
+ result <<= 20 - cnt;
+ return result;
+} /* lReverse */
+
+/*
+ * AllocateAtom() - Allocate a new atom. Associated with the "undefined" value of -1.
+ *
+ */
+
+static int AllocateAtom(AtomTable *atable)
+{
+ if (atable->nextFree >= atable->size)
+ GrowAtomTable(atable, atable->nextFree*2);
+ atable->amap[atable->nextFree] = -1;
+ atable->arev[atable->nextFree] = lReverse(atable->nextFree);
+ atable->nextFree++;
+ return atable->nextFree - 1;
+} /* AllocateAtom */
+
+/*
+ * SetAtomValue() - Allocate a new atom associated with "hashindex".
+ *
+ */
+
+static void SetAtomValue(AtomTable *atable, int atomnumber, int hashindex)
+{
+ atable->amap[atomnumber] = atable->htable.entry[hashindex].index;
+ atable->htable.entry[hashindex].value = atomnumber;
+} /* SetAtomValue */
+
+/*
+ * FindHashLoc() - Find the hash location for this string. Return -1 it hash table is full.
+ *
+ */
+
+static int FindHashLoc(AtomTable *atable, const char *s)
+{
+ int hashloc, hashdelta, count;
+ int FoundEmptySlot = 0;
+ int collision[HASH_TABLE_MAX_COLLISIONS + 1];
+
+ hashloc = HashString(s) % atable->htable.size;
+ if (!Empty(&atable->htable, hashloc)) {
+ if (Match(&atable->htable, &atable->stable, s, hashloc))
+ return hashloc;
+ collision[0] = hashloc;
+ hashdelta = HashString2(s);
+ count = 0;
+ while (count < HASH_TABLE_MAX_COLLISIONS) {
+ hashloc = ((hashloc + hashdelta) & 0x7fffffff) % atable->htable.size;
+ if (!Empty(&atable->htable, hashloc)) {
+ if (Match(&atable->htable, &atable->stable, s, hashloc)) {
+ return hashloc;
+ }
+ } else {
+ FoundEmptySlot = 1;
+ break;
+ }
+ count++;
+ collision[count] = hashloc;
+ }
+
+ if (!FoundEmptySlot) {
+ if (cpp->options.DumpAtomTable) {
+ int ii;
+ char str[200];
+ sprintf(str, "*** Hash failed with more than %d collisions. Must increase hash table size. ***",
+ HASH_TABLE_MAX_COLLISIONS);
+ CPPShInfoLogMsg(str);
+
+ sprintf(str, "*** New string \"%s\", hash=%04x, delta=%04x", s, collision[0], hashdelta);
+ CPPShInfoLogMsg(str);
+ for (ii = 0; ii <= HASH_TABLE_MAX_COLLISIONS; ii++) {
+ sprintf(str, "*** Collides on try %d at hash entry %04x with \"%s\"",
+ ii + 1, collision[ii], GetAtomString(atable, atable->htable.entry[collision[ii]].value));
+ CPPShInfoLogMsg(str);
+ }
+ }
+ return -1;
+ } else {
+ atable->htable.counts[count]++;
+ }
+ }
+ return hashloc;
+} /* FindHashLoc */
+
+/*
+ * IncreaseHashTableSize()
+ *
+ */
+
+static int IncreaseHashTableSize(AtomTable *atable)
+{
+ int ii, strloc, oldhashloc, value, size;
+ AtomTable oldtable;
+ char *s;
+
+ /* Save the old atom table and create a new one: */
+
+ oldtable = *atable;
+ size = oldtable.htable.size*2 + 1;
+ if (!InitAtomTable(atable, size))
+ return 0;
+
+ /* Add all the existing values to the new atom table preserving their atom values: */
+
+ for (ii = atable->nextFree; ii < oldtable.nextFree; ii++) {
+ strloc = oldtable.amap[ii];
+ s = &oldtable.stable.strings[strloc];
+ oldhashloc = FindHashLoc(&oldtable, s);
+ assert(oldhashloc >= 0);
+ value = oldtable.htable.entry[oldhashloc].value;
+ AddAtomFixed(atable, s, value);
+ }
+ FreeAtomTable(&oldtable);
+ return 1;
+} /* IncreaseHashTableSize */
+
+/*
+ * LookUpAddStringHash() - Lookup a string in the hash table. If it's not there, add it and
+ * initialize the atom value in the hash table to 0. Return the hash table index.
+ */
+
+static int LookUpAddStringHash(AtomTable *atable, const char *s)
+{
+ int hashloc, strloc;
+
+ while(1) {
+ hashloc = FindHashLoc(atable, s);
+ if (hashloc >= 0)
+ break;
+ IncreaseHashTableSize(atable);
+ }
+
+ if (Empty(&atable->htable, hashloc)) {
+ atable->htable.entries++;
+ strloc = AddString(&atable->stable, s);
+ atable->htable.entry[hashloc].index = strloc;
+ atable->htable.entry[hashloc].value = 0;
+ }
+ return hashloc;
+} /* LookUpAddStringHash */
+
+/*
+ * LookUpAddString() - Lookup a string in the hash table. If it's not there, add it and
+ * initialize the atom value in the hash table to the next atom number.
+ * Return the atom value of string.
+ */
+
+int LookUpAddString(AtomTable *atable, const char *s)
+{
+ int hashindex, atom;
+
+ hashindex = LookUpAddStringHash(atable, s);
+ atom = atable->htable.entry[hashindex].value;
+ if (atom == 0) {
+ atom = AllocateAtom(atable);
+ SetAtomValue(atable, atom, hashindex);
+ }
+ return atom;
+} /* LookUpAddString */
+
+/*
+ * GetAtomString()
+ *
+ */
+
+const char *GetAtomString(AtomTable *atable, int atom)
+{
+ int soffset;
+
+ if (atom > 0 && atom < atable->nextFree) {
+ soffset = atable->amap[atom];
+ if (soffset > 0 && soffset < atable->stable.nextFree) {
+ return &atable->stable.strings[soffset];
+ } else {
+ return "<internal error: bad soffset>";
+ }
+ } else {
+ if (atom == 0) {
+ return "<null atom>";
+ } else {
+ if (atom == EOF) {
+ return "<EOF>";
+ } else {
+ return "<invalid atom>";
+ }
+ }
+ }
+} /* GetAtomString */
+
+/*
+ * GetReversedAtom()
+ *
+ */
+
+int GetReversedAtom(AtomTable *atable, int atom)
+{
+ if (atom > 0 && atom < atable->nextFree) {
+ return atable->arev[atom];
+ } else {
+ return 0;
+ }
+} /* GetReversedAtom */
+
+/*
+ * AddAtom() - Add a string to the atom, hash and string tables if it isn't already there.
+ * Return it's atom index.
+ */
+
+int AddAtom(AtomTable *atable, const char *s)
+{
+ int atom;
+
+ atom = LookUpAddString(atable, s);
+ return atom;
+} /* AddAtom */
+
+/*
+ * AddAtomFixed() - Add an atom to the hash and string tables if it isn't already there.
+ * Assign it the atom value of "atom".
+ */
+
+static int AddAtomFixed(AtomTable *atable, const char *s, int atom)
+{
+ int hashindex, lsize;
+
+ hashindex = LookUpAddStringHash(atable, s);
+ if (atable->nextFree >= atable->size || atom >= atable->size) {
+ lsize = atable->size*2;
+ if (lsize <= atom)
+ lsize = atom + 1;
+ GrowAtomTable(atable, lsize);
+ }
+ atable->amap[atom] = atable->htable.entry[hashindex].index;
+ atable->htable.entry[hashindex].value = atom;
+ /*if (atom >= atable->nextFree) */
+ /* atable->nextFree = atom + 1; */
+ while (atom >= atable->nextFree) {
+ atable->arev[atable->nextFree] = lReverse(atable->nextFree);
+ atable->nextFree++;
+ }
+ return atom;
+} /* AddAtomFixed */
+
+/*
+ * InitAtomTable() - Initialize the atom table.
+ *
+ */
+
+int InitAtomTable(AtomTable *atable, int htsize)
+{
+ int ii;
+
+ htsize = htsize <= 0 ? INIT_HASH_TABLE_SIZE : htsize;
+ if (!InitStringTable(&atable->stable))
+ return 0;
+ if (!InitHashTable(&atable->htable, htsize))
+ return 0;
+
+ atable->nextFree = 0;
+ atable->amap = NULL;
+ atable->size = 0;
+ GrowAtomTable(atable, INIT_ATOM_TABLE_SIZE);
+ if (!atable->amap)
+ return 0;
+
+ /* Initialize lower part of atom table to "<undefined>" atom: */
+
+ AddAtomFixed(atable, "<undefined>", 0);
+ for (ii = 0; ii < FIRST_USER_TOKEN_SY; ii++)
+ atable->amap[ii] = atable->amap[0];
+
+ /* Add single character tokens to the atom table: */
+
+ {
+ const char *s = "~!%^&*()-+=|,.<>/?;:[]{}#";
+ char t[2];
+
+ t[1] = '\0';
+ while (*s) {
+ t[0] = *s;
+ AddAtomFixed(atable, t, s[0]);
+ s++;
+ }
+ }
+
+ /* Add multiple character scanner tokens : */
+
+ for (ii = 0; ii < sizeof(tokens)/sizeof(tokens[0]); ii++)
+ AddAtomFixed(atable, tokens[ii].str, tokens[ii].val);
+
+ /* Add error symbol if running in error mode: */
+
+ if (cpp->options.ErrorMode)
+ AddAtomFixed(atable, "error", ERROR_SY);
+
+ AddAtom(atable, "<*** end fixed atoms ***>");
+
+ return 1;
+} /* InitAtomTable */
+
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+/*//////////////////////////////// Debug Printing Functions: ////////////////////////////////// */
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+
+/*
+ * PrintAtomTable()
+ *
+ */
+
+void PrintAtomTable(AtomTable *atable)
+{
+ int ii;
+ char str[200];
+
+ for (ii = 0; ii < atable->nextFree; ii++) {
+ sprintf(str, "%d: \"%s\"", ii, &atable->stable.strings[atable->amap[ii]]);
+ CPPDebugLogMsg(str);
+ }
+ sprintf(str, "Hash table: size=%d, entries=%d, collisions=",
+ atable->htable.size, atable->htable.entries);
+ CPPDebugLogMsg(str);
+ for (ii = 0; ii < HASH_TABLE_MAX_COLLISIONS; ii++) {
+ sprintf(str, " %d", atable->htable.counts[ii]);
+ CPPDebugLogMsg(str);
+ }
+
+} /* PrintAtomTable */
+
+
+/*
+ * GetStringOfAtom()
+ *
+ */
+
+char* GetStringOfAtom(AtomTable *atable, int atom)
+{
+ char* chr_str;
+ chr_str=&atable->stable.strings[atable->amap[atom]];
+ return chr_str;
+} /* GetStringOfAtom */
+
+/*
+ * FreeAtomTable() - Free the atom table and associated memory
+ *
+ */
+
+void FreeAtomTable(AtomTable *atable)
+{
+ FreeStringTable(&atable->stable);
+ FreeHashTable(&atable->htable);
+ if (atable->amap)
+ free(atable->amap);
+ if (atable->arev)
+ free(atable->arev);
+ atable->amap = NULL;
+ atable->arev = NULL;
+ atable->nextFree = 0;
+ atable->size = 0;
+} /* FreeAtomTable */
+
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+/*/////////////////////////////////////// End of atom.c /////////////////////////////////////// */
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/atom.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/atom.h
new file mode 100755
index 000000000..4e509d6ba
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/atom.h
@@ -0,0 +1,96 @@
+/* */
+/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
+/*All rights reserved. */
+/* */
+/*Redistribution and use in source and binary forms, with or without */
+/*modification, are permitted provided that the following conditions */
+/*are met: */
+/* */
+/* Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* */
+/* Redistributions in binary form must reproduce the above */
+/* copyright notice, this list of conditions and the following */
+/* disclaimer in the documentation and/or other materials provided */
+/* with the distribution. */
+/* */
+/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
+/* contributors may be used to endorse or promote products derived */
+/* from this software without specific prior written permission. */
+/* */
+/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
+/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
+/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
+/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
+/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
+/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
+/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
+/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
+/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
+/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/*POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/* */
+/* atom.h */
+/* */
+
+#if !defined(__ATOM_H)
+#define __ATOM_H 1
+
+typedef struct AtomTable_Rec AtomTable;
+
+extern AtomTable *atable;
+
+int InitAtomTable(AtomTable *atable, int htsize);
+void FreeAtomTable(AtomTable *atable);
+int AddAtom(AtomTable *atable, const char *s);
+void PrintAtomTable(AtomTable *atable);
+int LookUpAddString(AtomTable *atable, const char *s);
+const char *GetAtomString(AtomTable *atable, int atom);
+int GetReversedAtom(AtomTable *atable, int atom);
+char* GetStringOfAtom(AtomTable *atable, int atom);
+#endif /* !defined(__ATOM_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/compile.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/compile.h
new file mode 100755
index 000000000..24673461e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/compile.h
@@ -0,0 +1,132 @@
+/* */
+/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
+/*All rights reserved. */
+/* */
+/*Redistribution and use in source and binary forms, with or without */
+/*modification, are permitted provided that the following conditions */
+/*are met: */
+/* */
+/* Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* */
+/* Redistributions in binary form must reproduce the above */
+/* copyright notice, this list of conditions and the following */
+/* disclaimer in the documentation and/or other materials provided */
+/* with the distribution. */
+/* */
+/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
+/* contributors may be used to endorse or promote products derived */
+/* from this software without specific prior written permission. */
+/* */
+/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
+/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
+/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
+/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
+/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
+/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
+/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
+/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
+/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
+/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/*POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/* */
+/* compile.h */
+/* */
+
+#if !defined(__COMPILE_H)
+#define __COMPILE_H 1
+
+int InitCPPStruct(void);
+
+typedef struct Options_Rec{
+ const char *profileString;
+ int ErrorMode;
+ int Quiet;
+
+ /* Debug The Compiler options: */
+ int DumpAtomTable;
+} Options;
+
+struct CPPStruct_Rec {
+ /* Public members */
+ SourceLoc *pLastSourceLoc; /* Set at the start of each statement by the tree walkers */
+ Options options; /* Compile options and parameters */
+
+ /* Private members */
+ SourceLoc lastSourceLoc;
+
+ /* Scanner data: */
+
+ SourceLoc *tokenLoc; /* Source location of most recent token seen by the scanner */
+ int mostRecentToken; /* Most recent token seen by the scanner */
+ InputSrc *currentInput;
+ int previous_token;
+ int notAVersionToken; /* used to make sure that #version is the first token seen in the file, if present */
+
+ void *pC; /* storing the parseContext of the compile object in cpp. */
+
+ /* Private members: */
+ SourceLoc ltokenLoc;
+ int ifdepth; /*current #if-#else-#endif nesting in the cpp.c file (pre-processor) */
+ int elsedepth[64]; /*Keep a track of #if depth..Max allowed is 64. */
+ int elsetracker; /*#if-#else and #endif constructs...Counter. */
+ const char *ErrMsg;
+ int CompileError; /*Indicate compile error when #error, #else,#elif mismatch. */
+
+ /* */
+ /* Globals used to communicate between PaParseStrings() and yy_input()and */
+ /* also across the files.(gen_glslang.cpp and scanner.c) */
+ /* */
+ int PaWhichStr; /* which string we're parsing */
+ int* PaStrLen; /* array of lengths of the PaArgv strings */
+ int PaArgc; /* count of strings in the array */
+ char** PaArgv; /* our array of strings to parse */
+ unsigned int tokensBeforeEOF : 1;
+};
+
+#endif /* !defined(__COMPILE_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/cpp.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/cpp.c
new file mode 100755
index 000000000..f8da59b38
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/cpp.c
@@ -0,0 +1,1037 @@
+/* */
+/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
+/*All rights reserved. */
+/* */
+/*Redistribution and use in source and binary forms, with or without */
+/*modification, are permitted provided that the following conditions */
+/*are met: */
+/* */
+/* Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* */
+/* Redistributions in binary form must reproduce the above */
+/* copyright notice, this list of conditions and the following */
+/* disclaimer in the documentation and/or other materials provided */
+/* with the distribution. */
+/* */
+/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
+/* contributors may be used to endorse or promote products derived */
+/* from this software without specific prior written permission. */
+/* */
+/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
+/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
+/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
+/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
+/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
+/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
+/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
+/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
+/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
+/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/*POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/* */
+/* cpp.c */
+/* */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "slglobals.h"
+
+static int CPPif(yystypepp * yylvalpp);
+
+/* Don't use memory.c's replacements, as we clean up properly here */
+#undef malloc
+#undef free
+
+static int bindAtom = 0;
+static int constAtom = 0;
+static int defaultAtom = 0;
+static int defineAtom = 0;
+static int definedAtom = 0;
+static int elseAtom = 0;
+static int elifAtom = 0;
+static int endifAtom = 0;
+static int ifAtom = 0;
+static int ifdefAtom = 0;
+static int ifndefAtom = 0;
+static int includeAtom = 0;
+static int lineAtom = 0;
+static int pragmaAtom = 0;
+static int texunitAtom = 0;
+static int undefAtom = 0;
+static int errorAtom = 0;
+static int __LINE__Atom = 0;
+static int __FILE__Atom = 0;
+static int __VERSION__Atom = 0;
+static int versionAtom = 0;
+static int extensionAtom = 0;
+
+static Scope *macros = 0;
+#define MAX_MACRO_ARGS 64
+#define MAX_IF_NESTING 64
+
+static SourceLoc ifloc; /* outermost #if */
+
+int InitCPP(void)
+{
+ char buffer[64], *t;
+ const char *f;
+ /* Add various atoms needed by the CPP line scanner: */
+ bindAtom = LookUpAddString(atable, "bind");
+ constAtom = LookUpAddString(atable, "const");
+ defaultAtom = LookUpAddString(atable, "default");
+ defineAtom = LookUpAddString(atable, "define");
+ definedAtom = LookUpAddString(atable, "defined");
+ elifAtom = LookUpAddString(atable, "elif");
+ elseAtom = LookUpAddString(atable, "else");
+ endifAtom = LookUpAddString(atable, "endif");
+ ifAtom = LookUpAddString(atable, "if");
+ ifdefAtom = LookUpAddString(atable, "ifdef");
+ ifndefAtom = LookUpAddString(atable, "ifndef");
+ includeAtom = LookUpAddString(atable, "include");
+ lineAtom = LookUpAddString(atable, "line");
+ pragmaAtom = LookUpAddString(atable, "pragma");
+ texunitAtom = LookUpAddString(atable, "texunit");
+ undefAtom = LookUpAddString(atable, "undef");
+ errorAtom = LookUpAddString(atable, "error");
+ __LINE__Atom = LookUpAddString(atable, "__LINE__");
+ __FILE__Atom = LookUpAddString(atable, "__FILE__");
+ __VERSION__Atom = LookUpAddString(atable, "__VERSION__");
+ versionAtom = LookUpAddString(atable, "version");
+ extensionAtom = LookUpAddString(atable, "extension");
+ macros = NewScopeInPool(mem_CreatePool(0, 0));
+ strcpy(buffer, "PROFILE_");
+ t = buffer + strlen(buffer);
+ f = cpp->options.profileString;
+ while ((isalnum(*f) || *f == '_') && t < buffer + sizeof(buffer) - 1)
+ *t++ = toupper(*f++);
+ *t = 0;
+ return 1;
+} /* InitCPP */
+
+int FreeCPP(void)
+{
+ if (macros)
+ {
+ mem_FreePool(macros->pool);
+ macros = 0;
+ }
+
+ return 1;
+}
+
+int FinalCPP(void)
+{
+ if (cpp->ifdepth)
+ CPPErrorToInfoLog("#if mismatch");
+ return 1;
+}
+
+static int CPPdefine(yystypepp * yylvalpp)
+{
+ int token, name, args[MAX_MACRO_ARGS], argc;
+ const char *message;
+ MacroSymbol mac;
+ Symbol *symb;
+ SourceLoc dummyLoc;
+ memset(&mac, 0, sizeof(mac));
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (token != CPP_IDENTIFIER) {
+ CPPErrorToInfoLog("#define");
+ return token;
+ }
+ name = yylvalpp->sc_ident;
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (token == '(' && !yylvalpp->sc_int) {
+ /* gather arguments */
+ argc = 0;
+ do {
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (argc == 0 && token == ')') break;
+ if (token != CPP_IDENTIFIER) {
+ CPPErrorToInfoLog("#define");
+ return token;
+ }
+ if (argc < MAX_MACRO_ARGS)
+ args[argc++] = yylvalpp->sc_ident;
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ } while (token == ',');
+ if (token != ')') {
+ CPPErrorToInfoLog("#define");
+ return token;
+ }
+ mac.argc = argc;
+ mac.args = mem_Alloc(macros->pool, argc * sizeof(int));
+ memcpy(mac.args, args, argc * sizeof(int));
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ }
+ mac.body = NewTokenStream(GetAtomString(atable, name));
+ while (token != '\n') {
+ while (token == '\\') {
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (token == '\n')
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ else
+ RecordToken(mac.body, '\\', yylvalpp);
+ }
+ RecordToken(mac.body, token, yylvalpp);
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ };
+
+ symb = LookUpSymbol(macros, name);
+ if (symb) {
+ if (!symb->details.mac.undef) {
+ /* already defined -- need to make sure they are identical */
+ if (symb->details.mac.argc != mac.argc) goto error;
+ for (argc=0; argc < mac.argc; argc++)
+ if (symb->details.mac.args[argc] != mac.args[argc])
+ goto error;
+ RewindTokenStream(symb->details.mac.body);
+ RewindTokenStream(mac.body);
+ do {
+ int old_lval, old_token;
+ old_token = ReadToken(symb->details.mac.body, yylvalpp);
+ old_lval = yylvalpp->sc_int;
+ token = ReadToken(mac.body, yylvalpp);
+ if (token != old_token || yylvalpp->sc_int != old_lval) {
+ error:
+ StoreStr("Macro Redefined");
+ StoreStr(GetStringOfAtom(atable,name));
+ message=GetStrfromTStr();
+ DecLineNumber();
+ CPPShInfoLogMsg(message);
+ IncLineNumber();
+ ResetTString();
+ break; }
+ } while (token > 0);
+ }
+ FreeMacro(&symb->details.mac);
+ } else {
+ dummyLoc.file = 0;
+ dummyLoc.line = 0;
+ symb = AddSymbol(&dummyLoc, macros, name, MACRO_S);
+ }
+ symb->details.mac = mac;
+ return '\n';
+} /* CPPdefine */
+
+static int CPPundef(yystypepp * yylvalpp)
+{
+ int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ Symbol *symb;
+ if(token == '\n'){
+ CPPErrorToInfoLog("#undef");
+ return token;
+ }
+ if (token != CPP_IDENTIFIER)
+ goto error;
+ symb = LookUpSymbol(macros, yylvalpp->sc_ident);
+ if (symb) {
+ symb->details.mac.undef = 1;
+ }
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (token != '\n') {
+ error:
+ CPPErrorToInfoLog("#undef");
+ }
+ return token;
+} /* CPPundef */
+
+/* CPPelse -- skip forward to appropriate spot. This is actually used
+** to skip to and #endif after seeing an #else, AND to skip to a #else,
+** #elif, or #endif after a #if/#ifdef/#ifndef/#elif test was false
+*/
+
+static int CPPelse(int matchelse, yystypepp * yylvalpp)
+{
+ int atom,depth=0;
+ int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+
+ while (token > 0) {
+ if (token != '#') {
+ while (token != '\n')
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ continue;
+ }
+ if ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) != CPP_IDENTIFIER)
+ continue;
+ atom = yylvalpp->sc_ident;
+ if (atom == ifAtom || atom == ifdefAtom || atom == ifndefAtom){
+ depth++; cpp->ifdepth++; cpp->elsetracker++;
+ }
+ else if (atom == endifAtom) {
+ if(--depth<=0){
+ cpp->elsedepth[cpp->elsetracker]=0;
+ --cpp->elsetracker;
+ if (cpp->ifdepth)
+ --cpp->ifdepth;
+ break;
+ }
+ --cpp->elsetracker;
+ --cpp->ifdepth;
+ }
+ else if (((int)(matchelse) != 0)&& depth==0) {
+ if (atom == elseAtom ) {
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (token != '\n') {
+ CPPWarningToInfoLog("unexpected tokens following #else preprocessor directive - expected a newline");
+ while (token != '\n')
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ }
+ break;
+ }
+ else if (atom == elifAtom) {
+ /* we decrement cpp->ifdepth here, because CPPif will increment
+ * it and we really want to leave it alone */
+ if (cpp->ifdepth){
+ --cpp->ifdepth;
+ --cpp->elsetracker;
+ }
+ return CPPif(yylvalpp);
+ }
+ }
+ else if((atom==elseAtom) && (!ChkCorrectElseNesting())){
+ CPPErrorToInfoLog("#else after a #else");
+ cpp->CompileError=1;
+ }
+ };
+ return token;
+}
+
+enum eval_prec {
+ MIN_PREC,
+ COND, LOGOR, LOGAND, OR, XOR, AND, EQUAL, RELATION, SHIFT, ADD, MUL, UNARY,
+ MAX_PREC
+};
+
+static int op_logor(int a, int b) { return a || b; }
+static int op_logand(int a, int b) { return a && b; }
+static int op_or(int a, int b) { return a | b; }
+static int op_xor(int a, int b) { return a ^ b; }
+static int op_and(int a, int b) { return a & b; }
+static int op_eq(int a, int b) { return a == b; }
+static int op_ne(int a, int b) { return a != b; }
+static int op_ge(int a, int b) { return a >= b; }
+static int op_le(int a, int b) { return a <= b; }
+static int op_gt(int a, int b) { return a > b; }
+static int op_lt(int a, int b) { return a < b; }
+static int op_shl(int a, int b) { return a << b; }
+static int op_shr(int a, int b) { return a >> b; }
+static int op_add(int a, int b) { return a + b; }
+static int op_sub(int a, int b) { return a - b; }
+static int op_mul(int a, int b) { return a * b; }
+static int op_div(int a, int b) { return a / b; }
+static int op_mod(int a, int b) { return a % b; }
+static int op_pos(int a) { return a; }
+static int op_neg(int a) { return -a; }
+static int op_cmpl(int a) { return ~a; }
+static int op_not(int a) { return !a; }
+
+struct {
+ int token, prec, (*op)(int, int);
+} binop[] = {
+ { CPP_OR_OP, LOGOR, op_logor },
+ { CPP_AND_OP, LOGAND, op_logand },
+ { '|', OR, op_or },
+ { '^', XOR, op_xor },
+ { '&', AND, op_and },
+ { CPP_EQ_OP, EQUAL, op_eq },
+ { CPP_NE_OP, EQUAL, op_ne },
+ { '>', RELATION, op_gt },
+ { CPP_GE_OP, RELATION, op_ge },
+ { '<', RELATION, op_lt },
+ { CPP_LE_OP, RELATION, op_le },
+ { CPP_LEFT_OP, SHIFT, op_shl },
+ { CPP_RIGHT_OP, SHIFT, op_shr },
+ { '+', ADD, op_add },
+ { '-', ADD, op_sub },
+ { '*', MUL, op_mul },
+ { '/', MUL, op_div },
+ { '%', MUL, op_mod },
+};
+
+struct {
+ int token, (*op)(int);
+} unop[] = {
+ { '+', op_pos },
+ { '-', op_neg },
+ { '~', op_cmpl },
+ { '!', op_not },
+};
+
+#define ALEN(A) (sizeof(A)/sizeof(A[0]))
+
+static int eval(int token, int prec, int *res, int *err, yystypepp * yylvalpp)
+{
+ int i, val;
+ Symbol *s;
+ if (token == CPP_IDENTIFIER) {
+ if (yylvalpp->sc_ident == definedAtom) {
+ int needclose = 0;
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (token == '(') {
+ needclose = 1;
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ }
+ if (token != CPP_IDENTIFIER)
+ goto error;
+ *res = (s = LookUpSymbol(macros, yylvalpp->sc_ident))
+ ? !s->details.mac.undef : 0;
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (needclose) {
+ if (token != ')')
+ goto error;
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ }
+ } else if (MacroExpand(yylvalpp->sc_ident, yylvalpp)) {
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ return eval(token, prec, res, err, yylvalpp);
+ } else {
+ goto error;
+ }
+ } else if (token == CPP_INTCONSTANT) {
+ *res = yylvalpp->sc_int;
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ } else if (token == '(') {
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ token = eval(token, MIN_PREC, res, err, yylvalpp);
+ if (!*err) {
+ if (token != ')')
+ goto error;
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ }
+ } else {
+ for (i = ALEN(unop) - 1; i >= 0; i--) {
+ if (unop[i].token == token)
+ break;
+ }
+ if (i >= 0) {
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ token = eval(token, UNARY, res, err, yylvalpp);
+ *res = unop[i].op(*res);
+ } else {
+ goto error;
+ }
+ }
+ while (!*err) {
+ if (token == ')' || token == '\n') break;
+ for (i = ALEN(binop) - 1; i >= 0; i--) {
+ if (binop[i].token == token)
+ break;
+ }
+ if (i < 0 || binop[i].prec <= prec)
+ break;
+ val = *res;
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ token = eval(token, binop[i].prec, res, err, yylvalpp);
+ *res = binop[i].op(val, *res);
+ }
+ return token;
+error:
+ CPPErrorToInfoLog("incorrect preprocessor directive");
+ *err = 1;
+ *res = 0;
+ return token;
+} /* eval */
+
+static int CPPif(yystypepp * yylvalpp) {
+ int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ int res = 0, err = 0;
+ cpp->elsetracker++;
+ if (!cpp->ifdepth++)
+ ifloc = *cpp->tokenLoc;
+ if(cpp->ifdepth >MAX_IF_NESTING){
+ CPPErrorToInfoLog("max #if nesting depth exceeded");
+ return 0;
+ }
+ token = eval(token, MIN_PREC, &res, &err, yylvalpp);
+ if (token != '\n') {
+ CPPWarningToInfoLog("unexpected tokens following the preprocessor directive - expected a newline");
+ while (token != '\n')
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ }
+ if (!res && !err) {
+ token = CPPelse(1, yylvalpp);
+ }
+
+ return token;
+} /* CPPif */
+
+static int CPPifdef(int defined, yystypepp * yylvalpp)
+{
+ int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ int name = yylvalpp->sc_ident;
+ if(++cpp->ifdepth >MAX_IF_NESTING){
+ CPPErrorToInfoLog("max #if nesting depth exceeded");
+ return 0;
+ }
+ cpp->elsetracker++;
+ if (token != CPP_IDENTIFIER) {
+ defined ? CPPErrorToInfoLog("ifdef"):CPPErrorToInfoLog("ifndef");
+ } else {
+ Symbol *s = LookUpSymbol(macros, name);
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (token != '\n') {
+ CPPWarningToInfoLog("unexpected tokens following #ifdef preprocessor directive - expected a newline");
+ while (token != '\n')
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ }
+ if (((s && !s->details.mac.undef) ? 1 : 0) != defined)
+ token = CPPelse(1, yylvalpp);
+ }
+ return token;
+} /* CPPifdef */
+
+static int CPPline(yystypepp * yylvalpp)
+{
+ int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if(token=='\n'){
+ DecLineNumber();
+ CPPErrorToInfoLog("#line");
+ IncLineNumber();
+ return token;
+ }
+ else if (token == CPP_INTCONSTANT) {
+ yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
+ SetLineNumber(yylvalpp->sc_int);
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+
+ if (token == CPP_INTCONSTANT) {
+ yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
+ SetStringNumber(yylvalpp->sc_int);
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if(token!='\n')
+ CPPErrorToInfoLog("#line");
+ }
+ else if (token == '\n'){
+ return token;
+ }
+ else{
+ CPPErrorToInfoLog("#line");
+ }
+ }
+ else{
+ CPPErrorToInfoLog("#line");
+ }
+ return token;
+}
+
+static int CPPerror(yystypepp * yylvalpp) {
+
+ int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ const char *message;
+
+ while (token != '\n') {
+ if (token == CPP_FLOATCONSTANT || token == CPP_INTCONSTANT){
+ StoreStr(yylvalpp->symbol_name);
+ }else if(token == CPP_IDENTIFIER || token == CPP_STRCONSTANT){
+ StoreStr(GetStringOfAtom(atable,yylvalpp->sc_ident));
+ }else {
+ StoreStr(GetStringOfAtom(atable,token));
+ }
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ }
+ DecLineNumber();
+ /*store this msg into the shader's information log..set the Compile Error flag!!!! */
+ message=GetStrfromTStr();
+ CPPShInfoLogMsg(message);
+ ResetTString();
+ cpp->CompileError=1;
+ IncLineNumber();
+ return '\n';
+}/*CPPerror */
+
+static int CPPpragma(yystypepp * yylvalpp)
+{
+ char SrcStrName[2];
+ char** allTokens;
+ int tokenCount = 0;
+ int maxTokenCount = 10;
+ const char* SrcStr;
+ int i;
+
+ int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+
+ if (token=='\n') {
+ DecLineNumber();
+ CPPErrorToInfoLog("#pragma");
+ IncLineNumber();
+ return token;
+ }
+
+ allTokens = (char**)malloc(sizeof(char*) * maxTokenCount);
+
+ while (token != '\n') {
+ if (tokenCount >= maxTokenCount) {
+ maxTokenCount *= 2;
+ allTokens = (char**)realloc((char**)allTokens, sizeof(char*) * maxTokenCount);
+ }
+ switch (token) {
+ case CPP_IDENTIFIER:
+ SrcStr = GetAtomString(atable, yylvalpp->sc_ident);
+ allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1);
+ strcpy(allTokens[tokenCount++], SrcStr);
+ break;
+ case CPP_INTCONSTANT:
+ SrcStr = yylvalpp->symbol_name;
+ allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1);
+ strcpy(allTokens[tokenCount++], SrcStr);
+ break;
+ case CPP_FLOATCONSTANT:
+ SrcStr = yylvalpp->symbol_name;
+ allTokens[tokenCount] = (char*)malloc(strlen(SrcStr) + 1);
+ strcpy(allTokens[tokenCount++], SrcStr);
+ break;
+ case -1:
+ /* EOF */
+ CPPShInfoLogMsg("#pragma directive must end with a newline");
+ return token;
+ default:
+ SrcStrName[0] = token;
+ SrcStrName[1] = '\0';
+ allTokens[tokenCount] = (char*)malloc(2);
+ strcpy(allTokens[tokenCount++], SrcStrName);
+ }
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ }
+
+ cpp->currentInput->ungetch(cpp->currentInput, token, yylvalpp);
+ HandlePragma(allTokens, tokenCount);
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+
+ for (i = 0; i < tokenCount; ++i) {
+ free (allTokens[i]);
+ }
+ free (allTokens);
+
+ return token;
+} /* CPPpragma */
+
+#define GL2_VERSION_NUMBER 110
+
+static int CPPversion(yystypepp * yylvalpp)
+{
+
+ int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+
+ if (cpp->notAVersionToken == 1)
+ CPPShInfoLogMsg("#version must occur before any other statement in the program");
+
+ if(token=='\n'){
+ DecLineNumber();
+ CPPErrorToInfoLog("#version");
+ IncLineNumber();
+ return token;
+ }
+ if (token != CPP_INTCONSTANT)
+ CPPErrorToInfoLog("#version");
+
+ yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
+ /*SetVersionNumber(yylvalpp->sc_int); */
+
+ if (yylvalpp->sc_int != GL2_VERSION_NUMBER)
+ CPPShInfoLogMsg("Version number not supported by GL2");
+
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+
+ if (token == '\n'){
+ return token;
+ }
+ else{
+ CPPErrorToInfoLog("#version");
+ }
+ return token;
+} /* CPPversion */
+
+static int CPPextension(yystypepp * yylvalpp)
+{
+
+ int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ char extensionName[80];
+
+ if(token=='\n'){
+ DecLineNumber();
+ CPPShInfoLogMsg("extension name not specified");
+ IncLineNumber();
+ return token;
+ }
+
+ if (token != CPP_IDENTIFIER)
+ CPPErrorToInfoLog("#extension");
+
+ strcpy(extensionName, GetAtomString(atable, yylvalpp->sc_ident));
+
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (token != ':') {
+ CPPShInfoLogMsg("':' missing after extension name");
+ return token;
+ }
+
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (token != CPP_IDENTIFIER) {
+ CPPShInfoLogMsg("behavior for extension not specified");
+ return token;
+ }
+
+ updateExtensionBehavior(extensionName, GetAtomString(atable, yylvalpp->sc_ident));
+
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (token == '\n'){
+ return token;
+ }
+ else{
+ CPPErrorToInfoLog("#extension");
+ }
+ return token;
+} /* CPPextension */
+
+int readCPPline(yystypepp * yylvalpp)
+{
+ int token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ const char *message;
+ int isVersion = 0;
+
+ if (token == CPP_IDENTIFIER) {
+ if (yylvalpp->sc_ident == defineAtom) {
+ token = CPPdefine(yylvalpp);
+ } else if (yylvalpp->sc_ident == elseAtom) {
+ if(ChkCorrectElseNesting()){
+ if (!cpp->ifdepth ){
+ CPPErrorToInfoLog("#else mismatch");
+ cpp->CompileError=1;
+ }
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (token != '\n') {
+ CPPWarningToInfoLog("unexpected tokens following #else preprocessor directive - expected a newline");
+ while (token != '\n')
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ }
+ token = CPPelse(0, yylvalpp);
+ }else{
+ CPPErrorToInfoLog("#else after a #else");
+ cpp->ifdepth=0;
+ cpp->notAVersionToken = 1;
+ return 0;
+ }
+ } else if (yylvalpp->sc_ident == elifAtom) {
+ if (!cpp->ifdepth){
+ CPPErrorToInfoLog("#elif mismatch");
+ cpp->CompileError=1;
+ }
+ /* this token is really a dont care, but we still need to eat the tokens */
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ while (token != '\n')
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ token = CPPelse(0, yylvalpp);
+ } else if (yylvalpp->sc_ident == endifAtom) {
+ cpp->elsedepth[cpp->elsetracker]=0;
+ --cpp->elsetracker;
+ if (!cpp->ifdepth){
+ CPPErrorToInfoLog("#endif mismatch");
+ cpp->CompileError=1;
+ }
+ else
+ --cpp->ifdepth;
+ } else if (yylvalpp->sc_ident == ifAtom) {
+ token = CPPif(yylvalpp);
+ } else if (yylvalpp->sc_ident == ifdefAtom) {
+ token = CPPifdef(1, yylvalpp);
+ } else if (yylvalpp->sc_ident == ifndefAtom) {
+ token = CPPifdef(0, yylvalpp);
+ } else if (yylvalpp->sc_ident == lineAtom) {
+ token = CPPline(yylvalpp);
+ } else if (yylvalpp->sc_ident == pragmaAtom) {
+ token = CPPpragma(yylvalpp);
+ } else if (yylvalpp->sc_ident == undefAtom) {
+ token = CPPundef(yylvalpp);
+ } else if (yylvalpp->sc_ident == errorAtom) {
+ token = CPPerror(yylvalpp);
+ } else if (yylvalpp->sc_ident == versionAtom) {
+ token = CPPversion(yylvalpp);
+ isVersion = 1;
+ } else if (yylvalpp->sc_ident == extensionAtom) {
+ token = CPPextension(yylvalpp);
+ } else {
+ StoreStr("Invalid Directive");
+ StoreStr(GetStringOfAtom(atable,yylvalpp->sc_ident));
+ message=GetStrfromTStr();
+ CPPShInfoLogMsg(message);
+ ResetTString();
+ }
+ }
+ while (token != '\n' && token != 0 && token != EOF) {
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ }
+
+ cpp->notAVersionToken = !isVersion;
+
+ return token;
+} /* readCPPline */
+
+void FreeMacro(MacroSymbol *s) {
+ DeleteTokenStream(s->body);
+}
+
+static int eof_scan(InputSrc *in, yystypepp * yylvalpp) { return -1; }
+static void noop(InputSrc *in, int ch, yystypepp * yylvalpp) { }
+
+static void PushEofSrc() {
+ InputSrc *in = malloc(sizeof(InputSrc));
+ memset(in, 0, sizeof(InputSrc));
+ in->scan = eof_scan;
+ in->getch = eof_scan;
+ in->ungetch = noop;
+ in->prev = cpp->currentInput;
+ cpp->currentInput = in;
+}
+
+static void PopEofSrc() {
+ if (cpp->currentInput->scan == eof_scan) {
+ InputSrc *in = cpp->currentInput;
+ cpp->currentInput = in->prev;
+ free(in);
+ }
+}
+
+static TokenStream *PrescanMacroArg(TokenStream *a, yystypepp * yylvalpp) {
+ int token;
+ TokenStream *n;
+ RewindTokenStream(a);
+ do {
+ token = ReadToken(a, yylvalpp);
+ if (token == CPP_IDENTIFIER && LookUpSymbol(macros, yylvalpp->sc_ident))
+ break;
+ } while (token > 0);
+ if (token <= 0) return a;
+ n = NewTokenStream("macro arg");
+ PushEofSrc();
+ ReadFromTokenStream(a, 0, 0);
+ while ((token = cpp->currentInput->scan(cpp->currentInput, yylvalpp)) > 0) {
+ if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp->sc_ident, yylvalpp))
+ continue;
+ RecordToken(n, token, yylvalpp);
+ }
+ PopEofSrc();
+ DeleteTokenStream(a);
+ return n;
+} /* PrescanMacroArg */
+
+typedef struct MacroInputSrc {
+ InputSrc base;
+ MacroSymbol *mac;
+ TokenStream **args;
+} MacroInputSrc;
+
+/* macro_scan ---
+** return the next token for a macro expanion, handling macro args
+*/
+static int macro_scan(MacroInputSrc *in, yystypepp * yylvalpp) {
+ int i;
+ int token = ReadToken(in->mac->body, yylvalpp);
+ if (token == CPP_IDENTIFIER) {
+ for (i = in->mac->argc-1; i>=0; i--)
+ if (in->mac->args[i] == yylvalpp->sc_ident) break;
+ if (i >= 0) {
+ ReadFromTokenStream(in->args[i], yylvalpp->sc_ident, 0);
+ return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ }
+ }
+ if (token > 0) return token;
+ in->mac->busy = 0;
+ cpp->currentInput = in->base.prev;
+ if (in->args) {
+ for (i=in->mac->argc-1; i>=0; i--)
+ DeleteTokenStream(in->args[i]);
+ free(in->args);
+ }
+ free(in);
+ return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+} /* macro_scan */
+
+/* MacroExpand
+** check an identifier (atom) to see if it a macro that should be expanded.
+** If it is, push an InputSrc that will produce the appropriate expansion
+** and return TRUE. If not, return FALSE.
+*/
+
+int MacroExpand(int atom, yystypepp * yylvalpp)
+{
+ Symbol *sym = LookUpSymbol(macros, atom);
+ MacroInputSrc *in;
+ int i,j, token, depth=0;
+ const char *message;
+ if (atom == __LINE__Atom) {
+ yylvalpp->sc_int = GetLineNumber();
+ sprintf(yylvalpp->symbol_name,"%d",yylvalpp->sc_int);
+ UngetToken(CPP_INTCONSTANT, yylvalpp);
+ return 1;
+ }
+ if (atom == __FILE__Atom) {
+ yylvalpp->sc_int = GetStringNumber();
+ sprintf(yylvalpp->symbol_name,"%d",yylvalpp->sc_int);
+ UngetToken(CPP_INTCONSTANT, yylvalpp);
+ return 1;
+ }
+ if (atom == __VERSION__Atom) {
+ strcpy(yylvalpp->symbol_name,"100");
+ yylvalpp->sc_int = atoi(yylvalpp->symbol_name);
+ UngetToken(CPP_INTCONSTANT, yylvalpp);
+ return 1;
+ }
+ if (!sym || sym->details.mac.undef) return 0;
+ if (sym->details.mac.busy) return 0; /* no recursive expansions */
+ in = malloc(sizeof(*in));
+ memset(in, 0, sizeof(*in));
+ in->base.scan = (void *)macro_scan;
+ in->base.line = cpp->currentInput->line;
+ in->base.name = cpp->currentInput->name;
+ in->mac = &sym->details.mac;
+ if (sym->details.mac.args) {
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (token != '(') {
+ UngetToken(token, yylvalpp);
+ yylvalpp->sc_ident = atom;
+ return 0;
+ }
+ in->args = malloc(in->mac->argc * sizeof(TokenStream *));
+ for (i=0; i<in->mac->argc; i++)
+ in->args[i] = NewTokenStream("macro arg");
+ i=0;j=0;
+ do{
+ depth = 0;
+ while(1) {
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (token <= 0) {
+ StoreStr("EOF in Macro ");
+ StoreStr(GetStringOfAtom(atable,atom));
+ message=GetStrfromTStr();
+ CPPShInfoLogMsg(message);
+ ResetTString();
+ return 1;
+ }
+ if((in->mac->argc==0) && (token!=')')) break;
+ if (depth == 0 && (token == ',' || token == ')')) break;
+ if (token == '(') depth++;
+ if (token == ')') depth--;
+ RecordToken(in->args[i], token, yylvalpp);
+ j=1;
+ }
+ if (token == ')') {
+ if((in->mac->argc==1) &&j==0)
+ break;
+ i++;
+ break;
+ }
+ i++;
+ }while(i < in->mac->argc);
+
+ if (i < in->mac->argc) {
+ StoreStr("Too few args in Macro ");
+ StoreStr(GetStringOfAtom(atable,atom));
+ message=GetStrfromTStr();
+ CPPShInfoLogMsg(message);
+ ResetTString();
+ } else if (token != ')') {
+ depth=0;
+ while (token >= 0 && (depth > 0 || token != ')')) {
+ if (token == ')') depth--;
+ token = cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+ if (token == '(') depth++;
+ }
+
+ if (token <= 0) {
+ StoreStr("EOF in Macro ");
+ StoreStr(GetStringOfAtom(atable,atom));
+ message=GetStrfromTStr();
+ CPPShInfoLogMsg(message);
+ ResetTString();
+ return 1;
+ }
+ StoreStr("Too many args in Macro ");
+ StoreStr(GetStringOfAtom(atable,atom));
+ message=GetStrfromTStr();
+ CPPShInfoLogMsg(message);
+ ResetTString();
+ }
+ for (i=0; i<in->mac->argc; i++) {
+ in->args[i] = PrescanMacroArg(in->args[i], yylvalpp);
+ }
+ }
+#if 0
+ printf(" <%s:%d>found macro %s\n", GetAtomString(atable, loc.file),
+ loc.line, GetAtomString(atable, atom));
+ for (i=0; i<in->mac->argc; i++) {
+ printf("\targ %s = '", GetAtomString(atable, in->mac->args[i]));
+ DumpTokenStream(stdout, in->args[i]);
+ printf("'\n");
+ }
+#endif
+ /*retain the input source*/
+ in->base.prev = cpp->currentInput;
+ sym->details.mac.busy = 1;
+ RewindTokenStream(sym->details.mac.body);
+ cpp->currentInput = &in->base;
+ return 1;
+} /* MacroExpand */
+
+int ChkCorrectElseNesting(void)
+{
+ if(cpp->elsedepth[cpp->elsetracker]==0){
+ cpp->elsedepth[cpp->elsetracker]=1;
+ return 1;
+ }
+ return 0;
+}
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/cpp.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/cpp.h
new file mode 100755
index 000000000..03449a17a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/cpp.h
@@ -0,0 +1,119 @@
+/* */
+/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
+/*All rights reserved. */
+/* */
+/*Redistribution and use in source and binary forms, with or without */
+/*modification, are permitted provided that the following conditions */
+/*are met: */
+/* */
+/* Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* */
+/* Redistributions in binary form must reproduce the above */
+/* copyright notice, this list of conditions and the following */
+/* disclaimer in the documentation and/or other materials provided */
+/* with the distribution. */
+/* */
+/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
+/* contributors may be used to endorse or promote products derived */
+/* from this software without specific prior written permission. */
+/* */
+/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
+/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
+/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
+/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
+/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
+/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
+/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
+/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
+/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
+/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/*POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/* */
+/* cpp.h */
+/* */
+
+#if !defined(__CPP_H)
+#define __CPP_H 1
+
+#include "parser.h"
+#include "tokens.h"
+
+int InitCPP(void);
+int FinalCPP(void);
+int readCPPline(yystypepp * yylvalpp);
+int MacroExpand(int atom, yystypepp * yylvalpp);
+int ChkCorrectElseNesting(void);
+
+typedef struct MacroSymbol {
+ int argc;
+ int *args;
+ TokenStream *body;
+ unsigned busy:1;
+ unsigned undef:1;
+} MacroSymbol;
+
+void FreeMacro(MacroSymbol *);
+int PredefineMacro(char *);
+
+void CPPDebugLogMsg(const char *msg); /* Prints information into debug log */
+void CPPShInfoLogMsg(const char*); /* Store cpp Err Msg into Sh.Info.Log */
+void CPPWarningToInfoLog(const char *msg); /* Prints warning messages into info log */
+void HandlePragma(const char**, int numTokens); /* #pragma directive container. */
+void ResetTString(void); /* #error Message as TString. */
+void CPPErrorToInfoLog(char*); /* Stick all cpp errors into Sh.Info.log . */
+void StoreStr(char*); /* Store the TString in Parse Context. */
+void SetLineNumber(int); /* Set line number. */
+void SetStringNumber(int); /* Set string number. */
+int GetLineNumber(void); /* Get the current String Number. */
+int GetStringNumber(void); /* Get the current String Number. */
+const char* GetStrfromTStr(void); /* Convert TString to String. */
+void updateExtensionBehavior(const char* extName, const char* behavior);
+int FreeCPP(void);
+
+#endif /* !(defined(__CPP_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/cpp_comment_fix.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/cpp_comment_fix.c
new file mode 100644
index 000000000..0c3073590
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/cpp_comment_fix.c
@@ -0,0 +1,76 @@
+/* converts c++ to c comments */
+/* usage: ./cpp_comment_fix source */
+
+#include <stdio.h>
+
+int main (int argc, char *argv[])
+{
+ FILE *f;
+ int c;
+ char *buf = NULL;
+ int size = 0, i = 0;
+
+ f = fopen (argv[1], "r");
+ while ((c = fgetc (f)) != EOF)
+ {
+ buf = (void *) realloc (buf, size + 1);
+ buf[size] = c;
+ size++;
+ }
+ fclose (f);
+
+ f = fopen (argv[1], "w");
+
+ while (i < size)
+ {
+ if (buf[i] == '/')
+ {
+ if (buf[i+1] == '/')
+ {
+ fprintf (f, "/*");
+ i+=2;
+ while (buf[i] != '\n' && buf[i] != '\r' && i < size)
+ fprintf (f, "%c", buf[i++]);
+ fprintf (f, " */\n");
+ if (i < size && buf[i] == '\n')
+ i++;
+ else if (i < size && buf[i] == '\r')
+ i+=2;
+ }
+ else
+ {
+ fprintf (f, "/");
+ i++;
+
+ if (buf[i] == '*')
+ {
+ fprintf (f, "*");
+ i++;
+
+ for (;;)
+ {
+ if (buf[i] == '*' && buf[i+1] == '/')
+ {
+ fprintf (f, "*/");
+ i+=2;
+ break;
+ }
+ else
+ {
+ fprintf (f, "%c", buf[i]);
+ i++;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ fprintf (f, "%c", buf[i]);
+ i++;
+ }
+ }
+ fclose (f);
+ return 0;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/cppstruct.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/cppstruct.c
new file mode 100755
index 000000000..c55b3f7c7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/cppstruct.c
@@ -0,0 +1,185 @@
+/* */
+/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
+/*All rights reserved. */
+/* */
+/*Redistribution and use in source and binary forms, with or without */
+/*modification, are permitted provided that the following conditions */
+/*are met: */
+/* */
+/* Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* */
+/* Redistributions in binary form must reproduce the above */
+/* copyright notice, this list of conditions and the following */
+/* disclaimer in the documentation and/or other materials provided */
+/* with the distribution. */
+/* */
+/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
+/* contributors may be used to endorse or promote products derived */
+/* from this software without specific prior written permission. */
+/* */
+/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
+/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
+/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
+/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
+/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
+/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
+/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
+/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
+/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
+/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/*POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/* */
+/* cppstruct.c */
+/* */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "slglobals.h"
+
+CPPStruct *cpp = NULL;
+static int refCount = 0;
+
+int InitPreprocessor(void);
+int ResetPreprocessor(void);
+int FreeCPPStruct(void);
+int FinalizePreprocessor(void);
+
+/*
+ * InitCPPStruct() - Initilaize the CPP structure.
+ *
+ */
+
+int InitCPPStruct(void)
+{
+ int len;
+ char *p;
+
+ cpp = (CPPStruct *) malloc(sizeof(CPPStruct));
+ if (cpp == NULL)
+ return 0;
+
+ refCount++;
+
+ /* Initialize public members: */
+ cpp->pLastSourceLoc = &cpp->lastSourceLoc;
+
+ p = (char *) &cpp->options;
+ len = sizeof(cpp->options);
+ while (--len >= 0)
+ p[len] = 0;
+
+ ResetPreprocessor();
+ return 1;
+} /* InitCPPStruct */
+
+int ResetPreprocessor(void)
+{
+ /* Initialize private members: */
+
+ cpp->lastSourceLoc.file = 0;
+ cpp->lastSourceLoc.line = 0;
+ cpp->pC=0;
+ cpp->CompileError=0;
+ cpp->ifdepth=0;
+ for(cpp->elsetracker=0; cpp->elsetracker<64; cpp->elsetracker++)
+ cpp->elsedepth[cpp->elsetracker]=0;
+ cpp->elsetracker=0;
+ cpp->tokensBeforeEOF = 0;
+ return 1;
+}
+
+/*Intializing the Preprocessor. */
+
+int InitPreprocessor(void)
+{
+ # define CPP_STUFF true
+ # ifdef CPP_STUFF
+ FreeCPPStruct();
+ InitCPPStruct();
+ cpp->options.Quiet = 1;
+ cpp->options.profileString = "generic";
+ if (!InitAtomTable(atable, 0))
+ return 1;
+ if (!InitScanner(cpp))
+ return 1;
+ # endif
+ return 0;
+}
+
+/*FreeCPPStruct() - Free the CPP structure. */
+
+int FreeCPPStruct(void)
+{
+ if (refCount)
+ {
+ free(cpp);
+ refCount--;
+ }
+
+ return 1;
+}
+
+/*Finalizing the Preprocessor. */
+
+int FinalizePreprocessor(void)
+{
+ # define CPP_STUFF true
+ # ifdef CPP_STUFF
+ FreeAtomTable(atable);
+ FreeCPPStruct();
+ FreeScanner();
+ # endif
+ return 0;
+}
+
+
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+/*//////////////////////////////////// End of cppstruct.c ////////////////////////////////////// */
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/memory.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/memory.c
new file mode 100755
index 000000000..ed0f4fb4b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/memory.c
@@ -0,0 +1,191 @@
+/* */
+/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
+/*All rights reserved. */
+/* */
+/*Redistribution and use in source and binary forms, with or without */
+/*modification, are permitted provided that the following conditions */
+/*are met: */
+/* */
+/* Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* */
+/* Redistributions in binary form must reproduce the above */
+/* copyright notice, this list of conditions and the following */
+/* disclaimer in the documentation and/or other materials provided */
+/* with the distribution. */
+/* */
+/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
+/* contributors may be used to endorse or promote products derived */
+/* from this software without specific prior written permission. */
+/* */
+/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
+/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
+/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
+/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
+/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
+/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
+/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
+/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
+/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
+/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/*POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/* */
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef __STDC99__
+#include <stdint.h>
+#elif defined (_WIN64)
+typedef unsigned __int64 uintptr_t;
+#else
+typedef unsigned int uintptr_t;
+#endif
+
+#include "memory.h"
+
+/* default alignment and chunksize, if called with 0 arguments */
+#define CHUNKSIZE (64*1024)
+#define ALIGN 8
+
+/* we need to call the `real' malloc and free, not our replacements */
+#undef malloc
+#undef free
+
+struct chunk {
+ struct chunk *next;
+};
+
+struct cleanup {
+ struct cleanup *next;
+ void (*fn)(void *);
+ void *arg;
+};
+
+struct MemoryPool_rec {
+ struct chunk *next;
+ uintptr_t free, end;
+ size_t chunksize;
+ uintptr_t alignmask;
+ struct cleanup *cleanup;
+};
+
+MemoryPool *mem_CreatePool(size_t chunksize, unsigned int align)
+{
+ MemoryPool *pool;
+
+ if (align == 0) align = ALIGN;
+ if (chunksize == 0) chunksize = CHUNKSIZE;
+ if (align & (align-1)) return 0;
+ if (chunksize < sizeof(MemoryPool)) return 0;
+ if (chunksize & (align-1)) return 0;
+ if (!(pool = malloc(chunksize))) return 0;
+ pool->next = 0;
+ pool->chunksize = chunksize;
+ pool->alignmask = (uintptr_t)(align)-1;
+ pool->free = ((uintptr_t)(pool + 1) + pool->alignmask) & ~pool->alignmask;
+ pool->end = (uintptr_t)pool + chunksize;
+ pool->cleanup = 0;
+ return pool;
+}
+
+void mem_FreePool(MemoryPool *pool)
+{
+ struct cleanup *cleanup;
+ struct chunk *p, *next;
+
+ for (cleanup = pool->cleanup; cleanup; cleanup = cleanup->next) {
+ cleanup->fn(cleanup->arg);
+ }
+ for (p = (struct chunk *)pool; p; p = next) {
+ next = p->next;
+ free(p);
+ }
+}
+
+void *mem_Alloc(MemoryPool *pool, size_t size)
+{
+ struct chunk *ch;
+ void *rv = (void *)pool->free;
+ size = (size + pool->alignmask) & ~pool->alignmask;
+ if (size <= 0) size = pool->alignmask;
+ pool->free += size;
+ if (pool->free > pool->end || pool->free < (uintptr_t)rv) {
+ size_t minreq = (size + sizeof(struct chunk) + pool->alignmask)
+ & ~pool->alignmask;
+ pool->free = (uintptr_t)rv;
+ if (minreq >= pool->chunksize) {
+ /* request size is too big for the chunksize, so allocate it as */
+ /* a single chunk of the right size */
+ ch = malloc(minreq);
+ if (!ch) return 0;
+ } else {
+ ch = malloc(pool->chunksize);
+ if (!ch) return 0;
+ pool->free = (uintptr_t)ch + minreq;
+ pool->end = (uintptr_t)ch + pool->chunksize;
+ }
+ ch->next = pool->next;
+ pool->next = ch;
+ rv = (void *)(((uintptr_t)(ch+1) + pool->alignmask) & ~pool->alignmask);
+ }
+ return rv;
+}
+
+int mem_AddCleanup(MemoryPool *pool, void (*fn)(void *), void *arg) {
+ struct cleanup *cleanup;
+
+ pool->free = (pool->free + sizeof(void *) - 1) & ~(sizeof(void *)-1);
+ cleanup = mem_Alloc(pool, sizeof(struct cleanup));
+ if (!cleanup) return -1;
+ cleanup->next = pool->cleanup;
+ cleanup->fn = fn;
+ cleanup->arg = arg;
+ pool->cleanup = cleanup;
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/memory.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/memory.h
new file mode 100755
index 000000000..89a57e24c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/memory.h
@@ -0,0 +1,89 @@
+/* */
+/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
+/*All rights reserved. */
+/* */
+/*Redistribution and use in source and binary forms, with or without */
+/*modification, are permitted provided that the following conditions */
+/*are met: */
+/* */
+/* Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* */
+/* Redistributions in binary form must reproduce the above */
+/* copyright notice, this list of conditions and the following */
+/* disclaimer in the documentation and/or other materials provided */
+/* with the distribution. */
+/* */
+/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
+/* contributors may be used to endorse or promote products derived */
+/* from this software without specific prior written permission. */
+/* */
+/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
+/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
+/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
+/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
+/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
+/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
+/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
+/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
+/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
+/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/*POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/* */
+#ifndef __MEMORY_H
+#define __MEMORY_H
+
+typedef struct MemoryPool_rec MemoryPool;
+
+extern MemoryPool *mem_CreatePool(size_t chunksize, unsigned align);
+extern void mem_FreePool(MemoryPool *);
+extern void *mem_Alloc(MemoryPool *p, size_t size);
+extern void *mem_Realloc(MemoryPool *p, void *old, size_t oldsize, size_t newsize);
+extern int mem_AddCleanup(MemoryPool *p, void (*fn)(void *), void *arg);
+
+#endif /* __MEMORY_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/parser.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/parser.h
new file mode 100755
index 000000000..5f70bdd1a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/parser.h
@@ -0,0 +1,126 @@
+/* */
+/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
+/*All rights reserved. */
+/* */
+/*Redistribution and use in source and binary forms, with or without */
+/*modification, are permitted provided that the following conditions */
+/*are met: */
+/* */
+/* Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* */
+/* Redistributions in binary form must reproduce the above */
+/* copyright notice, this list of conditions and the following */
+/* disclaimer in the documentation and/or other materials provided */
+/* with the distribution. */
+/* */
+/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
+/* contributors may be used to endorse or promote products derived */
+/* from this software without specific prior written permission. */
+/* */
+/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
+/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
+/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
+/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
+/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
+/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
+/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
+/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
+/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
+/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/*POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+
+#ifndef BISON_PARSER_H
+# define BISON_PARSER_H
+
+#ifndef yystypepp
+typedef struct {
+ int sc_int;
+ float sc_fval;
+ int sc_ident;
+ char symbol_name[MAX_SYMBOL_NAME_LEN+1];
+} yystypepp;
+
+# define YYSTYPE_IS_TRIVIAL 1
+#endif
+# define CPP_AND_OP 257
+# define CPP_SUB_ASSIGN 259
+# define CPP_MOD_ASSIGN 260
+# define CPP_ADD_ASSIGN 261
+# define CPP_DIV_ASSIGN 262
+# define CPP_MUL_ASSIGN 263
+# define CPP_EQ_OP 264
+# define CPP_XOR_OP 265
+# define ERROR_SY 266
+# define CPP_FLOATCONSTANT 267
+# define CPP_GE_OP 268
+# define CPP_RIGHT_OP 269
+# define CPP_IDENTIFIER 270
+# define CPP_INTCONSTANT 271
+# define CPP_LE_OP 272
+# define CPP_LEFT_OP 273
+# define CPP_DEC_OP 274
+# define CPP_NE_OP 275
+# define CPP_OR_OP 276
+# define CPP_INC_OP 277
+# define CPP_STRCONSTANT 278
+# define CPP_TYPEIDENTIFIER 279
+
+# define FIRST_USER_TOKEN_SY 289
+
+# define CPP_RIGHT_ASSIGN 280
+# define CPP_LEFT_ASSIGN 281
+# define CPP_AND_ASSIGN 282
+# define CPP_OR_ASSIGN 283
+# define CPP_XOR_ASSIGN 284
+# define CPP_LEFT_BRACKET 285
+# define CPP_RIGHT_BRACKET 286
+# define CPP_LEFT_BRACE 287
+# define CPP_RIGHT_BRACE 288
+
+#endif /* not BISON_PARSER_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/preprocess.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/preprocess.h
new file mode 100755
index 000000000..63996d669
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/preprocess.h
@@ -0,0 +1,84 @@
+/* */
+/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
+/*All rights reserved. */
+/* */
+/*Redistribution and use in source and binary forms, with or without */
+/*modification, are permitted provided that the following conditions */
+/*are met: */
+/* */
+/* Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* */
+/* Redistributions in binary form must reproduce the above */
+/* copyright notice, this list of conditions and the following */
+/* disclaimer in the documentation and/or other materials provided */
+/* with the distribution. */
+/* */
+/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
+/* contributors may be used to endorse or promote products derived */
+/* from this software without specific prior written permission. */
+/* */
+/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
+/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
+/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
+/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
+/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
+/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
+/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
+/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
+/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
+/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/*POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+
+# include "slglobals.h"
+extern CPPStruct *cpp;
+int InitCPPStruct(void);
+int InitScanner(CPPStruct *cpp);
+int InitAtomTable(AtomTable *atable, int htsize);
+int ScanFromString(char *s);
+char* GetStringOfAtom(AtomTable *atable, int atom);
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/scanner.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/scanner.c
new file mode 100755
index 000000000..d80e37b8e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/scanner.c
@@ -0,0 +1,789 @@
+/* */
+/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
+/*All rights reserved. */
+/* */
+/*Redistribution and use in source and binary forms, with or without */
+/*modification, are permitted provided that the following conditions */
+/*are met: */
+/* */
+/* Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* */
+/* Redistributions in binary form must reproduce the above */
+/* copyright notice, this list of conditions and the following */
+/* disclaimer in the documentation and/or other materials provided */
+/* with the distribution. */
+/* */
+/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
+/* contributors may be used to endorse or promote products derived */
+/* from this software without specific prior written permission. */
+/* */
+/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
+/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
+/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
+/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
+/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
+/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
+/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
+/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
+/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
+/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/*POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/* */
+/* scanner.c */
+/* */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#if 0
+ #include <ieeefp.h>
+ #else
+ #define isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
+ ((*(long *)&(x) & 0x007fffffL)==0000000000L))
+#endif
+
+#include "slglobals.h"
+
+
+typedef struct StringInputSrc {
+ InputSrc base;
+ char *p;
+} StringInputSrc;
+
+static int eof_scan(InputSrc *is, yystypepp * yylvalpp)
+{
+ return EOF;
+} /* eof_scan */
+
+static void noop(InputSrc *in, int ch, yystypepp * yylvalpp) {}
+
+static InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };
+
+static int byte_scan(InputSrc *, yystypepp * yylvalpp);
+
+#define EOL_SY '\n'
+
+#if defined(_WIN32)
+ #define DBG_BREAKPOINT() __asm int 3
+ #elif defined(_M_AMD64)
+ #define DBG_BREAKPOINT() assert(!"Dbg_Breakpoint");
+ #else
+ #define DBG_BREAKPOINT()
+ #endif
+
+ #if defined(_WIN32) && !defined(_M_AMD64)
+ __int64 RDTSC ( void ) {
+
+ __int64 v;
+
+ __asm __emit 0x0f
+ __asm __emit 0x31
+ __asm mov dword ptr v, eax
+ __asm mov dword ptr v+4, edx
+
+ return v;
+ }
+#endif
+
+
+int InitScanner(CPPStruct *cpp)
+{
+ /* Add various atoms needed by the CPP line scanner: */
+ if (!InitCPP())
+ return 0;
+
+ cpp->mostRecentToken = 0;
+ cpp->tokenLoc = &cpp->ltokenLoc;
+
+ cpp->ltokenLoc.file = 0;
+ cpp->ltokenLoc.line = 0;
+
+ cpp->currentInput = &eof_inputsrc;
+ cpp->previous_token = '\n';
+ cpp->notAVersionToken = 0;
+
+ return 1;
+} /* InitScanner */
+
+int FreeScanner(void)
+{
+ return (FreeCPP());
+}
+
+/*
+ * str_getch()
+ * takes care of reading from multiple strings.
+ * returns the next-char from the input stream.
+ * returns EOF when the complete shader is parsed.
+ */
+static int str_getch(StringInputSrc *in)
+{
+ for(;;){
+ if (*in->p){
+ if (*in->p == '\n') {
+ in->base.line++;
+ IncLineNumber();
+ }
+ return *in->p++;
+ }
+ if(++(cpp->PaWhichStr) < cpp->PaArgc){
+ free(in);
+ SetStringNumber(cpp->PaWhichStr);
+ SetLineNumber(1);
+ ScanFromString(cpp->PaArgv[cpp->PaWhichStr]);
+ in=(StringInputSrc*)cpp->currentInput;
+ continue;
+ }
+ else{
+ cpp->currentInput = in->base.prev;
+ cpp->PaWhichStr=0;
+ free(in);
+ return EOF;
+ }
+ }
+} /* str_getch */
+
+static void str_ungetch(StringInputSrc *in, int ch, yystypepp *type) {
+ if (in->p[-1] == ch)in->p--;
+ else {
+ *(in->p)='\0'; /*this would take care of shifting to the previous string. */
+ cpp->PaWhichStr--;
+ }
+ if (ch == '\n') {
+ in->base.line--;
+ DecLineNumber();
+ }
+} /* str_ungetch */
+
+int ScanFromString(char *s)
+{
+
+ StringInputSrc *in = malloc(sizeof(StringInputSrc));
+ memset(in, 0, sizeof(StringInputSrc));
+ in->p = s;
+ in->base.line = 1;
+ in->base.scan = byte_scan;
+ in->base.getch = (int (*)(InputSrc *, yystypepp *))str_getch;
+ in->base.ungetch = (void (*)(InputSrc *, int, yystypepp *))str_ungetch;
+ in->base.prev = cpp->currentInput;
+ cpp->currentInput = &in->base;
+
+ return 1;
+} /* ScanFromString; */
+
+
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+/*///////////////////////////////// Floating point constants: ///////////////////////////////// */
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+/*
+ * lBuildFloatValue() - Quick and dirty conversion to floating point. Since all
+ * we need is single precision this should be quite precise.
+ */
+
+static float lBuildFloatValue(const char *str, int len, int exp)
+{
+ double val, expval, ten;
+ int ii, llen, absexp;
+ float rv;
+
+ val = 0.0;
+ llen = len;
+ for (ii = 0; ii < len; ii++)
+ val = val*10.0 + (str[ii] - '0');
+ if (exp != 0) {
+ absexp = exp > 0 ? exp : -exp;
+ expval = 1.0f;
+ ten = 10.0;
+ while (absexp) {
+ if (absexp & 1)
+ expval *= ten;
+ ten *= ten;
+ absexp >>= 1;
+ }
+ if (exp >= 0) {
+ val *= expval;
+ } else {
+ val /= expval;
+ }
+ }
+ rv = (float)val;
+ if (isinff(rv)) {
+ CPPErrorToInfoLog(" ERROR___FP_CONST_OVERFLOW");
+ }
+ return rv;
+} /* lBuildFloatValue */
+
+
+/*
+ * lFloatConst() - Scan a floating point constant. Assumes that the scanner
+ * has seen at least one digit, followed by either a decimal '.' or the
+ * letter 'e'.
+ */
+
+static int lFloatConst(char *str, int len, int ch, yystypepp * yylvalpp)
+{
+ int HasDecimal, declen, exp, ExpSign;
+ int str_len;
+ float lval;
+
+ HasDecimal = 0;
+ declen = 0;
+ exp = 0;
+
+ str_len=len;
+ if (ch == '.') {
+ str[len++]=ch;
+ HasDecimal = 1;
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ while (ch >= '0' && ch <= '9') {
+ if (len < MAX_SYMBOL_NAME_LEN) {
+ declen++;
+ if (len > 0 || ch != '0') {
+ str[len] = ch;
+ len++;str_len++;
+ }
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ } else {
+ CPPErrorToInfoLog("ERROR___FP_CONST_TOO_LONG");
+ len = 1,str_len=1;
+ }
+ }
+ }
+
+ /* Exponent: */
+
+ if (ch == 'e' || ch == 'E') {
+ ExpSign = 1;
+ str[len++]=ch;
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch == '+') {
+ str[len++]=ch;
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ } else if (ch == '-') {
+ ExpSign = -1;
+ str[len++]=ch;
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ }
+ if (ch >= '0' && ch <= '9') {
+ while (ch >= '0' && ch <= '9') {
+ exp = exp*10 + ch - '0';
+ str[len++]=ch;
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ }
+ } else {
+ CPPErrorToInfoLog("ERROR___ERROR_IN_EXPONENT");
+ }
+ exp *= ExpSign;
+ }
+
+ if (len == 0) {
+ lval = 0.0f;
+ strcpy(str,"0.0");
+ } else {
+ str[len]='\0';
+ lval = lBuildFloatValue(str, str_len, exp - declen);
+ }
+ /* Suffix: */
+
+ yylvalpp->sc_fval = lval;
+ strcpy(yylvalpp->symbol_name,str);
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return CPP_FLOATCONSTANT;
+} /* lFloatConst */
+
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+/*/////////////////////////////////////// Normal Scanner ////////////////////////////////////// */
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+
+static int byte_scan(InputSrc *in, yystypepp * yylvalpp)
+{
+ char symbol_name[MAX_SYMBOL_NAME_LEN + 1];
+ char string_val[MAX_STRING_LEN + 1];
+ int AlreadyComplained;
+ int len, ch, ii, ival = 0;
+
+ for (;;) {
+ yylvalpp->sc_int = 0;
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+
+ while (ch == ' ' || ch == '\t' || ch == '\r') {
+ yylvalpp->sc_int = 1;
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ }
+
+ cpp->ltokenLoc.file = cpp->currentInput->name;
+ cpp->ltokenLoc.line = cpp->currentInput->line;
+ len = 0;
+ switch (ch) {
+ default:
+ return ch; /* Single character token */
+ case EOF:
+ return -1;
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'L': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z': case '_':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z':
+ do {
+ if (len < MAX_SYMBOL_NAME_LEN) {
+ symbol_name[len] = ch;
+ len++;
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ } else {
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ }
+ } while ((ch >= 'a' && ch <= 'z') ||
+ (ch >= 'A' && ch <= 'Z') ||
+ (ch >= '0' && ch <= '9') ||
+ ch == '_');
+ if (len >= MAX_SYMBOL_NAME_LEN)
+ len = MAX_SYMBOL_NAME_LEN - 1;
+ symbol_name[len] = '\0';
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ yylvalpp->sc_ident = LookUpAddString(atable, symbol_name);
+ return CPP_IDENTIFIER;
+ break;
+ case '0':
+ yylvalpp->symbol_name[len++] = ch;
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch == 'x' || ch == 'X') {
+ yylvalpp->symbol_name[len++] = ch;
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if ((ch >= '0' && ch <= '9') ||
+ (ch >= 'A' && ch <= 'F') ||
+ (ch >= 'a' && ch <= 'f'))
+ {
+ AlreadyComplained = 0;
+ ival = 0;
+ do {
+ yylvalpp->symbol_name[len++] = ch;
+ if (ival <= 0x0fffffff) {
+ if (ch >= '0' && ch <= '9') {
+ ii = ch - '0';
+ } else if (ch >= 'A' && ch <= 'F') {
+ ii = ch - 'A' + 10;
+ } else {
+ ii = ch - 'a' + 10;
+ }
+ ival = (ival << 4) | ii;
+ } else {
+ if (!AlreadyComplained)
+ CPPErrorToInfoLog("ERROR___HEX_CONST_OVERFLOW");
+ AlreadyComplained = 1;
+ }
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ } while ((ch >= '0' && ch <= '9') ||
+ (ch >= 'A' && ch <= 'F') ||
+ (ch >= 'a' && ch <= 'f'));
+ } else {
+ CPPErrorToInfoLog("ERROR___ERROR_IN_HEX_CONSTANT");
+ }
+ yylvalpp->symbol_name[len] = '\0';
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ yylvalpp->sc_int = ival;
+ return CPP_INTCONSTANT;
+ } else if (ch >= '0' && ch <= '7') { /* octal integer constants */
+ AlreadyComplained = 0;
+ ival = 0;
+ do {
+ yylvalpp->symbol_name[len++] = ch;
+ if (ival <= 0x1fffffff) {
+ ii = ch - '0';
+ ival = (ival << 3) | ii;
+ } else {
+ if (!AlreadyComplained)
+ CPPErrorToInfoLog("ERROR___OCT_CONST_OVERFLOW");
+ AlreadyComplained = 1;
+ }
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ } while (ch >= '0' && ch <= '7');
+ if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E')
+ return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp);
+ yylvalpp->symbol_name[len] = '\0';
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ yylvalpp->sc_int = ival;
+ return CPP_INTCONSTANT;
+ } else {
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ ch = '0';
+ }
+ /* Fall through... */
+ case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ do {
+ if (len < MAX_SYMBOL_NAME_LEN) {
+ if (len > 0 || ch != '0') {
+ yylvalpp->symbol_name[len] = ch;
+ len++;
+ }
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ }
+ } while (ch >= '0' && ch <= '9');
+ if (ch == '.' || ch == 'e' || ch == 'f' || ch == 'h' || ch == 'x'|| ch == 'E') {
+ return lFloatConst(yylvalpp->symbol_name, len, ch, yylvalpp);
+ } else {
+ yylvalpp->symbol_name[len] = '\0';
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ ival = 0;
+ AlreadyComplained = 0;
+ for (ii = 0; ii < len; ii++) {
+ ch = yylvalpp->symbol_name[ii] - '0';
+ if ((ival > 214748364) || (ival == 214748364 && ch >= 8)) {
+ if (!AlreadyComplained)
+ CPPErrorToInfoLog("ERROR___INTEGER_CONST_OVERFLOW");
+ AlreadyComplained = 1;
+ }
+ ival = ival*10 + ch;
+ }
+ yylvalpp->sc_int = ival;
+ if(ival==0)
+ strcpy(yylvalpp->symbol_name,"0");
+ return CPP_INTCONSTANT;
+ }
+ break;
+ case '-':
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch == '-') {
+ return CPP_DEC_OP;
+ } else if (ch == '=') {
+ return CPP_SUB_ASSIGN;
+ } else {
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return '-';
+ }
+ case '+':
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch == '+') {
+ return CPP_INC_OP;
+ } else if (ch == '=') {
+ return CPP_ADD_ASSIGN;
+ } else {
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return '+';
+ }
+ case '*':
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch == '=') {
+ return CPP_MUL_ASSIGN;
+ } else {
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return '*';
+ }
+ case '%':
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch == '=') {
+ return CPP_MOD_ASSIGN;
+ } else if (ch == '>'){
+ return CPP_RIGHT_BRACE;
+ } else {
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return '%';
+ }
+ case ':':
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch == '>') {
+ return CPP_RIGHT_BRACKET;
+ } else {
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return ':';
+ }
+ case '^':
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch == '^') {
+ return CPP_XOR_OP;
+ } else {
+ if (ch == '=')
+ return CPP_XOR_ASSIGN;
+ else{
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return '^';
+ }
+ }
+
+ case '=':
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch == '=') {
+ return CPP_EQ_OP;
+ } else {
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return '=';
+ }
+ case '!':
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch == '=') {
+ return CPP_NE_OP;
+ } else {
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return '!';
+ }
+ case '|':
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch == '|') {
+ return CPP_OR_OP;
+ } else {
+ if (ch == '=')
+ return CPP_OR_ASSIGN;
+ else{
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return '|';
+ }
+ }
+ case '&':
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch == '&') {
+ return CPP_AND_OP;
+ } else {
+ if (ch == '=')
+ return CPP_AND_ASSIGN;
+ else{
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return '&';
+ }
+ }
+ case '<':
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch == '<') {
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if(ch == '=')
+ return CPP_LEFT_ASSIGN;
+ else{
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return CPP_LEFT_OP;
+ }
+ } else {
+ if (ch == '=') {
+ return CPP_LE_OP;
+ } else {
+ if (ch == '%')
+ return CPP_LEFT_BRACE;
+ else if (ch == ':')
+ return CPP_LEFT_BRACKET;
+ else{
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return '<';
+ }
+ }
+ }
+ case '>':
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch == '>') {
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if(ch == '=')
+ return CPP_RIGHT_ASSIGN;
+ else{
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return CPP_RIGHT_OP;
+ }
+ } else {
+ if (ch == '=') {
+ return CPP_GE_OP;
+ } else {
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return '>';
+ }
+ }
+ case '.':
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch >= '0' && ch <= '9') {
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return lFloatConst(yylvalpp->symbol_name, 0, '.', yylvalpp);
+ } else {
+ if (ch == '.') {
+ return -1; /* Special EOF hack */
+ } else {
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return '.';
+ }
+ }
+ case '/':
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch == '/') {
+ do {
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ } while (ch != '\n' && ch != EOF);
+ if (ch == EOF)
+ return -1;
+ return '\n';
+ } else if (ch == '*') {
+ int nlcount = 0;
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ do {
+ while (ch != '*') {
+ if (ch == '\n') nlcount++;
+ if (ch == EOF) {
+ CPPErrorToInfoLog("ERROR___EOF_IN_COMMENT");
+ return -1;
+ }
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ }
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch == EOF) {
+ CPPErrorToInfoLog("ERROR___EOF_IN_COMMENT");
+ return -1;
+ }
+ } while (ch != '/');
+ if (nlcount) {
+ return '\n';
+ }
+ /* Go try it again... */
+ } else if (ch == '=') {
+ return CPP_DIV_ASSIGN;
+ } else {
+ cpp->currentInput->ungetch(cpp->currentInput, ch, yylvalpp);
+ return '/';
+ }
+ break;
+ case '"':
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ while (ch != '"' && ch != '\n' && ch != EOF) {
+ if (ch == '\\') {
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ if (ch == '\n' || ch == EOF) {
+ break;
+ }
+ }
+ if (len < MAX_STRING_LEN) {
+ string_val[len] = ch;
+ len++;
+ ch = cpp->currentInput->getch(cpp->currentInput, yylvalpp);
+ }
+ };
+ string_val[len] = '\0';
+ if (ch == '"') {
+ yylvalpp->sc_ident = LookUpAddString(atable, string_val);
+ return CPP_STRCONSTANT;
+ } else {
+ CPPErrorToInfoLog("ERROR___CPP_EOL_IN_STRING");
+ return ERROR_SY;
+ }
+ }
+ }
+} /* byte_scan */
+
+int yylex_CPP(char* buf, int maxSize)
+{
+ yystypepp yylvalpp;
+ int token = '\n';
+
+ for(;;) {
+
+ char* tokenString = 0;
+ token = cpp->currentInput->scan(cpp->currentInput, &yylvalpp);
+ if(check_EOF(token))
+ return 0;
+ if (token == '#' && (cpp->previous_token == '\n'||cpp->previous_token==0)) {
+ token = readCPPline(&yylvalpp);
+ if(check_EOF(token))
+ return 0;
+ continue;
+ }
+ cpp->previous_token = token;
+ /* expand macros */
+ if (token == CPP_IDENTIFIER && MacroExpand(yylvalpp.sc_ident, &yylvalpp)) {
+ cpp->notAVersionToken = 1;
+ continue;
+ }
+
+ if (token == '\n')
+ continue;
+
+ if (token == CPP_IDENTIFIER) {
+ cpp->notAVersionToken = 1;
+ tokenString = GetStringOfAtom(atable,yylvalpp.sc_ident);
+ } else if (token == CPP_FLOATCONSTANT||token == CPP_INTCONSTANT){
+ cpp->notAVersionToken = 1;
+ tokenString = yylvalpp.symbol_name;
+ } else {
+ cpp->notAVersionToken = 1;
+ tokenString = GetStringOfAtom(atable,token);
+ }
+
+ if (tokenString) {
+ if ((signed)strlen(tokenString) >= maxSize) {
+ cpp->tokensBeforeEOF = 1;
+ return maxSize;
+ } else if (strlen(tokenString) > 0) {
+ strcpy(buf, tokenString);
+ cpp->tokensBeforeEOF = 1;
+ return (int)strlen(tokenString);
+ }
+
+ return 0;
+ }
+ }
+
+ return 0;
+} /* yylex */
+
+/*Checks if the token just read is EOF or not. */
+int check_EOF(int token)
+{
+ if(token==-1){
+ if(cpp->ifdepth >0){
+ CPPErrorToInfoLog("#endif missing!! Compilation stopped");
+ cpp->CompileError=1;
+ }
+ return 1;
+ }
+ return 0;
+}
+
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+/*///////////////////////////////////// End of scanner.c ////////////////////////////////////// */
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/scanner.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/scanner.h
new file mode 100755
index 000000000..15472b5bf
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/scanner.h
@@ -0,0 +1,118 @@
+/* */
+/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
+/*All rights reserved. */
+/* */
+/*Redistribution and use in source and binary forms, with or without */
+/*modification, are permitted provided that the following conditions */
+/*are met: */
+/* */
+/* Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* */
+/* Redistributions in binary form must reproduce the above */
+/* copyright notice, this list of conditions and the following */
+/* disclaimer in the documentation and/or other materials provided */
+/* with the distribution. */
+/* */
+/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
+/* contributors may be used to endorse or promote products derived */
+/* from this software without specific prior written permission. */
+/* */
+/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
+/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
+/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
+/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
+/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
+/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
+/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
+/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
+/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
+/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/*POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/* */
+/* scanner.h */
+/* */
+
+#if !defined(__SCANNER_H)
+#define __SCANNER_H 1
+
+#define MAX_SYMBOL_NAME_LEN 128
+#define MAX_STRING_LEN 512
+
+#include "parser.h"
+
+/* Not really atom table stuff but needed first... */
+
+typedef struct SourceLoc_Rec {
+ unsigned short file, line;
+} SourceLoc;
+
+int yyparse (void);
+
+int yylex_CPP(char* buf, int maxSize);
+
+typedef struct InputSrc {
+ struct InputSrc *prev;
+ int (*scan)(struct InputSrc *, yystypepp *);
+ int (*getch)(struct InputSrc *, yystypepp *);
+ void (*ungetch)(struct InputSrc *, int, yystypepp *);
+ int name; /* atom */
+ int line;
+} InputSrc;
+
+int InitScanner(CPPStruct *cpp); /* Intialise the cpp scanner. */
+int ScanFromString(char *); /* Start scanning the input from the string mentioned. */
+int check_EOF(int); /* check if we hit a EOF abruptly */
+void CPPErrorToInfoLog(char *); /* sticking the msg,line into the Shader's.Info.log */
+void SetLineNumber(int);
+void SetStringNumber(int);
+void IncLineNumber(void);
+void DecLineNumber(void);
+int FreeScanner(void); /* Free the cpp scanner */
+#endif /* !(defined(__SCANNER_H) */
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/slglobals.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/slglobals.h
new file mode 100755
index 000000000..667ada6a2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/slglobals.h
@@ -0,0 +1,115 @@
+/* */
+/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
+/*All rights reserved. */
+/* */
+/*Redistribution and use in source and binary forms, with or without */
+/*modification, are permitted provided that the following conditions */
+/*are met: */
+/* */
+/* Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* */
+/* Redistributions in binary form must reproduce the above */
+/* copyright notice, this list of conditions and the following */
+/* disclaimer in the documentation and/or other materials provided */
+/* with the distribution. */
+/* */
+/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
+/* contributors may be used to endorse or promote products derived */
+/* from this software without specific prior written permission. */
+/* */
+/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
+/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
+/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
+/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
+/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
+/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
+/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
+/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
+/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
+/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/*POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/* */
+/* slglobals.h */
+/* */
+
+#if !defined(__SLGLOBALS_H)
+#define __SLGLOBALS_H 1
+
+typedef struct CPPStruct_Rec CPPStruct;
+
+extern CPPStruct *cpp;
+
+#undef CPPC_DEBUG_THE_COMPILER
+#if defined(_DEBUG)
+#define CPPC_DEBUG_THE_COMPILER 1
+#endif
+
+#undef CPPC_ENABLE_TOOLS
+#define CPPC_ENABLE_TOOLS 1
+
+#include "memory.h"
+#include "atom.h"
+#include "scanner.h"
+#include "cpp.h"
+#include "tokens.h"
+#include "symbols.h"
+#include "compile.h"
+#if !defined(NO_PARSER)
+#include "parser.h"
+#endif
+
+#if !defined(NULL)
+#define NULL 0
+#endif
+
+#endif /* !(defined(__SLGLOBALS_H) */
+
+
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/symbols.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/symbols.c
new file mode 100755
index 000000000..e807fe343
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/symbols.c
@@ -0,0 +1,318 @@
+/* */
+/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
+/*All rights reserved. */
+/* */
+/*Redistribution and use in source and binary forms, with or without */
+/*modification, are permitted provided that the following conditions */
+/*are met: */
+/* */
+/* Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* */
+/* Redistributions in binary form must reproduce the above */
+/* copyright notice, this list of conditions and the following */
+/* disclaimer in the documentation and/or other materials provided */
+/* with the distribution. */
+/* */
+/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
+/* contributors may be used to endorse or promote products derived */
+/* from this software without specific prior written permission. */
+/* */
+/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
+/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
+/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
+/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
+/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
+/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
+/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
+/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
+/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
+/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/*POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/* */
+/* symbols.c */
+/* */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "slglobals.h"
+
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+/*///////////////////////////////// Symbol Table Variables: /////////////////////////////////// */
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+
+Scope *ScopeList = NULL;
+Scope *CurrentScope = NULL;
+Scope *GlobalScope = NULL;
+
+static void unlinkScope(void *_scope) {
+ Scope *scope = _scope;
+
+ if (scope->next)
+ scope->next->prev = scope->prev;
+ if (scope->prev)
+ scope->prev->next = scope->next;
+ else
+ ScopeList = scope->next;
+}
+
+/*
+ * NewScope()
+ *
+ */
+Scope *NewScopeInPool(MemoryPool *pool)
+{
+ Scope *lScope;
+
+ lScope = mem_Alloc(pool, sizeof(Scope));
+ lScope->pool = pool;
+ lScope->parent = NULL;
+ lScope->funScope = NULL;
+ lScope->symbols = NULL;
+
+ lScope->level = 0;
+
+ lScope->programs = NULL;
+ if ((lScope->next = ScopeList))
+ ScopeList->prev = lScope;
+ lScope->prev = 0;
+ ScopeList = lScope;
+ mem_AddCleanup(pool, unlinkScope, lScope);
+ return lScope;
+} /* NewScope */
+
+/*
+ * PushScope()
+ *
+ */
+
+void PushScope(Scope *fScope)
+{
+ Scope *lScope;
+
+ if (CurrentScope) {
+ fScope->level = CurrentScope->level + 1;
+ if (fScope->level == 1) {
+ if (!GlobalScope) {
+ /* HACK - CTD -- if GlobalScope==NULL and level==1, we're
+ * defining a function in the superglobal scope. Things
+ * will break if we leave the level as 1, so we arbitrarily
+ * set it to 2 */
+ fScope->level = 2;
+ }
+ }
+ if (fScope->level >= 2) {
+ lScope = fScope;
+ while (lScope->level > 2)
+ lScope = lScope->next;
+ fScope->funScope = lScope;
+ }
+ } else {
+ fScope->level = 0;
+ }
+ fScope->parent = CurrentScope;
+ CurrentScope = fScope;
+} /* PushScope */
+
+/*
+ * PopScope()
+ *
+ */
+
+Scope *PopScope(void)
+{
+ Scope *lScope;
+
+ lScope = CurrentScope;
+ if (CurrentScope)
+ CurrentScope = CurrentScope->parent;
+ return lScope;
+} /* PopScope */
+
+/*
+ * NewSymbol() - Allocate a new symbol node;
+ *
+ */
+
+Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind)
+{
+ Symbol *lSymb;
+ char *pch;
+ int ii;
+
+ lSymb = (Symbol *) mem_Alloc(fScope->pool, sizeof(Symbol));
+ lSymb->left = NULL;
+ lSymb->right = NULL;
+ lSymb->next = NULL;
+ lSymb->name = name;
+ lSymb->loc = *loc;
+ lSymb->kind = kind;
+
+ /* Clear union area: */
+
+ pch = (char *) &lSymb->details;
+ for (ii = 0; ii < sizeof(lSymb->details); ii++)
+ *pch++ = 0;
+ return lSymb;
+} /* NewSymbol */
+
+/*
+ * lAddToTree() - Using a binary tree is not a good idea for basic atom values because they
+ * are generated in order. We'll fix this later (by reversing the bit pattern).
+ */
+
+static void lAddToTree(Symbol **fSymbols, Symbol *fSymb)
+{
+ Symbol *lSymb;
+ int lrev, frev;
+
+ lSymb = *fSymbols;
+ if (lSymb) {
+ frev = GetReversedAtom(atable, fSymb->name);
+ while (lSymb) {
+ lrev = GetReversedAtom(atable, lSymb->name);
+ if (lrev == frev) {
+ CPPErrorToInfoLog("GetAtomString(atable, fSymb->name)");
+ break;
+ } else {
+ if (lrev > frev) {
+ if (lSymb->left) {
+ lSymb = lSymb->left;
+ } else {
+ lSymb->left = fSymb;
+ break;
+ }
+ } else {
+ if (lSymb->right) {
+ lSymb = lSymb->right;
+ } else {
+ lSymb->right = fSymb;
+ break;
+ }
+ }
+ }
+ }
+ } else {
+ *fSymbols = fSymb;
+ }
+} /* lAddToTree */
+
+
+/*
+ * AddSymbol() - Add a variable, type, or function name to a scope.
+ *
+ */
+
+Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind)
+{
+ Symbol *lSymb;
+
+ if (!fScope)
+ fScope = CurrentScope;
+ lSymb = NewSymbol(loc, fScope, atom, kind);
+ lAddToTree(&fScope->symbols, lSymb);
+ return lSymb;
+} /* AddSymbol */
+
+
+/*********************************************************************************************/
+/************************************ Symbol Semantic Functions ******************************/
+/*********************************************************************************************/
+
+/*
+ * LookUpLocalSymbol()
+ *
+ */
+
+Symbol *LookUpLocalSymbol(Scope *fScope, int atom)
+{
+ Symbol *lSymb;
+ int rname, ratom;
+
+ ratom = GetReversedAtom(atable, atom);
+ if (!fScope)
+ fScope = CurrentScope;
+ lSymb = fScope->symbols;
+ while (lSymb) {
+ rname = GetReversedAtom(atable, lSymb->name);
+ if (rname == ratom) {
+ return lSymb;
+ } else {
+ if (rname > ratom) {
+ lSymb = lSymb->left;
+ } else {
+ lSymb = lSymb->right;
+ }
+ }
+ }
+ return NULL;
+} /* LookUpLocalSymbol */
+
+/*
+ * LookUpSymbol()
+ *
+ */
+
+Symbol *LookUpSymbol(Scope *fScope, int atom)
+{
+ Symbol *lSymb;
+
+ if (!fScope)
+ fScope = CurrentScope;
+ while (fScope) {
+ lSymb = LookUpLocalSymbol(fScope, atom);
+ if (lSymb)
+ return lSymb;
+ fScope = fScope->parent;
+ }
+ return NULL;
+} /* LookUpSymbol */
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/symbols.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/symbols.h
new file mode 100755
index 000000000..65cba9d6c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/symbols.h
@@ -0,0 +1,145 @@
+/* */
+/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
+/*All rights reserved. */
+/* */
+/*Redistribution and use in source and binary forms, with or without */
+/*modification, are permitted provided that the following conditions */
+/*are met: */
+/* */
+/* Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* */
+/* Redistributions in binary form must reproduce the above */
+/* copyright notice, this list of conditions and the following */
+/* disclaimer in the documentation and/or other materials provided */
+/* with the distribution. */
+/* */
+/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
+/* contributors may be used to endorse or promote products derived */
+/* from this software without specific prior written permission. */
+/* */
+/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
+/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
+/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
+/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
+/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
+/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
+/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
+/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
+/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
+/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/*POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/* */
+/* symbols.h */
+/* */
+
+#if !defined(__SYMBOLS_H)
+#define __SYMBOLS_H 1
+
+#include "memory.h"
+
+typedef enum symbolkind {
+ MACRO_S
+} symbolkind;
+
+/* Typedefs for things defined here in "symbols.h": */
+
+typedef struct Scope_Rec Scope;
+typedef struct Symbol_Rec Symbol;
+
+typedef struct SymbolList_Rec {
+ struct SymbolList_Rec *next;
+ Symbol *symb;
+} SymbolList;
+
+struct Scope_Rec {
+ Scope *next, *prev; /* doubly-linked list of all scopes */
+ Scope *parent;
+ Scope *funScope; /* Points to base scope of enclosing function */
+ MemoryPool *pool; /* pool used for allocation in this scope */
+ Symbol *symbols;
+
+ int level; /* 0 = super globals, 1 = globals, etc. */
+
+ /* Only used at global scope (level 1): */
+ SymbolList *programs; /* List of programs for this compilation. */
+};
+
+
+/* Symbol table is a simple binary tree. */
+
+#include "cpp.h" /* to get MacroSymbol def */
+
+struct Symbol_Rec {
+ Symbol *left, *right;
+ Symbol *next;
+ int name; /* Name atom */
+ SourceLoc loc;
+ symbolkind kind;
+ union {
+ MacroSymbol mac;
+ } details;
+};
+
+extern Scope *CurrentScope;
+extern Scope *GlobalScope;
+extern Scope *ScopeList;
+
+Scope *NewScopeInPool(MemoryPool *);
+#define NewScope() NewScopeInPool(CurrentScope->pool)
+void PushScope(Scope *fScope);
+Scope *PopScope(void);
+Symbol *NewSymbol(SourceLoc *loc, Scope *fScope, int name, symbolkind kind);
+Symbol *AddSymbol(SourceLoc *loc, Scope *fScope, int atom, symbolkind kind);
+Symbol *LookUpLocalSymbol(Scope *fScope, int atom);
+Symbol *LookUpSymbol(Scope *fScope, int atom);
+void CPPErrorToInfoLog(char *);
+
+
+#endif /* !defined(__SYMBOLS_H) */
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/tokens.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/tokens.c
new file mode 100755
index 000000000..815277db5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/tokens.c
@@ -0,0 +1,462 @@
+/* */
+/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
+/*All rights reserved. */
+/* */
+/*Redistribution and use in source and binary forms, with or without */
+/*modification, are permitted provided that the following conditions */
+/*are met: */
+/* */
+/* Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* */
+/* Redistributions in binary form must reproduce the above */
+/* copyright notice, this list of conditions and the following */
+/* disclaimer in the documentation and/or other materials provided */
+/* with the distribution. */
+/* */
+/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
+/* contributors may be used to endorse or promote products derived */
+/* from this software without specific prior written permission. */
+/* */
+/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
+/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
+/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
+/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
+/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
+/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
+/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
+/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
+/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
+/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/*POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/* */
+/* tokens.c */
+/* */
+
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "slglobals.h"
+
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+/*////////////////////// Preprocessor and Token Recorder and Playback: //////////////////////// */
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+
+/*
+ * idstr()
+ * Copy a string to a malloc'ed block and convert it into something suitable
+ * for an ID
+ *
+ */
+
+static char *idstr(const char *fstr)
+{
+ size_t len;
+ char *str, *t;
+ const char *f;
+
+ len = strlen(fstr);
+ str = (char *) malloc(len + 1);
+ for (f=fstr, t=str; *f; f++) {
+ if (isalnum(*f)) *t++ = *f;
+ else if (*f == '.' || *f == '/') *t++ = '_';
+ }
+ *t = 0;
+ return str;
+} /* idstr */
+
+
+/*
+ * lNewBlock()
+ *
+ */
+
+static TokenBlock *lNewBlock(TokenStream *fTok)
+{
+ TokenBlock *lBlock;
+
+ lBlock = (TokenBlock *) malloc(sizeof(TokenBlock) + 256);
+ lBlock->count = 0;
+ lBlock->current = 0;
+ lBlock->data = (unsigned char *) lBlock + sizeof(TokenBlock);
+ lBlock->max = 256;
+ lBlock->next = NULL;
+ if (fTok->head) {
+ fTok->current->next = lBlock;
+ } else {
+ fTok->head = lBlock;
+ }
+ fTok->current = lBlock;
+ return lBlock;
+} /* lNewBlock */
+
+/*
+ * lAddByte()
+ *
+ */
+
+static void lAddByte(TokenStream *fTok, unsigned char fVal)
+{
+ TokenBlock *lBlock;
+ lBlock = fTok->current;
+ if (lBlock->count >= lBlock->max)
+ lBlock = lNewBlock(fTok);
+ lBlock->data[lBlock->count++] = fVal;
+} /* lAddByte */
+
+
+
+/*
+ * lReadByte() - Get the next byte from a stream.
+ *
+ */
+
+static int lReadByte(TokenStream *pTok)
+{
+ TokenBlock *lBlock;
+ int lval = -1;
+
+ lBlock = pTok->current;
+ if (lBlock) {
+ if (lBlock->current >= lBlock->count) {
+ lBlock = lBlock->next;
+ if (lBlock)
+ lBlock->current = 0;
+ pTok->current = lBlock;
+ }
+ if (lBlock)
+ lval = lBlock->data[lBlock->current++];
+ }
+ return lval;
+} /* lReadByte */
+
+/*///////////////////////////////////// Global Functions:////////////////////////////////////// */
+
+/*
+ * NewTokenStream()
+ *
+ */
+
+TokenStream *NewTokenStream(const char *name)
+{
+ TokenStream *pTok;
+
+ pTok = (TokenStream *) malloc(sizeof(TokenStream));
+ pTok->next = NULL;
+ pTok->name = idstr(name);
+ pTok->head = NULL;
+ pTok->current = NULL;
+ lNewBlock(pTok);
+ return pTok;
+} /* NewTokenStream */
+
+/*
+ * DeleteTokenStream()
+ *
+ */
+
+void DeleteTokenStream(TokenStream *pTok)
+{
+ TokenBlock *pBlock, *nBlock;
+
+ if (pTok) {
+ pBlock = pTok->head;
+ while (pBlock) {
+ nBlock = pBlock->next;
+ free(pBlock);
+ pBlock = nBlock;
+ }
+ if (pTok->name)
+ free(pTok->name);
+ free(pTok);
+ }
+} /* DeleteTokenStream */
+
+/*
+ * RecordToken() - Add a token to the end of a list for later playback or printout.
+ *
+ */
+
+void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp)
+{
+ const char *s;
+ unsigned char *str=NULL;
+
+ if (token > 256)
+ lAddByte(pTok, (unsigned char)((token & 0x7f) + 0x80));
+ else
+ lAddByte(pTok, (unsigned char)(token & 0x7f));
+ switch (token) {
+ case CPP_IDENTIFIER:
+ case CPP_TYPEIDENTIFIER:
+ case CPP_STRCONSTANT:
+ s = GetAtomString(atable, yylvalpp->sc_ident);
+ while (*s)
+ lAddByte(pTok, (unsigned char) *s++);
+ lAddByte(pTok, 0);
+ break;
+ case CPP_FLOATCONSTANT:
+ case CPP_INTCONSTANT:
+ str=yylvalpp->symbol_name;
+ while (*str){
+ lAddByte(pTok,(unsigned char) *str);
+ *str++;
+ }
+ lAddByte(pTok, 0);
+ break;
+ case '(':
+ lAddByte(pTok, (unsigned char)(yylvalpp->sc_int ? 1 : 0));
+ default:
+ break;
+ }
+} /* RecordToken */
+
+/*
+ * RewindTokenStream() - Reset a token stream in preperation for reading.
+ *
+ */
+
+void RewindTokenStream(TokenStream *pTok)
+{
+ if (pTok->head) {
+ pTok->current = pTok->head;
+ pTok->current->current = 0;
+ }
+} /* RewindTokenStream */
+
+/*
+ * ReadToken() - Read the next token from a stream.
+ *
+ */
+
+int ReadToken(TokenStream *pTok, yystypepp * yylvalpp)
+{
+ char symbol_name[MAX_SYMBOL_NAME_LEN + 1];
+ char string_val[MAX_STRING_LEN + 1];
+ int ltoken, len;
+ char ch;
+
+ ltoken = lReadByte(pTok);
+ if (ltoken >= 0) {
+ if (ltoken > 127)
+ ltoken += 128;
+ switch (ltoken) {
+ case CPP_IDENTIFIER:
+ case CPP_TYPEIDENTIFIER:
+ len = 0;
+ ch = lReadByte(pTok);
+ while ((ch >= 'a' && ch <= 'z') ||
+ (ch >= 'A' && ch <= 'Z') ||
+ (ch >= '0' && ch <= '9') ||
+ ch == '_')
+ {
+ if (len < MAX_SYMBOL_NAME_LEN) {
+ symbol_name[len] = ch;
+ len++;
+ ch = lReadByte(pTok);
+ }
+ }
+ symbol_name[len] = '\0';
+ assert(ch == '\0');
+ yylvalpp->sc_ident = LookUpAddString(atable, symbol_name);
+ return CPP_IDENTIFIER;
+ break;
+ case CPP_STRCONSTANT:
+ len = 0;
+ while ((ch = lReadByte(pTok)) != 0)
+ if (len < MAX_STRING_LEN)
+ string_val[len++] = ch;
+ string_val[len] = 0;
+ yylvalpp->sc_ident = LookUpAddString(atable, string_val);
+ break;
+ case CPP_FLOATCONSTANT:
+ len = 0;
+ ch = lReadByte(pTok);
+ while ((ch >= '0' && ch <= '9')||(ch=='e'||ch=='E'||ch=='.')||(ch=='+'||ch=='-'))
+ {
+ if (len < MAX_SYMBOL_NAME_LEN) {
+ symbol_name[len] = ch;
+ len++;
+ ch = lReadByte(pTok);
+ }
+ }
+ symbol_name[len] = '\0';
+ assert(ch == '\0');
+ strcpy(yylvalpp->symbol_name,symbol_name);
+ yylvalpp->sc_fval=(float)atof(yylvalpp->symbol_name);
+ break;
+ case CPP_INTCONSTANT:
+ len = 0;
+ ch = lReadByte(pTok);
+ while ((ch >= '0' && ch <= '9'))
+ {
+ if (len < MAX_SYMBOL_NAME_LEN) {
+ symbol_name[len] = ch;
+ len++;
+ ch = lReadByte(pTok);
+ }
+ }
+ symbol_name[len] = '\0';
+ assert(ch == '\0');
+ strcpy(yylvalpp->symbol_name,symbol_name);
+ yylvalpp->sc_int=atoi(yylvalpp->symbol_name);
+ break;
+ case '(':
+ yylvalpp->sc_int = lReadByte(pTok);
+ break;
+ }
+ return ltoken;
+ }
+ return EOF_SY;
+} /* ReadToken */
+
+typedef struct TokenInputSrc {
+ InputSrc base;
+ TokenStream *tokens;
+ int (*final)(CPPStruct *);
+} TokenInputSrc;
+
+static int scan_token(TokenInputSrc *in, yystypepp * yylvalpp)
+{
+ int token = ReadToken(in->tokens, yylvalpp);
+ int (*final)(CPPStruct *);
+ cpp->tokenLoc->file = cpp->currentInput->name;
+ cpp->tokenLoc->line = cpp->currentInput->line;
+ if (token == '\n') {
+ in->base.line++;
+ return token;
+ }
+ if (token > 0) return token;
+ cpp->currentInput = in->base.prev;
+ final = in->final;
+ free(in);
+ if (final && !final(cpp)) return -1;
+ return cpp->currentInput->scan(cpp->currentInput, yylvalpp);
+}
+
+int ReadFromTokenStream(TokenStream *ts, int name, int (*final)(CPPStruct *))
+{
+ TokenInputSrc *in = malloc(sizeof(TokenInputSrc));
+ memset(in, 0, sizeof(TokenInputSrc));
+ in->base.name = name;
+ in->base.prev = cpp->currentInput;
+ in->base.scan = (int (*)(InputSrc *, yystypepp *))scan_token;
+ in->base.line = 1;
+ in->tokens = ts;
+ in->final = final;
+ RewindTokenStream(ts);
+ cpp->currentInput = &in->base;
+ return 1;
+}
+
+typedef struct UngotToken {
+ InputSrc base;
+ int token;
+ yystypepp lval;
+} UngotToken;
+
+static int reget_token(UngotToken *t, yystypepp * yylvalpp)
+{
+ int token = t->token;
+ *yylvalpp = t->lval;
+ cpp->currentInput = t->base.prev;
+ free(t);
+ return token;
+}
+
+void UngetToken(int token, yystypepp * yylvalpp) {
+ UngotToken *t = malloc(sizeof(UngotToken));
+ memset(t, 0, sizeof(UngotToken));
+ t->token = token;
+ t->lval = *yylvalpp;
+ t->base.scan = (void *)reget_token;
+ t->base.prev = cpp->currentInput;
+ t->base.name = cpp->currentInput->name;
+ t->base.line = cpp->currentInput->line;
+ cpp->currentInput = &t->base;
+}
+
+
+void DumpTokenStream(FILE *fp, TokenStream *s, yystypepp * yylvalpp) {
+ int token;
+ char str[100];
+
+ if (fp == 0) fp = stdout;
+ RewindTokenStream(s);
+ while ((token = ReadToken(s, yylvalpp)) > 0) {
+ switch (token) {
+ case CPP_IDENTIFIER:
+ case CPP_TYPEIDENTIFIER:
+ sprintf(str, "%s ", GetAtomString(atable, yylvalpp->sc_ident));
+ break;
+ case CPP_STRCONSTANT:
+ sprintf(str, "\"%s\"", GetAtomString(atable, yylvalpp->sc_ident));
+ break;
+ case CPP_FLOATCONSTANT:
+ /*printf("%g9.6 ", yylvalpp->sc_fval); */
+ break;
+ case CPP_INTCONSTANT:
+ /*printf("%d ", yylvalpp->sc_int); */
+ break;
+ default:
+ if (token >= 127)
+ sprintf(str, "%s ", GetAtomString(atable, token));
+ else
+ sprintf(str, "%c", token);
+ break;
+ }
+ CPPDebugLogMsg(str);
+ }
+}
+
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
+/*///////////////////////////////////// End of tokens.c /////////////////////////////////////// */
+/*///////////////////////////////////////////////////////////////////////////////////////////// */
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/tokens.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/tokens.h
new file mode 100755
index 000000000..0a25bf7c8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/preprocessor/tokens.h
@@ -0,0 +1,122 @@
+/* */
+/*Copyright (C) 2002-2005 3Dlabs Inc. Ltd. */
+/*All rights reserved. */
+/* */
+/*Redistribution and use in source and binary forms, with or without */
+/*modification, are permitted provided that the following conditions */
+/*are met: */
+/* */
+/* Redistributions of source code must retain the above copyright */
+/* notice, this list of conditions and the following disclaimer. */
+/* */
+/* Redistributions in binary form must reproduce the above */
+/* copyright notice, this list of conditions and the following */
+/* disclaimer in the documentation and/or other materials provided */
+/* with the distribution. */
+/* */
+/* Neither the name of 3Dlabs Inc. Ltd. nor the names of its */
+/* contributors may be used to endorse or promote products derived */
+/* from this software without specific prior written permission. */
+/* */
+/*THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
+/*"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
+/*LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
+/*FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE */
+/*COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
+/*INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, */
+/*BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
+/*LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER */
+/*CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT */
+/*LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN */
+/*ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
+/*POSSIBILITY OF SUCH DAMAGE. */
+/* */
+/****************************************************************************\
+Copyright (c) 2002, NVIDIA Corporation.
+
+NVIDIA Corporation("NVIDIA") supplies this software to you in
+consideration of your agreement to the following terms, and your use,
+installation, modification or redistribution of this NVIDIA software
+constitutes acceptance of these terms. If you do not agree with these
+terms, please do not use, install, modify or redistribute this NVIDIA
+software.
+
+In consideration of your agreement to abide by the following terms, and
+subject to these terms, NVIDIA grants you a personal, non-exclusive
+license, under NVIDIA's copyrights in this original NVIDIA software (the
+"NVIDIA Software"), to use, reproduce, modify and redistribute the
+NVIDIA Software, with or without modifications, in source and/or binary
+forms; provided that if you redistribute the NVIDIA Software, you must
+retain the copyright notice of NVIDIA, this notice and the following
+text and disclaimers in all such redistributions of the NVIDIA Software.
+Neither the name, trademarks, service marks nor logos of NVIDIA
+Corporation may be used to endorse or promote products derived from the
+NVIDIA Software without specific prior written permission from NVIDIA.
+Except as expressly stated in this notice, no other rights or licenses
+express or implied, are granted by NVIDIA herein, including but not
+limited to any patent rights that may be infringed by your derivative
+works or by other works in which the NVIDIA Software may be
+incorporated. No hardware is licensed hereunder.
+
+THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
+INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
+NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
+ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
+PRODUCTS.
+
+IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
+INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
+OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
+NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
+TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
+NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+\****************************************************************************/
+/* */
+/* tokens.h */
+/* */
+
+#if !defined(__TOKENS_H)
+#define __TOKENS_H 1
+
+#include "parser.h"
+
+#define EOF_SY (-1)
+
+typedef struct TokenBlock_Rec TokenBlock;
+
+typedef struct TokenStream_Rec {
+ struct TokenStream_Rec *next;
+ char *name;
+ TokenBlock *head;
+ TokenBlock *current;
+} TokenStream;
+
+struct TokenBlock_Rec {
+ TokenBlock *next;
+ int current;
+ int count;
+ int max;
+ unsigned char *data;
+};
+
+extern TokenStream stdlib_cpp_stream;
+
+
+TokenStream *NewTokenStream(const char *name);
+void DeleteTokenStream(TokenStream *pTok);
+void RecordToken(TokenStream *pTok, int token, yystypepp * yylvalpp);
+void RewindTokenStream(TokenStream *pTok);
+int ReadToken(TokenStream *pTok, yystypepp * yylvalpp);
+int ReadFromTokenStream(TokenStream *pTok, int name, int (*final)(CPPStruct *));
+void UngetToken(int, yystypepp * yylvalpp);
+
+#if defined(CPPC_ENABLE_TOOLS)
+
+void DumpTokenStream(FILE *, TokenStream *, yystypepp * yylvalpp);
+
+#endif /* defined(CPPC_ENABLE_TOOLS) */
+
+#endif /* !defined(__TOKENS_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/unistd.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/unistd.h
new file mode 100755
index 000000000..efadd63fd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/MachineIndependent/unistd.h
@@ -0,0 +1 @@
+// This is a NULL file and is meant to be empty
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/OGLCompilersDLL/Initialisation.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/OGLCompilersDLL/Initialisation.cpp
new file mode 100755
index 000000000..2e6f8c69b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/OGLCompilersDLL/Initialisation.cpp
@@ -0,0 +1,151 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#define SH_EXPORTING
+#include "Initialisation.h"
+#include "Include/InitializeGlobals.h"
+#include "Include/InitializeParseContext.h"
+#include "Public/ShaderLang.h"
+
+OS_TLSIndex GlobalProcessFlag = OS_INVALID_TLS_INDEX;
+
+bool InitProcess()
+{
+ if (GlobalProcessFlag != OS_INVALID_TLS_INDEX) {
+ //
+ // Function is re-entrant.
+ //
+ return true;
+ }
+
+ GlobalProcessFlag = OS_AllocTLSIndex();
+
+ if (GlobalProcessFlag == OS_INVALID_TLS_INDEX) {
+ assert (0 && "InitProcess(): Failed to allocate TLS area for init flag");
+ return false;
+ }
+
+ if (!InitializePoolIndex()) {
+ assert (0 && "InitProcess(): Failed to initalize global pool");
+ return false;
+ }
+
+ if (!InitializeParseContextIndex()) {
+ assert (0 && "InitProcess(): Failed to initalize parse context");
+ return false;
+ }
+
+ InitThread();
+ return true;
+}
+
+
+bool InitThread()
+{
+ //
+ // This function is re-entrant
+ //
+ if (GlobalProcessFlag == OS_INVALID_TLS_INDEX) {
+ assert(0 && "InitThread(): Process hasn't been initalised.");
+ return false;
+ }
+
+ if (OS_GetTLSValue(GlobalProcessFlag) != 0) {
+ return true;
+ }
+
+ InitializeGlobalPools();
+
+ if(!InitializeGlobalParseContext())
+ return false;
+
+ if(!OS_SetTLSValue(GlobalProcessFlag, (void *)1)) {
+ assert(0 && "InitThread(): Unable to set init flag.");
+ return false;
+ }
+
+ return true;
+}
+
+
+bool DetachThread()
+{
+ bool retFlag = true;
+
+ if (GlobalProcessFlag == OS_INVALID_TLS_INDEX) {
+ assert(0 && "DetachThread(): Process hasn't been initalised.");
+ return false;
+ }
+
+ //
+ // Function is re-entrant and this thread may not have been initalised.
+ //
+ if (OS_GetTLSValue(GlobalProcessFlag) != 0)
+ {
+ if(!OS_SetTLSValue(GlobalProcessFlag, (void *)0)) {
+ assert(0 && "DetachThread(): Unable to clear init flag.");
+ retFlag = false;
+ }
+
+ FreeGlobalPools();
+
+ if (!FreeParseContext())
+ retFlag = false;
+ }
+
+ return retFlag;
+}
+
+bool DetachProcess()
+{
+ bool retFlag = true;
+
+ if (GlobalProcessFlag == OS_INVALID_TLS_INDEX)
+ return true;
+
+ ShFinalize();
+
+ retFlag = DetachThread();
+
+ FreePoolIndex();
+
+ if(!FreeParseContextIndex())
+ retFlag = false;
+
+ OS_FreeTLSIndex(GlobalProcessFlag);
+ GlobalProcessFlag = OS_INVALID_TLS_INDEX;
+
+ return retFlag;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/OGLCompilersDLL/Initialisation.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/OGLCompilersDLL/Initialisation.h
new file mode 100755
index 000000000..1cfd97eeb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/OGLCompilersDLL/Initialisation.h
@@ -0,0 +1,47 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+#ifndef __INITIALISATION_H
+#define __INITIALISATION_H
+
+
+#include "osinclude.h"
+
+
+bool InitProcess();
+bool InitThread();
+bool DetachThread();
+bool DetachProcess();
+
+#endif // __INITIALISATION_H
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/OSDependent/Linux/osinclude.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/OSDependent/Linux/osinclude.h
new file mode 100755
index 000000000..8b20b961c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/OSDependent/Linux/osinclude.h
@@ -0,0 +1,78 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#ifndef __OSINCLUDE_H
+#define __OSINCLUDE_H
+
+//
+// This file contains any Linux specific functions.
+//
+
+/* WORKAROUND: linux builds seem not to define "linux" */
+/*#if !(defined(linux))
+#error Trying to include a Linux specific file in a non-Linux build.
+#endif*/
+
+#include <pthread.h>
+#include <semaphore.h>
+#include <assert.h>
+#include <errno.h>
+#include "Include/InitializeGlobals.h"
+#include "Include/PoolAlloc.h"
+
+#define _vsnprintf vsnprintf
+
+void DetachThreadLinux(void *);
+
+//
+// Thread Local Storage Operations
+//
+typedef unsigned int OS_TLSIndex;
+#define OS_INVALID_TLS_INDEX 0xFFFFFFFF
+
+OS_TLSIndex OS_AllocTLSIndex();
+bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
+bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
+
+
+inline void * OS_GetTLSValue(OS_TLSIndex nIndex)
+{
+ //
+ // This function should return 0 if nIndex is invalid.
+ //
+ assert(nIndex != OS_INVALID_TLS_INDEX);
+ return (pthread_getspecific(nIndex));
+}
+
+#endif // __OSINCLUDE_H
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/OSDependent/Linux/ossource.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/OSDependent/Linux/ossource.cpp
new file mode 100755
index 000000000..4bcd66a31
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/OSDependent/Linux/ossource.cpp
@@ -0,0 +1,140 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+//
+// This file contains the Linux specific functions
+//
+#include "osinclude.h"
+#include "Initialisation.h"
+
+/*#if !(defined(linux))
+#error Trying to build a Linux specific file in a non-Linux build.
+#endif*/
+
+//
+// Thread cleanup
+//
+
+//
+// Wrapper for Linux call to DetachThread. This is required as pthread_cleanup_push() expects
+// the cleanup routine to return void.
+//
+void DetachThreadLinux(void *)
+{
+ DetachThread();
+}
+
+
+//
+// Registers cleanup handler, sets cancel type and state, and excecutes the thread specific
+// cleanup handler. This function will be called in the Standalone.cpp for regression
+// testing. When OpenGL applications are run with the driver code, Linux OS does the
+// thread cleanup.
+//
+void OS_CleanupThreadData(void)
+{
+ int old_cancel_state, old_cancel_type;
+ void *cleanupArg = NULL;
+
+ //
+ // Set thread cancel state and push cleanup handler.
+ //
+ pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &old_cancel_state);
+ pthread_cleanup_push(DetachThreadLinux, (void *) cleanupArg);
+
+ //
+ // Put the thread in deferred cancellation mode.
+ //
+ pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &old_cancel_type);
+
+ //
+ // Pop cleanup handler and execute it prior to unregistering the cleanup handler.
+ //
+ pthread_cleanup_pop(1);
+
+ //
+ // Restore the thread's previous cancellation mode.
+ //
+ pthread_setcanceltype(old_cancel_state, NULL);
+}
+
+
+//
+// Thread Local Storage Operations
+//
+OS_TLSIndex OS_AllocTLSIndex()
+{
+ pthread_key_t pPoolIndex;
+
+ //
+ // Create global pool key.
+ //
+ if ((pthread_key_create(&pPoolIndex, NULL)) != 0) {
+ assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
+ return false;
+ }
+ else
+ return pPoolIndex;
+}
+
+
+bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
+{
+ if (nIndex == OS_INVALID_TLS_INDEX) {
+ assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
+ return false;
+ }
+
+ if (pthread_setspecific(nIndex, lpvValue) == 0)
+ return true;
+ else
+ return false;
+}
+
+
+bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
+{
+ if (nIndex == OS_INVALID_TLS_INDEX) {
+ assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
+ return false;
+ }
+
+ //
+ // Delete the global pool key.
+ //
+ if (pthread_key_delete(nIndex) == 0)
+ return true;
+ else
+ return false;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/OSDependent/Windows/osinclude.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/OSDependent/Windows/osinclude.h
new file mode 100755
index 000000000..97a9e9f3d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/OSDependent/Windows/osinclude.h
@@ -0,0 +1,68 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#ifndef __OSINCLUDE_H
+#define __OSINCLUDE_H
+
+//
+// This file contains contains the window's specific datatypes and
+// declares any windows specific functions.
+//
+
+#if !(defined(_WIN32) || defined(_WIN64))
+#error Trying to include a windows specific file in a non windows build.
+#endif
+
+#define STRICT
+#define VC_EXTRALEAN 1
+#include <windows.h>
+#include <assert.h>
+
+//
+// Thread Local Storage Operations
+//
+typedef DWORD OS_TLSIndex;
+#define OS_INVALID_TLS_INDEX (TLS_OUT_OF_INDEXES)
+
+OS_TLSIndex OS_AllocTLSIndex();
+bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
+bool OS_FreeTLSIndex(OS_TLSIndex nIndex);
+
+inline void* OS_GetTLSValue(OS_TLSIndex nIndex)
+{
+ assert(nIndex != OS_INVALID_TLS_INDEX);
+ return TlsGetValue(nIndex);
+}
+
+#endif // __OSINCLUDE_H
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/OSDependent/Windows/ossource.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/OSDependent/Windows/ossource.cpp
new file mode 100755
index 000000000..35d086614
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/OSDependent/Windows/ossource.cpp
@@ -0,0 +1,119 @@
+//
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+
+#include "Initialisation.h"
+
+//
+// This file contains contains the window's specific functions
+//
+
+#if !(defined(_WIN32) || defined(_WIN64))
+#error Trying to build a windows specific file in a non windows build.
+#endif
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ switch (fdwReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ if (!InitProcess())
+ return false;
+ break;
+ case DLL_THREAD_ATTACH:
+ if (!InitThread())
+ return false;
+ break;
+
+ case DLL_THREAD_DETACH:
+
+ if (!DetachThread())
+ return false;
+ break;
+
+ case DLL_PROCESS_DETACH:
+
+ DetachProcess();
+ break;
+
+ default:
+ assert(0 && "DllMain(): Reason for calling DLL Main is unknown");
+ return false;
+ }
+
+ return true;
+}
+
+//
+// Thread Local Storage Operations
+//
+OS_TLSIndex OS_AllocTLSIndex()
+{
+ DWORD dwIndex = TlsAlloc();
+ if (dwIndex == TLS_OUT_OF_INDEXES) {
+ assert(0 && "OS_AllocTLSIndex(): Unable to allocate Thread Local Storage");
+ return (OS_INVALID_TLS_INDEX);
+ }
+
+ return dwIndex;
+}
+
+
+bool OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue)
+{
+ if (nIndex == OS_INVALID_TLS_INDEX)
+ {
+ assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
+ return false;
+ }
+
+ if (TlsSetValue(nIndex, lpvValue))
+ return true;
+ else
+ return false;
+}
+
+
+bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
+{
+ if (nIndex == OS_INVALID_TLS_INDEX) {
+ assert(0 && "OS_SetTLSValue(): Invalid TLS Index");
+ return false;
+ }
+
+ if (TlsFree(nIndex))
+ return true;
+ else
+ return false;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/Public/ShaderLang.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/Public/ShaderLang.h
new file mode 100755
index 000000000..34b1688e8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/Public/ShaderLang.h
@@ -0,0 +1,212 @@
+/*
+//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+*/
+#ifndef _COMPILER_INTERFACE_INCLUDED_
+#define _COMPILER_INTERFACE_INCLUDED_
+
+#include "../Include/ResourceLimits.h"
+
+#ifdef _WIN32
+#define C_DECL __cdecl
+/*#ifdef SH_EXPORTING
+ #define SH_IMPORT_EXPORT __declspec(dllexport)
+#else
+ #define SH_IMPORT_EXPORT __declspec(dllimport)
+#endif*/
+/* disable DLL linking */
+#define SH_IMPORT_EXPORT
+#else
+#define SH_IMPORT_EXPORT
+#define __fastcall
+#define C_DECL
+#endif
+
+/*
+// This is the platform independent interface between an OGL driver
+// and the shading language compiler/linker.
+*/
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+/*
+// Driver must call this first, once, before doing any other
+// compiler/linker operations.
+*/
+SH_IMPORT_EXPORT int ShInitialize();
+/*
+// Driver should call this at shutdown.
+*/
+SH_IMPORT_EXPORT int __fastcall ShFinalize();
+
+/*
+// Types of languages the compiler can consume.
+*/
+typedef enum {
+ EShLangVertex,
+ EShLangFragment,
+ EShLangPack,
+ EShLangUnpack,
+ EShLangCount
+} EShLanguage;
+
+/*
+// Types of output the linker will create.
+*/
+typedef enum {
+ EShExVertexFragment,
+ EShExPackFragment,
+ EShExUnpackFragment,
+ EShExFragment
+} EShExecutable;
+
+/*
+// Optimization level for the compiler.
+*/
+typedef enum {
+ EShOptNoGeneration,
+ EShOptNone,
+ EShOptSimple, /* Optimizations that can be done quickly */
+ EShOptFull /* Optimizations that will take more time */
+} EShOptimizationLevel;
+
+/*
+// Build a table for bindings. This can be used for locating
+// attributes, uniforms, globals, etc., as needed.
+*/
+typedef struct {
+ char* name;
+ int binding;
+} ShBinding;
+
+typedef struct {
+ int numBindings;
+ ShBinding* bindings; /* array of bindings */
+} ShBindingTable;
+
+/*
+// ShHandle held by but opaque to the driver. It is allocated,
+// managed, and de-allocated by the compiler/linker. It's contents
+// are defined by and used by the compiler and linker. For example,
+// symbol table information and object code passed from the compiler
+// to the linker can be stored where ShHandle points.
+//
+// If handle creation fails, 0 will be returned.
+*/
+typedef void* ShHandle;
+
+/*
+// Driver calls these to create and destroy compiler/linker
+// objects.
+*/
+SH_IMPORT_EXPORT ShHandle ShConstructCompiler(const EShLanguage, int debugOptions); /* one per shader */
+SH_IMPORT_EXPORT ShHandle ShConstructLinker(const EShExecutable, int debugOptions); /* one per shader pair */
+SH_IMPORT_EXPORT ShHandle ShConstructUniformMap(); /* one per uniform namespace (currently entire program object) */
+SH_IMPORT_EXPORT void ShDestruct(ShHandle);
+
+/*
+// The return value of ShCompile is boolean, indicating
+// success or failure.
+//
+// The info-log should be written by ShCompile into
+// ShHandle, so it can answer future queries.
+*/
+SH_IMPORT_EXPORT int ShCompile(
+ const ShHandle,
+ const char* const shaderStrings[],
+ const int numStrings,
+ const EShOptimizationLevel,
+ const TBuiltInResource *resources,
+ int debugOptions
+ );
+
+
+/*
+// Similar to ShCompile, but accepts an opaque handle to an
+// intermediate language structure.
+*/
+SH_IMPORT_EXPORT int ShCompileIntermediate(
+ ShHandle compiler,
+ ShHandle intermediate,
+ const EShOptimizationLevel,
+ int debuggable /* boolean */
+ );
+
+SH_IMPORT_EXPORT int ShLink(
+ const ShHandle, /* linker object */
+ const ShHandle h[], /* compiler objects to link together */
+ const int numHandles,
+ ShHandle uniformMap, /* updated with new uniforms */
+ short int** uniformsAccessed, /* returned with indexes of uniforms accessed */
+ int* numUniformsAccessed);
+
+/*
+// ShSetEncrpytionMethod is a place-holder for specifying
+// how source code is encrypted.
+*/
+SH_IMPORT_EXPORT void ShSetEncryptionMethod(ShHandle);
+
+/*
+// All the following return 0 if the information is not
+// available in the object passed down, or the object is bad.
+*/
+SH_IMPORT_EXPORT const char* ShGetInfoLog(const ShHandle);
+SH_IMPORT_EXPORT const void* ShGetExecutable(const ShHandle);
+SH_IMPORT_EXPORT int ShSetVirtualAttributeBindings(const ShHandle, const ShBindingTable*); /* to detect user aliasing */
+SH_IMPORT_EXPORT int ShSetFixedAttributeBindings(const ShHandle, const ShBindingTable*); /* to force any physical mappings */
+SH_IMPORT_EXPORT int ShGetPhysicalAttributeBindings(const ShHandle, const ShBindingTable**); /* for all attributes */
+/*
+// Tell the linker to never assign a vertex attribute to this list of physical attributes
+*/
+SH_IMPORT_EXPORT int ShExcludeAttributes(const ShHandle, int *attributes, int count);
+
+/*
+// Returns the location ID of the named uniform.
+// Returns -1 if error.
+*/
+SH_IMPORT_EXPORT int ShGetUniformLocation(const ShHandle uniformMap, const char* name);
+
+enum TDebugOptions {
+ EDebugOpNone = 0x000,
+ EDebugOpIntermediate = 0x001,
+ EDebugOpAssembly = 0x002,
+ EDebugOpObjectCode = 0x004,
+ EDebugOpLinkMaps = 0x008
+};
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif /* _COMPILER_INTERFACE_INCLUDED_ */
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/Public/ShaderLangExt.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/Public/ShaderLangExt.h
new file mode 100755
index 000000000..e44b5f99a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/Public/ShaderLangExt.h
@@ -0,0 +1,57 @@
+//
+//Copyright (C) 2002-2004 3Dlabs Inc. Ltd.
+//All rights reserved.
+//
+//Redistribution and use in source and binary forms, with or without
+//modification, are permitted provided that the following conditions
+//are met:
+//
+// Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+//
+// Neither the name of 3Dlabs Inc. Ltd. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+//POSSIBILITY OF SUCH DAMAGE.
+//
+#ifndef _SHADERLANG_EXTENSION_INCLUDED_
+#define _SHADERLANG_EXTENSION_INCLUDED_
+
+#include "ShaderLang.h"
+
+//
+// This is the platform independent interface between an OGL driver
+// and the shading language compiler/linker.
+//
+
+#ifdef __cplusplus
+ extern "C" {
+#endif
+
+SH_IMPORT_EXPORT int ShLinkExt(
+ const ShHandle, // linker object
+ const ShHandle h[], // compiler objects to link together
+ const int numHandles);
+
+#ifdef __cplusplus
+ }
+#endif
+
+#endif // _SHADERLANG_EXTENSION_INCLUDED_
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/descrip.mms b/nx-X11/extras/Mesa/src/mesa/shader/slang/descrip.mms
new file mode 100644
index 000000000..6f2b90296
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/descrip.mms
@@ -0,0 +1,52 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+# Last revision : 1 June 2005
+
+.first
+ define gl [----.include.gl]
+ define math [--.math]
+ define swrast [--.swrast]
+ define array_cache [--.array_cache]
+
+.include [----]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [----.include],[--.main],[--.glapi],[-.slang],[-.grammar],[-]
+LIBDIR = [----.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)
+
+SOURCES = \
+ slang_compile.c,slang_preprocess.c
+
+OBJECTS = \
+ slang_compile.obj,slang_preprocess.obj,slang_utility.obj,\
+ slang_execute.obj,slang_assemble.obj,slang_assemble_conditional.obj,\
+ slang_assemble_constructor.obj,slang_assemble_typeinfo.obj,\
+ slang_storage.obj,slang_assemble_assignment.obj
+
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+ @ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
+
+clean :
+ purge
+ delete *.obj;*
+
+slang_compile.obj : slang_compile.c
+slang_preprocess.obj : slang_preprocess.c
+slang_utility.obj : slang_utility.c
+slang_execute.obj : slang_execute.c
+slang_assemble.obj : slang_assemble.c
+slang_assemble_conditional.obj : slang_assemble_conditional.c
+slang_assemble_constructor.obj : slang_assemble_constructor.c
+slang_assemble_typeinfo.obj : slang_assemble_typeinfo.c
+slang_storage.obj : slang_storage.c
+slang_assemble_assignment.obj : slang_assemble_assignment.c
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/gc_to_bin.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/gc_to_bin.c
new file mode 100755
index 000000000..4bd211442
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/gc_to_bin.c
@@ -0,0 +1,79 @@
+#include "../../grammar/grammar_crt.h"
+#include "../../grammar/grammar_crt.c"
+#include <stdio.h>
+
+static const char *slang_shader_syn =
+#include "slang_shader_syn.h"
+;
+
+static void gc_to_bin (grammar id, const char *in, const char *out)
+{
+ FILE *f;
+ byte *source, *prod;
+ unsigned int size, i, line = 0;
+
+ f = fopen (in, "r");
+ if (f == NULL)
+ return;
+ fseek (f, 0, SEEK_END);
+ size = ftell (f);
+ fseek (f, 0, SEEK_SET);
+ source = (byte *) grammar_alloc_malloc (size + 1);
+ source[fread (source, 1, size, f)] = '\0';
+ fclose (f);
+
+ if (!grammar_fast_check (id, source, &prod, &size, 65536))
+ {
+ grammar_alloc_free (source);
+ return;
+ }
+
+ f = fopen (out, "w");
+ for (i = 0; i < size; i++)
+ {
+ unsigned int a;
+ if (prod[i] < 10)
+ a = 1;
+ else if (prod[i] < 100)
+ a = 2;
+ else
+ a = 3;
+ if (i < size - 1)
+ a++;
+ if (line + a > 100)
+ {
+ fprintf (f, "\n");
+ line = 0;
+ }
+ line += a;
+ fprintf (f, "%d", prod[i]);
+ if (i < size - 1)
+ fprintf (f, ",");
+ }
+ fclose (f);
+ grammar_alloc_free (prod);
+}
+
+int main ()
+{
+ grammar id;
+
+ id = grammar_load_from_text ((const byte *) slang_shader_syn);
+ if (id == 0)
+ return 1;
+
+ grammar_set_reg8 (id, (const byte *) "parsing_builtin", 1);
+
+ grammar_set_reg8 (id, (const byte *) "shader_type", 1);
+ gc_to_bin (id, "slang_core.gc", "slang_core_gc_bin.h");
+ gc_to_bin (id, "slang_common_builtin.gc", "slang_common_builtin_gc_bin.h");
+ gc_to_bin (id, "slang_fragment_builtin.gc", "slang_fragment_builtin_gc_bin.h");
+
+ grammar_set_reg8 (id, (const byte *) "shader_type", 2);
+ gc_to_bin (id, "slang_vertex_builtin.gc", "slang_vertex_builtin_gc_bin.h");
+
+ grammar_destroy (id);
+
+ return 0;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/gc_to_string.py b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/gc_to_string.py
new file mode 100644
index 000000000..a9d399fc1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/gc_to_string.py
@@ -0,0 +1,55 @@
+#!/usr/bin/env python
+
+# Mesa 3-D graphics library
+# Version: 6.3
+#
+# Copyright (C) 2005 Brian Paul All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+# author: Michal Krol
+
+# converts slang source file into a C header containing one big string
+# comments and trailing whitespaces are stripped
+# C style comments are not supported, only C++ style ones are
+# empty lines are kept to maintain line numbers correlation
+# escape characters are not handled except for newlines
+
+# example:
+# -- source file
+# // some comment
+#
+# attribute vec4 myPosition; // my vertex data
+# -- output file
+# "\n"
+# "\n"
+# "attribute vec4 myPosition;\n"
+
+# usage: gc_to_string.py filename.gc > filename_gc.h
+
+import sys
+
+f = open (sys.argv[1], 'r')
+s = f.readline ()
+while s != '':
+ s = s[0:s.find ('//')].rstrip ()
+ # output empty lines, too, so line numbers can be tracked
+ print '\"' + s + '\\n\"'
+ s = f.readline ()
+f.close ()
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_common_builtin.gc b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_common_builtin.gc
new file mode 100755
index 000000000..0b3ed0e88
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_common_builtin.gc
@@ -0,0 +1,1410 @@
+
+//
+// TODO:
+// - implement sin, asin, acos, atan, pow, log2, floor, ceil,
+// - implement texture1D, texture2D, texture3D, textureCube,
+// - implement shadow1D, shadow2D,
+// - implement noise1, noise2, noise3, noise4,
+//
+
+//
+// From Shader Spec, ver. 1.10, rev. 59
+//
+// The following built-in constants are provided to vertex and fragment shaders.
+//
+
+//
+// Implementation dependent constants. The example values below
+// are the minimum values allowed for these maximums.
+//
+
+const int gl_MaxLights = 8; // GL 1.0
+const int gl_MaxClipPlanes = 6; // GL 1.0
+const int gl_MaxTextureUnits = 2; // GL 1.3
+const int gl_MaxTextureCoords = 2; // ARB_fragment_program
+const int gl_MaxVertexAttribs = 16; // ARB_vertex_shader
+const int gl_MaxVertexUniformComponents = 512; // ARB_vertex_shader
+const int gl_MaxVaryingFloats = 32; // ARB_vertex_shader
+const int gl_MaxVertexTextureImageUnits = 0; // ARB_vertex_shader
+const int gl_MaxCombinedTextureImageUnits = 2; // ARB_vertex_shader
+const int gl_MaxTextureImageUnits = 2; // ARB_fragment_shader
+const int gl_MaxFragmentUniformComponents = 64; // ARB_fragment_shader
+const int gl_MaxDrawBuffers = 1; // proposed ARB_draw_buffers
+
+//
+// As an aid to accessing OpenGL processing state, the following uniform variables are built into
+// the OpenGL Shading Language. All page numbers and notations are references to the 1.4
+// specification.
+//
+
+//
+// Matrix state. p. 31, 32, 37, 39, 40.
+//
+
+uniform mat4 gl_ModelViewMatrix;
+uniform mat4 gl_ProjectionMatrix;
+uniform mat4 gl_ModelViewProjectionMatrix;
+uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];
+
+//
+// Derived matrix state that provides inverse and transposed versions
+// of the matrices above. Poorly conditioned matrices may result
+// in unpredictable values in their inverse forms.
+//
+uniform mat3 gl_NormalMatrix; // transpose of the inverse of the
+ // upper leftmost 3x3 of gl_ModelViewMatrix
+
+uniform mat4 gl_ModelViewMatrixInverse;
+uniform mat4 gl_ProjectionMatrixInverse;
+uniform mat4 gl_ModelViewProjectionMatrixInverse;
+uniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords];
+
+uniform mat4 gl_ModelViewMatrixTranspose;
+uniform mat4 gl_ProjectionMatrixTranspose;
+uniform mat4 gl_ModelViewProjectionMatrixTranspose;
+uniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords];
+
+uniform mat4 gl_ModelViewMatrixInverseTranspose;
+uniform mat4 gl_ProjectionMatrixInverseTranspose;
+uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;
+uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];
+
+//
+// Normal scaling p. 39.
+//
+
+uniform float gl_NormalScale;
+
+//
+// Depth range in window coordinates, p. 33
+//
+
+struct gl_DepthRangeParameters {
+ float near; // n
+ float far; // f
+ float diff; // f - n
+};
+
+uniform gl_DepthRangeParameters gl_DepthRange;
+
+//
+// Clip planes p. 42.
+//
+
+uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];
+
+//
+// Point Size, p. 66, 67.
+//
+
+struct gl_PointParameters {
+ float size;
+ float sizeMin;
+ float sizeMax;
+ float fadeThresholdSize;
+ float distanceConstantAttenuation;
+ float distanceLinearAttenuation;
+ float distanceQuadraticAttenuation;
+};
+
+uniform gl_PointParameters gl_Point;
+
+//
+// Material State p. 50, 55.
+//
+
+struct gl_MaterialParameters {
+ vec4 emission; // Ecm
+ vec4 ambient; // Acm
+ vec4 diffuse; // Dcm
+ vec4 specular; // Scm
+ float shininess; // Srm
+};
+
+uniform gl_MaterialParameters gl_FrontMaterial;
+uniform gl_MaterialParameters gl_BackMaterial;
+
+//
+// Light State p 50, 53, 55.
+//
+
+struct gl_LightSourceParameters {
+ vec4 ambient; // Acli
+ vec4 diffuse; // Dcli
+ vec4 specular; // Scli
+ vec4 position; // Ppli
+ vec4 halfVector; // Derived: Hi
+ vec3 spotDirection; // Sdli
+ float spotExponent; // Srli
+ float spotCutoff; // Crli
+ // (range: [0.0,90.0], 180.0)
+ float spotCosCutoff; // Derived: cos(Crli)
+ // (range: [1.0,0.0],-1.0)
+ float constantAttenuation; // K0
+ float linearAttenuation; // K1
+ float quadraticAttenuation; // K2
+};
+
+uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];
+
+struct gl_LightModelParameters {
+ vec4 ambient; // Acs
+};
+
+uniform gl_LightModelParameters gl_LightModel;
+
+//
+// Derived state from products of light and material.
+//
+
+struct gl_LightModelProducts {
+ vec4 sceneColor; // Derived. Ecm + Acm * Acs
+};
+
+uniform gl_LightModelProducts gl_FrontLightModelProduct;
+uniform gl_LightModelProducts gl_BackLightModelProduct;
+
+struct gl_LightProducts {
+ vec4 ambient; // Acm * Acli
+ vec4 diffuse; // Dcm * Dcli
+ vec4 specular; // Scm * Scli
+};
+
+uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];
+uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];
+
+//
+// Texture Environment and Generation, p. 152, p. 40-42.
+//
+
+uniform vec4 gl_TextureEnvColor[gl_MaxTextureImageUnits];
+uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];
+uniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];
+uniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];
+uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];
+uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];
+uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];
+uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];
+uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];
+
+//
+// Fog p. 161
+//
+
+struct gl_FogParameters {
+ vec4 color;
+ float density;
+ float start;
+ float end;
+ float scale; // Derived: 1.0 / (end - start)
+};
+
+uniform gl_FogParameters gl_Fog;
+
+//
+// The OpenGL Shading Language defines an assortment of built-in convenience functions for scalar
+// and vector operations. Many of these built-in functions can be used in more than one type
+// of shader, but some are intended to provide a direct mapping to hardware and so are available
+// only for a specific type of shader.
+//
+// The built-in functions basically fall into three categories:
+//
+// * They expose some necessary hardware functionality in a convenient way such as accessing
+// a texture map. There is no way in the language for these functions to be emulated by a shader.
+//
+// * They represent a trivial operation (clamp, mix, etc.) that is very simple for the user
+// to write, but they are very common and may have direct hardware support. It is a very hard
+// problem for the compiler to map expressions to complex assembler instructions.
+//
+// * They represent an operation graphics hardware is likely to accelerate at some point. The
+// trigonometry functions fall into this category.
+//
+// Many of the functions are similar to the same named ones in common C libraries, but they support
+// vector input as well as the more traditional scalar input.
+//
+// Applications should be encouraged to use the built-in functions rather than do the equivalent
+// computations in their own shader code since the built-in functions are assumed to be optimal
+// (e.g., perhaps supported directly in hardware).
+//
+// User code can replace built-in functions with their own if they choose, by simply re-declaring
+// and defining the same name and argument list.
+//
+
+//
+// 8.1 Angle and Trigonometry Functions
+//
+// Function parameters specified as angle are assumed to be in units of radians. In no case will
+// any of these functions result in a divide by zero error. If the divisor of a ratio is 0, then
+// results will be undefined.
+//
+// These all operate component-wise. The description is per component.
+//
+
+//
+// Converts degrees to radians and returns the result, i.e., result = PI*deg/180.
+//
+
+float radians (float deg) {
+ return 3.141593 * deg / 180.0;
+}
+vec2 radians (vec2 deg) {
+ return vec2 (radians (deg.x), radians (deg.y));
+}
+vec3 radians (vec3 deg) {
+ return vec3 (radians (deg.x), radians (deg.y), radians (deg.z));
+}
+vec4 radians (vec4 deg) {
+ return vec4 (radians (deg.x), radians (deg.y), radians (deg.z), radians (deg.w));
+}
+
+//
+// Converts radians to degrees and returns the result, i.e., result = 180*rad/PI.
+//
+
+float degrees (float rad) {
+ return 180.0 * rad / 3.141593;
+}
+vec2 degrees (vec2 rad) {
+ return vec2 (degrees (rad.x), degrees (rad.y));
+}
+vec3 degrees (vec3 rad) {
+ return vec3 (degrees (rad.x), degrees (rad.y), degrees (rad.z));
+}
+vec4 degrees (vec4 rad) {
+ return vec4 (degrees (rad.x), degrees (rad.y), degrees (rad.z), degrees (rad.w));
+}
+
+//
+// The standard trigonometric sine function.
+//
+// XXX
+float sin (float angle) {
+ return 0.0;
+}
+vec2 sin (vec2 angle) {
+ return vec2 (sin (angle.x), sin (angle.y));
+}
+vec3 sin (vec3 angle) {
+ return vec3 (sin (angle.x), sin (angle.y), sin (angle.z));
+}
+vec4 sin (vec4 angle) {
+ return vec4 (sin (angle.x), sin (angle.y), sin (angle.z), sin (angle.w));
+}
+
+//
+// The standard trigonometric cosine function.
+//
+
+float cos (float angle) {
+ return sin (angle + 1.5708);
+}
+vec2 cos (vec2 angle) {
+ return vec2 (cos (angle.x), cos (angle.y));
+}
+vec3 cos (vec3 angle) {
+ return vec3 (cos (angle.x), cos (angle.y), cos (angle.z));
+}
+vec4 cos (vec4 angle) {
+ return vec4 (cos (angle.x), cos (angle.y), cos (angle.z), cos (angle.w));
+}
+
+//
+// The standard trigonometric tangent.
+//
+
+float tan (float angle) {
+ return sin (angle) / cos (angle);
+}
+vec2 tan (vec2 angle) {
+ return vec2 (tan (angle.x), tan (angle.y));
+}
+vec3 tan (vec3 angle) {
+ return vec3 (tan (angle.x), tan (angle.y), tan (angle.z));
+}
+vec4 tan (vec4 angle) {
+ return vec4 (tan (angle.x), tan (angle.y), tan (angle.z), tan (angle.w));
+}
+
+//
+// Arc sine. Returns an angle whose sine is x. The range of values returned by this function is
+// [–PI/2, PI/2]. Results are undefined if |x| > 1.
+//
+// XXX
+float asin (float x) {
+ return 0.0;
+}
+vec2 asin (vec2 x) {
+ return vec2 (asin (x.x), asin (x.y));
+}
+vec3 asin (vec3 x) {
+ return vec3 (asin (x.x), asin (x.y), asin (x.z));
+}
+vec4 asin (vec4 x) {
+ return vec4 (asin (x.x), asin (x.y), asin (x.z), asin (x.w));
+}
+
+//
+// Arc cosine. Returns an angle whose cosine is x. The range of values returned by this function is
+// [0, PI]. Results are undefined if |x| > 1.
+//
+// XXX
+float acos (float x) {
+ return 0.0;
+}
+vec2 acos (vec2 x) {
+ return vec2 (acos (x.x), acos (x.y));
+}
+vec3 acos (vec3 x) {
+ return vec3 (acos (x.x), acos (x.y), acos (x.z));
+}
+vec4 acos (vec4 x) {
+ return vec4 (acos (x.x), acos (x.y), acos (x.z), acos (x.w));
+}
+
+//
+// Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine
+// what quadrant the angle is in. The range of values returned by this function is [–PI, PI].
+// Results are undefined if x and y are both 0.
+//
+// XXX
+float atan (float x, float y) {
+ return 0.0;
+}
+vec2 atan (vec2 x, vec2 y) {
+ return vec2 (atan (x.x, y.x), atan (x.y, y.y));
+}
+vec3 atan (vec3 x, vec3 y) {
+ return vec3 (atan (x.x, y.x), atan (x.y, y.y), atan (x.z, y.z));
+}
+vec4 atan (vec4 x, vec4 y) {
+ return vec4 (atan (x.x, y.x), atan (x.y, y.y), atan (x.z, y.z), atan (x.w, y.w));
+}
+
+//
+// Arc tangent. Returns an angle whose tangent is y_over_x. The range of values returned by this
+// function is [–PI/2, PI/2].
+//
+// XXX
+float atan (float y_over_x) {
+ return 0.0;
+}
+vec2 atan (vec2 y_over_x) {
+ return vec2 (atan (y_over_x.x), atan (y_over_x.y));
+}
+vec3 atan (vec3 y_over_x) {
+ return vec3 (atan (y_over_x.x), atan (y_over_x.y), atan (y_over_x.z));
+}
+vec4 atan (vec4 y_over_x) {
+ return vec4 (atan (y_over_x.x), atan (y_over_x.y), atan (y_over_x.z), atan (y_over_x.w));
+}
+
+//
+// 8.2 Exponential Functions
+//
+// These all operate component-wise. The description is per component.
+//
+
+//
+// Returns x raised to the y power, i.e., x^y.
+// Results are undefined if x < 0.
+// Results are undefined if x = 0 and y <= 0.
+//
+// XXX
+float pow (float x, float y) {
+ return 0.0;
+}
+vec2 pow (vec2 x, vec2 y) {
+ return vec2 (pow (x.x, y.x), pow (x.y, y.y));
+}
+vec3 pow (vec3 x, vec3 y) {
+ return vec3 (pow (x.x, y.x), pow (x.y, y.y), pow (x.z, y.z));
+}
+vec4 pow (vec4 x, vec4 y) {
+ return vec4 (pow (x.x, y.x), pow (x.y, y.y), pow (x.z, y.z), pow (x.w, y.w));
+}
+
+//
+// Returns the natural exponentiation of x, i.e., e^x.
+//
+
+float exp (float x) {
+ return pow (2.71828183, x);
+}
+vec2 exp (vec2 x) {
+ return vec2 (exp (x.x), exp (x.y));
+}
+vec3 exp (vec3 x) {
+ return vec3 (exp (x.x), exp (x.y), exp (x.z));
+}
+vec4 exp (vec4 x) {
+ return vec4 (exp (x.x), exp (x.y), exp (x.z), exp (x.w));
+}
+
+//
+// Returns the natural logarithm of x, i.e., returns the value y which satisfies the equation
+// x = e^y.
+// Results are undefined if x <= 0.
+//
+
+float log (float x) {
+ return log2 (x) / log2 (2.71828183);
+}
+vec2 log (vec2 x) {
+ return vec2 (log (x.x), log (x.y));
+}
+vec3 log (vec3 x) {
+ return vec3 (log (x.x), log (x.y), log (x.z));
+}
+vec4 log (vec4 x) {
+ return vec4 (log (x.x), log (x.y), log (x.z), log (x.w));
+}
+
+//
+// Returns 2 raised to the x power, i.e., 2^x
+//
+
+float exp2 (float x) {
+ return pow (2.0, x);
+}
+vec2 exp2 (vec2 x) {
+ return vec2 (exp2 (x.x), exp2 (x.y));
+}
+vec3 exp2 (vec3 x) {
+ return vec3 (exp2 (x.x), exp2 (x.y), exp2 (x.z));
+}
+vec4 exp2 (vec4 x) {
+ return vec4 (exp2 (x.x), exp2 (x.y), exp2 (x.z), exp2 (x.w));
+}
+
+//
+// Returns the base 2 logarithm of x, i.e., returns the value y which satisfies the equation
+// x = 2^y.
+// Results are undefined if x <= 0.
+//
+// XXX
+float log2 (float x) {
+ return 0.0;
+}
+vec2 log2 (vec2 x) {
+ return vec2 (log2 (x.x), log2 (x.y));
+}
+vec3 log2 (vec3 x) {
+ return vec3 (log2 (x.x), log2 (x.y), log2 (x.z));
+}
+vec4 log2 (vec4 x) {
+ return vec4 (log2 (x.x), log2 (x.y), log2 (x.z), log2 (x.w));
+}
+
+//
+// Returns the positive square root of x.
+// Results are undefined if x < 0.
+//
+
+float sqrt (float x) {
+ return pow (x, 0.5);
+}
+vec2 sqrt (vec2 x) {
+ return vec2 (sqrt (x.x), sqrt (x.y));
+}
+vec3 sqrt (vec3 x) {
+ return vec3 (sqrt (x.x), sqrt (x.y), sqrt (x.z));
+}
+vec4 sqrt (vec4 x) {
+ return vec4 (sqrt (x.x), sqrt (x.y), sqrt (x.z), sqrt (x.w));
+}
+
+//
+// Returns the reciprocal of the positive square root of x.
+// Results are undefined if x <= 0.
+//
+
+float inversesqrt (float x) {
+ return 1.0 / sqrt (x);
+}
+vec2 inversesqrt (vec2 x) {
+ return vec2 (inversesqrt (x.x), inversesqrt (x.y));
+}
+vec3 inversesqrt (vec3 x) {
+ return vec3 (inversesqrt (x.x), inversesqrt (x.y), inversesqrt (x.z));
+}
+vec4 inversesqrt (vec4 x) {
+ return vec4 (inversesqrt (x.x), inversesqrt (x.y), inversesqrt (x.z), inversesqrt (x.w));
+}
+
+//
+// 8.3 Common Functions
+//
+// These all operate component-wise. The description is per component.
+//
+
+//
+// Returns x if x >= 0, otherwise it returns –x
+//
+
+float abs (float x) {
+ return x >= 0.0 ? x : -x;
+}
+vec2 abs (vec2 x) {
+ return vec2 (abs (x.x), abs (x.y));
+}
+vec3 abs (vec3 x) {
+ return vec3 (abs (x.x), abs (x.y), abs (x.z));
+}
+vec4 abs (vec4 x) {
+ return vec4 (abs (x.x), abs (x.y), abs (x.z), abs (x.w));
+}
+
+//
+// Returns 1.0 if x > 0, 0.0 if x = 0, or –1.0 if x < 0
+//
+
+float sign (float x) {
+ return x > 0.0 ? 1.0 : x < 0.0 ? -1.0 : 0.0;
+}
+vec2 sign (vec2 x) {
+ return vec2 (sign (x.x), sign (x.y));
+}
+vec3 sign (vec3 x) {
+ return vec3 (sign (x.x), sign (x.y), sign (x.z));
+}
+vec4 sign (vec4 x) {
+ return vec4 (sign (x.x), sign (x.y), sign (x.z), sign (x.w));
+}
+
+//
+// Returns a value equal to the nearest integer that is less than or equal to x
+//
+// XXX
+float floor (float x) {
+ return 0.0;
+}
+vec2 floor (vec2 x) {
+ return vec2 (floor (x.x), floor (x.y));
+}
+vec3 floor (vec3 x) {
+ return vec3 (floor (x.x), floor (x.y), floor (x.z));
+}
+vec4 floor (vec4 x) {
+ return vec4 (floor (x.x), floor (x.y), floor (x.z), floor (x.w));
+}
+
+//
+// Returns a value equal to the nearest integer that is greater than or equal to x
+//
+// XXX
+float ceil (float x) {
+ return 0.0;
+}
+vec2 ceil (vec2 x) {
+ return vec2 (ceil (x.x), ceil (x.y));
+}
+vec3 ceil (vec3 x) {
+ return vec3 (ceil (x.x), ceil (x.y), ceil (x.z));
+}
+vec4 ceil (vec4 x) {
+ return vec4 (ceil (x.x), ceil (x.y), ceil (x.z), ceil (x.w));
+}
+
+//
+// Returns x – floor (x)
+//
+
+float fract (float x) {
+ return x - floor (x);
+}
+vec2 fract (vec2 x) {
+ return vec2 (fract (x.x), fract (x.y));
+}
+vec3 fract (vec3 x) {
+ return vec3 (fract (x.x), fract (x.y), fract (x.z));
+}
+vec4 fract (vec4 x) {
+ return vec4 (fract (x.x), fract (x.y), fract (x.z), fract (x.w));
+}
+
+//
+// Modulus. Returns x – y * floor (x/y)
+//
+
+float mod (float x, float y) {
+ return x - y * floor (x / y);
+}
+vec2 mod (vec2 x, float y) {
+ return vec2 (mod (x.x, y), mod (x.y, y));
+}
+vec3 mod (vec3 x, float y) {
+ return vec3 (mod (x.x, y), mod (x.y, y), mod (x.z, y));
+}
+vec4 mod (vec4 x, float y) {
+ return vec4 (mod (x.x, y), mod (x.y, y), mod (x.z, y), mod (x.w, y));
+}
+vec2 mod (vec2 x, vec2 y) {
+ return vec2 (mod (x.x, y.x), mod (x.y, y.y));
+}
+vec3 mod (vec3 x, vec3 y) {
+ return vec3 (mod (x.x, y.x), mod (x.y, y.y), mod (x.z, y.z));
+}
+vec4 mod (vec4 x, vec4 y) {
+ return vec4 (mod (x.x, y.x), mod (x.y, y.y), mod (x.z, y.z), mod (x.w, y.w));
+}
+
+//
+// Returns y if y < x, otherwise it returns x
+//
+
+float min (float x, float y) {
+ return y < x ? y : x;
+}
+vec2 min (vec2 x, float y) {
+ return vec2 (min (x.x, y), min (x.y, y));
+}
+vec3 min (vec3 x, float y) {
+ return vec3 (min (x.x, y), min (x.y, y), min (x.z, y));
+}
+vec4 min (vec4 x, float y) {
+ return vec4 (min (x.x, y), min (x.y, y), min (x.z, y), min (x.w, y));
+}
+vec2 min (vec2 x, vec2 y) {
+ return vec2 (min (x.x, y.x), min (x.y, y.y));
+}
+vec3 min (vec3 x, vec3 y) {
+ return vec3 (min (x.x, y.x), min (x.y, y.y), min (x.z, y.z));
+}
+vec4 min (vec4 x, vec4 y) {
+ return vec4 (min (x.x, y.x), min (x.y, y.y), min (x.z, y.z), min (x.w, y.w));
+}
+
+//
+// Returns y if x < y, otherwise it returns x
+//
+
+float max (float x, float y) {
+ return min (y, x);
+}
+vec2 max (vec2 x, float y) {
+ return vec2 (max (x.x, y), max (x.y, y));
+}
+vec3 max (vec3 x, float y) {
+ return vec3 (max (x.x, y), max (x.y, y), max (x.z, y));
+}
+vec4 max (vec4 x, float y) {
+ return vec4 (max (x.x, y), max (x.y, y), max (x.z, y), max (x.w, y));
+}
+vec2 max (vec2 x, vec2 y) {
+ return vec2 (max (x.x, y.x), max (x.y, y.y));
+}
+vec3 max (vec3 x, vec3 y) {
+ return vec3 (max (x.x, y.x), max (x.y, y.y), max (x.z, y.z));
+}
+vec4 max (vec4 x, vec4 y) {
+ return vec4 (max (x.x, y.x), max (x.y, y.y), max (x.z, y.z), max (x.w, y.w));
+}
+
+//
+// Returns min (max (x, minVal), maxVal)
+//
+// Note that colors and depths written by fragment shaders will be clamped by the implementation
+// after the fragment shader runs.
+//
+
+float clamp (float x, float minVal, float maxVal) {
+ return min (max (x, minVal), maxVal);
+}
+vec2 clamp (vec2 x, float minVal, float maxVal) {
+ return vec2 (clamp (x.x, minVal, maxVal), clamp (x.y, minVal, maxVal));
+}
+vec3 clamp (vec3 x, float minVal, float maxVal) {
+ return vec3 (clamp (x.x, minVal, maxVal), clamp (x.y, minVal, maxVal),
+ clamp (x.z, minVal, maxVal));
+}
+vec4 clamp (vec4 x, float minVal, float maxVal) {
+ return vec4 (clamp (x.x, minVal, maxVal), clamp (x.y, minVal, maxVal),
+ clamp (x.z, minVal, maxVal), clamp (x.w, minVal, maxVal));
+}
+vec2 clamp (vec2 x, vec2 minVal, vec2 maxVal) {
+ return vec2 (clamp (x.x, minVal.x, maxVal.x), clamp (x.y, minVal.y, maxVal.y));
+}
+vec3 clamp (vec3 x, vec3 minVal, vec3 maxVal) {
+ return vec3 (clamp (x.x, minVal.x, maxVal.x), clamp (x.y, minVal.y, maxVal.y),
+ clamp (x.z, minVal.z, maxVal.z));
+}
+vec4 clamp (vec4 x, vec4 minVal, vec4 maxVal) {
+ return vec4 (clamp (x.x, minVal.x, maxVal.y), clamp (x.y, minVal.y, maxVal.y),
+ clamp (x.z, minVal.z, maxVal.z), clamp (x.w, minVal.w, maxVal.w));
+}
+
+//
+// Returns x * (1 – a) + y * a, i.e., the linear blend of x and y
+//
+
+float mix (float x, float y, float a) {
+ return x * (1.0 - a) + y * a;
+}
+vec2 mix (vec2 x, vec2 y, float a) {
+ return vec2 (mix (x.x, y.x, a), mix (x.y, y.y, a));
+}
+vec3 mix (vec3 x, vec3 y, float a) {
+ return vec3 (mix (x.x, y.x, a), mix (x.y, y.y, a), mix (x.z, y.z, a));
+}
+vec4 mix (vec4 x, vec4 y, float a) {
+ return vec4 (mix (x.x, y.x, a), mix (x.y, y.y, a), mix (x.z, y.z, a), mix (x.w, y.w, a));
+}
+vec2 mix (vec2 x, vec2 y, vec2 a) {
+ return vec2 (mix (x.x, y.x, a.x), mix (x.y, y.y, a.y));
+}
+vec3 mix (vec3 x, vec3 y, vec3 a) {
+ return vec3 (mix (x.x, y.x, a.x), mix (x.y, y.y, a.y), mix (x.z, y.z, a.z));
+}
+vec4 mix (vec4 x, vec4 y, vec4 a) {
+ return vec4 (mix (x.x, y.x, a.x), mix (x.y, y.y, a.y), mix (x.z, y.z, a.z),
+ mix (x.w, y.w, a.w));
+}
+
+//
+// Returns 0.0 if x < edge, otherwise it returns 1.0
+//
+
+float step (float edge, float x) {
+ return x < edge ? 0.0 : 1.0;
+}
+vec2 step (float edge, vec2 x) {
+ return vec2 (step (edge, x.x), step (edge, x.y));
+}
+vec3 step (float edge, vec3 x) {
+ return vec3 (step (edge, x.x), step (edge, x.y), step (edge, x.z));
+}
+vec4 step (float edge, vec4 x) {
+ return vec4 (step (edge, x.x), step (edge, x.y), step (edge, x.z), step (edge, x.w));
+}
+vec2 step (vec2 edge, vec2 x) {
+ return vec2 (step (edge.x, x.x), step (edge.y, x.y));
+}
+vec3 step (vec3 edge, vec3 x) {
+ return vec3 (step (edge.x, x.x), step (edge.y, x.y), step (edge.z, x.z));
+}
+vec4 step (vec4 edge, vec4 x) {
+ return vec4 (step (edge.x, x.x), step (edge.y, x.y), step (edge.z, x.z), step (edge.w, x.w));
+}
+
+//
+// Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation
+// between 0 and 1 when edge0 < x < edge1. This is useful in cases where you would want a threshold
+// function with a smooth transition. This is equivalent to:
+// <type> t;
+// t = clamp ((x – edge0) / (edge1 – edge0), 0, 1);
+// return t * t * (3 – 2 * t);
+//
+
+float smoothstep (float edge0, float edge1, float x) {
+ const float t = clamp ((x - edge0) / (edge1 - edge0), 0.0, 1.0);
+ return t * t * (3.0 - 2.0 * t);
+}
+vec2 smoothstep (float edge0, float edge1, vec2 x) {
+ return vec2 (smoothstep (edge0, edge1, x.x), smoothstep (edge0, edge1, x.y));
+}
+vec3 smoothstep (float edge0, float edge1, vec3 x) {
+ return vec3 (smoothstep (edge0, edge1, x.x), smoothstep (edge0, edge1, x.y),
+ smoothstep (edge0, edge1, x.z));
+}
+vec4 smoothstep (float edge0, float edge1, vec4 x) {
+ return vec4 (smoothstep (edge0, edge1, x.x), smoothstep (edge0, edge1, x.y),
+ smoothstep (edge0, edge1, x.z), smoothstep (edge0, edge1, x.w));
+}
+vec2 smoothstep (vec2 edge0, vec2 edge1, vec2 x) {
+ return vec2 (smoothstep (edge0.x, edge1.x, x.x), smoothstep (edge0.y, edge1.y, x.y));
+}
+vec3 smoothstep (vec3 edge0, vec3 edge1, vec3 x) {
+ return vec3 (smoothstep (edge0.x, edge1.x, x.x), smoothstep (edge0.y, edge1.y, x.y),
+ smoothstep (edge0.z, edge1.z, x.z));
+}
+vec4 smoothstep (vec4 edge0, vec4 edge1, vec4 x) {
+ return vec4 (smoothstep (edge0.x, edge1.x, x.x), smoothstep (edge0.y, edge1.y, x.y),
+ smoothstep (edge0.z, edge1.z, x.z), smoothstep (edge0.w, edge1.w, x.w));
+}
+
+//
+// 8.4 Geometric Functions
+//
+// These operate on vectors as vectors, not component-wise.
+//
+
+//
+// Returns the dot product of x and y, i.e., result = x[0] * y[0] + x[1] * y[1] + ...
+//
+
+float dot (float x, float y) {
+ return x * y;
+}
+float dot (vec2 x, vec2 y) {
+ return dot (x.x, y.x) + dot (x.y, y.y);
+}
+float dot (vec3 x, vec3 y) {
+ return dot (x.x, y.x) + dot (x.y, y.y) + dot (x.z, y.z);
+}
+float dot (vec4 x, vec4 y) {
+ return dot (x.x, y.x) + dot (x.y, y.y) + dot (x.z, y.z) + dot (x.w, y.w);
+}
+
+//
+// Returns the length of vector x, i.e., sqrt (x[0] * x[0] + x[1] * x[1] + ...)
+//
+
+float length (float x) {
+ return sqrt (dot (x, x));
+}
+float length (vec2 x) {
+ return sqrt (dot (x, x));
+}
+float length (vec3 x) {
+ return sqrt (dot (x, x));
+}
+float length (vec4 x) {
+ return sqrt (dot (x, x));
+}
+
+//
+// Returns the distance between p0 and p1, i.e. length (p0 – p1)
+//
+
+float distance (float x, float y) {
+ return length (x - y);
+}
+float distance (vec2 x, vec2 y) {
+ return length (x - y);
+}
+float distance (vec3 x, vec3 y) {
+ return length (x - y);
+}
+float distance (vec4 x, vec4 y) {
+ return length (x - y);
+}
+
+//
+// Returns the cross product of x and y, i.e.
+// result.0 = x[1] * y[2] - y[1] * x[2]
+// result.1 = x[2] * y[0] - y[2] * x[0]
+// result.2 = x[0] * y[1] - y[0] * x[1]
+//
+
+vec3 cross (vec3 x, vec3 y) {
+ return vec3 (x.y * y.z - y.y * x.z, x.z * y.x - y.z * x.x, x.x * y.y - y.x * x.y);
+}
+
+//
+// Returns a vector in the same direction as x but with a length of 1.
+//
+
+float normalize (float x) {
+ return 1.0;
+}
+vec2 normalize (vec2 x) {
+ return x / length (x);
+}
+vec3 normalize (vec3 x) {
+ return x / length (x);
+}
+vec4 normalize (vec4 x) {
+ return x / length (x);
+}
+
+//
+// If dot (Nref, I) < 0 return N otherwise return –N
+//
+
+float faceforward (float N, float I, float Nref) {
+ return dot (Nref, I) < 0.0 ? N : -N;
+}
+vec2 faceforward (vec2 N, vec2 I, vec2 Nref) {
+ return dot (Nref, I) < 0.0 ? N : -N;
+}
+vec3 faceforward (vec3 N, vec3 I, vec3 Nref) {
+ return dot (Nref, I) < 0.0 ? N : -N;
+}
+vec4 faceforward (vec4 N, vec4 I, vec4 Nref) {
+ return dot (Nref, I) < 0.0 ? N : -N;
+}
+
+//
+// For the incident vector I and surface orientation N, returns the reflection direction:
+// result = I - 2 * dot (N, I) * N
+// N must already be normalized in order to achieve the desired result.
+//
+
+float reflect (float I, float N) {
+ return I - 2.0 * dot (N, I) * N;
+}
+vec2 reflect (vec2 I, vec2 N) {
+ return I - 2.0 * dot (N, I) * N;
+}
+vec3 reflect (vec3 I, vec3 N) {
+ return I - 2.0 * dot (N, I) * N;
+}
+vec4 reflect (vec4 I, vec4 N) {
+ return I - 2.0 * dot (N, I) * N;
+}
+
+//
+// For the incident vector I and surface normal N, and the ratio of inidices of refraction eta,
+// return the refraction vector. The returned result is computed by
+//
+// k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I))
+// if (k < 0.0)
+// result = genType (0.0)
+// else
+// result = eta * I - (eta * dot (N, I) + sqrt (k)) * N
+//
+// The input parameters for the incident vector I and the surface normal N must already be
+// normalized to get the desired results.
+//
+
+float refract (float I, float N, float eta) {
+ const float k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));
+ if (k < 0.0)
+ return 0.0;
+ return eta * I - (eta * dot (N, I) + sqrt (k)) * N;
+}
+vec2 refract (vec2 I, vec2 N, float eta) {
+ const float k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));
+ if (k < 0.0)
+ return vec2 (0.0);
+ return eta * I - (eta * dot (N, I) + sqrt (k)) * N;
+}
+vec3 refract (vec3 I, vec3 N, float eta) {
+ const float k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));
+ if (k < 0.0)
+ return vec3 (0.0);
+ return eta * I - (eta * dot (N, I) + sqrt (k)) * N;
+}
+vec4 refract (vec4 I, vec4 N, float eta) {
+ const float k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));
+ if (k < 0.0)
+ return vec4 (0.0);
+ return eta * I - (eta * dot (N, I) + sqrt (k)) * N;
+}
+
+//
+// 8.5 Matrix Functions
+//
+
+//
+// Multiply matrix x by matrix y component-wise, i.e., result[i][j] is the scalar product
+// of x[i][j] and y[i][j].
+// Note: to get linear algebraic matrix multiplication, use the multiply operator (*).
+//
+
+mat2 matrixCompMult (mat2 x, mat2 y) {
+ return mat2 (
+ x[0].x * y[0].x, x[0].y * y[0].y,
+ x[1].x * y[1].x, x[1].y * y[1].y
+ );
+}
+mat3 matrixCompMult (mat3 x, mat3 y) {
+ return mat4 (
+ x[0].x * y[0].x, x[0].y * y[0].y, x[0].z * y[0].z,
+ x[1].x * y[1].x, x[1].y * y[1].y, x[1].z * y[1].z,
+ x[2].x * y[2].x, x[2].y * y[2].y, x[2].z * y[2].z
+ );
+}
+mat4 matrixCompMult (mat4 x, mat4 y) {
+ return mat4 (
+ x[0].x * y[0].x, x[0].y * y[0].y, x[0].z * y[0].z + x[0].w * y[0].w,
+ x[1].x * y[1].x, x[1].y * y[1].y, x[1].z * y[1].z + x[1].w * y[1].w,
+ x[2].x * y[2].x, x[2].y * y[2].y, x[2].z * y[2].z + x[2].w * y[2].w,
+ x[3].x * y[3].x, x[3].y * y[3].y, x[3].z * y[3].z + x[3].w * y[3].w
+ );
+}
+
+//
+// 8.6 Vector Relational Functions
+//
+// Relational and equality operators (<, <=, >, >=, ==, !=) are defined (or reserved) to produce
+// scalar Boolean results.
+//
+
+//
+// Returns the component-wise compare of x < y.
+//
+
+bvec2 lessThan (vec2 x, vec2 y) {
+ return bvec2 (x.x < y.x, x.y < y.y);
+}
+bvec3 lessThan (vec3 x, vec3 y) {
+ return bvec3 (x.x < y.x, x.y < y.y, x.z < y.z);
+}
+bvec4 lessThan (vec4 x, vec4 y) {
+ return bvec4 (x.x < y.x, x.y < y.y, x.z < y.z, x.w < y.w);
+}
+bvec2 lessThan (ivec2 x, ivec2 y) {
+ return bvec2 (x.x < y.x, x.y < y.y);
+}
+bvec3 lessThan (ivec3 x, ivec3 y) {
+ return bvec3 (x.x < y.x, x.y < y.y, x.z < y.z);
+}
+bvec4 lessThan (ivec4 x, ivec4 y) {
+ return bvec4 (x.x < y.x, x.y < y.y, x.z < y.z, x.w < y.w);
+}
+
+//
+// Returns the component-wise compare of x <= y.
+//
+
+bvec2 lessThanEqual (vec2 x, vec2 y) {
+ return bvec2 (x.x <= y.x, x.y <= y.y);
+}
+bvec3 lessThanEqual (vec3 x, vec3 y) {
+ return bvec3 (x.x <= y.x, x.y <= y.y, x.z <= y.z);
+}
+bvec4 lessThanEqual (vec4 x, vec4 y) {
+ return bvec4 (x.x <= y.x, x.y <= y.y, x.z <= y.z, x.w <= y.w);
+}
+bvec2 lessThanEqual (ivec2 x, ivec2 y) {
+ return bvec2 (x.x <= y.x, x.y <= y.y);
+}
+bvec3 lessThanEqual (ivec3 x, ivec3 y) {
+ return bvec3 (x.x <= y.x, x.y <= y.y, x.z <= y.z);
+}
+bvec4 lessThanEqual (ivec4 x, ivec4 y) {
+ return bvec4 (x.x <= y.x, x.y <= y.y, x.z <= y.z, x.w <= y.w);
+}
+
+//
+// Returns the component-wise compare of x > y.
+//
+
+bvec2 greaterThan (vec2 x, vec2 y) {
+ return bvec2 (x.x > y.x, x.y > y.y);
+}
+bvec3 greaterThan (vec3 x, vec3 y) {
+ return bvec3 (x.x > y.x, x.y > y.y, x.z > y.z);
+}
+bvec4 greaterThan (vec4 x, vec4 y) {
+ return bvec4 (x.x > y.x, x.y > y.y, x.z > y.z, x.w > y.w);
+}
+bvec2 greaterThan (ivec2 x, ivec2 y) {
+ return bvec2 (x.x > y.x, x.y > y.y);
+}
+bvec3 greaterThan (ivec3 x, ivec3 y) {
+ return bvec3 (x.x > y.x, x.y > y.y, x.z > y.z);
+}
+bvec4 greaterThan (ivec4 x, ivec4 y) {
+ return bvec4 (x.x > y.x, x.y > y.y, x.z > y.z, x.w > y.w);
+}
+
+//
+// Returns the component-wise compare of x >= y.
+//
+
+bvec2 greaterThanEqual (vec2 x, vec2 y) {
+ return bvec2 (x.x >= y.x, x.y >= y.y);
+}
+bvec3 greaterThanEqual (vec3 x, vec3 y) {
+ return bvec3 (x.x >= y.x, x.y >= y.y, x.z >= y.z);
+}
+bvec4 greaterThanEqual (vec4 x, vec4 y) {
+ return bvec4 (x.x >= y.x, x.y >= y.y, x.z >= y.z, x.w >= y.w);
+}
+bvec2 greaterThanEqual (ivec2 x, ivec2 y) {
+ return bvec2 (x.x >= y.x, x.y >= y.y);
+}
+bvec3 greaterThanEqual (ivec3 x, ivec3 y) {
+ return bvec3 (x.x >= y.x, x.y >= y.y, x.z >= y.z);
+}
+bvec4 greaterThanEqual (ivec4 x, ivec4 y) {
+ return bvec4 (x.x >= y.x, x.y >= y.y, x.z >= y.z, x.w >= y.w);
+}
+
+//
+// Returns the component-wise compare of x == y.
+//
+
+bvec2 equal (vec2 x, vec2 y) {
+ return bvec2 (x.x == y.x, x.y == y.y);
+}
+bvec3 equal (vec3 x, vec3 y) {
+ return bvec3 (x.x == y.x, x.y == y.y, x.z == y.z);
+}
+bvec4 equal (vec4 x, vec4 y) {
+ return bvec4 (x.x == y.x, x.y == y.y, x.z == y.z, x.w == y.w);
+}
+bvec2 equal (ivec2 x, ivec2 y) {
+ return bvec2 (x.x == y.x, x.y == y.y);
+}
+bvec3 equal (ivec3 x, ivec3 y) {
+ return bvec3 (x.x == y.x, x.y == y.y, x.z == y.z);
+}
+bvec4 equal (ivec4 x, ivec4 y) {
+ return bvec4 (x.x == y.x, x.y == y.y, x.z == y.z, x.w == y.w);
+}
+
+//
+// Returns the component-wise compare of x != y.
+//
+
+bvec2 notEqual (vec2 x, vec2 y) {
+ return bvec2 (x.x != y.x, x.y != y.y);
+}
+bvec3 notEqual (vec3 x, vec3 y) {
+ return bvec3 (x.x != y.x, x.y != y.y, x.z != y.z);
+}
+bvec4 notEqual (vec4 x, vec4 y) {
+ return bvec4 (x.x != y.x, x.y != y.y, x.z != y.z, x.w != y.w);
+}
+bvec2 notEqual (ivec2 x, ivec2 y) {
+ return bvec2 (x.x != y.x, x.y != y.y);
+}
+bvec3 notEqual (ivec3 x, ivec3 y) {
+ return bvec3 (x.x != y.x, x.y != y.y, x.z != y.z);
+}
+bvec4 notEqual (ivec4 x, ivec4 y) {
+ return bvec4 (x.x != y.x, x.y != y.y, x.z != y.z, x.w != y.w);
+}
+
+//
+// Returns true if any component of x is true.
+//
+
+bool any (bvec2 x) {
+ return x.x || x.y;
+}
+bool any (bvec3 x) {
+ return x.x || x.y || x.z;
+}
+bool any (bvec4 x) {
+ return x.x || x.y || x.z || x.w;
+}
+
+//
+// Returns true only if all components of x are true.
+//
+
+bool all (bvec2 x) {
+ return x.x && x.y;
+}
+bool all (bvec3 x) {
+ return x.x && x.y && x.z;
+}
+bool all (bvec4 x) {
+ return x.x && x.y && x.z && x.w;
+}
+
+//
+// Returns the component-wise logical complement of x.
+//
+
+bvec2 not (bvec2 x) {
+ return bvec2 (!x.x, !x.y);
+}
+bvec3 not (bvec3 x) {
+ return bvec3 (!x.x, !x.y, !x.z);
+}
+bvec4 not (bvec4 x) {
+ return bvec4 (!x.x, !x.y, !x.z, !x.w);
+}
+
+//
+// 8.7 Texture Lookup Functions
+//
+// Texture lookup functions are available to both vertex and fragment shaders. However, level
+// of detail is not computed by fixed functionality for vertex shaders, so there are some
+// differences in operation between vertex and fragment texture lookups. The functions in the table
+// below provide access to textures through samplers, as set up through the OpenGL API. Texture
+// properties such as size, pixel format, number of dimensions, filtering method, number of mip-map
+// levels, depth comparison, and so on are also defined by OpenGL API calls. Such properties are
+// taken into account as the texture is accessed via the built-in functions defined below.
+//
+// If a non-shadow texture call is made to a sampler that represents a depth texture with depth
+// comparisons turned on, then results are undefined. If a shadow texture call is made to a sampler
+// that represents a depth texture with depth comparisions turned off, the results are undefined.
+// If a shadow texture call is made to a sampler that does not represent a depth texture, then
+// results are undefined.
+//
+// In all functions below, the bias parameter is optional for fragment shaders. The bias parameter
+// is not accepted in a vertex shader. For a fragment shader, if bias is present, it is added to
+// the calculated level of detail prior to performing the texture access operation. If the bias
+// parameter is not provided, then the implementation automatically selects level of detail:
+// For a texture that is not mip-mapped, the texture is used directly. If it is mip-mapped and
+// running in a fragment shader, the LOD computed by the implementation is used to do the texture
+// lookup. If it is mip-mapped and running on the vertex shader, then the base texture is used.
+//
+// The built-ins suffixed with "Lod" are allowed only in a vertex shader. For the "Lod" functions,
+// lod is directly used as the level of detail.
+//
+
+//
+// Use the texture coordinate coord to do a texture lookup in the 1D texture currently bound
+// to sampler. For the projective ("Proj") versions, the texture coordinate coord.s is divided by
+// the last component of coord.
+//
+// XXX
+vec4 texture1D (sampler1D sampler, float coord) {
+ return vec4 (0.0);
+}
+vec4 texture1DProj (sampler1D sampler, vec2 coord) {
+ return texture1D (sampler, coord.s / coord.t);
+}
+vec4 texture1DProj (sampler1D sampler, vec4 coord) {
+ return texture1D (sampler, coord.s / coord.q);
+}
+
+//
+// Use the texture coordinate coord to do a texture lookup in the 2D texture currently bound
+// to sampler. For the projective ("Proj") versions, the texture coordinate (coord.s, coord.t) is
+// divided by the last component of coord. The third component of coord is ignored for the vec4
+// coord variant.
+//
+// XXX
+vec4 texture2D (sampler2D sampler, vec2 coord) {
+ return vec4 (0.0);
+}
+vec4 texture2DProj (sampler2D sampler, vec3 coord) {
+ return texture2D (sampler, vec2 (coord.s / coord.p, coord.t / coord.p));
+}
+vec4 texture2DProj (sampler2D sampler, vec4 coord) {
+ return texture2D (sampler, vec2 (coord.s / coord.q, coord.t / coord.q));
+}
+
+//
+// Use the texture coordinate coord to do a texture lookup in the 3D texture currently bound
+// to sampler. For the projective ("Proj") versions, the texture coordinate is divided by coord.q.
+//
+// XXX
+vec4 texture3D (sampler3D sampler, vec3 coord) {
+ return vec4 (0.0);
+}
+vec4 texture3DProj (sampler3D sampler, vec4 coord) {
+ return texture3D (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q));
+}
+
+//
+// Use the texture coordinate coord to do a texture lookup in the cube map texture currently bound
+// to sampler. The direction of coord is used to select which face to do a 2-dimensional texture
+// lookup in, as described in section 3.8.6 in version 1.4 of the OpenGL specification.
+//
+// XXX
+vec4 textureCube (samplerCube sampler, vec3 coord) {
+ return vec4 (0.0);
+}
+
+//
+// Use texture coordinate coord to do a depth comparison lookup on the depth texture bound
+// to sampler, as described in section 3.8.14 of version 1.4 of the OpenGL specification. The 3rd
+// component of coord (coord.p) is used as the R value. The texture bound to sampler must be a
+// depth texture, or results are undefined. For the projective ("Proj") version of each built-in,
+// the texture coordinate is divide by coord.q, giving a depth value R of coord.p/coord.q. The
+// second component of coord is ignored for the "1D" variants.
+//
+// XXX
+vec4 shadow1D (sampler1DShadow sampler, vec3 coord) {
+ return vec4 (0.0);
+}
+// XXX
+vec4 shadow2D (sampler2DShadow sampler, vec3 coord) {
+ return vec4 (0.0);
+}
+vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord) {
+ return shadow1D (sampler, vec3 (coord.s / coord.q, 0.0, coord.p / coord.q));
+}
+vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord) {
+ return shadow2D (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q));
+}
+
+//
+// 8.9 Noise Functions
+//
+// Noise functions are available to both fragment and vertex shaders. They are stochastic functions
+// that can be used to increase visual complexity. Values returned by the following noise functions
+// give the appearance of randomness, but are not truly random. The noise functions below are
+// defined to have the following characteristics:
+//
+// - The return value(s) are always in the range [-1,1], and cover at least the range [-0.6, 0.6],
+// with a gaussian-like distribution.
+// * The return value(s) have an overall average of 0.0
+// * They are repeatable, in that a particular input value will always produce the same return value
+// * They are statistically invariant under rotation (i.e., no matter how the domain is rotated, it
+// has the same statistical character)
+// * They have a statistical invariance under translation (i.e., no matter how the domain is
+// translated, it has the same statistical character)
+// * They typically give different results under translation.
+// - The spatial frequency is narrowly concentrated, centered somewhere between 0.5 to 1.0.
+//
+
+//
+// Returns a 1D noise value based on the input value x.
+//
+// XXX
+float noise1 (float x) {
+ return 0.0;
+}
+// XXX
+float noise1 (vec2 x) {
+ return 0.0;
+}
+// XXX
+float noise1 (vec3 x) {
+ return 0.0;
+}
+// XXX
+float noise1 (vec4 x) {
+ return 0.0;
+}
+
+//
+// Returns a 2D noise value based on the input value x.
+//
+// XXX
+vec2 noise2 (float x) {
+ return vec2 (0.0);
+}
+// XXX
+vec2 noise2 (vec2 x) {
+ return vec2 (0.0);
+}
+// XXX
+vec2 noise2 (vec3 x) {
+ return vec2 (0.0);
+}
+// XXX
+vec2 noise2 (vec4 x) {
+ return vec2 (0.0);
+}
+
+//
+// Returns a 3D noise value based on the input value x.
+//
+// XXX
+vec3 noise3 (float x) {
+ return vec3 (0.0);
+}
+// XXX
+vec3 noise3 (vec2 x) {
+ return vec3 (0.0);
+}
+// XXX
+vec3 noise3 (vec3 x) {
+ return vec3 (0.0);
+}
+// XXX
+vec3 noise3 (vec4 x) {
+ return vec3 (0.0);
+}
+
+//
+// Returns a 4D noise value based on the input value x.
+//
+// XXX
+vec4 noise4 (float x) {
+ return vec4 (0.0);
+}
+// XXX
+vec4 noise4 (vec2 x) {
+ return vec4 (0.0);
+}
+// XXX
+vec4 noise4 (vec3 x) {
+ return vec4 (0.0);
+}
+// XXX
+vec4 noise4 (vec4 x) {
+ return vec4 (0.0);
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_common_builtin_gc.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_common_builtin_gc.h
new file mode 100644
index 000000000..cd9d9ac7d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_common_builtin_gc.h
@@ -0,0 +1,1410 @@
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"const int gl_MaxLights = 8;\n"
+"const int gl_MaxClipPlanes = 6;\n"
+"const int gl_MaxTextureUnits = 2;\n"
+"const int gl_MaxTextureCoords = 2;\n"
+"const int gl_MaxVertexAttribs = 16;\n"
+"const int gl_MaxVertexUniformComponents = 512;\n"
+"const int gl_MaxVaryingFloats = 32;\n"
+"const int gl_MaxVertexTextureImageUnits = 0;\n"
+"const int gl_MaxCombinedTextureImageUnits = 2;\n"
+"const int gl_MaxTextureImageUnits = 2;\n"
+"const int gl_MaxFragmentUniformComponents = 64;\n"
+"const int gl_MaxDrawBuffers = 1;\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"uniform mat4 gl_ModelViewMatrix;\n"
+"uniform mat4 gl_ProjectionMatrix;\n"
+"uniform mat4 gl_ModelViewProjectionMatrix;\n"
+"uniform mat4 gl_TextureMatrix[gl_MaxTextureCoords];\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"uniform mat3 gl_NormalMatrix;\n"
+"\n"
+"\n"
+"uniform mat4 gl_ModelViewMatrixInverse;\n"
+"uniform mat4 gl_ProjectionMatrixInverse;\n"
+"uniform mat4 gl_ModelViewProjectionMatrixInverse;\n"
+"uniform mat4 gl_TextureMatrixInverse[gl_MaxTextureCoords];\n"
+"\n"
+"uniform mat4 gl_ModelViewMatrixTranspose;\n"
+"uniform mat4 gl_ProjectionMatrixTranspose;\n"
+"uniform mat4 gl_ModelViewProjectionMatrixTranspose;\n"
+"uniform mat4 gl_TextureMatrixTranspose[gl_MaxTextureCoords];\n"
+"\n"
+"uniform mat4 gl_ModelViewMatrixInverseTranspose;\n"
+"uniform mat4 gl_ProjectionMatrixInverseTranspose;\n"
+"uniform mat4 gl_ModelViewProjectionMatrixInverseTranspose;\n"
+"uniform mat4 gl_TextureMatrixInverseTranspose[gl_MaxTextureCoords];\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"uniform float gl_NormalScale;\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"struct gl_DepthRangeParameters {\n"
+" float near;\n"
+" float far;\n"
+" float diff;\n"
+"};\n"
+"\n"
+"uniform gl_DepthRangeParameters gl_DepthRange;\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"uniform vec4 gl_ClipPlane[gl_MaxClipPlanes];\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"struct gl_PointParameters {\n"
+" float size;\n"
+" float sizeMin;\n"
+" float sizeMax;\n"
+" float fadeThresholdSize;\n"
+" float distanceConstantAttenuation;\n"
+" float distanceLinearAttenuation;\n"
+" float distanceQuadraticAttenuation;\n"
+"};\n"
+"\n"
+"uniform gl_PointParameters gl_Point;\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"struct gl_MaterialParameters {\n"
+" vec4 emission;\n"
+" vec4 ambient;\n"
+" vec4 diffuse;\n"
+" vec4 specular;\n"
+" float shininess;\n"
+"};\n"
+"\n"
+"uniform gl_MaterialParameters gl_FrontMaterial;\n"
+"uniform gl_MaterialParameters gl_BackMaterial;\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"struct gl_LightSourceParameters {\n"
+" vec4 ambient;\n"
+" vec4 diffuse;\n"
+" vec4 specular;\n"
+" vec4 position;\n"
+" vec4 halfVector;\n"
+" vec3 spotDirection;\n"
+" float spotExponent;\n"
+" float spotCutoff;\n"
+"\n"
+" float spotCosCutoff;\n"
+"\n"
+" float constantAttenuation;\n"
+" float linearAttenuation;\n"
+" float quadraticAttenuation;\n"
+"};\n"
+"\n"
+"uniform gl_LightSourceParameters gl_LightSource[gl_MaxLights];\n"
+"\n"
+"struct gl_LightModelParameters {\n"
+" vec4 ambient;\n"
+"};\n"
+"\n"
+"uniform gl_LightModelParameters gl_LightModel;\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"struct gl_LightModelProducts {\n"
+" vec4 sceneColor;\n"
+"};\n"
+"\n"
+"uniform gl_LightModelProducts gl_FrontLightModelProduct;\n"
+"uniform gl_LightModelProducts gl_BackLightModelProduct;\n"
+"\n"
+"struct gl_LightProducts {\n"
+" vec4 ambient;\n"
+" vec4 diffuse;\n"
+" vec4 specular;\n"
+"};\n"
+"\n"
+"uniform gl_LightProducts gl_FrontLightProduct[gl_MaxLights];\n"
+"uniform gl_LightProducts gl_BackLightProduct[gl_MaxLights];\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"uniform vec4 gl_TextureEnvColor[gl_MaxTextureImageUnits];\n"
+"uniform vec4 gl_EyePlaneS[gl_MaxTextureCoords];\n"
+"uniform vec4 gl_EyePlaneT[gl_MaxTextureCoords];\n"
+"uniform vec4 gl_EyePlaneR[gl_MaxTextureCoords];\n"
+"uniform vec4 gl_EyePlaneQ[gl_MaxTextureCoords];\n"
+"uniform vec4 gl_ObjectPlaneS[gl_MaxTextureCoords];\n"
+"uniform vec4 gl_ObjectPlaneT[gl_MaxTextureCoords];\n"
+"uniform vec4 gl_ObjectPlaneR[gl_MaxTextureCoords];\n"
+"uniform vec4 gl_ObjectPlaneQ[gl_MaxTextureCoords];\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"struct gl_FogParameters {\n"
+" vec4 color;\n"
+" float density;\n"
+" float start;\n"
+" float end;\n"
+" float scale;\n"
+"};\n"
+"\n"
+"uniform gl_FogParameters gl_Fog;\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float radians (float deg) {\n"
+" return 3.141593 * deg / 180.0;\n"
+"}\n"
+"vec2 radians (vec2 deg) {\n"
+" return vec2 (radians (deg.x), radians (deg.y));\n"
+"}\n"
+"vec3 radians (vec3 deg) {\n"
+" return vec3 (radians (deg.x), radians (deg.y), radians (deg.z));\n"
+"}\n"
+"vec4 radians (vec4 deg) {\n"
+" return vec4 (radians (deg.x), radians (deg.y), radians (deg.z), radians (deg.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float degrees (float rad) {\n"
+" return 180.0 * rad / 3.141593;\n"
+"}\n"
+"vec2 degrees (vec2 rad) {\n"
+" return vec2 (degrees (rad.x), degrees (rad.y));\n"
+"}\n"
+"vec3 degrees (vec3 rad) {\n"
+" return vec3 (degrees (rad.x), degrees (rad.y), degrees (rad.z));\n"
+"}\n"
+"vec4 degrees (vec4 rad) {\n"
+" return vec4 (degrees (rad.x), degrees (rad.y), degrees (rad.z), degrees (rad.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float sin (float angle) {\n"
+" return 0.0;\n"
+"}\n"
+"vec2 sin (vec2 angle) {\n"
+" return vec2 (sin (angle.x), sin (angle.y));\n"
+"}\n"
+"vec3 sin (vec3 angle) {\n"
+" return vec3 (sin (angle.x), sin (angle.y), sin (angle.z));\n"
+"}\n"
+"vec4 sin (vec4 angle) {\n"
+" return vec4 (sin (angle.x), sin (angle.y), sin (angle.z), sin (angle.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float cos (float angle) {\n"
+" return sin (angle + 1.5708);\n"
+"}\n"
+"vec2 cos (vec2 angle) {\n"
+" return vec2 (cos (angle.x), cos (angle.y));\n"
+"}\n"
+"vec3 cos (vec3 angle) {\n"
+" return vec3 (cos (angle.x), cos (angle.y), cos (angle.z));\n"
+"}\n"
+"vec4 cos (vec4 angle) {\n"
+" return vec4 (cos (angle.x), cos (angle.y), cos (angle.z), cos (angle.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float tan (float angle) {\n"
+" return sin (angle) / cos (angle);\n"
+"}\n"
+"vec2 tan (vec2 angle) {\n"
+" return vec2 (tan (angle.x), tan (angle.y));\n"
+"}\n"
+"vec3 tan (vec3 angle) {\n"
+" return vec3 (tan (angle.x), tan (angle.y), tan (angle.z));\n"
+"}\n"
+"vec4 tan (vec4 angle) {\n"
+" return vec4 (tan (angle.x), tan (angle.y), tan (angle.z), tan (angle.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float asin (float x) {\n"
+" return 0.0;\n"
+"}\n"
+"vec2 asin (vec2 x) {\n"
+" return vec2 (asin (x.x), asin (x.y));\n"
+"}\n"
+"vec3 asin (vec3 x) {\n"
+" return vec3 (asin (x.x), asin (x.y), asin (x.z));\n"
+"}\n"
+"vec4 asin (vec4 x) {\n"
+" return vec4 (asin (x.x), asin (x.y), asin (x.z), asin (x.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float acos (float x) {\n"
+" return 0.0;\n"
+"}\n"
+"vec2 acos (vec2 x) {\n"
+" return vec2 (acos (x.x), acos (x.y));\n"
+"}\n"
+"vec3 acos (vec3 x) {\n"
+" return vec3 (acos (x.x), acos (x.y), acos (x.z));\n"
+"}\n"
+"vec4 acos (vec4 x) {\n"
+" return vec4 (acos (x.x), acos (x.y), acos (x.z), acos (x.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float atan (float x, float y) {\n"
+" return 0.0;\n"
+"}\n"
+"vec2 atan (vec2 x, vec2 y) {\n"
+" return vec2 (atan (x.x, y.x), atan (x.y, y.y));\n"
+"}\n"
+"vec3 atan (vec3 x, vec3 y) {\n"
+" return vec3 (atan (x.x, y.x), atan (x.y, y.y), atan (x.z, y.z));\n"
+"}\n"
+"vec4 atan (vec4 x, vec4 y) {\n"
+" return vec4 (atan (x.x, y.x), atan (x.y, y.y), atan (x.z, y.z), atan (x.w, y.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float atan (float y_over_x) {\n"
+" return 0.0;\n"
+"}\n"
+"vec2 atan (vec2 y_over_x) {\n"
+" return vec2 (atan (y_over_x.x), atan (y_over_x.y));\n"
+"}\n"
+"vec3 atan (vec3 y_over_x) {\n"
+" return vec3 (atan (y_over_x.x), atan (y_over_x.y), atan (y_over_x.z));\n"
+"}\n"
+"vec4 atan (vec4 y_over_x) {\n"
+" return vec4 (atan (y_over_x.x), atan (y_over_x.y), atan (y_over_x.z), atan (y_over_x.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float pow (float x, float y) {\n"
+" return 0.0;\n"
+"}\n"
+"vec2 pow (vec2 x, vec2 y) {\n"
+" return vec2 (pow (x.x, y.x), pow (x.y, y.y));\n"
+"}\n"
+"vec3 pow (vec3 x, vec3 y) {\n"
+" return vec3 (pow (x.x, y.x), pow (x.y, y.y), pow (x.z, y.z));\n"
+"}\n"
+"vec4 pow (vec4 x, vec4 y) {\n"
+" return vec4 (pow (x.x, y.x), pow (x.y, y.y), pow (x.z, y.z), pow (x.w, y.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float exp (float x) {\n"
+" return pow (2.71828183, x);\n"
+"}\n"
+"vec2 exp (vec2 x) {\n"
+" return vec2 (exp (x.x), exp (x.y));\n"
+"}\n"
+"vec3 exp (vec3 x) {\n"
+" return vec3 (exp (x.x), exp (x.y), exp (x.z));\n"
+"}\n"
+"vec4 exp (vec4 x) {\n"
+" return vec4 (exp (x.x), exp (x.y), exp (x.z), exp (x.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float log (float x) {\n"
+" return log2 (x) / log2 (2.71828183);\n"
+"}\n"
+"vec2 log (vec2 x) {\n"
+" return vec2 (log (x.x), log (x.y));\n"
+"}\n"
+"vec3 log (vec3 x) {\n"
+" return vec3 (log (x.x), log (x.y), log (x.z));\n"
+"}\n"
+"vec4 log (vec4 x) {\n"
+" return vec4 (log (x.x), log (x.y), log (x.z), log (x.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float exp2 (float x) {\n"
+" return pow (2.0, x);\n"
+"}\n"
+"vec2 exp2 (vec2 x) {\n"
+" return vec2 (exp2 (x.x), exp2 (x.y));\n"
+"}\n"
+"vec3 exp2 (vec3 x) {\n"
+" return vec3 (exp2 (x.x), exp2 (x.y), exp2 (x.z));\n"
+"}\n"
+"vec4 exp2 (vec4 x) {\n"
+" return vec4 (exp2 (x.x), exp2 (x.y), exp2 (x.z), exp2 (x.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float log2 (float x) {\n"
+" return 0.0;\n"
+"}\n"
+"vec2 log2 (vec2 x) {\n"
+" return vec2 (log2 (x.x), log2 (x.y));\n"
+"}\n"
+"vec3 log2 (vec3 x) {\n"
+" return vec3 (log2 (x.x), log2 (x.y), log2 (x.z));\n"
+"}\n"
+"vec4 log2 (vec4 x) {\n"
+" return vec4 (log2 (x.x), log2 (x.y), log2 (x.z), log2 (x.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float sqrt (float x) {\n"
+" return pow (x, 0.5);\n"
+"}\n"
+"vec2 sqrt (vec2 x) {\n"
+" return vec2 (sqrt (x.x), sqrt (x.y));\n"
+"}\n"
+"vec3 sqrt (vec3 x) {\n"
+" return vec3 (sqrt (x.x), sqrt (x.y), sqrt (x.z));\n"
+"}\n"
+"vec4 sqrt (vec4 x) {\n"
+" return vec4 (sqrt (x.x), sqrt (x.y), sqrt (x.z), sqrt (x.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float inversesqrt (float x) {\n"
+" return 1.0 / sqrt (x);\n"
+"}\n"
+"vec2 inversesqrt (vec2 x) {\n"
+" return vec2 (inversesqrt (x.x), inversesqrt (x.y));\n"
+"}\n"
+"vec3 inversesqrt (vec3 x) {\n"
+" return vec3 (inversesqrt (x.x), inversesqrt (x.y), inversesqrt (x.z));\n"
+"}\n"
+"vec4 inversesqrt (vec4 x) {\n"
+" return vec4 (inversesqrt (x.x), inversesqrt (x.y), inversesqrt (x.z), inversesqrt (x.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float abs (float x) {\n"
+" return x >= 0.0 ? x : -x;\n"
+"}\n"
+"vec2 abs (vec2 x) {\n"
+" return vec2 (abs (x.x), abs (x.y));\n"
+"}\n"
+"vec3 abs (vec3 x) {\n"
+" return vec3 (abs (x.x), abs (x.y), abs (x.z));\n"
+"}\n"
+"vec4 abs (vec4 x) {\n"
+" return vec4 (abs (x.x), abs (x.y), abs (x.z), abs (x.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float sign (float x) {\n"
+" return x > 0.0 ? 1.0 : x < 0.0 ? -1.0 : 0.0;\n"
+"}\n"
+"vec2 sign (vec2 x) {\n"
+" return vec2 (sign (x.x), sign (x.y));\n"
+"}\n"
+"vec3 sign (vec3 x) {\n"
+" return vec3 (sign (x.x), sign (x.y), sign (x.z));\n"
+"}\n"
+"vec4 sign (vec4 x) {\n"
+" return vec4 (sign (x.x), sign (x.y), sign (x.z), sign (x.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float floor (float x) {\n"
+" return 0.0;\n"
+"}\n"
+"vec2 floor (vec2 x) {\n"
+" return vec2 (floor (x.x), floor (x.y));\n"
+"}\n"
+"vec3 floor (vec3 x) {\n"
+" return vec3 (floor (x.x), floor (x.y), floor (x.z));\n"
+"}\n"
+"vec4 floor (vec4 x) {\n"
+" return vec4 (floor (x.x), floor (x.y), floor (x.z), floor (x.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float ceil (float x) {\n"
+" return 0.0;\n"
+"}\n"
+"vec2 ceil (vec2 x) {\n"
+" return vec2 (ceil (x.x), ceil (x.y));\n"
+"}\n"
+"vec3 ceil (vec3 x) {\n"
+" return vec3 (ceil (x.x), ceil (x.y), ceil (x.z));\n"
+"}\n"
+"vec4 ceil (vec4 x) {\n"
+" return vec4 (ceil (x.x), ceil (x.y), ceil (x.z), ceil (x.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float fract (float x) {\n"
+" return x - floor (x);\n"
+"}\n"
+"vec2 fract (vec2 x) {\n"
+" return vec2 (fract (x.x), fract (x.y));\n"
+"}\n"
+"vec3 fract (vec3 x) {\n"
+" return vec3 (fract (x.x), fract (x.y), fract (x.z));\n"
+"}\n"
+"vec4 fract (vec4 x) {\n"
+" return vec4 (fract (x.x), fract (x.y), fract (x.z), fract (x.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float mod (float x, float y) {\n"
+" return x - y * floor (x / y);\n"
+"}\n"
+"vec2 mod (vec2 x, float y) {\n"
+" return vec2 (mod (x.x, y), mod (x.y, y));\n"
+"}\n"
+"vec3 mod (vec3 x, float y) {\n"
+" return vec3 (mod (x.x, y), mod (x.y, y), mod (x.z, y));\n"
+"}\n"
+"vec4 mod (vec4 x, float y) {\n"
+" return vec4 (mod (x.x, y), mod (x.y, y), mod (x.z, y), mod (x.w, y));\n"
+"}\n"
+"vec2 mod (vec2 x, vec2 y) {\n"
+" return vec2 (mod (x.x, y.x), mod (x.y, y.y));\n"
+"}\n"
+"vec3 mod (vec3 x, vec3 y) {\n"
+" return vec3 (mod (x.x, y.x), mod (x.y, y.y), mod (x.z, y.z));\n"
+"}\n"
+"vec4 mod (vec4 x, vec4 y) {\n"
+" return vec4 (mod (x.x, y.x), mod (x.y, y.y), mod (x.z, y.z), mod (x.w, y.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float min (float x, float y) {\n"
+" return y < x ? y : x;\n"
+"}\n"
+"vec2 min (vec2 x, float y) {\n"
+" return vec2 (min (x.x, y), min (x.y, y));\n"
+"}\n"
+"vec3 min (vec3 x, float y) {\n"
+" return vec3 (min (x.x, y), min (x.y, y), min (x.z, y));\n"
+"}\n"
+"vec4 min (vec4 x, float y) {\n"
+" return vec4 (min (x.x, y), min (x.y, y), min (x.z, y), min (x.w, y));\n"
+"}\n"
+"vec2 min (vec2 x, vec2 y) {\n"
+" return vec2 (min (x.x, y.x), min (x.y, y.y));\n"
+"}\n"
+"vec3 min (vec3 x, vec3 y) {\n"
+" return vec3 (min (x.x, y.x), min (x.y, y.y), min (x.z, y.z));\n"
+"}\n"
+"vec4 min (vec4 x, vec4 y) {\n"
+" return vec4 (min (x.x, y.x), min (x.y, y.y), min (x.z, y.z), min (x.w, y.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float max (float x, float y) {\n"
+" return min (y, x);\n"
+"}\n"
+"vec2 max (vec2 x, float y) {\n"
+" return vec2 (max (x.x, y), max (x.y, y));\n"
+"}\n"
+"vec3 max (vec3 x, float y) {\n"
+" return vec3 (max (x.x, y), max (x.y, y), max (x.z, y));\n"
+"}\n"
+"vec4 max (vec4 x, float y) {\n"
+" return vec4 (max (x.x, y), max (x.y, y), max (x.z, y), max (x.w, y));\n"
+"}\n"
+"vec2 max (vec2 x, vec2 y) {\n"
+" return vec2 (max (x.x, y.x), max (x.y, y.y));\n"
+"}\n"
+"vec3 max (vec3 x, vec3 y) {\n"
+" return vec3 (max (x.x, y.x), max (x.y, y.y), max (x.z, y.z));\n"
+"}\n"
+"vec4 max (vec4 x, vec4 y) {\n"
+" return vec4 (max (x.x, y.x), max (x.y, y.y), max (x.z, y.z), max (x.w, y.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float clamp (float x, float minVal, float maxVal) {\n"
+" return min (max (x, minVal), maxVal);\n"
+"}\n"
+"vec2 clamp (vec2 x, float minVal, float maxVal) {\n"
+" return vec2 (clamp (x.x, minVal, maxVal), clamp (x.y, minVal, maxVal));\n"
+"}\n"
+"vec3 clamp (vec3 x, float minVal, float maxVal) {\n"
+" return vec3 (clamp (x.x, minVal, maxVal), clamp (x.y, minVal, maxVal),\n"
+" clamp (x.z, minVal, maxVal));\n"
+"}\n"
+"vec4 clamp (vec4 x, float minVal, float maxVal) {\n"
+" return vec4 (clamp (x.x, minVal, maxVal), clamp (x.y, minVal, maxVal),\n"
+" clamp (x.z, minVal, maxVal), clamp (x.w, minVal, maxVal));\n"
+"}\n"
+"vec2 clamp (vec2 x, vec2 minVal, vec2 maxVal) {\n"
+" return vec2 (clamp (x.x, minVal.x, maxVal.x), clamp (x.y, minVal.y, maxVal.y));\n"
+"}\n"
+"vec3 clamp (vec3 x, vec3 minVal, vec3 maxVal) {\n"
+" return vec3 (clamp (x.x, minVal.x, maxVal.x), clamp (x.y, minVal.y, maxVal.y),\n"
+" clamp (x.z, minVal.z, maxVal.z));\n"
+"}\n"
+"vec4 clamp (vec4 x, vec4 minVal, vec4 maxVal) {\n"
+" return vec4 (clamp (x.x, minVal.x, maxVal.y), clamp (x.y, minVal.y, maxVal.y),\n"
+" clamp (x.z, minVal.z, maxVal.z), clamp (x.w, minVal.w, maxVal.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float mix (float x, float y, float a) {\n"
+" return x * (1.0 - a) + y * a;\n"
+"}\n"
+"vec2 mix (vec2 x, vec2 y, float a) {\n"
+" return vec2 (mix (x.x, y.x, a), mix (x.y, y.y, a));\n"
+"}\n"
+"vec3 mix (vec3 x, vec3 y, float a) {\n"
+" return vec3 (mix (x.x, y.x, a), mix (x.y, y.y, a), mix (x.z, y.z, a));\n"
+"}\n"
+"vec4 mix (vec4 x, vec4 y, float a) {\n"
+" return vec4 (mix (x.x, y.x, a), mix (x.y, y.y, a), mix (x.z, y.z, a), mix (x.w, y.w, a));\n"
+"}\n"
+"vec2 mix (vec2 x, vec2 y, vec2 a) {\n"
+" return vec2 (mix (x.x, y.x, a.x), mix (x.y, y.y, a.y));\n"
+"}\n"
+"vec3 mix (vec3 x, vec3 y, vec3 a) {\n"
+" return vec3 (mix (x.x, y.x, a.x), mix (x.y, y.y, a.y), mix (x.z, y.z, a.z));\n"
+"}\n"
+"vec4 mix (vec4 x, vec4 y, vec4 a) {\n"
+" return vec4 (mix (x.x, y.x, a.x), mix (x.y, y.y, a.y), mix (x.z, y.z, a.z),\n"
+" mix (x.w, y.w, a.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float step (float edge, float x) {\n"
+" return x < edge ? 0.0 : 1.0;\n"
+"}\n"
+"vec2 step (float edge, vec2 x) {\n"
+" return vec2 (step (edge, x.x), step (edge, x.y));\n"
+"}\n"
+"vec3 step (float edge, vec3 x) {\n"
+" return vec3 (step (edge, x.x), step (edge, x.y), step (edge, x.z));\n"
+"}\n"
+"vec4 step (float edge, vec4 x) {\n"
+" return vec4 (step (edge, x.x), step (edge, x.y), step (edge, x.z), step (edge, x.w));\n"
+"}\n"
+"vec2 step (vec2 edge, vec2 x) {\n"
+" return vec2 (step (edge.x, x.x), step (edge.y, x.y));\n"
+"}\n"
+"vec3 step (vec3 edge, vec3 x) {\n"
+" return vec3 (step (edge.x, x.x), step (edge.y, x.y), step (edge.z, x.z));\n"
+"}\n"
+"vec4 step (vec4 edge, vec4 x) {\n"
+" return vec4 (step (edge.x, x.x), step (edge.y, x.y), step (edge.z, x.z), step (edge.w, x.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float smoothstep (float edge0, float edge1, float x) {\n"
+" const float t = clamp ((x - edge0) / (edge1 - edge0), 0.0, 1.0);\n"
+" return t * t * (3.0 - 2.0 * t);\n"
+"}\n"
+"vec2 smoothstep (float edge0, float edge1, vec2 x) {\n"
+" return vec2 (smoothstep (edge0, edge1, x.x), smoothstep (edge0, edge1, x.y));\n"
+"}\n"
+"vec3 smoothstep (float edge0, float edge1, vec3 x) {\n"
+" return vec3 (smoothstep (edge0, edge1, x.x), smoothstep (edge0, edge1, x.y),\n"
+" smoothstep (edge0, edge1, x.z));\n"
+"}\n"
+"vec4 smoothstep (float edge0, float edge1, vec4 x) {\n"
+" return vec4 (smoothstep (edge0, edge1, x.x), smoothstep (edge0, edge1, x.y),\n"
+" smoothstep (edge0, edge1, x.z), smoothstep (edge0, edge1, x.w));\n"
+"}\n"
+"vec2 smoothstep (vec2 edge0, vec2 edge1, vec2 x) {\n"
+" return vec2 (smoothstep (edge0.x, edge1.x, x.x), smoothstep (edge0.y, edge1.y, x.y));\n"
+"}\n"
+"vec3 smoothstep (vec3 edge0, vec3 edge1, vec3 x) {\n"
+" return vec3 (smoothstep (edge0.x, edge1.x, x.x), smoothstep (edge0.y, edge1.y, x.y),\n"
+" smoothstep (edge0.z, edge1.z, x.z));\n"
+"}\n"
+"vec4 smoothstep (vec4 edge0, vec4 edge1, vec4 x) {\n"
+" return vec4 (smoothstep (edge0.x, edge1.x, x.x), smoothstep (edge0.y, edge1.y, x.y),\n"
+" smoothstep (edge0.z, edge1.z, x.z), smoothstep (edge0.w, edge1.w, x.w));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float dot (float x, float y) {\n"
+" return x * y;\n"
+"}\n"
+"float dot (vec2 x, vec2 y) {\n"
+" return dot (x.x, y.x) + dot (x.y, y.y);\n"
+"}\n"
+"float dot (vec3 x, vec3 y) {\n"
+" return dot (x.x, y.x) + dot (x.y, y.y) + dot (x.z, y.z);\n"
+"}\n"
+"float dot (vec4 x, vec4 y) {\n"
+" return dot (x.x, y.x) + dot (x.y, y.y) + dot (x.z, y.z) + dot (x.w, y.w);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float length (float x) {\n"
+" return sqrt (dot (x, x));\n"
+"}\n"
+"float length (vec2 x) {\n"
+" return sqrt (dot (x, x));\n"
+"}\n"
+"float length (vec3 x) {\n"
+" return sqrt (dot (x, x));\n"
+"}\n"
+"float length (vec4 x) {\n"
+" return sqrt (dot (x, x));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float distance (float x, float y) {\n"
+" return length (x - y);\n"
+"}\n"
+"float distance (vec2 x, vec2 y) {\n"
+" return length (x - y);\n"
+"}\n"
+"float distance (vec3 x, vec3 y) {\n"
+" return length (x - y);\n"
+"}\n"
+"float distance (vec4 x, vec4 y) {\n"
+" return length (x - y);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec3 cross (vec3 x, vec3 y) {\n"
+" return vec3 (x.y * y.z - y.y * x.z, x.z * y.x - y.z * x.x, x.x * y.y - y.x * x.y);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float normalize (float x) {\n"
+" return 1.0;\n"
+"}\n"
+"vec2 normalize (vec2 x) {\n"
+" return x / length (x);\n"
+"}\n"
+"vec3 normalize (vec3 x) {\n"
+" return x / length (x);\n"
+"}\n"
+"vec4 normalize (vec4 x) {\n"
+" return x / length (x);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float faceforward (float N, float I, float Nref) {\n"
+" return dot (Nref, I) < 0.0 ? N : -N;\n"
+"}\n"
+"vec2 faceforward (vec2 N, vec2 I, vec2 Nref) {\n"
+" return dot (Nref, I) < 0.0 ? N : -N;\n"
+"}\n"
+"vec3 faceforward (vec3 N, vec3 I, vec3 Nref) {\n"
+" return dot (Nref, I) < 0.0 ? N : -N;\n"
+"}\n"
+"vec4 faceforward (vec4 N, vec4 I, vec4 Nref) {\n"
+" return dot (Nref, I) < 0.0 ? N : -N;\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float reflect (float I, float N) {\n"
+" return I - 2.0 * dot (N, I) * N;\n"
+"}\n"
+"vec2 reflect (vec2 I, vec2 N) {\n"
+" return I - 2.0 * dot (N, I) * N;\n"
+"}\n"
+"vec3 reflect (vec3 I, vec3 N) {\n"
+" return I - 2.0 * dot (N, I) * N;\n"
+"}\n"
+"vec4 reflect (vec4 I, vec4 N) {\n"
+" return I - 2.0 * dot (N, I) * N;\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float refract (float I, float N, float eta) {\n"
+" const float k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));\n"
+" if (k < 0.0)\n"
+" return 0.0;\n"
+" return eta * I - (eta * dot (N, I) + sqrt (k)) * N;\n"
+"}\n"
+"vec2 refract (vec2 I, vec2 N, float eta) {\n"
+" const float k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));\n"
+" if (k < 0.0)\n"
+" return vec2 (0.0);\n"
+" return eta * I - (eta * dot (N, I) + sqrt (k)) * N;\n"
+"}\n"
+"vec3 refract (vec3 I, vec3 N, float eta) {\n"
+" const float k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));\n"
+" if (k < 0.0)\n"
+" return vec3 (0.0);\n"
+" return eta * I - (eta * dot (N, I) + sqrt (k)) * N;\n"
+"}\n"
+"vec4 refract (vec4 I, vec4 N, float eta) {\n"
+" const float k = 1.0 - eta * eta * (1.0 - dot (N, I) * dot (N, I));\n"
+" if (k < 0.0)\n"
+" return vec4 (0.0);\n"
+" return eta * I - (eta * dot (N, I) + sqrt (k)) * N;\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"mat2 matrixCompMult (mat2 x, mat2 y) {\n"
+" return mat2 (\n"
+" x[0].x * y[0].x, x[0].y * y[0].y,\n"
+" x[1].x * y[1].x, x[1].y * y[1].y\n"
+" );\n"
+"}\n"
+"mat3 matrixCompMult (mat3 x, mat3 y) {\n"
+" return mat4 (\n"
+" x[0].x * y[0].x, x[0].y * y[0].y, x[0].z * y[0].z,\n"
+" x[1].x * y[1].x, x[1].y * y[1].y, x[1].z * y[1].z,\n"
+" x[2].x * y[2].x, x[2].y * y[2].y, x[2].z * y[2].z\n"
+" );\n"
+"}\n"
+"mat4 matrixCompMult (mat4 x, mat4 y) {\n"
+" return mat4 (\n"
+" x[0].x * y[0].x, x[0].y * y[0].y, x[0].z * y[0].z + x[0].w * y[0].w,\n"
+" x[1].x * y[1].x, x[1].y * y[1].y, x[1].z * y[1].z + x[1].w * y[1].w,\n"
+" x[2].x * y[2].x, x[2].y * y[2].y, x[2].z * y[2].z + x[2].w * y[2].w,\n"
+" x[3].x * y[3].x, x[3].y * y[3].y, x[3].z * y[3].z + x[3].w * y[3].w\n"
+" );\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"bvec2 lessThan (vec2 x, vec2 y) {\n"
+" return bvec2 (x.x < y.x, x.y < y.y);\n"
+"}\n"
+"bvec3 lessThan (vec3 x, vec3 y) {\n"
+" return bvec3 (x.x < y.x, x.y < y.y, x.z < y.z);\n"
+"}\n"
+"bvec4 lessThan (vec4 x, vec4 y) {\n"
+" return bvec4 (x.x < y.x, x.y < y.y, x.z < y.z, x.w < y.w);\n"
+"}\n"
+"bvec2 lessThan (ivec2 x, ivec2 y) {\n"
+" return bvec2 (x.x < y.x, x.y < y.y);\n"
+"}\n"
+"bvec3 lessThan (ivec3 x, ivec3 y) {\n"
+" return bvec3 (x.x < y.x, x.y < y.y, x.z < y.z);\n"
+"}\n"
+"bvec4 lessThan (ivec4 x, ivec4 y) {\n"
+" return bvec4 (x.x < y.x, x.y < y.y, x.z < y.z, x.w < y.w);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"bvec2 lessThanEqual (vec2 x, vec2 y) {\n"
+" return bvec2 (x.x <= y.x, x.y <= y.y);\n"
+"}\n"
+"bvec3 lessThanEqual (vec3 x, vec3 y) {\n"
+" return bvec3 (x.x <= y.x, x.y <= y.y, x.z <= y.z);\n"
+"}\n"
+"bvec4 lessThanEqual (vec4 x, vec4 y) {\n"
+" return bvec4 (x.x <= y.x, x.y <= y.y, x.z <= y.z, x.w <= y.w);\n"
+"}\n"
+"bvec2 lessThanEqual (ivec2 x, ivec2 y) {\n"
+" return bvec2 (x.x <= y.x, x.y <= y.y);\n"
+"}\n"
+"bvec3 lessThanEqual (ivec3 x, ivec3 y) {\n"
+" return bvec3 (x.x <= y.x, x.y <= y.y, x.z <= y.z);\n"
+"}\n"
+"bvec4 lessThanEqual (ivec4 x, ivec4 y) {\n"
+" return bvec4 (x.x <= y.x, x.y <= y.y, x.z <= y.z, x.w <= y.w);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"bvec2 greaterThan (vec2 x, vec2 y) {\n"
+" return bvec2 (x.x > y.x, x.y > y.y);\n"
+"}\n"
+"bvec3 greaterThan (vec3 x, vec3 y) {\n"
+" return bvec3 (x.x > y.x, x.y > y.y, x.z > y.z);\n"
+"}\n"
+"bvec4 greaterThan (vec4 x, vec4 y) {\n"
+" return bvec4 (x.x > y.x, x.y > y.y, x.z > y.z, x.w > y.w);\n"
+"}\n"
+"bvec2 greaterThan (ivec2 x, ivec2 y) {\n"
+" return bvec2 (x.x > y.x, x.y > y.y);\n"
+"}\n"
+"bvec3 greaterThan (ivec3 x, ivec3 y) {\n"
+" return bvec3 (x.x > y.x, x.y > y.y, x.z > y.z);\n"
+"}\n"
+"bvec4 greaterThan (ivec4 x, ivec4 y) {\n"
+" return bvec4 (x.x > y.x, x.y > y.y, x.z > y.z, x.w > y.w);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"bvec2 greaterThanEqual (vec2 x, vec2 y) {\n"
+" return bvec2 (x.x >= y.x, x.y >= y.y);\n"
+"}\n"
+"bvec3 greaterThanEqual (vec3 x, vec3 y) {\n"
+" return bvec3 (x.x >= y.x, x.y >= y.y, x.z >= y.z);\n"
+"}\n"
+"bvec4 greaterThanEqual (vec4 x, vec4 y) {\n"
+" return bvec4 (x.x >= y.x, x.y >= y.y, x.z >= y.z, x.w >= y.w);\n"
+"}\n"
+"bvec2 greaterThanEqual (ivec2 x, ivec2 y) {\n"
+" return bvec2 (x.x >= y.x, x.y >= y.y);\n"
+"}\n"
+"bvec3 greaterThanEqual (ivec3 x, ivec3 y) {\n"
+" return bvec3 (x.x >= y.x, x.y >= y.y, x.z >= y.z);\n"
+"}\n"
+"bvec4 greaterThanEqual (ivec4 x, ivec4 y) {\n"
+" return bvec4 (x.x >= y.x, x.y >= y.y, x.z >= y.z, x.w >= y.w);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"bvec2 equal (vec2 x, vec2 y) {\n"
+" return bvec2 (x.x == y.x, x.y == y.y);\n"
+"}\n"
+"bvec3 equal (vec3 x, vec3 y) {\n"
+" return bvec3 (x.x == y.x, x.y == y.y, x.z == y.z);\n"
+"}\n"
+"bvec4 equal (vec4 x, vec4 y) {\n"
+" return bvec4 (x.x == y.x, x.y == y.y, x.z == y.z, x.w == y.w);\n"
+"}\n"
+"bvec2 equal (ivec2 x, ivec2 y) {\n"
+" return bvec2 (x.x == y.x, x.y == y.y);\n"
+"}\n"
+"bvec3 equal (ivec3 x, ivec3 y) {\n"
+" return bvec3 (x.x == y.x, x.y == y.y, x.z == y.z);\n"
+"}\n"
+"bvec4 equal (ivec4 x, ivec4 y) {\n"
+" return bvec4 (x.x == y.x, x.y == y.y, x.z == y.z, x.w == y.w);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"bvec2 notEqual (vec2 x, vec2 y) {\n"
+" return bvec2 (x.x != y.x, x.y != y.y);\n"
+"}\n"
+"bvec3 notEqual (vec3 x, vec3 y) {\n"
+" return bvec3 (x.x != y.x, x.y != y.y, x.z != y.z);\n"
+"}\n"
+"bvec4 notEqual (vec4 x, vec4 y) {\n"
+" return bvec4 (x.x != y.x, x.y != y.y, x.z != y.z, x.w != y.w);\n"
+"}\n"
+"bvec2 notEqual (ivec2 x, ivec2 y) {\n"
+" return bvec2 (x.x != y.x, x.y != y.y);\n"
+"}\n"
+"bvec3 notEqual (ivec3 x, ivec3 y) {\n"
+" return bvec3 (x.x != y.x, x.y != y.y, x.z != y.z);\n"
+"}\n"
+"bvec4 notEqual (ivec4 x, ivec4 y) {\n"
+" return bvec4 (x.x != y.x, x.y != y.y, x.z != y.z, x.w != y.w);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"bool any (bvec2 x) {\n"
+" return x.x || x.y;\n"
+"}\n"
+"bool any (bvec3 x) {\n"
+" return x.x || x.y || x.z;\n"
+"}\n"
+"bool any (bvec4 x) {\n"
+" return x.x || x.y || x.z || x.w;\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"bool all (bvec2 x) {\n"
+" return x.x && x.y;\n"
+"}\n"
+"bool all (bvec3 x) {\n"
+" return x.x && x.y && x.z;\n"
+"}\n"
+"bool all (bvec4 x) {\n"
+" return x.x && x.y && x.z && x.w;\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"bvec2 not (bvec2 x) {\n"
+" return bvec2 (!x.x, !x.y);\n"
+"}\n"
+"bvec3 not (bvec3 x) {\n"
+" return bvec3 (!x.x, !x.y, !x.z);\n"
+"}\n"
+"bvec4 not (bvec4 x) {\n"
+" return bvec4 (!x.x, !x.y, !x.z, !x.w);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec4 texture1D (sampler1D sampler, float coord) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"vec4 texture1DProj (sampler1D sampler, vec2 coord) {\n"
+" return texture1D (sampler, coord.s / coord.t);\n"
+"}\n"
+"vec4 texture1DProj (sampler1D sampler, vec4 coord) {\n"
+" return texture1D (sampler, coord.s / coord.q);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec4 texture2D (sampler2D sampler, vec2 coord) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"vec4 texture2DProj (sampler2D sampler, vec3 coord) {\n"
+" return texture2D (sampler, vec2 (coord.s / coord.p, coord.t / coord.p));\n"
+"}\n"
+"vec4 texture2DProj (sampler2D sampler, vec4 coord) {\n"
+" return texture2D (sampler, vec2 (coord.s / coord.q, coord.t / coord.q));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec4 texture3D (sampler3D sampler, vec3 coord) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"vec4 texture3DProj (sampler3D sampler, vec4 coord) {\n"
+" return texture3D (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec4 textureCube (samplerCube sampler, vec3 coord) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec4 shadow1D (sampler1DShadow sampler, vec3 coord) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"\n"
+"vec4 shadow2D (sampler2DShadow sampler, vec3 coord) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord) {\n"
+" return shadow1D (sampler, vec3 (coord.s / coord.q, 0.0, coord.p / coord.q));\n"
+"}\n"
+"vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord) {\n"
+" return shadow2D (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q));\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float noise1 (float x) {\n"
+" return 0.0;\n"
+"}\n"
+"\n"
+"float noise1 (vec2 x) {\n"
+" return 0.0;\n"
+"}\n"
+"\n"
+"float noise1 (vec3 x) {\n"
+" return 0.0;\n"
+"}\n"
+"\n"
+"float noise1 (vec4 x) {\n"
+" return 0.0;\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec2 noise2 (float x) {\n"
+" return vec2 (0.0);\n"
+"}\n"
+"\n"
+"vec2 noise2 (vec2 x) {\n"
+" return vec2 (0.0);\n"
+"}\n"
+"\n"
+"vec2 noise2 (vec3 x) {\n"
+" return vec2 (0.0);\n"
+"}\n"
+"\n"
+"vec2 noise2 (vec4 x) {\n"
+" return vec2 (0.0);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec3 noise3 (float x) {\n"
+" return vec3 (0.0);\n"
+"}\n"
+"\n"
+"vec3 noise3 (vec2 x) {\n"
+" return vec3 (0.0);\n"
+"}\n"
+"\n"
+"vec3 noise3 (vec3 x) {\n"
+" return vec3 (0.0);\n"
+"}\n"
+"\n"
+"vec3 noise3 (vec4 x) {\n"
+" return vec3 (0.0);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec4 noise4 (float x) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"\n"
+"vec4 noise4 (vec2 x) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"\n"
+"vec4 noise4 (vec3 x) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"\n"
+"vec4 noise4 (vec4 x) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"\n"
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_common_builtin_gc_bin.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_common_builtin_gc_bin.h
new file mode 100755
index 000000000..971229a92
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_common_builtin_gc_bin.h
@@ -0,0 +1,943 @@
+2,2,2,1,5,1,103,108,95,77,97,120,76,105,103,104,116,115,0,2,16,10,56,0,
+0,0,2,2,1,5,1,103,108,95,77,97,120,67,108,105,112,80,108,97,110,101,115,0,
+2,16,10,54,0,0,0,2,2,1,5,1,103,108,95,77,97,120,84,101,120,116,117,114,
+101,85,110,105,116,115,0,2,16,10,50,0,0,0,2,2,1,5,1,103,108,95,77,97,
+120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,2,16,10,50,0,0,0,2,2,
+1,5,1,103,108,95,77,97,120,86,101,114,116,101,120,65,116,116,114,105,98,115,0,2,
+16,10,49,54,0,0,0,2,2,1,5,1,103,108,95,77,97,120,86,101,114,116,101,120,
+85,110,105,102,111,114,109,67,111,109,112,111,110,101,110,116,115,0,2,16,10,53,49,50,
+0,0,0,2,2,1,5,1,103,108,95,77,97,120,86,97,114,121,105,110,103,70,108,111,
+97,116,115,0,2,16,10,51,50,0,0,0,2,2,1,5,1,103,108,95,77,97,120,86,
+101,114,116,101,120,84,101,120,116,117,114,101,73,109,97,103,101,85,110,105,116,115,0,2,
+16,8,48,0,0,0,2,2,1,5,1,103,108,95,77,97,120,67,111,109,98,105,110,101,
+100,84,101,120,116,117,114,101,73,109,97,103,101,85,110,105,116,115,0,2,16,10,50,0,
+0,0,2,2,1,5,1,103,108,95,77,97,120,84,101,120,116,117,114,101,73,109,97,103,
+101,85,110,105,116,115,0,2,16,10,50,0,0,0,2,2,1,5,1,103,108,95,77,97,
+120,70,114,97,103,109,101,110,116,85,110,105,102,111,114,109,67,111,109,112,111,110,101,110,
+116,115,0,2,16,10,54,52,0,0,0,2,2,1,5,1,103,108,95,77,97,120,68,114,
+97,119,66,117,102,102,101,114,115,0,2,16,10,49,0,0,0,2,2,4,15,1,103,108,
+95,77,111,100,101,108,86,105,101,119,77,97,116,114,105,120,0,0,0,2,2,4,15,1,
+103,108,95,80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,120,0,0,0,2,2,
+4,15,1,103,108,95,77,111,100,101,108,86,105,101,119,80,114,111,106,101,99,116,105,111,
+110,77,97,116,114,105,120,0,0,0,2,2,4,15,1,103,108,95,84,101,120,116,117,114,
+101,77,97,116,114,105,120,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,
+111,111,114,100,115,0,0,0,2,2,4,14,1,103,108,95,78,111,114,109,97,108,77,97,
+116,114,105,120,0,0,0,2,2,4,15,1,103,108,95,77,111,100,101,108,86,105,101,119,
+77,97,116,114,105,120,73,110,118,101,114,115,101,0,0,0,2,2,4,15,1,103,108,95,
+80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,120,73,110,118,101,114,115,101,0,
+0,0,2,2,4,15,1,103,108,95,77,111,100,101,108,86,105,101,119,80,114,111,106,101,
+99,116,105,111,110,77,97,116,114,105,120,73,110,118,101,114,115,101,0,0,0,2,2,4,
+15,1,103,108,95,84,101,120,116,117,114,101,77,97,116,114,105,120,73,110,118,101,114,115,
+101,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,
+0,0,2,2,4,15,1,103,108,95,77,111,100,101,108,86,105,101,119,77,97,116,114,105,
+120,84,114,97,110,115,112,111,115,101,0,0,0,2,2,4,15,1,103,108,95,80,114,111,
+106,101,99,116,105,111,110,77,97,116,114,105,120,84,114,97,110,115,112,111,115,101,0,0,
+0,2,2,4,15,1,103,108,95,77,111,100,101,108,86,105,101,119,80,114,111,106,101,99,
+116,105,111,110,77,97,116,114,105,120,84,114,97,110,115,112,111,115,101,0,0,0,2,2,
+4,15,1,103,108,95,84,101,120,116,117,114,101,77,97,116,114,105,120,84,114,97,110,115,
+112,111,115,101,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,
+100,115,0,0,0,2,2,4,15,1,103,108,95,77,111,100,101,108,86,105,101,119,77,97,
+116,114,105,120,73,110,118,101,114,115,101,84,114,97,110,115,112,111,115,101,0,0,0,2,
+2,4,15,1,103,108,95,80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,120,73,
+110,118,101,114,115,101,84,114,97,110,115,112,111,115,101,0,0,0,2,2,4,15,1,103,
+108,95,77,111,100,101,108,86,105,101,119,80,114,111,106,101,99,116,105,111,110,77,97,116,
+114,105,120,73,110,118,101,114,115,101,84,114,97,110,115,112,111,115,101,0,0,0,2,2,
+4,15,1,103,108,95,84,101,120,116,117,114,101,77,97,116,114,105,120,73,110,118,101,114,
+115,101,84,114,97,110,115,112,111,115,101,0,3,18,103,108,95,77,97,120,84,101,120,116,
+117,114,101,67,111,111,114,100,115,0,0,0,2,2,4,9,1,103,108,95,78,111,114,109,
+97,108,83,99,97,108,101,0,0,0,2,2,0,22,103,108,95,68,101,112,116,104,82,97,
+110,103,101,80,97,114,97,109,101,116,101,114,115,0,9,110,101,97,114,0,0,0,1,9,
+102,97,114,0,0,0,1,9,100,105,102,102,0,0,0,0,0,0,2,2,4,23,103,108,
+95,68,101,112,116,104,82,97,110,103,101,80,97,114,97,109,101,116,101,114,115,0,1,103,
+108,95,68,101,112,116,104,82,97,110,103,101,0,0,0,2,2,4,12,1,103,108,95,67,
+108,105,112,80,108,97,110,101,0,3,18,103,108,95,77,97,120,67,108,105,112,80,108,97,
+110,101,115,0,0,0,2,2,0,22,103,108,95,80,111,105,110,116,80,97,114,97,109,101,
+116,101,114,115,0,9,115,105,122,101,0,0,0,1,9,115,105,122,101,77,105,110,0,0,
+0,1,9,115,105,122,101,77,97,120,0,0,0,1,9,102,97,100,101,84,104,114,101,115,
+104,111,108,100,83,105,122,101,0,0,0,1,9,100,105,115,116,97,110,99,101,67,111,110,
+115,116,97,110,116,65,116,116,101,110,117,97,116,105,111,110,0,0,0,1,9,100,105,115,
+116,97,110,99,101,76,105,110,101,97,114,65,116,116,101,110,117,97,116,105,111,110,0,0,
+0,1,9,100,105,115,116,97,110,99,101,81,117,97,100,114,97,116,105,99,65,116,116,101,
+110,117,97,116,105,111,110,0,0,0,0,0,0,2,2,4,23,103,108,95,80,111,105,110,
+116,80,97,114,97,109,101,116,101,114,115,0,1,103,108,95,80,111,105,110,116,0,0,0,
+2,2,0,22,103,108,95,77,97,116,101,114,105,97,108,80,97,114,97,109,101,116,101,114,
+115,0,12,101,109,105,115,115,105,111,110,0,0,0,1,12,97,109,98,105,101,110,116,0,
+0,0,1,12,100,105,102,102,117,115,101,0,0,0,1,12,115,112,101,99,117,108,97,114,
+0,0,0,1,9,115,104,105,110,105,110,101,115,115,0,0,0,0,0,0,2,2,4,23,
+103,108,95,77,97,116,101,114,105,97,108,80,97,114,97,109,101,116,101,114,115,0,1,103,
+108,95,70,114,111,110,116,77,97,116,101,114,105,97,108,0,0,0,2,2,4,23,103,108,
+95,77,97,116,101,114,105,97,108,80,97,114,97,109,101,116,101,114,115,0,1,103,108,95,
+66,97,99,107,77,97,116,101,114,105,97,108,0,0,0,2,2,0,22,103,108,95,76,105,
+103,104,116,83,111,117,114,99,101,80,97,114,97,109,101,116,101,114,115,0,12,97,109,98,
+105,101,110,116,0,0,0,1,12,100,105,102,102,117,115,101,0,0,0,1,12,115,112,101,
+99,117,108,97,114,0,0,0,1,12,112,111,115,105,116,105,111,110,0,0,0,1,12,104,
+97,108,102,86,101,99,116,111,114,0,0,0,1,11,115,112,111,116,68,105,114,101,99,116,
+105,111,110,0,0,0,1,9,115,112,111,116,69,120,112,111,110,101,110,116,0,0,0,1,
+9,115,112,111,116,67,117,116,111,102,102,0,0,0,1,9,115,112,111,116,67,111,115,67,
+117,116,111,102,102,0,0,0,1,9,99,111,110,115,116,97,110,116,65,116,116,101,110,117,
+97,116,105,111,110,0,0,0,1,9,108,105,110,101,97,114,65,116,116,101,110,117,97,116,
+105,111,110,0,0,0,1,9,113,117,97,100,114,97,116,105,99,65,116,116,101,110,117,97,
+116,105,111,110,0,0,0,0,0,0,2,2,4,23,103,108,95,76,105,103,104,116,83,111,
+117,114,99,101,80,97,114,97,109,101,116,101,114,115,0,1,103,108,95,76,105,103,104,116,
+83,111,117,114,99,101,0,3,18,103,108,95,77,97,120,76,105,103,104,116,115,0,0,0,
+2,2,0,22,103,108,95,76,105,103,104,116,77,111,100,101,108,80,97,114,97,109,101,116,
+101,114,115,0,12,97,109,98,105,101,110,116,0,0,0,0,0,0,2,2,4,23,103,108,
+95,76,105,103,104,116,77,111,100,101,108,80,97,114,97,109,101,116,101,114,115,0,1,103,
+108,95,76,105,103,104,116,77,111,100,101,108,0,0,0,2,2,0,22,103,108,95,76,105,
+103,104,116,77,111,100,101,108,80,114,111,100,117,99,116,115,0,12,115,99,101,110,101,67,
+111,108,111,114,0,0,0,0,0,0,2,2,4,23,103,108,95,76,105,103,104,116,77,111,
+100,101,108,80,114,111,100,117,99,116,115,0,1,103,108,95,70,114,111,110,116,76,105,103,
+104,116,77,111,100,101,108,80,114,111,100,117,99,116,0,0,0,2,2,4,23,103,108,95,
+76,105,103,104,116,77,111,100,101,108,80,114,111,100,117,99,116,115,0,1,103,108,95,66,
+97,99,107,76,105,103,104,116,77,111,100,101,108,80,114,111,100,117,99,116,0,0,0,2,
+2,0,22,103,108,95,76,105,103,104,116,80,114,111,100,117,99,116,115,0,12,97,109,98,
+105,101,110,116,0,0,0,1,12,100,105,102,102,117,115,101,0,0,0,1,12,115,112,101,
+99,117,108,97,114,0,0,0,0,0,0,2,2,4,23,103,108,95,76,105,103,104,116,80,
+114,111,100,117,99,116,115,0,1,103,108,95,70,114,111,110,116,76,105,103,104,116,80,114,
+111,100,117,99,116,0,3,18,103,108,95,77,97,120,76,105,103,104,116,115,0,0,0,2,
+2,4,23,103,108,95,76,105,103,104,116,80,114,111,100,117,99,116,115,0,1,103,108,95,
+66,97,99,107,76,105,103,104,116,80,114,111,100,117,99,116,0,3,18,103,108,95,77,97,
+120,76,105,103,104,116,115,0,0,0,2,2,4,12,1,103,108,95,84,101,120,116,117,114,
+101,69,110,118,67,111,108,111,114,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,
+101,73,109,97,103,101,85,110,105,116,115,0,0,0,2,2,4,12,1,103,108,95,69,121,
+101,80,108,97,110,101,83,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,
+111,111,114,100,115,0,0,0,2,2,4,12,1,103,108,95,69,121,101,80,108,97,110,101,
+84,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,
+0,0,2,2,4,12,1,103,108,95,69,121,101,80,108,97,110,101,82,0,3,18,103,108,
+95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,4,12,
+1,103,108,95,69,121,101,80,108,97,110,101,81,0,3,18,103,108,95,77,97,120,84,101,
+120,116,117,114,101,67,111,111,114,100,115,0,0,0,2,2,4,12,1,103,108,95,79,98,
+106,101,99,116,80,108,97,110,101,83,0,3,18,103,108,95,77,97,120,84,101,120,116,117,
+114,101,67,111,111,114,100,115,0,0,0,2,2,4,12,1,103,108,95,79,98,106,101,99,
+116,80,108,97,110,101,84,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,
+111,111,114,100,115,0,0,0,2,2,4,12,1,103,108,95,79,98,106,101,99,116,80,108,
+97,110,101,82,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,
+100,115,0,0,0,2,2,4,12,1,103,108,95,79,98,106,101,99,116,80,108,97,110,101,
+81,0,3,18,103,108,95,77,97,120,84,101,120,116,117,114,101,67,111,111,114,100,115,0,
+0,0,2,2,0,22,103,108,95,70,111,103,80,97,114,97,109,101,116,101,114,115,0,12,
+99,111,108,111,114,0,0,0,1,9,100,101,110,115,105,116,121,0,0,0,1,9,115,116,
+97,114,116,0,0,0,1,9,101,110,100,0,0,0,1,9,115,99,97,108,101,0,0,0,
+0,0,0,2,2,4,23,103,108,95,70,111,103,80,97,114,97,109,101,116,101,114,115,0,
+1,103,108,95,70,111,103,0,0,0,1,0,9,0,114,97,100,105,97,110,115,0,1,0,
+0,9,100,101,103,0,0,0,1,8,17,51,0,49,52,49,53,57,51,0,0,18,100,101,
+103,0,48,17,49,56,48,0,48,0,0,49,0,0,1,0,10,0,114,97,100,105,97,110,
+115,0,1,0,0,10,100,101,103,0,0,0,1,8,58,118,101,99,50,0,58,114,97,100,
+105,97,110,115,0,18,100,101,103,0,59,120,0,0,0,0,58,114,97,100,105,97,110,115,
+0,18,100,101,103,0,59,121,0,0,0,0,0,0,0,1,0,11,0,114,97,100,105,97,
+110,115,0,1,0,0,11,100,101,103,0,0,0,1,8,58,118,101,99,51,0,58,114,97,
+100,105,97,110,115,0,18,100,101,103,0,59,120,0,0,0,0,58,114,97,100,105,97,110,
+115,0,18,100,101,103,0,59,121,0,0,0,0,58,114,97,100,105,97,110,115,0,18,100,
+101,103,0,59,122,0,0,0,0,0,0,0,1,0,12,0,114,97,100,105,97,110,115,0,
+1,0,0,12,100,101,103,0,0,0,1,8,58,118,101,99,52,0,58,114,97,100,105,97,
+110,115,0,18,100,101,103,0,59,120,0,0,0,0,58,114,97,100,105,97,110,115,0,18,
+100,101,103,0,59,121,0,0,0,0,58,114,97,100,105,97,110,115,0,18,100,101,103,0,
+59,122,0,0,0,0,58,114,97,100,105,97,110,115,0,18,100,101,103,0,59,119,0,0,
+0,0,0,0,0,1,0,9,0,100,101,103,114,101,101,115,0,1,0,0,9,114,97,100,
+0,0,0,1,8,17,49,56,48,0,48,0,0,18,114,97,100,0,48,17,51,0,49,52,
+49,53,57,51,0,0,49,0,0,1,0,10,0,100,101,103,114,101,101,115,0,1,0,0,
+10,114,97,100,0,0,0,1,8,58,118,101,99,50,0,58,100,101,103,114,101,101,115,0,
+18,114,97,100,0,59,120,0,0,0,0,58,100,101,103,114,101,101,115,0,18,114,97,100,
+0,59,121,0,0,0,0,0,0,0,1,0,11,0,100,101,103,114,101,101,115,0,1,0,
+0,11,114,97,100,0,0,0,1,8,58,118,101,99,51,0,58,100,101,103,114,101,101,115,
+0,18,114,97,100,0,59,120,0,0,0,0,58,100,101,103,114,101,101,115,0,18,114,97,
+100,0,59,121,0,0,0,0,58,100,101,103,114,101,101,115,0,18,114,97,100,0,59,122,
+0,0,0,0,0,0,0,1,0,12,0,100,101,103,114,101,101,115,0,1,0,0,12,114,
+97,100,0,0,0,1,8,58,118,101,99,52,0,58,100,101,103,114,101,101,115,0,18,114,
+97,100,0,59,120,0,0,0,0,58,100,101,103,114,101,101,115,0,18,114,97,100,0,59,
+121,0,0,0,0,58,100,101,103,114,101,101,115,0,18,114,97,100,0,59,122,0,0,0,
+0,58,100,101,103,114,101,101,115,0,18,114,97,100,0,59,119,0,0,0,0,0,0,0,
+1,0,9,0,115,105,110,0,1,0,0,9,97,110,103,108,101,0,0,0,1,8,17,48,
+0,48,0,0,0,0,1,0,10,0,115,105,110,0,1,0,0,10,97,110,103,108,101,0,
+0,0,1,8,58,118,101,99,50,0,58,115,105,110,0,18,97,110,103,108,101,0,59,120,
+0,0,0,0,58,115,105,110,0,18,97,110,103,108,101,0,59,121,0,0,0,0,0,0,
+0,1,0,11,0,115,105,110,0,1,0,0,11,97,110,103,108,101,0,0,0,1,8,58,
+118,101,99,51,0,58,115,105,110,0,18,97,110,103,108,101,0,59,120,0,0,0,0,58,
+115,105,110,0,18,97,110,103,108,101,0,59,121,0,0,0,0,58,115,105,110,0,18,97,
+110,103,108,101,0,59,122,0,0,0,0,0,0,0,1,0,12,0,115,105,110,0,1,0,
+0,12,97,110,103,108,101,0,0,0,1,8,58,118,101,99,52,0,58,115,105,110,0,18,
+97,110,103,108,101,0,59,120,0,0,0,0,58,115,105,110,0,18,97,110,103,108,101,0,
+59,121,0,0,0,0,58,115,105,110,0,18,97,110,103,108,101,0,59,122,0,0,0,0,
+58,115,105,110,0,18,97,110,103,108,101,0,59,119,0,0,0,0,0,0,0,1,0,9,
+0,99,111,115,0,1,0,0,9,97,110,103,108,101,0,0,0,1,8,58,115,105,110,0,
+18,97,110,103,108,101,0,17,49,0,53,55,48,56,0,0,46,0,0,0,0,1,0,10,
+0,99,111,115,0,1,0,0,10,97,110,103,108,101,0,0,0,1,8,58,118,101,99,50,
+0,58,99,111,115,0,18,97,110,103,108,101,0,59,120,0,0,0,0,58,99,111,115,0,
+18,97,110,103,108,101,0,59,121,0,0,0,0,0,0,0,1,0,11,0,99,111,115,0,
+1,0,0,11,97,110,103,108,101,0,0,0,1,8,58,118,101,99,51,0,58,99,111,115,
+0,18,97,110,103,108,101,0,59,120,0,0,0,0,58,99,111,115,0,18,97,110,103,108,
+101,0,59,121,0,0,0,0,58,99,111,115,0,18,97,110,103,108,101,0,59,122,0,0,
+0,0,0,0,0,1,0,12,0,99,111,115,0,1,0,0,12,97,110,103,108,101,0,0,
+0,1,8,58,118,101,99,52,0,58,99,111,115,0,18,97,110,103,108,101,0,59,120,0,
+0,0,0,58,99,111,115,0,18,97,110,103,108,101,0,59,121,0,0,0,0,58,99,111,
+115,0,18,97,110,103,108,101,0,59,122,0,0,0,0,58,99,111,115,0,18,97,110,103,
+108,101,0,59,119,0,0,0,0,0,0,0,1,0,9,0,116,97,110,0,1,0,0,9,
+97,110,103,108,101,0,0,0,1,8,58,115,105,110,0,18,97,110,103,108,101,0,0,0,
+58,99,111,115,0,18,97,110,103,108,101,0,0,0,49,0,0,1,0,10,0,116,97,110,
+0,1,0,0,10,97,110,103,108,101,0,0,0,1,8,58,118,101,99,50,0,58,116,97,
+110,0,18,97,110,103,108,101,0,59,120,0,0,0,0,58,116,97,110,0,18,97,110,103,
+108,101,0,59,121,0,0,0,0,0,0,0,1,0,11,0,116,97,110,0,1,0,0,11,
+97,110,103,108,101,0,0,0,1,8,58,118,101,99,51,0,58,116,97,110,0,18,97,110,
+103,108,101,0,59,120,0,0,0,0,58,116,97,110,0,18,97,110,103,108,101,0,59,121,
+0,0,0,0,58,116,97,110,0,18,97,110,103,108,101,0,59,122,0,0,0,0,0,0,
+0,1,0,12,0,116,97,110,0,1,0,0,12,97,110,103,108,101,0,0,0,1,8,58,
+118,101,99,52,0,58,116,97,110,0,18,97,110,103,108,101,0,59,120,0,0,0,0,58,
+116,97,110,0,18,97,110,103,108,101,0,59,121,0,0,0,0,58,116,97,110,0,18,97,
+110,103,108,101,0,59,122,0,0,0,0,58,116,97,110,0,18,97,110,103,108,101,0,59,
+119,0,0,0,0,0,0,0,1,0,9,0,97,115,105,110,0,1,0,0,9,120,0,0,
+0,1,8,17,48,0,48,0,0,0,0,1,0,10,0,97,115,105,110,0,1,0,0,10,
+120,0,0,0,1,8,58,118,101,99,50,0,58,97,115,105,110,0,18,120,0,59,120,0,
+0,0,0,58,97,115,105,110,0,18,120,0,59,121,0,0,0,0,0,0,0,1,0,11,
+0,97,115,105,110,0,1,0,0,11,120,0,0,0,1,8,58,118,101,99,51,0,58,97,
+115,105,110,0,18,120,0,59,120,0,0,0,0,58,97,115,105,110,0,18,120,0,59,121,
+0,0,0,0,58,97,115,105,110,0,18,120,0,59,122,0,0,0,0,0,0,0,1,0,
+12,0,97,115,105,110,0,1,0,0,12,120,0,0,0,1,8,58,118,101,99,52,0,58,
+97,115,105,110,0,18,120,0,59,120,0,0,0,0,58,97,115,105,110,0,18,120,0,59,
+121,0,0,0,0,58,97,115,105,110,0,18,120,0,59,122,0,0,0,0,58,97,115,105,
+110,0,18,120,0,59,119,0,0,0,0,0,0,0,1,0,9,0,97,99,111,115,0,1,
+0,0,9,120,0,0,0,1,8,17,48,0,48,0,0,0,0,1,0,10,0,97,99,111,
+115,0,1,0,0,10,120,0,0,0,1,8,58,118,101,99,50,0,58,97,99,111,115,0,
+18,120,0,59,120,0,0,0,0,58,97,99,111,115,0,18,120,0,59,121,0,0,0,0,
+0,0,0,1,0,11,0,97,99,111,115,0,1,0,0,11,120,0,0,0,1,8,58,118,
+101,99,51,0,58,97,99,111,115,0,18,120,0,59,120,0,0,0,0,58,97,99,111,115,
+0,18,120,0,59,121,0,0,0,0,58,97,99,111,115,0,18,120,0,59,122,0,0,0,
+0,0,0,0,1,0,12,0,97,99,111,115,0,1,0,0,12,120,0,0,0,1,8,58,
+118,101,99,52,0,58,97,99,111,115,0,18,120,0,59,120,0,0,0,0,58,97,99,111,
+115,0,18,120,0,59,121,0,0,0,0,58,97,99,111,115,0,18,120,0,59,122,0,0,
+0,0,58,97,99,111,115,0,18,120,0,59,119,0,0,0,0,0,0,0,1,0,9,0,
+97,116,97,110,0,1,0,0,9,120,0,0,1,0,0,9,121,0,0,0,1,8,17,48,
+0,48,0,0,0,0,1,0,10,0,97,116,97,110,0,1,0,0,10,120,0,0,1,0,
+0,10,121,0,0,0,1,8,58,118,101,99,50,0,58,97,116,97,110,0,18,120,0,59,
+120,0,0,18,121,0,59,120,0,0,0,0,58,97,116,97,110,0,18,120,0,59,121,0,
+0,18,121,0,59,121,0,0,0,0,0,0,0,1,0,11,0,97,116,97,110,0,1,0,
+0,11,120,0,0,1,0,0,11,121,0,0,0,1,8,58,118,101,99,51,0,58,97,116,
+97,110,0,18,120,0,59,120,0,0,18,121,0,59,120,0,0,0,0,58,97,116,97,110,
+0,18,120,0,59,121,0,0,18,121,0,59,121,0,0,0,0,58,97,116,97,110,0,18,
+120,0,59,122,0,0,18,121,0,59,122,0,0,0,0,0,0,0,1,0,12,0,97,116,
+97,110,0,1,0,0,12,120,0,0,1,0,0,12,121,0,0,0,1,8,58,118,101,99,
+52,0,58,97,116,97,110,0,18,120,0,59,120,0,0,18,121,0,59,120,0,0,0,0,
+58,97,116,97,110,0,18,120,0,59,121,0,0,18,121,0,59,121,0,0,0,0,58,97,
+116,97,110,0,18,120,0,59,122,0,0,18,121,0,59,122,0,0,0,0,58,97,116,97,
+110,0,18,120,0,59,119,0,0,18,121,0,59,119,0,0,0,0,0,0,0,1,0,9,
+0,97,116,97,110,0,1,0,0,9,121,95,111,118,101,114,95,120,0,0,0,1,8,17,
+48,0,48,0,0,0,0,1,0,10,0,97,116,97,110,0,1,0,0,10,121,95,111,118,
+101,114,95,120,0,0,0,1,8,58,118,101,99,50,0,58,97,116,97,110,0,18,121,95,
+111,118,101,114,95,120,0,59,120,0,0,0,0,58,97,116,97,110,0,18,121,95,111,118,
+101,114,95,120,0,59,121,0,0,0,0,0,0,0,1,0,11,0,97,116,97,110,0,1,
+0,0,11,121,95,111,118,101,114,95,120,0,0,0,1,8,58,118,101,99,51,0,58,97,
+116,97,110,0,18,121,95,111,118,101,114,95,120,0,59,120,0,0,0,0,58,97,116,97,
+110,0,18,121,95,111,118,101,114,95,120,0,59,121,0,0,0,0,58,97,116,97,110,0,
+18,121,95,111,118,101,114,95,120,0,59,122,0,0,0,0,0,0,0,1,0,12,0,97,
+116,97,110,0,1,0,0,12,121,95,111,118,101,114,95,120,0,0,0,1,8,58,118,101,
+99,52,0,58,97,116,97,110,0,18,121,95,111,118,101,114,95,120,0,59,120,0,0,0,
+0,58,97,116,97,110,0,18,121,95,111,118,101,114,95,120,0,59,121,0,0,0,0,58,
+97,116,97,110,0,18,121,95,111,118,101,114,95,120,0,59,122,0,0,0,0,58,97,116,
+97,110,0,18,121,95,111,118,101,114,95,120,0,59,119,0,0,0,0,0,0,0,1,0,
+9,0,112,111,119,0,1,0,0,9,120,0,0,1,0,0,9,121,0,0,0,1,8,17,
+48,0,48,0,0,0,0,1,0,10,0,112,111,119,0,1,0,0,10,120,0,0,1,0,
+0,10,121,0,0,0,1,8,58,118,101,99,50,0,58,112,111,119,0,18,120,0,59,120,
+0,0,18,121,0,59,120,0,0,0,0,58,112,111,119,0,18,120,0,59,121,0,0,18,
+121,0,59,121,0,0,0,0,0,0,0,1,0,11,0,112,111,119,0,1,0,0,11,120,
+0,0,1,0,0,11,121,0,0,0,1,8,58,118,101,99,51,0,58,112,111,119,0,18,
+120,0,59,120,0,0,18,121,0,59,120,0,0,0,0,58,112,111,119,0,18,120,0,59,
+121,0,0,18,121,0,59,121,0,0,0,0,58,112,111,119,0,18,120,0,59,122,0,0,
+18,121,0,59,122,0,0,0,0,0,0,0,1,0,12,0,112,111,119,0,1,0,0,12,
+120,0,0,1,0,0,12,121,0,0,0,1,8,58,118,101,99,52,0,58,112,111,119,0,
+18,120,0,59,120,0,0,18,121,0,59,120,0,0,0,0,58,112,111,119,0,18,120,0,
+59,121,0,0,18,121,0,59,121,0,0,0,0,58,112,111,119,0,18,120,0,59,122,0,
+0,18,121,0,59,122,0,0,0,0,58,112,111,119,0,18,120,0,59,119,0,0,18,121,
+0,59,119,0,0,0,0,0,0,0,1,0,9,0,101,120,112,0,1,0,0,9,120,0,
+0,0,1,8,58,112,111,119,0,17,50,0,55,49,56,50,56,49,56,51,0,0,0,18,
+120,0,0,0,0,0,1,0,10,0,101,120,112,0,1,0,0,10,120,0,0,0,1,8,
+58,118,101,99,50,0,58,101,120,112,0,18,120,0,59,120,0,0,0,0,58,101,120,112,
+0,18,120,0,59,121,0,0,0,0,0,0,0,1,0,11,0,101,120,112,0,1,0,0,
+11,120,0,0,0,1,8,58,118,101,99,51,0,58,101,120,112,0,18,120,0,59,120,0,
+0,0,0,58,101,120,112,0,18,120,0,59,121,0,0,0,0,58,101,120,112,0,18,120,
+0,59,122,0,0,0,0,0,0,0,1,0,12,0,101,120,112,0,1,0,0,12,120,0,
+0,0,1,8,58,118,101,99,52,0,58,101,120,112,0,18,120,0,59,120,0,0,0,0,
+58,101,120,112,0,18,120,0,59,121,0,0,0,0,58,101,120,112,0,18,120,0,59,122,
+0,0,0,0,58,101,120,112,0,18,120,0,59,119,0,0,0,0,0,0,0,1,0,9,
+0,108,111,103,0,1,0,0,9,120,0,0,0,1,8,58,108,111,103,50,0,18,120,0,
+0,0,58,108,111,103,50,0,17,50,0,55,49,56,50,56,49,56,51,0,0,0,0,49,
+0,0,1,0,10,0,108,111,103,0,1,0,0,10,120,0,0,0,1,8,58,118,101,99,
+50,0,58,108,111,103,0,18,120,0,59,120,0,0,0,0,58,108,111,103,0,18,120,0,
+59,121,0,0,0,0,0,0,0,1,0,11,0,108,111,103,0,1,0,0,11,120,0,0,
+0,1,8,58,118,101,99,51,0,58,108,111,103,0,18,120,0,59,120,0,0,0,0,58,
+108,111,103,0,18,120,0,59,121,0,0,0,0,58,108,111,103,0,18,120,0,59,122,0,
+0,0,0,0,0,0,1,0,12,0,108,111,103,0,1,0,0,12,120,0,0,0,1,8,
+58,118,101,99,52,0,58,108,111,103,0,18,120,0,59,120,0,0,0,0,58,108,111,103,
+0,18,120,0,59,121,0,0,0,0,58,108,111,103,0,18,120,0,59,122,0,0,0,0,
+58,108,111,103,0,18,120,0,59,119,0,0,0,0,0,0,0,1,0,9,0,101,120,112,
+50,0,1,0,0,9,120,0,0,0,1,8,58,112,111,119,0,17,50,0,48,0,0,0,
+18,120,0,0,0,0,0,1,0,10,0,101,120,112,50,0,1,0,0,10,120,0,0,0,
+1,8,58,118,101,99,50,0,58,101,120,112,50,0,18,120,0,59,120,0,0,0,0,58,
+101,120,112,50,0,18,120,0,59,121,0,0,0,0,0,0,0,1,0,11,0,101,120,112,
+50,0,1,0,0,11,120,0,0,0,1,8,58,118,101,99,51,0,58,101,120,112,50,0,
+18,120,0,59,120,0,0,0,0,58,101,120,112,50,0,18,120,0,59,121,0,0,0,0,
+58,101,120,112,50,0,18,120,0,59,122,0,0,0,0,0,0,0,1,0,12,0,101,120,
+112,50,0,1,0,0,12,120,0,0,0,1,8,58,118,101,99,52,0,58,101,120,112,50,
+0,18,120,0,59,120,0,0,0,0,58,101,120,112,50,0,18,120,0,59,121,0,0,0,
+0,58,101,120,112,50,0,18,120,0,59,122,0,0,0,0,58,101,120,112,50,0,18,120,
+0,59,119,0,0,0,0,0,0,0,1,0,9,0,108,111,103,50,0,1,0,0,9,120,
+0,0,0,1,8,17,48,0,48,0,0,0,0,1,0,10,0,108,111,103,50,0,1,0,
+0,10,120,0,0,0,1,8,58,118,101,99,50,0,58,108,111,103,50,0,18,120,0,59,
+120,0,0,0,0,58,108,111,103,50,0,18,120,0,59,121,0,0,0,0,0,0,0,1,
+0,11,0,108,111,103,50,0,1,0,0,11,120,0,0,0,1,8,58,118,101,99,51,0,
+58,108,111,103,50,0,18,120,0,59,120,0,0,0,0,58,108,111,103,50,0,18,120,0,
+59,121,0,0,0,0,58,108,111,103,50,0,18,120,0,59,122,0,0,0,0,0,0,0,
+1,0,12,0,108,111,103,50,0,1,0,0,12,120,0,0,0,1,8,58,118,101,99,52,
+0,58,108,111,103,50,0,18,120,0,59,120,0,0,0,0,58,108,111,103,50,0,18,120,
+0,59,121,0,0,0,0,58,108,111,103,50,0,18,120,0,59,122,0,0,0,0,58,108,
+111,103,50,0,18,120,0,59,119,0,0,0,0,0,0,0,1,0,9,0,115,113,114,116,
+0,1,0,0,9,120,0,0,0,1,8,58,112,111,119,0,18,120,0,0,17,48,0,53,
+0,0,0,0,0,0,1,0,10,0,115,113,114,116,0,1,0,0,10,120,0,0,0,1,
+8,58,118,101,99,50,0,58,115,113,114,116,0,18,120,0,59,120,0,0,0,0,58,115,
+113,114,116,0,18,120,0,59,121,0,0,0,0,0,0,0,1,0,11,0,115,113,114,116,
+0,1,0,0,11,120,0,0,0,1,8,58,118,101,99,51,0,58,115,113,114,116,0,18,
+120,0,59,120,0,0,0,0,58,115,113,114,116,0,18,120,0,59,121,0,0,0,0,58,
+115,113,114,116,0,18,120,0,59,122,0,0,0,0,0,0,0,1,0,12,0,115,113,114,
+116,0,1,0,0,12,120,0,0,0,1,8,58,118,101,99,52,0,58,115,113,114,116,0,
+18,120,0,59,120,0,0,0,0,58,115,113,114,116,0,18,120,0,59,121,0,0,0,0,
+58,115,113,114,116,0,18,120,0,59,122,0,0,0,0,58,115,113,114,116,0,18,120,0,
+59,119,0,0,0,0,0,0,0,1,0,9,0,105,110,118,101,114,115,101,115,113,114,116,
+0,1,0,0,9,120,0,0,0,1,8,17,49,0,48,0,0,58,115,113,114,116,0,18,
+120,0,0,0,49,0,0,1,0,10,0,105,110,118,101,114,115,101,115,113,114,116,0,1,
+0,0,10,120,0,0,0,1,8,58,118,101,99,50,0,58,105,110,118,101,114,115,101,115,
+113,114,116,0,18,120,0,59,120,0,0,0,0,58,105,110,118,101,114,115,101,115,113,114,
+116,0,18,120,0,59,121,0,0,0,0,0,0,0,1,0,11,0,105,110,118,101,114,115,
+101,115,113,114,116,0,1,0,0,11,120,0,0,0,1,8,58,118,101,99,51,0,58,105,
+110,118,101,114,115,101,115,113,114,116,0,18,120,0,59,120,0,0,0,0,58,105,110,118,
+101,114,115,101,115,113,114,116,0,18,120,0,59,121,0,0,0,0,58,105,110,118,101,114,
+115,101,115,113,114,116,0,18,120,0,59,122,0,0,0,0,0,0,0,1,0,12,0,105,
+110,118,101,114,115,101,115,113,114,116,0,1,0,0,12,120,0,0,0,1,8,58,118,101,
+99,52,0,58,105,110,118,101,114,115,101,115,113,114,116,0,18,120,0,59,120,0,0,0,
+0,58,105,110,118,101,114,115,101,115,113,114,116,0,18,120,0,59,121,0,0,0,0,58,
+105,110,118,101,114,115,101,115,113,114,116,0,18,120,0,59,122,0,0,0,0,58,105,110,
+118,101,114,115,101,115,113,114,116,0,18,120,0,59,119,0,0,0,0,0,0,0,1,0,
+9,0,97,98,115,0,1,0,0,9,120,0,0,0,1,8,18,120,0,17,48,0,48,0,
+0,43,18,120,0,18,120,0,54,31,0,0,1,0,10,0,97,98,115,0,1,0,0,10,
+120,0,0,0,1,8,58,118,101,99,50,0,58,97,98,115,0,18,120,0,59,120,0,0,
+0,0,58,97,98,115,0,18,120,0,59,121,0,0,0,0,0,0,0,1,0,11,0,97,
+98,115,0,1,0,0,11,120,0,0,0,1,8,58,118,101,99,51,0,58,97,98,115,0,
+18,120,0,59,120,0,0,0,0,58,97,98,115,0,18,120,0,59,121,0,0,0,0,58,
+97,98,115,0,18,120,0,59,122,0,0,0,0,0,0,0,1,0,12,0,97,98,115,0,
+1,0,0,12,120,0,0,0,1,8,58,118,101,99,52,0,58,97,98,115,0,18,120,0,
+59,120,0,0,0,0,58,97,98,115,0,18,120,0,59,121,0,0,0,0,58,97,98,115,
+0,18,120,0,59,122,0,0,0,0,58,97,98,115,0,18,120,0,59,119,0,0,0,0,
+0,0,0,1,0,9,0,115,105,103,110,0,1,0,0,9,120,0,0,0,1,8,18,120,
+0,17,48,0,48,0,0,41,17,49,0,48,0,0,18,120,0,17,48,0,48,0,0,40,
+17,49,0,48,0,0,54,17,48,0,48,0,0,31,31,0,0,1,0,10,0,115,105,103,
+110,0,1,0,0,10,120,0,0,0,1,8,58,118,101,99,50,0,58,115,105,103,110,0,
+18,120,0,59,120,0,0,0,0,58,115,105,103,110,0,18,120,0,59,121,0,0,0,0,
+0,0,0,1,0,11,0,115,105,103,110,0,1,0,0,11,120,0,0,0,1,8,58,118,
+101,99,51,0,58,115,105,103,110,0,18,120,0,59,120,0,0,0,0,58,115,105,103,110,
+0,18,120,0,59,121,0,0,0,0,58,115,105,103,110,0,18,120,0,59,122,0,0,0,
+0,0,0,0,1,0,12,0,115,105,103,110,0,1,0,0,12,120,0,0,0,1,8,58,
+118,101,99,52,0,58,115,105,103,110,0,18,120,0,59,120,0,0,0,0,58,115,105,103,
+110,0,18,120,0,59,121,0,0,0,0,58,115,105,103,110,0,18,120,0,59,122,0,0,
+0,0,58,115,105,103,110,0,18,120,0,59,119,0,0,0,0,0,0,0,1,0,9,0,
+102,108,111,111,114,0,1,0,0,9,120,0,0,0,1,8,17,48,0,48,0,0,0,0,
+1,0,10,0,102,108,111,111,114,0,1,0,0,10,120,0,0,0,1,8,58,118,101,99,
+50,0,58,102,108,111,111,114,0,18,120,0,59,120,0,0,0,0,58,102,108,111,111,114,
+0,18,120,0,59,121,0,0,0,0,0,0,0,1,0,11,0,102,108,111,111,114,0,1,
+0,0,11,120,0,0,0,1,8,58,118,101,99,51,0,58,102,108,111,111,114,0,18,120,
+0,59,120,0,0,0,0,58,102,108,111,111,114,0,18,120,0,59,121,0,0,0,0,58,
+102,108,111,111,114,0,18,120,0,59,122,0,0,0,0,0,0,0,1,0,12,0,102,108,
+111,111,114,0,1,0,0,12,120,0,0,0,1,8,58,118,101,99,52,0,58,102,108,111,
+111,114,0,18,120,0,59,120,0,0,0,0,58,102,108,111,111,114,0,18,120,0,59,121,
+0,0,0,0,58,102,108,111,111,114,0,18,120,0,59,122,0,0,0,0,58,102,108,111,
+111,114,0,18,120,0,59,119,0,0,0,0,0,0,0,1,0,9,0,99,101,105,108,0,
+1,0,0,9,120,0,0,0,1,8,17,48,0,48,0,0,0,0,1,0,10,0,99,101,
+105,108,0,1,0,0,10,120,0,0,0,1,8,58,118,101,99,50,0,58,99,101,105,108,
+0,18,120,0,59,120,0,0,0,0,58,99,101,105,108,0,18,120,0,59,121,0,0,0,
+0,0,0,0,1,0,11,0,99,101,105,108,0,1,0,0,11,120,0,0,0,1,8,58,
+118,101,99,51,0,58,99,101,105,108,0,18,120,0,59,120,0,0,0,0,58,99,101,105,
+108,0,18,120,0,59,121,0,0,0,0,58,99,101,105,108,0,18,120,0,59,122,0,0,
+0,0,0,0,0,1,0,12,0,99,101,105,108,0,1,0,0,12,120,0,0,0,1,8,
+58,118,101,99,52,0,58,99,101,105,108,0,18,120,0,59,120,0,0,0,0,58,99,101,
+105,108,0,18,120,0,59,121,0,0,0,0,58,99,101,105,108,0,18,120,0,59,122,0,
+0,0,0,58,99,101,105,108,0,18,120,0,59,119,0,0,0,0,0,0,0,1,0,9,
+0,102,114,97,99,116,0,1,0,0,9,120,0,0,0,1,8,18,120,0,58,102,108,111,
+111,114,0,18,120,0,0,0,47,0,0,1,0,10,0,102,114,97,99,116,0,1,0,0,
+10,120,0,0,0,1,8,58,118,101,99,50,0,58,102,114,97,99,116,0,18,120,0,59,
+120,0,0,0,0,58,102,114,97,99,116,0,18,120,0,59,121,0,0,0,0,0,0,0,
+1,0,11,0,102,114,97,99,116,0,1,0,0,11,120,0,0,0,1,8,58,118,101,99,
+51,0,58,102,114,97,99,116,0,18,120,0,59,120,0,0,0,0,58,102,114,97,99,116,
+0,18,120,0,59,121,0,0,0,0,58,102,114,97,99,116,0,18,120,0,59,122,0,0,
+0,0,0,0,0,1,0,12,0,102,114,97,99,116,0,1,0,0,12,120,0,0,0,1,
+8,58,118,101,99,52,0,58,102,114,97,99,116,0,18,120,0,59,120,0,0,0,0,58,
+102,114,97,99,116,0,18,120,0,59,121,0,0,0,0,58,102,114,97,99,116,0,18,120,
+0,59,122,0,0,0,0,58,102,114,97,99,116,0,18,120,0,59,119,0,0,0,0,0,
+0,0,1,0,9,0,109,111,100,0,1,0,0,9,120,0,0,1,0,0,9,121,0,0,
+0,1,8,18,120,0,18,121,0,58,102,108,111,111,114,0,18,120,0,18,121,0,49,0,
+0,48,47,0,0,1,0,10,0,109,111,100,0,1,0,0,10,120,0,0,1,0,0,9,
+121,0,0,0,1,8,58,118,101,99,50,0,58,109,111,100,0,18,120,0,59,120,0,0,
+18,121,0,0,0,0,58,109,111,100,0,18,120,0,59,121,0,0,18,121,0,0,0,0,
+0,0,0,1,0,11,0,109,111,100,0,1,0,0,11,120,0,0,1,0,0,9,121,0,
+0,0,1,8,58,118,101,99,51,0,58,109,111,100,0,18,120,0,59,120,0,0,18,121,
+0,0,0,0,58,109,111,100,0,18,120,0,59,121,0,0,18,121,0,0,0,0,58,109,
+111,100,0,18,120,0,59,122,0,0,18,121,0,0,0,0,0,0,0,1,0,12,0,109,
+111,100,0,1,0,0,12,120,0,0,1,0,0,9,121,0,0,0,1,8,58,118,101,99,
+52,0,58,109,111,100,0,18,120,0,59,120,0,0,18,121,0,0,0,0,58,109,111,100,
+0,18,120,0,59,121,0,0,18,121,0,0,0,0,58,109,111,100,0,18,120,0,59,122,
+0,0,18,121,0,0,0,0,58,109,111,100,0,18,120,0,59,119,0,0,18,121,0,0,
+0,0,0,0,0,1,0,10,0,109,111,100,0,1,0,0,10,120,0,0,1,0,0,10,
+121,0,0,0,1,8,58,118,101,99,50,0,58,109,111,100,0,18,120,0,59,120,0,0,
+18,121,0,59,120,0,0,0,0,58,109,111,100,0,18,120,0,59,121,0,0,18,121,0,
+59,121,0,0,0,0,0,0,0,1,0,11,0,109,111,100,0,1,0,0,11,120,0,0,
+1,0,0,11,121,0,0,0,1,8,58,118,101,99,51,0,58,109,111,100,0,18,120,0,
+59,120,0,0,18,121,0,59,120,0,0,0,0,58,109,111,100,0,18,120,0,59,121,0,
+0,18,121,0,59,121,0,0,0,0,58,109,111,100,0,18,120,0,59,122,0,0,18,121,
+0,59,122,0,0,0,0,0,0,0,1,0,12,0,109,111,100,0,1,0,0,12,120,0,
+0,1,0,0,12,121,0,0,0,1,8,58,118,101,99,52,0,58,109,111,100,0,18,120,
+0,59,120,0,0,18,121,0,59,120,0,0,0,0,58,109,111,100,0,18,120,0,59,121,
+0,0,18,121,0,59,121,0,0,0,0,58,109,111,100,0,18,120,0,59,122,0,0,18,
+121,0,59,122,0,0,0,0,58,109,111,100,0,18,120,0,59,119,0,0,18,121,0,59,
+119,0,0,0,0,0,0,0,1,0,9,0,109,105,110,0,1,0,0,9,120,0,0,1,
+0,0,9,121,0,0,0,1,8,18,121,0,18,120,0,40,18,121,0,18,120,0,31,0,
+0,1,0,10,0,109,105,110,0,1,0,0,10,120,0,0,1,0,0,9,121,0,0,0,
+1,8,58,118,101,99,50,0,58,109,105,110,0,18,120,0,59,120,0,0,18,121,0,0,
+0,0,58,109,105,110,0,18,120,0,59,121,0,0,18,121,0,0,0,0,0,0,0,1,
+0,11,0,109,105,110,0,1,0,0,11,120,0,0,1,0,0,9,121,0,0,0,1,8,
+58,118,101,99,51,0,58,109,105,110,0,18,120,0,59,120,0,0,18,121,0,0,0,0,
+58,109,105,110,0,18,120,0,59,121,0,0,18,121,0,0,0,0,58,109,105,110,0,18,
+120,0,59,122,0,0,18,121,0,0,0,0,0,0,0,1,0,12,0,109,105,110,0,1,
+0,0,12,120,0,0,1,0,0,9,121,0,0,0,1,8,58,118,101,99,52,0,58,109,
+105,110,0,18,120,0,59,120,0,0,18,121,0,0,0,0,58,109,105,110,0,18,120,0,
+59,121,0,0,18,121,0,0,0,0,58,109,105,110,0,18,120,0,59,122,0,0,18,121,
+0,0,0,0,58,109,105,110,0,18,120,0,59,119,0,0,18,121,0,0,0,0,0,0,
+0,1,0,10,0,109,105,110,0,1,0,0,10,120,0,0,1,0,0,10,121,0,0,0,
+1,8,58,118,101,99,50,0,58,109,105,110,0,18,120,0,59,120,0,0,18,121,0,59,
+120,0,0,0,0,58,109,105,110,0,18,120,0,59,121,0,0,18,121,0,59,121,0,0,
+0,0,0,0,0,1,0,11,0,109,105,110,0,1,0,0,11,120,0,0,1,0,0,11,
+121,0,0,0,1,8,58,118,101,99,51,0,58,109,105,110,0,18,120,0,59,120,0,0,
+18,121,0,59,120,0,0,0,0,58,109,105,110,0,18,120,0,59,121,0,0,18,121,0,
+59,121,0,0,0,0,58,109,105,110,0,18,120,0,59,122,0,0,18,121,0,59,122,0,
+0,0,0,0,0,0,1,0,12,0,109,105,110,0,1,0,0,12,120,0,0,1,0,0,
+12,121,0,0,0,1,8,58,118,101,99,52,0,58,109,105,110,0,18,120,0,59,120,0,
+0,18,121,0,59,120,0,0,0,0,58,109,105,110,0,18,120,0,59,121,0,0,18,121,
+0,59,121,0,0,0,0,58,109,105,110,0,18,120,0,59,122,0,0,18,121,0,59,122,
+0,0,0,0,58,109,105,110,0,18,120,0,59,119,0,0,18,121,0,59,119,0,0,0,
+0,0,0,0,1,0,9,0,109,97,120,0,1,0,0,9,120,0,0,1,0,0,9,121,
+0,0,0,1,8,58,109,105,110,0,18,121,0,0,18,120,0,0,0,0,0,1,0,10,
+0,109,97,120,0,1,0,0,10,120,0,0,1,0,0,9,121,0,0,0,1,8,58,118,
+101,99,50,0,58,109,97,120,0,18,120,0,59,120,0,0,18,121,0,0,0,0,58,109,
+97,120,0,18,120,0,59,121,0,0,18,121,0,0,0,0,0,0,0,1,0,11,0,109,
+97,120,0,1,0,0,11,120,0,0,1,0,0,9,121,0,0,0,1,8,58,118,101,99,
+51,0,58,109,97,120,0,18,120,0,59,120,0,0,18,121,0,0,0,0,58,109,97,120,
+0,18,120,0,59,121,0,0,18,121,0,0,0,0,58,109,97,120,0,18,120,0,59,122,
+0,0,18,121,0,0,0,0,0,0,0,1,0,12,0,109,97,120,0,1,0,0,12,120,
+0,0,1,0,0,9,121,0,0,0,1,8,58,118,101,99,52,0,58,109,97,120,0,18,
+120,0,59,120,0,0,18,121,0,0,0,0,58,109,97,120,0,18,120,0,59,121,0,0,
+18,121,0,0,0,0,58,109,97,120,0,18,120,0,59,122,0,0,18,121,0,0,0,0,
+58,109,97,120,0,18,120,0,59,119,0,0,18,121,0,0,0,0,0,0,0,1,0,10,
+0,109,97,120,0,1,0,0,10,120,0,0,1,0,0,10,121,0,0,0,1,8,58,118,
+101,99,50,0,58,109,97,120,0,18,120,0,59,120,0,0,18,121,0,59,120,0,0,0,
+0,58,109,97,120,0,18,120,0,59,121,0,0,18,121,0,59,121,0,0,0,0,0,0,
+0,1,0,11,0,109,97,120,0,1,0,0,11,120,0,0,1,0,0,11,121,0,0,0,
+1,8,58,118,101,99,51,0,58,109,97,120,0,18,120,0,59,120,0,0,18,121,0,59,
+120,0,0,0,0,58,109,97,120,0,18,120,0,59,121,0,0,18,121,0,59,121,0,0,
+0,0,58,109,97,120,0,18,120,0,59,122,0,0,18,121,0,59,122,0,0,0,0,0,
+0,0,1,0,12,0,109,97,120,0,1,0,0,12,120,0,0,1,0,0,12,121,0,0,
+0,1,8,58,118,101,99,52,0,58,109,97,120,0,18,120,0,59,120,0,0,18,121,0,
+59,120,0,0,0,0,58,109,97,120,0,18,120,0,59,121,0,0,18,121,0,59,121,0,
+0,0,0,58,109,97,120,0,18,120,0,59,122,0,0,18,121,0,59,122,0,0,0,0,
+58,109,97,120,0,18,120,0,59,119,0,0,18,121,0,59,119,0,0,0,0,0,0,0,
+1,0,9,0,99,108,97,109,112,0,1,0,0,9,120,0,0,1,0,0,9,109,105,110,
+86,97,108,0,0,1,0,0,9,109,97,120,86,97,108,0,0,0,1,8,58,109,105,110,
+0,58,109,97,120,0,18,120,0,0,18,109,105,110,86,97,108,0,0,0,0,18,109,97,
+120,86,97,108,0,0,0,0,0,1,0,10,0,99,108,97,109,112,0,1,0,0,10,120,
+0,0,1,0,0,9,109,105,110,86,97,108,0,0,1,0,0,9,109,97,120,86,97,108,
+0,0,0,1,8,58,118,101,99,50,0,58,99,108,97,109,112,0,18,120,0,59,120,0,
+0,18,109,105,110,86,97,108,0,0,18,109,97,120,86,97,108,0,0,0,0,58,99,108,
+97,109,112,0,18,120,0,59,121,0,0,18,109,105,110,86,97,108,0,0,18,109,97,120,
+86,97,108,0,0,0,0,0,0,0,1,0,11,0,99,108,97,109,112,0,1,0,0,11,
+120,0,0,1,0,0,9,109,105,110,86,97,108,0,0,1,0,0,9,109,97,120,86,97,
+108,0,0,0,1,8,58,118,101,99,51,0,58,99,108,97,109,112,0,18,120,0,59,120,
+0,0,18,109,105,110,86,97,108,0,0,18,109,97,120,86,97,108,0,0,0,0,58,99,
+108,97,109,112,0,18,120,0,59,121,0,0,18,109,105,110,86,97,108,0,0,18,109,97,
+120,86,97,108,0,0,0,0,58,99,108,97,109,112,0,18,120,0,59,122,0,0,18,109,
+105,110,86,97,108,0,0,18,109,97,120,86,97,108,0,0,0,0,0,0,0,1,0,12,
+0,99,108,97,109,112,0,1,0,0,12,120,0,0,1,0,0,9,109,105,110,86,97,108,
+0,0,1,0,0,9,109,97,120,86,97,108,0,0,0,1,8,58,118,101,99,52,0,58,
+99,108,97,109,112,0,18,120,0,59,120,0,0,18,109,105,110,86,97,108,0,0,18,109,
+97,120,86,97,108,0,0,0,0,58,99,108,97,109,112,0,18,120,0,59,121,0,0,18,
+109,105,110,86,97,108,0,0,18,109,97,120,86,97,108,0,0,0,0,58,99,108,97,109,
+112,0,18,120,0,59,122,0,0,18,109,105,110,86,97,108,0,0,18,109,97,120,86,97,
+108,0,0,0,0,58,99,108,97,109,112,0,18,120,0,59,119,0,0,18,109,105,110,86,
+97,108,0,0,18,109,97,120,86,97,108,0,0,0,0,0,0,0,1,0,10,0,99,108,
+97,109,112,0,1,0,0,10,120,0,0,1,0,0,10,109,105,110,86,97,108,0,0,1,
+0,0,10,109,97,120,86,97,108,0,0,0,1,8,58,118,101,99,50,0,58,99,108,97,
+109,112,0,18,120,0,59,120,0,0,18,109,105,110,86,97,108,0,59,120,0,0,18,109,
+97,120,86,97,108,0,59,120,0,0,0,0,58,99,108,97,109,112,0,18,120,0,59,121,
+0,0,18,109,105,110,86,97,108,0,59,121,0,0,18,109,97,120,86,97,108,0,59,121,
+0,0,0,0,0,0,0,1,0,11,0,99,108,97,109,112,0,1,0,0,11,120,0,0,
+1,0,0,11,109,105,110,86,97,108,0,0,1,0,0,11,109,97,120,86,97,108,0,0,
+0,1,8,58,118,101,99,51,0,58,99,108,97,109,112,0,18,120,0,59,120,0,0,18,
+109,105,110,86,97,108,0,59,120,0,0,18,109,97,120,86,97,108,0,59,120,0,0,0,
+0,58,99,108,97,109,112,0,18,120,0,59,121,0,0,18,109,105,110,86,97,108,0,59,
+121,0,0,18,109,97,120,86,97,108,0,59,121,0,0,0,0,58,99,108,97,109,112,0,
+18,120,0,59,122,0,0,18,109,105,110,86,97,108,0,59,122,0,0,18,109,97,120,86,
+97,108,0,59,122,0,0,0,0,0,0,0,1,0,12,0,99,108,97,109,112,0,1,0,
+0,12,120,0,0,1,0,0,12,109,105,110,86,97,108,0,0,1,0,0,12,109,97,120,
+86,97,108,0,0,0,1,8,58,118,101,99,52,0,58,99,108,97,109,112,0,18,120,0,
+59,120,0,0,18,109,105,110,86,97,108,0,59,120,0,0,18,109,97,120,86,97,108,0,
+59,121,0,0,0,0,58,99,108,97,109,112,0,18,120,0,59,121,0,0,18,109,105,110,
+86,97,108,0,59,121,0,0,18,109,97,120,86,97,108,0,59,121,0,0,0,0,58,99,
+108,97,109,112,0,18,120,0,59,122,0,0,18,109,105,110,86,97,108,0,59,122,0,0,
+18,109,97,120,86,97,108,0,59,122,0,0,0,0,58,99,108,97,109,112,0,18,120,0,
+59,119,0,0,18,109,105,110,86,97,108,0,59,119,0,0,18,109,97,120,86,97,108,0,
+59,119,0,0,0,0,0,0,0,1,0,9,0,109,105,120,0,1,0,0,9,120,0,0,
+1,0,0,9,121,0,0,1,0,0,9,97,0,0,0,1,8,18,120,0,17,49,0,48,
+0,0,18,97,0,47,48,18,121,0,18,97,0,48,46,0,0,1,0,10,0,109,105,120,
+0,1,0,0,10,120,0,0,1,0,0,10,121,0,0,1,0,0,9,97,0,0,0,1,
+8,58,118,101,99,50,0,58,109,105,120,0,18,120,0,59,120,0,0,18,121,0,59,120,
+0,0,18,97,0,0,0,0,58,109,105,120,0,18,120,0,59,121,0,0,18,121,0,59,
+121,0,0,18,97,0,0,0,0,0,0,0,1,0,11,0,109,105,120,0,1,0,0,11,
+120,0,0,1,0,0,11,121,0,0,1,0,0,9,97,0,0,0,1,8,58,118,101,99,
+51,0,58,109,105,120,0,18,120,0,59,120,0,0,18,121,0,59,120,0,0,18,97,0,
+0,0,0,58,109,105,120,0,18,120,0,59,121,0,0,18,121,0,59,121,0,0,18,97,
+0,0,0,0,58,109,105,120,0,18,120,0,59,122,0,0,18,121,0,59,122,0,0,18,
+97,0,0,0,0,0,0,0,1,0,12,0,109,105,120,0,1,0,0,12,120,0,0,1,
+0,0,12,121,0,0,1,0,0,9,97,0,0,0,1,8,58,118,101,99,52,0,58,109,
+105,120,0,18,120,0,59,120,0,0,18,121,0,59,120,0,0,18,97,0,0,0,0,58,
+109,105,120,0,18,120,0,59,121,0,0,18,121,0,59,121,0,0,18,97,0,0,0,0,
+58,109,105,120,0,18,120,0,59,122,0,0,18,121,0,59,122,0,0,18,97,0,0,0,
+0,58,109,105,120,0,18,120,0,59,119,0,0,18,121,0,59,119,0,0,18,97,0,0,
+0,0,0,0,0,1,0,10,0,109,105,120,0,1,0,0,10,120,0,0,1,0,0,10,
+121,0,0,1,0,0,10,97,0,0,0,1,8,58,118,101,99,50,0,58,109,105,120,0,
+18,120,0,59,120,0,0,18,121,0,59,120,0,0,18,97,0,59,120,0,0,0,0,58,
+109,105,120,0,18,120,0,59,121,0,0,18,121,0,59,121,0,0,18,97,0,59,121,0,
+0,0,0,0,0,0,1,0,11,0,109,105,120,0,1,0,0,11,120,0,0,1,0,0,
+11,121,0,0,1,0,0,11,97,0,0,0,1,8,58,118,101,99,51,0,58,109,105,120,
+0,18,120,0,59,120,0,0,18,121,0,59,120,0,0,18,97,0,59,120,0,0,0,0,
+58,109,105,120,0,18,120,0,59,121,0,0,18,121,0,59,121,0,0,18,97,0,59,121,
+0,0,0,0,58,109,105,120,0,18,120,0,59,122,0,0,18,121,0,59,122,0,0,18,
+97,0,59,122,0,0,0,0,0,0,0,1,0,12,0,109,105,120,0,1,0,0,12,120,
+0,0,1,0,0,12,121,0,0,1,0,0,12,97,0,0,0,1,8,58,118,101,99,52,
+0,58,109,105,120,0,18,120,0,59,120,0,0,18,121,0,59,120,0,0,18,97,0,59,
+120,0,0,0,0,58,109,105,120,0,18,120,0,59,121,0,0,18,121,0,59,121,0,0,
+18,97,0,59,121,0,0,0,0,58,109,105,120,0,18,120,0,59,122,0,0,18,121,0,
+59,122,0,0,18,97,0,59,122,0,0,0,0,58,109,105,120,0,18,120,0,59,119,0,
+0,18,121,0,59,119,0,0,18,97,0,59,119,0,0,0,0,0,0,0,1,0,9,0,
+115,116,101,112,0,1,0,0,9,101,100,103,101,0,0,1,0,0,9,120,0,0,0,1,
+8,18,120,0,18,101,100,103,101,0,40,17,48,0,48,0,0,17,49,0,48,0,0,31,
+0,0,1,0,10,0,115,116,101,112,0,1,0,0,9,101,100,103,101,0,0,1,0,0,
+10,120,0,0,0,1,8,58,118,101,99,50,0,58,115,116,101,112,0,18,101,100,103,101,
+0,0,18,120,0,59,120,0,0,0,0,58,115,116,101,112,0,18,101,100,103,101,0,0,
+18,120,0,59,121,0,0,0,0,0,0,0,1,0,11,0,115,116,101,112,0,1,0,0,
+9,101,100,103,101,0,0,1,0,0,11,120,0,0,0,1,8,58,118,101,99,51,0,58,
+115,116,101,112,0,18,101,100,103,101,0,0,18,120,0,59,120,0,0,0,0,58,115,116,
+101,112,0,18,101,100,103,101,0,0,18,120,0,59,121,0,0,0,0,58,115,116,101,112,
+0,18,101,100,103,101,0,0,18,120,0,59,122,0,0,0,0,0,0,0,1,0,12,0,
+115,116,101,112,0,1,0,0,9,101,100,103,101,0,0,1,0,0,12,120,0,0,0,1,
+8,58,118,101,99,52,0,58,115,116,101,112,0,18,101,100,103,101,0,0,18,120,0,59,
+120,0,0,0,0,58,115,116,101,112,0,18,101,100,103,101,0,0,18,120,0,59,121,0,
+0,0,0,58,115,116,101,112,0,18,101,100,103,101,0,0,18,120,0,59,122,0,0,0,
+0,58,115,116,101,112,0,18,101,100,103,101,0,0,18,120,0,59,119,0,0,0,0,0,
+0,0,1,0,10,0,115,116,101,112,0,1,0,0,10,101,100,103,101,0,0,1,0,0,
+10,120,0,0,0,1,8,58,118,101,99,50,0,58,115,116,101,112,0,18,101,100,103,101,
+0,59,120,0,0,18,120,0,59,120,0,0,0,0,58,115,116,101,112,0,18,101,100,103,
+101,0,59,121,0,0,18,120,0,59,121,0,0,0,0,0,0,0,1,0,11,0,115,116,
+101,112,0,1,0,0,11,101,100,103,101,0,0,1,0,0,11,120,0,0,0,1,8,58,
+118,101,99,51,0,58,115,116,101,112,0,18,101,100,103,101,0,59,120,0,0,18,120,0,
+59,120,0,0,0,0,58,115,116,101,112,0,18,101,100,103,101,0,59,121,0,0,18,120,
+0,59,121,0,0,0,0,58,115,116,101,112,0,18,101,100,103,101,0,59,122,0,0,18,
+120,0,59,122,0,0,0,0,0,0,0,1,0,12,0,115,116,101,112,0,1,0,0,12,
+101,100,103,101,0,0,1,0,0,12,120,0,0,0,1,8,58,118,101,99,52,0,58,115,
+116,101,112,0,18,101,100,103,101,0,59,120,0,0,18,120,0,59,120,0,0,0,0,58,
+115,116,101,112,0,18,101,100,103,101,0,59,121,0,0,18,120,0,59,121,0,0,0,0,
+58,115,116,101,112,0,18,101,100,103,101,0,59,122,0,0,18,120,0,59,122,0,0,0,
+0,58,115,116,101,112,0,18,101,100,103,101,0,59,119,0,0,18,120,0,59,119,0,0,
+0,0,0,0,0,1,0,9,0,115,109,111,111,116,104,115,116,101,112,0,1,0,0,9,
+101,100,103,101,48,0,0,1,0,0,9,101,100,103,101,49,0,0,1,0,0,9,120,0,
+0,0,1,3,2,1,9,1,116,0,2,58,99,108,97,109,112,0,18,120,0,18,101,100,
+103,101,48,0,47,18,101,100,103,101,49,0,18,101,100,103,101,48,0,47,49,0,17,48,
+0,48,0,0,0,17,49,0,48,0,0,0,0,0,0,8,18,116,0,18,116,0,48,17,
+51,0,48,0,0,17,50,0,48,0,0,18,116,0,48,47,48,0,0,1,0,10,0,115,
+109,111,111,116,104,115,116,101,112,0,1,0,0,9,101,100,103,101,48,0,0,1,0,0,
+9,101,100,103,101,49,0,0,1,0,0,10,120,0,0,0,1,8,58,118,101,99,50,0,
+58,115,109,111,111,116,104,115,116,101,112,0,18,101,100,103,101,48,0,0,18,101,100,103,
+101,49,0,0,18,120,0,59,120,0,0,0,0,58,115,109,111,111,116,104,115,116,101,112,
+0,18,101,100,103,101,48,0,0,18,101,100,103,101,49,0,0,18,120,0,59,121,0,0,
+0,0,0,0,0,1,0,11,0,115,109,111,111,116,104,115,116,101,112,0,1,0,0,9,
+101,100,103,101,48,0,0,1,0,0,9,101,100,103,101,49,0,0,1,0,0,11,120,0,
+0,0,1,8,58,118,101,99,51,0,58,115,109,111,111,116,104,115,116,101,112,0,18,101,
+100,103,101,48,0,0,18,101,100,103,101,49,0,0,18,120,0,59,120,0,0,0,0,58,
+115,109,111,111,116,104,115,116,101,112,0,18,101,100,103,101,48,0,0,18,101,100,103,101,
+49,0,0,18,120,0,59,121,0,0,0,0,58,115,109,111,111,116,104,115,116,101,112,0,
+18,101,100,103,101,48,0,0,18,101,100,103,101,49,0,0,18,120,0,59,122,0,0,0,
+0,0,0,0,1,0,12,0,115,109,111,111,116,104,115,116,101,112,0,1,0,0,9,101,
+100,103,101,48,0,0,1,0,0,9,101,100,103,101,49,0,0,1,0,0,12,120,0,0,
+0,1,8,58,118,101,99,52,0,58,115,109,111,111,116,104,115,116,101,112,0,18,101,100,
+103,101,48,0,0,18,101,100,103,101,49,0,0,18,120,0,59,120,0,0,0,0,58,115,
+109,111,111,116,104,115,116,101,112,0,18,101,100,103,101,48,0,0,18,101,100,103,101,49,
+0,0,18,120,0,59,121,0,0,0,0,58,115,109,111,111,116,104,115,116,101,112,0,18,
+101,100,103,101,48,0,0,18,101,100,103,101,49,0,0,18,120,0,59,122,0,0,0,0,
+58,115,109,111,111,116,104,115,116,101,112,0,18,101,100,103,101,48,0,0,18,101,100,103,
+101,49,0,0,18,120,0,59,119,0,0,0,0,0,0,0,1,0,10,0,115,109,111,111,
+116,104,115,116,101,112,0,1,0,0,10,101,100,103,101,48,0,0,1,0,0,10,101,100,
+103,101,49,0,0,1,0,0,10,120,0,0,0,1,8,58,118,101,99,50,0,58,115,109,
+111,111,116,104,115,116,101,112,0,18,101,100,103,101,48,0,59,120,0,0,18,101,100,103,
+101,49,0,59,120,0,0,18,120,0,59,120,0,0,0,0,58,115,109,111,111,116,104,115,
+116,101,112,0,18,101,100,103,101,48,0,59,121,0,0,18,101,100,103,101,49,0,59,121,
+0,0,18,120,0,59,121,0,0,0,0,0,0,0,1,0,11,0,115,109,111,111,116,104,
+115,116,101,112,0,1,0,0,11,101,100,103,101,48,0,0,1,0,0,11,101,100,103,101,
+49,0,0,1,0,0,11,120,0,0,0,1,8,58,118,101,99,51,0,58,115,109,111,111,
+116,104,115,116,101,112,0,18,101,100,103,101,48,0,59,120,0,0,18,101,100,103,101,49,
+0,59,120,0,0,18,120,0,59,120,0,0,0,0,58,115,109,111,111,116,104,115,116,101,
+112,0,18,101,100,103,101,48,0,59,121,0,0,18,101,100,103,101,49,0,59,121,0,0,
+18,120,0,59,121,0,0,0,0,58,115,109,111,111,116,104,115,116,101,112,0,18,101,100,
+103,101,48,0,59,122,0,0,18,101,100,103,101,49,0,59,122,0,0,18,120,0,59,122,
+0,0,0,0,0,0,0,1,0,12,0,115,109,111,111,116,104,115,116,101,112,0,1,0,
+0,12,101,100,103,101,48,0,0,1,0,0,12,101,100,103,101,49,0,0,1,0,0,12,
+120,0,0,0,1,8,58,118,101,99,52,0,58,115,109,111,111,116,104,115,116,101,112,0,
+18,101,100,103,101,48,0,59,120,0,0,18,101,100,103,101,49,0,59,120,0,0,18,120,
+0,59,120,0,0,0,0,58,115,109,111,111,116,104,115,116,101,112,0,18,101,100,103,101,
+48,0,59,121,0,0,18,101,100,103,101,49,0,59,121,0,0,18,120,0,59,121,0,0,
+0,0,58,115,109,111,111,116,104,115,116,101,112,0,18,101,100,103,101,48,0,59,122,0,
+0,18,101,100,103,101,49,0,59,122,0,0,18,120,0,59,122,0,0,0,0,58,115,109,
+111,111,116,104,115,116,101,112,0,18,101,100,103,101,48,0,59,119,0,0,18,101,100,103,
+101,49,0,59,119,0,0,18,120,0,59,119,0,0,0,0,0,0,0,1,0,9,0,100,
+111,116,0,1,0,0,9,120,0,0,1,0,0,9,121,0,0,0,1,8,18,120,0,18,
+121,0,48,0,0,1,0,9,0,100,111,116,0,1,0,0,10,120,0,0,1,0,0,10,
+121,0,0,0,1,8,58,100,111,116,0,18,120,0,59,120,0,0,18,121,0,59,120,0,
+0,0,58,100,111,116,0,18,120,0,59,121,0,0,18,121,0,59,121,0,0,0,46,0,
+0,1,0,9,0,100,111,116,0,1,0,0,11,120,0,0,1,0,0,11,121,0,0,0,
+1,8,58,100,111,116,0,18,120,0,59,120,0,0,18,121,0,59,120,0,0,0,58,100,
+111,116,0,18,120,0,59,121,0,0,18,121,0,59,121,0,0,0,46,58,100,111,116,0,
+18,120,0,59,122,0,0,18,121,0,59,122,0,0,0,46,0,0,1,0,9,0,100,111,
+116,0,1,0,0,12,120,0,0,1,0,0,12,121,0,0,0,1,8,58,100,111,116,0,
+18,120,0,59,120,0,0,18,121,0,59,120,0,0,0,58,100,111,116,0,18,120,0,59,
+121,0,0,18,121,0,59,121,0,0,0,46,58,100,111,116,0,18,120,0,59,122,0,0,
+18,121,0,59,122,0,0,0,46,58,100,111,116,0,18,120,0,59,119,0,0,18,121,0,
+59,119,0,0,0,46,0,0,1,0,9,0,108,101,110,103,116,104,0,1,0,0,9,120,
+0,0,0,1,8,58,115,113,114,116,0,58,100,111,116,0,18,120,0,0,18,120,0,0,
+0,0,0,0,0,1,0,9,0,108,101,110,103,116,104,0,1,0,0,10,120,0,0,0,
+1,8,58,115,113,114,116,0,58,100,111,116,0,18,120,0,0,18,120,0,0,0,0,0,
+0,0,1,0,9,0,108,101,110,103,116,104,0,1,0,0,11,120,0,0,0,1,8,58,
+115,113,114,116,0,58,100,111,116,0,18,120,0,0,18,120,0,0,0,0,0,0,0,1,
+0,9,0,108,101,110,103,116,104,0,1,0,0,12,120,0,0,0,1,8,58,115,113,114,
+116,0,58,100,111,116,0,18,120,0,0,18,120,0,0,0,0,0,0,0,1,0,9,0,
+100,105,115,116,97,110,99,101,0,1,0,0,9,120,0,0,1,0,0,9,121,0,0,0,
+1,8,58,108,101,110,103,116,104,0,18,120,0,18,121,0,47,0,0,0,0,1,0,9,
+0,100,105,115,116,97,110,99,101,0,1,0,0,10,120,0,0,1,0,0,10,121,0,0,
+0,1,8,58,108,101,110,103,116,104,0,18,120,0,18,121,0,47,0,0,0,0,1,0,
+9,0,100,105,115,116,97,110,99,101,0,1,0,0,11,120,0,0,1,0,0,11,121,0,
+0,0,1,8,58,108,101,110,103,116,104,0,18,120,0,18,121,0,47,0,0,0,0,1,
+0,9,0,100,105,115,116,97,110,99,101,0,1,0,0,12,120,0,0,1,0,0,12,121,
+0,0,0,1,8,58,108,101,110,103,116,104,0,18,120,0,18,121,0,47,0,0,0,0,
+1,0,11,0,99,114,111,115,115,0,1,0,0,11,120,0,0,1,0,0,11,121,0,0,
+0,1,8,58,118,101,99,51,0,18,120,0,59,121,0,18,121,0,59,122,0,48,18,121,
+0,59,121,0,18,120,0,59,122,0,48,47,0,18,120,0,59,122,0,18,121,0,59,120,
+0,48,18,121,0,59,122,0,18,120,0,59,120,0,48,47,0,18,120,0,59,120,0,18,
+121,0,59,121,0,48,18,121,0,59,120,0,18,120,0,59,121,0,48,47,0,0,0,0,
+1,0,9,0,110,111,114,109,97,108,105,122,101,0,1,0,0,9,120,0,0,0,1,8,
+17,49,0,48,0,0,0,0,1,0,10,0,110,111,114,109,97,108,105,122,101,0,1,0,
+0,10,120,0,0,0,1,8,18,120,0,58,108,101,110,103,116,104,0,18,120,0,0,0,
+49,0,0,1,0,11,0,110,111,114,109,97,108,105,122,101,0,1,0,0,11,120,0,0,
+0,1,8,18,120,0,58,108,101,110,103,116,104,0,18,120,0,0,0,49,0,0,1,0,
+12,0,110,111,114,109,97,108,105,122,101,0,1,0,0,12,120,0,0,0,1,8,18,120,
+0,58,108,101,110,103,116,104,0,18,120,0,0,0,49,0,0,1,0,9,0,102,97,99,
+101,102,111,114,119,97,114,100,0,1,0,0,9,78,0,0,1,0,0,9,73,0,0,1,
+0,0,9,78,114,101,102,0,0,0,1,8,58,100,111,116,0,18,78,114,101,102,0,0,
+18,73,0,0,0,17,48,0,48,0,0,40,18,78,0,18,78,0,54,31,0,0,1,0,
+10,0,102,97,99,101,102,111,114,119,97,114,100,0,1,0,0,10,78,0,0,1,0,0,
+10,73,0,0,1,0,0,10,78,114,101,102,0,0,0,1,8,58,100,111,116,0,18,78,
+114,101,102,0,0,18,73,0,0,0,17,48,0,48,0,0,40,18,78,0,18,78,0,54,
+31,0,0,1,0,11,0,102,97,99,101,102,111,114,119,97,114,100,0,1,0,0,11,78,
+0,0,1,0,0,11,73,0,0,1,0,0,11,78,114,101,102,0,0,0,1,8,58,100,
+111,116,0,18,78,114,101,102,0,0,18,73,0,0,0,17,48,0,48,0,0,40,18,78,
+0,18,78,0,54,31,0,0,1,0,12,0,102,97,99,101,102,111,114,119,97,114,100,0,
+1,0,0,12,78,0,0,1,0,0,12,73,0,0,1,0,0,12,78,114,101,102,0,0,
+0,1,8,58,100,111,116,0,18,78,114,101,102,0,0,18,73,0,0,0,17,48,0,48,
+0,0,40,18,78,0,18,78,0,54,31,0,0,1,0,9,0,114,101,102,108,101,99,116,
+0,1,0,0,9,73,0,0,1,0,0,9,78,0,0,0,1,8,18,73,0,17,50,0,
+48,0,0,58,100,111,116,0,18,78,0,0,18,73,0,0,0,48,18,78,0,48,47,0,
+0,1,0,10,0,114,101,102,108,101,99,116,0,1,0,0,10,73,0,0,1,0,0,10,
+78,0,0,0,1,8,18,73,0,17,50,0,48,0,0,58,100,111,116,0,18,78,0,0,
+18,73,0,0,0,48,18,78,0,48,47,0,0,1,0,11,0,114,101,102,108,101,99,116,
+0,1,0,0,11,73,0,0,1,0,0,11,78,0,0,0,1,8,18,73,0,17,50,0,
+48,0,0,58,100,111,116,0,18,78,0,0,18,73,0,0,0,48,18,78,0,48,47,0,
+0,1,0,12,0,114,101,102,108,101,99,116,0,1,0,0,12,73,0,0,1,0,0,12,
+78,0,0,0,1,8,18,73,0,17,50,0,48,0,0,58,100,111,116,0,18,78,0,0,
+18,73,0,0,0,48,18,78,0,48,47,0,0,1,0,9,0,114,101,102,114,97,99,116,
+0,1,0,0,9,73,0,0,1,0,0,9,78,0,0,1,0,0,9,101,116,97,0,0,
+0,1,3,2,1,9,1,107,0,2,17,49,0,48,0,0,18,101,116,97,0,18,101,116,
+97,0,48,17,49,0,48,0,0,58,100,111,116,0,18,78,0,0,18,73,0,0,0,58,
+100,111,116,0,18,78,0,0,18,73,0,0,0,48,47,48,47,0,0,10,18,107,0,17,
+48,0,48,0,0,40,0,8,17,48,0,48,0,0,0,9,14,0,8,18,101,116,97,0,
+18,73,0,48,18,101,116,97,0,58,100,111,116,0,18,78,0,0,18,73,0,0,0,48,
+58,115,113,114,116,0,18,107,0,0,0,46,18,78,0,48,47,0,0,1,0,10,0,114,
+101,102,114,97,99,116,0,1,0,0,10,73,0,0,1,0,0,10,78,0,0,1,0,0,
+9,101,116,97,0,0,0,1,3,2,1,9,1,107,0,2,17,49,0,48,0,0,18,101,
+116,97,0,18,101,116,97,0,48,17,49,0,48,0,0,58,100,111,116,0,18,78,0,0,
+18,73,0,0,0,58,100,111,116,0,18,78,0,0,18,73,0,0,0,48,47,48,47,0,
+0,10,18,107,0,17,48,0,48,0,0,40,0,8,58,118,101,99,50,0,17,48,0,48,
+0,0,0,0,0,9,14,0,8,18,101,116,97,0,18,73,0,48,18,101,116,97,0,58,
+100,111,116,0,18,78,0,0,18,73,0,0,0,48,58,115,113,114,116,0,18,107,0,0,
+0,46,18,78,0,48,47,0,0,1,0,11,0,114,101,102,114,97,99,116,0,1,0,0,
+11,73,0,0,1,0,0,11,78,0,0,1,0,0,9,101,116,97,0,0,0,1,3,2,
+1,9,1,107,0,2,17,49,0,48,0,0,18,101,116,97,0,18,101,116,97,0,48,17,
+49,0,48,0,0,58,100,111,116,0,18,78,0,0,18,73,0,0,0,58,100,111,116,0,
+18,78,0,0,18,73,0,0,0,48,47,48,47,0,0,10,18,107,0,17,48,0,48,0,
+0,40,0,8,58,118,101,99,51,0,17,48,0,48,0,0,0,0,0,9,14,0,8,18,
+101,116,97,0,18,73,0,48,18,101,116,97,0,58,100,111,116,0,18,78,0,0,18,73,
+0,0,0,48,58,115,113,114,116,0,18,107,0,0,0,46,18,78,0,48,47,0,0,1,
+0,12,0,114,101,102,114,97,99,116,0,1,0,0,12,73,0,0,1,0,0,12,78,0,
+0,1,0,0,9,101,116,97,0,0,0,1,3,2,1,9,1,107,0,2,17,49,0,48,
+0,0,18,101,116,97,0,18,101,116,97,0,48,17,49,0,48,0,0,58,100,111,116,0,
+18,78,0,0,18,73,0,0,0,58,100,111,116,0,18,78,0,0,18,73,0,0,0,48,
+47,48,47,0,0,10,18,107,0,17,48,0,48,0,0,40,0,8,58,118,101,99,52,0,
+17,48,0,48,0,0,0,0,0,9,14,0,8,18,101,116,97,0,18,73,0,48,18,101,
+116,97,0,58,100,111,116,0,18,78,0,0,18,73,0,0,0,48,58,115,113,114,116,0,
+18,107,0,0,0,46,18,78,0,48,47,0,0,1,0,13,0,109,97,116,114,105,120,67,
+111,109,112,77,117,108,116,0,1,0,0,13,120,0,0,1,0,0,13,121,0,0,0,1,
+8,58,109,97,116,50,0,18,120,0,16,8,48,0,57,59,120,0,18,121,0,16,8,48,
+0,57,59,120,0,48,0,18,120,0,16,8,48,0,57,59,121,0,18,121,0,16,8,48,
+0,57,59,121,0,48,0,18,120,0,16,10,49,0,57,59,120,0,18,121,0,16,10,49,
+0,57,59,120,0,48,0,18,120,0,16,10,49,0,57,59,121,0,18,121,0,16,10,49,
+0,57,59,121,0,48,0,0,0,0,1,0,14,0,109,97,116,114,105,120,67,111,109,112,
+77,117,108,116,0,1,0,0,14,120,0,0,1,0,0,14,121,0,0,0,1,8,58,109,
+97,116,52,0,18,120,0,16,8,48,0,57,59,120,0,18,121,0,16,8,48,0,57,59,
+120,0,48,0,18,120,0,16,8,48,0,57,59,121,0,18,121,0,16,8,48,0,57,59,
+121,0,48,0,18,120,0,16,8,48,0,57,59,122,0,18,121,0,16,8,48,0,57,59,
+122,0,48,0,18,120,0,16,10,49,0,57,59,120,0,18,121,0,16,10,49,0,57,59,
+120,0,48,0,18,120,0,16,10,49,0,57,59,121,0,18,121,0,16,10,49,0,57,59,
+121,0,48,0,18,120,0,16,10,49,0,57,59,122,0,18,121,0,16,10,49,0,57,59,
+122,0,48,0,18,120,0,16,10,50,0,57,59,120,0,18,121,0,16,10,50,0,57,59,
+120,0,48,0,18,120,0,16,10,50,0,57,59,121,0,18,121,0,16,10,50,0,57,59,
+121,0,48,0,18,120,0,16,10,50,0,57,59,122,0,18,121,0,16,10,50,0,57,59,
+122,0,48,0,0,0,0,1,0,15,0,109,97,116,114,105,120,67,111,109,112,77,117,108,
+116,0,1,0,0,15,120,0,0,1,0,0,15,121,0,0,0,1,8,58,109,97,116,52,
+0,18,120,0,16,8,48,0,57,59,120,0,18,121,0,16,8,48,0,57,59,120,0,48,
+0,18,120,0,16,8,48,0,57,59,121,0,18,121,0,16,8,48,0,57,59,121,0,48,
+0,18,120,0,16,8,48,0,57,59,122,0,18,121,0,16,8,48,0,57,59,122,0,48,
+18,120,0,16,8,48,0,57,59,119,0,18,121,0,16,8,48,0,57,59,119,0,48,46,
+0,18,120,0,16,10,49,0,57,59,120,0,18,121,0,16,10,49,0,57,59,120,0,48,
+0,18,120,0,16,10,49,0,57,59,121,0,18,121,0,16,10,49,0,57,59,121,0,48,
+0,18,120,0,16,10,49,0,57,59,122,0,18,121,0,16,10,49,0,57,59,122,0,48,
+18,120,0,16,10,49,0,57,59,119,0,18,121,0,16,10,49,0,57,59,119,0,48,46,
+0,18,120,0,16,10,50,0,57,59,120,0,18,121,0,16,10,50,0,57,59,120,0,48,
+0,18,120,0,16,10,50,0,57,59,121,0,18,121,0,16,10,50,0,57,59,121,0,48,
+0,18,120,0,16,10,50,0,57,59,122,0,18,121,0,16,10,50,0,57,59,122,0,48,
+18,120,0,16,10,50,0,57,59,119,0,18,121,0,16,10,50,0,57,59,119,0,48,46,
+0,18,120,0,16,10,51,0,57,59,120,0,18,121,0,16,10,51,0,57,59,120,0,48,
+0,18,120,0,16,10,51,0,57,59,121,0,18,121,0,16,10,51,0,57,59,121,0,48,
+0,18,120,0,16,10,51,0,57,59,122,0,18,121,0,16,10,51,0,57,59,122,0,48,
+18,120,0,16,10,51,0,57,59,119,0,18,121,0,16,10,51,0,57,59,119,0,48,46,
+0,0,0,0,1,0,2,0,108,101,115,115,84,104,97,110,0,1,0,0,10,120,0,0,
+1,0,0,10,121,0,0,0,1,8,58,98,118,101,99,50,0,18,120,0,59,120,0,18,
+121,0,59,120,0,40,0,18,120,0,59,121,0,18,121,0,59,121,0,40,0,0,0,0,
+1,0,3,0,108,101,115,115,84,104,97,110,0,1,0,0,11,120,0,0,1,0,0,11,
+121,0,0,0,1,8,58,98,118,101,99,51,0,18,120,0,59,120,0,18,121,0,59,120,
+0,40,0,18,120,0,59,121,0,18,121,0,59,121,0,40,0,18,120,0,59,122,0,18,
+121,0,59,122,0,40,0,0,0,0,1,0,4,0,108,101,115,115,84,104,97,110,0,1,
+0,0,12,120,0,0,1,0,0,12,121,0,0,0,1,8,58,98,118,101,99,52,0,18,
+120,0,59,120,0,18,121,0,59,120,0,40,0,18,120,0,59,121,0,18,121,0,59,121,
+0,40,0,18,120,0,59,122,0,18,121,0,59,122,0,40,0,18,120,0,59,119,0,18,
+121,0,59,119,0,40,0,0,0,0,1,0,2,0,108,101,115,115,84,104,97,110,0,1,
+0,0,6,120,0,0,1,0,0,6,121,0,0,0,1,8,58,98,118,101,99,50,0,18,
+120,0,59,120,0,18,121,0,59,120,0,40,0,18,120,0,59,121,0,18,121,0,59,121,
+0,40,0,0,0,0,1,0,3,0,108,101,115,115,84,104,97,110,0,1,0,0,7,120,
+0,0,1,0,0,7,121,0,0,0,1,8,58,98,118,101,99,51,0,18,120,0,59,120,
+0,18,121,0,59,120,0,40,0,18,120,0,59,121,0,18,121,0,59,121,0,40,0,18,
+120,0,59,122,0,18,121,0,59,122,0,40,0,0,0,0,1,0,4,0,108,101,115,115,
+84,104,97,110,0,1,0,0,8,120,0,0,1,0,0,8,121,0,0,0,1,8,58,98,
+118,101,99,52,0,18,120,0,59,120,0,18,121,0,59,120,0,40,0,18,120,0,59,121,
+0,18,121,0,59,121,0,40,0,18,120,0,59,122,0,18,121,0,59,122,0,40,0,18,
+120,0,59,119,0,18,121,0,59,119,0,40,0,0,0,0,1,0,2,0,108,101,115,115,
+84,104,97,110,69,113,117,97,108,0,1,0,0,10,120,0,0,1,0,0,10,121,0,0,
+0,1,8,58,98,118,101,99,50,0,18,120,0,59,120,0,18,121,0,59,120,0,42,0,
+18,120,0,59,121,0,18,121,0,59,121,0,42,0,0,0,0,1,0,3,0,108,101,115,
+115,84,104,97,110,69,113,117,97,108,0,1,0,0,11,120,0,0,1,0,0,11,121,0,
+0,0,1,8,58,98,118,101,99,51,0,18,120,0,59,120,0,18,121,0,59,120,0,42,
+0,18,120,0,59,121,0,18,121,0,59,121,0,42,0,18,120,0,59,122,0,18,121,0,
+59,122,0,42,0,0,0,0,1,0,4,0,108,101,115,115,84,104,97,110,69,113,117,97,
+108,0,1,0,0,12,120,0,0,1,0,0,12,121,0,0,0,1,8,58,98,118,101,99,
+52,0,18,120,0,59,120,0,18,121,0,59,120,0,42,0,18,120,0,59,121,0,18,121,
+0,59,121,0,42,0,18,120,0,59,122,0,18,121,0,59,122,0,42,0,18,120,0,59,
+119,0,18,121,0,59,119,0,42,0,0,0,0,1,0,2,0,108,101,115,115,84,104,97,
+110,69,113,117,97,108,0,1,0,0,6,120,0,0,1,0,0,6,121,0,0,0,1,8,
+58,98,118,101,99,50,0,18,120,0,59,120,0,18,121,0,59,120,0,42,0,18,120,0,
+59,121,0,18,121,0,59,121,0,42,0,0,0,0,1,0,3,0,108,101,115,115,84,104,
+97,110,69,113,117,97,108,0,1,0,0,7,120,0,0,1,0,0,7,121,0,0,0,1,
+8,58,98,118,101,99,51,0,18,120,0,59,120,0,18,121,0,59,120,0,42,0,18,120,
+0,59,121,0,18,121,0,59,121,0,42,0,18,120,0,59,122,0,18,121,0,59,122,0,
+42,0,0,0,0,1,0,4,0,108,101,115,115,84,104,97,110,69,113,117,97,108,0,1,
+0,0,8,120,0,0,1,0,0,8,121,0,0,0,1,8,58,98,118,101,99,52,0,18,
+120,0,59,120,0,18,121,0,59,120,0,42,0,18,120,0,59,121,0,18,121,0,59,121,
+0,42,0,18,120,0,59,122,0,18,121,0,59,122,0,42,0,18,120,0,59,119,0,18,
+121,0,59,119,0,42,0,0,0,0,1,0,2,0,103,114,101,97,116,101,114,84,104,97,
+110,0,1,0,0,10,120,0,0,1,0,0,10,121,0,0,0,1,8,58,98,118,101,99,
+50,0,18,120,0,59,120,0,18,121,0,59,120,0,41,0,18,120,0,59,121,0,18,121,
+0,59,121,0,41,0,0,0,0,1,0,3,0,103,114,101,97,116,101,114,84,104,97,110,
+0,1,0,0,11,120,0,0,1,0,0,11,121,0,0,0,1,8,58,98,118,101,99,51,
+0,18,120,0,59,120,0,18,121,0,59,120,0,41,0,18,120,0,59,121,0,18,121,0,
+59,121,0,41,0,18,120,0,59,122,0,18,121,0,59,122,0,41,0,0,0,0,1,0,
+4,0,103,114,101,97,116,101,114,84,104,97,110,0,1,0,0,12,120,0,0,1,0,0,
+12,121,0,0,0,1,8,58,98,118,101,99,52,0,18,120,0,59,120,0,18,121,0,59,
+120,0,41,0,18,120,0,59,121,0,18,121,0,59,121,0,41,0,18,120,0,59,122,0,
+18,121,0,59,122,0,41,0,18,120,0,59,119,0,18,121,0,59,119,0,41,0,0,0,
+0,1,0,2,0,103,114,101,97,116,101,114,84,104,97,110,0,1,0,0,6,120,0,0,
+1,0,0,6,121,0,0,0,1,8,58,98,118,101,99,50,0,18,120,0,59,120,0,18,
+121,0,59,120,0,41,0,18,120,0,59,121,0,18,121,0,59,121,0,41,0,0,0,0,
+1,0,3,0,103,114,101,97,116,101,114,84,104,97,110,0,1,0,0,7,120,0,0,1,
+0,0,7,121,0,0,0,1,8,58,98,118,101,99,51,0,18,120,0,59,120,0,18,121,
+0,59,120,0,41,0,18,120,0,59,121,0,18,121,0,59,121,0,41,0,18,120,0,59,
+122,0,18,121,0,59,122,0,41,0,0,0,0,1,0,4,0,103,114,101,97,116,101,114,
+84,104,97,110,0,1,0,0,8,120,0,0,1,0,0,8,121,0,0,0,1,8,58,98,
+118,101,99,52,0,18,120,0,59,120,0,18,121,0,59,120,0,41,0,18,120,0,59,121,
+0,18,121,0,59,121,0,41,0,18,120,0,59,122,0,18,121,0,59,122,0,41,0,18,
+120,0,59,119,0,18,121,0,59,119,0,41,0,0,0,0,1,0,2,0,103,114,101,97,
+116,101,114,84,104,97,110,69,113,117,97,108,0,1,0,0,10,120,0,0,1,0,0,10,
+121,0,0,0,1,8,58,98,118,101,99,50,0,18,120,0,59,120,0,18,121,0,59,120,
+0,43,0,18,120,0,59,121,0,18,121,0,59,121,0,43,0,0,0,0,1,0,3,0,
+103,114,101,97,116,101,114,84,104,97,110,69,113,117,97,108,0,1,0,0,11,120,0,0,
+1,0,0,11,121,0,0,0,1,8,58,98,118,101,99,51,0,18,120,0,59,120,0,18,
+121,0,59,120,0,43,0,18,120,0,59,121,0,18,121,0,59,121,0,43,0,18,120,0,
+59,122,0,18,121,0,59,122,0,43,0,0,0,0,1,0,4,0,103,114,101,97,116,101,
+114,84,104,97,110,69,113,117,97,108,0,1,0,0,12,120,0,0,1,0,0,12,121,0,
+0,0,1,8,58,98,118,101,99,52,0,18,120,0,59,120,0,18,121,0,59,120,0,43,
+0,18,120,0,59,121,0,18,121,0,59,121,0,43,0,18,120,0,59,122,0,18,121,0,
+59,122,0,43,0,18,120,0,59,119,0,18,121,0,59,119,0,43,0,0,0,0,1,0,
+2,0,103,114,101,97,116,101,114,84,104,97,110,69,113,117,97,108,0,1,0,0,6,120,
+0,0,1,0,0,6,121,0,0,0,1,8,58,98,118,101,99,50,0,18,120,0,59,120,
+0,18,121,0,59,120,0,43,0,18,120,0,59,121,0,18,121,0,59,121,0,43,0,0,
+0,0,1,0,3,0,103,114,101,97,116,101,114,84,104,97,110,69,113,117,97,108,0,1,
+0,0,7,120,0,0,1,0,0,7,121,0,0,0,1,8,58,98,118,101,99,51,0,18,
+120,0,59,120,0,18,121,0,59,120,0,43,0,18,120,0,59,121,0,18,121,0,59,121,
+0,43,0,18,120,0,59,122,0,18,121,0,59,122,0,43,0,0,0,0,1,0,4,0,
+103,114,101,97,116,101,114,84,104,97,110,69,113,117,97,108,0,1,0,0,8,120,0,0,
+1,0,0,8,121,0,0,0,1,8,58,98,118,101,99,52,0,18,120,0,59,120,0,18,
+121,0,59,120,0,43,0,18,120,0,59,121,0,18,121,0,59,121,0,43,0,18,120,0,
+59,122,0,18,121,0,59,122,0,43,0,18,120,0,59,119,0,18,121,0,59,119,0,43,
+0,0,0,0,1,0,2,0,101,113,117,97,108,0,1,0,0,10,120,0,0,1,0,0,
+10,121,0,0,0,1,8,58,98,118,101,99,50,0,18,120,0,59,120,0,18,121,0,59,
+120,0,38,0,18,120,0,59,121,0,18,121,0,59,121,0,38,0,0,0,0,1,0,3,
+0,101,113,117,97,108,0,1,0,0,11,120,0,0,1,0,0,11,121,0,0,0,1,8,
+58,98,118,101,99,51,0,18,120,0,59,120,0,18,121,0,59,120,0,38,0,18,120,0,
+59,121,0,18,121,0,59,121,0,38,0,18,120,0,59,122,0,18,121,0,59,122,0,38,
+0,0,0,0,1,0,4,0,101,113,117,97,108,0,1,0,0,12,120,0,0,1,0,0,
+12,121,0,0,0,1,8,58,98,118,101,99,52,0,18,120,0,59,120,0,18,121,0,59,
+120,0,38,0,18,120,0,59,121,0,18,121,0,59,121,0,38,0,18,120,0,59,122,0,
+18,121,0,59,122,0,38,0,18,120,0,59,119,0,18,121,0,59,119,0,38,0,0,0,
+0,1,0,2,0,101,113,117,97,108,0,1,0,0,6,120,0,0,1,0,0,6,121,0,
+0,0,1,8,58,98,118,101,99,50,0,18,120,0,59,120,0,18,121,0,59,120,0,38,
+0,18,120,0,59,121,0,18,121,0,59,121,0,38,0,0,0,0,1,0,3,0,101,113,
+117,97,108,0,1,0,0,7,120,0,0,1,0,0,7,121,0,0,0,1,8,58,98,118,
+101,99,51,0,18,120,0,59,120,0,18,121,0,59,120,0,38,0,18,120,0,59,121,0,
+18,121,0,59,121,0,38,0,18,120,0,59,122,0,18,121,0,59,122,0,38,0,0,0,
+0,1,0,4,0,101,113,117,97,108,0,1,0,0,8,120,0,0,1,0,0,8,121,0,
+0,0,1,8,58,98,118,101,99,52,0,18,120,0,59,120,0,18,121,0,59,120,0,38,
+0,18,120,0,59,121,0,18,121,0,59,121,0,38,0,18,120,0,59,122,0,18,121,0,
+59,122,0,38,0,18,120,0,59,119,0,18,121,0,59,119,0,38,0,0,0,0,1,0,
+2,0,110,111,116,69,113,117,97,108,0,1,0,0,10,120,0,0,1,0,0,10,121,0,
+0,0,1,8,58,98,118,101,99,50,0,18,120,0,59,120,0,18,121,0,59,120,0,39,
+0,18,120,0,59,121,0,18,121,0,59,121,0,39,0,0,0,0,1,0,3,0,110,111,
+116,69,113,117,97,108,0,1,0,0,11,120,0,0,1,0,0,11,121,0,0,0,1,8,
+58,98,118,101,99,51,0,18,120,0,59,120,0,18,121,0,59,120,0,39,0,18,120,0,
+59,121,0,18,121,0,59,121,0,39,0,18,120,0,59,122,0,18,121,0,59,122,0,39,
+0,0,0,0,1,0,4,0,110,111,116,69,113,117,97,108,0,1,0,0,12,120,0,0,
+1,0,0,12,121,0,0,0,1,8,58,98,118,101,99,52,0,18,120,0,59,120,0,18,
+121,0,59,120,0,39,0,18,120,0,59,121,0,18,121,0,59,121,0,39,0,18,120,0,
+59,122,0,18,121,0,59,122,0,39,0,18,120,0,59,119,0,18,121,0,59,119,0,39,
+0,0,0,0,1,0,2,0,110,111,116,69,113,117,97,108,0,1,0,0,6,120,0,0,
+1,0,0,6,121,0,0,0,1,8,58,98,118,101,99,50,0,18,120,0,59,120,0,18,
+121,0,59,120,0,39,0,18,120,0,59,121,0,18,121,0,59,121,0,39,0,0,0,0,
+1,0,3,0,110,111,116,69,113,117,97,108,0,1,0,0,7,120,0,0,1,0,0,7,
+121,0,0,0,1,8,58,98,118,101,99,51,0,18,120,0,59,120,0,18,121,0,59,120,
+0,39,0,18,120,0,59,121,0,18,121,0,59,121,0,39,0,18,120,0,59,122,0,18,
+121,0,59,122,0,39,0,0,0,0,1,0,4,0,110,111,116,69,113,117,97,108,0,1,
+0,0,8,120,0,0,1,0,0,8,121,0,0,0,1,8,58,98,118,101,99,52,0,18,
+120,0,59,120,0,18,121,0,59,120,0,39,0,18,120,0,59,121,0,18,121,0,59,121,
+0,39,0,18,120,0,59,122,0,18,121,0,59,122,0,39,0,18,120,0,59,119,0,18,
+121,0,59,119,0,39,0,0,0,0,1,0,1,0,97,110,121,0,1,0,0,2,120,0,
+0,0,1,8,18,120,0,59,120,0,18,120,0,59,121,0,32,0,0,1,0,1,0,97,
+110,121,0,1,0,0,3,120,0,0,0,1,8,18,120,0,59,120,0,18,120,0,59,121,
+0,32,18,120,0,59,122,0,32,0,0,1,0,1,0,97,110,121,0,1,0,0,4,120,
+0,0,0,1,8,18,120,0,59,120,0,18,120,0,59,121,0,32,18,120,0,59,122,0,
+32,18,120,0,59,119,0,32,0,0,1,0,1,0,97,108,108,0,1,0,0,2,120,0,
+0,0,1,8,18,120,0,59,120,0,18,120,0,59,121,0,34,0,0,1,0,1,0,97,
+108,108,0,1,0,0,3,120,0,0,0,1,8,18,120,0,59,120,0,18,120,0,59,121,
+0,34,18,120,0,59,122,0,34,0,0,1,0,1,0,97,108,108,0,1,0,0,4,120,
+0,0,0,1,8,18,120,0,59,120,0,18,120,0,59,121,0,34,18,120,0,59,122,0,
+34,18,120,0,59,119,0,34,0,0,1,0,2,0,110,111,116,0,1,0,0,2,120,0,
+0,0,1,8,58,98,118,101,99,50,0,18,120,0,59,120,0,56,0,18,120,0,59,121,
+0,56,0,0,0,0,1,0,3,0,110,111,116,0,1,0,0,3,120,0,0,0,1,8,
+58,98,118,101,99,51,0,18,120,0,59,120,0,56,0,18,120,0,59,121,0,56,0,18,
+120,0,59,122,0,56,0,0,0,0,1,0,4,0,110,111,116,0,1,0,0,4,120,0,
+0,0,1,8,58,98,118,101,99,52,0,18,120,0,59,120,0,56,0,18,120,0,59,121,
+0,56,0,18,120,0,59,122,0,56,0,18,120,0,59,119,0,56,0,0,0,0,1,0,
+12,0,116,101,120,116,117,114,101,49,68,0,1,0,0,16,115,97,109,112,108,101,114,0,
+0,1,0,0,9,99,111,111,114,100,0,0,0,1,8,58,118,101,99,52,0,17,48,0,
+48,0,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,106,
+0,1,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,10,99,111,111,114,100,0,
+0,0,1,8,58,116,101,120,116,117,114,101,49,68,0,18,115,97,109,112,108,101,114,0,
+0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,116,0,49,0,0,
+0,0,1,0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,106,0,1,0,0,16,
+115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,0,1,8,58,
+116,101,120,116,117,114,101,49,68,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,
+114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,0,1,0,12,
+0,116,101,120,116,117,114,101,50,68,0,1,0,0,17,115,97,109,112,108,101,114,0,0,
+1,0,0,10,99,111,111,114,100,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,
+0,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,50,68,80,114,111,106,0,
+1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,
+0,1,8,58,116,101,120,116,117,114,101,50,68,0,18,115,97,109,112,108,101,114,0,0,
+58,118,101,99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,
+112,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,112,0,
+49,0,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,50,68,80,114,111,106,
+0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,
+0,0,1,8,58,116,101,120,116,117,114,101,50,68,0,18,115,97,109,112,108,101,114,0,
+0,58,118,101,99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,
+59,113,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,
+0,49,0,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,51,68,0,1,0,
+0,18,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,0,1,
+8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,12,0,116,101,120,
+116,117,114,101,51,68,80,114,111,106,0,1,0,0,18,115,97,109,112,108,101,114,0,0,
+1,0,0,12,99,111,111,114,100,0,0,0,1,8,58,116,101,120,116,117,114,101,51,68,
+0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,
+59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,
+0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,112,0,18,
+99,111,111,114,100,0,59,113,0,49,0,0,0,0,0,0,1,0,12,0,116,101,120,116,
+117,114,101,67,117,98,101,0,1,0,0,19,115,97,109,112,108,101,114,0,0,1,0,0,
+11,99,111,111,114,100,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,
+0,0,0,1,0,12,0,115,104,97,100,111,119,49,68,0,1,0,0,20,115,97,109,112,
+108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,0,1,8,58,118,101,99,52,
+0,17,48,0,48,0,0,0,0,0,0,1,0,12,0,115,104,97,100,111,119,50,68,0,
+1,0,0,21,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,
+0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,12,0,115,
+104,97,100,111,119,49,68,80,114,111,106,0,1,0,0,20,115,97,109,112,108,101,114,0,
+0,1,0,0,12,99,111,111,114,100,0,0,0,1,8,58,115,104,97,100,111,119,49,68,
+0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,
+59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,17,48,0,48,0,0,0,18,99,
+111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,0,0,
+0,1,0,12,0,115,104,97,100,111,119,50,68,80,114,111,106,0,1,0,0,21,115,97,
+109,112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,0,1,8,58,115,104,
+97,100,111,119,50,68,0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,
+99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,
+111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,
+100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,0,0,0,1,0,
+9,0,110,111,105,115,101,49,0,1,0,0,9,120,0,0,0,1,8,17,48,0,48,0,
+0,0,0,1,0,9,0,110,111,105,115,101,49,0,1,0,0,10,120,0,0,0,1,8,
+17,48,0,48,0,0,0,0,1,0,9,0,110,111,105,115,101,49,0,1,0,0,11,120,
+0,0,0,1,8,17,48,0,48,0,0,0,0,1,0,9,0,110,111,105,115,101,49,0,
+1,0,0,12,120,0,0,0,1,8,17,48,0,48,0,0,0,0,1,0,10,0,110,111,
+105,115,101,50,0,1,0,0,9,120,0,0,0,1,8,58,118,101,99,50,0,17,48,0,
+48,0,0,0,0,0,0,1,0,10,0,110,111,105,115,101,50,0,1,0,0,10,120,0,
+0,0,1,8,58,118,101,99,50,0,17,48,0,48,0,0,0,0,0,0,1,0,10,0,
+110,111,105,115,101,50,0,1,0,0,11,120,0,0,0,1,8,58,118,101,99,50,0,17,
+48,0,48,0,0,0,0,0,0,1,0,10,0,110,111,105,115,101,50,0,1,0,0,12,
+120,0,0,0,1,8,58,118,101,99,50,0,17,48,0,48,0,0,0,0,0,0,1,0,
+11,0,110,111,105,115,101,51,0,1,0,0,9,120,0,0,0,1,8,58,118,101,99,51,
+0,17,48,0,48,0,0,0,0,0,0,1,0,11,0,110,111,105,115,101,51,0,1,0,
+0,10,120,0,0,0,1,8,58,118,101,99,51,0,17,48,0,48,0,0,0,0,0,0,
+1,0,11,0,110,111,105,115,101,51,0,1,0,0,11,120,0,0,0,1,8,58,118,101,
+99,51,0,17,48,0,48,0,0,0,0,0,0,1,0,11,0,110,111,105,115,101,51,0,
+1,0,0,12,120,0,0,0,1,8,58,118,101,99,51,0,17,48,0,48,0,0,0,0,
+0,0,1,0,12,0,110,111,105,115,101,52,0,1,0,0,9,120,0,0,0,1,8,58,
+118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,12,0,110,111,105,115,101,
+52,0,1,0,0,10,120,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,
+0,0,0,0,1,0,12,0,110,111,105,115,101,52,0,1,0,0,11,120,0,0,0,1,
+8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,12,0,110,111,105,
+115,101,52,0,1,0,0,12,120,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,
+0,0,0,0,0,0,0 \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_core.gc b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_core.gc
new file mode 100755
index 000000000..d1d2cb10f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_core.gc
@@ -0,0 +1,1565 @@
+
+//
+// This file defines nearly all constructors and operators for built-in data types, using
+// extended language syntax. In general, compiler treats constructors and operators as
+// ordinary functions with some exceptions. For example, the language does not allow
+// functions to be called in constant expressions - here the exception is made to allow it.
+//
+// Each implementation provides its own version of this file. Each implementation can define
+// the required set of operators and constructors in its own fashion.
+//
+// The extended language syntax is only present when compiling this file. It is implicitly
+// included at the very beginning of the compiled shader, so no built-in functions can be
+// used.
+//
+// To communicate with the implementation, a special extended "__asm" keyword is used, followed
+// by an instruction name (any valid identifier), a destination variable identifier and a
+// a list of zero or more source variable identifiers. A variable identifier is a variable name
+// declared earlier in the code (as a function parameter, local or global variable).
+// An instruction name designates an instruction that must be exported by the implementation.
+// Each instruction receives data from source variable identifiers and returns data in the
+// destination variable identifier.
+//
+// It is up to the implementation how to define a particular operator or constructor. If it is
+// expected to being used rarely, it can be defined in terms of other operators and constructors,
+// for example:
+//
+// ivec2 __operator + (const ivec2 x, const ivec2 y) {
+// return ivec2 (x[0] + y[0], x[1] + y[1]);
+// }
+//
+// If a particular operator or constructor is expected to be used very often or is an atomic
+// operation (that is, an operation that cannot be expressed in terms of other operations or
+// would create a dependency cycle) it must be defined using one or more __asm constructs.
+//
+// Each implementation must define constructors for all scalar types (bool, float, int).
+// There are 9 scalar-to-scalar constructors (including identity constructors). However,
+// since the language introduces special constructors (like matrix constructor with a single
+// scalar value), implementations must also implement these cases.
+// The compiler provides the following algorithm when resolving a constructor:
+// - try to find a constructor with a prototype matching ours,
+// - if no constructor is found and this is a scalar-to-scalar constructor, raise an error,
+// - if a constructor is found, execute it and return,
+// - count the size of the constructor parameter list - if it is less than the size of
+// our constructor's type, raise an error,
+// - for each parameter in the list do a recursive constructor matching for appropriate
+// scalar fields in the constructed variable,
+//
+// Each implementation must also define a set of operators that deal with built-in data types.
+// There are four kinds of operators:
+// 1) Operators that are implemented only by the compiler: "()" (function call), "," (sequence)
+// and "?:" (selection).
+// 2) Operators that are implemented by the compiler by expressing it in terms of other operators:
+// - "." (field selection) - translated to subscript access,
+// - "&&" (logical and) - translated to "<left_expr> ? <right_expr> : false",
+// - "||" (logical or) - translated to "<left_expr> ? true : <right_expr>",
+// 3) Operators that can be defined by the implementation and if the required prototype is not
+// found, standard behaviour is used:
+// - "==", "!=", "=" (equality, assignment) - compare or assign matching fields one-by-one;
+// note that at least operators for scalar data types must be defined by the implementation
+// to get it work,
+// 4) All other operators not mentioned above. If no required prototype is found, an error is
+// raised. An implementation must follow the language specification to provide all valid
+// operator prototypes.
+//
+
+int __constructor (const float _f) {
+ int _i;
+ __asm float_to_int _i, _f;
+ return _i;
+}
+
+bool __constructor (const int _i) {
+ return _i != 0;
+}
+
+bool __constructor (const float _f) {
+ return _f != 0.0;
+}
+
+int __constructor (const bool _b) {
+ return _b ? 1 : 0;
+}
+
+float __constructor (const bool _b) {
+ return _b ? 1.0 : 0.0;
+}
+
+float __constructor (const int _i) {
+ float _f;
+ __asm int_to_float _f, _i;
+ return _f;
+}
+
+bool __constructor (const bool _b) {
+ return _b;
+}
+
+int __constructor (const int _i) {
+ return _i;
+}
+
+float __constructor (const float _f) {
+ return _f;
+}
+
+vec2 __constructor (const float _f) {
+ return vec2 (_f, _f);
+}
+
+vec2 __constructor (const int _i) {
+ return vec2 (_i, _i);
+}
+
+vec2 __constructor (const bool _b) {
+ return vec2 (_b, _b);
+}
+
+vec3 __constructor (const float _f) {
+ return vec3 (_f, _f, _f);
+}
+
+vec3 __constructor (const int _i) {
+ return vec3 (_i, _i, _i);
+}
+
+vec3 __constructor (const bool _b) {
+ return vec3 (_b, _b, _b);
+}
+
+vec4 __constructor (const float _f) {
+ return vec4 (_f, _f, _f, _f);
+}
+
+vec4 __constructor (const int _i) {
+ return vec4 (_i, _i, _i, _i);
+}
+
+vec4 __constructor (const bool _b) {
+ return vec4 (_b, _b, _b, _b);
+}
+
+ivec2 __constructor (const int _i) {
+ return ivec2 (_i, _i);
+}
+
+ivec2 __constructor (const float _f) {
+ return ivec2 (_f, _f);
+}
+
+ivec2 __constructor (const bool _b) {
+ return ivec2 (_b, _b);
+}
+
+ivec3 __constructor (const int _i) {
+ return ivec3 (_i, _i, _i);
+}
+
+ivec3 __constructor (const float _f) {
+ return ivec3 (_f, _f, _f);
+}
+
+ivec3 __constructor (const bool _b) {
+ return ivec3 (_b, _b, _b);
+}
+
+ivec4 __constructor (const int _i) {
+ return ivec4 (_i, _i, _i, _i);
+}
+
+ivec4 __constructor (const float _f) {
+ return ivec4 (_f, _f, _f, _f);
+}
+
+ivec4 __constructor (const bool _b) {
+ return ivec4 (_b, _b, _b, _b);
+}
+
+bvec2 __constructor (const bool _b) {
+ return bvec2 (_b, _b);
+}
+
+bvec2 __constructor (const float _f) {
+ return bvec2 (_f, _f);
+}
+
+bvec2 __constructor (const int _i) {
+ return bvec2 (_i, _i);
+}
+
+bvec3 __constructor (const bool _b) {
+ return bvec3 (_b, _b, _b);
+}
+
+bvec3 __constructor (const float _f) {
+ return bvec3 (_f, _f, _f);
+}
+
+bvec3 __constructor (const int _i) {
+ return bvec3 (_i, _i, _i);
+}
+
+bvec4 __constructor (const bool _b) {
+ return bvec4 (_b, _b, _b, _b);
+}
+
+bvec4 __constructor (const float _f) {
+ return bvec4 (_f, _f, _f, _f);
+}
+
+bvec4 __constructor (const int _i) {
+ return bvec4 (_i, _i, _i, _i);
+}
+
+mat2 __constructor (const float _f) {
+ return mat2 (
+ _f, .0,
+ .0, _f
+ );
+}
+
+mat2 __constructor (const int _i) {
+ return mat2 (
+ _i, .0,
+ .0, _i
+ );
+}
+
+mat2 __constructor (const bool _b) {
+ return mat2 (
+ _b, .0,
+ .0, _b
+ );
+}
+
+mat3 __constructor (const float _f) {
+ return mat3 (
+ _f, .0, .0,
+ .0, _f, .0,
+ .0, .0, _f
+ );
+}
+
+mat3 __constructor (const int _i) {
+ return mat3 (
+ _i, .0, .0,
+ .0, _i, .0,
+ .0, .0, _i
+ );
+}
+
+mat3 __constructor (const bool _b) {
+ return mat3 (
+ _b, .0, .0,
+ .0, _b, .0,
+ .0, .0, _b
+ );
+}
+
+mat4 __constructor (const float _f) {
+ return mat4 (
+ _f, .0, .0, .0,
+ .0, _f, .0, .0,
+ .0, .0, _f, .0,
+ .0, .0, .0, _f
+ );
+}
+
+mat4 __constructor (const int _i) {
+ return mat4 (
+ _i, .0, .0, .0,
+ .0, _i, .0, .0,
+ .0, .0, _i, .0,
+ .0, .0, .0, _i
+ );
+}
+
+mat4 __constructor (const bool _b) {
+ return mat4 (
+ _b, .0, .0, .0,
+ .0, _b, .0, .0,
+ .0, .0, _b, .0,
+ .0, .0, .0, _b
+ );
+}
+
+//void __operator = (out float a, const float b) {
+// __asm float_copy a, b;
+//}
+//
+//void __operator = (out int a, const int b) {
+// __asm int_copy a, b;
+//}
+//
+//void __operator = (out bool a, const bool b) {
+// __asm bool_copy a, b;
+//}
+//
+//void __operator = (out vec2 v, const vec2 u) {
+// v.x = u.x, v.y = u.y;
+//}
+//
+//void __operator = (out vec3 v, const vec3 u) {
+// v.x = u.x, v.y = u.y, v.z = u.z;
+//}
+//
+//void __operator = (out vec4 v, const vec4 u) {
+// v.x = u.x, v.y = u.y, v.z = u.z, v.w = u.w;
+//}
+//
+//void __operator = (out ivec2 v, const ivec2 u) {
+// v.x = u.x, v.y = u.y;
+//}
+//
+//void __operator = (out ivec3 v, const ivec3 u) {
+// v.x = u.x, v.y = u.y, v.z = u.z;
+//}
+//
+//void __operator = (out ivec4 v, const ivec4 u) {
+// v.x = u.x, v.y = u.y, v.z = u.z, v.w = u.w;
+//}
+//
+//void __operator = (out bvec2 v, const bvec2 u) {
+// v.x = u.x, v.y = u.y;
+//}
+//
+//void __operator = (out bvec3 v, const bvec3 u) {
+// v.x = u.x, v.y = u.y, v.z = u.z;
+//}
+//
+//void __operator = (out bvec4 v, const bvec4 u) {
+// v.x = u.x, v.y = u.y, v.z = u.z, v.w = u.w;
+//}
+//
+//void __operator = (out mat2 m, const mat2 n) {
+// m[0] = n[0], m[1] = n[1];
+//}
+//
+//void __operator = (out mat3 m, const mat3 n) {
+// m[0] = n[0], m[1] = n[1], m[2] = n[2];
+//}
+//
+//void __operator = (out mat4 m, const mat4 n) {
+// m[0] = n[0], m[1] = n[1], m[2] = n[2], m[3] = n[3];
+//}
+
+void __operator += (inout float a, const float b) {
+ __asm float_add a, a, b;
+}
+
+float __operator - (const float a) {
+ float c;
+ __asm float_negate c, a;
+ return c;
+}
+
+void __operator -= (inout float a, const float b) {
+ a += -b;
+}
+
+void __operator *= (inout float a, const float b) {
+ __asm float_multiply a, a, b;
+}
+
+void __operator /= (inout float a, const float b) {
+ __asm float_divide a, a, b;
+}
+
+float __operator + (const float a, const float b) {
+ float c;
+ c = a;
+ return c += b;
+}
+
+void __operator += (inout int a, const int b) {
+ a = int (float (a) + float (b));
+}
+
+int __operator - (const int a) {
+ return int (-float (a));
+}
+
+void __operator -= (inout int a, const int b) {
+ a += -b;
+}
+
+float __operator * (const float a, const float b) {
+ float c;
+ c = a;
+ return c *= b;
+}
+
+void __operator *= (inout int a, const int b) {
+ a = int (float (a) * float (b));
+}
+
+float __operator / (const float a, const float b) {
+ float c;
+ c = a;
+ return c /= b;
+}
+
+void __operator /= (inout int a, const int b) {
+ a = int (float (a) / float (b));
+}
+
+void __operator += (inout vec2 v, const vec2 u) {
+ v.x += u.x, v.y += u.y;
+}
+
+void __operator -= (inout vec2 v, const vec2 u) {
+ v.x -= u.x, v.y -= u.y;
+}
+
+void __operator *= (inout vec2 v, const vec2 u) {
+ v.x *= u.x, v.y *= u.y;
+}
+
+void __operator /= (inout vec2 v, const vec2 u) {
+ v.x /= u.x, v.y /= u.y;
+}
+
+void __operator += (inout vec3 v, const vec3 u) {
+ v.x += u.x, v.y += u.y, v.z += u.z;
+}
+
+void __operator -= (inout vec3 v, const vec3 u) {
+ v.x -= u.x, v.y -= u.y, v.z -= u.z;
+}
+
+void __operator *= (inout vec3 v, const vec3 u) {
+ v.x *= u.x, v.y *= u.y, v.z *= u.z;
+}
+
+void __operator /= (inout vec3 v, const vec3 u) {
+ v.x /= u.x, v.y /= u.y, v.z /= u.z;
+}
+
+void __operator += (inout vec4 v, const vec4 u) {
+ v.x += u.x, v.y += u.y, v.z += u.z, v.w += u.w;
+}
+
+void __operator -= (inout vec4 v, const vec4 u) {
+ v.x -= u.x, v.y -= u.y, v.z -= u.z, v.w -= u.w;
+}
+
+void __operator *= (inout vec4 v, const vec4 u) {
+ v.x *= u.x, v.y *= u.y, v.z *= u.z, v.w *= u.w;
+}
+
+void __operator /= (inout vec4 v, const vec4 u) {
+ v.x /= u.x, v.y /= u.y, v.z /= u.z, v.w /= u.w;
+}
+
+void __operator += (inout ivec2 v, const ivec2 u) {
+ v.x += u.x, v.y += u.y;
+}
+
+void __operator -= (inout ivec2 v, const ivec2 u) {
+ v.x -= u.x, v.y -= u.y;
+}
+
+void __operator *= (inout ivec2 v, const ivec2 u) {
+ v.x *= u.x, v.y *= u.y;
+}
+
+void __operator /= (inout ivec2 v, const ivec2 u) {
+ v.x /= u.x, v.y /= u.y;
+}
+
+void __operator += (inout ivec3 v, const ivec3 u) {
+ v.x += u.x, v.y += u.y, v.z += u.z;
+}
+
+void __operator -= (inout ivec3 v, const ivec3 u) {
+ v.x -= u.x, v.y -= u.y, v.z -= u.z;
+}
+
+void __operator *= (inout ivec3 v, const ivec3 u) {
+ v.x *= u.x, v.y *= u.y, v.z *= u.z;
+}
+
+void __operator /= (inout ivec3 v, const ivec3 u) {
+ v.x /= u.x, v.y /= u.y, v.z /= u.z;
+}
+
+void __operator += (inout ivec4 v, const ivec4 u) {
+ v.x += u.x, v.y += u.y, v.z += u.z, v.w += u.w;
+}
+
+void __operator -= (inout ivec4 v, const ivec4 u) {
+ v.x -= u.x, v.y -= u.y, v.z -= u.z, v.w -= u.w;
+}
+
+void __operator *= (inout ivec4 v, const ivec4 u) {
+ v.x *= u.x, v.y *= u.y, v.z *= u.z, v.w *= u.w;
+}
+
+void __operator /= (inout ivec4 v, const ivec4 u) {
+ v.x /= u.x, v.y /= u.y, v.z /= u.z, v.w /= u.w;
+}
+
+void __operator += (inout mat2 m, const mat2 n) {
+ m[0] += n[0], m[1] += n[1];
+}
+
+void __operator -= (inout mat2 m, const mat2 n) {
+ m[0] -= n[0], m[1] -= n[1];
+}
+
+vec2 __operator * (const mat2 m, const vec2 v) {
+ return vec2 (
+ v.x * m[0].x + v.y * m[1].x,
+ v.x * m[0].y + v.y * m[1].y
+ );
+}
+
+mat2 __operator * (const mat2 m, const mat2 n) {
+ return mat2 (m * n[0], m * n[1]);
+}
+
+void __operator *= (inout mat2 m, const mat2 n) {
+ m = m * n;
+}
+
+void __operator /= (inout mat2 m, const mat2 n) {
+ m[0] /= n[0], m[1] /= n[1];
+}
+
+void __operator += (inout mat3 m, const mat3 n) {
+ m[0] += n[0], m[1] += n[1], m[2] += n[2];
+}
+
+void __operator -= (inout mat3 m, const mat3 n) {
+ m[0] -= n[0], m[1] -= n[1], m[2] -= n[2];
+}
+
+vec3 __operator * (const mat3 m, const vec3 v) {
+ return vec3 (
+ v.x * m[0].x + v.y * m[1].x + v.z * m[2].x,
+ v.x * m[0].y + v.y * m[1].y + v.z * m[2].y,
+ v.x * m[0].z + v.y * m[1].z + v.z * m[2].z
+ );
+}
+
+mat3 __operator * (const mat3 m, const mat3 n) {
+ return mat3 (m * n[0], m * n[1], m * n[2]);
+}
+
+void __operator *= (inout mat3 m, const mat3 n) {
+ m = m * n;
+}
+
+void __operator /= (inout mat3 m, const mat3 n) {
+ m[0] /= n[0], m[1] /= n[1], m[2] /= n[2];
+}
+
+void __operator += (inout mat4 m, const mat4 n) {
+ m[0] += n[0], m[1] += n[1], m[2] += n[2], m[3] += n[3];
+}
+
+void __operator -= (inout mat4 m, const mat4 n) {
+ m[0] -= n[0], m[1] -= n[1], m[2] -= n[2], m[3] -= n[3];
+}
+
+vec4 __operator * (const mat4 m, const vec4 v) {
+ return vec4 (
+ v.x * m[0].x + v.y * m[1].x + v.z * m[2].x + v.w * m[3].x,
+ v.x * m[0].y + v.y * m[1].y + v.z * m[2].y + v.w * m[3].y,
+ v.x * m[0].z + v.y * m[1].z + v.z * m[2].z + v.w * m[3].z,
+ v.x * m[0].w + v.y * m[1].w + v.z * m[2].w + v.w * m[3].w
+ );
+}
+
+mat4 __operator * (const mat4 m, const mat4 n) {
+ return mat4 (m * n[0], m * n[1], m * n[2], m * n[3]);
+}
+
+void __operator *= (inout mat4 m, const mat4 n) {
+ m = m * n;
+}
+
+void __operator /= (inout mat4 m, const mat4 n) {
+ m[0] /= n[0], m[1] /= n[1], m[2] /= n[2], m[3] /= n[3];
+}
+
+void __operator += (inout vec2 v, const float a) {
+ v.x += a, v.y += a;
+}
+
+void __operator -= (inout vec2 v, const float a) {
+ v.x -= a, v.y -= a;
+}
+
+void __operator *= (inout vec2 v, const float a) {
+ v.x *= a, v.y *= a;
+}
+
+void __operator /= (inout vec2 v, const float a) {
+ v.x /= a, v.y /= a;
+}
+
+void __operator += (inout vec3 v, const float a) {
+ v.x += a, v.y += a, v.z += a;
+}
+
+void __operator -= (inout vec3 v, const float a) {
+ v.x -= a, v.y -= a, v.z -= a;
+}
+
+void __operator *= (inout vec3 v, const float a) {
+ v.x *= a, v.y *= a, v.z *= a;
+}
+
+void __operator /= (inout vec3 v, const float a) {
+ v.x /= a, v.y /= a, v.z /= a;
+}
+
+void __operator += (inout vec4 v, const float a) {
+ v.x += a, v.y += a, v.z += a, v.w += a;
+}
+
+void __operator -= (inout vec4 v, const float a) {
+ v.x -= a, v.y -= a, v.z -= a, v.w -= a;
+}
+
+void __operator *= (inout vec4 v, const float a) {
+ v.x *= a, v.y *= a, v.z *= a, v.w *= a;
+}
+
+void __operator /= (inout vec4 v, const float a) {
+ v.x /= a, v.y /= a, v.z /= a, v.w /= a;
+}
+
+void __operator += (inout mat2 m, const float a) {
+ m[0] += a, m[1] += a;
+}
+
+void __operator -= (inout mat2 m, const float a) {
+ m[0] -= a, m[1] -= a;
+}
+
+void __operator *= (inout mat2 m, const float a) {
+ m[0] *= a, m[1] *= a;
+}
+
+void __operator /= (inout mat2 m, const float a) {
+ m[0] /= a, m[1] /= a;
+}
+
+void __operator += (inout mat3 m, const float a) {
+ m[0] += a, m[1] += a, m[2] += a;
+}
+
+void __operator -= (inout mat3 m, const float a) {
+ m[0] -= a, m[1] -= a, m[2] -= a;
+}
+
+void __operator *= (inout mat3 m, const float a) {
+ m[0] *= a, m[1] *= a, m[2] *= a;
+}
+
+void __operator /= (inout mat3 m, const float a) {
+ m[0] /= a, m[1] /= a, m[2] /= a;
+}
+
+void __operator += (inout mat4 m, const float a) {
+ m[0] += a, m[1] += a, m[2] += a, m[3] += a;
+}
+
+void __operator -= (inout mat4 m, const float a) {
+ m[0] -= a, m[1] -= a, m[2] -= a, m[3] -= a;
+}
+
+void __operator *= (inout mat4 m, const float a) {
+ m[0] *= a, m[1] *= a, m[2] *= a, m[3] *= a;
+}
+
+void __operator /= (inout mat4 m, const float a) {
+ m[0] /= a, m[1] /= a, m[2] /= a, m[3] /= a;
+}
+
+vec2 __operator * (const vec2 v, const mat2 m) {
+ return vec2 (
+ v.x * m[0].x + v.y * m[0].y,
+ v.x * m[1].x + v.y * m[1].y
+ );
+}
+
+void __operator *= (inout vec2 v, const mat2 m) {
+ v = v * m;
+}
+
+vec3 __operator * (const vec3 v, const mat3 m) {
+ return vec3 (
+ v.x * m[0].x + v.y * m[0].y + v.z * m[0].z,
+ v.x * m[1].x + v.y * m[1].y + v.z * m[1].z,
+ v.x * m[2].x + v.y * m[2].y + v.z * m[2].z
+ );
+}
+
+void __operator *= (inout vec3 v, const mat3 m) {
+ v = v * m;
+}
+
+vec4 __operator * (const vec4 v, const mat4 m) {
+ return vec4 (
+ v.x * m[0].x + v.y * m[0].y + v.z * m[0].z + v.w * m[0].w,
+ v.x * m[1].x + v.y * m[1].y + v.z * m[1].z + v.w * m[1].w,
+ v.x * m[2].x + v.y * m[2].y + v.z * m[2].z + v.w * m[2].w,
+ v.x * m[3].x + v.y * m[3].y + v.z * m[3].z + v.w * m[3].w
+ );
+}
+
+void __operator *= (inout vec4 v, const mat4 m) {
+ v = v * m;
+}
+
+float __operator - (const float a, const float b) {
+ return a + -b;
+}
+
+int __operator + (const int a, const int b) {
+ int c;
+ c = a;
+ return c += b;
+}
+
+int __operator - (const int a, const int b) {
+ return a + -b;
+}
+
+int __operator * (const int a, const int b) {
+ int c;
+ return (c = a) *= b;
+}
+
+int __operator / (const int a, const int b) {
+ int c;
+ return (c = a) /= b;
+}
+
+vec2 __operator + (const vec2 v, const vec2 u) {
+ return vec2 (v.x + u.x, v.y + u.y);
+}
+
+vec2 __operator - (const vec2 v, const vec2 u) {
+ return vec2 (v.x - u.x, v.y - u.y);
+}
+
+vec3 __operator + (const vec3 v, const vec3 u) {
+ return vec3 (v.x + u.x, v.y + u.y, v.z + u.z);
+}
+
+vec3 __operator - (const vec3 v, const vec3 u) {
+ return vec3 (v.x - u.x, v.y - u.y, v.z - u.z);
+}
+
+vec4 __operator + (const vec4 v, const vec4 u) {
+ return vec4 (v.x + u.x, v.y + u.y, v.z + u.z, v.w + u.w);
+}
+
+vec4 __operator - (const vec4 v, const vec4 u) {
+ return vec4 (v.x - u.x, v.y - u.y, v.z - u.z, v.w - u.w);
+}
+
+ivec2 __operator + (const ivec2 v, const ivec2 u) {
+ return ivec2 (v.x + u.x, v.y + u.y);
+}
+
+ivec2 __operator - (const ivec2 v, const ivec2 u) {
+ return ivec2 (v.x - u.x, v.y - u.y);
+}
+
+ivec3 __operator + (const ivec3 v, const ivec3 u) {
+ return ivec3 (v.x + u.x, v.y + u.y, v.z + u.z);
+}
+
+ivec3 __operator - (const ivec3 v, const ivec3 u) {
+ return ivec3 (v.x - u.x, v.y - u.y, v.z - u.z);
+}
+
+ivec4 __operator + (const ivec4 v, const ivec4 u) {
+ return ivec4 (v.x + u.x, v.y + u.y, v.z + u.z, v.w + u.w);
+}
+
+ivec4 __operator - (const ivec4 v, const ivec4 u) {
+ return ivec4 (v.x - u.x, v.y - u.y, v.z - u.z, v.w - u.w);
+}
+
+mat2 __operator + (const mat2 m, const mat2 n) {
+ return mat2 (m[0] + n[0], m[1] + n[1]);
+}
+
+mat2 __operator - (const mat2 m, const mat2 n) {
+ return mat2 (m[0] - n[0], m[1] - n[1]);
+}
+
+mat3 __operator + (const mat3 m, const mat3 n) {
+ return mat3 (m[0] + n[0], m[1] + n[1], m[2] + n[2]);
+}
+
+mat3 __operator - (const mat3 m, const mat3 n) {
+ return mat3 (m[0] - n[0], m[1] - n[1], m[2] - n[2]);
+}
+
+mat4 __operator + (const mat4 m, const mat4 n) {
+ return mat4 (m[0] + n[0], m[1] + n[1], m[2] + n[2], m[3] + n[3]);
+}
+
+mat4 __operator - (const mat4 m, const mat4 n) {
+ return mat4 (m[0] - n[0], m[1] - n[1], m[2] - n[2], m[3] - n[3]);
+}
+
+vec2 __operator + (const float a, const vec2 u) {
+ return vec2 (a + u.x, a + u.y);
+}
+
+vec2 __operator + (const vec2 v, const float b) {
+ return vec2 (v.x + b, v.y + b);
+}
+
+vec2 __operator - (const float a, const vec2 u) {
+ return vec2 (a - u.x, a - u.y);
+}
+
+vec2 __operator - (const vec2 v, const float b) {
+ return vec2 (v.x - b, v.y - b);
+}
+
+vec2 __operator * (const float a, const vec2 u) {
+ return vec2 (a * u.x, a * u.y);
+}
+
+vec2 __operator * (const vec2 v, const float b) {
+ return vec2 (v.x * b, v.y * b);
+}
+
+vec2 __operator / (const float a, const vec2 u) {
+ return vec2 (a / u.x, a / u.y);
+}
+
+vec2 __operator / (const vec2 v, const float b) {
+ return vec2 (v.x / b, v.y / b);
+}
+
+vec3 __operator + (const float a, const vec3 u) {
+ return vec3 (a + u.x, a + u.y, a + u.z);
+}
+
+vec3 __operator + (const vec3 v, const float b) {
+ return vec3 (v.x + b, v.y + b, v.z + b);
+}
+
+vec3 __operator - (const float a, const vec3 u) {
+ return vec3 (a - u.x, a - u.y, a - u.z);
+}
+
+vec3 __operator - (const vec3 v, const float b) {
+ return vec3 (v.x - b, v.y - b, v.z - b);
+}
+
+vec3 __operator * (const float a, const vec3 u) {
+ return vec3 (a * u.x, a * u.y, a * u.z);
+}
+
+vec3 __operator * (const vec3 v, const float b) {
+ return vec3 (v.x * b, v.y * b, v.z * b);
+}
+
+vec3 __operator / (const float a, const vec3 u) {
+ return vec3 (a / u.x, a / u.y, a / u.z);
+}
+
+vec3 __operator / (const vec3 v, const float b) {
+ return vec3 (v.x / b, v.y / b, v.z / b);
+}
+
+vec4 __operator + (const float a, const vec4 u) {
+ return vec4 (a + u.x, a + u.y, a + u.z, a + u.w);
+}
+
+vec4 __operator + (const vec4 v, const float b) {
+ return vec4 (v.x + b, v.y + b, v.z + b, v.w + b);
+}
+
+vec4 __operator - (const float a, const vec4 u) {
+ return vec4 (a - u.x, a - u.y, a - u.z, a - u.w);
+}
+
+vec4 __operator - (const vec4 v, const float b) {
+ return vec4 (v.x - b, v.y - b, v.z - b, v.w - b);
+}
+
+vec4 __operator * (const float a, const vec4 u) {
+ return vec4 (a * u.x, a * u.y, a * u.z, a * u.w);
+}
+
+vec4 __operator * (const vec4 v, const float b) {
+ return vec4 (v.x * b, v.y * b, v.z * b, v.w * b);
+}
+
+vec4 __operator / (const float a, const vec4 u) {
+ return vec4 (a / u.x, a / u.y, a / u.z, a / u.w);
+}
+
+vec4 __operator / (const vec4 v, const float b) {
+ return vec4 (v.x / b, v.y / b, v.z / b, v.w / b);
+}
+
+mat2 __operator + (const float a, const mat2 n) {
+ return mat2 (a + n[0], a + n[1]);
+}
+
+mat2 __operator + (const mat2 m, const float b) {
+ return mat2 (m[0] + b, m[1] + b);
+}
+
+mat2 __operator - (const float a, const mat2 n) {
+ return mat2 (a - n[0], a - n[1]);
+}
+
+mat2 __operator - (const mat2 m, const float b) {
+ return mat2 (m[0] - b, m[1] - b);
+}
+
+mat2 __operator * (const float a, const mat2 n) {
+ return mat2 (a * n[0], a * n[1]);
+}
+
+mat2 __operator * (const mat2 m, const float b) {
+ return mat2 (m[0] * b, m[1] * b);
+}
+
+mat2 __operator / (const float a, const mat2 n) {
+ return mat2 (a / n[0], a / n[1]);
+}
+
+mat2 __operator / (const mat2 m, const float b) {
+ return mat2 (m[0] / b, m[1] / b);
+}
+
+mat3 __operator + (const float a, const mat3 n) {
+ return mat3 (a + n[0], a + n[1], a + n[2]);
+}
+
+mat3 __operator + (const mat3 m, const float b) {
+ return mat3 (m[0] + b, m[1] + b, m[2] + b);
+}
+
+mat3 __operator - (const float a, const mat3 n) {
+ return mat3 (a - n[0], a - n[1], a - n[2]);
+}
+
+mat3 __operator - (const mat3 m, const float b) {
+ return mat3 (m[0] - b, m[1] - b, m[2] - b);
+}
+
+mat3 __operator * (const float a, const mat3 n) {
+ return mat3 (a * n[0], a * n[1], a * n[2]);
+}
+
+mat3 __operator * (const mat3 m, const float b) {
+ return mat3 (m[0] * b, m[1] * b, m[2] * b);
+}
+
+mat3 __operator / (const float a, const mat3 n) {
+ return mat3 (a / n[0], a / n[1], a / n[2]);
+}
+
+mat3 __operator / (const mat3 m, const float b) {
+ return mat3 (m[0] / b, m[1] / b, m[2] / b);
+}
+
+mat4 __operator + (const float a, const mat4 n) {
+ return mat4 (a + n[0], a + n[1], a + n[2], a + n[3]);
+}
+
+mat4 __operator + (const mat4 m, const float b) {
+ return mat4 (m[0] + b, m[1] + b, m[2] + b, m[3] + b);
+}
+
+mat4 __operator - (const float a, const mat4 n) {
+ return mat4 (a - n[0], a - n[1], a - n[2], a - n[3]);
+}
+
+mat4 __operator - (const mat4 m, const float b) {
+ return mat4 (m[0] - b, m[1] - b, m[2] - b, m[3] - b);
+}
+
+mat4 __operator * (const float a, const mat4 n) {
+ return mat4 (a * n[0], a * n[1], a * n[2], a * n[3]);
+}
+
+mat4 __operator * (const mat4 m, const float b) {
+ return mat4 (m[0] * b, m[1] * b, m[2] * b, m[3] * b);
+}
+
+mat4 __operator / (const float a, const mat4 n) {
+ return mat4 (a / n[0], a / n[1], a / n[2], a / n[3]);
+}
+
+mat4 __operator / (const mat4 m, const float b) {
+ return mat4 (m[0] / b, m[1] / b, m[2] / b, m[3] / b);
+}
+
+ivec2 __operator + (const int a, const ivec2 u) {
+ return ivec2 (a + u.x, a + u.y);
+}
+
+ivec2 __operator + (const ivec2 v, const int b) {
+ return ivec2 (v.x + b, v.y + b);
+}
+
+ivec2 __operator - (const int a, const ivec2 u) {
+ return ivec2 (a - u.x, a - u.y);
+}
+
+ivec2 __operator - (const ivec2 v, const int b) {
+ return ivec2 (v.x - b, v.y - b);
+}
+
+ivec2 __operator * (const int a, const ivec2 u) {
+ return ivec2 (a * u.x, a * u.y);
+}
+
+ivec2 __operator * (const ivec2 v, const int b) {
+ return ivec2 (v.x * b, v.y * b);
+}
+
+ivec2 __operator / (const int a, const ivec2 u) {
+ return ivec2 (a / u.x, a / u.y);
+}
+
+ivec2 __operator / (const ivec2 v, const int b) {
+ return ivec2 (v.x / b, v.y / b);
+}
+
+ivec3 __operator + (const int a, const ivec3 u) {
+ return ivec3 (a + u.x, a + u.y, a + u.z);
+}
+
+ivec3 __operator + (const ivec3 v, const int b) {
+ return ivec3 (v.x + b, v.y + b, v.z + b);
+}
+
+ivec3 __operator - (const int a, const ivec3 u) {
+ return ivec3 (a - u.x, a - u.y, a - u.z);
+}
+
+ivec3 __operator - (const ivec3 v, const int b) {
+ return ivec3 (v.x - b, v.y - b, v.z - b);
+}
+
+ivec3 __operator * (const int a, const ivec3 u) {
+ return ivec3 (a * u.x, a * u.y, a * u.z);
+}
+
+ivec3 __operator * (const ivec3 v, const int b) {
+ return ivec3 (v.x * b, v.y * b, v.z * b);
+}
+
+ivec3 __operator / (const int a, const ivec3 u) {
+ return ivec3 (a / u.x, a / u.y, a / u.z);
+}
+
+ivec3 __operator / (const ivec3 v, const int b) {
+ return ivec3 (v.x / b, v.y / b, v.z / b);
+}
+
+ivec4 __operator + (const int a, const ivec4 u) {
+ return ivec4 (a + u.x, a + u.y, a + u.z, a + u.w);
+}
+
+ivec4 __operator + (const ivec4 v, const int b) {
+ return ivec4 (v.x + b, v.y + b, v.z + b, v.w + b);
+}
+
+ivec4 __operator - (const int a, const ivec4 u) {
+ return ivec4 (a - u.x, a - u.y, a - u.z, a - u.w);
+}
+
+ivec4 __operator - (const ivec4 v, const int b) {
+ return ivec4 (v.x - b, v.y - b, v.z - b, v.w - b);
+}
+
+ivec4 __operator * (const int a, const ivec4 u) {
+ return ivec4 (a * u.x, a * u.y, a * u.z, a * u.w);
+}
+
+ivec4 __operator * (const ivec4 v, const int b) {
+ return ivec4 (v.x * b, v.y * b, v.z * b, v.w * b);
+}
+
+ivec4 __operator / (const int a, const ivec4 u) {
+ return ivec4 (a / u.x, a / u.y, a / u.z, a / u.w);
+}
+
+ivec4 __operator / (const ivec4 v, const int b) {
+ return ivec4 (v.x / b, v.y / b, v.z / b, v.w / b);
+}
+
+vec2 __operator * (const vec2 v, const vec2 u) {
+ return vec2 (v.x * u.x, v.y * u.y);
+}
+
+vec3 __operator * (const vec3 v, const vec3 u) {
+ return vec3 (v.x * u.x, v.y * u.y, v.z * u.z);
+}
+
+vec4 __operator * (const vec4 v, const vec4 u) {
+ return vec4 (v.x * u.x, v.y * u.y, v.z * u.z, v.w * u.w);
+}
+
+ivec2 __operator * (const ivec2 v, const ivec2 u) {
+ return ivec2 (v.x * u.x, v.y * u.y);
+}
+
+ivec3 __operator * (const ivec3 v, const ivec3 u) {
+ return ivec3 (v.x * u.x, v.y * u.y, v.z * u.z);
+}
+
+ivec4 __operator * (const ivec4 v, const ivec4 u) {
+ return ivec4 (v.x * u.x, v.y * u.y, v.z * u.z, v.w * u.w);
+}
+
+vec2 __operator / (const vec2 v, const vec2 u) {
+ return vec2 (v.x / u.x, v.y / u.y);
+}
+
+vec3 __operator / (const vec3 v, const vec3 u) {
+ return vec3 (v.x / u.x, v.y / u.y, v.z / u.z);
+}
+
+vec4 __operator / (const vec4 v, const vec4 u) {
+ return vec4 (v.x / u.x, v.y / u.y, v.z / u.z, v.w / u.w);
+}
+
+ivec2 __operator / (const ivec2 v, const ivec2 u) {
+ return ivec2 (v.x / u.x, v.y / u.y);
+}
+
+ivec3 __operator / (const ivec3 v, const ivec3 u) {
+ return ivec3 (v.x / u.x, v.y / u.y, v.z / u.z);
+}
+
+ivec4 __operator / (const ivec4 v, const ivec4 u) {
+ return ivec4 (v.x / u.x, v.y / u.y, v.z / u.z, v.w / u.w);
+}
+
+mat2 __operator / (const mat2 m, const mat2 n) {
+ return mat2 (m[0] / n[0], m[1] / n[1]);
+}
+
+mat3 __operator / (const mat3 m, const mat3 n) {
+ return mat3 (m[0] / n[0], m[1] / n[1], m[2] / n[2]);
+}
+
+mat4 __operator / (const mat4 m, const mat4 n) {
+ return mat4 (m[0] / n[0], m[1] / n[1], m[2] / n[2], m[3] / n[3]);
+}
+
+vec2 __operator - (const vec2 v) {
+ return vec2 (-v.x, -v.y);
+}
+
+vec3 __operator - (const vec3 v) {
+ return vec3 (-v.x, -v.y, -v.z);
+}
+
+vec4 __operator - (const vec4 v) {
+ return vec4 (-v.x, -v.y, -v.z, -v.w);
+}
+
+ivec2 __operator - (const ivec2 v) {
+ return ivec2 (-v.x, -v.y);
+}
+
+ivec3 __operator - (const ivec3 v) {
+ return ivec3 (-v.x, -v.y, -v.z);
+}
+
+ivec4 __operator - (const ivec4 v) {
+ return ivec4 (-v.x, -v.y, -v.z, -v.w);
+}
+
+mat2 __operator - (const mat2 m) {
+ return mat2 (-m[0], -m[1]);
+}
+
+mat3 __operator - (const mat3 m) {
+ return mat3 (-m[0], -m[1], -m[2]);
+}
+
+mat4 __operator - (const mat4 m) {
+ return mat4 (-m[0], -m[1], -m[2], -m[3]);
+}
+
+//
+// NOTE: postfix increment and decrement operators take additional dummy int parameter to
+// distinguish their prototypes from prefix ones.
+//
+
+void __operator -- (inout float a) {
+ a -= 1.0;
+}
+
+void __operator -- (inout int a) {
+ a -= 1;
+}
+
+void __operator -- (inout vec2 v) {
+ --v.x, --v.y;
+}
+
+void __operator -- (inout vec3 v) {
+ --v.x, --v.y, --v.z;
+}
+
+void __operator -- (inout vec4 v) {
+ --v.x, --v.y, --v.z, --v.w;
+}
+
+void __operator -- (inout ivec2 v) {
+ --v.x, --v.y;
+}
+
+void __operator -- (inout ivec3 v) {
+ --v.x, --v.y, --v.z;
+}
+
+void __operator -- (inout ivec4 v) {
+ --v.x, --v.y, --v.z, --v.w;
+}
+
+void __operator -- (inout mat2 m) {
+ --m[0], --m[1];
+}
+
+void __operator -- (inout mat3 m) {
+ --m[0], --m[1], --m[2];
+}
+
+void __operator -- (inout mat4 m) {
+ --m[0], --m[1], --m[2], --m[3];
+}
+
+void __operator ++ (inout float a) {
+ a += 1.0;
+}
+
+void __operator ++ (inout int a) {
+ a += 1;
+}
+
+void __operator ++ (inout vec2 v) {
+ ++v.x, ++v.y;
+}
+
+void __operator ++ (inout vec3 v) {
+ ++v.x, ++v.y, ++v.z;
+}
+
+void __operator ++ (inout vec4 v) {
+ ++v.x, ++v.y, ++v.z, ++v.w;
+}
+
+void __operator ++ (inout ivec2 v) {
+ ++v.x, ++v.y;
+}
+
+void __operator ++ (inout ivec3 v) {
+ ++v.x, ++v.y, ++v.z;
+}
+
+void __operator ++ (inout ivec4 v) {
+ ++v.x, ++v.y, ++v.z, ++v.w;
+}
+
+void __operator ++ (inout mat2 m) {
+ ++m[0], ++m[1];
+}
+
+void __operator ++ (inout mat3 m) {
+ ++m[0], ++m[1], ++m[2];
+}
+
+void __operator ++ (inout mat4 m) {
+ ++m[0], ++m[1], ++m[2], ++m[3];
+}
+
+float __operator -- (inout float a, const int) {
+ float c;
+ c = a;
+ --a;
+ return c;
+}
+
+int __operator -- (inout int a, const int) {
+ int c;
+ c = a;
+ --a;
+ return c;
+}
+
+vec2 __operator -- (inout vec2 v, const int) {
+ return vec2 (v.x--, v.y--);
+}
+
+vec3 __operator -- (inout vec3 v, const int) {
+ return vec3 (v.x--, v.y--, v.z--);
+}
+
+vec4 __operator -- (inout vec4 v, const int) {
+ return vec4 (v.x--, v.y--, v.z--, v.w--);
+}
+
+ivec2 __operator -- (inout ivec2 v, const int) {
+ return ivec2 (v.x--, v.y--);
+}
+
+ivec3 __operator -- (inout ivec3 v, const int) {
+ return ivec3 (v.x--, v.y--, v.z--);
+}
+
+ivec4 __operator -- (inout ivec4 v, const int) {
+ return ivec4 (v.x--, v.y--, v.z--, v.w--);
+}
+
+mat2 __operator -- (inout mat2 m, const int) {
+ return mat2 (m[0]--, m[1]--);
+}
+
+mat3 __operator -- (inout mat3 m, const int) {
+ return mat3 (m[0]--, m[1]--, m[2]--);
+}
+
+mat4 __operator -- (inout mat4 m, const int) {
+ return mat4 (m[0]--, m[1]--, m[2]--, m[3]--);
+}
+
+float __operator ++ (inout float a, const int) {
+ float c;
+ c = a;
+ ++a;
+ return c;
+}
+
+int __operator ++ (inout int a, const int) {
+ int c;
+ c = a;
+ ++a;
+ return c;
+}
+
+vec2 __operator ++ (inout vec2 v, const int) {
+ return vec2 (v.x++, v.y++);
+}
+
+vec3 __operator ++ (inout vec3 v, const int) {
+ return vec3 (v.x++, v.y++, v.z++);
+}
+
+vec4 __operator ++ (inout vec4 v, const int) {
+ return vec4 (v.x++, v.y++, v.z++, v.w++);
+}
+
+ivec2 __operator ++ (inout ivec2 v, const int) {
+ return ivec2 (v.x++, v.y++);
+}
+
+ivec3 __operator ++ (inout ivec3 v, const int) {
+ return ivec3 (v.x++, v.y++, v.z++);
+}
+
+ivec4 __operator ++ (inout ivec4 v, const int) {
+ return ivec4 (v.x++, v.y++, v.z++, v.w++);
+}
+
+mat2 __operator ++ (inout mat2 m, const int) {
+ return mat2 (m[0]++, m[1]++);
+}
+
+mat3 __operator ++ (inout mat3 m, const int) {
+ return mat3 (m[0]++, m[1]++, m[2]++);
+}
+
+mat4 __operator ++ (inout mat4 m, const int) {
+ return mat4 (m[0]++, m[1]++, m[2]++, m[3]++);
+}
+
+bool __operator < (const float a, const float b) {
+ bool c;
+ __asm float_less c, a, b;
+ return c;
+}
+
+bool __operator < (const int a, const int b) {
+ return float (a) < float (b);
+}
+
+bool __operator > (const float a, const float b) {
+ return b < a;
+}
+
+bool __operator > (const int a, const int b) {
+ return b < a;
+}
+
+bool __operator >= (const float a, const float b) {
+ return a > b || a == b;
+}
+
+bool __operator >= (const int a, const int b) {
+ return a > b || a == b;
+}
+
+bool __operator <= (const float a, const float b) {
+ return a < b || a == b;
+}
+
+bool __operator <= (const int a, const int b) {
+ return a < b || a == b;
+}
+
+//bool __operator == (const float a, const float b) {
+// bool c;
+// __asm float_equal c, a, b;
+// return c;
+//}
+//
+//bool __operator == (const int a, const int b) {
+// return float (a) == float (b);
+//}
+//
+//bool __operator == (const bool a, const bool b) {
+// return float (a) == float (b);
+//}
+//
+//bool __operator == (const vec2 v, const vec2 u) {
+// return v.x == u.x && v.y == u.y;
+//}
+//
+//bool __operator == (const vec3 v, const vec3 u) {
+// return v.x == u.x && v.y == u.y && v.z == u.z;
+//}
+//
+//bool __operator == (const vec4 v, const vec4 u) {
+// return v.x == u.x && v.y == u.y && v.z == u.z && v.w == u.w;
+//}
+//
+//bool __operator == (const ivec2 v, const ivec2 u) {
+// return v.x == u.x && v.y == u.y;
+//}
+//
+//bool __operator == (const ivec3 v, const ivec3 u) {
+// return v.x == u.x && v.y == u.y && v.z == u.z;
+//}
+//
+//bool __operator == (const ivec4 v, const ivec4 u) {
+// return v.x == u.x && v.y == u.y && v.z == u.z && v.w == u.w;
+//}
+//
+//bool __operator == (const bvec2 v, const bvec2 u) {
+// return v.x == u.x && v.y == u.y;
+//}
+//
+//bool __operator == (const bvec3 v, const bvec3 u) {
+// return v.x == u.x && v.y == u.y && v.z == u.z;
+//}
+//
+//bool __operator == (const bvec4 v, const bvec4 u) {
+// return v.x == u.x && v.y == u.y && v.z == u.z && v.w == u.w;
+//}
+//
+//bool __operator == (const mat2 m, const mat2 n) {
+// return m[0] == n[0] && m[1] == n[1];
+//}
+//
+//bool __operator == (const mat3 m, const mat3 n) {
+// return m[0] == n[0] && m[1] == n[1] && m[2] == n[2];
+//}
+//
+//bool __operator == (const mat4 m, const mat4 n) {
+// return m[0] == n[0] && m[1] == n[1] && m[2] == n[2] && m[3] == n[3];
+//}
+//
+//bool __operator != (const float a, const float b) {
+// return !(a == b);
+//}
+//
+//bool __operator != (const int a, const int b) {
+// return !(a == b);
+//}
+//
+//bool __operator != (const bool a, const bool b) {
+// return !(a == b);
+//}
+//
+//bool __operator != (const vec2 v, const vec2 u) {
+// return v.x != u.x || v.y != u.y;
+//}
+//
+//bool __operator != (const vec3 v, const vec3 u) {
+// return v.x != u.x || v.y != u.y || v.z != u.z;
+//}
+//
+//bool __operator != (const vec4 v, const vec4 u) {
+// return v.x != u.x || v.y != u.y || v.z != u.z || v.w != u.w;
+//}
+//
+//bool __operator != (const ivec2 v, const ivec2 u) {
+// return v.x != u.x || v.y != u.y;
+//}
+//
+//bool __operator != (const ivec3 v, const ivec3 u) {
+// return v.x != u.x || v.y != u.y || v.z != u.z;
+//}
+//
+//bool __operator != (const ivec4 v, const ivec4 u) {
+// return v.x != u.x || v.y != u.y || v.z != u.z || v.w != u.w;
+//}
+//
+//bool __operator != (const bvec2 v, const bvec2 u) {
+// return v.x != u.x || v.y != u.y;
+//}
+//
+//bool __operator != (const bvec3 v, const bvec3 u) {
+// return v.x != u.x || v.y != u.y || v.z != u.z;
+//}
+//
+//bool __operator != (const bvec4 v, const bvec4 u) {
+// return v.x != u.x || v.y != u.y || v.z != u.z || v.w != u.w;
+//}
+//
+//bool __operator != (const mat2 m, const mat2 n) {
+// return m[0] != n[0] || m[1] != n[1];
+//}
+//
+//bool __operator != (const mat3 m, const mat3 n) {
+// return m[0] != n[0] || m[1] != n[1] || m[2] != n[2];
+//}
+//
+//bool __operator != (const mat4 m, const mat4 n) {
+// return m[0] != n[0] || m[1] != n[1] || m[2] != n[2] || m[3] != n[3];
+//}
+
+bool __operator ^^ (const bool a, const bool b) {
+ return a != b;
+}
+
+//
+// These operators are handled internally by the compiler:
+//
+// bool __operator && (bool a, bool b) {
+// return a ? b : false;
+// }
+// bool __operator || (bool a, bool b) {
+// return a ? true : b;
+// }
+//
+
+bool __operator ! (const bool a) {
+ return a == false;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_core_gc.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_core_gc.h
new file mode 100644
index 000000000..c7f3d368a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_core_gc.h
@@ -0,0 +1,1565 @@
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"int __constructor (const float _f) {\n"
+" int _i;\n"
+" __asm float_to_int _i, _f;\n"
+" return _i;\n"
+"}\n"
+"\n"
+"bool __constructor (const int _i) {\n"
+" return _i != 0;\n"
+"}\n"
+"\n"
+"bool __constructor (const float _f) {\n"
+" return _f != 0.0;\n"
+"}\n"
+"\n"
+"int __constructor (const bool _b) {\n"
+" return _b ? 1 : 0;\n"
+"}\n"
+"\n"
+"float __constructor (const bool _b) {\n"
+" return _b ? 1.0 : 0.0;\n"
+"}\n"
+"\n"
+"float __constructor (const int _i) {\n"
+" float _f;\n"
+" __asm int_to_float _f, _i;\n"
+" return _f;\n"
+"}\n"
+"\n"
+"bool __constructor (const bool _b) {\n"
+" return _b;\n"
+"}\n"
+"\n"
+"int __constructor (const int _i) {\n"
+" return _i;\n"
+"}\n"
+"\n"
+"float __constructor (const float _f) {\n"
+" return _f;\n"
+"}\n"
+"\n"
+"vec2 __constructor (const float _f) {\n"
+" return vec2 (_f, _f);\n"
+"}\n"
+"\n"
+"vec2 __constructor (const int _i) {\n"
+" return vec2 (_i, _i);\n"
+"}\n"
+"\n"
+"vec2 __constructor (const bool _b) {\n"
+" return vec2 (_b, _b);\n"
+"}\n"
+"\n"
+"vec3 __constructor (const float _f) {\n"
+" return vec3 (_f, _f, _f);\n"
+"}\n"
+"\n"
+"vec3 __constructor (const int _i) {\n"
+" return vec3 (_i, _i, _i);\n"
+"}\n"
+"\n"
+"vec3 __constructor (const bool _b) {\n"
+" return vec3 (_b, _b, _b);\n"
+"}\n"
+"\n"
+"vec4 __constructor (const float _f) {\n"
+" return vec4 (_f, _f, _f, _f);\n"
+"}\n"
+"\n"
+"vec4 __constructor (const int _i) {\n"
+" return vec4 (_i, _i, _i, _i);\n"
+"}\n"
+"\n"
+"vec4 __constructor (const bool _b) {\n"
+" return vec4 (_b, _b, _b, _b);\n"
+"}\n"
+"\n"
+"ivec2 __constructor (const int _i) {\n"
+" return ivec2 (_i, _i);\n"
+"}\n"
+"\n"
+"ivec2 __constructor (const float _f) {\n"
+" return ivec2 (_f, _f);\n"
+"}\n"
+"\n"
+"ivec2 __constructor (const bool _b) {\n"
+" return ivec2 (_b, _b);\n"
+"}\n"
+"\n"
+"ivec3 __constructor (const int _i) {\n"
+" return ivec3 (_i, _i, _i);\n"
+"}\n"
+"\n"
+"ivec3 __constructor (const float _f) {\n"
+" return ivec3 (_f, _f, _f);\n"
+"}\n"
+"\n"
+"ivec3 __constructor (const bool _b) {\n"
+" return ivec3 (_b, _b, _b);\n"
+"}\n"
+"\n"
+"ivec4 __constructor (const int _i) {\n"
+" return ivec4 (_i, _i, _i, _i);\n"
+"}\n"
+"\n"
+"ivec4 __constructor (const float _f) {\n"
+" return ivec4 (_f, _f, _f, _f);\n"
+"}\n"
+"\n"
+"ivec4 __constructor (const bool _b) {\n"
+" return ivec4 (_b, _b, _b, _b);\n"
+"}\n"
+"\n"
+"bvec2 __constructor (const bool _b) {\n"
+" return bvec2 (_b, _b);\n"
+"}\n"
+"\n"
+"bvec2 __constructor (const float _f) {\n"
+" return bvec2 (_f, _f);\n"
+"}\n"
+"\n"
+"bvec2 __constructor (const int _i) {\n"
+" return bvec2 (_i, _i);\n"
+"}\n"
+"\n"
+"bvec3 __constructor (const bool _b) {\n"
+" return bvec3 (_b, _b, _b);\n"
+"}\n"
+"\n"
+"bvec3 __constructor (const float _f) {\n"
+" return bvec3 (_f, _f, _f);\n"
+"}\n"
+"\n"
+"bvec3 __constructor (const int _i) {\n"
+" return bvec3 (_i, _i, _i);\n"
+"}\n"
+"\n"
+"bvec4 __constructor (const bool _b) {\n"
+" return bvec4 (_b, _b, _b, _b);\n"
+"}\n"
+"\n"
+"bvec4 __constructor (const float _f) {\n"
+" return bvec4 (_f, _f, _f, _f);\n"
+"}\n"
+"\n"
+"bvec4 __constructor (const int _i) {\n"
+" return bvec4 (_i, _i, _i, _i);\n"
+"}\n"
+"\n"
+"mat2 __constructor (const float _f) {\n"
+" return mat2 (\n"
+" _f, .0,\n"
+" .0, _f\n"
+" );\n"
+"}\n"
+"\n"
+"mat2 __constructor (const int _i) {\n"
+" return mat2 (\n"
+" _i, .0,\n"
+" .0, _i\n"
+" );\n"
+"}\n"
+"\n"
+"mat2 __constructor (const bool _b) {\n"
+" return mat2 (\n"
+" _b, .0,\n"
+" .0, _b\n"
+" );\n"
+"}\n"
+"\n"
+"mat3 __constructor (const float _f) {\n"
+" return mat3 (\n"
+" _f, .0, .0,\n"
+" .0, _f, .0,\n"
+" .0, .0, _f\n"
+" );\n"
+"}\n"
+"\n"
+"mat3 __constructor (const int _i) {\n"
+" return mat3 (\n"
+" _i, .0, .0,\n"
+" .0, _i, .0,\n"
+" .0, .0, _i\n"
+" );\n"
+"}\n"
+"\n"
+"mat3 __constructor (const bool _b) {\n"
+" return mat3 (\n"
+" _b, .0, .0,\n"
+" .0, _b, .0,\n"
+" .0, .0, _b\n"
+" );\n"
+"}\n"
+"\n"
+"mat4 __constructor (const float _f) {\n"
+" return mat4 (\n"
+" _f, .0, .0, .0,\n"
+" .0, _f, .0, .0,\n"
+" .0, .0, _f, .0,\n"
+" .0, .0, .0, _f\n"
+" );\n"
+"}\n"
+"\n"
+"mat4 __constructor (const int _i) {\n"
+" return mat4 (\n"
+" _i, .0, .0, .0,\n"
+" .0, _i, .0, .0,\n"
+" .0, .0, _i, .0,\n"
+" .0, .0, .0, _i\n"
+" );\n"
+"}\n"
+"\n"
+"mat4 __constructor (const bool _b) {\n"
+" return mat4 (\n"
+" _b, .0, .0, .0,\n"
+" .0, _b, .0, .0,\n"
+" .0, .0, _b, .0,\n"
+" .0, .0, .0, _b\n"
+" );\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"void __operator += (inout float a, const float b) {\n"
+" __asm float_add a, a, b;\n"
+"}\n"
+"\n"
+"float __operator - (const float a) {\n"
+" float c;\n"
+" __asm float_negate c, a;\n"
+" return c;\n"
+"}\n"
+"\n"
+"void __operator -= (inout float a, const float b) {\n"
+" a += -b;\n"
+"}\n"
+"\n"
+"void __operator *= (inout float a, const float b) {\n"
+" __asm float_multiply a, a, b;\n"
+"}\n"
+"\n"
+"void __operator /= (inout float a, const float b) {\n"
+" __asm float_divide a, a, b;\n"
+"}\n"
+"\n"
+"float __operator + (const float a, const float b) {\n"
+" float c;\n"
+" c = a;\n"
+" return c += b;\n"
+"}\n"
+"\n"
+"void __operator += (inout int a, const int b) {\n"
+" a = int (float (a) + float (b));\n"
+"}\n"
+"\n"
+"int __operator - (const int a) {\n"
+" return int (-float (a));\n"
+"}\n"
+"\n"
+"void __operator -= (inout int a, const int b) {\n"
+" a += -b;\n"
+"}\n"
+"\n"
+"float __operator * (const float a, const float b) {\n"
+" float c;\n"
+" c = a;\n"
+" return c *= b;\n"
+"}\n"
+"\n"
+"void __operator *= (inout int a, const int b) {\n"
+" a = int (float (a) * float (b));\n"
+"}\n"
+"\n"
+"float __operator / (const float a, const float b) {\n"
+" float c;\n"
+" c = a;\n"
+" return c /= b;\n"
+"}\n"
+"\n"
+"void __operator /= (inout int a, const int b) {\n"
+" a = int (float (a) / float (b));\n"
+"}\n"
+"\n"
+"void __operator += (inout vec2 v, const vec2 u) {\n"
+" v.x += u.x, v.y += u.y;\n"
+"}\n"
+"\n"
+"void __operator -= (inout vec2 v, const vec2 u) {\n"
+" v.x -= u.x, v.y -= u.y;\n"
+"}\n"
+"\n"
+"void __operator *= (inout vec2 v, const vec2 u) {\n"
+" v.x *= u.x, v.y *= u.y;\n"
+"}\n"
+"\n"
+"void __operator /= (inout vec2 v, const vec2 u) {\n"
+" v.x /= u.x, v.y /= u.y;\n"
+"}\n"
+"\n"
+"void __operator += (inout vec3 v, const vec3 u) {\n"
+" v.x += u.x, v.y += u.y, v.z += u.z;\n"
+"}\n"
+"\n"
+"void __operator -= (inout vec3 v, const vec3 u) {\n"
+" v.x -= u.x, v.y -= u.y, v.z -= u.z;\n"
+"}\n"
+"\n"
+"void __operator *= (inout vec3 v, const vec3 u) {\n"
+" v.x *= u.x, v.y *= u.y, v.z *= u.z;\n"
+"}\n"
+"\n"
+"void __operator /= (inout vec3 v, const vec3 u) {\n"
+" v.x /= u.x, v.y /= u.y, v.z /= u.z;\n"
+"}\n"
+"\n"
+"void __operator += (inout vec4 v, const vec4 u) {\n"
+" v.x += u.x, v.y += u.y, v.z += u.z, v.w += u.w;\n"
+"}\n"
+"\n"
+"void __operator -= (inout vec4 v, const vec4 u) {\n"
+" v.x -= u.x, v.y -= u.y, v.z -= u.z, v.w -= u.w;\n"
+"}\n"
+"\n"
+"void __operator *= (inout vec4 v, const vec4 u) {\n"
+" v.x *= u.x, v.y *= u.y, v.z *= u.z, v.w *= u.w;\n"
+"}\n"
+"\n"
+"void __operator /= (inout vec4 v, const vec4 u) {\n"
+" v.x /= u.x, v.y /= u.y, v.z /= u.z, v.w /= u.w;\n"
+"}\n"
+"\n"
+"void __operator += (inout ivec2 v, const ivec2 u) {\n"
+" v.x += u.x, v.y += u.y;\n"
+"}\n"
+"\n"
+"void __operator -= (inout ivec2 v, const ivec2 u) {\n"
+" v.x -= u.x, v.y -= u.y;\n"
+"}\n"
+"\n"
+"void __operator *= (inout ivec2 v, const ivec2 u) {\n"
+" v.x *= u.x, v.y *= u.y;\n"
+"}\n"
+"\n"
+"void __operator /= (inout ivec2 v, const ivec2 u) {\n"
+" v.x /= u.x, v.y /= u.y;\n"
+"}\n"
+"\n"
+"void __operator += (inout ivec3 v, const ivec3 u) {\n"
+" v.x += u.x, v.y += u.y, v.z += u.z;\n"
+"}\n"
+"\n"
+"void __operator -= (inout ivec3 v, const ivec3 u) {\n"
+" v.x -= u.x, v.y -= u.y, v.z -= u.z;\n"
+"}\n"
+"\n"
+"void __operator *= (inout ivec3 v, const ivec3 u) {\n"
+" v.x *= u.x, v.y *= u.y, v.z *= u.z;\n"
+"}\n"
+"\n"
+"void __operator /= (inout ivec3 v, const ivec3 u) {\n"
+" v.x /= u.x, v.y /= u.y, v.z /= u.z;\n"
+"}\n"
+"\n"
+"void __operator += (inout ivec4 v, const ivec4 u) {\n"
+" v.x += u.x, v.y += u.y, v.z += u.z, v.w += u.w;\n"
+"}\n"
+"\n"
+"void __operator -= (inout ivec4 v, const ivec4 u) {\n"
+" v.x -= u.x, v.y -= u.y, v.z -= u.z, v.w -= u.w;\n"
+"}\n"
+"\n"
+"void __operator *= (inout ivec4 v, const ivec4 u) {\n"
+" v.x *= u.x, v.y *= u.y, v.z *= u.z, v.w *= u.w;\n"
+"}\n"
+"\n"
+"void __operator /= (inout ivec4 v, const ivec4 u) {\n"
+" v.x /= u.x, v.y /= u.y, v.z /= u.z, v.w /= u.w;\n"
+"}\n"
+"\n"
+"void __operator += (inout mat2 m, const mat2 n) {\n"
+" m[0] += n[0], m[1] += n[1];\n"
+"}\n"
+"\n"
+"void __operator -= (inout mat2 m, const mat2 n) {\n"
+" m[0] -= n[0], m[1] -= n[1];\n"
+"}\n"
+"\n"
+"vec2 __operator * (const mat2 m, const vec2 v) {\n"
+" return vec2 (\n"
+" v.x * m[0].x + v.y * m[1].x,\n"
+" v.x * m[0].y + v.y * m[1].y\n"
+" );\n"
+"}\n"
+"\n"
+"mat2 __operator * (const mat2 m, const mat2 n) {\n"
+" return mat2 (m * n[0], m * n[1]);\n"
+"}\n"
+"\n"
+"void __operator *= (inout mat2 m, const mat2 n) {\n"
+" m = m * n;\n"
+"}\n"
+"\n"
+"void __operator /= (inout mat2 m, const mat2 n) {\n"
+" m[0] /= n[0], m[1] /= n[1];\n"
+"}\n"
+"\n"
+"void __operator += (inout mat3 m, const mat3 n) {\n"
+" m[0] += n[0], m[1] += n[1], m[2] += n[2];\n"
+"}\n"
+"\n"
+"void __operator -= (inout mat3 m, const mat3 n) {\n"
+" m[0] -= n[0], m[1] -= n[1], m[2] -= n[2];\n"
+"}\n"
+"\n"
+"vec3 __operator * (const mat3 m, const vec3 v) {\n"
+" return vec3 (\n"
+" v.x * m[0].x + v.y * m[1].x + v.z * m[2].x,\n"
+" v.x * m[0].y + v.y * m[1].y + v.z * m[2].y,\n"
+" v.x * m[0].z + v.y * m[1].z + v.z * m[2].z\n"
+" );\n"
+"}\n"
+"\n"
+"mat3 __operator * (const mat3 m, const mat3 n) {\n"
+" return mat3 (m * n[0], m * n[1], m * n[2]);\n"
+"}\n"
+"\n"
+"void __operator *= (inout mat3 m, const mat3 n) {\n"
+" m = m * n;\n"
+"}\n"
+"\n"
+"void __operator /= (inout mat3 m, const mat3 n) {\n"
+" m[0] /= n[0], m[1] /= n[1], m[2] /= n[2];\n"
+"}\n"
+"\n"
+"void __operator += (inout mat4 m, const mat4 n) {\n"
+" m[0] += n[0], m[1] += n[1], m[2] += n[2], m[3] += n[3];\n"
+"}\n"
+"\n"
+"void __operator -= (inout mat4 m, const mat4 n) {\n"
+" m[0] -= n[0], m[1] -= n[1], m[2] -= n[2], m[3] -= n[3];\n"
+"}\n"
+"\n"
+"vec4 __operator * (const mat4 m, const vec4 v) {\n"
+" return vec4 (\n"
+" v.x * m[0].x + v.y * m[1].x + v.z * m[2].x + v.w * m[3].x,\n"
+" v.x * m[0].y + v.y * m[1].y + v.z * m[2].y + v.w * m[3].y,\n"
+" v.x * m[0].z + v.y * m[1].z + v.z * m[2].z + v.w * m[3].z,\n"
+" v.x * m[0].w + v.y * m[1].w + v.z * m[2].w + v.w * m[3].w\n"
+" );\n"
+"}\n"
+"\n"
+"mat4 __operator * (const mat4 m, const mat4 n) {\n"
+" return mat4 (m * n[0], m * n[1], m * n[2], m * n[3]);\n"
+"}\n"
+"\n"
+"void __operator *= (inout mat4 m, const mat4 n) {\n"
+" m = m * n;\n"
+"}\n"
+"\n"
+"void __operator /= (inout mat4 m, const mat4 n) {\n"
+" m[0] /= n[0], m[1] /= n[1], m[2] /= n[2], m[3] /= n[3];\n"
+"}\n"
+"\n"
+"void __operator += (inout vec2 v, const float a) {\n"
+" v.x += a, v.y += a;\n"
+"}\n"
+"\n"
+"void __operator -= (inout vec2 v, const float a) {\n"
+" v.x -= a, v.y -= a;\n"
+"}\n"
+"\n"
+"void __operator *= (inout vec2 v, const float a) {\n"
+" v.x *= a, v.y *= a;\n"
+"}\n"
+"\n"
+"void __operator /= (inout vec2 v, const float a) {\n"
+" v.x /= a, v.y /= a;\n"
+"}\n"
+"\n"
+"void __operator += (inout vec3 v, const float a) {\n"
+" v.x += a, v.y += a, v.z += a;\n"
+"}\n"
+"\n"
+"void __operator -= (inout vec3 v, const float a) {\n"
+" v.x -= a, v.y -= a, v.z -= a;\n"
+"}\n"
+"\n"
+"void __operator *= (inout vec3 v, const float a) {\n"
+" v.x *= a, v.y *= a, v.z *= a;\n"
+"}\n"
+"\n"
+"void __operator /= (inout vec3 v, const float a) {\n"
+" v.x /= a, v.y /= a, v.z /= a;\n"
+"}\n"
+"\n"
+"void __operator += (inout vec4 v, const float a) {\n"
+" v.x += a, v.y += a, v.z += a, v.w += a;\n"
+"}\n"
+"\n"
+"void __operator -= (inout vec4 v, const float a) {\n"
+" v.x -= a, v.y -= a, v.z -= a, v.w -= a;\n"
+"}\n"
+"\n"
+"void __operator *= (inout vec4 v, const float a) {\n"
+" v.x *= a, v.y *= a, v.z *= a, v.w *= a;\n"
+"}\n"
+"\n"
+"void __operator /= (inout vec4 v, const float a) {\n"
+" v.x /= a, v.y /= a, v.z /= a, v.w /= a;\n"
+"}\n"
+"\n"
+"void __operator += (inout mat2 m, const float a) {\n"
+" m[0] += a, m[1] += a;\n"
+"}\n"
+"\n"
+"void __operator -= (inout mat2 m, const float a) {\n"
+" m[0] -= a, m[1] -= a;\n"
+"}\n"
+"\n"
+"void __operator *= (inout mat2 m, const float a) {\n"
+" m[0] *= a, m[1] *= a;\n"
+"}\n"
+"\n"
+"void __operator /= (inout mat2 m, const float a) {\n"
+" m[0] /= a, m[1] /= a;\n"
+"}\n"
+"\n"
+"void __operator += (inout mat3 m, const float a) {\n"
+" m[0] += a, m[1] += a, m[2] += a;\n"
+"}\n"
+"\n"
+"void __operator -= (inout mat3 m, const float a) {\n"
+" m[0] -= a, m[1] -= a, m[2] -= a;\n"
+"}\n"
+"\n"
+"void __operator *= (inout mat3 m, const float a) {\n"
+" m[0] *= a, m[1] *= a, m[2] *= a;\n"
+"}\n"
+"\n"
+"void __operator /= (inout mat3 m, const float a) {\n"
+" m[0] /= a, m[1] /= a, m[2] /= a;\n"
+"}\n"
+"\n"
+"void __operator += (inout mat4 m, const float a) {\n"
+" m[0] += a, m[1] += a, m[2] += a, m[3] += a;\n"
+"}\n"
+"\n"
+"void __operator -= (inout mat4 m, const float a) {\n"
+" m[0] -= a, m[1] -= a, m[2] -= a, m[3] -= a;\n"
+"}\n"
+"\n"
+"void __operator *= (inout mat4 m, const float a) {\n"
+" m[0] *= a, m[1] *= a, m[2] *= a, m[3] *= a;\n"
+"}\n"
+"\n"
+"void __operator /= (inout mat4 m, const float a) {\n"
+" m[0] /= a, m[1] /= a, m[2] /= a, m[3] /= a;\n"
+"}\n"
+"\n"
+"vec2 __operator * (const vec2 v, const mat2 m) {\n"
+" return vec2 (\n"
+" v.x * m[0].x + v.y * m[0].y,\n"
+" v.x * m[1].x + v.y * m[1].y\n"
+" );\n"
+"}\n"
+"\n"
+"void __operator *= (inout vec2 v, const mat2 m) {\n"
+" v = v * m;\n"
+"}\n"
+"\n"
+"vec3 __operator * (const vec3 v, const mat3 m) {\n"
+" return vec3 (\n"
+" v.x * m[0].x + v.y * m[0].y + v.z * m[0].z,\n"
+" v.x * m[1].x + v.y * m[1].y + v.z * m[1].z,\n"
+" v.x * m[2].x + v.y * m[2].y + v.z * m[2].z\n"
+" );\n"
+"}\n"
+"\n"
+"void __operator *= (inout vec3 v, const mat3 m) {\n"
+" v = v * m;\n"
+"}\n"
+"\n"
+"vec4 __operator * (const vec4 v, const mat4 m) {\n"
+" return vec4 (\n"
+" v.x * m[0].x + v.y * m[0].y + v.z * m[0].z + v.w * m[0].w,\n"
+" v.x * m[1].x + v.y * m[1].y + v.z * m[1].z + v.w * m[1].w,\n"
+" v.x * m[2].x + v.y * m[2].y + v.z * m[2].z + v.w * m[2].w,\n"
+" v.x * m[3].x + v.y * m[3].y + v.z * m[3].z + v.w * m[3].w\n"
+" );\n"
+"}\n"
+"\n"
+"void __operator *= (inout vec4 v, const mat4 m) {\n"
+" v = v * m;\n"
+"}\n"
+"\n"
+"float __operator - (const float a, const float b) {\n"
+" return a + -b;\n"
+"}\n"
+"\n"
+"int __operator + (const int a, const int b) {\n"
+" int c;\n"
+" c = a;\n"
+" return c += b;\n"
+"}\n"
+"\n"
+"int __operator - (const int a, const int b) {\n"
+" return a + -b;\n"
+"}\n"
+"\n"
+"int __operator * (const int a, const int b) {\n"
+" int c;\n"
+" return (c = a) *= b;\n"
+"}\n"
+"\n"
+"int __operator / (const int a, const int b) {\n"
+" int c;\n"
+" return (c = a) /= b;\n"
+"}\n"
+"\n"
+"vec2 __operator + (const vec2 v, const vec2 u) {\n"
+" return vec2 (v.x + u.x, v.y + u.y);\n"
+"}\n"
+"\n"
+"vec2 __operator - (const vec2 v, const vec2 u) {\n"
+" return vec2 (v.x - u.x, v.y - u.y);\n"
+"}\n"
+"\n"
+"vec3 __operator + (const vec3 v, const vec3 u) {\n"
+" return vec3 (v.x + u.x, v.y + u.y, v.z + u.z);\n"
+"}\n"
+"\n"
+"vec3 __operator - (const vec3 v, const vec3 u) {\n"
+" return vec3 (v.x - u.x, v.y - u.y, v.z - u.z);\n"
+"}\n"
+"\n"
+"vec4 __operator + (const vec4 v, const vec4 u) {\n"
+" return vec4 (v.x + u.x, v.y + u.y, v.z + u.z, v.w + u.w);\n"
+"}\n"
+"\n"
+"vec4 __operator - (const vec4 v, const vec4 u) {\n"
+" return vec4 (v.x - u.x, v.y - u.y, v.z - u.z, v.w - u.w);\n"
+"}\n"
+"\n"
+"ivec2 __operator + (const ivec2 v, const ivec2 u) {\n"
+" return ivec2 (v.x + u.x, v.y + u.y);\n"
+"}\n"
+"\n"
+"ivec2 __operator - (const ivec2 v, const ivec2 u) {\n"
+" return ivec2 (v.x - u.x, v.y - u.y);\n"
+"}\n"
+"\n"
+"ivec3 __operator + (const ivec3 v, const ivec3 u) {\n"
+" return ivec3 (v.x + u.x, v.y + u.y, v.z + u.z);\n"
+"}\n"
+"\n"
+"ivec3 __operator - (const ivec3 v, const ivec3 u) {\n"
+" return ivec3 (v.x - u.x, v.y - u.y, v.z - u.z);\n"
+"}\n"
+"\n"
+"ivec4 __operator + (const ivec4 v, const ivec4 u) {\n"
+" return ivec4 (v.x + u.x, v.y + u.y, v.z + u.z, v.w + u.w);\n"
+"}\n"
+"\n"
+"ivec4 __operator - (const ivec4 v, const ivec4 u) {\n"
+" return ivec4 (v.x - u.x, v.y - u.y, v.z - u.z, v.w - u.w);\n"
+"}\n"
+"\n"
+"mat2 __operator + (const mat2 m, const mat2 n) {\n"
+" return mat2 (m[0] + n[0], m[1] + n[1]);\n"
+"}\n"
+"\n"
+"mat2 __operator - (const mat2 m, const mat2 n) {\n"
+" return mat2 (m[0] - n[0], m[1] - n[1]);\n"
+"}\n"
+"\n"
+"mat3 __operator + (const mat3 m, const mat3 n) {\n"
+" return mat3 (m[0] + n[0], m[1] + n[1], m[2] + n[2]);\n"
+"}\n"
+"\n"
+"mat3 __operator - (const mat3 m, const mat3 n) {\n"
+" return mat3 (m[0] - n[0], m[1] - n[1], m[2] - n[2]);\n"
+"}\n"
+"\n"
+"mat4 __operator + (const mat4 m, const mat4 n) {\n"
+" return mat4 (m[0] + n[0], m[1] + n[1], m[2] + n[2], m[3] + n[3]);\n"
+"}\n"
+"\n"
+"mat4 __operator - (const mat4 m, const mat4 n) {\n"
+" return mat4 (m[0] - n[0], m[1] - n[1], m[2] - n[2], m[3] - n[3]);\n"
+"}\n"
+"\n"
+"vec2 __operator + (const float a, const vec2 u) {\n"
+" return vec2 (a + u.x, a + u.y);\n"
+"}\n"
+"\n"
+"vec2 __operator + (const vec2 v, const float b) {\n"
+" return vec2 (v.x + b, v.y + b);\n"
+"}\n"
+"\n"
+"vec2 __operator - (const float a, const vec2 u) {\n"
+" return vec2 (a - u.x, a - u.y);\n"
+"}\n"
+"\n"
+"vec2 __operator - (const vec2 v, const float b) {\n"
+" return vec2 (v.x - b, v.y - b);\n"
+"}\n"
+"\n"
+"vec2 __operator * (const float a, const vec2 u) {\n"
+" return vec2 (a * u.x, a * u.y);\n"
+"}\n"
+"\n"
+"vec2 __operator * (const vec2 v, const float b) {\n"
+" return vec2 (v.x * b, v.y * b);\n"
+"}\n"
+"\n"
+"vec2 __operator / (const float a, const vec2 u) {\n"
+" return vec2 (a / u.x, a / u.y);\n"
+"}\n"
+"\n"
+"vec2 __operator / (const vec2 v, const float b) {\n"
+" return vec2 (v.x / b, v.y / b);\n"
+"}\n"
+"\n"
+"vec3 __operator + (const float a, const vec3 u) {\n"
+" return vec3 (a + u.x, a + u.y, a + u.z);\n"
+"}\n"
+"\n"
+"vec3 __operator + (const vec3 v, const float b) {\n"
+" return vec3 (v.x + b, v.y + b, v.z + b);\n"
+"}\n"
+"\n"
+"vec3 __operator - (const float a, const vec3 u) {\n"
+" return vec3 (a - u.x, a - u.y, a - u.z);\n"
+"}\n"
+"\n"
+"vec3 __operator - (const vec3 v, const float b) {\n"
+" return vec3 (v.x - b, v.y - b, v.z - b);\n"
+"}\n"
+"\n"
+"vec3 __operator * (const float a, const vec3 u) {\n"
+" return vec3 (a * u.x, a * u.y, a * u.z);\n"
+"}\n"
+"\n"
+"vec3 __operator * (const vec3 v, const float b) {\n"
+" return vec3 (v.x * b, v.y * b, v.z * b);\n"
+"}\n"
+"\n"
+"vec3 __operator / (const float a, const vec3 u) {\n"
+" return vec3 (a / u.x, a / u.y, a / u.z);\n"
+"}\n"
+"\n"
+"vec3 __operator / (const vec3 v, const float b) {\n"
+" return vec3 (v.x / b, v.y / b, v.z / b);\n"
+"}\n"
+"\n"
+"vec4 __operator + (const float a, const vec4 u) {\n"
+" return vec4 (a + u.x, a + u.y, a + u.z, a + u.w);\n"
+"}\n"
+"\n"
+"vec4 __operator + (const vec4 v, const float b) {\n"
+" return vec4 (v.x + b, v.y + b, v.z + b, v.w + b);\n"
+"}\n"
+"\n"
+"vec4 __operator - (const float a, const vec4 u) {\n"
+" return vec4 (a - u.x, a - u.y, a - u.z, a - u.w);\n"
+"}\n"
+"\n"
+"vec4 __operator - (const vec4 v, const float b) {\n"
+" return vec4 (v.x - b, v.y - b, v.z - b, v.w - b);\n"
+"}\n"
+"\n"
+"vec4 __operator * (const float a, const vec4 u) {\n"
+" return vec4 (a * u.x, a * u.y, a * u.z, a * u.w);\n"
+"}\n"
+"\n"
+"vec4 __operator * (const vec4 v, const float b) {\n"
+" return vec4 (v.x * b, v.y * b, v.z * b, v.w * b);\n"
+"}\n"
+"\n"
+"vec4 __operator / (const float a, const vec4 u) {\n"
+" return vec4 (a / u.x, a / u.y, a / u.z, a / u.w);\n"
+"}\n"
+"\n"
+"vec4 __operator / (const vec4 v, const float b) {\n"
+" return vec4 (v.x / b, v.y / b, v.z / b, v.w / b);\n"
+"}\n"
+"\n"
+"mat2 __operator + (const float a, const mat2 n) {\n"
+" return mat2 (a + n[0], a + n[1]);\n"
+"}\n"
+"\n"
+"mat2 __operator + (const mat2 m, const float b) {\n"
+" return mat2 (m[0] + b, m[1] + b);\n"
+"}\n"
+"\n"
+"mat2 __operator - (const float a, const mat2 n) {\n"
+" return mat2 (a - n[0], a - n[1]);\n"
+"}\n"
+"\n"
+"mat2 __operator - (const mat2 m, const float b) {\n"
+" return mat2 (m[0] - b, m[1] - b);\n"
+"}\n"
+"\n"
+"mat2 __operator * (const float a, const mat2 n) {\n"
+" return mat2 (a * n[0], a * n[1]);\n"
+"}\n"
+"\n"
+"mat2 __operator * (const mat2 m, const float b) {\n"
+" return mat2 (m[0] * b, m[1] * b);\n"
+"}\n"
+"\n"
+"mat2 __operator / (const float a, const mat2 n) {\n"
+" return mat2 (a / n[0], a / n[1]);\n"
+"}\n"
+"\n"
+"mat2 __operator / (const mat2 m, const float b) {\n"
+" return mat2 (m[0] / b, m[1] / b);\n"
+"}\n"
+"\n"
+"mat3 __operator + (const float a, const mat3 n) {\n"
+" return mat3 (a + n[0], a + n[1], a + n[2]);\n"
+"}\n"
+"\n"
+"mat3 __operator + (const mat3 m, const float b) {\n"
+" return mat3 (m[0] + b, m[1] + b, m[2] + b);\n"
+"}\n"
+"\n"
+"mat3 __operator - (const float a, const mat3 n) {\n"
+" return mat3 (a - n[0], a - n[1], a - n[2]);\n"
+"}\n"
+"\n"
+"mat3 __operator - (const mat3 m, const float b) {\n"
+" return mat3 (m[0] - b, m[1] - b, m[2] - b);\n"
+"}\n"
+"\n"
+"mat3 __operator * (const float a, const mat3 n) {\n"
+" return mat3 (a * n[0], a * n[1], a * n[2]);\n"
+"}\n"
+"\n"
+"mat3 __operator * (const mat3 m, const float b) {\n"
+" return mat3 (m[0] * b, m[1] * b, m[2] * b);\n"
+"}\n"
+"\n"
+"mat3 __operator / (const float a, const mat3 n) {\n"
+" return mat3 (a / n[0], a / n[1], a / n[2]);\n"
+"}\n"
+"\n"
+"mat3 __operator / (const mat3 m, const float b) {\n"
+" return mat3 (m[0] / b, m[1] / b, m[2] / b);\n"
+"}\n"
+"\n"
+"mat4 __operator + (const float a, const mat4 n) {\n"
+" return mat4 (a + n[0], a + n[1], a + n[2], a + n[3]);\n"
+"}\n"
+"\n"
+"mat4 __operator + (const mat4 m, const float b) {\n"
+" return mat4 (m[0] + b, m[1] + b, m[2] + b, m[3] + b);\n"
+"}\n"
+"\n"
+"mat4 __operator - (const float a, const mat4 n) {\n"
+" return mat4 (a - n[0], a - n[1], a - n[2], a - n[3]);\n"
+"}\n"
+"\n"
+"mat4 __operator - (const mat4 m, const float b) {\n"
+" return mat4 (m[0] - b, m[1] - b, m[2] - b, m[3] - b);\n"
+"}\n"
+"\n"
+"mat4 __operator * (const float a, const mat4 n) {\n"
+" return mat4 (a * n[0], a * n[1], a * n[2], a * n[3]);\n"
+"}\n"
+"\n"
+"mat4 __operator * (const mat4 m, const float b) {\n"
+" return mat4 (m[0] * b, m[1] * b, m[2] * b, m[3] * b);\n"
+"}\n"
+"\n"
+"mat4 __operator / (const float a, const mat4 n) {\n"
+" return mat4 (a / n[0], a / n[1], a / n[2], a / n[3]);\n"
+"}\n"
+"\n"
+"mat4 __operator / (const mat4 m, const float b) {\n"
+" return mat4 (m[0] / b, m[1] / b, m[2] / b, m[3] / b);\n"
+"}\n"
+"\n"
+"ivec2 __operator + (const int a, const ivec2 u) {\n"
+" return ivec2 (a + u.x, a + u.y);\n"
+"}\n"
+"\n"
+"ivec2 __operator + (const ivec2 v, const int b) {\n"
+" return ivec2 (v.x + b, v.y + b);\n"
+"}\n"
+"\n"
+"ivec2 __operator - (const int a, const ivec2 u) {\n"
+" return ivec2 (a - u.x, a - u.y);\n"
+"}\n"
+"\n"
+"ivec2 __operator - (const ivec2 v, const int b) {\n"
+" return ivec2 (v.x - b, v.y - b);\n"
+"}\n"
+"\n"
+"ivec2 __operator * (const int a, const ivec2 u) {\n"
+" return ivec2 (a * u.x, a * u.y);\n"
+"}\n"
+"\n"
+"ivec2 __operator * (const ivec2 v, const int b) {\n"
+" return ivec2 (v.x * b, v.y * b);\n"
+"}\n"
+"\n"
+"ivec2 __operator / (const int a, const ivec2 u) {\n"
+" return ivec2 (a / u.x, a / u.y);\n"
+"}\n"
+"\n"
+"ivec2 __operator / (const ivec2 v, const int b) {\n"
+" return ivec2 (v.x / b, v.y / b);\n"
+"}\n"
+"\n"
+"ivec3 __operator + (const int a, const ivec3 u) {\n"
+" return ivec3 (a + u.x, a + u.y, a + u.z);\n"
+"}\n"
+"\n"
+"ivec3 __operator + (const ivec3 v, const int b) {\n"
+" return ivec3 (v.x + b, v.y + b, v.z + b);\n"
+"}\n"
+"\n"
+"ivec3 __operator - (const int a, const ivec3 u) {\n"
+" return ivec3 (a - u.x, a - u.y, a - u.z);\n"
+"}\n"
+"\n"
+"ivec3 __operator - (const ivec3 v, const int b) {\n"
+" return ivec3 (v.x - b, v.y - b, v.z - b);\n"
+"}\n"
+"\n"
+"ivec3 __operator * (const int a, const ivec3 u) {\n"
+" return ivec3 (a * u.x, a * u.y, a * u.z);\n"
+"}\n"
+"\n"
+"ivec3 __operator * (const ivec3 v, const int b) {\n"
+" return ivec3 (v.x * b, v.y * b, v.z * b);\n"
+"}\n"
+"\n"
+"ivec3 __operator / (const int a, const ivec3 u) {\n"
+" return ivec3 (a / u.x, a / u.y, a / u.z);\n"
+"}\n"
+"\n"
+"ivec3 __operator / (const ivec3 v, const int b) {\n"
+" return ivec3 (v.x / b, v.y / b, v.z / b);\n"
+"}\n"
+"\n"
+"ivec4 __operator + (const int a, const ivec4 u) {\n"
+" return ivec4 (a + u.x, a + u.y, a + u.z, a + u.w);\n"
+"}\n"
+"\n"
+"ivec4 __operator + (const ivec4 v, const int b) {\n"
+" return ivec4 (v.x + b, v.y + b, v.z + b, v.w + b);\n"
+"}\n"
+"\n"
+"ivec4 __operator - (const int a, const ivec4 u) {\n"
+" return ivec4 (a - u.x, a - u.y, a - u.z, a - u.w);\n"
+"}\n"
+"\n"
+"ivec4 __operator - (const ivec4 v, const int b) {\n"
+" return ivec4 (v.x - b, v.y - b, v.z - b, v.w - b);\n"
+"}\n"
+"\n"
+"ivec4 __operator * (const int a, const ivec4 u) {\n"
+" return ivec4 (a * u.x, a * u.y, a * u.z, a * u.w);\n"
+"}\n"
+"\n"
+"ivec4 __operator * (const ivec4 v, const int b) {\n"
+" return ivec4 (v.x * b, v.y * b, v.z * b, v.w * b);\n"
+"}\n"
+"\n"
+"ivec4 __operator / (const int a, const ivec4 u) {\n"
+" return ivec4 (a / u.x, a / u.y, a / u.z, a / u.w);\n"
+"}\n"
+"\n"
+"ivec4 __operator / (const ivec4 v, const int b) {\n"
+" return ivec4 (v.x / b, v.y / b, v.z / b, v.w / b);\n"
+"}\n"
+"\n"
+"vec2 __operator * (const vec2 v, const vec2 u) {\n"
+" return vec2 (v.x * u.x, v.y * u.y);\n"
+"}\n"
+"\n"
+"vec3 __operator * (const vec3 v, const vec3 u) {\n"
+" return vec3 (v.x * u.x, v.y * u.y, v.z * u.z);\n"
+"}\n"
+"\n"
+"vec4 __operator * (const vec4 v, const vec4 u) {\n"
+" return vec4 (v.x * u.x, v.y * u.y, v.z * u.z, v.w * u.w);\n"
+"}\n"
+"\n"
+"ivec2 __operator * (const ivec2 v, const ivec2 u) {\n"
+" return ivec2 (v.x * u.x, v.y * u.y);\n"
+"}\n"
+"\n"
+"ivec3 __operator * (const ivec3 v, const ivec3 u) {\n"
+" return ivec3 (v.x * u.x, v.y * u.y, v.z * u.z);\n"
+"}\n"
+"\n"
+"ivec4 __operator * (const ivec4 v, const ivec4 u) {\n"
+" return ivec4 (v.x * u.x, v.y * u.y, v.z * u.z, v.w * u.w);\n"
+"}\n"
+"\n"
+"vec2 __operator / (const vec2 v, const vec2 u) {\n"
+" return vec2 (v.x / u.x, v.y / u.y);\n"
+"}\n"
+"\n"
+"vec3 __operator / (const vec3 v, const vec3 u) {\n"
+" return vec3 (v.x / u.x, v.y / u.y, v.z / u.z);\n"
+"}\n"
+"\n"
+"vec4 __operator / (const vec4 v, const vec4 u) {\n"
+" return vec4 (v.x / u.x, v.y / u.y, v.z / u.z, v.w / u.w);\n"
+"}\n"
+"\n"
+"ivec2 __operator / (const ivec2 v, const ivec2 u) {\n"
+" return ivec2 (v.x / u.x, v.y / u.y);\n"
+"}\n"
+"\n"
+"ivec3 __operator / (const ivec3 v, const ivec3 u) {\n"
+" return ivec3 (v.x / u.x, v.y / u.y, v.z / u.z);\n"
+"}\n"
+"\n"
+"ivec4 __operator / (const ivec4 v, const ivec4 u) {\n"
+" return ivec4 (v.x / u.x, v.y / u.y, v.z / u.z, v.w / u.w);\n"
+"}\n"
+"\n"
+"mat2 __operator / (const mat2 m, const mat2 n) {\n"
+" return mat2 (m[0] / n[0], m[1] / n[1]);\n"
+"}\n"
+"\n"
+"mat3 __operator / (const mat3 m, const mat3 n) {\n"
+" return mat3 (m[0] / n[0], m[1] / n[1], m[2] / n[2]);\n"
+"}\n"
+"\n"
+"mat4 __operator / (const mat4 m, const mat4 n) {\n"
+" return mat4 (m[0] / n[0], m[1] / n[1], m[2] / n[2], m[3] / n[3]);\n"
+"}\n"
+"\n"
+"vec2 __operator - (const vec2 v) {\n"
+" return vec2 (-v.x, -v.y);\n"
+"}\n"
+"\n"
+"vec3 __operator - (const vec3 v) {\n"
+" return vec3 (-v.x, -v.y, -v.z);\n"
+"}\n"
+"\n"
+"vec4 __operator - (const vec4 v) {\n"
+" return vec4 (-v.x, -v.y, -v.z, -v.w);\n"
+"}\n"
+"\n"
+"ivec2 __operator - (const ivec2 v) {\n"
+" return ivec2 (-v.x, -v.y);\n"
+"}\n"
+"\n"
+"ivec3 __operator - (const ivec3 v) {\n"
+" return ivec3 (-v.x, -v.y, -v.z);\n"
+"}\n"
+"\n"
+"ivec4 __operator - (const ivec4 v) {\n"
+" return ivec4 (-v.x, -v.y, -v.z, -v.w);\n"
+"}\n"
+"\n"
+"mat2 __operator - (const mat2 m) {\n"
+" return mat2 (-m[0], -m[1]);\n"
+"}\n"
+"\n"
+"mat3 __operator - (const mat3 m) {\n"
+" return mat3 (-m[0], -m[1], -m[2]);\n"
+"}\n"
+"\n"
+"mat4 __operator - (const mat4 m) {\n"
+" return mat4 (-m[0], -m[1], -m[2], -m[3]);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"void __operator -- (inout float a) {\n"
+" a -= 1.0;\n"
+"}\n"
+"\n"
+"void __operator -- (inout int a) {\n"
+" a -= 1;\n"
+"}\n"
+"\n"
+"void __operator -- (inout vec2 v) {\n"
+" --v.x, --v.y;\n"
+"}\n"
+"\n"
+"void __operator -- (inout vec3 v) {\n"
+" --v.x, --v.y, --v.z;\n"
+"}\n"
+"\n"
+"void __operator -- (inout vec4 v) {\n"
+" --v.x, --v.y, --v.z, --v.w;\n"
+"}\n"
+"\n"
+"void __operator -- (inout ivec2 v) {\n"
+" --v.x, --v.y;\n"
+"}\n"
+"\n"
+"void __operator -- (inout ivec3 v) {\n"
+" --v.x, --v.y, --v.z;\n"
+"}\n"
+"\n"
+"void __operator -- (inout ivec4 v) {\n"
+" --v.x, --v.y, --v.z, --v.w;\n"
+"}\n"
+"\n"
+"void __operator -- (inout mat2 m) {\n"
+" --m[0], --m[1];\n"
+"}\n"
+"\n"
+"void __operator -- (inout mat3 m) {\n"
+" --m[0], --m[1], --m[2];\n"
+"}\n"
+"\n"
+"void __operator -- (inout mat4 m) {\n"
+" --m[0], --m[1], --m[2], --m[3];\n"
+"}\n"
+"\n"
+"void __operator ++ (inout float a) {\n"
+" a += 1.0;\n"
+"}\n"
+"\n"
+"void __operator ++ (inout int a) {\n"
+" a += 1;\n"
+"}\n"
+"\n"
+"void __operator ++ (inout vec2 v) {\n"
+" ++v.x, ++v.y;\n"
+"}\n"
+"\n"
+"void __operator ++ (inout vec3 v) {\n"
+" ++v.x, ++v.y, ++v.z;\n"
+"}\n"
+"\n"
+"void __operator ++ (inout vec4 v) {\n"
+" ++v.x, ++v.y, ++v.z, ++v.w;\n"
+"}\n"
+"\n"
+"void __operator ++ (inout ivec2 v) {\n"
+" ++v.x, ++v.y;\n"
+"}\n"
+"\n"
+"void __operator ++ (inout ivec3 v) {\n"
+" ++v.x, ++v.y, ++v.z;\n"
+"}\n"
+"\n"
+"void __operator ++ (inout ivec4 v) {\n"
+" ++v.x, ++v.y, ++v.z, ++v.w;\n"
+"}\n"
+"\n"
+"void __operator ++ (inout mat2 m) {\n"
+" ++m[0], ++m[1];\n"
+"}\n"
+"\n"
+"void __operator ++ (inout mat3 m) {\n"
+" ++m[0], ++m[1], ++m[2];\n"
+"}\n"
+"\n"
+"void __operator ++ (inout mat4 m) {\n"
+" ++m[0], ++m[1], ++m[2], ++m[3];\n"
+"}\n"
+"\n"
+"float __operator -- (inout float a, const int) {\n"
+" float c;\n"
+" c = a;\n"
+" --a;\n"
+" return c;\n"
+"}\n"
+"\n"
+"int __operator -- (inout int a, const int) {\n"
+" int c;\n"
+" c = a;\n"
+" --a;\n"
+" return c;\n"
+"}\n"
+"\n"
+"vec2 __operator -- (inout vec2 v, const int) {\n"
+" return vec2 (v.x--, v.y--);\n"
+"}\n"
+"\n"
+"vec3 __operator -- (inout vec3 v, const int) {\n"
+" return vec3 (v.x--, v.y--, v.z--);\n"
+"}\n"
+"\n"
+"vec4 __operator -- (inout vec4 v, const int) {\n"
+" return vec4 (v.x--, v.y--, v.z--, v.w--);\n"
+"}\n"
+"\n"
+"ivec2 __operator -- (inout ivec2 v, const int) {\n"
+" return ivec2 (v.x--, v.y--);\n"
+"}\n"
+"\n"
+"ivec3 __operator -- (inout ivec3 v, const int) {\n"
+" return ivec3 (v.x--, v.y--, v.z--);\n"
+"}\n"
+"\n"
+"ivec4 __operator -- (inout ivec4 v, const int) {\n"
+" return ivec4 (v.x--, v.y--, v.z--, v.w--);\n"
+"}\n"
+"\n"
+"mat2 __operator -- (inout mat2 m, const int) {\n"
+" return mat2 (m[0]--, m[1]--);\n"
+"}\n"
+"\n"
+"mat3 __operator -- (inout mat3 m, const int) {\n"
+" return mat3 (m[0]--, m[1]--, m[2]--);\n"
+"}\n"
+"\n"
+"mat4 __operator -- (inout mat4 m, const int) {\n"
+" return mat4 (m[0]--, m[1]--, m[2]--, m[3]--);\n"
+"}\n"
+"\n"
+"float __operator ++ (inout float a, const int) {\n"
+" float c;\n"
+" c = a;\n"
+" ++a;\n"
+" return c;\n"
+"}\n"
+"\n"
+"int __operator ++ (inout int a, const int) {\n"
+" int c;\n"
+" c = a;\n"
+" ++a;\n"
+" return c;\n"
+"}\n"
+"\n"
+"vec2 __operator ++ (inout vec2 v, const int) {\n"
+" return vec2 (v.x++, v.y++);\n"
+"}\n"
+"\n"
+"vec3 __operator ++ (inout vec3 v, const int) {\n"
+" return vec3 (v.x++, v.y++, v.z++);\n"
+"}\n"
+"\n"
+"vec4 __operator ++ (inout vec4 v, const int) {\n"
+" return vec4 (v.x++, v.y++, v.z++, v.w++);\n"
+"}\n"
+"\n"
+"ivec2 __operator ++ (inout ivec2 v, const int) {\n"
+" return ivec2 (v.x++, v.y++);\n"
+"}\n"
+"\n"
+"ivec3 __operator ++ (inout ivec3 v, const int) {\n"
+" return ivec3 (v.x++, v.y++, v.z++);\n"
+"}\n"
+"\n"
+"ivec4 __operator ++ (inout ivec4 v, const int) {\n"
+" return ivec4 (v.x++, v.y++, v.z++, v.w++);\n"
+"}\n"
+"\n"
+"mat2 __operator ++ (inout mat2 m, const int) {\n"
+" return mat2 (m[0]++, m[1]++);\n"
+"}\n"
+"\n"
+"mat3 __operator ++ (inout mat3 m, const int) {\n"
+" return mat3 (m[0]++, m[1]++, m[2]++);\n"
+"}\n"
+"\n"
+"mat4 __operator ++ (inout mat4 m, const int) {\n"
+" return mat4 (m[0]++, m[1]++, m[2]++, m[3]++);\n"
+"}\n"
+"\n"
+"bool __operator < (const float a, const float b) {\n"
+" bool c;\n"
+" __asm float_less c, a, b;\n"
+" return c;\n"
+"}\n"
+"\n"
+"bool __operator < (const int a, const int b) {\n"
+" return float (a) < float (b);\n"
+"}\n"
+"\n"
+"bool __operator > (const float a, const float b) {\n"
+" return b < a;\n"
+"}\n"
+"\n"
+"bool __operator > (const int a, const int b) {\n"
+" return b < a;\n"
+"}\n"
+"\n"
+"bool __operator >= (const float a, const float b) {\n"
+" return a > b || a == b;\n"
+"}\n"
+"\n"
+"bool __operator >= (const int a, const int b) {\n"
+" return a > b || a == b;\n"
+"}\n"
+"\n"
+"bool __operator <= (const float a, const float b) {\n"
+" return a < b || a == b;\n"
+"}\n"
+"\n"
+"bool __operator <= (const int a, const int b) {\n"
+" return a < b || a == b;\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"bool __operator ^^ (const bool a, const bool b) {\n"
+" return a != b;\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"bool __operator ! (const bool a) {\n"
+" return a == false;\n"
+"}\n"
+"\n"
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_core_gc_bin.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_core_gc_bin.h
new file mode 100755
index 000000000..ac53ceea8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_core_gc_bin.h
@@ -0,0 +1,490 @@
+2,1,0,5,1,1,1,0,9,95,102,0,0,0,1,3,2,0,5,1,95,105,0,0,0,4,102,108,111,97,116,95,116,111,95,105,110,
+116,0,18,95,105,0,0,18,95,102,0,0,0,8,18,95,105,0,0,0,1,0,1,1,1,1,0,5,95,105,0,0,0,1,8,18,95,105,0,
+16,8,48,0,39,0,0,1,0,1,1,1,1,0,9,95,102,0,0,0,1,8,18,95,102,0,17,48,0,48,0,0,39,0,0,1,0,5,1,1,1,0,1,
+95,98,0,0,0,1,8,18,95,98,0,16,10,49,0,16,8,48,0,31,0,0,1,0,9,1,1,1,0,1,95,98,0,0,0,1,8,18,95,98,0,
+17,49,0,48,0,0,17,48,0,48,0,0,31,0,0,1,0,9,1,1,1,0,5,95,105,0,0,0,1,3,2,0,9,1,95,102,0,0,0,4,105,
+110,116,95,116,111,95,102,108,111,97,116,0,18,95,102,0,0,18,95,105,0,0,0,8,18,95,102,0,0,0,1,0,1,1,
+1,1,0,1,95,98,0,0,0,1,8,18,95,98,0,0,0,1,0,5,1,1,1,0,5,95,105,0,0,0,1,8,18,95,105,0,0,0,1,0,9,1,1,1,
+0,9,95,102,0,0,0,1,8,18,95,102,0,0,0,1,0,10,1,1,1,0,9,95,102,0,0,0,1,8,58,118,101,99,50,0,18,95,102,
+0,0,18,95,102,0,0,0,0,0,1,0,10,1,1,1,0,5,95,105,0,0,0,1,8,58,118,101,99,50,0,18,95,105,0,0,18,95,
+105,0,0,0,0,0,1,0,10,1,1,1,0,1,95,98,0,0,0,1,8,58,118,101,99,50,0,18,95,98,0,0,18,95,98,0,0,0,0,0,1,
+0,11,1,1,1,0,9,95,102,0,0,0,1,8,58,118,101,99,51,0,18,95,102,0,0,18,95,102,0,0,18,95,102,0,0,0,0,0,
+1,0,11,1,1,1,0,5,95,105,0,0,0,1,8,58,118,101,99,51,0,18,95,105,0,0,18,95,105,0,0,18,95,105,0,0,0,0,
+0,1,0,11,1,1,1,0,1,95,98,0,0,0,1,8,58,118,101,99,51,0,18,95,98,0,0,18,95,98,0,0,18,95,98,0,0,0,0,0,
+1,0,12,1,1,1,0,9,95,102,0,0,0,1,8,58,118,101,99,52,0,18,95,102,0,0,18,95,102,0,0,18,95,102,0,0,18,
+95,102,0,0,0,0,0,1,0,12,1,1,1,0,5,95,105,0,0,0,1,8,58,118,101,99,52,0,18,95,105,0,0,18,95,105,0,0,
+18,95,105,0,0,18,95,105,0,0,0,0,0,1,0,12,1,1,1,0,1,95,98,0,0,0,1,8,58,118,101,99,52,0,18,95,98,0,0,
+18,95,98,0,0,18,95,98,0,0,18,95,98,0,0,0,0,0,1,0,6,1,1,1,0,5,95,105,0,0,0,1,8,58,105,118,101,99,50,
+0,18,95,105,0,0,18,95,105,0,0,0,0,0,1,0,6,1,1,1,0,9,95,102,0,0,0,1,8,58,105,118,101,99,50,0,18,95,
+102,0,0,18,95,102,0,0,0,0,0,1,0,6,1,1,1,0,1,95,98,0,0,0,1,8,58,105,118,101,99,50,0,18,95,98,0,0,18,
+95,98,0,0,0,0,0,1,0,7,1,1,1,0,5,95,105,0,0,0,1,8,58,105,118,101,99,51,0,18,95,105,0,0,18,95,105,0,0,
+18,95,105,0,0,0,0,0,1,0,7,1,1,1,0,9,95,102,0,0,0,1,8,58,105,118,101,99,51,0,18,95,102,0,0,18,95,102,
+0,0,18,95,102,0,0,0,0,0,1,0,7,1,1,1,0,1,95,98,0,0,0,1,8,58,105,118,101,99,51,0,18,95,98,0,0,18,95,
+98,0,0,18,95,98,0,0,0,0,0,1,0,8,1,1,1,0,5,95,105,0,0,0,1,8,58,105,118,101,99,52,0,18,95,105,0,0,18,
+95,105,0,0,18,95,105,0,0,18,95,105,0,0,0,0,0,1,0,8,1,1,1,0,9,95,102,0,0,0,1,8,58,105,118,101,99,52,
+0,18,95,102,0,0,18,95,102,0,0,18,95,102,0,0,18,95,102,0,0,0,0,0,1,0,8,1,1,1,0,1,95,98,0,0,0,1,8,58,
+105,118,101,99,52,0,18,95,98,0,0,18,95,98,0,0,18,95,98,0,0,18,95,98,0,0,0,0,0,1,0,2,1,1,1,0,1,95,98,
+0,0,0,1,8,58,98,118,101,99,50,0,18,95,98,0,0,18,95,98,0,0,0,0,0,1,0,2,1,1,1,0,9,95,102,0,0,0,1,8,58,
+98,118,101,99,50,0,18,95,102,0,0,18,95,102,0,0,0,0,0,1,0,2,1,1,1,0,5,95,105,0,0,0,1,8,58,98,118,101,
+99,50,0,18,95,105,0,0,18,95,105,0,0,0,0,0,1,0,3,1,1,1,0,1,95,98,0,0,0,1,8,58,98,118,101,99,51,0,18,
+95,98,0,0,18,95,98,0,0,18,95,98,0,0,0,0,0,1,0,3,1,1,1,0,9,95,102,0,0,0,1,8,58,98,118,101,99,51,0,18,
+95,102,0,0,18,95,102,0,0,18,95,102,0,0,0,0,0,1,0,3,1,1,1,0,5,95,105,0,0,0,1,8,58,98,118,101,99,51,0,
+18,95,105,0,0,18,95,105,0,0,18,95,105,0,0,0,0,0,1,0,4,1,1,1,0,1,95,98,0,0,0,1,8,58,98,118,101,99,52,
+0,18,95,98,0,0,18,95,98,0,0,18,95,98,0,0,18,95,98,0,0,0,0,0,1,0,4,1,1,1,0,9,95,102,0,0,0,1,8,58,98,
+118,101,99,52,0,18,95,102,0,0,18,95,102,0,0,18,95,102,0,0,18,95,102,0,0,0,0,0,1,0,4,1,1,1,0,5,95,
+105,0,0,0,1,8,58,98,118,101,99,52,0,18,95,105,0,0,18,95,105,0,0,18,95,105,0,0,18,95,105,0,0,0,0,0,1,
+0,13,1,1,1,0,9,95,102,0,0,0,1,8,58,109,97,116,50,0,18,95,102,0,0,17,0,48,0,0,0,17,0,48,0,0,0,18,95,
+102,0,0,0,0,0,1,0,13,1,1,1,0,5,95,105,0,0,0,1,8,58,109,97,116,50,0,18,95,105,0,0,17,0,48,0,0,0,17,0,
+48,0,0,0,18,95,105,0,0,0,0,0,1,0,13,1,1,1,0,1,95,98,0,0,0,1,8,58,109,97,116,50,0,18,95,98,0,0,17,0,
+48,0,0,0,17,0,48,0,0,0,18,95,98,0,0,0,0,0,1,0,14,1,1,1,0,9,95,102,0,0,0,1,8,58,109,97,116,51,0,18,
+95,102,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,48,0,0,0,18,95,102,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,
+48,0,0,0,18,95,102,0,0,0,0,0,1,0,14,1,1,1,0,5,95,105,0,0,0,1,8,58,109,97,116,51,0,18,95,105,0,0,17,
+0,48,0,0,0,17,0,48,0,0,0,17,0,48,0,0,0,18,95,105,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,48,0,0,0,18,
+95,105,0,0,0,0,0,1,0,14,1,1,1,0,1,95,98,0,0,0,1,8,58,109,97,116,51,0,18,95,98,0,0,17,0,48,0,0,0,17,
+0,48,0,0,0,17,0,48,0,0,0,18,95,98,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,48,0,0,0,18,95,98,0,0,0,0,0,
+1,0,15,1,1,1,0,9,95,102,0,0,0,1,8,58,109,97,116,52,0,18,95,102,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,
+48,0,0,0,17,0,48,0,0,0,18,95,102,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,48,0,0,0,18,95,
+102,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,48,0,0,0,18,95,102,0,0,0,0,0,1,0,15,1,1,1,0,
+5,95,105,0,0,0,1,8,58,109,97,116,52,0,18,95,105,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,
+48,0,0,0,18,95,105,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,48,0,0,0,18,95,105,0,0,17,0,
+48,0,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,48,0,0,0,18,95,105,0,0,0,0,0,1,0,15,1,1,1,0,1,95,98,0,0,0,
+1,8,58,109,97,116,52,0,18,95,98,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,48,0,0,0,18,95,
+98,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,48,0,0,0,17,0,48,0,0,0,18,95,98,0,0,17,0,48,0,0,0,17,0,48,0,
+0,0,17,0,48,0,0,0,17,0,48,0,0,0,18,95,98,0,0,0,0,0,1,0,0,2,2,1,0,2,9,97,0,0,1,1,0,9,98,0,0,0,1,4,
+102,108,111,97,116,95,97,100,100,0,18,97,0,0,18,97,0,0,18,98,0,0,0,0,1,0,9,2,30,1,1,0,9,97,0,0,0,1,
+3,2,0,9,1,99,0,0,0,4,102,108,111,97,116,95,110,101,103,97,116,101,0,18,99,0,0,18,97,0,0,0,8,18,99,0,
+0,0,1,0,0,2,3,1,0,2,9,97,0,0,1,1,0,9,98,0,0,0,1,9,18,97,0,18,98,0,54,21,0,0,1,0,0,2,4,1,0,2,9,97,0,
+0,1,1,0,9,98,0,0,0,1,4,102,108,111,97,116,95,109,117,108,116,105,112,108,121,0,18,97,0,0,18,97,0,0,
+18,98,0,0,0,0,1,0,0,2,5,1,0,2,9,97,0,0,1,1,0,9,98,0,0,0,1,4,102,108,111,97,116,95,100,105,118,105,
+100,101,0,18,97,0,0,18,97,0,0,18,98,0,0,0,0,1,0,9,2,29,1,1,0,9,97,0,0,1,1,0,9,98,0,0,0,1,3,2,0,9,1,
+99,0,0,0,9,18,99,0,18,97,0,20,0,8,18,99,0,18,98,0,21,0,0,1,0,0,2,2,1,0,2,5,97,0,0,1,1,0,5,98,0,0,0,
+1,9,18,97,0,58,105,110,116,0,58,102,108,111,97,116,0,18,97,0,0,0,58,102,108,111,97,116,0,18,98,0,0,
+0,46,0,0,20,0,0,1,0,5,2,30,1,1,0,5,97,0,0,0,1,8,58,105,110,116,0,58,102,108,111,97,116,0,18,97,0,0,
+0,54,0,0,0,0,1,0,0,2,3,1,0,2,5,97,0,0,1,1,0,5,98,0,0,0,1,9,18,97,0,18,98,0,54,21,0,0,1,0,9,2,24,1,1,
+0,9,97,0,0,1,1,0,9,98,0,0,0,1,3,2,0,9,1,99,0,0,0,9,18,99,0,18,97,0,20,0,8,18,99,0,18,98,0,23,0,0,1,
+0,0,2,4,1,0,2,5,97,0,0,1,1,0,5,98,0,0,0,1,9,18,97,0,58,105,110,116,0,58,102,108,111,97,116,0,18,97,
+0,0,0,58,102,108,111,97,116,0,18,98,0,0,0,48,0,0,20,0,0,1,0,9,2,25,1,1,0,9,97,0,0,1,1,0,9,98,0,0,0,
+1,3,2,0,9,1,99,0,0,0,9,18,99,0,18,97,0,20,0,8,18,99,0,18,98,0,24,0,0,1,0,0,2,5,1,0,2,5,97,0,0,1,1,0,
+5,98,0,0,0,1,9,18,97,0,58,105,110,116,0,58,102,108,111,97,116,0,18,97,0,0,0,58,102,108,111,97,116,0,
+18,98,0,0,0,49,0,0,20,0,0,1,0,0,2,2,1,0,2,10,118,0,0,1,1,0,10,117,0,0,0,1,9,18,118,0,59,120,0,18,
+117,0,59,120,0,21,18,118,0,59,121,0,18,117,0,59,121,0,21,19,0,0,1,0,0,2,3,1,0,2,10,118,0,0,1,1,0,10,
+117,0,0,0,1,9,18,118,0,59,120,0,18,117,0,59,120,0,22,18,118,0,59,121,0,18,117,0,59,121,0,22,19,0,0,
+1,0,0,2,4,1,0,2,10,118,0,0,1,1,0,10,117,0,0,0,1,9,18,118,0,59,120,0,18,117,0,59,120,0,23,18,118,0,
+59,121,0,18,117,0,59,121,0,23,19,0,0,1,0,0,2,5,1,0,2,10,118,0,0,1,1,0,10,117,0,0,0,1,9,18,118,0,59,
+120,0,18,117,0,59,120,0,24,18,118,0,59,121,0,18,117,0,59,121,0,24,19,0,0,1,0,0,2,2,1,0,2,11,118,0,0,
+1,1,0,11,117,0,0,0,1,9,18,118,0,59,120,0,18,117,0,59,120,0,21,18,118,0,59,121,0,18,117,0,59,121,0,
+21,19,18,118,0,59,122,0,18,117,0,59,122,0,21,19,0,0,1,0,0,2,3,1,0,2,11,118,0,0,1,1,0,11,117,0,0,0,1,
+9,18,118,0,59,120,0,18,117,0,59,120,0,22,18,118,0,59,121,0,18,117,0,59,121,0,22,19,18,118,0,59,122,
+0,18,117,0,59,122,0,22,19,0,0,1,0,0,2,4,1,0,2,11,118,0,0,1,1,0,11,117,0,0,0,1,9,18,118,0,59,120,0,
+18,117,0,59,120,0,23,18,118,0,59,121,0,18,117,0,59,121,0,23,19,18,118,0,59,122,0,18,117,0,59,122,0,
+23,19,0,0,1,0,0,2,5,1,0,2,11,118,0,0,1,1,0,11,117,0,0,0,1,9,18,118,0,59,120,0,18,117,0,59,120,0,24,
+18,118,0,59,121,0,18,117,0,59,121,0,24,19,18,118,0,59,122,0,18,117,0,59,122,0,24,19,0,0,1,0,0,2,2,1,
+0,2,12,118,0,0,1,1,0,12,117,0,0,0,1,9,18,118,0,59,120,0,18,117,0,59,120,0,21,18,118,0,59,121,0,18,
+117,0,59,121,0,21,19,18,118,0,59,122,0,18,117,0,59,122,0,21,19,18,118,0,59,119,0,18,117,0,59,119,0,
+21,19,0,0,1,0,0,2,3,1,0,2,12,118,0,0,1,1,0,12,117,0,0,0,1,9,18,118,0,59,120,0,18,117,0,59,120,0,22,
+18,118,0,59,121,0,18,117,0,59,121,0,22,19,18,118,0,59,122,0,18,117,0,59,122,0,22,19,18,118,0,59,119,
+0,18,117,0,59,119,0,22,19,0,0,1,0,0,2,4,1,0,2,12,118,0,0,1,1,0,12,117,0,0,0,1,9,18,118,0,59,120,0,
+18,117,0,59,120,0,23,18,118,0,59,121,0,18,117,0,59,121,0,23,19,18,118,0,59,122,0,18,117,0,59,122,0,
+23,19,18,118,0,59,119,0,18,117,0,59,119,0,23,19,0,0,1,0,0,2,5,1,0,2,12,118,0,0,1,1,0,12,117,0,0,0,1,
+9,18,118,0,59,120,0,18,117,0,59,120,0,24,18,118,0,59,121,0,18,117,0,59,121,0,24,19,18,118,0,59,122,
+0,18,117,0,59,122,0,24,19,18,118,0,59,119,0,18,117,0,59,119,0,24,19,0,0,1,0,0,2,2,1,0,2,6,118,0,0,1,
+1,0,6,117,0,0,0,1,9,18,118,0,59,120,0,18,117,0,59,120,0,21,18,118,0,59,121,0,18,117,0,59,121,0,21,
+19,0,0,1,0,0,2,3,1,0,2,6,118,0,0,1,1,0,6,117,0,0,0,1,9,18,118,0,59,120,0,18,117,0,59,120,0,22,18,
+118,0,59,121,0,18,117,0,59,121,0,22,19,0,0,1,0,0,2,4,1,0,2,6,118,0,0,1,1,0,6,117,0,0,0,1,9,18,118,0,
+59,120,0,18,117,0,59,120,0,23,18,118,0,59,121,0,18,117,0,59,121,0,23,19,0,0,1,0,0,2,5,1,0,2,6,118,0,
+0,1,1,0,6,117,0,0,0,1,9,18,118,0,59,120,0,18,117,0,59,120,0,24,18,118,0,59,121,0,18,117,0,59,121,0,
+24,19,0,0,1,0,0,2,2,1,0,2,7,118,0,0,1,1,0,7,117,0,0,0,1,9,18,118,0,59,120,0,18,117,0,59,120,0,21,18,
+118,0,59,121,0,18,117,0,59,121,0,21,19,18,118,0,59,122,0,18,117,0,59,122,0,21,19,0,0,1,0,0,2,3,1,0,
+2,7,118,0,0,1,1,0,7,117,0,0,0,1,9,18,118,0,59,120,0,18,117,0,59,120,0,22,18,118,0,59,121,0,18,117,0,
+59,121,0,22,19,18,118,0,59,122,0,18,117,0,59,122,0,22,19,0,0,1,0,0,2,4,1,0,2,7,118,0,0,1,1,0,7,117,
+0,0,0,1,9,18,118,0,59,120,0,18,117,0,59,120,0,23,18,118,0,59,121,0,18,117,0,59,121,0,23,19,18,118,0,
+59,122,0,18,117,0,59,122,0,23,19,0,0,1,0,0,2,5,1,0,2,7,118,0,0,1,1,0,7,117,0,0,0,1,9,18,118,0,59,
+120,0,18,117,0,59,120,0,24,18,118,0,59,121,0,18,117,0,59,121,0,24,19,18,118,0,59,122,0,18,117,0,59,
+122,0,24,19,0,0,1,0,0,2,2,1,0,2,8,118,0,0,1,1,0,8,117,0,0,0,1,9,18,118,0,59,120,0,18,117,0,59,120,0,
+21,18,118,0,59,121,0,18,117,0,59,121,0,21,19,18,118,0,59,122,0,18,117,0,59,122,0,21,19,18,118,0,59,
+119,0,18,117,0,59,119,0,21,19,0,0,1,0,0,2,3,1,0,2,8,118,0,0,1,1,0,8,117,0,0,0,1,9,18,118,0,59,120,0,
+18,117,0,59,120,0,22,18,118,0,59,121,0,18,117,0,59,121,0,22,19,18,118,0,59,122,0,18,117,0,59,122,0,
+22,19,18,118,0,59,119,0,18,117,0,59,119,0,22,19,0,0,1,0,0,2,4,1,0,2,8,118,0,0,1,1,0,8,117,0,0,0,1,9,
+18,118,0,59,120,0,18,117,0,59,120,0,23,18,118,0,59,121,0,18,117,0,59,121,0,23,19,18,118,0,59,122,0,
+18,117,0,59,122,0,23,19,18,118,0,59,119,0,18,117,0,59,119,0,23,19,0,0,1,0,0,2,5,1,0,2,8,118,0,0,1,1,
+0,8,117,0,0,0,1,9,18,118,0,59,120,0,18,117,0,59,120,0,24,18,118,0,59,121,0,18,117,0,59,121,0,24,19,
+18,118,0,59,122,0,18,117,0,59,122,0,24,19,18,118,0,59,119,0,18,117,0,59,119,0,24,19,0,0,1,0,0,2,2,1,
+0,2,13,109,0,0,1,1,0,13,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,21,18,109,0,16,10,
+49,0,57,18,110,0,16,10,49,0,57,21,19,0,0,1,0,0,2,3,1,0,2,13,109,0,0,1,1,0,13,110,0,0,0,1,9,18,109,0,
+16,8,48,0,57,18,110,0,16,8,48,0,57,22,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,22,19,0,0,1,0,
+10,2,24,1,1,0,13,109,0,0,1,1,0,10,118,0,0,0,1,8,58,118,101,99,50,0,18,118,0,59,120,0,18,109,0,16,8,
+48,0,57,59,120,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,120,0,48,46,0,18,118,0,59,120,0,18,
+109,0,16,8,48,0,57,59,121,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,121,0,48,46,0,0,0,0,1,0,
+13,2,24,1,1,0,13,109,0,0,1,1,0,13,110,0,0,0,1,8,58,109,97,116,50,0,18,109,0,18,110,0,16,8,48,0,57,
+48,0,18,109,0,18,110,0,16,10,49,0,57,48,0,0,0,0,1,0,0,2,4,1,0,2,13,109,0,0,1,1,0,13,110,0,0,0,1,9,
+18,109,0,18,109,0,18,110,0,48,20,0,0,1,0,0,2,5,1,0,2,13,109,0,0,1,1,0,13,110,0,0,0,1,9,18,109,0,16,
+8,48,0,57,18,110,0,16,8,48,0,57,24,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,24,19,0,0,1,0,0,2,
+2,1,0,2,14,109,0,0,1,1,0,14,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,21,18,109,0,
+16,10,49,0,57,18,110,0,16,10,49,0,57,21,19,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,21,19,0,0,
+1,0,0,2,3,1,0,2,14,109,0,0,1,1,0,14,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,22,18,
+109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,22,19,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,22,
+19,0,0,1,0,11,2,24,1,1,0,14,109,0,0,1,1,0,11,118,0,0,0,1,8,58,118,101,99,51,0,18,118,0,59,120,0,18,
+109,0,16,8,48,0,57,59,120,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,120,0,48,46,18,118,0,59,
+122,0,18,109,0,16,10,50,0,57,59,120,0,48,46,0,18,118,0,59,120,0,18,109,0,16,8,48,0,57,59,121,0,48,
+18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,121,0,48,46,18,118,0,59,122,0,18,109,0,16,10,50,0,57,59,
+121,0,48,46,0,18,118,0,59,120,0,18,109,0,16,8,48,0,57,59,122,0,48,18,118,0,59,121,0,18,109,0,16,10,
+49,0,57,59,122,0,48,46,18,118,0,59,122,0,18,109,0,16,10,50,0,57,59,122,0,48,46,0,0,0,0,1,0,14,2,24,
+1,1,0,14,109,0,0,1,1,0,14,110,0,0,0,1,8,58,109,97,116,51,0,18,109,0,18,110,0,16,8,48,0,57,48,0,18,
+109,0,18,110,0,16,10,49,0,57,48,0,18,109,0,18,110,0,16,10,50,0,57,48,0,0,0,0,1,0,0,2,4,1,0,2,14,109,
+0,0,1,1,0,14,110,0,0,0,1,9,18,109,0,18,109,0,18,110,0,48,20,0,0,1,0,0,2,5,1,0,2,14,109,0,0,1,1,0,14,
+110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,24,18,109,0,16,10,49,0,57,18,110,0,16,10,
+49,0,57,24,19,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,24,19,0,0,1,0,0,2,2,1,0,2,15,109,0,0,1,
+1,0,15,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,21,18,109,0,16,10,49,0,57,18,110,0,
+16,10,49,0,57,21,19,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,21,19,18,109,0,16,10,51,0,57,18,
+110,0,16,10,51,0,57,21,19,0,0,1,0,0,2,3,1,0,2,15,109,0,0,1,1,0,15,110,0,0,0,1,9,18,109,0,16,8,48,0,
+57,18,110,0,16,8,48,0,57,22,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,22,19,18,109,0,16,10,50,0,
+57,18,110,0,16,10,50,0,57,22,19,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,22,19,0,0,1,0,12,2,24,
+1,1,0,15,109,0,0,1,1,0,12,118,0,0,0,1,8,58,118,101,99,52,0,18,118,0,59,120,0,18,109,0,16,8,48,0,57,
+59,120,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,120,0,48,46,18,118,0,59,122,0,18,109,0,16,
+10,50,0,57,59,120,0,48,46,18,118,0,59,119,0,18,109,0,16,10,51,0,57,59,120,0,48,46,0,18,118,0,59,120,
+0,18,109,0,16,8,48,0,57,59,121,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,121,0,48,46,18,118,
+0,59,122,0,18,109,0,16,10,50,0,57,59,121,0,48,46,18,118,0,59,119,0,18,109,0,16,10,51,0,57,59,121,0,
+48,46,0,18,118,0,59,120,0,18,109,0,16,8,48,0,57,59,122,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,
+57,59,122,0,48,46,18,118,0,59,122,0,18,109,0,16,10,50,0,57,59,122,0,48,46,18,118,0,59,119,0,18,109,
+0,16,10,51,0,57,59,122,0,48,46,0,18,118,0,59,120,0,18,109,0,16,8,48,0,57,59,119,0,48,18,118,0,59,
+121,0,18,109,0,16,10,49,0,57,59,119,0,48,46,18,118,0,59,122,0,18,109,0,16,10,50,0,57,59,119,0,48,46,
+18,118,0,59,119,0,18,109,0,16,10,51,0,57,59,119,0,48,46,0,0,0,0,1,0,15,2,24,1,1,0,15,109,0,0,1,1,0,
+15,110,0,0,0,1,8,58,109,97,116,52,0,18,109,0,18,110,0,16,8,48,0,57,48,0,18,109,0,18,110,0,16,10,49,
+0,57,48,0,18,109,0,18,110,0,16,10,50,0,57,48,0,18,109,0,18,110,0,16,10,51,0,57,48,0,0,0,0,1,0,0,2,4,
+1,0,2,15,109,0,0,1,1,0,15,110,0,0,0,1,9,18,109,0,18,109,0,18,110,0,48,20,0,0,1,0,0,2,5,1,0,2,15,109,
+0,0,1,1,0,15,110,0,0,0,1,9,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,24,18,109,0,16,10,49,0,57,18,
+110,0,16,10,49,0,57,24,19,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,24,19,18,109,0,16,10,51,0,
+57,18,110,0,16,10,51,0,57,24,19,0,0,1,0,0,2,2,1,0,2,10,118,0,0,1,1,0,9,97,0,0,0,1,9,18,118,0,59,120,
+0,18,97,0,21,18,118,0,59,121,0,18,97,0,21,19,0,0,1,0,0,2,3,1,0,2,10,118,0,0,1,1,0,9,97,0,0,0,1,9,18,
+118,0,59,120,0,18,97,0,22,18,118,0,59,121,0,18,97,0,22,19,0,0,1,0,0,2,4,1,0,2,10,118,0,0,1,1,0,9,97,
+0,0,0,1,9,18,118,0,59,120,0,18,97,0,23,18,118,0,59,121,0,18,97,0,23,19,0,0,1,0,0,2,5,1,0,2,10,118,0,
+0,1,1,0,9,97,0,0,0,1,9,18,118,0,59,120,0,18,97,0,24,18,118,0,59,121,0,18,97,0,24,19,0,0,1,0,0,2,2,1,
+0,2,11,118,0,0,1,1,0,9,97,0,0,0,1,9,18,118,0,59,120,0,18,97,0,21,18,118,0,59,121,0,18,97,0,21,19,18,
+118,0,59,122,0,18,97,0,21,19,0,0,1,0,0,2,3,1,0,2,11,118,0,0,1,1,0,9,97,0,0,0,1,9,18,118,0,59,120,0,
+18,97,0,22,18,118,0,59,121,0,18,97,0,22,19,18,118,0,59,122,0,18,97,0,22,19,0,0,1,0,0,2,4,1,0,2,11,
+118,0,0,1,1,0,9,97,0,0,0,1,9,18,118,0,59,120,0,18,97,0,23,18,118,0,59,121,0,18,97,0,23,19,18,118,0,
+59,122,0,18,97,0,23,19,0,0,1,0,0,2,5,1,0,2,11,118,0,0,1,1,0,9,97,0,0,0,1,9,18,118,0,59,120,0,18,97,
+0,24,18,118,0,59,121,0,18,97,0,24,19,18,118,0,59,122,0,18,97,0,24,19,0,0,1,0,0,2,2,1,0,2,12,118,0,0,
+1,1,0,9,97,0,0,0,1,9,18,118,0,59,120,0,18,97,0,21,18,118,0,59,121,0,18,97,0,21,19,18,118,0,59,122,0,
+18,97,0,21,19,18,118,0,59,119,0,18,97,0,21,19,0,0,1,0,0,2,3,1,0,2,12,118,0,0,1,1,0,9,97,0,0,0,1,9,
+18,118,0,59,120,0,18,97,0,22,18,118,0,59,121,0,18,97,0,22,19,18,118,0,59,122,0,18,97,0,22,19,18,118,
+0,59,119,0,18,97,0,22,19,0,0,1,0,0,2,4,1,0,2,12,118,0,0,1,1,0,9,97,0,0,0,1,9,18,118,0,59,120,0,18,
+97,0,23,18,118,0,59,121,0,18,97,0,23,19,18,118,0,59,122,0,18,97,0,23,19,18,118,0,59,119,0,18,97,0,
+23,19,0,0,1,0,0,2,5,1,0,2,12,118,0,0,1,1,0,9,97,0,0,0,1,9,18,118,0,59,120,0,18,97,0,24,18,118,0,59,
+121,0,18,97,0,24,19,18,118,0,59,122,0,18,97,0,24,19,18,118,0,59,119,0,18,97,0,24,19,0,0,1,0,0,2,2,1,
+0,2,13,109,0,0,1,1,0,9,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,21,18,109,0,16,10,49,0,57,18,97,0,
+21,19,0,0,1,0,0,2,3,1,0,2,13,109,0,0,1,1,0,9,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,22,18,109,0,
+16,10,49,0,57,18,97,0,22,19,0,0,1,0,0,2,4,1,0,2,13,109,0,0,1,1,0,9,97,0,0,0,1,9,18,109,0,16,8,48,0,
+57,18,97,0,23,18,109,0,16,10,49,0,57,18,97,0,23,19,0,0,1,0,0,2,5,1,0,2,13,109,0,0,1,1,0,9,97,0,0,0,
+1,9,18,109,0,16,8,48,0,57,18,97,0,24,18,109,0,16,10,49,0,57,18,97,0,24,19,0,0,1,0,0,2,2,1,0,2,14,
+109,0,0,1,1,0,9,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,21,18,109,0,16,10,49,0,57,18,97,0,21,19,
+18,109,0,16,10,50,0,57,18,97,0,21,19,0,0,1,0,0,2,3,1,0,2,14,109,0,0,1,1,0,9,97,0,0,0,1,9,18,109,0,
+16,8,48,0,57,18,97,0,22,18,109,0,16,10,49,0,57,18,97,0,22,19,18,109,0,16,10,50,0,57,18,97,0,22,19,0,
+0,1,0,0,2,4,1,0,2,14,109,0,0,1,1,0,9,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,23,18,109,0,16,10,
+49,0,57,18,97,0,23,19,18,109,0,16,10,50,0,57,18,97,0,23,19,0,0,1,0,0,2,5,1,0,2,14,109,0,0,1,1,0,9,
+97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,24,18,109,0,16,10,49,0,57,18,97,0,24,19,18,109,0,16,10,
+50,0,57,18,97,0,24,19,0,0,1,0,0,2,2,1,0,2,15,109,0,0,1,1,0,9,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,
+97,0,21,18,109,0,16,10,49,0,57,18,97,0,21,19,18,109,0,16,10,50,0,57,18,97,0,21,19,18,109,0,16,10,51,
+0,57,18,97,0,21,19,0,0,1,0,0,2,3,1,0,2,15,109,0,0,1,1,0,9,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,
+0,22,18,109,0,16,10,49,0,57,18,97,0,22,19,18,109,0,16,10,50,0,57,18,97,0,22,19,18,109,0,16,10,51,0,
+57,18,97,0,22,19,0,0,1,0,0,2,4,1,0,2,15,109,0,0,1,1,0,9,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,
+23,18,109,0,16,10,49,0,57,18,97,0,23,19,18,109,0,16,10,50,0,57,18,97,0,23,19,18,109,0,16,10,51,0,57,
+18,97,0,23,19,0,0,1,0,0,2,5,1,0,2,15,109,0,0,1,1,0,9,97,0,0,0,1,9,18,109,0,16,8,48,0,57,18,97,0,24,
+18,109,0,16,10,49,0,57,18,97,0,24,19,18,109,0,16,10,50,0,57,18,97,0,24,19,18,109,0,16,10,51,0,57,18,
+97,0,24,19,0,0,1,0,10,2,24,1,1,0,10,118,0,0,1,1,0,13,109,0,0,0,1,8,58,118,101,99,50,0,18,118,0,59,
+120,0,18,109,0,16,8,48,0,57,59,120,0,48,18,118,0,59,121,0,18,109,0,16,8,48,0,57,59,121,0,48,46,0,18,
+118,0,59,120,0,18,109,0,16,10,49,0,57,59,120,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,121,0,
+48,46,0,0,0,0,1,0,0,2,4,1,0,2,10,118,0,0,1,1,0,13,109,0,0,0,1,9,18,118,0,18,118,0,18,109,0,48,20,0,
+0,1,0,11,2,24,1,1,0,11,118,0,0,1,1,0,14,109,0,0,0,1,8,58,118,101,99,51,0,18,118,0,59,120,0,18,109,0,
+16,8,48,0,57,59,120,0,48,18,118,0,59,121,0,18,109,0,16,8,48,0,57,59,121,0,48,46,18,118,0,59,122,0,
+18,109,0,16,8,48,0,57,59,122,0,48,46,0,18,118,0,59,120,0,18,109,0,16,10,49,0,57,59,120,0,48,18,118,
+0,59,121,0,18,109,0,16,10,49,0,57,59,121,0,48,46,18,118,0,59,122,0,18,109,0,16,10,49,0,57,59,122,0,
+48,46,0,18,118,0,59,120,0,18,109,0,16,10,50,0,57,59,120,0,48,18,118,0,59,121,0,18,109,0,16,10,50,0,
+57,59,121,0,48,46,18,118,0,59,122,0,18,109,0,16,10,50,0,57,59,122,0,48,46,0,0,0,0,1,0,0,2,4,1,0,2,
+11,118,0,0,1,1,0,14,109,0,0,0,1,9,18,118,0,18,118,0,18,109,0,48,20,0,0,1,0,12,2,24,1,1,0,12,118,0,0,
+1,1,0,15,109,0,0,0,1,8,58,118,101,99,52,0,18,118,0,59,120,0,18,109,0,16,8,48,0,57,59,120,0,48,18,
+118,0,59,121,0,18,109,0,16,8,48,0,57,59,121,0,48,46,18,118,0,59,122,0,18,109,0,16,8,48,0,57,59,122,
+0,48,46,18,118,0,59,119,0,18,109,0,16,8,48,0,57,59,119,0,48,46,0,18,118,0,59,120,0,18,109,0,16,10,
+49,0,57,59,120,0,48,18,118,0,59,121,0,18,109,0,16,10,49,0,57,59,121,0,48,46,18,118,0,59,122,0,18,
+109,0,16,10,49,0,57,59,122,0,48,46,18,118,0,59,119,0,18,109,0,16,10,49,0,57,59,119,0,48,46,0,18,118,
+0,59,120,0,18,109,0,16,10,50,0,57,59,120,0,48,18,118,0,59,121,0,18,109,0,16,10,50,0,57,59,121,0,48,
+46,18,118,0,59,122,0,18,109,0,16,10,50,0,57,59,122,0,48,46,18,118,0,59,119,0,18,109,0,16,10,50,0,57,
+59,119,0,48,46,0,18,118,0,59,120,0,18,109,0,16,10,51,0,57,59,120,0,48,18,118,0,59,121,0,18,109,0,16,
+10,51,0,57,59,121,0,48,46,18,118,0,59,122,0,18,109,0,16,10,51,0,57,59,122,0,48,46,18,118,0,59,119,0,
+18,109,0,16,10,51,0,57,59,119,0,48,46,0,0,0,0,1,0,0,2,4,1,0,2,12,118,0,0,1,1,0,15,109,0,0,0,1,9,18,
+118,0,18,118,0,18,109,0,48,20,0,0,1,0,9,2,30,1,1,0,9,97,0,0,1,1,0,9,98,0,0,0,1,8,18,97,0,18,98,0,54,
+46,0,0,1,0,5,2,29,1,1,0,5,97,0,0,1,1,0,5,98,0,0,0,1,3,2,0,5,1,99,0,0,0,9,18,99,0,18,97,0,20,0,8,18,
+99,0,18,98,0,21,0,0,1,0,5,2,30,1,1,0,5,97,0,0,1,1,0,5,98,0,0,0,1,8,18,97,0,18,98,0,54,46,0,0,1,0,5,
+2,24,1,1,0,5,97,0,0,1,1,0,5,98,0,0,0,1,3,2,0,5,1,99,0,0,0,8,18,99,0,18,97,0,20,18,98,0,23,0,0,1,0,5,
+2,25,1,1,0,5,97,0,0,1,1,0,5,98,0,0,0,1,3,2,0,5,1,99,0,0,0,8,18,99,0,18,97,0,20,18,98,0,24,0,0,1,0,
+10,2,29,1,1,0,10,118,0,0,1,1,0,10,117,0,0,0,1,8,58,118,101,99,50,0,18,118,0,59,120,0,18,117,0,59,
+120,0,46,0,18,118,0,59,121,0,18,117,0,59,121,0,46,0,0,0,0,1,0,10,2,30,1,1,0,10,118,0,0,1,1,0,10,117,
+0,0,0,1,8,58,118,101,99,50,0,18,118,0,59,120,0,18,117,0,59,120,0,47,0,18,118,0,59,121,0,18,117,0,59,
+121,0,47,0,0,0,0,1,0,11,2,29,1,1,0,11,118,0,0,1,1,0,11,117,0,0,0,1,8,58,118,101,99,51,0,18,118,0,59,
+120,0,18,117,0,59,120,0,46,0,18,118,0,59,121,0,18,117,0,59,121,0,46,0,18,118,0,59,122,0,18,117,0,59,
+122,0,46,0,0,0,0,1,0,11,2,30,1,1,0,11,118,0,0,1,1,0,11,117,0,0,0,1,8,58,118,101,99,51,0,18,118,0,59,
+120,0,18,117,0,59,120,0,47,0,18,118,0,59,121,0,18,117,0,59,121,0,47,0,18,118,0,59,122,0,18,117,0,59,
+122,0,47,0,0,0,0,1,0,12,2,29,1,1,0,12,118,0,0,1,1,0,12,117,0,0,0,1,8,58,118,101,99,52,0,18,118,0,59,
+120,0,18,117,0,59,120,0,46,0,18,118,0,59,121,0,18,117,0,59,121,0,46,0,18,118,0,59,122,0,18,117,0,59,
+122,0,46,0,18,118,0,59,119,0,18,117,0,59,119,0,46,0,0,0,0,1,0,12,2,30,1,1,0,12,118,0,0,1,1,0,12,117,
+0,0,0,1,8,58,118,101,99,52,0,18,118,0,59,120,0,18,117,0,59,120,0,47,0,18,118,0,59,121,0,18,117,0,59,
+121,0,47,0,18,118,0,59,122,0,18,117,0,59,122,0,47,0,18,118,0,59,119,0,18,117,0,59,119,0,47,0,0,0,0,
+1,0,6,2,29,1,1,0,6,118,0,0,1,1,0,6,117,0,0,0,1,8,58,105,118,101,99,50,0,18,118,0,59,120,0,18,117,0,
+59,120,0,46,0,18,118,0,59,121,0,18,117,0,59,121,0,46,0,0,0,0,1,0,6,2,30,1,1,0,6,118,0,0,1,1,0,6,117,
+0,0,0,1,8,58,105,118,101,99,50,0,18,118,0,59,120,0,18,117,0,59,120,0,47,0,18,118,0,59,121,0,18,117,
+0,59,121,0,47,0,0,0,0,1,0,7,2,29,1,1,0,7,118,0,0,1,1,0,7,117,0,0,0,1,8,58,105,118,101,99,51,0,18,
+118,0,59,120,0,18,117,0,59,120,0,46,0,18,118,0,59,121,0,18,117,0,59,121,0,46,0,18,118,0,59,122,0,18,
+117,0,59,122,0,46,0,0,0,0,1,0,7,2,30,1,1,0,7,118,0,0,1,1,0,7,117,0,0,0,1,8,58,105,118,101,99,51,0,
+18,118,0,59,120,0,18,117,0,59,120,0,47,0,18,118,0,59,121,0,18,117,0,59,121,0,47,0,18,118,0,59,122,0,
+18,117,0,59,122,0,47,0,0,0,0,1,0,8,2,29,1,1,0,8,118,0,0,1,1,0,8,117,0,0,0,1,8,58,105,118,101,99,52,
+0,18,118,0,59,120,0,18,117,0,59,120,0,46,0,18,118,0,59,121,0,18,117,0,59,121,0,46,0,18,118,0,59,122,
+0,18,117,0,59,122,0,46,0,18,118,0,59,119,0,18,117,0,59,119,0,46,0,0,0,0,1,0,8,2,30,1,1,0,8,118,0,0,
+1,1,0,8,117,0,0,0,1,8,58,105,118,101,99,52,0,18,118,0,59,120,0,18,117,0,59,120,0,47,0,18,118,0,59,
+121,0,18,117,0,59,121,0,47,0,18,118,0,59,122,0,18,117,0,59,122,0,47,0,18,118,0,59,119,0,18,117,0,59,
+119,0,47,0,0,0,0,1,0,13,2,29,1,1,0,13,109,0,0,1,1,0,13,110,0,0,0,1,8,58,109,97,116,50,0,18,109,0,16,
+8,48,0,57,18,110,0,16,8,48,0,57,46,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,46,0,0,0,0,1,0,
+13,2,30,1,1,0,13,109,0,0,1,1,0,13,110,0,0,0,1,8,58,109,97,116,50,0,18,109,0,16,8,48,0,57,18,110,0,
+16,8,48,0,57,47,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,47,0,0,0,0,1,0,14,2,29,1,1,0,14,109,
+0,0,1,1,0,14,110,0,0,0,1,8,58,109,97,116,51,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,46,0,18,
+109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,46,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,46,0,
+0,0,0,1,0,14,2,30,1,1,0,14,109,0,0,1,1,0,14,110,0,0,0,1,8,58,109,97,116,51,0,18,109,0,16,8,48,0,57,
+18,110,0,16,8,48,0,57,47,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,47,0,18,109,0,16,10,50,0,
+57,18,110,0,16,10,50,0,57,47,0,0,0,0,1,0,15,2,29,1,1,0,15,109,0,0,1,1,0,15,110,0,0,0,1,8,58,109,97,
+116,52,0,18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,46,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,
+0,57,46,0,18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,46,0,18,109,0,16,10,51,0,57,18,110,0,16,10,
+51,0,57,46,0,0,0,0,1,0,15,2,30,1,1,0,15,109,0,0,1,1,0,15,110,0,0,0,1,8,58,109,97,116,52,0,18,109,0,
+16,8,48,0,57,18,110,0,16,8,48,0,57,47,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,47,0,18,109,0,
+16,10,50,0,57,18,110,0,16,10,50,0,57,47,0,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,47,0,0,0,0,
+1,0,10,2,29,1,1,0,9,97,0,0,1,1,0,10,117,0,0,0,1,8,58,118,101,99,50,0,18,97,0,18,117,0,59,120,0,46,0,
+18,97,0,18,117,0,59,121,0,46,0,0,0,0,1,0,10,2,29,1,1,0,10,118,0,0,1,1,0,9,98,0,0,0,1,8,58,118,101,
+99,50,0,18,118,0,59,120,0,18,98,0,46,0,18,118,0,59,121,0,18,98,0,46,0,0,0,0,1,0,10,2,30,1,1,0,9,97,
+0,0,1,1,0,10,117,0,0,0,1,8,58,118,101,99,50,0,18,97,0,18,117,0,59,120,0,47,0,18,97,0,18,117,0,59,
+121,0,47,0,0,0,0,1,0,10,2,30,1,1,0,10,118,0,0,1,1,0,9,98,0,0,0,1,8,58,118,101,99,50,0,18,118,0,59,
+120,0,18,98,0,47,0,18,118,0,59,121,0,18,98,0,47,0,0,0,0,1,0,10,2,24,1,1,0,9,97,0,0,1,1,0,10,117,0,0,
+0,1,8,58,118,101,99,50,0,18,97,0,18,117,0,59,120,0,48,0,18,97,0,18,117,0,59,121,0,48,0,0,0,0,1,0,10,
+2,24,1,1,0,10,118,0,0,1,1,0,9,98,0,0,0,1,8,58,118,101,99,50,0,18,118,0,59,120,0,18,98,0,48,0,18,118,
+0,59,121,0,18,98,0,48,0,0,0,0,1,0,10,2,25,1,1,0,9,97,0,0,1,1,0,10,117,0,0,0,1,8,58,118,101,99,50,0,
+18,97,0,18,117,0,59,120,0,49,0,18,97,0,18,117,0,59,121,0,49,0,0,0,0,1,0,10,2,25,1,1,0,10,118,0,0,1,
+1,0,9,98,0,0,0,1,8,58,118,101,99,50,0,18,118,0,59,120,0,18,98,0,49,0,18,118,0,59,121,0,18,98,0,49,0,
+0,0,0,1,0,11,2,29,1,1,0,9,97,0,0,1,1,0,11,117,0,0,0,1,8,58,118,101,99,51,0,18,97,0,18,117,0,59,120,
+0,46,0,18,97,0,18,117,0,59,121,0,46,0,18,97,0,18,117,0,59,122,0,46,0,0,0,0,1,0,11,2,29,1,1,0,11,118,
+0,0,1,1,0,9,98,0,0,0,1,8,58,118,101,99,51,0,18,118,0,59,120,0,18,98,0,46,0,18,118,0,59,121,0,18,98,
+0,46,0,18,118,0,59,122,0,18,98,0,46,0,0,0,0,1,0,11,2,30,1,1,0,9,97,0,0,1,1,0,11,117,0,0,0,1,8,58,
+118,101,99,51,0,18,97,0,18,117,0,59,120,0,47,0,18,97,0,18,117,0,59,121,0,47,0,18,97,0,18,117,0,59,
+122,0,47,0,0,0,0,1,0,11,2,30,1,1,0,11,118,0,0,1,1,0,9,98,0,0,0,1,8,58,118,101,99,51,0,18,118,0,59,
+120,0,18,98,0,47,0,18,118,0,59,121,0,18,98,0,47,0,18,118,0,59,122,0,18,98,0,47,0,0,0,0,1,0,11,2,24,
+1,1,0,9,97,0,0,1,1,0,11,117,0,0,0,1,8,58,118,101,99,51,0,18,97,0,18,117,0,59,120,0,48,0,18,97,0,18,
+117,0,59,121,0,48,0,18,97,0,18,117,0,59,122,0,48,0,0,0,0,1,0,11,2,24,1,1,0,11,118,0,0,1,1,0,9,98,0,
+0,0,1,8,58,118,101,99,51,0,18,118,0,59,120,0,18,98,0,48,0,18,118,0,59,121,0,18,98,0,48,0,18,118,0,
+59,122,0,18,98,0,48,0,0,0,0,1,0,11,2,25,1,1,0,9,97,0,0,1,1,0,11,117,0,0,0,1,8,58,118,101,99,51,0,18,
+97,0,18,117,0,59,120,0,49,0,18,97,0,18,117,0,59,121,0,49,0,18,97,0,18,117,0,59,122,0,49,0,0,0,0,1,0,
+11,2,25,1,1,0,11,118,0,0,1,1,0,9,98,0,0,0,1,8,58,118,101,99,51,0,18,118,0,59,120,0,18,98,0,49,0,18,
+118,0,59,121,0,18,98,0,49,0,18,118,0,59,122,0,18,98,0,49,0,0,0,0,1,0,12,2,29,1,1,0,9,97,0,0,1,1,0,
+12,117,0,0,0,1,8,58,118,101,99,52,0,18,97,0,18,117,0,59,120,0,46,0,18,97,0,18,117,0,59,121,0,46,0,
+18,97,0,18,117,0,59,122,0,46,0,18,97,0,18,117,0,59,119,0,46,0,0,0,0,1,0,12,2,29,1,1,0,12,118,0,0,1,
+1,0,9,98,0,0,0,1,8,58,118,101,99,52,0,18,118,0,59,120,0,18,98,0,46,0,18,118,0,59,121,0,18,98,0,46,0,
+18,118,0,59,122,0,18,98,0,46,0,18,118,0,59,119,0,18,98,0,46,0,0,0,0,1,0,12,2,30,1,1,0,9,97,0,0,1,1,
+0,12,117,0,0,0,1,8,58,118,101,99,52,0,18,97,0,18,117,0,59,120,0,47,0,18,97,0,18,117,0,59,121,0,47,0,
+18,97,0,18,117,0,59,122,0,47,0,18,97,0,18,117,0,59,119,0,47,0,0,0,0,1,0,12,2,30,1,1,0,12,118,0,0,1,
+1,0,9,98,0,0,0,1,8,58,118,101,99,52,0,18,118,0,59,120,0,18,98,0,47,0,18,118,0,59,121,0,18,98,0,47,0,
+18,118,0,59,122,0,18,98,0,47,0,18,118,0,59,119,0,18,98,0,47,0,0,0,0,1,0,12,2,24,1,1,0,9,97,0,0,1,1,
+0,12,117,0,0,0,1,8,58,118,101,99,52,0,18,97,0,18,117,0,59,120,0,48,0,18,97,0,18,117,0,59,121,0,48,0,
+18,97,0,18,117,0,59,122,0,48,0,18,97,0,18,117,0,59,119,0,48,0,0,0,0,1,0,12,2,24,1,1,0,12,118,0,0,1,
+1,0,9,98,0,0,0,1,8,58,118,101,99,52,0,18,118,0,59,120,0,18,98,0,48,0,18,118,0,59,121,0,18,98,0,48,0,
+18,118,0,59,122,0,18,98,0,48,0,18,118,0,59,119,0,18,98,0,48,0,0,0,0,1,0,12,2,25,1,1,0,9,97,0,0,1,1,
+0,12,117,0,0,0,1,8,58,118,101,99,52,0,18,97,0,18,117,0,59,120,0,49,0,18,97,0,18,117,0,59,121,0,49,0,
+18,97,0,18,117,0,59,122,0,49,0,18,97,0,18,117,0,59,119,0,49,0,0,0,0,1,0,12,2,25,1,1,0,12,118,0,0,1,
+1,0,9,98,0,0,0,1,8,58,118,101,99,52,0,18,118,0,59,120,0,18,98,0,49,0,18,118,0,59,121,0,18,98,0,49,0,
+18,118,0,59,122,0,18,98,0,49,0,18,118,0,59,119,0,18,98,0,49,0,0,0,0,1,0,13,2,29,1,1,0,9,97,0,0,1,1,
+0,13,110,0,0,0,1,8,58,109,97,116,50,0,18,97,0,18,110,0,16,8,48,0,57,46,0,18,97,0,18,110,0,16,10,49,
+0,57,46,0,0,0,0,1,0,13,2,29,1,1,0,13,109,0,0,1,1,0,9,98,0,0,0,1,8,58,109,97,116,50,0,18,109,0,16,8,
+48,0,57,18,98,0,46,0,18,109,0,16,10,49,0,57,18,98,0,46,0,0,0,0,1,0,13,2,30,1,1,0,9,97,0,0,1,1,0,13,
+110,0,0,0,1,8,58,109,97,116,50,0,18,97,0,18,110,0,16,8,48,0,57,47,0,18,97,0,18,110,0,16,10,49,0,57,
+47,0,0,0,0,1,0,13,2,30,1,1,0,13,109,0,0,1,1,0,9,98,0,0,0,1,8,58,109,97,116,50,0,18,109,0,16,8,48,0,
+57,18,98,0,47,0,18,109,0,16,10,49,0,57,18,98,0,47,0,0,0,0,1,0,13,2,24,1,1,0,9,97,0,0,1,1,0,13,110,0,
+0,0,1,8,58,109,97,116,50,0,18,97,0,18,110,0,16,8,48,0,57,48,0,18,97,0,18,110,0,16,10,49,0,57,48,0,0,
+0,0,1,0,13,2,24,1,1,0,13,109,0,0,1,1,0,9,98,0,0,0,1,8,58,109,97,116,50,0,18,109,0,16,8,48,0,57,18,
+98,0,48,0,18,109,0,16,10,49,0,57,18,98,0,48,0,0,0,0,1,0,13,2,25,1,1,0,9,97,0,0,1,1,0,13,110,0,0,0,1,
+8,58,109,97,116,50,0,18,97,0,18,110,0,16,8,48,0,57,49,0,18,97,0,18,110,0,16,10,49,0,57,49,0,0,0,0,1,
+0,13,2,25,1,1,0,13,109,0,0,1,1,0,9,98,0,0,0,1,8,58,109,97,116,50,0,18,109,0,16,8,48,0,57,18,98,0,49,
+0,18,109,0,16,10,49,0,57,18,98,0,49,0,0,0,0,1,0,14,2,29,1,1,0,9,97,0,0,1,1,0,14,110,0,0,0,1,8,58,
+109,97,116,51,0,18,97,0,18,110,0,16,8,48,0,57,46,0,18,97,0,18,110,0,16,10,49,0,57,46,0,18,97,0,18,
+110,0,16,10,50,0,57,46,0,0,0,0,1,0,14,2,29,1,1,0,14,109,0,0,1,1,0,9,98,0,0,0,1,8,58,109,97,116,51,0,
+18,109,0,16,8,48,0,57,18,98,0,46,0,18,109,0,16,10,49,0,57,18,98,0,46,0,18,109,0,16,10,50,0,57,18,98,
+0,46,0,0,0,0,1,0,14,2,30,1,1,0,9,97,0,0,1,1,0,14,110,0,0,0,1,8,58,109,97,116,51,0,18,97,0,18,110,0,
+16,8,48,0,57,47,0,18,97,0,18,110,0,16,10,49,0,57,47,0,18,97,0,18,110,0,16,10,50,0,57,47,0,0,0,0,1,0,
+14,2,30,1,1,0,14,109,0,0,1,1,0,9,98,0,0,0,1,8,58,109,97,116,51,0,18,109,0,16,8,48,0,57,18,98,0,47,0,
+18,109,0,16,10,49,0,57,18,98,0,47,0,18,109,0,16,10,50,0,57,18,98,0,47,0,0,0,0,1,0,14,2,24,1,1,0,9,
+97,0,0,1,1,0,14,110,0,0,0,1,8,58,109,97,116,51,0,18,97,0,18,110,0,16,8,48,0,57,48,0,18,97,0,18,110,
+0,16,10,49,0,57,48,0,18,97,0,18,110,0,16,10,50,0,57,48,0,0,0,0,1,0,14,2,24,1,1,0,14,109,0,0,1,1,0,9,
+98,0,0,0,1,8,58,109,97,116,51,0,18,109,0,16,8,48,0,57,18,98,0,48,0,18,109,0,16,10,49,0,57,18,98,0,
+48,0,18,109,0,16,10,50,0,57,18,98,0,48,0,0,0,0,1,0,14,2,25,1,1,0,9,97,0,0,1,1,0,14,110,0,0,0,1,8,58,
+109,97,116,51,0,18,97,0,18,110,0,16,8,48,0,57,49,0,18,97,0,18,110,0,16,10,49,0,57,49,0,18,97,0,18,
+110,0,16,10,50,0,57,49,0,0,0,0,1,0,14,2,25,1,1,0,14,109,0,0,1,1,0,9,98,0,0,0,1,8,58,109,97,116,51,0,
+18,109,0,16,8,48,0,57,18,98,0,49,0,18,109,0,16,10,49,0,57,18,98,0,49,0,18,109,0,16,10,50,0,57,18,98,
+0,49,0,0,0,0,1,0,15,2,29,1,1,0,9,97,0,0,1,1,0,15,110,0,0,0,1,8,58,109,97,116,52,0,18,97,0,18,110,0,
+16,8,48,0,57,46,0,18,97,0,18,110,0,16,10,49,0,57,46,0,18,97,0,18,110,0,16,10,50,0,57,46,0,18,97,0,
+18,110,0,16,10,51,0,57,46,0,0,0,0,1,0,15,2,29,1,1,0,15,109,0,0,1,1,0,9,98,0,0,0,1,8,58,109,97,116,
+52,0,18,109,0,16,8,48,0,57,18,98,0,46,0,18,109,0,16,10,49,0,57,18,98,0,46,0,18,109,0,16,10,50,0,57,
+18,98,0,46,0,18,109,0,16,10,51,0,57,18,98,0,46,0,0,0,0,1,0,15,2,30,1,1,0,9,97,0,0,1,1,0,15,110,0,0,
+0,1,8,58,109,97,116,52,0,18,97,0,18,110,0,16,8,48,0,57,47,0,18,97,0,18,110,0,16,10,49,0,57,47,0,18,
+97,0,18,110,0,16,10,50,0,57,47,0,18,97,0,18,110,0,16,10,51,0,57,47,0,0,0,0,1,0,15,2,30,1,1,0,15,109,
+0,0,1,1,0,9,98,0,0,0,1,8,58,109,97,116,52,0,18,109,0,16,8,48,0,57,18,98,0,47,0,18,109,0,16,10,49,0,
+57,18,98,0,47,0,18,109,0,16,10,50,0,57,18,98,0,47,0,18,109,0,16,10,51,0,57,18,98,0,47,0,0,0,0,1,0,
+15,2,24,1,1,0,9,97,0,0,1,1,0,15,110,0,0,0,1,8,58,109,97,116,52,0,18,97,0,18,110,0,16,8,48,0,57,48,0,
+18,97,0,18,110,0,16,10,49,0,57,48,0,18,97,0,18,110,0,16,10,50,0,57,48,0,18,97,0,18,110,0,16,10,51,0,
+57,48,0,0,0,0,1,0,15,2,24,1,1,0,15,109,0,0,1,1,0,9,98,0,0,0,1,8,58,109,97,116,52,0,18,109,0,16,8,48,
+0,57,18,98,0,48,0,18,109,0,16,10,49,0,57,18,98,0,48,0,18,109,0,16,10,50,0,57,18,98,0,48,0,18,109,0,
+16,10,51,0,57,18,98,0,48,0,0,0,0,1,0,15,2,25,1,1,0,9,97,0,0,1,1,0,15,110,0,0,0,1,8,58,109,97,116,52,
+0,18,97,0,18,110,0,16,8,48,0,57,49,0,18,97,0,18,110,0,16,10,49,0,57,49,0,18,97,0,18,110,0,16,10,50,
+0,57,49,0,18,97,0,18,110,0,16,10,51,0,57,49,0,0,0,0,1,0,15,2,25,1,1,0,15,109,0,0,1,1,0,9,98,0,0,0,1,
+8,58,109,97,116,52,0,18,109,0,16,8,48,0,57,18,98,0,49,0,18,109,0,16,10,49,0,57,18,98,0,49,0,18,109,
+0,16,10,50,0,57,18,98,0,49,0,18,109,0,16,10,51,0,57,18,98,0,49,0,0,0,0,1,0,6,2,29,1,1,0,5,97,0,0,1,
+1,0,6,117,0,0,0,1,8,58,105,118,101,99,50,0,18,97,0,18,117,0,59,120,0,46,0,18,97,0,18,117,0,59,121,0,
+46,0,0,0,0,1,0,6,2,29,1,1,0,6,118,0,0,1,1,0,5,98,0,0,0,1,8,58,105,118,101,99,50,0,18,118,0,59,120,0,
+18,98,0,46,0,18,118,0,59,121,0,18,98,0,46,0,0,0,0,1,0,6,2,30,1,1,0,5,97,0,0,1,1,0,6,117,0,0,0,1,8,
+58,105,118,101,99,50,0,18,97,0,18,117,0,59,120,0,47,0,18,97,0,18,117,0,59,121,0,47,0,0,0,0,1,0,6,2,
+30,1,1,0,6,118,0,0,1,1,0,5,98,0,0,0,1,8,58,105,118,101,99,50,0,18,118,0,59,120,0,18,98,0,47,0,18,
+118,0,59,121,0,18,98,0,47,0,0,0,0,1,0,6,2,24,1,1,0,5,97,0,0,1,1,0,6,117,0,0,0,1,8,58,105,118,101,99,
+50,0,18,97,0,18,117,0,59,120,0,48,0,18,97,0,18,117,0,59,121,0,48,0,0,0,0,1,0,6,2,24,1,1,0,6,118,0,0,
+1,1,0,5,98,0,0,0,1,8,58,105,118,101,99,50,0,18,118,0,59,120,0,18,98,0,48,0,18,118,0,59,121,0,18,98,
+0,48,0,0,0,0,1,0,6,2,25,1,1,0,5,97,0,0,1,1,0,6,117,0,0,0,1,8,58,105,118,101,99,50,0,18,97,0,18,117,
+0,59,120,0,49,0,18,97,0,18,117,0,59,121,0,49,0,0,0,0,1,0,6,2,25,1,1,0,6,118,0,0,1,1,0,5,98,0,0,0,1,
+8,58,105,118,101,99,50,0,18,118,0,59,120,0,18,98,0,49,0,18,118,0,59,121,0,18,98,0,49,0,0,0,0,1,0,7,
+2,29,1,1,0,5,97,0,0,1,1,0,7,117,0,0,0,1,8,58,105,118,101,99,51,0,18,97,0,18,117,0,59,120,0,46,0,18,
+97,0,18,117,0,59,121,0,46,0,18,97,0,18,117,0,59,122,0,46,0,0,0,0,1,0,7,2,29,1,1,0,7,118,0,0,1,1,0,5,
+98,0,0,0,1,8,58,105,118,101,99,51,0,18,118,0,59,120,0,18,98,0,46,0,18,118,0,59,121,0,18,98,0,46,0,
+18,118,0,59,122,0,18,98,0,46,0,0,0,0,1,0,7,2,30,1,1,0,5,97,0,0,1,1,0,7,117,0,0,0,1,8,58,105,118,101,
+99,51,0,18,97,0,18,117,0,59,120,0,47,0,18,97,0,18,117,0,59,121,0,47,0,18,97,0,18,117,0,59,122,0,47,
+0,0,0,0,1,0,7,2,30,1,1,0,7,118,0,0,1,1,0,5,98,0,0,0,1,8,58,105,118,101,99,51,0,18,118,0,59,120,0,18,
+98,0,47,0,18,118,0,59,121,0,18,98,0,47,0,18,118,0,59,122,0,18,98,0,47,0,0,0,0,1,0,7,2,24,1,1,0,5,97,
+0,0,1,1,0,7,117,0,0,0,1,8,58,105,118,101,99,51,0,18,97,0,18,117,0,59,120,0,48,0,18,97,0,18,117,0,59,
+121,0,48,0,18,97,0,18,117,0,59,122,0,48,0,0,0,0,1,0,7,2,24,1,1,0,7,118,0,0,1,1,0,5,98,0,0,0,1,8,58,
+105,118,101,99,51,0,18,118,0,59,120,0,18,98,0,48,0,18,118,0,59,121,0,18,98,0,48,0,18,118,0,59,122,0,
+18,98,0,48,0,0,0,0,1,0,7,2,25,1,1,0,5,97,0,0,1,1,0,7,117,0,0,0,1,8,58,105,118,101,99,51,0,18,97,0,
+18,117,0,59,120,0,49,0,18,97,0,18,117,0,59,121,0,49,0,18,97,0,18,117,0,59,122,0,49,0,0,0,0,1,0,7,2,
+25,1,1,0,7,118,0,0,1,1,0,5,98,0,0,0,1,8,58,105,118,101,99,51,0,18,118,0,59,120,0,18,98,0,49,0,18,
+118,0,59,121,0,18,98,0,49,0,18,118,0,59,122,0,18,98,0,49,0,0,0,0,1,0,8,2,29,1,1,0,5,97,0,0,1,1,0,8,
+117,0,0,0,1,8,58,105,118,101,99,52,0,18,97,0,18,117,0,59,120,0,46,0,18,97,0,18,117,0,59,121,0,46,0,
+18,97,0,18,117,0,59,122,0,46,0,18,97,0,18,117,0,59,119,0,46,0,0,0,0,1,0,8,2,29,1,1,0,8,118,0,0,1,1,
+0,5,98,0,0,0,1,8,58,105,118,101,99,52,0,18,118,0,59,120,0,18,98,0,46,0,18,118,0,59,121,0,18,98,0,46,
+0,18,118,0,59,122,0,18,98,0,46,0,18,118,0,59,119,0,18,98,0,46,0,0,0,0,1,0,8,2,30,1,1,0,5,97,0,0,1,1,
+0,8,117,0,0,0,1,8,58,105,118,101,99,52,0,18,97,0,18,117,0,59,120,0,47,0,18,97,0,18,117,0,59,121,0,
+47,0,18,97,0,18,117,0,59,122,0,47,0,18,97,0,18,117,0,59,119,0,47,0,0,0,0,1,0,8,2,30,1,1,0,8,118,0,0,
+1,1,0,5,98,0,0,0,1,8,58,105,118,101,99,52,0,18,118,0,59,120,0,18,98,0,47,0,18,118,0,59,121,0,18,98,
+0,47,0,18,118,0,59,122,0,18,98,0,47,0,18,118,0,59,119,0,18,98,0,47,0,0,0,0,1,0,8,2,24,1,1,0,5,97,0,
+0,1,1,0,8,117,0,0,0,1,8,58,105,118,101,99,52,0,18,97,0,18,117,0,59,120,0,48,0,18,97,0,18,117,0,59,
+121,0,48,0,18,97,0,18,117,0,59,122,0,48,0,18,97,0,18,117,0,59,119,0,48,0,0,0,0,1,0,8,2,24,1,1,0,8,
+118,0,0,1,1,0,5,98,0,0,0,1,8,58,105,118,101,99,52,0,18,118,0,59,120,0,18,98,0,48,0,18,118,0,59,121,
+0,18,98,0,48,0,18,118,0,59,122,0,18,98,0,48,0,18,118,0,59,119,0,18,98,0,48,0,0,0,0,1,0,8,2,25,1,1,0,
+5,97,0,0,1,1,0,8,117,0,0,0,1,8,58,105,118,101,99,52,0,18,97,0,18,117,0,59,120,0,49,0,18,97,0,18,117,
+0,59,121,0,49,0,18,97,0,18,117,0,59,122,0,49,0,18,97,0,18,117,0,59,119,0,49,0,0,0,0,1,0,8,2,25,1,1,
+0,8,118,0,0,1,1,0,5,98,0,0,0,1,8,58,105,118,101,99,52,0,18,118,0,59,120,0,18,98,0,49,0,18,118,0,59,
+121,0,18,98,0,49,0,18,118,0,59,122,0,18,98,0,49,0,18,118,0,59,119,0,18,98,0,49,0,0,0,0,1,0,10,2,24,
+1,1,0,10,118,0,0,1,1,0,10,117,0,0,0,1,8,58,118,101,99,50,0,18,118,0,59,120,0,18,117,0,59,120,0,48,0,
+18,118,0,59,121,0,18,117,0,59,121,0,48,0,0,0,0,1,0,11,2,24,1,1,0,11,118,0,0,1,1,0,11,117,0,0,0,1,8,
+58,118,101,99,51,0,18,118,0,59,120,0,18,117,0,59,120,0,48,0,18,118,0,59,121,0,18,117,0,59,121,0,48,
+0,18,118,0,59,122,0,18,117,0,59,122,0,48,0,0,0,0,1,0,12,2,24,1,1,0,12,118,0,0,1,1,0,12,117,0,0,0,1,
+8,58,118,101,99,52,0,18,118,0,59,120,0,18,117,0,59,120,0,48,0,18,118,0,59,121,0,18,117,0,59,121,0,
+48,0,18,118,0,59,122,0,18,117,0,59,122,0,48,0,18,118,0,59,119,0,18,117,0,59,119,0,48,0,0,0,0,1,0,6,
+2,24,1,1,0,6,118,0,0,1,1,0,6,117,0,0,0,1,8,58,105,118,101,99,50,0,18,118,0,59,120,0,18,117,0,59,120,
+0,48,0,18,118,0,59,121,0,18,117,0,59,121,0,48,0,0,0,0,1,0,7,2,24,1,1,0,7,118,0,0,1,1,0,7,117,0,0,0,
+1,8,58,105,118,101,99,51,0,18,118,0,59,120,0,18,117,0,59,120,0,48,0,18,118,0,59,121,0,18,117,0,59,
+121,0,48,0,18,118,0,59,122,0,18,117,0,59,122,0,48,0,0,0,0,1,0,8,2,24,1,1,0,8,118,0,0,1,1,0,8,117,0,
+0,0,1,8,58,105,118,101,99,52,0,18,118,0,59,120,0,18,117,0,59,120,0,48,0,18,118,0,59,121,0,18,117,0,
+59,121,0,48,0,18,118,0,59,122,0,18,117,0,59,122,0,48,0,18,118,0,59,119,0,18,117,0,59,119,0,48,0,0,0,
+0,1,0,10,2,25,1,1,0,10,118,0,0,1,1,0,10,117,0,0,0,1,8,58,118,101,99,50,0,18,118,0,59,120,0,18,117,0,
+59,120,0,49,0,18,118,0,59,121,0,18,117,0,59,121,0,49,0,0,0,0,1,0,11,2,25,1,1,0,11,118,0,0,1,1,0,11,
+117,0,0,0,1,8,58,118,101,99,51,0,18,118,0,59,120,0,18,117,0,59,120,0,49,0,18,118,0,59,121,0,18,117,
+0,59,121,0,49,0,18,118,0,59,122,0,18,117,0,59,122,0,49,0,0,0,0,1,0,12,2,25,1,1,0,12,118,0,0,1,1,0,
+12,117,0,0,0,1,8,58,118,101,99,52,0,18,118,0,59,120,0,18,117,0,59,120,0,49,0,18,118,0,59,121,0,18,
+117,0,59,121,0,49,0,18,118,0,59,122,0,18,117,0,59,122,0,49,0,18,118,0,59,119,0,18,117,0,59,119,0,49,
+0,0,0,0,1,0,6,2,25,1,1,0,6,118,0,0,1,1,0,6,117,0,0,0,1,8,58,105,118,101,99,50,0,18,118,0,59,120,0,
+18,117,0,59,120,0,49,0,18,118,0,59,121,0,18,117,0,59,121,0,49,0,0,0,0,1,0,7,2,25,1,1,0,7,118,0,0,1,
+1,0,7,117,0,0,0,1,8,58,105,118,101,99,51,0,18,118,0,59,120,0,18,117,0,59,120,0,49,0,18,118,0,59,121,
+0,18,117,0,59,121,0,49,0,18,118,0,59,122,0,18,117,0,59,122,0,49,0,0,0,0,1,0,8,2,25,1,1,0,8,118,0,0,
+1,1,0,8,117,0,0,0,1,8,58,105,118,101,99,52,0,18,118,0,59,120,0,18,117,0,59,120,0,49,0,18,118,0,59,
+121,0,18,117,0,59,121,0,49,0,18,118,0,59,122,0,18,117,0,59,122,0,49,0,18,118,0,59,119,0,18,117,0,59,
+119,0,49,0,0,0,0,1,0,13,2,25,1,1,0,13,109,0,0,1,1,0,13,110,0,0,0,1,8,58,109,97,116,50,0,18,109,0,16,
+8,48,0,57,18,110,0,16,8,48,0,57,49,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,49,0,0,0,0,1,0,
+14,2,25,1,1,0,14,109,0,0,1,1,0,14,110,0,0,0,1,8,58,109,97,116,51,0,18,109,0,16,8,48,0,57,18,110,0,
+16,8,48,0,57,49,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,49,0,18,109,0,16,10,50,0,57,18,110,
+0,16,10,50,0,57,49,0,0,0,0,1,0,15,2,25,1,1,0,15,109,0,0,1,1,0,15,110,0,0,0,1,8,58,109,97,116,52,0,
+18,109,0,16,8,48,0,57,18,110,0,16,8,48,0,57,49,0,18,109,0,16,10,49,0,57,18,110,0,16,10,49,0,57,49,0,
+18,109,0,16,10,50,0,57,18,110,0,16,10,50,0,57,49,0,18,109,0,16,10,51,0,57,18,110,0,16,10,51,0,57,49,
+0,0,0,0,1,0,10,2,30,1,1,0,10,118,0,0,0,1,8,58,118,101,99,50,0,18,118,0,59,120,0,54,0,18,118,0,59,
+121,0,54,0,0,0,0,1,0,11,2,30,1,1,0,11,118,0,0,0,1,8,58,118,101,99,51,0,18,118,0,59,120,0,54,0,18,
+118,0,59,121,0,54,0,18,118,0,59,122,0,54,0,0,0,0,1,0,12,2,30,1,1,0,12,118,0,0,0,1,8,58,118,101,99,
+52,0,18,118,0,59,120,0,54,0,18,118,0,59,121,0,54,0,18,118,0,59,122,0,54,0,18,118,0,59,119,0,54,0,0,
+0,0,1,0,6,2,30,1,1,0,6,118,0,0,0,1,8,58,105,118,101,99,50,0,18,118,0,59,120,0,54,0,18,118,0,59,121,
+0,54,0,0,0,0,1,0,7,2,30,1,1,0,7,118,0,0,0,1,8,58,105,118,101,99,51,0,18,118,0,59,120,0,54,0,18,118,
+0,59,121,0,54,0,18,118,0,59,122,0,54,0,0,0,0,1,0,8,2,30,1,1,0,8,118,0,0,0,1,8,58,105,118,101,99,52,
+0,18,118,0,59,120,0,54,0,18,118,0,59,121,0,54,0,18,118,0,59,122,0,54,0,18,118,0,59,119,0,54,0,0,0,0,
+1,0,13,2,30,1,1,0,13,109,0,0,0,1,8,58,109,97,116,50,0,18,109,0,16,8,48,0,57,54,0,18,109,0,16,10,49,
+0,57,54,0,0,0,0,1,0,14,2,30,1,1,0,14,109,0,0,0,1,8,58,109,97,116,51,0,18,109,0,16,8,48,0,57,54,0,18,
+109,0,16,10,49,0,57,54,0,18,109,0,16,10,50,0,57,54,0,0,0,0,1,0,15,2,30,1,1,0,15,109,0,0,0,1,8,58,
+109,97,116,52,0,18,109,0,16,8,48,0,57,54,0,18,109,0,16,10,49,0,57,54,0,18,109,0,16,10,50,0,57,54,0,
+18,109,0,16,10,51,0,57,54,0,0,0,0,1,0,0,2,28,1,0,2,9,97,0,0,0,1,9,18,97,0,17,49,0,48,0,0,22,0,0,1,0,
+0,2,28,1,0,2,5,97,0,0,0,1,9,18,97,0,16,10,49,0,22,0,0,1,0,0,2,28,1,0,2,10,118,0,0,0,1,9,18,118,0,59,
+120,0,52,18,118,0,59,121,0,52,19,0,0,1,0,0,2,28,1,0,2,11,118,0,0,0,1,9,18,118,0,59,120,0,52,18,118,
+0,59,121,0,52,19,18,118,0,59,122,0,52,19,0,0,1,0,0,2,28,1,0,2,12,118,0,0,0,1,9,18,118,0,59,120,0,52,
+18,118,0,59,121,0,52,19,18,118,0,59,122,0,52,19,18,118,0,59,119,0,52,19,0,0,1,0,0,2,28,1,0,2,6,118,
+0,0,0,1,9,18,118,0,59,120,0,52,18,118,0,59,121,0,52,19,0,0,1,0,0,2,28,1,0,2,7,118,0,0,0,1,9,18,118,
+0,59,120,0,52,18,118,0,59,121,0,52,19,18,118,0,59,122,0,52,19,0,0,1,0,0,2,28,1,0,2,8,118,0,0,0,1,9,
+18,118,0,59,120,0,52,18,118,0,59,121,0,52,19,18,118,0,59,122,0,52,19,18,118,0,59,119,0,52,19,0,0,1,
+0,0,2,28,1,0,2,13,109,0,0,0,1,9,18,109,0,16,8,48,0,57,52,18,109,0,16,10,49,0,57,52,19,0,0,1,0,0,2,
+28,1,0,2,14,109,0,0,0,1,9,18,109,0,16,8,48,0,57,52,18,109,0,16,10,49,0,57,52,19,18,109,0,16,10,50,0,
+57,52,19,0,0,1,0,0,2,28,1,0,2,15,109,0,0,0,1,9,18,109,0,16,8,48,0,57,52,18,109,0,16,10,49,0,57,52,
+19,18,109,0,16,10,50,0,57,52,19,18,109,0,16,10,51,0,57,52,19,0,0,1,0,0,2,27,1,0,2,9,97,0,0,0,1,9,18,
+97,0,17,49,0,48,0,0,21,0,0,1,0,0,2,27,1,0,2,5,97,0,0,0,1,9,18,97,0,16,10,49,0,21,0,0,1,0,0,2,27,1,0,
+2,10,118,0,0,0,1,9,18,118,0,59,120,0,51,18,118,0,59,121,0,51,19,0,0,1,0,0,2,27,1,0,2,11,118,0,0,0,1,
+9,18,118,0,59,120,0,51,18,118,0,59,121,0,51,19,18,118,0,59,122,0,51,19,0,0,1,0,0,2,27,1,0,2,12,118,
+0,0,0,1,9,18,118,0,59,120,0,51,18,118,0,59,121,0,51,19,18,118,0,59,122,0,51,19,18,118,0,59,119,0,51,
+19,0,0,1,0,0,2,27,1,0,2,6,118,0,0,0,1,9,18,118,0,59,120,0,51,18,118,0,59,121,0,51,19,0,0,1,0,0,2,27,
+1,0,2,7,118,0,0,0,1,9,18,118,0,59,120,0,51,18,118,0,59,121,0,51,19,18,118,0,59,122,0,51,19,0,0,1,0,
+0,2,27,1,0,2,8,118,0,0,0,1,9,18,118,0,59,120,0,51,18,118,0,59,121,0,51,19,18,118,0,59,122,0,51,19,
+18,118,0,59,119,0,51,19,0,0,1,0,0,2,27,1,0,2,13,109,0,0,0,1,9,18,109,0,16,8,48,0,57,51,18,109,0,16,
+10,49,0,57,51,19,0,0,1,0,0,2,27,1,0,2,14,109,0,0,0,1,9,18,109,0,16,8,48,0,57,51,18,109,0,16,10,49,0,
+57,51,19,18,109,0,16,10,50,0,57,51,19,0,0,1,0,0,2,27,1,0,2,15,109,0,0,0,1,9,18,109,0,16,8,48,0,57,
+51,18,109,0,16,10,49,0,57,51,19,18,109,0,16,10,50,0,57,51,19,18,109,0,16,10,51,0,57,51,19,0,0,1,0,9,
+2,28,1,0,2,9,97,0,0,1,1,0,5,0,0,0,1,3,2,0,9,1,99,0,0,0,9,18,99,0,18,97,0,20,0,9,18,97,0,52,0,8,18,
+99,0,0,0,1,0,5,2,28,1,0,2,5,97,0,0,1,1,0,5,0,0,0,1,3,2,0,5,1,99,0,0,0,9,18,99,0,18,97,0,20,0,9,18,
+97,0,52,0,8,18,99,0,0,0,1,0,10,2,28,1,0,2,10,118,0,0,1,1,0,5,0,0,0,1,8,58,118,101,99,50,0,18,118,0,
+59,120,0,61,0,18,118,0,59,121,0,61,0,0,0,0,1,0,11,2,28,1,0,2,11,118,0,0,1,1,0,5,0,0,0,1,8,58,118,
+101,99,51,0,18,118,0,59,120,0,61,0,18,118,0,59,121,0,61,0,18,118,0,59,122,0,61,0,0,0,0,1,0,12,2,28,
+1,0,2,12,118,0,0,1,1,0,5,0,0,0,1,8,58,118,101,99,52,0,18,118,0,59,120,0,61,0,18,118,0,59,121,0,61,0,
+18,118,0,59,122,0,61,0,18,118,0,59,119,0,61,0,0,0,0,1,0,6,2,28,1,0,2,6,118,0,0,1,1,0,5,0,0,0,1,8,58,
+105,118,101,99,50,0,18,118,0,59,120,0,61,0,18,118,0,59,121,0,61,0,0,0,0,1,0,7,2,28,1,0,2,7,118,0,0,
+1,1,0,5,0,0,0,1,8,58,105,118,101,99,51,0,18,118,0,59,120,0,61,0,18,118,0,59,121,0,61,0,18,118,0,59,
+122,0,61,0,0,0,0,1,0,8,2,28,1,0,2,8,118,0,0,1,1,0,5,0,0,0,1,8,58,105,118,101,99,52,0,18,118,0,59,
+120,0,61,0,18,118,0,59,121,0,61,0,18,118,0,59,122,0,61,0,18,118,0,59,119,0,61,0,0,0,0,1,0,13,2,28,1,
+0,2,13,109,0,0,1,1,0,5,0,0,0,1,8,58,109,97,116,50,0,18,109,0,16,8,48,0,57,61,0,18,109,0,16,10,49,0,
+57,61,0,0,0,0,1,0,14,2,28,1,0,2,14,109,0,0,1,1,0,5,0,0,0,1,8,58,109,97,116,51,0,18,109,0,16,8,48,0,
+57,61,0,18,109,0,16,10,49,0,57,61,0,18,109,0,16,10,50,0,57,61,0,0,0,0,1,0,15,2,28,1,0,2,15,109,0,0,
+1,1,0,5,0,0,0,1,8,58,109,97,116,52,0,18,109,0,16,8,48,0,57,61,0,18,109,0,16,10,49,0,57,61,0,18,109,
+0,16,10,50,0,57,61,0,18,109,0,16,10,51,0,57,61,0,0,0,0,1,0,9,2,27,1,0,2,9,97,0,0,1,1,0,5,0,0,0,1,3,
+2,0,9,1,99,0,0,0,9,18,99,0,18,97,0,20,0,9,18,97,0,51,0,8,18,99,0,0,0,1,0,5,2,27,1,0,2,5,97,0,0,1,1,
+0,5,0,0,0,1,3,2,0,5,1,99,0,0,0,9,18,99,0,18,97,0,20,0,9,18,97,0,51,0,8,18,99,0,0,0,1,0,10,2,27,1,0,
+2,10,118,0,0,1,1,0,5,0,0,0,1,8,58,118,101,99,50,0,18,118,0,59,120,0,60,0,18,118,0,59,121,0,60,0,0,0,
+0,1,0,11,2,27,1,0,2,11,118,0,0,1,1,0,5,0,0,0,1,8,58,118,101,99,51,0,18,118,0,59,120,0,60,0,18,118,0,
+59,121,0,60,0,18,118,0,59,122,0,60,0,0,0,0,1,0,12,2,27,1,0,2,12,118,0,0,1,1,0,5,0,0,0,1,8,58,118,
+101,99,52,0,18,118,0,59,120,0,60,0,18,118,0,59,121,0,60,0,18,118,0,59,122,0,60,0,18,118,0,59,119,0,
+60,0,0,0,0,1,0,6,2,27,1,0,2,6,118,0,0,1,1,0,5,0,0,0,1,8,58,105,118,101,99,50,0,18,118,0,59,120,0,60,
+0,18,118,0,59,121,0,60,0,0,0,0,1,0,7,2,27,1,0,2,7,118,0,0,1,1,0,5,0,0,0,1,8,58,105,118,101,99,51,0,
+18,118,0,59,120,0,60,0,18,118,0,59,121,0,60,0,18,118,0,59,122,0,60,0,0,0,0,1,0,8,2,27,1,0,2,8,118,0,
+0,1,1,0,5,0,0,0,1,8,58,105,118,101,99,52,0,18,118,0,59,120,0,60,0,18,118,0,59,121,0,60,0,18,118,0,
+59,122,0,60,0,18,118,0,59,119,0,60,0,0,0,0,1,0,13,2,27,1,0,2,13,109,0,0,1,1,0,5,0,0,0,1,8,58,109,97,
+116,50,0,18,109,0,16,8,48,0,57,60,0,18,109,0,16,10,49,0,57,60,0,0,0,0,1,0,14,2,27,1,0,2,14,109,0,0,
+1,1,0,5,0,0,0,1,8,58,109,97,116,51,0,18,109,0,16,8,48,0,57,60,0,18,109,0,16,10,49,0,57,60,0,18,109,
+0,16,10,50,0,57,60,0,0,0,0,1,0,15,2,27,1,0,2,15,109,0,0,1,1,0,5,0,0,0,1,8,58,109,97,116,52,0,18,109,
+0,16,8,48,0,57,60,0,18,109,0,16,10,49,0,57,60,0,18,109,0,16,10,50,0,57,60,0,18,109,0,16,10,51,0,57,
+60,0,0,0,0,1,0,1,2,18,1,1,0,9,97,0,0,1,1,0,9,98,0,0,0,1,3,2,0,1,1,99,0,0,0,4,102,108,111,97,116,95,
+108,101,115,115,0,18,99,0,0,18,97,0,0,18,98,0,0,0,8,18,99,0,0,0,1,0,1,2,18,1,1,0,5,97,0,0,1,1,0,5,
+98,0,0,0,1,8,58,102,108,111,97,116,0,18,97,0,0,0,58,102,108,111,97,116,0,18,98,0,0,0,40,0,0,1,0,1,2,
+19,1,1,0,9,97,0,0,1,1,0,9,98,0,0,0,1,8,18,98,0,18,97,0,40,0,0,1,0,1,2,19,1,1,0,5,97,0,0,1,1,0,5,98,
+0,0,0,1,8,18,98,0,18,97,0,40,0,0,1,0,1,2,21,1,1,0,9,97,0,0,1,1,0,9,98,0,0,0,1,8,18,97,0,18,98,0,41,
+18,97,0,18,98,0,38,32,0,0,1,0,1,2,21,1,1,0,5,97,0,0,1,1,0,5,98,0,0,0,1,8,18,97,0,18,98,0,41,18,97,0,
+18,98,0,38,32,0,0,1,0,1,2,20,1,1,0,9,97,0,0,1,1,0,9,98,0,0,0,1,8,18,97,0,18,98,0,40,18,97,0,18,98,0,
+38,32,0,0,1,0,1,2,20,1,1,0,5,97,0,0,1,1,0,5,98,0,0,0,1,8,18,97,0,18,98,0,40,18,97,0,18,98,0,38,32,0,
+0,1,0,1,2,12,1,1,0,1,97,0,0,1,1,0,1,98,0,0,0,1,8,18,97,0,18,98,0,39,0,0,1,0,1,2,32,1,1,0,1,97,0,0,0,
+1,8,18,97,0,15,2,48,0,38,0,0,0 \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_fragment_builtin.gc b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_fragment_builtin.gc
new file mode 100755
index 000000000..b4c5aa3ec
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_fragment_builtin.gc
@@ -0,0 +1,366 @@
+
+//
+// TODO:
+// - implement texture1D, texture2D, texture3D, textureCube,
+// - implement shadow1D, shadow2D,
+// - implement dFdx, dFdy,
+//
+
+//
+// From Shader Spec, ver. 1.10, rev. 59
+//
+// The output of the fragment shader is processed by the fixed function operations at the back end
+// of the OpenGL pipeline. Fragment shaders output values to the OpenGL pipeline using the built-in
+// variables gl_FragColor, gl_FragData and gl_FragDepth, unless the discard keyword is executed.
+//
+// These variables may be written more than once within a fragment shader. If so, the last value
+// assigned is the one used in the subsequent fixed function pipeline. The values written to these
+// variables may be read back after writing them. Reading from these variables before writing them
+// results in an undefined value. The fixed functionality computed depth for a fragment may be
+// obtained by reading gl_FragCoord.z, described below.
+//
+// Writing to gl_FragColor specifies the fragment color that will be used by the subsequent fixed
+// functionality pipeline. If subsequent fixed functionality consumes fragment color and an
+// execution of a fragment shader does not write a value to gl_FragColor then the fragment color
+// consumed is undefined.
+//
+// If the frame buffer is configured as a color index buffer then behavior is undefined when using
+// a fragment shader.
+//
+// Writing to gl_FragDepth will establish the depth value for the fragment being processed. If
+// depth buffering is enabled, and a shader does not write gl_FragDepth, then the fixed function
+// value for depth will be used as the fragment's depth value. If a shader statically assigns
+// a value to gl_FragDepth, and there is an execution path through the shader that does not set
+// gl_FragDepth, then the value of the fragment's depth may be undefined for executions of the
+// shader that take that path. That is, if a shader statically contains a write gl_FragDepth, then
+// it is responsible for always writing it.
+//
+// (A shader contains a static assignment to a variable x if, after pre-processing, the shader
+// contains statement that would write x, whether or not run-time flow of control will cause
+// that statement to be executed.)
+//
+// The variable gl_FragData is an array. Writing to gl_FragData[n] specifies the fragment data
+// that will be used by the subsequent fixed functionality pipeline for data n. If subsequent
+// fixed functionality consumes fragment data and an execution of a fragment shader does not
+// write a value to it, then the fragment data consumed is undefined.
+//
+// If a shader statically assigns a value to gl_FragColor, it may not assign a value to any element
+// of gl_FragData. If a shader statically writes a value to any element of gl_FragData, it may not
+// assign a value to gl_FragColor. That is, a shader may assign values to either gl_FragColor or
+// gl_FragData, but not both.
+//
+// If a shader executes the discard keyword, the fragment is discarded, and the values of
+// gl_FragDepth, gl_FragColor and gl_FragData become irrelevant.
+//
+// The variable gl_FragCoord is available as a read-only variable from within fragment shaders
+// and it holds the window relative coordinates x, y, z, and 1/w values for the fragment. This
+// value is the result of the fixed functionality that interpolates primitives after vertex
+// processing to generate fragments. The z component is the depth value that would be used for
+// the fragment's depth if a shader contained no writes to gl_FragDepth. This is useful for
+// invariance if a shader conditionally computes gl_FragDepth but otherwise wants the fixed
+// functionality fragment depth.
+//
+// The fragment shader has access to the read-only built-in variable gl_FrontFacing whose value
+// is true if the fragment belongs to a front-facing primitive. One use of this is to emulate
+// two-sided lighting by selecting one of two colors calculated by the vertex shader.
+//
+// The built-in variables that are accessible from a fragment shader are intrinsically given types
+// as follows:
+//
+
+__fixed_input vec4 gl_FragCoord;
+__fixed_input bool gl_FrontFacing;
+__fixed_output vec4 gl_FragColor;
+__fixed_output vec4 gl_FragData[gl_MaxDrawBuffers];
+__fixed_output float gl_FragDepth;
+
+//
+// However, they do not behave like variables with no qualifier; their behavior is as described
+// above. These built-in variables have global scope.
+//
+
+//
+// Unlike user-defined varying variables, the built-in varying variables don't have a strict
+// one-to-one correspondence between the vertex language and the fragment language. Two sets are
+// provided, one for each language. Their relationship is described below.
+//
+// The following varying variables are available to read from in a fragment shader. The gl_Color
+// and gl_SecondaryColor names are the same names as attributes passed to the vertex shader.
+// However, there is no name conflict, because attributes are visible only in vertex shaders
+// and the following are only visible in a fragment shader.
+//
+
+varying vec4 gl_Color;
+varying vec4 gl_SecondaryColor;
+varying vec4 gl_TexCoord[]; // at most will be gl_MaxTextureCoords
+varying float gl_FogFragCoord;
+
+//
+// The values in gl_Color and gl_SecondaryColor will be derived automatically by the system from
+// gl_FrontColor, gl_BackColor, gl_FrontSecondaryColor, and gl_BackSecondaryColor based on which
+// face is visible. If fixed functionality is used for vertex processing, then gl_FogFragCoord will
+// either be the z-coordinate of the fragment in eye space, or the interpolation of the fog
+// coordinate, as described in section 3.10 of the OpenGL 1.4 Specification. The gl_TexCoord[]
+// values are the interpolated gl_TexCoord[] values from a vertex shader or the texture coordinates
+// of any fixed pipeline based vertex functionality.
+//
+// Indices to the fragment shader gl_TexCoord array are as described above in the vertex shader
+// text.
+//
+
+//
+// The OpenGL Shading Language defines an assortment of built-in convenience functions for scalar
+// and vector operations. Many of these built-in functions can be used in more than one type
+// of shader, but some are intended to provide a direct mapping to hardware and so are available
+// only for a specific type of shader.
+//
+// The built-in functions basically fall into three categories:
+//
+// * They expose some necessary hardware functionality in a convenient way such as accessing
+// a texture map. There is no way in the language for these functions to be emulated by a shader.
+//
+// * They represent a trivial operation (clamp, mix, etc.) that is very simple for the user
+// to write, but they are very common and may have direct hardware support. It is a very hard
+// problem for the compiler to map expressions to complex assembler instructions.
+//
+// * They represent an operation graphics hardware is likely to accelerate at some point. The
+// trigonometry functions fall into this category.
+//
+// Many of the functions are similar to the same named ones in common C libraries, but they support
+// vector input as well as the more traditional scalar input.
+//
+// Applications should be encouraged to use the built-in functions rather than do the equivalent
+// computations in their own shader code since the built-in functions are assumed to be optimal
+// (e.g., perhaps supported directly in hardware).
+//
+// User code can replace built-in functions with their own if they choose, by simply re-declaring
+// and defining the same name and argument list.
+//
+
+//
+// 8.7 Texture Lookup Functions
+//
+// Texture lookup functions are available to both vertex and fragment shaders. However, level
+// of detail is not computed by fixed functionality for vertex shaders, so there are some
+// differences in operation between vertex and fragment texture lookups. The functions in the table
+// below provide access to textures through samplers, as set up through the OpenGL API. Texture
+// properties such as size, pixel format, number of dimensions, filtering method, number of mip-map
+// levels, depth comparison, and so on are also defined by OpenGL API calls. Such properties are
+// taken into account as the texture is accessed via the built-in functions defined below.
+//
+// If a non-shadow texture call is made to a sampler that represents a depth texture with depth
+// comparisons turned on, then results are undefined. If a shadow texture call is made to a sampler
+// that represents a depth texture with depth comparisions turned off, the results are undefined.
+// If a shadow texture call is made to a sampler that does not represent a depth texture, then
+// results are undefined.
+//
+// In all functions below, the bias parameter is optional for fragment shaders. The bias parameter
+// is not accepted in a vertex shader. For a fragment shader, if bias is present, it is added to
+// the calculated level of detail prior to performing the texture access operation. If the bias
+// parameter is not provided, then the implementation automatically selects level of detail:
+// For a texture that is not mip-mapped, the texture is used directly. If it is mip-mapped and
+// running in a fragment shader, the LOD computed by the implementation is used to do the texture
+// lookup. If it is mip-mapped and running on the vertex shader, then the base texture is used.
+//
+// The built-ins suffixed with "Lod" are allowed only in a vertex shader. For the "Lod" functions,
+// lod is directly used as the level of detail.
+//
+
+//
+// Use the texture coordinate coord to do a texture lookup in the 1D texture currently bound
+// to sampler. For the projective ("Proj") versions, the texture coordinate coord.s is divided by
+// the last component of coord.
+//
+// XXX
+vec4 texture1D (sampler1D sampler, float coord, float bias) {
+ return vec4 (0.0);
+}
+vec4 texture1DProj (sampler1D sampler, vec2 coord, float bias) {
+ return texture1D (sampler, coord.s / coord.t, bias);
+}
+vec4 texture1DProj (sampler1D sampler, vec4 coord, float bias) {
+ return texture1D (sampler, coord.s / coord.q, bias);
+}
+
+//
+// Use the texture coordinate coord to do a texture lookup in the 2D texture currently bound
+// to sampler. For the projective ("Proj") versions, the texture coordinate (coord.s, coord.t) is
+// divided by the last component of coord. The third component of coord is ignored for the vec4
+// coord variant.
+//
+// XXX
+vec4 texture2D (sampler2D sampler, vec2 coord, float bias) {
+ return vec4 (0.0);
+}
+vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias) {
+ return texture2D (sampler, vec2 (coord.s / coord.p, coord.t / coord.p), bias);
+}
+vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias) {
+ return texture2D (sampler, vec2 (coord.s / coord.q, coord.s / coord.q), bias);
+}
+
+//
+// Use the texture coordinate coord to do a texture lookup in the 3D texture currently bound
+// to sampler. For the projective ("Proj") versions, the texture coordinate is divided by coord.q.
+//
+// XXX
+vec4 texture3D (sampler3D sampler, vec3 coord, float bias) {
+ return vec4 (0.0);
+}
+vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias) {
+ return texture3DProj (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q),
+ bias);
+}
+
+//
+// Use the texture coordinate coord to do a texture lookup in the cube map texture currently bound
+// to sampler. The direction of coord is used to select which face to do a 2-dimensional texture
+// lookup in, as described in section 3.8.6 in version 1.4 of the OpenGL specification.
+//
+// XXX
+vec4 textureCube (samplerCube sampler, vec3 coord, float bias) {
+ return vec4 (0.0);
+}
+
+//
+// Use texture coordinate coord to do a depth comparison lookup on the depth texture bound
+// to sampler, as described in section 3.8.14 of version 1.4 of the OpenGL specification. The 3rd
+// component of coord (coord.p) is used as the R value. The texture bound to sampler must be a
+// depth texture, or results are undefined. For the projective ("Proj") version of each built-in,
+// the texture coordinate is divide by coord.q, giving a depth value R of coord.p/coord.q. The
+// second component of coord is ignored for the "1D" variants.
+//
+// XXX
+vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias) {
+ return vec4 (0.0);
+}
+// XXX
+vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias) {
+ return vec4 (0.0);
+}
+vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias) {
+ return shadow1D (sampler, vec3 (coord.s / coord.q, 0.0, coord.p / coord.q), bias);
+}
+vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias) {
+ return shadow2D (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q), bias);
+}
+
+//
+// 8.8 Fragment Processing Functions
+//
+// Fragment processing functions are only available in shaders intended for use on the fragment
+// processor. Derivatives may be computationally expensive and/or numerically unstable. Therefore,
+// an OpenGL implementation may approximate the true derivatives by using a fast but not entirely
+// accurate derivative computation.
+//
+// The expected behavior of a derivative is specified using forward/backward differencing.
+//
+// Forward differencing:
+//
+// F(x+dx) - F(x) ~ dFdx(x) * dx 1a
+// dFdx(x) ~ (F(x+dx) - F(x)) / dx 1b
+//
+// Backward differencing:
+//
+// F(x-dx) - F(x) ~ -dFdx(x) * dx 2a
+// dFdx(x) ~ (F(x) - F(x-dx)) / dx 2b
+//
+// With single-sample rasterization, dx <= 1.0 in equations 1b and 2b. For multi-sample
+// rasterization, dx < 2.0 in equations 1b and 2b.
+//
+// dFdy is approximated similarly, with y replacing x.
+//
+// A GL implementation may use the above or other methods to perform the calculation, subject
+// to the following conditions:
+//
+// 1) The method may use piecewise linear approximations. Such linear approximations imply that
+// higher order derivatives, dFdx(dFdx(x)) and above, are undefined.
+//
+// 2) The method may assume that the function evaluated is continuous. Therefore derivatives within
+// the body of a non-uniform conditional are undefined.
+//
+// 3) The method may differ per fragment, subject to the constraint that the method may vary by
+// window coordinates, not screen coordinates. The invariance requirement described in section
+// 3.1 of the OpenGL 1.4 specification is relaxed for derivative calculations, because
+// the method may be a function of fragment location.
+//
+// Other properties that are desirable, but not required, are:
+//
+// 4) Functions should be evaluated within the interior of a primitive (interpolated, not
+// extrapolated).
+//
+// 5) Functions for dFdx should be evaluated while holding y constant. Functions for dFdy should
+// be evaluated while holding x constant. However, mixed higher order derivatives, like
+// dFdx(dFdy(y)) and dFdy(dFdx(x)) are undefined.
+//
+// In some implementations, varying degrees of derivative accuracy may be obtained by providing
+// GL hints (section 5.6 of the OpenGL 1.4 specification), allowing a user to make an image
+// quality versus speed tradeoff.
+//
+
+//
+// Returns the derivative in x using local differencing for the input argument p.
+//
+// XXX
+float dFdx (float p) {
+ return 0.0;
+}
+// XXX
+vec2 dFdx (vec2 p) {
+ return vec2 (0.0);
+}
+// XXX
+vec3 dFdx (vec3 p) {
+ return vec3 (0.0);
+}
+// XXX
+vec4 dFdx (vec4 p) {
+ return vec4 (0.0);
+}
+
+//
+// Returns the derivative in y using local differencing for the input argument p.
+//
+// These two functions are commonly used to estimate the filter width used to anti-alias procedural
+// textures.We are assuming that the expression is being evaluated in parallel on a SIMD array so
+// that at any given point in time the value of the function is known at the grid points
+// represented by the SIMD array. Local differencing between SIMD array elements can therefore
+// be used to derive dFdx, dFdy, etc.
+//
+// XXX
+float dFdy (float p) {
+ return 0.0;
+}
+// XXX
+vec2 dFdy (vec2 p) {
+ return vec2 (0.0);
+}
+// XXX
+vec3 dFdy (vec3 p) {
+ return vec3 (0.0);
+}
+// XXX
+vec4 dFdy (vec4 p) {
+ return vec4 (0.0);
+}
+
+//
+// Returns the sum of the absolute derivative in x and y using local differencing for the input
+// argument p, i.e.:
+//
+// return = abs (dFdx (p)) + abs (dFdy (p));
+//
+
+float fwidth (float p) {
+ return abs (dFdx (p)) + abs (dFdy (p));
+}
+vec2 fwidth (vec2 p) {
+ return abs (dFdx (p)) + abs (dFdy (p));
+}
+vec3 fwidth (vec3 p) {
+ return abs (dFdx (p)) + abs (dFdy (p));
+}
+vec4 fwidth (vec4 p) {
+ return abs (dFdx (p)) + abs (dFdy (p));
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_fragment_builtin_gc.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_fragment_builtin_gc.h
new file mode 100644
index 000000000..85f74bda8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_fragment_builtin_gc.h
@@ -0,0 +1,366 @@
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"__fixed_input vec4 gl_FragCoord;\n"
+"__fixed_input bool gl_FrontFacing;\n"
+"__fixed_output vec4 gl_FragColor;\n"
+"__fixed_output vec4 gl_FragData[gl_MaxDrawBuffers];\n"
+"__fixed_output float gl_FragDepth;\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"varying vec4 gl_Color;\n"
+"varying vec4 gl_SecondaryColor;\n"
+"varying vec4 gl_TexCoord[];\n"
+"varying float gl_FogFragCoord;\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec4 texture1D (sampler1D sampler, float coord, float bias) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"vec4 texture1DProj (sampler1D sampler, vec2 coord, float bias) {\n"
+" return texture1D (sampler, coord.s / coord.t, bias);\n"
+"}\n"
+"vec4 texture1DProj (sampler1D sampler, vec4 coord, float bias) {\n"
+" return texture1D (sampler, coord.s / coord.q, bias);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec4 texture2D (sampler2D sampler, vec2 coord, float bias) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"vec4 texture2DProj (sampler2D sampler, vec3 coord, float bias) {\n"
+" return texture2D (sampler, vec2 (coord.s / coord.p, coord.t / coord.p), bias);\n"
+"}\n"
+"vec4 texture2DProj (sampler2D sampler, vec4 coord, float bias) {\n"
+" return texture2D (sampler, vec2 (coord.s / coord.q, coord.s / coord.q), bias);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec4 texture3D (sampler3D sampler, vec3 coord, float bias) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"vec4 texture3DProj (sampler3D sampler, vec4 coord, float bias) {\n"
+" return texture3DProj (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q),\n"
+" bias);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec4 textureCube (samplerCube sampler, vec3 coord, float bias) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec4 shadow1D (sampler1DShadow sampler, vec3 coord, float bias) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"\n"
+"vec4 shadow2D (sampler2DShadow sampler, vec3 coord, float bias) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"vec4 shadow1DProj (sampler1DShadow sampler, vec4 coord, float bias) {\n"
+" return shadow1D (sampler, vec3 (coord.s / coord.q, 0.0, coord.p / coord.q), bias);\n"
+"}\n"
+"vec4 shadow2DProj (sampler2DShadow sampler, vec4 coord, float bias) {\n"
+" return shadow2D (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q), bias);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float dFdx (float p) {\n"
+" return 0.0;\n"
+"}\n"
+"\n"
+"vec2 dFdx (vec2 p) {\n"
+" return vec2 (0.0);\n"
+"}\n"
+"\n"
+"vec3 dFdx (vec3 p) {\n"
+" return vec3 (0.0);\n"
+"}\n"
+"\n"
+"vec4 dFdx (vec4 p) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float dFdy (float p) {\n"
+" return 0.0;\n"
+"}\n"
+"\n"
+"vec2 dFdy (vec2 p) {\n"
+" return vec2 (0.0);\n"
+"}\n"
+"\n"
+"vec3 dFdy (vec3 p) {\n"
+" return vec3 (0.0);\n"
+"}\n"
+"\n"
+"vec4 dFdy (vec4 p) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"float fwidth (float p) {\n"
+" return abs (dFdx (p)) + abs (dFdy (p));\n"
+"}\n"
+"vec2 fwidth (vec2 p) {\n"
+" return abs (dFdx (p)) + abs (dFdy (p));\n"
+"}\n"
+"vec3 fwidth (vec3 p) {\n"
+" return abs (dFdx (p)) + abs (dFdy (p));\n"
+"}\n"
+"vec4 fwidth (vec4 p) {\n"
+" return abs (dFdx (p)) + abs (dFdy (p));\n"
+"}\n"
+"\n"
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_fragment_builtin_gc_bin.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_fragment_builtin_gc_bin.h
new file mode 100755
index 000000000..b566c8b33
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_fragment_builtin_gc_bin.h
@@ -0,0 +1,87 @@
+2,2,2,6,12,1,103,108,95,70,114,97,103,67,111,111,114,100,0,0,0,2,2,6,
+1,1,103,108,95,70,114,111,110,116,70,97,99,105,110,103,0,0,0,2,2,5,12,1,
+103,108,95,70,114,97,103,67,111,108,111,114,0,0,0,2,2,5,12,1,103,108,95,70,
+114,97,103,68,97,116,97,0,3,18,103,108,95,77,97,120,68,114,97,119,66,117,102,102,
+101,114,115,0,0,0,2,2,5,9,1,103,108,95,70,114,97,103,68,101,112,116,104,0,
+0,0,2,2,3,12,1,103,108,95,67,111,108,111,114,0,0,0,2,2,3,12,1,103,
+108,95,83,101,99,111,110,100,97,114,121,67,111,108,111,114,0,0,0,2,2,3,12,1,
+103,108,95,84,101,120,67,111,111,114,100,0,4,0,2,2,3,9,1,103,108,95,70,111,
+103,70,114,97,103,67,111,111,114,100,0,0,0,1,0,12,0,116,101,120,116,117,114,101,
+49,68,0,1,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,9,99,111,111,114,
+100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,118,101,99,52,0,17,48,
+0,48,0,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,
+106,0,1,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,10,99,111,111,114,100,
+0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,116,101,120,116,117,114,101,49,
+68,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,59,115,0,18,99,
+111,111,114,100,0,59,116,0,49,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,
+116,101,120,116,117,114,101,49,68,80,114,111,106,0,1,0,0,16,115,97,109,112,108,101,
+114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,
+0,1,8,58,116,101,120,116,117,114,101,49,68,0,18,115,97,109,112,108,101,114,0,0,
+18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,98,
+105,97,115,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,50,68,0,1,0,
+0,17,115,97,109,112,108,101,114,0,0,1,0,0,10,99,111,111,114,100,0,0,1,0,
+0,9,98,105,97,115,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,
+0,0,0,1,0,12,0,116,101,120,116,117,114,101,50,68,80,114,111,106,0,1,0,0,
+17,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,
+9,98,105,97,115,0,0,0,1,8,58,116,101,120,116,117,114,101,50,68,0,18,115,97,
+109,112,108,101,114,0,0,58,118,101,99,50,0,18,99,111,111,114,100,0,59,115,0,18,
+99,111,111,114,100,0,59,112,0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,
+111,114,100,0,59,112,0,49,0,0,0,18,98,105,97,115,0,0,0,0,0,1,0,12,
+0,116,101,120,116,117,114,101,50,68,80,114,111,106,0,1,0,0,17,115,97,109,112,108,
+101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,
+0,0,1,8,58,116,101,120,116,117,114,101,50,68,0,18,115,97,109,112,108,101,114,0,
+0,58,118,101,99,50,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,
+59,113,0,49,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,
+0,49,0,0,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,116,101,120,116,117,
+114,101,51,68,0,1,0,0,18,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,
+111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,118,101,99,52,0,
+17,48,0,48,0,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,51,68,80,
+114,111,106,0,1,0,0,18,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,
+114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,116,101,120,116,117,114,
+101,51,68,80,114,111,106,0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,
+18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,
+111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,
+114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,18,98,105,97,
+115,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,67,117,98,101,0,1,0,
+0,19,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,
+0,9,98,105,97,115,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,
+0,0,0,1,0,12,0,115,104,97,100,111,119,49,68,0,1,0,0,20,115,97,109,112,
+108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,
+0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,12,
+0,115,104,97,100,111,119,50,68,0,1,0,0,21,115,97,109,112,108,101,114,0,0,1,
+0,0,11,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,
+118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,12,0,115,104,97,100,111,
+119,49,68,80,114,111,106,0,1,0,0,20,115,97,109,112,108,101,114,0,0,1,0,0,
+12,99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,115,104,
+97,100,111,119,49,68,0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,
+99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,17,48,0,
+48,0,0,0,18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,
+49,0,0,0,18,98,105,97,115,0,0,0,0,0,1,0,12,0,115,104,97,100,111,119,
+50,68,80,114,111,106,0,1,0,0,21,115,97,109,112,108,101,114,0,0,1,0,0,12,
+99,111,111,114,100,0,0,1,0,0,9,98,105,97,115,0,0,0,1,8,58,115,104,97,
+100,111,119,50,68,0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,
+111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,
+114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,
+0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,18,98,105,97,115,0,
+0,0,0,0,1,0,9,0,100,70,100,120,0,1,0,0,9,112,0,0,0,1,8,17,
+48,0,48,0,0,0,0,1,0,10,0,100,70,100,120,0,1,0,0,10,112,0,0,0,
+1,8,58,118,101,99,50,0,17,48,0,48,0,0,0,0,0,0,1,0,11,0,100,70,
+100,120,0,1,0,0,11,112,0,0,0,1,8,58,118,101,99,51,0,17,48,0,48,0,
+0,0,0,0,0,1,0,12,0,100,70,100,120,0,1,0,0,12,112,0,0,0,1,8,
+58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,9,0,100,70,100,121,
+0,1,0,0,9,112,0,0,0,1,8,17,48,0,48,0,0,0,0,1,0,10,0,100,
+70,100,121,0,1,0,0,10,112,0,0,0,1,8,58,118,101,99,50,0,17,48,0,48,
+0,0,0,0,0,0,1,0,11,0,100,70,100,121,0,1,0,0,11,112,0,0,0,1,
+8,58,118,101,99,51,0,17,48,0,48,0,0,0,0,0,0,1,0,12,0,100,70,100,
+121,0,1,0,0,12,112,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,
+0,0,0,0,1,0,9,0,102,119,105,100,116,104,0,1,0,0,9,112,0,0,0,1,
+8,58,97,98,115,0,58,100,70,100,120,0,18,112,0,0,0,0,0,58,97,98,115,0,
+58,100,70,100,121,0,18,112,0,0,0,0,0,46,0,0,1,0,10,0,102,119,105,100,
+116,104,0,1,0,0,10,112,0,0,0,1,8,58,97,98,115,0,58,100,70,100,120,0,
+18,112,0,0,0,0,0,58,97,98,115,0,58,100,70,100,121,0,18,112,0,0,0,0,
+0,46,0,0,1,0,11,0,102,119,105,100,116,104,0,1,0,0,11,112,0,0,0,1,
+8,58,97,98,115,0,58,100,70,100,120,0,18,112,0,0,0,0,0,58,97,98,115,0,
+58,100,70,100,121,0,18,112,0,0,0,0,0,46,0,0,1,0,12,0,102,119,105,100,
+116,104,0,1,0,0,12,112,0,0,0,1,8,58,97,98,115,0,58,100,70,100,120,0,
+18,112,0,0,0,0,0,58,97,98,115,0,58,100,70,100,121,0,18,112,0,0,0,0,
+0,46,0,0,0 \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_shader.syn b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_shader.syn
new file mode 100644
index 000000000..65d7fe353
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_shader.syn
@@ -0,0 +1,1508 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.2
+ *
+ * Copyright (C) 2004-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * \file slang_shader.syn
+ * slang vertex/fragment shader syntax
+ * \author Michal Krol
+ */
+
+/*
+ * usage:
+ * syn2c slang_shader.syn > slang_shader_syn.h
+ *
+ * when modifying or extending this file, several things must be taken into consideration:
+ * - when adding new operators that were marked as reserved in the initial specification,
+ * one must only uncomment particular lines of code that refer to operators being added;
+ * - when adding new shader target, one must reserve new value for shader_type register and
+ * use it in .if constructs for symbols that are exclusive for that shader;
+ * - some symbols mimic output of other symbols - the best example is the "for" construct:
+ * expression "for (foo(); ; bar())" is seen as "for (foo(); true; bar())" by the output
+ * processor - hence, special care must be taken when rearranging output of essential symbols;
+ * - order of single-quoted tokens does matter in alternatives - so do not parse "<" operator
+ * before "<<" and "<<" before "<<=";
+ * - all double-quoted tokens are internally preprocessed to eliminate problems with parsing
+ * strings that are prefixes of other strings, like "sampler1D" and "sampler1DShadow";
+ */
+
+.syntax translation_unit;
+
+/* revision number - increment after each change affecting emitted output */
+.emtcode REVISION 2
+
+/* external declaration */
+.emtcode EXTERNAL_NULL 0
+.emtcode EXTERNAL_FUNCTION_DEFINITION 1
+.emtcode EXTERNAL_DECLARATION 2
+
+/* declaration */
+.emtcode DECLARATION_FUNCTION_PROTOTYPE 1
+.emtcode DECLARATION_INIT_DECLARATOR_LIST 2
+
+/* function type */
+.emtcode FUNCTION_ORDINARY 0
+.emtcode FUNCTION_CONSTRUCTOR 1
+.emtcode FUNCTION_OPERATOR 2
+
+/* operator type */
+.emtcode OPERATOR_ASSIGN 1
+.emtcode OPERATOR_ADDASSIGN 2
+.emtcode OPERATOR_SUBASSIGN 3
+.emtcode OPERATOR_MULASSIGN 4
+.emtcode OPERATOR_DIVASSIGN 5
+/*.emtcode OPERATOR_MODASSIGN 6*/
+/*.emtcode OPERATOR_LSHASSIGN 7*/
+/*.emtcode OPERATOR_RSHASSIGN 8*/
+/*.emtcode OPERATOR_ORASSIGN 9*/
+/*.emtcode OPERATOR_XORASSIGN 10*/
+/*.emtcode OPERATOR_ANDASSIGN 11*/
+.emtcode OPERATOR_LOGICALXOR 12
+/*.emtcode OPERATOR_BITOR 13*/
+/*.emtcode OPERATOR_BITXOR 14*/
+/*.emtcode OPERATOR_BITAND 15*/
+.emtcode OPERATOR_EQUAL 16
+.emtcode OPERATOR_NOTEQUAL 17
+.emtcode OPERATOR_LESS 18
+.emtcode OPERATOR_GREATER 19
+.emtcode OPERATOR_LESSEQUAL 20
+.emtcode OPERATOR_GREATEREQUAL 21
+/*.emtcode OPERATOR_LSHIFT 22*/
+/*.emtcode OPERATOR_RSHIFT 23*/
+.emtcode OPERATOR_MULTIPLY 24
+.emtcode OPERATOR_DIVIDE 25
+/*.emtcode OPERATOR_MODULUS 26*/
+.emtcode OPERATOR_INCREMENT 27
+.emtcode OPERATOR_DECREMENT 28
+.emtcode OPERATOR_PLUS 29
+.emtcode OPERATOR_MINUS 30
+/*.emtcode OPERATOR_COMPLEMENT 31*/
+.emtcode OPERATOR_NOT 32
+
+/* init declarator list */
+.emtcode DECLARATOR_NONE 0
+.emtcode DECLARATOR_NEXT 1
+
+/* variable declaration */
+.emtcode VARIABLE_NONE 0
+.emtcode VARIABLE_IDENTIFIER 1
+.emtcode VARIABLE_INITIALIZER 2
+.emtcode VARIABLE_ARRAY_EXPLICIT 3
+.emtcode VARIABLE_ARRAY_UNKNOWN 4
+
+/* type qualifier */
+.emtcode TYPE_QUALIFIER_NONE 0
+.emtcode TYPE_QUALIFIER_CONST 1
+.emtcode TYPE_QUALIFIER_ATTRIBUTE 2
+.emtcode TYPE_QUALIFIER_VARYING 3
+.emtcode TYPE_QUALIFIER_UNIFORM 4
+.emtcode TYPE_QUALIFIER_FIXEDOUTPUT 5
+.emtcode TYPE_QUALIFIER_FIXEDINPUT 6
+
+/* type specifier */
+.emtcode TYPE_SPECIFIER_VOID 0
+.emtcode TYPE_SPECIFIER_BOOL 1
+.emtcode TYPE_SPECIFIER_BVEC2 2
+.emtcode TYPE_SPECIFIER_BVEC3 3
+.emtcode TYPE_SPECIFIER_BVEC4 4
+.emtcode TYPE_SPECIFIER_INT 5
+.emtcode TYPE_SPECIFIER_IVEC2 6
+.emtcode TYPE_SPECIFIER_IVEC3 7
+.emtcode TYPE_SPECIFIER_IVEC4 8
+.emtcode TYPE_SPECIFIER_FLOAT 9
+.emtcode TYPE_SPECIFIER_VEC2 10
+.emtcode TYPE_SPECIFIER_VEC3 11
+.emtcode TYPE_SPECIFIER_VEC4 12
+.emtcode TYPE_SPECIFIER_MAT2 13
+.emtcode TYPE_SPECIFIER_MAT3 14
+.emtcode TYPE_SPECIFIER_MAT4 15
+.emtcode TYPE_SPECIFIER_SAMPLER1D 16
+.emtcode TYPE_SPECIFIER_SAMPLER2D 17
+.emtcode TYPE_SPECIFIER_SAMPLER3D 18
+.emtcode TYPE_SPECIFIER_SAMPLERCUBE 19
+.emtcode TYPE_SPECIFIER_SAMPLER1DSHADOW 20
+.emtcode TYPE_SPECIFIER_SAMPLER2DSHADOW 21
+.emtcode TYPE_SPECIFIER_STRUCT 22
+.emtcode TYPE_SPECIFIER_TYPENAME 23
+
+/* structure field */
+.emtcode FIELD_NONE 0
+.emtcode FIELD_NEXT 1
+.emtcode FIELD_ARRAY 2
+
+/* operation */
+.emtcode OP_END 0
+.emtcode OP_BLOCK_BEGIN_NO_NEW_SCOPE 1
+.emtcode OP_BLOCK_BEGIN_NEW_SCOPE 2
+.emtcode OP_DECLARE 3
+.emtcode OP_ASM 4
+.emtcode OP_BREAK 5
+.emtcode OP_CONTINUE 6
+.emtcode OP_DISCARD 7
+.emtcode OP_RETURN 8
+.emtcode OP_EXPRESSION 9
+.emtcode OP_IF 10
+.emtcode OP_WHILE 11
+.emtcode OP_DO 12
+.emtcode OP_FOR 13
+.emtcode OP_PUSH_VOID 14
+.emtcode OP_PUSH_BOOL 15
+.emtcode OP_PUSH_INT 16
+.emtcode OP_PUSH_FLOAT 17
+.emtcode OP_PUSH_IDENTIFIER 18
+.emtcode OP_SEQUENCE 19
+.emtcode OP_ASSIGN 20
+.emtcode OP_ADDASSIGN 21
+.emtcode OP_SUBASSIGN 22
+.emtcode OP_MULASSIGN 23
+.emtcode OP_DIVASSIGN 24
+/*.emtcode OP_MODASSIGN 25*/
+/*.emtcode OP_LSHASSIGN 26*/
+/*.emtcode OP_RSHASSIGN 27*/
+/*.emtcode OP_ORASSIGN 28*/
+/*.emtcode OP_XORASSIGN 29*/
+/*.emtcode OP_ANDASSIGN 30*/
+.emtcode OP_SELECT 31
+.emtcode OP_LOGICALOR 32
+.emtcode OP_LOGICALXOR 33
+.emtcode OP_LOGICALAND 34
+/*.emtcode OP_BITOR 35*/
+/*.emtcode OP_BITXOR 36*/
+/*.emtcode OP_BITAND 37*/
+.emtcode OP_EQUAL 38
+.emtcode OP_NOTEQUAL 39
+.emtcode OP_LESS 40
+.emtcode OP_GREATER 41
+.emtcode OP_LESSEQUAL 42
+.emtcode OP_GREATEREQUAL 43
+/*.emtcode OP_LSHIFT 44*/
+/*.emtcode OP_RSHIFT 45*/
+.emtcode OP_ADD 46
+.emtcode OP_SUBTRACT 47
+.emtcode OP_MULTIPLY 48
+.emtcode OP_DIVIDE 49
+/*.emtcode OP_MODULUS 50*/
+.emtcode OP_PREINCREMENT 51
+.emtcode OP_PREDECREMENT 52
+.emtcode OP_PLUS 53
+.emtcode OP_MINUS 54
+/*.emtcode OP_COMPLEMENT 55*/
+.emtcode OP_NOT 56
+.emtcode OP_SUBSCRIPT 57
+.emtcode OP_CALL 58
+.emtcode OP_FIELD 59
+.emtcode OP_POSTINCREMENT 60
+.emtcode OP_POSTDECREMENT 61
+
+/* parameter qualifier */
+.emtcode PARAM_QUALIFIER_IN 0
+.emtcode PARAM_QUALIFIER_OUT 1
+.emtcode PARAM_QUALIFIER_INOUT 2
+
+/* function parameter */
+.emtcode PARAMETER_NONE 0
+.emtcode PARAMETER_NEXT 1
+
+/* function parameter array presence */
+.emtcode PARAMETER_ARRAY_NOT_PRESENT 0
+.emtcode PARAMETER_ARRAY_PRESENT 1
+
+.errtext INVALID_EXTERNAL_DECLARATION "error 2001: invalid external declaration"
+.errtext INVALID_OPERATOR_OVERRIDE "error 2002: invalid operator override"
+.errtext LBRACE_EXPECTED "error 2003: '{' expected but '$err_token$' found"
+.errtext LPAREN_EXPECTED "error 2004: '(' expected but '$err_token$' found"
+.errtext RPAREN_EXPECTED "error 2005: ')' expected but '$err_token$' found"
+
+/* tells whether the shader that is being parsed is a built-in shader or not */
+/* 0 - normal behaviour */
+/* 1 - accepts constructor and operator definitions and __asm statements */
+/* the implementation will set it to 1 when compiling internal built-in shaders */
+.regbyte parsing_builtin 0
+
+/* holds the type of the shader being parsed; possible values are listed below */
+/* FRAGMENT_SHADER 1 */
+/* VERTEX_SHADER 2 */
+/* shader type is set by the caller before parsing */
+.regbyte shader_type 0
+
+/*
+ <variable_identifier> ::= <identifier>
+*/
+variable_identifier
+ identifier .emit OP_PUSH_IDENTIFIER;
+
+/*
+ <primary_expression> ::= <variable_identifier>
+ | <intconstant>
+ | <floatconstant>
+ | <boolconstant>
+ | "(" <expression> ")"
+*/
+primary_expression
+ floatconstant .or boolconstant .or intconstant .or variable_identifier .or primary_expression_1;
+primary_expression_1
+ lparen .and expression .and rparen;
+
+/*
+ <postfix_expression> ::= <primary_expression>
+ | <postfix_expression> "[" <integer_expression> "]"
+ | <function_call>
+ | <postfix_expression> "." <field_selection>
+ | <postfix_expression> "++"
+ | <postfix_expression> "--"
+*/
+postfix_expression
+ postfix_expression_1 .and .loop postfix_expression_2;
+postfix_expression_1
+ function_call .or primary_expression;
+postfix_expression_2
+ postfix_expression_3 .or postfix_expression_4 .or
+ plusplus .emit OP_POSTINCREMENT .or
+ minusminus .emit OP_POSTDECREMENT;
+postfix_expression_3
+ lbracket .and integer_expression .and rbracket .emit OP_SUBSCRIPT;
+postfix_expression_4
+ dot .and field_selection .emit OP_FIELD;
+
+/*
+ <integer_expression> ::= <expression>
+*/
+integer_expression
+ expression;
+
+/*
+ <function_call> ::= <function_call_generic>
+*/
+function_call
+ function_call_generic .emit OP_CALL .and .true .emit OP_END;
+
+/*
+ <function_call_generic> ::= <function_call_header_with_parameters> ")"
+ | <function_call_header_no_parameters> ")"
+*/
+function_call_generic
+ function_call_generic_1 .or function_call_generic_2;
+function_call_generic_1
+ function_call_header_with_parameters .and rparen .error RPAREN_EXPECTED;
+function_call_generic_2
+ function_call_header_no_parameters .and rparen .error RPAREN_EXPECTED;
+
+/*
+ <function_call_header_no_parameters>::= <function_call_header> "void"
+ | <function_call_header>
+*/
+function_call_header_no_parameters
+ function_call_header .and function_call_header_no_parameters_1;
+function_call_header_no_parameters_1
+ "void" .or .true;
+
+/*
+ <function_call_header_with_parameters>::= <function_call_header> <assignment_expression>
+ | <function_call_header_with_parameters> ","
+ <assignment_expression>
+*/
+function_call_header_with_parameters
+ function_call_header .and assignment_expression .and .true .emit OP_END .and
+ .loop function_call_header_with_parameters_1;
+function_call_header_with_parameters_1
+ comma .and assignment_expression .and .true .emit OP_END;
+
+/*
+ <function_call_header> ::= <function_identifier> "("
+*/
+function_call_header
+ function_identifier .and lparen;
+
+/*
+ <function_identifier> ::= <constructor_identifier>
+ | <identifier>
+
+note: <constructor_identifier> has been deleted
+*/
+function_identifier
+ identifier;
+
+/*
+ <unary_expression> ::= <postfix_expression>
+ | "++" <unary_expression>
+ | "--" <unary_expression>
+ | <unary_operator> <unary_expression>
+
+ <unary_operator> ::= "+"
+ | "-"
+ | "!"
+ | "~" // reserved
+*/
+unary_expression
+ postfix_expression .or unary_expression_1 .or unary_expression_2 .or unary_expression_3 .or
+ unary_expression_4 .or unary_expression_5/* .or unary_expression_6*/;
+unary_expression_1
+ plusplus .and unary_expression .and .true .emit OP_PREINCREMENT;
+unary_expression_2
+ minusminus .and unary_expression .and .true .emit OP_PREDECREMENT;
+unary_expression_3
+ plus .and unary_expression .and .true .emit OP_PLUS;
+unary_expression_4
+ minus .and unary_expression .and .true .emit OP_MINUS;
+unary_expression_5
+ bang .and unary_expression .and .true .emit OP_NOT;
+/*unary_expression_6
+ tilde .and unary_expression .and .true .emit OP_COMPLEMENT;*/
+
+/*
+ <multiplicative_expression> ::= <unary_expression>
+ | <multiplicative_expression> "*" <unary_expression>
+ | <multiplicative_expression> "/" <unary_expression>
+ | <multiplicative_expression> "%" <unary_expression> // reserved
+*/
+multiplicative_expression
+ unary_expression .and .loop multiplicative_expression_1;
+multiplicative_expression_1
+ multiplicative_expression_2 .or multiplicative_expression_3/* .or multiplicative_expression_4*/;
+multiplicative_expression_2
+ star .and unary_expression .and .true .emit OP_MULTIPLY;
+multiplicative_expression_3
+ slash .and unary_expression .and .true .emit OP_DIVIDE;
+/*multiplicative_expression_4
+ percent .and unary_expression .and .true .emit OP_MODULUS;*/
+
+/*
+ <additive_expression> ::= <multiplicative_expression>
+ | <additive_expression> "+" <multiplicative_expression>
+ | <additive_expression> "-" <multiplicative_expression>
+*/
+additive_expression
+ multiplicative_expression .and .loop additive_expression_1;
+additive_expression_1
+ additive_expression_2 .or additive_expression_3;
+additive_expression_2
+ plus .and multiplicative_expression .and .true .emit OP_ADD;
+additive_expression_3
+ minus .and multiplicative_expression .and .true .emit OP_SUBTRACT;
+
+/*
+ <shift_expression> ::= <additive_expression>
+ | <shift_expression> "<<" <additive_expression> // reserved
+ | <shift_expression> ">>" <additive_expression> // reserved
+*/
+shift_expression
+ additive_expression/* .and .loop shift_expression_1*/;
+/*shift_expression_1
+ shift_expression_2 .or shift_expression_3;*/
+/*shift_expression_2
+ lessless .and additive_expression .and .true .emit OP_LSHIFT;*/
+/*shift_expression_3
+ greatergreater .and additive_expression .and .true .emit OP_RSHIFT;*/
+
+/*
+ <relational_expression> ::= <shift_expression>
+ | <relational_expression> "<" <shift_expression>
+ | <relational_expression> ">" <shift_expression>
+ | <relational_expression> "<=" <shift_expression>
+ | <relational_expression> ">=" <shift_expression>
+*/
+relational_expression
+ shift_expression .and .loop relational_expression_1;
+relational_expression_1
+ relational_expression_2 .or relational_expression_3 .or relational_expression_4 .or
+ relational_expression_5;
+relational_expression_2
+ lessequals .and shift_expression .and .true .emit OP_LESSEQUAL;
+relational_expression_3
+ greaterequals .and shift_expression .and .true .emit OP_GREATEREQUAL;
+relational_expression_4
+ less .and shift_expression .and .true .emit OP_LESS;
+relational_expression_5
+ greater .and shift_expression .and .true .emit OP_GREATER;
+
+/*
+ <equality_expression> ::= <relational_expression>
+ | <equality_expression> "==" <relational_expression>
+ | <equality_expression> "!=" <relational_expression>
+*/
+equality_expression
+ relational_expression .and .loop equality_expression_1;
+equality_expression_1
+ equality_expression_2 .or equality_expression_3;
+equality_expression_2
+ equalsequals .and relational_expression .and .true .emit OP_EQUAL;
+equality_expression_3
+ bangequals .and relational_expression .and .true .emit OP_NOTEQUAL;
+
+/*
+ <and_expression> ::= <equality_expression>
+ | <and_expression> "&" <equality_expression> // reserved
+*/
+and_expression
+ equality_expression/* .and .loop and_expression_1*/;
+/*and_expression_1
+ ampersand .and equality_expression .and .true .emit OP_BITAND;*/
+
+/*
+ <exclusive_or_expression> ::= <and_expression>
+ | <exclusive_or_expression> "^" <and_expression> // reserved
+*/
+exclusive_or_expression
+ and_expression/* .and .loop exclusive_or_expression_1*/;
+/*exclusive_or_expression_1
+ caret .and and_expression .and .true .emit OP_BITXOR;*/
+
+/*
+ <inclusive_or_expression> ::= <exclusive_or_expression>
+ | <inclusive_or_expression> "|" <exclusive_or_expression> // reserved
+*/
+inclusive_or_expression
+ exclusive_or_expression/* .and .loop inclusive_or_expression_1*/;
+/*inclusive_or_expression_1
+ bar .and exclusive_or_expression .and .true .emit OP_BITOR;*/
+
+/*
+ <logical_and_expression> ::= <inclusive_or_expression>
+ | <logical_and_expression> "&&" <inclusive_or_expression>
+*/
+logical_and_expression
+ inclusive_or_expression .and .loop logical_and_expression_1;
+logical_and_expression_1
+ ampersandampersand .and inclusive_or_expression .and .true .emit OP_LOGICALAND;
+
+/*
+ <logical_xor_expression> ::= <logical_and_expression>
+ | <logical_xor_expression> "^^" <logical_and_expression>
+*/
+logical_xor_expression
+ logical_and_expression .and .loop logical_xor_expression_1;
+logical_xor_expression_1
+ caretcaret .and logical_and_expression .and .true .emit OP_LOGICALXOR;
+
+/*
+ <logical_or_expression> ::= <logical_xor_expression>
+ | <logical_or_expression> "||" <logical_xor_expression>
+*/
+logical_or_expression
+ logical_xor_expression .and .loop logical_or_expression_1;
+logical_or_expression_1
+ barbar .and logical_xor_expression .and .true .emit OP_LOGICALOR;
+
+/*
+ <conditional_expression> ::= <logical_or_expression>
+ | <logical_or_expression> "?" <expression> ":"
+ <conditional_expression>
+*/
+conditional_expression
+ logical_or_expression .and .loop conditional_expression_1;
+conditional_expression_1
+ question .and expression .and colon .and conditional_expression .and .true .emit OP_SELECT;
+
+/*
+ <assignment_expression> ::= <conditional_expression>
+ | <unary_expression> <assignment_operator>
+ <assignment_expression>
+
+ <assignment_operator> ::= "="
+ | "*="
+ | "/="
+ | "+="
+ | "-="
+ | "%=" // reserved
+ | "<<=" // reserved
+ | ">>=" // reserved
+ | "&=" // reserved
+ | "^=" // reserved
+ | "|=" // reserved
+*/
+assignment_expression
+ assignment_expression_1 .or assignment_expression_2 .or assignment_expression_3 .or
+ assignment_expression_4 .or assignment_expression_5/* .or assignment_expression_6 .or
+ assignment_expression_7 .or assignment_expression_8 .or assignment_expression_9 .or
+ assignment_expression_10 .or assignment_expression_11*/ .or conditional_expression;
+assignment_expression_1
+ unary_expression .and equals .and assignment_expression .and .true .emit OP_ASSIGN;
+assignment_expression_2
+ unary_expression .and starequals .and assignment_expression .and .true .emit OP_MULASSIGN;
+assignment_expression_3
+ unary_expression .and slashequals .and assignment_expression .and .true .emit OP_DIVASSIGN;
+assignment_expression_4
+ unary_expression .and plusequals .and assignment_expression .and .true .emit OP_ADDASSIGN;
+assignment_expression_5
+ unary_expression .and minusequals .and assignment_expression .and .true .emit OP_SUBASSIGN;
+/*assignment_expression_6
+ unary_expression .and percentequals .and assignment_expression .and .true .emit OP_MODASSIGN;*/
+/*assignment_expression_7
+ unary_expression .and lesslessequals .and assignment_expression .and .true .emit OP_LSHASSIGN;*/
+/*assignment_expression_8
+ unary_expression .and greatergreaterequals .and assignment_expression .and
+ .true .emit OP_RSHASSIGN;*/
+/*assignment_expression_9
+ unary_expression .and ampersandequals .and assignment_expression .and .true .emit OP_ANDASSIGN;*/
+/*assignment_expression_10
+ unary_expression .and caretequals .and assignment_expression .and .true .emit OP_XORASSIGN;*/
+/*assignment_expression_11
+ unary_expression .and barequals .and assignment_expression .and .true .emit OP_ORASSIGN;*/
+
+/*
+ <expression> ::= <assignment_expression>
+ | <expression> "," <assignment_expression>
+*/
+expression
+ assignment_expression .and .loop expression_1;
+expression_1
+ comma .and assignment_expression .and .true .emit OP_SEQUENCE;
+
+/*
+ <constant_expression> ::= <conditional_expression>
+*/
+constant_expression
+ conditional_expression .and .true .emit OP_END;
+
+/*
+ <declaration> ::= <function_prototype> ";"
+ | <init_declarator_list> ";"
+*/
+declaration
+ declaration_1 .or declaration_2;
+declaration_1
+ function_prototype .emit DECLARATION_FUNCTION_PROTOTYPE .and semicolon;
+declaration_2
+ init_declarator_list .emit DECLARATION_INIT_DECLARATOR_LIST .and semicolon;
+
+/*
+ <function_prototype> ::= <function_declarator> ")"
+*/
+function_prototype
+ function_declarator .and rparen .error RPAREN_EXPECTED .emit PARAMETER_NONE;
+
+/*
+ <function_declarator> ::= <function_header>
+ | <function_header_with_parameters>
+*/
+function_declarator
+ function_header_with_parameters .or function_header;
+
+/*
+ <function_header_with_parameters> ::= <function_header> <parameter_declaration>
+ | <function_header_with_parameters> ","
+ <parameter_declaration>
+*/
+function_header_with_parameters
+ function_header .and parameter_declaration .and .loop function_header_with_parameters_1;
+function_header_with_parameters_1
+ comma .and parameter_declaration;
+
+/*
+ <function_header> ::= <fully_specified_type> <identifier> "("
+*/
+function_header
+ function_header_nospace .or function_header_space;
+function_header_space
+ fully_specified_type_space .and space .and function_decl_identifier .and lparen;
+function_header_nospace
+ fully_specified_type_nospace .and function_decl_identifier .and lparen;
+
+/*
+ <function_decl_identifier> ::= "__constructor"
+ | <__operator>
+ | <identifier>
+
+note: this is an extension to the standard language specification - normally slang disallows
+ operator and constructor prototypes and definitions
+*/
+function_decl_identifier
+ .if (parsing_builtin != 0) __operator .emit FUNCTION_OPERATOR .or
+ .if (parsing_builtin != 0) "__constructor" .emit FUNCTION_CONSTRUCTOR .or
+ identifier .emit FUNCTION_ORDINARY;
+
+/*
+ <__operator> ::= "__operator" <overriden_op>
+
+note: this is an extension to the standard language specification - normally slang disallows
+ operator prototypes and definitions
+*/
+__operator
+ "__operator" .and overriden_operator .error INVALID_OPERATOR_OVERRIDE;
+
+/*
+ <overriden_op> ::= "="
+ | "+="
+ | "-="
+ | "*="
+ | "/="
+ | "%=" // reserved
+ | "<<=" // reserved
+ | ">>=" // reserved
+ | "&=" // reserved
+ | "^=" // reserved
+ | "|=" // reserved
+ | "^^"
+ | "|" // reserved
+ | "^" // reserved
+ | "&" // reserved
+ | "=="
+ | "!="
+ | "<"
+ | ">"
+ | "<="
+ | ">="
+ | "<<" // reserved
+ | ">>" // reserved
+ | "*"
+ | "/"
+ | "%" // reserved
+ | "++"
+ | "--"
+ | "+"
+ | "-"
+ | "~" // reserved
+ | "!"
+
+note: this is an extension to the standard language specification - normally slang disallows
+ operator prototypes and definitions
+*/
+overriden_operator
+ plusplus .emit OPERATOR_INCREMENT .or
+ plusequals .emit OPERATOR_ADDASSIGN .or
+ plus .emit OPERATOR_PLUS .or
+ minusminus .emit OPERATOR_DECREMENT .or
+ minusequals .emit OPERATOR_SUBASSIGN .or
+ minus .emit OPERATOR_MINUS .or
+ bangequals .emit OPERATOR_NOTEQUAL .or
+ bang .emit OPERATOR_NOT .or
+ starequals .emit OPERATOR_MULASSIGN .or
+ star .emit OPERATOR_MULTIPLY .or
+ slashequals .emit OPERATOR_DIVASSIGN .or
+ slash .emit OPERATOR_DIVIDE .or
+ lessequals .emit OPERATOR_LESSEQUAL .or
+ /*lesslessequals .emit OPERATOR_LSHASSIGN .or*/
+ /*lessless .emit OPERATOR_LSHIFT .or*/
+ less .emit OPERATOR_LESS .or
+ greaterequals .emit OPERATOR_GREATEREQUAL .or
+ /*greatergreaterequals .emit OPERATOR_RSHASSIGN .or*/
+ /*greatergreater .emit OPERATOR_RSHIFT .or*/
+ greater .emit OPERATOR_GREATER .or
+ equalsequals .emit OPERATOR_EQUAL .or
+ equals .emit OPERATOR_ASSIGN .or
+ /*percentequals .emit OPERATOR_MODASSIGN .or*/
+ /*percent .emit OPERATOR_MODULUS .or*/
+ /*ampersandequals .emit OPERATOR_ANDASSIGN */
+ /*ampersand .emit OPERATOR_BITAND .or*/
+ /*barequals .emit OPERATOR_ORASSIGN .or*/
+ /*bar .emit OPERATOR_BITOR .or*/
+ /*tilde .emit OPERATOR_COMPLEMENT .or*/
+ /*caretequals .emit OPERATOR_XORASSIGN .or*/
+ caretcaret .emit OPERATOR_LOGICALXOR /*.or
+ caret .emit OPERATOR_BITXOR*/;
+
+/*
+ <parameter_declarator> ::= <type_specifier> <identifier>
+ | <type_specifier> <identifier> "[" <constant_expression>
+ "]"
+*/
+parameter_declarator
+ parameter_declarator_nospace .or parameter_declarator_space;
+parameter_declarator_nospace
+ type_specifier_nospace .and identifier .and parameter_declarator_1;
+parameter_declarator_space
+ type_specifier_space .and space .and identifier .and parameter_declarator_1;
+parameter_declarator_1
+ parameter_declarator_2 .emit PARAMETER_ARRAY_PRESENT .or
+ .true .emit PARAMETER_ARRAY_NOT_PRESENT;
+parameter_declarator_2
+ lbracket .and constant_expression .and rbracket;
+
+/*
+ <parameter_declaration> ::= <type_qualifier> <parameter_qualifier>
+ <parameter_declarator>
+ | <type_qualifier> <parameter_qualifier>
+ <parameter_type_specifier>
+ | <parameter_qualifier> <parameter_declarator>
+ | <parameter_qualifier> <parameter_type_specifier>
+*/
+parameter_declaration
+ parameter_declaration_1 .emit PARAMETER_NEXT;
+parameter_declaration_1
+ parameter_declaration_2 .or parameter_declaration_3;
+parameter_declaration_2
+ type_qualifier .and space .and parameter_qualifier .and parameter_declaration_4;
+parameter_declaration_3
+ parameter_qualifier .emit TYPE_QUALIFIER_NONE .and parameter_declaration_4;
+parameter_declaration_4
+ parameter_declarator .or parameter_type_specifier;
+
+/*
+ <parameter_qualifier> ::= "in"
+ | "out"
+ | "inout"
+ | ""
+*/
+parameter_qualifier
+ parameter_qualifier_1 .or .true .emit PARAM_QUALIFIER_IN;
+parameter_qualifier_1
+ parameter_qualifier_2 .and space;
+parameter_qualifier_2
+ "in" .emit PARAM_QUALIFIER_IN .or
+ "out" .emit PARAM_QUALIFIER_OUT .or
+ "inout" .emit PARAM_QUALIFIER_INOUT;
+
+/*
+ <parameter_type_specifier> ::= <type_specifier>
+ | <type_specifier> "[" <constant_expression> "]"
+*/
+parameter_type_specifier
+ parameter_type_specifier_1 .and .true .emit '\0' .and parameter_type_specifier_2;
+parameter_type_specifier_1
+ type_specifier_nospace .or type_specifier_space;
+parameter_type_specifier_2
+ parameter_type_specifier_3 .emit PARAMETER_ARRAY_PRESENT .or
+ .true .emit PARAMETER_ARRAY_NOT_PRESENT;
+parameter_type_specifier_3
+ lbracket .and constant_expression .and rbracket;
+
+/*
+ <init_declarator_list> ::= <single_declaration>
+ | <init_declarator_list> "," <identifier>
+ | <init_declarator_list> "," <identifier> "[" "]"
+ | <init_declarator_list> "," <identifier> "["
+ <constant_expression> "]"
+ | <init_declarator_list> "," <identifier> "="
+ <initializer>
+*/
+init_declarator_list
+ single_declaration .and .loop init_declarator_list_1 .emit DECLARATOR_NEXT .and
+ .true .emit DECLARATOR_NONE;
+init_declarator_list_1
+ comma .and identifier .emit VARIABLE_IDENTIFIER .and init_declarator_list_2;
+init_declarator_list_2
+ init_declarator_list_3 .or init_declarator_list_4 .or .true .emit VARIABLE_NONE;
+init_declarator_list_3
+ equals .and initializer .emit VARIABLE_INITIALIZER;
+init_declarator_list_4
+ lbracket .and init_declarator_list_5 .and rbracket;
+init_declarator_list_5
+ constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;
+
+/*
+ <single_declaration> ::= <fully_specified_type>
+ | <fully_specified_type> <identifier>
+ | <fully_specified_type> <identifier> "[" "]"
+ | <fully_specified_type> <identifier> "["
+ <constant_expression> "]"
+ | <fully_specified_type> <identifier> "=" <initializer>
+*/
+single_declaration
+ single_declaration_nospace .or single_declaration_space;
+single_declaration_space
+ fully_specified_type_space .and single_declaration_space_1;
+single_declaration_nospace
+ fully_specified_type_nospace .and single_declaration_nospace_1;
+single_declaration_space_1
+ single_declaration_space_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;
+single_declaration_nospace_1
+ single_declaration_nospace_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;
+single_declaration_space_2
+ space .and identifier .and single_declaration_3;
+single_declaration_nospace_2
+ identifier .and single_declaration_3;
+single_declaration_3
+ single_declaration_4 .or single_declaration_5 .or .true .emit VARIABLE_NONE;
+single_declaration_4
+ equals .and initializer .emit VARIABLE_INITIALIZER;
+single_declaration_5
+ lbracket .and single_declaration_6 .and rbracket;
+single_declaration_6
+ constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;
+
+/*
+ <fully_specified_type> ::= <type_specifier>
+ | <type_qualifier> <type_specifier>
+*/
+fully_specified_type_space
+ fully_specified_type_1 .and type_specifier_space;
+fully_specified_type_nospace
+ fully_specified_type_1 .and type_specifier_nospace;
+fully_specified_type_1
+ fully_specified_type_2 .or .true .emit TYPE_QUALIFIER_NONE;
+fully_specified_type_2
+ type_qualifier .and space;
+
+/*
+ <type_qualifier> ::= "const"
+ | "attribute" // Vertex only.
+ | "varying"
+ | "uniform"
+ | "__fixed_output"
+ | "__fixed_input"
+
+note: this is an extension to the standard language specification - normally slang disallows
+ __fixed_output and __fixed_input type qualifiers
+*/
+type_qualifier
+ "const" .emit TYPE_QUALIFIER_CONST .or
+ .if (shader_type == 2) "attribute" .emit TYPE_QUALIFIER_ATTRIBUTE .or
+ "varying" .emit TYPE_QUALIFIER_VARYING .or
+ "uniform" .emit TYPE_QUALIFIER_UNIFORM .or
+ .if (parsing_builtin != 0) "__fixed_output" .emit TYPE_QUALIFIER_FIXEDOUTPUT .or
+ .if (parsing_builtin != 0) "__fixed_input" .emit TYPE_QUALIFIER_FIXEDINPUT;
+
+/*
+ <type_specifier> ::= "void"
+ | "float"
+ | "int"
+ | "bool"
+ | "vec2"
+ | "vec3"
+ | "vec4"
+ | "bvec2"
+ | "bvec3"
+ | "bvec4"
+ | "ivec2"
+ | "ivec3"
+ | "ivec4"
+ | "mat2"
+ | "mat3"
+ | "mat4"
+ | "sampler1D"
+ | "sampler2D"
+ | "sampler3D"
+ | "samplerCube"
+ | "sampler1DShadow"
+ | "sampler2DShadow"
+ | <struct_specifier>
+ | <type_name>
+*/
+type_specifier_space
+ "void" .emit TYPE_SPECIFIER_VOID .or
+ "float" .emit TYPE_SPECIFIER_FLOAT .or
+ "int" .emit TYPE_SPECIFIER_INT .or
+ "bool" .emit TYPE_SPECIFIER_BOOL .or
+ "vec2" .emit TYPE_SPECIFIER_VEC2 .or
+ "vec3" .emit TYPE_SPECIFIER_VEC3 .or
+ "vec4" .emit TYPE_SPECIFIER_VEC4 .or
+ "bvec2" .emit TYPE_SPECIFIER_BVEC2 .or
+ "bvec3" .emit TYPE_SPECIFIER_BVEC3 .or
+ "bvec4" .emit TYPE_SPECIFIER_BVEC4 .or
+ "ivec2" .emit TYPE_SPECIFIER_IVEC2 .or
+ "ivec3" .emit TYPE_SPECIFIER_IVEC3 .or
+ "ivec4" .emit TYPE_SPECIFIER_IVEC4 .or
+ "mat2" .emit TYPE_SPECIFIER_MAT2 .or
+ "mat3" .emit TYPE_SPECIFIER_MAT3 .or
+ "mat4" .emit TYPE_SPECIFIER_MAT4 .or
+ "sampler1D" .emit TYPE_SPECIFIER_SAMPLER1D .or
+ "sampler2D" .emit TYPE_SPECIFIER_SAMPLER2D .or
+ "sampler3D" .emit TYPE_SPECIFIER_SAMPLER3D .or
+ "samplerCube" .emit TYPE_SPECIFIER_SAMPLERCUBE .or
+ "sampler1DShadow" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or
+ "sampler2DShadow" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or
+ type_name .emit TYPE_SPECIFIER_TYPENAME;
+type_specifier_nospace
+ struct_specifier .emit TYPE_SPECIFIER_STRUCT;
+
+/*
+ <struct_specifier> ::= "struct" <identifier> "{" <struct_declaration_list> "}"
+ | "struct" "{" <struct_declaration_list> "}"
+*/
+struct_specifier
+ "struct" .and struct_specifier_1 .and optional_space .and lbrace .error LBRACE_EXPECTED .and
+ struct_declaration_list .and rbrace .emit FIELD_NONE;
+struct_specifier_1
+ struct_specifier_2 .or .true .emit '\0';
+struct_specifier_2
+ space .and identifier;
+
+/*
+ <struct_declaration_list> ::= <struct_declaration>
+ | <struct_declaration_list> <struct_declaration>
+*/
+struct_declaration_list
+ struct_declaration .and .loop struct_declaration .emit FIELD_NEXT;
+
+/*
+ <struct_declaration> ::= <type_specifier> <struct_declarator_list> ";"
+*/
+struct_declaration
+ struct_declaration_nospace .or struct_declaration_space;
+struct_declaration_space
+ type_specifier_space .and space .and struct_declarator_list .and semicolon .emit FIELD_NONE;
+struct_declaration_nospace
+ type_specifier_nospace .and struct_declarator_list .and semicolon .emit FIELD_NONE;
+
+/*
+ <struct_declarator_list> ::= <struct_declarator>
+ | <struct_declarator_list> "," <struct_declarator>
+*/
+struct_declarator_list
+ struct_declarator .and .loop struct_declarator_list_1 .emit FIELD_NEXT;
+struct_declarator_list_1
+ comma .and struct_declarator;
+
+/*
+ <struct_declarator> ::= <identifier>
+ | <identifier> "[" <constant_expression> "]"
+*/
+struct_declarator
+ identifier .and struct_declarator_1;
+struct_declarator_1
+ struct_declarator_2 .emit FIELD_ARRAY .or .true .emit FIELD_NONE;
+struct_declarator_2
+ lbracket .and constant_expression .and rbracket;
+
+/*
+ <initializer> ::= <assignment_expression>
+*/
+initializer
+ assignment_expression .and .true .emit OP_END;
+
+/*
+ <declaration_statement> ::= <declaration>
+*/
+declaration_statement
+ declaration;
+
+/*
+ <statement> ::= <compound_statement>
+ | <simple_statement>
+*/
+statement
+ compound_statement .or simple_statement;
+statement_space
+ compound_statement .or statement_space_1;
+statement_space_1
+ space .and simple_statement;
+
+/*
+ <simple_statement> ::= <__asm_statement>
+ | <selection_statement>
+ | <iteration_statement>
+ | <jump_statement>
+ | <expression_statement>
+ | <declaration_statement>
+
+note: this is an extension to the standard language specification - normally slang disallows
+ use of __asm statements
+*/
+simple_statement
+ .if (parsing_builtin != 0) __asm_statement .emit OP_ASM .or
+ selection_statement .or
+ iteration_statement .or
+ jump_statement .or
+ expression_statement .emit OP_EXPRESSION .or
+ declaration_statement .emit OP_DECLARE;
+
+/*
+ <compound_statement> ::= "{" "}"
+ | "{" <statement_list> "}"
+*/
+compound_statement
+ compound_statement_1 .emit OP_BLOCK_BEGIN_NEW_SCOPE .and .true .emit OP_END;
+compound_statement_1
+ compound_statement_2 .or compound_statement_3;
+compound_statement_2
+ lbrace .and rbrace;
+compound_statement_3
+ lbrace .and statement_list .and rbrace;
+
+/*
+ <statement_no_new_scope> ::= <compound_statement_no_new_scope>
+ | <simple_statement>
+*/
+statement_no_new_scope
+ compound_statement_no_new_scope .or simple_statement;
+
+/*
+ <compound_statement_no_new_scope> ::= "{" "}"
+ | "{" <statement_list> "}"
+*/
+compound_statement_no_new_scope
+ compound_statement_no_new_scope_1 .emit OP_BLOCK_BEGIN_NO_NEW_SCOPE .and .true .emit OP_END;
+compound_statement_no_new_scope_1
+ compound_statement_no_new_scope_2 .or compound_statement_no_new_scope_3;
+compound_statement_no_new_scope_2
+ lbrace .and rbrace;
+compound_statement_no_new_scope_3
+ lbrace .and statement_list .and rbrace;
+
+/*
+ <statement_list> ::= <statement>
+ | <statement_list> <statement>
+*/
+statement_list
+ statement .and .loop statement;
+
+/*
+ <expression_statement> ::= ";"
+ | <expression> ";"
+*/
+expression_statement
+ expression_statement_1 .or expression_statement_2;
+expression_statement_1
+ semicolon .emit OP_PUSH_VOID .emit OP_END;
+expression_statement_2
+ expression .and semicolon .emit OP_END;
+
+/*
+ <selection_statement> ::= "if" "(" <expression> ")" <selection_rest_statement>
+*/
+selection_statement
+ "if" .emit OP_IF .and lparen .error LPAREN_EXPECTED .and expression .and
+ rparen .error RPAREN_EXPECTED .emit OP_END .and selection_rest_statement;
+
+/*
+ <selection_rest_statement> ::= <statement> "else" <statement>
+ | <statement>
+*/
+selection_rest_statement
+ statement .and selection_rest_statement_1;
+selection_rest_statement_1
+ selection_rest_statement_2 .or .true .emit OP_EXPRESSION .emit OP_PUSH_VOID .emit OP_END;
+selection_rest_statement_2
+ "else" .and optional_space .and statement;
+
+/*
+ <condition> ::= <expression>
+ | <fully_specified_type> <identifier> "=" <initializer>
+
+note: if <condition_1> is executed, the emit format must match <declaration> emit format
+*/
+condition
+ condition_1 .emit OP_DECLARE .emit DECLARATION_INIT_DECLARATOR_LIST .or
+ condition_3 .emit OP_EXPRESSION;
+condition_1
+ condition_1_nospace .or condition_1_space;
+condition_1_nospace
+ fully_specified_type_nospace .and condition_2;
+condition_1_space
+ fully_specified_type_space .and space .and condition_2;
+condition_2
+ identifier .emit VARIABLE_IDENTIFIER .and equals .emit VARIABLE_INITIALIZER .and
+ initializer .and .true .emit DECLARATOR_NONE;
+condition_3
+ expression .and .true .emit OP_END;
+
+/*
+ <iteration_statement> ::= "while" "(" <condition> ")" <statement_no_new_scope>
+ | "do" <statement> "while" "(" <expression> ")" ";"
+ | "for" "(" <for_init_statement> <for_rest_statement> ")"
+ <statement_no_new_scope>
+*/
+iteration_statement
+ iteration_statement_1 .or iteration_statement_2 .or iteration_statement_3;
+iteration_statement_1
+ "while" .emit OP_WHILE .and lparen .error LPAREN_EXPECTED .and condition .and
+ rparen .error RPAREN_EXPECTED .and statement_no_new_scope;
+iteration_statement_2
+ "do" .emit OP_DO .and statement_space .and "while" .and lparen .error LPAREN_EXPECTED .and
+ expression .and rparen .error RPAREN_EXPECTED .emit OP_END .and semicolon;
+iteration_statement_3
+ "for" .emit OP_FOR .and lparen .error LPAREN_EXPECTED .and for_init_statement .and
+ for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement_no_new_scope;
+
+/*
+ <for_init_statement> ::= <expression_statement>
+ | <declaration_statement>
+*/
+for_init_statement
+ expression_statement .emit OP_EXPRESSION .or declaration_statement .emit OP_DECLARE;
+
+/*
+ <conditionopt> ::= <condition>
+ | ""
+
+note: <conditionopt> is used only by "for" statement - if <condition> is ommitted, parser
+ simulates default behaviour, that is simulates "true" expression
+*/
+conditionopt
+ condition .or
+ .true .emit OP_EXPRESSION .emit OP_PUSH_BOOL .emit 2 .emit '1' .emit '\0' .emit OP_END;
+
+/*
+ <for_rest_statement> ::= <conditionopt> ";"
+ | <conditionopt> ";" <expression>
+*/
+for_rest_statement
+ conditionopt .and semicolon .and for_rest_statement_1;
+for_rest_statement_1
+ for_rest_statement_2 .or .true .emit OP_PUSH_VOID .emit OP_END;
+for_rest_statement_2
+ expression .and .true .emit OP_END;
+
+/*
+ <jump_statement> ::= "continue" ";"
+ | "break" ";"
+ | "return" ";"
+ | "return" <expression> ";"
+ | "discard" ";" // Fragment shader only.
+*/
+jump_statement
+ jump_statement_1 .or jump_statement_2 .or jump_statement_3 .or jump_statement_4 .or
+ .if (shader_type == 1) jump_statement_5;
+jump_statement_1
+ "continue" .and semicolon .emit OP_CONTINUE;
+jump_statement_2
+ "break" .and semicolon .emit OP_BREAK;
+jump_statement_3
+ "return" .emit OP_RETURN .and optional_space .and expression .and semicolon .emit OP_END;
+jump_statement_4
+ "return" .emit OP_RETURN .and semicolon .emit OP_PUSH_VOID .emit OP_END;
+jump_statement_5
+ "discard" .and semicolon .emit OP_DISCARD;
+
+/*
+ <__asm_statement> ::= "__asm" <identifier> <asm_arguments> ";"
+
+note: this is an extension to the standard language specification - normally slang disallows
+ __asm statements
+*/
+__asm_statement
+ "__asm" .and space .and identifier .and space .and asm_arguments .and semicolon .emit OP_END;
+
+/*
+ <asm_arguments> ::= <identifier>
+ | <asm_arguments> "," <identifier>
+
+note: this is an extension to the standard language specification - normally slang disallows
+ __asm statements
+*/
+asm_arguments
+ variable_identifier .and .true .emit OP_END .and .loop asm_arguments_1;
+asm_arguments_1
+ comma .and variable_identifier .and .true .emit OP_END;
+
+/*
+ <translation_unit> ::= <external_declaration>
+ | <translation_unit> <external_declaration>
+*/
+translation_unit
+ optional_space .emit REVISION .and external_declaration .error INVALID_EXTERNAL_DECLARATION .and
+ .loop external_declaration .and optional_space .and
+ '\0' .error INVALID_EXTERNAL_DECLARATION .emit EXTERNAL_NULL;
+
+/*
+ <external_declaration> ::= <function_definition>
+ | <declaration>
+*/
+external_declaration
+ function_definition .emit EXTERNAL_FUNCTION_DEFINITION .or
+ declaration .emit EXTERNAL_DECLARATION;
+
+/*
+ <function_definition> :: <function_prototype> <compound_statement_no_new_scope>
+*/
+function_definition
+ function_prototype .and compound_statement_no_new_scope;
+
+/* helper rulez, not part of the official language syntax */
+
+digit_oct
+ '0'-'7';
+
+digit_dec
+ '0'-'9';
+
+digit_hex
+ '0'-'9' .or 'A'-'F' .or 'a'-'f';
+
+id_character_first
+ 'a'-'z' .or 'A'-'Z' .or '_';
+
+id_character_next
+ id_character_first .or digit_dec;
+
+identifier
+ id_character_first .emit * .and .loop id_character_next .emit * .and .true .emit '\0';
+
+float
+ float_1 .or float_2;
+float_1
+ float_fractional_constant .and float_optional_exponent_part;
+float_2
+ float_digit_sequence .and .true .emit '\0' .and float_exponent_part;
+
+float_fractional_constant
+ float_fractional_constant_1 .or float_fractional_constant_2 .or float_fractional_constant_3;
+float_fractional_constant_1
+ float_digit_sequence .and '.' .and float_digit_sequence;
+float_fractional_constant_2
+ float_digit_sequence .and '.' .and .true .emit '\0';
+float_fractional_constant_3
+ '.' .emit '\0' .and float_digit_sequence;
+
+float_optional_exponent_part
+ float_exponent_part .or .true .emit '\0';
+
+float_digit_sequence
+ digit_dec .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
+
+float_exponent_part
+ float_exponent_part_1 .or float_exponent_part_2;
+float_exponent_part_1
+ 'e' .and float_optional_sign .and float_digit_sequence;
+float_exponent_part_2
+ 'E' .and float_optional_sign .and float_digit_sequence;
+
+float_optional_sign
+ float_sign .or .true;
+
+float_sign
+ '+' .or '-' .emit '-';
+
+integer
+ integer_hex .or integer_oct .or integer_dec;
+
+integer_hex
+ '0' .and integer_hex_1 .emit 0x10 .and digit_hex .emit * .and .loop digit_hex .emit * .and
+ .true .emit '\0';
+integer_hex_1
+ 'x' .or 'X';
+
+integer_oct
+ '0' .emit 8 .emit * .and .loop digit_oct .emit * .and .true .emit '\0';
+
+integer_dec
+ digit_dec .emit 10 .emit * .and .loop digit_dec .emit * .and .true .emit '\0';
+
+boolean
+ "true" .emit 2 .emit '1' .emit '\0' .or
+ "false" .emit 2 .emit '0' .emit '\0';
+
+type_name
+ identifier;
+
+field_selection
+ identifier;
+
+floatconstant
+ float .emit OP_PUSH_FLOAT;
+
+intconstant
+ integer .emit OP_PUSH_INT;
+
+boolconstant
+ boolean .emit OP_PUSH_BOOL;
+
+optional_space
+ .loop single_space;
+
+space
+ single_space .and .loop single_space;
+
+single_space
+ white_char .or c_style_comment_block .or cpp_style_comment_block;
+
+white_char
+ ' ' .or '\t' .or new_line .or '\v' .or '\f';
+
+new_line
+ cr_lf .or lf_cr .or '\n' .or '\r';
+
+cr_lf
+ '\r' .and '\n';
+
+lf_cr
+ '\n' .and '\r';
+
+c_style_comment_block
+ '/' .and '*' .and c_style_comment_rest;
+
+c_style_comment_rest
+ .loop c_style_comment_char_no_star .and c_style_comment_rest_1;
+c_style_comment_rest_1
+ c_style_comment_end .or c_style_comment_rest_2;
+c_style_comment_rest_2
+ '*' .and c_style_comment_rest;
+
+c_style_comment_char_no_star
+ '\x2B'-'\xFF' .or '\x01'-'\x29';
+
+c_style_comment_end
+ '*' .and '/';
+
+cpp_style_comment_block
+ '/' .and '/' .and cpp_style_comment_block_1;
+cpp_style_comment_block_1
+ cpp_style_comment_block_2 .or cpp_style_comment_block_3;
+cpp_style_comment_block_2
+ .loop cpp_style_comment_char .and new_line;
+cpp_style_comment_block_3
+ .loop cpp_style_comment_char;
+
+cpp_style_comment_char
+ '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
+
+/* lexical rulez */
+
+/*ampersand
+ optional_space .and '&' .and optional_space;*/
+
+ampersandampersand
+ optional_space .and '&' .and '&' .and optional_space;
+
+/*ampersandequals
+ optional_space .and '&' .and '=' .and optional_space;*/
+
+/*bar
+ optional_space .and '|' .and optional_space;*/
+
+barbar
+ optional_space .and '|' .and '|' .and optional_space;
+
+/*barequals
+ optional_space .and '|' .and '=' .and optional_space;*/
+
+bang
+ optional_space .and '!' .and optional_space;
+
+bangequals
+ optional_space .and '!' .and '=' .and optional_space;
+
+/*caret
+ optional_space .and '^' .and optional_space;*/
+
+caretcaret
+ optional_space .and '^' .and '^' .and optional_space;
+
+/*caretequals
+ optional_space .and '^' .and '=' .and optional_space;*/
+
+colon
+ optional_space .and ':' .and optional_space;
+
+comma
+ optional_space .and ',' .and optional_space;
+
+dot
+ optional_space .and '.' .and optional_space;
+
+equals
+ optional_space .and '=' .and optional_space;
+
+equalsequals
+ optional_space .and '=' .and '=' .and optional_space;
+
+greater
+ optional_space .and '>' .and optional_space;
+
+greaterequals
+ optional_space .and '>' .and '=' .and optional_space;
+
+/*greatergreater
+ optional_space .and '>' .and '>' .and optional_space;*/
+
+/*greatergreaterequals
+ optional_space .and '>' .and '>' .and '=' .and optional_space;*/
+
+lbrace
+ optional_space .and '{' .and optional_space;
+
+lbracket
+ optional_space .and '[' .and optional_space;
+
+less
+ optional_space .and '<' .and optional_space;
+
+lessequals
+ optional_space .and '<' .and '=' .and optional_space;
+
+/*lessless
+ optional_space .and '<' .and '<' .and optional_space;*/
+
+/*lesslessequals
+ optional_space .and '<' .and '<' .and '=' .and optional_space;*/
+
+lparen
+ optional_space .and '(' .and optional_space;
+
+minus
+ optional_space .and '-' .and optional_space;
+
+minusequals
+ optional_space .and '-' .and '=' .and optional_space;
+
+minusminus
+ optional_space .and '-' .and '-' .and optional_space;
+
+/*percent
+ optional_space .and '%' .and optional_space;*/
+
+/*percentequals
+ optional_space .and '%' .and '=' .and optional_space;*/
+
+plus
+ optional_space .and '+' .and optional_space;
+
+plusequals
+ optional_space .and '+' .and '=' .and optional_space;
+
+plusplus
+ optional_space .and '+' .and '+' .and optional_space;
+
+question
+ optional_space .and '?' .and optional_space;
+
+rbrace
+ optional_space .and '}' .and optional_space;
+
+rbracket
+ optional_space .and ']' .and optional_space;
+
+rparen
+ optional_space .and ')' .and optional_space;
+
+semicolon
+ optional_space .and ';' .and optional_space;
+
+slash
+ optional_space .and '/' .and optional_space;
+
+slashequals
+ optional_space .and '/' .and '=' .and optional_space;
+
+star
+ optional_space .and '*' .and optional_space;
+
+starequals
+ optional_space .and '*' .and '=' .and optional_space;
+
+/*tilde
+ optional_space .and '~' .and optional_space;*/
+
+/* string rulez - these are used internally by the parser when parsing quoted strings */
+
+.string string_lexer;
+
+string_lexer
+ lex_first_identifier_character .and .loop lex_next_identifier_character;
+
+lex_first_identifier_character
+ 'a'-'z' .or 'A'-'Z' .or '_';
+
+lex_next_identifier_character
+ 'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';
+
+/* error rulez - these are used by error messages */
+
+err_token
+ '~' .or '`' .or '!' .or '@' .or '#' .or '$' .or '%' .or '^' .or '&' .or '*' .or '(' .or ')' .or
+ '-' .or '+' .or '=' .or '|' .or '\\' .or '[' .or ']' .or '{' .or '}' .or ':' .or ';' .or '"' .or
+ '\'' .or '<' .or ',' .or '>' .or '.' .or '/' .or '?' .or err_identifier;
+
+err_identifier
+ id_character_first .and .loop id_character_next;
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_shader_syn.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_shader_syn.h
new file mode 100644
index 000000000..4645e1419
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_shader_syn.h
@@ -0,0 +1,758 @@
+".syntax translation_unit;\n"
+".emtcode REVISION 2\n"
+".emtcode EXTERNAL_NULL 0\n"
+".emtcode EXTERNAL_FUNCTION_DEFINITION 1\n"
+".emtcode EXTERNAL_DECLARATION 2\n"
+".emtcode DECLARATION_FUNCTION_PROTOTYPE 1\n"
+".emtcode DECLARATION_INIT_DECLARATOR_LIST 2\n"
+".emtcode FUNCTION_ORDINARY 0\n"
+".emtcode FUNCTION_CONSTRUCTOR 1\n"
+".emtcode FUNCTION_OPERATOR 2\n"
+".emtcode OPERATOR_ASSIGN 1\n"
+".emtcode OPERATOR_ADDASSIGN 2\n"
+".emtcode OPERATOR_SUBASSIGN 3\n"
+".emtcode OPERATOR_MULASSIGN 4\n"
+".emtcode OPERATOR_DIVASSIGN 5\n"
+".emtcode OPERATOR_LOGICALXOR 12\n"
+".emtcode OPERATOR_EQUAL 16\n"
+".emtcode OPERATOR_NOTEQUAL 17\n"
+".emtcode OPERATOR_LESS 18\n"
+".emtcode OPERATOR_GREATER 19\n"
+".emtcode OPERATOR_LESSEQUAL 20\n"
+".emtcode OPERATOR_GREATEREQUAL 21\n"
+".emtcode OPERATOR_MULTIPLY 24\n"
+".emtcode OPERATOR_DIVIDE 25\n"
+".emtcode OPERATOR_INCREMENT 27\n"
+".emtcode OPERATOR_DECREMENT 28\n"
+".emtcode OPERATOR_PLUS 29\n"
+".emtcode OPERATOR_MINUS 30\n"
+".emtcode OPERATOR_NOT 32\n"
+".emtcode DECLARATOR_NONE 0\n"
+".emtcode DECLARATOR_NEXT 1\n"
+".emtcode VARIABLE_NONE 0\n"
+".emtcode VARIABLE_IDENTIFIER 1\n"
+".emtcode VARIABLE_INITIALIZER 2\n"
+".emtcode VARIABLE_ARRAY_EXPLICIT 3\n"
+".emtcode VARIABLE_ARRAY_UNKNOWN 4\n"
+".emtcode TYPE_QUALIFIER_NONE 0\n"
+".emtcode TYPE_QUALIFIER_CONST 1\n"
+".emtcode TYPE_QUALIFIER_ATTRIBUTE 2\n"
+".emtcode TYPE_QUALIFIER_VARYING 3\n"
+".emtcode TYPE_QUALIFIER_UNIFORM 4\n"
+".emtcode TYPE_QUALIFIER_FIXEDOUTPUT 5\n"
+".emtcode TYPE_QUALIFIER_FIXEDINPUT 6\n"
+".emtcode TYPE_SPECIFIER_VOID 0\n"
+".emtcode TYPE_SPECIFIER_BOOL 1\n"
+".emtcode TYPE_SPECIFIER_BVEC2 2\n"
+".emtcode TYPE_SPECIFIER_BVEC3 3\n"
+".emtcode TYPE_SPECIFIER_BVEC4 4\n"
+".emtcode TYPE_SPECIFIER_INT 5\n"
+".emtcode TYPE_SPECIFIER_IVEC2 6\n"
+".emtcode TYPE_SPECIFIER_IVEC3 7\n"
+".emtcode TYPE_SPECIFIER_IVEC4 8\n"
+".emtcode TYPE_SPECIFIER_FLOAT 9\n"
+".emtcode TYPE_SPECIFIER_VEC2 10\n"
+".emtcode TYPE_SPECIFIER_VEC3 11\n"
+".emtcode TYPE_SPECIFIER_VEC4 12\n"
+".emtcode TYPE_SPECIFIER_MAT2 13\n"
+".emtcode TYPE_SPECIFIER_MAT3 14\n"
+".emtcode TYPE_SPECIFIER_MAT4 15\n"
+".emtcode TYPE_SPECIFIER_SAMPLER1D 16\n"
+".emtcode TYPE_SPECIFIER_SAMPLER2D 17\n"
+".emtcode TYPE_SPECIFIER_SAMPLER3D 18\n"
+".emtcode TYPE_SPECIFIER_SAMPLERCUBE 19\n"
+".emtcode TYPE_SPECIFIER_SAMPLER1DSHADOW 20\n"
+".emtcode TYPE_SPECIFIER_SAMPLER2DSHADOW 21\n"
+".emtcode TYPE_SPECIFIER_STRUCT 22\n"
+".emtcode TYPE_SPECIFIER_TYPENAME 23\n"
+".emtcode FIELD_NONE 0\n"
+".emtcode FIELD_NEXT 1\n"
+".emtcode FIELD_ARRAY 2\n"
+".emtcode OP_END 0\n"
+".emtcode OP_BLOCK_BEGIN_NO_NEW_SCOPE 1\n"
+".emtcode OP_BLOCK_BEGIN_NEW_SCOPE 2\n"
+".emtcode OP_DECLARE 3\n"
+".emtcode OP_ASM 4\n"
+".emtcode OP_BREAK 5\n"
+".emtcode OP_CONTINUE 6\n"
+".emtcode OP_DISCARD 7\n"
+".emtcode OP_RETURN 8\n"
+".emtcode OP_EXPRESSION 9\n"
+".emtcode OP_IF 10\n"
+".emtcode OP_WHILE 11\n"
+".emtcode OP_DO 12\n"
+".emtcode OP_FOR 13\n"
+".emtcode OP_PUSH_VOID 14\n"
+".emtcode OP_PUSH_BOOL 15\n"
+".emtcode OP_PUSH_INT 16\n"
+".emtcode OP_PUSH_FLOAT 17\n"
+".emtcode OP_PUSH_IDENTIFIER 18\n"
+".emtcode OP_SEQUENCE 19\n"
+".emtcode OP_ASSIGN 20\n"
+".emtcode OP_ADDASSIGN 21\n"
+".emtcode OP_SUBASSIGN 22\n"
+".emtcode OP_MULASSIGN 23\n"
+".emtcode OP_DIVASSIGN 24\n"
+".emtcode OP_SELECT 31\n"
+".emtcode OP_LOGICALOR 32\n"
+".emtcode OP_LOGICALXOR 33\n"
+".emtcode OP_LOGICALAND 34\n"
+".emtcode OP_EQUAL 38\n"
+".emtcode OP_NOTEQUAL 39\n"
+".emtcode OP_LESS 40\n"
+".emtcode OP_GREATER 41\n"
+".emtcode OP_LESSEQUAL 42\n"
+".emtcode OP_GREATEREQUAL 43\n"
+".emtcode OP_ADD 46\n"
+".emtcode OP_SUBTRACT 47\n"
+".emtcode OP_MULTIPLY 48\n"
+".emtcode OP_DIVIDE 49\n"
+".emtcode OP_PREINCREMENT 51\n"
+".emtcode OP_PREDECREMENT 52\n"
+".emtcode OP_PLUS 53\n"
+".emtcode OP_MINUS 54\n"
+".emtcode OP_NOT 56\n"
+".emtcode OP_SUBSCRIPT 57\n"
+".emtcode OP_CALL 58\n"
+".emtcode OP_FIELD 59\n"
+".emtcode OP_POSTINCREMENT 60\n"
+".emtcode OP_POSTDECREMENT 61\n"
+".emtcode PARAM_QUALIFIER_IN 0\n"
+".emtcode PARAM_QUALIFIER_OUT 1\n"
+".emtcode PARAM_QUALIFIER_INOUT 2\n"
+".emtcode PARAMETER_NONE 0\n"
+".emtcode PARAMETER_NEXT 1\n"
+".emtcode PARAMETER_ARRAY_NOT_PRESENT 0\n"
+".emtcode PARAMETER_ARRAY_PRESENT 1\n"
+".errtext INVALID_EXTERNAL_DECLARATION \"error 2001: invalid external declaration\"\n"
+".errtext INVALID_OPERATOR_OVERRIDE \"error 2002: invalid operator override\"\n"
+".errtext LBRACE_EXPECTED \"error 2003: '{' expected but '$err_token$' found\"\n"
+".errtext LPAREN_EXPECTED \"error 2004: '(' expected but '$err_token$' found\"\n"
+".errtext RPAREN_EXPECTED \"error 2005: ')' expected but '$err_token$' found\"\n"
+".regbyte parsing_builtin 0\n"
+".regbyte shader_type 0\n"
+"variable_identifier\n"
+" identifier .emit OP_PUSH_IDENTIFIER;\n"
+"primary_expression\n"
+" floatconstant .or boolconstant .or intconstant .or variable_identifier .or primary_expression_1;\n"
+"primary_expression_1\n"
+" lparen .and expression .and rparen;\n"
+"postfix_expression\n"
+" postfix_expression_1 .and .loop postfix_expression_2;\n"
+"postfix_expression_1\n"
+" function_call .or primary_expression;\n"
+"postfix_expression_2\n"
+" postfix_expression_3 .or postfix_expression_4 .or\n"
+" plusplus .emit OP_POSTINCREMENT .or\n"
+" minusminus .emit OP_POSTDECREMENT;\n"
+"postfix_expression_3\n"
+" lbracket .and integer_expression .and rbracket .emit OP_SUBSCRIPT;\n"
+"postfix_expression_4\n"
+" dot .and field_selection .emit OP_FIELD;\n"
+"integer_expression\n"
+" expression;\n"
+"function_call\n"
+" function_call_generic .emit OP_CALL .and .true .emit OP_END;\n"
+"function_call_generic\n"
+" function_call_generic_1 .or function_call_generic_2;\n"
+"function_call_generic_1\n"
+" function_call_header_with_parameters .and rparen .error RPAREN_EXPECTED;\n"
+"function_call_generic_2\n"
+" function_call_header_no_parameters .and rparen .error RPAREN_EXPECTED;\n"
+"function_call_header_no_parameters\n"
+" function_call_header .and function_call_header_no_parameters_1;\n"
+"function_call_header_no_parameters_1\n"
+" \"void\" .or .true;\n"
+"function_call_header_with_parameters\n"
+" function_call_header .and assignment_expression .and .true .emit OP_END .and\n"
+" .loop function_call_header_with_parameters_1;\n"
+"function_call_header_with_parameters_1\n"
+" comma .and assignment_expression .and .true .emit OP_END;\n"
+"function_call_header\n"
+" function_identifier .and lparen;\n"
+"function_identifier\n"
+" identifier;\n"
+"unary_expression\n"
+" postfix_expression .or unary_expression_1 .or unary_expression_2 .or unary_expression_3 .or\n"
+" unary_expression_4 .or unary_expression_5;\n"
+"unary_expression_1\n"
+" plusplus .and unary_expression .and .true .emit OP_PREINCREMENT;\n"
+"unary_expression_2\n"
+" minusminus .and unary_expression .and .true .emit OP_PREDECREMENT;\n"
+"unary_expression_3\n"
+" plus .and unary_expression .and .true .emit OP_PLUS;\n"
+"unary_expression_4\n"
+" minus .and unary_expression .and .true .emit OP_MINUS;\n"
+"unary_expression_5\n"
+" bang .and unary_expression .and .true .emit OP_NOT;\n"
+"multiplicative_expression\n"
+" unary_expression .and .loop multiplicative_expression_1;\n"
+"multiplicative_expression_1\n"
+" multiplicative_expression_2 .or multiplicative_expression_3;\n"
+"multiplicative_expression_2\n"
+" star .and unary_expression .and .true .emit OP_MULTIPLY;\n"
+"multiplicative_expression_3\n"
+" slash .and unary_expression .and .true .emit OP_DIVIDE;\n"
+"additive_expression\n"
+" multiplicative_expression .and .loop additive_expression_1;\n"
+"additive_expression_1\n"
+" additive_expression_2 .or additive_expression_3;\n"
+"additive_expression_2\n"
+" plus .and multiplicative_expression .and .true .emit OP_ADD;\n"
+"additive_expression_3\n"
+" minus .and multiplicative_expression .and .true .emit OP_SUBTRACT;\n"
+"shift_expression\n"
+" additive_expression;\n"
+"relational_expression\n"
+" shift_expression .and .loop relational_expression_1;\n"
+"relational_expression_1\n"
+" relational_expression_2 .or relational_expression_3 .or relational_expression_4 .or\n"
+" relational_expression_5;\n"
+"relational_expression_2\n"
+" lessequals .and shift_expression .and .true .emit OP_LESSEQUAL;\n"
+"relational_expression_3\n"
+" greaterequals .and shift_expression .and .true .emit OP_GREATEREQUAL;\n"
+"relational_expression_4\n"
+" less .and shift_expression .and .true .emit OP_LESS;\n"
+"relational_expression_5\n"
+" greater .and shift_expression .and .true .emit OP_GREATER;\n"
+"equality_expression\n"
+" relational_expression .and .loop equality_expression_1;\n"
+"equality_expression_1\n"
+" equality_expression_2 .or equality_expression_3;\n"
+"equality_expression_2\n"
+" equalsequals .and relational_expression .and .true .emit OP_EQUAL;\n"
+"equality_expression_3\n"
+" bangequals .and relational_expression .and .true .emit OP_NOTEQUAL;\n"
+"and_expression\n"
+" equality_expression;\n"
+"exclusive_or_expression\n"
+" and_expression;\n"
+"inclusive_or_expression\n"
+" exclusive_or_expression;\n"
+"logical_and_expression\n"
+" inclusive_or_expression .and .loop logical_and_expression_1;\n"
+"logical_and_expression_1\n"
+" ampersandampersand .and inclusive_or_expression .and .true .emit OP_LOGICALAND;\n"
+"logical_xor_expression\n"
+" logical_and_expression .and .loop logical_xor_expression_1;\n"
+"logical_xor_expression_1\n"
+" caretcaret .and logical_and_expression .and .true .emit OP_LOGICALXOR;\n"
+"logical_or_expression\n"
+" logical_xor_expression .and .loop logical_or_expression_1;\n"
+"logical_or_expression_1\n"
+" barbar .and logical_xor_expression .and .true .emit OP_LOGICALOR;\n"
+"conditional_expression\n"
+" logical_or_expression .and .loop conditional_expression_1;\n"
+"conditional_expression_1\n"
+" question .and expression .and colon .and conditional_expression .and .true .emit OP_SELECT;\n"
+"assignment_expression\n"
+" assignment_expression_1 .or assignment_expression_2 .or assignment_expression_3 .or\n"
+" assignment_expression_4 .or assignment_expression_5 .or conditional_expression;\n"
+"assignment_expression_1\n"
+" unary_expression .and equals .and assignment_expression .and .true .emit OP_ASSIGN;\n"
+"assignment_expression_2\n"
+" unary_expression .and starequals .and assignment_expression .and .true .emit OP_MULASSIGN;\n"
+"assignment_expression_3\n"
+" unary_expression .and slashequals .and assignment_expression .and .true .emit OP_DIVASSIGN;\n"
+"assignment_expression_4\n"
+" unary_expression .and plusequals .and assignment_expression .and .true .emit OP_ADDASSIGN;\n"
+"assignment_expression_5\n"
+" unary_expression .and minusequals .and assignment_expression .and .true .emit OP_SUBASSIGN;\n"
+"expression\n"
+" assignment_expression .and .loop expression_1;\n"
+"expression_1\n"
+" comma .and assignment_expression .and .true .emit OP_SEQUENCE;\n"
+"constant_expression\n"
+" conditional_expression .and .true .emit OP_END;\n"
+"declaration\n"
+" declaration_1 .or declaration_2;\n"
+"declaration_1\n"
+" function_prototype .emit DECLARATION_FUNCTION_PROTOTYPE .and semicolon;\n"
+"declaration_2\n"
+" init_declarator_list .emit DECLARATION_INIT_DECLARATOR_LIST .and semicolon;\n"
+"function_prototype\n"
+" function_declarator .and rparen .error RPAREN_EXPECTED .emit PARAMETER_NONE;\n"
+"function_declarator\n"
+" function_header_with_parameters .or function_header;\n"
+"function_header_with_parameters\n"
+" function_header .and parameter_declaration .and .loop function_header_with_parameters_1;\n"
+"function_header_with_parameters_1\n"
+" comma .and parameter_declaration;\n"
+"function_header\n"
+" function_header_nospace .or function_header_space;\n"
+"function_header_space\n"
+" fully_specified_type_space .and space .and function_decl_identifier .and lparen;\n"
+"function_header_nospace\n"
+" fully_specified_type_nospace .and function_decl_identifier .and lparen;\n"
+"function_decl_identifier\n"
+" .if (parsing_builtin != 0) __operator .emit FUNCTION_OPERATOR .or\n"
+" .if (parsing_builtin != 0) \"__constructor\" .emit FUNCTION_CONSTRUCTOR .or\n"
+" identifier .emit FUNCTION_ORDINARY;\n"
+"__operator\n"
+" \"__operator\" .and overriden_operator .error INVALID_OPERATOR_OVERRIDE;\n"
+"overriden_operator\n"
+" plusplus .emit OPERATOR_INCREMENT .or\n"
+" plusequals .emit OPERATOR_ADDASSIGN .or\n"
+" plus .emit OPERATOR_PLUS .or\n"
+" minusminus .emit OPERATOR_DECREMENT .or\n"
+" minusequals .emit OPERATOR_SUBASSIGN .or\n"
+" minus .emit OPERATOR_MINUS .or\n"
+" bangequals .emit OPERATOR_NOTEQUAL .or\n"
+" bang .emit OPERATOR_NOT .or\n"
+" starequals .emit OPERATOR_MULASSIGN .or\n"
+" star .emit OPERATOR_MULTIPLY .or\n"
+" slashequals .emit OPERATOR_DIVASSIGN .or\n"
+" slash .emit OPERATOR_DIVIDE .or\n"
+" lessequals .emit OPERATOR_LESSEQUAL .or\n"
+" \n"
+" \n"
+" less .emit OPERATOR_LESS .or\n"
+" greaterequals .emit OPERATOR_GREATEREQUAL .or\n"
+" \n"
+" \n"
+" greater .emit OPERATOR_GREATER .or\n"
+" equalsequals .emit OPERATOR_EQUAL .or\n"
+" equals .emit OPERATOR_ASSIGN .or\n"
+" \n"
+" \n"
+" \n"
+" \n"
+" \n"
+" \n"
+" \n"
+" \n"
+" caretcaret .emit OPERATOR_LOGICALXOR ;\n"
+"parameter_declarator\n"
+" parameter_declarator_nospace .or parameter_declarator_space;\n"
+"parameter_declarator_nospace\n"
+" type_specifier_nospace .and identifier .and parameter_declarator_1;\n"
+"parameter_declarator_space\n"
+" type_specifier_space .and space .and identifier .and parameter_declarator_1;\n"
+"parameter_declarator_1\n"
+" parameter_declarator_2 .emit PARAMETER_ARRAY_PRESENT .or\n"
+" .true .emit PARAMETER_ARRAY_NOT_PRESENT;\n"
+"parameter_declarator_2\n"
+" lbracket .and constant_expression .and rbracket;\n"
+"parameter_declaration\n"
+" parameter_declaration_1 .emit PARAMETER_NEXT;\n"
+"parameter_declaration_1\n"
+" parameter_declaration_2 .or parameter_declaration_3;\n"
+"parameter_declaration_2\n"
+" type_qualifier .and space .and parameter_qualifier .and parameter_declaration_4;\n"
+"parameter_declaration_3\n"
+" parameter_qualifier .emit TYPE_QUALIFIER_NONE .and parameter_declaration_4;\n"
+"parameter_declaration_4\n"
+" parameter_declarator .or parameter_type_specifier;\n"
+"parameter_qualifier\n"
+" parameter_qualifier_1 .or .true .emit PARAM_QUALIFIER_IN;\n"
+"parameter_qualifier_1\n"
+" parameter_qualifier_2 .and space;\n"
+"parameter_qualifier_2\n"
+" \"in\" .emit PARAM_QUALIFIER_IN .or\n"
+" \"out\" .emit PARAM_QUALIFIER_OUT .or\n"
+" \"inout\" .emit PARAM_QUALIFIER_INOUT;\n"
+"parameter_type_specifier\n"
+" parameter_type_specifier_1 .and .true .emit '\\0' .and parameter_type_specifier_2;\n"
+"parameter_type_specifier_1\n"
+" type_specifier_nospace .or type_specifier_space;\n"
+"parameter_type_specifier_2\n"
+" parameter_type_specifier_3 .emit PARAMETER_ARRAY_PRESENT .or\n"
+" .true .emit PARAMETER_ARRAY_NOT_PRESENT;\n"
+"parameter_type_specifier_3\n"
+" lbracket .and constant_expression .and rbracket;\n"
+"init_declarator_list\n"
+" single_declaration .and .loop init_declarator_list_1 .emit DECLARATOR_NEXT .and\n"
+" .true .emit DECLARATOR_NONE;\n"
+"init_declarator_list_1\n"
+" comma .and identifier .emit VARIABLE_IDENTIFIER .and init_declarator_list_2;\n"
+"init_declarator_list_2\n"
+" init_declarator_list_3 .or init_declarator_list_4 .or .true .emit VARIABLE_NONE;\n"
+"init_declarator_list_3\n"
+" equals .and initializer .emit VARIABLE_INITIALIZER;\n"
+"init_declarator_list_4\n"
+" lbracket .and init_declarator_list_5 .and rbracket;\n"
+"init_declarator_list_5\n"
+" constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;\n"
+"single_declaration\n"
+" single_declaration_nospace .or single_declaration_space;\n"
+"single_declaration_space\n"
+" fully_specified_type_space .and single_declaration_space_1;\n"
+"single_declaration_nospace\n"
+" fully_specified_type_nospace .and single_declaration_nospace_1;\n"
+"single_declaration_space_1\n"
+" single_declaration_space_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;\n"
+"single_declaration_nospace_1\n"
+" single_declaration_nospace_2 .emit VARIABLE_IDENTIFIER .or .true .emit VARIABLE_NONE;\n"
+"single_declaration_space_2\n"
+" space .and identifier .and single_declaration_3;\n"
+"single_declaration_nospace_2\n"
+" identifier .and single_declaration_3;\n"
+"single_declaration_3\n"
+" single_declaration_4 .or single_declaration_5 .or .true .emit VARIABLE_NONE;\n"
+"single_declaration_4\n"
+" equals .and initializer .emit VARIABLE_INITIALIZER;\n"
+"single_declaration_5\n"
+" lbracket .and single_declaration_6 .and rbracket;\n"
+"single_declaration_6\n"
+" constant_expression .emit VARIABLE_ARRAY_EXPLICIT .or .true .emit VARIABLE_ARRAY_UNKNOWN;\n"
+"fully_specified_type_space\n"
+" fully_specified_type_1 .and type_specifier_space;\n"
+"fully_specified_type_nospace\n"
+" fully_specified_type_1 .and type_specifier_nospace;\n"
+"fully_specified_type_1\n"
+" fully_specified_type_2 .or .true .emit TYPE_QUALIFIER_NONE;\n"
+"fully_specified_type_2\n"
+" type_qualifier .and space;\n"
+"type_qualifier\n"
+" \"const\" .emit TYPE_QUALIFIER_CONST .or\n"
+" .if (shader_type == 2) \"attribute\" .emit TYPE_QUALIFIER_ATTRIBUTE .or\n"
+" \"varying\" .emit TYPE_QUALIFIER_VARYING .or\n"
+" \"uniform\" .emit TYPE_QUALIFIER_UNIFORM .or\n"
+" .if (parsing_builtin != 0) \"__fixed_output\" .emit TYPE_QUALIFIER_FIXEDOUTPUT .or\n"
+" .if (parsing_builtin != 0) \"__fixed_input\" .emit TYPE_QUALIFIER_FIXEDINPUT;\n"
+"type_specifier_space\n"
+" \"void\" .emit TYPE_SPECIFIER_VOID .or\n"
+" \"float\" .emit TYPE_SPECIFIER_FLOAT .or\n"
+" \"int\" .emit TYPE_SPECIFIER_INT .or\n"
+" \"bool\" .emit TYPE_SPECIFIER_BOOL .or\n"
+" \"vec2\" .emit TYPE_SPECIFIER_VEC2 .or\n"
+" \"vec3\" .emit TYPE_SPECIFIER_VEC3 .or\n"
+" \"vec4\" .emit TYPE_SPECIFIER_VEC4 .or\n"
+" \"bvec2\" .emit TYPE_SPECIFIER_BVEC2 .or\n"
+" \"bvec3\" .emit TYPE_SPECIFIER_BVEC3 .or\n"
+" \"bvec4\" .emit TYPE_SPECIFIER_BVEC4 .or\n"
+" \"ivec2\" .emit TYPE_SPECIFIER_IVEC2 .or\n"
+" \"ivec3\" .emit TYPE_SPECIFIER_IVEC3 .or\n"
+" \"ivec4\" .emit TYPE_SPECIFIER_IVEC4 .or\n"
+" \"mat2\" .emit TYPE_SPECIFIER_MAT2 .or\n"
+" \"mat3\" .emit TYPE_SPECIFIER_MAT3 .or\n"
+" \"mat4\" .emit TYPE_SPECIFIER_MAT4 .or\n"
+" \"sampler1D\" .emit TYPE_SPECIFIER_SAMPLER1D .or\n"
+" \"sampler2D\" .emit TYPE_SPECIFIER_SAMPLER2D .or\n"
+" \"sampler3D\" .emit TYPE_SPECIFIER_SAMPLER3D .or\n"
+" \"samplerCube\" .emit TYPE_SPECIFIER_SAMPLERCUBE .or\n"
+" \"sampler1DShadow\" .emit TYPE_SPECIFIER_SAMPLER1DSHADOW .or\n"
+" \"sampler2DShadow\" .emit TYPE_SPECIFIER_SAMPLER2DSHADOW .or\n"
+" type_name .emit TYPE_SPECIFIER_TYPENAME;\n"
+"type_specifier_nospace\n"
+" struct_specifier .emit TYPE_SPECIFIER_STRUCT;\n"
+"struct_specifier\n"
+" \"struct\" .and struct_specifier_1 .and optional_space .and lbrace .error LBRACE_EXPECTED .and\n"
+" struct_declaration_list .and rbrace .emit FIELD_NONE;\n"
+"struct_specifier_1\n"
+" struct_specifier_2 .or .true .emit '\\0';\n"
+"struct_specifier_2\n"
+" space .and identifier;\n"
+"struct_declaration_list\n"
+" struct_declaration .and .loop struct_declaration .emit FIELD_NEXT;\n"
+"struct_declaration\n"
+" struct_declaration_nospace .or struct_declaration_space;\n"
+"struct_declaration_space\n"
+" type_specifier_space .and space .and struct_declarator_list .and semicolon .emit FIELD_NONE;\n"
+"struct_declaration_nospace\n"
+" type_specifier_nospace .and struct_declarator_list .and semicolon .emit FIELD_NONE;\n"
+"struct_declarator_list\n"
+" struct_declarator .and .loop struct_declarator_list_1 .emit FIELD_NEXT;\n"
+"struct_declarator_list_1\n"
+" comma .and struct_declarator;\n"
+"struct_declarator\n"
+" identifier .and struct_declarator_1;\n"
+"struct_declarator_1\n"
+" struct_declarator_2 .emit FIELD_ARRAY .or .true .emit FIELD_NONE;\n"
+"struct_declarator_2\n"
+" lbracket .and constant_expression .and rbracket;\n"
+"initializer\n"
+" assignment_expression .and .true .emit OP_END;\n"
+"declaration_statement\n"
+" declaration;\n"
+"statement\n"
+" compound_statement .or simple_statement;\n"
+"statement_space\n"
+" compound_statement .or statement_space_1;\n"
+"statement_space_1\n"
+" space .and simple_statement;\n"
+"simple_statement\n"
+" .if (parsing_builtin != 0) __asm_statement .emit OP_ASM .or\n"
+" selection_statement .or\n"
+" iteration_statement .or\n"
+" jump_statement .or\n"
+" expression_statement .emit OP_EXPRESSION .or\n"
+" declaration_statement .emit OP_DECLARE;\n"
+"compound_statement\n"
+" compound_statement_1 .emit OP_BLOCK_BEGIN_NEW_SCOPE .and .true .emit OP_END;\n"
+"compound_statement_1\n"
+" compound_statement_2 .or compound_statement_3;\n"
+"compound_statement_2\n"
+" lbrace .and rbrace;\n"
+"compound_statement_3\n"
+" lbrace .and statement_list .and rbrace;\n"
+"statement_no_new_scope\n"
+" compound_statement_no_new_scope .or simple_statement;\n"
+"compound_statement_no_new_scope\n"
+" compound_statement_no_new_scope_1 .emit OP_BLOCK_BEGIN_NO_NEW_SCOPE .and .true .emit OP_END;\n"
+"compound_statement_no_new_scope_1\n"
+" compound_statement_no_new_scope_2 .or compound_statement_no_new_scope_3;\n"
+"compound_statement_no_new_scope_2\n"
+" lbrace .and rbrace;\n"
+"compound_statement_no_new_scope_3\n"
+" lbrace .and statement_list .and rbrace;\n"
+"statement_list\n"
+" statement .and .loop statement;\n"
+"expression_statement\n"
+" expression_statement_1 .or expression_statement_2;\n"
+"expression_statement_1\n"
+" semicolon .emit OP_PUSH_VOID .emit OP_END;\n"
+"expression_statement_2\n"
+" expression .and semicolon .emit OP_END;\n"
+"selection_statement\n"
+" \"if\" .emit OP_IF .and lparen .error LPAREN_EXPECTED .and expression .and\n"
+" rparen .error RPAREN_EXPECTED .emit OP_END .and selection_rest_statement;\n"
+"selection_rest_statement\n"
+" statement .and selection_rest_statement_1;\n"
+"selection_rest_statement_1\n"
+" selection_rest_statement_2 .or .true .emit OP_EXPRESSION .emit OP_PUSH_VOID .emit OP_END;\n"
+"selection_rest_statement_2\n"
+" \"else\" .and optional_space .and statement;\n"
+"condition\n"
+" condition_1 .emit OP_DECLARE .emit DECLARATION_INIT_DECLARATOR_LIST .or\n"
+" condition_3 .emit OP_EXPRESSION;\n"
+"condition_1\n"
+" condition_1_nospace .or condition_1_space;\n"
+"condition_1_nospace\n"
+" fully_specified_type_nospace .and condition_2;\n"
+"condition_1_space\n"
+" fully_specified_type_space .and space .and condition_2;\n"
+"condition_2\n"
+" identifier .emit VARIABLE_IDENTIFIER .and equals .emit VARIABLE_INITIALIZER .and\n"
+" initializer .and .true .emit DECLARATOR_NONE;\n"
+"condition_3\n"
+" expression .and .true .emit OP_END;\n"
+"iteration_statement\n"
+" iteration_statement_1 .or iteration_statement_2 .or iteration_statement_3;\n"
+"iteration_statement_1\n"
+" \"while\" .emit OP_WHILE .and lparen .error LPAREN_EXPECTED .and condition .and\n"
+" rparen .error RPAREN_EXPECTED .and statement_no_new_scope;\n"
+"iteration_statement_2\n"
+" \"do\" .emit OP_DO .and statement_space .and \"while\" .and lparen .error LPAREN_EXPECTED .and\n"
+" expression .and rparen .error RPAREN_EXPECTED .emit OP_END .and semicolon;\n"
+"iteration_statement_3\n"
+" \"for\" .emit OP_FOR .and lparen .error LPAREN_EXPECTED .and for_init_statement .and\n"
+" for_rest_statement .and rparen .error RPAREN_EXPECTED .and statement_no_new_scope;\n"
+"for_init_statement\n"
+" expression_statement .emit OP_EXPRESSION .or declaration_statement .emit OP_DECLARE;\n"
+"conditionopt\n"
+" condition .or\n"
+" .true .emit OP_EXPRESSION .emit OP_PUSH_BOOL .emit 2 .emit '1' .emit '\\0' .emit OP_END;\n"
+"for_rest_statement\n"
+" conditionopt .and semicolon .and for_rest_statement_1;\n"
+"for_rest_statement_1\n"
+" for_rest_statement_2 .or .true .emit OP_PUSH_VOID .emit OP_END;\n"
+"for_rest_statement_2\n"
+" expression .and .true .emit OP_END;\n"
+"jump_statement\n"
+" jump_statement_1 .or jump_statement_2 .or jump_statement_3 .or jump_statement_4 .or\n"
+" .if (shader_type == 1) jump_statement_5;\n"
+"jump_statement_1\n"
+" \"continue\" .and semicolon .emit OP_CONTINUE;\n"
+"jump_statement_2\n"
+" \"break\" .and semicolon .emit OP_BREAK;\n"
+"jump_statement_3\n"
+" \"return\" .emit OP_RETURN .and optional_space .and expression .and semicolon .emit OP_END;\n"
+"jump_statement_4\n"
+" \"return\" .emit OP_RETURN .and semicolon .emit OP_PUSH_VOID .emit OP_END;\n"
+"jump_statement_5\n"
+" \"discard\" .and semicolon .emit OP_DISCARD;\n"
+"__asm_statement\n"
+" \"__asm\" .and space .and identifier .and space .and asm_arguments .and semicolon .emit OP_END;\n"
+"asm_arguments\n"
+" variable_identifier .and .true .emit OP_END .and .loop asm_arguments_1;\n"
+"asm_arguments_1\n"
+" comma .and variable_identifier .and .true .emit OP_END;\n"
+"translation_unit\n"
+" optional_space .emit REVISION .and external_declaration .error INVALID_EXTERNAL_DECLARATION .and\n"
+" .loop external_declaration .and optional_space .and\n"
+" '\\0' .error INVALID_EXTERNAL_DECLARATION .emit EXTERNAL_NULL;\n"
+"external_declaration\n"
+" function_definition .emit EXTERNAL_FUNCTION_DEFINITION .or\n"
+" declaration .emit EXTERNAL_DECLARATION;\n"
+"function_definition\n"
+" function_prototype .and compound_statement_no_new_scope;\n"
+"digit_oct\n"
+" '0'-'7';\n"
+"digit_dec\n"
+" '0'-'9';\n"
+"digit_hex\n"
+" '0'-'9' .or 'A'-'F' .or 'a'-'f';\n"
+"id_character_first\n"
+" 'a'-'z' .or 'A'-'Z' .or '_';\n"
+"id_character_next\n"
+" id_character_first .or digit_dec;\n"
+"identifier\n"
+" id_character_first .emit * .and .loop id_character_next .emit * .and .true .emit '\\0';\n"
+"float\n"
+" float_1 .or float_2;\n"
+"float_1\n"
+" float_fractional_constant .and float_optional_exponent_part;\n"
+"float_2\n"
+" float_digit_sequence .and .true .emit '\\0' .and float_exponent_part;\n"
+"float_fractional_constant\n"
+" float_fractional_constant_1 .or float_fractional_constant_2 .or float_fractional_constant_3;\n"
+"float_fractional_constant_1\n"
+" float_digit_sequence .and '.' .and float_digit_sequence;\n"
+"float_fractional_constant_2\n"
+" float_digit_sequence .and '.' .and .true .emit '\\0';\n"
+"float_fractional_constant_3\n"
+" '.' .emit '\\0' .and float_digit_sequence;\n"
+"float_optional_exponent_part\n"
+" float_exponent_part .or .true .emit '\\0';\n"
+"float_digit_sequence\n"
+" digit_dec .emit * .and .loop digit_dec .emit * .and .true .emit '\\0';\n"
+"float_exponent_part\n"
+" float_exponent_part_1 .or float_exponent_part_2;\n"
+"float_exponent_part_1\n"
+" 'e' .and float_optional_sign .and float_digit_sequence;\n"
+"float_exponent_part_2\n"
+" 'E' .and float_optional_sign .and float_digit_sequence;\n"
+"float_optional_sign\n"
+" float_sign .or .true;\n"
+"float_sign\n"
+" '+' .or '-' .emit '-';\n"
+"integer\n"
+" integer_hex .or integer_oct .or integer_dec;\n"
+"integer_hex\n"
+" '0' .and integer_hex_1 .emit 0x10 .and digit_hex .emit * .and .loop digit_hex .emit * .and\n"
+" .true .emit '\\0';\n"
+"integer_hex_1\n"
+" 'x' .or 'X';\n"
+"integer_oct\n"
+" '0' .emit 8 .emit * .and .loop digit_oct .emit * .and .true .emit '\\0';\n"
+"integer_dec\n"
+" digit_dec .emit 10 .emit * .and .loop digit_dec .emit * .and .true .emit '\\0';\n"
+"boolean\n"
+" \"true\" .emit 2 .emit '1' .emit '\\0' .or\n"
+" \"false\" .emit 2 .emit '0' .emit '\\0';\n"
+"type_name\n"
+" identifier;\n"
+"field_selection\n"
+" identifier;\n"
+"floatconstant\n"
+" float .emit OP_PUSH_FLOAT;\n"
+"intconstant\n"
+" integer .emit OP_PUSH_INT;\n"
+"boolconstant\n"
+" boolean .emit OP_PUSH_BOOL;\n"
+"optional_space\n"
+" .loop single_space;\n"
+"space\n"
+" single_space .and .loop single_space;\n"
+"single_space\n"
+" white_char .or c_style_comment_block .or cpp_style_comment_block;\n"
+"white_char\n"
+" ' ' .or '\\t' .or new_line .or '\\v' .or '\\f';\n"
+"new_line\n"
+" cr_lf .or lf_cr .or '\\n' .or '\\r';\n"
+"cr_lf\n"
+" '\\r' .and '\\n';\n"
+"lf_cr\n"
+" '\\n' .and '\\r';\n"
+"c_style_comment_block\n"
+" '/' .and '*' .and c_style_comment_rest;\n"
+"c_style_comment_rest\n"
+" .loop c_style_comment_char_no_star .and c_style_comment_rest_1;\n"
+"c_style_comment_rest_1\n"
+" c_style_comment_end .or c_style_comment_rest_2;\n"
+"c_style_comment_rest_2\n"
+" '*' .and c_style_comment_rest;\n"
+"c_style_comment_char_no_star\n"
+" '\\x2B'-'\\xFF' .or '\\x01'-'\\x29';\n"
+"c_style_comment_end\n"
+" '*' .and '/';\n"
+"cpp_style_comment_block\n"
+" '/' .and '/' .and cpp_style_comment_block_1;\n"
+"cpp_style_comment_block_1\n"
+" cpp_style_comment_block_2 .or cpp_style_comment_block_3;\n"
+"cpp_style_comment_block_2\n"
+" .loop cpp_style_comment_char .and new_line;\n"
+"cpp_style_comment_block_3\n"
+" .loop cpp_style_comment_char;\n"
+"cpp_style_comment_char\n"
+" '\\x0E'-'\\xFF' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
+"ampersandampersand\n"
+" optional_space .and '&' .and '&' .and optional_space;\n"
+"barbar\n"
+" optional_space .and '|' .and '|' .and optional_space;\n"
+"bang\n"
+" optional_space .and '!' .and optional_space;\n"
+"bangequals\n"
+" optional_space .and '!' .and '=' .and optional_space;\n"
+"caretcaret\n"
+" optional_space .and '^' .and '^' .and optional_space;\n"
+"colon\n"
+" optional_space .and ':' .and optional_space;\n"
+"comma\n"
+" optional_space .and ',' .and optional_space;\n"
+"dot\n"
+" optional_space .and '.' .and optional_space;\n"
+"equals\n"
+" optional_space .and '=' .and optional_space;\n"
+"equalsequals\n"
+" optional_space .and '=' .and '=' .and optional_space;\n"
+"greater\n"
+" optional_space .and '>' .and optional_space;\n"
+"greaterequals\n"
+" optional_space .and '>' .and '=' .and optional_space;\n"
+"lbrace\n"
+" optional_space .and '{' .and optional_space;\n"
+"lbracket\n"
+" optional_space .and '[' .and optional_space;\n"
+"less\n"
+" optional_space .and '<' .and optional_space;\n"
+"lessequals\n"
+" optional_space .and '<' .and '=' .and optional_space;\n"
+"lparen\n"
+" optional_space .and '(' .and optional_space;\n"
+"minus\n"
+" optional_space .and '-' .and optional_space;\n"
+"minusequals\n"
+" optional_space .and '-' .and '=' .and optional_space;\n"
+"minusminus\n"
+" optional_space .and '-' .and '-' .and optional_space;\n"
+"plus\n"
+" optional_space .and '+' .and optional_space;\n"
+"plusequals\n"
+" optional_space .and '+' .and '=' .and optional_space;\n"
+"plusplus\n"
+" optional_space .and '+' .and '+' .and optional_space;\n"
+"question\n"
+" optional_space .and '?' .and optional_space;\n"
+"rbrace\n"
+" optional_space .and '}' .and optional_space;\n"
+"rbracket\n"
+" optional_space .and ']' .and optional_space;\n"
+"rparen\n"
+" optional_space .and ')' .and optional_space;\n"
+"semicolon\n"
+" optional_space .and ';' .and optional_space;\n"
+"slash\n"
+" optional_space .and '/' .and optional_space;\n"
+"slashequals\n"
+" optional_space .and '/' .and '=' .and optional_space;\n"
+"star\n"
+" optional_space .and '*' .and optional_space;\n"
+"starequals\n"
+" optional_space .and '*' .and '=' .and optional_space;\n"
+".string string_lexer;\n"
+"string_lexer\n"
+" lex_first_identifier_character .and .loop lex_next_identifier_character;\n"
+"lex_first_identifier_character\n"
+" 'a'-'z' .or 'A'-'Z' .or '_';\n"
+"lex_next_identifier_character\n"
+" 'a'-'z' .or 'A'-'Z' .or '0'-'9' .or '_';\n"
+"err_token\n"
+" '~' .or '`' .or '!' .or '@' .or '#' .or '$' .or '%' .or '^' .or '&' .or '*' .or '(' .or ')' .or\n"
+" '-' .or '+' .or '=' .or '|' .or '\\\\' .or '[' .or ']' .or '{' .or '}' .or ':' .or ';' .or '\"' .or\n"
+" '\\'' .or '<' .or ',' .or '>' .or '.' .or '/' .or '?' .or err_identifier;\n"
+"err_identifier\n"
+" id_character_first .and .loop id_character_next;\n"
+""
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_version.syn b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_version.syn
new file mode 100755
index 000000000..3a8c7046b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_version.syn
@@ -0,0 +1,118 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file slang_version.syn
+ * slang #version directive syntax
+ * \author Michal Krol
+ */
+
+.syntax version_directive;
+
+version_directive
+ version_directive_1 .and .loop version_directive_2;
+version_directive_1
+ prior_optional_spaces .and optional_version_directive .and .true .emit $;
+version_directive_2
+ prior_optional_spaces .and version_directive_body .and .true .emit $;
+
+optional_version_directive
+ version_directive_body .or .true .emit 10 .emit 1;
+
+version_directive_body
+ '#' .and optional_space .and "version" .and space .and version_number .and optional_space .and
+ new_line;
+
+version_number
+ version_number_110;
+
+version_number_110
+ leading_zeroes .and "110" .emit 10 .emit 1;
+
+leading_zeroes
+ .loop zero;
+
+zero
+ '0';
+
+space
+ single_space .and .loop single_space;
+
+optional_space
+ .loop single_space;
+
+single_space
+ ' ' .or '\t';
+
+prior_optional_spaces
+ .loop prior_space;
+
+prior_space
+ c_style_comment_block .or cpp_style_comment_block .or space .or new_line;
+
+c_style_comment_block
+ '/' .and '*' .and c_style_comment_rest;
+
+c_style_comment_rest
+ .loop c_style_comment_char_no_star .and c_style_comment_rest_1;
+c_style_comment_rest_1
+ c_style_comment_end .or c_style_comment_rest_2;
+c_style_comment_rest_2
+ '*' .and c_style_comment_rest;
+
+c_style_comment_char_no_star
+ '\x2B'-'\xFF' .or '\x01'-'\x29';
+
+c_style_comment_end
+ '*' .and '/';
+
+cpp_style_comment_block
+ '/' .and '/' .and cpp_style_comment_block_1;
+cpp_style_comment_block_1
+ cpp_style_comment_block_2 .or cpp_style_comment_block_3;
+cpp_style_comment_block_2
+ .loop cpp_style_comment_char .and new_line;
+cpp_style_comment_block_3
+ .loop cpp_style_comment_char;
+
+cpp_style_comment_char
+ '\x0E'-'\xFF' .or '\x01'-'\x09' .or '\x0B'-'\x0C';
+
+new_line
+ cr_lf .or lf_cr .or '\n' .or '\r';
+
+cr_lf
+ '\r' .and '\n';
+
+lf_cr
+ '\n' .and '\r';
+
+.string __string_filter;
+
+__string_filter
+ .loop __identifier_char;
+
+__identifier_char
+ 'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_version_syn.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_version_syn.h
new file mode 100755
index 000000000..1c27546d7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_version_syn.h
@@ -0,0 +1,64 @@
+".syntax version_directive;\n"
+"version_directive\n"
+" version_directive_1 .and .loop version_directive_2;\n"
+"version_directive_1\n"
+" prior_optional_spaces .and optional_version_directive .and .true .emit $;\n"
+"version_directive_2\n"
+" prior_optional_spaces .and version_directive_body .and .true .emit $;\n"
+"optional_version_directive\n"
+" version_directive_body .or .true .emit 10 .emit 1;\n"
+"version_directive_body\n"
+" '#' .and optional_space .and \"version\" .and space .and version_number .and optional_space .and\n"
+" new_line;\n"
+"version_number\n"
+" version_number_110;\n"
+"version_number_110\n"
+" leading_zeroes .and \"110\" .emit 10 .emit 1;\n"
+"leading_zeroes\n"
+" .loop zero;\n"
+"zero\n"
+" '0';\n"
+"space\n"
+" single_space .and .loop single_space;\n"
+"optional_space\n"
+" .loop single_space;\n"
+"single_space\n"
+" ' ' .or '\\t';\n"
+"prior_optional_spaces\n"
+" .loop prior_space;\n"
+"prior_space\n"
+" c_style_comment_block .or cpp_style_comment_block .or space .or new_line;\n"
+"c_style_comment_block\n"
+" '/' .and '*' .and c_style_comment_rest;\n"
+"c_style_comment_rest\n"
+" .loop c_style_comment_char_no_star .and c_style_comment_rest_1;\n"
+"c_style_comment_rest_1\n"
+" c_style_comment_end .or c_style_comment_rest_2;\n"
+"c_style_comment_rest_2\n"
+" '*' .and c_style_comment_rest;\n"
+"c_style_comment_char_no_star\n"
+" '\\x2B'-'\\xFF' .or '\\x01'-'\\x29';\n"
+"c_style_comment_end\n"
+" '*' .and '/';\n"
+"cpp_style_comment_block\n"
+" '/' .and '/' .and cpp_style_comment_block_1;\n"
+"cpp_style_comment_block_1\n"
+" cpp_style_comment_block_2 .or cpp_style_comment_block_3;\n"
+"cpp_style_comment_block_2\n"
+" .loop cpp_style_comment_char .and new_line;\n"
+"cpp_style_comment_block_3\n"
+" .loop cpp_style_comment_char;\n"
+"cpp_style_comment_char\n"
+" '\\x0E'-'\\xFF' .or '\\x01'-'\\x09' .or '\\x0B'-'\\x0C';\n"
+"new_line\n"
+" cr_lf .or lf_cr .or '\\n' .or '\\r';\n"
+"cr_lf\n"
+" '\\r' .and '\\n';\n"
+"lf_cr\n"
+" '\\n' .and '\\r';\n"
+".string __string_filter;\n"
+"__string_filter\n"
+" .loop __identifier_char;\n"
+"__identifier_char\n"
+" 'a'-'z' .or 'A'-'Z' .or '_' .or '0'-'9';\n"
+""
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_vertex_builtin.gc b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_vertex_builtin.gc
new file mode 100755
index 000000000..850fd2bb8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_vertex_builtin.gc
@@ -0,0 +1,262 @@
+
+//
+// TODO:
+// - what to do with ftransform? can it stay in the current form?
+// - implement texture1DLod, texture2DLod, texture3DLod, textureCubeLod,
+// - implement shadow1DLod, shadow2DLod,
+//
+
+//
+// From Shader Spec, ver. 1.10, rev. 59
+//
+// Some OpenGL operations still continue to occur in fixed functionality in between the vertex
+// processor and the fragment processor. Other OpenGL operations continue to occur in fixed
+// functionality after the fragment processor. Shaders communicate with the fixed functionality
+// of OpenGL through the use of built-in variables.
+//
+// The variable gl_Position is available only in the vertex language and is intended for writing
+// the homogeneous vertex position. All executions of a well-formed vertex shader must write
+// a value into this variable. It can be written at any time during shader execution. It may also
+// be read back by the shader after being written. This value will be used by primitive assembly,
+// clipping, culling, and other fixed functionality operations that operate on primitives after
+// vertex processing has occurred. Compilers may generate a diagnostic message if they detect
+// gl_Position is not written, or read before being written, but not all such cases are detectable.
+// Results are undefined if a vertex shader is executed and does not write gl_Position.
+//
+// The variable gl_PointSize is available only in the vertex language and is intended for a vertex
+// shader to write the size of the point to be rasterized. It is measured in pixels.
+//
+// The variable gl_ClipVertex is available only in the vertex language and provides a place for
+// vertex shaders to write the coordinate to be used with the user clipping planes. The user must
+// ensure the clip vertex and user clipping planes are defined in the same coordinate space. User
+// clip planes work properly only under linear transform. It is undefined what happens under
+// non-linear transform.
+//
+// These built-in vertex shader variables for communicating with fixed functionality are
+// intrinsically declared with the following types:
+//
+
+__fixed_output vec4 gl_Position; // must be written to
+__fixed_output float gl_PointSize; // may be written to
+__fixed_output vec4 gl_ClipVertex; // may be written to
+
+//
+// If gl_PointSize or gl_ClipVertex are not written to, their values are undefined. Any of these
+// variables can be read back by the shader after writing to them, to retrieve what was written.
+// Reading them before writing them results in undefined behavior. If they are written more than
+// once, it is the last value written that is consumed by the subsequent operations.
+//
+// These built-in variables have global scope.
+//
+
+//
+// The following attribute names are built into the OpenGL vertex language and can be used from
+// within a vertex shader to access the current values of attributes declared by OpenGL. All page
+// numbers and notations are references to the OpenGL 1.4 specification.
+//
+
+//
+// Vertex Attributes, p. 19.
+//
+
+attribute vec4 gl_Color;
+attribute vec4 gl_SecondaryColor;
+attribute vec3 gl_Normal;
+attribute vec4 gl_Vertex;
+attribute vec4 gl_MultiTexCoord0;
+attribute vec4 gl_MultiTexCoord1;
+attribute vec4 gl_MultiTexCoord2;
+attribute vec4 gl_MultiTexCoord3;
+attribute vec4 gl_MultiTexCoord4;
+attribute vec4 gl_MultiTexCoord5;
+attribute vec4 gl_MultiTexCoord6;
+attribute vec4 gl_MultiTexCoord7;
+attribute float gl_FogCoord;
+
+//
+// Unlike user-defined varying variables, the built-in varying variables don't have a strict
+// one-to-one correspondence between the vertex language and the fragment language. Two sets are
+// provided, one for each language. Their relationship is described below.
+//
+// The following built-in varying variables are available to write to in a vertex shader.
+// A particular one should be written to if any functionality in a corresponding fragment shader
+// or fixed pipeline uses it or state derived from it. Otherwise, behavior is undefined.
+//
+
+varying vec4 gl_FrontColor;
+varying vec4 gl_BackColor;
+varying vec4 gl_FrontSecondaryColor;
+varying vec4 gl_BackSecondaryColor;
+varying vec4 gl_TexCoord[]; // at most will be gl_MaxTextureCoords
+varying float gl_FogFragCoord;
+
+//
+// For gl_FogFragCoord, the value written will be used as the "c" value on page 160 of the
+// OpenGL 1.4 Specification by the fixed functionality pipeline. For example, if the z-coordinate
+// of the fragment in eye space is desired as "c", then that's what the vertex shader should write
+// into gl_FogFragCoord.
+//
+// As with all arrays, indices used to subscript gl_TexCoord must either be an integral constant
+// expressions, or this array must be re-declared by the shader with a size. The size can be
+// at most gl_MaxTextureCoords. Using indexes close to 0 may aid the implementation
+// in preserving varying resources.
+//
+
+//
+// The OpenGL Shading Language defines an assortment of built-in convenience functions for scalar
+// and vector operations. Many of these built-in functions can be used in more than one type
+// of shader, but some are intended to provide a direct mapping to hardware and so are available
+// only for a specific type of shader.
+//
+// The built-in functions basically fall into three categories:
+//
+// * They expose some necessary hardware functionality in a convenient way such as accessing
+// a texture map. There is no way in the language for these functions to be emulated by a shader.
+//
+// * They represent a trivial operation (clamp, mix, etc.) that is very simple for the user
+// to write, but they are very common and may have direct hardware support. It is a very hard
+// problem for the compiler to map expressions to complex assembler instructions.
+//
+// * They represent an operation graphics hardware is likely to accelerate at some point. The
+// trigonometry functions fall into this category.
+//
+// Many of the functions are similar to the same named ones in common C libraries, but they support
+// vector input as well as the more traditional scalar input.
+//
+// Applications should be encouraged to use the built-in functions rather than do the equivalent
+// computations in their own shader code since the built-in functions are assumed to be optimal
+// (e.g., perhaps supported directly in hardware).
+//
+// User code can replace built-in functions with their own if they choose, by simply re-declaring
+// and defining the same name and argument list.
+//
+
+//
+// Geometric Functions
+//
+// These operate on vectors as vectors, not component-wise.
+//
+
+//
+// For vertex shaders only. This function will ensure that the incoming vertex value will be
+// transformed in a way that produces exactly the same result as would be produced by OpenGL's
+// fixed functionality transform. It is intended to be used to compute gl_Position, e.g.,
+// gl_Position = ftransform()
+// This function should be used, for example, when an application is rendering the same geometry in
+// separate passes, and one pass uses the fixed functionality path to render and another pass uses
+// programmable shaders.
+//
+
+vec4 ftransform () {
+ return gl_ModelViewProjectionMatrix * gl_Vertex;
+}
+
+//
+// 8.7 Texture Lookup Functions
+//
+// Texture lookup functions are available to both vertex and fragment shaders. However, level
+// of detail is not computed by fixed functionality for vertex shaders, so there are some
+// differences in operation between vertex and fragment texture lookups. The functions in the table
+// below provide access to textures through samplers, as set up through the OpenGL API. Texture
+// properties such as size, pixel format, number of dimensions, filtering method, number of mip-map
+// levels, depth comparison, and so on are also defined by OpenGL API calls. Such properties are
+// taken into account as the texture is accessed via the built-in functions defined below.
+//
+// If a non-shadow texture call is made to a sampler that represents a depth texture with depth
+// comparisons turned on, then results are undefined. If a shadow texture call is made to a sampler
+// that represents a depth texture with depth comparisions turned off, the results are undefined.
+// If a shadow texture call is made to a sampler that does not represent a depth texture, then
+// results are undefined.
+//
+// In all functions below, the bias parameter is optional for fragment shaders. The bias parameter
+// is not accepted in a vertex shader. For a fragment shader, if bias is present, it is added to
+// the calculated level of detail prior to performing the texture access operation. If the bias
+// parameter is not provided, then the implementation automatically selects level of detail:
+// For a texture that is not mip-mapped, the texture is used directly. If it is mip-mapped and
+// running in a fragment shader, the LOD computed by the implementation is used to do the texture
+// lookup. If it is mip-mapped and running on the vertex shader, then the base texture is used.
+//
+// The built-ins suffixed with "Lod" are allowed only in a vertex shader. For the "Lod" functions,
+// lod is directly used as the level of detail.
+//
+
+//
+// Use the texture coordinate coord to do a texture lookup in the 1D texture currently bound
+// to sampler. For the projective ("Proj") versions, the texture coordinate coord.s is divided by
+// the last component of coord.
+//
+// XXX
+vec4 texture1DLod (sampler1D sampler, float coord, float lod) {
+ return vec4 (0.0);
+}
+vec4 texture1DProjLod (sampler1D sampler, vec2 coord, float lod) {
+ return texture1DLod (sampler, coord.s / coord.t, lod);
+}
+vec4 texture1DProjLod (sampler1D sampler, vec4 coord, float lod) {
+ return texture1DLod (sampler, coord.s / coord.q, lod);
+}
+
+//
+// Use the texture coordinate coord to do a texture lookup in the 2D texture currently bound
+// to sampler. For the projective ("Proj") versions, the texture coordinate (coord.s, coord.t) is
+// divided by the last component of coord. The third component of coord is ignored for the vec4
+// coord variant.
+//
+// XXX
+vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod) {
+ return vec4 (0.0);
+}
+vec4 texture2DProjLod (sampler2D sampler, vec3 coord, float lod) {
+ return texture2DLod (sampler, vec2 (coord.s / coord.p, coord.t / coord.p), lod);
+}
+vec4 texture2DProjLod (sampler2D sampler, vec4 coord, float lod) {
+ return texture2DLod (sampler, vec2 (coord.s / coord.q, coord.t / coord.q), lod);
+}
+
+//
+// Use the texture coordinate coord to do a texture lookup in the 3D texture currently bound
+// to sampler. For the projective ("Proj") versions, the texture coordinate is divided by coord.q.
+//
+// XXX
+vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod) {
+ return vec4 (0.0);
+}
+vec4 texture3DProjLod (sampler3D sampler, vec4 coord, float lod) {
+ return texture3DLod (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.s / coord.q),
+ lod);
+}
+
+//
+// Use the texture coordinate coord to do a texture lookup in the cube map texture currently bound
+// to sampler. The direction of coord is used to select which face to do a 2-dimensional texture
+// lookup in, as described in section 3.8.6 in version 1.4 of the OpenGL specification.
+//
+// XXX
+vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod) {
+ return vec4 (0.0);
+}
+
+//
+// Use texture coordinate coord to do a depth comparison lookup on the depth texture bound
+// to sampler, as described in section 3.8.14 of version 1.4 of the OpenGL specification. The 3rd
+// component of coord (coord.p) is used as the R value. The texture bound to sampler must be a
+// depth texture, or results are undefined. For the projective ("Proj") version of each built-in,
+// the texture coordinate is divide by coord.q, giving a depth value R of coord.p/coord.q. The
+// second component of coord is ignored for the "1D" variants.
+//
+// XXX
+vec4 shadow1DLod (sampler1DShadow sampler, vec3 coord, float lod) {
+ return vec4 (0.0);
+}
+// XXX
+vec4 shadow2DLod (sampler2DShadow sampler, vec3 coord, float lod) {
+ return vec4 (0.0);
+}
+vec4 shadow1DProjLod (sampler1DShadow sampler, vec4 coord, float lod) {
+ return shadow1DLod (sampler, vec3 (coord.s / coord.q, 0.0, coord.p / coord.q), lod);
+}
+vec4 shadow2DProjLod (sampler2DShadow sampler, vec4 coord, float lod) {
+ return shadow2DLod (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q),
+ lod);
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_vertex_builtin_gc.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_vertex_builtin_gc.h
new file mode 100644
index 000000000..746226180
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_vertex_builtin_gc.h
@@ -0,0 +1,262 @@
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"__fixed_output vec4 gl_Position;\n"
+"__fixed_output float gl_PointSize;\n"
+"__fixed_output vec4 gl_ClipVertex;\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"attribute vec4 gl_Color;\n"
+"attribute vec4 gl_SecondaryColor;\n"
+"attribute vec3 gl_Normal;\n"
+"attribute vec4 gl_Vertex;\n"
+"attribute vec4 gl_MultiTexCoord0;\n"
+"attribute vec4 gl_MultiTexCoord1;\n"
+"attribute vec4 gl_MultiTexCoord2;\n"
+"attribute vec4 gl_MultiTexCoord3;\n"
+"attribute vec4 gl_MultiTexCoord4;\n"
+"attribute vec4 gl_MultiTexCoord5;\n"
+"attribute vec4 gl_MultiTexCoord6;\n"
+"attribute vec4 gl_MultiTexCoord7;\n"
+"attribute float gl_FogCoord;\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"varying vec4 gl_FrontColor;\n"
+"varying vec4 gl_BackColor;\n"
+"varying vec4 gl_FrontSecondaryColor;\n"
+"varying vec4 gl_BackSecondaryColor;\n"
+"varying vec4 gl_TexCoord[];\n"
+"varying float gl_FogFragCoord;\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec4 ftransform () {\n"
+" return gl_ModelViewProjectionMatrix * gl_Vertex;\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec4 texture1DLod (sampler1D sampler, float coord, float lod) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"vec4 texture1DProjLod (sampler1D sampler, vec2 coord, float lod) {\n"
+" return texture1DLod (sampler, coord.s / coord.t, lod);\n"
+"}\n"
+"vec4 texture1DProjLod (sampler1D sampler, vec4 coord, float lod) {\n"
+" return texture1DLod (sampler, coord.s / coord.q, lod);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec4 texture2DLod (sampler2D sampler, vec2 coord, float lod) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"vec4 texture2DProjLod (sampler2D sampler, vec3 coord, float lod) {\n"
+" return texture2DLod (sampler, vec2 (coord.s / coord.p, coord.t / coord.p), lod);\n"
+"}\n"
+"vec4 texture2DProjLod (sampler2D sampler, vec4 coord, float lod) {\n"
+" return texture2DLod (sampler, vec2 (coord.s / coord.q, coord.t / coord.q), lod);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec4 texture3DLod (sampler3D sampler, vec3 coord, float lod) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"vec4 texture3DProjLod (sampler3D sampler, vec4 coord, float lod) {\n"
+" return texture3DLod (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.s / coord.q),\n"
+" lod);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec4 textureCubeLod (samplerCube sampler, vec3 coord, float lod) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"\n"
+"vec4 shadow1DLod (sampler1DShadow sampler, vec3 coord, float lod) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"\n"
+"vec4 shadow2DLod (sampler2DShadow sampler, vec3 coord, float lod) {\n"
+" return vec4 (0.0);\n"
+"}\n"
+"vec4 shadow1DProjLod (sampler1DShadow sampler, vec4 coord, float lod) {\n"
+" return shadow1DLod (sampler, vec3 (coord.s / coord.q, 0.0, coord.p / coord.q), lod);\n"
+"}\n"
+"vec4 shadow2DProjLod (sampler2DShadow sampler, vec4 coord, float lod) {\n"
+" return shadow2DLod (sampler, vec3 (coord.s / coord.q, coord.t / coord.q, coord.p / coord.q),\n"
+" lod);\n"
+"}\n"
+"\n"
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_vertex_builtin_gc_bin.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_vertex_builtin_gc_bin.h
new file mode 100755
index 000000000..31d1fce3a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/library/slang_vertex_builtin_gc_bin.h
@@ -0,0 +1,82 @@
+2,2,2,5,12,1,103,108,95,80,111,115,105,116,105,111,110,0,0,0,2,2,5,9,
+1,103,108,95,80,111,105,110,116,83,105,122,101,0,0,0,2,2,5,12,1,103,108,95,
+67,108,105,112,86,101,114,116,101,120,0,0,0,2,2,2,12,1,103,108,95,67,111,108,
+111,114,0,0,0,2,2,2,12,1,103,108,95,83,101,99,111,110,100,97,114,121,67,111,
+108,111,114,0,0,0,2,2,2,11,1,103,108,95,78,111,114,109,97,108,0,0,0,2,
+2,2,12,1,103,108,95,86,101,114,116,101,120,0,0,0,2,2,2,12,1,103,108,95,
+77,117,108,116,105,84,101,120,67,111,111,114,100,48,0,0,0,2,2,2,12,1,103,108,
+95,77,117,108,116,105,84,101,120,67,111,111,114,100,49,0,0,0,2,2,2,12,1,103,
+108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,50,0,0,0,2,2,2,12,1,
+103,108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,51,0,0,0,2,2,2,12,
+1,103,108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,52,0,0,0,2,2,2,
+12,1,103,108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,53,0,0,0,2,2,
+2,12,1,103,108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,54,0,0,0,2,
+2,2,12,1,103,108,95,77,117,108,116,105,84,101,120,67,111,111,114,100,55,0,0,0,
+2,2,2,9,1,103,108,95,70,111,103,67,111,111,114,100,0,0,0,2,2,3,12,1,
+103,108,95,70,114,111,110,116,67,111,108,111,114,0,0,0,2,2,3,12,1,103,108,95,
+66,97,99,107,67,111,108,111,114,0,0,0,2,2,3,12,1,103,108,95,70,114,111,110,
+116,83,101,99,111,110,100,97,114,121,67,111,108,111,114,0,0,0,2,2,3,12,1,103,
+108,95,66,97,99,107,83,101,99,111,110,100,97,114,121,67,111,108,111,114,0,0,0,2,
+2,3,12,1,103,108,95,84,101,120,67,111,111,114,100,0,4,0,2,2,3,9,1,103,
+108,95,70,111,103,70,114,97,103,67,111,111,114,100,0,0,0,1,0,12,0,102,116,114,
+97,110,115,102,111,114,109,0,0,1,8,18,103,108,95,77,111,100,101,108,86,105,101,119,
+80,114,111,106,101,99,116,105,111,110,77,97,116,114,105,120,0,18,103,108,95,86,101,114,
+116,101,120,0,48,0,0,1,0,12,0,116,101,120,116,117,114,101,49,68,76,111,100,0,
+1,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,9,99,111,111,114,100,0,0,
+1,0,0,9,108,111,100,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,
+0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,49,68,80,114,111,106,76,111,100,
+0,1,0,0,16,115,97,109,112,108,101,114,0,0,1,0,0,10,99,111,111,114,100,0,
+0,1,0,0,9,108,111,100,0,0,0,1,8,58,116,101,120,116,117,114,101,49,68,76,
+111,100,0,18,115,97,109,112,108,101,114,0,0,18,99,111,111,114,100,0,59,115,0,18,
+99,111,111,114,100,0,59,116,0,49,0,18,108,111,100,0,0,0,0,0,1,0,12,0,
+116,101,120,116,117,114,101,49,68,80,114,111,106,76,111,100,0,1,0,0,16,115,97,109,
+112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,108,111,100,
+0,0,0,1,8,58,116,101,120,116,117,114,101,49,68,76,111,100,0,18,115,97,109,112,
+108,101,114,0,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,
+0,49,0,18,108,111,100,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,50,
+68,76,111,100,0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,10,99,111,
+111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,8,58,118,101,99,52,0,17,
+48,0,48,0,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,50,68,80,114,
+111,106,76,111,100,0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,11,99,
+111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,8,58,116,101,120,116,117,
+114,101,50,68,76,111,100,0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,50,0,
+18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,112,0,49,0,18,99,
+111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,112,0,49,0,0,0,18,108,
+111,100,0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,50,68,80,114,111,106,
+76,111,100,0,1,0,0,17,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,
+114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,8,58,116,101,120,116,117,114,101,
+50,68,76,111,100,0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,50,0,18,99,
+111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,
+114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,0,0,0,18,108,111,100,
+0,0,0,0,0,1,0,12,0,116,101,120,116,117,114,101,51,68,76,111,100,0,1,0,
+0,18,115,97,109,112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,
+0,9,108,111,100,0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,
+0,0,1,0,12,0,116,101,120,116,117,114,101,51,68,80,114,111,106,76,111,100,0,1,
+0,0,18,115,97,109,112,108,101,114,0,0,1,0,0,12,99,111,111,114,100,0,0,1,
+0,0,9,108,111,100,0,0,0,1,8,58,116,101,120,116,117,114,101,51,68,76,111,100,
+0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,51,0,18,99,111,111,114,100,0,
+59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,116,
+0,18,99,111,111,114,100,0,59,113,0,49,0,18,99,111,111,114,100,0,59,115,0,18,
+99,111,111,114,100,0,59,113,0,49,0,0,0,18,108,111,100,0,0,0,0,0,1,0,
+12,0,116,101,120,116,117,114,101,67,117,98,101,76,111,100,0,1,0,0,19,115,97,109,
+112,108,101,114,0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,108,111,100,
+0,0,0,1,8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,12,
+0,115,104,97,100,111,119,49,68,76,111,100,0,1,0,0,20,115,97,109,112,108,101,114,
+0,0,1,0,0,11,99,111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,
+8,58,118,101,99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,12,0,115,104,97,
+100,111,119,50,68,76,111,100,0,1,0,0,21,115,97,109,112,108,101,114,0,0,1,0,
+0,11,99,111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,8,58,118,101,
+99,52,0,17,48,0,48,0,0,0,0,0,0,1,0,12,0,115,104,97,100,111,119,49,
+68,80,114,111,106,76,111,100,0,1,0,0,20,115,97,109,112,108,101,114,0,0,1,0,
+0,12,99,111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,8,58,115,104,
+97,100,111,119,49,68,76,111,100,0,18,115,97,109,112,108,101,114,0,0,58,118,101,99,
+51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,0,49,0,
+17,48,0,48,0,0,0,18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,
+59,113,0,49,0,0,0,18,108,111,100,0,0,0,0,0,1,0,12,0,115,104,97,100,
+111,119,50,68,80,114,111,106,76,111,100,0,1,0,0,21,115,97,109,112,108,101,114,0,
+0,1,0,0,12,99,111,111,114,100,0,0,1,0,0,9,108,111,100,0,0,0,1,8,
+58,115,104,97,100,111,119,50,68,76,111,100,0,18,115,97,109,112,108,101,114,0,0,58,
+118,101,99,51,0,18,99,111,111,114,100,0,59,115,0,18,99,111,111,114,100,0,59,113,
+0,49,0,18,99,111,111,114,100,0,59,116,0,18,99,111,111,114,100,0,59,113,0,49,
+0,18,99,111,111,114,100,0,59,112,0,18,99,111,111,114,100,0,59,113,0,49,0,0,
+0,18,108,111,100,0,0,0,0,0,0 \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble.c
new file mode 100755
index 000000000..a9e2b07a5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble.c
@@ -0,0 +1,1208 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file slang_assemble.c
+ * slang intermediate code assembler
+ * \author Michal Krol
+ */
+
+#include "imports.h"
+#include "slang_utility.h"
+#include "slang_assemble.h"
+#include "slang_compile.h"
+#include "slang_storage.h"
+#include "slang_assemble_constructor.h"
+#include "slang_assemble_typeinfo.h"
+#include "slang_assemble_conditional.h"
+#include "slang_assemble_assignment.h"
+
+/* slang_assembly */
+
+static void slang_assembly_construct (slang_assembly *assem)
+{
+ assem->type = slang_asm_none;
+}
+
+static void slang_assembly_destruct (slang_assembly *assem)
+{
+}
+
+/* slang_assembly_file */
+
+void slang_assembly_file_construct (slang_assembly_file *file)
+{
+ file->code = NULL;
+ file->count = 0;
+}
+
+void slang_assembly_file_destruct (slang_assembly_file *file)
+{
+ unsigned int i;
+
+ for (i = 0; i < file->count; i++)
+ slang_assembly_destruct (file->code + i);
+ slang_alloc_free (file->code);
+}
+
+static int slang_assembly_file_push_new (slang_assembly_file *file)
+{
+ file->code = (slang_assembly *) slang_alloc_realloc (file->code, file->count * sizeof (
+ slang_assembly), (file->count + 1) * sizeof (slang_assembly));
+ if (file->code != NULL)
+ {
+ slang_assembly_construct (file->code + file->count);
+ file->count++;
+ return 1;
+ }
+ return 0;
+}
+
+static int slang_assembly_file_push_general (slang_assembly_file *file, slang_assembly_type type,
+ GLfloat literal, GLuint label, GLuint size)
+{
+ slang_assembly *assem;
+ if (!slang_assembly_file_push_new (file))
+ return 0;
+ assem = file->code + file->count - 1;
+ assem->type = type;
+ assem->literal = literal;
+ assem->param[0] = label;
+ assem->param[1] = size;
+ return 1;
+}
+
+int slang_assembly_file_push (slang_assembly_file *file, slang_assembly_type type)
+{
+ return slang_assembly_file_push_general (file, type, (GLfloat) 0, 0, 0);
+}
+
+int slang_assembly_file_push_label (slang_assembly_file *file, slang_assembly_type type,
+ GLuint label)
+{
+ return slang_assembly_file_push_general (file, type, (GLfloat) 0, label, 0);
+}
+
+int slang_assembly_file_push_label2 (slang_assembly_file *file, slang_assembly_type type,
+ GLuint label1, GLuint label2)
+{
+ return slang_assembly_file_push_general (file, type, (GLfloat) 0, label1, label2);
+}
+
+int slang_assembly_file_push_literal (slang_assembly_file *file, slang_assembly_type type,
+ GLfloat literal)
+{
+ return slang_assembly_file_push_general (file, type, literal, 0, 0);
+}
+
+/* utility functions */
+
+static int sizeof_variable (slang_type_specifier *spec, slang_type_qualifier qual,
+ slang_operation *array_size, slang_assembly_name_space *space, unsigned int *size)
+{
+ slang_storage_aggregate agg;
+
+ slang_storage_aggregate_construct (&agg);
+ if (!_slang_aggregate_variable (&agg, spec, array_size, space->funcs, space->structs))
+ {
+ slang_storage_aggregate_destruct (&agg);
+ return 0;
+ }
+ *size += _slang_sizeof_aggregate (&agg);
+ if (qual == slang_qual_out || qual == slang_qual_inout)
+ *size += 4;
+ slang_storage_aggregate_destruct (&agg);
+ return 1;
+}
+
+static int sizeof_variable2 (slang_variable *var, slang_assembly_name_space *space,
+ unsigned int *size)
+{
+ var->address = *size;
+ if (var->type.qualifier == slang_qual_out || var->type.qualifier == slang_qual_inout)
+ var->address += 4;
+ return sizeof_variable (&var->type.specifier, var->type.qualifier, var->array_size, space,
+ size);
+}
+
+static int sizeof_variables (slang_variable_scope *vars, unsigned int start, unsigned int stop,
+ slang_assembly_name_space *space, unsigned int *size)
+{
+ unsigned int i;
+
+ for (i = start; i < stop; i++)
+ if (!sizeof_variable2 (vars->variables + i, space, size))
+ return 0;
+ return 1;
+}
+
+static int collect_locals (slang_operation *op, slang_assembly_name_space *space,
+ unsigned int *size)
+{
+ unsigned int i;
+
+ if (!sizeof_variables (op->locals, 0, op->locals->num_variables, space, size))
+ return 0;
+ for (i = 0; i < op->num_children; i++)
+ if (!collect_locals (op->children + i, space, size))
+ return 0;
+ return 1;
+}
+
+/* _slang_locate_function() */
+
+slang_function *_slang_locate_function (const char *name, slang_operation *params,
+ unsigned int num_params, slang_assembly_name_space *space)
+{
+ unsigned int i;
+
+ for (i = 0; i < space->funcs->num_functions; i++)
+ {
+ unsigned int j;
+ slang_function *f = space->funcs->functions + i;
+
+ if (slang_string_compare (name, f->header.name) != 0)
+ continue;
+ if (f->param_count != num_params)
+ continue;
+ for (j = 0; j < num_params; j++)
+ {
+ slang_assembly_typeinfo ti;
+ slang_assembly_typeinfo_construct (&ti);
+ if (!_slang_typeof_operation (params + j, space, &ti))
+ {
+ slang_assembly_typeinfo_destruct (&ti);
+ return 0;
+ }
+ if (!slang_type_specifier_equal (&ti.spec, &f->parameters->variables[j].type.specifier))
+ {
+ slang_assembly_typeinfo_destruct (&ti);
+ break;
+ }
+ slang_assembly_typeinfo_destruct (&ti);
+ /* "out" and "inout" formal parameter requires the actual parameter to be l-value */
+ if (!ti.can_be_referenced &&
+ (f->parameters->variables[j].type.qualifier == slang_qual_out ||
+ f->parameters->variables[j].type.qualifier == slang_qual_inout))
+ break;
+ }
+ if (j == num_params)
+ return f;
+ }
+ if (space->funcs->outer_scope != NULL)
+ {
+ slang_assembly_name_space my_space = *space;
+ my_space.funcs = space->funcs->outer_scope;
+ return _slang_locate_function (name, params, num_params, &my_space);
+ }
+ return NULL;
+}
+
+/* _slang_assemble_function() */
+
+int _slang_assemble_function (slang_assembly_file *file, slang_function *fun,
+ slang_assembly_name_space *space)
+{
+ unsigned int param_size, local_size;
+ unsigned int skip, cleanup;
+ slang_assembly_flow_control flow;
+ slang_assembly_local_info info;
+ slang_assembly_stack_info stk;
+
+ fun->address = file->count;
+
+ if (fun->body == NULL)
+ {
+ /* TODO: jump to the actual function body */
+ return 1;
+ }
+
+ /* calculate return value and parameters size */
+ param_size = 0;
+ if (fun->header.type.specifier.type != slang_spec_void)
+ if (!sizeof_variable (&fun->header.type.specifier, slang_qual_none, NULL, space,
+ &param_size))
+ return 0;
+ info.ret_size = param_size;
+ if (!sizeof_variables (fun->parameters, 0, fun->param_count, space, &param_size))
+ return 0;
+
+ /* calculate local variables size, take into account the four-byte return address and
+ temporaries for various tasks */
+ info.addr_tmp = param_size + 4;
+ info.swizzle_tmp = param_size + 4 + 4;
+ local_size = param_size + 4 + 4 + 16;
+ if (!sizeof_variables (fun->parameters, fun->param_count, fun->parameters->num_variables, space,
+ &local_size))
+ return 0;
+ if (!collect_locals (fun->body, space, &local_size))
+ return 0;
+
+ /* allocate local variable storage */
+ if (!slang_assembly_file_push_label (file, slang_asm_local_alloc, local_size - param_size - 4))
+ return 0;
+
+ /* mark a new frame for function variable storage */
+ if (!slang_assembly_file_push_label (file, slang_asm_enter, local_size))
+ return 0;
+
+ /* skip the cleanup jump */
+ skip = file->count;
+ if (!slang_assembly_file_push_new (file))
+ return 0;
+ file->code[skip].type = slang_asm_jump;
+
+ /* all "return" statements will be directed here */
+ flow.function_end = file->count;
+ cleanup = file->count;
+ if (!slang_assembly_file_push_new (file))
+ return 0;
+ file->code[cleanup].type = slang_asm_jump;
+
+ /* execute the function body */
+ file->code[skip].param[0] = file->count;
+ if (!_slang_assemble_operation (file, fun->body, 0, &flow, space, &info, &stk))
+ return 0;
+
+ /* this is the end of the function - restore the old function frame */
+ file->code[cleanup].param[0] = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_leave))
+ return 0;
+
+ /* free local variable storage */
+ if (!slang_assembly_file_push_label (file, slang_asm_local_free, local_size - param_size - 4))
+ return 0;
+
+ /* jump out of the function */
+ if (!slang_assembly_file_push (file, slang_asm_return))
+ return 0;
+ return 1;
+}
+
+int _slang_cleanup_stack (slang_assembly_file *file, slang_operation *op, int ref,
+ slang_assembly_name_space *space)
+{
+ slang_assembly_typeinfo ti;
+ unsigned int size;
+
+ slang_assembly_typeinfo_construct (&ti);
+ if (!_slang_typeof_operation (op, space, &ti))
+ {
+ slang_assembly_typeinfo_destruct (&ti);
+ return 0;
+ }
+ if (ti.spec.type == slang_spec_void)
+ size = 0;
+ else if (ref)
+ size = 4;
+ else
+ {
+ size = 0;
+ if (!sizeof_variable (&ti.spec, slang_qual_none, NULL, space, &size))
+ {
+ slang_assembly_typeinfo_destruct (&ti);
+ return 0;
+ }
+ }
+ slang_assembly_typeinfo_destruct (&ti);
+ if (size != 0)
+ {
+ if (!slang_assembly_file_push_label (file, slang_asm_local_free, size))
+ return 0;
+ }
+ return 1;
+}
+
+/* _slang_assemble_operation() */
+
+/* XXX: general swizzle! */
+static int dereference_aggregate (slang_assembly_file *file, const slang_storage_aggregate *agg,
+ unsigned int index, unsigned int *size, slang_assembly_local_info *info)
+{
+ unsigned int i;
+
+ for (i = agg->count; i > 0; i--)
+ {
+ const slang_storage_array *arr = agg->arrays + i - 1;
+ unsigned int j;
+
+ for (j = arr->length; j > 0; j--)
+ {
+ if (arr->type == slang_stor_aggregate)
+ {
+ if (!dereference_aggregate (file, arr->aggregate, index, size, info))
+ return 0;
+ }
+ else
+ {
+ *size -= 4;
+ if (!slang_assembly_file_push_label2 (file, slang_asm_local_addr, info->addr_tmp,
+ 4))
+ return 0;
+ if (!slang_assembly_file_push (file, slang_asm_addr_deref))
+ return 0;
+ if (!slang_assembly_file_push_label (file, slang_asm_addr_push, *size))
+ return 0;
+ if (!slang_assembly_file_push (file, slang_asm_addr_add))
+ return 0;
+ switch (arr->type)
+ {
+ case slang_stor_bool:
+ if (!slang_assembly_file_push (file, slang_asm_bool_deref))
+ return 0;
+ break;
+ case slang_stor_int:
+ if (!slang_assembly_file_push (file, slang_asm_int_deref))
+ return 0;
+ break;
+ case slang_stor_float:
+ if (!slang_assembly_file_push (file, slang_asm_float_deref))
+ return 0;
+ break;
+ }
+ index += 4;
+ }
+ }
+ }
+ return 1;
+}
+/* XXX: general swizzle! */
+int dereference (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_name_space *space, slang_assembly_local_info *info)
+{
+ slang_assembly_typeinfo ti;
+ int result;
+ slang_storage_aggregate agg;
+ unsigned int size;
+
+ slang_assembly_typeinfo_construct (&ti);
+ if (!_slang_typeof_operation (op, space, &ti))
+ {
+ slang_assembly_typeinfo_destruct (&ti);
+ return 0;
+ }
+
+ slang_storage_aggregate_construct (&agg);
+ if (!_slang_aggregate_variable (&agg, &ti.spec, NULL, space->funcs, space->structs))
+ {
+ slang_storage_aggregate_destruct (&agg);
+ slang_assembly_typeinfo_destruct (&ti);
+ return 0;
+ }
+
+ size = _slang_sizeof_aggregate (&agg);
+ result = dereference_aggregate (file, &agg, 0, &size, info);
+
+ slang_storage_aggregate_destruct (&agg);
+ slang_assembly_typeinfo_destruct (&ti);
+ return result;
+}
+
+static int call_function (slang_assembly_file *file, slang_function *fun, slang_operation *params,
+ unsigned int param_count, int assignment, slang_assembly_name_space *space,
+ slang_assembly_local_info *info)
+{
+ unsigned int i;
+ slang_assembly_stack_info stk;
+
+ /* make room for the return value, if any */
+ if (fun->header.type.specifier.type != slang_spec_void)
+ {
+ unsigned int ret_size = 0;
+ if (!sizeof_variable (&fun->header.type.specifier, slang_qual_none, NULL, space, &ret_size))
+ return 0;
+ if (!slang_assembly_file_push_label (file, slang_asm_local_alloc, ret_size))
+ return 0;
+ }
+
+ /* push the actual parameters on the stack */
+ for (i = 0; i < param_count; i++)
+ {
+ slang_assembly_flow_control flow;
+
+ if (fun->parameters->variables[i].type.qualifier == slang_qual_inout ||
+ fun->parameters->variables[i].type.qualifier == slang_qual_out)
+ {
+ if (!slang_assembly_file_push_label2 (file, slang_asm_local_addr, info->addr_tmp, 4))
+ return 0;
+ /* TODO: optimize the "out" parameter case */
+ /* TODO: inspect stk */
+ if (!_slang_assemble_operation (file, params + i, 1, &flow, space, info, &stk))
+ return 0;
+ if (!slang_assembly_file_push (file, slang_asm_addr_copy))
+ return 0;
+ if (!slang_assembly_file_push (file, slang_asm_addr_deref))
+ return 0;
+ if (i == 0 && assignment)
+ {
+ if (!slang_assembly_file_push_label2 (file, slang_asm_local_addr, info->addr_tmp,
+ 4))
+ return 0;
+ if (!slang_assembly_file_push (file, slang_asm_addr_deref))
+ return 0;
+ }
+ if (!dereference (file, params, space, info))
+ return 0;
+ }
+ else
+ {
+ /* TODO: for "out" and "inout" parameters also push the address (first) */
+ /* TODO: optimize the "out" parameter case */
+ /* TODO: inspect stk */
+ if (!_slang_assemble_operation (file, params + i, 0, &flow, space, info, &stk))
+ return 0;
+ }
+ }
+
+ /* call the function */
+ if (!slang_assembly_file_push_label (file, slang_asm_call, fun->address))
+ return 0;
+
+ /* pop the parameters from the stack */
+ for (i = param_count; i > 0; i--)
+ {
+ unsigned int j = i - 1;
+ if (fun->parameters->variables[j].type.qualifier == slang_qual_inout ||
+ fun->parameters->variables[j].type.qualifier == slang_qual_out)
+ {
+ if (!_slang_assemble_assignment (file, params + j, space, info))
+ return 0;
+ if (!slang_assembly_file_push_label (file, slang_asm_local_free, 4))
+ return 0;
+ }
+ else
+ {
+ if (!_slang_cleanup_stack (file, params + j, 0, space))
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+int call_function_name (slang_assembly_file *file, const char *name, slang_operation *params,
+ unsigned int param_count, int assignment, slang_assembly_name_space *space,
+ slang_assembly_local_info *info)
+{
+ slang_function *fun = _slang_locate_function (name, params, param_count, space);
+ if (fun == NULL)
+ return 0;
+ return call_function (file, fun, params, param_count, assignment, space, info);
+}
+
+static int call_function_name_dummyint (slang_assembly_file *file, const char *name,
+ slang_operation *params, slang_assembly_name_space *space, slang_assembly_local_info *info)
+{
+ slang_operation p2[2];
+ int result;
+
+ p2[0] = *params;
+ if (!slang_operation_construct_a (p2 + 1))
+ return 0;
+ p2[1].type = slang_oper_literal_int;
+ result = call_function_name (file, name, p2, 2, 0, space, info);
+ slang_operation_destruct (p2 + 1);
+ return result;
+}
+
+static int call_asm_instruction (slang_assembly_file *file, const char *name)
+{
+ const struct
+ {
+ const char *name;
+ slang_assembly_type code1, code2;
+ } inst[] = {
+ { "float_to_int", slang_asm_float_to_int, slang_asm_int_copy },
+ { "int_to_float", slang_asm_int_to_float, slang_asm_float_copy },
+ { "float_copy", slang_asm_float_copy, slang_asm_none },
+ { "int_copy", slang_asm_int_copy, slang_asm_none },
+ { "bool_copy", slang_asm_bool_copy, slang_asm_none },
+ { "float_add", slang_asm_float_add, slang_asm_float_copy },
+ { "float_multiply", slang_asm_float_multiply, slang_asm_float_copy },
+ { "float_divide", slang_asm_float_divide, slang_asm_float_copy },
+ { "float_negate", slang_asm_float_negate, slang_asm_float_copy },
+ { "float_less", slang_asm_float_less, slang_asm_bool_copy },
+ { "float_equal", slang_asm_float_equal, slang_asm_bool_copy },
+ { NULL, slang_asm_none, slang_asm_none }
+ };
+ unsigned int i;
+
+ for (i = 0; inst[i].name != NULL; i++)
+ if (slang_string_compare (name, inst[i].name) == 0)
+ break;
+ if (inst[i].name == NULL)
+ return 0;
+
+ if (!slang_assembly_file_push_label2 (file, inst[i].code1, 4, 0))
+ return 0;
+ if (inst[i].code2 != slang_asm_none)
+ if (!slang_assembly_file_push_label2 (file, inst[i].code2, 4, 0))
+ return 0;
+
+ /* clean-up the stack from the remaining dst address */
+ if (!slang_assembly_file_push_label (file, slang_asm_local_free, 4))
+ return 0;
+
+ return 1;
+}
+
+/* XXX: general swizzle! */
+static int equality_aggregate (slang_assembly_file *file, const slang_storage_aggregate *agg,
+ unsigned int *index, unsigned int size, slang_assembly_local_info *info, unsigned int z_label)
+{
+ unsigned int i;
+
+ for (i = 0; i < agg->count; i++)
+ {
+ const slang_storage_array *arr = agg->arrays + i;
+ unsigned int j;
+
+ for (j = 0; j < arr->length; j++)
+ {
+ if (arr->type == slang_stor_aggregate)
+ {
+ if (!equality_aggregate (file, arr->aggregate, index, size, info, z_label))
+ return 0;
+ }
+ else
+ {
+ if (!slang_assembly_file_push_label2 (file, slang_asm_float_equal, size + *index,
+ *index))
+ return 0;
+ *index += 4;
+ if (!slang_assembly_file_push_label (file, slang_asm_jump_if_zero, z_label))
+ return 0;
+ }
+ }
+ }
+ return 1;
+}
+/* XXX: general swizzle! */
+static int equality (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_name_space *space, slang_assembly_local_info *info, int equal)
+{
+ slang_assembly_typeinfo ti;
+ int result;
+ slang_storage_aggregate agg;
+ unsigned int index, size;
+ unsigned int skip_jump, true_label, true_jump, false_label, false_jump;
+
+ /* get type of operation */
+ slang_assembly_typeinfo_construct (&ti);
+ if (!_slang_typeof_operation (op, space, &ti))
+ {
+ slang_assembly_typeinfo_destruct (&ti);
+ return 0;
+ }
+
+ /* convert it to an aggregate */
+ slang_storage_aggregate_construct (&agg);
+ if (!(result = _slang_aggregate_variable (&agg, &ti.spec, NULL, space->funcs, space->structs)))
+ goto end;
+
+ /* compute the size of the agregate - there are two such aggregates on the stack */
+ size = _slang_sizeof_aggregate (&agg);
+
+ /* jump to the actual data-comparison code */
+ skip_jump = file->count;
+ if (!(result = slang_assembly_file_push (file, slang_asm_jump)))
+ goto end;
+
+ /* pop off the stack the compared data and push 1 */
+ true_label = file->count;
+ if (!(result = slang_assembly_file_push_label (file, slang_asm_local_free, size * 2)))
+ goto end;
+ if (!(result = slang_assembly_file_push_literal (file, slang_asm_bool_push, 1.0f)))
+ goto end;
+ true_jump = file->count;
+ if (!(result = slang_assembly_file_push (file, slang_asm_jump)))
+ goto end;
+
+ false_label = file->count;
+ if (!(result = slang_assembly_file_push_label (file, slang_asm_local_free, size * 2)))
+ goto end;
+ if (!(result = slang_assembly_file_push_literal (file, slang_asm_bool_push, 0.0f)))
+ goto end;
+ false_jump = file->count;
+ if (!(result = slang_assembly_file_push (file, slang_asm_jump)))
+ goto end;
+
+ file->code[skip_jump].param[0] = file->count;
+
+ /* compare the data on stack, it will eventually jump either to true or false label */
+ index = 0;
+ if (!(result = equality_aggregate (file, &agg, &index, size, info,
+ equal ? false_label : true_label)))
+ goto end;
+ if (!(result = slang_assembly_file_push_label (file, slang_asm_jump,
+ equal ? true_label : false_label)))
+ goto end;
+
+ file->code[true_jump].param[0] = file->count;
+ file->code[false_jump].param[0] = file->count;
+
+ result = 1;
+end:
+ slang_storage_aggregate_destruct (&agg);
+ slang_assembly_typeinfo_destruct (&ti);
+ return result;
+}
+
+int _slang_assemble_operation (slang_assembly_file *file, slang_operation *op, int reference,
+ slang_assembly_flow_control *flow, slang_assembly_name_space *space,
+ slang_assembly_local_info *info, slang_assembly_stack_info *stk)
+{
+ unsigned int assem;
+
+ stk->swizzle_mask = 0;
+
+ assem = file->count;
+ if (!slang_assembly_file_push_new (file))
+ return 0;
+
+ switch (op->type)
+ {
+ case slang_oper_block_no_new_scope:
+ case slang_oper_block_new_scope:
+ {
+ unsigned int i;
+ for (i = 0; i < op->num_children; i++)
+ {
+ slang_assembly_stack_info stk;
+ if (!_slang_assemble_operation (file, op->children + i, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: pass-in stk to cleanup */
+ if (!_slang_cleanup_stack (file, op->children + i, 0, space))
+ return 0;
+ }
+ }
+ break;
+ case slang_oper_variable_decl:
+ {
+ unsigned int i;
+
+ for (i = 0; i < op->num_children; i++)
+ {
+ /* TODO: perform initialization of op->children[i] */
+ /* TODO: clean-up stack */
+ }
+ }
+ break;
+ case slang_oper_asm:
+ {
+ unsigned int i;
+ for (i = 0; i < op->num_children; i++)
+ {
+ slang_assembly_stack_info stk;
+ if (!_slang_assemble_operation (file, op->children + i, i == 0, flow, space, info,
+ &stk))
+ return 0;
+ /* TODO: inspect stk */
+ }
+ if (!call_asm_instruction (file, op->identifier))
+ return 0;
+ }
+ break;
+ case slang_oper_break:
+ file->code[assem].type = slang_asm_jump;
+ file->code[assem].param[0] = flow->loop_end;
+ break;
+ case slang_oper_continue:
+ file->code[assem].type = slang_asm_jump;
+ file->code[assem].param[0] = flow->loop_start;
+ break;
+ case slang_oper_discard:
+ file->code[assem].type = slang_asm_discard;
+ if (!slang_assembly_file_push (file, slang_asm_exit))
+ return 0;
+ break;
+ case slang_oper_return:
+ if (info->ret_size != 0)
+ {
+ slang_assembly_stack_info stk;
+ if (!slang_assembly_file_push_label2 (file, slang_asm_local_addr, 0, info->ret_size))
+ return 0;
+ if (!_slang_assemble_operation (file, op->children, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: inspect stk */
+ if (!_slang_assemble_assignment (file, op->children, space, info))
+ return 0;
+ if (!slang_assembly_file_push_label (file, slang_asm_local_free, 4))
+ return 0;
+ }
+ if (!slang_assembly_file_push_label (file, slang_asm_jump, flow->function_end))
+ return 0;
+ break;
+ case slang_oper_expression:
+ {
+ slang_assembly_stack_info stk;
+ if (!_slang_assemble_operation (file, op->children, reference, flow, space, info, &stk))
+ return 0;
+ /* TODO: inspect stk */
+ }
+ break;
+ case slang_oper_if:
+ if (!_slang_assemble_if (file, op, flow, space, info))
+ return 0;
+ break;
+ case slang_oper_while:
+ if (!_slang_assemble_while (file, op, flow, space, info))
+ return 0;
+ break;
+ case slang_oper_do:
+ if (!_slang_assemble_do (file, op, flow, space, info))
+ return 0;
+ break;
+ case slang_oper_for:
+ if (!_slang_assemble_for (file, op, flow, space, info))
+ return 0;
+ break;
+ case slang_oper_void:
+ break;
+ case slang_oper_literal_bool:
+ file->code[assem].type = slang_asm_bool_push;
+ file->code[assem].literal = op->literal;
+ break;
+ case slang_oper_literal_int:
+ file->code[assem].type = slang_asm_int_push;
+ file->code[assem].literal = op->literal;
+ break;
+ case slang_oper_literal_float:
+ file->code[assem].type = slang_asm_float_push;
+ file->code[assem].literal = op->literal;
+ break;
+ case slang_oper_identifier:
+ {
+ slang_variable *var;
+ unsigned int size;
+ var = _slang_locate_variable (op->locals, op->identifier, 1);
+ if (var == NULL)
+ return 0;
+ size = 0;
+ if (!sizeof_variable (&var->type.specifier, slang_qual_none, var->array_size, space,
+ &size))
+ return 0;
+ if (var->initializer != NULL)
+ {
+ assert (!"var->initializer, oper_identifier");
+ }
+ else
+ {
+ if (!reference)
+ {
+ if (!slang_assembly_file_push_label2 (file, slang_asm_local_addr,
+ info->addr_tmp, 4))
+ return 0;
+ }
+ /* XXX: globals! */
+ if (!slang_assembly_file_push_label2 (file, slang_asm_local_addr, var->address,
+ size))
+ return 0;
+ if (!reference)
+ {
+ if (!slang_assembly_file_push (file, slang_asm_addr_copy))
+ return 0;
+ if (!slang_assembly_file_push_label (file, slang_asm_local_free, 4))
+ return 0;
+ if (!dereference (file, op, space, info))
+ return 0;
+ }
+ }
+ }
+ break;
+ case slang_oper_sequence:
+ {
+ slang_assembly_stack_info stk;
+ if (!_slang_assemble_operation (file, op->children, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: pass-in stk to cleanup */
+ if (!_slang_cleanup_stack (file, op->children, 0, space))
+ return 0;
+ if (!_slang_assemble_operation (file, op->children + 1, 0, flow, space, info,
+ &stk))
+ return 0;
+ /* TODO: inspect stk */
+ }
+ break;
+ case slang_oper_assign:
+ if (!_slang_assemble_assign (file, op, "=", reference, space, info))
+ return 0;
+ break;
+ case slang_oper_addassign:
+ if (!_slang_assemble_assign (file, op, "+=", reference, space, info))
+ return 0;
+ break;
+ case slang_oper_subassign:
+ if (!_slang_assemble_assign (file, op, "-=", reference, space, info))
+ return 0;
+ break;
+ case slang_oper_mulassign:
+ if (!_slang_assemble_assign (file, op, "*=", reference, space, info))
+ return 0;
+ break;
+ /*case slang_oper_modassign:*/
+ /*case slang_oper_lshassign:*/
+ /*case slang_oper_rshassign:*/
+ /*case slang_oper_orassign:*/
+ /*case slang_oper_xorassign:*/
+ /*case slang_oper_andassign:*/
+ case slang_oper_divassign:
+ if (!_slang_assemble_assign (file, op, "/=", reference, space, info))
+ return 0;
+ break;
+ case slang_oper_select:
+ if (!_slang_assemble_select (file, op, flow, space, info))
+ return 0;
+ break;
+ case slang_oper_logicalor:
+ if (!_slang_assemble_logicalor (file, op, flow, space, info))
+ return 0;
+ break;
+ case slang_oper_logicaland:
+ if (!_slang_assemble_logicaland (file, op, flow, space, info))
+ return 0;
+ break;
+ case slang_oper_logicalxor:
+ if (!call_function_name (file, "^^", op->children, 2, 0, space, info))
+ return 0;
+ break;
+ /*case slang_oper_bitor:*/
+ /*case slang_oper_bitxor:*/
+ /*case slang_oper_bitand:*/
+ case slang_oper_less:
+ if (!call_function_name (file, "<", op->children, 2, 0, space, info))
+ return 0;
+ break;
+ case slang_oper_greater:
+ if (!call_function_name (file, ">", op->children, 2, 0, space, info))
+ return 0;
+ break;
+ case slang_oper_lessequal:
+ if (!call_function_name (file, "<=", op->children, 2, 0, space, info))
+ return 0;
+ break;
+ case slang_oper_greaterequal:
+ if (!call_function_name (file, ">=", op->children, 2, 0, space, info))
+ return 0;
+ break;
+ /*case slang_oper_lshift:*/
+ /*case slang_oper_rshift:*/
+ case slang_oper_add:
+ if (!call_function_name (file, "+", op->children, 2, 0, space, info))
+ return 0;
+ break;
+ case slang_oper_subtract:
+ if (!call_function_name (file, "-", op->children, 2, 0, space, info))
+ return 0;
+ break;
+ case slang_oper_multiply:
+ if (!call_function_name (file, "*", op->children, 2, 0, space, info))
+ return 0;
+ break;
+ /*case slang_oper_modulus:*/
+ case slang_oper_divide:
+ if (!call_function_name (file, "/", op->children, 2, 0, space, info))
+ return 0;
+ break;
+ case slang_oper_equal:
+ {
+ slang_assembly_stack_info stk;
+ if (!_slang_assemble_operation (file, op->children, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: inspect stk */
+ if (!_slang_assemble_operation (file, op->children + 1, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: inspect stk */
+ if (!equality (file, op->children, space, info, 1))
+ return 0;
+ }
+ break;
+ case slang_oper_notequal:
+ {
+ slang_assembly_stack_info stk;
+ if (!_slang_assemble_operation (file, op->children, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: inspect stk */
+ if (!_slang_assemble_operation (file, op->children + 1, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: inspect stk */
+ if (!equality (file, op->children, space, info, 0))
+ return 0;
+ }
+ break;
+ case slang_oper_preincrement:
+ if (!_slang_assemble_assign (file, op, "++", reference, space, info))
+ return 0;
+ break;
+ case slang_oper_predecrement:
+ if (!_slang_assemble_assign (file, op, "--", reference, space, info))
+ return 0;
+ break;
+ case slang_oper_plus:
+ if (!call_function_name (file, "+", op->children, 1, 0, space, info))
+ return 0;
+ break;
+ case slang_oper_minus:
+ if (!call_function_name (file, "-", op->children, 1, 0, space, info))
+ return 0;
+ break;
+ /*case slang_oper_complement:*/
+ case slang_oper_not:
+ if (!call_function_name (file, "!", op->children, 1, 0, space, info))
+ return 0;
+ break;
+ case slang_oper_subscript:
+ {
+ slang_assembly_stack_info _stk;
+ slang_assembly_typeinfo ti_arr, ti_elem;
+ unsigned int arr_size = 0, elem_size = 0;
+ if (!_slang_assemble_operation (file, op->children, reference, flow, space, info,
+ &_stk))
+ return 0;
+ if (!_slang_assemble_operation (file, op->children + 1, 0, flow, space, info, &_stk))
+ return 0;
+ slang_assembly_typeinfo_construct (&ti_arr);
+ if (!_slang_typeof_operation (op->children, space, &ti_arr))
+ {
+ slang_assembly_typeinfo_destruct (&ti_arr);
+ return 0;
+ }
+ if (!sizeof_variable (&ti_arr.spec, slang_qual_none, NULL, space, &arr_size))
+ {
+ slang_assembly_typeinfo_destruct (&ti_arr);
+ return 0;
+ }
+ slang_assembly_typeinfo_construct (&ti_elem);
+ if (!_slang_typeof_operation (op, space, &ti_elem))
+ {
+ slang_assembly_typeinfo_destruct (&ti_arr);
+ slang_assembly_typeinfo_destruct (&ti_elem);
+ return 0;
+ }
+ if (!sizeof_variable (&ti_elem.spec, slang_qual_none, NULL, space, &elem_size))
+ {
+ slang_assembly_typeinfo_destruct (&ti_arr);
+ slang_assembly_typeinfo_destruct (&ti_elem);
+ return 0;
+ }
+ if (!slang_assembly_file_push (file, slang_asm_int_to_addr))
+ {
+ slang_assembly_typeinfo_destruct (&ti_arr);
+ slang_assembly_typeinfo_destruct (&ti_elem);
+ return 0;
+ }
+ if (!slang_assembly_file_push_label (file, slang_asm_addr_push, elem_size))
+ {
+ slang_assembly_typeinfo_destruct (&ti_arr);
+ slang_assembly_typeinfo_destruct (&ti_elem);
+ return 0;
+ }
+ if (!slang_assembly_file_push (file, slang_asm_addr_multiply))
+ {
+ slang_assembly_typeinfo_destruct (&ti_arr);
+ slang_assembly_typeinfo_destruct (&ti_elem);
+ return 0;
+ }
+ if (reference)
+ {
+ if (!slang_assembly_file_push (file, slang_asm_addr_add))
+ {
+ slang_assembly_typeinfo_destruct (&ti_arr);
+ slang_assembly_typeinfo_destruct (&ti_elem);
+ return 0;
+ }
+ }
+ else
+ {
+ unsigned int i;
+ for (i = 0; i < elem_size; i += 4)
+ {
+ if (!slang_assembly_file_push_label2 (file, slang_asm_float_move,
+ arr_size - elem_size + i + 4, i + 4))
+ {
+ slang_assembly_typeinfo_destruct (&ti_arr);
+ slang_assembly_typeinfo_destruct (&ti_elem);
+ return 0;
+ }
+ }
+ if (!slang_assembly_file_push_label (file, slang_asm_local_free, 4))
+ {
+ slang_assembly_typeinfo_destruct (&ti_arr);
+ slang_assembly_typeinfo_destruct (&ti_elem);
+ return 0;
+ }
+ if (!slang_assembly_file_push_label (file, slang_asm_local_free,
+ arr_size - elem_size))
+ {
+ slang_assembly_typeinfo_destruct (&ti_arr);
+ slang_assembly_typeinfo_destruct (&ti_elem);
+ return 0;
+ }
+ }
+ slang_assembly_typeinfo_destruct (&ti_arr);
+ slang_assembly_typeinfo_destruct (&ti_elem);
+ }
+ break;
+ case slang_oper_call:
+ {
+ slang_function *fun = _slang_locate_function (op->identifier, op->children,
+ op->num_children, space);
+ if (fun == NULL)
+ {
+ if (!_slang_assemble_constructor (file, op, flow, space, info))
+ return 0;
+ }
+ else
+ {
+ if (!call_function (file, fun, op->children, op->num_children, 0, space, info))
+ return 0;
+ }
+ }
+ break;
+ case slang_oper_field:
+ {
+ slang_assembly_typeinfo ti_after, ti_before;
+ slang_assembly_stack_info _stk;
+ slang_assembly_typeinfo_construct (&ti_after);
+ if (!_slang_typeof_operation (op, space, &ti_after))
+ {
+ slang_assembly_typeinfo_destruct (&ti_after);
+ return 0;
+ }
+ slang_assembly_typeinfo_construct (&ti_before);
+ if (!_slang_typeof_operation (op->children, space, &ti_before))
+ {
+ slang_assembly_typeinfo_destruct (&ti_after);
+ slang_assembly_typeinfo_destruct (&ti_before);
+ return 0;
+ }
+ if (!reference && ti_after.is_swizzled)
+ {
+ if (!slang_assembly_file_push_label2 (file, slang_asm_local_addr,
+ info->swizzle_tmp, 16))
+ {
+ slang_assembly_typeinfo_destruct (&ti_after);
+ slang_assembly_typeinfo_destruct (&ti_before);
+ return 0;
+ }
+ }
+ if (!_slang_assemble_operation (file, op->children, reference, flow, space, info,
+ &_stk))
+ {
+ slang_assembly_typeinfo_destruct (&ti_after);
+ slang_assembly_typeinfo_destruct (&ti_before);
+ return 0;
+ }
+ /* TODO: inspect stk */
+ if (ti_after.is_swizzled)
+ {
+ if (reference)
+ {
+ if (ti_after.swz.num_components == 1)
+ {
+ if (!slang_assembly_file_push_label (file, slang_asm_addr_push,
+ ti_after.swz.swizzle[0] * 4))
+ {
+ slang_assembly_typeinfo_destruct (&ti_after);
+ slang_assembly_typeinfo_destruct (&ti_before);
+ return 0;
+ }
+ if (!slang_assembly_file_push (file, slang_asm_addr_add))
+ {
+ slang_assembly_typeinfo_destruct (&ti_after);
+ slang_assembly_typeinfo_destruct (&ti_before);
+ return 0;
+ }
+ }
+ else
+ {
+ unsigned int i;
+ for (i = 0; i < ti_after.swz.num_components; i++)
+ stk->swizzle_mask |= 1 << ti_after.swz.swizzle[i];
+ }
+ }
+ else
+ {
+ if (!_slang_assemble_constructor_from_swizzle (file, &ti_after.swz,
+ &ti_after.spec, &ti_before.spec, info))
+ {
+ slang_assembly_typeinfo_destruct (&ti_after);
+ slang_assembly_typeinfo_destruct (&ti_before);
+ return 0;
+ }
+ }
+ }
+ else
+ {
+ if (reference)
+ {
+ /* TODO: struct field address */
+ }
+ else
+ {
+ /* TODO: struct field value */
+ }
+ }
+ slang_assembly_typeinfo_destruct (&ti_after);
+ slang_assembly_typeinfo_destruct (&ti_before);
+ }
+ break;
+ case slang_oper_postincrement:
+ if (!call_function_name_dummyint (file, "++", op->children, space, info))
+ return 0;
+ if (!dereference (file, op, space, info))
+ return 0;
+ break;
+ case slang_oper_postdecrement:
+ if (!call_function_name_dummyint (file, "--", op->children, space, info))
+ return 0;
+ if (!dereference (file, op, space, info))
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+ return 1;
+}
+
+
+
+
+
+
+
+
+
+void xxx_first (slang_assembly_file *file)
+{
+ slang_assembly_file_push (file, slang_asm_jump);
+}
+
+void xxx_prolog (slang_assembly_file *file, unsigned int addr)
+{
+ file->code[0].param[0] = file->count;
+ slang_assembly_file_push_label (file, slang_asm_call, addr);
+ slang_assembly_file_push (file, slang_asm_exit);
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble.h
new file mode 100755
index 000000000..69e81d6af
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble.h
@@ -0,0 +1,145 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#if !defined SLANG_ASSEMBLE_H
+#define SLANG_ASSEMBLE_H
+
+#include "slang_compile.h"
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+typedef enum slang_assembly_type_
+{
+ /* core */
+ slang_asm_none,
+ slang_asm_float_copy,
+ slang_asm_float_move,
+ slang_asm_float_push,
+ slang_asm_float_deref,
+ slang_asm_float_add,
+ slang_asm_float_multiply,
+ slang_asm_float_divide,
+ slang_asm_float_negate,
+ slang_asm_float_less,
+ slang_asm_float_equal,
+ slang_asm_float_to_int,
+ slang_asm_int_copy,
+ slang_asm_int_move,
+ slang_asm_int_push,
+ slang_asm_int_deref,
+ slang_asm_int_to_float,
+ slang_asm_int_to_addr,
+ slang_asm_bool_copy,
+ slang_asm_bool_move,
+ slang_asm_bool_push,
+ slang_asm_bool_deref,
+ slang_asm_addr_copy,
+ slang_asm_addr_push,
+ slang_asm_addr_deref,
+ slang_asm_addr_add,
+ slang_asm_addr_multiply,
+ slang_asm_jump,
+ slang_asm_jump_if_zero,
+ slang_asm_enter,
+ slang_asm_leave,
+ slang_asm_local_alloc,
+ slang_asm_local_free,
+ slang_asm_local_addr,
+ slang_asm_call,
+ slang_asm_return,
+ slang_asm_discard,
+ slang_asm_exit,
+ slang_asm__last
+} slang_assembly_type;
+
+typedef struct slang_assembly_
+{
+ slang_assembly_type type;
+ GLfloat literal;
+ GLuint param[2];
+} slang_assembly;
+
+typedef struct slang_assembly_file_
+{
+ slang_assembly *code;
+ unsigned int count;
+} slang_assembly_file;
+
+void slang_assembly_file_construct (slang_assembly_file *);
+void slang_assembly_file_destruct (slang_assembly_file *);
+int slang_assembly_file_push (slang_assembly_file *, slang_assembly_type);
+int slang_assembly_file_push_label (slang_assembly_file *, slang_assembly_type, GLuint);
+int slang_assembly_file_push_label2 (slang_assembly_file *, slang_assembly_type, GLuint, GLuint);
+int slang_assembly_file_push_literal (slang_assembly_file *, slang_assembly_type, GLfloat);
+
+typedef struct slang_assembly_flow_control_
+{
+ unsigned int loop_start; /* for "continue" statement */
+ unsigned int loop_end; /* for "break" statement */
+ unsigned int function_end; /* for "return" statement */
+} slang_assembly_flow_control;
+
+typedef struct slang_assembly_name_space_
+{
+ struct slang_function_scope_ *funcs;
+ struct slang_struct_scope_ *structs;
+ struct slang_variable_scope_ *vars;
+} slang_assembly_name_space;
+
+slang_function *_slang_locate_function (const char *name, slang_operation *params,
+ unsigned int num_params, slang_assembly_name_space *space);
+
+int _slang_assemble_function (slang_assembly_file *, struct slang_function_ *,
+ slang_assembly_name_space *);
+
+typedef struct slang_assembly_stack_info_
+{
+ unsigned int swizzle_mask;
+} slang_assembly_stack_info;
+
+int _slang_cleanup_stack (slang_assembly_file *, slang_operation *, int ref,
+ slang_assembly_name_space *);
+
+typedef struct slang_assembly_local_info_
+{
+ unsigned int ret_size;
+ unsigned int addr_tmp;
+ unsigned int swizzle_tmp;
+} slang_assembly_local_info;
+
+int _slang_assemble_operation (slang_assembly_file *, struct slang_operation_ *, int reference,
+ slang_assembly_flow_control *, slang_assembly_name_space *, slang_assembly_local_info *,
+ slang_assembly_stack_info *);
+
+void xxx_first (slang_assembly_file *);
+void xxx_prolog (slang_assembly_file *, unsigned int);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_assignment.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_assignment.c
new file mode 100755
index 000000000..551f5d9b1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_assignment.c
@@ -0,0 +1,187 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file slang_assemble_assignment.c
+ * slang assignment expressions assembler
+ * \author Michal Krol
+ */
+
+#include "imports.h"
+#include "slang_assemble_assignment.h"
+#include "slang_assemble_typeinfo.h"
+#include "slang_storage.h"
+#include "slang_utility.h"
+
+/*
+ _slang_assemble_assignment()
+
+ copies values on the stack (<component 0> to <component N-1>) to a memory
+ location pointed by <addr of variable>;
+
+ in:
+ +------------------+
+ | addr of variable |
+ +------------------+
+ | component N-1 |
+ | ... |
+ | component 0 |
+ +------------------+
+
+ out:
+ +------------------+
+ | addr of variable |
+ +------------------+
+*/
+/* TODO: add support for swizzle mask */
+static int assign_aggregate (slang_assembly_file *file, const slang_storage_aggregate *agg,
+ unsigned int *index, unsigned int size, slang_assembly_local_info *info)
+{
+ unsigned int i;
+
+ for (i = 0; i < agg->count; i++)
+ {
+ const slang_storage_array *arr = agg->arrays + i;
+ unsigned int j;
+
+ for (j = 0; j < arr->length; j++)
+ {
+ if (arr->type == slang_stor_aggregate)
+ {
+ if (!assign_aggregate (file, arr->aggregate, index, size, info))
+ return 0;
+ }
+ else
+ {
+ slang_assembly_type ty;
+
+ switch (arr->type)
+ {
+ case slang_stor_bool:
+ ty = slang_asm_bool_copy;
+ break;
+ case slang_stor_int:
+ ty = slang_asm_int_copy;
+ break;
+ case slang_stor_float:
+ ty = slang_asm_float_copy;
+ break;
+ default:
+ break;
+ }
+ if (!slang_assembly_file_push_label2 (file, ty, size - *index, *index))
+ return 0;
+ *index += 4;
+ }
+ }
+ }
+ return 1;
+}
+
+int _slang_assemble_assignment (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_name_space *space, slang_assembly_local_info *info)
+{
+ slang_assembly_typeinfo ti;
+ int result;
+ slang_storage_aggregate agg;
+ unsigned int index, size;
+
+ slang_assembly_typeinfo_construct (&ti);
+ if (!_slang_typeof_operation (op, space, &ti))
+ {
+ slang_assembly_typeinfo_destruct (&ti);
+ return 0;
+ }
+
+ slang_storage_aggregate_construct (&agg);
+ if (!_slang_aggregate_variable (&agg, &ti.spec, NULL, space->funcs, space->structs))
+ {
+ slang_storage_aggregate_destruct (&agg);
+ slang_assembly_typeinfo_destruct (&ti);
+ return 0;
+ }
+
+ index = 0;
+ size = _slang_sizeof_aggregate (&agg);
+ result = assign_aggregate (file, &agg, &index, size, info);
+
+ slang_storage_aggregate_destruct (&agg);
+ slang_assembly_typeinfo_destruct (&ti);
+ return result;
+}
+
+/*
+ _slang_assemble_assign()
+
+ performs unary (pre ++ and --) or binary (=, +=, -=, *=, /=) assignment on the operation's
+ children
+*/
+
+int dereference (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_name_space *space, slang_assembly_local_info *info);
+
+int call_function_name (slang_assembly_file *file, const char *name, slang_operation *params,
+ unsigned int param_count, int assignment, slang_assembly_name_space *space,
+ slang_assembly_local_info *info);
+
+int _slang_assemble_assign (slang_assembly_file *file, slang_operation *op, const char *oper,
+ int ref, slang_assembly_name_space *space, slang_assembly_local_info *info)
+{
+ slang_assembly_stack_info stk;
+ slang_assembly_flow_control flow;
+
+ if (!ref)
+ {
+ if (!slang_assembly_file_push_label2 (file, slang_asm_local_addr, info->addr_tmp, 4))
+ return 0;
+ }
+
+ if (slang_string_compare ("=", oper) == 0)
+ {
+ if (!_slang_assemble_operation (file, op->children, 1, &flow, space, info, &stk))
+ return 0;
+ if (!_slang_assemble_operation (file, op->children + 1, 0, &flow, space, info, &stk))
+ return 0;
+ if (!_slang_assemble_assignment (file, op->children, space, info))
+ return 0;
+ }
+ else
+ {
+ if (!call_function_name (file, oper, op->children, op->num_children, 1, space, info))
+ return 0;
+ }
+
+ if (!ref)
+ {
+ if (!slang_assembly_file_push (file, slang_asm_addr_copy))
+ return 0;
+ if (!slang_assembly_file_push_label (file, slang_asm_local_free, 4))
+ return 0;
+ if (!dereference (file, op->children, space, info))
+ return 0;
+ }
+
+ return 1;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_assignment.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_assignment.h
new file mode 100755
index 000000000..06972ad17
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_assignment.h
@@ -0,0 +1,45 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#if !defined SLANG_ASSEMBLE_ASSIGNMENT_H
+#define SLANG_ASSEMBLE_ASSIGNMENT_H
+
+#include "slang_assemble.h"
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+int _slang_assemble_assignment (slang_assembly_file *, slang_operation *,
+ slang_assembly_name_space *, slang_assembly_local_info *);
+
+int _slang_assemble_assign (slang_assembly_file *, slang_operation *, const char *, int ref,
+ slang_assembly_name_space *, slang_assembly_local_info *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_conditional.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_conditional.c
new file mode 100755
index 000000000..498938bdd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_conditional.c
@@ -0,0 +1,485 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file slang_assemble_conditional.c
+ * slang condtional expressions assembler
+ * \author Michal Krol
+ */
+
+#include "imports.h"
+#include "slang_utility.h"
+#include "slang_assemble_conditional.h"
+#include "slang_assemble.h"
+
+/* _slang_assemble_logicaland() */
+
+int _slang_assemble_logicaland (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_flow_control *flow, slang_assembly_name_space *space,
+ slang_assembly_local_info *info)
+{
+ /*
+ and:
+ <left-expression>
+ jumpz zero
+ <right-expression>
+ jump end
+ zero:
+ push 0
+ end:
+ */
+
+ unsigned int zero_jump, end_jump;
+ slang_assembly_stack_info stk;
+
+ /* evaluate left expression */
+ if (!_slang_assemble_operation (file, op->children, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: inspect stk */
+
+ /* jump to pushing 0 if not true */
+ zero_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump_if_zero))
+ return 0;
+
+ /* evaluate right expression */
+ if (!_slang_assemble_operation (file, op->children + 1, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: inspect stk */
+
+ /* jump to the end of the expression */
+ end_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump))
+ return 0;
+
+ /* push 0 on stack */
+ file->code[zero_jump].param[0] = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_bool_push))
+ return 0;
+
+ /* the end of the expression */
+ file->code[end_jump].param[0] = file->count;
+
+ return 1;
+}
+
+/* _slang_assemble_logicalor() */
+
+int _slang_assemble_logicalor (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_flow_control *flow, slang_assembly_name_space *space,
+ slang_assembly_local_info *info)
+{
+ /*
+ or:
+ <left-expression>
+ jumpz right
+ push 1
+ jump end
+ right:
+ <right-expression>
+ end:
+ */
+
+ unsigned int right_jump, end_jump;
+ slang_assembly_stack_info stk;
+
+ /* evaluate left expression */
+ if (!_slang_assemble_operation (file, op->children, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: inspect stk */
+
+ /* jump to evaluation of right expression if not true */
+ right_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump_if_zero))
+ return 0;
+
+ /* push 1 on stack */
+ if (!slang_assembly_file_push_literal (file, slang_asm_bool_push, 1.0f))
+ return 0;
+
+ /* jump to the end of the expression */
+ end_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump))
+ return 0;
+
+ /* evaluate right expression */
+ file->code[right_jump].param[0] = file->count;
+ if (!_slang_assemble_operation (file, op->children + 1, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: inspect stk */
+
+ /* the end of the expression */
+ file->code[end_jump].param[0] = file->count;
+
+ return 1;
+}
+
+/* _slang_assemble_select() */
+
+int _slang_assemble_select (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_flow_control *flow, slang_assembly_name_space *space,
+ slang_assembly_local_info *info)
+{
+ /*
+ select:
+ <condition-expression>
+ jumpz false
+ <true-expression>
+ jump end
+ false:
+ <false-expression>
+ end:
+ */
+
+ unsigned int cond_jump, end_jump;
+ slang_assembly_stack_info stk;
+
+ /* execute condition expression */
+ if (!_slang_assemble_operation (file, op->children, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: inspect stk */
+
+ /* jump to false expression if not true */
+ cond_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump_if_zero))
+ return 0;
+
+ /* execute true expression */
+ if (!_slang_assemble_operation (file, op->children + 1, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: inspect stk */
+
+ /* jump to the end of the expression */
+ end_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump))
+ return 0;
+
+ /* resolve false point */
+ file->code[cond_jump].param[0] = file->count;
+
+ /* execute false expression */
+ if (!_slang_assemble_operation (file, op->children + 2, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: inspect stk */
+
+ /* resolve the end of the expression */
+ file->code[end_jump].param[0] = file->count;
+
+ return 1;
+}
+
+/* _slang_assemble_for() */
+
+int _slang_assemble_for (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_flow_control *flow, slang_assembly_name_space *space,
+ slang_assembly_local_info *info)
+{
+ /*
+ for:
+ <init-statement>
+ jump start
+ break:
+ jump end
+ continue:
+ <loop-increment>
+ start:
+ <condition-statement>
+ jumpz end
+ <loop-body>
+ jump continue
+ end:
+ */
+
+ unsigned int start_jump, end_jump, cond_jump;
+ unsigned int break_label, cont_label;
+ slang_assembly_flow_control loop_flow = *flow;
+ slang_assembly_stack_info stk;
+
+ /* execute initialization statement */
+ if (!_slang_assemble_operation (file, op->children, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: pass-in stk to cleanup */
+ if (!_slang_cleanup_stack (file, op->children, 0, space))
+ return 0;
+
+ /* skip the "go to the end of the loop" and loop-increment statements */
+ start_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump))
+ return 0;
+
+ /* go to the end of the loop - break statements are directed here */
+ break_label = file->count;
+ end_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump))
+ return 0;
+
+ /* resolve the beginning of the loop - continue statements are directed here */
+ cont_label = file->count;
+
+ /* execute loop-increment statement */
+ if (!_slang_assemble_operation (file, op->children + 2, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: pass-in stk to cleanup */
+ if (!_slang_cleanup_stack (file, op->children + 2, 0, space))
+ return 0;
+
+ /* resolve the condition point */
+ file->code[start_jump].param[0] = file->count;
+
+ /* execute condition statement */
+ if (!_slang_assemble_operation (file, op->children + 1, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: inspect stk */
+
+ /* jump to the end of the loop if not true */
+ cond_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump_if_zero))
+ return 0;
+
+ /* execute loop body */
+ loop_flow.loop_start = cont_label;
+ loop_flow.loop_end = break_label;
+ if (!_slang_assemble_operation (file, op->children + 3, 0, &loop_flow, space, info, &stk))
+ return 0;
+ /* TODO: pass-in stk to cleanup */
+ if (!_slang_cleanup_stack (file, op->children + 3, 0, space))
+ return 0;
+
+ /* go to the beginning of the loop */
+ if (!slang_assembly_file_push_label (file, slang_asm_jump, cont_label))
+ return 0;
+
+ /* resolve the end of the loop */
+ file->code[end_jump].param[0] = file->count;
+ file->code[cond_jump].param[0] = file->count;
+
+ return 1;
+}
+
+/* _slang_assemble_do() */
+
+int _slang_assemble_do (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_flow_control *flow, slang_assembly_name_space *space,
+ slang_assembly_local_info *info)
+{
+ /*
+ do:
+ jump start
+ break:
+ jump end
+ continue:
+ jump condition
+ start:
+ <loop-body>
+ condition:
+ <condition-statement>
+ jumpz end
+ jump start
+ end:
+ */
+
+ unsigned int skip_jump, end_jump, cont_jump, cond_jump;
+ unsigned int break_label, cont_label;
+ slang_assembly_flow_control loop_flow = *flow;
+ slang_assembly_stack_info stk;
+
+ /* skip the "go to the end of the loop" and "go to condition" statements */
+ skip_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump))
+ return 0;
+
+ /* go to the end of the loop - break statements are directed here */
+ break_label = file->count;
+ end_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump))
+ return 0;
+
+ /* go to condition - continue statements are directed here */
+ cont_label = file->count;
+ cont_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump))
+ return 0;
+
+ /* resolve the beginning of the loop */
+ file->code[skip_jump].param[0] = file->count;
+
+ /* execute loop body */
+ loop_flow.loop_start = cont_label;
+ loop_flow.loop_end = break_label;
+ if (!_slang_assemble_operation (file, op->children, 0, &loop_flow, space, info, &stk))
+ return 0;
+ /* TODO: pass-in stk to cleanup */
+ if (!_slang_cleanup_stack (file, op->children, 0, space))
+ return 0;
+
+ /* resolve condition point */
+ file->code[cont_jump].param[0] = file->count;
+
+ /* execute condition statement */
+ if (!_slang_assemble_operation (file, op->children + 1, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: pass-in stk to cleanup */
+
+ /* jump to the end of the loop if not true */
+ cond_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump_if_zero))
+ return 0;
+
+ /* jump to the beginning of the loop */
+ if (!slang_assembly_file_push_label (file, slang_asm_jump, file->code[skip_jump].param[0]))
+ return 0;
+
+ /* resolve the end of the loop */
+ file->code[end_jump].param[0] = file->count;
+ file->code[cond_jump].param[0] = file->count;
+
+ return 1;
+}
+
+/* _slang_assemble_while() */
+
+int _slang_assemble_while (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_flow_control *flow, slang_assembly_name_space *space,
+ slang_assembly_local_info *info)
+{
+ /*
+ while:
+ jump continue
+ break:
+ jump end
+ continue:
+ <condition-statement>
+ jumpz end
+ <loop-body>
+ jump continue
+ end:
+ */
+
+ unsigned int skip_jump, end_jump, cond_jump;
+ unsigned int break_label;
+ slang_assembly_flow_control loop_flow = *flow;
+ slang_assembly_stack_info stk;
+
+ /* skip the "go to the end of the loop" statement */
+ skip_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump))
+ return 0;
+
+ /* go to the end of the loop - break statements are directed here */
+ break_label = file->count;
+ end_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump))
+ return 0;
+
+ /* resolve the beginning of the loop - continue statements are directed here */
+ file->code[skip_jump].param[0] = file->count;
+
+ /* execute condition statement */
+ if (!_slang_assemble_operation (file, op->children, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: pass-in stk to cleanup */
+
+ /* jump to the end of the loop if not true */
+ cond_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump_if_zero))
+ return 0;
+
+ /* execute loop body */
+ loop_flow.loop_start = file->code[skip_jump].param[0];
+ loop_flow.loop_end = break_label;
+ if (!_slang_assemble_operation (file, op->children + 1, 0, &loop_flow, space, info, &stk))
+ return 0;
+ /* TODO: pass-in stk to cleanup */
+ if (!_slang_cleanup_stack (file, op->children + 1, 0, space))
+ return 0;
+
+ /* jump to the beginning of the loop */
+ if (!slang_assembly_file_push_label (file, slang_asm_jump, file->code[skip_jump].param[0]))
+ return 0;
+
+ /* resolve the end of the loop */
+ file->code[end_jump].param[0] = file->count;
+ file->code[cond_jump].param[0] = file->count;
+
+ return 1;
+}
+
+/* _slang_assemble_if() */
+
+int _slang_assemble_if (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_flow_control *flow, slang_assembly_name_space *space,
+ slang_assembly_local_info *info)
+{
+ /*
+ if:
+ <condition-statement>
+ jumpz else
+ <true-statement>
+ jump end
+ else:
+ <false-statement>
+ end:
+ */
+
+ unsigned int cond_jump, else_jump;
+ slang_assembly_stack_info stk;
+
+ /* execute condition statement */
+ if (!_slang_assemble_operation (file, op->children, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: pass-in stk to cleanup */
+
+ /* jump to false-statement if not true */
+ cond_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump_if_zero))
+ return 0;
+
+ /* execute true-statement */
+ if (!_slang_assemble_operation (file, op->children + 1, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: pass-in stk to cleanup */
+ if (!_slang_cleanup_stack (file, op->children + 1, 0, space))
+ return 0;
+
+ /* skip if-false statement */
+ else_jump = file->count;
+ if (!slang_assembly_file_push (file, slang_asm_jump))
+ return 0;
+
+ /* resolve start of false-statement */
+ file->code[cond_jump].param[0] = file->count;
+
+ /* execute false-statement */
+ if (!_slang_assemble_operation (file, op->children + 2, 0, flow, space, info, &stk))
+ return 0;
+ /* TODO: pass-in stk to cleanup */
+ if (!_slang_cleanup_stack (file, op->children + 2, 0, space))
+ return 0;
+
+ /* resolve end of if-false statement */
+ file->code[else_jump].param[0] = file->count;
+
+ return 1;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_conditional.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_conditional.h
new file mode 100755
index 000000000..f52b4129d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_conditional.h
@@ -0,0 +1,67 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#if !defined SLANG_ASSEMBLE_CONDITIONAL_H
+#define SLANG_ASSEMBLE_CONDITIONAL_H
+
+#include "slang_assemble.h"
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+int _slang_assemble_logicaland (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_flow_control *flow, slang_assembly_name_space *space,
+ slang_assembly_local_info *info);
+
+int _slang_assemble_logicalor (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_flow_control *flow, slang_assembly_name_space *space,
+ slang_assembly_local_info *info);
+
+int _slang_assemble_select (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_flow_control *flow, slang_assembly_name_space *space,
+ slang_assembly_local_info *info);
+
+int _slang_assemble_for (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_flow_control *flow, slang_assembly_name_space *space,
+ slang_assembly_local_info *info);
+
+int _slang_assemble_do (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_flow_control *flow, slang_assembly_name_space *space,
+ slang_assembly_local_info *info);
+
+int _slang_assemble_while (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_flow_control *flow, slang_assembly_name_space *space,
+ slang_assembly_local_info *info);
+
+int _slang_assemble_if (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_flow_control *flow, slang_assembly_name_space *space,
+ slang_assembly_local_info *info);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_constructor.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_constructor.c
new file mode 100755
index 000000000..76a30f6b6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_constructor.c
@@ -0,0 +1,339 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file slang_assemble_constructor.c
+ * slang constructor and vector swizzle assembler
+ * \author Michal Krol
+ */
+
+#include "imports.h"
+#include "slang_utility.h"
+#include "slang_assemble_constructor.h"
+#include "slang_assemble_typeinfo.h"
+#include "slang_storage.h"
+
+/* _slang_is_swizzle() */
+
+int _slang_is_swizzle (const char *field, unsigned int rows, slang_swizzle *swz)
+{
+ unsigned int i;
+ int xyzw = 0, rgba = 0, stpq = 0;
+
+ /* the swizzle can be at most 4-component long */
+ swz->num_components = slang_string_length (field);
+ if (swz->num_components > 4)
+ return 0;
+
+ for (i = 0; i < swz->num_components; i++)
+ {
+ /* mark which swizzle group is used */
+ switch (field[i])
+ {
+ case 'x':
+ case 'y':
+ case 'z':
+ case 'w':
+ xyzw = 1;
+ break;
+ case 'r':
+ case 'g':
+ case 'b':
+ case 'a':
+ rgba = 1;
+ break;
+ case 's':
+ case 't':
+ case 'p':
+ case 'q':
+ stpq = 1;
+ break;
+ default:
+ return 0;
+ }
+
+ /* collect swizzle component */
+ switch (field[i])
+ {
+ case 'x':
+ case 'r':
+ case 's':
+ swz->swizzle[i] = 0;
+ break;
+ case 'y':
+ case 'g':
+ case 't':
+ if (rows < 2)
+ return 0;
+ swz->swizzle[i] = 1;
+ break;
+ case 'z':
+ case 'b':
+ case 'p':
+ if (rows < 3)
+ return 0;
+ swz->swizzle[i] = 2;
+ break;
+ case 'w':
+ case 'a':
+ case 'q':
+ if (rows < 4)
+ return 0;
+ swz->swizzle[i] = 3;
+ break;
+ }
+ }
+
+ /* only one swizzle group can be used */
+ if ((xyzw && rgba) || (xyzw && stpq) || (rgba && stpq))
+ return 0;
+
+ return 1;
+}
+
+/* _slang_is_swizzle_mask() */
+
+int _slang_is_swizzle_mask (const slang_swizzle *swz, unsigned int rows)
+{
+ unsigned int c, i;
+
+ if (swz->num_components > rows)
+ return 0;
+ c = swz->swizzle[0];
+ for (i = 1; i < swz->num_components; i++)
+ {
+ if (swz->swizzle[i] <= c)
+ return 0;
+ c = swz->swizzle[i];
+ }
+ return 1;
+}
+
+/* _slang_multiply_swizzles() */
+
+void _slang_multiply_swizzles (slang_swizzle *dst, const slang_swizzle *left,
+ const slang_swizzle *right)
+{
+ unsigned int i;
+ dst->num_components = right->num_components;
+ for (i = 0; i < right->num_components; i++)
+ dst->swizzle[i] = left->swizzle[right->swizzle[i]];
+}
+
+/* _slang_assemble_constructor() */
+
+static int constructor_aggregate (slang_assembly_file *file, const slang_storage_aggregate *flat,
+ unsigned int *index, slang_operation *op, unsigned int size, slang_assembly_flow_control *flow,
+ slang_assembly_name_space *space, slang_assembly_local_info *info)
+{
+ slang_assembly_typeinfo ti;
+ int result;
+ slang_storage_aggregate agg, flat_agg;
+ slang_assembly_stack_info stk;
+ unsigned int i;
+
+ slang_assembly_typeinfo_construct (&ti);
+ if (!(result = _slang_typeof_operation (op, space, &ti)))
+ goto end1;
+
+ slang_storage_aggregate_construct (&agg);
+ if (!(result = _slang_aggregate_variable (&agg, &ti.spec, NULL, space->funcs, space->structs)))
+ goto end2;
+
+ slang_storage_aggregate_construct (&flat_agg);
+ if (!(result = _slang_flatten_aggregate (&flat_agg, &agg)))
+ goto end;
+
+ if (!(result = _slang_assemble_operation (file, op, 0, flow, space, info, &stk)))
+ goto end;
+
+ for (i = 0; i < flat_agg.count; i++)
+ {
+ const slang_storage_array *arr1 = flat_agg.arrays + i;
+ const slang_storage_array *arr2 = flat->arrays + *index;
+
+ if (arr1->type != arr2->type)
+ {
+ /* TODO: convert (generic) from arr1 to arr2 */
+ }
+ (*index)++;
+ /* TODO: watch the index, if it reaches the size, pop off the stack subsequent values */
+ }
+
+ result = 1;
+end:
+ slang_storage_aggregate_destruct (&flat_agg);
+end2:
+ slang_storage_aggregate_destruct (&agg);
+end1:
+ slang_assembly_typeinfo_destruct (&ti);
+ return result;
+}
+/* XXX: general swizzle! */
+int _slang_assemble_constructor (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_flow_control *flow, slang_assembly_name_space *space,
+ slang_assembly_local_info *info)
+{
+ slang_assembly_typeinfo ti;
+ int result;
+ slang_storage_aggregate agg, flat;
+ unsigned int size, index, i;
+
+ slang_assembly_typeinfo_construct (&ti);
+ if (!(result = _slang_typeof_operation (op, space, &ti)))
+ goto end1;
+
+ slang_storage_aggregate_construct (&agg);
+ if (!(result = _slang_aggregate_variable (&agg, &ti.spec, NULL, space->funcs, space->structs)))
+ goto end2;
+
+ size = _slang_sizeof_aggregate (&agg);
+
+ slang_storage_aggregate_construct (&flat);
+ if (!(result = _slang_flatten_aggregate (&flat, &agg)))
+ goto end;
+
+ index = 0;
+ for (i = 0; i < op->num_children; i++)
+ {
+ if (!(result = constructor_aggregate (file, &flat, &index, op->children + i, size, flow,
+ space, info)))
+ goto end;
+ /* TODO: watch the index, if it reaches the size, raise an error */
+ }
+
+ result = 1;
+end:
+ slang_storage_aggregate_destruct (&flat);
+end2:
+ slang_storage_aggregate_destruct (&agg);
+end1:
+ slang_assembly_typeinfo_destruct (&ti);
+ return result;
+}
+
+/* _slang_assemble_constructor_from_swizzle() */
+/* XXX: wrong */
+int _slang_assemble_constructor_from_swizzle (slang_assembly_file *file, const slang_swizzle *swz,
+ slang_type_specifier *spec, slang_type_specifier *master_spec, slang_assembly_local_info *info)
+{
+ unsigned int master_rows, i;
+ switch (master_spec->type)
+ {
+ case slang_spec_bool:
+ case slang_spec_int:
+ case slang_spec_float:
+ master_rows = 1;
+ break;
+ case slang_spec_bvec2:
+ case slang_spec_ivec2:
+ case slang_spec_vec2:
+ master_rows = 2;
+ break;
+ case slang_spec_bvec3:
+ case slang_spec_ivec3:
+ case slang_spec_vec3:
+ master_rows = 3;
+ break;
+ case slang_spec_bvec4:
+ case slang_spec_ivec4:
+ case slang_spec_vec4:
+ master_rows = 4;
+ break;
+ default:
+ break;
+ }
+ for (i = 0; i < master_rows; i++)
+ {
+ switch (master_spec->type)
+ {
+ case slang_spec_bool:
+ case slang_spec_bvec2:
+ case slang_spec_bvec3:
+ case slang_spec_bvec4:
+ if (!slang_assembly_file_push_label2 (file, slang_asm_bool_copy, (master_rows - i) * 4,
+ i * 4))
+ return 0;
+ break;
+ case slang_spec_int:
+ case slang_spec_ivec2:
+ case slang_spec_ivec3:
+ case slang_spec_ivec4:
+ if (!slang_assembly_file_push_label2 (file, slang_asm_int_copy, (master_rows - i) * 4,
+ i * 4))
+ return 0;
+ break;
+ case slang_spec_float:
+ case slang_spec_vec2:
+ case slang_spec_vec3:
+ case slang_spec_vec4:
+ if (!slang_assembly_file_push_label2 (file, slang_asm_float_copy,
+ (master_rows - i) * 4, i * 4))
+ return 0;
+ break;
+ default:
+ break;
+ }
+ }
+ if (!slang_assembly_file_push_label (file, slang_asm_local_free, 4))
+ return 0;
+ for (i = swz->num_components; i > 0; i--)
+ {
+ unsigned int n = i - 1;
+ if (!slang_assembly_file_push_label2 (file, slang_asm_local_addr, info->swizzle_tmp, 16))
+ return 0;
+ if (!slang_assembly_file_push_label (file, slang_asm_addr_push, swz->swizzle[n] * 4))
+ return 0;
+ if (!slang_assembly_file_push (file, slang_asm_addr_add))
+ return 0;
+ switch (master_spec->type)
+ {
+ case slang_spec_bool:
+ case slang_spec_bvec2:
+ case slang_spec_bvec3:
+ case slang_spec_bvec4:
+ if (!slang_assembly_file_push (file, slang_asm_bool_deref))
+ return 0;
+ break;
+ case slang_spec_int:
+ case slang_spec_ivec2:
+ case slang_spec_ivec3:
+ case slang_spec_ivec4:
+ if (!slang_assembly_file_push (file, slang_asm_int_deref))
+ return 0;
+ break;
+ case slang_spec_float:
+ case slang_spec_vec2:
+ case slang_spec_vec3:
+ case slang_spec_vec4:
+ if (!slang_assembly_file_push (file, slang_asm_float_deref))
+ return 0;
+ break;
+ default:
+ break;
+ }
+ }
+ return 1;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_constructor.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_constructor.h
new file mode 100755
index 000000000..f8a0fead3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_constructor.h
@@ -0,0 +1,80 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#if !defined SLANG_ASSEMBLE_CONSTRUCTOR_H
+#define SLANG_ASSEMBLE_CONSTRUCTOR_H
+
+#include "slang_assemble.h"
+#include "slang_compile.h"
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+/*
+ holds a complete information about vector swizzle - the <swizzle> array contains
+ vector component sources indices, where 0 is "x", 1 is "y", ...
+ example: "xwz" --> { 3, { 0, 3, 2, n/u } }
+*/
+typedef struct slang_swizzle_
+{
+ unsigned int num_components;
+ unsigned int swizzle[4];
+} slang_swizzle;
+
+/*
+ checks if a field selector is a general swizzle (an r-value swizzle with replicated
+ components or an l-value swizzle mask) for a vector
+ returns 1 if this is the case, <swz> is filled with swizzle information
+ returns 0 otherwise
+*/
+int _slang_is_swizzle (const char *field, unsigned int rows, slang_swizzle *swz);
+
+/*
+ checks if a general swizzle is an l-value swizzle - these swizzles do not have
+ duplicated fields and they are specified in order
+ returns 1 if this is a swizzle mask
+ returns 0 otherwise
+*/
+int _slang_is_swizzle_mask (const slang_swizzle *swz, unsigned int rows);
+
+/*
+ combines two swizzles to form single swizzle
+ example: "wzyx.yx" --> "zw"
+*/
+void _slang_multiply_swizzles (slang_swizzle *, const slang_swizzle *, const slang_swizzle *);
+
+int _slang_assemble_constructor (slang_assembly_file *file, slang_operation *op,
+ slang_assembly_flow_control *flow, slang_assembly_name_space *space,
+ slang_assembly_local_info *info);
+
+int _slang_assemble_constructor_from_swizzle (slang_assembly_file *file, const slang_swizzle *swz,
+ slang_type_specifier *spec, slang_type_specifier *master_spec, slang_assembly_local_info *info);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_typeinfo.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_typeinfo.c
new file mode 100755
index 000000000..ce78f66eb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_typeinfo.c
@@ -0,0 +1,430 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file slang_assemble_typeinfo.c
+ * slang type info
+ * \author Michal Krol
+ */
+
+#include "imports.h"
+#include "slang_utility.h"
+#include "slang_assemble_typeinfo.h"
+
+/* slang_assembly_typeinfo */
+
+void slang_assembly_typeinfo_construct (slang_assembly_typeinfo *ti)
+{
+ slang_type_specifier_construct (&ti->spec);
+}
+
+void slang_assembly_typeinfo_destruct (slang_assembly_typeinfo *ti)
+{
+ slang_type_specifier_destruct (&ti->spec);
+}
+
+/* _slang_typeof_operation() */
+
+int _slang_typeof_operation (slang_operation *op, slang_assembly_name_space *space,
+ slang_assembly_typeinfo *ti)
+{
+ ti->can_be_referenced = 0;
+ ti->is_swizzled = 0;
+
+ switch (op->type)
+ {
+ case slang_oper_block_no_new_scope:
+ case slang_oper_block_new_scope:
+ case slang_oper_variable_decl:
+ case slang_oper_asm:
+ case slang_oper_break:
+ case slang_oper_continue:
+ case slang_oper_discard:
+ case slang_oper_return:
+ case slang_oper_if:
+ case slang_oper_while:
+ case slang_oper_do:
+ case slang_oper_for:
+ case slang_oper_void:
+ ti->spec.type = slang_spec_void;
+ break;
+ case slang_oper_expression:
+ case slang_oper_assign:
+ case slang_oper_addassign:
+ case slang_oper_subassign:
+ case slang_oper_mulassign:
+ case slang_oper_divassign:
+ case slang_oper_preincrement:
+ case slang_oper_predecrement:
+ if (!_slang_typeof_operation (op->children, space, ti))
+ return 0;
+ break;
+ case slang_oper_literal_bool:
+ case slang_oper_logicalor:
+ case slang_oper_logicalxor:
+ case slang_oper_logicaland:
+ case slang_oper_equal:
+ case slang_oper_notequal:
+ case slang_oper_less:
+ case slang_oper_greater:
+ case slang_oper_lessequal:
+ case slang_oper_greaterequal:
+ case slang_oper_not:
+ ti->spec.type = slang_spec_bool;
+ break;
+ case slang_oper_literal_int:
+ ti->spec.type = slang_spec_int;
+ break;
+ case slang_oper_literal_float:
+ ti->spec.type = slang_spec_float;
+ break;
+ case slang_oper_identifier:
+ {
+ slang_variable *var;
+
+ var = _slang_locate_variable (op->locals, op->identifier, 1);
+ if (var == NULL)
+ return 0;
+ if (!slang_type_specifier_copy (&ti->spec, &var->type.specifier))
+ return 0;
+ ti->can_be_referenced = 1;
+ }
+ break;
+ case slang_oper_sequence:
+ /* TODO: check [0] and [1] if they match */
+ if (!_slang_typeof_operation (op->children + 1, space, ti))
+ return 0;
+ ti->can_be_referenced = 0;
+ ti->is_swizzled = 0;
+ break;
+ /*case slang_oper_modassign:*/
+ /*case slang_oper_lshassign:*/
+ /*case slang_oper_rshassign:*/
+ /*case slang_oper_orassign:*/
+ /*case slang_oper_xorassign:*/
+ /*case slang_oper_andassign:*/
+ case slang_oper_select:
+ /* TODO: check [1] and [2] if they match */
+ if (!_slang_typeof_operation (op->children + 1, space, ti))
+ return 0;
+ ti->can_be_referenced = 0;
+ ti->is_swizzled = 0;
+ break;
+ /*case slang_oper_bitor:*/
+ /*case slang_oper_bitxor:*/
+ /*case slang_oper_bitand:*/
+ /*case slang_oper_lshift:*/
+ /*case slang_oper_rshift:*/
+ case slang_oper_add:
+ {
+ int exists;
+ if (!_slang_typeof_function ("+", op->children, 2, space, &ti->spec, &exists))
+ return 0;
+ if (!exists)
+ return 0;
+ }
+ break;
+ case slang_oper_subtract:
+ {
+ int exists;
+ if (!_slang_typeof_function ("-", op->children, 2, space, &ti->spec, &exists))
+ return 0;
+ if (!exists)
+ return 0;
+ }
+ break;
+ case slang_oper_multiply:
+ {
+ int exists;
+ if (!_slang_typeof_function ("*", op->children, 2, space, &ti->spec, &exists))
+ return 0;
+ if (!exists)
+ return 0;
+ }
+ break;
+ case slang_oper_divide:
+ {
+ int exists;
+ if (!_slang_typeof_function ("/", op->children, 2, space, &ti->spec, &exists))
+ return 0;
+ if (!exists)
+ return 0;
+ }
+ break;
+ /*case slang_oper_modulus:*/
+ case slang_oper_plus:
+ {
+ int exists;
+ if (!_slang_typeof_function ("+", op->children, 1, space, &ti->spec, &exists))
+ return 0;
+ if (!exists)
+ return 0;
+ }
+ break;
+ case slang_oper_minus:
+ {
+ int exists;
+ if (!_slang_typeof_function ("-", op->children, 1, space, &ti->spec, &exists))
+ return 0;
+ if (!exists)
+ return 0;
+ }
+ break;
+ /*case slang_oper_complement:*/
+ case slang_oper_subscript:
+ {
+ slang_assembly_typeinfo _ti;
+ slang_assembly_typeinfo_construct (&_ti);
+ if (!_slang_typeof_operation (op->children, space, &_ti))
+ {
+ slang_assembly_typeinfo_destruct (&_ti);
+ return 0;
+ }
+ ti->can_be_referenced = _ti.can_be_referenced;
+ switch (_ti.spec.type)
+ {
+ case slang_spec_bvec2:
+ case slang_spec_bvec3:
+ case slang_spec_bvec4:
+ ti->spec.type = slang_spec_bool;
+ break;
+ case slang_spec_ivec2:
+ case slang_spec_ivec3:
+ case slang_spec_ivec4:
+ ti->spec.type = slang_spec_int;
+ break;
+ case slang_spec_vec2:
+ case slang_spec_vec3:
+ case slang_spec_vec4:
+ ti->spec.type = slang_spec_float;
+ break;
+ case slang_spec_mat2:
+ ti->spec.type = slang_spec_vec2;
+ break;
+ case slang_spec_mat3:
+ ti->spec.type = slang_spec_vec3;
+ break;
+ case slang_spec_mat4:
+ ti->spec.type = slang_spec_vec4;
+ break;
+ case slang_spec_array:
+ if (!slang_type_specifier_copy (&ti->spec, _ti.spec._array))
+ {
+ slang_assembly_typeinfo_destruct (&_ti);
+ return 0;
+ }
+ break;
+ default:
+ slang_assembly_typeinfo_destruct (&_ti);
+ return 0;
+ }
+ slang_assembly_typeinfo_destruct (&_ti);
+ }
+ break;
+ case slang_oper_call:
+ {
+ int exists;
+ if (!_slang_typeof_function (op->identifier, op->children, op->num_children, space,
+ &ti->spec, &exists))
+ return 0;
+ if (!exists)
+ {
+ slang_struct *s = slang_struct_scope_find (space->structs, op->identifier, 1);
+ if (s != NULL)
+ {
+ ti->spec.type = slang_spec_struct;
+ ti->spec._struct = (slang_struct *) slang_alloc_malloc (sizeof (slang_struct));
+ if (ti->spec._struct == NULL)
+ return 0;
+ if (!slang_struct_construct_a (ti->spec._struct))
+ {
+ slang_alloc_free (ti->spec._struct);
+ ti->spec._struct = NULL;
+ return 0;
+ }
+ if (!slang_struct_copy (ti->spec._struct, s))
+ return 0;
+ }
+ else
+ {
+ slang_type_specifier_type type = slang_type_specifier_type_from_string (
+ op->identifier);
+ if (type == slang_spec_void)
+ return 0;
+ ti->spec.type = type;
+ }
+ }
+ }
+ break;
+ case slang_oper_field:
+ {
+ slang_assembly_typeinfo _ti;
+ slang_assembly_typeinfo_construct (&_ti);
+ if (!_slang_typeof_operation (op->children, space, &_ti))
+ {
+ slang_assembly_typeinfo_destruct (&_ti);
+ return 0;
+ }
+ if (_ti.spec.type == slang_spec_struct)
+ {
+ slang_variable *field = _slang_locate_variable (_ti.spec._struct->fields,
+ op->identifier, 0);
+ if (field == NULL)
+ {
+ slang_assembly_typeinfo_destruct (&_ti);
+ return 0;
+ }
+ if (!slang_type_specifier_copy (&ti->spec, &field->type.specifier))
+ {
+ slang_assembly_typeinfo_destruct (&_ti);
+ return 0;
+ }
+ }
+ else
+ {
+ unsigned int rows;
+ switch (_ti.spec.type)
+ {
+ case slang_spec_vec2:
+ case slang_spec_ivec2:
+ case slang_spec_bvec2:
+ rows = 2;
+ break;
+ case slang_spec_vec3:
+ case slang_spec_ivec3:
+ case slang_spec_bvec3:
+ rows = 3;
+ break;
+ case slang_spec_vec4:
+ case slang_spec_ivec4:
+ case slang_spec_bvec4:
+ rows = 4;
+ break;
+ default:
+ slang_assembly_typeinfo_destruct (&_ti);
+ return 0;
+ }
+ if (!_slang_is_swizzle (op->identifier, rows, &ti->swz))
+ return 0;
+ ti->is_swizzled = 1;
+ ti->can_be_referenced = _ti.can_be_referenced && _slang_is_swizzle_mask (&ti->swz,
+ rows);
+ if (_ti.is_swizzled)
+ {
+ slang_swizzle swz;
+ _slang_multiply_swizzles (&swz, &_ti.swz, &ti->swz);
+ ti->swz = swz;
+ }
+ switch (_ti.spec.type)
+ {
+ case slang_spec_vec2:
+ case slang_spec_vec3:
+ case slang_spec_vec4:
+ switch (ti->swz.num_components)
+ {
+ case 1:
+ ti->spec.type = slang_spec_float;
+ break;
+ case 2:
+ ti->spec.type = slang_spec_vec2;
+ break;
+ case 3:
+ ti->spec.type = slang_spec_vec3;
+ break;
+ case 4:
+ ti->spec.type = slang_spec_vec4;
+ break;
+ }
+ break;
+ case slang_spec_ivec2:
+ case slang_spec_ivec3:
+ case slang_spec_ivec4:
+ switch (ti->swz.num_components)
+ {
+ case 1:
+ ti->spec.type = slang_spec_int;
+ break;
+ case 2:
+ ti->spec.type = slang_spec_ivec2;
+ break;
+ case 3:
+ ti->spec.type = slang_spec_ivec3;
+ break;
+ case 4:
+ ti->spec.type = slang_spec_ivec4;
+ break;
+ }
+ break;
+ case slang_spec_bvec2:
+ case slang_spec_bvec3:
+ case slang_spec_bvec4:
+ switch (ti->swz.num_components)
+ {
+ case 1:
+ ti->spec.type = slang_spec_bool;
+ break;
+ case 2:
+ ti->spec.type = slang_spec_bvec2;
+ break;
+ case 3:
+ ti->spec.type = slang_spec_bvec3;
+ break;
+ case 4:
+ ti->spec.type = slang_spec_bvec4;
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ slang_assembly_typeinfo_destruct (&_ti);
+ return 1;
+ }
+ break;
+ case slang_oper_postincrement:
+ case slang_oper_postdecrement:
+ if (!_slang_typeof_operation (op->children, space, ti))
+ return 0;
+ ti->can_be_referenced = 0;
+ ti->is_swizzled = 0;
+ break;
+ default:
+ return 0;
+ }
+ return 1;
+}
+
+/* _slang_typeof_function() */
+
+int _slang_typeof_function (const char *name, slang_operation *params, unsigned int num_params,
+ slang_assembly_name_space *space, slang_type_specifier *spec, int *exists)
+{
+ slang_function *fun = _slang_locate_function (name, params, num_params, space);
+ *exists = fun != NULL;
+ if (fun == NULL)
+ return 1;
+ return slang_type_specifier_copy (spec, &fun->header.type.specifier);
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_typeinfo.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_typeinfo.h
new file mode 100755
index 000000000..1c1839457
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_assemble_typeinfo.h
@@ -0,0 +1,67 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#if !defined SLANG_ASSEMBLE_TYPEINFO_H
+#define SLANG_ASSEMBLE_TYPEINFO_H
+
+#include "slang_assemble_constructor.h"
+#include "slang_compile.h"
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+typedef struct slang_assembly_typeinfo_
+{
+ int can_be_referenced;
+ int is_swizzled;
+ slang_swizzle swz;
+ slang_type_specifier spec;
+} slang_assembly_typeinfo;
+
+void slang_assembly_typeinfo_construct (slang_assembly_typeinfo *);
+void slang_assembly_typeinfo_destruct (slang_assembly_typeinfo *);
+
+/*
+ retrieves type information about an operation
+ returns 1 on success
+ returns 0 otherwise
+*/
+int _slang_typeof_operation (slang_operation *, slang_assembly_name_space *,
+ slang_assembly_typeinfo *);
+
+/*
+ retrieves type of a function prototype, if one exists
+ returns 1 on success, even if the function was not found
+ returns 0 otherwise
+*/
+int _slang_typeof_function (const char *name, slang_operation *params, unsigned int num_params,
+ slang_assembly_name_space *space, slang_type_specifier *spec, int *exists);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_compile.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_compile.c
new file mode 100644
index 000000000..2377173cf
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_compile.c
@@ -0,0 +1,2369 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file slang_compile.c
+ * slang front-end compiler
+ * \author Michal Krol
+ */
+
+#include "imports.h"
+#include "grammar_mesa.h"
+#include "slang_utility.h"
+#include "slang_compile.h"
+#include "slang_preprocess.h"
+#include "slang_storage.h"
+#include "slang_assemble.h"
+#include "slang_execute.h"
+
+/*
+ This is a straightforward implementation of the slang front-end compiler.
+ Lots of error-checking functionality is missing but every well-formed shader source should
+ compile successfully and execute as expected. However, some semantically ill-formed shaders
+ may be accepted resulting in undefined behaviour.
+*/
+
+static void slang_variable_construct (slang_variable *);
+static int slang_variable_copy (slang_variable *, const slang_variable *);
+static void slang_struct_destruct (slang_struct *);
+static int slang_struct_equal (const slang_struct *, const slang_struct *);
+static void slang_variable_destruct (slang_variable *);
+
+/* slang_type_specifier_type */
+
+/* these must match with slang_type_specifier_type enum */
+static const char *type_specifier_type_names[] = {
+ "void",
+ "bool",
+ "bvec2",
+ "bvec3",
+ "bvec4",
+ "int",
+ "ivec2",
+ "ivec3",
+ "ivec4",
+ "float",
+ "vec2",
+ "vec3",
+ "vec4",
+ "mat2",
+ "mat3",
+ "mat4",
+ "sampler1D",
+ "sampler2D",
+ "sampler3D",
+ "samplerCube",
+ "sampler1DShadow",
+ "sampler2DShadow",
+ NULL
+};
+
+slang_type_specifier_type slang_type_specifier_type_from_string (const char *name)
+{
+ const char **p = type_specifier_type_names;
+ while (*p != NULL)
+ {
+ if (slang_string_compare (*p, name) == 0)
+ return (slang_type_specifier_type) (p - type_specifier_type_names);
+ p++;
+ }
+ return slang_spec_void;
+}
+
+/* slang_type_specifier */
+
+void slang_type_specifier_construct (slang_type_specifier *spec)
+{
+ spec->type = slang_spec_void;
+ spec->_struct = NULL;
+ spec->_array = NULL;
+}
+
+void slang_type_specifier_destruct (slang_type_specifier *spec)
+{
+ if (spec->_struct != NULL)
+ {
+ slang_struct_destruct (spec->_struct);
+ slang_alloc_free (spec->_struct);
+ }
+ if (spec->_array != NULL)
+ {
+ slang_type_specifier_destruct (spec->_array);
+ slang_alloc_free (spec->_array);
+ }
+}
+
+int slang_type_specifier_copy (slang_type_specifier *x, const slang_type_specifier *y)
+{
+ slang_type_specifier_destruct (x);
+ slang_type_specifier_construct (x);
+ x->type = y->type;
+ if (x->type == slang_spec_struct)
+ {
+ x->_struct = (slang_struct *) slang_alloc_malloc (sizeof (slang_struct));
+ if (x->_struct == NULL)
+ return 0;
+ if (!slang_struct_construct_a (x->_struct))
+ {
+ slang_alloc_free (x->_struct);
+ x->_struct = NULL;
+ return 0;
+ }
+ return slang_struct_copy (x->_struct, y->_struct);
+ }
+ if (x->type == slang_spec_array)
+ {
+ x->_array = (slang_type_specifier *) slang_alloc_malloc (sizeof (slang_type_specifier));
+ if (x->_array == NULL)
+ return 0;
+ slang_type_specifier_construct (x->_array);
+ return slang_type_specifier_copy (x->_array, y->_array);
+ }
+ return 1;
+}
+
+int slang_type_specifier_equal (const slang_type_specifier *x, const slang_type_specifier *y)
+{
+ if (x->type != y->type)
+ return 0;
+ if (x->type == slang_spec_struct)
+ return slang_struct_equal (x->_struct, y->_struct);
+ if (x->type == slang_spec_array)
+ return slang_type_specifier_equal (x->_array, y->_array);
+ return 1;
+}
+
+/* slang_fully_specified_type */
+
+static void slang_fully_specified_type_construct (slang_fully_specified_type *type)
+{
+ type->qualifier = slang_qual_none;
+ slang_type_specifier_construct (&type->specifier);
+}
+
+static void slang_fully_specified_type_destruct (slang_fully_specified_type *type)
+{
+ slang_type_specifier_destruct (&type->specifier);
+}
+
+static int slang_fully_specified_type_copy (slang_fully_specified_type *x,
+ const slang_fully_specified_type *y)
+{
+ slang_fully_specified_type_construct (x);
+ slang_fully_specified_type_destruct (x);
+ x->qualifier = y->qualifier;
+ return slang_type_specifier_copy (&x->specifier, &y->specifier);
+}
+
+/* slang_variable_scope */
+
+static void slang_variable_scope_construct (slang_variable_scope *scope)
+{
+ scope->variables = NULL;
+ scope->num_variables = 0;
+ scope->outer_scope = NULL;
+}
+
+static void slang_variable_scope_destruct (slang_variable_scope *scope)
+{
+ unsigned int i;
+ for (i = 0; i < scope->num_variables; i++)
+ slang_variable_destruct (scope->variables + i);
+ slang_alloc_free (scope->variables);
+}
+
+static int slang_variable_scope_copy (slang_variable_scope *x, const slang_variable_scope *y)
+{
+ unsigned int i;
+ slang_variable_scope_destruct (x);
+ slang_variable_scope_construct (x);
+ x->variables = (slang_variable *) slang_alloc_malloc (y->num_variables * sizeof (
+ slang_variable));
+ if (x->variables == NULL)
+ return 0;
+ x->num_variables = y->num_variables;
+ for (i = 0; i < x->num_variables; i++)
+ slang_variable_construct (x->variables + i);
+ for (i = 0; i < x->num_variables; i++)
+ if (!slang_variable_copy (x->variables + i, y->variables + i))
+ return 0;
+ x->outer_scope = y->outer_scope;
+ return 1;
+}
+
+/* slang_operation */
+
+int slang_operation_construct_a (slang_operation *oper)
+{
+ oper->type = slang_oper_none;
+ oper->children = NULL;
+ oper->num_children = 0;
+ oper->literal = (float) 0;
+ oper->identifier = NULL;
+ oper->locals = (slang_variable_scope *) slang_alloc_malloc (sizeof (slang_variable_scope));
+ if (oper->locals == NULL)
+ return 0;
+ slang_variable_scope_construct (oper->locals);
+ return 1;
+}
+
+void slang_operation_destruct (slang_operation *oper)
+{
+ unsigned int i;
+ for (i = 0; i < oper->num_children; i++)
+ slang_operation_destruct (oper->children + i);
+ slang_alloc_free (oper->children);
+ slang_alloc_free (oper->identifier);
+ slang_variable_scope_destruct (oper->locals);
+ slang_alloc_free (oper->locals);
+}
+
+static int slang_operation_copy (slang_operation *x, const slang_operation *y)
+{
+ unsigned int i;
+ for (i = 0; i < x->num_children; i++)
+ slang_operation_destruct (x->children + i);
+ slang_alloc_free (x->children);
+ x->num_children = 0;
+ slang_alloc_free (x->identifier);
+ x->identifier = NULL;
+ slang_variable_scope_destruct (x->locals);
+ slang_variable_scope_construct (x->locals);
+
+ x->type = y->type;
+ x->children = (slang_operation *) slang_alloc_malloc (y->num_children * sizeof (
+ slang_operation));
+ if (x->children == NULL)
+ return 0;
+ for (i = 0; i < y->num_children; i++)
+ if (!slang_operation_construct_a (x->children + i))
+ {
+ unsigned int j;
+ for (j = 0; j < i; j++)
+ slang_operation_destruct (x->children + j);
+ slang_alloc_free (x->children);
+ x->children = NULL;
+ return 0;
+ }
+ x->num_children = y->num_children;
+ for (i = 0; i < x->num_children; i++)
+ if (!slang_operation_copy (x->children + i, y->children + i))
+ return 0;
+ x->literal = y->literal;
+ if (y->identifier != NULL)
+ {
+ x->identifier = slang_string_duplicate (y->identifier);
+ if (x->identifier == NULL)
+ return 0;
+ }
+ if (!slang_variable_scope_copy (x->locals, y->locals))
+ return 0;
+ return 1;
+}
+
+/* slang_variable */
+
+static void slang_variable_construct (slang_variable *var)
+{
+ slang_fully_specified_type_construct (&var->type);
+ var->name = NULL;
+ var->array_size = NULL;
+ var->initializer = NULL;
+ var->address = ~0;
+}
+
+static void slang_variable_destruct (slang_variable *var)
+{
+ slang_fully_specified_type_destruct (&var->type);
+ slang_alloc_free (var->name);
+ if (var->array_size != NULL)
+ {
+ slang_operation_destruct (var->array_size);
+ slang_alloc_free (var->array_size);
+ }
+ if (var->initializer != NULL)
+ {
+ slang_operation_destruct (var->initializer);
+ slang_alloc_free (var->initializer);
+ }
+}
+
+static int slang_variable_copy (slang_variable *x, const slang_variable *y)
+{
+ slang_variable_destruct (x);
+ slang_variable_construct (x);
+ if (!slang_fully_specified_type_copy (&x->type, &y->type))
+ return 0;
+ if (y->name != NULL)
+ {
+ x->name = slang_string_duplicate (y->name);
+ if (x->name == NULL)
+ return 0;
+ }
+ if (y->array_size != NULL)
+ {
+ x->array_size = (slang_operation *) slang_alloc_malloc (sizeof (slang_operation));
+ if (x->array_size == NULL)
+ return 0;
+ if (!slang_operation_construct_a (x->array_size))
+ {
+ slang_alloc_free (x->array_size);
+ x->array_size = NULL;
+ return 0;
+ }
+ if (!slang_operation_copy (x->array_size, y->array_size))
+ return 0;
+ }
+ if (y->initializer != NULL)
+ {
+ x->initializer = (slang_operation *) slang_alloc_malloc (sizeof (slang_operation));
+ if (x->initializer == NULL)
+ return 0;
+ if (!slang_operation_construct_a (x->initializer))
+ {
+ slang_alloc_free (x->initializer);
+ x->initializer = NULL;
+ return 0;
+ }
+ if (!slang_operation_copy (x->initializer, y->initializer))
+ return 0;
+ }
+ return 1;
+}
+
+slang_variable *_slang_locate_variable (slang_variable_scope *scope, const char *name, int all)
+{
+ unsigned int i;
+ for (i = 0; i < scope->num_variables; i++)
+ if (slang_string_compare (name, scope->variables[i].name) == 0)
+ return scope->variables + i;
+ if (all && scope->outer_scope != NULL)
+ return _slang_locate_variable (scope->outer_scope, name, 1);
+ return NULL;
+}
+
+/* slang_struct_scope */
+
+static void slang_struct_scope_construct (slang_struct_scope *scope)
+{
+ scope->structs = NULL;
+ scope->num_structs = 0;
+ scope->outer_scope = NULL;
+}
+
+static void slang_struct_scope_destruct (slang_struct_scope *scope)
+{
+ unsigned int i;
+ for (i = 0; i < scope->num_structs; i++)
+ slang_struct_destruct (scope->structs + i);
+ slang_alloc_free (scope->structs);
+}
+
+static int slang_struct_scope_copy (slang_struct_scope *x, const slang_struct_scope *y)
+{
+ unsigned int i;
+ slang_struct_scope_destruct (x);
+ slang_struct_scope_construct (x);
+ x->structs = (slang_struct *) slang_alloc_malloc (y->num_structs * sizeof (slang_struct));
+ if (x->structs == NULL)
+ return 0;
+ x->num_structs = y->num_structs;
+ for (i = 0; i < x->num_structs; i++)
+ {
+ unsigned int j;
+ if (!slang_struct_construct_a (x->structs + i))
+ {
+ for (j = 0; j < i; j++)
+ slang_struct_destruct (x->structs + j);
+ slang_alloc_free (x->structs);
+ x->structs = NULL;
+ return 0;
+ }
+ }
+ for (i = 0; i < x->num_structs; i++)
+ if (!slang_struct_copy (x->structs + i, y->structs + i))
+ return 0;
+ x->outer_scope = y->outer_scope;
+ return 1;
+}
+
+slang_struct *slang_struct_scope_find (slang_struct_scope *stru, const char *name, int all_scopes)
+{
+ unsigned int i;
+ for (i = 0; i < stru->num_structs; i++)
+ if (slang_string_compare (name, stru->structs[i].name) == 0)
+ return stru->structs + i;
+ if (all_scopes && stru->outer_scope != NULL)
+ return slang_struct_scope_find (stru->outer_scope, name, 1);
+ return NULL;
+}
+
+/* slang_struct */
+
+int slang_struct_construct_a (slang_struct *stru)
+{
+ stru->name = NULL;
+ stru->fields = (slang_variable_scope *) slang_alloc_malloc (sizeof (slang_variable_scope));
+ if (stru->fields == NULL)
+ return 0;
+ slang_variable_scope_construct (stru->fields);
+ stru->structs = (slang_struct_scope *) slang_alloc_malloc (sizeof (slang_struct_scope));
+ if (stru->structs == NULL)
+ {
+ slang_variable_scope_destruct (stru->fields);
+ slang_alloc_free (stru->fields);
+ return 0;
+ }
+ slang_struct_scope_construct (stru->structs);
+ return 1;
+}
+
+static void slang_struct_destruct (slang_struct *stru)
+{
+ slang_alloc_free (stru->name);
+ slang_variable_scope_destruct (stru->fields);
+ slang_alloc_free (stru->fields);
+ slang_struct_scope_destruct (stru->structs);
+ slang_alloc_free (stru->structs);
+}
+
+int slang_struct_copy (slang_struct *x, const slang_struct *y)
+{
+ slang_alloc_free (x->name);
+ x->name = NULL;
+ slang_variable_scope_destruct (x->fields);
+ slang_variable_scope_construct (x->fields);
+ slang_struct_scope_destruct (x->structs);
+ slang_struct_scope_construct (x->structs);
+ if (y->name != NULL)
+ {
+ x->name = slang_string_duplicate (y->name);
+ if (x->name == NULL)
+ return 0;
+ }
+ if (!slang_variable_scope_copy (x->fields, y->fields))
+ return 0;
+ if (!slang_struct_scope_copy (x->structs, y->structs))
+ return 0;
+ return 1;
+}
+
+static int slang_struct_equal (const slang_struct *x, const slang_struct *y)
+{
+ unsigned int i;
+ if (x->fields->num_variables != y->fields->num_variables)
+ return 0;
+ for (i = 0; i < x->fields->num_variables; i++)
+ {
+ slang_variable *varx = x->fields->variables + i;
+ slang_variable *vary = y->fields->variables + i;
+ if (slang_string_compare (varx->name, vary->name) != 0)
+ return 0;
+ if (!slang_type_specifier_equal (&varx->type.specifier, &vary->type.specifier))
+ return 0;
+ if (varx->type.specifier.type == slang_spec_array)
+ {
+ /* TODO compare array sizes */
+ }
+ }
+ return 1;
+}
+
+/* slang_function */
+/* XXX mem! */
+static void slang_function_construct (slang_function *func)
+{
+ func->kind = slang_func_ordinary;
+ slang_variable_construct (&func->header);
+ func->parameters = (slang_variable_scope *) slang_alloc_malloc (sizeof (slang_variable_scope));
+ slang_variable_scope_construct (func->parameters);
+ func->body = NULL;
+ func->address = ~0;
+}
+
+static void slang_function_destruct (slang_function *func)
+{
+ slang_variable_destruct (&func->header);
+ slang_variable_scope_destruct (func->parameters);
+ slang_alloc_free (func->parameters);
+ if (func->body != NULL)
+ {
+ slang_operation_destruct (func->body);
+ slang_alloc_free (func->body);
+ }
+}
+
+/* slang_function_scope */
+
+static void slang_function_scope_construct (slang_function_scope *scope)
+{
+ scope->functions = NULL;
+ scope->num_functions = 0;
+ scope->outer_scope = NULL;
+}
+
+static void slang_function_scope_destruct (slang_function_scope *scope)
+{
+ unsigned int i;
+ for (i = 0; i < scope->num_functions; i++)
+ slang_function_destruct (scope->functions + i);
+ slang_alloc_free (scope->functions);
+}
+
+static int slang_function_scope_find_by_name (slang_function_scope *funcs, const char *name,
+ int all_scopes)
+{
+ unsigned int i;
+ for (i = 0; i < funcs->num_functions; i++)
+ if (slang_string_compare (name, funcs->functions[i].header.name) == 0)
+ return 1;
+ if (all_scopes && funcs->outer_scope != NULL)
+ return slang_function_scope_find_by_name (funcs->outer_scope, name, 1);
+ return 0;
+}
+
+static slang_function *slang_function_scope_find (slang_function_scope *funcs, slang_function *fun,
+ int all_scopes)
+{
+ unsigned int i;
+ for (i = 0; i < funcs->num_functions; i++)
+ {
+ slang_function *f = funcs->functions + i;
+ unsigned int j;
+ if (slang_string_compare (fun->header.name, f->header.name) != 0)
+ continue;
+ if (fun->param_count != f->param_count)
+ continue;
+ for (j = 0; j < fun->param_count; j++)
+ {
+ if (!slang_type_specifier_equal (&fun->parameters->variables[j].type.specifier,
+ &f->parameters->variables[j].type.specifier))
+ {
+ break;
+ }
+ }
+ if (j == fun->param_count)
+ return f;
+ }
+ if (all_scopes && funcs->outer_scope != NULL)
+ return slang_function_scope_find (funcs->outer_scope, fun, 1);
+ return NULL;
+}
+
+/* slang_translation_unit */
+
+void slang_translation_unit_construct (slang_translation_unit *unit)
+{
+ slang_variable_scope_construct (&unit->globals);
+ slang_function_scope_construct (&unit->functions);
+ slang_struct_scope_construct (&unit->structs);
+}
+
+void slang_translation_unit_destruct (slang_translation_unit *unit)
+{
+ slang_variable_scope_destruct (&unit->globals);
+ slang_function_scope_destruct (&unit->functions);
+ slang_struct_scope_destruct (&unit->structs);
+}
+
+/* slang_info_log */
+
+static char *out_of_memory = "error: out of memory\n";
+
+void slang_info_log_construct (slang_info_log *log)
+{
+ log->text = NULL;
+ log->dont_free_text = 0;
+}
+
+void slang_info_log_destruct (slang_info_log *log)
+{
+ if (!log->dont_free_text)
+ slang_alloc_free (log->text);
+}
+
+static int slang_info_log_message (slang_info_log *log, const char *prefix, const char *msg)
+{
+ unsigned int new_size;
+ if (log->dont_free_text)
+ return 0;
+ new_size = slang_string_length (prefix) + 3 + slang_string_length (msg);
+ if (log->text != NULL)
+ {
+ log->text = (char *) slang_alloc_realloc (log->text, slang_string_length (log->text) + 1,
+ new_size + slang_string_length (log->text) + 1);
+ }
+ else
+ {
+ log->text = (char *) slang_alloc_malloc (new_size + 1);
+ if (log->text != NULL)
+ *log->text = '\0';
+ }
+ if (log->text == NULL)
+ return 0;
+ slang_string_concat (log->text, prefix);
+ slang_string_concat (log->text, ": ");
+ slang_string_concat (log->text, msg);
+ slang_string_concat (log->text, "\n");
+ return 1;
+}
+
+int slang_info_log_error (slang_info_log *log, const char *msg, ...)
+{
+ va_list va;
+ char buf[1024];
+
+ va_start (va, msg);
+ vsprintf (buf, msg, va);
+ if (slang_info_log_message (log, "error", buf))
+ return 1;
+ slang_info_log_memory (log);
+ va_end (va);
+ return 0;
+}
+
+int slang_info_log_warning (slang_info_log *log, const char *msg, ...)
+{
+ va_list va;
+ char buf[1024];
+
+ va_start (va, msg);
+ vsprintf (buf, msg, va);
+ if (slang_info_log_message (log, "warning", buf))
+ return 1;
+ slang_info_log_memory (log);
+ va_end (va);
+ return 0;
+}
+
+void slang_info_log_memory (slang_info_log *log)
+{
+ if (!slang_info_log_message (log, "error", "out of memory"))
+ {
+ log->dont_free_text = 1;
+ log->text = out_of_memory;
+ }
+}
+
+/* slang_parse_ctx */
+
+typedef struct slang_parse_ctx_
+{
+ const byte *I;
+ slang_info_log *L;
+ int parsing_builtin;
+} slang_parse_ctx;
+
+/* _slang_compile() */
+
+static int parse_identifier (slang_parse_ctx *C, char **id)
+{
+ *id = slang_string_duplicate ((const char *) C->I);
+ if (*id == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ C->I += strlen ((const char *) C->I) + 1;
+ return 1;
+}
+
+static int parse_number (slang_parse_ctx *C, int *number)
+{
+ const int radix = (int) (*C->I++);
+ *number = 0;
+ while (*C->I != '\0')
+ {
+ int digit;
+ if (*C->I >= '0' && *C->I <= '9')
+ digit = (int) (*C->I - '0');
+ else if (*C->I >= 'A' && *C->I <= 'Z')
+ digit = (int) (*C->I - 'A') + 10;
+ else
+ digit = (int) (*C->I - 'a') + 10;
+ *number = *number * radix + digit;
+ C->I++;
+ }
+ C->I++;
+ if (*number > 65535)
+ slang_info_log_warning (C->L, "%d: literal integer overflow", *number);
+ return 1;
+}
+
+static int parse_float (slang_parse_ctx *C, float *number)
+{
+ char *integral = NULL;
+ char *fractional = NULL;
+ char *exponent = NULL;
+ char *whole = NULL;
+
+ if (!parse_identifier (C, &integral))
+ return 0;
+
+ if (!parse_identifier (C, &fractional))
+ {
+ slang_alloc_free (integral);
+ return 0;
+ }
+
+ if (!parse_identifier (C, &exponent))
+ {
+ slang_alloc_free (fractional);
+ slang_alloc_free (integral);
+ return 0;
+ }
+
+ whole = (char *) (slang_alloc_malloc ((strlen (integral) + strlen (fractional) + strlen (
+ exponent) + 3) * sizeof (char)));
+ if (whole == NULL)
+ {
+ slang_alloc_free (exponent);
+ slang_alloc_free (fractional);
+ slang_alloc_free (integral);
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+
+ slang_string_copy (whole, integral);
+ slang_string_concat (whole, ".");
+ slang_string_concat (whole, fractional);
+ slang_string_concat (whole, "E");
+ slang_string_concat (whole, exponent);
+
+ *number = (float) (atof (whole));
+
+ slang_alloc_free (whole);
+ slang_alloc_free (exponent);
+ slang_alloc_free (fractional);
+ slang_alloc_free (integral);
+ return 1;
+}
+
+/* revision number - increment after each change affecting emitted output */
+#define REVISION 2
+
+static int check_revision (slang_parse_ctx *C)
+{
+ if (*C->I != REVISION)
+ {
+ slang_info_log_error (C->L, "internal compiler error");
+ return 0;
+ }
+ C->I++;
+ return 1;
+}
+
+static int parse_statement (slang_parse_ctx *, slang_operation *, slang_variable_scope *,
+ slang_struct_scope *, slang_function_scope *);
+static int parse_expression (slang_parse_ctx *, slang_operation *, slang_variable_scope *,
+ slang_struct_scope *, slang_function_scope *);
+
+/* type qualifier */
+#define TYPE_QUALIFIER_NONE 0
+#define TYPE_QUALIFIER_CONST 1
+#define TYPE_QUALIFIER_ATTRIBUTE 2
+#define TYPE_QUALIFIER_VARYING 3
+#define TYPE_QUALIFIER_UNIFORM 4
+#define TYPE_QUALIFIER_FIXEDOUTPUT 5
+#define TYPE_QUALIFIER_FIXEDINPUT 6
+
+static int parse_type_qualifier (slang_parse_ctx *C, slang_type_qualifier *qual)
+{
+ switch (*C->I++)
+ {
+ case TYPE_QUALIFIER_NONE:
+ *qual = slang_qual_none;
+ break;
+ case TYPE_QUALIFIER_CONST:
+ *qual = slang_qual_const;
+ break;
+ case TYPE_QUALIFIER_ATTRIBUTE:
+ *qual = slang_qual_attribute;
+ break;
+ case TYPE_QUALIFIER_VARYING:
+ *qual = slang_qual_varying;
+ break;
+ case TYPE_QUALIFIER_UNIFORM:
+ *qual = slang_qual_uniform;
+ break;
+ case TYPE_QUALIFIER_FIXEDOUTPUT:
+ *qual = slang_qual_fixedoutput;
+ break;
+ case TYPE_QUALIFIER_FIXEDINPUT:
+ *qual = slang_qual_fixedinput;
+ break;
+ default:
+ return 0;
+ }
+ return 1;
+}
+
+/* type specifier */
+#define TYPE_SPECIFIER_VOID 0
+#define TYPE_SPECIFIER_BOOL 1
+#define TYPE_SPECIFIER_BVEC2 2
+#define TYPE_SPECIFIER_BVEC3 3
+#define TYPE_SPECIFIER_BVEC4 4
+#define TYPE_SPECIFIER_INT 5
+#define TYPE_SPECIFIER_IVEC2 6
+#define TYPE_SPECIFIER_IVEC3 7
+#define TYPE_SPECIFIER_IVEC4 8
+#define TYPE_SPECIFIER_FLOAT 9
+#define TYPE_SPECIFIER_VEC2 10
+#define TYPE_SPECIFIER_VEC3 11
+#define TYPE_SPECIFIER_VEC4 12
+#define TYPE_SPECIFIER_MAT2 13
+#define TYPE_SPECIFIER_MAT3 14
+#define TYPE_SPECIFIER_MAT4 15
+#define TYPE_SPECIFIER_SAMPLER1D 16
+#define TYPE_SPECIFIER_SAMPLER2D 17
+#define TYPE_SPECIFIER_SAMPLER3D 18
+#define TYPE_SPECIFIER_SAMPLERCUBE 19
+#define TYPE_SPECIFIER_SAMPLER1DSHADOW 20
+#define TYPE_SPECIFIER_SAMPLER2DSHADOW 21
+#define TYPE_SPECIFIER_STRUCT 22
+#define TYPE_SPECIFIER_TYPENAME 23
+
+/* structure field */
+#define FIELD_NONE 0
+#define FIELD_NEXT 1
+#define FIELD_ARRAY 2
+
+static int parse_type_specifier (slang_parse_ctx *C, slang_type_specifier *spec,
+ slang_struct_scope *structs, slang_variable_scope *scope, slang_function_scope *funcs)
+{
+ switch (*C->I++)
+ {
+ case TYPE_SPECIFIER_VOID:
+ spec->type = slang_spec_void;
+ break;
+ case TYPE_SPECIFIER_BOOL:
+ spec->type = slang_spec_bool;
+ break;
+ case TYPE_SPECIFIER_BVEC2:
+ spec->type = slang_spec_bvec2;
+ break;
+ case TYPE_SPECIFIER_BVEC3:
+ spec->type = slang_spec_bvec3;
+ break;
+ case TYPE_SPECIFIER_BVEC4:
+ spec->type = slang_spec_bvec4;
+ break;
+ case TYPE_SPECIFIER_INT:
+ spec->type = slang_spec_int;
+ break;
+ case TYPE_SPECIFIER_IVEC2:
+ spec->type = slang_spec_ivec2;
+ break;
+ case TYPE_SPECIFIER_IVEC3:
+ spec->type = slang_spec_ivec3;
+ break;
+ case TYPE_SPECIFIER_IVEC4:
+ spec->type = slang_spec_ivec4;
+ break;
+ case TYPE_SPECIFIER_FLOAT:
+ spec->type = slang_spec_float;
+ break;
+ case TYPE_SPECIFIER_VEC2:
+ spec->type = slang_spec_vec2;
+ break;
+ case TYPE_SPECIFIER_VEC3:
+ spec->type = slang_spec_vec3;
+ break;
+ case TYPE_SPECIFIER_VEC4:
+ spec->type = slang_spec_vec4;
+ break;
+ case TYPE_SPECIFIER_MAT2:
+ spec->type = slang_spec_mat2;
+ break;
+ case TYPE_SPECIFIER_MAT3:
+ spec->type = slang_spec_mat3;
+ break;
+ case TYPE_SPECIFIER_MAT4:
+ spec->type = slang_spec_mat4;
+ break;
+ case TYPE_SPECIFIER_SAMPLER1D:
+ spec->type = slang_spec_sampler1D;
+ break;
+ case TYPE_SPECIFIER_SAMPLER2D:
+ spec->type = slang_spec_sampler2D;
+ break;
+ case TYPE_SPECIFIER_SAMPLER3D:
+ spec->type = slang_spec_sampler3D;
+ break;
+ case TYPE_SPECIFIER_SAMPLERCUBE:
+ spec->type = slang_spec_samplerCube;
+ break;
+ case TYPE_SPECIFIER_SAMPLER1DSHADOW:
+ spec->type = slang_spec_sampler1DShadow;
+ break;
+ case TYPE_SPECIFIER_SAMPLER2DSHADOW:
+ spec->type = slang_spec_sampler2DShadow;
+ break;
+ case TYPE_SPECIFIER_STRUCT:
+ spec->type = slang_spec_struct;
+ {
+ char *name;
+ if (!parse_identifier (C, &name))
+ return 0;
+ if (*name != '\0' && slang_struct_scope_find (structs, name, 0) != NULL)
+ {
+ slang_info_log_error (C->L, "%s: duplicate type name", name);
+ slang_alloc_free (name);
+ return 0;
+ }
+ spec->_struct = (slang_struct *) slang_alloc_malloc (sizeof (slang_struct));
+ if (spec->_struct == NULL)
+ {
+ slang_alloc_free (name);
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ if (!slang_struct_construct_a (spec->_struct))
+ {
+ slang_alloc_free (spec->_struct);
+ spec->_struct = NULL;
+ slang_alloc_free (name);
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ spec->_struct->name = name;
+ spec->_struct->structs->outer_scope = structs;
+ }
+ do
+ {
+ slang_type_specifier sp;
+ slang_type_specifier_construct (&sp);
+ if (!parse_type_specifier (C, &sp, spec->_struct->structs, scope, funcs))
+ {
+ slang_type_specifier_destruct (&sp);
+ return 0;
+ }
+ do
+ {
+ slang_variable *var;
+ spec->_struct->fields->variables = (slang_variable *) slang_alloc_realloc (
+ spec->_struct->fields->variables,
+ spec->_struct->fields->num_variables * sizeof (slang_variable),
+ (spec->_struct->fields->num_variables + 1) * sizeof (slang_variable));
+ if (spec->_struct->fields->variables == NULL)
+ {
+ slang_type_specifier_destruct (&sp);
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ var = spec->_struct->fields->variables + spec->_struct->fields->num_variables;
+ spec->_struct->fields->num_variables++;
+ slang_variable_construct (var);
+ if (!slang_type_specifier_copy (&var->type.specifier, &sp))
+ {
+ slang_type_specifier_destruct (&sp);
+ return 0;
+ }
+ if (!parse_identifier (C, &var->name))
+ {
+ slang_type_specifier_destruct (&sp);
+ return 0;
+ }
+ switch (*C->I++)
+ {
+ case FIELD_NONE:
+ break;
+ case FIELD_ARRAY:
+ var->array_size = (slang_operation *) slang_alloc_malloc (sizeof (
+ slang_operation));
+ if (var->array_size == NULL)
+ {
+ slang_type_specifier_destruct (&sp);
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ if (!slang_operation_construct_a (var->array_size))
+ {
+ slang_alloc_free (var->array_size);
+ var->array_size = NULL;
+ slang_type_specifier_destruct (&sp);
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ if (!parse_expression (C, var->array_size, scope, structs, funcs))
+ {
+ slang_type_specifier_destruct (&sp);
+ return 0;
+ }
+ break;
+ default:
+ return 0;
+ }
+ }
+ while (*C->I++ != FIELD_NONE);
+ }
+ while (*C->I++ != FIELD_NONE);
+ if (*spec->_struct->name != '\0')
+ {
+ slang_struct *s;
+ structs->structs = (slang_struct *) slang_alloc_realloc (structs->structs,
+ structs->num_structs * sizeof (slang_struct),
+ (structs->num_structs + 1) * sizeof (slang_struct));
+ if (structs->structs == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ s = structs->structs + structs->num_structs;
+ if (!slang_struct_construct_a (s))
+ return 0;
+ structs->num_structs++;
+ if (!slang_struct_copy (s, spec->_struct))
+ return 0;
+ }
+ break;
+ case TYPE_SPECIFIER_TYPENAME:
+ spec->type = slang_spec_struct;
+ {
+ char *name;
+ slang_struct *stru;
+ if (!parse_identifier (C, &name))
+ return 0;
+ stru = slang_struct_scope_find (structs, name, 1);
+ if (stru == NULL)
+ {
+ slang_info_log_error (C->L, "%s: undeclared type name", name);
+ slang_alloc_free (name);
+ return 0;
+ }
+ slang_alloc_free (name);
+ spec->_struct = (slang_struct *) slang_alloc_malloc (sizeof (slang_struct));
+ if (spec->_struct == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ if (!slang_struct_construct_a (spec->_struct))
+ {
+ slang_alloc_free (spec->_struct);
+ spec->_struct = NULL;
+ return 0;
+ }
+ if (!slang_struct_copy (spec->_struct, stru))
+ return 0;
+ }
+ break;
+ default:
+ return 0;
+ }
+ return 1;
+}
+
+static int parse_fully_specified_type (slang_parse_ctx *C, slang_fully_specified_type *type,
+ slang_struct_scope *structs, slang_variable_scope *scope, slang_function_scope *funcs)
+{
+ if (!parse_type_qualifier (C, &type->qualifier))
+ return 0;
+ return parse_type_specifier (C, &type->specifier, structs, scope, funcs);
+}
+
+/* operation */
+#define OP_END 0
+#define OP_BLOCK_BEGIN_NO_NEW_SCOPE 1
+#define OP_BLOCK_BEGIN_NEW_SCOPE 2
+#define OP_DECLARE 3
+#define OP_ASM 4
+#define OP_BREAK 5
+#define OP_CONTINUE 6
+#define OP_DISCARD 7
+#define OP_RETURN 8
+#define OP_EXPRESSION 9
+#define OP_IF 10
+#define OP_WHILE 11
+#define OP_DO 12
+#define OP_FOR 13
+#define OP_PUSH_VOID 14
+#define OP_PUSH_BOOL 15
+#define OP_PUSH_INT 16
+#define OP_PUSH_FLOAT 17
+#define OP_PUSH_IDENTIFIER 18
+#define OP_SEQUENCE 19
+#define OP_ASSIGN 20
+#define OP_ADDASSIGN 21
+#define OP_SUBASSIGN 22
+#define OP_MULASSIGN 23
+#define OP_DIVASSIGN 24
+/*#define OP_MODASSIGN 25*/
+/*#define OP_LSHASSIGN 26*/
+/*#define OP_RSHASSIGN 27*/
+/*#define OP_ORASSIGN 28*/
+/*#define OP_XORASSIGN 29*/
+/*#define OP_ANDASSIGN 30*/
+#define OP_SELECT 31
+#define OP_LOGICALOR 32
+#define OP_LOGICALXOR 33
+#define OP_LOGICALAND 34
+/*#define OP_BITOR 35*/
+/*#define OP_BITXOR 36*/
+/*#define OP_BITAND 37*/
+#define OP_EQUAL 38
+#define OP_NOTEQUAL 39
+#define OP_LESS 40
+#define OP_GREATER 41
+#define OP_LESSEQUAL 42
+#define OP_GREATEREQUAL 43
+/*#define OP_LSHIFT 44*/
+/*#define OP_RSHIFT 45*/
+#define OP_ADD 46
+#define OP_SUBTRACT 47
+#define OP_MULTIPLY 48
+#define OP_DIVIDE 49
+/*#define OP_MODULUS 50*/
+#define OP_PREINCREMENT 51
+#define OP_PREDECREMENT 52
+#define OP_PLUS 53
+#define OP_MINUS 54
+/*#define OP_COMPLEMENT 55*/
+#define OP_NOT 56
+#define OP_SUBSCRIPT 57
+#define OP_CALL 58
+#define OP_FIELD 59
+#define OP_POSTINCREMENT 60
+#define OP_POSTDECREMENT 61
+
+static int parse_child_operation (slang_parse_ctx *C, slang_operation *oper, int statement,
+ slang_variable_scope *scope, slang_struct_scope *structs, slang_function_scope *funcs)
+{
+ oper->children = (slang_operation *) slang_alloc_realloc (oper->children,
+ oper->num_children * sizeof (slang_operation),
+ (oper->num_children + 1) * sizeof (slang_operation));
+ if (oper->children == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ if (!slang_operation_construct_a (oper->children + oper->num_children))
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ oper->num_children++;
+ if (statement)
+ return parse_statement (C, oper->children + oper->num_children - 1, scope, structs, funcs);
+ return parse_expression (C, oper->children + oper->num_children - 1, scope, structs, funcs);
+}
+
+static int parse_declaration (slang_parse_ctx *C, slang_variable_scope *, slang_struct_scope *,
+ slang_function_scope *);
+
+static int parse_statement (slang_parse_ctx *C, slang_operation *oper, slang_variable_scope *scope,
+ slang_struct_scope *structs, slang_function_scope *funcs)
+{
+ oper->locals->outer_scope = scope;
+ switch (*C->I++)
+ {
+ case OP_BLOCK_BEGIN_NO_NEW_SCOPE:
+ oper->type = slang_oper_block_no_new_scope;
+ while (*C->I != OP_END)
+ if (!parse_child_operation (C, oper, 1, scope, structs, funcs))
+ return 0;
+ C->I++;
+ break;
+ case OP_BLOCK_BEGIN_NEW_SCOPE:
+ oper->type = slang_oper_block_new_scope;
+ while (*C->I != OP_END)
+ if (!parse_child_operation (C, oper, 1, oper->locals, structs, funcs))
+ return 0;
+ C->I++;
+ break;
+ case OP_DECLARE:
+ oper->type = slang_oper_variable_decl;
+ {
+ const unsigned int first_var = scope->num_variables;
+ if (!parse_declaration (C, scope, structs, funcs))
+ return 0;
+ if (first_var < scope->num_variables)
+ {
+ const unsigned int num_vars = scope->num_variables - first_var;
+ unsigned int i;
+ oper->children = (slang_operation *) slang_alloc_malloc (num_vars * sizeof (
+ slang_operation));
+ if (oper->children == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ for (i = 0; i < num_vars; i++)
+ if (!slang_operation_construct_a (oper->children + i))
+ {
+ unsigned int j;
+ for (j = 0; j < i; j++)
+ slang_operation_destruct (oper->children + j);
+ slang_alloc_free (oper->children);
+ oper->children = NULL;
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ oper->num_children = num_vars;
+ for (i = first_var; i < scope->num_variables; i++)
+ {
+ slang_operation *o = oper->children + i - first_var;
+ o->type = slang_oper_identifier;
+ o->locals->outer_scope = scope;
+ o->identifier = slang_string_duplicate (scope->variables[i].name);
+ if (o->identifier == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ }
+ }
+ }
+ break;
+ case OP_ASM:
+ oper->type = slang_oper_asm;
+ if (!parse_identifier (C, &oper->identifier))
+ return 0;
+ while (*C->I != OP_END)
+ if (!parse_child_operation (C, oper, 0, scope, structs, funcs))
+ return 0;
+ C->I++;
+ break;
+ case OP_BREAK:
+ oper->type = slang_oper_break;
+ break;
+ case OP_CONTINUE:
+ oper->type = slang_oper_continue;
+ break;
+ case OP_DISCARD:
+ oper->type = slang_oper_discard;
+ break;
+ case OP_RETURN:
+ oper->type = slang_oper_return;
+ if (!parse_child_operation (C, oper, 0, scope, structs, funcs))
+ return 0;
+ break;
+ case OP_EXPRESSION:
+ oper->type = slang_oper_expression;
+ if (!parse_child_operation (C, oper, 0, scope, structs, funcs))
+ return 0;
+ break;
+ case OP_IF:
+ oper->type = slang_oper_if;
+ if (!parse_child_operation (C, oper, 0, scope, structs, funcs))
+ return 0;
+ if (!parse_child_operation (C, oper, 1, scope, structs, funcs))
+ return 0;
+ if (!parse_child_operation (C, oper, 1, scope, structs, funcs))
+ return 0;
+ break;
+ case OP_WHILE:
+ oper->type = slang_oper_while;
+ if (!parse_child_operation (C, oper, 1, oper->locals, structs, funcs))
+ return 0;
+ if (!parse_child_operation (C, oper, 1, oper->locals, structs, funcs))
+ return 0;
+ break;
+ case OP_DO:
+ oper->type = slang_oper_do;
+ if (!parse_child_operation (C, oper, 1, scope, structs, funcs))
+ return 0;
+ if (!parse_child_operation (C, oper, 0, scope, structs, funcs))
+ return 0;
+ break;
+ case OP_FOR:
+ oper->type = slang_oper_for;
+ if (!parse_child_operation (C, oper, 1, oper->locals, structs, funcs))
+ return 0;
+ if (!parse_child_operation (C, oper, 1, oper->locals, structs, funcs))
+ return 0;
+ if (!parse_child_operation (C, oper, 0, oper->locals, structs, funcs))
+ return 0;
+ if (!parse_child_operation (C, oper, 1, oper->locals, structs, funcs))
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+ return 1;
+}
+
+static int handle_trinary_expression (slang_parse_ctx *C, slang_operation *op,
+ slang_operation **ops, unsigned int *num_ops)
+{
+ op->num_children = 3;
+ op->children = (slang_operation *) slang_alloc_malloc (3 * sizeof (slang_operation));
+ if (op->children == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ op->children[0] = (*ops)[*num_ops - 4];
+ op->children[1] = (*ops)[*num_ops - 3];
+ op->children[2] = (*ops)[*num_ops - 2];
+ (*ops)[*num_ops - 4] = (*ops)[*num_ops - 1];
+ *num_ops -= 3;
+ *ops = (slang_operation *) slang_alloc_realloc (*ops, (*num_ops + 3) * sizeof (slang_operation),
+ *num_ops * sizeof (slang_operation));
+ if (*ops == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ return 1;
+}
+
+static int handle_binary_expression (slang_parse_ctx *C, slang_operation *op,
+ slang_operation **ops, unsigned int *num_ops)
+{
+ op->num_children = 2;
+ op->children = (slang_operation *) slang_alloc_malloc (2 * sizeof (slang_operation));
+ if (op->children == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ op->children[0] = (*ops)[*num_ops - 3];
+ op->children[1] = (*ops)[*num_ops - 2];
+ (*ops)[*num_ops - 3] = (*ops)[*num_ops - 1];
+ *num_ops -= 2;
+ *ops = (slang_operation *) slang_alloc_realloc (*ops, (*num_ops + 2) * sizeof (slang_operation),
+ *num_ops * sizeof (slang_operation));
+ if (*ops == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ return 1;
+}
+
+static int handle_unary_expression (slang_parse_ctx *C, slang_operation *op,
+ slang_operation **ops, unsigned int *num_ops)
+{
+ op->num_children = 1;
+ op->children = (slang_operation *) slang_alloc_malloc (sizeof (slang_operation));
+ if (op->children == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ op->children[0] = (*ops)[*num_ops - 2];
+ (*ops)[*num_ops - 2] = (*ops)[*num_ops - 1];
+ (*num_ops)--;
+ *ops = (slang_operation *) slang_alloc_realloc (*ops, (*num_ops + 1) * sizeof (slang_operation),
+ *num_ops * sizeof (slang_operation));
+ if (*ops == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ return 1;
+}
+
+static int is_constructor_name (const char *name, slang_struct_scope *structs)
+{
+ if (slang_type_specifier_type_from_string (name) != slang_spec_void)
+ return 1;
+ return slang_struct_scope_find (structs, name, 1) != NULL;
+}
+
+static int parse_expression (slang_parse_ctx *C, slang_operation *oper, slang_variable_scope *scope,
+ slang_struct_scope *structs, slang_function_scope *funcs)
+{
+ slang_operation *ops = NULL;
+ unsigned int num_ops = 0;
+ int number;
+
+ while (*C->I != OP_END)
+ {
+ slang_operation *op;
+ const unsigned int op_code = *C->I++;
+ ops = (slang_operation *) slang_alloc_realloc (ops,
+ num_ops * sizeof (slang_operation), (num_ops + 1) * sizeof (slang_operation));
+ if (ops == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ op = ops + num_ops;
+ if (!slang_operation_construct_a (op))
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ num_ops++;
+ op->locals->outer_scope = scope;
+ switch (op_code)
+ {
+ case OP_PUSH_VOID:
+ op->type = slang_oper_void;
+ break;
+ case OP_PUSH_BOOL:
+ op->type = slang_oper_literal_bool;
+ if (!parse_number (C, &number))
+ return 0;
+ op->literal = (float) number;
+ break;
+ case OP_PUSH_INT:
+ op->type = slang_oper_literal_int;
+ if (!parse_number (C, &number))
+ return 0;
+ op->literal = (float) number;
+ break;
+ case OP_PUSH_FLOAT:
+ op->type = slang_oper_literal_float;
+ if (!parse_float (C, &op->literal))
+ return 0;
+ break;
+ case OP_PUSH_IDENTIFIER:
+ op->type = slang_oper_identifier;
+ if (!parse_identifier (C, &op->identifier))
+ return 0;
+ break;
+ case OP_SEQUENCE:
+ op->type = slang_oper_sequence;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_ASSIGN:
+ op->type = slang_oper_assign;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_ADDASSIGN:
+ op->type = slang_oper_addassign;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_SUBASSIGN:
+ op->type = slang_oper_subassign;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_MULASSIGN:
+ op->type = slang_oper_mulassign;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_DIVASSIGN:
+ op->type = slang_oper_divassign;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ /*case OP_MODASSIGN:*/
+ /*case OP_LSHASSIGN:*/
+ /*case OP_RSHASSIGN:*/
+ /*case OP_ORASSIGN:*/
+ /*case OP_XORASSIGN:*/
+ /*case OP_ANDASSIGN:*/
+ case OP_SELECT:
+ op->type = slang_oper_select;
+ if (!handle_trinary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_LOGICALOR:
+ op->type = slang_oper_logicalor;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_LOGICALXOR:
+ op->type = slang_oper_logicalxor;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_LOGICALAND:
+ op->type = slang_oper_logicaland;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ /*case OP_BITOR:*/
+ /*case OP_BITXOR:*/
+ /*case OP_BITAND:*/
+ case OP_EQUAL:
+ op->type = slang_oper_equal;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_NOTEQUAL:
+ op->type = slang_oper_notequal;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_LESS:
+ op->type = slang_oper_less;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_GREATER:
+ op->type = slang_oper_greater;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_LESSEQUAL:
+ op->type = slang_oper_lessequal;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_GREATEREQUAL:
+ op->type = slang_oper_greaterequal;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ /*case OP_LSHIFT:*/
+ /*case OP_RSHIFT:*/
+ case OP_ADD:
+ op->type = slang_oper_add;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_SUBTRACT:
+ op->type = slang_oper_subtract;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_MULTIPLY:
+ op->type = slang_oper_multiply;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_DIVIDE:
+ op->type = slang_oper_divide;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ /*case OP_MODULUS:*/
+ case OP_PREINCREMENT:
+ op->type = slang_oper_preincrement;
+ if (!handle_unary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_PREDECREMENT:
+ op->type = slang_oper_predecrement;
+ if (!handle_unary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_PLUS:
+ op->type = slang_oper_plus;
+ if (!handle_unary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_MINUS:
+ op->type = slang_oper_minus;
+ if (!handle_unary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_NOT:
+ op->type = slang_oper_not;
+ if (!handle_unary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ /*case OP_COMPLEMENT:*/
+ case OP_SUBSCRIPT:
+ op->type = slang_oper_subscript;
+ if (!handle_binary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_CALL:
+ op->type = slang_oper_call;
+ if (!parse_identifier (C, &op->identifier))
+ return 0;
+ while (*C->I != OP_END)
+ if (!parse_child_operation (C, op, 0, scope, structs, funcs))
+ return 0;
+ C->I++;
+ if (!C->parsing_builtin &&
+ !slang_function_scope_find_by_name (funcs, op->identifier, 1) &&
+ !is_constructor_name (op->identifier, structs))
+ {
+ slang_info_log_error (C->L, "%s: undeclared function name", op->identifier);
+ return 0;
+ }
+ break;
+ case OP_FIELD:
+ op->type = slang_oper_field;
+ if (!parse_identifier (C, &op->identifier))
+ return 0;
+ if (!handle_unary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_POSTINCREMENT:
+ op->type = slang_oper_postincrement;
+ if (!handle_unary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ case OP_POSTDECREMENT:
+ op->type = slang_oper_postdecrement;
+ if (!handle_unary_expression (C, op, &ops, &num_ops))
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+ }
+ C->I++;
+ *oper = *ops;
+ slang_alloc_free (ops);
+ return 1;
+}
+
+/* parameter qualifier */
+#define PARAM_QUALIFIER_IN 0
+#define PARAM_QUALIFIER_OUT 1
+#define PARAM_QUALIFIER_INOUT 2
+
+/* function parameter array presence */
+#define PARAMETER_ARRAY_NOT_PRESENT 0
+#define PARAMETER_ARRAY_PRESENT 1
+
+static int parse_parameter_declaration (slang_parse_ctx *C, slang_variable *param,
+ slang_struct_scope *structs, slang_variable_scope *scope, slang_function_scope *funcs)
+{
+ slang_storage_aggregate agg;
+ if (!parse_type_qualifier (C, &param->type.qualifier))
+ return 0;
+ switch (*C->I++)
+ {
+ case PARAM_QUALIFIER_IN:
+ if (param->type.qualifier != slang_qual_const && param->type.qualifier != slang_qual_none)
+ {
+ slang_info_log_error (C->L, "invalid type qualifier");
+ return 0;
+ }
+ break;
+ case PARAM_QUALIFIER_OUT:
+ if (param->type.qualifier == slang_qual_none)
+ param->type.qualifier = slang_qual_out;
+ else
+ {
+ slang_info_log_error (C->L, "invalid type qualifier");
+ return 0;
+ }
+ break;
+ case PARAM_QUALIFIER_INOUT:
+ if (param->type.qualifier == slang_qual_none)
+ param->type.qualifier = slang_qual_inout;
+ else
+ {
+ slang_info_log_error (C->L, "invalid type qualifier");
+ return 0;
+ }
+ break;
+ default:
+ return 0;
+ }
+ if (!parse_type_specifier (C, &param->type.specifier, structs, scope, funcs))
+ return 0;
+ if (!parse_identifier (C, &param->name))
+ return 0;
+ if (*C->I++ == PARAMETER_ARRAY_PRESENT)
+ {
+ param->array_size = (slang_operation *) slang_alloc_malloc (sizeof (slang_operation));
+ if (param->array_size == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ if (!slang_operation_construct_a (param->array_size))
+ {
+ slang_alloc_free (param->array_size);
+ param->array_size = NULL;
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ if (!parse_expression (C, param->array_size, scope, structs, funcs))
+ return 0;
+ }
+ slang_storage_aggregate_construct (&agg);
+ if (!_slang_aggregate_variable (&agg, &param->type.specifier, param->array_size, funcs,
+ structs))
+ {
+ slang_storage_aggregate_destruct (&agg);
+ return 0;
+ }
+ slang_storage_aggregate_destruct (&agg);
+ return 1;
+}
+
+/* function type */
+#define FUNCTION_ORDINARY 0
+#define FUNCTION_CONSTRUCTOR 1
+#define FUNCTION_OPERATOR 2
+
+/* function parameter */
+#define PARAMETER_NONE 0
+#define PARAMETER_NEXT 1
+
+/* operator type */
+#define OPERATOR_ASSIGN 1
+#define OPERATOR_ADDASSIGN 2
+#define OPERATOR_SUBASSIGN 3
+#define OPERATOR_MULASSIGN 4
+#define OPERATOR_DIVASSIGN 5
+/*#define OPERATOR_MODASSIGN 6*/
+/*#define OPERATOR_LSHASSIGN 7*/
+/*#define OPERATOR_RSHASSIGN 8*/
+/*#define OPERATOR_ANDASSIGN 9*/
+/*#define OPERATOR_XORASSIGN 10*/
+/*#define OPERATOR_ORASSIGN 11*/
+#define OPERATOR_LOGICALXOR 12
+/*#define OPERATOR_BITOR 13*/
+/*#define OPERATOR_BITXOR 14*/
+/*#define OPERATOR_BITAND 15*/
+#define OPERATOR_EQUAL 16
+#define OPERATOR_NOTEQUAL 17
+#define OPERATOR_LESS 18
+#define OPERATOR_GREATER 19
+#define OPERATOR_LESSEQUAL 20
+#define OPERATOR_GREATEREQUAL 21
+/*#define OPERATOR_LSHIFT 22*/
+/*#define OPERATOR_RSHIFT 23*/
+#define OPERATOR_MULTIPLY 24
+#define OPERATOR_DIVIDE 25
+/*#define OPERATOR_MODULUS 26*/
+#define OPERATOR_INCREMENT 27
+#define OPERATOR_DECREMENT 28
+#define OPERATOR_PLUS 29
+#define OPERATOR_MINUS 30
+/*#define OPERATOR_COMPLEMENT 31*/
+#define OPERATOR_NOT 32
+
+static const struct {
+ unsigned int o_code;
+ const char *o_name;
+} operator_names[] = {
+ { OPERATOR_INCREMENT, "++" },
+ { OPERATOR_ADDASSIGN, "+=" },
+ { OPERATOR_PLUS, "+" },
+ { OPERATOR_DECREMENT, "--" },
+ { OPERATOR_SUBASSIGN, "-=" },
+ { OPERATOR_MINUS, "-" },
+ { OPERATOR_NOTEQUAL, "!=" },
+ { OPERATOR_NOT, "!" },
+ { OPERATOR_MULASSIGN, "*=" },
+ { OPERATOR_MULTIPLY, "*" },
+ { OPERATOR_DIVASSIGN, "/=" },
+ { OPERATOR_DIVIDE, "/" },
+ { OPERATOR_LESSEQUAL, "<=" },
+ /*{ OPERATOR_LSHASSIGN, "<<=" },*/
+ /*{ OPERATOR_LSHIFT, "<<" },*/
+ { OPERATOR_LESS, "<" },
+ { OPERATOR_GREATEREQUAL, ">=" },
+ /*{ OPERATOR_RSHASSIGN, ">>=" },*/
+ /*{ OPERATOR_RSHIFT, ">>" },*/
+ { OPERATOR_GREATER, ">" },
+ { OPERATOR_EQUAL, "==" },
+ { OPERATOR_ASSIGN, "=" },
+ /*{ OPERATOR_MODASSIGN, "%=" },*/
+ /*{ OPERATOR_MODULUS, "%" },*/
+ /*{ OPERATOR_ANDASSIGN, "&=" },*/
+ /*{ OPERATOR_BITAND, "&" },*/
+ /*{ OPERATOR_ORASSIGN, "|=" },*/
+ /*{ OPERATOR_BITOR, "|" },*/
+ /*{ OPERATOR_COMPLEMENT, "~" },*/
+ /*{ OPERATOR_XORASSIGN, "^=" },*/
+ { OPERATOR_LOGICALXOR, "^^" }/*,*/
+ /*{ OPERATOR_BITXOR, "^" }*/
+};
+
+static int parse_operator_name (slang_parse_ctx *C, char **pname)
+{
+ unsigned int i;
+ for (i = 0; i < sizeof (operator_names) / sizeof (*operator_names); i++)
+ if (operator_names[i].o_code == (unsigned int) (*C->I))
+ {
+ *pname = slang_string_duplicate (operator_names[i].o_name);
+ if (*pname == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ C->I++;
+ return 1;
+ }
+ return 0;
+}
+
+static int parse_function_prototype (slang_parse_ctx *C, slang_function *func,
+ slang_struct_scope *structs, slang_variable_scope *scope, slang_function_scope *funcs)
+{
+ if (!parse_fully_specified_type (C, &func->header.type, structs, scope, funcs))
+ return 0;
+ switch (*C->I++)
+ {
+ case FUNCTION_ORDINARY:
+ func->kind = slang_func_ordinary;
+ if (!parse_identifier (C, &func->header.name))
+ return 0;
+ break;
+ case FUNCTION_CONSTRUCTOR:
+ func->kind = slang_func_constructor;
+ if (func->header.type.specifier.type == slang_spec_struct)
+ return 0;
+ func->header.name = slang_string_duplicate (
+ type_specifier_type_names[func->header.type.specifier.type]);
+ if (func->header.name == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ break;
+ case FUNCTION_OPERATOR:
+ func->kind = slang_func_operator;
+ if (!parse_operator_name (C, &func->header.name))
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+ func->parameters->outer_scope = scope;
+ while (*C->I++ == PARAMETER_NEXT)
+ {
+ func->parameters->variables = (slang_variable *) slang_alloc_realloc (
+ func->parameters->variables,
+ func->parameters->num_variables * sizeof (slang_variable),
+ (func->parameters->num_variables + 1) * sizeof (slang_variable));
+ if (func->parameters->variables == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ slang_variable_construct (func->parameters->variables + func->parameters->num_variables);
+ func->parameters->num_variables++;
+ if (!parse_parameter_declaration (C, func->parameters->variables +
+ func->parameters->num_variables - 1, structs, scope, funcs))
+ return 0;
+ }
+ func->param_count = func->parameters->num_variables;
+ return 1;
+}
+
+static int parse_function_definition (slang_parse_ctx *C, slang_function *func,
+ slang_struct_scope *structs, slang_variable_scope *scope, slang_function_scope *funcs)
+{
+ if (!parse_function_prototype (C, func, structs, scope, funcs))
+ return 0;
+ func->body = (slang_operation *) slang_alloc_malloc (sizeof (slang_operation));
+ if (func->body == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ if (!slang_operation_construct_a (func->body))
+ {
+ slang_alloc_free (func->body);
+ func->body = NULL;
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ if (!parse_statement (C, func->body, func->parameters, structs, funcs))
+ return 0;
+ return 1;
+}
+
+/* init declarator list */
+#define DECLARATOR_NONE 0
+#define DECLARATOR_NEXT 1
+
+/* variable declaration */
+#define VARIABLE_NONE 0
+#define VARIABLE_IDENTIFIER 1
+#define VARIABLE_INITIALIZER 2
+#define VARIABLE_ARRAY_EXPLICIT 3
+#define VARIABLE_ARRAY_UNKNOWN 4
+
+static int parse_init_declarator (slang_parse_ctx *C, const slang_fully_specified_type *type,
+ slang_variable_scope *vars, slang_struct_scope *structs, slang_function_scope *funcs)
+{
+ slang_variable *var;
+
+ if (*C->I++ == VARIABLE_NONE)
+ return 1;
+ vars->variables = (slang_variable *) slang_alloc_realloc (vars->variables,
+ vars->num_variables * sizeof (slang_variable),
+ (vars->num_variables + 1) * sizeof (slang_variable));
+ if (vars->variables == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ var = vars->variables + vars->num_variables;
+ vars->num_variables++;
+ slang_variable_construct (var);
+ var->type.qualifier = type->qualifier;
+ if (!parse_identifier (C, &var->name))
+ return 0;
+ switch (*C->I++)
+ {
+ case VARIABLE_NONE:
+ if (!slang_type_specifier_copy (&var->type.specifier, &type->specifier))
+ return 0;
+ break;
+ case VARIABLE_INITIALIZER:
+ if (!slang_type_specifier_copy (&var->type.specifier, &type->specifier))
+ return 0;
+ var->initializer = (slang_operation *) slang_alloc_malloc (sizeof (slang_operation));
+ if (var->initializer == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ if (!slang_operation_construct_a (var->initializer))
+ {
+ slang_alloc_free (var->initializer);
+ var->initializer = NULL;
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ if (!parse_expression (C, var->initializer, vars, structs, funcs))
+ return 0;
+ break;
+ case VARIABLE_ARRAY_UNKNOWN:
+ var->type.specifier.type = slang_spec_array;
+ var->type.specifier._array = (slang_type_specifier *) slang_alloc_malloc (sizeof (
+ slang_type_specifier));
+ if (var->type.specifier._array == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ slang_type_specifier_construct (var->type.specifier._array);
+ if (!slang_type_specifier_copy (var->type.specifier._array, &type->specifier))
+ return 0;
+ break;
+ case VARIABLE_ARRAY_EXPLICIT:
+ var->type.specifier.type = slang_spec_array;
+ var->type.specifier._array = (slang_type_specifier *) slang_alloc_malloc (sizeof (
+ slang_type_specifier));
+ if (var->type.specifier._array == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ slang_type_specifier_construct (var->type.specifier._array);
+ if (!slang_type_specifier_copy (var->type.specifier._array, &type->specifier))
+ return 0;
+ var->array_size = (slang_operation *) slang_alloc_malloc (sizeof (slang_operation));
+ if (var->array_size == NULL)
+ {
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ if (!slang_operation_construct_a (var->array_size))
+ {
+ slang_alloc_free (var->array_size);
+ var->array_size = NULL;
+ slang_info_log_memory (C->L);
+ return 0;
+ }
+ if (!parse_expression (C, var->array_size, vars, structs, funcs))
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+ if (!(var->type.specifier.type == slang_spec_array && var->array_size == NULL))
+ {
+ slang_storage_aggregate agg;
+
+ slang_storage_aggregate_construct (&agg);
+ if (!_slang_aggregate_variable (&agg, &var->type.specifier, var->array_size, funcs,
+ structs))
+ {
+ slang_storage_aggregate_destruct (&agg);
+ return 0;
+ }
+ slang_storage_aggregate_destruct (&agg);
+ }
+ return 1;
+}
+
+static int parse_init_declarator_list (slang_parse_ctx *C, slang_variable_scope *vars,
+ slang_struct_scope *structs, slang_function_scope *funcs)
+{
+ slang_fully_specified_type type;
+
+ slang_fully_specified_type_construct (&type);
+ if (!parse_fully_specified_type (C, &type, structs, vars, funcs))
+ {
+ slang_fully_specified_type_destruct (&type);
+ return 0;
+ }
+ do
+ {
+ if (!parse_init_declarator (C, &type, vars, structs, funcs))
+ {
+ slang_fully_specified_type_destruct (&type);
+ return 0;
+ }
+ }
+ while (*C->I++ == DECLARATOR_NEXT);
+ slang_fully_specified_type_destruct (&type);
+ return 1;
+}
+
+static int parse_function (slang_parse_ctx *C, int definition, slang_struct_scope *structs,
+ slang_function_scope *funcs, slang_variable_scope *scope, slang_function **parsed_func_ret)
+{
+ slang_function parsed_func, *found_func;
+
+ /* parse function definition/declaration */
+ slang_function_construct (&parsed_func);
+ if (definition)
+ {
+ if (!parse_function_definition (C, &parsed_func, structs, scope, funcs))
+ {
+ slang_function_destruct (&parsed_func);
+ return 0;
+ }
+ }
+ else
+ {
+ if (!parse_function_prototype (C, &parsed_func, structs, scope, funcs))
+ {
+ slang_function_destruct (&parsed_func);
+ return 0;
+ }
+ }
+
+ /* find a function with a prototype matching the parsed one - only the current scope
+ is being searched to allow built-in function overriding */
+ found_func = slang_function_scope_find (funcs, &parsed_func, 0);
+ if (found_func == NULL)
+ {
+ /* add the parsed function to the function list */
+ funcs->functions = (slang_function *) slang_alloc_realloc (funcs->functions,
+ funcs->num_functions * sizeof (slang_function), (funcs->num_functions + 1) * sizeof (
+ slang_function));
+ if (funcs->functions == NULL)
+ {
+ slang_info_log_memory (C->L);
+ slang_function_destruct (&parsed_func);
+ return 0;
+ }
+ funcs->functions[funcs->num_functions] = parsed_func;
+ funcs->num_functions++;
+
+ /* return the newly parsed function */
+ *parsed_func_ret = funcs->functions + funcs->num_functions - 1;
+ }
+ else
+ {
+ /* TODO: check function return type qualifiers and specifiers */
+ if (definition)
+ {
+ /* destroy the existing function declaration and replace it with the new one */
+ if (found_func->body != NULL)
+ {
+ slang_info_log_error (C->L, "%s: function already has a body",
+ parsed_func.header.name);
+ slang_function_destruct (&parsed_func);
+ return 0;
+ }
+ slang_function_destruct (found_func);
+ *found_func = parsed_func;
+ }
+ else
+ {
+ /* another declaration of the same function prototype - ignore it */
+ slang_function_destruct (&parsed_func);
+ }
+
+ /* return the found function */
+ *parsed_func_ret = found_func;
+ }
+
+ /* assemble the parsed function */
+ if (definition)
+ {
+static int x = 0;
+static
+ slang_assembly_file file;
+ slang_assembly_name_space space;
+x++;
+if (x == 1)
+ slang_assembly_file_construct (&file);
+ space.funcs = funcs;
+ space.structs = structs;
+ space.vars = scope;
+if (x == 1)
+xxx_first (&file);
+ (**parsed_func_ret).address = file.count;
+ if (!_slang_assemble_function (&file, *parsed_func_ret, &space))
+ {
+ slang_assembly_file_destruct (&file);
+ return 0;
+ }
+if (slang_string_compare ("main", (**parsed_func_ret).header.name) == 0)
+{
+xxx_prolog (&file, (**parsed_func_ret).address);
+_slang_execute (&file);
+slang_assembly_file_destruct (&file);
+exit (0);
+}
+ }
+ return 1;
+}
+
+/* declaration */
+#define DECLARATION_FUNCTION_PROTOTYPE 1
+#define DECLARATION_INIT_DECLARATOR_LIST 2
+
+static int parse_declaration (slang_parse_ctx *C, slang_variable_scope *scope,
+ slang_struct_scope *structs, slang_function_scope *funcs)
+{
+ slang_function *dummy_func;
+
+ switch (*C->I++)
+ {
+ case DECLARATION_INIT_DECLARATOR_LIST:
+ if (!parse_init_declarator_list (C, scope, structs, funcs))
+ return 0;
+ break;
+ case DECLARATION_FUNCTION_PROTOTYPE:
+ if (!parse_function (C, 0, structs, funcs, scope, &dummy_func))
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+ return 1;
+}
+
+/* external declaration */
+#define EXTERNAL_NULL 0
+#define EXTERNAL_FUNCTION_DEFINITION 1
+#define EXTERNAL_DECLARATION 2
+
+static int parse_translation_unit (slang_parse_ctx *C, slang_translation_unit *unit)
+{
+ while (*C->I != EXTERNAL_NULL)
+ {
+ slang_function *func;
+
+ switch (*C->I++)
+ {
+ case EXTERNAL_FUNCTION_DEFINITION:
+ if (!parse_function (C, 1, &unit->structs, &unit->functions, &unit->globals, &func))
+ return 0;
+ break;
+ case EXTERNAL_DECLARATION:
+ if (!parse_declaration (C, &unit->globals, &unit->structs, &unit->functions))
+ return 0;
+ break;
+ default:
+ return 0;
+ }
+ }
+ C->I++;
+ return 1;
+}
+
+static int compile_binary (const byte *prod, slang_translation_unit *unit, slang_unit_type type,
+ slang_info_log *log, slang_translation_unit *builtins)
+{
+ slang_parse_ctx C;
+
+ /* set-up parse context */
+ C.I = prod;
+ C.L = log;
+ C.parsing_builtin = builtins == NULL;
+
+ if (!check_revision (&C))
+ return 0;
+
+ /* create translation unit object */
+ slang_translation_unit_construct (unit);
+ unit->type = type;
+
+ if (builtins != NULL)
+ {
+ /* link to built-in functions */
+ builtins[1].functions.outer_scope = &builtins[0].functions;
+ builtins[2].functions.outer_scope = &builtins[1].functions;
+ unit->functions.outer_scope = &builtins[2].functions;
+
+ /* link to built-in variables - core unit does not define any */
+ builtins[2].globals.outer_scope = &builtins[1].globals;
+ unit->globals.outer_scope = &builtins[2].globals;
+
+ /* link to built-in structure typedefs - only in common unit */
+ unit->structs.outer_scope = &builtins[1].structs;
+ }
+
+ /* parse translation unit */
+ if (!parse_translation_unit (&C, unit))
+ {
+ slang_translation_unit_destruct (unit);
+ return 0;
+ }
+
+ return 1;
+}
+
+static int compile_with_grammar (grammar id, const char *source, slang_translation_unit *unit,
+ slang_unit_type type, slang_info_log *log, slang_translation_unit *builtins)
+{
+ byte *prod;
+ unsigned int size, start, version;
+
+ /* retrieve version */
+ if (!_slang_preprocess_version (source, &version, &start, log))
+ return 0;
+
+ /* check the syntax */
+ if (!grammar_fast_check (id, (const byte *) source + start, &prod, &size, 65536))
+ {
+ char buf[1024];
+ unsigned int pos;
+ grammar_get_last_error ( (unsigned char*) buf, 1024, (int*) &pos);
+ slang_info_log_error (log, buf);
+ return 0;
+ }
+
+ if (!compile_binary (prod, unit, type, log, builtins))
+ {
+ grammar_alloc_free (prod);
+ return 0;
+ }
+
+ grammar_alloc_free (prod);
+ return 1;
+}
+
+static const char *slang_shader_syn =
+#include "library/slang_shader_syn.h"
+;
+/*
+static const byte slang_core_gc_bin[] = {
+#include "library/slang_core_gc_bin.h"
+};*/
+static const byte slang_core_gc[] = {
+#include "library/slang_core_gc.h"
+};
+
+static const byte slang_common_builtin_gc_bin[] = {
+#include "library/slang_common_builtin_gc_bin.h"
+};
+
+static const byte slang_fragment_builtin_gc_bin[] = {
+#include "library/slang_fragment_builtin_gc_bin.h"
+};
+
+static const byte slang_vertex_builtin_gc_bin[] = {
+#include "library/slang_vertex_builtin_gc_bin.h"
+};
+
+int _slang_compile (const char *source, slang_translation_unit *unit, slang_unit_type type,
+ slang_info_log *log)
+{
+ grammar id;
+ slang_translation_unit builtin_units[3];
+ slang_translation_unit *builtins = NULL;
+
+ /* load slang grammar */
+ id = grammar_load_from_text ((const byte *) slang_shader_syn);
+ if (id == 0)
+ {
+ char buf[1024];
+ unsigned int pos;
+ grammar_get_last_error ( (unsigned char*) buf, 1024, (int*) &pos);
+ slang_info_log_error (log, buf);
+ return 0;
+ }
+
+ /* set shader type - the syntax is slightly different for different shaders */
+ if (type == slang_unit_fragment_shader || type == slang_unit_fragment_builtin)
+ grammar_set_reg8 (id, (const byte *) "shader_type", 1);
+ else
+ grammar_set_reg8 (id, (const byte *) "shader_type", 2);
+
+ /* enable language extensions */
+ grammar_set_reg8 (id, (const byte *) "parsing_builtin", 1);
+
+ /* if parsing user-specified shader, load built-in library */
+ if (type == slang_unit_fragment_shader || type == slang_unit_vertex_shader)
+ {
+ /*if (!compile_binary (slang_core_gc_bin, builtin_units,
+ slang_unit_fragment_builtin, log, NULL))*/
+ if (!compile_with_grammar (id, (const char*) slang_core_gc, builtin_units, slang_unit_fragment_builtin,
+ log, NULL))
+ {
+ grammar_destroy (id);
+ return 0;
+ }
+ if (!compile_binary (slang_common_builtin_gc_bin, builtin_units + 1,
+ slang_unit_fragment_builtin, log, NULL))
+ {
+ slang_translation_unit_destruct (builtin_units);
+ grammar_destroy (id);
+ return 0;
+ }
+ if (type == slang_unit_fragment_shader)
+ {
+ if (!compile_binary (slang_fragment_builtin_gc_bin, builtin_units + 2,
+ slang_unit_fragment_builtin, log, NULL))
+ {
+ slang_translation_unit_destruct (builtin_units);
+ slang_translation_unit_destruct (builtin_units + 1);
+ grammar_destroy (id);
+ return 0;
+ }
+ }
+ else if (type == slang_unit_vertex_shader)
+ {
+ if (!compile_binary (slang_vertex_builtin_gc_bin, builtin_units + 2,
+ slang_unit_vertex_builtin, log, NULL))
+ {
+ slang_translation_unit_destruct (builtin_units);
+ slang_translation_unit_destruct (builtin_units + 1);
+ grammar_destroy (id);
+ return 0;
+ }
+ }
+
+ /* disable language extensions */
+ grammar_set_reg8 (id, (const byte *) "parsing_builtin", 0);
+ builtins = builtin_units;
+ }
+
+ /* compile the actual shader - pass-in built-in library for external shader */
+ if (!compile_with_grammar (id, source, unit, type, log, builtins))
+ {
+ if (type == slang_unit_fragment_shader || type == slang_unit_vertex_shader)
+ {
+ slang_translation_unit_destruct (builtin_units);
+ slang_translation_unit_destruct (builtin_units + 1);
+ slang_translation_unit_destruct (builtin_units + 2);
+ }
+ grammar_destroy (id);
+ return 0;
+ }
+
+ /* destroy built-in library */
+ if (type == slang_unit_fragment_shader || type == slang_unit_vertex_shader)
+ {
+ slang_translation_unit_destruct (builtin_units);
+ slang_translation_unit_destruct (builtin_units + 1);
+ slang_translation_unit_destruct (builtin_units + 2);
+ }
+ grammar_destroy (id);
+ return 1;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_compile.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_compile.h
new file mode 100644
index 000000000..a9a075c37
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_compile.h
@@ -0,0 +1,271 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#if !defined SLANG_COMPILE_H
+#define SLANG_COMPILE_H
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+typedef enum slang_type_qualifier_
+{
+ slang_qual_none,
+ slang_qual_const,
+ slang_qual_attribute,
+ slang_qual_varying,
+ slang_qual_uniform,
+ slang_qual_out,
+ slang_qual_inout,
+ slang_qual_fixedoutput, /* internal */
+ slang_qual_fixedinput /* internal */
+} slang_type_qualifier;
+
+typedef enum slang_type_specifier_type_
+{
+ slang_spec_void,
+ slang_spec_bool,
+ slang_spec_bvec2,
+ slang_spec_bvec3,
+ slang_spec_bvec4,
+ slang_spec_int,
+ slang_spec_ivec2,
+ slang_spec_ivec3,
+ slang_spec_ivec4,
+ slang_spec_float,
+ slang_spec_vec2,
+ slang_spec_vec3,
+ slang_spec_vec4,
+ slang_spec_mat2,
+ slang_spec_mat3,
+ slang_spec_mat4,
+ slang_spec_sampler1D,
+ slang_spec_sampler2D,
+ slang_spec_sampler3D,
+ slang_spec_samplerCube,
+ slang_spec_sampler1DShadow,
+ slang_spec_sampler2DShadow,
+ slang_spec_struct,
+ slang_spec_array
+} slang_type_specifier_type;
+
+slang_type_specifier_type slang_type_specifier_type_from_string (const char *);
+
+typedef struct slang_type_specifier_
+{
+ slang_type_specifier_type type;
+ struct slang_struct_ *_struct; /* spec_struct */
+ struct slang_type_specifier_ *_array; /* spec_array */
+} slang_type_specifier;
+
+void slang_type_specifier_construct (slang_type_specifier *);
+void slang_type_specifier_destruct (slang_type_specifier *);
+int slang_type_specifier_copy (slang_type_specifier *, const slang_type_specifier *);
+int slang_type_specifier_equal (const slang_type_specifier *, const slang_type_specifier *);
+
+typedef struct slang_fully_specified_type_
+{
+ slang_type_qualifier qualifier;
+ slang_type_specifier specifier;
+} slang_fully_specified_type;
+
+typedef struct slang_variable_scope_
+{
+ struct slang_variable_ *variables;
+ unsigned int num_variables;
+ struct slang_variable_scope_ *outer_scope;
+} slang_variable_scope;
+
+typedef enum slang_operation_type_
+{
+ slang_oper_none,
+ slang_oper_block_no_new_scope,
+ slang_oper_block_new_scope,
+ slang_oper_variable_decl,
+ slang_oper_asm,
+ slang_oper_break,
+ slang_oper_continue,
+ slang_oper_discard,
+ slang_oper_return,
+ slang_oper_expression,
+ slang_oper_if,
+ slang_oper_while,
+ slang_oper_do,
+ slang_oper_for,
+ slang_oper_void,
+ slang_oper_literal_bool,
+ slang_oper_literal_int,
+ slang_oper_literal_float,
+ slang_oper_identifier,
+ slang_oper_sequence,
+ slang_oper_assign,
+ slang_oper_addassign,
+ slang_oper_subassign,
+ slang_oper_mulassign,
+ slang_oper_divassign,
+ /*slang_oper_modassign,*/
+ /*slang_oper_lshassign,*/
+ /*slang_oper_rshassign,*/
+ /*slang_oper_orassign,*/
+ /*slang_oper_xorassign,*/
+ /*slang_oper_andassign,*/
+ slang_oper_select,
+ slang_oper_logicalor,
+ slang_oper_logicalxor,
+ slang_oper_logicaland,
+ /*slang_oper_bitor,*/
+ /*slang_oper_bitxor,*/
+ /*slang_oper_bitand,*/
+ slang_oper_equal,
+ slang_oper_notequal,
+ slang_oper_less,
+ slang_oper_greater,
+ slang_oper_lessequal,
+ slang_oper_greaterequal,
+ /*slang_oper_lshift,*/
+ /*slang_oper_rshift,*/
+ slang_oper_add,
+ slang_oper_subtract,
+ slang_oper_multiply,
+ slang_oper_divide,
+ /*slang_oper_modulus,*/
+ slang_oper_preincrement,
+ slang_oper_predecrement,
+ slang_oper_plus,
+ slang_oper_minus,
+ /*slang_oper_complement,*/
+ slang_oper_not,
+ slang_oper_subscript,
+ slang_oper_call,
+ slang_oper_field,
+ slang_oper_postincrement,
+ slang_oper_postdecrement
+} slang_operation_type;
+
+typedef struct slang_operation_
+{
+ slang_operation_type type;
+ struct slang_operation_ *children;
+ unsigned int num_children;
+ float literal; /* bool, literal_int, literal_float */
+ char *identifier; /* asm, identifier, call, field */
+ slang_variable_scope *locals;
+} slang_operation;
+
+int slang_operation_construct_a (slang_operation *);
+void slang_operation_destruct (slang_operation *);
+
+typedef struct slang_variable_
+{
+ slang_fully_specified_type type;
+ char *name;
+ slang_operation *array_size; /* spec_array */
+ slang_operation *initializer;
+ unsigned int address;
+} slang_variable;
+
+slang_variable *_slang_locate_variable (slang_variable_scope *scope, const char *name, int all);
+
+typedef struct slang_struct_scope_
+{
+ struct slang_struct_ *structs;
+ unsigned int num_structs;
+ struct slang_struct_scope_ *outer_scope;
+} slang_struct_scope;
+
+struct slang_struct_ *slang_struct_scope_find (slang_struct_scope *, const char *, int);
+
+typedef struct slang_struct_
+{
+ char *name;
+ slang_variable_scope *fields;
+ slang_struct_scope *structs;
+} slang_struct;
+
+int slang_struct_construct_a (slang_struct *);
+int slang_struct_copy (slang_struct *, const slang_struct *);
+
+typedef enum slang_function_kind_
+{
+ slang_func_ordinary,
+ slang_func_constructor,
+ slang_func_operator
+} slang_function_kind;
+
+typedef struct slang_function_
+{
+ slang_function_kind kind;
+ slang_variable header;
+ slang_variable_scope *parameters;
+ unsigned int param_count;
+ slang_operation *body;
+ unsigned int address;
+} slang_function;
+
+typedef struct slang_function_scope_
+{
+ slang_function *functions;
+ unsigned int num_functions;
+ struct slang_function_scope_ *outer_scope;
+} slang_function_scope;
+
+typedef enum slang_unit_type_
+{
+ slang_unit_fragment_shader,
+ slang_unit_vertex_shader,
+ slang_unit_fragment_builtin,
+ slang_unit_vertex_builtin
+} slang_unit_type;
+
+typedef struct slang_translation_unit_
+{
+ slang_variable_scope globals;
+ slang_function_scope functions;
+ slang_struct_scope structs;
+ slang_unit_type type;
+} slang_translation_unit;
+
+void slang_translation_unit_construct (slang_translation_unit *);
+void slang_translation_unit_destruct (slang_translation_unit *);
+
+typedef struct slang_info_log_
+{
+ char *text;
+ int dont_free_text;
+} slang_info_log;
+
+void slang_info_log_construct (slang_info_log *);
+void slang_info_log_destruct (slang_info_log *);
+int slang_info_log_error (slang_info_log *, const char *, ...);
+int slang_info_log_warning (slang_info_log *, const char *, ...);
+void slang_info_log_memory (slang_info_log *);
+
+int _slang_compile (const char *, slang_translation_unit *, slang_unit_type type, slang_info_log *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_execute.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_execute.c
new file mode 100755
index 000000000..d47f3eaca
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_execute.c
@@ -0,0 +1,352 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file slang_execute.c
+ * intermediate code interpreter
+ * \author Michal Krol
+ */
+
+#include "imports.h"
+#include "slang_utility.h"
+#include "slang_assemble.h"
+#include "slang_storage.h"
+#include "slang_execute.h"
+
+static void dump_instruction (FILE *f, slang_assembly *a, unsigned int i)
+{
+ fprintf (f, "%.5u:\t", i);
+
+ switch (a->type)
+ {
+ case slang_asm_none:
+ fprintf (f, "none");
+ break;
+ case slang_asm_float_copy:
+ fprintf (f, "float_copy\t%d, %d", a->param[0], a->param[1]);
+ break;
+ case slang_asm_float_move:
+ fprintf (f, "float_move\t%d, %d", a->param[0], a->param[1]);
+ break;
+ case slang_asm_float_push:
+ fprintf (f, "float_push\t%f", a->literal);
+ break;
+ case slang_asm_float_deref:
+ fprintf (f, "float_deref");
+ break;
+ case slang_asm_float_add:
+ fprintf (f, "float_add");
+ break;
+ case slang_asm_float_multiply:
+ fprintf (f, "float_multiply");
+ break;
+ case slang_asm_float_divide:
+ fprintf (f, "float_divide");
+ break;
+ case slang_asm_float_negate:
+ fprintf (f, "float_negate");
+ break;
+ case slang_asm_float_less:
+ fprintf (f, "float_less");
+ break;
+ case slang_asm_float_equal:
+ fprintf (f, "float_equal\t%d, %d", a->param[0], a->param[1]);
+ break;
+ case slang_asm_float_to_int:
+ fprintf (f, "float_to_int");
+ break;
+ case slang_asm_int_copy:
+ fprintf (f, "int_copy\t%d, %d", a->param[0], a->param[1]);
+ break;
+ case slang_asm_int_move:
+ fprintf (f, "int_move\t%d, %d", a->param[0], a->param[1]);
+ break;
+ case slang_asm_int_push:
+ fprintf (f, "int_push\t%d", (GLint) a->literal);
+ break;
+ case slang_asm_int_deref:
+ fprintf (f, "int_deref");
+ break;
+ case slang_asm_int_to_float:
+ fprintf (f, "int_to_float");
+ break;
+ case slang_asm_int_to_addr:
+ fprintf (f, "int_to_addr");
+ break;
+ case slang_asm_bool_copy:
+ fprintf (f, "bool_copy\t%d, %d", a->param[0], a->param[1]);
+ break;
+ case slang_asm_bool_move:
+ fprintf (f, "bool_move\t%d, %d", a->param[0], a->param[1]);
+ break;
+ case slang_asm_bool_push:
+ fprintf (f, "bool_push\t%d", a->literal != 0.0f);
+ break;
+ case slang_asm_bool_deref:
+ fprintf (f, "bool_deref");
+ break;
+ case slang_asm_addr_copy:
+ fprintf (f, "addr_copy");
+ break;
+ case slang_asm_addr_push:
+ fprintf (f, "addr_push\t%u", a->param[0]);
+ break;
+ case slang_asm_addr_deref:
+ fprintf (f, "addr_deref");
+ break;
+ case slang_asm_addr_add:
+ fprintf (f, "addr_add");
+ break;
+ case slang_asm_addr_multiply:
+ fprintf (f, "addr_multiply");
+ break;
+ case slang_asm_jump:
+ fprintf (f, "jump\t%u", a->param[0]);
+ break;
+ case slang_asm_jump_if_zero:
+ fprintf (f, "jump_if_zero\t%u", a->param[0]);
+ break;
+ case slang_asm_enter:
+ fprintf (f, "enter\t%u", a->param[0]);
+ break;
+ case slang_asm_leave:
+ fprintf (f, "leave");
+ break;
+ case slang_asm_local_alloc:
+ fprintf (f, "local_alloc\t%u", a->param[0]);
+ break;
+ case slang_asm_local_free:
+ fprintf (f, "local_free\t%u", a->param[0]);
+ break;
+ case slang_asm_local_addr:
+ fprintf (f, "local_addr\t%u, %u", a->param[0], a->param[1]);
+ break;
+ case slang_asm_call:
+ fprintf (f, "call\t%u", a->param[0]);
+ break;
+ case slang_asm_return:
+ fprintf (f, "return");
+ break;
+ case slang_asm_discard:
+ fprintf (f, "discard");
+ break;
+ case slang_asm_exit:
+ fprintf (f, "exit");
+ break;
+ default:
+ break;
+ }
+
+ fprintf (f, "\n");
+}
+
+static void dump (const slang_assembly_file *file)
+{
+ unsigned int i;
+ static unsigned int counter = 0;
+ FILE *f;
+ char filename[256];
+
+ counter++;
+ sprintf (filename, "~mesa-slang-assembly-dump-(%u).txt", counter);
+ f = fopen (filename, "w");
+ if (f == NULL)
+ return;
+
+ for (i = 0; i < file->count; i++)
+ dump_instruction (f, file->code + i, i);
+
+ fclose (f);
+}
+
+int _slang_execute (const slang_assembly_file *file)
+{
+ slang_machine mach;
+ FILE *f;
+
+ mach.ip = 0;
+ mach.sp = SLANG_MACHINE_STACK_SIZE;
+ mach.bp = 0;
+ mach.kill = 0;
+ mach.exit = 0;
+
+ /* assume 32-bit machine */
+ /* XXX why???, disabling the pointer size assertions here.
+ * See bug 4021.
+ */
+ static_assert(sizeof (GLfloat) == 4);
+ /*static_assert(sizeof (GLfloat *) == 4);*/
+ static_assert(sizeof (GLuint) == 4);
+ /*static_assert(sizeof (GLuint *) == 4);*/
+
+ dump (file);
+
+ f = fopen ("~mesa-slang-assembly-execution.txt", "w");
+
+ while (!mach.exit)
+ {
+ slang_assembly *a = file->code + mach.ip;
+ if (f != NULL)
+ {
+ unsigned int i;
+ dump_instruction (f, a, mach.ip);
+ fprintf (f, "\t\tsp=%u bp=%u\n", mach.sp, mach.bp);
+ for (i = mach.sp; i < SLANG_MACHINE_STACK_SIZE; i++)
+ fprintf (f, "\t%.5u\t%6f\t%u\n", i, mach.stack._float[i], mach.stack._addr[i]);
+ fflush (f);
+ }
+ mach.ip++;
+
+ switch (a->type)
+ {
+ case slang_asm_none:
+ break;
+ case slang_asm_float_copy:
+ case slang_asm_int_copy:
+ case slang_asm_bool_copy:
+ *(mach.stack._floatp[mach.sp + a->param[0] / 4] + a->param[1] / 4) =
+ mach.stack._float[mach.sp];
+ mach.sp++;
+ break;
+ case slang_asm_float_move:
+ case slang_asm_int_move:
+ case slang_asm_bool_move:
+ mach.stack._float[mach.sp + a->param[0] / 4] =
+ mach.stack._float[mach.sp + (mach.stack._addr[mach.sp] + a->param[1]) / 4];
+ break;
+ case slang_asm_float_push:
+ case slang_asm_int_push:
+ case slang_asm_bool_push:
+ mach.sp--;
+ mach.stack._float[mach.sp] = a->literal;
+ break;
+ case slang_asm_float_deref:
+ case slang_asm_int_deref:
+ case slang_asm_bool_deref:
+ mach.stack._float[mach.sp] = *mach.stack._floatp[mach.sp];
+ break;
+ case slang_asm_float_add:
+ mach.stack._float[mach.sp + 1] += mach.stack._float[mach.sp];
+ mach.sp++;
+ break;
+ case slang_asm_float_multiply:
+ mach.stack._float[mach.sp + 1] *= mach.stack._float[mach.sp];
+ mach.sp++;
+ break;
+ case slang_asm_float_divide:
+ mach.stack._float[mach.sp + 1] /= mach.stack._float[mach.sp];
+ mach.sp++;
+ break;
+ case slang_asm_float_negate:
+ mach.stack._float[mach.sp] = -mach.stack._float[mach.sp];
+ break;
+ case slang_asm_float_less:
+ mach.stack._float[mach.sp + 1] =
+ mach.stack._float[mach.sp + 1] < mach.stack._float[mach.sp] ? 1.0f : 0.0f;
+ mach.sp++;
+ break;
+ case slang_asm_float_equal:
+ mach.sp--;
+ mach.stack._float[mach.sp] = mach.stack._float[mach.sp + 1 + a->param[0] / 4] ==
+ mach.stack._float[mach.sp + 1 + a->param[1] / 4] ? 1.0f : 0.0f;
+ break;
+ case slang_asm_float_to_int:
+ mach.stack._float[mach.sp] = (GLfloat) (GLint) mach.stack._float[mach.sp];
+ break;
+ case slang_asm_int_to_float:
+ break;
+ case slang_asm_int_to_addr:
+ mach.stack._addr[mach.sp] = (GLuint) (GLint) mach.stack._float[mach.sp];
+ break;
+ case slang_asm_addr_copy:
+ *mach.stack._addrp[mach.sp + 1] = mach.stack._addr[mach.sp];
+ mach.sp++;
+ break;
+ case slang_asm_addr_push:
+ mach.sp--;
+ mach.stack._addr[mach.sp] = a->param[0];
+ break;
+ case slang_asm_addr_deref:
+ mach.stack._addr[mach.sp] = *mach.stack._addrp[mach.sp];
+ break;
+ case slang_asm_addr_add:
+ mach.stack._addr[mach.sp + 1] += mach.stack._addr[mach.sp];
+ mach.sp++;
+ break;
+ case slang_asm_addr_multiply:
+ mach.stack._addr[mach.sp + 1] *= mach.stack._addr[mach.sp];
+ mach.sp++;
+ break;
+ case slang_asm_jump:
+ mach.ip = a->param[0];
+ break;
+ case slang_asm_jump_if_zero:
+ if (mach.stack._float[mach.sp] == 0.0f)
+ mach.ip = a->param[0];
+ mach.sp++;
+ break;
+ case slang_asm_enter:
+ mach.sp--;
+ mach.stack._addr[mach.sp] = mach.bp;
+ mach.bp = mach.sp + a->param[0] / 4;
+ break;
+ case slang_asm_leave:
+ mach.bp = mach.stack._addr[mach.sp];
+ mach.sp++;
+ break;
+ case slang_asm_local_alloc:
+ mach.sp -= a->param[0] / 4;
+ break;
+ case slang_asm_local_free:
+ mach.sp += a->param[0] / 4;
+ break;
+ case slang_asm_local_addr:
+ mach.sp--;
+ mach.stack._addr[mach.sp] = (GLuint) mach.stack._addr + mach.bp * 4 -
+ (a->param[0] + a->param[1]) + 4;
+ break;
+ case slang_asm_call:
+ mach.sp--;
+ mach.stack._addr[mach.sp] = mach.ip;
+ mach.ip = a->param[0];
+ break;
+ case slang_asm_return:
+ mach.ip = mach.stack._addr[mach.sp];
+ mach.sp++;
+ break;
+ case slang_asm_discard:
+ mach.kill = 1;
+ break;
+ case slang_asm_exit:
+ mach.exit = 1;
+ break;
+ }
+ }
+
+ if (f != NULL)
+ fclose (f);
+
+ return 0;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_execute.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_execute.h
new file mode 100755
index 000000000..8ff1eb17c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_execute.h
@@ -0,0 +1,57 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#if !defined SLANG_EXECUTE_H
+#define SLANG_EXECUTE_H
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+#define SLANG_MACHINE_STACK_SIZE 1024
+
+typedef struct slang_machine_
+{
+ GLuint ip; /* instruction pointer, for flow control */
+ GLuint sp; /* stack pointer, for stack access */
+ GLuint bp; /* base pointer, for local variable access */
+ GLuint kill; /* discard the fragment */
+ GLuint exit; /* terminate the shader */
+ union stack_
+ {
+ GLfloat _float[SLANG_MACHINE_STACK_SIZE];
+ GLfloat *_floatp[SLANG_MACHINE_STACK_SIZE];
+ GLuint _addr[SLANG_MACHINE_STACK_SIZE];
+ GLuint *_addrp[SLANG_MACHINE_STACK_SIZE];
+ } stack;
+} slang_machine;
+
+int _slang_execute (const slang_assembly_file *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_mesa.cpp b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_mesa.cpp
new file mode 100755
index 000000000..3f437ee7d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_mesa.cpp
@@ -0,0 +1,144 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "slang_mesa.h"
+#include "Initialisation.h"
+#include "Include/Common.h"
+#include "Include/ShHandle.h"
+#include "Public/ShaderLang.h"
+
+
+class TGenericCompiler: public TCompiler
+{
+public:
+ TGenericCompiler (EShLanguage l, int dOptions): TCompiler(l, infoSink), debugOptions(dOptions)
+ {
+ }
+public:
+ virtual bool compile (TIntermNode *root)
+ {
+ haveValidObjectCode = true;
+ return haveValidObjectCode;
+ }
+ TInfoSink infoSink;
+ int debugOptions;
+};
+
+TCompiler *ConstructCompiler (EShLanguage language, int debugOptions)
+{
+ return new TGenericCompiler (language, debugOptions);
+}
+
+void DeleteCompiler (TCompiler *compiler)
+{
+ delete compiler;
+}
+
+class TGenericLinker: public TLinker
+{
+public:
+ TGenericLinker (EShExecutable e, int dOptions): TLinker(e, infoSink), debugOptions(dOptions)
+ {
+ }
+public:
+ bool link (TCompilerList &, TUniformMap *)
+ {
+ return true;
+ }
+ void getAttributeBindings (ShBindingTable const **t) const
+ {
+ }
+ TInfoSink infoSink;
+ int debugOptions;
+};
+
+TShHandleBase *ConstructLinker (EShExecutable executable, int debugOptions)
+{
+ return new TGenericLinker (executable, debugOptions);
+}
+
+void DeleteLinker (TShHandleBase *linker)
+{
+ delete linker;
+}
+
+class TUniformLinkedMap: public TUniformMap
+{
+public:
+ TUniformLinkedMap()
+ {
+ }
+public:
+ virtual int getLocation (const char *name)
+ {
+ return 0;
+ }
+};
+
+TUniformMap *ConstructUniformMap ()
+{
+ return new TUniformLinkedMap;
+}
+
+void DeleteUniformMap (TUniformMap *map)
+{
+ delete map;
+}
+
+
+namespace std
+{
+
+void _Xran ()
+{
+ /* XXX fix this under Linux */
+ /*_THROW(out_of_range, "invalid string position");*/
+}
+
+void _Xlen ()
+{
+ /* XXX fix this under Linux */
+ /*_THROW(length_error, "string too long");*/
+}
+
+}
+
+
+/* these functions link with extern "C" */
+
+int _mesa_isalnum (char c)
+{
+ return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9');
+}
+
+int _glslang_3dlabs_InitProcess ()
+{
+ return InitProcess () ? 1 : 0;
+}
+
+int _glslang_3dlabs_ShInitialize ()
+{
+ return ShInitialize () ? 1 : 0;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_mesa.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_mesa.h
new file mode 100755
index 000000000..41f79aa70
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_mesa.h
@@ -0,0 +1,36 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+int _mesa_isalnum (char);
+int _glslang_3dlabs_InitProcess ();
+int _glslang_3dlabs_ShInitialize ();
+
+#if defined __cplusplus
+}
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_preprocess.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_preprocess.c
new file mode 100755
index 000000000..b1f62ded3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_preprocess.c
@@ -0,0 +1,87 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file slang_preprocess.c
+ * slang preprocessor
+ * \author Michal Krol
+ */
+
+#include "imports.h"
+#include "grammar_mesa.h"
+#include "slang_compile.h"
+#include "slang_preprocess.h"
+
+static const char *slang_version_syn =
+#include "library/slang_version_syn.h"
+;
+
+int _slang_preprocess_version (const char *text, unsigned int *version, unsigned int *eaten,
+ slang_info_log *log)
+{
+ grammar id;
+ byte *prod, *I;
+ unsigned int size;
+
+ id = grammar_load_from_text ((const byte *) slang_version_syn);
+ if (id == 0)
+ {
+ char buf[1024];
+ unsigned int pos;
+ grammar_get_last_error ( (unsigned char*) buf, 1024, (int*) &pos);
+ slang_info_log_error (log, buf);
+ return 0;
+ }
+
+ if (!grammar_fast_check (id, (const byte *) text, &prod, &size, 8))
+ {
+ char buf[1024];
+ unsigned int pos;
+ grammar_get_last_error ( (unsigned char*) buf, 1024, (int*) &pos);
+ slang_info_log_error (log, buf);
+ grammar_destroy (id);
+ return 0;
+ }
+
+ grammar_destroy (id);
+
+ /* there can be multiple #version directives - grab the last one */
+ I = prod;
+ while (I < prod + size)
+ {
+ *version =
+ (unsigned int) I[0] +
+ (unsigned int) I[1] * 100;
+ *eaten =
+ ((unsigned int) I[2]) +
+ ((unsigned int) I[3] << 8) +
+ ((unsigned int) I[4] << 16) +
+ ((unsigned int) I[5] << 24);
+ I += 6;
+ }
+
+ grammar_alloc_free (prod);
+ return 1;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_preprocess.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_preprocess.h
new file mode 100755
index 000000000..7901e7858
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_preprocess.h
@@ -0,0 +1,39 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#if !defined SLANG_PREPROCESS_H
+#define SLANG_PREPROCESS_H
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+int _slang_preprocess_version (const char *, unsigned int *, unsigned int *, slang_info_log *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_storage.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_storage.c
new file mode 100755
index 000000000..3b2fda415
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_storage.c
@@ -0,0 +1,255 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file slang_storage.c
+ * slang variable storage
+ * \author Michal Krol
+ */
+
+#include "imports.h"
+#include "slang_utility.h"
+#include "slang_storage.h"
+#include "slang_assemble.h"
+
+/* slang_storage_array */
+
+void slang_storage_array_construct (slang_storage_array *arr)
+{
+ arr->type = slang_stor_aggregate;
+ arr->aggregate = NULL;
+ arr->length = 0;
+}
+
+void slang_storage_array_destruct (slang_storage_array *arr)
+{
+ if (arr->aggregate != NULL)
+ {
+ slang_storage_aggregate_destruct (arr->aggregate);
+ slang_alloc_free (arr->aggregate);
+ }
+}
+
+/* slang_storage_aggregate */
+
+void slang_storage_aggregate_construct (slang_storage_aggregate *agg)
+{
+ agg->arrays = NULL;
+ agg->count = 0;
+}
+
+void slang_storage_aggregate_destruct (slang_storage_aggregate *agg)
+{
+ unsigned int i;
+ for (i = 0; i < agg->count; i++)
+ slang_storage_array_destruct (agg->arrays + i);
+ slang_alloc_free (agg->arrays);
+}
+
+static slang_storage_array *slang_storage_aggregate_push_new (slang_storage_aggregate *agg)
+{
+ slang_storage_array *arr = NULL;
+ agg->arrays = (slang_storage_array *) slang_alloc_realloc (agg->arrays, agg->count * sizeof (
+ slang_storage_array), (agg->count + 1) * sizeof (slang_storage_array));
+ if (agg->arrays != NULL)
+ {
+ arr = agg->arrays + agg->count;
+ slang_storage_array_construct (arr);
+ agg->count++;
+ }
+ return arr;
+}
+
+/* _slang_aggregate_variable() */
+
+static int aggregate_vector (slang_storage_aggregate *agg, slang_storage_type basic_type,
+ unsigned int row_count)
+{
+ slang_storage_array *arr = slang_storage_aggregate_push_new (agg);
+ if (arr == NULL)
+ return 0;
+ arr->type = basic_type;
+ arr->length = row_count;
+ return 1;
+}
+
+static int aggregate_matrix (slang_storage_aggregate *agg, slang_storage_type basic_type,
+ unsigned int dimension)
+{
+ slang_storage_array *arr = slang_storage_aggregate_push_new (agg);
+ if (arr == NULL)
+ return 0;
+ arr->type = slang_stor_aggregate;
+ arr->length = dimension;
+ arr->aggregate = (slang_storage_aggregate *) slang_alloc_malloc (sizeof (
+ slang_storage_aggregate));
+ if (arr->aggregate == NULL)
+ return 0;
+ slang_storage_aggregate_construct (arr->aggregate);
+ if (!aggregate_vector (arr->aggregate, basic_type, dimension))
+ return 0;
+ return 1;
+}
+
+static int aggregate_variables (slang_storage_aggregate *agg, const slang_variable_scope *vars,
+ slang_function_scope *funcs, slang_struct_scope *structs)
+{
+ unsigned int i;
+ for (i = 0; i < vars->num_variables; i++)
+ if (!_slang_aggregate_variable (agg, &vars->variables[i].type.specifier,
+ vars->variables[i].array_size, funcs, structs))
+ return 0;
+ return 1;
+}
+
+int _slang_aggregate_variable (slang_storage_aggregate *agg, slang_type_specifier *spec,
+ slang_operation *array_size, slang_function_scope *funcs, slang_struct_scope *structs)
+{
+ switch (spec->type)
+ {
+ case slang_spec_bool:
+ return aggregate_vector (agg, slang_stor_bool, 1);
+ case slang_spec_bvec2:
+ return aggregate_vector (agg, slang_stor_bool, 2);
+ case slang_spec_bvec3:
+ return aggregate_vector (agg, slang_stor_bool, 3);
+ case slang_spec_bvec4:
+ return aggregate_vector (agg, slang_stor_bool, 4);
+ case slang_spec_int:
+ return aggregate_vector (agg, slang_stor_int, 1);
+ case slang_spec_ivec2:
+ return aggregate_vector (agg, slang_stor_int, 2);
+ case slang_spec_ivec3:
+ return aggregate_vector (agg, slang_stor_int, 3);
+ case slang_spec_ivec4:
+ return aggregate_vector (agg, slang_stor_int, 4);
+ case slang_spec_float:
+ return aggregate_vector (agg, slang_stor_float, 1);
+ case slang_spec_vec2:
+ return aggregate_vector (agg, slang_stor_float, 2);
+ case slang_spec_vec3:
+ return aggregate_vector (agg, slang_stor_float, 3);
+ case slang_spec_vec4:
+ return aggregate_vector (agg, slang_stor_float, 4);
+ case slang_spec_mat2:
+ return aggregate_matrix (agg, slang_stor_float, 2);
+ case slang_spec_mat3:
+ return aggregate_matrix (agg, slang_stor_float, 3);
+ case slang_spec_mat4:
+ return aggregate_matrix (agg, slang_stor_float, 4);
+ case slang_spec_sampler1D:
+ case slang_spec_sampler2D:
+ case slang_spec_sampler3D:
+ case slang_spec_samplerCube:
+ case slang_spec_sampler1DShadow:
+ case slang_spec_sampler2DShadow:
+ return aggregate_vector (agg, slang_stor_int, 1);
+ case slang_spec_struct:
+ return aggregate_variables (agg, spec->_struct->fields, funcs, structs);
+ case slang_spec_array:
+ {
+ slang_storage_array *arr;
+ slang_assembly_file file;
+ slang_assembly_flow_control flow;
+ slang_assembly_name_space space;
+ slang_assembly_local_info info;
+ slang_assembly_stack_info stk;
+
+ arr = slang_storage_aggregate_push_new (agg);
+ if (arr == NULL)
+ return 0;
+ arr->type = slang_stor_aggregate;
+ arr->aggregate = (slang_storage_aggregate *) slang_alloc_malloc (sizeof (
+ slang_storage_aggregate));
+ if (arr->aggregate == NULL)
+ return 0;
+ slang_storage_aggregate_construct (arr->aggregate);
+ if (!_slang_aggregate_variable (arr->aggregate, spec->_array, NULL, funcs, structs))
+ return 0;
+ slang_assembly_file_construct (&file);
+ space.funcs = funcs;
+ space.structs = structs;
+ /* XXX: vars! */
+ space.vars = NULL;
+ if (!_slang_assemble_operation (&file, array_size, 0, &flow, &space, &info, &stk))
+ {
+ slang_assembly_file_destruct (&file);
+ return 0;
+ }
+ /* TODO: evaluate array size */
+ slang_assembly_file_destruct (&file);
+ arr->length = 256;
+ }
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+/* _slang_sizeof_aggregate() */
+
+unsigned int _slang_sizeof_aggregate (const slang_storage_aggregate *agg)
+{
+ unsigned int i, size = 0;
+ for (i = 0; i < agg->count; i++)
+ {
+ unsigned int element_size;
+ if (agg->arrays[i].type == slang_stor_aggregate)
+ element_size = _slang_sizeof_aggregate (agg->arrays[i].aggregate);
+ else
+ element_size = sizeof (GLfloat);
+ size += element_size * agg->arrays[i].length;
+ }
+ return size;
+}
+
+/* _slang_flatten_aggregate () */
+
+int _slang_flatten_aggregate (slang_storage_aggregate *flat, const slang_storage_aggregate *agg)
+{
+ unsigned int i;
+ for (i = 0; i < agg->count; i++)
+ {
+ unsigned int j;
+ for (j = 0; j < agg->arrays[i].length; j++)
+ {
+ if (agg->arrays[i].type == slang_stor_aggregate)
+ {
+ if (!_slang_flatten_aggregate (flat, agg->arrays[i].aggregate))
+ return 0;
+ }
+ else
+ {
+ slang_storage_array *arr;
+ arr = slang_storage_aggregate_push_new (flat);
+ if (arr == NULL)
+ return 0;
+ arr->type = agg->arrays[i].type;
+ arr->length = 1;
+ }
+ }
+ }
+ return 1;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_storage.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_storage.h
new file mode 100755
index 000000000..77962c198
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_storage.h
@@ -0,0 +1,109 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#if !defined SLANG_STORAGE_H
+#define SLANG_STORAGE_H
+
+#include "slang_compile.h"
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+/*
+ Program variable data storage is kept completely transparent to the front-end compiler. It is
+ up to the back-end how the data is actually allocated. The slang_storage_type enum
+ provides the basic information about how the memory is interpreted. This abstract piece
+ of memory is called a data slot. A data slot of a particular type has a fixed size.
+
+ For now, only the three basic types are supported, that is bool, int and float. Other built-in
+ types like vector or matrix can easily be decomposed into a series of basic types.
+*/
+typedef enum slang_storage_type_
+{
+ slang_stor_aggregate,
+ slang_stor_bool,
+ slang_stor_int,
+ slang_stor_float
+} slang_storage_type;
+
+/*
+ The slang_storage_array structure groups data slots of the same type into an array. This
+ array has a fixed length. Arrays are required to have a size equal to the sum of sizes of its
+ elements. They are also required to support indirect addressing. That is, if B references
+ first data slot in the array, S is the size of the data slot and I is the integral index that
+ is not known at compile time, B+I*S references I-th data slot.
+
+ This structure is also used to break down built-in data types that are not supported directly.
+ Vectors, like vec3, are constructed from arrays of their basic types. Matrices are formed of
+ an array of column vectors, which are in turn processed as other vectors.
+*/
+typedef struct slang_storage_array_
+{
+ slang_storage_type type;
+ struct slang_storage_aggregate_ *aggregate; /* slang_stor_aggregate */
+ unsigned int length;
+} slang_storage_array;
+
+void slang_storage_array_construct (slang_storage_array *);
+void slang_storage_array_destruct (slang_storage_array *);
+
+/*
+ The slang_storage_aggregate structure relaxes the indirect addressing requirement for
+ slang_storage_array structure. Aggregates are always accessed statically - its member
+ addresses are well-known at compile time. For example, user-defined types are implemented as
+ aggregates. Aggregates can collect data of a different type.
+*/
+typedef struct slang_storage_aggregate_
+{
+ slang_storage_array *arrays;
+ unsigned int count;
+} slang_storage_aggregate;
+
+void slang_storage_aggregate_construct (slang_storage_aggregate *);
+void slang_storage_aggregate_destruct (slang_storage_aggregate *);
+
+int _slang_aggregate_variable (slang_storage_aggregate *, struct slang_type_specifier_ *,
+ struct slang_operation_ *, struct slang_function_scope_ *, slang_struct_scope *);
+
+/*
+ returns total size (in machine units) of the given aggregate
+ returns 0 on error
+*/
+unsigned int _slang_sizeof_aggregate (const slang_storage_aggregate *);
+
+/*
+ converts structured aggregate to a flat one, with arrays of generic type being
+ one-element long
+ returns 1 on success
+ returns 0 otherwise
+*/
+int _slang_flatten_aggregate (slang_storage_aggregate *, const slang_storage_aggregate *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_utility.c b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_utility.c
new file mode 100755
index 000000000..c07e161c8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_utility.c
@@ -0,0 +1,73 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file slang_utility.c
+ * slang utilities
+ * \author Michal Krol
+ */
+
+#include "imports.h"
+#include "slang_utility.h"
+
+void slang_alloc_free (void *ptr)
+{
+ _mesa_free (ptr);
+}
+
+void *slang_alloc_malloc (unsigned int size)
+{
+ return _mesa_malloc (size);
+}
+
+void *slang_alloc_realloc (void *ptr, unsigned int old_size, unsigned int size)
+{
+ return _mesa_realloc (ptr, old_size, size);
+}
+
+int slang_string_compare (const char *str1, const char *str2)
+{
+ return _mesa_strcmp (str1, str2);
+}
+
+char *slang_string_copy (char *dst, const char *src)
+{
+ return _mesa_strcpy (dst, src);
+}
+
+char *slang_string_concat (char *dst, const char *src)
+{
+ return _mesa_strcpy (dst + _mesa_strlen (dst), src);
+}
+
+char *slang_string_duplicate (const char *src)
+{
+ return _mesa_strdup (src);
+}
+
+unsigned int slang_string_length (const char *str)
+{
+ return _mesa_strlen (str);
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_utility.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_utility.h
new file mode 100755
index 000000000..2b040a444
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/slang_utility.h
@@ -0,0 +1,51 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#if !defined SLANG_UTILITY_H
+#define SLANG_UTILITY_H
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+/* Compile-time assertions. If the expression is zero, try to declare an
+ * array of size [-1] to cause compilation error.
+ */
+#define static_assert(expr) do { int _array[(expr) ? 1 : -1]; _array[0]; } while (0)
+
+void slang_alloc_free (void *);
+void *slang_alloc_malloc (unsigned int);
+void *slang_alloc_realloc (void *, unsigned int, unsigned int);
+int slang_string_compare (const char *, const char *);
+char *slang_string_copy (char *, const char *);
+char *slang_string_concat (char *, const char *);
+char *slang_string_duplicate (const char *);
+unsigned int slang_string_length (const char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/shader/slang/traverse_wrap.h b/nx-X11/extras/Mesa/src/mesa/shader/slang/traverse_wrap.h
new file mode 100755
index 000000000..f0cc76108
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/shader/slang/traverse_wrap.h
@@ -0,0 +1,112 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file traverse_wrap.h
+ * Handy TIntermTraverser class wrapper
+ * \author Michal Krol
+ */
+
+#ifndef __TRAVERSE_WRAP_H__
+#define __TRAVERSE_WRAP_H__
+
+#include "Include/intermediate.h"
+
+/*
+ The original TIntermTraverser class that is used to walk the intermediate tree,
+ is not very elegant in its design. One must define static functions with
+ appropriate prototypes, construct TIntermTraverser object, and set its member
+ function pointers to one's static functions. If traversal-specific data
+ is needed, a new class must be derived, and one must up-cast the object
+ passed as a parameter to the static function.
+
+ The class below eliminates this burden by providing virtual methods that are
+ to be overridden in the derived class.
+*/
+
+class traverse_wrap: private TIntermTraverser
+{
+private:
+ static void _visitSymbol (TIntermSymbol *S, TIntermTraverser *T) {
+ static_cast<traverse_wrap *> (T)->Symbol (*S);
+ }
+ static void _visitConstantUnion (TIntermConstantUnion *U, TIntermTraverser *T) {
+ static_cast<traverse_wrap *> (T)->ConstantUnion (*U);
+ }
+ static bool _visitBinary (bool preVisit, TIntermBinary *B, TIntermTraverser *T) {
+ return static_cast<traverse_wrap *> (T)->Binary (preVisit, *B);
+ }
+ static bool _visitUnary (bool preVisit, TIntermUnary *U, TIntermTraverser *T) {
+ return static_cast<traverse_wrap *> (T)->Unary (preVisit, *U);
+ }
+ static bool _visitSelection (bool preVisit, TIntermSelection *S, TIntermTraverser *T) {
+ return static_cast<traverse_wrap *> (T)->Selection (preVisit, *S);
+ }
+ static bool _visitAggregate (bool preVisit, TIntermAggregate *A, TIntermTraverser *T) {
+ return static_cast<traverse_wrap *> (T)->Aggregate (preVisit, *A);
+ }
+ static bool _visitLoop (bool preVisit, TIntermLoop *L, TIntermTraverser *T) {
+ return static_cast<traverse_wrap *> (T)->Loop (preVisit, *L);
+ }
+ static bool _visitBranch (bool preVisit, TIntermBranch *B, TIntermTraverser *T) {
+ return static_cast<traverse_wrap *> (T)->Branch (preVisit, *B);
+ }
+public:
+ traverse_wrap () {
+ visitSymbol = _visitSymbol;
+ visitConstantUnion = _visitConstantUnion;
+ visitBinary = _visitBinary;
+ visitUnary = _visitUnary;
+ visitSelection = _visitSelection;
+ visitAggregate = _visitAggregate;
+ visitLoop = _visitLoop;
+ visitBranch = _visitBranch;
+ }
+protected:
+ virtual void Symbol (const TIntermSymbol &) {
+ }
+ virtual void ConstantUnion (const TIntermConstantUnion &) {
+ }
+ virtual bool Binary (bool, const TIntermBinary &) {
+ return true;
+ }
+ virtual bool Unary (bool, const TIntermUnary &) {
+ return true;
+ }
+ virtual bool Selection (bool, const TIntermSelection &) {
+ return true;
+ }
+ virtual bool Aggregate (bool, const TIntermAggregate &) {
+ return true;
+ }
+ virtual bool Loop (bool, const TIntermLoop &) {
+ return true;
+ }
+ virtual bool Branch (bool, const TIntermBranch &) {
+ return true;
+ }
+};
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/sources b/nx-X11/extras/Mesa/src/mesa/sources
new file mode 100644
index 000000000..48c3ab543
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/sources
@@ -0,0 +1,335 @@
+### Lists of source files, included by Makefiles
+
+MAIN_SOURCES = \
+ main/api_arrayelt.c \
+ main/api_loopback.c \
+ main/api_noop.c \
+ main/api_validate.c \
+ main/accum.c \
+ main/attrib.c \
+ main/blend.c \
+ main/bufferobj.c \
+ main/buffers.c \
+ main/clip.c \
+ main/colortab.c \
+ main/context.c \
+ main/convolve.c \
+ main/debug.c \
+ main/depth.c \
+ main/dispatch.c \
+ main/dlist.c \
+ main/drawpix.c \
+ main/enable.c \
+ main/enums.c \
+ main/eval.c \
+ main/execmem.c \
+ main/extensions.c \
+ main/fbobject.c \
+ main/feedback.c \
+ main/fog.c \
+ main/framebuffer.c \
+ main/get.c \
+ main/getstring.c \
+ main/hash.c \
+ main/hint.c \
+ main/histogram.c \
+ main/image.c \
+ main/imports.c \
+ main/light.c \
+ main/lines.c \
+ main/matrix.c \
+ main/mm.c \
+ main/occlude.c \
+ main/pixel.c \
+ main/points.c \
+ main/polygon.c \
+ main/rastpos.c \
+ main/renderbuffer.c \
+ main/state.c \
+ main/stencil.c \
+ main/texcompress.c \
+ main/texcompress_s3tc.c \
+ main/texcompress_fxt1.c \
+ main/texenvprogram.c \
+ main/texformat.c \
+ main/teximage.c \
+ main/texrender.c \
+ main/texobj.c \
+ main/texstate.c \
+ main/texstore.c \
+ main/varray.c \
+ main/vtxfmt.c
+
+GLAPI_SOURCES = \
+ glapi/glapi.c \
+ glapi/glthread.c
+
+MATH_SOURCES = \
+ math/m_debug_clip.c \
+ math/m_debug_norm.c \
+ math/m_debug_xform.c \
+ math/m_eval.c \
+ math/m_matrix.c \
+ math/m_translate.c \
+ math/m_vector.c \
+ math/m_xform.c
+
+ARRAY_CACHE_SOURCES = \
+ array_cache/ac_context.c \
+ array_cache/ac_import.c
+
+SWRAST_SOURCES = \
+ swrast/s_fragprog_to_c.c \
+ swrast/s_aaline.c \
+ swrast/s_aatriangle.c \
+ swrast/s_accum.c \
+ swrast/s_alpha.c \
+ swrast/s_atifragshader.c \
+ swrast/s_bitmap.c \
+ swrast/s_blend.c \
+ swrast/s_buffers.c \
+ swrast/s_copypix.c \
+ swrast/s_context.c \
+ swrast/s_depth.c \
+ swrast/s_drawpix.c \
+ swrast/s_feedback.c \
+ swrast/s_fog.c \
+ swrast/s_imaging.c \
+ swrast/s_lines.c \
+ swrast/s_logic.c \
+ swrast/s_masking.c \
+ swrast/s_nvfragprog.c \
+ swrast/s_pixeltex.c \
+ swrast/s_points.c \
+ swrast/s_readpix.c \
+ swrast/s_span.c \
+ swrast/s_stencil.c \
+ swrast/s_tcc.c \
+ swrast/s_texture.c \
+ swrast/s_texstore.c \
+ swrast/s_triangle.c \
+ swrast/s_zoom.c
+
+SWRAST_SETUP_SOURCES = \
+ swrast_setup/ss_context.c \
+ swrast_setup/ss_triangle.c
+
+TNL_SOURCES = \
+ tnl/t_array_api.c \
+ tnl/t_array_import.c \
+ tnl/t_context.c \
+ tnl/t_pipeline.c \
+ tnl/t_save_api.c \
+ tnl/t_save_loopback.c \
+ tnl/t_save_playback.c \
+ tnl/t_vb_arbprogram.c \
+ tnl/t_vb_arbprogram_sse.c \
+ tnl/t_vb_program.c \
+ tnl/t_vb_render.c \
+ tnl/t_vb_texgen.c \
+ tnl/t_vb_texmat.c \
+ tnl/t_vb_vertex.c \
+ tnl/t_vb_cull.c \
+ tnl/t_vb_fog.c \
+ tnl/t_vb_light.c \
+ tnl/t_vb_normals.c \
+ tnl/t_vb_points.c \
+ tnl/t_vp_build.c \
+ tnl/t_vertex.c \
+ tnl/t_vertex_sse.c \
+ tnl/t_vertex_generic.c \
+ tnl/t_vtx_api.c \
+ tnl/t_vtx_generic.c \
+ tnl/t_vtx_x86.c \
+ tnl/t_vtx_eval.c \
+ tnl/t_vtx_exec.c
+
+
+
+SHADER_SOURCES = \
+ shader/arbfragparse.c \
+ shader/arbprogparse.c \
+ shader/arbprogram.c \
+ shader/arbvertparse.c \
+ shader/atifragshader.c \
+ shader/grammar/grammar_mesa.c \
+ shader/nvfragparse.c \
+ shader/nvprogram.c \
+ shader/nvvertexec.c \
+ shader/nvvertparse.c \
+ shader/program.c \
+ shader/shaderobjects.c \
+ shader/shaderobjects_3dlabs.c
+
+SLANG_C_SOURCES = \
+ shader/slang/MachineIndependent/preprocessor/atom.c \
+ shader/slang/MachineIndependent/preprocessor/cpp.c \
+ shader/slang/MachineIndependent/preprocessor/cppstruct.c \
+ shader/slang/MachineIndependent/preprocessor/memory.c \
+ shader/slang/MachineIndependent/preprocessor/scanner.c \
+ shader/slang/MachineIndependent/preprocessor/symbols.c \
+ shader/slang/MachineIndependent/preprocessor/tokens.c
+
+SLANG_CPP_SOURCES = \
+ shader/slang/slang_mesa.cpp \
+ shader/slang/MachineIndependent/Gen_glslang.cpp \
+ shader/slang/MachineIndependent/Gen_glslang_tab.cpp \
+ shader/slang/MachineIndependent/InfoSink.cpp \
+ shader/slang/MachineIndependent/Initialize.cpp \
+ shader/slang/MachineIndependent/Intermediate.cpp \
+ shader/slang/MachineIndependent/intermOut.cpp \
+ shader/slang/MachineIndependent/IntermTraverse.cpp \
+ shader/slang/MachineIndependent/parseConst.cpp \
+ shader/slang/MachineIndependent/ParseHelper.cpp \
+ shader/slang/MachineIndependent/PoolAlloc.cpp \
+ shader/slang/MachineIndependent/QualifierAlive.cpp \
+ shader/slang/MachineIndependent/RemoveTree.cpp \
+ shader/slang/MachineIndependent/ShaderLang.cpp \
+ shader/slang/MachineIndependent/SymbolTable.cpp \
+ shader/slang/OGLCompilersDLL/Initialisation.cpp \
+ shader/slang/OSDependent/Linux/ossource.cpp
+
+SLANG_SOURCES = \
+ shader/slang/slang_assemble.c \
+ shader/slang/slang_assemble_assignment.c \
+ shader/slang/slang_assemble_conditional.c \
+ shader/slang/slang_assemble_constructor.c \
+ shader/slang/slang_assemble_typeinfo.c \
+ shader/slang/slang_compile.c \
+ shader/slang/slang_execute.c \
+ shader/slang/slang_preprocess.c \
+ shader/slang/slang_storage.c \
+ shader/slang/slang_utility.c
+
+ASM_C_SOURCES = \
+ x86/common_x86.c \
+ x86/x86.c \
+ x86/3dnow.c \
+ x86/sse.c \
+ x86/rtasm/x86sse.c \
+ sparc/sparc.c \
+ ppc/common_ppc.c \
+ x86-64/x86-64.c
+
+X86_SOURCES = \
+ x86/common_x86_asm.S \
+ x86/x86_xform2.S \
+ x86/x86_xform3.S \
+ x86/x86_xform4.S \
+ x86/x86_cliptest.S \
+ x86/mmx_blend.S \
+ x86/3dnow_xform1.S \
+ x86/3dnow_xform2.S \
+ x86/3dnow_xform3.S \
+ x86/3dnow_xform4.S \
+ x86/3dnow_normal.S \
+ x86/sse_xform1.S \
+ x86/sse_xform2.S \
+ x86/sse_xform3.S \
+ x86/sse_xform4.S \
+ x86/sse_normal.S \
+ x86/read_rgba_span_x86.S \
+ tnl/t_vtx_x86_gcc.S
+
+X86_API = \
+ x86/glapi_x86.S
+
+X86-64_SOURCES = \
+ x86-64/xform4.S
+
+X86-64_API = \
+ x86-64/glapi_x86-64.S
+
+SPARC_SOURCES = \
+ sparc/clip.S \
+ sparc/norm.S \
+ sparc/xform.S
+
+SPARC_API = \
+ sparc/glapi_sparc.S
+
+COMMON_DRIVER_SOURCES = \
+ drivers/common/driverfuncs.c
+
+X11_DRIVER_SOURCES = \
+ drivers/x11/glxapi.c \
+ drivers/x11/fakeglx.c \
+ drivers/x11/xfonts.c \
+ drivers/x11/xm_api.c \
+ drivers/x11/xm_buffer.c \
+ drivers/x11/xm_dd.c \
+ drivers/x11/xm_line.c \
+ drivers/x11/xm_span.c \
+ drivers/x11/xm_tri.c
+
+OSMESA_DRIVER_SOURCES = \
+ drivers/osmesa/osmesa.c
+
+GLIDE_DRIVER_SOURCES = \
+ drivers/glide/fxapi.c \
+ drivers/glide/fxdd.c \
+ drivers/glide/fxddspan.c \
+ drivers/glide/fxddtex.c \
+ drivers/glide/fxsetup.c \
+ drivers/glide/fxtexman.c \
+ drivers/glide/fxtris.c \
+ drivers/glide/fxvb.c \
+ drivers/glide/fxglidew.c \
+ drivers/glide/fxg.c
+
+SVGA_DRIVER_SOURCES = \
+ drivers/svga/svgamesa.c \
+ drivers/svga/svgamesa8.c \
+ drivers/svga/svgamesa15.c \
+ drivers/svga/svgamesa16.c \
+ drivers/svga/svgamesa24.c \
+ drivers/svga/svgamesa32.c
+
+FBDEV_DRIVER_SOURCES = \
+ drivers/fbdev/glfbdev.c
+
+
+### All the core C sources
+
+CORE_SOURCES = \
+ $(MAIN_SOURCES) \
+ $(GLAPI_SOURCES) \
+ $(MATH_SOURCES) \
+ $(ARRAY_CACHE_SOURCES) \
+ $(TNL_SOURCES) \
+ $(SHADER_SOURCES) \
+ $(SWRAST_SOURCES) \
+ $(SWRAST_SETUP_SOURCES) \
+ $(ASM_C_SOURCES) \
+ $(SLANG_SOURCES)
+
+# $(SLANG_C_SOURCES)
+
+
+### Object files
+
+#CORE_OBJECTS = $(CORE_SOURCES:.c=.o) $(SLANG_CPP_SOURCES:.cpp=.o)
+CORE_OBJECTS = $(CORE_SOURCES:.c=.o)
+
+OSMESA_DRIVER_OBJECTS = $(OSMESA_DRIVER_SOURCES:.c=.o)
+
+COMMON_DRIVER_OBJECTS = $(COMMON_DRIVER_SOURCES:.c=.o)
+
+
+
+### Include directories
+
+INCLUDE_DIRS = \
+ -I$(TOP)/include \
+ -I$(TOP)/src/mesa \
+ -I$(TOP)/src/mesa/main \
+ -I$(TOP)/src/mesa/glapi \
+ -I$(TOP)/src/mesa/math \
+ -I$(TOP)/src/mesa/tnl \
+ -I$(TOP)/src/mesa/shader \
+ -I$(TOP)/src/mesa/shader/grammar \
+ -I$(TOP)/src/mesa/shader/slang \
+ -I$(TOP)/src/mesa/shader/slang/OSDependent/Linux \
+ -I$(TOP)/src/mesa/shader/slang/OGLCompilersDLL \
+ -I$(TOP)/src/mesa/swrast \
+ -I$(TOP)/src/mesa/swrast_setup
diff --git a/nx-X11/extras/Mesa/src/mesa/sparc/clip.S b/nx-X11/extras/Mesa/src/mesa/sparc/clip.S
new file mode 100644
index 000000000..58c228ed1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/sparc/clip.S
@@ -0,0 +1,243 @@
+/*
+ * Clip testing in SPARC assembly
+ */
+
+#if __arch64__
+#define LDPTR ldx
+#define V4F_DATA 0x00
+#define V4F_START 0x08
+#define V4F_COUNT 0x10
+#define V4F_STRIDE 0x14
+#define V4F_SIZE 0x18
+#define V4F_FLAGS 0x1c
+#else
+#define LDPTR ld
+#define V4F_DATA 0x00
+#define V4F_START 0x04
+#define V4F_COUNT 0x08
+#define V4F_STRIDE 0x0c
+#define V4F_SIZE 0x10
+#define V4F_FLAGS 0x14
+#endif
+
+#define VEC_SIZE_1 1
+#define VEC_SIZE_2 3
+#define VEC_SIZE_3 7
+#define VEC_SIZE_4 15
+
+#if defined(SVR4) || defined(__SVR4) || defined(__svr4__)
+ /* Solaris requires this for 64-bit. */
+ .register %g2, #scratch
+ .register %g3, #scratch
+ .register %g7, #scratch
+#endif
+
+ .text
+ .align 64
+
+one_dot_zero:
+ .word 0x3f800000 /* 1.0f */
+
+ /* This trick is shamelessly stolen from the x86
+ * Mesa asm. Very clever, and we can do it too
+ * since we have the necessary add with carry
+ * instructions on Sparc.
+ */
+clip_table:
+ .byte 0, 1, 0, 2, 4, 5, 4, 6
+ .byte 0, 1, 0, 2, 8, 9, 8, 10
+ .byte 32, 33, 32, 34, 36, 37, 36, 38
+ .byte 32, 33, 32, 34, 40, 41, 40, 42
+ .byte 0, 1, 0, 2, 4, 5, 4, 6
+ .byte 0, 1, 0, 2, 8, 9, 8, 10
+ .byte 16, 17, 16, 18, 20, 21, 20, 22
+ .byte 16, 17, 16, 18, 24, 25, 24, 26
+ .byte 63, 61, 63, 62, 55, 53, 55, 54
+ .byte 63, 61, 63, 62, 59, 57, 59, 58
+ .byte 47, 45, 47, 46, 39, 37, 39, 38
+ .byte 47, 45, 47, 46, 43, 41, 43, 42
+ .byte 63, 61, 63, 62, 55, 53, 55, 54
+ .byte 63, 61, 63, 62, 59, 57, 59, 58
+ .byte 31, 29, 31, 30, 23, 21, 23, 22
+ .byte 31, 29, 31, 30, 27, 25, 27, 26
+
+/* GLvector4f *clip_vec, GLvector4f *proj_vec,
+ GLubyte clipMask[], GLubyte *orMask, GLubyte *andMask */
+
+ .align 64
+__pc_tramp:
+ retl
+ nop
+
+ .globl _mesa_sparc_cliptest_points4
+_mesa_sparc_cliptest_points4:
+ save %sp, -64, %sp
+ call __pc_tramp
+ sub %o7, (. - one_dot_zero - 4), %g1
+ ld [%g1 + 0x0], %f4
+ add %g1, 0x4, %g1
+
+ ld [%i0 + V4F_STRIDE], %l1
+ ld [%i0 + V4F_COUNT], %g7
+ LDPTR [%i0 + V4F_START], %i0
+ LDPTR [%i1 + V4F_START], %i5
+ ldub [%i3], %g2
+ ldub [%i4], %g3
+ sll %g3, 8, %g3
+ or %g2, %g3, %g2
+
+ ld [%i1 + V4F_FLAGS], %g3
+ or %g3, VEC_SIZE_4, %g3
+ st %g3, [%i1 + V4F_FLAGS]
+ mov 3, %g3
+ st %g3, [%i1 + V4F_SIZE]
+ st %g7, [%i1 + V4F_COUNT]
+ clr %l2
+ clr %l0
+
+ /* l0: i
+ * g7: count
+ * l1: stride
+ * l2: c
+ * g2: (tmpAndMask << 8) | tmpOrMask
+ * g1: clip_table
+ * i0: from[stride][i]
+ * i2: clipMask
+ * i5: vProj[4][i]
+ */
+
+1: ld [%i0 + 0x0c], %f3 ! LSU Group
+ ld [%i0 + 0x0c], %g5 ! LSU Group
+ ld [%i0 + 0x08], %g4 ! LSU Group
+ fdivs %f4, %f3, %f8 ! FGM
+ addcc %g5, %g5, %g5 ! IEU1 Group
+ addx %g0, 0x0, %g3 ! IEU1 Group
+ addcc %g4, %g4, %g4 ! IEU1 Group
+ addx %g3, %g3, %g3 ! IEU1 Group
+ subcc %g5, %g4, %g0 ! IEU1 Group
+ ld [%i0 + 0x04], %g4 ! LSU Group
+ addx %g3, %g3, %g3 ! IEU1 Group
+ addcc %g4, %g4, %g4 ! IEU1 Group
+ addx %g3, %g3, %g3 ! IEU1 Group
+ subcc %g5, %g4, %g0 ! IEU1 Group
+ ld [%i0 + 0x00], %g4 ! LSU Group
+ addx %g3, %g3, %g3 ! IEU1 Group
+ addcc %g4, %g4, %g4 ! IEU1 Group
+ addx %g3, %g3, %g3 ! IEU1 Group
+ subcc %g5, %g4, %g0 ! IEU1 Group
+ addx %g3, %g3, %g3 ! IEU1 Group
+ ldub [%g1 + %g3], %g3 ! LSU Group
+ cmp %g3, 0 ! IEU1 Group, stall
+ be 2f ! CTI
+ stb %g3, [%i2] ! LSU
+ sll %g3, 8, %g4 ! IEU1 Group
+ add %l2, 1, %l2 ! IEU0
+ st %g0, [%i5 + 0x00] ! LSU
+ or %g4, 0xff, %g4 ! IEU0 Group
+ or %g2, %g3, %g2 ! IEU1
+ st %g0, [%i5 + 0x04] ! LSU
+ and %g2, %g4, %g2 ! IEU0 Group
+ st %g0, [%i5 + 0x08] ! LSU
+ b 3f ! CTI
+ st %f4, [%i5 + 0x0c] ! LSU Group
+2: ld [%i0 + 0x00], %f0 ! LSU Group
+ ld [%i0 + 0x04], %f1 ! LSU Group
+ ld [%i0 + 0x08], %f2 ! LSU Group
+ fmuls %f0, %f8, %f0 ! FGM
+ st %f0, [%i5 + 0x00] ! LSU Group
+ fmuls %f1, %f8, %f1 ! FGM
+ st %f1, [%i5 + 0x04] ! LSU Group
+ fmuls %f2, %f8, %f2 ! FGM
+ st %f2, [%i5 + 0x08] ! LSU Group
+ st %f8, [%i5 + 0x0c] ! LSU Group
+3: add %i5, 0x10, %i5 ! IEU1
+ add %l0, 1, %l0 ! IEU0 Group
+ add %i2, 1, %i2 ! IEU0 Group
+ cmp %l0, %g7 ! IEU1 Group
+ bne 1b ! CTI
+ add %i0, %l1, %i0 ! IEU0 Group
+ stb %g2, [%i3] ! LSU
+ srl %g2, 8, %g3 ! IEU0 Group
+ cmp %l2, %g7 ! IEU1 Group
+ bl,a 1f ! CTI
+ clr %g3 ! IEU0
+1: stb %g3, [%i4] ! LSU Group
+ ret ! CTI Group
+ restore %i1, 0x0, %o0
+
+ .globl _mesa_sparc_cliptest_points4_np
+_mesa_sparc_cliptest_points4_np:
+ save %sp, -64, %sp
+
+ call __pc_tramp
+ sub %o7, (. - one_dot_zero - 4), %g1
+ add %g1, 0x4, %g1
+
+ ld [%i0 + V4F_STRIDE], %l1
+ ld [%i0 + V4F_COUNT], %g7
+ LDPTR [%i0 + V4F_START], %i0
+ LDPTR [%i1 + V4F_START], %i5
+ ldub [%i3], %g2
+ ldub [%i4], %g3
+ sll %g3, 8, %g3
+ or %g2, %g3, %g2
+
+ ld [%i1 + V4F_FLAGS], %g3
+ or %g3, VEC_SIZE_4, %g3
+ st %g3, [%i1 + V4F_FLAGS]
+ mov 3, %g3
+ st %g3, [%i1 + V4F_SIZE]
+ st %g7, [%i1 + V4F_COUNT]
+ clr %l2
+ clr %l0
+
+ /* l0: i
+ * g7: count
+ * l1: stride
+ * l2: c
+ * g2: (tmpAndMask << 8) | tmpOrMask
+ * g1: clip_table
+ * i0: from[stride][i]
+ * i2: clipMask
+ */
+
+1: ld [%i0 + 0x0c], %g5 ! LSU Group
+ ld [%i0 + 0x08], %g4 ! LSU Group
+ addcc %g5, %g5, %g5 ! IEU1 Group
+ addx %g0, 0x0, %g3 ! IEU1 Group
+ addcc %g4, %g4, %g4 ! IEU1 Group
+ addx %g3, %g3, %g3 ! IEU1 Group
+ subcc %g5, %g4, %g0 ! IEU1 Group
+ ld [%i0 + 0x04], %g4 ! LSU Group
+ addx %g3, %g3, %g3 ! IEU1 Group
+ addcc %g4, %g4, %g4 ! IEU1 Group
+ addx %g3, %g3, %g3 ! IEU1 Group
+ subcc %g5, %g4, %g0 ! IEU1 Group
+ ld [%i0 + 0x00], %g4 ! LSU Group
+ addx %g3, %g3, %g3 ! IEU1 Group
+ addcc %g4, %g4, %g4 ! IEU1 Group
+ addx %g3, %g3, %g3 ! IEU1 Group
+ subcc %g5, %g4, %g0 ! IEU1 Group
+ addx %g3, %g3, %g3 ! IEU1 Group
+ ldub [%g1 + %g3], %g3 ! LSU Group
+ cmp %g3, 0 ! IEU1 Group, stall
+ be 2f ! CTI
+ stb %g3, [%i2] ! LSU
+ sll %g3, 8, %g4 ! IEU1 Group
+ add %l2, 1, %l2 ! IEU0
+ or %g4, 0xff, %g4 ! IEU0 Group
+ or %g2, %g3, %g2 ! IEU1
+ and %g2, %g4, %g2 ! IEU0 Group
+2: add %l0, 1, %l0 ! IEU0 Group
+ add %i2, 1, %i2 ! IEU0 Group
+ cmp %l0, %g7 ! IEU1 Group
+ bne 1b ! CTI
+ add %i0, %l1, %i0 ! IEU0 Group
+ stb %g2, [%i3] ! LSU
+ srl %g2, 8, %g3 ! IEU0 Group
+ cmp %l2, %g7 ! IEU1 Group
+ bl,a 1f ! CTI
+ clr %g3 ! IEU0
+1: stb %g3, [%i4] ! LSU Group
+ ret ! CTI Group
+ restore %i1, 0x0, %o0
diff --git a/nx-X11/extras/Mesa/src/mesa/sparc/glapi_sparc.S b/nx-X11/extras/Mesa/src/mesa/sparc/glapi_sparc.S
new file mode 100644
index 000000000..175a2819f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/sparc/glapi_sparc.S
@@ -0,0 +1,1884 @@
+/* DO NOT EDIT - This file generated automatically by gl_SPARC_asm.py (from Mesa) script */
+
+/*
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * BRIAN PAUL, IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "glapioffsets.h"
+
+#ifdef __arch64__
+# define GL_STUB(fn,off) \
+fn: \
+ sethi %hi(0x00000000), %g4 ; \
+ sethi %hi(0x00000000), %g1 ; \
+ or %g4, %lo(0x00000000), %g4 ; \
+ or %g1, %lo(0x00000000), %g1 ; \
+ sllx %g4, 32, %g4 ; \
+ ldx [%g1 + %g4], %g1 ; \
+ sethi %hi(8 * off), %g4 ; \
+ or %g4, %lo(8 * off), %g4 ; \
+ ldx [%g1 + %g4], %g5 ; \
+ jmpl %g5, %g0 ; \
+ nop
+#else
+# define GL_STUB(fn,off) \
+fn: \
+ sethi %hi(0x00000000), %g1 ; \
+ ld [%g1 + %lo(0x00000000)], %g1 ; \
+ ld [%g1 + (4 * off)], %g5 ; \
+ jmpl %g5, %g0 ; \
+ nop
+#endif
+
+#define GL_STUB_ALIAS(fn,alias) fn = alias
+
+.text
+.align 32
+ .globl __glapi_sparc_icache_flush ; .type __glapi_sparc_icache_flush,#function
+__glapi_sparc_icache_flush: /* %o0 = insn_addr */
+ flush %o0
+ retl
+ nop
+
+.data
+.align 64
+
+ .globl glNewList ; .type glNewList,#function
+ .globl glEndList ; .type glEndList,#function
+ .globl glCallList ; .type glCallList,#function
+ .globl glCallLists ; .type glCallLists,#function
+ .globl glDeleteLists ; .type glDeleteLists,#function
+ .globl glGenLists ; .type glGenLists,#function
+ .globl glListBase ; .type glListBase,#function
+ .globl glBegin ; .type glBegin,#function
+ .globl glBitmap ; .type glBitmap,#function
+ .globl glColor3b ; .type glColor3b,#function
+ .globl glColor3bv ; .type glColor3bv,#function
+ .globl glColor3d ; .type glColor3d,#function
+ .globl glColor3dv ; .type glColor3dv,#function
+ .globl glColor3f ; .type glColor3f,#function
+ .globl glColor3fv ; .type glColor3fv,#function
+ .globl glColor3i ; .type glColor3i,#function
+ .globl glColor3iv ; .type glColor3iv,#function
+ .globl glColor3s ; .type glColor3s,#function
+ .globl glColor3sv ; .type glColor3sv,#function
+ .globl glColor3ub ; .type glColor3ub,#function
+ .globl glColor3ubv ; .type glColor3ubv,#function
+ .globl glColor3ui ; .type glColor3ui,#function
+ .globl glColor3uiv ; .type glColor3uiv,#function
+ .globl glColor3us ; .type glColor3us,#function
+ .globl glColor3usv ; .type glColor3usv,#function
+ .globl glColor4b ; .type glColor4b,#function
+ .globl glColor4bv ; .type glColor4bv,#function
+ .globl glColor4d ; .type glColor4d,#function
+ .globl glColor4dv ; .type glColor4dv,#function
+ .globl glColor4f ; .type glColor4f,#function
+ .globl glColor4fv ; .type glColor4fv,#function
+ .globl glColor4i ; .type glColor4i,#function
+ .globl glColor4iv ; .type glColor4iv,#function
+ .globl glColor4s ; .type glColor4s,#function
+ .globl glColor4sv ; .type glColor4sv,#function
+ .globl glColor4ub ; .type glColor4ub,#function
+ .globl glColor4ubv ; .type glColor4ubv,#function
+ .globl glColor4ui ; .type glColor4ui,#function
+ .globl glColor4uiv ; .type glColor4uiv,#function
+ .globl glColor4us ; .type glColor4us,#function
+ .globl glColor4usv ; .type glColor4usv,#function
+ .globl glEdgeFlag ; .type glEdgeFlag,#function
+ .globl glEdgeFlagv ; .type glEdgeFlagv,#function
+ .globl glEnd ; .type glEnd,#function
+ .globl glIndexd ; .type glIndexd,#function
+ .globl glIndexdv ; .type glIndexdv,#function
+ .globl glIndexf ; .type glIndexf,#function
+ .globl glIndexfv ; .type glIndexfv,#function
+ .globl glIndexi ; .type glIndexi,#function
+ .globl glIndexiv ; .type glIndexiv,#function
+ .globl glIndexs ; .type glIndexs,#function
+ .globl glIndexsv ; .type glIndexsv,#function
+ .globl glNormal3b ; .type glNormal3b,#function
+ .globl glNormal3bv ; .type glNormal3bv,#function
+ .globl glNormal3d ; .type glNormal3d,#function
+ .globl glNormal3dv ; .type glNormal3dv,#function
+ .globl glNormal3f ; .type glNormal3f,#function
+ .globl glNormal3fv ; .type glNormal3fv,#function
+ .globl glNormal3i ; .type glNormal3i,#function
+ .globl glNormal3iv ; .type glNormal3iv,#function
+ .globl glNormal3s ; .type glNormal3s,#function
+ .globl glNormal3sv ; .type glNormal3sv,#function
+ .globl glRasterPos2d ; .type glRasterPos2d,#function
+ .globl glRasterPos2dv ; .type glRasterPos2dv,#function
+ .globl glRasterPos2f ; .type glRasterPos2f,#function
+ .globl glRasterPos2fv ; .type glRasterPos2fv,#function
+ .globl glRasterPos2i ; .type glRasterPos2i,#function
+ .globl glRasterPos2iv ; .type glRasterPos2iv,#function
+ .globl glRasterPos2s ; .type glRasterPos2s,#function
+ .globl glRasterPos2sv ; .type glRasterPos2sv,#function
+ .globl glRasterPos3d ; .type glRasterPos3d,#function
+ .globl glRasterPos3dv ; .type glRasterPos3dv,#function
+ .globl glRasterPos3f ; .type glRasterPos3f,#function
+ .globl glRasterPos3fv ; .type glRasterPos3fv,#function
+ .globl glRasterPos3i ; .type glRasterPos3i,#function
+ .globl glRasterPos3iv ; .type glRasterPos3iv,#function
+ .globl glRasterPos3s ; .type glRasterPos3s,#function
+ .globl glRasterPos3sv ; .type glRasterPos3sv,#function
+ .globl glRasterPos4d ; .type glRasterPos4d,#function
+ .globl glRasterPos4dv ; .type glRasterPos4dv,#function
+ .globl glRasterPos4f ; .type glRasterPos4f,#function
+ .globl glRasterPos4fv ; .type glRasterPos4fv,#function
+ .globl glRasterPos4i ; .type glRasterPos4i,#function
+ .globl glRasterPos4iv ; .type glRasterPos4iv,#function
+ .globl glRasterPos4s ; .type glRasterPos4s,#function
+ .globl glRasterPos4sv ; .type glRasterPos4sv,#function
+ .globl glRectd ; .type glRectd,#function
+ .globl glRectdv ; .type glRectdv,#function
+ .globl glRectf ; .type glRectf,#function
+ .globl glRectfv ; .type glRectfv,#function
+ .globl glRecti ; .type glRecti,#function
+ .globl glRectiv ; .type glRectiv,#function
+ .globl glRects ; .type glRects,#function
+ .globl glRectsv ; .type glRectsv,#function
+ .globl glTexCoord1d ; .type glTexCoord1d,#function
+ .globl glTexCoord1dv ; .type glTexCoord1dv,#function
+ .globl glTexCoord1f ; .type glTexCoord1f,#function
+ .globl glTexCoord1fv ; .type glTexCoord1fv,#function
+ .globl glTexCoord1i ; .type glTexCoord1i,#function
+ .globl glTexCoord1iv ; .type glTexCoord1iv,#function
+ .globl glTexCoord1s ; .type glTexCoord1s,#function
+ .globl glTexCoord1sv ; .type glTexCoord1sv,#function
+ .globl glTexCoord2d ; .type glTexCoord2d,#function
+ .globl glTexCoord2dv ; .type glTexCoord2dv,#function
+ .globl glTexCoord2f ; .type glTexCoord2f,#function
+ .globl glTexCoord2fv ; .type glTexCoord2fv,#function
+ .globl glTexCoord2i ; .type glTexCoord2i,#function
+ .globl glTexCoord2iv ; .type glTexCoord2iv,#function
+ .globl glTexCoord2s ; .type glTexCoord2s,#function
+ .globl glTexCoord2sv ; .type glTexCoord2sv,#function
+ .globl glTexCoord3d ; .type glTexCoord3d,#function
+ .globl glTexCoord3dv ; .type glTexCoord3dv,#function
+ .globl glTexCoord3f ; .type glTexCoord3f,#function
+ .globl glTexCoord3fv ; .type glTexCoord3fv,#function
+ .globl glTexCoord3i ; .type glTexCoord3i,#function
+ .globl glTexCoord3iv ; .type glTexCoord3iv,#function
+ .globl glTexCoord3s ; .type glTexCoord3s,#function
+ .globl glTexCoord3sv ; .type glTexCoord3sv,#function
+ .globl glTexCoord4d ; .type glTexCoord4d,#function
+ .globl glTexCoord4dv ; .type glTexCoord4dv,#function
+ .globl glTexCoord4f ; .type glTexCoord4f,#function
+ .globl glTexCoord4fv ; .type glTexCoord4fv,#function
+ .globl glTexCoord4i ; .type glTexCoord4i,#function
+ .globl glTexCoord4iv ; .type glTexCoord4iv,#function
+ .globl glTexCoord4s ; .type glTexCoord4s,#function
+ .globl glTexCoord4sv ; .type glTexCoord4sv,#function
+ .globl glVertex2d ; .type glVertex2d,#function
+ .globl glVertex2dv ; .type glVertex2dv,#function
+ .globl glVertex2f ; .type glVertex2f,#function
+ .globl glVertex2fv ; .type glVertex2fv,#function
+ .globl glVertex2i ; .type glVertex2i,#function
+ .globl glVertex2iv ; .type glVertex2iv,#function
+ .globl glVertex2s ; .type glVertex2s,#function
+ .globl glVertex2sv ; .type glVertex2sv,#function
+ .globl glVertex3d ; .type glVertex3d,#function
+ .globl glVertex3dv ; .type glVertex3dv,#function
+ .globl glVertex3f ; .type glVertex3f,#function
+ .globl glVertex3fv ; .type glVertex3fv,#function
+ .globl glVertex3i ; .type glVertex3i,#function
+ .globl glVertex3iv ; .type glVertex3iv,#function
+ .globl glVertex3s ; .type glVertex3s,#function
+ .globl glVertex3sv ; .type glVertex3sv,#function
+ .globl glVertex4d ; .type glVertex4d,#function
+ .globl glVertex4dv ; .type glVertex4dv,#function
+ .globl glVertex4f ; .type glVertex4f,#function
+ .globl glVertex4fv ; .type glVertex4fv,#function
+ .globl glVertex4i ; .type glVertex4i,#function
+ .globl glVertex4iv ; .type glVertex4iv,#function
+ .globl glVertex4s ; .type glVertex4s,#function
+ .globl glVertex4sv ; .type glVertex4sv,#function
+ .globl glClipPlane ; .type glClipPlane,#function
+ .globl glColorMaterial ; .type glColorMaterial,#function
+ .globl glCullFace ; .type glCullFace,#function
+ .globl glFogf ; .type glFogf,#function
+ .globl glFogfv ; .type glFogfv,#function
+ .globl glFogi ; .type glFogi,#function
+ .globl glFogiv ; .type glFogiv,#function
+ .globl glFrontFace ; .type glFrontFace,#function
+ .globl glHint ; .type glHint,#function
+ .globl glLightf ; .type glLightf,#function
+ .globl glLightfv ; .type glLightfv,#function
+ .globl glLighti ; .type glLighti,#function
+ .globl glLightiv ; .type glLightiv,#function
+ .globl glLightModelf ; .type glLightModelf,#function
+ .globl glLightModelfv ; .type glLightModelfv,#function
+ .globl glLightModeli ; .type glLightModeli,#function
+ .globl glLightModeliv ; .type glLightModeliv,#function
+ .globl glLineStipple ; .type glLineStipple,#function
+ .globl glLineWidth ; .type glLineWidth,#function
+ .globl glMaterialf ; .type glMaterialf,#function
+ .globl glMaterialfv ; .type glMaterialfv,#function
+ .globl glMateriali ; .type glMateriali,#function
+ .globl glMaterialiv ; .type glMaterialiv,#function
+ .globl glPointSize ; .type glPointSize,#function
+ .globl glPolygonMode ; .type glPolygonMode,#function
+ .globl glPolygonStipple ; .type glPolygonStipple,#function
+ .globl glScissor ; .type glScissor,#function
+ .globl glShadeModel ; .type glShadeModel,#function
+ .globl glTexParameterf ; .type glTexParameterf,#function
+ .globl glTexParameterfv ; .type glTexParameterfv,#function
+ .globl glTexParameteri ; .type glTexParameteri,#function
+ .globl glTexParameteriv ; .type glTexParameteriv,#function
+ .globl glTexImage1D ; .type glTexImage1D,#function
+ .globl glTexImage2D ; .type glTexImage2D,#function
+ .globl glTexEnvf ; .type glTexEnvf,#function
+ .globl glTexEnvfv ; .type glTexEnvfv,#function
+ .globl glTexEnvi ; .type glTexEnvi,#function
+ .globl glTexEnviv ; .type glTexEnviv,#function
+ .globl glTexGend ; .type glTexGend,#function
+ .globl glTexGendv ; .type glTexGendv,#function
+ .globl glTexGenf ; .type glTexGenf,#function
+ .globl glTexGenfv ; .type glTexGenfv,#function
+ .globl glTexGeni ; .type glTexGeni,#function
+ .globl glTexGeniv ; .type glTexGeniv,#function
+ .globl glFeedbackBuffer ; .type glFeedbackBuffer,#function
+ .globl glSelectBuffer ; .type glSelectBuffer,#function
+ .globl glRenderMode ; .type glRenderMode,#function
+ .globl glInitNames ; .type glInitNames,#function
+ .globl glLoadName ; .type glLoadName,#function
+ .globl glPassThrough ; .type glPassThrough,#function
+ .globl glPopName ; .type glPopName,#function
+ .globl glPushName ; .type glPushName,#function
+ .globl glDrawBuffer ; .type glDrawBuffer,#function
+ .globl glClear ; .type glClear,#function
+ .globl glClearAccum ; .type glClearAccum,#function
+ .globl glClearIndex ; .type glClearIndex,#function
+ .globl glClearColor ; .type glClearColor,#function
+ .globl glClearStencil ; .type glClearStencil,#function
+ .globl glClearDepth ; .type glClearDepth,#function
+ .globl glStencilMask ; .type glStencilMask,#function
+ .globl glColorMask ; .type glColorMask,#function
+ .globl glDepthMask ; .type glDepthMask,#function
+ .globl glIndexMask ; .type glIndexMask,#function
+ .globl glAccum ; .type glAccum,#function
+ .globl glDisable ; .type glDisable,#function
+ .globl glEnable ; .type glEnable,#function
+ .globl glFinish ; .type glFinish,#function
+ .globl glFlush ; .type glFlush,#function
+ .globl glPopAttrib ; .type glPopAttrib,#function
+ .globl glPushAttrib ; .type glPushAttrib,#function
+ .globl glMap1d ; .type glMap1d,#function
+ .globl glMap1f ; .type glMap1f,#function
+ .globl glMap2d ; .type glMap2d,#function
+ .globl glMap2f ; .type glMap2f,#function
+ .globl glMapGrid1d ; .type glMapGrid1d,#function
+ .globl glMapGrid1f ; .type glMapGrid1f,#function
+ .globl glMapGrid2d ; .type glMapGrid2d,#function
+ .globl glMapGrid2f ; .type glMapGrid2f,#function
+ .globl glEvalCoord1d ; .type glEvalCoord1d,#function
+ .globl glEvalCoord1dv ; .type glEvalCoord1dv,#function
+ .globl glEvalCoord1f ; .type glEvalCoord1f,#function
+ .globl glEvalCoord1fv ; .type glEvalCoord1fv,#function
+ .globl glEvalCoord2d ; .type glEvalCoord2d,#function
+ .globl glEvalCoord2dv ; .type glEvalCoord2dv,#function
+ .globl glEvalCoord2f ; .type glEvalCoord2f,#function
+ .globl glEvalCoord2fv ; .type glEvalCoord2fv,#function
+ .globl glEvalMesh1 ; .type glEvalMesh1,#function
+ .globl glEvalPoint1 ; .type glEvalPoint1,#function
+ .globl glEvalMesh2 ; .type glEvalMesh2,#function
+ .globl glEvalPoint2 ; .type glEvalPoint2,#function
+ .globl glAlphaFunc ; .type glAlphaFunc,#function
+ .globl glBlendFunc ; .type glBlendFunc,#function
+ .globl glLogicOp ; .type glLogicOp,#function
+ .globl glStencilFunc ; .type glStencilFunc,#function
+ .globl glStencilOp ; .type glStencilOp,#function
+ .globl glDepthFunc ; .type glDepthFunc,#function
+ .globl glPixelZoom ; .type glPixelZoom,#function
+ .globl glPixelTransferf ; .type glPixelTransferf,#function
+ .globl glPixelTransferi ; .type glPixelTransferi,#function
+ .globl glPixelStoref ; .type glPixelStoref,#function
+ .globl glPixelStorei ; .type glPixelStorei,#function
+ .globl glPixelMapfv ; .type glPixelMapfv,#function
+ .globl glPixelMapuiv ; .type glPixelMapuiv,#function
+ .globl glPixelMapusv ; .type glPixelMapusv,#function
+ .globl glReadBuffer ; .type glReadBuffer,#function
+ .globl glCopyPixels ; .type glCopyPixels,#function
+ .globl glReadPixels ; .type glReadPixels,#function
+ .globl glDrawPixels ; .type glDrawPixels,#function
+ .globl glGetBooleanv ; .type glGetBooleanv,#function
+ .globl glGetClipPlane ; .type glGetClipPlane,#function
+ .globl glGetDoublev ; .type glGetDoublev,#function
+ .globl glGetError ; .type glGetError,#function
+ .globl glGetFloatv ; .type glGetFloatv,#function
+ .globl glGetIntegerv ; .type glGetIntegerv,#function
+ .globl glGetLightfv ; .type glGetLightfv,#function
+ .globl glGetLightiv ; .type glGetLightiv,#function
+ .globl glGetMapdv ; .type glGetMapdv,#function
+ .globl glGetMapfv ; .type glGetMapfv,#function
+ .globl glGetMapiv ; .type glGetMapiv,#function
+ .globl glGetMaterialfv ; .type glGetMaterialfv,#function
+ .globl glGetMaterialiv ; .type glGetMaterialiv,#function
+ .globl glGetPixelMapfv ; .type glGetPixelMapfv,#function
+ .globl glGetPixelMapuiv ; .type glGetPixelMapuiv,#function
+ .globl glGetPixelMapusv ; .type glGetPixelMapusv,#function
+ .globl glGetPolygonStipple ; .type glGetPolygonStipple,#function
+ .globl glGetString ; .type glGetString,#function
+ .globl glGetTexEnvfv ; .type glGetTexEnvfv,#function
+ .globl glGetTexEnviv ; .type glGetTexEnviv,#function
+ .globl glGetTexGendv ; .type glGetTexGendv,#function
+ .globl glGetTexGenfv ; .type glGetTexGenfv,#function
+ .globl glGetTexGeniv ; .type glGetTexGeniv,#function
+ .globl glGetTexImage ; .type glGetTexImage,#function
+ .globl glGetTexParameterfv ; .type glGetTexParameterfv,#function
+ .globl glGetTexParameteriv ; .type glGetTexParameteriv,#function
+ .globl glGetTexLevelParameterfv ; .type glGetTexLevelParameterfv,#function
+ .globl glGetTexLevelParameteriv ; .type glGetTexLevelParameteriv,#function
+ .globl glIsEnabled ; .type glIsEnabled,#function
+ .globl glIsList ; .type glIsList,#function
+ .globl glDepthRange ; .type glDepthRange,#function
+ .globl glFrustum ; .type glFrustum,#function
+ .globl glLoadIdentity ; .type glLoadIdentity,#function
+ .globl glLoadMatrixf ; .type glLoadMatrixf,#function
+ .globl glLoadMatrixd ; .type glLoadMatrixd,#function
+ .globl glMatrixMode ; .type glMatrixMode,#function
+ .globl glMultMatrixf ; .type glMultMatrixf,#function
+ .globl glMultMatrixd ; .type glMultMatrixd,#function
+ .globl glOrtho ; .type glOrtho,#function
+ .globl glPopMatrix ; .type glPopMatrix,#function
+ .globl glPushMatrix ; .type glPushMatrix,#function
+ .globl glRotated ; .type glRotated,#function
+ .globl glRotatef ; .type glRotatef,#function
+ .globl glScaled ; .type glScaled,#function
+ .globl glScalef ; .type glScalef,#function
+ .globl glTranslated ; .type glTranslated,#function
+ .globl glTranslatef ; .type glTranslatef,#function
+ .globl glViewport ; .type glViewport,#function
+ .globl glArrayElement ; .type glArrayElement,#function
+ .globl glBindTexture ; .type glBindTexture,#function
+ .globl glColorPointer ; .type glColorPointer,#function
+ .globl glDisableClientState ; .type glDisableClientState,#function
+ .globl glDrawArrays ; .type glDrawArrays,#function
+ .globl glDrawElements ; .type glDrawElements,#function
+ .globl glEdgeFlagPointer ; .type glEdgeFlagPointer,#function
+ .globl glEnableClientState ; .type glEnableClientState,#function
+ .globl glIndexPointer ; .type glIndexPointer,#function
+ .globl glIndexub ; .type glIndexub,#function
+ .globl glIndexubv ; .type glIndexubv,#function
+ .globl glInterleavedArrays ; .type glInterleavedArrays,#function
+ .globl glNormalPointer ; .type glNormalPointer,#function
+ .globl glPolygonOffset ; .type glPolygonOffset,#function
+ .globl glTexCoordPointer ; .type glTexCoordPointer,#function
+ .globl glVertexPointer ; .type glVertexPointer,#function
+ .globl glAreTexturesResident ; .type glAreTexturesResident,#function
+ .globl glCopyTexImage1D ; .type glCopyTexImage1D,#function
+ .globl glCopyTexImage2D ; .type glCopyTexImage2D,#function
+ .globl glCopyTexSubImage1D ; .type glCopyTexSubImage1D,#function
+ .globl glCopyTexSubImage2D ; .type glCopyTexSubImage2D,#function
+ .globl glDeleteTextures ; .type glDeleteTextures,#function
+ .globl glGenTextures ; .type glGenTextures,#function
+ .globl glGetPointerv ; .type glGetPointerv,#function
+ .globl glIsTexture ; .type glIsTexture,#function
+ .globl glPrioritizeTextures ; .type glPrioritizeTextures,#function
+ .globl glTexSubImage1D ; .type glTexSubImage1D,#function
+ .globl glTexSubImage2D ; .type glTexSubImage2D,#function
+ .globl glPopClientAttrib ; .type glPopClientAttrib,#function
+ .globl glPushClientAttrib ; .type glPushClientAttrib,#function
+ .globl glBlendColor ; .type glBlendColor,#function
+ .globl glBlendEquation ; .type glBlendEquation,#function
+ .globl glDrawRangeElements ; .type glDrawRangeElements,#function
+ .globl glColorTable ; .type glColorTable,#function
+ .globl glColorTableParameterfv ; .type glColorTableParameterfv,#function
+ .globl glColorTableParameteriv ; .type glColorTableParameteriv,#function
+ .globl glCopyColorTable ; .type glCopyColorTable,#function
+ .globl glGetColorTable ; .type glGetColorTable,#function
+ .globl glGetColorTableParameterfv ; .type glGetColorTableParameterfv,#function
+ .globl glGetColorTableParameteriv ; .type glGetColorTableParameteriv,#function
+ .globl glColorSubTable ; .type glColorSubTable,#function
+ .globl glCopyColorSubTable ; .type glCopyColorSubTable,#function
+ .globl glConvolutionFilter1D ; .type glConvolutionFilter1D,#function
+ .globl glConvolutionFilter2D ; .type glConvolutionFilter2D,#function
+ .globl glConvolutionParameterf ; .type glConvolutionParameterf,#function
+ .globl glConvolutionParameterfv ; .type glConvolutionParameterfv,#function
+ .globl glConvolutionParameteri ; .type glConvolutionParameteri,#function
+ .globl glConvolutionParameteriv ; .type glConvolutionParameteriv,#function
+ .globl glCopyConvolutionFilter1D ; .type glCopyConvolutionFilter1D,#function
+ .globl glCopyConvolutionFilter2D ; .type glCopyConvolutionFilter2D,#function
+ .globl glGetConvolutionFilter ; .type glGetConvolutionFilter,#function
+ .globl glGetConvolutionParameterfv ; .type glGetConvolutionParameterfv,#function
+ .globl glGetConvolutionParameteriv ; .type glGetConvolutionParameteriv,#function
+ .globl glGetSeparableFilter ; .type glGetSeparableFilter,#function
+ .globl glSeparableFilter2D ; .type glSeparableFilter2D,#function
+ .globl glGetHistogram ; .type glGetHistogram,#function
+ .globl glGetHistogramParameterfv ; .type glGetHistogramParameterfv,#function
+ .globl glGetHistogramParameteriv ; .type glGetHistogramParameteriv,#function
+ .globl glGetMinmax ; .type glGetMinmax,#function
+ .globl glGetMinmaxParameterfv ; .type glGetMinmaxParameterfv,#function
+ .globl glGetMinmaxParameteriv ; .type glGetMinmaxParameteriv,#function
+ .globl glHistogram ; .type glHistogram,#function
+ .globl glMinmax ; .type glMinmax,#function
+ .globl glResetHistogram ; .type glResetHistogram,#function
+ .globl glResetMinmax ; .type glResetMinmax,#function
+ .globl glTexImage3D ; .type glTexImage3D,#function
+ .globl glTexSubImage3D ; .type glTexSubImage3D,#function
+ .globl glCopyTexSubImage3D ; .type glCopyTexSubImage3D,#function
+ .globl glActiveTextureARB ; .type glActiveTextureARB,#function
+ .globl glClientActiveTextureARB ; .type glClientActiveTextureARB,#function
+ .globl glMultiTexCoord1dARB ; .type glMultiTexCoord1dARB,#function
+ .globl glMultiTexCoord1dvARB ; .type glMultiTexCoord1dvARB,#function
+ .globl glMultiTexCoord1fARB ; .type glMultiTexCoord1fARB,#function
+ .globl glMultiTexCoord1fvARB ; .type glMultiTexCoord1fvARB,#function
+ .globl glMultiTexCoord1iARB ; .type glMultiTexCoord1iARB,#function
+ .globl glMultiTexCoord1ivARB ; .type glMultiTexCoord1ivARB,#function
+ .globl glMultiTexCoord1sARB ; .type glMultiTexCoord1sARB,#function
+ .globl glMultiTexCoord1svARB ; .type glMultiTexCoord1svARB,#function
+ .globl glMultiTexCoord2dARB ; .type glMultiTexCoord2dARB,#function
+ .globl glMultiTexCoord2dvARB ; .type glMultiTexCoord2dvARB,#function
+ .globl glMultiTexCoord2fARB ; .type glMultiTexCoord2fARB,#function
+ .globl glMultiTexCoord2fvARB ; .type glMultiTexCoord2fvARB,#function
+ .globl glMultiTexCoord2iARB ; .type glMultiTexCoord2iARB,#function
+ .globl glMultiTexCoord2ivARB ; .type glMultiTexCoord2ivARB,#function
+ .globl glMultiTexCoord2sARB ; .type glMultiTexCoord2sARB,#function
+ .globl glMultiTexCoord2svARB ; .type glMultiTexCoord2svARB,#function
+ .globl glMultiTexCoord3dARB ; .type glMultiTexCoord3dARB,#function
+ .globl glMultiTexCoord3dvARB ; .type glMultiTexCoord3dvARB,#function
+ .globl glMultiTexCoord3fARB ; .type glMultiTexCoord3fARB,#function
+ .globl glMultiTexCoord3fvARB ; .type glMultiTexCoord3fvARB,#function
+ .globl glMultiTexCoord3iARB ; .type glMultiTexCoord3iARB,#function
+ .globl glMultiTexCoord3ivARB ; .type glMultiTexCoord3ivARB,#function
+ .globl glMultiTexCoord3sARB ; .type glMultiTexCoord3sARB,#function
+ .globl glMultiTexCoord3svARB ; .type glMultiTexCoord3svARB,#function
+ .globl glMultiTexCoord4dARB ; .type glMultiTexCoord4dARB,#function
+ .globl glMultiTexCoord4dvARB ; .type glMultiTexCoord4dvARB,#function
+ .globl glMultiTexCoord4fARB ; .type glMultiTexCoord4fARB,#function
+ .globl glMultiTexCoord4fvARB ; .type glMultiTexCoord4fvARB,#function
+ .globl glMultiTexCoord4iARB ; .type glMultiTexCoord4iARB,#function
+ .globl glMultiTexCoord4ivARB ; .type glMultiTexCoord4ivARB,#function
+ .globl glMultiTexCoord4sARB ; .type glMultiTexCoord4sARB,#function
+ .globl glMultiTexCoord4svARB ; .type glMultiTexCoord4svARB,#function
+ .globl glLoadTransposeMatrixfARB ; .type glLoadTransposeMatrixfARB,#function
+ .globl glLoadTransposeMatrixdARB ; .type glLoadTransposeMatrixdARB,#function
+ .globl glMultTransposeMatrixfARB ; .type glMultTransposeMatrixfARB,#function
+ .globl glMultTransposeMatrixdARB ; .type glMultTransposeMatrixdARB,#function
+ .globl glSampleCoverageARB ; .type glSampleCoverageARB,#function
+ .globl glDrawBuffersARB ; .type glDrawBuffersARB,#function
+ .globl glPolygonOffsetEXT ; .type glPolygonOffsetEXT,#function
+ .globl glGetTexFilterFuncSGIS ; .type glGetTexFilterFuncSGIS,#function
+ .globl glTexFilterFuncSGIS ; .type glTexFilterFuncSGIS,#function
+ .globl glGetHistogramEXT ; .type glGetHistogramEXT,#function
+ .globl glGetHistogramParameterfvEXT ; .type glGetHistogramParameterfvEXT,#function
+ .globl glGetHistogramParameterivEXT ; .type glGetHistogramParameterivEXT,#function
+ .globl glGetMinmaxEXT ; .type glGetMinmaxEXT,#function
+ .globl glGetMinmaxParameterfvEXT ; .type glGetMinmaxParameterfvEXT,#function
+ .globl glGetMinmaxParameterivEXT ; .type glGetMinmaxParameterivEXT,#function
+ .globl glGetConvolutionFilterEXT ; .type glGetConvolutionFilterEXT,#function
+ .globl glGetConvolutionParameterfvEXT ; .type glGetConvolutionParameterfvEXT,#function
+ .globl glGetConvolutionParameterivEXT ; .type glGetConvolutionParameterivEXT,#function
+ .globl glGetSeparableFilterEXT ; .type glGetSeparableFilterEXT,#function
+ .globl glGetColorTableSGI ; .type glGetColorTableSGI,#function
+ .globl glGetColorTableParameterfvSGI ; .type glGetColorTableParameterfvSGI,#function
+ .globl glGetColorTableParameterivSGI ; .type glGetColorTableParameterivSGI,#function
+ .globl glPixelTexGenSGIX ; .type glPixelTexGenSGIX,#function
+ .globl glPixelTexGenParameteriSGIS ; .type glPixelTexGenParameteriSGIS,#function
+ .globl glPixelTexGenParameterivSGIS ; .type glPixelTexGenParameterivSGIS,#function
+ .globl glPixelTexGenParameterfSGIS ; .type glPixelTexGenParameterfSGIS,#function
+ .globl glPixelTexGenParameterfvSGIS ; .type glPixelTexGenParameterfvSGIS,#function
+ .globl glGetPixelTexGenParameterivSGIS ; .type glGetPixelTexGenParameterivSGIS,#function
+ .globl glGetPixelTexGenParameterfvSGIS ; .type glGetPixelTexGenParameterfvSGIS,#function
+ .globl glTexImage4DSGIS ; .type glTexImage4DSGIS,#function
+ .globl glTexSubImage4DSGIS ; .type glTexSubImage4DSGIS,#function
+ .globl glAreTexturesResidentEXT ; .type glAreTexturesResidentEXT,#function
+ .globl glGenTexturesEXT ; .type glGenTexturesEXT,#function
+ .globl glIsTextureEXT ; .type glIsTextureEXT,#function
+ .globl glDetailTexFuncSGIS ; .type glDetailTexFuncSGIS,#function
+ .globl glGetDetailTexFuncSGIS ; .type glGetDetailTexFuncSGIS,#function
+ .globl glSharpenTexFuncSGIS ; .type glSharpenTexFuncSGIS,#function
+ .globl glGetSharpenTexFuncSGIS ; .type glGetSharpenTexFuncSGIS,#function
+ .globl glSampleMaskSGIS ; .type glSampleMaskSGIS,#function
+ .globl glSamplePatternSGIS ; .type glSamplePatternSGIS,#function
+ .globl glColorPointerEXT ; .type glColorPointerEXT,#function
+ .globl glEdgeFlagPointerEXT ; .type glEdgeFlagPointerEXT,#function
+ .globl glIndexPointerEXT ; .type glIndexPointerEXT,#function
+ .globl glNormalPointerEXT ; .type glNormalPointerEXT,#function
+ .globl glTexCoordPointerEXT ; .type glTexCoordPointerEXT,#function
+ .globl glVertexPointerEXT ; .type glVertexPointerEXT,#function
+ .globl glSpriteParameterfSGIX ; .type glSpriteParameterfSGIX,#function
+ .globl glSpriteParameterfvSGIX ; .type glSpriteParameterfvSGIX,#function
+ .globl glSpriteParameteriSGIX ; .type glSpriteParameteriSGIX,#function
+ .globl glSpriteParameterivSGIX ; .type glSpriteParameterivSGIX,#function
+ .globl glPointParameterfEXT ; .type glPointParameterfEXT,#function
+ .globl glPointParameterfvEXT ; .type glPointParameterfvEXT,#function
+ .globl glGetInstrumentsSGIX ; .type glGetInstrumentsSGIX,#function
+ .globl glInstrumentsBufferSGIX ; .type glInstrumentsBufferSGIX,#function
+ .globl glPollInstrumentsSGIX ; .type glPollInstrumentsSGIX,#function
+ .globl glReadInstrumentsSGIX ; .type glReadInstrumentsSGIX,#function
+ .globl glStartInstrumentsSGIX ; .type glStartInstrumentsSGIX,#function
+ .globl glStopInstrumentsSGIX ; .type glStopInstrumentsSGIX,#function
+ .globl glFrameZoomSGIX ; .type glFrameZoomSGIX,#function
+ .globl glTagSampleBufferSGIX ; .type glTagSampleBufferSGIX,#function
+ .globl glReferencePlaneSGIX ; .type glReferencePlaneSGIX,#function
+ .globl glFlushRasterSGIX ; .type glFlushRasterSGIX,#function
+ .globl glGetListParameterfvSGIX ; .type glGetListParameterfvSGIX,#function
+ .globl glGetListParameterivSGIX ; .type glGetListParameterivSGIX,#function
+ .globl glListParameterfSGIX ; .type glListParameterfSGIX,#function
+ .globl glListParameterfvSGIX ; .type glListParameterfvSGIX,#function
+ .globl glListParameteriSGIX ; .type glListParameteriSGIX,#function
+ .globl glListParameterivSGIX ; .type glListParameterivSGIX,#function
+ .globl glFragmentColorMaterialSGIX ; .type glFragmentColorMaterialSGIX,#function
+ .globl glFragmentLightfSGIX ; .type glFragmentLightfSGIX,#function
+ .globl glFragmentLightfvSGIX ; .type glFragmentLightfvSGIX,#function
+ .globl glFragmentLightiSGIX ; .type glFragmentLightiSGIX,#function
+ .globl glFragmentLightivSGIX ; .type glFragmentLightivSGIX,#function
+ .globl glFragmentLightModelfSGIX ; .type glFragmentLightModelfSGIX,#function
+ .globl glFragmentLightModelfvSGIX ; .type glFragmentLightModelfvSGIX,#function
+ .globl glFragmentLightModeliSGIX ; .type glFragmentLightModeliSGIX,#function
+ .globl glFragmentLightModelivSGIX ; .type glFragmentLightModelivSGIX,#function
+ .globl glFragmentMaterialfSGIX ; .type glFragmentMaterialfSGIX,#function
+ .globl glFragmentMaterialfvSGIX ; .type glFragmentMaterialfvSGIX,#function
+ .globl glFragmentMaterialiSGIX ; .type glFragmentMaterialiSGIX,#function
+ .globl glFragmentMaterialivSGIX ; .type glFragmentMaterialivSGIX,#function
+ .globl glGetFragmentLightfvSGIX ; .type glGetFragmentLightfvSGIX,#function
+ .globl glGetFragmentLightivSGIX ; .type glGetFragmentLightivSGIX,#function
+ .globl glGetFragmentMaterialfvSGIX ; .type glGetFragmentMaterialfvSGIX,#function
+ .globl glGetFragmentMaterialivSGIX ; .type glGetFragmentMaterialivSGIX,#function
+ .globl glLightEnviSGIX ; .type glLightEnviSGIX,#function
+ .globl glVertexWeightfEXT ; .type glVertexWeightfEXT,#function
+ .globl glVertexWeightfvEXT ; .type glVertexWeightfvEXT,#function
+ .globl glVertexWeightPointerEXT ; .type glVertexWeightPointerEXT,#function
+ .globl glFlushVertexArrayRangeNV ; .type glFlushVertexArrayRangeNV,#function
+ .globl glVertexArrayRangeNV ; .type glVertexArrayRangeNV,#function
+ .globl glCombinerParameterfvNV ; .type glCombinerParameterfvNV,#function
+ .globl glCombinerParameterfNV ; .type glCombinerParameterfNV,#function
+ .globl glCombinerParameterivNV ; .type glCombinerParameterivNV,#function
+ .globl glCombinerParameteriNV ; .type glCombinerParameteriNV,#function
+ .globl glCombinerInputNV ; .type glCombinerInputNV,#function
+ .globl glCombinerOutputNV ; .type glCombinerOutputNV,#function
+ .globl glFinalCombinerInputNV ; .type glFinalCombinerInputNV,#function
+ .globl glGetCombinerInputParameterfvNV ; .type glGetCombinerInputParameterfvNV,#function
+ .globl glGetCombinerInputParameterivNV ; .type glGetCombinerInputParameterivNV,#function
+ .globl glGetCombinerOutputParameterfvNV ; .type glGetCombinerOutputParameterfvNV,#function
+ .globl glGetCombinerOutputParameterivNV ; .type glGetCombinerOutputParameterivNV,#function
+ .globl glGetFinalCombinerInputParameterfvNV ; .type glGetFinalCombinerInputParameterfvNV,#function
+ .globl glGetFinalCombinerInputParameterivNV ; .type glGetFinalCombinerInputParameterivNV,#function
+ .globl glResizeBuffersMESA ; .type glResizeBuffersMESA,#function
+ .globl glWindowPos2dMESA ; .type glWindowPos2dMESA,#function
+ .globl glWindowPos2dvMESA ; .type glWindowPos2dvMESA,#function
+ .globl glWindowPos2fMESA ; .type glWindowPos2fMESA,#function
+ .globl glWindowPos2fvMESA ; .type glWindowPos2fvMESA,#function
+ .globl glWindowPos2iMESA ; .type glWindowPos2iMESA,#function
+ .globl glWindowPos2ivMESA ; .type glWindowPos2ivMESA,#function
+ .globl glWindowPos2sMESA ; .type glWindowPos2sMESA,#function
+ .globl glWindowPos2svMESA ; .type glWindowPos2svMESA,#function
+ .globl glWindowPos3dMESA ; .type glWindowPos3dMESA,#function
+ .globl glWindowPos3dvMESA ; .type glWindowPos3dvMESA,#function
+ .globl glWindowPos3fMESA ; .type glWindowPos3fMESA,#function
+ .globl glWindowPos3fvMESA ; .type glWindowPos3fvMESA,#function
+ .globl glWindowPos3iMESA ; .type glWindowPos3iMESA,#function
+ .globl glWindowPos3ivMESA ; .type glWindowPos3ivMESA,#function
+ .globl glWindowPos3sMESA ; .type glWindowPos3sMESA,#function
+ .globl glWindowPos3svMESA ; .type glWindowPos3svMESA,#function
+ .globl glWindowPos4dMESA ; .type glWindowPos4dMESA,#function
+ .globl glWindowPos4dvMESA ; .type glWindowPos4dvMESA,#function
+ .globl glWindowPos4fMESA ; .type glWindowPos4fMESA,#function
+ .globl glWindowPos4fvMESA ; .type glWindowPos4fvMESA,#function
+ .globl glWindowPos4iMESA ; .type glWindowPos4iMESA,#function
+ .globl glWindowPos4ivMESA ; .type glWindowPos4ivMESA,#function
+ .globl glWindowPos4sMESA ; .type glWindowPos4sMESA,#function
+ .globl glWindowPos4svMESA ; .type glWindowPos4svMESA,#function
+ .globl glBlendFuncSeparateEXT ; .type glBlendFuncSeparateEXT,#function
+ .globl glIndexMaterialEXT ; .type glIndexMaterialEXT,#function
+ .globl glIndexFuncEXT ; .type glIndexFuncEXT,#function
+ .globl glLockArraysEXT ; .type glLockArraysEXT,#function
+ .globl glUnlockArraysEXT ; .type glUnlockArraysEXT,#function
+ .globl glCullParameterdvEXT ; .type glCullParameterdvEXT,#function
+ .globl glCullParameterfvEXT ; .type glCullParameterfvEXT,#function
+ .globl glHintPGI ; .type glHintPGI,#function
+ .globl glFogCoordfEXT ; .type glFogCoordfEXT,#function
+ .globl glFogCoordfvEXT ; .type glFogCoordfvEXT,#function
+ .globl glFogCoorddEXT ; .type glFogCoorddEXT,#function
+ .globl glFogCoorddvEXT ; .type glFogCoorddvEXT,#function
+ .globl glFogCoordPointerEXT ; .type glFogCoordPointerEXT,#function
+ .globl glGetColorTableEXT ; .type glGetColorTableEXT,#function
+ .globl glGetColorTableParameterivEXT ; .type glGetColorTableParameterivEXT,#function
+ .globl glGetColorTableParameterfvEXT ; .type glGetColorTableParameterfvEXT,#function
+ .globl glTbufferMask3DFX ; .type glTbufferMask3DFX,#function
+ .globl glCompressedTexImage3DARB ; .type glCompressedTexImage3DARB,#function
+ .globl glCompressedTexImage2DARB ; .type glCompressedTexImage2DARB,#function
+ .globl glCompressedTexImage1DARB ; .type glCompressedTexImage1DARB,#function
+ .globl glCompressedTexSubImage3DARB ; .type glCompressedTexSubImage3DARB,#function
+ .globl glCompressedTexSubImage2DARB ; .type glCompressedTexSubImage2DARB,#function
+ .globl glCompressedTexSubImage1DARB ; .type glCompressedTexSubImage1DARB,#function
+ .globl glGetCompressedTexImageARB ; .type glGetCompressedTexImageARB,#function
+ .globl glSecondaryColor3bEXT ; .type glSecondaryColor3bEXT,#function
+ .globl glSecondaryColor3bvEXT ; .type glSecondaryColor3bvEXT,#function
+ .globl glSecondaryColor3dEXT ; .type glSecondaryColor3dEXT,#function
+ .globl glSecondaryColor3dvEXT ; .type glSecondaryColor3dvEXT,#function
+ .globl glSecondaryColor3fEXT ; .type glSecondaryColor3fEXT,#function
+ .globl glSecondaryColor3fvEXT ; .type glSecondaryColor3fvEXT,#function
+ .globl glSecondaryColor3iEXT ; .type glSecondaryColor3iEXT,#function
+ .globl glSecondaryColor3ivEXT ; .type glSecondaryColor3ivEXT,#function
+ .globl glSecondaryColor3sEXT ; .type glSecondaryColor3sEXT,#function
+ .globl glSecondaryColor3svEXT ; .type glSecondaryColor3svEXT,#function
+ .globl glSecondaryColor3ubEXT ; .type glSecondaryColor3ubEXT,#function
+ .globl glSecondaryColor3ubvEXT ; .type glSecondaryColor3ubvEXT,#function
+ .globl glSecondaryColor3uiEXT ; .type glSecondaryColor3uiEXT,#function
+ .globl glSecondaryColor3uivEXT ; .type glSecondaryColor3uivEXT,#function
+ .globl glSecondaryColor3usEXT ; .type glSecondaryColor3usEXT,#function
+ .globl glSecondaryColor3usvEXT ; .type glSecondaryColor3usvEXT,#function
+ .globl glSecondaryColorPointerEXT ; .type glSecondaryColorPointerEXT,#function
+ .globl glAreProgramsResidentNV ; .type glAreProgramsResidentNV,#function
+ .globl glBindProgramNV ; .type glBindProgramNV,#function
+ .globl glDeleteProgramsNV ; .type glDeleteProgramsNV,#function
+ .globl glExecuteProgramNV ; .type glExecuteProgramNV,#function
+ .globl glGenProgramsNV ; .type glGenProgramsNV,#function
+ .globl glGetProgramParameterdvNV ; .type glGetProgramParameterdvNV,#function
+ .globl glGetProgramParameterfvNV ; .type glGetProgramParameterfvNV,#function
+ .globl glGetProgramivNV ; .type glGetProgramivNV,#function
+ .globl glGetProgramStringNV ; .type glGetProgramStringNV,#function
+ .globl glGetTrackMatrixivNV ; .type glGetTrackMatrixivNV,#function
+ .globl glGetVertexAttribdvARB ; .type glGetVertexAttribdvARB,#function
+ .globl glGetVertexAttribfvARB ; .type glGetVertexAttribfvARB,#function
+ .globl glGetVertexAttribivARB ; .type glGetVertexAttribivARB,#function
+ .globl glGetVertexAttribPointervNV ; .type glGetVertexAttribPointervNV,#function
+ .globl glIsProgramNV ; .type glIsProgramNV,#function
+ .globl glLoadProgramNV ; .type glLoadProgramNV,#function
+ .globl glProgramParameter4dNV ; .type glProgramParameter4dNV,#function
+ .globl glProgramParameter4dvNV ; .type glProgramParameter4dvNV,#function
+ .globl glProgramParameter4fNV ; .type glProgramParameter4fNV,#function
+ .globl glProgramParameter4fvNV ; .type glProgramParameter4fvNV,#function
+ .globl glProgramParameters4dvNV ; .type glProgramParameters4dvNV,#function
+ .globl glProgramParameters4fvNV ; .type glProgramParameters4fvNV,#function
+ .globl glRequestResidentProgramsNV ; .type glRequestResidentProgramsNV,#function
+ .globl glTrackMatrixNV ; .type glTrackMatrixNV,#function
+ .globl glVertexAttribPointerNV ; .type glVertexAttribPointerNV,#function
+ .globl glVertexAttrib1dARB ; .type glVertexAttrib1dARB,#function
+ .globl glVertexAttrib1dvARB ; .type glVertexAttrib1dvARB,#function
+ .globl glVertexAttrib1fARB ; .type glVertexAttrib1fARB,#function
+ .globl glVertexAttrib1fvARB ; .type glVertexAttrib1fvARB,#function
+ .globl glVertexAttrib1sARB ; .type glVertexAttrib1sARB,#function
+ .globl glVertexAttrib1svARB ; .type glVertexAttrib1svARB,#function
+ .globl glVertexAttrib2dARB ; .type glVertexAttrib2dARB,#function
+ .globl glVertexAttrib2dvARB ; .type glVertexAttrib2dvARB,#function
+ .globl glVertexAttrib2fARB ; .type glVertexAttrib2fARB,#function
+ .globl glVertexAttrib2fvARB ; .type glVertexAttrib2fvARB,#function
+ .globl glVertexAttrib2sARB ; .type glVertexAttrib2sARB,#function
+ .globl glVertexAttrib2svARB ; .type glVertexAttrib2svARB,#function
+ .globl glVertexAttrib3dARB ; .type glVertexAttrib3dARB,#function
+ .globl glVertexAttrib3dvARB ; .type glVertexAttrib3dvARB,#function
+ .globl glVertexAttrib3fARB ; .type glVertexAttrib3fARB,#function
+ .globl glVertexAttrib3fvARB ; .type glVertexAttrib3fvARB,#function
+ .globl glVertexAttrib3sARB ; .type glVertexAttrib3sARB,#function
+ .globl glVertexAttrib3svARB ; .type glVertexAttrib3svARB,#function
+ .globl glVertexAttrib4dARB ; .type glVertexAttrib4dARB,#function
+ .globl glVertexAttrib4dvARB ; .type glVertexAttrib4dvARB,#function
+ .globl glVertexAttrib4fARB ; .type glVertexAttrib4fARB,#function
+ .globl glVertexAttrib4fvARB ; .type glVertexAttrib4fvARB,#function
+ .globl glVertexAttrib4sARB ; .type glVertexAttrib4sARB,#function
+ .globl glVertexAttrib4svARB ; .type glVertexAttrib4svARB,#function
+ .globl glVertexAttrib4NubARB ; .type glVertexAttrib4NubARB,#function
+ .globl glVertexAttrib4NubvARB ; .type glVertexAttrib4NubvARB,#function
+ .globl glVertexAttribs1dvNV ; .type glVertexAttribs1dvNV,#function
+ .globl glVertexAttribs1fvNV ; .type glVertexAttribs1fvNV,#function
+ .globl glVertexAttribs1svNV ; .type glVertexAttribs1svNV,#function
+ .globl glVertexAttribs2dvNV ; .type glVertexAttribs2dvNV,#function
+ .globl glVertexAttribs2fvNV ; .type glVertexAttribs2fvNV,#function
+ .globl glVertexAttribs2svNV ; .type glVertexAttribs2svNV,#function
+ .globl glVertexAttribs3dvNV ; .type glVertexAttribs3dvNV,#function
+ .globl glVertexAttribs3fvNV ; .type glVertexAttribs3fvNV,#function
+ .globl glVertexAttribs3svNV ; .type glVertexAttribs3svNV,#function
+ .globl glVertexAttribs4dvNV ; .type glVertexAttribs4dvNV,#function
+ .globl glVertexAttribs4fvNV ; .type glVertexAttribs4fvNV,#function
+ .globl glVertexAttribs4svNV ; .type glVertexAttribs4svNV,#function
+ .globl glVertexAttribs4ubvNV ; .type glVertexAttribs4ubvNV,#function
+ .globl glPointParameteriNV ; .type glPointParameteriNV,#function
+ .globl glPointParameterivNV ; .type glPointParameterivNV,#function
+ .globl glMultiDrawArraysEXT ; .type glMultiDrawArraysEXT,#function
+ .globl glMultiDrawElementsEXT ; .type glMultiDrawElementsEXT,#function
+ .globl glActiveStencilFaceEXT ; .type glActiveStencilFaceEXT,#function
+ .globl glDeleteFencesNV ; .type glDeleteFencesNV,#function
+ .globl glGenFencesNV ; .type glGenFencesNV,#function
+ .globl glIsFenceNV ; .type glIsFenceNV,#function
+ .globl glTestFenceNV ; .type glTestFenceNV,#function
+ .globl glGetFenceivNV ; .type glGetFenceivNV,#function
+ .globl glFinishFenceNV ; .type glFinishFenceNV,#function
+ .globl glSetFenceNV ; .type glSetFenceNV,#function
+ .globl glVertexAttrib4bvARB ; .type glVertexAttrib4bvARB,#function
+ .globl glVertexAttrib4ivARB ; .type glVertexAttrib4ivARB,#function
+ .globl glVertexAttrib4ubvARB ; .type glVertexAttrib4ubvARB,#function
+ .globl glVertexAttrib4usvARB ; .type glVertexAttrib4usvARB,#function
+ .globl glVertexAttrib4uivARB ; .type glVertexAttrib4uivARB,#function
+ .globl glVertexAttrib4NbvARB ; .type glVertexAttrib4NbvARB,#function
+ .globl glVertexAttrib4NsvARB ; .type glVertexAttrib4NsvARB,#function
+ .globl glVertexAttrib4NivARB ; .type glVertexAttrib4NivARB,#function
+ .globl glVertexAttrib4NusvARB ; .type glVertexAttrib4NusvARB,#function
+ .globl glVertexAttrib4NuivARB ; .type glVertexAttrib4NuivARB,#function
+ .globl glVertexAttribPointerARB ; .type glVertexAttribPointerARB,#function
+ .globl glEnableVertexAttribArrayARB ; .type glEnableVertexAttribArrayARB,#function
+ .globl glDisableVertexAttribArrayARB ; .type glDisableVertexAttribArrayARB,#function
+ .globl glProgramStringARB ; .type glProgramStringARB,#function
+ .globl glProgramEnvParameter4dARB ; .type glProgramEnvParameter4dARB,#function
+ .globl glProgramEnvParameter4dvARB ; .type glProgramEnvParameter4dvARB,#function
+ .globl glProgramEnvParameter4fARB ; .type glProgramEnvParameter4fARB,#function
+ .globl glProgramEnvParameter4fvARB ; .type glProgramEnvParameter4fvARB,#function
+ .globl glProgramLocalParameter4dARB ; .type glProgramLocalParameter4dARB,#function
+ .globl glProgramLocalParameter4dvARB ; .type glProgramLocalParameter4dvARB,#function
+ .globl glProgramLocalParameter4fARB ; .type glProgramLocalParameter4fARB,#function
+ .globl glProgramLocalParameter4fvARB ; .type glProgramLocalParameter4fvARB,#function
+ .globl glGetProgramEnvParameterdvARB ; .type glGetProgramEnvParameterdvARB,#function
+ .globl glGetProgramEnvParameterfvARB ; .type glGetProgramEnvParameterfvARB,#function
+ .globl glGetProgramLocalParameterdvARB ; .type glGetProgramLocalParameterdvARB,#function
+ .globl glGetProgramLocalParameterfvARB ; .type glGetProgramLocalParameterfvARB,#function
+ .globl glGetProgramivARB ; .type glGetProgramivARB,#function
+ .globl glGetProgramStringARB ; .type glGetProgramStringARB,#function
+ .globl glProgramNamedParameter4fNV ; .type glProgramNamedParameter4fNV,#function
+ .globl glProgramNamedParameter4dNV ; .type glProgramNamedParameter4dNV,#function
+ .globl glProgramNamedParameter4fvNV ; .type glProgramNamedParameter4fvNV,#function
+ .globl glProgramNamedParameter4dvNV ; .type glProgramNamedParameter4dvNV,#function
+ .globl glGetProgramNamedParameterfvNV ; .type glGetProgramNamedParameterfvNV,#function
+ .globl glGetProgramNamedParameterdvNV ; .type glGetProgramNamedParameterdvNV,#function
+ .globl glBindBufferARB ; .type glBindBufferARB,#function
+ .globl glBufferDataARB ; .type glBufferDataARB,#function
+ .globl glBufferSubDataARB ; .type glBufferSubDataARB,#function
+ .globl glDeleteBuffersARB ; .type glDeleteBuffersARB,#function
+ .globl glGenBuffersARB ; .type glGenBuffersARB,#function
+ .globl glGetBufferParameterivARB ; .type glGetBufferParameterivARB,#function
+ .globl glGetBufferPointervARB ; .type glGetBufferPointervARB,#function
+ .globl glGetBufferSubDataARB ; .type glGetBufferSubDataARB,#function
+ .globl glIsBufferARB ; .type glIsBufferARB,#function
+ .globl glMapBufferARB ; .type glMapBufferARB,#function
+ .globl glUnmapBufferARB ; .type glUnmapBufferARB,#function
+ .globl glDepthBoundsEXT ; .type glDepthBoundsEXT,#function
+ .globl glGenQueriesARB ; .type glGenQueriesARB,#function
+ .globl glDeleteQueriesARB ; .type glDeleteQueriesARB,#function
+ .globl glIsQueryARB ; .type glIsQueryARB,#function
+ .globl glBeginQueryARB ; .type glBeginQueryARB,#function
+ .globl glEndQueryARB ; .type glEndQueryARB,#function
+ .globl glGetQueryivARB ; .type glGetQueryivARB,#function
+ .globl glGetQueryObjectivARB ; .type glGetQueryObjectivARB,#function
+ .globl glGetQueryObjectuivARB ; .type glGetQueryObjectuivARB,#function
+ .globl glMultiModeDrawArraysIBM ; .type glMultiModeDrawArraysIBM,#function
+ .globl glMultiModeDrawElementsIBM ; .type glMultiModeDrawElementsIBM,#function
+ .globl glBlendEquationSeparateEXT ; .type glBlendEquationSeparateEXT,#function
+ .globl glDeleteObjectARB ; .type glDeleteObjectARB,#function
+ .globl glGetHandleARB ; .type glGetHandleARB,#function
+ .globl glDetachObjectARB ; .type glDetachObjectARB,#function
+ .globl glCreateShaderObjectARB ; .type glCreateShaderObjectARB,#function
+ .globl glShaderSourceARB ; .type glShaderSourceARB,#function
+ .globl glCompileShaderARB ; .type glCompileShaderARB,#function
+ .globl glCreateProgramObjectARB ; .type glCreateProgramObjectARB,#function
+ .globl glAttachObjectARB ; .type glAttachObjectARB,#function
+ .globl glLinkProgramARB ; .type glLinkProgramARB,#function
+ .globl glUseProgramObjectARB ; .type glUseProgramObjectARB,#function
+ .globl glValidateProgramARB ; .type glValidateProgramARB,#function
+ .globl glUniform1fARB ; .type glUniform1fARB,#function
+ .globl glUniform2fARB ; .type glUniform2fARB,#function
+ .globl glUniform3fARB ; .type glUniform3fARB,#function
+ .globl glUniform4fARB ; .type glUniform4fARB,#function
+ .globl glUniform1iARB ; .type glUniform1iARB,#function
+ .globl glUniform2iARB ; .type glUniform2iARB,#function
+ .globl glUniform3iARB ; .type glUniform3iARB,#function
+ .globl glUniform4iARB ; .type glUniform4iARB,#function
+ .globl glUniform1fvARB ; .type glUniform1fvARB,#function
+ .globl glUniform2fvARB ; .type glUniform2fvARB,#function
+ .globl glUniform3fvARB ; .type glUniform3fvARB,#function
+ .globl glUniform4fvARB ; .type glUniform4fvARB,#function
+ .globl glUniform1ivARB ; .type glUniform1ivARB,#function
+ .globl glUniform2ivARB ; .type glUniform2ivARB,#function
+ .globl glUniform3ivARB ; .type glUniform3ivARB,#function
+ .globl glUniform4ivARB ; .type glUniform4ivARB,#function
+ .globl glUniformMatrix2fvARB ; .type glUniformMatrix2fvARB,#function
+ .globl glUniformMatrix3fvARB ; .type glUniformMatrix3fvARB,#function
+ .globl glUniformMatrix4fvARB ; .type glUniformMatrix4fvARB,#function
+ .globl glGetObjectParameterfvARB ; .type glGetObjectParameterfvARB,#function
+ .globl glGetObjectParameterivARB ; .type glGetObjectParameterivARB,#function
+ .globl glGetInfoLogARB ; .type glGetInfoLogARB,#function
+ .globl glGetAttachedObjectsARB ; .type glGetAttachedObjectsARB,#function
+ .globl glGetUniformLocationARB ; .type glGetUniformLocationARB,#function
+ .globl glGetActiveUniformARB ; .type glGetActiveUniformARB,#function
+ .globl glGetUniformfvARB ; .type glGetUniformfvARB,#function
+ .globl glGetUniformivARB ; .type glGetUniformivARB,#function
+ .globl glGetShaderSourceARB ; .type glGetShaderSourceARB,#function
+ .globl glBindAttribLocationARB ; .type glBindAttribLocationARB,#function
+ .globl glGetActiveAttribARB ; .type glGetActiveAttribARB,#function
+ .globl glGetAttribLocationARB ; .type glGetAttribLocationARB,#function
+ .globl glGetVertexAttribdvNV ; .type glGetVertexAttribdvNV,#function
+ .globl glGetVertexAttribfvNV ; .type glGetVertexAttribfvNV,#function
+ .globl glGetVertexAttribivNV ; .type glGetVertexAttribivNV,#function
+ .globl glVertexAttrib1dNV ; .type glVertexAttrib1dNV,#function
+ .globl glVertexAttrib1dvNV ; .type glVertexAttrib1dvNV,#function
+ .globl glVertexAttrib1fNV ; .type glVertexAttrib1fNV,#function
+ .globl glVertexAttrib1fvNV ; .type glVertexAttrib1fvNV,#function
+ .globl glVertexAttrib1sNV ; .type glVertexAttrib1sNV,#function
+ .globl glVertexAttrib1svNV ; .type glVertexAttrib1svNV,#function
+ .globl glVertexAttrib2dNV ; .type glVertexAttrib2dNV,#function
+ .globl glVertexAttrib2dvNV ; .type glVertexAttrib2dvNV,#function
+ .globl glVertexAttrib2fNV ; .type glVertexAttrib2fNV,#function
+ .globl glVertexAttrib2fvNV ; .type glVertexAttrib2fvNV,#function
+ .globl glVertexAttrib2sNV ; .type glVertexAttrib2sNV,#function
+ .globl glVertexAttrib2svNV ; .type glVertexAttrib2svNV,#function
+ .globl glVertexAttrib3dNV ; .type glVertexAttrib3dNV,#function
+ .globl glVertexAttrib3dvNV ; .type glVertexAttrib3dvNV,#function
+ .globl glVertexAttrib3fNV ; .type glVertexAttrib3fNV,#function
+ .globl glVertexAttrib3fvNV ; .type glVertexAttrib3fvNV,#function
+ .globl glVertexAttrib3sNV ; .type glVertexAttrib3sNV,#function
+ .globl glVertexAttrib3svNV ; .type glVertexAttrib3svNV,#function
+ .globl glVertexAttrib4dNV ; .type glVertexAttrib4dNV,#function
+ .globl glVertexAttrib4dvNV ; .type glVertexAttrib4dvNV,#function
+ .globl glVertexAttrib4fNV ; .type glVertexAttrib4fNV,#function
+ .globl glVertexAttrib4fvNV ; .type glVertexAttrib4fvNV,#function
+ .globl glVertexAttrib4sNV ; .type glVertexAttrib4sNV,#function
+ .globl glVertexAttrib4svNV ; .type glVertexAttrib4svNV,#function
+ .globl glVertexAttrib4ubNV ; .type glVertexAttrib4ubNV,#function
+ .globl glVertexAttrib4ubvNV ; .type glVertexAttrib4ubvNV,#function
+ .globl glGenFragmentShadersATI ; .type glGenFragmentShadersATI,#function
+ .globl glBindFragmentShaderATI ; .type glBindFragmentShaderATI,#function
+ .globl glDeleteFragmentShaderATI ; .type glDeleteFragmentShaderATI,#function
+ .globl glBeginFragmentShaderATI ; .type glBeginFragmentShaderATI,#function
+ .globl glEndFragmentShaderATI ; .type glEndFragmentShaderATI,#function
+ .globl glPassTexCoordATI ; .type glPassTexCoordATI,#function
+ .globl glSampleMapATI ; .type glSampleMapATI,#function
+ .globl glColorFragmentOp1ATI ; .type glColorFragmentOp1ATI,#function
+ .globl glColorFragmentOp2ATI ; .type glColorFragmentOp2ATI,#function
+ .globl glColorFragmentOp3ATI ; .type glColorFragmentOp3ATI,#function
+ .globl glAlphaFragmentOp1ATI ; .type glAlphaFragmentOp1ATI,#function
+ .globl glAlphaFragmentOp2ATI ; .type glAlphaFragmentOp2ATI,#function
+ .globl glAlphaFragmentOp3ATI ; .type glAlphaFragmentOp3ATI,#function
+ .globl glSetFragmentShaderConstantATI ; .type glSetFragmentShaderConstantATI,#function
+ .globl glIsRenderbufferEXT ; .type glIsRenderbufferEXT,#function
+ .globl glBindRenderbufferEXT ; .type glBindRenderbufferEXT,#function
+ .globl glDeleteRenderbuffersEXT ; .type glDeleteRenderbuffersEXT,#function
+ .globl glGenRenderbuffersEXT ; .type glGenRenderbuffersEXT,#function
+ .globl glRenderbufferStorageEXT ; .type glRenderbufferStorageEXT,#function
+ .globl glGetRenderbufferParameterivEXT ; .type glGetRenderbufferParameterivEXT,#function
+ .globl glIsFramebufferEXT ; .type glIsFramebufferEXT,#function
+ .globl glBindFramebufferEXT ; .type glBindFramebufferEXT,#function
+ .globl glDeleteFramebuffersEXT ; .type glDeleteFramebuffersEXT,#function
+ .globl glGenFramebuffersEXT ; .type glGenFramebuffersEXT,#function
+ .globl glCheckFramebufferStatusEXT ; .type glCheckFramebufferStatusEXT,#function
+ .globl glFramebufferTexture1DEXT ; .type glFramebufferTexture1DEXT,#function
+ .globl glFramebufferTexture2DEXT ; .type glFramebufferTexture2DEXT,#function
+ .globl glFramebufferTexture3DEXT ; .type glFramebufferTexture3DEXT,#function
+ .globl glFramebufferRenderbufferEXT ; .type glFramebufferRenderbufferEXT,#function
+ .globl glGetFramebufferAttachmentParameterivEXT ; .type glGetFramebufferAttachmentParameterivEXT,#function
+ .globl glGenerateMipmapEXT ; .type glGenerateMipmapEXT,#function
+ .globl glStencilFuncSeparate ; .type glStencilFuncSeparate,#function
+ .globl glStencilOpSeparate ; .type glStencilOpSeparate,#function
+ .globl glStencilMaskSeparate ; .type glStencilMaskSeparate,#function
+ .globl _mesa_sparc_glapi_begin ; .type _mesa_sparc_glapi_begin,#function
+_mesa_sparc_glapi_begin:
+
+ GL_STUB(glNewList, _gloffset_NewList)
+ GL_STUB(glEndList, _gloffset_EndList)
+ GL_STUB(glCallList, _gloffset_CallList)
+ GL_STUB(glCallLists, _gloffset_CallLists)
+ GL_STUB(glDeleteLists, _gloffset_DeleteLists)
+ GL_STUB(glGenLists, _gloffset_GenLists)
+ GL_STUB(glListBase, _gloffset_ListBase)
+ GL_STUB(glBegin, _gloffset_Begin)
+ GL_STUB(glBitmap, _gloffset_Bitmap)
+ GL_STUB(glColor3b, _gloffset_Color3b)
+ GL_STUB(glColor3bv, _gloffset_Color3bv)
+ GL_STUB(glColor3d, _gloffset_Color3d)
+ GL_STUB(glColor3dv, _gloffset_Color3dv)
+ GL_STUB(glColor3f, _gloffset_Color3f)
+ GL_STUB(glColor3fv, _gloffset_Color3fv)
+ GL_STUB(glColor3i, _gloffset_Color3i)
+ GL_STUB(glColor3iv, _gloffset_Color3iv)
+ GL_STUB(glColor3s, _gloffset_Color3s)
+ GL_STUB(glColor3sv, _gloffset_Color3sv)
+ GL_STUB(glColor3ub, _gloffset_Color3ub)
+ GL_STUB(glColor3ubv, _gloffset_Color3ubv)
+ GL_STUB(glColor3ui, _gloffset_Color3ui)
+ GL_STUB(glColor3uiv, _gloffset_Color3uiv)
+ GL_STUB(glColor3us, _gloffset_Color3us)
+ GL_STUB(glColor3usv, _gloffset_Color3usv)
+ GL_STUB(glColor4b, _gloffset_Color4b)
+ GL_STUB(glColor4bv, _gloffset_Color4bv)
+ GL_STUB(glColor4d, _gloffset_Color4d)
+ GL_STUB(glColor4dv, _gloffset_Color4dv)
+ GL_STUB(glColor4f, _gloffset_Color4f)
+ GL_STUB(glColor4fv, _gloffset_Color4fv)
+ GL_STUB(glColor4i, _gloffset_Color4i)
+ GL_STUB(glColor4iv, _gloffset_Color4iv)
+ GL_STUB(glColor4s, _gloffset_Color4s)
+ GL_STUB(glColor4sv, _gloffset_Color4sv)
+ GL_STUB(glColor4ub, _gloffset_Color4ub)
+ GL_STUB(glColor4ubv, _gloffset_Color4ubv)
+ GL_STUB(glColor4ui, _gloffset_Color4ui)
+ GL_STUB(glColor4uiv, _gloffset_Color4uiv)
+ GL_STUB(glColor4us, _gloffset_Color4us)
+ GL_STUB(glColor4usv, _gloffset_Color4usv)
+ GL_STUB(glEdgeFlag, _gloffset_EdgeFlag)
+ GL_STUB(glEdgeFlagv, _gloffset_EdgeFlagv)
+ GL_STUB(glEnd, _gloffset_End)
+ GL_STUB(glIndexd, _gloffset_Indexd)
+ GL_STUB(glIndexdv, _gloffset_Indexdv)
+ GL_STUB(glIndexf, _gloffset_Indexf)
+ GL_STUB(glIndexfv, _gloffset_Indexfv)
+ GL_STUB(glIndexi, _gloffset_Indexi)
+ GL_STUB(glIndexiv, _gloffset_Indexiv)
+ GL_STUB(glIndexs, _gloffset_Indexs)
+ GL_STUB(glIndexsv, _gloffset_Indexsv)
+ GL_STUB(glNormal3b, _gloffset_Normal3b)
+ GL_STUB(glNormal3bv, _gloffset_Normal3bv)
+ GL_STUB(glNormal3d, _gloffset_Normal3d)
+ GL_STUB(glNormal3dv, _gloffset_Normal3dv)
+ GL_STUB(glNormal3f, _gloffset_Normal3f)
+ GL_STUB(glNormal3fv, _gloffset_Normal3fv)
+ GL_STUB(glNormal3i, _gloffset_Normal3i)
+ GL_STUB(glNormal3iv, _gloffset_Normal3iv)
+ GL_STUB(glNormal3s, _gloffset_Normal3s)
+ GL_STUB(glNormal3sv, _gloffset_Normal3sv)
+ GL_STUB(glRasterPos2d, _gloffset_RasterPos2d)
+ GL_STUB(glRasterPos2dv, _gloffset_RasterPos2dv)
+ GL_STUB(glRasterPos2f, _gloffset_RasterPos2f)
+ GL_STUB(glRasterPos2fv, _gloffset_RasterPos2fv)
+ GL_STUB(glRasterPos2i, _gloffset_RasterPos2i)
+ GL_STUB(glRasterPos2iv, _gloffset_RasterPos2iv)
+ GL_STUB(glRasterPos2s, _gloffset_RasterPos2s)
+ GL_STUB(glRasterPos2sv, _gloffset_RasterPos2sv)
+ GL_STUB(glRasterPos3d, _gloffset_RasterPos3d)
+ GL_STUB(glRasterPos3dv, _gloffset_RasterPos3dv)
+ GL_STUB(glRasterPos3f, _gloffset_RasterPos3f)
+ GL_STUB(glRasterPos3fv, _gloffset_RasterPos3fv)
+ GL_STUB(glRasterPos3i, _gloffset_RasterPos3i)
+ GL_STUB(glRasterPos3iv, _gloffset_RasterPos3iv)
+ GL_STUB(glRasterPos3s, _gloffset_RasterPos3s)
+ GL_STUB(glRasterPos3sv, _gloffset_RasterPos3sv)
+ GL_STUB(glRasterPos4d, _gloffset_RasterPos4d)
+ GL_STUB(glRasterPos4dv, _gloffset_RasterPos4dv)
+ GL_STUB(glRasterPos4f, _gloffset_RasterPos4f)
+ GL_STUB(glRasterPos4fv, _gloffset_RasterPos4fv)
+ GL_STUB(glRasterPos4i, _gloffset_RasterPos4i)
+ GL_STUB(glRasterPos4iv, _gloffset_RasterPos4iv)
+ GL_STUB(glRasterPos4s, _gloffset_RasterPos4s)
+ GL_STUB(glRasterPos4sv, _gloffset_RasterPos4sv)
+ GL_STUB(glRectd, _gloffset_Rectd)
+ GL_STUB(glRectdv, _gloffset_Rectdv)
+ GL_STUB(glRectf, _gloffset_Rectf)
+ GL_STUB(glRectfv, _gloffset_Rectfv)
+ GL_STUB(glRecti, _gloffset_Recti)
+ GL_STUB(glRectiv, _gloffset_Rectiv)
+ GL_STUB(glRects, _gloffset_Rects)
+ GL_STUB(glRectsv, _gloffset_Rectsv)
+ GL_STUB(glTexCoord1d, _gloffset_TexCoord1d)
+ GL_STUB(glTexCoord1dv, _gloffset_TexCoord1dv)
+ GL_STUB(glTexCoord1f, _gloffset_TexCoord1f)
+ GL_STUB(glTexCoord1fv, _gloffset_TexCoord1fv)
+ GL_STUB(glTexCoord1i, _gloffset_TexCoord1i)
+ GL_STUB(glTexCoord1iv, _gloffset_TexCoord1iv)
+ GL_STUB(glTexCoord1s, _gloffset_TexCoord1s)
+ GL_STUB(glTexCoord1sv, _gloffset_TexCoord1sv)
+ GL_STUB(glTexCoord2d, _gloffset_TexCoord2d)
+ GL_STUB(glTexCoord2dv, _gloffset_TexCoord2dv)
+ GL_STUB(glTexCoord2f, _gloffset_TexCoord2f)
+ GL_STUB(glTexCoord2fv, _gloffset_TexCoord2fv)
+ GL_STUB(glTexCoord2i, _gloffset_TexCoord2i)
+ GL_STUB(glTexCoord2iv, _gloffset_TexCoord2iv)
+ GL_STUB(glTexCoord2s, _gloffset_TexCoord2s)
+ GL_STUB(glTexCoord2sv, _gloffset_TexCoord2sv)
+ GL_STUB(glTexCoord3d, _gloffset_TexCoord3d)
+ GL_STUB(glTexCoord3dv, _gloffset_TexCoord3dv)
+ GL_STUB(glTexCoord3f, _gloffset_TexCoord3f)
+ GL_STUB(glTexCoord3fv, _gloffset_TexCoord3fv)
+ GL_STUB(glTexCoord3i, _gloffset_TexCoord3i)
+ GL_STUB(glTexCoord3iv, _gloffset_TexCoord3iv)
+ GL_STUB(glTexCoord3s, _gloffset_TexCoord3s)
+ GL_STUB(glTexCoord3sv, _gloffset_TexCoord3sv)
+ GL_STUB(glTexCoord4d, _gloffset_TexCoord4d)
+ GL_STUB(glTexCoord4dv, _gloffset_TexCoord4dv)
+ GL_STUB(glTexCoord4f, _gloffset_TexCoord4f)
+ GL_STUB(glTexCoord4fv, _gloffset_TexCoord4fv)
+ GL_STUB(glTexCoord4i, _gloffset_TexCoord4i)
+ GL_STUB(glTexCoord4iv, _gloffset_TexCoord4iv)
+ GL_STUB(glTexCoord4s, _gloffset_TexCoord4s)
+ GL_STUB(glTexCoord4sv, _gloffset_TexCoord4sv)
+ GL_STUB(glVertex2d, _gloffset_Vertex2d)
+ GL_STUB(glVertex2dv, _gloffset_Vertex2dv)
+ GL_STUB(glVertex2f, _gloffset_Vertex2f)
+ GL_STUB(glVertex2fv, _gloffset_Vertex2fv)
+ GL_STUB(glVertex2i, _gloffset_Vertex2i)
+ GL_STUB(glVertex2iv, _gloffset_Vertex2iv)
+ GL_STUB(glVertex2s, _gloffset_Vertex2s)
+ GL_STUB(glVertex2sv, _gloffset_Vertex2sv)
+ GL_STUB(glVertex3d, _gloffset_Vertex3d)
+ GL_STUB(glVertex3dv, _gloffset_Vertex3dv)
+ GL_STUB(glVertex3f, _gloffset_Vertex3f)
+ GL_STUB(glVertex3fv, _gloffset_Vertex3fv)
+ GL_STUB(glVertex3i, _gloffset_Vertex3i)
+ GL_STUB(glVertex3iv, _gloffset_Vertex3iv)
+ GL_STUB(glVertex3s, _gloffset_Vertex3s)
+ GL_STUB(glVertex3sv, _gloffset_Vertex3sv)
+ GL_STUB(glVertex4d, _gloffset_Vertex4d)
+ GL_STUB(glVertex4dv, _gloffset_Vertex4dv)
+ GL_STUB(glVertex4f, _gloffset_Vertex4f)
+ GL_STUB(glVertex4fv, _gloffset_Vertex4fv)
+ GL_STUB(glVertex4i, _gloffset_Vertex4i)
+ GL_STUB(glVertex4iv, _gloffset_Vertex4iv)
+ GL_STUB(glVertex4s, _gloffset_Vertex4s)
+ GL_STUB(glVertex4sv, _gloffset_Vertex4sv)
+ GL_STUB(glClipPlane, _gloffset_ClipPlane)
+ GL_STUB(glColorMaterial, _gloffset_ColorMaterial)
+ GL_STUB(glCullFace, _gloffset_CullFace)
+ GL_STUB(glFogf, _gloffset_Fogf)
+ GL_STUB(glFogfv, _gloffset_Fogfv)
+ GL_STUB(glFogi, _gloffset_Fogi)
+ GL_STUB(glFogiv, _gloffset_Fogiv)
+ GL_STUB(glFrontFace, _gloffset_FrontFace)
+ GL_STUB(glHint, _gloffset_Hint)
+ GL_STUB(glLightf, _gloffset_Lightf)
+ GL_STUB(glLightfv, _gloffset_Lightfv)
+ GL_STUB(glLighti, _gloffset_Lighti)
+ GL_STUB(glLightiv, _gloffset_Lightiv)
+ GL_STUB(glLightModelf, _gloffset_LightModelf)
+ GL_STUB(glLightModelfv, _gloffset_LightModelfv)
+ GL_STUB(glLightModeli, _gloffset_LightModeli)
+ GL_STUB(glLightModeliv, _gloffset_LightModeliv)
+ GL_STUB(glLineStipple, _gloffset_LineStipple)
+ GL_STUB(glLineWidth, _gloffset_LineWidth)
+ GL_STUB(glMaterialf, _gloffset_Materialf)
+ GL_STUB(glMaterialfv, _gloffset_Materialfv)
+ GL_STUB(glMateriali, _gloffset_Materiali)
+ GL_STUB(glMaterialiv, _gloffset_Materialiv)
+ GL_STUB(glPointSize, _gloffset_PointSize)
+ GL_STUB(glPolygonMode, _gloffset_PolygonMode)
+ GL_STUB(glPolygonStipple, _gloffset_PolygonStipple)
+ GL_STUB(glScissor, _gloffset_Scissor)
+ GL_STUB(glShadeModel, _gloffset_ShadeModel)
+ GL_STUB(glTexParameterf, _gloffset_TexParameterf)
+ GL_STUB(glTexParameterfv, _gloffset_TexParameterfv)
+ GL_STUB(glTexParameteri, _gloffset_TexParameteri)
+ GL_STUB(glTexParameteriv, _gloffset_TexParameteriv)
+ GL_STUB(glTexImage1D, _gloffset_TexImage1D)
+ GL_STUB(glTexImage2D, _gloffset_TexImage2D)
+ GL_STUB(glTexEnvf, _gloffset_TexEnvf)
+ GL_STUB(glTexEnvfv, _gloffset_TexEnvfv)
+ GL_STUB(glTexEnvi, _gloffset_TexEnvi)
+ GL_STUB(glTexEnviv, _gloffset_TexEnviv)
+ GL_STUB(glTexGend, _gloffset_TexGend)
+ GL_STUB(glTexGendv, _gloffset_TexGendv)
+ GL_STUB(glTexGenf, _gloffset_TexGenf)
+ GL_STUB(glTexGenfv, _gloffset_TexGenfv)
+ GL_STUB(glTexGeni, _gloffset_TexGeni)
+ GL_STUB(glTexGeniv, _gloffset_TexGeniv)
+ GL_STUB(glFeedbackBuffer, _gloffset_FeedbackBuffer)
+ GL_STUB(glSelectBuffer, _gloffset_SelectBuffer)
+ GL_STUB(glRenderMode, _gloffset_RenderMode)
+ GL_STUB(glInitNames, _gloffset_InitNames)
+ GL_STUB(glLoadName, _gloffset_LoadName)
+ GL_STUB(glPassThrough, _gloffset_PassThrough)
+ GL_STUB(glPopName, _gloffset_PopName)
+ GL_STUB(glPushName, _gloffset_PushName)
+ GL_STUB(glDrawBuffer, _gloffset_DrawBuffer)
+ GL_STUB(glClear, _gloffset_Clear)
+ GL_STUB(glClearAccum, _gloffset_ClearAccum)
+ GL_STUB(glClearIndex, _gloffset_ClearIndex)
+ GL_STUB(glClearColor, _gloffset_ClearColor)
+ GL_STUB(glClearStencil, _gloffset_ClearStencil)
+ GL_STUB(glClearDepth, _gloffset_ClearDepth)
+ GL_STUB(glStencilMask, _gloffset_StencilMask)
+ GL_STUB(glColorMask, _gloffset_ColorMask)
+ GL_STUB(glDepthMask, _gloffset_DepthMask)
+ GL_STUB(glIndexMask, _gloffset_IndexMask)
+ GL_STUB(glAccum, _gloffset_Accum)
+ GL_STUB(glDisable, _gloffset_Disable)
+ GL_STUB(glEnable, _gloffset_Enable)
+ GL_STUB(glFinish, _gloffset_Finish)
+ GL_STUB(glFlush, _gloffset_Flush)
+ GL_STUB(glPopAttrib, _gloffset_PopAttrib)
+ GL_STUB(glPushAttrib, _gloffset_PushAttrib)
+ GL_STUB(glMap1d, _gloffset_Map1d)
+ GL_STUB(glMap1f, _gloffset_Map1f)
+ GL_STUB(glMap2d, _gloffset_Map2d)
+ GL_STUB(glMap2f, _gloffset_Map2f)
+ GL_STUB(glMapGrid1d, _gloffset_MapGrid1d)
+ GL_STUB(glMapGrid1f, _gloffset_MapGrid1f)
+ GL_STUB(glMapGrid2d, _gloffset_MapGrid2d)
+ GL_STUB(glMapGrid2f, _gloffset_MapGrid2f)
+ GL_STUB(glEvalCoord1d, _gloffset_EvalCoord1d)
+ GL_STUB(glEvalCoord1dv, _gloffset_EvalCoord1dv)
+ GL_STUB(glEvalCoord1f, _gloffset_EvalCoord1f)
+ GL_STUB(glEvalCoord1fv, _gloffset_EvalCoord1fv)
+ GL_STUB(glEvalCoord2d, _gloffset_EvalCoord2d)
+ GL_STUB(glEvalCoord2dv, _gloffset_EvalCoord2dv)
+ GL_STUB(glEvalCoord2f, _gloffset_EvalCoord2f)
+ GL_STUB(glEvalCoord2fv, _gloffset_EvalCoord2fv)
+ GL_STUB(glEvalMesh1, _gloffset_EvalMesh1)
+ GL_STUB(glEvalPoint1, _gloffset_EvalPoint1)
+ GL_STUB(glEvalMesh2, _gloffset_EvalMesh2)
+ GL_STUB(glEvalPoint2, _gloffset_EvalPoint2)
+ GL_STUB(glAlphaFunc, _gloffset_AlphaFunc)
+ GL_STUB(glBlendFunc, _gloffset_BlendFunc)
+ GL_STUB(glLogicOp, _gloffset_LogicOp)
+ GL_STUB(glStencilFunc, _gloffset_StencilFunc)
+ GL_STUB(glStencilOp, _gloffset_StencilOp)
+ GL_STUB(glDepthFunc, _gloffset_DepthFunc)
+ GL_STUB(glPixelZoom, _gloffset_PixelZoom)
+ GL_STUB(glPixelTransferf, _gloffset_PixelTransferf)
+ GL_STUB(glPixelTransferi, _gloffset_PixelTransferi)
+ GL_STUB(glPixelStoref, _gloffset_PixelStoref)
+ GL_STUB(glPixelStorei, _gloffset_PixelStorei)
+ GL_STUB(glPixelMapfv, _gloffset_PixelMapfv)
+ GL_STUB(glPixelMapuiv, _gloffset_PixelMapuiv)
+ GL_STUB(glPixelMapusv, _gloffset_PixelMapusv)
+ GL_STUB(glReadBuffer, _gloffset_ReadBuffer)
+ GL_STUB(glCopyPixels, _gloffset_CopyPixels)
+ GL_STUB(glReadPixels, _gloffset_ReadPixels)
+ GL_STUB(glDrawPixels, _gloffset_DrawPixels)
+ GL_STUB(glGetBooleanv, _gloffset_GetBooleanv)
+ GL_STUB(glGetClipPlane, _gloffset_GetClipPlane)
+ GL_STUB(glGetDoublev, _gloffset_GetDoublev)
+ GL_STUB(glGetError, _gloffset_GetError)
+ GL_STUB(glGetFloatv, _gloffset_GetFloatv)
+ GL_STUB(glGetIntegerv, _gloffset_GetIntegerv)
+ GL_STUB(glGetLightfv, _gloffset_GetLightfv)
+ GL_STUB(glGetLightiv, _gloffset_GetLightiv)
+ GL_STUB(glGetMapdv, _gloffset_GetMapdv)
+ GL_STUB(glGetMapfv, _gloffset_GetMapfv)
+ GL_STUB(glGetMapiv, _gloffset_GetMapiv)
+ GL_STUB(glGetMaterialfv, _gloffset_GetMaterialfv)
+ GL_STUB(glGetMaterialiv, _gloffset_GetMaterialiv)
+ GL_STUB(glGetPixelMapfv, _gloffset_GetPixelMapfv)
+ GL_STUB(glGetPixelMapuiv, _gloffset_GetPixelMapuiv)
+ GL_STUB(glGetPixelMapusv, _gloffset_GetPixelMapusv)
+ GL_STUB(glGetPolygonStipple, _gloffset_GetPolygonStipple)
+ GL_STUB(glGetString, _gloffset_GetString)
+ GL_STUB(glGetTexEnvfv, _gloffset_GetTexEnvfv)
+ GL_STUB(glGetTexEnviv, _gloffset_GetTexEnviv)
+ GL_STUB(glGetTexGendv, _gloffset_GetTexGendv)
+ GL_STUB(glGetTexGenfv, _gloffset_GetTexGenfv)
+ GL_STUB(glGetTexGeniv, _gloffset_GetTexGeniv)
+ GL_STUB(glGetTexImage, _gloffset_GetTexImage)
+ GL_STUB(glGetTexParameterfv, _gloffset_GetTexParameterfv)
+ GL_STUB(glGetTexParameteriv, _gloffset_GetTexParameteriv)
+ GL_STUB(glGetTexLevelParameterfv, _gloffset_GetTexLevelParameterfv)
+ GL_STUB(glGetTexLevelParameteriv, _gloffset_GetTexLevelParameteriv)
+ GL_STUB(glIsEnabled, _gloffset_IsEnabled)
+ GL_STUB(glIsList, _gloffset_IsList)
+ GL_STUB(glDepthRange, _gloffset_DepthRange)
+ GL_STUB(glFrustum, _gloffset_Frustum)
+ GL_STUB(glLoadIdentity, _gloffset_LoadIdentity)
+ GL_STUB(glLoadMatrixf, _gloffset_LoadMatrixf)
+ GL_STUB(glLoadMatrixd, _gloffset_LoadMatrixd)
+ GL_STUB(glMatrixMode, _gloffset_MatrixMode)
+ GL_STUB(glMultMatrixf, _gloffset_MultMatrixf)
+ GL_STUB(glMultMatrixd, _gloffset_MultMatrixd)
+ GL_STUB(glOrtho, _gloffset_Ortho)
+ GL_STUB(glPopMatrix, _gloffset_PopMatrix)
+ GL_STUB(glPushMatrix, _gloffset_PushMatrix)
+ GL_STUB(glRotated, _gloffset_Rotated)
+ GL_STUB(glRotatef, _gloffset_Rotatef)
+ GL_STUB(glScaled, _gloffset_Scaled)
+ GL_STUB(glScalef, _gloffset_Scalef)
+ GL_STUB(glTranslated, _gloffset_Translated)
+ GL_STUB(glTranslatef, _gloffset_Translatef)
+ GL_STUB(glViewport, _gloffset_Viewport)
+ GL_STUB(glArrayElement, _gloffset_ArrayElement)
+ GL_STUB(glBindTexture, _gloffset_BindTexture)
+ GL_STUB(glColorPointer, _gloffset_ColorPointer)
+ GL_STUB(glDisableClientState, _gloffset_DisableClientState)
+ GL_STUB(glDrawArrays, _gloffset_DrawArrays)
+ GL_STUB(glDrawElements, _gloffset_DrawElements)
+ GL_STUB(glEdgeFlagPointer, _gloffset_EdgeFlagPointer)
+ GL_STUB(glEnableClientState, _gloffset_EnableClientState)
+ GL_STUB(glIndexPointer, _gloffset_IndexPointer)
+ GL_STUB(glIndexub, _gloffset_Indexub)
+ GL_STUB(glIndexubv, _gloffset_Indexubv)
+ GL_STUB(glInterleavedArrays, _gloffset_InterleavedArrays)
+ GL_STUB(glNormalPointer, _gloffset_NormalPointer)
+ GL_STUB(glPolygonOffset, _gloffset_PolygonOffset)
+ GL_STUB(glTexCoordPointer, _gloffset_TexCoordPointer)
+ GL_STUB(glVertexPointer, _gloffset_VertexPointer)
+ GL_STUB(glAreTexturesResident, _gloffset_AreTexturesResident)
+ GL_STUB(glCopyTexImage1D, _gloffset_CopyTexImage1D)
+ GL_STUB(glCopyTexImage2D, _gloffset_CopyTexImage2D)
+ GL_STUB(glCopyTexSubImage1D, _gloffset_CopyTexSubImage1D)
+ GL_STUB(glCopyTexSubImage2D, _gloffset_CopyTexSubImage2D)
+ GL_STUB(glDeleteTextures, _gloffset_DeleteTextures)
+ GL_STUB(glGenTextures, _gloffset_GenTextures)
+ GL_STUB(glGetPointerv, _gloffset_GetPointerv)
+ GL_STUB(glIsTexture, _gloffset_IsTexture)
+ GL_STUB(glPrioritizeTextures, _gloffset_PrioritizeTextures)
+ GL_STUB(glTexSubImage1D, _gloffset_TexSubImage1D)
+ GL_STUB(glTexSubImage2D, _gloffset_TexSubImage2D)
+ GL_STUB(glPopClientAttrib, _gloffset_PopClientAttrib)
+ GL_STUB(glPushClientAttrib, _gloffset_PushClientAttrib)
+ GL_STUB(glBlendColor, _gloffset_BlendColor)
+ GL_STUB(glBlendEquation, _gloffset_BlendEquation)
+ GL_STUB(glDrawRangeElements, _gloffset_DrawRangeElements)
+ GL_STUB(glColorTable, _gloffset_ColorTable)
+ GL_STUB(glColorTableParameterfv, _gloffset_ColorTableParameterfv)
+ GL_STUB(glColorTableParameteriv, _gloffset_ColorTableParameteriv)
+ GL_STUB(glCopyColorTable, _gloffset_CopyColorTable)
+ GL_STUB(glGetColorTable, _gloffset_GetColorTable)
+ GL_STUB(glGetColorTableParameterfv, _gloffset_GetColorTableParameterfv)
+ GL_STUB(glGetColorTableParameteriv, _gloffset_GetColorTableParameteriv)
+ GL_STUB(glColorSubTable, _gloffset_ColorSubTable)
+ GL_STUB(glCopyColorSubTable, _gloffset_CopyColorSubTable)
+ GL_STUB(glConvolutionFilter1D, _gloffset_ConvolutionFilter1D)
+ GL_STUB(glConvolutionFilter2D, _gloffset_ConvolutionFilter2D)
+ GL_STUB(glConvolutionParameterf, _gloffset_ConvolutionParameterf)
+ GL_STUB(glConvolutionParameterfv, _gloffset_ConvolutionParameterfv)
+ GL_STUB(glConvolutionParameteri, _gloffset_ConvolutionParameteri)
+ GL_STUB(glConvolutionParameteriv, _gloffset_ConvolutionParameteriv)
+ GL_STUB(glCopyConvolutionFilter1D, _gloffset_CopyConvolutionFilter1D)
+ GL_STUB(glCopyConvolutionFilter2D, _gloffset_CopyConvolutionFilter2D)
+ GL_STUB(glGetConvolutionFilter, _gloffset_GetConvolutionFilter)
+ GL_STUB(glGetConvolutionParameterfv, _gloffset_GetConvolutionParameterfv)
+ GL_STUB(glGetConvolutionParameteriv, _gloffset_GetConvolutionParameteriv)
+ GL_STUB(glGetSeparableFilter, _gloffset_GetSeparableFilter)
+ GL_STUB(glSeparableFilter2D, _gloffset_SeparableFilter2D)
+ GL_STUB(glGetHistogram, _gloffset_GetHistogram)
+ GL_STUB(glGetHistogramParameterfv, _gloffset_GetHistogramParameterfv)
+ GL_STUB(glGetHistogramParameteriv, _gloffset_GetHistogramParameteriv)
+ GL_STUB(glGetMinmax, _gloffset_GetMinmax)
+ GL_STUB(glGetMinmaxParameterfv, _gloffset_GetMinmaxParameterfv)
+ GL_STUB(glGetMinmaxParameteriv, _gloffset_GetMinmaxParameteriv)
+ GL_STUB(glHistogram, _gloffset_Histogram)
+ GL_STUB(glMinmax, _gloffset_Minmax)
+ GL_STUB(glResetHistogram, _gloffset_ResetHistogram)
+ GL_STUB(glResetMinmax, _gloffset_ResetMinmax)
+ GL_STUB(glTexImage3D, _gloffset_TexImage3D)
+ GL_STUB(glTexSubImage3D, _gloffset_TexSubImage3D)
+ GL_STUB(glCopyTexSubImage3D, _gloffset_CopyTexSubImage3D)
+ GL_STUB(glActiveTextureARB, _gloffset_ActiveTextureARB)
+ GL_STUB(glClientActiveTextureARB, _gloffset_ClientActiveTextureARB)
+ GL_STUB(glMultiTexCoord1dARB, _gloffset_MultiTexCoord1dARB)
+ GL_STUB(glMultiTexCoord1dvARB, _gloffset_MultiTexCoord1dvARB)
+ GL_STUB(glMultiTexCoord1fARB, _gloffset_MultiTexCoord1fARB)
+ GL_STUB(glMultiTexCoord1fvARB, _gloffset_MultiTexCoord1fvARB)
+ GL_STUB(glMultiTexCoord1iARB, _gloffset_MultiTexCoord1iARB)
+ GL_STUB(glMultiTexCoord1ivARB, _gloffset_MultiTexCoord1ivARB)
+ GL_STUB(glMultiTexCoord1sARB, _gloffset_MultiTexCoord1sARB)
+ GL_STUB(glMultiTexCoord1svARB, _gloffset_MultiTexCoord1svARB)
+ GL_STUB(glMultiTexCoord2dARB, _gloffset_MultiTexCoord2dARB)
+ GL_STUB(glMultiTexCoord2dvARB, _gloffset_MultiTexCoord2dvARB)
+ GL_STUB(glMultiTexCoord2fARB, _gloffset_MultiTexCoord2fARB)
+ GL_STUB(glMultiTexCoord2fvARB, _gloffset_MultiTexCoord2fvARB)
+ GL_STUB(glMultiTexCoord2iARB, _gloffset_MultiTexCoord2iARB)
+ GL_STUB(glMultiTexCoord2ivARB, _gloffset_MultiTexCoord2ivARB)
+ GL_STUB(glMultiTexCoord2sARB, _gloffset_MultiTexCoord2sARB)
+ GL_STUB(glMultiTexCoord2svARB, _gloffset_MultiTexCoord2svARB)
+ GL_STUB(glMultiTexCoord3dARB, _gloffset_MultiTexCoord3dARB)
+ GL_STUB(glMultiTexCoord3dvARB, _gloffset_MultiTexCoord3dvARB)
+ GL_STUB(glMultiTexCoord3fARB, _gloffset_MultiTexCoord3fARB)
+ GL_STUB(glMultiTexCoord3fvARB, _gloffset_MultiTexCoord3fvARB)
+ GL_STUB(glMultiTexCoord3iARB, _gloffset_MultiTexCoord3iARB)
+ GL_STUB(glMultiTexCoord3ivARB, _gloffset_MultiTexCoord3ivARB)
+ GL_STUB(glMultiTexCoord3sARB, _gloffset_MultiTexCoord3sARB)
+ GL_STUB(glMultiTexCoord3svARB, _gloffset_MultiTexCoord3svARB)
+ GL_STUB(glMultiTexCoord4dARB, _gloffset_MultiTexCoord4dARB)
+ GL_STUB(glMultiTexCoord4dvARB, _gloffset_MultiTexCoord4dvARB)
+ GL_STUB(glMultiTexCoord4fARB, _gloffset_MultiTexCoord4fARB)
+ GL_STUB(glMultiTexCoord4fvARB, _gloffset_MultiTexCoord4fvARB)
+ GL_STUB(glMultiTexCoord4iARB, _gloffset_MultiTexCoord4iARB)
+ GL_STUB(glMultiTexCoord4ivARB, _gloffset_MultiTexCoord4ivARB)
+ GL_STUB(glMultiTexCoord4sARB, _gloffset_MultiTexCoord4sARB)
+ GL_STUB(glMultiTexCoord4svARB, _gloffset_MultiTexCoord4svARB)
+ GL_STUB(glLoadTransposeMatrixfARB, _gloffset_LoadTransposeMatrixfARB)
+ GL_STUB(glLoadTransposeMatrixdARB, _gloffset_LoadTransposeMatrixdARB)
+ GL_STUB(glMultTransposeMatrixfARB, _gloffset_MultTransposeMatrixfARB)
+ GL_STUB(glMultTransposeMatrixdARB, _gloffset_MultTransposeMatrixdARB)
+ GL_STUB(glSampleCoverageARB, _gloffset_SampleCoverageARB)
+ GL_STUB(glDrawBuffersARB, _gloffset_DrawBuffersARB)
+ GL_STUB(glPolygonOffsetEXT, _gloffset_PolygonOffsetEXT)
+ GL_STUB(glGetTexFilterFuncSGIS, _gloffset_GetTexFilterFuncSGIS)
+ GL_STUB(glTexFilterFuncSGIS, _gloffset_TexFilterFuncSGIS)
+ GL_STUB(glGetHistogramEXT, _gloffset_GetHistogramEXT)
+ GL_STUB(glGetHistogramParameterfvEXT, _gloffset_GetHistogramParameterfvEXT)
+ GL_STUB(glGetHistogramParameterivEXT, _gloffset_GetHistogramParameterivEXT)
+ GL_STUB(glGetMinmaxEXT, _gloffset_GetMinmaxEXT)
+ GL_STUB(glGetMinmaxParameterfvEXT, _gloffset_GetMinmaxParameterfvEXT)
+ GL_STUB(glGetMinmaxParameterivEXT, _gloffset_GetMinmaxParameterivEXT)
+ GL_STUB(glGetConvolutionFilterEXT, _gloffset_GetConvolutionFilterEXT)
+ GL_STUB(glGetConvolutionParameterfvEXT, _gloffset_GetConvolutionParameterfvEXT)
+ GL_STUB(glGetConvolutionParameterivEXT, _gloffset_GetConvolutionParameterivEXT)
+ GL_STUB(glGetSeparableFilterEXT, _gloffset_GetSeparableFilterEXT)
+ GL_STUB(glGetColorTableSGI, _gloffset_GetColorTableSGI)
+ GL_STUB(glGetColorTableParameterfvSGI, _gloffset_GetColorTableParameterfvSGI)
+ GL_STUB(glGetColorTableParameterivSGI, _gloffset_GetColorTableParameterivSGI)
+ GL_STUB(glPixelTexGenSGIX, _gloffset_PixelTexGenSGIX)
+ GL_STUB(glPixelTexGenParameteriSGIS, _gloffset_PixelTexGenParameteriSGIS)
+ GL_STUB(glPixelTexGenParameterivSGIS, _gloffset_PixelTexGenParameterivSGIS)
+ GL_STUB(glPixelTexGenParameterfSGIS, _gloffset_PixelTexGenParameterfSGIS)
+ GL_STUB(glPixelTexGenParameterfvSGIS, _gloffset_PixelTexGenParameterfvSGIS)
+ GL_STUB(glGetPixelTexGenParameterivSGIS, _gloffset_GetPixelTexGenParameterivSGIS)
+ GL_STUB(glGetPixelTexGenParameterfvSGIS, _gloffset_GetPixelTexGenParameterfvSGIS)
+ GL_STUB(glTexImage4DSGIS, _gloffset_TexImage4DSGIS)
+ GL_STUB(glTexSubImage4DSGIS, _gloffset_TexSubImage4DSGIS)
+ GL_STUB(glAreTexturesResidentEXT, _gloffset_AreTexturesResidentEXT)
+ GL_STUB(glGenTexturesEXT, _gloffset_GenTexturesEXT)
+ GL_STUB(glIsTextureEXT, _gloffset_IsTextureEXT)
+ GL_STUB(glDetailTexFuncSGIS, _gloffset_DetailTexFuncSGIS)
+ GL_STUB(glGetDetailTexFuncSGIS, _gloffset_GetDetailTexFuncSGIS)
+ GL_STUB(glSharpenTexFuncSGIS, _gloffset_SharpenTexFuncSGIS)
+ GL_STUB(glGetSharpenTexFuncSGIS, _gloffset_GetSharpenTexFuncSGIS)
+ GL_STUB(glSampleMaskSGIS, _gloffset_SampleMaskSGIS)
+ GL_STUB(glSamplePatternSGIS, _gloffset_SamplePatternSGIS)
+ GL_STUB(glColorPointerEXT, _gloffset_ColorPointerEXT)
+ GL_STUB(glEdgeFlagPointerEXT, _gloffset_EdgeFlagPointerEXT)
+ GL_STUB(glIndexPointerEXT, _gloffset_IndexPointerEXT)
+ GL_STUB(glNormalPointerEXT, _gloffset_NormalPointerEXT)
+ GL_STUB(glTexCoordPointerEXT, _gloffset_TexCoordPointerEXT)
+ GL_STUB(glVertexPointerEXT, _gloffset_VertexPointerEXT)
+ GL_STUB(glSpriteParameterfSGIX, _gloffset_SpriteParameterfSGIX)
+ GL_STUB(glSpriteParameterfvSGIX, _gloffset_SpriteParameterfvSGIX)
+ GL_STUB(glSpriteParameteriSGIX, _gloffset_SpriteParameteriSGIX)
+ GL_STUB(glSpriteParameterivSGIX, _gloffset_SpriteParameterivSGIX)
+ GL_STUB(glPointParameterfEXT, _gloffset_PointParameterfEXT)
+ GL_STUB(glPointParameterfvEXT, _gloffset_PointParameterfvEXT)
+ GL_STUB(glGetInstrumentsSGIX, _gloffset_GetInstrumentsSGIX)
+ GL_STUB(glInstrumentsBufferSGIX, _gloffset_InstrumentsBufferSGIX)
+ GL_STUB(glPollInstrumentsSGIX, _gloffset_PollInstrumentsSGIX)
+ GL_STUB(glReadInstrumentsSGIX, _gloffset_ReadInstrumentsSGIX)
+ GL_STUB(glStartInstrumentsSGIX, _gloffset_StartInstrumentsSGIX)
+ GL_STUB(glStopInstrumentsSGIX, _gloffset_StopInstrumentsSGIX)
+ GL_STUB(glFrameZoomSGIX, _gloffset_FrameZoomSGIX)
+ GL_STUB(glTagSampleBufferSGIX, _gloffset_TagSampleBufferSGIX)
+ GL_STUB(glReferencePlaneSGIX, _gloffset_ReferencePlaneSGIX)
+ GL_STUB(glFlushRasterSGIX, _gloffset_FlushRasterSGIX)
+ GL_STUB(glGetListParameterfvSGIX, _gloffset_GetListParameterfvSGIX)
+ GL_STUB(glGetListParameterivSGIX, _gloffset_GetListParameterivSGIX)
+ GL_STUB(glListParameterfSGIX, _gloffset_ListParameterfSGIX)
+ GL_STUB(glListParameterfvSGIX, _gloffset_ListParameterfvSGIX)
+ GL_STUB(glListParameteriSGIX, _gloffset_ListParameteriSGIX)
+ GL_STUB(glListParameterivSGIX, _gloffset_ListParameterivSGIX)
+ GL_STUB(glFragmentColorMaterialSGIX, _gloffset_FragmentColorMaterialSGIX)
+ GL_STUB(glFragmentLightfSGIX, _gloffset_FragmentLightfSGIX)
+ GL_STUB(glFragmentLightfvSGIX, _gloffset_FragmentLightfvSGIX)
+ GL_STUB(glFragmentLightiSGIX, _gloffset_FragmentLightiSGIX)
+ GL_STUB(glFragmentLightivSGIX, _gloffset_FragmentLightivSGIX)
+ GL_STUB(glFragmentLightModelfSGIX, _gloffset_FragmentLightModelfSGIX)
+ GL_STUB(glFragmentLightModelfvSGIX, _gloffset_FragmentLightModelfvSGIX)
+ GL_STUB(glFragmentLightModeliSGIX, _gloffset_FragmentLightModeliSGIX)
+ GL_STUB(glFragmentLightModelivSGIX, _gloffset_FragmentLightModelivSGIX)
+ GL_STUB(glFragmentMaterialfSGIX, _gloffset_FragmentMaterialfSGIX)
+ GL_STUB(glFragmentMaterialfvSGIX, _gloffset_FragmentMaterialfvSGIX)
+ GL_STUB(glFragmentMaterialiSGIX, _gloffset_FragmentMaterialiSGIX)
+ GL_STUB(glFragmentMaterialivSGIX, _gloffset_FragmentMaterialivSGIX)
+ GL_STUB(glGetFragmentLightfvSGIX, _gloffset_GetFragmentLightfvSGIX)
+ GL_STUB(glGetFragmentLightivSGIX, _gloffset_GetFragmentLightivSGIX)
+ GL_STUB(glGetFragmentMaterialfvSGIX, _gloffset_GetFragmentMaterialfvSGIX)
+ GL_STUB(glGetFragmentMaterialivSGIX, _gloffset_GetFragmentMaterialivSGIX)
+ GL_STUB(glLightEnviSGIX, _gloffset_LightEnviSGIX)
+ GL_STUB(glVertexWeightfEXT, _gloffset_VertexWeightfEXT)
+ GL_STUB(glVertexWeightfvEXT, _gloffset_VertexWeightfvEXT)
+ GL_STUB(glVertexWeightPointerEXT, _gloffset_VertexWeightPointerEXT)
+ GL_STUB(glFlushVertexArrayRangeNV, _gloffset_FlushVertexArrayRangeNV)
+ GL_STUB(glVertexArrayRangeNV, _gloffset_VertexArrayRangeNV)
+ GL_STUB(glCombinerParameterfvNV, _gloffset_CombinerParameterfvNV)
+ GL_STUB(glCombinerParameterfNV, _gloffset_CombinerParameterfNV)
+ GL_STUB(glCombinerParameterivNV, _gloffset_CombinerParameterivNV)
+ GL_STUB(glCombinerParameteriNV, _gloffset_CombinerParameteriNV)
+ GL_STUB(glCombinerInputNV, _gloffset_CombinerInputNV)
+ GL_STUB(glCombinerOutputNV, _gloffset_CombinerOutputNV)
+ GL_STUB(glFinalCombinerInputNV, _gloffset_FinalCombinerInputNV)
+ GL_STUB(glGetCombinerInputParameterfvNV, _gloffset_GetCombinerInputParameterfvNV)
+ GL_STUB(glGetCombinerInputParameterivNV, _gloffset_GetCombinerInputParameterivNV)
+ GL_STUB(glGetCombinerOutputParameterfvNV, _gloffset_GetCombinerOutputParameterfvNV)
+ GL_STUB(glGetCombinerOutputParameterivNV, _gloffset_GetCombinerOutputParameterivNV)
+ GL_STUB(glGetFinalCombinerInputParameterfvNV, _gloffset_GetFinalCombinerInputParameterfvNV)
+ GL_STUB(glGetFinalCombinerInputParameterivNV, _gloffset_GetFinalCombinerInputParameterivNV)
+ GL_STUB(glResizeBuffersMESA, _gloffset_ResizeBuffersMESA)
+ GL_STUB(glWindowPos2dMESA, _gloffset_WindowPos2dMESA)
+ GL_STUB(glWindowPos2dvMESA, _gloffset_WindowPos2dvMESA)
+ GL_STUB(glWindowPos2fMESA, _gloffset_WindowPos2fMESA)
+ GL_STUB(glWindowPos2fvMESA, _gloffset_WindowPos2fvMESA)
+ GL_STUB(glWindowPos2iMESA, _gloffset_WindowPos2iMESA)
+ GL_STUB(glWindowPos2ivMESA, _gloffset_WindowPos2ivMESA)
+ GL_STUB(glWindowPos2sMESA, _gloffset_WindowPos2sMESA)
+ GL_STUB(glWindowPos2svMESA, _gloffset_WindowPos2svMESA)
+ GL_STUB(glWindowPos3dMESA, _gloffset_WindowPos3dMESA)
+ GL_STUB(glWindowPos3dvMESA, _gloffset_WindowPos3dvMESA)
+ GL_STUB(glWindowPos3fMESA, _gloffset_WindowPos3fMESA)
+ GL_STUB(glWindowPos3fvMESA, _gloffset_WindowPos3fvMESA)
+ GL_STUB(glWindowPos3iMESA, _gloffset_WindowPos3iMESA)
+ GL_STUB(glWindowPos3ivMESA, _gloffset_WindowPos3ivMESA)
+ GL_STUB(glWindowPos3sMESA, _gloffset_WindowPos3sMESA)
+ GL_STUB(glWindowPos3svMESA, _gloffset_WindowPos3svMESA)
+ GL_STUB(glWindowPos4dMESA, _gloffset_WindowPos4dMESA)
+ GL_STUB(glWindowPos4dvMESA, _gloffset_WindowPos4dvMESA)
+ GL_STUB(glWindowPos4fMESA, _gloffset_WindowPos4fMESA)
+ GL_STUB(glWindowPos4fvMESA, _gloffset_WindowPos4fvMESA)
+ GL_STUB(glWindowPos4iMESA, _gloffset_WindowPos4iMESA)
+ GL_STUB(glWindowPos4ivMESA, _gloffset_WindowPos4ivMESA)
+ GL_STUB(glWindowPos4sMESA, _gloffset_WindowPos4sMESA)
+ GL_STUB(glWindowPos4svMESA, _gloffset_WindowPos4svMESA)
+ GL_STUB(glBlendFuncSeparateEXT, _gloffset_BlendFuncSeparateEXT)
+ GL_STUB(glIndexMaterialEXT, _gloffset_IndexMaterialEXT)
+ GL_STUB(glIndexFuncEXT, _gloffset_IndexFuncEXT)
+ GL_STUB(glLockArraysEXT, _gloffset_LockArraysEXT)
+ GL_STUB(glUnlockArraysEXT, _gloffset_UnlockArraysEXT)
+ GL_STUB(glCullParameterdvEXT, _gloffset_CullParameterdvEXT)
+ GL_STUB(glCullParameterfvEXT, _gloffset_CullParameterfvEXT)
+ GL_STUB(glHintPGI, _gloffset_HintPGI)
+ GL_STUB(glFogCoordfEXT, _gloffset_FogCoordfEXT)
+ GL_STUB(glFogCoordfvEXT, _gloffset_FogCoordfvEXT)
+ GL_STUB(glFogCoorddEXT, _gloffset_FogCoorddEXT)
+ GL_STUB(glFogCoorddvEXT, _gloffset_FogCoorddvEXT)
+ GL_STUB(glFogCoordPointerEXT, _gloffset_FogCoordPointerEXT)
+ GL_STUB(glGetColorTableEXT, _gloffset_GetColorTableEXT)
+ GL_STUB(glGetColorTableParameterivEXT, _gloffset_GetColorTableParameterivEXT)
+ GL_STUB(glGetColorTableParameterfvEXT, _gloffset_GetColorTableParameterfvEXT)
+ GL_STUB(glTbufferMask3DFX, _gloffset_TbufferMask3DFX)
+ GL_STUB(glCompressedTexImage3DARB, _gloffset_CompressedTexImage3DARB)
+ GL_STUB(glCompressedTexImage2DARB, _gloffset_CompressedTexImage2DARB)
+ GL_STUB(glCompressedTexImage1DARB, _gloffset_CompressedTexImage1DARB)
+ GL_STUB(glCompressedTexSubImage3DARB, _gloffset_CompressedTexSubImage3DARB)
+ GL_STUB(glCompressedTexSubImage2DARB, _gloffset_CompressedTexSubImage2DARB)
+ GL_STUB(glCompressedTexSubImage1DARB, _gloffset_CompressedTexSubImage1DARB)
+ GL_STUB(glGetCompressedTexImageARB, _gloffset_GetCompressedTexImageARB)
+ GL_STUB(glSecondaryColor3bEXT, _gloffset_SecondaryColor3bEXT)
+ GL_STUB(glSecondaryColor3bvEXT, _gloffset_SecondaryColor3bvEXT)
+ GL_STUB(glSecondaryColor3dEXT, _gloffset_SecondaryColor3dEXT)
+ GL_STUB(glSecondaryColor3dvEXT, _gloffset_SecondaryColor3dvEXT)
+ GL_STUB(glSecondaryColor3fEXT, _gloffset_SecondaryColor3fEXT)
+ GL_STUB(glSecondaryColor3fvEXT, _gloffset_SecondaryColor3fvEXT)
+ GL_STUB(glSecondaryColor3iEXT, _gloffset_SecondaryColor3iEXT)
+ GL_STUB(glSecondaryColor3ivEXT, _gloffset_SecondaryColor3ivEXT)
+ GL_STUB(glSecondaryColor3sEXT, _gloffset_SecondaryColor3sEXT)
+ GL_STUB(glSecondaryColor3svEXT, _gloffset_SecondaryColor3svEXT)
+ GL_STUB(glSecondaryColor3ubEXT, _gloffset_SecondaryColor3ubEXT)
+ GL_STUB(glSecondaryColor3ubvEXT, _gloffset_SecondaryColor3ubvEXT)
+ GL_STUB(glSecondaryColor3uiEXT, _gloffset_SecondaryColor3uiEXT)
+ GL_STUB(glSecondaryColor3uivEXT, _gloffset_SecondaryColor3uivEXT)
+ GL_STUB(glSecondaryColor3usEXT, _gloffset_SecondaryColor3usEXT)
+ GL_STUB(glSecondaryColor3usvEXT, _gloffset_SecondaryColor3usvEXT)
+ GL_STUB(glSecondaryColorPointerEXT, _gloffset_SecondaryColorPointerEXT)
+ GL_STUB(glAreProgramsResidentNV, _gloffset_AreProgramsResidentNV)
+ GL_STUB(glBindProgramNV, _gloffset_BindProgramNV)
+ GL_STUB(glDeleteProgramsNV, _gloffset_DeleteProgramsNV)
+ GL_STUB(glExecuteProgramNV, _gloffset_ExecuteProgramNV)
+ GL_STUB(glGenProgramsNV, _gloffset_GenProgramsNV)
+ GL_STUB(glGetProgramParameterdvNV, _gloffset_GetProgramParameterdvNV)
+ GL_STUB(glGetProgramParameterfvNV, _gloffset_GetProgramParameterfvNV)
+ GL_STUB(glGetProgramivNV, _gloffset_GetProgramivNV)
+ GL_STUB(glGetProgramStringNV, _gloffset_GetProgramStringNV)
+ GL_STUB(glGetTrackMatrixivNV, _gloffset_GetTrackMatrixivNV)
+ GL_STUB(glGetVertexAttribdvARB, _gloffset_GetVertexAttribdvARB)
+ GL_STUB(glGetVertexAttribfvARB, _gloffset_GetVertexAttribfvARB)
+ GL_STUB(glGetVertexAttribivARB, _gloffset_GetVertexAttribivARB)
+ GL_STUB(glGetVertexAttribPointervNV, _gloffset_GetVertexAttribPointervNV)
+ GL_STUB(glIsProgramNV, _gloffset_IsProgramNV)
+ GL_STUB(glLoadProgramNV, _gloffset_LoadProgramNV)
+ GL_STUB(glProgramParameter4dNV, _gloffset_ProgramParameter4dNV)
+ GL_STUB(glProgramParameter4dvNV, _gloffset_ProgramParameter4dvNV)
+ GL_STUB(glProgramParameter4fNV, _gloffset_ProgramParameter4fNV)
+ GL_STUB(glProgramParameter4fvNV, _gloffset_ProgramParameter4fvNV)
+ GL_STUB(glProgramParameters4dvNV, _gloffset_ProgramParameters4dvNV)
+ GL_STUB(glProgramParameters4fvNV, _gloffset_ProgramParameters4fvNV)
+ GL_STUB(glRequestResidentProgramsNV, _gloffset_RequestResidentProgramsNV)
+ GL_STUB(glTrackMatrixNV, _gloffset_TrackMatrixNV)
+ GL_STUB(glVertexAttribPointerNV, _gloffset_VertexAttribPointerNV)
+ GL_STUB(glVertexAttrib1dARB, _gloffset_VertexAttrib1dARB)
+ GL_STUB(glVertexAttrib1dvARB, _gloffset_VertexAttrib1dvARB)
+ GL_STUB(glVertexAttrib1fARB, _gloffset_VertexAttrib1fARB)
+ GL_STUB(glVertexAttrib1fvARB, _gloffset_VertexAttrib1fvARB)
+ GL_STUB(glVertexAttrib1sARB, _gloffset_VertexAttrib1sARB)
+ GL_STUB(glVertexAttrib1svARB, _gloffset_VertexAttrib1svARB)
+ GL_STUB(glVertexAttrib2dARB, _gloffset_VertexAttrib2dARB)
+ GL_STUB(glVertexAttrib2dvARB, _gloffset_VertexAttrib2dvARB)
+ GL_STUB(glVertexAttrib2fARB, _gloffset_VertexAttrib2fARB)
+ GL_STUB(glVertexAttrib2fvARB, _gloffset_VertexAttrib2fvARB)
+ GL_STUB(glVertexAttrib2sARB, _gloffset_VertexAttrib2sARB)
+ GL_STUB(glVertexAttrib2svARB, _gloffset_VertexAttrib2svARB)
+ GL_STUB(glVertexAttrib3dARB, _gloffset_VertexAttrib3dARB)
+ GL_STUB(glVertexAttrib3dvARB, _gloffset_VertexAttrib3dvARB)
+ GL_STUB(glVertexAttrib3fARB, _gloffset_VertexAttrib3fARB)
+ GL_STUB(glVertexAttrib3fvARB, _gloffset_VertexAttrib3fvARB)
+ GL_STUB(glVertexAttrib3sARB, _gloffset_VertexAttrib3sARB)
+ GL_STUB(glVertexAttrib3svARB, _gloffset_VertexAttrib3svARB)
+ GL_STUB(glVertexAttrib4dARB, _gloffset_VertexAttrib4dARB)
+ GL_STUB(glVertexAttrib4dvARB, _gloffset_VertexAttrib4dvARB)
+ GL_STUB(glVertexAttrib4fARB, _gloffset_VertexAttrib4fARB)
+ GL_STUB(glVertexAttrib4fvARB, _gloffset_VertexAttrib4fvARB)
+ GL_STUB(glVertexAttrib4sARB, _gloffset_VertexAttrib4sARB)
+ GL_STUB(glVertexAttrib4svARB, _gloffset_VertexAttrib4svARB)
+ GL_STUB(glVertexAttrib4NubARB, _gloffset_VertexAttrib4NubARB)
+ GL_STUB(glVertexAttrib4NubvARB, _gloffset_VertexAttrib4NubvARB)
+ GL_STUB(glVertexAttribs1dvNV, _gloffset_VertexAttribs1dvNV)
+ GL_STUB(glVertexAttribs1fvNV, _gloffset_VertexAttribs1fvNV)
+ GL_STUB(glVertexAttribs1svNV, _gloffset_VertexAttribs1svNV)
+ GL_STUB(glVertexAttribs2dvNV, _gloffset_VertexAttribs2dvNV)
+ GL_STUB(glVertexAttribs2fvNV, _gloffset_VertexAttribs2fvNV)
+ GL_STUB(glVertexAttribs2svNV, _gloffset_VertexAttribs2svNV)
+ GL_STUB(glVertexAttribs3dvNV, _gloffset_VertexAttribs3dvNV)
+ GL_STUB(glVertexAttribs3fvNV, _gloffset_VertexAttribs3fvNV)
+ GL_STUB(glVertexAttribs3svNV, _gloffset_VertexAttribs3svNV)
+ GL_STUB(glVertexAttribs4dvNV, _gloffset_VertexAttribs4dvNV)
+ GL_STUB(glVertexAttribs4fvNV, _gloffset_VertexAttribs4fvNV)
+ GL_STUB(glVertexAttribs4svNV, _gloffset_VertexAttribs4svNV)
+ GL_STUB(glVertexAttribs4ubvNV, _gloffset_VertexAttribs4ubvNV)
+ GL_STUB(glPointParameteriNV, _gloffset_PointParameteriNV)
+ GL_STUB(glPointParameterivNV, _gloffset_PointParameterivNV)
+ GL_STUB(glMultiDrawArraysEXT, _gloffset_MultiDrawArraysEXT)
+ GL_STUB(glMultiDrawElementsEXT, _gloffset_MultiDrawElementsEXT)
+ GL_STUB(glActiveStencilFaceEXT, _gloffset_ActiveStencilFaceEXT)
+ GL_STUB(glDeleteFencesNV, _gloffset_DeleteFencesNV)
+ GL_STUB(glGenFencesNV, _gloffset_GenFencesNV)
+ GL_STUB(glIsFenceNV, _gloffset_IsFenceNV)
+ GL_STUB(glTestFenceNV, _gloffset_TestFenceNV)
+ GL_STUB(glGetFenceivNV, _gloffset_GetFenceivNV)
+ GL_STUB(glFinishFenceNV, _gloffset_FinishFenceNV)
+ GL_STUB(glSetFenceNV, _gloffset_SetFenceNV)
+ GL_STUB(glVertexAttrib4bvARB, _gloffset_VertexAttrib4bvARB)
+ GL_STUB(glVertexAttrib4ivARB, _gloffset_VertexAttrib4ivARB)
+ GL_STUB(glVertexAttrib4ubvARB, _gloffset_VertexAttrib4ubvARB)
+ GL_STUB(glVertexAttrib4usvARB, _gloffset_VertexAttrib4usvARB)
+ GL_STUB(glVertexAttrib4uivARB, _gloffset_VertexAttrib4uivARB)
+ GL_STUB(glVertexAttrib4NbvARB, _gloffset_VertexAttrib4NbvARB)
+ GL_STUB(glVertexAttrib4NsvARB, _gloffset_VertexAttrib4NsvARB)
+ GL_STUB(glVertexAttrib4NivARB, _gloffset_VertexAttrib4NivARB)
+ GL_STUB(glVertexAttrib4NusvARB, _gloffset_VertexAttrib4NusvARB)
+ GL_STUB(glVertexAttrib4NuivARB, _gloffset_VertexAttrib4NuivARB)
+ GL_STUB(glVertexAttribPointerARB, _gloffset_VertexAttribPointerARB)
+ GL_STUB(glEnableVertexAttribArrayARB, _gloffset_EnableVertexAttribArrayARB)
+ GL_STUB(glDisableVertexAttribArrayARB, _gloffset_DisableVertexAttribArrayARB)
+ GL_STUB(glProgramStringARB, _gloffset_ProgramStringARB)
+ GL_STUB(glProgramEnvParameter4dARB, _gloffset_ProgramEnvParameter4dARB)
+ GL_STUB(glProgramEnvParameter4dvARB, _gloffset_ProgramEnvParameter4dvARB)
+ GL_STUB(glProgramEnvParameter4fARB, _gloffset_ProgramEnvParameter4fARB)
+ GL_STUB(glProgramEnvParameter4fvARB, _gloffset_ProgramEnvParameter4fvARB)
+ GL_STUB(glProgramLocalParameter4dARB, _gloffset_ProgramLocalParameter4dARB)
+ GL_STUB(glProgramLocalParameter4dvARB, _gloffset_ProgramLocalParameter4dvARB)
+ GL_STUB(glProgramLocalParameter4fARB, _gloffset_ProgramLocalParameter4fARB)
+ GL_STUB(glProgramLocalParameter4fvARB, _gloffset_ProgramLocalParameter4fvARB)
+ GL_STUB(glGetProgramEnvParameterdvARB, _gloffset_GetProgramEnvParameterdvARB)
+ GL_STUB(glGetProgramEnvParameterfvARB, _gloffset_GetProgramEnvParameterfvARB)
+ GL_STUB(glGetProgramLocalParameterdvARB, _gloffset_GetProgramLocalParameterdvARB)
+ GL_STUB(glGetProgramLocalParameterfvARB, _gloffset_GetProgramLocalParameterfvARB)
+ GL_STUB(glGetProgramivARB, _gloffset_GetProgramivARB)
+ GL_STUB(glGetProgramStringARB, _gloffset_GetProgramStringARB)
+ GL_STUB(glProgramNamedParameter4fNV, _gloffset_ProgramNamedParameter4fNV)
+ GL_STUB(glProgramNamedParameter4dNV, _gloffset_ProgramNamedParameter4dNV)
+ GL_STUB(glProgramNamedParameter4fvNV, _gloffset_ProgramNamedParameter4fvNV)
+ GL_STUB(glProgramNamedParameter4dvNV, _gloffset_ProgramNamedParameter4dvNV)
+ GL_STUB(glGetProgramNamedParameterfvNV, _gloffset_GetProgramNamedParameterfvNV)
+ GL_STUB(glGetProgramNamedParameterdvNV, _gloffset_GetProgramNamedParameterdvNV)
+ GL_STUB(glBindBufferARB, _gloffset_BindBufferARB)
+ GL_STUB(glBufferDataARB, _gloffset_BufferDataARB)
+ GL_STUB(glBufferSubDataARB, _gloffset_BufferSubDataARB)
+ GL_STUB(glDeleteBuffersARB, _gloffset_DeleteBuffersARB)
+ GL_STUB(glGenBuffersARB, _gloffset_GenBuffersARB)
+ GL_STUB(glGetBufferParameterivARB, _gloffset_GetBufferParameterivARB)
+ GL_STUB(glGetBufferPointervARB, _gloffset_GetBufferPointervARB)
+ GL_STUB(glGetBufferSubDataARB, _gloffset_GetBufferSubDataARB)
+ GL_STUB(glIsBufferARB, _gloffset_IsBufferARB)
+ GL_STUB(glMapBufferARB, _gloffset_MapBufferARB)
+ GL_STUB(glUnmapBufferARB, _gloffset_UnmapBufferARB)
+ GL_STUB(glDepthBoundsEXT, _gloffset_DepthBoundsEXT)
+ GL_STUB(glGenQueriesARB, _gloffset_GenQueriesARB)
+ GL_STUB(glDeleteQueriesARB, _gloffset_DeleteQueriesARB)
+ GL_STUB(glIsQueryARB, _gloffset_IsQueryARB)
+ GL_STUB(glBeginQueryARB, _gloffset_BeginQueryARB)
+ GL_STUB(glEndQueryARB, _gloffset_EndQueryARB)
+ GL_STUB(glGetQueryivARB, _gloffset_GetQueryivARB)
+ GL_STUB(glGetQueryObjectivARB, _gloffset_GetQueryObjectivARB)
+ GL_STUB(glGetQueryObjectuivARB, _gloffset_GetQueryObjectuivARB)
+ GL_STUB(glMultiModeDrawArraysIBM, _gloffset_MultiModeDrawArraysIBM)
+ GL_STUB(glMultiModeDrawElementsIBM, _gloffset_MultiModeDrawElementsIBM)
+ GL_STUB(glBlendEquationSeparateEXT, _gloffset_BlendEquationSeparateEXT)
+ GL_STUB(glDeleteObjectARB, _gloffset_DeleteObjectARB)
+ GL_STUB(glGetHandleARB, _gloffset_GetHandleARB)
+ GL_STUB(glDetachObjectARB, _gloffset_DetachObjectARB)
+ GL_STUB(glCreateShaderObjectARB, _gloffset_CreateShaderObjectARB)
+ GL_STUB(glShaderSourceARB, _gloffset_ShaderSourceARB)
+ GL_STUB(glCompileShaderARB, _gloffset_CompileShaderARB)
+ GL_STUB(glCreateProgramObjectARB, _gloffset_CreateProgramObjectARB)
+ GL_STUB(glAttachObjectARB, _gloffset_AttachObjectARB)
+ GL_STUB(glLinkProgramARB, _gloffset_LinkProgramARB)
+ GL_STUB(glUseProgramObjectARB, _gloffset_UseProgramObjectARB)
+ GL_STUB(glValidateProgramARB, _gloffset_ValidateProgramARB)
+ GL_STUB(glUniform1fARB, _gloffset_Uniform1fARB)
+ GL_STUB(glUniform2fARB, _gloffset_Uniform2fARB)
+ GL_STUB(glUniform3fARB, _gloffset_Uniform3fARB)
+ GL_STUB(glUniform4fARB, _gloffset_Uniform4fARB)
+ GL_STUB(glUniform1iARB, _gloffset_Uniform1iARB)
+ GL_STUB(glUniform2iARB, _gloffset_Uniform2iARB)
+ GL_STUB(glUniform3iARB, _gloffset_Uniform3iARB)
+ GL_STUB(glUniform4iARB, _gloffset_Uniform4iARB)
+ GL_STUB(glUniform1fvARB, _gloffset_Uniform1fvARB)
+ GL_STUB(glUniform2fvARB, _gloffset_Uniform2fvARB)
+ GL_STUB(glUniform3fvARB, _gloffset_Uniform3fvARB)
+ GL_STUB(glUniform4fvARB, _gloffset_Uniform4fvARB)
+ GL_STUB(glUniform1ivARB, _gloffset_Uniform1ivARB)
+ GL_STUB(glUniform2ivARB, _gloffset_Uniform2ivARB)
+ GL_STUB(glUniform3ivARB, _gloffset_Uniform3ivARB)
+ GL_STUB(glUniform4ivARB, _gloffset_Uniform4ivARB)
+ GL_STUB(glUniformMatrix2fvARB, _gloffset_UniformMatrix2fvARB)
+ GL_STUB(glUniformMatrix3fvARB, _gloffset_UniformMatrix3fvARB)
+ GL_STUB(glUniformMatrix4fvARB, _gloffset_UniformMatrix4fvARB)
+ GL_STUB(glGetObjectParameterfvARB, _gloffset_GetObjectParameterfvARB)
+ GL_STUB(glGetObjectParameterivARB, _gloffset_GetObjectParameterivARB)
+ GL_STUB(glGetInfoLogARB, _gloffset_GetInfoLogARB)
+ GL_STUB(glGetAttachedObjectsARB, _gloffset_GetAttachedObjectsARB)
+ GL_STUB(glGetUniformLocationARB, _gloffset_GetUniformLocationARB)
+ GL_STUB(glGetActiveUniformARB, _gloffset_GetActiveUniformARB)
+ GL_STUB(glGetUniformfvARB, _gloffset_GetUniformfvARB)
+ GL_STUB(glGetUniformivARB, _gloffset_GetUniformivARB)
+ GL_STUB(glGetShaderSourceARB, _gloffset_GetShaderSourceARB)
+ GL_STUB(glBindAttribLocationARB, _gloffset_BindAttribLocationARB)
+ GL_STUB(glGetActiveAttribARB, _gloffset_GetActiveAttribARB)
+ GL_STUB(glGetAttribLocationARB, _gloffset_GetAttribLocationARB)
+ GL_STUB(glGetVertexAttribdvNV, _gloffset_GetVertexAttribdvNV)
+ GL_STUB(glGetVertexAttribfvNV, _gloffset_GetVertexAttribfvNV)
+ GL_STUB(glGetVertexAttribivNV, _gloffset_GetVertexAttribivNV)
+ GL_STUB(glVertexAttrib1dNV, _gloffset_VertexAttrib1dNV)
+ GL_STUB(glVertexAttrib1dvNV, _gloffset_VertexAttrib1dvNV)
+ GL_STUB(glVertexAttrib1fNV, _gloffset_VertexAttrib1fNV)
+ GL_STUB(glVertexAttrib1fvNV, _gloffset_VertexAttrib1fvNV)
+ GL_STUB(glVertexAttrib1sNV, _gloffset_VertexAttrib1sNV)
+ GL_STUB(glVertexAttrib1svNV, _gloffset_VertexAttrib1svNV)
+ GL_STUB(glVertexAttrib2dNV, _gloffset_VertexAttrib2dNV)
+ GL_STUB(glVertexAttrib2dvNV, _gloffset_VertexAttrib2dvNV)
+ GL_STUB(glVertexAttrib2fNV, _gloffset_VertexAttrib2fNV)
+ GL_STUB(glVertexAttrib2fvNV, _gloffset_VertexAttrib2fvNV)
+ GL_STUB(glVertexAttrib2sNV, _gloffset_VertexAttrib2sNV)
+ GL_STUB(glVertexAttrib2svNV, _gloffset_VertexAttrib2svNV)
+ GL_STUB(glVertexAttrib3dNV, _gloffset_VertexAttrib3dNV)
+ GL_STUB(glVertexAttrib3dvNV, _gloffset_VertexAttrib3dvNV)
+ GL_STUB(glVertexAttrib3fNV, _gloffset_VertexAttrib3fNV)
+ GL_STUB(glVertexAttrib3fvNV, _gloffset_VertexAttrib3fvNV)
+ GL_STUB(glVertexAttrib3sNV, _gloffset_VertexAttrib3sNV)
+ GL_STUB(glVertexAttrib3svNV, _gloffset_VertexAttrib3svNV)
+ GL_STUB(glVertexAttrib4dNV, _gloffset_VertexAttrib4dNV)
+ GL_STUB(glVertexAttrib4dvNV, _gloffset_VertexAttrib4dvNV)
+ GL_STUB(glVertexAttrib4fNV, _gloffset_VertexAttrib4fNV)
+ GL_STUB(glVertexAttrib4fvNV, _gloffset_VertexAttrib4fvNV)
+ GL_STUB(glVertexAttrib4sNV, _gloffset_VertexAttrib4sNV)
+ GL_STUB(glVertexAttrib4svNV, _gloffset_VertexAttrib4svNV)
+ GL_STUB(glVertexAttrib4ubNV, _gloffset_VertexAttrib4ubNV)
+ GL_STUB(glVertexAttrib4ubvNV, _gloffset_VertexAttrib4ubvNV)
+ GL_STUB(glGenFragmentShadersATI, _gloffset_GenFragmentShadersATI)
+ GL_STUB(glBindFragmentShaderATI, _gloffset_BindFragmentShaderATI)
+ GL_STUB(glDeleteFragmentShaderATI, _gloffset_DeleteFragmentShaderATI)
+ GL_STUB(glBeginFragmentShaderATI, _gloffset_BeginFragmentShaderATI)
+ GL_STUB(glEndFragmentShaderATI, _gloffset_EndFragmentShaderATI)
+ GL_STUB(glPassTexCoordATI, _gloffset_PassTexCoordATI)
+ GL_STUB(glSampleMapATI, _gloffset_SampleMapATI)
+ GL_STUB(glColorFragmentOp1ATI, _gloffset_ColorFragmentOp1ATI)
+ GL_STUB(glColorFragmentOp2ATI, _gloffset_ColorFragmentOp2ATI)
+ GL_STUB(glColorFragmentOp3ATI, _gloffset_ColorFragmentOp3ATI)
+ GL_STUB(glAlphaFragmentOp1ATI, _gloffset_AlphaFragmentOp1ATI)
+ GL_STUB(glAlphaFragmentOp2ATI, _gloffset_AlphaFragmentOp2ATI)
+ GL_STUB(glAlphaFragmentOp3ATI, _gloffset_AlphaFragmentOp3ATI)
+ GL_STUB(glSetFragmentShaderConstantATI, _gloffset_SetFragmentShaderConstantATI)
+ GL_STUB(glIsRenderbufferEXT, _gloffset_IsRenderbufferEXT)
+ GL_STUB(glBindRenderbufferEXT, _gloffset_BindRenderbufferEXT)
+ GL_STUB(glDeleteRenderbuffersEXT, _gloffset_DeleteRenderbuffersEXT)
+ GL_STUB(glGenRenderbuffersEXT, _gloffset_GenRenderbuffersEXT)
+ GL_STUB(glRenderbufferStorageEXT, _gloffset_RenderbufferStorageEXT)
+ GL_STUB(glGetRenderbufferParameterivEXT, _gloffset_GetRenderbufferParameterivEXT)
+ GL_STUB(glIsFramebufferEXT, _gloffset_IsFramebufferEXT)
+ GL_STUB(glBindFramebufferEXT, _gloffset_BindFramebufferEXT)
+ GL_STUB(glDeleteFramebuffersEXT, _gloffset_DeleteFramebuffersEXT)
+ GL_STUB(glGenFramebuffersEXT, _gloffset_GenFramebuffersEXT)
+ GL_STUB(glCheckFramebufferStatusEXT, _gloffset_CheckFramebufferStatusEXT)
+ GL_STUB(glFramebufferTexture1DEXT, _gloffset_FramebufferTexture1DEXT)
+ GL_STUB(glFramebufferTexture2DEXT, _gloffset_FramebufferTexture2DEXT)
+ GL_STUB(glFramebufferTexture3DEXT, _gloffset_FramebufferTexture3DEXT)
+ GL_STUB(glFramebufferRenderbufferEXT, _gloffset_FramebufferRenderbufferEXT)
+ GL_STUB(glGetFramebufferAttachmentParameterivEXT, _gloffset_GetFramebufferAttachmentParameterivEXT)
+ GL_STUB(glGenerateMipmapEXT, _gloffset_GenerateMipmapEXT)
+ GL_STUB(glStencilFuncSeparate, _gloffset_StencilFuncSeparate)
+ GL_STUB(glStencilOpSeparate, _gloffset_StencilOpSeparate)
+ GL_STUB(glStencilMaskSeparate, _gloffset_StencilMaskSeparate)
+
+ .globl _mesa_sparc_glapi_end ; .type _mesa_sparc_glapi_end,#function
+_mesa_sparc_glapi_end:
+
+ .globl glArrayElementEXT ; .type glArrayElementEXT,#function ; glArrayElementEXT = glArrayElement
+ .globl glBindTextureEXT ; .type glBindTextureEXT,#function ; glBindTextureEXT = glBindTexture
+ .globl glDrawArraysEXT ; .type glDrawArraysEXT,#function ; glDrawArraysEXT = glDrawArrays
+ .globl glCopyTexImage1DEXT ; .type glCopyTexImage1DEXT,#function ; glCopyTexImage1DEXT = glCopyTexImage1D
+ .globl glCopyTexImage2DEXT ; .type glCopyTexImage2DEXT,#function ; glCopyTexImage2DEXT = glCopyTexImage2D
+ .globl glCopyTexSubImage1DEXT ; .type glCopyTexSubImage1DEXT,#function ; glCopyTexSubImage1DEXT = glCopyTexSubImage1D
+ .globl glCopyTexSubImage2DEXT ; .type glCopyTexSubImage2DEXT,#function ; glCopyTexSubImage2DEXT = glCopyTexSubImage2D
+ .globl glDeleteTexturesEXT ; .type glDeleteTexturesEXT,#function ; glDeleteTexturesEXT = glDeleteTextures
+ .globl glGetPointervEXT ; .type glGetPointervEXT,#function ; glGetPointervEXT = glGetPointerv
+ .globl glPrioritizeTexturesEXT ; .type glPrioritizeTexturesEXT,#function ; glPrioritizeTexturesEXT = glPrioritizeTextures
+ .globl glTexSubImage1DEXT ; .type glTexSubImage1DEXT,#function ; glTexSubImage1DEXT = glTexSubImage1D
+ .globl glTexSubImage2DEXT ; .type glTexSubImage2DEXT,#function ; glTexSubImage2DEXT = glTexSubImage2D
+ .globl glBlendColorEXT ; .type glBlendColorEXT,#function ; glBlendColorEXT = glBlendColor
+ .globl glBlendEquationEXT ; .type glBlendEquationEXT,#function ; glBlendEquationEXT = glBlendEquation
+ .globl glDrawRangeElementsEXT ; .type glDrawRangeElementsEXT,#function ; glDrawRangeElementsEXT = glDrawRangeElements
+ .globl glColorTableSGI ; .type glColorTableSGI,#function ; glColorTableSGI = glColorTable
+ .globl glColorTableEXT ; .type glColorTableEXT,#function ; glColorTableEXT = glColorTable
+ .globl glColorTableParameterfvSGI ; .type glColorTableParameterfvSGI,#function ; glColorTableParameterfvSGI = glColorTableParameterfv
+ .globl glColorTableParameterivSGI ; .type glColorTableParameterivSGI,#function ; glColorTableParameterivSGI = glColorTableParameteriv
+ .globl glCopyColorTableSGI ; .type glCopyColorTableSGI,#function ; glCopyColorTableSGI = glCopyColorTable
+ .globl glColorSubTableEXT ; .type glColorSubTableEXT,#function ; glColorSubTableEXT = glColorSubTable
+ .globl glCopyColorSubTableEXT ; .type glCopyColorSubTableEXT,#function ; glCopyColorSubTableEXT = glCopyColorSubTable
+ .globl glConvolutionFilter1DEXT ; .type glConvolutionFilter1DEXT,#function ; glConvolutionFilter1DEXT = glConvolutionFilter1D
+ .globl glConvolutionFilter2DEXT ; .type glConvolutionFilter2DEXT,#function ; glConvolutionFilter2DEXT = glConvolutionFilter2D
+ .globl glConvolutionParameterfEXT ; .type glConvolutionParameterfEXT,#function ; glConvolutionParameterfEXT = glConvolutionParameterf
+ .globl glConvolutionParameterfvEXT ; .type glConvolutionParameterfvEXT,#function ; glConvolutionParameterfvEXT = glConvolutionParameterfv
+ .globl glConvolutionParameteriEXT ; .type glConvolutionParameteriEXT,#function ; glConvolutionParameteriEXT = glConvolutionParameteri
+ .globl glConvolutionParameterivEXT ; .type glConvolutionParameterivEXT,#function ; glConvolutionParameterivEXT = glConvolutionParameteriv
+ .globl glCopyConvolutionFilter1DEXT ; .type glCopyConvolutionFilter1DEXT,#function ; glCopyConvolutionFilter1DEXT = glCopyConvolutionFilter1D
+ .globl glCopyConvolutionFilter2DEXT ; .type glCopyConvolutionFilter2DEXT,#function ; glCopyConvolutionFilter2DEXT = glCopyConvolutionFilter2D
+ .globl glSeparableFilter2DEXT ; .type glSeparableFilter2DEXT,#function ; glSeparableFilter2DEXT = glSeparableFilter2D
+ .globl glHistogramEXT ; .type glHistogramEXT,#function ; glHistogramEXT = glHistogram
+ .globl glMinmaxEXT ; .type glMinmaxEXT,#function ; glMinmaxEXT = glMinmax
+ .globl glResetHistogramEXT ; .type glResetHistogramEXT,#function ; glResetHistogramEXT = glResetHistogram
+ .globl glResetMinmaxEXT ; .type glResetMinmaxEXT,#function ; glResetMinmaxEXT = glResetMinmax
+ .globl glTexImage3DEXT ; .type glTexImage3DEXT,#function ; glTexImage3DEXT = glTexImage3D
+ .globl glTexSubImage3DEXT ; .type glTexSubImage3DEXT,#function ; glTexSubImage3DEXT = glTexSubImage3D
+ .globl glCopyTexSubImage3DEXT ; .type glCopyTexSubImage3DEXT,#function ; glCopyTexSubImage3DEXT = glCopyTexSubImage3D
+ .globl glActiveTexture ; .type glActiveTexture,#function ; glActiveTexture = glActiveTextureARB
+ .globl glClientActiveTexture ; .type glClientActiveTexture,#function ; glClientActiveTexture = glClientActiveTextureARB
+ .globl glMultiTexCoord1d ; .type glMultiTexCoord1d,#function ; glMultiTexCoord1d = glMultiTexCoord1dARB
+ .globl glMultiTexCoord1dv ; .type glMultiTexCoord1dv,#function ; glMultiTexCoord1dv = glMultiTexCoord1dvARB
+ .globl glMultiTexCoord1f ; .type glMultiTexCoord1f,#function ; glMultiTexCoord1f = glMultiTexCoord1fARB
+ .globl glMultiTexCoord1fv ; .type glMultiTexCoord1fv,#function ; glMultiTexCoord1fv = glMultiTexCoord1fvARB
+ .globl glMultiTexCoord1i ; .type glMultiTexCoord1i,#function ; glMultiTexCoord1i = glMultiTexCoord1iARB
+ .globl glMultiTexCoord1iv ; .type glMultiTexCoord1iv,#function ; glMultiTexCoord1iv = glMultiTexCoord1ivARB
+ .globl glMultiTexCoord1s ; .type glMultiTexCoord1s,#function ; glMultiTexCoord1s = glMultiTexCoord1sARB
+ .globl glMultiTexCoord1sv ; .type glMultiTexCoord1sv,#function ; glMultiTexCoord1sv = glMultiTexCoord1svARB
+ .globl glMultiTexCoord2d ; .type glMultiTexCoord2d,#function ; glMultiTexCoord2d = glMultiTexCoord2dARB
+ .globl glMultiTexCoord2dv ; .type glMultiTexCoord2dv,#function ; glMultiTexCoord2dv = glMultiTexCoord2dvARB
+ .globl glMultiTexCoord2f ; .type glMultiTexCoord2f,#function ; glMultiTexCoord2f = glMultiTexCoord2fARB
+ .globl glMultiTexCoord2fv ; .type glMultiTexCoord2fv,#function ; glMultiTexCoord2fv = glMultiTexCoord2fvARB
+ .globl glMultiTexCoord2i ; .type glMultiTexCoord2i,#function ; glMultiTexCoord2i = glMultiTexCoord2iARB
+ .globl glMultiTexCoord2iv ; .type glMultiTexCoord2iv,#function ; glMultiTexCoord2iv = glMultiTexCoord2ivARB
+ .globl glMultiTexCoord2s ; .type glMultiTexCoord2s,#function ; glMultiTexCoord2s = glMultiTexCoord2sARB
+ .globl glMultiTexCoord2sv ; .type glMultiTexCoord2sv,#function ; glMultiTexCoord2sv = glMultiTexCoord2svARB
+ .globl glMultiTexCoord3d ; .type glMultiTexCoord3d,#function ; glMultiTexCoord3d = glMultiTexCoord3dARB
+ .globl glMultiTexCoord3dv ; .type glMultiTexCoord3dv,#function ; glMultiTexCoord3dv = glMultiTexCoord3dvARB
+ .globl glMultiTexCoord3f ; .type glMultiTexCoord3f,#function ; glMultiTexCoord3f = glMultiTexCoord3fARB
+ .globl glMultiTexCoord3fv ; .type glMultiTexCoord3fv,#function ; glMultiTexCoord3fv = glMultiTexCoord3fvARB
+ .globl glMultiTexCoord3i ; .type glMultiTexCoord3i,#function ; glMultiTexCoord3i = glMultiTexCoord3iARB
+ .globl glMultiTexCoord3iv ; .type glMultiTexCoord3iv,#function ; glMultiTexCoord3iv = glMultiTexCoord3ivARB
+ .globl glMultiTexCoord3s ; .type glMultiTexCoord3s,#function ; glMultiTexCoord3s = glMultiTexCoord3sARB
+ .globl glMultiTexCoord3sv ; .type glMultiTexCoord3sv,#function ; glMultiTexCoord3sv = glMultiTexCoord3svARB
+ .globl glMultiTexCoord4d ; .type glMultiTexCoord4d,#function ; glMultiTexCoord4d = glMultiTexCoord4dARB
+ .globl glMultiTexCoord4dv ; .type glMultiTexCoord4dv,#function ; glMultiTexCoord4dv = glMultiTexCoord4dvARB
+ .globl glMultiTexCoord4f ; .type glMultiTexCoord4f,#function ; glMultiTexCoord4f = glMultiTexCoord4fARB
+ .globl glMultiTexCoord4fv ; .type glMultiTexCoord4fv,#function ; glMultiTexCoord4fv = glMultiTexCoord4fvARB
+ .globl glMultiTexCoord4i ; .type glMultiTexCoord4i,#function ; glMultiTexCoord4i = glMultiTexCoord4iARB
+ .globl glMultiTexCoord4iv ; .type glMultiTexCoord4iv,#function ; glMultiTexCoord4iv = glMultiTexCoord4ivARB
+ .globl glMultiTexCoord4s ; .type glMultiTexCoord4s,#function ; glMultiTexCoord4s = glMultiTexCoord4sARB
+ .globl glMultiTexCoord4sv ; .type glMultiTexCoord4sv,#function ; glMultiTexCoord4sv = glMultiTexCoord4svARB
+ .globl glLoadTransposeMatrixf ; .type glLoadTransposeMatrixf,#function ; glLoadTransposeMatrixf = glLoadTransposeMatrixfARB
+ .globl glLoadTransposeMatrixd ; .type glLoadTransposeMatrixd,#function ; glLoadTransposeMatrixd = glLoadTransposeMatrixdARB
+ .globl glMultTransposeMatrixf ; .type glMultTransposeMatrixf,#function ; glMultTransposeMatrixf = glMultTransposeMatrixfARB
+ .globl glMultTransposeMatrixd ; .type glMultTransposeMatrixd,#function ; glMultTransposeMatrixd = glMultTransposeMatrixdARB
+ .globl glSampleCoverage ; .type glSampleCoverage,#function ; glSampleCoverage = glSampleCoverageARB
+ .globl glDrawBuffersATI ; .type glDrawBuffersATI,#function ; glDrawBuffersATI = glDrawBuffersARB
+ .globl glSampleMaskEXT ; .type glSampleMaskEXT,#function ; glSampleMaskEXT = glSampleMaskSGIS
+ .globl glSamplePatternEXT ; .type glSamplePatternEXT,#function ; glSamplePatternEXT = glSamplePatternSGIS
+ .globl glPointParameterf ; .type glPointParameterf,#function ; glPointParameterf = glPointParameterfEXT
+ .globl glPointParameterfARB ; .type glPointParameterfARB,#function ; glPointParameterfARB = glPointParameterfEXT
+ .globl glPointParameterfSGIS ; .type glPointParameterfSGIS,#function ; glPointParameterfSGIS = glPointParameterfEXT
+ .globl glPointParameterfv ; .type glPointParameterfv,#function ; glPointParameterfv = glPointParameterfvEXT
+ .globl glPointParameterfvARB ; .type glPointParameterfvARB,#function ; glPointParameterfvARB = glPointParameterfvEXT
+ .globl glPointParameterfvSGIS ; .type glPointParameterfvSGIS,#function ; glPointParameterfvSGIS = glPointParameterfvEXT
+ .globl glWindowPos2d ; .type glWindowPos2d,#function ; glWindowPos2d = glWindowPos2dMESA
+ .globl glWindowPos2dARB ; .type glWindowPos2dARB,#function ; glWindowPos2dARB = glWindowPos2dMESA
+ .globl glWindowPos2dv ; .type glWindowPos2dv,#function ; glWindowPos2dv = glWindowPos2dvMESA
+ .globl glWindowPos2dvARB ; .type glWindowPos2dvARB,#function ; glWindowPos2dvARB = glWindowPos2dvMESA
+ .globl glWindowPos2f ; .type glWindowPos2f,#function ; glWindowPos2f = glWindowPos2fMESA
+ .globl glWindowPos2fARB ; .type glWindowPos2fARB,#function ; glWindowPos2fARB = glWindowPos2fMESA
+ .globl glWindowPos2fv ; .type glWindowPos2fv,#function ; glWindowPos2fv = glWindowPos2fvMESA
+ .globl glWindowPos2fvARB ; .type glWindowPos2fvARB,#function ; glWindowPos2fvARB = glWindowPos2fvMESA
+ .globl glWindowPos2i ; .type glWindowPos2i,#function ; glWindowPos2i = glWindowPos2iMESA
+ .globl glWindowPos2iARB ; .type glWindowPos2iARB,#function ; glWindowPos2iARB = glWindowPos2iMESA
+ .globl glWindowPos2iv ; .type glWindowPos2iv,#function ; glWindowPos2iv = glWindowPos2ivMESA
+ .globl glWindowPos2ivARB ; .type glWindowPos2ivARB,#function ; glWindowPos2ivARB = glWindowPos2ivMESA
+ .globl glWindowPos2s ; .type glWindowPos2s,#function ; glWindowPos2s = glWindowPos2sMESA
+ .globl glWindowPos2sARB ; .type glWindowPos2sARB,#function ; glWindowPos2sARB = glWindowPos2sMESA
+ .globl glWindowPos2sv ; .type glWindowPos2sv,#function ; glWindowPos2sv = glWindowPos2svMESA
+ .globl glWindowPos2svARB ; .type glWindowPos2svARB,#function ; glWindowPos2svARB = glWindowPos2svMESA
+ .globl glWindowPos3d ; .type glWindowPos3d,#function ; glWindowPos3d = glWindowPos3dMESA
+ .globl glWindowPos3dARB ; .type glWindowPos3dARB,#function ; glWindowPos3dARB = glWindowPos3dMESA
+ .globl glWindowPos3dv ; .type glWindowPos3dv,#function ; glWindowPos3dv = glWindowPos3dvMESA
+ .globl glWindowPos3dvARB ; .type glWindowPos3dvARB,#function ; glWindowPos3dvARB = glWindowPos3dvMESA
+ .globl glWindowPos3f ; .type glWindowPos3f,#function ; glWindowPos3f = glWindowPos3fMESA
+ .globl glWindowPos3fARB ; .type glWindowPos3fARB,#function ; glWindowPos3fARB = glWindowPos3fMESA
+ .globl glWindowPos3fv ; .type glWindowPos3fv,#function ; glWindowPos3fv = glWindowPos3fvMESA
+ .globl glWindowPos3fvARB ; .type glWindowPos3fvARB,#function ; glWindowPos3fvARB = glWindowPos3fvMESA
+ .globl glWindowPos3i ; .type glWindowPos3i,#function ; glWindowPos3i = glWindowPos3iMESA
+ .globl glWindowPos3iARB ; .type glWindowPos3iARB,#function ; glWindowPos3iARB = glWindowPos3iMESA
+ .globl glWindowPos3iv ; .type glWindowPos3iv,#function ; glWindowPos3iv = glWindowPos3ivMESA
+ .globl glWindowPos3ivARB ; .type glWindowPos3ivARB,#function ; glWindowPos3ivARB = glWindowPos3ivMESA
+ .globl glWindowPos3s ; .type glWindowPos3s,#function ; glWindowPos3s = glWindowPos3sMESA
+ .globl glWindowPos3sARB ; .type glWindowPos3sARB,#function ; glWindowPos3sARB = glWindowPos3sMESA
+ .globl glWindowPos3sv ; .type glWindowPos3sv,#function ; glWindowPos3sv = glWindowPos3svMESA
+ .globl glWindowPos3svARB ; .type glWindowPos3svARB,#function ; glWindowPos3svARB = glWindowPos3svMESA
+ .globl glBlendFuncSeparate ; .type glBlendFuncSeparate,#function ; glBlendFuncSeparate = glBlendFuncSeparateEXT
+ .globl glBlendFuncSeparateINGR ; .type glBlendFuncSeparateINGR,#function ; glBlendFuncSeparateINGR = glBlendFuncSeparateEXT
+ .globl glFogCoordf ; .type glFogCoordf,#function ; glFogCoordf = glFogCoordfEXT
+ .globl glFogCoordfv ; .type glFogCoordfv,#function ; glFogCoordfv = glFogCoordfvEXT
+ .globl glFogCoordd ; .type glFogCoordd,#function ; glFogCoordd = glFogCoorddEXT
+ .globl glFogCoorddv ; .type glFogCoorddv,#function ; glFogCoorddv = glFogCoorddvEXT
+ .globl glFogCoordPointer ; .type glFogCoordPointer,#function ; glFogCoordPointer = glFogCoordPointerEXT
+ .globl glCompressedTexImage3D ; .type glCompressedTexImage3D,#function ; glCompressedTexImage3D = glCompressedTexImage3DARB
+ .globl glCompressedTexImage2D ; .type glCompressedTexImage2D,#function ; glCompressedTexImage2D = glCompressedTexImage2DARB
+ .globl glCompressedTexImage1D ; .type glCompressedTexImage1D,#function ; glCompressedTexImage1D = glCompressedTexImage1DARB
+ .globl glCompressedTexSubImage3D ; .type glCompressedTexSubImage3D,#function ; glCompressedTexSubImage3D = glCompressedTexSubImage3DARB
+ .globl glCompressedTexSubImage2D ; .type glCompressedTexSubImage2D,#function ; glCompressedTexSubImage2D = glCompressedTexSubImage2DARB
+ .globl glCompressedTexSubImage1D ; .type glCompressedTexSubImage1D,#function ; glCompressedTexSubImage1D = glCompressedTexSubImage1DARB
+ .globl glGetCompressedTexImage ; .type glGetCompressedTexImage,#function ; glGetCompressedTexImage = glGetCompressedTexImageARB
+ .globl glSecondaryColor3b ; .type glSecondaryColor3b,#function ; glSecondaryColor3b = glSecondaryColor3bEXT
+ .globl glSecondaryColor3bv ; .type glSecondaryColor3bv,#function ; glSecondaryColor3bv = glSecondaryColor3bvEXT
+ .globl glSecondaryColor3d ; .type glSecondaryColor3d,#function ; glSecondaryColor3d = glSecondaryColor3dEXT
+ .globl glSecondaryColor3dv ; .type glSecondaryColor3dv,#function ; glSecondaryColor3dv = glSecondaryColor3dvEXT
+ .globl glSecondaryColor3f ; .type glSecondaryColor3f,#function ; glSecondaryColor3f = glSecondaryColor3fEXT
+ .globl glSecondaryColor3fv ; .type glSecondaryColor3fv,#function ; glSecondaryColor3fv = glSecondaryColor3fvEXT
+ .globl glSecondaryColor3i ; .type glSecondaryColor3i,#function ; glSecondaryColor3i = glSecondaryColor3iEXT
+ .globl glSecondaryColor3iv ; .type glSecondaryColor3iv,#function ; glSecondaryColor3iv = glSecondaryColor3ivEXT
+ .globl glSecondaryColor3s ; .type glSecondaryColor3s,#function ; glSecondaryColor3s = glSecondaryColor3sEXT
+ .globl glSecondaryColor3sv ; .type glSecondaryColor3sv,#function ; glSecondaryColor3sv = glSecondaryColor3svEXT
+ .globl glSecondaryColor3ub ; .type glSecondaryColor3ub,#function ; glSecondaryColor3ub = glSecondaryColor3ubEXT
+ .globl glSecondaryColor3ubv ; .type glSecondaryColor3ubv,#function ; glSecondaryColor3ubv = glSecondaryColor3ubvEXT
+ .globl glSecondaryColor3ui ; .type glSecondaryColor3ui,#function ; glSecondaryColor3ui = glSecondaryColor3uiEXT
+ .globl glSecondaryColor3uiv ; .type glSecondaryColor3uiv,#function ; glSecondaryColor3uiv = glSecondaryColor3uivEXT
+ .globl glSecondaryColor3us ; .type glSecondaryColor3us,#function ; glSecondaryColor3us = glSecondaryColor3usEXT
+ .globl glSecondaryColor3usv ; .type glSecondaryColor3usv,#function ; glSecondaryColor3usv = glSecondaryColor3usvEXT
+ .globl glSecondaryColorPointer ; .type glSecondaryColorPointer,#function ; glSecondaryColorPointer = glSecondaryColorPointerEXT
+ .globl glBindProgramARB ; .type glBindProgramARB,#function ; glBindProgramARB = glBindProgramNV
+ .globl glDeleteProgramsARB ; .type glDeleteProgramsARB,#function ; glDeleteProgramsARB = glDeleteProgramsNV
+ .globl glGenProgramsARB ; .type glGenProgramsARB,#function ; glGenProgramsARB = glGenProgramsNV
+ .globl glGetVertexAttribPointervARB ; .type glGetVertexAttribPointervARB,#function ; glGetVertexAttribPointervARB = glGetVertexAttribPointervNV
+ .globl glIsProgramARB ; .type glIsProgramARB,#function ; glIsProgramARB = glIsProgramNV
+ .globl glPointParameteri ; .type glPointParameteri,#function ; glPointParameteri = glPointParameteriNV
+ .globl glPointParameteriv ; .type glPointParameteriv,#function ; glPointParameteriv = glPointParameterivNV
+ .globl glMultiDrawArrays ; .type glMultiDrawArrays,#function ; glMultiDrawArrays = glMultiDrawArraysEXT
+ .globl glMultiDrawElements ; .type glMultiDrawElements,#function ; glMultiDrawElements = glMultiDrawElementsEXT
+ .globl glBindBuffer ; .type glBindBuffer,#function ; glBindBuffer = glBindBufferARB
+ .globl glBufferData ; .type glBufferData,#function ; glBufferData = glBufferDataARB
+ .globl glBufferSubData ; .type glBufferSubData,#function ; glBufferSubData = glBufferSubDataARB
+ .globl glDeleteBuffers ; .type glDeleteBuffers,#function ; glDeleteBuffers = glDeleteBuffersARB
+ .globl glGenBuffers ; .type glGenBuffers,#function ; glGenBuffers = glGenBuffersARB
+ .globl glGetBufferParameteriv ; .type glGetBufferParameteriv,#function ; glGetBufferParameteriv = glGetBufferParameterivARB
+ .globl glGetBufferPointerv ; .type glGetBufferPointerv,#function ; glGetBufferPointerv = glGetBufferPointervARB
+ .globl glGetBufferSubData ; .type glGetBufferSubData,#function ; glGetBufferSubData = glGetBufferSubDataARB
+ .globl glIsBuffer ; .type glIsBuffer,#function ; glIsBuffer = glIsBufferARB
+ .globl glMapBuffer ; .type glMapBuffer,#function ; glMapBuffer = glMapBufferARB
+ .globl glUnmapBuffer ; .type glUnmapBuffer,#function ; glUnmapBuffer = glUnmapBufferARB
+ .globl glGenQueries ; .type glGenQueries,#function ; glGenQueries = glGenQueriesARB
+ .globl glDeleteQueries ; .type glDeleteQueries,#function ; glDeleteQueries = glDeleteQueriesARB
+ .globl glIsQuery ; .type glIsQuery,#function ; glIsQuery = glIsQueryARB
+ .globl glBeginQuery ; .type glBeginQuery,#function ; glBeginQuery = glBeginQueryARB
+ .globl glEndQuery ; .type glEndQuery,#function ; glEndQuery = glEndQueryARB
+ .globl glGetQueryiv ; .type glGetQueryiv,#function ; glGetQueryiv = glGetQueryivARB
+ .globl glGetQueryObjectiv ; .type glGetQueryObjectiv,#function ; glGetQueryObjectiv = glGetQueryObjectivARB
+ .globl glGetQueryObjectuiv ; .type glGetQueryObjectuiv,#function ; glGetQueryObjectuiv = glGetQueryObjectuivARB
+ .globl glBlendEquationSeparateATI ; .type glBlendEquationSeparateATI,#function ; glBlendEquationSeparateATI = glBlendEquationSeparateEXT
diff --git a/nx-X11/extras/Mesa/src/mesa/sparc/norm.S b/nx-X11/extras/Mesa/src/mesa/sparc/norm.S
new file mode 100644
index 000000000..ec25edd3e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/sparc/norm.S
@@ -0,0 +1,609 @@
+/* $Id: norm.S,v 1.1.1.3 2005/07/31 16:46:49 ajax Exp $ */
+
+#include "sparc_matrix.h"
+
+#if defined(SVR4) || defined(__SVR4) || defined(__svr4__)
+ /* Solaris requires this for 64-bit. */
+ .register %g2, #scratch
+ .register %g3, #scratch
+#endif
+
+ .text
+
+#ifdef __arch64__
+#define STACK_VAR_OFF (2047 + (8 * 16))
+#else
+#define STACK_VAR_OFF (4 * 16)
+#endif
+
+ /* Newton-Raphson approximation turns out to be slower
+ * (and less accurate) than direct fsqrts/fdivs.
+ */
+#define ONE_DOT_ZERO 0x3f800000
+
+ .globl _mesa_sparc_transform_normalize_normals
+_mesa_sparc_transform_normalize_normals:
+ /* o0=mat o1=scale o2=in o3=lengths o4=dest */
+
+ sethi %hi(ONE_DOT_ZERO), %g2
+ sub %sp, 16, %sp
+ st %g2, [%sp + STACK_VAR_OFF+0x0]
+ st %o1, [%sp + STACK_VAR_OFF+0x4]
+ ld [%sp + STACK_VAR_OFF+0x0], %f12 ! f12 = 1.0f
+ ld [%sp + STACK_VAR_OFF+0x4], %f15 ! f15 = scale
+ add %sp, 16, %sp
+
+ LDPTR [%o0 + MAT_INV], %o0 ! o0 = mat->inv
+ LDPTR [%o2 + V4F_START], %o5 ! o5 = 'from' in->start
+ ld [%o2 + V4F_COUNT], %g1 ! g1 = in->count
+ ld [%o2 + V4F_STRIDE], %g2 ! g2 = in->stride
+ LDPTR [%o4 + V4F_START], %g3 ! g3 = 'out' dest->start
+
+ LDMATRIX_0_1_2_4_5_6_8_9_10(%o0)
+
+ /* dest->count = in->count */
+ st %g1, [%o4 + V4F_COUNT]
+
+ cmp %g1, 1
+ bl 7f
+ cmp %o3, 0
+ bne 4f
+ clr %o4 ! 'i' for STRIDE_LOOP
+
+1: /* LENGTHS == NULL */
+ ld [%o5 + 0x00], %f0 ! ux = from[0]
+ ld [%o5 + 0x04], %f1 ! uy = from[1]
+ ld [%o5 + 0x08], %f2 ! uz = from[2]
+ add %o5, %g2, %o5 ! STRIDE_F(from, stride)
+ add %o4, 1, %o4 ! i++
+
+ /* tx (f3) = (ux * m0) + (uy * m1) + (uz * m2)
+ * ty (f5) = (ux * m4) + (uy * m5) + (uz * m6)
+ * tz (f7) = (ux * m8) + (uy * m9) + (uz * m10)
+ */
+ fmuls %f0, M0, %f3 ! FGM Group
+ fmuls %f1, M1, %f4 ! FGM Group
+ fmuls %f0, M4, %f5 ! FGM Group
+ fmuls %f1, M5, %f6 ! FGM Group
+ fmuls %f0, M8, %f7 ! FGM Group f3 available
+ fmuls %f1, M9, %f8 ! FGM Group f4 available
+ fadds %f3, %f4, %f3 ! FGA
+ fmuls %f2, M2, %f10 ! FGM Group f5 available
+ fmuls %f2, M6, %f0 ! FGM Group f6 available
+ fadds %f5, %f6, %f5 ! FGA
+ fmuls %f2, M10, %f4 ! FGM Group f7 available
+ fadds %f7, %f8, %f7 ! FGA Group f8,f3 available
+ fadds %f3, %f10, %f3 ! FGA Group f10 available
+ fadds %f5, %f0, %f5 ! FGA Group stall f0,f5 available
+ fadds %f7, %f4, %f7 ! FGA Group stall f4,f7 available
+
+ /* f3=tx, f5=ty, f7=tz */
+
+ /* len (f6) = (tx * tx) + (ty * ty) + (tz * tz) */
+ fmuls %f3, %f3, %f6 ! FGM Group f3 available
+ fmuls %f5, %f5, %f8 ! FGM Group f5 available
+ fmuls %f7, %f7, %f10 ! FGM Group f7 available
+ fadds %f6, %f8, %f6 ! FGA Group 2cyc stall f6,f8 available
+ fadds %f6, %f10, %f6 ! FGA Group 4cyc stall f6,f10 available
+
+ /* scale (f6) = 1.0 / sqrt(len) */
+ fsqrts %f6, %f6 ! FDIV 20 cycles
+ fdivs %f12, %f6, %f6 ! FDIV 14 cycles
+
+ fmuls %f3, %f6, %f3
+ st %f3, [%g3 + 0x00] ! out[i][0] = tx * scale
+ fmuls %f5, %f6, %f5
+ st %f5, [%g3 + 0x04] ! out[i][1] = ty * scale
+ fmuls %f7, %f6, %f7
+ st %f7, [%g3 + 0x08] ! out[i][2] = tz * scale
+
+ cmp %o4, %g1 ! continue if (i < count)
+ bl 1b
+ add %g3, 0x0c, %g3 ! advance out vector pointer
+
+ ba 7f
+ nop
+
+4: /* LENGTHS != NULL */
+ fmuls M0, %f15, M0
+ fmuls M1, %f15, M1
+ fmuls M2, %f15, M2
+ fmuls M4, %f15, M4
+ fmuls M5, %f15, M5
+ fmuls M6, %f15, M6
+ fmuls M8, %f15, M8
+ fmuls M9, %f15, M9
+ fmuls M10, %f15, M10
+
+5:
+ ld [%o5 + 0x00], %f0 ! ux = from[0]
+ ld [%o5 + 0x04], %f1 ! uy = from[1]
+ ld [%o5 + 0x08], %f2 ! uz = from[2]
+ add %o5, %g2, %o5 ! STRIDE_F(from, stride)
+ add %o4, 1, %o4 ! i++
+
+ /* tx (f3) = (ux * m0) + (uy * m1) + (uz * m2)
+ * ty (f5) = (ux * m4) + (uy * m5) + (uz * m6)
+ * tz (f7) = (ux * m8) + (uy * m9) + (uz * m10)
+ */
+ fmuls %f0, M0, %f3 ! FGM Group
+ fmuls %f1, M1, %f4 ! FGM Group
+ fmuls %f0, M4, %f5 ! FGM Group
+ fmuls %f1, M5, %f6 ! FGM Group
+ fmuls %f0, M8, %f7 ! FGM Group f3 available
+ fmuls %f1, M9, %f8 ! FGM Group f4 available
+ fadds %f3, %f4, %f3 ! FGA
+ fmuls %f2, M2, %f10 ! FGM Group f5 available
+ fmuls %f2, M6, %f0 ! FGM Group f6 available
+ fadds %f5, %f6, %f5 ! FGA
+ fmuls %f2, M10, %f4 ! FGM Group f7 available
+ fadds %f7, %f8, %f7 ! FGA Group f8,f3 available
+ fadds %f3, %f10, %f3 ! FGA Group f10 available
+ ld [%o3], %f13 ! LSU
+ fadds %f5, %f0, %f5 ! FGA Group stall f0,f5 available
+ add %o3, 4, %o3 ! IEU0
+ fadds %f7, %f4, %f7 ! FGA Group stall f4,f7 available
+
+ /* f3=tx, f5=ty, f7=tz, f13=lengths[i] */
+
+ fmuls %f3, %f13, %f3
+ st %f3, [%g3 + 0x00] ! out[i][0] = tx * len
+ fmuls %f5, %f13, %f5
+ st %f5, [%g3 + 0x04] ! out[i][1] = ty * len
+ fmuls %f7, %f13, %f7
+ st %f7, [%g3 + 0x08] ! out[i][2] = tz * len
+
+ cmp %o4, %g1 ! continue if (i < count)
+ bl 5b
+ add %g3, 0x0c, %g3 ! advance out vector pointer
+
+7: retl
+ nop
+
+ .globl _mesa_sparc_transform_normalize_normals_no_rot
+_mesa_sparc_transform_normalize_normals_no_rot:
+ /* o0=mat o1=scale o2=in o3=lengths o4=dest */
+
+ sethi %hi(ONE_DOT_ZERO), %g2
+ sub %sp, 16, %sp
+ st %g2, [%sp + STACK_VAR_OFF+0x0]
+ st %o1, [%sp + STACK_VAR_OFF+0x4]
+ ld [%sp + STACK_VAR_OFF+0x0], %f12 ! f12 = 1.0f
+ ld [%sp + STACK_VAR_OFF+0x4], %f15 ! f15 = scale
+ add %sp, 16, %sp
+
+ LDPTR [%o0 + MAT_INV], %o0 ! o0 = mat->inv
+ LDPTR [%o2 + V4F_START], %o5 ! o5 = 'from' in->start
+ ld [%o2 + V4F_COUNT], %g1 ! g1 = in->count
+ ld [%o2 + V4F_STRIDE], %g2 ! g2 = in->stride
+ LDPTR [%o4 + V4F_START], %g3 ! g3 = 'out' dest->start
+
+ LDMATRIX_0_5_10(%o0)
+
+ /* dest->count = in->count */
+ st %g1, [%o4 + V4F_COUNT]
+
+ cmp %g1, 1
+ bl 7f
+ cmp %o3, 0
+ bne 4f
+ clr %o4 ! 'i' for STRIDE_LOOP
+
+1: /* LENGTHS == NULL */
+ ld [%o5 + 0x00], %f0 ! ux = from[0]
+ ld [%o5 + 0x04], %f1 ! uy = from[1]
+ ld [%o5 + 0x08], %f2 ! uz = from[2]
+ add %o5, %g2, %o5 ! STRIDE_F(from, stride)
+ add %o4, 1, %o4 ! i++
+
+ /* tx (f3) = (ux * m0)
+ * ty (f5) = (uy * m5)
+ * tz (f7) = (uz * m10)
+ */
+ fmuls %f0, M0, %f3 ! FGM Group
+ fmuls %f1, M5, %f5 ! FGM Group
+ fmuls %f2, M10, %f7 ! FGM Group
+
+ /* f3=tx, f5=ty, f7=tz */
+
+ /* len (f6) = (tx * tx) + (ty * ty) + (tz * tz) */
+ fmuls %f3, %f3, %f6 ! FGM Group stall, f3 available
+ fmuls %f5, %f5, %f8 ! FGM Group f5 available
+ fmuls %f7, %f7, %f10 ! FGM Group f7 available
+ fadds %f6, %f8, %f6 ! FGA Group 2cyc stall f6,f8 available
+ fadds %f6, %f10, %f6 ! FGA Group 4cyc stall f6,f10 available
+
+ /* scale (f6) = 1.0 / sqrt(len) */
+ fsqrts %f6, %f6 ! FDIV 20 cycles
+ fdivs %f12, %f6, %f6 ! FDIV 14 cycles
+
+ fmuls %f3, %f6, %f3
+ st %f3, [%g3 + 0x00] ! out[i][0] = tx * scale
+ fmuls %f5, %f6, %f5
+ st %f5, [%g3 + 0x04] ! out[i][1] = ty * scale
+ fmuls %f7, %f6, %f7
+ st %f7, [%g3 + 0x08] ! out[i][2] = tz * scale
+
+ cmp %o4, %g1 ! continue if (i < count)
+ bl 1b
+ add %g3, 0x0c, %g3 ! advance out vector pointer
+
+ ba 7f
+ nop
+
+4: /* LENGTHS != NULL */
+ fmuls M0, %f15, M0
+ fmuls M5, %f15, M5
+ fmuls M10, %f15, M10
+
+5:
+ ld [%o5 + 0x00], %f0 ! ux = from[0]
+ ld [%o5 + 0x04], %f1 ! uy = from[1]
+ ld [%o5 + 0x08], %f2 ! uz = from[2]
+ add %o5, %g2, %o5 ! STRIDE_F(from, stride)
+ add %o4, 1, %o4 ! i++
+
+ /* tx (f3) = (ux * m0)
+ * ty (f5) = (uy * m5)
+ * tz (f7) = (uz * m10)
+ */
+ fmuls %f0, M0, %f3 ! FGM Group
+ ld [%o3], %f13 ! LSU
+ fmuls %f1, M5, %f5 ! FGM Group
+ add %o3, 4, %o3 ! IEU0
+ fmuls %f2, M10, %f7 ! FGM Group
+
+ /* f3=tx, f5=ty, f7=tz, f13=lengths[i] */
+
+ fmuls %f3, %f13, %f3
+ st %f3, [%g3 + 0x00] ! out[i][0] = tx * len
+ fmuls %f5, %f13, %f5
+ st %f5, [%g3 + 0x04] ! out[i][1] = ty * len
+ fmuls %f7, %f13, %f7
+ st %f7, [%g3 + 0x08] ! out[i][2] = tz * len
+
+ cmp %o4, %g1 ! continue if (i < count)
+ bl 5b
+ add %g3, 0x0c, %g3 ! advance out vector pointer
+
+7: retl
+ nop
+
+ .globl _mesa_sparc_transform_rescale_normals_no_rot
+_mesa_sparc_transform_rescale_normals_no_rot:
+ /* o0=mat o1=scale o2=in o3=lengths o4=dest */
+ sub %sp, 16, %sp
+ st %o1, [%sp + STACK_VAR_OFF+0x0]
+ ld [%sp + STACK_VAR_OFF+0x0], %f15 ! f15 = scale
+ add %sp, 16, %sp
+
+ LDPTR [%o0 + MAT_INV], %o0 ! o0 = mat->inv
+ LDPTR [%o2 + V4F_START], %o5 ! o5 = 'from' in->start
+ ld [%o2 + V4F_COUNT], %g1 ! g1 = in->count
+ ld [%o2 + V4F_STRIDE], %g2 ! g2 = in->stride
+ LDPTR [%o4 + V4F_START], %g3 ! g3 = 'out' dest->start
+
+ LDMATRIX_0_5_10(%o0)
+
+ /* dest->count = in->count */
+ st %g1, [%o4 + V4F_COUNT]
+
+ cmp %g1, 1
+ bl 7f
+ clr %o4 ! 'i' for STRIDE_LOOP
+
+ fmuls M0, %f15, M0
+ fmuls M5, %f15, M5
+ fmuls M10, %f15, M10
+
+1: ld [%o5 + 0x00], %f0 ! ux = from[0]
+ ld [%o5 + 0x04], %f1 ! uy = from[1]
+ ld [%o5 + 0x08], %f2 ! uz = from[2]
+ add %o5, %g2, %o5 ! STRIDE_F(from, stride)
+ add %o4, 1, %o4 ! i++
+
+ /* tx (f3) = (ux * m0)
+ * ty (f5) = (uy * m5)
+ * tz (f7) = (uz * m10)
+ */
+ fmuls %f0, M0, %f3 ! FGM Group
+ st %f3, [%g3 + 0x00] ! LSU
+ fmuls %f1, M5, %f5 ! FGM Group
+ st %f5, [%g3 + 0x04] ! LSU
+ fmuls %f2, M10, %f7 ! FGM Group
+ st %f7, [%g3 + 0x08] ! LSU
+
+ cmp %o4, %g1 ! continue if (i < count)
+ bl 1b
+ add %g3, 0x0c, %g3 ! advance out vector pointer
+
+7: retl
+ nop
+
+ .globl _mesa_sparc_transform_rescale_normals
+_mesa_sparc_transform_rescale_normals:
+ /* o0=mat o1=scale o2=in o3=lengths o4=dest */
+ sub %sp, 16, %sp
+ st %o1, [%sp + STACK_VAR_OFF+0x0]
+ ld [%sp + STACK_VAR_OFF+0x0], %f15 ! f15 = scale
+ add %sp, 16, %sp
+
+ LDPTR [%o0 + MAT_INV], %o0 ! o0 = mat->inv
+ LDPTR [%o2 + V4F_START], %o5 ! o5 = 'from' in->start
+ ld [%o2 + V4F_COUNT], %g1 ! g1 = in->count
+ ld [%o2 + V4F_STRIDE], %g2 ! g2 = in->stride
+ LDPTR [%o4 + V4F_START], %g3 ! g3 = 'out' dest->start
+
+ LDMATRIX_0_1_2_4_5_6_8_9_10(%o0)
+
+ /* dest->count = in->count */
+ st %g1, [%o4 + V4F_COUNT]
+
+ cmp %g1, 1
+ bl 7f
+ clr %o4 ! 'i' for STRIDE_LOOP
+
+ fmuls M0, %f15, M0
+ fmuls M1, %f15, M1
+ fmuls M2, %f15, M2
+ fmuls M4, %f15, M4
+ fmuls M5, %f15, M5
+ fmuls M6, %f15, M6
+ fmuls M8, %f15, M8
+ fmuls M9, %f15, M9
+ fmuls M10, %f15, M10
+
+1: ld [%o5 + 0x00], %f0 ! ux = from[0]
+ ld [%o5 + 0x04], %f1 ! uy = from[1]
+ ld [%o5 + 0x08], %f2 ! uz = from[2]
+ add %o5, %g2, %o5 ! STRIDE_F(from, stride)
+ add %o4, 1, %o4 ! i++
+
+ fmuls %f0, M0, %f3 ! FGM Group
+ fmuls %f1, M1, %f4 ! FGM Group
+ fmuls %f0, M4, %f5 ! FGM Group
+ fmuls %f1, M5, %f6 ! FGM Group
+ fmuls %f0, M8, %f7 ! FGM Group f3 available
+ fmuls %f1, M9, %f8 ! FGM Group f4 available
+ fadds %f3, %f4, %f3 ! FGA
+ fmuls %f2, M2, %f10 ! FGM Group f5 available
+ fmuls %f2, M6, %f0 ! FGM Group f6 available
+ fadds %f5, %f6, %f5 ! FGA
+ fmuls %f2, M10, %f4 ! FGM Group f7 available
+ fadds %f7, %f8, %f7 ! FGA Group f8,f3 available
+ fadds %f3, %f10, %f3 ! FGA Group f10 available
+ st %f3, [%g3 + 0x00] ! LSU
+ fadds %f5, %f0, %f5 ! FGA Group stall f0,f5 available
+ st %f5, [%g3 + 0x04] ! LSU
+ fadds %f7, %f4, %f7 ! FGA Group stall f4,f7 available
+ st %f7, [%g3 + 0x08] ! LSU
+
+ cmp %o4, %g1 ! continue if (i < count)
+ bl 1b
+ add %g3, 0x0c, %g3 ! advance out vector pointer
+
+7: retl
+ nop
+
+ .globl _mesa_sparc_transform_normals_no_rot
+_mesa_sparc_transform_normals_no_rot:
+ /* o0=mat o1=scale o2=in o3=lengths o4=dest */
+ LDPTR [%o0 + MAT_INV], %o0 ! o0 = mat->inv
+ LDPTR [%o2 + V4F_START], %o5 ! o5 = 'from' in->start
+ ld [%o2 + V4F_COUNT], %g1 ! g1 = in->count
+ ld [%o2 + V4F_STRIDE], %g2 ! g2 = in->stride
+ LDPTR [%o4 + V4F_START], %g3 ! g3 = 'out' dest->start
+
+ LDMATRIX_0_5_10(%o0)
+
+ /* dest->count = in->count */
+ st %g1, [%o4 + V4F_COUNT]
+
+ cmp %g1, 1
+ bl 7f
+ clr %o4 ! 'i' for STRIDE_LOOP
+
+1: ld [%o5 + 0x00], %f0 ! ux = from[0]
+ ld [%o5 + 0x04], %f1 ! uy = from[1]
+ ld [%o5 + 0x08], %f2 ! uz = from[2]
+ add %o5, %g2, %o5 ! STRIDE_F(from, stride)
+ add %o4, 1, %o4 ! i++
+
+ /* tx (f3) = (ux * m0)
+ * ty (f5) = (uy * m5)
+ * tz (f7) = (uz * m10)
+ */
+ fmuls %f0, M0, %f3 ! FGM Group
+ st %f3, [%g3 + 0x00] ! LSU
+ fmuls %f1, M5, %f5 ! FGM Group
+ st %f5, [%g3 + 0x04] ! LSU
+ fmuls %f2, M10, %f7 ! FGM Group
+ st %f7, [%g3 + 0x08] ! LSU
+
+ cmp %o4, %g1 ! continue if (i < count)
+ bl 1b
+ add %g3, 0x0c, %g3 ! advance out vector pointer
+
+7: retl
+ nop
+
+ .globl _mesa_sparc_transform_normals
+_mesa_sparc_transform_normals:
+ /* o0=mat o1=scale o2=in o3=lengths o4=dest */
+ LDPTR [%o0 + MAT_INV], %o0 ! o0 = mat->inv
+ LDPTR [%o2 + V4F_START], %o5 ! o5 = 'from' in->start
+ ld [%o2 + V4F_COUNT], %g1 ! g1 = in->count
+ ld [%o2 + V4F_STRIDE], %g2 ! g2 = in->stride
+ LDPTR [%o4 + V4F_START], %g3 ! g3 = 'out' dest->start
+
+ LDMATRIX_0_1_2_4_5_6_8_9_10(%o0)
+
+ /* dest->count = in->count */
+ st %g1, [%o4 + V4F_COUNT]
+
+ cmp %g1, 1
+ bl 7f
+ clr %o4 ! 'i' for STRIDE_LOOP
+
+1: ld [%o5 + 0x00], %f0 ! ux = from[0]
+ ld [%o5 + 0x04], %f1 ! uy = from[1]
+ ld [%o5 + 0x08], %f2 ! uz = from[2]
+ add %o5, %g2, %o5 ! STRIDE_F(from, stride)
+ add %o4, 1, %o4 ! i++
+
+ fmuls %f0, M0, %f3 ! FGM Group
+ fmuls %f1, M1, %f4 ! FGM Group
+ fmuls %f0, M4, %f5 ! FGM Group
+ fmuls %f1, M5, %f6 ! FGM Group
+ fmuls %f0, M8, %f7 ! FGM Group f3 available
+ fmuls %f1, M9, %f8 ! FGM Group f4 available
+ fadds %f3, %f4, %f3 ! FGA
+ fmuls %f2, M2, %f10 ! FGM Group f5 available
+ fmuls %f2, M6, %f0 ! FGM Group f6 available
+ fadds %f5, %f6, %f5 ! FGA
+ fmuls %f2, M10, %f4 ! FGM Group f7 available
+ fadds %f7, %f8, %f7 ! FGA Group f8,f3 available
+ fadds %f3, %f10, %f3 ! FGA Group f10 available
+ st %f3, [%g3 + 0x00] ! LSU
+ fadds %f5, %f0, %f5 ! FGA Group stall f0,f5 available
+ st %f5, [%g3 + 0x04] ! LSU
+ fadds %f7, %f4, %f7 ! FGA Group stall f4,f7 available
+ st %f7, [%g3 + 0x08] ! LSU
+
+ cmp %o4, %g1 ! continue if (i < count)
+ bl 1b
+ add %g3, 0x0c, %g3 ! advance out vector pointer
+
+7: retl
+ nop
+
+ .globl _mesa_sparc_normalize_normals
+_mesa_sparc_normalize_normals:
+ /* o0=mat o1=scale o2=in o3=lengths o4=dest */
+
+ sethi %hi(ONE_DOT_ZERO), %g2
+ sub %sp, 16, %sp
+ st %g2, [%sp + STACK_VAR_OFF+0x0]
+ ld [%sp + STACK_VAR_OFF+0x0], %f12 ! f12 = 1.0f
+ add %sp, 16, %sp
+
+ LDPTR [%o2 + V4F_START], %o5 ! o5 = 'from' in->start
+ ld [%o2 + V4F_COUNT], %g1 ! g1 = in->count
+ ld [%o2 + V4F_STRIDE], %g2 ! g2 = in->stride
+ LDPTR [%o4 + V4F_START], %g3 ! g3 = 'out' dest->start
+
+ /* dest->count = in->count */
+ st %g1, [%o4 + V4F_COUNT]
+
+ cmp %g1, 1
+ bl 7f
+ cmp %o3, 0
+ bne 4f
+ clr %o4 ! 'i' for STRIDE_LOOP
+
+1: /* LENGTHS == NULL */
+ ld [%o5 + 0x00], %f3 ! ux = from[0]
+ ld [%o5 + 0x04], %f5 ! uy = from[1]
+ ld [%o5 + 0x08], %f7 ! uz = from[2]
+ add %o5, %g2, %o5 ! STRIDE_F(from, stride)
+ add %o4, 1, %o4 ! i++
+
+ /* f3=tx, f5=ty, f7=tz */
+
+ /* len (f6) = (tx * tx) + (ty * ty) + (tz * tz) */
+ fmuls %f3, %f3, %f6 ! FGM Group f3 available
+ fmuls %f5, %f5, %f8 ! FGM Group f5 available
+ fmuls %f7, %f7, %f10 ! FGM Group f7 available
+ fadds %f6, %f8, %f6 ! FGA Group 2cyc stall f6,f8 available
+ fadds %f6, %f10, %f6 ! FGA Group 4cyc stall f6,f10 available
+
+ /* scale (f6) = 1.0 / sqrt(len) */
+ fsqrts %f6, %f6 ! FDIV 20 cycles
+ fdivs %f12, %f6, %f6 ! FDIV 14 cycles
+
+ fmuls %f3, %f6, %f3
+ st %f3, [%g3 + 0x00] ! out[i][0] = tx * scale
+ fmuls %f5, %f6, %f5
+ st %f5, [%g3 + 0x04] ! out[i][1] = ty * scale
+ fmuls %f7, %f6, %f7
+ st %f7, [%g3 + 0x08] ! out[i][2] = tz * scale
+
+ cmp %o4, %g1 ! continue if (i < count)
+ bl 1b
+ add %g3, 0x0c, %g3 ! advance out vector pointer
+
+ ba 7f
+ nop
+
+4: /* LENGTHS != NULL */
+
+5:
+ ld [%o5 + 0x00], %f3 ! ux = from[0]
+ ld [%o5 + 0x04], %f5 ! uy = from[1]
+ ld [%o5 + 0x08], %f7 ! uz = from[2]
+ add %o5, %g2, %o5 ! STRIDE_F(from, stride)
+ add %o4, 1, %o4 ! i++
+
+ ld [%o3], %f13 ! LSU
+ add %o3, 4, %o3 ! IEU0
+
+ /* f3=tx, f5=ty, f7=tz, f13=lengths[i] */
+
+ fmuls %f3, %f13, %f3
+ st %f3, [%g3 + 0x00] ! out[i][0] = tx * len
+ fmuls %f5, %f13, %f5
+ st %f5, [%g3 + 0x04] ! out[i][1] = ty * len
+ fmuls %f7, %f13, %f7
+ st %f7, [%g3 + 0x08] ! out[i][2] = tz * len
+
+ cmp %o4, %g1 ! continue if (i < count)
+ bl 5b
+ add %g3, 0x0c, %g3 ! advance out vector pointer
+
+7: retl
+ nop
+
+ .globl _mesa_sparc_rescale_normals
+_mesa_sparc_rescale_normals:
+ /* o0=mat o1=scale o2=in o3=lengths o4=dest */
+
+ sethi %hi(ONE_DOT_ZERO), %g2
+ sub %sp, 16, %sp
+ st %o1, [%sp + STACK_VAR_OFF+0x0]
+ ld [%sp + STACK_VAR_OFF+0x0], %f15 ! f15 = scale
+ add %sp, 16, %sp
+
+ LDPTR [%o2 + V4F_START], %o5 ! o5 = 'from' in->start
+ ld [%o2 + V4F_COUNT], %g1 ! g1 = in->count
+ ld [%o2 + V4F_STRIDE], %g2 ! g2 = in->stride
+ LDPTR [%o4 + V4F_START], %g3 ! g3 = 'out' dest->start
+
+ /* dest->count = in->count */
+ st %g1, [%o4 + V4F_COUNT]
+
+ cmp %g1, 1
+ bl 7f
+ clr %o4 ! 'i' for STRIDE_LOOP
+
+1:
+ ld [%o5 + 0x00], %f3 ! ux = from[0]
+ ld [%o5 + 0x04], %f5 ! uy = from[1]
+ ld [%o5 + 0x08], %f7 ! uz = from[2]
+ add %o5, %g2, %o5 ! STRIDE_F(from, stride)
+ add %o4, 1, %o4 ! i++
+
+ /* f3=tx, f5=ty, f7=tz */
+
+ fmuls %f3, %f15, %f3
+ st %f3, [%g3 + 0x00] ! out[i][0] = tx * scale
+ fmuls %f5, %f15, %f5
+ st %f5, [%g3 + 0x04] ! out[i][1] = ty * scale
+ fmuls %f7, %f15, %f7
+ st %f7, [%g3 + 0x08] ! out[i][2] = tz * scale
+
+ cmp %o4, %g1 ! continue if (i < count)
+ bl 1b
+ add %g3, 0x0c, %g3 ! advance out vector pointer
+
+7: retl
+ nop
diff --git a/nx-X11/extras/Mesa/src/mesa/sparc/sparc.c b/nx-X11/extras/Mesa/src/mesa/sparc/sparc.c
new file mode 100644
index 000000000..b7fe360d2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/sparc/sparc.c
@@ -0,0 +1,177 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+/*
+ * Sparc assembly code by David S. Miller
+ */
+
+
+#include "sparc.h"
+
+#ifdef USE_SPARC_ASM
+
+#include "context.h"
+#include "math/m_xform.h"
+#include "tnl/t_context.h"
+
+#ifdef DEBUG
+#include "math/m_debug.h"
+#endif
+
+#define XFORM_ARGS GLvector4f *to_vec, \
+ const GLfloat m[16], \
+ const GLvector4f *from_vec
+
+#define DECLARE_XFORM_GROUP(pfx, sz) \
+ extern void _mesa_##pfx##_transform_points##sz##_general(XFORM_ARGS); \
+ extern void _mesa_##pfx##_transform_points##sz##_identity(XFORM_ARGS); \
+ extern void _mesa_##pfx##_transform_points##sz##_3d_no_rot(XFORM_ARGS); \
+ extern void _mesa_##pfx##_transform_points##sz##_perspective(XFORM_ARGS); \
+ extern void _mesa_##pfx##_transform_points##sz##_2d(XFORM_ARGS); \
+ extern void _mesa_##pfx##_transform_points##sz##_2d_no_rot(XFORM_ARGS); \
+ extern void _mesa_##pfx##_transform_points##sz##_3d(XFORM_ARGS);
+
+#define ASSIGN_XFORM_GROUP(pfx, sz) \
+ _mesa_transform_tab[sz][MATRIX_GENERAL] = \
+ _mesa_##pfx##_transform_points##sz##_general; \
+ _mesa_transform_tab[sz][MATRIX_IDENTITY] = \
+ _mesa_##pfx##_transform_points##sz##_identity; \
+ _mesa_transform_tab[sz][MATRIX_3D_NO_ROT] = \
+ _mesa_##pfx##_transform_points##sz##_3d_no_rot; \
+ _mesa_transform_tab[sz][MATRIX_PERSPECTIVE] = \
+ _mesa_##pfx##_transform_points##sz##_perspective; \
+ _mesa_transform_tab[sz][MATRIX_2D] = \
+ _mesa_##pfx##_transform_points##sz##_2d; \
+ _mesa_transform_tab[sz][MATRIX_2D_NO_ROT] = \
+ _mesa_##pfx##_transform_points##sz##_2d_no_rot; \
+ _mesa_transform_tab[sz][MATRIX_3D] = \
+ _mesa_##pfx##_transform_points##sz##_3d;
+
+
+DECLARE_XFORM_GROUP(sparc, 1)
+DECLARE_XFORM_GROUP(sparc, 2)
+DECLARE_XFORM_GROUP(sparc, 3)
+DECLARE_XFORM_GROUP(sparc, 4)
+
+extern GLvector4f *_mesa_sparc_cliptest_points4(GLvector4f *clip_vec,
+ GLvector4f *proj_vec,
+ GLubyte clipMask[],
+ GLubyte *orMask,
+ GLubyte *andMask);
+
+extern GLvector4f *_mesa_sparc_cliptest_points4_np(GLvector4f *clip_vec,
+ GLvector4f *proj_vec,
+ GLubyte clipMask[],
+ GLubyte *orMask,
+ GLubyte *andMask);
+
+#define NORM_ARGS const GLmatrix *mat, \
+ GLfloat scale, \
+ const GLvector4f *in, \
+ const GLfloat *lengths, \
+ GLvector4f *dest
+
+extern void _mesa_sparc_transform_normalize_normals(NORM_ARGS);
+extern void _mesa_sparc_transform_normalize_normals_no_rot(NORM_ARGS);
+extern void _mesa_sparc_transform_rescale_normals_no_rot(NORM_ARGS);
+extern void _mesa_sparc_transform_rescale_normals(NORM_ARGS);
+extern void _mesa_sparc_transform_normals_no_rot(NORM_ARGS);
+extern void _mesa_sparc_transform_normals(NORM_ARGS);
+extern void _mesa_sparc_normalize_normals(NORM_ARGS);
+extern void _mesa_sparc_rescale_normals(NORM_ARGS);
+
+
+
+void _mesa_init_all_sparc_transform_asm(void)
+{
+ ASSIGN_XFORM_GROUP(sparc, 1)
+ ASSIGN_XFORM_GROUP(sparc, 2)
+ ASSIGN_XFORM_GROUP(sparc, 3)
+ ASSIGN_XFORM_GROUP(sparc, 4)
+
+ _mesa_clip_tab[4] = _mesa_sparc_cliptest_points4;
+ _mesa_clip_np_tab[4] = _mesa_sparc_cliptest_points4_np;
+
+#if 0
+ /* disable these too. See bug 673938 */
+ _mesa_normal_tab[NORM_TRANSFORM | NORM_NORMALIZE] =
+ _mesa_sparc_transform_normalize_normals;
+ _mesa_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_NORMALIZE] =
+ _mesa_sparc_transform_normalize_normals_no_rot;
+ _mesa_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_RESCALE] =
+ _mesa_sparc_transform_rescale_normals_no_rot;
+ _mesa_normal_tab[NORM_TRANSFORM | NORM_RESCALE] =
+ _mesa_sparc_transform_rescale_normals;
+ _mesa_normal_tab[NORM_TRANSFORM_NO_ROT] =
+ _mesa_sparc_transform_normals_no_rot;
+ _mesa_normal_tab[NORM_TRANSFORM] =
+ _mesa_sparc_transform_normals;
+ _mesa_normal_tab[NORM_NORMALIZE] =
+ _mesa_sparc_normalize_normals;
+ _mesa_normal_tab[NORM_RESCALE] =
+ _mesa_sparc_rescale_normals;
+#endif
+
+#ifdef DEBUG
+ _math_test_all_transform_functions("sparc");
+ _math_test_all_cliptest_functions("sparc");
+ _math_test_all_normal_transform_functions("sparc");
+#endif
+}
+
+extern unsigned int _mesa_sparc_glapi_begin;
+extern unsigned int _mesa_sparc_glapi_end;
+extern void __glapi_sparc_icache_flush(unsigned int *);
+
+#endif /* USE_SPARC_ASM */
+
+
+void _mesa_init_sparc_glapi_relocs(void)
+{
+#ifdef USE_SPARC_ASM
+ unsigned int *insn_ptr, *end_ptr;
+ unsigned long disp_addr;
+
+ insn_ptr = &_mesa_sparc_glapi_begin;
+ end_ptr = &_mesa_sparc_glapi_end;
+ disp_addr = (unsigned long) &_glapi_Dispatch;
+
+ while (insn_ptr < end_ptr) {
+#ifdef __arch64__
+ insn_ptr[0] |= (disp_addr >> (32 + 10));
+ insn_ptr[1] |= ((disp_addr & 0xffffffff) >> 10);
+ __glapi_sparc_icache_flush(&insn_ptr[0]);
+ insn_ptr[2] |= ((disp_addr >> 32) & ((1 << 10) - 1));
+ insn_ptr[3] |= (disp_addr & ((1 << 10) - 1));
+ __glapi_sparc_icache_flush(&insn_ptr[2]);
+ insn_ptr += 11;
+#else
+ insn_ptr[0] |= (disp_addr >> 10);
+ insn_ptr[1] |= (disp_addr & ((1 << 10) - 1));
+ __glapi_sparc_icache_flush(&insn_ptr[0]);
+ insn_ptr += 5;
+#endif
+ }
+#endif /* USE_SPARC_ASM */
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/sparc/sparc.h b/nx-X11/extras/Mesa/src/mesa/sparc/sparc.h
new file mode 100644
index 000000000..497b5728c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/sparc/sparc.h
@@ -0,0 +1,38 @@
+/* $Id: sparc.h,v 1.1.1.1 2004/06/16 09:19:24 anholt Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.1
+ *
+ * Copyright (C) 1999 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.
+ */
+
+/*
+ * Sparc assembly code by David S. Miller
+ */
+
+
+#ifndef SPARC_H
+#define SPARC_H
+
+extern void _mesa_init_all_sparc_transform_asm(void);
+extern void _mesa_init_sparc_glapi_relocs(void);
+
+#endif /* !(SPARC_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/sparc/sparc_matrix.h b/nx-X11/extras/Mesa/src/mesa/sparc/sparc_matrix.h
new file mode 100644
index 000000000..f677d9bda
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/sparc/sparc_matrix.h
@@ -0,0 +1,170 @@
+/*
+ * SPARC assembly matrix code.
+ */
+
+#ifndef _SPARC_MATRIX_H
+#define _SPARC_MATRIX_H
+
+#ifdef __arch64__
+#define LDPTR ldx
+#define MAT_M 0x00
+#define MAT_INV 0x08
+#define V4F_DATA 0x00
+#define V4F_START 0x08
+#define V4F_COUNT 0x10
+#define V4F_STRIDE 0x14
+#define V4F_SIZE 0x18
+#define V4F_FLAGS 0x1c
+#else
+#define LDPTR ld
+#define MAT_M 0x00
+#define MAT_INV 0x04
+#define V4F_DATA 0x00
+#define V4F_START 0x04
+#define V4F_COUNT 0x08
+#define V4F_STRIDE 0x0c
+#define V4F_SIZE 0x10
+#define V4F_FLAGS 0x14
+#endif
+
+#define VEC_SIZE_1 1
+#define VEC_SIZE_2 3
+#define VEC_SIZE_3 7
+#define VEC_SIZE_4 15
+
+#define M0 %f16
+#define M1 %f17
+#define M2 %f18
+#define M3 %f19
+#define M4 %f20
+#define M5 %f21
+#define M6 %f22
+#define M7 %f23
+#define M8 %f24
+#define M9 %f25
+#define M10 %f26
+#define M11 %f27
+#define M12 %f28
+#define M13 %f29
+#define M14 %f30
+#define M15 %f31
+
+#define LDMATRIX_0_1_2_3_12_13_14_15(BASE) \
+ ldd [BASE + ( 0 * 0x4)], M0; \
+ ldd [BASE + ( 2 * 0x4)], M2; \
+ ldd [BASE + (12 * 0x4)], M12; \
+ ldd [BASE + (14 * 0x4)], M14
+
+#define LDMATRIX_0_1_12_13(BASE) \
+ ldd [BASE + ( 0 * 0x4)], M0; \
+ ldd [BASE + (12 * 0x4)], M12
+
+#define LDMATRIX_0_12_13(BASE) \
+ ld [BASE + ( 0 * 0x4)], M0; \
+ ldd [BASE + (12 * 0x4)], M12
+
+#define LDMATRIX_0_1_2_12_13_14(BASE) \
+ ldd [BASE + ( 0 * 0x4)], M0; \
+ ld [BASE + ( 2 * 0x4)], M2; \
+ ldd [BASE + (12 * 0x4)], M12; \
+ ld [BASE + (14 * 0x4)], M14
+
+#define LDMATRIX_0_12_13_14(BASE) \
+ ld [BASE + ( 0 * 0x4)], M0; \
+ ldd [BASE + (12 * 0x4)], M12; \
+ ld [BASE + (14 * 0x4)], M14
+
+#define LDMATRIX_0_14(BASE) \
+ ld [BASE + ( 0 * 0x4)], M0; \
+ ld [BASE + (14 * 0x4)], M14
+
+#define LDMATRIX_0_1_2_3_4_5_6_7_12_13_14_15(BASE) \
+ ldd [BASE + ( 0 * 0x4)], M0; \
+ ldd [BASE + ( 2 * 0x4)], M2; \
+ ldd [BASE + ( 4 * 0x4)], M4; \
+ ldd [BASE + ( 6 * 0x4)], M6; \
+ ldd [BASE + (12 * 0x4)], M12; \
+ ldd [BASE + (14 * 0x4)], M14
+
+#define LDMATRIX_0_5_12_13(BASE) \
+ ld [BASE + ( 0 * 0x4)], M0; \
+ ld [BASE + ( 5 * 0x4)], M5; \
+ ldd [BASE + (12 * 0x4)], M12
+
+#define LDMATRIX_0_1_2_3_4_5_6_12_13_14(BASE) \
+ ldd [BASE + ( 0 * 0x4)], M0; \
+ ldd [BASE + ( 2 * 0x4)], M2; \
+ ldd [BASE + ( 4 * 0x4)], M4; \
+ ld [BASE + ( 6 * 0x4)], M6; \
+ ldd [BASE + (12 * 0x4)], M12; \
+ ld [BASE + (14 * 0x4)], M14
+
+#define LDMATRIX_0_5_12_13_14(BASE) \
+ ld [BASE + ( 0 * 0x4)], M0; \
+ ld [BASE + ( 5 * 0x4)], M5; \
+ ldd [BASE + (12 * 0x4)], M12; \
+ ld [BASE + (14 * 0x4)], M14
+
+#define LDMATRIX_0_5_14(BASE) \
+ ld [BASE + ( 0 * 0x4)], M0; \
+ ld [BASE + ( 5 * 0x4)], M5; \
+ ld [BASE + (14 * 0x4)], M14
+
+#define LDMATRIX_0_1_2_3_4_5_6_7_8_9_10_11_12_13_14_15(BASE) \
+ ldd [BASE + ( 0 * 0x4)], M0; \
+ ldd [BASE + ( 2 * 0x4)], M2; \
+ ldd [BASE + ( 4 * 0x4)], M4; \
+ ldd [BASE + ( 6 * 0x4)], M6; \
+ ldd [BASE + ( 8 * 0x4)], M8; \
+ ldd [BASE + (10 * 0x4)], M10; \
+ ldd [BASE + (12 * 0x4)], M12; \
+ ldd [BASE + (14 * 0x4)], M14
+
+#define LDMATRIX_0_1_4_5_12_13(BASE) \
+ ldd [BASE + ( 0 * 0x4)], M0; \
+ ldd [BASE + ( 4 * 0x4)], M4; \
+ ldd [BASE + (12 * 0x4)], M12
+
+#define LDMATRIX_0_5_12_13(BASE) \
+ ld [BASE + ( 0 * 0x4)], M0; \
+ ld [BASE + ( 5 * 0x4)], M5; \
+ ldd [BASE + (12 * 0x4)], M12
+
+#define LDMATRIX_0_1_2_4_5_6_8_9_10(BASE) \
+ ldd [BASE + ( 0 * 0x4)], M0; \
+ ld [BASE + ( 2 * 0x4)], M2; \
+ ldd [BASE + ( 4 * 0x4)], M4; \
+ ld [BASE + ( 6 * 0x4)], M6; \
+ ldd [BASE + ( 8 * 0x4)], M8; \
+ ld [BASE + (10 * 0x4)], M10
+
+#define LDMATRIX_0_1_2_4_5_6_8_9_10_12_13_14(BASE) \
+ ldd [BASE + ( 0 * 0x4)], M0; \
+ ld [BASE + ( 2 * 0x4)], M2; \
+ ldd [BASE + ( 4 * 0x4)], M4; \
+ ld [BASE + ( 6 * 0x4)], M6; \
+ ldd [BASE + ( 8 * 0x4)], M8; \
+ ld [BASE + (10 * 0x4)], M10; \
+ ldd [BASE + (12 * 0x4)], M12; \
+ ld [BASE + (14 * 0x4)], M14
+
+#define LDMATRIX_0_5_10(BASE) \
+ ld [BASE + ( 0 * 0x4)], M0; \
+ ld [BASE + ( 5 * 0x4)], M5; \
+ ld [BASE + (10 * 0x4)], M10; \
+
+#define LDMATRIX_0_5_10_12_13_14(BASE) \
+ ld [BASE + ( 0 * 0x4)], M0; \
+ ld [BASE + ( 5 * 0x4)], M5; \
+ ld [BASE + (10 * 0x4)], M10; \
+ ldd [BASE + (12 * 0x4)], M12; \
+ ld [BASE + (14 * 0x4)], M14
+
+#define LDMATRIX_0_5_8_9_10_14(BASE) \
+ ld [BASE + ( 0 * 0x4)], M0; \
+ ld [BASE + ( 5 * 0x4)], M5; \
+ ldd [BASE + ( 8 * 0x4)], M8; \
+ ld [BASE + (10 * 0x4)], M10; \
+ ld [BASE + (14 * 0x4)], M14
+
+#endif /* !(_SPARC_MATRIX_H) */
diff --git a/nx-X11/extras/Mesa/src/mesa/sparc/xform.S b/nx-X11/extras/Mesa/src/mesa/sparc/xform.S
new file mode 100644
index 000000000..625d31cbd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/sparc/xform.S
@@ -0,0 +1,1393 @@
+/* $Id: xform.S,v 1.1.1.2 2005/07/31 16:46:49 ajax Exp $ */
+
+ /* TODO
+ *
+ * 1) It would be nice if load/store double could be used
+ * at least for the matrix parts. I think for the matrices
+ * it is safe, but for the vertices it probably is not due to
+ * things like glInterleavedArrays etc.
+ *
+ * UPDATE: Trying this now in sparc_matrix.h -DaveM_990624
+ *
+ * 2) One extremely slick trick would be if we could enclose
+ * groups of xform calls on the same vertices such that
+ * we just load the matrix into f16-->f31 before the calls
+ * and then we would not have to do them here. This may be
+ * tricky and not much of a gain though.
+ */
+
+#include "sparc_matrix.h"
+
+#if defined(SVR4) || defined(__SVR4) || defined(__svr4__)
+ /* Solaris requires this for 64-bit. */
+ .register %g2, #scratch
+ .register %g3, #scratch
+#endif
+
+ .text
+ .align 64
+
+__set_v4f_1:
+ ld [%o0 + V4F_FLAGS], %g2
+ mov 1, %g1
+ st %g1, [%o0 + V4F_SIZE]
+ or %g2, VEC_SIZE_1, %g2
+ retl
+ st %g2, [%o0 + V4F_FLAGS]
+__set_v4f_2:
+ ld [%o0 + V4F_FLAGS], %g2
+ mov 2, %g1
+ st %g1, [%o0 + V4F_SIZE]
+ or %g2, VEC_SIZE_2, %g2
+ retl
+ st %g2, [%o0 + V4F_FLAGS]
+__set_v4f_3:
+ ld [%o0 + V4F_FLAGS], %g2
+ mov 3, %g1
+ st %g1, [%o0 + V4F_SIZE]
+ or %g2, VEC_SIZE_3, %g2
+ retl
+ st %g2, [%o0 + V4F_FLAGS]
+__set_v4f_4:
+ ld [%o0 + V4F_FLAGS], %g2
+ mov 4, %g1
+ st %g1, [%o0 + V4F_SIZE]
+ or %g2, VEC_SIZE_4, %g2
+ retl
+ st %g2, [%o0 + V4F_FLAGS]
+
+ /* First the raw versions. */
+
+ .globl _mesa_sparc_transform_points1_general
+_mesa_sparc_transform_points1_general:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_1_2_3_12_13_14_15(%o1)
+
+ cmp %g3, 1
+ st %g3, [%o0 + V4F_COUNT]
+ bl 3f
+ clr %o1
+
+ be 2f
+ andn %g3, 1, %o2
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ add %g1, %o5, %g1 ! IEU0
+ ld [%g1 + 0x00], %f8 ! LSU Group
+ add %o1, 2, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f1 ! FGM Group 1-cycle stall on %f0
+ fmuls %f0, M1, %f2 ! FGM Group
+ fmuls %f0, M2, %f3 ! FGM Group
+ fmuls %f0, M3, %f4 ! FGM Group
+ fmuls %f8, M0, %f9 ! FGM Group f1 available
+ fadds %f1, M12, %f1 ! FGA
+ st %f1, [%g2 + 0x00] ! LSU
+ fmuls %f8, M1, %f10 ! FGM Group f2 available
+ fadds %f2, M13, %f2 ! FGA
+ st %f2, [%g2 + 0x04] ! LSU
+ fmuls %f8, M2, %f11 ! FGM Group f3 available
+ fadds %f3, M14, %f3 ! FGA
+ st %f3, [%g2 + 0x08] ! LSU
+ fmuls %f8, M3, %f12 ! FGM Group f4 available
+ fadds %f4, M15, %f4 ! FGA
+ st %f4, [%g2 + 0x0c] ! LSU
+ fadds %f9, M12, %f9 ! FGA Group f9 available
+ st %f9, [%g2 + 0x10] ! LSU
+ fadds %f10, M13, %f10 ! FGA Group f10 available
+ st %f10, [%g2 + 0x14] ! LSU
+ fadds %f11, M14, %f11 ! FGA Group f11 available
+ st %f11, [%g2 + 0x18] ! LSU
+ fadds %f12, M15, %f12 ! FGA Group f12 available
+ st %f12, [%g2 + 0x1c] ! LSU
+ cmp %o1, %o2 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x20, %g2 ! IEU0 Group
+
+ cmp %o1, %g3
+ be 3f
+ nop
+
+2: ld [%g1 + 0x00], %f0 ! LSU Group
+ fmuls %f0, M0, %f1 ! FGM Group 1-cycle stall on %f0
+ fmuls %f0, M1, %f2 ! FGM Group
+ fmuls %f0, M2, %f3 ! FGM Group
+ fmuls %f0, M3, %f4 ! FGM Group
+ fadds %f1, M12, %f1 ! FGA Group
+ st %f1, [%g2 + 0x00] ! LSU
+ fadds %f2, M13, %f2 ! FGA Group
+ st %f2, [%g2 + 0x04] ! LSU
+ fadds %f3, M14, %f3 ! FGA Group
+ st %f3, [%g2 + 0x08] ! LSU
+ fadds %f4, M15, %f4 ! FGA Group
+ st %f4, [%g2 + 0x0c] ! LSU
+
+3:
+ ba __set_v4f_4
+ nop
+
+ .globl _mesa_sparc_transform_points1_identity
+_mesa_sparc_transform_points1_identity:
+ cmp %o0, %o2
+ be 4f
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ cmp %g3, 1
+ st %g3, [%o0 + V4F_COUNT]
+ bl 3f
+ clr %o1
+
+ be 2f
+ andn %g3, 1, %o2
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ add %g1, %o5, %g1 ! IEU0
+ ld [%g1 + 0x00], %f1 ! LSU Group
+ add %o1, 2, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ st %f0, [%g2 + 0x00] ! LSU Group
+ cmp %o1, %o2 ! IEU1
+ st %f1, [%g2 + 0x10] ! LSU Group
+ bne 1b ! CTI
+ add %g2, 0x20, %g2 ! IEU0
+
+ cmp %o1, %g3
+ be 3f
+ nop
+
+2: ld [%g1 + 0x00], %f0
+ addx %g0, %g0, %g0
+ st %f0, [%g2 + 0x00]
+
+3:
+ ba __set_v4f_1
+ nop
+
+4: retl
+ nop
+
+ .globl _mesa_sparc_transform_points1_2d
+_mesa_sparc_transform_points1_2d:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_1_12_13(%o1)
+
+ cmp %g3, 1
+ st %g3, [%o0 + V4F_COUNT]
+ bl 3f
+ clr %o1
+
+ be 2f
+ andn %g3, 1, %o2
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ add %g1, %o5, %g1 ! IEU0
+ ld [%g1 + 0x00], %f8 ! LSU Group
+ add %o1, 2, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f1 ! FGM Group
+ fmuls %f0, M1, %f2 ! FGM Group
+ fmuls %f8, M0, %f9 ! FGM Group
+ fmuls %f8, M1, %f10 ! FGM Group
+ fadds %f1, M12, %f3 ! FGA Group f1 available
+ st %f3, [%g2 + 0x00] ! LSU
+ fadds %f2, M13, %f4 ! FGA Group f2 available
+ st %f4, [%g2 + 0x04] ! LSU
+ fadds %f9, M12, %f11 ! FGA Group f9 available
+ st %f11, [%g2 + 0x10] ! LSU
+ fadds %f10, M13, %f12 ! FGA Group f10 available
+ st %f12, [%g2 + 0x14] ! LSU
+ cmp %o1, %o2 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x20, %g2 ! IEU0 Group
+
+ cmp %o1, %g3
+ be 3f
+ nop
+
+2: ld [%g1 + 0x00], %f0
+ fmuls %f0, M0, %f1
+ fmuls %f0, M1, %f2
+ fadds %f1, M12, %f3
+ st %f3, [%g2 + 0x00]
+ fadds %f2, M13, %f4
+ st %f4, [%g2 + 0x04]
+
+3:
+ ba __set_v4f_2
+ nop
+
+ .globl _mesa_sparc_transform_points1_2d_no_rot
+_mesa_sparc_transform_points1_2d_no_rot:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_12_13(%o1)
+
+ cmp %g3, 1
+ st %g3, [%o0 + V4F_COUNT]
+ bl 3f
+ clr %o1
+
+ be 2f
+ andn %g3, 1, %o2
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ add %g1, %o5, %g1 ! IEU0
+ ld [%g1 + 0x00], %f4 ! LSU Group
+ add %o1, 2, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f1 ! FGM Group
+ fmuls %f4, M0, %f5 ! FGM Group
+ fadds %f1, M12, %f3 ! FGA Group, 2 cycle stall, f1 available
+ st %f3, [%g2 + 0x00] ! LSU
+ st M13, [%g2 + 0x04] ! LSU Group, f5 available
+ fadds %f5, M12, %f6 ! FGA
+ st %f6, [%g2 + 0x10] ! LSU Group
+ st M13, [%g2 + 0x14] ! LSU Group
+ cmp %o1, %o2 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x20, %g2 ! IEU0 Group
+
+ cmp %o1, %g3
+ be 3f
+ nop
+
+2: ld [%g1 + 0x00], %f0
+ fmuls %f0, M0, %f1
+ fadds %f1, M12, %f3
+ st %f3, [%g2 + 0x00]
+ st M13, [%g2 + 0x04]
+
+3:
+ ba __set_v4f_2
+ nop
+
+ .globl _mesa_sparc_transform_points1_3d
+_mesa_sparc_transform_points1_3d:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_1_2_12_13_14(%o1)
+
+ cmp %g3, 1
+ st %g3, [%o0 + V4F_COUNT]
+ bl 3f
+ clr %o1
+
+ be 2f
+ andn %g3, 1, %o2
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ add %g1, %o5, %g1 ! IEU0
+ ld [%g1 + 0x00], %f4 ! LSU Group
+ add %o1, 2, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f1 ! FGM Group
+ fmuls %f0, M1, %f2 ! FGM Group
+ fmuls %f0, M2, %f3 ! FGM Group
+ fmuls %f4, M0, %f5 ! FGM Group
+ fadds %f1, M12, %f1 ! FGA Group, f1 available
+ st %f1, [%g2 + 0x00] ! LSU
+ fmuls %f4, M1, %f6 ! FGM
+ fadds %f2, M13, %f2 ! FGA Group, f2 available
+ st %f2, [%g2 + 0x04] ! LSU
+ fmuls %f4, M2, %f7 ! FGM
+ fadds %f3, M14, %f3 ! FGA Group, f3 available
+ st %f3, [%g2 + 0x08] ! LSU
+ fadds %f5, M12, %f5 ! FGA Group, f5 available
+ st %f5, [%g2 + 0x10] ! LSU
+ fadds %f6, M13, %f6 ! FGA Group, f6 available
+ st %f6, [%g2 + 0x14] ! LSU
+ fadds %f7, M14, %f7 ! FGA Group, f7 available
+ st %f7, [%g2 + 0x18] ! LSU
+ cmp %o1, %o2 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x20, %g2 ! IEU0 Group
+
+ cmp %o1, %g3
+ be 3f
+ nop
+
+2: ld [%g1 + 0x00], %f0
+ fmuls %f0, M0, %f1
+ fmuls %f0, M1, %f2
+ fmuls %f0, M2, %f3
+ fadds %f1, M12, %f1
+ st %f1, [%g2 + 0x00]
+ fadds %f2, M13, %f2
+ st %f2, [%g2 + 0x04]
+ fadds %f3, M14, %f3
+ st %f3, [%g2 + 0x08]
+
+3:
+ ba __set_v4f_3
+ nop
+
+ .globl _mesa_sparc_transform_points1_3d_no_rot
+_mesa_sparc_transform_points1_3d_no_rot:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_12_13_14(%o1)
+
+ cmp %g3, 1
+ st %g3, [%o0 + V4F_COUNT]
+ bl 3f
+ clr %o1
+
+ be 2f
+ andn %g3, 1, %o2
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ add %g1, %o5, %g1 ! IEU0
+ ld [%g1 + 0x00], %f2 ! LSU Group
+ add %o1, 2, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f1 ! FGM Group
+ fmuls %f2, M0, %f3 ! FGM Group
+ fadds %f1, M12, %f1 ! FGA Group, 2 cycle stall, f1 available
+ st %f1, [%g2 + 0x00] ! LSU
+ fadds %f3, M12, %f3 ! FGA Group, f3 available
+ st M13, [%g2 + 0x04] ! LSU
+ st M14, [%g2 + 0x08] ! LSU Group
+ st %f3, [%g2 + 0x10] ! LSU Group
+ st M13, [%g2 + 0x14] ! LSU Group
+ st M14, [%g2 + 0x18] ! LSU Group
+ cmp %o1, %o2 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x20, %g2 ! IEU0 Group
+
+ cmp %o1, %g3
+ be 3f
+ nop
+
+2: ld [%g1 + 0x00], %f0
+ fmuls %f0, M0, %f1
+ fadds %f1, M12, %f1
+ st %f1, [%g2 + 0x00]
+ st M13, [%g2 + 0x04]
+ st M14, [%g2 + 0x08]
+
+3:
+ ba __set_v4f_3
+ nop
+
+ .globl _mesa_sparc_transform_points1_perspective
+_mesa_sparc_transform_points1_perspective:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_14(%o1)
+
+ cmp %g3, 1
+ st %g3, [%o0 + V4F_COUNT]
+ bl 3f
+ clr %o1
+
+ be 2f
+ andn %g3, 1, %o2
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ add %g1, %o5, %g1 ! IEU0
+ ld [%g1 + 0x00], %f2 ! LSU Group
+ add %o1, 2, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f1 ! FGM Group
+ st %f1, [%g2 + 0x00] ! LSU
+ fmuls %f2, M0, %f3 ! FGM Group
+ st %g0, [%g2 + 0x04] ! LSU
+ st M14, [%g2 + 0x08] ! LSU Group
+ st %g0, [%g2 + 0x0c] ! LSU Group
+ st %f3, [%g2 + 0x10] ! LSU Group
+ st %g0, [%g2 + 0x14] ! LSU Group
+ st M14, [%g2 + 0x18] ! LSU Group
+ st %g0, [%g2 + 0x1c] ! LSU Group
+ cmp %o1, %o2 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x20, %g2 ! IEU0 Group
+
+ cmp %o1, %g3
+ be 3f
+ nop
+
+2: ld [%g1 + 0x00], %f0
+ fmuls %f0, M0, %f1
+ st %f1, [%g2 + 0x00]
+ st %g0, [%g2 + 0x04]
+ st M14, [%g2 + 0x08]
+ st %g0, [%g2 + 0x0c]
+
+3:
+ ba __set_v4f_4
+ nop
+
+ .globl _mesa_sparc_transform_points2_general
+_mesa_sparc_transform_points2_general:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_1_2_3_4_5_6_7_12_13_14_15(%o1)
+
+ cmp %g3, 0
+ st %g3, [%o0 + V4F_COUNT]
+ be 2f
+ clr %o1
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ add %o1, 1, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f2 ! FGM Group
+ fmuls %f0, M1, %f3 ! FGM Group
+ fmuls %f0, M2, %f4 ! FGM Group
+ fmuls %f0, M3, %f5 ! FGM Group
+ fadds %f2, M12, %f2 ! FGA Group f2 available
+ fmuls %f1, M4, %f6 ! FGM
+ fadds %f3, M13, %f3 ! FGA Group f3 available
+ fmuls %f1, M5, %f7 ! FGM
+ fadds %f4, M14, %f4 ! FGA Group f4 available
+ fmuls %f1, M6, %f8 ! FGM
+ fadds %f5, M15, %f5 ! FGA Group f5 available
+ fmuls %f1, M7, %f9 ! FGM
+ fadds %f2, %f6, %f2 ! FGA Group f6 available
+ st %f2, [%g2 + 0x00] ! LSU
+ fadds %f3, %f7, %f3 ! FGA Group f7 available
+ st %f3, [%g2 + 0x04] ! LSU
+ fadds %f4, %f8, %f4 ! FGA Group f8 available
+ st %f4, [%g2 + 0x08] ! LSU
+ fadds %f5, %f9, %f5 ! FGA Group f9 available
+ st %f5, [%g2 + 0x0c] ! LSU
+ cmp %o1, %g3 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x10, %g2 ! IEU0 Group
+2:
+ ba __set_v4f_4
+ nop
+
+ .globl _mesa_sparc_transform_points2_identity
+_mesa_sparc_transform_points2_identity:
+ cmp %o2, %o0
+ be 3f
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ cmp %g3, 0
+ st %g3, [%o0 + V4F_COUNT]
+ be 2f
+ clr %o1
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ add %o1, 1, %o1 ! IEU0
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ add %g1, %o5, %g1 ! IEU0
+ cmp %o1, %g3 ! IEU1
+ st %f0, [%g2 + 0x00] ! LSU Group
+ st %f1, [%g2 + 0x04] ! LSU Group
+ bne 1b ! CTI
+ add %g2, 0x10, %g2 ! IEU0
+2:
+ ba __set_v4f_2
+ nop
+
+3: retl
+ nop
+
+ .globl _mesa_sparc_transform_points2_2d
+_mesa_sparc_transform_points2_2d:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_1_4_5_12_13(%o1)
+
+ cmp %g3, 1
+ st %g3, [%o0 + V4F_COUNT]
+ bl 3f
+ clr %o1
+
+ be 2f
+ andn %g3, 1, %o2
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ add %o1, 2, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f2 ! FGM
+ ld [%g1 + 0x00], %f8 ! LSU Group
+ fmuls %f0, M1, %f3 ! FGM
+ ld [%g1 + 0x04], %f9 ! LSU Group
+ fmuls %f1, M4, %f6 ! FGM
+ fmuls %f1, M5, %f7 ! FGM Group
+ add %g1, %o5, %g1 ! IEU0
+ fmuls %f8, M0, %f10 ! FGM Group f2 available
+ fadds %f2, M12, %f2 ! FGA
+ fmuls %f8, M1, %f11 ! FGM Group f3 available
+ fadds %f3, M13, %f3 ! FGA
+ fmuls %f9, M4, %f12 ! FGM Group
+ fmuls %f9, M5, %f13 ! FGM Group
+ fadds %f10, M12, %f10 ! FGA Group f2, f10 available
+ fadds %f2, %f6, %f2 ! FGA Group f3, f11 available
+ st %f2, [%g2 + 0x00] ! LSU
+ fadds %f11, M13, %f11 ! FGA Group f12 available
+ fadds %f3, %f7, %f3 ! FGA Group f13 available
+ st %f3, [%g2 + 0x04] ! LSU
+ fadds %f10, %f12, %f10 ! FGA Group f10 available
+ st %f10, [%g2 + 0x10] ! LSU
+ fadds %f11, %f13, %f11 ! FGA Group f11 available
+ st %f11, [%g2 + 0x14] ! LSU
+ cmp %o1, %o2 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x20, %g2 ! IEU0 Group
+
+ cmp %o1, %g3
+ be 3f
+ nop
+
+2: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ fmuls %f0, M0, %f2 ! FGM Group
+ fmuls %f0, M1, %f3 ! FGM Group
+ fmuls %f1, M4, %f6 ! FGM Group
+ fmuls %f1, M5, %f7 ! FGM Group
+ fadds %f2, M12, %f2 ! FGA Group f2 available
+ fadds %f3, M13, %f3 ! FGA Group f3 available
+ fadds %f2, %f6, %f2 ! FGA Group 2 cycle stall, f2 available
+ st %f2, [%g2 + 0x00] ! LSU
+ fadds %f3, %f7, %f3 ! FGA Group f3 available
+ st %f3, [%g2 + 0x04] ! LSU
+
+3:
+ ba __set_v4f_2
+ nop
+
+ .globl _mesa_sparc_transform_points2_2d_no_rot
+_mesa_sparc_transform_points2_2d_no_rot:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_5_12_13(%o1)
+
+ cmp %g3, 1
+ st %g3, [%o0 + V4F_COUNT]
+ bl 3f
+ clr %o1
+
+ be 2f
+ andn %g3, 1, %o2
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ add %o1, 2, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ ld [%g1 + 0x00], %f4 ! LSU Group
+ fmuls %f0, M0, %f2 ! FGM
+ ld [%g1 + 0x04], %f5 ! LSU Group
+ fmuls %f1, M5, %f3 ! FGM
+ fmuls %f4, M0, %f6 ! FGM Group
+ add %g1, %o5, %g1 ! IEU0
+ fmuls %f5, M5, %f7 ! FGM Group
+ fadds %f2, M12, %f2 ! FGA Group f2 available
+ st %f2, [%g2 + 0x00] ! LSU
+ fadds %f3, M13, %f3 ! FGA Group f3 available
+ st %f3, [%g2 + 0x04] ! LSU
+ fadds %f6, M12, %f6 ! FGA Group f6 available
+ st %f6, [%g2 + 0x10] ! LSU
+ fadds %f7, M13, %f7 ! FGA Group f7 available
+ st %f7, [%g2 + 0x14] ! LSU
+ cmp %o1, %o2 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x20, %g2 ! IEU0 Group
+
+ cmp %o1, %g3
+ be 3f
+ nop
+
+2: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ fmuls %f0, M0, %f2 ! FGM Group
+ fmuls %f1, M5, %f3 ! FGM Group
+ fadds %f2, M12, %f2 ! FGA Group, 2 cycle stall, f2 available
+ st %f2, [%g2 + 0x00] ! LSU
+ fadds %f3, M13, %f3 ! FGA Group f3 available
+ st %f3, [%g2 + 0x04] ! LSU
+
+3:
+ ba __set_v4f_2
+ nop
+
+ /* orig: 12 cycles */
+ .globl _mesa_sparc_transform_points2_3d
+_mesa_sparc_transform_points2_3d:
+ ld [%o2 + V4F_STRIDE], %o5
+ ld [%o2 + V4F_START], %g1
+ ld [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_1_2_3_4_5_6_12_13_14(%o1)
+
+ cmp %g3, 1
+ st %g3, [%o0 + V4F_COUNT]
+ bl 3f
+ clr %o1
+
+ be 2f
+ andn %g3, 1, %o2
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ add %o1, 2, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ ld [%g1 + 0x00], %f9 ! LSU Group
+ fmuls %f0, M0, %f2 ! FGM
+ ld [%g1 + 0x04], %f10 ! LSU Group
+ fmuls %f0, M1, %f3 ! FGM
+ fmuls %f0, M2, %f4 ! FGM Group
+ add %g1, %o5, %g1 ! IEU0
+ fmuls %f1, M4, %f6 ! FGM Group
+ fmuls %f1, M5, %f7 ! FGM Group f2 available
+ fadds %f2, M12, %f2 ! FGA
+ fmuls %f1, M6, %f8 ! FGM Group f3 available
+ fadds %f3, M13, %f3 ! FGA
+ fmuls %f9, M0, %f11 ! FGM Group f4 available
+ fadds %f4, M14, %f4 ! FGA
+ fmuls %f9, M1, %f12 ! FGM Group f6 available
+ fmuls %f9, M2, %f13 ! FGM Group f2, f7 available
+ fadds %f2, %f6, %f2 ! FGA
+ st %f2, [%g2 + 0x00] ! LSU
+ fmuls %f10, M4, %f14 ! FGM Group f3, f8 available
+ fadds %f3, %f7, %f3 ! FGA
+ st %f3, [%g2 + 0x04] ! LSU
+ fmuls %f10, M5, %f15 ! FGM Group f4, f11 available
+ fadds %f11, M12, %f11 ! FGA
+ fmuls %f10, M6, %f0 ! FGM Group f12 available
+ fadds %f12, M13, %f12 ! FGA
+ fadds %f13, M14, %f13 ! FGA Group f13 available
+ fadds %f4, %f8, %f4 ! FGA Group f14 available
+ st %f4, [%g2 + 0x08] ! LSU
+ fadds %f11, %f14, %f11 ! FGA Group f15, f11 available
+ st %f11, [%g2 + 0x10] ! LSU
+ fadds %f12, %f15, %f12 ! FGA Group f0, f12 available
+ st %f12, [%g2 + 0x14] ! LSU
+ fadds %f13, %f0, %f13 ! FGA Group f13 available
+ st %f13, [%g2 + 0x18] ! LSU
+
+ cmp %o1, %o2 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x20, %g2 ! IEU0 Group
+
+ cmp %o1, %g3
+ be 3f
+ nop
+
+2: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ fmuls %f0, M0, %f2 ! FGM Group
+ fmuls %f0, M1, %f3 ! FGM Group
+ fmuls %f0, M2, %f4 ! FGM Group
+ fmuls %f1, M4, %f6 ! FGM Group
+ fmuls %f1, M5, %f7 ! FGM Group f2 available
+ fadds %f2, M12, %f2 ! FGA
+ fmuls %f1, M6, %f8 ! FGM Group f3 available
+ fadds %f3, M13, %f3 ! FGA
+ fadds %f4, M14, %f4 ! FGA Group f4 available
+ fadds %f2, %f6, %f2 ! FGA Group stall, f2, f6, f7 available
+ st %f2, [%g2 + 0x00] ! LSU
+ fadds %f3, %f7, %f3 ! FGA Group f3, f8 available
+ st %f3, [%g2 + 0x04] ! LSU
+ fadds %f4, %f8, %f4 ! FGA Group f4 available
+ st %f4, [%g2 + 0x08] ! LSU
+
+3:
+ ba __set_v4f_3
+ nop
+
+ .globl _mesa_sparc_transform_points2_3d_no_rot
+_mesa_sparc_transform_points2_3d_no_rot:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_5_12_13_14(%o1)
+
+ cmp %g3, 1
+ st %g3, [%o0 + V4F_COUNT]
+ bl 3f
+ clr %o3
+
+ be 2f
+ andn %g3, 1, %o2
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ add %o3, 2, %o3 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ ld [%g1 + 0x00], %f4 ! LSU Group
+ fmuls %f0, M0, %f2 ! FGM
+ ld [%g1 + 0x04], %f5 ! LSU Group
+ fmuls %f1, M5, %f3 ! FGM
+ fmuls %f4, M0, %f6 ! FGM Group
+ add %g1, %o5, %g1 ! IEU0
+ fmuls %f5, M5, %f7 ! FGM Group
+ fadds %f2, M12, %f2 ! FGA Group f2 available
+ st %f2, [%g2 + 0x00] ! LSU
+ fadds %f3, M13, %f3 ! FGA Group f3 available
+ st %f3, [%g2 + 0x04] ! LSU
+ fadds %f6, M12, %f6 ! FGA Group f6 available
+ st M14, [%g2 + 0x08] ! LSU
+ fadds %f7, M13, %f7 ! FGA Group f7 available
+ st %f6, [%g2 + 0x10] ! LSU
+ st %f7, [%g2 + 0x14] ! LSU Group
+ st M14, [%g2 + 0x18] ! LSU Group
+ cmp %o3, %o2 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x20, %g2 ! IEU0 Group
+
+ cmp %o3, %g3
+ be 3f
+ nop
+
+2: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ fmuls %f0, M0, %f2 ! FGM Group
+ fmuls %f1, M5, %f3 ! FGM Group
+ fadds %f2, M12, %f2 ! FGA Group, 2 cycle stall, f2 available
+ st %f2, [%g2 + 0x00] ! LSU
+ fadds %f3, M13, %f3 ! FGA Group f3 available
+ st %f3, [%g2 + 0x04] ! LSU
+ st M14, [%g2 + 0x08] ! LSU Group
+
+3: ld [%o1 + (14 * 0x4)], %g3
+ cmp %g3, 0
+ bne __set_v4f_3
+ nop
+ ba __set_v4f_2
+ nop
+
+ .globl _mesa_sparc_transform_points2_perspective
+_mesa_sparc_transform_points2_perspective:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_5_14(%o1)
+
+ cmp %g3, 0
+ st %g3, [%o0 + V4F_COUNT]
+ be 2f
+ clr %o1
+
+1: ld [%g1 + 0x00], %f0
+ ld [%g1 + 0x04], %f1
+ add %o1, 1, %o1
+ add %g1, %o5, %g1
+ fmuls %f0, M0, %f2
+ st %f2, [%g2 + 0x00]
+ fmuls %f1, M5, %f3
+ st %f3, [%g2 + 0x04]
+ st M14, [%g2 + 0x08]
+ st %g0, [%g2 + 0x0c]
+ cmp %o1, %g3
+ bne 1b
+ add %g2, 0x10, %g2
+2:
+ ba __set_v4f_4
+ nop
+
+ .globl _mesa_sparc_transform_points3_general
+_mesa_sparc_transform_points3_general:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_1_2_3_4_5_6_7_8_9_10_11_12_13_14_15(%o1)
+
+ cmp %g3, 0
+ st %g3, [%o0 + V4F_COUNT]
+ be 2f
+ clr %o1
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ ld [%g1 + 0x08], %f2 ! LSU Group
+ add %o1, 1, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f3 ! FGM
+ fmuls %f1, M4, %f7 ! FGM Group
+ fmuls %f0, M1, %f4 ! FGM Group
+ fmuls %f1, M5, %f8 ! FGM Group
+ fmuls %f0, M2, %f5 ! FGM Group f3 available
+ fmuls %f1, M6, %f9 ! FGM Group f7 available
+ fadds %f3, %f7, %f3 ! FGA
+ fmuls %f0, M3, %f6 ! FGM Group f4 available
+ fmuls %f1, M7, %f10 ! FGM Group f8 available
+ fadds %f4, %f8, %f4 ! FGA
+ fmuls %f2, M8, %f7 ! FGM Group f5 available
+ fmuls %f2, M9, %f8 ! FGM Group f9,f3 available
+ fadds %f5, %f9, %f5 ! FGA
+ fmuls %f2, M10, %f9 ! FGM Group f6 available
+ fadds %f6, %f10, %f6 ! FGA Group f10,f4 available
+ fmuls %f2, M11, %f10 ! FGM
+ fadds %f3, M12, %f3 ! FGA Group f7 available
+ fadds %f4, M13, %f4 ! FGA Group f8,f5 available
+ fadds %f5, M14, %f5 ! FGA Group f9 available
+ fadds %f6, M15, %f6 ! FGA Group f10,f6 available
+ fadds %f3, %f7, %f3 ! FGA Group f3 available
+ st %f3, [%g2 + 0x00] ! LSU
+ fadds %f4, %f8, %f4 ! FGA Group f4 available
+ st %f4, [%g2 + 0x04] ! LSU
+ fadds %f5, %f9, %f5 ! FGA Group f5 available
+ st %f5, [%g2 + 0x08] ! LSU
+ fadds %f6, %f10, %f6 ! FGA Group f6 available
+ st %f6, [%g2 + 0x0c] ! LSU
+ cmp %o1, %g3 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x10, %g2 ! IEU0 Group
+2:
+ ba __set_v4f_4
+ nop
+
+ .globl _mesa_sparc_transform_points3_identity
+_mesa_sparc_transform_points3_identity:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ cmp %g3, 0
+ st %g3, [%o0 + V4F_COUNT]
+ be 2f
+ clr %o1
+
+1: ld [%g1 + 0x00], %f0
+ ld [%g1 + 0x04], %f1
+ ld [%g1 + 0x08], %f2
+ add %o1, 1, %o1
+ add %g1, %o5, %g1
+ cmp %o1, %g3
+ st %f0, [%g2 + 0x00]
+ st %f1, [%g2 + 0x04]
+ st %f2, [%g2 + 0x08]
+ bne 1b
+ add %g2, 0x10, %g2
+2:
+ ba __set_v4f_3
+ nop
+
+ .globl _mesa_sparc_transform_points3_2d
+_mesa_sparc_transform_points3_2d:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_1_4_5_12_13(%o1)
+
+ cmp %g3, 0
+ st %g3, [%o0 + V4F_COUNT]
+ be 2f
+ clr %o1
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ ld [%g1 + 0x08], %f2 ! LSU Group
+ add %o1, 1, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f3 ! FGM
+ fmuls %f0, M1, %f4 ! FGM Group
+ fmuls %f1, M4, %f6 ! FGM Group
+ fmuls %f1, M5, %f7 ! FGM Group
+ fadds %f3, M12, %f3 ! FGA Group f3 available
+ fadds %f4, M13, %f4 ! FGA Group f4 available
+ fadds %f3, %f6, %f3 ! FGA Group f6 available
+ st %f3, [%g2 + 0x00] ! LSU
+ fadds %f4, %f7, %f4 ! FGA Group f7 available
+ st %f4, [%g2 + 0x04] ! LSU
+ st %f2, [%g2 + 0x08] ! LSU Group
+ cmp %o1, %g3 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x10, %g2 ! IEU0 Group
+2:
+ ba __set_v4f_3
+ nop
+
+ .globl _mesa_sparc_transform_points3_2d_no_rot
+_mesa_sparc_transform_points3_2d_no_rot:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_5_12_13(%o1)
+
+ cmp %g3, 0
+ st %g3, [%o0 + V4F_COUNT]
+ be 2f
+ clr %o1
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ ld [%g1 + 0x08], %f2 ! LSU Group
+ add %o1, 1, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f3 ! FGM
+ fmuls %f1, M5, %f4 ! FGM Group
+ st %f2, [%g2 + 0x08] ! LSU
+ fadds %f3, M12, %f3 ! FGA Group
+ st %f3, [%g2 + 0x00] ! LSU
+ fadds %f4, M13, %f4 ! FGA Group
+ st %f4, [%g2 + 0x04] ! LSU
+ cmp %o1, %g3 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x10, %g2 ! IEU0 Group
+2:
+ ba __set_v4f_3
+ nop
+
+ .globl _mesa_sparc_transform_points3_3d
+_mesa_sparc_transform_points3_3d:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_1_2_4_5_6_8_9_10_12_13_14(%o1)
+
+ cmp %g3, 0
+ st %g3, [%o0 + V4F_COUNT]
+ be 2f
+ clr %o1
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ ld [%g1 + 0x08], %f2 ! LSU Group
+ add %o1, 1, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f3 ! FGM
+ fmuls %f1, M4, %f6 ! FGM Group
+ fmuls %f0, M1, %f4 ! FGM Group
+ fmuls %f1, M5, %f7 ! FGM Group
+ fmuls %f0, M2, %f5 ! FGM Group f3 available
+ fmuls %f1, M6, %f8 ! FGM Group f6 available
+ fadds %f3, %f6, %f3 ! FGA
+ fmuls %f2, M8, %f9 ! FGM Group f4 available
+ fmuls %f2, M9, %f10 ! FGM Group f7 available
+ fadds %f4, %f7, %f4 ! FGA
+ fmuls %f2, M10, %f11 ! FGM Group f5 available
+ fadds %f5, %f8, %f5 ! FGA Group f8, f3 available
+ fadds %f3, %f9, %f3 ! FGA Group f9 available
+ fadds %f4, %f10, %f4 ! FGA Group f10, f4 available
+ fadds %f5, %f11, %f5 ! FGA Group stall, f11, f5 available
+ fadds %f3, M12, %f3 ! FGA Group f3 available
+ st %f3, [%g2 + 0x00] ! LSU
+ fadds %f4, M13, %f4 ! FGA Group f4 available
+ st %f4, [%g2 + 0x04] ! LSU
+ fadds %f5, M14, %f5 ! FGA Group f5 available
+ st %f5, [%g2 + 0x08] ! LSU
+ cmp %o1, %g3 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x10, %g2 ! IEU0 Group
+2:
+ ba __set_v4f_3
+ nop
+
+ .globl _mesa_sparc_transform_points3_3d_no_rot
+_mesa_sparc_transform_points3_3d_no_rot:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_5_10_12_13_14(%o1)
+
+ cmp %g3, 0
+ st %g3, [%o0 + V4F_COUNT]
+ be 2f
+ clr %o1
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ ld [%g1 + 0x08], %f2 ! LSU Group
+ add %o1, 1, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ cmp %o1, %g3 ! IEU1 Group
+ fmuls %f0, M0, %f3 ! FGM
+ fmuls %f1, M5, %f4 ! FGM Group
+ fmuls %f2, M10, %f5 ! FGM Group
+ fadds %f3, M12, %f3 ! FGA Group, stall, f3 available
+ st %f3, [%g2 + 0x00] ! LSU
+ fadds %f4, M13, %f4 ! FGA Group, f4 available
+ st %f4, [%g2 + 0x04] ! LSU
+ fadds %f5, M14, %f5 ! FGA Group, f5 available
+ st %f5, [%g2 + 0x08] ! LEU
+ bne 1b ! CTI
+ add %g2, 0x10, %g2 ! IEU0 Group
+2:
+ ba __set_v4f_3
+ nop
+
+ .globl _mesa_sparc_transform_points3_perspective
+_mesa_sparc_transform_points3_perspective:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_5_8_9_10_14(%o1)
+
+ cmp %g3, 0
+ st %g3, [%o0 + V4F_COUNT]
+ be 2f
+ clr %o1
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ ld [%g1 + 0x08], %f2 ! LSU Group
+ add %o1, 1, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f3 ! FGM
+ fmuls %f2, M8, %f6 ! FGM Group
+ fmuls %f1, M5, %f4 ! FGM Group
+ fmuls %f2, M9, %f7 ! FGM Group
+ fmuls %f2, M10, %f5 ! FGM Group f3 available
+ fadds %f3, %f6, %f3 ! FGA Group f6 available
+ st %f3, [%g2 + 0x00] ! LSU
+ fadds %f4, %f7, %f4 ! FGA Group stall, f4, f7 available
+ st %f4, [%g2 + 0x04] ! LSU
+ fadds %f5, M14, %f5 ! FGA Group
+ st %f5, [%g2 + 0x08] ! LSU
+ fnegs %f2, %f6 ! FGA Group
+ st %f6, [%g2 + 0x0c] ! LSU
+ cmp %o1, %g3 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x10, %g2 ! IEU0 Group
+2:
+ ba __set_v4f_4
+ nop
+
+ .globl _mesa_sparc_transform_points4_general
+_mesa_sparc_transform_points4_general:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_1_2_3_4_5_6_7_8_9_10_11_12_13_14_15(%o1)
+
+ cmp %g3, 0
+ st %g3, [%o0 + V4F_COUNT]
+ be 2f
+ clr %o1
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ ld [%g1 + 0x08], %f2 ! LSU Group
+ ld [%g1 + 0x0c], %f3 ! LSU Group
+ add %o1, 1, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f4 ! FGM Group
+ fmuls %f1, M4, %f8 ! FGM Group
+ fmuls %f0, M1, %f5 ! FGM Group
+ fmuls %f1, M5, %f9 ! FGM Group
+ fmuls %f0, M2, %f6 ! FGM Group f4 available
+ fmuls %f1, M6, %f10 ! FGM Group f8 available
+ fadds %f4, %f8, %f4 ! FGA
+ fmuls %f0, M3, %f7 ! FGM Group f5 available
+ fmuls %f1, M7, %f11 ! FGM Group f9 available
+ fadds %f5, %f9, %f5 ! FGA
+ fmuls %f2, M8, %f12 ! FGM Group f6 available
+ fmuls %f2, M9, %f13 ! FGM Group f10, f4 available
+ fadds %f6, %f10, %f6 ! FGA
+ fmuls %f2, M10, %f14 ! FGM Group f7 available
+ fmuls %f2, M11, %f15 ! FGM Group f11, f5 available
+ fadds %f7, %f11, %f7 ! FGA
+ fmuls %f3, M12, %f8 ! FGM Group f12 available
+ fadds %f4, %f12, %f4 ! FGA
+ fmuls %f3, M13, %f9 ! FGM Group f13, f6 available
+ fadds %f5, %f13, %f5 ! FGA
+ fmuls %f3, M14, %f10 ! FGM Group f14 available
+ fadds %f6, %f14, %f6 ! FGA
+ fmuls %f3, M15, %f11 ! FGM Group f15, f7 available
+ fadds %f7, %f15, %f7 ! FGA
+ fadds %f4, %f8, %f4 ! FGA Group f8, f4 available
+ st %f4, [%g2 + 0x00] ! LSU
+ fadds %f5, %f9, %f5 ! FGA Group f9, f5 available
+ st %f5, [%g2 + 0x04] ! LSU
+ fadds %f6, %f10, %f6 ! FGA Group f10, f6 available
+ st %f6, [%g2 + 0x08] ! LSU
+ fadds %f7, %f11, %f7 ! FGA Group f11, f7 available
+ st %f7, [%g2 + 0x0c] ! LSU
+ cmp %o1, %g3 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x10, %g2 ! IEU0 Group
+2:
+ ba __set_v4f_4
+ nop
+
+ .globl _mesa_sparc_transform_points4_identity
+_mesa_sparc_transform_points4_identity:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ cmp %g3, 0
+ st %g3, [%o0 + V4F_COUNT]
+ be 2f
+ clr %o1
+
+1: ld [%g1 + 0x00], %f0
+ ld [%g1 + 0x04], %f1
+ ld [%g1 + 0x08], %f2
+ add %o1, 1, %o1
+ ld [%g1 + 0x0c], %f3
+ add %g1, %o5, %g1
+ st %f0, [%g2 + 0x00]
+ st %f1, [%g2 + 0x04]
+ st %f2, [%g2 + 0x08]
+ cmp %o1, %g3
+ st %f3, [%g2 + 0x0c]
+ bne 1b
+ add %g2, 0x10, %g2
+2:
+ ba __set_v4f_4
+ nop
+
+ .globl _mesa_sparc_transform_points4_2d
+_mesa_sparc_transform_points4_2d:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_1_4_5_12_13(%o1)
+
+ cmp %g3, 0
+ st %g3, [%o0 + V4F_COUNT]
+ be 2f
+ clr %o1
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ ld [%g1 + 0x08], %f2 ! LSU Group
+ ld [%g1 + 0x0c], %f3 ! LSU Group
+ add %o1, 1, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f4 ! FGM
+ fmuls %f1, M4, %f8 ! FGM Group
+ fmuls %f0, M1, %f5 ! FGM Group
+ fmuls %f1, M5, %f9 ! FGM Group f4 available
+ fmuls %f3, M12, %f12 ! FGM Group
+ fmuls %f3, M13, %f13 ! FGM Group f8 available
+ fadds %f4, %f8, %f4 ! FGA
+ fadds %f5, %f9, %f5 ! FGA Group stall, f5, f9 available
+ fadds %f4, %f12, %f4 ! FGA Group 2 cycle stall, f4, f12, f13 avail
+ st %f4, [%g2 + 0x00] ! LSU
+ fadds %f5, %f13, %f5 ! FGA Group f5 available
+ st %f5, [%g2 + 0x04] ! LSU
+ st %f2, [%g2 + 0x08] ! LSU Group
+ st %f3, [%g2 + 0x0c] ! LSU Group
+ cmp %o1, %g3 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x10, %g2 ! IEU0 Group
+2:
+ ba __set_v4f_4
+ nop
+
+ .globl _mesa_sparc_transform_points4_2d_no_rot
+_mesa_sparc_transform_points4_2d_no_rot:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_1_4_5_12_13(%o1)
+
+ cmp %g3, 0
+ st %g3, [%o0 + V4F_COUNT]
+ be 2f
+ clr %o1
+
+1: ld [%g1 + 0x00], %f0
+ ld [%g1 + 0x04], %f1
+ ld [%g1 + 0x08], %f2
+ ld [%g1 + 0x0c], %f3
+ add %o1, 1, %o1
+ add %g1, %o5, %g1
+ fmuls %f0, M0, %f4
+ fmuls %f3, M12, %f8
+ fmuls %f1, M5, %f5
+ fmuls %f3, M13, %f9
+ fadds %f4, %f8, %f4
+ st %f4, [%g2 + 0x00]
+ fadds %f5, %f9, %f5
+ st %f5, [%g2 + 0x04]
+ st %f2, [%g2 + 0x08]
+ st %f3, [%g2 + 0x0c]
+ cmp %o1, %g3
+ bne 1b
+ add %g2, 0x10, %g2
+2:
+ ba __set_v4f_4
+ nop
+
+ .globl _mesa_sparc_transform_points4_3d
+_mesa_sparc_transform_points4_3d:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_1_2_4_5_6_8_9_10_12_13_14(%o1)
+
+ cmp %g3, 0
+ st %g3, [%o0 + V4F_COUNT]
+ be 2f
+ clr %o1
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ ld [%g1 + 0x08], %f2 ! LSU Group
+ ld [%g1 + 0x0c], %f3 ! LSU Group
+ add %o1, 1, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f4 ! FGM
+ fmuls %f1, M4, %f7 ! FGM Group
+ fmuls %f0, M1, %f5 ! FGM Group
+ fmuls %f1, M5, %f8 ! FGM Group
+ fmuls %f0, M2, %f6 ! FGM Group f4 available
+ fmuls %f1, M6, %f9 ! FGM Group f7 available
+ fadds %f4, %f7, %f4 ! FGA
+ fmuls %f2, M8, %f10 ! FGM Group f5 available
+ fmuls %f2, M9, %f11 ! FGM Group f8 available
+ fadds %f5, %f8, %f5 ! FGA
+ fmuls %f2, M10, %f12 ! FGM Group f6 available
+ fmuls %f3, M12, %f13 ! FGM Group f9, f4 available
+ fadds %f6, %f9, %f6 ! FGA
+ fmuls %f3, M13, %f14 ! FGM Group f10 available
+ fadds %f4, %f10, %f4 ! FGA
+ fmuls %f3, M14, %f15 ! FGM Group f11, f5 available
+ fadds %f5, %f11, %f5 ! FGA
+ fadds %f6, %f12, %f6 ! FGA Group stall, f12, f13, f6 available
+ fadds %f4, %f13, %f4 ! FGA Group f14, f4 available
+ st %f4, [%g2 + 0x00] ! LSU
+ fadds %f5, %f14, %f5 ! FGA Group f15, f5 available
+ st %f5, [%g2 + 0x04] ! LSU
+ fadds %f6, %f15, %f6 ! FGA Group f6 available
+ st %f6, [%g2 + 0x08] ! LSU
+ st %f3, [%g2 + 0x0c] ! LSU Group
+ cmp %o1, %g3 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x10, %g2 ! IEU0 Group
+2:
+ ba __set_v4f_4
+ nop
+
+ .globl _mesa_sparc_transform_points4_3d_no_rot
+_mesa_sparc_transform_points4_3d_no_rot:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_5_10_12_13_14(%o1)
+
+ cmp %g3, 0
+ st %g3, [%o0 + V4F_COUNT]
+ be 2f
+ clr %o1
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ ld [%g1 + 0x08], %f2 ! LSU Group
+ ld [%g1 + 0x0c], %f3 ! LSU Group
+ add %o1, 1, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f4 ! FGM
+ fmuls %f3, M12, %f7 ! FGM Group
+ fmuls %f1, M5, %f5 ! FGM Group
+ fmuls %f3, M13, %f8 ! FGM Group
+ fmuls %f2, M10, %f6 ! FGM Group f4 available
+ fmuls %f3, M14, %f9 ! FGM Group f7 available
+ fadds %f4, %f7, %f4 ! FGA
+ st %f4, [%g2 + 0x00] ! LSU
+ fadds %f5, %f8, %f5 ! FGA Group stall, f5, f8 available
+ st %f5, [%g2 + 0x04] ! LSU
+ fadds %f6, %f9, %f6 ! FGA Group stall, f6, f9 available
+ st %f6, [%g2 + 0x08] ! LSU
+ st %f3, [%g2 + 0x0c] ! LSU Group
+ cmp %o1, %g3 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x10, %g2 ! IEU0 Group
+2:
+ ba __set_v4f_4
+ nop
+
+ .globl _mesa_sparc_transform_points4_perspective
+_mesa_sparc_transform_points4_perspective:
+ ld [%o2 + V4F_STRIDE], %o5
+ LDPTR [%o2 + V4F_START], %g1
+ LDPTR [%o0 + V4F_START], %g2
+ ld [%o2 + V4F_COUNT], %g3
+
+ LDMATRIX_0_5_8_9_10_14(%o1)
+
+ cmp %g3, 0
+ st %g3, [%o0 + V4F_COUNT]
+ be 2f
+ clr %o1
+
+1: ld [%g1 + 0x00], %f0 ! LSU Group
+ ld [%g1 + 0x04], %f1 ! LSU Group
+ ld [%g1 + 0x08], %f2 ! LSU Group
+ ld [%g1 + 0x0c], %f3 ! LSU Group
+ add %o1, 1, %o1 ! IEU0
+ add %g1, %o5, %g1 ! IEU1
+ fmuls %f0, M0, %f4 ! FGM
+ fmuls %f2, M8, %f7 ! FGM Group
+ fmuls %f1, M5, %f5 ! FGM Group
+ fmuls %f2, M9, %f8 ! FGM Group
+ fmuls %f2, M10, %f6 ! FGM Group f4 available
+ fmuls %f3, M14, %f9 ! FGM Group f7 available
+ fadds %f4, %f7, %f4 ! FGA
+ st %f4, [%g2 + 0x00] ! LSU
+ fadds %f5, %f8, %f5 ! FGA Group stall, f5, f8 available
+ st %f5, [%g2 + 0x04] ! LSU
+ fadds %f6, %f9, %f6 ! FGA Group stall, f6, f9 available
+ st %f6, [%g2 + 0x08] ! LSU
+ fnegs %f2, %f7 ! FGA Group
+ st %f7, [%g2 + 0x0c] ! LSU
+ cmp %o1, %g3 ! IEU1
+ bne 1b ! CTI
+ add %g2, 0x10, %g2 ! IEU0 Group
+2:
+ ba __set_v4f_4
+ nop
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/NOTES b/nx-X11/extras/Mesa/src/mesa/swrast/NOTES
new file mode 100644
index 000000000..f906e41b9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/NOTES
@@ -0,0 +1,55 @@
+INTRODUCTION
+
+Mesa's native software rasterizer. This module provides the fallback
+paths for rasterization operations and states that aren't accelerated
+in hardware drivers, and as the full rasterization engine in software
+drivers.
+
+The swrast module 'stands alone', relying only on interfaces to core
+mesa and it's own driver interface. It knows nothing about the tnl or
+other modules, allowing it to be used for fallback paths in future tnl
+schemes without modification.
+
+As well as providing triangle/line/point rasterization functionality,
+the module provides implementations of the pixel operations
+(ReadPixels, etc), and texture operations (CopyTexSubImage) which may
+be plugged in to the core Mesa driver interface where accelerated
+versions of these operations are unavailable.
+
+
+STATE
+
+To create and destroy the module:
+
+ GLboolean _swrast_CreateContext( GLcontext *ctx );
+ void _swrast_DestroyContext( GLcontext *ctx );
+
+This module tracks state changes internally and maintains derived
+values based on the current state. For this to work, the driver
+ensure the following funciton is called whenever the state changes and
+the swsetup module is 'awake':
+
+ void _swrast_InvalidateState( GLcontext *ctx, GLuint new_state );
+
+There is no explicit call to put the swrast module to sleep.
+
+
+CUSTOMIZATION
+
+ void (*choose_point)( GLcontext * );
+ void (*choose_line)( GLcontext * );
+ void (*choose_triangle)( GLcontext * );
+
+Drivers may add additional triangle/line/point functions to swrast by
+overriding these functions. It is necessary for the driver to be very
+careful that it doesn't return an inappropriate function, eg a
+rasterization function in feedback mode. See the X11 driver for
+examples.
+
+DRIVER INTERFACE
+
+The swrast device driver provides swrast primarily with span- and
+pixel- level interfaces to a framebuffer, with a few additional hooks
+for locking and setting the read buffer.
+
+See the definition of struct swrast_device_driver in swrast.h. \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/descrip.mms b/nx-X11/extras/Mesa/src/mesa/swrast/descrip.mms
new file mode 100644
index 000000000..7b3562770
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/descrip.mms
@@ -0,0 +1,76 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+# Last revision : 23 March 2004
+
+.first
+ define gl [---.include.gl]
+ define math [-.math]
+ define swrast [-.swrast]
+ define array_cache [-.array_cache]
+
+.include [---]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [---.include],[-.main],[-.glapi],[-.shader]
+LIBDIR = [---.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)
+
+SOURCES = s_aaline.c s_aatriangle.c s_accum.c s_alpha.c \
+ s_bitmap.c s_blend.c s_buffers.c s_context.c s_copypix.c s_depth.c \
+ s_drawpix.c s_feedback.c s_fog.c s_imaging.c s_lines.c s_logic.c \
+ s_masking.c s_nvfragprog.c s_pixeltex.c s_points.c s_readpix.c \
+ s_span.c s_stencil.c s_texstore.c s_texture.c s_triangle.c s_zoom.c \
+ s_atifragshader.c
+
+OBJECTS = s_aaline.obj,s_aatriangle.obj,s_accum.obj,s_alpha.obj,\
+ s_bitmap.obj,s_blend.obj,\
+ s_buffers.obj,s_context.obj,s_atifragshader.obj,\
+ s_copypix.obj,s_depth.obj,s_drawpix.obj,s_feedback.obj,s_fog.obj,\
+ s_imaging.obj,s_lines.obj,s_logic.obj,s_masking.obj,s_nvfragprog.obj,\
+ s_pixeltex.obj,s_points.obj,s_readpix.obj,s_span.obj,s_stencil.obj,\
+ s_texstore.obj,s_texture.obj,s_triangle.obj,s_zoom.obj
+
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+ @ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
+
+clean :
+ purge
+ delete *.obj;*
+
+s_atifragshader.obj : s_atifragshader.c
+s_aaline.obj : s_aaline.c
+s_aatriangle.obj : s_aatriangle.c
+s_accum.obj : s_accum.c
+s_alpha.obj : s_alpha.c
+s_bitmap.obj : s_bitmap.c
+s_blend.obj : s_blend.c
+s_buffers.obj : s_buffers.c
+s_context.obj : s_context.c
+s_copypix.obj : s_copypix.c
+s_depth.obj : s_depth.c
+s_drawpix.obj : s_drawpix.c
+s_feedback.obj : s_feedback.c
+s_fog.obj : s_fog.c
+s_imaging.obj : s_imaging.c
+s_lines.obj : s_lines.c
+s_logic.obj : s_logic.c
+s_masking.obj : s_masking.c
+s_nvfragprog.obj : s_nvfragprog.c
+s_pixeltex.obj : s_pixeltex.c
+s_points.obj : s_points.c
+s_readpix.obj : s_readpix.c
+s_span.obj : s_span.c
+s_stencil.obj : s_stencil.c
+s_texstore.obj : s_texstore.c
+s_texture.obj : s_texture.c
+s_triangle.obj : s_triangle.c
+s_zoom.obj : s_zoom.c
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_aaline.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_aaline.c
new file mode 100644
index 000000000..39c51a50f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_aaline.c
@@ -0,0 +1,554 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "macros.h"
+#include "swrast/s_aaline.h"
+#include "swrast/s_context.h"
+#include "swrast/s_span.h"
+#include "swrast/swrast.h"
+#include "mtypes.h"
+
+
+#define SUB_PIXEL 4
+
+
+/*
+ * Info about the AA line we're rendering
+ */
+struct LineInfo
+{
+ GLfloat x0, y0; /* start */
+ GLfloat x1, y1; /* end */
+ GLfloat dx, dy; /* direction vector */
+ GLfloat len; /* length */
+ GLfloat halfWidth; /* half of line width */
+ GLfloat xAdj, yAdj; /* X and Y adjustment for quad corners around line */
+ /* for coverage computation */
+ GLfloat qx0, qy0; /* quad vertices */
+ GLfloat qx1, qy1;
+ GLfloat qx2, qy2;
+ GLfloat qx3, qy3;
+ GLfloat ex0, ey0; /* quad edge vectors */
+ GLfloat ex1, ey1;
+ GLfloat ex2, ey2;
+ GLfloat ex3, ey3;
+
+ /* DO_Z */
+ GLfloat zPlane[4];
+ /* DO_FOG */
+ GLfloat fPlane[4];
+ /* DO_RGBA */
+ GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4];
+ /* DO_INDEX */
+ GLfloat iPlane[4];
+ /* DO_SPEC */
+ GLfloat srPlane[4], sgPlane[4], sbPlane[4];
+ /* DO_TEX or DO_MULTITEX */
+ GLfloat sPlane[MAX_TEXTURE_COORD_UNITS][4];
+ GLfloat tPlane[MAX_TEXTURE_COORD_UNITS][4];
+ GLfloat uPlane[MAX_TEXTURE_COORD_UNITS][4];
+ GLfloat vPlane[MAX_TEXTURE_COORD_UNITS][4];
+ GLfloat lambda[MAX_TEXTURE_COORD_UNITS];
+ GLfloat texWidth[MAX_TEXTURE_COORD_UNITS];
+ GLfloat texHeight[MAX_TEXTURE_COORD_UNITS];
+
+ struct sw_span span;
+};
+
+
+
+/*
+ * Compute the equation of a plane used to interpolate line fragment data
+ * such as color, Z, texture coords, etc.
+ * Input: (x0, y0) and (x1,y1) are the endpoints of the line.
+ * z0, and z1 are the end point values to interpolate.
+ * Output: plane - the plane equation.
+ *
+ * Note: we don't really have enough parameters to specify a plane.
+ * We take the endpoints of the line and compute a plane such that
+ * the cross product of the line vector and the plane normal is
+ * parallel to the projection plane.
+ */
+static void
+compute_plane(GLfloat x0, GLfloat y0, GLfloat x1, GLfloat y1,
+ GLfloat z0, GLfloat z1, GLfloat plane[4])
+{
+#if 0
+ /* original */
+ const GLfloat px = x1 - x0;
+ const GLfloat py = y1 - y0;
+ const GLfloat pz = z1 - z0;
+ const GLfloat qx = -py;
+ const GLfloat qy = px;
+ const GLfloat qz = 0;
+ const GLfloat a = py * qz - pz * qy;
+ const GLfloat b = pz * qx - px * qz;
+ const GLfloat c = px * qy - py * qx;
+ const GLfloat d = -(a * x0 + b * y0 + c * z0);
+ plane[0] = a;
+ plane[1] = b;
+ plane[2] = c;
+ plane[3] = d;
+#else
+ /* simplified */
+ const GLfloat px = x1 - x0;
+ const GLfloat py = y1 - y0;
+ const GLfloat pz = z0 - z1;
+ const GLfloat a = pz * px;
+ const GLfloat b = pz * py;
+ const GLfloat c = px * px + py * py;
+ const GLfloat d = -(a * x0 + b * y0 + c * z0);
+ if (a == 0.0 && b == 0.0 && c == 0.0 && d == 0.0) {
+ plane[0] = 0.0;
+ plane[1] = 0.0;
+ plane[2] = 1.0;
+ plane[3] = 0.0;
+ }
+ else {
+ plane[0] = a;
+ plane[1] = b;
+ plane[2] = c;
+ plane[3] = d;
+ }
+#endif
+}
+
+
+static INLINE void
+constant_plane(GLfloat value, GLfloat plane[4])
+{
+ plane[0] = 0.0;
+ plane[1] = 0.0;
+ plane[2] = -1.0;
+ plane[3] = value;
+}
+
+
+static INLINE GLfloat
+solve_plane(GLfloat x, GLfloat y, const GLfloat plane[4])
+{
+ const GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2];
+ return z;
+}
+
+#define SOLVE_PLANE(X, Y, PLANE) \
+ ((PLANE[3] + PLANE[0] * (X) + PLANE[1] * (Y)) / -PLANE[2])
+
+
+/*
+ * Return 1 / solve_plane().
+ */
+static INLINE GLfloat
+solve_plane_recip(GLfloat x, GLfloat y, const GLfloat plane[4])
+{
+ const GLfloat denom = plane[3] + plane[0] * x + plane[1] * y;
+ if (denom == 0.0)
+ return 0.0;
+ else
+ return -plane[2] / denom;
+}
+
+
+/*
+ * Solve plane and return clamped GLchan value.
+ */
+static INLINE GLchan
+solve_plane_chan(GLfloat x, GLfloat y, const GLfloat plane[4])
+{
+ const GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2];
+#if CHAN_TYPE == GL_FLOAT
+ return CLAMP(z, 0.0F, CHAN_MAXF);
+#else
+ if (z < 0)
+ return 0;
+ else if (z > CHAN_MAX)
+ return CHAN_MAX;
+ return (GLchan) IROUND_POS(z);
+#endif
+}
+
+
+/*
+ * Compute mipmap level of detail.
+ */
+static INLINE GLfloat
+compute_lambda(const GLfloat sPlane[4], const GLfloat tPlane[4],
+ GLfloat invQ, GLfloat width, GLfloat height)
+{
+ GLfloat dudx = sPlane[0] / sPlane[2] * invQ * width;
+ GLfloat dudy = sPlane[1] / sPlane[2] * invQ * width;
+ GLfloat dvdx = tPlane[0] / tPlane[2] * invQ * height;
+ GLfloat dvdy = tPlane[1] / tPlane[2] * invQ * height;
+ GLfloat r1 = dudx * dudx + dudy * dudy;
+ GLfloat r2 = dvdx * dvdx + dvdy * dvdy;
+ GLfloat rho2 = r1 + r2;
+ /* return log base 2 of rho */
+ if (rho2 == 0.0F)
+ return 0.0;
+ else
+ return (GLfloat) (log(rho2) * 1.442695 * 0.5);/* 1.442695 = 1/log(2) */
+}
+
+
+
+
+/*
+ * Fill in the samples[] array with the (x,y) subpixel positions of
+ * xSamples * ySamples sample positions.
+ * Note that the four corner samples are put into the first four
+ * positions of the array. This allows us to optimize for the common
+ * case of all samples being inside the polygon.
+ */
+static void
+make_sample_table(GLint xSamples, GLint ySamples, GLfloat samples[][2])
+{
+ const GLfloat dx = 1.0F / (GLfloat) xSamples;
+ const GLfloat dy = 1.0F / (GLfloat) ySamples;
+ GLint x, y;
+ GLint i;
+
+ i = 4;
+ for (x = 0; x < xSamples; x++) {
+ for (y = 0; y < ySamples; y++) {
+ GLint j;
+ if (x == 0 && y == 0) {
+ /* lower left */
+ j = 0;
+ }
+ else if (x == xSamples - 1 && y == 0) {
+ /* lower right */
+ j = 1;
+ }
+ else if (x == 0 && y == ySamples - 1) {
+ /* upper left */
+ j = 2;
+ }
+ else if (x == xSamples - 1 && y == ySamples - 1) {
+ /* upper right */
+ j = 3;
+ }
+ else {
+ j = i++;
+ }
+ samples[j][0] = x * dx + 0.5F * dx;
+ samples[j][1] = y * dy + 0.5F * dy;
+ }
+ }
+}
+
+
+
+/*
+ * Compute how much of the given pixel's area is inside the rectangle
+ * defined by vertices v0, v1, v2, v3.
+ * Vertices MUST be specified in counter-clockwise order.
+ * Return: coverage in [0, 1].
+ */
+static GLfloat
+compute_coveragef(const struct LineInfo *info,
+ GLint winx, GLint winy)
+{
+ static GLfloat samples[SUB_PIXEL * SUB_PIXEL][2];
+ static GLboolean haveSamples = GL_FALSE;
+ const GLfloat x = (GLfloat) winx;
+ const GLfloat y = (GLfloat) winy;
+ GLint stop = 4, i;
+ GLfloat insideCount = SUB_PIXEL * SUB_PIXEL;
+
+ if (!haveSamples) {
+ make_sample_table(SUB_PIXEL, SUB_PIXEL, samples);
+ haveSamples = GL_TRUE;
+ }
+
+#if 0 /*DEBUG*/
+ {
+ const GLfloat area = dx0 * dy1 - dx1 * dy0;
+ assert(area >= 0.0);
+ }
+#endif
+
+ for (i = 0; i < stop; i++) {
+ const GLfloat sx = x + samples[i][0];
+ const GLfloat sy = y + samples[i][1];
+ const GLfloat fx0 = sx - info->qx0;
+ const GLfloat fy0 = sy - info->qy0;
+ const GLfloat fx1 = sx - info->qx1;
+ const GLfloat fy1 = sy - info->qy1;
+ const GLfloat fx2 = sx - info->qx2;
+ const GLfloat fy2 = sy - info->qy2;
+ const GLfloat fx3 = sx - info->qx3;
+ const GLfloat fy3 = sy - info->qy3;
+ /* cross product determines if sample is inside or outside each edge */
+ GLfloat cross0 = (info->ex0 * fy0 - info->ey0 * fx0);
+ GLfloat cross1 = (info->ex1 * fy1 - info->ey1 * fx1);
+ GLfloat cross2 = (info->ex2 * fy2 - info->ey2 * fx2);
+ GLfloat cross3 = (info->ex3 * fy3 - info->ey3 * fx3);
+ /* Check if the sample is exactly on an edge. If so, let cross be a
+ * positive or negative value depending on the direction of the edge.
+ */
+ if (cross0 == 0.0F)
+ cross0 = info->ex0 + info->ey0;
+ if (cross1 == 0.0F)
+ cross1 = info->ex1 + info->ey1;
+ if (cross2 == 0.0F)
+ cross2 = info->ex2 + info->ey2;
+ if (cross3 == 0.0F)
+ cross3 = info->ex3 + info->ey3;
+ if (cross0 < 0.0F || cross1 < 0.0F || cross2 < 0.0F || cross3 < 0.0F) {
+ /* point is outside quadrilateral */
+ insideCount -= 1.0F;
+ stop = SUB_PIXEL * SUB_PIXEL;
+ }
+ }
+ if (stop == 4)
+ return 1.0F;
+ else
+ return insideCount * (1.0F / (SUB_PIXEL * SUB_PIXEL));
+}
+
+
+/**
+ * Compute coverage value for color index mode.
+ * XXX this may not be quite correct.
+ * \return coverage in [0,15].
+ */
+static GLfloat
+compute_coveragei(const struct LineInfo *info,
+ GLint winx, GLint winy)
+{
+ return compute_coveragef(info, winx, winy) * 15.0F;
+}
+
+
+
+typedef void (*plot_func)(GLcontext *ctx, struct LineInfo *line,
+ int ix, int iy);
+
+
+
+/*
+ * Draw an AA line segment (called many times per line when stippling)
+ */
+static void
+segment(GLcontext *ctx,
+ struct LineInfo *line,
+ plot_func plot,
+ GLfloat t0, GLfloat t1)
+{
+ const GLfloat absDx = (line->dx < 0.0F) ? -line->dx : line->dx;
+ const GLfloat absDy = (line->dy < 0.0F) ? -line->dy : line->dy;
+ /* compute the actual segment's endpoints */
+ const GLfloat x0 = line->x0 + t0 * line->dx;
+ const GLfloat y0 = line->y0 + t0 * line->dy;
+ const GLfloat x1 = line->x0 + t1 * line->dx;
+ const GLfloat y1 = line->y0 + t1 * line->dy;
+
+ /* compute vertices of the line-aligned quadrilateral */
+ line->qx0 = x0 - line->yAdj;
+ line->qy0 = y0 + line->xAdj;
+ line->qx1 = x0 + line->yAdj;
+ line->qy1 = y0 - line->xAdj;
+ line->qx2 = x1 + line->yAdj;
+ line->qy2 = y1 - line->xAdj;
+ line->qx3 = x1 - line->yAdj;
+ line->qy3 = y1 + line->xAdj;
+ /* compute the quad's edge vectors (for coverage calc) */
+ line->ex0 = line->qx1 - line->qx0;
+ line->ey0 = line->qy1 - line->qy0;
+ line->ex1 = line->qx2 - line->qx1;
+ line->ey1 = line->qy2 - line->qy1;
+ line->ex2 = line->qx3 - line->qx2;
+ line->ey2 = line->qy3 - line->qy2;
+ line->ex3 = line->qx0 - line->qx3;
+ line->ey3 = line->qy0 - line->qy3;
+
+ if (absDx > absDy) {
+ /* X-major line */
+ GLfloat dydx = line->dy / line->dx;
+ GLfloat xLeft, xRight, yBot, yTop;
+ GLint ix, ixRight;
+ if (x0 < x1) {
+ xLeft = x0 - line->halfWidth;
+ xRight = x1 + line->halfWidth;
+ if (line->dy >= 0.0) {
+ yBot = y0 - 3.0F * line->halfWidth;
+ yTop = y0 + line->halfWidth;
+ }
+ else {
+ yBot = y0 - line->halfWidth;
+ yTop = y0 + 3.0F * line->halfWidth;
+ }
+ }
+ else {
+ xLeft = x1 - line->halfWidth;
+ xRight = x0 + line->halfWidth;
+ if (line->dy <= 0.0) {
+ yBot = y1 - 3.0F * line->halfWidth;
+ yTop = y1 + line->halfWidth;
+ }
+ else {
+ yBot = y1 - line->halfWidth;
+ yTop = y1 + 3.0F * line->halfWidth;
+ }
+ }
+
+ /* scan along the line, left-to-right */
+ ixRight = (GLint) (xRight + 1.0F);
+
+ /*printf("avg span height: %g\n", yTop - yBot);*/
+ for (ix = (GLint) xLeft; ix < ixRight; ix++) {
+ const GLint iyBot = (GLint) yBot;
+ const GLint iyTop = (GLint) (yTop + 1.0F);
+ GLint iy;
+ /* scan across the line, bottom-to-top */
+ for (iy = iyBot; iy < iyTop; iy++) {
+ (*plot)(ctx, line, ix, iy);
+ }
+ yBot += dydx;
+ yTop += dydx;
+ }
+ }
+ else {
+ /* Y-major line */
+ GLfloat dxdy = line->dx / line->dy;
+ GLfloat yBot, yTop, xLeft, xRight;
+ GLint iy, iyTop;
+ if (y0 < y1) {
+ yBot = y0 - line->halfWidth;
+ yTop = y1 + line->halfWidth;
+ if (line->dx >= 0.0) {
+ xLeft = x0 - 3.0F * line->halfWidth;
+ xRight = x0 + line->halfWidth;
+ }
+ else {
+ xLeft = x0 - line->halfWidth;
+ xRight = x0 + 3.0F * line->halfWidth;
+ }
+ }
+ else {
+ yBot = y1 - line->halfWidth;
+ yTop = y0 + line->halfWidth;
+ if (line->dx <= 0.0) {
+ xLeft = x1 - 3.0F * line->halfWidth;
+ xRight = x1 + line->halfWidth;
+ }
+ else {
+ xLeft = x1 - line->halfWidth;
+ xRight = x1 + 3.0F * line->halfWidth;
+ }
+ }
+
+ /* scan along the line, bottom-to-top */
+ iyTop = (GLint) (yTop + 1.0F);
+
+ /*printf("avg span width: %g\n", xRight - xLeft);*/
+ for (iy = (GLint) yBot; iy < iyTop; iy++) {
+ const GLint ixLeft = (GLint) xLeft;
+ const GLint ixRight = (GLint) (xRight + 1.0F);
+ GLint ix;
+ /* scan across the line, left-to-right */
+ for (ix = ixLeft; ix < ixRight; ix++) {
+ (*plot)(ctx, line, ix, iy);
+ }
+ xLeft += dxdy;
+ xRight += dxdy;
+ }
+ }
+}
+
+
+#define NAME(x) aa_ci_##x
+#define DO_Z
+#define DO_FOG
+#define DO_INDEX
+#include "s_aalinetemp.h"
+
+
+#define NAME(x) aa_rgba_##x
+#define DO_Z
+#define DO_FOG
+#define DO_RGBA
+#include "s_aalinetemp.h"
+
+
+#define NAME(x) aa_tex_rgba_##x
+#define DO_Z
+#define DO_FOG
+#define DO_RGBA
+#define DO_TEX
+#include "s_aalinetemp.h"
+
+
+#define NAME(x) aa_multitex_rgba_##x
+#define DO_Z
+#define DO_FOG
+#define DO_RGBA
+#define DO_MULTITEX
+#include "s_aalinetemp.h"
+
+
+#define NAME(x) aa_multitex_spec_##x
+#define DO_Z
+#define DO_FOG
+#define DO_RGBA
+#define DO_MULTITEX
+#define DO_SPEC
+#include "s_aalinetemp.h"
+
+
+
+void
+_swrast_choose_aa_line_function(GLcontext *ctx)
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ ASSERT(ctx->Line.SmoothFlag);
+
+ if (ctx->Visual.rgbMode) {
+ /* RGBA */
+ if (ctx->Texture._EnabledCoordUnits != 0) {
+ if (ctx->Texture._EnabledCoordUnits > 1) {
+ /* Multitextured! */
+ if (ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR ||
+ ctx->Fog.ColorSumEnabled)
+ swrast->Line = aa_multitex_spec_line;
+ else
+ swrast->Line = aa_multitex_rgba_line;
+ }
+ else {
+ swrast->Line = aa_tex_rgba_line;
+ }
+ }
+ else {
+ swrast->Line = aa_rgba_line;
+ }
+ }
+ else {
+ /* Color Index */
+ swrast->Line = aa_ci_line;
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_aaline.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_aaline.h
new file mode 100644
index 000000000..41e7e5fd4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_aaline.h
@@ -0,0 +1,39 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_AALINE_H
+#define S_AALINE_H
+
+
+#include "mtypes.h"
+#include "swrast.h"
+
+
+extern void
+_swrast_choose_aa_line_function(GLcontext *ctx);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_aalinetemp.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_aalinetemp.h
new file mode 100644
index 000000000..4a1e1ebda
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_aalinetemp.h
@@ -0,0 +1,329 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+/*
+ * Antialiased line template.
+ */
+
+
+/*
+ * Function to render each fragment in the AA line.
+ * \param ix - integer fragment window X coordiante
+ * \param iy - integer fragment window Y coordiante
+ */
+static void
+NAME(plot)(GLcontext *ctx, struct LineInfo *line, int ix, int iy)
+{
+ const GLfloat fx = (GLfloat) ix;
+ const GLfloat fy = (GLfloat) iy;
+#ifdef DO_INDEX
+ const GLfloat coverage = compute_coveragei(line, ix, iy);
+#else
+ const GLfloat coverage = compute_coveragef(line, ix, iy);
+#endif
+ const GLuint i = line->span.end;
+
+ if (coverage == 0.0)
+ return;
+
+ line->span.end++;
+ line->span.array->coverage[i] = coverage;
+ line->span.array->x[i] = ix;
+ line->span.array->y[i] = iy;
+
+ /*
+ * Compute Z, color, texture coords, fog for the fragment by
+ * solving the plane equations at (ix,iy).
+ */
+#ifdef DO_Z
+ line->span.array->z[i] = (GLdepth) IROUND(solve_plane(fx, fy, line->zPlane));
+#endif
+#ifdef DO_FOG
+ line->span.array->fog[i] = solve_plane(fx, fy, line->fPlane);
+#endif
+#ifdef DO_RGBA
+ line->span.array->rgba[i][RCOMP] = solve_plane_chan(fx, fy, line->rPlane);
+ line->span.array->rgba[i][GCOMP] = solve_plane_chan(fx, fy, line->gPlane);
+ line->span.array->rgba[i][BCOMP] = solve_plane_chan(fx, fy, line->bPlane);
+ line->span.array->rgba[i][ACOMP] = solve_plane_chan(fx, fy, line->aPlane);
+#endif
+#ifdef DO_INDEX
+ line->span.array->index[i] = (GLint) solve_plane(fx, fy, line->iPlane);
+#endif
+#ifdef DO_SPEC
+ line->span.array->spec[i][RCOMP] = solve_plane_chan(fx, fy, line->srPlane);
+ line->span.array->spec[i][GCOMP] = solve_plane_chan(fx, fy, line->sgPlane);
+ line->span.array->spec[i][BCOMP] = solve_plane_chan(fx, fy, line->sbPlane);
+#endif
+#ifdef DO_TEX
+ {
+ GLfloat invQ;
+ if (ctx->FragmentProgram._Active) {
+ invQ = 1.0F;
+ }
+ else {
+ invQ = solve_plane_recip(fx, fy, line->vPlane[0]);
+ }
+ line->span.array->texcoords[0][i][0] = solve_plane(fx, fy, line->sPlane[0]) * invQ;
+ line->span.array->texcoords[0][i][1] = solve_plane(fx, fy, line->tPlane[0]) * invQ;
+ line->span.array->texcoords[0][i][2] = solve_plane(fx, fy, line->uPlane[0]) * invQ;
+ line->span.array->lambda[0][i] = compute_lambda(line->sPlane[0],
+ line->tPlane[0], invQ,
+ line->texWidth[0],
+ line->texHeight[0]);
+ }
+#elif defined(DO_MULTITEX)
+ {
+ GLuint unit;
+ for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
+ if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+ GLfloat invQ;
+ if (ctx->FragmentProgram._Active) {
+ invQ = 1.0F;
+ }
+ else {
+ invQ = solve_plane_recip(fx, fy, line->vPlane[unit]);
+ }
+ line->span.array->texcoords[unit][i][0] = solve_plane(fx, fy, line->sPlane[unit]) * invQ;
+ line->span.array->texcoords[unit][i][1] = solve_plane(fx, fy, line->tPlane[unit]) * invQ;
+ line->span.array->texcoords[unit][i][2] = solve_plane(fx, fy, line->uPlane[unit]) * invQ;
+ line->span.array->lambda[unit][i] = compute_lambda(line->sPlane[unit],
+ line->tPlane[unit], invQ,
+ line->texWidth[unit], line->texHeight[unit]);
+ }
+ }
+ }
+#endif
+
+ if (line->span.end == MAX_WIDTH) {
+#if defined(DO_RGBA)
+ _swrast_write_rgba_span(ctx, &(line->span));
+#else
+ _swrast_write_index_span(ctx, &(line->span));
+#endif
+ line->span.end = 0; /* reset counter */
+ }
+}
+
+
+
+/*
+ * Line setup
+ */
+static void
+NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1)
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLfloat tStart, tEnd; /* segment start, end along line length */
+ GLboolean inSegment;
+ GLint iLen, i;
+
+ /* Init the LineInfo struct */
+ struct LineInfo line;
+ line.x0 = v0->win[0];
+ line.y0 = v0->win[1];
+ line.x1 = v1->win[0];
+ line.y1 = v1->win[1];
+ line.dx = line.x1 - line.x0;
+ line.dy = line.y1 - line.y0;
+ line.len = SQRTF(line.dx * line.dx + line.dy * line.dy);
+ line.halfWidth = 0.5F * ctx->Line._Width;
+
+ if (line.len == 0.0 || IS_INF_OR_NAN(line.len))
+ return;
+
+ INIT_SPAN(line.span, GL_LINE, 0, 0, SPAN_XY | SPAN_COVERAGE);
+
+ line.xAdj = line.dx / line.len * line.halfWidth;
+ line.yAdj = line.dy / line.len * line.halfWidth;
+
+#ifdef DO_Z
+ line.span.arrayMask |= SPAN_Z;
+ compute_plane(line.x0, line.y0, line.x1, line.y1,
+ v0->win[2], v1->win[2], line.zPlane);
+#endif
+#ifdef DO_FOG
+ line.span.arrayMask |= SPAN_FOG;
+ compute_plane(line.x0, line.y0, line.x1, line.y1,
+ v0->fog, v1->fog, line.fPlane);
+#endif
+#ifdef DO_RGBA
+ line.span.arrayMask |= SPAN_RGBA;
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ compute_plane(line.x0, line.y0, line.x1, line.y1,
+ v0->color[RCOMP], v1->color[RCOMP], line.rPlane);
+ compute_plane(line.x0, line.y0, line.x1, line.y1,
+ v0->color[GCOMP], v1->color[GCOMP], line.gPlane);
+ compute_plane(line.x0, line.y0, line.x1, line.y1,
+ v0->color[BCOMP], v1->color[BCOMP], line.bPlane);
+ compute_plane(line.x0, line.y0, line.x1, line.y1,
+ v0->color[ACOMP], v1->color[ACOMP], line.aPlane);
+ }
+ else {
+ constant_plane(v1->color[RCOMP], line.rPlane);
+ constant_plane(v1->color[GCOMP], line.gPlane);
+ constant_plane(v1->color[BCOMP], line.bPlane);
+ constant_plane(v1->color[ACOMP], line.aPlane);
+ }
+#endif
+#ifdef DO_SPEC
+ line.span.arrayMask |= SPAN_SPEC;
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ compute_plane(line.x0, line.y0, line.x1, line.y1,
+ v0->specular[RCOMP], v1->specular[RCOMP], line.srPlane);
+ compute_plane(line.x0, line.y0, line.x1, line.y1,
+ v0->specular[GCOMP], v1->specular[GCOMP], line.sgPlane);
+ compute_plane(line.x0, line.y0, line.x1, line.y1,
+ v0->specular[BCOMP], v1->specular[BCOMP], line.sbPlane);
+ }
+ else {
+ constant_plane(v1->specular[RCOMP], line.srPlane);
+ constant_plane(v1->specular[GCOMP], line.sgPlane);
+ constant_plane(v1->specular[BCOMP], line.sbPlane);
+ }
+#endif
+#ifdef DO_INDEX
+ line.span.arrayMask |= SPAN_INDEX;
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ compute_plane(line.x0, line.y0, line.x1, line.y1,
+ v0->index, v1->index, line.iPlane);
+ }
+ else {
+ constant_plane(v1->index, line.iPlane);
+ }
+#endif
+#ifdef DO_TEX
+ {
+ const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current;
+ const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel];
+ const GLfloat invW0 = v0->win[3];
+ const GLfloat invW1 = v1->win[3];
+ const GLfloat s0 = v0->texcoord[0][0] * invW0;
+ const GLfloat s1 = v1->texcoord[0][0] * invW1;
+ const GLfloat t0 = v0->texcoord[0][1] * invW0;
+ const GLfloat t1 = v1->texcoord[0][1] * invW1;
+ const GLfloat r0 = v0->texcoord[0][2] * invW0;
+ const GLfloat r1 = v1->texcoord[0][2] * invW1;
+ const GLfloat q0 = v0->texcoord[0][3] * invW0;
+ const GLfloat q1 = v1->texcoord[0][3] * invW1;
+ line.span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA);
+ compute_plane(line.x0, line.y0, line.x1, line.y1, s0, s1, line.sPlane[0]);
+ compute_plane(line.x0, line.y0, line.x1, line.y1, t0, t1, line.tPlane[0]);
+ compute_plane(line.x0, line.y0, line.x1, line.y1, r0, r1, line.uPlane[0]);
+ compute_plane(line.x0, line.y0, line.x1, line.y1, q0, q1, line.vPlane[0]);
+ line.texWidth[0] = (GLfloat) texImage->Width;
+ line.texHeight[0] = (GLfloat) texImage->Height;
+ }
+#elif defined(DO_MULTITEX)
+ {
+ GLuint u;
+ line.span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA);
+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
+ if (ctx->Texture.Unit[u]._ReallyEnabled) {
+ const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current;
+ const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel];
+ const GLfloat invW0 = v0->win[3];
+ const GLfloat invW1 = v1->win[3];
+ const GLfloat s0 = v0->texcoord[u][0] * invW0;
+ const GLfloat s1 = v1->texcoord[u][0] * invW1;
+ const GLfloat t0 = v0->texcoord[u][1] * invW0;
+ const GLfloat t1 = v1->texcoord[u][1] * invW1;
+ const GLfloat r0 = v0->texcoord[u][2] * invW0;
+ const GLfloat r1 = v1->texcoord[u][2] * invW1;
+ const GLfloat q0 = v0->texcoord[u][3] * invW0;
+ const GLfloat q1 = v1->texcoord[u][3] * invW1;
+ compute_plane(line.x0, line.y0, line.x1, line.y1, s0, s1, line.sPlane[u]);
+ compute_plane(line.x0, line.y0, line.x1, line.y1, t0, t1, line.tPlane[u]);
+ compute_plane(line.x0, line.y0, line.x1, line.y1, r0, r1, line.uPlane[u]);
+ compute_plane(line.x0, line.y0, line.x1, line.y1, q0, q1, line.vPlane[u]);
+ line.texWidth[u] = (GLfloat) texImage->Width;
+ line.texHeight[u] = (GLfloat) texImage->Height;
+ }
+ }
+ }
+#endif
+
+ tStart = tEnd = 0.0;
+ inSegment = GL_FALSE;
+ iLen = (GLint) line.len;
+
+ if (ctx->Line.StippleFlag) {
+ for (i = 0; i < iLen; i++) {
+ const GLuint bit = (swrast->StippleCounter / ctx->Line.StippleFactor) & 0xf;
+ if ((1 << bit) & ctx->Line.StipplePattern) {
+ /* stipple bit is on */
+ const GLfloat t = (GLfloat) i / (GLfloat) line.len;
+ if (!inSegment) {
+ /* start new segment */
+ inSegment = GL_TRUE;
+ tStart = t;
+ }
+ else {
+ /* still in the segment, extend it */
+ tEnd = t;
+ }
+ }
+ else {
+ /* stipple bit is off */
+ if (inSegment && (tEnd > tStart)) {
+ /* draw the segment */
+ segment(ctx, &line, NAME(plot), tStart, tEnd);
+ inSegment = GL_FALSE;
+ }
+ else {
+ /* still between segments, do nothing */
+ }
+ }
+ swrast->StippleCounter++;
+ }
+
+ if (inSegment) {
+ /* draw the final segment of the line */
+ segment(ctx, &line, NAME(plot), tStart, 1.0F);
+ }
+ }
+ else {
+ /* non-stippled */
+ segment(ctx, &line, NAME(plot), 0.0, 1.0);
+ }
+
+#if defined(DO_RGBA)
+ _swrast_write_rgba_span(ctx, &(line.span));
+#else
+ _swrast_write_index_span(ctx, &(line.span));
+#endif
+}
+
+
+
+
+#undef DO_Z
+#undef DO_FOG
+#undef DO_RGBA
+#undef DO_INDEX
+#undef DO_SPEC
+#undef DO_TEX
+#undef DO_MULTITEX
+#undef NAME
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_aatriangle.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_aatriangle.c
new file mode 100644
index 000000000..5509f34c9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_aatriangle.c
@@ -0,0 +1,495 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+/*
+ * Antialiased Triangle rasterizers
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "colormac.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+#include "nvfragprog.h"
+#include "s_aatriangle.h"
+#include "s_context.h"
+#include "s_span.h"
+
+
+/*
+ * Compute coefficients of a plane using the X,Y coords of the v0, v1, v2
+ * vertices and the given Z values.
+ * A point (x,y,z) lies on plane iff a*x+b*y+c*z+d = 0.
+ */
+static INLINE void
+compute_plane(const GLfloat v0[], const GLfloat v1[], const GLfloat v2[],
+ GLfloat z0, GLfloat z1, GLfloat z2, GLfloat plane[4])
+{
+ const GLfloat px = v1[0] - v0[0];
+ const GLfloat py = v1[1] - v0[1];
+ const GLfloat pz = z1 - z0;
+
+ const GLfloat qx = v2[0] - v0[0];
+ const GLfloat qy = v2[1] - v0[1];
+ const GLfloat qz = z2 - z0;
+
+ /* Crossproduct "(a,b,c):= dv1 x dv2" is orthogonal to plane. */
+ const GLfloat a = py * qz - pz * qy;
+ const GLfloat b = pz * qx - px * qz;
+ const GLfloat c = px * qy - py * qx;
+ /* Point on the plane = "r*(a,b,c) + w", with fixed "r" depending
+ on the distance of plane from origin and arbitrary "w" parallel
+ to the plane. */
+ /* The scalar product "(r*(a,b,c)+w)*(a,b,c)" is "r*(a^2+b^2+c^2)",
+ which is equal to "-d" below. */
+ const GLfloat d = -(a * v0[0] + b * v0[1] + c * z0);
+
+ plane[0] = a;
+ plane[1] = b;
+ plane[2] = c;
+ plane[3] = d;
+}
+
+
+/*
+ * Compute coefficients of a plane with a constant Z value.
+ */
+static INLINE void
+constant_plane(GLfloat value, GLfloat plane[4])
+{
+ plane[0] = 0.0;
+ plane[1] = 0.0;
+ plane[2] = -1.0;
+ plane[3] = value;
+}
+
+#define CONSTANT_PLANE(VALUE, PLANE) \
+do { \
+ PLANE[0] = 0.0F; \
+ PLANE[1] = 0.0F; \
+ PLANE[2] = -1.0F; \
+ PLANE[3] = VALUE; \
+} while (0)
+
+
+
+/*
+ * Solve plane equation for Z at (X,Y).
+ */
+static INLINE GLfloat
+solve_plane(GLfloat x, GLfloat y, const GLfloat plane[4])
+{
+ ASSERT(plane[2] != 0.0F);
+ return (plane[3] + plane[0] * x + plane[1] * y) / -plane[2];
+}
+
+
+#define SOLVE_PLANE(X, Y, PLANE) \
+ ((PLANE[3] + PLANE[0] * (X) + PLANE[1] * (Y)) / -PLANE[2])
+
+
+/*
+ * Return 1 / solve_plane().
+ */
+static INLINE GLfloat
+solve_plane_recip(GLfloat x, GLfloat y, const GLfloat plane[4])
+{
+ const GLfloat denom = plane[3] + plane[0] * x + plane[1] * y;
+ if (denom == 0.0F)
+ return 0.0F;
+ else
+ return -plane[2] / denom;
+}
+
+
+/*
+ * Solve plane and return clamped GLchan value.
+ */
+static INLINE GLchan
+solve_plane_chan(GLfloat x, GLfloat y, const GLfloat plane[4])
+{
+ const GLfloat z = (plane[3] + plane[0] * x + plane[1] * y) / -plane[2];
+#if CHAN_TYPE == GL_FLOAT
+ return CLAMP(z, 0.0F, CHAN_MAXF);
+#else
+ if (z < 0)
+ return 0;
+ else if (z > CHAN_MAX)
+ return CHAN_MAX;
+ return (GLchan) IROUND_POS(z);
+#endif
+}
+
+
+
+/*
+ * Compute how much (area) of the given pixel is inside the triangle.
+ * Vertices MUST be specified in counter-clockwise order.
+ * Return: coverage in [0, 1].
+ */
+static GLfloat
+compute_coveragef(const GLfloat v0[3], const GLfloat v1[3],
+ const GLfloat v2[3], GLint winx, GLint winy)
+{
+ /* Given a position [0,3]x[0,3] return the sub-pixel sample position.
+ * Contributed by Ray Tice.
+ *
+ * Jitter sample positions -
+ * - average should be .5 in x & y for each column
+ * - each of the 16 rows and columns should be used once
+ * - the rectangle formed by the first four points
+ * should contain the other points
+ * - the distrubition should be fairly even in any given direction
+ *
+ * The pattern drawn below isn't optimal, but it's better than a regular
+ * grid. In the drawing, the center of each subpixel is surrounded by
+ * four dots. The "x" marks the jittered position relative to the
+ * subpixel center.
+ */
+#define POS(a, b) (0.5+a*4+b)/16
+ static const GLfloat samples[16][2] = {
+ /* start with the four corners */
+ { POS(0, 2), POS(0, 0) },
+ { POS(3, 3), POS(0, 2) },
+ { POS(0, 0), POS(3, 1) },
+ { POS(3, 1), POS(3, 3) },
+ /* continue with interior samples */
+ { POS(1, 1), POS(0, 1) },
+ { POS(2, 0), POS(0, 3) },
+ { POS(0, 3), POS(1, 3) },
+ { POS(1, 2), POS(1, 0) },
+ { POS(2, 3), POS(1, 2) },
+ { POS(3, 2), POS(1, 1) },
+ { POS(0, 1), POS(2, 2) },
+ { POS(1, 0), POS(2, 1) },
+ { POS(2, 1), POS(2, 3) },
+ { POS(3, 0), POS(2, 0) },
+ { POS(1, 3), POS(3, 0) },
+ { POS(2, 2), POS(3, 2) }
+ };
+
+ const GLfloat x = (GLfloat) winx;
+ const GLfloat y = (GLfloat) winy;
+ const GLfloat dx0 = v1[0] - v0[0];
+ const GLfloat dy0 = v1[1] - v0[1];
+ const GLfloat dx1 = v2[0] - v1[0];
+ const GLfloat dy1 = v2[1] - v1[1];
+ const GLfloat dx2 = v0[0] - v2[0];
+ const GLfloat dy2 = v0[1] - v2[1];
+ GLint stop = 4, i;
+ GLfloat insideCount = 16.0F;
+
+#ifdef DEBUG
+ {
+ const GLfloat area = dx0 * dy1 - dx1 * dy0;
+ ASSERT(area >= 0.0);
+ }
+#endif
+
+ for (i = 0; i < stop; i++) {
+ const GLfloat sx = x + samples[i][0];
+ const GLfloat sy = y + samples[i][1];
+ /* cross product determines if sample is inside or outside each edge */
+ GLfloat cross = (dx0 * (sy - v0[1]) - dy0 * (sx - v0[0]));
+ /* Check if the sample is exactly on an edge. If so, let cross be a
+ * positive or negative value depending on the direction of the edge.
+ */
+ if (cross == 0.0F)
+ cross = dx0 + dy0;
+ if (cross < 0.0F) {
+ /* sample point is outside first edge */
+ insideCount -= 1.0F;
+ stop = 16;
+ }
+ else {
+ /* sample point is inside first edge */
+ cross = (dx1 * (sy - v1[1]) - dy1 * (sx - v1[0]));
+ if (cross == 0.0F)
+ cross = dx1 + dy1;
+ if (cross < 0.0F) {
+ /* sample point is outside second edge */
+ insideCount -= 1.0F;
+ stop = 16;
+ }
+ else {
+ /* sample point is inside first and second edges */
+ cross = (dx2 * (sy - v2[1]) - dy2 * (sx - v2[0]));
+ if (cross == 0.0F)
+ cross = dx2 + dy2;
+ if (cross < 0.0F) {
+ /* sample point is outside third edge */
+ insideCount -= 1.0F;
+ stop = 16;
+ }
+ }
+ }
+ }
+ if (stop == 4)
+ return 1.0F;
+ else
+ return insideCount * (1.0F / 16.0F);
+}
+
+
+
+/*
+ * Compute how much (area) of the given pixel is inside the triangle.
+ * Vertices MUST be specified in counter-clockwise order.
+ * Return: coverage in [0, 15].
+ */
+static GLint
+compute_coveragei(const GLfloat v0[3], const GLfloat v1[3],
+ const GLfloat v2[3], GLint winx, GLint winy)
+{
+ /* NOTE: 15 samples instead of 16. */
+ static const GLfloat samples[15][2] = {
+ /* start with the four corners */
+ { POS(0, 2), POS(0, 0) },
+ { POS(3, 3), POS(0, 2) },
+ { POS(0, 0), POS(3, 1) },
+ { POS(3, 1), POS(3, 3) },
+ /* continue with interior samples */
+ { POS(1, 1), POS(0, 1) },
+ { POS(2, 0), POS(0, 3) },
+ { POS(0, 3), POS(1, 3) },
+ { POS(1, 2), POS(1, 0) },
+ { POS(2, 3), POS(1, 2) },
+ { POS(3, 2), POS(1, 1) },
+ { POS(0, 1), POS(2, 2) },
+ { POS(1, 0), POS(2, 1) },
+ { POS(2, 1), POS(2, 3) },
+ { POS(3, 0), POS(2, 0) },
+ { POS(1, 3), POS(3, 0) }
+ };
+ const GLfloat x = (GLfloat) winx;
+ const GLfloat y = (GLfloat) winy;
+ const GLfloat dx0 = v1[0] - v0[0];
+ const GLfloat dy0 = v1[1] - v0[1];
+ const GLfloat dx1 = v2[0] - v1[0];
+ const GLfloat dy1 = v2[1] - v1[1];
+ const GLfloat dx2 = v0[0] - v2[0];
+ const GLfloat dy2 = v0[1] - v2[1];
+ GLint stop = 4, i;
+ GLint insideCount = 15;
+
+#ifdef DEBUG
+ {
+ const GLfloat area = dx0 * dy1 - dx1 * dy0;
+ ASSERT(area >= 0.0);
+ }
+#endif
+
+ for (i = 0; i < stop; i++) {
+ const GLfloat sx = x + samples[i][0];
+ const GLfloat sy = y + samples[i][1];
+ const GLfloat fx0 = sx - v0[0];
+ const GLfloat fy0 = sy - v0[1];
+ const GLfloat fx1 = sx - v1[0];
+ const GLfloat fy1 = sy - v1[1];
+ const GLfloat fx2 = sx - v2[0];
+ const GLfloat fy2 = sy - v2[1];
+ /* cross product determines if sample is inside or outside each edge */
+ GLfloat cross0 = (dx0 * fy0 - dy0 * fx0);
+ GLfloat cross1 = (dx1 * fy1 - dy1 * fx1);
+ GLfloat cross2 = (dx2 * fy2 - dy2 * fx2);
+ /* Check if the sample is exactly on an edge. If so, let cross be a
+ * positive or negative value depending on the direction of the edge.
+ */
+ if (cross0 == 0.0F)
+ cross0 = dx0 + dy0;
+ if (cross1 == 0.0F)
+ cross1 = dx1 + dy1;
+ if (cross2 == 0.0F)
+ cross2 = dx2 + dy2;
+ if (cross0 < 0.0F || cross1 < 0.0F || cross2 < 0.0F) {
+ /* point is outside triangle */
+ insideCount--;
+ stop = 15;
+ }
+ }
+ if (stop == 4)
+ return 15;
+ else
+ return insideCount;
+}
+
+
+
+static void
+rgba_aa_tri(GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+#define DO_Z
+#define DO_FOG
+#define DO_RGBA
+#include "s_aatritemp.h"
+}
+
+
+static void
+index_aa_tri(GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+#define DO_Z
+#define DO_FOG
+#define DO_INDEX
+#include "s_aatritemp.h"
+}
+
+
+/*
+ * Compute mipmap level of detail.
+ * XXX we should really include the R coordinate in this computation
+ * in order to do 3-D texture mipmapping.
+ */
+static INLINE GLfloat
+compute_lambda(const GLfloat sPlane[4], const GLfloat tPlane[4],
+ const GLfloat qPlane[4], GLfloat cx, GLfloat cy,
+ GLfloat invQ, GLfloat texWidth, GLfloat texHeight)
+{
+ const GLfloat s = solve_plane(cx, cy, sPlane);
+ const GLfloat t = solve_plane(cx, cy, tPlane);
+ const GLfloat invQ_x1 = solve_plane_recip(cx+1.0F, cy, qPlane);
+ const GLfloat invQ_y1 = solve_plane_recip(cx, cy+1.0F, qPlane);
+ const GLfloat s_x1 = s - sPlane[0] / sPlane[2];
+ const GLfloat s_y1 = s - sPlane[1] / sPlane[2];
+ const GLfloat t_x1 = t - tPlane[0] / tPlane[2];
+ const GLfloat t_y1 = t - tPlane[1] / tPlane[2];
+ GLfloat dsdx = s_x1 * invQ_x1 - s * invQ;
+ GLfloat dsdy = s_y1 * invQ_y1 - s * invQ;
+ GLfloat dtdx = t_x1 * invQ_x1 - t * invQ;
+ GLfloat dtdy = t_y1 * invQ_y1 - t * invQ;
+ GLfloat maxU, maxV, rho, lambda;
+ dsdx = FABSF(dsdx);
+ dsdy = FABSF(dsdy);
+ dtdx = FABSF(dtdx);
+ dtdy = FABSF(dtdy);
+ maxU = MAX2(dsdx, dsdy) * texWidth;
+ maxV = MAX2(dtdx, dtdy) * texHeight;
+ rho = MAX2(maxU, maxV);
+ lambda = LOG2(rho);
+ return lambda;
+}
+
+
+static void
+tex_aa_tri(GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+#define DO_Z
+#define DO_FOG
+#define DO_RGBA
+#define DO_TEX
+#include "s_aatritemp.h"
+}
+
+
+static void
+spec_tex_aa_tri(GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+#define DO_Z
+#define DO_FOG
+#define DO_RGBA
+#define DO_TEX
+#define DO_SPEC
+#include "s_aatritemp.h"
+}
+
+
+static void
+multitex_aa_tri(GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+#define DO_Z
+#define DO_FOG
+#define DO_RGBA
+#define DO_MULTITEX
+#include "s_aatritemp.h"
+}
+
+static void
+spec_multitex_aa_tri(GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+#define DO_Z
+#define DO_FOG
+#define DO_RGBA
+#define DO_MULTITEX
+#define DO_SPEC
+#include "s_aatritemp.h"
+}
+
+
+/*
+ * Examine GL state and set swrast->Triangle to an
+ * appropriate antialiased triangle rasterizer function.
+ */
+void
+_swrast_set_aa_triangle_function(GLcontext *ctx)
+{
+ ASSERT(ctx->Polygon.SmoothFlag);
+
+ if (ctx->Texture._EnabledCoordUnits != 0) {
+ if (NEED_SECONDARY_COLOR(ctx)) {
+ if (ctx->Texture._EnabledCoordUnits > 1) {
+ SWRAST_CONTEXT(ctx)->Triangle = spec_multitex_aa_tri;
+ }
+ else {
+ SWRAST_CONTEXT(ctx)->Triangle = spec_tex_aa_tri;
+ }
+ }
+ else {
+ if (ctx->Texture._EnabledCoordUnits > 1) {
+ SWRAST_CONTEXT(ctx)->Triangle = multitex_aa_tri;
+ }
+ else {
+ SWRAST_CONTEXT(ctx)->Triangle = tex_aa_tri;
+ }
+ }
+ }
+ else if (ctx->Visual.rgbMode) {
+ SWRAST_CONTEXT(ctx)->Triangle = rgba_aa_tri;
+ }
+ else {
+ SWRAST_CONTEXT(ctx)->Triangle = index_aa_tri;
+ }
+
+ ASSERT(SWRAST_CONTEXT(ctx)->Triangle);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_aatriangle.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_aatriangle.h
new file mode 100644
index 000000000..ebb828eb1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_aatriangle.h
@@ -0,0 +1,39 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_AATRIANGLE_H
+#define S_AATRIANGLE_H
+
+
+#include "mtypes.h"
+#include "swrast.h"
+
+
+extern void
+_swrast_set_aa_triangle_function(GLcontext *ctx);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_aatritemp.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_aatritemp.h
new file mode 100644
index 000000000..16e26d3f8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_aatritemp.h
@@ -0,0 +1,549 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+/*
+ * Antialiased Triangle Rasterizer Template
+ *
+ * This file is #include'd to generate custom AA triangle rasterizers.
+ * NOTE: this code hasn't been optimized yet. That'll come after it
+ * works correctly.
+ *
+ * The following macros may be defined to indicate what auxillary information
+ * must be copmuted across the triangle:
+ * DO_Z - if defined, compute Z values
+ * DO_RGBA - if defined, compute RGBA values
+ * DO_INDEX - if defined, compute color index values
+ * DO_SPEC - if defined, compute specular RGB values
+ * DO_TEX - if defined, compute unit 0 STRQ texcoords
+ * DO_MULTITEX - if defined, compute all unit's STRQ texcoords
+ */
+
+/*void triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv )*/
+{
+ const GLfloat *p0 = v0->win;
+ const GLfloat *p1 = v1->win;
+ const GLfloat *p2 = v2->win;
+ const SWvertex *vMin, *vMid, *vMax;
+ GLint iyMin, iyMax;
+ GLfloat yMin, yMax;
+ GLboolean ltor;
+ GLfloat majDx, majDy; /* major (i.e. long) edge dx and dy */
+
+ struct sw_span span;
+
+#ifdef DO_Z
+ GLfloat zPlane[4];
+#endif
+#ifdef DO_FOG
+ GLfloat fogPlane[4];
+#else
+ GLfloat *fog = NULL;
+#endif
+#ifdef DO_RGBA
+ GLfloat rPlane[4], gPlane[4], bPlane[4], aPlane[4];
+#endif
+#ifdef DO_INDEX
+ GLfloat iPlane[4];
+#endif
+#ifdef DO_SPEC
+ GLfloat srPlane[4], sgPlane[4], sbPlane[4];
+#endif
+#ifdef DO_TEX
+ GLfloat sPlane[4], tPlane[4], uPlane[4], vPlane[4];
+ GLfloat texWidth, texHeight;
+#elif defined(DO_MULTITEX)
+ GLfloat sPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture S */
+ GLfloat tPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture T */
+ GLfloat uPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture R */
+ GLfloat vPlane[MAX_TEXTURE_COORD_UNITS][4]; /* texture Q */
+ GLfloat texWidth[MAX_TEXTURE_COORD_UNITS];
+ GLfloat texHeight[MAX_TEXTURE_COORD_UNITS];
+#endif
+ GLfloat bf = SWRAST_CONTEXT(ctx)->_BackfaceSign;
+
+
+ INIT_SPAN(span, GL_POLYGON, 0, 0, SPAN_COVERAGE);
+
+ /* determine bottom to top order of vertices */
+ {
+ GLfloat y0 = v0->win[1];
+ GLfloat y1 = v1->win[1];
+ GLfloat y2 = v2->win[1];
+ if (y0 <= y1) {
+ if (y1 <= y2) {
+ vMin = v0; vMid = v1; vMax = v2; /* y0<=y1<=y2 */
+ }
+ else if (y2 <= y0) {
+ vMin = v2; vMid = v0; vMax = v1; /* y2<=y0<=y1 */
+ }
+ else {
+ vMin = v0; vMid = v2; vMax = v1; bf = -bf; /* y0<=y2<=y1 */
+ }
+ }
+ else {
+ if (y0 <= y2) {
+ vMin = v1; vMid = v0; vMax = v2; bf = -bf; /* y1<=y0<=y2 */
+ }
+ else if (y2 <= y1) {
+ vMin = v2; vMid = v1; vMax = v0; bf = -bf; /* y2<=y1<=y0 */
+ }
+ else {
+ vMin = v1; vMid = v2; vMax = v0; /* y1<=y2<=y0 */
+ }
+ }
+ }
+
+ majDx = vMax->win[0] - vMin->win[0];
+ majDy = vMax->win[1] - vMin->win[1];
+
+ {
+ const GLfloat botDx = vMid->win[0] - vMin->win[0];
+ const GLfloat botDy = vMid->win[1] - vMin->win[1];
+ const GLfloat area = majDx * botDy - botDx * majDy;
+ /* Do backface culling */
+ if (area * bf < 0 || area == 0 || IS_INF_OR_NAN(area))
+ return;
+ ltor = (GLboolean) (area < 0.0F);
+ }
+
+#ifndef DO_OCCLUSION_TEST
+ ctx->OcclusionResult = GL_TRUE;
+#endif
+
+ /* Plane equation setup:
+ * We evaluate plane equations at window (x,y) coordinates in order
+ * to compute color, Z, fog, texcoords, etc. This isn't terribly
+ * efficient but it's easy and reliable.
+ */
+#ifdef DO_Z
+ compute_plane(p0, p1, p2, p0[2], p1[2], p2[2], zPlane);
+ span.arrayMask |= SPAN_Z;
+#endif
+#ifdef DO_FOG
+ compute_plane(p0, p1, p2, v0->fog, v1->fog, v2->fog, fogPlane);
+ span.arrayMask |= SPAN_FOG;
+#endif
+#ifdef DO_RGBA
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ compute_plane(p0, p1, p2, v0->color[RCOMP], v1->color[RCOMP], v2->color[RCOMP], rPlane);
+ compute_plane(p0, p1, p2, v0->color[GCOMP], v1->color[GCOMP], v2->color[GCOMP], gPlane);
+ compute_plane(p0, p1, p2, v0->color[BCOMP], v1->color[BCOMP], v2->color[BCOMP], bPlane);
+ compute_plane(p0, p1, p2, v0->color[ACOMP], v1->color[ACOMP], v2->color[ACOMP], aPlane);
+ }
+ else {
+ constant_plane(v2->color[RCOMP], rPlane);
+ constant_plane(v2->color[GCOMP], gPlane);
+ constant_plane(v2->color[BCOMP], bPlane);
+ constant_plane(v2->color[ACOMP], aPlane);
+ }
+ span.arrayMask |= SPAN_RGBA;
+#endif
+#ifdef DO_INDEX
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ compute_plane(p0, p1, p2, (GLfloat) v0->index,
+ v1->index, v2->index, iPlane);
+ }
+ else {
+ constant_plane(v2->index, iPlane);
+ }
+ span.arrayMask |= SPAN_INDEX;
+#endif
+#ifdef DO_SPEC
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ compute_plane(p0, p1, p2, v0->specular[RCOMP], v1->specular[RCOMP], v2->specular[RCOMP], srPlane);
+ compute_plane(p0, p1, p2, v0->specular[GCOMP], v1->specular[GCOMP], v2->specular[GCOMP], sgPlane);
+ compute_plane(p0, p1, p2, v0->specular[BCOMP], v1->specular[BCOMP], v2->specular[BCOMP], sbPlane);
+ }
+ else {
+ constant_plane(v2->specular[RCOMP], srPlane);
+ constant_plane(v2->specular[GCOMP], sgPlane);
+ constant_plane(v2->specular[BCOMP], sbPlane);
+ }
+ span.arrayMask |= SPAN_SPEC;
+#endif
+#ifdef DO_TEX
+ {
+ const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current;
+ const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel];
+ const GLfloat invW0 = v0->win[3];
+ const GLfloat invW1 = v1->win[3];
+ const GLfloat invW2 = v2->win[3];
+ const GLfloat s0 = v0->texcoord[0][0] * invW0;
+ const GLfloat s1 = v1->texcoord[0][0] * invW1;
+ const GLfloat s2 = v2->texcoord[0][0] * invW2;
+ const GLfloat t0 = v0->texcoord[0][1] * invW0;
+ const GLfloat t1 = v1->texcoord[0][1] * invW1;
+ const GLfloat t2 = v2->texcoord[0][1] * invW2;
+ const GLfloat r0 = v0->texcoord[0][2] * invW0;
+ const GLfloat r1 = v1->texcoord[0][2] * invW1;
+ const GLfloat r2 = v2->texcoord[0][2] * invW2;
+ const GLfloat q0 = v0->texcoord[0][3] * invW0;
+ const GLfloat q1 = v1->texcoord[0][3] * invW1;
+ const GLfloat q2 = v2->texcoord[0][3] * invW2;
+ compute_plane(p0, p1, p2, s0, s1, s2, sPlane);
+ compute_plane(p0, p1, p2, t0, t1, t2, tPlane);
+ compute_plane(p0, p1, p2, r0, r1, r2, uPlane);
+ compute_plane(p0, p1, p2, q0, q1, q2, vPlane);
+ texWidth = (GLfloat) texImage->Width;
+ texHeight = (GLfloat) texImage->Height;
+ }
+ span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA);
+#elif defined(DO_MULTITEX)
+ {
+ GLuint u;
+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
+ if (ctx->Texture.Unit[u]._ReallyEnabled) {
+ const struct gl_texture_object *obj = ctx->Texture.Unit[u]._Current;
+ const struct gl_texture_image *texImage = obj->Image[0][obj->BaseLevel];
+ const GLfloat invW0 = v0->win[3];
+ const GLfloat invW1 = v1->win[3];
+ const GLfloat invW2 = v2->win[3];
+ const GLfloat s0 = v0->texcoord[u][0] * invW0;
+ const GLfloat s1 = v1->texcoord[u][0] * invW1;
+ const GLfloat s2 = v2->texcoord[u][0] * invW2;
+ const GLfloat t0 = v0->texcoord[u][1] * invW0;
+ const GLfloat t1 = v1->texcoord[u][1] * invW1;
+ const GLfloat t2 = v2->texcoord[u][1] * invW2;
+ const GLfloat r0 = v0->texcoord[u][2] * invW0;
+ const GLfloat r1 = v1->texcoord[u][2] * invW1;
+ const GLfloat r2 = v2->texcoord[u][2] * invW2;
+ const GLfloat q0 = v0->texcoord[u][3] * invW0;
+ const GLfloat q1 = v1->texcoord[u][3] * invW1;
+ const GLfloat q2 = v2->texcoord[u][3] * invW2;
+ compute_plane(p0, p1, p2, s0, s1, s2, sPlane[u]);
+ compute_plane(p0, p1, p2, t0, t1, t2, tPlane[u]);
+ compute_plane(p0, p1, p2, r0, r1, r2, uPlane[u]);
+ compute_plane(p0, p1, p2, q0, q1, q2, vPlane[u]);
+ texWidth[u] = (GLfloat) texImage->Width;
+ texHeight[u] = (GLfloat) texImage->Height;
+ }
+ }
+ }
+ span.arrayMask |= (SPAN_TEXTURE | SPAN_LAMBDA);
+#endif
+
+ /* Begin bottom-to-top scan over the triangle.
+ * The long edge will either be on the left or right side of the
+ * triangle. We always scan from the long edge toward the shorter
+ * edges, stopping when we find that coverage = 0. If the long edge
+ * is on the left we scan left-to-right. Else, we scan right-to-left.
+ */
+ yMin = vMin->win[1];
+ yMax = vMax->win[1];
+ iyMin = (GLint) yMin;
+ iyMax = (GLint) yMax + 1;
+
+ if (ltor) {
+ /* scan left to right */
+ const GLfloat *pMin = vMin->win;
+ const GLfloat *pMid = vMid->win;
+ const GLfloat *pMax = vMax->win;
+ const GLfloat dxdy = majDx / majDy;
+ const GLfloat xAdj = dxdy < 0.0F ? -dxdy : 0.0F;
+ GLfloat x = pMin[0] - (yMin - iyMin) * dxdy;
+ GLint iy;
+ for (iy = iyMin; iy < iyMax; iy++, x += dxdy) {
+ GLint ix, startX = (GLint) (x - xAdj);
+ GLuint count;
+ GLfloat coverage = 0.0F;
+
+ /* skip over fragments with zero coverage */
+ while (startX < MAX_WIDTH) {
+ coverage = compute_coveragef(pMin, pMid, pMax, startX, iy);
+ if (coverage > 0.0F)
+ break;
+ startX++;
+ }
+
+ /* enter interior of triangle */
+ ix = startX;
+ count = 0;
+ while (coverage > 0.0F) {
+ /* (cx,cy) = center of fragment */
+ const GLfloat cx = ix + 0.5F, cy = iy + 0.5F;
+ struct span_arrays *array = span.array;
+#ifdef DO_INDEX
+ array->coverage[count] = (GLfloat) compute_coveragei(pMin, pMid, pMax, ix, iy);
+#else
+ array->coverage[count] = coverage;
+#endif
+#ifdef DO_Z
+ array->z[count] = (GLdepth) IROUND(solve_plane(cx, cy, zPlane));
+#endif
+#ifdef DO_FOG
+ array->fog[count] = solve_plane(cx, cy, fogPlane);
+#endif
+#ifdef DO_RGBA
+ array->rgba[count][RCOMP] = solve_plane_chan(cx, cy, rPlane);
+ array->rgba[count][GCOMP] = solve_plane_chan(cx, cy, gPlane);
+ array->rgba[count][BCOMP] = solve_plane_chan(cx, cy, bPlane);
+ array->rgba[count][ACOMP] = solve_plane_chan(cx, cy, aPlane);
+#endif
+#ifdef DO_INDEX
+ array->index[count] = (GLint) solve_plane(cx, cy, iPlane);
+#endif
+#ifdef DO_SPEC
+ array->spec[count][RCOMP] = solve_plane_chan(cx, cy, srPlane);
+ array->spec[count][GCOMP] = solve_plane_chan(cx, cy, sgPlane);
+ array->spec[count][BCOMP] = solve_plane_chan(cx, cy, sbPlane);
+#endif
+#ifdef DO_TEX
+ {
+ const GLfloat invQ = solve_plane_recip(cx, cy, vPlane);
+ array->texcoords[0][count][0] = solve_plane(cx, cy, sPlane) * invQ;
+ array->texcoords[0][count][1] = solve_plane(cx, cy, tPlane) * invQ;
+ array->texcoords[0][count][2] = solve_plane(cx, cy, uPlane) * invQ;
+ array->lambda[0][count] = compute_lambda(sPlane, tPlane, vPlane,
+ cx, cy, invQ,
+ texWidth, texHeight);
+ }
+#elif defined(DO_MULTITEX)
+ {
+ GLuint unit;
+ for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
+ if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+ GLfloat invQ = solve_plane_recip(cx, cy, vPlane[unit]);
+ array->texcoords[unit][count][0] = solve_plane(cx, cy, sPlane[unit]) * invQ;
+ array->texcoords[unit][count][1] = solve_plane(cx, cy, tPlane[unit]) * invQ;
+ array->texcoords[unit][count][2] = solve_plane(cx, cy, uPlane[unit]) * invQ;
+ array->lambda[unit][count] = compute_lambda(sPlane[unit],
+ tPlane[unit], vPlane[unit], cx, cy, invQ,
+ texWidth[unit], texHeight[unit]);
+ }
+ }
+ }
+#endif
+ ix++;
+ count++;
+ coverage = compute_coveragef(pMin, pMid, pMax, ix, iy);
+ }
+
+ if (ix <= startX)
+ continue;
+
+ span.x = startX;
+ span.y = iy;
+ span.end = (GLuint) ix - (GLuint) startX;
+ ASSERT(span.interpMask == 0);
+#if defined(DO_RGBA)
+ _swrast_write_rgba_span(ctx, &span);
+#else
+ _swrast_write_index_span(ctx, &span);
+#endif
+ }
+ }
+ else {
+ /* scan right to left */
+ const GLfloat *pMin = vMin->win;
+ const GLfloat *pMid = vMid->win;
+ const GLfloat *pMax = vMax->win;
+ const GLfloat dxdy = majDx / majDy;
+ const GLfloat xAdj = dxdy > 0 ? dxdy : 0.0F;
+ GLfloat x = pMin[0] - (yMin - iyMin) * dxdy;
+ GLint iy;
+ for (iy = iyMin; iy < iyMax; iy++, x += dxdy) {
+ GLint ix, left, startX = (GLint) (x + xAdj);
+ GLuint count, n;
+ GLfloat coverage = 0.0F;
+
+ /* make sure we're not past the window edge */
+ if (startX >= ctx->DrawBuffer->_Xmax) {
+ startX = ctx->DrawBuffer->_Xmax - 1;
+ }
+
+ /* skip fragments with zero coverage */
+ while (startX >= 0) {
+ coverage = compute_coveragef(pMin, pMax, pMid, startX, iy);
+ if (coverage > 0.0F)
+ break;
+ startX--;
+ }
+
+ /* enter interior of triangle */
+ ix = startX;
+ count = 0;
+ while (coverage > 0.0F) {
+ /* (cx,cy) = center of fragment */
+ const GLfloat cx = ix + 0.5F, cy = iy + 0.5F;
+ struct span_arrays *array = span.array;
+#ifdef DO_INDEX
+ array->coverage[ix] = (GLfloat) compute_coveragei(pMin, pMax, pMid, ix, iy);
+#else
+ array->coverage[ix] = coverage;
+#endif
+#ifdef DO_Z
+ array->z[ix] = (GLdepth) IROUND(solve_plane(cx, cy, zPlane));
+#endif
+#ifdef DO_FOG
+ array->fog[ix] = solve_plane(cx, cy, fogPlane);
+#endif
+#ifdef DO_RGBA
+ array->rgba[ix][RCOMP] = solve_plane_chan(cx, cy, rPlane);
+ array->rgba[ix][GCOMP] = solve_plane_chan(cx, cy, gPlane);
+ array->rgba[ix][BCOMP] = solve_plane_chan(cx, cy, bPlane);
+ array->rgba[ix][ACOMP] = solve_plane_chan(cx, cy, aPlane);
+#endif
+#ifdef DO_INDEX
+ array->index[ix] = (GLint) solve_plane(cx, cy, iPlane);
+#endif
+#ifdef DO_SPEC
+ array->spec[ix][RCOMP] = solve_plane_chan(cx, cy, srPlane);
+ array->spec[ix][GCOMP] = solve_plane_chan(cx, cy, sgPlane);
+ array->spec[ix][BCOMP] = solve_plane_chan(cx, cy, sbPlane);
+#endif
+#ifdef DO_TEX
+ {
+ const GLfloat invQ = solve_plane_recip(cx, cy, vPlane);
+ array->texcoords[0][ix][0] = solve_plane(cx, cy, sPlane) * invQ;
+ array->texcoords[0][ix][1] = solve_plane(cx, cy, tPlane) * invQ;
+ array->texcoords[0][ix][2] = solve_plane(cx, cy, uPlane) * invQ;
+ array->lambda[0][ix] = compute_lambda(sPlane, tPlane, vPlane,
+ cx, cy, invQ, texWidth, texHeight);
+ }
+#elif defined(DO_MULTITEX)
+ {
+ GLuint unit;
+ for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
+ if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+ GLfloat invQ = solve_plane_recip(cx, cy, vPlane[unit]);
+ array->texcoords[unit][ix][0] = solve_plane(cx, cy, sPlane[unit]) * invQ;
+ array->texcoords[unit][ix][1] = solve_plane(cx, cy, tPlane[unit]) * invQ;
+ array->texcoords[unit][ix][2] = solve_plane(cx, cy, uPlane[unit]) * invQ;
+ array->lambda[unit][ix] = compute_lambda(sPlane[unit],
+ tPlane[unit],
+ vPlane[unit],
+ cx, cy, invQ,
+ texWidth[unit],
+ texHeight[unit]);
+ }
+ }
+ }
+#endif
+ ix--;
+ count++;
+ coverage = compute_coveragef(pMin, pMax, pMid, ix, iy);
+ }
+
+ if (startX <= ix)
+ continue;
+
+ n = (GLuint) startX - (GLuint) ix;
+
+ left = ix + 1;
+
+ /* shift all values to the left */
+ /* XXX this is temporary */
+ {
+ struct span_arrays *array = span.array;
+ GLint j;
+ for (j = 0; j < (GLint) n; j++) {
+#ifdef DO_RGBA
+ COPY_CHAN4(array->rgba[j], array->rgba[j + left]);
+#endif
+#ifdef DO_SPEC
+ COPY_CHAN4(array->spec[j], array->spec[j + left]);
+#endif
+#ifdef DO_INDEX
+ array->index[j] = array->index[j + left];
+#endif
+#ifdef DO_Z
+ array->z[j] = array->z[j + left];
+#endif
+#ifdef DO_FOG
+ array->fog[j] = array->fog[j + left];
+#endif
+#ifdef DO_TEX
+ COPY_4V(array->texcoords[0][j], array->texcoords[0][j + left]);
+#endif
+#if defined(DO_MULTITEX) || defined(DO_TEX)
+ array->lambda[0][j] = array->lambda[0][j + left];
+#endif
+ array->coverage[j] = array->coverage[j + left];
+ }
+ }
+#ifdef DO_MULTITEX
+ /* shift texcoords */
+ {
+ struct span_arrays *array = span.array;
+ GLuint unit;
+ for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
+ if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+ GLint j;
+ for (j = 0; j < (GLint) n; j++) {
+ array->texcoords[unit][j][0] = array->texcoords[unit][j + left][0];
+ array->texcoords[unit][j][1] = array->texcoords[unit][j + left][1];
+ array->texcoords[unit][j][2] = array->texcoords[unit][j + left][2];
+ array->lambda[unit][j] = array->lambda[unit][j + left];
+ }
+ }
+ }
+ }
+#endif
+
+ span.x = left;
+ span.y = iy;
+ span.end = n;
+ ASSERT(span.interpMask == 0);
+#if defined(DO_RGBA)
+ _swrast_write_rgba_span(ctx, &span);
+#else
+ _swrast_write_index_span(ctx, &span);
+#endif
+ }
+ }
+}
+
+
+#ifdef DO_Z
+#undef DO_Z
+#endif
+
+#ifdef DO_FOG
+#undef DO_FOG
+#endif
+
+#ifdef DO_RGBA
+#undef DO_RGBA
+#endif
+
+#ifdef DO_INDEX
+#undef DO_INDEX
+#endif
+
+#ifdef DO_SPEC
+#undef DO_SPEC
+#endif
+
+#ifdef DO_TEX
+#undef DO_TEX
+#endif
+
+#ifdef DO_MULTITEX
+#undef DO_MULTITEX
+#endif
+
+#ifdef DO_OCCLUSION_TEST
+#undef DO_OCCLUSION_TEST
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_accum.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_accum.c
new file mode 100644
index 000000000..5621d0c8a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_accum.c
@@ -0,0 +1,584 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+#include "fbobject.h"
+
+#include "s_accum.h"
+#include "s_context.h"
+#include "s_masking.h"
+#include "s_span.h"
+
+
+#define ACCUM_SCALE16 32767.0
+
+
+/*
+ * Accumulation buffer notes
+ *
+ * Normally, accumulation buffer values are GLshorts with values in
+ * [-32767, 32767] which represent floating point colors in [-1, 1],
+ * as defined by the OpenGL specification.
+ *
+ * We optimize for the common case used for full-scene antialiasing:
+ * // start with accum buffer cleared to zero
+ * glAccum(GL_LOAD, w); // or GL_ACCUM the first image
+ * glAccum(GL_ACCUM, w);
+ * ...
+ * glAccum(GL_ACCUM, w);
+ * glAccum(GL_RETURN, 1.0);
+ * That is, we start with an empty accumulation buffer and accumulate
+ * n images, each with weight w = 1/n.
+ * In this scenario, we can simply store unscaled integer values in
+ * the accum buffer instead of scaled integers. We'll also keep track
+ * of the w value so when we do GL_RETURN we simply divide the accumulated
+ * values by n (n=1/w).
+ * This lets us avoid _many_ int->float->int conversions.
+ */
+
+
+#if CHAN_BITS == 8 && ACCUM_BITS <= 32
+/* enable the optimization */
+#define USE_OPTIMIZED_ACCUM 1
+#else
+#define USE_OPTIMIZED_ACCUM 0
+#endif
+
+
+/**
+ * This is called when we fall out of optimized/unscaled accum buffer mode.
+ * That is, we convert each unscaled accum buffer value into a scaled value
+ * representing the range[-1, 1].
+ */
+static void
+rescale_accum( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *rb
+ = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
+ const GLfloat s = swrast->_IntegerAccumScaler * (32767.0F / CHAN_MAXF);
+
+ assert(rb);
+ assert(rb->_BaseFormat == GL_RGBA);
+ /* add other types in future? */
+ assert(rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT);
+ assert(swrast->_IntegerAccumMode);
+
+ if (rb->GetPointer(ctx, rb, 0, 0)) {
+ /* directly-addressable memory */
+ GLuint y;
+ for (y = 0; y < rb->Height; y++) {
+ GLuint i;
+ GLshort *acc = (GLshort *) rb->GetPointer(ctx, rb, 0, y);
+ for (i = 0; i < 4 * rb->Width; i++) {
+ acc[i] = (GLshort) (acc[i] * s);
+ }
+ }
+ }
+ else {
+ /* use get/put row funcs */
+ GLuint y;
+ for (y = 0; y < rb->Height; y++) {
+ GLshort accRow[MAX_WIDTH * 4];
+ GLuint i;
+ rb->GetRow(ctx, rb, rb->Width, 0, y, accRow);
+ for (i = 0; i < 4 * rb->Width; i++) {
+ accRow[i] = (GLshort) (accRow[i] * s);
+ }
+ rb->PutRow(ctx, rb, rb->Width, 0, y, accRow, NULL);
+ }
+ }
+
+ swrast->_IntegerAccumMode = GL_FALSE;
+}
+
+
+
+/**
+ * Clear the accumulation Buffer.
+ */
+void
+_swrast_clear_accum_buffer( GLcontext *ctx, struct gl_renderbuffer *rb )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLuint x, y, width, height;
+
+ if (ctx->Visual.accumRedBits == 0) {
+ /* No accumulation buffer! Not an error. */
+ return;
+ }
+
+ assert(rb);
+ assert(rb->_BaseFormat == GL_RGBA);
+ /* add other types in future? */
+ assert(rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT);
+
+ /* bounds, with scissor */
+ x = ctx->DrawBuffer->_Xmin;
+ y = ctx->DrawBuffer->_Ymin;
+ width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+ height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+
+ if (rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT) {
+ const GLfloat accScale = 32767.0;
+ GLshort clearVal[4];
+ GLuint i;
+
+ clearVal[0] = (GLshort) (ctx->Accum.ClearColor[0] * accScale);
+ clearVal[1] = (GLshort) (ctx->Accum.ClearColor[1] * accScale);
+ clearVal[2] = (GLshort) (ctx->Accum.ClearColor[2] * accScale);
+ clearVal[3] = (GLshort) (ctx->Accum.ClearColor[3] * accScale);
+
+ for (i = 0; i < height; i++) {
+ rb->PutMonoRow(ctx, rb, width, x, y + i, clearVal, NULL);
+ }
+ }
+ else {
+ /* someday support other sizes */
+ }
+
+ /* update optimized accum state vars */
+ if (ctx->Accum.ClearColor[0] == 0.0 && ctx->Accum.ClearColor[1] == 0.0 &&
+ ctx->Accum.ClearColor[2] == 0.0 && ctx->Accum.ClearColor[3] == 0.0) {
+#if USE_OPTIMIZED_ACCUM
+ swrast->_IntegerAccumMode = GL_TRUE;
+#else
+ swrast->_IntegerAccumMode = GL_FALSE;
+#endif
+ swrast->_IntegerAccumScaler = 0.0; /* denotes empty accum buffer */
+ }
+ else {
+ swrast->_IntegerAccumMode = GL_FALSE;
+ }
+}
+
+
+static void
+accum_add(GLcontext *ctx, GLfloat value,
+ GLint xpos, GLint ypos, GLint width, GLint height )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *rb
+ = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
+
+ assert(rb);
+
+ /* Leave optimized accum buffer mode */
+ if (swrast->_IntegerAccumMode)
+ rescale_accum(ctx);
+
+ if (rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT) {
+ const GLshort incr = (GLshort) (value * ACCUM_SCALE16);
+ if (rb->GetPointer(ctx, rb, 0, 0)) {
+ GLint i, j;
+ for (i = 0; i < height; i++) {
+ GLshort *acc = (GLshort *) rb->GetPointer(ctx, rb, xpos, ypos + i);
+ for (j = 0; j < 4 * width; j++) {
+ acc[j] += incr;
+ }
+ }
+ }
+ else {
+ GLint i, j;
+ for (i = 0; i < height; i++) {
+ GLshort accRow[4 * MAX_WIDTH];
+ rb->GetRow(ctx, rb, width, xpos, ypos + i, accRow);
+ for (j = 0; j < 4 * width; j++) {
+ accRow[j] += incr;
+ }
+ rb->PutRow(ctx, rb, width, xpos, ypos + i, accRow, NULL);
+ }
+ }
+ }
+ else {
+ /* other types someday */
+ }
+}
+
+
+static void
+accum_mult(GLcontext *ctx, GLfloat mult,
+ GLint xpos, GLint ypos, GLint width, GLint height )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *rb
+ = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
+
+ assert(rb);
+
+ /* Leave optimized accum buffer mode */
+ if (swrast->_IntegerAccumMode)
+ rescale_accum(ctx);
+
+ if (rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT) {
+ if (rb->GetPointer(ctx, rb, 0, 0)) {
+ GLint i, j;
+ for (i = 0; i < height; i++) {
+ GLshort *acc = (GLshort *) rb->GetPointer(ctx, rb, xpos, ypos + i);
+ for (j = 0; j < 4 * width; j++) {
+ acc[j] = (GLshort) (acc[j] * mult);
+ }
+ }
+ }
+ else {
+ GLint i, j;
+ for (i = 0; i < height; i++) {
+ GLshort accRow[4 * MAX_WIDTH];
+ rb->GetRow(ctx, rb, width, xpos, ypos + i, accRow);
+ for (j = 0; j < 4 * width; j++) {
+ accRow[j] = (GLshort) (accRow[j] * mult);
+ }
+ rb->PutRow(ctx, rb, width, xpos, ypos + i, accRow, NULL);
+ }
+ }
+ }
+ else {
+ /* other types someday */
+ }
+}
+
+
+
+static void
+accum_accum(GLcontext *ctx, GLfloat value,
+ GLint xpos, GLint ypos, GLint width, GLint height )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *rb
+ = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
+ const GLboolean directAccess = (rb->GetPointer(ctx, rb, 0, 0) != NULL);
+
+ assert(rb);
+
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no read buffer - OK */
+ return;
+ }
+
+ /* May have to leave optimized accum buffer mode */
+ if (swrast->_IntegerAccumScaler == 0.0 && value > 0.0 && value <= 1.0)
+ swrast->_IntegerAccumScaler = value;
+ if (swrast->_IntegerAccumMode && value != swrast->_IntegerAccumScaler)
+ rescale_accum(ctx);
+
+ _swrast_use_read_buffer(ctx);
+
+ if (rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT) {
+ const GLfloat scale = value * ACCUM_SCALE16 / CHAN_MAXF;
+ GLshort accumRow[4 * MAX_WIDTH];
+ GLchan rgba[MAX_WIDTH][4];
+ GLint i;
+
+ for (i = 0; i < height; i++) {
+ GLshort *acc;
+ if (directAccess) {
+ acc = (GLshort *) rb->GetPointer(ctx, rb, xpos, ypos + i);
+ }
+ else {
+ rb->GetRow(ctx, rb, width, xpos, ypos + i, accumRow);
+ acc = accumRow;
+ }
+
+ /* read colors from color buffer */
+ _swrast_read_rgba_span(ctx, ctx->ReadBuffer->_ColorReadBuffer, width,
+ xpos, ypos + i, rgba);
+
+ /* do accumulation */
+ if (swrast->_IntegerAccumMode) {
+ /* simply add integer color values into accum buffer */
+ GLint j;
+ for (j = 0; j < width; j++) {
+ acc[j * 4 + 0] += rgba[j][RCOMP];
+ acc[j * 4 + 1] += rgba[j][GCOMP];
+ acc[j * 4 + 2] += rgba[j][BCOMP];
+ acc[j * 4 + 3] += rgba[j][ACOMP];
+ }
+ }
+ else {
+ /* scaled integer (or float) accum buffer */
+ GLint j;
+ for (j = 0; j < width; j++) {
+ acc[j * 4 + 0] += (GLshort) ((GLfloat) rgba[j][RCOMP] * scale);
+ acc[j * 4 + 1] += (GLshort) ((GLfloat) rgba[j][GCOMP] * scale);
+ acc[j * 4 + 2] += (GLshort) ((GLfloat) rgba[j][BCOMP] * scale);
+ acc[j * 4 + 3] += (GLshort) ((GLfloat) rgba[j][ACOMP] * scale);
+ }
+ }
+
+ if (!directAccess) {
+ rb->PutRow(ctx, rb, width, xpos, ypos + i, accumRow, NULL);
+ }
+ }
+ }
+ else {
+ /* other types someday */
+ }
+
+ _swrast_use_draw_buffer(ctx);
+}
+
+
+
+static void
+accum_load(GLcontext *ctx, GLfloat value,
+ GLint xpos, GLint ypos, GLint width, GLint height )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *rb
+ = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
+ const GLboolean directAccess = (rb->GetPointer(ctx, rb, 0, 0) != NULL);
+
+ assert(rb);
+
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no read buffer - OK */
+ return;
+ }
+
+ /* This is a change to go into optimized accum buffer mode */
+ if (value > 0.0 && value <= 1.0) {
+#if USE_OPTIMIZED_ACCUM
+ swrast->_IntegerAccumMode = GL_TRUE;
+#else
+ swrast->_IntegerAccumMode = GL_FALSE;
+#endif
+ swrast->_IntegerAccumScaler = value;
+ }
+ else {
+ swrast->_IntegerAccumMode = GL_FALSE;
+ swrast->_IntegerAccumScaler = 0.0;
+ }
+
+ _swrast_use_read_buffer(ctx);
+
+ if (rb->DataType == GL_SHORT || rb->DataType == GL_UNSIGNED_SHORT) {
+ const GLfloat scale = value * ACCUM_SCALE16 / CHAN_MAXF;
+ GLshort accumRow[4 * MAX_WIDTH];
+ GLchan rgba[MAX_WIDTH][4];
+ GLint i;
+
+ for (i = 0; i < height; i++) {
+ GLshort *acc;
+ if (directAccess) {
+ acc = (GLshort *) rb->GetPointer(ctx, rb, xpos, ypos + i);
+ }
+ else {
+ rb->GetRow(ctx, rb, width, xpos, ypos + i, accumRow);
+ acc = accumRow;
+ }
+
+ /* read colors from color buffer */
+ _swrast_read_rgba_span(ctx, ctx->ReadBuffer->_ColorReadBuffer, width,
+ xpos, ypos + i, rgba);
+
+ /* do load */
+ if (swrast->_IntegerAccumMode) {
+ /* just copy values in */
+ GLint j;
+ assert(swrast->_IntegerAccumScaler > 0.0);
+ assert(swrast->_IntegerAccumScaler <= 1.0);
+ for (j = 0; j < width; j++) {
+ acc[j * 4 + 0] = rgba[j][RCOMP];
+ acc[j * 4 + 1] = rgba[j][GCOMP];
+ acc[j * 4 + 2] = rgba[j][BCOMP];
+ acc[j * 4 + 3] = rgba[j][ACOMP];
+ }
+ }
+ else {
+ /* scaled integer (or float) accum buffer */
+ GLint j;
+ for (j = 0; j < width; j++) {
+ acc[j * 4 + 0] = (GLshort) ((GLfloat) rgba[j][RCOMP] * scale);
+ acc[j * 4 + 1] = (GLshort) ((GLfloat) rgba[j][GCOMP] * scale);
+ acc[j * 4 + 2] = (GLshort) ((GLfloat) rgba[j][BCOMP] * scale);
+ acc[j * 4 + 3] = (GLshort) ((GLfloat) rgba[j][ACOMP] * scale);
+ }
+ }
+
+ if (!directAccess) {
+ rb->PutRow(ctx, rb, width, xpos, ypos + i, accumRow, NULL);
+ }
+ }
+ }
+ else {
+ /* other types someday */
+ }
+
+ _swrast_use_draw_buffer(ctx);
+}
+
+
+static void
+accum_return(GLcontext *ctx, GLfloat value,
+ GLint xpos, GLint ypos, GLint width, GLint height )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *accumRb = fb->Attachment[BUFFER_ACCUM].Renderbuffer;
+ const GLboolean directAccess
+ = (accumRb->GetPointer(ctx, accumRb, 0, 0) != NULL);
+ const GLboolean masking = (!ctx->Color.ColorMask[RCOMP] ||
+ !ctx->Color.ColorMask[GCOMP] ||
+ !ctx->Color.ColorMask[BCOMP] ||
+ !ctx->Color.ColorMask[ACOMP]);
+
+ static GLchan multTable[32768];
+ static GLfloat prevMult = 0.0;
+ const GLfloat mult = swrast->_IntegerAccumScaler;
+ const GLint max = MIN2((GLint) (256 / mult), 32767);
+
+ /* May have to leave optimized accum buffer mode */
+ if (swrast->_IntegerAccumMode && value != 1.0)
+ rescale_accum(ctx);
+
+ if (swrast->_IntegerAccumMode && swrast->_IntegerAccumScaler > 0) {
+ /* build lookup table to avoid many floating point multiplies */
+ GLint j;
+ assert(swrast->_IntegerAccumScaler <= 1.0);
+ if (mult != prevMult) {
+ for (j = 0; j < max; j++)
+ multTable[j] = IROUND((GLfloat) j * mult);
+ prevMult = mult;
+ }
+ }
+
+ if (accumRb->DataType == GL_SHORT ||
+ accumRb->DataType == GL_UNSIGNED_SHORT) {
+ const GLfloat scale = value * CHAN_MAXF / ACCUM_SCALE16;
+ GLuint buffer, i;
+
+ /* XXX maybe transpose the 'i' and 'buffer' loops??? */
+ for (i = 0; i < height; i++) {
+ GLchan rgba[MAX_WIDTH][4];
+ GLshort accumRow[4 * MAX_WIDTH];
+ GLshort *acc;
+
+ if (directAccess) {
+ acc = (GLshort *) accumRb->GetPointer(ctx, accumRb, xpos, ypos +i);
+ }
+ else {
+ accumRb->GetRow(ctx, accumRb, width, xpos, ypos + i, accumRow);
+ acc = accumRow;
+ }
+
+ /* get the colors to return */
+ if (swrast->_IntegerAccumMode) {
+ GLint j;
+ for (j = 0; j < width; j++) {
+ ASSERT(acc[j * 4 + 0] < max);
+ ASSERT(acc[j * 4 + 1] < max);
+ ASSERT(acc[j * 4 + 2] < max);
+ ASSERT(acc[j * 4 + 3] < max);
+ rgba[j][RCOMP] = multTable[acc[j * 4 + 0]];
+ rgba[j][GCOMP] = multTable[acc[j * 4 + 1]];
+ rgba[j][BCOMP] = multTable[acc[j * 4 + 2]];
+ rgba[j][ACOMP] = multTable[acc[j * 4 + 3]];
+ }
+ }
+ else {
+ /* scaled integer (or float) accum buffer */
+ GLint j;
+ for (j = 0; j < width; j++) {
+ GLint r = IROUND( (GLfloat) (acc[j * 4 + 0]) * scale );
+ GLint g = IROUND( (GLfloat) (acc[j * 4 + 1]) * scale );
+ GLint b = IROUND( (GLfloat) (acc[j * 4 + 2]) * scale );
+ GLint a = IROUND( (GLfloat) (acc[j * 4 + 3]) * scale );
+ rgba[j][RCOMP] = CLAMP( r, 0, CHAN_MAX );
+ rgba[j][GCOMP] = CLAMP( g, 0, CHAN_MAX );
+ rgba[j][BCOMP] = CLAMP( b, 0, CHAN_MAX );
+ rgba[j][ACOMP] = CLAMP( a, 0, CHAN_MAX );
+ }
+ }
+
+ /* store colors */
+ for (buffer = 0; buffer < fb->_NumColorDrawBuffers[0]; buffer++) {
+ struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[0][buffer];
+ if (masking) {
+ _swrast_mask_rgba_array(ctx, rb, width, xpos, ypos + i, rgba);
+ }
+ rb->PutRow(ctx, rb, width, xpos, ypos + i, rgba, NULL);
+ }
+ }
+ }
+ else {
+ /* other types someday */
+ }
+}
+
+
+
+/**
+ * Software fallback for glAccum.
+ */
+void
+_swrast_Accum( GLcontext *ctx, GLenum op, GLfloat value,
+ GLint xpos, GLint ypos,
+ GLint width, GLint height )
+
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ if (SWRAST_CONTEXT(ctx)->NewState)
+ _swrast_validate_derived( ctx );
+
+ if (!ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer) {
+ _mesa_warning(ctx, "Calling glAccum() without an accumulation buffer");
+ return;
+ }
+
+ RENDER_START(swrast, ctx);
+
+ switch (op) {
+ case GL_ADD:
+ if (value != 0.0F) {
+ accum_add(ctx, value, xpos, ypos, width, height);
+ }
+ break;
+ case GL_MULT:
+ if (value != 1.0F) {
+ accum_mult(ctx, value, xpos, ypos, width, height);
+ }
+ break;
+ case GL_ACCUM:
+ if (value != 0.0F) {
+ accum_accum(ctx, value, xpos, ypos, width, height);
+ }
+ break;
+ case GL_LOAD:
+ accum_load(ctx, value, xpos, ypos, width, height);
+ break;
+ case GL_RETURN:
+ accum_return(ctx, value, xpos, ypos, width, height);
+ break;
+ default:
+ _mesa_problem(ctx, "invalid mode in _swrast_Accum()");
+ break;
+ }
+
+ RENDER_FINISH(swrast, ctx);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_accum.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_accum.h
new file mode 100644
index 000000000..97d2bef4c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_accum.h
@@ -0,0 +1,37 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_ACCUM_H
+#define S_ACCUM_H
+
+
+#include "mtypes.h"
+
+
+extern void
+_swrast_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_alpha.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_alpha.c
new file mode 100644
index 000000000..55c1e6a58
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_alpha.c
@@ -0,0 +1,224 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file swrast/s_alpha.c
+ * \brief Functions to apply alpha test.
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "colormac.h"
+#include "macros.h"
+
+#include "s_alpha.h"
+#include "s_context.h"
+
+
+/**
+ * \fn GLint _swrast_alpha_test( const GLcontext *ctx, struct sw_span *span )
+ * \brief Apply the alpha test to a span of pixels.
+ * \return
+ * - "0" = all pixels in the span failed the alpha test.
+ * - "1" = one or more pixels passed the alpha test.
+ */
+GLint
+_swrast_alpha_test( const GLcontext *ctx, struct sw_span *span )
+{
+ const GLchan (*rgba)[4] = (const GLchan (*)[4]) span->array->rgba;
+ GLchan ref;
+ const GLuint n = span->end;
+ GLubyte *mask = span->array->mask;
+ GLuint i;
+
+ CLAMPED_FLOAT_TO_CHAN(ref, ctx->Color.AlphaRef);
+
+ if (span->arrayMask & SPAN_RGBA) {
+ /* Use the array values */
+ switch (ctx->Color.AlphaFunc) {
+ case GL_LESS:
+ for (i = 0; i < n; i++)
+ mask[i] &= (rgba[i][ACOMP] < ref);
+ break;
+ case GL_LEQUAL:
+ for (i = 0; i < n; i++)
+ mask[i] &= (rgba[i][ACOMP] <= ref);
+ break;
+ case GL_GEQUAL:
+ for (i = 0; i < n; i++)
+ mask[i] &= (rgba[i][ACOMP] >= ref);
+ break;
+ case GL_GREATER:
+ for (i = 0; i < n; i++)
+ mask[i] &= (rgba[i][ACOMP] > ref);
+ break;
+ case GL_NOTEQUAL:
+ for (i = 0; i < n; i++)
+ mask[i] &= (rgba[i][ACOMP] != ref);
+ break;
+ case GL_EQUAL:
+ for (i = 0; i < n; i++)
+ mask[i] &= (rgba[i][ACOMP] == ref);
+ break;
+ case GL_ALWAYS:
+ /* do nothing */
+ return 1;
+ case GL_NEVER:
+ /* caller should check for zero! */
+ span->writeAll = GL_FALSE;
+ return 0;
+ default:
+ _mesa_problem( ctx, "Invalid alpha test in _swrast_alpha_test" );
+ return 0;
+ }
+ }
+ else {
+ /* Use the interpolation values */
+#if CHAN_TYPE == GL_FLOAT
+ const GLfloat alphaStep = span->alphaStep;
+ GLfloat alpha = span->alpha;
+ ASSERT(span->interpMask & SPAN_RGBA);
+ switch (ctx->Color.AlphaFunc) {
+ case GL_LESS:
+ for (i = 0; i < n; i++) {
+ mask[i] &= (alpha < ref);
+ alpha += alphaStep;
+ }
+ break;
+ case GL_LEQUAL:
+ for (i = 0; i < n; i++) {
+ mask[i] &= (alpha <= ref);
+ alpha += alphaStep;
+ }
+ break;
+ case GL_GEQUAL:
+ for (i = 0; i < n; i++) {
+ mask[i] &= (alpha >= ref);
+ alpha += alphaStep;
+ }
+ break;
+ case GL_GREATER:
+ for (i = 0; i < n; i++) {
+ mask[i] &= (alpha > ref);
+ alpha += alphaStep;
+ }
+ break;
+ case GL_NOTEQUAL:
+ for (i = 0; i < n; i++) {
+ mask[i] &= (alpha != ref);
+ alpha += alphaStep;
+ }
+ break;
+ case GL_EQUAL:
+ for (i = 0; i < n; i++) {
+ mask[i] &= (alpha == ref);
+ alpha += alphaStep;
+ }
+ break;
+ case GL_ALWAYS:
+ /* do nothing */
+ return 1;
+ case GL_NEVER:
+ /* caller should check for zero! */
+ span->writeAll = GL_FALSE;
+ return 0;
+ default:
+ _mesa_problem( ctx, "Invalid alpha test in gl_alpha_test" );
+ return 0;
+ }
+#else
+ /* 8 or 16-bit channel interpolation */
+ const GLfixed alphaStep = span->alphaStep;
+ GLfixed alpha = span->alpha;
+ ASSERT(span->interpMask & SPAN_RGBA);
+ switch (ctx->Color.AlphaFunc) {
+ case GL_LESS:
+ for (i = 0; i < n; i++) {
+ mask[i] &= (FixedToChan(alpha) < ref);
+ alpha += alphaStep;
+ }
+ break;
+ case GL_LEQUAL:
+ for (i = 0; i < n; i++) {
+ mask[i] &= (FixedToChan(alpha) <= ref);
+ alpha += alphaStep;
+ }
+ break;
+ case GL_GEQUAL:
+ for (i = 0; i < n; i++) {
+ mask[i] &= (FixedToChan(alpha) >= ref);
+ alpha += alphaStep;
+ }
+ break;
+ case GL_GREATER:
+ for (i = 0; i < n; i++) {
+ mask[i] &= (FixedToChan(alpha) > ref);
+ alpha += alphaStep;
+ }
+ break;
+ case GL_NOTEQUAL:
+ for (i = 0; i < n; i++) {
+ mask[i] &= (FixedToChan(alpha) != ref);
+ alpha += alphaStep;
+ }
+ break;
+ case GL_EQUAL:
+ for (i = 0; i < n; i++) {
+ mask[i] &= (FixedToChan(alpha) == ref);
+ alpha += alphaStep;
+ }
+ break;
+ case GL_ALWAYS:
+ /* do nothing */
+ return 1;
+ case GL_NEVER:
+ /* caller should check for zero! */
+ span->writeAll = GL_FALSE;
+ return 0;
+ default:
+ _mesa_problem( ctx, "Invalid alpha test in gl_alpha_test" );
+ return 0;
+ }
+#endif /* CHAN_TYPE */
+ }
+
+#if 0
+ /* XXXX This causes conformance failures!!!! */
+ while ((span->start <= span->end) &&
+ (mask[span->start] == 0))
+ span->start ++;
+
+ while ((span->end >= span->start) &&
+ (mask[span->end] == 0))
+ span->end --;
+#endif
+
+ span->writeAll = GL_FALSE;
+
+ if (span->start >= span->end)
+ return 0;
+ else
+ return 1;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_alpha.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_alpha.h
new file mode 100644
index 000000000..add0f74c4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_alpha.h
@@ -0,0 +1,39 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_ALPHA_H
+#define S_ALPHA_H
+
+
+#include "mtypes.h"
+#include "s_context.h"
+
+
+extern GLint
+_swrast_alpha_test( const GLcontext *ctx, struct sw_span *span );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_atifragshader.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_atifragshader.c
new file mode 100644
index 000000000..d137b17d2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_atifragshader.c
@@ -0,0 +1,625 @@
+/*
+ *
+ * Copyright (C) 2004 David Airlie 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
+ * DAVID AIRLIE 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.
+ */
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "atifragshader.h"
+#include "macros.h"
+#include "program.h"
+
+#include "s_atifragshader.h"
+#include "s_nvfragprog.h"
+#include "s_span.h"
+#include "s_texture.h"
+
+/**
+ * Fetch a texel.
+ */
+static void
+fetch_texel(GLcontext * ctx, const GLfloat texcoord[4], GLfloat lambda,
+ GLuint unit, GLfloat color[4])
+{
+ GLchan rgba[4];
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ /* XXX use a float-valued TextureSample routine here!!! */
+ swrast->TextureSample[unit] (ctx, unit, ctx->Texture.Unit[unit]._Current,
+ 1, (const GLfloat(*)[4]) texcoord,
+ &lambda, &rgba);
+ color[0] = CHAN_TO_FLOAT(rgba[0]);
+ color[1] = CHAN_TO_FLOAT(rgba[1]);
+ color[2] = CHAN_TO_FLOAT(rgba[2]);
+ color[3] = CHAN_TO_FLOAT(rgba[3]);
+}
+
+static void
+apply_swizzle(struct atifs_machine *machine, GLuint reg, GLuint swizzle)
+{
+ GLfloat s, t, r, q;
+
+ s = machine->Registers[reg][0];
+ t = machine->Registers[reg][1];
+ r = machine->Registers[reg][2];
+ q = machine->Registers[reg][3];
+
+ switch (swizzle) {
+ case GL_SWIZZLE_STR_ATI:
+ machine->Registers[reg][0] = s;
+ machine->Registers[reg][1] = t;
+ machine->Registers[reg][2] = r;
+ break;
+ case GL_SWIZZLE_STQ_ATI:
+ machine->Registers[reg][0] = s;
+ machine->Registers[reg][1] = t;
+ machine->Registers[reg][2] = q;
+ break;
+ case GL_SWIZZLE_STR_DR_ATI:
+ machine->Registers[reg][0] = s / r;
+ machine->Registers[reg][1] = t / r;
+ machine->Registers[reg][2] = 1 / r;
+ break;
+ case GL_SWIZZLE_STQ_DQ_ATI:
+ machine->Registers[reg][0] = s / q;
+ machine->Registers[reg][1] = t / q;
+ machine->Registers[reg][2] = 1 / q;
+ break;
+ }
+ machine->Registers[reg][3] = 0.0;
+}
+
+static void
+apply_src_rep(GLint optype, GLuint rep, GLfloat * val)
+{
+ GLint i;
+ GLint start, end;
+ if (!rep)
+ return;
+
+ start = optype ? 3 : 0;
+ end = optype ? 4 : 3;
+
+ for (i = start; i < end; i++) {
+ switch (rep) {
+ case GL_RED:
+ val[i] = val[0];
+ break;
+ case GL_GREEN:
+ val[i] = val[1];
+ break;
+ case GL_BLUE:
+ val[i] = val[2];
+ break;
+ case GL_ALPHA:
+ val[i] = val[3];
+ break;
+ }
+ }
+}
+
+static void
+apply_src_mod(GLint optype, GLuint mod, GLfloat * val)
+{
+ GLint i;
+ GLint start, end;
+
+ if (!mod)
+ return;
+
+ start = optype ? 3 : 0;
+ end = optype ? 4 : 3;
+
+ for (i = start; i < end; i++) {
+ if (mod & GL_COMP_BIT_ATI)
+ val[i] = 1 - val[i];
+
+ if (mod & GL_BIAS_BIT_ATI)
+ val[i] = val[i] - 0.5;
+
+ if (mod & GL_2X_BIT_ATI)
+ val[i] = 2 * val[i];
+
+ if (mod & GL_NEGATE_BIT_ATI)
+ val[i] = -val[i];
+ }
+}
+
+static void
+apply_dst_mod(GLuint optype, GLuint mod, GLfloat * val)
+{
+ GLint i;
+ GLint has_sat = mod & GL_SATURATE_BIT_ATI;
+ GLint start, end;
+
+ mod &= ~GL_SATURATE_BIT_ATI;
+
+ start = optype ? 3 : 0;
+ end = optype ? 4 : 3;
+
+ for (i = start; i < end; i++) {
+ switch (mod) {
+ case GL_2X_BIT_ATI:
+ val[i] = 2 * val[i];
+ break;
+ case GL_4X_BIT_ATI:
+ val[i] = 4 * val[i];
+ break;
+ case GL_8X_BIT_ATI:
+ val[i] = 8 * val[i];
+ break;
+ case GL_HALF_BIT_ATI:
+ val[i] = val[i] * 0.5;
+ break;
+ case GL_QUARTER_BIT_ATI:
+ val[i] = val[i] * 0.25;
+ break;
+ case GL_EIGHTH_BIT_ATI:
+ val[i] = val[i] * 0.125;
+ break;
+ }
+
+ if (has_sat) {
+ if (val[i] < 0.0)
+ val[i] = 0;
+ else if (val[i] > 1.0)
+ val[i] = 1.0;
+ }
+ else {
+ if (val[i] < -8.0)
+ val[i] = -8.0;
+ else if (val[i] > 8.0)
+ val[i] = 8.0;
+ }
+ }
+}
+
+
+static void
+write_dst_addr(GLuint optype, GLuint mod, GLuint mask, GLfloat * src,
+ GLfloat * dst)
+{
+ GLint i;
+ apply_dst_mod(optype, mod, src);
+
+ if (optype == ATI_FRAGMENT_SHADER_COLOR_OP) {
+ if (mask) {
+ if (mask & GL_RED_BIT_ATI)
+ dst[0] = src[0];
+
+ if (mask & GL_GREEN_BIT_ATI)
+ dst[1] = src[1];
+
+ if (mask & GL_BLUE_BIT_ATI)
+ dst[2] = src[2];
+ }
+ else {
+ for (i = 0; i < 3; i++)
+ dst[i] = src[i];
+ }
+ }
+ else
+ dst[3] = src[3];
+}
+
+static void
+finish_pass(struct atifs_machine *machine)
+{
+ GLint i;
+
+ for (i = 0; i < 6; i++) {
+ COPY_4V(machine->PrevPassRegisters[i], machine->Registers[i]);
+ }
+}
+
+/**
+ * Execute the given fragment shader
+ * NOTE: we do everything in single-precision floating point; we don't
+ * currently observe the single/half/fixed-precision qualifiers.
+ * \param ctx - rendering context
+ * \param program - the fragment program to execute
+ * \param machine - machine state (register file)
+ * \param maxInst - max number of instructions to execute
+ * \return GL_TRUE if program completed or GL_FALSE if program executed KIL.
+ */
+
+struct ati_fs_opcode_st ati_fs_opcodes[] = {
+ {GL_ADD_ATI, 2},
+ {GL_SUB_ATI, 2},
+ {GL_MUL_ATI, 2},
+ {GL_MAD_ATI, 3},
+ {GL_LERP_ATI, 3},
+ {GL_MOV_ATI, 1},
+ {GL_CND_ATI, 3},
+ {GL_CND0_ATI, 3},
+ {GL_DOT2_ADD_ATI, 3},
+ {GL_DOT3_ATI, 2},
+ {GL_DOT4_ATI, 2}
+};
+
+
+
+static void
+handle_pass_op(struct atifs_machine *machine, struct atifs_instruction *inst,
+ const struct sw_span *span, GLuint column)
+{
+ GLuint idx = inst->DstReg[0].Index - GL_REG_0_ATI;
+ GLuint swizzle = inst->DstReg[0].Swizzle;
+ GLuint pass_tex = inst->SrcReg[0][0].Index;
+
+ /* if we get here after passing pass one then we are starting pass two - backup the registers */
+ if (machine->pass == 1) {
+ finish_pass(machine);
+ machine->pass = 2;
+ }
+ if (pass_tex >= GL_TEXTURE0_ARB && pass_tex <= GL_TEXTURE7_ARB) {
+ pass_tex -= GL_TEXTURE0_ARB;
+ COPY_4V(machine->Registers[idx],
+ span->array->texcoords[pass_tex][column]);
+ }
+ else if (pass_tex >= GL_REG_0_ATI && pass_tex <= GL_REG_5_ATI
+ && machine->pass == 2) {
+ pass_tex -= GL_REG_0_ATI;
+ COPY_4V(machine->Registers[idx], machine->PrevPassRegisters[pass_tex]);
+ }
+ apply_swizzle(machine, idx, swizzle);
+
+}
+
+static void
+handle_sample_op(GLcontext * ctx, struct atifs_machine *machine,
+ struct atifs_instruction *inst, const struct sw_span *span,
+ GLuint column)
+{
+ GLuint idx = inst->DstReg[0].Index - GL_REG_0_ATI;
+ GLuint swizzle = inst->DstReg[0].Swizzle;
+ GLuint sample_tex = inst->SrcReg[0][0].Index;
+
+ /* if we get here after passing pass one then we are starting pass two - backup the registers */
+ if (machine->pass == 1) {
+ finish_pass(machine);
+ machine->pass = 2;
+ }
+
+ if (sample_tex >= GL_TEXTURE0_ARB && sample_tex <= GL_TEXTURE7_ARB) {
+ sample_tex -= GL_TEXTURE0_ARB;
+ fetch_texel(ctx, span->array->texcoords[sample_tex][column], 0.0F,
+ sample_tex, machine->Registers[idx]);
+ }
+ else if (sample_tex >= GL_REG_0_ATI && sample_tex <= GL_REG_5_ATI) {
+ /* this is wrong... */
+ sample_tex -= GL_REG_0_ATI;
+ fetch_texel(ctx, machine->Registers[sample_tex], 0, sample_tex,
+ machine->Registers[idx]);
+ }
+
+ apply_swizzle(machine, idx, swizzle);
+}
+
+#define SETUP_SRC_REG(optype, i, x) do { \
+ if (optype) \
+ src[optype][i][3] = x[3]; \
+ else \
+ COPY_3V(src[optype][i], x); \
+ } while (0)
+
+static GLboolean
+execute_shader(GLcontext * ctx,
+ const struct ati_fragment_shader *shader, GLuint maxInst,
+ struct atifs_machine *machine, const struct sw_span *span,
+ GLuint column)
+{
+ GLuint pc;
+ struct atifs_instruction *inst;
+ GLint optype;
+ GLint i;
+ GLint dstreg;
+ GLfloat src[2][3][4];
+ GLfloat zeros[4] = { 0.0, 0.0, 0.0, 0.0 };
+ GLfloat ones[4] = { 1.0, 1.0, 1.0, 1.0 };
+ GLfloat dst[2][4], *dstp;
+
+ for (pc = 0; pc < shader->Base.NumInstructions; pc++) {
+ inst = &shader->Instructions[pc];
+
+ if (inst->Opcode[0] == ATI_FRAGMENT_SHADER_PASS_OP)
+ handle_pass_op(machine, inst, span, column);
+ else if (inst->Opcode[0] == ATI_FRAGMENT_SHADER_SAMPLE_OP)
+ handle_sample_op(ctx, machine, inst, span, column);
+ else {
+ if (machine->pass == 0)
+ machine->pass = 1;
+
+ /* setup the source registers for color and alpha ops */
+ for (optype = 0; optype < 2; optype++) {
+ for (i = 0; i < inst->ArgCount[optype]; i++) {
+ GLint index = inst->SrcReg[optype][i].Index;
+
+ if (index >= GL_REG_0_ATI && index <= GL_REG_5_ATI)
+ SETUP_SRC_REG(optype, i,
+ machine->Registers[index - GL_REG_0_ATI]);
+ else if (index >= GL_CON_0_ATI && index <= GL_CON_7_ATI)
+ SETUP_SRC_REG(optype, i,
+ shader->Constants[index - GL_CON_0_ATI]);
+ else if (index == GL_ONE)
+ SETUP_SRC_REG(optype, i, ones);
+ else if (index == GL_ZERO)
+ SETUP_SRC_REG(optype, i, zeros);
+ else if (index == GL_PRIMARY_COLOR_EXT)
+ SETUP_SRC_REG(optype, i,
+ machine->Inputs[ATI_FS_INPUT_PRIMARY]);
+ else if (index == GL_SECONDARY_INTERPOLATOR_ATI)
+ SETUP_SRC_REG(optype, i,
+ machine->Inputs[ATI_FS_INPUT_SECONDARY]);
+
+ apply_src_rep(optype, inst->SrcReg[optype][i].argRep,
+ src[optype][i]);
+ apply_src_mod(optype, inst->SrcReg[optype][i].argMod,
+ src[optype][i]);
+ }
+ }
+
+ /* Execute the operations - color then alpha */
+ for (optype = 0; optype < 2; optype++) {
+ if (inst->Opcode[optype]) {
+ switch (inst->Opcode[optype]) {
+ case GL_ADD_ATI:
+ if (!optype)
+ for (i = 0; i < 3; i++) {
+ dst[optype][i] =
+ src[optype][0][i] + src[optype][1][i];
+ }
+ else
+ dst[optype][3] = src[optype][0][3] + src[optype][1][3];
+ break;
+ case GL_SUB_ATI:
+ if (!optype)
+ for (i = 0; i < 3; i++) {
+ dst[optype][i] =
+ src[optype][0][i] - src[optype][1][i];
+ }
+ else
+ dst[optype][3] = src[optype][0][3] - src[optype][1][3];
+ break;
+ case GL_MUL_ATI:
+ if (!optype)
+ for (i = 0; i < 3; i++) {
+ dst[optype][i] =
+ src[optype][0][i] * src[optype][1][i];
+ }
+ else
+ dst[optype][3] = src[optype][0][3] * src[optype][1][3];
+ break;
+ case GL_MAD_ATI:
+ if (!optype)
+ for (i = 0; i < 3; i++) {
+ dst[optype][i] =
+ src[optype][0][i] * src[optype][1][i] +
+ src[optype][2][i];
+ }
+ else
+ dst[optype][3] =
+ src[optype][0][3] * src[optype][1][3] +
+ src[optype][2][3];
+ break;
+ case GL_LERP_ATI:
+ if (!optype)
+ for (i = 0; i < 3; i++) {
+ dst[optype][i] =
+ src[optype][0][i] * src[optype][1][i] + (1 -
+ src
+ [optype]
+ [0][i]) *
+ src[optype][2][i];
+ }
+ else
+ dst[optype][3] =
+ src[optype][0][3] * src[optype][1][3] + (1 -
+ src[optype]
+ [0][3]) *
+ src[optype][2][3];
+ break;
+
+ case GL_MOV_ATI:
+ if (!optype)
+ for (i = 0; i < 3; i++) {
+ dst[optype][i] = src[optype][0][i];
+ }
+ else
+ dst[optype][3] = src[optype][0][3];
+ break;
+ case GL_CND_ATI:
+ if (!optype) {
+ for (i = 0; i < 3; i++) {
+ dst[optype][i] =
+ (src[optype][2][i] >
+ 0.5) ? src[optype][0][i] : src[optype][1][i];
+ }
+ }
+ else {
+ dst[optype][3] =
+ (src[optype][2][3] >
+ 0.5) ? src[optype][0][3] : src[optype][1][3];
+ }
+ break;
+
+ case GL_CND0_ATI:
+ if (!optype)
+ for (i = 0; i < 3; i++) {
+ dst[optype][i] =
+ (src[optype][2][i] >=
+ 0) ? src[optype][0][i] : src[optype][1][i];
+ }
+ else {
+ dst[optype][3] =
+ (src[optype][2][3] >=
+ 0) ? src[optype][0][3] : src[optype][1][3];
+ }
+ break;
+ case GL_DOT2_ADD_ATI:
+ {
+ GLfloat result;
+
+ /* DOT 2 always uses the source from the color op */
+ result = src[0][0][0] * src[0][1][0] +
+ src[0][0][1] * src[0][1][1] + src[0][2][2];
+ if (!optype) {
+ for (i = 0; i < 3; i++) {
+ dst[optype][i] = result;
+ }
+ }
+ else
+ dst[optype][3] = result;
+
+ }
+ break;
+ case GL_DOT3_ATI:
+ {
+ GLfloat result;
+
+ /* DOT 3 always uses the source from the color op */
+ result = src[0][0][0] * src[0][1][0] +
+ src[0][0][1] * src[0][1][1] +
+ src[0][0][2] * src[0][1][2];
+
+ if (!optype) {
+ for (i = 0; i < 3; i++) {
+ dst[optype][i] = result;
+ }
+ }
+ else
+ dst[optype][3] = result;
+ }
+ break;
+ case GL_DOT4_ATI:
+ {
+ GLfloat result;
+
+ /* DOT 4 always uses the source from the color op */
+ result = src[optype][0][0] * src[0][1][0] +
+ src[0][0][1] * src[0][1][1] +
+ src[0][0][2] * src[0][1][2] +
+ src[0][0][3] * src[0][1][3];
+ if (!optype) {
+ for (i = 0; i < 3; i++) {
+ dst[optype][i] = result;
+ }
+ }
+ else
+ dst[optype][3] = result;
+ }
+ break;
+
+ }
+ }
+ }
+
+ /* write out the destination registers */
+ for (optype = 0; optype < 2; optype++) {
+ if (inst->Opcode[optype]) {
+ dstreg = inst->DstReg[optype].Index;
+ dstp = machine->Registers[dstreg - GL_REG_0_ATI];
+
+ write_dst_addr(optype, inst->DstReg[optype].dstMod,
+ inst->DstReg[optype].dstMask, dst[optype],
+ dstp);
+ }
+ }
+ }
+ }
+ return GL_TRUE;
+}
+
+static void
+init_machine(GLcontext * ctx, struct atifs_machine *machine,
+ const struct ati_fragment_shader *shader,
+ const struct sw_span *span, GLuint col)
+{
+ GLint i, j;
+
+ for (i = 0; i < 6; i++) {
+ for (j = 0; j < 4; j++)
+ ctx->ATIFragmentShader.Machine.Registers[i][j] = 0.0;
+
+ }
+
+ ctx->ATIFragmentShader.Machine.Inputs[ATI_FS_INPUT_PRIMARY][0] =
+ CHAN_TO_FLOAT(span->array->rgba[col][0]);
+ ctx->ATIFragmentShader.Machine.Inputs[ATI_FS_INPUT_PRIMARY][1] =
+ CHAN_TO_FLOAT(span->array->rgba[col][1]);
+ ctx->ATIFragmentShader.Machine.Inputs[ATI_FS_INPUT_PRIMARY][2] =
+ CHAN_TO_FLOAT(span->array->rgba[col][2]);
+ ctx->ATIFragmentShader.Machine.Inputs[ATI_FS_INPUT_PRIMARY][3] =
+ CHAN_TO_FLOAT(span->array->rgba[col][3]);
+
+ ctx->ATIFragmentShader.Machine.Inputs[ATI_FS_INPUT_SECONDARY][0] =
+ CHAN_TO_FLOAT(span->array->spec[col][0]);
+ ctx->ATIFragmentShader.Machine.Inputs[ATI_FS_INPUT_SECONDARY][1] =
+ CHAN_TO_FLOAT(span->array->spec[col][1]);
+ ctx->ATIFragmentShader.Machine.Inputs[ATI_FS_INPUT_SECONDARY][2] =
+ CHAN_TO_FLOAT(span->array->spec[col][2]);
+ ctx->ATIFragmentShader.Machine.Inputs[ATI_FS_INPUT_SECONDARY][3] =
+ CHAN_TO_FLOAT(span->array->spec[col][3]);
+
+ ctx->ATIFragmentShader.Machine.pass = 0;
+}
+
+
+
+/**
+ * Execute the current fragment program, operating on the given span.
+ */
+void
+_swrast_exec_fragment_shader(GLcontext * ctx, struct sw_span *span)
+{
+ const struct ati_fragment_shader *shader = ctx->ATIFragmentShader.Current;
+ GLuint i;
+
+ ctx->_CurrentProgram = GL_FRAGMENT_SHADER_ATI;
+
+ for (i = 0; i < span->end; i++) {
+ if (span->array->mask[i]) {
+ init_machine(ctx, &ctx->ATIFragmentShader.Machine,
+ ctx->ATIFragmentShader.Current, span, i);
+
+ if (execute_shader(ctx, shader, ~0,
+ &ctx->ATIFragmentShader.Machine, span, i)) {
+ span->array->mask[i] = GL_FALSE;
+ }
+
+ {
+ const GLfloat *colOut =
+ ctx->ATIFragmentShader.Machine.Registers[0];
+
+ /*fprintf(stderr,"outputs %f %f %f %f\n", colOut[0], colOut[1], colOut[2], colOut[3]); */
+ UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][RCOMP], colOut[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][GCOMP], colOut[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][BCOMP], colOut[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][ACOMP], colOut[3]);
+ }
+ }
+
+ }
+
+
+ ctx->_CurrentProgram = 0;
+
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_atifragshader.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_atifragshader.h
new file mode 100644
index 000000000..269be1f2e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_atifragshader.h
@@ -0,0 +1,37 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2003 David Airlie 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
+ * DAVID AIRLIE BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_ATIFRAGSHADER_H
+#define S_ATIFRAGSHADER_H
+
+
+#include "s_context.h"
+
+
+extern void
+_swrast_exec_fragment_shader( GLcontext *ctx, struct sw_span *span );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_bitmap.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_bitmap.c
new file mode 100644
index 000000000..dd5008cf6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_bitmap.c
@@ -0,0 +1,282 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file swrast/s_bitmap.c
+ * \brief glBitmap rendering.
+ * \author Brian Paul
+ */
+
+#include "glheader.h"
+#include "bufferobj.h"
+#include "image.h"
+#include "macros.h"
+#include "pixel.h"
+
+#include "s_context.h"
+#include "s_span.h"
+
+
+
+/*
+ * Render a bitmap.
+ */
+void
+_swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLint row, col;
+ GLuint count = 0;
+ struct sw_span span;
+
+ ASSERT(ctx->RenderMode == GL_RENDER);
+
+ if (unpack->BufferObj->Name) {
+ /* unpack from PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
+ GL_COLOR_INDEX, GL_BITMAP,
+ (GLvoid *) bitmap)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,"glBitmap(invalid PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ GL_READ_ONLY_ARB,
+ unpack->BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glBitmap(PBO is mapped)");
+ return;
+ }
+ bitmap = ADD_POINTERS(buf, bitmap);
+ }
+
+ RENDER_START(swrast,ctx);
+
+ if (SWRAST_CONTEXT(ctx)->NewState)
+ _swrast_validate_derived( ctx );
+
+ INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_XY);
+
+ if (ctx->Visual.rgbMode) {
+ span.interpMask |= SPAN_RGBA;
+ span.red = FloatToFixed(ctx->Current.RasterColor[0] * CHAN_MAXF);
+ span.green = FloatToFixed(ctx->Current.RasterColor[1] * CHAN_MAXF);
+ span.blue = FloatToFixed(ctx->Current.RasterColor[2] * CHAN_MAXF);
+ span.alpha = FloatToFixed(ctx->Current.RasterColor[3] * CHAN_MAXF);
+ span.redStep = span.greenStep = span.blueStep = span.alphaStep = 0;
+ }
+ else {
+ span.interpMask |= SPAN_INDEX;
+ span.index = FloatToFixed(ctx->Current.RasterIndex);
+ span.indexStep = 0;
+ }
+
+ if (ctx->Depth.Test)
+ _swrast_span_default_z(ctx, &span);
+ if (swrast->_FogEnabled)
+ _swrast_span_default_fog(ctx, &span);
+ if (ctx->Texture._EnabledCoordUnits)
+ _swrast_span_default_texcoords(ctx, &span);
+
+ for (row = 0; row < height; row++) {
+ const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack,
+ bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0);
+
+ if (unpack->LsbFirst) {
+ /* Lsb first */
+ GLubyte mask = 1U << (unpack->SkipPixels & 0x7);
+ for (col = 0; col < width; col++) {
+ if (*src & mask) {
+ span.array->x[count] = px + col;
+ span.array->y[count] = py + row;
+ count++;
+ }
+ if (mask == 128U) {
+ src++;
+ mask = 1U;
+ }
+ else {
+ mask = mask << 1;
+ }
+ }
+
+ /* get ready for next row */
+ if (mask != 1)
+ src++;
+ }
+ else {
+ /* Msb first */
+ GLubyte mask = 128U >> (unpack->SkipPixels & 0x7);
+ for (col = 0; col < width; col++) {
+ if (*src & mask) {
+ span.array->x[count] = px + col;
+ span.array->y[count] = py + row;
+ count++;
+ }
+ if (mask == 1U) {
+ src++;
+ mask = 128U;
+ }
+ else {
+ mask = mask >> 1;
+ }
+ }
+
+ /* get ready for next row */
+ if (mask != 128)
+ src++;
+ }
+
+ if (count + width >= MAX_WIDTH || row + 1 == height) {
+ /* flush the span */
+ span.end = count;
+ if (ctx->Visual.rgbMode)
+ _swrast_write_rgba_span(ctx, &span);
+ else
+ _swrast_write_index_span(ctx, &span);
+ span.end = 0;
+ count = 0;
+ }
+ }
+
+ RENDER_FINISH(swrast,ctx);
+
+ if (unpack->BufferObj->Name) {
+ /* done with PBO so unmap it now */
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ unpack->BufferObj);
+ }
+}
+
+
+#if 0
+/*
+ * XXX this is another way to implement Bitmap. Use horizontal runs of
+ * fragments, initializing the mask array to indicate which fragmens to
+ * draw or skip.
+ */
+void
+_swrast_Bitmap( GLcontext *ctx, GLint px, GLint py,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLint row, col;
+ struct sw_span span;
+
+ ASSERT(ctx->RenderMode == GL_RENDER);
+ ASSERT(bitmap);
+
+ RENDER_START(swrast,ctx);
+
+ if (SWRAST_CONTEXT(ctx)->NewState)
+ _swrast_validate_derived( ctx );
+
+ INIT_SPAN(span, GL_BITMAP, width, 0, SPAN_MASK);
+
+ /*span.arrayMask |= SPAN_MASK;*/ /* we'll init span.mask[] */
+ span.x = px;
+ span.y = py;
+ /*span.end = width;*/
+ if (ctx->Visual.rgbMode) {
+ span.interpMask |= SPAN_RGBA;
+ span.red = FloatToFixed(ctx->Current.RasterColor[0] * CHAN_MAXF);
+ span.green = FloatToFixed(ctx->Current.RasterColor[1] * CHAN_MAXF);
+ span.blue = FloatToFixed(ctx->Current.RasterColor[2] * CHAN_MAXF);
+ span.alpha = FloatToFixed(ctx->Current.RasterColor[3] * CHAN_MAXF);
+ span.redStep = span.greenStep = span.blueStep = span.alphaStep = 0;
+ }
+ else {
+ span.interpMask |= SPAN_INDEX;
+ span.index = FloatToFixed(ctx->Current.RasterIndex);
+ span.indexStep = 0;
+ }
+
+ if (ctx->Depth.Test)
+ _swrast_span_default_z(ctx, &span);
+ if (swrast->_FogEnabled)
+ _swrast_span_default_fog(ctx, &span);
+ if (ctx->Texture._EnabledCoordUnits)
+ _swrast_span_default_texcoords(ctx, &span);
+
+ for (row=0; row<height; row++, span.y++) {
+ const GLubyte *src = (const GLubyte *) _mesa_image_address2d(unpack,
+ bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, row, 0);
+
+ if (unpack->LsbFirst) {
+ /* Lsb first */
+ GLubyte mask = 1U << (unpack->SkipPixels & 0x7);
+ for (col=0; col<width; col++) {
+ span.array->mask[col] = (*src & mask) ? GL_TRUE : GL_FALSE;
+ if (mask == 128U) {
+ src++;
+ mask = 1U;
+ }
+ else {
+ mask = mask << 1;
+ }
+ }
+
+ if (ctx->Visual.rgbMode)
+ _swrast_write_rgba_span(ctx, &span);
+ else
+ _swrast_write_index_span(ctx, &span);
+
+ /* get ready for next row */
+ if (mask != 1)
+ src++;
+ }
+ else {
+ /* Msb first */
+ GLubyte mask = 128U >> (unpack->SkipPixels & 0x7);
+ for (col=0; col<width; col++) {
+ span.array->mask[col] = (*src & mask) ? GL_TRUE : GL_FALSE;
+ if (mask == 1U) {
+ src++;
+ mask = 128U;
+ }
+ else {
+ mask = mask >> 1;
+ }
+ }
+
+ if (ctx->Visual.rgbMode)
+ _swrast_write_rgba_span(ctx, &span);
+ else
+ _swrast_write_index_span(ctx, &span);
+
+ /* get ready for next row */
+ if (mask != 128)
+ src++;
+ }
+ }
+
+ RENDER_FINISH(swrast,ctx);
+}
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_blend.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_blend.c
new file mode 100644
index 000000000..d94ff3923
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_blend.c
@@ -0,0 +1,872 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Regarding GL_NV_blend_square:
+ *
+ * Portions of this software may use or implement intellectual
+ * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims
+ * any and all warranties with respect to such intellectual property,
+ * including any use thereof or modifications thereto.
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "colormac.h"
+#include "macros.h"
+
+#include "s_blend.h"
+#include "s_context.h"
+#include "s_span.h"
+
+
+#if defined(USE_MMX_ASM)
+#include "x86/mmx.h"
+#include "x86/common_x86_asm.h"
+#define _BLENDAPI _ASMAPI
+#else
+#define _BLENDAPI
+#endif
+
+
+/*
+ * Special case for glBlendFunc(GL_ZERO, GL_ONE)
+ */
+static void _BLENDAPI
+blend_noop( GLcontext *ctx, GLuint n, const GLubyte mask[],
+ GLchan rgba[][4], CONST GLchan dest[][4] )
+{
+ GLuint i;
+ ASSERT(ctx->Color.BlendEquationRGB==GL_FUNC_ADD);
+ ASSERT(ctx->Color.BlendEquationA==GL_FUNC_ADD);
+ ASSERT(ctx->Color.BlendSrcRGB==GL_ZERO);
+ ASSERT(ctx->Color.BlendDstRGB==GL_ONE);
+ (void) ctx;
+
+ for (i = 0; i < n; i++) {
+ if (mask[i]) {
+ COPY_CHAN4( rgba[i], dest[i] );
+ }
+ }
+}
+
+
+/*
+ * Special case for glBlendFunc(GL_ONE, GL_ZERO)
+ */
+static void _BLENDAPI
+blend_replace( GLcontext *ctx, GLuint n, const GLubyte mask[],
+ GLchan rgba[][4], CONST GLchan dest[][4] )
+{
+ ASSERT(ctx->Color.BlendEquationRGB==GL_FUNC_ADD);
+ ASSERT(ctx->Color.BlendEquationA==GL_FUNC_ADD);
+ ASSERT(ctx->Color.BlendSrcRGB==GL_ONE);
+ ASSERT(ctx->Color.BlendDstRGB==GL_ZERO);
+ (void) ctx;
+ (void) n;
+ (void) mask;
+ (void) rgba;
+ (void) dest;
+}
+
+
+/*
+ * Common transparency blending mode.
+ */
+static void _BLENDAPI
+blend_transparency( GLcontext *ctx, GLuint n, const GLubyte mask[],
+ GLchan rgba[][4], CONST GLchan dest[][4] )
+{
+ GLuint i;
+ ASSERT(ctx->Color.BlendEquationRGB==GL_FUNC_ADD);
+ ASSERT(ctx->Color.BlendEquationA==GL_FUNC_ADD);
+ ASSERT(ctx->Color.BlendSrcRGB==GL_SRC_ALPHA);
+ ASSERT(ctx->Color.BlendDstRGB==GL_ONE_MINUS_SRC_ALPHA);
+ (void) ctx;
+
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ const GLchan t = rgba[i][ACOMP]; /* t in [0, CHAN_MAX] */
+ if (t == 0) {
+ /* 0% alpha */
+ rgba[i][RCOMP] = dest[i][RCOMP];
+ rgba[i][GCOMP] = dest[i][GCOMP];
+ rgba[i][BCOMP] = dest[i][BCOMP];
+ rgba[i][ACOMP] = dest[i][ACOMP];
+ }
+ else if (t == CHAN_MAX) {
+ /* 100% alpha, no-op */
+ }
+ else {
+#if 0
+ /* This is pretty close, but Glean complains */
+ const GLint s = CHAN_MAX - t;
+ const GLint r = (rgba[i][RCOMP] * t + dest[i][RCOMP] * s + 1) >> 8;
+ const GLint g = (rgba[i][GCOMP] * t + dest[i][GCOMP] * s + 1) >> 8;
+ const GLint b = (rgba[i][BCOMP] * t + dest[i][BCOMP] * s + 1) >> 8;
+ const GLint a = (rgba[i][ACOMP] * t + dest[i][ACOMP] * s + 1) >> 8;
+#elif 0
+ /* This is slower but satisfies Glean */
+ const GLint s = CHAN_MAX - t;
+ const GLint r = (rgba[i][RCOMP] * t + dest[i][RCOMP] * s) / 255;
+ const GLint g = (rgba[i][GCOMP] * t + dest[i][GCOMP] * s) / 255;
+ const GLint b = (rgba[i][BCOMP] * t + dest[i][BCOMP] * s) / 255;
+ const GLint a = (rgba[i][ACOMP] * t + dest[i][ACOMP] * s) / 255;
+#else
+#if CHAN_BITS == 8
+ /* This satisfies Glean and should be reasonably fast */
+ /* Contributed by Nathan Hand */
+#if 0
+#define DIV255(X) (((X) << 8) + (X) + 256) >> 16
+#else
+ GLint temp;
+#define DIV255(X) (temp = (X), ((temp << 8) + temp + 256) >> 16)
+#endif
+ const GLint r = DIV255((rgba[i][RCOMP] - dest[i][RCOMP]) * t) + dest[i][RCOMP];
+ const GLint g = DIV255((rgba[i][GCOMP] - dest[i][GCOMP]) * t) + dest[i][GCOMP];
+ const GLint b = DIV255((rgba[i][BCOMP] - dest[i][BCOMP]) * t) + dest[i][BCOMP];
+ const GLint a = DIV255((rgba[i][ACOMP] - dest[i][ACOMP]) * t) + dest[i][ACOMP];
+
+#undef DIV255
+#elif CHAN_BITS == 16
+ const GLfloat tt = (GLfloat) t / CHAN_MAXF;
+ const GLint r = (GLint) ((rgba[i][RCOMP] - dest[i][RCOMP]) * tt + dest[i][RCOMP]);
+ const GLint g = (GLint) ((rgba[i][GCOMP] - dest[i][GCOMP]) * tt + dest[i][GCOMP]);
+ const GLint b = (GLint) ((rgba[i][BCOMP] - dest[i][BCOMP]) * tt + dest[i][BCOMP]);
+ const GLint a = (GLint) ((rgba[i][ACOMP] - dest[i][ACOMP]) * tt + dest[i][ACOMP]);
+#else /* CHAN_BITS == 32 */
+ const GLfloat tt = (GLfloat) t / CHAN_MAXF;
+ const GLfloat r = (rgba[i][RCOMP] - dest[i][RCOMP]) * tt + dest[i][RCOMP];
+ const GLfloat g = (rgba[i][GCOMP] - dest[i][GCOMP]) * tt + dest[i][GCOMP];
+ const GLfloat b = (rgba[i][BCOMP] - dest[i][BCOMP]) * tt + dest[i][BCOMP];
+ const GLfloat a = CLAMP( rgba[i][ACOMP], 0.0F, CHAN_MAXF ) * t +
+ CLAMP( dest[i][ACOMP], 0.0F, CHAN_MAXF ) * (1.0F - t);
+#endif
+#endif
+ ASSERT(r <= CHAN_MAX);
+ ASSERT(g <= CHAN_MAX);
+ ASSERT(b <= CHAN_MAX);
+ ASSERT(a <= CHAN_MAX);
+ rgba[i][RCOMP] = (GLchan) r;
+ rgba[i][GCOMP] = (GLchan) g;
+ rgba[i][BCOMP] = (GLchan) b;
+ rgba[i][ACOMP] = (GLchan) a;
+ }
+ }
+ }
+}
+
+
+
+/*
+ * Add src and dest.
+ */
+static void _BLENDAPI
+blend_add( GLcontext *ctx, GLuint n, const GLubyte mask[],
+ GLchan rgba[][4], CONST GLchan dest[][4] )
+{
+ GLuint i;
+ ASSERT(ctx->Color.BlendEquationRGB==GL_FUNC_ADD);
+ ASSERT(ctx->Color.BlendEquationA==GL_FUNC_ADD);
+ ASSERT(ctx->Color.BlendSrcRGB==GL_ONE);
+ ASSERT(ctx->Color.BlendDstRGB==GL_ONE);
+ (void) ctx;
+
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+#if CHAN_TYPE == GL_FLOAT
+ /* don't RGB clamp to max */
+ GLfloat a = CLAMP(rgba[i][ACOMP], 0.0F, CHAN_MAXF) + dest[i][ACOMP];
+ rgba[i][RCOMP] += dest[i][RCOMP];
+ rgba[i][GCOMP] += dest[i][GCOMP];
+ rgba[i][BCOMP] += dest[i][BCOMP];
+ rgba[i][ACOMP] = (GLchan) MIN2( a, CHAN_MAXF );
+#else
+ GLint r = rgba[i][RCOMP] + dest[i][RCOMP];
+ GLint g = rgba[i][GCOMP] + dest[i][GCOMP];
+ GLint b = rgba[i][BCOMP] + dest[i][BCOMP];
+ GLint a = rgba[i][ACOMP] + dest[i][ACOMP];
+ rgba[i][RCOMP] = (GLchan) MIN2( r, CHAN_MAX );
+ rgba[i][GCOMP] = (GLchan) MIN2( g, CHAN_MAX );
+ rgba[i][BCOMP] = (GLchan) MIN2( b, CHAN_MAX );
+ rgba[i][ACOMP] = (GLchan) MIN2( a, CHAN_MAX );
+#endif
+ }
+ }
+}
+
+
+
+/*
+ * Blend min function (for GL_EXT_blend_minmax)
+ */
+static void _BLENDAPI
+blend_min( GLcontext *ctx, GLuint n, const GLubyte mask[],
+ GLchan rgba[][4], CONST GLchan dest[][4] )
+{
+ GLuint i;
+ ASSERT(ctx->Color.BlendEquationRGB==GL_MIN);
+ ASSERT(ctx->Color.BlendEquationA==GL_MIN);
+ (void) ctx;
+
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ rgba[i][RCOMP] = (GLchan) MIN2( rgba[i][RCOMP], dest[i][RCOMP] );
+ rgba[i][GCOMP] = (GLchan) MIN2( rgba[i][GCOMP], dest[i][GCOMP] );
+ rgba[i][BCOMP] = (GLchan) MIN2( rgba[i][BCOMP], dest[i][BCOMP] );
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][ACOMP] = (GLchan) MIN2(CLAMP(rgba[i][ACOMP], 0.0F, CHAN_MAXF),
+ dest[i][ACOMP]);
+#else
+ rgba[i][ACOMP] = (GLchan) MIN2( rgba[i][ACOMP], dest[i][ACOMP] );
+#endif
+ }
+ }
+}
+
+
+
+/*
+ * Blend max function (for GL_EXT_blend_minmax)
+ */
+static void _BLENDAPI
+blend_max( GLcontext *ctx, GLuint n, const GLubyte mask[],
+ GLchan rgba[][4], CONST GLchan dest[][4] )
+{
+ GLuint i;
+ ASSERT(ctx->Color.BlendEquationRGB==GL_MAX);
+ ASSERT(ctx->Color.BlendEquationA==GL_MAX);
+ (void) ctx;
+
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ rgba[i][RCOMP] = (GLchan) MAX2( rgba[i][RCOMP], dest[i][RCOMP] );
+ rgba[i][GCOMP] = (GLchan) MAX2( rgba[i][GCOMP], dest[i][GCOMP] );
+ rgba[i][BCOMP] = (GLchan) MAX2( rgba[i][BCOMP], dest[i][BCOMP] );
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][ACOMP] = (GLchan) MAX2(CLAMP(rgba[i][ACOMP], 0.0F, CHAN_MAXF),
+ dest[i][ACOMP]);
+#else
+ rgba[i][ACOMP] = (GLchan) MAX2( rgba[i][ACOMP], dest[i][ACOMP] );
+#endif
+ }
+ }
+}
+
+
+
+/*
+ * Modulate: result = src * dest
+ */
+static void _BLENDAPI
+blend_modulate( GLcontext *ctx, GLuint n, const GLubyte mask[],
+ GLchan rgba[][4], CONST GLchan dest[][4] )
+{
+ GLuint i;
+ (void) ctx;
+
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][RCOMP] = rgba[i][RCOMP] * dest[i][RCOMP];
+ rgba[i][GCOMP] = rgba[i][GCOMP] * dest[i][GCOMP];
+ rgba[i][BCOMP] = rgba[i][BCOMP] * dest[i][BCOMP];
+ rgba[i][ACOMP] = rgba[i][ACOMP] * dest[i][ACOMP];
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ GLint r = (rgba[i][RCOMP] * dest[i][RCOMP] + 65535) >> 16;
+ GLint g = (rgba[i][GCOMP] * dest[i][GCOMP] + 65535) >> 16;
+ GLint b = (rgba[i][BCOMP] * dest[i][BCOMP] + 65535) >> 16;
+ GLint a = (rgba[i][ACOMP] * dest[i][ACOMP] + 65535) >> 16;
+ rgba[i][RCOMP] = (GLchan) r;
+ rgba[i][GCOMP] = (GLchan) g;
+ rgba[i][BCOMP] = (GLchan) b;
+ rgba[i][ACOMP] = (GLchan) a;
+#else
+ GLint r = (rgba[i][RCOMP] * dest[i][RCOMP] + 255) >> 8;
+ GLint g = (rgba[i][GCOMP] * dest[i][GCOMP] + 255) >> 8;
+ GLint b = (rgba[i][BCOMP] * dest[i][BCOMP] + 255) >> 8;
+ GLint a = (rgba[i][ACOMP] * dest[i][ACOMP] + 255) >> 8;
+ rgba[i][RCOMP] = (GLchan) r;
+ rgba[i][GCOMP] = (GLchan) g;
+ rgba[i][BCOMP] = (GLchan) b;
+ rgba[i][ACOMP] = (GLchan) a;
+#endif
+ }
+ }
+}
+
+
+
+/*
+ * General case blend pixels.
+ * Input: n - number of pixels
+ * mask - the usual write mask
+ * In/Out: rgba - the incoming and modified pixels
+ * Input: dest - the pixels from the dest color buffer
+ */
+static void _BLENDAPI
+blend_general( GLcontext *ctx, GLuint n, const GLubyte mask[],
+ GLchan rgba[][4], CONST GLchan dest[][4] )
+{
+ const GLfloat rscale = 1.0F / CHAN_MAXF;
+ const GLfloat gscale = 1.0F / CHAN_MAXF;
+ const GLfloat bscale = 1.0F / CHAN_MAXF;
+ const GLfloat ascale = 1.0F / CHAN_MAXF;
+ GLuint i;
+
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+#if CHAN_TYPE == GL_FLOAT
+ GLfloat Rs, Gs, Bs, As; /* Source colors */
+ GLfloat Rd, Gd, Bd, Ad; /* Dest colors */
+#else
+ GLint Rs, Gs, Bs, As; /* Source colors */
+ GLint Rd, Gd, Bd, Ad; /* Dest colors */
+#endif
+ GLfloat sR, sG, sB, sA; /* Source scaling */
+ GLfloat dR, dG, dB, dA; /* Dest scaling */
+ GLfloat r, g, b, a; /* result color */
+
+ /* Incoming/source Color */
+ Rs = rgba[i][RCOMP];
+ Gs = rgba[i][GCOMP];
+ Bs = rgba[i][BCOMP];
+ As = rgba[i][ACOMP];
+#if CHAN_TYPE == GL_FLOAT
+ /* clamp */
+ Rs = MIN2(Rs, CHAN_MAXF);
+ Gs = MIN2(Gs, CHAN_MAXF);
+ Bs = MIN2(Bs, CHAN_MAXF);
+ As = MIN2(As, CHAN_MAXF);
+#endif
+
+ /* Frame buffer/dest color */
+ Rd = dest[i][RCOMP];
+ Gd = dest[i][GCOMP];
+ Bd = dest[i][BCOMP];
+ Ad = dest[i][ACOMP];
+#if CHAN_TYPE == GL_FLOAT
+ /* clamp */
+ Rd = MIN2(Rd, CHAN_MAXF);
+ Gd = MIN2(Gd, CHAN_MAXF);
+ Bd = MIN2(Bd, CHAN_MAXF);
+ Ad = MIN2(Ad, CHAN_MAXF);
+#endif
+
+ /* Source RGB factor */
+ switch (ctx->Color.BlendSrcRGB) {
+ case GL_ZERO:
+ sR = sG = sB = 0.0F;
+ break;
+ case GL_ONE:
+ sR = sG = sB = 1.0F;
+ break;
+ case GL_DST_COLOR:
+ sR = (GLfloat) Rd * rscale;
+ sG = (GLfloat) Gd * gscale;
+ sB = (GLfloat) Bd * bscale;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ sR = 1.0F - (GLfloat) Rd * rscale;
+ sG = 1.0F - (GLfloat) Gd * gscale;
+ sB = 1.0F - (GLfloat) Bd * bscale;
+ break;
+ case GL_SRC_ALPHA:
+ sR = sG = sB = (GLfloat) As * ascale;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ sR = sG = sB = 1.0F - (GLfloat) As * ascale;
+ break;
+ case GL_DST_ALPHA:
+ sR = sG = sB = (GLfloat) Ad * ascale;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ sR = sG = sB = 1.0F - (GLfloat) Ad * ascale;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ if (As < CHAN_MAX - Ad) {
+ sR = sG = sB = (GLfloat) As * ascale;
+ }
+ else {
+ sR = sG = sB = 1.0F - (GLfloat) Ad * ascale;
+ }
+ break;
+ case GL_CONSTANT_COLOR:
+ sR = ctx->Color.BlendColor[0];
+ sG = ctx->Color.BlendColor[1];
+ sB = ctx->Color.BlendColor[2];
+ break;
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ sR = 1.0F - ctx->Color.BlendColor[0];
+ sG = 1.0F - ctx->Color.BlendColor[1];
+ sB = 1.0F - ctx->Color.BlendColor[2];
+ break;
+ case GL_CONSTANT_ALPHA:
+ sR = sG = sB = ctx->Color.BlendColor[3];
+ break;
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ sR = sG = sB = 1.0F - ctx->Color.BlendColor[3];
+ break;
+ case GL_SRC_COLOR: /* GL_NV_blend_square */
+ sR = (GLfloat) Rs * rscale;
+ sG = (GLfloat) Gs * gscale;
+ sB = (GLfloat) Bs * bscale;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR: /* GL_NV_blend_square */
+ sR = 1.0F - (GLfloat) Rs * rscale;
+ sG = 1.0F - (GLfloat) Gs * gscale;
+ sB = 1.0F - (GLfloat) Bs * bscale;
+ break;
+ default:
+ /* this should never happen */
+ _mesa_problem(ctx, "Bad blend source RGB factor in do_blend");
+ return;
+ }
+
+ /* Source Alpha factor */
+ switch (ctx->Color.BlendSrcA) {
+ case GL_ZERO:
+ sA = 0.0F;
+ break;
+ case GL_ONE:
+ sA = 1.0F;
+ break;
+ case GL_DST_COLOR:
+ sA = (GLfloat) Ad * ascale;
+ break;
+ case GL_ONE_MINUS_DST_COLOR:
+ sA = 1.0F - (GLfloat) Ad * ascale;
+ break;
+ case GL_SRC_ALPHA:
+ sA = (GLfloat) As * ascale;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ sA = 1.0F - (GLfloat) As * ascale;
+ break;
+ case GL_DST_ALPHA:
+ sA =(GLfloat) Ad * ascale;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ sA = 1.0F - (GLfloat) Ad * ascale;
+ break;
+ case GL_SRC_ALPHA_SATURATE:
+ sA = 1.0;
+ break;
+ case GL_CONSTANT_COLOR:
+ sA = ctx->Color.BlendColor[3];
+ break;
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ sA = 1.0F - ctx->Color.BlendColor[3];
+ break;
+ case GL_CONSTANT_ALPHA:
+ sA = ctx->Color.BlendColor[3];
+ break;
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ sA = 1.0F - ctx->Color.BlendColor[3];
+ break;
+ case GL_SRC_COLOR: /* GL_NV_blend_square */
+ sA = (GLfloat) As * ascale;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR: /* GL_NV_blend_square */
+ sA = 1.0F - (GLfloat) As * ascale;
+ break;
+ default:
+ /* this should never happen */
+ sA = 0.0F;
+ _mesa_problem(ctx, "Bad blend source A factor in do_blend");
+ }
+
+ /* Dest RGB factor */
+ switch (ctx->Color.BlendDstRGB) {
+ case GL_ZERO:
+ dR = dG = dB = 0.0F;
+ break;
+ case GL_ONE:
+ dR = dG = dB = 1.0F;
+ break;
+ case GL_SRC_COLOR:
+ dR = (GLfloat) Rs * rscale;
+ dG = (GLfloat) Gs * gscale;
+ dB = (GLfloat) Bs * bscale;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ dR = 1.0F - (GLfloat) Rs * rscale;
+ dG = 1.0F - (GLfloat) Gs * gscale;
+ dB = 1.0F - (GLfloat) Bs * bscale;
+ break;
+ case GL_SRC_ALPHA:
+ dR = dG = dB = (GLfloat) As * ascale;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ dR = dG = dB = 1.0F - (GLfloat) As * ascale;
+ break;
+ case GL_DST_ALPHA:
+ dR = dG = dB = (GLfloat) Ad * ascale;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ dR = dG = dB = 1.0F - (GLfloat) Ad * ascale;
+ break;
+ case GL_CONSTANT_COLOR:
+ dR = ctx->Color.BlendColor[0];
+ dG = ctx->Color.BlendColor[1];
+ dB = ctx->Color.BlendColor[2];
+ break;
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ dR = 1.0F - ctx->Color.BlendColor[0];
+ dG = 1.0F - ctx->Color.BlendColor[1];
+ dB = 1.0F - ctx->Color.BlendColor[2];
+ break;
+ case GL_CONSTANT_ALPHA:
+ dR = dG = dB = ctx->Color.BlendColor[3];
+ break;
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ dR = dG = dB = 1.0F - ctx->Color.BlendColor[3];
+ break;
+ case GL_DST_COLOR: /* GL_NV_blend_square */
+ dR = (GLfloat) Rd * rscale;
+ dG = (GLfloat) Gd * gscale;
+ dB = (GLfloat) Bd * bscale;
+ break;
+ case GL_ONE_MINUS_DST_COLOR: /* GL_NV_blend_square */
+ dR = 1.0F - (GLfloat) Rd * rscale;
+ dG = 1.0F - (GLfloat) Gd * gscale;
+ dB = 1.0F - (GLfloat) Bd * bscale;
+ break;
+ default:
+ /* this should never happen */
+ dR = dG = dB = 0.0F;
+ _mesa_problem(ctx, "Bad blend dest RGB factor in do_blend");
+ }
+
+ /* Dest Alpha factor */
+ switch (ctx->Color.BlendDstA) {
+ case GL_ZERO:
+ dA = 0.0F;
+ break;
+ case GL_ONE:
+ dA = 1.0F;
+ break;
+ case GL_SRC_COLOR:
+ dA = (GLfloat) As * ascale;
+ break;
+ case GL_ONE_MINUS_SRC_COLOR:
+ dA = 1.0F - (GLfloat) As * ascale;
+ break;
+ case GL_SRC_ALPHA:
+ dA = (GLfloat) As * ascale;
+ break;
+ case GL_ONE_MINUS_SRC_ALPHA:
+ dA = 1.0F - (GLfloat) As * ascale;
+ break;
+ case GL_DST_ALPHA:
+ dA = (GLfloat) Ad * ascale;
+ break;
+ case GL_ONE_MINUS_DST_ALPHA:
+ dA = 1.0F - (GLfloat) Ad * ascale;
+ break;
+ case GL_CONSTANT_COLOR:
+ dA = ctx->Color.BlendColor[3];
+ break;
+ case GL_ONE_MINUS_CONSTANT_COLOR:
+ dA = 1.0F - ctx->Color.BlendColor[3];
+ break;
+ case GL_CONSTANT_ALPHA:
+ dA = ctx->Color.BlendColor[3];
+ break;
+ case GL_ONE_MINUS_CONSTANT_ALPHA:
+ dA = 1.0F - ctx->Color.BlendColor[3];
+ break;
+ case GL_DST_COLOR: /* GL_NV_blend_square */
+ dA = (GLfloat) Ad * ascale;
+ break;
+ case GL_ONE_MINUS_DST_COLOR: /* GL_NV_blend_square */
+ dA = 1.0F - (GLfloat) Ad * ascale;
+ break;
+ default:
+ /* this should never happen */
+ dA = 0.0F;
+ _mesa_problem(ctx, "Bad blend dest A factor in do_blend");
+ return;
+ }
+
+ /* Due to round-off problems we have to clamp against zero. */
+ /* Optimization: we don't have to do this for all src & dst factors */
+ if (dA < 0.0F) dA = 0.0F;
+ if (dR < 0.0F) dR = 0.0F;
+ if (dG < 0.0F) dG = 0.0F;
+ if (dB < 0.0F) dB = 0.0F;
+ if (sA < 0.0F) sA = 0.0F;
+ if (sR < 0.0F) sR = 0.0F;
+ if (sG < 0.0F) sG = 0.0F;
+ if (sB < 0.0F) sB = 0.0F;
+
+ ASSERT( sR <= 1.0 );
+ ASSERT( sG <= 1.0 );
+ ASSERT( sB <= 1.0 );
+ ASSERT( sA <= 1.0 );
+ ASSERT( dR <= 1.0 );
+ ASSERT( dG <= 1.0 );
+ ASSERT( dB <= 1.0 );
+ ASSERT( dA <= 1.0 );
+
+ /* compute blended color */
+#if CHAN_TYPE == GL_FLOAT
+ if (ctx->Color.BlendEquationRGB==GL_FUNC_ADD) {
+ r = Rs * sR + Rd * dR;
+ g = Gs * sG + Gd * dG;
+ b = Bs * sB + Bd * dB;
+ a = As * sA + Ad * dA;
+ }
+ else if (ctx->Color.BlendEquationRGB==GL_FUNC_SUBTRACT) {
+ r = Rs * sR - Rd * dR;
+ g = Gs * sG - Gd * dG;
+ b = Bs * sB - Bd * dB;
+ a = As * sA - Ad * dA;
+ }
+ else if (ctx->Color.BlendEquationRGB==GL_FUNC_REVERSE_SUBTRACT) {
+ r = Rd * dR - Rs * sR;
+ g = Gd * dG - Gs * sG;
+ b = Bd * dB - Bs * sB;
+ a = Ad * dA - As * sA;
+ }
+ else if (ctx->Color.BlendEquationRGB==GL_MIN) {
+ r = MIN2( Rd, Rs );
+ g = MIN2( Gd, Gs );
+ b = MIN2( Bd, Bs );
+ }
+ else if (ctx->Color.BlendEquationRGB==GL_MAX) {
+ r = MAX2( Rd, Rs );
+ g = MAX2( Gd, Gs );
+ b = MAX2( Bd, Bs );
+ }
+ else {
+ /* should never get here */
+ r = g = b = 0.0F; /* silence uninitialized var warning */
+ _mesa_problem(ctx, "unexpected BlendEquation in blend_general()");
+ }
+
+ if (ctx->Color.BlendEquationA==GL_FUNC_ADD) {
+ a = As * sA + Ad * dA;
+ }
+ else if (ctx->Color.BlendEquationA==GL_FUNC_SUBTRACT) {
+ a = As * sA - Ad * dA;
+ }
+ else if (ctx->Color.BlendEquationA==GL_FUNC_REVERSE_SUBTRACT) {
+ a = Ad * dA - As * sA;
+ }
+ else if (ctx->Color.BlendEquationA==GL_MIN) {
+ a = MIN2( Ad, As );
+ }
+ else if (ctx->Color.BlendEquationA==GL_MAX) {
+ a = MAX2( Ad, As );
+ }
+ else {
+ /* should never get here */
+ a = 0.0F; /* silence uninitialized var warning */
+ _mesa_problem(ctx, "unexpected BlendEquation in blend_general()");
+ }
+
+ /* final clamping */
+ rgba[i][RCOMP] = MAX2( r, 0.0F );
+ rgba[i][GCOMP] = MAX2( g, 0.0F );
+ rgba[i][BCOMP] = MAX2( b, 0.0F );
+ rgba[i][ACOMP] = CLAMP( a, 0.0F, CHAN_MAXF );
+#else
+ if (ctx->Color.BlendEquationRGB==GL_FUNC_ADD) {
+ r = Rs * sR + Rd * dR + 0.5F;
+ g = Gs * sG + Gd * dG + 0.5F;
+ b = Bs * sB + Bd * dB + 0.5F;
+ }
+ else if (ctx->Color.BlendEquationRGB==GL_FUNC_SUBTRACT) {
+ r = Rs * sR - Rd * dR + 0.5F;
+ g = Gs * sG - Gd * dG + 0.5F;
+ b = Bs * sB - Bd * dB + 0.5F;
+ }
+ else if (ctx->Color.BlendEquationRGB==GL_FUNC_REVERSE_SUBTRACT) {
+ r = Rd * dR - Rs * sR + 0.5F;
+ g = Gd * dG - Gs * sG + 0.5F;
+ b = Bd * dB - Bs * sB + 0.5F;
+ }
+ else if (ctx->Color.BlendEquationRGB==GL_MIN) {
+ r = MIN2( Rd, Rs );
+ g = MIN2( Gd, Gs );
+ b = MIN2( Bd, Bs );
+ }
+ else if (ctx->Color.BlendEquationRGB==GL_MAX) {
+ r = MAX2( Rd, Rs );
+ g = MAX2( Gd, Gs );
+ b = MAX2( Bd, Bs );
+ }
+ else {
+ /* should never get here */
+ r = g = b = 0.0F; /* silence uninitialized var warning */
+ _mesa_problem(ctx, "unexpected BlendEquation in blend_general()");
+ }
+
+ if (ctx->Color.BlendEquationA==GL_FUNC_ADD) {
+ a = As * sA + Ad * dA + 0.5F;
+ }
+ else if (ctx->Color.BlendEquationA==GL_FUNC_SUBTRACT) {
+ a = As * sA - Ad * dA + 0.5F;
+ }
+ else if (ctx->Color.BlendEquationA==GL_FUNC_REVERSE_SUBTRACT) {
+ a = Ad * dA - As * sA + 0.5F;
+ }
+ else if (ctx->Color.BlendEquationA==GL_MIN) {
+ a = MIN2( Ad, As );
+ }
+ else if (ctx->Color.BlendEquationA==GL_MAX) {
+ a = MAX2( Ad, As );
+ }
+ else {
+ /* should never get here */
+ a = 0.0F; /* silence uninitialized var warning */
+ _mesa_problem(ctx, "unexpected BlendEquation in blend_general()");
+ }
+
+ /* final clamping */
+ rgba[i][RCOMP] = (GLchan) (GLint) CLAMP( r, 0.0F, CHAN_MAXF );
+ rgba[i][GCOMP] = (GLchan) (GLint) CLAMP( g, 0.0F, CHAN_MAXF );
+ rgba[i][BCOMP] = (GLchan) (GLint) CLAMP( b, 0.0F, CHAN_MAXF );
+ rgba[i][ACOMP] = (GLchan) (GLint) CLAMP( a, 0.0F, CHAN_MAXF );
+#endif
+ }
+ }
+}
+
+
+/*
+ * Analyze current blending parameters to pick fastest blending function.
+ * Result: the ctx->Color.BlendFunc pointer is updated.
+ */
+void _swrast_choose_blend_func( GLcontext *ctx )
+{
+ const GLenum eq = ctx->Color.BlendEquationRGB;
+ const GLenum srcRGB = ctx->Color.BlendSrcRGB;
+ const GLenum dstRGB = ctx->Color.BlendDstRGB;
+ const GLenum srcA = ctx->Color.BlendSrcA;
+ const GLenum dstA = ctx->Color.BlendDstA;
+
+ if (ctx->Color.BlendEquationRGB != ctx->Color.BlendEquationA) {
+ SWRAST_CONTEXT(ctx)->BlendFunc = blend_general;
+ }
+ else if (eq==GL_MIN) {
+ /* Note: GL_MIN ignores the blending weight factors */
+#if defined(USE_MMX_ASM)
+ if ( cpu_has_mmx ) {
+ SWRAST_CONTEXT(ctx)->BlendFunc = _mesa_mmx_blend_min;
+ }
+ else
+#endif
+ SWRAST_CONTEXT(ctx)->BlendFunc = blend_min;
+ }
+ else if (eq==GL_MAX) {
+ /* Note: GL_MAX ignores the blending weight factors */
+#if defined(USE_MMX_ASM)
+ if ( cpu_has_mmx ) {
+ SWRAST_CONTEXT(ctx)->BlendFunc = _mesa_mmx_blend_max;
+ }
+ else
+#endif
+ SWRAST_CONTEXT(ctx)->BlendFunc = blend_max;
+ }
+ else if (srcRGB != srcA || dstRGB != dstA) {
+ SWRAST_CONTEXT(ctx)->BlendFunc = blend_general;
+ }
+ else if (eq==GL_FUNC_ADD && srcRGB==GL_SRC_ALPHA
+ && dstRGB==GL_ONE_MINUS_SRC_ALPHA) {
+#if defined(USE_MMX_ASM)
+ if ( cpu_has_mmx ) {
+ SWRAST_CONTEXT(ctx)->BlendFunc = _mesa_mmx_blend_transparency;
+ }
+ else
+#endif
+ SWRAST_CONTEXT(ctx)->BlendFunc = blend_transparency;
+ }
+ else if (eq==GL_FUNC_ADD && srcRGB==GL_ONE && dstRGB==GL_ONE) {
+#if defined(USE_MMX_ASM)
+ if ( cpu_has_mmx ) {
+ SWRAST_CONTEXT(ctx)->BlendFunc = _mesa_mmx_blend_add;
+ }
+ else
+#endif
+ SWRAST_CONTEXT(ctx)->BlendFunc = blend_add;
+ }
+ else if (((eq==GL_FUNC_ADD || eq==GL_FUNC_REVERSE_SUBTRACT)
+ && (srcRGB==GL_ZERO && dstRGB==GL_SRC_COLOR))
+ ||
+ ((eq==GL_FUNC_ADD || eq==GL_FUNC_SUBTRACT)
+ && (srcRGB==GL_DST_COLOR && dstRGB==GL_ZERO))) {
+#if defined(USE_MMX_ASM)
+ if ( cpu_has_mmx ) {
+ SWRAST_CONTEXT(ctx)->BlendFunc = _mesa_mmx_blend_modulate;
+ }
+ else
+#endif
+ SWRAST_CONTEXT(ctx)->BlendFunc = blend_modulate;
+ }
+ else if (eq==GL_FUNC_ADD && srcRGB == GL_ZERO && dstRGB == GL_ONE) {
+ SWRAST_CONTEXT(ctx)->BlendFunc = blend_noop;
+ }
+ else if (eq==GL_FUNC_ADD && srcRGB == GL_ONE && dstRGB == GL_ZERO) {
+ SWRAST_CONTEXT(ctx)->BlendFunc = blend_replace;
+ }
+ else {
+ SWRAST_CONTEXT(ctx)->BlendFunc = blend_general;
+ }
+}
+
+
+
+/*
+ * Apply the blending operator to a span of pixels.
+ * We can handle horizontal runs of pixels (spans) or arrays of x/y
+ * pixel coordinates.
+ */
+void
+_swrast_blend_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLchan rgba[][4])
+{
+ GLchan framebuffer[MAX_WIDTH][4];
+
+ ASSERT(span->end <= MAX_WIDTH);
+ ASSERT(span->arrayMask & SPAN_RGBA);
+ ASSERT(!ctx->Color._LogicOpEnabled);
+
+ /* Read span of current frame buffer pixels */
+ if (span->arrayMask & SPAN_XY) {
+ /* array of x/y pixel coords */
+ _swrast_get_values(ctx, rb, span->end, span->array->x, span->array->y,
+ framebuffer, 4 * sizeof(GLchan));
+ }
+ else {
+ /* horizontal run of pixels */
+ _swrast_read_rgba_span(ctx, rb, span->end, span->x, span->y,
+ framebuffer);
+ }
+
+ SWRAST_CONTEXT(ctx)->BlendFunc( ctx, span->end, span->array->mask, rgba,
+ (const GLchan (*)[4]) framebuffer );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_blend.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_blend.h
new file mode 100644
index 000000000..c95193215
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_blend.h
@@ -0,0 +1,43 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_BLEND_H
+#define S_BLEND_H
+
+
+#include "mtypes.h"
+#include "s_context.h"
+
+
+extern void
+_swrast_blend_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLchan rgba[][4]);
+
+
+extern void
+_swrast_choose_blend_func(GLcontext *ctx);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_buffers.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_buffers.c
new file mode 100644
index 000000000..a7dc8a3af
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_buffers.c
@@ -0,0 +1,408 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4.1
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "colormac.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "fbobject.h"
+
+#include "s_accum.h"
+#include "s_context.h"
+#include "s_depth.h"
+#include "s_masking.h"
+#include "s_stencil.h"
+
+
+/**
+ * Clear the color buffer when glColorMask is in effect.
+ */
+static void
+clear_rgba_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb)
+{
+ const GLint x = ctx->DrawBuffer->_Xmin;
+ const GLint y = ctx->DrawBuffer->_Ymin;
+ const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+ const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+ GLchan clearColor[4];
+ GLint i;
+
+ ASSERT(ctx->Visual.rgbMode);
+ ASSERT(rb->PutRow);
+
+ CLAMPED_FLOAT_TO_CHAN(clearColor[RCOMP], ctx->Color.ClearColor[0]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[GCOMP], ctx->Color.ClearColor[1]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[BCOMP], ctx->Color.ClearColor[2]);
+ CLAMPED_FLOAT_TO_CHAN(clearColor[ACOMP], ctx->Color.ClearColor[3]);
+
+ for (i = 0; i < height; i++) {
+ GLchan rgba[MAX_WIDTH][4];
+ GLint j;
+ for (j = 0; j < width; j++) {
+ COPY_CHAN4(rgba[j], clearColor);
+ }
+ _swrast_mask_rgba_array( ctx, rb, width, x, y + i, rgba );
+ rb->PutRow(ctx, rb, width, x, y + i, rgba, NULL);
+ }
+}
+
+
+/**
+ * Clear color index buffer with masking.
+ */
+static void
+clear_ci_buffer_with_masking(GLcontext *ctx, struct gl_renderbuffer *rb)
+{
+ const GLint x = ctx->DrawBuffer->_Xmin;
+ const GLint y = ctx->DrawBuffer->_Ymin;
+ const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+ const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+ GLuint span[MAX_WIDTH];
+ GLubyte mask[MAX_WIDTH];
+ GLint i, j;
+
+ ASSERT(!ctx->Visual.rgbMode);
+
+ MEMSET( mask, 1, width );
+ for (i = 0; i < height;i++) {
+ for (j = 0; j < width;j++) {
+ span[j] = ctx->Color.ClearIndex;
+ }
+ _swrast_mask_ci_array(ctx, rb, width, x, y + i, span);
+ ASSERT(rb->PutRow);
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ rb->PutRow(ctx, rb, width, x, y + i, span, mask);
+ }
+}
+
+
+/**
+ * Clear an rgba color buffer without channel masking.
+ */
+static void
+clear_rgba_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
+{
+ const GLint x = ctx->DrawBuffer->_Xmin;
+ const GLint y = ctx->DrawBuffer->_Ymin;
+ const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+ const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+ GLubyte clear8[4];
+ GLushort clear16[4];
+ GLvoid *clearVal;
+ GLint i;
+
+ ASSERT(ctx->Visual.rgbMode);
+
+ ASSERT(ctx->Color.ColorMask[0] &&
+ ctx->Color.ColorMask[1] &&
+ ctx->Color.ColorMask[2] &&
+ ctx->Color.ColorMask[3]);
+
+ ASSERT(rb->PutMonoRow);
+
+ switch (rb->DataType) {
+ case GL_UNSIGNED_BYTE:
+ UNCLAMPED_FLOAT_TO_UBYTE(clear8[0], ctx->Color.ClearColor[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(clear8[1], ctx->Color.ClearColor[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(clear8[2], ctx->Color.ClearColor[2]);
+ UNCLAMPED_FLOAT_TO_UBYTE(clear8[3], ctx->Color.ClearColor[3]);
+ clearVal = clear8;
+ break;
+ case GL_UNSIGNED_SHORT:
+ UNCLAMPED_FLOAT_TO_USHORT(clear16[0], ctx->Color.ClearColor[0]);
+ UNCLAMPED_FLOAT_TO_USHORT(clear16[1], ctx->Color.ClearColor[1]);
+ UNCLAMPED_FLOAT_TO_USHORT(clear16[2], ctx->Color.ClearColor[2]);
+ UNCLAMPED_FLOAT_TO_USHORT(clear16[3], ctx->Color.ClearColor[3]);
+ clearVal = clear16;
+ break;
+ case GL_FLOAT:
+ clearVal = ctx->Color.ClearColor;
+ break;
+ default:
+ _mesa_problem(ctx, "Bad rb DataType in clear_color_buffer");
+ return;
+ }
+
+ for (i = 0; i < height; i++) {
+ rb->PutMonoRow(ctx, rb, width, x, y + i, clearVal, NULL);
+ }
+}
+
+
+/**
+ * Clear color index buffer without masking.
+ */
+static void
+clear_ci_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
+{
+ const GLint x = ctx->DrawBuffer->_Xmin;
+ const GLint y = ctx->DrawBuffer->_Ymin;
+ const GLint height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+ const GLint width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+ GLubyte clear8;
+ GLushort clear16;
+ GLuint clear32;
+ GLvoid *clearVal;
+ GLint i;
+
+ ASSERT(!ctx->Visual.rgbMode);
+
+ ASSERT((ctx->Color.IndexMask & ((1 << ctx->Visual.indexBits) - 1))
+ == (GLuint) ((1 << ctx->Visual.indexBits) - 1));
+
+ ASSERT(rb->PutMonoRow);
+
+ /* setup clear value */
+ switch (rb->DataType) {
+ case GL_UNSIGNED_BYTE:
+ clear8 = (GLubyte) ctx->Color.ClearIndex;
+ clearVal = &clear8;
+ break;
+ case GL_UNSIGNED_SHORT:
+ clear16 = (GLushort) ctx->Color.ClearIndex;
+ clearVal = &clear16;
+ break;
+ case GL_UNSIGNED_INT:
+ clear32 = ctx->Color.ClearIndex;
+ clearVal = &clear32;
+ break;
+ default:
+ _mesa_problem(ctx, "Bad rb DataType in clear_color_buffer");
+ return;
+ }
+
+ for (i = 0; i < height; i++)
+ rb->PutMonoRow(ctx, rb, width, x, y + i, clearVal, NULL);
+}
+
+
+/**
+ * Clear the front/back/left/right/aux color buffers.
+ * This function is usually only called if the device driver can't
+ * clear its own color buffers for some reason (such as with masking).
+ */
+static void
+clear_color_buffers(GLcontext *ctx)
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLboolean masking;
+ GLuint i;
+
+ if (ctx->Visual.rgbMode) {
+ if (ctx->Color.ColorMask[0] &&
+ ctx->Color.ColorMask[1] &&
+ ctx->Color.ColorMask[2] &&
+ ctx->Color.ColorMask[3]) {
+ masking = GL_FALSE;
+ }
+ else {
+ masking = GL_TRUE;
+ }
+ }
+ else {
+ const GLuint indexBits = (1 << ctx->Visual.indexBits) - 1;
+ if ((ctx->Color.IndexMask & indexBits) == indexBits) {
+ masking = GL_FALSE;
+ }
+ else {
+ masking = GL_TRUE;
+ }
+ }
+
+ for (i = 0; i < ctx->DrawBuffer->_NumColorDrawBuffers[0]; i++) {
+ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][i];
+#if OLD_RENDERBUFFER
+ /* SetBuffer will go away */
+ if (swrast->Driver.SetBuffer)
+ swrast->Driver.SetBuffer(ctx, ctx->DrawBuffer,
+ ctx->DrawBuffer->_ColorDrawBit[0][i]);
+#endif
+
+ if (ctx->Visual.rgbMode) {
+ if (masking) {
+ clear_rgba_buffer_with_masking(ctx, rb);
+ }
+ else {
+ clear_rgba_buffer(ctx, rb);
+ }
+ }
+ else {
+ if (masking) {
+ clear_ci_buffer_with_masking(ctx, rb);
+ }
+ else {
+ clear_ci_buffer(ctx, rb);
+ }
+ }
+ }
+
+ /* restore default read/draw buffer */
+ _swrast_use_draw_buffer(ctx);
+}
+
+
+/**
+ * Called via the device driver's ctx->Driver.Clear() function if the
+ * device driver can't clear one or more of the buffers itself.
+ * \param mask bitwise-OR of DD_*_BIT flags.
+ * \param all if GL_TRUE, clear whole buffer, else clear specified region.
+ */
+void
+_swrast_Clear(GLcontext *ctx, GLbitfield mask,
+ GLboolean all, GLint x, GLint y, GLint width, GLint height)
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ (void) all; (void) x; (void) y; (void) width; (void) height;
+
+#ifdef DEBUG_FOO
+ {
+ const GLbitfield legalBits =
+ BUFFER_BIT_FRONT_LEFT |
+ BUFFER_BIT_FRONT_RIGHT |
+ BUFFER_BIT_BACK_LEFT |
+ BUFFER_BIT_BACK_RIGHT |
+ BUFFER_BIT_DEPTH |
+ BUFFER_BIT_STENCIL |
+ BUFFER_BIT_ACCUM |
+ BUFFER_BIT_AUX0 |
+ BUFFER_BIT_AUX1 |
+ BUFFER_BIT_AUX2 |
+ BUFFER_BIT_AUX3;
+ assert((mask & (~legalBits)) == 0);
+ }
+#endif
+
+ RENDER_START(swrast,ctx);
+
+ /* do software clearing here */
+ if (mask) {
+ if (mask & ctx->DrawBuffer->_ColorDrawBufferMask[0]) {
+ clear_color_buffers(ctx);
+ }
+ if (mask & BUFFER_BIT_DEPTH) {
+ struct gl_renderbuffer *rb
+ = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+ _swrast_clear_depth_buffer(ctx, rb);
+ }
+ if (mask & BUFFER_BIT_ACCUM) {
+ struct gl_renderbuffer *rb
+ = ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer;
+ _swrast_clear_accum_buffer(ctx, rb);
+ }
+ if (mask & BUFFER_BIT_STENCIL) {
+ struct gl_renderbuffer *rb
+ = ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
+ _swrast_clear_stencil_buffer(ctx, rb);
+ }
+ }
+
+ RENDER_FINISH(swrast,ctx);
+}
+
+
+/*
+ * Fallback for ctx->Driver.DrawBuffer()
+ */
+void
+_swrast_DrawBuffer( GLcontext *ctx, GLenum mode )
+{
+ (void) mode;
+ _swrast_use_draw_buffer(ctx);
+}
+
+
+/*
+ * Fallback for ctx->Driver.DrawBuffers()
+ */
+void
+_swrast_DrawBuffers( GLcontext *ctx, GLsizei n, const GLenum *buffers )
+{
+ _swrast_use_draw_buffer(ctx);
+}
+
+
+/*
+ * Setup things so that we read/write spans from the user-designated
+ * read buffer (set via glReadPixels). We usually just have to call
+ * this for glReadPixels, glCopyPixels, etc.
+ */
+void
+_swrast_use_read_buffer( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ /* Do this so the software-emulated alpha plane span functions work! */
+ swrast->CurrentBufferBit = ctx->ReadBuffer->_ColorReadBufferMask;
+ /* Tell the device driver where to read/write spans */
+ if (swrast->Driver.SetBuffer)
+ swrast->Driver.SetBuffer(ctx, ctx->ReadBuffer, swrast->CurrentBufferBit);
+}
+
+
+/*
+ * Setup things so that we read/write spans from the default draw buffer.
+ * This is the usual mode that Mesa's software rasterizer operates in.
+ */
+void
+_swrast_use_draw_buffer( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ /* The user can specify rendering to zero, one, two, or four color
+ * buffers simultaneously with glDrawBuffer()!
+ * We don't expect the span/point/line/triangle functions to deal with
+ * that mess so we'll iterate over the multiple buffers as needed.
+ * But usually we only render to one color buffer at a time.
+ * We set ctx->Color._DriverDrawBuffer to that buffer and tell the
+ * device driver to use that buffer.
+ * Look in s_span.c's multi_write_rgba_span() function to see how
+ * we loop over multiple color buffers when needed.
+ */
+
+ if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT)
+ swrast->CurrentBufferBit = BUFFER_BIT_FRONT_LEFT;
+ else if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_BACK_LEFT)
+ swrast->CurrentBufferBit = BUFFER_BIT_BACK_LEFT;
+ else if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_RIGHT)
+ swrast->CurrentBufferBit = BUFFER_BIT_FRONT_RIGHT;
+ else if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_BACK_RIGHT)
+ swrast->CurrentBufferBit = BUFFER_BIT_BACK_RIGHT;
+ else if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_AUX0)
+ swrast->CurrentBufferBit = BUFFER_BIT_AUX0;
+ else if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_AUX1)
+ swrast->CurrentBufferBit = BUFFER_BIT_AUX1;
+ else if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_AUX2)
+ swrast->CurrentBufferBit = BUFFER_BIT_AUX2;
+ else if (ctx->DrawBuffer->_ColorDrawBufferMask[0] & BUFFER_BIT_AUX3)
+ swrast->CurrentBufferBit = BUFFER_BIT_AUX3;
+ else
+ /* glDrawBuffer(GL_NONE) */
+ swrast->CurrentBufferBit = BUFFER_BIT_FRONT_LEFT; /* we always have this buffer */
+
+ if (swrast->Driver.SetBuffer)
+ swrast->Driver.SetBuffer(ctx, ctx->DrawBuffer, swrast->CurrentBufferBit);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_context.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_context.c
new file mode 100644
index 000000000..a12703845
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_context.c
@@ -0,0 +1,750 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Brian Paul
+ */
+
+#include "imports.h"
+#include "bufferobj.h"
+#include "context.h"
+#include "colormac.h"
+#include "mtypes.h"
+#include "program.h"
+#include "texobj.h"
+#include "nvfragprog.h"
+
+#include "swrast.h"
+#include "s_blend.h"
+#include "s_context.h"
+#include "s_lines.h"
+#include "s_points.h"
+#include "s_span.h"
+#include "s_triangle.h"
+#include "s_texture.h"
+
+
+/**
+ * Recompute the value of swrast->_RasterMask, etc. according to
+ * the current context. The _RasterMask field can be easily tested by
+ * drivers to determine certain basic GL state (does the primitive need
+ * stenciling, logic-op, fog, etc?).
+ */
+static void
+_swrast_update_rasterflags( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLuint rasterMask = 0;
+
+ if (ctx->Color.AlphaEnabled) rasterMask |= ALPHATEST_BIT;
+ if (ctx->Color.BlendEnabled) rasterMask |= BLEND_BIT;
+ if (ctx->Depth.Test) rasterMask |= DEPTH_BIT;
+ if (swrast->_FogEnabled) rasterMask |= FOG_BIT;
+ if (ctx->Scissor.Enabled) rasterMask |= CLIP_BIT;
+ if (ctx->Stencil.Enabled) rasterMask |= STENCIL_BIT;
+ if (ctx->Visual.rgbMode) {
+ const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask);
+ if (colorMask != 0xffffffff) rasterMask |= MASKING_BIT;
+ if (ctx->Color._LogicOpEnabled) rasterMask |= LOGIC_OP_BIT;
+ if (ctx->Texture._EnabledUnits) rasterMask |= TEXTURE_BIT;
+ }
+ else {
+ if (ctx->Color.IndexMask != 0xffffffff) rasterMask |= MASKING_BIT;
+ if (ctx->Color.IndexLogicOpEnabled) rasterMask |= LOGIC_OP_BIT;
+ }
+
+ if ( ctx->Viewport.X < 0
+ || ctx->Viewport.X + ctx->Viewport.Width > (GLint) ctx->DrawBuffer->Width
+ || ctx->Viewport.Y < 0
+ || ctx->Viewport.Y + ctx->Viewport.Height > (GLint) ctx->DrawBuffer->Height) {
+ rasterMask |= CLIP_BIT;
+ }
+
+ if (ctx->Depth.OcclusionTest || ctx->Occlusion.Active)
+ 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.
+ */
+ if (ctx->DrawBuffer->_NumColorDrawBuffers[0] != 1) {
+ /* more than one color buffer designated for writing (or zero buffers) */
+ rasterMask |= MULTI_DRAW_BIT;
+ }
+ else if (ctx->Visual.rgbMode && *((GLuint *) ctx->Color.ColorMask) == 0) {
+ rasterMask |= MULTI_DRAW_BIT; /* all RGBA channels disabled */
+ }
+ else if (!ctx->Visual.rgbMode && ctx->Color.IndexMask==0) {
+ rasterMask |= MULTI_DRAW_BIT; /* all color index bits disabled */
+ }
+
+ if (ctx->FragmentProgram._Active) {
+ rasterMask |= FRAGPROG_BIT;
+ }
+
+ if (ctx->ATIFragmentShader._Enabled) {
+ rasterMask |= ATIFRAGSHADER_BIT;
+ }
+
+ SWRAST_CONTEXT(ctx)->_RasterMask = rasterMask;
+}
+
+
+/**
+ * Examine polycon culls tate to compute the _BackfaceSign field.
+ * _BackfaceSign will be 0 if no culling, -1 if culling back-faces,
+ * and 1 if culling front-faces. The Polygon FrontFace state also
+ * factors in.
+ */
+static void
+_swrast_update_polygon( GLcontext *ctx )
+{
+ GLfloat backface_sign = 1;
+
+ if (ctx->Polygon.CullFlag) {
+ backface_sign = 1;
+ switch(ctx->Polygon.CullFaceMode) {
+ case GL_BACK:
+ if(ctx->Polygon.FrontFace==GL_CCW)
+ backface_sign = -1;
+ break;
+ case GL_FRONT:
+ if(ctx->Polygon.FrontFace!=GL_CCW)
+ backface_sign = -1;
+ break;
+ default:
+ case GL_FRONT_AND_BACK:
+ backface_sign = 0;
+ break;
+ }
+ }
+ else {
+ backface_sign = 0;
+ }
+
+ SWRAST_CONTEXT(ctx)->_BackfaceSign = backface_sign;
+}
+
+
+/**
+ * Update the _PreferPixelFog field to indicate if we need to compute
+ * fog factors per-fragment.
+ */
+static void
+_swrast_update_fog_hint( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ swrast->_PreferPixelFog = (!swrast->AllowVertexFog ||
+ ctx->FragmentProgram._Enabled || /* not _Active! */
+ (ctx->Hint.Fog == GL_NICEST &&
+ swrast->AllowPixelFog));
+}
+
+
+
+/**
+ * Update the swrast->_AnyTextureCombine flag.
+ */
+static void
+_swrast_update_texture_env( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLuint i;
+ swrast->_AnyTextureCombine = GL_FALSE;
+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+ if (ctx->Texture.Unit[i].EnvMode == GL_COMBINE_EXT ||
+ ctx->Texture.Unit[i].EnvMode == GL_COMBINE4_NV) {
+ swrast->_AnyTextureCombine = GL_TRUE;
+ return;
+ }
+ }
+}
+
+
+/**
+ * Update swrast->_FogColor and swrast->_FogEnable values.
+ */
+static void
+_swrast_update_fog_state( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ /* convert fog color to GLchan values */
+ CLAMPED_FLOAT_TO_CHAN(swrast->_FogColor[RCOMP], ctx->Fog.Color[RCOMP]);
+ CLAMPED_FLOAT_TO_CHAN(swrast->_FogColor[GCOMP], ctx->Fog.Color[GCOMP]);
+ CLAMPED_FLOAT_TO_CHAN(swrast->_FogColor[BCOMP], ctx->Fog.Color[BCOMP]);
+
+ /* determine if fog is needed, and if so, which fog mode */
+ swrast->_FogEnabled = GL_FALSE;
+ if (ctx->FragmentProgram._Active) {
+ if (ctx->FragmentProgram._Current->Base.Target==GL_FRAGMENT_PROGRAM_ARB) {
+ const struct fragment_program *p
+ = (struct fragment_program *) ctx->FragmentProgram._Current;
+ if (p->FogOption != GL_NONE) {
+ swrast->_FogEnabled = GL_TRUE;
+ swrast->_FogMode = p->FogOption;
+ }
+ }
+ }
+ else if (ctx->Fog.Enabled) {
+ swrast->_FogEnabled = GL_TRUE;
+ swrast->_FogMode = ctx->Fog.Mode;
+ }
+}
+
+
+/**
+ * Update state for running fragment programs. Basically, load the
+ * program parameters with current state values.
+ */
+static void
+_swrast_update_fragment_program( GLcontext *ctx )
+{
+ if (ctx->FragmentProgram._Active) {
+ struct fragment_program *program = ctx->FragmentProgram._Current;
+ _mesa_load_state_parameters(ctx, program->Parameters);
+ }
+}
+
+
+
+#define _SWRAST_NEW_DERIVED (_SWRAST_NEW_RASTERMASK | \
+ _NEW_TEXTURE | \
+ _NEW_HINT | \
+ _NEW_POLYGON )
+
+/* State referenced by _swrast_choose_triangle, _swrast_choose_line.
+ */
+#define _SWRAST_NEW_TRIANGLE (_SWRAST_NEW_DERIVED | \
+ _NEW_RENDERMODE| \
+ _NEW_POLYGON| \
+ _NEW_DEPTH| \
+ _NEW_STENCIL| \
+ _NEW_COLOR| \
+ _NEW_TEXTURE| \
+ _SWRAST_NEW_RASTERMASK| \
+ _NEW_LIGHT| \
+ _NEW_FOG | \
+ _DD_NEW_SEPARATE_SPECULAR)
+
+#define _SWRAST_NEW_LINE (_SWRAST_NEW_DERIVED | \
+ _NEW_RENDERMODE| \
+ _NEW_LINE| \
+ _NEW_TEXTURE| \
+ _NEW_LIGHT| \
+ _NEW_FOG| \
+ _NEW_DEPTH | \
+ _DD_NEW_SEPARATE_SPECULAR)
+
+#define _SWRAST_NEW_POINT (_SWRAST_NEW_DERIVED | \
+ _NEW_RENDERMODE | \
+ _NEW_POINT | \
+ _NEW_TEXTURE | \
+ _NEW_LIGHT | \
+ _NEW_FOG | \
+ _DD_NEW_SEPARATE_SPECULAR)
+
+#define _SWRAST_NEW_TEXTURE_SAMPLE_FUNC _NEW_TEXTURE
+
+#define _SWRAST_NEW_TEXTURE_ENV_MODE _NEW_TEXTURE
+
+#define _SWRAST_NEW_BLEND_FUNC _NEW_COLOR
+
+
+
+/**
+ * Stub for swrast->Triangle to select a true triangle function
+ * after a state change.
+ */
+static void
+_swrast_validate_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ _swrast_validate_derived( ctx );
+ swrast->choose_triangle( ctx );
+
+ if (ctx->Texture._EnabledUnits == 0
+ && NEED_SECONDARY_COLOR(ctx)
+ && !ctx->FragmentProgram._Active) {
+ /* separate specular color, but no texture */
+ swrast->SpecTriangle = swrast->Triangle;
+ swrast->Triangle = _swrast_add_spec_terms_triangle;
+ }
+
+ swrast->Triangle( ctx, v0, v1, v2 );
+}
+
+/**
+ * Called via swrast->Line. Examine current GL state and choose a software
+ * line routine. Then call it.
+ */
+static void
+_swrast_validate_line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ _swrast_validate_derived( ctx );
+ swrast->choose_line( ctx );
+
+ if (ctx->Texture._EnabledUnits == 0
+ && NEED_SECONDARY_COLOR(ctx)
+ && !ctx->FragmentProgram._Active) {
+ swrast->SpecLine = swrast->Line;
+ swrast->Line = _swrast_add_spec_terms_line;
+ }
+
+
+ swrast->Line( ctx, v0, v1 );
+}
+
+/**
+ * Called via swrast->Point. Examine current GL state and choose a software
+ * point routine. Then call it.
+ */
+static void
+_swrast_validate_point( GLcontext *ctx, const SWvertex *v0 )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ _swrast_validate_derived( ctx );
+ swrast->choose_point( ctx );
+
+ if (ctx->Texture._EnabledUnits == 0
+ && NEED_SECONDARY_COLOR(ctx)
+ && !ctx->FragmentProgram._Active) {
+ swrast->SpecPoint = swrast->Point;
+ swrast->Point = _swrast_add_spec_terms_point;
+ }
+
+ swrast->Point( ctx, v0 );
+}
+
+
+/**
+ * Called via swrast->BlendFunc. Examine GL state to choose a blending
+ * function, then call it.
+ */
+static void _ASMAPI
+_swrast_validate_blend_func( GLcontext *ctx, GLuint n,
+ const GLubyte mask[],
+ GLchan src[][4],
+ CONST GLchan dst[][4] )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ _swrast_validate_derived( ctx );
+ _swrast_choose_blend_func( ctx );
+
+ swrast->BlendFunc( ctx, n, mask, src, dst );
+}
+
+
+/**
+ * Called via the swrast->TextureSample[i] function pointer.
+ * Basically, given a texture object, an array of texture coords
+ * and an array of level-of-detail values, return an array of colors.
+ * In this case, determine the correct texture sampling routine
+ * (depending on filter mode, texture dimensions, etc) then call the
+ * sampler routine.
+ */
+static void
+_swrast_validate_texture_sample( GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoords[][4],
+ const GLfloat lambda[], GLchan rgba[][4] )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ _swrast_validate_derived( ctx );
+
+ /* Compute min/mag filter threshold */
+ if (tObj && tObj->MinFilter != tObj->MagFilter) {
+ if (tObj->MagFilter == GL_LINEAR
+ && (tObj->MinFilter == GL_NEAREST_MIPMAP_NEAREST ||
+ tObj->MinFilter == GL_NEAREST_MIPMAP_LINEAR)) {
+ swrast->_MinMagThresh[texUnit] = 0.5F;
+ }
+ else {
+ swrast->_MinMagThresh[texUnit] = 0.0F;
+ }
+ }
+
+ swrast->TextureSample[texUnit] =
+ _swrast_choose_texture_sample_func( ctx, tObj );
+
+ swrast->TextureSample[texUnit]( ctx, texUnit, tObj, n, texcoords,
+ lambda, rgba );
+}
+
+
+static void
+_swrast_sleep( GLcontext *ctx, GLuint new_state )
+{
+ (void) ctx; (void) new_state;
+}
+
+
+static void
+_swrast_invalidate_state( GLcontext *ctx, GLuint new_state )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLuint i;
+
+ swrast->NewState |= new_state;
+
+ /* After 10 statechanges without any swrast functions being called,
+ * put the module to sleep.
+ */
+ if (++swrast->StateChanges > 10) {
+ swrast->InvalidateState = _swrast_sleep;
+ swrast->NewState = ~0;
+ new_state = ~0;
+ }
+
+ if (new_state & swrast->invalidate_triangle)
+ swrast->Triangle = _swrast_validate_triangle;
+
+ if (new_state & swrast->invalidate_line)
+ swrast->Line = _swrast_validate_line;
+
+ if (new_state & swrast->invalidate_point)
+ swrast->Point = _swrast_validate_point;
+
+ if (new_state & _SWRAST_NEW_BLEND_FUNC)
+ swrast->BlendFunc = _swrast_validate_blend_func;
+
+ if (new_state & _SWRAST_NEW_TEXTURE_SAMPLE_FUNC)
+ for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
+ swrast->TextureSample[i] = _swrast_validate_texture_sample;
+}
+
+
+void
+_swrast_validate_derived( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ if (swrast->NewState) {
+ if (swrast->NewState & _SWRAST_NEW_RASTERMASK)
+ _swrast_update_rasterflags( ctx );
+
+ if (swrast->NewState & _NEW_POLYGON)
+ _swrast_update_polygon( ctx );
+
+ if (swrast->NewState & (_NEW_HINT | _NEW_PROGRAM))
+ _swrast_update_fog_hint( ctx );
+
+ if (swrast->NewState & _SWRAST_NEW_TEXTURE_ENV_MODE)
+ _swrast_update_texture_env( ctx );
+
+ if (swrast->NewState & (_NEW_FOG | _NEW_PROGRAM))
+ _swrast_update_fog_state( ctx );
+
+ if (swrast->NewState & _NEW_PROGRAM)
+ _swrast_update_fragment_program( ctx );
+
+ swrast->NewState = 0;
+ swrast->StateChanges = 0;
+ swrast->InvalidateState = _swrast_invalidate_state;
+ }
+}
+
+#define SWRAST_DEBUG 0
+
+/* Public entrypoints: See also s_accum.c, s_bitmap.c, etc.
+ */
+void
+_swrast_Quad( GLcontext *ctx,
+ const SWvertex *v0, const SWvertex *v1,
+ const SWvertex *v2, const SWvertex *v3 )
+{
+ if (SWRAST_DEBUG) {
+ _mesa_debug(ctx, "_swrast_Quad\n");
+ _swrast_print_vertex( ctx, v0 );
+ _swrast_print_vertex( ctx, v1 );
+ _swrast_print_vertex( ctx, v2 );
+ _swrast_print_vertex( ctx, v3 );
+ }
+ SWRAST_CONTEXT(ctx)->Triangle( ctx, v0, v1, v3 );
+ SWRAST_CONTEXT(ctx)->Triangle( ctx, v1, v2, v3 );
+}
+
+void
+_swrast_Triangle( GLcontext *ctx, const SWvertex *v0,
+ const SWvertex *v1, const SWvertex *v2 )
+{
+ if (SWRAST_DEBUG) {
+ _mesa_debug(ctx, "_swrast_Triangle\n");
+ _swrast_print_vertex( ctx, v0 );
+ _swrast_print_vertex( ctx, v1 );
+ _swrast_print_vertex( ctx, v2 );
+ }
+ SWRAST_CONTEXT(ctx)->Triangle( ctx, v0, v1, v2 );
+}
+
+void
+_swrast_Line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 )
+{
+ if (SWRAST_DEBUG) {
+ _mesa_debug(ctx, "_swrast_Line\n");
+ _swrast_print_vertex( ctx, v0 );
+ _swrast_print_vertex( ctx, v1 );
+ }
+ SWRAST_CONTEXT(ctx)->Line( ctx, v0, v1 );
+}
+
+void
+_swrast_Point( GLcontext *ctx, const SWvertex *v0 )
+{
+ if (SWRAST_DEBUG) {
+ _mesa_debug(ctx, "_swrast_Point\n");
+ _swrast_print_vertex( ctx, v0 );
+ }
+ SWRAST_CONTEXT(ctx)->Point( ctx, v0 );
+}
+
+void
+_swrast_InvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ if (SWRAST_DEBUG) {
+ _mesa_debug(ctx, "_swrast_InvalidateState\n");
+ }
+ SWRAST_CONTEXT(ctx)->InvalidateState( ctx, new_state );
+}
+
+void
+_swrast_ResetLineStipple( GLcontext *ctx )
+{
+ if (SWRAST_DEBUG) {
+ _mesa_debug(ctx, "_swrast_ResetLineStipple\n");
+ }
+ SWRAST_CONTEXT(ctx)->StippleCounter = 0;
+}
+
+void
+_swrast_allow_vertex_fog( GLcontext *ctx, GLboolean value )
+{
+ if (SWRAST_DEBUG) {
+ _mesa_debug(ctx, "_swrast_allow_vertex_fog %d\n", value);
+ }
+ SWRAST_CONTEXT(ctx)->InvalidateState( ctx, _NEW_HINT );
+ SWRAST_CONTEXT(ctx)->AllowVertexFog = value;
+}
+
+void
+_swrast_allow_pixel_fog( GLcontext *ctx, GLboolean value )
+{
+ if (SWRAST_DEBUG) {
+ _mesa_debug(ctx, "_swrast_allow_pixel_fog %d\n", value);
+ }
+ SWRAST_CONTEXT(ctx)->InvalidateState( ctx, _NEW_HINT );
+ SWRAST_CONTEXT(ctx)->AllowPixelFog = value;
+}
+
+
+GLboolean
+_swrast_CreateContext( GLcontext *ctx )
+{
+ GLuint i;
+ SWcontext *swrast = (SWcontext *)CALLOC(sizeof(SWcontext));
+
+ if (SWRAST_DEBUG) {
+ _mesa_debug(ctx, "_swrast_CreateContext\n");
+ }
+
+ if (!swrast)
+ return GL_FALSE;
+
+ swrast->NewState = ~0;
+
+ swrast->choose_point = _swrast_choose_point;
+ swrast->choose_line = _swrast_choose_line;
+ swrast->choose_triangle = _swrast_choose_triangle;
+
+ swrast->invalidate_point = _SWRAST_NEW_POINT;
+ swrast->invalidate_line = _SWRAST_NEW_LINE;
+ swrast->invalidate_triangle = _SWRAST_NEW_TRIANGLE;
+
+ swrast->Point = _swrast_validate_point;
+ swrast->Line = _swrast_validate_line;
+ swrast->Triangle = _swrast_validate_triangle;
+ swrast->InvalidateState = _swrast_sleep;
+ swrast->BlendFunc = _swrast_validate_blend_func;
+
+ swrast->AllowVertexFog = GL_TRUE;
+ swrast->AllowPixelFog = GL_TRUE;
+
+ if (ctx->Visual.doubleBufferMode)
+ swrast->CurrentBufferBit = BUFFER_BIT_BACK_LEFT;
+ else
+ swrast->CurrentBufferBit = BUFFER_FRONT_LEFT;
+
+ /* Optimized Accum buffer */
+ swrast->_IntegerAccumMode = GL_FALSE;
+ swrast->_IntegerAccumScaler = 0.0;
+
+ for (i = 0; i < MAX_TEXTURE_IMAGE_UNITS; i++)
+ swrast->TextureSample[i] = _swrast_validate_texture_sample;
+
+ swrast->SpanArrays = MALLOC_STRUCT(span_arrays);
+ if (!swrast->SpanArrays) {
+ FREE(swrast);
+ return GL_FALSE;
+ }
+
+ /* init point span buffer */
+ swrast->PointSpan.primitive = GL_POINT;
+ swrast->PointSpan.start = 0;
+ swrast->PointSpan.end = 0;
+ swrast->PointSpan.facing = 0;
+ swrast->PointSpan.array = swrast->SpanArrays;
+
+ assert(ctx->Const.MaxTextureUnits > 0);
+ assert(ctx->Const.MaxTextureUnits <= MAX_TEXTURE_UNITS);
+
+ swrast->TexelBuffer = (GLchan *) MALLOC(ctx->Const.MaxTextureUnits *
+ MAX_WIDTH * 4 * sizeof(GLchan));
+ if (!swrast->TexelBuffer) {
+ FREE(swrast->SpanArrays);
+ FREE(swrast);
+ return GL_FALSE;
+ }
+
+ ctx->swrast_context = swrast;
+
+ return GL_TRUE;
+}
+
+void
+_swrast_DestroyContext( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ if (SWRAST_DEBUG) {
+ _mesa_debug(ctx, "_swrast_DestroyContext\n");
+ }
+
+ FREE( swrast->SpanArrays );
+ FREE( swrast->TexelBuffer );
+ FREE( swrast );
+
+ ctx->swrast_context = 0;
+}
+
+
+struct swrast_device_driver *
+_swrast_GetDeviceDriverReference( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ return &swrast->Driver;
+}
+
+void
+_swrast_flush( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ /* flush any pending fragments from rendering points */
+ if (swrast->PointSpan.end > 0) {
+ if (ctx->Visual.rgbMode) {
+ _swrast_write_rgba_span(ctx, &(swrast->PointSpan));
+ }
+ else {
+ _swrast_write_index_span(ctx, &(swrast->PointSpan));
+ }
+ swrast->PointSpan.end = 0;
+ }
+}
+
+void
+_swrast_render_primitive( GLcontext *ctx, GLenum prim )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ if (swrast->Primitive == GL_POINTS && prim != GL_POINTS) {
+ _swrast_flush(ctx);
+ }
+ swrast->Primitive = prim;
+}
+
+
+void
+_swrast_render_start( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ if (swrast->Driver.SpanRenderStart)
+ swrast->Driver.SpanRenderStart( ctx );
+ swrast->PointSpan.end = 0;
+}
+
+void
+_swrast_render_finish( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ if (swrast->Driver.SpanRenderFinish)
+ swrast->Driver.SpanRenderFinish( ctx );
+
+ _swrast_flush(ctx);
+}
+
+
+#define SWRAST_DEBUG_VERTICES 0
+
+void
+_swrast_print_vertex( GLcontext *ctx, const SWvertex *v )
+{
+ GLuint i;
+
+ if (SWRAST_DEBUG_VERTICES) {
+ _mesa_debug(ctx, "win %f %f %f %f\n",
+ v->win[0], v->win[1], v->win[2], v->win[3]);
+
+ for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
+ if (ctx->Texture.Unit[i]._ReallyEnabled)
+ _mesa_debug(ctx, "texcoord[%d] %f %f %f %f\n", i,
+ v->texcoord[i][0], v->texcoord[i][1],
+ v->texcoord[i][2], v->texcoord[i][3]);
+
+#if CHAN_TYPE == GL_FLOAT
+ _mesa_debug(ctx, "color %f %f %f %f\n",
+ v->color[0], v->color[1], v->color[2], v->color[3]);
+ _mesa_debug(ctx, "spec %f %f %f %f\n",
+ v->specular[0], v->specular[1],
+ v->specular[2], v->specular[3]);
+#else
+ _mesa_debug(ctx, "color %d %d %d %d\n",
+ v->color[0], v->color[1], v->color[2], v->color[3]);
+ _mesa_debug(ctx, "spec %d %d %d %d\n",
+ v->specular[0], v->specular[1],
+ v->specular[2], v->specular[3]);
+#endif
+ _mesa_debug(ctx, "fog %f\n", v->fog);
+ _mesa_debug(ctx, "index %d\n", v->index);
+ _mesa_debug(ctx, "pointsize %f\n", v->pointSize);
+ _mesa_debug(ctx, "\n");
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_context.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_context.h
new file mode 100644
index 000000000..5f5efdc22
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_context.h
@@ -0,0 +1,411 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file swrast/s_context.h
+ * \brief Software rasterization context and private types.
+ * \author Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+/**
+ * \mainpage swrast module
+ *
+ * This module, software rasterization, contains the software fallback
+ * routines for drawing points, lines, triangles, bitmaps and images.
+ * All rendering boils down to writing spans (arrays) of pixels with
+ * particular colors. The span-writing routines must be implemented
+ * by the device driver.
+ */
+
+
+#ifndef S_CONTEXT_H
+#define S_CONTEXT_H
+
+#include "mtypes.h"
+#include "swrast.h"
+
+
+/**
+ * \defgroup SpanFlags SPAN_XXX-flags
+ * Bitmasks to indicate which span_arrays need to be computed
+ * (sw_span::interpMask) or have already been filled
+ * (sw_span::arrayMask)
+ */
+/*@{*/
+#define SPAN_RGBA 0x001
+#define SPAN_SPEC 0x002
+#define SPAN_INDEX 0x004
+#define SPAN_Z 0x008
+#define SPAN_W 0x010
+#define SPAN_FOG 0x020
+#define SPAN_TEXTURE 0x040
+#define SPAN_INT_TEXTURE 0x080
+#define SPAN_LAMBDA 0x100
+#define SPAN_COVERAGE 0x200
+#define SPAN_FLAT 0x400 /**< flat shading? */
+/** sw_span::arrayMask only - for span_arrays::x, span_arrays::y */
+#define SPAN_XY 0x800
+#define SPAN_MASK 0x1000 /**< sw_span::arrayMask only */
+/*@}*/
+
+
+/**
+ * \struct span_arrays
+ * \brief Arrays of fragment values.
+ *
+ * These will either be computed from the x/xStep values above or
+ * filled in by glDraw/CopyPixels, etc.
+ * These arrays are separated out of sw_span to conserve memory.
+ */
+struct span_arrays {
+ GLchan rgb[MAX_WIDTH][3];
+ GLchan rgba[MAX_WIDTH][4];
+ GLuint index[MAX_WIDTH];
+ GLchan spec[MAX_WIDTH][4]; /* specular color */
+ GLint x[MAX_WIDTH]; /**< X/Y used for point/line rendering only */
+ GLint y[MAX_WIDTH]; /**< X/Y used for point/line rendering only */
+ GLdepth z[MAX_WIDTH];
+ GLfloat fog[MAX_WIDTH];
+ GLfloat texcoords[MAX_TEXTURE_COORD_UNITS][MAX_WIDTH][4];
+ GLfloat lambda[MAX_TEXTURE_COORD_UNITS][MAX_WIDTH];
+ GLfloat coverage[MAX_WIDTH];
+
+ /** This mask indicates if fragment is alive or culled */
+ GLubyte mask[MAX_WIDTH];
+};
+
+
+/**
+ * \struct sw_span
+ * \brief Contains data for either a horizontal line or a set of
+ * pixels that are passed through a pipeline of functions before being
+ * drawn.
+ *
+ * The sw_span structure describes the colors, Z, fogcoord, texcoords,
+ * etc for either a horizontal run or an array of independent pixels.
+ * We can either specify a base/step to indicate interpolated values, or
+ * fill in arrays of values. The interpMask and arrayMask bitfields
+ * indicate which are active.
+ *
+ * With this structure it's easy to hand-off span rasterization to
+ * subroutines instead of doing it all inline in the triangle functions
+ * like we used to do.
+ * It also cleans up the local variable namespace a great deal.
+ *
+ * It would be interesting to experiment with multiprocessor rasterization
+ * with this structure. The triangle rasterizer could simply emit a
+ * stream of these structures which would be consumed by one or more
+ * span-processing threads which could run in parallel.
+ */
+struct sw_span {
+ GLint x, y;
+
+ /** Only need to process pixels between start <= i < end */
+ /** At this time, start is always zero. */
+ GLuint start, end;
+
+ /** This flag indicates that mask[] array is effectively filled with ones */
+ GLboolean writeAll;
+
+ /** either GL_POLYGON, GL_LINE, GL_POLYGON, GL_BITMAP */
+ GLenum primitive;
+
+ /** 0 = front-facing span, 1 = back-facing span (for two-sided stencil) */
+ GLuint facing;
+
+ /**
+ * This bitmask (of \link SpanFlags SPAN_* flags\endlink) indicates
+ * which of the x/xStep variables are relevant.
+ */
+ GLuint interpMask;
+
+ /* For horizontal spans, step is the partial derivative wrt X.
+ * For lines, step is the delta from one fragment to the next.
+ */
+#if CHAN_TYPE == GL_FLOAT
+ GLfloat red, redStep;
+ GLfloat green, greenStep;
+ GLfloat blue, blueStep;
+ GLfloat alpha, alphaStep;
+ GLfloat specRed, specRedStep;
+ GLfloat specGreen, specGreenStep;
+ GLfloat specBlue, specBlueStep;
+#else /* CHAN_TYPE == GL_UNSIGNED_BYTE or GL_UNSIGNED_SHORT */
+ GLfixed red, redStep;
+ GLfixed green, greenStep;
+ GLfixed blue, blueStep;
+ GLfixed alpha, alphaStep;
+ GLfixed specRed, specRedStep;
+ GLfixed specGreen, specGreenStep;
+ GLfixed specBlue, specBlueStep;
+#endif
+ GLfixed index, indexStep;
+ GLfixed z, zStep;
+ GLfloat fog, fogStep;
+ GLfloat tex[MAX_TEXTURE_COORD_UNITS][4]; /* s, t, r, q */
+ GLfloat texStepX[MAX_TEXTURE_COORD_UNITS][4];
+ GLfloat texStepY[MAX_TEXTURE_COORD_UNITS][4];
+ GLfixed intTex[2], intTexStep[2]; /* s, t only */
+
+ /* partial derivatives wrt X and Y. */
+ GLfloat dzdx, dzdy;
+ GLfloat w, dwdx, dwdy;
+ GLfloat drdx, drdy;
+ GLfloat dgdx, dgdy;
+ GLfloat dbdx, dbdy;
+ GLfloat dadx, dady;
+ GLfloat dsrdx, dsrdy;
+ GLfloat dsgdx, dsgdy;
+ GLfloat dsbdx, dsbdy;
+ GLfloat dfogdx, dfogdy;
+
+ /**
+ * This bitmask (of \link SpanFlags SPAN_* flags\endlink) indicates
+ * which of the fragment arrays in the span_arrays struct are relevant.
+ */
+ GLuint arrayMask;
+
+ /**
+ * We store the arrays of fragment values in a separate struct so
+ * that we can allocate sw_span structs on the stack without using
+ * a lot of memory. The span_arrays struct is about 400KB while the
+ * sw_span struct is only about 512 bytes.
+ */
+ struct span_arrays *array;
+};
+
+
+#define INIT_SPAN(S, PRIMITIVE, END, INTERP_MASK, ARRAY_MASK) \
+do { \
+ (S).primitive = (PRIMITIVE); \
+ (S).interpMask = (INTERP_MASK); \
+ (S).arrayMask = (ARRAY_MASK); \
+ (S).start = 0; \
+ (S).end = (END); \
+ (S).facing = 0; \
+ (S).array = SWRAST_CONTEXT(ctx)->SpanArrays; \
+} while (0)
+
+
+typedef void (*texture_sample_func)(GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoords[][4],
+ const GLfloat lambda[], GLchan rgba[][4]);
+
+typedef void (_ASMAPIP blend_func)( GLcontext *ctx, GLuint n,
+ const GLubyte mask[],
+ GLchan src[][4], CONST GLchan dst[][4] );
+
+typedef void (*swrast_point_func)( GLcontext *ctx, const SWvertex *);
+
+typedef void (*swrast_line_func)( GLcontext *ctx,
+ const SWvertex *, const SWvertex *);
+
+typedef void (*swrast_tri_func)( GLcontext *ctx, const SWvertex *,
+ const SWvertex *, const SWvertex *);
+
+
+/** \defgroup Bitmasks
+ * Bitmasks to indicate which rasterization options are enabled
+ * (RasterMask)
+ */
+/*@{*/
+#define ALPHATEST_BIT 0x001 /**< Alpha-test pixels */
+#define BLEND_BIT 0x002 /**< Blend pixels */
+#define DEPTH_BIT 0x004 /**< Depth-test pixels */
+#define FOG_BIT 0x008 /**< Fog pixels */
+#define LOGIC_OP_BIT 0x010 /**< Apply logic op in software */
+#define CLIP_BIT 0x020 /**< Scissor or window clip pixels */
+#define STENCIL_BIT 0x040 /**< Stencil pixels */
+#define MASKING_BIT 0x080 /**< Do glColorMask or glIndexMask */
+#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 */
+#define FRAGPROG_BIT 0x2000 /**< Fragment program enabled */
+#define ATIFRAGSHADER_BIT 0x4000 /**< ATI Fragment shader enabled */
+/*@}*/
+
+#define _SWRAST_NEW_RASTERMASK (_NEW_BUFFERS| \
+ _NEW_SCISSOR| \
+ _NEW_COLOR| \
+ _NEW_DEPTH| \
+ _NEW_FOG| \
+ _NEW_PROGRAM| \
+ _NEW_STENCIL| \
+ _NEW_TEXTURE| \
+ _NEW_VIEWPORT| \
+ _NEW_DEPTH)
+
+
+/**
+ * \struct SWcontext
+ * \brief SWContext?
+ */
+typedef struct
+{
+ /** Driver interface:
+ */
+ struct swrast_device_driver Driver;
+
+ /** Configuration mechanisms to make software rasterizer match
+ * characteristics of the hardware rasterizer (if present):
+ */
+ GLboolean AllowVertexFog;
+ GLboolean AllowPixelFog;
+
+ /** Derived values, invalidated on statechanges, updated from
+ * _swrast_validate_derived():
+ */
+ GLuint _RasterMask;
+ GLfloat _MinMagThresh[MAX_TEXTURE_IMAGE_UNITS];
+ GLfloat _BackfaceSign;
+ GLboolean _PreferPixelFog; /* Compute fog blend factor per fragment? */
+ GLboolean _AnyTextureCombine;
+ GLchan _FogColor[3];
+ GLboolean _FogEnabled;
+ GLenum _FogMode; /* either GL_FOG_MODE or fragment program's fog mode */
+
+ /* Accum buffer temporaries.
+ */
+ GLboolean _IntegerAccumMode; /**< Storing unscaled integers? */
+ GLfloat _IntegerAccumScaler; /**< Implicit scale factor */
+
+ /* Working values:
+ */
+ GLuint StippleCounter; /**< Line stipple counter */
+ GLuint NewState;
+ GLuint StateChanges;
+ GLenum Primitive; /* current primitive being drawn (ala glBegin) */
+ GLbitfield CurrentBufferBit; /* exactly one the of DD_*_BIT buffer bits */
+
+ /** Mechanism to allow driver (like X11) to register further
+ * software rasterization routines.
+ */
+ /*@{*/
+ void (*choose_point)( GLcontext * );
+ void (*choose_line)( GLcontext * );
+ void (*choose_triangle)( GLcontext * );
+
+ GLuint invalidate_point;
+ GLuint invalidate_line;
+ GLuint invalidate_triangle;
+ /*@}*/
+
+ /** Function pointers for dispatch behind public entrypoints. */
+ /*@{*/
+ void (*InvalidateState)( GLcontext *ctx, GLuint new_state );
+
+ swrast_point_func Point;
+ swrast_line_func Line;
+ swrast_tri_func Triangle;
+ /*@}*/
+
+ /**
+ * Placeholders for when separate specular (or secondary color) is
+ * enabled but texturing is not.
+ */
+ /*@{*/
+ swrast_point_func SpecPoint;
+ swrast_line_func SpecLine;
+ swrast_tri_func SpecTriangle;
+ /*@}*/
+
+ /**
+ * Typically, we'll allocate a sw_span structure as a local variable
+ * and set its 'array' pointer to point to this object. The reason is
+ * this object is big and causes problems when allocated on the stack
+ * on some systems.
+ */
+ struct span_arrays *SpanArrays;
+
+ /**
+ * Used to buffer N GL_POINTS, instead of rendering one by one.
+ */
+ struct sw_span PointSpan;
+
+ /** Internal hooks, kept uptodate by the same mechanism as above.
+ */
+ blend_func BlendFunc;
+ texture_sample_func TextureSample[MAX_TEXTURE_IMAGE_UNITS];
+
+ /** Buffer for saving the sampled texture colors.
+ * Needed for GL_ARB_texture_env_crossbar implementation.
+ */
+ GLchan *TexelBuffer;
+
+} SWcontext;
+
+
+extern void
+_swrast_validate_derived( GLcontext *ctx );
+
+
+#define SWRAST_CONTEXT(ctx) ((SWcontext *)ctx->swrast_context)
+
+#define RENDER_START(SWctx, GLctx) \
+ do { \
+ if ((SWctx)->Driver.SpanRenderStart) { \
+ (*(SWctx)->Driver.SpanRenderStart)(GLctx); \
+ } \
+ } while (0)
+
+#define RENDER_FINISH(SWctx, GLctx) \
+ do { \
+ if ((SWctx)->Driver.SpanRenderFinish) { \
+ (*(SWctx)->Driver.SpanRenderFinish)(GLctx); \
+ } \
+ } while (0)
+
+
+
+/*
+ * XXX these macros are just bandages for now in order to make
+ * CHAN_BITS==32 compile cleanly.
+ * These should probably go elsewhere at some point.
+ */
+#if CHAN_TYPE == GL_FLOAT
+#define ChanToFixed(X) (X)
+#define FixedToChan(X) (X)
+#else
+#define ChanToFixed(X) IntToFixed(X)
+#define FixedToChan(X) FixedToInt(X)
+#endif
+
+
+
+extern void
+_swrast_translate_program( GLcontext *ctx );
+
+extern GLboolean
+_swrast_execute_codegen_program(GLcontext *ctx,
+ const struct fragment_program *program,
+ GLuint maxInst,
+ struct fp_machine *machine,
+ const struct sw_span *span,
+ GLuint column );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_copypix.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_copypix.c
new file mode 100644
index 000000000..05f81c690
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_copypix.c
@@ -0,0 +1,801 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "colormac.h"
+#include "convolve.h"
+#include "histogram.h"
+#include "image.h"
+#include "macros.h"
+#include "imports.h"
+#include "pixel.h"
+
+#include "s_context.h"
+#include "s_depth.h"
+#include "s_pixeltex.h"
+#include "s_span.h"
+#include "s_stencil.h"
+#include "s_texture.h"
+#include "s_zoom.h"
+
+
+
+/*
+ * Determine if there's overlap in an image copy.
+ * This test also compensates for the fact that copies are done from
+ * bottom to top and overlaps can sometimes be handled correctly
+ * without making a temporary image copy.
+ */
+static GLboolean
+regions_overlap(GLint srcx, GLint srcy,
+ GLint dstx, GLint dsty,
+ GLint width, GLint height,
+ GLfloat zoomX, GLfloat zoomY)
+{
+ if (zoomX == 1.0 && zoomY == 1.0) {
+ /* no zoom */
+ if (srcx >= dstx + width || (srcx + width <= dstx)) {
+ return GL_FALSE;
+ }
+ else if (srcy < dsty) { /* this is OK */
+ return GL_FALSE;
+ }
+ else if (srcy > dsty + height) {
+ return GL_FALSE;
+ }
+ else {
+ return GL_TRUE;
+ }
+ }
+ else {
+ /* add one pixel of slop when zooming, just to be safe */
+ if ((srcx > dstx + (width * zoomX) + 1) || (srcx + width + 1 < dstx)) {
+ return GL_FALSE;
+ }
+ else if ((srcy < dsty) && (srcy + height < dsty + (height * zoomY))) {
+ return GL_FALSE;
+ }
+ else if ((srcy > dsty) && (srcy + height > dsty + (height * zoomY))) {
+ return GL_FALSE;
+ }
+ else {
+ return GL_TRUE;
+ }
+ }
+}
+
+
+/**
+ * Convert GLfloat[n][4] colors to GLchan[n][4].
+ * XXX maybe move into image.c
+ */
+static void
+float_span_to_chan(GLuint n, CONST GLfloat in[][4], GLchan out[][4])
+{
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ UNCLAMPED_FLOAT_TO_CHAN(out[i][RCOMP], in[i][RCOMP]);
+ UNCLAMPED_FLOAT_TO_CHAN(out[i][GCOMP], in[i][GCOMP]);
+ UNCLAMPED_FLOAT_TO_CHAN(out[i][BCOMP], in[i][BCOMP]);
+ UNCLAMPED_FLOAT_TO_CHAN(out[i][ACOMP], in[i][ACOMP]);
+ }
+}
+
+
+/**
+ * Convert GLchan[n][4] colors to GLfloat[n][4].
+ * XXX maybe move into image.c
+ */
+static void
+chan_span_to_float(GLuint n, CONST GLchan in[][4], GLfloat out[][4])
+{
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ out[i][RCOMP] = CHAN_TO_FLOAT(in[i][RCOMP]);
+ out[i][GCOMP] = CHAN_TO_FLOAT(in[i][GCOMP]);
+ out[i][BCOMP] = CHAN_TO_FLOAT(in[i][BCOMP]);
+ out[i][ACOMP] = CHAN_TO_FLOAT(in[i][ACOMP]);
+ }
+}
+
+
+
+/*
+ * RGBA copypixels with convolution.
+ */
+static void
+copy_conv_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
+ GLint width, GLint height, GLint destx, GLint desty)
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *drawRb = NULL;
+ GLboolean quick_draw;
+ GLint row;
+ GLboolean changeBuffer;
+ const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
+ const GLuint transferOps = ctx->_ImageTransferState;
+ GLfloat *dest, *tmpImage, *convImage;
+ struct sw_span span;
+
+ INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA);
+
+ if (ctx->Depth.Test)
+ _swrast_span_default_z(ctx, &span);
+ if (swrast->_FogEnabled)
+ _swrast_span_default_fog(ctx, &span);
+
+
+ if (SWRAST_CONTEXT(ctx)->_RasterMask == 0
+ && !zoom
+ && destx >= 0
+ && destx + width <= (GLint) ctx->DrawBuffer->Width) {
+ quick_draw = GL_TRUE;
+ drawRb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+ }
+ else {
+ quick_draw = GL_FALSE;
+ }
+
+ /* If read and draw buffer are different we must do buffer switching */
+ changeBuffer = ctx->Pixel.ReadBuffer != ctx->Color.DrawBuffer[0]
+ || ctx->DrawBuffer != ctx->ReadBuffer;
+
+
+ /* allocate space for GLfloat image */
+ tmpImage = (GLfloat *) MALLOC(width * height * 4 * sizeof(GLfloat));
+ if (!tmpImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels");
+ return;
+ }
+ convImage = (GLfloat *) MALLOC(width * height * 4 * sizeof(GLfloat));
+ if (!convImage) {
+ FREE(tmpImage);
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels");
+ return;
+ }
+
+ if (changeBuffer) {
+ /* choose the read buffer */
+ _swrast_use_read_buffer(ctx);
+ }
+
+ /* read source image */
+ dest = tmpImage;
+ for (row = 0; row < height; row++) {
+ GLchan rgba[MAX_WIDTH][4];
+ /* Read GLchan and convert to GLfloat */
+ _swrast_read_rgba_span(ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, srcx, srcy + row, rgba);
+ chan_span_to_float(width, (CONST GLchan (*)[4]) rgba,
+ (GLfloat (*)[4]) dest);
+ dest += 4 * width;
+ }
+
+ if (changeBuffer) {
+ /* restore default src/dst buffer */
+ _swrast_use_draw_buffer(ctx);
+ }
+
+ /* do the image transfer ops which preceed convolution */
+ for (row = 0; row < height; row++) {
+ GLfloat (*rgba)[4] = (GLfloat (*)[4]) (tmpImage + row * width * 4);
+ _mesa_apply_rgba_transfer_ops(ctx,
+ transferOps & IMAGE_PRE_CONVOLUTION_BITS,
+ width, rgba);
+ }
+
+ /* do convolution */
+ if (ctx->Pixel.Convolution2DEnabled) {
+ _mesa_convolve_2d_image(ctx, &width, &height, tmpImage, convImage);
+ }
+ else {
+ ASSERT(ctx->Pixel.Separable2DEnabled);
+ _mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage);
+ }
+ FREE(tmpImage);
+
+ /* do remaining post-convolution image transfer ops */
+ for (row = 0; row < height; row++) {
+ GLfloat (*rgba)[4] = (GLfloat (*)[4]) (convImage + row * width * 4);
+ _mesa_apply_rgba_transfer_ops(ctx,
+ transferOps & IMAGE_POST_CONVOLUTION_BITS,
+ width, rgba);
+ }
+
+ /* write the new image */
+ for (row = 0; row < height; row++) {
+ const GLfloat *src = convImage + row * width * 4;
+ GLint dy;
+
+ /* convert floats back to chan */
+ float_span_to_chan(width, (const GLfloat (*)[4]) src, span.array->rgba);
+
+ if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._EnabledUnits) {
+ span.end = width;
+ _swrast_pixel_texture(ctx, &span);
+ }
+
+ /* write row to framebuffer */
+
+ dy = desty + row;
+ if (quick_draw && dy >= 0 && dy < (GLint) ctx->DrawBuffer->Height) {
+ drawRb->PutRow(ctx, drawRb, width, destx, dy, span.array->rgba, NULL);
+ }
+ else if (zoom) {
+ span.x = destx;
+ span.y = dy;
+ span.end = width;
+ _swrast_write_zoomed_rgba_span(ctx, &span,
+ (CONST GLchan (*)[4])span.array->rgba,
+ desty, 0);
+ }
+ else {
+ span.x = destx;
+ span.y = dy;
+ span.end = width;
+ _swrast_write_rgba_span(ctx, &span);
+ }
+ }
+
+ FREE(convImage);
+}
+
+
+/*
+ * RGBA copypixels
+ */
+static void
+copy_rgba_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
+ GLint width, GLint height, GLint destx, GLint desty)
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *drawRb;
+ GLchan *tmpImage,*p;
+ GLboolean quick_draw;
+ GLint sy, dy, stepy, j;
+ GLboolean changeBuffer;
+ const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
+ GLint overlapping;
+ const GLuint transferOps = ctx->_ImageTransferState;
+ struct sw_span span;
+
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no readbuffer - OK */
+ return;
+ }
+
+ INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA);
+
+ if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
+ copy_conv_rgba_pixels(ctx, srcx, srcy, width, height, destx, desty);
+ return;
+ }
+
+ /* Determine if copy should be done bottom-to-top or top-to-bottom */
+ if (srcy < desty) {
+ /* top-down max-to-min */
+ sy = srcy + height - 1;
+ dy = desty + height - 1;
+ stepy = -1;
+ }
+ else {
+ /* bottom-up min-to-max */
+ sy = srcy;
+ dy = desty;
+ stepy = 1;
+ }
+
+ if (ctx->DrawBuffer == ctx->ReadBuffer) {
+ overlapping = regions_overlap(srcx, srcy, destx, desty, width, height,
+ ctx->Pixel.ZoomX, ctx->Pixel.ZoomY);
+ }
+ else {
+ overlapping = GL_FALSE;
+ }
+
+ if (ctx->Depth.Test)
+ _swrast_span_default_z(ctx, &span);
+ if (swrast->_FogEnabled)
+ _swrast_span_default_fog(ctx, &span);
+
+ if (SWRAST_CONTEXT(ctx)->_RasterMask == 0
+ && !zoom
+ && destx >= 0
+ && destx + width <= (GLint) ctx->DrawBuffer->Width) {
+ quick_draw = GL_TRUE;
+ drawRb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+ }
+ else {
+ quick_draw = GL_FALSE;
+ drawRb = NULL;
+ }
+
+ /* If read and draw buffer are different we must do buffer switching */
+ changeBuffer = ctx->Pixel.ReadBuffer != ctx->Color.DrawBuffer[0]
+ || ctx->DrawBuffer != ctx->ReadBuffer;
+
+ if (overlapping) {
+ GLint ssy = sy;
+ tmpImage = (GLchan *) MALLOC(width * height * sizeof(GLchan) * 4);
+ if (!tmpImage) {
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" );
+ return;
+ }
+ /* setup source */
+ if (changeBuffer)
+ _swrast_use_read_buffer(ctx);
+ /* read the source image */
+ p = tmpImage;
+ for (j = 0; j < height; j++, ssy += stepy) {
+ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, srcx, ssy, (GLchan (*)[4]) p );
+ p += width * 4;
+ }
+ p = tmpImage;
+ /* restore dest */
+ if (changeBuffer) {
+ _swrast_use_draw_buffer(ctx);
+ changeBuffer = GL_FALSE;
+ }
+ }
+ else {
+ tmpImage = NULL; /* silence compiler warnings */
+ p = NULL;
+ }
+
+ for (j = 0; j < height; j++, sy += stepy, dy += stepy) {
+ /* Get source pixels */
+ if (overlapping) {
+ /* get from buffered image */
+ ASSERT(width < MAX_WIDTH);
+ MEMCPY(span.array->rgba, p, width * sizeof(GLchan) * 4);
+ p += width * 4;
+ }
+ else {
+ /* get from framebuffer */
+ if (changeBuffer)
+ _swrast_use_read_buffer(ctx);
+ ASSERT(width < MAX_WIDTH);
+ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, srcx, sy, span.array->rgba );
+ if (changeBuffer)
+ _swrast_use_draw_buffer(ctx);
+ }
+
+ if (transferOps) {
+ DEFMARRAY(GLfloat, rgbaFloat, MAX_WIDTH, 4); /* mac 32k limitation */
+ CHECKARRAY(rgbaFloat, return);
+
+ /* convert to float, transfer, convert back to chan */
+ chan_span_to_float(width, (CONST GLchan (*)[4]) span.array->rgba,
+ rgbaFloat);
+ _mesa_apply_rgba_transfer_ops(ctx, transferOps, width, rgbaFloat);
+ float_span_to_chan(width, (CONST GLfloat (*)[4]) rgbaFloat,
+ span.array->rgba);
+
+ UNDEFARRAY(rgbaFloat); /* mac 32k limitation */
+ }
+
+ if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._EnabledUnits) {
+ span.end = width;
+ _swrast_pixel_texture(ctx, &span);
+ }
+
+ /* Write color span */
+ if (quick_draw && dy >= 0 && dy < (GLint) ctx->DrawBuffer->Height) {
+ drawRb->PutRow(ctx, drawRb, width, destx, dy, span.array->rgba, NULL);
+ }
+ else if (zoom) {
+ span.x = destx;
+ span.y = dy;
+ span.end = width;
+ _swrast_write_zoomed_rgba_span(ctx, &span,
+ (CONST GLchan (*)[4]) span.array->rgba,
+ desty, 0);
+ }
+ else {
+ span.x = destx;
+ span.y = dy;
+ span.end = width;
+ _swrast_write_rgba_span(ctx, &span);
+ }
+ }
+
+ if (overlapping)
+ FREE(tmpImage);
+}
+
+
+static void
+copy_ci_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
+ GLint width, GLint height,
+ GLint destx, GLint desty )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLuint *tmpImage,*p;
+ GLint sy, dy, stepy;
+ GLint j;
+ GLboolean changeBuffer;
+ const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
+ const GLboolean shift_or_offset = ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset;
+ GLint overlapping;
+ struct sw_span span;
+
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no readbuffer - OK */
+ return;
+ }
+
+ INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_INDEX);
+
+ /* Determine if copy should be bottom-to-top or top-to-bottom */
+ if (srcy<desty) {
+ /* top-down max-to-min */
+ sy = srcy + height - 1;
+ dy = desty + height - 1;
+ stepy = -1;
+ }
+ else {
+ /* bottom-up min-to-max */
+ sy = srcy;
+ dy = desty;
+ stepy = 1;
+ }
+
+ if (ctx->DrawBuffer == ctx->ReadBuffer) {
+ overlapping = regions_overlap(srcx, srcy, destx, desty, width, height,
+ ctx->Pixel.ZoomX, ctx->Pixel.ZoomY);
+ }
+ else {
+ overlapping = GL_FALSE;
+ }
+
+ if (ctx->Depth.Test)
+ _swrast_span_default_z(ctx, &span);
+ if (swrast->_FogEnabled)
+ _swrast_span_default_fog(ctx, &span);
+
+ /* If read and draw buffer are different we must do buffer switching */
+ changeBuffer = ctx->Pixel.ReadBuffer != ctx->Color.DrawBuffer[0]
+ || ctx->DrawBuffer != ctx->ReadBuffer;
+
+ if (overlapping) {
+ GLint ssy = sy;
+ tmpImage = (GLuint *) MALLOC(width * height * sizeof(GLuint));
+ if (!tmpImage) {
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" );
+ return;
+ }
+ /* setup source */
+ if (changeBuffer)
+ _swrast_use_read_buffer(ctx);
+ /* read the image */
+ p = tmpImage;
+ for (j = 0; j < height; j++, ssy += stepy) {
+ _swrast_read_index_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, srcx, ssy, p );
+ p += width;
+ }
+ p = tmpImage;
+ /* restore to draw buffer */
+ if (changeBuffer) {
+ _swrast_use_draw_buffer(ctx);
+ changeBuffer = GL_FALSE;
+ }
+ }
+ else {
+ tmpImage = NULL; /* silence compiler warning */
+ p = NULL;
+ }
+
+ for (j = 0; j < height; j++, sy += stepy, dy += stepy) {
+ /* Get color indexes */
+ if (overlapping) {
+ MEMCPY(span.array->index, p, width * sizeof(GLuint));
+ p += width;
+ }
+ else {
+ if (changeBuffer)
+ _swrast_use_read_buffer(ctx);
+ _swrast_read_index_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, srcx, sy, span.array->index );
+ if (changeBuffer)
+ _swrast_use_draw_buffer(ctx);
+ }
+
+ /* Apply shift, offset, look-up table */
+ if (shift_or_offset) {
+ _mesa_shift_and_offset_ci( ctx, width, span.array->index );
+ }
+ if (ctx->Pixel.MapColorFlag) {
+ _mesa_map_ci( ctx, width, span.array->index );
+ }
+
+ /* write color indexes */
+ span.x = destx;
+ span.y = dy;
+ span.end = width;
+ if (zoom)
+ _swrast_write_zoomed_index_span(ctx, &span, desty, 0);
+ else
+ _swrast_write_index_span(ctx, &span);
+ }
+
+ if (overlapping)
+ FREE(tmpImage);
+}
+
+
+
+/*
+ * TODO: Optimize!!!!
+ */
+static void
+copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
+ GLint width, GLint height,
+ GLint destx, GLint desty )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
+ struct gl_renderbuffer *readRb
+ = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+ GLfloat *p, *tmpImage;
+ GLint sy, dy, stepy;
+ GLint i, j;
+ const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
+ GLint overlapping;
+ struct sw_span span;
+
+ if (!readRb) {
+ /* no readbuffer - OK */
+ return;
+ }
+
+ INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_Z);
+
+ if (!ctx->Visual.depthBits) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" );
+ return;
+ }
+
+ /* Determine if copy should be bottom-to-top or top-to-bottom */
+ if (srcy<desty) {
+ /* top-down max-to-min */
+ sy = srcy + height - 1;
+ dy = desty + height - 1;
+ stepy = -1;
+ }
+ else {
+ /* bottom-up min-to-max */
+ sy = srcy;
+ dy = desty;
+ stepy = 1;
+ }
+
+ if (ctx->DrawBuffer == ctx->ReadBuffer) {
+ overlapping = regions_overlap(srcx, srcy, destx, desty, width, height,
+ ctx->Pixel.ZoomX, ctx->Pixel.ZoomY);
+ }
+ else {
+ overlapping = GL_FALSE;
+ }
+
+ _swrast_span_default_color(ctx, &span);
+ if (swrast->_FogEnabled)
+ _swrast_span_default_fog(ctx, &span);
+
+ if (overlapping) {
+ GLint ssy = sy;
+ tmpImage = (GLfloat *) MALLOC(width * height * sizeof(GLfloat));
+ if (!tmpImage) {
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" );
+ return;
+ }
+ p = tmpImage;
+ for (j = 0; j < height; j++, ssy += stepy) {
+ _swrast_read_depth_span_float(ctx, readRb, width, srcx, ssy, p);
+ p += width;
+ }
+ p = tmpImage;
+ }
+ else {
+ tmpImage = NULL; /* silence compiler warning */
+ p = NULL;
+ }
+
+ for (j = 0; j < height; j++, sy += stepy, dy += stepy) {
+ GLfloat depth[MAX_WIDTH];
+ /* get depth values */
+ if (overlapping) {
+ MEMCPY(depth, p, width * sizeof(GLfloat));
+ p += width;
+ }
+ else {
+ _swrast_read_depth_span_float(ctx, readRb, width, srcx, sy, depth);
+ }
+
+ /* apply scale and bias */
+ for (i = 0; i < width; i++) {
+ GLfloat d = depth[i] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias;
+ span.array->z[i] = (GLdepth) (CLAMP(d, 0.0F, 1.0F) * depthMax);
+ }
+
+ /* write depth values */
+ span.x = destx;
+ span.y = dy;
+ span.end = width;
+ if (ctx->Visual.rgbMode) {
+ if (zoom)
+ _swrast_write_zoomed_rgba_span( ctx, &span,
+ (const GLchan (*)[4])span.array->rgba, desty, 0 );
+ else
+ _swrast_write_rgba_span(ctx, &span);
+ }
+ else {
+ if (zoom)
+ _swrast_write_zoomed_index_span( ctx, &span, desty, 0 );
+ else
+ _swrast_write_index_span(ctx, &span);
+ }
+ }
+
+ if (overlapping)
+ FREE(tmpImage);
+}
+
+
+
+static void
+copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy,
+ GLint width, GLint height,
+ GLint destx, GLint desty )
+{
+ struct gl_renderbuffer *rb
+ = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
+ GLint sy, dy, stepy;
+ GLint j;
+ GLstencil *p, *tmpImage;
+ const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F;
+ const GLboolean shift_or_offset = ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset;
+ GLint overlapping;
+
+ if (!ctx->Visual.stencilBits) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" );
+ return;
+ }
+
+ if (!rb) {
+ /* no readbuffer - OK */
+ return;
+ }
+
+ /* Determine if copy should be bottom-to-top or top-to-bottom */
+ if (srcy < desty) {
+ /* top-down max-to-min */
+ sy = srcy + height - 1;
+ dy = desty + height - 1;
+ stepy = -1;
+ }
+ else {
+ /* bottom-up min-to-max */
+ sy = srcy;
+ dy = desty;
+ stepy = 1;
+ }
+
+ if (ctx->DrawBuffer == ctx->ReadBuffer) {
+ overlapping = regions_overlap(srcx, srcy, destx, desty, width, height,
+ ctx->Pixel.ZoomX, ctx->Pixel.ZoomY);
+ }
+ else {
+ overlapping = GL_FALSE;
+ }
+
+ if (overlapping) {
+ GLint ssy = sy;
+ tmpImage = (GLstencil *) MALLOC(width * height * sizeof(GLstencil));
+ if (!tmpImage) {
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyPixels" );
+ return;
+ }
+ p = tmpImage;
+ for (j = 0; j < height; j++, ssy += stepy) {
+ _swrast_read_stencil_span( ctx, rb, width, srcx, ssy, p );
+ p += width;
+ }
+ p = tmpImage;
+ }
+ else {
+ tmpImage = NULL; /* silence compiler warning */
+ p = NULL;
+ }
+
+ for (j = 0; j < height; j++, sy += stepy, dy += stepy) {
+ GLstencil stencil[MAX_WIDTH];
+
+ /* Get stencil values */
+ if (overlapping) {
+ MEMCPY(stencil, p, width * sizeof(GLstencil));
+ p += width;
+ }
+ else {
+ _swrast_read_stencil_span( ctx, rb, width, srcx, sy, stencil );
+ }
+
+ /* Apply shift, offset, look-up table */
+ if (shift_or_offset) {
+ _mesa_shift_and_offset_stencil( ctx, width, stencil );
+ }
+ if (ctx->Pixel.MapStencilFlag) {
+ _mesa_map_stencil( ctx, width, stencil );
+ }
+
+ /* Write stencil values */
+ if (zoom) {
+ _swrast_write_zoomed_stencil_span( ctx, width, destx, dy,
+ stencil, desty, 0 );
+ }
+ else {
+ _swrast_write_stencil_span( ctx, width, destx, dy, stencil );
+ }
+ }
+
+ if (overlapping)
+ FREE(tmpImage);
+}
+
+
+
+void
+_swrast_CopyPixels( GLcontext *ctx,
+ GLint srcx, GLint srcy, GLsizei width, GLsizei height,
+ GLint destx, GLint desty,
+ GLenum type )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ RENDER_START(swrast,ctx);
+
+ if (swrast->NewState)
+ _swrast_validate_derived( ctx );
+
+ if (type == GL_COLOR && ctx->Visual.rgbMode) {
+ copy_rgba_pixels( ctx, srcx, srcy, width, height, destx, desty );
+ }
+ else if (type == GL_COLOR && !ctx->Visual.rgbMode) {
+ copy_ci_pixels( ctx, srcx, srcy, width, height, destx, desty );
+ }
+ else if (type == GL_DEPTH) {
+ copy_depth_pixels( ctx, srcx, srcy, width, height, destx, desty );
+ }
+ else if (type == GL_STENCIL) {
+ copy_stencil_pixels( ctx, srcx, srcy, width, height, destx, desty );
+ }
+ else {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glCopyPixels" );
+ }
+
+ RENDER_FINISH(swrast,ctx);
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_depth.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_depth.c
new file mode 100644
index 000000000..b9d7d8949
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_depth.c
@@ -0,0 +1,1365 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+#include "fbobject.h"
+
+#include "s_depth.h"
+#include "s_context.h"
+#include "s_span.h"
+
+
+/**
+ * Do depth test for a horizontal span of fragments.
+ * Input: zbuffer - array of z values in the zbuffer
+ * z - array of fragment z values
+ * Return: number of fragments which pass the test.
+ */
+static GLuint
+depth_test_span16( GLcontext *ctx, GLuint n,
+ GLushort zbuffer[], const GLuint z[], GLubyte mask[] )
+{
+ GLuint passed = 0;
+
+ /* switch cases ordered from most frequent to less frequent */
+ switch (ctx->Depth.Func) {
+ case GL_LESS:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ if (z[i] < zbuffer[i]) {
+ /* pass */
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ if (z[i] < zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_LEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] <= zbuffer[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] <= zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_GEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] >= zbuffer[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] >= zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_GREATER:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] > zbuffer[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] > zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_NOTEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] != zbuffer[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] != zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_EQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] == zbuffer[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] == zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_ALWAYS:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer or mask */
+ passed = n;
+ }
+ break;
+ case GL_NEVER:
+ _mesa_bzero(mask, n * sizeof(GLubyte));
+ break;
+ default:
+ _mesa_problem(ctx, "Bad depth func in depth_test_span16");
+ }
+
+ return passed;
+}
+
+
+static GLuint
+depth_test_span32( GLcontext *ctx, GLuint n,
+ GLuint zbuffer[], const GLuint z[], GLubyte mask[] )
+{
+ GLuint passed = 0;
+
+ /* switch cases ordered from most frequent to less frequent */
+ switch (ctx->Depth.Func) {
+ case GL_LESS:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ if (z[i] < zbuffer[i]) {
+ /* pass */
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ if (z[i] < zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_LEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] <= zbuffer[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] <= zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_GEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] >= zbuffer[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] >= zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_GREATER:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] > zbuffer[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] > zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_NOTEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] != zbuffer[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] != zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_EQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] == zbuffer[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ if (z[i] == zbuffer[i]) {
+ /* pass */
+ passed++;
+ }
+ else {
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_ALWAYS:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ zbuffer[i] = z[i];
+ passed++;
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer or mask */
+ passed = n;
+ }
+ break;
+ case GL_NEVER:
+ _mesa_bzero(mask, n * sizeof(GLubyte));
+ break;
+ default:
+ _mesa_problem(ctx, "Bad depth func in depth_test_span32");
+ }
+
+ return passed;
+}
+
+
+
+/*
+ * Apply depth test to span of fragments.
+ */
+static GLuint
+depth_test_span( GLcontext *ctx, struct sw_span *span)
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
+ const GLint x = span->x;
+ const GLint y = span->y;
+ const GLuint count = span->end;
+ const GLuint *zValues = span->array->z;
+ GLubyte *mask = span->array->mask;
+ GLuint passed;
+
+ ASSERT((span->arrayMask & SPAN_XY) == 0);
+ ASSERT(span->arrayMask & SPAN_Z);
+
+ if (rb->GetPointer(ctx, rb, 0, 0)) {
+ /* Directly access buffer */
+ if (ctx->DrawBuffer->Visual.depthBits <= 16) {
+ GLushort *zbuffer = (GLushort *) rb->GetPointer(ctx, rb, x, y);
+ passed = depth_test_span16(ctx, count, zbuffer, zValues, mask);
+ }
+ else {
+ GLuint *zbuffer = (GLuint *) rb->GetPointer(ctx, rb, x, y);
+ passed = depth_test_span32(ctx, count, zbuffer, zValues, mask);
+ }
+ }
+ else {
+ /* read depth values from buffer, test, write back */
+ if (rb->DataType == GL_UNSIGNED_SHORT) {
+ GLushort zbuffer[MAX_WIDTH];
+ rb->GetRow(ctx, rb, count, x, y, zbuffer);
+ passed = depth_test_span16(ctx, count, zbuffer, zValues, mask );
+ rb->PutRow(ctx, rb, count, x, y, zbuffer, NULL);
+ }
+ else {
+ GLuint zbuffer[MAX_WIDTH];
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ rb->GetRow(ctx, rb, count, x, y, zbuffer);
+ passed = depth_test_span32(ctx, count, zbuffer, zValues, mask );
+ rb->PutRow(ctx, rb, count, x, y, zbuffer, NULL);
+ }
+ }
+
+ if (passed < count) {
+ span->writeAll = GL_FALSE;
+ }
+ return passed;
+}
+
+
+
+#define Z_ADDRESS(X, Y) (zStart + (Y) * stride + (X))
+
+
+/*
+ * Do depth testing for an array of fragments at assorted locations.
+ */
+static void
+direct_depth_test_pixels16(GLcontext *ctx, GLushort *zStart, GLuint stride,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLuint z[], GLubyte mask[] )
+{
+ /* switch cases ordered from most frequent to less frequent */
+ switch (ctx->Depth.Func) {
+ case GL_LESS:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] < *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] < *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_LEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] <= *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] <= *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_GEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] >= *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] >= *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_GREATER:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] > *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] > *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_NOTEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] != *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] != *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_EQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] == *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] == *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_ALWAYS:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLushort *zptr = Z_ADDRESS(x[i], y[i]);
+ *zptr = z[i];
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer or mask */
+ }
+ break;
+ case GL_NEVER:
+ /* depth test never passes */
+ _mesa_bzero(mask, n * sizeof(GLubyte));
+ break;
+ default:
+ _mesa_problem(ctx, "Bad depth func in direct_depth_test_pixels");
+ }
+}
+
+
+
+/*
+ * Do depth testing for an array of fragments with direct access to zbuffer.
+ */
+static void
+direct_depth_test_pixels32(GLcontext *ctx, GLuint *zStart, GLuint stride,
+ GLuint n, const GLint x[], const GLint y[],
+ const GLuint z[], GLubyte mask[] )
+{
+ /* switch cases ordered from most frequent to less frequent */
+ switch (ctx->Depth.Func) {
+ case GL_LESS:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] < *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] < *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_LEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] <= *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] <= *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_GEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] >= *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] >= *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_GREATER:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] > *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] > *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_NOTEQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] != *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] != *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_EQUAL:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] == *zptr) {
+ /* pass */
+ *zptr = z[i];
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
+ if (z[i] == *zptr) {
+ /* pass */
+ }
+ else {
+ /* fail */
+ mask[i] = 0;
+ }
+ }
+ }
+ }
+ break;
+ case GL_ALWAYS:
+ if (ctx->Depth.Mask) {
+ /* Update Z buffer */
+ GLuint i;
+ for (i=0; i<n; i++) {
+ if (mask[i]) {
+ GLuint *zptr = Z_ADDRESS(x[i], y[i]);
+ *zptr = z[i];
+ }
+ }
+ }
+ else {
+ /* Don't update Z buffer or mask */
+ }
+ break;
+ case GL_NEVER:
+ /* depth test never passes */
+ _mesa_bzero(mask, n * sizeof(GLubyte));
+ break;
+ default:
+ _mesa_problem(ctx, "Bad depth func in direct_depth_test_pixels");
+ }
+}
+
+
+
+
+static GLuint
+depth_test_pixels( GLcontext *ctx, struct sw_span *span )
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
+ const GLuint count = span->end;
+ const GLint *x = span->array->x;
+ const GLint *y = span->array->y;
+ const GLuint *z = span->array->z;
+ GLubyte *mask = span->array->mask;
+
+ if (rb->GetPointer(ctx, rb, 0, 0)) {
+ /* Directly access values */
+ if (rb->DataType == GL_UNSIGNED_SHORT) {
+ GLushort *zStart = (GLushort *) rb->Data;
+ GLuint stride = rb->Width;
+ direct_depth_test_pixels16(ctx, zStart, stride, count, x, y, z, mask);
+ }
+ else {
+ GLuint *zStart = (GLuint *) rb->Data;
+ GLuint stride = rb->Width;
+ direct_depth_test_pixels32(ctx, zStart, stride, count, x, y, z, mask);
+ }
+ }
+ else {
+ /* read depth values from buffer, test, write back */
+ if (rb->DataType == GL_UNSIGNED_SHORT) {
+ GLushort zbuffer[MAX_WIDTH];
+ _swrast_get_values(ctx, rb, count, x, y, zbuffer, sizeof(GLushort));
+ depth_test_span16(ctx, count, zbuffer, z, mask );
+ rb->PutValues(ctx, rb, count, x, y, zbuffer, NULL);
+ }
+ else {
+ GLuint zbuffer[MAX_WIDTH];
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ _swrast_get_values(ctx, rb, count, x, y, zbuffer, sizeof(GLuint));
+ depth_test_span32(ctx, count, zbuffer, z, mask );
+ rb->PutValues(ctx, rb, count, x, y, zbuffer, NULL);
+ }
+ }
+
+ return count; /* not really correct, but OK */
+}
+
+
+/**
+ * Apply depth (Z) buffer testing to the span.
+ * \return approx number of pixels that passed (only zero is reliable)
+ */
+GLuint
+_swrast_depth_test_span( GLcontext *ctx, struct sw_span *span)
+{
+ if (span->arrayMask & SPAN_XY)
+ return depth_test_pixels(ctx, span);
+ else
+ return depth_test_span(ctx, span);
+}
+
+
+/**
+ * GL_EXT_depth_bounds_test extension.
+ * Discard fragments depending on whether the corresponding Z-buffer
+ * values are outside the depth bounds test range.
+ * Note: we test the Z buffer values, not the fragment Z values!
+ * \return GL_TRUE if any fragments pass, GL_FALSE if no fragments pass
+ */
+GLboolean
+_swrast_depth_bounds_test( GLcontext *ctx, struct sw_span *span )
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_DEPTH].Renderbuffer;
+ GLuint zMin = (GLuint) (ctx->Depth.BoundsMin * fb->_DepthMaxF + 0.5F);
+ GLuint zMax = (GLuint) (ctx->Depth.BoundsMax * fb->_DepthMaxF + 0.5F);
+ GLubyte *mask = span->array->mask;
+ const GLuint count = span->end;
+ GLuint i;
+ GLboolean anyPass = GL_FALSE;
+
+ if (rb->DataType == GL_UNSIGNED_SHORT) {
+ /* get 16-bit values */
+ GLushort zbuffer16[MAX_WIDTH], *zbuffer;
+ if (span->arrayMask & SPAN_XY) {
+ _swrast_get_values(ctx, rb, count, span->array->x, span->array->y,
+ zbuffer16, sizeof(GLushort));
+ zbuffer = zbuffer16;
+ }
+ else {
+ zbuffer = rb->GetPointer(ctx, rb, span->x, span->y);
+ if (!zbuffer) {
+ rb->GetRow(ctx, rb, count, span->x, span->y, zbuffer16);
+ zbuffer = zbuffer16;
+ }
+ }
+ assert(zbuffer);
+
+ /* Now do the tests */
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ if (zbuffer[i] < zMin || zbuffer[i] > zMax)
+ mask[i] = GL_FALSE;
+ else
+ anyPass = GL_TRUE;
+ }
+ }
+ }
+ else {
+ /* get 32-bit values */
+ GLuint zbuffer32[MAX_WIDTH], *zbuffer;
+ if (span->arrayMask & SPAN_XY) {
+ _swrast_get_values(ctx, rb, count, span->array->x, span->array->y,
+ zbuffer32, sizeof(GLuint));
+ zbuffer = zbuffer32;
+ }
+ else {
+ zbuffer = rb->GetPointer(ctx, rb, span->x, span->y);
+ if (!zbuffer) {
+ rb->GetRow(ctx, rb, count, span->x, span->y, zbuffer32);
+ zbuffer = zbuffer32;
+ }
+ }
+ assert(zbuffer);
+
+ /* Now do the tests */
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ if (zbuffer[i] < zMin || zbuffer[i] > zMax)
+ mask[i] = GL_FALSE;
+ else
+ anyPass = GL_TRUE;
+ }
+ }
+ }
+
+ return anyPass;
+}
+
+
+
+/**********************************************************************/
+/***** Read Depth Buffer *****/
+/**********************************************************************/
+
+
+/**
+ * Read a span of depth values from the depth buffer.
+ * This function does clipping before calling the device driver function.
+ *
+ * XXXX this is no longer a swrast function!!!
+ *
+ */
+void
+_swrast_read_depth_span( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint n, GLint x, GLint y, GLuint depth[] )
+{
+ if (y < 0 || y >= (GLint) rb->Height ||
+ x + (GLint) n <= 0 || x >= (GLint) rb->Width) {
+ /* span is completely outside framebuffer */
+ GLint i;
+ for (i = 0; i < n; i++)
+ depth[i] = 0;
+ return;
+ }
+
+ if (x < 0) {
+ GLint dx = -x;
+ GLint i;
+ for (i = 0; i < dx; i++)
+ depth[i] = 0;
+ x = 0;
+ n -= dx;
+ depth += dx;
+ }
+ if (x + n > (GLint) rb->Width) {
+ GLint dx = x + n - (GLint) rb->Width;
+ GLint i;
+ for (i = 0; i < dx; i++)
+ depth[n - i - 1] = 0;
+ n -= dx;
+ }
+ if (n <= 0) {
+ return;
+ }
+
+ /* we'll always return 32-bit values to our caller */
+ if (!rb) {
+ _mesa_bzero(depth, n * sizeof(GLuint));
+ }
+ else if (rb->DataType == GL_UNSIGNED_INT) {
+ rb->GetRow(ctx, rb, n, x, y, depth);
+ }
+ else {
+ GLushort temp[MAX_WIDTH];
+ GLuint i;
+ ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
+ rb->GetRow(ctx, rb, n, x, y, temp);
+ for (i = 0; i < n; i++) {
+ depth[i] = temp[i];
+ }
+ }
+}
+
+
+/**
+ * Return a span of depth values from the depth buffer as floats in [0,1].
+ * Input: n - how many pixels
+ * x,y - location of first pixel
+ * Output: depth - the array of depth values
+ */
+void
+_swrast_read_depth_span_float( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint n, GLint x, GLint y, GLfloat depth[] )
+{
+ const GLfloat scale = 1.0F / ctx->DrawBuffer->_DepthMaxF;
+ GLuint temp[MAX_WIDTH];
+ GLint i;
+
+ assert(n <= MAX_WIDTH);
+
+ _swrast_read_depth_span(ctx, rb, n, x, y, temp);
+ for (i = 0; i < n; i++) {
+ depth[i] = temp[i] * scale;
+ }
+}
+
+
+/**
+ * Clear the depth buffer.
+ */
+void
+_swrast_clear_depth_buffer( GLcontext *ctx, struct gl_renderbuffer *rb )
+{
+ GLuint clearValue;
+ GLint x, y, width, height;
+
+ if (!rb || !ctx->Depth.Mask) {
+ /* no depth buffer, or writing to it is disabled */
+ return;
+ }
+
+ /* compute integer clearing value */
+ if (ctx->Depth.Clear == 1.0) {
+ clearValue = ctx->DrawBuffer->_DepthMax;
+ }
+ else {
+ clearValue = (GLuint) (ctx->Depth.Clear * ctx->DrawBuffer->_DepthMaxF);
+ }
+
+ assert(rb->_BaseFormat == GL_DEPTH_COMPONENT);
+
+ /* compute region to clear */
+ x = ctx->DrawBuffer->_Xmin;
+ y = ctx->DrawBuffer->_Ymin;
+ width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+ height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+
+ if (rb->GetPointer(ctx, rb, 0, 0)) {
+ /* Direct buffer access is possible. Either this is just malloc'd
+ * memory, or perhaps the driver mmap'd the zbuffer memory.
+ */
+ if (rb->DataType == GL_UNSIGNED_SHORT) {
+ if (width == rb->Width &&
+ (clearValue & 0xff) == ((clearValue >> 8) & 0xff)) {
+ /* optimized case */
+ GLushort *dst = (GLushort *) rb->GetPointer(ctx, rb, x, y);
+ GLuint len = width * height * sizeof(GLushort);
+ _mesa_memset(dst, (clearValue & 0xff), len);
+ }
+ else {
+ /* general case */
+ GLint i, j;
+ for (i = 0; i < height; i++) {
+ GLushort *dst = (GLushort *) rb->GetPointer(ctx, rb, x, y + i);
+ for (j = 0; j < width; j++) {
+ dst[j] = clearValue;
+ }
+ }
+ }
+ }
+ else {
+ GLint i, j;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ for (i = 0; i < height; i++) {
+ GLuint *dst = (GLuint *) rb->GetPointer(ctx, rb, x, y + i);
+ for (j = 0; j < width; j++) {
+ dst[j] = clearValue;
+ }
+ }
+ }
+ }
+ else {
+ /* Direct access not possible. Use PutRow to write new values. */
+ if (rb->DataType == GL_UNSIGNED_SHORT) {
+ GLushort clearRow[MAX_WIDTH];
+ GLint i, j;
+ for (j = 0; j < width; j++) {
+ clearRow[j] = clearValue;
+ }
+ for (i = 0; i < height; i++) {
+ rb->PutRow(ctx, rb, width, x, y + i, clearRow, NULL);
+ }
+ }
+ else {
+ GLuint clearRow[MAX_WIDTH];
+ GLint i, j;
+ assert(rb->DataType == GL_UNSIGNED_INT);
+ for (j = 0; j < width; j++) {
+ clearRow[j] = clearValue;
+ }
+ for (i = 0; i < height; i++) {
+ rb->PutRow(ctx, rb, width, x, y + i, clearRow, NULL);
+ }
+ }
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_depth.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_depth.h
new file mode 100644
index 000000000..2229e8a22
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_depth.h
@@ -0,0 +1,56 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_DEPTH_H
+#define S_DEPTH_H
+
+
+#include "mtypes.h"
+#include "s_context.h"
+
+
+extern GLuint
+_swrast_depth_test_span( GLcontext *ctx, struct sw_span *span);
+
+
+extern GLboolean
+_swrast_depth_bounds_test( GLcontext *ctx, struct sw_span *span );
+
+
+extern void
+_swrast_read_depth_span( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint n, GLint x, GLint y, GLuint depth[] );
+
+
+extern void
+_swrast_read_depth_span_float( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint n, GLint x, GLint y, GLfloat depth[] );
+
+
+extern void
+_swrast_clear_depth_buffer( GLcontext *ctx, struct gl_renderbuffer *rb );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_drawpix.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_drawpix.c
new file mode 100644
index 000000000..b6aa77757
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_drawpix.c
@@ -0,0 +1,1007 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "bufferobj.h"
+#include "context.h"
+#include "convolve.h"
+#include "image.h"
+#include "macros.h"
+#include "imports.h"
+#include "pixel.h"
+
+#include "s_context.h"
+#include "s_drawpix.h"
+#include "s_pixeltex.h"
+#include "s_span.h"
+#include "s_stencil.h"
+#include "s_zoom.h"
+
+
+/*
+ * Try to do a fast and simple RGB(a) glDrawPixels.
+ * Return: GL_TRUE if success, GL_FALSE if slow path must be used instead
+ */
+static GLboolean
+fast_draw_pixels(GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels)
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+ struct sw_span span;
+
+ INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA);
+
+ if (!ctx->Current.RasterPosValid) {
+ return GL_TRUE; /* no-op */
+ }
+
+ if (swrast->_RasterMask & MULTI_DRAW_BIT)
+ return GL_FALSE;
+
+ if (ctx->Depth.Test)
+ _swrast_span_default_z(ctx, &span);
+ if (swrast->_FogEnabled)
+ _swrast_span_default_fog(ctx, &span);
+ if (ctx->Texture._EnabledCoordUnits)
+ _swrast_span_default_texcoords(ctx, &span);
+
+ if ((SWRAST_CONTEXT(ctx)->_RasterMask & ~CLIP_BIT) == 0
+ && ctx->Texture._EnabledCoordUnits == 0
+ && unpack->Alignment == 1
+ && !unpack->SwapBytes
+ && !unpack->LsbFirst) {
+
+ GLint destX = x;
+ GLint destY = y;
+ GLint drawWidth = width; /* actual width drawn */
+ GLint drawHeight = height; /* actual height drawn */
+ GLint skipPixels = unpack->SkipPixels;
+ GLint skipRows = unpack->SkipRows;
+ GLint rowLength;
+ GLint zoomY0 = 0;
+
+ if (unpack->RowLength > 0)
+ rowLength = unpack->RowLength;
+ else
+ rowLength = width;
+
+ /* If we're not using pixel zoom then do all clipping calculations
+ * now. Otherwise, we'll let the _swrast_write_zoomed_*_span() functions
+ * handle the clipping.
+ */
+ if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
+ /* horizontal clipping */
+ if (destX < ctx->DrawBuffer->_Xmin) {
+ skipPixels += (ctx->DrawBuffer->_Xmin - destX);
+ drawWidth -= (ctx->DrawBuffer->_Xmin - destX);
+ destX = ctx->DrawBuffer->_Xmin;
+ }
+ if (destX + drawWidth > ctx->DrawBuffer->_Xmax)
+ drawWidth -= (destX + drawWidth - ctx->DrawBuffer->_Xmax);
+ if (drawWidth <= 0)
+ return GL_TRUE;
+
+ /* vertical clipping */
+ if (destY < ctx->DrawBuffer->_Ymin) {
+ skipRows += (ctx->DrawBuffer->_Ymin - destY);
+ drawHeight -= (ctx->DrawBuffer->_Ymin - destY);
+ destY = ctx->DrawBuffer->_Ymin;
+ }
+ if (destY + drawHeight > ctx->DrawBuffer->_Ymax)
+ drawHeight -= (destY + drawHeight - ctx->DrawBuffer->_Ymax);
+ if (drawHeight <= 0)
+ return GL_TRUE;
+ }
+ else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
+ /* upside-down image */
+ /* horizontal clipping */
+ if (destX < ctx->DrawBuffer->_Xmin) {
+ skipPixels += (ctx->DrawBuffer->_Xmin - destX);
+ drawWidth -= (ctx->DrawBuffer->_Xmin - destX);
+ destX = ctx->DrawBuffer->_Xmin;
+ }
+ if (destX + drawWidth > ctx->DrawBuffer->_Xmax)
+ drawWidth -= (destX + drawWidth - ctx->DrawBuffer->_Xmax);
+ if (drawWidth <= 0)
+ return GL_TRUE;
+
+ /* vertical clipping */
+ if (destY > ctx->DrawBuffer->_Ymax) {
+ skipRows += (destY - ctx->DrawBuffer->_Ymax);
+ drawHeight -= (destY - ctx->DrawBuffer->_Ymax);
+ destY = ctx->DrawBuffer->_Ymax;
+ }
+ if (destY - drawHeight < ctx->DrawBuffer->_Ymin)
+ drawHeight -= (ctx->DrawBuffer->_Ymin - (destY - drawHeight));
+ if (drawHeight <= 0)
+ return GL_TRUE;
+ }
+ else {
+ if (drawWidth > MAX_WIDTH)
+ return GL_FALSE; /* fall back to general case path */
+
+ /* save Y value of first row */
+ zoomY0 = IROUND(ctx->Current.RasterPos[1]);
+ }
+
+
+ /*
+ * Ready to draw!
+ * The window region at (destX, destY) of size (drawWidth, drawHeight)
+ * will be written to.
+ * We'll take pixel data from buffer pointed to by "pixels" but we'll
+ * skip "skipRows" rows and skip "skipPixels" pixels/row.
+ */
+
+ if (format == GL_RGBA && type == CHAN_TYPE
+ && ctx->_ImageTransferState==0) {
+ if (ctx->Visual.rgbMode) {
+ GLchan *src = (GLchan *) pixels
+ + (skipRows * rowLength + skipPixels) * 4;
+ if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
+ /* no zooming */
+ GLint row;
+ for (row=0; row<drawHeight; row++) {
+ rb->PutRow(ctx, rb, drawWidth, destX, destY, src, NULL);
+ src += rowLength * 4;
+ destY++;
+ }
+ }
+ else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
+ /* upside-down */
+ GLint row;
+ for (row=0; row<drawHeight; row++) {
+ destY--;
+ rb->PutRow(ctx, rb, drawWidth, destX, destY, src, NULL);
+ src += rowLength * 4;
+ }
+ }
+ else {
+ /* with zooming */
+ GLint row;
+ for (row=0; row<drawHeight; row++) {
+ span.x = destX;
+ span.y = destY;
+ span.end = drawWidth;
+ _swrast_write_zoomed_rgba_span(ctx, &span,
+ (CONST GLchan (*)[4]) src, zoomY0, 0);
+ src += rowLength * 4;
+ destY++;
+ }
+ }
+ }
+ return GL_TRUE;
+ }
+ else if (format == GL_RGB && type == CHAN_TYPE
+ && ctx->_ImageTransferState == 0) {
+ if (ctx->Visual.rgbMode) {
+ GLchan *src = (GLchan *) pixels
+ + (skipRows * rowLength + skipPixels) * 3;
+ if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
+ GLint row;
+ for (row=0; row<drawHeight; row++) {
+ rb->PutRowRGB(ctx, rb, drawWidth, destX, destY, src, NULL);
+ src += rowLength * 3;
+ destY++;
+ }
+ }
+ else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
+ /* upside-down */
+ GLint row;
+ for (row=0; row<drawHeight; row++) {
+ destY--;
+ rb->PutRowRGB(ctx, rb, drawWidth, destX, destY, src, NULL);
+ src += rowLength * 3;
+ }
+ }
+ else {
+ /* with zooming */
+ GLint row;
+ for (row=0; row<drawHeight; row++) {
+ span.x = destX;
+ span.y = destY;
+ span.end = drawWidth;
+ _swrast_write_zoomed_rgb_span(ctx, &span,
+ (CONST GLchan (*)[3]) src, zoomY0, 0);
+ src += rowLength * 3;
+ destY++;
+ }
+ }
+ }
+ return GL_TRUE;
+ }
+ else if (format == GL_LUMINANCE && type == CHAN_TYPE
+ && ctx->_ImageTransferState==0) {
+ if (ctx->Visual.rgbMode) {
+ GLchan *src = (GLchan *) pixels
+ + (skipRows * rowLength + skipPixels);
+ if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
+ /* no zooming */
+ GLint row;
+ ASSERT(drawWidth <= MAX_WIDTH);
+ for (row=0; row<drawHeight; row++) {
+ GLint i;
+ for (i=0;i<drawWidth;i++) {
+ span.array->rgb[i][0] = src[i];
+ span.array->rgb[i][1] = src[i];
+ span.array->rgb[i][2] = src[i];
+ }
+ rb->PutRowRGB(ctx, rb, drawWidth, destX, destY,
+ span.array->rgb, NULL);
+ src += rowLength;
+ destY++;
+ }
+ }
+ else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
+ /* upside-down */
+ GLint row;
+ ASSERT(drawWidth <= MAX_WIDTH);
+ for (row=0; row<drawHeight; row++) {
+ GLint i;
+ for (i=0;i<drawWidth;i++) {
+ span.array->rgb[i][0] = src[i];
+ span.array->rgb[i][1] = src[i];
+ span.array->rgb[i][2] = src[i];
+ }
+ destY--;
+ rb->PutRow(ctx, rb, drawWidth, destX, destY,
+ span.array->rgb, NULL);
+ src += rowLength;
+ }
+ }
+ else {
+ /* with zooming */
+ GLint row;
+ ASSERT(drawWidth <= MAX_WIDTH);
+ for (row=0; row<drawHeight; row++) {
+ GLint i;
+ for (i=0;i<drawWidth;i++) {
+ span.array->rgb[i][0] = src[i];
+ span.array->rgb[i][1] = src[i];
+ span.array->rgb[i][2] = src[i];
+ }
+ span.x = destX;
+ span.y = destY;
+ span.end = drawWidth;
+ _swrast_write_zoomed_rgb_span(ctx, &span,
+ (CONST GLchan (*)[3]) span.array->rgb, zoomY0, 0);
+ src += rowLength;
+ destY++;
+ }
+ }
+ }
+ return GL_TRUE;
+ }
+ else if (format == GL_LUMINANCE_ALPHA && type == CHAN_TYPE
+ && ctx->_ImageTransferState == 0) {
+ if (ctx->Visual.rgbMode) {
+ GLchan *src = (GLchan *) pixels
+ + (skipRows * rowLength + skipPixels)*2;
+ if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
+ /* no zooming */
+ GLint row;
+ ASSERT(drawWidth <= MAX_WIDTH);
+ for (row=0; row<drawHeight; row++) {
+ GLint i;
+ GLchan *ptr = src;
+ for (i=0;i<drawWidth;i++) {
+ span.array->rgba[i][0] = *ptr;
+ span.array->rgba[i][1] = *ptr;
+ span.array->rgba[i][2] = *ptr++;
+ span.array->rgba[i][3] = *ptr++;
+ }
+ rb->PutRow(ctx, rb, drawWidth, destX, destY,
+ span.array->rgba, NULL);
+ src += rowLength*2;
+ destY++;
+ }
+ }
+ else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
+ /* upside-down */
+ GLint row;
+ ASSERT(drawWidth <= MAX_WIDTH);
+ for (row=0; row<drawHeight; row++) {
+ GLint i;
+ GLchan *ptr = src;
+ for (i=0;i<drawWidth;i++) {
+ span.array->rgba[i][0] = *ptr;
+ span.array->rgba[i][1] = *ptr;
+ span.array->rgba[i][2] = *ptr++;
+ span.array->rgba[i][3] = *ptr++;
+ }
+ destY--;
+ rb->PutRow(ctx, rb, drawWidth, destX, destY,
+ span.array->rgba, NULL);
+ src += rowLength*2;
+ }
+ }
+ else {
+ /* with zooming */
+ GLint row;
+ ASSERT(drawWidth <= MAX_WIDTH);
+ for (row=0; row<drawHeight; row++) {
+ GLchan *ptr = src;
+ GLint i;
+ for (i=0;i<drawWidth;i++) {
+ span.array->rgba[i][0] = *ptr;
+ span.array->rgba[i][1] = *ptr;
+ span.array->rgba[i][2] = *ptr++;
+ span.array->rgba[i][3] = *ptr++;
+ }
+ span.x = destX;
+ span.y = destY;
+ span.end = drawWidth;
+ _swrast_write_zoomed_rgba_span(ctx, &span,
+ (CONST GLchan (*)[4]) span.array->rgba, zoomY0, 0);
+ src += rowLength*2;
+ destY++;
+ }
+ }
+ }
+ return GL_TRUE;
+ }
+ else if (format==GL_COLOR_INDEX && type==GL_UNSIGNED_BYTE) {
+ GLubyte *src = (GLubyte *) pixels + skipRows * rowLength + skipPixels;
+ if (ctx->Visual.rgbMode) {
+ /* convert CI data to RGBA */
+ if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
+ /* no zooming */
+ GLint row;
+ for (row=0; row<drawHeight; row++) {
+ ASSERT(drawWidth <= MAX_WIDTH);
+ _mesa_map_ci8_to_rgba(ctx, drawWidth, src, span.array->rgba);
+ rb->PutRow(ctx, rb, drawWidth, destX, destY,
+ span.array->rgba, NULL);
+ src += rowLength;
+ destY++;
+ }
+ return GL_TRUE;
+ }
+ else if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==-1.0F) {
+ /* upside-down */
+ GLint row;
+ for (row=0; row<drawHeight; row++) {
+ ASSERT(drawWidth <= MAX_WIDTH);
+ _mesa_map_ci8_to_rgba(ctx, drawWidth, src, span.array->rgba);
+ destY--;
+ rb->PutRow(ctx, rb, drawWidth, destX, destY,
+ span.array->rgba, NULL);
+ src += rowLength;
+ }
+ return GL_TRUE;
+ }
+ else {
+ /* with zooming */
+ GLint row;
+ for (row=0; row<drawHeight; row++) {
+ ASSERT(drawWidth <= MAX_WIDTH);
+ _mesa_map_ci8_to_rgba(ctx, drawWidth, src, span.array->rgba);
+ span.x = destX;
+ span.y = destY;
+ span.end = drawWidth;
+ _swrast_write_zoomed_rgba_span(ctx, &span,
+ (CONST GLchan (*)[4]) span.array->rgba, zoomY0, 0);
+ src += rowLength;
+ destY++;
+ }
+ return GL_TRUE;
+ }
+ }
+ else if (ctx->_ImageTransferState==0) {
+ /* write CI data to CI frame buffer */
+ GLint row;
+ if (ctx->Pixel.ZoomX==1.0F && ctx->Pixel.ZoomY==1.0F) {
+ /* no zooming */
+ for (row=0; row<drawHeight; row++) {
+ GLuint index32[MAX_WIDTH];
+ GLint col;
+ for (col = 0; col < drawWidth; col++)
+ index32[col] = src[col];
+ rb->PutRow(ctx, rb, drawWidth, destX, destY, index32, NULL);
+ src += rowLength;
+ destY++;
+ }
+ return GL_TRUE;
+ }
+ else {
+ /* with zooming */
+ return GL_FALSE;
+ }
+ }
+ }
+ else {
+ /* can't handle this pixel format and/or data type here */
+ return GL_FALSE;
+ }
+ }
+
+ /* can't do a simple draw, have to use slow path */
+ return GL_FALSE;
+}
+
+
+
+/*
+ * Draw color index image.
+ */
+static void
+draw_index_pixels( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
+ GLint row, skipPixels;
+ struct sw_span span;
+
+ INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_INDEX);
+
+ if (ctx->Depth.Test)
+ _swrast_span_default_z(ctx, &span);
+ if (swrast->_FogEnabled)
+ _swrast_span_default_fog(ctx, &span);
+
+ /*
+ * General solution
+ */
+ skipPixels = 0;
+ while (skipPixels < width) {
+ const GLint spanX = x + (zoom ? 0 : skipPixels);
+ GLint spanY = y;
+ const GLint spanEnd = (width - skipPixels > MAX_WIDTH)
+ ? MAX_WIDTH : (width - skipPixels);
+ ASSERT(spanEnd <= MAX_WIDTH);
+ for (row = 0; row < height; row++, spanY++) {
+ const GLvoid *source = _mesa_image_address2d(unpack, pixels,
+ width, height,
+ GL_COLOR_INDEX, type,
+ row, skipPixels);
+ _mesa_unpack_index_span(ctx, spanEnd, GL_UNSIGNED_INT,
+ span.array->index, type, source, unpack,
+ ctx->_ImageTransferState);
+
+ /* These may get changed during writing/clipping */
+ span.x = spanX;
+ span.y = spanY;
+ span.end = spanEnd;
+
+ if (zoom)
+ _swrast_write_zoomed_index_span(ctx, &span, y, skipPixels);
+ else
+ _swrast_write_index_span(ctx, &span);
+ }
+ skipPixels += spanEnd;
+ }
+}
+
+
+
+/*
+ * Draw stencil image.
+ */
+static void
+draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels )
+{
+ const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
+ const GLint desty = y;
+ GLint row, skipPixels;
+
+ if (type != GL_BYTE &&
+ type != GL_UNSIGNED_BYTE &&
+ type != GL_SHORT &&
+ type != GL_UNSIGNED_SHORT &&
+ type != GL_INT &&
+ type != GL_UNSIGNED_INT &&
+ type != GL_FLOAT &&
+ type != GL_BITMAP) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glDrawPixels(stencil type)");
+ return;
+ }
+
+ if (ctx->Visual.stencilBits == 0) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glDrawPixels(no stencil buffer)");
+ return;
+ }
+
+ /* if width > MAX_WIDTH, have to process image in chunks */
+ skipPixels = 0;
+ while (skipPixels < width) {
+ const GLint spanX = x;
+ GLint spanY = y;
+ const GLint spanWidth = (width - skipPixels > MAX_WIDTH)
+ ? MAX_WIDTH : (width - skipPixels);
+
+ for (row = 0; row < height; row++, spanY++) {
+ GLstencil values[MAX_WIDTH];
+ GLenum destType = (sizeof(GLstencil) == sizeof(GLubyte))
+ ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT;
+ const GLvoid *source = _mesa_image_address2d(unpack, pixels,
+ width, height,
+ GL_COLOR_INDEX, type,
+ row, skipPixels);
+ _mesa_unpack_index_span(ctx, spanWidth, destType, values,
+ type, source, unpack,
+ ctx->_ImageTransferState);
+ if (ctx->_ImageTransferState & IMAGE_SHIFT_OFFSET_BIT) {
+ _mesa_shift_and_offset_stencil(ctx, spanWidth, values);
+ }
+ if (ctx->Pixel.MapStencilFlag) {
+ _mesa_map_stencil(ctx, spanWidth, values);
+ }
+
+ if (zoom) {
+ _swrast_write_zoomed_stencil_span(ctx, (GLuint) spanWidth,
+ spanX, spanY, values, desty, 0);
+ }
+ else {
+ _swrast_write_stencil_span(ctx, spanWidth, spanX, spanY, values);
+ }
+ }
+ skipPixels += spanWidth;
+ }
+}
+
+
+/*
+ * Draw depth image.
+ */
+static void
+draw_depth_pixels( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const GLboolean bias_or_scale = ctx->Pixel.DepthBias!=0.0 || ctx->Pixel.DepthScale!=1.0;
+ const GLboolean zoom = ctx->Pixel.ZoomX != 1.0 || ctx->Pixel.ZoomY != 1.0;
+ const GLint desty = y;
+ struct sw_span span;
+
+ INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_Z);
+
+ if (type != GL_BYTE
+ && type != GL_UNSIGNED_BYTE
+ && type != GL_SHORT
+ && type != GL_UNSIGNED_SHORT
+ && type != GL_INT
+ && type != GL_UNSIGNED_INT
+ && type != GL_FLOAT) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glDrawPixels(type)");
+ return;
+ }
+
+ _swrast_span_default_color(ctx, &span);
+
+ if (swrast->_FogEnabled)
+ _swrast_span_default_fog(ctx, &span);
+ if (ctx->Texture._EnabledCoordUnits)
+ _swrast_span_default_texcoords(ctx, &span);
+
+ if (type == GL_UNSIGNED_SHORT
+ && ctx->Visual.depthBits == 16
+ && !bias_or_scale
+ && !zoom
+ && ctx->Visual.rgbMode
+ && width <= MAX_WIDTH) {
+ /* Special case: directly write 16-bit depth values */
+ GLint row, spanY = y;
+ for (row = 0; row < height; row++, spanY++) {
+ const GLushort *zSrc = (const GLushort *)
+ _mesa_image_address2d(unpack, pixels, width, height,
+ GL_DEPTH_COMPONENT, type, row, 0);
+ GLint i;
+ for (i = 0; i < width; i++)
+ span.array->z[i] = zSrc[i];
+ span.x = x;
+ span.y = spanY;
+ span.end = width;
+ _swrast_write_rgba_span(ctx, &span);
+ }
+ }
+ else if (type == GL_UNSIGNED_INT
+ && sizeof(GLdepth) == 4
+ && !bias_or_scale
+ && !zoom
+ && ctx->Visual.rgbMode
+ && width <= MAX_WIDTH) {
+ /* Special case: shift 32-bit values down to ctx->Visual.depthBits */
+ const GLint shift = 32 - ctx->Visual.depthBits;
+ GLint row, spanY = y;
+ for (row = 0; row < height; row++, spanY++) {
+ const GLuint *zSrc = (const GLuint *)
+ _mesa_image_address2d(unpack, pixels, width, height,
+ GL_DEPTH_COMPONENT, type, row, 0);
+ if (shift == 0) {
+ MEMCPY(span.array->z, zSrc, width * sizeof(GLdepth));
+ }
+ else {
+ GLint col;
+ for (col = 0; col < width; col++)
+ span.array->z[col] = zSrc[col] >> shift;
+ }
+ span.x = x;
+ span.y = spanY;
+ span.end = width;
+ _swrast_write_rgba_span(ctx, &span);
+ }
+ }
+ else {
+ /* General case */
+ const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
+ GLint row, skipPixels = 0;
+
+ /* in case width > MAX_WIDTH do the copy in chunks */
+ while (skipPixels < width) {
+ const GLint spanX = x + (zoom ? 0 : skipPixels);
+ GLint spanY = y;
+ const GLint spanEnd = (width - skipPixels > MAX_WIDTH)
+ ? MAX_WIDTH : (width - skipPixels);
+ ASSERT(span.end <= MAX_WIDTH);
+ for (row = 0; row < height; row++, spanY++) {
+ GLfloat floatSpan[MAX_WIDTH];
+ const GLvoid *zSrc = _mesa_image_address2d(unpack,
+ pixels, width, height,
+ GL_DEPTH_COMPONENT, type,
+ row, skipPixels);
+
+ /* Set these for each row since the _swrast_write_* function may
+ * change them while clipping.
+ */
+ span.x = spanX;
+ span.y = spanY;
+ span.end = spanEnd;
+
+ _mesa_unpack_depth_span(ctx, span.end, floatSpan, type,
+ zSrc, unpack);
+ /* clamp depth values to [0,1] and convert from floats to ints */
+ {
+ GLuint i;
+ for (i = 0; i < span.end; i++) {
+ span.array->z[i] = (GLdepth) (floatSpan[i] * depthMax);
+ }
+ }
+ if (zoom) {
+ _swrast_write_zoomed_depth_span(ctx, &span, desty, skipPixels);
+ }
+ else if (ctx->Visual.rgbMode) {
+ _swrast_write_rgba_span(ctx, &span);
+ }
+ else {
+ _swrast_write_index_span(ctx, &span);
+ }
+ }
+ skipPixels += spanEnd;
+ }
+ }
+}
+
+
+
+/*
+ * Draw RGBA image.
+ */
+static void
+draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_renderbuffer *rb = NULL; /* only used for quickDraw path */
+ const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0;
+ const GLint desty = y;
+ GLboolean quickDraw;
+ GLfloat *convImage = NULL;
+ GLuint transferOps = ctx->_ImageTransferState;
+ struct sw_span span;
+
+ INIT_SPAN(span, GL_BITMAP, 0, 0, SPAN_RGBA);
+
+ if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
+ _mesa_error(ctx, GL_INVALID_ENUM, "glDrawPixels(format or type)");
+ return;
+ }
+
+ /* Try an optimized glDrawPixels first */
+ if (fast_draw_pixels(ctx, x, y, width, height, format, type, unpack, pixels))
+ return;
+
+ if (ctx->Depth.Test)
+ _swrast_span_default_z(ctx, &span);
+ if (swrast->_FogEnabled)
+ _swrast_span_default_fog(ctx, &span);
+ if (ctx->Texture._EnabledCoordUnits)
+ _swrast_span_default_texcoords(ctx, &span);
+
+ if (SWRAST_CONTEXT(ctx)->_RasterMask == 0 && !zoom && x >= 0 && y >= 0
+ && x + width <= (GLint) ctx->DrawBuffer->Width
+ && y + height <= (GLint) ctx->DrawBuffer->Height
+ && ctx->DrawBuffer->_NumColorDrawBuffers[0] == 1) {
+ quickDraw = GL_TRUE;
+ rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+ }
+ else {
+ quickDraw = GL_FALSE;
+ rb = NULL;
+ }
+
+ if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
+ /* Convolution has to be handled specially. We'll create an
+ * intermediate image, applying all pixel transfer operations
+ * up to convolution. Then we'll convolve the image. Then
+ * we'll proceed with the rest of the transfer operations and
+ * rasterize the image.
+ */
+ GLint row;
+ GLfloat *dest, *tmpImage;
+
+ tmpImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
+ if (!tmpImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels");
+ return;
+ }
+ convImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
+ if (!convImage) {
+ _mesa_free(tmpImage);
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glDrawPixels");
+ return;
+ }
+
+ /* Unpack the image and apply transfer ops up to convolution */
+ dest = tmpImage;
+ for (row = 0; row < height; row++) {
+ const GLvoid *source = _mesa_image_address2d(unpack,
+ pixels, width, height, format, type, row, 0);
+ _mesa_unpack_color_span_float(ctx, width, GL_RGBA, (GLfloat *) dest,
+ format, type, source, unpack,
+ transferOps & IMAGE_PRE_CONVOLUTION_BITS);
+ dest += width * 4;
+ }
+
+ /* do convolution */
+ if (ctx->Pixel.Convolution2DEnabled) {
+ _mesa_convolve_2d_image(ctx, &width, &height, tmpImage, convImage);
+ }
+ else {
+ ASSERT(ctx->Pixel.Separable2DEnabled);
+ _mesa_convolve_sep_image(ctx, &width, &height, tmpImage, convImage);
+ }
+ _mesa_free(tmpImage);
+
+ /* continue transfer ops and draw the convolved image */
+ unpack = &ctx->DefaultPacking;
+ pixels = convImage;
+ format = GL_RGBA;
+ type = GL_FLOAT;
+ transferOps &= IMAGE_POST_CONVOLUTION_BITS;
+ }
+
+ /*
+ * General solution
+ */
+ {
+ const GLuint interpMask = span.interpMask;
+ const GLuint arrayMask = span.arrayMask;
+ GLint row, skipPixels = 0;
+
+ /* if the span is wider than MAX_WIDTH we have to do it in chunks */
+ while (skipPixels < width) {
+ const GLint spanX = x + (zoom ? 0 : skipPixels);
+ GLint spanY = y;
+ const GLint spanEnd = (width - skipPixels > MAX_WIDTH)
+ ? MAX_WIDTH : (width - skipPixels);
+ ASSERT(span.end <= MAX_WIDTH);
+
+ for (row = 0; row < height; row++, spanY++) {
+ const GLvoid *source = _mesa_image_address2d(unpack,
+ pixels, width, height, format, type, row, skipPixels);
+
+ /* Set these for each row since the _swrast_write_* function may
+ * change them while clipping.
+ */
+ span.x = spanX;
+ span.y = spanY;
+ span.end = spanEnd;
+ span.arrayMask = arrayMask;
+ span.interpMask = interpMask;
+
+ _mesa_unpack_color_span_chan(ctx, span.end, GL_RGBA,
+ (GLchan *) span.array->rgba,
+ format, type, source, unpack,
+ transferOps);
+
+ if ((ctx->Pixel.MinMaxEnabled && ctx->MinMax.Sink) ||
+ (ctx->Pixel.HistogramEnabled && ctx->Histogram.Sink))
+ continue;
+
+ if (ctx->Pixel.PixelTextureEnabled && ctx->Texture._EnabledUnits) {
+ _swrast_pixel_texture(ctx, &span);
+ }
+
+ /* draw the span */
+ if (quickDraw) {
+ rb->PutRow(ctx, rb, span.end, span.x, span.y,
+ span.array->rgba, NULL);
+ }
+ else if (zoom) {
+ _swrast_write_zoomed_rgba_span(ctx, &span,
+ (CONST GLchan (*)[4]) span.array->rgba, desty, skipPixels);
+ }
+ else {
+ _swrast_write_rgba_span(ctx, &span);
+ }
+ }
+
+ skipPixels += spanEnd;
+ }
+ }
+
+ if (convImage) {
+ _mesa_free(convImage);
+ }
+}
+
+
+
+/*
+ * Execute glDrawPixels
+ */
+void
+_swrast_DrawPixels( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ if (swrast->NewState)
+ _swrast_validate_derived( ctx );
+
+ if (unpack->BufferObj->Name) {
+ /* unpack from PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(2, unpack, width, height, 1,
+ format, type, pixels)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glDrawPixels(invalid PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ GL_READ_ONLY_ARB,
+ unpack->BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawPixels(PBO is mapped)");
+ return;
+ }
+ pixels = ADD_POINTERS(buf, pixels);
+ }
+
+ RENDER_START(swrast,ctx);
+
+ switch (format) {
+ case GL_STENCIL_INDEX:
+ draw_stencil_pixels( ctx, x, y, width, height, type, unpack, pixels );
+ break;
+ case GL_DEPTH_COMPONENT:
+ draw_depth_pixels( ctx, x, y, width, height, type, unpack, pixels );
+ break;
+ case GL_COLOR_INDEX:
+ if (ctx->Visual.rgbMode)
+ draw_rgba_pixels(ctx, x,y, width, height, format, type, unpack, pixels);
+ else
+ draw_index_pixels(ctx, x, y, width, height, type, unpack, pixels);
+ break;
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_RGB:
+ case GL_BGR:
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_ABGR_EXT:
+ draw_rgba_pixels(ctx, x, y, width, height, format, type, unpack, pixels);
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glDrawPixels(format)" );
+ /* don't return yet, clean-up */
+ }
+
+ RENDER_FINISH(swrast,ctx);
+
+ if (unpack->BufferObj->Name) {
+ /* done with PBO so unmap it now */
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_UNPACK_BUFFER_EXT,
+ unpack->BufferObj);
+ }
+}
+
+
+
+#if 0 /* experimental */
+/*
+ * Execute glDrawDepthPixelsMESA().
+ */
+void
+_swrast_DrawDepthPixelsMESA( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum colorFormat, GLenum colorType,
+ const GLvoid *colors,
+ GLenum depthType, const GLvoid *depths,
+ const struct gl_pixelstore_attrib *unpack )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ if (swrast->NewState)
+ _swrast_validate_derived( ctx );
+
+ RENDER_START(swrast,ctx);
+
+ switch (colorFormat) {
+ case GL_COLOR_INDEX:
+ if (ctx->Visual.rgbMode)
+ draw_rgba_pixels(ctx, x,y, width, height, colorFormat, colorType, unpack, colors);
+ else
+ draw_index_pixels(ctx, x, y, width, height, colorType, unpack, colors);
+ break;
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_RGB:
+ case GL_BGR:
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_ABGR_EXT:
+ draw_rgba_pixels(ctx, x, y, width, height, colorFormat, colorType, unpack, colors);
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM,
+ "glDrawDepthPixelsMESA(colorFormat)" );
+ }
+
+ RENDER_FINISH(swrast,ctx);
+}
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_drawpix.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_drawpix.h
new file mode 100644
index 000000000..66067115d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_drawpix.h
@@ -0,0 +1,36 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_DRAWPIXELS_H
+#define S_DRAWPIXELS_H
+
+
+#include "mtypes.h"
+#include "swrast.h"
+
+/* XXX kill this header? */
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_feedback.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_feedback.c
new file mode 100644
index 000000000..26cb05cd5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_feedback.c
@@ -0,0 +1,161 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "enums.h"
+#include "feedback.h"
+#include "macros.h"
+
+#include "s_context.h"
+#include "s_feedback.h"
+#include "s_triangle.h"
+
+
+#define FB_3D 0x01
+#define FB_4D 0x02
+#define FB_INDEX 0x04
+#define FB_COLOR 0x08
+#define FB_TEXTURE 0X10
+
+
+
+
+static void feedback_vertex( GLcontext *ctx,
+ const SWvertex *v, const SWvertex *pv )
+{
+ const GLuint texUnit = 0; /* See section 5.3 of 1.2.1 spec */
+ GLfloat win[4];
+ GLfloat color[4];
+ GLfloat tc[4];
+
+ win[0] = v->win[0];
+ win[1] = v->win[1];
+ win[2] = v->win[2] / ctx->DrawBuffer->_DepthMaxF;
+ win[3] = 1.0F / v->win[3];
+
+ color[0] = CHAN_TO_FLOAT(pv->color[0]);
+ color[1] = CHAN_TO_FLOAT(pv->color[1]);
+ color[2] = CHAN_TO_FLOAT(pv->color[2]);
+ color[3] = CHAN_TO_FLOAT(pv->color[3]);
+
+ if (v->texcoord[texUnit][3] != 1.0 &&
+ v->texcoord[texUnit][3] != 0.0) {
+ GLfloat invq = 1.0F / v->texcoord[texUnit][3];
+ tc[0] = v->texcoord[texUnit][0] * invq;
+ tc[1] = v->texcoord[texUnit][1] * invq;
+ tc[2] = v->texcoord[texUnit][2] * invq;
+ tc[3] = v->texcoord[texUnit][3];
+ }
+ else {
+ COPY_4V(tc, v->texcoord[texUnit]);
+ }
+
+ _mesa_feedback_vertex( ctx, win, color, (GLfloat) v->index, tc );
+}
+
+
+/*
+ * Put triangle in feedback buffer.
+ */
+void _swrast_feedback_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+ if (_swrast_culltriangle( ctx, v0, v1, v2 )) {
+ FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_POLYGON_TOKEN );
+ FEEDBACK_TOKEN( ctx, (GLfloat) 3 ); /* three vertices */
+
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ feedback_vertex( ctx, v0, v0 );
+ feedback_vertex( ctx, v1, v1 );
+ feedback_vertex( ctx, v2, v2 );
+ } else {
+ feedback_vertex( ctx, v0, v2 );
+ feedback_vertex( ctx, v1, v2 );
+ feedback_vertex( ctx, v2, v2 );
+ }
+ }
+}
+
+
+void _swrast_feedback_line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 )
+{
+ GLenum token = GL_LINE_TOKEN;
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ if (swrast->StippleCounter==0)
+ token = GL_LINE_RESET_TOKEN;
+
+ FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) token );
+
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ feedback_vertex( ctx, v0, v0 );
+ feedback_vertex( ctx, v1, v1 );
+ } else {
+ feedback_vertex( ctx, v0, v1 );
+ feedback_vertex( ctx, v1, v1 );
+ }
+
+ swrast->StippleCounter++;
+}
+
+
+void _swrast_feedback_point( GLcontext *ctx, const SWvertex *v )
+{
+ FEEDBACK_TOKEN( ctx, (GLfloat) (GLint) GL_POINT_TOKEN );
+ feedback_vertex( ctx, v, v );
+}
+
+
+void _swrast_select_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2)
+{
+ if (_swrast_culltriangle( ctx, v0, v1, v2 )) {
+ const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF;
+
+ _mesa_update_hitflag( ctx, v0->win[2] * zs );
+ _mesa_update_hitflag( ctx, v1->win[2] * zs );
+ _mesa_update_hitflag( ctx, v2->win[2] * zs );
+ }
+}
+
+
+void _swrast_select_line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 )
+{
+ const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF;
+ _mesa_update_hitflag( ctx, v0->win[2] * zs );
+ _mesa_update_hitflag( ctx, v1->win[2] * zs );
+}
+
+
+void _swrast_select_point( GLcontext *ctx, const SWvertex *v )
+{
+ const GLfloat zs = 1.0F / ctx->DrawBuffer->_DepthMaxF;
+ _mesa_update_hitflag( ctx, v->win[2] * zs );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_feedback.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_feedback.h
new file mode 100644
index 000000000..73f45c10b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_feedback.h
@@ -0,0 +1,51 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_FEEDBACK_H
+#define S_FEEDBACK_H
+
+
+#include "mtypes.h"
+#include "swrast.h"
+
+
+extern void _swrast_feedback_point( GLcontext *ctx, const SWvertex *v );
+
+extern void _swrast_feedback_line( GLcontext *ctx,
+ const SWvertex *v1, const SWvertex *v2 );
+
+extern void _swrast_feedback_triangle( GLcontext *ctx, const SWvertex *v0,
+ const SWvertex *v1, const SWvertex *v2 );
+
+extern void _swrast_select_point( GLcontext *ctx, const SWvertex *v );
+
+extern void _swrast_select_line( GLcontext *ctx,
+ const SWvertex *v1, const SWvertex *v2 );
+
+extern void _swrast_select_triangle( GLcontext *ctx, const SWvertex *v0,
+ const SWvertex *v1, const SWvertex *v2 );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_fog.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_fog.c
new file mode 100644
index 000000000..0af9cd8f2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_fog.c
@@ -0,0 +1,327 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "macros.h"
+
+#include "s_context.h"
+#include "s_fog.h"
+#include "s_span.h"
+
+
+/**
+ * Used to convert current raster distance to a fog factor in [0,1].
+ */
+GLfloat
+_swrast_z_to_fogfactor(GLcontext *ctx, GLfloat z)
+{
+ GLfloat d, f;
+
+ switch (ctx->Fog.Mode) {
+ case GL_LINEAR:
+ if (ctx->Fog.Start == ctx->Fog.End)
+ d = 1.0F;
+ else
+ d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
+ f = (ctx->Fog.End - z) * d;
+ return CLAMP(f, 0.0F, 1.0F);
+ case GL_EXP:
+ d = ctx->Fog.Density;
+ f = (GLfloat) exp(-d * z);
+ f = CLAMP(f, 0.0F, 1.0F);
+ return f;
+ case GL_EXP2:
+ d = ctx->Fog.Density;
+ f = (GLfloat) exp(-(d * d * z * z));
+ f = CLAMP(f, 0.0F, 1.0F);
+ return f;
+ default:
+ _mesa_problem(ctx, "Bad fog mode in _swrast_z_to_fogfactor");
+ return 0.0;
+ }
+}
+
+
+/**
+ * Apply fog to a span of RGBA pixels.
+ * The fog value are either in the span->array->fog array or interpolated from
+ * the fog/fogStep values.
+ * They fog values are either fog coordinates (Z) or fog blend factors.
+ * _PreferPixelFog should be in sync with that state!
+ */
+void
+_swrast_fog_rgba_span( const GLcontext *ctx, struct sw_span *span )
+{
+ const SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const GLchan rFog = swrast->_FogColor[RCOMP];
+ const GLchan gFog = swrast->_FogColor[GCOMP];
+ const GLchan bFog = swrast->_FogColor[BCOMP];
+ const GLuint haveW = (span->interpMask & SPAN_W);
+ GLchan (*rgba)[4] = (GLchan (*)[4]) span->array->rgba;
+
+ ASSERT(swrast->_FogEnabled);
+ ASSERT((span->interpMask | span->arrayMask) & SPAN_FOG);
+ ASSERT(span->arrayMask & SPAN_RGBA);
+
+ /* NOTE: if haveW is true, that means the fog start/step values are
+ * perspective-corrected and we have to divide each fog coord by W.
+ */
+
+ /* we need to compute fog blend factors */
+ if (swrast->_PreferPixelFog) {
+ /* The span's fog values are fog coordinates, now compute blend factors
+ * and blend the fragment colors with the fog color.
+ */
+ switch (swrast->_FogMode) {
+ case GL_LINEAR:
+ {
+ const GLfloat fogEnd = ctx->Fog.End;
+ const GLfloat fogScale = (ctx->Fog.Start == ctx->Fog.End)
+ ? 1.0F : 1.0F / (ctx->Fog.End - ctx->Fog.Start);
+ const GLfloat fogStep = span->fogStep;
+ GLfloat fogCoord = span->fog;
+ const GLfloat wStep = haveW ? span->dwdx : 0.0F;
+ GLfloat w = haveW ? span->w : 1.0F;
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ GLfloat f, oneMinusF;
+ f = (fogEnd - FABSF(fogCoord) / w) * fogScale;
+ f = CLAMP(f, 0.0F, 1.0F);
+ oneMinusF = 1.0F - f;
+ rgba[i][RCOMP] = (GLchan) (f * rgba[i][RCOMP] + oneMinusF * rFog);
+ rgba[i][GCOMP] = (GLchan) (f * rgba[i][GCOMP] + oneMinusF * gFog);
+ rgba[i][BCOMP] = (GLchan) (f * rgba[i][BCOMP] + oneMinusF * bFog);
+ fogCoord += fogStep;
+ w += wStep;
+ }
+ }
+ break;
+ case GL_EXP:
+ {
+ const GLfloat density = -ctx->Fog.Density;
+ const GLfloat fogStep = span->fogStep;
+ GLfloat fogCoord = span->fog;
+ const GLfloat wStep = haveW ? span->dwdx : 0.0F;
+ GLfloat w = haveW ? span->w : 1.0F;
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ GLfloat f, oneMinusF;
+ f = (GLfloat) exp(density * FABSF(fogCoord) / w);
+ f = CLAMP(f, 0.0F, 1.0F);
+ oneMinusF = 1.0F - f;
+ rgba[i][RCOMP] = (GLchan) (f * rgba[i][RCOMP] + oneMinusF * rFog);
+ rgba[i][GCOMP] = (GLchan) (f * rgba[i][GCOMP] + oneMinusF * gFog);
+ rgba[i][BCOMP] = (GLchan) (f * rgba[i][BCOMP] + oneMinusF * bFog);
+ fogCoord += fogStep;
+ w += wStep;
+ }
+ }
+ break;
+ case GL_EXP2:
+ {
+ const GLfloat negDensitySquared = -ctx->Fog.Density * ctx->Fog.Density;
+ const GLfloat fogStep = span->fogStep;
+ GLfloat fogCoord = span->fog;
+ const GLfloat wStep = haveW ? span->dwdx : 0.0F;
+ GLfloat w = haveW ? span->w : 1.0F;
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ const GLfloat coord = fogCoord / w;
+ GLfloat tmp = negDensitySquared * coord * coord;
+ GLfloat f, oneMinusF;
+#if defined(__alpha__) || defined(__alpha)
+ /* XXX this underflow check may be needed for other systems*/
+ if (tmp < FLT_MIN_10_EXP)
+ tmp = FLT_MIN_10_EXP;
+#endif
+ f = (GLfloat) exp(tmp);
+ f = CLAMP(f, 0.0F, 1.0F);
+ oneMinusF = 1.0F - f;
+ rgba[i][RCOMP] = (GLchan) (f * rgba[i][RCOMP] + oneMinusF * rFog);
+ rgba[i][GCOMP] = (GLchan) (f * rgba[i][GCOMP] + oneMinusF * gFog);
+ rgba[i][BCOMP] = (GLchan) (f * rgba[i][BCOMP] + oneMinusF * bFog);
+ fogCoord += fogStep;
+ w += wStep;
+ }
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad fog mode in _swrast_fog_rgba_span");
+ return;
+ }
+ }
+ else if (span->arrayMask & SPAN_FOG) {
+ /* The span's fog array values are blend factors.
+ * They were previously computed per-vertex.
+ */
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ const GLfloat f = span->array->fog[i];
+ const GLfloat oneMinusF = 1.0F - f;
+ rgba[i][RCOMP] = (GLchan) (f * rgba[i][RCOMP] + oneMinusF * rFog);
+ rgba[i][GCOMP] = (GLchan) (f * rgba[i][GCOMP] + oneMinusF * gFog);
+ rgba[i][BCOMP] = (GLchan) (f * rgba[i][BCOMP] + oneMinusF * bFog);
+ }
+ }
+ else {
+ /* The span's fog start/step values are blend factors.
+ * They were previously computed per-vertex.
+ */
+ const GLfloat fogStep = span->fogStep;
+ GLfloat fog = span->fog;
+ const GLfloat wStep = haveW ? span->dwdx : 0.0F;
+ GLfloat w = haveW ? span->w : 1.0F;
+ GLuint i;
+ ASSERT(span->interpMask & SPAN_FOG);
+ for (i = 0; i < span->end; i++) {
+ const GLfloat fact = fog / w;
+ const GLfloat oneMinusF = 1.0F - fact;
+ rgba[i][RCOMP] = (GLchan) (fact * rgba[i][RCOMP] + oneMinusF * rFog);
+ rgba[i][GCOMP] = (GLchan) (fact * rgba[i][GCOMP] + oneMinusF * gFog);
+ rgba[i][BCOMP] = (GLchan) (fact * rgba[i][BCOMP] + oneMinusF * bFog);
+ fog += fogStep;
+ w += wStep;
+ }
+ }
+}
+
+
+/**
+ * As above, but color index mode.
+ */
+void
+_swrast_fog_ci_span( const GLcontext *ctx, struct sw_span *span )
+{
+ const SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const GLuint haveW = (span->interpMask & SPAN_W);
+ const GLuint fogIndex = (GLuint) ctx->Fog.Index;
+ GLuint *index = span->array->index;
+
+ ASSERT(swrast->_FogEnabled);
+ ASSERT(span->arrayMask & SPAN_INDEX);
+ ASSERT((span->interpMask | span->arrayMask) & SPAN_FOG);
+
+ /* we need to compute fog blend factors */
+ if (swrast->_PreferPixelFog) {
+ /* The span's fog values are fog coordinates, now compute blend factors
+ * and blend the fragment colors with the fog color.
+ */
+ switch (ctx->Fog.Mode) {
+ case GL_LINEAR:
+ {
+ const GLfloat fogEnd = ctx->Fog.End;
+ const GLfloat fogScale = (ctx->Fog.Start == ctx->Fog.End)
+ ? 1.0F : 1.0F / (ctx->Fog.End - ctx->Fog.Start);
+ const GLfloat fogStep = span->fogStep;
+ GLfloat fogCoord = span->fog;
+ const GLfloat wStep = haveW ? span->dwdx : 0.0F;
+ GLfloat w = haveW ? span->w : 1.0F;
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ GLfloat f = (fogEnd - fogCoord / w) * fogScale;
+ f = CLAMP(f, 0.0F, 1.0F);
+ index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);
+ fogCoord += fogStep;
+ w += wStep;
+ }
+ }
+ break;
+ case GL_EXP:
+ {
+ const GLfloat density = -ctx->Fog.Density;
+ const GLfloat fogStep = span->fogStep;
+ GLfloat fogCoord = span->fog;
+ const GLfloat wStep = haveW ? span->dwdx : 0.0F;
+ GLfloat w = haveW ? span->w : 1.0F;
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ GLfloat f = (GLfloat) exp(density * fogCoord / w);
+ f = CLAMP(f, 0.0F, 1.0F);
+ index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);
+ fogCoord += fogStep;
+ w += wStep;
+ }
+ }
+ break;
+ case GL_EXP2:
+ {
+ const GLfloat negDensitySquared = -ctx->Fog.Density * ctx->Fog.Density;
+ const GLfloat fogStep = span->fogStep;
+ GLfloat fogCoord = span->fog;
+ const GLfloat wStep = haveW ? span->dwdx : 0.0F;
+ GLfloat w = haveW ? span->w : 1.0F;
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ const GLfloat coord = fogCoord / w;
+ GLfloat tmp = negDensitySquared * coord * coord;
+ GLfloat f;
+#if defined(__alpha__) || defined(__alpha)
+ /* XXX this underflow check may be needed for other systems*/
+ if (tmp < FLT_MIN_10_EXP)
+ tmp = FLT_MIN_10_EXP;
+#endif
+ f = (GLfloat) exp(tmp);
+ f = CLAMP(f, 0.0F, 1.0F);
+ index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);
+ fogCoord += fogStep;
+ w += wStep;
+ }
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad fog mode in _swrast_fog_ci_span");
+ return;
+ }
+ }
+ else if (span->arrayMask & SPAN_FOG) {
+ /* The span's fog array values are blend factors.
+ * They were previously computed per-vertex.
+ */
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ const GLfloat f = span->array->fog[i];
+ index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);
+ }
+ }
+ else {
+ /* The span's fog start/step values are blend factors.
+ * They were previously computed per-vertex.
+ */
+ const GLfloat fogStep = span->fogStep;
+ GLfloat fog = span->fog;
+ const GLfloat wStep = haveW ? span->dwdx : 0.0F;
+ GLfloat w = haveW ? span->w : 1.0F;
+ GLuint i;
+ ASSERT(span->interpMask & SPAN_FOG);
+ for (i = 0; i < span->end; i++) {
+ const GLfloat f = fog / w;
+ index[i] = (GLuint) ((GLfloat) index[i] + (1.0F - f) * fogIndex);
+ fog += fogStep;
+ w += wStep;
+ }
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_fog.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_fog.h
new file mode 100644
index 000000000..f5744b1d9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_fog.h
@@ -0,0 +1,45 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_FOG_H
+#define S_FOG_H
+
+
+#include "mtypes.h"
+#include "swrast.h"
+
+
+extern GLfloat
+_swrast_z_to_fogfactor(GLcontext *ctx, GLfloat z);
+
+extern void
+_swrast_fog_rgba_span( const GLcontext *ctx, struct sw_span *span );
+
+extern void
+_swrast_fog_ci_span( const GLcontext *ctx, struct sw_span *span );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_fragprog_to_c.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_fragprog_to_c.c
new file mode 100644
index 000000000..1953e8c73
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_fragprog_to_c.c
@@ -0,0 +1,822 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+/* An amusing little utility to print ARB fragment programs out as a C
+ * function. Resulting code not tested except visually.
+ */
+
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "nvfragprog.h"
+#include "macros.h"
+#include "program.h"
+
+#include "s_nvfragprog.h"
+#include "s_span.h"
+#include "s_texture.h"
+
+
+#ifdef USE_TCC
+
+/* UREG - a way of representing an FP source register including
+ * swizzling and negation in a single GLuint. Major flaw is the
+ * limitiation to source->Index < 32. Secondary flaw is the fact that
+ * it's overkill & we could probably just pass around the original
+ * datatypes instead.
+ */
+
+#define UREG_TYPE_TEMP 0
+#define UREG_TYPE_INTERP 1
+#define UREG_TYPE_LOCAL_CONST 2
+#define UREG_TYPE_ENV_CONST 3
+#define UREG_TYPE_STATE_CONST 4
+#define UREG_TYPE_PARAM 5
+#define UREG_TYPE_OUTPUT 6
+#define UREG_TYPE_MASK 0x7
+
+#define UREG_TYPE_SHIFT 29
+#define UREG_NR_SHIFT 24
+#define UREG_NR_MASK 0x1f /* 31 */
+#define UREG_CHANNEL_X_NEGATE_SHIFT 23
+#define UREG_CHANNEL_X_SHIFT 20
+#define UREG_CHANNEL_Y_NEGATE_SHIFT 19
+#define UREG_CHANNEL_Y_SHIFT 16
+#define UREG_CHANNEL_Z_NEGATE_SHIFT 15
+#define UREG_CHANNEL_Z_SHIFT 12
+#define UREG_CHANNEL_W_NEGATE_SHIFT 11
+#define UREG_CHANNEL_W_SHIFT 8
+#define UREG_CHANNEL_ZERO_NEGATE_MBZ 5
+#define UREG_CHANNEL_ZERO_SHIFT 4
+#define UREG_CHANNEL_ONE_NEGATE_MBZ 1
+#define UREG_CHANNEL_ONE_SHIFT 0
+
+#define UREG_BAD 0xffffffff /* not a valid ureg */
+
+#define _X 0
+#define _Y 1
+#define _Z 2
+#define _W 3
+#define _ZERO 4 /* NOTE! */
+#define _ONE 5 /* NOTE! */
+
+
+/* Construct a ureg:
+ */
+#define UREG( type, nr ) (((type)<< UREG_TYPE_SHIFT) | \
+ ((nr) << UREG_NR_SHIFT) | \
+ (_X << UREG_CHANNEL_X_SHIFT) | \
+ (_Y << UREG_CHANNEL_Y_SHIFT) | \
+ (_Z << UREG_CHANNEL_Z_SHIFT) | \
+ (_W << UREG_CHANNEL_W_SHIFT) | \
+ (_ZERO << UREG_CHANNEL_ZERO_SHIFT) | \
+ (_ONE << UREG_CHANNEL_ONE_SHIFT))
+
+#define GET_CHANNEL_SRC( reg, channel ) ((reg<<(channel*4)) & \
+ (0xf<<UREG_CHANNEL_X_SHIFT))
+#define CHANNEL_SRC( src, channel ) (src>>(channel*4))
+
+#define GET_UREG_TYPE(reg) (((reg)>>UREG_TYPE_SHIFT)&UREG_TYPE_MASK)
+#define GET_UREG_NR(reg) (((reg)>>UREG_NR_SHIFT)&UREG_NR_MASK)
+
+
+
+#define UREG_XYZW_CHANNEL_MASK 0x00ffff00
+
+#define deref(reg,pos) swizzle(reg, pos, pos, pos, pos)
+
+
+static INLINE int is_swizzled( int reg )
+{
+ return ((reg & UREG_XYZW_CHANNEL_MASK) !=
+ (UREG(0,0) & UREG_XYZW_CHANNEL_MASK));
+}
+
+
+/* One neat thing about the UREG representation:
+ */
+static INLINE int swizzle( int reg, int x, int y, int z, int w )
+{
+ return ((reg & ~UREG_XYZW_CHANNEL_MASK) |
+ CHANNEL_SRC( GET_CHANNEL_SRC( reg, x ), 0 ) |
+ CHANNEL_SRC( GET_CHANNEL_SRC( reg, y ), 1 ) |
+ CHANNEL_SRC( GET_CHANNEL_SRC( reg, z ), 2 ) |
+ CHANNEL_SRC( GET_CHANNEL_SRC( reg, w ), 3 ));
+}
+
+/* Another neat thing about the UREG representation:
+ */
+static INLINE int negate( int reg, int x, int y, int z, int w )
+{
+ return reg ^ (((x&1)<<UREG_CHANNEL_X_NEGATE_SHIFT)|
+ ((y&1)<<UREG_CHANNEL_Y_NEGATE_SHIFT)|
+ ((z&1)<<UREG_CHANNEL_Z_NEGATE_SHIFT)|
+ ((w&1)<<UREG_CHANNEL_W_NEGATE_SHIFT));
+}
+
+
+
+static GLuint src_reg_file( GLuint file )
+{
+ switch (file) {
+ case PROGRAM_TEMPORARY: return UREG_TYPE_TEMP;
+ case PROGRAM_INPUT: return UREG_TYPE_INTERP;
+ case PROGRAM_LOCAL_PARAM: return UREG_TYPE_LOCAL_CONST;
+ case PROGRAM_ENV_PARAM: return UREG_TYPE_ENV_CONST;
+
+ case PROGRAM_STATE_VAR: return UREG_TYPE_STATE_CONST;
+ case PROGRAM_NAMED_PARAM: return UREG_TYPE_PARAM;
+ default: return UREG_BAD;
+ }
+}
+
+static void emit( struct fragment_program *p,
+ const char *fmt,
+ ... )
+{
+ va_list ap;
+ va_start( ap, fmt );
+
+ if (p->c_strlen < sizeof(p->c_str))
+ p->c_strlen += vsnprintf( p->c_str + p->c_strlen,
+ sizeof(p->c_str) - p->c_strlen,
+ fmt, ap );
+
+ va_end( ap );
+}
+
+static INLINE void emit_char( struct fragment_program *p, char c )
+{
+ if (p->c_strlen < sizeof(p->c_str)) {
+ p->c_str[p->c_strlen] = c;
+ p->c_strlen++;
+ }
+}
+
+
+/**
+ * Retrieve a ureg for the given source register. Will emit
+ * constants, apply swizzling and negation as needed.
+ */
+static GLuint src_vector( const struct fp_src_register *source )
+{
+ GLuint src;
+
+ assert(source->Index < 32); /* limitiation of UREG representation */
+
+ src = UREG( src_reg_file( source->File ), source->Index );
+
+ src = swizzle(src,
+ _X + source->Swizzle[0],
+ _X + source->Swizzle[1],
+ _X + source->Swizzle[2],
+ _X + source->Swizzle[3]);
+
+ if (source->NegateBase)
+ src = negate( src, 1,1,1,1 );
+
+ return src;
+}
+
+
+static void print_header( struct fragment_program *p )
+{
+ emit(p, "\n\n\n");
+
+ /* Mesa's program_parameter struct:
+ */
+ emit(p,
+ "struct program_parameter\n"
+ "{\n"
+ " const char *Name;\n"
+ " int Type;\n"
+ " int StateIndexes[6];\n"
+ " float Values[4];\n"
+ "};\n");
+
+
+ /* Texture samplers, not written yet:
+ */
+ emit(p, "extern void TEX( void *ctx, const float *txc, int unit, float *rslt );\n"
+ "extern void TXB( void *ctx, const float *txc, int unit, float *rslt );\n"
+ "extern void TXP( void *ctx, const float *txc, int unit, float *rslt );\n");
+
+ /* Resort to the standard math library (float versions):
+ */
+ emit(p, "extern float fabsf( float );\n"
+ "extern float cosf( float );\n"
+ "extern float sinf( float );\n"
+ "extern float expf( float );\n"
+ "extern float powf( float, float );\n"
+ "extern float floorf( float );\n");
+
+ /* These ones we have fast code in Mesa for:
+ */
+ emit(p, "extern float LOG2( float );\n"
+ "extern float _mesa_inv_sqrtf( float );\n");
+
+ /* The usual macros, not really needed, but handy:
+ */
+ emit(p, "#define MIN2(x,y) ((x)<(y)?(x):(y))\n"
+ "#define MAX2(x,y) ((x)<(y)?(x):(y))\n"
+ "#define SATURATE(x) ((x)>1.0?1.0:((x)<0.0?0.0:(x)))\n");
+
+ /* Our function!
+ */
+ emit(p, "int run_program( void *ctx, \n"
+ " const float (*local_param)[4], \n"
+ " const float (*env_param)[4], \n"
+ " const struct program_parameter *state_param, \n"
+ " const float (*interp)[4], \n"
+ " float (*outputs)[4])\n"
+ "{\n"
+ " float temp[32][4];\n"
+ );
+}
+
+static void print_footer( struct fragment_program *p )
+{
+ emit(p, " return 1;");
+ emit(p, "}\n");
+}
+
+static void print_dest_reg( struct fragment_program *p,
+ const struct fp_instruction *inst )
+{
+ switch (inst->DstReg.File) {
+ case PROGRAM_OUTPUT:
+ emit(p, "outputs[%d]", inst->DstReg.Index);
+ break;
+ case PROGRAM_TEMPORARY:
+ emit(p, "temp[%d]", inst->DstReg.Index);
+ break;
+ default:
+ break;
+ }
+}
+
+static void print_dest( struct fragment_program *p,
+ const struct fp_instruction *inst,
+ GLuint idx )
+{
+ print_dest_reg(p, inst);
+ emit(p, "[%d]", idx);
+}
+
+
+#define UREG_SRC0(reg) (((reg)>>UREG_CHANNEL_X_SHIFT) & 0x7)
+
+static void print_reg( struct fragment_program *p,
+ GLuint arg )
+{
+ switch (GET_UREG_TYPE(arg)) {
+ case UREG_TYPE_TEMP: emit(p, "temp"); break;
+ case UREG_TYPE_INTERP: emit(p, "interp"); break;
+ case UREG_TYPE_LOCAL_CONST: emit(p, "local_const"); break;
+ case UREG_TYPE_ENV_CONST: emit(p, "env_const"); break;
+ case UREG_TYPE_STATE_CONST: emit(p, "state_param"); break;
+ case UREG_TYPE_PARAM: emit(p, "local_param"); break;
+ };
+
+ emit(p, "[%d]", GET_UREG_NR(arg));
+
+ if (GET_UREG_TYPE(arg) == UREG_TYPE_STATE_CONST) {
+ emit(p, ".Values");
+ }
+}
+
+
+static void print_arg( struct fragment_program *p,
+ GLuint arg )
+{
+ GLuint src = UREG_SRC0(arg);
+
+ if (src == _ZERO) {
+ emit(p, "0");
+ return;
+ }
+
+ if (arg & (1<<UREG_CHANNEL_X_NEGATE_SHIFT))
+ emit(p, "-");
+
+ if (src == _ONE) {
+ emit(p, "1");
+ return;
+ }
+
+ if (GET_UREG_TYPE(arg) == UREG_TYPE_STATE_CONST &&
+ p->Parameters->Parameters[GET_UREG_NR(arg)].Type == CONSTANT) {
+ emit(p, "%g", p->Parameters->Parameters[GET_UREG_NR(arg)].Values[src]);
+ return;
+ }
+
+ print_reg( p, arg );
+
+ switch (src){
+ case _X: emit(p, "[0]"); break;
+ case _Y: emit(p, "[1]"); break;
+ case _Z: emit(p, "[2]"); break;
+ case _W: emit(p, "[3]"); break;
+ }
+}
+
+
+/* This is where the handling of expressions breaks down into string
+ * processing:
+ */
+static void print_expression( struct fragment_program *p,
+ GLuint i,
+ const char *fmt,
+ va_list ap )
+{
+ while (*fmt) {
+ if (*fmt == '%' && *(fmt+1) == 's') {
+ int reg = va_arg(ap, int);
+
+ /* Use of deref() is a bit of a hack:
+ */
+ print_arg( p, deref(reg, i) );
+ fmt += 2;
+ }
+ else {
+ emit_char(p, *fmt);
+ fmt++;
+ }
+ }
+
+ emit(p, ";\n");
+}
+
+static void do_tex_kill( struct fragment_program *p,
+ const struct fp_instruction *inst,
+ GLuint arg )
+{
+ GLuint i;
+
+ emit(p, "if (");
+
+ for (i = 0; i < 4; i++) {
+ print_arg( p, deref(arg, i) );
+ emit(p, " < 0 ");
+ if (i + 1 < 4)
+ emit(p, "|| ");
+ }
+
+ emit(p, ")\n");
+ emit(p, " return 0;\n");
+
+}
+
+static void do_tex_simple( struct fragment_program *p,
+ const struct fp_instruction *inst,
+ const char *fn, GLuint texunit, GLuint arg )
+{
+ emit(p, " %s( ctx, ", fn);
+ print_reg( p, arg );
+ emit(p, ", %d, ", texunit );
+ print_dest_reg(p, inst);
+ emit(p, ");\n");
+}
+
+
+static void do_tex( struct fragment_program *p,
+ const struct fp_instruction *inst,
+ const char *fn, GLuint texunit, GLuint arg )
+{
+ GLuint i;
+ GLboolean need_tex = GL_FALSE, need_result = GL_FALSE;
+
+ for (i = 0; i < 4; i++)
+ if (!inst->DstReg.WriteMask[i])
+ need_result = GL_TRUE;
+
+ if (is_swizzled(arg))
+ need_tex = GL_TRUE;
+
+ if (!need_tex && !need_result) {
+ do_tex_simple( p, inst, fn, texunit, arg );
+ return;
+ }
+
+ emit(p, " {\n");
+ emit(p, " float texcoord[4];\n");
+ emit(p, " float result[4];\n");
+
+ for (i = 0; i < 4; i++) {
+ emit(p, " texcoord[%d] = ", i);
+ print_arg( p, deref(arg, i) );
+ emit(p, ";\n");
+ }
+
+ emit(p, " %s( ctx, texcoord, %d, result);\n", fn, texunit );
+
+ for (i = 0; i < 4; i++) {
+ if (inst->DstReg.WriteMask[i]) {
+ emit(p, " ");
+ print_dest(p, inst, i);
+ emit(p, " = result[%d];\n", i);
+ }
+ }
+
+ emit(p, " }\n");
+}
+
+
+static void saturate( struct fragment_program *p,
+ const struct fp_instruction *inst,
+ GLuint i )
+{
+ emit(p, " ");
+ print_dest(p, inst, i);
+ emit(p, " = SATURATE( ");
+ print_dest(p, inst, i);
+ emit(p, ");\n");
+}
+
+static void assign_single( GLuint i,
+ struct fragment_program *p,
+ const struct fp_instruction *inst,
+ const char *fmt,
+ ... )
+{
+ va_list ap;
+ va_start( ap, fmt );
+
+ if (inst->DstReg.WriteMask[i]) {
+ emit(p, " ");
+ print_dest(p, inst, i);
+ emit(p, " = ");
+ print_expression( p, i, fmt, ap);
+ if (inst->Saturate)
+ saturate(p, inst, i);
+ }
+
+ va_end( ap );
+}
+
+static void assign4( struct fragment_program *p,
+ const struct fp_instruction *inst,
+ const char *fmt,
+ ... )
+{
+ GLuint i;
+ va_list ap;
+ va_start( ap, fmt );
+
+ for (i = 0; i < 4; i++)
+ if (inst->DstReg.WriteMask[i]) {
+ emit(p, " ");
+ print_dest(p, inst, i);
+ emit(p, " = ");
+ print_expression( p, i, fmt, ap);
+ if (inst->Saturate)
+ saturate(p, inst, i);
+ }
+
+ va_end( ap );
+}
+
+static void assign4_replicate( struct fragment_program *p,
+ const struct fp_instruction *inst,
+ const char *fmt,
+ ... )
+{
+ GLuint i, first = 0;
+ GLboolean ok = 0;
+ va_list ap;
+
+ for (i = 0; i < 4; i++)
+ if (inst->DstReg.WriteMask[i]) {
+ ok = 1;
+ first = i;
+ break;
+ }
+
+ if (!ok) return;
+
+ va_start( ap, fmt );
+
+ emit(p, " ");
+
+ print_dest(p, inst, first);
+ emit(p, " = ");
+ print_expression( p, 0, fmt, ap);
+ if (inst->Saturate)
+ saturate(p, inst, first);
+ va_end( ap );
+
+ for (i = first+1; i < 4; i++)
+ if (inst->DstReg.WriteMask[i]) {
+ emit(p, " ");
+ print_dest(p, inst, i);
+ emit(p, " = ");
+ print_dest(p, inst, first);
+ emit(p, ";\n");
+ }
+}
+
+
+
+
+static GLuint nr_args( GLuint opcode )
+{
+ switch (opcode) {
+ case FP_OPCODE_ABS: return 1;
+ case FP_OPCODE_ADD: return 2;
+ case FP_OPCODE_CMP: return 3;
+ case FP_OPCODE_COS: return 1;
+ case FP_OPCODE_DP3: return 2;
+ case FP_OPCODE_DP4: return 2;
+ case FP_OPCODE_DPH: return 2;
+ case FP_OPCODE_DST: return 2;
+ case FP_OPCODE_EX2: return 1;
+ case FP_OPCODE_FLR: return 1;
+ case FP_OPCODE_FRC: return 1;
+ case FP_OPCODE_KIL: return 1;
+ case FP_OPCODE_LG2: return 1;
+ case FP_OPCODE_LIT: return 1;
+ case FP_OPCODE_LRP: return 3;
+ case FP_OPCODE_MAD: return 3;
+ case FP_OPCODE_MAX: return 2;
+ case FP_OPCODE_MIN: return 2;
+ case FP_OPCODE_MOV: return 1;
+ case FP_OPCODE_MUL: return 2;
+ case FP_OPCODE_POW: return 2;
+ case FP_OPCODE_RCP: return 1;
+ case FP_OPCODE_RSQ: return 1;
+ case FP_OPCODE_SCS: return 1;
+ case FP_OPCODE_SGE: return 2;
+ case FP_OPCODE_SIN: return 1;
+ case FP_OPCODE_SLT: return 2;
+ case FP_OPCODE_SUB: return 2;
+ case FP_OPCODE_SWZ: return 1;
+ case FP_OPCODE_TEX: return 1;
+ case FP_OPCODE_TXB: return 1;
+ case FP_OPCODE_TXP: return 1;
+ case FP_OPCODE_XPD: return 2;
+ default: return 0;
+ }
+}
+
+
+
+static void translate_program( struct fragment_program *p )
+{
+ const struct fp_instruction *inst = p->Instructions;
+
+ for (; inst->Opcode != FP_OPCODE_END; inst++) {
+
+ GLuint src[3], i;
+ GLuint nr = nr_args( inst->Opcode );
+
+ for (i = 0; i < nr; i++)
+ src[i] = src_vector( &inst->SrcReg[i] );
+
+ /* Print the original program instruction string */
+ if (p->Base.String)
+ {
+ const char *s = (const char *) p->Base.String + inst->StringPos;
+ emit(p, " /* ");
+ while (*s != ';') {
+ emit_char(p, *s);
+ s++;
+ }
+ emit(p, "; */\n");
+ }
+
+ switch (inst->Opcode) {
+ case FP_OPCODE_ABS:
+ assign4(p, inst, "fabsf(%s)", src[0]);
+ break;
+
+ case FP_OPCODE_ADD:
+ assign4(p, inst, "%s + %s", src[0], src[1]);
+ break;
+
+ case FP_OPCODE_CMP:
+ assign4(p, inst, "%s < 0.0F ? %s : %s", src[0], src[1], src[2]);
+ break;
+
+ case FP_OPCODE_COS:
+ assign4_replicate(p, inst, "COS(%s)", src[0]);
+ break;
+
+ case FP_OPCODE_DP3:
+ assign4_replicate(p, inst,
+ "%s*%s + %s*%s + %s*%s",
+ deref(src[0],_X),
+ deref(src[1],_X),
+ deref(src[0],_Y),
+ deref(src[1],_Y),
+ deref(src[0],_Z),
+ deref(src[1],_Z));
+ break;
+
+ case FP_OPCODE_DP4:
+ assign4_replicate(p, inst,
+ "%s*%s + %s*%s + %s*%s + %s*%s",
+ deref(src[0],_X),
+ deref(src[1],_X),
+ deref(src[0],_Y),
+ deref(src[1],_Y),
+ deref(src[0],_Z),
+ deref(src[1],_Z));
+ break;
+
+ case FP_OPCODE_DPH:
+ assign4_replicate(p, inst,
+ "%s*%s + %s*%s + %s*%s + %s",
+ deref(src[0],_X),
+ deref(src[1],_X),
+ deref(src[0],_Y),
+ deref(src[1],_Y),
+ deref(src[1],_Z));
+ break;
+
+ case FP_OPCODE_DST:
+ /* result[0] = 1 * 1;
+ * result[1] = a[1] * b[1];
+ * result[2] = a[2] * 1;
+ * result[3] = 1 * b[3];
+ */
+ assign_single(0, p, inst, "1.0");
+
+ assign_single(1, p, inst, "%s * %s",
+ deref(src[0], _Y), deref(src[1], _Y));
+
+ assign_single(2, p, inst, "%s", deref(src[0], _Z));
+ assign_single(3, p, inst, "%s", deref(src[1], _W));
+ break;
+
+ case FP_OPCODE_EX2:
+ assign4_replicate(p, inst, "powf(2.0, %s)", src[0]);
+ break;
+
+ case FP_OPCODE_FLR:
+ assign4_replicate(p, inst, "floorf(%s)", src[0]);
+ break;
+
+ case FP_OPCODE_FRC:
+ assign4_replicate(p, inst, "%s - floorf(%s)", src[0], src[0]);
+ break;
+
+ case FP_OPCODE_KIL:
+ do_tex_kill(p, inst, src[0]);
+ break;
+
+ case FP_OPCODE_LG2:
+ assign4_replicate(p, inst, "LOG2(%s)", src[0]);
+ break;
+
+ case FP_OPCODE_LIT:
+ assign_single(0, p, inst, "1.0");
+ assign_single(1, p, inst, "MIN2(%s, 0)", deref(src[0], _X));
+ assign_single(2, p, inst, "(%s > 0.0) ? expf(%s * MIN2(%s, 0)) : 0.0",
+ deref(src[0], _X),
+ deref(src[0], _Z),
+ deref(src[0], _Y));
+ assign_single(3, p, inst, "1.0");
+ break;
+
+ case FP_OPCODE_LRP:
+ assign4(p, inst,
+ "%s * %s + (1.0 - %s) * %s",
+ src[0], src[1], src[0], src[2]);
+ break;
+
+ case FP_OPCODE_MAD:
+ assign4(p, inst, "%s * %s + %s", src[0], src[1], src[2]);
+ break;
+
+ case FP_OPCODE_MAX:
+ assign4(p, inst, "MAX2(%s, %s)", src[0], src[1]);
+ break;
+
+ case FP_OPCODE_MIN:
+ assign4(p, inst, "MIN2(%s, %s)", src[0], src[1]);
+ break;
+
+ case FP_OPCODE_MOV:
+ assign4(p, inst, "%s", src[0]);
+ break;
+
+ case FP_OPCODE_MUL:
+ assign4(p, inst, "%s * %s", src[0], src[1]);
+ break;
+
+ case FP_OPCODE_POW:
+ assign4_replicate(p, inst, "powf(%s, %s)", src[0], src[1]);
+ break;
+
+ case FP_OPCODE_RCP:
+ assign4_replicate(p, inst, "1.0/%s", src[0]);
+ break;
+
+ case FP_OPCODE_RSQ:
+ assign4_replicate(p, inst, "_mesa_inv_sqrtf(%s)", src[0]);
+ break;
+
+ case FP_OPCODE_SCS:
+ if (inst->DstReg.WriteMask[0]) {
+ assign_single(0, p, inst, "cosf(%s)", deref(src[0], _X));
+ }
+
+ if (inst->DstReg.WriteMask[1]) {
+ assign_single(1, p, inst, "sinf(%s)", deref(src[0], _X));
+ }
+ break;
+
+ case FP_OPCODE_SGE:
+ assign4(p, inst, "%s >= %s ? 1.0 : 0.0", src[0], src[1]);
+ break;
+
+ case FP_OPCODE_SIN:
+ assign4_replicate(p, inst, "sinf(%s)", src[0]);
+ break;
+
+ case FP_OPCODE_SLT:
+ assign4(p, inst, "%s < %s ? 1.0 : 0.0", src[0], src[1]);
+ break;
+
+ case FP_OPCODE_SUB:
+ assign4(p, inst, "%s - %s", src[0], src[1]);
+ break;
+
+ case FP_OPCODE_SWZ: /* same implementation as MOV: */
+ assign4(p, inst, "%s", src[0]);
+ break;
+
+ case FP_OPCODE_TEX:
+ do_tex(p, inst, "TEX", inst->TexSrcUnit, src[0]);
+ break;
+
+ case FP_OPCODE_TXB:
+ do_tex(p, inst, "TXB", inst->TexSrcUnit, src[0]);
+ break;
+
+ case FP_OPCODE_TXP:
+ do_tex(p, inst, "TXP", inst->TexSrcUnit, src[0]);
+ break;
+
+ case FP_OPCODE_XPD:
+ /* Cross product:
+ * result.x = src[0].y * src[1].z - src[0].z * src[1].y;
+ * result.y = src[0].z * src[1].x - src[0].x * src[1].z;
+ * result.z = src[0].x * src[1].y - src[0].y * src[1].x;
+ * result.w = undef;
+ */
+ assign4(p, inst,
+ "%s * %s - %s * %s",
+ swizzle(src[0], _Y, _Z, _X, _ONE),
+ swizzle(src[1], _Z, _X, _Y, _ONE),
+ swizzle(src[0], _Z, _X, _Y, _ONE),
+ swizzle(src[1], _Y, _Z, _X, _ONE));
+ break;
+
+ default:
+ emit(p, "BOGUS OPCODE\n");
+ return;
+ }
+ }
+}
+
+
+
+
+
+void _swrast_translate_program( GLcontext *ctx )
+{
+ struct fragment_program *p = ctx->FragmentProgram._Current;
+
+ if (p) {
+ p->c_strlen = 0;
+
+ print_header( p );
+ translate_program( p );
+ print_footer( p );
+ }
+}
+
+#endif /*USE_TCC*/
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_imaging.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_imaging.c
new file mode 100644
index 000000000..5c79a7ba9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_imaging.c
@@ -0,0 +1,213 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+/* KW: Moved these here to remove knowledge of swrast from core mesa.
+ * Should probably pull the entire software implementation of these
+ * extensions into either swrast or a sister module.
+ */
+
+#include "s_context.h"
+#include "s_span.h"
+#include "colortab.h"
+#include "convolve.h"
+
+
+void
+_swrast_CopyColorTable( GLcontext *ctx,
+ GLenum target, GLenum internalformat,
+ GLint x, GLint y, GLsizei width)
+{
+ GLchan data[MAX_WIDTH][4];
+ struct gl_buffer_object *bufferSave;
+
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no readbuffer - OK */
+ return;
+ }
+
+ /* Select buffer to read from */
+ _swrast_use_read_buffer(ctx);
+
+ if (width > MAX_WIDTH)
+ width = MAX_WIDTH;
+
+ /* read the data from framebuffer */
+ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, x, y, data );
+
+ /* Restore reading from draw buffer (the default) */
+ _swrast_use_draw_buffer(ctx);
+
+ /* save PBO binding */
+ bufferSave = ctx->Unpack.BufferObj;
+ ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+
+ _mesa_ColorTable(target, internalformat, width, GL_RGBA, CHAN_TYPE, data);
+
+ /* restore PBO binding */
+ ctx->Unpack.BufferObj = bufferSave;
+}
+
+
+void
+_swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,
+ GLint x, GLint y, GLsizei width)
+{
+ GLchan data[MAX_WIDTH][4];
+ struct gl_buffer_object *bufferSave;
+
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no readbuffer - OK */
+ return;
+ }
+
+ /* Select buffer to read from */
+ _swrast_use_read_buffer(ctx);
+
+ if (width > MAX_WIDTH)
+ width = MAX_WIDTH;
+
+ /* read the data from framebuffer */
+ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, x, y, data );
+
+ /* Restore reading from draw buffer (the default) */
+ _swrast_use_draw_buffer(ctx);
+
+ /* save PBO binding */
+ bufferSave = ctx->Unpack.BufferObj;
+ ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+
+ _mesa_ColorSubTable(target, start, width, GL_RGBA, CHAN_TYPE, data);
+
+ /* restore PBO binding */
+ ctx->Unpack.BufferObj = bufferSave;
+}
+
+
+void
+_swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target,
+ GLenum internalFormat,
+ GLint x, GLint y, GLsizei width)
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLchan rgba[MAX_CONVOLUTION_WIDTH][4];
+ struct gl_buffer_object *bufferSave;
+
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no readbuffer - OK */
+ return;
+ }
+
+ /* Select buffer to read from */
+ _swrast_use_read_buffer(ctx);
+
+ RENDER_START( swrast, ctx );
+
+ /* read the data from framebuffer */
+ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, x, y, (GLchan (*)[4]) rgba );
+
+ RENDER_FINISH( swrast, ctx );
+
+ /* Restore reading from draw buffer (the default) */
+ _swrast_use_draw_buffer(ctx);
+
+ /* save PBO binding */
+ bufferSave = ctx->Unpack.BufferObj;
+ ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+
+ /* store as convolution filter */
+ _mesa_ConvolutionFilter1D(target, internalFormat, width,
+ GL_RGBA, CHAN_TYPE, rgba);
+
+ /* restore PBO binding */
+ ctx->Unpack.BufferObj = bufferSave;
+}
+
+
+void
+_swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target,
+ GLenum internalFormat,
+ GLint x, GLint y, GLsizei width, GLsizei height)
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_pixelstore_attrib packSave;
+ GLchan rgba[MAX_CONVOLUTION_HEIGHT][MAX_CONVOLUTION_WIDTH][4];
+ GLint i;
+ struct gl_buffer_object *bufferSave;
+
+ if (!ctx->ReadBuffer->_ColorReadBuffer) {
+ /* no readbuffer - OK */
+ return;
+ }
+
+ /* Select buffer to read from */
+ _swrast_use_read_buffer(ctx);
+
+ RENDER_START(swrast,ctx);
+
+ /* read pixels from framebuffer */
+ for (i = 0; i < height; i++) {
+ _swrast_read_rgba_span( ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, x, y + i, (GLchan (*)[4]) rgba[i] );
+ }
+
+ RENDER_FINISH(swrast,ctx);
+
+ /* Restore reading from draw buffer (the default) */
+ _swrast_use_draw_buffer(ctx);
+
+ /*
+ * HACK: save & restore context state so we can store this as a
+ * convolution filter via the GL api. Doesn't call any callbacks
+ * hanging off ctx->Unpack statechanges.
+ */
+
+ 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;
+ ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+ ctx->NewState |= _NEW_PACKUNPACK;
+
+ /* save PBO binding */
+ bufferSave = ctx->Unpack.BufferObj;
+ ctx->Unpack.BufferObj = ctx->Array.NullBufferObj;
+
+ _mesa_ConvolutionFilter2D(target, internalFormat, width, height,
+ GL_RGBA, CHAN_TYPE, rgba);
+
+ /* restore PBO binding */
+ ctx->Unpack.BufferObj = bufferSave;
+
+ ctx->Unpack = packSave; /* restore pixel packing params */
+ ctx->NewState |= _NEW_PACKUNPACK;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_lines.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_lines.c
new file mode 100644
index 000000000..dccc92cbd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_lines.c
@@ -0,0 +1,338 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "colormac.h"
+#include "macros.h"
+#include "nvfragprog.h"
+#include "s_aaline.h"
+#include "s_context.h"
+#include "s_depth.h"
+#include "s_feedback.h"
+#include "s_lines.h"
+#include "s_span.h"
+
+
+/*
+ * Init the mask[] array to implement a line stipple.
+ */
+static void
+compute_stipple_mask( GLcontext *ctx, GLuint len, GLubyte mask[] )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLuint i;
+
+ for (i = 0; i < len; i++) {
+ GLuint bit = (swrast->StippleCounter / ctx->Line.StippleFactor) & 0xf;
+ if ((1 << bit) & ctx->Line.StipplePattern) {
+ mask[i] = GL_TRUE;
+ }
+ else {
+ mask[i] = GL_FALSE;
+ }
+ swrast->StippleCounter++;
+ }
+}
+
+
+/*
+ * To draw a wide line we can simply redraw the span N times, side by side.
+ */
+static void
+draw_wide_line( GLcontext *ctx, struct sw_span *span, GLboolean xMajor )
+{
+ GLint width, start;
+
+ ASSERT(span->end < MAX_WIDTH);
+
+ width = (GLint) CLAMP( ctx->Line._Width, MIN_LINE_WIDTH, MAX_LINE_WIDTH );
+
+ if (width & 1)
+ start = width / 2;
+ else
+ start = width / 2 - 1;
+
+ if (xMajor) {
+ GLint *y = span->array->y;
+ GLuint i;
+ GLint w;
+ for (w = 0; w < width; w++) {
+ if (w == 0) {
+ for (i = 0; i < span->end; i++)
+ y[i] -= start;
+ }
+ else {
+ for (i = 0; i < span->end; i++)
+ y[i]++;
+ }
+ if (ctx->Visual.rgbMode)
+ _swrast_write_rgba_span(ctx, span);
+ else
+ _swrast_write_index_span(ctx, span);
+ }
+ }
+ else {
+ GLint *x = span->array->x;
+ GLuint i;
+ GLint w;
+ for (w = 0; w < width; w++) {
+ if (w == 0) {
+ for (i = 0; i < span->end; i++)
+ x[i] -= start;
+ }
+ else {
+ for (i = 0; i < span->end; i++)
+ x[i]++;
+ }
+ if (ctx->Visual.rgbMode)
+ _swrast_write_rgba_span(ctx, span);
+ else
+ _swrast_write_index_span(ctx, span);
+ }
+ }
+}
+
+
+
+/**********************************************************************/
+/***** Rasterization *****/
+/**********************************************************************/
+
+/* Simple color index line (no stipple, width=1, no Z, no fog, no tex)*/
+#define NAME simple_ci_line
+#define INTERP_INDEX
+#define RENDER_SPAN(span) _swrast_write_index_span(ctx, &span)
+#include "s_linetemp.h"
+
+/* Simple RGBA index line (no stipple, width=1, no Z, no fog, no tex)*/
+#define NAME simple_rgba_line
+#define INTERP_RGBA
+#define RENDER_SPAN(span) _swrast_write_rgba_span(ctx, &span);
+#include "s_linetemp.h"
+
+
+/* Z, fog, wide, stipple color index line */
+#define NAME general_ci_line
+#define INTERP_INDEX
+#define INTERP_Z
+#define INTERP_FOG
+#define RENDER_SPAN(span) \
+ if (ctx->Line.StippleFlag) { \
+ span.arrayMask |= SPAN_MASK; \
+ compute_stipple_mask(ctx, span.end, span.array->mask); \
+ } \
+ if (ctx->Line._Width > 1.0) { \
+ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
+ } \
+ else { \
+ _swrast_write_index_span(ctx, &span); \
+ }
+#include "s_linetemp.h"
+
+
+/* Z, fog, wide, stipple RGBA line */
+#define NAME general_rgba_line
+#define INTERP_RGBA
+#define INTERP_Z
+#define INTERP_FOG
+#define RENDER_SPAN(span) \
+ if (ctx->Line.StippleFlag) { \
+ span.arrayMask |= SPAN_MASK; \
+ compute_stipple_mask(ctx, span.end, span.array->mask); \
+ } \
+ if (ctx->Line._Width > 1.0) { \
+ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
+ } \
+ else { \
+ _swrast_write_rgba_span(ctx, &span); \
+ }
+#include "s_linetemp.h"
+
+
+/* Single-texture line, w/ fog, Z, specular, etc. */
+#define NAME textured_line
+#define INTERP_RGBA
+#define INTERP_Z
+#define INTERP_FOG
+#define INTERP_TEX
+#define RENDER_SPAN(span) \
+ if (ctx->Line.StippleFlag) { \
+ span.arrayMask |= SPAN_MASK; \
+ compute_stipple_mask(ctx, span.end, span.array->mask); \
+ } \
+ if (ctx->Line._Width > 1.0) { \
+ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
+ } \
+ else { \
+ _swrast_write_rgba_span(ctx, &span); \
+ }
+#include "s_linetemp.h"
+
+
+/* Multi-texture or separate specular line, w/ fog, Z, specular, etc. */
+#define NAME multitextured_line
+#define INTERP_RGBA
+#define INTERP_SPEC
+#define INTERP_Z
+#define INTERP_FOG
+#define INTERP_MULTITEX
+#define RENDER_SPAN(span) \
+ if (ctx->Line.StippleFlag) { \
+ span.arrayMask |= SPAN_MASK; \
+ compute_stipple_mask(ctx, span.end, span.array->mask); \
+ } \
+ if (ctx->Line._Width > 1.0) { \
+ draw_wide_line(ctx, &span, (GLboolean)(dx > dy)); \
+ } \
+ else { \
+ _swrast_write_rgba_span(ctx, &span); \
+ }
+#include "s_linetemp.h"
+
+
+
+void
+_swrast_add_spec_terms_line( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1 )
+{
+ SWvertex *ncv0 = (SWvertex *)v0;
+ SWvertex *ncv1 = (SWvertex *)v1;
+ GLchan c[2][4];
+ COPY_CHAN4( c[0], ncv0->color );
+ COPY_CHAN4( c[1], ncv1->color );
+ ACC_3V( ncv0->color, ncv0->specular );
+ ACC_3V( ncv1->color, ncv1->specular );
+ SWRAST_CONTEXT(ctx)->SpecLine( ctx, ncv0, ncv1 );
+ COPY_CHAN4( ncv0->color, c[0] );
+ COPY_CHAN4( ncv1->color, c[1] );
+}
+
+
+#ifdef DEBUG
+extern void
+_mesa_print_line_function(GLcontext *ctx); /* silence compiler warning */
+void
+_mesa_print_line_function(GLcontext *ctx)
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ _mesa_printf("Line Func == ");
+ if (swrast->Line == simple_ci_line)
+ _mesa_printf("simple_ci_line\n");
+ else if (swrast->Line == simple_rgba_line)
+ _mesa_printf("simple_rgba_line\n");
+ else if (swrast->Line == general_ci_line)
+ _mesa_printf("general_ci_line\n");
+ else if (swrast->Line == general_rgba_line)
+ _mesa_printf("general_rgba_line\n");
+ else if (swrast->Line == textured_line)
+ _mesa_printf("textured_line\n");
+ else if (swrast->Line == multitextured_line)
+ _mesa_printf("multitextured_line\n");
+ else
+ _mesa_printf("Driver func %p\n", (void *(*)()) swrast->Line);
+}
+#endif
+
+
+
+#ifdef DEBUG
+
+/* record the current line function name */
+static const char *lineFuncName = NULL;
+
+#define USE(lineFunc) \
+do { \
+ lineFuncName = #lineFunc; \
+ /*_mesa_printf("%s\n", lineFuncName);*/ \
+ swrast->Line = lineFunc; \
+} while (0)
+
+#else
+
+#define USE(lineFunc) swrast->Line = lineFunc
+
+#endif
+
+
+
+/*
+ * Determine which line drawing function to use given the current
+ * rendering context.
+ *
+ * Please update the summary flag _SWRAST_NEW_LINE if you add or remove
+ * tests to this code.
+ */
+void
+_swrast_choose_line( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const GLboolean rgbmode = ctx->Visual.rgbMode;
+
+ if (ctx->RenderMode == GL_RENDER) {
+ if (ctx->Line.SmoothFlag) {
+ /* antialiased lines */
+ _swrast_choose_aa_line_function(ctx);
+ ASSERT(swrast->Line);
+ }
+ else if (ctx->Texture._EnabledCoordUnits) {
+ /* textured lines */
+ if (ctx->Texture._EnabledCoordUnits > 0x1
+ || NEED_SECONDARY_COLOR(ctx)) {
+ /* multi-texture and/or separate specular color */
+ USE(multitextured_line);
+ }
+ else {
+ USE(textured_line);
+ }
+ }
+ else if (ctx->Depth.Test || swrast->_FogEnabled || ctx->Line._Width != 1.0
+ || ctx->Line.StippleFlag) {
+ /* no texture, but Z, fog, width>1, stipple, etc. */
+ if (rgbmode)
+ USE(general_rgba_line);
+ else
+ USE(general_ci_line);
+ }
+ else {
+ /* simplest lines */
+ if (rgbmode)
+ USE(simple_rgba_line);
+ else
+ USE(simple_ci_line);
+ }
+ }
+ else if (ctx->RenderMode == GL_FEEDBACK) {
+ USE(_swrast_feedback_line);
+ }
+ else {
+ ASSERT(ctx->RenderMode == GL_SELECT);
+ USE(_swrast_select_line);
+ }
+
+ /*_mesa_print_line_function(ctx);*/
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_lines.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_lines.h
new file mode 100644
index 000000000..5372b99b9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_lines.h
@@ -0,0 +1,41 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_LINES_H
+#define S_LINES_H
+
+#include "mtypes.h"
+
+void
+_swrast_choose_line( GLcontext *ctx );
+
+void
+_swrast_add_spec_terms_line( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1 );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_linetemp.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_linetemp.h
new file mode 100644
index 000000000..af7aeabf6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_linetemp.h
@@ -0,0 +1,454 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+/*
+ * Line Rasterizer Template
+ *
+ * This file is #include'd to generate custom line rasterizers.
+ *
+ * The following macros may be defined to indicate what auxillary information
+ * must be interplated along the line:
+ * INTERP_Z - if defined, interpolate Z values
+ * INTERP_FOG - if defined, interpolate FOG values
+ * INTERP_RGBA - if defined, interpolate RGBA values
+ * INTERP_SPEC - if defined, interpolate specular RGB values
+ * INTERP_INDEX - if defined, interpolate color index values
+ * INTERP_TEX - if defined, interpolate unit 0 texcoords
+ * INTERP_MULTITEX - if defined, interpolate multi-texcoords
+ *
+ * When one can directly address pixels in the color buffer the following
+ * macros can be defined and used to directly compute pixel addresses during
+ * rasterization (see pixelPtr):
+ * PIXEL_TYPE - the datatype of a pixel (GLubyte, GLushort, GLuint)
+ * BYTES_PER_ROW - number of bytes per row in the color buffer
+ * PIXEL_ADDRESS(X,Y) - returns the address of pixel at (X,Y) where
+ * Y==0 at bottom of screen and increases upward.
+ *
+ * Similarly, for direct depth buffer access, this type is used for depth
+ * buffer addressing:
+ * DEPTH_TYPE - either GLushort or GLuint
+ *
+ * Optionally, one may provide one-time setup code
+ * SETUP_CODE - code which is to be executed once per line
+ *
+ * To actually "plot" each pixel the PLOT macro must be defined...
+ * PLOT(X,Y) - code to plot a pixel. Example:
+ * if (Z < *zPtr) {
+ * *zPtr = Z;
+ * color = pack_rgb( FixedToInt(r0), FixedToInt(g0),
+ * FixedToInt(b0) );
+ * put_pixel( X, Y, color );
+ * }
+ *
+ * This code was designed for the origin to be in the lower-left corner.
+ *
+ */
+
+
+static void
+NAME( GLcontext *ctx, const SWvertex *vert0, const SWvertex *vert1 )
+{
+ struct sw_span span;
+ GLuint interpFlags = 0;
+ GLint x0 = (GLint) vert0->win[0];
+ GLint x1 = (GLint) vert1->win[0];
+ GLint y0 = (GLint) vert0->win[1];
+ GLint y1 = (GLint) vert1->win[1];
+ GLint dx, dy;
+ GLint numPixels;
+ GLint xstep, ystep;
+#if defined(DEPTH_TYPE)
+ const GLint depthBits = ctx->Visual.depthBits;
+ const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0;
+ struct gl_renderbuffer *zrb = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+#define FixedToDepth(F) ((F) >> fixedToDepthShift)
+ GLint zPtrXstep, zPtrYstep;
+ DEPTH_TYPE *zPtr;
+#elif defined(INTERP_Z)
+ const GLint depthBits = ctx->Visual.depthBits;
+#endif
+#ifdef PIXEL_ADDRESS
+ PIXEL_TYPE *pixelPtr;
+ GLint pixelXstep, pixelYstep;
+#endif
+
+#ifdef SETUP_CODE
+ SETUP_CODE
+#endif
+
+ /* Cull primitives with malformed coordinates.
+ */
+ {
+ GLfloat tmp = vert0->win[0] + vert0->win[1]
+ + vert1->win[0] + vert1->win[1];
+ if (IS_INF_OR_NAN(tmp))
+ return;
+ }
+
+ /*
+ printf("%s():\n", __FUNCTION__);
+ printf(" (%f, %f, %f) -> (%f, %f, %f)\n",
+ vert0->win[0], vert0->win[1], vert0->win[2],
+ vert1->win[0], vert1->win[1], vert1->win[2]);
+ printf(" (%d, %d, %d) -> (%d, %d, %d)\n",
+ vert0->color[0], vert0->color[1], vert0->color[2],
+ vert1->color[0], vert1->color[1], vert1->color[2]);
+ printf(" (%d, %d, %d) -> (%d, %d, %d)\n",
+ vert0->specular[0], vert0->specular[1], vert0->specular[2],
+ vert1->specular[0], vert1->specular[1], vert1->specular[2]);
+ */
+
+/*
+ * Despite being clipped to the view volume, the line's window coordinates
+ * may just lie outside the window bounds. That is, if the legal window
+ * coordinates are [0,W-1][0,H-1], it's possible for x==W and/or y==H.
+ * This quick and dirty code nudges the endpoints inside the window if
+ * necessary.
+ */
+#ifdef CLIP_HACK
+ {
+ GLint w = ctx->DrawBuffer->Width;
+ GLint h = ctx->DrawBuffer->Height;
+ if ((x0==w) | (x1==w)) {
+ if ((x0==w) & (x1==w))
+ return;
+ x0 -= x0==w;
+ x1 -= x1==w;
+ }
+ if ((y0==h) | (y1==h)) {
+ if ((y0==h) & (y1==h))
+ return;
+ y0 -= y0==h;
+ y1 -= y1==h;
+ }
+ }
+#endif
+
+ dx = x1 - x0;
+ dy = y1 - y0;
+ if (dx == 0 && dy == 0)
+ return;
+
+#ifdef DEPTH_TYPE
+ zPtr = (DEPTH_TYPE *) zrb->GetPointer(ctx, zrb, x0, y0);
+#endif
+#ifdef PIXEL_ADDRESS
+ pixelPtr = (PIXEL_TYPE *) PIXEL_ADDRESS(x0,y0);
+#endif
+
+ if (dx<0) {
+ dx = -dx; /* make positive */
+ xstep = -1;
+#ifdef DEPTH_TYPE
+ zPtrXstep = -((GLint)sizeof(DEPTH_TYPE));
+#endif
+#ifdef PIXEL_ADDRESS
+ pixelXstep = -((GLint)sizeof(PIXEL_TYPE));
+#endif
+ }
+ else {
+ xstep = 1;
+#ifdef DEPTH_TYPE
+ zPtrXstep = ((GLint)sizeof(DEPTH_TYPE));
+#endif
+#ifdef PIXEL_ADDRESS
+ pixelXstep = ((GLint)sizeof(PIXEL_TYPE));
+#endif
+ }
+
+ if (dy<0) {
+ dy = -dy; /* make positive */
+ ystep = -1;
+#ifdef DEPTH_TYPE
+ zPtrYstep = -((GLint) (ctx->DrawBuffer->Width * sizeof(DEPTH_TYPE)));
+#endif
+#ifdef PIXEL_ADDRESS
+ pixelYstep = BYTES_PER_ROW;
+#endif
+ }
+ else {
+ ystep = 1;
+#ifdef DEPTH_TYPE
+ zPtrYstep = (GLint) (ctx->DrawBuffer->Width * sizeof(DEPTH_TYPE));
+#endif
+#ifdef PIXEL_ADDRESS
+ pixelYstep = -(BYTES_PER_ROW);
+#endif
+ }
+
+ ASSERT(dx >= 0);
+ ASSERT(dy >= 0);
+
+ numPixels = MAX2(dx, dy);
+
+ /*
+ * Span setup: compute start and step values for all interpolated values.
+ */
+#ifdef INTERP_RGBA
+ interpFlags |= SPAN_RGBA;
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ span.red = ChanToFixed(vert0->color[0]);
+ span.green = ChanToFixed(vert0->color[1]);
+ span.blue = ChanToFixed(vert0->color[2]);
+ span.alpha = ChanToFixed(vert0->color[3]);
+ span.redStep = (ChanToFixed(vert1->color[0]) - span.red ) / numPixels;
+ span.greenStep = (ChanToFixed(vert1->color[1]) - span.green) / numPixels;
+ span.blueStep = (ChanToFixed(vert1->color[2]) - span.blue ) / numPixels;
+ span.alphaStep = (ChanToFixed(vert1->color[3]) - span.alpha) / numPixels;
+ }
+ else {
+ span.red = ChanToFixed(vert1->color[0]);
+ span.green = ChanToFixed(vert1->color[1]);
+ span.blue = ChanToFixed(vert1->color[2]);
+ span.alpha = ChanToFixed(vert1->color[3]);
+ span.redStep = 0;
+ span.greenStep = 0;
+ span.blueStep = 0;
+ span.alphaStep = 0;
+ }
+#endif
+#ifdef INTERP_SPEC
+ interpFlags |= SPAN_SPEC;
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ span.specRed = ChanToFixed(vert0->specular[0]);
+ span.specGreen = ChanToFixed(vert0->specular[1]);
+ span.specBlue = ChanToFixed(vert0->specular[2]);
+ span.specRedStep = (ChanToFixed(vert1->specular[0]) - span.specRed) / numPixels;
+ span.specGreenStep = (ChanToFixed(vert1->specular[1]) - span.specBlue) / numPixels;
+ span.specBlueStep = (ChanToFixed(vert1->specular[2]) - span.specGreen) / numPixels;
+ }
+ else {
+ span.specRed = ChanToFixed(vert1->specular[0]);
+ span.specGreen = ChanToFixed(vert1->specular[1]);
+ span.specBlue = ChanToFixed(vert1->specular[2]);
+ span.specRedStep = 0;
+ span.specGreenStep = 0;
+ span.specBlueStep = 0;
+ }
+#endif
+#ifdef INTERP_INDEX
+ interpFlags |= SPAN_INDEX;
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ span.index = FloatToFixed(vert0->index);
+ span.indexStep = FloatToFixed(vert1->index - vert0->index) / numPixels;
+ }
+ else {
+ span.index = FloatToFixed(vert1->index);
+ span.indexStep = 0;
+ }
+#endif
+#if defined(INTERP_Z) || defined(DEPTH_TYPE)
+ interpFlags |= SPAN_Z;
+ {
+ if (depthBits <= 16) {
+ span.z = FloatToFixed(vert0->win[2]) + FIXED_HALF;
+ span.zStep = FloatToFixed(vert1->win[2] - vert0->win[2]) / numPixels;
+ }
+ else {
+ /* don't use fixed point */
+ span.z = (GLint) vert0->win[2];
+ span.zStep = (GLint) ((vert1->win[2] - vert0->win[2]) / numPixels);
+ }
+ }
+#endif
+#ifdef INTERP_FOG
+ interpFlags |= SPAN_FOG;
+ span.fog = vert0->fog;
+ span.fogStep = (vert1->fog - vert0->fog) / numPixels;
+#endif
+#ifdef INTERP_TEX
+ interpFlags |= SPAN_TEXTURE;
+ {
+ const GLfloat invw0 = vert0->win[3];
+ const GLfloat invw1 = vert1->win[3];
+ const GLfloat invLen = 1.0F / numPixels;
+ GLfloat ds, dt, dr, dq;
+ span.tex[0][0] = invw0 * vert0->texcoord[0][0];
+ span.tex[0][1] = invw0 * vert0->texcoord[0][1];
+ span.tex[0][2] = invw0 * vert0->texcoord[0][2];
+ span.tex[0][3] = invw0 * vert0->texcoord[0][3];
+ ds = (invw1 * vert1->texcoord[0][0]) - span.tex[0][0];
+ dt = (invw1 * vert1->texcoord[0][1]) - span.tex[0][1];
+ dr = (invw1 * vert1->texcoord[0][2]) - span.tex[0][2];
+ dq = (invw1 * vert1->texcoord[0][3]) - span.tex[0][3];
+ span.texStepX[0][0] = ds * invLen;
+ span.texStepX[0][1] = dt * invLen;
+ span.texStepX[0][2] = dr * invLen;
+ span.texStepX[0][3] = dq * invLen;
+ span.texStepY[0][0] = 0.0F;
+ span.texStepY[0][1] = 0.0F;
+ span.texStepY[0][2] = 0.0F;
+ span.texStepY[0][3] = 0.0F;
+ }
+#endif
+#ifdef INTERP_MULTITEX
+ interpFlags |= SPAN_TEXTURE;
+ {
+ const GLfloat invLen = 1.0F / numPixels;
+ GLuint u;
+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
+ if (ctx->Texture.Unit[u]._ReallyEnabled) {
+ const GLfloat invw0 = vert0->win[3];
+ const GLfloat invw1 = vert1->win[3];
+ GLfloat ds, dt, dr, dq;
+ span.tex[u][0] = invw0 * vert0->texcoord[u][0];
+ span.tex[u][1] = invw0 * vert0->texcoord[u][1];
+ span.tex[u][2] = invw0 * vert0->texcoord[u][2];
+ span.tex[u][3] = invw0 * vert0->texcoord[u][3];
+ ds = (invw1 * vert1->texcoord[u][0]) - span.tex[u][0];
+ dt = (invw1 * vert1->texcoord[u][1]) - span.tex[u][1];
+ dr = (invw1 * vert1->texcoord[u][2]) - span.tex[u][2];
+ dq = (invw1 * vert1->texcoord[u][3]) - span.tex[u][3];
+ span.texStepX[u][0] = ds * invLen;
+ span.texStepX[u][1] = dt * invLen;
+ span.texStepX[u][2] = dr * invLen;
+ span.texStepX[u][3] = dq * invLen;
+ span.texStepY[u][0] = 0.0F;
+ span.texStepY[u][1] = 0.0F;
+ span.texStepY[u][2] = 0.0F;
+ span.texStepY[u][3] = 0.0F;
+ }
+ }
+ }
+#endif
+
+ INIT_SPAN(span, GL_LINE, numPixels, interpFlags, SPAN_XY);
+
+ /* Need these for fragment prog texcoord interpolation */
+ span.w = 1.0F;
+ span.dwdx = 0.0F;
+ span.dwdy = 0.0F;
+
+ /*
+ * Draw
+ */
+
+ if (dx > dy) {
+ /*** X-major line ***/
+ GLint i;
+ GLint errorInc = dy+dy;
+ GLint error = errorInc-dx;
+ GLint errorDec = error-dx;
+
+ for (i = 0; i < dx; i++) {
+#ifdef DEPTH_TYPE
+ GLdepth Z = FixedToDepth(span.z);
+#endif
+#ifdef PLOT
+ PLOT( x0, y0 );
+#else
+ span.array->x[i] = x0;
+ span.array->y[i] = y0;
+#endif
+ x0 += xstep;
+#ifdef DEPTH_TYPE
+ zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrXstep);
+ span.z += span.zStep;
+#endif
+#ifdef PIXEL_ADDRESS
+ pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelXstep);
+#endif
+ if (error<0) {
+ error += errorInc;
+ }
+ else {
+ error += errorDec;
+ y0 += ystep;
+#ifdef DEPTH_TYPE
+ zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrYstep);
+#endif
+#ifdef PIXEL_ADDRESS
+ pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelYstep);
+#endif
+ }
+ }
+ }
+ else {
+ /*** Y-major line ***/
+ GLint i;
+ GLint errorInc = dx+dx;
+ GLint error = errorInc-dy;
+ GLint errorDec = error-dy;
+
+ for (i=0;i<dy;i++) {
+#ifdef DEPTH_TYPE
+ GLdepth Z = FixedToDepth(span.z);
+#endif
+#ifdef PLOT
+ PLOT( x0, y0 );
+#else
+ span.array->x[i] = x0;
+ span.array->y[i] = y0;
+#endif
+ y0 += ystep;
+#ifdef DEPTH_TYPE
+ zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrYstep);
+ span.z += span.zStep;
+#endif
+#ifdef PIXEL_ADDRESS
+ pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelYstep);
+#endif
+ if (error<0) {
+ error += errorInc;
+ }
+ else {
+ error += errorDec;
+ x0 += xstep;
+#ifdef DEPTH_TYPE
+ zPtr = (DEPTH_TYPE *) ((GLubyte*) zPtr + zPtrXstep);
+#endif
+#ifdef PIXEL_ADDRESS
+ pixelPtr = (PIXEL_TYPE*) ((GLubyte*) pixelPtr + pixelXstep);
+#endif
+ }
+ }
+ }
+
+#ifdef RENDER_SPAN
+ RENDER_SPAN( span );
+#endif
+
+ (void)span;
+
+}
+
+
+#undef NAME
+#undef INTERP_Z
+#undef INTERP_FOG
+#undef INTERP_RGBA
+#undef INTERP_SPEC
+#undef INTERP_TEX
+#undef INTERP_MULTITEX
+#undef INTERP_INDEX
+#undef PIXEL_ADDRESS
+#undef PIXEL_TYPE
+#undef DEPTH_TYPE
+#undef BYTES_PER_ROW
+#undef SETUP_CODE
+#undef PLOT
+#undef CLIP_HACK
+#undef FixedToDepth
+#undef RENDER_SPAN
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_logic.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_logic.c
new file mode 100644
index 000000000..ff3c3fc2f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_logic.c
@@ -0,0 +1,244 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "imports.h"
+#include "macros.h"
+
+#include "s_context.h"
+#include "s_logic.h"
+#include "s_span.h"
+
+
+#define LOGIC_OP_LOOP(MODE) \
+do { \
+ GLuint i; \
+ switch (MODE) { \
+ case GL_CLEAR: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = 0; \
+ } \
+ } \
+ break; \
+ case GL_SET: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = ~0; \
+ } \
+ } \
+ break; \
+ case GL_COPY: \
+ /* do nothing */ \
+ break; \
+ case GL_COPY_INVERTED: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = ~src[i]; \
+ } \
+ } \
+ break; \
+ case GL_NOOP: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = dest[i]; \
+ } \
+ } \
+ break; \
+ case GL_INVERT: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = ~dest[i]; \
+ } \
+ } \
+ break; \
+ case GL_AND: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] &= dest[i]; \
+ } \
+ } \
+ break; \
+ case GL_NAND: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = ~(src[i] & dest[i]); \
+ } \
+ } \
+ break; \
+ case GL_OR: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] |= dest[i]; \
+ } \
+ } \
+ break; \
+ case GL_NOR: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = ~(src[i] | dest[i]); \
+ } \
+ } \
+ break; \
+ case GL_XOR: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] ^= dest[i]; \
+ } \
+ } \
+ break; \
+ case GL_EQUIV: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = ~(src[i] ^ dest[i]); \
+ } \
+ } \
+ break; \
+ case GL_AND_REVERSE: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = src[i] & ~dest[i]; \
+ } \
+ } \
+ break; \
+ case GL_AND_INVERTED: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = ~src[i] & dest[i]; \
+ } \
+ } \
+ break; \
+ case GL_OR_REVERSE: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = src[i] | ~dest[i]; \
+ } \
+ } \
+ break; \
+ case GL_OR_INVERTED: \
+ for (i = 0; i < n; i++) { \
+ if (mask[i]) { \
+ src[i] = ~src[i] | dest[i]; \
+ } \
+ } \
+ break; \
+ default: \
+ _mesa_problem(ctx, "bad logicop mode");\
+ } \
+} while (0)
+
+
+
+static void
+logicop_ubyte(GLcontext *ctx, GLuint n, GLubyte src[], const GLubyte dest[],
+ const GLubyte mask[])
+{
+ LOGIC_OP_LOOP(ctx->Color.LogicOp);
+}
+
+
+static void
+logicop_ushort(GLcontext *ctx, GLuint n, GLushort src[], const GLushort dest[],
+ const GLubyte mask[])
+{
+ LOGIC_OP_LOOP(ctx->Color.LogicOp);
+}
+
+
+static void
+logicop_uint(GLcontext *ctx, GLuint n, GLuint src[], const GLuint dest[],
+ const GLubyte mask[])
+{
+ LOGIC_OP_LOOP(ctx->Color.LogicOp);
+}
+
+
+
+/*
+ * Apply the current logic operator to a span of CI pixels. This is only
+ * used if the device driver can't do logic ops.
+ */
+void
+_swrast_logicop_ci_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLuint index[])
+{
+ GLuint dest[MAX_WIDTH];
+
+ ASSERT(span->end < MAX_WIDTH);
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+
+ /* Read dest values from frame buffer */
+ if (span->arrayMask & SPAN_XY) {
+ _swrast_get_values(ctx, rb, span->end, span->array->x, span->array->y,
+ dest, sizeof(GLuint));
+ }
+ else {
+ rb->GetRow(ctx, rb, span->end, span->x, span->y, dest);
+ }
+
+ logicop_uint(ctx, span->end, index, dest, span->array->mask);
+}
+
+
+/**
+ * Apply the current logic operator to a span of RGBA pixels.
+ * We can handle horizontal runs of pixels (spans) or arrays of x/y
+ * pixel coordinates.
+ */
+void
+_swrast_logicop_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLchan rgba[][4])
+{
+ GLchan dest[MAX_WIDTH][4];
+
+ ASSERT(span->end < MAX_WIDTH);
+ ASSERT(span->arrayMask & SPAN_RGBA);
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+
+ if (span->arrayMask & SPAN_XY) {
+ _swrast_get_values(ctx, rb, span->end, span->array->x, span->array->y,
+ dest, 4 * sizeof(GLchan));
+ }
+ else {
+ _swrast_read_rgba_span(ctx, rb, span->end, span->x, span->y, dest);
+ }
+
+ /* XXX make this a runtime test */
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ /* treat 4*GLubyte as GLuint */
+ logicop_uint(ctx, span->end, (GLuint *) rgba,
+ (const GLuint *) dest, span->array->mask);
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ logicop_ushort(ctx, 4 * span->end, (GLushort *) rgba,
+ (const GLushort *) dest, span->array->mask);
+#elif CHAN_TYPE == GL_FLOAT
+ logicop_uint(ctx, 4 * span->end, (GLuint *) rgba,
+ (const GLuint *) dest, span->array->mask);
+#endif
+ (void) logicop_ubyte;
+ (void) logicop_ushort;
+ (void) logicop_uint;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_logic.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_logic.h
new file mode 100644
index 000000000..ce5f183ff
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_logic.h
@@ -0,0 +1,44 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_LOGIC_H
+#define S_LOGIC_H
+
+
+#include "mtypes.h"
+#include "swrast.h"
+
+
+extern void
+_swrast_logicop_ci_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLuint index[]);
+
+
+extern void
+_swrast_logicop_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLchan rgba[][4]);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_masking.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_masking.c
new file mode 100644
index 000000000..65c4e7d01
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_masking.c
@@ -0,0 +1,172 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/*
+ * Implement the effect of glColorMask and glIndexMask in software.
+ */
+
+
+#include "glheader.h"
+#include "enums.h"
+#include "macros.h"
+
+#include "s_context.h"
+#include "s_masking.h"
+#include "s_span.h"
+
+
+
+void
+_swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLchan rgba[][4])
+{
+ GLchan dest[MAX_WIDTH][4];
+#if CHAN_BITS == 8
+ GLuint srcMask = *((GLuint*)ctx->Color.ColorMask);
+ GLuint dstMask = ~srcMask;
+ GLuint *rgba32 = (GLuint *) rgba;
+ GLuint *dest32 = (GLuint *) dest;
+#else
+ const GLboolean rMask = ctx->Color.ColorMask[RCOMP];
+ const GLboolean gMask = ctx->Color.ColorMask[GCOMP];
+ const GLboolean bMask = ctx->Color.ColorMask[BCOMP];
+ const GLboolean aMask = ctx->Color.ColorMask[ACOMP];
+#endif
+ const GLuint n = span->end;
+ GLuint i;
+
+ ASSERT(n < MAX_WIDTH);
+ ASSERT(span->arrayMask & SPAN_RGBA);
+
+ if (span->arrayMask & SPAN_XY) {
+ _swrast_get_values(ctx, rb, n, span->array->x, span->array->y,
+ dest, 4 * sizeof(GLchan));
+ }
+ else {
+ _swrast_read_rgba_span(ctx, rb, n, span->x, span->y, dest);
+ }
+
+#if CHAN_BITS == 8
+ for (i = 0; i < n; i++) {
+ rgba32[i] = (rgba32[i] & srcMask) | (dest32[i] & dstMask);
+ }
+#else
+ for (i = 0; i < n; i++) {
+ if (!rMask) rgba[i][RCOMP] = dest[i][RCOMP];
+ if (!gMask) rgba[i][GCOMP] = dest[i][GCOMP];
+ if (!bMask) rgba[i][BCOMP] = dest[i][BCOMP];
+ if (!aMask) rgba[i][ACOMP] = dest[i][ACOMP];
+ }
+#endif
+}
+
+
+/*
+ * Apply glColorMask to a span of RGBA pixels.
+ */
+void
+_swrast_mask_rgba_array(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLchan rgba[][4])
+{
+ GLchan dest[MAX_WIDTH][4];
+ GLuint i;
+
+#if CHAN_BITS == 8
+
+ GLuint srcMask = *((GLuint*)ctx->Color.ColorMask);
+ GLuint dstMask = ~srcMask;
+ GLuint *rgba32 = (GLuint *) rgba;
+ GLuint *dest32 = (GLuint *) dest;
+
+ _swrast_read_rgba_span( ctx, rb, n, x, y, dest );
+ for (i = 0; i < n; i++) {
+ rgba32[i] = (rgba32[i] & srcMask) | (dest32[i] & dstMask);
+ }
+
+#else
+
+ const GLint rMask = ctx->Color.ColorMask[RCOMP];
+ const GLint gMask = ctx->Color.ColorMask[GCOMP];
+ const GLint bMask = ctx->Color.ColorMask[BCOMP];
+ const GLint aMask = ctx->Color.ColorMask[ACOMP];
+
+ _swrast_read_rgba_span( ctx, rb, n, x, y, dest );
+ for (i = 0; i < n; i++) {
+ if (!rMask) rgba[i][RCOMP] = dest[i][RCOMP];
+ if (!gMask) rgba[i][GCOMP] = dest[i][GCOMP];
+ if (!bMask) rgba[i][BCOMP] = dest[i][BCOMP];
+ if (!aMask) rgba[i][ACOMP] = dest[i][ACOMP];
+ }
+
+#endif
+}
+
+
+
+void
+_swrast_mask_ci_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLuint index[])
+{
+ const GLuint srcMask = ctx->Color.IndexMask;
+ const GLuint dstMask = ~srcMask;
+ GLuint dest[MAX_WIDTH];
+ GLuint i;
+
+ ASSERT(span->arrayMask & SPAN_INDEX);
+ ASSERT(span->end <= MAX_WIDTH);
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+
+ if (span->arrayMask & SPAN_XY) {
+ _swrast_get_values(ctx, rb, span->end, span->array->x, span->array->y,
+ dest, sizeof(GLuint));
+ }
+ else {
+ _swrast_read_index_span(ctx, rb, span->end, span->x, span->y, dest);
+ }
+
+ for (i = 0; i < span->end; i++) {
+ index[i] = (index[i] & srcMask) | (dest[i] & dstMask);
+ }
+}
+
+
+/*
+ * Apply glIndexMask to an array of CI pixels.
+ */
+void
+_swrast_mask_ci_array(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLuint index[])
+{
+ const GLuint srcMask = ctx->Color.IndexMask;
+ const GLuint dstMask = ~srcMask;
+ GLuint dest[MAX_WIDTH];
+ GLuint i;
+
+ _swrast_read_index_span(ctx, rb, n, x, y, dest);
+
+ for (i=0;i<n;i++) {
+ index[i] = (index[i] & srcMask) | (dest[i] & dstMask);
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_masking.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_masking.h
new file mode 100644
index 000000000..e2265448f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_masking.h
@@ -0,0 +1,58 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_MASKING_H
+#define S_MASKING_H
+
+
+#include "mtypes.h"
+#include "swrast.h"
+
+
+/*
+ * Implement glColorMask for a span of RGBA pixels.
+ */
+extern void
+_swrast_mask_rgba_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLchan rgba[][4]);
+
+
+extern void
+_swrast_mask_rgba_array(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLchan rgba[][4]);
+
+
+/*
+ * Implement glIndexMask for a span of CI pixels.
+ */
+extern void
+_swrast_mask_ci_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ const struct sw_span *span, GLuint index[]);
+
+extern void
+_swrast_mask_ci_array(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLuint index[]);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_nvfragprog.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_nvfragprog.c
new file mode 100644
index 000000000..5ee4a041a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_nvfragprog.c
@@ -0,0 +1,1507 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Regarding GL_NV_fragment_program:
+ *
+ * Portions of this software may use or implement intellectual
+ * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims
+ * any and all warranties with respect to such intellectual property,
+ * including any use thereof or modifications thereto.
+ */
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "nvfragprog.h"
+#include "macros.h"
+#include "program.h"
+
+#include "s_nvfragprog.h"
+#include "s_span.h"
+#include "s_texture.h"
+
+
+/* if 1, print some debugging info */
+#define DEBUG_FRAG 0
+
+/**
+ * Fetch a texel.
+ */
+static void
+fetch_texel( GLcontext *ctx, const GLfloat texcoord[4], GLfloat lambda,
+ GLuint unit, GLfloat color[4] )
+{
+ GLchan rgba[4];
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+
+ /* XXX use a float-valued TextureSample routine here!!! */
+ swrast->TextureSample[unit](ctx, unit, ctx->Texture.Unit[unit]._Current,
+ 1, (const GLfloat (*)[4]) texcoord,
+ &lambda, &rgba);
+ color[0] = CHAN_TO_FLOAT(rgba[0]);
+ color[1] = CHAN_TO_FLOAT(rgba[1]);
+ color[2] = CHAN_TO_FLOAT(rgba[2]);
+ color[3] = CHAN_TO_FLOAT(rgba[3]);
+}
+
+
+/**
+ * Fetch a texel with the given partial derivatives to compute a level
+ * of detail in the mipmap.
+ */
+static void
+fetch_texel_deriv( GLcontext *ctx, const GLfloat texcoord[4],
+ const GLfloat texdx[4], const GLfloat texdy[4],
+ GLuint unit, GLfloat color[4] )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current;
+ const struct gl_texture_image *texImg = texObj->Image[0][texObj->BaseLevel];
+ const GLfloat texW = (GLfloat) texImg->WidthScale;
+ const GLfloat texH = (GLfloat) texImg->HeightScale;
+ GLchan rgba[4];
+
+ GLfloat lambda = _swrast_compute_lambda(texdx[0], texdy[0], /* ds/dx, ds/dy */
+ texdx[1], texdy[1], /* dt/dx, dt/dy */
+ texdx[3], texdy[2], /* dq/dx, dq/dy */
+ texW, texH,
+ texcoord[0], texcoord[1], texcoord[3],
+ 1.0F / texcoord[3]);
+
+ swrast->TextureSample[unit](ctx, unit, ctx->Texture.Unit[unit]._Current,
+ 1, (const GLfloat (*)[4]) texcoord,
+ &lambda, &rgba);
+ color[0] = CHAN_TO_FLOAT(rgba[0]);
+ color[1] = CHAN_TO_FLOAT(rgba[1]);
+ color[2] = CHAN_TO_FLOAT(rgba[2]);
+ color[3] = CHAN_TO_FLOAT(rgba[3]);
+}
+
+
+/**
+ * Return a pointer to the 4-element float vector specified by the given
+ * source register.
+ */
+static INLINE const GLfloat *
+get_register_pointer( GLcontext *ctx,
+ const struct fp_src_register *source,
+ const struct fp_machine *machine,
+ const struct fragment_program *program )
+{
+ const GLfloat *src;
+ switch (source->File) {
+ case PROGRAM_TEMPORARY:
+ ASSERT(source->Index < MAX_NV_FRAGMENT_PROGRAM_TEMPS);
+ src = machine->Temporaries[source->Index];
+ break;
+ case PROGRAM_INPUT:
+ ASSERT(source->Index < MAX_NV_FRAGMENT_PROGRAM_INPUTS);
+ src = machine->Inputs[source->Index];
+ break;
+ case PROGRAM_OUTPUT:
+ /* This is only for PRINT */
+ ASSERT(source->Index < MAX_NV_FRAGMENT_PROGRAM_OUTPUTS);
+ src = machine->Outputs[source->Index];
+ break;
+ case PROGRAM_LOCAL_PARAM:
+ ASSERT(source->Index < MAX_PROGRAM_LOCAL_PARAMS);
+ src = program->Base.LocalParams[source->Index];
+ break;
+ case PROGRAM_ENV_PARAM:
+ ASSERT(source->Index < MAX_NV_FRAGMENT_PROGRAM_PARAMS);
+ src = ctx->FragmentProgram.Parameters[source->Index];
+ break;
+ case PROGRAM_STATE_VAR:
+ /* Fallthrough */
+ case PROGRAM_NAMED_PARAM:
+ ASSERT(source->Index < (GLint) program->Parameters->NumParameters);
+ src = program->Parameters->ParameterValues[source->Index];
+ break;
+ default:
+ _mesa_problem(ctx, "Invalid input register file %d in fetch_vector4", source->File);
+ src = NULL;
+ }
+ return src;
+}
+
+
+/**
+ * Fetch a 4-element float vector from the given source register.
+ * Apply swizzling and negating as needed.
+ */
+static void
+fetch_vector4( GLcontext *ctx,
+ const struct fp_src_register *source,
+ const struct fp_machine *machine,
+ const struct fragment_program *program,
+ GLfloat result[4] )
+{
+ const GLfloat *src = get_register_pointer(ctx, source, machine, program);
+ ASSERT(src);
+
+ result[0] = src[GET_SWZ(source->Swizzle, 0)];
+ result[1] = src[GET_SWZ(source->Swizzle, 1)];
+ result[2] = src[GET_SWZ(source->Swizzle, 2)];
+ result[3] = src[GET_SWZ(source->Swizzle, 3)];
+
+ if (source->NegateBase) {
+ result[0] = -result[0];
+ result[1] = -result[1];
+ result[2] = -result[2];
+ result[3] = -result[3];
+ }
+ if (source->Abs) {
+ result[0] = FABSF(result[0]);
+ result[1] = FABSF(result[1]);
+ result[2] = FABSF(result[2]);
+ result[3] = FABSF(result[3]);
+ }
+ if (source->NegateAbs) {
+ result[0] = -result[0];
+ result[1] = -result[1];
+ result[2] = -result[2];
+ result[3] = -result[3];
+ }
+}
+
+
+/**
+ * Fetch the derivative with respect to X for the given register.
+ * \return GL_TRUE if it was easily computed or GL_FALSE if we
+ * need to execute another instance of the program (ugh)!
+ */
+static GLboolean
+fetch_vector4_deriv( GLcontext *ctx,
+ const struct fp_src_register *source,
+ const struct sw_span *span,
+ char xOrY, GLint column, GLfloat result[4] )
+{
+ GLfloat src[4];
+
+ ASSERT(xOrY == 'X' || xOrY == 'Y');
+
+ switch (source->Index) {
+ case FRAG_ATTRIB_WPOS:
+ if (xOrY == 'X') {
+ src[0] = 1.0;
+ src[1] = 0.0;
+ src[2] = span->dzdx / ctx->DrawBuffer->_DepthMaxF;
+ src[3] = span->dwdx;
+ }
+ else {
+ src[0] = 0.0;
+ src[1] = 1.0;
+ src[2] = span->dzdy / ctx->DrawBuffer->_DepthMaxF;
+ src[3] = span->dwdy;
+ }
+ break;
+ case FRAG_ATTRIB_COL0:
+ if (xOrY == 'X') {
+ src[0] = span->drdx * (1.0F / CHAN_MAXF);
+ src[1] = span->dgdx * (1.0F / CHAN_MAXF);
+ src[2] = span->dbdx * (1.0F / CHAN_MAXF);
+ src[3] = span->dadx * (1.0F / CHAN_MAXF);
+ }
+ else {
+ src[0] = span->drdy * (1.0F / CHAN_MAXF);
+ src[1] = span->dgdy * (1.0F / CHAN_MAXF);
+ src[2] = span->dbdy * (1.0F / CHAN_MAXF);
+ src[3] = span->dady * (1.0F / CHAN_MAXF);
+ }
+ break;
+ case FRAG_ATTRIB_COL1:
+ if (xOrY == 'X') {
+ src[0] = span->dsrdx * (1.0F / CHAN_MAXF);
+ src[1] = span->dsgdx * (1.0F / CHAN_MAXF);
+ src[2] = span->dsbdx * (1.0F / CHAN_MAXF);
+ src[3] = 0.0; /* XXX need this */
+ }
+ else {
+ src[0] = span->dsrdy * (1.0F / CHAN_MAXF);
+ src[1] = span->dsgdy * (1.0F / CHAN_MAXF);
+ src[2] = span->dsbdy * (1.0F / CHAN_MAXF);
+ src[3] = 0.0; /* XXX need this */
+ }
+ break;
+ case FRAG_ATTRIB_FOGC:
+ if (xOrY == 'X') {
+ src[0] = span->dfogdx;
+ src[1] = 0.0;
+ src[2] = 0.0;
+ src[3] = 0.0;
+ }
+ else {
+ src[0] = span->dfogdy;
+ src[1] = 0.0;
+ src[2] = 0.0;
+ src[3] = 0.0;
+ }
+ break;
+ case FRAG_ATTRIB_TEX0:
+ case FRAG_ATTRIB_TEX1:
+ case FRAG_ATTRIB_TEX2:
+ case FRAG_ATTRIB_TEX3:
+ case FRAG_ATTRIB_TEX4:
+ case FRAG_ATTRIB_TEX5:
+ case FRAG_ATTRIB_TEX6:
+ case FRAG_ATTRIB_TEX7:
+ if (xOrY == 'X') {
+ const GLuint u = source->Index - FRAG_ATTRIB_TEX0;
+ /* this is a little tricky - I think I've got it right */
+ const GLfloat invQ = 1.0f / (span->tex[u][3]
+ + span->texStepX[u][3] * column);
+ src[0] = span->texStepX[u][0] * invQ;
+ src[1] = span->texStepX[u][1] * invQ;
+ src[2] = span->texStepX[u][2] * invQ;
+ src[3] = span->texStepX[u][3] * invQ;
+ }
+ else {
+ const GLuint u = source->Index - FRAG_ATTRIB_TEX0;
+ /* Tricky, as above, but in Y direction */
+ const GLfloat invQ = 1.0f / (span->tex[u][3] + span->texStepY[u][3]);
+ src[0] = span->texStepY[u][0] * invQ;
+ src[1] = span->texStepY[u][1] * invQ;
+ src[2] = span->texStepY[u][2] * invQ;
+ src[3] = span->texStepY[u][3] * invQ;
+ }
+ break;
+ default:
+ return GL_FALSE;
+ }
+
+ result[0] = src[GET_SWZ(source->Swizzle, 0)];
+ result[1] = src[GET_SWZ(source->Swizzle, 1)];
+ result[2] = src[GET_SWZ(source->Swizzle, 2)];
+ result[3] = src[GET_SWZ(source->Swizzle, 3)];
+
+ if (source->NegateBase) {
+ result[0] = -result[0];
+ result[1] = -result[1];
+ result[2] = -result[2];
+ result[3] = -result[3];
+ }
+ if (source->Abs) {
+ result[0] = FABSF(result[0]);
+ result[1] = FABSF(result[1]);
+ result[2] = FABSF(result[2]);
+ result[3] = FABSF(result[3]);
+ }
+ if (source->NegateAbs) {
+ result[0] = -result[0];
+ result[1] = -result[1];
+ result[2] = -result[2];
+ result[3] = -result[3];
+ }
+ return GL_TRUE;
+}
+
+
+/**
+ * As above, but only return result[0] element.
+ */
+static void
+fetch_vector1( GLcontext *ctx,
+ const struct fp_src_register *source,
+ const struct fp_machine *machine,
+ const struct fragment_program *program,
+ GLfloat result[4] )
+{
+ const GLfloat *src = get_register_pointer(ctx, source, machine, program);
+ ASSERT(src);
+
+ result[0] = src[GET_SWZ(source->Swizzle, 0)];
+
+ if (source->NegateBase) {
+ result[0] = -result[0];
+ }
+ if (source->Abs) {
+ result[0] = FABSF(result[0]);
+ }
+ if (source->NegateAbs) {
+ result[0] = -result[0];
+ }
+}
+
+
+/**
+ * Test value against zero and return GT, LT, EQ or UN if NaN.
+ */
+static INLINE GLuint
+generate_cc( float value )
+{
+ if (value != value)
+ return COND_UN; /* NaN */
+ if (value > 0.0F)
+ return COND_GT;
+ if (value < 0.0F)
+ return COND_LT;
+ return COND_EQ;
+}
+
+
+/**
+ * Test if the ccMaskRule is satisfied by the given condition code.
+ * Used to mask destination writes according to the current condition codee.
+ */
+static INLINE GLboolean
+test_cc(GLuint condCode, GLuint ccMaskRule)
+{
+ switch (ccMaskRule) {
+ case COND_EQ: return (condCode == COND_EQ);
+ case COND_NE: return (condCode != COND_EQ);
+ case COND_LT: return (condCode == COND_LT);
+ case COND_GE: return (condCode == COND_GT || condCode == COND_EQ);
+ case COND_LE: return (condCode == COND_LT || condCode == COND_EQ);
+ case COND_GT: return (condCode == COND_GT);
+ case COND_TR: return GL_TRUE;
+ case COND_FL: return GL_FALSE;
+ default: return GL_TRUE;
+ }
+}
+
+
+/**
+ * Store 4 floats into a register. Observe the instructions saturate and
+ * set-condition-code flags.
+ */
+static void
+store_vector4( const struct fp_instruction *inst,
+ struct fp_machine *machine,
+ const GLfloat value[4] )
+{
+ const struct fp_dst_register *dest = &(inst->DstReg);
+ const GLboolean clamp = inst->Saturate;
+ const GLboolean updateCC = inst->UpdateCondRegister;
+ GLfloat *dstReg;
+ GLfloat dummyReg[4];
+ GLfloat clampedValue[4];
+ GLboolean condWriteMask[4];
+ GLuint writeMask = dest->WriteMask;
+
+ switch (dest->File) {
+ case PROGRAM_OUTPUT:
+ dstReg = machine->Outputs[dest->Index];
+ break;
+ case PROGRAM_TEMPORARY:
+ dstReg = machine->Temporaries[dest->Index];
+ break;
+ case PROGRAM_WRITE_ONLY:
+ dstReg = dummyReg;
+ return;
+ default:
+ _mesa_problem(NULL, "bad register file in store_vector4(fp)");
+ return;
+ }
+
+#if DEBUG_FRAG
+ if (value[0] > 1.0e10 ||
+ IS_INF_OR_NAN(value[0]) ||
+ IS_INF_OR_NAN(value[1]) ||
+ IS_INF_OR_NAN(value[2]) ||
+ IS_INF_OR_NAN(value[3]) )
+ printf("store %g %g %g %g\n", value[0], value[1], value[2], value[3]);
+#endif
+
+ if (clamp) {
+ clampedValue[0] = CLAMP(value[0], 0.0F, 1.0F);
+ clampedValue[1] = CLAMP(value[1], 0.0F, 1.0F);
+ clampedValue[2] = CLAMP(value[2], 0.0F, 1.0F);
+ clampedValue[3] = CLAMP(value[3], 0.0F, 1.0F);
+ value = clampedValue;
+ }
+
+ if (dest->CondMask != COND_TR) {
+ condWriteMask[0] = GET_BIT(writeMask, 0)
+ && test_cc(machine->CondCodes[GET_SWZ(dest->CondSwizzle, 0)], dest->CondMask);
+ condWriteMask[1] = GET_BIT(writeMask, 1)
+ && test_cc(machine->CondCodes[GET_SWZ(dest->CondSwizzle, 1)], dest->CondMask);
+ condWriteMask[2] = GET_BIT(writeMask, 2)
+ && test_cc(machine->CondCodes[GET_SWZ(dest->CondSwizzle, 2)], dest->CondMask);
+ condWriteMask[3] = GET_BIT(writeMask, 3)
+ && test_cc(machine->CondCodes[GET_SWZ(dest->CondSwizzle, 3)], dest->CondMask);
+
+ writeMask = ((condWriteMask[0] << 0) |
+ (condWriteMask[1] << 1) |
+ (condWriteMask[2] << 2) |
+ (condWriteMask[3] << 3));
+ }
+
+ if (GET_BIT(writeMask, 0)) {
+ dstReg[0] = value[0];
+ if (updateCC)
+ machine->CondCodes[0] = generate_cc(value[0]);
+ }
+ if (GET_BIT(writeMask, 1)) {
+ dstReg[1] = value[1];
+ if (updateCC)
+ machine->CondCodes[1] = generate_cc(value[1]);
+ }
+ if (GET_BIT(writeMask, 2)) {
+ dstReg[2] = value[2];
+ if (updateCC)
+ machine->CondCodes[2] = generate_cc(value[2]);
+ }
+ if (GET_BIT(writeMask, 3)) {
+ dstReg[3] = value[3];
+ if (updateCC)
+ machine->CondCodes[3] = generate_cc(value[3]);
+ }
+}
+
+
+/**
+ * Initialize a new machine state instance from an existing one, adding
+ * the partial derivatives onto the input registers.
+ * Used to implement DDX and DDY instructions in non-trivial cases.
+ */
+static void
+init_machine_deriv( GLcontext *ctx,
+ const struct fp_machine *machine,
+ const struct fragment_program *program,
+ const struct sw_span *span, char xOrY,
+ struct fp_machine *dMachine )
+{
+ GLuint u;
+
+ ASSERT(xOrY == 'X' || xOrY == 'Y');
+
+ /* copy existing machine */
+ _mesa_memcpy(dMachine, machine, sizeof(struct fp_machine));
+
+ if (program->Base.Target == GL_FRAGMENT_PROGRAM_NV) {
+ /* Clear temporary registers (undefined for ARB_f_p) */
+ _mesa_bzero( (void*) machine->Temporaries,
+ MAX_NV_FRAGMENT_PROGRAM_TEMPS * 4 * sizeof(GLfloat));
+ }
+
+ /* Add derivatives */
+ if (program->InputsRead & (1 << FRAG_ATTRIB_WPOS)) {
+ GLfloat *wpos = (GLfloat*) machine->Inputs[FRAG_ATTRIB_WPOS];
+ if (xOrY == 'X') {
+ wpos[0] += 1.0F;
+ wpos[1] += 0.0F;
+ wpos[2] += span->dzdx;
+ wpos[3] += span->dwdx;
+ }
+ else {
+ wpos[0] += 0.0F;
+ wpos[1] += 1.0F;
+ wpos[2] += span->dzdy;
+ wpos[3] += span->dwdy;
+ }
+ }
+ if (program->InputsRead & (1 << FRAG_ATTRIB_COL0)) {
+ GLfloat *col0 = (GLfloat*) machine->Inputs[FRAG_ATTRIB_COL0];
+ if (xOrY == 'X') {
+ col0[0] += span->drdx * (1.0F / CHAN_MAXF);
+ col0[1] += span->dgdx * (1.0F / CHAN_MAXF);
+ col0[2] += span->dbdx * (1.0F / CHAN_MAXF);
+ col0[3] += span->dadx * (1.0F / CHAN_MAXF);
+ }
+ else {
+ col0[0] += span->drdy * (1.0F / CHAN_MAXF);
+ col0[1] += span->dgdy * (1.0F / CHAN_MAXF);
+ col0[2] += span->dbdy * (1.0F / CHAN_MAXF);
+ col0[3] += span->dady * (1.0F / CHAN_MAXF);
+ }
+ }
+ if (program->InputsRead & (1 << FRAG_ATTRIB_COL1)) {
+ GLfloat *col1 = (GLfloat*) machine->Inputs[FRAG_ATTRIB_COL1];
+ if (xOrY == 'X') {
+ col1[0] += span->dsrdx * (1.0F / CHAN_MAXF);
+ col1[1] += span->dsgdx * (1.0F / CHAN_MAXF);
+ col1[2] += span->dsbdx * (1.0F / CHAN_MAXF);
+ col1[3] += 0.0; /*XXX fix */
+ }
+ else {
+ col1[0] += span->dsrdy * (1.0F / CHAN_MAXF);
+ col1[1] += span->dsgdy * (1.0F / CHAN_MAXF);
+ col1[2] += span->dsbdy * (1.0F / CHAN_MAXF);
+ col1[3] += 0.0; /*XXX fix */
+ }
+ }
+ if (program->InputsRead & (1 << FRAG_ATTRIB_FOGC)) {
+ GLfloat *fogc = (GLfloat*) machine->Inputs[FRAG_ATTRIB_FOGC];
+ if (xOrY == 'X') {
+ fogc[0] += span->dfogdx;
+ }
+ else {
+ fogc[0] += span->dfogdy;
+ }
+ }
+ for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
+ if (program->InputsRead & (1 << (FRAG_ATTRIB_TEX0 + u))) {
+ GLfloat *tex = (GLfloat*) machine->Inputs[FRAG_ATTRIB_TEX0 + u];
+ /* XXX perspective-correct interpolation */
+ if (xOrY == 'X') {
+ tex[0] += span->texStepX[u][0];
+ tex[1] += span->texStepX[u][1];
+ tex[2] += span->texStepX[u][2];
+ tex[3] += span->texStepX[u][3];
+ }
+ else {
+ tex[0] += span->texStepY[u][0];
+ tex[1] += span->texStepY[u][1];
+ tex[2] += span->texStepY[u][2];
+ tex[3] += span->texStepY[u][3];
+ }
+ }
+ }
+
+ /* init condition codes */
+ dMachine->CondCodes[0] = COND_EQ;
+ dMachine->CondCodes[1] = COND_EQ;
+ dMachine->CondCodes[2] = COND_EQ;
+ dMachine->CondCodes[3] = COND_EQ;
+}
+
+
+/**
+ * Execute the given vertex program.
+ * NOTE: we do everything in single-precision floating point; we don't
+ * currently observe the single/half/fixed-precision qualifiers.
+ * \param ctx - rendering context
+ * \param program - the fragment program to execute
+ * \param machine - machine state (register file)
+ * \param maxInst - max number of instructions to execute
+ * \return GL_TRUE if program completed or GL_FALSE if program executed KIL.
+ */
+static GLboolean
+execute_program( GLcontext *ctx,
+ const struct fragment_program *program, GLuint maxInst,
+ struct fp_machine *machine, const struct sw_span *span,
+ GLuint column )
+{
+ GLuint pc;
+
+#if DEBUG_FRAG
+ printf("execute fragment program --------------------\n");
+#endif
+
+ for (pc = 0; pc < maxInst; pc++) {
+ const struct fp_instruction *inst = program->Instructions + pc;
+
+ if (ctx->FragmentProgram.CallbackEnabled &&
+ ctx->FragmentProgram.Callback) {
+ ctx->FragmentProgram.CurrentPosition = inst->StringPos;
+ ctx->FragmentProgram.Callback(program->Base.Target,
+ ctx->FragmentProgram.CallbackData);
+ }
+
+ switch (inst->Opcode) {
+ case FP_OPCODE_ABS:
+ {
+ GLfloat a[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ result[0] = FABSF(a[0]);
+ result[1] = FABSF(a[1]);
+ result[2] = FABSF(a[2]);
+ result[3] = FABSF(a[3]);
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_ADD:
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = a[0] + b[0];
+ result[1] = a[1] + b[1];
+ result[2] = a[2] + b[2];
+ result[3] = a[3] + b[3];
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_CMP:
+ {
+ GLfloat a[4], b[4], c[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ fetch_vector4( ctx, &inst->SrcReg[2], machine, program, c );
+ result[0] = a[0] < 0.0F ? b[0] : c[0];
+ result[1] = a[1] < 0.0F ? b[1] : c[1];
+ result[2] = a[2] < 0.0F ? b[2] : c[2];
+ result[3] = a[3] < 0.0F ? b[3] : c[3];
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_COS:
+ {
+ GLfloat a[4], result[4];
+ fetch_vector1( ctx, &inst->SrcReg[0], machine, program, a );
+ result[0] = result[1] = result[2] = result[3] = (GLfloat)_mesa_cos(a[0]);
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_DDX: /* Partial derivative with respect to X */
+ {
+ GLfloat a[4], aNext[4], result[4];
+ struct fp_machine dMachine;
+ if (!fetch_vector4_deriv(ctx, &inst->SrcReg[0], span, 'X',
+ column, result)) {
+ /* This is tricky. Make a copy of the current machine state,
+ * increment the input registers by the dx or dy partial
+ * derivatives, then re-execute the program up to the
+ * preceeding instruction, then fetch the source register.
+ * Finally, find the difference in the register values for
+ * the original and derivative runs.
+ */
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a);
+ init_machine_deriv(ctx, machine, program, span,
+ 'X', &dMachine);
+ execute_program(ctx, program, pc, &dMachine, span, column);
+ fetch_vector4( ctx, &inst->SrcReg[0], &dMachine, program, aNext );
+ result[0] = aNext[0] - a[0];
+ result[1] = aNext[1] - a[1];
+ result[2] = aNext[2] - a[2];
+ result[3] = aNext[3] - a[3];
+ }
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_DDY: /* Partial derivative with respect to Y */
+ {
+ GLfloat a[4], aNext[4], result[4];
+ struct fp_machine dMachine;
+ if (!fetch_vector4_deriv(ctx, &inst->SrcReg[0], span, 'Y',
+ column, result)) {
+ init_machine_deriv(ctx, machine, program, span,
+ 'Y', &dMachine);
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a);
+ execute_program(ctx, program, pc, &dMachine, span, column);
+ fetch_vector4( ctx, &inst->SrcReg[0], &dMachine, program, aNext );
+ result[0] = aNext[0] - a[0];
+ result[1] = aNext[1] - a[1];
+ result[2] = aNext[2] - a[2];
+ result[3] = aNext[3] - a[3];
+ }
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_DP3:
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = result[1] = result[2] = result[3] =
+ a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
+ store_vector4( inst, machine, result );
+#if DEBUG_FRAG
+ printf("DP3 %g = (%g %g %g) . (%g %g %g)\n",
+ result[0], a[0], a[1], a[2], b[0], b[1], b[2]);
+#endif
+ }
+ break;
+ case FP_OPCODE_DP4:
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = result[1] = result[2] = result[3] =
+ a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
+ store_vector4( inst, machine, result );
+#if DEBUG_FRAG
+ printf("DP4 %g = (%g, %g %g %g) . (%g, %g %g %g)\n",
+ result[0], a[0], a[1], a[2], a[3], b[0], b[1], b[2], b[3]);
+#endif
+ }
+ break;
+ case FP_OPCODE_DPH:
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = result[1] = result[2] = result[3] =
+ a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + b[3];
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_DST: /* Distance vector */
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = 1.0F;
+ result[1] = a[1] * b[1];
+ result[2] = a[2];
+ result[3] = b[3];
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_EX2: /* Exponential base 2 */
+ {
+ GLfloat a[4], result[4];
+ fetch_vector1( ctx, &inst->SrcReg[0], machine, program, a );
+ result[0] = result[1] = result[2] = result[3] =
+ (GLfloat) _mesa_pow(2.0, a[0]);
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_FLR:
+ {
+ GLfloat a[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ result[0] = FLOORF(a[0]);
+ result[1] = FLOORF(a[1]);
+ result[2] = FLOORF(a[2]);
+ result[3] = FLOORF(a[3]);
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_FRC:
+ {
+ GLfloat a[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ result[0] = a[0] - FLOORF(a[0]);
+ result[1] = a[1] - FLOORF(a[1]);
+ result[2] = a[2] - FLOORF(a[2]);
+ result[3] = a[3] - FLOORF(a[3]);
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_KIL_NV: /* NV_f_p only */
+ {
+ const GLuint swizzle = inst->DstReg.CondSwizzle;
+ const GLuint condMask = inst->DstReg.CondMask;
+ if (test_cc(machine->CondCodes[GET_SWZ(swizzle, 0)], condMask) ||
+ test_cc(machine->CondCodes[GET_SWZ(swizzle, 1)], condMask) ||
+ test_cc(machine->CondCodes[GET_SWZ(swizzle, 2)], condMask) ||
+ test_cc(machine->CondCodes[GET_SWZ(swizzle, 3)], condMask)) {
+ return GL_FALSE;
+ }
+ }
+ break;
+ case FP_OPCODE_KIL: /* ARB_f_p only */
+ {
+ GLfloat a[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ if (a[0] < 0.0F || a[1] < 0.0F || a[2] < 0.0F || a[3] < 0.0F) {
+ return GL_FALSE;
+ }
+ }
+ break;
+ case FP_OPCODE_LG2: /* log base 2 */
+ {
+ GLfloat a[4], result[4];
+ fetch_vector1( ctx, &inst->SrcReg[0], machine, program, a );
+ result[0] = result[1] = result[2] = result[3]
+ = LOG2(a[0]);
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_LIT:
+ {
+ const GLfloat epsilon = 1.0F / 256.0F; /* from NV VP spec */
+ GLfloat a[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ a[0] = MAX2(a[0], 0.0F);
+ a[1] = MAX2(a[1], 0.0F);
+ /* XXX ARB version clamps a[3], NV version doesn't */
+ a[3] = CLAMP(a[3], -(128.0F - epsilon), (128.0F - epsilon));
+ result[0] = 1.0F;
+ result[1] = a[0];
+ /* XXX we could probably just use pow() here */
+ if (a[0] > 0.0F) {
+ if (a[1] == 0.0 && a[3] == 0.0)
+ result[2] = 1.0;
+ else
+ result[2] = EXPF(a[3] * LOGF(a[1]));
+ }
+ else {
+ result[2] = 0.0;
+ }
+ result[3] = 1.0F;
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_LRP:
+ {
+ GLfloat a[4], b[4], c[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ fetch_vector4( ctx, &inst->SrcReg[2], machine, program, c );
+ result[0] = a[0] * b[0] + (1.0F - a[0]) * c[0];
+ result[1] = a[1] * b[1] + (1.0F - a[1]) * c[1];
+ result[2] = a[2] * b[2] + (1.0F - a[2]) * c[2];
+ result[3] = a[3] * b[3] + (1.0F - a[3]) * c[3];
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_MAD:
+ {
+ GLfloat a[4], b[4], c[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ fetch_vector4( ctx, &inst->SrcReg[2], machine, program, c );
+ result[0] = a[0] * b[0] + c[0];
+ result[1] = a[1] * b[1] + c[1];
+ result[2] = a[2] * b[2] + c[2];
+ result[3] = a[3] * b[3] + c[3];
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_MAX:
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = MAX2(a[0], b[0]);
+ result[1] = MAX2(a[1], b[1]);
+ result[2] = MAX2(a[2], b[2]);
+ result[3] = MAX2(a[3], b[3]);
+ store_vector4( inst, machine, result );
+#if DEBUG_FRAG
+ printf("MAX (%g %g %g %g) = (%g %g %g %g), (%g %g %g %g)\n",
+ result[0], result[1], result[2], result[3],
+ a[0], a[1], a[2], a[3],
+ b[0], b[1], b[2], b[3]);
+#endif
+ }
+ break;
+ case FP_OPCODE_MIN:
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = MIN2(a[0], b[0]);
+ result[1] = MIN2(a[1], b[1]);
+ result[2] = MIN2(a[2], b[2]);
+ result[3] = MIN2(a[3], b[3]);
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_MOV:
+ {
+ GLfloat result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, result );
+ store_vector4( inst, machine, result );
+#if DEBUG_FRAG
+ printf("MOV (%g %g %g %g)\n",
+ result[0], result[1], result[2], result[3]);
+#endif
+ }
+ break;
+ case FP_OPCODE_MUL:
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = a[0] * b[0];
+ result[1] = a[1] * b[1];
+ result[2] = a[2] * b[2];
+ result[3] = a[3] * b[3];
+ store_vector4( inst, machine, result );
+#if DEBUG_FRAG
+ printf("MUL (%g %g %g %g) = (%g %g %g %g) * (%g %g %g %g)\n",
+ result[0], result[1], result[2], result[3],
+ a[0], a[1], a[2], a[3],
+ b[0], b[1], b[2], b[3]);
+#endif
+ }
+ break;
+ case FP_OPCODE_PK2H: /* pack two 16-bit floats in one 32-bit float */
+ {
+ GLfloat a[4], result[4];
+ GLhalfNV hx, hy;
+ GLuint *rawResult = (GLuint *) result;
+ GLuint twoHalves;
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ hx = _mesa_float_to_half(a[0]);
+ hy = _mesa_float_to_half(a[1]);
+ twoHalves = hx | (hy << 16);
+ rawResult[0] = rawResult[1] = rawResult[2] = rawResult[3]
+ = twoHalves;
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_PK2US: /* pack two GLushorts into one 32-bit float */
+ {
+ GLfloat a[4], result[4];
+ GLuint usx, usy, *rawResult = (GLuint *) result;
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ a[0] = CLAMP(a[0], 0.0F, 1.0F);
+ a[1] = CLAMP(a[1], 0.0F, 1.0F);
+ usx = IROUND(a[0] * 65535.0F);
+ usy = IROUND(a[1] * 65535.0F);
+ rawResult[0] = rawResult[1] = rawResult[2] = rawResult[3]
+ = usx | (usy << 16);
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_PK4B: /* pack four GLbytes into one 32-bit float */
+ {
+ GLfloat a[4], result[4];
+ GLuint ubx, uby, ubz, ubw, *rawResult = (GLuint *) result;
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ a[0] = CLAMP(a[0], -128.0F / 127.0F, 1.0F);
+ a[1] = CLAMP(a[1], -128.0F / 127.0F, 1.0F);
+ a[2] = CLAMP(a[2], -128.0F / 127.0F, 1.0F);
+ a[3] = CLAMP(a[3], -128.0F / 127.0F, 1.0F);
+ ubx = IROUND(127.0F * a[0] + 128.0F);
+ uby = IROUND(127.0F * a[1] + 128.0F);
+ ubz = IROUND(127.0F * a[2] + 128.0F);
+ ubw = IROUND(127.0F * a[3] + 128.0F);
+ rawResult[0] = rawResult[1] = rawResult[2] = rawResult[3]
+ = ubx | (uby << 8) | (ubz << 16) | (ubw << 24);
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_PK4UB: /* pack four GLubytes into one 32-bit float */
+ {
+ GLfloat a[4], result[4];
+ GLuint ubx, uby, ubz, ubw, *rawResult = (GLuint *) result;
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ a[0] = CLAMP(a[0], 0.0F, 1.0F);
+ a[1] = CLAMP(a[1], 0.0F, 1.0F);
+ a[2] = CLAMP(a[2], 0.0F, 1.0F);
+ a[3] = CLAMP(a[3], 0.0F, 1.0F);
+ ubx = IROUND(255.0F * a[0]);
+ uby = IROUND(255.0F * a[1]);
+ ubz = IROUND(255.0F * a[2]);
+ ubw = IROUND(255.0F * a[3]);
+ rawResult[0] = rawResult[1] = rawResult[2] = rawResult[3]
+ = ubx | (uby << 8) | (ubz << 16) | (ubw << 24);
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_POW:
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector1( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector1( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = result[1] = result[2] = result[3]
+ = (GLfloat)_mesa_pow(a[0], b[0]);
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_RCP:
+ {
+ GLfloat a[4], result[4];
+ fetch_vector1( ctx, &inst->SrcReg[0], machine, program, a );
+#if DEBUG_FRAG
+ if (a[0] == 0)
+ printf("RCP(0)\n");
+ else if (IS_INF_OR_NAN(a[0]))
+ printf("RCP(inf)\n");
+#endif
+ result[0] = result[1] = result[2] = result[3]
+ = 1.0F / a[0];
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_RFL:
+ {
+ GLfloat axis[4], dir[4], result[4], tmp[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, axis );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, dir );
+ tmp[3] = axis[0] * axis[0]
+ + axis[1] * axis[1]
+ + axis[2] * axis[2];
+ tmp[0] = (2.0F * (axis[0] * dir[0] +
+ axis[1] * dir[1] +
+ axis[2] * dir[2])) / tmp[3];
+ result[0] = tmp[0] * axis[0] - dir[0];
+ result[1] = tmp[0] * axis[1] - dir[1];
+ result[2] = tmp[0] * axis[2] - dir[2];
+ /* result[3] is never written! XXX enforce in parser! */
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_RSQ: /* 1 / sqrt() */
+ {
+ GLfloat a[4], result[4];
+ fetch_vector1( ctx, &inst->SrcReg[0], machine, program, a );
+ a[0] = FABSF(a[0]);
+ result[0] = result[1] = result[2] = result[3] = INV_SQRTF(a[0]);
+ store_vector4( inst, machine, result );
+#if DEBUG_FRAG
+ printf("RSQ %g = 1/sqrt(|%g|)\n", result[0], a[0]);
+#endif
+ }
+ break;
+ case FP_OPCODE_SCS: /* sine and cos */
+ {
+ GLfloat a[4], result[4];
+ fetch_vector1( ctx, &inst->SrcReg[0], machine, program, a );
+ result[0] = (GLfloat)cos(a[0]);
+ result[1] = (GLfloat)sin(a[0]);
+ result[2] = 0.0; /* undefined! */
+ result[3] = 0.0; /* undefined! */
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_SEQ: /* set on equal */
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = (a[0] == b[0]) ? 1.0F : 0.0F;
+ result[1] = (a[1] == b[1]) ? 1.0F : 0.0F;
+ result[2] = (a[2] == b[2]) ? 1.0F : 0.0F;
+ result[3] = (a[3] == b[3]) ? 1.0F : 0.0F;
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_SFL: /* set false, operands ignored */
+ {
+ static const GLfloat result[4] = { 0.0F, 0.0F, 0.0F, 0.0F };
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_SGE: /* set on greater or equal */
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = (a[0] >= b[0]) ? 1.0F : 0.0F;
+ result[1] = (a[1] >= b[1]) ? 1.0F : 0.0F;
+ result[2] = (a[2] >= b[2]) ? 1.0F : 0.0F;
+ result[3] = (a[3] >= b[3]) ? 1.0F : 0.0F;
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_SGT: /* set on greater */
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = (a[0] > b[0]) ? 1.0F : 0.0F;
+ result[1] = (a[1] > b[1]) ? 1.0F : 0.0F;
+ result[2] = (a[2] > b[2]) ? 1.0F : 0.0F;
+ result[3] = (a[3] > b[3]) ? 1.0F : 0.0F;
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_SIN:
+ {
+ GLfloat a[4], result[4];
+ fetch_vector1( ctx, &inst->SrcReg[0], machine, program, a );
+ result[0] = result[1] = result[2] =
+ result[3] = (GLfloat)_mesa_sin(a[0]);
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_SLE: /* set on less or equal */
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = (a[0] <= b[0]) ? 1.0F : 0.0F;
+ result[1] = (a[1] <= b[1]) ? 1.0F : 0.0F;
+ result[2] = (a[2] <= b[2]) ? 1.0F : 0.0F;
+ result[3] = (a[3] <= b[3]) ? 1.0F : 0.0F;
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_SLT: /* set on less */
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = (a[0] < b[0]) ? 1.0F : 0.0F;
+ result[1] = (a[1] < b[1]) ? 1.0F : 0.0F;
+ result[2] = (a[2] < b[2]) ? 1.0F : 0.0F;
+ result[3] = (a[3] < b[3]) ? 1.0F : 0.0F;
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_SNE: /* set on not equal */
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = (a[0] != b[0]) ? 1.0F : 0.0F;
+ result[1] = (a[1] != b[1]) ? 1.0F : 0.0F;
+ result[2] = (a[2] != b[2]) ? 1.0F : 0.0F;
+ result[3] = (a[3] != b[3]) ? 1.0F : 0.0F;
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_STR: /* set true, operands ignored */
+ {
+ static const GLfloat result[4] = { 1.0F, 1.0F, 1.0F, 1.0F };
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_SUB:
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = a[0] - b[0];
+ result[1] = a[1] - b[1];
+ result[2] = a[2] - b[2];
+ result[3] = a[3] - b[3];
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_SWZ:
+ {
+ const struct fp_src_register *source = &inst->SrcReg[0];
+ const GLfloat *src = get_register_pointer(ctx, source,
+ machine, program);
+ GLfloat result[4];
+ GLuint i;
+
+ /* do extended swizzling here */
+ for (i = 0; i < 4; i++) {
+ if (GET_SWZ(source->Swizzle, i) == SWIZZLE_ZERO)
+ result[i] = 0.0;
+ else if (GET_SWZ(source->Swizzle, i) == SWIZZLE_ONE)
+ result[i] = 1.0;
+ else
+ result[i] = src[GET_SWZ(source->Swizzle, i)];
+
+ if (source->NegateBase & (1 << i))
+ result[i] = -result[i];
+ }
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_TEX: /* Both ARB and NV frag prog */
+ /* Texel lookup */
+ {
+ GLfloat texcoord[4], color[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, texcoord );
+ /* Note: we pass 0 for LOD. The ARB extension requires it
+ * while the NV extension says it's implementation dependant.
+ */
+ /* KW: Previously lambda was passed as zero, but I
+ * believe this is incorrect, the spec seems to
+ * indicate rather that lambda should not be
+ * changed/biased, unlike TXB where texcoord[3] is
+ * added to the lambda calculations. The lambda should
+ * still be calculated normally for TEX & TXP though,
+ * not set to zero. Otherwise it's very difficult to
+ * implement normal GL semantics through the fragment
+ * shader.
+ */
+ fetch_texel( ctx, texcoord,
+ span->array->lambda[inst->TexSrcUnit][column],
+ inst->TexSrcUnit, color );
+ store_vector4( inst, machine, color );
+ }
+ break;
+ case FP_OPCODE_TXB: /* GL_ARB_fragment_program only */
+ /* Texel lookup with LOD bias */
+ {
+ GLfloat texcoord[4], color[4], bias, lambda;
+
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, texcoord );
+ /* texcoord[3] is the bias to add to lambda */
+ bias = ctx->Texture.Unit[inst->TexSrcUnit].LodBias
+ + ctx->Texture.Unit[inst->TexSrcUnit]._Current->LodBias
+ + texcoord[3];
+ lambda = span->array->lambda[inst->TexSrcUnit][column] + bias;
+ fetch_texel( ctx, texcoord, lambda,
+ inst->TexSrcUnit, color );
+ store_vector4( inst, machine, color );
+ }
+ break;
+ case FP_OPCODE_TXD: /* GL_NV_fragment_program only */
+ /* Texture lookup w/ partial derivatives for LOD */
+ {
+ GLfloat texcoord[4], dtdx[4], dtdy[4], color[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, texcoord );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, dtdx );
+ fetch_vector4( ctx, &inst->SrcReg[2], machine, program, dtdy );
+ fetch_texel_deriv( ctx, texcoord, dtdx, dtdy, inst->TexSrcUnit,
+ color );
+ store_vector4( inst, machine, color );
+ }
+ break;
+ case FP_OPCODE_TXP: /* GL_ARB_fragment_program only */
+ /* Texture lookup w/ projective divide */
+ {
+ GLfloat texcoord[4], color[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, texcoord );
+ /* Not so sure about this test - if texcoord[3] is
+ * zero, we'd probably be fine except for an ASSERT in
+ * IROUND_POS() which gets triggered by the inf values created.
+ */
+ if (texcoord[3] != 0.0) {
+ texcoord[0] /= texcoord[3];
+ texcoord[1] /= texcoord[3];
+ texcoord[2] /= texcoord[3];
+ }
+ /* KW: Previously lambda was passed as zero, but I
+ * believe this is incorrect, the spec seems to
+ * indicate rather that lambda should not be
+ * changed/biased, unlike TXB where texcoord[3] is
+ * added to the lambda calculations. The lambda should
+ * still be calculated normally for TEX & TXP though,
+ * not set to zero.
+ */
+ fetch_texel( ctx, texcoord,
+ span->array->lambda[inst->TexSrcUnit][column],
+ inst->TexSrcUnit, color );
+ store_vector4( inst, machine, color );
+ }
+ break;
+ case FP_OPCODE_TXP_NV: /* GL_NV_fragment_program only */
+ /* Texture lookup w/ projective divide */
+ {
+ GLfloat texcoord[4], color[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, texcoord );
+ if (inst->TexSrcIdx != TEXTURE_CUBE_INDEX &&
+ texcoord[3] != 0.0) {
+ texcoord[0] /= texcoord[3];
+ texcoord[1] /= texcoord[3];
+ texcoord[2] /= texcoord[3];
+ }
+ fetch_texel( ctx, texcoord,
+ span->array->lambda[inst->TexSrcUnit][column],
+ inst->TexSrcUnit, color );
+ store_vector4( inst, machine, color );
+ }
+ break;
+ case FP_OPCODE_UP2H: /* unpack two 16-bit floats */
+ {
+ GLfloat a[4], result[4];
+ const GLuint *rawBits = (const GLuint *) a;
+ GLhalfNV hx, hy;
+ fetch_vector1( ctx, &inst->SrcReg[0], machine, program, a );
+ hx = rawBits[0] & 0xffff;
+ hy = rawBits[0] >> 16;
+ result[0] = result[2] = _mesa_half_to_float(hx);
+ result[1] = result[3] = _mesa_half_to_float(hy);
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_UP2US: /* unpack two GLushorts */
+ {
+ GLfloat a[4], result[4];
+ const GLuint *rawBits = (const GLuint *) a;
+ GLushort usx, usy;
+ fetch_vector1( ctx, &inst->SrcReg[0], machine, program, a );
+ usx = rawBits[0] & 0xffff;
+ usy = rawBits[0] >> 16;
+ result[0] = result[2] = usx * (1.0f / 65535.0f);
+ result[1] = result[3] = usy * (1.0f / 65535.0f);
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_UP4B: /* unpack four GLbytes */
+ {
+ GLfloat a[4], result[4];
+ const GLuint *rawBits = (const GLuint *) a;
+ fetch_vector1( ctx, &inst->SrcReg[0], machine, program, a );
+ result[0] = (((rawBits[0] >> 0) & 0xff) - 128) / 127.0F;
+ result[1] = (((rawBits[0] >> 8) & 0xff) - 128) / 127.0F;
+ result[2] = (((rawBits[0] >> 16) & 0xff) - 128) / 127.0F;
+ result[3] = (((rawBits[0] >> 24) & 0xff) - 128) / 127.0F;
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_UP4UB: /* unpack four GLubytes */
+ {
+ GLfloat a[4], result[4];
+ const GLuint *rawBits = (const GLuint *) a;
+ fetch_vector1( ctx, &inst->SrcReg[0], machine, program, a );
+ result[0] = ((rawBits[0] >> 0) & 0xff) / 255.0F;
+ result[1] = ((rawBits[0] >> 8) & 0xff) / 255.0F;
+ result[2] = ((rawBits[0] >> 16) & 0xff) / 255.0F;
+ result[3] = ((rawBits[0] >> 24) & 0xff) / 255.0F;
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_XPD: /* cross product */
+ {
+ GLfloat a[4], b[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ result[0] = a[1] * b[2] - a[2] * b[1];
+ result[1] = a[2] * b[0] - a[0] * b[2];
+ result[2] = a[0] * b[1] - a[1] * b[0];
+ result[3] = 1.0;
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_X2D: /* 2-D matrix transform */
+ {
+ GLfloat a[4], b[4], c[4], result[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a );
+ fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b );
+ fetch_vector4( ctx, &inst->SrcReg[2], machine, program, c );
+ result[0] = a[0] + b[0] * c[0] + b[1] * c[1];
+ result[1] = a[1] + b[0] * c[2] + b[1] * c[3];
+ result[2] = a[2] + b[0] * c[0] + b[1] * c[1];
+ result[3] = a[3] + b[0] * c[2] + b[1] * c[3];
+ store_vector4( inst, machine, result );
+ }
+ break;
+ case FP_OPCODE_PRINT:
+ {
+ if (inst->SrcReg[0].File != -1) {
+ GLfloat a[4];
+ fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a);
+ _mesa_printf("%s%g, %g, %g, %g\n", (const char *) inst->Data,
+ a[0], a[1], a[2], a[3]);
+ }
+ else {
+ _mesa_printf("%s\n", (const char *) inst->Data);
+ }
+ }
+ break;
+ case FP_OPCODE_END:
+ return GL_TRUE;
+ default:
+ _mesa_problem(ctx, "Bad opcode %d in _mesa_exec_fragment_program",
+ inst->Opcode);
+ return GL_TRUE; /* return value doesn't matter */
+ }
+ }
+ return GL_TRUE;
+}
+
+
+static void
+init_machine( GLcontext *ctx, struct fp_machine *machine,
+ const struct fragment_program *program,
+ const struct sw_span *span, GLuint col )
+{
+ GLuint inputsRead = program->InputsRead;
+ GLuint u;
+
+ if (ctx->FragmentProgram.CallbackEnabled)
+ inputsRead = ~0;
+
+ if (program->Base.Target == GL_FRAGMENT_PROGRAM_NV) {
+ /* Clear temporary registers (undefined for ARB_f_p) */
+ _mesa_bzero(machine->Temporaries,
+ MAX_NV_FRAGMENT_PROGRAM_TEMPS * 4 * sizeof(GLfloat));
+ }
+
+ /* Load input registers */
+ if (inputsRead & (1 << FRAG_ATTRIB_WPOS)) {
+ GLfloat *wpos = machine->Inputs[FRAG_ATTRIB_WPOS];
+ ASSERT(span->arrayMask & SPAN_Z);
+ wpos[0] = (GLfloat) span->x + col;
+ wpos[1] = (GLfloat) span->y;
+ wpos[2] = (GLfloat) span->array->z[col] / ctx->DrawBuffer->_DepthMaxF;
+ wpos[3] = span->w + col * span->dwdx;
+ }
+ if (inputsRead & (1 << FRAG_ATTRIB_COL0)) {
+ GLfloat *col0 = machine->Inputs[FRAG_ATTRIB_COL0];
+ ASSERT(span->arrayMask & SPAN_RGBA);
+ col0[0] = CHAN_TO_FLOAT(span->array->rgba[col][RCOMP]);
+ col0[1] = CHAN_TO_FLOAT(span->array->rgba[col][GCOMP]);
+ col0[2] = CHAN_TO_FLOAT(span->array->rgba[col][BCOMP]);
+ col0[3] = CHAN_TO_FLOAT(span->array->rgba[col][ACOMP]);
+ }
+ if (inputsRead & (1 << FRAG_ATTRIB_COL1)) {
+ GLfloat *col1 = machine->Inputs[FRAG_ATTRIB_COL1];
+ col1[0] = CHAN_TO_FLOAT(span->array->spec[col][RCOMP]);
+ col1[1] = CHAN_TO_FLOAT(span->array->spec[col][GCOMP]);
+ col1[2] = CHAN_TO_FLOAT(span->array->spec[col][BCOMP]);
+ col1[3] = CHAN_TO_FLOAT(span->array->spec[col][ACOMP]);
+ }
+ if (inputsRead & (1 << FRAG_ATTRIB_FOGC)) {
+ GLfloat *fogc = machine->Inputs[FRAG_ATTRIB_FOGC];
+ ASSERT(span->arrayMask & SPAN_FOG);
+ fogc[0] = span->array->fog[col];
+ fogc[1] = 0.0F;
+ fogc[2] = 0.0F;
+ fogc[3] = 0.0F;
+ }
+ for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
+ if (inputsRead & (1 << (FRAG_ATTRIB_TEX0 + u))) {
+ GLfloat *tex = machine->Inputs[FRAG_ATTRIB_TEX0 + u];
+ /*ASSERT(ctx->Texture._EnabledCoordUnits & (1 << u));*/
+ COPY_4V(tex, span->array->texcoords[u][col]);
+ /*ASSERT(tex[0] != 0 || tex[1] != 0 || tex[2] != 0);*/
+ }
+ }
+
+ /* init condition codes */
+ machine->CondCodes[0] = COND_EQ;
+ machine->CondCodes[1] = COND_EQ;
+ machine->CondCodes[2] = COND_EQ;
+ machine->CondCodes[3] = COND_EQ;
+}
+
+
+
+/**
+ * Execute the current fragment program, operating on the given span.
+ */
+void
+_swrast_exec_fragment_program( GLcontext *ctx, struct sw_span *span )
+{
+ const struct fragment_program *program = ctx->FragmentProgram._Current;
+ GLuint i;
+
+ ctx->_CurrentProgram = GL_FRAGMENT_PROGRAM_ARB; /* or NV, doesn't matter */
+
+ if (program->Parameters) {
+ _mesa_load_state_parameters(ctx, program->Parameters);
+ }
+
+ for (i = 0; i < span->end; i++) {
+ if (span->array->mask[i]) {
+ init_machine(ctx, &ctx->FragmentProgram.Machine,
+ ctx->FragmentProgram._Current, span, i);
+
+#ifdef USE_TCC
+ if (!_swrast_execute_codegen_program(ctx, program, ~0,
+ &ctx->FragmentProgram.Machine,
+ span, i)) {
+ span->array->mask[i] = GL_FALSE; /* killed fragment */
+ span->writeAll = GL_FALSE;
+ }
+#else
+ if (!execute_program(ctx, program, ~0,
+ &ctx->FragmentProgram.Machine, span, i)) {
+ span->array->mask[i] = GL_FALSE; /* killed fragment */
+ span->writeAll = GL_FALSE;
+ }
+#endif
+
+ /* Store output registers */
+ {
+ const GLfloat *colOut
+ = ctx->FragmentProgram.Machine.Outputs[FRAG_OUTPUT_COLR];
+ UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][RCOMP], colOut[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][GCOMP], colOut[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][BCOMP], colOut[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(span->array->rgba[i][ACOMP], colOut[3]);
+ }
+ /* depth value */
+ if (program->OutputsWritten & (1 << FRAG_OUTPUT_DEPR)) {
+ const GLfloat depth
+ = ctx->FragmentProgram.Machine.Outputs[FRAG_OUTPUT_DEPR][2];
+ span->array->z[i] = IROUND(depth * ctx->DrawBuffer->_DepthMaxF);
+ }
+ }
+ }
+
+ if (program->OutputsWritten & (1 << FRAG_OUTPUT_DEPR)) {
+ span->interpMask &= ~SPAN_Z;
+ span->arrayMask |= SPAN_Z;
+ }
+
+ ctx->_CurrentProgram = 0;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_nvfragprog.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_nvfragprog.h
new file mode 100644
index 000000000..ac5a15fe9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_nvfragprog.h
@@ -0,0 +1,37 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_NVFRAGPROG_H
+#define S_NVFRAGPROG_H
+
+
+#include "s_context.h"
+
+
+extern void
+_swrast_exec_fragment_program( GLcontext *ctx, struct sw_span *span );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_pixeltex.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_pixeltex.c
new file mode 100644
index 000000000..1c65290d4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_pixeltex.c
@@ -0,0 +1,111 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+/*
+ * This file implements both the GL_SGIX_pixel_texture and
+ * GL_SIGS_pixel_texture extensions. Luckily, they pretty much
+ * overlap in functionality so we use the same state variables
+ * and execution code for both.
+ */
+
+
+#include "glheader.h"
+#include "colormac.h"
+#include "imports.h"
+
+#include "s_context.h"
+#include "s_pixeltex.h"
+#include "s_texture.h"
+
+
+/*
+ * Convert RGBA values into strq texture coordinates.
+ */
+static void
+pixeltexgen(GLcontext *ctx, GLuint n, const GLchan rgba[][4],
+ GLfloat texcoord[][4])
+{
+ if (ctx->Pixel.FragmentRgbSource == GL_CURRENT_RASTER_COLOR) {
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ texcoord[i][0] = ctx->Current.RasterColor[RCOMP];
+ texcoord[i][1] = ctx->Current.RasterColor[GCOMP];
+ texcoord[i][2] = ctx->Current.RasterColor[BCOMP];
+ }
+ }
+ else {
+ GLuint i;
+ ASSERT(ctx->Pixel.FragmentRgbSource == GL_PIXEL_GROUP_COLOR_SGIS);
+ for (i = 0; i < n; i++) {
+ texcoord[i][0] = CHAN_TO_FLOAT(rgba[i][RCOMP]);
+ texcoord[i][1] = CHAN_TO_FLOAT(rgba[i][GCOMP]);
+ texcoord[i][2] = CHAN_TO_FLOAT(rgba[i][BCOMP]);
+ }
+ }
+
+ if (ctx->Pixel.FragmentAlphaSource == GL_CURRENT_RASTER_COLOR) {
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ texcoord[i][3] = ctx->Current.RasterColor[ACOMP];
+ }
+ }
+ else {
+ GLuint i;
+ ASSERT(ctx->Pixel.FragmentAlphaSource == GL_PIXEL_GROUP_COLOR_SGIS);
+ for (i = 0; i < n; i++) {
+ texcoord[i][3] = CHAN_TO_FLOAT(rgba[i][ACOMP]);
+ }
+ }
+}
+
+
+
+/*
+ * Used by glDraw/CopyPixels: the incoming image colors are treated
+ * as texture coordinates. Use those coords to texture the image.
+ * This is for GL_SGIS_pixel_texture / GL_SGIX_pixel_texture.
+ */
+void
+_swrast_pixel_texture(GLcontext *ctx, struct sw_span *span)
+{
+ GLuint unit;
+
+ ASSERT(!(span->arrayMask & SPAN_TEXTURE));
+ span->arrayMask |= SPAN_TEXTURE;
+ span->interpMask &= ~SPAN_TEXTURE;
+
+ /* convert colors into texture coordinates */
+ pixeltexgen( ctx, span->end,
+ (const GLchan (*)[4]) span->array->rgba,
+ span->array->texcoords[0] );
+
+ /* copy the new texture units for all enabled units */
+ for (unit = 1; unit < ctx->Const.MaxTextureUnits; unit++) {
+ if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+ MEMCPY( span->array->texcoords[unit], span->array->texcoords[0],
+ span->end * 4 * sizeof(GLfloat) );
+ }
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_pixeltex.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_pixeltex.h
new file mode 100644
index 000000000..6ef7a44df
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_pixeltex.h
@@ -0,0 +1,38 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_PIXELTEX_H
+#define S_PIXELTEX_H
+
+#include "mtypes.h"
+#include "swrast.h"
+
+
+extern void
+_swrast_pixel_texture(GLcontext *ctx, struct sw_span *span);
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_points.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_points.c
new file mode 100644
index 000000000..5879bccf1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_points.c
@@ -0,0 +1,275 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "macros.h"
+#include "texstate.h"
+#include "s_context.h"
+#include "s_feedback.h"
+#include "s_points.h"
+#include "s_span.h"
+
+
+
+#define RGBA 0x1
+#define INDEX 0x2
+#define SMOOTH 0x4
+#define TEXTURE 0x8
+#define SPECULAR 0x10
+#define LARGE 0x20
+#define ATTENUATE 0x40
+#define SPRITE 0x80
+
+
+/*
+ * CI points with size == 1.0
+ */
+#define FLAGS (INDEX)
+#define NAME size1_ci_point
+#include "s_pointtemp.h"
+
+
+/*
+ * General CI points.
+ */
+#define FLAGS (INDEX | LARGE)
+#define NAME general_ci_point
+#include "s_pointtemp.h"
+
+
+/*
+ * Antialiased CI points.
+ */
+#define FLAGS (INDEX | SMOOTH)
+#define NAME antialiased_ci_point
+#include "s_pointtemp.h"
+
+
+/*
+ * Distance attenuated, general CI points.
+ */
+#define FLAGS (INDEX | ATTENUATE)
+#define NAME atten_general_ci_point
+#include "s_pointtemp.h"
+
+
+/*
+ * RGBA points with size == 1.0
+ */
+#define FLAGS (RGBA)
+#define NAME size1_rgba_point
+#include "s_pointtemp.h"
+
+
+/*
+ * General RGBA points.
+ */
+#define FLAGS (RGBA | LARGE)
+#define NAME general_rgba_point
+#include "s_pointtemp.h"
+
+
+/*
+ * Antialiased RGBA points.
+ */
+#define FLAGS (RGBA | SMOOTH)
+#define NAME antialiased_rgba_point
+#include "s_pointtemp.h"
+
+
+/*
+ * Textured RGBA points.
+ */
+#define FLAGS (RGBA | LARGE | TEXTURE | SPECULAR)
+#define NAME textured_rgba_point
+#include "s_pointtemp.h"
+
+
+/*
+ * Antialiased points with texture mapping.
+ */
+#define FLAGS (RGBA | SMOOTH | TEXTURE | SPECULAR)
+#define NAME antialiased_tex_rgba_point
+#include "s_pointtemp.h"
+
+
+/*
+ * Distance attenuated, general RGBA points.
+ */
+#define FLAGS (RGBA | ATTENUATE)
+#define NAME atten_general_rgba_point
+#include "s_pointtemp.h"
+
+
+/*
+ * Distance attenuated, textured RGBA points.
+ */
+#define FLAGS (RGBA | ATTENUATE | TEXTURE | SPECULAR)
+#define NAME atten_textured_rgba_point
+#include "s_pointtemp.h"
+
+
+/*
+ * Distance attenuated, antialiased points with or without texture mapping.
+ */
+#define FLAGS (RGBA | ATTENUATE | TEXTURE | SMOOTH)
+#define NAME atten_antialiased_rgba_point
+#include "s_pointtemp.h"
+
+
+/*
+ * Sprite (textured point)
+ */
+#define FLAGS (RGBA | SPRITE | SPECULAR)
+#define NAME sprite_point
+#include "s_pointtemp.h"
+
+
+#define FLAGS (RGBA | SPRITE | SPECULAR | ATTENUATE)
+#define NAME atten_sprite_point
+#include "s_pointtemp.h"
+
+
+
+void _swrast_add_spec_terms_point( GLcontext *ctx,
+ const SWvertex *v0 )
+{
+ SWvertex *ncv0 = (SWvertex *)v0;
+ GLchan c[1][4];
+ COPY_CHAN4( c[0], ncv0->color );
+ ACC_3V( ncv0->color, ncv0->specular );
+ SWRAST_CONTEXT(ctx)->SpecPoint( ctx, ncv0 );
+ COPY_CHAN4( ncv0->color, c[0] );
+}
+
+
+
+/* record the current point function name */
+#ifdef DEBUG
+
+static const char *pntFuncName = NULL;
+
+#define USE(pntFunc) \
+do { \
+ pntFuncName = #pntFunc; \
+ /*printf("%s\n", pntFuncName);*/ \
+ swrast->Point = pntFunc; \
+} while (0)
+
+#else
+
+#define USE(pntFunc) swrast->Point = pntFunc
+
+#endif
+
+
+/*
+ * Examine the current context to determine which point drawing function
+ * should be used.
+ */
+void
+_swrast_choose_point( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLboolean rgbMode = ctx->Visual.rgbMode;
+
+ if (ctx->RenderMode==GL_RENDER) {
+ if (ctx->Point.PointSprite) {
+ /* GL_ARB_point_sprite / GL_NV_point_sprite */
+ /* XXX this might not be good enough */
+ if (ctx->Point._Attenuated)
+ USE(atten_sprite_point);
+ else
+ USE(sprite_point);
+ }
+ else if (ctx->Point.SmoothFlag) {
+ /* Smooth points */
+ if (rgbMode) {
+ if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
+ USE(atten_antialiased_rgba_point);
+ }
+ else if (ctx->Texture._EnabledCoordUnits) {
+ USE(antialiased_tex_rgba_point);
+ }
+ else {
+ USE(antialiased_rgba_point);
+ }
+ }
+ else {
+ USE(antialiased_ci_point);
+ }
+ }
+ else if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) {
+ if (rgbMode) {
+ if (ctx->Texture._EnabledCoordUnits) {
+ if (ctx->Point.SmoothFlag) {
+ USE(atten_antialiased_rgba_point);
+ }
+ else {
+ USE(atten_textured_rgba_point);
+ }
+ }
+ else {
+ USE(atten_general_rgba_point);
+ }
+ }
+ else {
+ /* ci, atten */
+ USE(atten_general_ci_point);
+ }
+ }
+ else if (ctx->Texture._EnabledCoordUnits && rgbMode) {
+ /* textured */
+ USE(textured_rgba_point);
+ }
+ else if (ctx->Point._Size != 1.0) {
+ /* large points */
+ if (rgbMode) {
+ USE(general_rgba_point);
+ }
+ else {
+ USE(general_ci_point);
+ }
+ }
+ else {
+ /* single pixel points */
+ if (rgbMode) {
+ USE(size1_rgba_point);
+ }
+ else {
+ USE(size1_ci_point);
+ }
+ }
+ }
+ else if (ctx->RenderMode==GL_FEEDBACK) {
+ USE(_swrast_feedback_point);
+ }
+ else {
+ /* GL_SELECT mode */
+ USE(_swrast_select_point);
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_points.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_points.h
new file mode 100644
index 000000000..40b442e95
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_points.h
@@ -0,0 +1,39 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_POINTS_H
+#define S_POINTS_H
+
+#include "mtypes.h"
+
+extern void
+_swrast_choose_point( GLcontext *ctx );
+
+extern void
+_swrast_add_spec_terms_point( GLcontext *ctx,
+ const SWvertex *v0 );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_pointtemp.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_pointtemp.h
new file mode 100644
index 000000000..4ce261009
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_pointtemp.h
@@ -0,0 +1,419 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Regarding GL_NV_point_sprite:
+ *
+ * Portions of this software may use or implement intellectual
+ * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims
+ * any and all warranties with respect to such intellectual property,
+ * including any use thereof or modifications thereto.
+ */
+
+
+/*
+ * Point rendering template code.
+ *
+ * Set FLAGS = bitwise-OR of the following tokens:
+ *
+ * RGBA = do rgba instead of color index
+ * SMOOTH = do antialiasing
+ * TEXTURE = do texture coords
+ * SPECULAR = do separate specular color
+ * LARGE = do points with diameter > 1 pixel
+ * ATTENUATE = compute point size attenuation
+ * SPRITE = GL_ARB_point_sprite / GL_NV_point_sprite
+ *
+ * Notes: LARGE and ATTENUATE are exclusive of each other.
+ * TEXTURE requires RGBA
+ */
+
+
+/*
+ * NOTES on antialiased point rasterization:
+ *
+ * Let d = distance of fragment center from vertex.
+ * if d < rmin2 then
+ * fragment has 100% coverage
+ * else if d > rmax2 then
+ * fragment has 0% coverage
+ * else
+ * fragment has % coverage = (d - rmin2) / (rmax2 - rmin2)
+ */
+
+
+
+static void
+NAME ( GLcontext *ctx, const SWvertex *vert )
+{
+#if FLAGS & (ATTENUATE | LARGE | SMOOTH | SPRITE)
+ GLfloat size;
+#endif
+#if FLAGS & RGBA
+#if (FLAGS & ATTENUATE) && (FLAGS & SMOOTH)
+ GLfloat alphaAtten;
+#endif
+ const GLchan red = vert->color[0];
+ const GLchan green = vert->color[1];
+ const GLchan blue = vert->color[2];
+ const GLchan alpha = vert->color[3];
+#endif
+#if FLAGS & SPECULAR
+ const GLchan specRed = vert->specular[0];
+ const GLchan specGreen = vert->specular[1];
+ const GLchan specBlue = vert->specular[2];
+#endif
+#if FLAGS & INDEX
+ const GLuint colorIndex = (GLuint) vert->index; /* XXX round? */
+#endif
+#if FLAGS & TEXTURE
+ GLfloat texcoord[MAX_TEXTURE_COORD_UNITS][4];
+ GLuint u;
+#endif
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct sw_span *span = &(swrast->PointSpan);
+
+ /* Cull primitives with malformed coordinates.
+ */
+ {
+ float tmp = vert->win[0] + vert->win[1];
+ if (IS_INF_OR_NAN(tmp))
+ return;
+ }
+
+ /*
+ * Span init
+ */
+ span->interpMask = SPAN_FOG;
+ span->arrayMask = SPAN_XY | SPAN_Z;
+ span->fog = vert->fog;
+ span->fogStep = 0.0;
+#if FLAGS & RGBA
+ span->arrayMask |= SPAN_RGBA;
+#endif
+#if FLAGS & SPECULAR
+ span->arrayMask |= SPAN_SPEC;
+#endif
+#if FLAGS & INDEX
+ span->arrayMask |= SPAN_INDEX;
+#endif
+#if FLAGS & TEXTURE
+ span->arrayMask |= SPAN_TEXTURE;
+ if (ctx->FragmentProgram._Active) {
+ /* Don't divide texture s,t,r by q (use TXP to do that) */
+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
+ if (ctx->Texture._EnabledCoordUnits & (1 << u)) {
+ COPY_4V(texcoord[u], vert->texcoord[u]);
+ }
+ }
+ }
+ else {
+ /* Divide texture s,t,r by q here */
+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
+ if (ctx->Texture._EnabledCoordUnits & (1 << u)) {
+ const GLfloat q = vert->texcoord[u][3];
+ const GLfloat invQ = (q == 0.0F || q == 1.0F) ? 1.0F : (1.0F / q);
+ texcoord[u][0] = vert->texcoord[u][0] * invQ;
+ texcoord[u][1] = vert->texcoord[u][1] * invQ;
+ texcoord[u][2] = vert->texcoord[u][2] * invQ;
+ texcoord[u][3] = q;
+ }
+ }
+ }
+ /* need these for fragment programs */
+ span->w = 1.0F;
+ span->dwdx = 0.0F;
+ span->dwdy = 0.0F;
+#endif
+#if FLAGS & SMOOTH
+ span->arrayMask |= SPAN_COVERAGE;
+#endif
+#if FLAGS & SPRITE
+ span->arrayMask |= SPAN_TEXTURE;
+#endif
+
+ /* Compute point size if not known to be one */
+#if FLAGS & ATTENUATE
+ /* first, clamp attenuated size to the user-specifed range */
+ size = CLAMP(vert->pointSize, ctx->Point.MinSize, ctx->Point.MaxSize);
+#if (FLAGS & RGBA) && (FLAGS & SMOOTH)
+ /* only if multisampling, compute the fade factor */
+ if (ctx->Multisample.Enabled) {
+ if (vert->pointSize >= ctx->Point.Threshold) {
+ alphaAtten = 1.0F;
+ }
+ else {
+ GLfloat dsize = vert->pointSize / ctx->Point.Threshold;
+ alphaAtten = dsize * dsize;
+ }
+ }
+ else {
+ alphaAtten = 1.0;
+ }
+#endif
+#elif FLAGS & (LARGE | SMOOTH | SPRITE)
+ /* constant, non-attenuated size */
+ size = ctx->Point._Size; /* this is already clamped */
+#endif
+
+
+#if FLAGS & (ATTENUATE | LARGE | SMOOTH | SPRITE)
+ /***
+ *** Multi-pixel points
+ ***/
+
+ /* do final clamping now */
+ if (ctx->Point.SmoothFlag) {
+ size = CLAMP(size, ctx->Const.MinPointSizeAA, ctx->Const.MaxPointSizeAA);
+ }
+ else {
+ size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize);
+ }
+
+ {{
+ GLint x, y;
+ const GLfloat radius = 0.5F * size;
+ const GLint z = (GLint) (vert->win[2] + 0.5F);
+ GLuint count;
+#if FLAGS & SMOOTH
+ const GLfloat rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */
+ const GLfloat rmax = radius + 0.7071F;
+ const GLfloat rmin2 = MAX2(0.0F, rmin * rmin);
+ const GLfloat rmax2 = rmax * rmax;
+ const GLfloat cscale = 1.0F / (rmax2 - rmin2);
+ const GLint xmin = (GLint) (vert->win[0] - radius);
+ const GLint xmax = (GLint) (vert->win[0] + radius);
+ const GLint ymin = (GLint) (vert->win[1] - radius);
+ const GLint ymax = (GLint) (vert->win[1] + radius);
+#else
+ /* non-smooth */
+ GLint xmin, xmax, ymin, ymax;
+ GLint iSize = (GLint) (size + 0.5F);
+ GLint iRadius;
+ iSize = MAX2(1, iSize);
+ iRadius = iSize / 2;
+ if (iSize & 1) {
+ /* odd size */
+ xmin = (GLint) (vert->win[0] - iRadius);
+ xmax = (GLint) (vert->win[0] + iRadius);
+ ymin = (GLint) (vert->win[1] - iRadius);
+ ymax = (GLint) (vert->win[1] + iRadius);
+ }
+ else {
+ /* even size */
+ xmin = (GLint) vert->win[0] - iRadius + 1;
+ xmax = xmin + iSize - 1;
+ ymin = (GLint) vert->win[1] - iRadius + 1;
+ ymax = ymin + iSize - 1;
+ }
+#endif /*SMOOTH*/
+
+ /* check if we need to flush */
+ if (span->end + (xmax-xmin+1) * (ymax-ymin+1) >= MAX_WIDTH ||
+ (swrast->_RasterMask & (BLEND_BIT | LOGIC_OP_BIT | MASKING_BIT))) {
+#if FLAGS & RGBA
+ _swrast_write_rgba_span(ctx, span);
+#else
+ _swrast_write_index_span(ctx, span);
+#endif
+ span->end = 0;
+ }
+
+ /*
+ * OK, generate fragments
+ */
+ count = span->end;
+ (void) radius;
+ for (y = ymin; y <= ymax; y++) {
+ /* check if we need to flush */
+ if (count + (xmax-xmin+1) >= MAX_WIDTH) {
+ span->end = count;
+#if FLAGS & RGBA
+ _swrast_write_rgba_span(ctx, span);
+#else
+ _swrast_write_index_span(ctx, span);
+#endif
+ count = span->end = 0;
+ }
+ for (x = xmin; x <= xmax; x++) {
+#if FLAGS & (SPRITE | TEXTURE)
+ GLuint u;
+#endif
+
+#if FLAGS & RGBA
+ span->array->rgba[count][RCOMP] = red;
+ span->array->rgba[count][GCOMP] = green;
+ span->array->rgba[count][BCOMP] = blue;
+ span->array->rgba[count][ACOMP] = alpha;
+#endif
+#if FLAGS & SPECULAR
+ span->array->spec[count][RCOMP] = specRed;
+ span->array->spec[count][GCOMP] = specGreen;
+ span->array->spec[count][BCOMP] = specBlue;
+#endif
+#if FLAGS & INDEX
+ span->array->index[count] = colorIndex;
+#endif
+#if FLAGS & TEXTURE
+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
+ if (ctx->Texture._EnabledCoordUnits & (1 << u)) {
+ COPY_4V(span->array->texcoords[u][count], texcoord[u]);
+ }
+ }
+#endif
+
+#if FLAGS & SMOOTH
+ /* compute coverage */
+ {
+ const GLfloat dx = x - vert->win[0] + 0.5F;
+ const GLfloat dy = y - vert->win[1] + 0.5F;
+ const GLfloat dist2 = dx * dx + dy * dy;
+ if (dist2 < rmax2) {
+ if (dist2 >= rmin2) {
+ /* compute partial coverage */
+ span->array->coverage[count] = 1.0F - (dist2 - rmin2) * cscale;
+#if FLAGS & INDEX
+ /* coverage in [0,15] */
+ span->array->coverage[count] *= 15.0;
+#endif
+ }
+ else {
+ /* full coverage */
+ span->array->coverage[count] = 1.0F;
+ }
+
+ span->array->x[count] = x;
+ span->array->y[count] = y;
+ span->array->z[count] = z;
+
+#if (FLAGS & ATTENUATE) && (FLAGS & RGBA)
+ span->array->rgba[count][ACOMP] = (GLchan) (alpha * alphaAtten);
+#elif FLAGS & RGBA
+ span->array->rgba[count][ACOMP] = alpha;
+#endif /*ATTENUATE*/
+ count++;
+ } /*if*/
+ }
+
+#else /*SMOOTH*/
+
+ /* not smooth (square points) */
+ span->array->x[count] = x;
+ span->array->y[count] = y;
+ span->array->z[count] = z;
+
+#if FLAGS & SPRITE
+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
+ if (ctx->Texture.Unit[u]._ReallyEnabled) {
+ if (ctx->Point.CoordReplace[u]) {
+ GLfloat s = 0.5F + (x + 0.5F - vert->win[0]) / size;
+ GLfloat t, r;
+ if (ctx->Point.SpriteOrigin == GL_LOWER_LEFT)
+ t = 0.5F + (y + 0.5F - vert->win[1]) / size;
+ else /* GL_UPPER_LEFT */
+ t = 0.5F - (y + 0.5F - vert->win[1]) / size;
+ if (ctx->Point.SpriteRMode == GL_ZERO)
+ r = 0.0F;
+ else if (ctx->Point.SpriteRMode == GL_S)
+ r = vert->texcoord[u][0];
+ else /* GL_R */
+ r = vert->texcoord[u][2];
+ span->array->texcoords[u][count][0] = s;
+ span->array->texcoords[u][count][1] = t;
+ span->array->texcoords[u][count][2] = r;
+ span->array->texcoords[u][count][3] = 1.0F;
+ }
+ else {
+ COPY_4V(span->array->texcoords[u][count], vert->texcoord[u]);
+ }
+ }
+ }
+#endif /*SPRITE*/
+
+ count++; /* square point */
+
+#endif /*SMOOTH*/
+
+ } /*for x*/
+ } /*for y*/
+ span->end = count;
+ }}
+
+#else /* LARGE | ATTENUATE | SMOOTH | SPRITE */
+
+ /***
+ *** Single-pixel points
+ ***/
+ {{
+ GLuint count;
+
+ /* check if we need to flush */
+ if (span->end >= MAX_WIDTH ||
+ (swrast->_RasterMask & (BLEND_BIT | LOGIC_OP_BIT | MASKING_BIT))) {
+#if FLAGS & RGBA
+ _swrast_write_rgba_span(ctx, span);
+#else
+ _swrast_write_index_span(ctx, span);
+#endif
+ span->end = 0;
+ }
+
+ count = span->end;
+
+#if FLAGS & RGBA
+ span->array->rgba[count][RCOMP] = red;
+ span->array->rgba[count][GCOMP] = green;
+ span->array->rgba[count][BCOMP] = blue;
+ span->array->rgba[count][ACOMP] = alpha;
+#endif
+#if FLAGS & SPECULAR
+ span->array->spec[count][RCOMP] = specRed;
+ span->array->spec[count][GCOMP] = specGreen;
+ span->array->spec[count][BCOMP] = specBlue;
+#endif
+#if FLAGS & INDEX
+ span->array->index[count] = colorIndex;
+#endif
+#if FLAGS & TEXTURE
+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
+ if (ctx->Texture.Unit[u]._ReallyEnabled) {
+ COPY_4V(span->array->texcoords[u][count], texcoord[u]);
+ }
+ }
+#endif
+
+ span->array->x[count] = (GLint) vert->win[0];
+ span->array->y[count] = (GLint) vert->win[1];
+ span->array->z[count] = (GLint) (vert->win[2] + 0.5F);
+ span->end = count + 1;
+ }}
+
+#endif /* LARGE || ATTENUATE || SMOOTH */
+
+ ASSERT(span->end <= MAX_WIDTH);
+}
+
+
+#undef FLAGS
+#undef NAME
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_readpix.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_readpix.c
new file mode 100644
index 000000000..dda35044a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_readpix.c
@@ -0,0 +1,584 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4.1
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "bufferobj.h"
+#include "colormac.h"
+#include "convolve.h"
+#include "context.h"
+#include "feedback.h"
+#include "image.h"
+#include "macros.h"
+#include "imports.h"
+#include "pixel.h"
+
+#include "s_context.h"
+#include "s_depth.h"
+#include "s_span.h"
+#include "s_stencil.h"
+
+
+
+/*
+ * Read a block of color index pixels.
+ */
+static void
+read_index_pixels( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum type, GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing )
+{
+ struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
+ /*
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ */
+ GLint i, readWidth;
+
+ /* error checking */
+ if (ctx->Visual.rgbMode) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glReadPixels" );
+ return;
+ }
+
+ if (type != GL_BYTE &&
+ type != GL_UNSIGNED_BYTE &&
+ type != GL_SHORT &&
+ type != GL_UNSIGNED_SHORT &&
+ type != GL_INT &&
+ type != GL_UNSIGNED_INT &&
+ type != GL_FLOAT) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glReadPixels(index type)");
+ return;
+ }
+
+ _swrast_use_read_buffer(ctx);
+
+ /* XXX: width should never be > MAX_WIDTH since we did clipping earlier */
+ readWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
+
+ /* process image row by row */
+ for (i = 0; i < height; i++) {
+ GLuint index[MAX_WIDTH];
+ GLvoid *dest;
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ rb->GetRow(ctx, rb, readWidth, x, y + i, index);
+
+ dest = _mesa_image_address2d(packing, pixels, width, height,
+ GL_COLOR_INDEX, type, i, 0);
+
+ _mesa_pack_index_span(ctx, readWidth, type, dest, index,
+ &ctx->Pack, ctx->_ImageTransferState);
+ }
+
+ _swrast_use_draw_buffer(ctx);
+}
+
+
+
+/**
+ * Read pixels for format=GL_DEPTH_COMPONENT.
+ */
+static void
+read_depth_pixels( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum type, GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing )
+{
+ struct gl_renderbuffer *rb
+ = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+ GLint readWidth;
+ GLboolean bias_or_scale;
+
+ /* Error checking */
+ if (ctx->ReadBuffer->Visual.depthBits <= 0 || !rb) {
+ /* No depth buffer */
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glReadPixels" );
+ return;
+ }
+
+ if (type != GL_BYTE &&
+ type != GL_UNSIGNED_BYTE &&
+ type != GL_SHORT &&
+ type != GL_UNSIGNED_SHORT &&
+ type != GL_INT &&
+ type != GL_UNSIGNED_INT &&
+ type != GL_FLOAT) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glReadPixels(depth type)");
+ return;
+ }
+
+ /* XXX: width should never be > MAX_WIDTH since we did clipping earlier */
+ readWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
+
+ bias_or_scale = ctx->Pixel.DepthBias!=0.0 || ctx->Pixel.DepthScale!=1.0;
+
+ if (type==GL_UNSIGNED_SHORT && ctx->ReadBuffer->Visual.depthBits == 16
+ && !bias_or_scale && !packing->SwapBytes) {
+ /* Special case: directly read 16-bit unsigned depth values. */
+ GLint j;
+ for (j=0;j<height;j++,y++) {
+ GLdepth depth[MAX_WIDTH];
+ GLushort *dst = (GLushort*) _mesa_image_address2d(packing, pixels,
+ width, height, GL_DEPTH_COMPONENT, type, j, 0);
+ GLint i;
+ _swrast_read_depth_span(ctx, rb, width, x, y, depth);
+ for (i = 0; i < width; i++)
+ dst[i] = depth[i];
+ }
+ }
+ else if (type==GL_UNSIGNED_INT && ctx->ReadBuffer->Visual.depthBits == 32
+ && !bias_or_scale && !packing->SwapBytes) {
+ /* Special case: directly read 32-bit unsigned depth values. */
+ GLint j;
+ for (j=0;j<height;j++,y++) {
+ GLdepth *dst = (GLdepth *) _mesa_image_address2d(packing, pixels,
+ width, height, GL_DEPTH_COMPONENT, type, j, 0);
+ _swrast_read_depth_span(ctx, rb, width, x, y, dst);
+ }
+ }
+ else {
+ /* General case (slower) */
+ GLint j;
+ for (j=0;j<height;j++,y++) {
+ GLfloat depth[MAX_WIDTH];
+ GLvoid *dest;
+
+ _swrast_read_depth_span_float(ctx, rb, readWidth, x, y, depth);
+
+ dest = _mesa_image_address2d(packing, pixels, width, height,
+ GL_DEPTH_COMPONENT, type, j, 0);
+
+ _mesa_pack_depth_span(ctx, readWidth, (GLdepth *) dest, type,
+ depth, packing);
+ }
+ }
+}
+
+
+/**
+ * Read pixels for format=GL_STENCIL_INDEX.
+ */
+static void
+read_stencil_pixels( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum type, GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing )
+{
+ struct gl_renderbuffer *rb
+ = ctx->ReadBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
+ GLint j, readWidth;
+
+ if (type != GL_BYTE &&
+ type != GL_UNSIGNED_BYTE &&
+ type != GL_SHORT &&
+ type != GL_UNSIGNED_SHORT &&
+ type != GL_INT &&
+ type != GL_UNSIGNED_INT &&
+ type != GL_FLOAT &&
+ type != GL_BITMAP) {
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glReadPixels(stencil type)");
+ return;
+ }
+
+ if (ctx->ReadBuffer->Visual.stencilBits <= 0 || !rb) {
+ /* No stencil buffer */
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glReadPixels" );
+ return;
+ }
+
+ /* XXX: width should never be > MAX_WIDTH since we did clipping earlier */
+ readWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
+
+ /* process image row by row */
+ for (j=0;j<height;j++,y++) {
+ GLvoid *dest;
+ GLstencil stencil[MAX_WIDTH];
+
+ _swrast_read_stencil_span(ctx, rb, readWidth, x, y, stencil);
+
+ dest = _mesa_image_address2d(packing, pixels, width, height,
+ GL_STENCIL_INDEX, type, j, 0);
+
+ _mesa_pack_stencil_span(ctx, readWidth, type, dest, stencil, packing);
+ }
+}
+
+
+
+/**
+ * Optimized glReadPixels for particular pixel formats:
+ * GL_UNSIGNED_BYTE, GL_RGBA
+ * when pixel scaling, biasing and mapping are disabled.
+ */
+static GLboolean
+read_fast_rgba_pixels( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing )
+{
+ struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
+ /* can't do scale, bias, mapping, etc */
+ if (ctx->_ImageTransferState)
+ return GL_FALSE;
+
+ /* can't do fancy pixel packing */
+ if (packing->Alignment != 1 || packing->SwapBytes || packing->LsbFirst)
+ return GL_FALSE;
+
+ {
+ GLint srcX = x;
+ GLint srcY = y;
+ GLint readWidth = width; /* actual width read */
+ GLint readHeight = height; /* actual height read */
+ GLint skipPixels = packing->SkipPixels;
+ GLint skipRows = packing->SkipRows;
+ GLint rowLength;
+
+ if (packing->RowLength > 0)
+ rowLength = packing->RowLength;
+ else
+ rowLength = width;
+
+ /*
+ * Ready to read!
+ * The window region at (destX, destY) of size (readWidth, readHeight)
+ * will be read back.
+ * We'll write pixel data to buffer pointed to by "pixels" but we'll
+ * skip "skipRows" rows and skip "skipPixels" pixels/row.
+ */
+#if CHAN_BITS == 8
+ if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) {
+#elif CHAN_BITS == 16
+ if (format == GL_RGBA && type == GL_UNSIGNED_SHORT) {
+#else
+ if (0) {
+#endif
+ GLchan *dest = (GLchan *) pixels
+ + (skipRows * rowLength + skipPixels) * 4;
+ GLint row;
+
+ if (packing->Invert) {
+ /* start at top and go down */
+ dest += (readHeight - 1) * rowLength * 4;
+ rowLength = -rowLength;
+ }
+
+ ASSERT(rb->GetRow);
+ for (row=0; row<readHeight; row++) {
+ rb->GetRow(ctx, rb, readWidth, srcX, srcY, dest);
+ dest += rowLength * 4;
+ srcY++;
+ }
+ return GL_TRUE;
+ }
+ else {
+ /* can't do this format/type combination */
+ return GL_FALSE;
+ }
+ }
+}
+
+
+
+/*
+ * Read R, G, B, A, RGB, L, or LA pixels.
+ */
+static void
+read_rgba_pixels( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type, GLvoid *pixels,
+ const struct gl_pixelstore_attrib *packing )
+{
+ struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
+ GLint readWidth;
+
+ if (!rb) {
+ /* No readbuffer is OK with GL_EXT_framebuffer_object */
+ return;
+ }
+
+ /* do error checking on pixel type, format was already checked by caller */
+ switch (type) {
+ case GL_UNSIGNED_BYTE:
+ case GL_BYTE:
+ case GL_UNSIGNED_SHORT:
+ case GL_SHORT:
+ case GL_UNSIGNED_INT:
+ case GL_INT:
+ case GL_FLOAT:
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ /* valid pixel type */
+ break;
+ case GL_HALF_FLOAT_ARB:
+ if (!ctx->Extensions.ARB_half_float_pixel) {
+ _mesa_error( ctx, GL_INVALID_ENUM, "glReadPixels(type)" );
+ return;
+ }
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glReadPixels(type)" );
+ return;
+ }
+
+ if (!_mesa_is_legal_format_and_type(ctx, format, type) ||
+ format == GL_INTENSITY) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(format or type)");
+ return;
+ }
+
+ _swrast_use_read_buffer(ctx);
+
+ /* Try optimized path first */
+ if (read_fast_rgba_pixels( ctx, x, y, width, height,
+ format, type, pixels, packing )) {
+
+ _swrast_use_draw_buffer(ctx);
+ return; /* done! */
+ }
+
+ /* XXX: width should never be > MAX_WIDTH since we did clipping earlier */
+ readWidth = (width > MAX_WIDTH) ? MAX_WIDTH : width;
+
+
+ if (ctx->Pixel.Convolution2DEnabled || ctx->Pixel.Separable2DEnabled) {
+ const GLuint transferOps = ctx->_ImageTransferState;
+ GLfloat *dest, *src, *tmpImage, *convImage;
+ GLint row;
+
+ tmpImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
+ if (!tmpImage) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels");
+ return;
+ }
+ convImage = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
+ if (!convImage) {
+ _mesa_free(tmpImage);
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glReadPixels");
+ return;
+ }
+
+ /* read full RGBA, FLOAT image */
+ dest = tmpImage;
+ for (row = 0; row < height; row++, y++) {
+ GLchan rgba[MAX_WIDTH][4];
+ if (ctx->Visual.rgbMode) {
+ _swrast_read_rgba_span(ctx, rb, readWidth, x, y, rgba);
+ }
+ else {
+ GLuint index[MAX_WIDTH];
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ rb->GetRow(ctx, rb, readWidth, x, y, index);
+ if (ctx->Pixel.IndexShift != 0 || ctx->Pixel.IndexOffset !=0 ) {
+ _mesa_map_ci(ctx, readWidth, index);
+ }
+ _mesa_map_ci_to_rgba_chan(ctx, readWidth, index, rgba);
+ }
+ _mesa_pack_rgba_span_chan(ctx, readWidth, (const GLchan (*)[4]) rgba,
+ GL_RGBA, GL_FLOAT, dest, &ctx->DefaultPacking,
+ transferOps & IMAGE_PRE_CONVOLUTION_BITS);
+ dest += width * 4;
+ }
+
+ /* do convolution */
+ if (ctx->Pixel.Convolution2DEnabled) {
+ _mesa_convolve_2d_image(ctx, &readWidth, &height, tmpImage, convImage);
+ }
+ else {
+ ASSERT(ctx->Pixel.Separable2DEnabled);
+ _mesa_convolve_sep_image(ctx, &readWidth, &height, tmpImage, convImage);
+ }
+ _mesa_free(tmpImage);
+
+ /* finish transfer ops and pack the resulting image */
+ src = convImage;
+ for (row = 0; row < height; row++) {
+ GLvoid *dest;
+ dest = _mesa_image_address2d(packing, pixels, readWidth, height,
+ format, type, row, 0);
+ _mesa_pack_rgba_span_float(ctx, readWidth,
+ (const GLfloat (*)[4]) src,
+ format, type, dest, packing,
+ transferOps & IMAGE_POST_CONVOLUTION_BITS);
+ src += readWidth * 4;
+ }
+ }
+ else {
+ /* no convolution */
+ GLint row;
+ for (row = 0; row < height; row++, y++) {
+ GLchan rgba[MAX_WIDTH][4];
+ GLvoid *dst;
+ if (ctx->Visual.rgbMode) {
+ _swrast_read_rgba_span(ctx, rb, readWidth, x, y, rgba);
+ }
+ else {
+ GLuint index[MAX_WIDTH];
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ rb->GetRow(ctx, rb, readWidth, x, y, index);
+ if (ctx->Pixel.IndexShift != 0 || ctx->Pixel.IndexOffset != 0) {
+ _mesa_map_ci(ctx, readWidth, index);
+ }
+ _mesa_map_ci_to_rgba_chan(ctx, readWidth, index, rgba);
+ }
+ dst = _mesa_image_address2d(packing, pixels, width, height,
+ format, type, row, 0);
+ if (ctx->Visual.redBits < CHAN_BITS ||
+ ctx->Visual.greenBits < CHAN_BITS ||
+ ctx->Visual.blueBits < CHAN_BITS) {
+ /* Requantize the color values into floating point and go from
+ * there. This fixes conformance failures with 16-bit color
+ * buffers, for example.
+ */
+ DEFMARRAY(GLfloat, rgbaf, MAX_WIDTH, 4); /* mac 32k limitation */
+ CHECKARRAY(rgbaf, return); /* mac 32k limitation */
+ _mesa_chan_to_float_span(ctx, readWidth,
+ (CONST GLchan (*)[4]) rgba, rgbaf);
+ _mesa_pack_rgba_span_float(ctx, readWidth,
+ (CONST GLfloat (*)[4]) rgbaf,
+ format, type, dst, packing,
+ ctx->_ImageTransferState);
+ UNDEFARRAY(rgbaf); /* mac 32k limitation */
+ }
+ else {
+ /* GLubytes are fine */
+ _mesa_pack_rgba_span_chan(ctx, readWidth, (CONST GLchan (*)[4]) rgba,
+ format, type, dst, packing,
+ ctx->_ImageTransferState);
+ }
+ }
+ }
+
+ _swrast_use_draw_buffer(ctx);
+}
+
+
+/**
+ * Software fallback routine for ctx->Driver.ReadPixels().
+ * We wind up using the swrast->ReadSpan() routines to do the job.
+ */
+void
+_swrast_ReadPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *packing,
+ GLvoid *pixels )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ struct gl_pixelstore_attrib clippedPacking;
+
+ if (swrast->NewState)
+ _swrast_validate_derived( ctx );
+
+ /* Do all needed clipping here, so that we can forget about it later */
+ clippedPacking = *packing;
+ if (clippedPacking.RowLength == 0) {
+ clippedPacking.RowLength = width;
+ }
+ if (!_mesa_clip_readpixels(ctx, &x, &y, &width, &height,
+ &clippedPacking.SkipPixels,
+ &clippedPacking.SkipRows)) {
+ /* The ReadPixels region is totally outside the window bounds */
+ return;
+ }
+
+ if (clippedPacking.BufferObj->Name) {
+ /* pack into PBO */
+ GLubyte *buf;
+ if (!_mesa_validate_pbo_access(2, &clippedPacking, width, height, 1,
+ format, type, pixels)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glReadPixels(invalid PBO access)");
+ return;
+ }
+ buf = (GLubyte *) ctx->Driver.MapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ GL_WRITE_ONLY_ARB,
+ clippedPacking.BufferObj);
+ if (!buf) {
+ /* buffer is already mapped - that's an error */
+ _mesa_error(ctx, GL_INVALID_OPERATION, "glReadPixels(PBO is mapped)");
+ return;
+ }
+ pixels = ADD_POINTERS(buf, pixels);
+ }
+
+ RENDER_START(swrast, ctx);
+
+ switch (format) {
+ case GL_COLOR_INDEX:
+ read_index_pixels(ctx, x, y, width, height, type, pixels,
+ &clippedPacking);
+ break;
+ case GL_STENCIL_INDEX:
+ read_stencil_pixels(ctx, x,y, width,height, type, pixels,
+ &clippedPacking);
+ break;
+ case GL_DEPTH_COMPONENT:
+ read_depth_pixels(ctx, x, y, width, height, type, pixels,
+ &clippedPacking);
+ break;
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_RGB:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_RGBA:
+ case GL_BGR:
+ case GL_BGRA:
+ case GL_ABGR_EXT:
+ read_rgba_pixels(ctx, x, y, width, height,
+ format, type, pixels, &clippedPacking);
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glReadPixels(format)" );
+ /* don't return yet, clean-up */
+ }
+
+ RENDER_FINISH(swrast, ctx);
+
+ if (clippedPacking.BufferObj->Name) {
+ /* done with PBO so unmap it now */
+ ctx->Driver.UnmapBuffer(ctx, GL_PIXEL_PACK_BUFFER_EXT,
+ clippedPacking.BufferObj);
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_span.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_span.c
new file mode 100644
index 000000000..47fa02bf1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_span.c
@@ -0,0 +1,1511 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file swrast/s_span.c
+ * \brief Span processing functions used by all rasterization functions.
+ * This is where all the per-fragment tests are performed
+ * \author Brian Paul
+ */
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+
+#include "s_atifragshader.h"
+#include "s_alpha.h"
+#include "s_blend.h"
+#include "s_context.h"
+#include "s_depth.h"
+#include "s_fog.h"
+#include "s_logic.h"
+#include "s_masking.h"
+#include "s_nvfragprog.h"
+#include "s_span.h"
+#include "s_stencil.h"
+#include "s_texture.h"
+
+
+/**
+ * Init span's Z interpolation values to the RasterPos Z.
+ * Used during setup for glDraw/CopyPixels.
+ */
+void
+_swrast_span_default_z( GLcontext *ctx, struct sw_span *span )
+{
+ const GLfloat depthMax = ctx->DrawBuffer->_DepthMaxF;
+ if (ctx->Visual.depthBits <= 16)
+ span->z = FloatToFixed(ctx->Current.RasterPos[2] * depthMax + 0.5F);
+ else
+ span->z = (GLint) (ctx->Current.RasterPos[2] * depthMax + 0.5F);
+ span->zStep = 0;
+ span->interpMask |= SPAN_Z;
+}
+
+
+/**
+ * Init span's fog interpolation values to the RasterPos fog.
+ * Used during setup for glDraw/CopyPixels.
+ */
+void
+_swrast_span_default_fog( GLcontext *ctx, struct sw_span *span )
+{
+ span->fog = _swrast_z_to_fogfactor(ctx, ctx->Current.RasterDistance);
+ span->fogStep = span->dfogdx = span->dfogdy = 0.0F;
+ span->interpMask |= SPAN_FOG;
+}
+
+
+/**
+ * Init span's rgba or index interpolation values to the RasterPos color.
+ * Used during setup for glDraw/CopyPixels.
+ */
+void
+_swrast_span_default_color( GLcontext *ctx, struct sw_span *span )
+{
+ if (ctx->Visual.rgbMode) {
+ GLchan r, g, b, a;
+ UNCLAMPED_FLOAT_TO_CHAN(r, ctx->Current.RasterColor[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(g, ctx->Current.RasterColor[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(b, ctx->Current.RasterColor[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(a, ctx->Current.RasterColor[3]);
+#if CHAN_TYPE == GL_FLOAT
+ span->red = r;
+ span->green = g;
+ span->blue = b;
+ span->alpha = a;
+#else
+ span->red = IntToFixed(r);
+ span->green = IntToFixed(g);
+ span->blue = IntToFixed(b);
+ span->alpha = IntToFixed(a);
+#endif
+ span->redStep = 0;
+ span->greenStep = 0;
+ span->blueStep = 0;
+ span->alphaStep = 0;
+ span->interpMask |= SPAN_RGBA;
+ }
+ else {
+ span->index = FloatToFixed(ctx->Current.RasterIndex);
+ span->indexStep = 0;
+ span->interpMask |= SPAN_INDEX;
+ }
+}
+
+
+/**
+ * Init span's texcoord interpolation values to the RasterPos texcoords.
+ * Used during setup for glDraw/CopyPixels.
+ */
+void
+_swrast_span_default_texcoords( GLcontext *ctx, struct sw_span *span )
+{
+ GLuint i;
+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+ const GLfloat *tc = ctx->Current.RasterTexCoords[i];
+ if (ctx->FragmentProgram._Active || ctx->ATIFragmentShader._Enabled) {
+ COPY_4V(span->tex[i], tc);
+ }
+ else if (tc[3] > 0.0F) {
+ /* use (s/q, t/q, r/q, 1) */
+ span->tex[i][0] = tc[0] / tc[3];
+ span->tex[i][1] = tc[1] / tc[3];
+ span->tex[i][2] = tc[2] / tc[3];
+ span->tex[i][3] = 1.0;
+ }
+ else {
+ ASSIGN_4V(span->tex[i], 0.0F, 0.0F, 0.0F, 1.0F);
+ }
+ ASSIGN_4V(span->texStepX[i], 0.0F, 0.0F, 0.0F, 0.0F);
+ ASSIGN_4V(span->texStepY[i], 0.0F, 0.0F, 0.0F, 0.0F);
+ }
+ span->interpMask |= SPAN_TEXTURE;
+}
+
+
+/* Fill in the span.color.rgba array from the interpolation values */
+static void
+interpolate_colors(GLcontext *ctx, struct sw_span *span)
+{
+ const GLuint n = span->end;
+ GLchan (*rgba)[4] = span->array->rgba;
+ GLuint i;
+ (void) ctx;
+
+ ASSERT((span->interpMask & SPAN_RGBA) &&
+ !(span->arrayMask & SPAN_RGBA));
+
+ if (span->interpMask & SPAN_FLAT) {
+ /* constant color */
+ GLchan color[4];
+ color[RCOMP] = FixedToChan(span->red);
+ color[GCOMP] = FixedToChan(span->green);
+ color[BCOMP] = FixedToChan(span->blue);
+ color[ACOMP] = FixedToChan(span->alpha);
+ for (i = 0; i < n; i++) {
+ COPY_CHAN4(span->array->rgba[i], color);
+ }
+ }
+ else {
+ /* interpolate */
+#if CHAN_TYPE == GL_FLOAT
+ GLfloat r = span->red;
+ GLfloat g = span->green;
+ GLfloat b = span->blue;
+ GLfloat a = span->alpha;
+ const GLfloat dr = span->redStep;
+ const GLfloat dg = span->greenStep;
+ const GLfloat db = span->blueStep;
+ const GLfloat da = span->alphaStep;
+#else
+ GLfixed r = span->red;
+ GLfixed g = span->green;
+ GLfixed b = span->blue;
+ GLfixed a = span->alpha;
+ const GLint dr = span->redStep;
+ const GLint dg = span->greenStep;
+ const GLint db = span->blueStep;
+ const GLint da = span->alphaStep;
+#endif
+ for (i = 0; i < n; i++) {
+ rgba[i][RCOMP] = FixedToChan(r);
+ rgba[i][GCOMP] = FixedToChan(g);
+ rgba[i][BCOMP] = FixedToChan(b);
+ rgba[i][ACOMP] = FixedToChan(a);
+ r += dr;
+ g += dg;
+ b += db;
+ a += da;
+ }
+ }
+ span->arrayMask |= SPAN_RGBA;
+}
+
+
+/* Fill in the span.color.index array from the interpolation values */
+static void
+interpolate_indexes(GLcontext *ctx, struct sw_span *span)
+{
+ GLfixed index = span->index;
+ const GLint indexStep = span->indexStep;
+ const GLuint n = span->end;
+ GLuint *indexes = span->array->index;
+ GLuint i;
+ (void) ctx;
+ ASSERT((span->interpMask & SPAN_INDEX) &&
+ !(span->arrayMask & SPAN_INDEX));
+
+ if ((span->interpMask & SPAN_FLAT) || (indexStep == 0)) {
+ /* constant color */
+ index = FixedToInt(index);
+ for (i = 0; i < n; i++) {
+ indexes[i] = index;
+ }
+ }
+ else {
+ /* interpolate */
+ for (i = 0; i < n; i++) {
+ indexes[i] = FixedToInt(index);
+ index += indexStep;
+ }
+ }
+ span->arrayMask |= SPAN_INDEX;
+ span->interpMask &= ~SPAN_INDEX;
+}
+
+
+/* Fill in the span.->array->spec array from the interpolation values */
+static void
+interpolate_specular(GLcontext *ctx, struct sw_span *span)
+{
+ (void) ctx;
+ if (span->interpMask & SPAN_FLAT) {
+ /* constant color */
+ const GLchan r = FixedToChan(span->specRed);
+ const GLchan g = FixedToChan(span->specGreen);
+ const GLchan b = FixedToChan(span->specBlue);
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ span->array->spec[i][RCOMP] = r;
+ span->array->spec[i][GCOMP] = g;
+ span->array->spec[i][BCOMP] = b;
+ }
+ }
+ else {
+ /* interpolate */
+#if CHAN_TYPE == GL_FLOAT
+ GLfloat r = span->specRed;
+ GLfloat g = span->specGreen;
+ GLfloat b = span->specBlue;
+#else
+ GLfixed r = span->specRed;
+ GLfixed g = span->specGreen;
+ GLfixed b = span->specBlue;
+#endif
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ span->array->spec[i][RCOMP] = FixedToChan(r);
+ span->array->spec[i][GCOMP] = FixedToChan(g);
+ span->array->spec[i][BCOMP] = FixedToChan(b);
+ r += span->specRedStep;
+ g += span->specGreenStep;
+ b += span->specBlueStep;
+ }
+ }
+ span->arrayMask |= SPAN_SPEC;
+}
+
+
+/* Fill in the span.array.fog values from the interpolation values */
+static void
+interpolate_fog(const GLcontext *ctx, struct sw_span *span)
+{
+ GLfloat *fog = span->array->fog;
+ const GLfloat fogStep = span->fogStep;
+ GLfloat fogCoord = span->fog;
+ const GLuint haveW = (span->interpMask & SPAN_W);
+ const GLfloat wStep = haveW ? span->dwdx : 0.0F;
+ GLfloat w = haveW ? span->w : 1.0F;
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ fog[i] = fogCoord / w;
+ fogCoord += fogStep;
+ w += wStep;
+ }
+ span->arrayMask |= SPAN_FOG;
+}
+
+
+/* Fill in the span.zArray array from the interpolation values */
+void
+_swrast_span_interpolate_z( const GLcontext *ctx, struct sw_span *span )
+{
+ const GLuint n = span->end;
+ GLuint i;
+
+ ASSERT((span->interpMask & SPAN_Z) &&
+ !(span->arrayMask & SPAN_Z));
+
+ if (ctx->Visual.depthBits <= 16) {
+ GLfixed zval = span->z;
+ GLdepth *z = span->array->z;
+ for (i = 0; i < n; i++) {
+ z[i] = FixedToInt(zval);
+ zval += span->zStep;
+ }
+ }
+ else {
+ /* Deep Z buffer, no fixed->int shift */
+ GLfixed zval = span->z;
+ GLdepth *z = span->array->z;
+ for (i = 0; i < n; i++) {
+ z[i] = zval;
+ zval += span->zStep;
+ }
+ }
+ span->interpMask &= ~SPAN_Z;
+ span->arrayMask |= SPAN_Z;
+}
+
+
+/*
+ * This the ideal solution, as given in the OpenGL spec.
+ */
+#if 0
+static GLfloat
+compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy,
+ GLfloat dqdx, GLfloat dqdy, GLfloat texW, GLfloat texH,
+ GLfloat s, GLfloat t, GLfloat q, GLfloat invQ)
+{
+ GLfloat dudx = texW * ((s + dsdx) / (q + dqdx) - s * invQ);
+ GLfloat dvdx = texH * ((t + dtdx) / (q + dqdx) - t * invQ);
+ GLfloat dudy = texW * ((s + dsdy) / (q + dqdy) - s * invQ);
+ GLfloat dvdy = texH * ((t + dtdy) / (q + dqdy) - t * invQ);
+ GLfloat x = SQRTF(dudx * dudx + dvdx * dvdx);
+ GLfloat y = SQRTF(dudy * dudy + dvdy * dvdy);
+ GLfloat rho = MAX2(x, y);
+ GLfloat lambda = LOG2(rho);
+ return lambda;
+}
+#endif
+
+
+/*
+ * This is a faster approximation
+ */
+GLfloat
+_swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy,
+ GLfloat dqdx, GLfloat dqdy, GLfloat texW, GLfloat texH,
+ GLfloat s, GLfloat t, GLfloat q, GLfloat invQ)
+{
+ GLfloat dsdx2 = (s + dsdx) / (q + dqdx) - s * invQ;
+ GLfloat dtdx2 = (t + dtdx) / (q + dqdx) - t * invQ;
+ GLfloat dsdy2 = (s + dsdy) / (q + dqdy) - s * invQ;
+ GLfloat dtdy2 = (t + dtdy) / (q + dqdy) - t * invQ;
+ GLfloat maxU, maxV, rho, lambda;
+ dsdx2 = FABSF(dsdx2);
+ dsdy2 = FABSF(dsdy2);
+ dtdx2 = FABSF(dtdx2);
+ dtdy2 = FABSF(dtdy2);
+ maxU = MAX2(dsdx2, dsdy2) * texW;
+ maxV = MAX2(dtdx2, dtdy2) * texH;
+ rho = MAX2(maxU, maxV);
+ lambda = LOG2(rho);
+ return lambda;
+}
+
+
+/**
+ * Fill in the span.texcoords array from the interpolation values.
+ * Note: in the places where we divide by Q (or mult by invQ) we're
+ * really doing two things: perspective correction and texcoord
+ * projection. Remember, for texcoord (s,t,r,q) we need to index
+ * texels with (s/q, t/q, r/q).
+ * If we're using a fragment program, we never do the division
+ * for texcoord projection. That's done by the TXP instruction
+ * or user-written code.
+ */
+static void
+interpolate_texcoords(GLcontext *ctx, struct sw_span *span)
+{
+ ASSERT(span->interpMask & SPAN_TEXTURE);
+ ASSERT(!(span->arrayMask & SPAN_TEXTURE));
+
+ if (ctx->Texture._EnabledCoordUnits > 1) {
+ /* multitexture */
+ GLuint u;
+ span->arrayMask |= SPAN_TEXTURE;
+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
+ if (ctx->Texture._EnabledCoordUnits & (1 << u)) {
+ const struct gl_texture_object *obj =ctx->Texture.Unit[u]._Current;
+ GLfloat texW, texH;
+ GLboolean needLambda;
+ if (obj) {
+ const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel];
+ needLambda = (obj->MinFilter != obj->MagFilter)
+ || ctx->FragmentProgram._Active;
+ texW = img->WidthScale;
+ texH = img->HeightScale;
+ }
+ else {
+ /* using a fragment program */
+ texW = 1.0;
+ texH = 1.0;
+ needLambda = GL_FALSE;
+ }
+ if (needLambda) {
+ GLfloat (*texcoord)[4] = span->array->texcoords[u];
+ GLfloat *lambda = span->array->lambda[u];
+ const GLfloat dsdx = span->texStepX[u][0];
+ const GLfloat dsdy = span->texStepY[u][0];
+ const GLfloat dtdx = span->texStepX[u][1];
+ const GLfloat dtdy = span->texStepY[u][1];
+ const GLfloat drdx = span->texStepX[u][2];
+ const GLfloat dqdx = span->texStepX[u][3];
+ const GLfloat dqdy = span->texStepY[u][3];
+ GLfloat s = span->tex[u][0];
+ GLfloat t = span->tex[u][1];
+ GLfloat r = span->tex[u][2];
+ GLfloat q = span->tex[u][3];
+ GLuint i;
+ if (ctx->FragmentProgram._Active) {
+ /* do perspective correction but don't divide s, t, r by q */
+ const GLfloat dwdx = span->dwdx;
+ GLfloat w = span->w;
+ for (i = 0; i < span->end; i++) {
+ const GLfloat invW = 1.0F / w;
+ texcoord[i][0] = s * invW;
+ texcoord[i][1] = t * invW;
+ texcoord[i][2] = r * invW;
+ texcoord[i][3] = q * invW;
+ lambda[i] = _swrast_compute_lambda(dsdx, dsdy, dtdx, dtdy,
+ dqdx, dqdy, texW, texH,
+ s, t, q, invW);
+ s += dsdx;
+ t += dtdx;
+ r += drdx;
+ q += dqdx;
+ w += dwdx;
+ }
+
+ }
+ else {
+ for (i = 0; i < span->end; i++) {
+ const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q);
+ texcoord[i][0] = s * invQ;
+ texcoord[i][1] = t * invQ;
+ texcoord[i][2] = r * invQ;
+ texcoord[i][3] = q;
+ lambda[i] = _swrast_compute_lambda(dsdx, dsdy, dtdx, dtdy,
+ dqdx, dqdy, texW, texH,
+ s, t, q, invQ);
+ s += dsdx;
+ t += dtdx;
+ r += drdx;
+ q += dqdx;
+ }
+ }
+ span->arrayMask |= SPAN_LAMBDA;
+ }
+ else {
+ GLfloat (*texcoord)[4] = span->array->texcoords[u];
+ GLfloat *lambda = span->array->lambda[u];
+ const GLfloat dsdx = span->texStepX[u][0];
+ const GLfloat dtdx = span->texStepX[u][1];
+ const GLfloat drdx = span->texStepX[u][2];
+ const GLfloat dqdx = span->texStepX[u][3];
+ GLfloat s = span->tex[u][0];
+ GLfloat t = span->tex[u][1];
+ GLfloat r = span->tex[u][2];
+ GLfloat q = span->tex[u][3];
+ GLuint i;
+ if (ctx->FragmentProgram._Active) {
+ /* do perspective correction but don't divide s, t, r by q */
+ const GLfloat dwdx = span->dwdx;
+ GLfloat w = span->w;
+ for (i = 0; i < span->end; i++) {
+ const GLfloat invW = 1.0F / w;
+ texcoord[i][0] = s * invW;
+ texcoord[i][1] = t * invW;
+ texcoord[i][2] = r * invW;
+ texcoord[i][3] = q * invW;
+ lambda[i] = 0.0;
+ s += dsdx;
+ t += dtdx;
+ r += drdx;
+ q += dqdx;
+ w += dwdx;
+ }
+ }
+ else if (dqdx == 0.0F) {
+ /* Ortho projection or polygon's parallel to window X axis */
+ const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q);
+ for (i = 0; i < span->end; i++) {
+ texcoord[i][0] = s * invQ;
+ texcoord[i][1] = t * invQ;
+ texcoord[i][2] = r * invQ;
+ texcoord[i][3] = q;
+ lambda[i] = 0.0;
+ s += dsdx;
+ t += dtdx;
+ r += drdx;
+ }
+ }
+ else {
+ for (i = 0; i < span->end; i++) {
+ const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q);
+ texcoord[i][0] = s * invQ;
+ texcoord[i][1] = t * invQ;
+ texcoord[i][2] = r * invQ;
+ texcoord[i][3] = q;
+ lambda[i] = 0.0;
+ s += dsdx;
+ t += dtdx;
+ r += drdx;
+ q += dqdx;
+ }
+ }
+ } /* lambda */
+ } /* if */
+ } /* for */
+ }
+ else {
+ /* single texture */
+ const struct gl_texture_object *obj = ctx->Texture.Unit[0]._Current;
+ GLfloat texW, texH;
+ GLboolean needLambda;
+ if (obj) {
+ const struct gl_texture_image *img = obj->Image[0][obj->BaseLevel];
+ needLambda = (obj->MinFilter != obj->MagFilter)
+ || ctx->FragmentProgram._Active;
+ texW = (GLfloat) img->WidthScale;
+ texH = (GLfloat) img->HeightScale;
+ }
+ else {
+ needLambda = GL_FALSE;
+ texW = texH = 1.0;
+ }
+ span->arrayMask |= SPAN_TEXTURE;
+ if (needLambda) {
+ /* just texture unit 0, with lambda */
+ GLfloat (*texcoord)[4] = span->array->texcoords[0];
+ GLfloat *lambda = span->array->lambda[0];
+ const GLfloat dsdx = span->texStepX[0][0];
+ const GLfloat dsdy = span->texStepY[0][0];
+ const GLfloat dtdx = span->texStepX[0][1];
+ const GLfloat dtdy = span->texStepY[0][1];
+ const GLfloat drdx = span->texStepX[0][2];
+ const GLfloat dqdx = span->texStepX[0][3];
+ const GLfloat dqdy = span->texStepY[0][3];
+ GLfloat s = span->tex[0][0];
+ GLfloat t = span->tex[0][1];
+ GLfloat r = span->tex[0][2];
+ GLfloat q = span->tex[0][3];
+ GLuint i;
+ if (ctx->FragmentProgram._Active) {
+ /* do perspective correction but don't divide s, t, r by q */
+ const GLfloat dwdx = span->dwdx;
+ GLfloat w = span->w;
+ for (i = 0; i < span->end; i++) {
+ const GLfloat invW = 1.0F / w;
+ texcoord[i][0] = s * invW;
+ texcoord[i][1] = t * invW;
+ texcoord[i][2] = r * invW;
+ texcoord[i][3] = q * invW;
+ lambda[i] = _swrast_compute_lambda(dsdx, dsdy, dtdx, dtdy,
+ dqdx, dqdy, texW, texH,
+ s, t, q, invW);
+ s += dsdx;
+ t += dtdx;
+ r += drdx;
+ q += dqdx;
+ w += dwdx;
+ }
+ }
+ else {
+ /* tex.c */
+ for (i = 0; i < span->end; i++) {
+ const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q);
+ lambda[i] = _swrast_compute_lambda(dsdx, dsdy, dtdx, dtdy,
+ dqdx, dqdy, texW, texH,
+ s, t, q, invQ);
+ texcoord[i][0] = s * invQ;
+ texcoord[i][1] = t * invQ;
+ texcoord[i][2] = r * invQ;
+ texcoord[i][3] = q;
+ s += dsdx;
+ t += dtdx;
+ r += drdx;
+ q += dqdx;
+ }
+ }
+ span->arrayMask |= SPAN_LAMBDA;
+ }
+ else {
+ /* just texture 0, without lambda */
+ GLfloat (*texcoord)[4] = span->array->texcoords[0];
+ const GLfloat dsdx = span->texStepX[0][0];
+ const GLfloat dtdx = span->texStepX[0][1];
+ const GLfloat drdx = span->texStepX[0][2];
+ const GLfloat dqdx = span->texStepX[0][3];
+ GLfloat s = span->tex[0][0];
+ GLfloat t = span->tex[0][1];
+ GLfloat r = span->tex[0][2];
+ GLfloat q = span->tex[0][3];
+ GLuint i;
+ if (ctx->FragmentProgram._Active) {
+ /* do perspective correction but don't divide s, t, r by q */
+ const GLfloat dwdx = span->dwdx;
+ GLfloat w = span->w;
+ for (i = 0; i < span->end; i++) {
+ const GLfloat invW = 1.0F / w;
+ texcoord[i][0] = s * invW;
+ texcoord[i][1] = t * invW;
+ texcoord[i][2] = r * invW;
+ texcoord[i][3] = q * invW;
+ s += dsdx;
+ t += dtdx;
+ r += drdx;
+ q += dqdx;
+ w += dwdx;
+ }
+ }
+ else if (dqdx == 0.0F) {
+ /* Ortho projection or polygon's parallel to window X axis */
+ const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q);
+ for (i = 0; i < span->end; i++) {
+ texcoord[i][0] = s * invQ;
+ texcoord[i][1] = t * invQ;
+ texcoord[i][2] = r * invQ;
+ texcoord[i][3] = q;
+ s += dsdx;
+ t += dtdx;
+ r += drdx;
+ }
+ }
+ else {
+ for (i = 0; i < span->end; i++) {
+ const GLfloat invQ = (q == 0.0F) ? 1.0F : (1.0F / q);
+ texcoord[i][0] = s * invQ;
+ texcoord[i][1] = t * invQ;
+ texcoord[i][2] = r * invQ;
+ texcoord[i][3] = q;
+ s += dsdx;
+ t += dtdx;
+ r += drdx;
+ q += dqdx;
+ }
+ }
+ }
+ }
+}
+
+
+/**
+ * Apply the current polygon stipple pattern to a span of pixels.
+ */
+static void
+stipple_polygon_span( GLcontext *ctx, struct sw_span *span )
+{
+ const GLuint highbit = 0x80000000;
+ const GLuint stipple = ctx->PolygonStipple[span->y % 32];
+ GLubyte *mask = span->array->mask;
+ GLuint i, m;
+
+ ASSERT(ctx->Polygon.StippleFlag);
+ ASSERT((span->arrayMask & SPAN_XY) == 0);
+
+ m = highbit >> (GLuint) (span->x % 32);
+
+ for (i = 0; i < span->end; i++) {
+ if ((m & stipple) == 0) {
+ mask[i] = 0;
+ }
+ m = m >> 1;
+ if (m == 0) {
+ m = highbit;
+ }
+ }
+ span->writeAll = GL_FALSE;
+}
+
+
+/**
+ * Clip a pixel span to the current buffer/window boundaries:
+ * DrawBuffer->_Xmin, _Xmax, _Ymin, _Ymax. This will accomplish
+ * window clipping and scissoring.
+ * Return: GL_TRUE some pixels still visible
+ * GL_FALSE nothing visible
+ */
+static GLuint
+clip_span( GLcontext *ctx, struct sw_span *span )
+{
+ const GLint xmin = ctx->DrawBuffer->_Xmin;
+ const GLint xmax = ctx->DrawBuffer->_Xmax;
+ const GLint ymin = ctx->DrawBuffer->_Ymin;
+ const GLint ymax = ctx->DrawBuffer->_Ymax;
+
+ if (span->arrayMask & SPAN_XY) {
+ /* arrays of x/y pixel coords */
+ const GLint *x = span->array->x;
+ const GLint *y = span->array->y;
+ const GLint n = span->end;
+ GLubyte *mask = span->array->mask;
+ GLint i;
+ if (span->arrayMask & SPAN_MASK) {
+ /* note: using & intead of && to reduce branches */
+ for (i = 0; i < n; i++) {
+ mask[i] &= (x[i] >= xmin) & (x[i] < xmax)
+ & (y[i] >= ymin) & (y[i] < ymax);
+ }
+ }
+ else {
+ /* note: using & intead of && to reduce branches */
+ for (i = 0; i < n; i++) {
+ mask[i] = (x[i] >= xmin) & (x[i] < xmax)
+ & (y[i] >= ymin) & (y[i] < ymax);
+ }
+ }
+ return GL_TRUE; /* some pixels visible */
+ }
+ else {
+ /* horizontal span of pixels */
+ const GLint x = span->x;
+ const GLint y = span->y;
+ const GLint n = span->end;
+
+ /* Trivial rejection tests */
+ if (y < ymin || y >= ymax || x + n <= xmin || x >= xmax) {
+ span->end = 0;
+ return GL_FALSE; /* all pixels clipped */
+ }
+
+ /* Clip to the left */
+ if (x < xmin) {
+ ASSERT(x + n > xmin);
+ span->writeAll = GL_FALSE;
+ _mesa_bzero(span->array->mask, (xmin - x) * sizeof(GLubyte));
+ }
+
+ /* Clip to right */
+ if (x + n > xmax) {
+ ASSERT(x < xmax);
+ span->end = xmax - x;
+ }
+
+ return GL_TRUE; /* some pixels visible */
+ }
+}
+
+
+/**
+ * Apply all the per-fragment opertions to a span of color index fragments
+ * and write them to the enabled color drawbuffers.
+ * The 'span' parameter can be considered to be const. Note that
+ * span->interpMask and span->arrayMask may be changed but will be restored
+ * to their original values before returning.
+ */
+void
+_swrast_write_index_span( GLcontext *ctx, struct sw_span *span)
+{
+ const SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const struct gl_framebuffer *fb = ctx->DrawBuffer;
+ const GLuint output = 0;
+ const GLuint origInterpMask = span->interpMask;
+ const GLuint origArrayMask = span->arrayMask;
+ GLuint buf;
+
+ ASSERT(span->end <= MAX_WIDTH);
+ ASSERT(span->primitive == GL_POINT || span->primitive == GL_LINE ||
+ span->primitive == GL_POLYGON || span->primitive == GL_BITMAP);
+ ASSERT((span->interpMask | span->arrayMask) & SPAN_INDEX);
+ ASSERT((span->interpMask & span->arrayMask) == 0);
+
+ if (span->arrayMask & SPAN_MASK) {
+ /* mask was initialized by caller, probably glBitmap */
+ span->writeAll = GL_FALSE;
+ }
+ else {
+ _mesa_memset(span->array->mask, 1, span->end);
+ span->writeAll = GL_TRUE;
+ }
+
+ /* Clipping */
+ if ((swrast->_RasterMask & CLIP_BIT) || (span->primitive != GL_POLYGON)) {
+ if (!clip_span(ctx, span)) {
+ return;
+ }
+ }
+
+ /* Depth bounds test */
+ if (ctx->Depth.BoundsTest && ctx->Visual.depthBits > 0) {
+ if (!_swrast_depth_bounds_test(ctx, span)) {
+ return;
+ }
+ }
+
+#ifdef DEBUG
+ /* Make sure all fragments are within window bounds */
+ if (span->arrayMask & SPAN_XY) {
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ if (span->array->mask[i]) {
+ assert(span->array->x[i] >= ctx->DrawBuffer->_Xmin);
+ assert(span->array->x[i] < ctx->DrawBuffer->_Xmax);
+ assert(span->array->y[i] >= ctx->DrawBuffer->_Ymin);
+ assert(span->array->y[i] < ctx->DrawBuffer->_Ymax);
+ }
+ }
+ }
+#endif
+
+ /* Polygon Stippling */
+ if (ctx->Polygon.StippleFlag && span->primitive == GL_POLYGON) {
+ stipple_polygon_span(ctx, span);
+ }
+
+ /* Stencil and Z testing */
+ if (ctx->Depth.Test || ctx->Stencil.Enabled) {
+ if (span->interpMask & SPAN_Z)
+ _swrast_span_interpolate_z(ctx, span);
+
+ if (ctx->Stencil.Enabled) {
+ if (!_swrast_stencil_and_ztest_span(ctx, span)) {
+ span->arrayMask = origArrayMask;
+ return;
+ }
+ }
+ else {
+ ASSERT(ctx->Depth.Test);
+ if (!_swrast_depth_test_span(ctx, span)) {
+ span->interpMask = origInterpMask;
+ span->arrayMask = origArrayMask;
+ return;
+ }
+ }
+ }
+
+ /* if we get here, something passed the depth test */
+ if (ctx->Depth.OcclusionTest) {
+ ctx->OcclusionResult = GL_TRUE;
+ }
+
+#if FEATURE_ARB_occlusion_query
+ if (ctx->Occlusion.Active) {
+ /* update count of 'passed' fragments */
+ GLuint i;
+ for (i = 0; i < span->end; i++)
+ ctx->Occlusion.PassedCounter += span->array->mask[i];
+ }
+#endif
+
+ /* we have to wait until after occlusion to do this test */
+ if (ctx->Color.DrawBuffer == GL_NONE || ctx->Color.IndexMask == 0) {
+ /* write no pixels */
+ span->arrayMask = origArrayMask;
+ return;
+ }
+
+ /* Interpolate the color indexes if needed */
+ if (swrast->_FogEnabled ||
+ ctx->Color.IndexLogicOpEnabled ||
+ ctx->Color.IndexMask != 0xffffffff ||
+ (span->arrayMask & SPAN_COVERAGE)) {
+ if (span->interpMask & SPAN_INDEX) {
+ interpolate_indexes(ctx, span);
+ }
+ }
+
+ /* Fog */
+ if (swrast->_FogEnabled) {
+ _swrast_fog_ci_span(ctx, span);
+ }
+
+ /* Antialias coverage application */
+ if (span->arrayMask & SPAN_COVERAGE) {
+ const GLfloat *coverage = span->array->coverage;
+ GLuint *index = span->array->index;
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ ASSERT(coverage[i] < 16);
+ index[i] = (index[i] & ~0xf) | ((GLuint) coverage[i]);
+ }
+ }
+
+ /* Loop over drawing buffers */
+ for (buf = 0; buf < fb->_NumColorDrawBuffers[output]; buf++) {
+ struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[output][buf];
+ GLuint indexTemp[MAX_WIDTH], *index32;
+
+ ASSERT(rb->_BaseFormat == GL_COLOR_INDEX);
+
+ if (ctx->Color.IndexLogicOpEnabled ||
+ ctx->Color.IndexMask != 0xffffffff) {
+ /* make copy of incoming indexes */
+ MEMCPY(indexTemp, span->array->index, span->end * sizeof(GLuint));
+
+ if (ctx->Color.IndexLogicOpEnabled) {
+ _swrast_logicop_ci_span(ctx, rb, span, indexTemp);
+ }
+
+ if (ctx->Color.IndexMask != 0xffffffff) {
+ _swrast_mask_ci_span(ctx, rb, span, indexTemp);
+ }
+ index32 = indexTemp;
+ }
+ else {
+ index32 = span->array->index;
+ }
+
+ if ((span->interpMask & SPAN_INDEX) && span->indexStep == 0) {
+ /* all fragments have same color index */
+ GLubyte index8;
+ GLushort index16;
+ GLuint index32;
+ void *value;
+
+ if (rb->DataType == GL_UNSIGNED_BYTE) {
+ index8 = FixedToInt(span->index);
+ value = &index8;
+ }
+ else if (rb->DataType == GL_UNSIGNED_SHORT) {
+ index16 = FixedToInt(span->index);
+ value = &index16;
+ }
+ else {
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ index32 = FixedToInt(span->index);
+ value = &index32;
+ }
+
+ if (span->arrayMask & SPAN_XY) {
+ rb->PutMonoValues(ctx, rb, span->end, span->array->x,
+ span->array->y, value, span->array->mask);
+ }
+ else {
+ rb->PutMonoRow(ctx, rb, span->end, span->x, span->y,
+ value, span->array->mask);
+ }
+ }
+ else {
+ /* each fragment is a different color */
+ GLubyte index8[MAX_WIDTH];
+ GLushort index16[MAX_WIDTH];
+ void *values;
+
+ if (rb->DataType == GL_UNSIGNED_BYTE) {
+ GLuint k;
+ for (k = 0; k < span->end; k++) {
+ index8[k] = (GLubyte) index32[k];
+ }
+ values = index8;
+ }
+ else if (rb->DataType == GL_UNSIGNED_SHORT) {
+ GLuint k;
+ for (k = 0; k < span->end; k++) {
+ index16[k] = (GLushort) index32[k];
+ }
+ values = index16;
+ }
+ else {
+ ASSERT(rb->DataType == GL_UNSIGNED_INT);
+ values = index32;
+ }
+
+ if (span->arrayMask & SPAN_XY) {
+ rb->PutValues(ctx, rb, span->end, span->array->x, span->array->y,
+ values, span->array->mask);
+ }
+ else {
+ rb->PutRow(ctx, rb, span->end, span->x, span->y,
+ values, span->array->mask);
+ }
+ }
+ }
+
+#if OLD_RENDERBUFFER
+ /* restore default dest buffer */
+ _swrast_use_draw_buffer(ctx);
+#endif
+
+ span->interpMask = origInterpMask;
+ span->arrayMask = origArrayMask;
+}
+
+
+/**
+ * Add specular color to base color. This is used only when
+ * GL_LIGHT_MODEL_COLOR_CONTROL = GL_SEPARATE_SPECULAR_COLOR.
+ */
+static void
+add_colors(GLuint n, GLchan rgba[][4], GLchan specular[][4] )
+{
+ GLuint i;
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ /* no clamping */
+ rgba[i][RCOMP] += specular[i][RCOMP];
+ rgba[i][GCOMP] += specular[i][GCOMP];
+ rgba[i][BCOMP] += specular[i][BCOMP];
+#else
+ GLint r = rgba[i][RCOMP] + specular[i][RCOMP];
+ GLint g = rgba[i][GCOMP] + specular[i][GCOMP];
+ GLint b = rgba[i][BCOMP] + specular[i][BCOMP];
+ rgba[i][RCOMP] = (GLchan) MIN2(r, CHAN_MAX);
+ rgba[i][GCOMP] = (GLchan) MIN2(g, CHAN_MAX);
+ rgba[i][BCOMP] = (GLchan) MIN2(b, CHAN_MAX);
+#endif
+ }
+}
+
+
+/**
+ * XXX merge this code into the _swrast_write_rgba_span() routine!
+ *
+ * Draw to more than one RGBA color buffer (or none).
+ * All fragment operations, up to (but not) blending/logicop should
+ * have been done first.
+ */
+static void
+multi_write_rgba_span( GLcontext *ctx, struct sw_span *span )
+{
+#if OLD_RENDERBUFFER
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+#endif
+ const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask);
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ const GLuint output = 0;
+ GLuint i;
+
+ ASSERT(span->end < MAX_WIDTH);
+ ASSERT(colorMask != 0x0);
+
+ for (i = 0; i < fb->_NumColorDrawBuffers[output]; i++) {
+ struct gl_renderbuffer *rb = fb->_ColorDrawBuffers[output][i];
+ GLchan rgbaTmp[MAX_WIDTH][4];
+
+#if OLD_RENDERBUFFER
+ /* obsolete code */
+ GLuint bufferBit = fb->_ColorDrawBit[output][i];
+ /* Set the current read/draw buffer */
+ swrast->CurrentBufferBit = bufferBit;
+ if (swrast->Driver.SetBuffer)
+ (*swrast->Driver.SetBuffer)(ctx, ctx->DrawBuffer, bufferBit);
+#endif
+
+ /* make copy of incoming colors */
+ MEMCPY( rgbaTmp, span->array->rgba, 4 * span->end * sizeof(GLchan) );
+
+ if (ctx->Color._LogicOpEnabled) {
+ _swrast_logicop_rgba_span(ctx, rb, span, rgbaTmp);
+ }
+ else if (ctx->Color.BlendEnabled) {
+ _swrast_blend_span(ctx, rb, span, rgbaTmp);
+ }
+
+ if (colorMask != 0xffffffff) {
+ _swrast_mask_rgba_span(ctx, rb, span, rgbaTmp);
+ }
+
+ if (span->arrayMask & SPAN_XY) {
+ /* array of pixel coords */
+ ASSERT(rb->PutValues);
+ rb->PutValues(ctx, rb, span->end, span->array->x,
+ span->array->y, rgbaTmp, span->array->mask);
+ }
+ else {
+ /* horizontal run of pixels */
+ ASSERT(rb->PutRow);
+ rb->PutRow(ctx, rb, span->end, span->x, span->y, rgbaTmp,
+ span->array->mask);
+ }
+ }
+
+#if OLD_RENDERBUFFER
+ /* restore default dest buffer */
+ _swrast_use_draw_buffer(ctx);
+#endif
+}
+
+
+/**
+ * Apply all the per-fragment operations to a span.
+ * This now includes texturing (_swrast_write_texture_span() is history).
+ * This function may modify any of the array values in the span.
+ * span->interpMask and span->arrayMask may be changed but will be restored
+ * to their original values before returning.
+ */
+void
+_swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span)
+{
+ const GLuint colorMask = *((GLuint *) ctx->Color.ColorMask);
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const GLuint origInterpMask = span->interpMask;
+ const GLuint origArrayMask = span->arrayMask;
+ const GLboolean deferredTexture = !(ctx->Color.AlphaEnabled ||
+ ctx->FragmentProgram._Active ||
+ ctx->ATIFragmentShader._Enabled);
+
+ ASSERT(span->primitive == GL_POINT || span->primitive == GL_LINE ||
+ span->primitive == GL_POLYGON || span->primitive == GL_BITMAP);
+ ASSERT(span->end <= MAX_WIDTH);
+ ASSERT((span->interpMask & span->arrayMask) == 0);
+
+ /*
+ printf("%s() interp 0x%x array 0x%x\n", __FUNCTION__,
+ span->interpMask, span->arrayMask);
+ */
+
+ if (span->arrayMask & SPAN_MASK) {
+ /* mask was initialized by caller, probably glBitmap */
+ span->writeAll = GL_FALSE;
+ }
+ else {
+ _mesa_memset(span->array->mask, 1, span->end);
+ span->writeAll = GL_TRUE;
+ }
+
+ /* Clip to window/scissor box */
+ if ((swrast->_RasterMask & CLIP_BIT) || (span->primitive != GL_POLYGON)) {
+ if (!clip_span(ctx, span)) {
+ return;
+ }
+ }
+
+#ifdef DEBUG
+ /* Make sure all fragments are within window bounds */
+ if (span->arrayMask & SPAN_XY) {
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ if (span->array->mask[i]) {
+ assert(span->array->x[i] >= ctx->DrawBuffer->_Xmin);
+ assert(span->array->x[i] < ctx->DrawBuffer->_Xmax);
+ assert(span->array->y[i] >= ctx->DrawBuffer->_Ymin);
+ assert(span->array->y[i] < ctx->DrawBuffer->_Ymax);
+ }
+ }
+ }
+#endif
+
+ /* Polygon Stippling */
+ if (ctx->Polygon.StippleFlag && span->primitive == GL_POLYGON) {
+ stipple_polygon_span(ctx, span);
+ }
+
+ /* Interpolate texcoords? */
+ if (ctx->Texture._EnabledCoordUnits
+ && (span->interpMask & SPAN_TEXTURE)
+ && (span->arrayMask & SPAN_TEXTURE) == 0) {
+ interpolate_texcoords(ctx, span);
+ }
+
+ /* This is the normal place to compute the resulting fragment color/Z.
+ * As an optimization, we try to defer this until after Z/stencil
+ * testing in order to try to avoid computing colors that we won't
+ * actually need.
+ */
+ if (!deferredTexture) {
+ /* Now we need the rgba array, fill it in if needed */
+ if ((span->interpMask & SPAN_RGBA) && (span->arrayMask & SPAN_RGBA) == 0)
+ interpolate_colors(ctx, span);
+
+ if (span->interpMask & SPAN_SPEC)
+ interpolate_specular(ctx, span);
+
+ if (span->interpMask & SPAN_FOG)
+ interpolate_fog(ctx, span);
+
+ /* Compute fragment colors with fragment program or texture lookups */
+ if (ctx->FragmentProgram._Active) {
+ /* frag prog may need Z values */
+ if (span->interpMask & SPAN_Z)
+ _swrast_span_interpolate_z(ctx, span);
+ _swrast_exec_fragment_program( ctx, span );
+ }
+ else if (ctx->ATIFragmentShader._Enabled)
+ _swrast_exec_fragment_shader( ctx, span );
+ else if (ctx->Texture._EnabledUnits && (span->arrayMask & SPAN_TEXTURE))
+ _swrast_texture_span( ctx, span );
+
+ /* Do the alpha test */
+ if (!_swrast_alpha_test(ctx, span)) {
+ span->arrayMask = origArrayMask;
+ return;
+ }
+ }
+
+ /* Stencil and Z testing */
+ if (ctx->Stencil.Enabled || ctx->Depth.Test) {
+ if (span->interpMask & SPAN_Z)
+ _swrast_span_interpolate_z(ctx, span);
+
+ if (ctx->Stencil.Enabled && ctx->DrawBuffer->Visual.stencilBits > 0) {
+ /* Combined Z/stencil tests */
+ if (!_swrast_stencil_and_ztest_span(ctx, span)) {
+ span->interpMask = origInterpMask;
+ span->arrayMask = origArrayMask;
+ return;
+ }
+ }
+ else if (ctx->DrawBuffer->Visual.depthBits > 0) {
+ /* Just regular depth testing */
+ ASSERT(ctx->Depth.Test);
+ ASSERT(span->arrayMask & SPAN_Z);
+ if (!_swrast_depth_test_span(ctx, span)) {
+ span->interpMask = origInterpMask;
+ span->arrayMask = origArrayMask;
+ return;
+ }
+ }
+ }
+
+ /* if we get here, some fragments passed the depth test */
+ if (ctx->Depth.OcclusionTest) {
+ ctx->OcclusionResult = GL_TRUE;
+ }
+
+#if FEATURE_ARB_occlusion_query
+ if (ctx->Occlusion.Active) {
+ /* update count of 'passed' fragments */
+ GLuint i;
+ for (i = 0; i < span->end; i++)
+ ctx->Occlusion.PassedCounter += span->array->mask[i];
+ }
+#endif
+
+ /* We had to wait until now to check for glColorMask(0,0,0,0) because of
+ * the occlusion test.
+ */
+ if (colorMask == 0x0) {
+ span->interpMask = origInterpMask;
+ span->arrayMask = origArrayMask;
+ return;
+ }
+
+ /* If we were able to defer fragment color computation to now, there's
+ * a good chance that many fragments will have already been killed by
+ * Z/stencil testing.
+ */
+ if (deferredTexture) {
+ /* Now we need the rgba array, fill it in if needed */
+ if ((span->interpMask & SPAN_RGBA) && (span->arrayMask & SPAN_RGBA) == 0)
+ interpolate_colors(ctx, span);
+
+ if (span->interpMask & SPAN_SPEC)
+ interpolate_specular(ctx, span);
+
+ if (span->interpMask & SPAN_FOG)
+ interpolate_fog(ctx, span);
+
+ if (ctx->FragmentProgram._Active)
+ _swrast_exec_fragment_program( ctx, span );
+ else if (ctx->ATIFragmentShader._Enabled)
+ _swrast_exec_fragment_shader( ctx, span );
+ else if (ctx->Texture._EnabledUnits && (span->arrayMask & SPAN_TEXTURE))
+ _swrast_texture_span( ctx, span );
+ }
+
+ ASSERT(span->arrayMask & SPAN_RGBA);
+
+ if (!ctx->FragmentProgram._Enabled) {
+ /* Add base and specular colors */
+ if (ctx->Fog.ColorSumEnabled ||
+ (ctx->Light.Enabled &&
+ ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)) {
+ if (span->interpMask & SPAN_SPEC) {
+ interpolate_specular(ctx, span);
+ }
+ if (span->arrayMask & SPAN_SPEC) {
+ add_colors( span->end, span->array->rgba, span->array->spec );
+ }
+ else {
+ /* We probably added the base/specular colors during the
+ * vertex stage!
+ */
+ }
+ }
+ }
+
+ /* Fog */
+ if (swrast->_FogEnabled) {
+ _swrast_fog_rgba_span(ctx, span);
+ }
+
+ /* Antialias coverage application */
+ if (span->arrayMask & SPAN_COVERAGE) {
+ GLchan (*rgba)[4] = span->array->rgba;
+ GLfloat *coverage = span->array->coverage;
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ rgba[i][ACOMP] = (GLchan) (rgba[i][ACOMP] * coverage[i]);
+ }
+ }
+
+ if (swrast->_RasterMask & MULTI_DRAW_BIT) {
+ /* need to do blend/logicop separately for each color buffer */
+ multi_write_rgba_span(ctx, span);
+ }
+ else {
+ /* normal: write to exactly one buffer */
+ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];
+
+ if (ctx->Color._LogicOpEnabled) {
+ _swrast_logicop_rgba_span(ctx, rb, span, span->array->rgba);
+ }
+ else if (ctx->Color.BlendEnabled) {
+ _swrast_blend_span(ctx, rb, span, span->array->rgba);
+ }
+
+ /* Color component masking */
+ if (colorMask != 0xffffffff) {
+ _swrast_mask_rgba_span(ctx, rb, span, span->array->rgba);
+ }
+
+ /* Finally, write the pixels to a color buffer */
+ if (span->arrayMask & SPAN_XY) {
+ /* array of pixel coords */
+ ASSERT(rb->PutValues);
+ ASSERT(rb->_BaseFormat == GL_RGB || rb->_BaseFormat == GL_RGBA);
+ /* XXX check datatype */
+ rb->PutValues(ctx, rb, span->end, span->array->x, span->array->y,
+ span->array->rgba, span->array->mask);
+ }
+ else {
+ /* horizontal run of pixels */
+ ASSERT(rb->PutRow);
+ ASSERT(rb->_BaseFormat == GL_RGB || rb->_BaseFormat == GL_RGBA);
+ /* XXX check datatype */
+ rb->PutRow(ctx, rb, span->end, span->x, span->y, span->array->rgba,
+ span->writeAll ? NULL : span->array->mask);
+ }
+ }
+
+ span->interpMask = origInterpMask;
+ span->arrayMask = origArrayMask;
+}
+
+
+
+/**
+ * Read RGBA pixels from frame buffer. Clipping will be done to prevent
+ * reading ouside the buffer's boundaries.
+ */
+void
+_swrast_read_rgba_span( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLchan rgba[][4] )
+{
+ const GLint bufWidth = (GLint) rb->Width;
+ const GLint bufHeight = (GLint) rb->Height;
+
+ if (y < 0 || y >= bufHeight || x + (GLint) n < 0 || x >= bufWidth) {
+ /* completely above, below, or right */
+ /* XXX maybe leave rgba values undefined? */
+ _mesa_bzero(rgba, 4 * n * sizeof(GLchan));
+ }
+ else {
+ GLint skip, length;
+ if (x < 0) {
+ /* left edge clipping */
+ skip = -x;
+ length = (GLint) n - skip;
+ if (length < 0) {
+ /* completely left of window */
+ return;
+ }
+ if (length > bufWidth) {
+ length = bufWidth;
+ }
+ }
+ else if ((GLint) (x + n) > bufWidth) {
+ /* right edge clipping */
+ skip = 0;
+ length = bufWidth - x;
+ if (length < 0) {
+ /* completely to right of window */
+ return;
+ }
+ }
+ else {
+ /* no clipping */
+ skip = 0;
+ length = (GLint) n;
+ }
+
+ ASSERT(rb);
+ ASSERT(rb->GetRow);
+ ASSERT(rb->_BaseFormat == GL_RGB || rb->_BaseFormat == GL_RGBA);
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ rb->GetRow(ctx, rb, length, x + skip, y, rgba + skip);
+ }
+}
+
+
+/**
+ * Read CI pixels from frame buffer. Clipping will be done to prevent
+ * reading ouside the buffer's boundaries.
+ */
+void
+_swrast_read_index_span( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLuint index[] )
+{
+ const GLint bufWidth = (GLint) rb->Width;
+ const GLint bufHeight = (GLint) rb->Height;
+
+ if (y < 0 || y >= bufHeight || x + (GLint) n < 0 || x >= bufWidth) {
+ /* completely above, below, or right */
+ _mesa_bzero(index, n * sizeof(GLuint));
+ }
+ else {
+ GLint skip, length;
+ if (x < 0) {
+ /* left edge clipping */
+ skip = -x;
+ length = (GLint) n - skip;
+ if (length < 0) {
+ /* completely left of window */
+ return;
+ }
+ if (length > bufWidth) {
+ length = bufWidth;
+ }
+ }
+ else if ((GLint) (x + n) > bufWidth) {
+ /* right edge clipping */
+ skip = 0;
+ length = bufWidth - x;
+ if (length < 0) {
+ /* completely to right of window */
+ return;
+ }
+ }
+ else {
+ /* no clipping */
+ skip = 0;
+ length = (GLint) n;
+ }
+
+ ASSERT(rb->GetRow);
+ ASSERT(rb->_BaseFormat == GL_COLOR_INDEX);
+
+ if (rb->DataType == GL_UNSIGNED_BYTE) {
+ GLubyte index8[MAX_WIDTH];
+ GLint i;
+ rb->GetRow(ctx, rb, length, x + skip, y, index8);
+ for (i = 0; i < length; i++)
+ index[skip + i] = index8[i];
+ }
+ else if (rb->DataType == GL_UNSIGNED_SHORT) {
+ GLushort index16[MAX_WIDTH];
+ GLint i;
+ rb->GetRow(ctx, rb, length, x + skip, y, index16);
+ for (i = 0; i < length; i++)
+ index[skip + i] = index16[i];
+ }
+ else if (rb->DataType == GL_UNSIGNED_INT) {
+ rb->GetRow(ctx, rb, length, x + skip, y, index + skip);
+ }
+ }
+}
+
+
+/**
+ * Wrapper for gl_renderbuffer::GetValues() which does clipping to avoid
+ * reading values outside the buffer bounds.
+ * We can use this for reading any format/type of renderbuffer.
+ * \param valueSize is the size in bytes of each value put into the
+ * values array.
+ */
+void
+_swrast_get_values(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ void *values, GLuint valueSize)
+{
+ GLuint i, inCount = 0, inStart = 0;
+
+ for (i = 0; i < count; i++) {
+ if (x[i] >= 0 && y[i] >= 0 && x[i] < rb->Width && y[i] < rb->Height) {
+ /* inside */
+ if (inCount == 0)
+ inStart = i;
+ inCount++;
+ }
+ else {
+ if (inCount > 0) {
+ /* read [inStart, inStart + inCount) */
+ rb->GetValues(ctx, rb, inCount, x + inStart, y + inStart,
+ (GLubyte *) values + inStart * valueSize);
+ inCount = 0;
+ }
+ }
+ }
+ if (inCount > 0) {
+ /* read last values */
+ rb->GetValues(ctx, rb, inCount, x + inStart, y + inStart,
+ (GLubyte *) values + inStart * valueSize);
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_span.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_span.h
new file mode 100644
index 000000000..1bba5aa53
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_span.h
@@ -0,0 +1,75 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_SPAN_H
+#define S_SPAN_H
+
+
+#include "mtypes.h"
+#include "swrast.h"
+
+
+extern void
+_swrast_span_default_z( GLcontext *ctx, struct sw_span *span );
+
+extern void
+_swrast_span_interpolate_z( const GLcontext *ctx, struct sw_span *span );
+
+extern void
+_swrast_span_default_fog( GLcontext *ctx, struct sw_span *span );
+
+extern void
+_swrast_span_default_color( GLcontext *ctx, struct sw_span *span );
+
+extern void
+_swrast_span_default_texcoords( GLcontext *ctx, struct sw_span *span );
+
+extern GLfloat
+_swrast_compute_lambda(GLfloat dsdx, GLfloat dsdy, GLfloat dtdx, GLfloat dtdy,
+ GLfloat dqdx, GLfloat dqdy, GLfloat texW, GLfloat texH,
+ GLfloat s, GLfloat t, GLfloat q, GLfloat invQ);
+
+extern void
+_swrast_write_index_span( GLcontext *ctx, struct sw_span *span);
+
+
+extern void
+_swrast_write_rgba_span( GLcontext *ctx, struct sw_span *span);
+
+
+extern void
+_swrast_read_rgba_span( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLchan rgba[][4] );
+
+extern void
+_swrast_read_index_span( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint n, GLint x, GLint y, GLuint indx[] );
+
+extern void
+_swrast_get_values(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ void *values, GLuint valueSize);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_spantemp.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_spantemp.h
new file mode 100644
index 000000000..4ccf031cb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_spantemp.h
@@ -0,0 +1,251 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/*
+ * Templates for the span/pixel-array write/read functions called via
+ * the gl_renderbuffer's GetRow, GetValues, PutRow, PutMonoRow, PutValues
+ * and PutMonoValues functions.
+ *
+ * Define the following macros before including this file:
+ * NAME(PREFIX) to generate the function name
+ * FORMAT must be either GL_RGBA, GL_RGBA8 or GL_COLOR_INDEX8_EXT
+ * SPAN_VARS to declare any local variables
+ * INIT_PIXEL_PTR(P, X, Y) to initialize a pointer to a pixel
+ * INC_PIXEL_PTR(P) to increment a pixel pointer by one pixel
+ * STORE_PIXEL(DST, X, Y, VALUE) to store pixel values in buffer
+ * FETCH_PIXEL(DST, SRC) to fetch pixel values from buffer
+ *
+ * Note that in the STORE_PIXEL macros, we also pass in the (X,Y) coordinates
+ * for the pixels to be stored. This is useful when dithering and probably
+ * ignored otherwise.
+ */
+
+#include "macros.h"
+
+
+static void
+NAME(get_row)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y, void *values )
+{
+#ifdef SPAN_VARS
+ SPAN_VARS
+#endif
+#if FORMAT == GL_RGBA
+ GLchan (*dest)[4] = (GLchan (*)[4]) values;
+#elif FORMAT == GL_RGBA8
+ GLubyte (*dest)[4] = (GLubyte (*)[4]) values;
+#elif FORMAT == GL_COLOR_INDEX8_EXT
+ GLubyte *dest = (GLubyte *) values;
+#else
+#error FORMAT must be set!!!!
+#endif
+ GLuint i;
+ INIT_PIXEL_PTR(pixel, x, y);
+ for (i = 0; i < count; i++) {
+ FETCH_PIXEL(dest[i], pixel);
+ INC_PIXEL_PTR(pixel);
+ }
+}
+
+static void
+NAME(get_values)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[], void *values )
+{
+#ifdef SPAN_VARS
+ SPAN_VARS
+#endif
+#if FORMAT == GL_RGBA
+ GLchan (*dest)[4] = (GLchan (*)[4]) values;
+#elif FORMAT == GL_RGBA8
+ GLubyte (*dest)[4] = (GLubyte (*)[4]) values;
+#elif FORMAT == GL_COLOR_INDEX8_EXT
+ GLubyte *dest = (GLubyte *) values;
+#endif
+ GLuint i;
+ for (i = 0; i < count; i++) {
+ INIT_PIXEL_PTR(pixel, x[i], y[i]);
+ FETCH_PIXEL(dest[i], pixel);
+ }
+}
+
+
+static void
+NAME(put_row)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y,
+ const void *values, const GLubyte mask[] )
+{
+#ifdef SPAN_VARS
+ SPAN_VARS
+#endif
+#if FORMAT == GL_RGBA
+ const GLchan (*src)[4] = (const GLchan (*)[4]) values;
+#elif FORMAT == GL_RGBA8
+ const GLubyte (*src)[4] = (const GLubyte (*)[4]) values;
+#elif FORMAT == GL_COLOR_INDEX8_EXT
+ const GLubyte (*src)[1] = (const GLubyte (*)[1]) values;
+#endif
+ GLuint i;
+ INIT_PIXEL_PTR(pixel, x, y);
+ if (mask) {
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ STORE_PIXEL(pixel, x + i, y, src[i]);
+ }
+ INC_PIXEL_PTR(pixel);
+ }
+ }
+ else {
+ for (i = 0; i < count; i++) {
+ STORE_PIXEL(pixel, x + i, y, src[i]);
+ INC_PIXEL_PTR(pixel);
+ }
+ }
+}
+
+#if (FORMAT == GL_RGBA) || (FORMAT == GL_RGBA8)
+static void
+NAME(put_row_rgb)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y,
+ const void *values, const GLubyte mask[] )
+{
+#ifdef SPAN_VARS
+ SPAN_VARS
+#endif
+#if FORMAT == GL_RGBA
+ const GLchan (*src)[3] = (const GLchan (*)[3]) values;
+#elif FORMAT == GL_RGBA8
+ const GLubyte (*src)[3] = (const GLubyte (*)[3]) values;
+#else
+#error bad format
+#endif
+ GLuint i;
+ INIT_PIXEL_PTR(pixel, x, y);
+ for (i = 0; i < count; i++) {
+ if (!mask || mask[i]) {
+#ifdef STORE_PIXEL_RGB
+ STORE_PIXEL_RGB(pixel, x + i, y, src[i]);
+#else
+ STORE_PIXEL(pixel, x + i, y, src[i]);
+#endif
+ }
+ INC_PIXEL_PTR(pixel);
+ }
+}
+#endif
+
+static void
+NAME(put_mono_row)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y,
+ const void *value, const GLubyte mask[] )
+{
+#ifdef SPAN_VARS
+ SPAN_VARS
+#endif
+#if FORMAT == GL_RGBA
+ const GLchan *src = (const GLchan *) value;
+#elif FORMAT == GL_RGBA8
+ const GLubyte *src = (const GLubyte *) value;
+#elif FORMAT == GL_COLOR_INDEX8_EXT
+ const GLubyte *src = (const GLubyte *) value;
+#endif
+ GLuint i;
+ INIT_PIXEL_PTR(pixel, x, y);
+ if (mask) {
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ STORE_PIXEL(pixel, x + i, y, src);
+ }
+ INC_PIXEL_PTR(pixel);
+ }
+ }
+ else {
+ for (i = 0; i < count; i++) {
+ STORE_PIXEL(pixel, x + i, y, src);
+ INC_PIXEL_PTR(pixel);
+ }
+ }
+}
+
+
+static void
+NAME(put_values)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *values, const GLubyte mask[] )
+{
+#ifdef SPAN_VARS
+ SPAN_VARS
+#endif
+#if FORMAT == GL_RGBA
+ const GLchan (*src)[4] = (const GLchan (*)[4]) values;
+#elif FORMAT == GL_RGBA8
+ const GLubyte (*src)[4] = (const GLubyte (*)[4]) values;
+#elif FORMAT == GL_COLOR_INDEX8_EXT
+ const GLubyte (*src)[1] = (const GLubyte (*)[1]) values;
+#endif
+ GLuint i;
+ ASSERT(mask);
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ INIT_PIXEL_PTR(pixel, x[i], y[i]);
+ STORE_PIXEL(pixel, x[i], y[i], src[i]);
+ }
+ }
+}
+
+
+static void
+NAME(put_mono_values)( GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLuint count, const GLint x[], const GLint y[],
+ const void *value, const GLubyte mask[] )
+{
+#ifdef SPAN_VARS
+ SPAN_VARS
+#endif
+#if FORMAT == GL_RGBA
+ const GLchan *src = (const GLchan *) value;
+#elif FORMAT == GL_RGBA8
+ const GLubyte *src = (const GLubyte *) value;
+#elif FORMAT == GL_COLOR_INDEX8_EXT
+ const GLubyte *src = (const GLubyte *) value;
+#endif
+ GLuint i;
+ ASSERT(mask);
+ for (i = 0; i < count; i++) {
+ if (mask[i]) {
+ INIT_PIXEL_PTR(pixel, x[i], y[i]);
+ STORE_PIXEL(pixel, x[i], y[i], src);
+ }
+ }
+}
+
+
+#undef NAME
+#undef SPAN_VARS
+#undef INIT_PIXEL_PTR
+#undef INC_PIXEL_PTR
+#undef STORE_PIXEL
+#undef STORE_PIXEL_RGB
+#undef FETCH_PIXEL
+#undef FORMAT
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_stencil.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_stencil.c
new file mode 100644
index 000000000..98638b244
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_stencil.c
@@ -0,0 +1,1221 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4.1
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+#include "fbobject.h"
+
+#include "s_context.h"
+#include "s_depth.h"
+#include "s_stencil.h"
+#include "s_span.h"
+
+
+
+/* Stencil Logic:
+
+IF stencil test fails THEN
+ Apply fail-op to stencil value
+ Don't write the pixel (RGBA,Z)
+ELSE
+ IF doing depth test && depth test fails THEN
+ Apply zfail-op to stencil value
+ Write RGBA and Z to appropriate buffers
+ ELSE
+ Apply zpass-op to stencil value
+ENDIF
+
+*/
+
+
+/**
+ * Apply the given stencil operator to the array of stencil values.
+ * Don't touch stencil[i] if mask[i] is zero.
+ * Input: n - size of stencil array
+ * oper - the stencil buffer operator
+ * face - 0 or 1 for front or back face operation
+ * stencil - array of stencil values
+ * mask - array [n] of flag: 1=apply operator, 0=don't apply operator
+ * Output: stencil - modified values
+ */
+static void
+apply_stencil_op( const GLcontext *ctx, GLenum oper, GLuint face,
+ GLuint n, GLstencil stencil[], const GLubyte mask[] )
+{
+ const GLstencil ref = ctx->Stencil.Ref[face];
+ const GLstencil wrtmask = ctx->Stencil.WriteMask[face];
+ const GLstencil invmask = (GLstencil) (~wrtmask);
+ GLuint i;
+
+ switch (oper) {
+ case GL_KEEP:
+ /* do nothing */
+ break;
+ case GL_ZERO:
+ if (invmask==0) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ stencil[i] = 0;
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ stencil[i] = (GLstencil) (stencil[i] & invmask);
+ }
+ }
+ }
+ break;
+ case GL_REPLACE:
+ if (invmask==0) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ stencil[i] = ref;
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil s = stencil[i];
+ stencil[i] = (GLstencil) ((invmask & s ) | (wrtmask & ref));
+ }
+ }
+ }
+ break;
+ case GL_INCR:
+ if (invmask==0) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil s = stencil[i];
+ if (s < STENCIL_MAX) {
+ stencil[i] = (GLstencil) (s+1);
+ }
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ /* VERIFY logic of adding 1 to a write-masked value */
+ GLstencil s = stencil[i];
+ if (s < STENCIL_MAX) {
+ stencil[i] = (GLstencil) ((invmask & s) | (wrtmask & (s+1)));
+ }
+ }
+ }
+ }
+ break;
+ case GL_DECR:
+ if (invmask==0) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil s = stencil[i];
+ if (s>0) {
+ stencil[i] = (GLstencil) (s-1);
+ }
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ /* VERIFY logic of subtracting 1 to a write-masked value */
+ GLstencil s = stencil[i];
+ if (s>0) {
+ stencil[i] = (GLstencil) ((invmask & s) | (wrtmask & (s-1)));
+ }
+ }
+ }
+ }
+ break;
+ case GL_INCR_WRAP_EXT:
+ if (invmask==0) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ stencil[i]++;
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil s = stencil[i];
+ stencil[i] = (GLstencil) ((invmask & s) | (wrtmask & (s+1)));
+ }
+ }
+ }
+ break;
+ case GL_DECR_WRAP_EXT:
+ if (invmask==0) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ stencil[i]--;
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil s = stencil[i];
+ stencil[i] = (GLstencil) ((invmask & s) | (wrtmask & (s-1)));
+ }
+ }
+ }
+ break;
+ case GL_INVERT:
+ if (invmask==0) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil s = stencil[i];
+ stencil[i] = (GLstencil) ~s;
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil s = stencil[i];
+ stencil[i] = (GLstencil) ((invmask & s) | (wrtmask & ~s));
+ }
+ }
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad stencil op in apply_stencil_op");
+ }
+}
+
+
+
+
+/**
+ * Apply stencil test to an array of stencil values (before depth buffering).
+ * Input: face - 0 or 1 for front or back-face polygons
+ * n - number of pixels in the array
+ * stencil - array of [n] stencil values
+ * mask - array [n] of flag: 0=skip the pixel, 1=stencil the pixel
+ * Output: mask - pixels which fail the stencil test will have their
+ * mask flag set to 0.
+ * stencil - updated stencil values (where the test passed)
+ * Return: GL_FALSE = all pixels failed, GL_TRUE = zero or more pixels passed.
+ */
+static GLboolean
+do_stencil_test( GLcontext *ctx, GLuint face, GLuint n, GLstencil stencil[],
+ GLubyte mask[] )
+{
+ GLubyte fail[MAX_WIDTH];
+ GLboolean allfail = GL_FALSE;
+ GLuint i;
+ GLstencil r, s;
+ const GLuint valueMask = ctx->Stencil.ValueMask[face];
+
+ ASSERT(n <= MAX_WIDTH);
+
+ /*
+ * Perform stencil test. The results of this operation are stored
+ * in the fail[] array:
+ * IF fail[i] is non-zero THEN
+ * the stencil fail operator is to be applied
+ * ELSE
+ * the stencil fail operator is not to be applied
+ * ENDIF
+ */
+ switch (ctx->Stencil.Function[face]) {
+ case GL_NEVER:
+ /* never pass; always fail */
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ mask[i] = 0;
+ fail[i] = 1;
+ }
+ else {
+ fail[i] = 0;
+ }
+ }
+ allfail = GL_TRUE;
+ break;
+ case GL_LESS:
+ r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ s = (GLstencil) (stencil[i] & valueMask);
+ if (r < s) {
+ /* passed */
+ fail[i] = 0;
+ }
+ else {
+ fail[i] = 1;
+ mask[i] = 0;
+ }
+ }
+ else {
+ fail[i] = 0;
+ }
+ }
+ break;
+ case GL_LEQUAL:
+ r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ s = (GLstencil) (stencil[i] & valueMask);
+ if (r <= s) {
+ /* pass */
+ fail[i] = 0;
+ }
+ else {
+ fail[i] = 1;
+ mask[i] = 0;
+ }
+ }
+ else {
+ fail[i] = 0;
+ }
+ }
+ break;
+ case GL_GREATER:
+ r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ s = (GLstencil) (stencil[i] & valueMask);
+ if (r > s) {
+ /* passed */
+ fail[i] = 0;
+ }
+ else {
+ fail[i] = 1;
+ mask[i] = 0;
+ }
+ }
+ else {
+ fail[i] = 0;
+ }
+ }
+ break;
+ case GL_GEQUAL:
+ r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ s = (GLstencil) (stencil[i] & valueMask);
+ if (r >= s) {
+ /* passed */
+ fail[i] = 0;
+ }
+ else {
+ fail[i] = 1;
+ mask[i] = 0;
+ }
+ }
+ else {
+ fail[i] = 0;
+ }
+ }
+ break;
+ case GL_EQUAL:
+ r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ s = (GLstencil) (stencil[i] & valueMask);
+ if (r == s) {
+ /* passed */
+ fail[i] = 0;
+ }
+ else {
+ fail[i] = 1;
+ mask[i] = 0;
+ }
+ }
+ else {
+ fail[i] = 0;
+ }
+ }
+ break;
+ case GL_NOTEQUAL:
+ r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ s = (GLstencil) (stencil[i] & valueMask);
+ if (r != s) {
+ /* passed */
+ fail[i] = 0;
+ }
+ else {
+ fail[i] = 1;
+ mask[i] = 0;
+ }
+ }
+ else {
+ fail[i] = 0;
+ }
+ }
+ break;
+ case GL_ALWAYS:
+ /* always pass */
+ for (i=0;i<n;i++) {
+ fail[i] = 0;
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad stencil func in gl_stencil_span");
+ return 0;
+ }
+
+ if (ctx->Stencil.FailFunc[face] != GL_KEEP) {
+ apply_stencil_op( ctx, ctx->Stencil.FailFunc[face], face, n, stencil, fail );
+ }
+
+ return !allfail;
+}
+
+
+
+/**
+ * Apply stencil and depth testing to the span of pixels.
+ * Both software and hardware stencil buffers are acceptable.
+ * Input: n - number of pixels in the span
+ * x, y - location of leftmost pixel in span
+ * z - array [n] of z values
+ * mask - array [n] of flags (1=test this pixel, 0=skip the pixel)
+ * Output: mask - array [n] of flags (1=stencil and depth test passed)
+ * Return: GL_FALSE - all fragments failed the testing
+ * GL_TRUE - one or more fragments passed the testing
+ *
+ */
+static GLboolean
+stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span, GLuint face)
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
+ GLstencil stencilRow[MAX_WIDTH];
+ GLstencil *stencil;
+ const GLuint n = span->end;
+ const GLint x = span->x;
+ const GLint y = span->y;
+ GLubyte *mask = span->array->mask;
+
+ ASSERT((span->arrayMask & SPAN_XY) == 0);
+ ASSERT(ctx->Stencil.Enabled);
+ ASSERT(n <= MAX_WIDTH);
+#ifdef DEBUG
+ if (ctx->Depth.Test) {
+ ASSERT(span->arrayMask & SPAN_Z);
+ }
+#endif
+
+ stencil = rb->GetPointer(ctx, rb, x, y);
+ if (!stencil) {
+ rb->GetRow(ctx, rb, n, x, y, stencilRow);
+ stencil = stencilRow;
+ }
+
+ /*
+ * Apply the stencil test to the fragments.
+ * failMask[i] is 1 if the stencil test failed.
+ */
+ if (do_stencil_test( ctx, face, n, stencil, mask ) == GL_FALSE) {
+ /* all fragments failed the stencil test, we're done. */
+ span->writeAll = GL_FALSE;
+ if (!rb->GetPointer(ctx, rb, 0, 0)) {
+ /* put updated stencil values into buffer */
+ rb->PutRow(ctx, rb, n, x, y, stencil, NULL);
+ }
+ return GL_FALSE;
+ }
+
+ /*
+ * Some fragments passed the stencil test, apply depth test to them
+ * and apply Zpass and Zfail stencil ops.
+ */
+ if (ctx->Depth.Test == GL_FALSE) {
+ /*
+ * No depth buffer, just apply zpass stencil function to active pixels.
+ */
+ apply_stencil_op( ctx, ctx->Stencil.ZPassFunc[face], face, n, stencil, mask );
+ }
+ else {
+ /*
+ * Perform depth buffering, then apply zpass or zfail stencil function.
+ */
+ GLubyte passmask[MAX_WIDTH], failmask[MAX_WIDTH], oldmask[MAX_WIDTH];
+ GLuint i;
+
+ /* save the current mask bits */
+ _mesa_memcpy(oldmask, mask, n * sizeof(GLubyte));
+
+ /* apply the depth test */
+ _swrast_depth_test_span(ctx, span);
+
+ /* Set the stencil pass/fail flags according to result of depth testing.
+ * if oldmask[i] == 0 then
+ * Don't touch the stencil value
+ * else if oldmask[i] and newmask[i] then
+ * Depth test passed
+ * else
+ * assert(oldmask[i] && !newmask[i])
+ * Depth test failed
+ * endif
+ */
+ for (i=0;i<n;i++) {
+ ASSERT(mask[i] == 0 || mask[i] == 1);
+ passmask[i] = oldmask[i] & mask[i];
+ failmask[i] = oldmask[i] & (mask[i] ^ 1);
+ }
+
+ /* apply the pass and fail operations */
+ if (ctx->Stencil.ZFailFunc[face] != GL_KEEP) {
+ apply_stencil_op( ctx, ctx->Stencil.ZFailFunc[face], face,
+ n, stencil, failmask );
+ }
+ if (ctx->Stencil.ZPassFunc[face] != GL_KEEP) {
+ apply_stencil_op( ctx, ctx->Stencil.ZPassFunc[face], face,
+ n, stencil, passmask );
+ }
+ }
+
+ /*
+ * Write updated stencil values back into hardware stencil buffer.
+ */
+ if (!rb->GetPointer(ctx, rb, 0, 0)) {
+ rb->PutRow(ctx, rb, n, x, y, stencil, NULL);
+ }
+
+ span->writeAll = GL_FALSE;
+
+ return GL_TRUE; /* one or more fragments passed both tests */
+}
+
+
+
+/*
+ * Return the address of a stencil buffer value given the window coords:
+ */
+#define STENCIL_ADDRESS(X, Y) (stencilStart + (Y) * stride + (X))
+
+
+
+/**
+ * Apply the given stencil operator for each pixel in the array whose
+ * mask flag is set.
+ * \note This is for software stencil buffers only.
+ * Input: n - number of pixels in the span
+ * x, y - array of [n] pixels
+ * operator - the stencil buffer operator
+ * mask - array [n] of flag: 1=apply operator, 0=don't apply operator
+ */
+static void
+apply_stencil_op_to_pixels( GLcontext *ctx,
+ GLuint n, const GLint x[], const GLint y[],
+ GLenum oper, GLuint face, const GLubyte mask[] )
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
+ const GLstencil ref = ctx->Stencil.Ref[face];
+ const GLstencil wrtmask = ctx->Stencil.WriteMask[face];
+ const GLstencil invmask = (GLstencil) (~wrtmask);
+ GLuint i;
+ GLstencil *stencilStart = (GLubyte *) rb->Data;
+ const GLuint stride = rb->Width;
+
+ ASSERT(rb->GetPointer(ctx, rb, 0, 0));
+ ASSERT(sizeof(GLstencil) == 1);
+
+ switch (oper) {
+ case GL_KEEP:
+ /* do nothing */
+ break;
+ case GL_ZERO:
+ if (invmask==0) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil *sptr = STENCIL_ADDRESS( x[i], y[i] );
+ *sptr = 0;
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil *sptr = STENCIL_ADDRESS( x[i], y[i] );
+ *sptr = (GLstencil) (invmask & *sptr);
+ }
+ }
+ }
+ break;
+ case GL_REPLACE:
+ if (invmask==0) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil *sptr = STENCIL_ADDRESS( x[i], y[i] );
+ *sptr = ref;
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil *sptr = STENCIL_ADDRESS( x[i], y[i] );
+ *sptr = (GLstencil) ((invmask & *sptr ) | (wrtmask & ref));
+ }
+ }
+ }
+ break;
+ case GL_INCR:
+ if (invmask==0) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil *sptr = STENCIL_ADDRESS( x[i], y[i] );
+ if (*sptr < STENCIL_MAX) {
+ *sptr = (GLstencil) (*sptr + 1);
+ }
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil *sptr = STENCIL_ADDRESS( x[i], y[i] );
+ if (*sptr < STENCIL_MAX) {
+ *sptr = (GLstencil) ((invmask & *sptr) | (wrtmask & (*sptr+1)));
+ }
+ }
+ }
+ }
+ break;
+ case GL_DECR:
+ if (invmask==0) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil *sptr = STENCIL_ADDRESS( x[i], y[i] );
+ if (*sptr>0) {
+ *sptr = (GLstencil) (*sptr - 1);
+ }
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil *sptr = STENCIL_ADDRESS( x[i], y[i] );
+ if (*sptr>0) {
+ *sptr = (GLstencil) ((invmask & *sptr) | (wrtmask & (*sptr-1)));
+ }
+ }
+ }
+ }
+ break;
+ case GL_INCR_WRAP_EXT:
+ if (invmask==0) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil *sptr = STENCIL_ADDRESS( x[i], y[i] );
+ *sptr = (GLstencil) (*sptr + 1);
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil *sptr = STENCIL_ADDRESS( x[i], y[i] );
+ *sptr = (GLstencil) ((invmask & *sptr) | (wrtmask & (*sptr+1)));
+ }
+ }
+ }
+ break;
+ case GL_DECR_WRAP_EXT:
+ if (invmask==0) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil *sptr = STENCIL_ADDRESS( x[i], y[i] );
+ *sptr = (GLstencil) (*sptr - 1);
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil *sptr = STENCIL_ADDRESS( x[i], y[i] );
+ *sptr = (GLstencil) ((invmask & *sptr) | (wrtmask & (*sptr-1)));
+ }
+ }
+ }
+ break;
+ case GL_INVERT:
+ if (invmask==0) {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil *sptr = STENCIL_ADDRESS( x[i], y[i] );
+ *sptr = (GLstencil) (~*sptr);
+ }
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ GLstencil *sptr = STENCIL_ADDRESS( x[i], y[i] );
+ *sptr = (GLstencil) ((invmask & *sptr) | (wrtmask & ~*sptr));
+ }
+ }
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad stencilop in apply_stencil_op_to_pixels");
+ }
+}
+
+
+
+/**
+ * Apply stencil test to an array of pixels before depth buffering.
+ *
+ * \note Used for software stencil buffer only.
+ * Input: n - number of pixels in the span
+ * x, y - array of [n] pixels to stencil
+ * mask - array [n] of flag: 0=skip the pixel, 1=stencil the pixel
+ * Output: mask - pixels which fail the stencil test will have their
+ * mask flag set to 0.
+ * \return GL_FALSE = all pixels failed, GL_TRUE = zero or more pixels passed.
+ */
+static GLboolean
+stencil_test_pixels( GLcontext *ctx, GLuint face, GLuint n,
+ const GLint x[], const GLint y[], GLubyte mask[] )
+{
+ const struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
+ GLubyte fail[MAX_WIDTH];
+ GLstencil r, s;
+ GLuint i;
+ GLboolean allfail = GL_FALSE;
+ const GLuint valueMask = ctx->Stencil.ValueMask[face];
+ const GLstencil *stencilStart = (GLstencil *) rb->Data;
+ const GLuint stride = rb->Width;
+
+ ASSERT(rb->GetPointer(ctx, rb, 0, 0));
+ ASSERT(sizeof(GLstencil) == 1);
+
+ /*
+ * Perform stencil test. The results of this operation are stored
+ * in the fail[] array:
+ * IF fail[i] is non-zero THEN
+ * the stencil fail operator is to be applied
+ * ELSE
+ * the stencil fail operator is not to be applied
+ * ENDIF
+ */
+
+ switch (ctx->Stencil.Function[face]) {
+ case GL_NEVER:
+ /* always fail */
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ mask[i] = 0;
+ fail[i] = 1;
+ }
+ else {
+ fail[i] = 0;
+ }
+ }
+ allfail = GL_TRUE;
+ break;
+ case GL_LESS:
+ r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ const GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
+ s = (GLstencil) (*sptr & valueMask);
+ if (r < s) {
+ /* passed */
+ fail[i] = 0;
+ }
+ else {
+ fail[i] = 1;
+ mask[i] = 0;
+ }
+ }
+ else {
+ fail[i] = 0;
+ }
+ }
+ break;
+ case GL_LEQUAL:
+ r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ const GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
+ s = (GLstencil) (*sptr & valueMask);
+ if (r <= s) {
+ /* pass */
+ fail[i] = 0;
+ }
+ else {
+ fail[i] = 1;
+ mask[i] = 0;
+ }
+ }
+ else {
+ fail[i] = 0;
+ }
+ }
+ break;
+ case GL_GREATER:
+ r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ const GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
+ s = (GLstencil) (*sptr & valueMask);
+ if (r > s) {
+ /* passed */
+ fail[i] = 0;
+ }
+ else {
+ fail[i] = 1;
+ mask[i] = 0;
+ }
+ }
+ else {
+ fail[i] = 0;
+ }
+ }
+ break;
+ case GL_GEQUAL:
+ r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ const GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
+ s = (GLstencil) (*sptr & valueMask);
+ if (r >= s) {
+ /* passed */
+ fail[i] = 0;
+ }
+ else {
+ fail[i] = 1;
+ mask[i] = 0;
+ }
+ }
+ else {
+ fail[i] = 0;
+ }
+ }
+ break;
+ case GL_EQUAL:
+ r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ const GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
+ s = (GLstencil) (*sptr & valueMask);
+ if (r == s) {
+ /* passed */
+ fail[i] = 0;
+ }
+ else {
+ fail[i] = 1;
+ mask[i] = 0;
+ }
+ }
+ else {
+ fail[i] = 0;
+ }
+ }
+ break;
+ case GL_NOTEQUAL:
+ r = (GLstencil) (ctx->Stencil.Ref[face] & valueMask);
+ for (i=0;i<n;i++) {
+ if (mask[i]) {
+ const GLstencil *sptr = STENCIL_ADDRESS(x[i],y[i]);
+ s = (GLstencil) (*sptr & valueMask);
+ if (r != s) {
+ /* passed */
+ fail[i] = 0;
+ }
+ else {
+ fail[i] = 1;
+ mask[i] = 0;
+ }
+ }
+ else {
+ fail[i] = 0;
+ }
+ }
+ break;
+ case GL_ALWAYS:
+ /* always pass */
+ for (i=0;i<n;i++) {
+ fail[i] = 0;
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad stencil func in gl_stencil_pixels");
+ return 0;
+ }
+
+ if (ctx->Stencil.FailFunc[face] != GL_KEEP) {
+ apply_stencil_op_to_pixels( ctx, n, x, y, ctx->Stencil.FailFunc[face],
+ face, fail );
+ }
+
+ return !allfail;
+}
+
+
+
+
+/**
+ * Apply stencil and depth testing to an array of pixels.
+ * This is used both for software and hardware stencil buffers.
+ *
+ * The comments in this function are a bit sparse but the code is
+ * almost identical to stencil_and_ztest_span(), which is well
+ * commented.
+ *
+ * Input: n - number of pixels in the array
+ * x, y - array of [n] pixel positions
+ * z - array [n] of z values
+ * mask - array [n] of flags (1=test this pixel, 0=skip the pixel)
+ * Output: mask - array [n] of flags (1=stencil and depth test passed)
+ * Return: GL_FALSE - all fragments failed the testing
+ * GL_TRUE - one or more fragments passed the testing
+ */
+static GLboolean
+stencil_and_ztest_pixels( GLcontext *ctx, struct sw_span *span, GLuint face )
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
+ const GLuint n = span->end;
+ const GLint *x = span->array->x;
+ const GLint *y = span->array->y;
+ GLubyte *mask = span->array->mask;
+
+ ASSERT(span->arrayMask & SPAN_XY);
+ ASSERT(ctx->Stencil.Enabled);
+ ASSERT(n <= MAX_WIDTH);
+
+ if (!rb->GetPointer(ctx, rb, 0, 0)) {
+ /* No direct access */
+ GLstencil stencil[MAX_WIDTH];
+ GLubyte origMask[MAX_WIDTH];
+
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ _swrast_get_values(ctx, rb, n, x, y, stencil, sizeof(GLubyte));
+
+ _mesa_memcpy(origMask, mask, n * sizeof(GLubyte));
+
+ (void) do_stencil_test(ctx, face, n, stencil, mask);
+
+ if (ctx->Depth.Test == GL_FALSE) {
+ apply_stencil_op(ctx, ctx->Stencil.ZPassFunc[face], face,
+ n, stencil, mask);
+ }
+ else {
+ _swrast_depth_test_span(ctx, span);
+
+ if (ctx->Stencil.ZFailFunc[face] != GL_KEEP) {
+ GLubyte failmask[MAX_WIDTH];
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ ASSERT(mask[i] == 0 || mask[i] == 1);
+ failmask[i] = origMask[i] & (mask[i] ^ 1);
+ }
+ apply_stencil_op(ctx, ctx->Stencil.ZFailFunc[face], face,
+ n, stencil, failmask);
+ }
+ if (ctx->Stencil.ZPassFunc[face] != GL_KEEP) {
+ GLubyte passmask[MAX_WIDTH];
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ ASSERT(mask[i] == 0 || mask[i] == 1);
+ passmask[i] = origMask[i] & mask[i];
+ }
+ apply_stencil_op(ctx, ctx->Stencil.ZPassFunc[face], face,
+ n, stencil, passmask);
+ }
+ }
+
+ /* Write updated stencil values into hardware stencil buffer */
+ rb->PutValues(ctx, rb, n, x, y, stencil, origMask);
+
+ return GL_TRUE;
+ }
+ else {
+ /* Direct access to stencil buffer */
+
+ if (stencil_test_pixels(ctx, face, n, x, y, mask) == GL_FALSE) {
+ /* all fragments failed the stencil test, we're done. */
+ return GL_FALSE;
+ }
+
+ if (ctx->Depth.Test==GL_FALSE) {
+ apply_stencil_op_to_pixels(ctx, n, x, y,
+ ctx->Stencil.ZPassFunc[face], face, mask);
+ }
+ else {
+ GLubyte passmask[MAX_WIDTH], failmask[MAX_WIDTH], oldmask[MAX_WIDTH];
+ GLuint i;
+
+ _mesa_memcpy(oldmask, mask, n * sizeof(GLubyte));
+
+ _swrast_depth_test_span(ctx, span);
+
+ for (i=0;i<n;i++) {
+ ASSERT(mask[i] == 0 || mask[i] == 1);
+ passmask[i] = oldmask[i] & mask[i];
+ failmask[i] = oldmask[i] & (mask[i] ^ 1);
+ }
+
+ if (ctx->Stencil.ZFailFunc[face] != GL_KEEP) {
+ apply_stencil_op_to_pixels(ctx, n, x, y,
+ ctx->Stencil.ZFailFunc[face],
+ face, failmask);
+ }
+ if (ctx->Stencil.ZPassFunc[face] != GL_KEEP) {
+ apply_stencil_op_to_pixels(ctx, n, x, y,
+ ctx->Stencil.ZPassFunc[face],
+ face, passmask);
+ }
+ }
+
+ return GL_TRUE; /* one or more fragments passed both tests */
+ }
+}
+
+
+/**
+ * /return GL_TRUE = one or more fragments passed,
+ * GL_FALSE = all fragments failed.
+ */
+GLboolean
+_swrast_stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span)
+{
+ /* span->facing can only be non-zero if using two-sided stencil */
+ ASSERT(ctx->Stencil.TestTwoSide || span->facing == 0);
+ if (span->arrayMask & SPAN_XY)
+ return stencil_and_ztest_pixels(ctx, span, span->facing);
+ else
+ return stencil_and_ztest_span(ctx, span, span->facing);
+}
+
+
+#if 0
+GLuint
+clip_span(GLuint bufferWidth, GLuint bufferHeight,
+ GLint x, GLint y, GLuint *count)
+{
+ GLuint n = *count;
+ GLuint skipPixels = 0;
+
+ if (y < 0 || y >= bufferHeight || x + n <= 0 || x >= bufferWidth) {
+ /* totally out of bounds */
+ n = 0;
+ }
+ else {
+ /* left clip */
+ if (x < 0) {
+ skipPixels = -x;
+ x = 0;
+ n -= skipPixels;
+ }
+ /* right clip */
+ if (x + n > bufferWidth) {
+ GLint dx = x + n - bufferWidth;
+ n -= dx;
+ }
+ }
+
+ *count = n;
+
+ return skipPixels;
+}
+#endif
+
+
+/**
+ * Return a span of stencil values from the stencil buffer.
+ * Used for glRead/CopyPixels
+ * Input: n - how many pixels
+ * x,y - location of first pixel
+ * Output: stencil - the array of stencil values
+ */
+void
+_swrast_read_stencil_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint n, GLint x, GLint y, GLstencil stencil[])
+{
+ if (y < 0 || y >= rb->Height || x + n <= 0 || x >= rb->Width) {
+ /* span is completely outside framebuffer */
+ return; /* undefined values OK */
+ }
+
+ if (x < 0) {
+ GLint dx = -x;
+ x = 0;
+ n -= dx;
+ stencil += dx;
+ }
+ if (x + n > rb->Width) {
+ GLint dx = x + n - rb->Width;
+ n -= dx;
+ }
+ if (n <= 0) {
+ return;
+ }
+
+ rb->GetRow(ctx, rb, n, x, y, stencil);
+}
+
+
+
+/**
+ * Write a span of stencil values to the stencil buffer.
+ * Used for glDraw/CopyPixels
+ * Input: n - how many pixels
+ * x, y - location of first pixel
+ * stencil - the array of stencil values
+ */
+void
+_swrast_write_stencil_span(GLcontext *ctx, GLint n, GLint x, GLint y,
+ const GLstencil stencil[] )
+{
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
+ struct gl_renderbuffer *rb = fb->Attachment[BUFFER_STENCIL].Renderbuffer;
+ const GLuint stencilMax = (1 << fb->Visual.stencilBits) - 1;
+ const GLuint stencilMask = ctx->Stencil.WriteMask[0];
+
+ if (y < 0 || y >= rb->Height || x + n <= 0 || x >= rb->Width) {
+ /* span is completely outside framebuffer */
+ return; /* undefined values OK */
+ }
+ if (x < 0) {
+ GLint dx = -x;
+ x = 0;
+ n -= dx;
+ stencil += dx;
+ }
+ if (x + n > rb->Width) {
+ GLint dx = x + n - rb->Width;
+ n -= dx;
+ }
+ if (n <= 0) {
+ return;
+ }
+
+ if ((stencilMask & stencilMax) != stencilMax) {
+ /* need to apply writemask */
+ GLstencil destVals[MAX_WIDTH], newVals[MAX_WIDTH];
+ GLint i;
+ rb->GetRow(ctx, rb, n, x, y, destVals);
+ for (i = 0; i < n; i++) {
+ newVals[i]
+ = (stencil[i] & stencilMask) | (destVals[i] & ~stencilMask);
+ }
+ rb->PutRow(ctx, rb, n, x, y, newVals, NULL);
+ }
+ else {
+ rb->PutRow(ctx, rb, n, x, y, stencil, NULL);
+ }
+}
+
+
+
+/**
+ * Clear the stencil buffer.
+ */
+void
+_swrast_clear_stencil_buffer( GLcontext *ctx, struct gl_renderbuffer *rb )
+{
+ const GLstencil mask = ctx->Stencil.WriteMask[0];
+ const GLstencil invMask = ~mask;
+ const GLstencil clearVal = (ctx->Stencil.Clear & mask);
+ GLint x, y, width, height;
+
+ if (!rb || mask == 0)
+ return;
+
+ ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
+ ASSERT(rb->_BaseFormat == GL_STENCIL_INDEX);
+
+ /* compute region to clear */
+ x = ctx->DrawBuffer->_Xmin;
+ y = ctx->DrawBuffer->_Ymin;
+ width = ctx->DrawBuffer->_Xmax - ctx->DrawBuffer->_Xmin;
+ height = ctx->DrawBuffer->_Ymax - ctx->DrawBuffer->_Ymin;
+
+ if (rb->GetPointer(ctx, rb, 0, 0)) {
+ /* Direct buffer access */
+ if (ctx->Stencil.WriteMask[0] != STENCIL_MAX) {
+ /* need to mask the clear */
+ GLint i, j;
+ for (i = 0; i < height; i++) {
+ GLubyte *stencil = rb->GetPointer(ctx, rb, x, y + i);
+ for (j = 0; j < width; j++) {
+ stencil[j] = (stencil[j] & invMask) | clearVal;
+ }
+ }
+ }
+ else {
+ /* no bit masking */
+ if (width == rb->Width &&
+ rb->InternalFormat == GL_STENCIL_INDEX8_EXT) {
+ /* optimized case */
+ GLubyte *stencil = rb->GetPointer(ctx, rb, x, y);
+ GLuint len = width * height * sizeof(GLubyte);
+ _mesa_memset(stencil, clearVal, len);
+ }
+ else {
+ /* general case */
+ GLint i, j;
+ for (i = 0; i < height; i++) {
+ GLubyte *stencil = rb->GetPointer(ctx, rb, x, y + i);
+ for (j = 0; j < width; j++) {
+ stencil[j] = clearVal;
+ }
+ }
+ }
+ }
+ }
+ else {
+ /* no direct access */
+ if (ctx->Stencil.WriteMask[0] != STENCIL_MAX) {
+ /* need to mask the clear */
+ GLint i, j;
+ for (i = 0; i < height; i++) {
+ GLubyte stencil[MAX_WIDTH];
+ rb->GetRow(ctx, rb, width, x, y + i, stencil);
+ for (j = 0; j < width; j++) {
+ stencil[j] = (stencil[j] & invMask) | clearVal;
+ }
+ rb->PutRow(ctx, rb, width, x, y + i, stencil, NULL);
+ }
+ }
+ else {
+ /* no bit masking */
+ const GLubyte clear8 = clearVal;
+ GLint i;
+ for (i = 0; i < height; i++) {
+ rb->PutMonoRow(ctx, rb, width, x, y + i, &clear8, NULL);
+ }
+ }
+ }
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_stencil.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_stencil.h
new file mode 100644
index 000000000..fabc25250
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_stencil.h
@@ -0,0 +1,53 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_STENCIL_H
+#define S_STENCIL_H
+
+
+#include "mtypes.h"
+#include "swrast.h"
+
+
+
+extern GLboolean
+_swrast_stencil_and_ztest_span(GLcontext *ctx, struct sw_span *span);
+
+
+extern void
+_swrast_read_stencil_span(GLcontext *ctx, struct gl_renderbuffer *rb,
+ GLint n, GLint x, GLint y, GLstencil stencil[]);
+
+
+extern void
+_swrast_write_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y,
+ const GLstencil stencil[] );
+
+
+extern void
+_swrast_clear_stencil_buffer( GLcontext *ctx, struct gl_renderbuffer *rb );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_tcc.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_tcc.c
new file mode 100644
index 000000000..550a2aabd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_tcc.c
@@ -0,0 +1,189 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+/* An attempt to hook s_fragprog_to_c.c up to libtcc.a to try &
+ * generate some real code.
+ *
+ * TCC isn't threadsafe, so it will need additional locking help if we
+ * end up using it as a backend in mesa.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "nvfragprog.h"
+#include "macros.h"
+#include "program.h"
+
+#include "s_nvfragprog.h"
+#include "s_texture.h"
+
+#ifdef USE_TCC
+
+#include <libtcc.h>
+
+typedef int (*cfunc)( void *ctx,
+ const GLfloat (*local_param)[4],
+ const GLfloat (*env_param)[4],
+ const struct program_parameter *state_param,
+ const GLfloat (*interp)[4],
+ GLfloat (*outputs)[4]);
+
+
+static cfunc current_func;
+static struct fragment_program *current_program;
+static TCCState *current_tcc_state;
+
+
+static void TEX( void *cc, const float *texcoord, int unit, float *result )
+{
+ GLcontext *ctx = (GLcontext *)cc;
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLfloat lambda = 1.0; /* hack */
+ GLchan rgba[4];
+
+ swrast->TextureSample[unit](ctx, unit, ctx->Texture.Unit[unit]._Current,
+ 1, (const GLfloat (*)[4]) texcoord,
+ &lambda, &rgba);
+
+ result[0] = CHAN_TO_FLOAT(rgba[0]);
+ result[1] = CHAN_TO_FLOAT(rgba[1]);
+ result[2] = CHAN_TO_FLOAT(rgba[2]);
+ result[3] = CHAN_TO_FLOAT(rgba[3]);
+}
+
+
+static void TXB( void *cc, const float *texcoord, int unit, float *result )
+{
+ GLcontext *ctx = (GLcontext *)cc;
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLfloat lambda = 1.0; /* hack */
+ GLchan rgba[4];
+
+ /* texcoord[3] is the bias to add to lambda */
+ lambda += texcoord[3];
+
+
+ /* Is it necessary to reset texcoord[3] to 1 at this point?
+ */
+ swrast->TextureSample[unit](ctx, unit, ctx->Texture.Unit[unit]._Current,
+ 1, (const GLfloat (*)[4]) texcoord,
+ &lambda, &rgba);
+
+ result[0] = CHAN_TO_FLOAT(rgba[0]);
+ result[1] = CHAN_TO_FLOAT(rgba[1]);
+ result[2] = CHAN_TO_FLOAT(rgba[2]);
+ result[3] = CHAN_TO_FLOAT(rgba[3]);
+}
+
+
+static void TXP( void *cc, const float *texcoord, int unit, float *result )
+{
+ /* I think that TEX needs to undo the perspective divide which has
+ * already occurred. In the meantime, TXP is correct to do this:
+ */
+ TEX( cc, texcoord, unit, result );
+}
+
+
+static cfunc codegen( TCCState *s, const char *prog, const char *fname )
+{
+ unsigned long val;
+
+ if (s)
+ tcc_delete(s);
+
+ s = tcc_new();
+ if (!s)
+ return 0;
+
+ tcc_set_output_type(s, TCC_OUTPUT_MEMORY);
+ tcc_compile_string(s, prog);
+
+/* tcc_add_dll("/usr/lib/libm.so"); */
+
+ tcc_add_symbol(s, "TEX", (unsigned long)&TEX);
+ tcc_add_symbol(s, "TXB", (unsigned long)&TXB);
+ tcc_add_symbol(s, "TXP", (unsigned long)&TXP);
+
+
+ tcc_relocate(s);
+ tcc_get_symbol(s, &val, fname);
+ return (cfunc) val;
+}
+
+/* TCC isn't threadsafe and even seems not to like having more than
+ * one TCCState created or used at any one time in a single threaded
+ * environment. So, this code is all for investigation only and can't
+ * currently be used in Mesa proper.
+ *
+ * I've taken some liberties with globals myself, now.
+ */
+GLboolean
+_swrast_execute_codegen_program( GLcontext *ctx,
+ const struct fragment_program *program, GLuint maxInst,
+ struct fp_machine *machine, const struct sw_span *span,
+ GLuint column )
+{
+ if (program != current_program) {
+
+ _swrast_translate_program( ctx );
+
+ fprintf(stderr, "%s: compiling:\n%s\n", __FUNCTION__, program->c_str);
+
+ current_program = program;
+ current_func = codegen( current_tcc_state, program->c_str,
+ "run_program" );
+ }
+
+ assert(current_func);
+
+ return current_func( ctx,
+ program->Base.LocalParams,
+ (const GLfloat (*)[4])ctx->FragmentProgram.Parameters,
+ program->Parameters->Parameters,
+ (const GLfloat (*)[4])machine->Inputs,
+ machine->Outputs );
+}
+
+#else /* USE_TCC */
+
+GLboolean
+_swrast_execute_codegen_program( GLcontext *ctx,
+ const struct fragment_program *program, GLuint maxInst,
+ struct fp_machine *machine, const struct sw_span *span,
+ GLuint column )
+{
+ (void) ctx;
+ (void) program; (void) maxInst;
+ (void) machine; (void) span;
+ (void) column;
+ return 0;
+}
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_texstore.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_texstore.c
new file mode 100644
index 000000000..24470a735
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_texstore.c
@@ -0,0 +1,430 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+/*
+ * Authors:
+ * Brian Paul
+ */
+
+
+/*
+ * The functions in this file are mostly related to software texture fallbacks.
+ * This includes texture image transfer/packing and texel fetching.
+ * Hardware drivers will likely override most of this.
+ */
+
+
+
+#include "glheader.h"
+#include "imports.h"
+#include "colormac.h"
+#include "context.h"
+#include "convolve.h"
+#include "image.h"
+#include "macros.h"
+#include "texformat.h"
+#include "teximage.h"
+#include "texstore.h"
+
+#include "s_context.h"
+#include "s_depth.h"
+#include "s_span.h"
+
+/*
+ * Read an RGBA image from the frame buffer.
+ * This is used by glCopyTex[Sub]Image[12]D().
+ * Input: ctx - the context
+ * x, y - lower left corner
+ * width, height - size of region to read
+ * Return: pointer to block of GL_RGBA, GLchan data.
+ */
+static GLchan *
+read_color_image( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLint stride, i;
+ GLchan *image, *dst;
+
+ image = (GLchan *) _mesa_malloc(width * height * 4 * sizeof(GLchan));
+ if (!image)
+ return NULL;
+
+ /* Select buffer to read from */
+ _swrast_use_read_buffer(ctx);
+
+ RENDER_START(swrast,ctx);
+
+ dst = image;
+ stride = width * 4;
+ for (i = 0; i < height; i++) {
+ _swrast_read_rgba_span(ctx, ctx->ReadBuffer->_ColorReadBuffer,
+ width, x, y + i, (GLchan (*)[4]) dst);
+ dst += stride;
+ }
+
+ RENDER_FINISH(swrast,ctx);
+
+ /* Read from draw buffer (the default) */
+ _swrast_use_draw_buffer(ctx);
+
+ return image;
+}
+
+
+/*
+ * As above, but read data from depth buffer.
+ */
+static GLfloat *
+read_depth_image( GLcontext *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height )
+{
+ struct gl_renderbuffer *rb
+ = ctx->ReadBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLfloat *image, *dst;
+ GLint i;
+
+ image = (GLfloat *) _mesa_malloc(width * height * sizeof(GLfloat));
+ if (!image)
+ return NULL;
+
+ RENDER_START(swrast,ctx);
+
+ dst = image;
+ for (i = 0; i < height; i++) {
+ _swrast_read_depth_span_float(ctx, rb, width, x, y + i, dst);
+ dst += width;
+ }
+
+ RENDER_FINISH(swrast,ctx);
+
+ return image;
+}
+
+
+
+static GLboolean
+is_depth_format(GLenum format)
+{
+ switch (format) {
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT16_SGIX:
+ case GL_DEPTH_COMPONENT24_SGIX:
+ case GL_DEPTH_COMPONENT32_SGIX:
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
+
+/*
+ * Fallback for Driver.CopyTexImage1D().
+ */
+void
+_swrast_copy_teximage1d( GLcontext *ctx, GLenum target, GLint level,
+ GLenum internalFormat,
+ GLint x, GLint y, GLsizei width, GLint border )
+{
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ ASSERT(texObj);
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ ASSERT(texImage);
+
+ ASSERT(ctx->Driver.TexImage1D);
+
+ if (is_depth_format(internalFormat)) {
+ /* read depth image from framebuffer */
+ GLfloat *image = read_depth_image(ctx, x, y, width, 1);
+ if (!image) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage1D");
+ return;
+ }
+
+ /* call glTexImage1D to redefine the texture */
+ (*ctx->Driver.TexImage1D)(ctx, target, level, internalFormat,
+ width, border,
+ GL_DEPTH_COMPONENT, GL_FLOAT, image,
+ &ctx->DefaultPacking, texObj, texImage);
+ _mesa_free(image);
+ }
+ else {
+ /* read RGBA image from framebuffer */
+ GLchan *image = read_color_image(ctx, x, y, width, 1);
+ if (!image) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage1D");
+ return;
+ }
+
+ /* call glTexImage1D to redefine the texture */
+ (*ctx->Driver.TexImage1D)(ctx, target, level, internalFormat,
+ width, border,
+ GL_RGBA, CHAN_TYPE, image,
+ &ctx->DefaultPacking, texObj, texImage);
+ _mesa_free(image);
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target, texUnit, texObj);
+ }
+}
+
+
+/*
+ * Fallback for Driver.CopyTexImage2D().
+ */
+void
+_swrast_copy_teximage2d( GLcontext *ctx, GLenum target, GLint level,
+ GLenum internalFormat,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLint border )
+{
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ ASSERT(texObj);
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ ASSERT(texImage);
+
+ ASSERT(ctx->Driver.TexImage2D);
+
+ if (is_depth_format(internalFormat)) {
+ /* read depth image from framebuffer */
+ GLfloat *image = read_depth_image(ctx, x, y, width, height);
+ if (!image) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D");
+ return;
+ }
+
+ /* call glTexImage2D to redefine the texture */
+ (*ctx->Driver.TexImage2D)(ctx, target, level, internalFormat,
+ width, height, border,
+ GL_DEPTH_COMPONENT, GL_FLOAT, image,
+ &ctx->DefaultPacking, texObj, texImage);
+ _mesa_free(image);
+ }
+ else {
+ /* read RGBA image from framebuffer */
+ GLchan *image = read_color_image(ctx, x, y, width, height);
+ if (!image) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D");
+ return;
+ }
+
+ /* call glTexImage2D to redefine the texture */
+ (*ctx->Driver.TexImage2D)(ctx, target, level, internalFormat,
+ width, height, border,
+ GL_RGBA, CHAN_TYPE, image,
+ &ctx->DefaultPacking, texObj, texImage);
+ _mesa_free(image);
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target, texUnit, texObj);
+ }
+}
+
+
+/*
+ * Fallback for Driver.CopyTexSubImage1D().
+ */
+void
+_swrast_copy_texsubimage1d( GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint x, GLint y, GLsizei width )
+{
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ ASSERT(texObj);
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ ASSERT(texImage);
+
+ ASSERT(ctx->Driver.TexImage1D);
+
+ if (texImage->Format == GL_DEPTH_COMPONENT) {
+ /* read depth image from framebuffer */
+ GLfloat *image = read_depth_image(ctx, x, y, width, 1);
+ if (!image) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D");
+ return;
+ }
+
+ /* call glTexSubImage1D to redefine the texture */
+ (*ctx->Driver.TexSubImage1D)(ctx, target, level, xoffset, width,
+ GL_DEPTH_COMPONENT, GL_FLOAT, image,
+ &ctx->DefaultPacking, texObj, texImage);
+ _mesa_free(image);
+ }
+ else {
+ /* read RGBA image from framebuffer */
+ GLchan *image = read_color_image(ctx, x, y, width, 1);
+ if (!image) {
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage1D" );
+ return;
+ }
+
+ /* now call glTexSubImage1D to do the real work */
+ (*ctx->Driver.TexSubImage1D)(ctx, target, level, xoffset, width,
+ GL_RGBA, CHAN_TYPE, image,
+ &ctx->DefaultPacking, texObj, texImage);
+ _mesa_free(image);
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target, texUnit, texObj);
+ }
+}
+
+
+/*
+ * Fallback for Driver.CopyTexSubImage2D().
+ */
+void
+_swrast_copy_texsubimage2d( GLcontext *ctx,
+ GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint x, GLint y, GLsizei width, GLsizei height )
+{
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ ASSERT(texObj);
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ ASSERT(texImage);
+
+ ASSERT(ctx->Driver.TexImage2D);
+
+ if (texImage->Format == GL_DEPTH_COMPONENT) {
+ /* read depth image from framebuffer */
+ GLfloat *image = read_depth_image(ctx, x, y, width, height);
+ if (!image) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D");
+ return;
+ }
+
+ /* call glTexImage1D to redefine the texture */
+ (*ctx->Driver.TexSubImage2D)(ctx, target, level,
+ xoffset, yoffset, width, height,
+ GL_DEPTH_COMPONENT, GL_FLOAT, image,
+ &ctx->DefaultPacking, texObj, texImage);
+ _mesa_free(image);
+ }
+ else {
+ /* read RGBA image from framebuffer */
+ GLchan *image = read_color_image(ctx, x, y, width, height);
+ if (!image) {
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage2D" );
+ return;
+ }
+
+ /* now call glTexSubImage2D to do the real work */
+ (*ctx->Driver.TexSubImage2D)(ctx, target, level,
+ xoffset, yoffset, width, height,
+ GL_RGBA, CHAN_TYPE, image,
+ &ctx->DefaultPacking, texObj, texImage);
+ _mesa_free(image);
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target, texUnit, texObj);
+ }
+}
+
+
+/*
+ * Fallback for Driver.CopyTexSubImage3D().
+ */
+void
+_swrast_copy_texsubimage3d( GLcontext *ctx,
+ GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLint x, GLint y, GLsizei width, GLsizei height )
+{
+ struct gl_texture_unit *texUnit;
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+
+ texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ ASSERT(texObj);
+ texImage = _mesa_select_tex_image(ctx, texUnit, target, level);
+ ASSERT(texImage);
+
+ ASSERT(ctx->Driver.TexImage3D);
+
+ if (texImage->Format == GL_DEPTH_COMPONENT) {
+ /* read depth image from framebuffer */
+ GLfloat *image = read_depth_image(ctx, x, y, width, height);
+ if (!image) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D");
+ return;
+ }
+
+ /* call glTexImage1D to redefine the texture */
+ (*ctx->Driver.TexSubImage3D)(ctx, target, level,
+ xoffset, yoffset, zoffset, width, height, 1,
+ GL_DEPTH_COMPONENT, GL_FLOAT, image,
+ &ctx->DefaultPacking, texObj, texImage);
+ _mesa_free(image);
+ }
+ else {
+ /* read RGBA image from framebuffer */
+ GLchan *image = read_color_image(ctx, x, y, width, height);
+ if (!image) {
+ _mesa_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexSubImage3D" );
+ return;
+ }
+
+ /* now call glTexSubImage3D to do the real work */
+ (*ctx->Driver.TexSubImage3D)(ctx, target, level,
+ xoffset, yoffset, zoffset, width, height, 1,
+ GL_RGBA, CHAN_TYPE, image,
+ &ctx->DefaultPacking, texObj, texImage);
+ _mesa_free(image);
+ }
+
+ /* GL_SGIS_generate_mipmap */
+ if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
+ _mesa_generate_mipmap(ctx, target, texUnit, texObj);
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_texture.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_texture.c
new file mode 100644
index 000000000..c75d826d2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_texture.c
@@ -0,0 +1,3963 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "colormac.h"
+#include "macros.h"
+#include "imports.h"
+#include "pixel.h"
+#include "texformat.h"
+#include "teximage.h"
+
+#include "s_context.h"
+#include "s_texture.h"
+
+
+/**
+ * Constants for integer linear interpolation.
+ */
+#define ILERP_SCALE 65536.0F
+#define ILERP_SHIFT 16
+
+
+/**
+ * Linear interpolation macros
+ */
+#define LERP(T, A, B) ( (A) + (T) * ((B) - (A)) )
+#define ILERP(IT, A, B) ( (A) + (((IT) * ((B) - (A))) >> ILERP_SHIFT) )
+
+
+/**
+ * Do 2D/biliner interpolation of float values.
+ * v00, v10, v01 and v11 are typically four texture samples in a square/box.
+ * a and b are the horizontal and vertical interpolants.
+ * It's important that this function is inlined when compiled with
+ * optimization! If we find that's not true on some systems, convert
+ * to a macro.
+ */
+static INLINE GLfloat
+lerp_2d(GLfloat a, GLfloat b,
+ GLfloat v00, GLfloat v10, GLfloat v01, GLfloat v11)
+{
+ const GLfloat temp0 = LERP(a, v00, v10);
+ const GLfloat temp1 = LERP(a, v01, v11);
+ return LERP(b, temp0, temp1);
+}
+
+
+/**
+ * Do 2D/biliner interpolation of integer values.
+ * \sa lerp_2d
+ */
+static INLINE GLint
+ilerp_2d(GLint ia, GLint ib,
+ GLint v00, GLint v10, GLint v01, GLint v11)
+{
+ /* fixed point interpolants in [0, ILERP_SCALE] */
+ const GLint temp0 = ILERP(ia, v00, v10);
+ const GLint temp1 = ILERP(ia, v01, v11);
+ return ILERP(ib, temp0, temp1);
+}
+
+
+/**
+ * Do 3D/trilinear interpolation of float values.
+ * \sa lerp_2d
+ */
+static INLINE GLfloat
+lerp_3d(GLfloat a, GLfloat b, GLfloat c,
+ GLfloat v000, GLfloat v100, GLfloat v010, GLfloat v110,
+ GLfloat v001, GLfloat v101, GLfloat v011, GLfloat v111)
+{
+ const GLfloat temp00 = LERP(a, v000, v100);
+ const GLfloat temp10 = LERP(a, v010, v110);
+ const GLfloat temp01 = LERP(a, v001, v101);
+ const GLfloat temp11 = LERP(a, v011, v111);
+ const GLfloat temp0 = LERP(b, temp00, temp10);
+ const GLfloat temp1 = LERP(b, temp01, temp11);
+ return LERP(c, temp0, temp1);
+}
+
+
+/**
+ * Do 3D/trilinear interpolation of integer values.
+ * \sa lerp_2d
+ */
+static INLINE GLint
+ilerp_3d(GLint ia, GLint ib, GLint ic,
+ GLint v000, GLint v100, GLint v010, GLint v110,
+ GLint v001, GLint v101, GLint v011, GLint v111)
+{
+ /* fixed point interpolants in [0, ILERP_SCALE] */
+ const GLint temp00 = ILERP(ia, v000, v100);
+ const GLint temp10 = ILERP(ia, v010, v110);
+ const GLint temp01 = ILERP(ia, v001, v101);
+ const GLint temp11 = ILERP(ia, v011, v111);
+ const GLint temp0 = ILERP(ib, temp00, temp10);
+ const GLint temp1 = ILERP(ib, temp01, temp11);
+ return ILERP(ic, temp0, temp1);
+}
+
+
+
+/**
+ * Compute the remainder of a divided by b, but be careful with
+ * negative values so that GL_REPEAT mode works right.
+ */
+static INLINE GLint
+repeat_remainder(GLint a, GLint b)
+{
+ if (a >= 0)
+ return a % b;
+ else
+ return (a + 1) % b + b - 1;
+}
+
+
+/**
+ * Used to compute texel locations for linear sampling.
+ * Input:
+ * wrapMode = GL_REPEAT, GL_CLAMP, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_BORDER
+ * S = texcoord in [0,1]
+ * SIZE = width (or height or depth) of texture
+ * Output:
+ * U = texcoord in [0, width]
+ * I0, I1 = two nearest texel indexes
+ */
+#define COMPUTE_LINEAR_TEXEL_LOCATIONS(wrapMode, S, U, SIZE, I0, I1) \
+{ \
+ if (wrapMode == GL_REPEAT) { \
+ U = S * SIZE - 0.5F; \
+ if (tObj->_IsPowerOfTwo) { \
+ I0 = IFLOOR(U) & (SIZE - 1); \
+ I1 = (I0 + 1) & (SIZE - 1); \
+ } \
+ else { \
+ I0 = repeat_remainder(IFLOOR(U), SIZE); \
+ I1 = repeat_remainder(I0 + 1, SIZE); \
+ } \
+ } \
+ else if (wrapMode == GL_CLAMP_TO_EDGE) { \
+ if (S <= 0.0F) \
+ U = 0.0F; \
+ else if (S >= 1.0F) \
+ U = (GLfloat) SIZE; \
+ else \
+ U = S * SIZE; \
+ U -= 0.5F; \
+ I0 = IFLOOR(U); \
+ I1 = I0 + 1; \
+ if (I0 < 0) \
+ I0 = 0; \
+ if (I1 >= (GLint) SIZE) \
+ I1 = SIZE - 1; \
+ } \
+ else if (wrapMode == GL_CLAMP_TO_BORDER) { \
+ const GLfloat min = -1.0F / (2.0F * SIZE); \
+ const GLfloat max = 1.0F - min; \
+ if (S <= min) \
+ U = min * SIZE; \
+ else if (S >= max) \
+ U = max * SIZE; \
+ else \
+ U = S * SIZE; \
+ U -= 0.5F; \
+ I0 = IFLOOR(U); \
+ I1 = I0 + 1; \
+ } \
+ else if (wrapMode == GL_MIRRORED_REPEAT) { \
+ const GLint flr = IFLOOR(S); \
+ if (flr & 1) \
+ U = 1.0F - (S - (GLfloat) flr); /* flr is odd */ \
+ else \
+ U = S - (GLfloat) flr; /* flr is even */ \
+ U = (U * SIZE) - 0.5F; \
+ I0 = IFLOOR(U); \
+ I1 = I0 + 1; \
+ if (I0 < 0) \
+ I0 = 0; \
+ if (I1 >= (GLint) SIZE) \
+ I1 = SIZE - 1; \
+ } \
+ else if (wrapMode == GL_MIRROR_CLAMP_EXT) { \
+ U = (GLfloat) fabs(S); \
+ if (U >= 1.0F) \
+ U = (GLfloat) SIZE; \
+ else \
+ U *= SIZE; \
+ U -= 0.5F; \
+ I0 = IFLOOR(U); \
+ I1 = I0 + 1; \
+ } \
+ else if (wrapMode == GL_MIRROR_CLAMP_TO_EDGE_EXT) { \
+ U = (GLfloat) fabs(S); \
+ if (U >= 1.0F) \
+ U = (GLfloat) SIZE; \
+ else \
+ U *= SIZE; \
+ U -= 0.5F; \
+ I0 = IFLOOR(U); \
+ I1 = I0 + 1; \
+ if (I0 < 0) \
+ I0 = 0; \
+ if (I1 >= (GLint) SIZE) \
+ I1 = SIZE - 1; \
+ } \
+ else if (wrapMode == GL_MIRROR_CLAMP_TO_BORDER_EXT) { \
+ const GLfloat min = -1.0F / (2.0F * SIZE); \
+ const GLfloat max = 1.0F - min; \
+ U = (GLfloat) fabs(S); \
+ if (U <= min) \
+ U = min * SIZE; \
+ else if (U >= max) \
+ U = max * SIZE; \
+ else \
+ U *= SIZE; \
+ U -= 0.5F; \
+ I0 = IFLOOR(U); \
+ I1 = I0 + 1; \
+ } \
+ else { \
+ ASSERT(wrapMode == GL_CLAMP); \
+ if (S <= 0.0F) \
+ U = 0.0F; \
+ else if (S >= 1.0F) \
+ U = (GLfloat) SIZE; \
+ else \
+ U = S * SIZE; \
+ U -= 0.5F; \
+ I0 = IFLOOR(U); \
+ I1 = I0 + 1; \
+ } \
+}
+
+
+/**
+ * Used to compute texel location for nearest sampling.
+ */
+#define COMPUTE_NEAREST_TEXEL_LOCATION(wrapMode, S, SIZE, I) \
+{ \
+ if (wrapMode == GL_REPEAT) { \
+ /* s limited to [0,1) */ \
+ /* i limited to [0,size-1] */ \
+ I = IFLOOR(S * SIZE); \
+ if (tObj->_IsPowerOfTwo) \
+ I &= (SIZE - 1); \
+ else \
+ I = repeat_remainder(I, SIZE); \
+ } \
+ else if (wrapMode == GL_CLAMP_TO_EDGE) { \
+ /* s limited to [min,max] */ \
+ /* i limited to [0, size-1] */ \
+ const GLfloat min = 1.0F / (2.0F * SIZE); \
+ const GLfloat max = 1.0F - min; \
+ if (S < min) \
+ I = 0; \
+ else if (S > max) \
+ I = SIZE - 1; \
+ else \
+ I = IFLOOR(S * SIZE); \
+ } \
+ else if (wrapMode == GL_CLAMP_TO_BORDER) { \
+ /* s limited to [min,max] */ \
+ /* i limited to [-1, size] */ \
+ const GLfloat min = -1.0F / (2.0F * SIZE); \
+ const GLfloat max = 1.0F - min; \
+ if (S <= min) \
+ I = -1; \
+ else if (S >= max) \
+ I = SIZE; \
+ else \
+ I = IFLOOR(S * SIZE); \
+ } \
+ else if (wrapMode == GL_MIRRORED_REPEAT) { \
+ const GLfloat min = 1.0F / (2.0F * SIZE); \
+ const GLfloat max = 1.0F - min; \
+ const GLint flr = IFLOOR(S); \
+ GLfloat u; \
+ if (flr & 1) \
+ u = 1.0F - (S - (GLfloat) flr); /* flr is odd */ \
+ else \
+ u = S - (GLfloat) flr; /* flr is even */ \
+ if (u < min) \
+ I = 0; \
+ else if (u > max) \
+ I = SIZE - 1; \
+ else \
+ I = IFLOOR(u * SIZE); \
+ } \
+ else if (wrapMode == GL_MIRROR_CLAMP_EXT) { \
+ /* s limited to [0,1] */ \
+ /* i limited to [0,size-1] */ \
+ const GLfloat u = (GLfloat) fabs(S); \
+ if (u <= 0.0F) \
+ I = 0; \
+ else if (u >= 1.0F) \
+ I = SIZE - 1; \
+ else \
+ I = IFLOOR(u * SIZE); \
+ } \
+ else if (wrapMode == GL_MIRROR_CLAMP_TO_EDGE_EXT) { \
+ /* s limited to [min,max] */ \
+ /* i limited to [0, size-1] */ \
+ const GLfloat min = 1.0F / (2.0F * SIZE); \
+ const GLfloat max = 1.0F - min; \
+ const GLfloat u = (GLfloat) fabs(S); \
+ if (u < min) \
+ I = 0; \
+ else if (u > max) \
+ I = SIZE - 1; \
+ else \
+ I = IFLOOR(u * SIZE); \
+ } \
+ else if (wrapMode == GL_MIRROR_CLAMP_TO_BORDER_EXT) { \
+ /* s limited to [min,max] */ \
+ /* i limited to [0, size-1] */ \
+ const GLfloat min = -1.0F / (2.0F * SIZE); \
+ const GLfloat max = 1.0F - min; \
+ const GLfloat u = (GLfloat) fabs(S); \
+ if (u < min) \
+ I = -1; \
+ else if (u > max) \
+ I = SIZE; \
+ else \
+ I = IFLOOR(u * SIZE); \
+ } \
+ else { \
+ ASSERT(wrapMode == GL_CLAMP); \
+ /* s limited to [0,1] */ \
+ /* i limited to [0,size-1] */ \
+ if (S <= 0.0F) \
+ I = 0; \
+ else if (S >= 1.0F) \
+ I = SIZE - 1; \
+ else \
+ I = IFLOOR(S * SIZE); \
+ } \
+}
+
+
+/* Power of two image sizes only */
+#define COMPUTE_LINEAR_REPEAT_TEXEL_LOCATION(S, U, SIZE, I0, I1) \
+{ \
+ U = S * SIZE - 0.5F; \
+ I0 = IFLOOR(U) & (SIZE - 1); \
+ I1 = (I0 + 1) & (SIZE - 1); \
+}
+
+
+/*
+ * Compute linear mipmap levels for given lambda.
+ */
+#define COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda, level) \
+{ \
+ if (lambda < 0.0F) \
+ level = tObj->BaseLevel; \
+ else if (lambda > tObj->_MaxLambda) \
+ level = (GLint) (tObj->BaseLevel + tObj->_MaxLambda); \
+ else \
+ level = (GLint) (tObj->BaseLevel + lambda); \
+}
+
+
+/*
+ * Compute nearest mipmap level for given lambda.
+ */
+#define COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda, level) \
+{ \
+ GLfloat l; \
+ if (lambda <= 0.5F) \
+ l = 0.0F; \
+ else if (lambda > tObj->_MaxLambda + 0.4999F) \
+ l = tObj->_MaxLambda + 0.4999F; \
+ else \
+ l = lambda; \
+ level = (GLint) (tObj->BaseLevel + l + 0.5F); \
+ if (level > tObj->_MaxLevel) \
+ level = tObj->_MaxLevel; \
+}
+
+
+
+/*
+ * Note, the FRAC macro has to work perfectly. Otherwise you'll sometimes
+ * see 1-pixel bands of improperly weighted linear-sampled texels. The
+ * tests/texwrap.c demo is a good test.
+ * Also note, FRAC(x) doesn't truly return the fractional part of x for x < 0.
+ * Instead, if x < 0 then FRAC(x) = 1 - true_frac(x).
+ */
+#define FRAC(f) ((f) - IFLOOR(f))
+
+
+
+/*
+ * Bitflags for texture border color sampling.
+ */
+#define I0BIT 1
+#define I1BIT 2
+#define J0BIT 4
+#define J1BIT 8
+#define K0BIT 16
+#define K1BIT 32
+
+
+
+/*
+ * The lambda[] array values are always monotonic. Either the whole span
+ * will be minified, magnified, or split between the two. This function
+ * determines the subranges in [0, n-1] that are to be minified or magnified.
+ */
+static INLINE void
+compute_min_mag_ranges( GLfloat minMagThresh, GLuint n, const GLfloat lambda[],
+ GLuint *minStart, GLuint *minEnd,
+ GLuint *magStart, GLuint *magEnd )
+{
+ ASSERT(lambda != NULL);
+#if 0
+ /* Verify that lambda[] is monotonous.
+ * We can't really use this because the inaccuracy in the LOG2 function
+ * causes this test to fail, yet the resulting texturing is correct.
+ */
+ if (n > 1) {
+ GLuint i;
+ printf("lambda delta = %g\n", lambda[0] - lambda[n-1]);
+ if (lambda[0] >= lambda[n-1]) { /* decreasing */
+ for (i = 0; i < n - 1; i++) {
+ ASSERT((GLint) (lambda[i] * 10) >= (GLint) (lambda[i+1] * 10));
+ }
+ }
+ else { /* increasing */
+ for (i = 0; i < n - 1; i++) {
+ ASSERT((GLint) (lambda[i] * 10) <= (GLint) (lambda[i+1] * 10));
+ }
+ }
+ }
+#endif /* DEBUG */
+
+ /* since lambda is monotonous-array use this check first */
+ if (lambda[0] <= minMagThresh && lambda[n-1] <= minMagThresh) {
+ /* magnification for whole span */
+ *magStart = 0;
+ *magEnd = n;
+ *minStart = *minEnd = 0;
+ }
+ else if (lambda[0] > minMagThresh && lambda[n-1] > minMagThresh) {
+ /* minification for whole span */
+ *minStart = 0;
+ *minEnd = n;
+ *magStart = *magEnd = 0;
+ }
+ else {
+ /* a mix of minification and magnification */
+ GLuint i;
+ if (lambda[0] > minMagThresh) {
+ /* start with minification */
+ for (i = 1; i < n; i++) {
+ if (lambda[i] <= minMagThresh)
+ break;
+ }
+ *minStart = 0;
+ *minEnd = i;
+ *magStart = i;
+ *magEnd = n;
+ }
+ else {
+ /* start with magnification */
+ for (i = 1; i < n; i++) {
+ if (lambda[i] > minMagThresh)
+ break;
+ }
+ *magStart = 0;
+ *magEnd = i;
+ *minStart = i;
+ *minEnd = n;
+ }
+ }
+
+#if 0
+ /* Verify the min/mag Start/End values
+ * We don't use this either (see above)
+ */
+ {
+ GLint i;
+ for (i = 0; i < n; i++) {
+ if (lambda[i] > minMagThresh) {
+ /* minification */
+ ASSERT(i >= *minStart);
+ ASSERT(i < *minEnd);
+ }
+ else {
+ /* magnification */
+ ASSERT(i >= *magStart);
+ ASSERT(i < *magEnd);
+ }
+ }
+ }
+#endif
+}
+
+
+/**********************************************************************/
+/* 1-D Texture Sampling Functions */
+/**********************************************************************/
+
+/*
+ * Return the texture sample for coordinate (s) using GL_NEAREST filter.
+ */
+static void
+sample_1d_nearest(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ const struct gl_texture_image *img,
+ const GLfloat texcoord[4], GLchan rgba[4])
+{
+ const GLint width = img->Width2; /* without border, power of two */
+ GLint i;
+ (void) ctx;
+
+ COMPUTE_NEAREST_TEXEL_LOCATION(tObj->WrapS, texcoord[0], width, i);
+
+ /* skip over the border, if any */
+ i += img->Border;
+
+ if (i < 0 || i >= (GLint) img->Width) {
+ /* Need this test for GL_CLAMP_TO_BORDER mode */
+ COPY_CHAN4(rgba, tObj->_BorderChan);
+ }
+ else {
+ img->FetchTexelc(img, i, 0, 0, rgba);
+ }
+}
+
+
+
+/*
+ * Return the texture sample for coordinate (s) using GL_LINEAR filter.
+ */
+static void
+sample_1d_linear(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ const struct gl_texture_image *img,
+ const GLfloat texcoord[4], GLchan rgba[4])
+{
+ const GLint width = img->Width2;
+ GLint i0, i1;
+ GLfloat u;
+ GLuint useBorderColor;
+ (void) ctx;
+
+ COMPUTE_LINEAR_TEXEL_LOCATIONS(tObj->WrapS, texcoord[0], u, width, i0, i1);
+
+ useBorderColor = 0;
+ if (img->Border) {
+ i0 += img->Border;
+ i1 += img->Border;
+ }
+ else {
+ if (i0 < 0 || i0 >= width) useBorderColor |= I0BIT;
+ if (i1 < 0 || i1 >= width) useBorderColor |= I1BIT;
+ }
+
+ {
+ const GLfloat a = FRAC(u);
+ GLchan t0[4], t1[4]; /* texels */
+
+ /* fetch texel colors */
+ if (useBorderColor & I0BIT) {
+ COPY_CHAN4(t0, tObj->_BorderChan);
+ }
+ else {
+ img->FetchTexelc(img, i0, 0, 0, t0);
+ }
+ if (useBorderColor & I1BIT) {
+ COPY_CHAN4(t1, tObj->_BorderChan);
+ }
+ else {
+ img->FetchTexelc(img, i1, 0, 0, t1);
+ }
+
+ /* do linear interpolation of texel colors */
+#if CHAN_TYPE == GL_FLOAT
+ rgba[0] = LERP(a, t0[0], t1[0]);
+ rgba[1] = LERP(a, t0[1], t1[1]);
+ rgba[2] = LERP(a, t0[2], t1[2]);
+ rgba[3] = LERP(a, t0[3], t1[3]);
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ rgba[0] = (GLchan) (LERP(a, t0[0], t1[0]) + 0.5);
+ rgba[1] = (GLchan) (LERP(a, t0[1], t1[1]) + 0.5);
+ rgba[2] = (GLchan) (LERP(a, t0[2], t1[2]) + 0.5);
+ rgba[3] = (GLchan) (LERP(a, t0[3], t1[3]) + 0.5);
+#else
+ ASSERT(CHAN_TYPE == GL_UNSIGNED_BYTE);
+ {
+ /* fixed point interpolants in [0, ILERP_SCALE] */
+ const GLint ia = IROUND_POS(a * ILERP_SCALE);
+ rgba[0] = ILERP(ia, t0[0], t1[0]);
+ rgba[1] = ILERP(ia, t0[1], t1[1]);
+ rgba[2] = ILERP(ia, t0[2], t1[2]);
+ rgba[3] = ILERP(ia, t0[3], t1[3]);
+ }
+#endif
+ }
+}
+
+
+static void
+sample_1d_nearest_mipmap_nearest(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoord[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ GLuint i;
+ ASSERT(lambda != NULL);
+ for (i = 0; i < n; i++) {
+ GLint level;
+ COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda[i], level);
+ sample_1d_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ }
+}
+
+
+static void
+sample_1d_linear_mipmap_nearest(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoord[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ GLuint i;
+ ASSERT(lambda != NULL);
+ for (i = 0; i < n; i++) {
+ GLint level;
+ COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda[i], level);
+ sample_1d_linear(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ }
+}
+
+
+
+/*
+ * This is really just needed in order to prevent warnings with some compilers.
+ */
+#if CHAN_TYPE == GL_FLOAT
+#define CHAN_CAST
+#else
+#define CHAN_CAST (GLchan) (GLint)
+#endif
+
+
+static void
+sample_1d_nearest_mipmap_linear(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoord[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ GLuint i;
+ ASSERT(lambda != NULL);
+ for (i = 0; i < n; i++) {
+ GLint level;
+ COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ if (level >= tObj->_MaxLevel) {
+ sample_1d_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ texcoord[i], rgba[i]);
+ }
+ else {
+ GLchan t0[4], t1[4];
+ const GLfloat f = FRAC(lambda[i]);
+ sample_1d_nearest(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
+ sample_1d_nearest(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ rgba[i][RCOMP] = CHAN_CAST ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]);
+ rgba[i][GCOMP] = CHAN_CAST ((1.0F-f) * t0[GCOMP] + f * t1[GCOMP]);
+ rgba[i][BCOMP] = CHAN_CAST ((1.0F-f) * t0[BCOMP] + f * t1[BCOMP]);
+ rgba[i][ACOMP] = CHAN_CAST ((1.0F-f) * t0[ACOMP] + f * t1[ACOMP]);
+ }
+ }
+}
+
+
+
+static void
+sample_1d_linear_mipmap_linear(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoord[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ GLuint i;
+ ASSERT(lambda != NULL);
+ for (i = 0; i < n; i++) {
+ GLint level;
+ COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ if (level >= tObj->_MaxLevel) {
+ sample_1d_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ texcoord[i], rgba[i]);
+ }
+ else {
+ GLchan t0[4], t1[4];
+ const GLfloat f = FRAC(lambda[i]);
+ sample_1d_linear(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
+ sample_1d_linear(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ rgba[i][RCOMP] = CHAN_CAST ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]);
+ rgba[i][GCOMP] = CHAN_CAST ((1.0F-f) * t0[GCOMP] + f * t1[GCOMP]);
+ rgba[i][BCOMP] = CHAN_CAST ((1.0F-f) * t0[BCOMP] + f * t1[BCOMP]);
+ rgba[i][ACOMP] = CHAN_CAST ((1.0F-f) * t0[ACOMP] + f * t1[ACOMP]);
+ }
+ }
+}
+
+
+
+static void
+sample_nearest_1d( GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ const GLfloat texcoords[][4], const GLfloat lambda[],
+ GLchan rgba[][4] )
+{
+ GLuint i;
+ struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ (void) texUnit;
+ (void) lambda;
+ for (i=0;i<n;i++) {
+ sample_1d_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
+ }
+}
+
+
+
+static void
+sample_linear_1d( GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ const GLfloat texcoords[][4], const GLfloat lambda[],
+ GLchan rgba[][4] )
+{
+ GLuint i;
+ struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ (void) texUnit;
+ (void) lambda;
+ for (i=0;i<n;i++) {
+ sample_1d_linear(ctx, tObj, image, texcoords[i], rgba[i]);
+ }
+}
+
+
+/*
+ * Given an (s) texture coordinate and lambda (level of detail) value,
+ * return a texture sample.
+ *
+ */
+static void
+sample_lambda_1d( GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ const GLfloat texcoords[][4],
+ const GLfloat lambda[], GLchan rgba[][4] )
+{
+ GLuint minStart, minEnd; /* texels with minification */
+ GLuint magStart, magEnd; /* texels with magnification */
+ GLuint i;
+
+ ASSERT(lambda != NULL);
+ compute_min_mag_ranges(SWRAST_CONTEXT(ctx)->_MinMagThresh[texUnit],
+ n, lambda, &minStart, &minEnd, &magStart, &magEnd);
+
+ if (minStart < minEnd) {
+ /* do the minified texels */
+ const GLuint m = minEnd - minStart;
+ switch (tObj->MinFilter) {
+ case GL_NEAREST:
+ for (i = minStart; i < minEnd; i++)
+ sample_1d_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ texcoords[i], rgba[i]);
+ break;
+ case GL_LINEAR:
+ for (i = minStart; i < minEnd; i++)
+ sample_1d_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ texcoords[i], rgba[i]);
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ sample_1d_nearest_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ sample_1d_linear_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ sample_1d_nearest_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ sample_1d_linear_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ default:
+ _mesa_problem(ctx, "Bad min filter in sample_1d_texture");
+ return;
+ }
+ }
+
+ if (magStart < magEnd) {
+ /* do the magnified texels */
+ switch (tObj->MagFilter) {
+ case GL_NEAREST:
+ for (i = magStart; i < magEnd; i++)
+ sample_1d_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ texcoords[i], rgba[i]);
+ break;
+ case GL_LINEAR:
+ for (i = magStart; i < magEnd; i++)
+ sample_1d_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ texcoords[i], rgba[i]);
+ break;
+ default:
+ _mesa_problem(ctx, "Bad mag filter in sample_1d_texture");
+ return;
+ }
+ }
+}
+
+
+/**********************************************************************/
+/* 2-D Texture Sampling Functions */
+/**********************************************************************/
+
+
+/*
+ * Return the texture sample for coordinate (s,t) using GL_NEAREST filter.
+ */
+static INLINE void
+sample_2d_nearest(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ const struct gl_texture_image *img,
+ const GLfloat texcoord[4],
+ GLchan rgba[])
+{
+ const GLint width = img->Width2; /* without border, power of two */
+ const GLint height = img->Height2; /* without border, power of two */
+ GLint i, j;
+ (void) ctx;
+
+ COMPUTE_NEAREST_TEXEL_LOCATION(tObj->WrapS, texcoord[0], width, i);
+ COMPUTE_NEAREST_TEXEL_LOCATION(tObj->WrapT, texcoord[1], height, j);
+
+ /* skip over the border, if any */
+ i += img->Border;
+ j += img->Border;
+
+ if (i < 0 || i >= (GLint) img->Width || j < 0 || j >= (GLint) img->Height) {
+ /* Need this test for GL_CLAMP_TO_BORDER mode */
+ COPY_CHAN4(rgba, tObj->_BorderChan);
+ }
+ else {
+ img->FetchTexelc(img, i, j, 0, rgba);
+ }
+}
+
+
+
+/**
+ * Return the texture sample for coordinate (s,t) using GL_LINEAR filter.
+ * New sampling code contributed by Lynn Quam <quam@ai.sri.com>.
+ */
+static INLINE void
+sample_2d_linear(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ const struct gl_texture_image *img,
+ const GLfloat texcoord[4],
+ GLchan rgba[])
+{
+ const GLint width = img->Width2;
+ const GLint height = img->Height2;
+ GLint i0, j0, i1, j1;
+ GLuint useBorderColor;
+ GLfloat u, v;
+ (void) ctx;
+
+ COMPUTE_LINEAR_TEXEL_LOCATIONS(tObj->WrapS, texcoord[0], u, width, i0, i1);
+ COMPUTE_LINEAR_TEXEL_LOCATIONS(tObj->WrapT, texcoord[1], v, height, j0, j1);
+
+ useBorderColor = 0;
+ if (img->Border) {
+ i0 += img->Border;
+ i1 += img->Border;
+ j0 += img->Border;
+ j1 += img->Border;
+ }
+ else {
+ if (i0 < 0 || i0 >= width) useBorderColor |= I0BIT;
+ if (i1 < 0 || i1 >= width) useBorderColor |= I1BIT;
+ if (j0 < 0 || j0 >= height) useBorderColor |= J0BIT;
+ if (j1 < 0 || j1 >= height) useBorderColor |= J1BIT;
+ }
+
+ {
+ const GLfloat a = FRAC(u);
+ const GLfloat b = FRAC(v);
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ const GLint ia = IROUND_POS(a * ILERP_SCALE);
+ const GLint ib = IROUND_POS(b * ILERP_SCALE);
+#endif
+ GLchan t00[4], t10[4], t01[4], t11[4]; /* sampled texel colors */
+
+ /* fetch four texel colors */
+ if (useBorderColor & (I0BIT | J0BIT)) {
+ COPY_CHAN4(t00, tObj->_BorderChan);
+ }
+ else {
+ img->FetchTexelc(img, i0, j0, 0, t00);
+ }
+ if (useBorderColor & (I1BIT | J0BIT)) {
+ COPY_CHAN4(t10, tObj->_BorderChan);
+ }
+ else {
+ img->FetchTexelc(img, i1, j0, 0, t10);
+ }
+ if (useBorderColor & (I0BIT | J1BIT)) {
+ COPY_CHAN4(t01, tObj->_BorderChan);
+ }
+ else {
+ img->FetchTexelc(img, i0, j1, 0, t01);
+ }
+ if (useBorderColor & (I1BIT | J1BIT)) {
+ COPY_CHAN4(t11, tObj->_BorderChan);
+ }
+ else {
+ img->FetchTexelc(img, i1, j1, 0, t11);
+ }
+
+ /* do bilinear interpolation of texel colors */
+#if CHAN_TYPE == GL_FLOAT
+ rgba[0] = lerp_2d(a, b, t00[0], t10[0], t01[0], t11[0]);
+ rgba[1] = lerp_2d(a, b, t00[1], t10[1], t01[1], t11[1]);
+ rgba[2] = lerp_2d(a, b, t00[2], t10[2], t01[2], t11[2]);
+ rgba[3] = lerp_2d(a, b, t00[3], t10[3], t01[3], t11[3]);
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ rgba[0] = (GLchan) (lerp_2d(a, b, t00[0], t10[0], t01[0], t11[0]) + 0.5);
+ rgba[1] = (GLchan) (lerp_2d(a, b, t00[1], t10[1], t01[1], t11[1]) + 0.5);
+ rgba[2] = (GLchan) (lerp_2d(a, b, t00[2], t10[2], t01[2], t11[2]) + 0.5);
+ rgba[3] = (GLchan) (lerp_2d(a, b, t00[3], t10[3], t01[3], t11[3]) + 0.5);
+#else
+ ASSERT(CHAN_TYPE == GL_UNSIGNED_BYTE);
+ rgba[0] = ilerp_2d(ia, ib, t00[0], t10[0], t01[0], t11[0]);
+ rgba[1] = ilerp_2d(ia, ib, t00[1], t10[1], t01[1], t11[1]);
+ rgba[2] = ilerp_2d(ia, ib, t00[2], t10[2], t01[2], t11[2]);
+ rgba[3] = ilerp_2d(ia, ib, t00[3], t10[3], t01[3], t11[3]);
+#endif
+ }
+}
+
+
+/*
+ * As above, but we know WRAP_S == REPEAT and WRAP_T == REPEAT.
+ */
+static INLINE void
+sample_2d_linear_repeat(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ const struct gl_texture_image *img,
+ const GLfloat texcoord[4],
+ GLchan rgba[])
+{
+ const GLint width = img->Width2;
+ const GLint height = img->Height2;
+ GLint i0, j0, i1, j1;
+ GLfloat u, v;
+ (void) ctx;
+ (void) tObj;
+
+ ASSERT(tObj->WrapS == GL_REPEAT);
+ ASSERT(tObj->WrapT == GL_REPEAT);
+ ASSERT(img->Border == 0);
+ ASSERT(img->Format != GL_COLOR_INDEX);
+ ASSERT(img->_IsPowerOfTwo);
+
+ COMPUTE_LINEAR_REPEAT_TEXEL_LOCATION(texcoord[0], u, width, i0, i1);
+ COMPUTE_LINEAR_REPEAT_TEXEL_LOCATION(texcoord[1], v, height, j0, j1);
+
+ {
+ const GLfloat a = FRAC(u);
+ const GLfloat b = FRAC(v);
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ const GLint ia = IROUND_POS(a * ILERP_SCALE);
+ const GLint ib = IROUND_POS(b * ILERP_SCALE);
+#endif
+ GLchan t00[4], t10[4], t01[4], t11[4]; /* sampled texel colors */
+
+ img->FetchTexelc(img, i0, j0, 0, t00);
+ img->FetchTexelc(img, i1, j0, 0, t10);
+ img->FetchTexelc(img, i0, j1, 0, t01);
+ img->FetchTexelc(img, i1, j1, 0, t11);
+
+ /* do bilinear interpolation of texel colors */
+#if CHAN_TYPE == GL_FLOAT
+ rgba[0] = lerp_2d(a, b, t00[0], t10[0], t01[0], t11[0]);
+ rgba[1] = lerp_2d(a, b, t00[1], t10[1], t01[1], t11[1]);
+ rgba[2] = lerp_2d(a, b, t00[2], t10[2], t01[2], t11[2]);
+ rgba[3] = lerp_2d(a, b, t00[3], t10[3], t01[3], t11[3]);
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ rgba[0] = (GLchan) (lerp_2d(a, b, t00[0], t10[0], t01[0], t11[0]) + 0.5);
+ rgba[1] = (GLchan) (lerp_2d(a, b, t00[1], t10[1], t01[1], t11[1]) + 0.5);
+ rgba[2] = (GLchan) (lerp_2d(a, b, t00[2], t10[2], t01[2], t11[2]) + 0.5);
+ rgba[3] = (GLchan) (lerp_2d(a, b, t00[3], t10[3], t01[3], t11[3]) + 0.5);
+#else
+ ASSERT(CHAN_TYPE == GL_UNSIGNED_BYTE);
+ rgba[0] = ilerp_2d(ia, ib, t00[0], t10[0], t01[0], t11[0]);
+ rgba[1] = ilerp_2d(ia, ib, t00[1], t10[1], t01[1], t11[1]);
+ rgba[2] = ilerp_2d(ia, ib, t00[2], t10[2], t01[2], t11[2]);
+ rgba[3] = ilerp_2d(ia, ib, t00[3], t10[3], t01[3], t11[3]);
+#endif
+ }
+}
+
+
+
+static void
+sample_2d_nearest_mipmap_nearest(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoord[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint level;
+ COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda[i], level);
+ sample_2d_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ }
+}
+
+
+
+static void
+sample_2d_linear_mipmap_nearest(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoord[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ GLuint i;
+ ASSERT(lambda != NULL);
+ for (i = 0; i < n; i++) {
+ GLint level;
+ COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda[i], level);
+ sample_2d_linear(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ }
+}
+
+
+
+static void
+sample_2d_nearest_mipmap_linear(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoord[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ GLuint i;
+ ASSERT(lambda != NULL);
+ for (i = 0; i < n; i++) {
+ GLint level;
+ COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ if (level >= tObj->_MaxLevel) {
+ sample_2d_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ texcoord[i], rgba[i]);
+ }
+ else {
+ GLchan t0[4], t1[4]; /* texels */
+ const GLfloat f = FRAC(lambda[i]);
+ sample_2d_nearest(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
+ sample_2d_nearest(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ rgba[i][RCOMP] = CHAN_CAST ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]);
+ rgba[i][GCOMP] = CHAN_CAST ((1.0F-f) * t0[GCOMP] + f * t1[GCOMP]);
+ rgba[i][BCOMP] = CHAN_CAST ((1.0F-f) * t0[BCOMP] + f * t1[BCOMP]);
+ rgba[i][ACOMP] = CHAN_CAST ((1.0F-f) * t0[ACOMP] + f * t1[ACOMP]);
+ }
+ }
+}
+
+
+
+/* Trilinear filtering */
+static void
+sample_2d_linear_mipmap_linear( GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoord[][4],
+ const GLfloat lambda[], GLchan rgba[][4] )
+{
+ GLuint i;
+ ASSERT(lambda != NULL);
+ for (i = 0; i < n; i++) {
+ GLint level;
+ COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ if (level >= tObj->_MaxLevel) {
+ sample_2d_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ texcoord[i], rgba[i]);
+ }
+ else {
+ GLchan t0[4], t1[4]; /* texels */
+ const GLfloat f = FRAC(lambda[i]);
+ sample_2d_linear(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
+ sample_2d_linear(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ rgba[i][RCOMP] = CHAN_CAST ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]);
+ rgba[i][GCOMP] = CHAN_CAST ((1.0F-f) * t0[GCOMP] + f * t1[GCOMP]);
+ rgba[i][BCOMP] = CHAN_CAST ((1.0F-f) * t0[BCOMP] + f * t1[BCOMP]);
+ rgba[i][ACOMP] = CHAN_CAST ((1.0F-f) * t0[ACOMP] + f * t1[ACOMP]);
+ }
+ }
+}
+
+
+static void
+sample_2d_linear_mipmap_linear_repeat( GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoord[][4],
+ const GLfloat lambda[], GLchan rgba[][4] )
+{
+ GLuint i;
+ ASSERT(lambda != NULL);
+ ASSERT(tObj->WrapS == GL_REPEAT);
+ ASSERT(tObj->WrapT == GL_REPEAT);
+ ASSERT(tObj->_IsPowerOfTwo);
+ for (i = 0; i < n; i++) {
+ GLint level;
+ COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ if (level >= tObj->_MaxLevel) {
+ sample_2d_linear_repeat(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ texcoord[i], rgba[i]);
+ }
+ else {
+ GLchan t0[4], t1[4]; /* texels */
+ const GLfloat f = FRAC(lambda[i]);
+ sample_2d_linear_repeat(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
+ sample_2d_linear_repeat(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ rgba[i][RCOMP] = CHAN_CAST ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]);
+ rgba[i][GCOMP] = CHAN_CAST ((1.0F-f) * t0[GCOMP] + f * t1[GCOMP]);
+ rgba[i][BCOMP] = CHAN_CAST ((1.0F-f) * t0[BCOMP] + f * t1[BCOMP]);
+ rgba[i][ACOMP] = CHAN_CAST ((1.0F-f) * t0[ACOMP] + f * t1[ACOMP]);
+ }
+ }
+}
+
+
+static void
+sample_nearest_2d( GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ const GLfloat texcoords[][4],
+ const GLfloat lambda[], GLchan rgba[][4] )
+{
+ GLuint i;
+ struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ (void) texUnit;
+ (void) lambda;
+ for (i=0;i<n;i++) {
+ sample_2d_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
+ }
+}
+
+
+
+static void
+sample_linear_2d( GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ const GLfloat texcoords[][4],
+ const GLfloat lambda[], GLchan rgba[][4] )
+{
+ GLuint i;
+ struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ (void) texUnit;
+ (void) lambda;
+ if (tObj->WrapS == GL_REPEAT && tObj->WrapT == GL_REPEAT
+ && image->Border == 0) {
+ for (i=0;i<n;i++) {
+ sample_2d_linear_repeat(ctx, tObj, image, texcoords[i], rgba[i]);
+ }
+ }
+ else {
+ for (i=0;i<n;i++) {
+ sample_2d_linear(ctx, tObj, image, texcoords[i], rgba[i]);
+ }
+ }
+}
+
+
+/*
+ * Optimized 2-D texture sampling:
+ * S and T wrap mode == GL_REPEAT
+ * GL_NEAREST min/mag filter
+ * No border,
+ * RowStride == Width,
+ * Format = GL_RGB
+ */
+static void
+opt_sample_rgb_2d( GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoords[][4],
+ const GLfloat lambda[], GLchan rgba[][4] )
+{
+ const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel];
+ const GLfloat width = (GLfloat) img->Width;
+ const GLfloat height = (GLfloat) img->Height;
+ const GLint colMask = img->Width - 1;
+ const GLint rowMask = img->Height - 1;
+ const GLint shift = img->WidthLog2;
+ GLuint k;
+ (void) ctx;
+ (void) texUnit;
+ (void) lambda;
+ ASSERT(tObj->WrapS==GL_REPEAT);
+ ASSERT(tObj->WrapT==GL_REPEAT);
+ ASSERT(img->Border==0);
+ ASSERT(img->Format==GL_RGB);
+ ASSERT(img->_IsPowerOfTwo);
+
+ for (k=0; k<n; k++) {
+ GLint i = IFLOOR(texcoords[k][0] * width) & colMask;
+ GLint j = IFLOOR(texcoords[k][1] * height) & rowMask;
+ GLint pos = (j << shift) | i;
+ GLchan *texel = ((GLchan *) img->Data) + 3*pos;
+ rgba[k][RCOMP] = texel[0];
+ rgba[k][GCOMP] = texel[1];
+ rgba[k][BCOMP] = texel[2];
+ }
+}
+
+
+/*
+ * Optimized 2-D texture sampling:
+ * S and T wrap mode == GL_REPEAT
+ * GL_NEAREST min/mag filter
+ * No border
+ * RowStride == Width,
+ * Format = GL_RGBA
+ */
+static void
+opt_sample_rgba_2d( GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoords[][4],
+ const GLfloat lambda[], GLchan rgba[][4] )
+{
+ const struct gl_texture_image *img = tObj->Image[0][tObj->BaseLevel];
+ const GLfloat width = (GLfloat) img->Width;
+ const GLfloat height = (GLfloat) img->Height;
+ const GLint colMask = img->Width - 1;
+ const GLint rowMask = img->Height - 1;
+ const GLint shift = img->WidthLog2;
+ GLuint i;
+ (void) ctx;
+ (void) texUnit;
+ (void) lambda;
+ ASSERT(tObj->WrapS==GL_REPEAT);
+ ASSERT(tObj->WrapT==GL_REPEAT);
+ ASSERT(img->Border==0);
+ ASSERT(img->Format==GL_RGBA);
+ ASSERT(img->_IsPowerOfTwo);
+
+ for (i = 0; i < n; i++) {
+ const GLint col = IFLOOR(texcoords[i][0] * width) & colMask;
+ const GLint row = IFLOOR(texcoords[i][1] * height) & rowMask;
+ const GLint pos = (row << shift) | col;
+ const GLchan *texel = ((GLchan *) img->Data) + (pos << 2); /* pos*4 */
+ COPY_CHAN4(rgba[i], texel);
+ }
+}
+
+
+/*
+ * Given an array of texture coordinate and lambda (level of detail)
+ * values, return an array of texture sample.
+ */
+static void
+sample_lambda_2d( GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoords[][4],
+ const GLfloat lambda[], GLchan rgba[][4] )
+{
+ const struct gl_texture_image *tImg = tObj->Image[0][tObj->BaseLevel];
+ GLuint minStart, minEnd; /* texels with minification */
+ GLuint magStart, magEnd; /* texels with magnification */
+
+ const GLboolean repeatNoBorderPOT = (tObj->WrapS == GL_REPEAT)
+ && (tObj->WrapT == GL_REPEAT)
+ && (tImg->Border == 0 && (tImg->Width == tImg->RowStride))
+ && (tImg->Format != GL_COLOR_INDEX)
+ && tImg->_IsPowerOfTwo;
+
+ ASSERT(lambda != NULL);
+ compute_min_mag_ranges(SWRAST_CONTEXT(ctx)->_MinMagThresh[texUnit],
+ n, lambda, &minStart, &minEnd, &magStart, &magEnd);
+
+ if (minStart < minEnd) {
+ /* do the minified texels */
+ const GLuint m = minEnd - minStart;
+ switch (tObj->MinFilter) {
+ case GL_NEAREST:
+ if (repeatNoBorderPOT) {
+ switch (tImg->TexFormat->MesaFormat) {
+ case MESA_FORMAT_RGB:
+ case MESA_FORMAT_RGB888:
+ /*case MESA_FORMAT_BGR888:*/
+ opt_sample_rgb_2d(ctx, texUnit, tObj, m, texcoords + minStart,
+ NULL, rgba + minStart);
+ break;
+ case MESA_FORMAT_RGBA:
+ case MESA_FORMAT_RGBA8888:
+ case MESA_FORMAT_ARGB8888:
+ /*case MESA_FORMAT_ABGR8888:*/
+ /*case MESA_FORMAT_BGRA8888:*/
+ opt_sample_rgba_2d(ctx, texUnit, tObj, m, texcoords + minStart,
+ NULL, rgba + minStart);
+ break;
+ default:
+ sample_nearest_2d(ctx, texUnit, tObj, m, texcoords + minStart,
+ NULL, rgba + minStart );
+ }
+ }
+ else {
+ sample_nearest_2d(ctx, texUnit, tObj, m, texcoords + minStart,
+ NULL, rgba + minStart);
+ }
+ break;
+ case GL_LINEAR:
+ sample_linear_2d(ctx, texUnit, tObj, m, texcoords + minStart,
+ NULL, rgba + minStart);
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ sample_2d_nearest_mipmap_nearest(ctx, tObj, m,
+ texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ sample_2d_linear_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ sample_2d_nearest_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ if (repeatNoBorderPOT)
+ sample_2d_linear_mipmap_linear_repeat(ctx, tObj, m,
+ texcoords + minStart, lambda + minStart, rgba + minStart);
+ else
+ sample_2d_linear_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ default:
+ _mesa_problem(ctx, "Bad min filter in sample_2d_texture");
+ return;
+ }
+ }
+
+ if (magStart < magEnd) {
+ /* do the magnified texels */
+ const GLuint m = magEnd - magStart;
+
+ switch (tObj->MagFilter) {
+ case GL_NEAREST:
+ if (repeatNoBorderPOT) {
+ switch (tImg->TexFormat->MesaFormat) {
+ case MESA_FORMAT_RGB:
+ case MESA_FORMAT_RGB888:
+ /*case MESA_FORMAT_BGR888:*/
+ opt_sample_rgb_2d(ctx, texUnit, tObj, m, texcoords + magStart,
+ NULL, rgba + magStart);
+ break;
+ case MESA_FORMAT_RGBA:
+ case MESA_FORMAT_RGBA8888:
+ case MESA_FORMAT_ARGB8888:
+ /*case MESA_FORMAT_ABGR8888:*/
+ /*case MESA_FORMAT_BGRA8888:*/
+ opt_sample_rgba_2d(ctx, texUnit, tObj, m, texcoords + magStart,
+ NULL, rgba + magStart);
+ break;
+ default:
+ sample_nearest_2d(ctx, texUnit, tObj, m, texcoords + magStart,
+ NULL, rgba + magStart );
+ }
+ }
+ else {
+ sample_nearest_2d(ctx, texUnit, tObj, m, texcoords + magStart,
+ NULL, rgba + magStart);
+ }
+ break;
+ case GL_LINEAR:
+ sample_linear_2d(ctx, texUnit, tObj, m, texcoords + magStart,
+ NULL, rgba + magStart);
+ break;
+ default:
+ _mesa_problem(ctx, "Bad mag filter in sample_lambda_2d");
+ }
+ }
+}
+
+
+
+/**********************************************************************/
+/* 3-D Texture Sampling Functions */
+/**********************************************************************/
+
+/*
+ * Return the texture sample for coordinate (s,t,r) using GL_NEAREST filter.
+ */
+static void
+sample_3d_nearest(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ const struct gl_texture_image *img,
+ const GLfloat texcoord[4],
+ GLchan rgba[4])
+{
+ const GLint width = img->Width2; /* without border, power of two */
+ const GLint height = img->Height2; /* without border, power of two */
+ const GLint depth = img->Depth2; /* without border, power of two */
+ GLint i, j, k;
+ (void) ctx;
+
+ COMPUTE_NEAREST_TEXEL_LOCATION(tObj->WrapS, texcoord[0], width, i);
+ COMPUTE_NEAREST_TEXEL_LOCATION(tObj->WrapT, texcoord[1], height, j);
+ COMPUTE_NEAREST_TEXEL_LOCATION(tObj->WrapR, texcoord[2], depth, k);
+
+ if (i < 0 || i >= (GLint) img->Width ||
+ j < 0 || j >= (GLint) img->Height ||
+ k < 0 || k >= (GLint) img->Depth) {
+ /* Need this test for GL_CLAMP_TO_BORDER mode */
+ COPY_CHAN4(rgba, tObj->_BorderChan);
+ }
+ else {
+ img->FetchTexelc(img, i, j, k, rgba);
+ }
+}
+
+
+
+/*
+ * Return the texture sample for coordinate (s,t,r) using GL_LINEAR filter.
+ */
+static void
+sample_3d_linear(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ const struct gl_texture_image *img,
+ const GLfloat texcoord[4],
+ GLchan rgba[4])
+{
+ const GLint width = img->Width2;
+ const GLint height = img->Height2;
+ const GLint depth = img->Depth2;
+ GLint i0, j0, k0, i1, j1, k1;
+ GLuint useBorderColor;
+ GLfloat u, v, w;
+ (void) ctx;
+
+ COMPUTE_LINEAR_TEXEL_LOCATIONS(tObj->WrapS, texcoord[0], u, width, i0, i1);
+ COMPUTE_LINEAR_TEXEL_LOCATIONS(tObj->WrapT, texcoord[1], v, height, j0, j1);
+ COMPUTE_LINEAR_TEXEL_LOCATIONS(tObj->WrapR, texcoord[2], w, depth, k0, k1);
+
+ useBorderColor = 0;
+ if (img->Border) {
+ i0 += img->Border;
+ i1 += img->Border;
+ j0 += img->Border;
+ j1 += img->Border;
+ k0 += img->Border;
+ k1 += img->Border;
+ }
+ else {
+ /* check if sampling texture border color */
+ if (i0 < 0 || i0 >= width) useBorderColor |= I0BIT;
+ if (i1 < 0 || i1 >= width) useBorderColor |= I1BIT;
+ if (j0 < 0 || j0 >= height) useBorderColor |= J0BIT;
+ if (j1 < 0 || j1 >= height) useBorderColor |= J1BIT;
+ if (k0 < 0 || k0 >= depth) useBorderColor |= K0BIT;
+ if (k1 < 0 || k1 >= depth) useBorderColor |= K1BIT;
+ }
+
+ {
+ const GLfloat a = FRAC(u);
+ const GLfloat b = FRAC(v);
+ const GLfloat c = FRAC(w);
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ const GLint ia = IROUND_POS(a * ILERP_SCALE);
+ const GLint ib = IROUND_POS(b * ILERP_SCALE);
+ const GLint ic = IROUND_POS(c * ILERP_SCALE);
+#endif
+ GLchan t000[4], t010[4], t001[4], t011[4];
+ GLchan t100[4], t110[4], t101[4], t111[4];
+
+ /* Fetch texels */
+ if (useBorderColor & (I0BIT | J0BIT | K0BIT)) {
+ COPY_CHAN4(t000, tObj->_BorderChan);
+ }
+ else {
+ img->FetchTexelc(img, i0, j0, k0, t000);
+ }
+ if (useBorderColor & (I1BIT | J0BIT | K0BIT)) {
+ COPY_CHAN4(t100, tObj->_BorderChan);
+ }
+ else {
+ img->FetchTexelc(img, i1, j0, k0, t100);
+ }
+ if (useBorderColor & (I0BIT | J1BIT | K0BIT)) {
+ COPY_CHAN4(t010, tObj->_BorderChan);
+ }
+ else {
+ img->FetchTexelc(img, i0, j1, k0, t010);
+ }
+ if (useBorderColor & (I1BIT | J1BIT | K0BIT)) {
+ COPY_CHAN4(t110, tObj->_BorderChan);
+ }
+ else {
+ img->FetchTexelc(img, i1, j1, k0, t110);
+ }
+
+ if (useBorderColor & (I0BIT | J0BIT | K1BIT)) {
+ COPY_CHAN4(t001, tObj->_BorderChan);
+ }
+ else {
+ img->FetchTexelc(img, i0, j0, k1, t001);
+ }
+ if (useBorderColor & (I1BIT | J0BIT | K1BIT)) {
+ COPY_CHAN4(t101, tObj->_BorderChan);
+ }
+ else {
+ img->FetchTexelc(img, i1, j0, k1, t101);
+ }
+ if (useBorderColor & (I0BIT | J1BIT | K1BIT)) {
+ COPY_CHAN4(t011, tObj->_BorderChan);
+ }
+ else {
+ img->FetchTexelc(img, i0, j1, k1, t011);
+ }
+ if (useBorderColor & (I1BIT | J1BIT | K1BIT)) {
+ COPY_CHAN4(t111, tObj->_BorderChan);
+ }
+ else {
+ img->FetchTexelc(img, i1, j1, k1, t111);
+ }
+
+ /* trilinear interpolation of samples */
+#if CHAN_TYPE == GL_FLOAT
+ rgba[0] = lerp_3d(a, b, c,
+ t000[0], t100[0], t010[0], t110[0],
+ t001[0], t101[0], t011[0], t111[0]);
+ rgba[1] = lerp_3d(a, b, c,
+ t000[1], t100[1], t010[1], t110[1],
+ t001[1], t101[1], t011[1], t111[1]);
+ rgba[2] = lerp_3d(a, b, c,
+ t000[2], t100[2], t010[2], t110[2],
+ t001[2], t101[2], t011[2], t111[2]);
+ rgba[3] = lerp_3d(a, b, c,
+ t000[3], t100[3], t010[3], t110[3],
+ t001[3], t101[3], t011[3], t111[3]);
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ rgba[0] = (GLchan) (lerp_3d(a, b, c,
+ t000[0], t100[0], t010[0], t110[0],
+ t001[0], t101[0], t011[0], t111[0]) + 0.5F);
+ rgba[1] = (GLchan) (lerp_3d(a, b, c,
+ t000[1], t100[1], t010[1], t110[1],
+ t001[1], t101[1], t011[1], t111[1]) + 0.5F);
+ rgba[2] = (GLchan) (lerp_3d(a, b, c,
+ t000[2], t100[2], t010[2], t110[2],
+ t001[2], t101[2], t011[2], t111[2]) + 0.5F);
+ rgba[3] = (GLchan) (lerp_3d(a, b, c,
+ t000[3], t100[3], t010[3], t110[3],
+ t001[3], t101[3], t011[3], t111[3]) + 0.5F);
+#else
+ ASSERT(CHAN_TYPE == GL_UNSIGNED_BYTE);
+ rgba[0] = ilerp_3d(ia, ib, ic,
+ t000[0], t100[0], t010[0], t110[0],
+ t001[0], t101[0], t011[0], t111[0]);
+ rgba[1] = ilerp_3d(ia, ib, ic,
+ t000[1], t100[1], t010[1], t110[1],
+ t001[1], t101[1], t011[1], t111[1]);
+ rgba[2] = ilerp_3d(ia, ib, ic,
+ t000[2], t100[2], t010[2], t110[2],
+ t001[2], t101[2], t011[2], t111[2]);
+ rgba[3] = ilerp_3d(ia, ib, ic,
+ t000[3], t100[3], t010[3], t110[3],
+ t001[3], t101[3], t011[3], t111[3]);
+#endif
+ }
+}
+
+
+
+static void
+sample_3d_nearest_mipmap_nearest(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoord[][4],
+ const GLfloat lambda[], GLchan rgba[][4] )
+{
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLint level;
+ COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda[i], level);
+ sample_3d_nearest(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ }
+}
+
+
+static void
+sample_3d_linear_mipmap_nearest(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoord[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ GLuint i;
+ ASSERT(lambda != NULL);
+ for (i = 0; i < n; i++) {
+ GLint level;
+ COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda[i], level);
+ sample_3d_linear(ctx, tObj, tObj->Image[0][level], texcoord[i], rgba[i]);
+ }
+}
+
+
+static void
+sample_3d_nearest_mipmap_linear(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoord[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ GLuint i;
+ ASSERT(lambda != NULL);
+ for (i = 0; i < n; i++) {
+ GLint level;
+ COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ if (level >= tObj->_MaxLevel) {
+ sample_3d_nearest(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ texcoord[i], rgba[i]);
+ }
+ else {
+ GLchan t0[4], t1[4]; /* texels */
+ const GLfloat f = FRAC(lambda[i]);
+ sample_3d_nearest(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
+ sample_3d_nearest(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ rgba[i][RCOMP] = CHAN_CAST ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]);
+ rgba[i][GCOMP] = CHAN_CAST ((1.0F-f) * t0[GCOMP] + f * t1[GCOMP]);
+ rgba[i][BCOMP] = CHAN_CAST ((1.0F-f) * t0[BCOMP] + f * t1[BCOMP]);
+ rgba[i][ACOMP] = CHAN_CAST ((1.0F-f) * t0[ACOMP] + f * t1[ACOMP]);
+ }
+ }
+}
+
+
+static void
+sample_3d_linear_mipmap_linear(GLcontext *ctx,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoord[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ GLuint i;
+ ASSERT(lambda != NULL);
+ for (i = 0; i < n; i++) {
+ GLint level;
+ COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ if (level >= tObj->_MaxLevel) {
+ sample_3d_linear(ctx, tObj, tObj->Image[0][tObj->_MaxLevel],
+ texcoord[i], rgba[i]);
+ }
+ else {
+ GLchan t0[4], t1[4]; /* texels */
+ const GLfloat f = FRAC(lambda[i]);
+ sample_3d_linear(ctx, tObj, tObj->Image[0][level ], texcoord[i], t0);
+ sample_3d_linear(ctx, tObj, tObj->Image[0][level+1], texcoord[i], t1);
+ rgba[i][RCOMP] = CHAN_CAST ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]);
+ rgba[i][GCOMP] = CHAN_CAST ((1.0F-f) * t0[GCOMP] + f * t1[GCOMP]);
+ rgba[i][BCOMP] = CHAN_CAST ((1.0F-f) * t0[BCOMP] + f * t1[BCOMP]);
+ rgba[i][ACOMP] = CHAN_CAST ((1.0F-f) * t0[ACOMP] + f * t1[ACOMP]);
+ }
+ }
+}
+
+
+static void
+sample_nearest_3d(GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ const GLfloat texcoords[][4], const GLfloat lambda[],
+ GLchan rgba[][4])
+{
+ GLuint i;
+ struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ (void) texUnit;
+ (void) lambda;
+ for (i=0;i<n;i++) {
+ sample_3d_nearest(ctx, tObj, image, texcoords[i], rgba[i]);
+ }
+}
+
+
+
+static void
+sample_linear_3d( GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ const GLfloat texcoords[][4],
+ const GLfloat lambda[], GLchan rgba[][4] )
+{
+ GLuint i;
+ struct gl_texture_image *image = tObj->Image[0][tObj->BaseLevel];
+ (void) texUnit;
+ (void) lambda;
+ for (i=0;i<n;i++) {
+ sample_3d_linear(ctx, tObj, image, texcoords[i], rgba[i]);
+ }
+}
+
+
+/*
+ * Given an (s,t,r) texture coordinate and lambda (level of detail) value,
+ * return a texture sample.
+ */
+static void
+sample_lambda_3d( GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ const GLfloat texcoords[][4], const GLfloat lambda[],
+ GLchan rgba[][4] )
+{
+ GLuint minStart, minEnd; /* texels with minification */
+ GLuint magStart, magEnd; /* texels with magnification */
+ GLuint i;
+
+ ASSERT(lambda != NULL);
+ compute_min_mag_ranges(SWRAST_CONTEXT(ctx)->_MinMagThresh[texUnit],
+ n, lambda, &minStart, &minEnd, &magStart, &magEnd);
+
+ if (minStart < minEnd) {
+ /* do the minified texels */
+ GLuint m = minEnd - minStart;
+ switch (tObj->MinFilter) {
+ case GL_NEAREST:
+ for (i = minStart; i < minEnd; i++)
+ sample_3d_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ texcoords[i], rgba[i]);
+ break;
+ case GL_LINEAR:
+ for (i = minStart; i < minEnd; i++)
+ sample_3d_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ texcoords[i], rgba[i]);
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ sample_3d_nearest_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ sample_3d_linear_mipmap_nearest(ctx, tObj, m, texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ sample_3d_nearest_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ sample_3d_linear_mipmap_linear(ctx, tObj, m, texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ default:
+ _mesa_problem(ctx, "Bad min filter in sample_3d_texture");
+ return;
+ }
+ }
+
+ if (magStart < magEnd) {
+ /* do the magnified texels */
+ switch (tObj->MagFilter) {
+ case GL_NEAREST:
+ for (i = magStart; i < magEnd; i++)
+ sample_3d_nearest(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ texcoords[i], rgba[i]);
+ break;
+ case GL_LINEAR:
+ for (i = magStart; i < magEnd; i++)
+ sample_3d_linear(ctx, tObj, tObj->Image[0][tObj->BaseLevel],
+ texcoords[i], rgba[i]);
+ break;
+ default:
+ _mesa_problem(ctx, "Bad mag filter in sample_3d_texture");
+ return;
+ }
+ }
+}
+
+
+/**********************************************************************/
+/* Texture Cube Map Sampling Functions */
+/**********************************************************************/
+
+/*
+ * Choose one of six sides of a texture cube map given the texture
+ * coord (rx,ry,rz). Return pointer to corresponding array of texture
+ * images.
+ */
+static const struct gl_texture_image **
+choose_cube_face(const struct gl_texture_object *texObj,
+ const GLfloat texcoord[4], GLfloat newCoord[4])
+{
+/*
+ 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
+*/
+ const GLfloat rx = texcoord[0];
+ const GLfloat ry = texcoord[1];
+ const GLfloat rz = texcoord[2];
+ const struct gl_texture_image **imgArray;
+ const GLfloat arx = FABSF(rx), ary = FABSF(ry), arz = FABSF(rz);
+ GLfloat sc, tc, ma;
+
+ if (arx > ary && arx > arz) {
+ if (rx >= 0.0F) {
+ imgArray = (const struct gl_texture_image **) texObj->Image[FACE_POS_X];
+ sc = -rz;
+ tc = -ry;
+ ma = arx;
+ }
+ else {
+ imgArray = (const struct gl_texture_image **) texObj->Image[FACE_NEG_X];
+ sc = rz;
+ tc = -ry;
+ ma = arx;
+ }
+ }
+ else if (ary > arx && ary > arz) {
+ if (ry >= 0.0F) {
+ imgArray = (const struct gl_texture_image **) texObj->Image[FACE_POS_Y];
+ sc = rx;
+ tc = rz;
+ ma = ary;
+ }
+ else {
+ imgArray = (const struct gl_texture_image **) texObj->Image[FACE_NEG_Y];
+ sc = rx;
+ tc = -rz;
+ ma = ary;
+ }
+ }
+ else {
+ if (rz > 0.0F) {
+ imgArray = (const struct gl_texture_image **) texObj->Image[FACE_POS_Z];
+ sc = rx;
+ tc = -ry;
+ ma = arz;
+ }
+ else {
+ imgArray = (const struct gl_texture_image **) texObj->Image[FACE_NEG_Z];
+ sc = -rx;
+ tc = -ry;
+ ma = arz;
+ }
+ }
+
+ newCoord[0] = ( sc / ma + 1.0F ) * 0.5F;
+ newCoord[1] = ( tc / ma + 1.0F ) * 0.5F;
+ return imgArray;
+}
+
+
+static void
+sample_nearest_cube(GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ const GLfloat texcoords[][4], const GLfloat lambda[],
+ GLchan rgba[][4])
+{
+ GLuint i;
+ (void) texUnit;
+ (void) lambda;
+ for (i = 0; i < n; i++) {
+ const struct gl_texture_image **images;
+ GLfloat newCoord[4];
+ images = choose_cube_face(tObj, texcoords[i], newCoord);
+ sample_2d_nearest(ctx, tObj, images[tObj->BaseLevel],
+ newCoord, rgba[i]);
+ }
+}
+
+
+static void
+sample_linear_cube(GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ const GLfloat texcoords[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ GLuint i;
+ (void) texUnit;
+ (void) lambda;
+ for (i = 0; i < n; i++) {
+ const struct gl_texture_image **images;
+ GLfloat newCoord[4];
+ images = choose_cube_face(tObj, texcoords[i], newCoord);
+ sample_2d_linear(ctx, tObj, images[tObj->BaseLevel],
+ newCoord, rgba[i]);
+ }
+}
+
+
+static void
+sample_cube_nearest_mipmap_nearest(GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoord[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ GLuint i;
+ (void) texUnit;
+ ASSERT(lambda != NULL);
+ for (i = 0; i < n; i++) {
+ const struct gl_texture_image **images;
+ GLfloat newCoord[4];
+ GLint level;
+ COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda[i], level);
+ images = choose_cube_face(tObj, texcoord[i], newCoord);
+ sample_2d_nearest(ctx, tObj, images[level], newCoord, rgba[i]);
+ }
+}
+
+
+static void
+sample_cube_linear_mipmap_nearest(GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoord[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ GLuint i;
+ (void) texUnit;
+ ASSERT(lambda != NULL);
+ for (i = 0; i < n; i++) {
+ const struct gl_texture_image **images;
+ GLfloat newCoord[4];
+ GLint level;
+ COMPUTE_NEAREST_MIPMAP_LEVEL(tObj, lambda[i], level);
+ images = choose_cube_face(tObj, texcoord[i], newCoord);
+ sample_2d_linear(ctx, tObj, images[level], newCoord, rgba[i]);
+ }
+}
+
+
+static void
+sample_cube_nearest_mipmap_linear(GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoord[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ GLuint i;
+ (void) texUnit;
+ ASSERT(lambda != NULL);
+ for (i = 0; i < n; i++) {
+ const struct gl_texture_image **images;
+ GLfloat newCoord[4];
+ GLint level;
+ COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ images = choose_cube_face(tObj, texcoord[i], newCoord);
+ if (level >= tObj->_MaxLevel) {
+ sample_2d_nearest(ctx, tObj, images[tObj->_MaxLevel],
+ newCoord, rgba[i]);
+ }
+ else {
+ GLchan t0[4], t1[4]; /* texels */
+ const GLfloat f = FRAC(lambda[i]);
+ sample_2d_nearest(ctx, tObj, images[level ], newCoord, t0);
+ sample_2d_nearest(ctx, tObj, images[level+1], newCoord, t1);
+ rgba[i][RCOMP] = CHAN_CAST ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]);
+ rgba[i][GCOMP] = CHAN_CAST ((1.0F-f) * t0[GCOMP] + f * t1[GCOMP]);
+ rgba[i][BCOMP] = CHAN_CAST ((1.0F-f) * t0[BCOMP] + f * t1[BCOMP]);
+ rgba[i][ACOMP] = CHAN_CAST ((1.0F-f) * t0[ACOMP] + f * t1[ACOMP]);
+ }
+ }
+}
+
+
+static void
+sample_cube_linear_mipmap_linear(GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj,
+ GLuint n, const GLfloat texcoord[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ GLuint i;
+ (void) texUnit;
+ ASSERT(lambda != NULL);
+ for (i = 0; i < n; i++) {
+ const struct gl_texture_image **images;
+ GLfloat newCoord[4];
+ GLint level;
+ COMPUTE_LINEAR_MIPMAP_LEVEL(tObj, lambda[i], level);
+ images = choose_cube_face(tObj, texcoord[i], newCoord);
+ if (level >= tObj->_MaxLevel) {
+ sample_2d_linear(ctx, tObj, images[tObj->_MaxLevel],
+ newCoord, rgba[i]);
+ }
+ else {
+ GLchan t0[4], t1[4];
+ const GLfloat f = FRAC(lambda[i]);
+ sample_2d_linear(ctx, tObj, images[level ], newCoord, t0);
+ sample_2d_linear(ctx, tObj, images[level+1], newCoord, t1);
+ rgba[i][RCOMP] = CHAN_CAST ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]);
+ rgba[i][GCOMP] = CHAN_CAST ((1.0F-f) * t0[GCOMP] + f * t1[GCOMP]);
+ rgba[i][BCOMP] = CHAN_CAST ((1.0F-f) * t0[BCOMP] + f * t1[BCOMP]);
+ rgba[i][ACOMP] = CHAN_CAST ((1.0F-f) * t0[ACOMP] + f * t1[ACOMP]);
+ }
+ }
+}
+
+
+static void
+sample_lambda_cube( GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ const GLfloat texcoords[][4], const GLfloat lambda[],
+ GLchan rgba[][4])
+{
+ GLuint minStart, minEnd; /* texels with minification */
+ GLuint magStart, magEnd; /* texels with magnification */
+
+ ASSERT(lambda != NULL);
+ compute_min_mag_ranges(SWRAST_CONTEXT(ctx)->_MinMagThresh[texUnit],
+ n, lambda, &minStart, &minEnd, &magStart, &magEnd);
+
+ if (minStart < minEnd) {
+ /* do the minified texels */
+ const GLuint m = minEnd - minStart;
+ switch (tObj->MinFilter) {
+ case GL_NEAREST:
+ sample_nearest_cube(ctx, texUnit, tObj, m, texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ case GL_LINEAR:
+ sample_linear_cube(ctx, texUnit, tObj, m, texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ case GL_NEAREST_MIPMAP_NEAREST:
+ sample_cube_nearest_mipmap_nearest(ctx, texUnit, tObj, m,
+ texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ case GL_LINEAR_MIPMAP_NEAREST:
+ sample_cube_linear_mipmap_nearest(ctx, texUnit, tObj, m,
+ texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ case GL_NEAREST_MIPMAP_LINEAR:
+ sample_cube_nearest_mipmap_linear(ctx, texUnit, tObj, m,
+ texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ case GL_LINEAR_MIPMAP_LINEAR:
+ sample_cube_linear_mipmap_linear(ctx, texUnit, tObj, m,
+ texcoords + minStart,
+ lambda + minStart, rgba + minStart);
+ break;
+ default:
+ _mesa_problem(ctx, "Bad min filter in sample_lambda_cube");
+ }
+ }
+
+ if (magStart < magEnd) {
+ /* do the magnified texels */
+ const GLuint m = magEnd - magStart;
+ switch (tObj->MagFilter) {
+ case GL_NEAREST:
+ sample_nearest_cube(ctx, texUnit, tObj, m, texcoords + magStart,
+ lambda + magStart, rgba + magStart);
+ break;
+ case GL_LINEAR:
+ sample_linear_cube(ctx, texUnit, tObj, m, texcoords + magStart,
+ lambda + magStart, rgba + magStart);
+ break;
+ default:
+ _mesa_problem(ctx, "Bad mag filter in sample_lambda_cube");
+ }
+ }
+}
+
+
+/**********************************************************************/
+/* Texture Rectangle Sampling Functions */
+/**********************************************************************/
+
+static void
+sample_nearest_rect(GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ const GLfloat texcoords[][4], const GLfloat lambda[],
+ GLchan rgba[][4])
+{
+ const struct gl_texture_image *img = tObj->Image[0][0];
+ const GLfloat width = (GLfloat) img->Width;
+ const GLfloat height = (GLfloat) img->Height;
+ const GLint width_minus_1 = img->Width - 1;
+ const GLint height_minus_1 = img->Height - 1;
+ GLuint i;
+
+ (void) ctx;
+ (void) texUnit;
+ (void) lambda;
+
+ ASSERT(tObj->WrapS == GL_CLAMP ||
+ tObj->WrapS == GL_CLAMP_TO_EDGE ||
+ tObj->WrapS == GL_CLAMP_TO_BORDER);
+ ASSERT(tObj->WrapT == GL_CLAMP ||
+ tObj->WrapT == GL_CLAMP_TO_EDGE ||
+ tObj->WrapT == GL_CLAMP_TO_BORDER);
+ ASSERT(img->Format != GL_COLOR_INDEX);
+
+ /* XXX move Wrap mode tests outside of loops for common cases */
+ for (i = 0; i < n; i++) {
+ GLint row, col;
+ /* NOTE: we DO NOT use [0, 1] texture coordinates! */
+ if (tObj->WrapS == GL_CLAMP) {
+ col = IFLOOR( CLAMP(texcoords[i][0], 0.0F, width - 1) );
+ }
+ else if (tObj->WrapS == GL_CLAMP_TO_EDGE) {
+ col = IFLOOR( CLAMP(texcoords[i][0], 0.5F, width - 0.5F) );
+ }
+ else {
+ col = IFLOOR( CLAMP(texcoords[i][0], -0.5F, width + 0.5F) );
+ }
+ if (tObj->WrapT == GL_CLAMP) {
+ row = IFLOOR( CLAMP(texcoords[i][1], 0.0F, height - 1) );
+ }
+ else if (tObj->WrapT == GL_CLAMP_TO_EDGE) {
+ row = IFLOOR( CLAMP(texcoords[i][1], 0.5F, height - 0.5F) );
+ }
+ else {
+ row = IFLOOR( CLAMP(texcoords[i][1], -0.5F, height + 0.5F) );
+ }
+
+ if (col < 0 || col > width_minus_1 || row < 0 || row > height_minus_1)
+ COPY_CHAN4(rgba[i], tObj->_BorderChan);
+ else
+ img->FetchTexelc(img, col, row, 0, rgba[i]);
+ }
+}
+
+
+static void
+sample_linear_rect(GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ const GLfloat texcoords[][4],
+ const GLfloat lambda[], GLchan rgba[][4])
+{
+ const struct gl_texture_image *img = tObj->Image[0][0];
+ const GLfloat width = (GLfloat) img->Width;
+ const GLfloat height = (GLfloat) img->Height;
+ const GLint width_minus_1 = img->Width - 1;
+ const GLint height_minus_1 = img->Height - 1;
+ GLuint i;
+
+ (void) ctx;
+ (void) texUnit;
+ (void) lambda;
+
+ ASSERT(tObj->WrapS == GL_CLAMP ||
+ tObj->WrapS == GL_CLAMP_TO_EDGE ||
+ tObj->WrapS == GL_CLAMP_TO_BORDER);
+ ASSERT(tObj->WrapT == GL_CLAMP ||
+ tObj->WrapT == GL_CLAMP_TO_EDGE ||
+ tObj->WrapT == GL_CLAMP_TO_BORDER);
+ ASSERT(img->Format != GL_COLOR_INDEX);
+
+ /* XXX lots of opportunity for optimization in this loop */
+ for (i = 0; i < n; i++) {
+ GLfloat frow, fcol;
+ GLint i0, j0, i1, j1;
+ GLchan t00[4], t01[4], t10[4], t11[4];
+ GLfloat a, b;
+ GLuint useBorderColor = 0;
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ GLint ia, ib;
+#endif
+
+ /* NOTE: we DO NOT use [0, 1] texture coordinates! */
+ if (tObj->WrapS == GL_CLAMP) {
+ /* Not exactly what the spec says, but it matches NVIDIA output */
+ fcol = CLAMP(texcoords[i][0] - 0.5F, 0.0, width_minus_1);
+ i0 = IFLOOR(fcol);
+ i1 = i0 + 1;
+ }
+ else if (tObj->WrapS == GL_CLAMP_TO_EDGE) {
+ fcol = CLAMP(texcoords[i][0], 0.5F, width - 0.5F);
+ fcol -= 0.5F;
+ i0 = IFLOOR(fcol);
+ i1 = i0 + 1;
+ if (i1 > width_minus_1)
+ i1 = width_minus_1;
+ }
+ else {
+ ASSERT(tObj->WrapS == GL_CLAMP_TO_BORDER);
+ fcol = CLAMP(texcoords[i][0], -0.5F, width + 0.5F);
+ fcol -= 0.5F;
+ i0 = IFLOOR(fcol);
+ i1 = i0 + 1;
+ }
+
+ if (tObj->WrapT == GL_CLAMP) {
+ /* Not exactly what the spec says, but it matches NVIDIA output */
+ frow = CLAMP(texcoords[i][1] - 0.5F, 0.0, width_minus_1);
+ j0 = IFLOOR(frow);
+ j1 = j0 + 1;
+ }
+ else if (tObj->WrapT == GL_CLAMP_TO_EDGE) {
+ frow = CLAMP(texcoords[i][1], 0.5F, height - 0.5F);
+ frow -= 0.5F;
+ j0 = IFLOOR(frow);
+ j1 = j0 + 1;
+ if (j1 > height_minus_1)
+ j1 = height_minus_1;
+ }
+ else {
+ ASSERT(tObj->WrapT == GL_CLAMP_TO_BORDER);
+ frow = CLAMP(texcoords[i][1], -0.5F, height + 0.5F);
+ frow -= 0.5F;
+ j0 = IFLOOR(frow);
+ j1 = j0 + 1;
+ }
+
+ /* compute integer rows/columns */
+ if (i0 < 0 || i0 > width_minus_1) useBorderColor |= I0BIT;
+ if (i1 < 0 || i1 > width_minus_1) useBorderColor |= I1BIT;
+ if (j0 < 0 || j0 > height_minus_1) useBorderColor |= J0BIT;
+ if (j1 < 0 || j1 > height_minus_1) useBorderColor |= J1BIT;
+
+ /* get four texel samples */
+ if (useBorderColor & (I0BIT | J0BIT))
+ COPY_CHAN4(t00, tObj->_BorderChan);
+ else
+ img->FetchTexelc(img, i0, j0, 0, t00);
+
+ if (useBorderColor & (I1BIT | J0BIT))
+ COPY_CHAN4(t10, tObj->_BorderChan);
+ else
+ img->FetchTexelc(img, i1, j0, 0, t10);
+
+ if (useBorderColor & (I0BIT | J1BIT))
+ COPY_CHAN4(t01, tObj->_BorderChan);
+ else
+ img->FetchTexelc(img, i0, j1, 0, t01);
+
+ if (useBorderColor & (I1BIT | J1BIT))
+ COPY_CHAN4(t11, tObj->_BorderChan);
+ else
+ img->FetchTexelc(img, i1, j1, 0, t11);
+
+ /* compute interpolants */
+ a = FRAC(fcol);
+ b = FRAC(frow);
+#if CHAN_TYPE == GL_UNSIGNED_BYTE
+ ia = IROUND_POS(a * ILERP_SCALE);
+ ib = IROUND_POS(b * ILERP_SCALE);
+#endif
+
+ /* do bilinear interpolation of texel colors */
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][0] = lerp_2d(a, b, t00[0], t10[0], t01[0], t11[0]);
+ rgba[i][1] = lerp_2d(a, b, t00[1], t10[1], t01[1], t11[1]);
+ rgba[i][2] = lerp_2d(a, b, t00[2], t10[2], t01[2], t11[2]);
+ rgba[i][3] = lerp_2d(a, b, t00[3], t10[3], t01[3], t11[3]);
+#elif CHAN_TYPE == GL_UNSIGNED_SHORT
+ rgba[i][0] = (GLchan) (lerp_2d(a, b, t00[0], t10[0], t01[0], t11[0]) + 0.5);
+ rgba[i][1] = (GLchan) (lerp_2d(a, b, t00[1], t10[1], t01[1], t11[1]) + 0.5);
+ rgba[i][2] = (GLchan) (lerp_2d(a, b, t00[2], t10[2], t01[2], t11[2]) + 0.5);
+ rgba[i][3] = (GLchan) (lerp_2d(a, b, t00[3], t10[3], t01[3], t11[3]) + 0.5);
+#else
+ ASSERT(CHAN_TYPE == GL_UNSIGNED_BYTE);
+ rgba[i][0] = ilerp_2d(ia, ib, t00[0], t10[0], t01[0], t11[0]);
+ rgba[i][1] = ilerp_2d(ia, ib, t00[1], t10[1], t01[1], t11[1]);
+ rgba[i][2] = ilerp_2d(ia, ib, t00[2], t10[2], t01[2], t11[2]);
+ rgba[i][3] = ilerp_2d(ia, ib, t00[3], t10[3], t01[3], t11[3]);
+#endif
+ }
+}
+
+
+static void
+sample_lambda_rect( GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ const GLfloat texcoords[][4], const GLfloat lambda[],
+ GLchan rgba[][4])
+{
+ GLuint minStart, minEnd, magStart, magEnd;
+
+ /* We only need lambda to decide between minification and magnification.
+ * There is no mipmapping with rectangular textures.
+ */
+ compute_min_mag_ranges(SWRAST_CONTEXT(ctx)->_MinMagThresh[texUnit],
+ n, lambda, &minStart, &minEnd, &magStart, &magEnd);
+
+ if (minStart < minEnd) {
+ if (tObj->MinFilter == GL_NEAREST) {
+ sample_nearest_rect( ctx, texUnit, tObj, minEnd - minStart,
+ texcoords + minStart, NULL, rgba + minStart);
+ }
+ else {
+ sample_linear_rect( ctx, texUnit, tObj, minEnd - minStart,
+ texcoords + minStart, NULL, rgba + minStart);
+ }
+ }
+ if (magStart < magEnd) {
+ if (tObj->MagFilter == GL_NEAREST) {
+ sample_nearest_rect( ctx, texUnit, tObj, magEnd - magStart,
+ texcoords + magStart, NULL, rgba + magStart);
+ }
+ else {
+ sample_linear_rect( ctx, texUnit, tObj, magEnd - magStart,
+ texcoords + magStart, NULL, rgba + magStart);
+ }
+ }
+}
+
+
+
+/*
+ * Sample a shadow/depth texture.
+ */
+static void
+sample_depth_texture( GLcontext *ctx, GLuint unit,
+ const struct gl_texture_object *tObj, GLuint n,
+ const GLfloat texcoords[][4], const GLfloat lambda[],
+ GLchan texel[][4] )
+{
+ const GLint baseLevel = tObj->BaseLevel;
+ const struct gl_texture_image *texImage = tObj->Image[0][baseLevel];
+ const GLuint width = texImage->Width;
+ const GLuint height = texImage->Height;
+ GLchan ambient;
+ GLenum function;
+ GLchan result;
+
+ (void) lambda;
+ (void) unit;
+
+ ASSERT(tObj->Image[0][tObj->BaseLevel]->Format == GL_DEPTH_COMPONENT);
+ ASSERT(tObj->Target == GL_TEXTURE_1D ||
+ tObj->Target == GL_TEXTURE_2D ||
+ tObj->Target == GL_TEXTURE_RECTANGLE_NV);
+
+ UNCLAMPED_FLOAT_TO_CHAN(ambient, tObj->ShadowAmbient);
+
+ /* XXXX if tObj->MinFilter != tObj->MagFilter, we're ignoring lambda */
+
+ /* XXX this could be precomputed and saved in the texture object */
+ if (tObj->CompareFlag) {
+ /* GL_SGIX_shadow */
+ if (tObj->CompareOperator == GL_TEXTURE_LEQUAL_R_SGIX) {
+ function = GL_LEQUAL;
+ }
+ else {
+ ASSERT(tObj->CompareOperator == GL_TEXTURE_GEQUAL_R_SGIX);
+ function = GL_GEQUAL;
+ }
+ }
+ else if (tObj->CompareMode == GL_COMPARE_R_TO_TEXTURE_ARB) {
+ /* GL_ARB_shadow */
+ function = tObj->CompareFunc;
+ }
+ else {
+ function = GL_NONE; /* pass depth through as grayscale */
+ }
+
+ if (tObj->MagFilter == GL_NEAREST) {
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ GLfloat depthSample;
+ GLint col, row;
+ /* XXX fix for texture rectangle! */
+ COMPUTE_NEAREST_TEXEL_LOCATION(tObj->WrapS, texcoords[i][0], width, col);
+ COMPUTE_NEAREST_TEXEL_LOCATION(tObj->WrapT, texcoords[i][1], height, row);
+ texImage->FetchTexelf(texImage, col, row, 0, &depthSample);
+
+ switch (function) {
+ case GL_LEQUAL:
+ result = (texcoords[i][2] <= depthSample) ? CHAN_MAX : ambient;
+ break;
+ case GL_GEQUAL:
+ result = (texcoords[i][2] >= depthSample) ? CHAN_MAX : ambient;
+ break;
+ case GL_LESS:
+ result = (texcoords[i][2] < depthSample) ? CHAN_MAX : ambient;
+ break;
+ case GL_GREATER:
+ result = (texcoords[i][2] > depthSample) ? CHAN_MAX : ambient;
+ break;
+ case GL_EQUAL:
+ result = (texcoords[i][2] == depthSample) ? CHAN_MAX : ambient;
+ break;
+ case GL_NOTEQUAL:
+ result = (texcoords[i][2] != depthSample) ? CHAN_MAX : ambient;
+ break;
+ case GL_ALWAYS:
+ result = CHAN_MAX;
+ break;
+ case GL_NEVER:
+ result = ambient;
+ break;
+ case GL_NONE:
+ CLAMPED_FLOAT_TO_CHAN(result, depthSample);
+ break;
+ default:
+ _mesa_problem(ctx, "Bad compare func in sample_depth_texture");
+ return;
+ }
+
+ switch (tObj->DepthMode) {
+ case GL_LUMINANCE:
+ texel[i][RCOMP] = result;
+ texel[i][GCOMP] = result;
+ texel[i][BCOMP] = result;
+ texel[i][ACOMP] = CHAN_MAX;
+ break;
+ case GL_INTENSITY:
+ texel[i][RCOMP] = result;
+ texel[i][GCOMP] = result;
+ texel[i][BCOMP] = result;
+ texel[i][ACOMP] = result;
+ break;
+ case GL_ALPHA:
+ texel[i][RCOMP] = 0;
+ texel[i][GCOMP] = 0;
+ texel[i][BCOMP] = 0;
+ texel[i][ACOMP] = result;
+ break;
+ default:
+ _mesa_problem(ctx, "Bad depth texture mode");
+ }
+ }
+ }
+ else {
+ GLuint i;
+ ASSERT(tObj->MagFilter == GL_LINEAR);
+ for (i = 0; i < n; i++) {
+ GLfloat depth00, depth01, depth10, depth11;
+ GLint i0, i1, j0, j1;
+ GLfloat u, v;
+ GLuint useBorderTexel;
+
+ /* XXX fix for texture rectangle! */
+ COMPUTE_LINEAR_TEXEL_LOCATIONS(tObj->WrapS, texcoords[i][0], u, width, i0, i1);
+ COMPUTE_LINEAR_TEXEL_LOCATIONS(tObj->WrapT, texcoords[i][1], v, height,j0, j1);
+
+ useBorderTexel = 0;
+ if (texImage->Border) {
+ i0 += texImage->Border;
+ i1 += texImage->Border;
+ j0 += texImage->Border;
+ j1 += texImage->Border;
+ }
+ else {
+ if (i0 < 0 || i0 >= (GLint) width) useBorderTexel |= I0BIT;
+ if (i1 < 0 || i1 >= (GLint) width) useBorderTexel |= I1BIT;
+ if (j0 < 0 || j0 >= (GLint) height) useBorderTexel |= J0BIT;
+ if (j1 < 0 || j1 >= (GLint) height) useBorderTexel |= J1BIT;
+ }
+
+ /* get four depth samples from the texture */
+ if (useBorderTexel & (I0BIT | J0BIT)) {
+ depth00 = 1.0;
+ }
+ else {
+ texImage->FetchTexelf(texImage, i0, j0, 0, &depth00);
+ }
+ if (useBorderTexel & (I1BIT | J0BIT)) {
+ depth10 = 1.0;
+ }
+ else {
+ texImage->FetchTexelf(texImage, i1, j0, 0, &depth10);
+ }
+ if (useBorderTexel & (I0BIT | J1BIT)) {
+ depth01 = 1.0;
+ }
+ else {
+ texImage->FetchTexelf(texImage, i0, j1, 0, &depth01);
+ }
+ if (useBorderTexel & (I1BIT | J1BIT)) {
+ depth11 = 1.0;
+ }
+ else {
+ texImage->FetchTexelf(texImage, i1, j1, 0, &depth11);
+ }
+
+ if (0) {
+ /* compute a single weighted depth sample and do one comparison */
+ const GLfloat a = FRAC(u + 1.0F);
+ const GLfloat b = FRAC(v + 1.0F);
+ const GLfloat depthSample
+ = lerp_2d(a, b, depth00, depth10, depth01, depth11);
+ if ((depthSample <= texcoords[i][2] && function == GL_LEQUAL) ||
+ (depthSample >= texcoords[i][2] && function == GL_GEQUAL)) {
+ result = ambient;
+ }
+ else {
+ result = CHAN_MAX;
+ }
+ }
+ else {
+ /* Do four depth/R comparisons and compute a weighted result.
+ * If this touches on somebody's I.P., I'll remove this code
+ * upon request.
+ */
+ const GLfloat d = (CHAN_MAXF - (GLfloat) ambient) * 0.25F;
+ GLfloat luminance = CHAN_MAXF;
+
+ switch (function) {
+ case GL_LEQUAL:
+ if (depth00 <= texcoords[i][2]) luminance -= d;
+ if (depth01 <= texcoords[i][2]) luminance -= d;
+ if (depth10 <= texcoords[i][2]) luminance -= d;
+ if (depth11 <= texcoords[i][2]) luminance -= d;
+ result = (GLchan) luminance;
+ break;
+ case GL_GEQUAL:
+ if (depth00 >= texcoords[i][2]) luminance -= d;
+ if (depth01 >= texcoords[i][2]) luminance -= d;
+ if (depth10 >= texcoords[i][2]) luminance -= d;
+ if (depth11 >= texcoords[i][2]) luminance -= d;
+ result = (GLchan) luminance;
+ break;
+ case GL_LESS:
+ if (depth00 < texcoords[i][2]) luminance -= d;
+ if (depth01 < texcoords[i][2]) luminance -= d;
+ if (depth10 < texcoords[i][2]) luminance -= d;
+ if (depth11 < texcoords[i][2]) luminance -= d;
+ result = (GLchan) luminance;
+ break;
+ case GL_GREATER:
+ if (depth00 > texcoords[i][2]) luminance -= d;
+ if (depth01 > texcoords[i][2]) luminance -= d;
+ if (depth10 > texcoords[i][2]) luminance -= d;
+ if (depth11 > texcoords[i][2]) luminance -= d;
+ result = (GLchan) luminance;
+ break;
+ case GL_EQUAL:
+ if (depth00 == texcoords[i][2]) luminance -= d;
+ if (depth01 == texcoords[i][2]) luminance -= d;
+ if (depth10 == texcoords[i][2]) luminance -= d;
+ if (depth11 == texcoords[i][2]) luminance -= d;
+ result = (GLchan) luminance;
+ break;
+ case GL_NOTEQUAL:
+ if (depth00 != texcoords[i][2]) luminance -= d;
+ if (depth01 != texcoords[i][2]) luminance -= d;
+ if (depth10 != texcoords[i][2]) luminance -= d;
+ if (depth11 != texcoords[i][2]) luminance -= d;
+ result = (GLchan) luminance;
+ break;
+ case GL_ALWAYS:
+ result = 0;
+ break;
+ case GL_NEVER:
+ result = CHAN_MAX;
+ break;
+ case GL_NONE:
+ /* ordinary bilinear filtering */
+ {
+ const GLfloat a = FRAC(u + 1.0F);
+ const GLfloat b = FRAC(v + 1.0F);
+ const GLfloat depthSample
+ = lerp_2d(a, b, depth00, depth10, depth01, depth11);
+ CLAMPED_FLOAT_TO_CHAN(result, depthSample);
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad compare func in sample_depth_texture");
+ return;
+ }
+ }
+
+ switch (tObj->DepthMode) {
+ case GL_LUMINANCE:
+ texel[i][RCOMP] = result;
+ texel[i][GCOMP] = result;
+ texel[i][BCOMP] = result;
+ texel[i][ACOMP] = CHAN_MAX;
+ break;
+ case GL_INTENSITY:
+ texel[i][RCOMP] = result;
+ texel[i][GCOMP] = result;
+ texel[i][BCOMP] = result;
+ texel[i][ACOMP] = result;
+ break;
+ case GL_ALPHA:
+ texel[i][RCOMP] = 0;
+ texel[i][GCOMP] = 0;
+ texel[i][BCOMP] = 0;
+ texel[i][ACOMP] = result;
+ break;
+ default:
+ _mesa_problem(ctx, "Bad depth texture mode");
+ }
+ } /* for */
+ } /* if filter */
+}
+
+
+#if 0
+/*
+ * Experimental depth texture sampling function.
+ */
+static void
+sample_depth_texture2(const GLcontext *ctx,
+ const struct gl_texture_unit *texUnit,
+ GLuint n, const GLfloat texcoords[][4],
+ GLchan texel[][4])
+{
+ const struct gl_texture_object *texObj = texUnit->_Current;
+ const GLint baseLevel = texObj->BaseLevel;
+ const struct gl_texture_image *texImage = texObj->Image[0][baseLevel];
+ const GLuint width = texImage->Width;
+ const GLuint height = texImage->Height;
+ GLchan ambient;
+ GLboolean lequal, gequal;
+
+ if (texObj->Target != GL_TEXTURE_2D) {
+ _mesa_problem(ctx, "only 2-D depth textures supported at this time");
+ return;
+ }
+
+ if (texObj->MinFilter != texObj->MagFilter) {
+ _mesa_problem(ctx, "mipmapped depth textures not supported at this time");
+ return;
+ }
+
+ /* XXX the GL_SGIX_shadow extension spec doesn't say what to do if
+ * GL_TEXTURE_COMPARE_SGIX == GL_TRUE but the current texture object
+ * isn't a depth texture.
+ */
+ if (texImage->Format != GL_DEPTH_COMPONENT) {
+ _mesa_problem(ctx,"GL_TEXTURE_COMPARE_SGIX enabled with non-depth texture");
+ return;
+ }
+
+ UNCLAMPED_FLOAT_TO_CHAN(ambient, tObj->ShadowAmbient);
+
+ if (texObj->CompareOperator == GL_TEXTURE_LEQUAL_R_SGIX) {
+ lequal = GL_TRUE;
+ gequal = GL_FALSE;
+ }
+ else {
+ lequal = GL_FALSE;
+ gequal = GL_TRUE;
+ }
+
+ {
+ GLuint i;
+ for (i = 0; i < n; i++) {
+ const GLint K = 3;
+ GLint col, row, ii, jj, imin, imax, jmin, jmax, samples, count;
+ GLfloat w;
+ GLchan lum;
+ COMPUTE_NEAREST_TEXEL_LOCATION(texObj->WrapS, texcoords[i][0],
+ width, col);
+ COMPUTE_NEAREST_TEXEL_LOCATION(texObj->WrapT, texcoords[i][1],
+ height, row);
+
+ imin = col - K;
+ imax = col + K;
+ jmin = row - K;
+ jmax = row + K;
+
+ if (imin < 0) imin = 0;
+ if (imax >= width) imax = width - 1;
+ if (jmin < 0) jmin = 0;
+ if (jmax >= height) jmax = height - 1;
+
+ samples = (imax - imin + 1) * (jmax - jmin + 1);
+ count = 0;
+ for (jj = jmin; jj <= jmax; jj++) {
+ for (ii = imin; ii <= imax; ii++) {
+ GLfloat depthSample;
+ texImage->FetchTexelf(texImage, ii, jj, 0, &depthSample);
+ if ((depthSample <= r[i] && lequal) ||
+ (depthSample >= r[i] && gequal)) {
+ count++;
+ }
+ }
+ }
+
+ w = (GLfloat) count / (GLfloat) samples;
+ w = CHAN_MAXF - w * (CHAN_MAXF - (GLfloat) ambient);
+ lum = (GLint) w;
+
+ texel[i][RCOMP] = lum;
+ texel[i][GCOMP] = lum;
+ texel[i][BCOMP] = lum;
+ texel[i][ACOMP] = CHAN_MAX;
+ }
+ }
+}
+#endif
+
+
+/**
+ * We use this function when a texture object is in an "incomplete" state.
+ * When a fragment program attempts to sample an incomplete texture we
+ * return black (see issue 23 in GL_ARB_fragment_program spec).
+ * Note: fragment programss don't observe the texture enable/disable flags.
+ */
+static void
+null_sample_func( GLcontext *ctx, GLuint texUnit,
+ const struct gl_texture_object *tObj, GLuint n,
+ const GLfloat texcoords[][4], const GLfloat lambda[],
+ GLchan rgba[][4])
+{
+ GLuint i;
+ (void) ctx;
+ (void) texUnit;
+ (void) tObj;
+ (void) texcoords;
+ (void) lambda;
+ for (i = 0; i < n; i++) {
+ rgba[i][RCOMP] = 0;
+ rgba[i][GCOMP] = 0;
+ rgba[i][BCOMP] = 0;
+ rgba[i][ACOMP] = CHAN_MAX;
+ }
+}
+
+
+/**
+ * Setup the texture sampling function for this texture object.
+ */
+texture_sample_func
+_swrast_choose_texture_sample_func( GLcontext *ctx,
+ const struct gl_texture_object *t )
+{
+ if (!t || !t->Complete) {
+ return &null_sample_func;
+ }
+ else {
+ const GLboolean needLambda = (GLboolean) (t->MinFilter != t->MagFilter);
+ const GLenum format = t->Image[0][t->BaseLevel]->Format;
+
+ switch (t->Target) {
+ case GL_TEXTURE_1D:
+ if (format == GL_DEPTH_COMPONENT) {
+ return &sample_depth_texture;
+ }
+ else if (needLambda) {
+ return &sample_lambda_1d;
+ }
+ else if (t->MinFilter == GL_LINEAR) {
+ return &sample_linear_1d;
+ }
+ else {
+ ASSERT(t->MinFilter == GL_NEAREST);
+ return &sample_nearest_1d;
+ }
+ case GL_TEXTURE_2D:
+ if (format == GL_DEPTH_COMPONENT) {
+ return &sample_depth_texture;
+ }
+ else if (needLambda) {
+ return &sample_lambda_2d;
+ }
+ else if (t->MinFilter == GL_LINEAR) {
+ return &sample_linear_2d;
+ }
+ else {
+ GLint baseLevel = t->BaseLevel;
+ ASSERT(t->MinFilter == GL_NEAREST);
+ if (t->WrapS == GL_REPEAT &&
+ t->WrapT == GL_REPEAT &&
+ t->_IsPowerOfTwo &&
+ t->Image[0][baseLevel]->Border == 0 &&
+ t->Image[0][baseLevel]->TexFormat->MesaFormat == MESA_FORMAT_RGB) {
+ return &opt_sample_rgb_2d;
+ }
+ else if (t->WrapS == GL_REPEAT &&
+ t->WrapT == GL_REPEAT &&
+ t->_IsPowerOfTwo &&
+ t->Image[0][baseLevel]->Border == 0 &&
+ t->Image[0][baseLevel]->TexFormat->MesaFormat == MESA_FORMAT_RGBA) {
+ return &opt_sample_rgba_2d;
+ }
+ else {
+ return &sample_nearest_2d;
+ }
+ }
+ case GL_TEXTURE_3D:
+ if (needLambda) {
+ return &sample_lambda_3d;
+ }
+ else if (t->MinFilter == GL_LINEAR) {
+ return &sample_linear_3d;
+ }
+ else {
+ ASSERT(t->MinFilter == GL_NEAREST);
+ return &sample_nearest_3d;
+ }
+ case GL_TEXTURE_CUBE_MAP:
+ if (needLambda) {
+ return &sample_lambda_cube;
+ }
+ else if (t->MinFilter == GL_LINEAR) {
+ return &sample_linear_cube;
+ }
+ else {
+ ASSERT(t->MinFilter == GL_NEAREST);
+ return &sample_nearest_cube;
+ }
+ case GL_TEXTURE_RECTANGLE_NV:
+ if (needLambda) {
+ return &sample_lambda_rect;
+ }
+ else if (t->MinFilter == GL_LINEAR) {
+ return &sample_linear_rect;
+ }
+ else {
+ ASSERT(t->MinFilter == GL_NEAREST);
+ return &sample_nearest_rect;
+ }
+ default:
+ _mesa_problem(ctx,
+ "invalid target in _swrast_choose_texture_sample_func");
+ return &null_sample_func;
+ }
+ }
+}
+
+
+#define PROD(A,B) ( (GLuint)(A) * ((GLuint)(B)+1) )
+#define S_PROD(A,B) ( (GLint)(A) * ((GLint)(B)+1) )
+
+
+/**
+ * Do texture application for GL_ARB/EXT_texture_env_combine.
+ * This function also supports GL_{EXT,ARB}_texture_env_dot3 and
+ * GL_ATI_texture_env_combine3. Since "classic" texture environments are
+ * implemented using GL_ARB_texture_env_combine-like state, this same function
+ * is used for classic texture environment application as well.
+ *
+ * \param ctx rendering context
+ * \param textureUnit the texture unit to apply
+ * \param n number of fragments to process (span width)
+ * \param primary_rgba incoming fragment color array
+ * \param texelBuffer pointer to texel colors for all texture units
+ *
+ * \param rgba incoming colors, which get modified here
+ */
+static INLINE void
+texture_combine( const GLcontext *ctx, GLuint unit, GLuint n,
+ CONST GLchan (*primary_rgba)[4],
+ CONST GLchan *texelBuffer,
+ GLchan (*rgba)[4] )
+{
+ const struct gl_texture_unit *textureUnit = &(ctx->Texture.Unit[unit]);
+ const GLchan (*argRGB [3])[4];
+ const GLchan (*argA [3])[4];
+ const GLuint RGBshift = textureUnit->_CurrentCombine->ScaleShiftRGB;
+ const GLuint Ashift = textureUnit->_CurrentCombine->ScaleShiftA;
+#if CHAN_TYPE == GL_FLOAT
+ const GLchan RGBmult = (GLfloat) (1 << RGBshift);
+ const GLchan Amult = (GLfloat) (1 << Ashift);
+ static const GLchan one[4] = { 1.0, 1.0, 1.0, 1.0 };
+ static const GLchan zero[4] = { 0.0, 0.0, 0.0, 0.0 };
+#else
+ const GLint half = (CHAN_MAX + 1) / 2;
+ static const GLchan one[4] = { CHAN_MAX, CHAN_MAX, CHAN_MAX, CHAN_MAX };
+ static const GLchan zero[4] = { 0, 0, 0, 0 };
+#endif
+ GLuint i, j;
+ GLuint numColorArgs;
+ GLuint numAlphaArgs;
+
+ /* GLchan ccolor[3][4]; */
+ DEFMNARRAY(GLchan, ccolor, 3, 3 * MAX_WIDTH, 4); /* mac 32k limitation */
+ CHECKARRAY(ccolor, return); /* mac 32k limitation */
+
+ ASSERT(ctx->Extensions.EXT_texture_env_combine ||
+ ctx->Extensions.ARB_texture_env_combine);
+ ASSERT(SWRAST_CONTEXT(ctx)->_AnyTextureCombine);
+
+
+ /*
+ printf("modeRGB 0x%x modeA 0x%x srcRGB1 0x%x srcA1 0x%x srcRGB2 0x%x srcA2 0x%x\n",
+ textureUnit->_CurrentCombine->ModeRGB,
+ textureUnit->_CurrentCombine->ModeA,
+ textureUnit->_CurrentCombine->SourceRGB[0],
+ textureUnit->_CurrentCombine->SourceA[0],
+ textureUnit->_CurrentCombine->SourceRGB[1],
+ textureUnit->_CurrentCombine->SourceA[1]);
+ */
+
+ /*
+ * Do operand setup for up to 3 operands. Loop over the terms.
+ */
+ numColorArgs = textureUnit->_CurrentCombine->_NumArgsRGB;
+ numAlphaArgs = textureUnit->_CurrentCombine->_NumArgsA;
+
+ for (j = 0; j < numColorArgs; j++) {
+ const GLenum srcRGB = textureUnit->_CurrentCombine->SourceRGB[j];
+
+
+ switch (srcRGB) {
+ case GL_TEXTURE:
+ argRGB[j] = (const GLchan (*)[4])
+ (texelBuffer + unit * (n * 4 * sizeof(GLchan)));
+ break;
+ case GL_PRIMARY_COLOR:
+ argRGB[j] = primary_rgba;
+ break;
+ case GL_PREVIOUS:
+ argRGB[j] = (const GLchan (*)[4]) rgba;
+ break;
+ case GL_CONSTANT:
+ {
+ GLchan (*c)[4] = ccolor[j];
+ GLchan red, green, blue, alpha;
+ UNCLAMPED_FLOAT_TO_CHAN(red, textureUnit->EnvColor[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(green, textureUnit->EnvColor[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(blue, textureUnit->EnvColor[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(alpha, textureUnit->EnvColor[3]);
+ for (i = 0; i < n; i++) {
+ c[i][RCOMP] = red;
+ c[i][GCOMP] = green;
+ c[i][BCOMP] = blue;
+ c[i][ACOMP] = alpha;
+ }
+ argRGB[j] = (const GLchan (*)[4]) ccolor[j];
+ }
+ break;
+ /* GL_ATI_texture_env_combine3 allows GL_ZERO & GL_ONE as sources.
+ */
+ case GL_ZERO:
+ argRGB[j] = & zero;
+ break;
+ case GL_ONE:
+ argRGB[j] = & one;
+ break;
+ default:
+ /* ARB_texture_env_crossbar source */
+ {
+ const GLuint srcUnit = srcRGB - GL_TEXTURE0;
+ ASSERT(srcUnit < ctx->Const.MaxTextureUnits);
+ if (!ctx->Texture.Unit[srcUnit]._ReallyEnabled)
+ return;
+ argRGB[j] = (const GLchan (*)[4])
+ (texelBuffer + srcUnit * (n * 4 * sizeof(GLchan)));
+ }
+ }
+
+ if (textureUnit->_CurrentCombine->OperandRGB[j] != GL_SRC_COLOR) {
+ const GLchan (*src)[4] = argRGB[j];
+ GLchan (*dst)[4] = ccolor[j];
+
+ /* point to new arg[j] storage */
+ argRGB[j] = (const GLchan (*)[4]) ccolor[j];
+
+ if (textureUnit->_CurrentCombine->OperandRGB[j] == GL_ONE_MINUS_SRC_COLOR) {
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = CHAN_MAX - src[i][RCOMP];
+ dst[i][GCOMP] = CHAN_MAX - src[i][GCOMP];
+ dst[i][BCOMP] = CHAN_MAX - src[i][BCOMP];
+ }
+ }
+ else if (textureUnit->_CurrentCombine->OperandRGB[j] == GL_SRC_ALPHA) {
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = src[i][ACOMP];
+ dst[i][GCOMP] = src[i][ACOMP];
+ dst[i][BCOMP] = src[i][ACOMP];
+ }
+ }
+ else {
+ ASSERT(textureUnit->_CurrentCombine->OperandRGB[j] ==GL_ONE_MINUS_SRC_ALPHA);
+ for (i = 0; i < n; i++) {
+ dst[i][RCOMP] = CHAN_MAX - src[i][ACOMP];
+ dst[i][GCOMP] = CHAN_MAX - src[i][ACOMP];
+ dst[i][BCOMP] = CHAN_MAX - src[i][ACOMP];
+ }
+ }
+ }
+ }
+
+
+ for (j = 0; j < numAlphaArgs; j++) {
+ const GLenum srcA = textureUnit->_CurrentCombine->SourceA[j];
+
+ switch (srcA) {
+ case GL_TEXTURE:
+ argA[j] = (const GLchan (*)[4])
+ (texelBuffer + unit * (n * 4 * sizeof(GLchan)));
+ break;
+ case GL_PRIMARY_COLOR:
+ argA[j] = primary_rgba;
+ break;
+ case GL_PREVIOUS:
+ argA[j] = (const GLchan (*)[4]) rgba;
+ break;
+ case GL_CONSTANT:
+ {
+ GLchan alpha, (*c)[4] = ccolor[j];
+ UNCLAMPED_FLOAT_TO_CHAN(alpha, textureUnit->EnvColor[3]);
+ for (i = 0; i < n; i++)
+ c[i][ACOMP] = alpha;
+ argA[j] = (const GLchan (*)[4]) ccolor[j];
+ }
+ break;
+ /* GL_ATI_texture_env_combine3 allows GL_ZERO & GL_ONE as sources.
+ */
+ case GL_ZERO:
+ argA[j] = & zero;
+ break;
+ case GL_ONE:
+ argA[j] = & one;
+ break;
+ default:
+ /* ARB_texture_env_crossbar source */
+ {
+ const GLuint srcUnit = srcA - GL_TEXTURE0;
+ ASSERT(srcUnit < ctx->Const.MaxTextureUnits);
+ if (!ctx->Texture.Unit[srcUnit]._ReallyEnabled)
+ return;
+ argA[j] = (const GLchan (*)[4])
+ (texelBuffer + srcUnit * (n * 4 * sizeof(GLchan)));
+ }
+ }
+
+ if (textureUnit->_CurrentCombine->OperandA[j] == GL_ONE_MINUS_SRC_ALPHA) {
+ const GLchan (*src)[4] = argA[j];
+ GLchan (*dst)[4] = ccolor[j];
+ argA[j] = (const GLchan (*)[4]) ccolor[j];
+ for (i = 0; i < n; i++) {
+ dst[i][ACOMP] = CHAN_MAX - src[i][ACOMP];
+ }
+ }
+ }
+
+ /*
+ * Do the texture combine.
+ */
+ switch (textureUnit->_CurrentCombine->ModeRGB) {
+ case GL_REPLACE:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0];
+ if (RGBshift) {
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][RCOMP] = arg0[i][RCOMP] * RGBmult;
+ rgba[i][GCOMP] = arg0[i][GCOMP] * RGBmult;
+ rgba[i][BCOMP] = arg0[i][BCOMP] * RGBmult;
+#else
+ GLuint r = (GLuint) arg0[i][RCOMP] << RGBshift;
+ GLuint g = (GLuint) arg0[i][GCOMP] << RGBshift;
+ GLuint b = (GLuint) arg0[i][BCOMP] << RGBshift;
+ rgba[i][RCOMP] = MIN2(r, CHAN_MAX);
+ rgba[i][GCOMP] = MIN2(g, CHAN_MAX);
+ rgba[i][BCOMP] = MIN2(b, CHAN_MAX);
+#endif
+ }
+ }
+ else {
+ for (i = 0; i < n; i++) {
+ rgba[i][RCOMP] = arg0[i][RCOMP];
+ rgba[i][GCOMP] = arg0[i][GCOMP];
+ rgba[i][BCOMP] = arg0[i][BCOMP];
+ }
+ }
+ }
+ break;
+ case GL_MODULATE:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1];
+#if CHAN_TYPE != GL_FLOAT
+ const GLint shift = CHAN_BITS - RGBshift;
+#endif
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][RCOMP] = arg0[i][RCOMP] * arg1[i][RCOMP] * RGBmult;
+ rgba[i][GCOMP] = arg0[i][GCOMP] * arg1[i][GCOMP] * RGBmult;
+ rgba[i][BCOMP] = arg0[i][BCOMP] * arg1[i][BCOMP] * RGBmult;
+#else
+ GLuint r = PROD(arg0[i][RCOMP], arg1[i][RCOMP]) >> shift;
+ GLuint g = PROD(arg0[i][GCOMP], arg1[i][GCOMP]) >> shift;
+ GLuint b = PROD(arg0[i][BCOMP], arg1[i][BCOMP]) >> shift;
+ rgba[i][RCOMP] = (GLchan) MIN2(r, CHAN_MAX);
+ rgba[i][GCOMP] = (GLchan) MIN2(g, CHAN_MAX);
+ rgba[i][BCOMP] = (GLchan) MIN2(b, CHAN_MAX);
+#endif
+ }
+ }
+ break;
+ case GL_ADD:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1];
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][RCOMP] = (arg0[i][RCOMP] + arg1[i][RCOMP]) * RGBmult;
+ rgba[i][GCOMP] = (arg0[i][GCOMP] + arg1[i][GCOMP]) * RGBmult;
+ rgba[i][BCOMP] = (arg0[i][BCOMP] + arg1[i][BCOMP]) * RGBmult;
+#else
+ GLint r = ((GLint) arg0[i][RCOMP] + (GLint) arg1[i][RCOMP]) << RGBshift;
+ GLint g = ((GLint) arg0[i][GCOMP] + (GLint) arg1[i][GCOMP]) << RGBshift;
+ GLint b = ((GLint) arg0[i][BCOMP] + (GLint) arg1[i][BCOMP]) << RGBshift;
+ rgba[i][RCOMP] = (GLchan) MIN2(r, CHAN_MAX);
+ rgba[i][GCOMP] = (GLchan) MIN2(g, CHAN_MAX);
+ rgba[i][BCOMP] = (GLchan) MIN2(b, CHAN_MAX);
+#endif
+ }
+ }
+ break;
+ case GL_ADD_SIGNED:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1];
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][RCOMP] = (arg0[i][RCOMP] + arg1[i][RCOMP] - 0.5) * RGBmult;
+ rgba[i][GCOMP] = (arg0[i][GCOMP] + arg1[i][GCOMP] - 0.5) * RGBmult;
+ rgba[i][BCOMP] = (arg0[i][BCOMP] + arg1[i][BCOMP] - 0.5) * RGBmult;
+#else
+ GLint r = (GLint) arg0[i][RCOMP] + (GLint) arg1[i][RCOMP] -half;
+ GLint g = (GLint) arg0[i][GCOMP] + (GLint) arg1[i][GCOMP] -half;
+ GLint b = (GLint) arg0[i][BCOMP] + (GLint) arg1[i][BCOMP] -half;
+ r = (r < 0) ? 0 : r << RGBshift;
+ g = (g < 0) ? 0 : g << RGBshift;
+ b = (b < 0) ? 0 : b << RGBshift;
+ rgba[i][RCOMP] = (GLchan) MIN2(r, CHAN_MAX);
+ rgba[i][GCOMP] = (GLchan) MIN2(g, CHAN_MAX);
+ rgba[i][BCOMP] = (GLchan) MIN2(b, CHAN_MAX);
+#endif
+ }
+ }
+ break;
+ case GL_INTERPOLATE:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1];
+ const GLchan (*arg2)[4] = (const GLchan (*)[4]) argRGB[2];
+#if CHAN_TYPE != GL_FLOAT
+ const GLint shift = CHAN_BITS - RGBshift;
+#endif
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][RCOMP] = (arg0[i][RCOMP] * arg2[i][RCOMP] +
+ arg1[i][RCOMP] * (CHAN_MAXF - arg2[i][RCOMP])) * RGBmult;
+ rgba[i][GCOMP] = (arg0[i][GCOMP] * arg2[i][GCOMP] +
+ arg1[i][GCOMP] * (CHAN_MAXF - arg2[i][GCOMP])) * RGBmult;
+ rgba[i][BCOMP] = (arg0[i][BCOMP] * arg2[i][BCOMP] +
+ arg1[i][BCOMP] * (CHAN_MAXF - arg2[i][BCOMP])) * RGBmult;
+#else
+ GLuint r = (PROD(arg0[i][RCOMP], arg2[i][RCOMP])
+ + PROD(arg1[i][RCOMP], CHAN_MAX - arg2[i][RCOMP]))
+ >> shift;
+ GLuint g = (PROD(arg0[i][GCOMP], arg2[i][GCOMP])
+ + PROD(arg1[i][GCOMP], CHAN_MAX - arg2[i][GCOMP]))
+ >> shift;
+ GLuint b = (PROD(arg0[i][BCOMP], arg2[i][BCOMP])
+ + PROD(arg1[i][BCOMP], CHAN_MAX - arg2[i][BCOMP]))
+ >> shift;
+ rgba[i][RCOMP] = (GLchan) MIN2(r, CHAN_MAX);
+ rgba[i][GCOMP] = (GLchan) MIN2(g, CHAN_MAX);
+ rgba[i][BCOMP] = (GLchan) MIN2(b, CHAN_MAX);
+#endif
+ }
+ }
+ break;
+ case GL_SUBTRACT:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1];
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][RCOMP] = (arg0[i][RCOMP] - arg1[i][RCOMP]) * RGBmult;
+ rgba[i][GCOMP] = (arg0[i][GCOMP] - arg1[i][GCOMP]) * RGBmult;
+ rgba[i][BCOMP] = (arg0[i][BCOMP] - arg1[i][BCOMP]) * RGBmult;
+#else
+ GLint r = ((GLint) arg0[i][RCOMP] - (GLint) arg1[i][RCOMP]) << RGBshift;
+ GLint g = ((GLint) arg0[i][GCOMP] - (GLint) arg1[i][GCOMP]) << RGBshift;
+ GLint b = ((GLint) arg0[i][BCOMP] - (GLint) arg1[i][BCOMP]) << RGBshift;
+ rgba[i][RCOMP] = (GLchan) CLAMP(r, 0, CHAN_MAX);
+ rgba[i][GCOMP] = (GLchan) CLAMP(g, 0, CHAN_MAX);
+ rgba[i][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX);
+#endif
+ }
+ }
+ break;
+ case GL_DOT3_RGB_EXT:
+ case GL_DOT3_RGBA_EXT:
+ {
+ /* Do not scale the result by 1 2 or 4 */
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1];
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ GLchan dot = ((arg0[i][RCOMP]-0.5F) * (arg1[i][RCOMP]-0.5F) +
+ (arg0[i][GCOMP]-0.5F) * (arg1[i][GCOMP]-0.5F) +
+ (arg0[i][BCOMP]-0.5F) * (arg1[i][BCOMP]-0.5F))
+ * 4.0F;
+ dot = CLAMP(dot, 0.0F, CHAN_MAXF);
+#else
+ GLint dot = (S_PROD((GLint)arg0[i][RCOMP] - half,
+ (GLint)arg1[i][RCOMP] - half) +
+ S_PROD((GLint)arg0[i][GCOMP] - half,
+ (GLint)arg1[i][GCOMP] - half) +
+ S_PROD((GLint)arg0[i][BCOMP] - half,
+ (GLint)arg1[i][BCOMP] - half)) >> 6;
+ dot = CLAMP(dot, 0, CHAN_MAX);
+#endif
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = (GLchan) dot;
+ }
+ }
+ break;
+ case GL_DOT3_RGB:
+ case GL_DOT3_RGBA:
+ {
+ /* DO scale the result by 1 2 or 4 */
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1];
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ GLchan dot = ((arg0[i][RCOMP]-0.5F) * (arg1[i][RCOMP]-0.5F) +
+ (arg0[i][GCOMP]-0.5F) * (arg1[i][GCOMP]-0.5F) +
+ (arg0[i][BCOMP]-0.5F) * (arg1[i][BCOMP]-0.5F))
+ * 4.0F * RGBmult;
+ dot = CLAMP(dot, 0.0, CHAN_MAXF);
+#else
+ GLint dot = (S_PROD((GLint)arg0[i][RCOMP] - half,
+ (GLint)arg1[i][RCOMP] - half) +
+ S_PROD((GLint)arg0[i][GCOMP] - half,
+ (GLint)arg1[i][GCOMP] - half) +
+ S_PROD((GLint)arg0[i][BCOMP] - half,
+ (GLint)arg1[i][BCOMP] - half)) >> 6;
+ dot <<= RGBshift;
+ dot = CLAMP(dot, 0, CHAN_MAX);
+#endif
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = (GLchan) dot;
+ }
+ }
+ break;
+ case GL_MODULATE_ADD_ATI:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1];
+ const GLchan (*arg2)[4] = (const GLchan (*)[4]) argRGB[2];
+#if CHAN_TYPE != GL_FLOAT
+ const GLint shift = CHAN_BITS - RGBshift;
+#endif
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][RCOMP] = ((arg0[i][RCOMP] * arg2[i][RCOMP]) + arg1[i][RCOMP]) * RGBmult;
+ rgba[i][GCOMP] = ((arg0[i][GCOMP] * arg2[i][GCOMP]) + arg1[i][GCOMP]) * RGBmult;
+ rgba[i][BCOMP] = ((arg0[i][BCOMP] * arg2[i][BCOMP]) + arg1[i][BCOMP]) * RGBmult;
+#else
+ GLuint r = (PROD(arg0[i][RCOMP], arg2[i][RCOMP])
+ + ((GLuint) arg1[i][RCOMP] << CHAN_BITS)) >> shift;
+ GLuint g = (PROD(arg0[i][GCOMP], arg2[i][GCOMP])
+ + ((GLuint) arg1[i][GCOMP] << CHAN_BITS)) >> shift;
+ GLuint b = (PROD(arg0[i][BCOMP], arg2[i][BCOMP])
+ + ((GLuint) arg1[i][BCOMP] << CHAN_BITS)) >> shift;
+ rgba[i][RCOMP] = (GLchan) MIN2(r, CHAN_MAX);
+ rgba[i][GCOMP] = (GLchan) MIN2(g, CHAN_MAX);
+ rgba[i][BCOMP] = (GLchan) MIN2(b, CHAN_MAX);
+#endif
+ }
+ }
+ break;
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1];
+ const GLchan (*arg2)[4] = (const GLchan (*)[4]) argRGB[2];
+#if CHAN_TYPE != GL_FLOAT
+ const GLint shift = CHAN_BITS - RGBshift;
+#endif
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][RCOMP] = ((arg0[i][RCOMP] * arg2[i][RCOMP]) + arg1[i][RCOMP] - 0.5) * RGBmult;
+ rgba[i][GCOMP] = ((arg0[i][GCOMP] * arg2[i][GCOMP]) + arg1[i][GCOMP] - 0.5) * RGBmult;
+ rgba[i][BCOMP] = ((arg0[i][BCOMP] * arg2[i][BCOMP]) + arg1[i][BCOMP] - 0.5) * RGBmult;
+#else
+ GLint r = (S_PROD(arg0[i][RCOMP], arg2[i][RCOMP])
+ + (((GLint) arg1[i][RCOMP] - half) << CHAN_BITS))
+ >> shift;
+ GLint g = (S_PROD(arg0[i][GCOMP], arg2[i][GCOMP])
+ + (((GLint) arg1[i][GCOMP] - half) << CHAN_BITS))
+ >> shift;
+ GLint b = (S_PROD(arg0[i][BCOMP], arg2[i][BCOMP])
+ + (((GLint) arg1[i][BCOMP] - half) << CHAN_BITS))
+ >> shift;
+ rgba[i][RCOMP] = (GLchan) CLAMP(r, 0, CHAN_MAX);
+ rgba[i][GCOMP] = (GLchan) CLAMP(g, 0, CHAN_MAX);
+ rgba[i][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX);
+#endif
+ }
+ }
+ break;
+ case GL_MODULATE_SUBTRACT_ATI:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argRGB[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argRGB[1];
+ const GLchan (*arg2)[4] = (const GLchan (*)[4]) argRGB[2];
+#if CHAN_TYPE != GL_FLOAT
+ const GLint shift = CHAN_BITS - RGBshift;
+#endif
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][RCOMP] = ((arg0[i][RCOMP] * arg2[i][RCOMP]) - arg1[i][RCOMP]) * RGBmult;
+ rgba[i][GCOMP] = ((arg0[i][GCOMP] * arg2[i][GCOMP]) - arg1[i][GCOMP]) * RGBmult;
+ rgba[i][BCOMP] = ((arg0[i][BCOMP] * arg2[i][BCOMP]) - arg1[i][BCOMP]) * RGBmult;
+#else
+ GLint r = (S_PROD(arg0[i][RCOMP], arg2[i][RCOMP])
+ - ((GLint) arg1[i][RCOMP] << CHAN_BITS))
+ >> shift;
+ GLint g = (S_PROD(arg0[i][GCOMP], arg2[i][GCOMP])
+ - ((GLint) arg1[i][GCOMP] << CHAN_BITS))
+ >> shift;
+ GLint b = (S_PROD(arg0[i][BCOMP], arg2[i][BCOMP])
+ - ((GLint) arg1[i][BCOMP] << CHAN_BITS))
+ >> shift;
+ rgba[i][RCOMP] = (GLchan) CLAMP(r, 0, CHAN_MAX);
+ rgba[i][GCOMP] = (GLchan) CLAMP(g, 0, CHAN_MAX);
+ rgba[i][BCOMP] = (GLchan) CLAMP(b, 0, CHAN_MAX);
+#endif
+ }
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "invalid combine mode");
+ }
+
+ switch (textureUnit->_CurrentCombine->ModeA) {
+ case GL_REPLACE:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0];
+ if (Ashift) {
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ GLchan a = arg0[i][ACOMP] * Amult;
+#else
+ GLuint a = (GLuint) arg0[i][ACOMP] << Ashift;
+#endif
+ rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAX);
+ }
+ }
+ else {
+ for (i = 0; i < n; i++) {
+ rgba[i][ACOMP] = arg0[i][ACOMP];
+ }
+ }
+ }
+ break;
+ case GL_MODULATE:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1];
+#if CHAN_TYPE != GL_FLOAT
+ const GLint shift = CHAN_BITS - Ashift;
+#endif
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][ACOMP] = arg0[i][ACOMP] * arg1[i][ACOMP] * Amult;
+#else
+ GLuint a = (PROD(arg0[i][ACOMP], arg1[i][ACOMP]) >> shift);
+ rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAX);
+#endif
+ }
+ }
+ break;
+ case GL_ADD:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1];
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][ACOMP] = (arg0[i][ACOMP] + arg1[i][ACOMP]) * Amult;
+#else
+ GLint a = ((GLint) arg0[i][ACOMP] + arg1[i][ACOMP]) << Ashift;
+ rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAX);
+#endif
+ }
+ }
+ break;
+ case GL_ADD_SIGNED:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1];
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][ACOMP] = (arg0[i][ACOMP] + arg1[i][ACOMP] - 0.5F) * Amult;
+#else
+ GLint a = (GLint) arg0[i][ACOMP] + (GLint) arg1[i][ACOMP] -half;
+ a = (a < 0) ? 0 : a << Ashift;
+ rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAX);
+#endif
+ }
+ }
+ break;
+ case GL_INTERPOLATE:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1];
+ const GLchan (*arg2)[4] = (const GLchan (*)[4]) argA[2];
+#if CHAN_TYPE != GL_FLOAT
+ const GLint shift = CHAN_BITS - Ashift;
+#endif
+ for (i=0; i<n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][ACOMP] = (arg0[i][ACOMP] * arg2[i][ACOMP] +
+ arg1[i][ACOMP] * (CHAN_MAXF - arg2[i][ACOMP]))
+ * Amult;
+#else
+ GLuint a = (PROD(arg0[i][ACOMP], arg2[i][ACOMP])
+ + PROD(arg1[i][ACOMP], CHAN_MAX - arg2[i][ACOMP]))
+ >> shift;
+ rgba[i][ACOMP] = (GLchan) MIN2(a, CHAN_MAX);
+#endif
+ }
+ }
+ break;
+ case GL_SUBTRACT:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1];
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][ACOMP] = (arg0[i][ACOMP] - arg1[i][ACOMP]) * Amult;
+#else
+ GLint a = ((GLint) arg0[i][ACOMP] - (GLint) arg1[i][ACOMP]) << Ashift;
+ rgba[i][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX);
+#endif
+ }
+ }
+ break;
+ case GL_MODULATE_ADD_ATI:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1];
+ const GLchan (*arg2)[4] = (const GLchan (*)[4]) argA[2];
+#if CHAN_TYPE != GL_FLOAT
+ const GLint shift = CHAN_BITS - Ashift;
+#endif
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][ACOMP] = ((arg0[i][ACOMP] * arg2[i][ACOMP]) + arg1[i][ACOMP]) * Amult;
+#else
+ GLint a = (PROD(arg0[i][ACOMP], arg2[i][ACOMP])
+ + ((GLuint) arg1[i][ACOMP] << CHAN_BITS))
+ >> shift;
+ rgba[i][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX);
+#endif
+ }
+ }
+ break;
+ case GL_MODULATE_SIGNED_ADD_ATI:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1];
+ const GLchan (*arg2)[4] = (const GLchan (*)[4]) argA[2];
+#if CHAN_TYPE != GL_FLOAT
+ const GLint shift = CHAN_BITS - Ashift;
+#endif
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][ACOMP] = ((arg0[i][ACOMP] * arg2[i][ACOMP]) + arg1[i][ACOMP] - 0.5F) * Amult;
+#else
+ GLint a = (S_PROD(arg0[i][ACOMP], arg2[i][ACOMP])
+ + (((GLint) arg1[i][ACOMP] - half) << CHAN_BITS))
+ >> shift;
+ rgba[i][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX);
+#endif
+ }
+ }
+ break;
+ case GL_MODULATE_SUBTRACT_ATI:
+ {
+ const GLchan (*arg0)[4] = (const GLchan (*)[4]) argA[0];
+ const GLchan (*arg1)[4] = (const GLchan (*)[4]) argA[1];
+ const GLchan (*arg2)[4] = (const GLchan (*)[4]) argA[2];
+#if CHAN_TYPE != GL_FLOAT
+ const GLint shift = CHAN_BITS - Ashift;
+#endif
+ for (i = 0; i < n; i++) {
+#if CHAN_TYPE == GL_FLOAT
+ rgba[i][ACOMP] = ((arg0[i][ACOMP] * arg2[i][ACOMP]) - arg1[i][ACOMP]) * Amult;
+#else
+ GLint a = (S_PROD(arg0[i][ACOMP], arg2[i][ACOMP])
+ - ((GLint) arg1[i][ACOMP] << CHAN_BITS))
+ >> shift;
+ rgba[i][ACOMP] = (GLchan) CLAMP(a, 0, CHAN_MAX);
+#endif
+ }
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "invalid combine mode");
+ }
+
+ /* Fix the alpha component for GL_DOT3_RGBA_EXT/ARB combining.
+ * This is kind of a kludge. It would have been better if the spec
+ * were written such that the GL_COMBINE_ALPHA value could be set to
+ * GL_DOT3.
+ */
+ if (textureUnit->_CurrentCombine->ModeRGB == GL_DOT3_RGBA_EXT ||
+ textureUnit->_CurrentCombine->ModeRGB == GL_DOT3_RGBA) {
+ for (i = 0; i < n; i++) {
+ rgba[i][ACOMP] = rgba[i][RCOMP];
+ }
+ }
+ UNDEFARRAY(ccolor); /* mac 32k limitation */
+}
+#undef PROD
+
+
+/**
+ * Apply a conventional OpenGL texture env mode (REPLACE, ADD, BLEND,
+ * MODULATE, or DECAL) to an array of fragments.
+ * Input: textureUnit - pointer to texture unit to apply
+ * format - base internal texture format
+ * n - number of fragments
+ * primary_rgba - primary colors (may alias rgba for single texture)
+ * texels - array of texel colors
+ * InOut: rgba - incoming fragment colors modified by texel colors
+ * according to the texture environment mode.
+ */
+static void
+texture_apply( const GLcontext *ctx,
+ const struct gl_texture_unit *texUnit,
+ GLuint n,
+ CONST GLchan primary_rgba[][4], CONST GLchan texel[][4],
+ GLchan rgba[][4] )
+{
+ GLint baseLevel;
+ GLuint i;
+ GLint Rc, Gc, Bc, Ac;
+ GLenum format;
+ (void) primary_rgba;
+
+ ASSERT(texUnit);
+ ASSERT(texUnit->_Current);
+
+ baseLevel = texUnit->_Current->BaseLevel;
+ ASSERT(texUnit->_Current->Image[0][baseLevel]);
+
+ format = texUnit->_Current->Image[0][baseLevel]->Format;
+
+ if (format == GL_COLOR_INDEX || format == GL_YCBCR_MESA) {
+ format = GL_RGBA; /* a bit of a hack */
+ }
+ else if (format == GL_DEPTH_COMPONENT) {
+ format = texUnit->_Current->DepthMode;
+ }
+
+ switch (texUnit->EnvMode) {
+ case GL_REPLACE:
+ switch (format) {
+ case GL_ALPHA:
+ for (i=0;i<n;i++) {
+ /* Cv = Cf */
+ /* Av = At */
+ rgba[i][ACOMP] = texel[i][ACOMP];
+ }
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++) {
+ /* Cv = Lt */
+ GLchan Lt = texel[i][RCOMP];
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = Lt;
+ /* Av = Af */
+ }
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i=0;i<n;i++) {
+ GLchan Lt = texel[i][RCOMP];
+ /* Cv = Lt */
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = Lt;
+ /* Av = At */
+ rgba[i][ACOMP] = texel[i][ACOMP];
+ }
+ break;
+ case GL_INTENSITY:
+ for (i=0;i<n;i++) {
+ /* Cv = It */
+ GLchan It = texel[i][RCOMP];
+ rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = It;
+ /* Av = It */
+ rgba[i][ACOMP] = It;
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;i++) {
+ /* Cv = Ct */
+ rgba[i][RCOMP] = texel[i][RCOMP];
+ rgba[i][GCOMP] = texel[i][GCOMP];
+ rgba[i][BCOMP] = texel[i][BCOMP];
+ /* Av = Af */
+ }
+ break;
+ case GL_RGBA:
+ for (i=0;i<n;i++) {
+ /* Cv = Ct */
+ rgba[i][RCOMP] = texel[i][RCOMP];
+ rgba[i][GCOMP] = texel[i][GCOMP];
+ rgba[i][BCOMP] = texel[i][BCOMP];
+ /* Av = At */
+ rgba[i][ACOMP] = texel[i][ACOMP];
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad format (GL_REPLACE) in texture_apply");
+ return;
+ }
+ break;
+
+ case GL_MODULATE:
+ switch (format) {
+ case GL_ALPHA:
+ for (i=0;i<n;i++) {
+ /* Cv = Cf */
+ /* Av = AfAt */
+ rgba[i][ACOMP] = CHAN_PRODUCT( rgba[i][ACOMP], texel[i][ACOMP] );
+ }
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++) {
+ /* Cv = LtCf */
+ GLchan Lt = texel[i][RCOMP];
+ rgba[i][RCOMP] = CHAN_PRODUCT( rgba[i][RCOMP], Lt );
+ rgba[i][GCOMP] = CHAN_PRODUCT( rgba[i][GCOMP], Lt );
+ rgba[i][BCOMP] = CHAN_PRODUCT( rgba[i][BCOMP], Lt );
+ /* Av = Af */
+ }
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i=0;i<n;i++) {
+ /* Cv = CfLt */
+ GLchan Lt = texel[i][RCOMP];
+ rgba[i][RCOMP] = CHAN_PRODUCT( rgba[i][RCOMP], Lt );
+ rgba[i][GCOMP] = CHAN_PRODUCT( rgba[i][GCOMP], Lt );
+ rgba[i][BCOMP] = CHAN_PRODUCT( rgba[i][BCOMP], Lt );
+ /* Av = AfAt */
+ rgba[i][ACOMP] = CHAN_PRODUCT( rgba[i][ACOMP], texel[i][ACOMP] );
+ }
+ break;
+ case GL_INTENSITY:
+ for (i=0;i<n;i++) {
+ /* Cv = CfIt */
+ GLchan It = texel[i][RCOMP];
+ rgba[i][RCOMP] = CHAN_PRODUCT( rgba[i][RCOMP], It );
+ rgba[i][GCOMP] = CHAN_PRODUCT( rgba[i][GCOMP], It );
+ rgba[i][BCOMP] = CHAN_PRODUCT( rgba[i][BCOMP], It );
+ /* Av = AfIt */
+ rgba[i][ACOMP] = CHAN_PRODUCT( rgba[i][ACOMP], It );
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;i++) {
+ /* Cv = CfCt */
+ rgba[i][RCOMP] = CHAN_PRODUCT( rgba[i][RCOMP], texel[i][RCOMP] );
+ rgba[i][GCOMP] = CHAN_PRODUCT( rgba[i][GCOMP], texel[i][GCOMP] );
+ rgba[i][BCOMP] = CHAN_PRODUCT( rgba[i][BCOMP], texel[i][BCOMP] );
+ /* Av = Af */
+ }
+ break;
+ case GL_RGBA:
+ for (i=0;i<n;i++) {
+ /* Cv = CfCt */
+ rgba[i][RCOMP] = CHAN_PRODUCT( rgba[i][RCOMP], texel[i][RCOMP] );
+ rgba[i][GCOMP] = CHAN_PRODUCT( rgba[i][GCOMP], texel[i][GCOMP] );
+ rgba[i][BCOMP] = CHAN_PRODUCT( rgba[i][BCOMP], texel[i][BCOMP] );
+ /* Av = AfAt */
+ rgba[i][ACOMP] = CHAN_PRODUCT( rgba[i][ACOMP], texel[i][ACOMP] );
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad format (GL_MODULATE) in texture_apply");
+ return;
+ }
+ break;
+
+ case GL_DECAL:
+ switch (format) {
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_LUMINANCE_ALPHA:
+ case GL_INTENSITY:
+ /* undefined */
+ break;
+ case GL_RGB:
+ for (i=0;i<n;i++) {
+ /* Cv = Ct */
+ rgba[i][RCOMP] = texel[i][RCOMP];
+ rgba[i][GCOMP] = texel[i][GCOMP];
+ rgba[i][BCOMP] = texel[i][BCOMP];
+ /* Av = Af */
+ }
+ break;
+ case GL_RGBA:
+ for (i=0;i<n;i++) {
+ /* Cv = Cf(1-At) + CtAt */
+ GLint t = texel[i][ACOMP], s = CHAN_MAX - t;
+ rgba[i][RCOMP] = CHAN_PRODUCT(rgba[i][RCOMP], s) + CHAN_PRODUCT(texel[i][RCOMP],t);
+ rgba[i][GCOMP] = CHAN_PRODUCT(rgba[i][GCOMP], s) + CHAN_PRODUCT(texel[i][GCOMP],t);
+ rgba[i][BCOMP] = CHAN_PRODUCT(rgba[i][BCOMP], s) + CHAN_PRODUCT(texel[i][BCOMP],t);
+ /* Av = Af */
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad format (GL_DECAL) in texture_apply");
+ return;
+ }
+ break;
+
+ case GL_BLEND:
+ Rc = (GLint) (texUnit->EnvColor[0] * CHAN_MAXF);
+ Gc = (GLint) (texUnit->EnvColor[1] * CHAN_MAXF);
+ Bc = (GLint) (texUnit->EnvColor[2] * CHAN_MAXF);
+ Ac = (GLint) (texUnit->EnvColor[3] * CHAN_MAXF);
+ switch (format) {
+ case GL_ALPHA:
+ for (i=0;i<n;i++) {
+ /* Cv = Cf */
+ /* Av = AfAt */
+ rgba[i][ACOMP] = CHAN_PRODUCT(rgba[i][ACOMP], texel[i][ACOMP]);
+ }
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++) {
+ /* Cv = Cf(1-Lt) + CcLt */
+ GLchan Lt = texel[i][RCOMP], s = CHAN_MAX - Lt;
+ rgba[i][RCOMP] = CHAN_PRODUCT(rgba[i][RCOMP], s) + CHAN_PRODUCT(Rc, Lt);
+ rgba[i][GCOMP] = CHAN_PRODUCT(rgba[i][GCOMP], s) + CHAN_PRODUCT(Gc, Lt);
+ rgba[i][BCOMP] = CHAN_PRODUCT(rgba[i][BCOMP], s) + CHAN_PRODUCT(Bc, Lt);
+ /* Av = Af */
+ }
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i=0;i<n;i++) {
+ /* Cv = Cf(1-Lt) + CcLt */
+ GLchan Lt = texel[i][RCOMP], s = CHAN_MAX - Lt;
+ rgba[i][RCOMP] = CHAN_PRODUCT(rgba[i][RCOMP], s) + CHAN_PRODUCT(Rc, Lt);
+ rgba[i][GCOMP] = CHAN_PRODUCT(rgba[i][GCOMP], s) + CHAN_PRODUCT(Gc, Lt);
+ rgba[i][BCOMP] = CHAN_PRODUCT(rgba[i][BCOMP], s) + CHAN_PRODUCT(Bc, Lt);
+ /* Av = AfAt */
+ rgba[i][ACOMP] = CHAN_PRODUCT(rgba[i][ACOMP],texel[i][ACOMP]);
+ }
+ break;
+ case GL_INTENSITY:
+ for (i=0;i<n;i++) {
+ /* Cv = Cf(1-It) + CcIt */
+ GLchan It = texel[i][RCOMP], s = CHAN_MAX - It;
+ rgba[i][RCOMP] = CHAN_PRODUCT(rgba[i][RCOMP], s) + CHAN_PRODUCT(Rc, It);
+ rgba[i][GCOMP] = CHAN_PRODUCT(rgba[i][GCOMP], s) + CHAN_PRODUCT(Gc, It);
+ rgba[i][BCOMP] = CHAN_PRODUCT(rgba[i][BCOMP], s) + CHAN_PRODUCT(Bc, It);
+ /* Av = Af(1-It) + Ac*It */
+ rgba[i][ACOMP] = CHAN_PRODUCT(rgba[i][ACOMP], s) + CHAN_PRODUCT(Ac, It);
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;i++) {
+ /* Cv = Cf(1-Ct) + CcCt */
+ rgba[i][RCOMP] = CHAN_PRODUCT(rgba[i][RCOMP], (CHAN_MAX-texel[i][RCOMP])) + CHAN_PRODUCT(Rc,texel[i][RCOMP]);
+ rgba[i][GCOMP] = CHAN_PRODUCT(rgba[i][GCOMP], (CHAN_MAX-texel[i][GCOMP])) + CHAN_PRODUCT(Gc,texel[i][GCOMP]);
+ rgba[i][BCOMP] = CHAN_PRODUCT(rgba[i][BCOMP], (CHAN_MAX-texel[i][BCOMP])) + CHAN_PRODUCT(Bc,texel[i][BCOMP]);
+ /* Av = Af */
+ }
+ break;
+ case GL_RGBA:
+ for (i=0;i<n;i++) {
+ /* Cv = Cf(1-Ct) + CcCt */
+ rgba[i][RCOMP] = CHAN_PRODUCT(rgba[i][RCOMP], (CHAN_MAX-texel[i][RCOMP])) + CHAN_PRODUCT(Rc,texel[i][RCOMP]);
+ rgba[i][GCOMP] = CHAN_PRODUCT(rgba[i][GCOMP], (CHAN_MAX-texel[i][GCOMP])) + CHAN_PRODUCT(Gc,texel[i][GCOMP]);
+ rgba[i][BCOMP] = CHAN_PRODUCT(rgba[i][BCOMP], (CHAN_MAX-texel[i][BCOMP])) + CHAN_PRODUCT(Bc,texel[i][BCOMP]);
+ /* Av = AfAt */
+ rgba[i][ACOMP] = CHAN_PRODUCT(rgba[i][ACOMP],texel[i][ACOMP]);
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad format (GL_BLEND) in texture_apply");
+ return;
+ }
+ break;
+
+ /* XXX don't clamp results if GLchan is float??? */
+
+ case GL_ADD: /* GL_EXT_texture_add_env */
+ switch (format) {
+ case GL_ALPHA:
+ for (i=0;i<n;i++) {
+ /* Rv = Rf */
+ /* Gv = Gf */
+ /* Bv = Bf */
+ rgba[i][ACOMP] = CHAN_PRODUCT(rgba[i][ACOMP], texel[i][ACOMP]);
+ }
+ break;
+ case GL_LUMINANCE:
+ for (i=0;i<n;i++) {
+ GLuint Lt = texel[i][RCOMP];
+ GLuint r = rgba[i][RCOMP] + Lt;
+ GLuint g = rgba[i][GCOMP] + Lt;
+ GLuint b = rgba[i][BCOMP] + Lt;
+ rgba[i][RCOMP] = MIN2(r, CHAN_MAX);
+ rgba[i][GCOMP] = MIN2(g, CHAN_MAX);
+ rgba[i][BCOMP] = MIN2(b, CHAN_MAX);
+ /* Av = Af */
+ }
+ break;
+ case GL_LUMINANCE_ALPHA:
+ for (i=0;i<n;i++) {
+ GLuint Lt = texel[i][RCOMP];
+ GLuint r = rgba[i][RCOMP] + Lt;
+ GLuint g = rgba[i][GCOMP] + Lt;
+ GLuint b = rgba[i][BCOMP] + Lt;
+ rgba[i][RCOMP] = MIN2(r, CHAN_MAX);
+ rgba[i][GCOMP] = MIN2(g, CHAN_MAX);
+ rgba[i][BCOMP] = MIN2(b, CHAN_MAX);
+ rgba[i][ACOMP] = CHAN_PRODUCT(rgba[i][ACOMP], texel[i][ACOMP]);
+ }
+ break;
+ case GL_INTENSITY:
+ for (i=0;i<n;i++) {
+ GLchan It = texel[i][RCOMP];
+ GLuint r = rgba[i][RCOMP] + It;
+ GLuint g = rgba[i][GCOMP] + It;
+ GLuint b = rgba[i][BCOMP] + It;
+ GLuint a = rgba[i][ACOMP] + It;
+ rgba[i][RCOMP] = MIN2(r, CHAN_MAX);
+ rgba[i][GCOMP] = MIN2(g, CHAN_MAX);
+ rgba[i][BCOMP] = MIN2(b, CHAN_MAX);
+ rgba[i][ACOMP] = MIN2(a, CHAN_MAX);
+ }
+ break;
+ case GL_RGB:
+ for (i=0;i<n;i++) {
+ GLuint r = rgba[i][RCOMP] + texel[i][RCOMP];
+ GLuint g = rgba[i][GCOMP] + texel[i][GCOMP];
+ GLuint b = rgba[i][BCOMP] + texel[i][BCOMP];
+ rgba[i][RCOMP] = MIN2(r, CHAN_MAX);
+ rgba[i][GCOMP] = MIN2(g, CHAN_MAX);
+ rgba[i][BCOMP] = MIN2(b, CHAN_MAX);
+ /* Av = Af */
+ }
+ break;
+ case GL_RGBA:
+ for (i=0;i<n;i++) {
+ GLuint r = rgba[i][RCOMP] + texel[i][RCOMP];
+ GLuint g = rgba[i][GCOMP] + texel[i][GCOMP];
+ GLuint b = rgba[i][BCOMP] + texel[i][BCOMP];
+ rgba[i][RCOMP] = MIN2(r, CHAN_MAX);
+ rgba[i][GCOMP] = MIN2(g, CHAN_MAX);
+ rgba[i][BCOMP] = MIN2(b, CHAN_MAX);
+ rgba[i][ACOMP] = CHAN_PRODUCT(rgba[i][ACOMP], texel[i][ACOMP]);
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad format (GL_ADD) in texture_apply");
+ return;
+ }
+ break;
+
+ default:
+ _mesa_problem(ctx, "Bad env mode in texture_apply");
+ return;
+ }
+}
+
+
+
+/**
+ * Apply texture mapping to a span of fragments.
+ */
+void
+_swrast_texture_span( GLcontext *ctx, struct sw_span *span )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ GLchan primary_rgba[MAX_WIDTH][4];
+ GLuint unit;
+
+ ASSERT(span->end < MAX_WIDTH);
+ ASSERT(span->arrayMask & SPAN_TEXTURE);
+
+ /*
+ * Save copy of the incoming fragment colors (the GL_PRIMARY_COLOR)
+ */
+ if (swrast->_AnyTextureCombine)
+ MEMCPY(primary_rgba, span->array->rgba, 4 * span->end * sizeof(GLchan));
+
+ /*
+ * Must do all texture sampling before combining in order to
+ * accomodate GL_ARB_texture_env_crossbar.
+ */
+ for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
+ if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ const struct gl_texture_object *curObj = texUnit->_Current;
+ GLfloat *lambda = span->array->lambda[unit];
+ GLchan (*texels)[4] = (GLchan (*)[4])
+ (swrast->TexelBuffer + unit * (span->end * 4 * sizeof(GLchan)));
+
+ /* adjust texture lod (lambda) */
+ if (span->arrayMask & SPAN_LAMBDA) {
+ if (texUnit->LodBias + curObj->LodBias != 0.0F) {
+ /* apply LOD bias, but don't clamp yet */
+ const GLfloat bias = CLAMP(texUnit->LodBias + curObj->LodBias,
+ -ctx->Const.MaxTextureLodBias,
+ ctx->Const.MaxTextureLodBias);
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ lambda[i] += bias;
+ }
+ }
+
+ if (curObj->MinLod != -1000.0 || curObj->MaxLod != 1000.0) {
+ /* apply LOD clamping to lambda */
+ const GLfloat min = curObj->MinLod;
+ const GLfloat max = curObj->MaxLod;
+ GLuint i;
+ for (i = 0; i < span->end; i++) {
+ GLfloat l = lambda[i];
+ lambda[i] = CLAMP(l, min, max);
+ }
+ }
+ }
+
+ /* Sample the texture (span->end fragments) */
+ swrast->TextureSample[unit]( ctx, unit, texUnit->_Current, span->end,
+ (const GLfloat (*)[4]) span->array->texcoords[unit],
+ lambda, texels );
+
+ /* GL_SGI_texture_color_table */
+ if (texUnit->ColorTableEnabled) {
+ _mesa_lookup_rgba_chan(&texUnit->ColorTable, span->end, texels);
+ }
+ }
+ }
+
+ /*
+ * OK, now apply the texture (aka texture combine/blend).
+ * We modify the span->color.rgba values.
+ */
+ for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
+ if (ctx->Texture.Unit[unit]._ReallyEnabled) {
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ if (texUnit->_CurrentCombine != &texUnit->_EnvMode ) {
+ texture_combine( ctx, unit, span->end,
+ (CONST GLchan (*)[4]) primary_rgba,
+ swrast->TexelBuffer,
+ span->array->rgba );
+ }
+ else {
+ /* conventional texture blend */
+ const GLchan (*texels)[4] = (const GLchan (*)[4])
+ (swrast->TexelBuffer + unit *
+ (span->end * 4 * sizeof(GLchan)));
+ texture_apply( ctx, texUnit, span->end,
+ (CONST GLchan (*)[4]) primary_rgba, texels,
+ span->array->rgba );
+ }
+ }
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_texture.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_texture.h
new file mode 100644
index 000000000..698f363a1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_texture.h
@@ -0,0 +1,42 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_TEXTURE_H
+#define S_TEXTURE_H
+
+
+#include "mtypes.h"
+#include "swrast.h"
+
+
+extern texture_sample_func
+_swrast_choose_texture_sample_func( GLcontext *ctx,
+ const struct gl_texture_object *tObj );
+
+
+extern void
+_swrast_texture_span( GLcontext *ctx, struct sw_span *span );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_triangle.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_triangle.c
new file mode 100644
index 000000000..16dea9477
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_triangle.c
@@ -0,0 +1,1175 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/*
+ * When the device driver doesn't implement triangle rasterization it
+ * can hook in _swrast_Triangle, which eventually calls one of these
+ * functions to draw triangles.
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "colormac.h"
+#include "imports.h"
+#include "macros.h"
+#include "texformat.h"
+
+#include "s_aatriangle.h"
+#include "s_context.h"
+#include "s_depth.h"
+#include "s_feedback.h"
+#include "s_span.h"
+#include "s_triangle.h"
+
+
+/*
+ * Just used for feedback mode.
+ */
+GLboolean
+_swrast_culltriangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ GLfloat ex = v1->win[0] - v0->win[0];
+ GLfloat ey = v1->win[1] - v0->win[1];
+ GLfloat fx = v2->win[0] - v0->win[0];
+ GLfloat fy = v2->win[1] - v0->win[1];
+ GLfloat c = ex*fy-ey*fx;
+
+ if (c * SWRAST_CONTEXT(ctx)->_BackfaceSign > 0)
+ return 0;
+
+ return 1;
+}
+
+
+
+/*
+ * Render a flat-shaded color index triangle.
+ */
+#define NAME flat_ci_triangle
+#define INTERP_Z 1
+#define INTERP_FOG 1
+#define SETUP_CODE \
+ span.interpMask |= SPAN_INDEX; \
+ span.index = FloatToFixed(v2->index);\
+ span.indexStep = 0;
+#define RENDER_SPAN( span ) _swrast_write_index_span(ctx, &span);
+#include "s_tritemp.h"
+
+
+
+/*
+ * Render a smooth-shaded color index triangle.
+ */
+#define NAME smooth_ci_triangle
+#define INTERP_Z 1
+#define INTERP_FOG 1
+#define INTERP_INDEX 1
+#define RENDER_SPAN( span ) _swrast_write_index_span(ctx, &span);
+#include "s_tritemp.h"
+
+
+
+/*
+ * Render a flat-shaded RGBA triangle.
+ */
+#define NAME flat_rgba_triangle
+#define INTERP_Z 1
+#define INTERP_FOG 1
+#define SETUP_CODE \
+ ASSERT(ctx->Texture._EnabledCoordUnits == 0);\
+ ASSERT(ctx->Light.ShadeModel==GL_FLAT); \
+ span.interpMask |= SPAN_RGBA; \
+ span.red = ChanToFixed(v2->color[0]); \
+ span.green = ChanToFixed(v2->color[1]); \
+ span.blue = ChanToFixed(v2->color[2]); \
+ span.alpha = ChanToFixed(v2->color[3]); \
+ span.redStep = 0; \
+ span.greenStep = 0; \
+ span.blueStep = 0; \
+ span.alphaStep = 0;
+#define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span);
+#include "s_tritemp.h"
+
+
+
+/*
+ * Render a smooth-shaded RGBA triangle.
+ */
+#define NAME smooth_rgba_triangle
+#define INTERP_Z 1
+#define INTERP_FOG 1
+#define INTERP_RGB 1
+#define INTERP_ALPHA 1
+#define SETUP_CODE \
+ { \
+ /* texturing must be off */ \
+ ASSERT(ctx->Texture._EnabledCoordUnits == 0); \
+ ASSERT(ctx->Light.ShadeModel==GL_SMOOTH); \
+ }
+#define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span);
+#include "s_tritemp.h"
+
+
+
+/*
+ * Render an RGB, GL_DECAL, textured triangle.
+ * Interpolate S,T only w/out mipmapping or perspective correction.
+ *
+ * No fog.
+ */
+#define NAME simple_textured_triangle
+#define INTERP_INT_TEX 1
+#define S_SCALE twidth
+#define T_SCALE theight
+
+#define SETUP_CODE \
+ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];\
+ struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \
+ const GLint b = obj->BaseLevel; \
+ const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width; \
+ const GLfloat theight = (GLfloat) obj->Image[0][b]->Height; \
+ const GLint twidth_log2 = obj->Image[0][b]->WidthLog2; \
+ const GLchan *texture = (const GLchan *) obj->Image[0][b]->Data; \
+ const GLint smask = obj->Image[0][b]->Width - 1; \
+ const GLint tmask = obj->Image[0][b]->Height - 1; \
+ if (!texture) { \
+ /* this shouldn't happen */ \
+ return; \
+ }
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ span.intTex[0] -= FIXED_HALF; /* off-by-one error? */ \
+ span.intTex[1] -= FIXED_HALF; \
+ for (i = 0; i < span.end; i++) { \
+ GLint s = FixedToInt(span.intTex[0]) & smask; \
+ GLint t = FixedToInt(span.intTex[1]) & tmask; \
+ GLint pos = (t << twidth_log2) + s; \
+ pos = pos + pos + pos; /* multiply by 3 */ \
+ span.array->rgb[i][RCOMP] = texture[pos]; \
+ span.array->rgb[i][GCOMP] = texture[pos+1]; \
+ span.array->rgb[i][BCOMP] = texture[pos+2]; \
+ span.intTex[0] += span.intTexStep[0]; \
+ span.intTex[1] += span.intTexStep[1]; \
+ } \
+ rb->PutRowRGB(ctx, rb, span.end, span.x, span.y, span.array->rgb, NULL);
+
+#include "s_tritemp.h"
+
+
+
+/*
+ * Render an RGB, GL_DECAL, textured triangle.
+ * Interpolate S,T, GL_LESS depth test, w/out mipmapping or
+ * perspective correction.
+ * Depth buffer bits must be <= sizeof(DEFAULT_SOFTWARE_DEPTH_TYPE)
+ *
+ * No fog.
+ */
+#define NAME simple_z_textured_triangle
+#define INTERP_Z 1
+#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE
+#define INTERP_INT_TEX 1
+#define S_SCALE twidth
+#define T_SCALE theight
+
+#define SETUP_CODE \
+ struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[0][0];\
+ struct gl_texture_object *obj = ctx->Texture.Unit[0].Current2D; \
+ const GLint b = obj->BaseLevel; \
+ const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width; \
+ const GLfloat theight = (GLfloat) obj->Image[0][b]->Height; \
+ const GLint twidth_log2 = obj->Image[0][b]->WidthLog2; \
+ const GLchan *texture = (const GLchan *) obj->Image[0][b]->Data; \
+ const GLint smask = obj->Image[0][b]->Width - 1; \
+ const GLint tmask = obj->Image[0][b]->Height - 1; \
+ if (!texture) { \
+ /* this shouldn't happen */ \
+ return; \
+ }
+
+#define RENDER_SPAN( span ) \
+ GLuint i; \
+ span.intTex[0] -= FIXED_HALF; /* off-by-one error? */ \
+ span.intTex[1] -= FIXED_HALF; \
+ for (i = 0; i < span.end; i++) { \
+ const GLdepth z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ GLint s = FixedToInt(span.intTex[0]) & smask; \
+ GLint t = FixedToInt(span.intTex[1]) & tmask; \
+ GLint pos = (t << twidth_log2) + s; \
+ pos = pos + pos + pos; /* multiply by 3 */ \
+ span.array->rgb[i][RCOMP] = texture[pos]; \
+ span.array->rgb[i][GCOMP] = texture[pos+1]; \
+ span.array->rgb[i][BCOMP] = texture[pos+2]; \
+ zRow[i] = z; \
+ span.array->mask[i] = 1; \
+ } \
+ else { \
+ span.array->mask[i] = 0; \
+ } \
+ span.intTex[0] += span.intTexStep[0]; \
+ span.intTex[1] += span.intTexStep[1]; \
+ span.z += span.zStep; \
+ } \
+ rb->PutRowRGB(ctx, rb, span.end, span.x, span.y, \
+ span.array->rgb, span.array->mask);
+
+#include "s_tritemp.h"
+
+
+
+#if CHAN_TYPE != GL_FLOAT
+
+struct affine_info
+{
+ GLenum filter;
+ GLenum format;
+ GLenum envmode;
+ GLint smask, tmask;
+ GLint twidth_log2;
+ const GLchan *texture;
+ GLfixed er, eg, eb, ea;
+ GLint tbytesline, tsize;
+};
+
+
+static INLINE GLint
+ilerp(GLint t, GLint a, GLint b)
+{
+ return a + ((t * (b - a)) >> FIXED_SHIFT);
+}
+
+static INLINE GLint
+ilerp_2d(GLint ia, GLint ib, GLint v00, GLint v10, GLint v01, GLint v11)
+{
+ const GLint temp0 = ilerp(ia, v00, v10);
+ const GLint temp1 = ilerp(ia, v01, v11);
+ return ilerp(ib, temp0, temp1);
+}
+
+
+/* This function can handle GL_NEAREST or GL_LINEAR sampling of 2D RGB or RGBA
+ * textures with GL_REPLACE, GL_MODULATE, GL_BLEND, GL_DECAL or GL_ADD
+ * texture env modes.
+ */
+static INLINE void
+affine_span(GLcontext *ctx, struct sw_span *span,
+ struct affine_info *info)
+{
+ GLchan sample[4]; /* the filtered texture sample */
+
+ /* Instead of defining a function for each mode, a test is done
+ * between the outer and inner loops. This is to reduce code size
+ * and complexity. Observe that an optimizing compiler kills
+ * unused variables (for instance tf,sf,ti,si in case of GL_NEAREST).
+ */
+
+#define NEAREST_RGB \
+ sample[RCOMP] = tex00[RCOMP]; \
+ sample[GCOMP] = tex00[GCOMP]; \
+ sample[BCOMP] = tex00[BCOMP]; \
+ sample[ACOMP] = CHAN_MAX
+
+#define LINEAR_RGB \
+ sample[RCOMP] = ilerp_2d(sf, tf, tex00[0], tex01[0], tex10[0], tex11[0]);\
+ sample[GCOMP] = ilerp_2d(sf, tf, tex00[1], tex01[1], tex10[1], tex11[1]);\
+ sample[BCOMP] = ilerp_2d(sf, tf, tex00[2], tex01[2], tex10[2], tex11[2]);\
+ sample[ACOMP] = CHAN_MAX;
+
+#define NEAREST_RGBA COPY_CHAN4(sample, tex00)
+
+#define LINEAR_RGBA \
+ sample[RCOMP] = ilerp_2d(sf, tf, tex00[0], tex01[0], tex10[0], tex11[0]);\
+ sample[GCOMP] = ilerp_2d(sf, tf, tex00[1], tex01[1], tex10[1], tex11[1]);\
+ sample[BCOMP] = ilerp_2d(sf, tf, tex00[2], tex01[2], tex10[2], tex11[2]);\
+ sample[ACOMP] = ilerp_2d(sf, tf, tex00[3], tex01[3], tex10[3], tex11[3])
+
+#define MODULATE \
+ dest[RCOMP] = span->red * (sample[RCOMP] + 1u) >> (FIXED_SHIFT + 8); \
+ dest[GCOMP] = span->green * (sample[GCOMP] + 1u) >> (FIXED_SHIFT + 8); \
+ dest[BCOMP] = span->blue * (sample[BCOMP] + 1u) >> (FIXED_SHIFT + 8); \
+ dest[ACOMP] = span->alpha * (sample[ACOMP] + 1u) >> (FIXED_SHIFT + 8)
+
+#define DECAL \
+ dest[RCOMP] = ((CHAN_MAX - sample[ACOMP]) * span->red + \
+ ((sample[ACOMP] + 1) * sample[RCOMP] << FIXED_SHIFT)) \
+ >> (FIXED_SHIFT + 8); \
+ dest[GCOMP] = ((CHAN_MAX - sample[ACOMP]) * span->green + \
+ ((sample[ACOMP] + 1) * sample[GCOMP] << FIXED_SHIFT)) \
+ >> (FIXED_SHIFT + 8); \
+ dest[BCOMP] = ((CHAN_MAX - sample[ACOMP]) * span->blue + \
+ ((sample[ACOMP] + 1) * sample[BCOMP] << FIXED_SHIFT)) \
+ >> (FIXED_SHIFT + 8); \
+ dest[ACOMP] = FixedToInt(span->alpha)
+
+#define BLEND \
+ dest[RCOMP] = ((CHAN_MAX - sample[RCOMP]) * span->red \
+ + (sample[RCOMP] + 1) * info->er) >> (FIXED_SHIFT + 8); \
+ dest[GCOMP] = ((CHAN_MAX - sample[GCOMP]) * span->green \
+ + (sample[GCOMP] + 1) * info->eg) >> (FIXED_SHIFT + 8); \
+ dest[BCOMP] = ((CHAN_MAX - sample[BCOMP]) * span->blue \
+ + (sample[BCOMP] + 1) * info->eb) >> (FIXED_SHIFT + 8); \
+ dest[ACOMP] = span->alpha * (sample[ACOMP] + 1) >> (FIXED_SHIFT + 8)
+
+#define REPLACE COPY_CHAN4(dest, sample)
+
+#define ADD \
+ { \
+ GLint rSum = FixedToInt(span->red) + (GLint) sample[RCOMP]; \
+ GLint gSum = FixedToInt(span->green) + (GLint) sample[GCOMP]; \
+ GLint bSum = FixedToInt(span->blue) + (GLint) sample[BCOMP]; \
+ dest[RCOMP] = MIN2(rSum, CHAN_MAX); \
+ dest[GCOMP] = MIN2(gSum, CHAN_MAX); \
+ dest[BCOMP] = MIN2(bSum, CHAN_MAX); \
+ dest[ACOMP] = span->alpha * (sample[ACOMP] + 1) >> (FIXED_SHIFT + 8); \
+ }
+
+/* shortcuts */
+
+#define NEAREST_RGB_REPLACE \
+ NEAREST_RGB; \
+ dest[0] = sample[0]; \
+ dest[1] = sample[1]; \
+ dest[2] = sample[2]; \
+ dest[3] = FixedToInt(span->alpha);
+
+#define NEAREST_RGBA_REPLACE COPY_CHAN4(dest, tex00)
+
+#define SPAN_NEAREST(DO_TEX, COMPS) \
+ for (i = 0; i < span->end; i++) { \
+ /* Isn't it necessary to use FixedFloor below?? */ \
+ GLint s = FixedToInt(span->intTex[0]) & info->smask; \
+ GLint t = FixedToInt(span->intTex[1]) & info->tmask; \
+ GLint pos = (t << info->twidth_log2) + s; \
+ const GLchan *tex00 = info->texture + COMPS * pos; \
+ DO_TEX; \
+ span->red += span->redStep; \
+ span->green += span->greenStep; \
+ span->blue += span->blueStep; \
+ span->alpha += span->alphaStep; \
+ span->intTex[0] += span->intTexStep[0]; \
+ span->intTex[1] += span->intTexStep[1]; \
+ dest += 4; \
+ }
+
+#define SPAN_LINEAR(DO_TEX, COMPS) \
+ for (i = 0; i < span->end; i++) { \
+ /* Isn't it necessary to use FixedFloor below?? */ \
+ const GLint s = FixedToInt(span->intTex[0]) & info->smask; \
+ const GLint t = FixedToInt(span->intTex[1]) & info->tmask; \
+ const GLfixed sf = span->intTex[0] & FIXED_FRAC_MASK; \
+ const GLfixed tf = span->intTex[1] & FIXED_FRAC_MASK; \
+ const GLint pos = (t << info->twidth_log2) + s; \
+ const GLchan *tex00 = info->texture + COMPS * pos; \
+ const GLchan *tex10 = tex00 + info->tbytesline; \
+ const GLchan *tex01 = tex00 + COMPS; \
+ const GLchan *tex11 = tex10 + COMPS; \
+ if (t == info->tmask) { \
+ tex10 -= info->tsize; \
+ tex11 -= info->tsize; \
+ } \
+ if (s == info->smask) { \
+ tex01 -= info->tbytesline; \
+ tex11 -= info->tbytesline; \
+ } \
+ DO_TEX; \
+ span->red += span->redStep; \
+ span->green += span->greenStep; \
+ span->blue += span->blueStep; \
+ span->alpha += span->alphaStep; \
+ span->intTex[0] += span->intTexStep[0]; \
+ span->intTex[1] += span->intTexStep[1]; \
+ dest += 4; \
+ }
+
+
+ GLuint i;
+ GLchan *dest = span->array->rgba[0];
+
+ span->intTex[0] -= FIXED_HALF;
+ span->intTex[1] -= FIXED_HALF;
+ switch (info->filter) {
+ case GL_NEAREST:
+ switch (info->format) {
+ case GL_RGB:
+ switch (info->envmode) {
+ case GL_MODULATE:
+ SPAN_NEAREST(NEAREST_RGB;MODULATE,3);
+ break;
+ case GL_DECAL:
+ case GL_REPLACE:
+ SPAN_NEAREST(NEAREST_RGB_REPLACE,3);
+ break;
+ case GL_BLEND:
+ SPAN_NEAREST(NEAREST_RGB;BLEND,3);
+ break;
+ case GL_ADD:
+ SPAN_NEAREST(NEAREST_RGB;ADD,3);
+ break;
+ default:
+ _mesa_problem(ctx, "bad tex env mode in SPAN_LINEAR");
+ return;
+ }
+ break;
+ case GL_RGBA:
+ switch(info->envmode) {
+ case GL_MODULATE:
+ SPAN_NEAREST(NEAREST_RGBA;MODULATE,4);
+ break;
+ case GL_DECAL:
+ SPAN_NEAREST(NEAREST_RGBA;DECAL,4);
+ break;
+ case GL_BLEND:
+ SPAN_NEAREST(NEAREST_RGBA;BLEND,4);
+ break;
+ case GL_ADD:
+ SPAN_NEAREST(NEAREST_RGBA;ADD,4);
+ break;
+ case GL_REPLACE:
+ SPAN_NEAREST(NEAREST_RGBA_REPLACE,4);
+ break;
+ default:
+ _mesa_problem(ctx, "bad tex env mode (2) in SPAN_LINEAR");
+ return;
+ }
+ break;
+ }
+ break;
+
+ case GL_LINEAR:
+ span->intTex[0] -= FIXED_HALF;
+ span->intTex[1] -= FIXED_HALF;
+ switch (info->format) {
+ case GL_RGB:
+ switch (info->envmode) {
+ case GL_MODULATE:
+ SPAN_LINEAR(LINEAR_RGB;MODULATE,3);
+ break;
+ case GL_DECAL:
+ case GL_REPLACE:
+ SPAN_LINEAR(LINEAR_RGB;REPLACE,3);
+ break;
+ case GL_BLEND:
+ SPAN_LINEAR(LINEAR_RGB;BLEND,3);
+ break;
+ case GL_ADD:
+ SPAN_LINEAR(LINEAR_RGB;ADD,3);
+ break;
+ default:
+ _mesa_problem(ctx, "bad tex env mode (3) in SPAN_LINEAR");
+ return;
+ }
+ break;
+ case GL_RGBA:
+ switch (info->envmode) {
+ case GL_MODULATE:
+ SPAN_LINEAR(LINEAR_RGBA;MODULATE,4);
+ break;
+ case GL_DECAL:
+ SPAN_LINEAR(LINEAR_RGBA;DECAL,4);
+ break;
+ case GL_BLEND:
+ SPAN_LINEAR(LINEAR_RGBA;BLEND,4);
+ break;
+ case GL_ADD:
+ SPAN_LINEAR(LINEAR_RGBA;ADD,4);
+ break;
+ case GL_REPLACE:
+ SPAN_LINEAR(LINEAR_RGBA;REPLACE,4);
+ break;
+ default:
+ _mesa_problem(ctx, "bad tex env mode (4) in SPAN_LINEAR");
+ return;
+ }
+ break;
+ }
+ break;
+ }
+ span->interpMask &= ~SPAN_RGBA;
+ ASSERT(span->arrayMask & SPAN_RGBA);
+ _swrast_write_rgba_span(ctx, span);
+
+#undef SPAN_NEAREST
+#undef SPAN_LINEAR
+}
+
+
+
+/*
+ * Render an RGB/RGBA textured triangle without perspective correction.
+ */
+#define NAME affine_textured_triangle
+#define INTERP_Z 1
+#define INTERP_FOG 1
+#define INTERP_RGB 1
+#define INTERP_ALPHA 1
+#define INTERP_INT_TEX 1
+#define S_SCALE twidth
+#define T_SCALE theight
+
+#define SETUP_CODE \
+ struct affine_info info; \
+ struct gl_texture_unit *unit = ctx->Texture.Unit+0; \
+ struct gl_texture_object *obj = unit->Current2D; \
+ const GLint b = obj->BaseLevel; \
+ const GLfloat twidth = (GLfloat) obj->Image[0][b]->Width; \
+ const GLfloat theight = (GLfloat) obj->Image[0][b]->Height; \
+ info.texture = (const GLchan *) obj->Image[0][b]->Data; \
+ info.twidth_log2 = obj->Image[0][b]->WidthLog2; \
+ info.smask = obj->Image[0][b]->Width - 1; \
+ info.tmask = obj->Image[0][b]->Height - 1; \
+ info.format = obj->Image[0][b]->Format; \
+ info.filter = obj->MinFilter; \
+ info.envmode = unit->EnvMode; \
+ span.arrayMask |= SPAN_RGBA; \
+ \
+ if (info.envmode == GL_BLEND) { \
+ /* potential off-by-one error here? (1.0f -> 2048 -> 0) */ \
+ info.er = FloatToFixed(unit->EnvColor[RCOMP] * CHAN_MAXF); \
+ info.eg = FloatToFixed(unit->EnvColor[GCOMP] * CHAN_MAXF); \
+ info.eb = FloatToFixed(unit->EnvColor[BCOMP] * CHAN_MAXF); \
+ info.ea = FloatToFixed(unit->EnvColor[ACOMP] * CHAN_MAXF); \
+ } \
+ if (!info.texture) { \
+ /* this shouldn't happen */ \
+ return; \
+ } \
+ \
+ switch (info.format) { \
+ case GL_ALPHA: \
+ case GL_LUMINANCE: \
+ case GL_INTENSITY: \
+ info.tbytesline = obj->Image[0][b]->Width; \
+ break; \
+ case GL_LUMINANCE_ALPHA: \
+ info.tbytesline = obj->Image[0][b]->Width * 2; \
+ break; \
+ case GL_RGB: \
+ info.tbytesline = obj->Image[0][b]->Width * 3; \
+ break; \
+ case GL_RGBA: \
+ info.tbytesline = obj->Image[0][b]->Width * 4; \
+ break; \
+ default: \
+ _mesa_problem(NULL, "Bad texture format in affine_texture_triangle");\
+ return; \
+ } \
+ info.tsize = obj->Image[0][b]->Height * info.tbytesline;
+
+#define RENDER_SPAN( span ) affine_span(ctx, &span, &info);
+
+#include "s_tritemp.h"
+
+
+
+struct persp_info
+{
+ GLenum filter;
+ GLenum format;
+ GLenum envmode;
+ GLint smask, tmask;
+ GLint twidth_log2;
+ const GLchan *texture;
+ GLfixed er, eg, eb, ea; /* texture env color */
+ GLint tbytesline, tsize;
+};
+
+
+static INLINE void
+fast_persp_span(GLcontext *ctx, struct sw_span *span,
+ struct persp_info *info)
+{
+ GLchan sample[4]; /* the filtered texture sample */
+
+ /* Instead of defining a function for each mode, a test is done
+ * between the outer and inner loops. This is to reduce code size
+ * and complexity. Observe that an optimizing compiler kills
+ * unused variables (for instance tf,sf,ti,si in case of GL_NEAREST).
+ */
+#define SPAN_NEAREST(DO_TEX,COMP) \
+ for (i = 0; i < span->end; i++) { \
+ GLdouble invQ = tex_coord[2] ? \
+ (1.0 / tex_coord[2]) : 1.0; \
+ GLfloat s_tmp = (GLfloat) (tex_coord[0] * invQ); \
+ GLfloat t_tmp = (GLfloat) (tex_coord[1] * invQ); \
+ GLint s = IFLOOR(s_tmp) & info->smask; \
+ GLint t = IFLOOR(t_tmp) & info->tmask; \
+ GLint pos = (t << info->twidth_log2) + s; \
+ const GLchan *tex00 = info->texture + COMP * pos; \
+ DO_TEX; \
+ span->red += span->redStep; \
+ span->green += span->greenStep; \
+ span->blue += span->blueStep; \
+ span->alpha += span->alphaStep; \
+ tex_coord[0] += tex_step[0]; \
+ tex_coord[1] += tex_step[1]; \
+ tex_coord[2] += tex_step[2]; \
+ dest += 4; \
+ }
+
+#define SPAN_LINEAR(DO_TEX,COMP) \
+ for (i = 0; i < span->end; i++) { \
+ GLdouble invQ = tex_coord[2] ? \
+ (1.0 / tex_coord[2]) : 1.0; \
+ const GLfloat s_tmp = (GLfloat) (tex_coord[0] * invQ); \
+ const GLfloat t_tmp = (GLfloat) (tex_coord[1] * invQ); \
+ const GLfixed s_fix = FloatToFixed(s_tmp) - FIXED_HALF; \
+ const GLfixed t_fix = FloatToFixed(t_tmp) - FIXED_HALF; \
+ const GLint s = FixedToInt(FixedFloor(s_fix)) & info->smask; \
+ const GLint t = FixedToInt(FixedFloor(t_fix)) & info->tmask; \
+ const GLfixed sf = s_fix & FIXED_FRAC_MASK; \
+ const GLfixed tf = t_fix & FIXED_FRAC_MASK; \
+ const GLint pos = (t << info->twidth_log2) + s; \
+ const GLchan *tex00 = info->texture + COMP * pos; \
+ const GLchan *tex10 = tex00 + info->tbytesline; \
+ const GLchan *tex01 = tex00 + COMP; \
+ const GLchan *tex11 = tex10 + COMP; \
+ if (t == info->tmask) { \
+ tex10 -= info->tsize; \
+ tex11 -= info->tsize; \
+ } \
+ if (s == info->smask) { \
+ tex01 -= info->tbytesline; \
+ tex11 -= info->tbytesline; \
+ } \
+ DO_TEX; \
+ span->red += span->redStep; \
+ span->green += span->greenStep; \
+ span->blue += span->blueStep; \
+ span->alpha += span->alphaStep; \
+ tex_coord[0] += tex_step[0]; \
+ tex_coord[1] += tex_step[1]; \
+ tex_coord[2] += tex_step[2]; \
+ dest += 4; \
+ }
+
+ GLuint i;
+ GLfloat tex_coord[3], tex_step[3];
+ GLchan *dest = span->array->rgba[0];
+
+ const GLuint savedTexEnable = ctx->Texture._EnabledUnits;
+ ctx->Texture._EnabledUnits = 0;
+
+ tex_coord[0] = span->tex[0][0] * (info->smask + 1);
+ tex_step[0] = span->texStepX[0][0] * (info->smask + 1);
+ tex_coord[1] = span->tex[0][1] * (info->tmask + 1);
+ tex_step[1] = span->texStepX[0][1] * (info->tmask + 1);
+ /* span->tex[0][2] only if 3D-texturing, here only 2D */
+ tex_coord[2] = span->tex[0][3];
+ tex_step[2] = span->texStepX[0][3];
+
+ switch (info->filter) {
+ case GL_NEAREST:
+ switch (info->format) {
+ case GL_RGB:
+ switch (info->envmode) {
+ case GL_MODULATE:
+ SPAN_NEAREST(NEAREST_RGB;MODULATE,3);
+ break;
+ case GL_DECAL:
+ case GL_REPLACE:
+ SPAN_NEAREST(NEAREST_RGB_REPLACE,3);
+ break;
+ case GL_BLEND:
+ SPAN_NEAREST(NEAREST_RGB;BLEND,3);
+ break;
+ case GL_ADD:
+ SPAN_NEAREST(NEAREST_RGB;ADD,3);
+ break;
+ default:
+ _mesa_problem(ctx, "bad tex env mode (5) in SPAN_LINEAR");
+ return;
+ }
+ break;
+ case GL_RGBA:
+ switch(info->envmode) {
+ case GL_MODULATE:
+ SPAN_NEAREST(NEAREST_RGBA;MODULATE,4);
+ break;
+ case GL_DECAL:
+ SPAN_NEAREST(NEAREST_RGBA;DECAL,4);
+ break;
+ case GL_BLEND:
+ SPAN_NEAREST(NEAREST_RGBA;BLEND,4);
+ break;
+ case GL_ADD:
+ SPAN_NEAREST(NEAREST_RGBA;ADD,4);
+ break;
+ case GL_REPLACE:
+ SPAN_NEAREST(NEAREST_RGBA_REPLACE,4);
+ break;
+ default:
+ _mesa_problem(ctx, "bad tex env mode (6) in SPAN_LINEAR");
+ return;
+ }
+ break;
+ }
+ break;
+
+ case GL_LINEAR:
+ switch (info->format) {
+ case GL_RGB:
+ switch (info->envmode) {
+ case GL_MODULATE:
+ SPAN_LINEAR(LINEAR_RGB;MODULATE,3);
+ break;
+ case GL_DECAL:
+ case GL_REPLACE:
+ SPAN_LINEAR(LINEAR_RGB;REPLACE,3);
+ break;
+ case GL_BLEND:
+ SPAN_LINEAR(LINEAR_RGB;BLEND,3);
+ break;
+ case GL_ADD:
+ SPAN_LINEAR(LINEAR_RGB;ADD,3);
+ break;
+ default:
+ _mesa_problem(ctx, "bad tex env mode (7) in SPAN_LINEAR");
+ return;
+ }
+ break;
+ case GL_RGBA:
+ switch (info->envmode) {
+ case GL_MODULATE:
+ SPAN_LINEAR(LINEAR_RGBA;MODULATE,4);
+ break;
+ case GL_DECAL:
+ SPAN_LINEAR(LINEAR_RGBA;DECAL,4);
+ break;
+ case GL_BLEND:
+ SPAN_LINEAR(LINEAR_RGBA;BLEND,4);
+ break;
+ case GL_ADD:
+ SPAN_LINEAR(LINEAR_RGBA;ADD,4);
+ break;
+ case GL_REPLACE:
+ SPAN_LINEAR(LINEAR_RGBA;REPLACE,4);
+ break;
+ default:
+ _mesa_problem(ctx, "bad tex env mode (8) in SPAN_LINEAR");
+ return;
+ }
+ break;
+ }
+ break;
+ }
+
+ ASSERT(span->arrayMask & SPAN_RGBA);
+ _swrast_write_rgba_span(ctx, span);
+
+#undef SPAN_NEAREST
+#undef SPAN_LINEAR
+
+ /* restore state */
+ ctx->Texture._EnabledUnits = savedTexEnable;
+}
+
+
+/*
+ * Render an perspective corrected RGB/RGBA textured triangle.
+ * The Q (aka V in Mesa) coordinate must be zero such that the divide
+ * by interpolated Q/W comes out right.
+ *
+ */
+#define NAME persp_textured_triangle
+#define INTERP_Z 1
+#define INTERP_W 1
+#define INTERP_FOG 1
+#define INTERP_RGB 1
+#define INTERP_ALPHA 1
+#define INTERP_TEX 1
+
+#define SETUP_CODE \
+ struct persp_info info; \
+ const struct gl_texture_unit *unit = ctx->Texture.Unit+0; \
+ const struct gl_texture_object *obj = unit->Current2D; \
+ const GLint b = obj->BaseLevel; \
+ info.texture = (const GLchan *) obj->Image[0][b]->Data; \
+ info.twidth_log2 = obj->Image[0][b]->WidthLog2; \
+ info.smask = obj->Image[0][b]->Width - 1; \
+ info.tmask = obj->Image[0][b]->Height - 1; \
+ info.format = obj->Image[0][b]->Format; \
+ info.filter = obj->MinFilter; \
+ info.envmode = unit->EnvMode; \
+ \
+ if (info.envmode == GL_BLEND) { \
+ /* potential off-by-one error here? (1.0f -> 2048 -> 0) */ \
+ info.er = FloatToFixed(unit->EnvColor[RCOMP] * CHAN_MAXF); \
+ info.eg = FloatToFixed(unit->EnvColor[GCOMP] * CHAN_MAXF); \
+ info.eb = FloatToFixed(unit->EnvColor[BCOMP] * CHAN_MAXF); \
+ info.ea = FloatToFixed(unit->EnvColor[ACOMP] * CHAN_MAXF); \
+ } \
+ if (!info.texture) { \
+ /* this shouldn't happen */ \
+ return; \
+ } \
+ \
+ switch (info.format) { \
+ case GL_ALPHA: \
+ case GL_LUMINANCE: \
+ case GL_INTENSITY: \
+ info.tbytesline = obj->Image[0][b]->Width; \
+ break; \
+ case GL_LUMINANCE_ALPHA: \
+ info.tbytesline = obj->Image[0][b]->Width * 2; \
+ break; \
+ case GL_RGB: \
+ info.tbytesline = obj->Image[0][b]->Width * 3; \
+ break; \
+ case GL_RGBA: \
+ info.tbytesline = obj->Image[0][b]->Width * 4; \
+ break; \
+ default: \
+ _mesa_problem(NULL, "Bad texture format in persp_textured_triangle");\
+ return; \
+ } \
+ info.tsize = obj->Image[0][b]->Height * info.tbytesline;
+
+#define RENDER_SPAN( span ) \
+ span.interpMask &= ~SPAN_RGBA; \
+ span.arrayMask |= SPAN_RGBA; \
+ fast_persp_span(ctx, &span, &info);
+
+#include "s_tritemp.h"
+
+
+#endif /* CHAN_BITS != GL_FLOAT */
+
+
+
+
+/*
+ * Render a smooth-shaded, textured, RGBA triangle.
+ * Interpolate S,T,R with perspective correction, w/out mipmapping.
+ */
+#define NAME general_textured_triangle
+#define INTERP_Z 1
+#define INTERP_W 1
+#define INTERP_FOG 1
+#define INTERP_RGB 1
+#define INTERP_SPEC 1
+#define INTERP_ALPHA 1
+#define INTERP_TEX 1
+#define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span);
+#include "s_tritemp.h"
+
+
+
+/*
+ * This is the big one!
+ * Interpolate Z, RGB, Alpha, specular, fog, and N sets of texture coordinates.
+ * Yup, it's slow.
+ */
+#define NAME multitextured_triangle
+#define INTERP_Z 1
+#define INTERP_W 1
+#define INTERP_FOG 1
+#define INTERP_RGB 1
+#define INTERP_ALPHA 1
+#define INTERP_SPEC 1
+#define INTERP_MULTITEX 1
+#define RENDER_SPAN( span ) _swrast_write_rgba_span(ctx, &span);
+#include "s_tritemp.h"
+
+
+
+/*
+ * Special tri function for occlusion testing
+ */
+#define NAME occlusion_zless_triangle
+#define INTERP_Z 1
+#define SETUP_CODE \
+ struct gl_renderbuffer *rb \
+ = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer; \
+ ASSERT(ctx->Depth.Test); \
+ ASSERT(!ctx->Depth.Mask); \
+ ASSERT(ctx->Depth.Func == GL_LESS); \
+ if (ctx->OcclusionResult && !ctx->Occlusion.Active) { \
+ return; \
+ }
+#define RENDER_SPAN( span ) \
+ if (ctx->Visual.depthBits <= 16) { \
+ GLuint i; \
+ const GLushort *zRow = (const GLushort *) \
+ rb->GetPointer(ctx, rb, span.x, span.y); \
+ for (i = 0; i < span.end; i++) { \
+ GLdepth z = FixedToDepth(span.z); \
+ if (z < zRow[i]) { \
+ ctx->OcclusionResult = GL_TRUE; \
+ ctx->Occlusion.PassedCounter++; \
+ } \
+ span.z += span.zStep; \
+ } \
+ } \
+ else { \
+ GLuint i; \
+ const GLuint *zRow = (const GLuint *) \
+ rb->GetPointer(ctx, rb, span.x, span.y); \
+ for (i = 0; i < span.end; i++) { \
+ if ((GLuint)span.z < zRow[i]) { \
+ ctx->OcclusionResult = GL_TRUE; \
+ ctx->Occlusion.PassedCounter++; \
+ } \
+ span.z += span.zStep; \
+ } \
+ }
+#include "s_tritemp.h"
+
+
+
+static void
+nodraw_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ (void) (ctx && v0 && v1 && v2);
+}
+
+
+/*
+ * This is used when separate specular color is enabled, but not
+ * texturing. We add the specular color to the primary color,
+ * draw the triangle, then restore the original primary color.
+ * Inefficient, but seldom needed.
+ */
+void _swrast_add_spec_terms_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ SWvertex *ncv0 = (SWvertex *)v0; /* drop const qualifier */
+ SWvertex *ncv1 = (SWvertex *)v1;
+ SWvertex *ncv2 = (SWvertex *)v2;
+#if CHAN_TYPE == GL_FLOAT
+ GLfloat rSum, gSum, bSum;
+#else
+ GLint rSum, gSum, bSum;
+#endif
+ GLchan c[3][4];
+ /* save original colors */
+ COPY_CHAN4( c[0], ncv0->color );
+ COPY_CHAN4( c[1], ncv1->color );
+ COPY_CHAN4( c[2], ncv2->color );
+ /* sum v0 */
+ rSum = ncv0->color[0] + ncv0->specular[0];
+ gSum = ncv0->color[1] + ncv0->specular[1];
+ bSum = ncv0->color[2] + ncv0->specular[2];
+ ncv0->color[0] = MIN2(rSum, CHAN_MAX);
+ ncv0->color[1] = MIN2(gSum, CHAN_MAX);
+ ncv0->color[2] = MIN2(bSum, CHAN_MAX);
+ /* sum v1 */
+ rSum = ncv1->color[0] + ncv1->specular[0];
+ gSum = ncv1->color[1] + ncv1->specular[1];
+ bSum = ncv1->color[2] + ncv1->specular[2];
+ ncv1->color[0] = MIN2(rSum, CHAN_MAX);
+ ncv1->color[1] = MIN2(gSum, CHAN_MAX);
+ ncv1->color[2] = MIN2(bSum, CHAN_MAX);
+ /* sum v2 */
+ rSum = ncv2->color[0] + ncv2->specular[0];
+ gSum = ncv2->color[1] + ncv2->specular[1];
+ bSum = ncv2->color[2] + ncv2->specular[2];
+ ncv2->color[0] = MIN2(rSum, CHAN_MAX);
+ ncv2->color[1] = MIN2(gSum, CHAN_MAX);
+ ncv2->color[2] = MIN2(bSum, CHAN_MAX);
+ /* draw */
+ SWRAST_CONTEXT(ctx)->SpecTriangle( ctx, ncv0, ncv1, ncv2 );
+ /* restore original colors */
+ COPY_CHAN4( ncv0->color, c[0] );
+ COPY_CHAN4( ncv1->color, c[1] );
+ COPY_CHAN4( ncv2->color, c[2] );
+}
+
+
+
+#ifdef DEBUG
+
+/* record the current triangle function name */
+const char *_mesa_triFuncName = NULL;
+
+#define USE(triFunc) \
+do { \
+ _mesa_triFuncName = #triFunc; \
+ /*printf("%s\n", _mesa_triFuncName);*/ \
+ swrast->Triangle = triFunc; \
+} while (0)
+
+#else
+
+#define USE(triFunc) swrast->Triangle = triFunc;
+
+#endif
+
+
+
+
+/*
+ * Determine which triangle rendering function to use given the current
+ * rendering context.
+ *
+ * Please update the summary flag _SWRAST_NEW_TRIANGLE if you add or
+ * remove tests to this code.
+ */
+void
+_swrast_choose_triangle( GLcontext *ctx )
+{
+ SWcontext *swrast = SWRAST_CONTEXT(ctx);
+ const GLboolean rgbmode = ctx->Visual.rgbMode;
+
+ if (ctx->Polygon.CullFlag &&
+ ctx->Polygon.CullFaceMode == GL_FRONT_AND_BACK) {
+ USE(nodraw_triangle);
+ return;
+ }
+
+ if (ctx->RenderMode==GL_RENDER) {
+
+ if (ctx->Polygon.SmoothFlag) {
+ _swrast_set_aa_triangle_function(ctx);
+ ASSERT(swrast->Triangle);
+ return;
+ }
+
+ /* special case for occlusion testing */
+ if ((ctx->Depth.OcclusionTest || ctx->Occlusion.Active) &&
+ ctx->Depth.Test &&
+ ctx->Depth.Mask == GL_FALSE &&
+ ctx->Depth.Func == GL_LESS &&
+ !ctx->Stencil.Enabled) {
+ if ((rgbmode &&
+ ctx->Color.ColorMask[0] == 0 &&
+ ctx->Color.ColorMask[1] == 0 &&
+ ctx->Color.ColorMask[2] == 0 &&
+ ctx->Color.ColorMask[3] == 0)
+ ||
+ (!rgbmode && ctx->Color.IndexMask == 0)) {
+ USE(occlusion_zless_triangle);
+ return;
+ }
+ }
+
+ if (ctx->Texture._EnabledCoordUnits || ctx->FragmentProgram._Active) {
+ /* Ugh, we do a _lot_ of tests to pick the best textured tri func */
+ const struct gl_texture_object *texObj2D;
+ const struct gl_texture_image *texImg;
+ GLenum minFilter, magFilter, envMode;
+ GLint format;
+ texObj2D = ctx->Texture.Unit[0].Current2D;
+ texImg = texObj2D ? texObj2D->Image[0][texObj2D->BaseLevel] : NULL;
+ format = texImg ? texImg->TexFormat->MesaFormat : -1;
+ minFilter = texObj2D ? texObj2D->MinFilter : (GLenum) 0;
+ magFilter = texObj2D ? texObj2D->MagFilter : (GLenum) 0;
+ envMode = ctx->Texture.Unit[0].EnvMode;
+
+ /* First see if we can use an optimized 2-D texture function */
+ if (ctx->Texture._EnabledCoordUnits == 0x1
+ && !ctx->FragmentProgram._Active
+ && ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT
+ && texObj2D->WrapS == GL_REPEAT
+ && texObj2D->WrapT == GL_REPEAT
+ && texObj2D->_IsPowerOfTwo
+ && texImg->Border == 0
+ && texImg->Width == texImg->RowStride
+ && (format == MESA_FORMAT_RGB || format == MESA_FORMAT_RGBA)
+ && minFilter == magFilter
+ && ctx->Light.Model.ColorControl == GL_SINGLE_COLOR
+ && ctx->Texture.Unit[0].EnvMode != GL_COMBINE_EXT) {
+ if (ctx->Hint.PerspectiveCorrection==GL_FASTEST) {
+ if (minFilter == GL_NEAREST
+ && format == MESA_FORMAT_RGB
+ && (envMode == GL_REPLACE || envMode == GL_DECAL)
+ && ((swrast->_RasterMask == (DEPTH_BIT | TEXTURE_BIT)
+ && ctx->Depth.Func == GL_LESS
+ && ctx->Depth.Mask == GL_TRUE)
+ || swrast->_RasterMask == TEXTURE_BIT)
+ && ctx->Polygon.StippleFlag == GL_FALSE
+ && ctx->Visual.depthBits <= 16) {
+ if (swrast->_RasterMask == (DEPTH_BIT | TEXTURE_BIT)) {
+ USE(simple_z_textured_triangle);
+ }
+ else {
+ USE(simple_textured_triangle);
+ }
+ }
+ else {
+#if (CHAN_BITS == 16 || CHAN_BITS == 32)
+ USE(general_textured_triangle);
+#else
+ USE(affine_textured_triangle);
+#endif
+ }
+ }
+ else {
+#if (CHAN_BITS == 16 || CHAN_BITS == 32)
+ USE(general_textured_triangle);
+#else
+ USE(persp_textured_triangle);
+#endif
+ }
+ }
+ else {
+ /* general case textured triangles */
+ if (ctx->Texture._EnabledCoordUnits > 1) {
+ USE(multitextured_triangle);
+ }
+ else {
+ USE(general_textured_triangle);
+ }
+ }
+ }
+ else {
+ ASSERT(!ctx->Texture._EnabledCoordUnits);
+ if (ctx->Light.ShadeModel==GL_SMOOTH) {
+ /* smooth shaded, no texturing, stippled or some raster ops */
+ if (rgbmode) {
+ USE(smooth_rgba_triangle);
+ }
+ else {
+ USE(smooth_ci_triangle);
+ }
+ }
+ else {
+ /* flat shaded, no texturing, stippled or some raster ops */
+ if (rgbmode) {
+ USE(flat_rgba_triangle);
+ }
+ else {
+ USE(flat_ci_triangle);
+ }
+ }
+ }
+ }
+ else if (ctx->RenderMode==GL_FEEDBACK) {
+ USE(_swrast_feedback_triangle);
+ }
+ else {
+ /* GL_SELECT mode */
+ USE(_swrast_select_triangle);
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_triangle.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_triangle.h
new file mode 100644
index 000000000..0de812500
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_triangle.h
@@ -0,0 +1,51 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_TRIANGLES_H
+#define S_TRIANGLES_H
+
+
+#include "mtypes.h"
+#include "swrast.h"
+
+
+extern GLboolean
+_swrast_culltriangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2);
+
+extern void
+_swrast_choose_triangle( GLcontext *ctx );
+
+extern void
+_swrast_add_spec_terms_triangle( GLcontext *ctx,
+ const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_trispan.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_trispan.h
new file mode 100644
index 000000000..15207e863
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_trispan.h
@@ -0,0 +1,31 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef S_TRISPAN_H
+#define S_TRISPAN_H
+
+
+#endif /* S_TRISPAN_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_tritemp.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_tritemp.h
new file mode 100644
index 000000000..a32d8a66b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_tritemp.h
@@ -0,0 +1,1308 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4.1
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/*
+ * Triangle Rasterizer Template
+ *
+ * This file is #include'd to generate custom triangle rasterizers.
+ *
+ * The following macros may be defined to indicate what auxillary information
+ * must be interplated across the triangle:
+ * INTERP_Z - if defined, interpolate vertex Z values
+ * INTERP_W - if defined, interpolate vertex W values
+ * INTERP_FOG - if defined, interpolate fog values
+ * INTERP_RGB - if defined, interpolate RGB values
+ * INTERP_ALPHA - if defined, interpolate Alpha values (req's INTERP_RGB)
+ * INTERP_SPEC - if defined, interpolate specular RGB values
+ * INTERP_INDEX - if defined, interpolate color index values
+ * INTERP_INT_TEX - if defined, interpolate integer ST texcoords
+ * (fast, simple 2-D texture mapping)
+ * INTERP_TEX - if defined, interpolate set 0 float STRQ texcoords
+ * NOTE: OpenGL STRQ = Mesa STUV (R was taken for red)
+ * INTERP_MULTITEX - if defined, interpolate N units of STRQ texcoords
+ *
+ * When one can directly address pixels in the color buffer the following
+ * macros can be defined and used to compute pixel addresses during
+ * rasterization (see pRow):
+ * PIXEL_TYPE - the datatype of a pixel (GLubyte, GLushort, GLuint)
+ * BYTES_PER_ROW - number of bytes per row in the color buffer
+ * PIXEL_ADDRESS(X,Y) - returns the address of pixel at (X,Y) where
+ * Y==0 at bottom of screen and increases upward.
+ *
+ * Similarly, for direct depth buffer access, this type is used for depth
+ * buffer addressing:
+ * DEPTH_TYPE - either GLushort or GLuint
+ *
+ * Optionally, one may provide one-time setup code per triangle:
+ * SETUP_CODE - code which is to be executed once per triangle
+ * CLEANUP_CODE - code to execute at end of triangle
+ *
+ * The following macro MUST be defined:
+ * RENDER_SPAN(span) - code to write a span of pixels.
+ *
+ * This code was designed for the origin to be in the lower-left corner.
+ *
+ * Inspired by triangle rasterizer code written by Allen Akin. Thanks Allen!
+ *
+ *
+ * Some notes on rasterization accuracy:
+ *
+ * This code uses fixed point arithmetic (the GLfixed type) to iterate
+ * over the triangle edges and interpolate ancillary data (such as Z,
+ * color, secondary color, etc). The number of fractional bits in
+ * GLfixed and the value of SUB_PIXEL_BITS has a direct bearing on the
+ * accuracy of rasterization.
+ *
+ * If SUB_PIXEL_BITS=4 then we'll snap the vertices to the nearest
+ * 1/16 of a pixel. If we're walking up a long, nearly vertical edge
+ * (dx=1/16, dy=1024) we'll need 4 + 10 = 14 fractional bits in
+ * GLfixed to walk the edge without error. If the maximum viewport
+ * height is 4K pixels, then we'll need 4 + 12 = 16 fractional bits.
+ *
+ * Historically, Mesa has used 11 fractional bits in GLfixed, snaps
+ * vertices to 1/16 pixel and allowed a maximum viewport height of 2K
+ * pixels. 11 fractional bits is actually insufficient for accurately
+ * rasterizing some triangles. More recently, the maximum viewport
+ * height was increased to 4K pixels. Thus, Mesa should be using 16
+ * fractional bits in GLfixed. Unfortunately, there may be some issues
+ * with setting FIXED_FRAC_BITS=16, such as multiplication overflow.
+ * This will have to be examined in some detail...
+ *
+ * For now, if you find rasterization errors, particularly with tall,
+ * sliver triangles, try increasing FIXED_FRAC_BITS and/or decreasing
+ * SUB_PIXEL_BITS.
+ */
+
+/*
+ * ColorTemp is used for intermediate color values.
+ */
+#if CHAN_TYPE == GL_FLOAT
+#define ColorTemp GLfloat
+#else
+#define ColorTemp GLint /* same as GLfixed */
+#endif
+
+
+/*
+ * Walk triangle edges with GLfixed or GLdouble
+ */
+#if TRIANGLE_WALK_DOUBLE
+#define GLinterp GLdouble
+#define InterpToInt(X) ((GLint) (X))
+#define INTERP_ONE 1.0
+#else
+#define GLinterp GLfixed
+#define InterpToInt(X) FixedToInt(X)
+#define INTERP_ONE FIXED_ONE
+#endif
+
+
+/*
+ * Either loop over all texture units, or just use unit zero.
+ */
+#ifdef INTERP_MULTITEX
+#define TEX_UNIT_LOOP(CODE) \
+ { \
+ GLuint u; \
+ for (u = 0; u < ctx->Const.MaxTextureUnits; u++) { \
+ if (ctx->Texture._EnabledCoordUnits & (1 << u)) { \
+ CODE \
+ } \
+ } \
+ }
+#define INTERP_TEX
+#elif defined(INTERP_TEX)
+#define TEX_UNIT_LOOP(CODE) \
+ { \
+ const GLuint u = 0; \
+ CODE \
+ }
+#endif
+
+
+
+/*
+ * Some code we unfortunately need to prevent negative interpolated colors.
+ */
+#ifndef CLAMP_INTERPOLANT
+#define CLAMP_INTERPOLANT(CHANNEL, CHANNELSTEP, LEN) \
+do { \
+ GLfixed endVal = span.CHANNEL + (LEN) * span.CHANNELSTEP; \
+ if (endVal < 0) { \
+ span.CHANNEL -= endVal; \
+ } \
+ if (span.CHANNEL < 0) { \
+ span.CHANNEL = 0; \
+ } \
+} while (0)
+#endif
+
+
+static void NAME(GLcontext *ctx, const SWvertex *v0,
+ const SWvertex *v1,
+ const SWvertex *v2 )
+{
+ typedef struct {
+ const SWvertex *v0, *v1; /* Y(v0) < Y(v1) */
+#if TRIANGLE_WALK_DOUBLE
+ GLdouble dx; /* X(v1) - X(v0) */
+ GLdouble dy; /* Y(v1) - Y(v0) */
+ GLdouble dxdy; /* dx/dy */
+ GLdouble adjy; /* adjust from v[0]->fy to fsy, scaled */
+ GLdouble fsx; /* first sample point x coord */
+ GLdouble fsy;
+ GLdouble fx0; /*X of lower endpoint */
+#else
+ GLfloat dx; /* X(v1) - X(v0) */
+ GLfloat dy; /* Y(v1) - Y(v0) */
+ GLfloat dxdy; /* dx/dy */
+ GLfixed fdxdy; /* dx/dy in fixed-point */
+ GLfloat adjy; /* adjust from v[0]->fy to fsy, scaled */
+ GLfixed fsx; /* first sample point x coord */
+ GLfixed fsy;
+ GLfixed fx0; /* fixed pt X of lower endpoint */
+#endif
+ GLint lines; /* number of lines to be sampled on this edge */
+ } EdgeT;
+
+#ifdef INTERP_Z
+ const GLint depthBits = ctx->DrawBuffer->Visual.depthBits;
+ const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0;
+ const GLfloat maxDepth = ctx->DrawBuffer->_DepthMaxF;
+#define FixedToDepth(F) ((F) >> fixedToDepthShift)
+#endif
+ EdgeT eMaj, eTop, eBot;
+ GLfloat oneOverArea;
+ const SWvertex *vMin, *vMid, *vMax; /* Y(vMin)<=Y(vMid)<=Y(vMax) */
+ GLfloat bf = SWRAST_CONTEXT(ctx)->_BackfaceSign;
+#if !TRIANGLE_WALK_DOUBLE
+ const GLint snapMask = ~((FIXED_ONE / (1 << SUB_PIXEL_BITS)) - 1); /* for x/y coord snapping */
+#endif
+ GLinterp vMin_fx, vMin_fy, vMid_fx, vMid_fy, vMax_fx, vMax_fy;
+
+ struct sw_span span;
+
+ INIT_SPAN(span, GL_POLYGON, 0, 0, 0);
+
+#ifdef INTERP_Z
+ (void) fixedToDepthShift;
+#endif
+
+ /*
+ printf("%s()\n", __FUNCTION__);
+ printf(" %g, %g, %g\n", v0->win[0], v0->win[1], v0->win[2]);
+ printf(" %g, %g, %g\n", v1->win[0], v1->win[1], v1->win[2]);
+ printf(" %g, %g, %g\n", v2->win[0], v2->win[1], v2->win[2]);
+ */
+ /*
+ ASSERT(v0->win[2] >= 0.0);
+ ASSERT(v1->win[2] >= 0.0);
+ ASSERT(v2->win[2] >= 0.0);
+ */
+ /* Compute fixed point x,y coords w/ half-pixel offsets and snapping.
+ * And find the order of the 3 vertices along the Y axis.
+ */
+ {
+#if TRIANGLE_WALK_DOUBLE
+ const GLdouble fy0 = v0->win[1] - 0.5;
+ const GLdouble fy1 = v1->win[1] - 0.5;
+ const GLdouble fy2 = v2->win[1] - 0.5;
+#else
+ const GLfixed fy0 = FloatToFixed(v0->win[1] - 0.5F) & snapMask;
+ const GLfixed fy1 = FloatToFixed(v1->win[1] - 0.5F) & snapMask;
+ const GLfixed fy2 = FloatToFixed(v2->win[1] - 0.5F) & snapMask;
+#endif
+ if (fy0 <= fy1) {
+ if (fy1 <= fy2) {
+ /* y0 <= y1 <= y2 */
+ vMin = v0; vMid = v1; vMax = v2;
+ vMin_fy = fy0; vMid_fy = fy1; vMax_fy = fy2;
+ }
+ else if (fy2 <= fy0) {
+ /* y2 <= y0 <= y1 */
+ vMin = v2; vMid = v0; vMax = v1;
+ vMin_fy = fy2; vMid_fy = fy0; vMax_fy = fy1;
+ }
+ else {
+ /* y0 <= y2 <= y1 */
+ vMin = v0; vMid = v2; vMax = v1;
+ vMin_fy = fy0; vMid_fy = fy2; vMax_fy = fy1;
+ bf = -bf;
+ }
+ }
+ else {
+ if (fy0 <= fy2) {
+ /* y1 <= y0 <= y2 */
+ vMin = v1; vMid = v0; vMax = v2;
+ vMin_fy = fy1; vMid_fy = fy0; vMax_fy = fy2;
+ bf = -bf;
+ }
+ else if (fy2 <= fy1) {
+ /* y2 <= y1 <= y0 */
+ vMin = v2; vMid = v1; vMax = v0;
+ vMin_fy = fy2; vMid_fy = fy1; vMax_fy = fy0;
+ bf = -bf;
+ }
+ else {
+ /* y1 <= y2 <= y0 */
+ vMin = v1; vMid = v2; vMax = v0;
+ vMin_fy = fy1; vMid_fy = fy2; vMax_fy = fy0;
+ }
+ }
+
+ /* fixed point X coords */
+#if TRIANGLE_WALK_DOUBLE
+ vMin_fx = vMin->win[0] + 0.5;
+ vMid_fx = vMid->win[0] + 0.5;
+ vMax_fx = vMax->win[0] + 0.5;
+#else
+ vMin_fx = FloatToFixed(vMin->win[0] + 0.5F) & snapMask;
+ vMid_fx = FloatToFixed(vMid->win[0] + 0.5F) & snapMask;
+ vMax_fx = FloatToFixed(vMax->win[0] + 0.5F) & snapMask;
+#endif
+ }
+
+ /* vertex/edge relationship */
+ eMaj.v0 = vMin; eMaj.v1 = vMax; /*TODO: .v1's not needed */
+ eTop.v0 = vMid; eTop.v1 = vMax;
+ eBot.v0 = vMin; eBot.v1 = vMid;
+
+ /* compute deltas for each edge: vertex[upper] - vertex[lower] */
+#if TRIANGLE_WALK_DOUBLE
+ eMaj.dx = vMax_fx - vMin_fx;
+ eMaj.dy = vMax_fy - vMin_fy;
+ eTop.dx = vMax_fx - vMid_fx;
+ eTop.dy = vMax_fy - vMid_fy;
+ eBot.dx = vMid_fx - vMin_fx;
+ eBot.dy = vMid_fy - vMin_fy;
+#else
+ eMaj.dx = FixedToFloat(vMax_fx - vMin_fx);
+ eMaj.dy = FixedToFloat(vMax_fy - vMin_fy);
+ eTop.dx = FixedToFloat(vMax_fx - vMid_fx);
+ eTop.dy = FixedToFloat(vMax_fy - vMid_fy);
+ eBot.dx = FixedToFloat(vMid_fx - vMin_fx);
+ eBot.dy = FixedToFloat(vMid_fy - vMin_fy);
+#endif
+
+ /* compute area, oneOverArea and perform backface culling */
+ {
+#if TRIANGLE_WALK_DOUBLE
+ const GLdouble area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy;
+#else
+ const GLfloat area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy;
+#endif
+ /* Do backface culling */
+ if (area * bf < 0.0)
+ return;
+
+ if (IS_INF_OR_NAN(area) || area == 0.0F)
+ return;
+
+ oneOverArea = 1.0F / area;
+ }
+
+
+ span.facing = ctx->_Facing; /* for 2-sided stencil test */
+
+ /* Edge setup. For a triangle strip these could be reused... */
+ {
+#if TRIANGLE_WALK_DOUBLE
+ eMaj.fsy = CEILF(vMin_fy);
+ eMaj.lines = (GLint) CEILF(vMax_fy - eMaj.fsy);
+#else
+ eMaj.fsy = FixedCeil(vMin_fy);
+ eMaj.lines = FixedToInt(FixedCeil(vMax_fy - eMaj.fsy));
+#endif
+ if (eMaj.lines > 0) {
+ eMaj.dxdy = eMaj.dx / eMaj.dy;
+#if TRIANGLE_WALK_DOUBLE
+ eMaj.adjy = (eMaj.fsy - vMin_fy) * FIXED_SCALE; /* SCALED! */
+ eMaj.fx0 = vMin_fx;
+ eMaj.fsx = eMaj.fx0 + (eMaj.adjy * eMaj.dxdy) / (GLdouble) FIXED_SCALE;
+#else
+ eMaj.fdxdy = SignedFloatToFixed(eMaj.dxdy);
+ eMaj.adjy = (GLfloat) (eMaj.fsy - vMin_fy); /* SCALED! */
+ eMaj.fx0 = vMin_fx;
+ eMaj.fsx = eMaj.fx0 + (GLfixed) (eMaj.adjy * eMaj.dxdy);
+#endif
+ }
+ else {
+ return; /*CULLED*/
+ }
+
+#if TRIANGLE_WALK_DOUBLE
+ eTop.fsy = CEILF(vMid_fy);
+ eTop.lines = (GLint) CEILF(vMax_fy - eTop.fsy);
+#else
+ eTop.fsy = FixedCeil(vMid_fy);
+ eTop.lines = FixedToInt(FixedCeil(vMax_fy - eTop.fsy));
+#endif
+ if (eTop.lines > 0) {
+ eTop.dxdy = eTop.dx / eTop.dy;
+#if TRIANGLE_WALK_DOUBLE
+ eTop.adjy = (eTop.fsy - vMid_fy) * FIXED_SCALE; /* SCALED! */
+ eTop.fx0 = vMid_fx;
+ eTop.fsx = eTop.fx0 + (eTop.adjy * eTop.dxdy) / (GLdouble) FIXED_SCALE;
+#else
+ eTop.fdxdy = SignedFloatToFixed(eTop.dxdy);
+ eTop.adjy = (GLfloat) (eTop.fsy - vMid_fy); /* SCALED! */
+ eTop.fx0 = vMid_fx;
+ eTop.fsx = eTop.fx0 + (GLfixed) (eTop.adjy * eTop.dxdy);
+#endif
+ }
+
+#if TRIANGLE_WALK_DOUBLE
+ eBot.fsy = CEILF(vMin_fy);
+ eBot.lines = (GLint) CEILF(vMid_fy - eBot.fsy);
+#else
+ eBot.fsy = FixedCeil(vMin_fy);
+ eBot.lines = FixedToInt(FixedCeil(vMid_fy - eBot.fsy));
+#endif
+ if (eBot.lines > 0) {
+ eBot.dxdy = eBot.dx / eBot.dy;
+#if TRIANGLE_WALK_DOUBLE
+ eBot.adjy = (eBot.fsy - vMin_fy) * FIXED_SCALE; /* SCALED! */
+ eBot.fx0 = vMin_fx;
+ eBot.fsx = eBot.fx0 + (eBot.adjy * eBot.dxdy) / (GLdouble) FIXED_SCALE;
+#else
+ eBot.fdxdy = SignedFloatToFixed(eBot.dxdy);
+ eBot.adjy = (GLfloat) (eBot.fsy - vMin_fy); /* SCALED! */
+ eBot.fx0 = vMin_fx;
+ eBot.fsx = eBot.fx0 + (GLfixed) (eBot.adjy * eBot.dxdy);
+#endif
+ }
+ }
+
+ /*
+ * Conceptually, we view a triangle as two subtriangles
+ * separated by a perfectly horizontal line. The edge that is
+ * intersected by this line is one with maximal absolute dy; we
+ * call it a ``major'' edge. The other two edges are the
+ * ``top'' edge (for the upper subtriangle) and the ``bottom''
+ * edge (for the lower subtriangle). If either of these two
+ * edges is horizontal or very close to horizontal, the
+ * corresponding subtriangle might cover zero sample points;
+ * we take care to handle such cases, for performance as well
+ * as correctness.
+ *
+ * By stepping rasterization parameters along the major edge,
+ * we can avoid recomputing them at the discontinuity where
+ * the top and bottom edges meet. However, this forces us to
+ * be able to scan both left-to-right and right-to-left.
+ * Also, we must determine whether the major edge is at the
+ * left or right side of the triangle. We do this by
+ * computing the magnitude of the cross-product of the major
+ * and top edges. Since this magnitude depends on the sine of
+ * the angle between the two edges, its sign tells us whether
+ * we turn to the left or to the right when travelling along
+ * the major edge to the top edge, and from this we infer
+ * whether the major edge is on the left or the right.
+ *
+ * Serendipitously, this cross-product magnitude is also a
+ * value we need to compute the iteration parameter
+ * derivatives for the triangle, and it can be used to perform
+ * backface culling because its sign tells us whether the
+ * triangle is clockwise or counterclockwise. In this code we
+ * refer to it as ``area'' because it's also proportional to
+ * the pixel area of the triangle.
+ */
+
+ {
+ GLint scan_from_left_to_right; /* true if scanning left-to-right */
+#ifdef INTERP_INDEX
+ GLfloat didx, didy;
+#endif
+
+ /*
+ * Execute user-supplied setup code
+ */
+#ifdef SETUP_CODE
+ SETUP_CODE
+#endif
+
+ scan_from_left_to_right = (oneOverArea < 0.0F);
+
+
+ /* compute d?/dx and d?/dy derivatives */
+#ifdef INTERP_Z
+ span.interpMask |= SPAN_Z;
+ {
+ GLfloat eMaj_dz = vMax->win[2] - vMin->win[2];
+ GLfloat eBot_dz = vMid->win[2] - vMin->win[2];
+ span.dzdx = oneOverArea * (eMaj_dz * eBot.dy - eMaj.dy * eBot_dz);
+ if (span.dzdx > maxDepth || span.dzdx < -maxDepth) {
+ /* probably a sliver triangle */
+ span.dzdx = 0.0;
+ span.dzdy = 0.0;
+ }
+ else {
+ span.dzdy = oneOverArea * (eMaj.dx * eBot_dz - eMaj_dz * eBot.dx);
+ }
+ if (depthBits <= 16)
+ span.zStep = SignedFloatToFixed(span.dzdx);
+ else
+ span.zStep = (GLint) span.dzdx;
+ }
+#endif
+#ifdef INTERP_W
+ span.interpMask |= SPAN_W;
+ {
+ const GLfloat eMaj_dw = vMax->win[3] - vMin->win[3];
+ const GLfloat eBot_dw = vMid->win[3] - vMin->win[3];
+ span.dwdx = oneOverArea * (eMaj_dw * eBot.dy - eMaj.dy * eBot_dw);
+ span.dwdy = oneOverArea * (eMaj.dx * eBot_dw - eMaj_dw * eBot.dx);
+ }
+#endif
+#ifdef INTERP_FOG
+ span.interpMask |= SPAN_FOG;
+ {
+# ifdef INTERP_W
+ const GLfloat wMax = vMax->win[3], wMin = vMin->win[3], wMid = vMid->win[3];
+ const GLfloat eMaj_dfog = vMax->fog * wMax - vMin->fog * wMin;
+ const GLfloat eBot_dfog = vMid->fog * wMid - vMin->fog * wMin;
+# else
+ const GLfloat eMaj_dfog = vMax->fog - vMin->fog;
+ const GLfloat eBot_dfog = vMid->fog - vMin->fog;
+# endif
+ span.dfogdx = oneOverArea * (eMaj_dfog * eBot.dy - eMaj.dy * eBot_dfog);
+ span.dfogdy = oneOverArea * (eMaj.dx * eBot_dfog - eMaj_dfog * eBot.dx);
+ span.fogStep = span.dfogdx;
+ }
+#endif
+#ifdef INTERP_RGB
+ span.interpMask |= SPAN_RGBA;
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ GLfloat eMaj_dr = (GLfloat) ((ColorTemp) vMax->color[RCOMP] - (ColorTemp) vMin->color[RCOMP]);
+ GLfloat eBot_dr = (GLfloat) ((ColorTemp) vMid->color[RCOMP] - (ColorTemp) vMin->color[RCOMP]);
+ GLfloat eMaj_dg = (GLfloat) ((ColorTemp) vMax->color[GCOMP] - (ColorTemp) vMin->color[GCOMP]);
+ GLfloat eBot_dg = (GLfloat) ((ColorTemp) vMid->color[GCOMP] - (ColorTemp) vMin->color[GCOMP]);
+ GLfloat eMaj_db = (GLfloat) ((ColorTemp) vMax->color[BCOMP] - (ColorTemp) vMin->color[BCOMP]);
+ GLfloat eBot_db = (GLfloat) ((ColorTemp) vMid->color[BCOMP] - (ColorTemp) vMin->color[BCOMP]);
+# ifdef INTERP_ALPHA
+ GLfloat eMaj_da = (GLfloat) ((ColorTemp) vMax->color[ACOMP] - (ColorTemp) vMin->color[ACOMP]);
+ GLfloat eBot_da = (GLfloat) ((ColorTemp) vMid->color[ACOMP] - (ColorTemp) vMin->color[ACOMP]);
+# endif
+ span.drdx = oneOverArea * (eMaj_dr * eBot.dy - eMaj.dy * eBot_dr);
+ span.drdy = oneOverArea * (eMaj.dx * eBot_dr - eMaj_dr * eBot.dx);
+ span.dgdx = oneOverArea * (eMaj_dg * eBot.dy - eMaj.dy * eBot_dg);
+ span.dgdy = oneOverArea * (eMaj.dx * eBot_dg - eMaj_dg * eBot.dx);
+ span.dbdx = oneOverArea * (eMaj_db * eBot.dy - eMaj.dy * eBot_db);
+ span.dbdy = oneOverArea * (eMaj.dx * eBot_db - eMaj_db * eBot.dx);
+# if CHAN_TYPE == GL_FLOAT
+ span.redStep = span.drdx;
+ span.greenStep = span.dgdx;
+ span.blueStep = span.dbdx;
+# else
+ span.redStep = SignedFloatToFixed(span.drdx);
+ span.greenStep = SignedFloatToFixed(span.dgdx);
+ span.blueStep = SignedFloatToFixed(span.dbdx);
+# endif /* GL_FLOAT */
+# ifdef INTERP_ALPHA
+ span.dadx = oneOverArea * (eMaj_da * eBot.dy - eMaj.dy * eBot_da);
+ span.dady = oneOverArea * (eMaj.dx * eBot_da - eMaj_da * eBot.dx);
+# if CHAN_TYPE == GL_FLOAT
+ span.alphaStep = span.dadx;
+# else
+ span.alphaStep = SignedFloatToFixed(span.dadx);
+# endif /* GL_FLOAT */
+# endif /* INTERP_ALPHA */
+ }
+ else {
+ ASSERT(ctx->Light.ShadeModel == GL_FLAT);
+ span.interpMask |= SPAN_FLAT;
+ span.drdx = span.drdy = 0.0F;
+ span.dgdx = span.dgdy = 0.0F;
+ span.dbdx = span.dbdy = 0.0F;
+# if CHAN_TYPE == GL_FLOAT
+ span.redStep = 0.0F;
+ span.greenStep = 0.0F;
+ span.blueStep = 0.0F;
+# else
+ span.redStep = 0;
+ span.greenStep = 0;
+ span.blueStep = 0;
+# endif /* GL_FLOAT */
+# ifdef INTERP_ALPHA
+ span.dadx = span.dady = 0.0F;
+# if CHAN_TYPE == GL_FLOAT
+ span.alphaStep = 0.0F;
+# else
+ span.alphaStep = 0;
+# endif /* GL_FLOAT */
+# endif
+ }
+#endif /* INTERP_RGB */
+#ifdef INTERP_SPEC
+ span.interpMask |= SPAN_SPEC;
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ GLfloat eMaj_dsr = (GLfloat) ((ColorTemp) vMax->specular[RCOMP] - (ColorTemp) vMin->specular[RCOMP]);
+ GLfloat eBot_dsr = (GLfloat) ((ColorTemp) vMid->specular[RCOMP] - (ColorTemp) vMin->specular[RCOMP]);
+ GLfloat eMaj_dsg = (GLfloat) ((ColorTemp) vMax->specular[GCOMP] - (ColorTemp) vMin->specular[GCOMP]);
+ GLfloat eBot_dsg = (GLfloat) ((ColorTemp) vMid->specular[GCOMP] - (ColorTemp) vMin->specular[GCOMP]);
+ GLfloat eMaj_dsb = (GLfloat) ((ColorTemp) vMax->specular[BCOMP] - (ColorTemp) vMin->specular[BCOMP]);
+ GLfloat eBot_dsb = (GLfloat) ((ColorTemp) vMid->specular[BCOMP] - (ColorTemp) vMin->specular[BCOMP]);
+ span.dsrdx = oneOverArea * (eMaj_dsr * eBot.dy - eMaj.dy * eBot_dsr);
+ span.dsrdy = oneOverArea * (eMaj.dx * eBot_dsr - eMaj_dsr * eBot.dx);
+ span.dsgdx = oneOverArea * (eMaj_dsg * eBot.dy - eMaj.dy * eBot_dsg);
+ span.dsgdy = oneOverArea * (eMaj.dx * eBot_dsg - eMaj_dsg * eBot.dx);
+ span.dsbdx = oneOverArea * (eMaj_dsb * eBot.dy - eMaj.dy * eBot_dsb);
+ span.dsbdy = oneOverArea * (eMaj.dx * eBot_dsb - eMaj_dsb * eBot.dx);
+# if CHAN_TYPE == GL_FLOAT
+ span.specRedStep = span.dsrdx;
+ span.specGreenStep = span.dsgdx;
+ span.specBlueStep = span.dsbdx;
+# else
+ span.specRedStep = SignedFloatToFixed(span.dsrdx);
+ span.specGreenStep = SignedFloatToFixed(span.dsgdx);
+ span.specBlueStep = SignedFloatToFixed(span.dsbdx);
+# endif
+ }
+ else {
+ span.dsrdx = span.dsrdy = 0.0F;
+ span.dsgdx = span.dsgdy = 0.0F;
+ span.dsbdx = span.dsbdy = 0.0F;
+# if CHAN_TYPE == GL_FLOAT
+ span.specRedStep = 0.0F;
+ span.specGreenStep = 0.0F;
+ span.specBlueStep = 0.0F;
+# else
+ span.specRedStep = 0;
+ span.specGreenStep = 0;
+ span.specBlueStep = 0;
+# endif
+ }
+#endif /* INTERP_SPEC */
+#ifdef INTERP_INDEX
+ span.interpMask |= SPAN_INDEX;
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ GLfloat eMaj_di = vMax->index - vMin->index;
+ GLfloat eBot_di = vMid->index - vMin->index;
+ didx = oneOverArea * (eMaj_di * eBot.dy - eMaj.dy * eBot_di);
+ didy = oneOverArea * (eMaj.dx * eBot_di - eMaj_di * eBot.dx);
+ span.indexStep = SignedFloatToFixed(didx);
+ }
+ else {
+ span.interpMask |= SPAN_FLAT;
+ didx = didy = 0.0F;
+ span.indexStep = 0;
+ }
+#endif
+#ifdef INTERP_INT_TEX
+ span.interpMask |= SPAN_INT_TEXTURE;
+ {
+ GLfloat eMaj_ds = (vMax->texcoord[0][0] - vMin->texcoord[0][0]) * S_SCALE;
+ GLfloat eBot_ds = (vMid->texcoord[0][0] - vMin->texcoord[0][0]) * S_SCALE;
+ GLfloat eMaj_dt = (vMax->texcoord[0][1] - vMin->texcoord[0][1]) * T_SCALE;
+ GLfloat eBot_dt = (vMid->texcoord[0][1] - vMin->texcoord[0][1]) * T_SCALE;
+ span.texStepX[0][0] = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
+ span.texStepY[0][0] = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx);
+ span.texStepX[0][1] = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt);
+ span.texStepY[0][1] = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx);
+ span.intTexStep[0] = SignedFloatToFixed(span.texStepX[0][0]);
+ span.intTexStep[1] = SignedFloatToFixed(span.texStepX[0][1]);
+ }
+#endif
+#ifdef INTERP_TEX
+ span.interpMask |= SPAN_TEXTURE;
+ {
+ /* win[3] is 1/W */
+ const GLfloat wMax = vMax->win[3], wMin = vMin->win[3], wMid = vMid->win[3];
+ TEX_UNIT_LOOP(
+ GLfloat eMaj_ds = vMax->texcoord[u][0] * wMax - vMin->texcoord[u][0] * wMin;
+ GLfloat eBot_ds = vMid->texcoord[u][0] * wMid - vMin->texcoord[u][0] * wMin;
+ GLfloat eMaj_dt = vMax->texcoord[u][1] * wMax - vMin->texcoord[u][1] * wMin;
+ GLfloat eBot_dt = vMid->texcoord[u][1] * wMid - vMin->texcoord[u][1] * wMin;
+ GLfloat eMaj_du = vMax->texcoord[u][2] * wMax - vMin->texcoord[u][2] * wMin;
+ GLfloat eBot_du = vMid->texcoord[u][2] * wMid - vMin->texcoord[u][2] * wMin;
+ GLfloat eMaj_dv = vMax->texcoord[u][3] * wMax - vMin->texcoord[u][3] * wMin;
+ GLfloat eBot_dv = vMid->texcoord[u][3] * wMid - vMin->texcoord[u][3] * wMin;
+ span.texStepX[u][0] = oneOverArea * (eMaj_ds * eBot.dy - eMaj.dy * eBot_ds);
+ span.texStepY[u][0] = oneOverArea * (eMaj.dx * eBot_ds - eMaj_ds * eBot.dx);
+ span.texStepX[u][1] = oneOverArea * (eMaj_dt * eBot.dy - eMaj.dy * eBot_dt);
+ span.texStepY[u][1] = oneOverArea * (eMaj.dx * eBot_dt - eMaj_dt * eBot.dx);
+ span.texStepX[u][2] = oneOverArea * (eMaj_du * eBot.dy - eMaj.dy * eBot_du);
+ span.texStepY[u][2] = oneOverArea * (eMaj.dx * eBot_du - eMaj_du * eBot.dx);
+ span.texStepX[u][3] = oneOverArea * (eMaj_dv * eBot.dy - eMaj.dy * eBot_dv);
+ span.texStepY[u][3] = oneOverArea * (eMaj.dx * eBot_dv - eMaj_dv * eBot.dx);
+ )
+ }
+#endif
+
+ /*
+ * We always sample at pixel centers. However, we avoid
+ * explicit half-pixel offsets in this code by incorporating
+ * the proper offset in each of x and y during the
+ * transformation to window coordinates.
+ *
+ * We also apply the usual rasterization rules to prevent
+ * cracks and overlaps. A pixel is considered inside a
+ * subtriangle if it meets all of four conditions: it is on or
+ * to the right of the left edge, strictly to the left of the
+ * right edge, on or below the top edge, and strictly above
+ * the bottom edge. (Some edges may be degenerate.)
+ *
+ * The following discussion assumes left-to-right scanning
+ * (that is, the major edge is on the left); the right-to-left
+ * case is a straightforward variation.
+ *
+ * We start by finding the half-integral y coordinate that is
+ * at or below the top of the triangle. This gives us the
+ * first scan line that could possibly contain pixels that are
+ * inside the triangle.
+ *
+ * Next we creep down the major edge until we reach that y,
+ * and compute the corresponding x coordinate on the edge.
+ * Then we find the half-integral x that lies on or just
+ * inside the edge. This is the first pixel that might lie in
+ * the interior of the triangle. (We won't know for sure
+ * until we check the other edges.)
+ *
+ * As we rasterize the triangle, we'll step down the major
+ * edge. For each step in y, we'll move an integer number
+ * of steps in x. There are two possible x step sizes, which
+ * we'll call the ``inner'' step (guaranteed to land on the
+ * edge or inside it) and the ``outer'' step (guaranteed to
+ * land on the edge or outside it). The inner and outer steps
+ * differ by one. During rasterization we maintain an error
+ * term that indicates our distance from the true edge, and
+ * select either the inner step or the outer step, whichever
+ * gets us to the first pixel that falls inside the triangle.
+ *
+ * All parameters (z, red, etc.) as well as the buffer
+ * addresses for color and z have inner and outer step values,
+ * so that we can increment them appropriately. This method
+ * eliminates the need to adjust parameters by creeping a
+ * sub-pixel amount into the triangle at each scanline.
+ */
+
+ {
+ GLint subTriangle;
+ GLinterp fxLeftEdge = 0, fxRightEdge = 0;
+ GLinterp fdxLeftEdge = 0, fdxRightEdge = 0;
+ GLinterp fError = 0, fdError = 0;
+#ifdef PIXEL_ADDRESS
+ PIXEL_TYPE *pRow = NULL;
+ GLint dPRowOuter = 0, dPRowInner; /* offset in bytes */
+#endif
+#ifdef INTERP_Z
+# ifdef DEPTH_TYPE
+ struct gl_renderbuffer *zrb
+ = ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+ DEPTH_TYPE *zRow = NULL;
+ GLint dZRowOuter = 0, dZRowInner; /* offset in bytes */
+# endif
+ GLfixed zLeft = 0, fdzOuter = 0, fdzInner;
+#endif
+#ifdef INTERP_W
+ GLfloat wLeft = 0, dwOuter = 0, dwInner;
+#endif
+#ifdef INTERP_FOG
+ GLfloat fogLeft = 0, dfogOuter = 0, dfogInner;
+#endif
+#ifdef INTERP_RGB
+ ColorTemp rLeft = 0, fdrOuter = 0, fdrInner;
+ ColorTemp gLeft = 0, fdgOuter = 0, fdgInner;
+ ColorTemp bLeft = 0, fdbOuter = 0, fdbInner;
+#endif
+#ifdef INTERP_ALPHA
+ ColorTemp aLeft = 0, fdaOuter = 0, fdaInner;
+#endif
+#ifdef INTERP_SPEC
+ ColorTemp srLeft=0, dsrOuter=0, dsrInner;
+ ColorTemp sgLeft=0, dsgOuter=0, dsgInner;
+ ColorTemp sbLeft=0, dsbOuter=0, dsbInner;
+#endif
+#ifdef INTERP_INDEX
+ GLfixed iLeft=0, diOuter=0, diInner;
+#endif
+#ifdef INTERP_INT_TEX
+ GLfixed sLeft=0, dsOuter=0, dsInner;
+ GLfixed tLeft=0, dtOuter=0, dtInner;
+#endif
+#ifdef INTERP_TEX
+ GLfloat sLeft[MAX_TEXTURE_COORD_UNITS];
+ GLfloat tLeft[MAX_TEXTURE_COORD_UNITS];
+ GLfloat uLeft[MAX_TEXTURE_COORD_UNITS];
+ GLfloat vLeft[MAX_TEXTURE_COORD_UNITS];
+ GLfloat dsOuter[MAX_TEXTURE_COORD_UNITS], dsInner[MAX_TEXTURE_COORD_UNITS];
+ GLfloat dtOuter[MAX_TEXTURE_COORD_UNITS], dtInner[MAX_TEXTURE_COORD_UNITS];
+ GLfloat duOuter[MAX_TEXTURE_COORD_UNITS], duInner[MAX_TEXTURE_COORD_UNITS];
+ GLfloat dvOuter[MAX_TEXTURE_COORD_UNITS], dvInner[MAX_TEXTURE_COORD_UNITS];
+#endif
+
+ for (subTriangle=0; subTriangle<=1; subTriangle++) {
+ EdgeT *eLeft, *eRight;
+ int setupLeft, setupRight;
+ int lines;
+
+ if (subTriangle==0) {
+ /* bottom half */
+ if (scan_from_left_to_right) {
+ eLeft = &eMaj;
+ eRight = &eBot;
+ lines = eRight->lines;
+ setupLeft = 1;
+ setupRight = 1;
+ }
+ else {
+ eLeft = &eBot;
+ eRight = &eMaj;
+ lines = eLeft->lines;
+ setupLeft = 1;
+ setupRight = 1;
+ }
+ }
+ else {
+ /* top half */
+ if (scan_from_left_to_right) {
+ eLeft = &eMaj;
+ eRight = &eTop;
+ lines = eRight->lines;
+ setupLeft = 0;
+ setupRight = 1;
+ }
+ else {
+ eLeft = &eTop;
+ eRight = &eMaj;
+ lines = eLeft->lines;
+ setupLeft = 1;
+ setupRight = 0;
+ }
+ if (lines == 0)
+ return;
+ }
+
+ if (setupLeft && eLeft->lines > 0) {
+ const SWvertex *vLower = eLeft->v0;
+#if TRIANGLE_WALK_DOUBLE
+ const GLdouble fsy = eLeft->fsy;
+ const GLdouble fsx = eLeft->fsx;
+ const GLdouble fx = CEILF(fsx);
+ const GLdouble adjx = (fx - eLeft->fx0) * FIXED_SCALE; /* SCALED! */
+#else
+ const GLfixed fsy = eLeft->fsy;
+ const GLfixed fsx = eLeft->fsx; /* no fractional part */
+ const GLfixed fx = FixedCeil(fsx); /* no fractional part */
+ const GLfixed adjx = (GLinterp) (fx - eLeft->fx0); /* SCALED! */
+#endif
+ const GLinterp adjy = (GLinterp) eLeft->adjy; /* SCALED! */
+ GLint idxOuter;
+#if TRIANGLE_WALK_DOUBLE
+ GLdouble dxOuter;
+
+ fError = fx - fsx - 1.0;
+ fxLeftEdge = fsx;
+ fdxLeftEdge = eLeft->dxdy;
+ dxOuter = FLOORF(fdxLeftEdge);
+ fdError = dxOuter - fdxLeftEdge + 1.0;
+ idxOuter = (GLint) dxOuter;
+ span.y = (GLint) fsy;
+#else
+ GLfloat dxOuter;
+ GLfixed fdxOuter;
+
+ fError = fx - fsx - FIXED_ONE;
+ fxLeftEdge = fsx - FIXED_EPSILON;
+ fdxLeftEdge = eLeft->fdxdy;
+ fdxOuter = FixedFloor(fdxLeftEdge - FIXED_EPSILON);
+ fdError = fdxOuter - fdxLeftEdge + FIXED_ONE;
+ idxOuter = FixedToInt(fdxOuter);
+ dxOuter = (GLfloat) idxOuter;
+ span.y = FixedToInt(fsy);
+#endif
+
+ /* silence warnings on some compilers */
+ (void) dxOuter;
+ (void) adjx;
+ (void) adjy;
+ (void) vLower;
+
+#ifdef PIXEL_ADDRESS
+ {
+ pRow = (PIXEL_TYPE *) PIXEL_ADDRESS(InterpToInt(fxLeftEdge), span.y);
+ dPRowOuter = -((int)BYTES_PER_ROW) + idxOuter * sizeof(PIXEL_TYPE);
+ /* negative because Y=0 at bottom and increases upward */
+ }
+#endif
+ /*
+ * Now we need the set of parameter (z, color, etc.) values at
+ * the point (fx, fsy). This gives us properly-sampled parameter
+ * values that we can step from pixel to pixel. Furthermore,
+ * although we might have intermediate results that overflow
+ * the normal parameter range when we step temporarily outside
+ * the triangle, we shouldn't overflow or underflow for any
+ * pixel that's actually inside the triangle.
+ */
+
+#ifdef INTERP_Z
+ {
+ GLfloat z0 = vLower->win[2];
+ if (depthBits <= 16) {
+ /* interpolate fixed-pt values */
+ GLfloat tmp = (z0 * FIXED_SCALE + span.dzdx * adjx + span.dzdy * adjy) + FIXED_HALF;
+ if (tmp < MAX_GLUINT / 2)
+ zLeft = (GLfixed) tmp;
+ else
+ zLeft = MAX_GLUINT / 2;
+ fdzOuter = SignedFloatToFixed(span.dzdy + dxOuter * span.dzdx);
+ }
+ else {
+ /* interpolate depth values exactly */
+ zLeft = (GLint) (z0 + span.dzdx * FixedToFloat(adjx) + span.dzdy * FixedToFloat(adjy));
+ fdzOuter = (GLint) (span.dzdy + dxOuter * span.dzdx);
+ }
+# ifdef DEPTH_TYPE
+ zRow = (DEPTH_TYPE *)
+ zrb->GetPointer(ctx, zrb, InterpToInt(fxLeftEdge), span.y);
+ dZRowOuter = (ctx->DrawBuffer->Width + idxOuter) * sizeof(DEPTH_TYPE);
+# endif
+ }
+#endif
+#ifdef INTERP_W
+ wLeft = vLower->win[3] + (span.dwdx * adjx + span.dwdy * adjy) * (1.0F/FIXED_SCALE);
+ dwOuter = span.dwdy + dxOuter * span.dwdx;
+#endif
+#ifdef INTERP_FOG
+# ifdef INTERP_W
+ fogLeft = vLower->fog * vLower->win[3] + (span.dfogdx * adjx + span.dfogdy * adjy) * (1.0F/FIXED_SCALE);
+# else
+ fogLeft = vLower->fog + (span.dfogdx * adjx + span.dfogdy * adjy) * (1.0F/FIXED_SCALE);
+# endif
+ dfogOuter = span.dfogdy + dxOuter * span.dfogdx;
+#endif
+#ifdef INTERP_RGB
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+# if CHAN_TYPE == GL_FLOAT
+ rLeft = vLower->color[RCOMP] + (span.drdx * adjx + span.drdy * adjy) * (1.0F / FIXED_SCALE);
+ gLeft = vLower->color[GCOMP] + (span.dgdx * adjx + span.dgdy * adjy) * (1.0F / FIXED_SCALE);
+ bLeft = vLower->color[BCOMP] + (span.dbdx * adjx + span.dbdy * adjy) * (1.0F / FIXED_SCALE);
+ fdrOuter = span.drdy + dxOuter * span.drdx;
+ fdgOuter = span.dgdy + dxOuter * span.dgdx;
+ fdbOuter = span.dbdy + dxOuter * span.dbdx;
+# else
+ rLeft = (GLint)(ChanToFixed(vLower->color[RCOMP]) + span.drdx * adjx + span.drdy * adjy) + FIXED_HALF;
+ gLeft = (GLint)(ChanToFixed(vLower->color[GCOMP]) + span.dgdx * adjx + span.dgdy * adjy) + FIXED_HALF;
+ bLeft = (GLint)(ChanToFixed(vLower->color[BCOMP]) + span.dbdx * adjx + span.dbdy * adjy) + FIXED_HALF;
+ fdrOuter = SignedFloatToFixed(span.drdy + dxOuter * span.drdx);
+ fdgOuter = SignedFloatToFixed(span.dgdy + dxOuter * span.dgdx);
+ fdbOuter = SignedFloatToFixed(span.dbdy + dxOuter * span.dbdx);
+# endif
+# ifdef INTERP_ALPHA
+# if CHAN_TYPE == GL_FLOAT
+ aLeft = vLower->color[ACOMP] + (span.dadx * adjx + span.dady * adjy) * (1.0F / FIXED_SCALE);
+ fdaOuter = span.dady + dxOuter * span.dadx;
+# else
+ aLeft = (GLint)(ChanToFixed(vLower->color[ACOMP]) + span.dadx * adjx + span.dady * adjy) + FIXED_HALF;
+ fdaOuter = SignedFloatToFixed(span.dady + dxOuter * span.dadx);
+# endif
+# endif
+ }
+ else {
+ ASSERT(ctx->Light.ShadeModel == GL_FLAT);
+# if CHAN_TYPE == GL_FLOAT
+ rLeft = v2->color[RCOMP];
+ gLeft = v2->color[GCOMP];
+ bLeft = v2->color[BCOMP];
+ fdrOuter = fdgOuter = fdbOuter = 0.0F;
+# else
+ rLeft = ChanToFixed(v2->color[RCOMP]);
+ gLeft = ChanToFixed(v2->color[GCOMP]);
+ bLeft = ChanToFixed(v2->color[BCOMP]);
+ fdrOuter = fdgOuter = fdbOuter = 0;
+# endif
+# ifdef INTERP_ALPHA
+# if CHAN_TYPE == GL_FLOAT
+ aLeft = v2->color[ACOMP];
+ fdaOuter = 0.0F;
+# else
+ aLeft = ChanToFixed(v2->color[ACOMP]);
+ fdaOuter = 0;
+# endif
+# endif
+ }
+#endif /* INTERP_RGB */
+
+
+#ifdef INTERP_SPEC
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+# if CHAN_TYPE == GL_FLOAT
+ srLeft = vLower->specular[RCOMP] + (span.dsrdx * adjx + span.dsrdy * adjy) * (1.0F / FIXED_SCALE);
+ sgLeft = vLower->specular[GCOMP] + (span.dsgdx * adjx + span.dsgdy * adjy) * (1.0F / FIXED_SCALE);
+ sbLeft = vLower->specular[BCOMP] + (span.dsbdx * adjx + span.dsbdy * adjy) * (1.0F / FIXED_SCALE);
+ dsrOuter = span.dsrdy + dxOuter * span.dsrdx;
+ dsgOuter = span.dsgdy + dxOuter * span.dsgdx;
+ dsbOuter = span.dsbdy + dxOuter * span.dsbdx;
+# else
+ srLeft = (GLfixed) (ChanToFixed(vLower->specular[RCOMP]) + span.dsrdx * adjx + span.dsrdy * adjy) + FIXED_HALF;
+ sgLeft = (GLfixed) (ChanToFixed(vLower->specular[GCOMP]) + span.dsgdx * adjx + span.dsgdy * adjy) + FIXED_HALF;
+ sbLeft = (GLfixed) (ChanToFixed(vLower->specular[BCOMP]) + span.dsbdx * adjx + span.dsbdy * adjy) + FIXED_HALF;
+ dsrOuter = SignedFloatToFixed(span.dsrdy + dxOuter * span.dsrdx);
+ dsgOuter = SignedFloatToFixed(span.dsgdy + dxOuter * span.dsgdx);
+ dsbOuter = SignedFloatToFixed(span.dsbdy + dxOuter * span.dsbdx);
+# endif
+ }
+ else {
+ ASSERT(ctx->Light.ShadeModel == GL_FLAT);
+#if CHAN_TYPE == GL_FLOAT
+ srLeft = v2->specular[RCOMP];
+ sgLeft = v2->specular[GCOMP];
+ sbLeft = v2->specular[BCOMP];
+ dsrOuter = dsgOuter = dsbOuter = 0.0F;
+# else
+ srLeft = ChanToFixed(v2->specular[RCOMP]);
+ sgLeft = ChanToFixed(v2->specular[GCOMP]);
+ sbLeft = ChanToFixed(v2->specular[BCOMP]);
+ dsrOuter = dsgOuter = dsbOuter = 0;
+# endif
+ }
+#endif
+
+#ifdef INTERP_INDEX
+ if (ctx->Light.ShadeModel == GL_SMOOTH) {
+ iLeft = (GLfixed)(vLower->index * FIXED_SCALE
+ + didx * adjx + didy * adjy) + FIXED_HALF;
+ diOuter = SignedFloatToFixed(didy + dxOuter * didx);
+ }
+ else {
+ ASSERT(ctx->Light.ShadeModel == GL_FLAT);
+ iLeft = FloatToFixed(v2->index);
+ diOuter = 0;
+ }
+#endif
+#ifdef INTERP_INT_TEX
+ {
+ GLfloat s0, t0;
+ s0 = vLower->texcoord[0][0] * S_SCALE;
+ sLeft = (GLfixed)(s0 * FIXED_SCALE + span.texStepX[0][0] * adjx
+ + span.texStepY[0][0] * adjy) + FIXED_HALF;
+ dsOuter = SignedFloatToFixed(span.texStepY[0][0] + dxOuter * span.texStepX[0][0]);
+
+ t0 = vLower->texcoord[0][1] * T_SCALE;
+ tLeft = (GLfixed)(t0 * FIXED_SCALE + span.texStepX[0][1] * adjx
+ + span.texStepY[0][1] * adjy) + FIXED_HALF;
+ dtOuter = SignedFloatToFixed(span.texStepY[0][1] + dxOuter * span.texStepX[0][1]);
+ }
+#endif
+#ifdef INTERP_TEX
+ TEX_UNIT_LOOP(
+ const GLfloat invW = vLower->win[3];
+ const GLfloat s0 = vLower->texcoord[u][0] * invW;
+ const GLfloat t0 = vLower->texcoord[u][1] * invW;
+ const GLfloat u0 = vLower->texcoord[u][2] * invW;
+ const GLfloat v0 = vLower->texcoord[u][3] * invW;
+ sLeft[u] = s0 + (span.texStepX[u][0] * adjx + span.texStepY[u][0] * adjy) * (1.0F/FIXED_SCALE);
+ tLeft[u] = t0 + (span.texStepX[u][1] * adjx + span.texStepY[u][1] * adjy) * (1.0F/FIXED_SCALE);
+ uLeft[u] = u0 + (span.texStepX[u][2] * adjx + span.texStepY[u][2] * adjy) * (1.0F/FIXED_SCALE);
+ vLeft[u] = v0 + (span.texStepX[u][3] * adjx + span.texStepY[u][3] * adjy) * (1.0F/FIXED_SCALE);
+ dsOuter[u] = span.texStepY[u][0] + dxOuter * span.texStepX[u][0];
+ dtOuter[u] = span.texStepY[u][1] + dxOuter * span.texStepX[u][1];
+ duOuter[u] = span.texStepY[u][2] + dxOuter * span.texStepX[u][2];
+ dvOuter[u] = span.texStepY[u][3] + dxOuter * span.texStepX[u][3];
+ )
+#endif
+ } /*if setupLeft*/
+
+
+ if (setupRight && eRight->lines>0) {
+#if TRIANGLE_WALK_DOUBLE
+ fxRightEdge = eRight->fsx;
+ fdxRightEdge = eRight->dxdy;
+#else
+ fxRightEdge = eRight->fsx - FIXED_EPSILON;
+ fdxRightEdge = eRight->fdxdy;
+#endif
+ }
+
+ if (lines==0) {
+ continue;
+ }
+
+
+ /* Rasterize setup */
+#ifdef PIXEL_ADDRESS
+ dPRowInner = dPRowOuter + sizeof(PIXEL_TYPE);
+#endif
+#ifdef INTERP_Z
+# ifdef DEPTH_TYPE
+ dZRowInner = dZRowOuter + sizeof(DEPTH_TYPE);
+# endif
+ fdzInner = fdzOuter + span.zStep;
+#endif
+#ifdef INTERP_W
+ dwInner = dwOuter + span.dwdx;
+#endif
+#ifdef INTERP_FOG
+ dfogInner = dfogOuter + span.dfogdx;
+#endif
+#ifdef INTERP_RGB
+ fdrInner = fdrOuter + span.redStep;
+ fdgInner = fdgOuter + span.greenStep;
+ fdbInner = fdbOuter + span.blueStep;
+#endif
+#ifdef INTERP_ALPHA
+ fdaInner = fdaOuter + span.alphaStep;
+#endif
+#ifdef INTERP_SPEC
+ dsrInner = dsrOuter + span.specRedStep;
+ dsgInner = dsgOuter + span.specGreenStep;
+ dsbInner = dsbOuter + span.specBlueStep;
+#endif
+#ifdef INTERP_INDEX
+ diInner = diOuter + span.indexStep;
+#endif
+#ifdef INTERP_INT_TEX
+ dsInner = dsOuter + span.intTexStep[0];
+ dtInner = dtOuter + span.intTexStep[1];
+#endif
+#ifdef INTERP_TEX
+ TEX_UNIT_LOOP(
+ dsInner[u] = dsOuter[u] + span.texStepX[u][0];
+ dtInner[u] = dtOuter[u] + span.texStepX[u][1];
+ duInner[u] = duOuter[u] + span.texStepX[u][2];
+ dvInner[u] = dvOuter[u] + span.texStepX[u][3];
+ )
+#endif
+
+ while (lines > 0) {
+ /* initialize the span interpolants to the leftmost value */
+ /* ff = fixed-pt fragment */
+ const GLint right = InterpToInt(fxRightEdge);
+ span.x = InterpToInt(fxLeftEdge);
+ if (right <= span.x)
+ span.end = 0;
+ else
+ span.end = right - span.x;
+
+#ifdef INTERP_Z
+ span.z = zLeft;
+#endif
+#ifdef INTERP_W
+ span.w = wLeft;
+#endif
+#ifdef INTERP_FOG
+ span.fog = fogLeft;
+#endif
+#ifdef INTERP_RGB
+ span.red = rLeft;
+ span.green = gLeft;
+ span.blue = bLeft;
+#endif
+#ifdef INTERP_ALPHA
+ span.alpha = aLeft;
+#endif
+#ifdef INTERP_SPEC
+ span.specRed = srLeft;
+ span.specGreen = sgLeft;
+ span.specBlue = sbLeft;
+#endif
+#ifdef INTERP_INDEX
+ span.index = iLeft;
+#endif
+#ifdef INTERP_INT_TEX
+ span.intTex[0] = sLeft;
+ span.intTex[1] = tLeft;
+#endif
+
+#ifdef INTERP_TEX
+ TEX_UNIT_LOOP(
+ span.tex[u][0] = sLeft[u];
+ span.tex[u][1] = tLeft[u];
+ span.tex[u][2] = uLeft[u];
+ span.tex[u][3] = vLeft[u];
+ )
+#endif
+
+ /* This is where we actually generate fragments */
+ /* XXX the test for span.y > 0 _shouldn't_ be needed but
+ * it fixes a problem on 64-bit Opterons (bug 4842).
+ */
+ if (span.end > 0 && span.y >= 0) {
+ const GLint len = span.end - 1;
+ (void) len;
+#ifdef INTERP_RGB
+ CLAMP_INTERPOLANT(red, redStep, len);
+ CLAMP_INTERPOLANT(green, greenStep, len);
+ CLAMP_INTERPOLANT(blue, blueStep, len);
+#endif
+#ifdef INTERP_ALPHA
+ CLAMP_INTERPOLANT(alpha, alphaStep, len);
+#endif
+#ifdef INTERP_SPEC
+ CLAMP_INTERPOLANT(specRed, specRedStep, len);
+ CLAMP_INTERPOLANT(specGreen, specGreenStep, len);
+ CLAMP_INTERPOLANT(specBlue, specBlueStep, len);
+#endif
+#ifdef INTERP_INDEX
+ CLAMP_INTERPOLANT(index, indexStep, len);
+#endif
+ { RENDER_SPAN( span ); }
+ }
+
+ /*
+ * Advance to the next scan line. Compute the
+ * new edge coordinates, and adjust the
+ * pixel-center x coordinate so that it stays
+ * on or inside the major edge.
+ */
+ span.y++;
+ lines--;
+
+ fxLeftEdge += fdxLeftEdge;
+ fxRightEdge += fdxRightEdge;
+
+ fError += fdError;
+ if (fError >= 0) {
+ fError -= INTERP_ONE;
+
+#ifdef PIXEL_ADDRESS
+ pRow = (PIXEL_TYPE *) ((GLubyte *) pRow + dPRowOuter);
+#endif
+#ifdef INTERP_Z
+# ifdef DEPTH_TYPE
+ zRow = (DEPTH_TYPE *) ((GLubyte *) zRow + dZRowOuter);
+# endif
+ zLeft += fdzOuter;
+#endif
+#ifdef INTERP_W
+ wLeft += dwOuter;
+#endif
+#ifdef INTERP_FOG
+ fogLeft += dfogOuter;
+#endif
+#ifdef INTERP_RGB
+ rLeft += fdrOuter;
+ gLeft += fdgOuter;
+ bLeft += fdbOuter;
+#endif
+#ifdef INTERP_ALPHA
+ aLeft += fdaOuter;
+#endif
+#ifdef INTERP_SPEC
+ srLeft += dsrOuter;
+ sgLeft += dsgOuter;
+ sbLeft += dsbOuter;
+#endif
+#ifdef INTERP_INDEX
+ iLeft += diOuter;
+#endif
+#ifdef INTERP_INT_TEX
+ sLeft += dsOuter;
+ tLeft += dtOuter;
+#endif
+#ifdef INTERP_TEX
+ TEX_UNIT_LOOP(
+ sLeft[u] += dsOuter[u];
+ tLeft[u] += dtOuter[u];
+ uLeft[u] += duOuter[u];
+ vLeft[u] += dvOuter[u];
+ )
+#endif
+ }
+ else {
+#ifdef PIXEL_ADDRESS
+ pRow = (PIXEL_TYPE *) ((GLubyte *) pRow + dPRowInner);
+#endif
+#ifdef INTERP_Z
+# ifdef DEPTH_TYPE
+ zRow = (DEPTH_TYPE *) ((GLubyte *) zRow + dZRowInner);
+# endif
+ zLeft += fdzInner;
+#endif
+#ifdef INTERP_W
+ wLeft += dwInner;
+#endif
+#ifdef INTERP_FOG
+ fogLeft += dfogInner;
+#endif
+#ifdef INTERP_RGB
+ rLeft += fdrInner;
+ gLeft += fdgInner;
+ bLeft += fdbInner;
+#endif
+#ifdef INTERP_ALPHA
+ aLeft += fdaInner;
+#endif
+#ifdef INTERP_SPEC
+ srLeft += dsrInner;
+ sgLeft += dsgInner;
+ sbLeft += dsbInner;
+#endif
+#ifdef INTERP_INDEX
+ iLeft += diInner;
+#endif
+#ifdef INTERP_INT_TEX
+ sLeft += dsInner;
+ tLeft += dtInner;
+#endif
+#ifdef INTERP_TEX
+ TEX_UNIT_LOOP(
+ sLeft[u] += dsInner[u];
+ tLeft[u] += dtInner[u];
+ uLeft[u] += duInner[u];
+ vLeft[u] += dvInner[u];
+ )
+#endif
+ }
+ } /*while lines>0*/
+
+ } /* for subTriangle */
+
+ }
+#ifdef CLEANUP_CODE
+ CLEANUP_CODE
+#endif
+ }
+}
+
+#undef SETUP_CODE
+#undef CLEANUP_CODE
+#undef RENDER_SPAN
+
+#undef PIXEL_TYPE
+#undef BYTES_PER_ROW
+#undef PIXEL_ADDRESS
+#undef DEPTH_TYPE
+
+#undef INTERP_Z
+#undef INTERP_W
+#undef INTERP_FOG
+#undef INTERP_RGB
+#undef INTERP_ALPHA
+#undef INTERP_SPEC
+#undef INTERP_INDEX
+#undef INTERP_INT_TEX
+#undef INTERP_TEX
+#undef INTERP_MULTITEX
+#undef TEX_UNIT_LOOP
+
+#undef S_SCALE
+#undef T_SCALE
+
+#undef FixedToDepth
+#undef ColorTemp
+#undef GLinterp
+#undef InterpToInt
+#undef INTERP_ONE
+
+#undef NAME
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_zoom.c b/nx-X11/extras/Mesa/src/mesa/swrast/s_zoom.c
new file mode 100644
index 000000000..b67a29701
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_zoom.c
@@ -0,0 +1,428 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+#include "glheader.h"
+#include "macros.h"
+#include "imports.h"
+#include "colormac.h"
+
+#include "s_context.h"
+#include "s_span.h"
+#include "s_stencil.h"
+#include "s_zoom.h"
+
+
+/*
+ * Helper function called from _swrast_write_zoomed_rgba/rgb/index_span().
+ */
+static void
+zoom_span( GLcontext *ctx, const struct sw_span *span,
+ const GLvoid *src, GLint y0, GLenum format, GLint skipPixels )
+{
+ GLint r0, r1, row;
+ GLint c0, c1, skipCol;
+ GLint i, j;
+ const GLuint maxWidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH );
+ struct sw_span zoomed;
+ struct span_arrays zoomed_arrays; /* this is big! */
+
+ /* no pixel arrays! must be horizontal spans. */
+ ASSERT((span->arrayMask & SPAN_XY) == 0);
+ ASSERT(span->primitive == GL_BITMAP);
+
+ INIT_SPAN(zoomed, GL_BITMAP, 0, 0, 0);
+ zoomed.array = &zoomed_arrays;
+
+ /* copy fog interp info */
+ zoomed.fog = span->fog;
+ zoomed.fogStep = span->fogStep;
+ /* XXX copy texcoord info? */
+
+ if (format == GL_RGBA || format == GL_RGB) {
+ /* copy Z info */
+ zoomed.z = span->z;
+ zoomed.zStep = span->zStep;
+ /* we'll generate an array of colorss */
+ zoomed.interpMask = span->interpMask & ~SPAN_RGBA;
+ zoomed.arrayMask |= SPAN_RGBA;
+ }
+ else if (format == GL_COLOR_INDEX) {
+ /* copy Z info */
+ zoomed.z = span->z;
+ zoomed.zStep = span->zStep;
+ /* we'll generate an array of color indexes */
+ zoomed.interpMask = span->interpMask & ~SPAN_INDEX;
+ zoomed.arrayMask |= SPAN_INDEX;
+ }
+ else {
+ assert(format == GL_DEPTH_COMPONENT);
+ /* Copy color info */
+ zoomed.red = span->red;
+ zoomed.green = span->green;
+ zoomed.blue = span->blue;
+ zoomed.alpha = span->alpha;
+ zoomed.redStep = span->redStep;
+ zoomed.greenStep = span->greenStep;
+ zoomed.blueStep = span->blueStep;
+ zoomed.alphaStep = span->alphaStep;
+ /* we'll generate an array of depth values */
+ zoomed.interpMask = span->interpMask & ~SPAN_Z;
+ zoomed.arrayMask |= SPAN_Z;
+ }
+
+ /*
+ * Compute which columns to draw: [c0, c1)
+ */
+ c0 = (GLint) (span->x + skipPixels * ctx->Pixel.ZoomX);
+ c1 = (GLint) (span->x + (skipPixels + span->end) * ctx->Pixel.ZoomX);
+ if (c0 == c1) {
+ return;
+ }
+ else if (c1 < c0) {
+ /* swap */
+ GLint ctmp = c1;
+ c1 = c0;
+ c0 = ctmp;
+ }
+ if (c0 < 0) {
+ zoomed.x = 0;
+ zoomed.start = 0;
+ zoomed.end = c1;
+ skipCol = -c0;
+ }
+ else {
+ zoomed.x = c0;
+ zoomed.start = 0;
+ zoomed.end = c1 - c0;
+ skipCol = 0;
+ }
+ if (zoomed.end > maxWidth)
+ zoomed.end = maxWidth;
+
+ /*
+ * Compute which rows to draw: [r0, r1)
+ */
+ row = span->y - y0;
+ r0 = y0 + (GLint) (row * ctx->Pixel.ZoomY);
+ r1 = y0 + (GLint) ((row+1) * ctx->Pixel.ZoomY);
+ if (r0 == r1) {
+ return;
+ }
+ else if (r1 < r0) {
+ /* swap */
+ GLint rtmp = r1;
+ r1 = r0;
+ r0 = rtmp;
+ }
+
+ ASSERT(r0 < r1);
+ ASSERT(c0 < c1);
+
+ /*
+ * Trivial clip rejection testing.
+ */
+ if (r1 < 0) /* below window */
+ return;
+ if (r0 >= (GLint) ctx->DrawBuffer->Height) /* above window */
+ return;
+ if (c1 < 0) /* left of window */
+ return;
+ if (c0 >= (GLint) ctx->DrawBuffer->Width) /* right of window */
+ return;
+
+ /* zoom the span horizontally */
+ if (format == GL_RGBA) {
+ const GLchan (*rgba)[4] = (const GLchan (*)[4]) src;
+ if (ctx->Pixel.ZoomX == -1.0F) {
+ /* common case */
+ for (j = (GLint) zoomed.start; j < (GLint) zoomed.end; j++) {
+ i = span->end - (j + skipCol) - 1;
+ COPY_CHAN4(zoomed.array->rgba[j], rgba[i]);
+ }
+ }
+ else {
+ /* general solution */
+ const GLfloat xscale = 1.0F / ctx->Pixel.ZoomX;
+ for (j = (GLint) zoomed.start; j < (GLint) zoomed.end; j++) {
+ i = (GLint) ((j + skipCol) * xscale);
+ if (ctx->Pixel.ZoomX < 0.0) {
+ ASSERT(i <= 0);
+ i = span->end + i - 1;
+ }
+ ASSERT(i >= 0);
+ ASSERT(i < (GLint) span->end);
+ COPY_CHAN4(zoomed.array->rgba[j], rgba[i]);
+ }
+ }
+ }
+ else if (format == GL_RGB) {
+ const GLchan (*rgb)[3] = (const GLchan (*)[3]) src;
+ if (ctx->Pixel.ZoomX == -1.0F) {
+ /* common case */
+ for (j = (GLint) zoomed.start; j < (GLint) zoomed.end; j++) {
+ i = span->end - (j + skipCol) - 1;
+ zoomed.array->rgba[j][0] = rgb[i][0];
+ zoomed.array->rgba[j][1] = rgb[i][1];
+ zoomed.array->rgba[j][2] = rgb[i][2];
+ zoomed.array->rgba[j][3] = CHAN_MAX;
+ }
+ }
+ else {
+ /* general solution */
+ const GLfloat xscale = 1.0F / ctx->Pixel.ZoomX;
+ for (j = (GLint) zoomed.start; j < (GLint) zoomed.end; j++) {
+ i = (GLint) ((j + skipCol) * xscale);
+ if (ctx->Pixel.ZoomX < 0.0) {
+ ASSERT(i <= 0);
+ i = span->end + i - 1;
+ }
+ ASSERT(i >= 0);
+ ASSERT(i < (GLint) span->end);
+ zoomed.array->rgba[j][0] = rgb[i][0];
+ zoomed.array->rgba[j][1] = rgb[i][1];
+ zoomed.array->rgba[j][2] = rgb[i][2];
+ zoomed.array->rgba[j][3] = CHAN_MAX;
+ }
+ }
+ }
+ else if (format == GL_COLOR_INDEX) {
+ const GLuint *indexes = (const GLuint *) src;
+ if (ctx->Pixel.ZoomX == -1.0F) {
+ /* common case */
+ for (j = (GLint) zoomed.start; j < (GLint) zoomed.end; j++) {
+ i = span->end - (j + skipCol) - 1;
+ zoomed.array->index[j] = indexes[i];
+ }
+ }
+ else {
+ /* general solution */
+ const GLfloat xscale = 1.0F / ctx->Pixel.ZoomX;
+ for (j = (GLint) zoomed.start; j < (GLint) zoomed.end; j++) {
+ i = (GLint) ((j + skipCol) * xscale);
+ if (ctx->Pixel.ZoomX < 0.0) {
+ ASSERT(i <= 0);
+ i = span->end + i - 1;
+ }
+ ASSERT(i >= 0);
+ ASSERT(i < (GLint) span->end);
+ zoomed.array->index[j] = indexes[i];
+ }
+ }
+ }
+ else {
+ const GLdepth *zValues = (const GLuint *) src;
+ assert(format == GL_DEPTH_COMPONENT);
+ if (ctx->Pixel.ZoomX == -1.0F) {
+ /* common case */
+ for (j = (GLint) zoomed.start; j < (GLint) zoomed.end; j++) {
+ i = span->end - (j + skipCol) - 1;
+ zoomed.array->z[j] = zValues[i];
+ }
+ }
+ else {
+ /* general solution */
+ const GLfloat xscale = 1.0F / ctx->Pixel.ZoomX;
+ for (j = (GLint) zoomed.start; j < (GLint) zoomed.end; j++) {
+ i = (GLint) ((j + skipCol) * xscale);
+ if (ctx->Pixel.ZoomX < 0.0) {
+ ASSERT(i <= 0);
+ i = span->end + i - 1;
+ }
+ ASSERT(i >= 0);
+ ASSERT(i < (GLint) span->end);
+ zoomed.array->z[j] = zValues[i];
+ }
+ }
+ /* Now, fall into either the RGB or COLOR_INDEX path below */
+ if (ctx->Visual.rgbMode)
+ format = GL_RGBA;
+ else
+ format = GL_COLOR_INDEX;
+ }
+
+
+ /* write the span in rows [r0, r1) */
+ if (format == GL_RGBA || format == GL_RGB) {
+ /* Writing the span may modify the colors, so make a backup now if we're
+ * going to call _swrast_write_zoomed_span() more than once.
+ * Also, clipping may change the span end value, so store it as well.
+ */
+ GLchan rgbaSave[MAX_WIDTH][4];
+ const GLint end = zoomed.end; /* save */
+ if (r1 - r0 > 1) {
+ MEMCPY(rgbaSave, zoomed.array->rgba, zoomed.end * 4 * sizeof(GLchan));
+ }
+ for (zoomed.y = r0; zoomed.y < r1; zoomed.y++) {
+ _swrast_write_rgba_span(ctx, &zoomed);
+ zoomed.end = end; /* restore */
+ if (r1 - r0 > 1) {
+ /* restore the colors */
+ MEMCPY(zoomed.array->rgba, rgbaSave, zoomed.end*4 * sizeof(GLchan));
+ }
+ }
+ }
+ else if (format == GL_COLOR_INDEX) {
+ GLuint indexSave[MAX_WIDTH];
+ const GLint end = zoomed.end; /* save */
+ if (r1 - r0 > 1) {
+ MEMCPY(indexSave, zoomed.array->index, zoomed.end * sizeof(GLuint));
+ }
+ for (zoomed.y = r0; zoomed.y < r1; zoomed.y++) {
+ _swrast_write_index_span(ctx, &zoomed);
+ zoomed.end = end; /* restore */
+ if (r1 - r0 > 1) {
+ /* restore the colors */
+ MEMCPY(zoomed.array->index, indexSave, zoomed.end * sizeof(GLuint));
+ }
+ }
+ }
+}
+
+
+void
+_swrast_write_zoomed_rgba_span( GLcontext *ctx, const struct sw_span *span,
+ CONST GLchan rgba[][4], GLint y0,
+ GLint skipPixels )
+{
+ zoom_span(ctx, span, (const GLvoid *) rgba, y0, GL_RGBA, skipPixels);
+}
+
+
+void
+_swrast_write_zoomed_rgb_span( GLcontext *ctx, const struct sw_span *span,
+ CONST GLchan rgb[][3], GLint y0,
+ GLint skipPixels )
+{
+ zoom_span(ctx, span, (const GLvoid *) rgb, y0, GL_RGB, skipPixels);
+}
+
+
+void
+_swrast_write_zoomed_index_span( GLcontext *ctx, const struct sw_span *span,
+ GLint y0, GLint skipPixels )
+{
+ zoom_span(ctx, span, (const GLvoid *) span->array->index, y0,
+ GL_COLOR_INDEX, skipPixels);
+}
+
+
+void
+_swrast_write_zoomed_depth_span( GLcontext *ctx, const struct sw_span *span,
+ GLint y0, GLint skipPixels )
+{
+ zoom_span(ctx, span, (const GLvoid *) span->array->z, y0,
+ GL_DEPTH_COMPONENT, skipPixels);
+}
+
+
+/*
+ * As above, but write stencil values.
+ */
+void
+_swrast_write_zoomed_stencil_span( GLcontext *ctx,
+ GLuint n, GLint x, GLint y,
+ const GLstencil stencil[], GLint y0,
+ GLint skipPixels )
+{
+ GLint m;
+ GLint r0, r1, row, r;
+ GLint i, j, skipcol;
+ GLstencil zstencil[MAX_WIDTH]; /* zoomed stencil values */
+ GLint maxwidth = MIN2( ctx->DrawBuffer->Width, MAX_WIDTH );
+
+ (void) skipPixels; /* XXX this shouldn't be ignored */
+
+ /* compute width of output row */
+ m = (GLint) FABSF( n * ctx->Pixel.ZoomX );
+ if (m==0) {
+ return;
+ }
+ if (ctx->Pixel.ZoomX<0.0) {
+ /* adjust x coordinate for left/right mirroring */
+ x = x - m;
+ }
+
+ /* compute which rows to draw */
+ row = y - y0;
+ r0 = y0 + (GLint) (row * ctx->Pixel.ZoomY);
+ r1 = y0 + (GLint) ((row+1) * ctx->Pixel.ZoomY);
+ if (r0==r1) {
+ return;
+ }
+ else if (r1<r0) {
+ GLint rtmp = r1;
+ r1 = r0;
+ r0 = rtmp;
+ }
+
+ /* return early if r0...r1 is above or below window */
+ if (r0<0 && r1<0) {
+ /* below window */
+ return;
+ }
+ if (r0 >= (GLint) ctx->DrawBuffer->Height &&
+ r1 >= (GLint) ctx->DrawBuffer->Height) {
+ /* above window */
+ return;
+ }
+
+ /* check if left edge is outside window */
+ skipcol = 0;
+ if (x<0) {
+ skipcol = -x;
+ m += x;
+ }
+ /* make sure span isn't too long or short */
+ if (m>maxwidth) {
+ m = maxwidth;
+ }
+ else if (m<=0) {
+ return;
+ }
+
+ ASSERT( m <= MAX_WIDTH );
+
+ /* zoom the span horizontally */
+ if (ctx->Pixel.ZoomX==-1.0F) {
+ /* n==m */
+ for (j=0;j<m;j++) {
+ i = n - (j+skipcol) - 1;
+ zstencil[j] = stencil[i];
+ }
+ }
+ else {
+ GLfloat xscale = 1.0F / ctx->Pixel.ZoomX;
+ for (j=0;j<m;j++) {
+ i = (GLint) ((j+skipcol) * xscale);
+ if (i<0) i = n + i - 1;
+ zstencil[j] = stencil[i];
+ }
+ }
+
+ /* write the span */
+ for (r=r0; r<r1; r++) {
+ _swrast_write_stencil_span( ctx, m, x+skipcol, r, zstencil );
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/s_zoom.h b/nx-X11/extras/Mesa/src/mesa/swrast/s_zoom.h
new file mode 100644
index 000000000..aa9a891eb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/s_zoom.h
@@ -0,0 +1,54 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef S_ZOOM_H
+#define S_ZOOM_H
+
+#include "mtypes.h"
+#include "swrast.h"
+
+extern void
+_swrast_write_zoomed_rgba_span( GLcontext *ctx, const struct sw_span *span,
+ CONST GLchan rgb[][4], GLint y0,
+ GLint skipPixels );
+
+extern void
+_swrast_write_zoomed_rgb_span( GLcontext *ctx, const struct sw_span *span,
+ CONST GLchan rgb[][3], GLint y0,
+ GLint skipPixels );
+
+extern void
+_swrast_write_zoomed_index_span( GLcontext *ctx, const struct sw_span *span,
+ GLint y0, GLint skipPixels );
+
+extern void
+_swrast_write_zoomed_depth_span( GLcontext *ctx, const struct sw_span *span,
+ GLint y0, GLint skipPixels );
+
+extern void
+_swrast_write_zoomed_stencil_span( GLcontext *ctx, GLuint n, GLint x, GLint y,
+ const GLstencil stencil[], GLint y0,
+ GLint skipPixels );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast/swrast.h b/nx-X11/extras/Mesa/src/mesa/swrast/swrast.h
new file mode 100644
index 000000000..90123e513
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast/swrast.h
@@ -0,0 +1,299 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+/**
+ * \file swrast/swrast.h
+ * \brief Public interface to the software rasterization functions.
+ * \author Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef SWRAST_H
+#define SWRAST_H
+
+#include "mtypes.h"
+
+/**
+ * \struct SWvertex
+ * \brief Data-structure to handle vertices in the software rasterizer.
+ *
+ * The software rasterizer now uses this format for vertices. Thus a
+ * 'RasterSetup' stage or other translation is required between the
+ * tnl module and the swrast rasterization functions. This serves to
+ * isolate the swrast module from the internals of the tnl module, and
+ * improve its usefulness as a fallback mechanism for hardware
+ * drivers.
+ *
+ * Full software drivers:
+ * - Register the rastersetup and triangle functions from
+ * utils/software_helper.
+ * - On statechange, update the rasterization pointers in that module.
+ *
+ * Rasterization hardware drivers:
+ * - Keep native rastersetup.
+ * - Implement native twoside,offset and unfilled triangle setup.
+ * - Implement a translator from native vertices to swrast vertices.
+ * - On partial fallback (mix of accelerated and unaccelerated
+ * prims), call a pass-through function which translates native
+ * vertices to SWvertices and calls the appropriate swrast function.
+ * - On total fallback (vertex format insufficient for state or all
+ * primitives unaccelerated), hook in swrast_setup instead.
+ */
+typedef struct {
+ /** win[0], win[1] are the screen-coords of SWvertex.
+ * win[2] is the z-buffer coord (if 16-bit Z buffer, in range [0,65535]).
+ * win[3] is 1/w where w is the clip-space W coord. This is the value
+ * that clip{XYZ} were multiplied by to get ndc{XYZ}.
+ */
+ GLfloat win[4];
+ GLfloat texcoord[MAX_TEXTURE_COORD_UNITS][4];
+ GLchan color[4];
+ GLchan specular[4];
+ GLfloat fog;
+ GLfloat index;
+ GLfloat pointSize;
+} SWvertex;
+
+
+struct swrast_device_driver;
+
+
+/* These are the public-access functions exported from swrast.
+ */
+extern void
+_swrast_use_read_buffer( GLcontext *ctx );
+
+extern void
+_swrast_use_draw_buffer( GLcontext *ctx );
+
+extern GLboolean
+_swrast_CreateContext( GLcontext *ctx );
+
+extern void
+_swrast_DestroyContext( GLcontext *ctx );
+
+/* Get a (non-const) reference to the device driver struct for swrast.
+ */
+extern struct swrast_device_driver *
+_swrast_GetDeviceDriverReference( GLcontext *ctx );
+
+extern void
+_swrast_Bitmap( GLcontext *ctx,
+ GLint px, GLint py,
+ GLsizei width, GLsizei height,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLubyte *bitmap );
+
+extern void
+_swrast_CopyPixels( GLcontext *ctx,
+ GLint srcx, GLint srcy,
+ GLint destx, GLint desty,
+ GLsizei width, GLsizei height,
+ GLenum type );
+
+extern void
+_swrast_DrawPixels( GLcontext *ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels );
+
+extern void
+_swrast_ReadPixels( GLcontext *ctx,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ GLvoid *pixels );
+
+extern void
+_swrast_Clear( GLcontext *ctx, GLbitfield mask, GLboolean all,
+ GLint x, GLint y, GLint width, GLint height );
+
+extern void
+_swrast_Accum( GLcontext *ctx, GLenum op,
+ GLfloat value, GLint xpos, GLint ypos,
+ GLint width, GLint height );
+
+
+extern void
+_swrast_DrawBuffer( GLcontext *ctx, GLenum mode );
+
+
+extern void
+_swrast_DrawBuffers( GLcontext *ctx, GLsizei n, const GLenum *buffers );
+
+
+/* Reset the stipple counter
+ */
+extern void
+_swrast_ResetLineStipple( GLcontext *ctx );
+
+/* These will always render the correct point/line/triangle for the
+ * current state.
+ *
+ * For flatshaded primitives, the provoking vertex is the final one.
+ */
+extern void
+_swrast_Point( GLcontext *ctx, const SWvertex *v );
+
+extern void
+_swrast_Line( GLcontext *ctx, const SWvertex *v0, const SWvertex *v1 );
+
+extern void
+_swrast_Triangle( GLcontext *ctx, const SWvertex *v0,
+ const SWvertex *v1, const SWvertex *v2 );
+
+extern void
+_swrast_Quad( GLcontext *ctx,
+ const SWvertex *v0, const SWvertex *v1,
+ const SWvertex *v2, const SWvertex *v3);
+
+extern void
+_swrast_flush( GLcontext *ctx );
+
+extern void
+_swrast_render_primitive( GLcontext *ctx, GLenum mode );
+
+extern void
+_swrast_render_start( GLcontext *ctx );
+
+extern void
+_swrast_render_finish( GLcontext *ctx );
+
+/* Tell the software rasterizer about core state changes.
+ */
+extern void
+_swrast_InvalidateState( GLcontext *ctx, GLuint new_state );
+
+/* Configure software rasterizer to match hardware rasterizer characteristics:
+ */
+extern void
+_swrast_allow_vertex_fog( GLcontext *ctx, GLboolean value );
+
+extern void
+_swrast_allow_pixel_fog( GLcontext *ctx, GLboolean value );
+
+/* Debug:
+ */
+extern void
+_swrast_print_vertex( GLcontext *ctx, const SWvertex *v );
+
+
+/*
+ * Imaging fallbacks (a better solution should be found, perhaps
+ * moving all the imaging fallback code to a new module)
+ */
+extern void
+_swrast_CopyConvolutionFilter2D(GLcontext *ctx, GLenum target,
+ GLenum internalFormat,
+ GLint x, GLint y, GLsizei width,
+ GLsizei height);
+extern void
+_swrast_CopyConvolutionFilter1D(GLcontext *ctx, GLenum target,
+ GLenum internalFormat,
+ GLint x, GLint y, GLsizei width);
+extern void
+_swrast_CopyColorSubTable( GLcontext *ctx,GLenum target, GLsizei start,
+ GLint x, GLint y, GLsizei width);
+extern void
+_swrast_CopyColorTable( GLcontext *ctx,
+ GLenum target, GLenum internalformat,
+ GLint x, GLint y, GLsizei width);
+
+
+/*
+ * Texture fallbacks. Could also live in a new module
+ * with the rest of the texture store fallbacks?
+ */
+extern void
+_swrast_copy_teximage1d(GLcontext *ctx, GLenum target, GLint level,
+ GLenum internalFormat,
+ GLint x, GLint y, GLsizei width, GLint border);
+
+extern void
+_swrast_copy_teximage2d(GLcontext *ctx, GLenum target, GLint level,
+ GLenum internalFormat,
+ GLint x, GLint y, GLsizei width, GLsizei height,
+ GLint border);
+
+
+extern void
+_swrast_copy_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
+ GLint xoffset, GLint x, GLint y, GLsizei width);
+
+extern void
+_swrast_copy_texsubimage2d(GLcontext *ctx,
+ GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint x, GLint y, GLsizei width, GLsizei height);
+
+extern void
+_swrast_copy_texsubimage3d(GLcontext *ctx,
+ GLenum target, GLint level,
+ GLint xoffset, GLint yoffset, GLint zoffset,
+ GLint x, GLint y, GLsizei width, GLsizei height);
+
+
+/* The driver interface for the software rasterizer.
+ * Unless otherwise noted, all functions are mandatory.
+ */
+struct swrast_device_driver {
+#if OLD_RENDERBUFFER
+ void (*SetBuffer)(GLcontext *ctx, GLframebuffer *buffer, GLuint bufferBit);
+ /*
+ * Specifies the current color buffer for span/pixel writing/reading.
+ * buffer indicates which window to write to / read from. Normally,
+ * this'll be the buffer currently bound to the context, but it doesn't
+ * have to be!
+ * bufferBit indicates which color buffer, exactly one of:
+ * DD_FRONT_LEFT_BIT - this buffer always exists
+ * DD_BACK_LEFT_BIT - when double buffering
+ * DD_FRONT_RIGHT_BIT - when using stereo
+ * DD_BACK_RIGHT_BIT - when using stereo and double buffering
+ * DD_AUXn_BIT - if aux buffers are implemented
+ */
+#endif
+
+ /***
+ *** Functions for synchronizing access to the framebuffer:
+ ***/
+
+ void (*SpanRenderStart)(GLcontext *ctx);
+ void (*SpanRenderFinish)(GLcontext *ctx);
+ /* OPTIONAL.
+ *
+ * Called before and after all rendering operations, including DrawPixels,
+ * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands.
+ * These are a suitable place for grabbing/releasing hardware locks.
+ *
+ * NOTE: The swrast triangle/line/point routines *DO NOT* call
+ * these functions. Locking in that case must be organized by the
+ * driver by other mechanisms.
+ */
+};
+
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/NOTES b/nx-X11/extras/Mesa/src/mesa/swrast_setup/NOTES
new file mode 100644
index 000000000..c6cb4ab34
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/NOTES
@@ -0,0 +1,65 @@
+INTRODUCTION
+
+A helper module which provides glue to bind the software rasterizer to
+the software t&l module. The main task of this module is to build
+swrast vertices from the t&l vertex_buffer structs, and to use them to
+perform triangle setup functions not implemented in the software
+rasterizer.
+
+The module implements a full set of functions to plug into the
+t_vb_render.c driver interface (tnl->Driver.Render.*).
+
+There are strong advantages to decoupling the software rasterizer from
+the t&l module, primarily allowing hardware drivers better control
+over fallbacks, the removal of implicit knowledge about the software
+rasterizer in the t&l module, allowing the two modules to evolve
+independently and allowing either to be substituted with equivalent
+functionality from another codebase.
+
+This module implements triangle/quad setup for offset, unfilled and
+twoside-lit triangles. The software rasterizer doesn't handle these
+primitives directly.
+
+Hardware rasterization drivers typically use this module in situations
+where no hardware rasterization is possible, ie during total
+fallbacks.
+
+STATE
+
+To create and destroy the module:
+
+ GLboolean _swsetup_CreateContext( GLcontext *ctx );
+ void _swsetup_DestroyContext( GLcontext *ctx );
+
+The module is not active by default, and must be installed by calling
+_swrast_Wakeup(). This function installs internal swrast_setup
+functions into all the tnl->Driver.Render driver hooks, thus taking
+over the task of rasterization entirely:
+
+ void _swrast_Wakeup( GLcontext *ctx );
+
+
+This module tracks state changes internally and maintains derived
+values based on the current state. For this to work, the driver
+ensure the following funciton is called whenever the state changes and
+the swsetup module is 'awake':
+
+ void _swsetup_InvalidateState( GLcontext *ctx, GLuint new_state );
+
+There is no explicit call to put the swsetup module to sleep. Simply
+install other function pointers into all the tnl->Driver.Render.*
+hooks, and (optionally) cease calling _swsetup_InvalidateState().
+
+DRIVER INTERFACE
+
+The module offers a minimal driver interface:
+
+ void (*Start)( GLcontext *ctx );
+ void (*Finish)( GLcontext *ctx );
+
+These are called before and after the completion of all swrast drawing
+activity. As swrast doesn't call callbacks during triangle, line or
+point rasterization, these are necessary to provide locking hooks for
+some drivers. They may otherwise be left null.
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/descrip.mms b/nx-X11/extras/Mesa/src/mesa/swrast_setup/descrip.mms
new file mode 100644
index 000000000..3b8af930c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/descrip.mms
@@ -0,0 +1,39 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+# Last revision : 16 June 2003
+
+.first
+ define gl [---.include.gl]
+ define math [-.math]
+ define tnl [-.tnl]
+ define swrast [-.swrast]
+ define array_cache [-.array_cache]
+
+.include [---]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [---.include],[-.main],[-.glapi]
+LIBDIR = [---.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)
+
+SOURCES = ss_context.c ss_triangle.c
+
+OBJECTS = ss_context.obj,ss_triangle.obj
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+ @ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
+
+clean :
+ purge
+ delete *.obj;*
+
+ss_context.obj : ss_context.c
+ss_triangle.obj : ss_triangle.c
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_context.c b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_context.c
new file mode 100644
index 000000000..c63646ca9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_context.c
@@ -0,0 +1,250 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "imports.h"
+#include "colormac.h"
+#include "ss_context.h"
+#include "ss_triangle.h"
+#include "swrast_setup.h"
+#include "tnl/tnl.h"
+#include "tnl/t_context.h"
+#include "tnl/t_pipeline.h"
+#include "tnl/t_vertex.h"
+
+/* Need to check lighting state and vertex program state to know
+ * if two-sided lighting is in effect.
+ */
+#define _SWSETUP_NEW_RENDERINDEX (_NEW_POLYGON|_NEW_LIGHT|_NEW_PROGRAM)
+
+
+GLboolean
+_swsetup_CreateContext( GLcontext *ctx )
+{
+ SScontext *swsetup = (SScontext *)CALLOC(sizeof(SScontext));
+
+ if (!swsetup)
+ return GL_FALSE;
+
+ ctx->swsetup_context = swsetup;
+
+ swsetup->NewState = ~0;
+ _swsetup_trifuncs_init( ctx );
+
+ _tnl_init_vertices( ctx, ctx->Const.MaxArrayLockSize + 12,
+ sizeof(SWvertex) );
+
+
+ return GL_TRUE;
+}
+
+void
+_swsetup_DestroyContext( GLcontext *ctx )
+{
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+
+ if (swsetup) {
+ FREE(swsetup);
+ ctx->swsetup_context = 0;
+ }
+
+ _tnl_free_vertices( ctx );
+}
+
+static void
+_swsetup_RenderPrimitive( GLcontext *ctx, GLenum mode )
+{
+ SWSETUP_CONTEXT(ctx)->render_prim = mode;
+ _swrast_render_primitive( ctx, mode );
+}
+
+#define SWZ ((SWvertex *)0)
+#define SWOffset(MEMBER) (((char *)&(SWZ->MEMBER)) - ((char *)SWZ))
+
+#define EMIT_ATTR( ATTR, STYLE, MEMBER ) \
+do { \
+ map[e].attrib = (ATTR); \
+ map[e].format = (STYLE); \
+ map[e].offset = SWOffset(MEMBER); \
+ e++; \
+} while (0)
+
+
+/*
+ * We patch this function into tnl->Driver.Render.Start.
+ * It's called when we start rendering a vertex buffer.
+ */
+static void
+_swsetup_RenderStart( GLcontext *ctx )
+{
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint new_state = swsetup->NewState;
+
+ if (new_state & _SWSETUP_NEW_RENDERINDEX) {
+ _swsetup_choose_trifuncs( ctx );
+ }
+
+ swsetup->NewState = 0;
+
+ _swrast_render_start( ctx );
+
+ /* Important:
+ */
+ VB->AttribPtr[VERT_ATTRIB_POS] = VB->NdcPtr;
+
+
+ if (tnl->render_inputs != swsetup->last_index) {
+ GLuint index = tnl->render_inputs;
+ struct tnl_attr_map map[_TNL_ATTRIB_MAX];
+ int i, e = 0;
+
+ EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, win );
+
+ if (index & _TNL_BIT_COLOR0)
+ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4CHAN_4F_RGBA, color );
+
+ if (index & _TNL_BIT_COLOR1)
+ EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4CHAN_4F_RGBA, specular);
+
+ if (index & _TNL_BIT_FOG)
+ EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1F, fog);
+
+ if (index & _TNL_BITS_TEX_ANY) {
+ for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
+ if (index & _TNL_BIT_TEX(i)) {
+ EMIT_ATTR( _TNL_ATTRIB_TEX0+i, EMIT_4F, texcoord[i] );
+ }
+ }
+ }
+
+ if (index & _TNL_BIT_INDEX)
+ EMIT_ATTR( _TNL_ATTRIB_INDEX, EMIT_1F, index );
+
+ if (index & _TNL_BIT_POINTSIZE)
+ EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, pointSize );
+
+ _tnl_install_attrs( ctx, map, e,
+ ctx->Viewport._WindowMap.m,
+ sizeof(SWvertex) );
+
+ swsetup->last_index = index;
+ }
+
+}
+
+/*
+ * We patch this function into tnl->Driver.Render.Finish.
+ * It's called when we finish rendering a vertex buffer.
+ */
+static void
+_swsetup_RenderFinish( GLcontext *ctx )
+{
+ _swrast_render_finish( ctx );
+}
+
+void
+_swsetup_InvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+ swsetup->NewState |= new_state;
+ _tnl_invalidate_vertex_state( ctx, new_state );
+}
+
+
+void
+_swsetup_Wakeup( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+
+ tnl->Driver.Render.Start = _swsetup_RenderStart;
+ tnl->Driver.Render.Finish = _swsetup_RenderFinish;
+ tnl->Driver.Render.PrimitiveNotify = _swsetup_RenderPrimitive;
+ tnl->Driver.Render.Interp = _tnl_interp;
+ tnl->Driver.Render.CopyPV = _tnl_copy_pv;
+ tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon; /* new */
+ tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine; /* new */
+ /* points */
+ /* line */
+ /* triangle */
+ /* quad */
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = _tnl_build_vertices;
+ tnl->Driver.Render.Multipass = 0;
+
+ _tnl_invalidate_vertices( ctx, ~0 );
+ _tnl_need_projected_coords( ctx, GL_TRUE );
+ _swsetup_InvalidateState( ctx, ~0 );
+
+ swsetup->verts = (SWvertex *)tnl->clipspace.vertex_buf;
+ swsetup->last_index = 0;
+}
+
+
+
+
+
+/* Populate a swrast SWvertex from an attrib-style vertex.
+ */
+void
+_swsetup_Translate( GLcontext *ctx, const void *vertex, SWvertex *dest )
+{
+ const GLfloat *m = ctx->Viewport._WindowMap.m;
+ GLfloat tmp[4];
+ GLuint i;
+
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_POS, tmp );
+
+ dest->win[0] = m[0] * tmp[0] + m[12];
+ dest->win[1] = m[5] * tmp[1] + m[13];
+ dest->win[2] = m[10] * tmp[2] + m[14];
+ dest->win[3] = tmp[3];
+
+
+ for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_TEX0+i, dest->texcoord[i] );
+
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR0, tmp );
+ UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->color, tmp );
+
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_COLOR1, tmp );
+ UNCLAMPED_FLOAT_TO_RGBA_CHAN( dest->specular, tmp );
+
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_FOG, tmp );
+ dest->fog = tmp[0];
+
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_INDEX, tmp );
+ dest->index = (GLuint) tmp[0];
+
+ _tnl_get_attr( ctx, vertex, _TNL_ATTRIB_POINTSIZE, tmp );
+ dest->pointSize = tmp[0];
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_context.h b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_context.h
new file mode 100644
index 000000000..2c6e4faf3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_context.h
@@ -0,0 +1,45 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.1
+ *
+ * Copyright (C) 1999-2002 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef SS_CONTEXT_H
+#define SS_CONTEXT_H
+
+#include "mtypes.h"
+#include "swrast/swrast.h"
+#include "swrast_setup.h"
+
+typedef struct {
+ GLuint NewState;
+ GLenum render_prim;
+ GLuint last_index;
+ SWvertex *verts;
+} SScontext;
+
+#define SWSETUP_CONTEXT(ctx) ((SScontext *)ctx->swsetup_context)
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_triangle.c b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_triangle.c
new file mode 100644
index 000000000..d37bdf71c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_triangle.c
@@ -0,0 +1,314 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "colormac.h"
+#include "macros.h"
+#include "mtypes.h"
+
+#include "tnl/t_context.h"
+
+#include "ss_triangle.h"
+#include "ss_context.h"
+
+#define SS_RGBA_BIT 0x1
+#define SS_OFFSET_BIT 0x2
+#define SS_TWOSIDE_BIT 0x4
+#define SS_UNFILLED_BIT 0x8
+#define SS_MAX_TRIFUNC 0x10
+
+static tnl_triangle_func tri_tab[SS_MAX_TRIFUNC];
+static tnl_quad_func quad_tab[SS_MAX_TRIFUNC];
+
+
+static void _swsetup_render_line_tri( GLcontext *ctx,
+ GLuint e0, GLuint e1, GLuint e2,
+ GLuint facing )
+{
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLubyte *ef = VB->EdgeFlag;
+ SWvertex *verts = swsetup->verts;
+ SWvertex *v0 = &verts[e0];
+ SWvertex *v1 = &verts[e1];
+ SWvertex *v2 = &verts[e2];
+ GLchan c[2][4];
+ GLchan s[2][4];
+ GLfloat i[2];
+
+ /* cull testing */
+ if (ctx->Polygon.CullFlag) {
+ if (facing == 1 && ctx->Polygon.CullFaceMode != GL_FRONT)
+ return;
+ if (facing == 0 && ctx->Polygon.CullFaceMode != GL_BACK)
+ return;
+ }
+
+ if (ctx->Light.ShadeModel == GL_FLAT) {
+ COPY_CHAN4(c[0], v0->color);
+ COPY_CHAN4(c[1], v1->color);
+ COPY_CHAN4(s[0], v0->specular);
+ COPY_CHAN4(s[1], v1->specular);
+ i[0] = v0->index;
+ i[1] = v1->index;
+
+ COPY_CHAN4(v0->color, v2->color);
+ COPY_CHAN4(v1->color, v2->color);
+ COPY_CHAN4(v0->specular, v2->specular);
+ COPY_CHAN4(v1->specular, v2->specular);
+ v0->index = v2->index;
+ v1->index = v2->index;
+ }
+
+ if (swsetup->render_prim == GL_POLYGON) {
+ if (ef[e2]) _swrast_Line( ctx, v2, v0 );
+ if (ef[e0]) _swrast_Line( ctx, v0, v1 );
+ if (ef[e1]) _swrast_Line( ctx, v1, v2 );
+ } else {
+ if (ef[e0]) _swrast_Line( ctx, v0, v1 );
+ if (ef[e1]) _swrast_Line( ctx, v1, v2 );
+ if (ef[e2]) _swrast_Line( ctx, v2, v0 );
+ }
+
+ if (ctx->Light.ShadeModel == GL_FLAT) {
+ COPY_CHAN4(v0->color, c[0]);
+ COPY_CHAN4(v1->color, c[1]);
+ COPY_CHAN4(v0->specular, s[0]);
+ COPY_CHAN4(v1->specular, s[1]);
+ v0->index = i[0];
+ v1->index = i[1];
+ }
+}
+
+static void _swsetup_render_point_tri( GLcontext *ctx,
+ GLuint e0, GLuint e1, GLuint e2,
+ GLuint facing )
+{
+ SScontext *swsetup = SWSETUP_CONTEXT(ctx);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLubyte *ef = VB->EdgeFlag;
+ SWvertex *verts = swsetup->verts;
+ SWvertex *v0 = &verts[e0];
+ SWvertex *v1 = &verts[e1];
+ SWvertex *v2 = &verts[e2];
+ GLchan c[2][4];
+ GLchan s[2][4];
+ GLfloat i[2];
+
+ /* cull testing */
+ if (ctx->Polygon.CullFlag) {
+ if (facing == 1 && ctx->Polygon.CullFaceMode != GL_FRONT)
+ return;
+ if (facing == 0 && ctx->Polygon.CullFaceMode != GL_BACK)
+ return;
+ }
+
+ if (ctx->Light.ShadeModel == GL_FLAT) {
+ /* save colors/indexes for v0, v1 vertices */
+ COPY_CHAN4(c[0], v0->color);
+ COPY_CHAN4(c[1], v1->color);
+ COPY_CHAN4(s[0], v0->specular);
+ COPY_CHAN4(s[1], v1->specular);
+ i[0] = v0->index;
+ i[1] = v1->index;
+
+ /* copy v2 color/indexes to v0, v1 indexes */
+ COPY_CHAN4(v0->color, v2->color);
+ COPY_CHAN4(v1->color, v2->color);
+ COPY_CHAN4(v0->specular, v2->specular);
+ COPY_CHAN4(v1->specular, v2->specular);
+ v0->index = v2->index;
+ v1->index = v2->index;
+ }
+
+ if (ef[e0]) _swrast_Point( ctx, v0 );
+ if (ef[e1]) _swrast_Point( ctx, v1 );
+ if (ef[e2]) _swrast_Point( ctx, v2 );
+
+ if (ctx->Light.ShadeModel == GL_FLAT) {
+ /* restore v0, v1 colores/indexes */
+ COPY_CHAN4(v0->color, c[0]);
+ COPY_CHAN4(v1->color, c[1]);
+ COPY_CHAN4(v0->specular, s[0]);
+ COPY_CHAN4(v1->specular, s[1]);
+ v0->index = i[0];
+ v1->index = i[1];
+ }
+ _swrast_flush(ctx);
+}
+
+#define SS_COLOR(a,b) UNCLAMPED_FLOAT_TO_RGBA_CHAN(a,b)
+#define SS_SPEC(a,b) UNCLAMPED_FLOAT_TO_RGB_CHAN(a,b)
+#define SS_IND(a,b) (a = b)
+
+#define IND (0)
+#define TAG(x) x
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT)
+#define TAG(x) x##_offset
+#include "ss_tritmp.h"
+
+#define IND (SS_TWOSIDE_BIT)
+#define TAG(x) x##_twoside
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT)
+#define TAG(x) x##_offset_twoside
+#include "ss_tritmp.h"
+
+#define IND (SS_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "ss_tritmp.h"
+
+#define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT)
+#define TAG(x) x##_offset_twoside_unfilled
+#include "ss_tritmp.h"
+
+#define IND (0|SS_RGBA_BIT)
+#define TAG(x) x##_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT|SS_RGBA_BIT)
+#define TAG(x) x##_offset_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_TWOSIDE_BIT|SS_RGBA_BIT)
+#define TAG(x) x##_twoside_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_RGBA_BIT)
+#define TAG(x) x##_offset_twoside_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_UNFILLED_BIT|SS_RGBA_BIT)
+#define TAG(x) x##_unfilled_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
+#define TAG(x) x##_offset_unfilled_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
+#define TAG(x) x##_twoside_unfilled_rgba
+#include "ss_tritmp.h"
+
+#define IND (SS_OFFSET_BIT|SS_TWOSIDE_BIT|SS_UNFILLED_BIT|SS_RGBA_BIT)
+#define TAG(x) x##_offset_twoside_unfilled_rgba
+#include "ss_tritmp.h"
+
+
+void _swsetup_trifuncs_init( GLcontext *ctx )
+{
+ (void) ctx;
+
+ init();
+ init_offset();
+ init_twoside();
+ init_offset_twoside();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_offset_twoside_unfilled();
+
+ init_rgba();
+ init_offset_rgba();
+ init_twoside_rgba();
+ init_offset_twoside_rgba();
+ init_unfilled_rgba();
+ init_offset_unfilled_rgba();
+ init_twoside_unfilled_rgba();
+ init_offset_twoside_unfilled_rgba();
+}
+
+
+static void swsetup_points( GLcontext *ctx, GLuint first, GLuint last )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts;
+ GLuint i;
+
+ if (VB->Elts) {
+ for (i = first; i < last; i++)
+ if (VB->ClipMask[VB->Elts[i]] == 0)
+ _swrast_Point( ctx, &verts[VB->Elts[i]] );
+ }
+ else {
+ for (i = first; i < last; i++)
+ if (VB->ClipMask[i] == 0)
+ _swrast_Point( ctx, &verts[i] );
+ }
+}
+
+static void swsetup_line( GLcontext *ctx, GLuint v0, GLuint v1 )
+{
+ SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts;
+ _swrast_Line( ctx, &verts[v0], &verts[v1] );
+}
+
+
+
+void _swsetup_choose_trifuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint ind = 0;
+
+ if (ctx->Polygon.OffsetPoint ||
+ ctx->Polygon.OffsetLine ||
+ ctx->Polygon.OffsetFill)
+ ind |= SS_OFFSET_BIT;
+
+ if ((ctx->Light.Enabled && ctx->Light.Model.TwoSide) ||
+ (ctx->VertexProgram._Enabled && ctx->VertexProgram.TwoSideEnabled))
+ ind |= SS_TWOSIDE_BIT;
+
+ /* We piggyback the two-sided stencil front/back determination on the
+ * unfilled triangle path.
+ */
+ if (ctx->Polygon.FrontMode != GL_FILL ||
+ ctx->Polygon.BackMode != GL_FILL ||
+ (ctx->Stencil.Enabled && ctx->Stencil.TestTwoSide))
+ ind |= SS_UNFILLED_BIT;
+
+ if (ctx->Visual.rgbMode)
+ ind |= SS_RGBA_BIT;
+
+ tnl->Driver.Render.Triangle = tri_tab[ind];
+ tnl->Driver.Render.Quad = quad_tab[ind];
+ tnl->Driver.Render.Line = swsetup_line;
+ tnl->Driver.Render.Points = swsetup_points;
+
+ ctx->_Facing = 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_triangle.h b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_triangle.h
new file mode 100644
index 000000000..78833269e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_triangle.h
@@ -0,0 +1,39 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef SS_TRIANGLE_H
+#define SS_TRIANGLE_H
+
+#include "mtypes.h"
+#include "ss_context.h"
+
+
+void _swsetup_trifuncs_init( GLcontext *ctx );
+void _swsetup_choose_trifuncs( GLcontext *ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_tritmp.h b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_tritmp.h
new file mode 100644
index 000000000..61c9b2817
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_tritmp.h
@@ -0,0 +1,222 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+static void TAG(triangle)(GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ SWvertex *verts = SWSETUP_CONTEXT(ctx)->verts;
+ SWvertex *v[3];
+ GLfloat z[3];
+ GLfloat offset;
+ GLenum mode = GL_FILL;
+ GLuint facing = 0;
+ GLchan saved_color[3][4];
+ GLchan saved_spec[3][4];
+ GLfloat saved_index[3];
+
+ v[0] = &verts[e0];
+ v[1] = &verts[e1];
+ v[2] = &verts[e2];
+
+
+ if (IND & (SS_TWOSIDE_BIT | SS_OFFSET_BIT | SS_UNFILLED_BIT))
+ {
+ GLfloat ex = v[0]->win[0] - v[2]->win[0];
+ GLfloat ey = v[0]->win[1] - v[2]->win[1];
+ GLfloat fx = v[1]->win[0] - v[2]->win[0];
+ GLfloat fy = v[1]->win[1] - v[2]->win[1];
+ GLfloat cc = ex*fy - ey*fx;
+
+ if (IND & (SS_TWOSIDE_BIT | SS_UNFILLED_BIT))
+ {
+ facing = (cc < 0.0) ^ ctx->Polygon._FrontBit;
+ if (ctx->Stencil.TestTwoSide)
+ ctx->_Facing = facing; /* for 2-sided stencil test */
+
+ if (IND & SS_UNFILLED_BIT)
+ mode = facing ? ctx->Polygon.BackMode : ctx->Polygon.FrontMode;
+
+ if (facing == 1) {
+ if (IND & SS_TWOSIDE_BIT) {
+ if (IND & SS_RGBA_BIT) {
+ GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data;
+
+ COPY_CHAN4(saved_color[0], v[0]->color);
+ COPY_CHAN4(saved_color[1], v[1]->color);
+ COPY_CHAN4(saved_color[2], v[2]->color);
+
+ if (VB->ColorPtr[1]->stride) {
+ SS_COLOR(v[0]->color, vbcolor[e0]);
+ SS_COLOR(v[1]->color, vbcolor[e1]);
+ SS_COLOR(v[2]->color, vbcolor[e2]);
+ }
+ else {
+ SS_COLOR(v[0]->color, vbcolor[0]);
+ SS_COLOR(v[1]->color, vbcolor[0]);
+ SS_COLOR(v[2]->color, vbcolor[0]);
+ }
+
+ if (VB->SecondaryColorPtr[1]) {
+ GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;
+
+ COPY_CHAN4(saved_spec[0], v[0]->specular);
+ COPY_CHAN4(saved_spec[1], v[1]->specular);
+ COPY_CHAN4(saved_spec[2], v[2]->specular);
+
+ if (VB->SecondaryColorPtr[1]->stride) {
+ SS_SPEC(v[0]->specular, vbspec[e0]);
+ SS_SPEC(v[1]->specular, vbspec[e1]);
+ SS_SPEC(v[2]->specular, vbspec[e2]);
+ }
+ else {
+ SS_SPEC(v[0]->specular, vbspec[0]);
+ SS_SPEC(v[1]->specular, vbspec[0]);
+ SS_SPEC(v[2]->specular, vbspec[0]);
+ }
+ }
+ } else {
+ GLfloat *vbindex = (GLfloat *)VB->IndexPtr[1]->data;
+ saved_index[0] = v[0]->index;
+ saved_index[1] = v[1]->index;
+ saved_index[2] = v[2]->index;
+
+ SS_IND(v[0]->index, (GLuint) vbindex[e0]);
+ SS_IND(v[1]->index, (GLuint) vbindex[e1]);
+ SS_IND(v[2]->index, (GLuint) vbindex[e2]);
+ }
+ }
+ }
+ }
+
+ if (IND & SS_OFFSET_BIT)
+ {
+ offset = ctx->Polygon.OffsetUnits * ctx->DrawBuffer->_MRD;
+ z[0] = v[0]->win[2];
+ z[1] = v[1]->win[2];
+ z[2] = v[2]->win[2];
+ if (cc * cc > 1e-16) {
+ const GLfloat ez = z[0] - z[2];
+ const GLfloat fz = z[1] - z[2];
+ const GLfloat oneOverArea = 1.0F / cc;
+ const GLfloat dzdx = FABSF((ey * fz - ez * fy) * oneOverArea);
+ const GLfloat dzdy = FABSF((ez * fx - ex * fz) * oneOverArea);
+ offset += MAX2(dzdx, dzdy) * ctx->Polygon.OffsetFactor;
+ /* Unfortunately, we need to clamp to prevent negative Zs below.
+ * Technically, we should do the clamping per-fragment.
+ */
+ offset = MAX2(offset, -v[0]->win[2]);
+ offset = MAX2(offset, -v[1]->win[2]);
+ offset = MAX2(offset, -v[2]->win[2]);
+ }
+ }
+ }
+
+ if (mode == GL_POINT) {
+ if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetPoint) {
+ v[0]->win[2] += offset;
+ v[1]->win[2] += offset;
+ v[2]->win[2] += offset;
+ }
+ _swsetup_render_point_tri( ctx, e0, e1, e2, facing );
+ } else if (mode == GL_LINE) {
+ if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetLine) {
+ v[0]->win[2] += offset;
+ v[1]->win[2] += offset;
+ v[2]->win[2] += offset;
+ }
+ _swsetup_render_line_tri( ctx, e0, e1, e2, facing );
+ } else {
+ if ((IND & SS_OFFSET_BIT) && ctx->Polygon.OffsetFill) {
+ v[0]->win[2] += offset;
+ v[1]->win[2] += offset;
+ v[2]->win[2] += offset;
+ }
+ _swrast_Triangle( ctx, v[0], v[1], v[2] );
+ }
+
+ if (IND & SS_OFFSET_BIT) {
+ v[0]->win[2] = z[0];
+ v[1]->win[2] = z[1];
+ v[2]->win[2] = z[2];
+ }
+
+ if (IND & SS_TWOSIDE_BIT) {
+ if (facing == 1) {
+ if (IND & SS_RGBA_BIT) {
+ COPY_CHAN4(v[0]->color, saved_color[0]);
+ COPY_CHAN4(v[1]->color, saved_color[1]);
+ COPY_CHAN4(v[2]->color, saved_color[2]);
+ if (VB->SecondaryColorPtr[1]) {
+ COPY_CHAN4(v[0]->specular, saved_spec[0]);
+ COPY_CHAN4(v[1]->specular, saved_spec[1]);
+ COPY_CHAN4(v[2]->specular, saved_spec[2]);
+ }
+ } else {
+ v[0]->index = saved_index[0];
+ v[1]->index = saved_index[1];
+ v[2]->index = saved_index[2];
+ }
+ }
+ }
+}
+
+
+
+/* Need to fixup edgeflags when decomposing to triangles:
+ */
+static void TAG(quadfunc)( GLcontext *ctx, GLuint v0,
+ GLuint v1, GLuint v2, GLuint v3 )
+{
+ if (IND & SS_UNFILLED_BIT) {
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLubyte ef1 = VB->EdgeFlag[v1];
+ GLubyte ef3 = VB->EdgeFlag[v3];
+ VB->EdgeFlag[v1] = 0;
+ TAG(triangle)( ctx, v0, v1, v3 );
+ VB->EdgeFlag[v1] = ef1;
+ VB->EdgeFlag[v3] = 0;
+ TAG(triangle)( ctx, v1, v2, v3 );
+ VB->EdgeFlag[v3] = ef3;
+ } else {
+ TAG(triangle)( ctx, v0, v1, v3 );
+ TAG(triangle)( ctx, v1, v2, v3 );
+ }
+}
+
+
+
+
+static void TAG(init)( void )
+{
+ tri_tab[IND] = TAG(triangle);
+ quad_tab[IND] = TAG(quadfunc);
+}
+
+
+#undef IND
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_vb.h b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_vb.h
new file mode 100644
index 000000000..6ea0cb1a7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/ss_vb.h
@@ -0,0 +1,38 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef SS_VB_H
+#define SS_VB_H
+
+#include "mtypes.h"
+#include "swrast_setup.h"
+
+void _swsetup_vb_init( GLcontext *ctx );
+void _swsetup_choose_rastersetup_func( GLcontext *ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/swrast_setup/swrast_setup.h b/nx-X11/extras/Mesa/src/mesa/swrast_setup/swrast_setup.h
new file mode 100644
index 000000000..5dcbe2675
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/swrast_setup/swrast_setup.h
@@ -0,0 +1,61 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+/* Public interface to the swrast_setup module. This module provides
+ * an implementation of the driver interface to t_vb_render.c, and uses
+ * the software rasterizer (swrast) to perform actual rasterization.
+ *
+ * The internals of the implementation are private, but can be hooked
+ * into tnl at any time (except between RenderStart/RenderEnd) by
+ * calling _swsetup_Wakeup().
+ */
+
+#ifndef SWRAST_SETUP_H
+#define SWRAST_SETUP_H
+
+#include "swrast/swrast.h"
+
+extern GLboolean
+_swsetup_CreateContext( GLcontext *ctx );
+
+extern void
+_swsetup_DestroyContext( GLcontext *ctx );
+
+extern void
+_swsetup_InvalidateState( GLcontext *ctx, GLuint new_state );
+
+extern void
+_swsetup_Wakeup( GLcontext *ctx );
+
+/* Helper function to translate a hardware vertex (as understood by
+ * the tnl/t_vertex.c code) to a swrast vertex.
+ */
+extern void
+_swsetup_Translate( GLcontext *ctx, const void *vertex, SWvertex *dest );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/NOTES b/nx-X11/extras/Mesa/src/mesa/tnl/NOTES
new file mode 100644
index 000000000..c39b43485
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/NOTES
@@ -0,0 +1,102 @@
+INTRODUCTION
+
+A generic, configurable software implementation of GL transformation &
+lighting.
+
+This module provides an implementation of the routines required by the
+'vtxfmt' mechanism of core mesa for tnl functionality in all
+combinations of compile and execute modes.
+
+Most current drivers use the tnl module exclusively to provide this
+functionality, though there is an experimental alternate
+implementation provided by the tnl_dd/t_dd_imm_* files which can
+handle a small subset of GL states in execute mode only.
+
+
+STATE
+
+To create and destroy the module:
+
+ GLboolean _tnl_CreateContext( GLcontext *ctx );
+ void _tnl_DestroyContext( GLcontext *ctx );
+
+The module is not active by default, and must be installed by calling
+_tnl_Wakeup(). This function installs internal tnl functions into all
+the vtxfmt dispatch hooks, thus taking over the task of transformation
+and lighting entirely:
+
+ void _tnl_wakeup_exec( GLcontext *ctx );
+ void _tnl_wakeup_save_exec( GLcontext *ctx );
+
+
+This module tracks state changes internally and maintains derived
+values based on the current state. For this to work, the driver
+ensure the following funciton is called whenever the state changes and
+the swsetup module is 'awake':
+
+ void _tnl_InvalidateState( GLcontext *ctx, GLuint new_state );
+
+There is no explicit call to put the tnl module to sleep. Simply
+install other function pointers into all the vtxfmt dispatch slots,
+and (optionally) cease calling _tnl_InvalidateState().
+
+CUSTOMIZATION
+
+The module provides customizability through several mechanisms. The
+most important is by allowing drivers to specify the pipeline through
+which vertex data is passed, including its eventual transfer to
+rasterization hardware (or software).
+
+The default pipeline is specified in t_pipeline.c, and is usually a
+starting point for driver pipelines. Some drivers will remove a stage
+where hardware provides support for the implemented operation (for
+instance fog where per-pixel hardware fog is available, as in the dri
+tdfx driver), or add stages to shortcircuit latter operations (for
+example taking advantage of hardware support for strips and other
+higher-level primitives (for example the radeon driver).
+
+In addition, the following functions provide further tweaks:
+
+extern void
+_tnl_need_projected_coords( GLcontext *ctx, GLboolean flag );
+
+ - Direct the default vertex transformation stage to
+ produce/not produce projected clip coordinates.
+
+extern void
+_tnl_need_dlist_loopback( GLcontext *ctx, GLboolean flag );
+
+ - Direct the display list component of the tnl module to
+ replay display lists as 'glVertex' type calls, rather than
+ passing the display list data directly into the tnl pipeline
+ mechanism.
+
+ This allows display lists to be replayed by the tnl module
+ even when the module is not strictly active.
+
+
+extern void
+_tnl_need_dlist_norm_lengths( GLcontext *ctx, GLboolean flag );
+
+ - Direct the display list component to enable/disable caching
+ 1/length values for display list normals. Doing so is
+ ususally helpful when lighting is performed in software, but
+ wasteful otherwise.
+
+
+DRIVER INTERFACE
+
+The module itself offers a minimal driver interface:
+
+ void (*RunPipeline)( GLcontext *ctx );
+
+Normally this is set to _tnl_RunPipeline(), however the driver can use
+this hook to wrap checks or other code around this call.
+
+In addition, the driver interface for the default render pipeline
+stage is housed in the tnl context struct (this could be cleaner).
+
+
+RENDER DRIVER INTERFACE
+
+See t_context.h for the definition and explanation of this. \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/descrip.mms b/nx-X11/extras/Mesa/src/mesa/tnl/descrip.mms
new file mode 100644
index 000000000..a77d66ca3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/descrip.mms
@@ -0,0 +1,74 @@
+# Makefile for core library for VMS
+# contributed by Jouk Jansen joukj@hrem.stm.tudelft.nl
+# Last revision : 13 June 2005
+
+.first
+ define gl [---.include.gl]
+ define math [-.math]
+ define shader [-.shader]
+ define array_cache [-.array_cache]
+
+.include [---]mms-config.
+
+##### MACROS #####
+
+VPATH = RCS
+
+INCDIR = [---.include],[-.main],[-.glapi],[-.shader]
+LIBDIR = [---.lib]
+CFLAGS = /include=($(INCDIR),[])/define=(PTHREADS=1)/name=(as_is,short)
+
+SOURCES = t_array_api.c t_array_import.c t_context.c \
+ t_pipeline.c t_vb_fog.c t_save_api.c t_vtx_api.c \
+ t_vb_light.c t_vb_normals.c t_vb_points.c t_vb_program.c \
+ t_vb_render.c t_vb_texgen.c t_vb_texmat.c t_vb_vertex.c \
+ t_vtx_eval.c t_vtx_exec.c t_save_playback.c t_save_loopback.c \
+ t_vertex.c t_vtx_generic.c t_vtx_x86.c t_vertex_generic.c \
+ t_vb_arbprogram.c t_vp_build.c
+
+OBJECTS = t_array_api.obj,t_array_import.obj,t_context.obj,\
+ t_pipeline.obj,t_vb_fog.obj,t_vb_light.obj,t_vb_normals.obj,\
+ t_vb_points.obj,t_vb_program.obj,t_vb_render.obj,t_vb_texgen.obj,\
+ t_vb_texmat.obj,t_vb_vertex.obj,t_save_api.obj,t_vtx_api.obj,\
+ t_vtx_eval.obj,t_vtx_exec.obj,t_save_playback.obj,t_save_loopback.obj,\
+ t_vertex.obj,t_vtx_generic.obj,t_vtx_x86.obj,t_vertex_generic.obj,\
+ t_vb_arbprogram.obj,t_vp_build.obj
+
+##### RULES #####
+
+VERSION=Mesa V3.4
+
+##### TARGETS #####
+# Make the library
+$(LIBDIR)$(GL_LIB) : $(OBJECTS)
+ @ library $(LIBDIR)$(GL_LIB) $(OBJECTS)
+
+clean :
+ purge
+ delete *.obj;*
+
+t_array_api.obj : t_array_api.c
+t_array_import.obj : t_array_import.c
+t_context.obj : t_context.c
+t_pipeline.obj : t_pipeline.c
+t_vb_fog.obj : t_vb_fog.c
+t_vb_light.obj : t_vb_light.c
+t_vb_normals.obj : t_vb_normals.c
+t_vb_points.obj : t_vb_points.c
+t_vb_program.obj : t_vb_program.c
+t_vb_render.obj : t_vb_render.c
+t_vb_texgen.obj : t_vb_texgen.c
+t_vb_texmat.obj : t_vb_texmat.c
+t_vb_vertex.obj : t_vb_vertex.c
+t_save_api.obj : t_save_api.c
+t_vtx_api.obj : t_vtx_api.c
+t_vtx_eval.obj : t_vtx_eval.c
+t_vtx_exec.obj : t_vtx_exec.c
+t_save_playback.obj : t_save_playback.c
+t_save_loopback.obj : t_save_loopback.c
+t_vertex.obj : t_vertex.c
+t_vtx_x86.obj : t_vtx_x86.c
+t_vtx_generic.obj : t_vtx_generic.c
+t_vertex_generic.obj : t_vertex_generic.c
+t_vb_arbprogram.obj : t_vb_arbprogram.c
+t_vp_build.obj : t_vp_build.c
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_array_api.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_array_api.c
new file mode 100644
index 000000000..1ad77c5a9
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_array_api.c
@@ -0,0 +1,414 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file t_array_api.c
+ * \brief Vertex array API functions (glDrawArrays, etc)
+ * \author Keith Whitwell
+ */
+
+#include "glheader.h"
+#include "api_validate.h"
+#include "context.h"
+#include "imports.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "state.h"
+
+#include "array_cache/acache.h"
+
+#include "t_array_api.h"
+#include "t_array_import.h"
+#include "t_save_api.h"
+#include "t_context.h"
+#include "t_pipeline.h"
+#include "dispatch.h"
+
+static void fallback_drawarrays( GLcontext *ctx, GLenum mode, GLint start,
+ GLsizei count )
+{
+ GLint i;
+
+ assert(!ctx->CompileFlag);
+ assert(ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1);
+
+ CALL_Begin(GET_DISPATCH(), (mode));
+ for (i = 0; i < count; i++)
+ CALL_ArrayElement(GET_DISPATCH(), ( start + i ));
+ CALL_End(GET_DISPATCH(), ());
+}
+
+
+static void fallback_drawelements( GLcontext *ctx, GLenum mode, GLsizei count,
+ const GLuint *indices)
+{
+ GLint i;
+
+ assert(!ctx->CompileFlag);
+ assert(ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1);
+
+ /* Here, indices will already reflect the buffer object if active */
+
+ CALL_Begin(GET_DISPATCH(), (mode));
+ for (i = 0 ; i < count ; i++) {
+ CALL_ArrayElement(GET_DISPATCH(), ( indices[i] ));
+ }
+ CALL_End(GET_DISPATCH(), ());
+}
+
+
+/* Note this function no longer takes a 'start' value, the range is
+ * assumed to start at zero. The old trick of subtracting 'start'
+ * from each index won't work if the indices are not in writeable
+ * memory.
+ */
+static void _tnl_draw_range_elements( GLcontext *ctx, GLenum mode,
+ GLuint max_index,
+ GLsizei index_count, GLuint *indices )
+
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct tnl_prim prim;
+ FLUSH_CURRENT( ctx, 0 );
+
+ _tnl_vb_bind_arrays( ctx, 0, max_index );
+
+ tnl->vb.Primitive = &prim;
+ tnl->vb.Primitive[0].mode = mode | PRIM_BEGIN | PRIM_END;
+ tnl->vb.Primitive[0].start = 0;
+ tnl->vb.Primitive[0].count = index_count;
+ tnl->vb.PrimitiveCount = 1;
+
+ tnl->vb.Elts = (GLuint *)indices;
+
+ tnl->Driver.RunPipeline( ctx );
+}
+
+
+
+/**
+ * Called via the GL API dispatcher.
+ */
+void GLAPIENTRY
+_tnl_DrawArrays(GLenum mode, GLint start, GLsizei count)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint thresh = (ctx->Driver.NeedFlush & FLUSH_STORED_VERTICES) ? 30 : 10;
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(NULL, "_tnl_DrawArrays %d %d\n", start, count);
+
+ /* Check arguments, etc.
+ */
+ if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
+ return;
+
+ assert(!ctx->CompileFlag);
+
+ if (!ctx->Array.LockCount && (GLuint) count < thresh) {
+ /* Small primitives: attempt to share a vb (at the expense of
+ * using the immediate interface).
+ */
+ fallback_drawarrays( ctx, mode, start, count );
+ }
+ else if (start >= (GLint) ctx->Array.LockFirst &&
+ start + count <= (GLint)(ctx->Array.LockFirst + ctx->Array.LockCount)) {
+
+ struct tnl_prim prim;
+
+ /* Locked primitives which can fit in a single vertex buffer:
+ */
+ FLUSH_CURRENT( ctx, 0 );
+
+ /* Locked drawarrays. Reuse any previously transformed data.
+ */
+ _tnl_vb_bind_arrays( ctx, ctx->Array.LockFirst,
+ ctx->Array.LockFirst + ctx->Array.LockCount );
+
+ tnl->vb.Primitive = &prim;
+ tnl->vb.Primitive[0].mode = mode | PRIM_BEGIN | PRIM_END;
+ tnl->vb.Primitive[0].start = start;
+ tnl->vb.Primitive[0].count = count;
+ tnl->vb.PrimitiveCount = 1;
+
+ tnl->Driver.RunPipeline( ctx );
+ }
+ else {
+ int bufsz = 256; /* Use a small buffer for cache goodness */
+ int j, nr;
+ int minimum, modulo, skip;
+
+ /* Large primitives requiring decomposition to multiple vertex
+ * buffers:
+ */
+ switch (mode) {
+ case GL_POINTS:
+ minimum = 0;
+ modulo = 1;
+ skip = 0;
+ break;
+ case GL_LINES:
+ minimum = 1;
+ modulo = 2;
+ skip = 1;
+ break;
+ case GL_LINE_STRIP:
+ minimum = 1;
+ modulo = 1;
+ skip = 0;
+ break;
+ case GL_TRIANGLES:
+ minimum = 2;
+ modulo = 3;
+ skip = 2;
+ break;
+ case GL_TRIANGLE_STRIP:
+ minimum = 2;
+ modulo = 1;
+ skip = 0;
+ break;
+ case GL_QUADS:
+ minimum = 3;
+ modulo = 4;
+ skip = 3;
+ break;
+ case GL_QUAD_STRIP:
+ minimum = 3;
+ modulo = 2;
+ skip = 0;
+ break;
+ case GL_LINE_LOOP:
+ case GL_TRIANGLE_FAN:
+ case GL_POLYGON:
+ default:
+ /* Primitives requiring a copied vertex (fan-like primitives)
+ * must use the slow path if they cannot fit in a single
+ * vertex buffer.
+ */
+ if (count <= (GLint) ctx->Const.MaxArrayLockSize) {
+ bufsz = ctx->Const.MaxArrayLockSize;
+ minimum = 0;
+ modulo = 1;
+ skip = 0;
+ }
+ else {
+ fallback_drawarrays( ctx, mode, start, count );
+ return;
+ }
+ }
+
+ FLUSH_CURRENT( ctx, 0 );
+
+ bufsz -= bufsz % modulo;
+ bufsz -= minimum;
+ count += start;
+
+ for (j = start + minimum ; j < count ; j += nr + skip ) {
+
+ struct tnl_prim prim;
+
+ nr = MIN2( bufsz, count - j );
+
+ /* XXX is the last parameter a count or index into the array??? */
+ _tnl_vb_bind_arrays( ctx, j - minimum, j + nr );
+
+ tnl->vb.Primitive = &prim;
+ tnl->vb.Primitive[0].mode = mode;
+
+ if (j == start + minimum)
+ tnl->vb.Primitive[0].mode |= PRIM_BEGIN;
+
+ if (j + nr + skip >= count)
+ tnl->vb.Primitive[0].mode |= PRIM_END;
+
+ tnl->vb.Primitive[0].start = 0;
+ tnl->vb.Primitive[0].count = nr + minimum;
+ tnl->vb.PrimitiveCount = 1;
+
+ tnl->Driver.RunPipeline( ctx );
+ }
+ }
+}
+
+
+/**
+ * Called via the GL API dispatcher.
+ */
+void GLAPIENTRY
+_tnl_DrawRangeElements(GLenum mode,
+ GLuint start, GLuint end,
+ GLsizei count, GLenum type, const GLvoid *indices)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint *ui_indices;
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(NULL, "_tnl_DrawRangeElements %d %d %d\n", start, end, count);
+
+ if (ctx->Array.ElementArrayBufferObj->Name) {
+ /* use indices in the buffer object */
+ if (!ctx->Array.ElementArrayBufferObj->Data) {
+ _mesa_warning(ctx,
+ "DrawRangeElements with empty vertex elements buffer!");
+ return;
+ }
+ /* actual address is the sum of pointers */
+ indices = (const GLvoid *)
+ ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Data,
+ (const GLubyte *) indices);
+ }
+
+ /* Check arguments, etc.
+ */
+ if (!_mesa_validate_DrawRangeElements( ctx, mode, start, end, count,
+ type, indices ))
+ return;
+
+ ui_indices = (GLuint *)_ac_import_elements( ctx, GL_UNSIGNED_INT,
+ count, type, indices );
+
+
+ assert(!ctx->CompileFlag);
+
+ if (ctx->Array.LockCount) {
+ /* Are the arrays already locked? If so we currently have to look
+ * at the whole locked range.
+ */
+
+ if (start == 0 && ctx->Array.LockFirst == 0 &&
+ end < (ctx->Array.LockFirst + ctx->Array.LockCount))
+ _tnl_draw_range_elements( ctx, mode,
+ ctx->Array.LockCount,
+ count, ui_indices );
+ else {
+ fallback_drawelements( ctx, mode, count, ui_indices );
+ }
+ }
+ else if (start == 0 && end < ctx->Const.MaxArrayLockSize) {
+ /* The arrays aren't locked but we can still fit them inside a
+ * single vertexbuffer.
+ */
+ _tnl_draw_range_elements( ctx, mode, end + 1, count, ui_indices );
+ }
+ else {
+ /* Range is too big to optimize:
+ */
+ fallback_drawelements( ctx, mode, count, ui_indices );
+ }
+}
+
+
+
+/**
+ * Called via the GL API dispatcher.
+ */
+void GLAPIENTRY
+_tnl_DrawElements(GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLuint *ui_indices;
+
+ if (MESA_VERBOSE & VERBOSE_API)
+ _mesa_debug(NULL, "_tnl_DrawElements %d\n", count);
+
+ /* Check arguments, etc. */
+ if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices ))
+ return;
+
+ if (ctx->Array.ElementArrayBufferObj->Name) {
+ /* actual address is the sum of pointers */
+ indices = (const GLvoid *)
+ ADD_POINTERS(ctx->Array.ElementArrayBufferObj->Data,
+ (const GLubyte *) indices);
+ }
+
+ ui_indices = (GLuint *)_ac_import_elements( ctx, GL_UNSIGNED_INT,
+ count, type, indices );
+
+ assert(!ctx->CompileFlag);
+
+ if (ctx->Array.LockCount) {
+ if (ctx->Array.LockFirst == 0)
+ _tnl_draw_range_elements( ctx, mode,
+ ctx->Array.LockCount,
+ count, ui_indices );
+ else
+ fallback_drawelements( ctx, mode, count, ui_indices );
+ }
+ else {
+ /* Scan the index list and see if we can use the locked path anyway.
+ */
+ GLuint max_elt = 0;
+ GLint i;
+
+ for (i = 0 ; i < count ; i++)
+ if (ui_indices[i] > max_elt)
+ max_elt = ui_indices[i];
+
+ if (max_elt < ctx->Const.MaxArrayLockSize && /* can we use it? */
+ max_elt < (GLuint) count) /* do we want to use it? */
+ _tnl_draw_range_elements( ctx, mode, max_elt+1, count, ui_indices );
+ else
+ fallback_drawelements( ctx, mode, count, ui_indices );
+ }
+}
+
+
+/**
+ * Initialize context's vertex array fields. Called during T 'n L context
+ * creation.
+ */
+void _tnl_array_init( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct tnl_vertex_arrays *tmp = &tnl->array_inputs;
+ GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->exec_vtxfmt);
+ GLuint i;
+
+ vfmt->DrawArrays = _tnl_DrawArrays;
+ vfmt->DrawElements = _tnl_DrawElements;
+ vfmt->DrawRangeElements = _tnl_DrawRangeElements;
+
+ /* Setup vector pointers that will be used to bind arrays to VB's.
+ */
+ _mesa_vector4f_init( &tmp->Obj, 0, NULL);
+ _mesa_vector4f_init( &tmp->Normal, 0, NULL);
+ _mesa_vector4f_init( &tmp->FogCoord, 0, NULL);
+ _mesa_vector4f_init( &tmp->Index, 0, NULL);
+
+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++)
+ _mesa_vector4f_init( &tmp->TexCoord[i], 0, NULL);
+}
+
+
+/**
+ * Destroy the context's vertex array stuff.
+ * Called during T 'n L context destruction.
+ */
+void _tnl_array_destroy( GLcontext *ctx )
+{
+ (void) ctx;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_array_api.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_array_api.h
new file mode 100644
index 000000000..61d1f696b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_array_api.h
@@ -0,0 +1,46 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _T_VARRAY_H
+#define _T_VARRAY_H
+
+#include "mtypes.h"
+#include "t_context.h"
+
+
+extern void GLAPIENTRY _tnl_DrawArrays(GLenum mode, GLint first, GLsizei count);
+
+extern void GLAPIENTRY _tnl_DrawElements(GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices);
+
+extern void GLAPIENTRY _tnl_DrawRangeElements(GLenum mode, GLuint start,
+ GLuint end, GLsizei count, GLenum type,
+ const GLvoid *indices);
+
+
+extern void _tnl_array_init( GLcontext *ctx );
+extern void _tnl_array_destroy( GLcontext *ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_array_import.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_array_import.c
new file mode 100644
index 000000000..7cc834ffa
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_array_import.c
@@ -0,0 +1,352 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+#include "state.h"
+#include "mtypes.h"
+
+#include "array_cache/acache.h"
+#include "math/m_translate.h"
+
+#include "t_array_import.h"
+#include "t_context.h"
+
+
+static void _tnl_import_vertex( GLcontext *ctx,
+ GLboolean writeable,
+ GLboolean stride )
+{
+ struct gl_client_array *tmp;
+ GLboolean is_writeable = 0;
+ struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
+ const GLubyte *data;
+
+ tmp = _ac_import_vertex(ctx,
+ GL_FLOAT,
+ stride ? 4*sizeof(GLfloat) : 0,
+ 0,
+ writeable,
+ &is_writeable);
+
+ data = tmp->Ptr;
+ inputs->Obj.data = (GLfloat (*)[4]) data;
+ inputs->Obj.start = (GLfloat *) data;
+ inputs->Obj.stride = tmp->StrideB;
+ inputs->Obj.size = tmp->Size;
+}
+
+static void _tnl_import_normal( GLcontext *ctx,
+ GLboolean writeable,
+ GLboolean stride )
+{
+ struct gl_client_array *tmp;
+ GLboolean is_writeable = 0;
+ struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
+ const GLubyte *data;
+
+ tmp = _ac_import_normal(ctx, GL_FLOAT,
+ stride ? 3*sizeof(GLfloat) : 0, writeable,
+ &is_writeable);
+
+ data = tmp->Ptr;
+ inputs->Normal.data = (GLfloat (*)[4]) data;
+ inputs->Normal.start = (GLfloat *) data;
+ inputs->Normal.stride = tmp->StrideB;
+ inputs->Normal.size = 3;
+}
+
+
+static void _tnl_import_color( GLcontext *ctx,
+ GLboolean writeable,
+ GLboolean stride )
+{
+ struct gl_client_array *tmp;
+ GLboolean is_writeable = 0;
+ struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
+ const GLubyte *data;
+
+ tmp = _ac_import_color(ctx,
+ GL_FLOAT,
+ stride ? 4*sizeof(GLfloat) : 0,
+ 4,
+ writeable,
+ &is_writeable);
+
+ data = tmp->Ptr;
+ inputs->Color.data = (GLfloat (*)[4]) data;
+ inputs->Color.start = (GLfloat *) data;
+ inputs->Color.stride = tmp->StrideB;
+ inputs->Color.size = tmp->Size;
+}
+
+
+static void _tnl_import_secondarycolor( GLcontext *ctx,
+ GLboolean writeable,
+ GLboolean stride )
+{
+ struct gl_client_array *tmp;
+ GLboolean is_writeable = 0;
+ struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
+ const GLubyte *data;
+
+ tmp = _ac_import_secondarycolor(ctx,
+ GL_FLOAT,
+ stride ? 4*sizeof(GLfloat) : 0,
+ 4,
+ writeable,
+ &is_writeable);
+
+ data = tmp->Ptr;
+ inputs->SecondaryColor.data = (GLfloat (*)[4]) data;
+ inputs->SecondaryColor.start = (GLfloat *) data;
+ inputs->SecondaryColor.stride = tmp->StrideB;
+ inputs->SecondaryColor.size = tmp->Size;
+}
+
+static void _tnl_import_fogcoord( GLcontext *ctx,
+ GLboolean writeable,
+ GLboolean stride )
+{
+ struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
+ struct gl_client_array *tmp;
+ GLboolean is_writeable = 0;
+ const GLubyte *data;
+
+ tmp = _ac_import_fogcoord(ctx, GL_FLOAT,
+ stride ? sizeof(GLfloat) : 0, writeable,
+ &is_writeable);
+
+ data = tmp->Ptr;
+ inputs->FogCoord.data = (GLfloat (*)[4]) data;
+ inputs->FogCoord.start = (GLfloat *) data;
+ inputs->FogCoord.stride = tmp->StrideB;
+}
+
+static void _tnl_import_index( GLcontext *ctx,
+ GLboolean writeable,
+ GLboolean stride )
+{
+ struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
+ struct gl_client_array *tmp;
+ GLboolean is_writeable = 0;
+ const GLubyte *data;
+
+ tmp = _ac_import_index(ctx, GL_FLOAT,
+ stride ? sizeof(GLfloat) : 0, writeable,
+ &is_writeable);
+
+ data = tmp->Ptr;
+ inputs->Index.data = (GLfloat (*)[4]) data;
+ inputs->Index.start = (GLfloat *) data;
+ inputs->Index.stride = tmp->StrideB;
+}
+
+
+static void _tnl_import_texcoord( GLcontext *ctx,
+ GLuint unit,
+ GLboolean writeable,
+ GLboolean stride )
+{
+ struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
+ struct gl_client_array *tmp;
+ GLboolean is_writeable = 0;
+ const GLubyte *data;
+
+ tmp = _ac_import_texcoord(ctx, unit, GL_FLOAT,
+ stride ? 4 * sizeof(GLfloat) : 0,
+ 0,
+ writeable,
+ &is_writeable);
+
+ data = tmp->Ptr;
+ inputs->TexCoord[unit].data = (GLfloat (*)[4]) data;
+ inputs->TexCoord[unit].start = (GLfloat *) data;
+ inputs->TexCoord[unit].stride = tmp->StrideB;
+ inputs->TexCoord[unit].size = tmp->Size;
+}
+
+
+static void _tnl_import_edgeflag( GLcontext *ctx,
+ GLboolean writeable,
+ GLboolean stride )
+{
+ struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
+ struct gl_client_array *tmp;
+ GLboolean is_writeable = 0;
+ const GLubyte *data;
+ (void) writeable; (void) stride;
+
+ tmp = _ac_import_edgeflag(ctx, GL_UNSIGNED_BYTE,
+ sizeof(GLubyte),
+ 0,
+ &is_writeable);
+
+ data = tmp->Ptr;
+ inputs->EdgeFlag = (GLubyte *) data;
+}
+
+
+
+static void _tnl_import_attrib( GLcontext *ctx,
+ GLuint index,
+ GLboolean writeable,
+ GLboolean stride )
+{
+ struct tnl_vertex_arrays *inputs = &TNL_CONTEXT(ctx)->array_inputs;
+ struct gl_client_array *tmp;
+ GLboolean is_writeable = 0;
+ const GLubyte *data;
+
+ tmp = _ac_import_attrib(ctx, index, GL_FLOAT,
+ stride ? 4 * sizeof(GLfloat) : 0,
+ 4, /* want GLfloat[4] */
+ writeable,
+ &is_writeable);
+
+ data = tmp->Ptr;
+ inputs->Attribs[index].data = (GLfloat (*)[4]) data;
+ inputs->Attribs[index].start = (GLfloat *) data;
+ inputs->Attribs[index].stride = tmp->StrideB;
+ inputs->Attribs[index].size = tmp->Size;
+}
+
+
+static void _tnl_constant_attrib( TNLcontext *tnl,
+ struct tnl_vertex_arrays *tmp,
+ GLuint i )
+{
+ tmp->Attribs[i].count = 1;
+ tmp->Attribs[i].data = (GLfloat (*)[4]) tnl->vtx.current[i];
+ tmp->Attribs[i].start = tnl->vtx.current[i];
+ tmp->Attribs[i].size = 4;
+ tmp->Attribs[i].stride = 0;
+ tnl->vb.AttribPtr[i] = &tmp->Attribs[i];
+}
+
+
+
+void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLint end)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ struct tnl_vertex_arrays *tmp = &tnl->array_inputs;
+ GLuint i, index;
+
+ VB->Count = end - start;
+ VB->Elts = NULL;
+
+ _ac_import_range( ctx, start, end );
+
+ /* When vertex program mode is enabled, the generic vertex program
+ * attribute arrays have priority over the conventional attributes.
+ * Try to use them now.
+ */
+ for (index = 0; index < VERT_ATTRIB_MAX; index++) {
+ /* When vertex program mode is enabled, the generic vertex attribute
+ * arrays have priority over the conventional vertex arrays.
+ */
+ if (ctx->VertexProgram._Enabled
+ && ctx->Array.VertexAttrib[index].Enabled) {
+ /* Use generic attribute array */
+ _tnl_import_attrib( ctx, index, GL_FALSE, GL_TRUE );
+ VB->AttribPtr[index] = &tmp->Attribs[index];
+ }
+ /* use conventional arrays... */
+ else if (index == VERT_ATTRIB_POS) {
+ _tnl_import_vertex( ctx, 0, 0 );
+ tmp->Obj.count = VB->Count;
+ VB->AttribPtr[_TNL_ATTRIB_POS] = &tmp->Obj;
+ }
+ else if (index == VERT_ATTRIB_NORMAL) {
+ _tnl_import_normal( ctx, 0, 0 );
+ tmp->Normal.count = VB->Count;
+ VB->AttribPtr[_TNL_ATTRIB_NORMAL] = &tmp->Normal;
+ }
+ else if (index == VERT_ATTRIB_COLOR0) {
+ _tnl_import_color( ctx, 0, 0 );
+ tmp->Color.count = VB->Count;
+ VB->AttribPtr[_TNL_ATTRIB_COLOR0] = &tmp->Color;
+ }
+ else if (index == VERT_ATTRIB_COLOR1) {
+ _tnl_import_secondarycolor( ctx, 0, 0 );
+ tmp->SecondaryColor.count = VB->Count;
+ VB->AttribPtr[_TNL_ATTRIB_COLOR1] = &tmp->SecondaryColor;
+ }
+ else if (index == VERT_ATTRIB_FOG) {
+ _tnl_import_fogcoord( ctx, 0, 0 );
+ tmp->FogCoord.count = VB->Count;
+ VB->AttribPtr[_TNL_ATTRIB_FOG] = &tmp->FogCoord;
+ }
+ else if (index >= VERT_ATTRIB_TEX0 && index <= VERT_ATTRIB_TEX7) {
+ i = index - VERT_ATTRIB_TEX0;
+ _tnl_import_texcoord( ctx, i, GL_FALSE, GL_FALSE );
+ tmp->TexCoord[i].count = VB->Count;
+ VB->AttribPtr[_TNL_ATTRIB_TEX0 + i] = &tmp->TexCoord[i];
+ }
+ else {
+ _tnl_constant_attrib(tnl, tmp, index);
+ }
+ }
+
+ /* odd-ball vertex attributes */
+ {
+ _tnl_import_index( ctx, 0, 0 );
+ tmp->Index.count = VB->Count;
+ VB->AttribPtr[_TNL_ATTRIB_INDEX] = &tmp->Index;
+ }
+
+ {
+ _tnl_import_edgeflag( ctx, GL_TRUE, sizeof(GLboolean) );
+ VB->EdgeFlag = (GLboolean *) tmp->EdgeFlag;
+ }
+
+ /* These are constant & could be precalculated:
+ */
+ for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT; i < _TNL_ATTRIB_INDEX; i++) {
+ _tnl_constant_attrib(tnl, tmp, i);
+ }
+
+
+ /* Legacy pointers -- remove one day.
+ */
+ VB->ObjPtr = VB->AttribPtr[_TNL_ATTRIB_POS];
+ VB->NormalPtr = VB->AttribPtr[_TNL_ATTRIB_NORMAL];
+ VB->ColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR0];
+ VB->ColorPtr[1] = NULL;
+ VB->IndexPtr[0] = VB->AttribPtr[_TNL_ATTRIB_INDEX];
+ VB->IndexPtr[1] = NULL;
+ VB->SecondaryColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR1];
+ VB->SecondaryColorPtr[1] = NULL;
+ VB->FogCoordPtr = VB->AttribPtr[_TNL_ATTRIB_FOG];
+
+ for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
+ VB->TexCoordPtr[i] = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i];
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_array_import.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_array_import.h
new file mode 100644
index 000000000..39b77641d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_array_import.h
@@ -0,0 +1,36 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _T_ARRAY_IMPORT_H
+#define _T_ARRAY_IMPORT_H
+
+#include "mtypes.h"
+#include "t_context.h"
+
+extern void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLint end );
+
+extern void _tnl_array_import_init( GLcontext *ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_context.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_context.c
new file mode 100644
index 000000000..3be8f8dd3
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_context.c
@@ -0,0 +1,294 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+#include "api_arrayelt.h"
+#include "glheader.h"
+#include "imports.h"
+#include "context.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "dlist.h"
+#include "light.h"
+#include "vtxfmt.h"
+#include "nvfragprog.h"
+
+#include "tnl.h"
+#include "t_array_api.h"
+#include "t_context.h"
+#include "t_pipeline.h"
+#include "t_save_api.h"
+#include "t_vp_build.h"
+#include "t_vtx_api.h"
+
+
+
+void
+_tnl_MakeCurrent( GLcontext *ctx,
+ GLframebuffer *drawBuffer,
+ GLframebuffer *readBuffer )
+{
+ (void) ctx; (void) drawBuffer; (void) readBuffer;
+}
+
+
+static void
+install_driver_callbacks( GLcontext *ctx )
+{
+ ctx->Driver.NewList = _tnl_NewList;
+ ctx->Driver.EndList = _tnl_EndList;
+ ctx->Driver.FlushVertices = _tnl_FlushVertices;
+ ctx->Driver.SaveFlushVertices = _tnl_SaveFlushVertices;
+ ctx->Driver.MakeCurrent = _tnl_MakeCurrent;
+ ctx->Driver.BeginCallList = _tnl_BeginCallList;
+ ctx->Driver.EndCallList = _tnl_EndCallList;
+}
+
+
+
+GLboolean
+_tnl_CreateContext( GLcontext *ctx )
+{
+ TNLcontext *tnl;
+
+ /* Create the TNLcontext structure
+ */
+ ctx->swtnl_context = tnl = (TNLcontext *) CALLOC( sizeof(TNLcontext) );
+
+ if (!tnl) {
+ return GL_FALSE;
+ }
+
+ if (getenv("MESA_CODEGEN"))
+ tnl->AllowCodegen = GL_TRUE;
+
+ /* Initialize the VB.
+ */
+ tnl->vb.Size = ctx->Const.MaxArrayLockSize + MAX_CLIPPED_VERTICES;
+
+
+ /* Initialize tnl state and tnl->vtxfmt.
+ */
+ _tnl_save_init( ctx );
+ _tnl_array_init( ctx );
+ _tnl_vtx_init( ctx );
+
+ if (ctx->_MaintainTnlProgram)
+ _tnl_install_pipeline( ctx, _tnl_vp_pipeline );
+ else
+ _tnl_install_pipeline( ctx, _tnl_default_pipeline );
+
+ /* Initialize the arrayelt helper
+ */
+ if (!_ae_create_context( ctx ))
+ return GL_FALSE;
+
+
+ tnl->NeedNdcCoords = GL_TRUE;
+ tnl->LoopbackDListCassettes = GL_FALSE;
+ tnl->CalcDListNormalLengths = GL_TRUE;
+ tnl->AllowVertexFog = GL_TRUE;
+ tnl->AllowPixelFog = GL_TRUE;
+
+ /* Hook our functions into exec and compile dispatch tables.
+ */
+ _mesa_install_exec_vtxfmt( ctx, &tnl->exec_vtxfmt );
+
+
+ /* Set a few default values in the driver struct.
+ */
+ install_driver_callbacks(ctx);
+ ctx->Driver.NeedFlush = 0;
+ ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END;
+ ctx->Driver.CurrentSavePrimitive = PRIM_UNKNOWN;
+
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.NotifyMaterialChange = _mesa_validate_all_lighting_tables;
+
+ return GL_TRUE;
+}
+
+
+void
+_tnl_DestroyContext( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ _tnl_array_destroy( ctx );
+ _tnl_vtx_destroy( ctx );
+ _tnl_save_destroy( ctx );
+ _tnl_destroy_pipeline( ctx );
+ _ae_destroy_context( ctx );
+
+ _tnl_ProgramCacheDestroy( ctx );
+
+ FREE(tnl);
+ ctx->swtnl_context = NULL;
+}
+
+
+void
+_tnl_InvalidateState( GLcontext *ctx, GLuint new_state )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ if (new_state & (_NEW_HINT)) {
+ ASSERT(tnl->AllowVertexFog || tnl->AllowPixelFog);
+ tnl->_DoVertexFog = (tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST))
+ || !tnl->AllowPixelFog;
+ }
+
+ _ae_invalidate_state(ctx, new_state);
+
+ tnl->pipeline.new_state |= new_state;
+ tnl->vtx.eval.new_state |= new_state;
+
+ /* Calculate tnl->render_inputs:
+ */
+ if (ctx->Visual.rgbMode) {
+ tnl->render_inputs = (_TNL_BIT_POS|
+ _TNL_BIT_COLOR0|
+ (ctx->Texture._EnabledCoordUnits << _TNL_ATTRIB_TEX0));
+
+ if (NEED_SECONDARY_COLOR(ctx))
+ tnl->render_inputs |= _TNL_BIT_COLOR1;
+ }
+ else {
+ tnl->render_inputs |= (_TNL_BIT_POS|_TNL_BIT_INDEX);
+ }
+
+ if (ctx->Fog.Enabled ||
+ (ctx->FragmentProgram._Active &&
+ ctx->FragmentProgram._Current->FogOption != GL_NONE))
+ tnl->render_inputs |= _TNL_BIT_FOG;
+
+ if (ctx->Polygon.FrontMode != GL_FILL ||
+ ctx->Polygon.BackMode != GL_FILL)
+ tnl->render_inputs |= _TNL_BIT_EDGEFLAG;
+
+ if (ctx->RenderMode == GL_FEEDBACK)
+ tnl->render_inputs |= _TNL_BIT_TEX0;
+
+ if (ctx->Point._Attenuated ||
+ (ctx->VertexProgram._Enabled && ctx->VertexProgram.PointSizeEnabled))
+ tnl->render_inputs |= _TNL_BIT_POINTSIZE;
+}
+
+
+void
+_tnl_wakeup_exec( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ install_driver_callbacks(ctx);
+ ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT;
+
+ /* Hook our functions into exec and compile dispatch tables.
+ */
+ _mesa_install_exec_vtxfmt( ctx, &tnl->exec_vtxfmt );
+
+ /* Call all appropriate driver callbacks to revive state.
+ */
+ _tnl_MakeCurrent( ctx, ctx->DrawBuffer, ctx->ReadBuffer );
+
+ /* Assume we haven't been getting state updates either:
+ */
+ _tnl_InvalidateState( ctx, ~0 );
+
+ if (ctx->Light.ColorMaterialEnabled) {
+ _mesa_update_color_material( ctx,
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0] );
+ }
+}
+
+
+void
+_tnl_wakeup_save_exec( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ _tnl_wakeup_exec( ctx );
+ _mesa_install_save_vtxfmt( ctx, &tnl->save_vtxfmt );
+}
+
+
+/**
+ * Drivers call this function to tell the TCL module whether or not
+ * it wants Normalized Device Coords (NDC) computed. I.e. whether
+ * we should "Divide-by-W". Software renders will want that.
+ */
+void
+_tnl_need_projected_coords( GLcontext *ctx, GLboolean mode )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ if (tnl->NeedNdcCoords != mode) {
+ tnl->NeedNdcCoords = mode;
+ _tnl_InvalidateState( ctx, _NEW_PROJECTION );
+ }
+}
+
+void
+_tnl_need_dlist_loopback( GLcontext *ctx, GLboolean mode )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->LoopbackDListCassettes = mode;
+}
+
+void
+_tnl_need_dlist_norm_lengths( GLcontext *ctx, GLboolean mode )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->CalcDListNormalLengths = mode;
+}
+
+void
+_tnl_isolate_materials( GLcontext *ctx, GLboolean mode )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->IsolateMaterials = mode;
+}
+
+void
+_tnl_allow_vertex_fog( GLcontext *ctx, GLboolean value )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->AllowVertexFog = value;
+ tnl->_DoVertexFog = (tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST))
+ || !tnl->AllowPixelFog;
+
+}
+
+void
+_tnl_allow_pixel_fog( GLcontext *ctx, GLboolean value )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->AllowPixelFog = value;
+ tnl->_DoVertexFog = (tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST))
+ || !tnl->AllowPixelFog;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_context.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_context.h
new file mode 100644
index 000000000..9c8f2003b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_context.h
@@ -0,0 +1,806 @@
+/*
+ * mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file t_context.h
+ * \brief TnL module datatypes and definitions.
+ * \author Keith Whitwell
+ */
+
+
+/**
+ * \mainpage The TNL-module
+ *
+ * TNL stands for "transform and lighting", i.e. this module implements
+ * a pipeline that receives as input a buffer of vertices and does all
+ * necessary transformations (rotations, clipping, vertex shader etc.)
+ * and passes then the output to the rasterizer.
+ *
+ * The tnl_pipeline contains the array of all stages, which should be
+ * applied. Each stage is a black-box, which is described by an
+ * tnl_pipeline_stage. The function ::_tnl_run_pipeline applies all the
+ * stages to the vertex_buffer TNLcontext::vb, where the vertex data
+ * is stored. The last stage in the pipeline is the rasterizer.
+ *
+ * The initial vertex_buffer data may either come from an ::immediate
+ * structure or client vertex_arrays or display lists:
+ *
+ *
+ * - The ::immediate structure records all the GL commands issued between
+ * glBegin and glEnd. \n
+ * The structure accumulates data, until it is either full or it is
+ * flushed (usually by a state change). Before starting then the pipeline,
+ * the collected vertex data in ::immediate has to be pushed into
+ * TNLcontext::vb.
+ * This happens in ::_tnl_vb_bind_immediate. The pipeline is then run by
+ * calling tnl_device_driver::RunPipeline = ::_tnl_run_pipeline, which
+ * is stored in TNLcontext::Driver. \n
+ * An ::immediate does (for performance reasons) usually not finish with a
+ * glEnd, and hence it also does not need to start with a glBegin.
+ * This means that the last vertices of one ::immediate may need to be
+ * saved for the next one.
+ *
+ *
+ * - NOT SURE ABOUT THIS: The vertex_arrays structure is used to handle
+ * glDrawArrays etc. \n
+ * Here, the data of the vertex_arrays is copied by ::_tnl_vb_bind_arrays
+ * into TNLcontext::vb, so that the pipeline can be started.
+ */
+
+
+#ifndef _T_CONTEXT_H
+#define _T_CONTEXT_H
+
+#include "glheader.h"
+#include "mtypes.h"
+
+#include "math/m_matrix.h"
+#include "math/m_vector.h"
+#include "math/m_xform.h"
+
+
+#define MAX_PIPELINE_STAGES 30
+
+/*
+ * Note: The first attributes match the VERT_ATTRIB_* definitions
+ * in mtypes.h. However, the tnl module has additional attributes
+ * for materials, color indexes, edge flags, etc.
+ */
+/* Although it's nice to use these as bit indexes in a DWORD flag, we
+ * could manage without if necessary. Another limit currently is the
+ * number of bits allocated for these numbers in places like vertex
+ * program instruction formats and register layouts.
+ */
+enum {
+ _TNL_ATTRIB_POS = 0,
+ _TNL_ATTRIB_WEIGHT = 1,
+ _TNL_ATTRIB_NORMAL = 2,
+ _TNL_ATTRIB_COLOR0 = 3,
+ _TNL_ATTRIB_COLOR1 = 4,
+ _TNL_ATTRIB_FOG = 5,
+ _TNL_ATTRIB_SIX = 6,
+ _TNL_ATTRIB_SEVEN = 7,
+ _TNL_ATTRIB_TEX0 = 8,
+ _TNL_ATTRIB_TEX1 = 9,
+ _TNL_ATTRIB_TEX2 = 10,
+ _TNL_ATTRIB_TEX3 = 11,
+ _TNL_ATTRIB_TEX4 = 12,
+ _TNL_ATTRIB_TEX5 = 13,
+ _TNL_ATTRIB_TEX6 = 14,
+ _TNL_ATTRIB_TEX7 = 15,
+ _TNL_ATTRIB_MAT_FRONT_AMBIENT = 16,
+ _TNL_ATTRIB_MAT_BACK_AMBIENT = 17,
+ _TNL_ATTRIB_MAT_FRONT_DIFFUSE = 18,
+ _TNL_ATTRIB_MAT_BACK_DIFFUSE = 19,
+ _TNL_ATTRIB_MAT_FRONT_SPECULAR = 20,
+ _TNL_ATTRIB_MAT_BACK_SPECULAR = 21,
+ _TNL_ATTRIB_MAT_FRONT_EMISSION = 22,
+ _TNL_ATTRIB_MAT_BACK_EMISSION = 23,
+ _TNL_ATTRIB_MAT_FRONT_SHININESS = 24,
+ _TNL_ATTRIB_MAT_BACK_SHININESS = 25,
+ _TNL_ATTRIB_MAT_FRONT_INDEXES = 26,
+ _TNL_ATTRIB_MAT_BACK_INDEXES = 27,
+ _TNL_ATTRIB_INDEX = 28,
+ _TNL_ATTRIB_EDGEFLAG = 29,
+ _TNL_ATTRIB_POINTSIZE = 30,
+ _TNL_ATTRIB_MAX = 31
+} ;
+
+/* Will probably have to revise this scheme fairly shortly, eg. by
+ * compacting all the MAT flags down to one bit, or by using two
+ * dwords to store the flags.
+ */
+#define _TNL_BIT_POS (1<<0)
+#define _TNL_BIT_WEIGHT (1<<1)
+#define _TNL_BIT_NORMAL (1<<2)
+#define _TNL_BIT_COLOR0 (1<<3)
+#define _TNL_BIT_COLOR1 (1<<4)
+#define _TNL_BIT_FOG (1<<5)
+#define _TNL_BIT_SIX (1<<6)
+#define _TNL_BIT_SEVEN (1<<7)
+#define _TNL_BIT_TEX0 (1<<8)
+#define _TNL_BIT_TEX1 (1<<9)
+#define _TNL_BIT_TEX2 (1<<10)
+#define _TNL_BIT_TEX3 (1<<11)
+#define _TNL_BIT_TEX4 (1<<12)
+#define _TNL_BIT_TEX5 (1<<13)
+#define _TNL_BIT_TEX6 (1<<14)
+#define _TNL_BIT_TEX7 (1<<15)
+#define _TNL_BIT_MAT_FRONT_AMBIENT (1<<16)
+#define _TNL_BIT_MAT_BACK_AMBIENT (1<<17)
+#define _TNL_BIT_MAT_FRONT_DIFFUSE (1<<18)
+#define _TNL_BIT_MAT_BACK_DIFFUSE (1<<19)
+#define _TNL_BIT_MAT_FRONT_SPECULAR (1<<20)
+#define _TNL_BIT_MAT_BACK_SPECULAR (1<<21)
+#define _TNL_BIT_MAT_FRONT_EMISSION (1<<22)
+#define _TNL_BIT_MAT_BACK_EMISSION (1<<23)
+#define _TNL_BIT_MAT_FRONT_SHININESS (1<<24)
+#define _TNL_BIT_MAT_BACK_SHININESS (1<<25)
+#define _TNL_BIT_MAT_FRONT_INDEXES (1<<26)
+#define _TNL_BIT_MAT_BACK_INDEXES (1<<27)
+#define _TNL_BIT_INDEX (1<<28)
+#define _TNL_BIT_EDGEFLAG (1<<29)
+#define _TNL_BIT_POINTSIZE (1<<30)
+
+#define _TNL_BIT_TEX(u) (1 << (_TNL_ATTRIB_TEX0 + (u)))
+
+
+
+#define _TNL_BITS_MAT_ANY (_TNL_BIT_MAT_FRONT_AMBIENT | \
+ _TNL_BIT_MAT_BACK_AMBIENT | \
+ _TNL_BIT_MAT_FRONT_DIFFUSE | \
+ _TNL_BIT_MAT_BACK_DIFFUSE | \
+ _TNL_BIT_MAT_FRONT_SPECULAR | \
+ _TNL_BIT_MAT_BACK_SPECULAR | \
+ _TNL_BIT_MAT_FRONT_EMISSION | \
+ _TNL_BIT_MAT_BACK_EMISSION | \
+ _TNL_BIT_MAT_FRONT_SHININESS | \
+ _TNL_BIT_MAT_BACK_SHININESS | \
+ _TNL_BIT_MAT_FRONT_INDEXES | \
+ _TNL_BIT_MAT_BACK_INDEXES)
+
+
+#define _TNL_BITS_TEX_ANY (_TNL_BIT_TEX0 | \
+ _TNL_BIT_TEX1 | \
+ _TNL_BIT_TEX2 | \
+ _TNL_BIT_TEX3 | \
+ _TNL_BIT_TEX4 | \
+ _TNL_BIT_TEX5 | \
+ _TNL_BIT_TEX6 | \
+ _TNL_BIT_TEX7)
+
+
+#define _TNL_BITS_PROG_ANY (_TNL_BIT_POS | \
+ _TNL_BIT_WEIGHT | \
+ _TNL_BIT_NORMAL | \
+ _TNL_BIT_COLOR0 | \
+ _TNL_BIT_COLOR1 | \
+ _TNL_BIT_FOG | \
+ _TNL_BIT_SIX | \
+ _TNL_BIT_SEVEN | \
+ _TNL_BITS_TEX_ANY)
+
+
+
+#define PRIM_BEGIN 0x10
+#define PRIM_END 0x20
+#define PRIM_WEAK 0x40
+#define PRIM_MODE_MASK 0x0f
+
+/*
+ */
+struct tnl_prim {
+ GLuint mode;
+ GLuint start;
+ GLuint count;
+};
+
+
+
+struct tnl_eval1_map {
+ struct gl_1d_map *map;
+ GLuint sz;
+};
+
+struct tnl_eval2_map {
+ struct gl_2d_map *map;
+ GLuint sz;
+};
+
+struct tnl_eval {
+ GLuint new_state;
+ struct tnl_eval1_map map1[_TNL_ATTRIB_INDEX + 1];
+ struct tnl_eval2_map map2[_TNL_ATTRIB_INDEX + 1];
+};
+
+
+#define TNL_MAX_PRIM 16
+#define TNL_MAX_COPIED_VERTS 3
+
+struct tnl_copied_vtx {
+ GLfloat buffer[_TNL_ATTRIB_MAX * 4 * TNL_MAX_COPIED_VERTS];
+ GLuint nr;
+};
+
+#define VERT_BUFFER_SIZE 2048 /* 8kbytes */
+
+
+typedef void (*tnl_attrfv_func)( const GLfloat * );
+
+struct _tnl_dynfn {
+ struct _tnl_dynfn *next, *prev;
+ GLuint key;
+ char *code;
+};
+
+struct _tnl_dynfn_lists {
+ struct _tnl_dynfn Vertex[4];
+ struct _tnl_dynfn Attribute[4];
+};
+
+struct _tnl_dynfn_generators {
+ struct _tnl_dynfn *(*Vertex[4])( GLcontext *ctx, int key );
+ struct _tnl_dynfn *(*Attribute[4])( GLcontext *ctx, int key );
+};
+
+#define _TNL_MAX_ATTR_CODEGEN 16
+
+
+/* The assembly of vertices in immediate mode is separated from
+ * display list compilation. This allows a simpler immediate mode
+ * treatment and a display list compiler better suited to
+ * hardware-acceleration.
+ */
+struct tnl_vtx {
+ GLfloat buffer[VERT_BUFFER_SIZE];
+ GLubyte attrsz[_TNL_ATTRIB_MAX];
+ GLuint vertex_size;
+ struct tnl_prim prim[TNL_MAX_PRIM];
+ GLuint prim_count;
+ GLfloat *vbptr; /* cursor, points into buffer */
+ GLfloat vertex[_TNL_ATTRIB_MAX*4]; /* current vertex */
+ GLfloat *attrptr[_TNL_ATTRIB_MAX]; /* points into vertex */
+ GLfloat *current[_TNL_ATTRIB_MAX]; /* points into ctx->Current, etc */
+ GLfloat CurrentFloatEdgeFlag;
+ GLuint counter, initial_counter;
+ struct tnl_copied_vtx copied;
+
+ tnl_attrfv_func tabfv[_TNL_MAX_ATTR_CODEGEN+1][4]; /* plus 1 for ERROR_ATTRIB */
+
+ struct _tnl_dynfn_lists cache;
+ struct _tnl_dynfn_generators gen;
+
+ struct tnl_eval eval;
+ GLboolean *edgeflag_tmp;
+ GLboolean have_materials;
+};
+
+
+
+
+/* For display lists, this structure holds a run of vertices of the
+ * same format, and a strictly well-formed set of begin/end pairs,
+ * starting on the first vertex and ending at the last. Vertex
+ * copying on buffer breaks is precomputed according to these
+ * primitives, though there are situations where the copying will need
+ * correction at execute-time, perhaps by replaying the list as
+ * immediate mode commands.
+ *
+ * On executing this list, the 'current' values may be updated with
+ * the values of the final vertex, and often no fixup of the start of
+ * the vertex list is required.
+ *
+ * Eval and other commands that don't fit into these vertex lists are
+ * compiled using the fallback opcode mechanism provided by dlist.c.
+ */
+struct tnl_vertex_list {
+ GLubyte attrsz[_TNL_ATTRIB_MAX];
+ GLuint vertex_size;
+
+ GLfloat *buffer;
+ GLuint count;
+ GLuint wrap_count; /* number of copied vertices at start */
+ GLboolean have_materials; /* bit of a hack - quick check for materials */
+ GLboolean dangling_attr_ref; /* current attr implicitly referenced
+ outside the list */
+
+ GLfloat *normal_lengths;
+ struct tnl_prim *prim;
+ GLuint prim_count;
+
+ struct tnl_vertex_store *vertex_store;
+ struct tnl_primitive_store *prim_store;
+};
+
+/* These buffers should be a reasonable size to support upload to
+ * hardware? Maybe drivers should stitch them back together, or
+ * specify a desired size?
+ */
+#define SAVE_BUFFER_SIZE (16*1024)
+#define SAVE_PRIM_SIZE 128
+
+/* Storage to be shared among several vertex_lists.
+ */
+struct tnl_vertex_store {
+ GLfloat buffer[SAVE_BUFFER_SIZE];
+ GLuint used;
+ GLuint refcount;
+};
+
+struct tnl_primitive_store {
+ struct tnl_prim buffer[SAVE_PRIM_SIZE];
+ GLuint used;
+ GLuint refcount;
+};
+
+
+struct tnl_save {
+ GLubyte attrsz[_TNL_ATTRIB_MAX];
+ GLuint vertex_size;
+
+ GLfloat *buffer;
+ GLuint count;
+ GLuint wrap_count;
+ GLuint replay_flags;
+
+ struct tnl_prim *prim;
+ GLuint prim_count, prim_max;
+
+ struct tnl_vertex_store *vertex_store;
+ struct tnl_primitive_store *prim_store;
+
+ GLfloat *vbptr; /* cursor, points into buffer */
+ GLfloat vertex[_TNL_ATTRIB_MAX*4]; /* current values */
+ GLfloat *attrptr[_TNL_ATTRIB_MAX];
+ GLuint counter, initial_counter;
+ GLboolean dangling_attr_ref;
+ GLboolean have_materials;
+
+ GLuint opcode_vertex_list;
+
+ struct tnl_copied_vtx copied;
+
+ GLfloat CurrentFloatEdgeFlag;
+
+ GLfloat *current[_TNL_ATTRIB_MAX]; /* points into ctx->ListState */
+ GLubyte *currentsz[_TNL_ATTRIB_MAX];
+
+ void (*tabfv[_TNL_ATTRIB_MAX][4])( const GLfloat * );
+};
+
+
+struct tnl_vertex_arrays
+{
+ /* Conventional vertex attribute arrays */
+ GLvector4f Obj;
+ GLvector4f Normal;
+ GLvector4f Color;
+ GLvector4f SecondaryColor;
+ GLvector4f FogCoord;
+ GLvector4f TexCoord[MAX_TEXTURE_COORD_UNITS];
+ GLvector4f Index;
+
+ GLubyte *EdgeFlag;
+ GLuint *Elt;
+
+ /* These attributes don't alias with the conventional attributes.
+ * The GL_NV_vertex_program extension defines 16 extra sets of vertex
+ * arrays which have precedent over the conventional arrays when enabled.
+ */
+ GLvector4f Attribs[_TNL_ATTRIB_MAX];
+};
+
+
+/**
+ * Contains the current state of a running pipeline.
+ */
+struct vertex_buffer
+{
+ /* Constant over life of the vertex_buffer.
+ */
+ GLuint Size;
+
+ /* Constant over the pipeline.
+ */
+ GLuint Count; /* for everything except Elts */
+
+ /* Pointers to current data.
+ */
+ GLuint *Elts;
+ GLvector4f *ObjPtr; /* _TNL_BIT_POS */
+ GLvector4f *EyePtr; /* _TNL_BIT_POS */
+ GLvector4f *ClipPtr; /* _TNL_BIT_POS */
+ GLvector4f *NdcPtr; /* _TNL_BIT_POS */
+ GLubyte ClipOrMask; /* _TNL_BIT_POS */
+ GLubyte ClipAndMask; /* _TNL_BIT_POS */
+ GLubyte *ClipMask; /* _TNL_BIT_POS */
+ GLvector4f *NormalPtr; /* _TNL_BIT_NORMAL */
+ GLfloat *NormalLengthPtr; /* _TNL_BIT_NORMAL */
+ GLboolean *EdgeFlag; /* _TNL_BIT_EDGEFLAG */
+ GLvector4f *TexCoordPtr[MAX_TEXTURE_COORD_UNITS]; /* VERT_TEX_0..n */
+ GLvector4f *IndexPtr[2]; /* _TNL_BIT_INDEX */
+ GLvector4f *ColorPtr[2]; /* _TNL_BIT_COLOR0 */
+ GLvector4f *SecondaryColorPtr[2]; /* _TNL_BIT_COLOR1 */
+ GLvector4f *PointSizePtr; /* _TNL_BIT_POS */
+ GLvector4f *FogCoordPtr; /* _TNL_BIT_FOG */
+
+ struct tnl_prim *Primitive;
+ GLuint PrimitiveCount;
+
+ /* Inputs to the vertex program stage */
+ GLvector4f *AttribPtr[_TNL_ATTRIB_MAX]; /* GL_NV_vertex_program */
+
+ GLuint LastClipped;
+ /* Private data from _tnl_render_stage that has no business being
+ * in this struct.
+ */
+};
+
+
+/** Describes an individual operation on the pipeline.
+ */
+struct tnl_pipeline_stage
+{
+ const char *name;
+
+ /* Private data for the pipeline stage:
+ */
+ void *privatePtr;
+
+ /* Allocate private data
+ */
+ GLboolean (*create)( GLcontext *ctx, struct tnl_pipeline_stage * );
+
+ /* Free private data.
+ */
+ void (*destroy)( struct tnl_pipeline_stage * );
+
+ /* Called on any statechange or input array size change or
+ * input array change to/from zero stride.
+ */
+ void (*validate)( GLcontext *ctx, struct tnl_pipeline_stage * );
+
+ /* Called from _tnl_run_pipeline(). The stage.changed_inputs value
+ * encodes all inputs to thee struct which have changed. If
+ * non-zero, recompute all affected outputs of the stage, otherwise
+ * execute any 'sideeffects' of the stage.
+ *
+ * Return value: GL_TRUE - keep going
+ * GL_FALSE - finished pipeline
+ */
+ GLboolean (*run)( GLcontext *ctx, struct tnl_pipeline_stage * );
+};
+
+
+
+/** Contains the array of all pipeline stages.
+ * The default values are defined at the end of t_pipeline.c
+ */
+struct tnl_pipeline {
+
+ GLuint last_attrib_stride[_TNL_ATTRIB_MAX];
+ GLuint last_attrib_size[_TNL_ATTRIB_MAX];
+ GLuint input_changes;
+ GLuint new_state;
+
+ struct tnl_pipeline_stage stages[MAX_PIPELINE_STAGES+1];
+ GLuint nr_stages;
+};
+
+struct tnl_clipspace;
+struct tnl_clipspace_attr;
+
+typedef void (*tnl_extract_func)( const struct tnl_clipspace_attr *a,
+ GLfloat *out,
+ const GLubyte *v );
+
+typedef void (*tnl_insert_func)( const struct tnl_clipspace_attr *a,
+ GLubyte *v,
+ const GLfloat *in );
+
+typedef void (*tnl_emit_func)( GLcontext *ctx,
+ GLuint count,
+ GLubyte *dest );
+
+
+/**
+ * Describes how to convert/move a vertex attribute from a vertex array
+ * to a vertex structure.
+ */
+struct tnl_clipspace_attr
+{
+ GLuint attrib; /* which vertex attrib (0=position, etc) */
+ GLuint format;
+ GLuint vertoffset; /* position of the attrib in the vertex struct */
+ GLuint vertattrsize; /* size of the attribute in bytes */
+ GLubyte *inputptr;
+ GLuint inputstride;
+ GLuint inputsize;
+ const tnl_insert_func *insert;
+ tnl_insert_func emit;
+ tnl_extract_func extract;
+ const GLfloat *vp; /* NDC->Viewport mapping matrix */
+};
+
+
+
+
+typedef void (*tnl_points_func)( GLcontext *ctx, GLuint first, GLuint last );
+typedef void (*tnl_line_func)( GLcontext *ctx, GLuint v1, GLuint v2 );
+typedef void (*tnl_triangle_func)( GLcontext *ctx,
+ GLuint v1, GLuint v2, GLuint v3 );
+typedef void (*tnl_quad_func)( GLcontext *ctx, GLuint v1, GLuint v2,
+ GLuint v3, GLuint v4 );
+typedef void (*tnl_render_func)( GLcontext *ctx, GLuint start, GLuint count,
+ GLuint flags );
+typedef void (*tnl_interp_func)( GLcontext *ctx,
+ GLfloat t, GLuint dst, GLuint out, GLuint in,
+ GLboolean force_boundary );
+typedef void (*tnl_copy_pv_func)( GLcontext *ctx, GLuint dst, GLuint src );
+typedef void (*tnl_setup_func)( GLcontext *ctx,
+ GLuint start, GLuint end,
+ GLuint new_inputs);
+
+
+struct tnl_clipspace_fastpath {
+ GLuint vertex_size;
+ GLuint attr_count;
+ GLboolean match_strides;
+
+ struct {
+ GLuint format;
+ GLuint size;
+ GLuint stride;
+ GLuint offset;
+ } *attr;
+
+ tnl_emit_func func;
+ struct tnl_clipspace_fastpath *next;
+};
+
+/**
+ * Used to describe conversion of vertex arrays to vertex structures.
+ * I.e. Structure of arrays to arrays of structs.
+ */
+struct tnl_clipspace
+{
+ GLboolean need_extras;
+
+ GLuint new_inputs;
+
+ GLubyte *vertex_buf;
+ GLuint vertex_size;
+ GLuint max_vertex_size;
+
+ struct tnl_clipspace_attr attr[_TNL_ATTRIB_MAX];
+ GLuint attr_count;
+
+ tnl_emit_func emit;
+ tnl_interp_func interp;
+ tnl_copy_pv_func copy_pv;
+
+ /* Parameters and constants for codegen:
+ */
+ GLboolean need_viewport;
+ GLfloat vp_scale[4];
+ GLfloat vp_xlate[4];
+ GLfloat chan_scale[4];
+ GLfloat identity[4];
+
+ struct tnl_clipspace_fastpath *fastpath;
+
+ void (*codegen_emit)( GLcontext *ctx );
+};
+
+
+
+struct tnl_cache {
+ GLuint hash;
+ void *key;
+ void *data;
+ struct tnl_cache *next;
+};
+
+
+struct tnl_device_driver
+{
+ /***
+ *** TNL Pipeline
+ ***/
+
+ void (*RunPipeline)(GLcontext *ctx);
+ /* Replaces PipelineStart/PipelineFinish -- intended to allow
+ * drivers to wrap _tnl_run_pipeline() with code to validate state
+ * and grab/release hardware locks.
+ */
+
+ void (*NotifyMaterialChange)(GLcontext *ctx);
+ /* Alert tnl-aware drivers of changes to material.
+ */
+
+ GLboolean (*NotifyBegin)(GLcontext *ctx, GLenum p);
+ /* Allow drivers to hook in optimized begin/end engines.
+ * Return value: GL_TRUE - driver handled the begin
+ * GL_FALSE - driver didn't handle the begin
+ */
+
+ /***
+ *** Rendering -- These functions called only from t_vb_render.c
+ ***/
+ struct
+ {
+ void (*Start)(GLcontext *ctx);
+ void (*Finish)(GLcontext *ctx);
+ /* Called before and after all rendering operations, including DrawPixels,
+ * ReadPixels, Bitmap, span functions, and CopyTexImage, etc commands.
+ * These are a suitable place for grabbing/releasing hardware locks.
+ */
+
+ void (*PrimitiveNotify)(GLcontext *ctx, GLenum mode);
+ /* Called between RenderStart() and RenderFinish() to indicate the
+ * type of primitive we're about to draw. Mode will be one of the
+ * modes accepted by glBegin().
+ */
+
+ tnl_interp_func Interp;
+ /* The interp function is called by the clipping routines when we need
+ * to generate an interpolated vertex. All pertinant vertex ancilliary
+ * data should be computed by interpolating between the 'in' and 'out'
+ * vertices.
+ */
+
+ tnl_copy_pv_func CopyPV;
+ /* The copy function is used to make a copy of a vertex. All pertinant
+ * vertex attributes should be copied.
+ */
+
+ void (*ClippedPolygon)( GLcontext *ctx, const GLuint *elts, GLuint n );
+ /* Render a polygon with <n> vertices whose indexes are in the <elts>
+ * array.
+ */
+
+ void (*ClippedLine)( GLcontext *ctx, GLuint v0, GLuint v1 );
+ /* Render a line between the two vertices given by indexes v0 and v1. */
+
+ tnl_points_func Points; /* must now respect vb->elts */
+ tnl_line_func Line;
+ tnl_triangle_func Triangle;
+ tnl_quad_func Quad;
+ /* These functions are called in order to render points, lines,
+ * triangles and quads. These are only called via the T&L module.
+ */
+
+ tnl_render_func *PrimTabVerts;
+ tnl_render_func *PrimTabElts;
+ /* Render whole unclipped primitives (points, lines, linestrips,
+ * lineloops, etc). The tables are indexed by the GL enum of the
+ * primitive to be rendered. RenderTabVerts is used for non-indexed
+ * arrays of vertices. RenderTabElts is used for indexed arrays of
+ * vertices.
+ */
+
+ void (*ResetLineStipple)( GLcontext *ctx );
+ /* Reset the hardware's line stipple counter.
+ */
+
+ tnl_setup_func BuildVertices;
+ /* This function is called whenever new vertices are required for
+ * rendering. The vertices in question are those n such that start
+ * <= n < end. The new_inputs parameter indicates those fields of
+ * the vertex which need to be updated, if only a partial repair of
+ * the vertex is required.
+ *
+ * This function is called only from _tnl_render_stage in tnl/t_render.c.
+ */
+
+
+ GLboolean (*Multipass)( GLcontext *ctx, 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.
+ */
+ } Render;
+};
+
+
+/**
+ * Context state for T&L context.
+ */
+typedef struct
+{
+ /* Driver interface.
+ */
+ struct tnl_device_driver Driver;
+
+ /* Execute:
+ */
+ struct tnl_vtx vtx;
+
+ /* Compile:
+ */
+ struct tnl_save save;
+
+ /* Pipeline
+ */
+ struct tnl_pipeline pipeline;
+ struct vertex_buffer vb;
+
+ /* GLvectors for binding to vb:
+ */
+ struct tnl_vertex_arrays vtx_inputs;
+ struct tnl_vertex_arrays save_inputs;
+ struct tnl_vertex_arrays current;
+ struct tnl_vertex_arrays array_inputs;
+
+ /* Clipspace/ndc/window vertex managment:
+ */
+ struct tnl_clipspace clipspace;
+
+ /* Probably need a better configuration mechanism:
+ */
+ GLboolean NeedNdcCoords;
+ GLboolean LoopbackDListCassettes;
+ GLboolean CalcDListNormalLengths;
+ GLboolean IsolateMaterials;
+ GLboolean AllowVertexFog;
+ GLboolean AllowPixelFog;
+ GLboolean AllowCodegen;
+
+ GLboolean _DoVertexFog; /* eval fog function at each vertex? */
+
+ /* If True, it means we started a glBegin/End primtive with an invalid
+ * vertex/fragment program or incomplete framebuffer. In that case,
+ * discard any buffered vertex data.
+ */
+ GLboolean DiscardPrimitive;
+
+ GLuint render_inputs;
+
+ GLvertexformat exec_vtxfmt;
+ GLvertexformat save_vtxfmt;
+
+ struct tnl_cache *vp_cache;
+
+} TNLcontext;
+
+
+
+#define TNL_CONTEXT(ctx) ((TNLcontext *)((ctx)->swtnl_context))
+
+
+#define TYPE_IDX(t) ((t) & 0xf)
+#define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */
+
+extern void _tnl_MakeCurrent( GLcontext *ctx,
+ GLframebuffer *drawBuffer,
+ GLframebuffer *readBuffer );
+
+
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_pipeline.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_pipeline.c
new file mode 100644
index 000000000..61bfed290
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_pipeline.c
@@ -0,0 +1,218 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "imports.h"
+#include "state.h"
+#include "mtypes.h"
+
+#include "math/m_translate.h"
+#include "math/m_xform.h"
+
+#include "t_context.h"
+#include "t_pipeline.h"
+#include "t_vp_build.h"
+#include "t_vertex.h"
+
+void _tnl_install_pipeline( GLcontext *ctx,
+ const struct tnl_pipeline_stage **stages )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint i;
+
+ tnl->pipeline.new_state = ~0;
+
+ /* Create a writeable copy of each stage.
+ */
+ for (i = 0 ; i < MAX_PIPELINE_STAGES && stages[i] ; i++) {
+ struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i];
+ MEMCPY(s, stages[i], sizeof(*s));
+ if (s->create)
+ s->create(ctx, s);
+ }
+
+ tnl->pipeline.nr_stages = i;
+}
+
+void _tnl_destroy_pipeline( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint i;
+
+ for (i = 0 ; i < tnl->pipeline.nr_stages ; i++) {
+ struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i];
+ if (s->destroy)
+ s->destroy(s);
+ }
+
+ tnl->pipeline.nr_stages = 0;
+}
+
+
+
+static GLuint check_input_changes( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint i;
+
+ for (i = 0; i < _TNL_ATTRIB_EDGEFLAG; i++) {
+ if (tnl->vb.AttribPtr[i]->size != tnl->pipeline.last_attrib_size[i] ||
+ tnl->vb.AttribPtr[i]->stride != tnl->pipeline.last_attrib_stride[i]) {
+ tnl->pipeline.last_attrib_size[i] = tnl->vb.AttribPtr[i]->size;
+ tnl->pipeline.last_attrib_stride[i] = tnl->vb.AttribPtr[i]->stride;
+ tnl->pipeline.input_changes |= 1<<i;
+ }
+ }
+
+ return tnl->pipeline.input_changes;
+}
+
+
+static GLuint check_output_changes( GLcontext *ctx )
+{
+#if 0
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ for (i = 0; i < VERT_RESULT_MAX; i++) {
+ if (tnl->vb.ResultPtr[i]->size != tnl->last_result_size[i] ||
+ tnl->vb.ResultPtr[i]->stride != tnl->last_result_stride[i]) {
+ tnl->last_result_size[i] = tnl->vb.ResultPtr[i]->size;
+ tnl->last_result_stride[i] = tnl->vb.ResultPtr[i]->stride;
+ tnl->pipeline.output_changes |= 1<<i;
+ }
+ }
+
+ if (tnl->pipeline.output_changes)
+ tnl->Driver.NotifyOutputChanges( ctx, tnl->pipeline.output_changes );
+
+ return tnl->pipeline.output_changes;
+#else
+ return ~0;
+#endif
+}
+
+
+void _tnl_run_pipeline( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ unsigned short __tmp;
+ GLuint i;
+
+ if (!tnl->vb.Count)
+ return;
+
+ /* Check for changed input sizes or change in stride to/from zero
+ * (ie const or non-const).
+ */
+ if (check_input_changes( ctx ) || tnl->pipeline.new_state) {
+ if (ctx->_MaintainTnlProgram)
+ _tnl_UpdateFixedFunctionProgram( ctx );
+
+ for (i = 0; i < tnl->pipeline.nr_stages ; i++) {
+ struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i];
+ if (s->validate)
+ s->validate( ctx, s );
+ }
+
+ tnl->pipeline.new_state = 0;
+ tnl->pipeline.input_changes = 0;
+
+ /* Pipeline can only change its output in response to either a
+ * statechange or an input size/stride change. No other changes
+ * are allowed.
+ */
+ if (check_output_changes( ctx ))
+ _tnl_notify_pipeline_output_change( ctx );
+ }
+
+ START_FAST_MATH(__tmp);
+
+ for (i = 0; i < tnl->pipeline.nr_stages ; i++) {
+ struct tnl_pipeline_stage *s = &tnl->pipeline.stages[i];
+ if (!s->run( ctx, s ))
+ break;
+ }
+
+ END_FAST_MATH(__tmp);
+}
+
+
+
+/* The default pipeline. This is useful for software rasterizers, and
+ * simple hardware rasterizers. For customization, I don't recommend
+ * tampering with the internals of these stages in the way that
+ * drivers did in Mesa 3.4. These stages are basically black boxes,
+ * and should be left intact.
+ *
+ * To customize the pipeline, consider:
+ *
+ * - removing redundant stages (making sure that the software rasterizer
+ * can cope with this on fallback paths). An example is fog
+ * coordinate generation, which is not required in the FX driver.
+ *
+ * - replacing general-purpose machine-independent stages with
+ * general-purpose machine-specific stages. There is no example of
+ * this to date, though it must be borne in mind that all subsequent
+ * stages that reference the output of the new stage must cope with
+ * any machine-specific data introduced. This may not be easy
+ * unless there are no such stages (ie the new stage is the last in
+ * the pipe).
+ *
+ * - inserting optimized (but specialized) stages ahead of the
+ * general-purpose fallback implementation. For example, the old
+ * fastpath mechanism, which only works when the VB->Elts input is
+ * available, can be duplicated by placing the fastpath stage at the
+ * head of this pipeline. Such specialized stages are currently
+ * constrained to have no outputs (ie. they must either finish the *
+ * pipeline by returning GL_FALSE from run(), or do nothing).
+ *
+ * Some work can be done to lift some of the restrictions in the final
+ * case, if it becomes necessary to do so.
+ */
+const struct tnl_pipeline_stage *_tnl_default_pipeline[] = {
+ &_tnl_vertex_transform_stage,
+ &_tnl_normal_transform_stage,
+ &_tnl_lighting_stage,
+ &_tnl_fog_coordinate_stage,
+ &_tnl_texgen_stage,
+ &_tnl_texture_transform_stage,
+ &_tnl_point_attenuation_stage,
+#if defined(FEATURE_NV_vertex_program) || defined(FEATURE_ARB_vertex_program)
+ &_tnl_arb_vertex_program_stage,
+ &_tnl_vertex_program_stage,
+#endif
+ &_tnl_render_stage,
+ NULL
+};
+
+const struct tnl_pipeline_stage *_tnl_vp_pipeline[] = {
+ &_tnl_arb_vertex_program_stage,
+ &_tnl_render_stage,
+ NULL
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_pipeline.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_pipeline.h
new file mode 100644
index 000000000..6c7a0814c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_pipeline.h
@@ -0,0 +1,76 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+
+#ifndef _T_PIPELINE_H_
+#define _T_PIPELINE_H_
+
+#include "mtypes.h"
+#include "t_context.h"
+
+extern void _tnl_run_pipeline( GLcontext *ctx );
+
+extern void _tnl_destroy_pipeline( GLcontext *ctx );
+
+extern void _tnl_install_pipeline( GLcontext *ctx,
+ const struct tnl_pipeline_stage **stages );
+
+
+/* These are implemented in the t_vb_*.c files:
+ */
+extern const struct tnl_pipeline_stage _tnl_vertex_transform_stage;
+extern const struct tnl_pipeline_stage _tnl_vertex_cull_stage;
+extern const struct tnl_pipeline_stage _tnl_normal_transform_stage;
+extern const struct tnl_pipeline_stage _tnl_lighting_stage;
+extern const struct tnl_pipeline_stage _tnl_fog_coordinate_stage;
+extern const struct tnl_pipeline_stage _tnl_texgen_stage;
+extern const struct tnl_pipeline_stage _tnl_texture_transform_stage;
+extern const struct tnl_pipeline_stage _tnl_point_attenuation_stage;
+extern const struct tnl_pipeline_stage _tnl_arb_vertex_program_stage;
+extern const struct tnl_pipeline_stage _tnl_vertex_program_stage;
+extern const struct tnl_pipeline_stage _tnl_render_stage;
+
+/* Shorthand to plug in the default pipeline:
+ */
+extern const struct tnl_pipeline_stage *_tnl_default_pipeline[];
+extern const struct tnl_pipeline_stage *_tnl_vp_pipeline[];
+
+
+/* Convenience routines provided by t_vb_render.c:
+ */
+extern tnl_render_func _tnl_render_tab_elts[];
+extern tnl_render_func _tnl_render_tab_verts[];
+
+extern void _tnl_RenderClippedPolygon( GLcontext *ctx,
+ const GLuint *elts, GLuint n );
+
+extern void _tnl_RenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj );
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_save_api.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_save_api.c
new file mode 100644
index 000000000..9788468d5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_save_api.c
@@ -0,0 +1,1724 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 2002 Tungsten Graphics 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
+TUNGSTEN GRAPHICS 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+
+/* Display list compiler attempts to store lists of vertices with the
+ * same vertex layout. Additionally it attempts to minimize the need
+ * for execute-time fixup of these vertex lists, allowing them to be
+ * cached on hardware.
+ *
+ * There are still some circumstances where this can be thwarted, for
+ * example by building a list that consists of one very long primitive
+ * (eg Begin(Triangles), 1000 vertices, End), and calling that list
+ * from inside a different begin/end object (Begin(Lines), CallList,
+ * End).
+ *
+ * In that case the code will have to replay the list as individual
+ * commands through the Exec dispatch table, or fix up the copied
+ * vertices at execute-time.
+ *
+ * The other case where fixup is required is when a vertex attribute
+ * is introduced in the middle of a primitive. Eg:
+ * Begin(Lines)
+ * TexCoord1f() Vertex2f()
+ * TexCoord1f() Color3f() Vertex2f()
+ * End()
+ *
+ * If the current value of Color isn't known at compile-time, this
+ * primitive will require fixup.
+ *
+ *
+ * The list compiler currently doesn't attempt to compile lists
+ * containing EvalCoord or EvalPoint commands. On encountering one of
+ * these, compilation falls back to opcodes.
+ *
+ * This could be improved to fallback only when a mix of EvalCoord and
+ * Vertex commands are issued within a single primitive.
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "dlist.h"
+#include "enums.h"
+#include "macros.h"
+#include "api_validate.h"
+#include "api_arrayelt.h"
+#include "vtxfmt.h"
+#include "t_save_api.h"
+#include "dispatch.h"
+
+/*
+ * NOTE: Old 'parity' issue is gone, but copying can still be
+ * wrong-footed on replay.
+ */
+static GLuint _save_copy_vertices( GLcontext *ctx,
+ const struct tnl_vertex_list *node )
+{
+ TNLcontext *tnl = TNL_CONTEXT( ctx );
+ const struct tnl_prim *prim = &node->prim[node->prim_count-1];
+ GLuint nr = prim->count;
+ GLuint sz = tnl->save.vertex_size;
+ const GLfloat *src = node->buffer + prim->start * sz;
+ GLfloat *dst = tnl->save.copied.buffer;
+ GLuint ovf, i;
+
+ if (prim->mode & PRIM_END)
+ return 0;
+
+ switch( prim->mode & PRIM_MODE_MASK )
+ {
+ case GL_POINTS:
+ return 0;
+ case GL_LINES:
+ ovf = nr&1;
+ for (i = 0 ; i < ovf ; i++)
+ _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*sizeof(GLfloat) );
+ return i;
+ case GL_TRIANGLES:
+ ovf = nr%3;
+ for (i = 0 ; i < ovf ; i++)
+ _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*sizeof(GLfloat) );
+ return i;
+ case GL_QUADS:
+ ovf = nr&3;
+ for (i = 0 ; i < ovf ; i++)
+ _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*sizeof(GLfloat) );
+ return i;
+ case GL_LINE_STRIP:
+ if (nr == 0)
+ return 0;
+ else {
+ _mesa_memcpy( dst, src+(nr-1)*sz, sz*sizeof(GLfloat) );
+ return 1;
+ }
+ case GL_LINE_LOOP:
+ case GL_TRIANGLE_FAN:
+ case GL_POLYGON:
+ if (nr == 0)
+ return 0;
+ else if (nr == 1) {
+ _mesa_memcpy( dst, src+0, sz*sizeof(GLfloat) );
+ return 1;
+ } else {
+ _mesa_memcpy( dst, src+0, sz*sizeof(GLfloat) );
+ _mesa_memcpy( dst+sz, src+(nr-1)*sz, sz*sizeof(GLfloat) );
+ return 2;
+ }
+ case GL_TRIANGLE_STRIP:
+ case GL_QUAD_STRIP:
+ switch (nr) {
+ case 0: ovf = 0; break;
+ case 1: ovf = 1; break;
+ default: ovf = 2 + (nr&1); break;
+ }
+ for (i = 0 ; i < ovf ; i++)
+ _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz*sizeof(GLfloat) );
+ return i;
+ default:
+ assert(0);
+ return 0;
+ }
+}
+
+
+static void
+build_normal_lengths( struct tnl_vertex_list *node )
+{
+ GLuint i;
+ GLfloat *len;
+ GLfloat *n = node->buffer;
+ GLuint stride = node->vertex_size;
+ GLuint count = node->count;
+
+ len = node->normal_lengths = (GLfloat *) MALLOC( count * sizeof(GLfloat) );
+ if (!len)
+ return;
+
+ /* Find the normal of the first vertex:
+ */
+ for (i = 0 ; i < _TNL_ATTRIB_NORMAL ; i++)
+ n += node->attrsz[i];
+
+ for (i = 0 ; i < count ; i++, n += stride) {
+ len[i] = LEN_3FV( n );
+ if (len[i] > 0.0F) len[i] = 1.0F / len[i];
+ }
+}
+
+static struct tnl_vertex_store *alloc_vertex_store( GLcontext *ctx )
+{
+ struct tnl_vertex_store *store = MALLOC_STRUCT(tnl_vertex_store);
+ (void) ctx;
+ store->used = 0;
+ store->refcount = 1;
+ return store;
+}
+
+static struct tnl_primitive_store *alloc_prim_store( GLcontext *ctx )
+{
+ struct tnl_primitive_store *store = MALLOC_STRUCT(tnl_primitive_store);
+ (void) ctx;
+ store->used = 0;
+ store->refcount = 1;
+ return store;
+}
+
+static void _save_reset_counters( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ tnl->save.prim = tnl->save.prim_store->buffer + tnl->save.prim_store->used;
+ tnl->save.buffer = (tnl->save.vertex_store->buffer +
+ tnl->save.vertex_store->used);
+
+ if (tnl->save.vertex_size)
+ tnl->save.initial_counter = ((SAVE_BUFFER_SIZE -
+ tnl->save.vertex_store->used) /
+ tnl->save.vertex_size);
+ else
+ tnl->save.initial_counter = 0;
+
+ if (tnl->save.initial_counter > ctx->Const.MaxArrayLockSize )
+ tnl->save.initial_counter = ctx->Const.MaxArrayLockSize;
+
+ tnl->save.counter = tnl->save.initial_counter;
+ tnl->save.prim_count = 0;
+ tnl->save.prim_max = SAVE_PRIM_SIZE - tnl->save.prim_store->used;
+ tnl->save.copied.nr = 0;
+ tnl->save.dangling_attr_ref = 0;
+}
+
+
+/* Insert the active immediate struct onto the display list currently
+ * being built.
+ */
+static void _save_compile_vertex_list( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct tnl_vertex_list *node;
+
+ /* Allocate space for this structure in the display list currently
+ * being compiled.
+ */
+ node = (struct tnl_vertex_list *)
+ _mesa_alloc_instruction(ctx, tnl->save.opcode_vertex_list, sizeof(*node));
+
+ if (!node)
+ return;
+
+ /* Duplicate our template, increment refcounts to the storage structs:
+ */
+ _mesa_memcpy(node->attrsz, tnl->save.attrsz, sizeof(node->attrsz));
+ node->vertex_size = tnl->save.vertex_size;
+ node->buffer = tnl->save.buffer;
+ node->count = tnl->save.initial_counter - tnl->save.counter;
+ node->wrap_count = tnl->save.copied.nr;
+ node->have_materials = tnl->save.have_materials;
+ node->dangling_attr_ref = tnl->save.dangling_attr_ref;
+ node->normal_lengths = NULL;
+ node->prim = tnl->save.prim;
+ node->prim_count = tnl->save.prim_count;
+ node->vertex_store = tnl->save.vertex_store;
+ node->prim_store = tnl->save.prim_store;
+
+ node->vertex_store->refcount++;
+ node->prim_store->refcount++;
+
+ assert(node->attrsz[_TNL_ATTRIB_POS] != 0 ||
+ node->count == 0);
+
+ if (tnl->save.dangling_attr_ref)
+ ctx->ListState.CurrentList->flags |= MESA_DLIST_DANGLING_REFS;
+
+ /* Maybe calculate normal lengths:
+ */
+ if (tnl->CalcDListNormalLengths &&
+ node->attrsz[_TNL_ATTRIB_NORMAL] == 3 &&
+ !(ctx->ListState.CurrentList->flags & MESA_DLIST_DANGLING_REFS))
+ build_normal_lengths( node );
+
+
+ tnl->save.vertex_store->used += tnl->save.vertex_size * node->count;
+ tnl->save.prim_store->used += node->prim_count;
+
+ /* Decide whether the storage structs are full, or can be used for
+ * the next vertex lists as well.
+ */
+ if (tnl->save.vertex_store->used >
+ SAVE_BUFFER_SIZE - 16 * (tnl->save.vertex_size + 4)) {
+
+ tnl->save.vertex_store->refcount--;
+ assert(tnl->save.vertex_store->refcount != 0);
+ tnl->save.vertex_store = alloc_vertex_store( ctx );
+ tnl->save.vbptr = tnl->save.vertex_store->buffer;
+ }
+
+ if (tnl->save.prim_store->used > SAVE_PRIM_SIZE - 6) {
+ tnl->save.prim_store->refcount--;
+ assert(tnl->save.prim_store->refcount != 0);
+ tnl->save.prim_store = alloc_prim_store( ctx );
+ }
+
+ /* Reset our structures for the next run of vertices:
+ */
+ _save_reset_counters( ctx );
+
+ /* Copy duplicated vertices
+ */
+ tnl->save.copied.nr = _save_copy_vertices( ctx, node );
+
+
+ /* Deal with GL_COMPILE_AND_EXECUTE:
+ */
+ if (ctx->ExecuteFlag) {
+ _tnl_playback_vertex_list( ctx, (void *) node );
+ }
+}
+
+
+/* TODO -- If no new vertices have been stored, don't bother saving
+ * it.
+ */
+static void _save_wrap_buffers( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLint i = tnl->save.prim_count - 1;
+ GLenum mode;
+
+ assert(i < (GLint) tnl->save.prim_max);
+ assert(i >= 0);
+
+ /* Close off in-progress primitive.
+ */
+ tnl->save.prim[i].count = ((tnl->save.initial_counter - tnl->save.counter) -
+ tnl->save.prim[i].start);
+ mode = tnl->save.prim[i].mode & ~(PRIM_BEGIN|PRIM_END);
+
+ /* store the copied vertices, and allocate a new list.
+ */
+ _save_compile_vertex_list( ctx );
+
+ /* Restart interrupted primitive
+ */
+ tnl->save.prim[0].mode = mode;
+ tnl->save.prim[0].start = 0;
+ tnl->save.prim[0].count = 0;
+ tnl->save.prim_count = 1;
+}
+
+
+
+/* Called only when buffers are wrapped as the result of filling the
+ * vertex_store struct.
+ */
+static void _save_wrap_filled_vertex( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLfloat *data = tnl->save.copied.buffer;
+ GLuint i;
+
+ /* Emit a glEnd to close off the last vertex list.
+ */
+ _save_wrap_buffers( ctx );
+
+ /* Copy stored stored vertices to start of new list.
+ */
+ assert(tnl->save.counter > tnl->save.copied.nr);
+
+ for (i = 0 ; i < tnl->save.copied.nr ; i++) {
+ _mesa_memcpy( tnl->save.vbptr, data, tnl->save.vertex_size * sizeof(GLfloat));
+ data += tnl->save.vertex_size;
+ tnl->save.vbptr += tnl->save.vertex_size;
+ tnl->save.counter--;
+ }
+}
+
+
+static void _save_copy_to_current( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint i;
+
+ for (i = _TNL_ATTRIB_POS+1 ; i <= _TNL_ATTRIB_INDEX ; i++) {
+ if (tnl->save.attrsz[i]) {
+ tnl->save.currentsz[i][0] = tnl->save.attrsz[i];
+ COPY_CLEAN_4V(tnl->save.current[i],
+ tnl->save.attrsz[i],
+ tnl->save.attrptr[i]);
+ }
+ }
+
+ /* Edgeflag requires special treatment:
+ *
+ * TODO: change edgeflag to GLfloat in Mesa.
+ */
+ if (tnl->save.attrsz[_TNL_ATTRIB_EDGEFLAG]) {
+ ctx->ListState.ActiveEdgeFlag = 1;
+ tnl->save.CurrentFloatEdgeFlag =
+ tnl->save.attrptr[_TNL_ATTRIB_EDGEFLAG][0];
+ ctx->ListState.CurrentEdgeFlag =
+ (tnl->save.CurrentFloatEdgeFlag == 1.0);
+ }
+}
+
+
+static void _save_copy_from_current( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLint i;
+
+ for (i = _TNL_ATTRIB_POS+1 ; i <= _TNL_ATTRIB_INDEX ; i++)
+ switch (tnl->save.attrsz[i]) {
+ case 4: tnl->save.attrptr[i][3] = tnl->save.current[i][3];
+ case 3: tnl->save.attrptr[i][2] = tnl->save.current[i][2];
+ case 2: tnl->save.attrptr[i][1] = tnl->save.current[i][1];
+ case 1: tnl->save.attrptr[i][0] = tnl->save.current[i][0];
+ case 0: break;
+ }
+
+ /* Edgeflag requires special treatment:
+ */
+ if (tnl->save.attrsz[_TNL_ATTRIB_EDGEFLAG]) {
+ tnl->save.CurrentFloatEdgeFlag = (GLfloat)ctx->ListState.CurrentEdgeFlag;
+ tnl->save.attrptr[_TNL_ATTRIB_EDGEFLAG][0] = tnl->save.CurrentFloatEdgeFlag;
+ }
+}
+
+
+
+
+/* Flush existing data, set new attrib size, replay copied vertices.
+ */
+static void _save_upgrade_vertex( GLcontext *ctx,
+ GLuint attr,
+ GLuint newsz )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldsz;
+ GLuint i;
+ GLfloat *tmp;
+
+ /* Store the current run of vertices, and emit a GL_END. Emit a
+ * BEGIN in the new buffer.
+ */
+ if (tnl->save.initial_counter != tnl->save.counter)
+ _save_wrap_buffers( ctx );
+ else
+ assert( tnl->save.copied.nr == 0 );
+
+ /* Do a COPY_TO_CURRENT to ensure back-copying works for the case
+ * when the attribute already exists in the vertex and is having
+ * its size increased.
+ */
+ _save_copy_to_current( ctx );
+
+ /* Fix up sizes:
+ */
+ oldsz = tnl->save.attrsz[attr];
+ tnl->save.attrsz[attr] = newsz;
+
+ tnl->save.vertex_size += newsz - oldsz;
+ tnl->save.counter = ((SAVE_BUFFER_SIZE - tnl->save.vertex_store->used) /
+ tnl->save.vertex_size);
+ if (tnl->save.counter > ctx->Const.MaxArrayLockSize )
+ tnl->save.counter = ctx->Const.MaxArrayLockSize;
+ tnl->save.initial_counter = tnl->save.counter;
+
+ /* Recalculate all the attrptr[] values:
+ */
+ for (i = 0, tmp = tnl->save.vertex ; i < _TNL_ATTRIB_MAX ; i++) {
+ if (tnl->save.attrsz[i]) {
+ tnl->save.attrptr[i] = tmp;
+ tmp += tnl->save.attrsz[i];
+ }
+ else
+ tnl->save.attrptr[i] = NULL; /* will not be dereferenced. */
+ }
+
+ /* Copy from current to repopulate the vertex with correct values.
+ */
+ _save_copy_from_current( ctx );
+
+ /* Replay stored vertices to translate them to new format here.
+ *
+ * If there are copied vertices and the new (upgraded) attribute
+ * has not been defined before, this list is somewhat degenerate,
+ * and will need fixup at runtime.
+ */
+ if (tnl->save.copied.nr)
+ {
+ GLfloat *data = tnl->save.copied.buffer;
+ GLfloat *dest = tnl->save.buffer;
+ GLuint j;
+
+ /* Need to note this and fix up at runtime (or loopback):
+ */
+ if (tnl->save.currentsz[attr][0] == 0) {
+ assert(oldsz == 0);
+ tnl->save.dangling_attr_ref = GL_TRUE;
+
+/* _mesa_debug(NULL, "_save_upgrade_vertex: dangling reference attr %d\n", */
+/* attr); */
+
+#if 0
+ /* The current strategy is to punt these degenerate cases
+ * through _tnl_loopback_vertex_list(), a lower-performance
+ * option. To minimize the impact of this, artificially
+ * reduce the size of this vertex_list.
+ */
+ if (t->save.counter > 10) {
+ t->save.initial_counter = 10;
+ t->save.counter = 10;
+ }
+#endif
+ }
+
+ for (i = 0 ; i < tnl->save.copied.nr ; i++) {
+ for (j = 0 ; j < _TNL_ATTRIB_MAX ; j++) {
+ if (tnl->save.attrsz[j]) {
+ if (j == attr) {
+ if (oldsz) {
+ COPY_CLEAN_4V( dest, oldsz, data );
+ data += oldsz;
+ dest += newsz;
+ }
+ else {
+ COPY_SZ_4V( dest, newsz, tnl->save.current[attr] );
+ dest += newsz;
+ }
+ }
+ else {
+ GLint sz = tnl->save.attrsz[j];
+ COPY_SZ_4V( dest, sz, data );
+ data += sz;
+ dest += sz;
+ }
+ }
+ }
+ }
+
+ tnl->save.vbptr = dest;
+ tnl->save.counter -= tnl->save.copied.nr;
+ }
+}
+
+
+
+
+/* Helper function for 'CHOOSE' macro. Do what's necessary when an
+ * entrypoint is called for the first time.
+ */
+static void do_choose( GLuint attr, GLuint sz,
+ void (*attr_func)( const GLfloat *),
+ void (*choose1)( const GLfloat *),
+ void (*choose2)( const GLfloat *),
+ void (*choose3)( const GLfloat *),
+ void (*choose4)( const GLfloat *),
+ const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ static GLfloat id[4] = { 0, 0, 0, 1 };
+ int i;
+
+ if (tnl->save.attrsz[attr] < sz) {
+ /* New size is larger. Need to flush existing vertices and get
+ * an enlarged vertex format.
+ */
+ _save_upgrade_vertex( ctx, attr, sz );
+ }
+ else {
+ /* New size is equal or smaller - just need to fill in some
+ * zeros.
+ */
+ for (i = sz ; i <= tnl->save.attrsz[attr] ; i++)
+ tnl->save.attrptr[attr][i-1] = id[i-1];
+ }
+
+ /* Reset any active pointers for this attribute
+ */
+ tnl->save.tabfv[attr][0] = choose1;
+ tnl->save.tabfv[attr][1] = choose2;
+ tnl->save.tabfv[attr][2] = choose3;
+ tnl->save.tabfv[attr][3] = choose4;
+
+ /* Update the secondary dispatch table with the new function
+ */
+ tnl->save.tabfv[attr][sz-1] = attr_func;
+
+ (*attr_func)(v);
+}
+
+
+
+/* Only one size for each attribute may be active at once. Eg. if
+ * Color3f is installed/active, then Color4f may not be, even if the
+ * vertex actually contains 4 color coordinates. This is because the
+ * 3f version won't otherwise set color[3] to 1.0 -- this is the job
+ * of the chooser function when switching between Color4f and Color3f.
+ */
+#define ATTRFV( ATTR, N ) \
+static void save_choose_##ATTR##_##N( const GLfloat *v ); \
+ \
+static void save_attrib_##ATTR##_##N( const GLfloat *v ) \
+{ \
+ GET_CURRENT_CONTEXT( ctx ); \
+ TNLcontext *tnl = TNL_CONTEXT(ctx); \
+ \
+ if ((ATTR) == 0) { \
+ GLuint i; \
+ \
+ if (N>0) tnl->save.vbptr[0] = v[0]; \
+ if (N>1) tnl->save.vbptr[1] = v[1]; \
+ if (N>2) tnl->save.vbptr[2] = v[2]; \
+ if (N>3) tnl->save.vbptr[3] = v[3]; \
+ \
+ for (i = N; i < tnl->save.vertex_size; i++) \
+ tnl->save.vbptr[i] = tnl->save.vertex[i]; \
+ \
+ tnl->save.vbptr += tnl->save.vertex_size; \
+ \
+ if (--tnl->save.counter == 0) \
+ _save_wrap_filled_vertex( ctx ); \
+ } \
+ else { \
+ GLfloat *dest = tnl->save.attrptr[ATTR]; \
+ if (N>0) dest[0] = v[0]; \
+ if (N>1) dest[1] = v[1]; \
+ if (N>2) dest[2] = v[2]; \
+ if (N>3) dest[3] = v[3]; \
+ } \
+}
+
+#define CHOOSE( ATTR, N ) \
+static void save_choose_##ATTR##_##N( const GLfloat *v ) \
+{ \
+ do_choose(ATTR, N, \
+ save_attrib_##ATTR##_##N, \
+ save_choose_##ATTR##_1, \
+ save_choose_##ATTR##_2, \
+ save_choose_##ATTR##_3, \
+ save_choose_##ATTR##_4, \
+ v ); \
+}
+
+#define INIT(ATTR) \
+static void save_init_##ATTR( TNLcontext *tnl ) \
+{ \
+ tnl->save.tabfv[ATTR][0] = save_choose_##ATTR##_1; \
+ tnl->save.tabfv[ATTR][1] = save_choose_##ATTR##_2; \
+ tnl->save.tabfv[ATTR][2] = save_choose_##ATTR##_3; \
+ tnl->save.tabfv[ATTR][3] = save_choose_##ATTR##_4; \
+}
+
+#define ATTRS( ATTRIB ) \
+ ATTRFV( ATTRIB, 1 ) \
+ ATTRFV( ATTRIB, 2 ) \
+ ATTRFV( ATTRIB, 3 ) \
+ ATTRFV( ATTRIB, 4 ) \
+ CHOOSE( ATTRIB, 1 ) \
+ CHOOSE( ATTRIB, 2 ) \
+ CHOOSE( ATTRIB, 3 ) \
+ CHOOSE( ATTRIB, 4 ) \
+ INIT( ATTRIB ) \
+
+
+/* Generate a lot of functions. These are the actual worker
+ * functions, which are equivalent to those generated via codegen
+ * elsewhere.
+ */
+ATTRS( 0 )
+ATTRS( 1 )
+ATTRS( 2 )
+ATTRS( 3 )
+ATTRS( 4 )
+ATTRS( 5 )
+ATTRS( 6 )
+ATTRS( 7 )
+ATTRS( 8 )
+ATTRS( 9 )
+ATTRS( 10 )
+ATTRS( 11 )
+ATTRS( 12 )
+ATTRS( 13 )
+ATTRS( 14 )
+ATTRS( 15 )
+
+
+static void _save_reset_vertex( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint i;
+
+ save_init_0( tnl );
+ save_init_1( tnl );
+ save_init_2( tnl );
+ save_init_3( tnl );
+ save_init_4( tnl );
+ save_init_5( tnl );
+ save_init_6( tnl );
+ save_init_7( tnl );
+ save_init_8( tnl );
+ save_init_9( tnl );
+ save_init_10( tnl );
+ save_init_11( tnl );
+ save_init_12( tnl );
+ save_init_13( tnl );
+ save_init_14( tnl );
+ save_init_15( tnl );
+
+ for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++)
+ tnl->save.attrsz[i] = 0;
+
+ tnl->save.vertex_size = 0;
+ tnl->save.have_materials = 0;
+
+ _save_reset_counters( ctx );
+}
+
+
+
+/* Cope with aliasing of classic Vertex, Normal, etc. and the fan-out
+ * of glMultTexCoord and glProgramParamterNV by routing all these
+ * through a second level dispatch table.
+ */
+#define DISPATCH_ATTRFV( ATTR, COUNT, P ) \
+do { \
+ GET_CURRENT_CONTEXT( ctx ); \
+ TNLcontext *tnl = TNL_CONTEXT(ctx); \
+ tnl->save.tabfv[ATTR][COUNT-1]( P ); \
+} while (0)
+
+#define DISPATCH_ATTR1FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 1, V )
+#define DISPATCH_ATTR2FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 2, V )
+#define DISPATCH_ATTR3FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 3, V )
+#define DISPATCH_ATTR4FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 4, V )
+
+#define DISPATCH_ATTR1F( ATTR, S ) DISPATCH_ATTRFV( ATTR, 1, &(S) )
+
+#if defined(USE_X86_ASM) && 0 /* will break register calling convention */
+/* Naughty cheat:
+ */
+#define DISPATCH_ATTR2F( ATTR, S,T ) DISPATCH_ATTRFV( ATTR, 2, &(S) )
+#define DISPATCH_ATTR3F( ATTR, S,T,R ) DISPATCH_ATTRFV( ATTR, 3, &(S) )
+#define DISPATCH_ATTR4F( ATTR, S,T,R,Q ) DISPATCH_ATTRFV( ATTR, 4, &(S) )
+#else
+/* Safe:
+ */
+#define DISPATCH_ATTR2F( ATTR, S,T ) \
+do { \
+ GLfloat v[2]; \
+ v[0] = S; v[1] = T; \
+ DISPATCH_ATTR2FV( ATTR, v ); \
+} while (0)
+#define DISPATCH_ATTR3F( ATTR, S,T,R ) \
+do { \
+ GLfloat v[3]; \
+ v[0] = S; v[1] = T; v[2] = R; \
+ DISPATCH_ATTR3FV( ATTR, v ); \
+} while (0)
+#define DISPATCH_ATTR4F( ATTR, S,T,R,Q ) \
+do { \
+ GLfloat v[4]; \
+ v[0] = S; v[1] = T; v[2] = R; v[3] = Q; \
+ DISPATCH_ATTR4FV( ATTR, v ); \
+} while (0)
+#endif
+
+
+static void enum_error( void )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ _mesa_compile_error( ctx, GL_INVALID_ENUM, "glVertexAttrib" );
+}
+
+static void GLAPIENTRY _save_Vertex2f( GLfloat x, GLfloat y )
+{
+ DISPATCH_ATTR2F( _TNL_ATTRIB_POS, x, y );
+}
+
+static void GLAPIENTRY _save_Vertex2fv( const GLfloat *v )
+{
+ DISPATCH_ATTR2FV( _TNL_ATTRIB_POS, v );
+}
+
+static void GLAPIENTRY _save_Vertex3f( GLfloat x, GLfloat y, GLfloat z )
+{
+ DISPATCH_ATTR3F( _TNL_ATTRIB_POS, x, y, z );
+}
+
+static void GLAPIENTRY _save_Vertex3fv( const GLfloat *v )
+{
+ DISPATCH_ATTR3FV( _TNL_ATTRIB_POS, v );
+}
+
+static void GLAPIENTRY _save_Vertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+ DISPATCH_ATTR4F( _TNL_ATTRIB_POS, x, y, z, w );
+}
+
+static void GLAPIENTRY _save_Vertex4fv( const GLfloat *v )
+{
+ DISPATCH_ATTR4FV( _TNL_ATTRIB_POS, v );
+}
+
+static void GLAPIENTRY _save_TexCoord1f( GLfloat x )
+{
+ DISPATCH_ATTR1F( _TNL_ATTRIB_TEX0, x );
+}
+
+static void GLAPIENTRY _save_TexCoord1fv( const GLfloat *v )
+{
+ DISPATCH_ATTR1FV( _TNL_ATTRIB_TEX0, v );
+}
+
+static void GLAPIENTRY _save_TexCoord2f( GLfloat x, GLfloat y )
+{
+ DISPATCH_ATTR2F( _TNL_ATTRIB_TEX0, x, y );
+}
+
+static void GLAPIENTRY _save_TexCoord2fv( const GLfloat *v )
+{
+ DISPATCH_ATTR2FV( _TNL_ATTRIB_TEX0, v );
+}
+
+static void GLAPIENTRY _save_TexCoord3f( GLfloat x, GLfloat y, GLfloat z )
+{
+ DISPATCH_ATTR3F( _TNL_ATTRIB_TEX0, x, y, z );
+}
+
+static void GLAPIENTRY _save_TexCoord3fv( const GLfloat *v )
+{
+ DISPATCH_ATTR3FV( _TNL_ATTRIB_TEX0, v );
+}
+
+static void GLAPIENTRY _save_TexCoord4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+ DISPATCH_ATTR4F( _TNL_ATTRIB_TEX0, x, y, z, w );
+}
+
+static void GLAPIENTRY _save_TexCoord4fv( const GLfloat *v )
+{
+ DISPATCH_ATTR4FV( _TNL_ATTRIB_TEX0, v );
+}
+
+static void GLAPIENTRY _save_Normal3f( GLfloat x, GLfloat y, GLfloat z )
+{
+ DISPATCH_ATTR3F( _TNL_ATTRIB_NORMAL, x, y, z );
+}
+
+static void GLAPIENTRY _save_Normal3fv( const GLfloat *v )
+{
+ DISPATCH_ATTR3FV( _TNL_ATTRIB_NORMAL, v );
+}
+
+static void GLAPIENTRY _save_FogCoordfEXT( GLfloat x )
+{
+ DISPATCH_ATTR1F( _TNL_ATTRIB_FOG, x );
+}
+
+static void GLAPIENTRY _save_FogCoordfvEXT( const GLfloat *v )
+{
+ DISPATCH_ATTR1FV( _TNL_ATTRIB_FOG, v );
+}
+
+static void GLAPIENTRY _save_Color3f( GLfloat x, GLfloat y, GLfloat z )
+{
+ DISPATCH_ATTR3F( _TNL_ATTRIB_COLOR0, x, y, z );
+}
+
+static void GLAPIENTRY _save_Color3fv( const GLfloat *v )
+{
+ DISPATCH_ATTR3FV( _TNL_ATTRIB_COLOR0, v );
+}
+
+static void GLAPIENTRY _save_Color4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+ DISPATCH_ATTR4F( _TNL_ATTRIB_COLOR0, x, y, z, w );
+}
+
+static void GLAPIENTRY _save_Color4fv( const GLfloat *v )
+{
+ DISPATCH_ATTR4FV( _TNL_ATTRIB_COLOR0, v );
+}
+
+static void GLAPIENTRY _save_SecondaryColor3fEXT( GLfloat x, GLfloat y, GLfloat z )
+{
+ DISPATCH_ATTR3F( _TNL_ATTRIB_COLOR1, x, y, z );
+}
+
+static void GLAPIENTRY _save_SecondaryColor3fvEXT( const GLfloat *v )
+{
+ DISPATCH_ATTR3FV( _TNL_ATTRIB_COLOR1, v );
+}
+
+static void GLAPIENTRY _save_MultiTexCoord1f( GLenum target, GLfloat x )
+{
+ GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
+ DISPATCH_ATTR1F( attr, x );
+}
+
+static void GLAPIENTRY _save_MultiTexCoord1fv( GLenum target, const GLfloat *v )
+{
+ GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
+ DISPATCH_ATTR1FV( attr, v );
+}
+
+static void GLAPIENTRY _save_MultiTexCoord2f( GLenum target, GLfloat x, GLfloat y )
+{
+ GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
+ DISPATCH_ATTR2F( attr, x, y );
+}
+
+static void GLAPIENTRY _save_MultiTexCoord2fv( GLenum target, const GLfloat *v )
+{
+ GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
+ DISPATCH_ATTR2FV( attr, v );
+}
+
+static void GLAPIENTRY _save_MultiTexCoord3f( GLenum target, GLfloat x, GLfloat y,
+ GLfloat z)
+{
+ GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
+ DISPATCH_ATTR3F( attr, x, y, z );
+}
+
+static void GLAPIENTRY _save_MultiTexCoord3fv( GLenum target, const GLfloat *v )
+{
+ GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
+ DISPATCH_ATTR3FV( attr, v );
+}
+
+static void GLAPIENTRY _save_MultiTexCoord4f( GLenum target, GLfloat x, GLfloat y,
+ GLfloat z, GLfloat w )
+{
+ GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
+ DISPATCH_ATTR4F( attr, x, y, z, w );
+}
+
+static void GLAPIENTRY _save_MultiTexCoord4fv( GLenum target, const GLfloat *v )
+{
+ GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
+ DISPATCH_ATTR4FV( attr, v );
+}
+
+static void GLAPIENTRY _save_VertexAttrib1fNV( GLuint index, GLfloat x )
+{
+ if (index < VERT_ATTRIB_MAX)
+ DISPATCH_ATTR1F( index, x );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY _save_VertexAttrib1fvNV( GLuint index, const GLfloat *v )
+{
+ if (index < VERT_ATTRIB_MAX)
+ DISPATCH_ATTR1FV( index, v );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY _save_VertexAttrib2fNV( GLuint index, GLfloat x, GLfloat y )
+{
+ if (index < VERT_ATTRIB_MAX)
+ DISPATCH_ATTR2F( index, x, y );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY _save_VertexAttrib2fvNV( GLuint index, const GLfloat *v )
+{
+ if (index < VERT_ATTRIB_MAX)
+ DISPATCH_ATTR2FV( index, v );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY _save_VertexAttrib3fNV( GLuint index, GLfloat x, GLfloat y,
+ GLfloat z )
+{
+ if (index < VERT_ATTRIB_MAX)
+ DISPATCH_ATTR3F( index, x, y, z );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY _save_VertexAttrib3fvNV( GLuint index, const GLfloat *v )
+{
+ if (index < VERT_ATTRIB_MAX)
+ DISPATCH_ATTR3FV( index, v );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY _save_VertexAttrib4fNV( GLuint index, GLfloat x, GLfloat y,
+ GLfloat z, GLfloat w )
+{
+ if (index < VERT_ATTRIB_MAX)
+ DISPATCH_ATTR4F( index, x, y, z, w );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY _save_VertexAttrib4fvNV( GLuint index, const GLfloat *v )
+{
+ if (index < VERT_ATTRIB_MAX)
+ DISPATCH_ATTR4FV( index, v );
+ else
+ enum_error();
+}
+
+
+static void GLAPIENTRY
+_save_VertexAttrib1fARB( GLuint index, GLfloat x )
+{
+ if (index < VERT_ATTRIB_MAX)
+ DISPATCH_ATTR1F( index, x );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY
+_save_VertexAttrib1fvARB( GLuint index, const GLfloat *v )
+{
+ if (index < VERT_ATTRIB_MAX)
+ DISPATCH_ATTR1FV( index, v );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY
+_save_VertexAttrib2fARB( GLuint index, GLfloat x, GLfloat y )
+{
+ if (index < VERT_ATTRIB_MAX)
+ DISPATCH_ATTR2F( index, x, y );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY
+_save_VertexAttrib2fvARB( GLuint index, const GLfloat *v )
+{
+ if (index < VERT_ATTRIB_MAX)
+ DISPATCH_ATTR2FV( index, v );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY
+_save_VertexAttrib3fARB( GLuint index, GLfloat x, GLfloat y, GLfloat z )
+{
+ if (index < VERT_ATTRIB_MAX)
+ DISPATCH_ATTR3F( index, x, y, z );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY
+_save_VertexAttrib3fvARB( GLuint index, const GLfloat *v )
+{
+ if (index < VERT_ATTRIB_MAX)
+ DISPATCH_ATTR3FV( index, v );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY
+_save_VertexAttrib4fARB( GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w )
+{
+ if (index < VERT_ATTRIB_MAX)
+ DISPATCH_ATTR4F( index, x, y, z, w );
+ else
+ enum_error();
+}
+
+static void GLAPIENTRY
+_save_VertexAttrib4fvARB( GLuint index, const GLfloat *v )
+{
+ if (index < VERT_ATTRIB_MAX)
+ DISPATCH_ATTR4FV( index, v );
+ else
+ enum_error();
+}
+
+
+/* Materials:
+ *
+ * These are treated as per-vertex attributes, at indices above where
+ * the NV_vertex_program leaves off. There are a lot of good things
+ * about treating materials this way.
+ *
+ * However: I don't want to double the number of generated functions
+ * just to cope with this, so I unroll the 'C' varients of CHOOSE and
+ * ATTRF into this function, and dispense with codegen and
+ * second-level dispatch.
+ *
+ * There is no aliasing of material attributes with other entrypoints.
+ */
+#define MAT_ATTR( A, N, params ) \
+do { \
+ if (tnl->save.attrsz[A] < N) { \
+ _save_upgrade_vertex( ctx, A, N ); \
+ tnl->save.have_materials = GL_TRUE; \
+ } \
+ \
+ { \
+ GLfloat *dest = tnl->save.attrptr[A]; \
+ if (N>0) dest[0] = params[0]; \
+ if (N>1) dest[1] = params[1]; \
+ if (N>2) dest[2] = params[2]; \
+ if (N>3) dest[3] = params[3]; \
+ } \
+} while (0)
+
+
+#define MAT( ATTR, N, face, params ) \
+do { \
+ if (face != GL_BACK) \
+ MAT_ATTR( ATTR, N, params ); /* front */ \
+ if (face != GL_FRONT) \
+ MAT_ATTR( ATTR + 1, N, params ); /* back */ \
+} while (0)
+
+
+/* NOTE: Have to remove/deal-with colormaterial crossovers, probably
+ * later on - in the meantime just store everything.
+ */
+static void GLAPIENTRY _save_Materialfv( GLenum face, GLenum pname,
+ const GLfloat *params )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ switch (pname) {
+ case GL_EMISSION:
+ MAT( _TNL_ATTRIB_MAT_FRONT_EMISSION, 4, face, params );
+ break;
+ case GL_AMBIENT:
+ MAT( _TNL_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params );
+ break;
+ case GL_DIFFUSE:
+ MAT( _TNL_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params );
+ break;
+ case GL_SPECULAR:
+ MAT( _TNL_ATTRIB_MAT_FRONT_SPECULAR, 4, face, params );
+ break;
+ case GL_SHININESS:
+ MAT( _TNL_ATTRIB_MAT_FRONT_SHININESS, 1, face, params );
+ break;
+ case GL_COLOR_INDEXES:
+ MAT( _TNL_ATTRIB_MAT_FRONT_INDEXES, 3, face, params );
+ break;
+ case GL_AMBIENT_AND_DIFFUSE:
+ MAT( _TNL_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params );
+ MAT( _TNL_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params );
+ break;
+ default:
+ _mesa_compile_error( ctx, GL_INVALID_ENUM, "glMaterialfv" );
+ return;
+ }
+}
+
+
+#define IDX_ATTR( A, IDX ) \
+do { \
+ GET_CURRENT_CONTEXT( ctx ); \
+ TNLcontext *tnl = TNL_CONTEXT(ctx); \
+ \
+ if (tnl->save.attrsz[A] < 1) { \
+ _save_upgrade_vertex( ctx, A, 1 ); \
+ } \
+ \
+ { \
+ GLfloat *dest = tnl->save.attrptr[A]; \
+ dest[0] = IDX; \
+ } \
+} while (0)
+
+
+static void GLAPIENTRY _save_EdgeFlag( GLboolean b )
+{
+ IDX_ATTR( _TNL_ATTRIB_EDGEFLAG, (GLfloat)b );
+}
+
+static void GLAPIENTRY _save_EdgeFlagv( const GLboolean *v )
+{
+ IDX_ATTR( _TNL_ATTRIB_EDGEFLAG, (GLfloat)(v[0]) );
+}
+
+static void GLAPIENTRY _save_Indexf( GLfloat f )
+{
+ IDX_ATTR( _TNL_ATTRIB_INDEX, f );
+}
+
+static void GLAPIENTRY _save_Indexfv( const GLfloat *f )
+{
+ IDX_ATTR( _TNL_ATTRIB_INDEX, f[0] );
+}
+
+
+
+
+/* Cope with EvalCoord/CallList called within a begin/end object:
+ * -- Flush current buffer
+ * -- Fallback to opcodes for the rest of the begin/end object.
+ */
+#define FALLBACK(ctx) \
+do { \
+ TNLcontext *tnl = TNL_CONTEXT(ctx); \
+ \
+ if (tnl->save.initial_counter != tnl->save.counter || \
+ tnl->save.prim_count) \
+ _save_compile_vertex_list( ctx ); \
+ \
+ _save_copy_to_current( ctx ); \
+ _save_reset_vertex( ctx ); \
+ _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt ); \
+ ctx->Driver.SaveNeedFlush = 0; \
+} while (0)
+
+static void GLAPIENTRY _save_EvalCoord1f( GLfloat u )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FALLBACK(ctx);
+ CALL_EvalCoord1f(ctx->Save, ( u ));
+}
+
+static void GLAPIENTRY _save_EvalCoord1fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FALLBACK(ctx);
+ CALL_EvalCoord1fv(ctx->Save, ( v ));
+}
+
+static void GLAPIENTRY _save_EvalCoord2f( GLfloat u, GLfloat v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FALLBACK(ctx);
+ CALL_EvalCoord2f(ctx->Save, ( u, v ));
+}
+
+static void GLAPIENTRY _save_EvalCoord2fv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FALLBACK(ctx);
+ CALL_EvalCoord2fv(ctx->Save, ( v ));
+}
+
+static void GLAPIENTRY _save_EvalPoint1( GLint i )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FALLBACK(ctx);
+ CALL_EvalPoint1(ctx->Save, ( i ));
+}
+
+static void GLAPIENTRY _save_EvalPoint2( GLint i, GLint j )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FALLBACK(ctx);
+ CALL_EvalPoint2(ctx->Save, ( i, j ));
+}
+
+static void GLAPIENTRY _save_CallList( GLuint l )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FALLBACK(ctx);
+ CALL_CallList(ctx->Save, ( l ));
+}
+
+static void GLAPIENTRY _save_CallLists( GLsizei n, GLenum type, const GLvoid *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ FALLBACK(ctx);
+ CALL_CallLists(ctx->Save, ( n, type, v ));
+}
+
+
+
+
+/* This begin is hooked into ... Updating of
+ * ctx->Driver.CurrentSavePrimitive is already taken care of.
+ */
+static GLboolean _save_NotifyBegin( GLcontext *ctx, GLenum mode )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ if (1) {
+ GLuint i = tnl->save.prim_count++;
+
+ assert(i < tnl->save.prim_max);
+ tnl->save.prim[i].mode = mode | PRIM_BEGIN;
+ tnl->save.prim[i].start = tnl->save.initial_counter - tnl->save.counter;
+ tnl->save.prim[i].count = 0;
+
+ _mesa_install_save_vtxfmt( ctx, &tnl->save_vtxfmt );
+ ctx->Driver.SaveNeedFlush = 1;
+ return GL_TRUE;
+ }
+ else
+ return GL_FALSE;
+}
+
+
+
+static void GLAPIENTRY _save_End( void )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLint i = tnl->save.prim_count - 1;
+
+ ctx->Driver.CurrentSavePrimitive = PRIM_OUTSIDE_BEGIN_END;
+ tnl->save.prim[i].mode |= PRIM_END;
+ tnl->save.prim[i].count = ((tnl->save.initial_counter - tnl->save.counter) -
+ tnl->save.prim[i].start);
+
+ if (i == (GLint) tnl->save.prim_max - 1) {
+ _save_compile_vertex_list( ctx );
+ assert(tnl->save.copied.nr == 0);
+ }
+
+ /* Swap out this vertex format while outside begin/end. Any color,
+ * etc. received between here and the next begin will be compiled
+ * as opcodes.
+ */
+ _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt );
+}
+
+
+/* These are all errors as this vtxfmt is only installed inside
+ * begin/end pairs.
+ */
+static void GLAPIENTRY _save_DrawElements(GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ (void) mode; (void) count; (void) type; (void) indices;
+ _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glDrawElements" );
+}
+
+
+static void GLAPIENTRY _save_DrawRangeElements(GLenum mode,
+ GLuint start, GLuint end,
+ GLsizei count, GLenum type,
+ const GLvoid *indices)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ (void) mode; (void) start; (void) end; (void) count; (void) type; (void) indices;
+ _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glDrawRangeElements" );
+}
+
+static void GLAPIENTRY _save_DrawArrays(GLenum mode, GLint start, GLsizei count)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ (void) mode; (void) start; (void) count;
+ _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glDrawArrays" );
+}
+
+static void GLAPIENTRY _save_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ (void) x1; (void) y1; (void) x2; (void) y2;
+ _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glRectf" );
+}
+
+static void GLAPIENTRY _save_EvalMesh1( GLenum mode, GLint i1, GLint i2 )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ (void) mode; (void) i1; (void) i2;
+ _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glEvalMesh1" );
+}
+
+static void GLAPIENTRY _save_EvalMesh2( GLenum mode, GLint i1, GLint i2,
+ GLint j1, GLint j2 )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ (void) mode; (void) i1; (void) i2; (void) j1; (void) j2;
+ _mesa_compile_error( ctx, GL_INVALID_OPERATION, "glEvalMesh2" );
+}
+
+static void GLAPIENTRY _save_Begin( GLenum mode )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ (void) mode;
+ _mesa_compile_error( ctx, GL_INVALID_OPERATION, "Recursive glBegin" );
+}
+
+
+/* Unlike the functions above, these are to be hooked into the vtxfmt
+ * maintained in ctx->ListState, active when the list is known or
+ * suspected to be outside any begin/end primitive.
+ */
+static void GLAPIENTRY _save_OBE_Rectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ _save_NotifyBegin( ctx, GL_QUADS | PRIM_WEAK );
+ CALL_Vertex2f(GET_DISPATCH(), ( x1, y1 ));
+ CALL_Vertex2f(GET_DISPATCH(), ( x2, y1 ));
+ CALL_Vertex2f(GET_DISPATCH(), ( x2, y2 ));
+ CALL_Vertex2f(GET_DISPATCH(), ( x1, y2 ));
+ CALL_End(GET_DISPATCH(), ());
+}
+
+
+static void GLAPIENTRY _save_OBE_DrawArrays(GLenum mode, GLint start, GLsizei count)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i;
+
+ if (!_mesa_validate_DrawArrays( ctx, mode, start, count ))
+ return;
+
+ _save_NotifyBegin( ctx, mode | PRIM_WEAK );
+ for (i = 0; i < count; i++)
+ CALL_ArrayElement(GET_DISPATCH(), (start + i));
+ CALL_End(GET_DISPATCH(), ());
+}
+
+
+static void GLAPIENTRY _save_OBE_DrawElements(GLenum mode, GLsizei count, GLenum type,
+ const GLvoid *indices)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLint i;
+
+ if (!_mesa_validate_DrawElements( ctx, mode, count, type, indices ))
+ return;
+
+ _save_NotifyBegin( ctx, mode | PRIM_WEAK );
+
+ switch (type) {
+ case GL_UNSIGNED_BYTE:
+ for (i = 0 ; i < count ; i++)
+ CALL_ArrayElement(GET_DISPATCH(), ( ((GLubyte *)indices)[i] ));
+ break;
+ case GL_UNSIGNED_SHORT:
+ for (i = 0 ; i < count ; i++)
+ CALL_ArrayElement(GET_DISPATCH(), ( ((GLushort *)indices)[i] ));
+ break;
+ case GL_UNSIGNED_INT:
+ for (i = 0 ; i < count ; i++)
+ CALL_ArrayElement(GET_DISPATCH(), ( ((GLuint *)indices)[i] ));
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glDrawElements(type)" );
+ break;
+ }
+
+ CALL_End(GET_DISPATCH(), ());
+}
+
+static void GLAPIENTRY _save_OBE_DrawRangeElements(GLenum mode,
+ GLuint start, GLuint end,
+ GLsizei count, GLenum type,
+ const GLvoid *indices)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ if (_mesa_validate_DrawRangeElements( ctx, mode,
+ start, end,
+ count, type, indices ))
+ _save_OBE_DrawElements( mode, count, type, indices );
+}
+
+
+
+
+
+static void _save_vtxfmt_init( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLvertexformat *vfmt = &tnl->save_vtxfmt;
+
+ vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */
+ vfmt->Begin = _save_Begin;
+ vfmt->Color3f = _save_Color3f;
+ vfmt->Color3fv = _save_Color3fv;
+ vfmt->Color4f = _save_Color4f;
+ vfmt->Color4fv = _save_Color4fv;
+ vfmt->EdgeFlag = _save_EdgeFlag;
+ vfmt->EdgeFlagv = _save_EdgeFlagv;
+ vfmt->End = _save_End;
+ vfmt->FogCoordfEXT = _save_FogCoordfEXT;
+ vfmt->FogCoordfvEXT = _save_FogCoordfvEXT;
+ vfmt->Indexf = _save_Indexf;
+ vfmt->Indexfv = _save_Indexfv;
+ vfmt->Materialfv = _save_Materialfv;
+ vfmt->MultiTexCoord1fARB = _save_MultiTexCoord1f;
+ vfmt->MultiTexCoord1fvARB = _save_MultiTexCoord1fv;
+ vfmt->MultiTexCoord2fARB = _save_MultiTexCoord2f;
+ vfmt->MultiTexCoord2fvARB = _save_MultiTexCoord2fv;
+ vfmt->MultiTexCoord3fARB = _save_MultiTexCoord3f;
+ vfmt->MultiTexCoord3fvARB = _save_MultiTexCoord3fv;
+ vfmt->MultiTexCoord4fARB = _save_MultiTexCoord4f;
+ vfmt->MultiTexCoord4fvARB = _save_MultiTexCoord4fv;
+ vfmt->Normal3f = _save_Normal3f;
+ vfmt->Normal3fv = _save_Normal3fv;
+ vfmt->SecondaryColor3fEXT = _save_SecondaryColor3fEXT;
+ vfmt->SecondaryColor3fvEXT = _save_SecondaryColor3fvEXT;
+ vfmt->TexCoord1f = _save_TexCoord1f;
+ vfmt->TexCoord1fv = _save_TexCoord1fv;
+ vfmt->TexCoord2f = _save_TexCoord2f;
+ vfmt->TexCoord2fv = _save_TexCoord2fv;
+ vfmt->TexCoord3f = _save_TexCoord3f;
+ vfmt->TexCoord3fv = _save_TexCoord3fv;
+ vfmt->TexCoord4f = _save_TexCoord4f;
+ vfmt->TexCoord4fv = _save_TexCoord4fv;
+ vfmt->Vertex2f = _save_Vertex2f;
+ vfmt->Vertex2fv = _save_Vertex2fv;
+ vfmt->Vertex3f = _save_Vertex3f;
+ vfmt->Vertex3fv = _save_Vertex3fv;
+ vfmt->Vertex4f = _save_Vertex4f;
+ vfmt->Vertex4fv = _save_Vertex4fv;
+ vfmt->VertexAttrib1fNV = _save_VertexAttrib1fNV;
+ vfmt->VertexAttrib1fvNV = _save_VertexAttrib1fvNV;
+ vfmt->VertexAttrib2fNV = _save_VertexAttrib2fNV;
+ vfmt->VertexAttrib2fvNV = _save_VertexAttrib2fvNV;
+ vfmt->VertexAttrib3fNV = _save_VertexAttrib3fNV;
+ vfmt->VertexAttrib3fvNV = _save_VertexAttrib3fvNV;
+ vfmt->VertexAttrib4fNV = _save_VertexAttrib4fNV;
+ vfmt->VertexAttrib4fvNV = _save_VertexAttrib4fvNV;
+ vfmt->VertexAttrib1fARB = _save_VertexAttrib1fARB;
+ vfmt->VertexAttrib1fvARB = _save_VertexAttrib1fvARB;
+ vfmt->VertexAttrib2fARB = _save_VertexAttrib2fARB;
+ vfmt->VertexAttrib2fvARB = _save_VertexAttrib2fvARB;
+ vfmt->VertexAttrib3fARB = _save_VertexAttrib3fARB;
+ vfmt->VertexAttrib3fvARB = _save_VertexAttrib3fvARB;
+ vfmt->VertexAttrib4fARB = _save_VertexAttrib4fARB;
+ vfmt->VertexAttrib4fvARB = _save_VertexAttrib4fvARB;
+
+ /* This will all require us to fallback to saving the list as opcodes:
+ */
+ vfmt->CallList = _save_CallList; /* inside begin/end */
+ vfmt->CallLists = _save_CallLists; /* inside begin/end */
+ vfmt->EvalCoord1f = _save_EvalCoord1f;
+ vfmt->EvalCoord1fv = _save_EvalCoord1fv;
+ vfmt->EvalCoord2f = _save_EvalCoord2f;
+ vfmt->EvalCoord2fv = _save_EvalCoord2fv;
+ vfmt->EvalPoint1 = _save_EvalPoint1;
+ vfmt->EvalPoint2 = _save_EvalPoint2;
+
+ /* These are all errors as we at least know we are in some sort of
+ * begin/end pair:
+ */
+ vfmt->EvalMesh1 = _save_EvalMesh1;
+ vfmt->EvalMesh2 = _save_EvalMesh2;
+ vfmt->Begin = _save_Begin;
+ vfmt->Rectf = _save_Rectf;
+ vfmt->DrawArrays = _save_DrawArrays;
+ vfmt->DrawElements = _save_DrawElements;
+ vfmt->DrawRangeElements = _save_DrawRangeElements;
+
+}
+
+
+void _tnl_SaveFlushVertices( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ /* Noop when we are actually active:
+ */
+ if (ctx->Driver.CurrentSavePrimitive == PRIM_INSIDE_UNKNOWN_PRIM ||
+ ctx->Driver.CurrentSavePrimitive <= GL_POLYGON)
+ return;
+
+ if (tnl->save.initial_counter != tnl->save.counter ||
+ tnl->save.prim_count)
+ _save_compile_vertex_list( ctx );
+
+ _save_copy_to_current( ctx );
+ _save_reset_vertex( ctx );
+ ctx->Driver.SaveNeedFlush = 0;
+}
+
+void _tnl_NewList( GLcontext *ctx, GLuint list, GLenum mode )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ (void) list; (void) mode;
+
+ if (!tnl->save.prim_store)
+ tnl->save.prim_store = alloc_prim_store( ctx );
+
+ if (!tnl->save.vertex_store) {
+ tnl->save.vertex_store = alloc_vertex_store( ctx );
+ tnl->save.vbptr = tnl->save.vertex_store->buffer;
+ }
+
+ _save_reset_vertex( ctx );
+ ctx->Driver.SaveNeedFlush = 0;
+}
+
+void _tnl_EndList( GLcontext *ctx )
+{
+ (void) ctx;
+ assert(TNL_CONTEXT(ctx)->save.vertex_size == 0);
+}
+
+void _tnl_BeginCallList( GLcontext *ctx, struct mesa_display_list *dlist )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->save.replay_flags |= dlist->flags;
+ tnl->save.replay_flags |= tnl->LoopbackDListCassettes;
+}
+
+void _tnl_EndCallList( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ if (ctx->ListState.CallDepth == 1)
+ tnl->save.replay_flags = 0;
+}
+
+
+static void _tnl_destroy_vertex_list( GLcontext *ctx, void *data )
+{
+ struct tnl_vertex_list *node = (struct tnl_vertex_list *)data;
+ (void) ctx;
+
+ if ( --node->vertex_store->refcount == 0 )
+ FREE( node->vertex_store );
+
+ if ( --node->prim_store->refcount == 0 )
+ FREE( node->prim_store );
+
+ if ( node->normal_lengths )
+ FREE( node->normal_lengths );
+}
+
+
+static void _tnl_print_vertex_list( GLcontext *ctx, void *data )
+{
+ struct tnl_vertex_list *node = (struct tnl_vertex_list *)data;
+ GLuint i;
+ (void) ctx;
+
+ _mesa_debug(NULL, "TNL-VERTEX-LIST, %u vertices %d primitives, %d vertsize\n",
+ node->count,
+ node->prim_count,
+ node->vertex_size);
+
+ for (i = 0 ; i < node->prim_count ; i++) {
+ struct tnl_prim *prim = &node->prim[i];
+ _mesa_debug(NULL, " prim %d: %s %d..%d %s %s\n",
+ i,
+ _mesa_lookup_enum_by_nr(prim->mode & PRIM_MODE_MASK),
+ prim->start,
+ prim->start + prim->count,
+ (prim->mode & PRIM_BEGIN) ? "BEGIN" : "(wrap)",
+ (prim->mode & PRIM_END) ? "END" : "(wrap)");
+ }
+}
+
+
+static void _save_current_init( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLint i;
+
+ for (i = 0; i < _TNL_ATTRIB_MAT_FRONT_AMBIENT; i++) {
+ ASSERT(i < VERT_ATTRIB_MAX);
+ tnl->save.currentsz[i] = &ctx->ListState.ActiveAttribSize[i];
+ tnl->save.current[i] = ctx->ListState.CurrentAttrib[i];
+ }
+
+ for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT; i < _TNL_ATTRIB_INDEX; i++) {
+ const GLuint j = i - _TNL_ATTRIB_MAT_FRONT_AMBIENT;
+ ASSERT(j < MAT_ATTRIB_MAX);
+ tnl->save.currentsz[i] = &ctx->ListState.ActiveMaterialSize[j];
+ tnl->save.current[i] = ctx->ListState.CurrentMaterial[j];
+ }
+
+ tnl->save.currentsz[_TNL_ATTRIB_INDEX] = &ctx->ListState.ActiveIndex;
+ tnl->save.current[_TNL_ATTRIB_INDEX] = &ctx->ListState.CurrentIndex;
+
+ tnl->save.currentsz[_TNL_ATTRIB_EDGEFLAG] = &ctx->ListState.ActiveEdgeFlag;
+ tnl->save.current[_TNL_ATTRIB_EDGEFLAG] = &tnl->save.CurrentFloatEdgeFlag;
+}
+
+/**
+ * Initialize the display list compiler
+ */
+void _tnl_save_init( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct tnl_vertex_arrays *tmp = &tnl->save_inputs;
+ GLuint i;
+
+
+ for (i = 0; i < _TNL_ATTRIB_MAX; i++)
+ _mesa_vector4f_init( &tmp->Attribs[i], 0, NULL);
+
+ tnl->save.opcode_vertex_list =
+ _mesa_alloc_opcode( ctx,
+ sizeof(struct tnl_vertex_list),
+ _tnl_playback_vertex_list,
+ _tnl_destroy_vertex_list,
+ _tnl_print_vertex_list );
+
+ ctx->Driver.NotifySaveBegin = _save_NotifyBegin;
+
+ _save_vtxfmt_init( ctx );
+ _save_current_init( ctx );
+
+ /* Hook our array functions into the outside-begin-end vtxfmt in
+ * ctx->ListState.
+ */
+ ctx->ListState.ListVtxfmt.Rectf = _save_OBE_Rectf;
+ ctx->ListState.ListVtxfmt.DrawArrays = _save_OBE_DrawArrays;
+ ctx->ListState.ListVtxfmt.DrawElements = _save_OBE_DrawElements;
+ ctx->ListState.ListVtxfmt.DrawRangeElements = _save_OBE_DrawRangeElements;
+ _mesa_install_save_vtxfmt( ctx, &ctx->ListState.ListVtxfmt );
+}
+
+
+/**
+ * Deallocate the immediate-mode buffer for the given context, if
+ * its reference count goes to zero.
+ */
+void _tnl_save_destroy( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ /* Decrement the refcounts. References may still be held by
+ * display lists yet to be destroyed, so it may not yet be time to
+ * free these items.
+ */
+ if (tnl->save.prim_store &&
+ --tnl->save.prim_store->refcount == 0 )
+ FREE( tnl->save.prim_store );
+
+ if (tnl->save.vertex_store &&
+ --tnl->save.vertex_store->refcount == 0 )
+ FREE( tnl->save.vertex_store );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_save_api.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_save_api.h
new file mode 100644
index 000000000..8ffb7f573
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_save_api.h
@@ -0,0 +1,58 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 2002 Tungsten Graphics 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
+TUNGSTEN GRAPHICS 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ *
+ */
+
+#ifndef __T_SAVE_API_H__
+#define __T_SAVE_API_H__
+
+#include "t_context.h"
+
+extern GLboolean _tnl_weak_begin( GLcontext *ctx, GLenum mode );
+
+extern void _tnl_EndList( GLcontext *ctx );
+extern void _tnl_NewList( GLcontext *ctx, GLuint list, GLenum mode );
+
+extern void _tnl_EndCallList( GLcontext *ctx );
+extern void _tnl_BeginCallList( GLcontext *ctx, struct mesa_display_list *list );
+
+extern void _tnl_SaveFlushVertices( GLcontext *ctx );
+
+extern void _tnl_save_init( GLcontext *ctx );
+extern void _tnl_save_destroy( GLcontext *ctx );
+
+extern void _tnl_loopback_vertex_list( GLcontext *ctx,
+ const struct tnl_vertex_list *list );
+
+extern void _tnl_playback_vertex_list( GLcontext *ctx, void *data );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_save_loopback.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_save_loopback.c
new file mode 100644
index 000000000..7b2e4a432
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_save_loopback.c
@@ -0,0 +1,342 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+/* Author:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "enums.h"
+#include "glapi.h"
+#include "imports.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "t_context.h"
+#include "t_save_api.h"
+#include "dispatch.h"
+
+/* If someone compiles a display list like:
+ * glBegin(Triangles)
+ * glVertex()
+ * ... lots of vertices ...
+ * glEnd()
+ *
+ * or:
+ * glDrawArrays(...)
+ *
+ * and then tries to execute it like this:
+ *
+ * glBegin(Lines)
+ * glCallList()
+ * glEnd()
+ *
+ * it will wind up in here, as the vertex copying used when wrapping
+ * buffers in list compilation (Triangles) won't be right for how the
+ * list is being executed (as Lines).
+ *
+ * This could be avoided by not compiling as vertex_lists until after
+ * the first glEnd() has been seen. However, that would miss an
+ * important category of display lists, for the sake of a degenerate
+ * usage.
+ *
+ * Further, replaying degenerately-called lists in this fashion is
+ * probably still faster than the replay using opcodes.
+ */
+
+typedef void (*attr_func)( GLcontext *ctx, GLint target, const GLfloat * );
+
+
+/* Wrapper functions in case glVertexAttrib*fvNV doesn't exist */
+static void VertexAttrib1fvNV(GLcontext *ctx, GLint target, const GLfloat *v)
+{
+ CALL_VertexAttrib1fvNV(ctx->Exec, (target, v));
+}
+
+static void VertexAttrib2fvNV(GLcontext *ctx, GLint target, const GLfloat *v)
+{
+ CALL_VertexAttrib2fvNV(ctx->Exec, (target, v));
+}
+
+static void VertexAttrib3fvNV(GLcontext *ctx, GLint target, const GLfloat *v)
+{
+ CALL_VertexAttrib3fvNV(ctx->Exec, (target, v));
+}
+
+static void VertexAttrib4fvNV(GLcontext *ctx, GLint target, const GLfloat *v)
+{
+ CALL_VertexAttrib4fvNV(ctx->Exec, (target, v));
+}
+
+static attr_func vert_attrfunc[4] = {
+ VertexAttrib1fvNV,
+ VertexAttrib2fvNV,
+ VertexAttrib3fvNV,
+ VertexAttrib4fvNV
+};
+
+
+static void VertexAttrib1fvARB(GLcontext *ctx, GLint target, const GLfloat *v)
+{
+ CALL_VertexAttrib1fvARB(ctx->Exec, (target, v));
+}
+
+static void VertexAttrib2fvARB(GLcontext *ctx, GLint target, const GLfloat *v)
+{
+ CALL_VertexAttrib2fvARB(ctx->Exec, (target, v));
+}
+
+static void VertexAttrib3fvARB(GLcontext *ctx, GLint target, const GLfloat *v)
+{
+ CALL_VertexAttrib3fvARB(ctx->Exec, (target, v));
+}
+
+static void VertexAttrib4fvARB(GLcontext *ctx, GLint target, const GLfloat *v)
+{
+ CALL_VertexAttrib4fvARB(ctx->Exec, (target, v));
+}
+
+static attr_func vert_attrfunc_arb[4] = {
+ VertexAttrib1fvARB,
+ VertexAttrib2fvARB,
+ VertexAttrib3fvARB,
+ VertexAttrib4fvARB
+};
+
+
+
+
+
+
+
+static void mat_attr1fv( GLcontext *ctx, GLint target, const GLfloat *v )
+{
+ switch (target) {
+ case _TNL_ATTRIB_MAT_FRONT_SHININESS:
+ CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_SHININESS, v ));
+ break;
+ case _TNL_ATTRIB_MAT_BACK_SHININESS:
+ CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_SHININESS, v ));
+ break;
+ }
+}
+
+
+static void mat_attr3fv( GLcontext *ctx, GLint target, const GLfloat *v )
+{
+ switch (target) {
+ case _TNL_ATTRIB_MAT_FRONT_INDEXES:
+ CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_COLOR_INDEXES, v ));
+ break;
+ case _TNL_ATTRIB_MAT_BACK_INDEXES:
+ CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_COLOR_INDEXES, v ));
+ break;
+ }
+}
+
+
+static void mat_attr4fv( GLcontext *ctx, GLint target, const GLfloat *v )
+{
+ switch (target) {
+ case _TNL_ATTRIB_MAT_FRONT_EMISSION:
+ CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_EMISSION, v ));
+ break;
+ case _TNL_ATTRIB_MAT_BACK_EMISSION:
+ CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_EMISSION, v ));
+ break;
+ case _TNL_ATTRIB_MAT_FRONT_AMBIENT:
+ CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_AMBIENT, v ));
+ break;
+ case _TNL_ATTRIB_MAT_BACK_AMBIENT:
+ CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_AMBIENT, v ));
+ break;
+ case _TNL_ATTRIB_MAT_FRONT_DIFFUSE:
+ CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_DIFFUSE, v ));
+ break;
+ case _TNL_ATTRIB_MAT_BACK_DIFFUSE:
+ CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_DIFFUSE, v ));
+ break;
+ case _TNL_ATTRIB_MAT_FRONT_SPECULAR:
+ CALL_Materialfv(ctx->Exec, ( GL_FRONT, GL_SPECULAR, v ));
+ break;
+ case _TNL_ATTRIB_MAT_BACK_SPECULAR:
+ CALL_Materialfv(ctx->Exec, ( GL_BACK, GL_SPECULAR, v ));
+ break;
+ }
+}
+
+
+static attr_func mat_attrfunc[4] = {
+ mat_attr1fv,
+ NULL,
+ mat_attr3fv,
+ mat_attr4fv
+};
+
+
+static void index_attr1fv(GLcontext *ctx, GLint target, const GLfloat *v)
+{
+ (void) target;
+ CALL_Indexf(ctx->Exec, (v[0]));
+}
+
+static void edgeflag_attr1fv(GLcontext *ctx, GLint target, const GLfloat *v)
+{
+ (void) target;
+ CALL_EdgeFlag(ctx->Exec, ((GLboolean)(v[0] == 1.0)));
+}
+
+struct loopback_attr {
+ GLint target;
+ GLint sz;
+ attr_func func;
+};
+
+/* Don't emit ends and begins on wrapped primitives. Don't replay
+ * wrapped vertices. If we get here, it's probably because the the
+ * precalculated wrapping is wrong.
+ */
+static void loopback_prim( GLcontext *ctx,
+ const struct tnl_vertex_list *list, GLuint i,
+ const struct loopback_attr *la, GLuint nr )
+{
+ struct tnl_prim *prim = &list->prim[i];
+ GLint begin = prim->start;
+ GLint end = begin + prim->count;
+ GLfloat *data;
+ GLint j;
+ GLuint k;
+
+ if (prim->mode & PRIM_BEGIN) {
+ CALL_Begin(GET_DISPATCH(), ( prim->mode & PRIM_MODE_MASK ));
+ }
+ else {
+ assert(i == 0);
+ assert(begin == 0);
+ begin += list->wrap_count;
+ }
+
+ data = list->buffer + begin * list->vertex_size;
+
+ for (j = begin ; j < end ; j++) {
+ GLfloat *tmp = data + la[0].sz;
+
+ for (k = 1 ; k < nr ; k++) {
+ la[k].func( ctx, la[k].target, tmp );
+ tmp += la[k].sz;
+ }
+
+ /* Fire the vertex
+ */
+ la[0].func( ctx, VERT_ATTRIB_POS, data );
+ data = tmp;
+ }
+
+ if (prim->mode & PRIM_END) {
+ CALL_End(GET_DISPATCH(), ());
+ }
+ else {
+ assert (i == list->prim_count-1);
+ }
+}
+
+/* Primitives generated by DrawArrays/DrawElements/Rectf may be
+ * caught here. If there is no primitive in progress, execute them
+ * normally, otherwise need to track and discard the generated
+ * primitives.
+ */
+static void loopback_weak_prim( GLcontext *ctx,
+ const struct tnl_vertex_list *list, GLuint i,
+ const struct loopback_attr *la, GLuint nr )
+{
+ if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END)
+ loopback_prim( ctx, list, i, la, nr );
+ else {
+ struct tnl_prim *prim = &list->prim[i];
+
+ /* Use the prim_weak flag to ensure that if this primitive
+ * wraps, we don't mistake future vertex_lists for part of the
+ * surrounding primitive.
+ *
+ * While this flag is set, we are simply disposing of data
+ * generated by an operation now known to be a noop.
+ */
+ if (prim->mode & PRIM_BEGIN)
+ ctx->Driver.CurrentExecPrimitive |= PRIM_WEAK;
+ if (prim->mode & PRIM_END)
+ ctx->Driver.CurrentExecPrimitive &= ~PRIM_WEAK;
+ }
+}
+
+
+
+void _tnl_loopback_vertex_list( GLcontext *ctx,
+ const struct tnl_vertex_list *list )
+{
+ struct loopback_attr la[_TNL_ATTRIB_MAX];
+ GLuint i, nr = 0;
+
+ for (i = 0 ; i <= _TNL_ATTRIB_TEX7 ; i++) {
+ if (list->attrsz[i]) {
+ la[nr].target = i;
+ la[nr].sz = list->attrsz[i];
+ la[nr].func = vert_attrfunc[list->attrsz[i]-1];
+ nr++;
+ }
+ }
+
+ for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT ;
+ i <= _TNL_ATTRIB_MAT_BACK_INDEXES ;
+ i++) {
+ if (list->attrsz[i]) {
+ la[nr].target = i;
+ la[nr].sz = list->attrsz[i];
+ la[nr].func = mat_attrfunc[list->attrsz[i]-1];
+ nr++;
+ }
+ }
+
+ if (list->attrsz[_TNL_ATTRIB_EDGEFLAG]) {
+ la[nr].target = _TNL_ATTRIB_EDGEFLAG;
+ la[nr].sz = list->attrsz[_TNL_ATTRIB_EDGEFLAG];
+ la[nr].func = edgeflag_attr1fv;
+ nr++;
+ }
+
+ if (list->attrsz[_TNL_ATTRIB_INDEX]) {
+ la[nr].target = _TNL_ATTRIB_INDEX;
+ la[nr].sz = list->attrsz[_TNL_ATTRIB_INDEX];
+ la[nr].func = index_attr1fv;
+ nr++;
+ }
+
+ /* XXX ARB vertex attribs */
+
+ for (i = 0 ; i < list->prim_count ; i++) {
+ if (list->prim[i].mode & PRIM_WEAK)
+ loopback_weak_prim( ctx, list, i, la, nr );
+ else
+ loopback_prim( ctx, list, i, la, nr );
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_save_playback.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_save_playback.c
new file mode 100644
index 000000000..995964c96
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_save_playback.c
@@ -0,0 +1,215 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+/* Author:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "light.h"
+#include "state.h"
+#include "t_pipeline.h"
+#include "t_save_api.h"
+#include "t_vtx_api.h"
+
+static INLINE GLint get_size( const GLfloat *f )
+{
+ if (f[3] != 1.0) return 4;
+ if (f[2] != 0.0) return 3;
+ return 2;
+}
+
+
+/* Some nasty stuff still hanging on here.
+ *
+ * TODO - remove VB->ColorPtr, etc and just use the AttrPtr's.
+ */
+static void _tnl_bind_vertex_list( GLcontext *ctx,
+ const struct tnl_vertex_list *node )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ struct tnl_vertex_arrays *tmp = &tnl->save_inputs;
+ GLfloat *data = node->buffer;
+ GLuint attr, i;
+
+ /* Setup constant data in the VB.
+ */
+ VB->Count = node->count;
+ VB->Primitive = node->prim;
+ VB->PrimitiveCount = node->prim_count;
+ VB->Elts = NULL;
+ VB->NormalLengthPtr = node->normal_lengths;
+
+ for (attr = 0; attr <= _TNL_ATTRIB_INDEX; attr++) {
+ if (node->attrsz[attr]) {
+ tmp->Attribs[attr].count = node->count;
+ tmp->Attribs[attr].data = (GLfloat (*)[4]) data;
+ tmp->Attribs[attr].start = data;
+ tmp->Attribs[attr].size = node->attrsz[attr];
+ tmp->Attribs[attr].stride = node->vertex_size * sizeof(GLfloat);
+ VB->AttribPtr[attr] = &tmp->Attribs[attr];
+ data += node->attrsz[attr];
+ }
+ else {
+ tmp->Attribs[attr].count = 1;
+ tmp->Attribs[attr].data = (GLfloat (*)[4]) tnl->vtx.current[attr];
+ tmp->Attribs[attr].start = tnl->vtx.current[attr];
+ tmp->Attribs[attr].size = get_size( tnl->vtx.current[attr] );
+ tmp->Attribs[attr].stride = 0;
+ VB->AttribPtr[attr] = &tmp->Attribs[attr];
+ }
+ }
+
+
+ /* Copy edgeflag to a contiguous array
+ */
+ if (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL) {
+ if (node->attrsz[_TNL_ATTRIB_EDGEFLAG]) {
+ VB->EdgeFlag = _tnl_translate_edgeflag( ctx, data,
+ node->count,
+ node->vertex_size );
+ data++;
+ }
+ else
+ VB->EdgeFlag = _tnl_import_current_edgeflag( ctx, node->count );
+ }
+
+ /* Legacy pointers -- remove one day.
+ */
+ VB->ObjPtr = VB->AttribPtr[_TNL_ATTRIB_POS];
+ VB->NormalPtr = VB->AttribPtr[_TNL_ATTRIB_NORMAL];
+ VB->ColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR0];
+ VB->ColorPtr[1] = NULL;
+ VB->IndexPtr[0] = VB->AttribPtr[_TNL_ATTRIB_INDEX];
+ VB->IndexPtr[1] = NULL;
+ VB->SecondaryColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR1];
+ VB->SecondaryColorPtr[1] = NULL;
+ VB->FogCoordPtr = VB->AttribPtr[_TNL_ATTRIB_FOG];
+
+ for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
+ VB->TexCoordPtr[i] = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i];
+ }
+}
+
+static void _playback_copy_to_current( GLcontext *ctx,
+ const struct tnl_vertex_list *node )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ const GLfloat *data;
+ GLuint i;
+
+ if (node->count)
+ data = node->buffer + (node->count-1) * node->vertex_size;
+ else
+ data = node->buffer;
+
+ for (i = _TNL_ATTRIB_POS+1 ; i <= _TNL_ATTRIB_INDEX ; i++) {
+ if (node->attrsz[i]) {
+ COPY_CLEAN_4V(tnl->vtx.current[i], node->attrsz[i], data);
+ data += node->attrsz[i];
+ }
+ }
+
+ /* Edgeflag requires special treatment:
+ */
+ if (node->attrsz[_TNL_ATTRIB_EDGEFLAG]) {
+ ctx->Current.EdgeFlag = (data[0] == 1.0);
+ }
+
+ /* Colormaterial -- this kindof sucks.
+ */
+ if (ctx->Light.ColorMaterialEnabled) {
+ _mesa_update_color_material(ctx, ctx->Current.Attrib[VERT_ATTRIB_COLOR0]);
+ }
+
+ if (node->have_materials) {
+ tnl->Driver.NotifyMaterialChange( ctx );
+ }
+
+ /* CurrentExecPrimitive
+ */
+ if (node->prim_count) {
+ GLenum mode = node->prim[node->prim_count - 1].mode;
+ if (mode & PRIM_END)
+ ctx->Driver.CurrentExecPrimitive = PRIM_OUTSIDE_BEGIN_END;
+ else
+ ctx->Driver.CurrentExecPrimitive = (mode & PRIM_MODE_MASK);
+ }
+}
+
+
+/**
+ * Execute the buffer and save copied verts.
+ */
+void _tnl_playback_vertex_list( GLcontext *ctx, void *data )
+{
+ const struct tnl_vertex_list *node = (const struct tnl_vertex_list *) data;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ FLUSH_CURRENT(ctx, 0);
+
+ if (node->prim_count > 0 && node->count > 0) {
+
+ if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END &&
+ (node->prim[0].mode & PRIM_BEGIN)) {
+
+ /* Degenerate case: list is called inside begin/end pair and
+ * includes operations such as glBegin or glDrawArrays.
+ */
+ _mesa_error( ctx, GL_INVALID_OPERATION, "displaylist recursive begin");
+ _tnl_loopback_vertex_list( ctx, node );
+ return;
+ }
+ else if (tnl->save.replay_flags) {
+ /* Various degnerate cases: translate into immediate mode
+ * calls rather than trying to execute in place.
+ */
+ _tnl_loopback_vertex_list( ctx, node );
+ return;
+ }
+
+ if (ctx->NewState)
+ _mesa_update_state( ctx );
+
+ if ((ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) ||
+ (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBegin (invalid vertex/fragment program)");
+ return;
+ }
+
+ _tnl_bind_vertex_list( ctx, node );
+
+ tnl->Driver.RunPipeline( ctx );
+ }
+
+ /* Copy to current?
+ */
+ _playback_copy_to_current( ctx, node );
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram.c
new file mode 100644
index 000000000..0b76bd008
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram.c
@@ -0,0 +1,1496 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.4.1
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file t_arb_program.c
+ * Compile vertex programs to an intermediate representation.
+ * Execute vertex programs over a buffer of vertices.
+ * \author Keith Whitwell, Brian Paul
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "imports.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "arbprogparse.h"
+#include "light.h"
+#include "program.h"
+#include "math/m_matrix.h"
+#include "math/m_translate.h"
+#include "t_context.h"
+#include "t_pipeline.h"
+#include "t_vb_arbprogram.h"
+#include "tnl.h"
+
+
+#define DISASSEM 0
+
+/*--------------------------------------------------------------------------- */
+
+struct opcode_info {
+ GLuint nr_args;
+ const char *string;
+ void (*print)( union instruction , const struct opcode_info * );
+};
+
+struct compilation {
+ GLuint reg_active;
+ union instruction *csr;
+};
+
+
+#define ARB_VP_MACHINE(stage) ((struct arb_vp_machine *)(stage->privatePtr))
+
+#define PUFF(x) ((x)[1] = (x)[2] = (x)[3] = (x)[0])
+
+
+
+/* Lower precision functions for the EXP, LOG and LIT opcodes. The
+ * LOG2() implementation is probably not accurate enough, and the
+ * attempted optimization for Exp2 is definitely not accurate
+ * enough - it discards all of t's fractional bits!
+ */
+static GLfloat RoughApproxLog2(GLfloat t)
+{
+ return LOG2(t);
+}
+
+static GLfloat RoughApproxExp2(GLfloat t)
+{
+#if 0
+ fi_type fi;
+ fi.i = (GLint) t;
+ fi.i = (fi.i << 23) + 0x3f800000;
+ return fi.f;
+#else
+ return (GLfloat) _mesa_pow(2.0, t);
+#endif
+}
+
+static GLfloat RoughApproxPower(GLfloat x, GLfloat y)
+{
+ if (x == 0.0 && y == 0.0)
+ return 1.0; /* spec requires this */
+ else
+ return RoughApproxExp2(y * RoughApproxLog2(x));
+}
+
+
+/* Higher precision functions for the EX2, LG2 and POW opcodes:
+ */
+static GLfloat ApproxLog2(GLfloat t)
+{
+ return (GLfloat) (log(t) * 1.442695F);
+}
+
+static GLfloat ApproxExp2(GLfloat t)
+{
+ return (GLfloat) _mesa_pow(2.0, t);
+}
+
+static GLfloat ApproxPower(GLfloat x, GLfloat y)
+{
+ return (GLfloat) _mesa_pow(x, y);
+}
+
+static GLfloat rough_approx_log2_0_1(GLfloat x)
+{
+ return LOG2(x);
+}
+
+
+
+
+/**
+ * Perform a reduced swizzle:
+ */
+static void do_RSW( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.rsw.dst];
+ const GLfloat *arg0 = m->File[op.rsw.file0][op.rsw.idx0];
+ GLuint swz = op.rsw.swz;
+ GLuint neg = op.rsw.neg;
+ GLfloat tmp[4];
+
+ /* Need a temporary to be correct in the case where result == arg0.
+ */
+ COPY_4V(tmp, arg0);
+
+ result[0] = tmp[GET_RSW(swz, 0)];
+ result[1] = tmp[GET_RSW(swz, 1)];
+ result[2] = tmp[GET_RSW(swz, 2)];
+ result[3] = tmp[GET_RSW(swz, 3)];
+
+ if (neg) {
+ if (neg & 0x1) result[0] = -result[0];
+ if (neg & 0x2) result[1] = -result[1];
+ if (neg & 0x4) result[2] = -result[2];
+ if (neg & 0x8) result[3] = -result[3];
+ }
+}
+
+/* Used to implement write masking. To make things easier for the sse
+ * generator I've gone back to a 1 argument version of this function
+ * (dst.msk = arg), rather than the semantically cleaner (dst = SEL
+ * arg0, arg1, msk)
+ *
+ * That means this is the only instruction which doesn't write a full
+ * 4 dwords out. This would make such a program harder to analyse,
+ * but it looks like analysis is going to take place on a higher level
+ * anyway.
+ */
+static void do_MSK( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *dst = m->File[0][op.msk.dst];
+ const GLfloat *arg = m->File[op.msk.file][op.msk.idx];
+
+ if (op.msk.mask & 0x1) dst[0] = arg[0];
+ if (op.msk.mask & 0x2) dst[1] = arg[1];
+ if (op.msk.mask & 0x4) dst[2] = arg[2];
+ if (op.msk.mask & 0x8) dst[3] = arg[3];
+}
+
+
+static void do_PRT( struct arb_vp_machine *m, union instruction op )
+{
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+
+ _mesa_printf("%d: %f %f %f %f\n", m->vtx_nr,
+ arg0[0], arg0[1], arg0[2], arg0[3]);
+}
+
+
+/**
+ * The traditional ALU and texturing instructions. All operate on
+ * internal registers and ignore write masks and swizzling issues.
+ */
+
+static void do_ABS( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+
+ result[0] = (arg0[0] < 0.0) ? -arg0[0] : arg0[0];
+ result[1] = (arg0[1] < 0.0) ? -arg0[1] : arg0[1];
+ result[2] = (arg0[2] < 0.0) ? -arg0[2] : arg0[2];
+ result[3] = (arg0[3] < 0.0) ? -arg0[3] : arg0[3];
+}
+
+static void do_ADD( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+ const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
+
+ result[0] = arg0[0] + arg1[0];
+ result[1] = arg0[1] + arg1[1];
+ result[2] = arg0[2] + arg1[2];
+ result[3] = arg0[3] + arg1[3];
+}
+
+
+static void do_DP3( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+ const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
+
+ result[0] = (arg0[0] * arg1[0] +
+ arg0[1] * arg1[1] +
+ arg0[2] * arg1[2]);
+
+ PUFF(result);
+}
+
+
+
+static void do_DP4( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+ const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
+
+ result[0] = (arg0[0] * arg1[0] +
+ arg0[1] * arg1[1] +
+ arg0[2] * arg1[2] +
+ arg0[3] * arg1[3]);
+
+ PUFF(result);
+}
+
+static void do_DPH( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+ const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
+
+ result[0] = (arg0[0] * arg1[0] +
+ arg0[1] * arg1[1] +
+ arg0[2] * arg1[2] +
+ 1.0 * arg1[3]);
+
+ PUFF(result);
+}
+
+static void do_DST( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+ const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
+
+ /* This should be ok even if result == arg0 or result == arg1.
+ */
+ result[0] = 1.0F;
+ result[1] = arg0[1] * arg1[1];
+ result[2] = arg0[2];
+ result[3] = arg1[3];
+}
+
+
+/* Intended to be high precision:
+ */
+static void do_EX2( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+
+ result[0] = (GLfloat)ApproxExp2(arg0[0]);
+ PUFF(result);
+}
+
+
+/* Allowed to be lower precision:
+ */
+static void do_EXP( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+ GLfloat tmp = arg0[0];
+ GLfloat flr_tmp = FLOORF(tmp);
+ GLfloat frac_tmp = tmp - flr_tmp;
+
+ result[0] = LDEXPF(1.0, (int)flr_tmp);
+ result[1] = frac_tmp;
+ result[2] = LDEXPF(rough_approx_log2_0_1(frac_tmp), (int)flr_tmp);
+ result[3] = 1.0F;
+}
+
+static void do_FLR( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+
+ result[0] = FLOORF(arg0[0]);
+ result[1] = FLOORF(arg0[1]);
+ result[2] = FLOORF(arg0[2]);
+ result[3] = FLOORF(arg0[3]);
+}
+
+static void do_FRC( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+
+ result[0] = arg0[0] - FLOORF(arg0[0]);
+ result[1] = arg0[1] - FLOORF(arg0[1]);
+ result[2] = arg0[2] - FLOORF(arg0[2]);
+ result[3] = arg0[3] - FLOORF(arg0[3]);
+}
+
+/* High precision log base 2:
+ */
+static void do_LG2( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+
+ result[0] = ApproxLog2(arg0[0]);
+ PUFF(result);
+}
+
+
+
+static void do_LIT( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+ GLfloat tmp[4];
+
+ tmp[0] = 1.0;
+ tmp[1] = arg0[0];
+ if (arg0[0] > 0.0) {
+ tmp[2] = RoughApproxPower(arg0[1], arg0[3]);
+ }
+ else {
+ tmp[2] = 0.0;
+ }
+ tmp[3] = 1.0;
+
+
+ COPY_4V(result, tmp);
+}
+
+
+/* Intended to allow a lower precision than required for LG2 above.
+ */
+static void do_LOG( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+ GLfloat tmp = FABSF(arg0[0]);
+ int exponent;
+ GLfloat mantissa = FREXPF(tmp, &exponent);
+
+ result[0] = (GLfloat) (exponent - 1);
+ result[1] = 2.0 * mantissa; /* map [.5, 1) -> [1, 2) */
+ result[2] = exponent + LOG2(mantissa);
+ result[3] = 1.0;
+}
+
+static void do_MAX( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+ const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
+
+ result[0] = (arg0[0] > arg1[0]) ? arg0[0] : arg1[0];
+ result[1] = (arg0[1] > arg1[1]) ? arg0[1] : arg1[1];
+ result[2] = (arg0[2] > arg1[2]) ? arg0[2] : arg1[2];
+ result[3] = (arg0[3] > arg1[3]) ? arg0[3] : arg1[3];
+}
+
+
+static void do_MIN( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+ const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
+
+ result[0] = (arg0[0] < arg1[0]) ? arg0[0] : arg1[0];
+ result[1] = (arg0[1] < arg1[1]) ? arg0[1] : arg1[1];
+ result[2] = (arg0[2] < arg1[2]) ? arg0[2] : arg1[2];
+ result[3] = (arg0[3] < arg1[3]) ? arg0[3] : arg1[3];
+}
+
+static void do_MOV( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+
+ result[0] = arg0[0];
+ result[1] = arg0[1];
+ result[2] = arg0[2];
+ result[3] = arg0[3];
+}
+
+static void do_MUL( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+ const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
+
+ result[0] = arg0[0] * arg1[0];
+ result[1] = arg0[1] * arg1[1];
+ result[2] = arg0[2] * arg1[2];
+ result[3] = arg0[3] * arg1[3];
+}
+
+
+/* Intended to be "high" precision
+ */
+static void do_POW( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+ const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
+
+ result[0] = (GLfloat)ApproxPower(arg0[0], arg1[0]);
+ PUFF(result);
+}
+
+static void do_REL( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ GLuint idx = (op.alu.idx0 + (GLint)m->File[0][REG_ADDR][0]) & (MAX_NV_VERTEX_PROGRAM_PARAMS-1);
+ const GLfloat *arg0 = m->File[op.alu.file0][idx];
+
+ result[0] = arg0[0];
+ result[1] = arg0[1];
+ result[2] = arg0[2];
+ result[3] = arg0[3];
+}
+
+static void do_RCP( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+
+ result[0] = 1.0F / arg0[0];
+ PUFF(result);
+}
+
+static void do_RSQ( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+
+ result[0] = INV_SQRTF(FABSF(arg0[0]));
+ PUFF(result);
+}
+
+
+static void do_SGE( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+ const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
+
+ result[0] = (arg0[0] >= arg1[0]) ? 1.0F : 0.0F;
+ result[1] = (arg0[1] >= arg1[1]) ? 1.0F : 0.0F;
+ result[2] = (arg0[2] >= arg1[2]) ? 1.0F : 0.0F;
+ result[3] = (arg0[3] >= arg1[3]) ? 1.0F : 0.0F;
+}
+
+
+static void do_SLT( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+ const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
+
+ result[0] = (arg0[0] < arg1[0]) ? 1.0F : 0.0F;
+ result[1] = (arg0[1] < arg1[1]) ? 1.0F : 0.0F;
+ result[2] = (arg0[2] < arg1[2]) ? 1.0F : 0.0F;
+ result[3] = (arg0[3] < arg1[3]) ? 1.0F : 0.0F;
+}
+
+static void do_SUB( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+ const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
+
+ result[0] = arg0[0] - arg1[0];
+ result[1] = arg0[1] - arg1[1];
+ result[2] = arg0[2] - arg1[2];
+ result[3] = arg0[3] - arg1[3];
+}
+
+
+static void do_XPD( struct arb_vp_machine *m, union instruction op )
+{
+ GLfloat *result = m->File[0][op.alu.dst];
+ const GLfloat *arg0 = m->File[op.alu.file0][op.alu.idx0];
+ const GLfloat *arg1 = m->File[op.alu.file1][op.alu.idx1];
+ GLfloat tmp[3];
+
+ tmp[0] = arg0[1] * arg1[2] - arg0[2] * arg1[1];
+ tmp[1] = arg0[2] * arg1[0] - arg0[0] * arg1[2];
+ tmp[2] = arg0[0] * arg1[1] - arg0[1] * arg1[0];
+
+ /* Need a temporary to be correct in the case where result == arg0
+ * or result == arg1.
+ */
+ result[0] = tmp[0];
+ result[1] = tmp[1];
+ result[2] = tmp[2];
+}
+
+static void do_NOP( struct arb_vp_machine *m, union instruction op )
+{
+}
+
+/* Some useful debugging functions:
+ */
+static void print_mask( GLuint mask )
+{
+ _mesa_printf(".");
+ if (mask&0x1) _mesa_printf("x");
+ if (mask&0x2) _mesa_printf("y");
+ if (mask&0x4) _mesa_printf("z");
+ if (mask&0x8) _mesa_printf("w");
+}
+
+static void print_reg( GLuint file, GLuint reg )
+{
+ static const char *reg_file[] = {
+ "REG",
+ "LOCAL_PARAM",
+ "ENV_PARAM",
+ "STATE_VAR",
+ };
+
+ if (file == 0) {
+ if (reg == REG_RES)
+ _mesa_printf("RES");
+ else if (reg >= REG_ARG0 && reg <= REG_ARG1)
+ _mesa_printf("ARG%d", reg - REG_ARG0);
+ else if (reg >= REG_TMP0 && reg <= REG_TMP11)
+ _mesa_printf("TMP%d", reg - REG_TMP0);
+ else if (reg >= REG_IN0 && reg <= REG_IN31)
+ _mesa_printf("IN%d", reg - REG_IN0);
+ else if (reg >= REG_OUT0 && reg <= REG_OUT14)
+ _mesa_printf("OUT%d", reg - REG_OUT0);
+ else if (reg == REG_ADDR)
+ _mesa_printf("ADDR");
+ else if (reg == REG_ID)
+ _mesa_printf("ID");
+ else
+ _mesa_printf("REG%d", reg);
+ }
+ else
+ _mesa_printf("%s:%d", reg_file[file], reg);
+}
+
+
+static void print_RSW( union instruction op, const struct opcode_info *info )
+{
+ GLuint swz = op.rsw.swz;
+ GLuint neg = op.rsw.neg;
+ GLuint i;
+
+ _mesa_printf("%s ", info->string);
+ print_reg(0, op.rsw.dst);
+ _mesa_printf(", ");
+ print_reg(op.rsw.file0, op.rsw.idx0);
+ _mesa_printf(".");
+ for (i = 0; i < 4; i++, swz >>= 2) {
+ const char *cswz = "xyzw";
+ if (neg & (1<<i))
+ _mesa_printf("-");
+ _mesa_printf("%c", cswz[swz&0x3]);
+ }
+ _mesa_printf("\n");
+}
+
+
+static void print_ALU( union instruction op, const struct opcode_info *info )
+{
+ _mesa_printf("%s ", info->string);
+ print_reg(0, op.alu.dst);
+ _mesa_printf(", ");
+ print_reg(op.alu.file0, op.alu.idx0);
+ if (info->nr_args > 1) {
+ _mesa_printf(", ");
+ print_reg(op.alu.file1, op.alu.idx1);
+ }
+ _mesa_printf("\n");
+}
+
+static void print_MSK( union instruction op, const struct opcode_info *info )
+{
+ _mesa_printf("%s ", info->string);
+ print_reg(0, op.msk.dst);
+ print_mask(op.msk.mask);
+ _mesa_printf(", ");
+ print_reg(op.msk.file, op.msk.idx);
+ _mesa_printf("\n");
+}
+
+
+static void print_NOP( union instruction op, const struct opcode_info *info )
+{
+}
+
+#define NOP 0
+#define ALU 1
+#define SWZ 2
+
+static const struct opcode_info opcode_info[] =
+{
+ { 1, "ABS", print_ALU },
+ { 2, "ADD", print_ALU },
+ { 1, "ARL", print_NOP },
+ { 2, "DP3", print_ALU },
+ { 2, "DP4", print_ALU },
+ { 2, "DPH", print_ALU },
+ { 2, "DST", print_ALU },
+ { 0, "END", print_NOP },
+ { 1, "EX2", print_ALU },
+ { 1, "EXP", print_ALU },
+ { 1, "FLR", print_ALU },
+ { 1, "FRC", print_ALU },
+ { 1, "LG2", print_ALU },
+ { 1, "LIT", print_ALU },
+ { 1, "LOG", print_ALU },
+ { 3, "MAD", print_NOP },
+ { 2, "MAX", print_ALU },
+ { 2, "MIN", print_ALU },
+ { 1, "MOV", print_ALU },
+ { 2, "MUL", print_ALU },
+ { 2, "POW", print_ALU },
+ { 1, "PRT", print_ALU }, /* PRINT */
+ { 1, "RCC", print_NOP },
+ { 1, "RCP", print_ALU },
+ { 1, "RSQ", print_ALU },
+ { 2, "SGE", print_ALU },
+ { 2, "SLT", print_ALU },
+ { 2, "SUB", print_ALU },
+ { 1, "SWZ", print_NOP },
+ { 2, "XPD", print_ALU },
+ { 1, "RSW", print_RSW },
+ { 2, "MSK", print_MSK },
+ { 1, "REL", print_ALU },
+};
+
+void _tnl_disassem_vba_insn( union instruction op )
+{
+ const struct opcode_info *info = &opcode_info[op.alu.opcode];
+ info->print( op, info );
+}
+
+
+static void (* const opcode_func[])(struct arb_vp_machine *, union instruction) =
+{
+ do_ABS,
+ do_ADD,
+ do_NOP,
+ do_DP3,
+ do_DP4,
+ do_DPH,
+ do_DST,
+ do_NOP,
+ do_EX2,
+ do_EXP,
+ do_FLR,
+ do_FRC,
+ do_LG2,
+ do_LIT,
+ do_LOG,
+ do_NOP,
+ do_MAX,
+ do_MIN,
+ do_MOV,
+ do_MUL,
+ do_POW,
+ do_PRT,
+ do_NOP,
+ do_RCP,
+ do_RSQ,
+ do_SGE,
+ do_SLT,
+ do_SUB,
+ do_RSW,
+ do_XPD,
+ do_RSW,
+ do_MSK,
+ do_REL,
+};
+
+static union instruction *cvp_next_instruction( struct compilation *cp )
+{
+ union instruction *op = cp->csr++;
+ op->dword = 0;
+ return op;
+}
+
+static struct reg cvp_make_reg( GLuint file, GLuint idx )
+{
+ struct reg reg;
+ reg.file = file;
+ reg.idx = idx;
+ return reg;
+}
+
+static struct reg cvp_emit_rel( struct compilation *cp,
+ struct reg reg,
+ struct reg tmpreg )
+{
+ union instruction *op = cvp_next_instruction(cp);
+ op->alu.opcode = REL;
+ op->alu.file0 = reg.file;
+ op->alu.idx0 = reg.idx;
+ op->alu.dst = tmpreg.idx;
+ return tmpreg;
+}
+
+
+static struct reg cvp_load_reg( struct compilation *cp,
+ GLuint file,
+ GLuint index,
+ GLuint rel,
+ GLuint tmpidx )
+{
+ struct reg tmpreg = cvp_make_reg(FILE_REG, tmpidx);
+ struct reg reg;
+
+ switch (file) {
+ case PROGRAM_TEMPORARY:
+ return cvp_make_reg(FILE_REG, REG_TMP0 + index);
+
+ case PROGRAM_INPUT:
+ return cvp_make_reg(FILE_REG, REG_IN0 + index);
+
+ case PROGRAM_OUTPUT:
+ return cvp_make_reg(FILE_REG, REG_OUT0 + index);
+
+ /* These two aren't populated by the parser?
+ */
+ case PROGRAM_LOCAL_PARAM:
+ reg = cvp_make_reg(FILE_LOCAL_PARAM, index);
+ if (rel)
+ return cvp_emit_rel(cp, reg, tmpreg);
+ else
+ return reg;
+
+ case PROGRAM_ENV_PARAM:
+ reg = cvp_make_reg(FILE_ENV_PARAM, index);
+ if (rel)
+ return cvp_emit_rel(cp, reg, tmpreg);
+ else
+ return reg;
+
+ case PROGRAM_STATE_VAR:
+ reg = cvp_make_reg(FILE_STATE_PARAM, index);
+ if (rel)
+ return cvp_emit_rel(cp, reg, tmpreg);
+ else
+ return reg;
+
+ /* Invalid values:
+ */
+ case PROGRAM_WRITE_ONLY:
+ case PROGRAM_ADDRESS:
+ default:
+ assert(0);
+ return tmpreg; /* can't happen */
+ }
+}
+
+static struct reg cvp_emit_arg( struct compilation *cp,
+ const struct vp_src_register *src,
+ GLuint arg )
+{
+ struct reg reg = cvp_load_reg( cp, src->File, src->Index, src->RelAddr, arg );
+ union instruction rsw, noop;
+
+ /* Emit any necessary swizzling.
+ */
+ rsw.dword = 0;
+ rsw.rsw.neg = src->Negate ? WRITEMASK_XYZW : 0;
+ rsw.rsw.swz = ((GET_SWZ(src->Swizzle, 0) << 0) |
+ (GET_SWZ(src->Swizzle, 1) << 2) |
+ (GET_SWZ(src->Swizzle, 2) << 4) |
+ (GET_SWZ(src->Swizzle, 3) << 6));
+
+ noop.dword = 0;
+ noop.rsw.neg = 0;
+ noop.rsw.swz = RSW_NOOP;
+
+ if (rsw.dword != noop.dword) {
+ union instruction *op = cvp_next_instruction(cp);
+ struct reg rsw_reg = cvp_make_reg(FILE_REG, REG_ARG0 + arg);
+ op->dword = rsw.dword;
+ op->rsw.opcode = RSW;
+ op->rsw.file0 = reg.file;
+ op->rsw.idx0 = reg.idx;
+ op->rsw.dst = rsw_reg.idx;
+ return rsw_reg;
+ }
+ else
+ return reg;
+}
+
+static GLuint cvp_choose_result( struct compilation *cp,
+ const struct vp_dst_register *dst,
+ union instruction *fixup )
+{
+ GLuint mask = dst->WriteMask;
+ GLuint idx;
+
+ switch (dst->File) {
+ case PROGRAM_TEMPORARY:
+ idx = REG_TMP0 + dst->Index;
+ break;
+ case PROGRAM_OUTPUT:
+ idx = REG_OUT0 + dst->Index;
+ break;
+ default:
+ assert(0);
+ return REG_RES; /* can't happen */
+ }
+
+ /* Optimization: When writing (with a writemask) to an undefined
+ * value for the first time, the writemask may be ignored.
+ */
+ if (mask != WRITEMASK_XYZW && (cp->reg_active & (1 << idx))) {
+ fixup->msk.opcode = MSK;
+ fixup->msk.dst = idx;
+ fixup->msk.file = FILE_REG;
+ fixup->msk.idx = REG_RES;
+ fixup->msk.mask = mask;
+ cp->reg_active |= 1 << idx;
+ return REG_RES;
+ }
+ else {
+ fixup->dword = 0;
+ cp->reg_active |= 1 << idx;
+ return idx;
+ }
+}
+
+static struct reg cvp_emit_rsw( struct compilation *cp,
+ GLuint dst,
+ struct reg src,
+ GLuint neg,
+ GLuint swz,
+ GLboolean force)
+{
+ struct reg retval;
+
+ if (swz != RSW_NOOP || neg != 0) {
+ union instruction *op = cvp_next_instruction(cp);
+ op->rsw.opcode = RSW;
+ op->rsw.dst = dst;
+ op->rsw.file0 = src.file;
+ op->rsw.idx0 = src.idx;
+ op->rsw.neg = neg;
+ op->rsw.swz = swz;
+
+ retval.file = FILE_REG;
+ retval.idx = dst;
+ return retval;
+ }
+ else if (force) {
+ /* Oops. Degenerate case:
+ */
+ union instruction *op = cvp_next_instruction(cp);
+ op->alu.opcode = VP_OPCODE_MOV;
+ op->alu.dst = dst;
+ op->alu.file0 = src.file;
+ op->alu.idx0 = src.idx;
+
+ retval.file = FILE_REG;
+ retval.idx = dst;
+ return retval;
+ }
+ else {
+ return src;
+ }
+}
+
+
+static void cvp_emit_inst( struct compilation *cp,
+ const struct vp_instruction *inst )
+{
+ const struct opcode_info *info = &opcode_info[inst->Opcode];
+ union instruction *op;
+ union instruction fixup;
+ struct reg reg[3];
+ GLuint result, i;
+
+ assert(sizeof(*op) == sizeof(GLuint));
+
+ /* Need to handle SWZ, ARL specially.
+ */
+ switch (inst->Opcode) {
+ /* Split into mul and add:
+ */
+ case VP_OPCODE_MAD:
+ result = cvp_choose_result( cp, &inst->DstReg, &fixup );
+ for (i = 0; i < 3; i++)
+ reg[i] = cvp_emit_arg( cp, &inst->SrcReg[i], REG_ARG0+i );
+
+ op = cvp_next_instruction(cp);
+ op->alu.opcode = VP_OPCODE_MUL;
+ op->alu.file0 = reg[0].file;
+ op->alu.idx0 = reg[0].idx;
+ op->alu.file1 = reg[1].file;
+ op->alu.idx1 = reg[1].idx;
+ op->alu.dst = REG_ARG0;
+
+ op = cvp_next_instruction(cp);
+ op->alu.opcode = VP_OPCODE_ADD;
+ op->alu.file0 = FILE_REG;
+ op->alu.idx0 = REG_ARG0;
+ op->alu.file1 = reg[2].file;
+ op->alu.idx1 = reg[2].idx;
+ op->alu.dst = result;
+
+ if (result == REG_RES) {
+ op = cvp_next_instruction(cp);
+ op->dword = fixup.dword;
+ }
+ break;
+
+ case VP_OPCODE_ARL:
+ reg[0] = cvp_emit_arg( cp, &inst->SrcReg[0], REG_ARG0 );
+
+ op = cvp_next_instruction(cp);
+ op->alu.opcode = VP_OPCODE_FLR;
+ op->alu.dst = REG_ADDR;
+ op->alu.file0 = reg[0].file;
+ op->alu.idx0 = reg[0].idx;
+ break;
+
+ case VP_OPCODE_SWZ: {
+ GLuint swz0 = 0, swz1 = 0;
+ GLuint neg0 = 0, neg1 = 0;
+ GLuint mask = 0;
+
+ /* Translate 3-bit-per-element swizzle into two 2-bit swizzles,
+ * one from the source register the other from a constant
+ * {0,0,0,1}.
+ */
+ for (i = 0; i < 4; i++) {
+ GLuint swzelt = GET_SWZ(inst->SrcReg[0].Swizzle, i);
+ if (swzelt >= SWIZZLE_ZERO) {
+ neg0 |= inst->SrcReg[0].Negate & (1<<i);
+ if (swzelt == SWIZZLE_ONE)
+ swz0 |= SWIZZLE_W << (i*2);
+ else if (i < SWIZZLE_W)
+ swz0 |= i << (i*2);
+ }
+ else {
+ mask |= 1<<i;
+ neg1 |= inst->SrcReg[0].Negate & (1<<i);
+ swz1 |= swzelt << (i*2);
+ }
+ }
+
+ result = cvp_choose_result( cp, &inst->DstReg, &fixup );
+ reg[0].file = FILE_REG;
+ reg[0].idx = REG_ID;
+ reg[1] = cvp_emit_arg( cp, &inst->SrcReg[0], REG_ARG0 );
+
+ if (mask == WRITEMASK_XYZW) {
+ cvp_emit_rsw(cp, result, reg[0], neg0, swz0, GL_TRUE);
+
+ }
+ else if (mask == 0) {
+ cvp_emit_rsw(cp, result, reg[1], neg1, swz1, GL_TRUE);
+ }
+ else {
+ cvp_emit_rsw(cp, result, reg[0], neg0, swz0, GL_TRUE);
+ reg[1] = cvp_emit_rsw(cp, REG_ARG0, reg[1], neg1, swz1, GL_FALSE);
+
+ op = cvp_next_instruction(cp);
+ op->msk.opcode = MSK;
+ op->msk.dst = result;
+ op->msk.file = reg[1].file;
+ op->msk.idx = reg[1].idx;
+ op->msk.mask = mask;
+ }
+
+ if (result == REG_RES) {
+ op = cvp_next_instruction(cp);
+ op->dword = fixup.dword;
+ }
+ break;
+ }
+
+ case VP_OPCODE_END:
+ break;
+
+ default:
+ result = cvp_choose_result( cp, &inst->DstReg, &fixup );
+ for (i = 0; i < info->nr_args; i++)
+ reg[i] = cvp_emit_arg( cp, &inst->SrcReg[i], REG_ARG0 + i );
+
+ op = cvp_next_instruction(cp);
+ op->alu.opcode = inst->Opcode;
+ op->alu.file0 = reg[0].file;
+ op->alu.idx0 = reg[0].idx;
+ op->alu.file1 = reg[1].file;
+ op->alu.idx1 = reg[1].idx;
+ op->alu.dst = result;
+
+ if (result == REG_RES) {
+ op = cvp_next_instruction(cp);
+ op->dword = fixup.dword;
+ }
+ break;
+ }
+}
+
+static void free_tnl_data( struct vertex_program *program )
+{
+ struct tnl_compiled_program *p = program->TnlData;
+ if (p->compiled_func)
+ _mesa_free((void *)p->compiled_func);
+ _mesa_free(p);
+ program->TnlData = NULL;
+}
+
+static void compile_vertex_program( struct vertex_program *program,
+ GLboolean try_codegen )
+{
+ struct compilation cp;
+ struct tnl_compiled_program *p = CALLOC_STRUCT(tnl_compiled_program);
+ GLuint i;
+
+ if (program->TnlData)
+ free_tnl_data( program );
+
+ program->TnlData = p;
+
+ /* Initialize cp. Note that ctx and VB aren't used in compilation
+ * so we don't have to worry about statechanges:
+ */
+ _mesa_memset(&cp, 0, sizeof(cp));
+ cp.csr = p->instructions;
+
+ /* Compile instructions:
+ */
+ for (i = 0; i < program->Base.NumInstructions; i++) {
+ cvp_emit_inst(&cp, &program->Instructions[i]);
+ }
+
+ /* Finish up:
+ */
+ p->nr_instructions = cp.csr - p->instructions;
+
+ /* Print/disassemble:
+ */
+ if (DISASSEM) {
+ for (i = 0; i < p->nr_instructions; i++) {
+ _tnl_disassem_vba_insn(p->instructions[i]);
+ }
+ _mesa_printf("\n\n");
+ }
+
+#ifdef USE_SSE_ASM
+ if (try_codegen)
+ _tnl_sse_codegen_vertex_program(p);
+#endif
+
+}
+
+
+
+
+/* ----------------------------------------------------------------------
+ * Execution
+ */
+static void userclip( GLcontext *ctx,
+ GLvector4f *clip,
+ GLubyte *clipmask,
+ GLubyte *clipormask,
+ GLubyte *clipandmask )
+{
+ GLuint p;
+
+ for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
+ GLuint nr, i;
+ const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
+ const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
+ const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
+ const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
+ GLfloat *coord = (GLfloat *)clip->data;
+ GLuint stride = clip->stride;
+ GLuint count = clip->count;
+
+ for (nr = 0, i = 0 ; i < count ; i++) {
+ GLfloat dp = (coord[0] * a +
+ coord[1] * b +
+ coord[2] * c +
+ coord[3] * d);
+
+ if (dp < 0) {
+ nr++;
+ clipmask[i] |= CLIP_USER_BIT;
+ }
+
+ STRIDE_F(coord, stride);
+ }
+
+ if (nr > 0) {
+ *clipormask |= CLIP_USER_BIT;
+ if (nr == count) {
+ *clipandmask |= CLIP_USER_BIT;
+ return;
+ }
+ }
+ }
+ }
+}
+
+
+static GLboolean do_ndc_cliptest( struct arb_vp_machine *m )
+{
+ GLcontext *ctx = m->ctx;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = m->VB;
+
+ /* Cliptest and perspective divide. Clip functions must clear
+ * the clipmask.
+ */
+ m->ormask = 0;
+ m->andmask = CLIP_ALL_BITS;
+
+ if (tnl->NeedNdcCoords) {
+ VB->NdcPtr =
+ _mesa_clip_tab[VB->ClipPtr->size]( VB->ClipPtr,
+ &m->ndcCoords,
+ m->clipmask,
+ &m->ormask,
+ &m->andmask );
+ }
+ else {
+ VB->NdcPtr = NULL;
+ _mesa_clip_np_tab[VB->ClipPtr->size]( VB->ClipPtr,
+ NULL,
+ m->clipmask,
+ &m->ormask,
+ &m->andmask );
+ }
+
+ if (m->andmask) {
+ /* All vertices are outside the frustum */
+ return GL_FALSE;
+ }
+
+ /* Test userclip planes. This contributes to VB->ClipMask.
+ */
+ if (ctx->Transform.ClipPlanesEnabled && !ctx->VertexProgram._Enabled) {
+ userclip( ctx,
+ VB->ClipPtr,
+ m->clipmask,
+ &m->ormask,
+ &m->andmask );
+
+ if (m->andmask) {
+ return GL_FALSE;
+ }
+ }
+
+ VB->ClipAndMask = m->andmask;
+ VB->ClipOrMask = m->ormask;
+ VB->ClipMask = m->clipmask;
+
+ return GL_TRUE;
+}
+
+
+static INLINE void call_func( struct tnl_compiled_program *p,
+ struct arb_vp_machine *m )
+{
+ p->compiled_func(m);
+}
+
+/**
+ * Execute the given vertex program.
+ *
+ * TODO: Integrate the t_vertex.c code here, to build machine vertices
+ * directly at this point.
+ *
+ * TODO: Eliminate the VB struct entirely and just use
+ * struct arb_vertex_machine.
+ */
+static GLboolean
+run_arb_vertex_program(GLcontext *ctx, struct tnl_pipeline_stage *stage)
+{
+ struct vertex_program *program = (ctx->VertexProgram._Enabled ?
+ ctx->VertexProgram.Current :
+ ctx->_TnlProgram);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ struct arb_vp_machine *m = ARB_VP_MACHINE(stage);
+ struct tnl_compiled_program *p;
+ GLuint i, j, outputs;
+
+ if (!program || program->IsNVProgram)
+ return GL_TRUE;
+
+ if (program->Parameters) {
+ _mesa_load_state_parameters(ctx, program->Parameters);
+ }
+
+ p = (struct tnl_compiled_program *)program->TnlData;
+ assert(p);
+
+
+ m->nr_inputs = m->nr_outputs = 0;
+
+ for (i = 0; i < _TNL_ATTRIB_MAX; i++) {
+ if (program->InputsRead & (1<<i)) {
+ GLuint j = m->nr_inputs++;
+ m->input[j].idx = i;
+ m->input[j].data = (GLfloat *)m->VB->AttribPtr[i]->data;
+ m->input[j].stride = m->VB->AttribPtr[i]->stride;
+ m->input[j].size = m->VB->AttribPtr[i]->size;
+ ASSIGN_4V(m->File[0][REG_IN0 + i], 0, 0, 0, 1);
+ }
+ }
+
+ for (i = 0; i < 15; i++) {
+ if (program->OutputsWritten & (1<<i)) {
+ GLuint j = m->nr_outputs++;
+ m->output[j].idx = i;
+ m->output[j].data = (GLfloat *)m->attribs[i].data;
+ }
+ }
+
+
+ /* Run the actual program:
+ */
+ for (m->vtx_nr = 0; m->vtx_nr < VB->Count; m->vtx_nr++) {
+ for (j = 0; j < m->nr_inputs; j++) {
+ GLuint idx = REG_IN0 + m->input[j].idx;
+ switch (m->input[j].size) {
+ case 4: m->File[0][idx][3] = m->input[j].data[3];
+ case 3: m->File[0][idx][2] = m->input[j].data[2];
+ case 2: m->File[0][idx][1] = m->input[j].data[1];
+ case 1: m->File[0][idx][0] = m->input[j].data[0];
+ }
+
+ STRIDE_F(m->input[j].data, m->input[j].stride);
+ }
+
+ if (p->compiled_func) {
+ call_func( p, m );
+ }
+ else {
+ for (j = 0; j < p->nr_instructions; j++) {
+ union instruction inst = p->instructions[j];
+ opcode_func[inst.alu.opcode]( m, inst );
+ }
+ }
+
+ for (j = 0; j < m->nr_outputs; j++) {
+ GLuint idx = REG_OUT0 + m->output[j].idx;
+ m->output[j].data[0] = m->File[0][idx][0];
+ m->output[j].data[1] = m->File[0][idx][1];
+ m->output[j].data[2] = m->File[0][idx][2];
+ m->output[j].data[3] = m->File[0][idx][3];
+ m->output[j].data += 4;
+ }
+ }
+
+ /* Setup the VB pointers so that the next pipeline stages get
+ * their data from the right place (the program output arrays).
+ *
+ * TODO: 1) Have tnl use these RESULT values for outputs rather
+ * than trying to shoe-horn inputs and outputs into one set of
+ * values.
+ *
+ * TODO: 2) Integrate t_vertex.c so that we just go straight ahead
+ * and build machine vertices here.
+ */
+ VB->ClipPtr = &m->attribs[VERT_RESULT_HPOS];
+ VB->ClipPtr->count = VB->Count;
+
+ outputs = program->OutputsWritten;
+
+ if (outputs & (1<<VERT_RESULT_COL0)) {
+ VB->ColorPtr[0] = &m->attribs[VERT_RESULT_COL0];
+ VB->AttribPtr[VERT_ATTRIB_COLOR0] = VB->ColorPtr[0];
+ }
+
+ if (outputs & (1<<VERT_RESULT_BFC0)) {
+ VB->ColorPtr[1] = &m->attribs[VERT_RESULT_BFC0];
+ }
+
+ if (outputs & (1<<VERT_RESULT_COL1)) {
+ VB->SecondaryColorPtr[0] = &m->attribs[VERT_RESULT_COL1];
+ VB->AttribPtr[VERT_ATTRIB_COLOR1] = VB->SecondaryColorPtr[0];
+ }
+
+ if (outputs & (1<<VERT_RESULT_BFC1)) {
+ VB->SecondaryColorPtr[1] = &m->attribs[VERT_RESULT_BFC1];
+ }
+
+ if (outputs & (1<<VERT_RESULT_FOGC)) {
+ VB->FogCoordPtr = &m->attribs[VERT_RESULT_FOGC];
+ VB->AttribPtr[VERT_ATTRIB_FOG] = VB->FogCoordPtr;
+ }
+
+ if (outputs & (1<<VERT_RESULT_PSIZ)) {
+ VB->PointSizePtr = &m->attribs[VERT_RESULT_PSIZ];
+ VB->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &m->attribs[VERT_RESULT_PSIZ];
+ }
+
+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+ if (outputs & (1<<(VERT_RESULT_TEX0+i))) {
+ VB->TexCoordPtr[i] = &m->attribs[VERT_RESULT_TEX0 + i];
+ VB->AttribPtr[VERT_ATTRIB_TEX0+i] = VB->TexCoordPtr[i];
+ }
+ }
+
+#if 0
+ for (i = 0; i < VB->Count; i++) {
+ printf("Out %d: %f %f %f %f %f %f %f %f\n", i,
+ VEC_ELT(VB->ClipPtr, GLfloat, i)[0],
+ VEC_ELT(VB->ClipPtr, GLfloat, i)[1],
+ VEC_ELT(VB->ClipPtr, GLfloat, i)[2],
+ VEC_ELT(VB->ClipPtr, GLfloat, i)[3],
+ VEC_ELT(VB->TexCoordPtr[0], GLfloat, i)[0],
+ VEC_ELT(VB->TexCoordPtr[0], GLfloat, i)[1],
+ VEC_ELT(VB->TexCoordPtr[0], GLfloat, i)[2],
+ VEC_ELT(VB->TexCoordPtr[0], GLfloat, i)[3]);
+ }
+#endif
+
+ /* Perform NDC and cliptest operations:
+ */
+ return do_ndc_cliptest(m);
+}
+
+
+static void
+validate_vertex_program( GLcontext *ctx, struct tnl_pipeline_stage *stage )
+{
+ struct arb_vp_machine *m = ARB_VP_MACHINE(stage);
+ struct vertex_program *program =
+ (ctx->VertexProgram._Enabled ? ctx->VertexProgram.Current : 0);
+
+ if (!program && ctx->_MaintainTnlProgram) {
+ program = ctx->_TnlProgram;
+ }
+
+ if (program) {
+ if (!program->TnlData)
+ compile_vertex_program( program, m->try_codegen );
+
+ /* Grab the state GL state and put into registers:
+ */
+ m->File[FILE_LOCAL_PARAM] = program->Base.LocalParams;
+ m->File[FILE_ENV_PARAM] = ctx->VertexProgram.Parameters;
+ /* GL_NV_vertex_programs can't reference GL state */
+ if (program->Parameters)
+ m->File[FILE_STATE_PARAM] = program->Parameters->ParameterValues;
+ else
+ m->File[FILE_STATE_PARAM] = NULL;
+ }
+}
+
+
+
+
+
+
+
+/**
+ * Called the first time stage->run is called. In effect, don't
+ * allocate data until the first time the stage is run.
+ */
+static GLboolean init_vertex_program( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &(tnl->vb);
+ struct arb_vp_machine *m;
+ const GLuint size = VB->Size;
+ GLuint i;
+
+ stage->privatePtr = _mesa_malloc(sizeof(*m));
+ m = ARB_VP_MACHINE(stage);
+ if (!m)
+ return GL_FALSE;
+
+ /* arb_vertex_machine struct should subsume the VB:
+ */
+ m->VB = VB;
+ m->ctx = ctx;
+
+ m->File[0] = ALIGN_MALLOC(REG_MAX * sizeof(GLfloat) * 4, 16);
+
+ /* Initialize regs where necessary:
+ */
+ ASSIGN_4V(m->File[0][REG_ID], 0, 0, 0, 1);
+ ASSIGN_4V(m->File[0][REG_ONES], 1, 1, 1, 1);
+ ASSIGN_4V(m->File[0][REG_SWZ], -1, 1, 0, 0);
+ ASSIGN_4V(m->File[0][REG_NEG], -1, -1, -1, -1);
+ ASSIGN_4V(m->File[0][REG_LIT], 1, 0, 0, 1);
+ ASSIGN_4V(m->File[0][REG_LIT2], 1, .5, .2, 1); /* debug value */
+
+ if (_mesa_getenv("MESA_EXPERIMENTAL"))
+ m->try_codegen = 1;
+
+ /* Allocate arrays of vertex output values */
+ for (i = 0; i < VERT_RESULT_MAX; i++) {
+ _mesa_vector4f_alloc( &m->attribs[i], 0, size, 32 );
+ m->attribs[i].size = 4;
+ }
+
+ /* a few other misc allocations */
+ _mesa_vector4f_alloc( &m->ndcCoords, 0, size, 32 );
+ m->clipmask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte)*size, 32 );
+
+ if (ctx->_MaintainTnlProgram)
+ _mesa_allow_light_in_model( ctx, GL_FALSE );
+
+ m->fpucntl_rnd_neg = RND_NEG_FPU; /* const value */
+ m->fpucntl_restore = RESTORE_FPU; /* const value */
+
+ return GL_TRUE;
+}
+
+
+
+
+/**
+ * Destructor for this pipeline stage.
+ */
+static void dtr( struct tnl_pipeline_stage *stage )
+{
+ struct arb_vp_machine *m = ARB_VP_MACHINE(stage);
+
+ if (m) {
+ GLuint i;
+
+ /* free the vertex program result arrays */
+ for (i = 0; i < VERT_RESULT_MAX; i++)
+ _mesa_vector4f_free( &m->attribs[i] );
+
+ /* free misc arrays */
+ _mesa_vector4f_free( &m->ndcCoords );
+ ALIGN_FREE( m->clipmask );
+ ALIGN_FREE( m->File[0] );
+
+ _mesa_free( m );
+ stage->privatePtr = NULL;
+ }
+}
+
+/**
+ * Public description of this pipeline stage.
+ */
+const struct tnl_pipeline_stage _tnl_arb_vertex_program_stage =
+{
+ "vertex-program",
+ NULL, /* private_data */
+ init_vertex_program, /* create */
+ dtr, /* destroy */
+ validate_vertex_program, /* validate */
+ run_arb_vertex_program /* run */
+};
+
+
+/**
+ * Called via ctx->Driver.ProgramStringNotify() after a new vertex program
+ * string has been parsed.
+ */
+void
+_tnl_program_string(GLcontext *ctx, GLenum target, struct program *program)
+{
+ if (program->Target == GL_VERTEX_PROGRAM_ARB) {
+ /* free any existing tnl data hanging off the program */
+ struct vertex_program *vprog = (struct vertex_program *) program;
+ if (vprog->TnlData) {
+ free_tnl_data(vprog);
+ }
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram.h
new file mode 100644
index 000000000..02cd43282
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram.h
@@ -0,0 +1,189 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file t_arb_program.c
+ * Compile vertex programs to an intermediate representation.
+ * Execute vertex programs over a buffer of vertices.
+ * \author Keith Whitwell, Brian Paul
+ */
+
+
+#ifndef _T_VB_ARBPROGRAM_H_
+#define _T_VB_ARBPROGRAM_H_
+
+
+/* New, internal instructions:
+ */
+#define RSW (VP_MAX_OPCODE)
+#define MSK (VP_MAX_OPCODE+1)
+#define REL (VP_MAX_OPCODE+2)
+
+/**
+ * Register files for vertex programs
+ */
+#define FILE_REG 0 /* temporaries */
+#define FILE_LOCAL_PARAM 1 /* local parameters */
+#define FILE_ENV_PARAM 2 /* global parameters */
+#define FILE_STATE_PARAM 3 /* GL state references */
+
+#define REG_ARG0 0
+#define REG_ARG1 1
+#define REG_ARG2 2
+#define REG_RES 3
+#define REG_ADDR 4
+#define REG_TMP0 5
+#define REG_TMP11 16
+#define REG_OUT0 17
+#define REG_OUT14 31
+#define REG_IN0 32
+#define REG_IN31 63
+#define REG_ID 64 /* 0,0,0,1 */
+#define REG_ONES 65 /* 1,1,1,1 */
+#define REG_SWZ 66 /* -1,1,0,0 */
+#define REG_NEG 67 /* -1,-1,-1,-1 */
+#define REG_LIT 68 /* 1,0,0,1 */
+#define REG_LIT2 69 /* 1,0,0,1 */
+#define REG_SCRATCH 70 /* internal temporary */
+#define REG_UNDEF 127 /* special case - never used */
+#define REG_MAX 128
+#define REG_INVALID ~0
+
+/* ARB_vp instructions are broken down into one or more of the
+ * following micro-instructions, each representable in a 32 bit packed
+ * structure.
+ */
+struct reg {
+ GLuint file:2;
+ GLuint idx:7;
+};
+
+
+union instruction {
+ struct {
+ GLuint opcode:6;
+ GLuint dst:5;
+ GLuint file0:2;
+ GLuint idx0:7;
+ GLuint file1:2;
+ GLuint idx1:7;
+ GLuint pad:3;
+ } alu;
+
+ struct {
+ GLuint opcode:6;
+ GLuint dst:5;
+ GLuint file0:2;
+ GLuint idx0:7;
+ GLuint neg:4;
+ GLuint swz:8; /* xyzw only */
+ } rsw;
+
+ struct {
+ GLuint opcode:6;
+ GLuint dst:5;
+ GLuint file:2;
+ GLuint idx:7;
+ GLuint mask:4;
+ GLuint pad:1;
+ } msk;
+
+ GLuint dword;
+};
+
+#define RSW_NOOP ((0<<0) | (1<<2) | (2<<4) | (3<<6))
+#define GET_RSW(swz, idx) (((swz) >> ((idx)*2)) & 0x3)
+
+
+struct input {
+ GLuint idx;
+ GLfloat *data;
+ GLuint stride;
+ GLuint size;
+};
+
+struct output {
+ GLuint idx;
+ GLfloat *data;
+};
+
+
+
+/*--------------------------------------------------------------------------- */
+#if defined(USE_SSE_ASM)
+#ifdef NO_FAST_MATH
+#define RESTORE_FPU (DEFAULT_X86_FPU)
+#define RND_NEG_FPU (DEFAULT_X86_FPU | 0x400)
+#else
+#define RESTORE_FPU (FAST_X86_FPU)
+#define RND_NEG_FPU (FAST_X86_FPU | 0x400)
+#endif
+#else
+#define RESTORE_FPU 0
+#define RND_NEG_FPU 0
+#endif
+
+
+/*!
+ * Private storage for the vertex program pipeline stage.
+ */
+struct arb_vp_machine {
+ GLfloat (*File[4])[4]; /* All values referencable from the program. */
+
+ struct input input[_TNL_ATTRIB_MAX];
+ GLuint nr_inputs;
+
+ struct output output[15];
+ GLuint nr_outputs;
+
+ GLvector4f attribs[VERT_RESULT_MAX]; /**< result vectors. */
+ GLvector4f ndcCoords; /**< normalized device coords */
+ GLubyte *clipmask; /**< clip flags */
+ GLubyte ormask, andmask; /**< for clipping */
+
+ GLuint vtx_nr; /**< loop counter */
+
+ struct vertex_buffer *VB;
+ GLcontext *ctx;
+
+ GLshort fpucntl_rnd_neg; /* constant value */
+ GLshort fpucntl_restore; /* constant value */
+
+ GLboolean try_codegen;
+};
+
+struct tnl_compiled_program {
+ union instruction instructions[1024];
+ GLint nr_instructions;
+ void (*compiled_func)( struct arb_vp_machine * ); /**< codegen'd program */
+};
+
+void _tnl_program_string_change( struct vertex_program * );
+void _tnl_program_destroy( struct vertex_program * );
+
+void _tnl_disassem_vba_insn( union instruction op );
+
+GLboolean _tnl_sse_codegen_vertex_program(struct tnl_compiled_program *p);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram_sse.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram_sse.c
new file mode 100644
index 000000000..330d30efb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_arbprogram_sse.c
@@ -0,0 +1,1222 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file t_vb_arb_program_sse.c
+ *
+ * Translate simplified vertex_program representation to
+ * x86/x87/SSE/SSE2 machine code using mesa's rtasm runtime assembler.
+ *
+ * This is very much a first attempt - build something that works.
+ * There are probably better approaches for applying SSE to vertex
+ * programs, and the whole thing is crying out for static analysis of
+ * the programs to avoid redundant operations.
+ *
+ * \author Keith Whitwell
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "imports.h"
+#include "macros.h"
+#include "mtypes.h"
+#include "arbprogparse.h"
+#include "program.h"
+#include "math/m_matrix.h"
+#include "math/m_translate.h"
+#include "t_context.h"
+#include "t_vb_arbprogram.h"
+
+#if defined(USE_SSE_ASM)
+
+#include "x86/rtasm/x86sse.h"
+#include "x86/common_x86_asm.h"
+
+#define X 0
+#define Y 1
+#define Z 2
+#define W 3
+
+/* Reg usage:
+ *
+ * EAX - temp
+ * EBX - point to 'm->File[0]'
+ * ECX - point to 'm->File[3]'
+ * EDX - holds 'm'
+ * EBP,
+ * ESI,
+ * EDI
+ */
+
+#define DISASSEM 0
+
+#define FAIL \
+do { \
+ _mesa_printf("x86 translation failed in %s\n", __FUNCTION__); \
+ return GL_FALSE; \
+} while (0)
+
+struct compilation {
+ struct x86_function func;
+ struct tnl_compiled_program *p;
+ GLuint insn_counter;
+
+ struct {
+ GLuint file:2;
+ GLuint idx:7;
+ GLuint dirty:1;
+ GLuint last_used:10;
+ } xmm[8];
+
+ struct {
+ struct x86_reg base;
+ } file[4];
+
+ GLboolean have_sse2;
+ GLshort fpucntl;
+};
+
+static INLINE GLboolean eq( struct x86_reg a,
+ struct x86_reg b )
+{
+ return (a.file == b.file &&
+ a.idx == b.idx &&
+ a.mod == b.mod &&
+ a.disp == b.disp);
+}
+
+static GLint get_offset( const void *a, const void *b )
+{
+ return (const char *)b - (const char *)a;
+}
+
+
+static struct x86_reg get_reg_ptr(GLuint file,
+ GLuint idx )
+{
+ struct x86_reg reg;
+
+ switch (file) {
+ case FILE_REG:
+ reg = x86_make_reg(file_REG32, reg_BX);
+ assert(idx != REG_UNDEF);
+ break;
+ case FILE_STATE_PARAM:
+ reg = x86_make_reg(file_REG32, reg_CX);
+ break;
+ default:
+ assert(0);
+ }
+
+ return x86_make_disp(reg, 16 * idx);
+}
+
+
+static void spill( struct compilation *cp, GLuint idx )
+{
+ struct x86_reg oldval = get_reg_ptr(cp->xmm[idx].file,
+ cp->xmm[idx].idx);
+
+ assert(cp->xmm[idx].dirty);
+ sse_movups(&cp->func, oldval, x86_make_reg(file_XMM, idx));
+ cp->xmm[idx].dirty = 0;
+}
+
+static struct x86_reg get_xmm_reg( struct compilation *cp )
+{
+ GLuint i;
+ GLuint oldest = 0;
+
+ for (i = 0; i < 8; i++)
+ if (cp->xmm[i].last_used < cp->xmm[oldest].last_used)
+ oldest = i;
+
+ /* Need to write out the old value?
+ */
+ if (cp->xmm[oldest].dirty)
+ spill(cp, oldest);
+
+ assert(cp->xmm[oldest].last_used != cp->insn_counter);
+
+ cp->xmm[oldest].file = FILE_REG;
+ cp->xmm[oldest].idx = REG_UNDEF;
+ cp->xmm[oldest].last_used = cp->insn_counter;
+ return x86_make_reg(file_XMM, oldest);
+}
+
+static void invalidate_xmm( struct compilation *cp,
+ GLuint file, GLuint idx )
+{
+ GLuint i;
+
+ /* Invalidate any old copy of this register in XMM0-7.
+ */
+ for (i = 0; i < 8; i++) {
+ if (cp->xmm[i].file == file && cp->xmm[i].idx == idx) {
+ cp->xmm[i].file = FILE_REG;
+ cp->xmm[i].idx = REG_UNDEF;
+ cp->xmm[i].dirty = 0;
+ break;
+ }
+ }
+}
+
+
+/* Return an XMM reg to receive the results of an operation.
+ */
+static struct x86_reg get_dst_xmm_reg( struct compilation *cp,
+ GLuint file, GLuint idx )
+{
+ struct x86_reg reg;
+
+ /* Invalidate any old copy of this register in XMM0-7. Don't reuse
+ * as this may be one of the arguments.
+ */
+ invalidate_xmm( cp, file, idx );
+
+ reg = get_xmm_reg( cp );
+ cp->xmm[reg.idx].file = file;
+ cp->xmm[reg.idx].idx = idx;
+ cp->xmm[reg.idx].dirty = 1;
+ return reg;
+}
+
+/* As above, but return a pointer. Note - this pointer may alias
+ * those returned by get_arg_ptr().
+ */
+static struct x86_reg get_dst_ptr( struct compilation *cp,
+ GLuint file, GLuint idx )
+{
+ /* Invalidate any old copy of this register in XMM0-7. Don't reuse
+ * as this may be one of the arguments.
+ */
+ invalidate_xmm( cp, file, idx );
+
+ return get_reg_ptr(file, idx);
+}
+
+
+
+/* Return an XMM reg if the argument is resident, otherwise return a
+ * base+offset pointer to the saved value.
+ */
+static struct x86_reg get_arg( struct compilation *cp, GLuint file, GLuint idx )
+{
+ GLuint i;
+
+ for (i = 0; i < 8; i++) {
+ if (cp->xmm[i].file == file &&
+ cp->xmm[i].idx == idx) {
+ cp->xmm[i].last_used = cp->insn_counter;
+ return x86_make_reg(file_XMM, i);
+ }
+ }
+
+ return get_reg_ptr(file, idx);
+}
+
+/* As above, but always return a pointer:
+ */
+static struct x86_reg get_arg_ptr( struct compilation *cp, GLuint file, GLuint idx )
+{
+ GLuint i;
+
+ /* If there is a modified version of this register in one of the
+ * XMM regs, write it out to memory.
+ */
+ for (i = 0; i < 8; i++) {
+ if (cp->xmm[i].file == file &&
+ cp->xmm[i].idx == idx &&
+ cp->xmm[i].dirty)
+ spill(cp, i);
+ }
+
+ return get_reg_ptr(file, idx);
+}
+
+/* Emulate pshufd insn in regular SSE, if necessary:
+ */
+static void emit_pshufd( struct compilation *cp,
+ struct x86_reg dst,
+ struct x86_reg arg0,
+ GLubyte shuf )
+{
+ if (cp->have_sse2) {
+ sse2_pshufd(&cp->func, dst, arg0, shuf);
+ cp->func.fn = 0;
+ }
+ else {
+ if (!eq(dst, arg0))
+ sse_movups(&cp->func, dst, arg0);
+
+ sse_shufps(&cp->func, dst, dst, shuf);
+ }
+}
+
+static void set_fpu_round_neg_inf( struct compilation *cp )
+{
+ if (cp->fpucntl != RND_NEG_FPU) {
+ struct x86_reg regEDX = x86_make_reg(file_REG32, reg_DX);
+ struct arb_vp_machine *m = NULL;
+
+ cp->fpucntl = RND_NEG_FPU;
+ x87_fnclex(&cp->func);
+ x87_fldcw(&cp->func, x86_make_disp(regEDX, get_offset(m, &m->fpucntl_rnd_neg)));
+ }
+}
+
+
+/* Perform a reduced swizzle.
+ */
+static GLboolean emit_RSW( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.rsw.file0, op.rsw.idx0);
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.rsw.dst);
+ GLuint swz = op.rsw.swz;
+ GLuint neg = op.rsw.neg;
+
+ emit_pshufd(cp, dst, arg0, swz);
+
+ if (neg) {
+ struct x86_reg negs = get_arg(cp, FILE_REG, REG_SWZ);
+ struct x86_reg tmp = get_xmm_reg(cp);
+ /* Load 1,-1,0,0
+ * Use neg as arg to pshufd
+ * Multiply
+ */
+ emit_pshufd(cp, tmp, negs,
+ SHUF((neg & 1) ? 1 : 0,
+ (neg & 2) ? 1 : 0,
+ (neg & 4) ? 1 : 0,
+ (neg & 8) ? 1 : 0));
+ sse_mulps(&cp->func, dst, tmp);
+ }
+
+ return GL_TRUE;
+}
+
+/* Helper for writemask:
+ */
+static GLboolean emit_shuf_copy1( struct compilation *cp,
+ struct x86_reg dst,
+ struct x86_reg arg0,
+ struct x86_reg arg1,
+ GLubyte shuf )
+{
+ struct x86_reg tmp = get_xmm_reg(cp);
+ sse_movups(&cp->func, dst, arg1);
+ emit_pshufd(cp, dst, dst, shuf);
+ emit_pshufd(cp, tmp, arg0, shuf);
+
+ sse_movss(&cp->func, dst, tmp);
+
+ emit_pshufd(cp, dst, dst, shuf);
+ return GL_TRUE;
+}
+
+
+/* Helper for writemask:
+ */
+static GLboolean emit_shuf_copy2( struct compilation *cp,
+ struct x86_reg dst,
+ struct x86_reg arg0,
+ struct x86_reg arg1,
+ GLubyte shuf )
+{
+ struct x86_reg tmp = get_xmm_reg(cp);
+ emit_pshufd(cp, dst, arg1, shuf);
+ emit_pshufd(cp, tmp, arg0, shuf);
+
+ sse_shufps(&cp->func, dst, tmp, SHUF(X, Y, Z, W));
+
+ emit_pshufd(cp, dst, dst, shuf);
+ return GL_TRUE;
+}
+
+
+static void emit_x87_ex2( struct compilation *cp )
+{
+ struct x86_reg st0 = x86_make_reg(file_x87, 0);
+ struct x86_reg st1 = x86_make_reg(file_x87, 1);
+ struct x86_reg st3 = x86_make_reg(file_x87, 3);
+
+ set_fpu_round_neg_inf( cp );
+
+ x87_fld(&cp->func, st0); /* a a */
+ x87_fprndint( &cp->func ); /* int(a) a */
+ x87_fld(&cp->func, st0); /* int(a) int(a) a */
+ x87_fstp(&cp->func, st3); /* int(a) a int(a)*/
+ x87_fsubp(&cp->func, st1); /* frac(a) int(a) */
+ x87_f2xm1(&cp->func); /* (2^frac(a))-1 int(a)*/
+ x87_fld1(&cp->func); /* 1 (2^frac(a))-1 int(a)*/
+ x87_faddp(&cp->func, st1); /* 2^frac(a) int(a) */
+ x87_fscale(&cp->func); /* 2^a */
+}
+
+#if 0
+static GLboolean emit_MSK2( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.msk.file, op.msk.arg);
+ struct x86_reg arg1 = get_arg(cp, FILE_REG, op.msk.dst); /* NOTE! */
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.msk.dst);
+
+ /* make full width bitmask in tmp
+ * dst = ~tmp
+ * tmp &= arg0
+ * dst &= arg1
+ * dst |= tmp
+ */
+ emit_pshufd(cp, tmp, get_arg(cp, FILE_REG, REG_NEGS),
+ SHUF((op.msk.mask & 1) ? 2 : 0,
+ (op.msk.mask & 2) ? 2 : 0,
+ (op.msk.mask & 4) ? 2 : 0,
+ (op.msk.mask & 8) ? 2 : 0));
+ sse2_pnot(&cp->func, dst, tmp);
+ sse2_pand(&cp->func, arg0, tmp);
+ sse2_pand(&cp->func, arg1, dst);
+ sse2_por(&cp->func, tmp, dst);
+ return GL_TRUE;
+}
+#endif
+
+
+/* Used to implement write masking. This and most of the other instructions
+ * here would be easier to implement if there had been a translation
+ * to a 2 argument format (dst/arg0, arg1) at the shader level before
+ * attempting to translate to x86/sse code.
+ */
+static GLboolean emit_MSK( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg = get_arg(cp, op.msk.file, op.msk.idx);
+ struct x86_reg dst0 = get_arg(cp, FILE_REG, op.msk.dst); /* NOTE! */
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.msk.dst);
+
+ /* Note that dst and dst0 refer to the same program variable, but
+ * will definitely be different XMM registers. We're effectively
+ * treating this as a 2 argument SEL now, just one of which happens
+ * always to be the same register as the destination.
+ */
+
+ switch (op.msk.mask) {
+ case 0:
+ sse_movups(&cp->func, dst, dst0);
+ return GL_TRUE;
+
+ case WRITEMASK_X:
+ if (arg.file == file_XMM) {
+ sse_movups(&cp->func, dst, dst0);
+ sse_movss(&cp->func, dst, arg);
+ }
+ else {
+ struct x86_reg tmp = get_xmm_reg(cp);
+ sse_movups(&cp->func, dst, dst0);
+ sse_movss(&cp->func, tmp, arg);
+ sse_movss(&cp->func, dst, tmp);
+ }
+ return GL_TRUE;
+
+ case WRITEMASK_XY:
+ sse_movups(&cp->func, dst, dst0);
+ sse_shufps(&cp->func, dst, arg, SHUF(X, Y, Z, W));
+ return GL_TRUE;
+
+ case WRITEMASK_ZW:
+ sse_movups(&cp->func, dst, arg);
+ sse_shufps(&cp->func, dst, dst0, SHUF(X, Y, Z, W));
+ return GL_TRUE;
+
+ case WRITEMASK_YZW:
+ if (dst0.file == file_XMM) {
+ sse_movups(&cp->func, dst, arg);
+ sse_movss(&cp->func, dst, dst0);
+ }
+ else {
+ struct x86_reg tmp = get_xmm_reg(cp);
+ sse_movups(&cp->func, dst, arg);
+ sse_movss(&cp->func, tmp, dst0);
+ sse_movss(&cp->func, dst, tmp);
+ }
+ return GL_TRUE;
+
+ case WRITEMASK_Y:
+ emit_shuf_copy1(cp, dst, arg, dst0, SHUF(Y,X,Z,W));
+ return GL_TRUE;
+
+ case WRITEMASK_Z:
+ emit_shuf_copy1(cp, dst, arg, dst0, SHUF(Z,Y,X,W));
+ return GL_TRUE;
+
+ case WRITEMASK_W:
+ emit_shuf_copy1(cp, dst, arg, dst0, SHUF(W,Y,Z,X));
+ return GL_TRUE;
+
+ case WRITEMASK_XZ:
+ emit_shuf_copy2(cp, dst, arg, dst0, SHUF(X,Z,Y,W));
+ return GL_TRUE;
+
+ case WRITEMASK_XW:
+ emit_shuf_copy2(cp, dst, arg, dst0, SHUF(X,W,Z,Y));
+
+ case WRITEMASK_YZ:
+ emit_shuf_copy2(cp, dst, arg, dst0, SHUF(Z,Y,X,W));
+ return GL_TRUE;
+
+ case WRITEMASK_YW:
+ emit_shuf_copy2(cp, dst, arg, dst0, SHUF(W,Y,Z,X));
+ return GL_TRUE;
+
+ case WRITEMASK_XZW:
+ emit_shuf_copy1(cp, dst, dst0, arg, SHUF(Y,X,Z,W));
+ return GL_TRUE;
+
+ case WRITEMASK_XYW:
+ emit_shuf_copy1(cp, dst, dst0, arg, SHUF(Z,Y,X,W));
+ return GL_TRUE;
+
+ case WRITEMASK_XYZ:
+ emit_shuf_copy1(cp, dst, dst0, arg, SHUF(W,Y,Z,X));
+ return GL_TRUE;
+
+ case WRITEMASK_XYZW:
+ sse_movups(&cp->func, dst, arg);
+ return GL_TRUE;
+
+ default:
+ assert(0);
+ break;
+ }
+}
+
+
+
+static GLboolean emit_PRT( struct compilation *cp, union instruction op )
+{
+ FAIL;
+}
+
+
+/**
+ * The traditional instructions. All operate on internal registers
+ * and ignore write masks and swizzling issues.
+ */
+
+static GLboolean emit_ABS( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
+ struct x86_reg neg = get_reg_ptr(FILE_REG, REG_NEG);
+
+ sse_movups(&cp->func, dst, arg0);
+ sse_mulps(&cp->func, dst, neg);
+ sse_maxps(&cp->func, dst, arg0);
+ return GL_TRUE;
+}
+
+static GLboolean emit_ADD( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
+
+ sse_movups(&cp->func, dst, arg0);
+ sse_addps(&cp->func, dst, arg1);
+ return GL_TRUE;
+}
+
+
+/* The dotproduct instructions don't really do that well in sse:
+ */
+static GLboolean emit_DP3( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
+ struct x86_reg tmp = get_xmm_reg(cp);
+
+ sse_movups(&cp->func, dst, arg0);
+ sse_mulps(&cp->func, dst, arg1);
+
+ /* Now the hard bit: sum the first 3 values:
+ */
+ sse_movhlps(&cp->func, tmp, dst);
+ sse_addss(&cp->func, dst, tmp); /* a*x+c*z, b*y, ?, ? */
+ emit_pshufd(cp, tmp, dst, SHUF(Y,X,W,Z));
+ sse_addss(&cp->func, dst, tmp);
+ sse_shufps(&cp->func, dst, dst, SHUF(X, X, X, X));
+ return GL_TRUE;
+}
+
+
+
+static GLboolean emit_DP4( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
+ struct x86_reg tmp = get_xmm_reg(cp);
+
+ sse_movups(&cp->func, dst, arg0);
+ sse_mulps(&cp->func, dst, arg1);
+
+ /* Now the hard bit: sum the values:
+ */
+ sse_movhlps(&cp->func, tmp, dst);
+ sse_addps(&cp->func, dst, tmp); /* a*x+c*z, b*y+d*w, a*x+c*z, b*y+d*w */
+ emit_pshufd(cp, tmp, dst, SHUF(Y,X,W,Z));
+ sse_addss(&cp->func, dst, tmp);
+ sse_shufps(&cp->func, dst, dst, SHUF(X, X, X, X));
+ return GL_TRUE;
+}
+
+static GLboolean emit_DPH( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
+ struct x86_reg ones = get_reg_ptr(FILE_REG, REG_ONES);
+ struct x86_reg tmp = get_xmm_reg(cp);
+
+ emit_pshufd(cp, dst, arg0, SHUF(W,X,Y,Z));
+ sse_movss(&cp->func, dst, ones);
+ emit_pshufd(cp, dst, dst, SHUF(W,X,Y,Z));
+ sse_mulps(&cp->func, dst, arg1);
+
+ /* Now the hard bit: sum the values (from DP4):
+ */
+ sse_movhlps(&cp->func, tmp, dst);
+ sse_addps(&cp->func, dst, tmp); /* a*x+c*z, b*y+d*w, a*x+c*z, b*y+d*w */
+ emit_pshufd(cp, tmp, dst, SHUF(Y,X,W,Z));
+ sse_addss(&cp->func, dst, tmp);
+ sse_shufps(&cp->func, dst, dst, SHUF(X, X, X, X));
+ return GL_TRUE;
+}
+
+#if 0
+static GLboolean emit_DST( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg arg1 = get_arg_ptr(cp, op.alu.file1, op.alu.idx1);
+ struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
+
+/* dst[0] = 1.0 * 1.0F; */
+/* dst[1] = arg0[1] * arg1[1]; */
+/* dst[2] = arg0[2] * 1.0; */
+/* dst[3] = 1.0 * arg1[3]; */
+
+ /* Would rather do some of this with integer regs, but:
+ * 1) No proper support for immediate values yet
+ * 2) I'd need to push/pop somewhere to get a free reg.
+ */
+ x87_fld1(&cp->func);
+ x87_fstp(&cp->func, dst); /* would rather do an immediate store... */
+ x87_fld(&cp->func, x86_make_disp(arg0, 4));
+ x87_fmul(&cp->func, x86_make_disp(arg1, 4));
+ x87_fstp(&cp->func, x86_make_disp(dst, 4));
+
+ if (!eq(arg0, dst)) {
+ x86_fld(&cp->func, x86_make_disp(arg0, 8));
+ x86_stp(&cp->func, x86_make_disp(dst, 8));
+ }
+
+ if (!eq(arg1, dst)) {
+ x86_fld(&cp->func, x86_make_disp(arg0, 12));
+ x86_stp(&cp->func, x86_make_disp(dst, 12));
+ }
+
+ return GL_TRUE;
+}
+#else
+static GLboolean emit_DST( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
+ struct x86_reg tmp = get_xmm_reg(cp);
+ struct x86_reg ones = get_reg_ptr(FILE_REG, REG_ONES);
+
+ emit_shuf_copy2(cp, dst, arg0, ones, SHUF(X,W,Z,Y));
+ emit_shuf_copy2(cp, tmp, arg1, ones, SHUF(X,Z,Y,W));
+ sse_mulps(&cp->func, dst, tmp);
+
+/* dst[0] = 1.0 * 1.0F; */
+/* dst[1] = arg0[1] * arg1[1]; */
+/* dst[2] = arg0[2] * 1.0; */
+/* dst[3] = 1.0 * arg1[3]; */
+
+ return GL_TRUE;
+}
+#endif
+
+static GLboolean emit_LG2( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
+
+ x87_fld1(&cp->func); /* 1 */
+ x87_fld(&cp->func, arg0); /* a0 1 */
+ x87_fyl2x(&cp->func); /* log2(a0) */
+ x87_fst(&cp->func, x86_make_disp(dst, 0));
+ x87_fst(&cp->func, x86_make_disp(dst, 4));
+ x87_fst(&cp->func, x86_make_disp(dst, 8));
+ x87_fstp(&cp->func, x86_make_disp(dst, 12));
+
+ return GL_TRUE;
+}
+
+
+static GLboolean emit_EX2( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
+
+ /* CAUTION: dst may alias arg0!
+ */
+ x87_fld(&cp->func, arg0);
+
+ emit_x87_ex2(cp);
+
+ x87_fst(&cp->func, x86_make_disp(dst, 0));
+ x87_fst(&cp->func, x86_make_disp(dst, 4));
+ x87_fst(&cp->func, x86_make_disp(dst, 8));
+ x87_fst(&cp->func, x86_make_disp(dst, 12));
+ return GL_TRUE;
+}
+
+static GLboolean emit_EXP( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
+ struct x86_reg st0 = x86_make_reg(file_x87, 0);
+ struct x86_reg st1 = x86_make_reg(file_x87, 1);
+ struct x86_reg st3 = x86_make_reg(file_x87, 3);
+
+ /* CAUTION: dst may alias arg0!
+ */
+ x87_fld(&cp->func, arg0); /* arg0.x */
+ x87_fld(&cp->func, st0); /* arg arg */
+
+ /* by default, fpu is setup to round-to-nearest. We want to
+ * change this now, and track the state through to the end of the
+ * generated function so that it isn't repeated unnecessarily.
+ * Alternately, could subtract .5 to get round to -inf behaviour.
+ */
+ set_fpu_round_neg_inf( cp );
+ x87_fprndint( &cp->func ); /* flr(a) a */
+ x87_fld(&cp->func, st0); /* flr(a) flr(a) a */
+ x87_fld1(&cp->func); /* 1 floor(a) floor(a) a */
+ x87_fst(&cp->func, x86_make_disp(dst, 12)); /* stack unchanged */
+ x87_fscale(&cp->func); /* 2^floor(a) floor(a) a */
+ x87_fst(&cp->func, st3); /* 2^floor(a) floor(a) a 2^floor(a)*/
+ x87_fstp(&cp->func, x86_make_disp(dst, 0)); /* flr(a) a 2^flr(a) */
+ x87_fsubrp(&cp->func, st1); /* frac(a) 2^flr(a) */
+ x87_fst(&cp->func, x86_make_disp(dst, 4)); /* frac(a) 2^flr(a) */
+ x87_f2xm1(&cp->func); /* (2^frac(a))-1 2^flr(a)*/
+ x87_fld1(&cp->func); /* 1 (2^frac(a))-1 2^flr(a)*/
+ x87_faddp(&cp->func, st1); /* 2^frac(a) 2^flr(a) */
+ x87_fmulp(&cp->func, st1); /* 2^a */
+ x87_fst(&cp->func, x86_make_disp(dst, 8));
+
+
+
+/* dst[0] = 2^floor(tmp); */
+/* dst[1] = frac(tmp); */
+/* dst[2] = 2^floor(tmp) * 2^frac(tmp); */
+/* dst[3] = 1.0F; */
+ return GL_TRUE;
+}
+
+static GLboolean emit_LOG( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
+ struct x86_reg st0 = x86_make_reg(file_x87, 0);
+ struct x86_reg st1 = x86_make_reg(file_x87, 1);
+ struct x86_reg st2 = x86_make_reg(file_x87, 2);
+
+ /* CAUTION: dst may alias arg0!
+ */
+ x87_fld(&cp->func, arg0); /* arg0.x */
+ x87_fabs(&cp->func); /* |arg0.x| */
+ x87_fxtract(&cp->func); /* mantissa(arg0.x), exponent(arg0.x) */
+ x87_fst(&cp->func, st2); /* mantissa, exponent, mantissa */
+ x87_fld1(&cp->func); /* 1, mantissa, exponent, mantissa */
+ x87_fyl2x(&cp->func); /* log2(mantissa), exponent, mantissa */
+ x87_fadd(&cp->func, st0, st1); /* e+l2(m), e, m */
+ x87_fstp(&cp->func, x86_make_disp(dst, 8)); /* e, m */
+
+ x87_fld1(&cp->func); /* 1, e, m */
+ x87_fsub(&cp->func, st1, st0); /* 1, e-1, m */
+ x87_fstp(&cp->func, x86_make_disp(dst, 12)); /* e-1,m */
+ x87_fstp(&cp->func, dst); /* m */
+
+ x87_fadd(&cp->func, st0, st0); /* 2m */
+ x87_fstp(&cp->func, x86_make_disp(dst, 4));
+
+ return GL_TRUE;
+}
+
+static GLboolean emit_FLR( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
+ int i;
+
+ set_fpu_round_neg_inf( cp );
+
+ for (i = 0; i < 4; i++) {
+ x87_fld(&cp->func, x86_make_disp(arg0, i*4));
+ x87_fprndint( &cp->func );
+ x87_fstp(&cp->func, x86_make_disp(dst, i*4));
+ }
+
+
+ return GL_TRUE;
+}
+
+static GLboolean emit_FRC( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
+ struct x86_reg st0 = x86_make_reg(file_x87, 0);
+ struct x86_reg st1 = x86_make_reg(file_x87, 1);
+ int i;
+
+ set_fpu_round_neg_inf( cp );
+
+ /* Knowing liveness info or even just writemask would be useful
+ * here:
+ */
+ for (i = 0; i < 4; i++) {
+ x87_fld(&cp->func, x86_make_disp(arg0, i*4));
+ x87_fld(&cp->func, st0); /* a a */
+ x87_fprndint( &cp->func ); /* flr(a) a */
+ x87_fsubrp(&cp->func, st1); /* frc(a) */
+ x87_fstp(&cp->func, x86_make_disp(dst, i*4));
+ }
+
+ return GL_TRUE;
+}
+
+
+
+static GLboolean emit_LIT( struct compilation *cp, union instruction op )
+{
+#if 1
+ struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
+ struct x86_reg lit = get_arg(cp, FILE_REG, REG_LIT);
+ struct x86_reg tmp = get_xmm_reg(cp);
+ struct x86_reg st1 = x86_make_reg(file_x87, 1);
+ struct x86_reg regEAX = x86_make_reg(file_REG32, reg_AX);
+ GLubyte *fixup1, *fixup2;
+
+
+ /* Load the interesting parts of arg0:
+ */
+ x87_fld(&cp->func, x86_make_disp(arg0, 12)); /* a3 */
+ x87_fld(&cp->func, x86_make_disp(arg0, 4)); /* a1 a3 */
+ x87_fld(&cp->func, x86_make_disp(arg0, 0)); /* a0 a1 a3 */
+
+ /* Intialize dst:
+ */
+ sse_movaps(&cp->func, tmp, lit);
+ sse_movaps(&cp->func, dst, tmp);
+
+ /* Check arg0[0]:
+ */
+ x87_fldz(&cp->func); /* 0 a0 a1 a3 */
+ x87_fucomp(&cp->func, st1); /* a0 a1 a3 */
+ x87_fnstsw(&cp->func, regEAX);
+ x86_sahf(&cp->func);
+ fixup1 = x86_jcc_forward(&cp->func, cc_AE);
+
+ x87_fstp(&cp->func, x86_make_disp(dst, 4)); /* a1 a3 */
+
+ /* Check arg0[1]:
+ */
+ x87_fldz(&cp->func); /* 0 a1 a3 */
+ x87_fucomp(&cp->func, st1); /* a1 a3 */
+ x87_fnstsw(&cp->func, regEAX);
+ x86_sahf(&cp->func);
+ fixup2 = x86_jcc_forward(&cp->func, cc_AE);
+
+ /* Compute pow(a1, a3)
+ */
+ x87_fyl2x(&cp->func); /* a3*log2(a1) */
+
+ emit_x87_ex2( cp ); /* 2^(a3*log2(a1)) */
+
+ x87_fstp(&cp->func, x86_make_disp(dst, 8));
+
+ /* Land jumps:
+ */
+ x86_fixup_fwd_jump(&cp->func, fixup1);
+ x86_fixup_fwd_jump(&cp->func, fixup2);
+#else
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
+ struct x86_reg ones = get_reg_ptr(FILE_REG, REG_LIT);
+ sse_movups(&cp->func, dst, ones);
+#endif
+ return GL_TRUE;
+}
+
+
+
+static GLboolean emit_MAX( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
+
+ sse_movups(&cp->func, dst, arg0);
+ sse_maxps(&cp->func, dst, arg1);
+ return GL_TRUE;
+}
+
+
+static GLboolean emit_MIN( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
+
+ sse_movups(&cp->func, dst, arg0);
+ sse_minps(&cp->func, dst, arg1);
+ return GL_TRUE;
+}
+
+static GLboolean emit_MOV( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
+
+ sse_movups(&cp->func, dst, arg0);
+ return GL_TRUE;
+}
+
+static GLboolean emit_MUL( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
+
+ sse_movups(&cp->func, dst, arg0);
+ sse_mulps(&cp->func, dst, arg1);
+ return GL_TRUE;
+}
+
+
+static GLboolean emit_POW( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg_ptr(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg arg1 = get_arg_ptr(cp, op.alu.file1, op.alu.idx1);
+ struct x86_reg dst = get_dst_ptr(cp, FILE_REG, op.alu.dst);
+
+ x87_fld(&cp->func, arg1); /* a1 */
+ x87_fld(&cp->func, arg0); /* a0 a1 */
+ x87_fyl2x(&cp->func); /* a1*log2(a0) */
+
+ emit_x87_ex2( cp ); /* 2^(a1*log2(a0)) */
+
+ x87_fst(&cp->func, x86_make_disp(dst, 0));
+ x87_fst(&cp->func, x86_make_disp(dst, 4));
+ x87_fst(&cp->func, x86_make_disp(dst, 8));
+ x87_fstp(&cp->func, x86_make_disp(dst, 12));
+
+ return GL_TRUE;
+}
+
+static GLboolean emit_REL( struct compilation *cp, union instruction op )
+{
+/* GLuint idx = (op.alu.idx0 + (GLint)cp->File[0][REG_ADDR][0]) & (MAX_NV_VERTEX_PROGRAM_PARAMS-1); */
+/* GLuint idx = 0; */
+/* struct x86_reg arg0 = get_arg(cp, op.alu.file0, idx); */
+/* struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst); */
+
+/* dst[0] = arg0[0]; */
+/* dst[1] = arg0[1]; */
+/* dst[2] = arg0[2]; */
+/* dst[3] = arg0[3]; */
+
+ FAIL;
+}
+
+static GLboolean emit_RCP( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
+
+ if (cp->have_sse2) {
+ sse2_rcpss(&cp->func, dst, arg0);
+ }
+ else {
+ struct x86_reg ones = get_reg_ptr(FILE_REG, REG_ONES);
+ sse_movss(&cp->func, dst, ones);
+ sse_divss(&cp->func, dst, arg0);
+ }
+
+ sse_shufps(&cp->func, dst, dst, SHUF(X, X, X, X));
+ return GL_TRUE;
+}
+
+static GLboolean emit_RSQ( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
+
+ /* TODO: Calculate absolute value
+ */
+#if 0
+ sse_movss(&cp->func, dst, arg0);
+ sse_mulss(&cp->func, dst, neg);
+ sse_maxss(&cp->func, dst, arg0);
+#endif
+
+ sse_rsqrtss(&cp->func, dst, arg0);
+ sse_shufps(&cp->func, dst, dst, SHUF(X, X, X, X));
+ return GL_TRUE;
+}
+
+
+static GLboolean emit_SGE( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
+ struct x86_reg ones = get_reg_ptr(FILE_REG, REG_ONES);
+
+ sse_movups(&cp->func, dst, arg0);
+ sse_cmpps(&cp->func, dst, arg1, cc_NotLessThan);
+ sse_andps(&cp->func, dst, ones);
+ return GL_TRUE;
+}
+
+
+static GLboolean emit_SLT( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
+ struct x86_reg ones = get_reg_ptr(FILE_REG, REG_ONES);
+
+ sse_movups(&cp->func, dst, arg0);
+ sse_cmpps(&cp->func, dst, arg1, cc_LessThan);
+ sse_andps(&cp->func, dst, ones);
+ return GL_TRUE;
+}
+
+static GLboolean emit_SUB( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
+
+ sse_movups(&cp->func, dst, arg0);
+ sse_subps(&cp->func, dst, arg1);
+ return GL_TRUE;
+}
+
+
+static GLboolean emit_XPD( struct compilation *cp, union instruction op )
+{
+ struct x86_reg arg0 = get_arg(cp, op.alu.file0, op.alu.idx0);
+ struct x86_reg arg1 = get_arg(cp, op.alu.file1, op.alu.idx1);
+ struct x86_reg dst = get_dst_xmm_reg(cp, FILE_REG, op.alu.dst);
+ struct x86_reg tmp0 = get_xmm_reg(cp);
+ struct x86_reg tmp1 = get_xmm_reg(cp);
+
+ /* Could avoid tmp0, tmp1 if we overwrote arg0, arg1. Need a way
+ * to invalidate registers. This will come with better analysis
+ * (liveness analysis) of the incoming program.
+ */
+ emit_pshufd(cp, dst, arg0, SHUF(Y, Z, X, W));
+ emit_pshufd(cp, tmp1, arg1, SHUF(Z, X, Y, W));
+ sse_mulps(&cp->func, dst, tmp1);
+ emit_pshufd(cp, tmp0, arg0, SHUF(Z, X, Y, W));
+ emit_pshufd(cp, tmp1, arg1, SHUF(Y, Z, X, W));
+ sse_mulps(&cp->func, tmp0, tmp1);
+ sse_subps(&cp->func, dst, tmp0);
+
+/* dst[0] = arg0[1] * arg1[2] - arg0[2] * arg1[1]; */
+/* dst[1] = arg0[2] * arg1[0] - arg0[0] * arg1[2]; */
+/* dst[2] = arg0[0] * arg1[1] - arg0[1] * arg1[0]; */
+/* dst[3] is undef */
+
+ return GL_TRUE;
+}
+
+static GLboolean emit_NOP( struct compilation *cp, union instruction op )
+{
+ return GL_TRUE;
+}
+
+
+static GLboolean (* const emit_func[])(struct compilation *, union instruction) =
+{
+ emit_ABS,
+ emit_ADD,
+ emit_NOP,
+ emit_DP3,
+ emit_DP4,
+ emit_DPH,
+ emit_DST,
+ emit_NOP,
+ emit_EX2,
+ emit_EXP,
+ emit_FLR,
+ emit_FRC,
+ emit_LG2,
+ emit_LIT,
+ emit_LOG,
+ emit_NOP,
+ emit_MAX,
+ emit_MIN,
+ emit_MOV,
+ emit_MUL,
+ emit_POW,
+ emit_PRT,
+ emit_NOP,
+ emit_RCP,
+ emit_RSQ,
+ emit_SGE,
+ emit_SLT,
+ emit_SUB,
+ emit_RSW,
+ emit_XPD,
+ emit_RSW,
+ emit_MSK,
+ emit_REL,
+};
+
+
+
+static GLboolean build_vertex_program( struct compilation *cp )
+{
+ struct arb_vp_machine *m = NULL;
+ GLuint j;
+
+ struct x86_reg regEBX = x86_make_reg(file_REG32, reg_BX);
+ struct x86_reg regECX = x86_make_reg(file_REG32, reg_CX);
+ struct x86_reg regEDX = x86_make_reg(file_REG32, reg_DX);
+
+ x86_push(&cp->func, regEBX);
+
+ x86_mov(&cp->func, regEDX, x86_fn_arg(&cp->func, 1));
+ x86_mov(&cp->func, regEBX, x86_make_disp(regEDX, get_offset(m, m->File + FILE_REG)));
+ x86_mov(&cp->func, regECX, x86_make_disp(regEDX, get_offset(m, m->File + FILE_STATE_PARAM)));
+
+ for (j = 0; j < cp->p->nr_instructions; j++) {
+ union instruction inst = cp->p->instructions[j];
+ cp->insn_counter = j+1; /* avoid zero */
+
+ if (DISASSEM) {
+ _mesa_printf("%p: ", cp->func.csr);
+ _tnl_disassem_vba_insn( inst );
+ }
+ cp->func.fn = NULL;
+
+ if (!emit_func[inst.alu.opcode]( cp, inst )) {
+ return GL_FALSE;
+ }
+ }
+
+ /* TODO: only for outputs:
+ */
+ for (j = 0; j < 8; j++) {
+ if (cp->xmm[j].dirty)
+ spill(cp, j);
+ }
+
+
+ /* Exit mmx state?
+ */
+ if (cp->func.need_emms)
+ mmx_emms(&cp->func);
+
+ /* Restore FPU control word?
+ */
+ if (cp->fpucntl != RESTORE_FPU) {
+ x87_fnclex(&cp->func);
+ x87_fldcw(&cp->func, x86_make_disp(regEDX, get_offset(m, &m->fpucntl_restore)));
+ }
+
+ x86_pop(&cp->func, regEBX);
+ x86_ret(&cp->func);
+
+ return GL_TRUE;
+}
+
+/**
+ * Execute the given vertex program.
+ *
+ * TODO: Integrate the t_vertex.c code here, to build machine vertices
+ * directly at this point.
+ *
+ * TODO: Eliminate the VB struct entirely and just use
+ * struct arb_vertex_machine.
+ */
+GLboolean
+_tnl_sse_codegen_vertex_program(struct tnl_compiled_program *p)
+{
+ struct compilation cp;
+
+ memset(&cp, 0, sizeof(cp));
+ cp.p = p;
+ cp.have_sse2 = 1;
+
+ if (p->compiled_func) {
+ _mesa_free((void *)p->compiled_func);
+ p->compiled_func = NULL;
+ }
+
+ x86_init_func(&cp.func);
+
+ cp.fpucntl = RESTORE_FPU;
+
+
+ /* Note ctx state is not referenced in building the function, so it
+ * depends only on the list of instructions:
+ */
+ if (!build_vertex_program(&cp)) {
+ x86_release_func( &cp.func );
+ return GL_FALSE;
+ }
+
+
+ p->compiled_func = (void (*)(struct arb_vp_machine *))x86_get_func( &cp.func );
+ return GL_TRUE;
+}
+
+
+
+#else
+
+GLboolean
+_tnl_sse_codegen_vertex_program(struct tnl_compiled_program *p)
+{
+ /* Dummy version for when USE_SSE_ASM not defined */
+ return GL_FALSE;
+}
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_cliptmp.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_cliptmp.h
new file mode 100644
index 000000000..1e3a6b02e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_cliptmp.h
@@ -0,0 +1,270 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+#define CLIP_DOTPROD(K, A, B, C, D) X(K)*A + Y(K)*B + Z(K)*C + W(K)*D
+
+#define POLY_CLIP( PLANE, A, B, C, D ) \
+do { \
+ if (mask & PLANE) { \
+ GLuint idxPrev = inlist[0]; \
+ GLfloat dpPrev = CLIP_DOTPROD(idxPrev, A, B, C, D ); \
+ GLuint outcount = 0; \
+ GLuint i; \
+ \
+ inlist[n] = inlist[0]; /* prevent rotation of vertices */ \
+ for (i = 1; i <= n; i++) { \
+ GLuint idx = inlist[i]; \
+ GLfloat dp = CLIP_DOTPROD(idx, A, B, C, D ); \
+ \
+ clipmask[idxPrev] |= PLANE; \
+ if (!IS_NEGATIVE(dpPrev)) { \
+ outlist[outcount++] = idxPrev; \
+ clipmask[idxPrev] &= ~PLANE; \
+ } \
+ \
+ if (DIFFERENT_SIGNS(dp, dpPrev)) { \
+ GLuint newvert = VB->LastClipped++; \
+ VB->ClipMask[newvert] = 0; \
+ outlist[outcount++] = newvert; \
+ if (IS_NEGATIVE(dp)) { \
+ /* Going out of bounds. Avoid division by zero as we \
+ * know dp != dpPrev from DIFFERENT_SIGNS, above. \
+ */ \
+ GLfloat t = dp / (dp - dpPrev); \
+ INTERP_4F( t, coord[newvert], coord[idx], coord[idxPrev]); \
+ interp( ctx, t, newvert, idx, idxPrev, GL_TRUE ); \
+ } else { \
+ /* Coming back in. \
+ */ \
+ GLfloat t = dpPrev / (dpPrev - dp); \
+ INTERP_4F( t, coord[newvert], coord[idxPrev], coord[idx]); \
+ interp( ctx, t, newvert, idxPrev, idx, GL_FALSE ); \
+ } \
+ } \
+ \
+ idxPrev = idx; \
+ dpPrev = dp; \
+ } \
+ \
+ if (outcount < 3) \
+ return; \
+ \
+ { \
+ GLuint *tmp = inlist; \
+ inlist = outlist; \
+ outlist = tmp; \
+ n = outcount; \
+ } \
+ } \
+} while (0)
+
+
+#define LINE_CLIP(PLANE, A, B, C, D ) \
+do { \
+ if (mask & PLANE) { \
+ GLfloat dpI = CLIP_DOTPROD( ii, A, B, C, D ); \
+ GLfloat dpJ = CLIP_DOTPROD( jj, A, B, C, D ); \
+ \
+ if (DIFFERENT_SIGNS(dpI, dpJ)) { \
+ GLuint newvert = VB->LastClipped++; \
+ VB->ClipMask[newvert] = 0; \
+ if (IS_NEGATIVE(dpJ)) { \
+ GLfloat t = dpI / (dpI - dpJ); \
+ VB->ClipMask[jj] |= PLANE; \
+ INTERP_4F( t, coord[newvert], coord[ii], coord[jj] ); \
+ interp( ctx, t, newvert, ii, jj, GL_FALSE ); \
+ jj = newvert; \
+ } else { \
+ GLfloat t = dpJ / (dpJ - dpI); \
+ VB->ClipMask[ii] |= PLANE; \
+ INTERP_4F( t, coord[newvert], coord[jj], coord[ii] ); \
+ interp( ctx, t, newvert, jj, ii, GL_FALSE ); \
+ ii = newvert; \
+ } \
+ } \
+ else if (IS_NEGATIVE(dpI)) \
+ return; \
+ } \
+} while (0)
+
+
+
+/* Clip a line against the viewport and user clip planes.
+ */
+static INLINE void
+TAG(clip_line)( GLcontext *ctx, GLuint i, GLuint j, GLubyte mask )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ tnl_interp_func interp = tnl->Driver.Render.Interp;
+ GLfloat (*coord)[4] = VB->ClipPtr->data;
+ GLuint ii = i, jj = j, p;
+
+ VB->LastClipped = VB->Count;
+
+ if (mask & 0x3f) {
+ LINE_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 );
+ LINE_CLIP( CLIP_LEFT_BIT, 1, 0, 0, 1 );
+ LINE_CLIP( CLIP_TOP_BIT, 0, -1, 0, 1 );
+ LINE_CLIP( CLIP_BOTTOM_BIT, 0, 1, 0, 1 );
+ LINE_CLIP( CLIP_FAR_BIT, 0, 0, -1, 1 );
+ LINE_CLIP( CLIP_NEAR_BIT, 0, 0, 1, 1 );
+ }
+
+ if (mask & CLIP_USER_BIT) {
+ for (p=0;p<MAX_CLIP_PLANES;p++) {
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
+ const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
+ const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
+ const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
+ const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
+ LINE_CLIP( CLIP_USER_BIT, a, b, c, d );
+ }
+ }
+ }
+
+ if ((ctx->_TriangleCaps & DD_FLATSHADE) && j != jj)
+ tnl->Driver.Render.CopyPV( ctx, jj, j );
+
+ tnl->Driver.Render.ClippedLine( ctx, ii, jj );
+}
+
+
+/* Clip a triangle against the viewport and user clip planes.
+ */
+static INLINE void
+TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ tnl_interp_func interp = tnl->Driver.Render.Interp;
+ GLfloat (*coord)[4] = VB->ClipPtr->data;
+ GLuint pv = v2;
+ GLuint vlist[2][MAX_CLIPPED_VERTICES];
+ GLuint *inlist = vlist[0], *outlist = vlist[1];
+ GLuint p;
+ GLubyte *clipmask = VB->ClipMask;
+ GLuint n = 3;
+
+ ASSIGN_3V(inlist, v2, v0, v1 ); /* pv rotated to slot zero */
+
+ VB->LastClipped = VB->Count;
+
+ if (mask & 0x3f) {
+ POLY_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 );
+ POLY_CLIP( CLIP_LEFT_BIT, 1, 0, 0, 1 );
+ POLY_CLIP( CLIP_TOP_BIT, 0, -1, 0, 1 );
+ POLY_CLIP( CLIP_BOTTOM_BIT, 0, 1, 0, 1 );
+ POLY_CLIP( CLIP_FAR_BIT, 0, 0, -1, 1 );
+ POLY_CLIP( CLIP_NEAR_BIT, 0, 0, 1, 1 );
+ }
+
+ if (mask & CLIP_USER_BIT) {
+ for (p=0;p<MAX_CLIP_PLANES;p++) {
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
+ const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
+ const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
+ const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
+ const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
+ POLY_CLIP( CLIP_USER_BIT, a, b, c, d );
+ }
+ }
+ }
+
+ if (ctx->_TriangleCaps & DD_FLATSHADE) {
+ if (pv != inlist[0]) {
+ ASSERT( inlist[0] >= VB->Count );
+ tnl->Driver.Render.CopyPV( ctx, inlist[0], pv );
+ }
+ }
+
+ tnl->Driver.Render.ClippedPolygon( ctx, inlist, n );
+}
+
+
+/* Clip a quad against the viewport and user clip planes.
+ */
+static INLINE void
+TAG(clip_quad)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3,
+ GLubyte mask )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ tnl_interp_func interp = tnl->Driver.Render.Interp;
+ GLfloat (*coord)[4] = VB->ClipPtr->data;
+ GLuint pv = v3;
+ GLuint vlist[2][MAX_CLIPPED_VERTICES];
+ GLuint *inlist = vlist[0], *outlist = vlist[1];
+ GLuint p;
+ GLubyte *clipmask = VB->ClipMask;
+ GLuint n = 4;
+
+ ASSIGN_4V(inlist, v3, v0, v1, v2 ); /* pv rotated to slot zero */
+
+ VB->LastClipped = VB->Count;
+
+ if (mask & 0x3f) {
+ POLY_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 );
+ POLY_CLIP( CLIP_LEFT_BIT, 1, 0, 0, 1 );
+ POLY_CLIP( CLIP_TOP_BIT, 0, -1, 0, 1 );
+ POLY_CLIP( CLIP_BOTTOM_BIT, 0, 1, 0, 1 );
+ POLY_CLIP( CLIP_FAR_BIT, 0, 0, -1, 1 );
+ POLY_CLIP( CLIP_NEAR_BIT, 0, 0, 1, 1 );
+ }
+
+ if (mask & CLIP_USER_BIT) {
+ for (p=0;p<MAX_CLIP_PLANES;p++) {
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
+ const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
+ const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
+ const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
+ const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
+ POLY_CLIP( CLIP_USER_BIT, a, b, c, d );
+ }
+ }
+ }
+
+ if (ctx->_TriangleCaps & DD_FLATSHADE) {
+ if (pv != inlist[0]) {
+ ASSERT( inlist[0] >= VB->Count );
+ tnl->Driver.Render.CopyPV( ctx, inlist[0], pv );
+ }
+ }
+
+ tnl->Driver.Render.ClippedPolygon( ctx, inlist, n );
+}
+
+#undef W
+#undef Z
+#undef Y
+#undef X
+#undef SIZE
+#undef TAG
+#undef POLY_CLIP
+#undef LINE_CLIP
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_cull.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_cull.c
new file mode 100644
index 000000000..3f1294570
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_cull.c
@@ -0,0 +1,97 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+
+#include "math/m_xform.h"
+
+#include "t_context.h"
+#include "t_pipeline.h"
+
+
+
+/* EXT_vertex_cull. Not really a big win, but probably depends on
+ * your application. This stage not included in the default pipeline.
+ */
+static GLboolean run_cull_stage( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+
+ const GLfloat a = ctx->Transform.CullObjPos[0];
+ const GLfloat b = ctx->Transform.CullObjPos[1];
+ const GLfloat c = ctx->Transform.CullObjPos[2];
+ GLfloat *norm = (GLfloat *)VB->NormalPtr->data;
+ GLuint stride = VB->NormalPtr->stride;
+ GLuint count = VB->Count;
+ GLuint i;
+
+ if (ctx->VertexProgram._Enabled ||
+ !ctx->Transform.CullVertexFlag)
+ return GL_TRUE;
+
+ VB->ClipOrMask &= ~CLIP_CULL_BIT;
+ VB->ClipAndMask |= CLIP_CULL_BIT;
+
+ for (i = 0 ; i < count ; i++) {
+ GLfloat dp = (norm[0] * a +
+ norm[1] * b +
+ norm[2] * c);
+
+ if (dp < 0) {
+ VB->ClipMask[i] |= CLIP_CULL_BIT;
+ VB->ClipOrMask |= CLIP_CULL_BIT;
+ }
+ else {
+ VB->ClipMask[i] &= ~CLIP_CULL_BIT;
+ VB->ClipAndMask &= ~CLIP_CULL_BIT;
+ }
+
+ STRIDE_F(norm, stride);
+ }
+
+ return !(VB->ClipAndMask & CLIP_CULL_BIT);
+}
+
+
+
+const struct tnl_pipeline_stage _tnl_vertex_cull_stage =
+{
+ "EXT_cull_vertex",
+ NULL, /* private data */
+ NULL, /* ctr */
+ NULL, /* destructor */
+ NULL,
+ run_cull_stage /* run -- initially set to init */
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_fog.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_fog.c
new file mode 100644
index 000000000..f1d01bc47
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_fog.c
@@ -0,0 +1,266 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+
+#include "math/m_xform.h"
+
+#include "t_context.h"
+#include "t_pipeline.h"
+
+
+struct fog_stage_data {
+ GLvector4f fogcoord; /* has actual storage allocated */
+ GLvector4f input; /* points into VB->EyePtr Z values */
+};
+
+#define FOG_STAGE_DATA(stage) ((struct fog_stage_data *)stage->privatePtr)
+
+#define FOG_EXP_TABLE_SIZE 256
+#define FOG_MAX (10.0)
+#define EXP_FOG_MAX .0006595
+#define FOG_INCR (FOG_MAX/FOG_EXP_TABLE_SIZE)
+static GLfloat exp_table[FOG_EXP_TABLE_SIZE];
+static GLfloat inited = 0;
+
+#if 1
+#define NEG_EXP( result, narg ) \
+do { \
+ GLfloat f = (GLfloat) (narg * (1.0/FOG_INCR)); \
+ GLint k = (GLint) f; \
+ if (k > FOG_EXP_TABLE_SIZE-2) \
+ result = (GLfloat) EXP_FOG_MAX; \
+ else \
+ result = exp_table[k] + (f-k)*(exp_table[k+1]-exp_table[k]); \
+} while (0)
+#else
+#define NEG_EXP( result, narg ) \
+do { \
+ result = exp(-narg); \
+} while (0)
+#endif
+
+
+/**
+ * Initialize the exp_table[] lookup table for approximating exp().
+ */
+static void
+init_static_data( void )
+{
+ GLfloat f = 0.0F;
+ GLint i = 0;
+ for ( ; i < FOG_EXP_TABLE_SIZE ; i++, f += FOG_INCR) {
+ exp_table[i] = EXPF(-f);
+ }
+ inited = 1;
+}
+
+
+/**
+ * Compute per-vertex fog blend factors from fog coordinates by
+ * evaluating the GL_LINEAR, GL_EXP or GL_EXP2 fog function.
+ * Fog coordinates are distances from the eye (typically between the
+ * near and far clip plane distances).
+ * Note the fog (eye Z) coords may be negative so we use ABS(z) below.
+ * Fog blend factors are in the range [0,1].
+ */
+static void
+compute_fog_blend_factors(GLcontext *ctx, GLvector4f *out, const GLvector4f *in)
+{
+ GLfloat end = ctx->Fog.End;
+ GLfloat *v = in->start;
+ GLuint stride = in->stride;
+ GLuint n = in->count;
+ GLfloat (*data)[4] = out->data;
+ GLfloat d;
+ GLuint i;
+
+ out->count = in->count;
+
+ switch (ctx->Fog.Mode) {
+ case GL_LINEAR:
+ if (ctx->Fog.Start == ctx->Fog.End)
+ d = 1.0F;
+ else
+ d = 1.0F / (ctx->Fog.End - ctx->Fog.Start);
+ for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
+ const GLfloat z = FABSF(*v);
+ GLfloat f = (end - z) * d;
+ data[i][0] = CLAMP(f, 0.0F, 1.0F);
+ }
+ break;
+ case GL_EXP:
+ d = ctx->Fog.Density;
+ for ( i = 0 ; i < n ; i++, STRIDE_F(v,stride)) {
+ const GLfloat z = FABSF(*v);
+ NEG_EXP( data[i][0], d * z );
+ }
+ break;
+ case GL_EXP2:
+ d = ctx->Fog.Density*ctx->Fog.Density;
+ for ( i = 0 ; i < n ; i++, STRIDE_F(v, stride)) {
+ const GLfloat z = FABSF(*v);
+ NEG_EXP( data[i][0], d * z * z );
+ }
+ break;
+ default:
+ _mesa_problem(ctx, "Bad fog mode in make_fog_coord");
+ return;
+ }
+}
+
+
+static GLboolean
+run_fog_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ struct fog_stage_data *store = FOG_STAGE_DATA(stage);
+ GLvector4f *input;
+
+ if (!ctx->Fog.Enabled || ctx->VertexProgram._Enabled)
+ return GL_TRUE;
+
+
+ if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) {
+ /* Fog is computed from vertex or fragment Z values */
+ /* source = VB->ObjPtr or VB->EyePtr coords */
+ /* dest = VB->FogCoordPtr = fog stage private storage */
+ VB->FogCoordPtr = &store->fogcoord;
+
+ if (!ctx->_NeedEyeCoords) {
+ /* compute fog coords from object coords */
+ const GLfloat *m = ctx->ModelviewMatrixStack.Top->m;
+ GLfloat plane[4];
+
+ /* Use this to store calculated eye z values:
+ */
+ input = &store->fogcoord;
+
+ /* NOTE: negate plane here so we get positive fog coords! */
+ plane[0] = -m[2];
+ plane[1] = -m[6];
+ plane[2] = -m[10];
+ plane[3] = -m[14];
+ /* Full eye coords weren't required, just calculate the
+ * eye Z values.
+ */
+ _mesa_dotprod_tab[VB->ObjPtr->size]( (GLfloat *) input->data,
+ 4 * sizeof(GLfloat),
+ VB->ObjPtr, plane );
+
+ input->count = VB->ObjPtr->count;
+ }
+ else {
+ /* fog coordinates = eye Z coordinates (use ABS later) */
+ input = &store->input;
+
+ if (VB->EyePtr->size < 2)
+ _mesa_vector4f_clean_elem( VB->EyePtr, VB->Count, 2 );
+
+ input->data = (GLfloat (*)[4]) &(VB->EyePtr->data[0][2]);
+ input->start = VB->EyePtr->start+2;
+ input->stride = VB->EyePtr->stride;
+ input->count = VB->EyePtr->count;
+ }
+ }
+ else {
+ /* use glFogCoord() coordinates */
+ input = VB->FogCoordPtr; /* source data */
+
+ /* input->count may be one if glFogCoord was only called once
+ * before glBegin. But we need to compute fog for all vertices.
+ */
+ input->count = VB->ObjPtr->count;
+
+ VB->FogCoordPtr = &store->fogcoord; /* dest data */
+ }
+
+ if (tnl->_DoVertexFog) {
+ /* compute blend factors from fog coordinates */
+ compute_fog_blend_factors( ctx, VB->FogCoordPtr, input );
+ }
+ else {
+ /* results = incoming fog coords (compute fog per-fragment later) */
+ VB->FogCoordPtr = input;
+ }
+
+ VB->AttribPtr[_TNL_ATTRIB_FOG] = VB->FogCoordPtr;
+ return GL_TRUE;
+}
+
+
+
+/* Called the first time stage->run() is invoked.
+ */
+static GLboolean
+alloc_fog_data(GLcontext *ctx, struct tnl_pipeline_stage *stage)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct fog_stage_data *store;
+ stage->privatePtr = MALLOC(sizeof(*store));
+ store = FOG_STAGE_DATA(stage);
+ if (!store)
+ return GL_FALSE;
+
+ _mesa_vector4f_alloc( &store->fogcoord, 0, tnl->vb.Size, 32 );
+ _mesa_vector4f_init( &store->input, 0, NULL );
+
+ if (!inited)
+ init_static_data();
+
+ return GL_TRUE;
+}
+
+
+static void
+free_fog_data(struct tnl_pipeline_stage *stage)
+{
+ struct fog_stage_data *store = FOG_STAGE_DATA(stage);
+ if (store) {
+ _mesa_vector4f_free( &store->fogcoord );
+ FREE( store );
+ stage->privatePtr = NULL;
+ }
+}
+
+
+const struct tnl_pipeline_stage _tnl_fog_coordinate_stage =
+{
+ "build fog coordinates", /* name */
+ NULL, /* private_data */
+ alloc_fog_data, /* dtr */
+ free_fog_data, /* dtr */
+ NULL, /* check */
+ run_fog_stage /* run -- initially set to init. */
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_light.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_light.c
new file mode 100644
index 000000000..1deab4d43
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_light.c
@@ -0,0 +1,362 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+
+#include "glheader.h"
+#include "colormac.h"
+#include "light.h"
+#include "macros.h"
+#include "imports.h"
+#include "simple_list.h"
+#include "mtypes.h"
+
+#include "math/m_translate.h"
+
+#include "t_context.h"
+#include "t_pipeline.h"
+
+#define LIGHT_TWOSIDE 0x1
+#define LIGHT_MATERIAL 0x2
+#define MAX_LIGHT_FUNC 0x4
+
+typedef void (*light_func)( GLcontext *ctx,
+ struct vertex_buffer *VB,
+ struct tnl_pipeline_stage *stage,
+ GLvector4f *input );
+
+/**
+ * Information for updating current material attributes from vertex color,
+ * for GL_COLOR_MATERIAL.
+ */
+struct material_cursor {
+ const GLfloat *ptr; /* points to src vertex color (in VB array) */
+ GLuint stride; /* stride to next vertex color (bytes) */
+ GLfloat *current; /* points to material attribute to update */
+ GLuint size; /* vertex/color size: 1, 2, 3 or 4 */
+};
+
+/**
+ * Data private to this pipeline stage.
+ */
+struct light_stage_data {
+ GLvector4f Input;
+ GLvector4f LitColor[2];
+ GLvector4f LitSecondary[2];
+ GLvector4f LitIndex[2];
+ light_func *light_func_tab;
+
+ struct material_cursor mat[MAT_ATTRIB_MAX];
+ GLuint mat_count;
+ GLuint mat_bitmask;
+};
+
+
+#define LIGHT_STAGE_DATA(stage) ((struct light_stage_data *)(stage->privatePtr))
+
+
+
+/**
+ * In the case of colormaterial, the effected material attributes
+ * should already have been bound to point to the incoming color data,
+ * prior to running the pipeline.
+ * This function copies the vertex's color to the material attributes
+ * which are tracking glColor.
+ * It's called per-vertex in the lighting loop.
+ */
+static void
+update_materials(GLcontext *ctx, struct light_stage_data *store)
+{
+ GLuint i;
+
+ for (i = 0 ; i < store->mat_count ; i++) {
+ /* update the material */
+ COPY_CLEAN_4V(store->mat[i].current, store->mat[i].size, store->mat[i].ptr);
+ /* increment src vertex color pointer */
+ STRIDE_F(store->mat[i].ptr, store->mat[i].stride);
+ }
+
+ /* recompute derived light/material values */
+ _mesa_update_material( ctx, store->mat_bitmask );
+ /* XXX we should only call this if we're tracking/changing the specular
+ * exponent.
+ */
+ _mesa_validate_all_lighting_tables( ctx );
+}
+
+
+/**
+ * Prepare things prior to running the lighting stage.
+ * Return number of material attributes which will track vertex color.
+ */
+static GLuint
+prepare_materials(GLcontext *ctx,
+ struct vertex_buffer *VB, struct light_stage_data *store)
+{
+ GLuint i;
+
+ store->mat_count = 0;
+ store->mat_bitmask = 0;
+
+ /* Examine the ColorMaterialBitmask to determine which materials
+ * track vertex color. Override the material attribute's pointer
+ * with the color pointer for each one.
+ */
+ if (ctx->Light.ColorMaterialEnabled) {
+ const GLuint bitmask = ctx->Light.ColorMaterialBitmask;
+ for (i = 0 ; i < MAT_ATTRIB_MAX ; i++)
+ if (bitmask & (1<<i))
+ VB->AttribPtr[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] = VB->ColorPtr[0];
+ }
+
+ /* Now, for each material attribute that's tracking vertex color, save
+ * some values (ptr, stride, size, current) that we'll need in
+ * update_materials(), above, that'll actually copy the vertex color to
+ * the material attribute(s).
+ */
+ for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT ; i < _TNL_ATTRIB_INDEX ; i++) {
+ if (VB->AttribPtr[i]->stride) {
+ const GLuint j = store->mat_count++;
+ const GLuint attr = i - _TNL_ATTRIB_MAT_FRONT_AMBIENT;
+ store->mat[j].ptr = VB->AttribPtr[i]->start;
+ store->mat[j].stride = VB->AttribPtr[i]->stride;
+ store->mat[j].size = VB->AttribPtr[i]->size;
+ store->mat[j].current = ctx->Light.Material.Attrib[attr];
+ store->mat_bitmask |= (1<<attr);
+ }
+ }
+
+ /* FIXME: Is this already done?
+ */
+ _mesa_update_material( ctx, ~0 );
+ _mesa_validate_all_lighting_tables( ctx );
+
+ return store->mat_count;
+}
+
+/* Tables for all the shading functions.
+ */
+static light_func _tnl_light_tab[MAX_LIGHT_FUNC];
+static light_func _tnl_light_fast_tab[MAX_LIGHT_FUNC];
+static light_func _tnl_light_fast_single_tab[MAX_LIGHT_FUNC];
+static light_func _tnl_light_spec_tab[MAX_LIGHT_FUNC];
+static light_func _tnl_light_ci_tab[MAX_LIGHT_FUNC];
+
+#define TAG(x) x
+#define IDX (0)
+#include "t_vb_lighttmp.h"
+
+#define TAG(x) x##_twoside
+#define IDX (LIGHT_TWOSIDE)
+#include "t_vb_lighttmp.h"
+
+#define TAG(x) x##_material
+#define IDX (LIGHT_MATERIAL)
+#include "t_vb_lighttmp.h"
+
+#define TAG(x) x##_twoside_material
+#define IDX (LIGHT_TWOSIDE|LIGHT_MATERIAL)
+#include "t_vb_lighttmp.h"
+
+
+static void init_lighting_tables( void )
+{
+ static int done;
+
+ if (!done) {
+ init_light_tab();
+ init_light_tab_twoside();
+ init_light_tab_material();
+ init_light_tab_twoside_material();
+ done = 1;
+ }
+}
+
+
+static GLboolean run_lighting( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLvector4f *input = ctx->_NeedEyeCoords ? VB->EyePtr : VB->ObjPtr;
+ GLuint idx;
+
+ if (!ctx->Light.Enabled || ctx->VertexProgram._Enabled)
+ return GL_TRUE;
+
+ /* Make sure we can talk about position x,y and z:
+ */
+ if (input->size <= 2 && input == VB->ObjPtr) {
+
+ _math_trans_4f( store->Input.data,
+ VB->ObjPtr->data,
+ VB->ObjPtr->stride,
+ GL_FLOAT,
+ VB->ObjPtr->size,
+ 0,
+ VB->Count );
+
+ if (input->size <= 2) {
+ /* Clean z.
+ */
+ _mesa_vector4f_clean_elem(&store->Input, VB->Count, 2);
+ }
+
+ if (input->size <= 1) {
+ /* Clean y.
+ */
+ _mesa_vector4f_clean_elem(&store->Input, VB->Count, 1);
+ }
+
+ input = &store->Input;
+ }
+
+ idx = 0;
+
+ if (prepare_materials( ctx, VB, store ))
+ idx |= LIGHT_MATERIAL;
+
+ if (ctx->Light.Model.TwoSide)
+ idx |= LIGHT_TWOSIDE;
+
+ /* The individual functions know about replaying side-effects
+ * vs. full re-execution.
+ */
+ store->light_func_tab[idx]( ctx, VB, stage, input );
+
+ VB->AttribPtr[_TNL_ATTRIB_COLOR0] = VB->ColorPtr[0];
+ VB->AttribPtr[_TNL_ATTRIB_COLOR1] = VB->SecondaryColorPtr[0];
+ VB->AttribPtr[_TNL_ATTRIB_INDEX] = VB->IndexPtr[0];
+
+ return GL_TRUE;
+}
+
+
+/* Called in place of do_lighting when the light table may have changed.
+ */
+static void validate_lighting( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ light_func *tab;
+
+ if (!ctx->Light.Enabled || ctx->VertexProgram._Enabled)
+ return;
+
+ if (ctx->Visual.rgbMode) {
+ if (ctx->Light._NeedVertices) {
+ if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR)
+ tab = _tnl_light_spec_tab;
+ else
+ tab = _tnl_light_tab;
+ }
+ else {
+ if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev)
+ tab = _tnl_light_fast_single_tab;
+ else
+ tab = _tnl_light_fast_tab;
+ }
+ }
+ else
+ tab = _tnl_light_ci_tab;
+
+
+ LIGHT_STAGE_DATA(stage)->light_func_tab = tab;
+
+ /* This and the above should only be done on _NEW_LIGHT:
+ */
+ TNL_CONTEXT(ctx)->Driver.NotifyMaterialChange( ctx );
+}
+
+
+
+/* Called the first time stage->run is called. In effect, don't
+ * allocate data until the first time the stage is run.
+ */
+static GLboolean init_lighting( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct light_stage_data *store;
+ GLuint size = tnl->vb.Size;
+
+ stage->privatePtr = MALLOC(sizeof(*store));
+ store = LIGHT_STAGE_DATA(stage);
+ if (!store)
+ return GL_FALSE;
+
+ /* Do onetime init.
+ */
+ init_lighting_tables();
+
+ _mesa_vector4f_alloc( &store->Input, 0, size, 32 );
+ _mesa_vector4f_alloc( &store->LitColor[0], 0, size, 32 );
+ _mesa_vector4f_alloc( &store->LitColor[1], 0, size, 32 );
+ _mesa_vector4f_alloc( &store->LitSecondary[0], 0, size, 32 );
+ _mesa_vector4f_alloc( &store->LitSecondary[1], 0, size, 32 );
+ _mesa_vector4f_alloc( &store->LitIndex[0], 0, size, 32 );
+ _mesa_vector4f_alloc( &store->LitIndex[1], 0, size, 32 );
+
+ store->LitColor[0].size = 4;
+ store->LitColor[1].size = 4;
+ store->LitSecondary[0].size = 3;
+ store->LitSecondary[1].size = 3;
+
+ store->LitIndex[0].size = 1;
+ store->LitIndex[0].stride = sizeof(GLfloat);
+ store->LitIndex[1].size = 1;
+ store->LitIndex[1].stride = sizeof(GLfloat);
+
+ return GL_TRUE;
+}
+
+
+
+
+static void dtr( struct tnl_pipeline_stage *stage )
+{
+ struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
+
+ if (store) {
+ _mesa_vector4f_free( &store->Input );
+ _mesa_vector4f_free( &store->LitColor[0] );
+ _mesa_vector4f_free( &store->LitColor[1] );
+ _mesa_vector4f_free( &store->LitSecondary[0] );
+ _mesa_vector4f_free( &store->LitSecondary[1] );
+ _mesa_vector4f_free( &store->LitIndex[0] );
+ _mesa_vector4f_free( &store->LitIndex[1] );
+ FREE( store );
+ stage->privatePtr = NULL;
+ }
+}
+
+const struct tnl_pipeline_stage _tnl_lighting_stage =
+{
+ "lighting", /* name */
+ NULL, /* private_data */
+ init_lighting,
+ dtr, /* destroy */
+ validate_lighting,
+ run_lighting
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_lighttmp.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_lighttmp.h
new file mode 100644
index 000000000..a27f70842
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_lighttmp.h
@@ -0,0 +1,824 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ *
+ *
+ * Authors:
+ * Brian Paul
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+#if IDX & LIGHT_TWOSIDE
+# define NR_SIDES 2
+#else
+# define NR_SIDES 1
+#endif
+
+
+/* define TRACE to trace lighting code */
+/* #define TRACE 1 */
+
+/*
+ * ctx is the current context
+ * VB is the vertex buffer
+ * stage is the lighting stage-private data
+ * input is the vector of eye or object-space vertex coordinates
+ */
+static void TAG(light_rgba_spec)( GLcontext *ctx,
+ struct vertex_buffer *VB,
+ struct tnl_pipeline_stage *stage,
+ GLvector4f *input )
+{
+ struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
+ GLfloat (*base)[3] = ctx->Light._BaseColor;
+ GLfloat sumA[2];
+ GLuint j;
+
+ const GLuint vstride = input->stride;
+ const GLfloat *vertex = (GLfloat *)input->data;
+ const GLuint nstride = VB->NormalPtr->stride;
+ const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
+
+ GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
+ GLfloat (*Fspec)[4] = (GLfloat (*)[4]) store->LitSecondary[0].data;
+#if IDX & LIGHT_TWOSIDE
+ GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
+ GLfloat (*Bspec)[4] = (GLfloat (*)[4]) store->LitSecondary[1].data;
+#endif
+
+ const GLuint nr = VB->Count;
+
+#ifdef TRACE
+ fprintf(stderr, "%s\n", __FUNCTION__ );
+#endif
+
+ VB->ColorPtr[0] = &store->LitColor[0];
+ VB->SecondaryColorPtr[0] = &store->LitSecondary[0];
+ sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
+
+#if IDX & LIGHT_TWOSIDE
+ VB->ColorPtr[1] = &store->LitColor[1];
+ VB->SecondaryColorPtr[1] = &store->LitSecondary[1];
+ sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+#endif
+
+
+ store->LitColor[0].stride = 16;
+ store->LitColor[1].stride = 16;
+
+ for (j = 0; j < nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal,nstride)) {
+ GLfloat sum[2][3], spec[2][3];
+ struct gl_light *light;
+
+#if IDX & LIGHT_MATERIAL
+ update_materials( ctx, store );
+ sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
+#if IDX & LIGHT_TWOSIDE
+ sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+#endif
+#endif
+
+ COPY_3V(sum[0], base[0]);
+ ZERO_3V(spec[0]);
+
+#if IDX & LIGHT_TWOSIDE
+ COPY_3V(sum[1], base[1]);
+ ZERO_3V(spec[1]);
+#endif
+
+ /* Add contribution from each enabled light source */
+ foreach (light, &ctx->Light.EnabledList) {
+ GLfloat n_dot_h;
+ GLfloat correction;
+ GLint side;
+ GLfloat contrib[3];
+ GLfloat attenuation;
+ GLfloat VP[3]; /* unit vector from vertex to light */
+ GLfloat n_dot_VP; /* n dot VP */
+ GLfloat *h;
+
+ /* compute VP and attenuation */
+ if (!(light->_Flags & LIGHT_POSITIONAL)) {
+ /* directional light */
+ COPY_3V(VP, light->_VP_inf_norm);
+ attenuation = light->_VP_inf_spot_attenuation;
+ }
+ else {
+ GLfloat d; /* distance from vertex to light */
+
+ SUB_3V(VP, light->_Position, vertex);
+
+ d = (GLfloat) LEN_3FV( VP );
+
+ if (d > 1e-6) {
+ GLfloat invd = 1.0F / d;
+ SELF_SCALE_SCALAR_3V(VP, invd);
+ }
+
+ attenuation = 1.0F / (light->ConstantAttenuation + d *
+ (light->LinearAttenuation + d *
+ light->QuadraticAttenuation));
+
+ /* spotlight attenuation */
+ if (light->_Flags & LIGHT_SPOT) {
+ GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
+
+ if (PV_dot_dir<light->_CosCutoff) {
+ continue; /* this light makes no contribution */
+ }
+ else {
+ GLdouble x = PV_dot_dir * (EXP_TABLE_SIZE-1);
+ GLint k = (GLint) x;
+ GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0]
+ + (x-k)*light->_SpotExpTable[k][1]);
+ attenuation *= spot;
+ }
+ }
+ }
+
+ if (attenuation < 1e-3)
+ continue; /* this light makes no contribution */
+
+ /* Compute dot product or normal and vector from V to light pos */
+ n_dot_VP = DOT3( normal, VP );
+
+ /* Which side gets the diffuse & specular terms? */
+ if (n_dot_VP < 0.0F) {
+ ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]);
+#if IDX & LIGHT_TWOSIDE
+ side = 1;
+ correction = -1;
+ n_dot_VP = -n_dot_VP;
+#else
+ continue;
+#endif
+ }
+ else {
+#if IDX & LIGHT_TWOSIDE
+ ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]);
+#endif
+ side = 0;
+ correction = 1;
+ }
+
+ /* diffuse term */
+ COPY_3V(contrib, light->_MatAmbient[side]);
+ ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->_MatDiffuse[side]);
+ ACC_SCALE_SCALAR_3V(sum[side], attenuation, contrib );
+
+ /* specular term - cannibalize VP... */
+ if (ctx->Light.Model.LocalViewer) {
+ GLfloat v[3];
+ COPY_3V(v, vertex);
+ NORMALIZE_3FV(v);
+ SUB_3V(VP, VP, v); /* h = VP + VPe */
+ h = VP;
+ NORMALIZE_3FV(h);
+ }
+ else if (light->_Flags & LIGHT_POSITIONAL) {
+ h = VP;
+ ACC_3V(h, ctx->_EyeZDir);
+ NORMALIZE_3FV(h);
+ }
+ else {
+ h = light->_h_inf_norm;
+ }
+
+ n_dot_h = correction * DOT3(normal, h);
+
+ if (n_dot_h > 0.0F) {
+ GLfloat spec_coef;
+ struct gl_shine_tab *tab = ctx->_ShineTable[side];
+ GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef );
+
+ if (spec_coef > 1.0e-10) {
+ spec_coef *= attenuation;
+ ACC_SCALE_SCALAR_3V( spec[side], spec_coef,
+ light->_MatSpecular[side]);
+ }
+ }
+ } /*loop over lights*/
+
+ COPY_3V( Fcolor[j], sum[0] );
+ COPY_3V( Fspec[j], spec[0] );
+ Fcolor[j][3] = sumA[0];
+
+#if IDX & LIGHT_TWOSIDE
+ COPY_3V( Bcolor[j], sum[1] );
+ COPY_3V( Bspec[j], spec[1] );
+ Bcolor[j][3] = sumA[1];
+#endif
+ }
+}
+
+
+static void TAG(light_rgba)( GLcontext *ctx,
+ struct vertex_buffer *VB,
+ struct tnl_pipeline_stage *stage,
+ GLvector4f *input )
+{
+ struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
+ GLuint j;
+
+ GLfloat (*base)[3] = ctx->Light._BaseColor;
+ GLfloat sumA[2];
+
+ const GLuint vstride = input->stride;
+ const GLfloat *vertex = (GLfloat *) input->data;
+ const GLuint nstride = VB->NormalPtr->stride;
+ const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
+
+ GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
+#if IDX & LIGHT_TWOSIDE
+ GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
+#endif
+
+ const GLuint nr = VB->Count;
+
+#ifdef TRACE
+ fprintf(stderr, "%s\n", __FUNCTION__ );
+#endif
+
+ VB->ColorPtr[0] = &store->LitColor[0];
+ sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
+
+#if IDX & LIGHT_TWOSIDE
+ VB->ColorPtr[1] = &store->LitColor[1];
+ sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+#endif
+
+ store->LitColor[0].stride = 16;
+ store->LitColor[1].stride = 16;
+
+ for (j = 0; j < nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal,nstride)) {
+ GLfloat sum[2][3];
+ struct gl_light *light;
+
+#if IDX & LIGHT_MATERIAL
+ update_materials( ctx, store );
+ sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
+#if IDX & LIGHT_TWOSIDE
+ sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+#endif
+#endif
+
+ COPY_3V(sum[0], base[0]);
+
+#if IDX & LIGHT_TWOSIDE
+ COPY_3V(sum[1], base[1]);
+#endif
+
+ /* Add contribution from each enabled light source */
+ foreach (light, &ctx->Light.EnabledList) {
+
+ GLfloat n_dot_h;
+ GLfloat correction;
+ GLint side;
+ GLfloat contrib[3];
+ GLfloat attenuation = 1.0;
+ GLfloat VP[3]; /* unit vector from vertex to light */
+ GLfloat n_dot_VP; /* n dot VP */
+ GLfloat *h;
+
+ /* compute VP and attenuation */
+ if (!(light->_Flags & LIGHT_POSITIONAL)) {
+ /* directional light */
+ COPY_3V(VP, light->_VP_inf_norm);
+ attenuation = light->_VP_inf_spot_attenuation;
+ }
+ else {
+ GLfloat d; /* distance from vertex to light */
+
+
+ SUB_3V(VP, light->_Position, vertex);
+
+ d = (GLfloat) LEN_3FV( VP );
+
+ if ( d > 1e-6) {
+ GLfloat invd = 1.0F / d;
+ SELF_SCALE_SCALAR_3V(VP, invd);
+ }
+
+ attenuation = 1.0F / (light->ConstantAttenuation + d *
+ (light->LinearAttenuation + d *
+ light->QuadraticAttenuation));
+
+ /* spotlight attenuation */
+ if (light->_Flags & LIGHT_SPOT) {
+ GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
+
+ if (PV_dot_dir<light->_CosCutoff) {
+ continue; /* this light makes no contribution */
+ }
+ else {
+ GLdouble x = PV_dot_dir * (EXP_TABLE_SIZE-1);
+ GLint k = (GLint) x;
+ GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0]
+ + (x-k)*light->_SpotExpTable[k][1]);
+ attenuation *= spot;
+ }
+ }
+ }
+
+ if (attenuation < 1e-3)
+ continue; /* this light makes no contribution */
+
+ /* Compute dot product or normal and vector from V to light pos */
+ n_dot_VP = DOT3( normal, VP );
+
+ /* which side are we lighting? */
+ if (n_dot_VP < 0.0F) {
+ ACC_SCALE_SCALAR_3V(sum[0], attenuation, light->_MatAmbient[0]);
+#if IDX & LIGHT_TWOSIDE
+ side = 1;
+ correction = -1;
+ n_dot_VP = -n_dot_VP;
+#else
+ continue;
+#endif
+ }
+ else {
+#if IDX & LIGHT_TWOSIDE
+ ACC_SCALE_SCALAR_3V( sum[1], attenuation, light->_MatAmbient[1]);
+#endif
+ side = 0;
+ correction = 1;
+ }
+
+ COPY_3V(contrib, light->_MatAmbient[side]);
+
+ /* diffuse term */
+ ACC_SCALE_SCALAR_3V(contrib, n_dot_VP, light->_MatDiffuse[side]);
+
+ /* specular term - cannibalize VP... */
+ {
+ if (ctx->Light.Model.LocalViewer) {
+ GLfloat v[3];
+ COPY_3V(v, vertex);
+ NORMALIZE_3FV(v);
+ SUB_3V(VP, VP, v); /* h = VP + VPe */
+ h = VP;
+ NORMALIZE_3FV(h);
+ }
+ else if (light->_Flags & LIGHT_POSITIONAL) {
+ h = VP;
+ ACC_3V(h, ctx->_EyeZDir);
+ NORMALIZE_3FV(h);
+ }
+ else {
+ h = light->_h_inf_norm;
+ }
+
+ n_dot_h = correction * DOT3(normal, h);
+
+ if (n_dot_h > 0.0F)
+ {
+ GLfloat spec_coef;
+ struct gl_shine_tab *tab = ctx->_ShineTable[side];
+
+ GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef );
+
+ ACC_SCALE_SCALAR_3V( contrib, spec_coef,
+ light->_MatSpecular[side]);
+ }
+ }
+
+ ACC_SCALE_SCALAR_3V( sum[side], attenuation, contrib );
+ }
+
+ COPY_3V( Fcolor[j], sum[0] );
+ Fcolor[j][3] = sumA[0];
+
+#if IDX & LIGHT_TWOSIDE
+ COPY_3V( Bcolor[j], sum[1] );
+ Bcolor[j][3] = sumA[1];
+#endif
+ }
+}
+
+
+
+
+/* As below, but with just a single light.
+ */
+static void TAG(light_fast_rgba_single)( GLcontext *ctx,
+ struct vertex_buffer *VB,
+ struct tnl_pipeline_stage *stage,
+ GLvector4f *input )
+
+{
+ struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
+ const GLuint nstride = VB->NormalPtr->stride;
+ const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
+ GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
+#if IDX & LIGHT_TWOSIDE
+ GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
+#endif
+ const struct gl_light *light = ctx->Light.EnabledList.next;
+ GLuint j = 0;
+ GLfloat base[2][4];
+#if IDX & LIGHT_MATERIAL
+ const GLuint nr = VB->Count;
+#else
+ const GLuint nr = VB->NormalPtr->count;
+#endif
+
+#ifdef TRACE
+ fprintf(stderr, "%s\n", __FUNCTION__ );
+#endif
+
+ (void) input; /* doesn't refer to Eye or Obj */
+
+ VB->ColorPtr[0] = &store->LitColor[0];
+#if IDX & LIGHT_TWOSIDE
+ VB->ColorPtr[1] = &store->LitColor[1];
+#endif
+
+ if (nr > 1) {
+ store->LitColor[0].stride = 16;
+ store->LitColor[1].stride = 16;
+ }
+ else {
+ store->LitColor[0].stride = 0;
+ store->LitColor[1].stride = 0;
+ }
+
+ for (j = 0; j < nr; j++, STRIDE_F(normal,nstride)) {
+
+ GLfloat n_dot_VP;
+
+#if IDX & LIGHT_MATERIAL
+ update_materials( ctx, store );
+#endif
+
+ /* No attenuation, so incoporate _MatAmbient into base color.
+ */
+#if !(IDX & LIGHT_MATERIAL)
+ if ( j == 0 )
+#endif
+ {
+ COPY_3V(base[0], light->_MatAmbient[0]);
+ ACC_3V(base[0], ctx->Light._BaseColor[0] );
+ base[0][3] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
+
+#if IDX & LIGHT_TWOSIDE
+ COPY_3V(base[1], light->_MatAmbient[1]);
+ ACC_3V(base[1], ctx->Light._BaseColor[1]);
+ base[1][3] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+#endif
+ }
+
+ n_dot_VP = DOT3(normal, light->_VP_inf_norm);
+
+ if (n_dot_VP < 0.0F) {
+#if IDX & LIGHT_TWOSIDE
+ GLfloat n_dot_h = -DOT3(normal, light->_h_inf_norm);
+ GLfloat sum[3];
+ COPY_3V(sum, base[1]);
+ ACC_SCALE_SCALAR_3V(sum, -n_dot_VP, light->_MatDiffuse[1]);
+ if (n_dot_h > 0.0F) {
+ GLfloat spec;
+ GET_SHINE_TAB_ENTRY( ctx->_ShineTable[1], n_dot_h, spec );
+ ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[1]);
+ }
+ COPY_3V(Bcolor[j], sum );
+ Bcolor[j][3] = base[1][3];
+#endif
+ COPY_4FV(Fcolor[j], base[0]);
+ }
+ else {
+ GLfloat n_dot_h = DOT3(normal, light->_h_inf_norm);
+ GLfloat sum[3];
+ COPY_3V(sum, base[0]);
+ ACC_SCALE_SCALAR_3V(sum, n_dot_VP, light->_MatDiffuse[0]);
+ if (n_dot_h > 0.0F) {
+ GLfloat spec;
+ GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec );
+ ACC_SCALE_SCALAR_3V(sum, spec, light->_MatSpecular[0]);
+
+ }
+ COPY_3V(Fcolor[j], sum );
+ Fcolor[j][3] = base[0][3];
+#if IDX & LIGHT_TWOSIDE
+ COPY_4FV(Bcolor[j], base[1]);
+#endif
+ }
+ }
+}
+
+
+/* Light infinite lights
+ */
+static void TAG(light_fast_rgba)( GLcontext *ctx,
+ struct vertex_buffer *VB,
+ struct tnl_pipeline_stage *stage,
+ GLvector4f *input )
+{
+ struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
+ GLfloat sumA[2];
+ const GLuint nstride = VB->NormalPtr->stride;
+ const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
+ GLfloat (*Fcolor)[4] = (GLfloat (*)[4]) store->LitColor[0].data;
+#if IDX & LIGHT_TWOSIDE
+ GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data;
+#endif
+ GLuint j = 0;
+#if IDX & LIGHT_MATERIAL
+ const GLuint nr = VB->Count;
+#else
+ const GLuint nr = VB->NormalPtr->count;
+#endif
+ const struct gl_light *light;
+
+#ifdef TRACE
+ fprintf(stderr, "%s %d\n", __FUNCTION__, nr );
+#endif
+
+ (void) input;
+
+ sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
+ sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+
+ VB->ColorPtr[0] = &store->LitColor[0];
+#if IDX & LIGHT_TWOSIDE
+ VB->ColorPtr[1] = &store->LitColor[1];
+#endif
+
+ if (nr > 1) {
+ store->LitColor[0].stride = 16;
+ store->LitColor[1].stride = 16;
+ }
+ else {
+ store->LitColor[0].stride = 0;
+ store->LitColor[1].stride = 0;
+ }
+
+ for (j = 0; j < nr; j++, STRIDE_F(normal,nstride)) {
+
+ GLfloat sum[2][3];
+
+#if IDX & LIGHT_MATERIAL
+ update_materials( ctx, store );
+
+ sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3];
+#if IDX & LIGHT_TWOSIDE
+ sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3];
+#endif
+#endif
+
+
+ COPY_3V(sum[0], ctx->Light._BaseColor[0]);
+#if IDX & LIGHT_TWOSIDE
+ COPY_3V(sum[1], ctx->Light._BaseColor[1]);
+#endif
+
+ foreach (light, &ctx->Light.EnabledList) {
+ GLfloat n_dot_h, n_dot_VP, spec;
+
+ ACC_3V(sum[0], light->_MatAmbient[0]);
+#if IDX & LIGHT_TWOSIDE
+ ACC_3V(sum[1], light->_MatAmbient[1]);
+#endif
+
+ n_dot_VP = DOT3(normal, light->_VP_inf_norm);
+
+ if (n_dot_VP > 0.0F) {
+ ACC_SCALE_SCALAR_3V(sum[0], n_dot_VP, light->_MatDiffuse[0]);
+ n_dot_h = DOT3(normal, light->_h_inf_norm);
+ if (n_dot_h > 0.0F) {
+ struct gl_shine_tab *tab = ctx->_ShineTable[0];
+ GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec );
+ ACC_SCALE_SCALAR_3V( sum[0], spec, light->_MatSpecular[0]);
+ }
+ }
+#if IDX & LIGHT_TWOSIDE
+ else {
+ ACC_SCALE_SCALAR_3V(sum[1], -n_dot_VP, light->_MatDiffuse[1]);
+ n_dot_h = -DOT3(normal, light->_h_inf_norm);
+ if (n_dot_h > 0.0F) {
+ struct gl_shine_tab *tab = ctx->_ShineTable[1];
+ GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec );
+ ACC_SCALE_SCALAR_3V( sum[1], spec, light->_MatSpecular[1]);
+ }
+ }
+#endif
+ }
+
+ COPY_3V( Fcolor[j], sum[0] );
+ Fcolor[j][3] = sumA[0];
+
+#if IDX & LIGHT_TWOSIDE
+ COPY_3V( Bcolor[j], sum[1] );
+ Bcolor[j][3] = sumA[1];
+#endif
+ }
+}
+
+
+
+
+
+/*
+ * Use current lighting/material settings to compute the color indexes
+ * for an array of vertices.
+ * Input: n - number of vertices to light
+ * side - 0=use front material, 1=use back material
+ * vertex - array of [n] vertex position in eye coordinates
+ * normal - array of [n] surface normal vector
+ * Output: indexResult - resulting array of [n] color indexes
+ */
+static void TAG(light_ci)( GLcontext *ctx,
+ struct vertex_buffer *VB,
+ struct tnl_pipeline_stage *stage,
+ GLvector4f *input )
+{
+ struct light_stage_data *store = LIGHT_STAGE_DATA(stage);
+ GLuint j;
+ const GLuint vstride = input->stride;
+ const GLfloat *vertex = (GLfloat *) input->data;
+ const GLuint nstride = VB->NormalPtr->stride;
+ const GLfloat *normal = (GLfloat *)VB->NormalPtr->data;
+ GLfloat *indexResult[2];
+ const GLuint nr = VB->Count;
+
+#ifdef TRACE
+ fprintf(stderr, "%s\n", __FUNCTION__ );
+#endif
+
+ VB->IndexPtr[0] = &store->LitIndex[0];
+#if IDX & LIGHT_TWOSIDE
+ VB->IndexPtr[1] = &store->LitIndex[1];
+#endif
+
+ indexResult[0] = (GLfloat *)VB->IndexPtr[0]->data;
+#if IDX & LIGHT_TWOSIDE
+ indexResult[1] = (GLfloat *)VB->IndexPtr[1]->data;
+#endif
+
+ /* loop over vertices */
+ for (j=0; j<nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal, nstride)) {
+ GLfloat diffuse[2], specular[2];
+ GLuint side = 0;
+ struct gl_light *light;
+
+#if IDX & LIGHT_MATERIAL
+ update_materials( ctx, store );
+#endif
+
+ diffuse[0] = specular[0] = 0.0F;
+
+#if IDX & LIGHT_TWOSIDE
+ diffuse[1] = specular[1] = 0.0F;
+#endif
+
+ /* Accumulate diffuse and specular from each light source */
+ foreach (light, &ctx->Light.EnabledList) {
+
+ GLfloat attenuation = 1.0F;
+ GLfloat VP[3]; /* unit vector from vertex to light */
+ GLfloat n_dot_VP; /* dot product of l and n */
+ GLfloat *h, n_dot_h, correction = 1.0;
+
+ /* compute l and attenuation */
+ if (!(light->_Flags & LIGHT_POSITIONAL)) {
+ /* directional light */
+ COPY_3V(VP, light->_VP_inf_norm);
+ }
+ else {
+ GLfloat d; /* distance from vertex to light */
+
+ SUB_3V(VP, light->_Position, vertex);
+
+ d = (GLfloat) LEN_3FV( VP );
+ if ( d > 1e-6) {
+ GLfloat invd = 1.0F / d;
+ SELF_SCALE_SCALAR_3V(VP, invd);
+ }
+
+ attenuation = 1.0F / (light->ConstantAttenuation + d *
+ (light->LinearAttenuation + d *
+ light->QuadraticAttenuation));
+
+ /* spotlight attenuation */
+ if (light->_Flags & LIGHT_SPOT) {
+ GLfloat PV_dot_dir = - DOT3(VP, light->_NormDirection);
+ if (PV_dot_dir < light->_CosCutoff) {
+ continue; /* this light makes no contribution */
+ }
+ else {
+ GLdouble x = PV_dot_dir * (EXP_TABLE_SIZE-1);
+ GLint k = (GLint) x;
+ GLfloat spot = (GLfloat) (light->_SpotExpTable[k][0]
+ + (x-k)*light->_SpotExpTable[k][1]);
+ attenuation *= spot;
+ }
+ }
+ }
+
+ if (attenuation < 1e-3)
+ continue; /* this light makes no contribution */
+
+ n_dot_VP = DOT3( normal, VP );
+
+ /* which side are we lighting? */
+ if (n_dot_VP < 0.0F) {
+#if IDX & LIGHT_TWOSIDE
+ side = 1;
+ correction = -1;
+ n_dot_VP = -n_dot_VP;
+#else
+ continue;
+#endif
+ }
+
+ /* accumulate diffuse term */
+ diffuse[side] += n_dot_VP * light->_dli * attenuation;
+
+ /* specular term */
+ if (ctx->Light.Model.LocalViewer) {
+ GLfloat v[3];
+ COPY_3V(v, vertex);
+ NORMALIZE_3FV(v);
+ SUB_3V(VP, VP, v); /* h = VP + VPe */
+ h = VP;
+ NORMALIZE_3FV(h);
+ }
+ else if (light->_Flags & LIGHT_POSITIONAL) {
+ h = VP;
+ /* Strangely, disabling this addition fixes a conformance
+ * problem. If this code is enabled, l_sed.c fails.
+ */
+ /*ACC_3V(h, ctx->_EyeZDir);*/
+ NORMALIZE_3FV(h);
+ }
+ else {
+ h = light->_h_inf_norm;
+ }
+
+ n_dot_h = correction * DOT3(normal, h);
+ if (n_dot_h > 0.0F) {
+ GLfloat spec_coef;
+ struct gl_shine_tab *tab = ctx->_ShineTable[side];
+ GET_SHINE_TAB_ENTRY( tab, n_dot_h, spec_coef);
+ specular[side] += spec_coef * light->_sli * attenuation;
+ }
+ } /*loop over lights*/
+
+ /* Now compute final color index */
+ for (side = 0 ; side < NR_SIDES ; side++) {
+ const GLfloat *ind = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_INDEXES + side];
+ GLfloat index;
+
+ if (specular[side] > 1.0F) {
+ index = ind[MAT_INDEX_SPECULAR];
+ }
+ else {
+ GLfloat d_a = ind[MAT_INDEX_DIFFUSE] - ind[MAT_INDEX_AMBIENT];
+ GLfloat s_a = ind[MAT_INDEX_SPECULAR] - ind[MAT_INDEX_AMBIENT];
+ index = (ind[MAT_INDEX_AMBIENT]
+ + diffuse[side] * (1.0F-specular[side]) * d_a
+ + specular[side] * s_a);
+ if (index > ind[MAT_INDEX_SPECULAR]) {
+ index = ind[MAT_INDEX_SPECULAR];
+ }
+ }
+ indexResult[side][j] = index;
+ }
+ } /*for vertex*/
+}
+
+
+
+static void TAG(init_light_tab)( void )
+{
+ _tnl_light_tab[IDX] = TAG(light_rgba);
+ _tnl_light_fast_tab[IDX] = TAG(light_fast_rgba);
+ _tnl_light_fast_single_tab[IDX] = TAG(light_fast_rgba_single);
+ _tnl_light_spec_tab[IDX] = TAG(light_rgba_spec);
+ _tnl_light_ci_tab[IDX] = TAG(light_ci);
+}
+
+
+#undef TAG
+#undef IDX
+#undef NR_SIDES
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_normals.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_normals.c
new file mode 100644
index 000000000..7ac33f8be
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_normals.c
@@ -0,0 +1,189 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+
+#include "math/m_xform.h"
+
+#include "t_context.h"
+#include "t_pipeline.h"
+
+
+struct normal_stage_data {
+ normal_func NormalTransform;
+ GLvector4f normal;
+};
+
+#define NORMAL_STAGE_DATA(stage) ((struct normal_stage_data *)stage->privatePtr)
+
+
+static GLboolean
+run_normal_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
+{
+ struct normal_stage_data *store = NORMAL_STAGE_DATA(stage);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ const GLfloat *lengths;
+
+ if (!store->NormalTransform)
+ return GL_TRUE;
+
+ /* We can only use the display list's saved normal lengths if we've
+ * got a transformation matrix with uniform scaling.
+ */
+ if (_math_matrix_is_general_scale(ctx->ModelviewMatrixStack.Top))
+ lengths = NULL;
+ else
+ lengths = VB->NormalLengthPtr;
+
+ store->NormalTransform( ctx->ModelviewMatrixStack.Top,
+ ctx->_ModelViewInvScale,
+ VB->NormalPtr, /* input normals */
+ lengths,
+ &store->normal ); /* resulting normals */
+
+ if (VB->NormalPtr->count > 1) {
+ store->normal.stride = 4 * sizeof(GLfloat);
+ }
+ else {
+ store->normal.stride = 0;
+ }
+
+ VB->NormalPtr = &store->normal;
+ VB->AttribPtr[_TNL_ATTRIB_NORMAL] = VB->NormalPtr;
+
+ VB->NormalLengthPtr = NULL; /* no longer valid */
+ return GL_TRUE;
+}
+
+
+/**
+ * Examine current GL state and set the store->NormalTransform pointer
+ * to point to the appropriate normal transformation routine.
+ */
+static void
+validate_normal_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
+{
+ struct normal_stage_data *store = NORMAL_STAGE_DATA(stage);
+
+ if (ctx->VertexProgram._Enabled ||
+ (!ctx->Light.Enabled &&
+ !(ctx->Texture._GenFlags & TEXGEN_NEED_NORMALS))) {
+ store->NormalTransform = NULL;
+ return;
+ }
+
+ if (ctx->_NeedEyeCoords) {
+ /* Eye coordinates are needed, for whatever reasons.
+ * Do lighting in eye coordinates, as the GL spec says.
+ */
+ GLuint transform = NORM_TRANSFORM_NO_ROT;
+
+ if (_math_matrix_has_rotation(ctx->ModelviewMatrixStack.Top)) {
+ /* need to do full (3x3) matrix transform */
+ transform = NORM_TRANSFORM;
+ }
+
+ if (ctx->Transform.Normalize) {
+ store->NormalTransform = _mesa_normal_tab[transform | NORM_NORMALIZE];
+ }
+ else if (ctx->Transform.RescaleNormals &&
+ ctx->_ModelViewInvScale != 1.0) {
+ store->NormalTransform = _mesa_normal_tab[transform | NORM_RESCALE];
+ }
+ else {
+ store->NormalTransform = _mesa_normal_tab[transform];
+ }
+ }
+ else {
+ /* We don't need eye coordinates.
+ * Do lighting in object coordinates. Thus, we don't need to fully
+ * transform normal vectors (just leave them in object coordinates)
+ * but we still need to do normalization/rescaling if enabled.
+ */
+ if (ctx->Transform.Normalize) {
+ store->NormalTransform = _mesa_normal_tab[NORM_NORMALIZE];
+ }
+ else if (!ctx->Transform.RescaleNormals &&
+ ctx->_ModelViewInvScale != 1.0) {
+ store->NormalTransform = _mesa_normal_tab[NORM_RESCALE];
+ }
+ else {
+ store->NormalTransform = NULL;
+ }
+ }
+}
+
+
+/**
+ * Allocate stage's private data (storage for transformed normals).
+ */
+static GLboolean
+alloc_normal_data(GLcontext *ctx, struct tnl_pipeline_stage *stage)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct normal_stage_data *store;
+
+ stage->privatePtr = _mesa_malloc(sizeof(*store));
+ store = NORMAL_STAGE_DATA(stage);
+ if (!store)
+ return GL_FALSE;
+
+ _mesa_vector4f_alloc( &store->normal, 0, tnl->vb.Size, 32 );
+ return GL_TRUE;
+}
+
+
+/**
+ * Free stage's private data.
+ */
+static void
+free_normal_data(struct tnl_pipeline_stage *stage)
+{
+ struct normal_stage_data *store = NORMAL_STAGE_DATA(stage);
+ if (store) {
+ _mesa_vector4f_free( &store->normal );
+ _mesa_free( store );
+ stage->privatePtr = NULL;
+ }
+}
+
+
+const struct tnl_pipeline_stage _tnl_normal_transform_stage =
+{
+ "normal transform", /* name */
+ NULL, /* privatePtr */
+ alloc_normal_data, /* create */
+ free_normal_data, /* destroy */
+ validate_normal_stage, /* validate */
+ run_normal_stage /* run */
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_points.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_points.c
new file mode 100644
index 000000000..47c37930d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_points.c
@@ -0,0 +1,111 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.5
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Brian Paul
+ */
+
+#include "mtypes.h"
+#include "imports.h"
+#include "t_context.h"
+#include "t_pipeline.h"
+
+
+struct point_stage_data {
+ GLvector4f PointSize;
+};
+
+#define POINT_STAGE_DATA(stage) ((struct point_stage_data *)stage->privatePtr)
+
+
+/**
+ * Compute point size for each vertex from the vertex eye-space Z
+ * coordinate and the point size attenuation factors.
+ * Only done when point size attenuation is enabled and vertex program is
+ * disabled.
+ */
+static GLboolean
+run_point_stage(GLcontext *ctx, struct tnl_pipeline_stage *stage)
+{
+ if (ctx->Point._Attenuated && !ctx->VertexProgram._Enabled) {
+ struct point_stage_data *store = POINT_STAGE_DATA(stage);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ const GLfloat (*eye)[4] = (const GLfloat (*)[4]) VB->EyePtr->data;
+ const GLfloat p0 = ctx->Point.Params[0];
+ const GLfloat p1 = ctx->Point.Params[1];
+ const GLfloat p2 = ctx->Point.Params[2];
+ const GLfloat pointSize = ctx->Point.Size;
+ GLfloat (*size)[4] = store->PointSize.data;
+ GLuint i;
+
+ for (i = 0; i < VB->Count; i++) {
+ const GLfloat dist = FABSF(eye[i][2]);
+ const GLfloat q = p0 + dist * (p1 + dist * p2);
+ const GLfloat atten = (q != 0.0) ? SQRTF(1.0 / q) : 1.0;
+ size[i][0] = pointSize * atten; /* clamping done in rasterization */
+ }
+
+ VB->PointSizePtr = &store->PointSize;
+ VB->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->PointSize;
+ }
+
+ return GL_TRUE;
+}
+
+
+static GLboolean
+alloc_point_data(GLcontext *ctx, struct tnl_pipeline_stage *stage)
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ struct point_stage_data *store;
+ stage->privatePtr = _mesa_malloc(sizeof(*store));
+ store = POINT_STAGE_DATA(stage);
+ if (!store)
+ return GL_FALSE;
+
+ _mesa_vector4f_alloc( &store->PointSize, 0, VB->Size, 32 );
+ return GL_TRUE;
+}
+
+
+static void
+free_point_data(struct tnl_pipeline_stage *stage)
+{
+ struct point_stage_data *store = POINT_STAGE_DATA(stage);
+ if (store) {
+ _mesa_vector4f_free( &store->PointSize );
+ _mesa_free( store );
+ stage->privatePtr = NULL;
+ }
+}
+
+
+const struct tnl_pipeline_stage _tnl_point_attenuation_stage =
+{
+ "point size attenuation", /* name */
+ NULL, /* stage private data */
+ alloc_point_data, /* alloc data */
+ free_point_data, /* destructor */
+ NULL,
+ run_point_stage /* run */
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_program.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_program.c
new file mode 100644
index 000000000..d77f5424c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_program.c
@@ -0,0 +1,281 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file tnl/t_vb_program.c
+ * \brief Pipeline stage for executing NVIDIA vertex programs.
+ * \author Brian Paul, Keith Whitwell
+ */
+
+
+#include "glheader.h"
+#include "api_noop.h"
+#include "colormac.h"
+#include "context.h"
+#include "dlist.h"
+#include "hash.h"
+#include "light.h"
+#include "macros.h"
+#include "imports.h"
+#include "simple_list.h"
+#include "mtypes.h"
+#include "nvvertprog.h"
+#include "nvvertexec.h"
+#include "nvprogram.h"
+
+#include "math/m_translate.h"
+
+#include "t_context.h"
+#include "t_pipeline.h"
+
+
+
+/*!
+ * Private storage for the vertex program pipeline stage.
+ */
+struct vp_stage_data {
+ /** The results of running the vertex program go into these arrays. */
+ GLvector4f attribs[15];
+
+ GLvector4f ndcCoords; /**< normalized device coords */
+ GLubyte *clipmask; /**< clip flags */
+ GLubyte ormask, andmask; /**< for clipping */
+};
+
+
+#define VP_STAGE_DATA(stage) ((struct vp_stage_data *)(stage->privatePtr))
+
+
+/**
+ * This function executes vertex programs
+ */
+static GLboolean
+run_vp( GLcontext *ctx, struct tnl_pipeline_stage *stage )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vp_stage_data *store = VP_STAGE_DATA(stage);
+ struct vertex_buffer *VB = &tnl->vb;
+ struct vertex_program *program = ctx->VertexProgram.Current;
+ GLuint i;
+
+ if (!ctx->VertexProgram._Enabled ||
+ !program->IsNVProgram)
+ return GL_TRUE;
+
+ /* load program parameter registers (they're read-only) */
+ _mesa_init_vp_per_primitive_registers(ctx);
+
+ for (i = 0; i < VB->Count; i++) {
+ GLuint attr;
+
+ _mesa_init_vp_per_vertex_registers(ctx);
+
+#if 0
+ printf("Input %d: %f, %f, %f, %f\n", i,
+ VB->AttribPtr[0]->data[i][0],
+ VB->AttribPtr[0]->data[i][1],
+ VB->AttribPtr[0]->data[i][2],
+ VB->AttribPtr[0]->data[i][3]);
+ printf(" color: %f, %f, %f, %f\n",
+ VB->AttribPtr[3]->data[i][0],
+ VB->AttribPtr[3]->data[i][1],
+ VB->AttribPtr[3]->data[i][2],
+ VB->AttribPtr[3]->data[i][3]);
+ printf(" normal: %f, %f, %f, %f\n",
+ VB->AttribPtr[2]->data[i][0],
+ VB->AttribPtr[2]->data[i][1],
+ VB->AttribPtr[2]->data[i][2],
+ VB->AttribPtr[2]->data[i][3]);
+#endif
+
+ /* the vertex array case */
+ for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
+ if (program->InputsRead & (1 << attr)) {
+ const GLubyte *ptr = (const GLubyte*) VB->AttribPtr[attr]->data;
+ const GLuint size = VB->AttribPtr[attr]->size;
+ const GLuint stride = VB->AttribPtr[attr]->stride;
+ const GLfloat *data = (GLfloat *) (ptr + stride * i);
+ COPY_CLEAN_4V(ctx->VertexProgram.Inputs[attr], size, data);
+ }
+ }
+
+ /* execute the program */
+ ASSERT(program);
+ _mesa_exec_vertex_program(ctx, program);
+
+ /* Fixup fog an point size results if needed */
+ if (ctx->Fog.Enabled &&
+ (program->OutputsWritten & (1 << VERT_RESULT_FOGC)) == 0) {
+ ctx->VertexProgram.Outputs[VERT_RESULT_FOGC][0] = 1.0;
+ }
+
+ if (ctx->VertexProgram.PointSizeEnabled &&
+ (program->OutputsWritten & (1 << VERT_RESULT_PSIZ)) == 0) {
+ ctx->VertexProgram.Outputs[VERT_RESULT_PSIZ][0] = ctx->Point.Size;
+ }
+
+ /* copy the output registers into the VB->attribs arrays */
+ /* XXX (optimize) could use a conditional and smaller loop limit here */
+ for (attr = 0; attr < 15; attr++) {
+ COPY_4V(store->attribs[attr].data[i],
+ ctx->VertexProgram.Outputs[attr]);
+ }
+ }
+
+ /* Setup the VB pointers so that the next pipeline stages get
+ * their data from the right place (the program output arrays).
+ */
+ VB->ClipPtr = &store->attribs[VERT_RESULT_HPOS];
+ VB->ClipPtr->size = 4;
+ VB->ClipPtr->count = VB->Count;
+ VB->ColorPtr[0] = &store->attribs[VERT_RESULT_COL0];
+ VB->ColorPtr[1] = &store->attribs[VERT_RESULT_BFC0];
+ VB->SecondaryColorPtr[0] = &store->attribs[VERT_RESULT_COL1];
+ VB->SecondaryColorPtr[1] = &store->attribs[VERT_RESULT_BFC1];
+ VB->FogCoordPtr = &store->attribs[VERT_RESULT_FOGC];
+ VB->PointSizePtr = &store->attribs[VERT_RESULT_PSIZ];
+
+ VB->AttribPtr[VERT_ATTRIB_COLOR0] = VB->ColorPtr[0];
+ VB->AttribPtr[VERT_ATTRIB_COLOR1] = VB->SecondaryColorPtr[0];
+ VB->AttribPtr[VERT_ATTRIB_FOG] = VB->FogCoordPtr;
+ VB->AttribPtr[_TNL_ATTRIB_POINTSIZE] = &store->attribs[VERT_RESULT_PSIZ];
+
+ for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
+ VB->AttribPtr[VERT_ATTRIB_TEX0+i] = VB->TexCoordPtr[i] =
+ &store->attribs[VERT_RESULT_TEX0 + i];
+ }
+
+
+
+ /* Cliptest and perspective divide. Clip functions must clear
+ * the clipmask.
+ */
+ store->ormask = 0;
+ store->andmask = CLIP_ALL_BITS;
+
+ if (tnl->NeedNdcCoords) {
+ VB->NdcPtr =
+ _mesa_clip_tab[VB->ClipPtr->size]( VB->ClipPtr,
+ &store->ndcCoords,
+ store->clipmask,
+ &store->ormask,
+ &store->andmask );
+ }
+ else {
+ VB->NdcPtr = NULL;
+ _mesa_clip_np_tab[VB->ClipPtr->size]( VB->ClipPtr,
+ NULL,
+ store->clipmask,
+ &store->ormask,
+ &store->andmask );
+ }
+
+ if (store->andmask) /* All vertices are outside the frustum */
+ return GL_FALSE;
+
+
+ /* This is where we'd do clip testing against the user-defined
+ * clipping planes, but they're not supported by vertex programs.
+ */
+
+ VB->ClipOrMask = store->ormask;
+ VB->ClipMask = store->clipmask;
+
+ return GL_TRUE;
+}
+
+
+
+
+/**
+ * Called the first time stage->run is called. In effect, don't
+ * allocate data until the first time the stage is run.
+ */
+static GLboolean init_vp( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &(tnl->vb);
+ struct vp_stage_data *store;
+ const GLuint size = VB->Size;
+ GLuint i;
+
+ stage->privatePtr = MALLOC(sizeof(*store));
+ store = VP_STAGE_DATA(stage);
+ if (!store)
+ return GL_FALSE;
+
+ /* Allocate arrays of vertex output values */
+ for (i = 0; i < 15; i++) {
+ _mesa_vector4f_alloc( &store->attribs[i], 0, size, 32 );
+ store->attribs[i].size = 4;
+ }
+
+ /* a few other misc allocations */
+ _mesa_vector4f_alloc( &store->ndcCoords, 0, size, 32 );
+ store->clipmask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte)*size, 32 );
+
+ return GL_TRUE;
+}
+
+
+
+
+
+/**
+ * Destructor for this pipeline stage.
+ */
+static void dtr( struct tnl_pipeline_stage *stage )
+{
+ struct vp_stage_data *store = VP_STAGE_DATA(stage);
+
+ if (store) {
+ GLuint i;
+
+ /* free the vertex program result arrays */
+ for (i = 0; i < VERT_RESULT_MAX; i++)
+ _mesa_vector4f_free( &store->attribs[i] );
+
+ /* free misc arrays */
+ _mesa_vector4f_free( &store->ndcCoords );
+ ALIGN_FREE( store->clipmask );
+
+ FREE( store );
+ stage->privatePtr = NULL;
+ }
+}
+
+/**
+ * Public description of this pipeline stage.
+ */
+const struct tnl_pipeline_stage _tnl_vertex_program_stage =
+{
+ "vertex-program",
+ NULL, /* private_data */
+ init_vp, /* create */
+ dtr, /* destroy */
+ NULL, /* validate */
+ run_vp /* run -- initially set to ctr */
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_render.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_render.c
new file mode 100644
index 000000000..8c92ac0db
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_render.c
@@ -0,0 +1,352 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+/*
+ * Render whole vertex buffers, including projection of vertices from
+ * clip space and clipping of primitives.
+ *
+ * This file makes calls to project vertices and to the point, line
+ * and triangle rasterizers via the function pointers:
+ *
+ * context->Driver.Render.*
+ *
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "enums.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+#include "nvfragprog.h"
+#include "math/m_matrix.h"
+#include "math/m_xform.h"
+
+#include "t_pipeline.h"
+
+
+
+/**********************************************************************/
+/* Clip single primitives */
+/**********************************************************************/
+
+
+#define W(i) coord[i][3]
+#define Z(i) coord[i][2]
+#define Y(i) coord[i][1]
+#define X(i) coord[i][0]
+#define SIZE 4
+#define TAG(x) x##_4
+#include "t_vb_cliptmp.h"
+
+
+
+/**********************************************************************/
+/* Clip and render whole begin/end objects */
+/**********************************************************************/
+
+#define NEED_EDGEFLAG_SETUP (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL)
+#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx]
+#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
+
+
+#define CLIPMASK (CLIP_ALL_BITS|CLIP_CULL_BIT)
+
+
+/* Vertices, with the possibility of clipping.
+ */
+#define RENDER_POINTS( start, count ) \
+ tnl->Driver.Render.Points( ctx, start, count )
+
+#define RENDER_LINE( v1, v2 ) \
+do { \
+ GLubyte c1 = mask[v1], c2 = mask[v2]; \
+ GLubyte ormask = c1|c2; \
+ if (!ormask) \
+ LineFunc( ctx, v1, v2 ); \
+ else if (!(c1 & c2 & CLIPMASK)) \
+ clip_line_4( ctx, v1, v2, ormask ); \
+} while (0)
+
+#define RENDER_TRI( v1, v2, v3 ) \
+do { \
+ GLubyte c1 = mask[v1], c2 = mask[v2], c3 = mask[v3]; \
+ GLubyte ormask = c1|c2|c3; \
+ if (!ormask) \
+ TriangleFunc( ctx, v1, v2, v3 ); \
+ else if (!(c1 & c2 & c3 & CLIPMASK)) \
+ clip_tri_4( ctx, v1, v2, v3, ormask ); \
+} while (0)
+
+#define RENDER_QUAD( v1, v2, v3, v4 ) \
+do { \
+ GLubyte c1 = mask[v1], c2 = mask[v2]; \
+ GLubyte c3 = mask[v3], c4 = mask[v4]; \
+ GLubyte ormask = c1|c2|c3|c4; \
+ if (!ormask) \
+ QuadFunc( ctx, v1, v2, v3, v4 ); \
+ else if (!(c1 & c2 & c3 & c4 & CLIPMASK)) \
+ clip_quad_4( ctx, v1, v2, v3, v4, ormask ); \
+} while (0)
+
+
+#define LOCAL_VARS \
+ TNLcontext *tnl = TNL_CONTEXT(ctx); \
+ struct vertex_buffer *VB = &tnl->vb; \
+ const GLuint * const elt = VB->Elts; \
+ const GLubyte *mask = VB->ClipMask; \
+ const GLuint sz = VB->ClipPtr->size; \
+ const tnl_line_func LineFunc = tnl->Driver.Render.Line; \
+ const tnl_triangle_func TriangleFunc = tnl->Driver.Render.Triangle; \
+ const tnl_quad_func QuadFunc = tnl->Driver.Render.Quad; \
+ const GLboolean stipple = ctx->Line.StippleFlag; \
+ (void) (LineFunc && TriangleFunc && QuadFunc); \
+ (void) elt; (void) mask; (void) sz; (void) stipple;
+
+#define TAG(x) clip_##x##_verts
+#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
+#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx )
+#define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE
+#define PRESERVE_VB_DEFS
+#include "t_vb_rendertmp.h"
+
+
+
+/* Elts, with the possibility of clipping.
+ */
+#undef ELT
+#undef TAG
+#define ELT(x) elt[x]
+#define TAG(x) clip_##x##_elts
+#include "t_vb_rendertmp.h"
+
+/* TODO: do this for all primitives, verts and elts:
+ */
+static void clip_elt_triangles( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl_render_func render_tris = tnl->Driver.Render.PrimTabElts[GL_TRIANGLES];
+ struct vertex_buffer *VB = &tnl->vb;
+ const GLuint * const elt = VB->Elts;
+ GLubyte *mask = VB->ClipMask;
+ GLuint last = count-2;
+ GLuint j;
+ (void) flags;
+
+ tnl->Driver.Render.PrimitiveNotify( ctx, GL_TRIANGLES );
+
+ for (j=start; j < last; j+=3 ) {
+ GLubyte c1 = mask[elt[j]];
+ GLubyte c2 = mask[elt[j+1]];
+ GLubyte c3 = mask[elt[j+2]];
+ GLubyte ormask = c1|c2|c3;
+ if (ormask) {
+ if (start < j)
+ render_tris( ctx, start, j, 0 );
+ if (!(c1&c2&c3&CLIPMASK))
+ clip_tri_4( ctx, elt[j], elt[j+1], elt[j+2], ormask );
+ start = j+3;
+ }
+ }
+
+ if (start < j)
+ render_tris( ctx, start, j, 0 );
+}
+
+/**********************************************************************/
+/* Render whole begin/end objects */
+/**********************************************************************/
+
+#define NEED_EDGEFLAG_SETUP (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL)
+#define EDGEFLAG_GET(idx) VB->EdgeFlag[idx]
+#define EDGEFLAG_SET(idx, val) VB->EdgeFlag[idx] = val
+
+
+/* Vertices, no clipping.
+ */
+#define RENDER_POINTS( start, count ) \
+ tnl->Driver.Render.Points( ctx, start, count )
+
+#define RENDER_LINE( v1, v2 ) \
+ LineFunc( ctx, v1, v2 )
+
+#define RENDER_TRI( v1, v2, v3 ) \
+ TriangleFunc( ctx, v1, v2, v3 )
+
+#define RENDER_QUAD( v1, v2, v3, v4 ) \
+ QuadFunc( ctx, v1, v2, v3, v4 )
+
+#define TAG(x) _tnl_##x##_verts
+
+#define LOCAL_VARS \
+ TNLcontext *tnl = TNL_CONTEXT(ctx); \
+ struct vertex_buffer *VB = &tnl->vb; \
+ const GLuint * const elt = VB->Elts; \
+ const tnl_line_func LineFunc = tnl->Driver.Render.Line; \
+ const tnl_triangle_func TriangleFunc = tnl->Driver.Render.Triangle; \
+ const tnl_quad_func QuadFunc = tnl->Driver.Render.Quad; \
+ const GLboolean stipple = ctx->Line.StippleFlag; \
+ (void) (LineFunc && TriangleFunc && QuadFunc); \
+ (void) elt; (void) stipple
+
+#define RESET_STIPPLE if (stipple) tnl->Driver.Render.ResetLineStipple( ctx )
+#define RESET_OCCLUSION ctx->OcclusionResult = GL_TRUE
+#define INIT(x) tnl->Driver.Render.PrimitiveNotify( ctx, x )
+#define RENDER_TAB_QUALIFIER
+#define PRESERVE_VB_DEFS
+#include "t_vb_rendertmp.h"
+
+
+/* Elts, no clipping.
+ */
+#undef ELT
+#define TAG(x) _tnl_##x##_elts
+#define ELT(x) elt[x]
+#include "t_vb_rendertmp.h"
+
+
+/**********************************************************************/
+/* Helper functions for drivers */
+/**********************************************************************/
+
+void _tnl_RenderClippedPolygon( GLcontext *ctx, const GLuint *elts, GLuint n )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint *tmp = VB->Elts;
+
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n, PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+}
+
+void _tnl_RenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ tnl->Driver.Render.Line( ctx, ii, jj );
+}
+
+
+
+/**********************************************************************/
+/* Clip and render whole vertex buffers */
+/**********************************************************************/
+
+
+static GLboolean run_render( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ tnl_render_func *tab;
+ GLint pass = 0;
+
+ /* Allow the drivers to lock before projected verts are built so
+ * that window coordinates are guarenteed not to change before
+ * rendering.
+ */
+ ASSERT(tnl->Driver.Render.Start);
+
+ tnl->Driver.Render.Start( ctx );
+
+ ASSERT(tnl->Driver.Render.BuildVertices);
+ ASSERT(tnl->Driver.Render.PrimitiveNotify);
+ ASSERT(tnl->Driver.Render.Points);
+ ASSERT(tnl->Driver.Render.Line);
+ ASSERT(tnl->Driver.Render.Triangle);
+ ASSERT(tnl->Driver.Render.Quad);
+ ASSERT(tnl->Driver.Render.ResetLineStipple);
+ ASSERT(tnl->Driver.Render.Interp);
+ ASSERT(tnl->Driver.Render.CopyPV);
+ ASSERT(tnl->Driver.Render.ClippedLine);
+ ASSERT(tnl->Driver.Render.ClippedPolygon);
+ ASSERT(tnl->Driver.Render.Finish);
+
+ tnl->Driver.Render.BuildVertices( ctx, 0, VB->Count, ~0 );
+
+ if (VB->ClipOrMask) {
+ tab = VB->Elts ? clip_render_tab_elts : clip_render_tab_verts;
+ clip_render_tab_elts[GL_TRIANGLES] = clip_elt_triangles;
+ }
+ else {
+ tab = (VB->Elts ?
+ tnl->Driver.Render.PrimTabElts :
+ tnl->Driver.Render.PrimTabVerts);
+ }
+
+ do
+ {
+ GLuint i;
+
+ for (i = 0 ; i < VB->PrimitiveCount ; i++)
+ {
+ GLuint prim = VB->Primitive[i].mode;
+ GLuint start = VB->Primitive[i].start;
+ GLuint length = VB->Primitive[i].count;
+
+ assert((prim & PRIM_MODE_MASK) < GL_POLYGON+1);
+
+ if (MESA_VERBOSE & VERBOSE_PRIMS)
+ _mesa_debug(NULL, "MESA prim %s %d..%d\n",
+ _mesa_lookup_enum_by_nr(prim & PRIM_MODE_MASK),
+ start, start+length);
+
+ if (length)
+ tab[prim & PRIM_MODE_MASK]( ctx, start, start + length, prim );
+ }
+ } while (tnl->Driver.Render.Multipass &&
+ tnl->Driver.Render.Multipass( ctx, ++pass ));
+
+ tnl->Driver.Render.Finish( ctx );
+
+ return GL_FALSE; /* finished the pipe */
+}
+
+
+/**********************************************************************/
+/* Render pipeline stage */
+/**********************************************************************/
+
+
+
+
+
+const struct tnl_pipeline_stage _tnl_render_stage =
+{
+ "render", /* name */
+ NULL, /* private data */
+ NULL, /* creator */
+ NULL, /* destructor */
+ NULL, /* validate */
+ run_render /* run */
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_rendertmp.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_rendertmp.h
new file mode 100644
index 000000000..3db94bc09
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_rendertmp.h
@@ -0,0 +1,440 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+#ifndef POSTFIX
+#define POSTFIX
+#endif
+
+#ifndef INIT
+#define INIT(x)
+#endif
+
+#ifndef NEED_EDGEFLAG_SETUP
+#define NEED_EDGEFLAG_SETUP 0
+#define EDGEFLAG_GET(a) 0
+#define EDGEFLAG_SET(a,b) (void)b
+#endif
+
+#ifndef RESET_STIPPLE
+#define RESET_STIPPLE
+#endif
+
+#ifndef RESET_OCCLUSION
+#define RESET_OCCLUSION
+#endif
+
+#ifndef TEST_PRIM_END
+#define TEST_PRIM_END(flags) (flags & PRIM_END)
+#define TEST_PRIM_BEGIN(flags) (flags & PRIM_BEGIN)
+#endif
+
+#ifndef ELT
+#define ELT(x) x
+#endif
+
+#ifndef RENDER_TAB_QUALIFIER
+#define RENDER_TAB_QUALIFIER static
+#endif
+
+static void TAG(render_points)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ (void) flags;
+
+ RESET_OCCLUSION;
+ INIT(GL_POINTS);
+ RENDER_POINTS( start, count );
+ POSTFIX;
+}
+
+static void TAG(render_lines)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ RESET_OCCLUSION;
+ INIT(GL_LINES);
+ for (j=start+1; j<count; j+=2 ) {
+ RESET_STIPPLE;
+ RENDER_LINE( ELT(j-1), ELT(j) );
+ }
+ POSTFIX;
+}
+
+
+static void TAG(render_line_strip)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ RESET_OCCLUSION;
+ INIT(GL_LINE_STRIP);
+
+ if (TEST_PRIM_BEGIN(flags)) {
+ RESET_STIPPLE;
+ }
+
+ for (j=start+1; j<count; j++ )
+ RENDER_LINE( ELT(j-1), ELT(j) );
+
+ POSTFIX;
+}
+
+
+static void TAG(render_line_loop)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint i;
+ LOCAL_VARS;
+
+ (void) flags;
+
+ RESET_OCCLUSION;
+ INIT(GL_LINE_LOOP);
+
+ if (start+1 < count) {
+ if (TEST_PRIM_BEGIN(flags)) {
+ RESET_STIPPLE;
+ RENDER_LINE( ELT(start), ELT(start+1) );
+ }
+
+ for ( i = start+2 ; i < count ; i++) {
+ RENDER_LINE( ELT(i-1), ELT(i) );
+ }
+
+ if ( TEST_PRIM_END(flags)) {
+ RENDER_LINE( ELT(count-1), ELT(start) );
+ }
+ }
+
+ POSTFIX;
+}
+
+
+static void TAG(render_triangles)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ INIT(GL_TRIANGLES);
+ if (NEED_EDGEFLAG_SETUP) {
+ for (j=start+2; j<count; j+=3) {
+ /* Leave the edgeflags as supplied by the user.
+ */
+ RESET_STIPPLE;
+ RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) );
+ }
+ } else {
+ for (j=start+2; j<count; j+=3) {
+ RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) );
+ }
+ }
+ POSTFIX;
+}
+
+
+
+static void TAG(render_tri_strip)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ GLuint parity = 0;
+ LOCAL_VARS;
+
+ INIT(GL_TRIANGLE_STRIP);
+ if (NEED_EDGEFLAG_SETUP) {
+ for (j=start+2;j<count;j++,parity^=1) {
+ GLuint ej2 = ELT(j-2+parity);
+ GLuint ej1 = ELT(j-1-parity);
+ GLuint ej = ELT(j);
+ GLboolean ef2 = EDGEFLAG_GET( ej2 );
+ GLboolean ef1 = EDGEFLAG_GET( ej1 );
+ GLboolean ef = EDGEFLAG_GET( ej );
+ if (TEST_PRIM_BEGIN(flags)) {
+ RESET_STIPPLE;
+ }
+ EDGEFLAG_SET( ej2, GL_TRUE );
+ EDGEFLAG_SET( ej1, GL_TRUE );
+ EDGEFLAG_SET( ej, GL_TRUE );
+ RENDER_TRI( ej2, ej1, ej );
+ EDGEFLAG_SET( ej2, ef2 );
+ EDGEFLAG_SET( ej1, ef1 );
+ EDGEFLAG_SET( ej, ef );
+ }
+ } else {
+ for (j=start+2; j<count ; j++, parity^=1) {
+ RENDER_TRI( ELT(j-2+parity), ELT(j-1-parity), ELT(j) );
+ }
+ }
+ POSTFIX;
+}
+
+
+static void TAG(render_tri_fan)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ INIT(GL_TRIANGLE_FAN);
+ if (NEED_EDGEFLAG_SETUP) {
+ for (j=start+2;j<count;j++) {
+ /* For trifans, all edges are boundary.
+ */
+ GLuint ejs = ELT(start);
+ GLuint ej1 = ELT(j-1);
+ GLuint ej = ELT(j);
+ GLboolean efs = EDGEFLAG_GET( ejs );
+ GLboolean ef1 = EDGEFLAG_GET( ej1 );
+ GLboolean ef = EDGEFLAG_GET( ej );
+ if (TEST_PRIM_BEGIN(flags)) {
+ RESET_STIPPLE;
+ }
+ EDGEFLAG_SET( ejs, GL_TRUE );
+ EDGEFLAG_SET( ej1, GL_TRUE );
+ EDGEFLAG_SET( ej, GL_TRUE );
+ RENDER_TRI( ejs, ej1, ej);
+ EDGEFLAG_SET( ejs, efs );
+ EDGEFLAG_SET( ej1, ef1 );
+ EDGEFLAG_SET( ej, ef );
+ }
+ } else {
+ for (j=start+2;j<count;j++) {
+ RENDER_TRI( ELT(start), ELT(j-1), ELT(j) );
+ }
+ }
+
+ POSTFIX;
+}
+
+
+static void TAG(render_poly)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j = start+2;
+ LOCAL_VARS;
+ (void) flags;
+
+ INIT(GL_POLYGON);
+ if (NEED_EDGEFLAG_SETUP) {
+ GLboolean efstart = EDGEFLAG_GET( ELT(start) );
+ GLboolean efcount = EDGEFLAG_GET( ELT(count-1) );
+
+ /* If the primitive does not begin here, the first edge
+ * is non-boundary.
+ */
+ if (!TEST_PRIM_BEGIN(flags))
+ EDGEFLAG_SET( ELT(start), GL_FALSE );
+ else {
+ RESET_STIPPLE;
+ }
+
+ /* If the primitive does not end here, the final edge is
+ * non-boundary.
+ */
+ if (!TEST_PRIM_END(flags))
+ EDGEFLAG_SET( ELT(count-1), GL_FALSE );
+
+ /* Draw the first triangles (possibly zero)
+ */
+ if (j+1<count) {
+ GLboolean ef = EDGEFLAG_GET( ELT(j) );
+ EDGEFLAG_SET( ELT(j), GL_FALSE );
+ RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
+ EDGEFLAG_SET( ELT(j), ef );
+ j++;
+
+ /* Don't render the first edge again:
+ */
+ EDGEFLAG_SET( ELT(start), GL_FALSE );
+
+ for (;j+1<count;j++) {
+ GLboolean efj = EDGEFLAG_GET( ELT(j) );
+ EDGEFLAG_SET( ELT(j), GL_FALSE );
+ RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
+ EDGEFLAG_SET( ELT(j), efj );
+ }
+ }
+
+ /* Draw the last or only triangle
+ */
+ if (j < count)
+ RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
+
+ /* Restore the first and last edgeflags:
+ */
+ EDGEFLAG_SET( ELT(count-1), efcount );
+ EDGEFLAG_SET( ELT(start), efstart );
+
+ }
+ else {
+ for (j=start+2;j<count;j++) {
+ RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
+ }
+ }
+ POSTFIX;
+}
+
+static void TAG(render_quads)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ INIT(GL_QUADS);
+ if (NEED_EDGEFLAG_SETUP) {
+ for (j=start+3; j<count; j+=4) {
+ /* Use user-specified edgeflags for quads.
+ */
+ RESET_STIPPLE;
+ RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) );
+ }
+ } else {
+ for (j=start+3; j<count; j+=4) {
+ RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) );
+ }
+ }
+ POSTFIX;
+}
+
+static void TAG(render_quad_strip)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ INIT(GL_QUAD_STRIP);
+ if (NEED_EDGEFLAG_SETUP) {
+ for (j=start+3;j<count;j+=2) {
+ /* All edges are boundary. Set edgeflags to 1, draw the
+ * quad, and restore them to the original values.
+ */
+ GLboolean ef3 = EDGEFLAG_GET( ELT(j-3) );
+ GLboolean ef2 = EDGEFLAG_GET( ELT(j-2) );
+ GLboolean ef1 = EDGEFLAG_GET( ELT(j-1) );
+ GLboolean ef = EDGEFLAG_GET( ELT(j) );
+ if (TEST_PRIM_BEGIN(flags)) {
+ RESET_STIPPLE;
+ }
+ EDGEFLAG_SET( ELT(j-3), GL_TRUE );
+ EDGEFLAG_SET( ELT(j-2), GL_TRUE );
+ EDGEFLAG_SET( ELT(j-1), GL_TRUE );
+ EDGEFLAG_SET( ELT(j), GL_TRUE );
+ RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) );
+ EDGEFLAG_SET( ELT(j-3), ef3 );
+ EDGEFLAG_SET( ELT(j-2), ef2 );
+ EDGEFLAG_SET( ELT(j-1), ef1 );
+ EDGEFLAG_SET( ELT(j), ef );
+ }
+ } else {
+ for (j=start+3;j<count;j+=2) {
+ RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) );
+ }
+ }
+ POSTFIX;
+}
+
+static void TAG(render_noop)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ (void)(ctx && start && count && flags);
+}
+
+RENDER_TAB_QUALIFIER void (*TAG(render_tab)[GL_POLYGON+2])(GLcontext *,
+ GLuint,
+ GLuint,
+ GLuint) =
+{
+ TAG(render_points),
+ TAG(render_lines),
+ TAG(render_line_loop),
+ TAG(render_line_strip),
+ TAG(render_triangles),
+ TAG(render_tri_strip),
+ TAG(render_tri_fan),
+ TAG(render_quads),
+ TAG(render_quad_strip),
+ TAG(render_poly),
+ TAG(render_noop),
+};
+
+
+
+#ifndef PRESERVE_VB_DEFS
+#undef RENDER_TRI
+#undef RENDER_QUAD
+#undef RENDER_LINE
+#undef RENDER_POINTS
+#undef LOCAL_VARS
+#undef INIT
+#undef POSTFIX
+#undef RESET_STIPPLE
+#undef DBG
+#undef ELT
+#undef RENDER_TAB_QUALIFIER
+#endif
+
+#ifndef PRESERVE_TAG
+#undef TAG
+#endif
+
+#undef PRESERVE_VB_DEFS
+#undef PRESERVE_TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_texgen.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_texgen.c
new file mode 100644
index 000000000..1af8e2ba4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_texgen.c
@@ -0,0 +1,611 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ *
+ * Authors:
+ * Brian Paul
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+/*
+ * Regarding GL_NV_texgen_reflection:
+ *
+ * Portions of this software may use or implement intellectual
+ * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims
+ * any and all warranties with respect to such intellectual property,
+ * including any use thereof or modifications thereto.
+ */
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+
+#include "math/m_xform.h"
+
+#include "t_context.h"
+#include "t_pipeline.h"
+
+
+/***********************************************************************
+ * Automatic texture coordinate generation (texgen) code.
+ */
+
+
+struct texgen_stage_data;
+
+typedef void (*texgen_func)( GLcontext *ctx,
+ struct texgen_stage_data *store,
+ GLuint unit);
+
+
+struct texgen_stage_data {
+
+ /* Per-texunit derived state.
+ */
+ GLuint TexgenSize[MAX_TEXTURE_COORD_UNITS];
+ texgen_func TexgenFunc[MAX_TEXTURE_COORD_UNITS];
+
+ /* Temporary values used in texgen.
+ */
+ GLfloat (*tmp_f)[3];
+ GLfloat *tmp_m;
+
+ /* Buffered outputs of the stage.
+ */
+ GLvector4f texcoord[MAX_TEXTURE_COORD_UNITS];
+};
+
+
+#define TEXGEN_STAGE_DATA(stage) ((struct texgen_stage_data *)stage->privatePtr)
+
+
+
+static GLuint all_bits[5] = {
+ 0,
+ VEC_SIZE_1,
+ VEC_SIZE_2,
+ VEC_SIZE_3,
+ VEC_SIZE_4,
+};
+
+#define VEC_SIZE_FLAGS (VEC_SIZE_1|VEC_SIZE_2|VEC_SIZE_3|VEC_SIZE_4)
+
+#define TEXGEN_NEED_M (TEXGEN_SPHERE_MAP)
+#define TEXGEN_NEED_F (TEXGEN_SPHERE_MAP | \
+ TEXGEN_REFLECTION_MAP_NV)
+
+
+
+static void build_m3( GLfloat f[][3], GLfloat m[],
+ const GLvector4f *normal,
+ const GLvector4f *eye )
+{
+ GLuint stride = eye->stride;
+ GLfloat *coord = (GLfloat *)eye->start;
+ GLuint count = eye->count;
+ const GLfloat *norm = normal->start;
+ GLuint i;
+
+ for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(norm,normal->stride)) {
+ GLfloat u[3], two_nu, fx, fy, fz;
+ COPY_3V( u, coord );
+ NORMALIZE_3FV( u );
+ two_nu = 2.0F * DOT3(norm,u);
+ fx = f[i][0] = u[0] - norm[0] * two_nu;
+ fy = f[i][1] = u[1] - norm[1] * two_nu;
+ fz = f[i][2] = u[2] - norm[2] * two_nu;
+ m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F);
+ if (m[i] != 0.0F) {
+ m[i] = 0.5F * _mesa_inv_sqrtf(m[i]);
+ }
+ }
+}
+
+
+
+static void build_m2( GLfloat f[][3], GLfloat m[],
+ const GLvector4f *normal,
+ const GLvector4f *eye )
+{
+ GLuint stride = eye->stride;
+ GLfloat *coord = eye->start;
+ GLuint count = eye->count;
+
+ GLfloat *norm = normal->start;
+ GLuint i;
+
+ for (i=0;i<count;i++,STRIDE_F(coord,stride),STRIDE_F(norm,normal->stride)) {
+ GLfloat u[3], two_nu, fx, fy, fz;
+ COPY_2V( u, coord );
+ u[2] = 0;
+ NORMALIZE_3FV( u );
+ two_nu = 2.0F * DOT3(norm,u);
+ fx = f[i][0] = u[0] - norm[0] * two_nu;
+ fy = f[i][1] = u[1] - norm[1] * two_nu;
+ fz = f[i][2] = u[2] - norm[2] * two_nu;
+ m[i] = fx * fx + fy * fy + (fz + 1.0F) * (fz + 1.0F);
+ if (m[i] != 0.0F) {
+ m[i] = 0.5F * _mesa_inv_sqrtf(m[i]);
+ }
+ }
+}
+
+
+
+typedef void (*build_m_func)( GLfloat f[][3],
+ GLfloat m[],
+ const GLvector4f *normal,
+ const GLvector4f *eye );
+
+
+static build_m_func build_m_tab[5] = {
+ NULL,
+ NULL,
+ build_m2,
+ build_m3,
+ build_m3
+};
+
+
+/* This is unusual in that we respect the stride of the output vector
+ * (f). This allows us to pass in either a texcoord vector4f, or a
+ * temporary vector3f.
+ */
+static void build_f3( GLfloat *f,
+ GLuint fstride,
+ const GLvector4f *normal,
+ const GLvector4f *eye )
+{
+ GLuint stride = eye->stride;
+ GLfloat *coord = eye->start;
+ GLuint count = eye->count;
+
+ GLfloat *norm = normal->start;
+ GLuint i;
+
+ for (i=0;i<count;i++) {
+ GLfloat u[3], two_nu;
+ COPY_3V( u, coord );
+ NORMALIZE_3FV( u );
+ two_nu = 2.0F * DOT3(norm,u);
+ f[0] = u[0] - norm[0] * two_nu;
+ f[1] = u[1] - norm[1] * two_nu;
+ f[2] = u[2] - norm[2] * two_nu;
+ STRIDE_F(coord,stride);
+ STRIDE_F(f,fstride);
+ STRIDE_F(norm, normal->stride);
+ }
+}
+
+
+static void build_f2( GLfloat *f,
+ GLuint fstride,
+ const GLvector4f *normal,
+ const GLvector4f *eye )
+{
+ GLuint stride = eye->stride;
+ GLfloat *coord = eye->start;
+ GLuint count = eye->count;
+ GLfloat *norm = normal->start;
+ GLuint i;
+
+ for (i=0;i<count;i++) {
+
+ GLfloat u[3], two_nu;
+ COPY_2V( u, coord );
+ u[2] = 0;
+ NORMALIZE_3FV( u );
+ two_nu = 2.0F * DOT3(norm,u);
+ f[0] = u[0] - norm[0] * two_nu;
+ f[1] = u[1] - norm[1] * two_nu;
+ f[2] = u[2] - norm[2] * two_nu;
+
+ STRIDE_F(coord,stride);
+ STRIDE_F(f,fstride);
+ STRIDE_F(norm, normal->stride);
+ }
+}
+
+typedef void (*build_f_func)( GLfloat *f,
+ GLuint fstride,
+ const GLvector4f *normal_vec,
+ const GLvector4f *eye );
+
+
+
+/* Just treat 4-vectors as 3-vectors.
+ */
+static build_f_func build_f_tab[5] = {
+ NULL,
+ NULL,
+ build_f2,
+ build_f3,
+ build_f3
+};
+
+
+
+/* Special case texgen functions.
+ */
+static void texgen_reflection_map_nv( GLcontext *ctx,
+ struct texgen_stage_data *store,
+ GLuint unit )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLvector4f *in = VB->TexCoordPtr[unit];
+ GLvector4f *out = &store->texcoord[unit];
+
+ build_f_tab[VB->EyePtr->size]( out->start,
+ out->stride,
+ VB->NormalPtr,
+ VB->EyePtr );
+
+ out->flags |= (in->flags & VEC_SIZE_FLAGS) | VEC_SIZE_3;
+ out->count = VB->Count;
+ out->size = MAX2(in->size, 3);
+ if (in->size == 4)
+ _mesa_copy_tab[0x8]( out, in );
+}
+
+
+
+static void texgen_normal_map_nv( GLcontext *ctx,
+ struct texgen_stage_data *store,
+ GLuint unit )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLvector4f *in = VB->TexCoordPtr[unit];
+ GLvector4f *out = &store->texcoord[unit];
+ GLvector4f *normal = VB->NormalPtr;
+ GLfloat (*texcoord)[4] = (GLfloat (*)[4])out->start;
+ GLuint count = VB->Count;
+ GLuint i;
+ const GLfloat *norm = normal->start;
+
+ for (i=0;i<count;i++, STRIDE_F(norm, normal->stride)) {
+ texcoord[i][0] = norm[0];
+ texcoord[i][1] = norm[1];
+ texcoord[i][2] = norm[2];
+ }
+
+
+ out->flags |= (in->flags & VEC_SIZE_FLAGS) | VEC_SIZE_3;
+ out->count = count;
+ out->size = MAX2(in->size, 3);
+ if (in->size == 4)
+ _mesa_copy_tab[0x8]( out, in );
+}
+
+
+static void texgen_sphere_map( GLcontext *ctx,
+ struct texgen_stage_data *store,
+ GLuint unit )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLvector4f *in = VB->TexCoordPtr[unit];
+ GLvector4f *out = &store->texcoord[unit];
+ GLfloat (*texcoord)[4] = (GLfloat (*)[4]) out->start;
+ GLuint count = VB->Count;
+ GLuint i;
+ GLfloat (*f)[3] = store->tmp_f;
+ GLfloat *m = store->tmp_m;
+
+ (build_m_tab[VB->EyePtr->size])( store->tmp_f,
+ store->tmp_m,
+ VB->NormalPtr,
+ VB->EyePtr );
+
+ out->size = MAX2(in->size,2);
+
+ for (i=0;i<count;i++) {
+ texcoord[i][0] = f[i][0] * m[i] + 0.5F;
+ texcoord[i][1] = f[i][1] * m[i] + 0.5F;
+ }
+
+ out->count = count;
+ out->flags |= (in->flags & VEC_SIZE_FLAGS) | VEC_SIZE_2;
+ if (in->size > 2)
+ _mesa_copy_tab[all_bits[in->size] & ~0x3]( out, in );
+}
+
+
+
+static void texgen( GLcontext *ctx,
+ struct texgen_stage_data *store,
+ GLuint unit )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLvector4f *in = VB->TexCoordPtr[unit];
+ GLvector4f *out = &store->texcoord[unit];
+ const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ const GLvector4f *obj = VB->ObjPtr;
+ const GLvector4f *eye = VB->EyePtr;
+ const GLvector4f *normal = VB->NormalPtr;
+ const GLfloat *m = store->tmp_m;
+ const GLuint count = VB->Count;
+ GLfloat (*texcoord)[4] = (GLfloat (*)[4])out->data;
+ GLfloat (*f)[3] = store->tmp_f;
+ GLuint copy;
+
+ if (texUnit->_GenFlags & TEXGEN_NEED_M) {
+ build_m_tab[eye->size]( store->tmp_f, store->tmp_m, normal, eye );
+ } else if (texUnit->_GenFlags & TEXGEN_NEED_F) {
+ build_f_tab[eye->size]( (GLfloat *)store->tmp_f, 3, normal, eye );
+ }
+
+
+ out->size = MAX2(in->size, store->TexgenSize[unit]);
+ out->flags |= (in->flags & VEC_SIZE_FLAGS) | texUnit->TexGenEnabled;
+ out->count = count;
+
+ copy = (all_bits[in->size] & ~texUnit->TexGenEnabled);
+ if (copy)
+ _mesa_copy_tab[copy]( out, in );
+
+ if (texUnit->TexGenEnabled & S_BIT) {
+ GLuint i;
+ switch (texUnit->GenModeS) {
+ case GL_OBJECT_LINEAR:
+ _mesa_dotprod_tab[obj->size]( (GLfloat *)out->data,
+ sizeof(out->data[0]), obj,
+ texUnit->ObjectPlaneS );
+ break;
+ case GL_EYE_LINEAR:
+ _mesa_dotprod_tab[eye->size]( (GLfloat *)out->data,
+ sizeof(out->data[0]), eye,
+ texUnit->EyePlaneS );
+ break;
+ case GL_SPHERE_MAP:
+ for (i = 0; i < count; i++)
+ texcoord[i][0] = f[i][0] * m[i] + 0.5F;
+ break;
+ case GL_REFLECTION_MAP_NV:
+ for (i=0;i<count;i++)
+ texcoord[i][0] = f[i][0];
+ break;
+ case GL_NORMAL_MAP_NV: {
+ const GLfloat *norm = normal->start;
+ for (i=0;i<count;i++, STRIDE_F(norm, normal->stride)) {
+ texcoord[i][0] = norm[0];
+ }
+ break;
+ }
+ default:
+ _mesa_problem(ctx, "Bad S texgen");
+ }
+ }
+
+ if (texUnit->TexGenEnabled & T_BIT) {
+ GLuint i;
+ switch (texUnit->GenModeT) {
+ case GL_OBJECT_LINEAR:
+ _mesa_dotprod_tab[obj->size]( &(out->data[0][1]),
+ sizeof(out->data[0]), obj,
+ texUnit->ObjectPlaneT );
+ break;
+ case GL_EYE_LINEAR:
+ _mesa_dotprod_tab[eye->size]( &(out->data[0][1]),
+ sizeof(out->data[0]), eye,
+ texUnit->EyePlaneT );
+ break;
+ case GL_SPHERE_MAP:
+ for (i = 0; i < count; i++)
+ texcoord[i][1] = f[i][1] * m[i] + 0.5F;
+ break;
+ case GL_REFLECTION_MAP_NV:
+ for (i=0;i<count;i++)
+ texcoord[i][1] = f[i][1];
+ break;
+ case GL_NORMAL_MAP_NV: {
+ const GLfloat *norm = normal->start;
+ for (i=0;i<count;i++, STRIDE_F(norm, normal->stride)) {
+ texcoord[i][1] = norm[1];
+ }
+ break;
+ }
+ default:
+ _mesa_problem(ctx, "Bad T texgen");
+ }
+ }
+
+ if (texUnit->TexGenEnabled & R_BIT) {
+ GLuint i;
+ switch (texUnit->GenModeR) {
+ case GL_OBJECT_LINEAR:
+ _mesa_dotprod_tab[obj->size]( &(out->data[0][2]),
+ sizeof(out->data[0]), obj,
+ texUnit->ObjectPlaneR );
+ break;
+ case GL_EYE_LINEAR:
+ _mesa_dotprod_tab[eye->size]( &(out->data[0][2]),
+ sizeof(out->data[0]), eye,
+ texUnit->EyePlaneR );
+ break;
+ case GL_REFLECTION_MAP_NV:
+ for (i=0;i<count;i++)
+ texcoord[i][2] = f[i][2];
+ break;
+ case GL_NORMAL_MAP_NV: {
+ const GLfloat *norm = normal->start;
+ for (i=0;i<count;i++,STRIDE_F(norm, normal->stride)) {
+ texcoord[i][2] = norm[2];
+ }
+ break;
+ }
+ default:
+ _mesa_problem(ctx, "Bad R texgen");
+ }
+ }
+
+ if (texUnit->TexGenEnabled & Q_BIT) {
+ switch (texUnit->GenModeQ) {
+ case GL_OBJECT_LINEAR:
+ _mesa_dotprod_tab[obj->size]( &(out->data[0][3]),
+ sizeof(out->data[0]), obj,
+ texUnit->ObjectPlaneQ );
+ break;
+ case GL_EYE_LINEAR:
+ _mesa_dotprod_tab[eye->size]( &(out->data[0][3]),
+ sizeof(out->data[0]), eye,
+ texUnit->EyePlaneQ );
+ break;
+ default:
+ _mesa_problem(ctx, "Bad Q texgen");
+ }
+ }
+}
+
+
+
+
+static GLboolean run_texgen_stage( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
+ GLuint i;
+
+ if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Enabled)
+ return GL_TRUE;
+
+ for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
+
+ if (texUnit->TexGenEnabled) {
+
+ store->TexgenFunc[i]( ctx, store, i );
+
+ VB->AttribPtr[VERT_ATTRIB_TEX0+i] =
+ VB->TexCoordPtr[i] = &store->texcoord[i];
+ }
+ }
+
+ return GL_TRUE;
+}
+
+
+static void validate_texgen_stage( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
+ GLuint i;
+
+ if (!ctx->Texture._TexGenEnabled || ctx->VertexProgram._Enabled)
+ return;
+
+ for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
+
+ if (texUnit->TexGenEnabled) {
+ GLuint sz;
+
+ if (texUnit->TexGenEnabled & Q_BIT)
+ sz = 4;
+ else if (texUnit->TexGenEnabled & R_BIT)
+ sz = 3;
+ else if (texUnit->TexGenEnabled & T_BIT)
+ sz = 2;
+ else
+ sz = 1;
+
+ store->TexgenSize[i] = sz;
+ store->TexgenFunc[i] = texgen; /* general solution */
+
+ /* look for special texgen cases */
+ if (texUnit->TexGenEnabled == (S_BIT|T_BIT|R_BIT)) {
+ if (texUnit->_GenFlags == TEXGEN_REFLECTION_MAP_NV) {
+ store->TexgenFunc[i] = texgen_reflection_map_nv;
+ }
+ else if (texUnit->_GenFlags == TEXGEN_NORMAL_MAP_NV) {
+ store->TexgenFunc[i] = texgen_normal_map_nv;
+ }
+ }
+ else if (texUnit->TexGenEnabled == (S_BIT|T_BIT) &&
+ texUnit->_GenFlags == TEXGEN_SPHERE_MAP) {
+ store->TexgenFunc[i] = texgen_sphere_map;
+ }
+ }
+ }
+}
+
+
+
+
+
+/* Called the first time stage->run() is invoked.
+ */
+static GLboolean alloc_texgen_data( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ struct texgen_stage_data *store;
+ GLuint i;
+
+ stage->privatePtr = CALLOC(sizeof(*store));
+ store = TEXGEN_STAGE_DATA(stage);
+ if (!store)
+ return GL_FALSE;
+
+ for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++)
+ _mesa_vector4f_alloc( &store->texcoord[i], 0, VB->Size, 32 );
+
+ store->tmp_f = (GLfloat (*)[3]) MALLOC(VB->Size * sizeof(GLfloat) * 3);
+ store->tmp_m = (GLfloat *) MALLOC(VB->Size * sizeof(GLfloat));
+
+ return GL_TRUE;
+}
+
+
+static void free_texgen_data( struct tnl_pipeline_stage *stage )
+
+{
+ struct texgen_stage_data *store = TEXGEN_STAGE_DATA(stage);
+ GLuint i;
+
+ if (store) {
+ for (i = 0 ; i < MAX_TEXTURE_COORD_UNITS ; i++)
+ if (store->texcoord[i].data)
+ _mesa_vector4f_free( &store->texcoord[i] );
+
+
+ if (store->tmp_f) FREE( store->tmp_f );
+ if (store->tmp_m) FREE( store->tmp_m );
+ FREE( store );
+ stage->privatePtr = NULL;
+ }
+}
+
+
+
+const struct tnl_pipeline_stage _tnl_texgen_stage =
+{
+ "texgen", /* name */
+ NULL, /* private data */
+ alloc_texgen_data, /* destructor */
+ free_texgen_data, /* destructor */
+ validate_texgen_stage, /* check */
+ run_texgen_stage /* run -- initially set to alloc data */
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_texmat.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_texmat.c
new file mode 100644
index 000000000..234753038
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_texmat.c
@@ -0,0 +1,130 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+
+#include "math/m_xform.h"
+
+#include "t_context.h"
+#include "t_pipeline.h"
+
+/* Is there any real benefit seperating texmat from texgen? It means
+ * we need two lots of intermediate storage. Any changes to
+ * _NEW_TEXTURE will invalidate both sets -- it's only on changes to
+ * *only* _NEW_TEXTURE_MATRIX that texgen survives but texmat doesn't.
+ *
+ * However, the seperation of this code from the complex texgen stuff
+ * is very appealing.
+ */
+struct texmat_stage_data {
+ GLvector4f texcoord[MAX_TEXTURE_COORD_UNITS];
+};
+
+#define TEXMAT_STAGE_DATA(stage) ((struct texmat_stage_data *)stage->privatePtr)
+
+
+
+static GLboolean run_texmat_stage( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ struct texmat_stage_data *store = TEXMAT_STAGE_DATA(stage);
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLuint i;
+
+ if (!ctx->Texture._TexMatEnabled || ctx->VertexProgram._Enabled)
+ return GL_TRUE;
+
+ /* ENABLE_TEXMAT implies that the texture matrix is not the
+ * identity, so we don't have to check that here.
+ */
+ for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++) {
+ if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i)) {
+ (void) TransformRaw( &store->texcoord[i],
+ ctx->TextureMatrixStack[i].Top,
+ VB->TexCoordPtr[i]);
+
+ VB->AttribPtr[VERT_ATTRIB_TEX0+i] =
+ VB->TexCoordPtr[i] = &store->texcoord[i];
+ }
+ }
+
+ return GL_TRUE;
+}
+
+
+/* Called the first time stage->run() is invoked.
+ */
+static GLboolean alloc_texmat_data( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ struct texmat_stage_data *store;
+ GLuint i;
+
+ stage->privatePtr = CALLOC(sizeof(*store));
+ store = TEXMAT_STAGE_DATA(stage);
+ if (!store)
+ return GL_FALSE;
+
+ for (i = 0 ; i < ctx->Const.MaxTextureCoordUnits ; i++)
+ _mesa_vector4f_alloc( &store->texcoord[i], 0, VB->Size, 32 );
+
+ return GL_TRUE;
+}
+
+
+static void free_texmat_data( struct tnl_pipeline_stage *stage )
+{
+ struct texmat_stage_data *store = TEXMAT_STAGE_DATA(stage);
+ GLuint i;
+
+ if (store) {
+ for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++)
+ if (store->texcoord[i].data)
+ _mesa_vector4f_free( &store->texcoord[i] );
+ FREE( store );
+ stage->privatePtr = NULL;
+ }
+}
+
+
+
+const struct tnl_pipeline_stage _tnl_texture_transform_stage =
+{
+ "texture transform", /* name */
+ NULL, /* private data */
+ alloc_texmat_data,
+ free_texmat_data, /* destructor */
+ NULL,
+ run_texmat_stage,
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_vertex.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_vertex.c
new file mode 100644
index 000000000..b3defaad0
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vb_vertex.c
@@ -0,0 +1,264 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+#include "glheader.h"
+#include "colormac.h"
+#include "context.h"
+#include "macros.h"
+#include "imports.h"
+#include "mtypes.h"
+
+#include "math/m_xform.h"
+
+#include "t_context.h"
+#include "t_pipeline.h"
+
+
+
+struct vertex_stage_data {
+ GLvector4f eye;
+ GLvector4f clip;
+ GLvector4f proj;
+ GLubyte *clipmask;
+ GLubyte ormask;
+ GLubyte andmask;
+};
+
+#define VERTEX_STAGE_DATA(stage) ((struct vertex_stage_data *)stage->privatePtr)
+
+
+
+
+/* This function implements cliptesting for user-defined clip planes.
+ * The clipping of primitives to these planes is implemented in
+ * t_render_clip.h.
+ */
+#define USER_CLIPTEST(NAME, SZ) \
+static void NAME( GLcontext *ctx, \
+ GLvector4f *clip, \
+ GLubyte *clipmask, \
+ GLubyte *clipormask, \
+ GLubyte *clipandmask ) \
+{ \
+ GLuint p; \
+ \
+ for (p = 0; p < ctx->Const.MaxClipPlanes; p++) \
+ if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { \
+ GLuint nr, i; \
+ const GLfloat a = ctx->Transform._ClipUserPlane[p][0]; \
+ const GLfloat b = ctx->Transform._ClipUserPlane[p][1]; \
+ const GLfloat c = ctx->Transform._ClipUserPlane[p][2]; \
+ const GLfloat d = ctx->Transform._ClipUserPlane[p][3]; \
+ GLfloat *coord = (GLfloat *)clip->data; \
+ GLuint stride = clip->stride; \
+ GLuint count = clip->count; \
+ \
+ for (nr = 0, i = 0 ; i < count ; i++) { \
+ GLfloat dp = coord[0] * a + coord[1] * b; \
+ if (SZ > 2) dp += coord[2] * c; \
+ if (SZ > 3) dp += coord[3] * d; else dp += d; \
+ \
+ if (dp < 0) { \
+ nr++; \
+ clipmask[i] |= CLIP_USER_BIT; \
+ } \
+ \
+ STRIDE_F(coord, stride); \
+ } \
+ \
+ if (nr > 0) { \
+ *clipormask |= CLIP_USER_BIT; \
+ if (nr == count) { \
+ *clipandmask |= CLIP_USER_BIT; \
+ return; \
+ } \
+ } \
+ } \
+}
+
+
+USER_CLIPTEST(userclip2, 2)
+USER_CLIPTEST(userclip3, 3)
+USER_CLIPTEST(userclip4, 4)
+
+static void (*(usercliptab[5]))( GLcontext *,
+ GLvector4f *, GLubyte *,
+ GLubyte *, GLubyte * ) =
+{
+ NULL,
+ NULL,
+ userclip2,
+ userclip3,
+ userclip4
+};
+
+
+
+static GLboolean run_vertex_stage( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ struct vertex_stage_data *store = (struct vertex_stage_data *)stage->privatePtr;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+
+ if (ctx->VertexProgram._Enabled)
+ return GL_TRUE;
+
+ if (ctx->_NeedEyeCoords) {
+ /* Separate modelview transformation:
+ * Use combined ModelProject to avoid some depth artifacts
+ */
+ if (ctx->ModelviewMatrixStack.Top->type == MATRIX_IDENTITY)
+ VB->EyePtr = VB->ObjPtr;
+ else
+ VB->EyePtr = TransformRaw( &store->eye,
+ ctx->ModelviewMatrixStack.Top,
+ VB->ObjPtr);
+ }
+
+ VB->ClipPtr = TransformRaw( &store->clip,
+ &ctx->_ModelProjectMatrix,
+ VB->ObjPtr );
+
+ /* Drivers expect this to be clean to element 4...
+ */
+ switch (VB->ClipPtr->size) {
+ case 1:
+ /* impossible */
+ case 2:
+ _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 2 );
+ /* fall-through */
+ case 3:
+ _mesa_vector4f_clean_elem( VB->ClipPtr, VB->Count, 3 );
+ /* fall-through */
+ case 4:
+ break;
+ }
+
+
+ /* Cliptest and perspective divide. Clip functions must clear
+ * the clipmask.
+ */
+ store->ormask = 0;
+ store->andmask = CLIP_ALL_BITS;
+
+ if (tnl->NeedNdcCoords) {
+ VB->NdcPtr =
+ _mesa_clip_tab[VB->ClipPtr->size]( VB->ClipPtr,
+ &store->proj,
+ store->clipmask,
+ &store->ormask,
+ &store->andmask );
+ }
+ else {
+ VB->NdcPtr = NULL;
+ _mesa_clip_np_tab[VB->ClipPtr->size]( VB->ClipPtr,
+ NULL,
+ store->clipmask,
+ &store->ormask,
+ &store->andmask );
+ }
+
+ if (store->andmask)
+ return GL_FALSE;
+
+
+ /* Test userclip planes. This contributes to VB->ClipMask, so
+ * is essentially required to be in this stage.
+ */
+ if (ctx->Transform.ClipPlanesEnabled) {
+ usercliptab[VB->ClipPtr->size]( ctx,
+ VB->ClipPtr,
+ store->clipmask,
+ &store->ormask,
+ &store->andmask );
+
+ if (store->andmask)
+ return GL_FALSE;
+ }
+
+ VB->ClipAndMask = store->andmask;
+ VB->ClipOrMask = store->ormask;
+ VB->ClipMask = store->clipmask;
+
+ return GL_TRUE;
+}
+
+
+static GLboolean init_vertex_stage( GLcontext *ctx,
+ struct tnl_pipeline_stage *stage )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ struct vertex_stage_data *store;
+ GLuint size = VB->Size;
+
+ stage->privatePtr = CALLOC(sizeof(*store));
+ store = VERTEX_STAGE_DATA(stage);
+ if (!store)
+ return GL_FALSE;
+
+ _mesa_vector4f_alloc( &store->eye, 0, size, 32 );
+ _mesa_vector4f_alloc( &store->clip, 0, size, 32 );
+ _mesa_vector4f_alloc( &store->proj, 0, size, 32 );
+
+ store->clipmask = (GLubyte *) ALIGN_MALLOC(sizeof(GLubyte)*size, 32 );
+
+ if (!store->clipmask ||
+ !store->eye.data ||
+ !store->clip.data ||
+ !store->proj.data)
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+
+static void dtr( struct tnl_pipeline_stage *stage )
+{
+ struct vertex_stage_data *store = VERTEX_STAGE_DATA(stage);
+
+ if (store) {
+ _mesa_vector4f_free( &store->eye );
+ _mesa_vector4f_free( &store->clip );
+ _mesa_vector4f_free( &store->proj );
+ ALIGN_FREE( store->clipmask );
+ FREE(store);
+ stage->privatePtr = NULL;
+ stage->run = init_vertex_stage;
+ }
+}
+
+
+const struct tnl_pipeline_stage _tnl_vertex_transform_stage =
+{
+ "modelview/project/cliptest/divide",
+ NULL, /* private data */
+ init_vertex_stage,
+ dtr, /* destructor */
+ NULL,
+ run_vertex_stage /* run -- initially set to init */
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex.c
new file mode 100644
index 000000000..ca3aad140
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex.c
@@ -0,0 +1,509 @@
+/*
+ * Copyright 2003 Tungsten Graphics, inc.
+ * 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
+ * TUNGSTEN GRAPHICS 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:
+ * Keith Whitwell <keithw@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "colormac.h"
+
+#include "t_context.h"
+#include "t_vertex.h"
+
+#define DBG 0
+
+/* Build and manage clipspace/ndc/window vertices.
+ */
+
+static GLboolean match_fastpath( struct tnl_clipspace *vtx,
+ const struct tnl_clipspace_fastpath *fp)
+{
+ GLuint j;
+
+ if (vtx->attr_count != fp->attr_count)
+ return GL_FALSE;
+
+ for (j = 0; j < vtx->attr_count; j++)
+ if (vtx->attr[j].format != fp->attr[j].format ||
+ vtx->attr[j].inputsize != fp->attr[j].size ||
+ vtx->attr[j].vertoffset != fp->attr[j].offset)
+ return GL_FALSE;
+
+ if (fp->match_strides) {
+ if (vtx->vertex_size != fp->vertex_size)
+ return GL_FALSE;
+
+ for (j = 0; j < vtx->attr_count; j++)
+ if (vtx->attr[j].inputstride != fp->attr[j].stride)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+static GLboolean search_fastpath_emit( struct tnl_clipspace *vtx )
+{
+ struct tnl_clipspace_fastpath *fp = vtx->fastpath;
+
+ for ( ; fp ; fp = fp->next) {
+ if (match_fastpath(vtx, fp)) {
+ vtx->emit = fp->func;
+ return GL_TRUE;
+ }
+ }
+
+ return GL_FALSE;
+}
+
+void _tnl_register_fastpath( struct tnl_clipspace *vtx,
+ GLboolean match_strides )
+{
+ struct tnl_clipspace_fastpath *fastpath = CALLOC_STRUCT(tnl_clipspace_fastpath);
+ GLuint i;
+
+ fastpath->vertex_size = vtx->vertex_size;
+ fastpath->attr_count = vtx->attr_count;
+ fastpath->match_strides = match_strides;
+ fastpath->func = vtx->emit;
+ fastpath->attr = MALLOC(vtx->attr_count * sizeof(fastpath->attr[0]));
+
+ for (i = 0; i < vtx->attr_count; i++) {
+ fastpath->attr[i].format = vtx->attr[i].format;
+ fastpath->attr[i].stride = vtx->attr[i].inputstride;
+ fastpath->attr[i].size = vtx->attr[i].inputsize;
+ fastpath->attr[i].offset = vtx->attr[i].vertoffset;
+ }
+
+ fastpath->next = vtx->fastpath;
+ vtx->fastpath = fastpath;
+}
+
+
+
+/***********************************************************************
+ * Build codegen functions or return generic ones:
+ */
+static void choose_emit_func( GLcontext *ctx, GLuint count, GLubyte *dest)
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ struct tnl_clipspace_attr *a = vtx->attr;
+ const GLuint attr_count = vtx->attr_count;
+ GLuint j;
+
+ for (j = 0; j < attr_count; j++) {
+ GLvector4f *vptr = VB->AttribPtr[a[j].attrib];
+ a[j].inputstride = vptr->stride;
+ a[j].inputsize = vptr->size;
+ a[j].emit = a[j].insert[vptr->size - 1]; /* not always used */
+ }
+
+ vtx->emit = NULL;
+
+ /* Does this match an existing (hardwired, codegen or known-bad)
+ * fastpath?
+ */
+ if (search_fastpath_emit(vtx)) {
+ /* Use this result. If it is null, then it is already known
+ * that the current state will fail for codegen and there is no
+ * point trying again.
+ */
+ }
+ else if (vtx->codegen_emit) {
+ vtx->codegen_emit(ctx);
+ }
+
+ if (!vtx->emit) {
+ _tnl_generate_hardwired_emit(ctx);
+ }
+
+ /* Otherwise use the generic version:
+ */
+ if (!vtx->emit)
+ vtx->emit = _tnl_generic_emit;
+
+ vtx->emit( ctx, count, dest );
+}
+
+
+
+static void choose_interp_func( GLcontext *ctx,
+ GLfloat t,
+ GLuint edst, GLuint eout, GLuint ein,
+ GLboolean force_boundary )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+
+ if (vtx->need_extras &&
+ (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ vtx->interp = _tnl_generic_interp_extras;
+ } else {
+ vtx->interp = _tnl_generic_interp;
+ }
+
+ vtx->interp( ctx, t, edst, eout, ein, force_boundary );
+}
+
+
+static void choose_copy_pv_func( GLcontext *ctx, GLuint edst, GLuint esrc )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+
+ if (vtx->need_extras &&
+ (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ vtx->copy_pv = _tnl_generic_copy_pv_extras;
+ } else {
+ vtx->copy_pv = _tnl_generic_copy_pv;
+ }
+
+ vtx->copy_pv( ctx, edst, esrc );
+}
+
+
+/***********************************************************************
+ * Public entrypoints, mostly dispatch to the above:
+ */
+
+
+/* Interpolate between two vertices to produce a third:
+ */
+void _tnl_interp( GLcontext *ctx,
+ GLfloat t,
+ GLuint edst, GLuint eout, GLuint ein,
+ GLboolean force_boundary )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ vtx->interp( ctx, t, edst, eout, ein, force_boundary );
+}
+
+/* Copy colors from one vertex to another:
+ */
+void _tnl_copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ vtx->copy_pv( ctx, edst, esrc );
+}
+
+
+/* Extract a named attribute from a hardware vertex. Will have to
+ * reverse any viewport transformation, swizzling or other conversions
+ * which may have been applied:
+ */
+void _tnl_get_attr( GLcontext *ctx, const void *vin,
+ GLenum attr, GLfloat *dest )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ const struct tnl_clipspace_attr *a = vtx->attr;
+ const GLuint attr_count = vtx->attr_count;
+ GLuint j;
+
+ for (j = 0; j < attr_count; j++) {
+ if (a[j].attrib == attr) {
+ a[j].extract( &a[j], dest, (GLubyte *)vin + a[j].vertoffset );
+ return;
+ }
+ }
+
+ /* Else return the value from ctx->Current.
+ */
+ _mesa_memcpy( dest, ctx->Current.Attrib[attr], 4*sizeof(GLfloat));
+}
+
+
+/* Complementary operation to the above.
+ */
+void _tnl_set_attr( GLcontext *ctx, void *vout,
+ GLenum attr, const GLfloat *src )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ const struct tnl_clipspace_attr *a = vtx->attr;
+ const GLuint attr_count = vtx->attr_count;
+ GLuint j;
+
+ for (j = 0; j < attr_count; j++) {
+ if (a[j].attrib == attr) {
+ a[j].insert[4-1]( &a[j], (GLubyte *)vout + a[j].vertoffset, src );
+ return;
+ }
+ }
+}
+
+
+void *_tnl_get_vertex( GLcontext *ctx, GLuint nr )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+
+ return vtx->vertex_buf + nr * vtx->vertex_size;
+}
+
+void _tnl_invalidate_vertex_state( GLcontext *ctx, GLuint new_state )
+{
+ if (new_state & (_DD_NEW_TRI_LIGHT_TWOSIDE|_DD_NEW_TRI_UNFILLED) ) {
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ vtx->new_inputs = ~0;
+ vtx->interp = choose_interp_func;
+ vtx->copy_pv = choose_copy_pv_func;
+ }
+}
+
+static void invalidate_funcs( struct tnl_clipspace *vtx )
+{
+ vtx->emit = choose_emit_func;
+ vtx->interp = choose_interp_func;
+ vtx->copy_pv = choose_copy_pv_func;
+ vtx->new_inputs = ~0;
+}
+
+GLuint _tnl_install_attrs( GLcontext *ctx, const struct tnl_attr_map *map,
+ GLuint nr, const GLfloat *vp,
+ GLuint unpacked_size )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ GLuint offset = 0;
+ GLuint i, j;
+
+ assert(nr < _TNL_ATTRIB_MAX);
+ assert(nr == 0 || map[0].attrib == VERT_ATTRIB_POS);
+
+ vtx->new_inputs = ~0;
+ vtx->need_viewport = GL_FALSE;
+
+ if (vp) {
+ vtx->need_viewport = GL_TRUE;
+ }
+
+ for (j = 0, i = 0; i < nr; i++) {
+ const GLuint format = map[i].format;
+ if (format == EMIT_PAD) {
+ if (DBG)
+ _mesa_printf("%d: pad %d, offset %d\n", i,
+ map[i].offset, offset);
+
+ offset += map[i].offset;
+
+ }
+ else {
+ GLuint tmpoffset;
+
+ if (unpacked_size)
+ tmpoffset = map[i].offset;
+ else
+ tmpoffset = offset;
+
+ if (vtx->attr_count != j ||
+ vtx->attr[j].attrib != map[i].attrib ||
+ vtx->attr[j].format != format ||
+ vtx->attr[j].vertoffset != tmpoffset) {
+ invalidate_funcs(vtx);
+
+ vtx->attr[j].attrib = map[i].attrib;
+ vtx->attr[j].format = format;
+ vtx->attr[j].vp = vp;
+ vtx->attr[j].insert = _tnl_format_info[format].insert;
+ vtx->attr[j].extract = _tnl_format_info[format].extract;
+ vtx->attr[j].vertattrsize = _tnl_format_info[format].attrsize;
+ vtx->attr[j].vertoffset = tmpoffset;
+ }
+
+
+ if (DBG)
+ _mesa_printf("%d: %s, vp %p, offset %d\n", i,
+ _tnl_format_info[format].name, (void *)vp,
+ vtx->attr[j].vertoffset);
+
+ offset += _tnl_format_info[format].attrsize;
+ j++;
+ }
+ }
+
+ vtx->attr_count = j;
+
+ if (unpacked_size)
+ vtx->vertex_size = unpacked_size;
+ else
+ vtx->vertex_size = offset;
+
+ assert(vtx->vertex_size <= vtx->max_vertex_size);
+ return vtx->vertex_size;
+}
+
+
+
+void _tnl_invalidate_vertices( GLcontext *ctx, GLuint newinputs )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ vtx->new_inputs |= newinputs;
+}
+
+
+/* This event has broader use beyond this file - will move elsewhere
+ * and probably invoke a driver callback.
+ */
+void _tnl_notify_pipeline_output_change( GLcontext *ctx )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ invalidate_funcs(vtx);
+}
+
+static void update_input_ptrs( GLcontext *ctx, GLuint start )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ struct tnl_clipspace_attr *a = vtx->attr;
+ const GLuint count = vtx->attr_count;
+ GLuint j;
+
+ for (j = 0; j < count; j++) {
+ GLvector4f *vptr = VB->AttribPtr[a[j].attrib];
+
+ if (vtx->emit != choose_emit_func) {
+ assert(a[j].inputstride == vptr->stride);
+ assert(a[j].inputsize == vptr->size);
+ }
+
+ a[j].inputptr = ((GLubyte *)vptr->data) + start * vptr->stride;
+ }
+
+ if (a->vp) {
+ vtx->vp_scale[0] = a->vp[MAT_SX];
+ vtx->vp_scale[1] = a->vp[MAT_SY];
+ vtx->vp_scale[2] = a->vp[MAT_SZ];
+ vtx->vp_scale[3] = 1.0;
+ vtx->vp_xlate[0] = a->vp[MAT_TX];
+ vtx->vp_xlate[1] = a->vp[MAT_TY];
+ vtx->vp_xlate[2] = a->vp[MAT_TZ];
+ vtx->vp_xlate[3] = 0.0;
+ }
+}
+
+
+void _tnl_build_vertices( GLcontext *ctx,
+ GLuint start,
+ GLuint end,
+ GLuint newinputs )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ update_input_ptrs( ctx, start );
+ vtx->emit( ctx, end - start,
+ (GLubyte *)(vtx->vertex_buf +
+ start * vtx->vertex_size));
+}
+
+/* Emit VB vertices start..end to dest. Note that VB vertex at
+ * postion start will be emitted to dest at position zero.
+ */
+void *_tnl_emit_vertices_to_buffer( GLcontext *ctx,
+ GLuint start,
+ GLuint end,
+ void *dest )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+
+ update_input_ptrs(ctx, start);
+
+ /* Note: dest should not be adjusted for non-zero 'start' values:
+ */
+ vtx->emit( ctx, end - start, dest );
+ return (void *)((GLubyte *)dest + vtx->vertex_size * (end - start));
+}
+
+
+void _tnl_init_vertices( GLcontext *ctx,
+ GLuint vb_size,
+ GLuint max_vertex_size )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+
+ _tnl_install_attrs( ctx, NULL, 0, NULL, 0 );
+
+ vtx->need_extras = GL_TRUE;
+ if (max_vertex_size > vtx->max_vertex_size) {
+ _tnl_free_vertices( ctx );
+ vtx->max_vertex_size = max_vertex_size;
+ vtx->vertex_buf = (GLubyte *)ALIGN_CALLOC(vb_size * max_vertex_size, 32 );
+ invalidate_funcs(vtx);
+ }
+
+ switch(CHAN_TYPE) {
+ case GL_UNSIGNED_BYTE:
+ vtx->chan_scale[0] = 255.0;
+ vtx->chan_scale[1] = 255.0;
+ vtx->chan_scale[2] = 255.0;
+ vtx->chan_scale[3] = 255.0;
+ break;
+ case GL_UNSIGNED_SHORT:
+ vtx->chan_scale[0] = 65535.0;
+ vtx->chan_scale[1] = 65535.0;
+ vtx->chan_scale[2] = 65535.0;
+ vtx->chan_scale[3] = 65535.0;
+ break;
+ default:
+ vtx->chan_scale[0] = 1.0;
+ vtx->chan_scale[1] = 1.0;
+ vtx->chan_scale[2] = 1.0;
+ vtx->chan_scale[3] = 1.0;
+ break;
+ }
+
+ vtx->identity[0] = 0.0;
+ vtx->identity[1] = 0.0;
+ vtx->identity[2] = 0.0;
+ vtx->identity[3] = 1.0;
+
+ vtx->codegen_emit = NULL;
+
+#ifdef USE_SSE_ASM
+ if (!_mesa_getenv("MESA_NO_CODEGEN"))
+ vtx->codegen_emit = _tnl_generate_sse_emit;
+#endif
+}
+
+
+void _tnl_free_vertices( GLcontext *ctx )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ struct tnl_clipspace_fastpath *fp, *tmp;
+
+ if (vtx->vertex_buf) {
+ ALIGN_FREE(vtx->vertex_buf);
+ vtx->vertex_buf = NULL;
+ }
+
+ for (fp = vtx->fastpath ; fp ; fp = tmp) {
+ tmp = fp->next;
+ FREE(fp->attr);
+
+ /* KW: At the moment, fp->func is constrained to be allocated by
+ * _mesa_exec_alloc(), as the hardwired fastpaths in
+ * t_vertex_generic.c are handled specially. It would be nice
+ * to unify them, but this probably won't change until this
+ * module gets another overhaul.
+ */
+ _mesa_exec_free((void *) fp->func);
+ FREE(fp);
+ }
+
+ vtx->fastpath = NULL;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex.h
new file mode 100644
index 000000000..fda8f151d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex.h
@@ -0,0 +1,169 @@
+/*
+ * Copyright 2003 Tungsten Graphics, inc.
+ * 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
+ * TUNGSTEN GRAPHICS 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:
+ * Keith Whitwell <keithw@tungstengraphics.com>
+ */
+
+#ifndef _TNL_VERTEX_H
+#define _TNL_VERTEX_H
+
+#include "mtypes.h"
+#include "t_context.h"
+
+/* New mechanism to specify hardware vertices so that tnl can build
+ * and manipulate them directly.
+ */
+
+
+/* It will probably be necessary to allow drivers to specify new
+ * emit-styles to cover all the wierd and wacky things out there.
+ */
+enum tnl_attr_format {
+ EMIT_1F,
+ EMIT_2F,
+ EMIT_3F,
+ EMIT_4F,
+ EMIT_2F_VIEWPORT, /* do viewport transform and emit */
+ EMIT_3F_VIEWPORT, /* do viewport transform and emit */
+ EMIT_4F_VIEWPORT, /* do viewport transform and emit */
+ EMIT_3F_XYW, /* for projective texture */
+ EMIT_1UB_1F, /* for fog coordinate */
+ EMIT_3UB_3F_RGB, /* for specular color */
+ EMIT_3UB_3F_BGR, /* for specular color */
+ EMIT_4UB_4F_RGBA, /* for color */
+ EMIT_4UB_4F_BGRA, /* for color */
+ EMIT_4UB_4F_ARGB, /* for color */
+ EMIT_4UB_4F_ABGR, /* for color */
+ EMIT_4CHAN_4F_RGBA, /* for swrast color */
+ EMIT_PAD, /* leave a hole of 'offset' bytes */
+ EMIT_MAX
+};
+
+struct tnl_attr_map {
+ GLuint attrib; /* _TNL_ATTRIB_ enum */
+ enum tnl_attr_format format;
+ GLuint offset;
+};
+
+struct tnl_format_info {
+ const char *name;
+ tnl_extract_func extract;
+ tnl_insert_func insert[4];
+ const GLuint attrsize;
+};
+
+extern const struct tnl_format_info _tnl_format_info[EMIT_MAX];
+
+
+/* Interpolate between two vertices to produce a third:
+ */
+extern void _tnl_interp( GLcontext *ctx,
+ GLfloat t,
+ GLuint edst, GLuint eout, GLuint ein,
+ GLboolean force_boundary );
+
+/* Copy colors from one vertex to another:
+ */
+extern void _tnl_copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc );
+
+
+/* Extract a named attribute from a hardware vertex. Will have to
+ * reverse any viewport transformation, swizzling or other conversions
+ * which may have been applied:
+ */
+extern void _tnl_get_attr( GLcontext *ctx, const void *vertex, GLenum attrib,
+ GLfloat *dest );
+
+/* Complementary to the above.
+ */
+extern void _tnl_set_attr( GLcontext *ctx, void *vout, GLenum attrib,
+ const GLfloat *src );
+
+
+extern void *_tnl_get_vertex( GLcontext *ctx, GLuint nr );
+
+extern GLuint _tnl_install_attrs( GLcontext *ctx,
+ const struct tnl_attr_map *map,
+ GLuint nr, const GLfloat *vp,
+ GLuint unpacked_size );
+
+extern void _tnl_free_vertices( GLcontext *ctx );
+
+extern void _tnl_init_vertices( GLcontext *ctx,
+ GLuint vb_size,
+ GLuint max_vertex_size );
+
+extern void *_tnl_emit_vertices_to_buffer( GLcontext *ctx,
+ GLuint start,
+ GLuint end,
+ void *dest );
+
+extern void _tnl_build_vertices( GLcontext *ctx,
+ GLuint start,
+ GLuint end,
+ GLuint newinputs );
+
+extern void _tnl_invalidate_vertices( GLcontext *ctx, GLuint newinputs );
+
+extern void _tnl_invalidate_vertex_state( GLcontext *ctx, GLuint new_state );
+
+extern void _tnl_notify_pipeline_output_change( GLcontext *ctx );
+
+
+#define GET_VERTEX_STATE(ctx) &(TNL_CONTEXT(ctx)->clipspace)
+
+/* Internal function:
+ */
+void _tnl_register_fastpath( struct tnl_clipspace *vtx,
+ GLboolean match_strides );
+
+
+/* t_vertex_generic.c -- Internal functions for t_vertex.c
+ */
+void _tnl_generic_copy_pv_extras( GLcontext *ctx,
+ GLuint dst, GLuint src );
+
+void _tnl_generic_interp_extras( GLcontext *ctx,
+ GLfloat t,
+ GLuint dst, GLuint out, GLuint in,
+ GLboolean force_boundary );
+
+void _tnl_generic_copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc );
+
+void _tnl_generic_interp( GLcontext *ctx,
+ GLfloat t,
+ GLuint edst, GLuint eout, GLuint ein,
+ GLboolean force_boundary );
+
+void _tnl_generic_emit( GLcontext *ctx,
+ GLuint count,
+ GLubyte *v );
+
+void _tnl_generate_hardwired_emit( GLcontext *ctx );
+
+/* t_vertex_sse.c -- Internal functions for t_vertex.c
+ */
+void _tnl_generate_sse_emit( GLcontext *ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex_generic.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex_generic.c
new file mode 100644
index 000000000..3f9445805
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex_generic.c
@@ -0,0 +1,1119 @@
+
+/*
+ * Copyright 2003 Tungsten Graphics, inc.
+ * 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
+ * TUNGSTEN GRAPHICS 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:
+ * Keith Whitwell <keithw@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "colormac.h"
+#include "t_context.h"
+#include "t_vertex.h"
+#include "simple_list.h"
+
+
+
+/*
+ * These functions take the NDC coordinates pointed to by 'in', apply the
+ * NDC->Viewport mapping and store the results at 'v'.
+ */
+
+static INLINE void insert_4f_viewport_4( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)v;
+ const GLfloat * const vp = a->vp;
+
+ out[0] = vp[0] * in[0] + vp[12];
+ out[1] = vp[5] * in[1] + vp[13];
+ out[2] = vp[10] * in[2] + vp[14];
+ out[3] = in[3];
+}
+
+static INLINE void insert_4f_viewport_3( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)v;
+ const GLfloat * const vp = a->vp;
+
+ out[0] = vp[0] * in[0] + vp[12];
+ out[1] = vp[5] * in[1] + vp[13];
+ out[2] = vp[10] * in[2] + vp[14];
+ out[3] = 1;
+}
+
+static INLINE void insert_4f_viewport_2( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)v;
+ const GLfloat * const vp = a->vp;
+
+ out[0] = vp[0] * in[0] + vp[12];
+ out[1] = vp[5] * in[1] + vp[13];
+ out[2] = vp[14];
+ out[3] = 1;
+}
+
+static INLINE void insert_4f_viewport_1( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)v;
+ const GLfloat * const vp = a->vp;
+
+ out[0] = vp[0] * in[0] + vp[12];
+ out[1] = vp[13];
+ out[2] = vp[14];
+ out[3] = 1;
+}
+
+static INLINE void insert_3f_viewport_3( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)v;
+ const GLfloat * const vp = a->vp;
+
+ out[0] = vp[0] * in[0] + vp[12];
+ out[1] = vp[5] * in[1] + vp[13];
+ out[2] = vp[10] * in[2] + vp[14];
+}
+
+static INLINE void insert_3f_viewport_2( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)v;
+ const GLfloat * const vp = a->vp;
+
+ out[0] = vp[0] * in[0] + vp[12];
+ out[1] = vp[5] * in[1] + vp[13];
+ out[2] = vp[10] * in[2] + vp[14];
+}
+
+static INLINE void insert_3f_viewport_1( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)v;
+ const GLfloat * const vp = a->vp;
+
+ out[0] = vp[0] * in[0] + vp[12];
+ out[1] = vp[13];
+ out[2] = vp[14];
+}
+
+static INLINE void insert_2f_viewport_2( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)v;
+ const GLfloat * const vp = a->vp;
+
+ out[0] = vp[0] * in[0] + vp[12];
+ out[1] = vp[5] * in[1] + vp[13];
+}
+
+static INLINE void insert_2f_viewport_1( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)v;
+ const GLfloat * const vp = a->vp;
+
+ out[0] = vp[0] * in[0] + vp[12];
+ out[1] = vp[13];
+}
+
+
+/*
+ * These functions do the same as above, except for the viewport mapping.
+ */
+
+static INLINE void insert_4f_4( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)(v);
+ (void) a;
+
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = in[2];
+ out[3] = in[3];
+}
+
+static INLINE void insert_4f_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)(v);
+ (void) a;
+
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = in[2];
+ out[3] = 1;
+}
+
+static INLINE void insert_4f_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)(v);
+ (void) a;
+
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = 0;
+ out[3] = 1;
+}
+
+static INLINE void insert_4f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)(v);
+ (void) a;
+
+ out[0] = in[0];
+ out[1] = 0;
+ out[2] = 0;
+ out[3] = 1;
+}
+
+static INLINE void insert_3f_xyw_4( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)(v);
+ (void) a;
+
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = in[3];
+}
+
+static INLINE void insert_3f_xyw_err( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
+{
+ (void) a; (void) v; (void) in;
+ abort();
+}
+
+static INLINE void insert_3f_3( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)(v);
+ (void) a;
+
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = in[2];
+}
+
+static INLINE void insert_3f_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)(v);
+ (void) a;
+
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = 0;
+}
+
+static INLINE void insert_3f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)(v);
+ (void) a;
+
+ out[0] = in[0];
+ out[1] = 0;
+ out[2] = 0;
+}
+
+
+static INLINE void insert_2f_2( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)(v);
+ (void) a;
+
+ out[0] = in[0];
+ out[1] = in[1];
+}
+
+static INLINE void insert_2f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)(v);
+ (void) a;
+
+ out[0] = in[0];
+ out[1] = 0;
+}
+
+static INLINE void insert_1f_1( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
+{
+ GLfloat *out = (GLfloat *)(v);
+ (void) a;
+
+ out[0] = in[0];
+}
+
+static INLINE void insert_null( const struct tnl_clipspace_attr *a, GLubyte *v, const GLfloat *in )
+{
+ (void) a; (void) v; (void) in;
+}
+
+static INLINE void insert_4chan_4f_rgba_4( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ GLchan *c = (GLchan *)v;
+ (void) a;
+ UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(c[2], in[2]);
+ UNCLAMPED_FLOAT_TO_CHAN(c[3], in[3]);
+}
+
+static INLINE void insert_4chan_4f_rgba_3( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ GLchan *c = (GLchan *)v;
+ (void) a;
+ UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]);
+ UNCLAMPED_FLOAT_TO_CHAN(c[2], in[2]);
+ c[3] = CHAN_MAX;
+}
+
+static INLINE void insert_4chan_4f_rgba_2( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ GLchan *c = (GLchan *)v;
+ (void) a;
+ UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]);
+ UNCLAMPED_FLOAT_TO_CHAN(c[1], in[1]);
+ c[2] = 0;
+ c[3] = CHAN_MAX;
+}
+
+static INLINE void insert_4chan_4f_rgba_1( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ GLchan *c = (GLchan *)v;
+ (void) a;
+ UNCLAMPED_FLOAT_TO_CHAN(c[0], in[0]);
+ c[1] = 0;
+ c[2] = 0;
+ c[3] = CHAN_MAX;
+}
+
+static INLINE void insert_4ub_4f_rgba_4( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[3]);
+}
+
+static INLINE void insert_4ub_4f_rgba_3( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);
+ v[3] = 0xff;
+}
+
+static INLINE void insert_4ub_4f_rgba_2( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
+ v[2] = 0;
+ v[3] = 0xff;
+}
+
+static INLINE void insert_4ub_4f_rgba_1( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
+ v[1] = 0;
+ v[2] = 0;
+ v[3] = 0xff;
+}
+
+static INLINE void insert_4ub_4f_bgra_4( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[3]);
+}
+
+static INLINE void insert_4ub_4f_bgra_3( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);
+ v[3] = 0xff;
+}
+
+static INLINE void insert_4ub_4f_bgra_2( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
+ v[0] = 0;
+ v[3] = 0xff;
+}
+
+static INLINE void insert_4ub_4f_bgra_1( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
+ v[1] = 0;
+ v[0] = 0;
+ v[3] = 0xff;
+}
+
+static INLINE void insert_4ub_4f_argb_4( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[2]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[3]);
+}
+
+static INLINE void insert_4ub_4f_argb_3( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[2]);
+ v[0] = 0xff;
+}
+
+static INLINE void insert_4ub_4f_argb_2( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
+ v[3] = 0x00;
+ v[0] = 0xff;
+}
+
+static INLINE void insert_4ub_4f_argb_1( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[0]);
+ v[2] = 0x00;
+ v[3] = 0x00;
+ v[0] = 0xff;
+}
+
+static INLINE void insert_4ub_4f_abgr_4( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[2]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[3]);
+}
+
+static INLINE void insert_4ub_4f_abgr_3( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[2]);
+ v[0] = 0xff;
+}
+
+static INLINE void insert_4ub_4f_abgr_2( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[1]);
+ v[1] = 0x00;
+ v[0] = 0xff;
+}
+
+static INLINE void insert_4ub_4f_abgr_1( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[3], in[0]);
+ v[2] = 0x00;
+ v[1] = 0x00;
+ v[0] = 0xff;
+}
+
+static INLINE void insert_3ub_3f_rgb_3( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[2]);
+}
+
+static INLINE void insert_3ub_3f_rgb_2( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
+ v[2] = 0;
+}
+
+static INLINE void insert_3ub_3f_rgb_1( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
+ v[1] = 0;
+ v[2] = 0;
+}
+
+static INLINE void insert_3ub_3f_bgr_3( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[2]);
+}
+
+static INLINE void insert_3ub_3f_bgr_2( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v[1], in[1]);
+ v[0] = 0;
+}
+
+static INLINE void insert_3ub_3f_bgr_1( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[2], in[0]);
+ v[1] = 0;
+ v[0] = 0;
+}
+
+
+static INLINE void insert_1ub_1f_1( const struct tnl_clipspace_attr *a, GLubyte *v,
+ const GLfloat *in )
+{
+ (void) a;
+ UNCLAMPED_FLOAT_TO_UBYTE(v[0], in[0]);
+}
+
+
+/***********************************************************************
+ * Functions to perform the reverse operations to the above, for
+ * swrast translation and clip-interpolation.
+ *
+ * Currently always extracts a full 4 floats.
+ */
+
+static void extract_4f_viewport( const struct tnl_clipspace_attr *a, GLfloat *out,
+ const GLubyte *v )
+{
+ const GLfloat *in = (const GLfloat *)v;
+ const GLfloat * const vp = a->vp;
+
+ /* Although included for completeness, the position coordinate is
+ * usually handled differently during clipping.
+ */
+ out[0] = (in[0] - vp[12]) / vp[0];
+ out[1] = (in[1] - vp[13]) / vp[5];
+ out[2] = (in[2] - vp[14]) / vp[10];
+ out[3] = in[3];
+}
+
+static void extract_3f_viewport( const struct tnl_clipspace_attr *a, GLfloat *out,
+ const GLubyte *v )
+{
+ const GLfloat *in = (const GLfloat *)v;
+ const GLfloat * const vp = a->vp;
+
+ out[0] = (in[0] - vp[12]) / vp[0];
+ out[1] = (in[1] - vp[13]) / vp[5];
+ out[2] = (in[2] - vp[14]) / vp[10];
+ out[3] = 1;
+}
+
+
+static void extract_2f_viewport( const struct tnl_clipspace_attr *a, GLfloat *out,
+ const GLubyte *v )
+{
+ const GLfloat *in = (const GLfloat *)v;
+ const GLfloat * const vp = a->vp;
+
+ out[0] = (in[0] - vp[12]) / vp[0];
+ out[1] = (in[1] - vp[13]) / vp[5];
+ out[2] = 0;
+ out[3] = 1;
+}
+
+
+static void extract_4f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v )
+{
+ const GLfloat *in = (const GLfloat *)v;
+ (void) a;
+
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = in[2];
+ out[3] = in[3];
+}
+
+static void extract_3f_xyw( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v )
+{
+ const GLfloat *in = (const GLfloat *)v;
+ (void) a;
+
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = 0;
+ out[3] = in[2];
+}
+
+
+static void extract_3f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v )
+{
+ const GLfloat *in = (const GLfloat *)v;
+ (void) a;
+
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = in[2];
+ out[3] = 1;
+}
+
+
+static void extract_2f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v )
+{
+ const GLfloat *in = (const GLfloat *)v;
+ (void) a;
+
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = 0;
+ out[3] = 1;
+}
+
+static void extract_1f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v )
+{
+ const GLfloat *in = (const GLfloat *)v;
+ (void) a;
+
+ out[0] = in[0];
+ out[1] = 0;
+ out[2] = 0;
+ out[3] = 1;
+}
+
+static void extract_4chan_4f_rgba( const struct tnl_clipspace_attr *a, GLfloat *out,
+ const GLubyte *v )
+{
+ GLchan *c = (GLchan *)v;
+ (void) a;
+
+ out[0] = CHAN_TO_FLOAT(c[0]);
+ out[1] = CHAN_TO_FLOAT(c[1]);
+ out[2] = CHAN_TO_FLOAT(c[2]);
+ out[3] = CHAN_TO_FLOAT(c[3]);
+}
+
+static void extract_4ub_4f_rgba( const struct tnl_clipspace_attr *a, GLfloat *out,
+ const GLubyte *v )
+{
+ (void) a;
+ out[0] = UBYTE_TO_FLOAT(v[0]);
+ out[1] = UBYTE_TO_FLOAT(v[1]);
+ out[2] = UBYTE_TO_FLOAT(v[2]);
+ out[3] = UBYTE_TO_FLOAT(v[3]);
+}
+
+static void extract_4ub_4f_bgra( const struct tnl_clipspace_attr *a, GLfloat *out,
+ const GLubyte *v )
+{
+ (void) a;
+ out[2] = UBYTE_TO_FLOAT(v[0]);
+ out[1] = UBYTE_TO_FLOAT(v[1]);
+ out[0] = UBYTE_TO_FLOAT(v[2]);
+ out[3] = UBYTE_TO_FLOAT(v[3]);
+}
+
+static void extract_4ub_4f_argb( const struct tnl_clipspace_attr *a, GLfloat *out,
+ const GLubyte *v )
+{
+ (void) a;
+ out[3] = UBYTE_TO_FLOAT(v[0]);
+ out[0] = UBYTE_TO_FLOAT(v[1]);
+ out[1] = UBYTE_TO_FLOAT(v[2]);
+ out[2] = UBYTE_TO_FLOAT(v[3]);
+}
+
+static void extract_4ub_4f_abgr( const struct tnl_clipspace_attr *a, GLfloat *out,
+ const GLubyte *v )
+{
+ (void) a;
+ out[3] = UBYTE_TO_FLOAT(v[0]);
+ out[2] = UBYTE_TO_FLOAT(v[1]);
+ out[1] = UBYTE_TO_FLOAT(v[2]);
+ out[0] = UBYTE_TO_FLOAT(v[3]);
+}
+
+static void extract_3ub_3f_rgb( const struct tnl_clipspace_attr *a, GLfloat *out,
+ const GLubyte *v )
+{
+ (void) a;
+ out[0] = UBYTE_TO_FLOAT(v[0]);
+ out[1] = UBYTE_TO_FLOAT(v[1]);
+ out[2] = UBYTE_TO_FLOAT(v[2]);
+ out[3] = 1;
+}
+
+static void extract_3ub_3f_bgr( const struct tnl_clipspace_attr *a, GLfloat *out,
+ const GLubyte *v )
+{
+ (void) a;
+ out[2] = UBYTE_TO_FLOAT(v[0]);
+ out[1] = UBYTE_TO_FLOAT(v[1]);
+ out[0] = UBYTE_TO_FLOAT(v[2]);
+ out[3] = 1;
+}
+
+static void extract_1ub_1f( const struct tnl_clipspace_attr *a, GLfloat *out, const GLubyte *v )
+{
+ (void) a;
+ out[0] = UBYTE_TO_FLOAT(v[0]);
+ out[1] = 0;
+ out[2] = 0;
+ out[3] = 1;
+}
+
+
+const struct tnl_format_info _tnl_format_info[EMIT_MAX] =
+{
+ { "1f",
+ extract_1f,
+ { insert_1f_1, insert_1f_1, insert_1f_1, insert_1f_1 },
+ sizeof(GLfloat) },
+
+ { "2f",
+ extract_2f,
+ { insert_2f_1, insert_2f_2, insert_2f_2, insert_2f_2 },
+ 2 * sizeof(GLfloat) },
+
+ { "3f",
+ extract_3f,
+ { insert_3f_1, insert_3f_2, insert_3f_3, insert_3f_3 },
+ 3 * sizeof(GLfloat) },
+
+ { "4f",
+ extract_4f,
+ { insert_4f_1, insert_4f_2, insert_4f_3, insert_4f_4 },
+ 4 * sizeof(GLfloat) },
+
+ { "2f_viewport",
+ extract_2f_viewport,
+ { insert_2f_viewport_1, insert_2f_viewport_2, insert_2f_viewport_2,
+ insert_2f_viewport_2 },
+ 2 * sizeof(GLfloat) },
+
+ { "3f_viewport",
+ extract_3f_viewport,
+ { insert_3f_viewport_1, insert_3f_viewport_2, insert_3f_viewport_3,
+ insert_3f_viewport_3 },
+ 3 * sizeof(GLfloat) },
+
+ { "4f_viewport",
+ extract_4f_viewport,
+ { insert_4f_viewport_1, insert_4f_viewport_2, insert_4f_viewport_3,
+ insert_4f_viewport_4 },
+ 4 * sizeof(GLfloat) },
+
+ { "3f_xyw",
+ extract_3f_xyw,
+ { insert_3f_xyw_err, insert_3f_xyw_err, insert_3f_xyw_err,
+ insert_3f_xyw_4 },
+ 3 * sizeof(GLfloat) },
+
+ { "1ub_1f",
+ extract_1ub_1f,
+ { insert_1ub_1f_1, insert_1ub_1f_1, insert_1ub_1f_1, insert_1ub_1f_1 },
+ sizeof(GLubyte) },
+
+ { "3ub_3f_rgb",
+ extract_3ub_3f_rgb,
+ { insert_3ub_3f_rgb_1, insert_3ub_3f_rgb_2, insert_3ub_3f_rgb_3,
+ insert_3ub_3f_rgb_3 },
+ 3 * sizeof(GLubyte) },
+
+ { "3ub_3f_bgr",
+ extract_3ub_3f_bgr,
+ { insert_3ub_3f_bgr_1, insert_3ub_3f_bgr_2, insert_3ub_3f_bgr_3,
+ insert_3ub_3f_bgr_3 },
+ 3 * sizeof(GLubyte) },
+
+ { "4ub_4f_rgba",
+ extract_4ub_4f_rgba,
+ { insert_4ub_4f_rgba_1, insert_4ub_4f_rgba_2, insert_4ub_4f_rgba_3,
+ insert_4ub_4f_rgba_4 },
+ 4 * sizeof(GLubyte) },
+
+ { "4ub_4f_bgra",
+ extract_4ub_4f_bgra,
+ { insert_4ub_4f_bgra_1, insert_4ub_4f_bgra_2, insert_4ub_4f_bgra_3,
+ insert_4ub_4f_bgra_4 },
+ 4 * sizeof(GLubyte) },
+
+ { "4ub_4f_argb",
+ extract_4ub_4f_argb,
+ { insert_4ub_4f_argb_1, insert_4ub_4f_argb_2, insert_4ub_4f_argb_3,
+ insert_4ub_4f_argb_4 },
+ 4 * sizeof(GLubyte) },
+
+ { "4ub_4f_abgr",
+ extract_4ub_4f_abgr,
+ { insert_4ub_4f_abgr_1, insert_4ub_4f_abgr_2, insert_4ub_4f_abgr_3,
+ insert_4ub_4f_abgr_4 },
+ 4 * sizeof(GLubyte) },
+
+ { "4chan_4f_rgba",
+ extract_4chan_4f_rgba,
+ { insert_4chan_4f_rgba_1, insert_4chan_4f_rgba_2, insert_4chan_4f_rgba_3,
+ insert_4chan_4f_rgba_4 },
+ 4 * sizeof(GLchan) },
+
+ { "pad",
+ NULL,
+ { NULL, NULL, NULL, NULL },
+ 0 }
+
+};
+
+
+
+
+/***********************************************************************
+ * Hardwired fastpaths for emitting whole vertices or groups of
+ * vertices
+ */
+#define EMIT5(NR, F0, F1, F2, F3, F4, NAME) \
+static void NAME( GLcontext *ctx, \
+ GLuint count, \
+ GLubyte *v ) \
+{ \
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx); \
+ struct tnl_clipspace_attr *a = vtx->attr; \
+ GLuint i; \
+ \
+ for (i = 0 ; i < count ; i++, v += vtx->vertex_size) { \
+ if (NR > 0) { \
+ F0( &a[0], v + a[0].vertoffset, (GLfloat *)a[0].inputptr ); \
+ a[0].inputptr += a[0].inputstride; \
+ } \
+ \
+ if (NR > 1) { \
+ F1( &a[1], v + a[1].vertoffset, (GLfloat *)a[1].inputptr ); \
+ a[1].inputptr += a[1].inputstride; \
+ } \
+ \
+ if (NR > 2) { \
+ F2( &a[2], v + a[2].vertoffset, (GLfloat *)a[2].inputptr ); \
+ a[2].inputptr += a[2].inputstride; \
+ } \
+ \
+ if (NR > 3) { \
+ F3( &a[3], v + a[3].vertoffset, (GLfloat *)a[3].inputptr ); \
+ a[3].inputptr += a[3].inputstride; \
+ } \
+ \
+ if (NR > 4) { \
+ F4( &a[4], v + a[4].vertoffset, (GLfloat *)a[4].inputptr ); \
+ a[4].inputptr += a[4].inputstride; \
+ } \
+ } \
+}
+
+
+#define EMIT2(F0, F1, NAME) EMIT5(2, F0, F1, insert_null, \
+ insert_null, insert_null, NAME)
+
+#define EMIT3(F0, F1, F2, NAME) EMIT5(3, F0, F1, F2, insert_null, \
+ insert_null, NAME)
+
+#define EMIT4(F0, F1, F2, F3, NAME) EMIT5(4, F0, F1, F2, F3, \
+ insert_null, NAME)
+
+
+EMIT2(insert_3f_viewport_3, insert_4ub_4f_rgba_4, emit_viewport3_rgba4)
+EMIT2(insert_3f_viewport_3, insert_4ub_4f_bgra_4, emit_viewport3_bgra4)
+EMIT2(insert_3f_3, insert_4ub_4f_rgba_4, emit_xyz3_rgba4)
+
+EMIT3(insert_4f_viewport_4, insert_4ub_4f_rgba_4, insert_2f_2, emit_viewport4_rgba4_st2)
+EMIT3(insert_4f_viewport_4, insert_4ub_4f_bgra_4, insert_2f_2, emit_viewport4_bgra4_st2)
+EMIT3(insert_4f_4, insert_4ub_4f_rgba_4, insert_2f_2, emit_xyzw4_rgba4_st2)
+
+EMIT4(insert_4f_viewport_4, insert_4ub_4f_rgba_4, insert_2f_2, insert_2f_2, emit_viewport4_rgba4_st2_st2)
+EMIT4(insert_4f_viewport_4, insert_4ub_4f_bgra_4, insert_2f_2, insert_2f_2, emit_viewport4_bgra4_st2_st2)
+EMIT4(insert_4f_4, insert_4ub_4f_rgba_4, insert_2f_2, insert_2f_2, emit_xyzw4_rgba4_st2_st2)
+
+
+/* Use the codegen paths to select one of a number of hardwired
+ * fastpaths.
+ */
+void _tnl_generate_hardwired_emit( GLcontext *ctx )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ tnl_emit_func func = NULL;
+
+ /* Does it fit a hardwired fastpath? Help! this is growing out of
+ * control!
+ */
+ switch (vtx->attr_count) {
+ case 2:
+ if (vtx->attr[0].emit == insert_3f_viewport_3) {
+ if (vtx->attr[1].emit == insert_4ub_4f_bgra_4)
+ func = emit_viewport3_bgra4;
+ else if (vtx->attr[1].emit == insert_4ub_4f_rgba_4)
+ func = emit_viewport3_rgba4;
+ }
+ else if (vtx->attr[0].emit == insert_3f_3 &&
+ vtx->attr[1].emit == insert_4ub_4f_rgba_4) {
+ func = emit_xyz3_rgba4;
+ }
+ break;
+ case 3:
+ if (vtx->attr[2].emit == insert_2f_2) {
+ if (vtx->attr[1].emit == insert_4ub_4f_rgba_4) {
+ if (vtx->attr[0].emit == insert_4f_viewport_4)
+ func = emit_viewport4_rgba4_st2;
+ else if (vtx->attr[0].emit == insert_4f_4)
+ func = emit_xyzw4_rgba4_st2;
+ }
+ else if (vtx->attr[1].emit == insert_4ub_4f_bgra_4 &&
+ vtx->attr[0].emit == insert_4f_viewport_4)
+ func = emit_viewport4_bgra4_st2;
+ }
+ break;
+ case 4:
+ if (vtx->attr[2].emit == insert_2f_2 &&
+ vtx->attr[3].emit == insert_2f_2) {
+ if (vtx->attr[1].emit == insert_4ub_4f_rgba_4) {
+ if (vtx->attr[0].emit == insert_4f_viewport_4)
+ func = emit_viewport4_rgba4_st2_st2;
+ else if (vtx->attr[0].emit == insert_4f_4)
+ func = emit_xyzw4_rgba4_st2_st2;
+ }
+ else if (vtx->attr[1].emit == insert_4ub_4f_bgra_4 &&
+ vtx->attr[0].emit == insert_4f_viewport_4)
+ func = emit_viewport4_bgra4_st2_st2;
+ }
+ break;
+ }
+
+ vtx->emit = func;
+}
+
+/***********************************************************************
+ * Generic (non-codegen) functions for whole vertices or groups of
+ * vertices
+ */
+
+void _tnl_generic_emit( GLcontext *ctx,
+ GLuint count,
+ GLubyte *v )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ struct tnl_clipspace_attr *a = vtx->attr;
+ const GLuint attr_count = vtx->attr_count;
+ const GLuint stride = vtx->vertex_size;
+ GLuint i, j;
+
+ for (i = 0 ; i < count ; i++, v += stride) {
+ for (j = 0; j < attr_count; j++) {
+ GLfloat *in = (GLfloat *)a[j].inputptr;
+ a[j].inputptr += a[j].inputstride;
+ a[j].emit( &a[j], v + a[j].vertoffset, in );
+ }
+ }
+}
+
+
+void _tnl_generic_interp( GLcontext *ctx,
+ GLfloat t,
+ GLuint edst, GLuint eout, GLuint ein,
+ GLboolean force_boundary )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ const GLubyte *vin = vtx->vertex_buf + ein * vtx->vertex_size;
+ const GLubyte *vout = vtx->vertex_buf + eout * vtx->vertex_size;
+ GLubyte *vdst = vtx->vertex_buf + edst * vtx->vertex_size;
+ const struct tnl_clipspace_attr *a = vtx->attr;
+ const GLuint attr_count = vtx->attr_count;
+ GLuint j;
+ (void) force_boundary;
+
+ if (tnl->NeedNdcCoords) {
+ const GLfloat *dstclip = VB->ClipPtr->data[edst];
+ if (dstclip[3] != 0.0) {
+ const GLfloat w = 1.0f / dstclip[3];
+ GLfloat pos[4];
+
+ pos[0] = dstclip[0] * w;
+ pos[1] = dstclip[1] * w;
+ pos[2] = dstclip[2] * w;
+ pos[3] = w;
+
+ a[0].insert[4-1]( &a[0], vdst, pos );
+ }
+ }
+ else {
+ a[0].insert[4-1]( &a[0], vdst, VB->ClipPtr->data[edst] );
+ }
+
+
+ for (j = 1; j < attr_count; j++) {
+ GLfloat fin[4], fout[4], fdst[4];
+
+ a[j].extract( &a[j], fin, vin + a[j].vertoffset );
+ a[j].extract( &a[j], fout, vout + a[j].vertoffset );
+
+ INTERP_F( t, fdst[3], fout[3], fin[3] );
+ INTERP_F( t, fdst[2], fout[2], fin[2] );
+ INTERP_F( t, fdst[1], fout[1], fin[1] );
+ INTERP_F( t, fdst[0], fout[0], fin[0] );
+
+ a[j].insert[4-1]( &a[j], vdst + a[j].vertoffset, fdst );
+ }
+}
+
+
+/* Extract color attributes from one vertex and insert them into
+ * another. (Shortcircuit extract/insert with memcpy).
+ */
+void _tnl_generic_copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ GLubyte *vsrc = vtx->vertex_buf + esrc * vtx->vertex_size;
+ GLubyte *vdst = vtx->vertex_buf + edst * vtx->vertex_size;
+ const struct tnl_clipspace_attr *a = vtx->attr;
+ const GLuint attr_count = vtx->attr_count;
+ GLuint j;
+
+ for (j = 0; j < attr_count; j++) {
+ if (a[j].attrib == VERT_ATTRIB_COLOR0 ||
+ a[j].attrib == VERT_ATTRIB_COLOR1) {
+
+ _mesa_memcpy( vdst + a[j].vertoffset,
+ vsrc + a[j].vertoffset,
+ a[j].vertattrsize );
+ }
+ }
+}
+
+
+/* Helper functions for hardware which doesn't put back colors and/or
+ * edgeflags into vertices.
+ */
+void _tnl_generic_interp_extras( GLcontext *ctx,
+ GLfloat t,
+ GLuint dst, GLuint out, GLuint in,
+ GLboolean force_boundary )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ /* If stride is zero, ColorPtr[1] is constant across the VB, so
+ * there is no point interpolating between two values as they will
+ * be identical. In all other cases, this value is generated by
+ * t_vb_lighttmp.h and has a stride of 4 dwords.
+ */
+ if (VB->ColorPtr[1] && VB->ColorPtr[1]->stride) {
+ assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat));
+
+ INTERP_4F( t,
+ VB->ColorPtr[1]->data[dst],
+ VB->ColorPtr[1]->data[out],
+ VB->ColorPtr[1]->data[in] );
+ }
+
+ if (VB->SecondaryColorPtr[1]) {
+ assert(VB->SecondaryColorPtr[1]->stride == 4 * sizeof(GLfloat));
+
+ INTERP_3F( t,
+ VB->SecondaryColorPtr[1]->data[dst],
+ VB->SecondaryColorPtr[1]->data[out],
+ VB->SecondaryColorPtr[1]->data[in] );
+ }
+
+ if (VB->IndexPtr[1]) {
+ VB->IndexPtr[1]->data[dst][0] = LINTERP( t,
+ VB->IndexPtr[1]->data[out][0],
+ VB->IndexPtr[1]->data[in][0] );
+ }
+
+ if (VB->EdgeFlag) {
+ VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
+ }
+
+ _tnl_generic_interp(ctx, t, dst, out, in, force_boundary);
+}
+
+void _tnl_generic_copy_pv_extras( GLcontext *ctx,
+ GLuint dst, GLuint src )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ /* See above comment:
+ */
+ if (VB->ColorPtr[1] && VB->ColorPtr[1]->stride) {
+ COPY_4FV( VB->ColorPtr[1]->data[dst],
+ VB->ColorPtr[1]->data[src] );
+ }
+
+ if (VB->SecondaryColorPtr[1]) {
+ COPY_4FV( VB->SecondaryColorPtr[1]->data[dst],
+ VB->SecondaryColorPtr[1]->data[src] );
+ }
+
+ if (VB->IndexPtr[1]) {
+ VB->IndexPtr[1]->data[dst][0] = VB->IndexPtr[1]->data[src][0];
+ }
+
+ _tnl_generic_copy_pv(ctx, dst, src);
+}
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex_sse.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex_sse.c
new file mode 100644
index 000000000..13dc2f4d5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vertex_sse.c
@@ -0,0 +1,670 @@
+/*
+ * Copyright 2003 Tungsten Graphics, inc.
+ * 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
+ * TUNGSTEN GRAPHICS 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:
+ * Keith Whitwell <keithw@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "colormac.h"
+#include "t_context.h"
+#include "t_vertex.h"
+#include "simple_list.h"
+#include "enums.h"
+
+#if defined(USE_SSE_ASM)
+
+#include "x86/rtasm/x86sse.h"
+#include "x86/common_x86_asm.h"
+
+
+#define X 0
+#define Y 1
+#define Z 2
+#define W 3
+
+
+struct x86_program {
+ struct x86_function func;
+
+ GLcontext *ctx;
+ GLboolean inputs_safe;
+ GLboolean outputs_safe;
+ GLboolean have_sse2;
+
+ struct x86_reg identity;
+ struct x86_reg chan0;
+};
+
+
+static struct x86_reg get_identity( struct x86_program *p )
+{
+ return p->identity;
+}
+
+static void emit_load4f_4( struct x86_program *p,
+ struct x86_reg dest,
+ struct x86_reg arg0 )
+{
+ sse_movups(&p->func, dest, arg0);
+}
+
+static void emit_load4f_3( struct x86_program *p,
+ struct x86_reg dest,
+ struct x86_reg arg0 )
+{
+ /* Have to jump through some hoops:
+ *
+ * c 0 0 0
+ * c 0 0 1
+ * 0 0 c 1
+ * a b c 1
+ */
+ sse_movss(&p->func, dest, x86_make_disp(arg0, 8));
+ sse_shufps(&p->func, dest, get_identity(p), SHUF(X,Y,Z,W) );
+ sse_shufps(&p->func, dest, dest, SHUF(Y,Z,X,W) );
+ sse_movlps(&p->func, dest, arg0);
+}
+
+static void emit_load4f_2( struct x86_program *p,
+ struct x86_reg dest,
+ struct x86_reg arg0 )
+{
+ /* Initialize from identity, then pull in low two words:
+ */
+ sse_movups(&p->func, dest, get_identity(p));
+ sse_movlps(&p->func, dest, arg0);
+}
+
+static void emit_load4f_1( struct x86_program *p,
+ struct x86_reg dest,
+ struct x86_reg arg0 )
+{
+ /* Pull in low word, then swizzle in identity */
+ sse_movss(&p->func, dest, arg0);
+ sse_shufps(&p->func, dest, get_identity(p), SHUF(X,Y,Z,W) );
+}
+
+
+
+static void emit_load3f_3( struct x86_program *p,
+ struct x86_reg dest,
+ struct x86_reg arg0 )
+{
+ /* Over-reads by 1 dword - potential SEGV if input is a vertex
+ * array.
+ */
+ if (p->inputs_safe) {
+ sse_movups(&p->func, dest, arg0);
+ }
+ else {
+ /* c 0 0 0
+ * c c c c
+ * a b c c
+ */
+ sse_movss(&p->func, dest, x86_make_disp(arg0, 8));
+ sse_shufps(&p->func, dest, dest, SHUF(X,X,X,X));
+ sse_movlps(&p->func, dest, arg0);
+ }
+}
+
+static void emit_load3f_2( struct x86_program *p,
+ struct x86_reg dest,
+ struct x86_reg arg0 )
+{
+ emit_load4f_2(p, dest, arg0);
+}
+
+static void emit_load3f_1( struct x86_program *p,
+ struct x86_reg dest,
+ struct x86_reg arg0 )
+{
+ emit_load4f_1(p, dest, arg0);
+}
+
+static void emit_load2f_2( struct x86_program *p,
+ struct x86_reg dest,
+ struct x86_reg arg0 )
+{
+ sse_movlps(&p->func, dest, arg0);
+}
+
+static void emit_load2f_1( struct x86_program *p,
+ struct x86_reg dest,
+ struct x86_reg arg0 )
+{
+ emit_load4f_1(p, dest, arg0);
+}
+
+static void emit_load1f_1( struct x86_program *p,
+ struct x86_reg dest,
+ struct x86_reg arg0 )
+{
+ sse_movss(&p->func, dest, arg0);
+}
+
+static void (*load[4][4])( struct x86_program *p,
+ struct x86_reg dest,
+ struct x86_reg arg0 ) = {
+ { emit_load1f_1,
+ emit_load1f_1,
+ emit_load1f_1,
+ emit_load1f_1 },
+
+ { emit_load2f_1,
+ emit_load2f_2,
+ emit_load2f_2,
+ emit_load2f_2 },
+
+ { emit_load3f_1,
+ emit_load3f_2,
+ emit_load3f_3,
+ emit_load3f_3 },
+
+ { emit_load4f_1,
+ emit_load4f_2,
+ emit_load4f_3,
+ emit_load4f_4 }
+};
+
+static void emit_load( struct x86_program *p,
+ struct x86_reg dest,
+ GLuint sz,
+ struct x86_reg src,
+ GLuint src_sz)
+{
+ load[sz-1][src_sz-1](p, dest, src);
+}
+
+static void emit_store4f( struct x86_program *p,
+ struct x86_reg dest,
+ struct x86_reg arg0 )
+{
+ sse_movups(&p->func, dest, arg0);
+}
+
+static void emit_store3f( struct x86_program *p,
+ struct x86_reg dest,
+ struct x86_reg arg0 )
+{
+ if (p->outputs_safe) {
+ /* Emit the extra dword anyway. This may hurt writecombining,
+ * may cause other problems.
+ */
+ sse_movups(&p->func, dest, arg0);
+ }
+ else {
+ /* Alternate strategy - emit two, shuffle, emit one.
+ */
+ sse_movlps(&p->func, dest, arg0);
+ sse_shufps(&p->func, arg0, arg0, SHUF(Z,Z,Z,Z) ); /* NOTE! destructive */
+ sse_movss(&p->func, x86_make_disp(dest,8), arg0);
+ }
+}
+
+static void emit_store2f( struct x86_program *p,
+ struct x86_reg dest,
+ struct x86_reg arg0 )
+{
+ sse_movlps(&p->func, dest, arg0);
+}
+
+static void emit_store1f( struct x86_program *p,
+ struct x86_reg dest,
+ struct x86_reg arg0 )
+{
+ sse_movss(&p->func, dest, arg0);
+}
+
+
+static void (*store[4])( struct x86_program *p,
+ struct x86_reg dest,
+ struct x86_reg arg0 ) =
+{
+ emit_store1f,
+ emit_store2f,
+ emit_store3f,
+ emit_store4f
+};
+
+static void emit_store( struct x86_program *p,
+ struct x86_reg dest,
+ GLuint sz,
+ struct x86_reg temp )
+
+{
+ store[sz-1](p, dest, temp);
+}
+
+static void emit_pack_store_4ub( struct x86_program *p,
+ struct x86_reg dest,
+ struct x86_reg temp )
+{
+ /* Scale by 255.0
+ */
+ sse_mulps(&p->func, temp, p->chan0);
+
+ if (p->have_sse2) {
+ sse2_cvtps2dq(&p->func, temp, temp);
+ sse2_packssdw(&p->func, temp, temp);
+ sse2_packuswb(&p->func, temp, temp);
+ sse_movss(&p->func, dest, temp);
+ }
+ else {
+ struct x86_reg mmx0 = x86_make_reg(file_MMX, 0);
+ struct x86_reg mmx1 = x86_make_reg(file_MMX, 1);
+ sse_cvtps2pi(&p->func, mmx0, temp);
+ sse_movhlps(&p->func, temp, temp);
+ sse_cvtps2pi(&p->func, mmx1, temp);
+ mmx_packssdw(&p->func, mmx0, mmx1);
+ mmx_packuswb(&p->func, mmx0, mmx0);
+ mmx_movd(&p->func, dest, mmx0);
+ }
+}
+
+static GLint get_offset( const void *a, const void *b )
+{
+ return (const char *)b - (const char *)a;
+}
+
+/* Not much happens here. Eventually use this function to try and
+ * avoid saving/reloading the source pointers each vertex (if some of
+ * them can fit in registers).
+ */
+static void get_src_ptr( struct x86_program *p,
+ struct x86_reg srcREG,
+ struct x86_reg vtxREG,
+ struct tnl_clipspace_attr *a )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(p->ctx);
+ struct x86_reg ptr_to_src = x86_make_disp(vtxREG, get_offset(vtx, &a->inputptr));
+
+ /* Load current a[j].inputptr
+ */
+ x86_mov(&p->func, srcREG, ptr_to_src);
+}
+
+static void update_src_ptr( struct x86_program *p,
+ struct x86_reg srcREG,
+ struct x86_reg vtxREG,
+ struct tnl_clipspace_attr *a )
+{
+ if (a->inputstride) {
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(p->ctx);
+ struct x86_reg ptr_to_src = x86_make_disp(vtxREG, get_offset(vtx, &a->inputptr));
+
+ /* add a[j].inputstride (hardcoded value - could just as easily
+ * pull the stride value from memory each time).
+ */
+ x86_lea(&p->func, srcREG, x86_make_disp(srcREG, a->inputstride));
+
+ /* save new value of a[j].inputptr
+ */
+ x86_mov(&p->func, ptr_to_src, srcREG);
+ }
+}
+
+
+/* Lots of hardcoding
+ *
+ * EAX -- pointer to current output vertex
+ * ECX -- pointer to current attribute
+ *
+ */
+static GLboolean build_vertex_emit( struct x86_program *p )
+{
+ GLcontext *ctx = p->ctx;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ GLuint j = 0;
+
+ struct x86_reg vertexEAX = x86_make_reg(file_REG32, reg_AX);
+ struct x86_reg srcECX = x86_make_reg(file_REG32, reg_CX);
+ struct x86_reg countEBP = x86_make_reg(file_REG32, reg_BP);
+ struct x86_reg vtxESI = x86_make_reg(file_REG32, reg_SI);
+ struct x86_reg temp = x86_make_reg(file_XMM, 0);
+ struct x86_reg vp0 = x86_make_reg(file_XMM, 1);
+ struct x86_reg vp1 = x86_make_reg(file_XMM, 2);
+ GLubyte *fixup, *label;
+
+ x86_init_func(&p->func);
+
+ /* Push a few regs?
+ */
+ x86_push(&p->func, countEBP);
+ x86_push(&p->func, vtxESI);
+
+
+ /* Get vertex count, compare to zero
+ */
+ x86_xor(&p->func, srcECX, srcECX);
+ x86_mov(&p->func, countEBP, x86_fn_arg(&p->func, 2));
+ x86_cmp(&p->func, countEBP, srcECX);
+ fixup = x86_jcc_forward(&p->func, cc_E);
+
+ /* Initialize destination register.
+ */
+ x86_mov(&p->func, vertexEAX, x86_fn_arg(&p->func, 3));
+
+ /* Dereference ctx to get tnl, then vtx:
+ */
+ x86_mov(&p->func, vtxESI, x86_fn_arg(&p->func, 1));
+ x86_mov(&p->func, vtxESI, x86_make_disp(vtxESI, get_offset(ctx, &ctx->swtnl_context)));
+ vtxESI = x86_make_disp(vtxESI, get_offset(tnl, &tnl->clipspace));
+
+
+ /* Possibly load vp0, vp1 for viewport calcs:
+ */
+ if (vtx->need_viewport) {
+ sse_movups(&p->func, vp0, x86_make_disp(vtxESI, get_offset(vtx, &vtx->vp_scale[0])));
+ sse_movups(&p->func, vp1, x86_make_disp(vtxESI, get_offset(vtx, &vtx->vp_xlate[0])));
+ }
+
+ /* always load, needed or not:
+ */
+ sse_movups(&p->func, p->chan0, x86_make_disp(vtxESI, get_offset(vtx, &vtx->chan_scale[0])));
+ sse_movups(&p->func, p->identity, x86_make_disp(vtxESI, get_offset(vtx, &vtx->identity[0])));
+
+ /* Note address for loop jump */
+ label = x86_get_label(&p->func);
+
+ /* Emit code for each of the attributes. Currently routes
+ * everything through SSE registers, even when it might be more
+ * efficient to stick with regular old x86. No optimization or
+ * other tricks - enough new ground to cover here just getting
+ * things working.
+ */
+ while (j < vtx->attr_count) {
+ struct tnl_clipspace_attr *a = &vtx->attr[j];
+ struct x86_reg dest = x86_make_disp(vertexEAX, a->vertoffset);
+
+ /* Now, load an XMM reg from src, perhaps transform, then save.
+ * Could be shortcircuited in specific cases:
+ */
+ switch (a->format) {
+ case EMIT_1F:
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 1, x86_deref(srcECX), a->inputsize);
+ emit_store(p, dest, 1, temp);
+ update_src_ptr(p, srcECX, vtxESI, a);
+ break;
+ case EMIT_2F:
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 2, x86_deref(srcECX), a->inputsize);
+ emit_store(p, dest, 2, temp);
+ update_src_ptr(p, srcECX, vtxESI, a);
+ break;
+ case EMIT_3F:
+ /* Potentially the worst case - hardcode 2+1 copying:
+ */
+ if (0) {
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize);
+ emit_store(p, dest, 3, temp);
+ update_src_ptr(p, srcECX, vtxESI, a);
+ }
+ else {
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 2, x86_deref(srcECX), a->inputsize);
+ emit_store(p, dest, 2, temp);
+ if (a->inputsize > 2) {
+ emit_load(p, temp, 1, x86_make_disp(srcECX, 8), 1);
+ emit_store(p, x86_make_disp(dest,8), 1, temp);
+ }
+ else {
+ sse_movss(&p->func, x86_make_disp(dest,8), get_identity(p));
+ }
+ update_src_ptr(p, srcECX, vtxESI, a);
+ }
+ break;
+ case EMIT_4F:
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
+ emit_store(p, dest, 4, temp);
+ update_src_ptr(p, srcECX, vtxESI, a);
+ break;
+ case EMIT_2F_VIEWPORT:
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 2, x86_deref(srcECX), a->inputsize);
+ sse_mulps(&p->func, temp, vp0);
+ sse_addps(&p->func, temp, vp1);
+ emit_store(p, dest, 2, temp);
+ update_src_ptr(p, srcECX, vtxESI, a);
+ break;
+ case EMIT_3F_VIEWPORT:
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize);
+ sse_mulps(&p->func, temp, vp0);
+ sse_addps(&p->func, temp, vp1);
+ emit_store(p, dest, 3, temp);
+ update_src_ptr(p, srcECX, vtxESI, a);
+ break;
+ case EMIT_4F_VIEWPORT:
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
+ sse_mulps(&p->func, temp, vp0);
+ sse_addps(&p->func, temp, vp1);
+ emit_store(p, dest, 4, temp);
+ update_src_ptr(p, srcECX, vtxESI, a);
+ break;
+ case EMIT_3F_XYW:
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
+ sse_shufps(&p->func, temp, temp, SHUF(X,Y,W,Z));
+ emit_store(p, dest, 3, temp);
+ update_src_ptr(p, srcECX, vtxESI, a);
+ break;
+
+ case EMIT_1UB_1F:
+ /* Test for PAD3 + 1UB:
+ */
+ if (j > 0 &&
+ a[-1].vertoffset + a[-1].vertattrsize <= a->vertoffset - 3)
+ {
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 1, x86_deref(srcECX), a->inputsize);
+ sse_shufps(&p->func, temp, temp, SHUF(X,X,X,X));
+ emit_pack_store_4ub(p, x86_make_disp(dest, -3), temp); /* overkill! */
+ update_src_ptr(p, srcECX, vtxESI, a);
+ }
+ else {
+ _mesa_printf("Can't emit 1ub %x %x %d\n", a->vertoffset, a[-1].vertoffset, a[-1].vertattrsize );
+ return GL_FALSE;
+ }
+ break;
+ case EMIT_3UB_3F_RGB:
+ case EMIT_3UB_3F_BGR:
+ /* Test for 3UB + PAD1:
+ */
+ if (j == vtx->attr_count - 1 ||
+ a[1].vertoffset >= a->vertoffset + 4) {
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize);
+ if (a->format == EMIT_3UB_3F_BGR)
+ sse_shufps(&p->func, temp, temp, SHUF(Z,Y,X,W));
+ emit_pack_store_4ub(p, dest, temp);
+ update_src_ptr(p, srcECX, vtxESI, a);
+ }
+ /* Test for 3UB + 1UB:
+ */
+ else if (j < vtx->attr_count - 1 &&
+ a[1].format == EMIT_1UB_1F &&
+ a[1].vertoffset == a->vertoffset + 3) {
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 3, x86_deref(srcECX), a->inputsize);
+ update_src_ptr(p, srcECX, vtxESI, a);
+
+ /* Make room for incoming value:
+ */
+ sse_shufps(&p->func, temp, temp, SHUF(W,X,Y,Z));
+
+ get_src_ptr(p, srcECX, vtxESI, &a[1]);
+ emit_load(p, temp, 1, x86_deref(srcECX), a[1].inputsize);
+ update_src_ptr(p, srcECX, vtxESI, &a[1]);
+
+ /* Rearrange and possibly do BGR conversion:
+ */
+ if (a->format == EMIT_3UB_3F_BGR)
+ sse_shufps(&p->func, temp, temp, SHUF(W,Z,Y,X));
+ else
+ sse_shufps(&p->func, temp, temp, SHUF(Y,Z,W,X));
+
+ emit_pack_store_4ub(p, dest, temp);
+ j++; /* NOTE: two attrs consumed */
+ }
+ else {
+ _mesa_printf("Can't emit 3ub\n");
+ }
+ return GL_FALSE; /* add this later */
+ break;
+
+ case EMIT_4UB_4F_RGBA:
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
+ emit_pack_store_4ub(p, dest, temp);
+ update_src_ptr(p, srcECX, vtxESI, a);
+ break;
+ case EMIT_4UB_4F_BGRA:
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
+ sse_shufps(&p->func, temp, temp, SHUF(Z,Y,X,W));
+ emit_pack_store_4ub(p, dest, temp);
+ update_src_ptr(p, srcECX, vtxESI, a);
+ break;
+ case EMIT_4UB_4F_ARGB:
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
+ sse_shufps(&p->func, temp, temp, SHUF(W,X,Y,Z));
+ emit_pack_store_4ub(p, dest, temp);
+ update_src_ptr(p, srcECX, vtxESI, a);
+ break;
+ case EMIT_4UB_4F_ABGR:
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
+ sse_shufps(&p->func, temp, temp, SHUF(W,Z,Y,X));
+ emit_pack_store_4ub(p, dest, temp);
+ update_src_ptr(p, srcECX, vtxESI, a);
+ break;
+ case EMIT_4CHAN_4F_RGBA:
+ switch (CHAN_TYPE) {
+ case GL_UNSIGNED_BYTE:
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
+ emit_pack_store_4ub(p, dest, temp);
+ update_src_ptr(p, srcECX, vtxESI, a);
+ break;
+ case GL_FLOAT:
+ get_src_ptr(p, srcECX, vtxESI, a);
+ emit_load(p, temp, 4, x86_deref(srcECX), a->inputsize);
+ emit_store(p, dest, 4, temp);
+ update_src_ptr(p, srcECX, vtxESI, a);
+ break;
+ case GL_UNSIGNED_SHORT:
+ default:
+ _mesa_printf("unknown CHAN_TYPE %s\n", _mesa_lookup_enum_by_nr(CHAN_TYPE));
+ return GL_FALSE;
+ }
+ break;
+ default:
+ _mesa_printf("unknown a[%d].format %d\n", j, a->format);
+ return GL_FALSE; /* catch any new opcodes */
+ }
+
+ /* Increment j by at least 1 - may have been incremented above also:
+ */
+ j++;
+ }
+
+ /* Next vertex:
+ */
+ x86_lea(&p->func, vertexEAX, x86_make_disp(vertexEAX, vtx->vertex_size));
+
+ /* decr count, loop if not zero
+ */
+ x86_dec(&p->func, countEBP);
+ x86_test(&p->func, countEBP, countEBP);
+ x86_jcc(&p->func, cc_NZ, label);
+
+ /* Exit mmx state?
+ */
+ if (p->func.need_emms)
+ mmx_emms(&p->func);
+
+ /* Land forward jump here:
+ */
+ x86_fixup_fwd_jump(&p->func, fixup);
+
+ /* Pop regs and return
+ */
+ x86_pop(&p->func, x86_get_base_reg(vtxESI));
+ x86_pop(&p->func, countEBP);
+ x86_ret(&p->func);
+
+ vtx->emit = (tnl_emit_func)x86_get_func(&p->func);
+ return GL_TRUE;
+}
+
+
+
+void _tnl_generate_sse_emit( GLcontext *ctx )
+{
+ struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
+ struct x86_program p;
+
+ if (!cpu_has_xmm) {
+ vtx->codegen_emit = NULL;
+ return;
+ }
+
+ memset(&p, 0, sizeof(p));
+
+ p.ctx = ctx;
+ p.inputs_safe = 0; /* for now */
+ p.outputs_safe = 1; /* for now */
+ p.have_sse2 = cpu_has_xmm2;
+ p.identity = x86_make_reg(file_XMM, 6);
+ p.chan0 = x86_make_reg(file_XMM, 7);
+
+ x86_init_func(&p.func);
+
+ if (build_vertex_emit(&p)) {
+ _tnl_register_fastpath( vtx, GL_TRUE );
+ }
+ else {
+ /* Note the failure so that we don't keep trying to codegen an
+ * impossible state:
+ */
+ _tnl_register_fastpath( vtx, GL_FALSE );
+ x86_release_func(&p.func);
+ }
+}
+
+#else
+
+void _tnl_generate_sse_emit( GLcontext *ctx )
+{
+ /* Dummy version for when USE_SSE_ASM not defined */
+}
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vp_build.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vp_build.c
new file mode 100644
index 000000000..e62c5b374
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vp_build.c
@@ -0,0 +1,1497 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3.1
+ *
+ * Copyright (C) 2005 Tungsten Graphics 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
+ * TUNGSTEN GRAPHICS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file t_vp_build.c
+ * Create a vertex program to execute the current fixed function T&L pipeline.
+ * \author Keith Whitwell
+ */
+
+
+#include "glheader.h"
+#include "macros.h"
+#include "enums.h"
+#include "t_context.h"
+#include "t_vp_build.h"
+
+#include "shader/program.h"
+#include "shader/nvvertprog.h"
+#include "shader/arbvertparse.h"
+
+struct state_key {
+ unsigned light_global_enabled:1;
+ unsigned light_local_viewer:1;
+ unsigned light_twoside:1;
+ unsigned light_color_material:1;
+ unsigned light_color_material_mask:12;
+ unsigned light_material_mask:12;
+
+ unsigned normalize:1;
+ unsigned rescale_normals:1;
+ unsigned fog_source_is_depth:1;
+ unsigned tnl_do_vertex_fog:1;
+ unsigned separate_specular:1;
+ unsigned fog_enabled:1;
+ unsigned fog_mode:2;
+ unsigned point_attenuated:1;
+ unsigned texture_enabled_global:1;
+
+ struct {
+ unsigned light_enabled:1;
+ unsigned light_eyepos3_is_zero:1;
+ unsigned light_spotcutoff_is_180:1;
+ unsigned light_attenuated:1;
+ unsigned texunit_really_enabled:1;
+ unsigned texmat_enabled:1;
+ unsigned texgen_enabled:4;
+ unsigned texgen_mode0:4;
+ unsigned texgen_mode1:4;
+ unsigned texgen_mode2:4;
+ unsigned texgen_mode3:4;
+ } unit[8];
+};
+
+
+
+#define FOG_LINEAR 0
+#define FOG_EXP 1
+#define FOG_EXP2 2
+#define FOG_UNKNOWN 3
+
+static GLuint translate_fog_mode( GLenum mode )
+{
+ switch (mode) {
+ case GL_LINEAR: return FOG_LINEAR;
+ case GL_EXP: return FOG_EXP;
+ case GL_EXP2: return FOG_EXP2;
+ default: return FOG_UNKNOWN;
+ }
+}
+
+#define TXG_NONE 0
+#define TXG_OBJ_LINEAR 1
+#define TXG_EYE_LINEAR 2
+#define TXG_SPHERE_MAP 3
+#define TXG_REFLECTION_MAP 4
+#define TXG_NORMAL_MAP 5
+
+static GLuint translate_texgen( GLboolean enabled, GLenum mode )
+{
+ if (!enabled)
+ return TXG_NONE;
+
+ switch (mode) {
+ case GL_OBJECT_LINEAR: return TXG_OBJ_LINEAR;
+ case GL_EYE_LINEAR: return TXG_EYE_LINEAR;
+ case GL_SPHERE_MAP: return TXG_SPHERE_MAP;
+ case GL_REFLECTION_MAP_NV: return TXG_REFLECTION_MAP;
+ case GL_NORMAL_MAP_NV: return TXG_NORMAL_MAP;
+ default: return TXG_NONE;
+ }
+}
+
+static struct state_key *make_state_key( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ struct state_key *key = CALLOC_STRUCT(state_key);
+ GLuint i;
+
+ key->separate_specular = (ctx->Light.Model.ColorControl ==
+ GL_SEPARATE_SPECULAR_COLOR);
+
+ if (ctx->Light.Enabled) {
+ key->light_global_enabled = 1;
+
+ if (ctx->Light.Model.LocalViewer)
+ key->light_local_viewer = 1;
+
+ if (ctx->Light.Model.TwoSide)
+ key->light_twoside = 1;
+
+ if (ctx->Light.ColorMaterialEnabled) {
+ key->light_color_material = 1;
+ key->light_color_material_mask = ctx->Light.ColorMaterialBitmask;
+ }
+
+ for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT ; i < _TNL_ATTRIB_INDEX ; i++)
+ if (VB->AttribPtr[i]->stride)
+ key->light_material_mask |= 1<<(i-_TNL_ATTRIB_MAT_FRONT_AMBIENT);
+
+ for (i = 0; i < MAX_LIGHTS; i++) {
+ struct gl_light *light = &ctx->Light.Light[i];
+
+ if (light->Enabled) {
+ key->unit[i].light_enabled = 1;
+
+ if (light->EyePosition[3] == 0.0)
+ key->unit[i].light_eyepos3_is_zero = 1;
+
+ if (light->SpotCutoff == 180.0)
+ key->unit[i].light_spotcutoff_is_180 = 1;
+
+ if (light->ConstantAttenuation != 1.0 ||
+ light->LinearAttenuation != 0.0 ||
+ light->QuadraticAttenuation != 0.0)
+ key->unit[i].light_attenuated = 1;
+ }
+ }
+ }
+
+ if (ctx->Transform.Normalize)
+ key->normalize = 1;
+
+ if (ctx->Transform.RescaleNormals)
+ key->rescale_normals = 1;
+
+ if (ctx->Fog.Enabled)
+ key->fog_enabled = 1;
+
+ if (key->fog_enabled) {
+ if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT)
+ key->fog_source_is_depth = 1;
+
+ if (tnl->_DoVertexFog)
+ key->tnl_do_vertex_fog = 1;
+
+ key->fog_mode = translate_fog_mode(ctx->Fog.Mode);
+ }
+
+ if (ctx->Point._Attenuated)
+ key->point_attenuated = 1;
+
+ if (ctx->Texture._TexGenEnabled ||
+ ctx->Texture._TexMatEnabled ||
+ ctx->Texture._EnabledUnits)
+ key->texture_enabled_global = 1;
+
+ for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
+
+ if (texUnit->_ReallyEnabled)
+ key->unit[i].texunit_really_enabled = 1;
+
+ if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i))
+ key->unit[i].texmat_enabled = 1;
+
+ if (texUnit->TexGenEnabled) {
+ key->unit[i].texgen_enabled = 1;
+
+ key->unit[i].texgen_mode0 =
+ translate_texgen( texUnit->TexGenEnabled & (1<<0),
+ texUnit->GenModeS );
+ key->unit[i].texgen_mode1 =
+ translate_texgen( texUnit->TexGenEnabled & (1<<1),
+ texUnit->GenModeT );
+ key->unit[i].texgen_mode2 =
+ translate_texgen( texUnit->TexGenEnabled & (1<<2),
+ texUnit->GenModeR );
+ key->unit[i].texgen_mode3 =
+ translate_texgen( texUnit->TexGenEnabled & (1<<3),
+ texUnit->GenModeQ );
+ }
+ }
+
+ return key;
+}
+
+
+
+/* Very useful debugging tool - produces annotated listing of
+ * generated program with line/function references for each
+ * instruction back into this file:
+ */
+#define DISASSEM (MESA_VERBOSE&VERBOSE_DISASSEM)
+
+/* Should be tunable by the driver - do we want to do matrix
+ * multiplications with DP4's or with MUL/MAD's? SSE works better
+ * with the latter, drivers may differ.
+ */
+#define PREFER_DP4 0
+
+#define MAX_INSN 200
+
+/* Use uregs to represent registers internally, translate to Mesa's
+ * expected formats on emit.
+ *
+ * NOTE: These are passed by value extensively in this file rather
+ * than as usual by pointer reference. If this disturbs you, try
+ * remembering they are just 32bits in size.
+ *
+ * GCC is smart enough to deal with these dword-sized structures in
+ * much the same way as if I had defined them as dwords and was using
+ * macros to access and set the fields. This is much nicer and easier
+ * to evolve.
+ */
+struct ureg {
+ GLuint file:4;
+ GLint idx:8; /* relative addressing may be negative */
+ GLuint negate:1;
+ GLuint swz:12;
+ GLuint pad:7;
+};
+
+
+struct tnl_program {
+ const struct state_key *state;
+ struct vertex_program *program;
+
+ GLuint temp_in_use;
+ GLuint temp_reserved;
+
+ struct ureg eye_position;
+ struct ureg eye_position_normalized;
+ struct ureg eye_normal;
+ struct ureg identity;
+
+ GLuint materials;
+ GLuint color_materials;
+};
+
+
+const static struct ureg undef = {
+ ~0,
+ ~0,
+ 0,
+ 0,
+ 0
+};
+
+/* Local shorthand:
+ */
+#define X SWIZZLE_X
+#define Y SWIZZLE_Y
+#define Z SWIZZLE_Z
+#define W SWIZZLE_W
+
+
+/* Construct a ureg:
+ */
+static struct ureg make_ureg(GLuint file, GLint idx)
+{
+ struct ureg reg;
+ reg.file = file;
+ reg.idx = idx;
+ reg.negate = 0;
+ reg.swz = SWIZZLE_NOOP;
+ reg.pad = 0;
+ return reg;
+}
+
+
+
+static struct ureg negate( struct ureg reg )
+{
+ reg.negate ^= 1;
+ return reg;
+}
+
+
+static struct ureg swizzle( struct ureg reg, int x, int y, int z, int w )
+{
+ reg.swz = MAKE_SWIZZLE4(GET_SWZ(reg.swz, x),
+ GET_SWZ(reg.swz, y),
+ GET_SWZ(reg.swz, z),
+ GET_SWZ(reg.swz, w));
+
+ return reg;
+}
+
+static struct ureg swizzle1( struct ureg reg, int x )
+{
+ return swizzle(reg, x, x, x, x);
+}
+
+static struct ureg get_temp( struct tnl_program *p )
+{
+ int bit = ffs( ~p->temp_in_use );
+ if (!bit) {
+ fprintf(stderr, "%s: out of temporaries\n", __FILE__);
+ exit(1);
+ }
+
+ p->temp_in_use |= 1<<(bit-1);
+ return make_ureg(PROGRAM_TEMPORARY, bit-1);
+}
+
+static struct ureg reserve_temp( struct tnl_program *p )
+{
+ struct ureg temp = get_temp( p );
+ p->temp_reserved |= 1<<temp.idx;
+ return temp;
+}
+
+static void release_temp( struct tnl_program *p, struct ureg reg )
+{
+ if (reg.file == PROGRAM_TEMPORARY) {
+ p->temp_in_use &= ~(1<<reg.idx);
+ p->temp_in_use |= p->temp_reserved; /* can't release reserved temps */
+ }
+}
+
+static void release_temps( struct tnl_program *p )
+{
+ p->temp_in_use = p->temp_reserved;
+}
+
+
+
+static struct ureg register_input( struct tnl_program *p, GLuint input )
+{
+ p->program->InputsRead |= (1<<input);
+ return make_ureg(PROGRAM_INPUT, input);
+}
+
+static struct ureg register_output( struct tnl_program *p, GLuint output )
+{
+ p->program->OutputsWritten |= (1<<output);
+ return make_ureg(PROGRAM_OUTPUT, output);
+}
+
+static struct ureg register_const4f( struct tnl_program *p,
+ GLfloat s0,
+ GLfloat s1,
+ GLfloat s2,
+ GLfloat s3)
+{
+ GLfloat values[4];
+ GLint idx;
+ values[0] = s0;
+ values[1] = s1;
+ values[2] = s2;
+ values[3] = s3;
+ idx = _mesa_add_unnamed_constant( p->program->Parameters, values );
+ return make_ureg(PROGRAM_STATE_VAR, idx);
+}
+
+#define register_const1f(p, s0) register_const4f(p, s0, 0, 0, 1)
+#define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0)
+#define register_const2f(p, s0, s1) register_const4f(p, s0, s1, 0, 1)
+#define register_const3f(p, s0, s1, s2) register_const4f(p, s0, s1, s2, 1)
+
+static GLboolean is_undef( struct ureg reg )
+{
+ return reg.file == 0xf;
+}
+
+static struct ureg get_identity_param( struct tnl_program *p )
+{
+ if (is_undef(p->identity))
+ p->identity = register_const4f(p, 0,0,0,1);
+
+ return p->identity;
+}
+
+static struct ureg register_param6( struct tnl_program *p,
+ GLint s0,
+ GLint s1,
+ GLint s2,
+ GLint s3,
+ GLint s4,
+ GLint s5)
+{
+ GLint tokens[6];
+ GLint idx;
+ tokens[0] = s0;
+ tokens[1] = s1;
+ tokens[2] = s2;
+ tokens[3] = s3;
+ tokens[4] = s4;
+ tokens[5] = s5;
+ idx = _mesa_add_state_reference( p->program->Parameters, tokens );
+ return make_ureg(PROGRAM_STATE_VAR, idx);
+}
+
+
+#define register_param1(p,s0) register_param6(p,s0,0,0,0,0,0)
+#define register_param2(p,s0,s1) register_param6(p,s0,s1,0,0,0,0)
+#define register_param3(p,s0,s1,s2) register_param6(p,s0,s1,s2,0,0,0)
+#define register_param4(p,s0,s1,s2,s3) register_param6(p,s0,s1,s2,s3,0,0)
+
+
+static void register_matrix_param6( struct tnl_program *p,
+ GLint s0,
+ GLint s1,
+ GLint s2,
+ GLint s3,
+ GLint s4,
+ GLint s5,
+ struct ureg *matrix )
+{
+ GLuint i;
+
+ /* This is a bit sad as the support is there to pull the whole
+ * matrix out in one go:
+ */
+ for (i = 0; i <= s4 - s3; i++)
+ matrix[i] = register_param6( p, s0, s1, s2, i, i, s5 );
+}
+
+
+static void emit_arg( struct vp_src_register *src,
+ struct ureg reg )
+{
+ src->File = reg.file;
+ src->Index = reg.idx;
+ src->Swizzle = reg.swz;
+ src->Negate = reg.negate;
+ src->RelAddr = 0;
+ src->pad = 0;
+}
+
+static void emit_dst( struct vp_dst_register *dst,
+ struct ureg reg, GLuint mask )
+{
+ dst->File = reg.file;
+ dst->Index = reg.idx;
+ /* allow zero as a shorthand for xyzw */
+ dst->WriteMask = mask ? mask : WRITEMASK_XYZW;
+ dst->pad = 0;
+}
+
+static void debug_insn( struct vp_instruction *inst, const char *fn,
+ GLuint line )
+{
+ if (DISASSEM) {
+ static const char *last_fn;
+
+ if (fn != last_fn) {
+ last_fn = fn;
+ _mesa_printf("%s:\n", fn);
+ }
+
+ _mesa_printf("%d:\t", line);
+ _mesa_debug_vp_inst(1, inst);
+ }
+}
+
+
+static void emit_op3fn(struct tnl_program *p,
+ GLuint op,
+ struct ureg dest,
+ GLuint mask,
+ struct ureg src0,
+ struct ureg src1,
+ struct ureg src2,
+ const char *fn,
+ GLuint line)
+{
+ GLuint nr = p->program->Base.NumInstructions++;
+ struct vp_instruction *inst = &p->program->Instructions[nr];
+
+ if (p->program->Base.NumInstructions > MAX_INSN) {
+ _mesa_problem(0, "Out of instructions in emit_op3fn\n");
+ return;
+ }
+
+ inst->Opcode = op;
+ inst->StringPos = 0;
+ inst->Data = 0;
+
+ emit_arg( &inst->SrcReg[0], src0 );
+ emit_arg( &inst->SrcReg[1], src1 );
+ emit_arg( &inst->SrcReg[2], src2 );
+
+ emit_dst( &inst->DstReg, dest, mask );
+
+ debug_insn(inst, fn, line);
+}
+
+
+#define emit_op3(p, op, dst, mask, src0, src1, src2) \
+ emit_op3fn(p, op, dst, mask, src0, src1, src2, __FUNCTION__, __LINE__)
+
+#define emit_op2(p, op, dst, mask, src0, src1) \
+ emit_op3fn(p, op, dst, mask, src0, src1, undef, __FUNCTION__, __LINE__)
+
+#define emit_op1(p, op, dst, mask, src0) \
+ emit_op3fn(p, op, dst, mask, src0, undef, undef, __FUNCTION__, __LINE__)
+
+
+static struct ureg make_temp( struct tnl_program *p, struct ureg reg )
+{
+ if (reg.file == PROGRAM_TEMPORARY &&
+ !(p->temp_reserved & (1<<reg.idx)))
+ return reg;
+ else {
+ struct ureg temp = get_temp(p);
+ emit_op1(p, VP_OPCODE_MOV, temp, 0, reg);
+ return temp;
+ }
+}
+
+
+/* Currently no tracking performed of input/output/register size or
+ * active elements. Could be used to reduce these operations, as
+ * could the matrix type.
+ */
+static void emit_matrix_transform_vec4( struct tnl_program *p,
+ struct ureg dest,
+ const struct ureg *mat,
+ struct ureg src)
+{
+ emit_op2(p, VP_OPCODE_DP4, dest, WRITEMASK_X, src, mat[0]);
+ emit_op2(p, VP_OPCODE_DP4, dest, WRITEMASK_Y, src, mat[1]);
+ emit_op2(p, VP_OPCODE_DP4, dest, WRITEMASK_Z, src, mat[2]);
+ emit_op2(p, VP_OPCODE_DP4, dest, WRITEMASK_W, src, mat[3]);
+}
+
+/* This version is much easier to implement if writemasks are not
+ * supported natively on the target or (like SSE), the target doesn't
+ * have a clean/obvious dotproduct implementation.
+ */
+static void emit_transpose_matrix_transform_vec4( struct tnl_program *p,
+ struct ureg dest,
+ const struct ureg *mat,
+ struct ureg src)
+{
+ struct ureg tmp;
+
+ if (dest.file != PROGRAM_TEMPORARY)
+ tmp = get_temp(p);
+ else
+ tmp = dest;
+
+ emit_op2(p, VP_OPCODE_MUL, tmp, 0, swizzle1(src,X), mat[0]);
+ emit_op3(p, VP_OPCODE_MAD, tmp, 0, swizzle1(src,Y), mat[1], tmp);
+ emit_op3(p, VP_OPCODE_MAD, tmp, 0, swizzle1(src,Z), mat[2], tmp);
+ emit_op3(p, VP_OPCODE_MAD, dest, 0, swizzle1(src,W), mat[3], tmp);
+
+ if (dest.file != PROGRAM_TEMPORARY)
+ release_temp(p, tmp);
+}
+
+static void emit_matrix_transform_vec3( struct tnl_program *p,
+ struct ureg dest,
+ const struct ureg *mat,
+ struct ureg src)
+{
+ emit_op2(p, VP_OPCODE_DP3, dest, WRITEMASK_X, src, mat[0]);
+ emit_op2(p, VP_OPCODE_DP3, dest, WRITEMASK_Y, src, mat[1]);
+ emit_op2(p, VP_OPCODE_DP3, dest, WRITEMASK_Z, src, mat[2]);
+}
+
+
+static void emit_normalize_vec3( struct tnl_program *p,
+ struct ureg dest,
+ struct ureg src )
+{
+ struct ureg tmp = get_temp(p);
+ emit_op2(p, VP_OPCODE_DP3, tmp, 0, src, src);
+ emit_op1(p, VP_OPCODE_RSQ, tmp, 0, tmp);
+ emit_op2(p, VP_OPCODE_MUL, dest, 0, src, tmp);
+ release_temp(p, tmp);
+}
+
+static void emit_passthrough( struct tnl_program *p,
+ GLuint input,
+ GLuint output )
+{
+ struct ureg out = register_output(p, output);
+ emit_op1(p, VP_OPCODE_MOV, out, 0, register_input(p, input));
+}
+
+static struct ureg get_eye_position( struct tnl_program *p )
+{
+ if (is_undef(p->eye_position)) {
+ struct ureg pos = register_input( p, VERT_ATTRIB_POS );
+ struct ureg modelview[4];
+
+ p->eye_position = reserve_temp(p);
+
+ if (PREFER_DP4) {
+ register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 3,
+ STATE_MATRIX, modelview );
+
+ emit_matrix_transform_vec4(p, p->eye_position, modelview, pos);
+ }
+ else {
+ register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 3,
+ STATE_MATRIX_TRANSPOSE, modelview );
+
+ emit_transpose_matrix_transform_vec4(p, p->eye_position, modelview, pos);
+ }
+ }
+
+ return p->eye_position;
+}
+
+
+static struct ureg get_eye_position_normalized( struct tnl_program *p )
+{
+ if (is_undef(p->eye_position_normalized)) {
+ struct ureg eye = get_eye_position(p);
+ p->eye_position_normalized = reserve_temp(p);
+ emit_normalize_vec3(p, p->eye_position_normalized, eye);
+ }
+
+ return p->eye_position_normalized;
+}
+
+
+static struct ureg get_eye_normal( struct tnl_program *p )
+{
+ if (is_undef(p->eye_normal)) {
+ struct ureg normal = register_input(p, VERT_ATTRIB_NORMAL );
+ struct ureg mvinv[3];
+
+ register_matrix_param6( p, STATE_MATRIX, STATE_MODELVIEW, 0, 0, 2,
+ STATE_MATRIX_INVTRANS, mvinv );
+
+ p->eye_normal = reserve_temp(p);
+
+ /* Transform to eye space:
+ */
+ emit_matrix_transform_vec3( p, p->eye_normal, mvinv, normal );
+
+ /* Normalize/Rescale:
+ */
+ if (p->state->normalize) {
+ emit_normalize_vec3( p, p->eye_normal, p->eye_normal );
+ }
+ else if (p->state->rescale_normals) {
+ struct ureg rescale = register_param2(p, STATE_INTERNAL,
+ STATE_NORMAL_SCALE);
+
+ emit_op2( p, VP_OPCODE_MUL, p->eye_normal, 0, normal,
+ swizzle1(rescale, X));
+ }
+ }
+
+ return p->eye_normal;
+}
+
+
+
+static void build_hpos( struct tnl_program *p )
+{
+ struct ureg pos = register_input( p, VERT_ATTRIB_POS );
+ struct ureg hpos = register_output( p, VERT_RESULT_HPOS );
+ struct ureg mvp[4];
+
+ if (PREFER_DP4) {
+ register_matrix_param6( p, STATE_MATRIX, STATE_MVP, 0, 0, 3,
+ STATE_MATRIX, mvp );
+ emit_matrix_transform_vec4( p, hpos, mvp, pos );
+ }
+ else {
+ register_matrix_param6( p, STATE_MATRIX, STATE_MVP, 0, 0, 3,
+ STATE_MATRIX_TRANSPOSE, mvp );
+ emit_transpose_matrix_transform_vec4( p, hpos, mvp, pos );
+ }
+}
+
+
+static GLuint material_attrib( GLuint side, GLuint property )
+{
+ return ((property - STATE_AMBIENT) * 2 +
+ side);
+}
+
+static void set_material_flags( struct tnl_program *p )
+{
+ p->color_materials = 0;
+ p->materials = 0;
+
+ if (p->state->light_color_material) {
+ p->materials =
+ p->color_materials = p->state->light_color_material_mask;
+ }
+
+ p->materials |= p->state->light_material_mask;
+}
+
+
+static struct ureg get_material( struct tnl_program *p, GLuint side,
+ GLuint property )
+{
+ GLuint attrib = material_attrib(side, property);
+
+ if (p->color_materials & (1<<attrib))
+ return register_input(p, VERT_ATTRIB_COLOR0);
+ else if (p->materials & (1<<attrib))
+ return register_input( p, attrib + _TNL_ATTRIB_MAT_FRONT_AMBIENT );
+ else
+ return register_param3( p, STATE_MATERIAL, side, property );
+}
+
+#define SCENE_COLOR_BITS(side) (( MAT_BIT_FRONT_EMISSION | \
+ MAT_BIT_FRONT_AMBIENT | \
+ MAT_BIT_FRONT_DIFFUSE) << (side))
+
+/* Either return a precalculated constant value or emit code to
+ * calculate these values dynamically in the case where material calls
+ * are present between begin/end pairs.
+ *
+ * Probably want to shift this to the program compilation phase - if
+ * we always emitted the calculation here, a smart compiler could
+ * detect that it was constant (given a certain set of inputs), and
+ * lift it out of the main loop. That way the programs created here
+ * would be independent of the vertex_buffer details.
+ */
+static struct ureg get_scenecolor( struct tnl_program *p, GLuint side )
+{
+ if (p->materials & SCENE_COLOR_BITS(side)) {
+ struct ureg lm_ambient = register_param1(p, STATE_LIGHTMODEL_AMBIENT);
+ struct ureg material_emission = get_material(p, side, STATE_EMISSION);
+ struct ureg material_ambient = get_material(p, side, STATE_AMBIENT);
+ struct ureg material_diffuse = get_material(p, side, STATE_DIFFUSE);
+ struct ureg tmp = make_temp(p, material_diffuse);
+ emit_op3(p, VP_OPCODE_MAD, tmp, WRITEMASK_XYZ, lm_ambient,
+ material_ambient, material_emission);
+ return tmp;
+ }
+ else
+ return register_param2( p, STATE_LIGHTMODEL_SCENECOLOR, side );
+}
+
+
+static struct ureg get_lightprod( struct tnl_program *p, GLuint light,
+ GLuint side, GLuint property )
+{
+ GLuint attrib = material_attrib(side, property);
+ if (p->materials & (1<<attrib)) {
+ struct ureg light_value =
+ register_param3(p, STATE_LIGHT, light, property);
+ struct ureg material_value = get_material(p, side, property);
+ struct ureg tmp = get_temp(p);
+ emit_op2(p, VP_OPCODE_MUL, tmp, 0, light_value, material_value);
+ return tmp;
+ }
+ else
+ return register_param4(p, STATE_LIGHTPROD, light, side, property);
+}
+
+static struct ureg calculate_light_attenuation( struct tnl_program *p,
+ GLuint i,
+ struct ureg VPpli,
+ struct ureg dist )
+{
+ struct ureg attenuation = register_param3(p, STATE_LIGHT, i,
+ STATE_ATTENUATION);
+ struct ureg att = get_temp(p);
+
+ /* Calculate spot attenuation:
+ */
+ if (!p->state->unit[i].light_spotcutoff_is_180) {
+ struct ureg spot_dir = register_param3(p, STATE_LIGHT, i,
+ STATE_SPOT_DIRECTION);
+ struct ureg spot = get_temp(p);
+ struct ureg slt = get_temp(p);
+
+ emit_normalize_vec3( p, spot, spot_dir ); /* XXX: precompute! */
+ emit_op2(p, VP_OPCODE_DP3, spot, 0, negate(VPpli), spot);
+ emit_op2(p, VP_OPCODE_SLT, slt, 0, swizzle1(spot_dir,W), spot);
+ emit_op2(p, VP_OPCODE_POW, spot, 0, spot, swizzle1(attenuation, W));
+ emit_op2(p, VP_OPCODE_MUL, att, 0, slt, spot);
+
+ release_temp(p, spot);
+ release_temp(p, slt);
+ }
+
+ /* Calculate distance attenuation:
+ */
+ if (p->state->unit[i].light_attenuated) {
+
+ /* 1/d,d,d,1/d */
+ emit_op1(p, VP_OPCODE_RCP, dist, WRITEMASK_YZ, dist);
+ /* 1,d,d*d,1/d */
+ emit_op2(p, VP_OPCODE_MUL, dist, WRITEMASK_XZ, dist, swizzle1(dist,Y));
+ /* 1/dist-atten */
+ emit_op2(p, VP_OPCODE_DP3, dist, 0, attenuation, dist);
+
+ if (!p->state->unit[i].light_spotcutoff_is_180) {
+ /* dist-atten */
+ emit_op1(p, VP_OPCODE_RCP, dist, 0, dist);
+ /* spot-atten * dist-atten */
+ emit_op2(p, VP_OPCODE_MUL, att, 0, dist, att);
+ } else {
+ /* dist-atten */
+ emit_op1(p, VP_OPCODE_RCP, att, 0, dist);
+ }
+ }
+
+ return att;
+}
+
+
+
+
+
+/* Need to add some addtional parameters to allow lighting in object
+ * space - STATE_SPOT_DIRECTION and STATE_HALF implicitly assume eye
+ * space lighting.
+ */
+static void build_lighting( struct tnl_program *p )
+{
+ const GLboolean twoside = p->state->light_twoside;
+ const GLboolean separate = p->state->separate_specular;
+ GLuint nr_lights = 0, count = 0;
+ struct ureg normal = get_eye_normal(p);
+ struct ureg lit = get_temp(p);
+ struct ureg dots = get_temp(p);
+ struct ureg _col0 = undef, _col1 = undef;
+ struct ureg _bfc0 = undef, _bfc1 = undef;
+ GLuint i;
+
+ for (i = 0; i < MAX_LIGHTS; i++)
+ if (p->state->unit[i].light_enabled)
+ nr_lights++;
+
+ set_material_flags(p);
+
+ {
+ struct ureg shininess = get_material(p, 0, STATE_SHININESS);
+ emit_op1(p, VP_OPCODE_MOV, dots, WRITEMASK_W, swizzle1(shininess,X));
+ release_temp(p, shininess);
+
+ _col0 = make_temp(p, get_scenecolor(p, 0));
+ if (separate)
+ _col1 = make_temp(p, get_identity_param(p));
+ else
+ _col1 = _col0;
+
+ }
+
+ if (twoside) {
+ struct ureg shininess = get_material(p, 1, STATE_SHININESS);
+ emit_op1(p, VP_OPCODE_MOV, dots, WRITEMASK_Z,
+ negate(swizzle1(shininess,X)));
+ release_temp(p, shininess);
+
+ _bfc0 = make_temp(p, get_scenecolor(p, 1));
+ if (separate)
+ _bfc1 = make_temp(p, get_identity_param(p));
+ else
+ _bfc1 = _bfc0;
+ }
+
+
+ /* If no lights, still need to emit the scenecolor.
+ */
+ {
+ struct ureg res0 = register_output( p, VERT_RESULT_COL0 );
+ emit_op1(p, VP_OPCODE_MOV, res0, 0, _col0);
+ }
+
+ if (separate) {
+ struct ureg res1 = register_output( p, VERT_RESULT_COL1 );
+ emit_op1(p, VP_OPCODE_MOV, res1, 0, _col1);
+ }
+
+ if (twoside) {
+ struct ureg res0 = register_output( p, VERT_RESULT_BFC0 );
+ emit_op1(p, VP_OPCODE_MOV, res0, 0, _bfc0);
+ }
+
+ if (twoside && separate) {
+ struct ureg res1 = register_output( p, VERT_RESULT_BFC1 );
+ emit_op1(p, VP_OPCODE_MOV, res1, 0, _bfc1);
+ }
+
+ if (nr_lights == 0) {
+ release_temps(p);
+ return;
+ }
+
+
+ for (i = 0; i < MAX_LIGHTS; i++) {
+ if (p->state->unit[i].light_enabled) {
+ struct ureg half = undef;
+ struct ureg att = undef, VPpli = undef;
+
+ count++;
+
+ if (p->state->unit[i].light_eyepos3_is_zero) {
+ /* Can used precomputed constants in this case.
+ * Attenuation never applies to infinite lights.
+ */
+ VPpli = register_param3(p, STATE_LIGHT, i,
+ STATE_POSITION_NORMALIZED);
+ half = register_param3(p, STATE_LIGHT, i, STATE_HALF);
+ }
+ else {
+ struct ureg Ppli = register_param3(p, STATE_LIGHT, i,
+ STATE_POSITION);
+ struct ureg V = get_eye_position(p);
+ struct ureg dist = get_temp(p);
+
+ VPpli = get_temp(p);
+ half = get_temp(p);
+
+ /* Calulate VPpli vector
+ */
+ emit_op2(p, VP_OPCODE_SUB, VPpli, 0, Ppli, V);
+
+ /* Normalize VPpli. The dist value also used in
+ * attenuation below.
+ */
+ emit_op2(p, VP_OPCODE_DP3, dist, 0, VPpli, VPpli);
+ emit_op1(p, VP_OPCODE_RSQ, dist, 0, dist);
+ emit_op2(p, VP_OPCODE_MUL, VPpli, 0, VPpli, dist);
+
+
+ /* Calculate attenuation:
+ */
+ if (!p->state->unit[i].light_spotcutoff_is_180 ||
+ p->state->unit[i].light_attenuated) {
+ att = calculate_light_attenuation(p, i, VPpli, dist);
+ }
+
+
+ /* Calculate viewer direction, or use infinite viewer:
+ */
+ if (p->state->light_local_viewer) {
+ struct ureg eye_hat = get_eye_position_normalized(p);
+ emit_op2(p, VP_OPCODE_SUB, half, 0, VPpli, eye_hat);
+ }
+ else {
+ struct ureg z_dir = swizzle(get_identity_param(p),X,Y,W,Z);
+ emit_op2(p, VP_OPCODE_ADD, half, 0, VPpli, z_dir);
+ }
+
+ emit_normalize_vec3(p, half, half);
+
+ release_temp(p, dist);
+ }
+
+ /* Calculate dot products:
+ */
+ emit_op2(p, VP_OPCODE_DP3, dots, WRITEMASK_X, normal, VPpli);
+ emit_op2(p, VP_OPCODE_DP3, dots, WRITEMASK_Y, normal, half);
+
+
+ /* Front face lighting:
+ */
+ {
+ struct ureg ambient = get_lightprod(p, i, 0, STATE_AMBIENT);
+ struct ureg diffuse = get_lightprod(p, i, 0, STATE_DIFFUSE);
+ struct ureg specular = get_lightprod(p, i, 0, STATE_SPECULAR);
+ struct ureg res0, res1;
+ GLuint mask0, mask1;
+
+ emit_op1(p, VP_OPCODE_LIT, lit, 0, dots);
+
+ if (!is_undef(att))
+ emit_op2(p, VP_OPCODE_MUL, lit, 0, lit, att);
+
+
+ if (count == nr_lights) {
+ if (separate) {
+ mask0 = WRITEMASK_XYZ;
+ mask1 = WRITEMASK_XYZ;
+ res0 = register_output( p, VERT_RESULT_COL0 );
+ res1 = register_output( p, VERT_RESULT_COL1 );
+ }
+ else {
+ mask0 = 0;
+ mask1 = WRITEMASK_XYZ;
+ res0 = _col0;
+ res1 = register_output( p, VERT_RESULT_COL0 );
+ }
+ } else {
+ mask0 = 0;
+ mask1 = 0;
+ res0 = _col0;
+ res1 = _col1;
+ }
+
+ emit_op3(p, VP_OPCODE_MAD, _col0, 0, swizzle1(lit,X), ambient, _col0);
+ emit_op3(p, VP_OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _col0);
+ emit_op3(p, VP_OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _col1);
+
+ release_temp(p, ambient);
+ release_temp(p, diffuse);
+ release_temp(p, specular);
+ }
+
+ /* Back face lighting:
+ */
+ if (twoside) {
+ struct ureg ambient = get_lightprod(p, i, 1, STATE_AMBIENT);
+ struct ureg diffuse = get_lightprod(p, i, 1, STATE_DIFFUSE);
+ struct ureg specular = get_lightprod(p, i, 1, STATE_SPECULAR);
+ struct ureg res0, res1;
+ GLuint mask0, mask1;
+
+ emit_op1(p, VP_OPCODE_LIT, lit, 0, negate(swizzle(dots,X,Y,W,Z)));
+
+ if (!is_undef(att))
+ emit_op2(p, VP_OPCODE_MUL, lit, 0, lit, att);
+
+ if (count == nr_lights) {
+ if (separate) {
+ mask0 = WRITEMASK_XYZ;
+ mask1 = WRITEMASK_XYZ;
+ res0 = register_output( p, VERT_RESULT_BFC0 );
+ res1 = register_output( p, VERT_RESULT_BFC1 );
+ }
+ else {
+ mask0 = 0;
+ mask1 = WRITEMASK_XYZ;
+ res0 = _bfc0;
+ res1 = register_output( p, VERT_RESULT_BFC0 );
+ }
+ } else {
+ res0 = _bfc0;
+ res1 = _bfc1;
+ mask0 = 0;
+ mask1 = 0;
+ }
+
+ emit_op3(p, VP_OPCODE_MAD, _bfc0, 0, swizzle1(lit,X), ambient, _bfc0);
+ emit_op3(p, VP_OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _bfc0);
+ emit_op3(p, VP_OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _bfc1);
+
+ release_temp(p, ambient);
+ release_temp(p, diffuse);
+ release_temp(p, specular);
+ }
+
+ release_temp(p, half);
+ release_temp(p, VPpli);
+ release_temp(p, att);
+ }
+ }
+
+ release_temps( p );
+}
+
+
+static void build_fog( struct tnl_program *p )
+{
+ struct ureg fog = register_output(p, VERT_RESULT_FOGC);
+ struct ureg input;
+
+ if (p->state->fog_source_is_depth) {
+ input = swizzle1(get_eye_position(p), Z);
+ }
+ else {
+ input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X);
+ }
+
+ if (p->state->tnl_do_vertex_fog) {
+ struct ureg params = register_param1(p, STATE_FOG_PARAMS);
+ struct ureg tmp = get_temp(p);
+
+ switch (p->state->fog_mode) {
+ case FOG_LINEAR: {
+ struct ureg id = get_identity_param(p);
+ emit_op2(p, VP_OPCODE_SUB, tmp, 0, swizzle1(params,Z), input);
+ emit_op2(p, VP_OPCODE_MUL, tmp, 0, tmp, swizzle1(params,W));
+ emit_op2(p, VP_OPCODE_MAX, tmp, 0, tmp, swizzle1(id,X)); /* saturate */
+ emit_op2(p, VP_OPCODE_MIN, fog, WRITEMASK_X, tmp, swizzle1(id,W));
+ break;
+ }
+ case FOG_EXP:
+ emit_op1(p, VP_OPCODE_ABS, tmp, 0, input);
+ emit_op2(p, VP_OPCODE_MUL, tmp, 0, tmp, swizzle1(params,X));
+ emit_op2(p, VP_OPCODE_POW, fog, WRITEMASK_X,
+ register_const1f(p, M_E), negate(tmp));
+ break;
+ case FOG_EXP2:
+ emit_op2(p, VP_OPCODE_MUL, tmp, 0, input, swizzle1(params,X));
+ emit_op2(p, VP_OPCODE_MUL, tmp, 0, tmp, tmp);
+ emit_op2(p, VP_OPCODE_POW, fog, WRITEMASK_X,
+ register_const1f(p, M_E), negate(tmp));
+ break;
+ }
+
+ release_temp(p, tmp);
+ }
+ else {
+ /* results = incoming fog coords (compute fog per-fragment later)
+ *
+ * KW: Is it really necessary to do anything in this case?
+ */
+ emit_op1(p, VP_OPCODE_MOV, fog, WRITEMASK_X, input);
+ }
+}
+
+static void build_reflect_texgen( struct tnl_program *p,
+ struct ureg dest,
+ GLuint writemask )
+{
+ struct ureg normal = get_eye_normal(p);
+ struct ureg eye_hat = get_eye_position_normalized(p);
+ struct ureg tmp = get_temp(p);
+
+ /* n.u */
+ emit_op2(p, VP_OPCODE_DP3, tmp, 0, normal, eye_hat);
+ /* 2n.u */
+ emit_op2(p, VP_OPCODE_ADD, tmp, 0, tmp, tmp);
+ /* (-2n.u)n + u */
+ emit_op3(p, VP_OPCODE_MAD, dest, writemask, negate(tmp), normal, eye_hat);
+}
+
+static void build_sphere_texgen( struct tnl_program *p,
+ struct ureg dest,
+ GLuint writemask )
+{
+ struct ureg normal = get_eye_normal(p);
+ struct ureg eye_hat = get_eye_position_normalized(p);
+ struct ureg tmp = get_temp(p);
+ struct ureg half = register_scalar_const(p, .5);
+ struct ureg r = get_temp(p);
+ struct ureg inv_m = get_temp(p);
+ struct ureg id = get_identity_param(p);
+
+ /* Could share the above calculations, but it would be
+ * a fairly odd state for someone to set (both sphere and
+ * reflection active for different texture coordinate
+ * components. Of course - if two texture units enable
+ * reflect and/or sphere, things start to tilt in favour
+ * of seperating this out:
+ */
+
+ /* n.u */
+ emit_op2(p, VP_OPCODE_DP3, tmp, 0, normal, eye_hat);
+ /* 2n.u */
+ emit_op2(p, VP_OPCODE_ADD, tmp, 0, tmp, tmp);
+ /* (-2n.u)n + u */
+ emit_op3(p, VP_OPCODE_MAD, r, 0, negate(tmp), normal, eye_hat);
+ /* r + 0,0,1 */
+ emit_op2(p, VP_OPCODE_ADD, tmp, 0, r, swizzle(id,X,Y,W,Z));
+ /* rx^2 + ry^2 + (rz+1)^2 */
+ emit_op2(p, VP_OPCODE_DP3, tmp, 0, tmp, tmp);
+ /* 2/m */
+ emit_op1(p, VP_OPCODE_RSQ, tmp, 0, tmp);
+ /* 1/m */
+ emit_op2(p, VP_OPCODE_MUL, inv_m, 0, tmp, half);
+ /* r/m + 1/2 */
+ emit_op3(p, VP_OPCODE_MAD, dest, writemask, r, inv_m, half);
+
+ release_temp(p, tmp);
+ release_temp(p, r);
+ release_temp(p, inv_m);
+}
+
+
+static void build_texture_transform( struct tnl_program *p )
+{
+ GLuint i, j;
+
+ for (i = 0; i < MAX_TEXTURE_UNITS; i++) {
+ GLuint texmat_enabled = p->state->unit[i].texmat_enabled;
+
+ if (p->state->unit[i].texgen_enabled || texmat_enabled) {
+ struct ureg out = register_output(p, VERT_RESULT_TEX0 + i);
+ struct ureg out_texgen = undef;
+
+ if (p->state->unit[i].texgen_enabled) {
+ GLuint copy_mask = 0;
+ GLuint sphere_mask = 0;
+ GLuint reflect_mask = 0;
+ GLuint normal_mask = 0;
+ GLuint modes[4];
+
+ if (texmat_enabled)
+ out_texgen = get_temp(p);
+ else
+ out_texgen = out;
+
+ modes[0] = p->state->unit[i].texgen_mode0;
+ modes[1] = p->state->unit[i].texgen_mode1;
+ modes[2] = p->state->unit[i].texgen_mode2;
+ modes[3] = p->state->unit[i].texgen_mode3;
+
+ for (j = 0; j < 4; j++) {
+ switch (modes[j]) {
+ case TXG_OBJ_LINEAR: {
+ struct ureg obj = register_input(p, VERT_ATTRIB_POS);
+ struct ureg plane =
+ register_param3(p, STATE_TEXGEN, i,
+ STATE_TEXGEN_OBJECT_S + j);
+
+ emit_op2(p, VP_OPCODE_DP4, out_texgen, WRITEMASK_X << j,
+ obj, plane );
+ break;
+ }
+ case TXG_EYE_LINEAR: {
+ struct ureg eye = get_eye_position(p);
+ struct ureg plane =
+ register_param3(p, STATE_TEXGEN, i,
+ STATE_TEXGEN_EYE_S + j);
+
+ emit_op2(p, VP_OPCODE_DP4, out_texgen, WRITEMASK_X << j,
+ eye, plane );
+ break;
+ }
+ case TXG_SPHERE_MAP:
+ sphere_mask |= WRITEMASK_X << j;
+ break;
+ case TXG_REFLECTION_MAP:
+ reflect_mask |= WRITEMASK_X << j;
+ break;
+ case TXG_NORMAL_MAP:
+ normal_mask |= WRITEMASK_X << j;
+ break;
+ case TXG_NONE:
+ copy_mask |= WRITEMASK_X << j;
+ }
+
+ }
+
+
+ if (sphere_mask) {
+ build_sphere_texgen(p, out_texgen, sphere_mask);
+ }
+
+ if (reflect_mask) {
+ build_reflect_texgen(p, out_texgen, reflect_mask);
+ }
+
+ if (normal_mask) {
+ struct ureg normal = get_eye_normal(p);
+ emit_op1(p, VP_OPCODE_MOV, out_texgen, normal_mask, normal );
+ }
+
+ if (copy_mask) {
+ struct ureg in = register_input(p, VERT_ATTRIB_TEX0+i);
+ emit_op1(p, VP_OPCODE_MOV, out_texgen, copy_mask, in );
+ }
+ }
+
+ if (texmat_enabled) {
+ struct ureg texmat[4];
+ struct ureg in = (!is_undef(out_texgen) ?
+ out_texgen :
+ register_input(p, VERT_ATTRIB_TEX0+i));
+ if (PREFER_DP4) {
+ register_matrix_param6( p, STATE_MATRIX, STATE_TEXTURE, i,
+ 0, 3, STATE_MATRIX, texmat );
+ emit_matrix_transform_vec4( p, out, texmat, in );
+ }
+ else {
+ register_matrix_param6( p, STATE_MATRIX, STATE_TEXTURE, i,
+ 0, 3, STATE_MATRIX_TRANSPOSE, texmat );
+ emit_transpose_matrix_transform_vec4( p, out, texmat, in );
+ }
+ }
+
+ release_temps(p);
+ }
+ else if (p->state->unit[i].texunit_really_enabled) {
+ /* KW: _ReallyEnabled isn't sufficient? Need to know whether
+ * this texture unit is referenced by the fragment shader.
+ */
+ emit_passthrough(p, VERT_ATTRIB_TEX0+i, VERT_RESULT_TEX0+i);
+ }
+ }
+}
+
+
+/* Seems like it could be tighter:
+ */
+static void build_pointsize( struct tnl_program *p )
+{
+ struct ureg eye = get_eye_position(p);
+ struct ureg state_size = register_param1(p, STATE_POINT_SIZE);
+ struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION);
+ struct ureg out = register_output(p, VERT_RESULT_PSIZ);
+ struct ureg ut = get_temp(p);
+
+ /* 1, -Z, Z * Z, 1 */
+ emit_op1(p, VP_OPCODE_MOV, ut, 0, swizzle1(get_identity_param(p), W));
+ emit_op2(p, VP_OPCODE_MUL, ut, WRITEMASK_YZ, ut, negate(swizzle1(eye, Z)));
+ emit_op2(p, VP_OPCODE_MUL, ut, WRITEMASK_Z, ut, negate(swizzle1(eye, Z)));
+
+
+ /* p1 + p2 * dist + p3 * dist * dist, 0 */
+ emit_op2(p, VP_OPCODE_DP3, ut, 0, ut, state_attenuation);
+
+ /* 1 / factor */
+ emit_op1(p, VP_OPCODE_RCP, ut, 0, ut );
+
+ /* out = pointSize / factor */
+ emit_op2(p, VP_OPCODE_MUL, out, WRITEMASK_X, ut, state_size);
+
+ release_temp(p, ut);
+}
+
+static void build_tnl_program( struct tnl_program *p )
+{ /* Emit the program, starting with modelviewproject:
+ */
+ build_hpos(p);
+
+ /* Lighting calculations:
+ */
+ if (p->state->light_global_enabled)
+ build_lighting(p);
+ else
+ emit_passthrough(p, VERT_ATTRIB_COLOR0, VERT_RESULT_COL0);
+
+ if (p->state->fog_enabled)
+ build_fog(p);
+
+ if (p->state->texture_enabled_global)
+ build_texture_transform(p);
+
+ if (p->state->point_attenuated)
+ build_pointsize(p);
+
+ /* Finish up:
+ */
+ emit_op1(p, VP_OPCODE_END, undef, 0, undef);
+
+ /* Disassemble:
+ */
+ if (DISASSEM) {
+ _mesa_printf ("\n");
+ }
+}
+
+
+static void
+create_new_program( const struct state_key *key,
+ struct vertex_program *program,
+ GLuint max_temps)
+{
+ struct tnl_program p;
+
+ _mesa_memset(&p, 0, sizeof(p));
+ p.state = key;
+ p.program = program;
+ p.eye_position = undef;
+ p.eye_position_normalized = undef;
+ p.eye_normal = undef;
+ p.identity = undef;
+ p.temp_in_use = 0;
+
+ if (max_temps >= sizeof(int) * 8)
+ p.temp_reserved = 0;
+ else
+ p.temp_reserved = ~((1<<max_temps)-1);
+
+ p.program->Instructions = MALLOC(sizeof(struct vp_instruction) * MAX_INSN);
+ p.program->Base.String = 0;
+ p.program->Base.NumInstructions =
+ p.program->Base.NumTemporaries =
+ p.program->Base.NumParameters =
+ p.program->Base.NumAttributes = p.program->Base.NumAddressRegs = 0;
+ p.program->Parameters = _mesa_new_parameter_list();
+ p.program->InputsRead = 0;
+ p.program->OutputsWritten = 0;
+
+ build_tnl_program( &p );
+}
+
+static void *search_cache( struct tnl_cache *cache,
+ GLuint hash,
+ const void *key,
+ GLuint keysize)
+{
+ struct tnl_cache *c;
+
+ for (c = cache; c; c = c->next) {
+ if (c->hash == hash && memcmp(c->key, key, keysize) == 0)
+ return c->data;
+ }
+
+ return NULL;
+}
+
+static void cache_item( struct tnl_cache **cache,
+ GLuint hash,
+ void *key,
+ void *data )
+{
+ struct tnl_cache *c = MALLOC(sizeof(*c));
+ c->hash = hash;
+ c->key = key;
+ c->data = data;
+ c->next = *cache;
+ *cache = c;
+}
+
+static GLuint hash_key( struct state_key *key )
+{
+ GLuint *ikey = (GLuint *)key;
+ GLuint hash = 0, i;
+
+ /* I'm sure this can be improved on, but speed is important:
+ */
+ for (i = 0; i < sizeof(*key)/sizeof(GLuint); i++)
+ hash ^= ikey[i];
+
+ return hash;
+}
+
+void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct state_key *key;
+ GLuint hash;
+
+ if (ctx->VertexProgram._Enabled)
+ return;
+
+ /* Grab all the relevent state and put it in a single structure:
+ */
+ key = make_state_key(ctx);
+ hash = hash_key(key);
+
+ /* Look for an already-prepared program for this state:
+ */
+ ctx->_TnlProgram = (struct vertex_program *)
+ search_cache( tnl->vp_cache, hash, key, sizeof(*key) );
+
+ /* OK, we'll have to build a new one:
+ */
+ if (!ctx->_TnlProgram) {
+ if (0)
+ _mesa_printf("Build new TNL program\n");
+
+ ctx->_TnlProgram = (struct vertex_program *)
+ ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0);
+
+ create_new_program( key, ctx->_TnlProgram,
+ ctx->Const.MaxVertexProgramTemps );
+
+ cache_item(&tnl->vp_cache, hash, key, ctx->_TnlProgram );
+ }
+ else {
+ FREE(key);
+ if (0)
+ _mesa_printf("Found existing TNL program for key %x\n", hash);
+ }
+
+ /* Need a BindProgram callback for the driver?
+ */
+}
+
+
+void _tnl_ProgramCacheDestroy( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct tnl_cache *a, *tmp;
+
+ for (a = tnl->vp_cache ; a; a = tmp) {
+ tmp = a->next;
+ FREE(a->key);
+ FREE(a->data);
+ FREE(a);
+ }
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vp_build.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_vp_build.h
new file mode 100644
index 000000000..83e685b1a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vp_build.h
@@ -0,0 +1,35 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 2005 Tungsten Graphics 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
+ * TUNGSTEN GRAPHICS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef _T_ARB_BUILD_H
+#define _T_ARB_BUILD_H
+
+#include "mtypes.h"
+
+extern void _tnl_UpdateFixedFunctionProgram( GLcontext *ctx );
+
+extern void _tnl_ProgramCacheDestroy( GLcontext *ctx );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_api.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_api.c
new file mode 100644
index 000000000..c86c160d2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_api.c
@@ -0,0 +1,995 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 2002 Tungsten Graphics 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
+TUNGSTEN GRAPHICS 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "vtxfmt.h"
+#include "dlist.h"
+#include "state.h"
+#include "light.h"
+#include "api_arrayelt.h"
+#include "api_noop.h"
+#include "t_vtx_api.h"
+#include "simple_list.h"
+
+#include "dispatch.h"
+
+static void reset_attrfv( TNLcontext *tnl );
+
+static tnl_attrfv_func choose[_TNL_MAX_ATTR_CODEGEN+1][4]; /* +1 for ERROR_ATTRIB */
+static tnl_attrfv_func generic_attr_func[_TNL_MAX_ATTR_CODEGEN][4];
+
+
+/* Close off the last primitive, execute the buffer, restart the
+ * primitive.
+ */
+static void _tnl_wrap_buffers( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+
+ if (tnl->vtx.prim_count == 0) {
+ tnl->vtx.copied.nr = 0;
+ tnl->vtx.counter = tnl->vtx.initial_counter;
+ tnl->vtx.vbptr = tnl->vtx.buffer;
+ }
+ else {
+ GLuint last_prim = tnl->vtx.prim[tnl->vtx.prim_count-1].mode;
+ GLuint last_count;
+
+ if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) {
+ GLint i = tnl->vtx.prim_count - 1;
+ assert(i >= 0);
+ tnl->vtx.prim[i].count = ((tnl->vtx.initial_counter -
+ tnl->vtx.counter) -
+ tnl->vtx.prim[i].start);
+ }
+
+ last_count = tnl->vtx.prim[tnl->vtx.prim_count-1].count;
+
+ /* Execute the buffer and save copied vertices.
+ */
+ if (tnl->vtx.counter != tnl->vtx.initial_counter)
+ _tnl_flush_vtx( ctx );
+ else {
+ tnl->vtx.prim_count = 0;
+ tnl->vtx.copied.nr = 0;
+ }
+
+ /* Emit a glBegin to start the new list.
+ */
+ assert(tnl->vtx.prim_count == 0);
+
+ if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) {
+ tnl->vtx.prim[0].mode = ctx->Driver.CurrentExecPrimitive;
+ tnl->vtx.prim[0].start = 0;
+ tnl->vtx.prim[0].count = 0;
+ tnl->vtx.prim_count++;
+
+ if (tnl->vtx.copied.nr == last_count)
+ tnl->vtx.prim[0].mode |= last_prim & PRIM_BEGIN;
+ }
+ }
+}
+
+
+/* Deal with buffer wrapping where provoked by the vertex buffer
+ * filling up, as opposed to upgrade_vertex().
+ *
+ * Make it GLAPIENTRY, so we can tail from the codegen'ed Vertex*fv
+ */
+void GLAPIENTRY _tnl_wrap_filled_vertex( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLfloat *data = tnl->vtx.copied.buffer;
+ GLuint i;
+
+ /* Run pipeline on current vertices, copy wrapped vertices
+ * to tnl->copied.
+ */
+ _tnl_wrap_buffers( ctx );
+
+ /* Copy stored stored vertices to start of new list.
+ */
+ assert(tnl->vtx.counter > tnl->vtx.copied.nr);
+
+ for (i = 0 ; i < tnl->vtx.copied.nr ; i++) {
+ _mesa_memcpy( tnl->vtx.vbptr, data,
+ tnl->vtx.vertex_size * sizeof(GLfloat));
+ tnl->vtx.vbptr += tnl->vtx.vertex_size;
+ data += tnl->vtx.vertex_size;
+ tnl->vtx.counter--;
+ }
+
+ tnl->vtx.copied.nr = 0;
+}
+
+
+/*
+ * Copy the active vertex's values to the ctx->Current fields.
+ */
+static void _tnl_copy_to_current( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint i;
+
+ for (i = _TNL_ATTRIB_POS+1 ; i < _TNL_ATTRIB_INDEX ; i++) {
+ if (tnl->vtx.attrsz[i]) {
+ /* Note: the tnl->vtx.current[i] pointers points to
+ * the ctx->Current fields. The first 16 or so, anyway.
+ */
+ COPY_CLEAN_4V(tnl->vtx.current[i],
+ tnl->vtx.attrsz[i],
+ tnl->vtx.attrptr[i]);
+ }
+ }
+
+ /* color index is special (it's not a float[4] so COPY_CLEAN_4V above
+ * will trash adjacent memory!)
+ */
+ if (tnl->vtx.attrsz[_TNL_ATTRIB_INDEX]) {
+ ctx->Current.Index = tnl->vtx.attrptr[_TNL_ATTRIB_INDEX][0];
+ }
+
+ /* Edgeflag requires additional treatment:
+ */
+ if (tnl->vtx.attrsz[_TNL_ATTRIB_EDGEFLAG]) {
+ ctx->Current.EdgeFlag =
+ (tnl->vtx.CurrentFloatEdgeFlag == 1.0);
+ }
+
+ /* Colormaterial -- this kindof sucks.
+ */
+ if (ctx->Light.ColorMaterialEnabled) {
+ _mesa_update_color_material(ctx,
+ ctx->Current.Attrib[VERT_ATTRIB_COLOR0]);
+ }
+
+ if (tnl->vtx.have_materials) {
+ tnl->Driver.NotifyMaterialChange( ctx );
+ }
+
+ ctx->Driver.NeedFlush &= ~FLUSH_UPDATE_CURRENT;
+}
+
+
+static void _tnl_copy_from_current( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLint i;
+
+ /* Edgeflag requires additional treatment:
+ */
+ tnl->vtx.CurrentFloatEdgeFlag =
+ (GLfloat)ctx->Current.EdgeFlag;
+
+ for (i = _TNL_ATTRIB_POS+1 ; i <= _TNL_ATTRIB_MAX ; i++)
+ switch (tnl->vtx.attrsz[i]) {
+ case 4: tnl->vtx.attrptr[i][3] = tnl->vtx.current[i][3];
+ case 3: tnl->vtx.attrptr[i][2] = tnl->vtx.current[i][2];
+ case 2: tnl->vtx.attrptr[i][1] = tnl->vtx.current[i][1];
+ case 1: tnl->vtx.attrptr[i][0] = tnl->vtx.current[i][0];
+ break;
+ }
+
+ ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT;
+}
+
+
+/* Flush existing data, set new attrib size, replay copied vertices.
+ */
+static void _tnl_wrap_upgrade_vertex( GLcontext *ctx,
+ GLuint attr,
+ GLuint newsz )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldsz;
+ GLuint i;
+ GLfloat *tmp;
+ GLint lastcount = tnl->vtx.initial_counter - tnl->vtx.counter;
+
+ /* Run pipeline on current vertices, copy wrapped vertices
+ * to tnl->vtx.copied.
+ */
+ _tnl_wrap_buffers( ctx );
+
+
+ /* Do a COPY_TO_CURRENT to ensure back-copying works for the case
+ * when the attribute already exists in the vertex and is having
+ * its size increased.
+ */
+ _tnl_copy_to_current( ctx );
+
+
+ /* Heuristic: Attempt to isolate attributes received outside
+ * begin/end so that they don't bloat the vertices.
+ */
+ if (ctx->Driver.CurrentExecPrimitive == PRIM_OUTSIDE_BEGIN_END &&
+ tnl->vtx.attrsz[attr] == 0 &&
+ lastcount > 8 &&
+ tnl->vtx.vertex_size) {
+ reset_attrfv( tnl );
+ }
+
+ /* Fix up sizes:
+ */
+ oldsz = tnl->vtx.attrsz[attr];
+ tnl->vtx.attrsz[attr] = newsz;
+
+ tnl->vtx.vertex_size += newsz - oldsz;
+ tnl->vtx.counter = MIN2( VERT_BUFFER_SIZE / tnl->vtx.vertex_size,
+ ctx->Const.MaxArrayLockSize );
+ tnl->vtx.initial_counter = tnl->vtx.counter;
+ tnl->vtx.vbptr = tnl->vtx.buffer;
+
+
+ /* Recalculate all the attrptr[] values
+ */
+ for (i = 0, tmp = tnl->vtx.vertex ; i < _TNL_ATTRIB_MAX ; i++) {
+ if (tnl->vtx.attrsz[i]) {
+ tnl->vtx.attrptr[i] = tmp;
+ tmp += tnl->vtx.attrsz[i];
+ }
+ else
+ tnl->vtx.attrptr[i] = NULL; /* will not be dereferenced */
+ }
+
+ /* Copy from current to repopulate the vertex with correct values.
+ */
+ _tnl_copy_from_current( ctx );
+
+ /* Replay stored vertices to translate them
+ * to new format here.
+ *
+ * -- No need to replay - just copy piecewise
+ */
+ if (tnl->vtx.copied.nr)
+ {
+ GLfloat *data = tnl->vtx.copied.buffer;
+ GLfloat *dest = tnl->vtx.buffer;
+ GLuint j;
+
+ for (i = 0 ; i < tnl->vtx.copied.nr ; i++) {
+ for (j = 0 ; j < _TNL_ATTRIB_MAX ; j++) {
+ if (tnl->vtx.attrsz[j]) {
+ if (j == attr) {
+ if (oldsz) {
+ COPY_CLEAN_4V( dest, oldsz, data );
+ data += oldsz;
+ dest += newsz;
+ } else {
+ COPY_SZ_4V( dest, newsz, tnl->vtx.current[j] );
+ dest += newsz;
+ }
+ }
+ else {
+ GLuint sz = tnl->vtx.attrsz[j];
+ COPY_SZ_4V( dest, sz, data );
+ dest += sz;
+ data += sz;
+ }
+ }
+ }
+ }
+
+ tnl->vtx.vbptr = dest;
+ tnl->vtx.counter -= tnl->vtx.copied.nr;
+ tnl->vtx.copied.nr = 0;
+ }
+
+ /* For codegen - attrptr's may have changed, so need to redo
+ * codegen. Might be a reasonable place to try & detect attributes
+ * in the vertex which aren't being submitted any more.
+ */
+ for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++)
+ if (tnl->vtx.attrsz[i]) {
+ GLuint j = tnl->vtx.attrsz[i] - 1;
+
+ if (i < _TNL_MAX_ATTR_CODEGEN)
+ tnl->vtx.tabfv[i][j] = choose[i][j];
+ }
+
+}
+
+
+static void _tnl_fixup_vertex( GLcontext *ctx, GLuint attr, GLuint sz )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ static const GLfloat id[4] = { 0, 0, 0, 1 };
+ int i;
+
+ if (tnl->vtx.attrsz[attr] < sz) {
+ /* New size is larger. Need to flush existing vertices and get
+ * an enlarged vertex format.
+ */
+ _tnl_wrap_upgrade_vertex( ctx, attr, sz );
+ }
+ else if (tnl->vtx.attrsz[attr] > sz) {
+ /* New size is smaller - just need to fill in some
+ * zeros. Don't need to flush or wrap.
+ */
+ for (i = sz ; i <= tnl->vtx.attrsz[attr] ; i++)
+ tnl->vtx.attrptr[attr][i-1] = id[i-1];
+ }
+
+ /* Does setting NeedFlush belong here? Necessitates resetting
+ * vtxfmt on each flush (otherwise flags won't get reset
+ * afterwards).
+ */
+ if (attr == 0)
+ ctx->Driver.NeedFlush |= FLUSH_STORED_VERTICES;
+ else
+ ctx->Driver.NeedFlush |= FLUSH_UPDATE_CURRENT;
+}
+
+#ifdef USE_X86_ASM
+
+static struct _tnl_dynfn *lookup( struct _tnl_dynfn *l, GLuint key )
+{
+ struct _tnl_dynfn *f;
+
+ foreach( f, l ) {
+ if (f->key == key)
+ return f;
+ }
+
+ return NULL;
+}
+
+
+static tnl_attrfv_func do_codegen( GLcontext *ctx, GLuint attr, GLuint sz )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct _tnl_dynfn *dfn = NULL;
+
+ if (attr == 0) {
+ GLuint key = tnl->vtx.vertex_size;
+
+ dfn = lookup( &tnl->vtx.cache.Vertex[sz-1], key );
+
+ if (!dfn)
+ dfn = tnl->vtx.gen.Vertex[sz-1]( ctx, key );
+ }
+ else {
+ GLuint key = (GLuint) tnl->vtx.attrptr[attr];
+
+ dfn = lookup( &tnl->vtx.cache.Attribute[sz-1], key );
+
+ if (!dfn)
+ dfn = tnl->vtx.gen.Attribute[sz-1]( ctx, key );
+ }
+
+ if (dfn)
+ return *(tnl_attrfv_func *) &dfn->code;
+ else
+ return NULL;
+}
+
+#endif /* USE_X86_ASM */
+
+/* Helper function for 'CHOOSE' macro. Do what's necessary when an
+ * entrypoint is called for the first time.
+ */
+
+static tnl_attrfv_func do_choose( GLuint attr, GLuint sz )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldsz = tnl->vtx.attrsz[attr];
+
+ assert(attr < _TNL_MAX_ATTR_CODEGEN);
+
+ if (oldsz != sz) {
+ /* Reset any active pointers for this attribute
+ */
+ if (oldsz)
+ tnl->vtx.tabfv[attr][oldsz-1] = choose[attr][oldsz-1];
+
+ _tnl_fixup_vertex( ctx, attr, sz );
+
+ }
+
+
+ /* Try to use codegen:
+ */
+#ifdef USE_X86_ASM
+ if (tnl->AllowCodegen)
+ tnl->vtx.tabfv[attr][sz-1] = do_codegen( ctx, attr, sz );
+ else
+#endif
+ tnl->vtx.tabfv[attr][sz-1] = NULL;
+
+ /* Else use generic version:
+ */
+ if (!tnl->vtx.tabfv[attr][sz-1])
+ tnl->vtx.tabfv[attr][sz-1] = generic_attr_func[attr][sz-1];
+
+ return tnl->vtx.tabfv[attr][sz-1];
+}
+
+
+
+#define CHOOSE( ATTR, N ) \
+static void choose_##ATTR##_##N( const GLfloat *v ) \
+{ \
+ tnl_attrfv_func f = do_choose(ATTR, N); \
+ f( v ); \
+}
+
+#define CHOOSERS( ATTRIB ) \
+ CHOOSE( ATTRIB, 1 ) \
+ CHOOSE( ATTRIB, 2 ) \
+ CHOOSE( ATTRIB, 3 ) \
+ CHOOSE( ATTRIB, 4 ) \
+
+
+#define INIT_CHOOSERS(ATTR) \
+ choose[ATTR][0] = choose_##ATTR##_1; \
+ choose[ATTR][1] = choose_##ATTR##_2; \
+ choose[ATTR][2] = choose_##ATTR##_3; \
+ choose[ATTR][3] = choose_##ATTR##_4;
+
+CHOOSERS( 0 )
+CHOOSERS( 1 )
+CHOOSERS( 2 )
+CHOOSERS( 3 )
+CHOOSERS( 4 )
+CHOOSERS( 5 )
+CHOOSERS( 6 )
+CHOOSERS( 7 )
+CHOOSERS( 8 )
+CHOOSERS( 9 )
+CHOOSERS( 10 )
+CHOOSERS( 11 )
+CHOOSERS( 12 )
+CHOOSERS( 13 )
+CHOOSERS( 14 )
+CHOOSERS( 15 )
+
+static void error_attrib( const GLfloat *unused )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ (void) unused;
+ _mesa_error( ctx, GL_INVALID_ENUM, "glVertexAttrib" );
+}
+
+
+
+static void reset_attrfv( TNLcontext *tnl )
+{
+ GLuint i;
+
+ for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++)
+ if (tnl->vtx.attrsz[i]) {
+ GLint j = tnl->vtx.attrsz[i] - 1;
+ tnl->vtx.attrsz[i] = 0;
+
+ if (i < _TNL_MAX_ATTR_CODEGEN) {
+ while (j >= 0) {
+ tnl->vtx.tabfv[i][j] = choose[i][j];
+ j--;
+ }
+ }
+ }
+
+ tnl->vtx.vertex_size = 0;
+ tnl->vtx.have_materials = 0;
+}
+
+
+
+/* Materials:
+ *
+ * These are treated as per-vertex attributes, at indices above where
+ * the NV_vertex_program leaves off. There are a lot of good things
+ * about treating materials this way.
+ *
+ * However: I don't want to double the number of generated functions
+ * just to cope with this, so I unroll the 'C' varients of CHOOSE and
+ * ATTRF into this function, and dispense with codegen and
+ * second-level dispatch.
+ *
+ * There is no aliasing of material attributes with other entrypoints.
+ */
+#define OTHER_ATTR( A, N, params ) \
+do { \
+ if (tnl->vtx.attrsz[A] != N) { \
+ _tnl_fixup_vertex( ctx, A, N ); \
+ } \
+ \
+ { \
+ GLfloat *dest = tnl->vtx.attrptr[A]; \
+ if (N>0) dest[0] = (params)[0]; \
+ if (N>1) dest[1] = (params)[1]; \
+ if (N>2) dest[2] = (params)[2]; \
+ if (N>3) dest[3] = (params)[3]; \
+ } \
+} while (0)
+
+
+#define MAT( ATTR, N, face, params ) \
+do { \
+ if (face != GL_BACK) \
+ OTHER_ATTR( ATTR, N, params ); /* front */ \
+ if (face != GL_FRONT) \
+ OTHER_ATTR( ATTR + 1, N, params ); /* back */ \
+} while (0)
+
+
+/* Colormaterial is dealt with later on.
+ */
+static void GLAPIENTRY _tnl_Materialfv( GLenum face, GLenum pname,
+ const GLfloat *params )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ switch (face) {
+ case GL_FRONT:
+ case GL_BACK:
+ case GL_FRONT_AND_BACK:
+ break;
+
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glMaterialfv" );
+ return;
+ }
+
+ switch (pname) {
+ case GL_EMISSION:
+ MAT( _TNL_ATTRIB_MAT_FRONT_EMISSION, 4, face, params );
+ break;
+ case GL_AMBIENT:
+ MAT( _TNL_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params );
+ break;
+ case GL_DIFFUSE:
+ MAT( _TNL_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params );
+ break;
+ case GL_SPECULAR:
+ MAT( _TNL_ATTRIB_MAT_FRONT_SPECULAR, 4, face, params );
+ break;
+ case GL_SHININESS:
+ MAT( _TNL_ATTRIB_MAT_FRONT_SHININESS, 1, face, params );
+ break;
+ case GL_COLOR_INDEXES:
+ MAT( _TNL_ATTRIB_MAT_FRONT_INDEXES, 3, face, params );
+ break;
+ case GL_AMBIENT_AND_DIFFUSE:
+ MAT( _TNL_ATTRIB_MAT_FRONT_AMBIENT, 4, face, params );
+ MAT( _TNL_ATTRIB_MAT_FRONT_DIFFUSE, 4, face, params );
+ break;
+ default:
+ _mesa_error( ctx, GL_INVALID_ENUM, "glMaterialfv" );
+ return;
+ }
+
+ tnl->vtx.have_materials = GL_TRUE;
+}
+
+
+static void GLAPIENTRY _tnl_EdgeFlag( GLboolean b )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLfloat f = (GLfloat)b;
+
+ OTHER_ATTR( _TNL_ATTRIB_EDGEFLAG, 1, &f );
+}
+
+static void GLAPIENTRY _tnl_EdgeFlagv( const GLboolean *v )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLfloat f = (GLfloat)v[0];
+
+ OTHER_ATTR( _TNL_ATTRIB_EDGEFLAG, 1, &f );
+}
+
+static void GLAPIENTRY _tnl_Indexf( GLfloat f )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ OTHER_ATTR( _TNL_ATTRIB_INDEX, 1, &f );
+}
+
+static void GLAPIENTRY _tnl_Indexfv( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ OTHER_ATTR( _TNL_ATTRIB_INDEX, 1, v );
+}
+
+/* Eval
+ */
+static void GLAPIENTRY _tnl_EvalCoord1f( GLfloat u )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ /* TODO: use a CHOOSE() function for this: */
+ {
+ GLint i;
+ if (tnl->vtx.eval.new_state)
+ _tnl_update_eval( ctx );
+
+ for (i = 0 ; i <= _TNL_ATTRIB_INDEX ; i++) {
+ if (tnl->vtx.eval.map1[i].map)
+ if (tnl->vtx.attrsz[i] != tnl->vtx.eval.map1[i].sz)
+ _tnl_fixup_vertex( ctx, i, tnl->vtx.eval.map1[i].sz );
+ }
+ }
+
+
+ _mesa_memcpy( tnl->vtx.copied.buffer, tnl->vtx.vertex,
+ tnl->vtx.vertex_size * sizeof(GLfloat));
+
+ _tnl_do_EvalCoord1f( ctx, u );
+
+ _mesa_memcpy( tnl->vtx.vertex, tnl->vtx.copied.buffer,
+ tnl->vtx.vertex_size * sizeof(GLfloat));
+}
+
+static void GLAPIENTRY _tnl_EvalCoord2f( GLfloat u, GLfloat v )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ /* TODO: use a CHOOSE() function for this: */
+ {
+ GLint i;
+ if (tnl->vtx.eval.new_state)
+ _tnl_update_eval( ctx );
+
+ for (i = 0 ; i <= _TNL_ATTRIB_INDEX ; i++) {
+ if (tnl->vtx.eval.map2[i].map)
+ if (tnl->vtx.attrsz[i] != tnl->vtx.eval.map2[i].sz)
+ _tnl_fixup_vertex( ctx, i, tnl->vtx.eval.map2[i].sz );
+ }
+
+ if (ctx->Eval.AutoNormal)
+ if (tnl->vtx.attrsz[_TNL_ATTRIB_NORMAL] != 3)
+ _tnl_fixup_vertex( ctx, _TNL_ATTRIB_NORMAL, 3 );
+ }
+
+ _mesa_memcpy( tnl->vtx.copied.buffer, tnl->vtx.vertex,
+ tnl->vtx.vertex_size * sizeof(GLfloat));
+
+ _tnl_do_EvalCoord2f( ctx, u, v );
+
+ _mesa_memcpy( tnl->vtx.vertex, tnl->vtx.copied.buffer,
+ tnl->vtx.vertex_size * sizeof(GLfloat));
+}
+
+static void GLAPIENTRY _tnl_EvalCoord1fv( const GLfloat *u )
+{
+ _tnl_EvalCoord1f( u[0] );
+}
+
+static void GLAPIENTRY _tnl_EvalCoord2fv( const GLfloat *u )
+{
+ _tnl_EvalCoord2f( u[0], u[1] );
+}
+
+static void GLAPIENTRY _tnl_EvalPoint1( GLint i )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ GLfloat du = ((ctx->Eval.MapGrid1u2 - ctx->Eval.MapGrid1u1) /
+ (GLfloat) ctx->Eval.MapGrid1un);
+ GLfloat u = i * du + ctx->Eval.MapGrid1u1;
+
+ _tnl_EvalCoord1f( u );
+}
+
+
+static void GLAPIENTRY _tnl_EvalPoint2( GLint i, GLint j )
+{
+ GET_CURRENT_CONTEXT( ctx );
+ GLfloat du = ((ctx->Eval.MapGrid2u2 - ctx->Eval.MapGrid2u1) /
+ (GLfloat) ctx->Eval.MapGrid2un);
+ GLfloat dv = ((ctx->Eval.MapGrid2v2 - ctx->Eval.MapGrid2v1) /
+ (GLfloat) ctx->Eval.MapGrid2vn);
+ GLfloat u = i * du + ctx->Eval.MapGrid2u1;
+ GLfloat v = j * dv + ctx->Eval.MapGrid2v1;
+
+ _tnl_EvalCoord2f( u, v );
+}
+
+
+/* Build a list of primitives on the fly. Keep
+ * ctx->Driver.CurrentExecPrimitive uptodate as well.
+ */
+static void GLAPIENTRY _tnl_Begin( GLenum mode )
+{
+ GET_CURRENT_CONTEXT( ctx );
+
+ if (ctx->Driver.CurrentExecPrimitive == GL_POLYGON+1) {
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint i;
+
+ if (ctx->NewState) {
+ _mesa_update_state( ctx );
+
+ if ((ctx->VertexProgram.Enabled && !ctx->VertexProgram._Enabled) ||
+ (ctx->FragmentProgram.Enabled && !ctx->FragmentProgram._Enabled)) {
+ _mesa_error(ctx, GL_INVALID_OPERATION,
+ "glBegin (invalid vertex/fragment program)");
+ tnl->DiscardPrimitive = GL_TRUE;
+ return;
+ }
+
+ if (ctx->DrawBuffer->_Status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ _mesa_error(ctx, GL_INVALID_FRAMEBUFFER_OPERATION_EXT,
+ "glBegin(incomplete framebuffer)");
+ tnl->DiscardPrimitive = GL_TRUE;
+ return;
+ }
+
+ tnl->DiscardPrimitive = GL_FALSE;
+
+ if (!(tnl->Driver.NotifyBegin &&
+ tnl->Driver.NotifyBegin( ctx, mode )))
+ CALL_Begin(ctx->Exec, (mode));
+ return;
+ }
+
+ /* Heuristic: attempt to isolate attributes occuring outside
+ * begin/end pairs.
+ */
+ if (tnl->vtx.vertex_size && !tnl->vtx.attrsz[0])
+ _tnl_FlushVertices( ctx, ~0 );
+
+ i = tnl->vtx.prim_count++;
+ tnl->vtx.prim[i].mode = mode | PRIM_BEGIN;
+ tnl->vtx.prim[i].start = tnl->vtx.initial_counter - tnl->vtx.counter;
+ tnl->vtx.prim[i].count = 0;
+
+ ctx->Driver.CurrentExecPrimitive = mode;
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glBegin" );
+
+}
+
+static void GLAPIENTRY _tnl_End( void )
+{
+ GET_CURRENT_CONTEXT( ctx );
+
+ if (ctx->Driver.CurrentExecPrimitive != GL_POLYGON+1) {
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ int idx = tnl->vtx.initial_counter - tnl->vtx.counter;
+ int i = tnl->vtx.prim_count - 1;
+
+ tnl->vtx.prim[i].mode |= PRIM_END;
+ tnl->vtx.prim[i].count = idx - tnl->vtx.prim[i].start;
+
+ ctx->Driver.CurrentExecPrimitive = GL_POLYGON+1;
+
+ /* Two choices which effect the way vertex attributes are
+ * carried over (or not) between adjacent primitives.
+ */
+#if 0
+ if (tnl->vtx.prim_count == TNL_MAX_PRIM)
+ _tnl_FlushVertices( ctx, ~0 );
+#else
+ if (tnl->vtx.prim_count == TNL_MAX_PRIM)
+ _tnl_flush_vtx( ctx );
+#endif
+
+ }
+ else
+ _mesa_error( ctx, GL_INVALID_OPERATION, "glEnd" );
+}
+
+
+static void _tnl_exec_vtxfmt_init( GLcontext *ctx )
+{
+ GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->exec_vtxfmt);
+
+ vfmt->ArrayElement = _ae_loopback_array_elt; /* generic helper */
+ vfmt->Begin = _tnl_Begin;
+ vfmt->CallList = _mesa_CallList;
+ vfmt->CallLists = _mesa_CallLists;
+ vfmt->EdgeFlag = _tnl_EdgeFlag;
+ vfmt->EdgeFlagv = _tnl_EdgeFlagv;
+ vfmt->End = _tnl_End;
+ vfmt->EvalCoord1f = _tnl_EvalCoord1f;
+ vfmt->EvalCoord1fv = _tnl_EvalCoord1fv;
+ vfmt->EvalCoord2f = _tnl_EvalCoord2f;
+ vfmt->EvalCoord2fv = _tnl_EvalCoord2fv;
+ vfmt->EvalPoint1 = _tnl_EvalPoint1;
+ vfmt->EvalPoint2 = _tnl_EvalPoint2;
+ vfmt->Indexf = _tnl_Indexf;
+ vfmt->Indexfv = _tnl_Indexfv;
+ vfmt->Materialfv = _tnl_Materialfv;
+
+ vfmt->Rectf = _mesa_noop_Rectf;
+ vfmt->EvalMesh1 = _mesa_noop_EvalMesh1;
+ vfmt->EvalMesh2 = _mesa_noop_EvalMesh2;
+}
+
+
+
+void _tnl_FlushVertices( GLcontext *ctx, GLuint flags )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ (void) flags;
+
+ if (ctx->Driver.CurrentExecPrimitive != PRIM_OUTSIDE_BEGIN_END) {
+ /* still inside a glBegin/End pair. How'd we get here??? */
+ return;
+ }
+
+ if (tnl->DiscardPrimitive) {
+ /* discard any primitives */
+ tnl->vtx.prim_count = 0;
+ tnl->vtx.counter = tnl->vtx.initial_counter;
+ tnl->vtx.vbptr = tnl->vtx.buffer;
+ }
+
+ if (tnl->vtx.counter != tnl->vtx.initial_counter) {
+ _tnl_flush_vtx( ctx );
+ }
+
+ if (tnl->vtx.vertex_size) {
+ _tnl_copy_to_current( ctx );
+ reset_attrfv( tnl );
+ }
+
+ ctx->Driver.NeedFlush = 0;
+}
+
+
+static void _tnl_current_init( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLint i;
+
+ /* setup the pointers for the typical 16 vertex attributes */
+ for (i = 0; i < VERT_ATTRIB_MAX; i++)
+ tnl->vtx.current[i] = ctx->Current.Attrib[i];
+
+ /* setup pointers for the 12 material attributes */
+ for (i = 0; i < MAT_ATTRIB_MAX; i++)
+ tnl->vtx.current[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] =
+ ctx->Light.Material.Attrib[i];
+
+ tnl->vtx.current[_TNL_ATTRIB_INDEX] = &ctx->Current.Index;
+ tnl->vtx.current[_TNL_ATTRIB_EDGEFLAG] = &tnl->vtx.CurrentFloatEdgeFlag;
+}
+
+static struct _tnl_dynfn *no_codegen( GLcontext *ctx, int key )
+{
+ (void) ctx; (void) key;
+ return NULL;
+}
+
+void _tnl_vtx_init( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct tnl_vertex_arrays *tmp = &tnl->vtx_inputs;
+ GLuint i;
+ static int firsttime = 1;
+
+ if (firsttime) {
+ firsttime = 0;
+
+ INIT_CHOOSERS( 0 );
+ INIT_CHOOSERS( 1 );
+ INIT_CHOOSERS( 2 );
+ INIT_CHOOSERS( 3 );
+ INIT_CHOOSERS( 4 );
+ INIT_CHOOSERS( 5 );
+ INIT_CHOOSERS( 6 );
+ INIT_CHOOSERS( 7 );
+ INIT_CHOOSERS( 8 );
+ INIT_CHOOSERS( 9 );
+ INIT_CHOOSERS( 10 );
+ INIT_CHOOSERS( 11 );
+ INIT_CHOOSERS( 12 );
+ INIT_CHOOSERS( 13 );
+ INIT_CHOOSERS( 14 );
+ INIT_CHOOSERS( 15 );
+
+ choose[ERROR_ATTRIB][0] = error_attrib;
+ choose[ERROR_ATTRIB][1] = error_attrib;
+ choose[ERROR_ATTRIB][2] = error_attrib;
+ choose[ERROR_ATTRIB][3] = error_attrib;
+
+#ifdef USE_X86_ASM
+ if (tnl->AllowCodegen) {
+ _tnl_x86choosers(choose, do_choose); /* x86 INIT_CHOOSERS */
+ }
+#endif
+
+ _tnl_generic_attr_table_init( generic_attr_func );
+ }
+
+ for (i = 0; i < _TNL_ATTRIB_INDEX; i++)
+ _mesa_vector4f_init( &tmp->Attribs[i], 0, NULL);
+
+ for (i = 0; i < 4; i++) {
+ make_empty_list( &tnl->vtx.cache.Vertex[i] );
+ make_empty_list( &tnl->vtx.cache.Attribute[i] );
+ tnl->vtx.gen.Vertex[i] = no_codegen;
+ tnl->vtx.gen.Attribute[i] = no_codegen;
+ }
+
+#ifdef USE_X86_ASM
+ _tnl_InitX86Codegen( &tnl->vtx.gen );
+#endif
+
+ _tnl_current_init( ctx );
+ _tnl_exec_vtxfmt_init( ctx );
+ _tnl_generic_exec_vtxfmt_init( ctx );
+#ifdef USE_X86_ASM
+ if (tnl->AllowCodegen) {
+ _tnl_x86_exec_vtxfmt_init( ctx ); /* x86 DISPATCH_ATTRFV */
+ }
+#endif
+
+ _mesa_install_exec_vtxfmt( ctx, &tnl->exec_vtxfmt );
+
+ memcpy( tnl->vtx.tabfv, choose, sizeof(choose) );
+
+ for (i = 0 ; i < _TNL_ATTRIB_MAX ; i++)
+ tnl->vtx.attrsz[i] = 0;
+
+ tnl->vtx.vertex_size = 0;
+ tnl->vtx.have_materials = 0;
+}
+
+static void free_funcs( struct _tnl_dynfn *l )
+{
+ struct _tnl_dynfn *f, *tmp;
+ foreach_s (f, tmp, l) {
+ remove_from_list( f );
+ ALIGN_FREE( f->code );
+ FREE( f );
+ }
+}
+
+
+void _tnl_vtx_destroy( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint i;
+
+ for (i = 0; i < 4; i++) {
+ free_funcs( &tnl->vtx.cache.Vertex[i] );
+ free_funcs( &tnl->vtx.cache.Attribute[i] );
+ }
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_api.h b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_api.h
new file mode 100644
index 000000000..9818c082b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_api.h
@@ -0,0 +1,90 @@
+/* $XFree86$ */
+/**************************************************************************
+
+Copyright 2002 Tungsten Graphics 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
+TUNGSTEN GRAPHICS 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ *
+ */
+
+#ifndef __T_VTX_API_H__
+#define __T_VTX_API_H__
+
+#include "t_context.h"
+
+#define ERROR_ATTRIB 16
+
+
+
+/* t_vtx_api.c:
+ */
+extern void _tnl_vtx_init( GLcontext *ctx );
+extern void _tnl_vtx_destroy( GLcontext *ctx );
+
+extern void _tnl_FlushVertices( GLcontext *ctx, GLuint flags );
+extern void _tnl_flush_vtx( GLcontext *ctx );
+
+extern void GLAPIENTRY _tnl_wrap_filled_vertex( GLcontext *ctx );
+
+/* t_vtx_exec.c:
+ */
+
+extern void _tnl_do_EvalCoord2f( GLcontext* ctx, GLfloat u, GLfloat v );
+extern void _tnl_do_EvalCoord1f(GLcontext* ctx, GLfloat u);
+extern void _tnl_update_eval( GLcontext *ctx );
+
+extern GLboolean *_tnl_translate_edgeflag( GLcontext *ctx,
+ const GLfloat *data,
+ GLuint count,
+ GLuint stride );
+
+extern GLboolean *_tnl_import_current_edgeflag( GLcontext *ctx,
+ GLuint count );
+
+
+
+/* t_vtx_generic.c:
+ */
+extern void _tnl_generic_exec_vtxfmt_init( GLcontext *ctx );
+
+extern void _tnl_generic_attr_table_init( tnl_attrfv_func (*tab)[4] );
+
+/* t_vtx_x86.c:
+ */
+extern void _tnl_InitX86Codegen( struct _tnl_dynfn_generators *gen );
+
+extern void _tnl_x86_exec_vtxfmt_init( GLcontext *ctx );
+
+extern void _tnl_x86choosers( tnl_attrfv_func (*choose)[4],
+ tnl_attrfv_func (*do_choose)( GLuint attr,
+ GLuint sz ));
+
+
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_eval.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_eval.c
new file mode 100644
index 000000000..d948e700b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_eval.c
@@ -0,0 +1,254 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "api_eval.h"
+#include "context.h"
+#include "macros.h"
+#include "math/m_eval.h"
+#include "t_vtx_api.h"
+#include "dispatch.h"
+
+
+static void clear_active_eval1( TNLcontext *tnl, GLuint attr )
+{
+ tnl->vtx.eval.map1[attr].map = NULL;
+}
+
+static void clear_active_eval2( TNLcontext *tnl, GLuint attr )
+{
+ tnl->vtx.eval.map2[attr].map = NULL;
+}
+
+static void set_active_eval1( TNLcontext *tnl, GLuint attr, GLuint dim,
+ struct gl_1d_map *map )
+{
+ if (!tnl->vtx.eval.map1[attr].map) {
+ tnl->vtx.eval.map1[attr].map = map;
+ tnl->vtx.eval.map1[attr].sz = dim;
+ }
+}
+
+static void set_active_eval2( TNLcontext *tnl, GLuint attr, GLuint dim,
+ struct gl_2d_map *map )
+{
+ if (!tnl->vtx.eval.map2[attr].map) {
+ tnl->vtx.eval.map2[attr].map = map;
+ tnl->vtx.eval.map2[attr].sz = dim;
+ }
+}
+
+void _tnl_update_eval( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint attr;
+
+ /* Vertex program maps have priority over conventional attribs */
+
+ for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
+ clear_active_eval1( tnl, attr );
+ clear_active_eval2( tnl, attr );
+ }
+
+ if (ctx->VertexProgram._Enabled) {
+ for (attr = 0; attr < VERT_ATTRIB_MAX; attr++) {
+ if (ctx->Eval.Map1Attrib[attr])
+ set_active_eval1( tnl, attr, 4, &ctx->EvalMap.Map1Attrib[attr] );
+
+ if (ctx->Eval.Map2Attrib[attr])
+ set_active_eval2( tnl, attr, 4, &ctx->EvalMap.Map2Attrib[attr] );
+ }
+ }
+
+ if (ctx->Eval.Map1Color4)
+ set_active_eval1( tnl, VERT_ATTRIB_COLOR0, 4, &ctx->EvalMap.Map1Color4 );
+
+ if (ctx->Eval.Map2Color4)
+ set_active_eval2( tnl, VERT_ATTRIB_COLOR0, 4, &ctx->EvalMap.Map2Color4 );
+
+ if (ctx->Eval.Map1TextureCoord4)
+ set_active_eval1( tnl, VERT_ATTRIB_TEX0, 4, &ctx->EvalMap.Map1Texture4 );
+ else if (ctx->Eval.Map1TextureCoord3)
+ set_active_eval1( tnl, VERT_ATTRIB_TEX0, 3, &ctx->EvalMap.Map1Texture3 );
+ else if (ctx->Eval.Map1TextureCoord2)
+ set_active_eval1( tnl, VERT_ATTRIB_TEX0, 2, &ctx->EvalMap.Map1Texture2 );
+ else if (ctx->Eval.Map1TextureCoord1)
+ set_active_eval1( tnl, VERT_ATTRIB_TEX0, 1, &ctx->EvalMap.Map1Texture1 );
+
+ if (ctx->Eval.Map2TextureCoord4)
+ set_active_eval2( tnl, VERT_ATTRIB_TEX0, 4, &ctx->EvalMap.Map2Texture4 );
+ else if (ctx->Eval.Map2TextureCoord3)
+ set_active_eval2( tnl, VERT_ATTRIB_TEX0, 3, &ctx->EvalMap.Map2Texture3 );
+ else if (ctx->Eval.Map2TextureCoord2)
+ set_active_eval2( tnl, VERT_ATTRIB_TEX0, 2, &ctx->EvalMap.Map2Texture2 );
+ else if (ctx->Eval.Map2TextureCoord1)
+ set_active_eval2( tnl, VERT_ATTRIB_TEX0, 1, &ctx->EvalMap.Map2Texture1 );
+
+ if (ctx->Eval.Map1Normal)
+ set_active_eval1( tnl, VERT_ATTRIB_NORMAL, 3, &ctx->EvalMap.Map1Normal );
+
+ if (ctx->Eval.Map2Normal)
+ set_active_eval2( tnl, VERT_ATTRIB_NORMAL, 3, &ctx->EvalMap.Map2Normal );
+
+ if (ctx->Eval.Map1Vertex4)
+ set_active_eval1( tnl, VERT_ATTRIB_POS, 4, &ctx->EvalMap.Map1Vertex4 );
+ else if (ctx->Eval.Map1Vertex3)
+ set_active_eval1( tnl, VERT_ATTRIB_POS, 3, &ctx->EvalMap.Map1Vertex3 );
+
+ if (ctx->Eval.Map2Vertex4)
+ set_active_eval2( tnl, VERT_ATTRIB_POS, 4, &ctx->EvalMap.Map2Vertex4 );
+ else if (ctx->Eval.Map2Vertex3)
+ set_active_eval2( tnl, VERT_ATTRIB_POS, 3, &ctx->EvalMap.Map2Vertex3 );
+
+ tnl->vtx.eval.new_state = 0;
+}
+
+
+
+void _tnl_do_EvalCoord1f(GLcontext* ctx, GLfloat u)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint attr;
+
+ for (attr = 1; attr <= _TNL_ATTRIB_INDEX; attr++) {
+ struct gl_1d_map *map = tnl->vtx.eval.map1[attr].map;
+ if (map) {
+ GLfloat uu = (u - map->u1) * map->du;
+ GLfloat data[4];
+
+ ASSIGN_4V(data, 0, 0, 0, 1);
+
+ _math_horner_bezier_curve(map->Points, data, uu,
+ tnl->vtx.eval.map1[attr].sz,
+ map->Order);
+
+ COPY_SZ_4V( tnl->vtx.attrptr[attr],
+ tnl->vtx.attrsz[attr],
+ data );
+ }
+ }
+
+ /** Vertex -- EvalCoord1f is a noop if this map not enabled:
+ **/
+ if (tnl->vtx.eval.map1[0].map) {
+ struct gl_1d_map *map = tnl->vtx.eval.map1[0].map;
+ GLfloat uu = (u - map->u1) * map->du;
+ GLfloat vertex[4];
+
+ ASSIGN_4V(vertex, 0, 0, 0, 1);
+
+ _math_horner_bezier_curve(map->Points, vertex, uu,
+ tnl->vtx.eval.map1[0].sz,
+ map->Order);
+
+ if (tnl->vtx.eval.map1[0].sz == 4)
+ CALL_Vertex4fv(GET_DISPATCH(), ( vertex ));
+ else
+ CALL_Vertex3fv(GET_DISPATCH(), ( vertex ));
+ }
+}
+
+
+
+void _tnl_do_EvalCoord2f( GLcontext* ctx, GLfloat u, GLfloat v )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint attr;
+
+ for (attr = 1; attr <= _TNL_ATTRIB_INDEX; attr++) {
+ struct gl_2d_map *map = tnl->vtx.eval.map2[attr].map;
+ if (map) {
+ GLfloat uu = (u - map->u1) * map->du;
+ GLfloat vv = (v - map->v1) * map->dv;
+ GLfloat data[4];
+
+ ASSIGN_4V(data, 0, 0, 0, 1);
+
+ _math_horner_bezier_surf(map->Points,
+ data,
+ uu, vv,
+ tnl->vtx.eval.map2[attr].sz,
+ map->Uorder, map->Vorder);
+
+ COPY_SZ_4V( tnl->vtx.attrptr[attr],
+ tnl->vtx.attrsz[attr],
+ data );
+ }
+ }
+
+ /** Vertex -- EvalCoord2f is a noop if this map not enabled:
+ **/
+ if (tnl->vtx.eval.map2[0].map) {
+ struct gl_2d_map *map = tnl->vtx.eval.map2[0].map;
+ GLfloat uu = (u - map->u1) * map->du;
+ GLfloat vv = (v - map->v1) * map->dv;
+ GLfloat vertex[4];
+
+ ASSIGN_4V(vertex, 0, 0, 0, 1);
+
+ if (ctx->Eval.AutoNormal) {
+ GLfloat normal[4];
+ GLfloat du[4], dv[4];
+
+ _math_de_casteljau_surf(map->Points, vertex, du, dv, uu, vv,
+ tnl->vtx.eval.map2[0].sz,
+ map->Uorder, map->Vorder);
+
+ if (tnl->vtx.eval.map2[0].sz == 4) {
+ du[0] = du[0]*vertex[3] - du[3]*vertex[0];
+ du[1] = du[1]*vertex[3] - du[3]*vertex[1];
+ du[2] = du[2]*vertex[3] - du[3]*vertex[2];
+
+ dv[0] = dv[0]*vertex[3] - dv[3]*vertex[0];
+ dv[1] = dv[1]*vertex[3] - dv[3]*vertex[1];
+ dv[2] = dv[2]*vertex[3] - dv[3]*vertex[2];
+ }
+
+
+ CROSS3(normal, du, dv);
+ NORMALIZE_3FV(normal);
+ normal[3] = 1.0;
+
+ COPY_SZ_4V( tnl->vtx.attrptr[_TNL_ATTRIB_NORMAL],
+ tnl->vtx.attrsz[_TNL_ATTRIB_NORMAL],
+ normal );
+
+ }
+ else {
+ _math_horner_bezier_surf(map->Points, vertex, uu, vv,
+ tnl->vtx.eval.map2[0].sz,
+ map->Uorder, map->Vorder);
+ }
+
+ if (tnl->vtx.attrsz[0] == 4)
+ CALL_Vertex4fv(GET_DISPATCH(), ( vertex ));
+ else
+ CALL_Vertex3fv(GET_DISPATCH(), ( vertex ));
+ }
+}
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_exec.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_exec.c
new file mode 100644
index 000000000..ef609781c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_exec.c
@@ -0,0 +1,284 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "api_eval.h"
+#include "context.h"
+#include "enums.h"
+#include "state.h"
+#include "macros.h"
+#include "math/m_eval.h"
+#include "t_vtx_api.h"
+#include "t_pipeline.h"
+
+
+static void _tnl_print_vtx( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint count = tnl->vtx.initial_counter - tnl->vtx.counter;
+ GLuint i;
+
+ _mesa_debug(ctx, "_tnl_print_vtx: %u vertices %d primitives, %d vertsize\n",
+ count,
+ tnl->vtx.prim_count,
+ tnl->vtx.vertex_size);
+
+ for (i = 0 ; i < tnl->vtx.prim_count ; i++) {
+ struct tnl_prim *prim = &tnl->vtx.prim[i];
+ _mesa_debug(NULL, " prim %d: %s %d..%d %s %s\n",
+ i,
+ _mesa_lookup_enum_by_nr(prim->mode & PRIM_MODE_MASK),
+ prim->start,
+ prim->start + prim->count,
+ (prim->mode & PRIM_BEGIN) ? "BEGIN" : "(wrap)",
+ (prim->mode & PRIM_END) ? "END" : "(wrap)");
+ }
+}
+
+GLboolean *_tnl_translate_edgeflag( GLcontext *ctx, const GLfloat *data,
+ GLuint count, GLuint stride )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLboolean *ef = tnl->vtx.edgeflag_tmp;
+ GLuint i;
+
+ if (!ef)
+ ef = tnl->vtx.edgeflag_tmp = (GLboolean *) MALLOC( tnl->vb.Size );
+
+ for (i = 0 ; i < count ; i++, data += stride)
+ ef[i] = (data[0] == 1.0);
+
+ return ef;
+}
+
+
+GLboolean *_tnl_import_current_edgeflag( GLcontext *ctx,
+ GLuint count )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLboolean *ef = tnl->vtx.edgeflag_tmp;
+ GLboolean tmp = ctx->Current.EdgeFlag;
+ GLuint i;
+
+ if (!ef)
+ ef = tnl->vtx.edgeflag_tmp = (GLboolean *) MALLOC( tnl->vb.Size );
+
+ for (i = 0 ; i < count ; i++)
+ ef[i] = tmp;
+
+ return ef;
+}
+
+static INLINE GLint get_size( const GLfloat *f )
+{
+ if (f[3] != 1.0) return 4;
+ if (f[2] != 0.0) return 3;
+ return 2;
+}
+
+/* Some nasty stuff still hanging on here.
+ *
+ * TODO - remove VB->NormalPtr, etc and just use the AttrPtr's.
+ */
+static void _tnl_vb_bind_vtx( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ struct tnl_vertex_arrays *tmp = &tnl->vtx_inputs;
+ GLfloat *data = tnl->vtx.buffer;
+ GLuint count = tnl->vtx.initial_counter - tnl->vtx.counter;
+ GLuint attr, i;
+
+ if (0) fprintf(stderr, "_tnl_vb_bind_vtx(): %d verts %d vertsize\n",
+ count, tnl->vtx.vertex_size);
+
+
+ /* Setup constant data in the VB.
+ */
+ VB->Count = count;
+ VB->Primitive = tnl->vtx.prim;
+ VB->PrimitiveCount = tnl->vtx.prim_count;
+ VB->Elts = NULL;
+ VB->NormalLengthPtr = NULL;
+
+ for (attr = 0; attr <= _TNL_ATTRIB_INDEX ; attr++) {
+ if (tnl->vtx.attrsz[attr]) {
+ tmp->Attribs[attr].count = count;
+ tmp->Attribs[attr].data = (GLfloat (*)[4]) data;
+ tmp->Attribs[attr].start = data;
+ tmp->Attribs[attr].size = tnl->vtx.attrsz[attr];
+ tmp->Attribs[attr].stride = tnl->vtx.vertex_size * sizeof(GLfloat);
+ VB->AttribPtr[attr] = &tmp->Attribs[attr];
+ data += tnl->vtx.attrsz[attr];
+ }
+ else {
+/* VB->AttribPtr[attr] = &tnl->current.Attribs[attr]; */
+
+
+ tmp->Attribs[attr].count = 1;
+ tmp->Attribs[attr].data = (GLfloat (*)[4]) tnl->vtx.current[attr];
+ tmp->Attribs[attr].start = tnl->vtx.current[attr];
+ tmp->Attribs[attr].size = get_size( tnl->vtx.current[attr] );
+ tmp->Attribs[attr].stride = 0;
+ VB->AttribPtr[attr] = &tmp->Attribs[attr];
+ }
+ }
+
+
+ /* Copy and translate EdgeFlag to a contiguous array of GLbooleans
+ */
+ if (ctx->Polygon.FrontMode != GL_FILL || ctx->Polygon.BackMode != GL_FILL) {
+ if (tnl->vtx.attrsz[_TNL_ATTRIB_EDGEFLAG]) {
+ VB->EdgeFlag = _tnl_translate_edgeflag( ctx, data, count,
+ tnl->vtx.vertex_size );
+ data++;
+ }
+ else
+ VB->EdgeFlag = _tnl_import_current_edgeflag( ctx, count );
+ }
+
+ /* Legacy pointers -- remove one day.
+ */
+ VB->ObjPtr = VB->AttribPtr[_TNL_ATTRIB_POS];
+ VB->NormalPtr = VB->AttribPtr[_TNL_ATTRIB_NORMAL];
+ VB->ColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR0];
+ VB->ColorPtr[1] = NULL;
+ VB->IndexPtr[0] = VB->AttribPtr[_TNL_ATTRIB_INDEX];
+ VB->IndexPtr[1] = NULL;
+ VB->SecondaryColorPtr[0] = VB->AttribPtr[_TNL_ATTRIB_COLOR1];
+ VB->SecondaryColorPtr[1] = NULL;
+ VB->FogCoordPtr = VB->AttribPtr[_TNL_ATTRIB_FOG];
+
+ for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
+ VB->TexCoordPtr[i] = VB->AttribPtr[_TNL_ATTRIB_TEX0 + i];
+ }
+}
+
+
+/*
+ * NOTE: Need to have calculated primitives by this point -- do it on the fly.
+ * NOTE: Old 'parity' issue is gone.
+ */
+static GLuint _tnl_copy_vertices( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT( ctx );
+ GLuint nr = tnl->vtx.prim[tnl->vtx.prim_count-1].count;
+ GLuint ovf, i;
+ GLuint sz = tnl->vtx.vertex_size;
+ GLfloat *dst = tnl->vtx.copied.buffer;
+ GLfloat *src = (tnl->vtx.buffer +
+ tnl->vtx.prim[tnl->vtx.prim_count-1].start *
+ tnl->vtx.vertex_size);
+
+
+ switch( ctx->Driver.CurrentExecPrimitive )
+ {
+ case GL_POINTS:
+ return 0;
+ case GL_LINES:
+ ovf = nr&1;
+ for (i = 0 ; i < ovf ; i++)
+ _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) );
+ return i;
+ case GL_TRIANGLES:
+ ovf = nr%3;
+ for (i = 0 ; i < ovf ; i++)
+ _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) );
+ return i;
+ case GL_QUADS:
+ ovf = nr&3;
+ for (i = 0 ; i < ovf ; i++)
+ _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) );
+ return i;
+ case GL_LINE_STRIP:
+ if (nr == 0)
+ return 0;
+ else {
+ _mesa_memcpy( dst, src+(nr-1)*sz, sz * sizeof(GLfloat) );
+ return 1;
+ }
+ case GL_LINE_LOOP:
+ case GL_TRIANGLE_FAN:
+ case GL_POLYGON:
+ if (nr == 0)
+ return 0;
+ else if (nr == 1) {
+ _mesa_memcpy( dst, src+0, sz * sizeof(GLfloat) );
+ return 1;
+ } else {
+ _mesa_memcpy( dst, src+0, sz * sizeof(GLfloat) );
+ _mesa_memcpy( dst+sz, src+(nr-1)*sz, sz * sizeof(GLfloat) );
+ return 2;
+ }
+ case GL_TRIANGLE_STRIP:
+ case GL_QUAD_STRIP:
+ switch (nr) {
+ case 0: ovf = 0; break;
+ case 1: ovf = 1; break;
+ default: ovf = 2 + (nr&1); break;
+ }
+ for (i = 0 ; i < ovf ; i++)
+ _mesa_memcpy( dst+i*sz, src+(nr-ovf+i)*sz, sz * sizeof(GLfloat) );
+ return i;
+ case GL_POLYGON+1:
+ return 0;
+ default:
+ assert(0);
+ return 0;
+ }
+}
+
+
+/**
+ * Execute the buffer and save copied verts.
+ */
+void _tnl_flush_vtx( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint vertex_count = tnl->vtx.initial_counter - tnl->vtx.counter;
+
+ if (0)
+ _tnl_print_vtx( ctx );
+
+ if (tnl->vtx.prim_count && vertex_count) {
+
+ tnl->vtx.copied.nr = _tnl_copy_vertices( ctx );
+
+ if (tnl->vtx.copied.nr != vertex_count) {
+ if (ctx->NewState)
+ _mesa_update_state( ctx );
+
+ _tnl_vb_bind_vtx( ctx );
+
+ tnl->Driver.RunPipeline( ctx );
+ }
+ }
+
+ tnl->vtx.prim_count = 0;
+ tnl->vtx.counter = tnl->vtx.initial_counter;
+ tnl->vtx.vbptr = tnl->vtx.buffer;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_generic.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_generic.c
new file mode 100644
index 000000000..0422fcd45
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_generic.c
@@ -0,0 +1,538 @@
+/**************************************************************************
+
+Copyright 2004 Tungsten Graphics 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, TUNGSTEN GRAPHICS 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "vtxfmt.h"
+#include "dlist.h"
+#include "state.h"
+#include "light.h"
+#include "api_arrayelt.h"
+#include "api_noop.h"
+#include "t_vtx_api.h"
+
+
+/* Versions of all the entrypoints for situations where codegen isn't
+ * available.
+ *
+ * Note: Only one size for each attribute may be active at once.
+ * Eg. if Color3f is installed/active, then Color4f may not be, even
+ * if the vertex actually contains 4 color coordinates. This is
+ * because the 3f version won't otherwise set color[3] to 1.0 -- this
+ * is the job of the chooser function when switching between Color4f
+ * and Color3f.
+ */
+#define ATTRFV( ATTR, N ) \
+static void attrib_##ATTR##_##N( const GLfloat *v ) \
+{ \
+ GET_CURRENT_CONTEXT( ctx ); \
+ TNLcontext *tnl = TNL_CONTEXT(ctx); \
+ \
+ if ((ATTR) == 0) { \
+ GLuint i; \
+ \
+ if (N>0) tnl->vtx.vbptr[0] = v[0]; \
+ if (N>1) tnl->vtx.vbptr[1] = v[1]; \
+ if (N>2) tnl->vtx.vbptr[2] = v[2]; \
+ if (N>3) tnl->vtx.vbptr[3] = v[3]; \
+ \
+ for (i = N; i < tnl->vtx.vertex_size; i++) \
+ tnl->vtx.vbptr[i] = tnl->vtx.vertex[i]; \
+ \
+ tnl->vtx.vbptr += tnl->vtx.vertex_size; \
+ \
+ if (--tnl->vtx.counter == 0) \
+ _tnl_wrap_filled_vertex( ctx ); \
+ } \
+ else { \
+ GLfloat *dest = tnl->vtx.attrptr[ATTR]; \
+ if (N>0) dest[0] = v[0]; \
+ if (N>1) dest[1] = v[1]; \
+ if (N>2) dest[2] = v[2]; \
+ if (N>3) dest[3] = v[3]; \
+ } \
+}
+
+#define INIT(TAB, ATTR) \
+ TAB[ATTR][0] = attrib_##ATTR##_1; \
+ TAB[ATTR][1] = attrib_##ATTR##_2; \
+ TAB[ATTR][2] = attrib_##ATTR##_3; \
+ TAB[ATTR][3] = attrib_##ATTR##_4;
+
+
+#define ATTRS( ATTRIB ) \
+ ATTRFV( ATTRIB, 1 ) \
+ ATTRFV( ATTRIB, 2 ) \
+ ATTRFV( ATTRIB, 3 ) \
+ ATTRFV( ATTRIB, 4 )
+
+ATTRS( 0 )
+ATTRS( 1 )
+ATTRS( 2 )
+ATTRS( 3 )
+ATTRS( 4 )
+ATTRS( 5 )
+ATTRS( 6 )
+ATTRS( 7 )
+ATTRS( 8 )
+ATTRS( 9 )
+ATTRS( 10 )
+ATTRS( 11 )
+ATTRS( 12 )
+ATTRS( 13 )
+ATTRS( 14 )
+ATTRS( 15 )
+
+void _tnl_generic_attr_table_init( tnl_attrfv_func (*tab)[4] )
+{
+ INIT( tab, 0 );
+ INIT( tab, 1 );
+ INIT( tab, 2 );
+ INIT( tab, 3 );
+ INIT( tab, 4 );
+ INIT( tab, 5 );
+ INIT( tab, 6 );
+ INIT( tab, 7 );
+ INIT( tab, 8 );
+ INIT( tab, 9 );
+ INIT( tab, 10 );
+ INIT( tab, 11 );
+ INIT( tab, 12 );
+ INIT( tab, 13 );
+ INIT( tab, 14 );
+ INIT( tab, 15 );
+}
+
+/* These can be made efficient with codegen. Further, by adding more
+ * logic to do_choose(), the double-dispatch for legacy entrypoints
+ * like glVertex3f() can be removed.
+ */
+#define DISPATCH_ATTRFV( ATTR, COUNT, P ) \
+do { \
+ GET_CURRENT_CONTEXT( ctx ); \
+ TNLcontext *tnl = TNL_CONTEXT(ctx); \
+ tnl->vtx.tabfv[ATTR][COUNT-1]( P ); \
+} while (0)
+
+#define DISPATCH_ATTR1FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 1, V )
+#define DISPATCH_ATTR2FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 2, V )
+#define DISPATCH_ATTR3FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 3, V )
+#define DISPATCH_ATTR4FV( ATTR, V ) DISPATCH_ATTRFV( ATTR, 4, V )
+
+#define DISPATCH_ATTR1F( ATTR, S ) DISPATCH_ATTRFV( ATTR, 1, &(S) )
+
+#if defined(USE_X86_ASM) && 0 /* will break register calling convention */
+/* Naughty cheat:
+ */
+#define DISPATCH_ATTR2F( ATTR, S,T ) DISPATCH_ATTRFV( ATTR, 2, &(S) )
+#define DISPATCH_ATTR3F( ATTR, S,T,R ) DISPATCH_ATTRFV( ATTR, 3, &(S) )
+#define DISPATCH_ATTR4F( ATTR, S,T,R,Q ) DISPATCH_ATTRFV( ATTR, 4, &(S) )
+#else
+/* Safe:
+ */
+#define DISPATCH_ATTR2F( ATTR, S,T ) \
+do { \
+ GLfloat v[2]; \
+ v[0] = S; v[1] = T; \
+ DISPATCH_ATTR2FV( ATTR, v ); \
+} while (0)
+#define DISPATCH_ATTR3F( ATTR, S,T,R ) \
+do { \
+ GLfloat v[3]; \
+ v[0] = S; v[1] = T; v[2] = R; \
+ DISPATCH_ATTR3FV( ATTR, v ); \
+} while (0)
+#define DISPATCH_ATTR4F( ATTR, S,T,R,Q ) \
+do { \
+ GLfloat v[4]; \
+ v[0] = S; v[1] = T; v[2] = R; v[3] = Q; \
+ DISPATCH_ATTR4FV( ATTR, v ); \
+} while (0)
+#endif
+
+
+static void GLAPIENTRY _tnl_Vertex2f( GLfloat x, GLfloat y )
+{
+ DISPATCH_ATTR2F( _TNL_ATTRIB_POS, x, y );
+}
+
+static void GLAPIENTRY _tnl_Vertex2fv( const GLfloat *v )
+{
+ DISPATCH_ATTR2FV( _TNL_ATTRIB_POS, v );
+}
+
+static void GLAPIENTRY _tnl_Vertex3f( GLfloat x, GLfloat y, GLfloat z )
+{
+ DISPATCH_ATTR3F( _TNL_ATTRIB_POS, x, y, z );
+}
+
+static void GLAPIENTRY _tnl_Vertex3fv( const GLfloat *v )
+{
+ DISPATCH_ATTR3FV( _TNL_ATTRIB_POS, v );
+}
+
+static void GLAPIENTRY _tnl_Vertex4f( GLfloat x, GLfloat y, GLfloat z,
+ GLfloat w )
+{
+ DISPATCH_ATTR4F( _TNL_ATTRIB_POS, x, y, z, w );
+}
+
+static void GLAPIENTRY _tnl_Vertex4fv( const GLfloat *v )
+{
+ DISPATCH_ATTR4FV( _TNL_ATTRIB_POS, v );
+}
+
+static void GLAPIENTRY _tnl_TexCoord1f( GLfloat x )
+{
+ DISPATCH_ATTR1F( _TNL_ATTRIB_TEX0, x );
+}
+
+static void GLAPIENTRY _tnl_TexCoord1fv( const GLfloat *v )
+{
+ DISPATCH_ATTR1FV( _TNL_ATTRIB_TEX0, v );
+}
+
+static void GLAPIENTRY _tnl_TexCoord2f( GLfloat x, GLfloat y )
+{
+ DISPATCH_ATTR2F( _TNL_ATTRIB_TEX0, x, y );
+}
+
+static void GLAPIENTRY _tnl_TexCoord2fv( const GLfloat *v )
+{
+ DISPATCH_ATTR2FV( _TNL_ATTRIB_TEX0, v );
+}
+
+static void GLAPIENTRY _tnl_TexCoord3f( GLfloat x, GLfloat y, GLfloat z )
+{
+ DISPATCH_ATTR3F( _TNL_ATTRIB_TEX0, x, y, z );
+}
+
+static void GLAPIENTRY _tnl_TexCoord3fv( const GLfloat *v )
+{
+ DISPATCH_ATTR3FV( _TNL_ATTRIB_TEX0, v );
+}
+
+static void GLAPIENTRY _tnl_TexCoord4f( GLfloat x, GLfloat y, GLfloat z,
+ GLfloat w )
+{
+ DISPATCH_ATTR4F( _TNL_ATTRIB_TEX0, x, y, z, w );
+}
+
+static void GLAPIENTRY _tnl_TexCoord4fv( const GLfloat *v )
+{
+ DISPATCH_ATTR4FV( _TNL_ATTRIB_TEX0, v );
+}
+
+static void GLAPIENTRY _tnl_Normal3f( GLfloat x, GLfloat y, GLfloat z )
+{
+ DISPATCH_ATTR3F( _TNL_ATTRIB_NORMAL, x, y, z );
+}
+
+static void GLAPIENTRY _tnl_Normal3fv( const GLfloat *v )
+{
+ DISPATCH_ATTR3FV( _TNL_ATTRIB_NORMAL, v );
+}
+
+static void GLAPIENTRY _tnl_FogCoordfEXT( GLfloat x )
+{
+ DISPATCH_ATTR1F( _TNL_ATTRIB_FOG, x );
+}
+
+static void GLAPIENTRY _tnl_FogCoordfvEXT( const GLfloat *v )
+{
+ DISPATCH_ATTR1FV( _TNL_ATTRIB_FOG, v );
+}
+
+static void GLAPIENTRY _tnl_Color3f( GLfloat x, GLfloat y, GLfloat z )
+{
+ DISPATCH_ATTR3F( _TNL_ATTRIB_COLOR0, x, y, z );
+}
+
+static void GLAPIENTRY _tnl_Color3fv( const GLfloat *v )
+{
+ DISPATCH_ATTR3FV( _TNL_ATTRIB_COLOR0, v );
+}
+
+static void GLAPIENTRY _tnl_Color4f( GLfloat x, GLfloat y, GLfloat z,
+ GLfloat w )
+{
+ DISPATCH_ATTR4F( _TNL_ATTRIB_COLOR0, x, y, z, w );
+}
+
+static void GLAPIENTRY _tnl_Color4fv( const GLfloat *v )
+{
+ DISPATCH_ATTR4FV( _TNL_ATTRIB_COLOR0, v );
+}
+
+static void GLAPIENTRY _tnl_SecondaryColor3fEXT( GLfloat x, GLfloat y,
+ GLfloat z )
+{
+ DISPATCH_ATTR3F( _TNL_ATTRIB_COLOR1, x, y, z );
+}
+
+static void GLAPIENTRY _tnl_SecondaryColor3fvEXT( const GLfloat *v )
+{
+ DISPATCH_ATTR3FV( _TNL_ATTRIB_COLOR1, v );
+}
+
+static void GLAPIENTRY _tnl_MultiTexCoord1f( GLenum target, GLfloat x )
+{
+ GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
+ DISPATCH_ATTR1F( attr, x );
+}
+
+static void GLAPIENTRY _tnl_MultiTexCoord1fv( GLenum target,
+ const GLfloat *v )
+{
+ GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
+ DISPATCH_ATTR1FV( attr, v );
+}
+
+static void GLAPIENTRY _tnl_MultiTexCoord2f( GLenum target, GLfloat x,
+ GLfloat y )
+{
+ GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
+ DISPATCH_ATTR2F( attr, x, y );
+}
+
+static void GLAPIENTRY _tnl_MultiTexCoord2fv( GLenum target,
+ const GLfloat *v )
+{
+ GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
+ DISPATCH_ATTR2FV( attr, v );
+}
+
+static void GLAPIENTRY _tnl_MultiTexCoord3f( GLenum target, GLfloat x,
+ GLfloat y, GLfloat z)
+{
+ GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
+ DISPATCH_ATTR3F( attr, x, y, z );
+}
+
+static void GLAPIENTRY _tnl_MultiTexCoord3fv( GLenum target,
+ const GLfloat *v )
+{
+ GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
+ DISPATCH_ATTR3FV( attr, v );
+}
+
+static void GLAPIENTRY _tnl_MultiTexCoord4f( GLenum target, GLfloat x,
+ GLfloat y, GLfloat z,
+ GLfloat w )
+{
+ GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
+ DISPATCH_ATTR4F( attr, x, y, z, w );
+}
+
+static void GLAPIENTRY _tnl_MultiTexCoord4fv( GLenum target,
+ const GLfloat *v )
+{
+ GLuint attr = (target & 0x7) + _TNL_ATTRIB_TEX0;
+ DISPATCH_ATTR4FV( attr, v );
+}
+
+
+static void GLAPIENTRY _tnl_VertexAttrib1fNV( GLuint index, GLfloat x )
+{
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR1F( index, x );
+}
+
+static void GLAPIENTRY _tnl_VertexAttrib1fvNV( GLuint index,
+ const GLfloat *v )
+{
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR1FV( index, v );
+}
+
+static void GLAPIENTRY _tnl_VertexAttrib2fNV( GLuint index, GLfloat x,
+ GLfloat y )
+{
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR2F( index, x, y );
+}
+
+static void GLAPIENTRY _tnl_VertexAttrib2fvNV( GLuint index,
+ const GLfloat *v )
+{
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR2FV( index, v );
+}
+
+static void GLAPIENTRY _tnl_VertexAttrib3fNV( GLuint index, GLfloat x,
+ GLfloat y, GLfloat z )
+{
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR3F( index, x, y, z );
+}
+
+static void GLAPIENTRY _tnl_VertexAttrib3fvNV( GLuint index,
+ const GLfloat *v )
+{
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR3FV( index, v );
+}
+
+static void GLAPIENTRY _tnl_VertexAttrib4fNV( GLuint index, GLfloat x,
+ GLfloat y, GLfloat z,
+ GLfloat w )
+{
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR4F( index, x, y, z, w );
+}
+
+static void GLAPIENTRY _tnl_VertexAttrib4fvNV( GLuint index,
+ const GLfloat *v )
+{
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR4FV( index, v );
+}
+
+
+/*
+ * XXX adjust index
+ */
+
+static void GLAPIENTRY _tnl_VertexAttrib1fARB( GLuint index, GLfloat x )
+{
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR1F( index, x );
+}
+
+static void GLAPIENTRY _tnl_VertexAttrib1fvARB( GLuint index,
+ const GLfloat *v )
+{
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR1FV( index, v );
+}
+
+static void GLAPIENTRY _tnl_VertexAttrib2fARB( GLuint index, GLfloat x,
+ GLfloat y )
+{
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR2F( index, x, y );
+}
+
+static void GLAPIENTRY _tnl_VertexAttrib2fvARB( GLuint index,
+ const GLfloat *v )
+{
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR2FV( index, v );
+}
+
+static void GLAPIENTRY _tnl_VertexAttrib3fARB( GLuint index, GLfloat x,
+ GLfloat y, GLfloat z )
+{
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR3F( index, x, y, z );
+}
+
+static void GLAPIENTRY _tnl_VertexAttrib3fvARB( GLuint index,
+ const GLfloat *v )
+{
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR3FV( index, v );
+}
+
+static void GLAPIENTRY _tnl_VertexAttrib4fARB( GLuint index, GLfloat x,
+ GLfloat y, GLfloat z,
+ GLfloat w )
+{
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR4F( index, x, y, z, w );
+}
+
+static void GLAPIENTRY _tnl_VertexAttrib4fvARB( GLuint index,
+ const GLfloat *v )
+{
+ if (index >= VERT_ATTRIB_MAX) index = ERROR_ATTRIB;
+ DISPATCH_ATTR4FV( index, v );
+}
+
+
+/* Install the generic versions of the 2nd level dispatch
+ * functions. Some of these have a codegen alternative.
+ */
+void _tnl_generic_exec_vtxfmt_init( GLcontext *ctx )
+{
+ GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->exec_vtxfmt);
+
+ vfmt->Color3f = _tnl_Color3f;
+ vfmt->Color3fv = _tnl_Color3fv;
+ vfmt->Color4f = _tnl_Color4f;
+ vfmt->Color4fv = _tnl_Color4fv;
+ vfmt->FogCoordfEXT = _tnl_FogCoordfEXT;
+ vfmt->FogCoordfvEXT = _tnl_FogCoordfvEXT;
+ vfmt->MultiTexCoord1fARB = _tnl_MultiTexCoord1f;
+ vfmt->MultiTexCoord1fvARB = _tnl_MultiTexCoord1fv;
+ vfmt->MultiTexCoord2fARB = _tnl_MultiTexCoord2f;
+ vfmt->MultiTexCoord2fvARB = _tnl_MultiTexCoord2fv;
+ vfmt->MultiTexCoord3fARB = _tnl_MultiTexCoord3f;
+ vfmt->MultiTexCoord3fvARB = _tnl_MultiTexCoord3fv;
+ vfmt->MultiTexCoord4fARB = _tnl_MultiTexCoord4f;
+ vfmt->MultiTexCoord4fvARB = _tnl_MultiTexCoord4fv;
+ vfmt->Normal3f = _tnl_Normal3f;
+ vfmt->Normal3fv = _tnl_Normal3fv;
+ vfmt->SecondaryColor3fEXT = _tnl_SecondaryColor3fEXT;
+ vfmt->SecondaryColor3fvEXT = _tnl_SecondaryColor3fvEXT;
+ vfmt->TexCoord1f = _tnl_TexCoord1f;
+ vfmt->TexCoord1fv = _tnl_TexCoord1fv;
+ vfmt->TexCoord2f = _tnl_TexCoord2f;
+ vfmt->TexCoord2fv = _tnl_TexCoord2fv;
+ vfmt->TexCoord3f = _tnl_TexCoord3f;
+ vfmt->TexCoord3fv = _tnl_TexCoord3fv;
+ vfmt->TexCoord4f = _tnl_TexCoord4f;
+ vfmt->TexCoord4fv = _tnl_TexCoord4fv;
+ vfmt->Vertex2f = _tnl_Vertex2f;
+ vfmt->Vertex2fv = _tnl_Vertex2fv;
+ vfmt->Vertex3f = _tnl_Vertex3f;
+ vfmt->Vertex3fv = _tnl_Vertex3fv;
+ vfmt->Vertex4f = _tnl_Vertex4f;
+ vfmt->Vertex4fv = _tnl_Vertex4fv;
+ vfmt->VertexAttrib1fNV = _tnl_VertexAttrib1fNV;
+ vfmt->VertexAttrib1fvNV = _tnl_VertexAttrib1fvNV;
+ vfmt->VertexAttrib2fNV = _tnl_VertexAttrib2fNV;
+ vfmt->VertexAttrib2fvNV = _tnl_VertexAttrib2fvNV;
+ vfmt->VertexAttrib3fNV = _tnl_VertexAttrib3fNV;
+ vfmt->VertexAttrib3fvNV = _tnl_VertexAttrib3fvNV;
+ vfmt->VertexAttrib4fNV = _tnl_VertexAttrib4fNV;
+ vfmt->VertexAttrib4fvNV = _tnl_VertexAttrib4fvNV;
+ vfmt->VertexAttrib1fARB = _tnl_VertexAttrib1fARB;
+ vfmt->VertexAttrib1fvARB = _tnl_VertexAttrib1fvARB;
+ vfmt->VertexAttrib2fARB = _tnl_VertexAttrib2fARB;
+ vfmt->VertexAttrib2fvARB = _tnl_VertexAttrib2fvARB;
+ vfmt->VertexAttrib3fARB = _tnl_VertexAttrib3fARB;
+ vfmt->VertexAttrib3fvARB = _tnl_VertexAttrib3fvARB;
+ vfmt->VertexAttrib4fARB = _tnl_VertexAttrib4fARB;
+ vfmt->VertexAttrib4fvARB = _tnl_VertexAttrib4fvARB;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_x86.c b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_x86.c
new file mode 100644
index 000000000..38cdad451
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_x86.c
@@ -0,0 +1,385 @@
+/**************************************************************************
+
+Copyright 2004 Tungsten Graphics 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, TUNGSTEN GRAPHICS 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Daniel Borca <dborca@yahoo.com>
+ */
+
+
+#include "glheader.h"
+#include "context.h"
+#include "macros.h"
+#include "vtxfmt.h"
+#include "dlist.h"
+#include "state.h"
+#include "light.h"
+#include "api_arrayelt.h"
+#include "api_noop.h"
+#include "t_vtx_api.h"
+#include "simple_list.h"
+
+
+#if defined(USE_X86_ASM) && !defined(HAVE_NONSTANDARD_GLAPIENTRY)
+
+#define EXTERN( FUNC ) \
+extern const char FUNC[]; \
+extern const char FUNC##_end[]
+
+EXTERN( _tnl_x86_Attribute1fv );
+EXTERN( _tnl_x86_Attribute2fv );
+EXTERN( _tnl_x86_Attribute3fv );
+EXTERN( _tnl_x86_Attribute4fv );
+EXTERN( _tnl_x86_Vertex1fv );
+EXTERN( _tnl_x86_Vertex2fv );
+EXTERN( _tnl_x86_Vertex3fv );
+EXTERN( _tnl_x86_Vertex4fv );
+
+EXTERN( _tnl_x86_dispatch_attrf1 );
+EXTERN( _tnl_x86_dispatch_attrf2 );
+EXTERN( _tnl_x86_dispatch_attrf3 );
+EXTERN( _tnl_x86_dispatch_attrf4 );
+EXTERN( _tnl_x86_dispatch_attrfv );
+EXTERN( _tnl_x86_dispatch_multitexcoordf1 );
+EXTERN( _tnl_x86_dispatch_multitexcoordf2 );
+EXTERN( _tnl_x86_dispatch_multitexcoordf3 );
+EXTERN( _tnl_x86_dispatch_multitexcoordf4 );
+EXTERN( _tnl_x86_dispatch_multitexcoordfv );
+EXTERN( _tnl_x86_dispatch_vertexattribf1 );
+EXTERN( _tnl_x86_dispatch_vertexattribf2 );
+EXTERN( _tnl_x86_dispatch_vertexattribf3 );
+EXTERN( _tnl_x86_dispatch_vertexattribf4 );
+EXTERN( _tnl_x86_dispatch_vertexattribfv );
+
+EXTERN( _tnl_x86_choose_fv );
+
+
+#define DONT_KNOW_OFFSETS 1
+
+
+#define DFN( FUNC, CACHE, KEY ) \
+ struct _tnl_dynfn *dfn = MALLOC_STRUCT( _tnl_dynfn );\
+ const char *start = FUNC; \
+ const char *end = FUNC##_end; \
+ int offset = 0; \
+ insert_at_head( &CACHE, dfn ); \
+ dfn->key = KEY; \
+ dfn->code = ALIGN_MALLOC( end - start, 16 ); \
+ memcpy (dfn->code, start, end - start)
+
+
+
+#define FIXUP( CODE, KNOWN_OFFSET, CHECKVAL, NEWVAL ) \
+do { \
+ GLint subst = 0x10101010 + CHECKVAL; \
+ \
+ if (DONT_KNOW_OFFSETS) { \
+ while (*(int *)(CODE+offset) != subst) offset++; \
+ *(int *)(CODE+offset) = (int)(NEWVAL); \
+ if (0) fprintf(stderr, "%s/%d: offset %d, new value: 0x%x\n", __FILE__, __LINE__, offset, (int)(NEWVAL)); \
+ offset += 4; \
+ } \
+ else { \
+ int *icode = (int *)(CODE+KNOWN_OFFSET); \
+ assert (*icode == subst); \
+ *icode = (int)NEWVAL; \
+ } \
+} while (0)
+
+
+
+#define FIXUPREL( CODE, KNOWN_OFFSET, CHECKVAL, NEWVAL )\
+do { \
+ GLint subst = 0x10101010 + CHECKVAL; \
+ \
+ if (DONT_KNOW_OFFSETS) { \
+ while (*(int *)(CODE+offset) != subst) offset++; \
+ *(int *)(CODE+offset) = (int)(NEWVAL) - ((int)(CODE)+offset) - 4; \
+ if (0) fprintf(stderr, "%s/%d: offset %d, new value: 0x%x\n", __FILE__, __LINE__, offset, (int)(NEWVAL) - ((int)(CODE)+offset) - 4); \
+ offset += 4; \
+ } \
+ else { \
+ int *icode = (int *)(CODE+KNOWN_OFFSET); \
+ assert (*icode == subst); \
+ *icode = (int)(NEWVAL) - (int)(icode) - 4; \
+ } \
+} while (0)
+
+
+
+
+/* Build specialized versions of the immediate calls on the fly for
+ * the current state. Generic x86 versions.
+ */
+
+static struct _tnl_dynfn *makeX86Vertex1fv( GLcontext *ctx, int vertex_size )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ DFN ( _tnl_x86_Vertex1fv, tnl->vtx.cache.Vertex[1-1], vertex_size );
+
+ FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
+ FIXUP(dfn->code, 0, 1, vertex_size - 1);
+ FIXUP(dfn->code, 0, 2, (int)&tnl->vtx.vertex[1]);
+ FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
+ FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
+ FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
+ FIXUP(dfn->code, 0, 4, (int)ctx);
+ FIXUPREL(dfn->code, 0, 5, (int)&_tnl_wrap_filled_vertex);
+
+ return dfn;
+}
+
+static struct _tnl_dynfn *makeX86Vertex2fv( GLcontext *ctx, int vertex_size )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ DFN ( _tnl_x86_Vertex2fv, tnl->vtx.cache.Vertex[2-1], vertex_size );
+
+ FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
+ FIXUP(dfn->code, 0, 1, vertex_size - 2);
+ FIXUP(dfn->code, 0, 2, (int)&tnl->vtx.vertex[2]);
+ FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
+ FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
+ FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
+ FIXUP(dfn->code, 0, 4, (int)ctx);
+ FIXUPREL(dfn->code, 0, 5, (int)&_tnl_wrap_filled_vertex);
+
+ return dfn;
+}
+
+static struct _tnl_dynfn *makeX86Vertex3fv( GLcontext *ctx, int vertex_size )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+
+ switch (vertex_size) {
+ default: {
+ DFN ( _tnl_x86_Vertex3fv, tnl->vtx.cache.Vertex[3-1], vertex_size );
+
+ FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
+ FIXUP(dfn->code, 0, 1, vertex_size - 3);
+ FIXUP(dfn->code, 0, 2, (int)&tnl->vtx.vertex[3]);
+ FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
+ FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
+ FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
+ FIXUP(dfn->code, 0, 4, (int)ctx);
+ FIXUPREL(dfn->code, 0, 5, (int)&_tnl_wrap_filled_vertex);
+ return dfn;
+ }
+ }
+}
+
+static struct _tnl_dynfn *makeX86Vertex4fv( GLcontext *ctx, int vertex_size )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ DFN ( _tnl_x86_Vertex4fv, tnl->vtx.cache.Vertex[4-1], vertex_size );
+
+ FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
+ FIXUP(dfn->code, 0, 1, vertex_size - 4);
+ FIXUP(dfn->code, 0, 2, (int)&tnl->vtx.vertex[4]);
+ FIXUP(dfn->code, 0, 0, (int)&tnl->vtx.vbptr);
+ FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
+ FIXUP(dfn->code, 0, 3, (int)&tnl->vtx.counter);
+ FIXUP(dfn->code, 0, 4, (int)ctx);
+ FIXUPREL(dfn->code, 0, 5, (int)&_tnl_wrap_filled_vertex);
+
+ return dfn;
+}
+
+
+static struct _tnl_dynfn *makeX86Attribute1fv( GLcontext *ctx, int dest )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ DFN ( _tnl_x86_Attribute1fv, tnl->vtx.cache.Attribute[1-1], dest );
+
+ FIXUP(dfn->code, 0, 0, dest);
+
+ return dfn;
+}
+
+static struct _tnl_dynfn *makeX86Attribute2fv( GLcontext *ctx, int dest )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ DFN ( _tnl_x86_Attribute2fv, tnl->vtx.cache.Attribute[2-1], dest );
+
+ FIXUP(dfn->code, 0, 0, dest);
+ FIXUP(dfn->code, 0, 1, 4+dest);
+
+ return dfn;
+}
+
+static struct _tnl_dynfn *makeX86Attribute3fv( GLcontext *ctx, int dest )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ DFN ( _tnl_x86_Attribute3fv, tnl->vtx.cache.Attribute[3-1], dest );
+
+ FIXUP(dfn->code, 0, 0, dest);
+ FIXUP(dfn->code, 0, 1, 4+dest);
+ FIXUP(dfn->code, 0, 2, 8+dest);
+
+ return dfn;
+}
+
+static struct _tnl_dynfn *makeX86Attribute4fv( GLcontext *ctx, int dest )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ DFN ( _tnl_x86_Attribute4fv, tnl->vtx.cache.Attribute[4-1], dest );
+
+ FIXUP(dfn->code, 0, 0, dest);
+ FIXUP(dfn->code, 0, 1, 4+dest);
+ FIXUP(dfn->code, 0, 2, 8+dest);
+ FIXUP(dfn->code, 0, 3, 12+dest);
+
+ return dfn;
+}
+
+
+void _tnl_InitX86Codegen( struct _tnl_dynfn_generators *gen )
+{
+ gen->Vertex[0] = makeX86Vertex1fv;
+ gen->Vertex[1] = makeX86Vertex2fv;
+ gen->Vertex[2] = makeX86Vertex3fv;
+ gen->Vertex[3] = makeX86Vertex4fv;
+ gen->Attribute[0] = makeX86Attribute1fv;
+ gen->Attribute[1] = makeX86Attribute2fv;
+ gen->Attribute[2] = makeX86Attribute3fv;
+ gen->Attribute[3] = makeX86Attribute4fv;
+}
+
+
+#define MKDISP(FUNC, SIZE, ATTR, WARP) \
+do { \
+ char *code; \
+ const char *start = WARP; \
+ const char *end = WARP##_end; \
+ int offset = 0; \
+ code = ALIGN_MALLOC( end - start, 16 ); \
+ memcpy (code, start, end - start); \
+ FIXUP(code, 0, 0, (int)&(TNL_CONTEXT(ctx)->vtx.tabfv[ATTR][SIZE-1]));\
+ *(void **)&vfmt->FUNC = code; \
+} while (0)
+
+
+/* Install the codegen'ed versions of the 2nd level dispatch
+ * functions. We should keep a list and free them in the end...
+ */
+void _tnl_x86_exec_vtxfmt_init( GLcontext *ctx )
+{
+ GLvertexformat *vfmt = &(TNL_CONTEXT(ctx)->exec_vtxfmt);
+
+ MKDISP(Color3f, 3, _TNL_ATTRIB_COLOR0, _tnl_x86_dispatch_attrf3);
+ MKDISP(Color3fv, 3, _TNL_ATTRIB_COLOR0, _tnl_x86_dispatch_attrfv);
+ MKDISP(Color4f, 4, _TNL_ATTRIB_COLOR0, _tnl_x86_dispatch_attrf4);
+ MKDISP(Color4fv, 4, _TNL_ATTRIB_COLOR0, _tnl_x86_dispatch_attrfv);
+ MKDISP(FogCoordfEXT, 1, _TNL_ATTRIB_FOG, _tnl_x86_dispatch_attrf1);
+ MKDISP(FogCoordfvEXT, 1, _TNL_ATTRIB_FOG, _tnl_x86_dispatch_attrfv);
+ MKDISP(Normal3f, 3, _TNL_ATTRIB_NORMAL, _tnl_x86_dispatch_attrf3);
+ MKDISP(Normal3fv, 3, _TNL_ATTRIB_NORMAL, _tnl_x86_dispatch_attrfv);
+ MKDISP(SecondaryColor3fEXT, 3, _TNL_ATTRIB_COLOR1, _tnl_x86_dispatch_attrf3);
+ MKDISP(SecondaryColor3fvEXT,3, _TNL_ATTRIB_COLOR1, _tnl_x86_dispatch_attrfv);
+ MKDISP(TexCoord1f, 1, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_attrf1);
+ MKDISP(TexCoord1fv, 1, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_attrfv);
+ MKDISP(TexCoord2f, 2, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_attrf2);
+ MKDISP(TexCoord2fv, 2, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_attrfv);
+ MKDISP(TexCoord3f, 3, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_attrf3);
+ MKDISP(TexCoord3fv, 3, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_attrfv);
+ MKDISP(TexCoord4f, 4, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_attrf4);
+ MKDISP(TexCoord4fv, 4, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_attrfv);
+ MKDISP(Vertex2f, 2, _TNL_ATTRIB_POS, _tnl_x86_dispatch_attrf2);
+ MKDISP(Vertex2fv, 2, _TNL_ATTRIB_POS, _tnl_x86_dispatch_attrfv);
+ MKDISP(Vertex3f, 3, _TNL_ATTRIB_POS, _tnl_x86_dispatch_attrf3);
+ MKDISP(Vertex3fv, 3, _TNL_ATTRIB_POS, _tnl_x86_dispatch_attrfv);
+ MKDISP(Vertex4f, 4, _TNL_ATTRIB_POS, _tnl_x86_dispatch_attrf4);
+ MKDISP(Vertex4fv, 4, _TNL_ATTRIB_POS, _tnl_x86_dispatch_attrfv);
+
+ MKDISP(MultiTexCoord1fARB, 1, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_multitexcoordf1);
+ MKDISP(MultiTexCoord1fvARB, 1, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_multitexcoordfv);
+ MKDISP(MultiTexCoord2fARB, 2, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_multitexcoordf2);
+ MKDISP(MultiTexCoord2fvARB, 2, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_multitexcoordfv);
+ MKDISP(MultiTexCoord3fARB, 3, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_multitexcoordf3);
+ MKDISP(MultiTexCoord3fvARB, 3, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_multitexcoordfv);
+ MKDISP(MultiTexCoord4fARB, 4, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_multitexcoordf4);
+ MKDISP(MultiTexCoord4fvARB, 4, _TNL_ATTRIB_TEX0, _tnl_x86_dispatch_multitexcoordfv);
+
+ MKDISP(VertexAttrib1fNV, 1, 0, _tnl_x86_dispatch_vertexattribf1);
+ MKDISP(VertexAttrib1fvNV, 1, 0, _tnl_x86_dispatch_vertexattribfv);
+ MKDISP(VertexAttrib2fNV, 2, 0, _tnl_x86_dispatch_vertexattribf2);
+ MKDISP(VertexAttrib2fvNV, 2, 0, _tnl_x86_dispatch_vertexattribfv);
+ MKDISP(VertexAttrib3fNV, 3, 0, _tnl_x86_dispatch_vertexattribf3);
+ MKDISP(VertexAttrib3fvNV, 3, 0, _tnl_x86_dispatch_vertexattribfv);
+ MKDISP(VertexAttrib4fNV, 4, 0, _tnl_x86_dispatch_vertexattribf4);
+ MKDISP(VertexAttrib4fvNV, 4, 0, _tnl_x86_dispatch_vertexattribfv);
+}
+
+
+/* Install the codegen'ed choosers.
+ * We should keep a list and free them in the end...
+ */
+void _tnl_x86choosers( tnl_attrfv_func (*choose)[4],
+ tnl_attrfv_func (*do_choose)( GLuint attr,
+ GLuint sz ))
+{
+ int attr, size;
+
+ for (attr = 0; attr < _TNL_MAX_ATTR_CODEGEN; attr++) {
+ for (size = 0; size < 4; size++) {
+ char *code;
+ const char *start = _tnl_x86_choose_fv;
+ const char *end = _tnl_x86_choose_fv_end;
+ int offset = 0;
+ code = ALIGN_MALLOC( end - start, 16 );
+ memcpy (code, start, end - start);
+ FIXUP(code, 0, 0, attr);
+ FIXUP(code, 0, 1, size + 1);
+ FIXUPREL(code, 0, 2, do_choose);
+ choose[attr][size] = (tnl_attrfv_func)code;
+ }
+ }
+}
+
+#else
+
+void _tnl_InitX86Codegen( struct _tnl_dynfn_generators *gen )
+{
+ (void) gen;
+}
+
+
+void _tnl_x86_exec_vtxfmt_init( GLcontext *ctx )
+{
+ (void) ctx;
+}
+
+
+void _tnl_x86choosers( tnl_attrfv_func (*choose)[4],
+ tnl_attrfv_func (*do_choose)( GLuint attr,
+ GLuint sz ))
+{
+ (void) choose;
+ (void) do_choose;
+}
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_x86_gcc.S b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_x86_gcc.S
new file mode 100644
index 000000000..5f79197f7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/t_vtx_x86_gcc.S
@@ -0,0 +1,557 @@
+/**************************************************************************
+
+Copyright 2004 Tungsten Graphics 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, TUNGSTEN GRAPHICS 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:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ * Daniel Borca <dborca@yahoo.com>
+ */
+
+#if defined (__DJGPP__) || defined (__MINGW32__) || defined (__CYGWIN__)
+#define GLOBL( x ) \
+.globl _##x; \
+_##x:
+#else /* !defined (__DJGPP__) && !defined (__MINGW32__) && !defined (__CYGWIN__) */
+#define GLOBL( x ) \
+.globl x; \
+x:
+#endif /* !defined (__DJGPP__) && !defined (__MINGW32__) && !defined (__CYGWIN__) */
+
+
+#if !defined (STDCALL_API)
+#define RETCLEAN( x ) ret
+#else
+#define RETCLEAN( x ) ret $x
+#endif
+
+
+#define _JMP(x) \
+.byte 0xe9; \
+.long x
+
+#define _CALL(x) \
+.byte 0xe8; \
+.long x
+
+
+/* Someone who knew a lot about this sort of thing would use this
+ * macro to note current offsets, etc in a special region of the
+ * object file & just make everything work out neat. I don't know
+ * enough to do that...
+ */
+
+#define SUBST( x ) (0x10101010 + x)
+
+
+.data
+
+
+/* [dBorca] TODO
+ * Unfold functions for each vertex size?
+ * Build super-specialized SSE versions?
+ *
+ * There is a trick in Vertex*fv: under certain conditions,
+ * we tail to _tnl_wrap_filled_vertex(ctx). This means that
+ * if Vertex*fv is STDCALL, then _tnl_wrap_filled_vertex must
+ * be STDCALL as well, because (GLcontext *) and (GLfloat *)
+ * have the same size.
+ */
+.align 4
+GLOBL ( _tnl_x86_Vertex1fv )
+ movl 4(%esp), %ecx
+ push %edi
+ push %esi
+ movl SUBST(0), %edi /* 0x0 --> tnl->vtx.vbptr */
+ movl (%ecx), %edx /* load v[0] */
+ movl %edx, (%edi) /* tnl->vtx.vbptr[0] = v[0] */
+ addl $4, %edi /* tnl->vtx.vbptr += 1 */
+ movl $SUBST(1), %ecx /* 0x1 --> (tnl->vtx.vertex_size - 1) */
+ movl $SUBST(2), %esi /* 0x2 --> (tnl->vtx.vertex + 1) */
+ repz
+ movsl %ds:(%esi), %es:(%edi)
+ movl %edi, SUBST(0) /* 0x0 --> tnl->vtx.vbptr */
+ movl SUBST(3), %edx /* 0x3 --> counter */
+ pop %esi
+ pop %edi
+ dec %edx /* counter-- */
+ movl %edx, SUBST(3) /* 0x3 --> counter */
+ je .0 /* if (counter == 0) goto .0 */
+ RETCLEAN(4) /* return */
+ .balign 16
+.0:
+ movl $SUBST(4), %eax /* load ctx */
+ movl %eax, 4(%esp) /* push ctx */
+ _JMP (SUBST(5)) /* jmp _tnl_wrap_filled_vertex */
+GLOBL ( _tnl_x86_Vertex1fv_end )
+
+.align 4
+GLOBL ( _tnl_x86_Vertex2fv )
+ movl 4(%esp), %ecx
+ push %edi
+ push %esi
+ movl SUBST(0), %edi /* load tnl->vtx.vbptr */
+ movl (%ecx), %edx /* load v[0] */
+ movl 4(%ecx), %eax /* load v[1] */
+ movl %edx, (%edi) /* tnl->vtx.vbptr[0] = v[0] */
+ movl %eax, 4(%edi) /* tnl->vtx.vbptr[1] = v[1] */
+ addl $8, %edi /* tnl->vtx.vbptr += 2 */
+ movl $SUBST(1), %ecx /* vertex_size - 2 */
+ movl $SUBST(2), %esi /* tnl->vtx.vertex + 2 */
+ repz
+ movsl %ds:(%esi), %es:(%edi)
+ movl %edi, SUBST(0) /* save tnl->vtx.vbptr */
+ movl SUBST(3), %edx /* load counter */
+ pop %esi
+ pop %edi
+ dec %edx /* counter-- */
+ movl %edx, SUBST(3) /* save counter */
+ je .1 /* if (counter == 0) goto .1 */
+ RETCLEAN(4) /* return */
+ .balign 16
+.1:
+ movl $SUBST(4), %eax /* load ctx */
+ movl %eax, 4(%esp) /* push ctx */
+ _JMP (SUBST(5)) /* jmp _tnl_wrap_filled_vertex */
+GLOBL ( _tnl_x86_Vertex2fv_end )
+
+.align 4
+GLOBL ( _tnl_x86_Vertex3fv )
+ movl 4(%esp), %ecx
+ push %edi
+ push %esi
+ movl SUBST(0), %edi /* load tnl->vtx.vbptr */
+ movl (%ecx), %edx /* load v[0] */
+ movl 4(%ecx), %eax /* load v[1] */
+ movl 8(%ecx), %esi /* load v[2] */
+ movl %edx, (%edi) /* tnl->vtx.vbptr[0] = v[0] */
+ movl %eax, 4(%edi) /* tnl->vtx.vbptr[1] = v[1] */
+ movl %esi, 8(%edi) /* tnl->vtx.vbptr[2] = v[2] */
+ addl $12, %edi /* tnl->vtx.vbptr += 3 */
+ movl $SUBST(1), %ecx /* vertex_size - 3 */
+ movl $SUBST(2), %esi /* tnl->vtx.vertex + 3 */
+ repz
+ movsl %ds:(%esi), %es:(%edi)
+ movl %edi, SUBST(0) /* save tnl->vtx.vbptr */
+ movl SUBST(3), %edx /* load counter */
+ pop %esi
+ pop %edi
+ dec %edx /* counter-- */
+ movl %edx, SUBST(3) /* save counter */
+ je .2 /* if (counter == 0) goto .2 */
+ RETCLEAN(4) /* return */
+ .balign 16
+.2:
+ movl $SUBST(4), %eax /* load ctx */
+ movl %eax, 4(%esp) /* push ctx */
+ _JMP (SUBST(5)) /* jmp _tnl_wrap_filled_vertex */
+GLOBL ( _tnl_x86_Vertex3fv_end )
+
+.align 4
+GLOBL ( _tnl_x86_Vertex4fv )
+ movl 4(%esp), %ecx
+ push %edi
+ push %esi
+ movl SUBST(0), %edi /* load tnl->vtx.vbptr */
+ movl (%ecx), %edx /* load v[0] */
+ movl 4(%ecx), %eax /* load v[1] */
+ movl 8(%ecx), %esi /* load v[2] */
+ movl 12(%ecx), %ecx /* load v[3] */
+ movl %edx, (%edi) /* tnl->vtx.vbptr[0] = v[0] */
+ movl %eax, 4(%edi) /* tnl->vtx.vbptr[1] = v[1] */
+ movl %esi, 8(%edi) /* tnl->vtx.vbptr[2] = v[2] */
+ movl %ecx, 12(%edi) /* tnl->vtx.vbptr[3] = v[3] */
+ addl $16, %edi /* tnl->vtx.vbptr += 4 */
+ movl $SUBST(1), %ecx /* vertex_size - 4 */
+ movl $SUBST(2), %esi /* tnl->vtx.vertex + 4 */
+ repz
+ movsl %ds:(%esi), %es:(%edi)
+ movl %edi, SUBST(0) /* save tnl->vtx.vbptr */
+ movl SUBST(3), %edx /* load counter */
+ pop %esi
+ pop %edi
+ dec %edx /* counter-- */
+ movl %edx, SUBST(3) /* save counter */
+ je .3 /* if (counter == 0) goto .3 */
+ RETCLEAN(4) /* return */
+ .balign 16
+.3:
+ movl $SUBST(4), %eax /* load ctx */
+ movl %eax, 4(%esp) /* push ctx */
+ _JMP (SUBST(5)) /* jmp _tnl_wrap_filled_vertex */
+GLOBL ( _tnl_x86_Vertex4fv_end )
+
+
+/**
+ * Generic handlers for vector format data.
+ */
+GLOBL( _tnl_x86_Attribute1fv )
+ movl 4(%esp), %ecx
+ movl (%ecx), %eax /* load v[0] */
+ movl %eax, SUBST(0) /* store v[0] to current vertex */
+ RETCLEAN(4)
+GLOBL ( _tnl_x86_Attribute1fv_end )
+
+GLOBL( _tnl_x86_Attribute2fv )
+ movl 4(%esp), %ecx
+ movl (%ecx), %eax /* load v[0] */
+ movl 4(%ecx), %edx /* load v[1] */
+ movl %eax, SUBST(0) /* store v[0] to current vertex */
+ movl %edx, SUBST(1) /* store v[1] to current vertex */
+ RETCLEAN(4)
+GLOBL ( _tnl_x86_Attribute2fv_end )
+
+GLOBL( _tnl_x86_Attribute3fv )
+ movl 4(%esp), %ecx
+ movl (%ecx), %eax /* load v[0] */
+ movl 4(%ecx), %edx /* load v[1] */
+ movl 8(%ecx), %ecx /* load v[2] */
+ movl %eax, SUBST(0) /* store v[0] to current vertex */
+ movl %edx, SUBST(1) /* store v[1] to current vertex */
+ movl %ecx, SUBST(2) /* store v[2] to current vertex */
+ RETCLEAN(4)
+GLOBL ( _tnl_x86_Attribute3fv_end )
+
+GLOBL( _tnl_x86_Attribute4fv )
+ movl 4(%esp), %ecx
+ movl (%ecx), %eax /* load v[0] */
+ movl 4(%ecx), %edx /* load v[1] */
+ movl %eax, SUBST(0) /* store v[0] to current vertex */
+ movl %edx, SUBST(1) /* store v[1] to current vertex */
+ movl 8(%ecx), %eax /* load v[2] */
+ movl 12(%ecx), %edx /* load v[3] */
+ movl %eax, SUBST(2) /* store v[2] to current vertex */
+ movl %edx, SUBST(3) /* store v[3] to current vertex */
+ RETCLEAN(4)
+GLOBL ( _tnl_x86_Attribute4fv_end )
+
+
+/* Choosers:
+ *
+ * Must generate all of these ahead of first usage. Generate at
+ * compile-time?
+ */
+GLOBL( _tnl_x86_choose_fv )
+ subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
+ movl $SUBST(0), (%esp) /* arg 0 - attrib */
+ movl $SUBST(1), 4(%esp) /* arg 1 - N */
+ _CALL (SUBST(2)) /* call do_choose */
+ add $12, %esp /* tear down stack frame */
+ jmp *%eax /* jump to new func */
+GLOBL ( _tnl_x86_choose_fv_end )
+
+
+/* FIRST LEVEL FUNCTIONS -- these are plugged directly into GL dispatch.
+ *
+ * In the 1st level dispatch functions, switch to a different
+ * calling convention -- (const GLfloat *v) in %ecx.
+ *
+ * As with regular (x86) dispatch, don't create a new stack frame -
+ * just let the 'ret' in the dispatched function return straight
+ * back to the original caller.
+ *
+ * Vertex/Normal/Color, etc: the address of the function pointer
+ * is known at codegen time.
+ */
+
+/* Unfortunately, have to play with the stack in the non-fv case:
+ */
+#if !defined (STDCALL_API)
+GLOBL( _tnl_x86_dispatch_attrf1 )
+GLOBL( _tnl_x86_dispatch_attrf2 )
+GLOBL( _tnl_x86_dispatch_attrf3 )
+GLOBL( _tnl_x86_dispatch_attrf4 )
+ subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
+ leal 16(%esp), %edx /* address of first float on stack */
+ movl %edx, (%esp) /* save as 'v' */
+ call *SUBST(0) /* 0x0 --> tabfv[attr][n] */
+ addl $12, %esp /* tear down frame */
+ ret /* return */
+GLOBL( _tnl_x86_dispatch_attrf4_end )
+GLOBL( _tnl_x86_dispatch_attrf3_end )
+GLOBL( _tnl_x86_dispatch_attrf2_end )
+GLOBL( _tnl_x86_dispatch_attrf1_end )
+
+#else /* defined(STDCALL_API) */
+
+GLOBL( _tnl_x86_dispatch_attrf1 )
+ subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
+ leal 16(%esp), %edx /* address of first float on stack */
+ movl %edx, (%esp) /* save as 'v' */
+ call *SUBST(0) /* 0x0 --> tabfv[attr][n] */
+ addl $8, %esp /* tear down frame (4 shaved off by the callee) */
+ ret $4 /* return */
+GLOBL( _tnl_x86_dispatch_attrf1_end )
+
+GLOBL( _tnl_x86_dispatch_attrf2 )
+ subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
+ leal 16(%esp), %edx /* address of first float on stack */
+ movl %edx, (%esp) /* save as 'v' */
+ call *SUBST(0) /* 0x0 --> tabfv[attr][n] */
+ addl $8, %esp /* tear down frame (4 shaved off by the callee) */
+ ret $8 /* return */
+GLOBL( _tnl_x86_dispatch_attrf2_end )
+
+GLOBL( _tnl_x86_dispatch_attrf3 )
+ subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
+ leal 16(%esp), %edx /* address of first float on stack */
+ movl %edx, (%esp) /* save as 'v' */
+ call *SUBST(0) /* 0x0 --> tabfv[attr][n] */
+ addl $8, %esp /* tear down frame (4 shaved off by the callee) */
+ ret $12 /* return */
+GLOBL( _tnl_x86_dispatch_attrf3_end )
+
+GLOBL( _tnl_x86_dispatch_attrf4 )
+ subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
+ leal 16(%esp), %edx /* address of first float on stack */
+ movl %edx, (%esp) /* save as 'v' */
+ call *SUBST(0) /* 0x0 --> tabfv[attr][n] */
+ addl $8, %esp /* tear down frame (4 shaved off by the callee) */
+ ret $16 /* return */
+GLOBL( _tnl_x86_dispatch_attrf4_end )
+#endif /* defined(STDCALL_API) */
+
+/* The fv case is simpler:
+ */
+GLOBL( _tnl_x86_dispatch_attrfv )
+ jmp *SUBST(0) /* 0x0 --> tabfv[attr][n] */
+GLOBL( _tnl_x86_dispatch_attrfv_end )
+
+
+/* MultiTexcoord: the address of the function pointer must be
+ * calculated, but can use the index argument slot to hold 'v', and
+ * avoid setting up a new stack frame.
+ *
+ * [dBorca]
+ * right, this would be the preferred approach, but gcc does not
+ * clean up the stack after each function call when optimizing (-fdefer-pop);
+ * can it make assumptions about what's already on the stack? I dunno,
+ * but in this case, we can't mess with the caller's stack frame, and
+ * we must use a model like `_x86_dispatch_attrfv' above. Caveat emptor!
+ */
+
+/* Also, will only need a maximum of four of each of these per context:
+ */
+#if !defined (STDCALL_API)
+GLOBL( _tnl_x86_dispatch_multitexcoordf1 )
+GLOBL( _tnl_x86_dispatch_multitexcoordf2 )
+GLOBL( _tnl_x86_dispatch_multitexcoordf3 )
+GLOBL( _tnl_x86_dispatch_multitexcoordf4 )
+ movl 4(%esp), %ecx
+ leal 8(%esp), %edx
+ andl $7, %ecx
+ movl %edx, 4(%esp)
+ sall $4, %ecx
+ jmp *SUBST(0)(%ecx) /* 0x0 - tabfv[tex0][n] */
+GLOBL( _tnl_x86_dispatch_multitexcoordf4_end )
+GLOBL( _tnl_x86_dispatch_multitexcoordf3_end )
+GLOBL( _tnl_x86_dispatch_multitexcoordf2_end )
+GLOBL( _tnl_x86_dispatch_multitexcoordf1_end )
+
+GLOBL( _tnl_x86_dispatch_multitexcoordfv )
+ movl 4(%esp), %ecx
+ movl 8(%esp), %edx
+ andl $7, %ecx
+ movl %edx, 4(%esp)
+ sall $4, %ecx
+ jmp *SUBST(0)(%ecx) /* 0x0 - tabfv[tex0][n] */
+GLOBL( _tnl_x86_dispatch_multitexcoordfv_end )
+
+#else /* defined (STDCALL_API) */
+
+GLOBL( _tnl_x86_dispatch_multitexcoordf1 )
+ subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
+ movl 16(%esp), %ecx
+ leal 20(%esp), %edx
+ andl $7, %ecx
+ movl %edx, (%esp)
+ sall $4, %ecx
+ call *SUBST(0)(%ecx) /* 0x0 - tabfv[tex0][n] */
+ addl $8, %esp /* tear down frame (4 shaved off by the callee) */
+ ret $8 /* return */
+GLOBL( _tnl_x86_dispatch_multitexcoordf1_end )
+
+GLOBL( _tnl_x86_dispatch_multitexcoordf2 )
+ subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
+ movl 16(%esp), %ecx
+ leal 20(%esp), %edx
+ andl $7, %ecx
+ movl %edx, (%esp)
+ sall $4, %ecx
+ call *SUBST(0)(%ecx) /* 0x0 - tabfv[tex0][n] */
+ addl $8, %esp /* tear down frame (4 shaved off by the callee) */
+ ret $12 /* return */
+GLOBL( _tnl_x86_dispatch_multitexcoordf2_end )
+
+GLOBL( _tnl_x86_dispatch_multitexcoordf3 )
+ subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
+ movl 16(%esp), %ecx
+ leal 20(%esp), %edx
+ andl $7, %ecx
+ movl %edx, (%esp)
+ sall $4, %ecx
+ call *SUBST(0)(%ecx) /* 0x0 - tabfv[tex0][n] */
+ addl $8, %esp /* tear down frame (4 shaved off by the callee) */
+ ret $16 /* return */
+GLOBL( _tnl_x86_dispatch_multitexcoordf3_end )
+
+GLOBL( _tnl_x86_dispatch_multitexcoordf4 )
+ subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
+ movl 16(%esp), %ecx
+ leal 20(%esp), %edx
+ andl $7, %ecx
+ movl %edx, (%esp)
+ sall $4, %ecx
+ call *SUBST(0)(%ecx) /* 0x0 - tabfv[tex0][n] */
+ addl $8, %esp /* tear down frame (4 shaved off by the callee) */
+ ret $20 /* return */
+GLOBL( _tnl_x86_dispatch_multitexcoordf4_end )
+
+GLOBL( _tnl_x86_dispatch_multitexcoordfv )
+ subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
+ movl 16(%esp), %ecx
+ movl 20(%esp), %edx
+ andl $7, %ecx
+ movl %edx, (%esp)
+ sall $4, %ecx
+ call *SUBST(0)(%ecx) /* 0x0 - tabfv[tex0][n] */
+ addl $8, %esp /* tear down frame (4 shaved off by the callee) */
+ ret $8 /* return */
+GLOBL( _tnl_x86_dispatch_multitexcoordfv_end )
+#endif /* defined (STDCALL_API) */
+
+
+/* VertexAttrib: the address of the function pointer must be
+ * calculated.
+ */
+#if !defined (STDCALL_API)
+GLOBL( _tnl_x86_dispatch_vertexattribf1 )
+GLOBL( _tnl_x86_dispatch_vertexattribf2 )
+GLOBL( _tnl_x86_dispatch_vertexattribf3 )
+GLOBL( _tnl_x86_dispatch_vertexattribf4 )
+ movl 4(%esp), %eax
+ cmpl $16, %eax
+ jb .8 /* "cmovge" is not supported on all CPUs */
+ movl $16, %eax
+.8:
+ leal 8(%esp), %ecx /* calculate 'v' */
+ movl %ecx, 4(%esp) /* save in 1st arg slot */
+ sall $4, %eax
+ jmp *SUBST(0)(%eax) /* 0x0 - tabfv[0][n] */
+GLOBL( _tnl_x86_dispatch_vertexattribf4_end )
+GLOBL( _tnl_x86_dispatch_vertexattribf3_end )
+GLOBL( _tnl_x86_dispatch_vertexattribf2_end )
+GLOBL( _tnl_x86_dispatch_vertexattribf1_end )
+
+GLOBL( _tnl_x86_dispatch_vertexattribfv )
+ movl 4(%esp), %eax
+ cmpl $16, %eax
+ jb .9 /* "cmovge" is not supported on all CPUs */
+ movl $16, %eax
+.9:
+ movl 8(%esp), %ecx /* load 'v' */
+ movl %ecx, 4(%esp) /* save in 1st arg slot */
+ sall $4, %eax
+ jmp *SUBST(0)(%eax) /* 0x0 - tabfv[0][n] */
+GLOBL( _tnl_x86_dispatch_vertexattribfv_end )
+
+#else /* defined (STDCALL_API) */
+
+GLOBL( _tnl_x86_dispatch_vertexattribf1 )
+ subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
+ movl 16(%esp), %eax
+ cmpl $16, %eax
+ jb .81 /* "cmovge" is not supported on all CPUs */
+ movl $16, %eax
+.81:
+ leal 20(%esp), %ecx /* load 'v' */
+ movl %ecx, (%esp) /* save in 1st arg slot */
+ sall $4, %eax
+ call *SUBST(0)(%eax) /* 0x0 - tabfv[0][n] */
+ addl $8, %esp /* tear down frame (4 shaved off by the callee) */
+ ret $8 /* return */
+GLOBL( _tnl_x86_dispatch_vertexattribf1_end )
+
+GLOBL( _tnl_x86_dispatch_vertexattribf2 )
+ subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
+ movl 16(%esp), %eax
+ cmpl $16, %eax
+ jb .82 /* "cmovge" is not supported on all CPUs */
+ movl $16, %eax
+.82:
+ leal 20(%esp), %ecx /* load 'v' */
+ movl %ecx, (%esp) /* save in 1st arg slot */
+ sall $4, %eax
+ call *SUBST(0)(%eax) /* 0x0 - tabfv[0][n] */
+ addl $8, %esp /* tear down frame (4 shaved off by the callee) */
+ ret $12 /* return */
+GLOBL( _tnl_x86_dispatch_vertexattribf2_end )
+
+GLOBL( _tnl_x86_dispatch_vertexattribf3 )
+ subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
+ movl 16(%esp), %eax
+ cmpl $16, %eax
+ jb .83 /* "cmovge" is not supported on all CPUs */
+ movl $16, %eax
+.83:
+ leal 20(%esp), %ecx /* load 'v' */
+ movl %ecx, (%esp) /* save in 1st arg slot */
+ sall $4, %eax
+ call *SUBST(0)(%eax) /* 0x0 - tabfv[0][n] */
+ addl $8, %esp /* tear down frame (4 shaved off by the callee) */
+ ret $16 /* return */
+GLOBL( _tnl_x86_dispatch_vertexattribf3_end )
+
+GLOBL( _tnl_x86_dispatch_vertexattribf4 )
+ subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
+ movl 16(%esp), %eax
+ cmpl $16, %eax
+ jb .84 /* "cmovge" is not supported on all CPUs */
+ movl $16, %eax
+.84:
+ leal 20(%esp), %ecx /* load 'v' */
+ movl %ecx, (%esp) /* save in 1st arg slot */
+ sall $4, %eax
+ call *SUBST(0)(%eax) /* 0x0 - tabfv[0][n] */
+ addl $8, %esp /* tear down frame (4 shaved off by the callee) */
+ ret $20 /* return */
+GLOBL( _tnl_x86_dispatch_vertexattribf4_end )
+
+GLOBL( _tnl_x86_dispatch_vertexattribfv )
+ subl $12, %esp /* gcc does 16 byte alignment of stack frames? */
+ movl 16(%esp), %eax
+ cmpl $16, %eax
+ jb .9 /* "cmovge" is not supported on all CPUs */
+ movl $16, %eax
+.9:
+ movl 20(%esp), %ecx /* load 'v' */
+ movl %ecx, (%esp) /* save in 1st arg slot */
+ sall $4, %eax
+ call *SUBST(0)(%eax) /* 0x0 - tabfv[0][n] */
+ addl $8, %esp /* tear down frame (4 shaved off by the callee) */
+ ret $8 /* return */
+GLOBL( _tnl_x86_dispatch_vertexattribfv_end )
+#endif /* defined (STDCALL_API) */
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl/tnl.h b/nx-X11/extras/Mesa/src/mesa/tnl/tnl.h
new file mode 100644
index 000000000..428fe1278
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl/tnl.h
@@ -0,0 +1,89 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#ifndef _TNL_H
+#define _TNL_H
+
+#include "mtypes.h"
+
+
+
+/* These are the public-access functions exported from tnl. (A few
+ * more are currently hooked into dispatch directly by the module
+ * itself.)
+ */
+extern GLboolean
+_tnl_CreateContext( GLcontext *ctx );
+
+extern void
+_tnl_DestroyContext( GLcontext *ctx );
+
+extern void
+_tnl_InvalidateState( GLcontext *ctx, GLuint new_state );
+
+/* Functions to revive the tnl module after being unhooked from
+ * dispatch and/or driver callbacks.
+ */
+
+/* Restore just the ctx->Exec table:
+ */
+extern void
+_tnl_wakeup_exec( GLcontext *ctx );
+
+/* Restore both ctx->Exec and ctx->Save:
+ */
+extern void
+_tnl_wakeup_save_exec( GLcontext *ctx );
+
+/* Driver configuration options:
+ */
+extern void
+_tnl_need_projected_coords( GLcontext *ctx, GLboolean flag );
+
+extern void
+_tnl_need_dlist_loopback( GLcontext *ctx, GLboolean flag );
+
+extern void
+_tnl_need_dlist_norm_lengths( GLcontext *ctx, GLboolean flag );
+
+extern void
+_tnl_isolate_materials( GLcontext *ctx, GLboolean flag );
+
+
+/* Control whether T&L does per-vertex fog
+ */
+extern void
+_tnl_allow_vertex_fog( GLcontext *ctx, GLboolean value );
+
+extern void
+_tnl_allow_pixel_fog( GLcontext *ctx, GLboolean value );
+
+extern void
+_tnl_program_string(GLcontext *ctx, GLenum target, struct program *program);
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/NOTES.imm b/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/NOTES.imm
new file mode 100644
index 000000000..9b2bd65e4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/NOTES.imm
@@ -0,0 +1,112 @@
+
+NOTE:
+
+These files are incomplete. They do not yet form a working
+implementation of hte concepts discused below.
+
+
+OVERVIEW
+
+The t_dd_imm_* files form a set of templates to produce driver -
+specific software tnl modules for a small subset of transformation and
+lighting states.
+
+The approach is quite different to the large vertex buffers of the
+src/tnl module, and is based around a cache of four recent vertices
+and a 'current' vertex which is updated directly from the Color,
+Normal, Texcoord, SecondaryColor and Fog entrypoints.
+
+The current vertex is actually a composite of the ctx->Current values
+and a partial hardware vertex maintained where the hardware values
+differ from those in ctx->Current. For example, clamped color values
+are kept in the hardware vertex, while texcoords remain in
+ctx->Current.
+
+A crude diagram:
+
+ +--------------+ +-------------------+
+ | ctx->Current | | Current-HW-vertex |
+ +--------------+ +-------------------+
+ \ /
+ \ /
+ \ /
+ \ /
+ --------- --------
+ | |
+ v v
+ +--------+ +--------+ +--------+ +--------+
+ | vert-0 | | vert-1 | | vert-2 | | vert-3 |
+ +--------+ +--------+ +--------+ +--------+
+ |
+ |
+ v
+
+ DMA
+
+
+Here values from ctx->Current and current-HW-vertex are merged to
+build vert-2, which is then dumped to hardware (DMA). A state machine
+determines which vertex is built in turn, and how the vertices are
+used to present primitives to hardware. These actions all occur
+during a call to Vertex{234}f{v}.
+
+Each vert-n includes clip coordinates and a clipmask in addition to
+the hardware (window) coordinates. This information allows clipping
+to take place directly on these vertices, if need be.
+
+t_dd_imm_capi.h
+
+ Color{34}{fub}{v}() implementations. These update both
+ ctx->Current (unclamped float colors) and current-HW-vertex
+ with hardware-specific color values (typically unsigned
+ bytes).
+
+ When lighting is enabled, the functions from src/api_noop.c
+ should be used, which just update ctx->Current. (The
+ current-hw-vertex colors are produced from lighting, which is
+ keyed to Normal3f).
+
+t_dd_imm_vb.c
+
+ Support functions for clipping and fallback. See
+ t_dd_imm_primtmp.h.
+
+t_dd_imm_napi.c
+t_dd_imm_napi.h
+
+ Versions of Normal3f{v} to perform lighting with one or more
+ infinite lights. Updates ctx->Current.Normal and the current
+ HW colors.
+
+ When lighting is disabled, use the functions from api_noop.c
+ instead.
+
+
+t_dd_imm_primtmp.h
+
+ State machine to control emission of vertices and primitives
+ to hardware. Called indirectly from Vertex{234}f{v}. Capable
+ of supporting hardware strip and fan primitives, and of
+ decomposing to discreet primitives for clipping or fallback,
+ or where the native primitive is unavailable.
+
+t_dd_imm_tapi.h
+
+ Implementations of TexCoord{v} and MultiTexCoord4f{v}ARB to
+ fire a callback when transitioning to projective texture.
+ Most drivers will need to change vertex format at this point,
+ some may need to enable a software rasterization fallback.
+
+t_dd_imm_vapi.h
+
+ Implementations of Vertex{234}f{v}. These perform
+ transformation and cliptesting on their arguments, then jump
+ into the state machine implemented in primtmp.h.
+
+t_dd_imm_vertex.h
+
+ Support functions for building and clip-interpolating hardware
+ vertices. Called from primtmp.h.
+
+
+Keith Whitwell, June 2001. \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_capi.h b/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_capi.h
new file mode 100644
index 000000000..eecbf0da5
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_capi.h
@@ -0,0 +1,419 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ */
+
+/* Template for immediate mode color functions.
+ *
+ * FIXME: Floating-point color versions of these...
+ */
+
+
+static void TAG(Color3f)( GLfloat r, GLfloat g, GLfloat b )
+{
+ GET_CURRENT;
+#ifdef COLOR_IS_FLOAT
+ CURRENT_COLOR( RCOMP ) = CLAMP(r, 0.0f, 1.0f);
+ CURRENT_COLOR( GCOMP ) = CLAMP(g, 0.0f, 1.0f);
+ CURRENT_COLOR( BCOMP ) = CLAMP(b, 0.0f, 1.0f);
+ CURRENT_COLOR( ACOMP ) = 1.0f;
+#else
+ UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( RCOMP ), r );
+ UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( GCOMP ), g );
+ UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( BCOMP ), b );
+ CURRENT_COLOR( ACOMP ) = 255;
+#endif
+}
+
+static void TAG(Color3fv)( const GLfloat *v )
+{
+ GET_CURRENT;
+#ifdef COLOR_IS_FLOAT
+ CURRENT_COLOR( RCOMP ) = CLAMP(v[0], 0.0f, 1.0f);
+ CURRENT_COLOR( GCOMP ) = CLAMP(v[1], 0.0f, 1.0f);
+ CURRENT_COLOR( BCOMP ) = CLAMP(v[2], 0.0f, 1.0f);
+ CURRENT_COLOR( ACOMP ) = 1.0f;
+#else
+ UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( RCOMP ), v[0] );
+ UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( GCOMP ), v[1] );
+ UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( BCOMP ), v[2] );
+ CURRENT_COLOR( ACOMP ) = 255;
+#endif
+}
+
+static void TAG(Color3ub)( GLubyte r, GLubyte g, GLubyte b )
+{
+ GET_CURRENT;
+#ifdef COLOR_IS_FLOAT
+ CURRENT_COLOR( RCOMP ) = UBYTE_TO_FLOAT( r );
+ CURRENT_COLOR( GCOMP ) = UBYTE_TO_FLOAT( g );
+ CURRENT_COLOR( BCOMP ) = UBYTE_TO_FLOAT( b );
+ CURRENT_COLOR( ACOMP ) = 1.0f;
+#else
+ CURRENT_COLOR( RCOMP ) = r;
+ CURRENT_COLOR( GCOMP ) = g;
+ CURRENT_COLOR( BCOMP ) = b;
+ CURRENT_COLOR( ACOMP ) = 255;
+#endif
+}
+
+static void TAG(Color3ubv)( const GLubyte *v )
+{
+ GET_CURRENT;
+#ifdef COLOR_IS_FLOAT
+ CURRENT_COLOR( RCOMP ) = UBYTE_TO_FLOAT( v[0] );
+ CURRENT_COLOR( GCOMP ) = UBYTE_TO_FLOAT( v[1] );
+ CURRENT_COLOR( BCOMP ) = UBYTE_TO_FLOAT( v[2] );
+ CURRENT_COLOR( ACOMP ) = 1.0f;
+#else
+ CURRENT_COLOR( RCOMP ) = v[0];
+ CURRENT_COLOR( GCOMP ) = v[1];
+ CURRENT_COLOR( BCOMP ) = v[2];
+ CURRENT_COLOR( ACOMP ) = 255;
+#endif
+}
+
+static void TAG(Color4f)( GLfloat r, GLfloat g, GLfloat b, GLfloat a )
+{
+ GET_CURRENT;
+#ifdef COLOR_IS_FLOAT
+ CURRENT_COLOR( RCOMP ) = CLAMP(r, 0.0f, 1.0f);
+ CURRENT_COLOR( GCOMP ) = CLAMP(g, 0.0f, 1.0f);
+ CURRENT_COLOR( BCOMP ) = CLAMP(b, 0.0f, 1.0f);
+ CURRENT_COLOR( ACOMP ) = CLAMP(a, 0.0f, 1.0f);
+#else
+ UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( RCOMP ), r );
+ UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( GCOMP ), g );
+ UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( BCOMP ), b );
+ UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( ACOMP ), a );
+#endif
+}
+
+static void TAG(Color4fv)( const GLfloat *v )
+{
+ GET_CURRENT;
+#ifdef COLOR_IS_FLOAT
+ CURRENT_COLOR( RCOMP ) = CLAMP(v[0], 0.0f, 1.0f);
+ CURRENT_COLOR( GCOMP ) = CLAMP(v[1], 0.0f, 1.0f);
+ CURRENT_COLOR( BCOMP ) = CLAMP(v[2], 0.0f, 1.0f);
+ CURRENT_COLOR( ACOMP ) = CLAMP(v[3], 0.0f, 1.0f);
+#else
+ UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( RCOMP ), v[0] );
+ UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( GCOMP ), v[1] );
+ UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( BCOMP ), v[2] );
+ UNCLAMPED_FLOAT_TO_UBYTE( CURRENT_COLOR( ACOMP ), v[3] );
+#endif
+}
+
+static void TAG(Color4ub)( GLubyte r, GLubyte g, GLubyte b, GLubyte a )
+{
+ GET_CURRENT;
+#ifdef COLOR_IS_FLOAT
+ CURRENT_COLOR( RCOMP ) = UBYTE_TO_FLOAT( r );
+ CURRENT_COLOR( GCOMP ) = UBYTE_TO_FLOAT( g );
+ CURRENT_COLOR( BCOMP ) = UBYTE_TO_FLOAT( b );
+ CURRENT_COLOR( ACOMP ) = UBYTE_TO_FLOAT( a );
+#else
+ CURRENT_COLOR( RCOMP ) = r;
+ CURRENT_COLOR( GCOMP ) = g;
+ CURRENT_COLOR( BCOMP ) = b;
+ CURRENT_COLOR( ACOMP ) = a;
+#endif
+}
+
+static void TAG(Color4ubv)( const GLubyte *v )
+{
+ GET_CURRENT;
+#ifdef COLOR_IS_FLOAT
+ CURRENT_COLOR( RCOMP ) = UBYTE_TO_FLOAT( v[0] );
+ CURRENT_COLOR( GCOMP ) = UBYTE_TO_FLOAT( v[1] );
+ CURRENT_COLOR( BCOMP ) = UBYTE_TO_FLOAT( v[2] );
+ CURRENT_COLOR( ACOMP ) = UBYTE_TO_FLOAT( v[3] );
+#else
+ CURRENT_COLOR( RCOMP ) = v[0];
+ CURRENT_COLOR( GCOMP ) = v[1];
+ CURRENT_COLOR( BCOMP ) = v[2];
+ CURRENT_COLOR( ACOMP ) = v[3];
+#endif
+}
+
+
+static void TAG(ColorMaterial3f)( GLfloat r, GLfloat g, GLfloat b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *color = ctx->Current.Color;
+
+ color[0] = r;
+ color[1] = g;
+ color[2] = b;
+ color[3] = 1.0;
+
+ _mesa_update_color_material( ctx, color );
+ RECALC_BASE_COLOR( ctx );
+}
+
+static void TAG(ColorMaterial3fv)( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *color = ctx->Current.Color;
+
+ color[0] = v[0];
+ color[1] = v[1];
+ color[2] = v[2];
+ color[3] = 1.0;
+
+ _mesa_update_color_material( ctx, color );
+ RECALC_BASE_COLOR( ctx );
+}
+
+static void TAG(ColorMaterial3ub)( GLubyte r, GLubyte g, GLubyte b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *color = ctx->Current.Color;
+
+ color[0] = UBYTE_TO_FLOAT( r );
+ color[1] = UBYTE_TO_FLOAT( g );
+ color[2] = UBYTE_TO_FLOAT( b );
+ color[3] = 1.0;
+
+ _mesa_update_color_material( ctx, color );
+ RECALC_BASE_COLOR( ctx );
+}
+
+static void TAG(ColorMaterial3ubv)( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *color = ctx->Current.Color;
+
+ color[0] = UBYTE_TO_FLOAT( v[0] );
+ color[1] = UBYTE_TO_FLOAT( v[1] );
+ color[2] = UBYTE_TO_FLOAT( v[2] );
+ color[3] = 1.0;
+
+ _mesa_update_color_material( ctx, color );
+ RECALC_BASE_COLOR( ctx );
+}
+
+static void TAG(ColorMaterial4f)( GLfloat r, GLfloat g, GLfloat b, GLfloat a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *color = ctx->Current.Color;
+
+ color[0] = r;
+ color[1] = g;
+ color[2] = b;
+ color[3] = a;
+
+ _mesa_update_color_material( ctx, color );
+ RECALC_BASE_COLOR( ctx );
+}
+
+static void TAG(ColorMaterial4fv)( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *color = ctx->Current.Color;
+
+ color[0] = v[0];
+ color[1] = v[1];
+ color[2] = v[2];
+ color[3] = v[3];
+
+ _mesa_update_color_material( ctx, color );
+ RECALC_BASE_COLOR( ctx );
+}
+
+static void TAG(ColorMaterial4ub)( GLubyte r, GLubyte g, GLubyte b, GLubyte a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *color = ctx->Current.Color;
+
+ color[0] = UBYTE_TO_FLOAT( r );
+ color[1] = UBYTE_TO_FLOAT( g );
+ color[2] = UBYTE_TO_FLOAT( b );
+ color[3] = UBYTE_TO_FLOAT( a );
+
+ _mesa_update_color_material( ctx, color );
+ RECALC_BASE_COLOR( ctx );
+}
+
+static void TAG(ColorMaterial4ubv)( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+ GLfloat *color = ctx->Current.Color;
+
+ color[0] = UBYTE_TO_FLOAT( v[0] );
+ color[1] = UBYTE_TO_FLOAT( v[1] );
+ color[2] = UBYTE_TO_FLOAT( v[2] );
+ color[3] = UBYTE_TO_FLOAT( v[3] );
+
+ _mesa_update_color_material( ctx, color );
+ RECALC_BASE_COLOR( ctx );
+}
+
+
+
+
+
+/* =============================================================
+ * Color chooser functions:
+ */
+
+static void TAG(choose_Color3f)( GLfloat r, GLfloat g, GLfloat b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if ( ctx->Light.Enabled ) {
+ if ( ctx->Light.ColorMaterialEnabled ) {
+ SET_Color3f(ctx->Exec, TAG(ColorMaterial3f));
+ } else {
+ SET_Color3f(ctx->Exec, _mesa_noop_Color3f);
+ }
+ } else {
+ SET_Color3f(ctx->Exec, TAG(Color3f));
+ }
+ glColor3f( r, g, b );
+}
+
+static void TAG(choose_Color3fv)( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if ( ctx->Light.Enabled ) {
+ if ( ctx->Light.ColorMaterialEnabled ) {
+ SET_Color3fv(ctx->Exec, TAG(ColorMaterial3fv));
+ } else {
+ SET_Color3fv(ctx->Exec, _mesa_noop_Color3fv);
+ }
+ } else {
+ SET_Color3fv(ctx->Exec, TAG(Color3fv));
+ }
+ glColor3fv( v );
+}
+
+static void TAG(choose_Color3ub)( GLubyte r, GLubyte g, GLubyte b )
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if ( ctx->Light.Enabled ) {
+ if ( ctx->Light.ColorMaterialEnabled ) {
+ SET_Color3ub(ctx->Exec, TAG(ColorMaterial3ub));
+ } else {
+ SET_Color3ub(ctx->Exec, _mesa_noop_Color3ub);
+ }
+ } else {
+ SET_Color3ub(ctx->Exec, TAG(Color3ub));
+ }
+ glColor3ub( r, g, b );
+}
+
+static void TAG(choose_Color3ubv)( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if ( ctx->Light.Enabled ) {
+ if ( ctx->Light.ColorMaterialEnabled ) {
+ SET_Color3ubv(ctx->Exec, TAG(ColorMaterial3ubv));
+ } else {
+ SET_Color3ubv(ctx->Exec, _mesa_noop_Color3ubv);
+ }
+ } else {
+ SET_Color3ubv(ctx->Exec, TAG(Color3ubv));
+ }
+ glColor3ubv( v );
+}
+
+static void TAG(choose_Color4f)( GLfloat r, GLfloat g, GLfloat b, GLfloat a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if ( ctx->Light.Enabled ) {
+ if ( ctx->Light.ColorMaterialEnabled ) {
+ SET_Color4f(ctx->Exec, TAG(ColorMaterial4f));
+ } else {
+ SET_Color4f(ctx->Exec, _mesa_noop_Color4f);
+ }
+ } else {
+ SET_Color4f(ctx->Exec, TAG(Color4f));
+ }
+ glColor4f( r, g, b, a );
+}
+
+static void TAG(choose_Color4fv)( const GLfloat *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if ( ctx->Light.Enabled ) {
+ if ( ctx->Light.ColorMaterialEnabled ) {
+ SET_Color4fv(ctx->Exec, TAG(ColorMaterial4fv));
+ } else {
+ SET_Color4fv(ctx->Exec, _mesa_noop_Color4fv);
+ }
+ } else {
+ SET_Color4fv(ctx->Exec, TAG(Color4fv));
+ }
+ glColor4fv( v );
+}
+
+static void TAG(choose_Color4ub)( GLubyte r, GLubyte g, GLubyte b, GLubyte a )
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if ( ctx->Light.Enabled ) {
+ if ( ctx->Light.ColorMaterialEnabled ) {
+ SET_Color4ub(ctx->Exec, TAG(ColorMaterial4ub));
+ } else {
+ SET_Color4ub(ctx->Exec, _mesa_noop_Color4ub);
+ }
+ } else {
+ SET_Color4ub(ctx->Exec, TAG(Color4ub));
+ }
+ glColor4ub( r, g, b, a );
+}
+
+static void TAG(choose_Color4ubv)( const GLubyte *v )
+{
+ GET_CURRENT_CONTEXT(ctx);
+
+ if ( ctx->Light.Enabled ) {
+ if ( ctx->Light.ColorMaterialEnabled ) {
+ SET_Color4ubv(ctx->Exec, TAG(ColorMaterial4ubv));
+ } else {
+ SET_Color4ubv(ctx->Exec, _mesa_noop_Color4ubv);
+ }
+ } else {
+ SET_Color4ubv(ctx->Exec, TAG(Color4ubv));
+ }
+ glColor4ubv( v );
+}
+
+
+
+#undef GET_CURRENT
+#undef CURRENT_COLOR
+#undef CURRENT_SPECULAR
+#undef COLOR_IS_FLOAT
+#undef RECALC_BASE_COLOR
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_napi.h b/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_napi.h
new file mode 100644
index 000000000..9844f615f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_napi.h
@@ -0,0 +1,226 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Keith Whitwell <keith_whitwell@yahoo.com>
+ */
+
+/* Template for immediate mode normal functions. Optimize for infinite
+ * lights when doing software lighting.
+ */
+
+static void TAG(Normal3f_single)( GLfloat x, GLfloat y, GLfloat z )
+{
+ GET_CURRENT_VERTEX;
+ const struct gl_light *light = ctx->Light.EnabledList.prev;
+ GLfloat n_dot_h, n_dot_VP, spec, sum[3];
+ GLfloat *normal = ctx->Current.Normal;
+ GLfloat scale = 1.0;
+
+ ASSIGN_3V( normal, x, y, z );
+ COPY_3V( sum, BASE_COLOR );
+
+ if ( IND & NORM_RESCALE ) {
+ scale = ctx->_ModelViewInvScale;
+ } else if ( IND & NORM_NORMALIZE ) {
+ scale = LEN_3FV( normal );
+ if ( scale != 0.0 ) scale = 1.0 / scale;
+ }
+
+ n_dot_VP = DOT3( normal, light->_VP_inf_norm ) * scale;
+ if ( n_dot_VP > 0.0F ) {
+ ACC_SCALE_SCALAR_3V( sum, n_dot_VP, light->_MatDiffuse[0] );
+ n_dot_h = DOT3( normal, light->_h_inf_norm ) * scale;
+ if ( n_dot_h > 0.0F ) {
+ GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec );
+ ACC_SCALE_SCALAR_3V( sum, spec, light->_MatSpecular[0] );
+ }
+ }
+
+#ifdef LIT_COLOR_IS_FLOAT
+ LIT_COLOR ( RCOMP ) = CLAMP(sum[0], 0.0f, 0.1f);
+ LIT_COLOR ( GCOMP ) = CLAMP(sum[1], 0.0f, 0.1f);
+ LIT_COLOR ( BCOMP ) = CLAMP(sum[2], 0.0f, 0.1f);
+#else
+ UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( RCOMP ), sum[0] );
+ UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( GCOMP ), sum[1] );
+ UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( BCOMP ), sum[2] );
+#endif
+ LIT_COLOR( ACOMP ) = LIT_ALPHA;
+}
+
+static void TAG(Normal3fv_single)( const GLfloat *normal )
+{
+ GET_CURRENT_VERTEX;
+ const struct gl_light *light = ctx->Light.EnabledList.prev;
+ GLfloat n_dot_h, n_dot_VP, spec, sum[3];
+ GLfloat scale = 1.0;
+
+ COPY_3V( ctx->Current.Normal, normal );
+ COPY_3V( sum, BASE_COLOR );
+
+ if ( IND & NORM_RESCALE ) {
+ scale = ctx->_ModelViewInvScale;
+ } else if ( IND & NORM_NORMALIZE ) {
+ scale = LEN_3FV( normal );
+ if ( scale != 0.0 ) scale = 1.0 / scale;
+ }
+
+ n_dot_VP = DOT3( normal, light->_VP_inf_norm ) * scale;
+ if ( n_dot_VP > 0.0F ) {
+ ACC_SCALE_SCALAR_3V( sum, n_dot_VP, light->_MatDiffuse[0] );
+ n_dot_h = DOT3( normal, light->_h_inf_norm ) * scale;
+ if ( n_dot_h > 0.0F ) {
+ GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec );
+ ACC_SCALE_SCALAR_3V( sum, spec, light->_MatSpecular[0] );
+ }
+ }
+
+#ifdef LIT_COLOR_IS_FLOAT
+ LIT_COLOR ( RCOMP ) = CLAMP(sum[0], 0.0f, 0.1f);
+ LIT_COLOR ( GCOMP ) = CLAMP(sum[1], 0.0f, 0.1f);
+ LIT_COLOR ( BCOMP ) = CLAMP(sum[2], 0.0f, 0.1f);
+#else
+ UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( RCOMP ), sum[0] );
+ UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( GCOMP ), sum[1] );
+ UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( BCOMP ), sum[2] );
+#endif
+ LIT_COLOR( ACOMP ) = LIT_ALPHA;
+}
+
+
+static void TAG(Normal3f_multi)( GLfloat x, GLfloat y, GLfloat z )
+{
+ GET_CURRENT_VERTEX;
+ struct gl_light *light;
+ GLfloat n_dot_h, n_dot_VP, spec, sum[3], tmp[3];
+ GLfloat *normal;
+
+ ASSIGN_3V( ctx->Current.Normal, x, y, z );
+ COPY_3V( sum, BASE_COLOR );
+
+ if ( IND & NORM_RESCALE ) {
+ normal = tmp;
+ ASSIGN_3V( normal, x, y, z );
+ SELF_SCALE_SCALAR_3V( normal, ctx->_ModelViewInvScale );
+ } else if ( IND & NORM_NORMALIZE ) {
+ normal = tmp;
+ ASSIGN_3V( normal, x, y, z );
+ NORMALIZE_3FV( normal );
+ } else {
+ normal = ctx->Current.Normal;
+ }
+
+ foreach ( light, &ctx->Light.EnabledList ) {
+ n_dot_VP = DOT3( normal, light->_VP_inf_norm );
+ if ( n_dot_VP > 0.0F ) {
+ ACC_SCALE_SCALAR_3V( sum, n_dot_VP, light->_MatDiffuse[0] );
+ n_dot_h = DOT3( normal, light->_h_inf_norm );
+ if ( n_dot_h > 0.0F ) {
+ GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec );
+ ACC_SCALE_SCALAR_3V( sum, spec, light->_MatSpecular[0] );
+ }
+ }
+ }
+
+#ifdef LIT_COLOR_IS_FLOAT
+ LIT_COLOR ( RCOMP ) = CLAMP(sum[0], 0.0f, 0.1f);
+ LIT_COLOR ( GCOMP ) = CLAMP(sum[1], 0.0f, 0.1f);
+ LIT_COLOR ( BCOMP ) = CLAMP(sum[2], 0.0f, 0.1f);
+#else
+ UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( RCOMP ), sum[0] );
+ UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( GCOMP ), sum[1] );
+ UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( BCOMP ), sum[2] );
+#endif
+ LIT_COLOR( ACOMP ) = LIT_ALPHA;
+}
+
+static void TAG(Normal3fv_multi)( const GLfloat *n )
+{
+ GET_CURRENT_VERTEX;
+ struct gl_light *light;
+ GLfloat n_dot_h, n_dot_VP, spec, sum[3], tmp[3];
+ GLfloat *normal;
+
+ COPY_3V( ctx->Current.Normal, n );
+ COPY_3V( sum, BASE_COLOR );
+
+ if ( IND & NORM_RESCALE ) {
+ normal = tmp;
+ COPY_3V( normal, n );
+ SELF_SCALE_SCALAR_3V( normal, ctx->_ModelViewInvScale );
+ } else if ( IND & NORM_NORMALIZE ) {
+ normal = tmp;
+ COPY_3V( normal, n );
+ NORMALIZE_3FV( normal );
+ } else {
+ normal = ctx->Current.Normal;
+ }
+
+ foreach ( light, &ctx->Light.EnabledList ) {
+ n_dot_VP = DOT3( normal, light->_VP_inf_norm );
+ if ( n_dot_VP > 0.0F ) {
+ ACC_SCALE_SCALAR_3V( sum, n_dot_VP, light->_MatDiffuse[0] );
+ n_dot_h = DOT3( normal, light->_h_inf_norm );
+ if ( n_dot_h > 0.0F ) {
+ GET_SHINE_TAB_ENTRY( ctx->_ShineTable[0], n_dot_h, spec );
+ ACC_SCALE_SCALAR_3V( sum, spec, light->_MatSpecular[0] );
+ }
+ }
+ }
+
+#ifdef LIT_COLOR_IS_FLOAT
+ LIT_COLOR ( RCOMP ) = CLAMP(sum[0], 0.0f, 0.1f);
+ LIT_COLOR ( GCOMP ) = CLAMP(sum[1], 0.0f, 0.1f);
+ LIT_COLOR ( BCOMP ) = CLAMP(sum[2], 0.0f, 0.1f);
+#else
+ UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( RCOMP ), sum[0] );
+ UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( GCOMP ), sum[1] );
+ UNCLAMPED_FLOAT_TO_UBYTE( LIT_COLOR( BCOMP ), sum[2] );
+#endif
+ LIT_COLOR( ACOMP ) = LIT_ALPHA;
+}
+
+
+
+static void TAG(init_norm)( void )
+{
+ norm_tab[IND].normal3f_single = TAG(Normal3f_single);
+ norm_tab[IND].normal3fv_single = TAG(Normal3fv_single);
+ norm_tab[IND].normal3f_multi = TAG(Normal3f_multi);
+ norm_tab[IND].normal3fv_multi = TAG(Normal3fv_multi);
+}
+
+
+
+#ifndef PRESERVE_NORMAL_DEFS
+#undef GET_CURRENT
+#undef GET_CURRENT_VERTEX
+#undef LIT_COLOR
+#undef LIT_COLOR_IS_FLOAT
+#endif
+#undef PRESERVE_NORMAL_DEFS
+#undef IND
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_primtmp.h b/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_primtmp.h
new file mode 100644
index 000000000..97dca3fd4
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_primtmp.h
@@ -0,0 +1,570 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Keith Whitwell <keithw@valinux.com>
+ * Gareth Hughes <gareth@valinux.com>
+ */
+
+/* Template for immediate mode vertices.
+ *
+ * Probably instantiate once for each vertex format used:
+ * - TINY_VERTICES
+ * - TEX0_VERTICES
+ * - TEX1_VERTICES
+ * - PTEX_VERTICES
+ *
+ * Have to handle TEX->PTEX transition somehow.
+ */
+
+#define DBG 0
+
+
+
+/* =============================================================
+ * GL_POINTS
+ */
+
+static void TAG(flush_point_0)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ if ( !v0->mask ) {
+ LOCAL_VARS;
+ DRAW_POINT( v0 );
+ }
+}
+
+
+/* =============================================================
+ * GL_LINES
+ */
+
+static void TAG(flush_line_1)( GLcontext *ctx, TNL_VERTEX *v0 );
+
+static void TAG(flush_line_0)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ FLUSH_VERTEX = TAG(flush_line_1);
+ ACTIVE_VERTEX = IMM_VERTICES( 1 );
+}
+
+static void TAG(flush_line_1)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ TNL_VERTEX *v1 = v0 - 1;
+ ACTIVE_VERTEX = IMM_VERTICES( 0 );
+ FLUSH_VERTEX = TAG(flush_line_0);
+ if (FALLBACK_OR_CLIPPING)
+ CLIP_OR_DRAW_LINE( ctx, v1, v0 );
+ else
+ DRAW_LINE( ctx, v1, v0 );
+}
+
+
+/* =============================================================
+ * GL_LINE_LOOP
+ */
+
+static void TAG(flush_line_loop_2)( GLcontext *ctx, TNL_VERTEX *v0 );
+static void TAG(flush_line_loop_1)( GLcontext *ctx, TNL_VERTEX *v0 );
+
+static void TAG(flush_line_loop_0)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+
+ ACTIVE_VERTEX = v0 + 1;
+ FLUSH_VERTEX = TAG(flush_line_loop_1);
+}
+
+#define DRAW_LINELOOP_LINE( a, b ) \
+ if (!HAVE_LINE_STRIP || FALLBACK_OR_CLIPPING) { \
+ CLIP_OR_DRAW_LINE( ctx, a, b ); \
+ } else if (EXTEND_PRIM( 1 )) { \
+ EMIT_VERTEX( b ); \
+ } else { \
+ BEGIN_PRIM( GL_LINE_STRIP, 2 ); \
+ EMIT_VERTEX( a ); \
+ EMIT_VERTEX( b ); \
+ }
+
+static void TAG(flush_line_loop_1)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ TNL_VERTEX *v1 = v0 - 1;
+ ACTIVE_VERTEX = v1;
+ FLUSH_VERTEX = TAG(flush_line_loop_2);
+ DRAW_LINELOOP_LINE( v1, v0 );
+}
+
+static void TAG(flush_line_loop_2)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ TNL_VERTEX *v1 = v0 + 1;
+ ACTIVE_VERTEX = v1;
+ FLUSH_VERTEX = TAG(flush_line_loop_1);
+ DRAW_LINELOOP_LINE( v1, v0 );
+}
+
+static void TAG(end_line_loop)( GLcontext *ctx )
+{
+ LOCAL_VARS;
+
+ if ( FLUSH_VERTEX != TAG(flush_line_loop_0) ) {
+ TNL_VERTEX *v1 = ACTIVE_VERTEX;
+ TNL_VERTEX *v0 = IMM_VERTICES( 0 );
+ DRAW_LINELOOP_LINE( v1, v0 );
+ }
+}
+
+
+
+/* =============================================================
+ * GL_LINE_STRIP
+ */
+
+static void TAG(flush_line_strip_2)( GLcontext *ctx, TNL_VERTEX *v0 );
+static void TAG(flush_line_strip_1)( GLcontext *ctx, TNL_VERTEX *v0 );
+
+static void TAG(flush_line_strip_0)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+
+ ACTIVE_VERTEX = v0 + 1;
+ FLUSH_VERTEX = TAG(flush_line_strip_0b);
+}
+
+
+static void TAG(flush_line_strip_1)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ TNL_VERTEX *v1 = v0 - 1;
+
+ ACTIVE_VERTEX = v1;
+ FLUSH_VERTEX = TAG(flush_line_strip_2);
+
+ if (!HAVE_LINE_STRIP || FALLBACK_OR_CLIPPING)
+ CLIP_OR_DRAW_LINE( ctx, v1, v0 );
+ else if (EXTEND_PRIM( 1 )) {
+ EMIT_VERTEX( v0 );
+ } else {
+ BEGIN_PRIM( GL_LINE_STRIP, 2 );
+ EMIT_VERTEX( v1 );
+ EMIT_VERTEX( v0 );
+ }
+}
+
+static void TAG(flush_line_strip_2)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ TNL_VERTEX *v1 = v0 + 1;
+
+ ACTIVE_VERTEX = v1;
+ FLUSH_VERTEX = TAG(flush_line_strip_1);
+
+ if (!HAVE_LINE_STRIP || FALLBACK_OR_CLIPPING)
+ CLIP_OR_DRAW_LINE( ctx, v1, v0 );
+ else if (EXTEND_PRIM( 1 )) {
+ EMIT_VERTEX( v0 );
+ } else {
+ BEGIN_PRIM( GL_LINE_STRIP, 2 );
+ EMIT_VERTEX( v1 );
+ EMIT_VERTEX( v0 );
+ }
+}
+
+
+
+/* =============================================================
+ * GL_TRIANGLES
+ */
+
+static void TAG(flush_triangle_2)( GLcontext *ctx, TNL_VERTEX *v0 );
+static void TAG(flush_triangle_1)( GLcontext *ctx, TNL_VERTEX *v0 );
+
+static void TAG(flush_triangle_0)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+
+ if ( DBG ) fprintf( stderr, __FUNCTION__ "\n" );
+
+ ACTIVE_VERTEX = v0 + 1;
+ FLUSH_VERTEX = TAG(flush_triangle_1);
+ BEGIN_PRIM( GL_TRIANGLES, 0 );
+}
+
+static void TAG(flush_triangle_1)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+
+ if ( DBG ) fprintf( stderr, __FUNCTION__ "\n" );
+
+ ACTIVE_VERTEX = v0 + 1;
+ FLUSH_VERTEX = TAG(flush_triangle_2);
+}
+
+static void TAG(flush_triangle_2)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ TNL_VERTEX *v2 = v0 - 2;
+ TNL_VERTEX *v1 = v0 - 1;
+
+ if ( DBG ) fprintf( stderr, __FUNCTION__ "\n" );
+
+ ACTIVE_VERTEX = v2;
+ FLUSH_VERTEX = TAG(flush_triangle_0);
+
+ /* nothing gained by trying to emit as hw primitives -- that
+ * happens normally in this case.
+ */
+ if (FALLBACK_OR_CLIPPING)
+ CLIP_OR_DRAW_TRI( ctx, v2, v1, v0 );
+ else
+ DRAW_TRI( ctx, v2, v1, v0 );
+}
+
+
+
+
+/* =============================================================
+ * GL_TRIANGLE_STRIP
+ */
+
+static void TAG(flush_tri_strip_3)( GLcontext *ctx, TNL_VERTEX *v0 );
+static void TAG(flush_tri_strip_2)( GLcontext *ctx, TNL_VERTEX *v0 );
+static void TAG(flush_tri_strip_1)( GLcontext *ctx, TNL_VERTEX *v0 );
+
+static void TAG(flush_tri_strip_0)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ ACTIVE_VERTEX = IMM_VERTICES( 1 );
+ FLUSH_VERTEX = TAG(flush_tri_strip_1);
+}
+
+static void TAG(flush_tri_strip_1)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ ACTIVE_VERTEX = IMM_VERTICES( 2 );
+ FLUSH_VERTEX = TAG(flush_tri_strip_2);
+}
+
+#define DO_TRISTRIP_TRI( vert0, vert1 ) \
+ if (!HAVE_TRI_STRIP || FALLBACK_OR_CLIPPING) { \
+ TNL_VERTEX *v2 = IMM_VERTICES( vert0 ); \
+ TNL_VERTEX *v1 = IMM_VERTICES( vert1 ); \
+ TAG(draw_tri)( ctx, v2, v1, v0 ); \
+ } else if (EXTEND_PRIM( 1 )) { \
+ EMIT_VERTEX( v0 ); \
+ } else { \
+ TNL_VERTEX *v2 = IMM_VERTICES( vert0 ); \
+ TNL_VERTEX *v1 = IMM_VERTICES( vert1 ); \
+ BEGIN_PRIM( GL_TRIANGLE_STRIP, 3 ); \
+ EMIT_VERTEX( v2 ); \
+ EMIT_VERTEX( v1 ); \
+ EMIT_VERTEX( v0 ); \
+ }
+
+static void TAG(flush_tri_strip_2)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ FLUSH_VERTEX = TAG(flush_tri_strip_3);
+ ACTIVE_VERTEX = IMM_VERTICES( 3 );
+ DO_TRISTRIP_TRI( 0, 1 );
+}
+
+static void TAG(flush_tri_strip_3)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ FLUSH_VERTEX = TAG(flush_tri_strip_4);
+ ACTIVE_VERTEX = IMM_VERTICES( 0 );
+ DO_TRISTRIP_TRI( 1, 2 );
+}
+
+static void TAG(flush_tri_strip_4)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ FLUSH_VERTEX = TAG(flush_tri_strip_5);
+ ACTIVE_VERTEX = IMM_VERTICES( 1 );
+ DO_TRISTRIP_TRI( 2, 3 );
+}
+
+static void TAG(flush_tri_strip_5)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ FLUSH_VERTEX = TAG(flush_tri_strip_2);
+ ACTIVE_VERTEX = IMM_VERTICES( 2 );
+ DO_TRISTRIP_TRI( 0, 3 );
+}
+
+
+
+/* =============================================================
+ * GL_TRIANGLE_FAN
+ */
+
+static void TAG(flush_tri_fan_2)( GLcontext *ctx, TNL_VERTEX *v0 );
+static void TAG(flush_tri_fan_1)( GLcontext *ctx, TNL_VERTEX *v0 );
+
+static void TAG(flush_tri_fan_0)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+
+ ACTIVE_VERTEX = v0 + 1;
+ FLUSH_VERTEX = TAG(flush_tri_fan_1);
+}
+
+static void TAG(flush_tri_fan_1)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+
+ ACTIVE_VERTEX = v0 + 1;
+ FLUSH_VERTEX = TAG(flush_tri_fan_2);
+}
+
+#define DO_TRIFAN_TRI( vert0, vert1 ) \
+ if (!HAVE_TRI_FAN || FALLBACK_OR_CLIPPING) { \
+ TNL_VERTEX *v2 = IMM_VERTICES( vert0 ); \
+ TNL_VERTEX *v1 = IMM_VERTICES( vert1 ); \
+ TAG(draw_tri)( ctx, v2, v1, v0 ); \
+ } else if (EXTEND_PRIM( 1 )) { \
+ EMIT_VERTEX( v0 ); \
+ } else { \
+ TNL_VERTEX *v2 = IMM_VERTICES( vert0 ); \
+ TNL_VERTEX *v1 = IMM_VERTICES( vert1 ); \
+ BEGIN_PRIM( GL_TRIANGLE_FAN, 3 ); \
+ EMIT_VERTEX( v2 ); \
+ EMIT_VERTEX( v1 ); \
+ EMIT_VERTEX( v0 ); \
+ }
+
+static void TAG(flush_tri_fan_2)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ ACTIVE_VERTEX = IMM_VERTICES( 1 );
+ FLUSH_VERTEX = TAG(flush_tri_fan_3 );
+ DO_TRIFAN_TRI( 0, 1 );
+}
+
+static void TAG(flush_tri_fan_3)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ ACTIVE_VERTEX = IMM_VERTICES( 2 );
+ FLUSH_VERTEX = TAG(flush_tri_fan_2 );
+ DO_TRIFAN_TRI( 0, 2 );
+}
+
+
+
+/* =============================================================
+ * GL_QUADS
+ */
+
+static void TAG(flush_quad_3)( GLcontext *ctx, TNL_VERTEX *v0 );
+static void TAG(flush_quad_2)( GLcontext *ctx, TNL_VERTEX *v0 );
+static void TAG(flush_quad_1)( GLcontext *ctx, TNL_VERTEX *v0 );
+
+static void TAG(flush_quad_0)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ IMM_VERTEX( v0 ) = v0 + 1;
+ FLUSH_VERTEX = TAG(flush_quad_1);
+}
+
+static void TAG(flush_quad_1)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ IMM_VERTEX( v0 ) = v0 + 1;
+ FLUSH_VERTEX = TAG(flush_quad_2);
+}
+
+static void TAG(flush_quad_2)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ IMM_VERTEX( v0 ) = v0 + 1;
+ FLUSH_VERTEX = TAG(flush_quad_3);
+}
+
+static void TAG(flush_quad_3)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ TNL_VERTEX *v3 = v0 - 3;
+ TNL_VERTEX *v2 = v0 - 2;
+ TNL_VERTEX *v1 = v0 - 1;
+
+ IMM_VERTEX( v0 ) = v3;
+ FLUSH_VERTEX = TAG(flush_quad_0);
+
+ if (!HAVE_HW_QUADS || FALLBACK_OR_CLIPPING) {
+ CLIP_OR_DRAW_TRI( ctx, v3, v2, v0 );
+ CLIP_OR_DRAW_TRI( ctx, v2, v1, v0 );
+ } else {
+ EXTEND_PRIM_NF( GL_QUADS, 4 );
+ EMIT_VERTEX( v3 );
+ EMIT_VERTEX( v2 );
+ EMIT_VERTEX( v1 );
+ EMIT_VERTEX( v0 );
+ }
+}
+
+
+
+/* =============================================================
+ * GL_QUAD_STRIP
+ */
+
+static void TAG(flush_quad_strip_3)( GLcontext *ctx, TNL_VERTEX *v0 );
+static void TAG(flush_quad_strip_2)( GLcontext *ctx, TNL_VERTEX *v0 );
+static void TAG(flush_quad_strip_1)( GLcontext *ctx, TNL_VERTEX *v0 );
+
+static void TAG(flush_quad_strip_0)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+
+ IMM_VERTEX( v3 ) = v0;
+ IMM_VERTEX( v0 ) = v0 + 1;
+ FLUSH_VERTEX = TAG(flush_quad_strip_1);
+}
+
+static void TAG(flush_quad_strip_1)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+
+ IMM_VERTEX( v2 ) = v0;
+ IMM_VERTEX( v0 ) = v0 + 1;
+ FLUSH_VERTEX = TAG(flush_quad_strip_2);
+}
+
+static void TAG(flush_quad_strip_2)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+
+ IMM_VERTEX( v1 ) = v0;
+ IMM_VERTEX( v0 ) = v0 + 1;
+ FLUSH_VERTEX = TAG(flush_quad_strip_3);
+}
+
+static void TAG(flush_quad_strip_3)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ TNL_VERTEX *v3 = IMM_VERTEX( v3 );
+ TNL_VERTEX *v2 = IMM_VERTEX( v2 );
+ TNL_VERTEX *v1 = IMM_VERTEX( v1 );
+
+ IMM_VERTEX( v0 ) = v3;
+ IMM_VERTEX( v2 ) = v0;
+ IMM_VERTEX( v3 ) = v1;
+ FLUSH_VERTEX = TAG(flush_quad_strip_2);
+
+ if (FALLBACK_OR_CLIPPING) {
+ CLIP_OR_DRAW_TRI( ctx, v3, v2, v0 );
+ CLIP_OR_DRAW_TRI( ctx, v2, v1, v0 );
+ } else {
+ DRAW_TRI( ctx, v3, v2, v0 );
+ DRAW_TRI( ctx, v2, v1, v0 );
+ }
+}
+
+
+
+/* =============================================================
+ * GL_POLYGON
+ */
+
+static void TAG(flush_poly_2)( GLcontext *ctx, TNL_VERTEX *v0 );
+static void TAG(flush_poly_1)( GLcontext *ctx, TNL_VERTEX *v0 );
+
+static void TAG(flush_poly_0)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ ACTIVE_VERTEX = IMM_VERTICES( 1 );
+ FLUSH_VERTEX = TAG(flush_poly_1);
+}
+
+static void TAG(flush_poly_1)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ ACTIVE_VERTEX = IMM_VERTICES( 2 );
+ FLUSH_VERTEX = TAG(flush_poly_2);
+}
+
+#define DO_POLY_TRI( vert0, vert1 ) \
+ if (!HAVE_POLYGONS || FALLBACK_OR_CLIPPING) { \
+ TNL_VERTEX *v2 = IMM_VERTICES( vert0 ); \
+ TNL_VERTEX *v1 = IMM_VERTICES( vert1 ); \
+ TAG(draw_tri)( ctx, v1, v0, v2 ); \
+ } else if (EXTEND_PRIM( 1 )) { \
+ EMIT_VERTEX( v0 ); \
+ } else { \
+ TNL_VERTEX *v2 = IMM_VERTICES( vert0 ); \
+ TNL_VERTEX *v1 = IMM_VERTICES( vert1 ); \
+ BEGIN_PRIM( GL_POLYGON, 3 ); \
+ EMIT_VERTEX( v2 ); \
+ EMIT_VERTEX( v1 ); \
+ EMIT_VERTEX( v0 ); \
+ }
+
+static void TAG(flush_poly_2)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ ACTIVE_VERTEX = IMM_VERTICES( 1 );
+ FLUSH_VERTEX = TAG(flush_poly_3);
+ DO_POLY_TRI( 0, 1 );
+}
+
+static void TAG(flush_poly_3)( GLcontext *ctx, TNL_VERTEX *v0 )
+{
+ LOCAL_VARS;
+ ACTIVE_VERTEX = IMM_VERTICES( 2 );
+ FLUSH_VERTEX = TAG(flush_poly_2);
+ DO_POLY_TRI( 0, 2 );
+}
+
+
+void (*TAG(flush_tab)[GL_POLYGON+1])( GLcontext *, TNL_VERTEX * ) =
+{
+ TAG(flush_point),
+ TAG(flush_line_0),
+ TAG(flush_line_loop_0),
+ TAG(flush_line_strip_0),
+ TAG(flush_triangle_0),
+ TAG(flush_tri_strip_0),
+ TAG(flush_tri_fan_0),
+ TAG(flush_quad_0),
+ TAG(flush_quad_strip_0),
+ TAG(flush_poly_0),
+};
+
+
+#ifndef PRESERVE_PRIM_DEFS
+#undef LOCAL_VARS
+#undef GET_INTERP_FUNC
+#undef IMM_VERTEX
+#undef IMM_VERTICES
+#undef FLUSH_VERTEX
+#endif
+#undef PRESERVE_PRIM_DEFS
+#undef EXTEND_PRIM
+#undef EMIT_VERTEX
+#undef EMIT_VERTEX_TRI
+#undef EMIT_VERTEX_LINE
+#undef EMIT_VERTEX_POINT
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_tapi.h b/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_tapi.h
new file mode 100644
index 000000000..b82a9abeb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_tapi.h
@@ -0,0 +1,75 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Keith Whitwell <keith_whitwell@yahoo.com>
+ */
+
+/* Template for immediate mode texture coordinate functions.
+ */
+
+#ifndef DO_PROJ_TEX
+#error "Need to define DO_PROJ_TEX"
+#endif
+
+
+/* =============================================================
+ * Notify on calls to texture4f, to allow switch to projected texture
+ * vertex format:
+ */
+
+static void TAG(TexCoord4f)( GLfloat s, GLfloat t, GLfloat r, GLfloat q )
+{
+ GET_CURRENT;
+ DO_PROJ_TEX;
+ TEXCOORD4( s, t, r, q );
+}
+
+static void TAG(TexCoord4fv)( const GLfloat *v )
+{
+ GET_CURRENT;
+ DO_PROJ_TEX;
+ TEXCOORD4( v[0], v[1], v[2], v[3] );
+}
+
+static void TAG(MultiTexCoord4fARB)( GLenum target, GLfloat s,
+ GLfloat t, GLfloat r, GLfloat q )
+{
+ GET_CURRENT;
+ DO_PROJ_TEX;
+ MULTI_TEXCOORD4( unit, s, t, r, q );
+}
+
+static void TAG(MultiTexCoord4fvARB)( GLenum target, const GLfloat *v )
+{
+ GET_CURRENT;
+ DO_PROJ_TEX;
+ MULTI_TEXCOORD4( unit, v[0], v[1], v[2], v[3] );
+}
+
+
+
+#undef DO_PROJ_TEX
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_vapi.h b/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_vapi.h
new file mode 100644
index 000000000..95e93b1c8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_vapi.h
@@ -0,0 +1,159 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Gareth Hughes <gareth@valinux.com>
+ * Keith Whitwell <keithw@valinux.com>
+ */
+
+/* Template for immediate mode vertex functions.
+ */
+
+#define DBG 0
+
+#define VERTEX( ox, oy, oz, ow )
+do {
+ GET_CURRENT_VERTEX;
+ GLfloat w;
+ GLuint mask;
+ const GLfloat * const m = ctx->_ModelProjectMatrix.m;
+
+ if (DO_FULL_MATRIX) {
+ VERTEX_CLIP(0) = m[0] * ox + m[4] * oy + m[8] * oz + m[12] * ow;
+ VERTEX_CLIP(1) = m[1] * ox + m[5] * oy + m[9] * oz + m[13] * ow;
+ VERTEX_CLIP(2) = m[2] * ox + m[6] * oy + m[10] * oz + m[14] * ow;
+ VERTEX_CLIP(3) = m[3] * ox + m[7] * oy + m[11] * oz + m[15] * ow;
+ w = VERTEX_CLIP(3);
+ }
+ else if (DO_NOROT_MATRIX) {
+ VERTEX_CLIP(0) = m[0] * ox + m[12] * ow;
+ VERTEX_CLIP(1) = m[5] * oy + m[13] * ow;
+ VERTEX_CLIP(2) = m[10] * oz + m[14] * ow;
+ VERTEX_CLIP(3) = ow;
+ w = ow;
+ }
+ else {
+ ASSERT (DO_IDENTITY_MATRIX);
+ VERTEX_CLIP(0) = ox;
+ VERTEX_CLIP(1) = oy;
+ VERTEX_CLIP(2) = oz;
+ VERTEX_CLIP(3) = ow;
+ w = ow;
+ }
+
+ mask = 0;
+ if (DO_CLIP_TEST) {
+ if ( VERTEX_CLIP(0) > w ) mask |= CLIP_RIGHT_BIT;
+ if ( VERTEX_CLIP(0) < -w ) mask |= CLIP_LEFT_BIT;
+ if ( VERTEX_CLIP(1) > w ) mask |= CLIP_TOP_BIT;
+ if ( VERTEX_CLIP(1) < -w ) mask |= CLIP_BOTTOM_BIT;
+ if ( VERTEX_CLIP(2) > w ) mask |= CLIP_FAR_BIT;
+ if ( VERTEX_CLIP(2) < -w ) mask |= CLIP_NEAR_BIT;
+ VERTEX_MASK(v) = mask;
+ }
+
+ if (!mask) {
+ if (HAVE_VERTEX_WIN) {
+ if (!HAVE_HW_VIEWPORT) {
+ const GLfloat *s = GET_VIEWPORT_MATRIX();
+ if (HAVE_W && HAVE_HW_DIVIDE) {
+ VERTEX_WIN( 0 ) = s[0] * VERTEX_CLIP( 0 ) + s[12];
+ VERTEX_WIN( 1 ) = s[5] * VERTEX_CLIP( 1 ) + s[13];
+ VERTEX_WIN( 2 ) = s[10] * VERTEX_CLIP( 2 ) + s[14];
+ VERTEX_WIN( 3 ) = w;
+ }
+ else {
+ const GLfloat oow = 1.0/w; /* possibly opt away */
+ VERTEX_WIN( 0 ) = s[0] * VERTEX_CLIP( 0 ) * oow + s[12];
+ VERTEX_WIN( 1 ) = s[5] * VERTEX_CLIP( 1 ) * oow + s[13];
+ VERTEX_WIN( 2 ) = s[10] * VERTEX_CLIP( 2 ) * oow + s[14];
+ if (HAVE_W)
+ VERTEX_WIN( 3 ) = oow;
+ }
+ }
+ else if (HAVE_W && HAVE_HW_DIVIDE) {
+ if (!VERTEX_WIN_IS_VERTEX_CLIP) {
+ VERTEX_WIN( 0 ) = VERTEX_CLIP( 0 );
+ VERTEX_WIN( 1 ) = VERTEX_CLIP( 1 );
+ VERTEX_WIN( 2 ) = VERTEX_CLIP( 2 );
+ VERTEX_WIN( 3 ) = w;
+ }
+ }
+ else {
+ const GLfloat oow = 1.0/w; /* possibly opt away */
+ VERTEX_WIN( 0 ) = VERTEX_CLIP( 0 ) * oow;
+ VERTEX_WIN( 1 ) = VERTEX_CLIP( 1 ) * oow;
+ VERTEX_WIN( 2 ) = VERTEX_CLIP( 2 ) * oow;
+ if (HAVE_W)
+ VERTEX_WIN( 3 ) = oow;
+ }
+ }
+ } else if (!FALLBACK_OR_CLIPPING) {
+ SET_CLIPPING(); /* transition to clipping */
+ }
+
+ COPY_VERTEX_FROM_CURRENT;
+ BUILD_PRIM_FROM_VERTEX;
+}
+
+/* Let the compiler optimize away the constant operations:
+ */
+static void VTAG(Vertex2f)( GLfloat ox, GLfloat oy )
+{
+ /* Cliptest on clip[2] could also be eliminated...
+ */
+ VERTEX( ox, oy, 0, 1 );
+}
+
+static void VTAG(Vertex2fv)( const GLfloat *obj )
+{
+ /* Cliptest on clip[2] could also be eliminated...
+ */
+ VERTEX( obj[0], obj[1], 0, 1 );
+}
+
+static void VTAG(Vertex3f)( GLfloat ox, GLfloat oy, GLfloat oz )
+{
+ VERTEX( ox, oy, oz, 1 );
+}
+
+static void VTAG(Vertex3fv)( const GLfloat *obj )
+{
+ VERTEX( obj[0], obj[1], obj[2], 1 );
+}
+
+static void VTAG(Vertex4f)( GLfloat ox, GLfloat oy, GLfloat oz, GLfloat ow )
+{
+ VERTEX( ox, oy, oz, ow );
+}
+
+static void VTAG(Vertex4fv)( const GLfloat *obj )
+{
+ VERTEX( obj[0], obj[1], obj[2], obj[3] );
+}
+
+
+#undef DO_FULL_MATRIX
+#undef VTAG
+#undef VERTEX
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_vb.c b/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_vb.c
new file mode 100644
index 000000000..0c4462f55
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_vb.c
@@ -0,0 +1,204 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith_whitwell@yahoo.com>
+ */
+
+/* Template to build clipping routines to support t_dd_imm_primtmp.h.
+ *
+ * The TAG(draw_line) and TAG(draw_triangle) routines are called in
+ * clipping and fallback scenarios, and when the native hardware
+ * primitive (eg polygons) is unavailable.
+ */
+
+
+#define CLIP_DOTPROD(K, A, B, C, D) \
+ (CLIP_X(K)*A + CLIP_Y(K)*B + \
+ CLIP_Z(K)*C + CLIP_W(K)*D)
+
+#define POLY_CLIP( PLANE, A, B, C, D ) \
+do { \
+ if (mask & PLANE) { \
+ TNL_VERTEX **indata = inlist[in]; \
+ TNL_VERTEX **outdata = inlist[in ^= 1]; \
+ TNL_VERTEX *J = indata[0]; \
+ GLfloat dpJ = CLIP_DOTPROD(J, A, B, C, D ); \
+ GLuint outcount = 0; \
+ GLuint i; \
+ \
+ indata[n] = indata[0]; /* prevent rotation of vertices */ \
+ for (i = 1; i <= n; i++) { \
+ TNL_VERTEX *I = indata[i]; \
+ GLfloat dpI = CLIP_DOTPROD(idx, A, B, C, D ); \
+ \
+ if (!NEGATIVE(dpPrev)) { \
+ outdata[outcount++] = J; \
+ } \
+ \
+ if (DIFFERENT_SIGNS(dpI, dpJ)) { \
+ TNL_VERTEX *O = verts++; \
+ outdata[outcount++] = O; \
+ if (NEGATIVE(dpI)) { \
+ /* Going out of bounds. Avoid division by zero as we \
+ * know dp != dpPrev from DIFFERENT_SIGNS, above. \
+ */ \
+ GLfloat t = dpI / (dpI - dpJ); \
+ INTERP( ctx, t, O, I, J ); \
+ } else { \
+ /* Coming back in. \
+ */ \
+ GLfloat t = dpJ / (dpJ - dpI); \
+ INTERP( ctx, t, O, J, I ); \
+ } \
+ } \
+ \
+ J = I; \
+ dpJ = dpI; \
+ } \
+ \
+ if (outcount < 3) \
+ return; \
+ \
+ nr = outcount; \
+ } \
+} while (0)
+
+
+#define LINE_CLIP(PLANE, A, B, C, D ) \
+do { \
+ if (mask & PLANE) { \
+ GLfloat dpI = CLIP_DOTPROD( I, A, B, C, D ); \
+ GLfloat dpJ = CLIP_DOTPROD( J, A, B, C, D ); \
+ \
+ if (DIFFERENT_SIGNS(dpI, dpJ)) { \
+ TNL_VERTEX *O = verts++; \
+ if (NEGATIVE(dpJ)) { \
+ GLfloat t = dpI / (dpI - dpJ); \
+ INTERP( ctx, t, O, I, J ); \
+ J = O; \
+ } else { \
+ GLfloat t = dpJ / (dpJ - dpI); \
+ INTERP( ctx, t, O, J, I ); \
+ I = O; \
+ } \
+ } \
+ else if (NEGATIVE(dpI)) \
+ return; \
+ } \
+} while (0)
+
+
+
+/* Clip a line against the viewport and user clip planes.
+ */
+static void TAG(clip_draw_line)( GLcontext *ctx,
+ TNL_VERTEX *I,
+ TNL_VERTEX *J,
+ GLuint mask )
+{
+ LOCAL_VARS;
+ GET_INTERP_FUNC;
+ TNL_VERTEX tmp[MAX_CLIPPED_VERTICES];
+ TNL_VERTEX *verts = tmp;
+ TNL_VERTEX *pv = J;
+
+ LINE_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 );
+ LINE_CLIP( CLIP_LEFT_BIT, 1, 0, 0, 1 );
+ LINE_CLIP( CLIP_TOP_BIT, 0, -1, 0, 1 );
+ LINE_CLIP( CLIP_BOTTOM_BIT, 0, 1, 0, 1 );
+ LINE_CLIP( CLIP_FAR_BIT, 0, 0, -1, 1 );
+ LINE_CLIP( CLIP_NEAR_BIT, 0, 0, 1, 1 );
+
+ if ((ctx->_TriangleCaps & DD_FLATSHADE) && J != pv)
+ COPY_PV( ctx, J, pv );
+
+ DRAW_LINE( I, J );
+}
+
+
+/* Clip a triangle against the viewport and user clip planes.
+ */
+static void TAG(clip_draw_triangle)( GLcontext *ctx,
+ TNL_VERTEX *v0,
+ TNL_VERTEX *v1,
+ TNL_VERTEX *v2,
+ GLuint mask )
+{
+ LOCAL_VARS;
+ GET_INTERP_FUNC;
+ TNL_VERTEX tmp[MAX_CLIPPED_VERTICES];
+ TNL_VERTEX *verts = tmp;
+ TNL_VERTEX *(inlist[2][MAX_CLIPPED_VERTICES]);
+ TNL_VERTEX **out;
+ GLuint in = 0;
+ GLuint n = 3;
+ GLuint i;
+
+ ASSIGN_3V(inlist, v2, v0, v1 ); /* pv rotated to slot zero */
+
+ POLY_CLIP( CLIP_RIGHT_BIT, -1, 0, 0, 1 );
+ POLY_CLIP( CLIP_LEFT_BIT, 1, 0, 0, 1 );
+ POLY_CLIP( CLIP_TOP_BIT, 0, -1, 0, 1 );
+ POLY_CLIP( CLIP_BOTTOM_BIT, 0, 1, 0, 1 );
+ POLY_CLIP( CLIP_FAR_BIT, 0, 0, -1, 1 );
+ POLY_CLIP( CLIP_NEAR_BIT, 0, 0, 1, 1 );
+
+ if ((ctx->_TriangleCaps & DD_FLATSHADE) && v2 != inlist[0])
+ COPY_PV( ctx, inlist[0], v2 );
+
+ out = inlist[in];
+ DRAW_POLYGON( out, n );
+}
+
+
+static __inline void TAG(draw_triangle)( GLcontext *ctx,
+ TNL_VERTEX *v0,
+ TNL_VERTEX *v1,
+ TNL_VERTEX *v2 )
+{
+ LOCAL_VARS;
+ GLubyte ormask = (v0->mask | v1->mask | v2->mask);
+
+ if ( !ormask ) {
+ DRAW_TRI( v0, v1, v2 );
+ } else if ( !(v0->mask & v1->mask & v2->mask) ) {
+ TAG(clip_draw_triangle)( ctx, v0, v1, v2, ormask );
+ }
+}
+
+static __inline void TAG(draw_line)( GLcontext *ctx,
+ TNL_VERTEX *v0,
+ TNL_VERTEX *v1 )
+{
+ LOCAL_VARS;
+ GLubyte ormask = (v0->mask | v1->mask);
+
+ if ( !ormask ) {
+ DRAW_LINE( v0, v1 );
+ } else if ( !(v0->mask & v1->mask) ) {
+ TAG(clip_draw_line)( ctx, v0, v1, ormask );
+ }
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_vbtmp.h b/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_vbtmp.h
new file mode 100644
index 000000000..2f76553cf
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/imm/t_dd_imm_vbtmp.h
@@ -0,0 +1,268 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith_whitwell@yahoo.com>
+ */
+
+/* Template to build support for t_dd_imm_* tnl module using vertices
+ * as defined in t_dd_vertex.h.
+ *
+ * See t_dd_vbtmp.h for definitions of arguments to this file.
+ * Unfortunately it seems necessary to duplicate a lot of that code.
+ */
+
+#ifndef LOCALVARS
+#define LOCALVARS
+#endif
+
+
+
+/* COPY_VERTEX_FROM_CURRENT in t_dd_imm_vapi.c
+ */
+static void TAG(emit_vfmt)( GLcontext *ctx, VERTEX *v )
+{
+ LOCALVARS
+ ;
+
+ /* This template assumes (like t_dd_vbtmp.h) that color is ubyte.
+ */
+ if (DO_TEX0 || DO_TEX1 || !HAVE_TINY_VERTICES)
+ {
+ const GLubyte *col = GET_HARDWARE_COLOR();
+ if (HAVE_RGBA_COLOR) {
+ v->v.ui[4] = *(GLuint *)&col;
+ } else {
+ v->v.color.blue = col[2];
+ v->v.color.green = col[1];
+ v->v.color.red = col[0];
+ v->v.color.alpha = col[3];
+ }
+ }
+ else {
+ if (HAVE_RGBA_COLOR) {
+ v->v.ui[3] = *(GLuint *)col;
+ }
+ else {
+ v->tv.color.blue = col[2];
+ v->tv.color.green = col[1];
+ v->tv.color.red = col[0];
+ v->tv.color.alpha = col[3];
+ }
+ }
+
+ if (DO_TEX0) {
+ GLfloat *tc = ctx->Current.Texture[0];
+ v->v.u0 = tc[0];
+ v->v.v0 = tc[1];
+ if (DO_PTEX) {
+ if (HAVE_PTEX_VERTICES) {
+ v->pv.q0 = tc[3];
+ }
+ else {
+ float rhw = 1.0 / tc[3];
+ v->v.w *= tc[3];
+ v->v.u0 *= rhw;
+ v->v.v0 *= rhw;
+ }
+ }
+ }
+ if (DO_TEX1) {
+ GLfloat *tc = ctx->Current.Texture[1];
+ if (DO_PTEX) {
+ v->pv.u1 = tc[0];
+ v->pv.v1 = tc[1];
+ v->pv.q1 = tc[3];
+ }
+ else {
+ v->v.u1 = tc[0];
+ v->v.v1 = tc[1];
+ }
+ }
+ else if (DO_PTEX) {
+ *(GLuint *)&v->pv.q1 = 0; /* avoid culling on radeon */
+ }
+ if (DO_TEX2) {
+ GLfloat *tc = ctx->Current.Texture[2];
+ if (DO_PTEX) {
+ v->pv.u2 = tc[0];
+ v->pv.v2 = tc[1];
+ v->pv.q2 = tc[3];
+ }
+ else {
+ v->v.u2 = tc[0];
+ v->v.v2 = tc[1];
+ }
+ }
+ if (DO_TEX3) {
+ GLfloat *tc = ctx->Current.Texture[3];
+ if (DO_PTEX) {
+ v->pv.u3 = tc[0];
+ v->pv.v3 = tc[1];
+ v->pv.q3 = tc[3];
+ }
+ else {
+ v->v.u3 = tc[0];
+ v->v.v3 = tc[1];
+ }
+ }
+}
+
+
+
+
+static void TAG(interp)( GLcontext *ctx,
+ GLfloat t,
+ TNL_VERTEX *dst,
+ TNL_VERTEX *in,
+ TNL_VERTEX *out )
+{
+ LOCALVARS
+ const GLfloat *s = GET_VIEWPORT_MAT();
+ GLfloat w;
+
+ (void)s;
+
+ if (HAVE_HW_DIVIDE) {
+ VIEWPORT_X( dst->v.v.x, dst->clip[0] );
+ VIEWPORT_Y( dst->v.v.y, dst->clip[1] );
+ VIEWPORT_Z( dst->v.v.z, dst->clip[2] );
+ w = dstclip[3];
+ }
+ else {
+ w = 1.0 / dst->clip[3];
+ VIEWPORT_X( dst->v.v.x, dst->clip[0] * w );
+ VIEWPORT_Y( dst->v.v.y, dst->clip[1] * w );
+ VIEWPORT_Z( dst->v.v.z, dst->clip[2] * w );
+ }
+
+ if (HAVE_HW_DIVIDE || DO_TEX0) {
+
+ dst->v.v.w = w;
+
+ INTERP_UB( t, dst->v.ub4[4][0], out->v.ub4[4][0], in->v.ub4[4][0] );
+ INTERP_UB( t, dst->v.ub4[4][1], out->v.ub4[4][1], in->v.ub4[4][1] );
+ INTERP_UB( t, dst->v.ub4[4][2], out->v.ub4[4][2], in->v.ub4[4][2] );
+ INTERP_UB( t, dst->v.ub4[4][3], out->v.ub4[4][3], in->v.ub4[4][3] );
+
+ if (DO_TEX0) {
+ if (DO_PTEX) {
+ if (HAVE_PTEX_VERTICES) {
+ INTERP_F( t, dst->v.pv.u0, out->v.pv.u0, in->v.pv.u0 );
+ INTERP_F( t, dst->v.pv.v0, out->v.pv.v0, in->v.pv.v0 );
+ INTERP_F( t, dst->v.pv.q0, out->v.pv.q0, in->v.pv.q0 );
+ } else {
+ GLfloat wout = out->clip[3]; /* projected clip */
+ GLfloat win = in->clip[3]; /* projected clip */
+ GLfloat qout = out->v.pv.w / wout;
+ GLfloat qin = in->v.pv.w / win;
+ GLfloat qdst, rqdst;
+
+ ASSERT( !HAVE_HW_DIVIDE ); /* assert win, wout projected clip */
+
+ INTERP_F( t, dst->v.v.u0, out->v.v.u0 * qout, in->v.v.u0 * qin );
+ INTERP_F( t, dst->v.v.v0, out->v.v.v0 * qout, in->v.v.v0 * qin );
+ INTERP_F( t, qdst, qout, qin );
+
+ rqdst = 1.0 / qdst;
+ dst->v.v.u0 *= rqdst;
+ dst->v.v.v0 *= rqdst;
+ dst->v.v.w *= rqdst;
+ }
+ }
+ else {
+ INTERP_F( t, dst->v.v.u0, out->v.v.u0, in->v.v.u0 );
+ INTERP_F( t, dst->v.v.v0, out->v.v.v0, in->v.v.v0 );
+ }
+ }
+ if (DO_TEX1) {
+ if (DO_PTEX) {
+ INTERP_F( t, dst->v.pv.u1, out->v.pv.u1, in->v.pv.u1 );
+ INTERP_F( t, dst->v.pv.v1, out->v.pv.v1, in->v.pv.v1 );
+ INTERP_F( t, dst->v.pv.q1, out->v.pv.q1, in->v.pv.q1 );
+ } else {
+ INTERP_F( t, dst->v.v.u1, out->v.v.u1, in->v.v.u1 );
+ INTERP_F( t, dst->v.v.v1, out->v.v.v1, in->v.v.v1 );
+ }
+ }
+ else if (DO_PTEX) {
+ dst->v.pv.q0 = 0.0; /* must be a valid float on radeon */
+ }
+ if (DO_TEX2) {
+ if (DO_PTEX) {
+ INTERP_F( t, dst->v.pv.u2, out->v.pv.u2, in->v.pv.u2 );
+ INTERP_F( t, dst->v.pv.v2, out->v.pv.v2, in->v.pv.v2 );
+ INTERP_F( t, dst->v.pv.q2, out->v.pv.q2, in->v.pv.q2 );
+ } else {
+ INTERP_F( t, dst->v.v.u2, out->v.v.u2, in->v.v.u2 );
+ INTERP_F( t, dst->v.v.v2, out->v.v.v2, in->v.v.v2 );
+ }
+ }
+ if (DO_TEX3) {
+ if (DO_PTEX) {
+ INTERP_F( t, dst->v.pv.u3, out->v.pv.u3, in->v.pv.u3 );
+ INTERP_F( t, dst->v.pv.v3, out->v.pv.v3, in->v.pv.v3 );
+ INTERP_F( t, dst->v.pv.q3, out->v.pv.q3, in->v.pv.q3 );
+ } else {
+ INTERP_F( t, dst->v.v.u3, out->v.v.u3, in->v.v.u3 );
+ INTERP_F( t, dst->v.v.v3, out->v.v.v3, in->v.v.v3 );
+ }
+ }
+ } else {
+ /* 4-dword vertex. Color is in v[3] and there is no oow coordinate.
+ */
+ INTERP_UB( t, dst->v.ub4[3][0], out->v.ub4[3][0], in->v.ub4[3][0] );
+ INTERP_UB( t, dst->v.ub4[3][1], out->v.ub4[3][1], in->v.ub4[3][1] );
+ INTERP_UB( t, dst->v.ub4[3][2], out->v.ub4[3][2], in->v.ub4[3][2] );
+ INTERP_UB( t, dst->v.ub4[3][3], out->v.ub4[3][3], in->v.ub4[3][3] );
+ }
+}
+
+
+static __inline void TAG(copy_pv)( GLcontext *ctx,
+ TNL_VERTEX *dst,
+ TNL_VERTEX *src )
+{
+ if (DO_TEX0 || DO_TEX1 || !HAVE_TINY_VERTICES) {
+ dst->v.v.ui[4] = src->v.v.ui[4];
+ }
+ else {
+ dst->v.v.ui[3] = src->v.v.ui[3];
+ }
+}
+
+
+
+static void TAG(init)( void )
+{
+ setup_tab[IND].emit = TAG(emit_vfmt);
+ setup_tab[IND].interp = TAG(interp_vfmt);
+}
+
+
+#undef IND
+#undef TAG
+
+
+
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd.c b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd.c
new file mode 100644
index 000000000..731da5c32
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd.c
@@ -0,0 +1,58 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+static void copy_pv_rgba4_spec5( GLcontext *ctx, GLuint edst, GLuint esrc )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ GLubyte *i810verts = (GLubyte *)imesa->verts;
+ GLuint shift = imesa->vertex_stride_shift;
+ i810Vertex *dst = (i810Vertex *)(i810verts + (edst << shift));
+ i810Vertex *src = (i810Vertex *)(i810verts + (esrc << shift));
+ dst->ui[4] = src->ui[4];
+ dst->ui[5] = src->ui[5];
+}
+
+static void copy_pv_rgba4( GLcontext *ctx, GLuint edst, GLuint esrc )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ GLubyte *i810verts = (GLubyte *)imesa->verts;
+ GLuint shift = imesa->vertex_stride_shift;
+ i810Vertex *dst = (i810Vertex *)(i810verts + (edst << shift));
+ i810Vertex *src = (i810Vertex *)(i810verts + (esrc << shift));
+ dst->ui[4] = src->ui[4];
+}
+
+static void copy_pv_rgba3( GLcontext *ctx, GLuint edst, GLuint esrc )
+{
+ i810ContextPtr imesa = I810_CONTEXT( ctx );
+ GLubyte *i810verts = (GLubyte *)imesa->verts;
+ GLuint shift = imesa->vertex_stride_shift;
+ i810Vertex *dst = (i810Vertex *)(i810verts + (edst << shift));
+ i810Vertex *src = (i810Vertex *)(i810verts + (esrc << shift));
+ dst->ui[3] = src->ui[3];
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_dmatmp.h b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_dmatmp.h
new file mode 100644
index 000000000..d274ead2c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_dmatmp.h
@@ -0,0 +1,1254 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.1
+ *
+ * Copyright (C) 1999-2004 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+/* Template for render stages which build and emit vertices directly
+ * to fixed-size dma buffers. Useful for rendering strips and other
+ * native primitives where clipping and per-vertex tweaks such as
+ * those in t_dd_tritmp.h are not required.
+ *
+ * Produces code for both inline triangles and indexed triangles.
+ * Where various primitive types are unaccelerated by hardware, the
+ * code attempts to fallback to other primitive types (quadstrips to
+ * tristrips, lineloops to linestrips), or to indexed vertices.
+ */
+
+#if !defined(HAVE_TRIANGLES)
+#error "must have at least triangles to use render template"
+#endif
+
+#if !HAVE_ELTS
+#define ELTS_VARS(buf)
+#define ALLOC_ELTS(nr) 0
+#define EMIT_ELT( offset, elt )
+#define EMIT_TWO_ELTS( offset, elt0, elt1 )
+#define INCR_ELTS( nr )
+#define ELT_INIT(prim)
+#define GET_CURRENT_VB_MAX_ELTS() 0
+#define GET_SUBSEQUENT_VB_MAX_ELTS() 0
+#define RELEASE_ELT_VERTS()
+#define EMIT_INDEXED_VERTS( ctx, start, count )
+#endif
+
+#ifndef EMIT_TWO_ELTS
+#define EMIT_TWO_ELTS( offset, elt0, elt1 ) \
+do { \
+ EMIT_ELT( offset, elt0 ); \
+ EMIT_ELT( offset+1, elt1 ); \
+} while (0)
+#endif
+
+
+/**********************************************************************/
+/* Render whole begin/end objects */
+/**********************************************************************/
+
+
+
+
+#if (HAVE_ELTS)
+static void *TAG(emit_elts)( GLcontext *ctx, GLuint *elts, GLuint nr,
+ void *buf)
+{
+ GLint i;
+ LOCAL_VARS;
+ ELTS_VARS(buf);
+
+ for ( i = 0 ; i+1 < nr ; i+=2, elts += 2 ) {
+ EMIT_TWO_ELTS( 0, elts[0], elts[1] );
+ INCR_ELTS( 2 );
+ }
+
+ if (i < nr) {
+ EMIT_ELT( 0, elts[0] );
+ INCR_ELTS( 1 );
+ }
+
+ return (void *)ELTPTR;
+}
+#endif
+
+static __inline void *TAG(emit_verts)( GLcontext *ctx, GLuint start,
+ GLuint count, void *buf )
+{
+ return EMIT_VERTS(ctx, start, count, buf);
+}
+
+/***********************************************************************
+ * Render non-indexed primitives.
+ ***********************************************************************/
+
+static void TAG(render_points_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_POINTS) {
+ LOCAL_VARS;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
+ int currentsz;
+ GLuint j, nr;
+
+ INIT( GL_POINTS );
+
+ currentsz = GET_CURRENT_VB_MAX_VERTS();
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count; j += nr ) {
+ nr = MIN2( currentsz, count - j );
+ TAG(emit_verts)( ctx, j, nr, ALLOC_VERTS(nr) );
+ currentsz = dmasz;
+ }
+
+ } else {
+ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__);
+ return;
+ }
+}
+
+static void TAG(render_lines_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_LINES) {
+ LOCAL_VARS;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
+ int currentsz;
+ GLuint j, nr;
+
+ INIT( GL_LINES );
+
+ /* Emit whole number of lines in total and in each buffer:
+ */
+ count -= (count-start) & 1;
+ currentsz = GET_CURRENT_VB_MAX_VERTS();
+ currentsz -= currentsz & 1;
+ dmasz -= dmasz & 1;
+
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count; j += nr ) {
+ nr = MIN2( currentsz, count - j );
+ TAG(emit_verts)( ctx, j, nr, ALLOC_VERTS(nr) );
+ currentsz = dmasz;
+ }
+
+ } else {
+ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__);
+ return;
+ }
+}
+
+
+static void TAG(render_line_strip_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_LINE_STRIPS) {
+ LOCAL_VARS;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
+ int currentsz;
+ GLuint j, nr;
+
+ INIT( GL_LINE_STRIP );
+
+ currentsz = GET_CURRENT_VB_MAX_VERTS();
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j + 1 < count; j += nr - 1 ) {
+ nr = MIN2( currentsz, count - j );
+ TAG(emit_verts)( ctx, j, nr, ALLOC_VERTS(nr) );
+ currentsz = dmasz;
+ }
+
+ FLUSH();
+
+ } else {
+ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__);
+ return;
+ }
+}
+
+
+static void TAG(render_line_loop_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_LINE_STRIPS) {
+ LOCAL_VARS;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
+ int currentsz;
+ GLuint j, nr;
+
+ INIT( GL_LINE_STRIP );
+
+ if (flags & PRIM_BEGIN)
+ j = start;
+ else
+ j = start + 1;
+
+ /* Ensure last vertex won't wrap buffers:
+ */
+ currentsz = GET_CURRENT_VB_MAX_VERTS();
+ currentsz--;
+ dmasz--;
+
+ if (currentsz < 8) {
+ currentsz = dmasz;
+ }
+
+ if (j + 1 < count) {
+ for ( ; j + 1 < count; j += nr - 1 ) {
+ nr = MIN2( currentsz, count - j );
+
+ if (j + nr >= count &&
+ start < count - 1 &&
+ (flags & PRIM_END))
+ {
+ void *tmp;
+ tmp = ALLOC_VERTS(nr+1);
+ tmp = TAG(emit_verts)( ctx, j, nr, tmp );
+ tmp = TAG(emit_verts)( ctx, start, 1, tmp );
+ }
+ else {
+ TAG(emit_verts)( ctx, j, nr, ALLOC_VERTS(nr) );
+ currentsz = dmasz;
+ }
+ }
+
+ }
+ else if (start + 1 < count && (flags & PRIM_END)) {
+ void *tmp;
+ tmp = ALLOC_VERTS(2);
+ tmp = TAG(emit_verts)( ctx, start+1, 1, tmp );
+ tmp = TAG(emit_verts)( ctx, start, 1, tmp );
+ }
+
+ FLUSH();
+
+ } else {
+ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__);
+ return;
+ }
+}
+
+
+static void TAG(render_triangles_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ int dmasz = (GET_SUBSEQUENT_VB_MAX_VERTS()/3) * 3;
+ int currentsz;
+ GLuint j, nr;
+
+ INIT(GL_TRIANGLES);
+
+ currentsz = (GET_CURRENT_VB_MAX_VERTS()/3) * 3;
+
+ /* Emit whole number of tris in total. dmasz is already a multiple
+ * of 3.
+ */
+ count -= (count-start)%3;
+
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count; j += nr) {
+ nr = MIN2( currentsz, count - j );
+ TAG(emit_verts)( ctx, j, nr, ALLOC_VERTS(nr) );
+ currentsz = dmasz;
+ }
+}
+
+
+
+static void TAG(render_tri_strip_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_TRI_STRIPS) {
+ LOCAL_VARS;
+ GLuint j, nr;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
+ int currentsz;
+
+ INIT(GL_TRIANGLE_STRIP);
+
+ currentsz = GET_CURRENT_VB_MAX_VERTS();
+
+ if (currentsz < 8) {
+ currentsz = dmasz;
+ }
+
+ /* From here on emit even numbers of tris when wrapping over buffers:
+ */
+ dmasz -= (dmasz & 1);
+ currentsz -= (currentsz & 1);
+
+ for (j = start ; j + 2 < count; j += nr - 2 ) {
+ nr = MIN2( currentsz, count - j );
+ TAG(emit_verts)( ctx, j, nr, ALLOC_VERTS(nr) );
+ currentsz = dmasz;
+ }
+
+ FLUSH();
+
+ } else {
+ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__);
+ return;
+ }
+}
+
+static void TAG(render_tri_fan_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_TRI_FANS) {
+ LOCAL_VARS;
+ GLuint j, nr;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
+ int currentsz;
+
+ INIT(GL_TRIANGLE_FAN);
+
+ currentsz = GET_CURRENT_VB_MAX_VERTS();
+ if (currentsz < 8) {
+ currentsz = dmasz;
+ }
+
+ for (j = start + 1 ; j + 1 < count; j += nr - 2 ) {
+ void *tmp;
+ nr = MIN2( currentsz, count - j + 1 );
+ tmp = ALLOC_VERTS( nr );
+ tmp = TAG(emit_verts)( ctx, start, 1, tmp );
+ tmp = TAG(emit_verts)( ctx, j, nr - 1, tmp );
+ currentsz = dmasz;
+ }
+
+ FLUSH();
+ }
+ else {
+ /* Could write code to emit these as indexed vertices (for the
+ * g400, for instance).
+ */
+ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__);
+ return;
+ }
+}
+
+
+static void TAG(render_poly_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_POLYGONS) {
+ LOCAL_VARS;
+ GLuint j, nr;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
+ int currentsz;
+
+ INIT(GL_POLYGON);
+
+ currentsz = GET_CURRENT_VB_MAX_VERTS();
+ if (currentsz < 8) {
+ currentsz = dmasz;
+ }
+
+ for (j = start + 1 ; j + 1 < count ; j += nr - 2 ) {
+ void *tmp;
+ nr = MIN2( currentsz, count - j + 1 );
+ tmp = ALLOC_VERTS( nr );
+ tmp = TAG(emit_verts)( ctx, start, 1, tmp );
+ tmp = TAG(emit_verts)( ctx, j, nr - 1, tmp );
+ currentsz = dmasz;
+ }
+
+ FLUSH();
+ }
+ else if (HAVE_TRI_FANS && !(ctx->_TriangleCaps & DD_FLATSHADE)) {
+ TAG(render_tri_fan_verts)( ctx, start, count, flags );
+ } else {
+ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__);
+ return;
+ }
+}
+
+static void TAG(render_quad_strip_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j, nr;
+
+ if (HAVE_QUAD_STRIPS) {
+ LOCAL_VARS;
+ GLuint j, nr;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
+ int currentsz;
+
+ INIT(GL_QUAD_STRIP);
+
+ currentsz = GET_CURRENT_VB_MAX_VERTS();
+ if (currentsz < 8) {
+ currentsz = dmasz;
+ }
+
+ dmasz -= (dmasz & 2);
+ currentsz -= (currentsz & 2);
+
+ for (j = start ; j + 3 < count; j += nr - 2 ) {
+ nr = MIN2( currentsz, count - j );
+ TAG(emit_verts)( ctx, j, nr, ALLOC_VERTS(nr) );
+ currentsz = dmasz;
+ }
+
+ FLUSH();
+
+ } else if (HAVE_TRI_STRIPS &&
+ (ctx->_TriangleCaps & DD_FLATSHADE) &&
+ TNL_CONTEXT(ctx)->vb.ColorPtr[0]->stride) {
+ if (HAVE_ELTS) {
+ LOCAL_VARS;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+ GLuint j, nr;
+
+ EMIT_INDEXED_VERTS( ctx, start, count );
+
+ /* Simulate flat-shaded quadstrips using indexed vertices:
+ */
+ ELT_INIT( GL_TRIANGLES );
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS();
+
+ /* Emit whole number of quads in total, and in each buffer.
+ */
+ dmasz -= dmasz & 1;
+ count -= (count-start) & 1;
+ currentsz -= currentsz & 1;
+
+ if (currentsz < 12)
+ currentsz = dmasz;
+
+ currentsz = currentsz/6*2;
+ dmasz = dmasz/6*2;
+
+ for (j = start; j + 3 < count; j += nr - 2 ) {
+ nr = MIN2( currentsz, count - j );
+ if (nr >= 4) {
+ GLint quads = (nr/2)-1;
+ GLint i;
+ ELTS_VARS( ALLOC_ELTS( quads*6 ) );
+
+ for ( i = j-start ; i < j-start+quads*2 ; i+=2 ) {
+ EMIT_TWO_ELTS( 0, (i+0), (i+1) );
+ EMIT_TWO_ELTS( 2, (i+2), (i+1) );
+ EMIT_TWO_ELTS( 4, (i+3), (i+2) );
+ INCR_ELTS( 6 );
+ }
+
+ FLUSH();
+ }
+ currentsz = dmasz;
+ }
+
+ RELEASE_ELT_VERTS();
+ FLUSH();
+ }
+ else {
+ /* Vertices won't fit in a single buffer or elts not
+ * available - should never happen.
+ */
+ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__);
+ return;
+ }
+ }
+ else if (HAVE_TRI_STRIPS) {
+ LOCAL_VARS;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_VERTS();
+ int currentsz;
+
+ /* Emit smooth-shaded quadstrips as tristrips:
+ */
+ FLUSH();
+ INIT( GL_TRIANGLE_STRIP );
+
+ /* Emit whole number of quads in total, and in each buffer.
+ */
+ dmasz -= dmasz & 1;
+ currentsz = GET_CURRENT_VB_MAX_VERTS();
+ currentsz -= currentsz & 1;
+ count -= (count-start) & 1;
+
+ if (currentsz < 8) {
+ currentsz = dmasz;
+ }
+
+ for (j = start; j + 3 < count; j += nr - 2 ) {
+ nr = MIN2( currentsz, count - j );
+ TAG(emit_verts)( ctx, j, nr, ALLOC_VERTS(nr) );
+ currentsz = dmasz;
+ }
+
+ FLUSH();
+
+ } else {
+ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__);
+ return;
+ }
+}
+
+
+static void TAG(render_quads_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_QUADS) {
+ LOCAL_VARS;
+ int dmasz = (GET_SUBSEQUENT_VB_MAX_VERTS()/4) * 4;
+ int currentsz;
+ GLuint j, nr;
+
+ INIT(GL_QUADS);
+
+ /* Emit whole number of quads in total. dmasz is already a multiple
+ * of 4.
+ */
+ count -= (count-start)%4;
+
+ currentsz = (GET_CURRENT_VB_MAX_VERTS()/4) * 4;
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count; j += nr) {
+ nr = MIN2( currentsz, count - j );
+ TAG(emit_verts)( ctx, j, nr, ALLOC_VERTS(nr) );
+ currentsz = dmasz;
+ }
+ }
+ else if (HAVE_ELTS) {
+ /* Hardware doesn't have a quad primitive type -- try to
+ * simulate it using indexed vertices and the triangle
+ * primitive:
+ */
+ LOCAL_VARS;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+ GLuint j, nr;
+
+ EMIT_INDEXED_VERTS( ctx, start, count );
+
+ FLUSH();
+ ELT_INIT( GL_TRIANGLES );
+ currentsz = GET_CURRENT_VB_MAX_ELTS();
+
+ /* Emit whole number of quads in total, and in each buffer.
+ */
+ dmasz -= dmasz & 3;
+ count -= (count-start) & 3;
+ currentsz -= currentsz & 3;
+
+ /* Adjust for rendering as triangles:
+ */
+ currentsz = currentsz/6*4;
+ dmasz = dmasz/6*4;
+
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count; j += nr ) {
+ nr = MIN2( currentsz, count - j );
+ if (nr >= 4) {
+ GLint quads = nr/4;
+ GLint i;
+ ELTS_VARS( ALLOC_ELTS( quads*6 ) );
+
+ for ( i = j-start ; i < j-start+quads*4 ; i+=4 ) {
+ EMIT_TWO_ELTS( 0, (i+0), (i+1) );
+ EMIT_TWO_ELTS( 2, (i+3), (i+1) );
+ EMIT_TWO_ELTS( 4, (i+2), (i+3) );
+ INCR_ELTS( 6 );
+ }
+
+ FLUSH();
+ }
+ currentsz = dmasz;
+ }
+
+ RELEASE_ELT_VERTS();
+ }
+ else if (HAVE_TRIANGLES) {
+ /* Hardware doesn't have a quad primitive type -- try to
+ * simulate it using triangle primitive. This is a win for
+ * gears, but is it useful in the broader world?
+ */
+ LOCAL_VARS;
+ GLuint j;
+
+ INIT(GL_TRIANGLES);
+
+ for (j = start; j < count-3; j += 4) {
+ void *tmp = ALLOC_VERTS( 6 );
+ /* Send v0, v1, v3
+ */
+ tmp = EMIT_VERTS(ctx, j, 2, tmp);
+ tmp = EMIT_VERTS(ctx, j + 3, 1, tmp);
+ /* Send v1, v2, v3
+ */
+ tmp = EMIT_VERTS(ctx, j + 1, 3, tmp);
+ }
+ }
+ else {
+ /* Vertices won't fit in a single buffer, should never happen.
+ */
+ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__);
+ return;
+ }
+}
+
+static void TAG(render_noop)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+}
+
+
+
+
+static tnl_render_func TAG(render_tab_verts)[GL_POLYGON+2] =
+{
+ TAG(render_points_verts),
+ TAG(render_lines_verts),
+ TAG(render_line_loop_verts),
+ TAG(render_line_strip_verts),
+ TAG(render_triangles_verts),
+ TAG(render_tri_strip_verts),
+ TAG(render_tri_fan_verts),
+ TAG(render_quads_verts),
+ TAG(render_quad_strip_verts),
+ TAG(render_poly_verts),
+ TAG(render_noop),
+};
+
+
+/****************************************************************************
+ * Render elts using hardware indexed verts *
+ ****************************************************************************/
+
+#if (HAVE_ELTS)
+static void TAG(render_points_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_POINTS) {
+ LOCAL_VARS;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ GLuint j, nr;
+
+ ELT_INIT( GL_POINTS );
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS();
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count; j += nr ) {
+ nr = MIN2( currentsz, count - j );
+ TAG(emit_elts)( ctx, elts+j, nr, ALLOC_ELTS(nr) );
+ FLUSH();
+ currentsz = dmasz;
+ }
+ } else {
+ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__);
+ return;
+ }
+}
+
+
+
+static void TAG(render_lines_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_LINES) {
+ LOCAL_VARS;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ GLuint j, nr;
+
+ ELT_INIT( GL_LINES );
+
+ /* Emit whole number of lines in total and in each buffer:
+ */
+ count -= (count-start) & 1;
+ currentsz -= currentsz & 1;
+ dmasz -= dmasz & 1;
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS();
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count; j += nr ) {
+ nr = MIN2( currentsz, count - j );
+ TAG(emit_elts)( ctx, elts+j, nr, ALLOC_ELTS(nr) );
+ FLUSH();
+ currentsz = dmasz;
+ }
+ } else {
+ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__);
+ return;
+ }
+}
+
+
+static void TAG(render_line_strip_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_LINE_STRIPS) {
+ LOCAL_VARS;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ GLuint j, nr;
+
+ FLUSH(); /* always a new primitive */
+ ELT_INIT( GL_LINE_STRIP );
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS();
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j + 1 < count; j += nr - 1 ) {
+ nr = MIN2( currentsz, count - j );
+ TAG(emit_elts)( ctx, elts+j, nr, ALLOC_ELTS(nr) );
+ FLUSH();
+ currentsz = dmasz;
+ }
+ } else {
+ /* TODO: Try to emit as indexed lines.
+ */
+ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__);
+ return;
+ }
+}
+
+
+static void TAG(render_line_loop_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_LINE_STRIPS) {
+ LOCAL_VARS;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ GLuint j, nr;
+
+ FLUSH();
+ ELT_INIT( GL_LINE_STRIP );
+
+ if (flags & PRIM_BEGIN)
+ j = start;
+ else
+ j = start + 1;
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS();
+ if (currentsz < 8) {
+ currentsz = dmasz;
+ }
+
+ /* Ensure last vertex doesn't wrap:
+ */
+ currentsz--;
+ dmasz--;
+
+ if (j + 1 < count) {
+ for ( ; j + 1 < count; j += nr - 1 ) {
+ nr = MIN2( currentsz, count - j );
+
+ if (j + nr >= count &&
+ start < count - 1 &&
+ (flags & PRIM_END))
+ {
+ void *tmp;
+ tmp = ALLOC_ELTS(nr+1);
+ tmp = TAG(emit_elts)( ctx, elts+j, nr, tmp );
+ tmp = TAG(emit_elts)( ctx, elts+start, 1, tmp );
+ }
+ else {
+ TAG(emit_elts)( ctx, elts+j, nr, ALLOC_ELTS(nr) );
+ currentsz = dmasz;
+ }
+ }
+
+ }
+ else if (start + 1 < count && (flags & PRIM_END)) {
+ void *tmp;
+ tmp = ALLOC_ELTS(2);
+ tmp = TAG(emit_elts)( ctx, elts+start+1, 1, tmp );
+ tmp = TAG(emit_elts)( ctx, elts+start, 1, tmp );
+ }
+
+ FLUSH();
+ } else {
+ /* TODO: Try to emit as indexed lines */
+ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__);
+ return;
+ }
+}
+
+
+/* For verts, we still eliminate the copy from main memory to dma
+ * buffers. For elts, this is probably no better (worse?) than the
+ * standard path.
+ */
+static void TAG(render_triangles_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS()/3*3;
+ int currentsz;
+ GLuint j, nr;
+
+ FLUSH();
+ ELT_INIT( GL_TRIANGLES );
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS();
+
+ /* Emit whole number of tris in total. dmasz is already a multiple
+ * of 3.
+ */
+ count -= (count-start)%3;
+ currentsz -= currentsz%3;
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count; j += nr) {
+ nr = MIN2( currentsz, count - j );
+ TAG(emit_elts)( ctx, elts+j, nr, ALLOC_ELTS(nr) );
+ FLUSH();
+ currentsz = dmasz;
+ }
+}
+
+
+
+static void TAG(render_tri_strip_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_TRI_STRIPS) {
+ LOCAL_VARS;
+ GLuint j, nr;
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+
+ FLUSH();
+ ELT_INIT( GL_TRIANGLE_STRIP );
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS();
+ if (currentsz < 8) {
+ currentsz = dmasz;
+ }
+
+ /* Keep the same winding over multiple buffers:
+ */
+ dmasz -= (dmasz & 1);
+ currentsz -= (currentsz & 1);
+
+ for (j = start ; j + 2 < count; j += nr - 2 ) {
+ nr = MIN2( currentsz, count - j );
+ TAG(emit_elts)( ctx, elts+j, nr, ALLOC_ELTS(nr) );
+ FLUSH();
+ currentsz = dmasz;
+ }
+ } else {
+ /* TODO: try to emit as indexed triangles */
+ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__);
+ return;
+ }
+}
+
+static void TAG(render_tri_fan_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_TRI_FANS) {
+ LOCAL_VARS;
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ GLuint j, nr;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+
+ FLUSH();
+ ELT_INIT( GL_TRIANGLE_FAN );
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS();
+ if (currentsz < 8) {
+ currentsz = dmasz;
+ }
+
+ for (j = start + 1 ; j + 1 < count; j += nr - 2 ) {
+ void *tmp;
+ nr = MIN2( currentsz, count - j + 1 );
+ tmp = ALLOC_ELTS( nr );
+ tmp = TAG(emit_elts)( ctx, elts+start, 1, tmp );
+ tmp = TAG(emit_elts)( ctx, elts+j, nr - 1, tmp );
+ FLUSH();
+ currentsz = dmasz;
+ }
+ } else {
+ /* TODO: try to emit as indexed triangles */
+ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__);
+ return;
+ }
+}
+
+
+static void TAG(render_poly_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_POLYGONS) {
+ LOCAL_VARS;
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ GLuint j, nr;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+
+ FLUSH();
+ ELT_INIT( GL_POLYGON );
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS();
+ if (currentsz < 8) {
+ currentsz = dmasz;
+ }
+
+ for (j = start + 1 ; j + 1 < count; j += nr - 2 ) {
+ void *tmp;
+ nr = MIN2( currentsz, count - j + 1 );
+ tmp = ALLOC_ELTS( nr );
+ tmp = TAG(emit_elts)( ctx, elts+start, 1, tmp );
+ tmp = TAG(emit_elts)( ctx, elts+j, nr - 1, tmp );
+ FLUSH();
+ currentsz = dmasz;
+ }
+ } else if (HAVE_TRI_FANS && !(ctx->_TriangleCaps & DD_FLATSHADE)) {
+ TAG(render_tri_fan_verts)( ctx, start, count, flags );
+ } else {
+ fprintf(stderr, "%s - cannot draw primitive\n", __FUNCTION__);
+ return;
+ }
+}
+
+static void TAG(render_quad_strip_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_QUAD_STRIPS && 0) {
+ }
+ else if (HAVE_TRI_STRIPS) {
+ LOCAL_VARS;
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+ GLuint j, nr;
+
+ FLUSH();
+ currentsz = GET_CURRENT_VB_MAX_ELTS();
+
+ /* Emit whole number of quads in total, and in each buffer.
+ */
+ dmasz -= dmasz & 1;
+ count -= (count-start) & 1;
+ currentsz -= currentsz & 1;
+
+ if (currentsz < 12)
+ currentsz = dmasz;
+
+ if (ctx->_TriangleCaps & DD_FLATSHADE) {
+ ELT_INIT( GL_TRIANGLES );
+
+ currentsz = currentsz/6*2;
+ dmasz = dmasz/6*2;
+
+ for (j = start; j + 3 < count; j += nr - 2 ) {
+ nr = MIN2( currentsz, count - j );
+
+ if (nr >= 4)
+ {
+ GLint i;
+ GLint quads = (nr/2)-1;
+ ELTS_VARS( ALLOC_ELTS( quads*6 ) );
+
+ for ( i = j-start ; i < j-start+quads ; i++, elts += 2 ) {
+ EMIT_TWO_ELTS( 0, elts[0], elts[1] );
+ EMIT_TWO_ELTS( 2, elts[2], elts[1] );
+ EMIT_TWO_ELTS( 4, elts[3], elts[2] );
+ INCR_ELTS( 6 );
+ }
+
+ FLUSH();
+ }
+
+ currentsz = dmasz;
+ }
+ }
+ else {
+ ELT_INIT( GL_TRIANGLE_STRIP );
+
+ for (j = start; j + 3 < count; j += nr - 2 ) {
+ nr = MIN2( currentsz, count - j );
+ TAG(emit_elts)( ctx, elts+j, nr, ALLOC_ELTS(nr) );
+ FLUSH();
+ currentsz = dmasz;
+ }
+ }
+ }
+}
+
+
+static void TAG(render_quads_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (HAVE_QUADS) {
+ LOCAL_VARS;
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS()/4*4;
+ int currentsz;
+ GLuint j, nr;
+
+ FLUSH();
+ ELT_INIT( GL_TRIANGLES );
+
+ currentsz = GET_CURRENT_VB_MAX_ELTS()/4*4;
+
+ count -= (count-start)%4;
+
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j < count; j += nr) {
+ nr = MIN2( currentsz, count - j );
+ TAG(emit_elts)( ctx, elts+j, nr, ALLOC_ELTS(nr) );
+ FLUSH();
+ currentsz = dmasz;
+ }
+ } else {
+ LOCAL_VARS;
+ GLuint *elts = TNL_CONTEXT(ctx)->vb.Elts;
+ int dmasz = GET_SUBSEQUENT_VB_MAX_ELTS();
+ int currentsz;
+ GLuint j, nr;
+
+ ELT_INIT( GL_TRIANGLES );
+ currentsz = GET_CURRENT_VB_MAX_ELTS();
+
+ /* Emit whole number of quads in total, and in each buffer.
+ */
+ dmasz -= dmasz & 3;
+ count -= (count-start) & 3;
+ currentsz -= currentsz & 3;
+
+ /* Adjust for rendering as triangles:
+ */
+ currentsz = currentsz/6*4;
+ dmasz = dmasz/6*4;
+
+ if (currentsz < 8)
+ currentsz = dmasz;
+
+ for (j = start; j + 3 < count; j += nr - 2 ) {
+ nr = MIN2( currentsz, count - j );
+
+ if (nr >= 4)
+ {
+ GLint quads = nr/4;
+ GLint i;
+ ELTS_VARS( ALLOC_ELTS( quads * 6 ) );
+
+ for ( i = j-start ; i < j-start+quads ; i++, elts += 4 ) {
+ EMIT_TWO_ELTS( 0, elts[0], elts[1] );
+ EMIT_TWO_ELTS( 2, elts[3], elts[1] );
+ EMIT_TWO_ELTS( 4, elts[2], elts[3] );
+ INCR_ELTS( 6 );
+ }
+
+ FLUSH();
+ }
+
+ currentsz = dmasz;
+ }
+ }
+}
+
+
+
+static tnl_render_func TAG(render_tab_elts)[GL_POLYGON+2] =
+{
+ TAG(render_points_elts),
+ TAG(render_lines_elts),
+ TAG(render_line_loop_elts),
+ TAG(render_line_strip_elts),
+ TAG(render_triangles_elts),
+ TAG(render_tri_strip_elts),
+ TAG(render_tri_fan_elts),
+ TAG(render_quads_elts),
+ TAG(render_quad_strip_elts),
+ TAG(render_poly_elts),
+ TAG(render_noop),
+};
+
+
+
+#endif
+
+
+
+/* Pre-check the primitives in the VB to prevent the need for
+ * fallbacks later on.
+ */
+static GLboolean TAG(validate_render)( GLcontext *ctx,
+ struct vertex_buffer *VB )
+{
+ GLint i;
+
+ if (VB->ClipOrMask & ~CLIP_CULL_BIT)
+ return GL_FALSE;
+
+ if (VB->Elts && !HAVE_ELTS)
+ return GL_FALSE;
+
+ for (i = 0 ; i < VB->PrimitiveCount ; i++) {
+ GLuint prim = VB->Primitive[i].mode;
+ GLuint count = VB->Primitive[i].count;
+ GLboolean ok = GL_FALSE;
+
+ if (!count)
+ continue;
+
+ switch (prim & PRIM_MODE_MASK) {
+ case GL_POINTS:
+ ok = HAVE_POINTS;
+ break;
+ case GL_LINES:
+ ok = HAVE_LINES && !ctx->Line.StippleFlag;
+ break;
+ case GL_LINE_STRIP:
+ ok = HAVE_LINE_STRIPS && !ctx->Line.StippleFlag;
+ break;
+ case GL_LINE_LOOP:
+ ok = HAVE_LINE_STRIPS && !ctx->Line.StippleFlag;
+ break;
+ case GL_TRIANGLES:
+ ok = HAVE_TRIANGLES;
+ break;
+ case GL_TRIANGLE_STRIP:
+ ok = HAVE_TRI_STRIPS;
+ break;
+ case GL_TRIANGLE_FAN:
+ ok = HAVE_TRI_FANS;
+ break;
+ case GL_POLYGON:
+ if (HAVE_POLYGONS) {
+ ok = GL_TRUE;
+ }
+ else
+ ok = (HAVE_TRI_FANS && !(ctx->_TriangleCaps & DD_FLATSHADE));
+ break;
+ case GL_QUAD_STRIP:
+ if (VB->Elts) {
+ ok = HAVE_TRI_STRIPS;
+ }
+ else if (HAVE_QUAD_STRIPS) {
+ ok = GL_TRUE;
+ } else if (HAVE_TRI_STRIPS &&
+ (ctx->_TriangleCaps & DD_FLATSHADE) &&
+ VB->ColorPtr[0]->stride != 0) {
+ if (HAVE_ELTS) {
+ ok = (GLint) count < GET_SUBSEQUENT_VB_MAX_ELTS();
+ }
+ else {
+ ok = GL_FALSE;
+ }
+ }
+ else
+ ok = HAVE_TRI_STRIPS;
+ break;
+ case GL_QUADS:
+ if (HAVE_QUADS) {
+ ok = GL_TRUE;
+ } else if (HAVE_ELTS) {
+ ok = (GLint) count < GET_SUBSEQUENT_VB_MAX_ELTS();
+ }
+ else {
+ ok = HAVE_TRIANGLES; /* flatshading is ok. */
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (!ok) {
+/* fprintf(stderr, "not ok %s\n", _mesa_lookup_enum_by_nr(prim & PRIM_MODE_MASK)); */
+ return GL_FALSE;
+ }
+ }
+
+ return GL_TRUE;
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_dmatmp2.h b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_dmatmp2.h
new file mode 100644
index 000000000..b762221b1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_dmatmp2.h
@@ -0,0 +1,914 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.0.3
+ *
+ * Copyright (C) 1999-2002 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+/* Template for render stages which build and emit vertices directly
+ * to fixed-size dma buffers. Useful for rendering strips and other
+ * native primitives where clipping and per-vertex tweaks such as
+ * those in t_dd_tritmp.h are not required.
+ *
+ */
+
+#if !HAVE_TRIANGLES || !HAVE_POINTS || !HAVE_LINES
+#error "must have points, lines & triangles to use render template"
+#endif
+
+#if !HAVE_TRI_STRIPS || !HAVE_TRI_FANS
+#error "must have tri strip and fans to use render template"
+#endif
+
+#if !HAVE_LINE_STRIPS
+#error "must have line strips to use render template"
+#endif
+
+#if !HAVE_POLYGONS
+#error "must have polygons to use render template"
+#endif
+
+#if !HAVE_ELTS
+#error "must have elts to use render template"
+#endif
+
+
+#ifndef EMIT_TWO_ELTS
+#define EMIT_TWO_ELTS( dest, offset, elt0, elt1 ) \
+do { \
+ (dest)[offset] = (elt0); \
+ (dest)[offset+1] = (elt1); \
+} while (0)
+#endif
+
+
+/**********************************************************************/
+/* Render whole begin/end objects */
+/**********************************************************************/
+
+
+static ELT_TYPE *TAG(emit_elts)( GLcontext *ctx,
+ ELT_TYPE *dest,
+ GLuint *elts, GLuint nr )
+{
+ GLint i;
+ LOCAL_VARS;
+
+ for ( i = 0 ; i+1 < nr ; i+=2, elts += 2 ) {
+ EMIT_TWO_ELTS( dest, 0, elts[0], elts[1] );
+ dest += 2;
+ }
+ if (i < nr) {
+ EMIT_ELT( dest, 0, elts[0] );
+ dest += 1;
+ }
+
+ return dest;
+}
+
+static ELT_TYPE *TAG(emit_consecutive_elts)( GLcontext *ctx,
+ ELT_TYPE *dest,
+ GLuint start, GLuint nr )
+{
+ GLint i;
+ LOCAL_VARS;
+
+ for ( i = 0 ; i+1 < nr ; i+=2, start += 2 ) {
+ EMIT_TWO_ELTS( dest, 0, start, start+1 );
+ dest += 2;
+ }
+ if (i < nr) {
+ EMIT_ELT( dest, 0, start );
+ dest += 1;
+ }
+
+ return dest;
+}
+
+/***********************************************************************
+ * Render non-indexed primitives.
+ ***********************************************************************/
+
+
+
+static void TAG(render_points_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (start < count) {
+ LOCAL_VARS;
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+ EMIT_PRIM( ctx, GL_POINTS, HW_POINTS, start, count );
+ }
+}
+
+static void TAG(render_lines_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+ count -= (count-start) & 1;
+
+ if (start+1 >= count)
+ return;
+
+ if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag) {
+ RESET_STIPPLE();
+ AUTO_STIPPLE( GL_TRUE );
+ }
+
+ EMIT_PRIM( ctx, GL_LINES, HW_LINES, start, count );
+
+ if ((flags & PRIM_END) && ctx->Line.StippleFlag)
+ AUTO_STIPPLE( GL_FALSE );
+}
+
+
+static void TAG(render_line_strip_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (start+1 >= count)
+ return;
+
+ if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag)
+ RESET_STIPPLE();
+
+
+ if (PREFER_DISCRETE_ELT_PRIM( count-start, HW_LINES ))
+ {
+ int dmasz = GET_MAX_HW_ELTS();
+ GLuint j, nr;
+
+ ELT_INIT( GL_LINES, HW_LINES );
+
+ /* Emit whole number of lines in each full buffer.
+ */
+ dmasz = dmasz/2;
+
+
+ for (j = start; j + 1 < count; j += nr - 1 ) {
+ ELT_TYPE *dest;
+ GLint i;
+
+ nr = MIN2( dmasz, count - j );
+ dest = ALLOC_ELTS( (nr-1)*2 );
+
+ for ( i = j ; i+1 < j+nr ; i+=1 ) {
+ EMIT_TWO_ELTS( dest, 0, (i+0), (i+1) );
+ dest += 2;
+ }
+
+ CLOSE_ELTS();
+ }
+ }
+ else
+ EMIT_PRIM( ctx, GL_LINE_STRIP, HW_LINE_STRIP, start, count );
+}
+
+
+static void TAG(render_line_loop_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ GLuint j, nr;
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (flags & PRIM_BEGIN) {
+ j = start;
+ if (ctx->Line.StippleFlag)
+ RESET_STIPPLE( );
+ }
+ else
+ j = start + 1;
+
+ if (flags & PRIM_END) {
+
+ if (start+1 >= count)
+ return;
+
+ if (PREFER_DISCRETE_ELT_PRIM( count-start, HW_LINES )) {
+ int dmasz = GET_MAX_HW_ELTS();
+
+ ELT_INIT( GL_LINES, HW_LINES );
+
+ /* Emit whole number of lines in each full buffer.
+ */
+ dmasz = dmasz/2;
+
+ /* Ensure last vertex doesn't wrap:
+ */
+ dmasz--;
+
+ for (; j + 1 < count; ) {
+ GLint i;
+ ELT_TYPE *dest;
+
+ nr = MIN2( dmasz, count - j );
+ dest = ALLOC_ELTS( nr*2 ); /* allocs room for 1 more line */
+
+ for ( i = 0 ; i < nr - 1 ; i+=1 ) {
+ EMIT_TWO_ELTS( dest, 0, (j+i), (j+i+1) );
+ dest += 2;
+ }
+
+ j += nr - 1;
+
+ /* Emit 1 more line into space alloced above */
+ if (j + 1 >= count) {
+ EMIT_TWO_ELTS( dest, 0, (j), (start) );
+ dest += 2;
+ }
+
+ CLOSE_ELTS();
+ }
+ }
+ else
+ {
+ int dmasz = GET_MAX_HW_ELTS() - 1;
+
+ ELT_INIT( GL_LINE_STRIP, HW_LINE_STRIP );
+
+ for ( ; j + 1 < count; ) {
+ nr = MIN2( dmasz, count - j );
+ if (j + nr < count) {
+ ELT_TYPE *dest = ALLOC_ELTS( nr );
+ dest = TAG(emit_consecutive_elts)( ctx, dest, j, nr );
+ j += nr - 1;
+ CLOSE_ELTS();
+ }
+ else if (nr) {
+ ELT_TYPE *dest = ALLOC_ELTS( nr + 1 );
+ dest = TAG(emit_consecutive_elts)( ctx, dest, j, nr );
+ dest = TAG(emit_consecutive_elts)( ctx, dest, start, 1 );
+ j += nr;
+ CLOSE_ELTS();
+ }
+ }
+ }
+ } else {
+ TAG(render_line_strip_verts)( ctx, j, count, flags );
+ }
+}
+
+
+static void TAG(render_triangles_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+
+ count -= (count-start)%3;
+
+ if (start+2 >= count) {
+ return;
+ }
+
+ /* need a PREFER_DISCRETE_ELT_PRIM here too..
+ */
+ EMIT_PRIM( ctx, GL_TRIANGLES, HW_TRIANGLES, start, count );
+}
+
+
+
+static void TAG(render_tri_strip_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (start + 2 >= count)
+ return;
+
+ if (PREFER_DISCRETE_ELT_PRIM( count-start, HW_TRIANGLES ))
+ {
+ int dmasz = GET_MAX_HW_ELTS();
+ int parity = 0;
+ GLuint j, nr;
+
+ ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );
+
+ /* Emit even number of tris in each full buffer.
+ */
+ dmasz = dmasz/3;
+ dmasz -= dmasz & 1;
+
+ for (j = start; j + 2 < count; j += nr - 2 ) {
+ ELT_TYPE *dest;
+ GLint i;
+
+ nr = MIN2( dmasz, count - j );
+ dest = ALLOC_ELTS( (nr-2)*3 );
+
+ for ( i = j ; i+2 < j+nr ; i++, parity^=1 ) {
+ EMIT_ELT( dest, 0, (i+0+parity) );
+ EMIT_ELT( dest, 1, (i+1-parity) );
+ EMIT_ELT( dest, 2, (i+2) );
+ dest += 3;
+ }
+
+ CLOSE_ELTS();
+ }
+ }
+ else
+ EMIT_PRIM( ctx, GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0, start, count );
+}
+
+static void TAG(render_tri_fan_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (start+2 >= count)
+ return;
+
+ if (PREFER_DISCRETE_ELT_PRIM( count-start, HW_TRIANGLES ))
+ {
+ int dmasz = GET_MAX_HW_ELTS();
+ GLuint j, nr;
+
+ ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );
+
+ dmasz = dmasz/3;
+
+ for (j = start + 1; j + 1 < count; j += nr - 1 ) {
+ ELT_TYPE *dest;
+ GLint i;
+
+ nr = MIN2( dmasz, count - j );
+ dest = ALLOC_ELTS( (nr-1)*3 );
+
+ for ( i = j ; i+1 < j+nr ; i++ ) {
+ EMIT_ELT( dest, 0, (start) );
+ EMIT_ELT( dest, 1, (i) );
+ EMIT_ELT( dest, 2, (i+1) );
+ dest += 3;
+ }
+
+ CLOSE_ELTS();
+ }
+ }
+ else {
+ EMIT_PRIM( ctx, GL_TRIANGLE_FAN, HW_TRIANGLE_FAN, start, count );
+ }
+}
+
+
+static void TAG(render_poly_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (start+2 >= count)
+ return;
+
+ EMIT_PRIM( ctx, GL_POLYGON, HW_POLYGON, start, count );
+}
+
+static void TAG(render_quad_strip_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+
+ count -= (count-start) & 1;
+
+ if (start+3 >= count)
+ return;
+
+ if (HAVE_QUAD_STRIPS) {
+ EMIT_PRIM( ctx, GL_QUAD_STRIP, HW_QUAD_STRIP, start, count );
+ }
+ else if (ctx->_TriangleCaps & DD_FLATSHADE) {
+ LOCAL_VARS;
+ int dmasz = GET_MAX_HW_ELTS();
+ GLuint j, nr;
+
+ ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );
+
+ /* Emit whole number of quads in total, and in each buffer.
+ */
+ dmasz = (dmasz/6)*2;
+
+ for (j = start; j + 3 < count; j += nr - 2 ) {
+ ELT_TYPE *dest;
+ GLint quads, i;
+
+ nr = MIN2( dmasz, count - j );
+ quads = (nr/2)-1;
+ dest = ALLOC_ELTS( quads*6 );
+
+ for ( i = j ; i < j+quads*2 ; i+=2 ) {
+ EMIT_TWO_ELTS( dest, 0, (i+0), (i+1) );
+ EMIT_TWO_ELTS( dest, 2, (i+2), (i+1) );
+ EMIT_TWO_ELTS( dest, 4, (i+3), (i+2) );
+ dest += 6;
+ }
+
+ CLOSE_ELTS();
+ }
+ }
+ else {
+ EMIT_PRIM( ctx, GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0, start, count );
+ }
+}
+
+
+static void TAG(render_quads_verts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+ count -= (count-start)%4;
+
+ if (start+3 >= count)
+ return;
+
+ if (HAVE_QUADS) {
+ EMIT_PRIM( ctx, GL_QUADS, HW_QUADS, start, count );
+ }
+ else {
+ /* Hardware doesn't have a quad primitive type -- simulate it
+ * using indexed vertices and the triangle primitive:
+ */
+ LOCAL_VARS;
+ int dmasz = GET_MAX_HW_ELTS();
+ GLuint j, nr;
+
+ ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );
+
+ /* Adjust for rendering as triangles:
+ */
+ dmasz = (dmasz/6)*4;
+
+ for (j = start; j < count; j += nr ) {
+ ELT_TYPE *dest;
+ GLint quads, i;
+
+ nr = MIN2( dmasz, count - j );
+ quads = nr/4;
+ dest = ALLOC_ELTS( quads*6 );
+
+ for ( i = j ; i < j+quads*4 ; i+=4 ) {
+ EMIT_TWO_ELTS( dest, 0, (i+0), (i+1) );
+ EMIT_TWO_ELTS( dest, 2, (i+3), (i+1) );
+ EMIT_TWO_ELTS( dest, 4, (i+2), (i+3) );
+ dest += 6;
+ }
+
+ CLOSE_ELTS();
+ }
+ }
+}
+
+static void TAG(render_noop)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+}
+
+
+
+
+static tnl_render_func TAG(render_tab_verts)[GL_POLYGON+2] =
+{
+ TAG(render_points_verts),
+ TAG(render_lines_verts),
+ TAG(render_line_loop_verts),
+ TAG(render_line_strip_verts),
+ TAG(render_triangles_verts),
+ TAG(render_tri_strip_verts),
+ TAG(render_tri_fan_verts),
+ TAG(render_quads_verts),
+ TAG(render_quad_strip_verts),
+ TAG(render_poly_verts),
+ TAG(render_noop),
+};
+
+
+/****************************************************************************
+ * Render elts using hardware indexed verts *
+ ****************************************************************************/
+
+static void TAG(render_points_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ int dmasz = GET_MAX_HW_ELTS();
+ GLuint *elts = GET_MESA_ELTS();
+ GLuint j, nr;
+ ELT_TYPE *dest;
+
+ ELT_INIT( GL_POINTS, HW_POINTS );
+
+ for (j = start; j < count; j += nr ) {
+ nr = MIN2( dmasz, count - j );
+ dest = ALLOC_ELTS( nr );
+ dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+ CLOSE_ELTS();
+ }
+}
+
+
+
+static void TAG(render_lines_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ int dmasz = GET_MAX_HW_ELTS();
+ GLuint *elts = GET_MESA_ELTS();
+ GLuint j, nr;
+ ELT_TYPE *dest;
+
+ if (start+1 >= count)
+ return;
+
+ if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag) {
+ RESET_STIPPLE();
+ AUTO_STIPPLE( GL_TRUE );
+ }
+
+ ELT_INIT( GL_LINES, HW_LINES );
+
+ /* Emit whole number of lines in total and in each buffer:
+ */
+ count -= (count-start) & 1;
+ dmasz -= dmasz & 1;
+
+ for (j = start; j < count; j += nr ) {
+ nr = MIN2( dmasz, count - j );
+ dest = ALLOC_ELTS( nr );
+ dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+ CLOSE_ELTS();
+ }
+
+ if ((flags & PRIM_END) && ctx->Line.StippleFlag)
+ AUTO_STIPPLE( GL_FALSE );
+}
+
+
+static void TAG(render_line_strip_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ int dmasz = GET_MAX_HW_ELTS();
+ GLuint *elts = GET_MESA_ELTS();
+ GLuint j, nr;
+ ELT_TYPE *dest;
+
+ if (start+1 >= count)
+ return;
+
+ ELT_INIT( GL_LINE_STRIP, HW_LINE_STRIP );
+
+ if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag)
+ RESET_STIPPLE();
+
+ for (j = start; j + 1 < count; j += nr - 1 ) {
+ nr = MIN2( dmasz, count - j );
+ dest = ALLOC_ELTS( nr );
+ dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+ CLOSE_ELTS();
+ }
+}
+
+
+static void TAG(render_line_loop_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ int dmasz = GET_MAX_HW_ELTS();
+ GLuint *elts = GET_MESA_ELTS();
+ GLuint j, nr;
+ ELT_TYPE *dest;
+
+ if (0) fprintf(stderr, "%s\n", __FUNCTION__);
+
+ if (flags & PRIM_BEGIN)
+ j = start;
+ else
+ j = start + 1;
+
+
+ if (flags & PRIM_END) {
+ if (start+1 >= count)
+ return;
+ }
+ else {
+ if (j+1 >= count)
+ return;
+ }
+
+ ELT_INIT( GL_LINE_STRIP, HW_LINE_STRIP );
+
+ if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag)
+ RESET_STIPPLE();
+
+
+ /* Ensure last vertex doesn't wrap:
+ */
+ dmasz--;
+
+ for ( ; j + 1 < count; ) {
+ nr = MIN2( dmasz, count - j );
+ dest = ALLOC_ELTS( nr+1 ); /* Reserve possible space for last elt */
+ dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+ j += nr - 1;
+ if (j + 1 >= count && (flags & PRIM_END)) {
+ dest = TAG(emit_elts)( ctx, dest, elts+start, 1 );
+ }
+ CLOSE_ELTS();
+ }
+}
+
+
+static void TAG(render_triangles_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ GLuint *elts = GET_MESA_ELTS();
+ int dmasz = GET_MAX_HW_ELTS()/3*3;
+ GLuint j, nr;
+ ELT_TYPE *dest;
+
+ if (start+2 >= count)
+ return;
+
+ ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );
+
+
+ /* Emit whole number of tris in total. dmasz is already a multiple
+ * of 3.
+ */
+ count -= (count-start)%3;
+
+ for (j = start; j < count; j += nr) {
+ nr = MIN2( dmasz, count - j );
+ dest = ALLOC_ELTS( nr );
+ dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+ CLOSE_ELTS();
+ }
+}
+
+
+
+static void TAG(render_tri_strip_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ GLuint j, nr;
+ GLuint *elts = GET_MESA_ELTS();
+ int dmasz = GET_MAX_HW_ELTS();
+ ELT_TYPE *dest;
+
+ if (start+2 >= count)
+ return;
+
+ ELT_INIT( GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0 );
+
+ /* Keep the same winding over multiple buffers:
+ */
+ dmasz -= (dmasz & 1);
+
+ for (j = start ; j + 2 < count; j += nr - 2 ) {
+ nr = MIN2( dmasz, count - j );
+
+ dest = ALLOC_ELTS( nr );
+ dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+ CLOSE_ELTS();
+ }
+}
+
+static void TAG(render_tri_fan_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ GLuint *elts = GET_MESA_ELTS();
+ GLuint j, nr;
+ int dmasz = GET_MAX_HW_ELTS();
+ ELT_TYPE *dest;
+
+ if (start+2 >= count)
+ return;
+
+ ELT_INIT( GL_TRIANGLE_FAN, HW_TRIANGLE_FAN );
+
+ for (j = start + 1 ; j + 1 < count; j += nr - 1 ) {
+ nr = MIN2( dmasz, count - j + 1 );
+ dest = ALLOC_ELTS( nr );
+ dest = TAG(emit_elts)( ctx, dest, elts+start, 1 );
+ dest = TAG(emit_elts)( ctx, dest, elts+j, nr - 1 );
+ CLOSE_ELTS();
+ }
+}
+
+
+static void TAG(render_poly_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ GLuint *elts = GET_MESA_ELTS();
+ GLuint j, nr;
+ int dmasz = GET_MAX_HW_ELTS();
+ ELT_TYPE *dest;
+
+ if (start+2 >= count)
+ return;
+
+ ELT_INIT( GL_POLYGON, HW_POLYGON );
+
+ for (j = start + 1 ; j + 1 < count ; j += nr - 1 ) {
+ nr = MIN2( dmasz, count - j + 1 );
+ dest = ALLOC_ELTS( nr );
+ dest = TAG(emit_elts)( ctx, dest, elts+start, 1 );
+ dest = TAG(emit_elts)( ctx, dest, elts+j, nr - 1 );
+ CLOSE_ELTS();
+ }
+}
+
+static void TAG(render_quad_strip_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (start+3 >= count)
+ return;
+
+ if (HAVE_QUAD_STRIPS && 0) {
+ }
+ else {
+ LOCAL_VARS;
+ GLuint *elts = GET_MESA_ELTS();
+ int dmasz = GET_MAX_HW_ELTS();
+ GLuint j, nr;
+ ELT_TYPE *dest;
+
+ /* Emit whole number of quads in total, and in each buffer.
+ */
+ dmasz -= dmasz & 1;
+ count -= (count-start) & 1;
+
+ if (ctx->_TriangleCaps & DD_FLATSHADE) {
+ ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );
+
+ dmasz = dmasz/6*2;
+
+ for (j = start; j + 3 < count; j += nr - 2 ) {
+ nr = MIN2( dmasz, count - j );
+
+ if (nr >= 4)
+ {
+ GLint quads = (nr/2)-1;
+ ELT_TYPE *dest = ALLOC_ELTS( quads*6 );
+ GLint i;
+
+ for ( i = j-start ; i < j-start+quads ; i++, elts += 2 ) {
+ EMIT_TWO_ELTS( dest, 0, elts[0], elts[1] );
+ EMIT_TWO_ELTS( dest, 2, elts[2], elts[1] );
+ EMIT_TWO_ELTS( dest, 4, elts[3], elts[2] );
+ dest += 6;
+ }
+
+ CLOSE_ELTS();
+ }
+ }
+ }
+ else {
+ ELT_INIT( GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0 );
+
+ for (j = start; j + 3 < count; j += nr - 2 ) {
+ nr = MIN2( dmasz, count - j );
+ dest = ALLOC_ELTS( nr );
+ dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
+ CLOSE_ELTS();
+ }
+ }
+ }
+}
+
+
+static void TAG(render_quads_elts)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ if (start+3 >= count)
+ return;
+
+ if (HAVE_QUADS && 0) {
+ } else {
+ LOCAL_VARS;
+ GLuint *elts = GET_MESA_ELTS();
+ int dmasz = GET_MAX_HW_ELTS();
+ GLuint j, nr;
+
+ ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );
+
+ /* Emit whole number of quads in total, and in each buffer.
+ */
+ dmasz -= dmasz & 3;
+ count -= (count-start) & 3;
+
+ /* Adjust for rendering as triangles:
+ */
+ dmasz = dmasz/6*4;
+
+ for (j = start; j + 3 < count; j += nr ) {
+ nr = MIN2( dmasz, count - j );
+
+ {
+ GLint quads = nr/4;
+ ELT_TYPE *dest = ALLOC_ELTS( quads * 6 );
+ GLint i;
+
+ for ( i = j-start ; i < j-start+quads ; i++, elts += 4 ) {
+ EMIT_TWO_ELTS( dest, 0, elts[0], elts[1] );
+ EMIT_TWO_ELTS( dest, 2, elts[3], elts[1] );
+ EMIT_TWO_ELTS( dest, 4, elts[2], elts[3] );
+ dest += 6;
+ }
+
+ CLOSE_ELTS();
+ }
+ }
+ }
+}
+
+
+
+static tnl_render_func TAG(render_tab_elts)[GL_POLYGON+2] =
+{
+ TAG(render_points_elts),
+ TAG(render_lines_elts),
+ TAG(render_line_loop_elts),
+ TAG(render_line_strip_elts),
+ TAG(render_triangles_elts),
+ TAG(render_tri_strip_elts),
+ TAG(render_tri_fan_elts),
+ TAG(render_quads_elts),
+ TAG(render_quad_strip_elts),
+ TAG(render_poly_elts),
+ TAG(render_noop),
+};
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_rendertmp.h b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_rendertmp.h
new file mode 100644
index 000000000..b9f030195
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_rendertmp.h
@@ -0,0 +1,434 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+#ifndef POSTFIX
+#define POSTFIX
+#endif
+
+#ifndef INIT
+#define INIT(x)
+#endif
+
+#ifndef NEED_EDGEFLAG_SETUP
+#define NEED_EDGEFLAG_SETUP 0
+#define EDGEFLAG_GET(a) 0
+#define EDGEFLAG_SET(a,b) (void)b
+#endif
+
+#ifndef RESET_STIPPLE
+#define RESET_STIPPLE
+#endif
+
+#ifndef RESET_OCCLUSION
+#define RESET_OCCLUSION
+#endif
+
+#ifndef TEST_PRIM_END
+#define TEST_PRIM_END(flags) (flags & PRIM_END)
+#define TEST_PRIM_BEGIN(flags) (flags & PRIM_BEGIN)
+#define TEST_PRIM_PARITY(flags) (flags & PRIM_PARITY)
+#endif
+
+#ifndef ELT
+#define ELT(x) x
+#endif
+
+#ifndef RENDER_TAB_QUALIFIER
+#define RENDER_TAB_QUALIFIER static
+#endif
+
+static void TAG(render_points)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ LOCAL_VARS;
+ (void) flags;
+
+ RESET_OCCLUSION;
+ INIT(GL_POINTS);
+ RENDER_POINTS( start, count );
+ POSTFIX;
+}
+
+static void TAG(render_lines)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ RESET_OCCLUSION;
+ INIT(GL_LINES);
+ for (j=start+1; j<count; j+=2 ) {
+ RENDER_LINE( ELT(j-1), ELT(j) );
+ RESET_STIPPLE;
+ }
+ POSTFIX;
+}
+
+
+static void TAG(render_line_strip)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ RESET_OCCLUSION;
+ INIT(GL_LINE_STRIP);
+
+ for (j=start+1; j<count; j++ )
+ RENDER_LINE( ELT(j-1), ELT(j) );
+
+ if (TEST_PRIM_END(flags))
+ RESET_STIPPLE;
+
+ POSTFIX;
+}
+
+
+static void TAG(render_line_loop)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint i;
+ LOCAL_VARS;
+
+ (void) flags;
+
+ RESET_OCCLUSION;
+ INIT(GL_LINE_LOOP);
+
+ if (start+1 < count) {
+ if (TEST_PRIM_BEGIN(flags)) {
+ RENDER_LINE( ELT(start), ELT(start+1) );
+ }
+
+ for ( i = start+2 ; i < count ; i++) {
+ RENDER_LINE( ELT(i-1), ELT(i) );
+ }
+
+ if ( TEST_PRIM_END(flags)) {
+ RENDER_LINE( ELT(count-1), ELT(start) );
+ RESET_STIPPLE;
+ }
+ }
+
+ POSTFIX;
+}
+
+
+static void TAG(render_triangles)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ INIT(GL_TRIANGLES);
+ if (NEED_EDGEFLAG_SETUP) {
+ for (j=start+2; j<count; j+=3) {
+ /* Leave the edgeflags as supplied by the user.
+ */
+ RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) );
+ RESET_STIPPLE;
+ }
+ } else {
+ for (j=start+2; j<count; j+=3) {
+ RENDER_TRI( ELT(j-2), ELT(j-1), ELT(j) );
+ }
+ }
+ POSTFIX;
+}
+
+
+
+static void TAG(render_tri_strip)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ GLuint parity = 0;
+ LOCAL_VARS;
+
+ INIT(GL_TRIANGLE_STRIP);
+ if (NEED_EDGEFLAG_SETUP) {
+ for (j=start+2;j<count;j++,parity^=1) {
+ GLuint ej2 = ELT(j-2+parity);
+ GLuint ej1 = ELT(j-1-parity);
+ GLuint ej = ELT(j);
+ GLboolean ef2 = EDGEFLAG_GET( ej2 );
+ GLboolean ef1 = EDGEFLAG_GET( ej1 );
+ GLboolean ef = EDGEFLAG_GET( ej );
+ EDGEFLAG_SET( ej2, GL_TRUE );
+ EDGEFLAG_SET( ej1, GL_TRUE );
+ EDGEFLAG_SET( ej, GL_TRUE );
+ RENDER_TRI( ej2, ej1, ej );
+ EDGEFLAG_SET( ej2, ef2 );
+ EDGEFLAG_SET( ej1, ef1 );
+ EDGEFLAG_SET( ej, ef );
+ RESET_STIPPLE;
+ }
+ } else {
+ for (j=start+2; j<count ; j++, parity^=1) {
+ RENDER_TRI( ELT(j-2+parity), ELT(j-1-parity), ELT(j) );
+ }
+ }
+ POSTFIX;
+}
+
+
+static void TAG(render_tri_fan)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ INIT(GL_TRIANGLE_FAN);
+ if (NEED_EDGEFLAG_SETUP) {
+ for (j=start+2;j<count;j++) {
+ /* For trifans, all edges are boundary.
+ */
+ GLuint ejs = ELT(start);
+ GLuint ej1 = ELT(j-1);
+ GLuint ej = ELT(j);
+ GLboolean efs = EDGEFLAG_GET( ejs );
+ GLboolean ef1 = EDGEFLAG_GET( ej1 );
+ GLboolean ef = EDGEFLAG_GET( ej );
+ EDGEFLAG_SET( ejs, GL_TRUE );
+ EDGEFLAG_SET( ej1, GL_TRUE );
+ EDGEFLAG_SET( ej, GL_TRUE );
+ RENDER_TRI( ejs, ej1, ej);
+ EDGEFLAG_SET( ejs, efs );
+ EDGEFLAG_SET( ej1, ef1 );
+ EDGEFLAG_SET( ej, ef );
+ RESET_STIPPLE;
+ }
+ } else {
+ for (j=start+2;j<count;j++) {
+ RENDER_TRI( ELT(start), ELT(j-1), ELT(j) );
+ }
+ }
+
+ POSTFIX;
+}
+
+
+static void TAG(render_poly)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j = start+2;
+ LOCAL_VARS;
+ (void) flags;
+
+ INIT(GL_POLYGON);
+ if (NEED_EDGEFLAG_SETUP) {
+ GLboolean efstart = EDGEFLAG_GET( ELT(start) );
+ GLboolean efcount = EDGEFLAG_GET( ELT(count-1) );
+
+ /* If the primitive does not begin here, the first edge
+ * is non-boundary.
+ */
+ if (!TEST_PRIM_BEGIN(flags))
+ EDGEFLAG_SET( ELT(start), GL_FALSE );
+
+ /* If the primitive does not end here, the final edge is
+ * non-boundary.
+ */
+ if (!TEST_PRIM_END(flags))
+ EDGEFLAG_SET( ELT(count-1), GL_FALSE );
+
+ /* Draw the first triangles (possibly zero)
+ */
+ if (j<count-1) {
+ GLboolean ef = EDGEFLAG_GET( ELT(j) );
+ EDGEFLAG_SET( ELT(j), GL_FALSE );
+ RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
+ EDGEFLAG_SET( ELT(j), ef );
+ j++;
+
+ /* Don't render the first edge again:
+ */
+ EDGEFLAG_SET( ELT(start), GL_FALSE );
+
+ for (;j<count-1;j++) {
+ GLboolean efj = EDGEFLAG_GET( ELT(j) );
+ EDGEFLAG_SET( ELT(j), GL_FALSE );
+ RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
+ EDGEFLAG_SET( ELT(j), efj );
+ }
+ }
+
+ /* Draw the last or only triangle
+ */
+ if (j < count)
+ RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
+
+ /* Restore the first and last edgeflags:
+ */
+ EDGEFLAG_SET( ELT(count-1), efcount );
+ EDGEFLAG_SET( ELT(start), efstart );
+
+ if (TEST_PRIM_END(flags)) {
+ RESET_STIPPLE;
+ }
+ }
+ else {
+ for (j=start+2;j<count;j++) {
+ RENDER_TRI( ELT(j-1), ELT(j), ELT(start) );
+ }
+ }
+ POSTFIX;
+}
+
+static void TAG(render_quads)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ INIT(GL_QUADS);
+ if (NEED_EDGEFLAG_SETUP) {
+ for (j=start+3; j<count; j+=4) {
+ /* Use user-specified edgeflags for quads.
+ */
+ RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) );
+ RESET_STIPPLE;
+ }
+ } else {
+ for (j=start+3; j<count; j+=4) {
+ RENDER_QUAD( ELT(j-3), ELT(j-2), ELT(j-1), ELT(j) );
+ }
+ }
+ POSTFIX;
+}
+
+static void TAG(render_quad_strip)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ GLuint j;
+ LOCAL_VARS;
+ (void) flags;
+
+ INIT(GL_QUAD_STRIP);
+ if (NEED_EDGEFLAG_SETUP) {
+ for (j=start+3;j<count;j+=2) {
+ /* All edges are boundary. Set edgeflags to 1, draw the
+ * quad, and restore them to the original values.
+ */
+ GLboolean ef3 = EDGEFLAG_GET( ELT(j-3) );
+ GLboolean ef2 = EDGEFLAG_GET( ELT(j-2) );
+ GLboolean ef1 = EDGEFLAG_GET( ELT(j-1) );
+ GLboolean ef = EDGEFLAG_GET( ELT(j) );
+ EDGEFLAG_SET( ELT(j-3), GL_TRUE );
+ EDGEFLAG_SET( ELT(j-2), GL_TRUE );
+ EDGEFLAG_SET( ELT(j-1), GL_TRUE );
+ EDGEFLAG_SET( ELT(j), GL_TRUE );
+ RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) );
+ EDGEFLAG_SET( ELT(j-3), ef3 );
+ EDGEFLAG_SET( ELT(j-2), ef2 );
+ EDGEFLAG_SET( ELT(j-1), ef1 );
+ EDGEFLAG_SET( ELT(j), ef );
+ RESET_STIPPLE;
+ }
+ } else {
+ for (j=start+3;j<count;j+=2) {
+ RENDER_QUAD( ELT(j-1), ELT(j-3), ELT(j-2), ELT(j) );
+ }
+ }
+ POSTFIX;
+}
+
+static void TAG(render_noop)( GLcontext *ctx,
+ GLuint start,
+ GLuint count,
+ GLuint flags )
+{
+ (void)(ctx && start && count && flags);
+}
+
+RENDER_TAB_QUALIFIER void (*TAG(render_tab)[GL_POLYGON+2])(GLcontext *,
+ GLuint,
+ GLuint,
+ GLuint) =
+{
+ TAG(render_points),
+ TAG(render_lines),
+ TAG(render_line_loop),
+ TAG(render_line_strip),
+ TAG(render_triangles),
+ TAG(render_tri_strip),
+ TAG(render_tri_fan),
+ TAG(render_quads),
+ TAG(render_quad_strip),
+ TAG(render_poly),
+ TAG(render_noop),
+};
+
+
+
+#ifndef PRESERVE_VB_DEFS
+#undef RENDER_TRI
+#undef RENDER_QUAD
+#undef RENDER_LINE
+#undef RENDER_POINTS
+#undef LOCAL_VARS
+#undef INIT
+#undef POSTFIX
+#undef RESET_STIPPLE
+#undef DBG
+#undef ELT
+#undef RENDER_TAB_QUALIFIER
+#endif
+
+#ifndef PRESERVE_TAG
+#undef TAG
+#endif
+
+#undef PRESERVE_VB_DEFS
+#undef PRESERVE_TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_triemit.h b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_triemit.h
new file mode 100644
index 000000000..f5979ee9a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_triemit.h
@@ -0,0 +1,164 @@
+#ifndef DO_DEBUG_VERTS
+#define DO_DEBUG_VERTS 0
+#endif
+
+#ifndef PRINT_VERTEX
+#define PRINT_VERTEX(x)
+#endif
+
+#if defined(USE_X86_ASM)
+#define COPY_DWORDS( j, vb, vertsize, v ) \
+do { \
+ int __tmp; \
+ __asm__ __volatile__( "rep ; movsl" \
+ : "=%c" (j), "=D" (vb), "=S" (__tmp) \
+ : "0" (vertsize), \
+ "D" ((long)vb), \
+ "S" ((long)v) ); \
+} while (0)
+#elif defined(HAVE_LE32_VERTS)
+#define COPY_DWORDS( j, vb, vertsize, v ) \
+do { \
+ for ( j = 0 ; j < vertsize ; j++ ) \
+ vb[j] = CPU_TO_LE32(((GLuint *)v)[j]); \
+ vb += vertsize; \
+} while (0)
+#else
+#define COPY_DWORDS( j, vb, vertsize, v ) \
+do { \
+ for ( j = 0 ; j < vertsize ; j++ ) \
+ vb[j] = ((GLuint *)v)[j]; \
+ vb += vertsize; \
+} while (0)
+#endif
+
+
+
+#if HAVE_QUADS
+static __inline void TAG(quad)( CTX_ARG,
+ VERTEX *v0,
+ VERTEX *v1,
+ VERTEX *v2,
+ VERTEX *v3 )
+{
+ GLuint vertsize = GET_VERTEX_DWORDS();
+ GLuint *vb = (GLuint *)ALLOC_VERTS( 4, vertsize);
+ GLuint j;
+
+ if (DO_DEBUG_VERTS) {
+ fprintf(stderr, "%s\n", __FUNCTION__);
+ PRINT_VERTEX(v0);
+ PRINT_VERTEX(v1);
+ PRINT_VERTEX(v2);
+ PRINT_VERTEX(v3);
+ }
+
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v2 );
+ COPY_DWORDS( j, vb, vertsize, v3 );
+}
+#else
+static __inline void TAG(quad)( CTX_ARG,
+ VERTEX *v0,
+ VERTEX *v1,
+ VERTEX *v2,
+ VERTEX *v3 )
+{
+ GLuint vertsize = GET_VERTEX_DWORDS();
+ GLuint *vb = (GLuint *)ALLOC_VERTS( 6, vertsize);
+ GLuint j;
+
+ if (DO_DEBUG_VERTS) {
+ fprintf(stderr, "%s\n", __FUNCTION__);
+ PRINT_VERTEX(v0);
+ PRINT_VERTEX(v1);
+ PRINT_VERTEX(v2);
+ PRINT_VERTEX(v3);
+ }
+
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v3 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v2 );
+ COPY_DWORDS( j, vb, vertsize, v3 );
+}
+#endif
+
+
+static __inline void TAG(triangle)( CTX_ARG,
+ VERTEX *v0,
+ VERTEX *v1,
+ VERTEX *v2 )
+{
+ GLuint vertsize = GET_VERTEX_DWORDS();
+ GLuint *vb = (GLuint *)ALLOC_VERTS( 3, vertsize);
+ GLuint j;
+
+ if (DO_DEBUG_VERTS) {
+ fprintf(stderr, "%s\n", __FUNCTION__);
+ PRINT_VERTEX(v0);
+ PRINT_VERTEX(v1);
+ PRINT_VERTEX(v2);
+ }
+
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+ COPY_DWORDS( j, vb, vertsize, v2 );
+}
+
+
+#if HAVE_LINES
+static __inline void TAG(line)( CTX_ARG,
+ VERTEX *v0,
+ VERTEX *v1 )
+{
+ GLuint vertsize = GET_VERTEX_DWORDS();
+ GLuint *vb = (GLuint *)ALLOC_VERTS( 2, vertsize);
+ GLuint j;
+
+ COPY_DWORDS( j, vb, vertsize, v0 );
+ COPY_DWORDS( j, vb, vertsize, v1 );
+}
+#endif
+
+#if HAVE_POINTS
+static __inline void TAG(point)( CTX_ARG,
+ VERTEX *v0 )
+{
+ GLuint vertsize = GET_VERTEX_DWORDS();
+ GLuint *vb = (GLuint *)ALLOC_VERTS( 1, vertsize);
+ int j;
+
+ COPY_DWORDS( j, vb, vertsize, v0 );
+}
+#endif
+
+
+static void TAG(fast_clipped_poly)( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
+{
+ LOCAL_VARS
+ GLuint vertsize = GET_VERTEX_DWORDS();
+ GLuint *vb = (GLuint *)ALLOC_VERTS( (n-2) * 3, vertsize );
+ const GLuint *start = (const GLuint *)VERT(elts[0]);
+ GLuint i,j;
+
+ if (DO_DEBUG_VERTS) {
+ fprintf(stderr, "%s\n", __FUNCTION__);
+ PRINT_VERTEX(VERT(elts[0]));
+ PRINT_VERTEX(VERT(elts[1]));
+ }
+
+ for (i = 2 ; i < n ; i++) {
+ if (DO_DEBUG_VERTS) {
+ PRINT_VERTEX(VERT(elts[i]));
+ }
+
+ COPY_DWORDS( j, vb, vertsize, VERT(elts[i-1]) );
+ COPY_DWORDS( j, vb, vertsize, VERT(elts[i]) );
+ COPY_DWORDS( j, vb, vertsize, start );
+ }
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_tritmp.h b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_tritmp.h
new file mode 100644
index 000000000..0bf32ff34
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_tritmp.h
@@ -0,0 +1,833 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+/* Template for building functions to plug into the driver interface
+ * of t_vb_render.c:
+ * ctx->Driver.QuadFunc
+ * ctx->Driver.TriangleFunc
+ * ctx->Driver.LineFunc
+ * ctx->Driver.PointsFunc
+ *
+ * DO_TWOSIDE: Plug back-color values from the VB into backfacing triangles,
+ * and restore vertices afterwards.
+ * DO_OFFSET: Calculate offset for triangles and adjust vertices. Restore
+ * vertices after rendering.
+ * DO_FLAT: For hardware without native flatshading, copy provoking colors
+ * into the other vertices. Restore after rendering.
+ * DO_UNFILLED: Decompose triangles to lines and points where appropriate.
+ * DO_TWOSTENCIL:Gross hack for two-sided stencil.
+ *
+ * HAVE_RGBA: Vertices have rgba values (otherwise index values).
+ * HAVE_SPEC: Vertices have secondary rgba values.
+ *
+ * VERT_X(v): Alias for vertex x value.
+ * VERT_Y(v): Alias for vertex y value.
+ * VERT_Z(v): Alias for vertex z value.
+ * DEPTH_SCALE: Scale for constant offset.
+ * REVERSE_DEPTH: Viewport depth range reversed.
+ *
+ * VERTEX: Hardware vertex type.
+ * GET_VERTEX(n): Retreive vertex with index n.
+ * AREA_IS_CCW(a): Return true if triangle with signed area a is ccw.
+ *
+ * VERT_SET_RGBA: Assign vertex rgba from VB color.
+ * VERT_COPY_RGBA: Copy vertex rgba another vertex.
+ * VERT_SAVE_RGBA: Save vertex rgba to a local variable.
+ * VERT_RESTORE_RGBA: Restore vertex rgba from a local variable.
+ * --> Similar for IND and SPEC.
+ *
+ * LOCAL_VARS(n): (At least) define local vars for save/restore rgba.
+ *
+ */
+
+#if HAVE_RGBA
+#define VERT_SET_IND( v, c ) (void) c
+#define VERT_COPY_IND( v0, v1 )
+#define VERT_SAVE_IND( idx )
+#define VERT_RESTORE_IND( idx )
+#if HAVE_BACK_COLORS
+#define VERT_SET_RGBA( v, c )
+#endif
+#else
+#define VERT_SET_RGBA( v, c ) (void) c
+#define VERT_COPY_RGBA( v0, v1 )
+#define VERT_SAVE_RGBA( idx )
+#define VERT_RESTORE_RGBA( idx )
+#if HAVE_BACK_COLORS
+#define VERT_SET_IND( v, c )
+#endif
+#endif
+
+#if !HAVE_SPEC
+#define VERT_SET_SPEC( v, c ) (void) c
+#define VERT_COPY_SPEC( v0, v1 )
+#define VERT_SAVE_SPEC( idx )
+#define VERT_RESTORE_SPEC( idx )
+#if HAVE_BACK_COLORS
+#define VERT_COPY_SPEC1( v )
+#endif
+#else
+#if HAVE_BACK_COLORS
+#define VERT_SET_SPEC( v, c )
+#endif
+#endif
+
+#if !HAVE_BACK_COLORS
+#define VERT_COPY_SPEC1( v )
+#define VERT_COPY_IND1( v )
+#define VERT_COPY_RGBA1( v )
+#endif
+
+#ifndef INSANE_VERTICES
+#define VERT_SET_Z(v,val) VERT_Z(v) = val
+#define VERT_Z_ADD(v,val) VERT_Z(v) += val
+#endif
+
+#ifndef REVERSE_DEPTH
+#define REVERSE_DEPTH 0
+#endif
+
+/* disable twostencil for un-aware drivers */
+#ifndef HAVE_STENCIL_TWOSIDE
+#define HAVE_STENCIL_TWOSIDE 0
+#endif
+#ifndef DO_TWOSTENCIL
+#define DO_TWOSTENCIL 0
+#endif
+#ifndef SETUP_STENCIL
+#define SETUP_STENCIL(f)
+#endif
+#ifndef UNSET_STENCIL
+#define UNSET_STENCIL(f)
+#endif
+
+#if DO_TRI
+static void TAG(triangle)( GLcontext *ctx, GLuint e0, GLuint e1, GLuint e2 )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
+ VERTEX *v[3];
+ GLfloat offset = 0;
+ GLfloat z[3];
+ GLenum mode = GL_FILL;
+ GLuint facing = 0;
+ LOCAL_VARS(3);
+
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ v[0] = (VERTEX *)GET_VERTEX(e0);
+ v[1] = (VERTEX *)GET_VERTEX(e1);
+ v[2] = (VERTEX *)GET_VERTEX(e2);
+
+ if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL)
+ {
+ GLfloat ex = VERT_X(v[0]) - VERT_X(v[2]);
+ GLfloat ey = VERT_Y(v[0]) - VERT_Y(v[2]);
+ GLfloat fx = VERT_X(v[1]) - VERT_X(v[2]);
+ GLfloat fy = VERT_Y(v[1]) - VERT_Y(v[2]);
+ GLfloat cc = ex*fy - ey*fx;
+
+ if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL)
+ {
+ facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit;
+
+ if (DO_TWOSTENCIL && ctx->Stencil.TestTwoSide) {
+ ctx->_Facing = facing; /* mixed mode rendering: for 2-sided stencil test */
+ }
+
+ if (DO_UNFILLED) {
+ if (facing) {
+ mode = ctx->Polygon.BackMode;
+ if (ctx->Polygon.CullFlag &&
+ ctx->Polygon.CullFaceMode != GL_FRONT) {
+ return;
+ }
+ } else {
+ mode = ctx->Polygon.FrontMode;
+ if (ctx->Polygon.CullFlag &&
+ ctx->Polygon.CullFaceMode != GL_BACK) {
+ return;
+ }
+ }
+ }
+
+ if (DO_TWOSIDE && facing == 1)
+ {
+ if (HAVE_RGBA) {
+ if (HAVE_BACK_COLORS) {
+ if (!DO_FLAT) {
+ VERT_SAVE_RGBA( 0 );
+ VERT_SAVE_RGBA( 1 );
+ VERT_COPY_RGBA1( v[0] );
+ VERT_COPY_RGBA1( v[1] );
+ }
+ VERT_SAVE_RGBA( 2 );
+ VERT_COPY_RGBA1( v[2] );
+ if (HAVE_SPEC) {
+ if (!DO_FLAT) {
+ VERT_SAVE_SPEC( 0 );
+ VERT_SAVE_SPEC( 1 );
+ VERT_COPY_SPEC1( v[0] );
+ VERT_COPY_SPEC1( v[1] );
+ }
+ VERT_SAVE_SPEC( 2 );
+ VERT_COPY_SPEC1( v[2] );
+ }
+ }
+ else {
+ GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data;
+ (void) vbcolor;
+
+ if (!DO_FLAT) {
+ VERT_SAVE_RGBA( 0 );
+ VERT_SAVE_RGBA( 1 );
+ }
+ VERT_SAVE_RGBA( 2 );
+
+ if (VB->ColorPtr[1]->stride) {
+ ASSERT(VB->ColorPtr[1]->stride == 4*sizeof(GLfloat));
+
+ if (!DO_FLAT) {
+ VERT_SET_RGBA( v[0], vbcolor[e0] );
+ VERT_SET_RGBA( v[1], vbcolor[e1] );
+ }
+ VERT_SET_RGBA( v[2], vbcolor[e2] );
+ }
+ else {
+ if (!DO_FLAT) {
+ VERT_SET_RGBA( v[0], vbcolor[0] );
+ VERT_SET_RGBA( v[1], vbcolor[0] );
+ }
+ VERT_SET_RGBA( v[2], vbcolor[0] );
+ }
+
+ if (HAVE_SPEC && VB->SecondaryColorPtr[1]) {
+ GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;
+ ASSERT(VB->SecondaryColorPtr[1]->stride == 4*sizeof(GLfloat));
+
+ if (!DO_FLAT) {
+ VERT_SAVE_SPEC( 0 );
+ VERT_SAVE_SPEC( 1 );
+ VERT_SET_SPEC( v[0], vbspec[e0] );
+ VERT_SET_SPEC( v[1], vbspec[e1] );
+ }
+ VERT_SAVE_SPEC( 2 );
+ VERT_SET_SPEC( v[2], vbspec[e2] );
+ }
+ }
+ }
+ else {
+ GLfloat (*vbindex) = (GLfloat *)VB->IndexPtr[1]->data;
+ if (!DO_FLAT) {
+ VERT_SAVE_IND( 0 );
+ VERT_SAVE_IND( 1 );
+ VERT_SET_IND( v[0], vbindex[e0] );
+ VERT_SET_IND( v[1], vbindex[e1] );
+ }
+ VERT_SAVE_IND( 2 );
+ VERT_SET_IND( v[2], vbindex[e2] );
+ }
+ }
+ }
+
+
+ if (DO_OFFSET)
+ {
+ offset = ctx->Polygon.OffsetUnits * DEPTH_SCALE;
+ z[0] = VERT_Z(v[0]);
+ z[1] = VERT_Z(v[1]);
+ z[2] = VERT_Z(v[2]);
+ if (cc * cc > 1e-16) {
+ GLfloat ic = 1.0 / cc;
+ GLfloat ez = z[0] - z[2];
+ GLfloat fz = z[1] - z[2];
+ GLfloat a = ey*fz - ez*fy;
+ GLfloat b = ez*fx - ex*fz;
+ GLfloat ac = a * ic;
+ GLfloat bc = b * ic;
+ if ( ac < 0.0f ) ac = -ac;
+ if ( bc < 0.0f ) bc = -bc;
+ offset += MAX2( ac, bc ) * ctx->Polygon.OffsetFactor;
+ }
+ offset *= ctx->DrawBuffer->_MRD * (REVERSE_DEPTH ? -1.0 : 1.0);
+ }
+ }
+
+ if (DO_FLAT) {
+ if (HAVE_RGBA) {
+ VERT_SAVE_RGBA( 0 );
+ VERT_SAVE_RGBA( 1 );
+ VERT_COPY_RGBA( v[0], v[2] );
+ VERT_COPY_RGBA( v[1], v[2] );
+ if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
+ VERT_SAVE_SPEC( 0 );
+ VERT_SAVE_SPEC( 1 );
+ VERT_COPY_SPEC( v[0], v[2] );
+ VERT_COPY_SPEC( v[1], v[2] );
+ }
+ }
+ else {
+ VERT_SAVE_IND( 0 );
+ VERT_SAVE_IND( 1 );
+ VERT_COPY_IND( v[0], v[2] );
+ VERT_COPY_IND( v[1], v[2] );
+ }
+ }
+
+ if (mode == GL_POINT) {
+ if (DO_OFFSET && ctx->Polygon.OffsetPoint) {
+ VERT_Z_ADD(v[0], offset);
+ VERT_Z_ADD(v[1], offset);
+ VERT_Z_ADD(v[2], offset);
+ }
+ if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) {
+ SETUP_STENCIL(facing);
+ UNFILLED_TRI( ctx, GL_POINT, e0, e1, e2 );
+ UNSET_STENCIL(facing);
+ } else {
+ UNFILLED_TRI( ctx, GL_POINT, e0, e1, e2 );
+ }
+ } else if (mode == GL_LINE) {
+ if (DO_OFFSET && ctx->Polygon.OffsetLine) {
+ VERT_Z_ADD(v[0], offset);
+ VERT_Z_ADD(v[1], offset);
+ VERT_Z_ADD(v[2], offset);
+ }
+ if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) {
+ SETUP_STENCIL(facing);
+ UNFILLED_TRI( ctx, GL_LINE, e0, e1, e2 );
+ UNSET_STENCIL(facing);
+ } else {
+ UNFILLED_TRI( ctx, GL_LINE, e0, e1, e2 );
+ }
+ } else {
+ if (DO_OFFSET && ctx->Polygon.OffsetFill) {
+ VERT_Z_ADD(v[0], offset);
+ VERT_Z_ADD(v[1], offset);
+ VERT_Z_ADD(v[2], offset);
+ }
+ if (DO_UNFILLED)
+ RASTERIZE( GL_TRIANGLES );
+ if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) {
+ SETUP_STENCIL(facing);
+ TRI( v[0], v[1], v[2] );
+ UNSET_STENCIL(facing);
+ } else {
+ TRI( v[0], v[1], v[2] );
+ }
+ }
+
+ if (DO_OFFSET)
+ {
+ VERT_SET_Z(v[0], z[0]);
+ VERT_SET_Z(v[1], z[1]);
+ VERT_SET_Z(v[2], z[2]);
+ }
+
+ if (DO_TWOSIDE && facing == 1)
+ {
+ if (HAVE_RGBA) {
+ if (!DO_FLAT) {
+ VERT_RESTORE_RGBA( 0 );
+ VERT_RESTORE_RGBA( 1 );
+ }
+ VERT_RESTORE_RGBA( 2 );
+ if (HAVE_SPEC) {
+ if (!DO_FLAT) {
+ VERT_RESTORE_SPEC( 0 );
+ VERT_RESTORE_SPEC( 1 );
+ }
+ VERT_RESTORE_SPEC( 2 );
+ }
+ }
+ else {
+ if (!DO_FLAT) {
+ VERT_RESTORE_IND( 0 );
+ VERT_RESTORE_IND( 1 );
+ }
+ VERT_RESTORE_IND( 2 );
+ }
+ }
+
+
+ if (DO_FLAT) {
+ if (HAVE_RGBA) {
+ VERT_RESTORE_RGBA( 0 );
+ VERT_RESTORE_RGBA( 1 );
+ if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
+ VERT_RESTORE_SPEC( 0 );
+ VERT_RESTORE_SPEC( 1 );
+ }
+ }
+ else {
+ VERT_RESTORE_IND( 0 );
+ VERT_RESTORE_IND( 1 );
+ }
+ }
+}
+#endif
+
+#if DO_QUAD
+#if DO_FULL_QUAD
+static void TAG(quad)( GLcontext *ctx,
+ GLuint e0, GLuint e1, GLuint e2, GLuint e3 )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
+ VERTEX *v[4];
+ GLfloat offset = 0;
+ GLfloat z[4];
+ GLenum mode = GL_FILL;
+ GLuint facing = 0;
+ LOCAL_VARS(4);
+
+ v[0] = (VERTEX *)GET_VERTEX(e0);
+ v[1] = (VERTEX *)GET_VERTEX(e1);
+ v[2] = (VERTEX *)GET_VERTEX(e2);
+ v[3] = (VERTEX *)GET_VERTEX(e3);
+
+ if (DO_TWOSIDE || DO_OFFSET || DO_UNFILLED || DO_TWOSTENCIL)
+ {
+ GLfloat ex = VERT_X(v[2]) - VERT_X(v[0]);
+ GLfloat ey = VERT_Y(v[2]) - VERT_Y(v[0]);
+ GLfloat fx = VERT_X(v[3]) - VERT_X(v[1]);
+ GLfloat fy = VERT_Y(v[3]) - VERT_Y(v[1]);
+ GLfloat cc = ex*fy - ey*fx;
+
+ if (DO_TWOSIDE || DO_UNFILLED || DO_TWOSTENCIL)
+ {
+ facing = AREA_IS_CCW( cc ) ^ ctx->Polygon._FrontBit;
+
+ if (DO_TWOSTENCIL && ctx->Stencil.TestTwoSide) {
+ ctx->_Facing = facing; /* mixed mode rendering: for 2-sided stencil test */
+ }
+
+ if (DO_UNFILLED) {
+ if (facing) {
+ mode = ctx->Polygon.BackMode;
+ if (ctx->Polygon.CullFlag &&
+ ctx->Polygon.CullFaceMode != GL_FRONT) {
+ return;
+ }
+ } else {
+ mode = ctx->Polygon.FrontMode;
+ if (ctx->Polygon.CullFlag &&
+ ctx->Polygon.CullFaceMode != GL_BACK) {
+ return;
+ }
+ }
+ }
+
+ if (DO_TWOSIDE && facing == 1)
+ {
+ if (HAVE_RGBA) {
+ GLfloat (*vbcolor)[4] = VB->ColorPtr[1]->data;
+ (void)vbcolor;
+
+ if (HAVE_BACK_COLORS) {
+ if (!DO_FLAT) {
+ VERT_SAVE_RGBA( 0 );
+ VERT_SAVE_RGBA( 1 );
+ VERT_SAVE_RGBA( 2 );
+ VERT_COPY_RGBA1( v[0] );
+ VERT_COPY_RGBA1( v[1] );
+ VERT_COPY_RGBA1( v[2] );
+ }
+ VERT_SAVE_RGBA( 3 );
+ VERT_COPY_RGBA1( v[3] );
+ if (HAVE_SPEC) {
+ if (!DO_FLAT) {
+ VERT_SAVE_SPEC( 0 );
+ VERT_SAVE_SPEC( 1 );
+ VERT_SAVE_SPEC( 2 );
+ VERT_COPY_SPEC1( v[0] );
+ VERT_COPY_SPEC1( v[1] );
+ VERT_COPY_SPEC1( v[2] );
+ }
+ VERT_SAVE_SPEC( 3 );
+ VERT_COPY_SPEC1( v[3] );
+ }
+ }
+ else {
+ if (!DO_FLAT) {
+ VERT_SAVE_RGBA( 0 );
+ VERT_SAVE_RGBA( 1 );
+ VERT_SAVE_RGBA( 2 );
+ }
+ VERT_SAVE_RGBA( 3 );
+
+ if (VB->ColorPtr[1]->stride) {
+ if (!DO_FLAT) {
+ VERT_SET_RGBA( v[0], vbcolor[e0] );
+ VERT_SET_RGBA( v[1], vbcolor[e1] );
+ VERT_SET_RGBA( v[2], vbcolor[e2] );
+ }
+ VERT_SET_RGBA( v[3], vbcolor[e3] );
+ }
+ else {
+ if (!DO_FLAT) {
+ VERT_SET_RGBA( v[0], vbcolor[0] );
+ VERT_SET_RGBA( v[1], vbcolor[0] );
+ VERT_SET_RGBA( v[2], vbcolor[0] );
+ }
+ VERT_SET_RGBA( v[3], vbcolor[0] );
+ }
+
+ if (HAVE_SPEC && VB->SecondaryColorPtr[1]) {
+ GLfloat (*vbspec)[4] = VB->SecondaryColorPtr[1]->data;
+ ASSERT(VB->SecondaryColorPtr[1]->stride==4*sizeof(GLfloat));
+
+ if (!DO_FLAT) {
+ VERT_SAVE_SPEC( 0 );
+ VERT_SAVE_SPEC( 1 );
+ VERT_SAVE_SPEC( 2 );
+ VERT_SET_SPEC( v[0], vbspec[e0] );
+ VERT_SET_SPEC( v[1], vbspec[e1] );
+ VERT_SET_SPEC( v[2], vbspec[e2] );
+ }
+ VERT_SAVE_SPEC( 3 );
+ VERT_SET_SPEC( v[3], vbspec[e3] );
+ }
+ }
+ }
+ else {
+ GLfloat *vbindex = (GLfloat *)VB->IndexPtr[1]->data;
+ if (!DO_FLAT) {
+ VERT_SAVE_IND( 0 );
+ VERT_SAVE_IND( 1 );
+ VERT_SAVE_IND( 2 );
+ VERT_SET_IND( v[0], vbindex[e0] );
+ VERT_SET_IND( v[1], vbindex[e1] );
+ VERT_SET_IND( v[2], vbindex[e2] );
+ }
+ VERT_SAVE_IND( 3 );
+ VERT_SET_IND( v[3], vbindex[e3] );
+ }
+ }
+ }
+
+
+ if (DO_OFFSET)
+ {
+ offset = ctx->Polygon.OffsetUnits * DEPTH_SCALE;
+ z[0] = VERT_Z(v[0]);
+ z[1] = VERT_Z(v[1]);
+ z[2] = VERT_Z(v[2]);
+ z[3] = VERT_Z(v[3]);
+ if (cc * cc > 1e-16) {
+ GLfloat ez = z[2] - z[0];
+ GLfloat fz = z[3] - z[1];
+ 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 ) * ctx->Polygon.OffsetFactor;
+ }
+ offset *= ctx->DrawBuffer->_MRD * (REVERSE_DEPTH ? -1.0 : 1.0);
+ }
+ }
+
+ if (DO_FLAT) {
+ if (HAVE_RGBA) {
+ VERT_SAVE_RGBA( 0 );
+ VERT_SAVE_RGBA( 1 );
+ VERT_SAVE_RGBA( 2 );
+ VERT_COPY_RGBA( v[0], v[3] );
+ VERT_COPY_RGBA( v[1], v[3] );
+ VERT_COPY_RGBA( v[2], v[3] );
+ if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
+ VERT_SAVE_SPEC( 0 );
+ VERT_SAVE_SPEC( 1 );
+ VERT_SAVE_SPEC( 2 );
+ VERT_COPY_SPEC( v[0], v[3] );
+ VERT_COPY_SPEC( v[1], v[3] );
+ VERT_COPY_SPEC( v[2], v[3] );
+ }
+ }
+ else {
+ VERT_SAVE_IND( 0 );
+ VERT_SAVE_IND( 1 );
+ VERT_SAVE_IND( 2 );
+ VERT_COPY_IND( v[0], v[3] );
+ VERT_COPY_IND( v[1], v[3] );
+ VERT_COPY_IND( v[2], v[3] );
+ }
+ }
+
+ if (mode == GL_POINT) {
+ if (( DO_OFFSET) && ctx->Polygon.OffsetPoint) {
+ VERT_Z_ADD(v[0], offset);
+ VERT_Z_ADD(v[1], offset);
+ VERT_Z_ADD(v[2], offset);
+ VERT_Z_ADD(v[3], offset);
+ }
+ if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) {
+ SETUP_STENCIL(facing);
+ UNFILLED_QUAD( ctx, GL_POINT, e0, e1, e2, e3 );
+ UNSET_STENCIL(facing);
+ } else {
+ UNFILLED_QUAD( ctx, GL_POINT, e0, e1, e2, e3 );
+ }
+ } else if (mode == GL_LINE) {
+ if (DO_OFFSET && ctx->Polygon.OffsetLine) {
+ VERT_Z_ADD(v[0], offset);
+ VERT_Z_ADD(v[1], offset);
+ VERT_Z_ADD(v[2], offset);
+ VERT_Z_ADD(v[3], offset);
+ }
+ if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) {
+ SETUP_STENCIL(facing);
+ UNFILLED_QUAD( ctx, GL_LINE, e0, e1, e2, e3 );
+ UNSET_STENCIL(facing);
+ } else {
+ UNFILLED_QUAD( ctx, GL_LINE, e0, e1, e2, e3 );
+ }
+ } else {
+ if (DO_OFFSET && ctx->Polygon.OffsetFill) {
+ VERT_Z_ADD(v[0], offset);
+ VERT_Z_ADD(v[1], offset);
+ VERT_Z_ADD(v[2], offset);
+ VERT_Z_ADD(v[3], offset);
+ }
+ RASTERIZE( GL_QUADS );
+ if (DO_TWOSTENCIL && !HAVE_STENCIL_TWOSIDE && ctx->Stencil.TestTwoSide) {
+ SETUP_STENCIL(facing);
+ QUAD( (v[0]), (v[1]), (v[2]), (v[3]) );
+ UNSET_STENCIL(facing);
+ } else {
+ QUAD( (v[0]), (v[1]), (v[2]), (v[3]) );
+ }
+ }
+
+ if (DO_OFFSET)
+ {
+ VERT_SET_Z(v[0], z[0]);
+ VERT_SET_Z(v[1], z[1]);
+ VERT_SET_Z(v[2], z[2]);
+ VERT_SET_Z(v[3], z[3]);
+ }
+
+ if (DO_TWOSIDE && facing == 1)
+ {
+ if (HAVE_RGBA) {
+ if (!DO_FLAT) {
+ VERT_RESTORE_RGBA( 0 );
+ VERT_RESTORE_RGBA( 1 );
+ VERT_RESTORE_RGBA( 2 );
+ }
+ VERT_RESTORE_RGBA( 3 );
+ if (HAVE_SPEC) {
+ if (!DO_FLAT) {
+ VERT_RESTORE_SPEC( 0 );
+ VERT_RESTORE_SPEC( 1 );
+ VERT_RESTORE_SPEC( 2 );
+ }
+ VERT_RESTORE_SPEC( 3 );
+ }
+ }
+ else {
+ if (!DO_FLAT) {
+ VERT_RESTORE_IND( 0 );
+ VERT_RESTORE_IND( 1 );
+ VERT_RESTORE_IND( 2 );
+ }
+ VERT_RESTORE_IND( 3 );
+ }
+ }
+
+
+ if (DO_FLAT) {
+ if (HAVE_RGBA) {
+ VERT_RESTORE_RGBA( 0 );
+ VERT_RESTORE_RGBA( 1 );
+ VERT_RESTORE_RGBA( 2 );
+ if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
+ VERT_RESTORE_SPEC( 0 );
+ VERT_RESTORE_SPEC( 1 );
+ VERT_RESTORE_SPEC( 2 );
+ }
+ }
+ else {
+ VERT_RESTORE_IND( 0 );
+ VERT_RESTORE_IND( 1 );
+ VERT_RESTORE_IND( 2 );
+ }
+ }
+}
+#else
+static void TAG(quad)( GLcontext *ctx, GLuint e0,
+ GLuint e1, GLuint e2, GLuint e3 )
+{
+ if (DO_UNFILLED) {
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLubyte ef1 = VB->EdgeFlag[e1];
+ GLubyte ef3 = VB->EdgeFlag[e3];
+ VB->EdgeFlag[e1] = 0;
+ TAG(triangle)( ctx, e0, e1, e3 );
+ VB->EdgeFlag[e1] = ef1;
+ VB->EdgeFlag[e3] = 0;
+ TAG(triangle)( ctx, e1, e2, e3 );
+ VB->EdgeFlag[e3] = ef3;
+ } else {
+ TAG(triangle)( ctx, e0, e1, e3 );
+ TAG(triangle)( ctx, e1, e2, e3 );
+ }
+}
+#endif
+#endif
+
+#if DO_LINE
+static void TAG(line)( GLcontext *ctx, GLuint e0, GLuint e1 )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ VERTEX *v[2];
+ LOCAL_VARS(2);
+
+ v[0] = (VERTEX *)GET_VERTEX(e0);
+ v[1] = (VERTEX *)GET_VERTEX(e1);
+
+ if (DO_FLAT) {
+ if (HAVE_RGBA) {
+ VERT_SAVE_RGBA( 0 );
+ VERT_COPY_RGBA( v[0], v[1] );
+ if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
+ VERT_SAVE_SPEC( 0 );
+ VERT_COPY_SPEC( v[0], v[1] );
+ }
+ }
+ else {
+ VERT_SAVE_IND( 0 );
+ VERT_COPY_IND( v[0], v[1] );
+ }
+ }
+
+ LINE( v[0], v[1] );
+
+ if (DO_FLAT) {
+ if (HAVE_RGBA) {
+ VERT_RESTORE_RGBA( 0 );
+
+ if (HAVE_SPEC && VB->SecondaryColorPtr[0]) {
+ VERT_RESTORE_SPEC( 0 );
+ }
+ }
+ else {
+ VERT_RESTORE_IND( 0 );
+ }
+ }
+}
+#endif
+
+#if DO_POINTS
+static void TAG(points)( GLcontext *ctx, GLuint first, GLuint last )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT( ctx )->vb;
+ GLuint i;
+ LOCAL_VARS(1);
+
+ if (VB->Elts == 0) {
+ for ( i = first ; i < last ; i++ ) {
+ if ( VB->ClipMask[i] == 0 ) {
+ VERTEX *v = (VERTEX *)GET_VERTEX(i);
+ POINT( v );
+ }
+ }
+ } else {
+ for ( i = first ; i < last ; i++ ) {
+ GLuint e = VB->Elts[i];
+ if ( VB->ClipMask[e] == 0 ) {
+ VERTEX *v = (VERTEX *)GET_VERTEX(e);
+ POINT( v );
+ }
+ }
+ }
+}
+#endif
+
+static void TAG(init)( void )
+{
+#if DO_QUAD
+ TAB[IND].quad = TAG(quad);
+#endif
+#if DO_TRI
+ TAB[IND].triangle = TAG(triangle);
+#endif
+#if DO_LINE
+ TAB[IND].line = TAG(line);
+#endif
+#if DO_POINTS
+ TAB[IND].points = TAG(points);
+#endif
+}
+
+#undef IND
+#undef TAG
+
+#if HAVE_RGBA
+#undef VERT_SET_IND
+#undef VERT_COPY_IND
+#undef VERT_SAVE_IND
+#undef VERT_RESTORE_IND
+#if HAVE_BACK_COLORS
+#undef VERT_SET_RGBA
+#endif
+#else
+#undef VERT_SET_RGBA
+#undef VERT_COPY_RGBA
+#undef VERT_SAVE_RGBA
+#undef VERT_RESTORE_RGBA
+#if HAVE_BACK_COLORS
+#undef VERT_SET_IND
+#endif
+#endif
+
+#if !HAVE_SPEC
+#undef VERT_SET_SPEC
+#undef VERT_COPY_SPEC
+#undef VERT_SAVE_SPEC
+#undef VERT_RESTORE_SPEC
+#if HAVE_BACK_COLORS
+#undef VERT_COPY_SPEC1
+#endif
+#else
+#if HAVE_BACK_COLORS
+#undef VERT_SET_SPEC
+#endif
+#endif
+
+#if !HAVE_BACK_COLORS
+#undef VERT_COPY_SPEC1
+#undef VERT_COPY_IND1
+#undef VERT_COPY_RGBA1
+#endif
+
+#ifndef INSANE_VERTICES
+#undef VERT_SET_Z
+#undef VERT_Z_ADD
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_unfilled.h b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_unfilled.h
new file mode 100644
index 000000000..46415ea5f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_unfilled.h
@@ -0,0 +1,212 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+#if HAVE_RGBA
+#define VERT_SET_IND( v, c )
+#define VERT_COPY_IND( v0, v1 )
+#define VERT_SAVE_IND( idx )
+#define VERT_RESTORE_IND( idx )
+#endif
+
+#if !HAVE_SPEC
+#define VERT_SET_SPEC( v, c )
+#define VERT_COPY_SPEC( v0, v1 )
+#define VERT_SAVE_SPEC( idx )
+#define VERT_RESTORE_SPEC( idx )
+#endif
+
+static void TAG(unfilled_tri)( GLcontext *ctx,
+ GLenum mode,
+ GLuint e0, GLuint e1, GLuint e2 )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLubyte *ef = VB->EdgeFlag;
+ VERTEX *v[3];
+ LOCAL_VARS(3);
+
+ v[0] = (VERTEX *)GET_VERTEX(e0);
+ v[1] = (VERTEX *)GET_VERTEX(e1);
+ v[2] = (VERTEX *)GET_VERTEX(e2);
+
+ if ((ctx->_TriangleCaps & DD_FLATSHADE) && HAVE_HW_FLATSHADE) {
+ if (HAVE_RGBA) {
+ VERT_SAVE_RGBA(0);
+ VERT_SAVE_RGBA(1);
+ VERT_COPY_RGBA(v[0], v[2]);
+ VERT_COPY_RGBA(v[1], v[2]);
+
+ if (HAVE_SPEC) {
+ VERT_SAVE_SPEC(0);
+ VERT_SAVE_SPEC(1);
+ VERT_COPY_SPEC(v[0], v[2]);
+ VERT_COPY_SPEC(v[1], v[2]);
+ }
+ } else {
+ VERT_SAVE_IND(0);
+ VERT_SAVE_IND(1);
+ VERT_COPY_IND(v[0], v[2]);
+ VERT_COPY_IND(v[1], v[2]);
+ }
+ }
+
+/* fprintf(stderr, "%s %s %d %d %d\n", __FUNCTION__, */
+/* _mesa_lookup_enum_by_nr( mode ), */
+/* ef[e0], ef[e1], ef[e2]); */
+
+ if (mode == GL_POINT) {
+ RASTERIZE(GL_POINTS);
+ if (ef[e0]) POINT( v[0] );
+ if (ef[e1]) POINT( v[1] );
+ if (ef[e2]) POINT( v[2] );
+ }
+ else {
+ RASTERIZE(GL_LINES);
+ if (RENDER_PRIMITIVE == GL_POLYGON) {
+ if (ef[e2]) LINE( v[2], v[0] );
+ if (ef[e0]) LINE( v[0], v[1] );
+ if (ef[e1]) LINE( v[1], v[2] );
+ }
+ else {
+ if (ef[e0]) LINE( v[0], v[1] );
+ if (ef[e1]) LINE( v[1], v[2] );
+ if (ef[e2]) LINE( v[2], v[0] );
+ }
+ }
+
+ if ((ctx->_TriangleCaps & DD_FLATSHADE) && HAVE_HW_FLATSHADE) {
+ if (HAVE_RGBA) {
+ VERT_RESTORE_RGBA(0);
+ VERT_RESTORE_RGBA(1);
+
+ if (HAVE_SPEC) {
+ VERT_RESTORE_SPEC(0);
+ VERT_RESTORE_SPEC(1);
+ }
+ } else {
+ VERT_RESTORE_IND(0);
+ VERT_RESTORE_IND(1);
+ }
+ }
+}
+
+
+static void TAG(unfilled_quad)( GLcontext *ctx,
+ GLenum mode,
+ GLuint e0, GLuint e1,
+ GLuint e2, GLuint e3 )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLubyte *ef = VB->EdgeFlag;
+ VERTEX *v[4];
+ LOCAL_VARS(4);
+
+ v[0] = (VERTEX *)GET_VERTEX(e0);
+ v[1] = (VERTEX *)GET_VERTEX(e1);
+ v[2] = (VERTEX *)GET_VERTEX(e2);
+ v[3] = (VERTEX *)GET_VERTEX(e3);
+
+ /* Hardware flatshading breaks down here. If the hardware doesn't
+ * support flatshading, this will already have been done:
+ */
+ if ((ctx->_TriangleCaps & DD_FLATSHADE) && HAVE_HW_FLATSHADE) {
+ if (HAVE_RGBA) {
+ VERT_SAVE_RGBA(0);
+ VERT_SAVE_RGBA(1);
+ VERT_SAVE_RGBA(2);
+ VERT_COPY_RGBA(v[0], v[3]);
+ VERT_COPY_RGBA(v[1], v[3]);
+ VERT_COPY_RGBA(v[2], v[3]);
+
+ if (HAVE_SPEC) {
+ VERT_SAVE_SPEC(0);
+ VERT_SAVE_SPEC(1);
+ VERT_SAVE_SPEC(2);
+ VERT_COPY_SPEC(v[0], v[3]);
+ VERT_COPY_SPEC(v[1], v[3]);
+ VERT_COPY_SPEC(v[2], v[3]);
+ }
+ } else {
+ VERT_SAVE_IND(0);
+ VERT_SAVE_IND(1);
+ VERT_SAVE_IND(2);
+ VERT_COPY_IND(v[0], v[3]);
+ VERT_COPY_IND(v[1], v[3]);
+ VERT_COPY_IND(v[2], v[3]);
+ }
+ }
+
+ if (mode == GL_POINT) {
+ RASTERIZE(GL_POINTS);
+ if (ef[e0]) POINT( v[0] );
+ if (ef[e1]) POINT( v[1] );
+ if (ef[e2]) POINT( v[2] );
+ if (ef[e3]) POINT( v[3] );
+ }
+ else {
+ RASTERIZE(GL_LINES);
+ if (ef[e0]) LINE( v[0], v[1] );
+ if (ef[e1]) LINE( v[1], v[2] );
+ if (ef[e2]) LINE( v[2], v[3] );
+ if (ef[e3]) LINE( v[3], v[0] );
+ }
+
+ if ((ctx->_TriangleCaps & DD_FLATSHADE) && HAVE_HW_FLATSHADE) {
+ if (HAVE_RGBA) {
+ VERT_RESTORE_RGBA(0);
+ VERT_RESTORE_RGBA(1);
+ VERT_RESTORE_RGBA(2);
+
+ if (HAVE_SPEC) {
+ VERT_RESTORE_SPEC(0);
+ VERT_RESTORE_SPEC(1);
+ VERT_RESTORE_SPEC(2);
+ }
+ } else {
+ VERT_RESTORE_IND(0);
+ VERT_RESTORE_IND(1);
+ VERT_RESTORE_IND(2);
+ }
+ }
+}
+
+
+#if HAVE_RGBA
+#undef VERT_SET_IND
+#undef VERT_COPY_IND
+#undef VERT_SAVE_IND
+#undef VERT_RESTORE_IND
+#endif
+
+#if !HAVE_SPEC
+#undef VERT_SET_SPEC
+#undef VERT_COPY_SPEC
+#undef VERT_SAVE_SPEC
+#undef VERT_RESTORE_SPEC
+#endif
+
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_vb.c b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_vb.c
new file mode 100644
index 000000000..edd78f7ac
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_vb.c
@@ -0,0 +1,344 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+#include "math/m_translate.h"
+
+#if (HAVE_HW_VIEWPORT)
+#define UNVIEWPORT_VARS
+#define UNVIEWPORT_X(x) x
+#define UNVIEWPORT_Y(x) x
+#define UNVIEWPORT_Z(x) x
+#endif
+
+#ifndef LOCALVARS
+#define LOCALVARS
+#endif
+
+#ifndef CHECK_HW_DIVIDE
+#define CHECK_HW_DIVIDE 1
+#endif
+
+/* These don't need to be duplicated, but there's currently nowhere
+ * really convenient to put them. Need to build some actual .o files in
+ * this directory?
+ */
+static void copy_pv_rgba4_spec5( GLcontext *ctx, GLuint edst, GLuint esrc )
+{
+ LOCALVARS
+ GLubyte *verts = GET_VERTEX_STORE();
+ GLuint size = GET_VERTEX_SIZE();
+ GLuint *dst = (GLuint *)(verts + (edst * size));
+ GLuint *src = (GLuint *)(verts + (esrc * size));
+ dst[4] = src[4];
+ dst[5] = src[5];
+}
+
+static void copy_pv_rgba4( GLcontext *ctx, GLuint edst, GLuint esrc )
+{
+ LOCALVARS
+ GLubyte *verts = GET_VERTEX_STORE();
+ GLuint size = GET_VERTEX_SIZE();
+ GLuint *dst = (GLuint *)(verts + (edst * size));
+ GLuint *src = (GLuint *)(verts + (esrc * size));
+ dst[4] = src[4];
+}
+
+static void copy_pv_rgba3( GLcontext *ctx, GLuint edst, GLuint esrc )
+{
+ LOCALVARS
+ GLubyte *verts = GET_VERTEX_STORE();
+ GLuint size = GET_VERTEX_SIZE();
+ GLuint *dst = (GLuint *)(verts + (edst * size));
+ GLuint *src = (GLuint *)(verts + (esrc * size));
+ dst[3] = src[3];
+}
+
+
+void TAG(translate_vertex)(GLcontext *ctx,
+ const VERTEX *src,
+ SWvertex *dst)
+{
+ LOCALVARS
+ GLuint format = GET_VERTEX_FORMAT();
+ GLfloat *s = ctx->Viewport._WindowMap.m;
+ UNVIEWPORT_VARS;
+
+ if (format == TINY_VERTEX_FORMAT) {
+ if (HAVE_HW_VIEWPORT) {
+ dst->win[0] = s[0] * src->v.x + s[12];
+ dst->win[1] = s[5] * src->v.y + s[13];
+ dst->win[2] = s[10] * src->v.z + s[14];
+ dst->win[3] = 1.0;
+ } else {
+ dst->win[0] = UNVIEWPORT_X( src->v.x );
+ dst->win[1] = UNVIEWPORT_Y( src->v.y );
+ dst->win[2] = UNVIEWPORT_Z( src->v.z );
+ dst->win[3] = 1.0;
+ }
+
+ dst->color[0] = src->tv.color.red;
+ dst->color[1] = src->tv.color.green;
+ dst->color[2] = src->tv.color.blue;
+ dst->color[3] = src->tv.color.alpha;
+ }
+ else {
+ if (HAVE_HW_VIEWPORT) {
+ if (HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) {
+ GLfloat oow = 1.0 / src->v.w;
+ dst->win[0] = s[0] * src->v.x * oow + s[12];
+ dst->win[1] = s[5] * src->v.y * oow + s[13];
+ dst->win[2] = s[10] * src->v.z * oow + s[14];
+ dst->win[3] = oow;
+ } else {
+ dst->win[0] = s[0] * src->v.x + s[12];
+ dst->win[1] = s[5] * src->v.y + s[13];
+ dst->win[2] = s[10] * src->v.z + s[14];
+ dst->win[3] = src->v.w;
+ }
+ } else {
+ dst->win[0] = UNVIEWPORT_X( src->v.x );
+ dst->win[1] = UNVIEWPORT_Y( src->v.y );
+ dst->win[2] = UNVIEWPORT_Z( src->v.z );
+ dst->win[3] = src->v.w;
+ }
+
+ dst->color[0] = src->v.color.red;
+ dst->color[1] = src->v.color.green;
+ dst->color[2] = src->v.color.blue;
+ dst->color[3] = src->v.color.alpha;
+
+ dst->specular[0] = src->v.specular.red;
+ dst->specular[1] = src->v.specular.green;
+ dst->specular[2] = src->v.specular.blue;
+
+ dst->fog = src->v.specular.alpha/255.0;
+
+ if (HAVE_PTEX_VERTICES &&
+ ((HAVE_TEX2_VERTICES && format == PROJ_TEX3_VERTEX_FORMAT) ||
+ (format == PROJ_TEX1_VERTEX_FORMAT))) {
+
+ dst->texcoord[0][0] = src->pv.u0;
+ dst->texcoord[0][1] = src->pv.v0;
+ dst->texcoord[0][3] = src->pv.q0;
+
+ dst->texcoord[1][0] = src->pv.u1;
+ dst->texcoord[1][1] = src->pv.v1;
+ dst->texcoord[1][3] = src->pv.q1;
+
+ if (HAVE_TEX2_VERTICES) {
+ dst->texcoord[2][0] = src->pv.u2;
+ dst->texcoord[2][1] = src->pv.v2;
+ dst->texcoord[2][3] = src->pv.q2;
+ }
+
+ if (HAVE_TEX3_VERTICES) {
+ dst->texcoord[3][0] = src->pv.u3;
+ dst->texcoord[3][1] = src->pv.v3;
+ dst->texcoord[3][3] = src->pv.q3;
+ }
+ }
+ else {
+ dst->texcoord[0][0] = src->v.u0;
+ dst->texcoord[0][1] = src->v.v0;
+ dst->texcoord[0][3] = 1.0;
+
+ dst->texcoord[1][0] = src->v.u1;
+ dst->texcoord[1][1] = src->v.v1;
+ dst->texcoord[1][3] = 1.0;
+
+ if (HAVE_TEX2_VERTICES) {
+ dst->texcoord[2][0] = src->v.u2;
+ dst->texcoord[2][1] = src->v.v2;
+ dst->texcoord[2][3] = 1.0;
+ }
+
+ if (HAVE_TEX3_VERTICES) {
+ dst->texcoord[3][0] = src->v.u3;
+ dst->texcoord[3][1] = src->v.v3;
+ dst->texcoord[3][3] = 1.0;
+ }
+ }
+ }
+
+ dst->pointSize = ctx->Point._Size;
+}
+
+
+
+void TAG(print_vertex)( GLcontext *ctx, const VERTEX *v )
+{
+ LOCALVARS
+ GLuint format = GET_VERTEX_FORMAT();
+
+ fprintf(stderr, "(%x) ", format);
+
+ switch (format) {
+#if HAVE_TINY_VERTICES
+ case TINY_VERTEX_FORMAT:
+ fprintf(stderr, "xyz %.4f,%.4f,%.4f rgba %x:%x:%x:%x\n",
+ v->v.x, v->v.y, v->v.z,
+ v->tv.color.red,
+ v->tv.color.green,
+ v->tv.color.blue,
+ v->tv.color.alpha);
+ break;
+#endif
+#if HAVE_NOTEX_VERTICES
+ case NOTEX_VERTEX_FORMAT:
+ fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x spec %x:%x:%x:%x\n",
+ v->v.x, v->v.y, v->v.z, v->v.w,
+ v->v.color.red,
+ v->v.color.green,
+ v->v.color.blue,
+ v->v.color.alpha,
+ v->v.specular.red,
+ v->v.specular.green,
+ v->v.specular.blue,
+ v->v.specular.alpha);
+ break;
+#endif
+#if HAVE_TEX0_VERTICES
+ case TEX0_VERTEX_FORMAT:
+ fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x st %.4f,%.4f\n",
+ v->v.x, v->v.y, v->v.z, v->v.w,
+ v->v.color.red,
+ v->v.color.green,
+ v->v.color.blue,
+ v->v.color.alpha,
+ v->v.u0,
+ v->v.v0);
+ break;
+#endif
+#if HAVE_TEX1_VERTICES
+ case TEX1_VERTEX_FORMAT:
+ fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x st %.4f,%.4f st %.4f,%.4f\n",
+ v->v.x, v->v.y, v->v.z, v->v.w,
+ v->v.color.red,
+ v->v.color.green,
+ v->v.color.blue,
+ v->v.color.alpha,
+ v->v.u0,
+ v->v.v0,
+ v->v.u1,
+ v->v.u2);
+ break;
+#endif
+#if HAVE_PTEX_VERTICES
+ case PROJ_TEX1_VERTEX_FORMAT:
+ fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x stq %.4f,%.4f,%.4f stq %.4f,%.4f,%.4f\n",
+ v->v.x, v->v.y, v->v.z, v->v.w,
+ v->v.color.red,
+ v->v.color.green,
+ v->v.color.blue,
+ v->v.color.alpha,
+ v->pv.u0,
+ v->pv.v0,
+ v->pv.q0,
+ v->pv.u1,
+ v->pv.v1,
+ v->pv.q1);
+ break;
+#endif
+ default:
+ fprintf(stderr, "???\n");
+ break;
+ }
+
+ fprintf(stderr, "\n");
+}
+
+
+
+/* Interpolate the elements of the VB not included in typical hardware
+ * vertices.
+ *
+ * NOTE: All these arrays are guarenteed by tnl to be writeable and
+ * have good stride.
+ */
+#ifndef INTERP_QUALIFIER
+#define INTERP_QUALIFIER static
+#endif
+
+#define GET_COLOR(ptr, idx) ((ptr)->data[idx])
+
+
+INTERP_QUALIFIER void TAG(interp_extras)( GLcontext *ctx,
+ GLfloat t,
+ GLuint dst, GLuint out, GLuint in,
+ GLboolean force_boundary )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ if (VB->ColorPtr[1]) {
+ assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat));
+
+ INTERP_4F( t,
+ GET_COLOR(VB->ColorPtr[1], dst),
+ GET_COLOR(VB->ColorPtr[1], out),
+ GET_COLOR(VB->ColorPtr[1], in) );
+
+ if (VB->SecondaryColorPtr[1]) {
+ INTERP_3F( t,
+ GET_COLOR(VB->SecondaryColorPtr[1], dst),
+ GET_COLOR(VB->SecondaryColorPtr[1], out),
+ GET_COLOR(VB->SecondaryColorPtr[1], in) );
+ }
+ }
+
+ if (VB->EdgeFlag) {
+ VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
+ }
+
+ INTERP_VERTEX(ctx, t, dst, out, in, force_boundary);
+}
+
+INTERP_QUALIFIER void TAG(copy_pv_extras)( GLcontext *ctx,
+ GLuint dst, GLuint src )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ if (VB->ColorPtr[1]) {
+ COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst),
+ GET_COLOR(VB->ColorPtr[1], src) );
+
+ if (VB->SecondaryColorPtr[1]) {
+ COPY_4FV( GET_COLOR(VB->SecondaryColorPtr[1], dst),
+ GET_COLOR(VB->SecondaryColorPtr[1], src) );
+ }
+ }
+
+ COPY_PV_VERTEX(ctx, dst, src);
+}
+
+
+#undef INTERP_QUALIFIER
+#undef GET_COLOR
+
+#undef IND
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_vbtmp.h b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_vbtmp.h
new file mode 100644
index 000000000..92dd8931c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_vbtmp.h
@@ -0,0 +1,675 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.0.1
+ *
+ * Copyright (C) 1999-2003 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+
+/* Unlike the other templates here, this assumes quite a bit about the
+ * underlying hardware. Specifically it assumes a d3d-like vertex
+ * format, with a layout more or less constrained to look like the
+ * following:
+ *
+ * union {
+ * struct {
+ * float x, y, z, w;
+ * struct { char r, g, b, a; } color;
+ * struct { char r, g, b, fog; } spec;
+ * float u0, v0;
+ * float u1, v1;
+ * float u2, v2;
+ * float u3, v3;
+ * } v;
+ * struct {
+ * float x, y, z, w;
+ * struct { char r, g, b, a; } color;
+ * struct { char r, g, b, fog; } spec;
+ * float u0, v0, q0;
+ * float u1, v1, q1;
+ * float u2, v2, q2;
+ * float u3, v3, q3;
+ * } pv;
+ * struct {
+ * float x, y, z;
+ * struct { char r, g, b, a; } color;
+ * } tv;
+ * float f[16];
+ * unsigned int ui[16];
+ * unsigned char ub4[4][16];
+ * }
+ *
+
+ * VERTEX: hw vertex type as above
+ * VERTEX_COLOR: hw color struct type in VERTEX
+ *
+ * DO_XYZW: Emit xyz and maybe w coordinates.
+ * DO_RGBA: Emit color.
+ * DO_SPEC: Emit specular color.
+ * DO_FOG: Emit fog coordinate in specular alpha.
+ * DO_TEX0: Emit tex0 u,v coordinates.
+ * DO_TEX1: Emit tex1 u,v coordinates.
+ * DO_TEX2: Emit tex2 u,v coordinates.
+ * DO_TEX3: Emit tex3 u,v coordinates.
+ * DO_PTEX: Emit tex0,1,2,3 q coordinates where possible.
+ *
+ * HAVE_RGBA_COLOR: Hardware takes color in rgba order (else bgra).
+ *
+ * HAVE_HW_VIEWPORT: Hardware performs viewport transform.
+ * HAVE_HW_DIVIDE: Hardware performs perspective divide.
+ *
+ * HAVE_TINY_VERTICES: Hardware understands v.tv format.
+ * HAVE_PTEX_VERTICES: Hardware understands v.pv format.
+ * HAVE_NOTEX_VERTICES: Hardware understands v.v format with texcount 0.
+ *
+ * Additionally, this template assumes it is emitting *transformed*
+ * vertices; the modifications to emit untransformed vertices (ie. to
+ * t&l hardware) are probably too great to cooexist with the code
+ * already in this file.
+ *
+ * NOTE: The PTEX vertex format always includes TEX0 and TEX1, even if
+ * only TEX0 is enabled, in order to maintain a vertex size which is
+ * an exact number of quadwords.
+ */
+
+#if (HAVE_HW_VIEWPORT)
+#define VIEWPORT_X(dst,x) dst = x
+#define VIEWPORT_Y(dst,y) dst = y
+#define VIEWPORT_Z(dst,z) dst = z
+#else
+#define VIEWPORT_X(dst,x) dst = s[0] * x + s[12]
+#define VIEWPORT_Y(dst,y) dst = s[5] * y + s[13]
+#define VIEWPORT_Z(dst,z) dst = s[10] * z + s[14]
+#endif
+
+#if (HAVE_HW_DIVIDE && !HAVE_PTEX_VERTICES)
+#error "can't cope with this combination"
+#endif
+
+#ifndef LOCALVARS
+#define LOCALVARS
+#endif
+
+#ifndef CHECK_HW_DIVIDE
+#define CHECK_HW_DIVIDE 1
+#endif
+
+#if (HAVE_HW_DIVIDE || DO_SPEC || DO_TEX0 || DO_FOG || !HAVE_TINY_VERTICES)
+
+static void TAG(emit)( GLcontext *ctx,
+ GLuint start, GLuint end,
+ void *dest,
+ GLuint stride )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLfloat (*tc0)[4], (*tc1)[4], (*fog)[4];
+ GLfloat (*tc2)[4], (*tc3)[4];
+ GLfloat (*col)[4], (*spec)[4];
+ GLuint tc0_stride, tc1_stride, col_stride, spec_stride, fog_stride;
+ GLuint tc2_stride, tc3_stride;
+ GLuint tc0_size, tc1_size, col_size;
+ GLuint tc2_size, tc3_size;
+ GLfloat (*coord)[4];
+ GLuint coord_stride;
+ VERTEX *v = (VERTEX *)dest;
+ const GLfloat *s = GET_VIEWPORT_MAT();
+ const GLubyte *mask = VB->ClipMask;
+ int i;
+
+/* fprintf(stderr, "%s(big) importable %d %d..%d\n", */
+/* __FUNCTION__, VB->importable_data, start, end); */
+
+ if (HAVE_HW_VIEWPORT && HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) {
+ (void) s;
+ coord = VB->ClipPtr->data;
+ coord_stride = VB->ClipPtr->stride;
+ }
+ else {
+ coord = VB->NdcPtr->data;
+ coord_stride = VB->NdcPtr->stride;
+ }
+
+ if (DO_TEX3) {
+ const GLuint t3 = GET_TEXSOURCE(3);
+ tc3 = VB->TexCoordPtr[t3]->data;
+ tc3_stride = VB->TexCoordPtr[t3]->stride;
+ if (DO_PTEX)
+ tc3_size = VB->TexCoordPtr[t3]->size;
+ }
+
+ if (DO_TEX2) {
+ const GLuint t2 = GET_TEXSOURCE(2);
+ tc2 = VB->TexCoordPtr[t2]->data;
+ tc2_stride = VB->TexCoordPtr[t2]->stride;
+ if (DO_PTEX)
+ tc2_size = VB->TexCoordPtr[t2]->size;
+ }
+
+ if (DO_TEX1) {
+ const GLuint t1 = GET_TEXSOURCE(1);
+ tc1 = VB->TexCoordPtr[t1]->data;
+ tc1_stride = VB->TexCoordPtr[t1]->stride;
+ if (DO_PTEX)
+ tc1_size = VB->TexCoordPtr[t1]->size;
+ }
+
+ if (DO_TEX0) {
+ const GLuint t0 = GET_TEXSOURCE(0);
+ tc0_stride = VB->TexCoordPtr[t0]->stride;
+ tc0 = VB->TexCoordPtr[t0]->data;
+ if (DO_PTEX)
+ tc0_size = VB->TexCoordPtr[t0]->size;
+ }
+
+ if (DO_RGBA) {
+ col_stride = VB->ColorPtr[0]->stride;
+ col = VB->ColorPtr[0]->data;
+ col_size = VB->ColorPtr[0]->size;
+ }
+
+ if (DO_SPEC) {
+ if (VB->SecondaryColorPtr[0]) {
+ spec_stride = VB->SecondaryColorPtr[0]->stride;
+ spec = VB->SecondaryColorPtr[0]->data;
+ } else {
+ spec = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
+ spec_stride = 0;
+ }
+ }
+
+ if (DO_FOG) {
+ if (VB->FogCoordPtr) {
+ fog = VB->FogCoordPtr->data;
+ fog_stride = VB->FogCoordPtr->stride;
+ }
+ else {
+ static GLfloat tmp[4] = {0, 0, 0, 0};
+ fog = &tmp;
+ fog_stride = 0;
+ }
+ }
+
+ /* May have nonstandard strides:
+ */
+ if (start) {
+ STRIDE_4F(coord, start * coord_stride);
+ if (DO_TEX0)
+ STRIDE_4F(tc0, start * tc0_stride);
+ if (DO_TEX1)
+ STRIDE_4F(tc1, start * tc1_stride);
+ if (DO_TEX2)
+ STRIDE_4F(tc2, start * tc2_stride);
+ if (DO_TEX3)
+ STRIDE_4F(tc3, start * tc3_stride);
+ if (DO_RGBA)
+ STRIDE_4F(col, start * col_stride);
+ if (DO_SPEC)
+ STRIDE_4F(spec, start * spec_stride);
+ if (DO_FOG)
+ STRIDE_4F(fog, start * fog_stride);
+ }
+
+ for (i=start; i < end; i++, v = (VERTEX *)((GLubyte *)v + stride)) {
+ if (DO_XYZW) {
+ if (HAVE_HW_VIEWPORT || mask[i] == 0) {
+ VIEWPORT_X(v->v.x, coord[0][0]);
+ VIEWPORT_Y(v->v.y, coord[0][1]);
+ VIEWPORT_Z(v->v.z, coord[0][2]);
+ v->v.w = coord[0][3];
+ }
+ STRIDE_4F(coord, coord_stride);
+ }
+ if (DO_RGBA) {
+ UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.red, col[0][0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.green, col[0][1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.blue, col[0][2]);
+ if (col_size == 4) {
+ UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.alpha, col[0][3]);
+ } else {
+ v->v.color.alpha = CHAN_MAX;
+ }
+ STRIDE_4F(col, col_stride);
+ }
+ if (DO_SPEC) {
+ UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.red, spec[0][0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.green, spec[0][1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.blue, spec[0][2]);
+ STRIDE_4F(spec, spec_stride);
+ }
+ if (DO_FOG) {
+ UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.alpha, fog[0][0]);
+ STRIDE_4F(fog, fog_stride);
+ }
+ if (DO_TEX0) {
+ v->v.u0 = tc0[0][0];
+ v->v.v0 = tc0[0][1];
+ if (DO_PTEX) {
+ if (HAVE_PTEX_VERTICES) {
+ if (tc0_size == 4)
+ v->pv.q0 = tc0[0][3];
+ else
+ v->pv.q0 = 1.0;
+ }
+ else if (tc0_size == 4) {
+ float rhw = 1.0 / tc0[0][3];
+ v->v.w *= tc0[0][3];
+ v->v.u0 *= rhw;
+ v->v.v0 *= rhw;
+ }
+ }
+ STRIDE_4F(tc0, tc0_stride);
+ }
+ if (DO_TEX1) {
+ if (DO_PTEX) {
+ v->pv.u1 = tc1[0][0];
+ v->pv.v1 = tc1[0][1];
+ if (tc1_size == 4)
+ v->pv.q1 = tc1[0][3];
+ else
+ v->pv.q1 = 1.0;
+ }
+ else {
+ v->v.u1 = tc1[0][0];
+ v->v.v1 = tc1[0][1];
+ }
+ STRIDE_4F(tc1, tc1_stride);
+ }
+ else if (DO_PTEX) {
+ *(GLuint *)&v->pv.q1 = 0; /* avoid culling on radeon */
+ }
+ if (DO_TEX2) {
+ if (DO_PTEX) {
+ v->pv.u2 = tc2[0][0];
+ v->pv.v2 = tc2[0][1];
+ if (tc2_size == 4)
+ v->pv.q2 = tc2[0][3];
+ else
+ v->pv.q2 = 1.0;
+ }
+ else {
+ v->v.u2 = tc2[0][0];
+ v->v.v2 = tc2[0][1];
+ }
+ STRIDE_4F(tc2, tc2_stride);
+ }
+ if (DO_TEX3) {
+ if (DO_PTEX) {
+ v->pv.u3 = tc3[0][0];
+ v->pv.v3 = tc3[0][1];
+ if (tc3_size == 4)
+ v->pv.q3 = tc3[0][3];
+ else
+ v->pv.q3 = 1.0;
+ }
+ else {
+ v->v.u3 = tc3[0][0];
+ v->v.v3 = tc3[0][1];
+ }
+ STRIDE_4F(tc3, tc3_stride);
+ }
+ }
+
+}
+#else
+
+#if HAVE_HW_DIVIDE
+#error "cannot use tiny vertices with hw perspective divide"
+#endif
+
+static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
+ void *dest, GLuint stride )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLfloat (*col)[4];
+ GLuint col_stride, col_size;
+ GLfloat (*coord)[4] = VB->NdcPtr->data;
+ GLuint coord_stride = VB->NdcPtr->stride;
+ GLfloat *v = (GLfloat *)dest;
+ const GLubyte *mask = VB->ClipMask;
+ const GLfloat *s = GET_VIEWPORT_MAT();
+ int i;
+
+ (void) s;
+
+ ASSERT(stride == 4);
+
+ col = VB->ColorPtr[0]->data;
+ col_stride = VB->ColorPtr[0]->stride;
+ col_size = VB->ColorPtr[0]->size;
+
+/* fprintf(stderr, "%s(small) importable %x\n", */
+/* __FUNCTION__, VB->importable_data); */
+
+ /* Pack what's left into a 4-dword vertex. Color is in a different
+ * place, and there is no 'w' coordinate.
+ */
+ if (start) {
+ STRIDE_4F(coord, start * coord_stride);
+ STRIDE_4F(col, start * col_stride);
+ }
+
+ for (i=start; i < end; i++, v+=4) {
+ if (DO_XYZW) {
+ if (HAVE_HW_VIEWPORT || mask[i] == 0) {
+ VIEWPORT_X(v[0], coord[0][0]);
+ VIEWPORT_Y(v[1], coord[0][1]);
+ VIEWPORT_Z(v[2], coord[0][2]);
+ }
+ STRIDE_4F( coord, coord_stride );
+ }
+ if (DO_RGBA) {
+ VERTEX_COLOR *c = (VERTEX_COLOR *)&v[3];
+ UNCLAMPED_FLOAT_TO_UBYTE(c->red, col[0][0]);
+ UNCLAMPED_FLOAT_TO_UBYTE(c->green, col[0][1]);
+ UNCLAMPED_FLOAT_TO_UBYTE(c->blue, col[0][2]);
+ if (col_size == 4) {
+ UNCLAMPED_FLOAT_TO_UBYTE(c->alpha, col[0][3]);
+ } else {
+ c->alpha = CHAN_MAX;
+ }
+ STRIDE_4F( col, col_stride );
+ }
+/* fprintf(stderr, "vert %d: %.2f %.2f %.2f %x\n", */
+/* i, v[0], v[1], v[2], *(int *)&v[3]); */
+ }
+}
+
+#endif /* emit */
+
+#if (DO_XYZW) && (DO_RGBA)
+
+
+#if (HAVE_PTEX_VERTICES)
+static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ /* Force 'missing' texcoords to something valid.
+ */
+ if (DO_TEX3 && VB->TexCoordPtr[2] == 0)
+ VB->TexCoordPtr[2] = VB->TexCoordPtr[3];
+
+ if (DO_TEX2 && VB->TexCoordPtr[1] == 0)
+ VB->TexCoordPtr[1] = VB->TexCoordPtr[2];
+
+ if (DO_TEX1 && VB->TexCoordPtr[0] == 0)
+ VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
+
+ if (DO_PTEX)
+ return GL_TRUE;
+
+ if ((DO_TEX3 && VB->TexCoordPtr[GET_TEXSOURCE(3)]->size == 4) ||
+ (DO_TEX2 && VB->TexCoordPtr[GET_TEXSOURCE(2)]->size == 4) ||
+ (DO_TEX1 && VB->TexCoordPtr[GET_TEXSOURCE(1)]->size == 4) ||
+ (DO_TEX0 && VB->TexCoordPtr[GET_TEXSOURCE(0)]->size == 4))
+ return GL_FALSE;
+
+ return GL_TRUE;
+}
+#else
+static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ /* Force 'missing' texcoords to something valid.
+ */
+ if (DO_TEX3 && VB->TexCoordPtr[2] == 0)
+ VB->TexCoordPtr[2] = VB->TexCoordPtr[3];
+
+ if (DO_TEX2 && VB->TexCoordPtr[1] == 0)
+ VB->TexCoordPtr[1] = VB->TexCoordPtr[2];
+
+ if (DO_TEX1 && VB->TexCoordPtr[0] == 0)
+ VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
+
+ if (DO_PTEX)
+ return GL_TRUE;
+
+ /* No hardware support for projective texture. Can fake it for
+ * TEX0 only.
+ */
+ if ((DO_TEX3 && VB->TexCoordPtr[GET_TEXSOURCE(3)]->size == 4) ||
+ (DO_TEX2 && VB->TexCoordPtr[GET_TEXSOURCE(2)]->size == 4) ||
+ (DO_TEX1 && VB->TexCoordPtr[GET_TEXSOURCE(1)]->size == 4)) {
+ PTEX_FALLBACK();
+ return GL_FALSE;
+ }
+
+ if (DO_TEX0 && VB->TexCoordPtr[GET_TEXSOURCE(0)]->size == 4) {
+ if (DO_TEX1 || DO_TEX2 || DO_TEX3) {
+ PTEX_FALLBACK();
+ }
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+#endif /* ptex */
+
+
+static void TAG(interp)( GLcontext *ctx,
+ GLfloat t,
+ GLuint edst, GLuint eout, GLuint ein,
+ GLboolean force_boundary )
+{
+ LOCALVARS
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ GLubyte *ddverts = GET_VERTEX_STORE();
+ GLuint size = GET_VERTEX_SIZE();
+ const GLfloat *dstclip = VB->ClipPtr->data[edst];
+ GLfloat w;
+ const GLfloat *s = GET_VIEWPORT_MAT();
+
+ VERTEX *dst = (VERTEX *)(ddverts + (edst * size));
+ VERTEX *in = (VERTEX *)(ddverts + (ein * size));
+ VERTEX *out = (VERTEX *)(ddverts + (eout * size));
+
+ (void)s;
+
+ if (HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) {
+ VIEWPORT_X( dst->v.x, dstclip[0] );
+ VIEWPORT_Y( dst->v.y, dstclip[1] );
+ VIEWPORT_Z( dst->v.z, dstclip[2] );
+ w = dstclip[3];
+ }
+ else {
+ w = 1.0 / dstclip[3];
+ VIEWPORT_X( dst->v.x, dstclip[0] * w );
+ VIEWPORT_Y( dst->v.y, dstclip[1] * w );
+ VIEWPORT_Z( dst->v.z, dstclip[2] * w );
+ }
+
+ if ((HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) ||
+ DO_FOG || DO_SPEC || DO_TEX0 || DO_TEX1 ||
+ DO_TEX2 || DO_TEX3 || !HAVE_TINY_VERTICES) {
+
+ dst->v.w = w;
+
+ INTERP_UB( t, dst->ub4[4][0], out->ub4[4][0], in->ub4[4][0] );
+ INTERP_UB( t, dst->ub4[4][1], out->ub4[4][1], in->ub4[4][1] );
+ INTERP_UB( t, dst->ub4[4][2], out->ub4[4][2], in->ub4[4][2] );
+ INTERP_UB( t, dst->ub4[4][3], out->ub4[4][3], in->ub4[4][3] );
+
+ if (DO_SPEC) {
+ INTERP_UB( t, dst->v.specular.red, out->v.specular.red, in->v.specular.red );
+ INTERP_UB( t, dst->v.specular.green, out->v.specular.green, in->v.specular.green );
+ INTERP_UB( t, dst->v.specular.blue, out->v.specular.blue, in->v.specular.blue );
+ }
+ if (DO_FOG) {
+ INTERP_UB( t, dst->v.specular.alpha, out->v.specular.alpha, in->v.specular.alpha );
+ }
+ if (DO_TEX0) {
+ if (DO_PTEX) {
+ if (HAVE_PTEX_VERTICES) {
+ INTERP_F( t, dst->pv.u0, out->pv.u0, in->pv.u0 );
+ INTERP_F( t, dst->pv.v0, out->pv.v0, in->pv.v0 );
+ INTERP_F( t, dst->pv.q0, out->pv.q0, in->pv.q0 );
+ } else {
+ GLfloat wout = VB->NdcPtr->data[eout][3];
+ GLfloat win = VB->NdcPtr->data[ein][3];
+ GLfloat qout = out->pv.w / wout;
+ GLfloat qin = in->pv.w / win;
+ GLfloat qdst, rqdst;
+
+ ASSERT( !HAVE_HW_DIVIDE );
+
+ INTERP_F( t, dst->v.u0, out->v.u0 * qout, in->v.u0 * qin );
+ INTERP_F( t, dst->v.v0, out->v.v0 * qout, in->v.v0 * qin );
+ INTERP_F( t, qdst, qout, qin );
+
+ rqdst = 1.0 / qdst;
+ dst->v.u0 *= rqdst;
+ dst->v.v0 *= rqdst;
+ dst->v.w *= rqdst;
+ }
+ }
+ else {
+ INTERP_F( t, dst->v.u0, out->v.u0, in->v.u0 );
+ INTERP_F( t, dst->v.v0, out->v.v0, in->v.v0 );
+ }
+ }
+ if (DO_TEX1) {
+ if (DO_PTEX) {
+ INTERP_F( t, dst->pv.u1, out->pv.u1, in->pv.u1 );
+ INTERP_F( t, dst->pv.v1, out->pv.v1, in->pv.v1 );
+ INTERP_F( t, dst->pv.q1, out->pv.q1, in->pv.q1 );
+ } else {
+ INTERP_F( t, dst->v.u1, out->v.u1, in->v.u1 );
+ INTERP_F( t, dst->v.v1, out->v.v1, in->v.v1 );
+ }
+ }
+ else if (DO_PTEX) {
+ dst->pv.q1 = 0.0; /* must be a valid float on radeon */
+ }
+ if (DO_TEX2) {
+ if (DO_PTEX) {
+ INTERP_F( t, dst->pv.u2, out->pv.u2, in->pv.u2 );
+ INTERP_F( t, dst->pv.v2, out->pv.v2, in->pv.v2 );
+ INTERP_F( t, dst->pv.q2, out->pv.q2, in->pv.q2 );
+ } else {
+ INTERP_F( t, dst->v.u2, out->v.u2, in->v.u2 );
+ INTERP_F( t, dst->v.v2, out->v.v2, in->v.v2 );
+ }
+ }
+ if (DO_TEX3) {
+ if (DO_PTEX) {
+ INTERP_F( t, dst->pv.u3, out->pv.u3, in->pv.u3 );
+ INTERP_F( t, dst->pv.v3, out->pv.v3, in->pv.v3 );
+ INTERP_F( t, dst->pv.q3, out->pv.q3, in->pv.q3 );
+ } else {
+ INTERP_F( t, dst->v.u3, out->v.u3, in->v.u3 );
+ INTERP_F( t, dst->v.v3, out->v.v3, in->v.v3 );
+ }
+ }
+ } else {
+ /* 4-dword vertex. Color is in v[3] and there is no oow coordinate.
+ */
+ INTERP_UB( t, dst->ub4[3][0], out->ub4[3][0], in->ub4[3][0] );
+ INTERP_UB( t, dst->ub4[3][1], out->ub4[3][1], in->ub4[3][1] );
+ INTERP_UB( t, dst->ub4[3][2], out->ub4[3][2], in->ub4[3][2] );
+ INTERP_UB( t, dst->ub4[3][3], out->ub4[3][3], in->ub4[3][3] );
+ }
+}
+
+#endif /* rgba && xyzw */
+
+
+static void TAG(init)( void )
+{
+ setup_tab[IND].emit = TAG(emit);
+
+#if (DO_XYZW && DO_RGBA)
+ setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes);
+ setup_tab[IND].interp = TAG(interp);
+#endif
+
+ if (DO_SPEC)
+ setup_tab[IND].copy_pv = copy_pv_rgba4_spec5;
+ else if (HAVE_HW_DIVIDE || DO_SPEC || DO_FOG || DO_TEX0 || DO_TEX1 ||
+ DO_TEX2 || DO_TEX3 || !HAVE_TINY_VERTICES)
+ setup_tab[IND].copy_pv = copy_pv_rgba4;
+ else
+ setup_tab[IND].copy_pv = copy_pv_rgba3;
+
+ if (DO_TEX3) {
+ if (DO_PTEX) {
+ ASSERT(HAVE_PTEX_VERTICES);
+ setup_tab[IND].vertex_format = PROJ_TEX3_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 18;
+ }
+ else {
+ setup_tab[IND].vertex_format = TEX3_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 14;
+ }
+ }
+ else if (DO_TEX2) {
+ if (DO_PTEX) {
+ ASSERT(HAVE_PTEX_VERTICES);
+ setup_tab[IND].vertex_format = PROJ_TEX3_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 18;
+ }
+ else {
+ setup_tab[IND].vertex_format = TEX2_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 12;
+ }
+ }
+ else if (DO_TEX1) {
+ if (DO_PTEX) {
+ ASSERT(HAVE_PTEX_VERTICES);
+ setup_tab[IND].vertex_format = PROJ_TEX1_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 12;
+ }
+ else {
+ setup_tab[IND].vertex_format = TEX1_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 10;
+ }
+ }
+ else if (DO_TEX0) {
+ if (DO_PTEX && HAVE_PTEX_VERTICES) {
+ setup_tab[IND].vertex_format = PROJ_TEX1_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 12;
+ } else {
+ setup_tab[IND].vertex_format = TEX0_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 8;
+ }
+ }
+ else if (!HAVE_HW_DIVIDE && !DO_SPEC && !DO_FOG && HAVE_TINY_VERTICES) {
+ setup_tab[IND].vertex_format = TINY_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 4;
+ } else if (HAVE_NOTEX_VERTICES) {
+ setup_tab[IND].vertex_format = NOTEX_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 6;
+ } else {
+ setup_tab[IND].vertex_format = TEX0_VERTEX_FORMAT;
+ setup_tab[IND].vertex_size = 8;
+ }
+}
+
+
+#undef IND
+#undef TAG
diff --git a/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_vertex.h b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_vertex.h
new file mode 100644
index 000000000..d45dd09fb
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/tnl_dd/t_dd_vertex.h
@@ -0,0 +1,78 @@
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 4.0.3
+ *
+ * Copyright (C) 1999-2002 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.
+ *
+ * Authors:
+ * Keith Whitwell <keith@tungstengraphics.com>
+ */
+
+typedef struct {
+ GLfloat x, y, z, w;
+} TAG(_coord_t);
+
+#ifdef COLOR_IS_RGBA
+typedef struct {
+#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
+ GLubyte alpha, blue, green, red;
+#else
+ GLubyte red, green, blue, alpha;
+#endif
+} TAG(_color_t);
+#else
+typedef struct {
+#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
+ GLubyte alpha, red, green, blue;
+#else
+ GLubyte blue, green, red, alpha;
+#endif
+} TAG(_color_t);
+#endif
+
+typedef union {
+ struct {
+ GLfloat x, y, z, w;
+ TAG(_color_t) color;
+ TAG(_color_t) specular;
+ GLfloat u0, v0;
+ GLfloat u1, v1;
+ GLfloat u2, v2;
+ GLfloat u3, v3;
+ } v;
+ struct {
+ GLfloat x, y, z, w;
+ TAG(_color_t) color;
+ TAG(_color_t) specular;
+ GLfloat u0, v0, q0;
+ GLfloat u1, v1, q1;
+ GLfloat u2, v2, q2;
+ GLfloat u3, v3, q3;
+ } pv;
+ struct {
+ GLfloat x, y, z;
+ TAG(_color_t) color;
+ } tv;
+ GLfloat f[24];
+ GLuint ui[24];
+ GLubyte ub4[24][4];
+} TAG(Vertex), *TAG(VertexPtr);
+
diff --git a/nx-X11/extras/Mesa/src/mesa/x86-64/Makefile b/nx-X11/extras/Mesa/src/mesa/x86-64/Makefile
new file mode 100644
index 000000000..252218ca8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86-64/Makefile
@@ -0,0 +1,29 @@
+# src/mesa/x86-64/Makefile
+
+TOP = ../../..
+
+include $(TOP)/configs/current
+
+
+
+INCLUDE_DIRS = \
+ -I$(TOP)/include/GL \
+ -I$(TOP)/include \
+ -I.. \
+ -I../main \
+ -I../math \
+ -I../glapi \
+ -I../tnl
+
+
+default: matypes.h
+
+clean:
+ rm -f matypes.h
+
+
+# need some special rules here, unfortunately
+matypes.h: ../main/mtypes.h ../tnl/t_context.h ../x86/gen_matypes
+ ../x86/gen_matypes | grep -v '#include "assyntax.h' > matypes.h
+
+xform4.o: matypes.h
diff --git a/nx-X11/extras/Mesa/src/mesa/x86-64/calling_convention.txt b/nx-X11/extras/Mesa/src/mesa/x86-64/calling_convention.txt
new file mode 100644
index 000000000..4147f7eba
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86-64/calling_convention.txt
@@ -0,0 +1,50 @@
+Register Usage
+rax temporary register; with variable arguments passes information
+ about the number of SSE registers used; 1st return register
+
+rbx* callee-saved register; optionally used as base pointer
+
+rcx used to pass 4th integer argument to functions
+
+rdx used to pass 3rd argument to functions 2nd return register
+
+rsp* stack pointer
+
+rbp* callee-saved register; optionally used as frame pointer
+
+rsi used to pass 2nd argument to functions
+
+rdi used to pass 1st argument to functions
+
+r8 used to pass 5th argument to functions
+
+r9 used to pass 6th argument to functions
+
+r10 temporary register, used for passing a function's static chain pointer
+
+r11 temporary register
+
+r12-15* callee-saved registers
+
+xmm0­1 used to pass and return floating point arguments
+
+xmm2­7 used to pass floating point arguments
+
+xmm8­15 temporary registers
+
+mmx0­7 temporary registers
+
+st0 temporary register; used to return long double arguments
+
+st1 temporary registers; used to return long double arguments
+
+st2­7 temporary registers
+
+fs Reserved for system use (as thread specific data register)
+
+
+
+*) must be preserved across function calls
+
+Integer arguments from list: rdi,rsi,rdx,rcx,r8,r9,stack
+Floating point arguments from list: xmm0-xmm7 \ No newline at end of file
diff --git a/nx-X11/extras/Mesa/src/mesa/x86-64/glapi_x86-64.S b/nx-X11/extras/Mesa/src/mesa/x86-64/glapi_x86-64.S
new file mode 100644
index 000000000..dbc2d7702
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86-64/glapi_x86-64.S
@@ -0,0 +1,31002 @@
+/* DO NOT EDIT - This file generated automatically by gl_x86-64_asm.py (from Mesa) script */
+
+/*
+ * (C) Copyright IBM Corporation 2005
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sub license,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/* If we build with gcc's -fvisibility=hidden flag, we'll need to change
+ * the symbol visibility mode to 'default'.
+ */
+
+#include "assyntax.h"
+
+#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
+# pragma GCC visibility push(default)
+# define HIDDEN(x) .hidden x
+#else
+# define HIDDEN(x)
+#endif
+
+# if defined(USE_MGL_NAMESPACE)
+# define GL_PREFIX(n) GLNAME(CONCAT(mgl,n))
+# else
+# define GL_PREFIX(n) GLNAME(CONCAT(gl,n))
+# endif
+
+#if defined(PTHREADS) || defined(USE_XTHREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)
+# define THREADS
+#endif
+
+ .text
+
+#ifdef GLX_USE_TLS
+
+ .globl _x86_64_get_get_dispatch; HIDDEN(_x86_64_get_get_dispatch)
+_x86_64_get_get_dispatch:
+ lea _x86_64_get_dispatch(%rip), %rax
+ ret
+
+ .p2align 4,,15
+_x86_64_get_dispatch:
+ movq _glapi_tls_Dispatch@GOTTPOFF(%rip), %rax
+ movq %fs:(%rax), %rax
+ ret
+ .size _x86_64_get_dispatch, .-_x86_64_get_dispatch
+
+#elif defined(PTHREADS)
+
+ .extern _glapi_Dispatch
+ .extern _gl_DispatchTSD
+ .extern pthread_getspecific
+
+ .p2align 4,,15
+_x86_64_get_dispatch:
+ movq _gl_DispatchTSD(%rip), %rdi
+ jmp pthread_getspecific@PLT
+
+#elif defined(THREADS)
+
+ .extern _glapi_get_dispatch
+
+#endif
+
+ .p2align 4,,15
+ .globl GL_PREFIX(NewList)
+ .type GL_PREFIX(NewList), @function
+GL_PREFIX(NewList):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 0(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq (%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 0(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 0(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(NewList), .-GL_PREFIX(NewList)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EndList)
+ .type GL_PREFIX(EndList), @function
+GL_PREFIX(EndList):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 8(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 8(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 8(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EndList), .-GL_PREFIX(EndList)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CallList)
+ .type GL_PREFIX(CallList), @function
+GL_PREFIX(CallList):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 16(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 16(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 16(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CallList), .-GL_PREFIX(CallList)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CallLists)
+ .type GL_PREFIX(CallLists), @function
+GL_PREFIX(CallLists):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 24(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 24(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 24(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CallLists), .-GL_PREFIX(CallLists)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DeleteLists)
+ .type GL_PREFIX(DeleteLists), @function
+GL_PREFIX(DeleteLists):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 32(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 32(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 32(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 32(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DeleteLists), .-GL_PREFIX(DeleteLists)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GenLists)
+ .type GL_PREFIX(GenLists), @function
+GL_PREFIX(GenLists):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 40(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 40(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 40(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 40(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GenLists), .-GL_PREFIX(GenLists)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ListBase)
+ .type GL_PREFIX(ListBase), @function
+GL_PREFIX(ListBase):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 48(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 48(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 48(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 48(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ListBase), .-GL_PREFIX(ListBase)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Begin)
+ .type GL_PREFIX(Begin), @function
+GL_PREFIX(Begin):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 56(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 56(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 56(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 56(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Begin), .-GL_PREFIX(Begin)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Bitmap)
+ .type GL_PREFIX(Bitmap), @function
+GL_PREFIX(Bitmap):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 64(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ movq %xmm1, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ movq %rdx, 48(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 48(%rsp), %rdx
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %xmm1
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 64(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 64(%rax), %r11
+ jmp *%r11
+1:
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ movq %xmm1, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ movq %rdx, 48(%rsp)
+ call _glapi_get_dispatch
+ movq 48(%rsp), %rdx
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %xmm1
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 64(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Bitmap), .-GL_PREFIX(Bitmap)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color3b)
+ .type GL_PREFIX(Color3b), @function
+GL_PREFIX(Color3b):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 72(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 72(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 72(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 72(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color3b), .-GL_PREFIX(Color3b)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color3bv)
+ .type GL_PREFIX(Color3bv), @function
+GL_PREFIX(Color3bv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 80(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 80(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 80(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 80(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color3bv), .-GL_PREFIX(Color3bv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color3d)
+ .type GL_PREFIX(Color3d), @function
+GL_PREFIX(Color3d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 88(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 88(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 88(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 88(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color3d), .-GL_PREFIX(Color3d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color3dv)
+ .type GL_PREFIX(Color3dv), @function
+GL_PREFIX(Color3dv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 96(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 96(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 96(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 96(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color3dv), .-GL_PREFIX(Color3dv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color3f)
+ .type GL_PREFIX(Color3f), @function
+GL_PREFIX(Color3f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 104(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 104(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 104(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 104(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color3f), .-GL_PREFIX(Color3f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color3fv)
+ .type GL_PREFIX(Color3fv), @function
+GL_PREFIX(Color3fv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 112(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 112(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 112(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 112(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color3fv), .-GL_PREFIX(Color3fv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color3i)
+ .type GL_PREFIX(Color3i), @function
+GL_PREFIX(Color3i):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 120(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 120(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 120(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 120(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color3i), .-GL_PREFIX(Color3i)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color3iv)
+ .type GL_PREFIX(Color3iv), @function
+GL_PREFIX(Color3iv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 128(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 128(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 128(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 128(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color3iv), .-GL_PREFIX(Color3iv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color3s)
+ .type GL_PREFIX(Color3s), @function
+GL_PREFIX(Color3s):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 136(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 136(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 136(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 136(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color3s), .-GL_PREFIX(Color3s)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color3sv)
+ .type GL_PREFIX(Color3sv), @function
+GL_PREFIX(Color3sv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 144(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 144(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 144(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 144(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color3sv), .-GL_PREFIX(Color3sv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color3ub)
+ .type GL_PREFIX(Color3ub), @function
+GL_PREFIX(Color3ub):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 152(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 152(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 152(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 152(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color3ub), .-GL_PREFIX(Color3ub)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color3ubv)
+ .type GL_PREFIX(Color3ubv), @function
+GL_PREFIX(Color3ubv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 160(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 160(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 160(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 160(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color3ubv), .-GL_PREFIX(Color3ubv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color3ui)
+ .type GL_PREFIX(Color3ui), @function
+GL_PREFIX(Color3ui):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 168(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 168(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 168(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 168(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color3ui), .-GL_PREFIX(Color3ui)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color3uiv)
+ .type GL_PREFIX(Color3uiv), @function
+GL_PREFIX(Color3uiv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 176(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 176(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 176(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 176(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color3uiv), .-GL_PREFIX(Color3uiv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color3us)
+ .type GL_PREFIX(Color3us), @function
+GL_PREFIX(Color3us):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 184(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 184(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 184(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 184(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color3us), .-GL_PREFIX(Color3us)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color3usv)
+ .type GL_PREFIX(Color3usv), @function
+GL_PREFIX(Color3usv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 192(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 192(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 192(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 192(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color3usv), .-GL_PREFIX(Color3usv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color4b)
+ .type GL_PREFIX(Color4b), @function
+GL_PREFIX(Color4b):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 200(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 200(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 200(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 200(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color4b), .-GL_PREFIX(Color4b)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color4bv)
+ .type GL_PREFIX(Color4bv), @function
+GL_PREFIX(Color4bv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 208(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 208(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 208(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 208(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color4bv), .-GL_PREFIX(Color4bv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color4d)
+ .type GL_PREFIX(Color4d), @function
+GL_PREFIX(Color4d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 216(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 216(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 216(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 216(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color4d), .-GL_PREFIX(Color4d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color4dv)
+ .type GL_PREFIX(Color4dv), @function
+GL_PREFIX(Color4dv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 224(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 224(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 224(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 224(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color4dv), .-GL_PREFIX(Color4dv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color4f)
+ .type GL_PREFIX(Color4f), @function
+GL_PREFIX(Color4f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 232(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 232(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 232(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 232(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color4f), .-GL_PREFIX(Color4f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color4fv)
+ .type GL_PREFIX(Color4fv), @function
+GL_PREFIX(Color4fv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 240(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 240(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 240(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 240(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color4fv), .-GL_PREFIX(Color4fv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color4i)
+ .type GL_PREFIX(Color4i), @function
+GL_PREFIX(Color4i):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 248(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 248(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 248(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 248(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color4i), .-GL_PREFIX(Color4i)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color4iv)
+ .type GL_PREFIX(Color4iv), @function
+GL_PREFIX(Color4iv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 256(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 256(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 256(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 256(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color4iv), .-GL_PREFIX(Color4iv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color4s)
+ .type GL_PREFIX(Color4s), @function
+GL_PREFIX(Color4s):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 264(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 264(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 264(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 264(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color4s), .-GL_PREFIX(Color4s)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color4sv)
+ .type GL_PREFIX(Color4sv), @function
+GL_PREFIX(Color4sv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 272(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 272(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 272(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 272(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color4sv), .-GL_PREFIX(Color4sv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color4ub)
+ .type GL_PREFIX(Color4ub), @function
+GL_PREFIX(Color4ub):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 280(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 280(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 280(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 280(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color4ub), .-GL_PREFIX(Color4ub)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color4ubv)
+ .type GL_PREFIX(Color4ubv), @function
+GL_PREFIX(Color4ubv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 288(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 288(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 288(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 288(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color4ubv), .-GL_PREFIX(Color4ubv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color4ui)
+ .type GL_PREFIX(Color4ui), @function
+GL_PREFIX(Color4ui):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 296(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 296(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 296(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 296(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color4ui), .-GL_PREFIX(Color4ui)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color4uiv)
+ .type GL_PREFIX(Color4uiv), @function
+GL_PREFIX(Color4uiv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 304(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 304(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 304(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 304(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color4uiv), .-GL_PREFIX(Color4uiv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color4us)
+ .type GL_PREFIX(Color4us), @function
+GL_PREFIX(Color4us):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 312(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 312(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 312(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 312(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color4us), .-GL_PREFIX(Color4us)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Color4usv)
+ .type GL_PREFIX(Color4usv), @function
+GL_PREFIX(Color4usv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 320(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 320(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 320(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 320(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Color4usv), .-GL_PREFIX(Color4usv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EdgeFlag)
+ .type GL_PREFIX(EdgeFlag), @function
+GL_PREFIX(EdgeFlag):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 328(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 328(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 328(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 328(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EdgeFlag), .-GL_PREFIX(EdgeFlag)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EdgeFlagv)
+ .type GL_PREFIX(EdgeFlagv), @function
+GL_PREFIX(EdgeFlagv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 336(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 336(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 336(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 336(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EdgeFlagv), .-GL_PREFIX(EdgeFlagv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(End)
+ .type GL_PREFIX(End), @function
+GL_PREFIX(End):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 344(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 344(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 344(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 344(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(End), .-GL_PREFIX(End)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Indexd)
+ .type GL_PREFIX(Indexd), @function
+GL_PREFIX(Indexd):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 352(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 352(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 352(%rax), %r11
+ jmp *%r11
+1:
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _glapi_get_dispatch
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 352(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Indexd), .-GL_PREFIX(Indexd)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Indexdv)
+ .type GL_PREFIX(Indexdv), @function
+GL_PREFIX(Indexdv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 360(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 360(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 360(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 360(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Indexdv), .-GL_PREFIX(Indexdv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Indexf)
+ .type GL_PREFIX(Indexf), @function
+GL_PREFIX(Indexf):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 368(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 368(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 368(%rax), %r11
+ jmp *%r11
+1:
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _glapi_get_dispatch
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 368(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Indexf), .-GL_PREFIX(Indexf)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Indexfv)
+ .type GL_PREFIX(Indexfv), @function
+GL_PREFIX(Indexfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 376(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 376(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 376(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 376(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Indexfv), .-GL_PREFIX(Indexfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Indexi)
+ .type GL_PREFIX(Indexi), @function
+GL_PREFIX(Indexi):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 384(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 384(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 384(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 384(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Indexi), .-GL_PREFIX(Indexi)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Indexiv)
+ .type GL_PREFIX(Indexiv), @function
+GL_PREFIX(Indexiv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 392(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 392(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 392(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 392(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Indexiv), .-GL_PREFIX(Indexiv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Indexs)
+ .type GL_PREFIX(Indexs), @function
+GL_PREFIX(Indexs):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 400(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 400(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 400(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 400(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Indexs), .-GL_PREFIX(Indexs)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Indexsv)
+ .type GL_PREFIX(Indexsv), @function
+GL_PREFIX(Indexsv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 408(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 408(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 408(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 408(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Indexsv), .-GL_PREFIX(Indexsv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Normal3b)
+ .type GL_PREFIX(Normal3b), @function
+GL_PREFIX(Normal3b):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 416(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 416(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 416(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 416(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Normal3b), .-GL_PREFIX(Normal3b)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Normal3bv)
+ .type GL_PREFIX(Normal3bv), @function
+GL_PREFIX(Normal3bv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 424(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 424(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 424(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 424(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Normal3bv), .-GL_PREFIX(Normal3bv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Normal3d)
+ .type GL_PREFIX(Normal3d), @function
+GL_PREFIX(Normal3d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 432(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 432(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 432(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 432(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Normal3d), .-GL_PREFIX(Normal3d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Normal3dv)
+ .type GL_PREFIX(Normal3dv), @function
+GL_PREFIX(Normal3dv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 440(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 440(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 440(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 440(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Normal3dv), .-GL_PREFIX(Normal3dv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Normal3f)
+ .type GL_PREFIX(Normal3f), @function
+GL_PREFIX(Normal3f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 448(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 448(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 448(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 448(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Normal3f), .-GL_PREFIX(Normal3f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Normal3fv)
+ .type GL_PREFIX(Normal3fv), @function
+GL_PREFIX(Normal3fv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 456(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 456(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 456(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 456(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Normal3fv), .-GL_PREFIX(Normal3fv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Normal3i)
+ .type GL_PREFIX(Normal3i), @function
+GL_PREFIX(Normal3i):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 464(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 464(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 464(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 464(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Normal3i), .-GL_PREFIX(Normal3i)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Normal3iv)
+ .type GL_PREFIX(Normal3iv), @function
+GL_PREFIX(Normal3iv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 472(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 472(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 472(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 472(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Normal3iv), .-GL_PREFIX(Normal3iv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Normal3s)
+ .type GL_PREFIX(Normal3s), @function
+GL_PREFIX(Normal3s):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 480(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 480(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 480(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 480(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Normal3s), .-GL_PREFIX(Normal3s)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Normal3sv)
+ .type GL_PREFIX(Normal3sv), @function
+GL_PREFIX(Normal3sv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 488(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 488(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 488(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 488(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Normal3sv), .-GL_PREFIX(Normal3sv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos2d)
+ .type GL_PREFIX(RasterPos2d), @function
+GL_PREFIX(RasterPos2d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 496(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 496(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 496(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 496(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos2d), .-GL_PREFIX(RasterPos2d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos2dv)
+ .type GL_PREFIX(RasterPos2dv), @function
+GL_PREFIX(RasterPos2dv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 504(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 504(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 504(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 504(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos2dv), .-GL_PREFIX(RasterPos2dv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos2f)
+ .type GL_PREFIX(RasterPos2f), @function
+GL_PREFIX(RasterPos2f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 512(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 512(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 512(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 512(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos2f), .-GL_PREFIX(RasterPos2f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos2fv)
+ .type GL_PREFIX(RasterPos2fv), @function
+GL_PREFIX(RasterPos2fv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 520(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 520(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 520(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 520(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos2fv), .-GL_PREFIX(RasterPos2fv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos2i)
+ .type GL_PREFIX(RasterPos2i), @function
+GL_PREFIX(RasterPos2i):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 528(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 528(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 528(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 528(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos2i), .-GL_PREFIX(RasterPos2i)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos2iv)
+ .type GL_PREFIX(RasterPos2iv), @function
+GL_PREFIX(RasterPos2iv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 536(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 536(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 536(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 536(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos2iv), .-GL_PREFIX(RasterPos2iv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos2s)
+ .type GL_PREFIX(RasterPos2s), @function
+GL_PREFIX(RasterPos2s):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 544(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 544(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 544(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 544(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos2s), .-GL_PREFIX(RasterPos2s)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos2sv)
+ .type GL_PREFIX(RasterPos2sv), @function
+GL_PREFIX(RasterPos2sv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 552(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 552(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 552(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 552(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos2sv), .-GL_PREFIX(RasterPos2sv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos3d)
+ .type GL_PREFIX(RasterPos3d), @function
+GL_PREFIX(RasterPos3d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 560(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 560(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 560(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 560(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos3d), .-GL_PREFIX(RasterPos3d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos3dv)
+ .type GL_PREFIX(RasterPos3dv), @function
+GL_PREFIX(RasterPos3dv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 568(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 568(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 568(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 568(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos3dv), .-GL_PREFIX(RasterPos3dv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos3f)
+ .type GL_PREFIX(RasterPos3f), @function
+GL_PREFIX(RasterPos3f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 576(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 576(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 576(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 576(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos3f), .-GL_PREFIX(RasterPos3f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos3fv)
+ .type GL_PREFIX(RasterPos3fv), @function
+GL_PREFIX(RasterPos3fv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 584(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 584(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 584(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 584(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos3fv), .-GL_PREFIX(RasterPos3fv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos3i)
+ .type GL_PREFIX(RasterPos3i), @function
+GL_PREFIX(RasterPos3i):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 592(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 592(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 592(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 592(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos3i), .-GL_PREFIX(RasterPos3i)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos3iv)
+ .type GL_PREFIX(RasterPos3iv), @function
+GL_PREFIX(RasterPos3iv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 600(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 600(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 600(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 600(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos3iv), .-GL_PREFIX(RasterPos3iv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos3s)
+ .type GL_PREFIX(RasterPos3s), @function
+GL_PREFIX(RasterPos3s):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 608(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 608(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 608(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 608(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos3s), .-GL_PREFIX(RasterPos3s)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos3sv)
+ .type GL_PREFIX(RasterPos3sv), @function
+GL_PREFIX(RasterPos3sv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 616(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 616(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 616(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 616(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos3sv), .-GL_PREFIX(RasterPos3sv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos4d)
+ .type GL_PREFIX(RasterPos4d), @function
+GL_PREFIX(RasterPos4d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 624(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 624(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 624(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 624(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos4d), .-GL_PREFIX(RasterPos4d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos4dv)
+ .type GL_PREFIX(RasterPos4dv), @function
+GL_PREFIX(RasterPos4dv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 632(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 632(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 632(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 632(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos4dv), .-GL_PREFIX(RasterPos4dv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos4f)
+ .type GL_PREFIX(RasterPos4f), @function
+GL_PREFIX(RasterPos4f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 640(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 640(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 640(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 640(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos4f), .-GL_PREFIX(RasterPos4f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos4fv)
+ .type GL_PREFIX(RasterPos4fv), @function
+GL_PREFIX(RasterPos4fv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 648(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 648(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 648(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 648(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos4fv), .-GL_PREFIX(RasterPos4fv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos4i)
+ .type GL_PREFIX(RasterPos4i), @function
+GL_PREFIX(RasterPos4i):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 656(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 656(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 656(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 656(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos4i), .-GL_PREFIX(RasterPos4i)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos4iv)
+ .type GL_PREFIX(RasterPos4iv), @function
+GL_PREFIX(RasterPos4iv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 664(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 664(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 664(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 664(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos4iv), .-GL_PREFIX(RasterPos4iv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos4s)
+ .type GL_PREFIX(RasterPos4s), @function
+GL_PREFIX(RasterPos4s):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 672(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 672(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 672(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 672(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos4s), .-GL_PREFIX(RasterPos4s)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RasterPos4sv)
+ .type GL_PREFIX(RasterPos4sv), @function
+GL_PREFIX(RasterPos4sv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 680(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 680(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 680(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 680(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RasterPos4sv), .-GL_PREFIX(RasterPos4sv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Rectd)
+ .type GL_PREFIX(Rectd), @function
+GL_PREFIX(Rectd):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 688(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 688(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 688(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 688(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Rectd), .-GL_PREFIX(Rectd)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Rectdv)
+ .type GL_PREFIX(Rectdv), @function
+GL_PREFIX(Rectdv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 696(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 696(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 696(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 696(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Rectdv), .-GL_PREFIX(Rectdv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Rectf)
+ .type GL_PREFIX(Rectf), @function
+GL_PREFIX(Rectf):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 704(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 704(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 704(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 704(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Rectf), .-GL_PREFIX(Rectf)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Rectfv)
+ .type GL_PREFIX(Rectfv), @function
+GL_PREFIX(Rectfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 712(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 712(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 712(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 712(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Rectfv), .-GL_PREFIX(Rectfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Recti)
+ .type GL_PREFIX(Recti), @function
+GL_PREFIX(Recti):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 720(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 720(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 720(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 720(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Recti), .-GL_PREFIX(Recti)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Rectiv)
+ .type GL_PREFIX(Rectiv), @function
+GL_PREFIX(Rectiv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 728(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 728(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 728(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 728(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Rectiv), .-GL_PREFIX(Rectiv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Rects)
+ .type GL_PREFIX(Rects), @function
+GL_PREFIX(Rects):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 736(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 736(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 736(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 736(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Rects), .-GL_PREFIX(Rects)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Rectsv)
+ .type GL_PREFIX(Rectsv), @function
+GL_PREFIX(Rectsv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 744(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 744(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 744(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 744(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Rectsv), .-GL_PREFIX(Rectsv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord1d)
+ .type GL_PREFIX(TexCoord1d), @function
+GL_PREFIX(TexCoord1d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 752(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 752(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 752(%rax), %r11
+ jmp *%r11
+1:
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _glapi_get_dispatch
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 752(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord1d), .-GL_PREFIX(TexCoord1d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord1dv)
+ .type GL_PREFIX(TexCoord1dv), @function
+GL_PREFIX(TexCoord1dv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 760(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 760(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 760(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 760(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord1dv), .-GL_PREFIX(TexCoord1dv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord1f)
+ .type GL_PREFIX(TexCoord1f), @function
+GL_PREFIX(TexCoord1f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 768(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 768(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 768(%rax), %r11
+ jmp *%r11
+1:
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _glapi_get_dispatch
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 768(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord1f), .-GL_PREFIX(TexCoord1f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord1fv)
+ .type GL_PREFIX(TexCoord1fv), @function
+GL_PREFIX(TexCoord1fv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 776(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 776(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 776(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 776(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord1fv), .-GL_PREFIX(TexCoord1fv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord1i)
+ .type GL_PREFIX(TexCoord1i), @function
+GL_PREFIX(TexCoord1i):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 784(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 784(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 784(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 784(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord1i), .-GL_PREFIX(TexCoord1i)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord1iv)
+ .type GL_PREFIX(TexCoord1iv), @function
+GL_PREFIX(TexCoord1iv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 792(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 792(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 792(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 792(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord1iv), .-GL_PREFIX(TexCoord1iv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord1s)
+ .type GL_PREFIX(TexCoord1s), @function
+GL_PREFIX(TexCoord1s):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 800(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 800(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 800(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 800(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord1s), .-GL_PREFIX(TexCoord1s)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord1sv)
+ .type GL_PREFIX(TexCoord1sv), @function
+GL_PREFIX(TexCoord1sv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 808(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 808(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 808(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 808(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord1sv), .-GL_PREFIX(TexCoord1sv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord2d)
+ .type GL_PREFIX(TexCoord2d), @function
+GL_PREFIX(TexCoord2d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 816(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 816(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 816(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 816(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord2d), .-GL_PREFIX(TexCoord2d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord2dv)
+ .type GL_PREFIX(TexCoord2dv), @function
+GL_PREFIX(TexCoord2dv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 824(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 824(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 824(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 824(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord2dv), .-GL_PREFIX(TexCoord2dv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord2f)
+ .type GL_PREFIX(TexCoord2f), @function
+GL_PREFIX(TexCoord2f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 832(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 832(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 832(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 832(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord2f), .-GL_PREFIX(TexCoord2f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord2fv)
+ .type GL_PREFIX(TexCoord2fv), @function
+GL_PREFIX(TexCoord2fv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 840(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 840(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 840(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 840(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord2fv), .-GL_PREFIX(TexCoord2fv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord2i)
+ .type GL_PREFIX(TexCoord2i), @function
+GL_PREFIX(TexCoord2i):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 848(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 848(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 848(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 848(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord2i), .-GL_PREFIX(TexCoord2i)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord2iv)
+ .type GL_PREFIX(TexCoord2iv), @function
+GL_PREFIX(TexCoord2iv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 856(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 856(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 856(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 856(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord2iv), .-GL_PREFIX(TexCoord2iv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord2s)
+ .type GL_PREFIX(TexCoord2s), @function
+GL_PREFIX(TexCoord2s):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 864(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 864(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 864(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 864(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord2s), .-GL_PREFIX(TexCoord2s)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord2sv)
+ .type GL_PREFIX(TexCoord2sv), @function
+GL_PREFIX(TexCoord2sv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 872(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 872(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 872(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 872(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord2sv), .-GL_PREFIX(TexCoord2sv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord3d)
+ .type GL_PREFIX(TexCoord3d), @function
+GL_PREFIX(TexCoord3d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 880(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 880(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 880(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 880(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord3d), .-GL_PREFIX(TexCoord3d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord3dv)
+ .type GL_PREFIX(TexCoord3dv), @function
+GL_PREFIX(TexCoord3dv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 888(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 888(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 888(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 888(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord3dv), .-GL_PREFIX(TexCoord3dv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord3f)
+ .type GL_PREFIX(TexCoord3f), @function
+GL_PREFIX(TexCoord3f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 896(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 896(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 896(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 896(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord3f), .-GL_PREFIX(TexCoord3f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord3fv)
+ .type GL_PREFIX(TexCoord3fv), @function
+GL_PREFIX(TexCoord3fv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 904(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 904(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 904(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 904(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord3fv), .-GL_PREFIX(TexCoord3fv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord3i)
+ .type GL_PREFIX(TexCoord3i), @function
+GL_PREFIX(TexCoord3i):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 912(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 912(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 912(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 912(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord3i), .-GL_PREFIX(TexCoord3i)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord3iv)
+ .type GL_PREFIX(TexCoord3iv), @function
+GL_PREFIX(TexCoord3iv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 920(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 920(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 920(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 920(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord3iv), .-GL_PREFIX(TexCoord3iv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord3s)
+ .type GL_PREFIX(TexCoord3s), @function
+GL_PREFIX(TexCoord3s):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 928(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 928(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 928(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 928(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord3s), .-GL_PREFIX(TexCoord3s)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord3sv)
+ .type GL_PREFIX(TexCoord3sv), @function
+GL_PREFIX(TexCoord3sv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 936(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 936(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 936(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 936(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord3sv), .-GL_PREFIX(TexCoord3sv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord4d)
+ .type GL_PREFIX(TexCoord4d), @function
+GL_PREFIX(TexCoord4d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 944(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 944(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 944(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 944(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord4d), .-GL_PREFIX(TexCoord4d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord4dv)
+ .type GL_PREFIX(TexCoord4dv), @function
+GL_PREFIX(TexCoord4dv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 952(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 952(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 952(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 952(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord4dv), .-GL_PREFIX(TexCoord4dv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord4f)
+ .type GL_PREFIX(TexCoord4f), @function
+GL_PREFIX(TexCoord4f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 960(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 960(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 960(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 960(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord4f), .-GL_PREFIX(TexCoord4f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord4fv)
+ .type GL_PREFIX(TexCoord4fv), @function
+GL_PREFIX(TexCoord4fv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 968(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 968(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 968(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 968(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord4fv), .-GL_PREFIX(TexCoord4fv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord4i)
+ .type GL_PREFIX(TexCoord4i), @function
+GL_PREFIX(TexCoord4i):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 976(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 976(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 976(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 976(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord4i), .-GL_PREFIX(TexCoord4i)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord4iv)
+ .type GL_PREFIX(TexCoord4iv), @function
+GL_PREFIX(TexCoord4iv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 984(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 984(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 984(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 984(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord4iv), .-GL_PREFIX(TexCoord4iv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord4s)
+ .type GL_PREFIX(TexCoord4s), @function
+GL_PREFIX(TexCoord4s):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 992(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 992(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 992(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 992(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord4s), .-GL_PREFIX(TexCoord4s)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoord4sv)
+ .type GL_PREFIX(TexCoord4sv), @function
+GL_PREFIX(TexCoord4sv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1000(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1000(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1000(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1000(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoord4sv), .-GL_PREFIX(TexCoord4sv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex2d)
+ .type GL_PREFIX(Vertex2d), @function
+GL_PREFIX(Vertex2d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1008(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 1008(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1008(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 1008(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex2d), .-GL_PREFIX(Vertex2d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex2dv)
+ .type GL_PREFIX(Vertex2dv), @function
+GL_PREFIX(Vertex2dv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1016(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1016(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1016(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1016(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex2dv), .-GL_PREFIX(Vertex2dv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex2f)
+ .type GL_PREFIX(Vertex2f), @function
+GL_PREFIX(Vertex2f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1024(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 1024(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1024(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 1024(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex2f), .-GL_PREFIX(Vertex2f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex2fv)
+ .type GL_PREFIX(Vertex2fv), @function
+GL_PREFIX(Vertex2fv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1032(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1032(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1032(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1032(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex2fv), .-GL_PREFIX(Vertex2fv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex2i)
+ .type GL_PREFIX(Vertex2i), @function
+GL_PREFIX(Vertex2i):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1040(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1040(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1040(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1040(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex2i), .-GL_PREFIX(Vertex2i)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex2iv)
+ .type GL_PREFIX(Vertex2iv), @function
+GL_PREFIX(Vertex2iv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1048(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1048(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1048(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1048(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex2iv), .-GL_PREFIX(Vertex2iv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex2s)
+ .type GL_PREFIX(Vertex2s), @function
+GL_PREFIX(Vertex2s):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1056(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1056(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1056(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1056(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex2s), .-GL_PREFIX(Vertex2s)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex2sv)
+ .type GL_PREFIX(Vertex2sv), @function
+GL_PREFIX(Vertex2sv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1064(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1064(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1064(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1064(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex2sv), .-GL_PREFIX(Vertex2sv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex3d)
+ .type GL_PREFIX(Vertex3d), @function
+GL_PREFIX(Vertex3d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1072(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 1072(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1072(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 1072(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex3d), .-GL_PREFIX(Vertex3d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex3dv)
+ .type GL_PREFIX(Vertex3dv), @function
+GL_PREFIX(Vertex3dv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1080(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1080(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1080(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1080(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex3dv), .-GL_PREFIX(Vertex3dv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex3f)
+ .type GL_PREFIX(Vertex3f), @function
+GL_PREFIX(Vertex3f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1088(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 1088(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1088(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 1088(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex3f), .-GL_PREFIX(Vertex3f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex3fv)
+ .type GL_PREFIX(Vertex3fv), @function
+GL_PREFIX(Vertex3fv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1096(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1096(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1096(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1096(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex3fv), .-GL_PREFIX(Vertex3fv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex3i)
+ .type GL_PREFIX(Vertex3i), @function
+GL_PREFIX(Vertex3i):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1104(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1104(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1104(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1104(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex3i), .-GL_PREFIX(Vertex3i)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex3iv)
+ .type GL_PREFIX(Vertex3iv), @function
+GL_PREFIX(Vertex3iv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1112(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1112(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1112(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1112(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex3iv), .-GL_PREFIX(Vertex3iv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex3s)
+ .type GL_PREFIX(Vertex3s), @function
+GL_PREFIX(Vertex3s):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1120(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1120(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1120(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1120(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex3s), .-GL_PREFIX(Vertex3s)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex3sv)
+ .type GL_PREFIX(Vertex3sv), @function
+GL_PREFIX(Vertex3sv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1128(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1128(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1128(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1128(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex3sv), .-GL_PREFIX(Vertex3sv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex4d)
+ .type GL_PREFIX(Vertex4d), @function
+GL_PREFIX(Vertex4d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1136(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 1136(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1136(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 1136(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex4d), .-GL_PREFIX(Vertex4d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex4dv)
+ .type GL_PREFIX(Vertex4dv), @function
+GL_PREFIX(Vertex4dv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1144(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1144(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1144(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1144(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex4dv), .-GL_PREFIX(Vertex4dv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex4f)
+ .type GL_PREFIX(Vertex4f), @function
+GL_PREFIX(Vertex4f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1152(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 1152(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1152(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 1152(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex4f), .-GL_PREFIX(Vertex4f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex4fv)
+ .type GL_PREFIX(Vertex4fv), @function
+GL_PREFIX(Vertex4fv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1160(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1160(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1160(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1160(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex4fv), .-GL_PREFIX(Vertex4fv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex4i)
+ .type GL_PREFIX(Vertex4i), @function
+GL_PREFIX(Vertex4i):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1168(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1168(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1168(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1168(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex4i), .-GL_PREFIX(Vertex4i)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex4iv)
+ .type GL_PREFIX(Vertex4iv), @function
+GL_PREFIX(Vertex4iv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1176(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1176(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1176(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1176(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex4iv), .-GL_PREFIX(Vertex4iv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex4s)
+ .type GL_PREFIX(Vertex4s), @function
+GL_PREFIX(Vertex4s):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1184(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1184(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1184(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1184(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex4s), .-GL_PREFIX(Vertex4s)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Vertex4sv)
+ .type GL_PREFIX(Vertex4sv), @function
+GL_PREFIX(Vertex4sv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1192(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1192(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1192(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1192(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Vertex4sv), .-GL_PREFIX(Vertex4sv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ClipPlane)
+ .type GL_PREFIX(ClipPlane), @function
+GL_PREFIX(ClipPlane):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1200(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1200(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1200(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1200(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ClipPlane), .-GL_PREFIX(ClipPlane)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ColorMaterial)
+ .type GL_PREFIX(ColorMaterial), @function
+GL_PREFIX(ColorMaterial):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1208(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1208(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1208(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1208(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ColorMaterial), .-GL_PREFIX(ColorMaterial)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CullFace)
+ .type GL_PREFIX(CullFace), @function
+GL_PREFIX(CullFace):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1216(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1216(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1216(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1216(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CullFace), .-GL_PREFIX(CullFace)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Fogf)
+ .type GL_PREFIX(Fogf), @function
+GL_PREFIX(Fogf):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1224(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1224(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1224(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1224(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Fogf), .-GL_PREFIX(Fogf)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Fogfv)
+ .type GL_PREFIX(Fogfv), @function
+GL_PREFIX(Fogfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1232(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1232(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1232(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1232(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Fogfv), .-GL_PREFIX(Fogfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Fogi)
+ .type GL_PREFIX(Fogi), @function
+GL_PREFIX(Fogi):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1240(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1240(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1240(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1240(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Fogi), .-GL_PREFIX(Fogi)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Fogiv)
+ .type GL_PREFIX(Fogiv), @function
+GL_PREFIX(Fogiv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1248(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1248(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1248(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1248(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Fogiv), .-GL_PREFIX(Fogiv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FrontFace)
+ .type GL_PREFIX(FrontFace), @function
+GL_PREFIX(FrontFace):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1256(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1256(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1256(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1256(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FrontFace), .-GL_PREFIX(FrontFace)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Hint)
+ .type GL_PREFIX(Hint), @function
+GL_PREFIX(Hint):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1264(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1264(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1264(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1264(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Hint), .-GL_PREFIX(Hint)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Lightf)
+ .type GL_PREFIX(Lightf), @function
+GL_PREFIX(Lightf):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1272(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1272(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1272(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1272(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Lightf), .-GL_PREFIX(Lightf)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Lightfv)
+ .type GL_PREFIX(Lightfv), @function
+GL_PREFIX(Lightfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1280(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1280(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1280(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1280(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Lightfv), .-GL_PREFIX(Lightfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Lighti)
+ .type GL_PREFIX(Lighti), @function
+GL_PREFIX(Lighti):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1288(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1288(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1288(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1288(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Lighti), .-GL_PREFIX(Lighti)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Lightiv)
+ .type GL_PREFIX(Lightiv), @function
+GL_PREFIX(Lightiv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1296(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1296(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1296(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1296(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Lightiv), .-GL_PREFIX(Lightiv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(LightModelf)
+ .type GL_PREFIX(LightModelf), @function
+GL_PREFIX(LightModelf):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1304(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1304(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1304(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1304(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(LightModelf), .-GL_PREFIX(LightModelf)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(LightModelfv)
+ .type GL_PREFIX(LightModelfv), @function
+GL_PREFIX(LightModelfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1312(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1312(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1312(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1312(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(LightModelfv), .-GL_PREFIX(LightModelfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(LightModeli)
+ .type GL_PREFIX(LightModeli), @function
+GL_PREFIX(LightModeli):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1320(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1320(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1320(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1320(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(LightModeli), .-GL_PREFIX(LightModeli)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(LightModeliv)
+ .type GL_PREFIX(LightModeliv), @function
+GL_PREFIX(LightModeliv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1328(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1328(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1328(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1328(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(LightModeliv), .-GL_PREFIX(LightModeliv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(LineStipple)
+ .type GL_PREFIX(LineStipple), @function
+GL_PREFIX(LineStipple):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1336(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1336(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1336(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1336(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(LineStipple), .-GL_PREFIX(LineStipple)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(LineWidth)
+ .type GL_PREFIX(LineWidth), @function
+GL_PREFIX(LineWidth):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1344(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 1344(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1344(%rax), %r11
+ jmp *%r11
+1:
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _glapi_get_dispatch
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 1344(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(LineWidth), .-GL_PREFIX(LineWidth)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Materialf)
+ .type GL_PREFIX(Materialf), @function
+GL_PREFIX(Materialf):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1352(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1352(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1352(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1352(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Materialf), .-GL_PREFIX(Materialf)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Materialfv)
+ .type GL_PREFIX(Materialfv), @function
+GL_PREFIX(Materialfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1360(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1360(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1360(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1360(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Materialfv), .-GL_PREFIX(Materialfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Materiali)
+ .type GL_PREFIX(Materiali), @function
+GL_PREFIX(Materiali):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1368(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1368(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1368(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1368(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Materiali), .-GL_PREFIX(Materiali)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Materialiv)
+ .type GL_PREFIX(Materialiv), @function
+GL_PREFIX(Materialiv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1376(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1376(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1376(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1376(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Materialiv), .-GL_PREFIX(Materialiv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PointSize)
+ .type GL_PREFIX(PointSize), @function
+GL_PREFIX(PointSize):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1384(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 1384(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1384(%rax), %r11
+ jmp *%r11
+1:
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _glapi_get_dispatch
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 1384(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PointSize), .-GL_PREFIX(PointSize)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PolygonMode)
+ .type GL_PREFIX(PolygonMode), @function
+GL_PREFIX(PolygonMode):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1392(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1392(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1392(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1392(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PolygonMode), .-GL_PREFIX(PolygonMode)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PolygonStipple)
+ .type GL_PREFIX(PolygonStipple), @function
+GL_PREFIX(PolygonStipple):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1400(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1400(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1400(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1400(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PolygonStipple), .-GL_PREFIX(PolygonStipple)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Scissor)
+ .type GL_PREFIX(Scissor), @function
+GL_PREFIX(Scissor):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1408(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1408(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1408(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1408(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Scissor), .-GL_PREFIX(Scissor)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ShadeModel)
+ .type GL_PREFIX(ShadeModel), @function
+GL_PREFIX(ShadeModel):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1416(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1416(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1416(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1416(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ShadeModel), .-GL_PREFIX(ShadeModel)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexParameterf)
+ .type GL_PREFIX(TexParameterf), @function
+GL_PREFIX(TexParameterf):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1424(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1424(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1424(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1424(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexParameterf), .-GL_PREFIX(TexParameterf)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexParameterfv)
+ .type GL_PREFIX(TexParameterfv), @function
+GL_PREFIX(TexParameterfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1432(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1432(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1432(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1432(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexParameterfv), .-GL_PREFIX(TexParameterfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexParameteri)
+ .type GL_PREFIX(TexParameteri), @function
+GL_PREFIX(TexParameteri):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1440(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1440(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1440(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1440(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexParameteri), .-GL_PREFIX(TexParameteri)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexParameteriv)
+ .type GL_PREFIX(TexParameteriv), @function
+GL_PREFIX(TexParameteriv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1448(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1448(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1448(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1448(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexParameteriv), .-GL_PREFIX(TexParameteriv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexImage1D)
+ .type GL_PREFIX(TexImage1D), @function
+GL_PREFIX(TexImage1D):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1456(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1456(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1456(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1456(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexImage1D), .-GL_PREFIX(TexImage1D)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexImage2D)
+ .type GL_PREFIX(TexImage2D), @function
+GL_PREFIX(TexImage2D):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1464(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1464(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1464(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1464(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexImage2D), .-GL_PREFIX(TexImage2D)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexEnvf)
+ .type GL_PREFIX(TexEnvf), @function
+GL_PREFIX(TexEnvf):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1472(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1472(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1472(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1472(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexEnvf), .-GL_PREFIX(TexEnvf)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexEnvfv)
+ .type GL_PREFIX(TexEnvfv), @function
+GL_PREFIX(TexEnvfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1480(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1480(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1480(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1480(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexEnvfv), .-GL_PREFIX(TexEnvfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexEnvi)
+ .type GL_PREFIX(TexEnvi), @function
+GL_PREFIX(TexEnvi):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1488(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1488(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1488(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1488(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexEnvi), .-GL_PREFIX(TexEnvi)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexEnviv)
+ .type GL_PREFIX(TexEnviv), @function
+GL_PREFIX(TexEnviv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1496(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1496(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1496(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1496(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexEnviv), .-GL_PREFIX(TexEnviv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexGend)
+ .type GL_PREFIX(TexGend), @function
+GL_PREFIX(TexGend):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1504(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1504(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1504(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1504(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexGend), .-GL_PREFIX(TexGend)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexGendv)
+ .type GL_PREFIX(TexGendv), @function
+GL_PREFIX(TexGendv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1512(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1512(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1512(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1512(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexGendv), .-GL_PREFIX(TexGendv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexGenf)
+ .type GL_PREFIX(TexGenf), @function
+GL_PREFIX(TexGenf):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1520(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1520(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1520(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1520(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexGenf), .-GL_PREFIX(TexGenf)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexGenfv)
+ .type GL_PREFIX(TexGenfv), @function
+GL_PREFIX(TexGenfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1528(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1528(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1528(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1528(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexGenfv), .-GL_PREFIX(TexGenfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexGeni)
+ .type GL_PREFIX(TexGeni), @function
+GL_PREFIX(TexGeni):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1536(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1536(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1536(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1536(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexGeni), .-GL_PREFIX(TexGeni)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexGeniv)
+ .type GL_PREFIX(TexGeniv), @function
+GL_PREFIX(TexGeniv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1544(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1544(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1544(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1544(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexGeniv), .-GL_PREFIX(TexGeniv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FeedbackBuffer)
+ .type GL_PREFIX(FeedbackBuffer), @function
+GL_PREFIX(FeedbackBuffer):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1552(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1552(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1552(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1552(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FeedbackBuffer), .-GL_PREFIX(FeedbackBuffer)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SelectBuffer)
+ .type GL_PREFIX(SelectBuffer), @function
+GL_PREFIX(SelectBuffer):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1560(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1560(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1560(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1560(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SelectBuffer), .-GL_PREFIX(SelectBuffer)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RenderMode)
+ .type GL_PREFIX(RenderMode), @function
+GL_PREFIX(RenderMode):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1568(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1568(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1568(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1568(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RenderMode), .-GL_PREFIX(RenderMode)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(InitNames)
+ .type GL_PREFIX(InitNames), @function
+GL_PREFIX(InitNames):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1576(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 1576(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1576(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 1576(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(InitNames), .-GL_PREFIX(InitNames)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(LoadName)
+ .type GL_PREFIX(LoadName), @function
+GL_PREFIX(LoadName):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1584(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1584(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1584(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1584(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(LoadName), .-GL_PREFIX(LoadName)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PassThrough)
+ .type GL_PREFIX(PassThrough), @function
+GL_PREFIX(PassThrough):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1592(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 1592(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1592(%rax), %r11
+ jmp *%r11
+1:
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _glapi_get_dispatch
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 1592(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PassThrough), .-GL_PREFIX(PassThrough)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PopName)
+ .type GL_PREFIX(PopName), @function
+GL_PREFIX(PopName):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1600(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 1600(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1600(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 1600(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PopName), .-GL_PREFIX(PopName)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PushName)
+ .type GL_PREFIX(PushName), @function
+GL_PREFIX(PushName):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1608(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1608(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1608(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1608(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PushName), .-GL_PREFIX(PushName)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DrawBuffer)
+ .type GL_PREFIX(DrawBuffer), @function
+GL_PREFIX(DrawBuffer):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1616(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1616(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1616(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1616(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DrawBuffer), .-GL_PREFIX(DrawBuffer)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Clear)
+ .type GL_PREFIX(Clear), @function
+GL_PREFIX(Clear):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1624(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1624(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1624(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1624(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Clear), .-GL_PREFIX(Clear)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ClearAccum)
+ .type GL_PREFIX(ClearAccum), @function
+GL_PREFIX(ClearAccum):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1632(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 1632(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1632(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 1632(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ClearAccum), .-GL_PREFIX(ClearAccum)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ClearIndex)
+ .type GL_PREFIX(ClearIndex), @function
+GL_PREFIX(ClearIndex):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1640(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 1640(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1640(%rax), %r11
+ jmp *%r11
+1:
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _glapi_get_dispatch
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 1640(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ClearIndex), .-GL_PREFIX(ClearIndex)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ClearColor)
+ .type GL_PREFIX(ClearColor), @function
+GL_PREFIX(ClearColor):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1648(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1648(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1648(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1648(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ClearColor), .-GL_PREFIX(ClearColor)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ClearStencil)
+ .type GL_PREFIX(ClearStencil), @function
+GL_PREFIX(ClearStencil):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1656(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1656(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1656(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1656(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ClearStencil), .-GL_PREFIX(ClearStencil)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ClearDepth)
+ .type GL_PREFIX(ClearDepth), @function
+GL_PREFIX(ClearDepth):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1664(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1664(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1664(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1664(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ClearDepth), .-GL_PREFIX(ClearDepth)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(StencilMask)
+ .type GL_PREFIX(StencilMask), @function
+GL_PREFIX(StencilMask):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1672(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1672(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1672(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1672(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(StencilMask), .-GL_PREFIX(StencilMask)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ColorMask)
+ .type GL_PREFIX(ColorMask), @function
+GL_PREFIX(ColorMask):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1680(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1680(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1680(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1680(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ColorMask), .-GL_PREFIX(ColorMask)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DepthMask)
+ .type GL_PREFIX(DepthMask), @function
+GL_PREFIX(DepthMask):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1688(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1688(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1688(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1688(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DepthMask), .-GL_PREFIX(DepthMask)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(IndexMask)
+ .type GL_PREFIX(IndexMask), @function
+GL_PREFIX(IndexMask):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1696(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1696(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1696(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1696(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(IndexMask), .-GL_PREFIX(IndexMask)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Accum)
+ .type GL_PREFIX(Accum), @function
+GL_PREFIX(Accum):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1704(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1704(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1704(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1704(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Accum), .-GL_PREFIX(Accum)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Disable)
+ .type GL_PREFIX(Disable), @function
+GL_PREFIX(Disable):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1712(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1712(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1712(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1712(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Disable), .-GL_PREFIX(Disable)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Enable)
+ .type GL_PREFIX(Enable), @function
+GL_PREFIX(Enable):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1720(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1720(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1720(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1720(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Enable), .-GL_PREFIX(Enable)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Finish)
+ .type GL_PREFIX(Finish), @function
+GL_PREFIX(Finish):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1728(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 1728(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1728(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 1728(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Finish), .-GL_PREFIX(Finish)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Flush)
+ .type GL_PREFIX(Flush), @function
+GL_PREFIX(Flush):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1736(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 1736(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1736(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 1736(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Flush), .-GL_PREFIX(Flush)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PopAttrib)
+ .type GL_PREFIX(PopAttrib), @function
+GL_PREFIX(PopAttrib):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1744(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 1744(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1744(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 1744(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PopAttrib), .-GL_PREFIX(PopAttrib)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PushAttrib)
+ .type GL_PREFIX(PushAttrib), @function
+GL_PREFIX(PushAttrib):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1752(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1752(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1752(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1752(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PushAttrib), .-GL_PREFIX(PushAttrib)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Map1d)
+ .type GL_PREFIX(Map1d), @function
+GL_PREFIX(Map1d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1760(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %rsi, 24(%rsp)
+ movq %rdx, 32(%rsp)
+ movq %rcx, 40(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 40(%rsp), %rcx
+ movq 32(%rsp), %rdx
+ movq 24(%rsp), %rsi
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 1760(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1760(%rax), %r11
+ jmp *%r11
+1:
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %rsi, 24(%rsp)
+ movq %rdx, 32(%rsp)
+ movq %rcx, 40(%rsp)
+ call _glapi_get_dispatch
+ movq 40(%rsp), %rcx
+ movq 32(%rsp), %rdx
+ movq 24(%rsp), %rsi
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 1760(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Map1d), .-GL_PREFIX(Map1d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Map1f)
+ .type GL_PREFIX(Map1f), @function
+GL_PREFIX(Map1f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1768(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %rsi, 24(%rsp)
+ movq %rdx, 32(%rsp)
+ movq %rcx, 40(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 40(%rsp), %rcx
+ movq 32(%rsp), %rdx
+ movq 24(%rsp), %rsi
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 1768(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1768(%rax), %r11
+ jmp *%r11
+1:
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %rsi, 24(%rsp)
+ movq %rdx, 32(%rsp)
+ movq %rcx, 40(%rsp)
+ call _glapi_get_dispatch
+ movq 40(%rsp), %rcx
+ movq 32(%rsp), %rdx
+ movq 24(%rsp), %rsi
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 1768(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Map1f), .-GL_PREFIX(Map1f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Map2d)
+ .type GL_PREFIX(Map2d), @function
+GL_PREFIX(Map2d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1776(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $88, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %rsi, 24(%rsp)
+ movq %rdx, 32(%rsp)
+ movq %xmm2, 40(%rsp)
+ movq %xmm3, 48(%rsp)
+ movq %rcx, 56(%rsp)
+ movq %r8, 64(%rsp)
+ movq %r9, 72(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 72(%rsp), %r9
+ movq 64(%rsp), %r8
+ movq 56(%rsp), %rcx
+ movq 48(%rsp), %xmm3
+ movq 40(%rsp), %xmm2
+ movq 32(%rsp), %rdx
+ movq 24(%rsp), %rsi
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $88, %rsp
+ movq 1776(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1776(%rax), %r11
+ jmp *%r11
+1:
+ subq $88, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %rsi, 24(%rsp)
+ movq %rdx, 32(%rsp)
+ movq %xmm2, 40(%rsp)
+ movq %xmm3, 48(%rsp)
+ movq %rcx, 56(%rsp)
+ movq %r8, 64(%rsp)
+ movq %r9, 72(%rsp)
+ call _glapi_get_dispatch
+ movq 72(%rsp), %r9
+ movq 64(%rsp), %r8
+ movq 56(%rsp), %rcx
+ movq 48(%rsp), %xmm3
+ movq 40(%rsp), %xmm2
+ movq 32(%rsp), %rdx
+ movq 24(%rsp), %rsi
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $88, %rsp
+ movq 1776(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Map2d), .-GL_PREFIX(Map2d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Map2f)
+ .type GL_PREFIX(Map2f), @function
+GL_PREFIX(Map2f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1784(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $88, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %rsi, 24(%rsp)
+ movq %rdx, 32(%rsp)
+ movq %xmm2, 40(%rsp)
+ movq %xmm3, 48(%rsp)
+ movq %rcx, 56(%rsp)
+ movq %r8, 64(%rsp)
+ movq %r9, 72(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 72(%rsp), %r9
+ movq 64(%rsp), %r8
+ movq 56(%rsp), %rcx
+ movq 48(%rsp), %xmm3
+ movq 40(%rsp), %xmm2
+ movq 32(%rsp), %rdx
+ movq 24(%rsp), %rsi
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $88, %rsp
+ movq 1784(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1784(%rax), %r11
+ jmp *%r11
+1:
+ subq $88, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %rsi, 24(%rsp)
+ movq %rdx, 32(%rsp)
+ movq %xmm2, 40(%rsp)
+ movq %xmm3, 48(%rsp)
+ movq %rcx, 56(%rsp)
+ movq %r8, 64(%rsp)
+ movq %r9, 72(%rsp)
+ call _glapi_get_dispatch
+ movq 72(%rsp), %r9
+ movq 64(%rsp), %r8
+ movq 56(%rsp), %rcx
+ movq 48(%rsp), %xmm3
+ movq 40(%rsp), %xmm2
+ movq 32(%rsp), %rdx
+ movq 24(%rsp), %rsi
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $88, %rsp
+ movq 1784(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Map2f), .-GL_PREFIX(Map2f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MapGrid1d)
+ .type GL_PREFIX(MapGrid1d), @function
+GL_PREFIX(MapGrid1d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1792(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1792(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1792(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1792(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MapGrid1d), .-GL_PREFIX(MapGrid1d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MapGrid1f)
+ .type GL_PREFIX(MapGrid1f), @function
+GL_PREFIX(MapGrid1f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1800(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1800(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1800(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1800(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MapGrid1f), .-GL_PREFIX(MapGrid1f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MapGrid2d)
+ .type GL_PREFIX(MapGrid2d), @function
+GL_PREFIX(MapGrid2d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1808(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %rsi, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %rsi
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 1808(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1808(%rax), %r11
+ jmp *%r11
+1:
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %rsi, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ call _glapi_get_dispatch
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %rsi
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 1808(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MapGrid2d), .-GL_PREFIX(MapGrid2d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MapGrid2f)
+ .type GL_PREFIX(MapGrid2f), @function
+GL_PREFIX(MapGrid2f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1816(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %rsi, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %rsi
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 1816(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1816(%rax), %r11
+ jmp *%r11
+1:
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %rsi, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ call _glapi_get_dispatch
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %rsi
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 1816(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MapGrid2f), .-GL_PREFIX(MapGrid2f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EvalCoord1d)
+ .type GL_PREFIX(EvalCoord1d), @function
+GL_PREFIX(EvalCoord1d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1824(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 1824(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1824(%rax), %r11
+ jmp *%r11
+1:
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _glapi_get_dispatch
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 1824(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EvalCoord1d), .-GL_PREFIX(EvalCoord1d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EvalCoord1dv)
+ .type GL_PREFIX(EvalCoord1dv), @function
+GL_PREFIX(EvalCoord1dv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1832(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1832(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1832(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1832(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EvalCoord1dv), .-GL_PREFIX(EvalCoord1dv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EvalCoord1f)
+ .type GL_PREFIX(EvalCoord1f), @function
+GL_PREFIX(EvalCoord1f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1840(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 1840(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1840(%rax), %r11
+ jmp *%r11
+1:
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _glapi_get_dispatch
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 1840(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EvalCoord1f), .-GL_PREFIX(EvalCoord1f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EvalCoord1fv)
+ .type GL_PREFIX(EvalCoord1fv), @function
+GL_PREFIX(EvalCoord1fv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1848(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1848(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1848(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1848(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EvalCoord1fv), .-GL_PREFIX(EvalCoord1fv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EvalCoord2d)
+ .type GL_PREFIX(EvalCoord2d), @function
+GL_PREFIX(EvalCoord2d):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1856(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 1856(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1856(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 1856(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EvalCoord2d), .-GL_PREFIX(EvalCoord2d)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EvalCoord2dv)
+ .type GL_PREFIX(EvalCoord2dv), @function
+GL_PREFIX(EvalCoord2dv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1864(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1864(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1864(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1864(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EvalCoord2dv), .-GL_PREFIX(EvalCoord2dv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EvalCoord2f)
+ .type GL_PREFIX(EvalCoord2f), @function
+GL_PREFIX(EvalCoord2f):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1872(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 1872(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1872(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 1872(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EvalCoord2f), .-GL_PREFIX(EvalCoord2f)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EvalCoord2fv)
+ .type GL_PREFIX(EvalCoord2fv), @function
+GL_PREFIX(EvalCoord2fv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1880(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1880(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1880(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1880(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EvalCoord2fv), .-GL_PREFIX(EvalCoord2fv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EvalMesh1)
+ .type GL_PREFIX(EvalMesh1), @function
+GL_PREFIX(EvalMesh1):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1888(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1888(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1888(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1888(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EvalMesh1), .-GL_PREFIX(EvalMesh1)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EvalPoint1)
+ .type GL_PREFIX(EvalPoint1), @function
+GL_PREFIX(EvalPoint1):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1896(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1896(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1896(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1896(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EvalPoint1), .-GL_PREFIX(EvalPoint1)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EvalMesh2)
+ .type GL_PREFIX(EvalMesh2), @function
+GL_PREFIX(EvalMesh2):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1904(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1904(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1904(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1904(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EvalMesh2), .-GL_PREFIX(EvalMesh2)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EvalPoint2)
+ .type GL_PREFIX(EvalPoint2), @function
+GL_PREFIX(EvalPoint2):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1912(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1912(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1912(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1912(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EvalPoint2), .-GL_PREFIX(EvalPoint2)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(AlphaFunc)
+ .type GL_PREFIX(AlphaFunc), @function
+GL_PREFIX(AlphaFunc):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1920(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1920(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1920(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1920(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(AlphaFunc), .-GL_PREFIX(AlphaFunc)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(BlendFunc)
+ .type GL_PREFIX(BlendFunc), @function
+GL_PREFIX(BlendFunc):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1928(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1928(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1928(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1928(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(BlendFunc), .-GL_PREFIX(BlendFunc)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(LogicOp)
+ .type GL_PREFIX(LogicOp), @function
+GL_PREFIX(LogicOp):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1936(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1936(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1936(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1936(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(LogicOp), .-GL_PREFIX(LogicOp)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(StencilFunc)
+ .type GL_PREFIX(StencilFunc), @function
+GL_PREFIX(StencilFunc):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1944(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1944(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1944(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1944(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(StencilFunc), .-GL_PREFIX(StencilFunc)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(StencilOp)
+ .type GL_PREFIX(StencilOp), @function
+GL_PREFIX(StencilOp):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1952(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1952(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1952(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 1952(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(StencilOp), .-GL_PREFIX(StencilOp)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DepthFunc)
+ .type GL_PREFIX(DepthFunc), @function
+GL_PREFIX(DepthFunc):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1960(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 1960(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1960(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 1960(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DepthFunc), .-GL_PREFIX(DepthFunc)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PixelZoom)
+ .type GL_PREFIX(PixelZoom), @function
+GL_PREFIX(PixelZoom):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1968(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 1968(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1968(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 1968(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PixelZoom), .-GL_PREFIX(PixelZoom)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PixelTransferf)
+ .type GL_PREFIX(PixelTransferf), @function
+GL_PREFIX(PixelTransferf):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1976(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1976(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1976(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1976(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PixelTransferf), .-GL_PREFIX(PixelTransferf)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PixelTransferi)
+ .type GL_PREFIX(PixelTransferi), @function
+GL_PREFIX(PixelTransferi):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1984(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1984(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1984(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 1984(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PixelTransferi), .-GL_PREFIX(PixelTransferi)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PixelStoref)
+ .type GL_PREFIX(PixelStoref), @function
+GL_PREFIX(PixelStoref):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 1992(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1992(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 1992(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 1992(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PixelStoref), .-GL_PREFIX(PixelStoref)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PixelStorei)
+ .type GL_PREFIX(PixelStorei), @function
+GL_PREFIX(PixelStorei):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2000(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2000(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2000(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2000(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PixelStorei), .-GL_PREFIX(PixelStorei)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PixelMapfv)
+ .type GL_PREFIX(PixelMapfv), @function
+GL_PREFIX(PixelMapfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2008(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2008(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2008(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2008(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PixelMapfv), .-GL_PREFIX(PixelMapfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PixelMapuiv)
+ .type GL_PREFIX(PixelMapuiv), @function
+GL_PREFIX(PixelMapuiv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2016(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2016(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2016(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2016(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PixelMapuiv), .-GL_PREFIX(PixelMapuiv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PixelMapusv)
+ .type GL_PREFIX(PixelMapusv), @function
+GL_PREFIX(PixelMapusv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2024(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2024(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2024(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2024(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PixelMapusv), .-GL_PREFIX(PixelMapusv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ReadBuffer)
+ .type GL_PREFIX(ReadBuffer), @function
+GL_PREFIX(ReadBuffer):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2032(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2032(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2032(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2032(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ReadBuffer), .-GL_PREFIX(ReadBuffer)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CopyPixels)
+ .type GL_PREFIX(CopyPixels), @function
+GL_PREFIX(CopyPixels):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2040(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2040(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2040(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2040(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CopyPixels), .-GL_PREFIX(CopyPixels)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ReadPixels)
+ .type GL_PREFIX(ReadPixels), @function
+GL_PREFIX(ReadPixels):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2048(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2048(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2048(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2048(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ReadPixels), .-GL_PREFIX(ReadPixels)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DrawPixels)
+ .type GL_PREFIX(DrawPixels), @function
+GL_PREFIX(DrawPixels):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2056(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2056(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2056(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2056(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DrawPixels), .-GL_PREFIX(DrawPixels)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetBooleanv)
+ .type GL_PREFIX(GetBooleanv), @function
+GL_PREFIX(GetBooleanv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2064(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2064(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2064(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2064(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetBooleanv), .-GL_PREFIX(GetBooleanv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetClipPlane)
+ .type GL_PREFIX(GetClipPlane), @function
+GL_PREFIX(GetClipPlane):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2072(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2072(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2072(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2072(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetClipPlane), .-GL_PREFIX(GetClipPlane)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetDoublev)
+ .type GL_PREFIX(GetDoublev), @function
+GL_PREFIX(GetDoublev):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2080(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2080(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2080(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2080(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetDoublev), .-GL_PREFIX(GetDoublev)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetError)
+ .type GL_PREFIX(GetError), @function
+GL_PREFIX(GetError):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2088(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 2088(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2088(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 2088(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetError), .-GL_PREFIX(GetError)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetFloatv)
+ .type GL_PREFIX(GetFloatv), @function
+GL_PREFIX(GetFloatv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2096(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2096(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2096(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2096(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetFloatv), .-GL_PREFIX(GetFloatv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetIntegerv)
+ .type GL_PREFIX(GetIntegerv), @function
+GL_PREFIX(GetIntegerv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2104(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2104(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2104(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2104(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetIntegerv), .-GL_PREFIX(GetIntegerv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetLightfv)
+ .type GL_PREFIX(GetLightfv), @function
+GL_PREFIX(GetLightfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2112(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2112(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2112(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2112(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetLightfv), .-GL_PREFIX(GetLightfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetLightiv)
+ .type GL_PREFIX(GetLightiv), @function
+GL_PREFIX(GetLightiv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2120(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2120(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2120(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2120(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetLightiv), .-GL_PREFIX(GetLightiv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetMapdv)
+ .type GL_PREFIX(GetMapdv), @function
+GL_PREFIX(GetMapdv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2128(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2128(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2128(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2128(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetMapdv), .-GL_PREFIX(GetMapdv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetMapfv)
+ .type GL_PREFIX(GetMapfv), @function
+GL_PREFIX(GetMapfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2136(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2136(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2136(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2136(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetMapfv), .-GL_PREFIX(GetMapfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetMapiv)
+ .type GL_PREFIX(GetMapiv), @function
+GL_PREFIX(GetMapiv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2144(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2144(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2144(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2144(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetMapiv), .-GL_PREFIX(GetMapiv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetMaterialfv)
+ .type GL_PREFIX(GetMaterialfv), @function
+GL_PREFIX(GetMaterialfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2152(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2152(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2152(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2152(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetMaterialfv), .-GL_PREFIX(GetMaterialfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetMaterialiv)
+ .type GL_PREFIX(GetMaterialiv), @function
+GL_PREFIX(GetMaterialiv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2160(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2160(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2160(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2160(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetMaterialiv), .-GL_PREFIX(GetMaterialiv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetPixelMapfv)
+ .type GL_PREFIX(GetPixelMapfv), @function
+GL_PREFIX(GetPixelMapfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2168(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2168(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2168(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2168(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetPixelMapfv), .-GL_PREFIX(GetPixelMapfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetPixelMapuiv)
+ .type GL_PREFIX(GetPixelMapuiv), @function
+GL_PREFIX(GetPixelMapuiv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2176(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2176(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2176(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2176(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetPixelMapuiv), .-GL_PREFIX(GetPixelMapuiv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetPixelMapusv)
+ .type GL_PREFIX(GetPixelMapusv), @function
+GL_PREFIX(GetPixelMapusv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2184(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2184(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2184(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2184(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetPixelMapusv), .-GL_PREFIX(GetPixelMapusv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetPolygonStipple)
+ .type GL_PREFIX(GetPolygonStipple), @function
+GL_PREFIX(GetPolygonStipple):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2192(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2192(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2192(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2192(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetPolygonStipple), .-GL_PREFIX(GetPolygonStipple)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetString)
+ .type GL_PREFIX(GetString), @function
+GL_PREFIX(GetString):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2200(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2200(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2200(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2200(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetString), .-GL_PREFIX(GetString)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetTexEnvfv)
+ .type GL_PREFIX(GetTexEnvfv), @function
+GL_PREFIX(GetTexEnvfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2208(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2208(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2208(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2208(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetTexEnvfv), .-GL_PREFIX(GetTexEnvfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetTexEnviv)
+ .type GL_PREFIX(GetTexEnviv), @function
+GL_PREFIX(GetTexEnviv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2216(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2216(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2216(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2216(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetTexEnviv), .-GL_PREFIX(GetTexEnviv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetTexGendv)
+ .type GL_PREFIX(GetTexGendv), @function
+GL_PREFIX(GetTexGendv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2224(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2224(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2224(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2224(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetTexGendv), .-GL_PREFIX(GetTexGendv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetTexGenfv)
+ .type GL_PREFIX(GetTexGenfv), @function
+GL_PREFIX(GetTexGenfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2232(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2232(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2232(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2232(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetTexGenfv), .-GL_PREFIX(GetTexGenfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetTexGeniv)
+ .type GL_PREFIX(GetTexGeniv), @function
+GL_PREFIX(GetTexGeniv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2240(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2240(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2240(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2240(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetTexGeniv), .-GL_PREFIX(GetTexGeniv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetTexImage)
+ .type GL_PREFIX(GetTexImage), @function
+GL_PREFIX(GetTexImage):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2248(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2248(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2248(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2248(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetTexImage), .-GL_PREFIX(GetTexImage)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetTexParameterfv)
+ .type GL_PREFIX(GetTexParameterfv), @function
+GL_PREFIX(GetTexParameterfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2256(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2256(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2256(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2256(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetTexParameterfv), .-GL_PREFIX(GetTexParameterfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetTexParameteriv)
+ .type GL_PREFIX(GetTexParameteriv), @function
+GL_PREFIX(GetTexParameteriv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2264(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2264(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2264(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2264(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetTexParameteriv), .-GL_PREFIX(GetTexParameteriv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetTexLevelParameterfv)
+ .type GL_PREFIX(GetTexLevelParameterfv), @function
+GL_PREFIX(GetTexLevelParameterfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2272(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2272(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2272(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2272(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetTexLevelParameterfv), .-GL_PREFIX(GetTexLevelParameterfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetTexLevelParameteriv)
+ .type GL_PREFIX(GetTexLevelParameteriv), @function
+GL_PREFIX(GetTexLevelParameteriv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2280(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2280(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2280(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2280(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetTexLevelParameteriv), .-GL_PREFIX(GetTexLevelParameteriv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(IsEnabled)
+ .type GL_PREFIX(IsEnabled), @function
+GL_PREFIX(IsEnabled):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2288(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2288(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2288(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2288(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(IsEnabled), .-GL_PREFIX(IsEnabled)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(IsList)
+ .type GL_PREFIX(IsList), @function
+GL_PREFIX(IsList):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2296(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2296(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2296(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2296(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(IsList), .-GL_PREFIX(IsList)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DepthRange)
+ .type GL_PREFIX(DepthRange), @function
+GL_PREFIX(DepthRange):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2304(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2304(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2304(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2304(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DepthRange), .-GL_PREFIX(DepthRange)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Frustum)
+ .type GL_PREFIX(Frustum), @function
+GL_PREFIX(Frustum):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2312(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $56, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ movq %xmm4, 32(%rsp)
+ movq %xmm5, 40(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 40(%rsp), %xmm5
+ movq 32(%rsp), %xmm4
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $56, %rsp
+ movq 2312(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2312(%rax), %r11
+ jmp *%r11
+1:
+ subq $56, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ movq %xmm4, 32(%rsp)
+ movq %xmm5, 40(%rsp)
+ call _glapi_get_dispatch
+ movq 40(%rsp), %xmm5
+ movq 32(%rsp), %xmm4
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $56, %rsp
+ movq 2312(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Frustum), .-GL_PREFIX(Frustum)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(LoadIdentity)
+ .type GL_PREFIX(LoadIdentity), @function
+GL_PREFIX(LoadIdentity):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2320(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 2320(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2320(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 2320(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(LoadIdentity), .-GL_PREFIX(LoadIdentity)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(LoadMatrixf)
+ .type GL_PREFIX(LoadMatrixf), @function
+GL_PREFIX(LoadMatrixf):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2328(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2328(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2328(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2328(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(LoadMatrixf), .-GL_PREFIX(LoadMatrixf)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(LoadMatrixd)
+ .type GL_PREFIX(LoadMatrixd), @function
+GL_PREFIX(LoadMatrixd):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2336(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2336(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2336(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2336(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(LoadMatrixd), .-GL_PREFIX(LoadMatrixd)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MatrixMode)
+ .type GL_PREFIX(MatrixMode), @function
+GL_PREFIX(MatrixMode):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2344(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2344(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2344(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2344(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MatrixMode), .-GL_PREFIX(MatrixMode)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultMatrixf)
+ .type GL_PREFIX(MultMatrixf), @function
+GL_PREFIX(MultMatrixf):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2352(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2352(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2352(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2352(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultMatrixf), .-GL_PREFIX(MultMatrixf)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultMatrixd)
+ .type GL_PREFIX(MultMatrixd), @function
+GL_PREFIX(MultMatrixd):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2360(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2360(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2360(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2360(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultMatrixd), .-GL_PREFIX(MultMatrixd)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Ortho)
+ .type GL_PREFIX(Ortho), @function
+GL_PREFIX(Ortho):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2368(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $56, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ movq %xmm4, 32(%rsp)
+ movq %xmm5, 40(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 40(%rsp), %xmm5
+ movq 32(%rsp), %xmm4
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $56, %rsp
+ movq 2368(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2368(%rax), %r11
+ jmp *%r11
+1:
+ subq $56, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ movq %xmm4, 32(%rsp)
+ movq %xmm5, 40(%rsp)
+ call _glapi_get_dispatch
+ movq 40(%rsp), %xmm5
+ movq 32(%rsp), %xmm4
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $56, %rsp
+ movq 2368(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Ortho), .-GL_PREFIX(Ortho)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PopMatrix)
+ .type GL_PREFIX(PopMatrix), @function
+GL_PREFIX(PopMatrix):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2376(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 2376(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2376(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 2376(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PopMatrix), .-GL_PREFIX(PopMatrix)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PushMatrix)
+ .type GL_PREFIX(PushMatrix), @function
+GL_PREFIX(PushMatrix):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2384(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 2384(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2384(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 2384(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PushMatrix), .-GL_PREFIX(PushMatrix)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Rotated)
+ .type GL_PREFIX(Rotated), @function
+GL_PREFIX(Rotated):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2392(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 2392(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2392(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 2392(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Rotated), .-GL_PREFIX(Rotated)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Rotatef)
+ .type GL_PREFIX(Rotatef), @function
+GL_PREFIX(Rotatef):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2400(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 2400(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2400(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 2400(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Rotatef), .-GL_PREFIX(Rotatef)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Scaled)
+ .type GL_PREFIX(Scaled), @function
+GL_PREFIX(Scaled):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2408(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 2408(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2408(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 2408(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Scaled), .-GL_PREFIX(Scaled)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Scalef)
+ .type GL_PREFIX(Scalef), @function
+GL_PREFIX(Scalef):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2416(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 2416(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2416(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 2416(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Scalef), .-GL_PREFIX(Scalef)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Translated)
+ .type GL_PREFIX(Translated), @function
+GL_PREFIX(Translated):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2424(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 2424(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2424(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 2424(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Translated), .-GL_PREFIX(Translated)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Translatef)
+ .type GL_PREFIX(Translatef), @function
+GL_PREFIX(Translatef):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2432(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 2432(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2432(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 2432(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Translatef), .-GL_PREFIX(Translatef)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Viewport)
+ .type GL_PREFIX(Viewport), @function
+GL_PREFIX(Viewport):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2440(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2440(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2440(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2440(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Viewport), .-GL_PREFIX(Viewport)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ArrayElement)
+ .type GL_PREFIX(ArrayElement), @function
+GL_PREFIX(ArrayElement):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2448(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2448(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2448(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2448(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ArrayElement), .-GL_PREFIX(ArrayElement)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(BindTexture)
+ .type GL_PREFIX(BindTexture), @function
+GL_PREFIX(BindTexture):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2456(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2456(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2456(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2456(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(BindTexture), .-GL_PREFIX(BindTexture)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ColorPointer)
+ .type GL_PREFIX(ColorPointer), @function
+GL_PREFIX(ColorPointer):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2464(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2464(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2464(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2464(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ColorPointer), .-GL_PREFIX(ColorPointer)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DisableClientState)
+ .type GL_PREFIX(DisableClientState), @function
+GL_PREFIX(DisableClientState):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2472(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2472(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2472(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2472(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DisableClientState), .-GL_PREFIX(DisableClientState)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DrawArrays)
+ .type GL_PREFIX(DrawArrays), @function
+GL_PREFIX(DrawArrays):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2480(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2480(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2480(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2480(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DrawArrays), .-GL_PREFIX(DrawArrays)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DrawElements)
+ .type GL_PREFIX(DrawElements), @function
+GL_PREFIX(DrawElements):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2488(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2488(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2488(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2488(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DrawElements), .-GL_PREFIX(DrawElements)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EdgeFlagPointer)
+ .type GL_PREFIX(EdgeFlagPointer), @function
+GL_PREFIX(EdgeFlagPointer):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2496(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2496(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2496(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2496(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EdgeFlagPointer), .-GL_PREFIX(EdgeFlagPointer)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EnableClientState)
+ .type GL_PREFIX(EnableClientState), @function
+GL_PREFIX(EnableClientState):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2504(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2504(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2504(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2504(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EnableClientState), .-GL_PREFIX(EnableClientState)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(IndexPointer)
+ .type GL_PREFIX(IndexPointer), @function
+GL_PREFIX(IndexPointer):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2512(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2512(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2512(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2512(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(IndexPointer), .-GL_PREFIX(IndexPointer)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Indexub)
+ .type GL_PREFIX(Indexub), @function
+GL_PREFIX(Indexub):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2520(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2520(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2520(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2520(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Indexub), .-GL_PREFIX(Indexub)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Indexubv)
+ .type GL_PREFIX(Indexubv), @function
+GL_PREFIX(Indexubv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2528(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2528(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2528(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2528(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Indexubv), .-GL_PREFIX(Indexubv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(InterleavedArrays)
+ .type GL_PREFIX(InterleavedArrays), @function
+GL_PREFIX(InterleavedArrays):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2536(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2536(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2536(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2536(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(InterleavedArrays), .-GL_PREFIX(InterleavedArrays)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(NormalPointer)
+ .type GL_PREFIX(NormalPointer), @function
+GL_PREFIX(NormalPointer):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2544(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2544(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2544(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2544(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(NormalPointer), .-GL_PREFIX(NormalPointer)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PolygonOffset)
+ .type GL_PREFIX(PolygonOffset), @function
+GL_PREFIX(PolygonOffset):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2552(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 2552(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2552(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 2552(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PolygonOffset), .-GL_PREFIX(PolygonOffset)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoordPointer)
+ .type GL_PREFIX(TexCoordPointer), @function
+GL_PREFIX(TexCoordPointer):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2560(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2560(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2560(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2560(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoordPointer), .-GL_PREFIX(TexCoordPointer)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexPointer)
+ .type GL_PREFIX(VertexPointer), @function
+GL_PREFIX(VertexPointer):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2568(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2568(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2568(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2568(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexPointer), .-GL_PREFIX(VertexPointer)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(AreTexturesResident)
+ .type GL_PREFIX(AreTexturesResident), @function
+GL_PREFIX(AreTexturesResident):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2576(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2576(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2576(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2576(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(AreTexturesResident), .-GL_PREFIX(AreTexturesResident)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CopyTexImage1D)
+ .type GL_PREFIX(CopyTexImage1D), @function
+GL_PREFIX(CopyTexImage1D):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2584(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2584(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2584(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2584(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CopyTexImage1D), .-GL_PREFIX(CopyTexImage1D)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CopyTexImage2D)
+ .type GL_PREFIX(CopyTexImage2D), @function
+GL_PREFIX(CopyTexImage2D):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2592(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2592(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2592(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2592(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CopyTexImage2D), .-GL_PREFIX(CopyTexImage2D)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CopyTexSubImage1D)
+ .type GL_PREFIX(CopyTexSubImage1D), @function
+GL_PREFIX(CopyTexSubImage1D):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2600(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2600(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2600(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2600(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CopyTexSubImage1D), .-GL_PREFIX(CopyTexSubImage1D)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CopyTexSubImage2D)
+ .type GL_PREFIX(CopyTexSubImage2D), @function
+GL_PREFIX(CopyTexSubImage2D):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2608(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2608(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2608(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2608(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CopyTexSubImage2D), .-GL_PREFIX(CopyTexSubImage2D)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DeleteTextures)
+ .type GL_PREFIX(DeleteTextures), @function
+GL_PREFIX(DeleteTextures):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2616(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2616(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2616(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2616(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DeleteTextures), .-GL_PREFIX(DeleteTextures)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GenTextures)
+ .type GL_PREFIX(GenTextures), @function
+GL_PREFIX(GenTextures):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2624(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2624(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2624(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2624(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GenTextures), .-GL_PREFIX(GenTextures)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetPointerv)
+ .type GL_PREFIX(GetPointerv), @function
+GL_PREFIX(GetPointerv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2632(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2632(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2632(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 2632(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetPointerv), .-GL_PREFIX(GetPointerv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(IsTexture)
+ .type GL_PREFIX(IsTexture), @function
+GL_PREFIX(IsTexture):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2640(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2640(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2640(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2640(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(IsTexture), .-GL_PREFIX(IsTexture)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PrioritizeTextures)
+ .type GL_PREFIX(PrioritizeTextures), @function
+GL_PREFIX(PrioritizeTextures):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2648(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2648(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2648(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2648(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PrioritizeTextures), .-GL_PREFIX(PrioritizeTextures)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexSubImage1D)
+ .type GL_PREFIX(TexSubImage1D), @function
+GL_PREFIX(TexSubImage1D):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2656(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2656(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2656(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2656(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexSubImage1D), .-GL_PREFIX(TexSubImage1D)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexSubImage2D)
+ .type GL_PREFIX(TexSubImage2D), @function
+GL_PREFIX(TexSubImage2D):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2664(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2664(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2664(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2664(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexSubImage2D), .-GL_PREFIX(TexSubImage2D)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PopClientAttrib)
+ .type GL_PREFIX(PopClientAttrib), @function
+GL_PREFIX(PopClientAttrib):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2672(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 2672(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2672(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 2672(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PopClientAttrib), .-GL_PREFIX(PopClientAttrib)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PushClientAttrib)
+ .type GL_PREFIX(PushClientAttrib), @function
+GL_PREFIX(PushClientAttrib):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2680(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2680(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2680(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2680(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PushClientAttrib), .-GL_PREFIX(PushClientAttrib)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(BlendColor)
+ .type GL_PREFIX(BlendColor), @function
+GL_PREFIX(BlendColor):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2688(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2688(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2688(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2688(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(BlendColor), .-GL_PREFIX(BlendColor)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(BlendEquation)
+ .type GL_PREFIX(BlendEquation), @function
+GL_PREFIX(BlendEquation):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2696(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2696(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2696(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2696(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(BlendEquation), .-GL_PREFIX(BlendEquation)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DrawRangeElements)
+ .type GL_PREFIX(DrawRangeElements), @function
+GL_PREFIX(DrawRangeElements):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2704(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2704(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2704(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2704(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DrawRangeElements), .-GL_PREFIX(DrawRangeElements)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ColorTable)
+ .type GL_PREFIX(ColorTable), @function
+GL_PREFIX(ColorTable):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2712(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2712(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2712(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2712(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ColorTable), .-GL_PREFIX(ColorTable)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ColorTableParameterfv)
+ .type GL_PREFIX(ColorTableParameterfv), @function
+GL_PREFIX(ColorTableParameterfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2720(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2720(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2720(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2720(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ColorTableParameterfv), .-GL_PREFIX(ColorTableParameterfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ColorTableParameteriv)
+ .type GL_PREFIX(ColorTableParameteriv), @function
+GL_PREFIX(ColorTableParameteriv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2728(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2728(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2728(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2728(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ColorTableParameteriv), .-GL_PREFIX(ColorTableParameteriv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CopyColorTable)
+ .type GL_PREFIX(CopyColorTable), @function
+GL_PREFIX(CopyColorTable):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2736(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2736(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2736(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2736(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CopyColorTable), .-GL_PREFIX(CopyColorTable)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetColorTable)
+ .type GL_PREFIX(GetColorTable), @function
+GL_PREFIX(GetColorTable):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2744(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2744(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2744(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2744(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetColorTable), .-GL_PREFIX(GetColorTable)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetColorTableParameterfv)
+ .type GL_PREFIX(GetColorTableParameterfv), @function
+GL_PREFIX(GetColorTableParameterfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2752(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2752(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2752(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2752(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetColorTableParameterfv), .-GL_PREFIX(GetColorTableParameterfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetColorTableParameteriv)
+ .type GL_PREFIX(GetColorTableParameteriv), @function
+GL_PREFIX(GetColorTableParameteriv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2760(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2760(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2760(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2760(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetColorTableParameteriv), .-GL_PREFIX(GetColorTableParameteriv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ColorSubTable)
+ .type GL_PREFIX(ColorSubTable), @function
+GL_PREFIX(ColorSubTable):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2768(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2768(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2768(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2768(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ColorSubTable), .-GL_PREFIX(ColorSubTable)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CopyColorSubTable)
+ .type GL_PREFIX(CopyColorSubTable), @function
+GL_PREFIX(CopyColorSubTable):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2776(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2776(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2776(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2776(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CopyColorSubTable), .-GL_PREFIX(CopyColorSubTable)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ConvolutionFilter1D)
+ .type GL_PREFIX(ConvolutionFilter1D), @function
+GL_PREFIX(ConvolutionFilter1D):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2784(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2784(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2784(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2784(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ConvolutionFilter1D), .-GL_PREFIX(ConvolutionFilter1D)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ConvolutionFilter2D)
+ .type GL_PREFIX(ConvolutionFilter2D), @function
+GL_PREFIX(ConvolutionFilter2D):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2792(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2792(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2792(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2792(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ConvolutionFilter2D), .-GL_PREFIX(ConvolutionFilter2D)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ConvolutionParameterf)
+ .type GL_PREFIX(ConvolutionParameterf), @function
+GL_PREFIX(ConvolutionParameterf):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2800(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 2800(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2800(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 2800(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ConvolutionParameterf), .-GL_PREFIX(ConvolutionParameterf)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ConvolutionParameterfv)
+ .type GL_PREFIX(ConvolutionParameterfv), @function
+GL_PREFIX(ConvolutionParameterfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2808(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2808(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2808(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2808(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ConvolutionParameterfv), .-GL_PREFIX(ConvolutionParameterfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ConvolutionParameteri)
+ .type GL_PREFIX(ConvolutionParameteri), @function
+GL_PREFIX(ConvolutionParameteri):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2816(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2816(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2816(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2816(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ConvolutionParameteri), .-GL_PREFIX(ConvolutionParameteri)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ConvolutionParameteriv)
+ .type GL_PREFIX(ConvolutionParameteriv), @function
+GL_PREFIX(ConvolutionParameteriv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2824(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2824(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2824(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2824(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ConvolutionParameteriv), .-GL_PREFIX(ConvolutionParameteriv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CopyConvolutionFilter1D)
+ .type GL_PREFIX(CopyConvolutionFilter1D), @function
+GL_PREFIX(CopyConvolutionFilter1D):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2832(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2832(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2832(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2832(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CopyConvolutionFilter1D), .-GL_PREFIX(CopyConvolutionFilter1D)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CopyConvolutionFilter2D)
+ .type GL_PREFIX(CopyConvolutionFilter2D), @function
+GL_PREFIX(CopyConvolutionFilter2D):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2840(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2840(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2840(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2840(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CopyConvolutionFilter2D), .-GL_PREFIX(CopyConvolutionFilter2D)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetConvolutionFilter)
+ .type GL_PREFIX(GetConvolutionFilter), @function
+GL_PREFIX(GetConvolutionFilter):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2848(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2848(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2848(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2848(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetConvolutionFilter), .-GL_PREFIX(GetConvolutionFilter)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetConvolutionParameterfv)
+ .type GL_PREFIX(GetConvolutionParameterfv), @function
+GL_PREFIX(GetConvolutionParameterfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2856(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2856(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2856(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2856(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetConvolutionParameterfv), .-GL_PREFIX(GetConvolutionParameterfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetConvolutionParameteriv)
+ .type GL_PREFIX(GetConvolutionParameteriv), @function
+GL_PREFIX(GetConvolutionParameteriv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2864(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2864(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2864(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2864(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetConvolutionParameteriv), .-GL_PREFIX(GetConvolutionParameteriv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetSeparableFilter)
+ .type GL_PREFIX(GetSeparableFilter), @function
+GL_PREFIX(GetSeparableFilter):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2872(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2872(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2872(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2872(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetSeparableFilter), .-GL_PREFIX(GetSeparableFilter)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SeparableFilter2D)
+ .type GL_PREFIX(SeparableFilter2D), @function
+GL_PREFIX(SeparableFilter2D):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2880(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2880(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2880(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2880(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SeparableFilter2D), .-GL_PREFIX(SeparableFilter2D)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetHistogram)
+ .type GL_PREFIX(GetHistogram), @function
+GL_PREFIX(GetHistogram):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2888(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2888(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2888(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2888(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetHistogram), .-GL_PREFIX(GetHistogram)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetHistogramParameterfv)
+ .type GL_PREFIX(GetHistogramParameterfv), @function
+GL_PREFIX(GetHistogramParameterfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2896(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2896(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2896(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2896(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetHistogramParameterfv), .-GL_PREFIX(GetHistogramParameterfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetHistogramParameteriv)
+ .type GL_PREFIX(GetHistogramParameteriv), @function
+GL_PREFIX(GetHistogramParameteriv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2904(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2904(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2904(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2904(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetHistogramParameteriv), .-GL_PREFIX(GetHistogramParameteriv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetMinmax)
+ .type GL_PREFIX(GetMinmax), @function
+GL_PREFIX(GetMinmax):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2912(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2912(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2912(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2912(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetMinmax), .-GL_PREFIX(GetMinmax)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetMinmaxParameterfv)
+ .type GL_PREFIX(GetMinmaxParameterfv), @function
+GL_PREFIX(GetMinmaxParameterfv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2920(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2920(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2920(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2920(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetMinmaxParameterfv), .-GL_PREFIX(GetMinmaxParameterfv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetMinmaxParameteriv)
+ .type GL_PREFIX(GetMinmaxParameteriv), @function
+GL_PREFIX(GetMinmaxParameteriv):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2928(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2928(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2928(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2928(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetMinmaxParameteriv), .-GL_PREFIX(GetMinmaxParameteriv)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Histogram)
+ .type GL_PREFIX(Histogram), @function
+GL_PREFIX(Histogram):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2936(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2936(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2936(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2936(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Histogram), .-GL_PREFIX(Histogram)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Minmax)
+ .type GL_PREFIX(Minmax), @function
+GL_PREFIX(Minmax):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2944(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2944(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2944(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2944(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Minmax), .-GL_PREFIX(Minmax)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ResetHistogram)
+ .type GL_PREFIX(ResetHistogram), @function
+GL_PREFIX(ResetHistogram):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2952(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2952(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2952(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2952(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ResetHistogram), .-GL_PREFIX(ResetHistogram)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ResetMinmax)
+ .type GL_PREFIX(ResetMinmax), @function
+GL_PREFIX(ResetMinmax):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2960(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2960(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2960(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2960(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ResetMinmax), .-GL_PREFIX(ResetMinmax)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexImage3D)
+ .type GL_PREFIX(TexImage3D), @function
+GL_PREFIX(TexImage3D):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2968(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2968(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2968(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2968(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexImage3D), .-GL_PREFIX(TexImage3D)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexSubImage3D)
+ .type GL_PREFIX(TexSubImage3D), @function
+GL_PREFIX(TexSubImage3D):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2976(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2976(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2976(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2976(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexSubImage3D), .-GL_PREFIX(TexSubImage3D)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CopyTexSubImage3D)
+ .type GL_PREFIX(CopyTexSubImage3D), @function
+GL_PREFIX(CopyTexSubImage3D):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2984(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2984(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2984(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 2984(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CopyTexSubImage3D), .-GL_PREFIX(CopyTexSubImage3D)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ActiveTextureARB)
+ .type GL_PREFIX(ActiveTextureARB), @function
+GL_PREFIX(ActiveTextureARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 2992(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 2992(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 2992(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 2992(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ActiveTextureARB), .-GL_PREFIX(ActiveTextureARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ClientActiveTextureARB)
+ .type GL_PREFIX(ClientActiveTextureARB), @function
+GL_PREFIX(ClientActiveTextureARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3000(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 3000(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3000(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 3000(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ClientActiveTextureARB), .-GL_PREFIX(ClientActiveTextureARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord1dARB)
+ .type GL_PREFIX(MultiTexCoord1dARB), @function
+GL_PREFIX(MultiTexCoord1dARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3008(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3008(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3008(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3008(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord1dARB), .-GL_PREFIX(MultiTexCoord1dARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord1dvARB)
+ .type GL_PREFIX(MultiTexCoord1dvARB), @function
+GL_PREFIX(MultiTexCoord1dvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3016(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3016(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3016(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3016(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord1dvARB), .-GL_PREFIX(MultiTexCoord1dvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord1fARB)
+ .type GL_PREFIX(MultiTexCoord1fARB), @function
+GL_PREFIX(MultiTexCoord1fARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3024(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3024(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3024(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3024(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord1fARB), .-GL_PREFIX(MultiTexCoord1fARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord1fvARB)
+ .type GL_PREFIX(MultiTexCoord1fvARB), @function
+GL_PREFIX(MultiTexCoord1fvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3032(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3032(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3032(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3032(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord1fvARB), .-GL_PREFIX(MultiTexCoord1fvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord1iARB)
+ .type GL_PREFIX(MultiTexCoord1iARB), @function
+GL_PREFIX(MultiTexCoord1iARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3040(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3040(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3040(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3040(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord1iARB), .-GL_PREFIX(MultiTexCoord1iARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord1ivARB)
+ .type GL_PREFIX(MultiTexCoord1ivARB), @function
+GL_PREFIX(MultiTexCoord1ivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3048(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3048(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3048(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3048(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord1ivARB), .-GL_PREFIX(MultiTexCoord1ivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord1sARB)
+ .type GL_PREFIX(MultiTexCoord1sARB), @function
+GL_PREFIX(MultiTexCoord1sARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3056(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3056(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3056(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3056(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord1sARB), .-GL_PREFIX(MultiTexCoord1sARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord1svARB)
+ .type GL_PREFIX(MultiTexCoord1svARB), @function
+GL_PREFIX(MultiTexCoord1svARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3064(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3064(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3064(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3064(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord1svARB), .-GL_PREFIX(MultiTexCoord1svARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord2dARB)
+ .type GL_PREFIX(MultiTexCoord2dARB), @function
+GL_PREFIX(MultiTexCoord2dARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3072(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3072(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3072(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3072(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord2dARB), .-GL_PREFIX(MultiTexCoord2dARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord2dvARB)
+ .type GL_PREFIX(MultiTexCoord2dvARB), @function
+GL_PREFIX(MultiTexCoord2dvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3080(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3080(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3080(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3080(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord2dvARB), .-GL_PREFIX(MultiTexCoord2dvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord2fARB)
+ .type GL_PREFIX(MultiTexCoord2fARB), @function
+GL_PREFIX(MultiTexCoord2fARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3088(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3088(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3088(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3088(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord2fARB), .-GL_PREFIX(MultiTexCoord2fARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord2fvARB)
+ .type GL_PREFIX(MultiTexCoord2fvARB), @function
+GL_PREFIX(MultiTexCoord2fvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3096(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3096(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3096(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3096(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord2fvARB), .-GL_PREFIX(MultiTexCoord2fvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord2iARB)
+ .type GL_PREFIX(MultiTexCoord2iARB), @function
+GL_PREFIX(MultiTexCoord2iARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3104(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3104(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3104(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3104(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord2iARB), .-GL_PREFIX(MultiTexCoord2iARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord2ivARB)
+ .type GL_PREFIX(MultiTexCoord2ivARB), @function
+GL_PREFIX(MultiTexCoord2ivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3112(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3112(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3112(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3112(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord2ivARB), .-GL_PREFIX(MultiTexCoord2ivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord2sARB)
+ .type GL_PREFIX(MultiTexCoord2sARB), @function
+GL_PREFIX(MultiTexCoord2sARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3120(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3120(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3120(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3120(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord2sARB), .-GL_PREFIX(MultiTexCoord2sARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord2svARB)
+ .type GL_PREFIX(MultiTexCoord2svARB), @function
+GL_PREFIX(MultiTexCoord2svARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3128(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3128(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3128(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3128(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord2svARB), .-GL_PREFIX(MultiTexCoord2svARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord3dARB)
+ .type GL_PREFIX(MultiTexCoord3dARB), @function
+GL_PREFIX(MultiTexCoord3dARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3136(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 3136(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3136(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 3136(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord3dARB), .-GL_PREFIX(MultiTexCoord3dARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord3dvARB)
+ .type GL_PREFIX(MultiTexCoord3dvARB), @function
+GL_PREFIX(MultiTexCoord3dvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3144(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3144(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3144(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3144(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord3dvARB), .-GL_PREFIX(MultiTexCoord3dvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord3fARB)
+ .type GL_PREFIX(MultiTexCoord3fARB), @function
+GL_PREFIX(MultiTexCoord3fARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3152(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 3152(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3152(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 3152(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord3fARB), .-GL_PREFIX(MultiTexCoord3fARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord3fvARB)
+ .type GL_PREFIX(MultiTexCoord3fvARB), @function
+GL_PREFIX(MultiTexCoord3fvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3160(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3160(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3160(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3160(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord3fvARB), .-GL_PREFIX(MultiTexCoord3fvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord3iARB)
+ .type GL_PREFIX(MultiTexCoord3iARB), @function
+GL_PREFIX(MultiTexCoord3iARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3168(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3168(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3168(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3168(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord3iARB), .-GL_PREFIX(MultiTexCoord3iARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord3ivARB)
+ .type GL_PREFIX(MultiTexCoord3ivARB), @function
+GL_PREFIX(MultiTexCoord3ivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3176(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3176(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3176(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3176(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord3ivARB), .-GL_PREFIX(MultiTexCoord3ivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord3sARB)
+ .type GL_PREFIX(MultiTexCoord3sARB), @function
+GL_PREFIX(MultiTexCoord3sARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3184(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3184(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3184(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3184(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord3sARB), .-GL_PREFIX(MultiTexCoord3sARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord3svARB)
+ .type GL_PREFIX(MultiTexCoord3svARB), @function
+GL_PREFIX(MultiTexCoord3svARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3192(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3192(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3192(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3192(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord3svARB), .-GL_PREFIX(MultiTexCoord3svARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord4dARB)
+ .type GL_PREFIX(MultiTexCoord4dARB), @function
+GL_PREFIX(MultiTexCoord4dARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3200(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ movq %xmm3, 32(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 32(%rsp), %xmm3
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 3200(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3200(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ movq %xmm3, 32(%rsp)
+ call _glapi_get_dispatch
+ movq 32(%rsp), %xmm3
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 3200(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord4dARB), .-GL_PREFIX(MultiTexCoord4dARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord4dvARB)
+ .type GL_PREFIX(MultiTexCoord4dvARB), @function
+GL_PREFIX(MultiTexCoord4dvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3208(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3208(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3208(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3208(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord4dvARB), .-GL_PREFIX(MultiTexCoord4dvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord4fARB)
+ .type GL_PREFIX(MultiTexCoord4fARB), @function
+GL_PREFIX(MultiTexCoord4fARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3216(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ movq %xmm3, 32(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 32(%rsp), %xmm3
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 3216(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3216(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ movq %xmm3, 32(%rsp)
+ call _glapi_get_dispatch
+ movq 32(%rsp), %xmm3
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 3216(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord4fARB), .-GL_PREFIX(MultiTexCoord4fARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord4fvARB)
+ .type GL_PREFIX(MultiTexCoord4fvARB), @function
+GL_PREFIX(MultiTexCoord4fvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3224(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3224(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3224(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3224(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord4fvARB), .-GL_PREFIX(MultiTexCoord4fvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord4iARB)
+ .type GL_PREFIX(MultiTexCoord4iARB), @function
+GL_PREFIX(MultiTexCoord4iARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3232(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3232(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3232(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3232(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord4iARB), .-GL_PREFIX(MultiTexCoord4iARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord4ivARB)
+ .type GL_PREFIX(MultiTexCoord4ivARB), @function
+GL_PREFIX(MultiTexCoord4ivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3240(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3240(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3240(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3240(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord4ivARB), .-GL_PREFIX(MultiTexCoord4ivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord4sARB)
+ .type GL_PREFIX(MultiTexCoord4sARB), @function
+GL_PREFIX(MultiTexCoord4sARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3248(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3248(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3248(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3248(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord4sARB), .-GL_PREFIX(MultiTexCoord4sARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiTexCoord4svARB)
+ .type GL_PREFIX(MultiTexCoord4svARB), @function
+GL_PREFIX(MultiTexCoord4svARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3256(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3256(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3256(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3256(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiTexCoord4svARB), .-GL_PREFIX(MultiTexCoord4svARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(LoadTransposeMatrixfARB)
+ .type GL_PREFIX(LoadTransposeMatrixfARB), @function
+GL_PREFIX(LoadTransposeMatrixfARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3264(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 3264(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3264(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 3264(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(LoadTransposeMatrixfARB), .-GL_PREFIX(LoadTransposeMatrixfARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(LoadTransposeMatrixdARB)
+ .type GL_PREFIX(LoadTransposeMatrixdARB), @function
+GL_PREFIX(LoadTransposeMatrixdARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3272(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 3272(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3272(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 3272(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(LoadTransposeMatrixdARB), .-GL_PREFIX(LoadTransposeMatrixdARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultTransposeMatrixfARB)
+ .type GL_PREFIX(MultTransposeMatrixfARB), @function
+GL_PREFIX(MultTransposeMatrixfARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3280(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 3280(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3280(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 3280(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultTransposeMatrixfARB), .-GL_PREFIX(MultTransposeMatrixfARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultTransposeMatrixdARB)
+ .type GL_PREFIX(MultTransposeMatrixdARB), @function
+GL_PREFIX(MultTransposeMatrixdARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3288(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 3288(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3288(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 3288(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultTransposeMatrixdARB), .-GL_PREFIX(MultTransposeMatrixdARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SampleCoverageARB)
+ .type GL_PREFIX(SampleCoverageARB), @function
+GL_PREFIX(SampleCoverageARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3296(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3296(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3296(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3296(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SampleCoverageARB), .-GL_PREFIX(SampleCoverageARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DrawBuffersARB)
+ .type GL_PREFIX(DrawBuffersARB), @function
+GL_PREFIX(DrawBuffersARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3304(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3304(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3304(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3304(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DrawBuffersARB), .-GL_PREFIX(DrawBuffersARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PolygonOffsetEXT)
+ .type GL_PREFIX(PolygonOffsetEXT), @function
+GL_PREFIX(PolygonOffsetEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3312(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 3312(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3312(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 3312(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PolygonOffsetEXT), .-GL_PREFIX(PolygonOffsetEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetTexFilterFuncSGIS)
+ .type GL_PREFIX(GetTexFilterFuncSGIS), @function
+GL_PREFIX(GetTexFilterFuncSGIS):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3320(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3320(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3320(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3320(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetTexFilterFuncSGIS), .-GL_PREFIX(GetTexFilterFuncSGIS)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexFilterFuncSGIS)
+ .type GL_PREFIX(TexFilterFuncSGIS), @function
+GL_PREFIX(TexFilterFuncSGIS):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3328(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3328(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3328(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3328(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexFilterFuncSGIS), .-GL_PREFIX(TexFilterFuncSGIS)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetHistogramEXT)
+ .type GL_PREFIX(GetHistogramEXT), @function
+GL_PREFIX(GetHistogramEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3336(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3336(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3336(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3336(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetHistogramEXT), .-GL_PREFIX(GetHistogramEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetHistogramParameterfvEXT)
+ .type GL_PREFIX(GetHistogramParameterfvEXT), @function
+GL_PREFIX(GetHistogramParameterfvEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3344(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3344(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3344(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3344(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetHistogramParameterfvEXT), .-GL_PREFIX(GetHistogramParameterfvEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetHistogramParameterivEXT)
+ .type GL_PREFIX(GetHistogramParameterivEXT), @function
+GL_PREFIX(GetHistogramParameterivEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3352(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3352(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3352(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3352(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetHistogramParameterivEXT), .-GL_PREFIX(GetHistogramParameterivEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetMinmaxEXT)
+ .type GL_PREFIX(GetMinmaxEXT), @function
+GL_PREFIX(GetMinmaxEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3360(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3360(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3360(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3360(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetMinmaxEXT), .-GL_PREFIX(GetMinmaxEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetMinmaxParameterfvEXT)
+ .type GL_PREFIX(GetMinmaxParameterfvEXT), @function
+GL_PREFIX(GetMinmaxParameterfvEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3368(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3368(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3368(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3368(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetMinmaxParameterfvEXT), .-GL_PREFIX(GetMinmaxParameterfvEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetMinmaxParameterivEXT)
+ .type GL_PREFIX(GetMinmaxParameterivEXT), @function
+GL_PREFIX(GetMinmaxParameterivEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3376(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3376(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3376(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3376(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetMinmaxParameterivEXT), .-GL_PREFIX(GetMinmaxParameterivEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetConvolutionFilterEXT)
+ .type GL_PREFIX(GetConvolutionFilterEXT), @function
+GL_PREFIX(GetConvolutionFilterEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3384(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3384(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3384(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3384(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetConvolutionFilterEXT), .-GL_PREFIX(GetConvolutionFilterEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetConvolutionParameterfvEXT)
+ .type GL_PREFIX(GetConvolutionParameterfvEXT), @function
+GL_PREFIX(GetConvolutionParameterfvEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3392(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3392(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3392(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3392(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetConvolutionParameterfvEXT), .-GL_PREFIX(GetConvolutionParameterfvEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetConvolutionParameterivEXT)
+ .type GL_PREFIX(GetConvolutionParameterivEXT), @function
+GL_PREFIX(GetConvolutionParameterivEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3400(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3400(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3400(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3400(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetConvolutionParameterivEXT), .-GL_PREFIX(GetConvolutionParameterivEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetSeparableFilterEXT)
+ .type GL_PREFIX(GetSeparableFilterEXT), @function
+GL_PREFIX(GetSeparableFilterEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3408(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3408(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3408(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3408(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetSeparableFilterEXT), .-GL_PREFIX(GetSeparableFilterEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetColorTableSGI)
+ .type GL_PREFIX(GetColorTableSGI), @function
+GL_PREFIX(GetColorTableSGI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3416(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3416(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3416(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3416(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetColorTableSGI), .-GL_PREFIX(GetColorTableSGI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetColorTableParameterfvSGI)
+ .type GL_PREFIX(GetColorTableParameterfvSGI), @function
+GL_PREFIX(GetColorTableParameterfvSGI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3424(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3424(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3424(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3424(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetColorTableParameterfvSGI), .-GL_PREFIX(GetColorTableParameterfvSGI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetColorTableParameterivSGI)
+ .type GL_PREFIX(GetColorTableParameterivSGI), @function
+GL_PREFIX(GetColorTableParameterivSGI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3432(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3432(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3432(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3432(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetColorTableParameterivSGI), .-GL_PREFIX(GetColorTableParameterivSGI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PixelTexGenSGIX)
+ .type GL_PREFIX(PixelTexGenSGIX), @function
+GL_PREFIX(PixelTexGenSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3440(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 3440(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3440(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 3440(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PixelTexGenSGIX), .-GL_PREFIX(PixelTexGenSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PixelTexGenParameteriSGIS)
+ .type GL_PREFIX(PixelTexGenParameteriSGIS), @function
+GL_PREFIX(PixelTexGenParameteriSGIS):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3448(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3448(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3448(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3448(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PixelTexGenParameteriSGIS), .-GL_PREFIX(PixelTexGenParameteriSGIS)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PixelTexGenParameterivSGIS)
+ .type GL_PREFIX(PixelTexGenParameterivSGIS), @function
+GL_PREFIX(PixelTexGenParameterivSGIS):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3456(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3456(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3456(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3456(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PixelTexGenParameterivSGIS), .-GL_PREFIX(PixelTexGenParameterivSGIS)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PixelTexGenParameterfSGIS)
+ .type GL_PREFIX(PixelTexGenParameterfSGIS), @function
+GL_PREFIX(PixelTexGenParameterfSGIS):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3464(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3464(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3464(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3464(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PixelTexGenParameterfSGIS), .-GL_PREFIX(PixelTexGenParameterfSGIS)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PixelTexGenParameterfvSGIS)
+ .type GL_PREFIX(PixelTexGenParameterfvSGIS), @function
+GL_PREFIX(PixelTexGenParameterfvSGIS):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3472(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3472(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3472(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3472(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PixelTexGenParameterfvSGIS), .-GL_PREFIX(PixelTexGenParameterfvSGIS)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetPixelTexGenParameterivSGIS)
+ .type GL_PREFIX(GetPixelTexGenParameterivSGIS), @function
+GL_PREFIX(GetPixelTexGenParameterivSGIS):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3480(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3480(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3480(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3480(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetPixelTexGenParameterivSGIS), .-GL_PREFIX(GetPixelTexGenParameterivSGIS)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetPixelTexGenParameterfvSGIS)
+ .type GL_PREFIX(GetPixelTexGenParameterfvSGIS), @function
+GL_PREFIX(GetPixelTexGenParameterfvSGIS):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3488(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3488(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3488(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3488(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetPixelTexGenParameterfvSGIS), .-GL_PREFIX(GetPixelTexGenParameterfvSGIS)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexImage4DSGIS)
+ .type GL_PREFIX(TexImage4DSGIS), @function
+GL_PREFIX(TexImage4DSGIS):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3496(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3496(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3496(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3496(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexImage4DSGIS), .-GL_PREFIX(TexImage4DSGIS)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexSubImage4DSGIS)
+ .type GL_PREFIX(TexSubImage4DSGIS), @function
+GL_PREFIX(TexSubImage4DSGIS):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3504(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3504(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3504(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3504(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexSubImage4DSGIS), .-GL_PREFIX(TexSubImage4DSGIS)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(AreTexturesResidentEXT)
+ .type GL_PREFIX(AreTexturesResidentEXT), @function
+GL_PREFIX(AreTexturesResidentEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3512(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3512(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3512(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3512(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(AreTexturesResidentEXT), .-GL_PREFIX(AreTexturesResidentEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GenTexturesEXT)
+ .type GL_PREFIX(GenTexturesEXT), @function
+GL_PREFIX(GenTexturesEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3520(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3520(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3520(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3520(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GenTexturesEXT), .-GL_PREFIX(GenTexturesEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(IsTextureEXT)
+ .type GL_PREFIX(IsTextureEXT), @function
+GL_PREFIX(IsTextureEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3528(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 3528(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3528(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 3528(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(IsTextureEXT), .-GL_PREFIX(IsTextureEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DetailTexFuncSGIS)
+ .type GL_PREFIX(DetailTexFuncSGIS), @function
+GL_PREFIX(DetailTexFuncSGIS):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3536(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3536(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3536(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3536(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DetailTexFuncSGIS), .-GL_PREFIX(DetailTexFuncSGIS)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetDetailTexFuncSGIS)
+ .type GL_PREFIX(GetDetailTexFuncSGIS), @function
+GL_PREFIX(GetDetailTexFuncSGIS):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3544(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3544(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3544(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3544(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetDetailTexFuncSGIS), .-GL_PREFIX(GetDetailTexFuncSGIS)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SharpenTexFuncSGIS)
+ .type GL_PREFIX(SharpenTexFuncSGIS), @function
+GL_PREFIX(SharpenTexFuncSGIS):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3552(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3552(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3552(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3552(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SharpenTexFuncSGIS), .-GL_PREFIX(SharpenTexFuncSGIS)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetSharpenTexFuncSGIS)
+ .type GL_PREFIX(GetSharpenTexFuncSGIS), @function
+GL_PREFIX(GetSharpenTexFuncSGIS):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3560(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3560(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3560(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3560(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetSharpenTexFuncSGIS), .-GL_PREFIX(GetSharpenTexFuncSGIS)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SampleMaskSGIS)
+ .type GL_PREFIX(SampleMaskSGIS), @function
+GL_PREFIX(SampleMaskSGIS):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3568(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3568(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3568(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3568(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SampleMaskSGIS), .-GL_PREFIX(SampleMaskSGIS)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SamplePatternSGIS)
+ .type GL_PREFIX(SamplePatternSGIS), @function
+GL_PREFIX(SamplePatternSGIS):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3576(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 3576(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3576(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 3576(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SamplePatternSGIS), .-GL_PREFIX(SamplePatternSGIS)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ColorPointerEXT)
+ .type GL_PREFIX(ColorPointerEXT), @function
+GL_PREFIX(ColorPointerEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3584(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3584(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3584(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3584(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ColorPointerEXT), .-GL_PREFIX(ColorPointerEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EdgeFlagPointerEXT)
+ .type GL_PREFIX(EdgeFlagPointerEXT), @function
+GL_PREFIX(EdgeFlagPointerEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3592(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3592(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3592(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3592(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EdgeFlagPointerEXT), .-GL_PREFIX(EdgeFlagPointerEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(IndexPointerEXT)
+ .type GL_PREFIX(IndexPointerEXT), @function
+GL_PREFIX(IndexPointerEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3600(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3600(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3600(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3600(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(IndexPointerEXT), .-GL_PREFIX(IndexPointerEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(NormalPointerEXT)
+ .type GL_PREFIX(NormalPointerEXT), @function
+GL_PREFIX(NormalPointerEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3608(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3608(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3608(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3608(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(NormalPointerEXT), .-GL_PREFIX(NormalPointerEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TexCoordPointerEXT)
+ .type GL_PREFIX(TexCoordPointerEXT), @function
+GL_PREFIX(TexCoordPointerEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3616(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3616(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3616(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3616(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TexCoordPointerEXT), .-GL_PREFIX(TexCoordPointerEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexPointerEXT)
+ .type GL_PREFIX(VertexPointerEXT), @function
+GL_PREFIX(VertexPointerEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3624(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3624(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3624(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3624(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexPointerEXT), .-GL_PREFIX(VertexPointerEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SpriteParameterfSGIX)
+ .type GL_PREFIX(SpriteParameterfSGIX), @function
+GL_PREFIX(SpriteParameterfSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3632(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3632(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3632(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3632(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SpriteParameterfSGIX), .-GL_PREFIX(SpriteParameterfSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SpriteParameterfvSGIX)
+ .type GL_PREFIX(SpriteParameterfvSGIX), @function
+GL_PREFIX(SpriteParameterfvSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3640(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3640(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3640(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3640(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SpriteParameterfvSGIX), .-GL_PREFIX(SpriteParameterfvSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SpriteParameteriSGIX)
+ .type GL_PREFIX(SpriteParameteriSGIX), @function
+GL_PREFIX(SpriteParameteriSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3648(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3648(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3648(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3648(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SpriteParameteriSGIX), .-GL_PREFIX(SpriteParameteriSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SpriteParameterivSGIX)
+ .type GL_PREFIX(SpriteParameterivSGIX), @function
+GL_PREFIX(SpriteParameterivSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3656(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3656(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3656(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3656(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SpriteParameterivSGIX), .-GL_PREFIX(SpriteParameterivSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PointParameterfEXT)
+ .type GL_PREFIX(PointParameterfEXT), @function
+GL_PREFIX(PointParameterfEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3664(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3664(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3664(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3664(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PointParameterfEXT), .-GL_PREFIX(PointParameterfEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PointParameterfvEXT)
+ .type GL_PREFIX(PointParameterfvEXT), @function
+GL_PREFIX(PointParameterfvEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3672(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3672(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3672(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3672(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PointParameterfvEXT), .-GL_PREFIX(PointParameterfvEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetInstrumentsSGIX)
+ .type GL_PREFIX(GetInstrumentsSGIX), @function
+GL_PREFIX(GetInstrumentsSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3680(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 3680(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3680(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 3680(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetInstrumentsSGIX), .-GL_PREFIX(GetInstrumentsSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(InstrumentsBufferSGIX)
+ .type GL_PREFIX(InstrumentsBufferSGIX), @function
+GL_PREFIX(InstrumentsBufferSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3688(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3688(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3688(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3688(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(InstrumentsBufferSGIX), .-GL_PREFIX(InstrumentsBufferSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PollInstrumentsSGIX)
+ .type GL_PREFIX(PollInstrumentsSGIX), @function
+GL_PREFIX(PollInstrumentsSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3696(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 3696(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3696(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 3696(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PollInstrumentsSGIX), .-GL_PREFIX(PollInstrumentsSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ReadInstrumentsSGIX)
+ .type GL_PREFIX(ReadInstrumentsSGIX), @function
+GL_PREFIX(ReadInstrumentsSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3704(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 3704(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3704(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 3704(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ReadInstrumentsSGIX), .-GL_PREFIX(ReadInstrumentsSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(StartInstrumentsSGIX)
+ .type GL_PREFIX(StartInstrumentsSGIX), @function
+GL_PREFIX(StartInstrumentsSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3712(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 3712(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3712(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 3712(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(StartInstrumentsSGIX), .-GL_PREFIX(StartInstrumentsSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(StopInstrumentsSGIX)
+ .type GL_PREFIX(StopInstrumentsSGIX), @function
+GL_PREFIX(StopInstrumentsSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3720(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 3720(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3720(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 3720(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(StopInstrumentsSGIX), .-GL_PREFIX(StopInstrumentsSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FrameZoomSGIX)
+ .type GL_PREFIX(FrameZoomSGIX), @function
+GL_PREFIX(FrameZoomSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3728(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 3728(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3728(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 3728(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FrameZoomSGIX), .-GL_PREFIX(FrameZoomSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TagSampleBufferSGIX)
+ .type GL_PREFIX(TagSampleBufferSGIX), @function
+GL_PREFIX(TagSampleBufferSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3736(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 3736(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3736(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 3736(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TagSampleBufferSGIX), .-GL_PREFIX(TagSampleBufferSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ReferencePlaneSGIX)
+ .type GL_PREFIX(ReferencePlaneSGIX), @function
+GL_PREFIX(ReferencePlaneSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3744(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 3744(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3744(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 3744(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ReferencePlaneSGIX), .-GL_PREFIX(ReferencePlaneSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FlushRasterSGIX)
+ .type GL_PREFIX(FlushRasterSGIX), @function
+GL_PREFIX(FlushRasterSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3752(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 3752(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3752(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 3752(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FlushRasterSGIX), .-GL_PREFIX(FlushRasterSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetListParameterfvSGIX)
+ .type GL_PREFIX(GetListParameterfvSGIX), @function
+GL_PREFIX(GetListParameterfvSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3760(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3760(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3760(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3760(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetListParameterfvSGIX), .-GL_PREFIX(GetListParameterfvSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetListParameterivSGIX)
+ .type GL_PREFIX(GetListParameterivSGIX), @function
+GL_PREFIX(GetListParameterivSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3768(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3768(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3768(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3768(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetListParameterivSGIX), .-GL_PREFIX(GetListParameterivSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ListParameterfSGIX)
+ .type GL_PREFIX(ListParameterfSGIX), @function
+GL_PREFIX(ListParameterfSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3776(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3776(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3776(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3776(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ListParameterfSGIX), .-GL_PREFIX(ListParameterfSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ListParameterfvSGIX)
+ .type GL_PREFIX(ListParameterfvSGIX), @function
+GL_PREFIX(ListParameterfvSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3784(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3784(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3784(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3784(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ListParameterfvSGIX), .-GL_PREFIX(ListParameterfvSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ListParameteriSGIX)
+ .type GL_PREFIX(ListParameteriSGIX), @function
+GL_PREFIX(ListParameteriSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3792(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3792(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3792(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3792(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ListParameteriSGIX), .-GL_PREFIX(ListParameteriSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ListParameterivSGIX)
+ .type GL_PREFIX(ListParameterivSGIX), @function
+GL_PREFIX(ListParameterivSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3800(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3800(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3800(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3800(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ListParameterivSGIX), .-GL_PREFIX(ListParameterivSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FragmentColorMaterialSGIX)
+ .type GL_PREFIX(FragmentColorMaterialSGIX), @function
+GL_PREFIX(FragmentColorMaterialSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3808(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3808(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3808(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3808(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FragmentColorMaterialSGIX), .-GL_PREFIX(FragmentColorMaterialSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FragmentLightfSGIX)
+ .type GL_PREFIX(FragmentLightfSGIX), @function
+GL_PREFIX(FragmentLightfSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3816(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3816(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3816(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3816(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FragmentLightfSGIX), .-GL_PREFIX(FragmentLightfSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FragmentLightfvSGIX)
+ .type GL_PREFIX(FragmentLightfvSGIX), @function
+GL_PREFIX(FragmentLightfvSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3824(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3824(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3824(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3824(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FragmentLightfvSGIX), .-GL_PREFIX(FragmentLightfvSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FragmentLightiSGIX)
+ .type GL_PREFIX(FragmentLightiSGIX), @function
+GL_PREFIX(FragmentLightiSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3832(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3832(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3832(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3832(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FragmentLightiSGIX), .-GL_PREFIX(FragmentLightiSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FragmentLightivSGIX)
+ .type GL_PREFIX(FragmentLightivSGIX), @function
+GL_PREFIX(FragmentLightivSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3840(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3840(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3840(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3840(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FragmentLightivSGIX), .-GL_PREFIX(FragmentLightivSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FragmentLightModelfSGIX)
+ .type GL_PREFIX(FragmentLightModelfSGIX), @function
+GL_PREFIX(FragmentLightModelfSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3848(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3848(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3848(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3848(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FragmentLightModelfSGIX), .-GL_PREFIX(FragmentLightModelfSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FragmentLightModelfvSGIX)
+ .type GL_PREFIX(FragmentLightModelfvSGIX), @function
+GL_PREFIX(FragmentLightModelfvSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3856(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3856(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3856(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3856(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FragmentLightModelfvSGIX), .-GL_PREFIX(FragmentLightModelfvSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FragmentLightModeliSGIX)
+ .type GL_PREFIX(FragmentLightModeliSGIX), @function
+GL_PREFIX(FragmentLightModeliSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3864(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3864(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3864(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3864(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FragmentLightModeliSGIX), .-GL_PREFIX(FragmentLightModeliSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FragmentLightModelivSGIX)
+ .type GL_PREFIX(FragmentLightModelivSGIX), @function
+GL_PREFIX(FragmentLightModelivSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3872(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3872(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3872(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3872(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FragmentLightModelivSGIX), .-GL_PREFIX(FragmentLightModelivSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FragmentMaterialfSGIX)
+ .type GL_PREFIX(FragmentMaterialfSGIX), @function
+GL_PREFIX(FragmentMaterialfSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3880(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3880(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3880(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 3880(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FragmentMaterialfSGIX), .-GL_PREFIX(FragmentMaterialfSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FragmentMaterialfvSGIX)
+ .type GL_PREFIX(FragmentMaterialfvSGIX), @function
+GL_PREFIX(FragmentMaterialfvSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3888(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3888(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3888(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3888(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FragmentMaterialfvSGIX), .-GL_PREFIX(FragmentMaterialfvSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FragmentMaterialiSGIX)
+ .type GL_PREFIX(FragmentMaterialiSGIX), @function
+GL_PREFIX(FragmentMaterialiSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3896(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3896(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3896(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3896(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FragmentMaterialiSGIX), .-GL_PREFIX(FragmentMaterialiSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FragmentMaterialivSGIX)
+ .type GL_PREFIX(FragmentMaterialivSGIX), @function
+GL_PREFIX(FragmentMaterialivSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3904(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3904(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3904(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3904(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FragmentMaterialivSGIX), .-GL_PREFIX(FragmentMaterialivSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetFragmentLightfvSGIX)
+ .type GL_PREFIX(GetFragmentLightfvSGIX), @function
+GL_PREFIX(GetFragmentLightfvSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3912(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3912(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3912(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3912(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetFragmentLightfvSGIX), .-GL_PREFIX(GetFragmentLightfvSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetFragmentLightivSGIX)
+ .type GL_PREFIX(GetFragmentLightivSGIX), @function
+GL_PREFIX(GetFragmentLightivSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3920(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3920(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3920(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3920(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetFragmentLightivSGIX), .-GL_PREFIX(GetFragmentLightivSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetFragmentMaterialfvSGIX)
+ .type GL_PREFIX(GetFragmentMaterialfvSGIX), @function
+GL_PREFIX(GetFragmentMaterialfvSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3928(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3928(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3928(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3928(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetFragmentMaterialfvSGIX), .-GL_PREFIX(GetFragmentMaterialfvSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetFragmentMaterialivSGIX)
+ .type GL_PREFIX(GetFragmentMaterialivSGIX), @function
+GL_PREFIX(GetFragmentMaterialivSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3936(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3936(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3936(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3936(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetFragmentMaterialivSGIX), .-GL_PREFIX(GetFragmentMaterialivSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(LightEnviSGIX)
+ .type GL_PREFIX(LightEnviSGIX), @function
+GL_PREFIX(LightEnviSGIX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3944(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3944(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3944(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3944(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(LightEnviSGIX), .-GL_PREFIX(LightEnviSGIX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexWeightfEXT)
+ .type GL_PREFIX(VertexWeightfEXT), @function
+GL_PREFIX(VertexWeightfEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3952(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 3952(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3952(%rax), %r11
+ jmp *%r11
+1:
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _glapi_get_dispatch
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 3952(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexWeightfEXT), .-GL_PREFIX(VertexWeightfEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexWeightfvEXT)
+ .type GL_PREFIX(VertexWeightfvEXT), @function
+GL_PREFIX(VertexWeightfvEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3960(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 3960(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3960(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 3960(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexWeightfvEXT), .-GL_PREFIX(VertexWeightfvEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexWeightPointerEXT)
+ .type GL_PREFIX(VertexWeightPointerEXT), @function
+GL_PREFIX(VertexWeightPointerEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3968(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3968(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3968(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 3968(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexWeightPointerEXT), .-GL_PREFIX(VertexWeightPointerEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FlushVertexArrayRangeNV)
+ .type GL_PREFIX(FlushVertexArrayRangeNV), @function
+GL_PREFIX(FlushVertexArrayRangeNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3976(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 3976(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3976(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 3976(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FlushVertexArrayRangeNV), .-GL_PREFIX(FlushVertexArrayRangeNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexArrayRangeNV)
+ .type GL_PREFIX(VertexArrayRangeNV), @function
+GL_PREFIX(VertexArrayRangeNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3984(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3984(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3984(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3984(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexArrayRangeNV), .-GL_PREFIX(VertexArrayRangeNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CombinerParameterfvNV)
+ .type GL_PREFIX(CombinerParameterfvNV), @function
+GL_PREFIX(CombinerParameterfvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 3992(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3992(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 3992(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 3992(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CombinerParameterfvNV), .-GL_PREFIX(CombinerParameterfvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CombinerParameterfNV)
+ .type GL_PREFIX(CombinerParameterfNV), @function
+GL_PREFIX(CombinerParameterfNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4000(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 4000(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4000(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 4000(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CombinerParameterfNV), .-GL_PREFIX(CombinerParameterfNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CombinerParameterivNV)
+ .type GL_PREFIX(CombinerParameterivNV), @function
+GL_PREFIX(CombinerParameterivNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4008(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4008(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4008(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4008(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CombinerParameterivNV), .-GL_PREFIX(CombinerParameterivNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CombinerParameteriNV)
+ .type GL_PREFIX(CombinerParameteriNV), @function
+GL_PREFIX(CombinerParameteriNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4016(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4016(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4016(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4016(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CombinerParameteriNV), .-GL_PREFIX(CombinerParameteriNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CombinerInputNV)
+ .type GL_PREFIX(CombinerInputNV), @function
+GL_PREFIX(CombinerInputNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4024(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4024(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4024(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4024(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CombinerInputNV), .-GL_PREFIX(CombinerInputNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CombinerOutputNV)
+ .type GL_PREFIX(CombinerOutputNV), @function
+GL_PREFIX(CombinerOutputNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4032(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4032(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4032(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4032(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CombinerOutputNV), .-GL_PREFIX(CombinerOutputNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FinalCombinerInputNV)
+ .type GL_PREFIX(FinalCombinerInputNV), @function
+GL_PREFIX(FinalCombinerInputNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4040(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4040(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4040(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4040(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FinalCombinerInputNV), .-GL_PREFIX(FinalCombinerInputNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetCombinerInputParameterfvNV)
+ .type GL_PREFIX(GetCombinerInputParameterfvNV), @function
+GL_PREFIX(GetCombinerInputParameterfvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4048(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4048(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4048(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4048(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetCombinerInputParameterfvNV), .-GL_PREFIX(GetCombinerInputParameterfvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetCombinerInputParameterivNV)
+ .type GL_PREFIX(GetCombinerInputParameterivNV), @function
+GL_PREFIX(GetCombinerInputParameterivNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4056(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4056(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4056(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4056(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetCombinerInputParameterivNV), .-GL_PREFIX(GetCombinerInputParameterivNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetCombinerOutputParameterfvNV)
+ .type GL_PREFIX(GetCombinerOutputParameterfvNV), @function
+GL_PREFIX(GetCombinerOutputParameterfvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4064(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4064(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4064(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4064(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetCombinerOutputParameterfvNV), .-GL_PREFIX(GetCombinerOutputParameterfvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetCombinerOutputParameterivNV)
+ .type GL_PREFIX(GetCombinerOutputParameterivNV), @function
+GL_PREFIX(GetCombinerOutputParameterivNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4072(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4072(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4072(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4072(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetCombinerOutputParameterivNV), .-GL_PREFIX(GetCombinerOutputParameterivNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetFinalCombinerInputParameterfvNV)
+ .type GL_PREFIX(GetFinalCombinerInputParameterfvNV), @function
+GL_PREFIX(GetFinalCombinerInputParameterfvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4080(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4080(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4080(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4080(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetFinalCombinerInputParameterfvNV), .-GL_PREFIX(GetFinalCombinerInputParameterfvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetFinalCombinerInputParameterivNV)
+ .type GL_PREFIX(GetFinalCombinerInputParameterivNV), @function
+GL_PREFIX(GetFinalCombinerInputParameterivNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4088(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4088(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4088(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4088(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetFinalCombinerInputParameterivNV), .-GL_PREFIX(GetFinalCombinerInputParameterivNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ResizeBuffersMESA)
+ .type GL_PREFIX(ResizeBuffersMESA), @function
+GL_PREFIX(ResizeBuffersMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4096(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 4096(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4096(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 4096(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ResizeBuffersMESA), .-GL_PREFIX(ResizeBuffersMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos2dMESA)
+ .type GL_PREFIX(WindowPos2dMESA), @function
+GL_PREFIX(WindowPos2dMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4104(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 4104(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4104(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 4104(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos2dMESA), .-GL_PREFIX(WindowPos2dMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos2dvMESA)
+ .type GL_PREFIX(WindowPos2dvMESA), @function
+GL_PREFIX(WindowPos2dvMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4112(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4112(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4112(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4112(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos2dvMESA), .-GL_PREFIX(WindowPos2dvMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos2fMESA)
+ .type GL_PREFIX(WindowPos2fMESA), @function
+GL_PREFIX(WindowPos2fMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4120(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 4120(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4120(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 4120(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos2fMESA), .-GL_PREFIX(WindowPos2fMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos2fvMESA)
+ .type GL_PREFIX(WindowPos2fvMESA), @function
+GL_PREFIX(WindowPos2fvMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4128(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4128(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4128(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4128(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos2fvMESA), .-GL_PREFIX(WindowPos2fvMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos2iMESA)
+ .type GL_PREFIX(WindowPos2iMESA), @function
+GL_PREFIX(WindowPos2iMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4136(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4136(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4136(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4136(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos2iMESA), .-GL_PREFIX(WindowPos2iMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos2ivMESA)
+ .type GL_PREFIX(WindowPos2ivMESA), @function
+GL_PREFIX(WindowPos2ivMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4144(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4144(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4144(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4144(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos2ivMESA), .-GL_PREFIX(WindowPos2ivMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos2sMESA)
+ .type GL_PREFIX(WindowPos2sMESA), @function
+GL_PREFIX(WindowPos2sMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4152(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4152(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4152(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4152(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos2sMESA), .-GL_PREFIX(WindowPos2sMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos2svMESA)
+ .type GL_PREFIX(WindowPos2svMESA), @function
+GL_PREFIX(WindowPos2svMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4160(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4160(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4160(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4160(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos2svMESA), .-GL_PREFIX(WindowPos2svMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos3dMESA)
+ .type GL_PREFIX(WindowPos3dMESA), @function
+GL_PREFIX(WindowPos3dMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4168(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 4168(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4168(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 4168(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos3dMESA), .-GL_PREFIX(WindowPos3dMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos3dvMESA)
+ .type GL_PREFIX(WindowPos3dvMESA), @function
+GL_PREFIX(WindowPos3dvMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4176(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4176(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4176(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4176(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos3dvMESA), .-GL_PREFIX(WindowPos3dvMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos3fMESA)
+ .type GL_PREFIX(WindowPos3fMESA), @function
+GL_PREFIX(WindowPos3fMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4184(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 4184(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4184(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 4184(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos3fMESA), .-GL_PREFIX(WindowPos3fMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos3fvMESA)
+ .type GL_PREFIX(WindowPos3fvMESA), @function
+GL_PREFIX(WindowPos3fvMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4192(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4192(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4192(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4192(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos3fvMESA), .-GL_PREFIX(WindowPos3fvMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos3iMESA)
+ .type GL_PREFIX(WindowPos3iMESA), @function
+GL_PREFIX(WindowPos3iMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4200(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4200(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4200(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4200(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos3iMESA), .-GL_PREFIX(WindowPos3iMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos3ivMESA)
+ .type GL_PREFIX(WindowPos3ivMESA), @function
+GL_PREFIX(WindowPos3ivMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4208(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4208(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4208(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4208(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos3ivMESA), .-GL_PREFIX(WindowPos3ivMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos3sMESA)
+ .type GL_PREFIX(WindowPos3sMESA), @function
+GL_PREFIX(WindowPos3sMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4216(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4216(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4216(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4216(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos3sMESA), .-GL_PREFIX(WindowPos3sMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos3svMESA)
+ .type GL_PREFIX(WindowPos3svMESA), @function
+GL_PREFIX(WindowPos3svMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4224(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4224(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4224(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4224(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos3svMESA), .-GL_PREFIX(WindowPos3svMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos4dMESA)
+ .type GL_PREFIX(WindowPos4dMESA), @function
+GL_PREFIX(WindowPos4dMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4232(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 4232(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4232(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 4232(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos4dMESA), .-GL_PREFIX(WindowPos4dMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos4dvMESA)
+ .type GL_PREFIX(WindowPos4dvMESA), @function
+GL_PREFIX(WindowPos4dvMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4240(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4240(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4240(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4240(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos4dvMESA), .-GL_PREFIX(WindowPos4dvMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos4fMESA)
+ .type GL_PREFIX(WindowPos4fMESA), @function
+GL_PREFIX(WindowPos4fMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4248(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 4248(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4248(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ movq %xmm3, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm3
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $40, %rsp
+ movq 4248(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos4fMESA), .-GL_PREFIX(WindowPos4fMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos4fvMESA)
+ .type GL_PREFIX(WindowPos4fvMESA), @function
+GL_PREFIX(WindowPos4fvMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4256(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4256(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4256(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4256(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos4fvMESA), .-GL_PREFIX(WindowPos4fvMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos4iMESA)
+ .type GL_PREFIX(WindowPos4iMESA), @function
+GL_PREFIX(WindowPos4iMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4264(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4264(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4264(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4264(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos4iMESA), .-GL_PREFIX(WindowPos4iMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos4ivMESA)
+ .type GL_PREFIX(WindowPos4ivMESA), @function
+GL_PREFIX(WindowPos4ivMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4272(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4272(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4272(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4272(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos4ivMESA), .-GL_PREFIX(WindowPos4ivMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos4sMESA)
+ .type GL_PREFIX(WindowPos4sMESA), @function
+GL_PREFIX(WindowPos4sMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4280(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4280(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4280(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4280(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos4sMESA), .-GL_PREFIX(WindowPos4sMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(WindowPos4svMESA)
+ .type GL_PREFIX(WindowPos4svMESA), @function
+GL_PREFIX(WindowPos4svMESA):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4288(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4288(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4288(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4288(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(WindowPos4svMESA), .-GL_PREFIX(WindowPos4svMESA)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(BlendFuncSeparateEXT)
+ .type GL_PREFIX(BlendFuncSeparateEXT), @function
+GL_PREFIX(BlendFuncSeparateEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4296(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4296(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4296(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4296(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(BlendFuncSeparateEXT), .-GL_PREFIX(BlendFuncSeparateEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(IndexMaterialEXT)
+ .type GL_PREFIX(IndexMaterialEXT), @function
+GL_PREFIX(IndexMaterialEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4304(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4304(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4304(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4304(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(IndexMaterialEXT), .-GL_PREFIX(IndexMaterialEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(IndexFuncEXT)
+ .type GL_PREFIX(IndexFuncEXT), @function
+GL_PREFIX(IndexFuncEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4312(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4312(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4312(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4312(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(IndexFuncEXT), .-GL_PREFIX(IndexFuncEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(LockArraysEXT)
+ .type GL_PREFIX(LockArraysEXT), @function
+GL_PREFIX(LockArraysEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4320(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4320(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4320(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4320(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(LockArraysEXT), .-GL_PREFIX(LockArraysEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(UnlockArraysEXT)
+ .type GL_PREFIX(UnlockArraysEXT), @function
+GL_PREFIX(UnlockArraysEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4328(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 4328(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4328(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 4328(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(UnlockArraysEXT), .-GL_PREFIX(UnlockArraysEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CullParameterdvEXT)
+ .type GL_PREFIX(CullParameterdvEXT), @function
+GL_PREFIX(CullParameterdvEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4336(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4336(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4336(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4336(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CullParameterdvEXT), .-GL_PREFIX(CullParameterdvEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CullParameterfvEXT)
+ .type GL_PREFIX(CullParameterfvEXT), @function
+GL_PREFIX(CullParameterfvEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4344(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4344(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4344(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4344(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CullParameterfvEXT), .-GL_PREFIX(CullParameterfvEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(HintPGI)
+ .type GL_PREFIX(HintPGI), @function
+GL_PREFIX(HintPGI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4352(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4352(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4352(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4352(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(HintPGI), .-GL_PREFIX(HintPGI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FogCoordfEXT)
+ .type GL_PREFIX(FogCoordfEXT), @function
+GL_PREFIX(FogCoordfEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4360(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 4360(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4360(%rax), %r11
+ jmp *%r11
+1:
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _glapi_get_dispatch
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 4360(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FogCoordfEXT), .-GL_PREFIX(FogCoordfEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FogCoordfvEXT)
+ .type GL_PREFIX(FogCoordfvEXT), @function
+GL_PREFIX(FogCoordfvEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4368(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4368(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4368(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4368(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FogCoordfvEXT), .-GL_PREFIX(FogCoordfvEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FogCoorddEXT)
+ .type GL_PREFIX(FogCoorddEXT), @function
+GL_PREFIX(FogCoorddEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4376(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 4376(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4376(%rax), %r11
+ jmp *%r11
+1:
+ subq $8, %rsp
+ movq %xmm0, (%rsp)
+ call _glapi_get_dispatch
+ movq (%rsp), %xmm0
+ addq $8, %rsp
+ movq 4376(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FogCoorddEXT), .-GL_PREFIX(FogCoorddEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FogCoorddvEXT)
+ .type GL_PREFIX(FogCoorddvEXT), @function
+GL_PREFIX(FogCoorddvEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4384(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4384(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4384(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4384(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FogCoorddvEXT), .-GL_PREFIX(FogCoorddvEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FogCoordPointerEXT)
+ .type GL_PREFIX(FogCoordPointerEXT), @function
+GL_PREFIX(FogCoordPointerEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4392(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4392(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4392(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4392(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FogCoordPointerEXT), .-GL_PREFIX(FogCoordPointerEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetColorTableEXT)
+ .type GL_PREFIX(GetColorTableEXT), @function
+GL_PREFIX(GetColorTableEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4400(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4400(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4400(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4400(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetColorTableEXT), .-GL_PREFIX(GetColorTableEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetColorTableParameterivEXT)
+ .type GL_PREFIX(GetColorTableParameterivEXT), @function
+GL_PREFIX(GetColorTableParameterivEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4408(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4408(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4408(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4408(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetColorTableParameterivEXT), .-GL_PREFIX(GetColorTableParameterivEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetColorTableParameterfvEXT)
+ .type GL_PREFIX(GetColorTableParameterfvEXT), @function
+GL_PREFIX(GetColorTableParameterfvEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4416(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4416(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4416(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4416(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetColorTableParameterfvEXT), .-GL_PREFIX(GetColorTableParameterfvEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TbufferMask3DFX)
+ .type GL_PREFIX(TbufferMask3DFX), @function
+GL_PREFIX(TbufferMask3DFX):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4424(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4424(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4424(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4424(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TbufferMask3DFX), .-GL_PREFIX(TbufferMask3DFX)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CompressedTexImage3DARB)
+ .type GL_PREFIX(CompressedTexImage3DARB), @function
+GL_PREFIX(CompressedTexImage3DARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4432(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4432(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4432(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4432(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CompressedTexImage3DARB), .-GL_PREFIX(CompressedTexImage3DARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CompressedTexImage2DARB)
+ .type GL_PREFIX(CompressedTexImage2DARB), @function
+GL_PREFIX(CompressedTexImage2DARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4440(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4440(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4440(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4440(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CompressedTexImage2DARB), .-GL_PREFIX(CompressedTexImage2DARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CompressedTexImage1DARB)
+ .type GL_PREFIX(CompressedTexImage1DARB), @function
+GL_PREFIX(CompressedTexImage1DARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4448(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4448(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4448(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4448(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CompressedTexImage1DARB), .-GL_PREFIX(CompressedTexImage1DARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CompressedTexSubImage3DARB)
+ .type GL_PREFIX(CompressedTexSubImage3DARB), @function
+GL_PREFIX(CompressedTexSubImage3DARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4456(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4456(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4456(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4456(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CompressedTexSubImage3DARB), .-GL_PREFIX(CompressedTexSubImage3DARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CompressedTexSubImage2DARB)
+ .type GL_PREFIX(CompressedTexSubImage2DARB), @function
+GL_PREFIX(CompressedTexSubImage2DARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4464(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4464(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4464(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4464(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CompressedTexSubImage2DARB), .-GL_PREFIX(CompressedTexSubImage2DARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CompressedTexSubImage1DARB)
+ .type GL_PREFIX(CompressedTexSubImage1DARB), @function
+GL_PREFIX(CompressedTexSubImage1DARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4472(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4472(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4472(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4472(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CompressedTexSubImage1DARB), .-GL_PREFIX(CompressedTexSubImage1DARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetCompressedTexImageARB)
+ .type GL_PREFIX(GetCompressedTexImageARB), @function
+GL_PREFIX(GetCompressedTexImageARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4480(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4480(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4480(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4480(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetCompressedTexImageARB), .-GL_PREFIX(GetCompressedTexImageARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SecondaryColor3bEXT)
+ .type GL_PREFIX(SecondaryColor3bEXT), @function
+GL_PREFIX(SecondaryColor3bEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4488(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4488(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4488(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4488(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SecondaryColor3bEXT), .-GL_PREFIX(SecondaryColor3bEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SecondaryColor3bvEXT)
+ .type GL_PREFIX(SecondaryColor3bvEXT), @function
+GL_PREFIX(SecondaryColor3bvEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4496(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4496(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4496(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4496(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SecondaryColor3bvEXT), .-GL_PREFIX(SecondaryColor3bvEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SecondaryColor3dEXT)
+ .type GL_PREFIX(SecondaryColor3dEXT), @function
+GL_PREFIX(SecondaryColor3dEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4504(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 4504(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4504(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 4504(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SecondaryColor3dEXT), .-GL_PREFIX(SecondaryColor3dEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SecondaryColor3dvEXT)
+ .type GL_PREFIX(SecondaryColor3dvEXT), @function
+GL_PREFIX(SecondaryColor3dvEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4512(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4512(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4512(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4512(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SecondaryColor3dvEXT), .-GL_PREFIX(SecondaryColor3dvEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SecondaryColor3fEXT)
+ .type GL_PREFIX(SecondaryColor3fEXT), @function
+GL_PREFIX(SecondaryColor3fEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4520(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 4520(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4520(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %xmm0, (%rsp)
+ movq %xmm1, 8(%rsp)
+ movq %xmm2, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm2
+ movq 8(%rsp), %xmm1
+ movq (%rsp), %xmm0
+ addq $24, %rsp
+ movq 4520(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SecondaryColor3fEXT), .-GL_PREFIX(SecondaryColor3fEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SecondaryColor3fvEXT)
+ .type GL_PREFIX(SecondaryColor3fvEXT), @function
+GL_PREFIX(SecondaryColor3fvEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4528(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4528(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4528(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4528(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SecondaryColor3fvEXT), .-GL_PREFIX(SecondaryColor3fvEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SecondaryColor3iEXT)
+ .type GL_PREFIX(SecondaryColor3iEXT), @function
+GL_PREFIX(SecondaryColor3iEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4536(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4536(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4536(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4536(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SecondaryColor3iEXT), .-GL_PREFIX(SecondaryColor3iEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SecondaryColor3ivEXT)
+ .type GL_PREFIX(SecondaryColor3ivEXT), @function
+GL_PREFIX(SecondaryColor3ivEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4544(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4544(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4544(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4544(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SecondaryColor3ivEXT), .-GL_PREFIX(SecondaryColor3ivEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SecondaryColor3sEXT)
+ .type GL_PREFIX(SecondaryColor3sEXT), @function
+GL_PREFIX(SecondaryColor3sEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4552(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4552(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4552(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4552(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SecondaryColor3sEXT), .-GL_PREFIX(SecondaryColor3sEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SecondaryColor3svEXT)
+ .type GL_PREFIX(SecondaryColor3svEXT), @function
+GL_PREFIX(SecondaryColor3svEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4560(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4560(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4560(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4560(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SecondaryColor3svEXT), .-GL_PREFIX(SecondaryColor3svEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SecondaryColor3ubEXT)
+ .type GL_PREFIX(SecondaryColor3ubEXT), @function
+GL_PREFIX(SecondaryColor3ubEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4568(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4568(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4568(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4568(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SecondaryColor3ubEXT), .-GL_PREFIX(SecondaryColor3ubEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SecondaryColor3ubvEXT)
+ .type GL_PREFIX(SecondaryColor3ubvEXT), @function
+GL_PREFIX(SecondaryColor3ubvEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4576(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4576(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4576(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4576(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SecondaryColor3ubvEXT), .-GL_PREFIX(SecondaryColor3ubvEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SecondaryColor3uiEXT)
+ .type GL_PREFIX(SecondaryColor3uiEXT), @function
+GL_PREFIX(SecondaryColor3uiEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4584(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4584(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4584(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4584(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SecondaryColor3uiEXT), .-GL_PREFIX(SecondaryColor3uiEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SecondaryColor3uivEXT)
+ .type GL_PREFIX(SecondaryColor3uivEXT), @function
+GL_PREFIX(SecondaryColor3uivEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4592(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4592(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4592(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4592(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SecondaryColor3uivEXT), .-GL_PREFIX(SecondaryColor3uivEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SecondaryColor3usEXT)
+ .type GL_PREFIX(SecondaryColor3usEXT), @function
+GL_PREFIX(SecondaryColor3usEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4600(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4600(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4600(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4600(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SecondaryColor3usEXT), .-GL_PREFIX(SecondaryColor3usEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SecondaryColor3usvEXT)
+ .type GL_PREFIX(SecondaryColor3usvEXT), @function
+GL_PREFIX(SecondaryColor3usvEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4608(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4608(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4608(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4608(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SecondaryColor3usvEXT), .-GL_PREFIX(SecondaryColor3usvEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SecondaryColorPointerEXT)
+ .type GL_PREFIX(SecondaryColorPointerEXT), @function
+GL_PREFIX(SecondaryColorPointerEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4616(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4616(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4616(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4616(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SecondaryColorPointerEXT), .-GL_PREFIX(SecondaryColorPointerEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(AreProgramsResidentNV)
+ .type GL_PREFIX(AreProgramsResidentNV), @function
+GL_PREFIX(AreProgramsResidentNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4624(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4624(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4624(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4624(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(AreProgramsResidentNV), .-GL_PREFIX(AreProgramsResidentNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(BindProgramNV)
+ .type GL_PREFIX(BindProgramNV), @function
+GL_PREFIX(BindProgramNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4632(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4632(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4632(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4632(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(BindProgramNV), .-GL_PREFIX(BindProgramNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DeleteProgramsNV)
+ .type GL_PREFIX(DeleteProgramsNV), @function
+GL_PREFIX(DeleteProgramsNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4640(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4640(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4640(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4640(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DeleteProgramsNV), .-GL_PREFIX(DeleteProgramsNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ExecuteProgramNV)
+ .type GL_PREFIX(ExecuteProgramNV), @function
+GL_PREFIX(ExecuteProgramNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4648(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4648(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4648(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4648(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ExecuteProgramNV), .-GL_PREFIX(ExecuteProgramNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GenProgramsNV)
+ .type GL_PREFIX(GenProgramsNV), @function
+GL_PREFIX(GenProgramsNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4656(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4656(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4656(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4656(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GenProgramsNV), .-GL_PREFIX(GenProgramsNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetProgramParameterdvNV)
+ .type GL_PREFIX(GetProgramParameterdvNV), @function
+GL_PREFIX(GetProgramParameterdvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4664(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4664(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4664(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4664(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetProgramParameterdvNV), .-GL_PREFIX(GetProgramParameterdvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetProgramParameterfvNV)
+ .type GL_PREFIX(GetProgramParameterfvNV), @function
+GL_PREFIX(GetProgramParameterfvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4672(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4672(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4672(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4672(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetProgramParameterfvNV), .-GL_PREFIX(GetProgramParameterfvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetProgramivNV)
+ .type GL_PREFIX(GetProgramivNV), @function
+GL_PREFIX(GetProgramivNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4680(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4680(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4680(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4680(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetProgramivNV), .-GL_PREFIX(GetProgramivNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetProgramStringNV)
+ .type GL_PREFIX(GetProgramStringNV), @function
+GL_PREFIX(GetProgramStringNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4688(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4688(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4688(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4688(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetProgramStringNV), .-GL_PREFIX(GetProgramStringNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetTrackMatrixivNV)
+ .type GL_PREFIX(GetTrackMatrixivNV), @function
+GL_PREFIX(GetTrackMatrixivNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4696(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4696(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4696(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4696(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetTrackMatrixivNV), .-GL_PREFIX(GetTrackMatrixivNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetVertexAttribdvARB)
+ .type GL_PREFIX(GetVertexAttribdvARB), @function
+GL_PREFIX(GetVertexAttribdvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4704(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4704(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4704(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4704(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetVertexAttribdvARB), .-GL_PREFIX(GetVertexAttribdvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetVertexAttribfvARB)
+ .type GL_PREFIX(GetVertexAttribfvARB), @function
+GL_PREFIX(GetVertexAttribfvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4712(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4712(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4712(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4712(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetVertexAttribfvARB), .-GL_PREFIX(GetVertexAttribfvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetVertexAttribivARB)
+ .type GL_PREFIX(GetVertexAttribivARB), @function
+GL_PREFIX(GetVertexAttribivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4720(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4720(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4720(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4720(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetVertexAttribivARB), .-GL_PREFIX(GetVertexAttribivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetVertexAttribPointervNV)
+ .type GL_PREFIX(GetVertexAttribPointervNV), @function
+GL_PREFIX(GetVertexAttribPointervNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4728(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4728(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4728(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4728(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetVertexAttribPointervNV), .-GL_PREFIX(GetVertexAttribPointervNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(IsProgramNV)
+ .type GL_PREFIX(IsProgramNV), @function
+GL_PREFIX(IsProgramNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4736(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 4736(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4736(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 4736(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(IsProgramNV), .-GL_PREFIX(IsProgramNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(LoadProgramNV)
+ .type GL_PREFIX(LoadProgramNV), @function
+GL_PREFIX(LoadProgramNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4744(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4744(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4744(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4744(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(LoadProgramNV), .-GL_PREFIX(LoadProgramNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramParameter4dNV)
+ .type GL_PREFIX(ProgramParameter4dNV), @function
+GL_PREFIX(ProgramParameter4dNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4752(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ movq %xmm1, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %xmm1
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 4752(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4752(%rax), %r11
+ jmp *%r11
+1:
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ movq %xmm1, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ call _glapi_get_dispatch
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %xmm1
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 4752(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramParameter4dNV), .-GL_PREFIX(ProgramParameter4dNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramParameter4dvNV)
+ .type GL_PREFIX(ProgramParameter4dvNV), @function
+GL_PREFIX(ProgramParameter4dvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4760(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4760(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4760(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4760(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramParameter4dvNV), .-GL_PREFIX(ProgramParameter4dvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramParameter4fNV)
+ .type GL_PREFIX(ProgramParameter4fNV), @function
+GL_PREFIX(ProgramParameter4fNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4768(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ movq %xmm1, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %xmm1
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 4768(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4768(%rax), %r11
+ jmp *%r11
+1:
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ movq %xmm1, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ call _glapi_get_dispatch
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %xmm1
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 4768(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramParameter4fNV), .-GL_PREFIX(ProgramParameter4fNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramParameter4fvNV)
+ .type GL_PREFIX(ProgramParameter4fvNV), @function
+GL_PREFIX(ProgramParameter4fvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4776(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4776(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4776(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4776(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramParameter4fvNV), .-GL_PREFIX(ProgramParameter4fvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramParameters4dvNV)
+ .type GL_PREFIX(ProgramParameters4dvNV), @function
+GL_PREFIX(ProgramParameters4dvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4784(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4784(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4784(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4784(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramParameters4dvNV), .-GL_PREFIX(ProgramParameters4dvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramParameters4fvNV)
+ .type GL_PREFIX(ProgramParameters4fvNV), @function
+GL_PREFIX(ProgramParameters4fvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4792(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4792(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4792(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4792(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramParameters4fvNV), .-GL_PREFIX(ProgramParameters4fvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RequestResidentProgramsNV)
+ .type GL_PREFIX(RequestResidentProgramsNV), @function
+GL_PREFIX(RequestResidentProgramsNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4800(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4800(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4800(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4800(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RequestResidentProgramsNV), .-GL_PREFIX(RequestResidentProgramsNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TrackMatrixNV)
+ .type GL_PREFIX(TrackMatrixNV), @function
+GL_PREFIX(TrackMatrixNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4808(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4808(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4808(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4808(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TrackMatrixNV), .-GL_PREFIX(TrackMatrixNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttribPointerNV)
+ .type GL_PREFIX(VertexAttribPointerNV), @function
+GL_PREFIX(VertexAttribPointerNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4816(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4816(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4816(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4816(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttribPointerNV), .-GL_PREFIX(VertexAttribPointerNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib1dARB)
+ .type GL_PREFIX(VertexAttrib1dARB), @function
+GL_PREFIX(VertexAttrib1dARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4824(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 4824(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4824(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 4824(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib1dARB), .-GL_PREFIX(VertexAttrib1dARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib1dvARB)
+ .type GL_PREFIX(VertexAttrib1dvARB), @function
+GL_PREFIX(VertexAttrib1dvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4832(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4832(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4832(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4832(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib1dvARB), .-GL_PREFIX(VertexAttrib1dvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib1fARB)
+ .type GL_PREFIX(VertexAttrib1fARB), @function
+GL_PREFIX(VertexAttrib1fARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4840(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 4840(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4840(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 4840(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib1fARB), .-GL_PREFIX(VertexAttrib1fARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib1fvARB)
+ .type GL_PREFIX(VertexAttrib1fvARB), @function
+GL_PREFIX(VertexAttrib1fvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4848(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4848(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4848(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4848(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib1fvARB), .-GL_PREFIX(VertexAttrib1fvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib1sARB)
+ .type GL_PREFIX(VertexAttrib1sARB), @function
+GL_PREFIX(VertexAttrib1sARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4856(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4856(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4856(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4856(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib1sARB), .-GL_PREFIX(VertexAttrib1sARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib1svARB)
+ .type GL_PREFIX(VertexAttrib1svARB), @function
+GL_PREFIX(VertexAttrib1svARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4864(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4864(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4864(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4864(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib1svARB), .-GL_PREFIX(VertexAttrib1svARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib2dARB)
+ .type GL_PREFIX(VertexAttrib2dARB), @function
+GL_PREFIX(VertexAttrib2dARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4872(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 4872(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4872(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 4872(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib2dARB), .-GL_PREFIX(VertexAttrib2dARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib2dvARB)
+ .type GL_PREFIX(VertexAttrib2dvARB), @function
+GL_PREFIX(VertexAttrib2dvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4880(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4880(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4880(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4880(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib2dvARB), .-GL_PREFIX(VertexAttrib2dvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib2fARB)
+ .type GL_PREFIX(VertexAttrib2fARB), @function
+GL_PREFIX(VertexAttrib2fARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4888(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 4888(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4888(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 4888(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib2fARB), .-GL_PREFIX(VertexAttrib2fARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib2fvARB)
+ .type GL_PREFIX(VertexAttrib2fvARB), @function
+GL_PREFIX(VertexAttrib2fvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4896(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4896(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4896(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4896(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib2fvARB), .-GL_PREFIX(VertexAttrib2fvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib2sARB)
+ .type GL_PREFIX(VertexAttrib2sARB), @function
+GL_PREFIX(VertexAttrib2sARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4904(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4904(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4904(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4904(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib2sARB), .-GL_PREFIX(VertexAttrib2sARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib2svARB)
+ .type GL_PREFIX(VertexAttrib2svARB), @function
+GL_PREFIX(VertexAttrib2svARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4912(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4912(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4912(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4912(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib2svARB), .-GL_PREFIX(VertexAttrib2svARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib3dARB)
+ .type GL_PREFIX(VertexAttrib3dARB), @function
+GL_PREFIX(VertexAttrib3dARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4920(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 4920(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4920(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 4920(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib3dARB), .-GL_PREFIX(VertexAttrib3dARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib3dvARB)
+ .type GL_PREFIX(VertexAttrib3dvARB), @function
+GL_PREFIX(VertexAttrib3dvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4928(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4928(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4928(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4928(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib3dvARB), .-GL_PREFIX(VertexAttrib3dvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib3fARB)
+ .type GL_PREFIX(VertexAttrib3fARB), @function
+GL_PREFIX(VertexAttrib3fARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4936(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 4936(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4936(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 4936(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib3fARB), .-GL_PREFIX(VertexAttrib3fARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib3fvARB)
+ .type GL_PREFIX(VertexAttrib3fvARB), @function
+GL_PREFIX(VertexAttrib3fvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4944(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4944(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4944(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4944(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib3fvARB), .-GL_PREFIX(VertexAttrib3fvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib3sARB)
+ .type GL_PREFIX(VertexAttrib3sARB), @function
+GL_PREFIX(VertexAttrib3sARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4952(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4952(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4952(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 4952(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib3sARB), .-GL_PREFIX(VertexAttrib3sARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib3svARB)
+ .type GL_PREFIX(VertexAttrib3svARB), @function
+GL_PREFIX(VertexAttrib3svARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4960(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4960(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4960(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4960(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib3svARB), .-GL_PREFIX(VertexAttrib3svARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4dARB)
+ .type GL_PREFIX(VertexAttrib4dARB), @function
+GL_PREFIX(VertexAttrib4dARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4968(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ movq %xmm3, 32(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 32(%rsp), %xmm3
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 4968(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4968(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ movq %xmm3, 32(%rsp)
+ call _glapi_get_dispatch
+ movq 32(%rsp), %xmm3
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 4968(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4dARB), .-GL_PREFIX(VertexAttrib4dARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4dvARB)
+ .type GL_PREFIX(VertexAttrib4dvARB), @function
+GL_PREFIX(VertexAttrib4dvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4976(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4976(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4976(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4976(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4dvARB), .-GL_PREFIX(VertexAttrib4dvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4fARB)
+ .type GL_PREFIX(VertexAttrib4fARB), @function
+GL_PREFIX(VertexAttrib4fARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4984(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ movq %xmm3, 32(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 32(%rsp), %xmm3
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 4984(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4984(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ movq %xmm3, 32(%rsp)
+ call _glapi_get_dispatch
+ movq 32(%rsp), %xmm3
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 4984(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4fARB), .-GL_PREFIX(VertexAttrib4fARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4fvARB)
+ .type GL_PREFIX(VertexAttrib4fvARB), @function
+GL_PREFIX(VertexAttrib4fvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 4992(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4992(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 4992(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 4992(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4fvARB), .-GL_PREFIX(VertexAttrib4fvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4sARB)
+ .type GL_PREFIX(VertexAttrib4sARB), @function
+GL_PREFIX(VertexAttrib4sARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5000(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5000(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5000(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5000(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4sARB), .-GL_PREFIX(VertexAttrib4sARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4svARB)
+ .type GL_PREFIX(VertexAttrib4svARB), @function
+GL_PREFIX(VertexAttrib4svARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5008(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5008(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5008(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5008(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4svARB), .-GL_PREFIX(VertexAttrib4svARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4NubARB)
+ .type GL_PREFIX(VertexAttrib4NubARB), @function
+GL_PREFIX(VertexAttrib4NubARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5016(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5016(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5016(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5016(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4NubARB), .-GL_PREFIX(VertexAttrib4NubARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4NubvARB)
+ .type GL_PREFIX(VertexAttrib4NubvARB), @function
+GL_PREFIX(VertexAttrib4NubvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5024(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5024(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5024(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5024(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4NubvARB), .-GL_PREFIX(VertexAttrib4NubvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttribs1dvNV)
+ .type GL_PREFIX(VertexAttribs1dvNV), @function
+GL_PREFIX(VertexAttribs1dvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5032(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5032(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5032(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5032(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttribs1dvNV), .-GL_PREFIX(VertexAttribs1dvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttribs1fvNV)
+ .type GL_PREFIX(VertexAttribs1fvNV), @function
+GL_PREFIX(VertexAttribs1fvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5040(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5040(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5040(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5040(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttribs1fvNV), .-GL_PREFIX(VertexAttribs1fvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttribs1svNV)
+ .type GL_PREFIX(VertexAttribs1svNV), @function
+GL_PREFIX(VertexAttribs1svNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5048(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5048(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5048(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5048(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttribs1svNV), .-GL_PREFIX(VertexAttribs1svNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttribs2dvNV)
+ .type GL_PREFIX(VertexAttribs2dvNV), @function
+GL_PREFIX(VertexAttribs2dvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5056(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5056(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5056(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5056(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttribs2dvNV), .-GL_PREFIX(VertexAttribs2dvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttribs2fvNV)
+ .type GL_PREFIX(VertexAttribs2fvNV), @function
+GL_PREFIX(VertexAttribs2fvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5064(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5064(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5064(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5064(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttribs2fvNV), .-GL_PREFIX(VertexAttribs2fvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttribs2svNV)
+ .type GL_PREFIX(VertexAttribs2svNV), @function
+GL_PREFIX(VertexAttribs2svNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5072(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5072(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5072(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5072(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttribs2svNV), .-GL_PREFIX(VertexAttribs2svNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttribs3dvNV)
+ .type GL_PREFIX(VertexAttribs3dvNV), @function
+GL_PREFIX(VertexAttribs3dvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5080(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5080(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5080(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5080(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttribs3dvNV), .-GL_PREFIX(VertexAttribs3dvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttribs3fvNV)
+ .type GL_PREFIX(VertexAttribs3fvNV), @function
+GL_PREFIX(VertexAttribs3fvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5088(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5088(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5088(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5088(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttribs3fvNV), .-GL_PREFIX(VertexAttribs3fvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttribs3svNV)
+ .type GL_PREFIX(VertexAttribs3svNV), @function
+GL_PREFIX(VertexAttribs3svNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5096(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5096(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5096(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5096(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttribs3svNV), .-GL_PREFIX(VertexAttribs3svNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttribs4dvNV)
+ .type GL_PREFIX(VertexAttribs4dvNV), @function
+GL_PREFIX(VertexAttribs4dvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5104(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5104(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5104(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5104(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttribs4dvNV), .-GL_PREFIX(VertexAttribs4dvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttribs4fvNV)
+ .type GL_PREFIX(VertexAttribs4fvNV), @function
+GL_PREFIX(VertexAttribs4fvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5112(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5112(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5112(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5112(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttribs4fvNV), .-GL_PREFIX(VertexAttribs4fvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttribs4svNV)
+ .type GL_PREFIX(VertexAttribs4svNV), @function
+GL_PREFIX(VertexAttribs4svNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5120(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5120(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5120(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5120(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttribs4svNV), .-GL_PREFIX(VertexAttribs4svNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttribs4ubvNV)
+ .type GL_PREFIX(VertexAttribs4ubvNV), @function
+GL_PREFIX(VertexAttribs4ubvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5128(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5128(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5128(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5128(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttribs4ubvNV), .-GL_PREFIX(VertexAttribs4ubvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PointParameteriNV)
+ .type GL_PREFIX(PointParameteriNV), @function
+GL_PREFIX(PointParameteriNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5136(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5136(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5136(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5136(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PointParameteriNV), .-GL_PREFIX(PointParameteriNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PointParameterivNV)
+ .type GL_PREFIX(PointParameterivNV), @function
+GL_PREFIX(PointParameterivNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5144(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5144(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5144(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5144(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PointParameterivNV), .-GL_PREFIX(PointParameterivNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiDrawArraysEXT)
+ .type GL_PREFIX(MultiDrawArraysEXT), @function
+GL_PREFIX(MultiDrawArraysEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5152(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5152(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5152(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5152(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiDrawArraysEXT), .-GL_PREFIX(MultiDrawArraysEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiDrawElementsEXT)
+ .type GL_PREFIX(MultiDrawElementsEXT), @function
+GL_PREFIX(MultiDrawElementsEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5160(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5160(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5160(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5160(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiDrawElementsEXT), .-GL_PREFIX(MultiDrawElementsEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ActiveStencilFaceEXT)
+ .type GL_PREFIX(ActiveStencilFaceEXT), @function
+GL_PREFIX(ActiveStencilFaceEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5168(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 5168(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5168(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 5168(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ActiveStencilFaceEXT), .-GL_PREFIX(ActiveStencilFaceEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DeleteFencesNV)
+ .type GL_PREFIX(DeleteFencesNV), @function
+GL_PREFIX(DeleteFencesNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5176(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5176(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5176(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5176(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DeleteFencesNV), .-GL_PREFIX(DeleteFencesNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GenFencesNV)
+ .type GL_PREFIX(GenFencesNV), @function
+GL_PREFIX(GenFencesNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5184(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5184(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5184(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5184(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GenFencesNV), .-GL_PREFIX(GenFencesNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(IsFenceNV)
+ .type GL_PREFIX(IsFenceNV), @function
+GL_PREFIX(IsFenceNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5192(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 5192(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5192(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 5192(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(IsFenceNV), .-GL_PREFIX(IsFenceNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(TestFenceNV)
+ .type GL_PREFIX(TestFenceNV), @function
+GL_PREFIX(TestFenceNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5200(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 5200(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5200(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 5200(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(TestFenceNV), .-GL_PREFIX(TestFenceNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetFenceivNV)
+ .type GL_PREFIX(GetFenceivNV), @function
+GL_PREFIX(GetFenceivNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5208(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5208(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5208(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5208(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetFenceivNV), .-GL_PREFIX(GetFenceivNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FinishFenceNV)
+ .type GL_PREFIX(FinishFenceNV), @function
+GL_PREFIX(FinishFenceNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5216(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 5216(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5216(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 5216(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FinishFenceNV), .-GL_PREFIX(FinishFenceNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SetFenceNV)
+ .type GL_PREFIX(SetFenceNV), @function
+GL_PREFIX(SetFenceNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5224(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5224(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5224(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5224(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SetFenceNV), .-GL_PREFIX(SetFenceNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4bvARB)
+ .type GL_PREFIX(VertexAttrib4bvARB), @function
+GL_PREFIX(VertexAttrib4bvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5232(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5232(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5232(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5232(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4bvARB), .-GL_PREFIX(VertexAttrib4bvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4ivARB)
+ .type GL_PREFIX(VertexAttrib4ivARB), @function
+GL_PREFIX(VertexAttrib4ivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5240(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5240(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5240(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5240(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4ivARB), .-GL_PREFIX(VertexAttrib4ivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4ubvARB)
+ .type GL_PREFIX(VertexAttrib4ubvARB), @function
+GL_PREFIX(VertexAttrib4ubvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5248(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5248(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5248(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5248(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4ubvARB), .-GL_PREFIX(VertexAttrib4ubvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4usvARB)
+ .type GL_PREFIX(VertexAttrib4usvARB), @function
+GL_PREFIX(VertexAttrib4usvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5256(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5256(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5256(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5256(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4usvARB), .-GL_PREFIX(VertexAttrib4usvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4uivARB)
+ .type GL_PREFIX(VertexAttrib4uivARB), @function
+GL_PREFIX(VertexAttrib4uivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5264(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5264(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5264(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5264(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4uivARB), .-GL_PREFIX(VertexAttrib4uivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4NbvARB)
+ .type GL_PREFIX(VertexAttrib4NbvARB), @function
+GL_PREFIX(VertexAttrib4NbvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5272(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5272(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5272(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5272(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4NbvARB), .-GL_PREFIX(VertexAttrib4NbvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4NsvARB)
+ .type GL_PREFIX(VertexAttrib4NsvARB), @function
+GL_PREFIX(VertexAttrib4NsvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5280(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5280(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5280(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5280(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4NsvARB), .-GL_PREFIX(VertexAttrib4NsvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4NivARB)
+ .type GL_PREFIX(VertexAttrib4NivARB), @function
+GL_PREFIX(VertexAttrib4NivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5288(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5288(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5288(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5288(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4NivARB), .-GL_PREFIX(VertexAttrib4NivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4NusvARB)
+ .type GL_PREFIX(VertexAttrib4NusvARB), @function
+GL_PREFIX(VertexAttrib4NusvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5296(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5296(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5296(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5296(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4NusvARB), .-GL_PREFIX(VertexAttrib4NusvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4NuivARB)
+ .type GL_PREFIX(VertexAttrib4NuivARB), @function
+GL_PREFIX(VertexAttrib4NuivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5304(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5304(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5304(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5304(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4NuivARB), .-GL_PREFIX(VertexAttrib4NuivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttribPointerARB)
+ .type GL_PREFIX(VertexAttribPointerARB), @function
+GL_PREFIX(VertexAttribPointerARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5312(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5312(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5312(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5312(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttribPointerARB), .-GL_PREFIX(VertexAttribPointerARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EnableVertexAttribArrayARB)
+ .type GL_PREFIX(EnableVertexAttribArrayARB), @function
+GL_PREFIX(EnableVertexAttribArrayARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5320(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 5320(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5320(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 5320(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EnableVertexAttribArrayARB), .-GL_PREFIX(EnableVertexAttribArrayARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DisableVertexAttribArrayARB)
+ .type GL_PREFIX(DisableVertexAttribArrayARB), @function
+GL_PREFIX(DisableVertexAttribArrayARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5328(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 5328(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5328(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 5328(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DisableVertexAttribArrayARB), .-GL_PREFIX(DisableVertexAttribArrayARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramStringARB)
+ .type GL_PREFIX(ProgramStringARB), @function
+GL_PREFIX(ProgramStringARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5336(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5336(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5336(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5336(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramStringARB), .-GL_PREFIX(ProgramStringARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramEnvParameter4dARB)
+ .type GL_PREFIX(ProgramEnvParameter4dARB), @function
+GL_PREFIX(ProgramEnvParameter4dARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5344(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ movq %xmm1, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %xmm1
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 5344(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5344(%rax), %r11
+ jmp *%r11
+1:
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ movq %xmm1, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ call _glapi_get_dispatch
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %xmm1
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 5344(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramEnvParameter4dARB), .-GL_PREFIX(ProgramEnvParameter4dARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramEnvParameter4dvARB)
+ .type GL_PREFIX(ProgramEnvParameter4dvARB), @function
+GL_PREFIX(ProgramEnvParameter4dvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5352(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5352(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5352(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5352(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramEnvParameter4dvARB), .-GL_PREFIX(ProgramEnvParameter4dvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramEnvParameter4fARB)
+ .type GL_PREFIX(ProgramEnvParameter4fARB), @function
+GL_PREFIX(ProgramEnvParameter4fARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5360(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ movq %xmm1, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %xmm1
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 5360(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5360(%rax), %r11
+ jmp *%r11
+1:
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ movq %xmm1, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ call _glapi_get_dispatch
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %xmm1
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 5360(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramEnvParameter4fARB), .-GL_PREFIX(ProgramEnvParameter4fARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramEnvParameter4fvARB)
+ .type GL_PREFIX(ProgramEnvParameter4fvARB), @function
+GL_PREFIX(ProgramEnvParameter4fvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5368(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5368(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5368(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5368(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramEnvParameter4fvARB), .-GL_PREFIX(ProgramEnvParameter4fvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramLocalParameter4dARB)
+ .type GL_PREFIX(ProgramLocalParameter4dARB), @function
+GL_PREFIX(ProgramLocalParameter4dARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5376(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ movq %xmm1, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %xmm1
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 5376(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5376(%rax), %r11
+ jmp *%r11
+1:
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ movq %xmm1, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ call _glapi_get_dispatch
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %xmm1
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 5376(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramLocalParameter4dARB), .-GL_PREFIX(ProgramLocalParameter4dARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramLocalParameter4dvARB)
+ .type GL_PREFIX(ProgramLocalParameter4dvARB), @function
+GL_PREFIX(ProgramLocalParameter4dvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5384(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5384(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5384(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5384(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramLocalParameter4dvARB), .-GL_PREFIX(ProgramLocalParameter4dvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramLocalParameter4fARB)
+ .type GL_PREFIX(ProgramLocalParameter4fARB), @function
+GL_PREFIX(ProgramLocalParameter4fARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5392(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ movq %xmm1, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %xmm1
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 5392(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5392(%rax), %r11
+ jmp *%r11
+1:
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %xmm0, 16(%rsp)
+ movq %xmm1, 24(%rsp)
+ movq %xmm2, 32(%rsp)
+ movq %xmm3, 40(%rsp)
+ call _glapi_get_dispatch
+ movq 40(%rsp), %xmm3
+ movq 32(%rsp), %xmm2
+ movq 24(%rsp), %xmm1
+ movq 16(%rsp), %xmm0
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 5392(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramLocalParameter4fARB), .-GL_PREFIX(ProgramLocalParameter4fARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramLocalParameter4fvARB)
+ .type GL_PREFIX(ProgramLocalParameter4fvARB), @function
+GL_PREFIX(ProgramLocalParameter4fvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5400(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5400(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5400(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5400(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramLocalParameter4fvARB), .-GL_PREFIX(ProgramLocalParameter4fvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetProgramEnvParameterdvARB)
+ .type GL_PREFIX(GetProgramEnvParameterdvARB), @function
+GL_PREFIX(GetProgramEnvParameterdvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5408(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5408(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5408(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5408(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetProgramEnvParameterdvARB), .-GL_PREFIX(GetProgramEnvParameterdvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetProgramEnvParameterfvARB)
+ .type GL_PREFIX(GetProgramEnvParameterfvARB), @function
+GL_PREFIX(GetProgramEnvParameterfvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5416(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5416(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5416(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5416(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetProgramEnvParameterfvARB), .-GL_PREFIX(GetProgramEnvParameterfvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetProgramLocalParameterdvARB)
+ .type GL_PREFIX(GetProgramLocalParameterdvARB), @function
+GL_PREFIX(GetProgramLocalParameterdvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5424(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5424(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5424(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5424(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetProgramLocalParameterdvARB), .-GL_PREFIX(GetProgramLocalParameterdvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetProgramLocalParameterfvARB)
+ .type GL_PREFIX(GetProgramLocalParameterfvARB), @function
+GL_PREFIX(GetProgramLocalParameterfvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5432(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5432(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5432(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5432(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetProgramLocalParameterfvARB), .-GL_PREFIX(GetProgramLocalParameterfvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetProgramivARB)
+ .type GL_PREFIX(GetProgramivARB), @function
+GL_PREFIX(GetProgramivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5440(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5440(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5440(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5440(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetProgramivARB), .-GL_PREFIX(GetProgramivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetProgramStringARB)
+ .type GL_PREFIX(GetProgramStringARB), @function
+GL_PREFIX(GetProgramStringARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5448(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5448(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5448(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5448(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetProgramStringARB), .-GL_PREFIX(GetProgramStringARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramNamedParameter4fNV)
+ .type GL_PREFIX(ProgramNamedParameter4fNV), @function
+GL_PREFIX(ProgramNamedParameter4fNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5456(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %rdx, 16(%rsp)
+ movq %xmm0, 24(%rsp)
+ movq %xmm1, 32(%rsp)
+ movq %xmm2, 40(%rsp)
+ movq %xmm3, 48(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 48(%rsp), %xmm3
+ movq 40(%rsp), %xmm2
+ movq 32(%rsp), %xmm1
+ movq 24(%rsp), %xmm0
+ movq 16(%rsp), %rdx
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 5456(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5456(%rax), %r11
+ jmp *%r11
+1:
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %rdx, 16(%rsp)
+ movq %xmm0, 24(%rsp)
+ movq %xmm1, 32(%rsp)
+ movq %xmm2, 40(%rsp)
+ movq %xmm3, 48(%rsp)
+ call _glapi_get_dispatch
+ movq 48(%rsp), %xmm3
+ movq 40(%rsp), %xmm2
+ movq 32(%rsp), %xmm1
+ movq 24(%rsp), %xmm0
+ movq 16(%rsp), %rdx
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 5456(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramNamedParameter4fNV), .-GL_PREFIX(ProgramNamedParameter4fNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramNamedParameter4dNV)
+ .type GL_PREFIX(ProgramNamedParameter4dNV), @function
+GL_PREFIX(ProgramNamedParameter4dNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5464(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %rdx, 16(%rsp)
+ movq %xmm0, 24(%rsp)
+ movq %xmm1, 32(%rsp)
+ movq %xmm2, 40(%rsp)
+ movq %xmm3, 48(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 48(%rsp), %xmm3
+ movq 40(%rsp), %xmm2
+ movq 32(%rsp), %xmm1
+ movq 24(%rsp), %xmm0
+ movq 16(%rsp), %rdx
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 5464(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5464(%rax), %r11
+ jmp *%r11
+1:
+ subq $56, %rsp
+ movq %rdi, (%rsp)
+ movq %rsi, 8(%rsp)
+ movq %rdx, 16(%rsp)
+ movq %xmm0, 24(%rsp)
+ movq %xmm1, 32(%rsp)
+ movq %xmm2, 40(%rsp)
+ movq %xmm3, 48(%rsp)
+ call _glapi_get_dispatch
+ movq 48(%rsp), %xmm3
+ movq 40(%rsp), %xmm2
+ movq 32(%rsp), %xmm1
+ movq 24(%rsp), %xmm0
+ movq 16(%rsp), %rdx
+ movq 8(%rsp), %rsi
+ movq (%rsp), %rdi
+ addq $56, %rsp
+ movq 5464(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramNamedParameter4dNV), .-GL_PREFIX(ProgramNamedParameter4dNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramNamedParameter4fvNV)
+ .type GL_PREFIX(ProgramNamedParameter4fvNV), @function
+GL_PREFIX(ProgramNamedParameter4fvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5472(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5472(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5472(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5472(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramNamedParameter4fvNV), .-GL_PREFIX(ProgramNamedParameter4fvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ProgramNamedParameter4dvNV)
+ .type GL_PREFIX(ProgramNamedParameter4dvNV), @function
+GL_PREFIX(ProgramNamedParameter4dvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5480(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5480(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5480(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5480(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ProgramNamedParameter4dvNV), .-GL_PREFIX(ProgramNamedParameter4dvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetProgramNamedParameterfvNV)
+ .type GL_PREFIX(GetProgramNamedParameterfvNV), @function
+GL_PREFIX(GetProgramNamedParameterfvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5488(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5488(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5488(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5488(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetProgramNamedParameterfvNV), .-GL_PREFIX(GetProgramNamedParameterfvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetProgramNamedParameterdvNV)
+ .type GL_PREFIX(GetProgramNamedParameterdvNV), @function
+GL_PREFIX(GetProgramNamedParameterdvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5496(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5496(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5496(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5496(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetProgramNamedParameterdvNV), .-GL_PREFIX(GetProgramNamedParameterdvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(BindBufferARB)
+ .type GL_PREFIX(BindBufferARB), @function
+GL_PREFIX(BindBufferARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5504(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5504(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5504(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5504(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(BindBufferARB), .-GL_PREFIX(BindBufferARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(BufferDataARB)
+ .type GL_PREFIX(BufferDataARB), @function
+GL_PREFIX(BufferDataARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5512(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5512(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5512(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5512(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(BufferDataARB), .-GL_PREFIX(BufferDataARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(BufferSubDataARB)
+ .type GL_PREFIX(BufferSubDataARB), @function
+GL_PREFIX(BufferSubDataARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5520(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5520(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5520(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5520(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(BufferSubDataARB), .-GL_PREFIX(BufferSubDataARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DeleteBuffersARB)
+ .type GL_PREFIX(DeleteBuffersARB), @function
+GL_PREFIX(DeleteBuffersARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5528(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5528(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5528(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5528(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DeleteBuffersARB), .-GL_PREFIX(DeleteBuffersARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GenBuffersARB)
+ .type GL_PREFIX(GenBuffersARB), @function
+GL_PREFIX(GenBuffersARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5536(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5536(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5536(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5536(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GenBuffersARB), .-GL_PREFIX(GenBuffersARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetBufferParameterivARB)
+ .type GL_PREFIX(GetBufferParameterivARB), @function
+GL_PREFIX(GetBufferParameterivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5544(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5544(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5544(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5544(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetBufferParameterivARB), .-GL_PREFIX(GetBufferParameterivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetBufferPointervARB)
+ .type GL_PREFIX(GetBufferPointervARB), @function
+GL_PREFIX(GetBufferPointervARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5552(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5552(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5552(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5552(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetBufferPointervARB), .-GL_PREFIX(GetBufferPointervARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetBufferSubDataARB)
+ .type GL_PREFIX(GetBufferSubDataARB), @function
+GL_PREFIX(GetBufferSubDataARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5560(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5560(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5560(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5560(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetBufferSubDataARB), .-GL_PREFIX(GetBufferSubDataARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(IsBufferARB)
+ .type GL_PREFIX(IsBufferARB), @function
+GL_PREFIX(IsBufferARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5568(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 5568(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5568(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 5568(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(IsBufferARB), .-GL_PREFIX(IsBufferARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MapBufferARB)
+ .type GL_PREFIX(MapBufferARB), @function
+GL_PREFIX(MapBufferARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5576(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5576(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5576(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5576(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MapBufferARB), .-GL_PREFIX(MapBufferARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(UnmapBufferARB)
+ .type GL_PREFIX(UnmapBufferARB), @function
+GL_PREFIX(UnmapBufferARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5584(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 5584(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5584(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 5584(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(UnmapBufferARB), .-GL_PREFIX(UnmapBufferARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DepthBoundsEXT)
+ .type GL_PREFIX(DepthBoundsEXT), @function
+GL_PREFIX(DepthBoundsEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5592(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5592(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5592(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5592(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DepthBoundsEXT), .-GL_PREFIX(DepthBoundsEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GenQueriesARB)
+ .type GL_PREFIX(GenQueriesARB), @function
+GL_PREFIX(GenQueriesARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5600(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5600(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5600(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5600(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GenQueriesARB), .-GL_PREFIX(GenQueriesARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DeleteQueriesARB)
+ .type GL_PREFIX(DeleteQueriesARB), @function
+GL_PREFIX(DeleteQueriesARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5608(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5608(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5608(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5608(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DeleteQueriesARB), .-GL_PREFIX(DeleteQueriesARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(IsQueryARB)
+ .type GL_PREFIX(IsQueryARB), @function
+GL_PREFIX(IsQueryARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5616(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 5616(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5616(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 5616(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(IsQueryARB), .-GL_PREFIX(IsQueryARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(BeginQueryARB)
+ .type GL_PREFIX(BeginQueryARB), @function
+GL_PREFIX(BeginQueryARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5624(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5624(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5624(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5624(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(BeginQueryARB), .-GL_PREFIX(BeginQueryARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EndQueryARB)
+ .type GL_PREFIX(EndQueryARB), @function
+GL_PREFIX(EndQueryARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5632(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 5632(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5632(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 5632(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EndQueryARB), .-GL_PREFIX(EndQueryARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetQueryivARB)
+ .type GL_PREFIX(GetQueryivARB), @function
+GL_PREFIX(GetQueryivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5640(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5640(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5640(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5640(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetQueryivARB), .-GL_PREFIX(GetQueryivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetQueryObjectivARB)
+ .type GL_PREFIX(GetQueryObjectivARB), @function
+GL_PREFIX(GetQueryObjectivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5648(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5648(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5648(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5648(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetQueryObjectivARB), .-GL_PREFIX(GetQueryObjectivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetQueryObjectuivARB)
+ .type GL_PREFIX(GetQueryObjectuivARB), @function
+GL_PREFIX(GetQueryObjectuivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5656(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5656(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5656(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5656(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetQueryObjectuivARB), .-GL_PREFIX(GetQueryObjectuivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiModeDrawArraysIBM)
+ .type GL_PREFIX(MultiModeDrawArraysIBM), @function
+GL_PREFIX(MultiModeDrawArraysIBM):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5664(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5664(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5664(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5664(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiModeDrawArraysIBM), .-GL_PREFIX(MultiModeDrawArraysIBM)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(MultiModeDrawElementsIBM)
+ .type GL_PREFIX(MultiModeDrawElementsIBM), @function
+GL_PREFIX(MultiModeDrawElementsIBM):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5672(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5672(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5672(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5672(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(MultiModeDrawElementsIBM), .-GL_PREFIX(MultiModeDrawElementsIBM)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(BlendEquationSeparateEXT)
+ .type GL_PREFIX(BlendEquationSeparateEXT), @function
+GL_PREFIX(BlendEquationSeparateEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5680(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5680(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5680(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5680(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(BlendEquationSeparateEXT), .-GL_PREFIX(BlendEquationSeparateEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DeleteObjectARB)
+ .type GL_PREFIX(DeleteObjectARB), @function
+GL_PREFIX(DeleteObjectARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5688(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 5688(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5688(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 5688(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DeleteObjectARB), .-GL_PREFIX(DeleteObjectARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetHandleARB)
+ .type GL_PREFIX(GetHandleARB), @function
+GL_PREFIX(GetHandleARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5696(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 5696(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5696(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 5696(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetHandleARB), .-GL_PREFIX(GetHandleARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DetachObjectARB)
+ .type GL_PREFIX(DetachObjectARB), @function
+GL_PREFIX(DetachObjectARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5704(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5704(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5704(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5704(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DetachObjectARB), .-GL_PREFIX(DetachObjectARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CreateShaderObjectARB)
+ .type GL_PREFIX(CreateShaderObjectARB), @function
+GL_PREFIX(CreateShaderObjectARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5712(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 5712(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5712(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 5712(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CreateShaderObjectARB), .-GL_PREFIX(CreateShaderObjectARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ShaderSourceARB)
+ .type GL_PREFIX(ShaderSourceARB), @function
+GL_PREFIX(ShaderSourceARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5720(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5720(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5720(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5720(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ShaderSourceARB), .-GL_PREFIX(ShaderSourceARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CompileShaderARB)
+ .type GL_PREFIX(CompileShaderARB), @function
+GL_PREFIX(CompileShaderARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5728(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 5728(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5728(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 5728(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CompileShaderARB), .-GL_PREFIX(CompileShaderARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CreateProgramObjectARB)
+ .type GL_PREFIX(CreateProgramObjectARB), @function
+GL_PREFIX(CreateProgramObjectARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5736(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 5736(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5736(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 5736(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CreateProgramObjectARB), .-GL_PREFIX(CreateProgramObjectARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(AttachObjectARB)
+ .type GL_PREFIX(AttachObjectARB), @function
+GL_PREFIX(AttachObjectARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5744(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5744(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5744(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5744(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(AttachObjectARB), .-GL_PREFIX(AttachObjectARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(LinkProgramARB)
+ .type GL_PREFIX(LinkProgramARB), @function
+GL_PREFIX(LinkProgramARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5752(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 5752(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5752(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 5752(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(LinkProgramARB), .-GL_PREFIX(LinkProgramARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(UseProgramObjectARB)
+ .type GL_PREFIX(UseProgramObjectARB), @function
+GL_PREFIX(UseProgramObjectARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5760(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 5760(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5760(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 5760(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(UseProgramObjectARB), .-GL_PREFIX(UseProgramObjectARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ValidateProgramARB)
+ .type GL_PREFIX(ValidateProgramARB), @function
+GL_PREFIX(ValidateProgramARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5768(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 5768(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5768(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 5768(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ValidateProgramARB), .-GL_PREFIX(ValidateProgramARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Uniform1fARB)
+ .type GL_PREFIX(Uniform1fARB), @function
+GL_PREFIX(Uniform1fARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5776(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 5776(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5776(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 5776(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Uniform1fARB), .-GL_PREFIX(Uniform1fARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Uniform2fARB)
+ .type GL_PREFIX(Uniform2fARB), @function
+GL_PREFIX(Uniform2fARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5784(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 5784(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5784(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 5784(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Uniform2fARB), .-GL_PREFIX(Uniform2fARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Uniform3fARB)
+ .type GL_PREFIX(Uniform3fARB), @function
+GL_PREFIX(Uniform3fARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5792(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 5792(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5792(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 5792(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Uniform3fARB), .-GL_PREFIX(Uniform3fARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Uniform4fARB)
+ .type GL_PREFIX(Uniform4fARB), @function
+GL_PREFIX(Uniform4fARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5800(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ movq %xmm3, 32(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 32(%rsp), %xmm3
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 5800(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5800(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ movq %xmm3, 32(%rsp)
+ call _glapi_get_dispatch
+ movq 32(%rsp), %xmm3
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 5800(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Uniform4fARB), .-GL_PREFIX(Uniform4fARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Uniform1iARB)
+ .type GL_PREFIX(Uniform1iARB), @function
+GL_PREFIX(Uniform1iARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5808(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5808(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5808(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5808(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Uniform1iARB), .-GL_PREFIX(Uniform1iARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Uniform2iARB)
+ .type GL_PREFIX(Uniform2iARB), @function
+GL_PREFIX(Uniform2iARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5816(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5816(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5816(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5816(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Uniform2iARB), .-GL_PREFIX(Uniform2iARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Uniform3iARB)
+ .type GL_PREFIX(Uniform3iARB), @function
+GL_PREFIX(Uniform3iARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5824(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5824(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5824(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5824(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Uniform3iARB), .-GL_PREFIX(Uniform3iARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Uniform4iARB)
+ .type GL_PREFIX(Uniform4iARB), @function
+GL_PREFIX(Uniform4iARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5832(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5832(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5832(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5832(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Uniform4iARB), .-GL_PREFIX(Uniform4iARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Uniform1fvARB)
+ .type GL_PREFIX(Uniform1fvARB), @function
+GL_PREFIX(Uniform1fvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5840(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5840(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5840(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5840(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Uniform1fvARB), .-GL_PREFIX(Uniform1fvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Uniform2fvARB)
+ .type GL_PREFIX(Uniform2fvARB), @function
+GL_PREFIX(Uniform2fvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5848(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5848(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5848(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5848(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Uniform2fvARB), .-GL_PREFIX(Uniform2fvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Uniform3fvARB)
+ .type GL_PREFIX(Uniform3fvARB), @function
+GL_PREFIX(Uniform3fvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5856(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5856(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5856(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5856(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Uniform3fvARB), .-GL_PREFIX(Uniform3fvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Uniform4fvARB)
+ .type GL_PREFIX(Uniform4fvARB), @function
+GL_PREFIX(Uniform4fvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5864(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5864(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5864(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5864(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Uniform4fvARB), .-GL_PREFIX(Uniform4fvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Uniform1ivARB)
+ .type GL_PREFIX(Uniform1ivARB), @function
+GL_PREFIX(Uniform1ivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5872(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5872(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5872(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5872(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Uniform1ivARB), .-GL_PREFIX(Uniform1ivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Uniform2ivARB)
+ .type GL_PREFIX(Uniform2ivARB), @function
+GL_PREFIX(Uniform2ivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5880(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5880(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5880(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5880(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Uniform2ivARB), .-GL_PREFIX(Uniform2ivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Uniform3ivARB)
+ .type GL_PREFIX(Uniform3ivARB), @function
+GL_PREFIX(Uniform3ivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5888(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5888(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5888(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5888(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Uniform3ivARB), .-GL_PREFIX(Uniform3ivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(Uniform4ivARB)
+ .type GL_PREFIX(Uniform4ivARB), @function
+GL_PREFIX(Uniform4ivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5896(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5896(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5896(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5896(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(Uniform4ivARB), .-GL_PREFIX(Uniform4ivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(UniformMatrix2fvARB)
+ .type GL_PREFIX(UniformMatrix2fvARB), @function
+GL_PREFIX(UniformMatrix2fvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5904(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5904(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5904(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5904(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(UniformMatrix2fvARB), .-GL_PREFIX(UniformMatrix2fvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(UniformMatrix3fvARB)
+ .type GL_PREFIX(UniformMatrix3fvARB), @function
+GL_PREFIX(UniformMatrix3fvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5912(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5912(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5912(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5912(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(UniformMatrix3fvARB), .-GL_PREFIX(UniformMatrix3fvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(UniformMatrix4fvARB)
+ .type GL_PREFIX(UniformMatrix4fvARB), @function
+GL_PREFIX(UniformMatrix4fvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5920(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5920(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5920(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5920(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(UniformMatrix4fvARB), .-GL_PREFIX(UniformMatrix4fvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetObjectParameterfvARB)
+ .type GL_PREFIX(GetObjectParameterfvARB), @function
+GL_PREFIX(GetObjectParameterfvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5928(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5928(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5928(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5928(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetObjectParameterfvARB), .-GL_PREFIX(GetObjectParameterfvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetObjectParameterivARB)
+ .type GL_PREFIX(GetObjectParameterivARB), @function
+GL_PREFIX(GetObjectParameterivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5936(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5936(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5936(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5936(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetObjectParameterivARB), .-GL_PREFIX(GetObjectParameterivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetInfoLogARB)
+ .type GL_PREFIX(GetInfoLogARB), @function
+GL_PREFIX(GetInfoLogARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5944(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5944(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5944(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5944(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetInfoLogARB), .-GL_PREFIX(GetInfoLogARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetAttachedObjectsARB)
+ .type GL_PREFIX(GetAttachedObjectsARB), @function
+GL_PREFIX(GetAttachedObjectsARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5952(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5952(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5952(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5952(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetAttachedObjectsARB), .-GL_PREFIX(GetAttachedObjectsARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetUniformLocationARB)
+ .type GL_PREFIX(GetUniformLocationARB), @function
+GL_PREFIX(GetUniformLocationARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5960(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5960(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5960(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 5960(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetUniformLocationARB), .-GL_PREFIX(GetUniformLocationARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetActiveUniformARB)
+ .type GL_PREFIX(GetActiveUniformARB), @function
+GL_PREFIX(GetActiveUniformARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5968(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5968(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5968(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5968(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetActiveUniformARB), .-GL_PREFIX(GetActiveUniformARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetUniformfvARB)
+ .type GL_PREFIX(GetUniformfvARB), @function
+GL_PREFIX(GetUniformfvARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5976(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5976(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5976(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5976(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetUniformfvARB), .-GL_PREFIX(GetUniformfvARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetUniformivARB)
+ .type GL_PREFIX(GetUniformivARB), @function
+GL_PREFIX(GetUniformivARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5984(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5984(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5984(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5984(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetUniformivARB), .-GL_PREFIX(GetUniformivARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetShaderSourceARB)
+ .type GL_PREFIX(GetShaderSourceARB), @function
+GL_PREFIX(GetShaderSourceARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 5992(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5992(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 5992(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 5992(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetShaderSourceARB), .-GL_PREFIX(GetShaderSourceARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(BindAttribLocationARB)
+ .type GL_PREFIX(BindAttribLocationARB), @function
+GL_PREFIX(BindAttribLocationARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6000(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6000(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6000(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6000(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(BindAttribLocationARB), .-GL_PREFIX(BindAttribLocationARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetActiveAttribARB)
+ .type GL_PREFIX(GetActiveAttribARB), @function
+GL_PREFIX(GetActiveAttribARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6008(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6008(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6008(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6008(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetActiveAttribARB), .-GL_PREFIX(GetActiveAttribARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetAttribLocationARB)
+ .type GL_PREFIX(GetAttribLocationARB), @function
+GL_PREFIX(GetAttribLocationARB):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6016(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6016(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6016(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6016(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetAttribLocationARB), .-GL_PREFIX(GetAttribLocationARB)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetVertexAttribdvNV)
+ .type GL_PREFIX(GetVertexAttribdvNV), @function
+GL_PREFIX(GetVertexAttribdvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6024(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6024(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6024(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6024(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetVertexAttribdvNV), .-GL_PREFIX(GetVertexAttribdvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetVertexAttribfvNV)
+ .type GL_PREFIX(GetVertexAttribfvNV), @function
+GL_PREFIX(GetVertexAttribfvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6032(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6032(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6032(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6032(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetVertexAttribfvNV), .-GL_PREFIX(GetVertexAttribfvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetVertexAttribivNV)
+ .type GL_PREFIX(GetVertexAttribivNV), @function
+GL_PREFIX(GetVertexAttribivNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6040(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6040(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6040(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6040(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetVertexAttribivNV), .-GL_PREFIX(GetVertexAttribivNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib1dNV)
+ .type GL_PREFIX(VertexAttrib1dNV), @function
+GL_PREFIX(VertexAttrib1dNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6048(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 6048(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6048(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 6048(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib1dNV), .-GL_PREFIX(VertexAttrib1dNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib1dvNV)
+ .type GL_PREFIX(VertexAttrib1dvNV), @function
+GL_PREFIX(VertexAttrib1dvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6056(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6056(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6056(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6056(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib1dvNV), .-GL_PREFIX(VertexAttrib1dvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib1fNV)
+ .type GL_PREFIX(VertexAttrib1fNV), @function
+GL_PREFIX(VertexAttrib1fNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6064(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 6064(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6064(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ call _glapi_get_dispatch
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 6064(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib1fNV), .-GL_PREFIX(VertexAttrib1fNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib1fvNV)
+ .type GL_PREFIX(VertexAttrib1fvNV), @function
+GL_PREFIX(VertexAttrib1fvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6072(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6072(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6072(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6072(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib1fvNV), .-GL_PREFIX(VertexAttrib1fvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib1sNV)
+ .type GL_PREFIX(VertexAttrib1sNV), @function
+GL_PREFIX(VertexAttrib1sNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6080(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6080(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6080(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6080(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib1sNV), .-GL_PREFIX(VertexAttrib1sNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib1svNV)
+ .type GL_PREFIX(VertexAttrib1svNV), @function
+GL_PREFIX(VertexAttrib1svNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6088(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6088(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6088(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6088(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib1svNV), .-GL_PREFIX(VertexAttrib1svNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib2dNV)
+ .type GL_PREFIX(VertexAttrib2dNV), @function
+GL_PREFIX(VertexAttrib2dNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6096(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 6096(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6096(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 6096(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib2dNV), .-GL_PREFIX(VertexAttrib2dNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib2dvNV)
+ .type GL_PREFIX(VertexAttrib2dvNV), @function
+GL_PREFIX(VertexAttrib2dvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6104(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6104(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6104(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6104(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib2dvNV), .-GL_PREFIX(VertexAttrib2dvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib2fNV)
+ .type GL_PREFIX(VertexAttrib2fNV), @function
+GL_PREFIX(VertexAttrib2fNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6112(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 6112(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6112(%rax), %r11
+ jmp *%r11
+1:
+ subq $24, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ call _glapi_get_dispatch
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $24, %rsp
+ movq 6112(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib2fNV), .-GL_PREFIX(VertexAttrib2fNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib2fvNV)
+ .type GL_PREFIX(VertexAttrib2fvNV), @function
+GL_PREFIX(VertexAttrib2fvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6120(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6120(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6120(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6120(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib2fvNV), .-GL_PREFIX(VertexAttrib2fvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib2sNV)
+ .type GL_PREFIX(VertexAttrib2sNV), @function
+GL_PREFIX(VertexAttrib2sNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6128(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6128(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6128(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6128(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib2sNV), .-GL_PREFIX(VertexAttrib2sNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib2svNV)
+ .type GL_PREFIX(VertexAttrib2svNV), @function
+GL_PREFIX(VertexAttrib2svNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6136(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6136(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6136(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6136(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib2svNV), .-GL_PREFIX(VertexAttrib2svNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib3dNV)
+ .type GL_PREFIX(VertexAttrib3dNV), @function
+GL_PREFIX(VertexAttrib3dNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6144(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 6144(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6144(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 6144(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib3dNV), .-GL_PREFIX(VertexAttrib3dNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib3dvNV)
+ .type GL_PREFIX(VertexAttrib3dvNV), @function
+GL_PREFIX(VertexAttrib3dvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6152(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6152(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6152(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6152(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib3dvNV), .-GL_PREFIX(VertexAttrib3dvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib3fNV)
+ .type GL_PREFIX(VertexAttrib3fNV), @function
+GL_PREFIX(VertexAttrib3fNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6160(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 6160(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6160(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ call _glapi_get_dispatch
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 6160(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib3fNV), .-GL_PREFIX(VertexAttrib3fNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib3fvNV)
+ .type GL_PREFIX(VertexAttrib3fvNV), @function
+GL_PREFIX(VertexAttrib3fvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6168(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6168(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6168(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6168(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib3fvNV), .-GL_PREFIX(VertexAttrib3fvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib3sNV)
+ .type GL_PREFIX(VertexAttrib3sNV), @function
+GL_PREFIX(VertexAttrib3sNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6176(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6176(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6176(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6176(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib3sNV), .-GL_PREFIX(VertexAttrib3sNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib3svNV)
+ .type GL_PREFIX(VertexAttrib3svNV), @function
+GL_PREFIX(VertexAttrib3svNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6184(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6184(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6184(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6184(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib3svNV), .-GL_PREFIX(VertexAttrib3svNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4dNV)
+ .type GL_PREFIX(VertexAttrib4dNV), @function
+GL_PREFIX(VertexAttrib4dNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6192(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ movq %xmm3, 32(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 32(%rsp), %xmm3
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 6192(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6192(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ movq %xmm3, 32(%rsp)
+ call _glapi_get_dispatch
+ movq 32(%rsp), %xmm3
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 6192(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4dNV), .-GL_PREFIX(VertexAttrib4dNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4dvNV)
+ .type GL_PREFIX(VertexAttrib4dvNV), @function
+GL_PREFIX(VertexAttrib4dvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6200(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6200(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6200(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6200(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4dvNV), .-GL_PREFIX(VertexAttrib4dvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4fNV)
+ .type GL_PREFIX(VertexAttrib4fNV), @function
+GL_PREFIX(VertexAttrib4fNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6208(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ movq %xmm3, 32(%rsp)
+ call _x86_64_get_dispatch@PLT
+ movq 32(%rsp), %xmm3
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 6208(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6208(%rax), %r11
+ jmp *%r11
+1:
+ subq $40, %rsp
+ movq %rdi, (%rsp)
+ movq %xmm0, 8(%rsp)
+ movq %xmm1, 16(%rsp)
+ movq %xmm2, 24(%rsp)
+ movq %xmm3, 32(%rsp)
+ call _glapi_get_dispatch
+ movq 32(%rsp), %xmm3
+ movq 24(%rsp), %xmm2
+ movq 16(%rsp), %xmm1
+ movq 8(%rsp), %xmm0
+ movq (%rsp), %rdi
+ addq $40, %rsp
+ movq 6208(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4fNV), .-GL_PREFIX(VertexAttrib4fNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4fvNV)
+ .type GL_PREFIX(VertexAttrib4fvNV), @function
+GL_PREFIX(VertexAttrib4fvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6216(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6216(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6216(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6216(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4fvNV), .-GL_PREFIX(VertexAttrib4fvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4sNV)
+ .type GL_PREFIX(VertexAttrib4sNV), @function
+GL_PREFIX(VertexAttrib4sNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6224(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6224(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6224(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6224(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4sNV), .-GL_PREFIX(VertexAttrib4sNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4svNV)
+ .type GL_PREFIX(VertexAttrib4svNV), @function
+GL_PREFIX(VertexAttrib4svNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6232(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6232(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6232(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6232(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4svNV), .-GL_PREFIX(VertexAttrib4svNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4ubNV)
+ .type GL_PREFIX(VertexAttrib4ubNV), @function
+GL_PREFIX(VertexAttrib4ubNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6240(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6240(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6240(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6240(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4ubNV), .-GL_PREFIX(VertexAttrib4ubNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(VertexAttrib4ubvNV)
+ .type GL_PREFIX(VertexAttrib4ubvNV), @function
+GL_PREFIX(VertexAttrib4ubvNV):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6248(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6248(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6248(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6248(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(VertexAttrib4ubvNV), .-GL_PREFIX(VertexAttrib4ubvNV)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GenFragmentShadersATI)
+ .type GL_PREFIX(GenFragmentShadersATI), @function
+GL_PREFIX(GenFragmentShadersATI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6256(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 6256(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6256(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 6256(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GenFragmentShadersATI), .-GL_PREFIX(GenFragmentShadersATI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(BindFragmentShaderATI)
+ .type GL_PREFIX(BindFragmentShaderATI), @function
+GL_PREFIX(BindFragmentShaderATI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6264(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 6264(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6264(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 6264(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(BindFragmentShaderATI), .-GL_PREFIX(BindFragmentShaderATI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DeleteFragmentShaderATI)
+ .type GL_PREFIX(DeleteFragmentShaderATI), @function
+GL_PREFIX(DeleteFragmentShaderATI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6272(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 6272(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6272(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 6272(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DeleteFragmentShaderATI), .-GL_PREFIX(DeleteFragmentShaderATI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(BeginFragmentShaderATI)
+ .type GL_PREFIX(BeginFragmentShaderATI), @function
+GL_PREFIX(BeginFragmentShaderATI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6280(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 6280(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6280(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 6280(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(BeginFragmentShaderATI), .-GL_PREFIX(BeginFragmentShaderATI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(EndFragmentShaderATI)
+ .type GL_PREFIX(EndFragmentShaderATI), @function
+GL_PREFIX(EndFragmentShaderATI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6288(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ movq 6288(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6288(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ movq 6288(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(EndFragmentShaderATI), .-GL_PREFIX(EndFragmentShaderATI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(PassTexCoordATI)
+ .type GL_PREFIX(PassTexCoordATI), @function
+GL_PREFIX(PassTexCoordATI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6296(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6296(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6296(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6296(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(PassTexCoordATI), .-GL_PREFIX(PassTexCoordATI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SampleMapATI)
+ .type GL_PREFIX(SampleMapATI), @function
+GL_PREFIX(SampleMapATI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6304(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6304(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6304(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6304(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SampleMapATI), .-GL_PREFIX(SampleMapATI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ColorFragmentOp1ATI)
+ .type GL_PREFIX(ColorFragmentOp1ATI), @function
+GL_PREFIX(ColorFragmentOp1ATI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6312(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6312(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6312(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6312(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ColorFragmentOp1ATI), .-GL_PREFIX(ColorFragmentOp1ATI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ColorFragmentOp2ATI)
+ .type GL_PREFIX(ColorFragmentOp2ATI), @function
+GL_PREFIX(ColorFragmentOp2ATI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6320(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6320(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6320(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6320(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ColorFragmentOp2ATI), .-GL_PREFIX(ColorFragmentOp2ATI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(ColorFragmentOp3ATI)
+ .type GL_PREFIX(ColorFragmentOp3ATI), @function
+GL_PREFIX(ColorFragmentOp3ATI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6328(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6328(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6328(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6328(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(ColorFragmentOp3ATI), .-GL_PREFIX(ColorFragmentOp3ATI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(AlphaFragmentOp1ATI)
+ .type GL_PREFIX(AlphaFragmentOp1ATI), @function
+GL_PREFIX(AlphaFragmentOp1ATI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6336(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6336(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6336(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6336(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(AlphaFragmentOp1ATI), .-GL_PREFIX(AlphaFragmentOp1ATI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(AlphaFragmentOp2ATI)
+ .type GL_PREFIX(AlphaFragmentOp2ATI), @function
+GL_PREFIX(AlphaFragmentOp2ATI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6344(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6344(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6344(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6344(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(AlphaFragmentOp2ATI), .-GL_PREFIX(AlphaFragmentOp2ATI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(AlphaFragmentOp3ATI)
+ .type GL_PREFIX(AlphaFragmentOp3ATI), @function
+GL_PREFIX(AlphaFragmentOp3ATI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6352(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6352(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6352(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6352(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(AlphaFragmentOp3ATI), .-GL_PREFIX(AlphaFragmentOp3ATI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(SetFragmentShaderConstantATI)
+ .type GL_PREFIX(SetFragmentShaderConstantATI), @function
+GL_PREFIX(SetFragmentShaderConstantATI):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6360(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6360(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6360(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6360(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(SetFragmentShaderConstantATI), .-GL_PREFIX(SetFragmentShaderConstantATI)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(IsRenderbufferEXT)
+ .type GL_PREFIX(IsRenderbufferEXT), @function
+GL_PREFIX(IsRenderbufferEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6368(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 6368(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6368(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 6368(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(IsRenderbufferEXT), .-GL_PREFIX(IsRenderbufferEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(BindRenderbufferEXT)
+ .type GL_PREFIX(BindRenderbufferEXT), @function
+GL_PREFIX(BindRenderbufferEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6376(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6376(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6376(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6376(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(BindRenderbufferEXT), .-GL_PREFIX(BindRenderbufferEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DeleteRenderbuffersEXT)
+ .type GL_PREFIX(DeleteRenderbuffersEXT), @function
+GL_PREFIX(DeleteRenderbuffersEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6384(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6384(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6384(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6384(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DeleteRenderbuffersEXT), .-GL_PREFIX(DeleteRenderbuffersEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GenRenderbuffersEXT)
+ .type GL_PREFIX(GenRenderbuffersEXT), @function
+GL_PREFIX(GenRenderbuffersEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6392(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6392(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6392(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6392(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GenRenderbuffersEXT), .-GL_PREFIX(GenRenderbuffersEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(RenderbufferStorageEXT)
+ .type GL_PREFIX(RenderbufferStorageEXT), @function
+GL_PREFIX(RenderbufferStorageEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6400(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6400(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6400(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6400(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(RenderbufferStorageEXT), .-GL_PREFIX(RenderbufferStorageEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetRenderbufferParameterivEXT)
+ .type GL_PREFIX(GetRenderbufferParameterivEXT), @function
+GL_PREFIX(GetRenderbufferParameterivEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6408(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _x86_64_get_dispatch@PLT
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6408(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6408(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ call _glapi_get_dispatch
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6408(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetRenderbufferParameterivEXT), .-GL_PREFIX(GetRenderbufferParameterivEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(IsFramebufferEXT)
+ .type GL_PREFIX(IsFramebufferEXT), @function
+GL_PREFIX(IsFramebufferEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6416(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 6416(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6416(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 6416(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(IsFramebufferEXT), .-GL_PREFIX(IsFramebufferEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(BindFramebufferEXT)
+ .type GL_PREFIX(BindFramebufferEXT), @function
+GL_PREFIX(BindFramebufferEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6424(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6424(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6424(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6424(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(BindFramebufferEXT), .-GL_PREFIX(BindFramebufferEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(DeleteFramebuffersEXT)
+ .type GL_PREFIX(DeleteFramebuffersEXT), @function
+GL_PREFIX(DeleteFramebuffersEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6432(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6432(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6432(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6432(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(DeleteFramebuffersEXT), .-GL_PREFIX(DeleteFramebuffersEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GenFramebuffersEXT)
+ .type GL_PREFIX(GenFramebuffersEXT), @function
+GL_PREFIX(GenFramebuffersEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6440(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6440(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6440(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6440(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GenFramebuffersEXT), .-GL_PREFIX(GenFramebuffersEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(CheckFramebufferStatusEXT)
+ .type GL_PREFIX(CheckFramebufferStatusEXT), @function
+GL_PREFIX(CheckFramebufferStatusEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6448(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 6448(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6448(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 6448(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(CheckFramebufferStatusEXT), .-GL_PREFIX(CheckFramebufferStatusEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FramebufferTexture1DEXT)
+ .type GL_PREFIX(FramebufferTexture1DEXT), @function
+GL_PREFIX(FramebufferTexture1DEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6456(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6456(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6456(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6456(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FramebufferTexture1DEXT), .-GL_PREFIX(FramebufferTexture1DEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FramebufferTexture2DEXT)
+ .type GL_PREFIX(FramebufferTexture2DEXT), @function
+GL_PREFIX(FramebufferTexture2DEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6464(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _x86_64_get_dispatch@PLT
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6464(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6464(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ call _glapi_get_dispatch
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6464(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FramebufferTexture2DEXT), .-GL_PREFIX(FramebufferTexture2DEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FramebufferTexture3DEXT)
+ .type GL_PREFIX(FramebufferTexture3DEXT), @function
+GL_PREFIX(FramebufferTexture3DEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6472(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6472(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6472(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %r8
+ pushq %r9
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %r9
+ popq %r8
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6472(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FramebufferTexture3DEXT), .-GL_PREFIX(FramebufferTexture3DEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(FramebufferRenderbufferEXT)
+ .type GL_PREFIX(FramebufferRenderbufferEXT), @function
+GL_PREFIX(FramebufferRenderbufferEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6480(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6480(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6480(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6480(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(FramebufferRenderbufferEXT), .-GL_PREFIX(FramebufferRenderbufferEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GetFramebufferAttachmentParameterivEXT)
+ .type GL_PREFIX(GetFramebufferAttachmentParameterivEXT), @function
+GL_PREFIX(GetFramebufferAttachmentParameterivEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6488(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6488(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6488(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6488(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GetFramebufferAttachmentParameterivEXT), .-GL_PREFIX(GetFramebufferAttachmentParameterivEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(GenerateMipmapEXT)
+ .type GL_PREFIX(GenerateMipmapEXT), @function
+GL_PREFIX(GenerateMipmapEXT):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6496(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ call _x86_64_get_dispatch@PLT
+ popq %rdi
+ movq 6496(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6496(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ call _glapi_get_dispatch
+ popq %rdi
+ movq 6496(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(GenerateMipmapEXT), .-GL_PREFIX(GenerateMipmapEXT)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(StencilFuncSeparate)
+ .type GL_PREFIX(StencilFuncSeparate), @function
+GL_PREFIX(StencilFuncSeparate):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6504(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6504(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6504(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6504(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(StencilFuncSeparate), .-GL_PREFIX(StencilFuncSeparate)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(StencilOpSeparate)
+ .type GL_PREFIX(StencilOpSeparate), @function
+GL_PREFIX(StencilOpSeparate):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6512(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6512(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6512(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rdx
+ pushq %rcx
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rcx
+ popq %rdx
+ popq %rsi
+ popq %rdi
+ movq 6512(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(StencilOpSeparate), .-GL_PREFIX(StencilOpSeparate)
+
+ .p2align 4,,15
+ .globl GL_PREFIX(StencilMaskSeparate)
+ .type GL_PREFIX(StencilMaskSeparate), @function
+GL_PREFIX(StencilMaskSeparate):
+#if defined(GLX_USE_TLS)
+ call _x86_64_get_dispatch@PLT
+ movq 6520(%rax), %r11
+ jmp *%r11
+#elif defined(PTHREADS)
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _x86_64_get_dispatch@PLT
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6520(%rax), %r11
+ jmp *%r11
+#else
+ movq _glapi_Dispatch(%rip), %rax
+ testq %rax, %rax
+ je 1f
+ movq 6520(%rax), %r11
+ jmp *%r11
+1:
+ pushq %rdi
+ pushq %rsi
+ pushq %rbp
+ call _glapi_get_dispatch
+ popq %rbp
+ popq %rsi
+ popq %rdi
+ movq 6520(%rax), %r11
+ jmp *%r11
+#endif /* defined(GLX_USE_TLS) */
+ .size GL_PREFIX(StencilMaskSeparate), .-GL_PREFIX(StencilMaskSeparate)
+
+ .globl GL_PREFIX(ArrayElementEXT) ; .set GL_PREFIX(ArrayElementEXT), GL_PREFIX(ArrayElement)
+ .globl GL_PREFIX(BindTextureEXT) ; .set GL_PREFIX(BindTextureEXT), GL_PREFIX(BindTexture)
+ .globl GL_PREFIX(DrawArraysEXT) ; .set GL_PREFIX(DrawArraysEXT), GL_PREFIX(DrawArrays)
+ .globl GL_PREFIX(CopyTexImage1DEXT) ; .set GL_PREFIX(CopyTexImage1DEXT), GL_PREFIX(CopyTexImage1D)
+ .globl GL_PREFIX(CopyTexImage2DEXT) ; .set GL_PREFIX(CopyTexImage2DEXT), GL_PREFIX(CopyTexImage2D)
+ .globl GL_PREFIX(CopyTexSubImage1DEXT) ; .set GL_PREFIX(CopyTexSubImage1DEXT), GL_PREFIX(CopyTexSubImage1D)
+ .globl GL_PREFIX(CopyTexSubImage2DEXT) ; .set GL_PREFIX(CopyTexSubImage2DEXT), GL_PREFIX(CopyTexSubImage2D)
+ .globl GL_PREFIX(DeleteTexturesEXT) ; .set GL_PREFIX(DeleteTexturesEXT), GL_PREFIX(DeleteTextures)
+ .globl GL_PREFIX(GetPointervEXT) ; .set GL_PREFIX(GetPointervEXT), GL_PREFIX(GetPointerv)
+ .globl GL_PREFIX(PrioritizeTexturesEXT) ; .set GL_PREFIX(PrioritizeTexturesEXT), GL_PREFIX(PrioritizeTextures)
+ .globl GL_PREFIX(TexSubImage1DEXT) ; .set GL_PREFIX(TexSubImage1DEXT), GL_PREFIX(TexSubImage1D)
+ .globl GL_PREFIX(TexSubImage2DEXT) ; .set GL_PREFIX(TexSubImage2DEXT), GL_PREFIX(TexSubImage2D)
+ .globl GL_PREFIX(BlendColorEXT) ; .set GL_PREFIX(BlendColorEXT), GL_PREFIX(BlendColor)
+ .globl GL_PREFIX(BlendEquationEXT) ; .set GL_PREFIX(BlendEquationEXT), GL_PREFIX(BlendEquation)
+ .globl GL_PREFIX(DrawRangeElementsEXT) ; .set GL_PREFIX(DrawRangeElementsEXT), GL_PREFIX(DrawRangeElements)
+ .globl GL_PREFIX(ColorTableSGI) ; .set GL_PREFIX(ColorTableSGI), GL_PREFIX(ColorTable)
+ .globl GL_PREFIX(ColorTableEXT) ; .set GL_PREFIX(ColorTableEXT), GL_PREFIX(ColorTable)
+ .globl GL_PREFIX(ColorTableParameterfvSGI) ; .set GL_PREFIX(ColorTableParameterfvSGI), GL_PREFIX(ColorTableParameterfv)
+ .globl GL_PREFIX(ColorTableParameterivSGI) ; .set GL_PREFIX(ColorTableParameterivSGI), GL_PREFIX(ColorTableParameteriv)
+ .globl GL_PREFIX(CopyColorTableSGI) ; .set GL_PREFIX(CopyColorTableSGI), GL_PREFIX(CopyColorTable)
+ .globl GL_PREFIX(ColorSubTableEXT) ; .set GL_PREFIX(ColorSubTableEXT), GL_PREFIX(ColorSubTable)
+ .globl GL_PREFIX(CopyColorSubTableEXT) ; .set GL_PREFIX(CopyColorSubTableEXT), GL_PREFIX(CopyColorSubTable)
+ .globl GL_PREFIX(ConvolutionFilter1DEXT) ; .set GL_PREFIX(ConvolutionFilter1DEXT), GL_PREFIX(ConvolutionFilter1D)
+ .globl GL_PREFIX(ConvolutionFilter2DEXT) ; .set GL_PREFIX(ConvolutionFilter2DEXT), GL_PREFIX(ConvolutionFilter2D)
+ .globl GL_PREFIX(ConvolutionParameterfEXT) ; .set GL_PREFIX(ConvolutionParameterfEXT), GL_PREFIX(ConvolutionParameterf)
+ .globl GL_PREFIX(ConvolutionParameterfvEXT) ; .set GL_PREFIX(ConvolutionParameterfvEXT), GL_PREFIX(ConvolutionParameterfv)
+ .globl GL_PREFIX(ConvolutionParameteriEXT) ; .set GL_PREFIX(ConvolutionParameteriEXT), GL_PREFIX(ConvolutionParameteri)
+ .globl GL_PREFIX(ConvolutionParameterivEXT) ; .set GL_PREFIX(ConvolutionParameterivEXT), GL_PREFIX(ConvolutionParameteriv)
+ .globl GL_PREFIX(CopyConvolutionFilter1DEXT) ; .set GL_PREFIX(CopyConvolutionFilter1DEXT), GL_PREFIX(CopyConvolutionFilter1D)
+ .globl GL_PREFIX(CopyConvolutionFilter2DEXT) ; .set GL_PREFIX(CopyConvolutionFilter2DEXT), GL_PREFIX(CopyConvolutionFilter2D)
+ .globl GL_PREFIX(SeparableFilter2DEXT) ; .set GL_PREFIX(SeparableFilter2DEXT), GL_PREFIX(SeparableFilter2D)
+ .globl GL_PREFIX(HistogramEXT) ; .set GL_PREFIX(HistogramEXT), GL_PREFIX(Histogram)
+ .globl GL_PREFIX(MinmaxEXT) ; .set GL_PREFIX(MinmaxEXT), GL_PREFIX(Minmax)
+ .globl GL_PREFIX(ResetHistogramEXT) ; .set GL_PREFIX(ResetHistogramEXT), GL_PREFIX(ResetHistogram)
+ .globl GL_PREFIX(ResetMinmaxEXT) ; .set GL_PREFIX(ResetMinmaxEXT), GL_PREFIX(ResetMinmax)
+ .globl GL_PREFIX(TexImage3DEXT) ; .set GL_PREFIX(TexImage3DEXT), GL_PREFIX(TexImage3D)
+ .globl GL_PREFIX(TexSubImage3DEXT) ; .set GL_PREFIX(TexSubImage3DEXT), GL_PREFIX(TexSubImage3D)
+ .globl GL_PREFIX(CopyTexSubImage3DEXT) ; .set GL_PREFIX(CopyTexSubImage3DEXT), GL_PREFIX(CopyTexSubImage3D)
+ .globl GL_PREFIX(ActiveTexture) ; .set GL_PREFIX(ActiveTexture), GL_PREFIX(ActiveTextureARB)
+ .globl GL_PREFIX(ClientActiveTexture) ; .set GL_PREFIX(ClientActiveTexture), GL_PREFIX(ClientActiveTextureARB)
+ .globl GL_PREFIX(MultiTexCoord1d) ; .set GL_PREFIX(MultiTexCoord1d), GL_PREFIX(MultiTexCoord1dARB)
+ .globl GL_PREFIX(MultiTexCoord1dv) ; .set GL_PREFIX(MultiTexCoord1dv), GL_PREFIX(MultiTexCoord1dvARB)
+ .globl GL_PREFIX(MultiTexCoord1f) ; .set GL_PREFIX(MultiTexCoord1f), GL_PREFIX(MultiTexCoord1fARB)
+ .globl GL_PREFIX(MultiTexCoord1fv) ; .set GL_PREFIX(MultiTexCoord1fv), GL_PREFIX(MultiTexCoord1fvARB)
+ .globl GL_PREFIX(MultiTexCoord1i) ; .set GL_PREFIX(MultiTexCoord1i), GL_PREFIX(MultiTexCoord1iARB)
+ .globl GL_PREFIX(MultiTexCoord1iv) ; .set GL_PREFIX(MultiTexCoord1iv), GL_PREFIX(MultiTexCoord1ivARB)
+ .globl GL_PREFIX(MultiTexCoord1s) ; .set GL_PREFIX(MultiTexCoord1s), GL_PREFIX(MultiTexCoord1sARB)
+ .globl GL_PREFIX(MultiTexCoord1sv) ; .set GL_PREFIX(MultiTexCoord1sv), GL_PREFIX(MultiTexCoord1svARB)
+ .globl GL_PREFIX(MultiTexCoord2d) ; .set GL_PREFIX(MultiTexCoord2d), GL_PREFIX(MultiTexCoord2dARB)
+ .globl GL_PREFIX(MultiTexCoord2dv) ; .set GL_PREFIX(MultiTexCoord2dv), GL_PREFIX(MultiTexCoord2dvARB)
+ .globl GL_PREFIX(MultiTexCoord2f) ; .set GL_PREFIX(MultiTexCoord2f), GL_PREFIX(MultiTexCoord2fARB)
+ .globl GL_PREFIX(MultiTexCoord2fv) ; .set GL_PREFIX(MultiTexCoord2fv), GL_PREFIX(MultiTexCoord2fvARB)
+ .globl GL_PREFIX(MultiTexCoord2i) ; .set GL_PREFIX(MultiTexCoord2i), GL_PREFIX(MultiTexCoord2iARB)
+ .globl GL_PREFIX(MultiTexCoord2iv) ; .set GL_PREFIX(MultiTexCoord2iv), GL_PREFIX(MultiTexCoord2ivARB)
+ .globl GL_PREFIX(MultiTexCoord2s) ; .set GL_PREFIX(MultiTexCoord2s), GL_PREFIX(MultiTexCoord2sARB)
+ .globl GL_PREFIX(MultiTexCoord2sv) ; .set GL_PREFIX(MultiTexCoord2sv), GL_PREFIX(MultiTexCoord2svARB)
+ .globl GL_PREFIX(MultiTexCoord3d) ; .set GL_PREFIX(MultiTexCoord3d), GL_PREFIX(MultiTexCoord3dARB)
+ .globl GL_PREFIX(MultiTexCoord3dv) ; .set GL_PREFIX(MultiTexCoord3dv), GL_PREFIX(MultiTexCoord3dvARB)
+ .globl GL_PREFIX(MultiTexCoord3f) ; .set GL_PREFIX(MultiTexCoord3f), GL_PREFIX(MultiTexCoord3fARB)
+ .globl GL_PREFIX(MultiTexCoord3fv) ; .set GL_PREFIX(MultiTexCoord3fv), GL_PREFIX(MultiTexCoord3fvARB)
+ .globl GL_PREFIX(MultiTexCoord3i) ; .set GL_PREFIX(MultiTexCoord3i), GL_PREFIX(MultiTexCoord3iARB)
+ .globl GL_PREFIX(MultiTexCoord3iv) ; .set GL_PREFIX(MultiTexCoord3iv), GL_PREFIX(MultiTexCoord3ivARB)
+ .globl GL_PREFIX(MultiTexCoord3s) ; .set GL_PREFIX(MultiTexCoord3s), GL_PREFIX(MultiTexCoord3sARB)
+ .globl GL_PREFIX(MultiTexCoord3sv) ; .set GL_PREFIX(MultiTexCoord3sv), GL_PREFIX(MultiTexCoord3svARB)
+ .globl GL_PREFIX(MultiTexCoord4d) ; .set GL_PREFIX(MultiTexCoord4d), GL_PREFIX(MultiTexCoord4dARB)
+ .globl GL_PREFIX(MultiTexCoord4dv) ; .set GL_PREFIX(MultiTexCoord4dv), GL_PREFIX(MultiTexCoord4dvARB)
+ .globl GL_PREFIX(MultiTexCoord4f) ; .set GL_PREFIX(MultiTexCoord4f), GL_PREFIX(MultiTexCoord4fARB)
+ .globl GL_PREFIX(MultiTexCoord4fv) ; .set GL_PREFIX(MultiTexCoord4fv), GL_PREFIX(MultiTexCoord4fvARB)
+ .globl GL_PREFIX(MultiTexCoord4i) ; .set GL_PREFIX(MultiTexCoord4i), GL_PREFIX(MultiTexCoord4iARB)
+ .globl GL_PREFIX(MultiTexCoord4iv) ; .set GL_PREFIX(MultiTexCoord4iv), GL_PREFIX(MultiTexCoord4ivARB)
+ .globl GL_PREFIX(MultiTexCoord4s) ; .set GL_PREFIX(MultiTexCoord4s), GL_PREFIX(MultiTexCoord4sARB)
+ .globl GL_PREFIX(MultiTexCoord4sv) ; .set GL_PREFIX(MultiTexCoord4sv), GL_PREFIX(MultiTexCoord4svARB)
+ .globl GL_PREFIX(LoadTransposeMatrixf) ; .set GL_PREFIX(LoadTransposeMatrixf), GL_PREFIX(LoadTransposeMatrixfARB)
+ .globl GL_PREFIX(LoadTransposeMatrixd) ; .set GL_PREFIX(LoadTransposeMatrixd), GL_PREFIX(LoadTransposeMatrixdARB)
+ .globl GL_PREFIX(MultTransposeMatrixf) ; .set GL_PREFIX(MultTransposeMatrixf), GL_PREFIX(MultTransposeMatrixfARB)
+ .globl GL_PREFIX(MultTransposeMatrixd) ; .set GL_PREFIX(MultTransposeMatrixd), GL_PREFIX(MultTransposeMatrixdARB)
+ .globl GL_PREFIX(SampleCoverage) ; .set GL_PREFIX(SampleCoverage), GL_PREFIX(SampleCoverageARB)
+ .globl GL_PREFIX(DrawBuffersATI) ; .set GL_PREFIX(DrawBuffersATI), GL_PREFIX(DrawBuffersARB)
+ .globl GL_PREFIX(SampleMaskEXT) ; .set GL_PREFIX(SampleMaskEXT), GL_PREFIX(SampleMaskSGIS)
+ .globl GL_PREFIX(SamplePatternEXT) ; .set GL_PREFIX(SamplePatternEXT), GL_PREFIX(SamplePatternSGIS)
+ .globl GL_PREFIX(PointParameterf) ; .set GL_PREFIX(PointParameterf), GL_PREFIX(PointParameterfEXT)
+ .globl GL_PREFIX(PointParameterfARB) ; .set GL_PREFIX(PointParameterfARB), GL_PREFIX(PointParameterfEXT)
+ .globl GL_PREFIX(PointParameterfSGIS) ; .set GL_PREFIX(PointParameterfSGIS), GL_PREFIX(PointParameterfEXT)
+ .globl GL_PREFIX(PointParameterfv) ; .set GL_PREFIX(PointParameterfv), GL_PREFIX(PointParameterfvEXT)
+ .globl GL_PREFIX(PointParameterfvARB) ; .set GL_PREFIX(PointParameterfvARB), GL_PREFIX(PointParameterfvEXT)
+ .globl GL_PREFIX(PointParameterfvSGIS) ; .set GL_PREFIX(PointParameterfvSGIS), GL_PREFIX(PointParameterfvEXT)
+ .globl GL_PREFIX(WindowPos2d) ; .set GL_PREFIX(WindowPos2d), GL_PREFIX(WindowPos2dMESA)
+ .globl GL_PREFIX(WindowPos2dARB) ; .set GL_PREFIX(WindowPos2dARB), GL_PREFIX(WindowPos2dMESA)
+ .globl GL_PREFIX(WindowPos2dv) ; .set GL_PREFIX(WindowPos2dv), GL_PREFIX(WindowPos2dvMESA)
+ .globl GL_PREFIX(WindowPos2dvARB) ; .set GL_PREFIX(WindowPos2dvARB), GL_PREFIX(WindowPos2dvMESA)
+ .globl GL_PREFIX(WindowPos2f) ; .set GL_PREFIX(WindowPos2f), GL_PREFIX(WindowPos2fMESA)
+ .globl GL_PREFIX(WindowPos2fARB) ; .set GL_PREFIX(WindowPos2fARB), GL_PREFIX(WindowPos2fMESA)
+ .globl GL_PREFIX(WindowPos2fv) ; .set GL_PREFIX(WindowPos2fv), GL_PREFIX(WindowPos2fvMESA)
+ .globl GL_PREFIX(WindowPos2fvARB) ; .set GL_PREFIX(WindowPos2fvARB), GL_PREFIX(WindowPos2fvMESA)
+ .globl GL_PREFIX(WindowPos2i) ; .set GL_PREFIX(WindowPos2i), GL_PREFIX(WindowPos2iMESA)
+ .globl GL_PREFIX(WindowPos2iARB) ; .set GL_PREFIX(WindowPos2iARB), GL_PREFIX(WindowPos2iMESA)
+ .globl GL_PREFIX(WindowPos2iv) ; .set GL_PREFIX(WindowPos2iv), GL_PREFIX(WindowPos2ivMESA)
+ .globl GL_PREFIX(WindowPos2ivARB) ; .set GL_PREFIX(WindowPos2ivARB), GL_PREFIX(WindowPos2ivMESA)
+ .globl GL_PREFIX(WindowPos2s) ; .set GL_PREFIX(WindowPos2s), GL_PREFIX(WindowPos2sMESA)
+ .globl GL_PREFIX(WindowPos2sARB) ; .set GL_PREFIX(WindowPos2sARB), GL_PREFIX(WindowPos2sMESA)
+ .globl GL_PREFIX(WindowPos2sv) ; .set GL_PREFIX(WindowPos2sv), GL_PREFIX(WindowPos2svMESA)
+ .globl GL_PREFIX(WindowPos2svARB) ; .set GL_PREFIX(WindowPos2svARB), GL_PREFIX(WindowPos2svMESA)
+ .globl GL_PREFIX(WindowPos3d) ; .set GL_PREFIX(WindowPos3d), GL_PREFIX(WindowPos3dMESA)
+ .globl GL_PREFIX(WindowPos3dARB) ; .set GL_PREFIX(WindowPos3dARB), GL_PREFIX(WindowPos3dMESA)
+ .globl GL_PREFIX(WindowPos3dv) ; .set GL_PREFIX(WindowPos3dv), GL_PREFIX(WindowPos3dvMESA)
+ .globl GL_PREFIX(WindowPos3dvARB) ; .set GL_PREFIX(WindowPos3dvARB), GL_PREFIX(WindowPos3dvMESA)
+ .globl GL_PREFIX(WindowPos3f) ; .set GL_PREFIX(WindowPos3f), GL_PREFIX(WindowPos3fMESA)
+ .globl GL_PREFIX(WindowPos3fARB) ; .set GL_PREFIX(WindowPos3fARB), GL_PREFIX(WindowPos3fMESA)
+ .globl GL_PREFIX(WindowPos3fv) ; .set GL_PREFIX(WindowPos3fv), GL_PREFIX(WindowPos3fvMESA)
+ .globl GL_PREFIX(WindowPos3fvARB) ; .set GL_PREFIX(WindowPos3fvARB), GL_PREFIX(WindowPos3fvMESA)
+ .globl GL_PREFIX(WindowPos3i) ; .set GL_PREFIX(WindowPos3i), GL_PREFIX(WindowPos3iMESA)
+ .globl GL_PREFIX(WindowPos3iARB) ; .set GL_PREFIX(WindowPos3iARB), GL_PREFIX(WindowPos3iMESA)
+ .globl GL_PREFIX(WindowPos3iv) ; .set GL_PREFIX(WindowPos3iv), GL_PREFIX(WindowPos3ivMESA)
+ .globl GL_PREFIX(WindowPos3ivARB) ; .set GL_PREFIX(WindowPos3ivARB), GL_PREFIX(WindowPos3ivMESA)
+ .globl GL_PREFIX(WindowPos3s) ; .set GL_PREFIX(WindowPos3s), GL_PREFIX(WindowPos3sMESA)
+ .globl GL_PREFIX(WindowPos3sARB) ; .set GL_PREFIX(WindowPos3sARB), GL_PREFIX(WindowPos3sMESA)
+ .globl GL_PREFIX(WindowPos3sv) ; .set GL_PREFIX(WindowPos3sv), GL_PREFIX(WindowPos3svMESA)
+ .globl GL_PREFIX(WindowPos3svARB) ; .set GL_PREFIX(WindowPos3svARB), GL_PREFIX(WindowPos3svMESA)
+ .globl GL_PREFIX(BlendFuncSeparate) ; .set GL_PREFIX(BlendFuncSeparate), GL_PREFIX(BlendFuncSeparateEXT)
+ .globl GL_PREFIX(BlendFuncSeparateINGR) ; .set GL_PREFIX(BlendFuncSeparateINGR), GL_PREFIX(BlendFuncSeparateEXT)
+ .globl GL_PREFIX(FogCoordf) ; .set GL_PREFIX(FogCoordf), GL_PREFIX(FogCoordfEXT)
+ .globl GL_PREFIX(FogCoordfv) ; .set GL_PREFIX(FogCoordfv), GL_PREFIX(FogCoordfvEXT)
+ .globl GL_PREFIX(FogCoordd) ; .set GL_PREFIX(FogCoordd), GL_PREFIX(FogCoorddEXT)
+ .globl GL_PREFIX(FogCoorddv) ; .set GL_PREFIX(FogCoorddv), GL_PREFIX(FogCoorddvEXT)
+ .globl GL_PREFIX(FogCoordPointer) ; .set GL_PREFIX(FogCoordPointer), GL_PREFIX(FogCoordPointerEXT)
+ .globl GL_PREFIX(CompressedTexImage3D) ; .set GL_PREFIX(CompressedTexImage3D), GL_PREFIX(CompressedTexImage3DARB)
+ .globl GL_PREFIX(CompressedTexImage2D) ; .set GL_PREFIX(CompressedTexImage2D), GL_PREFIX(CompressedTexImage2DARB)
+ .globl GL_PREFIX(CompressedTexImage1D) ; .set GL_PREFIX(CompressedTexImage1D), GL_PREFIX(CompressedTexImage1DARB)
+ .globl GL_PREFIX(CompressedTexSubImage3D) ; .set GL_PREFIX(CompressedTexSubImage3D), GL_PREFIX(CompressedTexSubImage3DARB)
+ .globl GL_PREFIX(CompressedTexSubImage2D) ; .set GL_PREFIX(CompressedTexSubImage2D), GL_PREFIX(CompressedTexSubImage2DARB)
+ .globl GL_PREFIX(CompressedTexSubImage1D) ; .set GL_PREFIX(CompressedTexSubImage1D), GL_PREFIX(CompressedTexSubImage1DARB)
+ .globl GL_PREFIX(GetCompressedTexImage) ; .set GL_PREFIX(GetCompressedTexImage), GL_PREFIX(GetCompressedTexImageARB)
+ .globl GL_PREFIX(SecondaryColor3b) ; .set GL_PREFIX(SecondaryColor3b), GL_PREFIX(SecondaryColor3bEXT)
+ .globl GL_PREFIX(SecondaryColor3bv) ; .set GL_PREFIX(SecondaryColor3bv), GL_PREFIX(SecondaryColor3bvEXT)
+ .globl GL_PREFIX(SecondaryColor3d) ; .set GL_PREFIX(SecondaryColor3d), GL_PREFIX(SecondaryColor3dEXT)
+ .globl GL_PREFIX(SecondaryColor3dv) ; .set GL_PREFIX(SecondaryColor3dv), GL_PREFIX(SecondaryColor3dvEXT)
+ .globl GL_PREFIX(SecondaryColor3f) ; .set GL_PREFIX(SecondaryColor3f), GL_PREFIX(SecondaryColor3fEXT)
+ .globl GL_PREFIX(SecondaryColor3fv) ; .set GL_PREFIX(SecondaryColor3fv), GL_PREFIX(SecondaryColor3fvEXT)
+ .globl GL_PREFIX(SecondaryColor3i) ; .set GL_PREFIX(SecondaryColor3i), GL_PREFIX(SecondaryColor3iEXT)
+ .globl GL_PREFIX(SecondaryColor3iv) ; .set GL_PREFIX(SecondaryColor3iv), GL_PREFIX(SecondaryColor3ivEXT)
+ .globl GL_PREFIX(SecondaryColor3s) ; .set GL_PREFIX(SecondaryColor3s), GL_PREFIX(SecondaryColor3sEXT)
+ .globl GL_PREFIX(SecondaryColor3sv) ; .set GL_PREFIX(SecondaryColor3sv), GL_PREFIX(SecondaryColor3svEXT)
+ .globl GL_PREFIX(SecondaryColor3ub) ; .set GL_PREFIX(SecondaryColor3ub), GL_PREFIX(SecondaryColor3ubEXT)
+ .globl GL_PREFIX(SecondaryColor3ubv) ; .set GL_PREFIX(SecondaryColor3ubv), GL_PREFIX(SecondaryColor3ubvEXT)
+ .globl GL_PREFIX(SecondaryColor3ui) ; .set GL_PREFIX(SecondaryColor3ui), GL_PREFIX(SecondaryColor3uiEXT)
+ .globl GL_PREFIX(SecondaryColor3uiv) ; .set GL_PREFIX(SecondaryColor3uiv), GL_PREFIX(SecondaryColor3uivEXT)
+ .globl GL_PREFIX(SecondaryColor3us) ; .set GL_PREFIX(SecondaryColor3us), GL_PREFIX(SecondaryColor3usEXT)
+ .globl GL_PREFIX(SecondaryColor3usv) ; .set GL_PREFIX(SecondaryColor3usv), GL_PREFIX(SecondaryColor3usvEXT)
+ .globl GL_PREFIX(SecondaryColorPointer) ; .set GL_PREFIX(SecondaryColorPointer), GL_PREFIX(SecondaryColorPointerEXT)
+ .globl GL_PREFIX(BindProgramARB) ; .set GL_PREFIX(BindProgramARB), GL_PREFIX(BindProgramNV)
+ .globl GL_PREFIX(DeleteProgramsARB) ; .set GL_PREFIX(DeleteProgramsARB), GL_PREFIX(DeleteProgramsNV)
+ .globl GL_PREFIX(GenProgramsARB) ; .set GL_PREFIX(GenProgramsARB), GL_PREFIX(GenProgramsNV)
+ .globl GL_PREFIX(GetVertexAttribPointervARB) ; .set GL_PREFIX(GetVertexAttribPointervARB), GL_PREFIX(GetVertexAttribPointervNV)
+ .globl GL_PREFIX(IsProgramARB) ; .set GL_PREFIX(IsProgramARB), GL_PREFIX(IsProgramNV)
+ .globl GL_PREFIX(PointParameteri) ; .set GL_PREFIX(PointParameteri), GL_PREFIX(PointParameteriNV)
+ .globl GL_PREFIX(PointParameteriv) ; .set GL_PREFIX(PointParameteriv), GL_PREFIX(PointParameterivNV)
+ .globl GL_PREFIX(MultiDrawArrays) ; .set GL_PREFIX(MultiDrawArrays), GL_PREFIX(MultiDrawArraysEXT)
+ .globl GL_PREFIX(MultiDrawElements) ; .set GL_PREFIX(MultiDrawElements), GL_PREFIX(MultiDrawElementsEXT)
+ .globl GL_PREFIX(BindBuffer) ; .set GL_PREFIX(BindBuffer), GL_PREFIX(BindBufferARB)
+ .globl GL_PREFIX(BufferData) ; .set GL_PREFIX(BufferData), GL_PREFIX(BufferDataARB)
+ .globl GL_PREFIX(BufferSubData) ; .set GL_PREFIX(BufferSubData), GL_PREFIX(BufferSubDataARB)
+ .globl GL_PREFIX(DeleteBuffers) ; .set GL_PREFIX(DeleteBuffers), GL_PREFIX(DeleteBuffersARB)
+ .globl GL_PREFIX(GenBuffers) ; .set GL_PREFIX(GenBuffers), GL_PREFIX(GenBuffersARB)
+ .globl GL_PREFIX(GetBufferParameteriv) ; .set GL_PREFIX(GetBufferParameteriv), GL_PREFIX(GetBufferParameterivARB)
+ .globl GL_PREFIX(GetBufferPointerv) ; .set GL_PREFIX(GetBufferPointerv), GL_PREFIX(GetBufferPointervARB)
+ .globl GL_PREFIX(GetBufferSubData) ; .set GL_PREFIX(GetBufferSubData), GL_PREFIX(GetBufferSubDataARB)
+ .globl GL_PREFIX(IsBuffer) ; .set GL_PREFIX(IsBuffer), GL_PREFIX(IsBufferARB)
+ .globl GL_PREFIX(MapBuffer) ; .set GL_PREFIX(MapBuffer), GL_PREFIX(MapBufferARB)
+ .globl GL_PREFIX(UnmapBuffer) ; .set GL_PREFIX(UnmapBuffer), GL_PREFIX(UnmapBufferARB)
+ .globl GL_PREFIX(GenQueries) ; .set GL_PREFIX(GenQueries), GL_PREFIX(GenQueriesARB)
+ .globl GL_PREFIX(DeleteQueries) ; .set GL_PREFIX(DeleteQueries), GL_PREFIX(DeleteQueriesARB)
+ .globl GL_PREFIX(IsQuery) ; .set GL_PREFIX(IsQuery), GL_PREFIX(IsQueryARB)
+ .globl GL_PREFIX(BeginQuery) ; .set GL_PREFIX(BeginQuery), GL_PREFIX(BeginQueryARB)
+ .globl GL_PREFIX(EndQuery) ; .set GL_PREFIX(EndQuery), GL_PREFIX(EndQueryARB)
+ .globl GL_PREFIX(GetQueryiv) ; .set GL_PREFIX(GetQueryiv), GL_PREFIX(GetQueryivARB)
+ .globl GL_PREFIX(GetQueryObjectiv) ; .set GL_PREFIX(GetQueryObjectiv), GL_PREFIX(GetQueryObjectivARB)
+ .globl GL_PREFIX(GetQueryObjectuiv) ; .set GL_PREFIX(GetQueryObjectuiv), GL_PREFIX(GetQueryObjectuivARB)
+ .globl GL_PREFIX(BlendEquationSeparateATI) ; .set GL_PREFIX(BlendEquationSeparateATI), GL_PREFIX(BlendEquationSeparateEXT)
+
+#if defined(GLX_USE_TLS) && defined(__linux__)
+ .section ".note.ABI-tag", "a"
+ .p2align 2
+ .long 1f - 0f /* name length */
+ .long 3f - 2f /* data length */
+ .long 1 /* note length */
+0: .asciz "GNU" /* vendor name */
+1: .p2align 2
+2: .long 0 /* note data: the ABI tag */
+ .long 2,4,20 /* Minimum kernel version w/TLS */
+3: .p2align 2 /* pad out section */
+#endif /* GLX_USE_TLS */
diff --git a/nx-X11/extras/Mesa/src/mesa/x86-64/x86-64.c b/nx-X11/extras/Mesa/src/mesa/x86-64/x86-64.c
new file mode 100644
index 000000000..13393bc21
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86-64/x86-64.c
@@ -0,0 +1,115 @@
+/* $Id: x86-64.c,v 1.1.1.1 2005/07/31 16:46:23 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2003 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-64 optimizations shamelessy converted from x86/sse/3dnow assembly by
+ * Mikko Tiihonen
+ */
+
+#ifdef USE_X86_64_ASM
+
+#include "glheader.h"
+#include "context.h"
+#include "math/m_xform.h"
+#include "tnl/t_context.h"
+#include "x86-64.h"
+#include "../x86/common_x86_macros.h"
+
+#ifdef DEBUG
+#include "math/m_debug.h"
+#endif
+
+DECLARE_XFORM_GROUP( x86_64, 4 )
+
+#endif
+
+/*
+extern void _mesa_x86_64_transform_points4_general( XFORM_ARGS );
+extern void _mesa_x86_64_transform_points4_identity( XFORM_ARGS );
+extern void _mesa_x86_64_transform_points4_perspective( XFORM_ARGS );
+extern void _mesa_x86_64_transform_points4_3d( XFORM_ARGS );
+extern void _mesa_x86_64_transform_points4_3d_no_rot( XFORM_ARGS );
+extern void _mesa_x86_64_transform_points4_2d_no_rot( XFORM_ARGS );
+extern void _mesa_x86_64_transform_points4_2d( XFORM_ARGS );
+*/
+
+#ifdef USE_X86_64_ASM
+static void message( const char *msg )
+{
+ GLboolean debug;
+#ifdef DEBUG
+ debug = GL_TRUE;
+#else
+ if ( _mesa_getenv( "MESA_DEBUG" ) ) {
+ debug = GL_TRUE;
+ } else {
+ debug = GL_FALSE;
+ }
+#endif
+ if ( debug ) {
+ fprintf( stderr, "%s", msg );
+ }
+}
+#endif
+
+
+void _mesa_init_all_x86_64_transform_asm(void)
+{
+#ifdef USE_X86_64_ASM
+
+ if ( _mesa_getenv( "MESA_NO_ASM" ) ) {
+ return;
+ }
+
+ message("Initializing x86-64 optimizations\n");
+
+ ASSIGN_XFORM_GROUP( x86_64, 4 );
+
+ /*
+ _mesa_transform_tab[4][MATRIX_GENERAL] =
+ _mesa_x86_64_transform_points4_general;
+ _mesa_transform_tab[4][MATRIX_IDENTITY] =
+ _mesa_x86_64_transform_points4_identity;
+ _mesa_transform_tab[4][MATRIX_3D] =
+ _mesa_x86_64_transform_points4_3d;
+ _mesa_transform_tab[4][MATRIX_3D_NO_ROT] =
+ _mesa_x86_64_transform_points4_3d_no_rot;
+ _mesa_transform_tab[4][MATRIX_PERSPECTIVE] =
+ _mesa_x86_64_transform_points4_perspective;
+ _mesa_transform_tab[4][MATRIX_2D_NO_ROT] =
+ _mesa_x86_64_transform_points4_2d_no_rot;
+ _mesa_transform_tab[4][MATRIX_2D] =
+ _mesa_x86_64_transform_points4_2d;
+ */
+
+#ifdef DEBUG
+ _math_test_all_transform_functions("x86_64");
+ _math_test_all_cliptest_functions("x86_64");
+ _math_test_all_normal_transform_functions("x86_64");
+#endif
+
+#endif
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/x86-64/x86-64.h b/nx-X11/extras/Mesa/src/mesa/x86-64/x86-64.h
new file mode 100644
index 000000000..cfd7857f2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86-64/x86-64.h
@@ -0,0 +1,32 @@
+/* $Id: x86-64.h,v 1.1.1.1 2005/07/31 16:46:25 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef __X86_64_ASM_H__
+#define __X86_64_ASM_H__
+
+extern void _mesa_init_all_x86_64_transform_asm( void );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86-64/xform4.S b/nx-X11/extras/Mesa/src/mesa/x86-64/xform4.S
new file mode 100644
index 000000000..96318f2d7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86-64/xform4.S
@@ -0,0 +1,458 @@
+/* $Id: xform4.S,v 1.1.1.1 2005/07/31 16:46:23 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+#ifdef USE_X86_64_ASM
+
+#include "matypes.h"
+
+.text
+
+.align 16
+
+.globl _mesa_x86_64_transform_points4_general
+_mesa_x86_64_transform_points4_general:
+/*
+ * rdi = dest
+ * rsi = matrix
+ * rdx = source
+ */
+ movl V4F_COUNT(%rdx), %ecx /* count */
+ movzx V4F_STRIDE(%rdx), %eax /* stride */
+
+ movl %ecx, V4F_COUNT(%rdi) /* set dest count */
+ movl $4, V4F_SIZE(%rdi) /* set dest size */
+ .byte 0x66, 0x66, 0x66, 0x90 /* manual align += 3 */
+ orl $VEC_SIZE_4, V4F_FLAGS(%rdi)/* set dest flags */
+
+ testl %ecx, %ecx /* verify non-zero count */
+ prefetchnta 64(%rsi)
+ jz p4_general_done
+
+ movq V4F_START(%rdx), %rdx /* ptr to first src vertex */
+ movq V4F_START(%rdi), %rdi /* ptr to first dest vertex */
+
+ prefetch 16(%rdx)
+
+ movaps 0(%rsi), %xmm4 /* m3 | m2 | m1 | m0 */
+ movaps 16(%rsi), %xmm5 /* m7 | m6 | m5 | m4 */
+ .byte 0x66, 0x66, 0x90 /* manual align += 3 */
+ movaps 32(%rsi), %xmm6 /* m11 | m10 | m9 | m8 */
+ movaps 48(%rsi), %xmm7 /* m15 | m14 | m13 | m12 */
+
+p4_general_loop:
+
+ movaps (%rdx), %xmm8 /* ox | oy | oz | ow */
+ prefetchw 16(%rdi)
+
+ pshufd $0x00, %xmm8, %xmm0 /* ox | ox | ox | ox */
+ addq %rax, %rdx
+ pshufd $0x55, %xmm8, %xmm1 /* oy | oy | oy | oy */
+ mulps %xmm4, %xmm0 /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */
+ pshufd $0xAA, %xmm8, %xmm2 /* oz | oz | oz | ox */
+ mulps %xmm5, %xmm1 /* oy*m7 | oy*m6 | oy*m5 | oy*m4 */
+ pshufd $0xFF, %xmm8, %xmm3 /* ow | ow | ow | ow */
+ mulps %xmm6, %xmm2 /* oz*m11 | oz*m10 | oz*m9 | oz*m8 */
+ addps %xmm1, %xmm0 /* ox*m3+oy*m7 | ... */
+ mulps %xmm7, %xmm3 /* ow*m15 | ow*m14 | ow*m13 | ow*m12 */
+ addps %xmm2, %xmm0 /* ox*m3+oy*m7+oz*m11 | ... */
+ prefetch 16(%rdx)
+ addps %xmm3, %xmm0 /* ox*m3+oy*m7+oz*m11+ow*m15 | ... */
+
+ movaps %xmm0, (%rdi) /* ->D(3) | ->D(2) | ->D(1) | ->D(0) */
+ addq $16, %rdi
+
+ decl %ecx
+ jnz p4_general_loop
+
+p4_general_done:
+ .byte 0xf3
+ ret
+
+.section .rodata
+
+.align 16
+p4_constants:
+.byte 0xff, 0xff, 0xff, 0xff
+.byte 0xff, 0xff, 0xff, 0xff
+.byte 0xff, 0xff, 0xff, 0xff
+.byte 0x00, 0x00, 0x00, 0x00
+
+.byte 0x00, 0x00, 0x00, 0x00
+.byte 0x00, 0x00, 0x00, 0x00
+.byte 0x00, 0x00, 0x00, 0x00
+.float 0f+1.0
+
+.text
+.align 16
+.globl _mesa_x86_64_transform_points4_3d
+/*
+ * this is slower than _mesa_x86_64_transform_points4_general
+ * because it ensures that the last matrix row (or is it column?) is 0,0,0,1
+ */
+_mesa_x86_64_transform_points4_3d:
+
+ leaq p4_constants(%rip), %rax
+
+ prefetchnta 64(%rsi)
+
+ movaps (%rax), %xmm9
+ movaps 16(%rax), %xmm10
+
+ movl V4F_COUNT(%rdx), %ecx /* count */
+ movzx V4F_STRIDE(%rdx), %eax /* stride */
+
+ movl %ecx, V4F_COUNT(%rdi) /* set dest count */
+ movl $4, V4F_SIZE(%rdi) /* set dest size */
+ orl $VEC_SIZE_4, V4F_FLAGS(%rdi)/* set dest flags */
+
+ testl %ecx, %ecx /* verify non-zero count */
+ jz p4_3d_done
+
+ movq V4F_START(%rdx), %rdx /* ptr to first src vertex */
+ movq V4F_START(%rdi), %rdi /* ptr to first dest vertex */
+
+ prefetch 16(%rdx)
+
+ movaps 0(%rsi), %xmm4 /* m3 | m2 | m1 | m0 */
+ movaps 16(%rsi), %xmm5 /* m7 | m6 | m5 | m4 */
+ andps %xmm9, %xmm4 /* 0.0 | m2 | m1 | m0 */
+ movaps 32(%rsi), %xmm6 /* m11 | m10 | m9 | m8 */
+ andps %xmm9, %xmm5 /* 0.0 | m6 | m5 | m4 */
+ movaps 48(%rsi), %xmm7 /* m15 | m14 | m13 | m12 */
+ andps %xmm9, %xmm6 /* 0.0 | m10 | m9 | m8 */
+ andps %xmm9, %xmm7 /* 0.0 | m14 | m13 | m12 */
+ .byte 0x66, 0x66, 0x90 /* manual align += 3 */
+ orps %xmm10, %xmm7 /* 1.0 | m14 | m13 | m12 */
+
+p4_3d_loop:
+
+ movaps (%rdx), %xmm8 /* ox | oy | oz | ow */
+ prefetchw 16(%rdi)
+
+ pshufd $0x00, %xmm8, %xmm0 /* ox | ox | ox | ox */
+ addq %rax, %rdx
+ pshufd $0x55, %xmm8, %xmm1 /* oy | oy | oy | oy */
+ mulps %xmm4, %xmm0 /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */
+ pshufd $0xAA, %xmm8, %xmm2 /* oz | oz | oz | ox */
+ mulps %xmm5, %xmm1 /* oy*m7 | oy*m6 | oy*m5 | oy*m4 */
+ pshufd $0xFF, %xmm8, %xmm3 /* ow | ow | ow | ow */
+ mulps %xmm6, %xmm2 /* oz*m11 | oz*m10 | oz*m9 | oz*m8 */
+ addps %xmm1, %xmm0 /* ox*m3+oy*m7 | ... */
+ mulps %xmm7, %xmm3 /* ow*m15 | ow*m14 | ow*m13 | ow*m12 */
+ addps %xmm2, %xmm0 /* ox*m3+oy*m7+oz*m11 | ... */
+ prefetch 16(%rdx)
+ addps %xmm3, %xmm0 /* ox*m3+oy*m7+oz*m11+ow*m15 | ... */
+
+ movaps %xmm0, (%rdi) /* ->D(3) | ->D(2) | ->D(1) | ->D(0) */
+ addq $16, %rdi
+
+ dec %ecx
+ jnz p4_3d_loop
+
+p4_3d_done:
+ .byte 0xf3
+ ret
+
+
+.align 16
+.globl _mesa_x86_64_transform_points4_identity
+_mesa_x86_64_transform_points4_identity:
+
+ movl V4F_COUNT(%rdx), %ecx /* count */
+ movzx V4F_STRIDE(%rdx), %eax /* stride */
+
+ movl %ecx, V4F_COUNT(%rdi) /* set dest count */
+ movl $4, V4F_SIZE(%rdi) /* set dest size */
+ orl $VEC_SIZE_4, V4F_FLAGS(%rdi)/* set dest flags */
+
+ test %ecx, %ecx
+ jz p4_identity_done
+
+ movq V4F_START(%rdx), %rsi /* ptr to first src vertex */
+ movq V4F_START(%rdi), %rdi /* ptr to first dest vertex */
+ prefetch 64(%rsi)
+ prefetchw 64(%rdi)
+
+ add %ecx, %ecx
+
+ rep movsq
+
+p4_identity_done:
+ .byte 0xf3
+ ret
+
+
+.align 16
+.globl _mesa_x86_64_transform_points4_3d_no_rot
+_mesa_x86_64_transform_points4_3d_no_rot:
+
+ movl V4F_COUNT(%rdx), %ecx /* count */
+ movzx V4F_STRIDE(%rdx), %eax /* stride */
+
+ movl %ecx, V4F_COUNT(%rdi) /* set dest count */
+ movl $4, V4F_SIZE(%rdi) /* set dest size */
+ .byte 0x66, 0x66, 0x90 /* manual align += 3 */
+ orl $VEC_SIZE_4, V4F_FLAGS(%rdi)/* set dest flags */
+
+ test %ecx, %ecx
+ .byte 0x66, 0x66, 0x90 /* manual align += 3 */
+ jz p4_3d_no_rot_done
+
+ movq V4F_START(%rdx), %rdx /* ptr to first src vertex */
+ movq V4F_START(%rdi), %rdi /* ptr to first dest vertex */
+
+ prefetch (%rdx)
+
+ movd (%rsi), %mm0 /* | m00 */
+ .byte 0x66, 0x66, 0x90 /* manual align += 3 */
+ punpckldq 20(%rsi), %mm0 /* m11 | m00 */
+
+ movd 40(%rsi), %mm2 /* | m22 */
+ movq 48(%rsi), %mm1 /* m31 | m30 */
+
+ punpckldq 56(%rsi), %mm2 /* m11 | m00 */
+
+p4_3d_no_rot_loop:
+
+ prefetchw 32(%rdi)
+
+ movq (%rdx), %mm4 /* x1 | x0 */
+ movq 8(%rdx), %mm5 /* x3 | x2 */
+ movd 12(%rdx), %mm7 /* | x3 */
+
+ movq %mm5, %mm6 /* x3 | x2 */
+ pfmul %mm0, %mm4 /* x1*m11 | x0*m00 */
+
+ punpckhdq %mm6, %mm6 /* x3 | x3 */
+ pfmul %mm2, %mm5 /* x3*m32 | x2*m22 */
+
+ pfmul %mm1, %mm6 /* x3*m31 | x3*m30 */
+ pfacc %mm7, %mm5 /* x3 | x2*m22+x3*m32 */
+
+ pfadd %mm6, %mm4 /* x1*m11+x3*m31 | x0*m00+x3*m30 */
+
+ addq %rax, %rdx
+ movq %mm4, (%rdi) /* write r0, r1 */
+ movq %mm5, 8(%rdi) /* write r2, r3 */
+
+ addq $16, %rdi
+
+ decl %ecx
+ prefetch 32(%rdx)
+ jnz p4_3d_no_rot_loop
+
+p4_3d_no_rot_done:
+ femms
+ ret
+
+
+.align 16
+.globl _mesa_x86_64_transform_points4_perspective
+_mesa_x86_64_transform_points4_perspective:
+
+ movl V4F_COUNT(%rdx), %ecx /* count */
+ movzx V4F_STRIDE(%rdx), %eax /* stride */
+
+ movl %ecx, V4F_COUNT(%rdi) /* set dest count */
+ movl $4, V4F_SIZE(%rdi) /* set dest size */
+ orl $VEC_SIZE_4, V4F_FLAGS(%rdi)/* set dest flags */
+
+ test %ecx, %ecx
+ .byte 0x66, 0x66, 0x90 /* manual align += 3 */
+ jz p4_perspective_done
+
+ movq V4F_START(%rdx), %rdx /* ptr to first src vertex */
+ movq V4F_START(%rdi), %rdi /* ptr to first dest vertex */
+
+ movd (%rsi), %mm0 /* | m00 */
+ pxor %mm7, %mm7 /* 0 | 0 */
+ punpckldq 20(%rsi), %mm0 /* m11 | m00 */
+
+ movq 32(%rsi), %mm2 /* m21 | m20 */
+ prefetch (%rdx)
+
+ movd 40(%rsi), %mm1 /* | m22 */
+
+ .byte 0x66, 0x66, 0x90 /* manual align += 3 */
+ punpckldq 56(%rsi), %mm1 /* m32 | m22 */
+
+
+p4_perspective_loop:
+
+ prefetchw 32(%rdi) /* prefetch 2 vertices ahead */
+
+ movq (%rdx), %mm4 /* x1 | x0 */
+ movq 8(%rdx), %mm5 /* x3 | x2 */
+ movd 8(%rdx), %mm3 /* | x2 */
+
+ movq %mm5, %mm6 /* x3 | x2 */
+ pfmul %mm0, %mm4 /* x1*m11 | x0*m00 */
+
+ punpckldq %mm5, %mm5 /* x2 | x2 */
+
+ pfmul %mm2, %mm5 /* x2*m21 | x2*m20 */
+ pfsubr %mm7, %mm3 /* | -x2 */
+
+ pfmul %mm1, %mm6 /* x3*m32 | x2*m22 */
+ pfadd %mm4, %mm5 /* x1*m11+x2*m21 | x0*m00+x2*m20 */
+
+ pfacc %mm3, %mm6 /* -x2 | x2*m22+x3*m32 */
+
+ movq %mm5, (%rdi) /* write r0, r1 */
+ addq %rax, %rdx
+ movq %mm6, 8(%rdi) /* write r2, r3 */
+
+ addq $16, %rdi
+
+ decl %ecx
+ prefetch 32(%rdx) /* hopefully stride is zero */
+ jnz p4_perspective_loop
+
+p4_perspective_done:
+ femms
+ ret
+
+.align 16
+.globl _mesa_x86_64_transform_points4_2d_no_rot
+_mesa_x86_64_transform_points4_2d_no_rot:
+
+ movl V4F_COUNT(%rdx), %ecx /* count */
+ movzx V4F_STRIDE(%rdx), %eax /* stride */
+
+ movl %ecx, V4F_COUNT(%rdi) /* set dest count */
+ movl $4, V4F_SIZE(%rdi) /* set dest size */
+ orl $VEC_SIZE_4, V4F_FLAGS(%rdi)/* set dest flags */
+
+ test %ecx, %ecx
+ .byte 0x90 /* manual align += 1 */
+ jz p4_2d_no_rot_done
+
+ movq V4F_START(%rdx), %rdx /* ptr to first src vertex */
+ movq V4F_START(%rdi), %rdi /* ptr to first dest vertex */
+
+ movd (%rsi), %mm0 /* | m00 */
+ prefetch (%rdx)
+ punpckldq 20(%rsi), %mm0 /* m11 | m00 */
+
+ movq 48(%rsi), %mm1 /* m31 | m30 */
+
+p4_2d_no_rot_loop:
+
+ prefetchw 32(%rdi) /* prefetch 2 vertices ahead */
+
+ movq (%rdx), %mm4 /* x1 | x0 */
+ movq 8(%rdx), %mm5 /* x3 | x2 */
+
+ pfmul %mm0, %mm4 /* x1*m11 | x0*m00 */
+ movq %mm5, %mm6 /* x3 | x2 */
+
+ punpckhdq %mm6, %mm6 /* x3 | x3 */
+
+ addq %rax, %rdx
+ pfmul %mm1, %mm6 /* x3*m31 | x3*m30 */
+
+ prefetch 32(%rdx) /* hopefully stride is zero */
+ pfadd %mm4, %mm6 /* x1*m11+x3*m31 | x0*m00+x3*m30 */
+
+ movq %mm6, (%rdi) /* write r0, r1 */
+ movq %mm5, 8(%rdi) /* write r2, r3 */
+
+ addq $16, %rdi
+
+ decl %ecx
+ jnz p4_2d_no_rot_loop
+
+p4_2d_no_rot_done:
+ femms
+ ret
+
+
+.align 16
+.globl _mesa_x86_64_transform_points4_2d
+_mesa_x86_64_transform_points4_2d:
+
+ movl V4F_COUNT(%rdx), %ecx /* count */
+ movzx V4F_STRIDE(%rdx), %eax /* stride */
+
+ movl %ecx, V4F_COUNT(%rdi) /* set dest count */
+ movl $4, V4F_SIZE(%rdi) /* set dest size */
+ .byte 0x66, 0x66, 0x90 /* manual align += 4 */
+ orl $VEC_SIZE_4, V4F_FLAGS(%rdi)/* set dest flags */
+
+ test %ecx, %ecx
+ .byte 0x66, 0x66, 0x90 /* manual align += 4 */
+ jz p4_2d_done
+
+ movq V4F_START(%rdx), %rdx /* ptr to first src vertex */
+ movq V4F_START(%rdi), %rdi /* ptr to first dest vertex */
+
+ movd (%rsi), %mm0 /* | m00 */
+ movd 4(%rsi), %mm1 /* | m01 */
+
+ prefetch (%rdx)
+
+ punpckldq 16(%rsi), %mm0 /* m10 | m00 */
+ .byte 0x66, 0x66, 0x90 /* manual align += 4 */
+ punpckldq 20(%rsi), %mm1 /* m11 | m01 */
+
+ movq 48(%rsi), %mm2 /* m31 | m30 */
+
+p4_2d_loop:
+
+ prefetchw 32(%rdi) /* prefetch 2 vertices ahead */
+
+ movq (%rdx), %mm3 /* x1 | x0 */
+ movq 8(%rdx), %mm5 /* x3 | x2 */
+
+ movq %mm3, %mm4 /* x1 | x0 */
+ movq %mm5, %mm6 /* x3 | x2 */
+
+ pfmul %mm1, %mm4 /* x1*m11 | x0*m01 */
+ punpckhdq %mm6, %mm6 /* x3 | x3 */
+
+ pfmul %mm0, %mm3 /* x1*m10 | x0*m00 */
+
+ addq %rax, %rdx
+ pfacc %mm4, %mm3 /* x0*m01+x1*m11 | x0*m00+x1*m10 */
+
+ pfmul %mm2, %mm6 /* x3*m31 | x3*m30 */
+ prefetch 32(%rdx) /* hopefully stride is zero */
+
+ pfadd %mm6, %mm3 /* r1 | r0 */
+
+ movq %mm3, (%rdi) /* write r0, r1 */
+ movq %mm5, 8(%rdi) /* write r2, r3 */
+
+ addq $16, %rdi
+
+ decl %ecx
+ jnz p4_2d_loop
+
+p4_2d_done:
+ femms
+ ret
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/3dnow.c b/nx-X11/extras/Mesa/src/mesa/x86/3dnow.c
new file mode 100644
index 000000000..d1f827c3a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/3dnow.c
@@ -0,0 +1,92 @@
+/* $Id: 3dnow.c,v 1.1.1.1 2004/06/16 09:19:34 anholt Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.0.1
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+/*
+ * 3DNow! optimizations contributed by
+ * Holger Waechtler <holger@akaflieg.extern.tu-berlin.de>
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "math/m_xform.h"
+#include "tnl/t_context.h"
+
+#include "3dnow.h"
+#include "common_x86_macros.h"
+
+#ifdef DEBUG
+#include "math/m_debug.h"
+#endif
+
+
+#ifdef USE_3DNOW_ASM
+DECLARE_XFORM_GROUP( 3dnow, 2 )
+DECLARE_XFORM_GROUP( 3dnow, 3 )
+DECLARE_XFORM_GROUP( 3dnow, 4 )
+
+DECLARE_NORM_GROUP( 3dnow )
+
+
+extern void _ASMAPI
+_mesa_v16_3dnow_general_xform( GLfloat *first_vert,
+ const GLfloat *m,
+ const GLfloat *src,
+ GLuint src_stride,
+ GLuint count );
+
+extern void _ASMAPI
+_mesa_3dnow_project_vertices( GLfloat *first,
+ GLfloat *last,
+ const GLfloat *m,
+ GLuint stride );
+
+extern void _ASMAPI
+_mesa_3dnow_project_clipped_vertices( GLfloat *first,
+ GLfloat *last,
+ const GLfloat *m,
+ GLuint stride,
+ const GLubyte *clipmask );
+#endif
+
+
+void _mesa_init_3dnow_transform_asm( void )
+{
+#ifdef USE_3DNOW_ASM
+ ASSIGN_XFORM_GROUP( 3dnow, 2 );
+ ASSIGN_XFORM_GROUP( 3dnow, 3 );
+ ASSIGN_XFORM_GROUP( 3dnow, 4 );
+
+ /* There's a bug somewhere in the 3dnow_normal.S file that causes
+ * bad shading. Disable for now.
+ ASSIGN_NORM_GROUP( 3dnow );
+ */
+
+#ifdef DEBUG
+ _math_test_all_transform_functions( "3DNow!" );
+ _math_test_all_normal_transform_functions( "3DNow!" );
+#endif
+#endif
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/3dnow.h b/nx-X11/extras/Mesa/src/mesa/x86/3dnow.h
new file mode 100644
index 000000000..0ff0888ff
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/3dnow.h
@@ -0,0 +1,39 @@
+/* $Id: 3dnow.h,v 1.1.1.1 2004/06/16 09:19:34 anholt Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * 3DNow! optimizations contributed by
+ * Holger Waechtler <holger@akaflieg.extern.tu-berlin.de>
+ */
+
+#ifndef __3DNOW_H__
+#define __3DNOW_H__
+
+#include "math/m_xform.h"
+
+void _mesa_init_3dnow_transform_asm( void );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/3dnow_normal.S b/nx-X11/extras/Mesa/src/mesa/x86/3dnow_normal.S
new file mode 100644
index 000000000..15fc569bc
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/3dnow_normal.S
@@ -0,0 +1,848 @@
+/* $Id: 3dnow_normal.S,v 1.1.1.2 2005/07/31 16:46:39 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ */
+
+/*
+ * 3Dnow assembly code by Holger Waechtler
+ */
+
+#ifdef USE_3DNOW_ASM
+
+#include "matypes.h"
+#include "norm_args.h"
+
+ SEG_TEXT
+
+#define M(i) REGOFF(i * 4, ECX)
+#define STRIDE REGOFF(12, ESI)
+
+
+ALIGNTEXT16
+GLOBL GLNAME(_mesa_3dnow_transform_normalize_normals)
+HIDDEN(_mesa_3dnow_transform_normalize_normals)
+GLNAME(_mesa_3dnow_transform_normalize_normals):
+
+#define FRAME_OFFSET 12
+
+ PUSH_L ( EDI )
+ PUSH_L ( ESI )
+ PUSH_L ( EBP )
+
+ MOV_L ( ARG_LENGTHS, EDI )
+ MOV_L ( ARG_IN, ESI )
+ MOV_L ( ARG_DEST, EAX )
+ MOV_L ( REGOFF(V4F_COUNT, ESI), EBP ) /* dest->count = in->count */
+ MOV_L ( EBP, REGOFF(V4F_COUNT, EAX) )
+ MOV_L ( REGOFF(V4F_START, ESI), EDX ) /* in->start */
+ MOV_L ( REGOFF(V4F_START, EAX), EAX ) /* dest->start */
+ MOV_L ( ARG_MAT, ECX )
+ MOV_L ( REGOFF(MATRIX_INV, ECX), ECX ) /* mat->inv */
+
+ CMP_L ( CONST(0), EBP ) /* count > 0 ?? */
+ JE ( LLBL (G3TN_end) )
+
+ MOV_L ( REGOFF (V4F_COUNT, ESI), EBP )
+ FEMMS
+
+ PUSH_L ( EBP )
+ PUSH_L ( EAX )
+ PUSH_L ( EDX ) /* save counter & pointer for */
+ /* the normalize pass */
+#undef FRAME_OFFSET
+#define FRAME_OFFSET 24
+
+ MOVQ ( M(0), MM3 ) /* m1 | m0 */
+ MOVQ ( M(4), MM4 ) /* m5 | m4 */
+
+ MOVD ( M(2), MM5 ) /* | m2 */
+ PUNPCKLDQ ( M(6), MM5 ) /* m6 | m2 */
+
+ MOVQ ( M(8), MM6 ) /* m9 | m8 */
+ MOVQ ( M(10), MM7 ) /* | m10 */
+
+ CMP_L ( CONST(0), EDI ) /* lengths == 0 ? */
+ JNE ( LLBL (G3TN_scale_end ) )
+
+ MOVD ( ARG_SCALE, MM0 ) /* | scale */
+ PUNPCKLDQ ( MM0, MM0 ) /* scale | scale */
+
+ PFMUL ( MM0, MM3 ) /* scale * m1 | scale * m0 */
+ PFMUL ( MM0, MM4 ) /* scale * m5 | scale * m4 */
+ PFMUL ( MM0, MM5 ) /* scale * m6 | scale * m2 */
+ PFMUL ( MM0, MM6 ) /* scale * m9 | scale * m8 */
+ PFMUL ( MM0, MM7 ) /* | scale * m10 */
+
+ALIGNTEXT32
+LLBL (G3TN_scale_end):
+LLBL (G3TN_transform):
+ MOVQ ( REGIND (EDX), MM0 ) /* x1 | x0 */
+ MOVD ( REGOFF (8, EDX), MM2 ) /* | x2 */
+
+ MOVQ ( MM0, MM1 ) /* x1 | x0 */
+ PUNPCKLDQ ( MM2, MM2 ) /* x2 | x2 */
+
+ PFMUL ( MM3, MM0 ) /* x1*m1 | x0*m0 */
+ ADD_L ( CONST(16), EAX ) /* next r */
+
+ PREFETCHW ( REGIND(EAX) )
+
+ PFMUL ( MM4, MM1 ) /* x1*m5 | x0*m4 */
+ PFACC ( MM1, MM0 ) /* x0*m4+x1*m5 | x0*m0+x1*m1 */
+
+ PFMUL ( MM5, MM2 ) /* x2*m6 | x2*m2 */
+ PFADD ( MM2, MM0 ) /* x0*m4+x1*m5+x2*m6| x0*m0+...+x2**/
+
+ MOVQ ( REGIND (EDX), MM1 ) /* x1 | x0 */
+ MOVQ ( MM0, REGOFF(-16, EAX) ) /* write r0, r1 */
+
+ PFMUL ( MM6, MM1 ) /* x1*m9 | x0*m8 */
+ MOVD ( REGOFF (8, EDX), MM2 ) /* | x2 */
+
+ PFMUL ( MM7, MM2 ) /* | x2*m10 */
+ PFACC ( MM1, MM1 ) /* *not used* | x0*m8+x1*m9 */
+
+ PFADD ( MM2, MM1 ) /* *not used* | x0*m8+x1*m9+x2*m*/
+ ADD_L ( STRIDE, EDX ) /* next normal */
+
+ PREFETCH ( REGIND(EDX) )
+
+ MOVD ( MM1, REGOFF(-8, EAX) ) /* write r2 */
+ DEC_L ( EBP ) /* decrement normal counter */
+ JA ( LLBL (G3TN_transform) )
+
+
+ POP_L ( EDX ) /* end of transform --- */
+ POP_L ( EAX ) /* now normalizing ... */
+ POP_L ( EBP )
+
+ CMP_L ( CONST(0), EDI ) /* lengths == 0 ? */
+ JE ( LLBL (G3TN_norm ) ) /* calculate lengths */
+
+
+ALIGNTEXT32
+LLBL (G3TN_norm_w_lengths):
+
+ PREFETCHW ( REGOFF(12,EAX) )
+
+ MOVQ ( REGIND(EAX), MM0 ) /* x1 | x0 */
+ MOVD ( REGOFF(8, EAX), MM1 ) /* | x2 */
+
+ MOVD ( REGIND (EDI), MM3 ) /* | length (x) */
+ PFMUL ( MM3, MM1 ) /* | x2 (normalize*/
+
+ PUNPCKLDQ ( MM3, MM3 ) /* length (x) | length (x) */
+ PFMUL ( MM3, MM0 ) /* x1 (normalized) | x0 (normalize*/
+
+ ADD_L ( STRIDE, EDX ) /* next normal */
+ ADD_L ( CONST(4), EDI ) /* next length */
+
+ PREFETCH ( REGIND(EDI) )
+
+ MOVQ ( MM0, REGIND(EAX) ) /* write new x0, x1 */
+ MOVD ( MM1, REGOFF(8, EAX) ) /* write new x2 */
+
+ ADD_L ( CONST(16), EAX ) /* next r */
+ DEC_L ( EBP ) /* decrement normal counter */
+
+ JA ( LLBL (G3TN_norm_w_lengths) )
+ JMP ( LLBL (G3TN_exit_3dnow) )
+
+ALIGNTEXT32
+LLBL (G3TN_norm):
+
+ PREFETCHW ( REGIND(EAX) )
+
+ MOVQ ( REGIND (EAX), MM0 ) /* x1 | x0 */
+ MOVD ( REGOFF(8, EAX), MM1 ) /* | x2 */
+
+ MOVQ ( MM0, MM3 ) /* x1 | x0 */
+ MOVQ ( MM1, MM4 ) /* | x2 */
+
+ PFMUL ( MM0, MM3 ) /* x1*x1 | x0*x0 */
+ ADD_L ( CONST(16), EAX ) /* next r */
+
+ PFMUL ( MM1, MM4 ) /* | x2*x2 */
+ PFADD ( MM4, MM3 ) /* | x0*x0+x2*x2 */
+
+ PFACC ( MM3, MM3 ) /* **not used** | x0*x0+x1*x1+x2**/
+ PFRSQRT ( MM3, MM5 ) /* 1/sqrt (x0*x0+x1*x1+x2*x2) */
+
+ MOVQ ( MM5, MM4 )
+ PUNPCKLDQ ( MM3, MM3 )
+
+ DEC_L ( EBP ) /* decrement normal counter */
+ PFMUL ( MM5, MM5 )
+
+ PFRSQIT1 ( MM3, MM5 )
+ PFRCPIT2 ( MM4, MM5 )
+
+ PFMUL ( MM5, MM0 ) /* x1 (normalized) | x0 (normalize*/
+
+ MOVQ ( MM0, REGOFF(-16, EAX) ) /* write new x0, x1 */
+ PFMUL ( MM5, MM1 ) /* | x2 (normalize*/
+
+ MOVD ( MM1, REGOFF(-8, EAX) ) /* write new x2 */
+ JA ( LLBL (G3TN_norm) )
+
+LLBL (G3TN_exit_3dnow):
+ FEMMS
+
+LLBL (G3TN_end):
+ POP_L ( EBP )
+ POP_L ( ESI )
+ POP_L ( EDI )
+ RET
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME(_mesa_3dnow_transform_normalize_normals_no_rot)
+HIDDEN(_mesa_3dnow_transform_normalize_normals_no_rot)
+GLNAME(_mesa_3dnow_transform_normalize_normals_no_rot):
+
+#undef FRAME_OFFSET
+#define FRAME_OFFSET 12
+
+ PUSH_L ( EDI )
+ PUSH_L ( ESI )
+ PUSH_L ( EBP )
+
+ MOV_L ( ARG_LENGTHS, EDI )
+ MOV_L ( ARG_IN, ESI )
+ MOV_L ( ARG_DEST, EAX )
+ MOV_L ( REGOFF(V4F_COUNT, ESI), EBP ) /* dest->count = in->count */
+ MOV_L ( EBP, REGOFF(V4F_COUNT, EAX) )
+ MOV_L ( ARG_MAT, ECX )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX ) /* dest->start */
+ MOV_L ( REGOFF(MATRIX_INV, ECX), ECX ) /* mat->inv */
+ MOV_L ( REGOFF(V4F_START, ESI), EDX ) /* in->start */
+
+ CMP_L ( CONST(0), EBP ) /* count > 0 ?? */
+ JE ( LLBL (G3TNNR_end) )
+
+ FEMMS
+
+ MOVD ( M(0), MM0 ) /* | m0 */
+ PUNPCKLDQ ( M(5), MM0 ) /* m5 | m0 */
+
+ MOVD ( M(10), MM2 ) /* | m10 */
+ PUNPCKLDQ ( MM2, MM2 ) /* m10 | m10 */
+
+ CMP_L ( CONST(0), EDI ) /* lengths == 0 ? */
+ JNE ( LLBL (G3TNNR_scale_end ) )
+
+ MOVD ( ARG_SCALE, MM7 ) /* | scale */
+ PUNPCKLDQ ( MM7, MM7 ) /* scale | scale */
+
+ PFMUL ( MM7, MM0 ) /* scale * m5 | scale * m0 */
+ PFMUL ( MM7, MM2 ) /* scale * m10 | scale * m10 */
+
+ALIGNTEXT32
+LLBL (G3TNNR_scale_end):
+ CMP_L ( CONST(0), EDI ) /* lengths == 0 ? */
+ JE ( LLBL (G3TNNR_norm) ) /* need to calculate lengths */
+
+ MOVD ( REGIND(EDI), MM3 ) /* | length (x) */
+
+
+ALIGNTEXT32
+LLBL (G3TNNR_norm_w_lengths): /* use precalculated lengths */
+
+ PREFETCHW ( REGIND(EAX) )
+
+ MOVQ ( REGIND(EDX), MM6 ) /* x1 | x0 */
+ MOVD ( REGOFF(8, EDX), MM7 ) /* | x2 */
+
+ PFMUL ( MM0, MM6 ) /* x1*m5 | x0*m0 */
+ ADD_L ( STRIDE, EDX ) /* next normal */
+
+ PREFETCH ( REGIND(EDX) )
+
+ PFMUL ( MM2, MM7 ) /* | x2*m10 */
+ ADD_L ( CONST(16), EAX ) /* next r */
+
+ PFMUL ( MM3, MM7 ) /* | x2 (normalized) */
+ PUNPCKLDQ ( MM3, MM3 ) /* length (x) | length (x) */
+
+ ADD_L ( CONST(4), EDI ) /* next length */
+ PFMUL ( MM3, MM6 ) /* x1 (normalized) | x0 (normalized) */
+
+ DEC_L ( EBP ) /* decrement normal counter */
+ MOVQ ( MM6, REGOFF(-16, EAX) ) /* write r0, r1 */
+
+ MOVD ( MM7, REGOFF(-8, EAX) ) /* write r2 */
+ MOVD ( REGIND(EDI), MM3 ) /* | length (x) */
+
+ JA ( LLBL (G3TNNR_norm_w_lengths) )
+ JMP ( LLBL (G3TNNR_exit_3dnow) )
+
+ALIGNTEXT32
+LLBL (G3TNNR_norm): /* need to calculate lengths */
+
+ PREFETCHW ( REGIND(EAX) )
+
+ MOVQ ( REGIND(EDX), MM6 ) /* x1 | x0 */
+ MOVD ( REGOFF(8, EDX), MM7 ) /* | x2 */
+
+ PFMUL ( MM0, MM6 ) /* x1*m5 | x0*m0 */
+ ADD_L ( CONST(16), EAX ) /* next r */
+
+ PFMUL ( MM2, MM7 ) /* | x2*m10 */
+ MOVQ ( MM6, MM3 ) /* x1 (transformed)| x0 (transformed) */
+
+ MOVQ ( MM7, MM4 ) /* | x2 (transformed) */
+ PFMUL ( MM6, MM3 ) /* x1*x1 | x0*x0 */
+
+
+ PFMUL ( MM7, MM4 ) /* | x2*x2 */
+ PFACC ( MM3, MM3 ) /* **not used** | x0*x0+x1*x1 */
+
+ PFADD ( MM4, MM3 ) /* | x0*x0+x1*x1+x2*x2*/
+ ADD_L ( STRIDE, EDX ) /* next normal */
+
+ PREFETCH ( REGIND(EDX) )
+
+ PFRSQRT ( MM3, MM5 ) /* 1/sqrt (x0*x0+x1*x1+x2*x2) */
+ MOVQ ( MM5, MM4 )
+
+ PUNPCKLDQ ( MM3, MM3 )
+ PFMUL ( MM5, MM5 )
+
+ PFRSQIT1 ( MM3, MM5 )
+ DEC_L ( EBP ) /* decrement normal counter */
+
+ PFRCPIT2 ( MM4, MM5 )
+ PFMUL ( MM5, MM6 ) /* x1 (normalized) | x0 (normalized) */
+
+ MOVQ ( MM6, REGOFF(-16, EAX) ) /* write r0, r1 */
+ PFMUL ( MM5, MM7 ) /* | x2 (normalized) */
+
+ MOVD ( MM7, REGOFF(-8, EAX) ) /* write r2 */
+ JA ( LLBL (G3TNNR_norm) )
+
+
+LLBL (G3TNNR_exit_3dnow):
+ FEMMS
+
+LLBL (G3TNNR_end):
+ POP_L ( EBP )
+ POP_L ( ESI )
+ POP_L ( EDI )
+ RET
+
+
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME(_mesa_3dnow_transform_rescale_normals_no_rot)
+HIDDEN(_mesa_3dnow_transform_rescale_normals_no_rot)
+GLNAME(_mesa_3dnow_transform_rescale_normals_no_rot):
+
+#undef FRAME_OFFSET
+#define FRAME_OFFSET 12
+
+ PUSH_L ( EDI )
+ PUSH_L ( ESI )
+ PUSH_L ( EBP )
+
+ MOV_L ( ARG_IN, EAX )
+ MOV_L ( ARG_DEST, EDX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EBP ) /* dest->count = in->count */
+ MOV_L ( EBP, REGOFF(V4F_COUNT, EDX) )
+ MOV_L ( ARG_IN, ESI )
+ MOV_L ( ARG_MAT, ECX )
+ MOV_L ( REGOFF(MATRIX_INV, ECX), ECX ) /* mat->inv */
+ MOV_L ( REGOFF(V4F_START, EDX), EAX ) /* dest->start */
+ MOV_L ( REGOFF(V4F_START, ESI), EDX ) /* in->start */
+
+ CMP_L ( CONST(0), EBP )
+ JE ( LLBL (G3TRNR_end) )
+
+ FEMMS
+
+ MOVD ( ARG_SCALE, MM6 ) /* | scale */
+ PUNPCKLDQ ( MM6, MM6 ) /* scale | scale */
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m0 */
+ PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m5 | m0 */
+
+ PFMUL ( MM6, MM0 ) /* scale*m5 | scale*m0 */
+ MOVD ( REGOFF(40, ECX), MM2 ) /* | m10 */
+
+ PFMUL ( MM6, MM2 ) /* | scale*m10 */
+
+ALIGNTEXT32
+LLBL (G3TRNR_rescale):
+
+ PREFETCHW ( REGIND(EAX) )
+
+ MOVQ ( REGIND(EDX), MM4 ) /* x1 | x0 */
+ MOVD ( REGOFF(8, EDX), MM5 ) /* | x2 */
+
+ PFMUL ( MM0, MM4 ) /* x1*m5 | x0*m0 */
+ ADD_L ( STRIDE, EDX ) /* next normal */
+
+ PREFETCH ( REGIND(EDX) )
+
+ PFMUL ( MM2, MM5 ) /* | x2*m10 */
+ ADD_L ( CONST(16), EAX ) /* next r */
+
+ DEC_L ( EBP ) /* decrement normal counter */
+ MOVQ ( MM4, REGOFF(-16, EAX) ) /* write r0, r1 */
+
+ MOVD ( MM5, REGOFF(-8, EAX) ) /* write r2 */
+ JA ( LLBL (G3TRNR_rescale) ) /* cnt > 0 ? -> process next normal */
+
+ FEMMS
+
+LLBL (G3TRNR_end):
+ POP_L ( EBP )
+ POP_L ( ESI )
+ POP_L ( EDI )
+ RET
+
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME(_mesa_3dnow_transform_rescale_normals)
+HIDDEN(_mesa_3dnow_transform_rescale_normals)
+GLNAME(_mesa_3dnow_transform_rescale_normals):
+
+#undef FRAME_OFFSET
+#define FRAME_OFFSET 8
+
+ PUSH_L ( EDI )
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_IN, ESI )
+ MOV_L ( ARG_DEST, EAX )
+ MOV_L ( ARG_MAT, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, ESI), EDI ) /* dest->count = in->count */
+ MOV_L ( EDI, REGOFF(V4F_COUNT, EAX) )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX ) /* dest->start */
+ MOV_L ( REGOFF(V4F_START, ESI), EDX ) /* in->start */
+ MOV_L ( REGOFF(MATRIX_INV, ECX), ECX ) /* mat->inv */
+
+ CMP_L ( CONST(0), EDI )
+ JE ( LLBL (G3TR_end) )
+
+ FEMMS
+
+ MOVQ ( REGIND(ECX), MM3 ) /* m1 | m0 */
+
+ MOVQ ( REGOFF(16,ECX), MM4 ) /* m5 | m4 */
+ MOVD ( ARG_SCALE, MM0 ) /* scale */
+
+ MOVD ( REGOFF(8,ECX), MM5 ) /* | m2 */
+ PUNPCKLDQ ( MM0, MM0 ) /* scale | scale */
+
+ PUNPCKLDQ ( REGOFF(24, ECX), MM5 )
+ PFMUL ( MM0, MM3 ) /* scale*m1 | scale*m0 */
+
+ MOVQ ( REGOFF(32, ECX), MM6 ) /* m9 | m8*/
+ PFMUL ( MM0, MM4 ) /* scale*m5 | scale*m4 */
+
+ MOVD ( REGOFF(40, ECX), MM7 ) /* | m10 */
+ PFMUL ( MM0, MM5 ) /* scale*m6 | scale*m2 */
+
+ PFMUL ( MM0, MM6 ) /* scale*m9 | scale*m8 */
+
+ PFMUL ( MM0, MM7 ) /* | scale*m10 */
+
+ALIGNTEXT32
+LLBL (G3TR_rescale):
+
+ PREFETCHW ( REGIND(EAX) )
+
+ MOVQ ( REGIND(EDX), MM0 ) /* x1 | x0 */
+ MOVD ( REGOFF(8, EDX), MM2 ) /* | x2 */
+
+ MOVQ ( MM0, MM1 ) /* x1 | x0 */
+ PUNPCKLDQ ( MM2, MM2 ) /* x2 | x2 */
+
+ PFMUL ( MM3, MM0 ) /* x1*m1 | x0*m0 */
+ ADD_L ( CONST(16), EAX ) /* next r */
+
+ PFMUL ( MM4, MM1 ) /* x1*m5 | x0*m4 */
+ PFACC ( MM1, MM0 ) /* x0*m4+x1*m5 | x0*m0+x1*m1 */
+
+ MOVQ ( REGIND(EDX), MM1 ) /* x1 | x0 */
+
+ PFMUL ( MM5, MM2 ) /* x2*m6 | x2*m2 */
+ PFADD ( MM2, MM0 ) /* x0*m4...+x2*m6| x0*m0+x1*m1+x2*m2 */
+
+ MOVD ( REGOFF(8, EDX), MM2 ) /* | x2 */
+ ADD_L ( STRIDE, EDX ) /* next normal */
+
+ PREFETCH ( REGIND(EDX) )
+
+ MOVQ ( MM0, REGOFF(-16, EAX) ) /* write r0, r1 */
+ PFMUL ( MM6, MM1 ) /* x1*m9 | x0*m8 */
+
+ PFMUL ( MM7, MM2 ) /* | x2*m10 */
+ PFACC ( MM1, MM1 ) /* *not used* | x0*m8+x1*m9 */
+
+ PFADD ( MM2, MM1 ) /* *not used* | x0*m8+x1*m9+x2*m10 */
+ MOVD ( MM1, REGOFF(-8, EAX) ) /* write r2 */
+
+ DEC_L ( EDI ) /* decrement normal counter */
+ JA ( LLBL (G3TR_rescale) )
+
+ FEMMS
+
+LLBL (G3TR_end):
+ POP_L ( ESI )
+ POP_L ( EDI )
+ RET
+
+
+
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME(_mesa_3dnow_transform_normals_no_rot)
+HIDDEN(_mesa_3dnow_transform_normals_no_rot)
+GLNAME(_mesa_3dnow_transform_normals_no_rot):
+
+#undef FRAME_OFFSET
+#define FRAME_OFFSET 8
+
+ PUSH_L ( EDI )
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_IN, ESI )
+ MOV_L ( ARG_DEST, EAX )
+ MOV_L ( ARG_MAT, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, ESI), EDI ) /* dest->count = in->count */
+ MOV_L ( EDI, REGOFF(V4F_COUNT, EAX) )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX ) /* dest->start */
+ MOV_L ( REGOFF(V4F_START, ESI), EDX ) /* in->start */
+ MOV_L ( REGOFF(MATRIX_INV, ECX), ECX ) /* mat->inv */
+
+ CMP_L ( CONST(0), EDI )
+ JE ( LLBL (G3TNR_end) )
+
+ FEMMS
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m0 */
+ PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m5 | m0 */
+
+ MOVD ( REGOFF(40, ECX), MM2 ) /* | m10 */
+ PUNPCKLDQ ( MM2, MM2 ) /* m10 | m10 */
+
+ALIGNTEXT32
+LLBL (G3TNR_transform):
+
+ PREFETCHW ( REGIND(EAX) )
+
+ MOVQ ( REGIND(EDX), MM4 ) /* x1 | x0 */
+ MOVD ( REGOFF(8, EDX), MM5 ) /* | x2 */
+
+ PFMUL ( MM0, MM4 ) /* x1*m5 | x0*m0 */
+ ADD_L ( STRIDE, EDX) /* next normal */
+
+ PREFETCH ( REGIND(EDX) )
+
+ PFMUL ( MM2, MM5 ) /* | x2*m10 */
+ ADD_L ( CONST(16), EAX ) /* next r */
+
+ DEC_L ( EDI ) /* decrement normal counter */
+ MOVQ ( MM4, REGOFF(-16, EAX) ) /* write r0, r1 */
+
+ MOVD ( MM5, REGOFF(-8, EAX) ) /* write r2 */
+ JA ( LLBL (G3TNR_transform) )
+
+ FEMMS
+
+LLBL (G3TNR_end):
+ POP_L ( ESI )
+ POP_L ( EDI )
+ RET
+
+
+
+
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME(_mesa_3dnow_transform_normals)
+HIDDEN(_mesa_3dnow_transform_normals)
+GLNAME(_mesa_3dnow_transform_normals):
+
+#undef FRAME_OFFSET
+#define FRAME_OFFSET 8
+
+ PUSH_L ( EDI )
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_IN, ESI )
+ MOV_L ( ARG_DEST, EAX )
+ MOV_L ( ARG_MAT, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, ESI), EDI ) /* dest->count = in->count */
+ MOV_L ( EDI, REGOFF(V4F_COUNT, EAX) )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX ) /* dest->start */
+ MOV_L ( REGOFF(V4F_START, ESI), EDX ) /* in->start */
+ MOV_L ( REGOFF(MATRIX_INV, ECX), ECX ) /* mat->inv */
+
+ CMP_L ( CONST(0), EDI ) /* count > 0 ?? */
+ JE ( LLBL (G3T_end) )
+
+ FEMMS
+
+ MOVQ ( REGIND(ECX), MM3 ) /* m1 | m0 */
+ MOVQ ( REGOFF(16, ECX), MM4 ) /* m5 | m4 */
+
+ MOVD ( REGOFF(8, ECX), MM5 ) /* | m2 */
+ PUNPCKLDQ ( REGOFF(24, ECX), MM5 ) /* m6 | m2 */
+
+ MOVQ ( REGOFF(32, ECX), MM6 ) /* m9 | m8 */
+ MOVD ( REGOFF(40, ECX), MM7 ) /* | m10 */
+
+ALIGNTEXT32
+LLBL (G3T_transform):
+
+ PREFETCHW ( REGIND(EAX) )
+
+ MOVQ ( REGIND(EDX), MM0 ) /* x1 | x0 */
+ MOVD ( REGOFF(8, EDX), MM2 ) /* | x2 */
+
+ MOVQ ( MM0, MM1 ) /* x1 | x0 */
+ PUNPCKLDQ ( MM2, MM2 ) /* x2 | x2 */
+
+ PFMUL ( MM3, MM0 ) /* x1*m1 | x0*m0 */
+ ADD_L ( CONST(16), EAX ) /* next r */
+
+ PFMUL ( MM4, MM1 ) /* x1*m5 | x0*m4 */
+ PFACC ( MM1, MM0 ) /* x0*m4+x1*m5 | x0*m0+x1*m1 */
+
+ PFMUL ( MM5, MM2 ) /* x2*m6 | x2*m2 */
+ PFADD ( MM2, MM0 ) /* x0*m4...+x2*m6| x0*m0+x1*m1+x2*m2 */
+
+ MOVQ ( REGIND(EDX), MM1 ) /* x1 | x0 */
+ MOVQ ( MM0, REGOFF(-16, EAX) ) /* write r0, r1 */
+
+ PFMUL ( MM6, MM1 ) /* x1*m9 | x0*m8 */
+ MOVD ( REGOFF(8, EDX), MM2 ) /* | x2 */
+
+ PFMUL ( MM7, MM2 ) /* | x2*m10 */
+ ADD_L ( STRIDE, EDX ) /* next normal */
+
+ PREFETCH ( REGIND(EDX) )
+
+ PFACC ( MM1, MM1 ) /* *not used* | x0*m8+x1*m9 */
+ PFADD ( MM2, MM1 ) /* *not used* | x0*m8+x1*m9+x2*m10 */
+
+ MOVD ( MM1, REGOFF(-8, EAX) ) /* write r2 */
+ DEC_L ( EDI ) /* decrement normal counter */
+
+ JA ( LLBL (G3T_transform) )
+
+ FEMMS
+
+LLBL (G3T_end):
+ POP_L ( ESI )
+ POP_L ( EDI )
+ RET
+
+
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME(_mesa_3dnow_normalize_normals)
+HIDDEN(_mesa_3dnow_normalize_normals)
+GLNAME(_mesa_3dnow_normalize_normals):
+
+#undef FRAME_OFFSET
+#define FRAME_OFFSET 12
+
+ PUSH_L ( EDI )
+ PUSH_L ( ESI )
+ PUSH_L ( EBP )
+
+ MOV_L ( ARG_IN, ESI )
+ MOV_L ( ARG_DEST, EAX )
+ MOV_L ( REGOFF(V4F_COUNT, ESI), EBP ) /* dest->count = in->count */
+ MOV_L ( EBP, REGOFF(V4F_COUNT, EAX) )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX ) /* dest->start */
+ MOV_L ( REGOFF(V4F_START, ESI), ECX ) /* in->start */
+ MOV_L ( ARG_LENGTHS, EDX )
+
+ CMP_L ( CONST(0), EBP ) /* count > 0 ?? */
+ JE ( LLBL (G3N_end) )
+
+ FEMMS
+
+ CMP_L ( CONST(0), EDX ) /* lengths == 0 ? */
+ JE ( LLBL (G3N_norm2) ) /* calculate lengths */
+
+ALIGNTEXT32
+LLBL (G3N_norm1): /* use precalculated lengths */
+
+ PREFETCH ( REGIND(EAX) )
+
+ MOVQ ( REGIND(ECX), MM0 ) /* x1 | x0 */
+ MOVD ( REGOFF(8, ECX), MM1 ) /* | x2 */
+
+ MOVD ( REGIND(EDX), MM3 ) /* | length (x) */
+ PFMUL ( MM3, MM1 ) /* | x2 (normalized) */
+
+ PUNPCKLDQ ( MM3, MM3 ) /* length (x) | length (x) */
+ ADD_L ( STRIDE, ECX ) /* next normal */
+
+ PREFETCH ( REGIND(ECX) )
+
+ PFMUL ( MM3, MM0 ) /* x1 (normalized) | x0 (normalized) */
+ MOVQ ( MM0, REGIND(EAX) ) /* write new x0, x1 */
+
+ MOVD ( MM1, REGOFF(8, EAX) ) /* write new x2 */
+ ADD_L ( CONST(16), EAX ) /* next r */
+
+ ADD_L ( CONST(4), EDX ) /* next length */
+ DEC_L ( EBP ) /* decrement normal counter */
+
+ JA ( LLBL (G3N_norm1) )
+
+ JMP ( LLBL (G3N_end1) )
+
+ALIGNTEXT32
+LLBL (G3N_norm2): /* need to calculate lengths */
+
+ PREFETCHW ( REGIND(EAX) )
+
+ PREFETCH ( REGIND(ECX) )
+
+ MOVQ ( REGIND(ECX), MM0 ) /* x1 | x0 */
+ MOVD ( REGOFF(8, ECX), MM1 ) /* | x2 */
+
+ MOVQ ( MM0, MM3 ) /* x1 | x0 */
+ ADD_L ( STRIDE, ECX ) /* next normal */
+
+ PFMUL ( MM0, MM3 ) /* x1*x1 | x0*x0 */
+ MOVQ ( MM1, MM4 ) /* | x2 */
+
+ ADD_L ( CONST(16), EAX ) /* next r */
+ PFMUL ( MM1, MM4 ) /* | x2*x2 */
+
+ PFADD ( MM4, MM3 ) /* | x0*x0+x2*x2 */
+ PFACC ( MM3, MM3 ) /* x0*x0+...+x2*x2 | x0*x0+x1*x1+x2*x2*/
+
+ PFRSQRT ( MM3, MM5 ) /* 1/sqrt (x0*x0+x1*x1+x2*x2) */
+ MOVQ ( MM5, MM4 )
+
+ PUNPCKLDQ ( MM3, MM3 )
+ PFMUL ( MM5, MM5 )
+
+ PFRSQIT1 ( MM3, MM5 )
+ DEC_L ( EBP ) /* decrement normal counter */
+
+ PFRCPIT2 ( MM4, MM5 )
+
+ PFMUL ( MM5, MM0 ) /* x1 (normalized) | x0 (normalized) */
+ MOVQ ( MM0, REGOFF(-16, EAX) ) /* write new x0, x1 */
+
+ PFMUL ( MM5, MM1 ) /* | x2 (normalized) */
+ MOVD ( MM1, REGOFF(-8, EAX) ) /* write new x2 */
+
+ JA ( LLBL (G3N_norm2) )
+
+LLBL (G3N_end1):
+ FEMMS
+
+LLBL (G3N_end):
+ POP_L ( EBP )
+ POP_L ( ESI )
+ POP_L ( EDI )
+ RET
+
+
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME(_mesa_3dnow_rescale_normals)
+HIDDEN(_mesa_3dnow_rescale_normals)
+GLNAME(_mesa_3dnow_rescale_normals):
+
+#undef FRAME_OFFSET
+#define FRAME_OFFSET 8
+ PUSH_L ( EDI )
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_IN, ESI )
+ MOV_L ( ARG_DEST, EAX )
+ MOV_L ( REGOFF(V4F_COUNT, ESI), EDX ) /* dest->count = in->count */
+ MOV_L ( EDX, REGOFF(V4F_COUNT, EAX) )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX ) /* dest->start */
+ MOV_L ( REGOFF(V4F_START, ESI), ECX ) /* in->start */
+
+ CMP_L ( CONST(0), EDX )
+ JE ( LLBL (G3R_end) )
+
+ FEMMS
+
+ MOVD ( ARG_SCALE, MM0 ) /* scale */
+ PUNPCKLDQ ( MM0, MM0 )
+
+ALIGNTEXT32
+LLBL (G3R_rescale):
+
+ PREFETCHW ( REGIND(EAX) )
+
+ MOVQ ( REGIND(ECX), MM1 ) /* x1 | x0 */
+ MOVD ( REGOFF(8, ECX), MM2 ) /* | x2 */
+
+ PFMUL ( MM0, MM1 ) /* x1*scale | x0*scale */
+ ADD_L ( STRIDE, ECX ) /* next normal */
+
+ PREFETCH ( REGIND(ECX) )
+
+ PFMUL ( MM0, MM2 ) /* | x2*scale */
+ ADD_L ( CONST(16), EAX ) /* next r */
+
+ MOVQ ( MM1, REGOFF(-16, EAX) ) /* write r0, r1 */
+ MOVD ( MM2, REGOFF(-8, EAX) ) /* write r2 */
+
+ DEC_L ( EDX ) /* decrement normal counter */
+ JA ( LLBL (G3R_rescale) )
+
+ FEMMS
+
+LLBL (G3R_end):
+ POP_L ( ESI )
+ POP_L ( EDI )
+ RET
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/3dnow_xform1.S b/nx-X11/extras/Mesa/src/mesa/x86/3dnow_xform1.S
new file mode 100644
index 000000000..f1e4c7b67
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/3dnow_xform1.S
@@ -0,0 +1,433 @@
+/* $Id: 3dnow_xform1.S,v 1.1.1.2 2005/07/31 16:46:39 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+#ifdef USE_3DNOW_ASM
+#include "matypes.h"
+#include "xform_args.h"
+
+ SEG_TEXT
+
+#define FRAME_OFFSET 4
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points1_general )
+HIDDEN(_mesa_3dnow_transform_points1_general)
+GLNAME( _mesa_3dnow_transform_points1_general ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(4, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TPGR_3 ) )
+
+ MOVQ ( REGIND(ECX), MM0 ) /* m01 | m00 */
+ MOVQ ( REGOFF(8, ECX), MM1 ) /* m03 | m02 */
+
+ MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */
+ MOVQ ( REGOFF(56, ECX), MM3 ) /* m33 | m32 */
+
+ALIGNTEXT16
+LLBL( G3TPGR_2 ):
+
+ MOVD ( REGIND(EAX), MM4 ) /* | x0 */
+ PUNPCKLDQ ( MM4, MM4 ) /* x0 | x0 */
+
+ MOVQ ( MM4, MM5 ) /* x0 | x0 */
+ PFMUL ( MM0, MM4 ) /* x0*m01 | x0*m00 */
+
+ PFMUL ( MM1, MM5 ) /* x0*m03 | x0*m02 */
+ PFADD ( MM2, MM4 ) /* x0*m01+m31 | x0*m00+m30 */
+
+ PFADD ( MM3, MM5 ) /* x0*m03+m33 | x0*m02+m32 */
+ MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */
+
+ MOVQ ( MM5, REGOFF(8, EDX) ) /* write r3, r2 */
+ ADD_L ( EDI, EAX ) /* next vertex */
+
+ ADD_L ( CONST(16), EDX ) /* next r */
+ DEC_L ( ESI ) /* decrement vertex counter */
+
+ JNZ ( LLBL( G3TPGR_2 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TPGR_3 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points1_identity )
+HIDDEN(_mesa_3dnow_transform_points1_identity)
+GLNAME( _mesa_3dnow_transform_points1_identity ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(1), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_1), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(4, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TPIR_4) )
+
+ALIGNTEXT16
+LLBL( G3TPIR_3 ):
+
+ MOVD ( REGIND(EAX), MM0 ) /* | x0 */
+ ADD_L ( EDI, EAX ) /* next vertex */
+
+ MOVD ( MM0, REGIND(EDX) ) /* | r0 */
+ ADD_L ( CONST(16), EDX ) /* next r */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ JNZ ( LLBL( G3TPIR_3 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TPIR_4 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points1_3d_no_rot )
+HIDDEN(_mesa_3dnow_transform_points1_3d_no_rot)
+GLNAME( _mesa_3dnow_transform_points1_3d_no_rot ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(4, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TP3NRR_3 ) )
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m00 */
+ MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */
+
+ MOVD ( REGOFF(56, ECX), MM3 ) /* | m32 */
+
+ALIGNTEXT16
+LLBL( G3TP3NRR_2 ):
+
+ MOVD ( REGIND(EAX), MM4 ) /* | x0 */
+ PFMUL ( MM0, MM4 ) /* | x0*m00 */
+
+ PFADD ( MM2, MM4 ) /* m31 | x0*m00+m30 */
+ MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */
+
+ MOVD ( MM3, REGOFF(8, EDX) ) /* write r2 */
+ ADD_L ( EDI, EAX ) /* next vertex */
+
+ ADD_L ( CONST(16), EDX ) /* next r */
+ DEC_L ( ESI ) /* decrement vertex counter */
+
+ JNZ ( LLBL( G3TP3NRR_2 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TP3NRR_3 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points1_perspective )
+HIDDEN(_mesa_3dnow_transform_points1_perspective)
+GLNAME( _mesa_3dnow_transform_points1_perspective ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(4, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TPPR_3 ) )
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m00 */
+ MOVD ( REGOFF(56, ECX), MM3 ) /* | m32 */
+
+ALIGNTEXT16
+LLBL( G3TPPR_2 ):
+
+ MOVD ( REGIND(EAX), MM4 ) /* 0 | x0 */
+ PFMUL ( MM0, MM4 ) /* 0 | x0*m00 */
+
+ MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */
+ MOVQ ( MM3, REGOFF(8, EDX) ) /* write r2 (=m32), r3 (=0) */
+
+ ADD_L ( EDI, EAX ) /* next vertex */
+ ADD_L ( CONST(16), EDX ) /* next r */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ JNZ ( LLBL( G3TPPR_2 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TPPR_3 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points1_2d )
+HIDDEN(_mesa_3dnow_transform_points1_2d)
+GLNAME( _mesa_3dnow_transform_points1_2d ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(2), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(4, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TP2R_3 ) )
+
+ MOVQ ( REGIND(ECX), MM0 ) /* m01 | m00 */
+ MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */
+
+ALIGNTEXT16
+LLBL( G3TP2R_2 ):
+
+ MOVD ( REGIND(EAX), MM4 ) /* | x0 */
+ PUNPCKLDQ ( MM4, MM4 ) /* x0 | x0 */
+
+ PFMUL ( MM0, MM4 ) /* x0*m01 | x0*m00 */
+ PFADD ( MM2, MM4 ) /* x0*m01+m31 | x0*m00+m30 */
+
+ MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */
+ ADD_L ( EDI, EAX ) /* next vertex */
+
+ ADD_L ( CONST(16), EDX ) /* next r */
+ DEC_L ( ESI ) /* decrement vertex counter */
+
+ JNZ ( LLBL( G3TP2R_2 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TP2R_3 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points1_2d_no_rot )
+HIDDEN(_mesa_3dnow_transform_points1_2d_no_rot)
+GLNAME( _mesa_3dnow_transform_points1_2d_no_rot ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(2), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(4, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TP2NRR_3 ) )
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m00 */
+ MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */
+
+ALIGNTEXT16
+LLBL( G3TP2NRR_2 ):
+
+ MOVD ( REGIND(EAX), MM4 ) /* | x0 */
+ ADD_L ( EDI, EAX ) /* next vertex */
+
+ PFMUL ( MM0, MM4 ) /* | x0*m00 */
+ PFADD ( MM2, MM4 ) /* m31 | x0*m00+m30 */
+
+ MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */
+ ADD_L ( CONST(16), EDX ) /* next r */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ JNZ ( LLBL( G3TP2NRR_2 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TP2NRR_3 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points1_3d )
+HIDDEN(_mesa_3dnow_transform_points1_3d)
+GLNAME( _mesa_3dnow_transform_points1_3d ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(4, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TP3R_3 ) )
+
+ MOVQ ( REGIND(ECX), MM0 ) /* m01 | m00 */
+ MOVD ( REGOFF(8, ECX), MM1 ) /* | m02 */
+
+ MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */
+ MOVD ( REGOFF(56, ECX), MM3 ) /* | m32 */
+
+ALIGNTEXT16
+LLBL( G3TP3R_2 ):
+
+ MOVD ( REGIND(EAX), MM4 ) /* | x0 */
+ PUNPCKLDQ ( MM4, MM4 ) /* x0 | x0 */
+
+ MOVQ ( MM4, MM5 ) /* | x0 */
+ PFMUL ( MM0, MM4 ) /* x0*m01 | x0*m00 */
+
+ PFMUL ( MM1, MM5 ) /* | x0*m02 */
+ PFADD ( MM2, MM4 ) /* x0*m01+m31 | x0*m00+m30 */
+
+ PFADD ( MM3, MM5 ) /* | x0*m02+m32 */
+ MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */
+
+ MOVD ( MM5, REGOFF(8, EDX) ) /* write r2 */
+ ADD_L ( EDI, EAX ) /* next vertex */
+
+ ADD_L ( CONST(16), EDX ) /* next r */
+ DEC_L ( ESI ) /* decrement vertex counter */
+
+ JNZ ( LLBL( G3TP3R_2 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TP3R_3 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/3dnow_xform2.S b/nx-X11/extras/Mesa/src/mesa/x86/3dnow_xform2.S
new file mode 100644
index 000000000..49a602b83
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/3dnow_xform2.S
@@ -0,0 +1,473 @@
+/* $Id: 3dnow_xform2.S,v 1.1.1.2 2005/07/31 16:46:38 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+#ifdef USE_3DNOW_ASM
+#include "matypes.h"
+#include "xform_args.h"
+
+ SEG_TEXT
+
+#define FRAME_OFFSET 4
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points2_general )
+HIDDEN(_mesa_3dnow_transform_points2_general)
+GLNAME( _mesa_3dnow_transform_points2_general ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TPGR_3 ) )
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m00 */
+ PUNPCKLDQ ( REGOFF(16, ECX), MM0 ) /* m10 | m00 */
+
+ MOVD ( REGOFF(4, ECX), MM1 ) /* | m01 */
+ PUNPCKLDQ ( REGOFF(20, ECX), MM1 ) /* m11 | m01 */
+
+ MOVD ( REGOFF(8, ECX), MM2 ) /* | m02 */
+ PUNPCKLDQ ( REGOFF(24, ECX), MM2 ) /* m12 | m02 */
+
+ MOVD ( REGOFF(12, ECX), MM3 ) /* | m03 */
+ PUNPCKLDQ ( REGOFF(28, ECX), MM3 ) /* m13 | m03 */
+
+ MOVQ ( REGOFF(48, ECX), MM4 ) /* m31 | m30 */
+ MOVQ ( REGOFF(56, ECX), MM5 ) /* m33 | m32 */
+
+ALIGNTEXT16
+LLBL( G3TPGR_2 ):
+
+ MOVQ ( REGIND(EAX), MM6 ) /* x1 | x0 */
+ MOVQ ( MM6, MM7 ) /* x1 | x0 */
+
+ PFMUL ( MM0, MM6 ) /* x1*m10 | x0*m00 */
+ PFMUL ( MM1, MM7 ) /* x1*m11 | x0*m01 */
+
+ PFACC ( MM7, MM6 ) /* x0*m01+x1*m11 | x0*x00+x1*m10 */
+ PFADD ( MM4, MM6 ) /* x0*...*m11+m31 | x0*...*m10+m30 */
+
+ MOVQ ( MM6, REGIND(EDX) ) /* write r1, r0 */
+ MOVQ ( REGIND(EAX), MM6 ) /* x1 | x0 */
+
+ MOVQ ( MM6, MM7 ) /* x1 | x0 */
+ PFMUL ( MM2, MM6 ) /* x1*m12 | x0*m02 */
+
+ PFMUL ( MM3, MM7 ) /* x1*m13 | x0*m03 */
+ ADD_L ( EDI, EAX ) /* next vertex */
+
+ PFACC ( MM7, MM6 ) /* x0*m03+x1*m13 | x0*x02+x1*m12 */
+ PFADD ( MM5, MM6 ) /* x0*...*m13+m33 | x0*...*m12+m32 */
+
+ MOVQ ( MM6, REGOFF(8, EDX) ) /* write r3, r2 */
+ ADD_L ( CONST(16), EDX ) /* next r */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ JNZ ( LLBL( G3TPGR_2 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TPGR_3 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points2_perspective )
+HIDDEN(_mesa_3dnow_transform_points2_perspective)
+GLNAME( _mesa_3dnow_transform_points2_perspective ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TPPR_3 ) )
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m00 */
+ PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */
+
+ MOVD ( REGOFF(56, ECX), MM3 ) /* | m32 */
+
+ALIGNTEXT16
+LLBL( G3TPPR_2 ):
+
+ MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */
+ PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */
+
+ MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */
+ MOVQ ( MM3, REGOFF(8, EDX) ) /* write r2 (=m32), r3 (=0) */
+
+ ADD_L ( EDI, EAX ) /* next vertex */
+ ADD_L ( CONST(16), EDX ) /* next r */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ JNZ ( LLBL( G3TPPR_2 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TPPR_3 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points2_3d )
+HIDDEN(_mesa_3dnow_transform_points2_3d)
+GLNAME( _mesa_3dnow_transform_points2_3d ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_3 ), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TP3R_3 ) )
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m00 */
+ PUNPCKLDQ ( REGOFF(16, ECX), MM0 ) /* m10 | m00 */
+
+ MOVD ( REGOFF(4, ECX), MM1 ) /* | m01 */
+ PUNPCKLDQ ( REGOFF(20, ECX), MM1 ) /* m11 | m01 */
+
+ MOVD ( REGOFF(8, ECX), MM2 ) /* | m02 */
+ PUNPCKLDQ ( REGOFF(24, ECX), MM2 ) /* m12 | m02 */
+
+ MOVQ ( REGOFF(48, ECX), MM4 ) /* m31 | m30 */
+ MOVD ( REGOFF(56, ECX), MM5 ) /* | m32 */
+
+ALIGNTEXT16
+LLBL( G3TP3R_2 ):
+
+ MOVQ ( REGIND(EAX), MM6 ) /* x1 | x0 */
+ MOVQ ( MM6, MM7 ) /* x1 | x0 */
+
+ PFMUL ( MM0, MM6 ) /* x1*m10 | x0*m00 */
+ PFMUL ( MM1, MM7 ) /* x1*m11 | x0*m01 */
+
+ PFACC ( MM7, MM6 ) /* x0*m01+x1*m11 | x0*x00+x1*m10 */
+ PFADD ( MM4, MM6 ) /* x0*...*m11+m31 | x0*...*m10+m30 */
+
+ MOVQ ( MM6, REGIND(EDX) ) /* write r1, r0 */
+ MOVQ ( REGIND(EAX), MM6 ) /* x1 | x0 */
+
+ MOVQ ( MM6, MM7 ) /* x1 | x0 */
+ PFMUL ( MM2, MM6 ) /* x1*m12 | x0*m02 */
+
+ PFACC ( MM7, MM6 ) /* ***trash*** | x0*x02+x1*m12 */
+ PFADD ( MM5, MM6 ) /* ***trash*** | x0*...*m12+m32 */
+
+ MOVD ( MM6, REGOFF(8, EDX) ) /* write r2 */
+ ADD_L ( EDI, EAX ) /* next vertex */
+
+ ADD_L ( CONST(16), EDX ) /* next r */
+ DEC_L ( ESI ) /* decrement vertex counter */
+
+ JNZ ( LLBL( G3TP3R_2 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TP3R_3 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points2_3d_no_rot )
+HIDDEN(_mesa_3dnow_transform_points2_3d_no_rot)
+GLNAME( _mesa_3dnow_transform_points2_3d_no_rot ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_3 ), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TP3NRR_3 ) )
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m00 */
+ PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */
+
+ MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */
+ MOVD ( REGOFF(56, ECX), MM3 ) /* | m32 */
+
+ALIGNTEXT16
+LLBL( G3TP3NRR_2 ):
+
+ MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */
+ PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */
+
+ PFADD ( MM2, MM4 ) /* x1*m11+m31 | x0*m00+m30 */
+ MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */
+
+ MOVD ( MM3, REGOFF(8, EDX) ) /* write r2 */
+ ADD_L ( EDI, EAX ) /* next vertex */
+
+ ADD_L ( CONST(16), EDX ) /* next r */
+ DEC_L ( ESI ) /* decrement vertex counter */
+
+ JNZ ( LLBL( G3TP3NRR_2 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TP3NRR_3 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points2_2d )
+HIDDEN(_mesa_3dnow_transform_points2_2d)
+GLNAME( _mesa_3dnow_transform_points2_2d ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(2), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TP2R_3 ) )
+
+ MOVQ ( REGIND(ECX), MM0 ) /* m01 | m00 */
+ MOVQ ( REGOFF(16, ECX), MM1 ) /* m11 | m10 */
+
+ MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */
+
+ALIGNTEXT16
+LLBL( G3TP2R_2 ):
+
+ MOVD ( REGIND(EAX), MM4 ) /* | x0 */
+ MOVD ( REGOFF(4, EAX), MM5 ) /* | x1 */
+
+ PUNPCKLDQ ( MM4, MM4 ) /* x0 | x0 */
+ ADD_L ( EDI, EAX ) /* next vertex */
+
+ PFMUL ( MM0, MM4 ) /* x0*m01 | x0*m00 */
+ PUNPCKLDQ ( MM5, MM5 ) /* x1 | x1 */
+
+ PFMUL ( MM1, MM5 ) /* x1*m11 | x1*m10 */
+ PFADD ( MM2, MM4 ) /* x...x1*m11+31 | x0*..*m10+m30 */
+
+ PFADD ( MM5, MM4 ) /* x0*m01+x1*m11 | x0*m00+x1*m10 */
+ MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */
+
+ ADD_L ( CONST(16), EDX ) /* next r */
+ DEC_L ( ESI ) /* decrement vertex counter */
+
+ JNZ ( LLBL( G3TP2R_2 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TP2R_3 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points2_2d_no_rot )
+HIDDEN(_mesa_3dnow_transform_points2_2d_no_rot)
+GLNAME( _mesa_3dnow_transform_points2_2d_no_rot ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(2), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TP2NRR_3 ) )
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m00 */
+ PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */
+
+ MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */
+
+ALIGNTEXT16
+LLBL( G3TP2NRR_2 ):
+
+ MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */
+ ADD_L ( EDI, EAX ) /* next vertex */
+
+ PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */
+ PFADD ( MM2, MM4 ) /* m31 | x0*m00+m30 */
+
+ MOVQ ( MM4, REGIND(EDX) ) /* write r1, r0 */
+ ADD_L ( CONST(16), EDX ) /* next r */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ JNZ ( LLBL( G3TP2NRR_2 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TP2NRR_3 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points2_identity )
+HIDDEN(_mesa_3dnow_transform_points2_identity)
+GLNAME( _mesa_3dnow_transform_points2_identity ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(2), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TPIR_3 ) )
+
+ALIGNTEXT16
+LLBL( G3TPIR_3 ):
+
+ MOVQ ( REGIND(EAX), MM0 ) /* x1 | x0 */
+ ADD_L ( EDI, EAX ) /* next vertex */
+
+ MOVQ ( MM0, REGIND(EDX) ) /* r1 | r0 */
+ ADD_L ( CONST(16), EDX ) /* next r */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ JNZ ( LLBL( G3TPIR_3 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TPIR_4 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/3dnow_xform3.S b/nx-X11/extras/Mesa/src/mesa/x86/3dnow_xform3.S
new file mode 100644
index 000000000..d9fac6612
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/3dnow_xform3.S
@@ -0,0 +1,557 @@
+/* $Id: 3dnow_xform3.S,v 1.1.1.2 2005/07/31 16:46:40 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+#ifdef USE_3DNOW_ASM
+#include "matypes.h"
+#include "xform_args.h"
+
+ SEG_TEXT
+
+#define FRAME_OFFSET 4
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points3_general )
+HIDDEN(_mesa_3dnow_transform_points3_general)
+GLNAME( _mesa_3dnow_transform_points3_general ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TPGR_2 ) )
+
+ PREFETCHW ( REGIND(EDX) )
+
+ALIGNTEXT16
+LLBL( G3TPGR_1 ):
+
+ PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */
+
+ MOVQ ( REGIND(EAX), MM0 ) /* x1 | x0 */
+ MOVD ( REGOFF(8, EAX), MM2 ) /* | x2 */
+
+ ADD_L ( EDI, EAX ) /* next vertex */
+ PREFETCH ( REGIND(EAX) )
+
+ MOVQ ( MM0, MM1 ) /* x1 | x0 */
+ PUNPCKLDQ ( MM2, MM2 ) /* x2 | x2 */
+
+ PUNPCKLDQ ( MM0, MM0 ) /* x0 | x0 */
+ MOVQ ( MM2, MM5 ) /* x2 | x2 */
+
+ PUNPCKHDQ ( MM1, MM1 ) /* x1 | x1 */
+ PFMUL ( REGOFF(32, ECX), MM2 ) /* x2*m9 | x2*m8 */
+
+ MOVQ ( MM0, MM3 ) /* x0 | x0 */
+ PFMUL ( REGOFF(40, ECX), MM5 ) /* x2*m11 | x2*m10 */
+
+ MOVQ ( MM1, MM4 ) /* x1 | x1 */
+ PFMUL ( REGIND(ECX), MM0 ) /* x0*m1 | x0*m0 */
+
+ PFADD ( REGOFF(48, ECX), MM2 ) /* x2*m9+m13 | x2*m8+m12 */
+ PFMUL ( REGOFF(16, ECX), MM1 ) /* x1*m5 | x1*m4 */
+
+ PFADD ( REGOFF(56, ECX), MM5 ) /* x2*m11+m15 | x2*m10+m14 */
+ PFADD ( MM0, MM1 ) /* x0*m1+x1*m5 | x0*m0+x1*m4 */
+
+ PFMUL ( REGOFF(8, ECX), MM3 ) /* x0*m3 | x0*m2 */
+ PFADD ( MM1, MM2 ) /* r1 | r0 */
+
+ PFMUL ( REGOFF(24, ECX), MM4 ) /* x1*m7 | x1*m6 */
+ ADD_L ( CONST(16), EDX ) /* next output vertex */
+
+ PFADD ( MM3, MM4 ) /* x0*m3+x1*m7 | x0*m2+x1*m6 */
+ MOVQ ( MM2, REGOFF(-16, EDX) ) /* write r0, r1 */
+
+ PFADD ( MM4, MM5 ) /* r3 | r2 */
+ MOVQ ( MM5, REGOFF(-8, EDX) ) /* write r2, r3 */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ JNZ ( LLBL( G3TPGR_1 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TPGR_2 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points3_perspective )
+HIDDEN(_mesa_3dnow_transform_points3_perspective)
+GLNAME( _mesa_3dnow_transform_points3_perspective ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TPPR_2 ) )
+
+ PREFETCH ( REGIND(EAX) )
+ PREFETCHW ( REGIND(EDX) )
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m00 */
+ PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */
+
+ MOVQ ( REGOFF(32, ECX), MM1 ) /* m21 | m20 */
+ MOVD ( REGOFF(40, ECX), MM2 ) /* | m22 */
+
+ MOVD ( REGOFF(56, ECX), MM3 ) /* | m32 */
+
+ALIGNTEXT16
+LLBL( G3TPPR_1 ):
+
+ PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */
+
+ MOVD ( REGOFF(8, EAX), MM5 ) /* | x2 */
+ MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */
+
+ ADD_L ( EDI, EAX ) /* next vertex */
+ PREFETCH ( REGIND(EAX) )
+
+ PXOR ( MM7, MM7 ) /* 0 | 0 */
+ MOVQ ( MM5, MM6 ) /* | x2 */
+
+ PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */
+ PFSUB ( MM5, MM7 ) /* | -x2 */
+
+ PFMUL ( MM2, MM6 ) /* | x2*m22 */
+ PUNPCKLDQ ( MM5, MM5 ) /* x2 | x2 */
+
+ ADD_L ( CONST(16), EDX ) /* next r */
+ PFMUL ( MM1, MM5 ) /* x2*m21 | x2*m20 */
+
+ PFADD ( MM3, MM6 ) /* | x2*m22+m32 */
+ PFADD ( MM4, MM5 ) /* x1*m11+x2*m21 | x0*m00+x2*m20 */
+
+ MOVQ ( MM5, REGOFF(-16, EDX) ) /* write r0, r1 */
+ MOVD ( MM6, REGOFF(-8, EDX) ) /* write r2 */
+
+ MOVD ( MM7, REGOFF(-4, EDX) ) /* write r3 */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ JNZ ( LLBL( G3TPPR_1 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TPPR_2 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points3_3d )
+HIDDEN(_mesa_3dnow_transform_points3_3d)
+GLNAME( _mesa_3dnow_transform_points3_3d ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TP3R_2 ) )
+
+ PREFETCH ( REGIND(EAX) )
+ PREFETCH ( REGIND(EDX) )
+
+ MOVD ( REGOFF(8, ECX), MM7 ) /* | m2 */
+ PUNPCKLDQ ( REGOFF(24, ECX), MM7 ) /* m6 | m2 */
+
+
+ALIGNTEXT16
+LLBL( G3TP3R_1 ):
+
+ PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */
+
+ MOVQ ( REGIND(EAX), MM0 ) /* x1 | x0 */
+ MOVD ( REGOFF(8, EAX), MM1 ) /* | x2 */
+
+ ADD_L ( EDI, EAX ) /* next vertex */
+ PREFETCH ( REGIND(EAX) )
+
+ MOVQ ( MM0, MM2 ) /* x1 | x0 */
+ ADD_L ( CONST(16), EDX ) /* next r */
+
+ PUNPCKLDQ ( MM2, MM2 ) /* x0 | x0 */
+ MOVQ ( MM0, MM3 ) /* x1 | x0 */
+
+ PFMUL ( REGIND(ECX), MM2 ) /* x0*m1 | x0*m0 */
+ PUNPCKHDQ ( MM3, MM3 ) /* x1 | x1 */
+
+ MOVQ ( MM1, MM4 ) /* | x2 */
+ PFMUL ( REGOFF(16, ECX), MM3 ) /* x1*m5 | x1*m4 */
+
+ PUNPCKLDQ ( MM4, MM4 ) /* x2 | x2 */
+ PFADD ( MM2, MM3 ) /* x0*m1+x1*m5 | x0*m0+x1*m4 */
+
+ PFMUL ( REGOFF(32, ECX), MM4 ) /* x2*m9 | x2*m8 */
+ PFADD ( REGOFF(48, ECX), MM3 ) /* x0*m1+...+m11 | x0*m0+x1*m4+m12 */
+
+ PFMUL ( MM7, MM0 ) /* x1*m6 | x0*m2 */
+ PFADD ( MM4, MM3 ) /* r1 | r0 */
+
+ PFMUL ( REGOFF(40, ECX), MM1 ) /* | x2*m10 */
+ PUNPCKLDQ ( REGOFF(56, ECX), MM1 ) /* m14 | x2*m10 */
+
+ PFACC ( MM0, MM1 )
+
+ MOVQ ( MM3, REGOFF(-16, EDX) ) /* write r0, r1 */
+ PFACC ( MM1, MM1 ) /* | r2 */
+
+ MOVD ( MM1, REGOFF(-8, EDX) ) /* write r2 */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ JNZ ( LLBL( G3TP3R_1 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TP3R_2 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points3_3d_no_rot )
+HIDDEN(_mesa_3dnow_transform_points3_3d_no_rot)
+GLNAME( _mesa_3dnow_transform_points3_3d_no_rot ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TP3NRR_2 ) )
+
+ PREFETCH ( REGIND(EAX) )
+ PREFETCHW ( REGIND(EDX) )
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m00 */
+ PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */
+
+ MOVD ( REGOFF(40, ECX), MM2 ) /* | m22 */
+ PUNPCKLDQ ( MM2, MM2 ) /* m22 | m22 */
+
+ MOVQ ( REGOFF(48, ECX), MM1 ) /* m31 | m30 */
+ MOVD ( REGOFF(56, ECX), MM3 ) /* | m32 */
+
+ PUNPCKLDQ ( MM3, MM3 ) /* m32 | m32 */
+
+
+ALIGNTEXT16
+LLBL( G3TP3NRR_1 ):
+
+ PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */
+
+ MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */
+ MOVD ( REGOFF(8, EAX), MM5 ) /* | x2 */
+
+ ADD_L ( EDI, EAX ) /* next vertex */
+ PREFETCHW ( REGIND(EAX) )
+
+ PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */
+
+ PFADD ( MM1, MM4 ) /* x1*m11+m31 | x0*m00+m30 */
+ PFMUL ( MM2, MM5 ) /* | x2*m22 */
+
+ PFADD ( MM3, MM5 ) /* | x2*m22+m32 */
+ MOVQ ( MM4, REGIND(EDX) ) /* write r0, r1 */
+
+ ADD_L ( CONST(16), EDX ) /* next r */
+ DEC_L ( ESI ) /* decrement vertex counter */
+
+ MOVD ( MM5, REGOFF(-8, EDX) ) /* write r2 */
+ JNZ ( LLBL( G3TP3NRR_1 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TP3NRR_2 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points3_2d )
+HIDDEN(_mesa_3dnow_transform_points3_2d)
+GLNAME( _mesa_3dnow_transform_points3_2d ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TP2R_3) )
+
+ PREFETCH ( REGIND(EAX) )
+ PREFETCHW ( REGIND(EDX) )
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m00 */
+ PUNPCKLDQ ( REGOFF(16, ECX), MM0 ) /* m10 | m00 */
+
+ MOVD ( REGOFF(4, ECX), MM1 ) /* | m01 */
+ PUNPCKLDQ ( REGOFF(20, ECX), MM1 ) /* m11 | m01 */
+
+ MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */
+
+ALIGNTEXT16
+LLBL( G3TP2R_2 ):
+
+ PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */
+
+ MOVQ ( REGIND(EAX), MM3 ) /* x1 | x0 */
+ MOVD ( REGOFF(8, EAX), MM5 ) /* | x2 */
+
+ ADD_L ( EDI, EAX ) /* next vertex */
+ PREFETCH ( REGIND(EAX) )
+
+ MOVQ ( MM3, MM4 ) /* x1 | x0 */
+ PFMUL ( MM0, MM3 ) /* x1*m10 | x0*m00 */
+
+ ADD_L ( CONST(16), EDX ) /* next r */
+ PFMUL ( MM1, MM4 ) /* x1*m11 | x0*m01 */
+
+ PFACC ( MM4, MM3 ) /* x0*m00+x1*m10 | x0*m01+x1*m11 */
+ MOVD ( MM5, REGOFF(-8, EDX) ) /* write r2 (=x2) */
+
+ PFADD ( MM2, MM3 ) /* x0*...*m10+m30 | x0*...*m11+m31 */
+ MOVQ ( MM3, REGOFF(-16, EDX) ) /* write r0, r1 */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ JNZ ( LLBL( G3TP2R_2 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TP2R_3 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points3_2d_no_rot )
+HIDDEN(_mesa_3dnow_transform_points3_2d_no_rot)
+GLNAME( _mesa_3dnow_transform_points3_2d_no_rot ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TP2NRR_2 ) )
+
+ PREFETCH ( REGIND(EAX) )
+ PREFETCHW ( REGIND(EDX) )
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m00 */
+ PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */
+
+ MOVQ ( REGOFF(48, ECX), MM1 ) /* m31 | m30 */
+
+
+ALIGNTEXT16
+LLBL( G3TP2NRR_1 ):
+
+ PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */
+
+ MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */
+ MOVD ( REGOFF(8, EAX), MM5 ) /* | x2 */
+
+ ADD_L ( EDI, EAX ) /* next vertex */
+ PREFETCH ( REGIND(EAX) )
+
+ PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */
+ ADD_L ( CONST(16), EDX ) /* next r */
+
+ PFADD ( MM1, MM4 ) /* x1*m11+m31 | x0*m00+m30 */
+
+ MOVQ ( MM4, REGOFF(-16, EDX) ) /* write r0, r1 */
+ MOVD ( MM5, REGOFF(-8, EDX) ) /* write r2 (=x2) */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ JNZ ( LLBL( G3TP2NRR_1 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TP2NRR_2 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points3_identity )
+HIDDEN(_mesa_3dnow_transform_points3_identity)
+GLNAME( _mesa_3dnow_transform_points3_identity ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(3), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TPIR_2 ) )
+
+ PREFETCHW ( REGIND(EDX) )
+
+ALIGNTEXT16
+LLBL( G3TPIR_1 ):
+
+ PREFETCHW ( REGOFF(32, EDX) )
+
+ MOVQ ( REGIND(EAX), MM0 ) /* x1 | x0 */
+ MOVD ( REGOFF(8, EAX), MM1 ) /* | x2 */
+
+ ADD_L ( EDI, EAX ) /* next vertex */
+ ADD_L ( CONST(16), EDX ) /* next r */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ MOVQ ( MM0, REGOFF(-16, EDX) ) /* r1 | r0 */
+
+ MOVD ( MM1, REGOFF(-8, EDX) ) /* | r2 */
+ JNZ ( LLBL( G3TPIR_1 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TPIR_2 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/3dnow_xform4.S b/nx-X11/extras/Mesa/src/mesa/x86/3dnow_xform4.S
new file mode 100644
index 000000000..4df8ae8e2
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/3dnow_xform4.S
@@ -0,0 +1,566 @@
+/* $Id: 3dnow_xform4.S,v 1.1.1.2 2005/07/31 16:46:39 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+#ifdef USE_3DNOW_ASM
+#include "matypes.h"
+#include "xform_args.h"
+
+ SEG_TEXT
+
+#define FRAME_OFFSET 4
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points4_general )
+HIDDEN(_mesa_3dnow_transform_points4_general)
+GLNAME( _mesa_3dnow_transform_points4_general ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TPGR_2 ) )
+
+ PREFETCHW ( REGIND(EDX) )
+
+ALIGNTEXT16
+LLBL( G3TPGR_1 ):
+
+ PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */
+
+ MOVQ ( REGIND(EAX), MM0 ) /* x1 | x0 */
+ MOVQ ( REGOFF(8, EAX), MM4 ) /* x3 | x2 */
+
+ ADD_L ( EDI, EAX ) /* next vertex */
+ PREFETCH ( REGIND(EAX) )
+
+ MOVQ ( MM0, MM2 ) /* x1 | x0 */
+ MOVQ ( MM4, MM6 ) /* x3 | x2 */
+
+ PUNPCKLDQ ( MM0, MM0 ) /* x0 | x0 */
+ PUNPCKHDQ ( MM2, MM2 ) /* x1 | x1 */
+
+ MOVQ ( MM0, MM1 ) /* x0 | x0 */
+ ADD_L ( CONST(16), EDX ) /* next r */
+
+ PFMUL ( REGIND(ECX), MM0 ) /* x0*m1 | x0*m0 */
+ MOVQ ( MM2, MM3 ) /* x1 | x1 */
+
+ PFMUL ( REGOFF(8, ECX), MM1 ) /* x0*m3 | x0*m2 */
+ PUNPCKLDQ ( MM4, MM4 ) /* x2 | x2 */
+
+ PFMUL ( REGOFF(16, ECX), MM2 ) /* x1*m5 | x1*m4 */
+ MOVQ ( MM4, MM5 ) /* x2 | x2 */
+
+ PFMUL ( REGOFF(24, ECX), MM3 ) /* x1*m7 | x1*m6 */
+ PUNPCKHDQ ( MM6, MM6 ) /* x3 | x3 */
+
+ PFMUL ( REGOFF(32, ECX), MM4 ) /* x2*m9 | x2*m8 */
+ MOVQ ( MM6, MM7 ) /* x3 | x3 */
+
+ PFMUL ( REGOFF(40, ECX), MM5 ) /* x2*m11 | x2*m10 */
+ PFADD ( MM0, MM2 )
+
+ PFMUL ( REGOFF(48, ECX), MM6 ) /* x3*m13 | x3*m12 */
+ PFADD ( MM1, MM3 )
+
+ PFMUL ( REGOFF(56, ECX), MM7 ) /* x3*m15 | x3*m14 */
+ PFADD ( MM4, MM6 )
+
+ PFADD ( MM5, MM7 )
+ PFADD ( MM2, MM6 )
+
+ PFADD ( MM3, MM7 )
+ MOVQ ( MM6, REGOFF(-16, EDX) )
+
+ MOVQ ( MM7, REGOFF(-8, EDX) )
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ JNZ ( LLBL( G3TPGR_1 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TPGR_2 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points4_perspective )
+HIDDEN(_mesa_3dnow_transform_points4_perspective)
+GLNAME( _mesa_3dnow_transform_points4_perspective ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TPPR_2 ) )
+
+ PREFETCH ( REGIND(EAX) )
+ PREFETCHW ( REGIND(EDX) )
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m00 */
+ PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */
+
+ MOVD ( REGOFF(40, ECX), MM1 ) /* | m22 */
+ PUNPCKLDQ ( REGOFF(56, ECX), MM1 ) /* m32 | m22 */
+
+ MOVQ ( REGOFF(32, ECX), MM2 ) /* m21 | m20 */
+ PXOR ( MM7, MM7 ) /* 0 | 0 */
+
+ALIGNTEXT16
+LLBL( G3TPPR_1 ):
+
+ PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */
+
+ MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */
+ MOVQ ( REGOFF(8, EAX), MM5 ) /* x3 | x2 */
+ MOVD ( REGOFF(8, EAX), MM3 ) /* | x2 */
+
+ ADD_L ( EDI, EAX ) /* next vertex */
+ PREFETCH ( REGOFF(32, EAX) ) /* hopefully stride is zero */
+
+ MOVQ ( MM5, MM6 ) /* x3 | x2 */
+ PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */
+
+ PUNPCKLDQ ( MM5, MM5 ) /* x2 | x2 */
+ ADD_L ( CONST(16), EDX ) /* next r */
+
+ PFMUL ( MM2, MM5 ) /* x2*m21 | x2*m20 */
+ PFSUBR ( MM7, MM3 ) /* | -x2 */
+
+ PFMUL ( MM1, MM6 ) /* x3*m32 | x2*m22 */
+ PFADD ( MM4, MM5 ) /* x1*m11+x2*m21 | x0*m00+x2*m20 */
+
+ PFACC ( MM3, MM6 ) /* -x2 | x2*m22+x3*m32 */
+ MOVQ ( MM5, REGOFF(-16, EDX) ) /* write r0, r1 */
+
+ MOVQ ( MM6, REGOFF(-8, EDX) ) /* write r2, r3 */
+ DEC_L ( ESI ) /* decrement vertex counter */
+
+ JNZ ( LLBL( G3TPPR_1 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TPPR_2 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points4_3d )
+HIDDEN(_mesa_3dnow_transform_points4_3d)
+GLNAME( _mesa_3dnow_transform_points4_3d ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TP3R_2 ) )
+
+ MOVD ( REGOFF(8, ECX), MM6 ) /* | m2 */
+ PUNPCKLDQ ( REGOFF(24, ECX), MM6 ) /* m6 | m2 */
+
+ MOVD ( REGOFF(40, ECX), MM7 ) /* | m10 */
+ PUNPCKLDQ ( REGOFF(56, ECX), MM7 ) /* m14 | m10 */
+
+ALIGNTEXT16
+LLBL( G3TP3R_1 ):
+
+ PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */
+ PREFETCH ( REGOFF(32, EAX) ) /* hopefully array is tightly packed */
+
+ MOVQ ( REGIND(EAX), MM2 ) /* x1 | x0 */
+ MOVQ ( REGOFF(8, EAX), MM3 ) /* x3 | x2 */
+
+ MOVQ ( MM2, MM0 ) /* x1 | x0 */
+ MOVQ ( MM3, MM4 ) /* x3 | x2 */
+
+ MOVQ ( MM0, MM1 ) /* x1 | x0 */
+ MOVQ ( MM4, MM5 ) /* x3 | x2 */
+
+ PUNPCKLDQ ( MM0, MM0 ) /* x0 | x0 */
+ PUNPCKHDQ ( MM1, MM1 ) /* x1 | x1 */
+
+ PFMUL ( REGIND(ECX), MM0 ) /* x0*m1 | x0*m0 */
+ PUNPCKLDQ ( MM3, MM3 ) /* x2 | x2 */
+
+ PFMUL ( REGOFF(16, ECX), MM1 ) /* x1*m5 | x1*m4 */
+ PUNPCKHDQ ( MM4, MM4 ) /* x3 | x3 */
+
+ PFMUL ( MM6, MM2 ) /* x1*m6 | x0*m2 */
+ PFADD ( MM0, MM1 ) /* x0*m1+x1*m5 | x0*m0+x1*m4 */
+
+ PFMUL ( REGOFF(32, ECX), MM3 ) /* x2*m9 | x2*m8 */
+ ADD_L ( CONST(16), EDX ) /* next r */
+
+ PFMUL ( REGOFF(48, ECX), MM4 ) /* x3*m13 | x3*m12 */
+ PFADD ( MM1, MM3 ) /* x0*m1+..+x2*m9 | x0*m0+...+x2*m8 */
+
+ PFMUL ( MM7, MM5 ) /* x3*m14 | x2*m10 */
+ PFADD ( MM3, MM4 ) /* r1 | r0 */
+
+ PFACC ( MM2, MM5 ) /* x0*m2+x1*m6 | x2*m10+x3*m14 */
+ MOVD ( REGOFF(12, EAX), MM0 ) /* | x3 */
+
+ ADD_L ( EDI, EAX ) /* next vertex */
+ PFACC ( MM0, MM5 ) /* r3 | r2 */
+
+ MOVQ ( MM4, REGOFF(-16, EDX) ) /* write r0, r1 */
+ MOVQ ( MM5, REGOFF(-8, EDX) ) /* write r2, r3 */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ JNZ ( LLBL( G3TP3R_1 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TP3R_2 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points4_3d_no_rot )
+HIDDEN(_mesa_3dnow_transform_points4_3d_no_rot)
+GLNAME( _mesa_3dnow_transform_points4_3d_no_rot ):
+
+ PUSH_L ( ESI )
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TP3NRR_2 ) )
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m00 */
+ PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */
+
+ MOVD ( REGOFF(40, ECX), MM2 ) /* | m22 */
+ PUNPCKLDQ ( REGOFF(56, ECX), MM2 ) /* m32 | m22 */
+
+ MOVQ ( REGOFF(48, ECX), MM1 ) /* m31 | m30 */
+
+ALIGNTEXT16
+LLBL( G3TP3NRR_1 ):
+
+ PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */
+
+ MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */
+ MOVQ ( REGOFF(8, EAX), MM5 ) /* x3 | x2 */
+ MOVD ( REGOFF(12, EAX), MM7 ) /* | x3 */
+
+ ADD_L ( EDI, EAX ) /* next vertex */
+ PREFETCH ( REGOFF(32, EAX) ) /* hopefully stride is zero */
+
+ MOVQ ( MM5, MM6 ) /* x3 | x2 */
+ PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */
+
+ PUNPCKHDQ ( MM6, MM6 ) /* x3 | x3 */
+ PFMUL ( MM2, MM5 ) /* x3*m32 | x2*m22 */
+
+ PFMUL ( MM1, MM6 ) /* x3*m31 | x3*m30 */
+ PFACC ( MM7, MM5 ) /* x3 | x2*m22+x3*m32 */
+
+ PFADD ( MM6, MM4 ) /* x1*m11+x3*m31 | x0*m00+x3*m30 */
+ ADD_L ( CONST(16), EDX ) /* next r */
+
+ MOVQ ( MM4, REGOFF(-16, EDX) ) /* write r0, r1 */
+ MOVQ ( MM5, REGOFF(-8, EDX) ) /* write r2, r3 */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ JNZ ( LLBL( G3TP3NRR_1 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TP3NRR_2 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points4_2d )
+HIDDEN(_mesa_3dnow_transform_points4_2d)
+GLNAME( _mesa_3dnow_transform_points4_2d ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TP2R_2 ) )
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m00 */
+ PUNPCKLDQ ( REGOFF(16, ECX), MM0 ) /* m10 | m00 */
+
+ MOVD ( REGOFF(4, ECX), MM1 ) /* | m01 */
+ PUNPCKLDQ ( REGOFF(20, ECX), MM1 ) /* m11 | m01 */
+
+ MOVQ ( REGOFF(48, ECX), MM2 ) /* m31 | m30 */
+
+ALIGNTEXT16
+LLBL( G3TP2R_1 ):
+
+ PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */
+
+ MOVQ ( REGIND(EAX), MM3 ) /* x1 | x0 */
+ MOVQ ( REGOFF(8, EAX), MM5 ) /* x3 | x2 */
+
+ ADD_L ( EDI, EAX ) /* next vertex */
+ PREFETCH ( REGIND(EAX) )
+
+ MOVQ ( MM3, MM4 ) /* x1 | x0 */
+ MOVQ ( MM5, MM6 ) /* x3 | x2 */
+
+ PFMUL ( MM1, MM4 ) /* x1*m11 | x0*m01 */
+ PUNPCKHDQ ( MM6, MM6 ) /* x3 | x3 */
+
+ PFMUL ( MM0, MM3 ) /* x1*m10 | x0*m00 */
+ ADD_L ( CONST(16), EDX ) /* next r */
+
+ PFACC ( MM4, MM3 ) /* x0*m01+x1*m11 | x0*m00+x1*m10 */
+ PFMUL ( MM2, MM6 ) /* x3*m31 | x3*m30 */
+
+ PFADD ( MM6, MM3 ) /* r1 | r0 */
+ MOVQ ( MM5, REGOFF(-8, EDX) ) /* write r2, r3 */
+
+ MOVQ ( MM3, REGOFF(-16, EDX) ) /* write r0, r1 */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ JNZ ( LLBL( G3TP2R_1 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TP2R_2 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points4_2d_no_rot )
+HIDDEN(_mesa_3dnow_transform_points4_2d_no_rot)
+GLNAME( _mesa_3dnow_transform_points4_2d_no_rot ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TP2NRR_3 ) )
+
+ MOVD ( REGIND(ECX), MM0 ) /* | m00 */
+ PUNPCKLDQ ( REGOFF(20, ECX), MM0 ) /* m11 | m00 */
+
+ MOVQ ( REGOFF(48, ECX), MM1 ) /* m31 | m30 */
+
+ALIGNTEXT16
+LLBL( G3TP2NRR_2 ):
+
+ PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */
+
+ MOVQ ( REGIND(EAX), MM4 ) /* x1 | x0 */
+ MOVQ ( REGOFF(8, EAX), MM5 ) /* x3 | x2 */
+
+ ADD_L ( EDI, EAX ) /* next vertex */
+ PREFETCH ( REGIND(EAX) )
+
+ PFMUL ( MM0, MM4 ) /* x1*m11 | x0*m00 */
+ MOVQ ( MM5, MM6 ) /* x3 | x2 */
+
+ ADD_L ( CONST(16), EDX ) /* next r */
+ PUNPCKHDQ ( MM6, MM6 ) /* x3 | x3 */
+
+ PFMUL ( MM1, MM6 ) /* x3*m31 | x3*m30 */
+ PFADD ( MM4, MM6 ) /* x1*m11+x3*m31 | x0*m00+x3*m30 */
+
+ MOVQ ( MM6, REGOFF(-16, EDX) ) /* write r0, r1 */
+ MOVQ ( MM5, REGOFF(-8, EDX) ) /* write r2, r3 */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+
+ JNZ ( LLBL( G3TP2NRR_2 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TP2NRR_3 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_3dnow_transform_points4_identity )
+HIDDEN(_mesa_3dnow_transform_points4_identity)
+GLNAME( _mesa_3dnow_transform_points4_identity ):
+
+ PUSH_L ( ESI )
+
+ MOV_L ( ARG_DEST, ECX )
+ MOV_L ( ARG_MATRIX, ESI )
+ MOV_L ( ARG_SOURCE, EAX )
+ MOV_L ( CONST(4), REGOFF(V4F_SIZE, ECX) )
+ OR_B ( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, ECX) )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), EDX )
+ MOV_L ( EDX, REGOFF(V4F_COUNT, ECX) )
+
+ PUSH_L ( EDI )
+
+ MOV_L ( REGOFF(V4F_START, ECX), EDX )
+ MOV_L ( ESI, ECX )
+ MOV_L ( REGOFF(V4F_COUNT, EAX), ESI )
+ MOV_L ( REGOFF(V4F_STRIDE, EAX), EDI )
+ MOV_L ( REGOFF(V4F_START, EAX), EAX )
+
+ TEST_L ( ESI, ESI )
+ JZ ( LLBL( G3TPIR_2 ) )
+
+ALIGNTEXT16
+LLBL( G3TPIR_1 ):
+
+ PREFETCHW ( REGOFF(32, EDX) ) /* prefetch 2 vertices ahead */
+
+ MOVQ ( REGIND(EAX), MM0 ) /* x1 | x0 */
+ MOVQ ( REGOFF(8, EAX), MM1 ) /* x3 | x2 */
+
+ ADD_L ( EDI, EAX ) /* next vertex */
+ PREFETCH ( REGIND(EAX) )
+
+ ADD_L ( CONST(16), EDX ) /* next r */
+ MOVQ ( MM0, REGOFF(-16, EDX) ) /* r1 | r0 */
+
+ MOVQ ( MM1, REGOFF(-8, EDX) ) /* r3 | r2 */
+
+ DEC_L ( ESI ) /* decrement vertex counter */
+ JNZ ( LLBL( G3TPIR_1 ) ) /* cnt > 0 ? -> process next vertex */
+
+LLBL( G3TPIR_2 ):
+
+ FEMMS
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/Makefile b/nx-X11/extras/Mesa/src/mesa/x86/Makefile
new file mode 100644
index 000000000..3c6a6b11c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/Makefile
@@ -0,0 +1,46 @@
+# src/mesa/x86/Makefile
+
+TOP = ../../..
+include $(TOP)/configs/current
+
+
+INCLUDE_DIRS = \
+ -I$(TOP)/include/GL \
+ -I$(TOP)/include \
+ -I.. \
+ -I../main \
+ -I../math \
+ -I../glapi \
+ -I../tnl
+
+
+default: gen_matypes matypes.h
+
+clean:
+ rm -f matypes.h gen_matypes
+
+
+gen_matypes: gen_matypes.c
+ $(CC) $(INCLUDE_DIRS) $(CFLAGS) gen_matypes.c -o gen_matypes
+
+# need some special rules here, unfortunately
+matypes.h: ../main/mtypes.h ../tnl/t_context.h gen_matypes
+ ./gen_matypes > matypes.h
+
+common_x86_asm.o: matypes.h
+3dnow_normal.o: matypes.h
+3dnow_xform1.o: matypes.h
+3dnow_xform2.o: matypes.h
+3dnow_xform3.o: matypes.h
+3dnow_xform4.o: matypes.h
+mmx_blend.o: matypes.h
+sse_normal.o: matypes.h
+sse_xform1.o: matypes.h
+sse_xform2.o: matypes.h
+sse_xform3.o: matypes.h
+sse_xform4.o: matypes.h
+x86_cliptest.o: matypes.h
+x86_xform2.o: matypes.h
+x86_xform3.o: matypes.h
+x86_xform4.o: matypes.h
+
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/assyntax.h b/nx-X11/extras/Mesa/src/mesa/x86/assyntax.h
new file mode 100644
index 000000000..9bceacebd
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/assyntax.h
@@ -0,0 +1,1746 @@
+
+#ifndef __ASSYNTAX_H__
+#define __ASSYNTAX_H__
+
+/*
+ * Copyright 1992 Vrije Universiteit, The Netherlands
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted, 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 the Vrije Universiteit not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. The Vrije Universiteit makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * The Vrije Universiteit DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ * IN NO EVENT SHALL The Vrije Universiteit 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.
+ */
+
+/*
+ * assyntax.h
+ *
+ * Select the syntax appropriate to the 386 assembler being used
+ * To add support for more assemblers add more columns to the CHOICE
+ * macro. Note that register names must also have uppercase names
+ * to avoid macro recursion. e.g., #define ah %ah recurses!
+ *
+ * NB 1. Some of the macros for certain assemblers imply that the code is to
+ * run in protected mode!! Caveat emptor.
+ *
+ * NB 2. 486 specific instructions are not included. This is to discourage
+ * their accidental use in code that is intended to run on 386 and 486
+ * systems.
+ *
+ * Supported assemblers:
+ *
+ * (a) AT&T SysVr4 as(1): define ATT_ASSEMBLER
+ * (b) GNU Assembler gas: define GNU_ASSEMBLER (default)
+ * (c) Amsterdam Compiler kit: define ACK_ASSEMBLER
+ * (d) The Netwide Assembler: define NASM_ASSEMBLER
+ * (e) Microsoft Assembler: define MASM_ASSEMBLER (UNTESTED!)
+ *
+ * The following naming conventions have been used to identify the various
+ * data types:
+ * _SR = segment register version
+ * Integer:
+ * _Q = quadword = 64 bits
+ * _L = long = 32 bits
+ * _W = short = 16 bits
+ * _B = byte = 8 bits
+ * Floating-point:
+ * _X = m80real = 80 bits
+ * _D = double = 64 bits
+ * _S = single = 32 bits
+ *
+ * Author: Gregory J. Sharp, Sept 1992
+ * Vrije Universiteit, Amsterdam, The Netherlands
+ *
+ * [support for Intel syntax added by Josh Vanderhoof, 1999]
+ */
+
+#if !(defined(NASM_ASSEMBLER) || defined(MASM_ASSEMBLER))
+
+/* Default to ATT_ASSEMBLER when SVR4 or SYSV are defined */
+#if (defined(SVR4) || defined(SYSV)) && !defined(GNU_ASSEMBLER)
+#define ATT_ASSEMBLER
+#endif
+
+#if !defined(ATT_ASSEMBLER) && !defined(GNU_ASSEMBLER) && !defined(ACK_ASSEMBLER)
+#define GNU_ASSEMBLER
+#endif
+
+#if (defined(__STDC__) && !defined(UNIXCPP)) || (defined (sun) && defined (i386) && defined (SVR4) && defined (__STDC__) && !defined (__GNUC__))
+#define CONCAT(x, y) x ## y
+#define CONCAT3(x, y, z) x ## y ## z
+#else
+#define CONCAT(x, y) x/**/y
+#define CONCAT3(x, y, z) x/**/y/**/z
+#endif
+
+#ifdef ACK_ASSEMBLER
+
+/* Assume we write code for 32-bit protected mode! */
+
+/* Redefine register names for GAS & AT&T assemblers */
+#define AL al
+#define AH ah
+#define AX ax
+#define EAX ax
+#define BL bl
+#define BH bh
+#define BX bx
+#define EBX bx
+#define CL cl
+#define CH ch
+#define CX cx
+#define ECX cx
+#define DL dl
+#define DH dh
+#define DX dx
+#define EDX dx
+#define BP bp
+#define EBP bp
+#define SI si
+#define ESI si
+#define DI di
+#define EDI di
+#define SP sp
+#define ESP sp
+#define CS cs
+#define SS ss
+#define DS ds
+#define ES es
+#define FS fs
+#define GS gs
+/* Control Registers */
+#define CR0 cr0
+#define CR1 cr1
+#define CR2 cr2
+#define CR3 cr3
+/* Debug Registers */
+#define DR0 dr0
+#define DR1 dr1
+#define DR2 dr2
+#define DR3 dr3
+#define DR4 dr4
+#define DR5 dr5
+#define DR6 dr6
+#define DR7 dr7
+/* Floating-point Stack */
+#define ST st
+
+#define AS_BEGIN .sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text
+
+
+#define _WTOG o16 /* word toggle for _W instructions */
+#define _LTOG /* long toggle for _L instructions */
+#define ADDR_TOGGLE a16
+#define OPSZ_TOGGLE o16
+#define USE16 .use16
+#define USE32 .use32
+
+#define CHOICE(a,b,c) c
+
+#else /* AT&T or GAS */
+
+/* Redefine register names for GAS & AT&T assemblers */
+#define AL %al
+#define AH %ah
+#define AX %ax
+#define EAX %eax
+#define BL %bl
+#define BH %bh
+#define BX %bx
+#define EBX %ebx
+#define CL %cl
+#define CH %ch
+#define CX %cx
+#define ECX %ecx
+#define DL %dl
+#define DH %dh
+#define DX %dx
+#define EDX %edx
+#define BP %bp
+#define EBP %ebp
+#define SI %si
+#define ESI %esi
+#define DI %di
+#define EDI %edi
+#define SP %sp
+#define ESP %esp
+#define CS %cs
+#define SS %ss
+#define DS %ds
+#define ES %es
+#define FS %fs
+#define GS %gs
+/* Control Registers */
+#define CR0 %cr0
+#define CR1 %cr1
+#define CR2 %cr2
+#define CR3 %cr3
+/* Debug Registers */
+#define DR0 %db0
+#define DR1 %db1
+#define DR2 %db2
+#define DR3 %db3
+#define DR4 %db4
+#define DR5 %db5
+#define DR6 %db6
+#define DR7 %db7
+/* Floating-point Stack */
+#define _STX0 %st(0)
+#define _STX1 %st(1)
+#define _STX2 %st(2)
+#define _STX3 %st(3)
+#define _STX4 %st(4)
+#define _STX5 %st(5)
+#define _STX6 %st(6)
+#define _STX7 %st(7)
+#define ST(x) CONCAT(_STX,x)
+#ifdef GNU_ASSEMBLER
+#define ST0 %st(0)
+#else
+#define ST0 %st
+#endif
+/* MMX Registers */
+#define MM0 %mm0
+#define MM1 %mm1
+#define MM2 %mm2
+#define MM3 %mm3
+#define MM4 %mm4
+#define MM5 %mm5
+#define MM6 %mm6
+#define MM7 %mm7
+/* SSE Registers */
+#define XMM0 %xmm0
+#define XMM1 %xmm1
+#define XMM2 %xmm2
+#define XMM3 %xmm3
+#define XMM4 %xmm4
+#define XMM5 %xmm5
+#define XMM6 %xmm6
+#define XMM7 %xmm7
+
+#define AS_BEGIN
+#define USE16
+#define USE32
+
+#ifdef GNU_ASSEMBLER
+
+#define ADDR_TOGGLE aword
+#define OPSZ_TOGGLE word
+
+#define CHOICE(a,b,c) b
+
+#else
+/*
+ * AT&T ASSEMBLER SYNTAX
+ * *********************
+ */
+#define CHOICE(a,b,c) a
+
+#define ADDR_TOGGLE addr16
+#define OPSZ_TOGGLE data16
+
+#endif /* GNU_ASSEMBLER */
+#endif /* ACK_ASSEMBLER */
+
+
+#if defined(__QNX__) || defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || defined(__ELF__) || defined(__GNU__) || defined(__GNUC__) && !defined(__DJGPP__) && !defined(__MINGW32__)
+#define GLNAME(a) a
+#else
+#define GLNAME(a) CONCAT(_,a)
+#endif
+
+
+ /****************************************/
+ /* */
+ /* Select the various choices */
+ /* */
+ /****************************************/
+
+
+/* Redefine assembler directives */
+/*********************************/
+#define GLOBL CHOICE(.globl, .globl, .extern)
+#define GLOBAL GLOBL
+#define EXTERN GLOBL
+#ifndef __AOUT__
+#define ALIGNTEXT32 CHOICE(.align 32, .balign 32, .align 32)
+#define ALIGNTEXT16 CHOICE(.align 16, .balign 16, .align 16)
+#define ALIGNTEXT8 CHOICE(.align 8, .balign 8, .align 8)
+#define ALIGNTEXT4 CHOICE(.align 4, .balign 4, .align 4)
+#define ALIGNTEXT2 CHOICE(.align 2, .balign 2, .align 2)
+/* ALIGNTEXT4ifNOP is the same as ALIGNTEXT4, but only if the space is
+ * guaranteed to be filled with NOPs. Otherwise it does nothing.
+ */
+#define ALIGNTEXT32ifNOP CHOICE(.align 32, .balign ARG2(32,0x90), /*can't do it*/)
+#define ALIGNTEXT16ifNOP CHOICE(.align 16, .balign ARG2(16,0x90), /*can't do it*/)
+#define ALIGNTEXT8ifNOP CHOICE(.align 8, .balign ARG2(8,0x90), /*can't do it*/)
+#define ALIGNTEXT4ifNOP CHOICE(.align 4, .balign ARG2(4,0x90), /*can't do it*/)
+#define ALIGNDATA32 CHOICE(.align 32, .balign ARG2(32,0x0), .align 32)
+#define ALIGNDATA16 CHOICE(.align 16, .balign ARG2(16,0x0), .align 16)
+#define ALIGNDATA8 CHOICE(.align 8, .balign ARG2(8,0x0), .align 8)
+#define ALIGNDATA4 CHOICE(.align 4, .balign ARG2(4,0x0), .align 4)
+#define ALIGNDATA2 CHOICE(.align 2, .balign ARG2(2,0x0), .align 2)
+#else
+/* 'as -aout' on FreeBSD doesn't have .balign */
+#define ALIGNTEXT32 CHOICE(.align 32, .align ARG2(5,0x90), .align 32)
+#define ALIGNTEXT16 CHOICE(.align 16, .align ARG2(4,0x90), .align 16)
+#define ALIGNTEXT8 CHOICE(.align 8, .align ARG2(3,0x90), .align 8)
+#define ALIGNTEXT4 CHOICE(.align 4, .align ARG2(2,0x90), .align 4)
+#define ALIGNTEXT2 CHOICE(.align 2, .align ARG2(1,0x90), .align 2)
+/* ALIGNTEXT4ifNOP is the same as ALIGNTEXT4, but only if the space is
+ * guaranteed to be filled with NOPs. Otherwise it does nothing.
+ */
+#define ALIGNTEXT32ifNOP CHOICE(.align 32, .align ARG2(5,0x90), /*can't do it*/)
+#define ALIGNTEXT16ifNOP CHOICE(.align 16, .align ARG2(4,0x90), /*can't do it*/)
+#define ALIGNTEXT8ifNOP CHOICE(.align 8, .align ARG2(3,0x90), /*can't do it*/)
+#define ALIGNTEXT4ifNOP CHOICE(.align 4, .align ARG2(2,0x90), /*can't do it*/)
+#define ALIGNDATA32 CHOICE(.align 32, .align ARG2(5,0x0), .align 32)
+#define ALIGNDATA16 CHOICE(.align 16, .align ARG2(4,0x0), .align 16)
+#define ALIGNDATA8 CHOICE(.align 8, .align ARG2(3,0x0), .align 8)
+#define ALIGNDATA4 CHOICE(.align 4, .align ARG2(2,0x0), .align 4)
+#define ALIGNDATA2 CHOICE(.align 2, .align ARG2(1,0x0), .align 2)
+#endif /* __AOUT__ */
+#define FILE(s) CHOICE(.file s, .file s, .file s)
+#define STRING(s) CHOICE(.string s, .asciz s, .asciz s)
+#define D_LONG CHOICE(.long, .long, .data4)
+#define D_WORD CHOICE(.value, .short, .data2)
+#define D_BYTE CHOICE(.byte, .byte, .data1)
+#define SPACE CHOICE(.comm, .space, .space)
+#define COMM CHOICE(.comm, .comm, .comm)
+#define SEG_DATA CHOICE(.data, .data, .sect .data)
+#define SEG_TEXT CHOICE(.text, .text, .sect .text)
+#define SEG_BSS CHOICE(.bss, .bss, .sect .bss)
+
+#ifdef GNU_ASSEMBLER
+#define D_SPACE(n) . = . + n
+#else
+#define D_SPACE(n) .space n
+#endif
+
+/* Addressing Modes */
+/* Immediate Mode */
+#define ADDR(a) CHOICE(CONCAT($,a), $a, a)
+#define CONST(a) CHOICE(CONCAT($,a), $a, a)
+
+/* Indirect Mode */
+#define CONTENT(a) CHOICE(a, a, (a)) /* take contents of variable */
+#define REGIND(a) CHOICE((a), (a), (a)) /* Register a indirect */
+/* Register b indirect plus displacement a */
+#define REGOFF(a, b) CHOICE(a(b), a(b), a(b))
+/* Reg indirect Base + Index + Displacement - this is mainly for 16-bit mode
+ * which has no scaling
+ */
+#define REGBID(b,i,d) CHOICE(d(b,i), d(b,i), d(b)(i))
+/* Reg indirect Base + (Index * Scale) */
+#define REGBIS(b,i,s) CHOICE((b,i,s), (b,i,s), (b)(i*s))
+/* Reg indirect Base + (Index * Scale) + Displacement */
+#define REGBISD(b,i,s,d) CHOICE(d(b,i,s), d(b,i,s), d(b)(i*s))
+/* Displaced Scaled Index: */
+#define REGDIS(d,i,s) CHOICE(d(,i,s), d(,i,s), d(i * s))
+/* Indexed Base: */
+#define REGBI(b,i) CHOICE((b,i), (b,i), (b)(i))
+/* Displaced Base: */
+#define REGDB(d,b) CHOICE(d(b), d(b), d(b))
+/* Variable indirect: */
+#define VARINDIRECT(var) CHOICE(*var, *var, (var))
+/* Use register contents as jump/call target: */
+#define CODEPTR(reg) CHOICE(*reg, *reg, reg)
+
+/* For expressions requiring bracketing
+ * eg. (CRT0_PM | CRT_EM)
+ */
+
+#define EXPR(a) CHOICE([a], (a), [a])
+#define ENOT(a) CHOICE(0!a, ~a, ~a)
+#define EMUL(a,b) CHOICE(a\*b, a*b, a*b)
+#define EDIV(a,b) CHOICE(a\/b, a/b, a/b)
+
+/*
+ * We have to beat the problem of commas within arguments to choice.
+ * eg. choice (add a,b, add b,a) will get argument mismatch. Luckily ANSI
+ * and other known cpp definitions evaluate arguments before substitution
+ * so the following works.
+ */
+#define ARG2(a, b) a,b
+#define ARG3(a,b,c) a,b,c
+
+/* Redefine assembler commands */
+#define AAA CHOICE(aaa, aaa, aaa)
+#define AAD CHOICE(aad, aad, aad)
+#define AAM CHOICE(aam, aam, aam)
+#define AAS CHOICE(aas, aas, aas)
+#define ADC_L(a, b) CHOICE(adcl ARG2(a,b), adcl ARG2(a,b), _LTOG adc ARG2(b,a))
+#define ADC_W(a, b) CHOICE(adcw ARG2(a,b), adcw ARG2(a,b), _WTOG adc ARG2(b,a))
+#define ADC_B(a, b) CHOICE(adcb ARG2(a,b), adcb ARG2(a,b), adcb ARG2(b,a))
+#define ADD_L(a, b) CHOICE(addl ARG2(a,b), addl ARG2(a,b), _LTOG add ARG2(b,a))
+#define ADD_W(a, b) CHOICE(addw ARG2(a,b), addw ARG2(a,b), _WTOG add ARG2(b,a))
+#define ADD_B(a, b) CHOICE(addb ARG2(a,b), addb ARG2(a,b), addb ARG2(b,a))
+#define AND_L(a, b) CHOICE(andl ARG2(a,b), andl ARG2(a,b), _LTOG and ARG2(b,a))
+#define AND_W(a, b) CHOICE(andw ARG2(a,b), andw ARG2(a,b), _WTOG and ARG2(b,a))
+#define AND_B(a, b) CHOICE(andb ARG2(a,b), andb ARG2(a,b), andb ARG2(b,a))
+#define ARPL(a,b) CHOICE(arpl ARG2(a,b), arpl ARG2(a,b), arpl ARG2(b,a))
+#define BOUND_L(a, b) CHOICE(boundl ARG2(a,b), boundl ARG2(b,a), _LTOG bound ARG2(b,a))
+#define BOUND_W(a, b) CHOICE(boundw ARG2(a,b), boundw ARG2(b,a), _WTOG bound ARG2(b,a))
+#define BSF_L(a, b) CHOICE(bsfl ARG2(a,b), bsfl ARG2(a,b), _LTOG bsf ARG2(b,a))
+#define BSF_W(a, b) CHOICE(bsfw ARG2(a,b), bsfw ARG2(a,b), _WTOG bsf ARG2(b,a))
+#define BSR_L(a, b) CHOICE(bsrl ARG2(a,b), bsrl ARG2(a,b), _LTOG bsr ARG2(b,a))
+#define BSR_W(a, b) CHOICE(bsrw ARG2(a,b), bsrw ARG2(a,b), _WTOG bsr ARG2(b,a))
+#define BT_L(a, b) CHOICE(btl ARG2(a,b), btl ARG2(a,b), _LTOG bt ARG2(b,a))
+#define BT_W(a, b) CHOICE(btw ARG2(a,b), btw ARG2(a,b), _WTOG bt ARG2(b,a))
+#define BTC_L(a, b) CHOICE(btcl ARG2(a,b), btcl ARG2(a,b), _LTOG btc ARG2(b,a))
+#define BTC_W(a, b) CHOICE(btcw ARG2(a,b), btcw ARG2(a,b), _WTOG btc ARG2(b,a))
+#define BTR_L(a, b) CHOICE(btrl ARG2(a,b), btrl ARG2(a,b), _LTOG btr ARG2(b,a))
+#define BTR_W(a, b) CHOICE(btrw ARG2(a,b), btrw ARG2(a,b), _WTOG btr ARG2(b,a))
+#define BTS_L(a, b) CHOICE(btsl ARG2(a,b), btsl ARG2(a,b), _LTOG bts ARG2(b,a))
+#define BTS_W(a, b) CHOICE(btsw ARG2(a,b), btsw ARG2(a,b), _WTOG bts ARG2(b,a))
+#define CALL(a) CHOICE(call a, call a, call a)
+#define CALLF(s,a) CHOICE(lcall ARG2(s,a), lcall ARG2(s,a), callf s:a)
+#define CBW CHOICE(cbtw, cbw, cbw)
+#define CWDE CHOICE(cwtd, cwde, cwde)
+#define CLC CHOICE(clc, clc, clc)
+#define CLD CHOICE(cld, cld, cld)
+#define CLI CHOICE(cli, cli, cli)
+#define CLTS CHOICE(clts, clts, clts)
+#define CMC CHOICE(cmc, cmc, cmc)
+#define CMP_L(a, b) CHOICE(cmpl ARG2(a,b), cmpl ARG2(a,b), _LTOG cmp ARG2(b,a))
+#define CMP_W(a, b) CHOICE(cmpw ARG2(a,b), cmpw ARG2(a,b), _WTOG cmp ARG2(b,a))
+#define CMP_B(a, b) CHOICE(cmpb ARG2(a,b), cmpb ARG2(a,b), cmpb ARG2(b,a))
+#define CMPS_L CHOICE(cmpsl, cmpsl, _LTOG cmps)
+#define CMPS_W CHOICE(cmpsw, cmpsw, _WTOG cmps)
+#define CMPS_B CHOICE(cmpsb, cmpsb, cmpsb)
+#define CWD CHOICE(cwtl, cwd, cwd)
+#define CDQ CHOICE(cltd, cdq, cdq)
+#define DAA CHOICE(daa, daa, daa)
+#define DAS CHOICE(das, das, das)
+#define DEC_L(a) CHOICE(decl a, decl a, _LTOG dec a)
+#define DEC_W(a) CHOICE(decw a, decw a, _WTOG dec a)
+#define DEC_B(a) CHOICE(decb a, decb a, decb a)
+#define DIV_L(a) CHOICE(divl a, divl a, div a)
+#define DIV_W(a) CHOICE(divw a, divw a, div a)
+#define DIV_B(a) CHOICE(divb a, divb a, divb a)
+#define ENTER(a,b) CHOICE(enter ARG2(a,b), enter ARG2(a,b), enter ARG2(b,a))
+#define HLT CHOICE(hlt, hlt, hlt)
+#define IDIV_L(a) CHOICE(idivl a, idivl a, _LTOG idiv a)
+#define IDIV_W(a) CHOICE(idivw a, idivw a, _WTOG idiv a)
+#define IDIV_B(a) CHOICE(idivb a, idivb a, idivb a)
+/* More forms than this for imul!! */
+#define IMUL_L(a, b) CHOICE(imull ARG2(a,b), imull ARG2(a,b), _LTOG imul ARG2(b,a))
+#define IMUL_W(a, b) CHOICE(imulw ARG2(a,b), imulw ARG2(a,b), _WTOG imul ARG2(b,a))
+#define IMUL_B(a) CHOICE(imulb a, imulb a, imulb a)
+#define IN_L CHOICE(inl (DX), inl ARG2(DX,EAX), _LTOG in DX)
+#define IN_W CHOICE(inw (DX), inw ARG2(DX,AX), _WTOG in DX)
+#define IN_B CHOICE(inb (DX), inb ARG2(DX,AL), inb DX)
+/* Please AS code writer: use the following ONLY, if you refer to ports<256
+ * directly, but not in IN1_W(DX), for instance, even if IN1_ looks nicer
+ */
+#if defined (sun)
+#define IN1_L(a) CHOICE(inl (a), inl ARG2(a,EAX), _LTOG in a)
+#define IN1_W(a) CHOICE(inw (a), inw ARG2(a,AX), _WTOG in a)
+#define IN1_B(a) CHOICE(inb (a), inb ARG2(a,AL), inb a)
+#else
+#define IN1_L(a) CHOICE(inl a, inl ARG2(a,EAX), _LTOG in a)
+#define IN1_W(a) CHOICE(inw a, inw ARG2(a,AX), _WTOG in a)
+#define IN1_B(a) CHOICE(inb a, inb ARG2(a,AL), inb a)
+#endif
+#define INC_L(a) CHOICE(incl a, incl a, _LTOG inc a)
+#define INC_W(a) CHOICE(incw a, incw a, _WTOG inc a)
+#define INC_B(a) CHOICE(incb a, incb a, incb a)
+#define INS_L CHOICE(insl, insl, _LTOG ins)
+#define INS_W CHOICE(insw, insw, _WTOG ins)
+#define INS_B CHOICE(insb, insb, insb)
+#define INT(a) CHOICE(int a, int a, int a)
+#define INT3 CHOICE(int CONST(3), int3, int CONST(3))
+#define INTO CHOICE(into, into, into)
+#define IRET CHOICE(iret, iret, iret)
+#define IRETD CHOICE(iret, iret, iretd)
+#define JA(a) CHOICE(ja a, ja a, ja a)
+#define JAE(a) CHOICE(jae a, jae a, jae a)
+#define JB(a) CHOICE(jb a, jb a, jb a)
+#define JBE(a) CHOICE(jbe a, jbe a, jbe a)
+#define JC(a) CHOICE(jc a, jc a, jc a)
+#define JE(a) CHOICE(je a, je a, je a)
+#define JG(a) CHOICE(jg a, jg a, jg a)
+#define JGE(a) CHOICE(jge a, jge a, jge a)
+#define JL(a) CHOICE(jl a, jl a, jl a)
+#define JLE(a) CHOICE(jle a, jle a, jle a)
+#define JNA(a) CHOICE(jna a, jna a, jna a)
+#define JNAE(a) CHOICE(jnae a, jnae a, jnae a)
+#define JNB(a) CHOICE(jnb a, jnb a, jnb a)
+#define JNBE(a) CHOICE(jnbe a, jnbe a, jnbe a)
+#define JNC(a) CHOICE(jnc a, jnc a, jnc a)
+#define JNE(a) CHOICE(jne a, jne a, jne a)
+#define JNG(a) CHOICE(jng a, jng a, jng a)
+#define JNGE(a) CHOICE(jnge a, jnge a, jnge a)
+#define JNL(a) CHOICE(jnl a, jnl a, jnl a)
+#define JNLE(a) CHOICE(jnle a, jnle a, jnle a)
+#define JNO(a) CHOICE(jno a, jno a, jno a)
+#define JNP(a) CHOICE(jnp a, jnp a, jnp a)
+#define JNS(a) CHOICE(jns a, jns a, jns a)
+#define JNZ(a) CHOICE(jnz a, jnz a, jnz a)
+#define JO(a) CHOICE(jo a, jo a, jo a)
+#define JP(a) CHOICE(jp a, jp a, jp a)
+#define JPE(a) CHOICE(jpe a, jpe a, jpe a)
+#define JPO(a) CHOICE(jpo a, jpo a, jpo a)
+#define JS(a) CHOICE(js a, js a, js a)
+#define JZ(a) CHOICE(jz a, jz a, jz a)
+#define JMP(a) CHOICE(jmp a, jmp a, jmp a)
+#define JMPF(s,a) CHOICE(ljmp ARG2(s,a), ljmp ARG2(s,a), jmpf s:a)
+#define LAHF CHOICE(lahf, lahf, lahf)
+#if !defined(_REAL_MODE) && !defined(_V86_MODE)
+#define LAR(a, b) CHOICE(lar ARG2(a, b), lar ARG2(a, b), lar ARG2(b, a))
+#endif
+#define LEA_L(a, b) CHOICE(leal ARG2(a,b), leal ARG2(a,b), _LTOG lea ARG2(b,a))
+#define LEA_W(a, b) CHOICE(leaw ARG2(a,b), leaw ARG2(a,b), _WTOG lea ARG2(b,a))
+#define LEAVE CHOICE(leave, leave, leave)
+#define LGDT(a) CHOICE(lgdt a, lgdt a, lgdt a)
+#define LIDT(a) CHOICE(lidt a, lidt a, lidt a)
+#define LDS(a, b) CHOICE(ldsl ARG2(a,b), lds ARG2(a,b), lds ARG2(b,a))
+#define LES(a, b) CHOICE(lesl ARG2(a,b), les ARG2(a,b), les ARG2(b,a))
+#define LFS(a, b) CHOICE(lfsl ARG2(a,b), lfs ARG2(a,b), lfs ARG2(b,a))
+#define LGS(a, b) CHOICE(lgsl ARG2(a,b), lgs ARG2(a,b), lgs ARG2(b,a))
+#define LSS(a, b) CHOICE(lssl ARG2(a,b), lss ARG2(a,b), lss ARG2(b,a))
+#define LLDT(a) CHOICE(lldt a, lldt a, lldt a)
+#define LMSW(a) CHOICE(lmsw a, lmsw a, lmsw a)
+#define LOCK CHOICE(lock, lock, lock)
+#define LODS_L CHOICE(lodsl, lodsl, _LTOG lods)
+#define LODS_W CHOICE(lodsw, lodsw, _WTOG lods)
+#define LODS_B CHOICE(lodsb, lodsb, lodsb)
+#define LOOP(a) CHOICE(loop a, loop a, loop a)
+#define LOOPE(a) CHOICE(loope a, loope a, loope a)
+#define LOOPZ(a) CHOICE(loopz a, loopz a, loopz a)
+#define LOOPNE(a) CHOICE(loopne a, loopne a, loopne a)
+#define LOOPNZ(a) CHOICE(loopnz a, loopnz a, loopnz a)
+#if !defined(_REAL_MODE) && !defined(_V86_MODE)
+#define LSL(a, b) CHOICE(lsl ARG2(a,b), lsl ARG2(a,b), lsl ARG2(b,a))
+#endif
+#define LTR(a) CHOICE(ltr a, ltr a, ltr a)
+#define MOV_SR(a, b) CHOICE(movw ARG2(a,b), mov ARG2(a,b), mov ARG2(b,a))
+#define MOV_L(a, b) CHOICE(movl ARG2(a,b), movl ARG2(a,b), _LTOG mov ARG2(b,a))
+#define MOV_W(a, b) CHOICE(movw ARG2(a,b), movw ARG2(a,b), _WTOG mov ARG2(b,a))
+#define MOV_B(a, b) CHOICE(movb ARG2(a,b), movb ARG2(a,b), movb ARG2(b,a))
+#define MOVS_L CHOICE(movsl, movsl, _LTOG movs)
+#define MOVS_W CHOICE(movsw, movsw, _WTOG movs)
+#define MOVS_B CHOICE(movsb, movsb, movsb)
+#define MOVSX_BL(a, b) CHOICE(movsbl ARG2(a,b), movsbl ARG2(a,b), movsx ARG2(b,a))
+#define MOVSX_BW(a, b) CHOICE(movsbw ARG2(a,b), movsbw ARG2(a,b), movsx ARG2(b,a))
+#define MOVSX_WL(a, b) CHOICE(movswl ARG2(a,b), movswl ARG2(a,b), movsx ARG2(b,a))
+#define MOVZX_BL(a, b) CHOICE(movzbl ARG2(a,b), movzbl ARG2(a,b), movzx ARG2(b,a))
+#define MOVZX_BW(a, b) CHOICE(movzbw ARG2(a,b), movzbw ARG2(a,b), movzx ARG2(b,a))
+#define MOVZX_WL(a, b) CHOICE(movzwl ARG2(a,b), movzwl ARG2(a,b), movzx ARG2(b,a))
+#define MUL_L(a) CHOICE(mull a, mull a, _LTOG mul a)
+#define MUL_W(a) CHOICE(mulw a, mulw a, _WTOG mul a)
+#define MUL_B(a) CHOICE(mulb a, mulb a, mulb a)
+#define NEG_L(a) CHOICE(negl a, negl a, _LTOG neg a)
+#define NEG_W(a) CHOICE(negw a, negw a, _WTOG neg a)
+#define NEG_B(a) CHOICE(negb a, negb a, negb a)
+#define NOP CHOICE(nop, nop, nop)
+#define NOT_L(a) CHOICE(notl a, notl a, _LTOG not a)
+#define NOT_W(a) CHOICE(notw a, notw a, _WTOG not a)
+#define NOT_B(a) CHOICE(notb a, notb a, notb a)
+#define OR_L(a,b) CHOICE(orl ARG2(a,b), orl ARG2(a,b), _LTOG or ARG2(b,a))
+#define OR_W(a,b) CHOICE(orw ARG2(a,b), orw ARG2(a,b), _WTOG or ARG2(b,a))
+#define OR_B(a,b) CHOICE(orb ARG2(a,b), orb ARG2(a,b), orb ARG2(b,a))
+#define OUT_L CHOICE(outl (DX), outl ARG2(EAX,DX), _LTOG out DX)
+#define OUT_W CHOICE(outw (DX), outw ARG2(AX,DX), _WTOG out DX)
+#define OUT_B CHOICE(outb (DX), outb ARG2(AL,DX), outb DX)
+/* Please AS code writer: use the following ONLY, if you refer to ports<256
+ * directly, but not in OUT1_W(DX), for instance, even if OUT1_ looks nicer
+ */
+#define OUT1_L(a) CHOICE(outl (a), outl ARG2(EAX,a), _LTOG out a)
+#define OUT1_W(a) CHOICE(outw (a), outw ARG2(AX,a), _WTOG out a)
+#define OUT1_B(a) CHOICE(outb (a), outb ARG2(AL,a), outb a)
+#define OUTS_L CHOICE(outsl, outsl, _LTOG outs)
+#define OUTS_W CHOICE(outsw, outsw, _WTOG outs)
+#define OUTS_B CHOICE(outsb, outsb, outsb)
+#define POP_SR(a) CHOICE(pop a, pop a, pop a)
+#define POP_L(a) CHOICE(popl a, popl a, _LTOG pop a)
+#define POP_W(a) CHOICE(popw a, popw a, _WTOG pop a)
+#define POPA_L CHOICE(popal, popal, _LTOG popa)
+#define POPA_W CHOICE(popaw, popaw, _WTOG popa)
+#define POPF_L CHOICE(popfl, popfl, _LTOG popf)
+#define POPF_W CHOICE(popfw, popfw, _WTOG popf)
+#define PUSH_SR(a) CHOICE(push a, push a, push a)
+#define PUSH_L(a) CHOICE(pushl a, pushl a, _LTOG push a)
+#define PUSH_W(a) CHOICE(pushw a, pushw a, _WTOG push a)
+#define PUSH_B(a) CHOICE(push a, pushb a, push a)
+#define PUSHA_L CHOICE(pushal, pushal, _LTOG pusha)
+#define PUSHA_W CHOICE(pushaw, pushaw, _WTOG pusha)
+#define PUSHF_L CHOICE(pushfl, pushfl, _LTOG pushf)
+#define PUSHF_W CHOICE(pushfw, pushfw, _WTOG pushf)
+#define RCL_L(a, b) CHOICE(rcll ARG2(a,b), rcll ARG2(a,b), _LTOG rcl ARG2(b,a))
+#define RCL_W(a, b) CHOICE(rclw ARG2(a,b), rclw ARG2(a,b), _WTOG rcl ARG2(b,a))
+#define RCL_B(a, b) CHOICE(rclb ARG2(a,b), rclb ARG2(a,b), rclb ARG2(b,a))
+#define RCR_L(a, b) CHOICE(rcrl ARG2(a,b), rcrl ARG2(a,b), _LTOG rcr ARG2(b,a))
+#define RCR_W(a, b) CHOICE(rcrw ARG2(a,b), rcrw ARG2(a,b), _WTOG rcr ARG2(b,a))
+#define RCR_B(a, b) CHOICE(rcrb ARG2(a,b), rcrb ARG2(a,b), rcrb ARG2(b,a))
+#define ROL_L(a, b) CHOICE(roll ARG2(a,b), roll ARG2(a,b), _LTOG rol ARG2(b,a))
+#define ROL_W(a, b) CHOICE(rolw ARG2(a,b), rolw ARG2(a,b), _WTOG rol ARG2(b,a))
+#define ROL_B(a, b) CHOICE(rolb ARG2(a,b), rolb ARG2(a,b), rolb ARG2(b,a))
+#define ROR_L(a, b) CHOICE(rorl ARG2(a,b), rorl ARG2(a,b), _LTOG ror ARG2(b,a))
+#define ROR_W(a, b) CHOICE(rorw ARG2(a,b), rorw ARG2(a,b), _WTOG ror ARG2(b,a))
+#define ROR_B(a, b) CHOICE(rorb ARG2(a,b), rorb ARG2(a,b), rorb ARG2(b,a))
+#define REP CHOICE(rep ;, rep ;, repe)
+#define REPE CHOICE(repz ;, repe ;, repe)
+#define REPNE CHOICE(repnz ;, repne ;, repne)
+#define REPNZ REPNE
+#define REPZ REPE
+#define RET CHOICE(ret, ret, ret)
+#define SAHF CHOICE(sahf, sahf, sahf)
+#define SAL_L(a, b) CHOICE(sall ARG2(a,b), sall ARG2(a,b), _LTOG sal ARG2(b,a))
+#define SAL_W(a, b) CHOICE(salw ARG2(a,b), salw ARG2(a,b), _WTOG sal ARG2(b,a))
+#define SAL_B(a, b) CHOICE(salb ARG2(a,b), salb ARG2(a,b), salb ARG2(b,a))
+#define SAR_L(a, b) CHOICE(sarl ARG2(a,b), sarl ARG2(a,b), _LTOG sar ARG2(b,a))
+#define SAR_W(a, b) CHOICE(sarw ARG2(a,b), sarw ARG2(a,b), _WTOG sar ARG2(b,a))
+#define SAR_B(a, b) CHOICE(sarb ARG2(a,b), sarb ARG2(a,b), sarb ARG2(b,a))
+#define SBB_L(a, b) CHOICE(sbbl ARG2(a,b), sbbl ARG2(a,b), _LTOG sbb ARG2(b,a))
+#define SBB_W(a, b) CHOICE(sbbw ARG2(a,b), sbbw ARG2(a,b), _WTOG sbb ARG2(b,a))
+#define SBB_B(a, b) CHOICE(sbbb ARG2(a,b), sbbb ARG2(a,b), sbbb ARG2(b,a))
+#define SCAS_L CHOICE(scasl, scasl, _LTOG scas)
+#define SCAS_W CHOICE(scasw, scasw, _WTOG scas)
+#define SCAS_B CHOICE(scasb, scasb, scasb)
+#define SETA(a) CHOICE(seta a, seta a, seta a)
+#define SETAE(a) CHOICE(setae a, setae a, setae a)
+#define SETB(a) CHOICE(setb a, setb a, setb a)
+#define SETBE(a) CHOICE(setbe a, setbe a, setbe a)
+#define SETC(a) CHOICE(setc a, setb a, setb a)
+#define SETE(a) CHOICE(sete a, sete a, sete a)
+#define SETG(a) CHOICE(setg a, setg a, setg a)
+#define SETGE(a) CHOICE(setge a, setge a, setge a)
+#define SETL(a) CHOICE(setl a, setl a, setl a)
+#define SETLE(a) CHOICE(setle a, setle a, setle a)
+#define SETNA(a) CHOICE(setna a, setna a, setna a)
+#define SETNAE(a) CHOICE(setnae a, setnae a, setnae a)
+#define SETNB(a) CHOICE(setnb a, setnb a, setnb a)
+#define SETNBE(a) CHOICE(setnbe a, setnbe a, setnbe a)
+#define SETNC(a) CHOICE(setnc a, setnb a, setnb a)
+#define SETNE(a) CHOICE(setne a, setne a, setne a)
+#define SETNG(a) CHOICE(setng a, setng a, setng a)
+#define SETNGE(a) CHOICE(setnge a, setnge a, setnge a)
+#define SETNL(a) CHOICE(setnl a, setnl a, setnl a)
+#define SETNLE(a) CHOICE(setnle a, setnle a, setnle a)
+#define SETNO(a) CHOICE(setno a, setno a, setno a)
+#define SETNP(a) CHOICE(setnp a, setnp a, setnp a)
+#define SETNS(a) CHOICE(setns a, setns a, setna a)
+#define SETNZ(a) CHOICE(setnz a, setnz a, setnz a)
+#define SETO(a) CHOICE(seto a, seto a, seto a)
+#define SETP(a) CHOICE(setp a, setp a, setp a)
+#define SETPE(a) CHOICE(setpe a, setpe a, setpe a)
+#define SETPO(a) CHOICE(setpo a, setpo a, setpo a)
+#define SETS(a) CHOICE(sets a, sets a, seta a)
+#define SETZ(a) CHOICE(setz a, setz a, setz a)
+#define SGDT(a) CHOICE(sgdt a, sgdt a, sgdt a)
+#define SIDT(a) CHOICE(sidt a, sidt a, sidt a)
+#define SHL_L(a, b) CHOICE(shll ARG2(a,b), shll ARG2(a,b), _LTOG shl ARG2(b,a))
+#define SHL_W(a, b) CHOICE(shlw ARG2(a,b), shlw ARG2(a,b), _WTOG shl ARG2(b,a))
+#define SHL_B(a, b) CHOICE(shlb ARG2(a,b), shlb ARG2(a,b), shlb ARG2(b,a))
+#define SHLD_L(a,b,c) CHOICE(shldl ARG3(a,b,c), shldl ARG3(a,b,c), _LTOG shld ARG3(c,b,a))
+#define SHLD2_L(a,b) CHOICE(shldl ARG2(a,b), shldl ARG3(CL,a,b), _LTOG shld ARG3(b,a,CL))
+#define SHLD_W(a,b,c) CHOICE(shldw ARG3(a,b,c), shldw ARG3(a,b,c), _WTOG shld ARG3(c,b,a))
+#define SHLD2_W(a,b) CHOICE(shldw ARG2(a,b), shldw ARG3(CL,a,b), _WTOG shld ARG3(b,a,CL))
+#define SHR_L(a, b) CHOICE(shrl ARG2(a,b), shrl ARG2(a,b), _LTOG shr ARG2(b,a))
+#define SHR_W(a, b) CHOICE(shrw ARG2(a,b), shrw ARG2(a,b), _WTOG shr ARG2(b,a))
+#define SHR_B(a, b) CHOICE(shrb ARG2(a,b), shrb ARG2(a,b), shrb ARG2(b,a))
+#define SHRD_L(a,b,c) CHOICE(shrdl ARG3(a,b,c), shrdl ARG3(a,b,c), _LTOG shrd ARG3(c,b,a))
+#define SHRD2_L(a,b) CHOICE(shrdl ARG2(a,b), shrdl ARG3(CL,a,b), _LTOG shrd ARG3(b,a,CL))
+#define SHRD_W(a,b,c) CHOICE(shrdw ARG3(a,b,c), shrdw ARG3(a,b,c), _WTOG shrd ARG3(c,b,a))
+#define SHRD2_W(a,b) CHOICE(shrdw ARG2(a,b), shrdw ARG3(CL,a,b), _WTOG shrd ARG3(b,a,CL))
+#define SLDT(a) CHOICE(sldt a, sldt a, sldt a)
+#define SMSW(a) CHOICE(smsw a, smsw a, smsw a)
+#define STC CHOICE(stc, stc, stc)
+#define STD CHOICE(std, std, std)
+#define STI CHOICE(sti, sti, sti)
+#define STOS_L CHOICE(stosl, stosl, _LTOG stos)
+#define STOS_W CHOICE(stosw, stosw, _WTOG stos)
+#define STOS_B CHOICE(stosb, stosb, stosb)
+#define STR(a) CHOICE(str a, str a, str a)
+#define SUB_L(a, b) CHOICE(subl ARG2(a,b), subl ARG2(a,b), _LTOG sub ARG2(b,a))
+#define SUB_W(a, b) CHOICE(subw ARG2(a,b), subw ARG2(a,b), _WTOG sub ARG2(b,a))
+#define SUB_B(a, b) CHOICE(subb ARG2(a,b), subb ARG2(a,b), subb ARG2(b,a))
+#define TEST_L(a, b) CHOICE(testl ARG2(a,b), testl ARG2(a,b), _LTOG test ARG2(b,a))
+#define TEST_W(a, b) CHOICE(testw ARG2(a,b), testw ARG2(a,b), _WTOG test ARG2(b,a))
+#define TEST_B(a, b) CHOICE(testb ARG2(a,b), testb ARG2(a,b), testb ARG2(b,a))
+#define VERR(a) CHOICE(verr a, verr a, verr a)
+#define VERW(a) CHOICE(verw a, verw a, verw a)
+#define WAIT CHOICE(wait, wait, wait)
+#define XCHG_L(a, b) CHOICE(xchgl ARG2(a,b), xchgl ARG2(a,b), _LTOG xchg ARG2(b,a))
+#define XCHG_W(a, b) CHOICE(xchgw ARG2(a,b), xchgw ARG2(a,b), _WTOG xchg ARG2(b,a))
+#define XCHG_B(a, b) CHOICE(xchgb ARG2(a,b), xchgb ARG2(a,b), xchgb ARG2(b,a))
+#define XLAT CHOICE(xlat, xlat, xlat)
+#define XOR_L(a, b) CHOICE(xorl ARG2(a,b), xorl ARG2(a,b), _LTOG xor ARG2(b,a))
+#define XOR_W(a, b) CHOICE(xorw ARG2(a,b), xorw ARG2(a,b), _WTOG xor ARG2(b,a))
+#define XOR_B(a, b) CHOICE(xorb ARG2(a,b), xorb ARG2(a,b), xorb ARG2(b,a))
+
+
+/* Floating Point Instructions */
+#define F2XM1 CHOICE(f2xm1, f2xm1, f2xm1)
+#define FABS CHOICE(fabs, fabs, fabs)
+#define FADD_D(a) CHOICE(faddl a, faddl a, faddd a)
+#define FADD_S(a) CHOICE(fadds a, fadds a, fadds a)
+#define FADD2(a, b) CHOICE(fadd ARG2(a,b), fadd ARG2(a,b), fadd ARG2(b,a))
+#define FADDP(a, b) CHOICE(faddp ARG2(a,b), faddp ARG2(a,b), faddp ARG2(b,a))
+#define FIADD_L(a) CHOICE(fiaddl a, fiaddl a, fiaddl a)
+#define FIADD_W(a) CHOICE(fiadd a, fiadds a, fiadds a)
+#define FBLD(a) CHOICE(fbld a, fbld a, fbld a)
+#define FBSTP(a) CHOICE(fbstp a, fbstp a, fbstp a)
+#define FCHS CHOICE(fchs, fchs, fchs)
+#define FCLEX CHOICE(fclex, wait; fnclex, wait; fclex)
+#define FNCLEX CHOICE(fnclex, fnclex, fclex)
+#define FCOM(a) CHOICE(fcom a, fcom a, fcom a)
+#define FCOM_D(a) CHOICE(fcoml a, fcoml a, fcomd a)
+#define FCOM_S(a) CHOICE(fcoms a, fcoms a, fcoms a)
+#define FCOMP(a) CHOICE(fcomp a, fcomp a, fcomp a)
+#define FCOMP_D(a) CHOICE(fcompl a, fcompl a, fcompd a)
+#define FCOMP_S(a) CHOICE(fcomps a, fcomps a, fcomps a)
+#define FCOMPP CHOICE(fcompp, fcompp, fcompp)
+#define FCOS CHOICE(fcos, fcos, fcos)
+#define FDECSTP CHOICE(fdecstp, fdecstp, fdecstp)
+#define FDIV_D(a) CHOICE(fdivl a, fdivl a, fdivd a)
+#define FDIV_S(a) CHOICE(fdivs a, fdivs a, fdivs a)
+#define FDIV2(a, b) CHOICE(fdiv ARG2(a,b), fdiv ARG2(a,b), fdiv ARG2(b,a))
+#define FDIVP(a, b) CHOICE(fdivp ARG2(a,b), fdivp ARG2(a,b), fdivp ARG2(b,a))
+#define FIDIV_L(a) CHOICE(fidivl a, fidivl a, fidivl a)
+#define FIDIV_W(a) CHOICE(fidiv a, fidivs a, fidivs a)
+#define FDIVR_D(a) CHOICE(fdivrl a, fdivrl a, fdivrd a)
+#define FDIVR_S(a) CHOICE(fdivrs a, fdivrs a, fdivrs a)
+#define FDIVR2(a, b) CHOICE(fdivr ARG2(a,b), fdivr ARG2(a,b), fdivr ARG2(b,a))
+#define FDIVRP(a, b) CHOICE(fdivrp ARG2(a,b), fdivrp ARG2(a,b), fdivrp ARG2(b,a))
+#define FIDIVR_L(a) CHOICE(fidivrl a, fidivrl a, fidivrl a)
+#define FIDIVR_W(a) CHOICE(fidivr a, fidivrs a, fidivrs a)
+#define FFREE(a) CHOICE(ffree a, ffree a, ffree a)
+#define FICOM_L(a) CHOICE(ficoml a, ficoml a, ficoml a)
+#define FICOM_W(a) CHOICE(ficom a, ficoms a, ficoms a)
+#define FICOMP_L(a) CHOICE(ficompl a, ficompl a, ficompl a)
+#define FICOMP_W(a) CHOICE(ficomp a, ficomps a, ficomps a)
+#define FILD_Q(a) CHOICE(fildll a, fildq a, fildq a)
+#define FILD_L(a) CHOICE(fildl a, fildl a, fildl a)
+#define FILD_W(a) CHOICE(fild a, filds a, filds a)
+#define FINCSTP CHOICE(fincstp, fincstp, fincstp)
+#define FINIT CHOICE(finit, wait; fninit, wait; finit)
+#define FNINIT CHOICE(fninit, fninit, finit)
+#define FIST_L(a) CHOICE(fistl a, fistl a, fistl a)
+#define FIST_W(a) CHOICE(fist a, fists a, fists a)
+#define FISTP_Q(a) CHOICE(fistpll a, fistpq a, fistpq a)
+#define FISTP_L(a) CHOICE(fistpl a, fistpl a, fistpl a)
+#define FISTP_W(a) CHOICE(fistp a, fistps a, fistps a)
+#define FLD_X(a) CHOICE(fldt a, fldt a, fldx a) /* 80 bit data type! */
+#define FLD_D(a) CHOICE(fldl a, fldl a, fldd a)
+#define FLD_S(a) CHOICE(flds a, flds a, flds a)
+#define FLD1 CHOICE(fld1, fld1, fld1)
+#define FLDL2T CHOICE(fldl2t, fldl2t, fldl2t)
+#define FLDL2E CHOICE(fldl2e, fldl2e, fldl2e)
+#define FLDPI CHOICE(fldpi, fldpi, fldpi)
+#define FLDLG2 CHOICE(fldlg2, fldlg2, fldlg2)
+#define FLDLN2 CHOICE(fldln2, fldln2, fldln2)
+#define FLDZ CHOICE(fldz, fldz, fldz)
+#define FLDCW(a) CHOICE(fldcw a, fldcw a, fldcw a)
+#define FLDENV(a) CHOICE(fldenv a, fldenv a, fldenv a)
+#define FMUL_S(a) CHOICE(fmuls a, fmuls a, fmuls a)
+#define FMUL_D(a) CHOICE(fmull a, fmull a, fmuld a)
+#define FMUL2(a, b) CHOICE(fmul ARG2(a,b), fmul ARG2(a,b), fmul ARG2(b,a))
+#define FMULP(a, b) CHOICE(fmulp ARG2(a,b), fmulp ARG2(a,b), fmulp ARG2(b,a))
+#define FIMUL_L(a) CHOICE(fimull a, fimull a, fimull a)
+#define FIMUL_W(a) CHOICE(fimul a, fimuls a, fimuls a)
+#define FNOP CHOICE(fnop, fnop, fnop)
+#define FPATAN CHOICE(fpatan, fpatan, fpatan)
+#define FPREM CHOICE(fprem, fprem, fprem)
+#define FPREM1 CHOICE(fprem1, fprem1, fprem1)
+#define FPTAN CHOICE(fptan, fptan, fptan)
+#define FRNDINT CHOICE(frndint, frndint, frndint)
+#define FRSTOR(a) CHOICE(frstor a, frstor a, frstor a)
+#define FSAVE(a) CHOICE(fsave a, wait; fnsave a, wait; fsave a)
+#define FNSAVE(a) CHOICE(fnsave a, fnsave a, fsave a)
+#define FSCALE CHOICE(fscale, fscale, fscale)
+#define FSIN CHOICE(fsin, fsin, fsin)
+#define FSINCOS CHOICE(fsincos, fsincos, fsincos)
+#define FSQRT CHOICE(fsqrt, fsqrt, fsqrt)
+#define FST_D(a) CHOICE(fstl a, fstl a, fstd a)
+#define FST_S(a) CHOICE(fsts a, fsts a, fsts a)
+#define FSTP_X(a) CHOICE(fstpt a, fstpt a, fstpx a)
+#define FSTP_D(a) CHOICE(fstpl a, fstpl a, fstpd a)
+#define FSTP_S(a) CHOICE(fstps a, fstps a, fstps a)
+#define FSTP(a) CHOICE(fstp a, fstp a, fstp a)
+#define FSTCW(a) CHOICE(fstcw a, wait; fnstcw a, wait; fstcw a)
+#define FNSTCW(a) CHOICE(fnstcw a, fnstcw a, fstcw a)
+#define FSTENV(a) CHOICE(fstenv a, wait; fnstenv a, fstenv a)
+#define FNSTENV(a) CHOICE(fnstenv a, fnstenv a, fstenv a)
+#define FSTSW(a) CHOICE(fstsw a, wait; fnstsw a, wait; fstsw a)
+#define FNSTSW(a) CHOICE(fnstsw a, fnstsw a, fstsw a)
+#define FSUB_S(a) CHOICE(fsubs a, fsubs a, fsubs a)
+#define FSUB_D(a) CHOICE(fsubl a, fsubl a, fsubd a)
+#define FSUB2(a, b) CHOICE(fsub ARG2(a,b), fsub ARG2(a,b), fsub ARG2(b,a))
+#define FSUBP(a, b) CHOICE(fsubp ARG2(a,b), fsubp ARG2(a,b), fsubp ARG2(b,a))
+#define FISUB_L(a) CHOICE(fisubl a, fisubl a, fisubl a)
+#define FISUB_W(a) CHOICE(fisub a, fisubs a, fisubs a)
+#define FSUBR_S(a) CHOICE(fsubrs a, fsubrs a, fsubrs a)
+#define FSUBR_D(a) CHOICE(fsubrl a, fsubrl a, fsubrd a)
+#define FSUBR2(a, b) CHOICE(fsubr ARG2(a,b), fsubr ARG2(a,b), fsubr ARG2(b,a))
+#define FSUBRP(a, b) CHOICE(fsubrp ARG2(a,b), fsubrp ARG2(a,b), fsubrp ARG2(b,a))
+#define FISUBR_L(a) CHOICE(fisubrl a, fisubrl a, fisubrl a)
+#define FISUBR_W(a) CHOICE(fisubr a, fisubrs a, fisubrs a)
+#define FTST CHOICE(ftst, ftst, ftst)
+#define FUCOM(a) CHOICE(fucom a, fucom a, fucom a)
+#define FUCOMP(a) CHOICE(fucomp a, fucomp a, fucomp a)
+#define FUCOMPP CHOICE(fucompp, fucompp, fucompp)
+#define FWAIT CHOICE(wait, wait, wait)
+#define FXAM CHOICE(fxam, fxam, fxam)
+#define FXCH(a) CHOICE(fxch a, fxch a, fxch a)
+#define FXTRACT CHOICE(fxtract, fxtract, fxtract)
+#define FYL2X CHOICE(fyl2x, fyl2x, fyl2x)
+#define FYL2XP1 CHOICE(fyl2xp1, fyl2xp1, fyl2xp1)
+
+/* New instructions */
+#define CPUID CHOICE(D_BYTE ARG2(15, 162), cpuid, D_BYTE ARG2(15, 162))
+#define RDTSC CHOICE(D_BYTE ARG2(15, 49), rdtsc, D_BYTE ARG2(15, 49))
+
+#else /* NASM_ASSEMBLER || MASM_ASSEMBLER is defined */
+
+ /****************************************/
+ /* */
+ /* Intel style assemblers. */
+ /* (NASM and MASM) */
+ /* */
+ /****************************************/
+
+#define P_EAX EAX
+#define L_EAX EAX
+#define W_AX AX
+#define B_AH AH
+#define B_AL AL
+
+#define P_EBX EBX
+#define L_EBX EBX
+#define W_BX BX
+#define B_BH BH
+#define B_BL BL
+
+#define P_ECX ECX
+#define L_ECX ECX
+#define W_CX CX
+#define B_CH CH
+#define B_CL CL
+
+#define P_EDX EDX
+#define L_EDX EDX
+#define W_DX DX
+#define B_DH DH
+#define B_DL DL
+
+#define P_EBP EBP
+#define L_EBP EBP
+#define W_BP BP
+
+#define P_ESI ESI
+#define L_ESI ESI
+#define W_SI SI
+
+#define P_EDI EDI
+#define L_EDI EDI
+#define W_DI DI
+
+#define P_ESP ESP
+#define L_ESP ESP
+#define W_SP SP
+
+#define W_CS CS
+#define W_SS SS
+#define W_DS DS
+#define W_ES ES
+#define W_FS FS
+#define W_GS GS
+
+#define X_ST ST
+#define D_ST ST
+#define L_ST ST
+
+#define P_MM0 mm0
+#define P_MM1 mm1
+#define P_MM2 mm2
+#define P_MM3 mm3
+#define P_MM4 mm4
+#define P_MM5 mm5
+#define P_MM6 mm6
+#define P_MM7 mm7
+
+#define P_XMM0 xmm0
+#define P_XMM1 xmm1
+#define P_XMM2 xmm2
+#define P_XMM3 xmm3
+#define P_XMM4 xmm4
+#define P_XMM5 xmm5
+#define P_XMM6 xmm6
+#define P_XMM7 xmm7
+
+#define CONCAT(x, y) x ## y
+#define CONCAT3(x, y, z) x ## y ## z
+
+#if defined(NASM_ASSEMBLER)
+
+#define ST(n) st ## n
+#define ST0 st0
+
+#define TBYTE_PTR tword
+#define QWORD_PTR qword
+#define DWORD_PTR dword
+#define WORD_PTR word
+#define BYTE_PTR byte
+
+#define OFFSET
+
+#define GLOBL GLOBAL
+#define ALIGNTEXT32 ALIGN 32
+#define ALIGNTEXT16 ALIGN 16
+#define ALIGNTEXT8 ALIGN 8
+#define ALIGNTEXT4 ALIGN 4
+#define ALIGNTEXT2 ALIGN 2
+#define ALIGNTEXT32ifNOP ALIGN 32
+#define ALIGNTEXT16ifNOP ALIGN 16
+#define ALIGNTEXT8ifNOP ALIGN 8
+#define ALIGNTEXT4ifNOP ALIGN 4
+#define ALIGNDATA32 ALIGN 32
+#define ALIGNDATA16 ALIGN 16
+#define ALIGNDATA8 ALIGN 8
+#define ALIGNDATA4 ALIGN 4
+#define ALIGNDATA2 ALIGN 2
+#define FILE(s)
+#define STRING(s) db s
+#define D_LONG dd
+#define D_WORD dw
+#define D_BYTE db
+/* #define SPACE */
+/* #define COMM */
+#if defined(__WATCOMC__)
+SECTION _TEXT public align=16 class=CODE use32 flat
+SECTION _DATA public align=16 class=DATA use32 flat
+#define SEG_TEXT SECTION _TEXT
+#define SEG_DATA SECTION _DATA
+#define SEG_BSS SECTION .bss
+#else
+#define SEG_DATA SECTION .data
+#define SEG_TEXT SECTION .text
+#define SEG_BSS SECTION .bss
+#endif
+
+#define D_SPACE(n) db n REP 0
+
+#define AS_BEGIN
+
+/* Jcc's should be handled better than this... */
+#define NEAR near
+
+#else /* MASM */
+
+#define TBYTE_PTR tbyte ptr
+#define QWORD_PTR qword ptr
+#define DWORD_PTR dword ptr
+#define WORD_PTR word ptr
+#define BYTE_PTR byte ptr
+
+#define OFFSET offset
+
+#define GLOBL GLOBAL
+#define ALIGNTEXT32 ALIGN 32
+#define ALIGNTEXT16 ALIGN 16
+#define ALIGNTEXT8 ALIGN 8
+#define ALIGNTEXT4 ALIGN 4
+#define ALIGNTEXT2 ALIGN 2
+#define ALIGNTEXT32ifNOP ALIGN 32
+#define ALIGNTEXT16ifNOP ALIGN 16
+#define ALIGNTEXT8ifNOP ALIGN 8
+#define ALIGNTEXT4ifNOP ALIGN 4
+#define ALIGNDATA32 ALIGN 32
+#define ALIGNDATA16 ALIGN 16
+#define ALIGNDATA8 ALIGN 8
+#define ALIGNDATA4 ALIGN 4
+#define ALIGNDATA2 ALIGN 2
+#define FILE(s)
+#define STRING(s) db s
+#define D_LONG dd
+#define D_WORD dw
+#define D_BYTE db
+/* #define SPACE */
+/* #define COMM */
+#define SEG_DATA .DATA
+#define SEG_TEXT .CODE
+#define SEG_BSS .DATA
+
+#define D_SPACE(n) db n REP 0
+
+#define AS_BEGIN
+
+#define NEAR
+
+#endif
+
+#if defined(Lynx) || (defined(SYSV) || defined(SVR4)) \
+ || (defined(__linux__) || defined(__OS2ELF__)) && defined(__ELF__) \
+ || defined(__FreeBSD__) && __FreeBSD__ >= 3
+#define GLNAME(a) a
+#else
+#define GLNAME(a) CONCAT(_, a)
+#endif
+
+/*
+ * Addressing Modes
+ */
+
+/* Immediate Mode */
+#define P_ADDR(a) OFFSET a
+#define X_ADDR(a) OFFSET a
+#define D_ADDR(a) OFFSET a
+#define L_ADDR(a) OFFSET a
+#define W_ADDR(a) OFFSET a
+#define B_ADDR(a) OFFSET a
+
+#define P_CONST(a) a
+#define X_CONST(a) a
+#define D_CONST(a) a
+#define L_CONST(a) a
+#define W_CONST(a) a
+#define B_CONST(a) a
+
+/* Indirect Mode */
+#ifdef NASM_ASSEMBLER
+#define P_CONTENT(a) [a]
+#define X_CONTENT(a) TBYTE_PTR [a]
+#define D_CONTENT(a) QWORD_PTR [a]
+#define L_CONTENT(a) DWORD_PTR [a]
+#define W_CONTENT(a) WORD_PTR [a]
+#define B_CONTENT(a) BYTE_PTR [a]
+#else
+#define P_CONTENT(a) a
+#define X_CONTENT(a) TBYTE_PTR a
+#define D_CONTENT(a) QWORD_PTR a
+#define L_CONTENT(a) DWORD_PTR a
+#define W_CONTENT(a) WORD_PTR a
+#define B_CONTENT(a) BYTE_PTR a
+#endif
+
+/* Register a indirect */
+#define P_REGIND(a) [a]
+#define X_REGIND(a) TBYTE_PTR [a]
+#define D_REGIND(a) QWORD_PTR [a]
+#define L_REGIND(a) DWORD_PTR [a]
+#define W_REGIND(a) WORD_PTR [a]
+#define B_REGIND(a) BYTE_PTR [a]
+
+/* Register b indirect plus displacement a */
+#define P_REGOFF(a, b) [b + a]
+#define X_REGOFF(a, b) TBYTE_PTR [b + a]
+#define D_REGOFF(a, b) QWORD_PTR [b + a]
+#define L_REGOFF(a, b) DWORD_PTR [b + a]
+#define W_REGOFF(a, b) WORD_PTR [b + a]
+#define B_REGOFF(a, b) BYTE_PTR [b + a]
+
+/* Reg indirect Base + Index + Displacement - this is mainly for 16-bit mode
+ * which has no scaling
+ */
+#define P_REGBID(b, i, d) [b + i + d]
+#define X_REGBID(b, i, d) TBYTE_PTR [b + i + d]
+#define D_REGBID(b, i, d) QWORD_PTR [b + i + d]
+#define L_REGBID(b, i, d) DWORD_PTR [b + i + d]
+#define W_REGBID(b, i, d) WORD_PTR [b + i + d]
+#define B_REGBID(b, i, d) BYTE_PTR [b + i + d]
+
+/* Reg indirect Base + (Index * Scale) */
+#define P_REGBIS(b, i, s) [b + i * s]
+#define X_REGBIS(b, i, s) TBYTE_PTR [b + i * s]
+#define D_REGBIS(b, i, s) QWORD_PTR [b + i * s]
+#define L_REGBIS(b, i, s) DWORD_PTR [b + i * s]
+#define W_REGBIS(b, i, s) WORD_PTR [b + i * s]
+#define B_REGBIS(b, i, s) BYTE_PTR [b + i * s]
+
+/* Reg indirect Base + (Index * Scale) + Displacement */
+#define P_REGBISD(b, i, s, d) [b + i * s + d]
+#define X_REGBISD(b, i, s, d) TBYTE_PTR [b + i * s + d]
+#define D_REGBISD(b, i, s, d) QWORD_PTR [b + i * s + d]
+#define L_REGBISD(b, i, s, d) DWORD_PTR [b + i * s + d]
+#define W_REGBISD(b, i, s, d) WORD_PTR [b + i * s + d]
+#define B_REGBISD(b, i, s, d) BYTE_PTR [b + i * s + d]
+
+/* Displaced Scaled Index: */
+#define P_REGDIS(d, i, s) [i * s + d]
+#define X_REGDIS(d, i, s) TBYTE_PTR [i * s + d]
+#define D_REGDIS(d, i, s) QWORD_PTR [i * s + d]
+#define L_REGDIS(d, i, s) DWORD_PTR [i * s + d]
+#define W_REGDIS(d, i, s) WORD_PTR [i * s + d]
+#define B_REGDIS(d, i, s) BYTE_PTR [i * s + d]
+
+/* Indexed Base: */
+#define P_REGBI(b, i) [b + i]
+#define X_REGBI(b, i) TBYTE_PTR [b + i]
+#define D_REGBI(b, i) QWORD_PTR [b + i]
+#define L_REGBI(b, i) DWORD_PTR [b + i]
+#define W_REGBI(b, i) WORD_PTR [b + i]
+#define B_REGBI(b, i) BYTE_PTR [b + i]
+
+/* Displaced Base: */
+#define P_REGDB(d, b) [b + d]
+#define X_REGDB(d, b) TBYTE_PTR [b + d]
+#define D_REGDB(d, b) QWORD_PTR [b + d]
+#define L_REGDB(d, b) DWORD_PTR [b + d]
+#define W_REGDB(d, b) WORD_PTR [b + d]
+#define B_REGDB(d, b) BYTE_PTR [b + d]
+
+/* Variable indirect: */
+#define VARINDIRECT(var) [var]
+
+/* Use register contents as jump/call target: */
+#define CODEPTR(reg) P_(reg)
+
+/*
+ * Redefine assembler commands
+ */
+
+#define P_(a) P_ ## a
+#define X_(a) X_ ## a
+#define D_(a) D_ ## a
+#define SR_(a) W_ ## a
+#define S_(a) L_ ## a
+#define L_(a) L_ ## a
+#define W_(a) W_ ## a
+#define B_(a) B_ ## a
+
+#define AAA aaa
+#define AAD aad
+#define AAM aam
+#define AAS aas
+#define ADC_L(a, b) adc L_(b), L_(a)
+#define ADC_W(a, b) adc W_(b), W_(a)
+#define ADC_B(a, b) adc B_(b), B_(a)
+#define ADD_L(a, b) add L_(b), L_(a)
+#define ADD_W(a, b) add W_(b), W_(a)
+#define ADD_B(a, b) add B_(b), B_(a)
+#define AND_L(a, b) and L_(b), L_(a)
+#define AND_W(a, b) and W_(b), W_(a)
+#define AND_B(a, b) and B_(b), B_(a)
+#define ARPL(a,b) arpl W_(b), a
+#define BOUND_L(a, b) bound L_(b), L_(a)
+#define BOUND_W(a, b) bound W_(b), W_(a)
+#define BSF_L(a, b) bsf L_(b), L_(a)
+#define BSF_W(a, b) bsf W_(b), W_(a)
+#define BSR_L(a, b) bsr L_(b), L_(a)
+#define BSR_W(a, b) bsr W_(b), W_(a)
+#define BT_L(a, b) bt L_(b), L_(a)
+#define BT_W(a, b) bt W_(b), W_(a)
+#define BTC_L(a, b) btc L_(b), L_(a)
+#define BTC_W(a, b) btc W_(b), W_(a)
+#define BTR_L(a, b) btr L_(b), L_(a)
+#define BTR_W(a, b) btr W_(b), W_(a)
+#define BTS_L(a, b) bts L_(b), L_(a)
+#define BTS_W(a, b) bts W_(b), W_(a)
+#define CALL(a) call a
+#define CALLF(s,a) call far s:a
+#define CBW cbw
+#define CWDE cwde
+#define CLC clc
+#define CLD cld
+#define CLI cli
+#define CLTS clts
+#define CMC cmc
+#define CMP_L(a, b) cmp L_(b), L_(a)
+#define CMP_W(a, b) cmp W_(b), W_(a)
+#define CMP_B(a, b) cmp B_(b), B_(a)
+#define CMPS_L cmpsd
+#define CMPS_W cmpsw
+#define CMPS_B cmpsb
+#define CPUID cpuid
+#define CWD cwd
+#define CDQ cdq
+#define DAA daa
+#define DAS das
+#define DEC_L(a) dec L_(a)
+#define DEC_W(a) dec W_(a)
+#define DEC_B(a) dec B_(a)
+#define DIV_L(a) div L_(a)
+#define DIV_W(a) div W_(a)
+#define DIV_B(a) div B_(a)
+#define ENTER(a,b) enter b, a
+#define HLT hlt
+#define IDIV_L(a) idiv L_(a)
+#define IDIV_W(a) idiv W_(a)
+#define IDIV_B(a) idiv B_(a)
+#define IMUL_L(a, b) imul L_(b), L_(a)
+#define IMUL_W(a, b) imul W_(b), W_(a)
+#define IMUL_B(a) imul B_(a)
+#define IN_L in EAX, DX
+#define IN_W in AX, DX
+#define IN_B in AL, DX
+#define IN1_L(a) in1 L_(a)
+#define IN1_W(a) in1 W_(a)
+#define IN1_B(a) in1 B_(a)
+#define INC_L(a) inc L_(a)
+#define INC_W(a) inc W_(a)
+#define INC_B(a) inc B_(a)
+#define INS_L ins
+#define INS_W ins
+#define INS_B ins
+#define INT(a) int B_(a)
+#define INT3 int3
+#define INTO into
+#define IRET iret
+#define IRETD iretd
+#define JA(a) ja NEAR a
+#define JAE(a) jae NEAR a
+#define JB(a) jb NEAR a
+#define JBE(a) jbe NEAR a
+#define JC(a) jc NEAR a
+#define JE(a) je NEAR a
+#define JG(a) jg NEAR a
+#define JGE(a) jge NEAR a
+#define JL(a) jl NEAR a
+#define JLE(a) jle NEAR a
+#define JNA(a) jna NEAR a
+#define JNAE(a) jnae NEAR a
+#define JNB(a) jnb NEAR a
+#define JNBE(a) jnbe NEAR a
+#define JNC(a) jnc NEAR a
+#define JNE(a) jne NEAR a
+#define JNG(a) jng NEAR a
+#define JNGE(a) jnge NEAR a
+#define JNL(a) jnl NEAR a
+#define JNLE(a) jnle NEAR a
+#define JNO(a) jno NEAR a
+#define JNP(a) jnp NEAR a
+#define JNS(a) jns NEAR a
+#define JNZ(a) jnz NEAR a
+#define JO(a) jo NEAR a
+#define JP(a) jp NEAR a
+#define JPE(a) jpe NEAR a
+#define JPO(a) jpo NEAR a
+#define JS(a) js NEAR a
+#define JZ(a) jz NEAR a
+#define JMP(a) jmp a
+#define JMPF(s,a) jmp far s:a
+#define LAHF lahf
+#define LAR(a, b) lar b, a
+#define LEA_L(a, b) lea P_(b), P_(a)
+#define LEA_W(a, b) lea P_(b), P_(a)
+#define LEAVE leave
+#define LGDT(a) lgdt a
+#define LIDT(a) lidt a
+#define LDS(a, b) lds b, P_(a)
+#define LES(a, b) les b, P_(a)
+#define LFS(a, b) lfs b, P_(a)
+#define LGS(a, b) lgs b, P_(a)
+#define LSS(a, b) lss b, P_(a)
+#define LLDT(a) lldt a
+#define LMSW(a) lmsw a
+#define LOCK lock
+#define LODS_L lodsd
+#define LODS_W lodsw
+#define LODS_B lodsb
+#define LOOP(a) loop a
+#define LOOPE(a) loope a
+#define LOOPZ(a) loopz a
+#define LOOPNE(a) loopne a
+#define LOOPNZ(a) loopnz a
+#define LSL(a, b) lsl b, a
+#define LTR(a) ltr a
+#define MOV_SR(a, b) mov SR_(b), SR_(a)
+#define MOV_L(a, b) mov L_(b), L_(a)
+#define MOV_W(a, b) mov W_(b), W_(a)
+#define MOV_B(a, b) mov B_(b), B_(a)
+#define MOVS_L movsd
+#define MOVS_W movsw
+#define MOVS_B movsb
+#define MOVSX_BL(a, b) movsx B_(b), B_(a)
+#define MOVSX_BW(a, b) movsx B_(b), B_(a)
+#define MOVSX_WL(a, b) movsx W_(b), W_(a)
+#define MOVZX_BL(a, b) movzx B_(b), B_(a)
+#define MOVZX_BW(a, b) movzx B_(b), B_(a)
+#define MOVZX_WL(a, b) movzx W_(b), W_(a)
+#define MUL_L(a) mul L_(a)
+#define MUL_W(a) mul W_(a)
+#define MUL_B(a) mul B_(a)
+#define NEG_L(a) neg L_(a)
+#define NEG_W(a) neg W_(a)
+#define NEG_B(a) neg B_(a)
+#define NOP nop
+#define NOT_L(a) not L_(a)
+#define NOT_W(a) not W_(a)
+#define NOT_B(a) not B_(a)
+#define OR_L(a,b) or L_(b), L_(a)
+#define OR_W(a,b) or W_(b), W_(a)
+#define OR_B(a,b) or B_(b), B_(a)
+#define OUT_L out DX, EAX
+#define OUT_W out DX, AX
+#define OUT_B out DX, AL
+#define OUT1_L(a) out1 L_(a)
+#define OUT1_W(a) out1 W_(a)
+#define OUT1_B(a) out1 B_(a)
+#define OUTS_L outsd
+#define OUTS_W outsw
+#define OUTS_B outsb
+#define POP_SR(a) pop SR_(a)
+#define POP_L(a) pop L_(a)
+#define POP_W(a) pop W_(a)
+#define POPA_L popad
+#define POPA_W popa
+#define POPF_L popfd
+#define POPF_W popf
+#define PUSH_SR(a) push SR_(a)
+#define PUSH_L(a) push L_(a)
+#define PUSH_W(a) push W_(a)
+#define PUSH_B(a) push B_(a)
+#define PUSHA_L pushad
+#define PUSHA_W pusha
+#define PUSHF_L pushfd
+#define PUSHF_W pushf
+#define RCL_L(a, b) rcl L_(b), L_(a)
+#define RCL_W(a, b) rcl W_(b), W_(a)
+#define RCL_B(a, b) rcl B_(b), B_(a)
+#define RCR_L(a, b) rcr L_(b), L_(a)
+#define RCR_W(a, b) rcr W_(b), W_(a)
+#define RCR_B(a, b) rcr B_(b), B_(a)
+#define RDTSC rdtsc
+#define ROL_L(a, b) rol L_(b), L_(a)
+#define ROL_W(a, b) rol W_(b), W_(a)
+#define ROL_B(a, b) rol B_(b), B_(a)
+#define ROR_L(a, b) ror L_(b), L_(a)
+#define ROR_W(a, b) ror W_(b), W_(a)
+#define ROR_B(a, b) ror B_(b), B_(a)
+#define REP rep
+#define REPE repe
+#define REPNE repne
+#define REPNZ REPNE
+#define REPZ REPE
+#define RET ret
+#define SAHF sahf
+#define SAL_L(a, b) sal L_(b), B_(a)
+#define SAL_W(a, b) sal W_(b), B_(a)
+#define SAL_B(a, b) sal B_(b), B_(a)
+#define SAR_L(a, b) sar L_(b), B_(a)
+#define SAR_W(a, b) sar W_(b), B_(a)
+#define SAR_B(a, b) sar B_(b), B_(a)
+#define SBB_L(a, b) sbb L_(b), L_(a)
+#define SBB_W(a, b) sbb W_(b), W_(a)
+#define SBB_B(a, b) sbb B_(b), B_(a)
+#define SCAS_L scas
+#define SCAS_W scas
+#define SCAS_B scas
+#define SETA(a) seta a
+#define SETAE(a) setae a
+#define SETB(a) setb a
+#define SETBE(a) setbe a
+#define SETC(a) setc a
+#define SETE(a) sete a
+#define SETG(a) setg a
+#define SETGE(a) setge a
+#define SETL(a) setl a
+#define SETLE(a) setle a
+#define SETNA(a) setna a
+#define SETNAE(a) setnae a
+#define SETNB(a) setnb a
+#define SETNBE(a) setnbe a
+#define SETNC(a) setnc a
+#define SETNE(a) setne a
+#define SETNG(a) setng a
+#define SETNGE(a) setnge a
+#define SETNL(a) setnl a
+#define SETNLE(a) setnle a
+#define SETNO(a) setno a
+#define SETNP(a) setnp a
+#define SETNS(a) setns a
+#define SETNZ(a) setnz a
+#define SETO(a) seto a
+#define SETP(a) setp a
+#define SETPE(a) setpe a
+#define SETPO(a) setpo a
+#define SETS(a) sets a
+#define SETZ(a) setz a
+#define SGDT(a) sgdt a
+#define SIDT(a) sidt a
+#define SHL_L(a, b) shl L_(b), B_(a)
+#define SHL_W(a, b) shl W_(b), B_(a)
+#define SHL_B(a, b) shl B_(b), B_(a)
+#define SHLD_L(a,b,c) shld
+#define SHLD2_L(a,b) shld L_(b), L_(a)
+#define SHLD_W(a,b,c) shld
+#define SHLD2_W(a,b) shld W_(b), W_(a)
+#define SHR_L(a, b) shr L_(b), B_(a)
+#define SHR_W(a, b) shr W_(b), B_(a)
+#define SHR_B(a, b) shr B_(b), B_(a)
+#define SHRD_L(a,b,c) shrd
+#define SHRD2_L(a,b) shrd L_(b), L_(a)
+#define SHRD_W(a,b,c) shrd
+#define SHRD2_W(a,b) shrd W_(b), W_(a)
+#define SLDT(a) sldt a
+#define SMSW(a) smsw a
+#define STC stc
+#define STD std
+#define STI sti
+#define STOS_L stosd
+#define STOS_W stosw
+#define STOS_B stosb
+#define STR(a) str a
+#define SUB_L(a, b) sub L_(b), L_(a)
+#define SUB_W(a, b) sub W_(b), W_(a)
+#define SUB_B(a, b) sub B_(b), B_(a)
+#define TEST_L(a, b) test L_(b), L_(a)
+#define TEST_W(a, b) test W_(b), W_(a)
+#define TEST_B(a, b) test B_(b), B_(a)
+#define VERR(a) verr a
+#define VERW(a) verw a
+#define WAIT wait
+#define XCHG_L(a, b) xchg L_(b), L_(a)
+#define XCHG_W(a, b) xchg W_(b), W_(a)
+#define XCHG_B(a, b) xchg B_(b), B_(a)
+#define XLAT xlat
+#define XOR_L(a, b) xor L_(b), L_(a)
+#define XOR_W(a, b) xor W_(b), W_(a)
+#define XOR_B(a, b) xor B_(b), B_(a)
+
+
+/* Floating Point Instructions */
+#define F2XM1 f2xm1
+#define FABS fabs
+#define FADD_D(a) fadd D_(a)
+#define FADD_S(a) fadd S_(a)
+#define FADD2(a, b) fadd b, a
+#define FADDP(a, b) faddp b, a
+#define FIADD_L(a) fiadd L_(a)
+#define FIADD_W(a) fiadd W_(a)
+#define FBLD(a) fbld a
+#define FBSTP(a) fbstp a
+#define FCHS fchs
+#define FCLEX fclex
+#define FNCLEX fnclex
+#define FCOM(a) fcom a
+#define FCOM_D(a) fcom D_(a)
+#define FCOM_S(a) fcom S_(a)
+#define FCOMP(a) fcomp a
+#define FCOMP_D(a) fcomp D_(a)
+#define FCOMP_S(a) fcomp S_(a)
+#define FCOMPP fcompp
+#define FCOS fcos
+#define FDECSTP fdecstp
+#define FDIV_D(a) fdiv D_(a)
+#define FDIV_S(a) fdiv S_(a)
+#define FDIV2(a, b) fdiv b, a
+#define FDIVP(a, b) fdivp b, a
+#define FIDIV_L(a) fidiv L_(a)
+#define FIDIV_W(a) fidiv W_(a)
+#define FDIVR_D(a) fdivr D_(a)
+#define FDIVR_S(a) fdivr S_(a)
+#define FDIVR2(a, b) fdivr b, a
+#define FDIVRP(a, b) fdivrp b, a
+#define FIDIVR_L(a) fidivr L_(a)
+#define FIDIVR_W(a) fidivr W_(a)
+#define FFREE(a) ffree a
+#define FICOM_L(a) ficom L_(a)
+#define FICOM_W(a) ficom W_(a)
+#define FICOMP_L(a) ficomp L_(a)
+#define FICOMP_W(a) ficomp W_(a)
+#define FILD_Q(a) fild D_(a)
+#define FILD_L(a) fild L_(a)
+#define FILD_W(a) fild W_(a)
+#define FINCSTP fincstp
+#define FINIT finit
+#define FNINIT fninit
+#define FIST_L(a) fist L_(a)
+#define FIST_W(a) fist W_(a)
+#define FISTP_Q(a) fistp D_(a)
+#define FISTP_L(a) fistp L_(a)
+#define FISTP_W(a) fistp W_(a)
+#define FLD_X(a) fld X_(a)
+#define FLD_D(a) fld D_(a)
+#define FLD_S(a) fld S_(a)
+#define FLD1 fld1
+#define FLDL2T fldl2t
+#define FLDL2E fldl2e
+#define FLDPI fldpi
+#define FLDLG2 fldlg2
+#define FLDLN2 fldln2
+#define FLDZ fldz
+#define FLDCW(a) fldcw a
+#define FLDENV(a) fldenv a
+#define FMUL_S(a) fmul S_(a)
+#define FMUL_D(a) fmul D_(a)
+#define FMUL2(a, b) fmul b, a
+#define FMULP(a, b) fmulp b, a
+#define FIMUL_L(a) fimul L_(a)
+#define FIMUL_W(a) fimul W_(a)
+#define FNOP fnop
+#define FPATAN fpatan
+#define FPREM fprem
+#define FPREM1 fprem1
+#define FPTAN fptan
+#define FRNDINT frndint
+#define FRSTOR(a) frstor a
+#define FSAVE(a) fsave a
+#define FNSAVE(a) fnsave a
+#define FSCALE fscale
+#define FSIN fsin
+#define FSINCOS fsincos
+#define FSQRT fsqrt
+#define FST_D(a) fst D_(a)
+#define FST_S(a) fst S_(a)
+#define FSTP_X(a) fstp X_(a)
+#define FSTP_D(a) fstp D_(a)
+#define FSTP_S(a) fstp S_(a)
+#define FSTP(a) fstp a
+#define FSTCW(a) fstcw a
+#define FNSTCW(a) fnstcw a
+#define FSTENV(a) fstenv a
+#define FNSTENV(a) fnstenv a
+#define FSTSW(a) fstsw a
+#define FNSTSW(a) fnstsw a
+#define FSUB_S(a) fsub S_(a)
+#define FSUB_D(a) fsub D_(a)
+#define FSUB2(a, b) fsub b, a
+#define FSUBP(a, b) fsubp b, a
+#define FISUB_L(a) fisub L_(a)
+#define FISUB_W(a) fisub W_(a)
+#define FSUBR_S(a) fsubr S_(a)
+#define FSUBR_D(a) fsubr D_(a)
+#define FSUBR2(a, b) fsubr b, a
+#define FSUBRP(a, b) fsubrp b, a
+#define FISUBR_L(a) fisubr L_(a)
+#define FISUBR_W(a) fisubr W_(a)
+#define FTST ftst
+#define FUCOM(a) fucom a
+#define FUCOMP(a) fucomp a
+#define FUCOMPP fucompp
+#define FWAIT fwait
+#define FXAM fxam
+#define FXCH(a) fxch a
+#define FXTRACT fxtract
+#define FYL2X fyl2x
+#define FYL2XP1 fyl2xp1
+
+#endif /* NASM_ASSEMBLER, MASM_ASSEMBLER */
+
+ /****************************************/
+ /* */
+ /* Extensions to x86 insn set - */
+ /* MMX, 3DNow! */
+ /* */
+ /****************************************/
+
+#if defined(NASM_ASSEMBLER) || defined(MASM_ASSEMBLER)
+#define P_ARG1(a) P_ ## a
+#define P_ARG2(a, b) P_ ## b, P_ ## a
+#define P_ARG3(a, b, c) P_ ## c, P_ ## b, P_ ## a
+#else
+#define P_ARG1(a) a
+#define P_ARG2(a, b) a, b
+#define P_ARG3(a, b, c) a, b, c
+#endif
+
+/* MMX */
+#define MOVD(a, b) movd P_ARG2(a, b)
+#define MOVQ(a, b) movq P_ARG2(a, b)
+
+#define PADDB(a, b) paddb P_ARG2(a, b)
+#define PADDW(a, b) paddw P_ARG2(a, b)
+#define PADDD(a, b) paddd P_ARG2(a, b)
+
+#define PADDSB(a, b) paddsb P_ARG2(a, b)
+#define PADDSW(a, b) paddsw P_ARG2(a, b)
+
+#define PADDUSB(a, b) paddusb P_ARG2(a, b)
+#define PADDUSW(a, b) paddusw P_ARG2(a, b)
+
+#define PSUBB(a, b) psubb P_ARG2(a, b)
+#define PSUBW(a, b) psubw P_ARG2(a, b)
+#define PSUBD(a, b) psubd P_ARG2(a, b)
+
+#define PSUBSB(a, b) psubsb P_ARG2(a, b)
+#define PSUBSW(a, b) psubsw P_ARG2(a, b)
+
+#define PSUBUSB(a, b) psubusb P_ARG2(a, b)
+#define PSUBUSW(a, b) psubusw P_ARG2(a, b)
+
+#define PCMPEQB(a, b) pcmpeqb P_ARG2(a, b)
+#define PCMPEQW(a, b) pcmpeqw P_ARG2(a, b)
+#define PCMPEQD(a, b) pcmpeqd P_ARG2(a, b)
+
+#define PCMPGTB(a, b) pcmpgtb P_ARG2(a, b)
+#define PCMPGTW(a, b) pcmpgtw P_ARG2(a, b)
+#define PCMPGTD(a, b) pcmpgtd P_ARG2(a, b)
+
+#define PMULHW(a, b) pmulhw P_ARG2(a, b)
+#define PMULLW(a, b) pmullw P_ARG2(a, b)
+
+#define PMADDWD(a, b) pmaddwd P_ARG2(a, b)
+
+#define PAND(a, b) pand P_ARG2(a, b)
+
+#define PANDN(a, b) pandn P_ARG2(a, b)
+
+#define POR(a, b) por P_ARG2(a, b)
+
+#define PXOR(a, b) pxor P_ARG2(a, b)
+
+#define PSRAW(a, b) psraw P_ARG2(a, b)
+#define PSRAD(a, b) psrad P_ARG2(a, b)
+
+#define PSRLW(a, b) psrlw P_ARG2(a, b)
+#define PSRLD(a, b) psrld P_ARG2(a, b)
+#define PSRLQ(a, b) psrlq P_ARG2(a, b)
+
+#define PSLLW(a, b) psllw P_ARG2(a, b)
+#define PSLLD(a, b) pslld P_ARG2(a, b)
+#define PSLLQ(a, b) psllq P_ARG2(a, b)
+
+#define PACKSSWB(a, b) packsswb P_ARG2(a, b)
+#define PACKSSDW(a, b) packssdw P_ARG2(a, b)
+#define PACKUSWB(a, b) packuswb P_ARG2(a, b)
+
+#define PUNPCKHBW(a, b) punpckhbw P_ARG2(a, b)
+#define PUNPCKHWD(a, b) punpckhwd P_ARG2(a, b)
+#define PUNPCKHDQ(a, b) punpckhdq P_ARG2(a, b)
+#define PUNPCKLBW(a, b) punpcklbw P_ARG2(a, b)
+#define PUNPCKLWD(a, b) punpcklwd P_ARG2(a, b)
+#define PUNPCKLDQ(a, b) punpckldq P_ARG2(a, b)
+
+#define EMMS emms
+
+/* AMD 3DNow! */
+#define PAVGUSB(a, b) pavgusb P_ARG2(a, b)
+#define PFADD(a, b) pfadd P_ARG2(a, b)
+#define PFSUB(a, b) pfsub P_ARG2(a, b)
+#define PFSUBR(a, b) pfsubr P_ARG2(a, b)
+#define PFACC(a, b) pfacc P_ARG2(a, b)
+#define PFCMPGE(a, b) pfcmpge P_ARG2(a, b)
+#define PFCMPGT(a, b) pfcmpgt P_ARG2(a, b)
+#define PFCMPEQ(a, b) pfcmpeq P_ARG2(a, b)
+#define PFMIN(a, b) pfmin P_ARG2(a, b)
+#define PFMAX(a, b) pfmax P_ARG2(a, b)
+#define PI2FD(a, b) pi2fd P_ARG2(a, b)
+#define PF2ID(a, b) pf2id P_ARG2(a, b)
+#define PFRCP(a, b) pfrcp P_ARG2(a, b)
+#define PFRSQRT(a, b) pfrsqrt P_ARG2(a, b)
+#define PFMUL(a, b) pfmul P_ARG2(a, b)
+#define PFRCPIT1(a, b) pfrcpit1 P_ARG2(a, b)
+#define PFRSQIT1(a, b) pfrsqit1 P_ARG2(a, b)
+#define PFRCPIT2(a, b) pfrcpit2 P_ARG2(a, b)
+#define PMULHRW(a, b) pmulhrw P_ARG2(a, b)
+
+#define FEMMS femms
+#define PREFETCH(a) prefetch P_ARG1(a)
+#define PREFETCHW(a) prefetchw P_ARG1(a)
+
+/* Intel SSE */
+#define ADDPS(a, b) addps P_ARG2(a, b)
+#define ADDSS(a, b) addss P_ARG2(a, b)
+#define ANDNPS(a, b) andnps P_ARG2(a, b)
+#define ANDPS(a, b) andps P_ARG2(a, b)
+/* NASM only knows the pseudo ops for these.
+#define CMPPS(a, b, c) cmpps P_ARG3(a, b, c)
+#define CMPSS(a, b, c) cmpss P_ARG3(a, b, c)
+*/
+#define CMPEQPS(a, b) cmpeqps P_ARG2(a, b)
+#define CMPLTPS(a, b) cmpltps P_ARG2(a, b)
+#define CMPLEPS(a, b) cmpleps P_ARG2(a, b)
+#define CMPUNORDPS(a, b) cmpunordps P_ARG2(a, b)
+#define CMPNEQPS(a, b) cmpneqps P_ARG2(a, b)
+#define CMPNLTPS(a, b) cmpnltps P_ARG2(a, b)
+#define CMPNLEPS(a, b) cmpnleps P_ARG2(a, b)
+#define CMPORDPS(a, b) cmpordps P_ARG2(a, b)
+#define CMPEQSS(a, b) cmpeqss P_ARG2(a, b)
+#define CMPLTSS(a, b) cmpltss P_ARG2(a, b)
+#define CMPLESS(a, b) cmpless P_ARG2(a, b)
+#define CMPUNORDSS(a, b) cmpunordss P_ARG2(a, b)
+#define CMPNEQSS(a, b) cmpneqss P_ARG2(a, b)
+#define CMPNLTSS(a, b) cmpnltss P_ARG2(a, b)
+#define CMPNLESS(a, b) cmpnless P_ARG2(a, b)
+#define CMPORDSS(a, b) cmpordss P_ARG2(a, b)
+#define COMISS(a, b) comiss P_ARG2(a, b)
+#define CVTPI2PS(a, b) cvtpi2ps P_ARG2(a, b)
+#define CVTPS2PI(a, b) cvtps2pi P_ARG2(a, b)
+#define CVTSI2SS(a, b) cvtsi2ss P_ARG2(a, b)
+#define CVTSS2SI(a, b) cvtss2si P_ARG2(a, b)
+#define CVTTPS2PI(a, b) cvttps2pi P_ARG2(a, b)
+#define CVTTSS2SI(a, b) cvttss2si P_ARG2(a, b)
+#define DIVPS(a, b) divps P_ARG2(a, b)
+#define DIVSS(a, b) divss P_ARG2(a, b)
+#define FXRSTOR(a) fxrstor P_ARG1(a)
+#define FXSAVE(a) fxsave P_ARG1(a)
+#define LDMXCSR(a) ldmxcsr P_ARG1(a)
+#define MAXPS(a, b) maxps P_ARG2(a, b)
+#define MAXSS(a, b) maxss P_ARG2(a, b)
+#define MINPS(a, b) minps P_ARG2(a, b)
+#define MINSS(a, b) minss P_ARG2(a, b)
+#define MOVAPS(a, b) movaps P_ARG2(a, b)
+#define MOVHLPS(a, b) movhlps P_ARG2(a, b)
+#define MOVHPS(a, b) movhps P_ARG2(a, b)
+#define MOVLHPS(a, b) movlhps P_ARG2(a, b)
+#define MOVLPS(a, b) movlps P_ARG2(a, b)
+#define MOVMSKPS(a, b) movmskps P_ARG2(a, b)
+#define MOVNTPS(a, b) movntps P_ARG2(a, b)
+#define MOVNTQ(a, b) movntq P_ARG2(a, b)
+#define MOVSS(a, b) movss P_ARG2(a, b)
+#define MOVUPS(a, b) movups P_ARG2(a, b)
+#define MULPS(a, b) mulps P_ARG2(a, b)
+#define MULSS(a, b) mulss P_ARG2(a, b)
+#define ORPS(a, b) orps P_ARG2(a, b)
+#define RCPPS(a, b) rcpps P_ARG2(a, b)
+#define RCPSS(a, b) rcpss P_ARG2(a, b)
+#define RSQRTPS(a, b) rsqrtps P_ARG2(a, b)
+#define RSQRTSS(a, b) rsqrtss P_ARG2(a, b)
+#define SHUFPS(a, b, c) shufps P_ARG3(a, b, c)
+#define SQRTPS(a, b) sqrtps P_ARG2(a, b)
+#define SQRTSS(a, b) sqrtss P_ARG2(a, b)
+#define STMXCSR(a) stmxcsr P_ARG1(a)
+#define SUBPS(a, b) subps P_ARG2(a, b)
+#define UCOMISS(a, b) ucomiss P_ARG2(a, b)
+#define UNPCKHPS(a, b) unpckhps P_ARG2(a, b)
+#define UNPCKLPS(a, b) unpcklps P_ARG2(a, b)
+#define XORPS(a, b) xorps P_ARG2(a, b)
+
+#define PREFETCHNTA(a) prefetchnta P_ARG1(a)
+#define PREFETCHT0(a) prefetcht0 P_ARG1(a)
+#define PREFETCHT1(a) prefetcht1 P_ARG1(a)
+#define PREFETCHT2(a) prefetcht2 P_ARG1(a)
+#define SFENCE sfence
+
+/* Added by BrianP for FreeBSD (per David Dawes) */
+#if !defined(NASM_ASSEMBLER) && !defined(MASM_ASSEMBLER) && !defined(__bsdi__)
+#define LLBL(a) CONCAT(.L,a)
+#define LLBL2(a,b) CONCAT3(.L,a,b)
+#else
+#define LLBL(a) a
+#define LLBL2(a,b) CONCAT(a,b)
+#endif
+
+/* Segment overrides */
+#define SEGCS D_BYTE 46
+#define SEGDS D_BYTE 62
+#define SEGES D_BYTE 38
+#define SEGFS D_BYTE 100
+#define SEGGS D_BYTE 101
+
+/* Temporary labels: valid until next non-local label */
+#ifdef NASM_ASSEMBLER
+#define TLBL(a) CONCAT(.,a)
+#else
+#define TLBL(a) CONCAT(a,$)
+#endif
+
+/* Hidden symbol visibility support.
+ * If we build with gcc's -fvisibility=hidden flag, we'll need to change
+ * the symbol visibility mode to 'default'.
+ */
+#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__)
+# define HIDDEN(x) .hidden x
+#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303 && !defined(__MINGW32__)
+# pragma GCC visibility push(default)
+# define HIDDEN(x) .hidden x
+#else
+# define HIDDEN(x)
+#endif
+
+#endif /* __ASSYNTAX_H__ */
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/clip_args.h b/nx-X11/extras/Mesa/src/mesa/x86/clip_args.h
new file mode 100644
index 000000000..ff9aa377f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/clip_args.h
@@ -0,0 +1,60 @@
+/* $Id: clip_args.h,v 1.1.1.1 2004/06/16 09:19:35 anholt Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * Clip test function interface for assembly code. Simply define
+ * FRAME_OFFSET to the number of bytes pushed onto the stack before
+ * using the ARG_* argument macros.
+ *
+ * Gareth Hughes
+ */
+
+#ifndef __CLIP_ARGS_H__
+#define __CLIP_ARGS_H__
+
+/*
+ * Offsets for clip_func arguments
+ *
+ * typedef GLvector4f *(*clip_func)( GLvector4f *clip_vec,
+ * GLvector4f *proj_vec,
+ * GLubyte clipMask[],
+ * GLubyte *orMask,
+ * GLubyte *andMask );
+ */
+
+#define OFFSET_SOURCE 4
+#define OFFSET_DEST 8
+#define OFFSET_CLIP 12
+#define OFFSET_OR 16
+#define OFFSET_AND 20
+
+#define ARG_SOURCE REGOFF(FRAME_OFFSET+OFFSET_SOURCE, ESP)
+#define ARG_DEST REGOFF(FRAME_OFFSET+OFFSET_DEST, ESP)
+#define ARG_CLIP REGOFF(FRAME_OFFSET+OFFSET_CLIP, ESP)
+#define ARG_OR REGOFF(FRAME_OFFSET+OFFSET_OR, ESP)
+#define ARG_AND REGOFF(FRAME_OFFSET+OFFSET_AND, ESP)
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/common_x86.c b/nx-X11/extras/Mesa/src/mesa/x86/common_x86.c
new file mode 100644
index 000000000..0ff7fd51a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/common_x86.c
@@ -0,0 +1,448 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.0.1
+ *
+ * Copyright (C) 1999-2004 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file common_x86.c
+ *
+ * Check CPU capabilities & initialize optimized funtions for this particular
+ * processor.
+ *
+ * Changed by Andre Werthmann for using the new SSE functions.
+ *
+ * \author Holger Waechtler <holger@akaflieg.extern.tu-berlin.de>
+ * \author Andre Werthmann <wertmann@cs.uni-potsdam.de>
+ */
+
+/* XXX these includes should probably go into imports.h or glheader.h */
+#if defined(USE_SSE_ASM) && defined(__linux__)
+#include <signal.h>
+#endif
+#if defined(USE_SSE_ASM) && defined(__FreeBSD__)
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif
+
+#include "common_x86_asm.h"
+#include "imports.h"
+
+
+int _mesa_x86_cpu_features = 0;
+
+/* No reason for this to be public.
+ */
+extern GLuint _ASMAPI _mesa_x86_has_cpuid(void);
+extern void _ASMAPI _mesa_x86_cpuid(GLuint op, GLuint *reg_eax, GLuint *reg_ebx, GLuint *reg_ecx, GLuint *reg_edx);
+extern GLuint _ASMAPI _mesa_x86_cpuid_eax(GLuint op);
+extern GLuint _ASMAPI _mesa_x86_cpuid_ebx(GLuint op);
+extern GLuint _ASMAPI _mesa_x86_cpuid_ecx(GLuint op);
+extern GLuint _ASMAPI _mesa_x86_cpuid_edx(GLuint op);
+
+static void message( const char *msg )
+{
+ GLboolean debug;
+#ifdef DEBUG
+ debug = GL_TRUE;
+#else
+ if ( _mesa_getenv( "MESA_DEBUG" ) ) {
+ debug = GL_TRUE;
+ } else {
+ debug = GL_FALSE;
+ }
+#endif
+ if ( debug ) {
+ fprintf( stderr, "%s", msg );
+ }
+}
+
+#if defined(USE_SSE_ASM)
+/*
+ * We must verify that the Streaming SIMD Extensions are truly supported
+ * on this processor before we go ahead and hook out the optimized code.
+ * Unfortunately, the CPUID bit isn't enough, as the OS must set the
+ * OSFXSR bit in CR4 if it supports the extended FPU save and restore
+ * required to use SSE. Unfortunately, we can't just go ahead and read
+ * this register, as only the kernel can do that. Similarly, we must
+ * verify that the OSXMMEXCPT bit in CR4 has been set by the OS,
+ * signifying that it supports unmasked SIMD FPU exceptions. If we take
+ * an unmasked exception and the OS doesn't correctly support them, the
+ * best we'll get is a SIGILL and the worst we'll get is an infinite
+ * loop in the signal delivery from the kernel as we can't interact with
+ * the SIMD FPU state to clear the exception bits. Either way, this is
+ * not good.
+ *
+ * However, I have been told by Alan Cox that all 2.4 (and later) Linux
+ * kernels provide full SSE support on all processors that expose SSE via
+ * the CPUID mechanism. It just so happens that this is the exact set of
+ * kernels supported DRI. Therefore, when building for DRI the funky SSE
+ * exception test is omitted.
+ */
+
+extern void _mesa_test_os_sse_support( void );
+extern void _mesa_test_os_sse_exception_support( void );
+
+#if defined(__linux__) && defined(_POSIX_SOURCE) && defined(X86_FXSR_MAGIC) \
+ && !defined(IN_DRI_DRIVER)
+static void sigill_handler( int signal, struct sigcontext sc )
+{
+ message( "SIGILL, " );
+
+ /* Both the "xorps %%xmm0,%%xmm0" and "divps %xmm0,%%xmm1"
+ * instructions are 3 bytes long. We must increment the instruction
+ * pointer manually to avoid repeated execution of the offending
+ * instruction.
+ *
+ * If the SIGILL is caused by a divide-by-zero when unmasked
+ * exceptions aren't supported, the SIMD FPU status and control
+ * word will be restored at the end of the test, so we don't need
+ * to worry about doing it here. Besides, we may not be able to...
+ */
+ sc.eip += 3;
+
+ _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM);
+}
+
+static void sigfpe_handler( int signal, struct sigcontext sc )
+{
+ message( "SIGFPE, " );
+
+ if ( sc.fpstate->magic != 0xffff ) {
+ /* Our signal context has the extended FPU state, so reset the
+ * divide-by-zero exception mask and clear the divide-by-zero
+ * exception bit.
+ */
+ sc.fpstate->mxcsr |= 0x00000200;
+ sc.fpstate->mxcsr &= 0xfffffffb;
+ } else {
+ /* If we ever get here, we're completely hosed.
+ */
+ message( "\n\n" );
+ _mesa_problem( NULL, "SSE enabling test failed badly!" );
+ }
+}
+#endif /* __linux__ && _POSIX_SOURCE && X86_FXSR_MAGIC */
+
+#if defined(WIN32)
+#ifndef STATUS_FLOAT_MULTIPLE_TRAPS
+# define STATUS_FLOAT_MULTIPLE_TRAPS (0xC00002B5L)
+#endif
+static LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS exp)
+{
+ PEXCEPTION_RECORD rec = exp->ExceptionRecord;
+ PCONTEXT ctx = exp->ContextRecord;
+
+ if ( rec->ExceptionCode == EXCEPTION_ILLEGAL_INSTRUCTION ) {
+ message( "EXCEPTION_ILLEGAL_INSTRUCTION, " );
+ _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM);
+ } else if ( rec->ExceptionCode == STATUS_FLOAT_MULTIPLE_TRAPS ) {
+ message( "STATUS_FLOAT_MULTIPLE_TRAPS, " );
+ /* Windows seems to clear the exception flag itself, we just have to increment Eip */
+ } else {
+ message( "UNEXPECTED EXCEPTION (0x%08x), terminating!" );
+ return EXCEPTION_EXECUTE_HANDLER;
+ }
+
+ if ( (ctx->ContextFlags & CONTEXT_CONTROL) != CONTEXT_CONTROL ) {
+ message( "Context does not contain control registers, terminating!" );
+ return EXCEPTION_EXECUTE_HANDLER;
+ }
+ ctx->Eip += 3;
+
+ return EXCEPTION_CONTINUE_EXECUTION;
+}
+#endif /* WIN32 */
+
+
+/* If we're running on a processor that can do SSE, let's see if we
+ * are allowed to or not. This will catch 2.4.0 or later kernels that
+ * haven't been configured for a Pentium III but are running on one,
+ * and RedHat patched 2.2 kernels that have broken exception handling
+ * support for user space apps that do SSE.
+ *
+ * GH: Isn't this just awful?
+ */
+static void check_os_sse_support( void )
+{
+#if defined(__linux__) && !defined(IN_DRI_DRIVER)
+#if defined(_POSIX_SOURCE) && defined(X86_FXSR_MAGIC)
+ struct sigaction saved_sigill;
+ struct sigaction saved_sigfpe;
+
+ /* Save the original signal handlers.
+ */
+ sigaction( SIGILL, NULL, &saved_sigill );
+ sigaction( SIGFPE, NULL, &saved_sigfpe );
+
+ signal( SIGILL, (void (*)(int))sigill_handler );
+ signal( SIGFPE, (void (*)(int))sigfpe_handler );
+
+ /* Emulate test for OSFXSR in CR4. The OS will set this bit if it
+ * supports the extended FPU save and restore required for SSE. If
+ * we execute an SSE instruction on a PIII and get a SIGILL, the OS
+ * doesn't support Streaming SIMD Exceptions, even if the processor
+ * does.
+ */
+ if ( cpu_has_xmm ) {
+ message( "Testing OS support for SSE... " );
+
+ _mesa_test_os_sse_support();
+
+ if ( cpu_has_xmm ) {
+ message( "yes.\n" );
+ } else {
+ message( "no!\n" );
+ }
+ }
+
+ /* Emulate test for OSXMMEXCPT in CR4. The OS will set this bit if
+ * it supports unmasked SIMD FPU exceptions. If we unmask the
+ * exceptions, do a SIMD divide-by-zero and get a SIGILL, the OS
+ * doesn't support unmasked SIMD FPU exceptions. If we get a SIGFPE
+ * as expected, we're okay but we need to clean up after it.
+ *
+ * Are we being too stringent in our requirement that the OS support
+ * unmasked exceptions? Certain RedHat 2.2 kernels enable SSE by
+ * setting CR4.OSFXSR but don't support unmasked exceptions. Win98
+ * doesn't even support them. We at least know the user-space SSE
+ * support is good in kernels that do support unmasked exceptions,
+ * and therefore to be safe I'm going to leave this test in here.
+ */
+ if ( cpu_has_xmm ) {
+ message( "Testing OS support for SSE unmasked exceptions... " );
+
+ _mesa_test_os_sse_exception_support();
+
+ if ( cpu_has_xmm ) {
+ message( "yes.\n" );
+ } else {
+ message( "no!\n" );
+ }
+ }
+
+ /* Restore the original signal handlers.
+ */
+ sigaction( SIGILL, &saved_sigill, NULL );
+ sigaction( SIGFPE, &saved_sigfpe, NULL );
+
+ /* If we've gotten to here and the XMM CPUID bit is still set, we're
+ * safe to go ahead and hook out the SSE code throughout Mesa.
+ */
+ if ( cpu_has_xmm ) {
+ message( "Tests of OS support for SSE passed.\n" );
+ } else {
+ message( "Tests of OS support for SSE failed!\n" );
+ }
+#else
+ /* We can't use POSIX signal handling to test the availability of
+ * SSE, so we disable it by default.
+ */
+ message( "Cannot test OS support for SSE, disabling to be safe.\n" );
+ _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM);
+#endif /* _POSIX_SOURCE && X86_FXSR_MAGIC */
+#elif defined(__FreeBSD__)
+ {
+ int ret, enabled;
+ unsigned int len;
+ len = sizeof(enabled);
+ ret = sysctlbyname("hw.instruction_sse", &enabled, &len, NULL, 0);
+ if (ret || !enabled)
+ _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM);
+ }
+#elif defined(WIN32)
+ LPTOP_LEVEL_EXCEPTION_FILTER oldFilter;
+
+ /* Install our ExceptionFilter */
+ oldFilter = SetUnhandledExceptionFilter( ExceptionFilter );
+
+ if ( cpu_has_xmm ) {
+ message( "Testing OS support for SSE... " );
+
+ _mesa_test_os_sse_support();
+
+ if ( cpu_has_xmm ) {
+ message( "yes.\n" );
+ } else {
+ message( "no!\n" );
+ }
+ }
+
+ if ( cpu_has_xmm ) {
+ message( "Testing OS support for SSE unmasked exceptions... " );
+
+ _mesa_test_os_sse_exception_support();
+
+ if ( cpu_has_xmm ) {
+ message( "yes.\n" );
+ } else {
+ message( "no!\n" );
+ }
+ }
+
+ /* Restore previous exception filter */
+ SetUnhandledExceptionFilter( oldFilter );
+
+ if ( cpu_has_xmm ) {
+ message( "Tests of OS support for SSE passed.\n" );
+ } else {
+ message( "Tests of OS support for SSE failed!\n" );
+ }
+#else
+ /* Do nothing on other platforms for now.
+ */
+ message( "Not testing OS support for SSE, leaving enabled.\n" );
+#endif /* __linux__ */
+}
+
+#endif /* USE_SSE_ASM */
+
+
+void _mesa_init_all_x86_transform_asm( void )
+{
+ (void) message; /* silence warning */
+#ifdef USE_X86_ASM
+ _mesa_x86_cpu_features = 0;
+
+ if (!_mesa_x86_has_cpuid()) {
+ message("CPUID not detected");
+ }
+ else {
+ GLuint cpu_features;
+ GLuint cpu_ext_features;
+ GLuint cpu_ext_info;
+ char cpu_vendor[13];
+ GLuint result;
+
+ /* get vendor name */
+ _mesa_x86_cpuid(0, &result, (GLuint *)(cpu_vendor + 0), (GLuint *)(cpu_vendor + 8), (GLuint *)(cpu_vendor + 4));
+ cpu_vendor[12] = '\0';
+
+ message("cpu vendor: ");
+ message(cpu_vendor);
+ message("\n");
+
+ /* get cpu features */
+ cpu_features = _mesa_x86_cpuid_edx(1);
+
+ if (cpu_features & X86_CPU_FPU)
+ _mesa_x86_cpu_features |= X86_FEATURE_FPU;
+ if (cpu_features & X86_CPU_CMOV)
+ _mesa_x86_cpu_features |= X86_FEATURE_CMOV;
+
+#ifdef USE_MMX_ASM
+ if (cpu_features & X86_CPU_MMX)
+ _mesa_x86_cpu_features |= X86_FEATURE_MMX;
+#endif
+
+#ifdef USE_SSE_ASM
+ if (cpu_features & X86_CPU_XMM)
+ _mesa_x86_cpu_features |= X86_FEATURE_XMM;
+ if (cpu_features & X86_CPU_XMM2)
+ _mesa_x86_cpu_features |= X86_FEATURE_XMM2;
+#endif
+
+ /* query extended cpu features */
+ if ((cpu_ext_info = _mesa_x86_cpuid_eax(0x80000000)) > 0x80000000) {
+ if (cpu_ext_info >= 0x80000001) {
+
+ cpu_ext_features = _mesa_x86_cpuid_edx(0x80000001);
+
+ if (cpu_features & X86_CPU_MMX) {
+
+#ifdef USE_3DNOW_ASM
+ if (cpu_ext_features & X86_CPUEXT_3DNOW)
+ _mesa_x86_cpu_features |= X86_FEATURE_3DNOW;
+ if (cpu_ext_features & X86_CPUEXT_3DNOW_EXT)
+ _mesa_x86_cpu_features |= X86_FEATURE_3DNOWEXT;
+#endif
+
+#ifdef USE_MMX_ASM
+ if (cpu_ext_features & X86_CPUEXT_MMX_EXT)
+ _mesa_x86_cpu_features |= X86_FEATURE_MMXEXT;
+#endif
+ }
+ }
+
+ /* query cpu name */
+ if (cpu_ext_info >= 0x80000002) {
+ GLuint ofs;
+ char cpu_name[49];
+ for (ofs = 0; ofs < 3; ofs++)
+ _mesa_x86_cpuid(0x80000002+ofs, (GLuint *)(cpu_name + (16*ofs)+0), (GLuint *)(cpu_name + (16*ofs)+4), (GLuint *)(cpu_name + (16*ofs)+8), (GLuint *)(cpu_name + (16*ofs)+12));
+ cpu_name[48] = '\0'; /* the name should be NULL terminated, but just to be sure */
+
+ message("cpu name: ");
+ message(cpu_name);
+ message("\n");
+ }
+ }
+
+ }
+
+ if ( _mesa_getenv( "MESA_NO_ASM" ) ) {
+ _mesa_x86_cpu_features = 0;
+ }
+
+ if ( _mesa_x86_cpu_features ) {
+ _mesa_init_x86_transform_asm();
+ }
+
+#ifdef USE_MMX_ASM
+ if ( cpu_has_mmx ) {
+ if ( _mesa_getenv( "MESA_NO_MMX" ) == 0 ) {
+ message( "MMX cpu detected.\n" );
+ } else {
+ _mesa_x86_cpu_features &= ~(X86_FEATURE_MMX);
+ }
+ }
+#endif
+
+#ifdef USE_3DNOW_ASM
+ if ( cpu_has_3dnow ) {
+ if ( _mesa_getenv( "MESA_NO_3DNOW" ) == 0 ) {
+ message( "3DNow! cpu detected.\n" );
+ _mesa_init_3dnow_transform_asm();
+ } else {
+ _mesa_x86_cpu_features &= ~(X86_FEATURE_3DNOW);
+ }
+ }
+#endif
+
+#ifdef USE_SSE_ASM
+ if ( cpu_has_xmm ) {
+ if ( _mesa_getenv( "MESA_NO_SSE" ) == 0 ) {
+ message( "SSE cpu detected.\n" );
+ if ( _mesa_getenv( "MESA_FORCE_SSE" ) == 0 ) {
+ check_os_sse_support();
+ }
+ if ( cpu_has_xmm ) {
+ _mesa_init_sse_transform_asm();
+ }
+ } else {
+ message( "SSE cpu detected, but switched off by user.\n" );
+ _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM);
+ }
+ }
+#endif
+#endif
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/common_x86_asm.S b/nx-X11/extras/Mesa/src/mesa/x86/common_x86_asm.S
new file mode 100644
index 000000000..654b3469d
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/common_x86_asm.S
@@ -0,0 +1,215 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+/*
+ * Check extended CPU capabilities. Now justs returns the raw CPUID
+ * feature information, allowing the higher level code to interpret the
+ * results.
+ *
+ * Written by Holger Waechtler <holger@akaflieg.extern.tu-berlin.de>
+ *
+ * Cleaned up and simplified by Gareth Hughes <gareth@valinux.com>
+ *
+ */
+
+/*
+ * NOTE: Avoid using spaces in between '(' ')' and arguments, especially
+ * with macros like CONST, LLBL that expand to CONCAT(...). Putting spaces
+ * in there will break the build on some platforms.
+ */
+
+#include "matypes.h"
+#include "common_x86_features.h"
+
+ SEG_TEXT
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_x86_has_cpuid)
+HIDDEN(_mesa_x86_has_cpuid)
+GLNAME(_mesa_x86_has_cpuid):
+
+ /* Test for the CPUID command. If the ID Flag bit in EFLAGS
+ * (bit 21) is writable, the CPUID command is present */
+ PUSHF_L
+ POP_L (EAX)
+ MOV_L (EAX, ECX)
+ XOR_L (CONST(0x00200000), EAX)
+ PUSH_L (EAX)
+ POPF_L
+ PUSHF_L
+ POP_L (EAX)
+
+ /* Verify the ID Flag bit has been written. */
+ CMP_L (ECX, EAX)
+ SETNE (AL)
+ XOR_L (CONST(0xff), EAX)
+
+ RET
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_x86_cpuid)
+HIDDEN(_mesa_x86_cpuid)
+GLNAME(_mesa_x86_cpuid):
+
+ MOV_L (REGOFF(4, ESP), EAX) /* cpuid op */
+ PUSH_L (EDI)
+ PUSH_L (EBX)
+
+ CPUID
+
+ MOV_L (REGOFF(16, ESP), EDI) /* *eax */
+ MOV_L (EAX, REGIND(EDI))
+ MOV_L (REGOFF(20, ESP), EDI) /* *ebx */
+ MOV_L (EBX, REGIND(EDI))
+ MOV_L (REGOFF(24, ESP), EDI) /* *ecx */
+ MOV_L (ECX, REGIND(EDI))
+ MOV_L (REGOFF(28, ESP), EDI) /* *edx */
+ MOV_L (EDX, REGIND(EDI))
+
+ POP_L (EBX)
+ POP_L (EDI)
+ RET
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_x86_cpuid_eax)
+HIDDEN(_mesa_x86_cpuid_eax)
+GLNAME(_mesa_x86_cpuid_eax):
+
+ MOV_L (REGOFF(4, ESP), EAX) /* cpuid op */
+ PUSH_L (EBX)
+
+ CPUID
+
+ POP_L (EBX)
+ RET
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_x86_cpuid_ebx)
+HIDDEN(_mesa_x86_cpuid_ebx)
+GLNAME(_mesa_x86_cpuid_ebx):
+
+ MOV_L (REGOFF(4, ESP), EAX) /* cpuid op */
+ PUSH_L (EBX)
+
+ CPUID
+ MOV_L (EBX, EAX) /* return EBX */
+
+ POP_L (EBX)
+ RET
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_x86_cpuid_ecx)
+HIDDEN(_mesa_x86_cpuid_ecx)
+GLNAME(_mesa_x86_cpuid_ecx):
+
+ MOV_L (REGOFF(4, ESP), EAX) /* cpuid op */
+ PUSH_L (EBX)
+
+ CPUID
+ MOV_L (ECX, EAX) /* return ECX */
+
+ POP_L (EBX)
+ RET
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_x86_cpuid_edx)
+HIDDEN(_mesa_x86_cpuid_edx)
+GLNAME(_mesa_x86_cpuid_edx):
+
+ MOV_L (REGOFF(4, ESP), EAX) /* cpuid op */
+ PUSH_L (EBX)
+
+ CPUID
+ MOV_L (EDX, EAX) /* return EDX */
+
+ POP_L (EBX)
+ RET
+
+#ifdef USE_SSE_ASM
+/* Execute an SSE instruction to see if the operating system correctly
+ * supports SSE. A signal handler for SIGILL should have been set
+ * before calling this function, otherwise this could kill the client
+ * application.
+ *
+ * -----> !!!! ATTENTION DEVELOPERS !!!! <-----
+ *
+ * If you're debugging with gdb and you get stopped in this function,
+ * just type 'continue'! Execution will proceed normally.
+ * See freedesktop.org bug #1709 for more info.
+ */
+ALIGNTEXT4
+GLOBL GLNAME( _mesa_test_os_sse_support )
+HIDDEN(_mesa_test_os_sse_support)
+GLNAME( _mesa_test_os_sse_support ):
+
+ XORPS ( XMM0, XMM0 )
+
+ RET
+
+
+/* Perform an SSE divide-by-zero to see if the operating system
+ * correctly supports unmasked SIMD FPU exceptions. Signal handlers for
+ * SIGILL and SIGFPE should have been set before calling this function,
+ * otherwise this could kill the client application.
+ */
+ALIGNTEXT4
+GLOBL GLNAME( _mesa_test_os_sse_exception_support )
+HIDDEN(_mesa_test_os_sse_exception_support)
+GLNAME( _mesa_test_os_sse_exception_support ):
+
+ PUSH_L ( EBP )
+ MOV_L ( ESP, EBP )
+ SUB_L ( CONST( 8 ), ESP )
+
+ /* Save the original MXCSR register value.
+ */
+ STMXCSR ( REGOFF( -4, EBP ) )
+
+ /* Unmask the divide-by-zero exception and perform one.
+ */
+ STMXCSR ( REGOFF( -8, EBP ) )
+ AND_L ( CONST( 0xfffffdff ), REGOFF( -8, EBP ) )
+ LDMXCSR ( REGOFF( -8, EBP ) )
+
+ XORPS ( XMM0, XMM0 )
+
+ PUSH_L ( CONST( 0x3f800000 ) )
+ PUSH_L ( CONST( 0x3f800000 ) )
+ PUSH_L ( CONST( 0x3f800000 ) )
+ PUSH_L ( CONST( 0x3f800000 ) )
+
+ MOVUPS ( REGIND( ESP ), XMM1 )
+
+ DIVPS ( XMM0, XMM1 )
+
+ /* Restore the original MXCSR register value.
+ */
+ LDMXCSR ( REGOFF( -4, EBP ) )
+
+ LEAVE
+ RET
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/common_x86_asm.h b/nx-X11/extras/Mesa/src/mesa/x86/common_x86_asm.h
new file mode 100644
index 000000000..a59585abe
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/common_x86_asm.h
@@ -0,0 +1,60 @@
+/* $Id: common_x86_asm.h,v 1.1.1.2 2005/07/31 16:46:39 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * Check CPU capabilities & initialize optimized funtions for this particular
+ * processor.
+ *
+ * Written by Holger Waechtler <holger@akaflieg.extern.tu-berlin.de>
+ * Changed by Andre Werthmann <wertmann@cs.uni-potsdam.de> for using the
+ * new SSE functions
+ *
+ * Reimplemented by Gareth Hughes in a more
+ * future-proof manner, based on code in the Linux kernel.
+ */
+
+#ifndef __COMMON_X86_ASM_H__
+#define __COMMON_X86_ASM_H__
+
+/* Do not reference mtypes.h from this file.
+ */
+#include "common_x86_features.h"
+
+#ifdef USE_X86_ASM
+#include "x86.h"
+#ifdef USE_3DNOW_ASM
+#include "3dnow.h"
+#endif
+#ifdef USE_SSE_ASM
+#include "sse.h"
+#endif
+#endif
+
+extern int _mesa_x86_cpu_features;
+
+extern void _mesa_init_all_x86_transform_asm( void );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/common_x86_features.h b/nx-X11/extras/Mesa/src/mesa/x86/common_x86_features.h
new file mode 100644
index 000000000..d6f488fc7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/common_x86_features.h
@@ -0,0 +1,68 @@
+/* $Id: common_x86_features.h,v 1.1.1.1 2004/06/16 09:19:36 anholt Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2001 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 CPUID feature information. The raw data is returned by
+ * _mesa_identify_x86_cpu_features() and interpreted with the cpu_has_*
+ * helper macros.
+ *
+ * Gareth Hughes
+ */
+
+#ifndef __COMMON_X86_FEATURES_H__
+#define __COMMON_X86_FEATURES_H__
+
+#define X86_FEATURE_FPU (1<<0)
+#define X86_FEATURE_CMOV (1<<1)
+#define X86_FEATURE_MMXEXT (1<<2)
+#define X86_FEATURE_MMX (1<<3)
+#define X86_FEATURE_FXSR (1<<4)
+#define X86_FEATURE_XMM (1<<5)
+#define X86_FEATURE_XMM2 (1<<6)
+#define X86_FEATURE_3DNOWEXT (1<<7)
+#define X86_FEATURE_3DNOW (1<<8)
+
+/* standard X86 CPU features */
+#define X86_CPU_FPU (1<<0)
+#define X86_CPU_CMOV (1<<15)
+#define X86_CPU_MMX (1<<23)
+#define X86_CPU_XMM (1<<25)
+#define X86_CPU_XMM2 (1<<26)
+
+/* extended X86 CPU features */
+#define X86_CPUEXT_MMX_EXT (1<<22)
+#define X86_CPUEXT_3DNOW_EXT (1<<30)
+#define X86_CPUEXT_3DNOW (1<<31)
+
+#define cpu_has_mmx (_mesa_x86_cpu_features & X86_FEATURE_MMX)
+#define cpu_has_mmxext (_mesa_x86_cpu_features & X86_FEATURE_MMXEXT)
+#define cpu_has_xmm (_mesa_x86_cpu_features & X86_FEATURE_XMM)
+#define cpu_has_xmm2 (_mesa_x86_cpu_features & X86_FEATURE_XMM2)
+#define cpu_has_3dnow (_mesa_x86_cpu_features & X86_FEATURE_3DNOW)
+#define cpu_has_3dnowext (_mesa_x86_cpu_features & X86_FEATURE_3DNOWEXT)
+
+#endif
+
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/common_x86_macros.h b/nx-X11/extras/Mesa/src/mesa/x86/common_x86_macros.h
new file mode 100644
index 000000000..8741ff11b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/common_x86_macros.h
@@ -0,0 +1,107 @@
+/* $Id: common_x86_macros.h,v 1.1.1.1 2004/06/16 09:19:36 anholt Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ *
+ * Authors:
+ * Gareth Hughes
+ */
+
+#ifndef __COMMON_X86_MACROS_H__
+#define __COMMON_X86_MACROS_H__
+
+
+/* =============================================================
+ * Transformation function declarations:
+ */
+
+#define XFORM_ARGS GLvector4f *to_vec, \
+ const GLfloat m[16], \
+ const GLvector4f *from_vec
+
+#define DECLARE_XFORM_GROUP( pfx, sz ) \
+extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_general( XFORM_ARGS ); \
+extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_identity( XFORM_ARGS ); \
+extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_3d_no_rot( XFORM_ARGS ); \
+extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_perspective( XFORM_ARGS ); \
+extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_2d( XFORM_ARGS ); \
+extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_2d_no_rot( XFORM_ARGS ); \
+extern void _ASMAPI _mesa_##pfx##_transform_points##sz##_3d( XFORM_ARGS );
+
+#define ASSIGN_XFORM_GROUP( pfx, sz ) \
+ _mesa_transform_tab[sz][MATRIX_GENERAL] = \
+ _mesa_##pfx##_transform_points##sz##_general; \
+ _mesa_transform_tab[sz][MATRIX_IDENTITY] = \
+ _mesa_##pfx##_transform_points##sz##_identity; \
+ _mesa_transform_tab[sz][MATRIX_3D_NO_ROT] = \
+ _mesa_##pfx##_transform_points##sz##_3d_no_rot; \
+ _mesa_transform_tab[sz][MATRIX_PERSPECTIVE] = \
+ _mesa_##pfx##_transform_points##sz##_perspective; \
+ _mesa_transform_tab[sz][MATRIX_2D] = \
+ _mesa_##pfx##_transform_points##sz##_2d; \
+ _mesa_transform_tab[sz][MATRIX_2D_NO_ROT] = \
+ _mesa_##pfx##_transform_points##sz##_2d_no_rot; \
+ _mesa_transform_tab[sz][MATRIX_3D] = \
+ _mesa_##pfx##_transform_points##sz##_3d;
+
+
+/* =============================================================
+ * Normal transformation function declarations:
+ */
+
+#define NORM_ARGS const GLmatrix *mat, \
+ GLfloat scale, \
+ const GLvector4f *in, \
+ const GLfloat *lengths, \
+ GLvector4f *dest
+
+#define DECLARE_NORM_GROUP( pfx ) \
+extern void _ASMAPI _mesa_##pfx##_rescale_normals( NORM_ARGS ); \
+extern void _ASMAPI _mesa_##pfx##_normalize_normals( NORM_ARGS ); \
+extern void _ASMAPI _mesa_##pfx##_transform_normals( NORM_ARGS ); \
+extern void _ASMAPI _mesa_##pfx##_transform_normals_no_rot( NORM_ARGS ); \
+extern void _ASMAPI _mesa_##pfx##_transform_rescale_normals( NORM_ARGS ); \
+extern void _ASMAPI _mesa_##pfx##_transform_rescale_normals_no_rot( NORM_ARGS ); \
+extern void _ASMAPI _mesa_##pfx##_transform_normalize_normals( NORM_ARGS ); \
+extern void _ASMAPI _mesa_##pfx##_transform_normalize_normals_no_rot( NORM_ARGS );
+
+#define ASSIGN_NORM_GROUP( pfx ) \
+ _mesa_normal_tab[NORM_RESCALE] = \
+ _mesa_##pfx##_rescale_normals; \
+ _mesa_normal_tab[NORM_NORMALIZE] = \
+ _mesa_##pfx##_normalize_normals; \
+ _mesa_normal_tab[NORM_TRANSFORM] = \
+ _mesa_##pfx##_transform_normals; \
+ _mesa_normal_tab[NORM_TRANSFORM_NO_ROT] = \
+ _mesa_##pfx##_transform_normals_no_rot; \
+ _mesa_normal_tab[NORM_TRANSFORM | NORM_RESCALE] = \
+ _mesa_##pfx##_transform_rescale_normals; \
+ _mesa_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_RESCALE] = \
+ _mesa_##pfx##_transform_rescale_normals_no_rot; \
+ _mesa_normal_tab[NORM_TRANSFORM | NORM_NORMALIZE] = \
+ _mesa_##pfx##_transform_normalize_normals; \
+ _mesa_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_NORMALIZE] = \
+ _mesa_##pfx##_transform_normalize_normals_no_rot;
+
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/gen_matypes.c b/nx-X11/extras/Mesa/src/mesa/x86/gen_matypes.c
new file mode 100644
index 000000000..d5cee5347
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/gen_matypes.c
@@ -0,0 +1,251 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 5.1
+ *
+ * Copyright (C) 1999-2003 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.
+ *
+ * Authors:
+ * Gareth Hughes
+ */
+
+/*
+ * This generates an asm version of mtypes.h (called matypes.h), so that
+ * Mesa's x86 assembly code can access the internal structures easily.
+ * This will be particularly useful when developing new x86 asm code for
+ * Mesa, including lighting, clipping, texture image conversion etc.
+ */
+
+#include "main/glheader.h"
+#include "main/mtypes.h"
+#include "tnl/t_context.h"
+
+
+#undef offsetof
+#define offsetof( type, member ) ((size_t) &((type *)0)->member)
+
+
+#define OFFSET_HEADER( x ) \
+do { \
+ printf( "\n" ); \
+ printf( "\n" ); \
+ printf( "/* =====================================================" \
+ "========\n" ); \
+ printf( " * Offsets for %s\n", x ); \
+ printf( " */\n" ); \
+ printf( "\n" ); \
+} while (0)
+
+#define DEFINE_HEADER( x ) \
+do { \
+ printf( "\n" ); \
+ printf( "/*\n" ); \
+ printf( " * Flags for %s\n", x ); \
+ printf( " */\n" ); \
+ printf( "\n" ); \
+} while (0)
+
+#if defined(__BEOS__) || defined(_LP64)
+#define OFFSET( s, t, m ) \
+ printf( "#define %s\t%ld\n", s, offsetof( t, m ) );
+#else
+#define OFFSET( s, t, m ) \
+ printf( "#define %s\t%d\n", s, offsetof( t, m ) );
+#endif
+
+#if defined(__BEOS__) || defined(_LP64)
+#define SIZEOF( s, t ) \
+ printf( "#define %s\t%ld\n", s, sizeof(t) );
+#else
+#define SIZEOF( s, t ) \
+ printf( "#define %s\t%d\n", s, sizeof(t) );
+#endif
+
+#define DEFINE( s, d ) \
+ printf( "#define %s\t0x%x\n", s, d );
+
+
+
+int main( int argc, char **argv )
+{
+ printf( "/*\n" );
+ printf( " * This file is automatically generated from the Mesa internal type\n" );
+ printf( " * definitions. Do not edit directly.\n" );
+ printf( " */\n" );
+ printf( "\n" );
+ printf( "#ifndef __ASM_TYPES_H__\n" );
+ printf( "#define __ASM_TYPES_H__\n" );
+ printf( "\n" );
+ printf( "#include \"assyntax.h\"\n" );
+
+
+ /* GLcontext offsets:
+ */
+ OFFSET_HEADER( "GLcontext" );
+
+ OFFSET( "CTX_DRIVER_CTX ", GLcontext, DriverCtx );
+ printf( "\n" );
+ OFFSET( "CTX_LIGHT_ENABLED ", GLcontext, Light.Enabled );
+ OFFSET( "CTX_LIGHT_SHADE_MODEL ", GLcontext, Light.ShadeModel );
+ OFFSET( "CTX_LIGHT_COLOR_MAT_FACE ", GLcontext, Light.ColorMaterialFace );
+ OFFSET( "CTX_LIGHT_COLOR_MAT_MODE ", GLcontext, Light.ColorMaterialMode );
+ OFFSET( "CTX_LIGHT_COLOR_MAT_MASK ", GLcontext, Light.ColorMaterialBitmask );
+ OFFSET( "CTX_LIGHT_COLOR_MAT_ENABLED ", GLcontext, Light.ColorMaterialEnabled );
+ OFFSET( "CTX_LIGHT_ENABLED_LIST ", GLcontext, Light.EnabledList );
+ OFFSET( "CTX_LIGHT_NEED_VERTS ", GLcontext, Light._NeedVertices );
+ OFFSET( "CTX_LIGHT_FLAGS ", GLcontext, Light._Flags );
+ OFFSET( "CTX_LIGHT_BASE_COLOR ", GLcontext, Light._BaseColor );
+
+
+ /* struct vertex_buffer offsets:
+ */
+ OFFSET_HEADER( "struct vertex_buffer" );
+
+ OFFSET( "VB_SIZE ", struct vertex_buffer, Size );
+ OFFSET( "VB_COUNT ", struct vertex_buffer, Count );
+ printf( "\n" );
+ OFFSET( "VB_ELTS ", struct vertex_buffer, Elts );
+ OFFSET( "VB_OBJ_PTR ", struct vertex_buffer, ObjPtr );
+ OFFSET( "VB_EYE_PTR ", struct vertex_buffer, EyePtr );
+ OFFSET( "VB_CLIP_PTR ", struct vertex_buffer, ClipPtr );
+ OFFSET( "VB_PROJ_CLIP_PTR ", struct vertex_buffer, NdcPtr );
+ OFFSET( "VB_CLIP_OR_MASK ", struct vertex_buffer, ClipOrMask );
+ OFFSET( "VB_CLIP_MASK ", struct vertex_buffer, ClipMask );
+ OFFSET( "VB_NORMAL_PTR ", struct vertex_buffer, NormalPtr );
+ OFFSET( "VB_EDGE_FLAG ", struct vertex_buffer, EdgeFlag );
+ OFFSET( "VB_TEX0_COORD_PTR ", struct vertex_buffer, TexCoordPtr[0] );
+ OFFSET( "VB_TEX1_COORD_PTR ", struct vertex_buffer, TexCoordPtr[1] );
+ OFFSET( "VB_TEX2_COORD_PTR ", struct vertex_buffer, TexCoordPtr[2] );
+ OFFSET( "VB_TEX3_COORD_PTR ", struct vertex_buffer, TexCoordPtr[3] );
+ OFFSET( "VB_INDEX_PTR ", struct vertex_buffer, IndexPtr );
+ OFFSET( "VB_COLOR_PTR ", struct vertex_buffer, ColorPtr );
+ OFFSET( "VB_SECONDARY_COLOR_PTR ", struct vertex_buffer, SecondaryColorPtr );
+ OFFSET( "VB_FOG_COORD_PTR ", struct vertex_buffer, FogCoordPtr );
+ OFFSET( "VB_POINT_SIZE_PTR ", struct vertex_buffer, PointSizePtr );
+ OFFSET( "VB_PRIMITIVE ", struct vertex_buffer, Primitive );
+ printf( "\n" );
+ OFFSET( "VB_LAST_CLIPPED ", struct vertex_buffer, LastClipped );
+
+ DEFINE_HEADER( "struct vertex_buffer" );
+
+ /* XXX use new labels here someday after vertex proram is done */
+ DEFINE( "VERT_BIT_OBJ ", VERT_BIT_POS );
+ DEFINE( "VERT_BIT_NORM ", VERT_BIT_NORMAL );
+ DEFINE( "VERT_BIT_RGBA ", VERT_BIT_COLOR0 );
+ DEFINE( "VERT_BIT_SPEC_RGB ", VERT_BIT_COLOR1 );
+ DEFINE( "VERT_BIT_FOG_COORD ", VERT_BIT_FOG );
+ DEFINE( "VERT_BIT_TEX0 ", VERT_BIT_TEX0 );
+ DEFINE( "VERT_BIT_TEX1 ", VERT_BIT_TEX1 );
+ DEFINE( "VERT_BIT_TEX2 ", VERT_BIT_TEX2 );
+ DEFINE( "VERT_BIT_TEX3 ", VERT_BIT_TEX3 );
+
+
+ /* GLvector4f offsets:
+ */
+ OFFSET_HEADER( "GLvector4f" );
+
+ OFFSET( "V4F_DATA ", GLvector4f, data );
+ OFFSET( "V4F_START ", GLvector4f, start );
+ OFFSET( "V4F_COUNT ", GLvector4f, count );
+ OFFSET( "V4F_STRIDE ", GLvector4f, stride );
+ OFFSET( "V4F_SIZE ", GLvector4f, size );
+ OFFSET( "V4F_FLAGS ", GLvector4f, flags );
+
+ DEFINE_HEADER( "GLvector4f" );
+
+ DEFINE( "VEC_MALLOC ", VEC_MALLOC );
+ DEFINE( "VEC_NOT_WRITEABLE ", VEC_NOT_WRITEABLE );
+ DEFINE( "VEC_BAD_STRIDE ", VEC_BAD_STRIDE );
+ printf( "\n" );
+ DEFINE( "VEC_SIZE_1 ", VEC_SIZE_1 );
+ DEFINE( "VEC_SIZE_2 ", VEC_SIZE_2 );
+ DEFINE( "VEC_SIZE_3 ", VEC_SIZE_3 );
+ DEFINE( "VEC_SIZE_4 ", VEC_SIZE_4 );
+
+
+ /* GLmatrix offsets:
+ */
+ OFFSET_HEADER( "GLmatrix" );
+
+ OFFSET( "MATRIX_DATA ", GLmatrix, m );
+ OFFSET( "MATRIX_INV ", GLmatrix, inv );
+ OFFSET( "MATRIX_FLAGS ", GLmatrix, flags );
+ OFFSET( "MATRIX_TYPE ", GLmatrix, type );
+
+
+ /* struct gl_light offsets:
+ */
+ OFFSET_HEADER( "struct gl_light" );
+
+ OFFSET( "LIGHT_NEXT ", struct gl_light, next );
+ OFFSET( "LIGHT_PREV ", struct gl_light, prev );
+ printf( "\n" );
+ OFFSET( "LIGHT_AMBIENT ", struct gl_light, Ambient );
+ OFFSET( "LIGHT_DIFFUSE ", struct gl_light, Diffuse );
+ OFFSET( "LIGHT_SPECULAR ", struct gl_light, Specular );
+ OFFSET( "LIGHT_EYE_POSITION ", struct gl_light, EyePosition );
+ OFFSET( "LIGHT_EYE_DIRECTION ", struct gl_light, EyeDirection );
+ OFFSET( "LIGHT_SPOT_EXPONENT ", struct gl_light, SpotExponent );
+ OFFSET( "LIGHT_SPOT_CUTOFF ", struct gl_light, SpotCutoff );
+ OFFSET( "LIGHT_COS_CUTOFF ", struct gl_light, _CosCutoff );
+ OFFSET( "LIGHT_CONST_ATTEN ", struct gl_light, ConstantAttenuation );
+ OFFSET( "LIGHT_LINEAR_ATTEN ", struct gl_light, LinearAttenuation );
+ OFFSET( "LIGHT_QUADRATIC_ATTEN ", struct gl_light, QuadraticAttenuation );
+ OFFSET( "LIGHT_ENABLED ", struct gl_light, Enabled );
+ printf( "\n" );
+ OFFSET( "LIGHT_FLAGS ", struct gl_light, _Flags );
+ printf( "\n" );
+ OFFSET( "LIGHT_POSITION ", struct gl_light, _Position );
+ OFFSET( "LIGHT_VP_INF_NORM ", struct gl_light, _VP_inf_norm );
+ OFFSET( "LIGHT_H_INF_NORM ", struct gl_light, _h_inf_norm );
+ OFFSET( "LIGHT_NORM_DIRECTION ", struct gl_light, _NormDirection );
+ OFFSET( "LIGHT_VP_INF_SPOT_ATTEN ", struct gl_light, _VP_inf_spot_attenuation );
+ printf( "\n" );
+ OFFSET( "LIGHT_SPOT_EXP_TABLE ", struct gl_light, _SpotExpTable );
+ OFFSET( "LIGHT_MAT_AMBIENT ", struct gl_light, _MatAmbient );
+ OFFSET( "LIGHT_MAT_DIFFUSE ", struct gl_light, _MatDiffuse );
+ OFFSET( "LIGHT_MAT_SPECULAR ", struct gl_light, _MatSpecular );
+ printf( "\n" );
+ SIZEOF( "SIZEOF_GL_LIGHT ", struct gl_light );
+
+ DEFINE_HEADER( "struct gl_light" );
+
+ DEFINE( "LIGHT_SPOT ", LIGHT_SPOT );
+ DEFINE( "LIGHT_LOCAL_VIEWER ", LIGHT_LOCAL_VIEWER );
+ DEFINE( "LIGHT_POSITIONAL ", LIGHT_POSITIONAL );
+ printf( "\n" );
+ DEFINE( "LIGHT_NEED_VERTICES ", LIGHT_NEED_VERTICES );
+
+
+ /* struct gl_lightmodel offsets:
+ */
+ OFFSET_HEADER( "struct gl_lightmodel" );
+
+ OFFSET( "LIGHT_MODEL_AMBIENT ", struct gl_lightmodel, Ambient );
+ OFFSET( "LIGHT_MODEL_LOCAL_VIEWER ", struct gl_lightmodel, LocalViewer );
+ OFFSET( "LIGHT_MODEL_TWO_SIDE ", struct gl_lightmodel, TwoSide );
+ OFFSET( "LIGHT_MODEL_COLOR_CONTROL ", struct gl_lightmodel, ColorControl );
+
+
+ printf( "\n" );
+ printf( "\n" );
+ printf( "#endif /* __ASM_TYPES_H__ */\n" );
+
+ return 0;
+}
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/glapi_x86.S b/nx-X11/extras/Mesa/src/mesa/x86/glapi_x86.S
new file mode 100644
index 000000000..231027ed6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/glapi_x86.S
@@ -0,0 +1,1155 @@
+/* DO NOT EDIT - This file generated automatically by gl_x86_asm.py (from Mesa) script */
+
+/*
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * (C) Copyright IBM Corporation 2004, 2005
+ * 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
+ * BRIAN PAUL, IBM,
+ * AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
+ * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include "assyntax.h"
+#include "glapioffsets.h"
+
+#if defined(STDCALL_API)
+# if defined(USE_MGL_NAMESPACE)
+# define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n2))
+# else
+# define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n2))
+# endif
+#else
+# if defined(USE_MGL_NAMESPACE)
+# define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n))
+# else
+# define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n))
+# endif
+#endif
+
+#define GL_OFFSET(x) CODEPTR(REGOFF(4 * x, EAX))
+
+#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__)
+#define GLOBL_FN(x) GLOBL x ; .type x, function
+#else
+#define GLOBL_FN(x) GLOBL x
+#endif
+
+#if defined(PTHREADS) || defined(USE_XTHREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)
+# define THREADS
+#endif
+
+#ifdef GLX_USE_TLS
+
+# define GL_STUB(fn,off,fn_alt) \
+ALIGNTEXT16; \
+GLOBL_FN(GL_PREFIX(fn, fn_alt)); \
+GL_PREFIX(fn, fn_alt): \
+ CALL(_x86_get_dispatch) ; \
+ NOP ; \
+ JMP(GL_OFFSET(off))
+
+#elif defined(PTHREADS)
+# define GL_STUB(fn,off,fn_alt) \
+ALIGNTEXT16; \
+GLOBL_FN(GL_PREFIX(fn, fn_alt)); \
+GL_PREFIX(fn, fn_alt): \
+ MOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ; \
+ TEST_L(EAX, EAX) ; \
+ JE(1f) ; \
+ JMP(GL_OFFSET(off)) ; \
+1: CALL(_x86_get_dispatch) ; \
+ JMP(GL_OFFSET(off))
+#elif defined(THREADS)
+# define GL_STUB(fn,off,fn_alt) \
+ALIGNTEXT16; \
+GLOBL_FN(GL_PREFIX(fn, fn_alt)); \
+GL_PREFIX(fn, fn_alt): \
+ MOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ; \
+ TEST_L(EAX, EAX) ; \
+ JE(1f) ; \
+ JMP(GL_OFFSET(off)) ; \
+1: CALL(_glapi_get_dispatch) ; \
+ JMP(GL_OFFSET(off))
+#else /* Non-threaded version. */
+# define GL_STUB(fn,off,fn_alt) \
+ALIGNTEXT16; \
+GLOBL_FN(GL_PREFIX(fn, fn_alt)); \
+GL_PREFIX(fn, fn_alt): \
+ MOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ; \
+ JMP(GL_OFFSET(off))
+#endif
+
+#ifdef HAVE_ALIAS
+# define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt) \
+ .globl GL_PREFIX(fn, fn_alt) ; \
+ .set GL_PREFIX(fn, fn_alt), GL_PREFIX(alias, alias_alt)
+#else
+# define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt) \
+ GL_STUB(fn, off, fn_alt)
+#endif
+
+SEG_TEXT
+
+#ifdef GLX_USE_TLS
+
+ GLOBL GLNAME(_x86_get_dispatch)
+ HIDDEN(GLNAME(_x86_get_dispatch))
+ALIGNTEXT16
+GLNAME(_x86_get_dispatch):
+ movl %gs:_glapi_tls_Dispatch@NTPOFF, %eax
+ ret
+
+#elif defined(PTHREADS)
+EXTERN GLNAME(_glapi_Dispatch)
+EXTERN GLNAME(_gl_DispatchTSD)
+EXTERN GLNAME(pthread_getspecific)
+
+ALIGNTEXT16
+GLNAME(_x86_get_dispatch):
+ SUB_L(CONST(24), ESP)
+ PUSH_L(GLNAME(_gl_DispatchTSD))
+ CALL(GLNAME(pthread_getspecific))
+ ADD_L(CONST(28), ESP)
+ RET
+#elif defined(THREADS)
+EXTERN GLNAME(_glapi_get_dispatch)
+#endif
+
+#if defined( GLX_USE_TLS )
+ .section wtext, "awx", @progbits
+#endif /* defined( GLX_USE_TLS ) */
+
+ ALIGNTEXT16
+ GLOBL GLNAME(gl_dispatch_functions_start)
+ HIDDEN(GLNAME(gl_dispatch_functions_start))
+GLNAME(gl_dispatch_functions_start):
+
+ GL_STUB(NewList, _gloffset_NewList, NewList@8)
+ GL_STUB(EndList, _gloffset_EndList, EndList@0)
+ GL_STUB(CallList, _gloffset_CallList, CallList@4)
+ GL_STUB(CallLists, _gloffset_CallLists, CallLists@12)
+ GL_STUB(DeleteLists, _gloffset_DeleteLists, DeleteLists@8)
+ GL_STUB(GenLists, _gloffset_GenLists, GenLists@4)
+ GL_STUB(ListBase, _gloffset_ListBase, ListBase@4)
+ GL_STUB(Begin, _gloffset_Begin, Begin@4)
+ GL_STUB(Bitmap, _gloffset_Bitmap, Bitmap@28)
+ GL_STUB(Color3b, _gloffset_Color3b, Color3b@12)
+ GL_STUB(Color3bv, _gloffset_Color3bv, Color3bv@4)
+ GL_STUB(Color3d, _gloffset_Color3d, Color3d@24)
+ GL_STUB(Color3dv, _gloffset_Color3dv, Color3dv@4)
+ GL_STUB(Color3f, _gloffset_Color3f, Color3f@12)
+ GL_STUB(Color3fv, _gloffset_Color3fv, Color3fv@4)
+ GL_STUB(Color3i, _gloffset_Color3i, Color3i@12)
+ GL_STUB(Color3iv, _gloffset_Color3iv, Color3iv@4)
+ GL_STUB(Color3s, _gloffset_Color3s, Color3s@12)
+ GL_STUB(Color3sv, _gloffset_Color3sv, Color3sv@4)
+ GL_STUB(Color3ub, _gloffset_Color3ub, Color3ub@12)
+ GL_STUB(Color3ubv, _gloffset_Color3ubv, Color3ubv@4)
+ GL_STUB(Color3ui, _gloffset_Color3ui, Color3ui@12)
+ GL_STUB(Color3uiv, _gloffset_Color3uiv, Color3uiv@4)
+ GL_STUB(Color3us, _gloffset_Color3us, Color3us@12)
+ GL_STUB(Color3usv, _gloffset_Color3usv, Color3usv@4)
+ GL_STUB(Color4b, _gloffset_Color4b, Color4b@16)
+ GL_STUB(Color4bv, _gloffset_Color4bv, Color4bv@4)
+ GL_STUB(Color4d, _gloffset_Color4d, Color4d@32)
+ GL_STUB(Color4dv, _gloffset_Color4dv, Color4dv@4)
+ GL_STUB(Color4f, _gloffset_Color4f, Color4f@16)
+ GL_STUB(Color4fv, _gloffset_Color4fv, Color4fv@4)
+ GL_STUB(Color4i, _gloffset_Color4i, Color4i@16)
+ GL_STUB(Color4iv, _gloffset_Color4iv, Color4iv@4)
+ GL_STUB(Color4s, _gloffset_Color4s, Color4s@16)
+ GL_STUB(Color4sv, _gloffset_Color4sv, Color4sv@4)
+ GL_STUB(Color4ub, _gloffset_Color4ub, Color4ub@16)
+ GL_STUB(Color4ubv, _gloffset_Color4ubv, Color4ubv@4)
+ GL_STUB(Color4ui, _gloffset_Color4ui, Color4ui@16)
+ GL_STUB(Color4uiv, _gloffset_Color4uiv, Color4uiv@4)
+ GL_STUB(Color4us, _gloffset_Color4us, Color4us@16)
+ GL_STUB(Color4usv, _gloffset_Color4usv, Color4usv@4)
+ GL_STUB(EdgeFlag, _gloffset_EdgeFlag, EdgeFlag@4)
+ GL_STUB(EdgeFlagv, _gloffset_EdgeFlagv, EdgeFlagv@4)
+ GL_STUB(End, _gloffset_End, End@0)
+ GL_STUB(Indexd, _gloffset_Indexd, Indexd@8)
+ GL_STUB(Indexdv, _gloffset_Indexdv, Indexdv@4)
+ GL_STUB(Indexf, _gloffset_Indexf, Indexf@4)
+ GL_STUB(Indexfv, _gloffset_Indexfv, Indexfv@4)
+ GL_STUB(Indexi, _gloffset_Indexi, Indexi@4)
+ GL_STUB(Indexiv, _gloffset_Indexiv, Indexiv@4)
+ GL_STUB(Indexs, _gloffset_Indexs, Indexs@4)
+ GL_STUB(Indexsv, _gloffset_Indexsv, Indexsv@4)
+ GL_STUB(Normal3b, _gloffset_Normal3b, Normal3b@12)
+ GL_STUB(Normal3bv, _gloffset_Normal3bv, Normal3bv@4)
+ GL_STUB(Normal3d, _gloffset_Normal3d, Normal3d@24)
+ GL_STUB(Normal3dv, _gloffset_Normal3dv, Normal3dv@4)
+ GL_STUB(Normal3f, _gloffset_Normal3f, Normal3f@12)
+ GL_STUB(Normal3fv, _gloffset_Normal3fv, Normal3fv@4)
+ GL_STUB(Normal3i, _gloffset_Normal3i, Normal3i@12)
+ GL_STUB(Normal3iv, _gloffset_Normal3iv, Normal3iv@4)
+ GL_STUB(Normal3s, _gloffset_Normal3s, Normal3s@12)
+ GL_STUB(Normal3sv, _gloffset_Normal3sv, Normal3sv@4)
+ GL_STUB(RasterPos2d, _gloffset_RasterPos2d, RasterPos2d@16)
+ GL_STUB(RasterPos2dv, _gloffset_RasterPos2dv, RasterPos2dv@4)
+ GL_STUB(RasterPos2f, _gloffset_RasterPos2f, RasterPos2f@8)
+ GL_STUB(RasterPos2fv, _gloffset_RasterPos2fv, RasterPos2fv@4)
+ GL_STUB(RasterPos2i, _gloffset_RasterPos2i, RasterPos2i@8)
+ GL_STUB(RasterPos2iv, _gloffset_RasterPos2iv, RasterPos2iv@4)
+ GL_STUB(RasterPos2s, _gloffset_RasterPos2s, RasterPos2s@8)
+ GL_STUB(RasterPos2sv, _gloffset_RasterPos2sv, RasterPos2sv@4)
+ GL_STUB(RasterPos3d, _gloffset_RasterPos3d, RasterPos3d@24)
+ GL_STUB(RasterPos3dv, _gloffset_RasterPos3dv, RasterPos3dv@4)
+ GL_STUB(RasterPos3f, _gloffset_RasterPos3f, RasterPos3f@12)
+ GL_STUB(RasterPos3fv, _gloffset_RasterPos3fv, RasterPos3fv@4)
+ GL_STUB(RasterPos3i, _gloffset_RasterPos3i, RasterPos3i@12)
+ GL_STUB(RasterPos3iv, _gloffset_RasterPos3iv, RasterPos3iv@4)
+ GL_STUB(RasterPos3s, _gloffset_RasterPos3s, RasterPos3s@12)
+ GL_STUB(RasterPos3sv, _gloffset_RasterPos3sv, RasterPos3sv@4)
+ GL_STUB(RasterPos4d, _gloffset_RasterPos4d, RasterPos4d@32)
+ GL_STUB(RasterPos4dv, _gloffset_RasterPos4dv, RasterPos4dv@4)
+ GL_STUB(RasterPos4f, _gloffset_RasterPos4f, RasterPos4f@16)
+ GL_STUB(RasterPos4fv, _gloffset_RasterPos4fv, RasterPos4fv@4)
+ GL_STUB(RasterPos4i, _gloffset_RasterPos4i, RasterPos4i@16)
+ GL_STUB(RasterPos4iv, _gloffset_RasterPos4iv, RasterPos4iv@4)
+ GL_STUB(RasterPos4s, _gloffset_RasterPos4s, RasterPos4s@16)
+ GL_STUB(RasterPos4sv, _gloffset_RasterPos4sv, RasterPos4sv@4)
+ GL_STUB(Rectd, _gloffset_Rectd, Rectd@32)
+ GL_STUB(Rectdv, _gloffset_Rectdv, Rectdv@8)
+ GL_STUB(Rectf, _gloffset_Rectf, Rectf@16)
+ GL_STUB(Rectfv, _gloffset_Rectfv, Rectfv@8)
+ GL_STUB(Recti, _gloffset_Recti, Recti@16)
+ GL_STUB(Rectiv, _gloffset_Rectiv, Rectiv@8)
+ GL_STUB(Rects, _gloffset_Rects, Rects@16)
+ GL_STUB(Rectsv, _gloffset_Rectsv, Rectsv@8)
+ GL_STUB(TexCoord1d, _gloffset_TexCoord1d, TexCoord1d@8)
+ GL_STUB(TexCoord1dv, _gloffset_TexCoord1dv, TexCoord1dv@4)
+ GL_STUB(TexCoord1f, _gloffset_TexCoord1f, TexCoord1f@4)
+ GL_STUB(TexCoord1fv, _gloffset_TexCoord1fv, TexCoord1fv@4)
+ GL_STUB(TexCoord1i, _gloffset_TexCoord1i, TexCoord1i@4)
+ GL_STUB(TexCoord1iv, _gloffset_TexCoord1iv, TexCoord1iv@4)
+ GL_STUB(TexCoord1s, _gloffset_TexCoord1s, TexCoord1s@4)
+ GL_STUB(TexCoord1sv, _gloffset_TexCoord1sv, TexCoord1sv@4)
+ GL_STUB(TexCoord2d, _gloffset_TexCoord2d, TexCoord2d@16)
+ GL_STUB(TexCoord2dv, _gloffset_TexCoord2dv, TexCoord2dv@4)
+ GL_STUB(TexCoord2f, _gloffset_TexCoord2f, TexCoord2f@8)
+ GL_STUB(TexCoord2fv, _gloffset_TexCoord2fv, TexCoord2fv@4)
+ GL_STUB(TexCoord2i, _gloffset_TexCoord2i, TexCoord2i@8)
+ GL_STUB(TexCoord2iv, _gloffset_TexCoord2iv, TexCoord2iv@4)
+ GL_STUB(TexCoord2s, _gloffset_TexCoord2s, TexCoord2s@8)
+ GL_STUB(TexCoord2sv, _gloffset_TexCoord2sv, TexCoord2sv@4)
+ GL_STUB(TexCoord3d, _gloffset_TexCoord3d, TexCoord3d@24)
+ GL_STUB(TexCoord3dv, _gloffset_TexCoord3dv, TexCoord3dv@4)
+ GL_STUB(TexCoord3f, _gloffset_TexCoord3f, TexCoord3f@12)
+ GL_STUB(TexCoord3fv, _gloffset_TexCoord3fv, TexCoord3fv@4)
+ GL_STUB(TexCoord3i, _gloffset_TexCoord3i, TexCoord3i@12)
+ GL_STUB(TexCoord3iv, _gloffset_TexCoord3iv, TexCoord3iv@4)
+ GL_STUB(TexCoord3s, _gloffset_TexCoord3s, TexCoord3s@12)
+ GL_STUB(TexCoord3sv, _gloffset_TexCoord3sv, TexCoord3sv@4)
+ GL_STUB(TexCoord4d, _gloffset_TexCoord4d, TexCoord4d@32)
+ GL_STUB(TexCoord4dv, _gloffset_TexCoord4dv, TexCoord4dv@4)
+ GL_STUB(TexCoord4f, _gloffset_TexCoord4f, TexCoord4f@16)
+ GL_STUB(TexCoord4fv, _gloffset_TexCoord4fv, TexCoord4fv@4)
+ GL_STUB(TexCoord4i, _gloffset_TexCoord4i, TexCoord4i@16)
+ GL_STUB(TexCoord4iv, _gloffset_TexCoord4iv, TexCoord4iv@4)
+ GL_STUB(TexCoord4s, _gloffset_TexCoord4s, TexCoord4s@16)
+ GL_STUB(TexCoord4sv, _gloffset_TexCoord4sv, TexCoord4sv@4)
+ GL_STUB(Vertex2d, _gloffset_Vertex2d, Vertex2d@16)
+ GL_STUB(Vertex2dv, _gloffset_Vertex2dv, Vertex2dv@4)
+ GL_STUB(Vertex2f, _gloffset_Vertex2f, Vertex2f@8)
+ GL_STUB(Vertex2fv, _gloffset_Vertex2fv, Vertex2fv@4)
+ GL_STUB(Vertex2i, _gloffset_Vertex2i, Vertex2i@8)
+ GL_STUB(Vertex2iv, _gloffset_Vertex2iv, Vertex2iv@4)
+ GL_STUB(Vertex2s, _gloffset_Vertex2s, Vertex2s@8)
+ GL_STUB(Vertex2sv, _gloffset_Vertex2sv, Vertex2sv@4)
+ GL_STUB(Vertex3d, _gloffset_Vertex3d, Vertex3d@24)
+ GL_STUB(Vertex3dv, _gloffset_Vertex3dv, Vertex3dv@4)
+ GL_STUB(Vertex3f, _gloffset_Vertex3f, Vertex3f@12)
+ GL_STUB(Vertex3fv, _gloffset_Vertex3fv, Vertex3fv@4)
+ GL_STUB(Vertex3i, _gloffset_Vertex3i, Vertex3i@12)
+ GL_STUB(Vertex3iv, _gloffset_Vertex3iv, Vertex3iv@4)
+ GL_STUB(Vertex3s, _gloffset_Vertex3s, Vertex3s@12)
+ GL_STUB(Vertex3sv, _gloffset_Vertex3sv, Vertex3sv@4)
+ GL_STUB(Vertex4d, _gloffset_Vertex4d, Vertex4d@32)
+ GL_STUB(Vertex4dv, _gloffset_Vertex4dv, Vertex4dv@4)
+ GL_STUB(Vertex4f, _gloffset_Vertex4f, Vertex4f@16)
+ GL_STUB(Vertex4fv, _gloffset_Vertex4fv, Vertex4fv@4)
+ GL_STUB(Vertex4i, _gloffset_Vertex4i, Vertex4i@16)
+ GL_STUB(Vertex4iv, _gloffset_Vertex4iv, Vertex4iv@4)
+ GL_STUB(Vertex4s, _gloffset_Vertex4s, Vertex4s@16)
+ GL_STUB(Vertex4sv, _gloffset_Vertex4sv, Vertex4sv@4)
+ GL_STUB(ClipPlane, _gloffset_ClipPlane, ClipPlane@8)
+ GL_STUB(ColorMaterial, _gloffset_ColorMaterial, ColorMaterial@8)
+ GL_STUB(CullFace, _gloffset_CullFace, CullFace@4)
+ GL_STUB(Fogf, _gloffset_Fogf, Fogf@8)
+ GL_STUB(Fogfv, _gloffset_Fogfv, Fogfv@8)
+ GL_STUB(Fogi, _gloffset_Fogi, Fogi@8)
+ GL_STUB(Fogiv, _gloffset_Fogiv, Fogiv@8)
+ GL_STUB(FrontFace, _gloffset_FrontFace, FrontFace@4)
+ GL_STUB(Hint, _gloffset_Hint, Hint@8)
+ GL_STUB(Lightf, _gloffset_Lightf, Lightf@12)
+ GL_STUB(Lightfv, _gloffset_Lightfv, Lightfv@12)
+ GL_STUB(Lighti, _gloffset_Lighti, Lighti@12)
+ GL_STUB(Lightiv, _gloffset_Lightiv, Lightiv@12)
+ GL_STUB(LightModelf, _gloffset_LightModelf, LightModelf@8)
+ GL_STUB(LightModelfv, _gloffset_LightModelfv, LightModelfv@8)
+ GL_STUB(LightModeli, _gloffset_LightModeli, LightModeli@8)
+ GL_STUB(LightModeliv, _gloffset_LightModeliv, LightModeliv@8)
+ GL_STUB(LineStipple, _gloffset_LineStipple, LineStipple@8)
+ GL_STUB(LineWidth, _gloffset_LineWidth, LineWidth@4)
+ GL_STUB(Materialf, _gloffset_Materialf, Materialf@12)
+ GL_STUB(Materialfv, _gloffset_Materialfv, Materialfv@12)
+ GL_STUB(Materiali, _gloffset_Materiali, Materiali@12)
+ GL_STUB(Materialiv, _gloffset_Materialiv, Materialiv@12)
+ GL_STUB(PointSize, _gloffset_PointSize, PointSize@4)
+ GL_STUB(PolygonMode, _gloffset_PolygonMode, PolygonMode@8)
+ GL_STUB(PolygonStipple, _gloffset_PolygonStipple, PolygonStipple@4)
+ GL_STUB(Scissor, _gloffset_Scissor, Scissor@16)
+ GL_STUB(ShadeModel, _gloffset_ShadeModel, ShadeModel@4)
+ GL_STUB(TexParameterf, _gloffset_TexParameterf, TexParameterf@12)
+ GL_STUB(TexParameterfv, _gloffset_TexParameterfv, TexParameterfv@12)
+ GL_STUB(TexParameteri, _gloffset_TexParameteri, TexParameteri@12)
+ GL_STUB(TexParameteriv, _gloffset_TexParameteriv, TexParameteriv@12)
+ GL_STUB(TexImage1D, _gloffset_TexImage1D, TexImage1D@32)
+ GL_STUB(TexImage2D, _gloffset_TexImage2D, TexImage2D@36)
+ GL_STUB(TexEnvf, _gloffset_TexEnvf, TexEnvf@12)
+ GL_STUB(TexEnvfv, _gloffset_TexEnvfv, TexEnvfv@12)
+ GL_STUB(TexEnvi, _gloffset_TexEnvi, TexEnvi@12)
+ GL_STUB(TexEnviv, _gloffset_TexEnviv, TexEnviv@12)
+ GL_STUB(TexGend, _gloffset_TexGend, TexGend@16)
+ GL_STUB(TexGendv, _gloffset_TexGendv, TexGendv@12)
+ GL_STUB(TexGenf, _gloffset_TexGenf, TexGenf@12)
+ GL_STUB(TexGenfv, _gloffset_TexGenfv, TexGenfv@12)
+ GL_STUB(TexGeni, _gloffset_TexGeni, TexGeni@12)
+ GL_STUB(TexGeniv, _gloffset_TexGeniv, TexGeniv@12)
+ GL_STUB(FeedbackBuffer, _gloffset_FeedbackBuffer, FeedbackBuffer@12)
+ GL_STUB(SelectBuffer, _gloffset_SelectBuffer, SelectBuffer@8)
+ GL_STUB(RenderMode, _gloffset_RenderMode, RenderMode@4)
+ GL_STUB(InitNames, _gloffset_InitNames, InitNames@0)
+ GL_STUB(LoadName, _gloffset_LoadName, LoadName@4)
+ GL_STUB(PassThrough, _gloffset_PassThrough, PassThrough@4)
+ GL_STUB(PopName, _gloffset_PopName, PopName@0)
+ GL_STUB(PushName, _gloffset_PushName, PushName@4)
+ GL_STUB(DrawBuffer, _gloffset_DrawBuffer, DrawBuffer@4)
+ GL_STUB(Clear, _gloffset_Clear, Clear@4)
+ GL_STUB(ClearAccum, _gloffset_ClearAccum, ClearAccum@16)
+ GL_STUB(ClearIndex, _gloffset_ClearIndex, ClearIndex@4)
+ GL_STUB(ClearColor, _gloffset_ClearColor, ClearColor@16)
+ GL_STUB(ClearStencil, _gloffset_ClearStencil, ClearStencil@4)
+ GL_STUB(ClearDepth, _gloffset_ClearDepth, ClearDepth@8)
+ GL_STUB(StencilMask, _gloffset_StencilMask, StencilMask@4)
+ GL_STUB(ColorMask, _gloffset_ColorMask, ColorMask@16)
+ GL_STUB(DepthMask, _gloffset_DepthMask, DepthMask@4)
+ GL_STUB(IndexMask, _gloffset_IndexMask, IndexMask@4)
+ GL_STUB(Accum, _gloffset_Accum, Accum@8)
+ GL_STUB(Disable, _gloffset_Disable, Disable@4)
+ GL_STUB(Enable, _gloffset_Enable, Enable@4)
+ GL_STUB(Finish, _gloffset_Finish, Finish@0)
+ GL_STUB(Flush, _gloffset_Flush, Flush@0)
+ GL_STUB(PopAttrib, _gloffset_PopAttrib, PopAttrib@0)
+ GL_STUB(PushAttrib, _gloffset_PushAttrib, PushAttrib@4)
+ GL_STUB(Map1d, _gloffset_Map1d, Map1d@32)
+ GL_STUB(Map1f, _gloffset_Map1f, Map1f@24)
+ GL_STUB(Map2d, _gloffset_Map2d, Map2d@56)
+ GL_STUB(Map2f, _gloffset_Map2f, Map2f@40)
+ GL_STUB(MapGrid1d, _gloffset_MapGrid1d, MapGrid1d@20)
+ GL_STUB(MapGrid1f, _gloffset_MapGrid1f, MapGrid1f@12)
+ GL_STUB(MapGrid2d, _gloffset_MapGrid2d, MapGrid2d@40)
+ GL_STUB(MapGrid2f, _gloffset_MapGrid2f, MapGrid2f@24)
+ GL_STUB(EvalCoord1d, _gloffset_EvalCoord1d, EvalCoord1d@8)
+ GL_STUB(EvalCoord1dv, _gloffset_EvalCoord1dv, EvalCoord1dv@4)
+ GL_STUB(EvalCoord1f, _gloffset_EvalCoord1f, EvalCoord1f@4)
+ GL_STUB(EvalCoord1fv, _gloffset_EvalCoord1fv, EvalCoord1fv@4)
+ GL_STUB(EvalCoord2d, _gloffset_EvalCoord2d, EvalCoord2d@16)
+ GL_STUB(EvalCoord2dv, _gloffset_EvalCoord2dv, EvalCoord2dv@4)
+ GL_STUB(EvalCoord2f, _gloffset_EvalCoord2f, EvalCoord2f@8)
+ GL_STUB(EvalCoord2fv, _gloffset_EvalCoord2fv, EvalCoord2fv@4)
+ GL_STUB(EvalMesh1, _gloffset_EvalMesh1, EvalMesh1@12)
+ GL_STUB(EvalPoint1, _gloffset_EvalPoint1, EvalPoint1@4)
+ GL_STUB(EvalMesh2, _gloffset_EvalMesh2, EvalMesh2@20)
+ GL_STUB(EvalPoint2, _gloffset_EvalPoint2, EvalPoint2@8)
+ GL_STUB(AlphaFunc, _gloffset_AlphaFunc, AlphaFunc@8)
+ GL_STUB(BlendFunc, _gloffset_BlendFunc, BlendFunc@8)
+ GL_STUB(LogicOp, _gloffset_LogicOp, LogicOp@4)
+ GL_STUB(StencilFunc, _gloffset_StencilFunc, StencilFunc@12)
+ GL_STUB(StencilOp, _gloffset_StencilOp, StencilOp@12)
+ GL_STUB(DepthFunc, _gloffset_DepthFunc, DepthFunc@4)
+ GL_STUB(PixelZoom, _gloffset_PixelZoom, PixelZoom@8)
+ GL_STUB(PixelTransferf, _gloffset_PixelTransferf, PixelTransferf@8)
+ GL_STUB(PixelTransferi, _gloffset_PixelTransferi, PixelTransferi@8)
+ GL_STUB(PixelStoref, _gloffset_PixelStoref, PixelStoref@8)
+ GL_STUB(PixelStorei, _gloffset_PixelStorei, PixelStorei@8)
+ GL_STUB(PixelMapfv, _gloffset_PixelMapfv, PixelMapfv@12)
+ GL_STUB(PixelMapuiv, _gloffset_PixelMapuiv, PixelMapuiv@12)
+ GL_STUB(PixelMapusv, _gloffset_PixelMapusv, PixelMapusv@12)
+ GL_STUB(ReadBuffer, _gloffset_ReadBuffer, ReadBuffer@4)
+ GL_STUB(CopyPixels, _gloffset_CopyPixels, CopyPixels@20)
+ GL_STUB(ReadPixels, _gloffset_ReadPixels, ReadPixels@28)
+ GL_STUB(DrawPixels, _gloffset_DrawPixels, DrawPixels@20)
+ GL_STUB(GetBooleanv, _gloffset_GetBooleanv, GetBooleanv@8)
+ GL_STUB(GetClipPlane, _gloffset_GetClipPlane, GetClipPlane@8)
+ GL_STUB(GetDoublev, _gloffset_GetDoublev, GetDoublev@8)
+ GL_STUB(GetError, _gloffset_GetError, GetError@0)
+ GL_STUB(GetFloatv, _gloffset_GetFloatv, GetFloatv@8)
+ GL_STUB(GetIntegerv, _gloffset_GetIntegerv, GetIntegerv@8)
+ GL_STUB(GetLightfv, _gloffset_GetLightfv, GetLightfv@12)
+ GL_STUB(GetLightiv, _gloffset_GetLightiv, GetLightiv@12)
+ GL_STUB(GetMapdv, _gloffset_GetMapdv, GetMapdv@12)
+ GL_STUB(GetMapfv, _gloffset_GetMapfv, GetMapfv@12)
+ GL_STUB(GetMapiv, _gloffset_GetMapiv, GetMapiv@12)
+ GL_STUB(GetMaterialfv, _gloffset_GetMaterialfv, GetMaterialfv@12)
+ GL_STUB(GetMaterialiv, _gloffset_GetMaterialiv, GetMaterialiv@12)
+ GL_STUB(GetPixelMapfv, _gloffset_GetPixelMapfv, GetPixelMapfv@8)
+ GL_STUB(GetPixelMapuiv, _gloffset_GetPixelMapuiv, GetPixelMapuiv@8)
+ GL_STUB(GetPixelMapusv, _gloffset_GetPixelMapusv, GetPixelMapusv@8)
+ GL_STUB(GetPolygonStipple, _gloffset_GetPolygonStipple, GetPolygonStipple@4)
+ GL_STUB(GetString, _gloffset_GetString, GetString@4)
+ GL_STUB(GetTexEnvfv, _gloffset_GetTexEnvfv, GetTexEnvfv@12)
+ GL_STUB(GetTexEnviv, _gloffset_GetTexEnviv, GetTexEnviv@12)
+ GL_STUB(GetTexGendv, _gloffset_GetTexGendv, GetTexGendv@12)
+ GL_STUB(GetTexGenfv, _gloffset_GetTexGenfv, GetTexGenfv@12)
+ GL_STUB(GetTexGeniv, _gloffset_GetTexGeniv, GetTexGeniv@12)
+ GL_STUB(GetTexImage, _gloffset_GetTexImage, GetTexImage@20)
+ GL_STUB(GetTexParameterfv, _gloffset_GetTexParameterfv, GetTexParameterfv@12)
+ GL_STUB(GetTexParameteriv, _gloffset_GetTexParameteriv, GetTexParameteriv@12)
+ GL_STUB(GetTexLevelParameterfv, _gloffset_GetTexLevelParameterfv, GetTexLevelParameterfv@16)
+ GL_STUB(GetTexLevelParameteriv, _gloffset_GetTexLevelParameteriv, GetTexLevelParameteriv@16)
+ GL_STUB(IsEnabled, _gloffset_IsEnabled, IsEnabled@4)
+ GL_STUB(IsList, _gloffset_IsList, IsList@4)
+ GL_STUB(DepthRange, _gloffset_DepthRange, DepthRange@16)
+ GL_STUB(Frustum, _gloffset_Frustum, Frustum@48)
+ GL_STUB(LoadIdentity, _gloffset_LoadIdentity, LoadIdentity@0)
+ GL_STUB(LoadMatrixf, _gloffset_LoadMatrixf, LoadMatrixf@4)
+ GL_STUB(LoadMatrixd, _gloffset_LoadMatrixd, LoadMatrixd@4)
+ GL_STUB(MatrixMode, _gloffset_MatrixMode, MatrixMode@4)
+ GL_STUB(MultMatrixf, _gloffset_MultMatrixf, MultMatrixf@4)
+ GL_STUB(MultMatrixd, _gloffset_MultMatrixd, MultMatrixd@4)
+ GL_STUB(Ortho, _gloffset_Ortho, Ortho@48)
+ GL_STUB(PopMatrix, _gloffset_PopMatrix, PopMatrix@0)
+ GL_STUB(PushMatrix, _gloffset_PushMatrix, PushMatrix@0)
+ GL_STUB(Rotated, _gloffset_Rotated, Rotated@32)
+ GL_STUB(Rotatef, _gloffset_Rotatef, Rotatef@16)
+ GL_STUB(Scaled, _gloffset_Scaled, Scaled@24)
+ GL_STUB(Scalef, _gloffset_Scalef, Scalef@12)
+ GL_STUB(Translated, _gloffset_Translated, Translated@24)
+ GL_STUB(Translatef, _gloffset_Translatef, Translatef@12)
+ GL_STUB(Viewport, _gloffset_Viewport, Viewport@16)
+ GL_STUB(ArrayElement, _gloffset_ArrayElement, ArrayElement@4)
+ GL_STUB(BindTexture, _gloffset_BindTexture, BindTexture@8)
+ GL_STUB(ColorPointer, _gloffset_ColorPointer, ColorPointer@16)
+ GL_STUB(DisableClientState, _gloffset_DisableClientState, DisableClientState@4)
+ GL_STUB(DrawArrays, _gloffset_DrawArrays, DrawArrays@12)
+ GL_STUB(DrawElements, _gloffset_DrawElements, DrawElements@16)
+ GL_STUB(EdgeFlagPointer, _gloffset_EdgeFlagPointer, EdgeFlagPointer@8)
+ GL_STUB(EnableClientState, _gloffset_EnableClientState, EnableClientState@4)
+ GL_STUB(IndexPointer, _gloffset_IndexPointer, IndexPointer@12)
+ GL_STUB(Indexub, _gloffset_Indexub, Indexub@4)
+ GL_STUB(Indexubv, _gloffset_Indexubv, Indexubv@4)
+ GL_STUB(InterleavedArrays, _gloffset_InterleavedArrays, InterleavedArrays@12)
+ GL_STUB(NormalPointer, _gloffset_NormalPointer, NormalPointer@12)
+ GL_STUB(PolygonOffset, _gloffset_PolygonOffset, PolygonOffset@8)
+ GL_STUB(TexCoordPointer, _gloffset_TexCoordPointer, TexCoordPointer@16)
+ GL_STUB(VertexPointer, _gloffset_VertexPointer, VertexPointer@16)
+ GL_STUB(AreTexturesResident, _gloffset_AreTexturesResident, AreTexturesResident@12)
+ GL_STUB(CopyTexImage1D, _gloffset_CopyTexImage1D, CopyTexImage1D@28)
+ GL_STUB(CopyTexImage2D, _gloffset_CopyTexImage2D, CopyTexImage2D@32)
+ GL_STUB(CopyTexSubImage1D, _gloffset_CopyTexSubImage1D, CopyTexSubImage1D@24)
+ GL_STUB(CopyTexSubImage2D, _gloffset_CopyTexSubImage2D, CopyTexSubImage2D@32)
+ GL_STUB(DeleteTextures, _gloffset_DeleteTextures, DeleteTextures@8)
+ GL_STUB(GenTextures, _gloffset_GenTextures, GenTextures@8)
+ GL_STUB(GetPointerv, _gloffset_GetPointerv, GetPointerv@8)
+ GL_STUB(IsTexture, _gloffset_IsTexture, IsTexture@4)
+ GL_STUB(PrioritizeTextures, _gloffset_PrioritizeTextures, PrioritizeTextures@12)
+ GL_STUB(TexSubImage1D, _gloffset_TexSubImage1D, TexSubImage1D@28)
+ GL_STUB(TexSubImage2D, _gloffset_TexSubImage2D, TexSubImage2D@36)
+ GL_STUB(PopClientAttrib, _gloffset_PopClientAttrib, PopClientAttrib@0)
+ GL_STUB(PushClientAttrib, _gloffset_PushClientAttrib, PushClientAttrib@4)
+ GL_STUB(BlendColor, _gloffset_BlendColor, BlendColor@16)
+ GL_STUB(BlendEquation, _gloffset_BlendEquation, BlendEquation@4)
+ GL_STUB(DrawRangeElements, _gloffset_DrawRangeElements, DrawRangeElements@24)
+ GL_STUB(ColorTable, _gloffset_ColorTable, ColorTable@24)
+ GL_STUB(ColorTableParameterfv, _gloffset_ColorTableParameterfv, ColorTableParameterfv@12)
+ GL_STUB(ColorTableParameteriv, _gloffset_ColorTableParameteriv, ColorTableParameteriv@12)
+ GL_STUB(CopyColorTable, _gloffset_CopyColorTable, CopyColorTable@20)
+ GL_STUB(GetColorTable, _gloffset_GetColorTable, GetColorTable@16)
+ GL_STUB(GetColorTableParameterfv, _gloffset_GetColorTableParameterfv, GetColorTableParameterfv@12)
+ GL_STUB(GetColorTableParameteriv, _gloffset_GetColorTableParameteriv, GetColorTableParameteriv@12)
+ GL_STUB(ColorSubTable, _gloffset_ColorSubTable, ColorSubTable@24)
+ GL_STUB(CopyColorSubTable, _gloffset_CopyColorSubTable, CopyColorSubTable@20)
+ GL_STUB(ConvolutionFilter1D, _gloffset_ConvolutionFilter1D, ConvolutionFilter1D@24)
+ GL_STUB(ConvolutionFilter2D, _gloffset_ConvolutionFilter2D, ConvolutionFilter2D@28)
+ GL_STUB(ConvolutionParameterf, _gloffset_ConvolutionParameterf, ConvolutionParameterf@12)
+ GL_STUB(ConvolutionParameterfv, _gloffset_ConvolutionParameterfv, ConvolutionParameterfv@12)
+ GL_STUB(ConvolutionParameteri, _gloffset_ConvolutionParameteri, ConvolutionParameteri@12)
+ GL_STUB(ConvolutionParameteriv, _gloffset_ConvolutionParameteriv, ConvolutionParameteriv@12)
+ GL_STUB(CopyConvolutionFilter1D, _gloffset_CopyConvolutionFilter1D, CopyConvolutionFilter1D@20)
+ GL_STUB(CopyConvolutionFilter2D, _gloffset_CopyConvolutionFilter2D, CopyConvolutionFilter2D@24)
+ GL_STUB(GetConvolutionFilter, _gloffset_GetConvolutionFilter, GetConvolutionFilter@16)
+ GL_STUB(GetConvolutionParameterfv, _gloffset_GetConvolutionParameterfv, GetConvolutionParameterfv@12)
+ GL_STUB(GetConvolutionParameteriv, _gloffset_GetConvolutionParameteriv, GetConvolutionParameteriv@12)
+ GL_STUB(GetSeparableFilter, _gloffset_GetSeparableFilter, GetSeparableFilter@24)
+ GL_STUB(SeparableFilter2D, _gloffset_SeparableFilter2D, SeparableFilter2D@32)
+ GL_STUB(GetHistogram, _gloffset_GetHistogram, GetHistogram@20)
+ GL_STUB(GetHistogramParameterfv, _gloffset_GetHistogramParameterfv, GetHistogramParameterfv@12)
+ GL_STUB(GetHistogramParameteriv, _gloffset_GetHistogramParameteriv, GetHistogramParameteriv@12)
+ GL_STUB(GetMinmax, _gloffset_GetMinmax, GetMinmax@20)
+ GL_STUB(GetMinmaxParameterfv, _gloffset_GetMinmaxParameterfv, GetMinmaxParameterfv@12)
+ GL_STUB(GetMinmaxParameteriv, _gloffset_GetMinmaxParameteriv, GetMinmaxParameteriv@12)
+ GL_STUB(Histogram, _gloffset_Histogram, Histogram@16)
+ GL_STUB(Minmax, _gloffset_Minmax, Minmax@12)
+ GL_STUB(ResetHistogram, _gloffset_ResetHistogram, ResetHistogram@4)
+ GL_STUB(ResetMinmax, _gloffset_ResetMinmax, ResetMinmax@4)
+ GL_STUB(TexImage3D, _gloffset_TexImage3D, TexImage3D@40)
+ GL_STUB(TexSubImage3D, _gloffset_TexSubImage3D, TexSubImage3D@44)
+ GL_STUB(CopyTexSubImage3D, _gloffset_CopyTexSubImage3D, CopyTexSubImage3D@36)
+ GL_STUB(ActiveTextureARB, _gloffset_ActiveTextureARB, ActiveTextureARB@4)
+ GL_STUB(ClientActiveTextureARB, _gloffset_ClientActiveTextureARB, ClientActiveTextureARB@4)
+ GL_STUB(MultiTexCoord1dARB, _gloffset_MultiTexCoord1dARB, MultiTexCoord1dARB@12)
+ GL_STUB(MultiTexCoord1dvARB, _gloffset_MultiTexCoord1dvARB, MultiTexCoord1dvARB@8)
+ GL_STUB(MultiTexCoord1fARB, _gloffset_MultiTexCoord1fARB, MultiTexCoord1fARB@8)
+ GL_STUB(MultiTexCoord1fvARB, _gloffset_MultiTexCoord1fvARB, MultiTexCoord1fvARB@8)
+ GL_STUB(MultiTexCoord1iARB, _gloffset_MultiTexCoord1iARB, MultiTexCoord1iARB@8)
+ GL_STUB(MultiTexCoord1ivARB, _gloffset_MultiTexCoord1ivARB, MultiTexCoord1ivARB@8)
+ GL_STUB(MultiTexCoord1sARB, _gloffset_MultiTexCoord1sARB, MultiTexCoord1sARB@8)
+ GL_STUB(MultiTexCoord1svARB, _gloffset_MultiTexCoord1svARB, MultiTexCoord1svARB@8)
+ GL_STUB(MultiTexCoord2dARB, _gloffset_MultiTexCoord2dARB, MultiTexCoord2dARB@20)
+ GL_STUB(MultiTexCoord2dvARB, _gloffset_MultiTexCoord2dvARB, MultiTexCoord2dvARB@8)
+ GL_STUB(MultiTexCoord2fARB, _gloffset_MultiTexCoord2fARB, MultiTexCoord2fARB@12)
+ GL_STUB(MultiTexCoord2fvARB, _gloffset_MultiTexCoord2fvARB, MultiTexCoord2fvARB@8)
+ GL_STUB(MultiTexCoord2iARB, _gloffset_MultiTexCoord2iARB, MultiTexCoord2iARB@12)
+ GL_STUB(MultiTexCoord2ivARB, _gloffset_MultiTexCoord2ivARB, MultiTexCoord2ivARB@8)
+ GL_STUB(MultiTexCoord2sARB, _gloffset_MultiTexCoord2sARB, MultiTexCoord2sARB@12)
+ GL_STUB(MultiTexCoord2svARB, _gloffset_MultiTexCoord2svARB, MultiTexCoord2svARB@8)
+ GL_STUB(MultiTexCoord3dARB, _gloffset_MultiTexCoord3dARB, MultiTexCoord3dARB@28)
+ GL_STUB(MultiTexCoord3dvARB, _gloffset_MultiTexCoord3dvARB, MultiTexCoord3dvARB@8)
+ GL_STUB(MultiTexCoord3fARB, _gloffset_MultiTexCoord3fARB, MultiTexCoord3fARB@16)
+ GL_STUB(MultiTexCoord3fvARB, _gloffset_MultiTexCoord3fvARB, MultiTexCoord3fvARB@8)
+ GL_STUB(MultiTexCoord3iARB, _gloffset_MultiTexCoord3iARB, MultiTexCoord3iARB@16)
+ GL_STUB(MultiTexCoord3ivARB, _gloffset_MultiTexCoord3ivARB, MultiTexCoord3ivARB@8)
+ GL_STUB(MultiTexCoord3sARB, _gloffset_MultiTexCoord3sARB, MultiTexCoord3sARB@16)
+ GL_STUB(MultiTexCoord3svARB, _gloffset_MultiTexCoord3svARB, MultiTexCoord3svARB@8)
+ GL_STUB(MultiTexCoord4dARB, _gloffset_MultiTexCoord4dARB, MultiTexCoord4dARB@36)
+ GL_STUB(MultiTexCoord4dvARB, _gloffset_MultiTexCoord4dvARB, MultiTexCoord4dvARB@8)
+ GL_STUB(MultiTexCoord4fARB, _gloffset_MultiTexCoord4fARB, MultiTexCoord4fARB@20)
+ GL_STUB(MultiTexCoord4fvARB, _gloffset_MultiTexCoord4fvARB, MultiTexCoord4fvARB@8)
+ GL_STUB(MultiTexCoord4iARB, _gloffset_MultiTexCoord4iARB, MultiTexCoord4iARB@20)
+ GL_STUB(MultiTexCoord4ivARB, _gloffset_MultiTexCoord4ivARB, MultiTexCoord4ivARB@8)
+ GL_STUB(MultiTexCoord4sARB, _gloffset_MultiTexCoord4sARB, MultiTexCoord4sARB@20)
+ GL_STUB(MultiTexCoord4svARB, _gloffset_MultiTexCoord4svARB, MultiTexCoord4svARB@8)
+ GL_STUB(LoadTransposeMatrixfARB, _gloffset_LoadTransposeMatrixfARB, LoadTransposeMatrixfARB@4)
+ GL_STUB(LoadTransposeMatrixdARB, _gloffset_LoadTransposeMatrixdARB, LoadTransposeMatrixdARB@4)
+ GL_STUB(MultTransposeMatrixfARB, _gloffset_MultTransposeMatrixfARB, MultTransposeMatrixfARB@4)
+ GL_STUB(MultTransposeMatrixdARB, _gloffset_MultTransposeMatrixdARB, MultTransposeMatrixdARB@4)
+ GL_STUB(SampleCoverageARB, _gloffset_SampleCoverageARB, SampleCoverageARB@8)
+ GL_STUB(DrawBuffersARB, _gloffset_DrawBuffersARB, DrawBuffersARB@8)
+ GL_STUB(PolygonOffsetEXT, _gloffset_PolygonOffsetEXT, PolygonOffsetEXT@8)
+ GL_STUB(GetTexFilterFuncSGIS, _gloffset_GetTexFilterFuncSGIS, GetTexFilterFuncSGIS@12)
+ GL_STUB(TexFilterFuncSGIS, _gloffset_TexFilterFuncSGIS, TexFilterFuncSGIS@16)
+ GL_STUB(GetHistogramEXT, _gloffset_GetHistogramEXT, GetHistogramEXT@20)
+ GL_STUB(GetHistogramParameterfvEXT, _gloffset_GetHistogramParameterfvEXT, GetHistogramParameterfvEXT@12)
+ GL_STUB(GetHistogramParameterivEXT, _gloffset_GetHistogramParameterivEXT, GetHistogramParameterivEXT@12)
+ GL_STUB(GetMinmaxEXT, _gloffset_GetMinmaxEXT, GetMinmaxEXT@20)
+ GL_STUB(GetMinmaxParameterfvEXT, _gloffset_GetMinmaxParameterfvEXT, GetMinmaxParameterfvEXT@12)
+ GL_STUB(GetMinmaxParameterivEXT, _gloffset_GetMinmaxParameterivEXT, GetMinmaxParameterivEXT@12)
+ GL_STUB(GetConvolutionFilterEXT, _gloffset_GetConvolutionFilterEXT, GetConvolutionFilterEXT@16)
+ GL_STUB(GetConvolutionParameterfvEXT, _gloffset_GetConvolutionParameterfvEXT, GetConvolutionParameterfvEXT@12)
+ GL_STUB(GetConvolutionParameterivEXT, _gloffset_GetConvolutionParameterivEXT, GetConvolutionParameterivEXT@12)
+ GL_STUB(GetSeparableFilterEXT, _gloffset_GetSeparableFilterEXT, GetSeparableFilterEXT@24)
+ GL_STUB(GetColorTableSGI, _gloffset_GetColorTableSGI, GetColorTableSGI@16)
+ GL_STUB(GetColorTableParameterfvSGI, _gloffset_GetColorTableParameterfvSGI, GetColorTableParameterfvSGI@12)
+ GL_STUB(GetColorTableParameterivSGI, _gloffset_GetColorTableParameterivSGI, GetColorTableParameterivSGI@12)
+ GL_STUB(PixelTexGenSGIX, _gloffset_PixelTexGenSGIX, PixelTexGenSGIX@4)
+ GL_STUB(PixelTexGenParameteriSGIS, _gloffset_PixelTexGenParameteriSGIS, PixelTexGenParameteriSGIS@8)
+ GL_STUB(PixelTexGenParameterivSGIS, _gloffset_PixelTexGenParameterivSGIS, PixelTexGenParameterivSGIS@8)
+ GL_STUB(PixelTexGenParameterfSGIS, _gloffset_PixelTexGenParameterfSGIS, PixelTexGenParameterfSGIS@8)
+ GL_STUB(PixelTexGenParameterfvSGIS, _gloffset_PixelTexGenParameterfvSGIS, PixelTexGenParameterfvSGIS@8)
+ GL_STUB(GetPixelTexGenParameterivSGIS, _gloffset_GetPixelTexGenParameterivSGIS, GetPixelTexGenParameterivSGIS@8)
+ GL_STUB(GetPixelTexGenParameterfvSGIS, _gloffset_GetPixelTexGenParameterfvSGIS, GetPixelTexGenParameterfvSGIS@8)
+ GL_STUB(TexImage4DSGIS, _gloffset_TexImage4DSGIS, TexImage4DSGIS@44)
+ GL_STUB(TexSubImage4DSGIS, _gloffset_TexSubImage4DSGIS, TexSubImage4DSGIS@52)
+ GL_STUB(AreTexturesResidentEXT, _gloffset_AreTexturesResidentEXT, AreTexturesResidentEXT@12)
+ GL_STUB(GenTexturesEXT, _gloffset_GenTexturesEXT, GenTexturesEXT@8)
+ GL_STUB(IsTextureEXT, _gloffset_IsTextureEXT, IsTextureEXT@4)
+ GL_STUB(DetailTexFuncSGIS, _gloffset_DetailTexFuncSGIS, DetailTexFuncSGIS@12)
+ GL_STUB(GetDetailTexFuncSGIS, _gloffset_GetDetailTexFuncSGIS, GetDetailTexFuncSGIS@8)
+ GL_STUB(SharpenTexFuncSGIS, _gloffset_SharpenTexFuncSGIS, SharpenTexFuncSGIS@12)
+ GL_STUB(GetSharpenTexFuncSGIS, _gloffset_GetSharpenTexFuncSGIS, GetSharpenTexFuncSGIS@8)
+ GL_STUB(SampleMaskSGIS, _gloffset_SampleMaskSGIS, SampleMaskSGIS@8)
+ GL_STUB(SamplePatternSGIS, _gloffset_SamplePatternSGIS, SamplePatternSGIS@4)
+ GL_STUB(ColorPointerEXT, _gloffset_ColorPointerEXT, ColorPointerEXT@20)
+ GL_STUB(EdgeFlagPointerEXT, _gloffset_EdgeFlagPointerEXT, EdgeFlagPointerEXT@12)
+ GL_STUB(IndexPointerEXT, _gloffset_IndexPointerEXT, IndexPointerEXT@16)
+ GL_STUB(NormalPointerEXT, _gloffset_NormalPointerEXT, NormalPointerEXT@16)
+ GL_STUB(TexCoordPointerEXT, _gloffset_TexCoordPointerEXT, TexCoordPointerEXT@20)
+ GL_STUB(VertexPointerEXT, _gloffset_VertexPointerEXT, VertexPointerEXT@20)
+ GL_STUB(SpriteParameterfSGIX, _gloffset_SpriteParameterfSGIX, SpriteParameterfSGIX@8)
+ GL_STUB(SpriteParameterfvSGIX, _gloffset_SpriteParameterfvSGIX, SpriteParameterfvSGIX@8)
+ GL_STUB(SpriteParameteriSGIX, _gloffset_SpriteParameteriSGIX, SpriteParameteriSGIX@8)
+ GL_STUB(SpriteParameterivSGIX, _gloffset_SpriteParameterivSGIX, SpriteParameterivSGIX@8)
+ GL_STUB(PointParameterfEXT, _gloffset_PointParameterfEXT, PointParameterfEXT@8)
+ GL_STUB(PointParameterfvEXT, _gloffset_PointParameterfvEXT, PointParameterfvEXT@8)
+ GL_STUB(GetInstrumentsSGIX, _gloffset_GetInstrumentsSGIX, GetInstrumentsSGIX@0)
+ GL_STUB(InstrumentsBufferSGIX, _gloffset_InstrumentsBufferSGIX, InstrumentsBufferSGIX@8)
+ GL_STUB(PollInstrumentsSGIX, _gloffset_PollInstrumentsSGIX, PollInstrumentsSGIX@4)
+ GL_STUB(ReadInstrumentsSGIX, _gloffset_ReadInstrumentsSGIX, ReadInstrumentsSGIX@4)
+ GL_STUB(StartInstrumentsSGIX, _gloffset_StartInstrumentsSGIX, StartInstrumentsSGIX@0)
+ GL_STUB(StopInstrumentsSGIX, _gloffset_StopInstrumentsSGIX, StopInstrumentsSGIX@4)
+ GL_STUB(FrameZoomSGIX, _gloffset_FrameZoomSGIX, FrameZoomSGIX@4)
+ GL_STUB(TagSampleBufferSGIX, _gloffset_TagSampleBufferSGIX, TagSampleBufferSGIX@0)
+ GL_STUB(ReferencePlaneSGIX, _gloffset_ReferencePlaneSGIX, ReferencePlaneSGIX@4)
+ GL_STUB(FlushRasterSGIX, _gloffset_FlushRasterSGIX, FlushRasterSGIX@0)
+ GL_STUB(GetListParameterfvSGIX, _gloffset_GetListParameterfvSGIX, GetListParameterfvSGIX@12)
+ GL_STUB(GetListParameterivSGIX, _gloffset_GetListParameterivSGIX, GetListParameterivSGIX@12)
+ GL_STUB(ListParameterfSGIX, _gloffset_ListParameterfSGIX, ListParameterfSGIX@12)
+ GL_STUB(ListParameterfvSGIX, _gloffset_ListParameterfvSGIX, ListParameterfvSGIX@12)
+ GL_STUB(ListParameteriSGIX, _gloffset_ListParameteriSGIX, ListParameteriSGIX@12)
+ GL_STUB(ListParameterivSGIX, _gloffset_ListParameterivSGIX, ListParameterivSGIX@12)
+ GL_STUB(FragmentColorMaterialSGIX, _gloffset_FragmentColorMaterialSGIX, FragmentColorMaterialSGIX@8)
+ GL_STUB(FragmentLightfSGIX, _gloffset_FragmentLightfSGIX, FragmentLightfSGIX@12)
+ GL_STUB(FragmentLightfvSGIX, _gloffset_FragmentLightfvSGIX, FragmentLightfvSGIX@12)
+ GL_STUB(FragmentLightiSGIX, _gloffset_FragmentLightiSGIX, FragmentLightiSGIX@12)
+ GL_STUB(FragmentLightivSGIX, _gloffset_FragmentLightivSGIX, FragmentLightivSGIX@12)
+ GL_STUB(FragmentLightModelfSGIX, _gloffset_FragmentLightModelfSGIX, FragmentLightModelfSGIX@8)
+ GL_STUB(FragmentLightModelfvSGIX, _gloffset_FragmentLightModelfvSGIX, FragmentLightModelfvSGIX@8)
+ GL_STUB(FragmentLightModeliSGIX, _gloffset_FragmentLightModeliSGIX, FragmentLightModeliSGIX@8)
+ GL_STUB(FragmentLightModelivSGIX, _gloffset_FragmentLightModelivSGIX, FragmentLightModelivSGIX@8)
+ GL_STUB(FragmentMaterialfSGIX, _gloffset_FragmentMaterialfSGIX, FragmentMaterialfSGIX@12)
+ GL_STUB(FragmentMaterialfvSGIX, _gloffset_FragmentMaterialfvSGIX, FragmentMaterialfvSGIX@12)
+ GL_STUB(FragmentMaterialiSGIX, _gloffset_FragmentMaterialiSGIX, FragmentMaterialiSGIX@12)
+ GL_STUB(FragmentMaterialivSGIX, _gloffset_FragmentMaterialivSGIX, FragmentMaterialivSGIX@12)
+ GL_STUB(GetFragmentLightfvSGIX, _gloffset_GetFragmentLightfvSGIX, GetFragmentLightfvSGIX@12)
+ GL_STUB(GetFragmentLightivSGIX, _gloffset_GetFragmentLightivSGIX, GetFragmentLightivSGIX@12)
+ GL_STUB(GetFragmentMaterialfvSGIX, _gloffset_GetFragmentMaterialfvSGIX, GetFragmentMaterialfvSGIX@12)
+ GL_STUB(GetFragmentMaterialivSGIX, _gloffset_GetFragmentMaterialivSGIX, GetFragmentMaterialivSGIX@12)
+ GL_STUB(LightEnviSGIX, _gloffset_LightEnviSGIX, LightEnviSGIX@8)
+ GL_STUB(VertexWeightfEXT, _gloffset_VertexWeightfEXT, VertexWeightfEXT@4)
+ GL_STUB(VertexWeightfvEXT, _gloffset_VertexWeightfvEXT, VertexWeightfvEXT@4)
+ GL_STUB(VertexWeightPointerEXT, _gloffset_VertexWeightPointerEXT, VertexWeightPointerEXT@16)
+ GL_STUB(FlushVertexArrayRangeNV, _gloffset_FlushVertexArrayRangeNV, FlushVertexArrayRangeNV@0)
+ GL_STUB(VertexArrayRangeNV, _gloffset_VertexArrayRangeNV, VertexArrayRangeNV@8)
+ GL_STUB(CombinerParameterfvNV, _gloffset_CombinerParameterfvNV, CombinerParameterfvNV@8)
+ GL_STUB(CombinerParameterfNV, _gloffset_CombinerParameterfNV, CombinerParameterfNV@8)
+ GL_STUB(CombinerParameterivNV, _gloffset_CombinerParameterivNV, CombinerParameterivNV@8)
+ GL_STUB(CombinerParameteriNV, _gloffset_CombinerParameteriNV, CombinerParameteriNV@8)
+ GL_STUB(CombinerInputNV, _gloffset_CombinerInputNV, CombinerInputNV@24)
+ GL_STUB(CombinerOutputNV, _gloffset_CombinerOutputNV, CombinerOutputNV@40)
+ GL_STUB(FinalCombinerInputNV, _gloffset_FinalCombinerInputNV, FinalCombinerInputNV@16)
+ GL_STUB(GetCombinerInputParameterfvNV, _gloffset_GetCombinerInputParameterfvNV, GetCombinerInputParameterfvNV@20)
+ GL_STUB(GetCombinerInputParameterivNV, _gloffset_GetCombinerInputParameterivNV, GetCombinerInputParameterivNV@20)
+ GL_STUB(GetCombinerOutputParameterfvNV, _gloffset_GetCombinerOutputParameterfvNV, GetCombinerOutputParameterfvNV@16)
+ GL_STUB(GetCombinerOutputParameterivNV, _gloffset_GetCombinerOutputParameterivNV, GetCombinerOutputParameterivNV@16)
+ GL_STUB(GetFinalCombinerInputParameterfvNV, _gloffset_GetFinalCombinerInputParameterfvNV, GetFinalCombinerInputParameterfvNV@12)
+ GL_STUB(GetFinalCombinerInputParameterivNV, _gloffset_GetFinalCombinerInputParameterivNV, GetFinalCombinerInputParameterivNV@12)
+ GL_STUB(ResizeBuffersMESA, _gloffset_ResizeBuffersMESA, ResizeBuffersMESA@0)
+ GL_STUB(WindowPos2dMESA, _gloffset_WindowPos2dMESA, WindowPos2dMESA@16)
+ GL_STUB(WindowPos2dvMESA, _gloffset_WindowPos2dvMESA, WindowPos2dvMESA@4)
+ GL_STUB(WindowPos2fMESA, _gloffset_WindowPos2fMESA, WindowPos2fMESA@8)
+ GL_STUB(WindowPos2fvMESA, _gloffset_WindowPos2fvMESA, WindowPos2fvMESA@4)
+ GL_STUB(WindowPos2iMESA, _gloffset_WindowPos2iMESA, WindowPos2iMESA@8)
+ GL_STUB(WindowPos2ivMESA, _gloffset_WindowPos2ivMESA, WindowPos2ivMESA@4)
+ GL_STUB(WindowPos2sMESA, _gloffset_WindowPos2sMESA, WindowPos2sMESA@8)
+ GL_STUB(WindowPos2svMESA, _gloffset_WindowPos2svMESA, WindowPos2svMESA@4)
+ GL_STUB(WindowPos3dMESA, _gloffset_WindowPos3dMESA, WindowPos3dMESA@24)
+ GL_STUB(WindowPos3dvMESA, _gloffset_WindowPos3dvMESA, WindowPos3dvMESA@4)
+ GL_STUB(WindowPos3fMESA, _gloffset_WindowPos3fMESA, WindowPos3fMESA@12)
+ GL_STUB(WindowPos3fvMESA, _gloffset_WindowPos3fvMESA, WindowPos3fvMESA@4)
+ GL_STUB(WindowPos3iMESA, _gloffset_WindowPos3iMESA, WindowPos3iMESA@12)
+ GL_STUB(WindowPos3ivMESA, _gloffset_WindowPos3ivMESA, WindowPos3ivMESA@4)
+ GL_STUB(WindowPos3sMESA, _gloffset_WindowPos3sMESA, WindowPos3sMESA@12)
+ GL_STUB(WindowPos3svMESA, _gloffset_WindowPos3svMESA, WindowPos3svMESA@4)
+ GL_STUB(WindowPos4dMESA, _gloffset_WindowPos4dMESA, WindowPos4dMESA@32)
+ GL_STUB(WindowPos4dvMESA, _gloffset_WindowPos4dvMESA, WindowPos4dvMESA@4)
+ GL_STUB(WindowPos4fMESA, _gloffset_WindowPos4fMESA, WindowPos4fMESA@16)
+ GL_STUB(WindowPos4fvMESA, _gloffset_WindowPos4fvMESA, WindowPos4fvMESA@4)
+ GL_STUB(WindowPos4iMESA, _gloffset_WindowPos4iMESA, WindowPos4iMESA@16)
+ GL_STUB(WindowPos4ivMESA, _gloffset_WindowPos4ivMESA, WindowPos4ivMESA@4)
+ GL_STUB(WindowPos4sMESA, _gloffset_WindowPos4sMESA, WindowPos4sMESA@16)
+ GL_STUB(WindowPos4svMESA, _gloffset_WindowPos4svMESA, WindowPos4svMESA@4)
+ GL_STUB(BlendFuncSeparateEXT, _gloffset_BlendFuncSeparateEXT, BlendFuncSeparateEXT@16)
+ GL_STUB(IndexMaterialEXT, _gloffset_IndexMaterialEXT, IndexMaterialEXT@8)
+ GL_STUB(IndexFuncEXT, _gloffset_IndexFuncEXT, IndexFuncEXT@8)
+ GL_STUB(LockArraysEXT, _gloffset_LockArraysEXT, LockArraysEXT@8)
+ GL_STUB(UnlockArraysEXT, _gloffset_UnlockArraysEXT, UnlockArraysEXT@0)
+ GL_STUB(CullParameterdvEXT, _gloffset_CullParameterdvEXT, CullParameterdvEXT@8)
+ GL_STUB(CullParameterfvEXT, _gloffset_CullParameterfvEXT, CullParameterfvEXT@8)
+ GL_STUB(HintPGI, _gloffset_HintPGI, HintPGI@8)
+ GL_STUB(FogCoordfEXT, _gloffset_FogCoordfEXT, FogCoordfEXT@4)
+ GL_STUB(FogCoordfvEXT, _gloffset_FogCoordfvEXT, FogCoordfvEXT@4)
+ GL_STUB(FogCoorddEXT, _gloffset_FogCoorddEXT, FogCoorddEXT@8)
+ GL_STUB(FogCoorddvEXT, _gloffset_FogCoorddvEXT, FogCoorddvEXT@4)
+ GL_STUB(FogCoordPointerEXT, _gloffset_FogCoordPointerEXT, FogCoordPointerEXT@12)
+ GL_STUB(GetColorTableEXT, _gloffset_GetColorTableEXT, GetColorTableEXT@16)
+ GL_STUB(GetColorTableParameterivEXT, _gloffset_GetColorTableParameterivEXT, GetColorTableParameterivEXT@12)
+ GL_STUB(GetColorTableParameterfvEXT, _gloffset_GetColorTableParameterfvEXT, GetColorTableParameterfvEXT@12)
+ GL_STUB(TbufferMask3DFX, _gloffset_TbufferMask3DFX, TbufferMask3DFX@4)
+ GL_STUB(CompressedTexImage3DARB, _gloffset_CompressedTexImage3DARB, CompressedTexImage3DARB@36)
+ GL_STUB(CompressedTexImage2DARB, _gloffset_CompressedTexImage2DARB, CompressedTexImage2DARB@32)
+ GL_STUB(CompressedTexImage1DARB, _gloffset_CompressedTexImage1DARB, CompressedTexImage1DARB@28)
+ GL_STUB(CompressedTexSubImage3DARB, _gloffset_CompressedTexSubImage3DARB, CompressedTexSubImage3DARB@44)
+ GL_STUB(CompressedTexSubImage2DARB, _gloffset_CompressedTexSubImage2DARB, CompressedTexSubImage2DARB@36)
+ GL_STUB(CompressedTexSubImage1DARB, _gloffset_CompressedTexSubImage1DARB, CompressedTexSubImage1DARB@28)
+ GL_STUB(GetCompressedTexImageARB, _gloffset_GetCompressedTexImageARB, GetCompressedTexImageARB@12)
+ GL_STUB(SecondaryColor3bEXT, _gloffset_SecondaryColor3bEXT, SecondaryColor3bEXT@12)
+ GL_STUB(SecondaryColor3bvEXT, _gloffset_SecondaryColor3bvEXT, SecondaryColor3bvEXT@4)
+ GL_STUB(SecondaryColor3dEXT, _gloffset_SecondaryColor3dEXT, SecondaryColor3dEXT@24)
+ GL_STUB(SecondaryColor3dvEXT, _gloffset_SecondaryColor3dvEXT, SecondaryColor3dvEXT@4)
+ GL_STUB(SecondaryColor3fEXT, _gloffset_SecondaryColor3fEXT, SecondaryColor3fEXT@12)
+ GL_STUB(SecondaryColor3fvEXT, _gloffset_SecondaryColor3fvEXT, SecondaryColor3fvEXT@4)
+ GL_STUB(SecondaryColor3iEXT, _gloffset_SecondaryColor3iEXT, SecondaryColor3iEXT@12)
+ GL_STUB(SecondaryColor3ivEXT, _gloffset_SecondaryColor3ivEXT, SecondaryColor3ivEXT@4)
+ GL_STUB(SecondaryColor3sEXT, _gloffset_SecondaryColor3sEXT, SecondaryColor3sEXT@12)
+ GL_STUB(SecondaryColor3svEXT, _gloffset_SecondaryColor3svEXT, SecondaryColor3svEXT@4)
+ GL_STUB(SecondaryColor3ubEXT, _gloffset_SecondaryColor3ubEXT, SecondaryColor3ubEXT@12)
+ GL_STUB(SecondaryColor3ubvEXT, _gloffset_SecondaryColor3ubvEXT, SecondaryColor3ubvEXT@4)
+ GL_STUB(SecondaryColor3uiEXT, _gloffset_SecondaryColor3uiEXT, SecondaryColor3uiEXT@12)
+ GL_STUB(SecondaryColor3uivEXT, _gloffset_SecondaryColor3uivEXT, SecondaryColor3uivEXT@4)
+ GL_STUB(SecondaryColor3usEXT, _gloffset_SecondaryColor3usEXT, SecondaryColor3usEXT@12)
+ GL_STUB(SecondaryColor3usvEXT, _gloffset_SecondaryColor3usvEXT, SecondaryColor3usvEXT@4)
+ GL_STUB(SecondaryColorPointerEXT, _gloffset_SecondaryColorPointerEXT, SecondaryColorPointerEXT@16)
+ GL_STUB(AreProgramsResidentNV, _gloffset_AreProgramsResidentNV, AreProgramsResidentNV@12)
+ GL_STUB(BindProgramNV, _gloffset_BindProgramNV, BindProgramNV@8)
+ GL_STUB(DeleteProgramsNV, _gloffset_DeleteProgramsNV, DeleteProgramsNV@8)
+ GL_STUB(ExecuteProgramNV, _gloffset_ExecuteProgramNV, ExecuteProgramNV@12)
+ GL_STUB(GenProgramsNV, _gloffset_GenProgramsNV, GenProgramsNV@8)
+ GL_STUB(GetProgramParameterdvNV, _gloffset_GetProgramParameterdvNV, GetProgramParameterdvNV@16)
+ GL_STUB(GetProgramParameterfvNV, _gloffset_GetProgramParameterfvNV, GetProgramParameterfvNV@16)
+ GL_STUB(GetProgramivNV, _gloffset_GetProgramivNV, GetProgramivNV@12)
+ GL_STUB(GetProgramStringNV, _gloffset_GetProgramStringNV, GetProgramStringNV@12)
+ GL_STUB(GetTrackMatrixivNV, _gloffset_GetTrackMatrixivNV, GetTrackMatrixivNV@16)
+ GL_STUB(GetVertexAttribdvARB, _gloffset_GetVertexAttribdvARB, GetVertexAttribdvARB@12)
+ GL_STUB(GetVertexAttribfvARB, _gloffset_GetVertexAttribfvARB, GetVertexAttribfvARB@12)
+ GL_STUB(GetVertexAttribivARB, _gloffset_GetVertexAttribivARB, GetVertexAttribivARB@12)
+ GL_STUB(GetVertexAttribPointervNV, _gloffset_GetVertexAttribPointervNV, GetVertexAttribPointervNV@12)
+ GL_STUB(IsProgramNV, _gloffset_IsProgramNV, IsProgramNV@4)
+ GL_STUB(LoadProgramNV, _gloffset_LoadProgramNV, LoadProgramNV@16)
+ GL_STUB(ProgramParameter4dNV, _gloffset_ProgramParameter4dNV, ProgramParameter4dNV@40)
+ GL_STUB(ProgramParameter4dvNV, _gloffset_ProgramParameter4dvNV, ProgramParameter4dvNV@12)
+ GL_STUB(ProgramParameter4fNV, _gloffset_ProgramParameter4fNV, ProgramParameter4fNV@24)
+ GL_STUB(ProgramParameter4fvNV, _gloffset_ProgramParameter4fvNV, ProgramParameter4fvNV@12)
+ GL_STUB(ProgramParameters4dvNV, _gloffset_ProgramParameters4dvNV, ProgramParameters4dvNV@16)
+ GL_STUB(ProgramParameters4fvNV, _gloffset_ProgramParameters4fvNV, ProgramParameters4fvNV@16)
+ GL_STUB(RequestResidentProgramsNV, _gloffset_RequestResidentProgramsNV, RequestResidentProgramsNV@8)
+ GL_STUB(TrackMatrixNV, _gloffset_TrackMatrixNV, TrackMatrixNV@16)
+ GL_STUB(VertexAttribPointerNV, _gloffset_VertexAttribPointerNV, VertexAttribPointerNV@20)
+ GL_STUB(VertexAttrib1dARB, _gloffset_VertexAttrib1dARB, VertexAttrib1dARB@12)
+ GL_STUB(VertexAttrib1dvARB, _gloffset_VertexAttrib1dvARB, VertexAttrib1dvARB@8)
+ GL_STUB(VertexAttrib1fARB, _gloffset_VertexAttrib1fARB, VertexAttrib1fARB@8)
+ GL_STUB(VertexAttrib1fvARB, _gloffset_VertexAttrib1fvARB, VertexAttrib1fvARB@8)
+ GL_STUB(VertexAttrib1sARB, _gloffset_VertexAttrib1sARB, VertexAttrib1sARB@8)
+ GL_STUB(VertexAttrib1svARB, _gloffset_VertexAttrib1svARB, VertexAttrib1svARB@8)
+ GL_STUB(VertexAttrib2dARB, _gloffset_VertexAttrib2dARB, VertexAttrib2dARB@20)
+ GL_STUB(VertexAttrib2dvARB, _gloffset_VertexAttrib2dvARB, VertexAttrib2dvARB@8)
+ GL_STUB(VertexAttrib2fARB, _gloffset_VertexAttrib2fARB, VertexAttrib2fARB@12)
+ GL_STUB(VertexAttrib2fvARB, _gloffset_VertexAttrib2fvARB, VertexAttrib2fvARB@8)
+ GL_STUB(VertexAttrib2sARB, _gloffset_VertexAttrib2sARB, VertexAttrib2sARB@12)
+ GL_STUB(VertexAttrib2svARB, _gloffset_VertexAttrib2svARB, VertexAttrib2svARB@8)
+ GL_STUB(VertexAttrib3dARB, _gloffset_VertexAttrib3dARB, VertexAttrib3dARB@28)
+ GL_STUB(VertexAttrib3dvARB, _gloffset_VertexAttrib3dvARB, VertexAttrib3dvARB@8)
+ GL_STUB(VertexAttrib3fARB, _gloffset_VertexAttrib3fARB, VertexAttrib3fARB@16)
+ GL_STUB(VertexAttrib3fvARB, _gloffset_VertexAttrib3fvARB, VertexAttrib3fvARB@8)
+ GL_STUB(VertexAttrib3sARB, _gloffset_VertexAttrib3sARB, VertexAttrib3sARB@16)
+ GL_STUB(VertexAttrib3svARB, _gloffset_VertexAttrib3svARB, VertexAttrib3svARB@8)
+ GL_STUB(VertexAttrib4dARB, _gloffset_VertexAttrib4dARB, VertexAttrib4dARB@36)
+ GL_STUB(VertexAttrib4dvARB, _gloffset_VertexAttrib4dvARB, VertexAttrib4dvARB@8)
+ GL_STUB(VertexAttrib4fARB, _gloffset_VertexAttrib4fARB, VertexAttrib4fARB@20)
+ GL_STUB(VertexAttrib4fvARB, _gloffset_VertexAttrib4fvARB, VertexAttrib4fvARB@8)
+ GL_STUB(VertexAttrib4sARB, _gloffset_VertexAttrib4sARB, VertexAttrib4sARB@20)
+ GL_STUB(VertexAttrib4svARB, _gloffset_VertexAttrib4svARB, VertexAttrib4svARB@8)
+ GL_STUB(VertexAttrib4NubARB, _gloffset_VertexAttrib4NubARB, VertexAttrib4NubARB@20)
+ GL_STUB(VertexAttrib4NubvARB, _gloffset_VertexAttrib4NubvARB, VertexAttrib4NubvARB@8)
+ GL_STUB(VertexAttribs1dvNV, _gloffset_VertexAttribs1dvNV, VertexAttribs1dvNV@12)
+ GL_STUB(VertexAttribs1fvNV, _gloffset_VertexAttribs1fvNV, VertexAttribs1fvNV@12)
+ GL_STUB(VertexAttribs1svNV, _gloffset_VertexAttribs1svNV, VertexAttribs1svNV@12)
+ GL_STUB(VertexAttribs2dvNV, _gloffset_VertexAttribs2dvNV, VertexAttribs2dvNV@12)
+ GL_STUB(VertexAttribs2fvNV, _gloffset_VertexAttribs2fvNV, VertexAttribs2fvNV@12)
+ GL_STUB(VertexAttribs2svNV, _gloffset_VertexAttribs2svNV, VertexAttribs2svNV@12)
+ GL_STUB(VertexAttribs3dvNV, _gloffset_VertexAttribs3dvNV, VertexAttribs3dvNV@12)
+ GL_STUB(VertexAttribs3fvNV, _gloffset_VertexAttribs3fvNV, VertexAttribs3fvNV@12)
+ GL_STUB(VertexAttribs3svNV, _gloffset_VertexAttribs3svNV, VertexAttribs3svNV@12)
+ GL_STUB(VertexAttribs4dvNV, _gloffset_VertexAttribs4dvNV, VertexAttribs4dvNV@12)
+ GL_STUB(VertexAttribs4fvNV, _gloffset_VertexAttribs4fvNV, VertexAttribs4fvNV@12)
+ GL_STUB(VertexAttribs4svNV, _gloffset_VertexAttribs4svNV, VertexAttribs4svNV@12)
+ GL_STUB(VertexAttribs4ubvNV, _gloffset_VertexAttribs4ubvNV, VertexAttribs4ubvNV@12)
+ GL_STUB(PointParameteriNV, _gloffset_PointParameteriNV, PointParameteriNV@8)
+ GL_STUB(PointParameterivNV, _gloffset_PointParameterivNV, PointParameterivNV@8)
+ GL_STUB(MultiDrawArraysEXT, _gloffset_MultiDrawArraysEXT, MultiDrawArraysEXT@16)
+ GL_STUB(MultiDrawElementsEXT, _gloffset_MultiDrawElementsEXT, MultiDrawElementsEXT@20)
+ GL_STUB(ActiveStencilFaceEXT, _gloffset_ActiveStencilFaceEXT, ActiveStencilFaceEXT@4)
+ GL_STUB(DeleteFencesNV, _gloffset_DeleteFencesNV, DeleteFencesNV@8)
+ GL_STUB(GenFencesNV, _gloffset_GenFencesNV, GenFencesNV@8)
+ GL_STUB(IsFenceNV, _gloffset_IsFenceNV, IsFenceNV@4)
+ GL_STUB(TestFenceNV, _gloffset_TestFenceNV, TestFenceNV@4)
+ GL_STUB(GetFenceivNV, _gloffset_GetFenceivNV, GetFenceivNV@12)
+ GL_STUB(FinishFenceNV, _gloffset_FinishFenceNV, FinishFenceNV@4)
+ GL_STUB(SetFenceNV, _gloffset_SetFenceNV, SetFenceNV@8)
+ GL_STUB(VertexAttrib4bvARB, _gloffset_VertexAttrib4bvARB, VertexAttrib4bvARB@8)
+ GL_STUB(VertexAttrib4ivARB, _gloffset_VertexAttrib4ivARB, VertexAttrib4ivARB@8)
+ GL_STUB(VertexAttrib4ubvARB, _gloffset_VertexAttrib4ubvARB, VertexAttrib4ubvARB@8)
+ GL_STUB(VertexAttrib4usvARB, _gloffset_VertexAttrib4usvARB, VertexAttrib4usvARB@8)
+ GL_STUB(VertexAttrib4uivARB, _gloffset_VertexAttrib4uivARB, VertexAttrib4uivARB@8)
+ GL_STUB(VertexAttrib4NbvARB, _gloffset_VertexAttrib4NbvARB, VertexAttrib4NbvARB@8)
+ GL_STUB(VertexAttrib4NsvARB, _gloffset_VertexAttrib4NsvARB, VertexAttrib4NsvARB@8)
+ GL_STUB(VertexAttrib4NivARB, _gloffset_VertexAttrib4NivARB, VertexAttrib4NivARB@8)
+ GL_STUB(VertexAttrib4NusvARB, _gloffset_VertexAttrib4NusvARB, VertexAttrib4NusvARB@8)
+ GL_STUB(VertexAttrib4NuivARB, _gloffset_VertexAttrib4NuivARB, VertexAttrib4NuivARB@8)
+ GL_STUB(VertexAttribPointerARB, _gloffset_VertexAttribPointerARB, VertexAttribPointerARB@24)
+ GL_STUB(EnableVertexAttribArrayARB, _gloffset_EnableVertexAttribArrayARB, EnableVertexAttribArrayARB@4)
+ GL_STUB(DisableVertexAttribArrayARB, _gloffset_DisableVertexAttribArrayARB, DisableVertexAttribArrayARB@4)
+ GL_STUB(ProgramStringARB, _gloffset_ProgramStringARB, ProgramStringARB@16)
+ GL_STUB(ProgramEnvParameter4dARB, _gloffset_ProgramEnvParameter4dARB, ProgramEnvParameter4dARB@40)
+ GL_STUB(ProgramEnvParameter4dvARB, _gloffset_ProgramEnvParameter4dvARB, ProgramEnvParameter4dvARB@12)
+ GL_STUB(ProgramEnvParameter4fARB, _gloffset_ProgramEnvParameter4fARB, ProgramEnvParameter4fARB@24)
+ GL_STUB(ProgramEnvParameter4fvARB, _gloffset_ProgramEnvParameter4fvARB, ProgramEnvParameter4fvARB@12)
+ GL_STUB(ProgramLocalParameter4dARB, _gloffset_ProgramLocalParameter4dARB, ProgramLocalParameter4dARB@40)
+ GL_STUB(ProgramLocalParameter4dvARB, _gloffset_ProgramLocalParameter4dvARB, ProgramLocalParameter4dvARB@12)
+ GL_STUB(ProgramLocalParameter4fARB, _gloffset_ProgramLocalParameter4fARB, ProgramLocalParameter4fARB@24)
+ GL_STUB(ProgramLocalParameter4fvARB, _gloffset_ProgramLocalParameter4fvARB, ProgramLocalParameter4fvARB@12)
+ GL_STUB(GetProgramEnvParameterdvARB, _gloffset_GetProgramEnvParameterdvARB, GetProgramEnvParameterdvARB@12)
+ GL_STUB(GetProgramEnvParameterfvARB, _gloffset_GetProgramEnvParameterfvARB, GetProgramEnvParameterfvARB@12)
+ GL_STUB(GetProgramLocalParameterdvARB, _gloffset_GetProgramLocalParameterdvARB, GetProgramLocalParameterdvARB@12)
+ GL_STUB(GetProgramLocalParameterfvARB, _gloffset_GetProgramLocalParameterfvARB, GetProgramLocalParameterfvARB@12)
+ GL_STUB(GetProgramivARB, _gloffset_GetProgramivARB, GetProgramivARB@12)
+ GL_STUB(GetProgramStringARB, _gloffset_GetProgramStringARB, GetProgramStringARB@12)
+ GL_STUB(ProgramNamedParameter4fNV, _gloffset_ProgramNamedParameter4fNV, ProgramNamedParameter4fNV@28)
+ GL_STUB(ProgramNamedParameter4dNV, _gloffset_ProgramNamedParameter4dNV, ProgramNamedParameter4dNV@44)
+ GL_STUB(ProgramNamedParameter4fvNV, _gloffset_ProgramNamedParameter4fvNV, ProgramNamedParameter4fvNV@16)
+ GL_STUB(ProgramNamedParameter4dvNV, _gloffset_ProgramNamedParameter4dvNV, ProgramNamedParameter4dvNV@16)
+ GL_STUB(GetProgramNamedParameterfvNV, _gloffset_GetProgramNamedParameterfvNV, GetProgramNamedParameterfvNV@16)
+ GL_STUB(GetProgramNamedParameterdvNV, _gloffset_GetProgramNamedParameterdvNV, GetProgramNamedParameterdvNV@16)
+ GL_STUB(BindBufferARB, _gloffset_BindBufferARB, BindBufferARB@8)
+ GL_STUB(BufferDataARB, _gloffset_BufferDataARB, BufferDataARB@16)
+ GL_STUB(BufferSubDataARB, _gloffset_BufferSubDataARB, BufferSubDataARB@16)
+ GL_STUB(DeleteBuffersARB, _gloffset_DeleteBuffersARB, DeleteBuffersARB@8)
+ GL_STUB(GenBuffersARB, _gloffset_GenBuffersARB, GenBuffersARB@8)
+ GL_STUB(GetBufferParameterivARB, _gloffset_GetBufferParameterivARB, GetBufferParameterivARB@12)
+ GL_STUB(GetBufferPointervARB, _gloffset_GetBufferPointervARB, GetBufferPointervARB@12)
+ GL_STUB(GetBufferSubDataARB, _gloffset_GetBufferSubDataARB, GetBufferSubDataARB@16)
+ GL_STUB(IsBufferARB, _gloffset_IsBufferARB, IsBufferARB@4)
+ GL_STUB(MapBufferARB, _gloffset_MapBufferARB, MapBufferARB@8)
+ GL_STUB(UnmapBufferARB, _gloffset_UnmapBufferARB, UnmapBufferARB@4)
+ GL_STUB(DepthBoundsEXT, _gloffset_DepthBoundsEXT, DepthBoundsEXT@16)
+ GL_STUB(GenQueriesARB, _gloffset_GenQueriesARB, GenQueriesARB@8)
+ GL_STUB(DeleteQueriesARB, _gloffset_DeleteQueriesARB, DeleteQueriesARB@8)
+ GL_STUB(IsQueryARB, _gloffset_IsQueryARB, IsQueryARB@4)
+ GL_STUB(BeginQueryARB, _gloffset_BeginQueryARB, BeginQueryARB@8)
+ GL_STUB(EndQueryARB, _gloffset_EndQueryARB, EndQueryARB@4)
+ GL_STUB(GetQueryivARB, _gloffset_GetQueryivARB, GetQueryivARB@12)
+ GL_STUB(GetQueryObjectivARB, _gloffset_GetQueryObjectivARB, GetQueryObjectivARB@12)
+ GL_STUB(GetQueryObjectuivARB, _gloffset_GetQueryObjectuivARB, GetQueryObjectuivARB@12)
+ GL_STUB(MultiModeDrawArraysIBM, _gloffset_MultiModeDrawArraysIBM, MultiModeDrawArraysIBM@20)
+ GL_STUB(MultiModeDrawElementsIBM, _gloffset_MultiModeDrawElementsIBM, MultiModeDrawElementsIBM@24)
+ GL_STUB(BlendEquationSeparateEXT, _gloffset_BlendEquationSeparateEXT, BlendEquationSeparateEXT@8)
+ GL_STUB(DeleteObjectARB, _gloffset_DeleteObjectARB, DeleteObjectARB@4)
+ GL_STUB(GetHandleARB, _gloffset_GetHandleARB, GetHandleARB@4)
+ GL_STUB(DetachObjectARB, _gloffset_DetachObjectARB, DetachObjectARB@8)
+ GL_STUB(CreateShaderObjectARB, _gloffset_CreateShaderObjectARB, CreateShaderObjectARB@4)
+ GL_STUB(ShaderSourceARB, _gloffset_ShaderSourceARB, ShaderSourceARB@16)
+ GL_STUB(CompileShaderARB, _gloffset_CompileShaderARB, CompileShaderARB@4)
+ GL_STUB(CreateProgramObjectARB, _gloffset_CreateProgramObjectARB, CreateProgramObjectARB@0)
+ GL_STUB(AttachObjectARB, _gloffset_AttachObjectARB, AttachObjectARB@8)
+ GL_STUB(LinkProgramARB, _gloffset_LinkProgramARB, LinkProgramARB@4)
+ GL_STUB(UseProgramObjectARB, _gloffset_UseProgramObjectARB, UseProgramObjectARB@4)
+ GL_STUB(ValidateProgramARB, _gloffset_ValidateProgramARB, ValidateProgramARB@4)
+ GL_STUB(Uniform1fARB, _gloffset_Uniform1fARB, Uniform1fARB@8)
+ GL_STUB(Uniform2fARB, _gloffset_Uniform2fARB, Uniform2fARB@12)
+ GL_STUB(Uniform3fARB, _gloffset_Uniform3fARB, Uniform3fARB@16)
+ GL_STUB(Uniform4fARB, _gloffset_Uniform4fARB, Uniform4fARB@20)
+ GL_STUB(Uniform1iARB, _gloffset_Uniform1iARB, Uniform1iARB@8)
+ GL_STUB(Uniform2iARB, _gloffset_Uniform2iARB, Uniform2iARB@12)
+ GL_STUB(Uniform3iARB, _gloffset_Uniform3iARB, Uniform3iARB@16)
+ GL_STUB(Uniform4iARB, _gloffset_Uniform4iARB, Uniform4iARB@20)
+ GL_STUB(Uniform1fvARB, _gloffset_Uniform1fvARB, Uniform1fvARB@12)
+ GL_STUB(Uniform2fvARB, _gloffset_Uniform2fvARB, Uniform2fvARB@12)
+ GL_STUB(Uniform3fvARB, _gloffset_Uniform3fvARB, Uniform3fvARB@12)
+ GL_STUB(Uniform4fvARB, _gloffset_Uniform4fvARB, Uniform4fvARB@12)
+ GL_STUB(Uniform1ivARB, _gloffset_Uniform1ivARB, Uniform1ivARB@12)
+ GL_STUB(Uniform2ivARB, _gloffset_Uniform2ivARB, Uniform2ivARB@12)
+ GL_STUB(Uniform3ivARB, _gloffset_Uniform3ivARB, Uniform3ivARB@12)
+ GL_STUB(Uniform4ivARB, _gloffset_Uniform4ivARB, Uniform4ivARB@12)
+ GL_STUB(UniformMatrix2fvARB, _gloffset_UniformMatrix2fvARB, UniformMatrix2fvARB@16)
+ GL_STUB(UniformMatrix3fvARB, _gloffset_UniformMatrix3fvARB, UniformMatrix3fvARB@16)
+ GL_STUB(UniformMatrix4fvARB, _gloffset_UniformMatrix4fvARB, UniformMatrix4fvARB@16)
+ GL_STUB(GetObjectParameterfvARB, _gloffset_GetObjectParameterfvARB, GetObjectParameterfvARB@12)
+ GL_STUB(GetObjectParameterivARB, _gloffset_GetObjectParameterivARB, GetObjectParameterivARB@12)
+ GL_STUB(GetInfoLogARB, _gloffset_GetInfoLogARB, GetInfoLogARB@16)
+ GL_STUB(GetAttachedObjectsARB, _gloffset_GetAttachedObjectsARB, GetAttachedObjectsARB@16)
+ GL_STUB(GetUniformLocationARB, _gloffset_GetUniformLocationARB, GetUniformLocationARB@8)
+ GL_STUB(GetActiveUniformARB, _gloffset_GetActiveUniformARB, GetActiveUniformARB@28)
+ GL_STUB(GetUniformfvARB, _gloffset_GetUniformfvARB, GetUniformfvARB@12)
+ GL_STUB(GetUniformivARB, _gloffset_GetUniformivARB, GetUniformivARB@12)
+ GL_STUB(GetShaderSourceARB, _gloffset_GetShaderSourceARB, GetShaderSourceARB@16)
+ GL_STUB(BindAttribLocationARB, _gloffset_BindAttribLocationARB, BindAttribLocationARB@12)
+ GL_STUB(GetActiveAttribARB, _gloffset_GetActiveAttribARB, GetActiveAttribARB@28)
+ GL_STUB(GetAttribLocationARB, _gloffset_GetAttribLocationARB, GetAttribLocationARB@8)
+ GL_STUB(GetVertexAttribdvNV, _gloffset_GetVertexAttribdvNV, GetVertexAttribdvNV@12)
+ GL_STUB(GetVertexAttribfvNV, _gloffset_GetVertexAttribfvNV, GetVertexAttribfvNV@12)
+ GL_STUB(GetVertexAttribivNV, _gloffset_GetVertexAttribivNV, GetVertexAttribivNV@12)
+ GL_STUB(VertexAttrib1dNV, _gloffset_VertexAttrib1dNV, VertexAttrib1dNV@12)
+ GL_STUB(VertexAttrib1dvNV, _gloffset_VertexAttrib1dvNV, VertexAttrib1dvNV@8)
+ GL_STUB(VertexAttrib1fNV, _gloffset_VertexAttrib1fNV, VertexAttrib1fNV@8)
+ GL_STUB(VertexAttrib1fvNV, _gloffset_VertexAttrib1fvNV, VertexAttrib1fvNV@8)
+ GL_STUB(VertexAttrib1sNV, _gloffset_VertexAttrib1sNV, VertexAttrib1sNV@8)
+ GL_STUB(VertexAttrib1svNV, _gloffset_VertexAttrib1svNV, VertexAttrib1svNV@8)
+ GL_STUB(VertexAttrib2dNV, _gloffset_VertexAttrib2dNV, VertexAttrib2dNV@20)
+ GL_STUB(VertexAttrib2dvNV, _gloffset_VertexAttrib2dvNV, VertexAttrib2dvNV@8)
+ GL_STUB(VertexAttrib2fNV, _gloffset_VertexAttrib2fNV, VertexAttrib2fNV@12)
+ GL_STUB(VertexAttrib2fvNV, _gloffset_VertexAttrib2fvNV, VertexAttrib2fvNV@8)
+ GL_STUB(VertexAttrib2sNV, _gloffset_VertexAttrib2sNV, VertexAttrib2sNV@12)
+ GL_STUB(VertexAttrib2svNV, _gloffset_VertexAttrib2svNV, VertexAttrib2svNV@8)
+ GL_STUB(VertexAttrib3dNV, _gloffset_VertexAttrib3dNV, VertexAttrib3dNV@28)
+ GL_STUB(VertexAttrib3dvNV, _gloffset_VertexAttrib3dvNV, VertexAttrib3dvNV@8)
+ GL_STUB(VertexAttrib3fNV, _gloffset_VertexAttrib3fNV, VertexAttrib3fNV@16)
+ GL_STUB(VertexAttrib3fvNV, _gloffset_VertexAttrib3fvNV, VertexAttrib3fvNV@8)
+ GL_STUB(VertexAttrib3sNV, _gloffset_VertexAttrib3sNV, VertexAttrib3sNV@16)
+ GL_STUB(VertexAttrib3svNV, _gloffset_VertexAttrib3svNV, VertexAttrib3svNV@8)
+ GL_STUB(VertexAttrib4dNV, _gloffset_VertexAttrib4dNV, VertexAttrib4dNV@36)
+ GL_STUB(VertexAttrib4dvNV, _gloffset_VertexAttrib4dvNV, VertexAttrib4dvNV@8)
+ GL_STUB(VertexAttrib4fNV, _gloffset_VertexAttrib4fNV, VertexAttrib4fNV@20)
+ GL_STUB(VertexAttrib4fvNV, _gloffset_VertexAttrib4fvNV, VertexAttrib4fvNV@8)
+ GL_STUB(VertexAttrib4sNV, _gloffset_VertexAttrib4sNV, VertexAttrib4sNV@20)
+ GL_STUB(VertexAttrib4svNV, _gloffset_VertexAttrib4svNV, VertexAttrib4svNV@8)
+ GL_STUB(VertexAttrib4ubNV, _gloffset_VertexAttrib4ubNV, VertexAttrib4ubNV@20)
+ GL_STUB(VertexAttrib4ubvNV, _gloffset_VertexAttrib4ubvNV, VertexAttrib4ubvNV@8)
+ GL_STUB(GenFragmentShadersATI, _gloffset_GenFragmentShadersATI, GenFragmentShadersATI@4)
+ GL_STUB(BindFragmentShaderATI, _gloffset_BindFragmentShaderATI, BindFragmentShaderATI@4)
+ GL_STUB(DeleteFragmentShaderATI, _gloffset_DeleteFragmentShaderATI, DeleteFragmentShaderATI@4)
+ GL_STUB(BeginFragmentShaderATI, _gloffset_BeginFragmentShaderATI, BeginFragmentShaderATI@0)
+ GL_STUB(EndFragmentShaderATI, _gloffset_EndFragmentShaderATI, EndFragmentShaderATI@0)
+ GL_STUB(PassTexCoordATI, _gloffset_PassTexCoordATI, PassTexCoordATI@12)
+ GL_STUB(SampleMapATI, _gloffset_SampleMapATI, SampleMapATI@12)
+ GL_STUB(ColorFragmentOp1ATI, _gloffset_ColorFragmentOp1ATI, ColorFragmentOp1ATI@28)
+ GL_STUB(ColorFragmentOp2ATI, _gloffset_ColorFragmentOp2ATI, ColorFragmentOp2ATI@40)
+ GL_STUB(ColorFragmentOp3ATI, _gloffset_ColorFragmentOp3ATI, ColorFragmentOp3ATI@52)
+ GL_STUB(AlphaFragmentOp1ATI, _gloffset_AlphaFragmentOp1ATI, AlphaFragmentOp1ATI@24)
+ GL_STUB(AlphaFragmentOp2ATI, _gloffset_AlphaFragmentOp2ATI, AlphaFragmentOp2ATI@36)
+ GL_STUB(AlphaFragmentOp3ATI, _gloffset_AlphaFragmentOp3ATI, AlphaFragmentOp3ATI@48)
+ GL_STUB(SetFragmentShaderConstantATI, _gloffset_SetFragmentShaderConstantATI, SetFragmentShaderConstantATI@8)
+ GL_STUB(IsRenderbufferEXT, _gloffset_IsRenderbufferEXT, IsRenderbufferEXT@4)
+ GL_STUB(BindRenderbufferEXT, _gloffset_BindRenderbufferEXT, BindRenderbufferEXT@8)
+ GL_STUB(DeleteRenderbuffersEXT, _gloffset_DeleteRenderbuffersEXT, DeleteRenderbuffersEXT@8)
+ GL_STUB(GenRenderbuffersEXT, _gloffset_GenRenderbuffersEXT, GenRenderbuffersEXT@8)
+ GL_STUB(RenderbufferStorageEXT, _gloffset_RenderbufferStorageEXT, RenderbufferStorageEXT@16)
+ GL_STUB(GetRenderbufferParameterivEXT, _gloffset_GetRenderbufferParameterivEXT, GetRenderbufferParameterivEXT@12)
+ GL_STUB(IsFramebufferEXT, _gloffset_IsFramebufferEXT, IsFramebufferEXT@4)
+ GL_STUB(BindFramebufferEXT, _gloffset_BindFramebufferEXT, BindFramebufferEXT@8)
+ GL_STUB(DeleteFramebuffersEXT, _gloffset_DeleteFramebuffersEXT, DeleteFramebuffersEXT@8)
+ GL_STUB(GenFramebuffersEXT, _gloffset_GenFramebuffersEXT, GenFramebuffersEXT@8)
+ GL_STUB(CheckFramebufferStatusEXT, _gloffset_CheckFramebufferStatusEXT, CheckFramebufferStatusEXT@4)
+ GL_STUB(FramebufferTexture1DEXT, _gloffset_FramebufferTexture1DEXT, FramebufferTexture1DEXT@20)
+ GL_STUB(FramebufferTexture2DEXT, _gloffset_FramebufferTexture2DEXT, FramebufferTexture2DEXT@20)
+ GL_STUB(FramebufferTexture3DEXT, _gloffset_FramebufferTexture3DEXT, FramebufferTexture3DEXT@24)
+ GL_STUB(FramebufferRenderbufferEXT, _gloffset_FramebufferRenderbufferEXT, FramebufferRenderbufferEXT@16)
+ GL_STUB(GetFramebufferAttachmentParameterivEXT, _gloffset_GetFramebufferAttachmentParameterivEXT, GetFramebufferAttachmentParameterivEXT@16)
+ GL_STUB(GenerateMipmapEXT, _gloffset_GenerateMipmapEXT, GenerateMipmapEXT@4)
+ GL_STUB(StencilFuncSeparate, _gloffset_StencilFuncSeparate, StencilFuncSeparate@16)
+ GL_STUB(StencilOpSeparate, _gloffset_StencilOpSeparate, StencilOpSeparate@16)
+ GL_STUB(StencilMaskSeparate, _gloffset_StencilMaskSeparate, StencilMaskSeparate@8)
+ GL_STUB_ALIAS(ArrayElementEXT, _gloffset_ArrayElement, ArrayElementEXT@4, ArrayElement, ArrayElement@4)
+ GL_STUB_ALIAS(BindTextureEXT, _gloffset_BindTexture, BindTextureEXT@8, BindTexture, BindTexture@8)
+ GL_STUB_ALIAS(DrawArraysEXT, _gloffset_DrawArrays, DrawArraysEXT@12, DrawArrays, DrawArrays@12)
+ GL_STUB_ALIAS(CopyTexImage1DEXT, _gloffset_CopyTexImage1D, CopyTexImage1DEXT@28, CopyTexImage1D, CopyTexImage1D@28)
+ GL_STUB_ALIAS(CopyTexImage2DEXT, _gloffset_CopyTexImage2D, CopyTexImage2DEXT@32, CopyTexImage2D, CopyTexImage2D@32)
+ GL_STUB_ALIAS(CopyTexSubImage1DEXT, _gloffset_CopyTexSubImage1D, CopyTexSubImage1DEXT@24, CopyTexSubImage1D, CopyTexSubImage1D@24)
+ GL_STUB_ALIAS(CopyTexSubImage2DEXT, _gloffset_CopyTexSubImage2D, CopyTexSubImage2DEXT@32, CopyTexSubImage2D, CopyTexSubImage2D@32)
+ GL_STUB_ALIAS(DeleteTexturesEXT, _gloffset_DeleteTextures, DeleteTexturesEXT@8, DeleteTextures, DeleteTextures@8)
+ GL_STUB_ALIAS(GetPointervEXT, _gloffset_GetPointerv, GetPointervEXT@8, GetPointerv, GetPointerv@8)
+ GL_STUB_ALIAS(PrioritizeTexturesEXT, _gloffset_PrioritizeTextures, PrioritizeTexturesEXT@12, PrioritizeTextures, PrioritizeTextures@12)
+ GL_STUB_ALIAS(TexSubImage1DEXT, _gloffset_TexSubImage1D, TexSubImage1DEXT@28, TexSubImage1D, TexSubImage1D@28)
+ GL_STUB_ALIAS(TexSubImage2DEXT, _gloffset_TexSubImage2D, TexSubImage2DEXT@36, TexSubImage2D, TexSubImage2D@36)
+ GL_STUB_ALIAS(BlendColorEXT, _gloffset_BlendColor, BlendColorEXT@16, BlendColor, BlendColor@16)
+ GL_STUB_ALIAS(BlendEquationEXT, _gloffset_BlendEquation, BlendEquationEXT@4, BlendEquation, BlendEquation@4)
+ GL_STUB_ALIAS(DrawRangeElementsEXT, _gloffset_DrawRangeElements, DrawRangeElementsEXT@24, DrawRangeElements, DrawRangeElements@24)
+ GL_STUB_ALIAS(ColorTableSGI, _gloffset_ColorTable, ColorTableSGI@24, ColorTable, ColorTable@24)
+ GL_STUB_ALIAS(ColorTableEXT, _gloffset_ColorTable, ColorTableEXT@24, ColorTable, ColorTable@24)
+ GL_STUB_ALIAS(ColorTableParameterfvSGI, _gloffset_ColorTableParameterfv, ColorTableParameterfvSGI@12, ColorTableParameterfv, ColorTableParameterfv@12)
+ GL_STUB_ALIAS(ColorTableParameterivSGI, _gloffset_ColorTableParameteriv, ColorTableParameterivSGI@12, ColorTableParameteriv, ColorTableParameteriv@12)
+ GL_STUB_ALIAS(CopyColorTableSGI, _gloffset_CopyColorTable, CopyColorTableSGI@20, CopyColorTable, CopyColorTable@20)
+ GL_STUB_ALIAS(ColorSubTableEXT, _gloffset_ColorSubTable, ColorSubTableEXT@24, ColorSubTable, ColorSubTable@24)
+ GL_STUB_ALIAS(CopyColorSubTableEXT, _gloffset_CopyColorSubTable, CopyColorSubTableEXT@20, CopyColorSubTable, CopyColorSubTable@20)
+ GL_STUB_ALIAS(ConvolutionFilter1DEXT, _gloffset_ConvolutionFilter1D, ConvolutionFilter1DEXT@24, ConvolutionFilter1D, ConvolutionFilter1D@24)
+ GL_STUB_ALIAS(ConvolutionFilter2DEXT, _gloffset_ConvolutionFilter2D, ConvolutionFilter2DEXT@28, ConvolutionFilter2D, ConvolutionFilter2D@28)
+ GL_STUB_ALIAS(ConvolutionParameterfEXT, _gloffset_ConvolutionParameterf, ConvolutionParameterfEXT@12, ConvolutionParameterf, ConvolutionParameterf@12)
+ GL_STUB_ALIAS(ConvolutionParameterfvEXT, _gloffset_ConvolutionParameterfv, ConvolutionParameterfvEXT@12, ConvolutionParameterfv, ConvolutionParameterfv@12)
+ GL_STUB_ALIAS(ConvolutionParameteriEXT, _gloffset_ConvolutionParameteri, ConvolutionParameteriEXT@12, ConvolutionParameteri, ConvolutionParameteri@12)
+ GL_STUB_ALIAS(ConvolutionParameterivEXT, _gloffset_ConvolutionParameteriv, ConvolutionParameterivEXT@12, ConvolutionParameteriv, ConvolutionParameteriv@12)
+ GL_STUB_ALIAS(CopyConvolutionFilter1DEXT, _gloffset_CopyConvolutionFilter1D, CopyConvolutionFilter1DEXT@20, CopyConvolutionFilter1D, CopyConvolutionFilter1D@20)
+ GL_STUB_ALIAS(CopyConvolutionFilter2DEXT, _gloffset_CopyConvolutionFilter2D, CopyConvolutionFilter2DEXT@24, CopyConvolutionFilter2D, CopyConvolutionFilter2D@24)
+ GL_STUB_ALIAS(SeparableFilter2DEXT, _gloffset_SeparableFilter2D, SeparableFilter2DEXT@32, SeparableFilter2D, SeparableFilter2D@32)
+ GL_STUB_ALIAS(HistogramEXT, _gloffset_Histogram, HistogramEXT@16, Histogram, Histogram@16)
+ GL_STUB_ALIAS(MinmaxEXT, _gloffset_Minmax, MinmaxEXT@12, Minmax, Minmax@12)
+ GL_STUB_ALIAS(ResetHistogramEXT, _gloffset_ResetHistogram, ResetHistogramEXT@4, ResetHistogram, ResetHistogram@4)
+ GL_STUB_ALIAS(ResetMinmaxEXT, _gloffset_ResetMinmax, ResetMinmaxEXT@4, ResetMinmax, ResetMinmax@4)
+ GL_STUB_ALIAS(TexImage3DEXT, _gloffset_TexImage3D, TexImage3DEXT@40, TexImage3D, TexImage3D@40)
+ GL_STUB_ALIAS(TexSubImage3DEXT, _gloffset_TexSubImage3D, TexSubImage3DEXT@44, TexSubImage3D, TexSubImage3D@44)
+ GL_STUB_ALIAS(CopyTexSubImage3DEXT, _gloffset_CopyTexSubImage3D, CopyTexSubImage3DEXT@36, CopyTexSubImage3D, CopyTexSubImage3D@36)
+ GL_STUB_ALIAS(ActiveTexture, _gloffset_ActiveTextureARB, ActiveTexture@4, ActiveTextureARB, ActiveTextureARB@4)
+ GL_STUB_ALIAS(ClientActiveTexture, _gloffset_ClientActiveTextureARB, ClientActiveTexture@4, ClientActiveTextureARB, ClientActiveTextureARB@4)
+ GL_STUB_ALIAS(MultiTexCoord1d, _gloffset_MultiTexCoord1dARB, MultiTexCoord1d@12, MultiTexCoord1dARB, MultiTexCoord1dARB@12)
+ GL_STUB_ALIAS(MultiTexCoord1dv, _gloffset_MultiTexCoord1dvARB, MultiTexCoord1dv@8, MultiTexCoord1dvARB, MultiTexCoord1dvARB@8)
+ GL_STUB_ALIAS(MultiTexCoord1f, _gloffset_MultiTexCoord1fARB, MultiTexCoord1f@8, MultiTexCoord1fARB, MultiTexCoord1fARB@8)
+ GL_STUB_ALIAS(MultiTexCoord1fv, _gloffset_MultiTexCoord1fvARB, MultiTexCoord1fv@8, MultiTexCoord1fvARB, MultiTexCoord1fvARB@8)
+ GL_STUB_ALIAS(MultiTexCoord1i, _gloffset_MultiTexCoord1iARB, MultiTexCoord1i@8, MultiTexCoord1iARB, MultiTexCoord1iARB@8)
+ GL_STUB_ALIAS(MultiTexCoord1iv, _gloffset_MultiTexCoord1ivARB, MultiTexCoord1iv@8, MultiTexCoord1ivARB, MultiTexCoord1ivARB@8)
+ GL_STUB_ALIAS(MultiTexCoord1s, _gloffset_MultiTexCoord1sARB, MultiTexCoord1s@8, MultiTexCoord1sARB, MultiTexCoord1sARB@8)
+ GL_STUB_ALIAS(MultiTexCoord1sv, _gloffset_MultiTexCoord1svARB, MultiTexCoord1sv@8, MultiTexCoord1svARB, MultiTexCoord1svARB@8)
+ GL_STUB_ALIAS(MultiTexCoord2d, _gloffset_MultiTexCoord2dARB, MultiTexCoord2d@20, MultiTexCoord2dARB, MultiTexCoord2dARB@20)
+ GL_STUB_ALIAS(MultiTexCoord2dv, _gloffset_MultiTexCoord2dvARB, MultiTexCoord2dv@8, MultiTexCoord2dvARB, MultiTexCoord2dvARB@8)
+ GL_STUB_ALIAS(MultiTexCoord2f, _gloffset_MultiTexCoord2fARB, MultiTexCoord2f@12, MultiTexCoord2fARB, MultiTexCoord2fARB@12)
+ GL_STUB_ALIAS(MultiTexCoord2fv, _gloffset_MultiTexCoord2fvARB, MultiTexCoord2fv@8, MultiTexCoord2fvARB, MultiTexCoord2fvARB@8)
+ GL_STUB_ALIAS(MultiTexCoord2i, _gloffset_MultiTexCoord2iARB, MultiTexCoord2i@12, MultiTexCoord2iARB, MultiTexCoord2iARB@12)
+ GL_STUB_ALIAS(MultiTexCoord2iv, _gloffset_MultiTexCoord2ivARB, MultiTexCoord2iv@8, MultiTexCoord2ivARB, MultiTexCoord2ivARB@8)
+ GL_STUB_ALIAS(MultiTexCoord2s, _gloffset_MultiTexCoord2sARB, MultiTexCoord2s@12, MultiTexCoord2sARB, MultiTexCoord2sARB@12)
+ GL_STUB_ALIAS(MultiTexCoord2sv, _gloffset_MultiTexCoord2svARB, MultiTexCoord2sv@8, MultiTexCoord2svARB, MultiTexCoord2svARB@8)
+ GL_STUB_ALIAS(MultiTexCoord3d, _gloffset_MultiTexCoord3dARB, MultiTexCoord3d@28, MultiTexCoord3dARB, MultiTexCoord3dARB@28)
+ GL_STUB_ALIAS(MultiTexCoord3dv, _gloffset_MultiTexCoord3dvARB, MultiTexCoord3dv@8, MultiTexCoord3dvARB, MultiTexCoord3dvARB@8)
+ GL_STUB_ALIAS(MultiTexCoord3f, _gloffset_MultiTexCoord3fARB, MultiTexCoord3f@16, MultiTexCoord3fARB, MultiTexCoord3fARB@16)
+ GL_STUB_ALIAS(MultiTexCoord3fv, _gloffset_MultiTexCoord3fvARB, MultiTexCoord3fv@8, MultiTexCoord3fvARB, MultiTexCoord3fvARB@8)
+ GL_STUB_ALIAS(MultiTexCoord3i, _gloffset_MultiTexCoord3iARB, MultiTexCoord3i@16, MultiTexCoord3iARB, MultiTexCoord3iARB@16)
+ GL_STUB_ALIAS(MultiTexCoord3iv, _gloffset_MultiTexCoord3ivARB, MultiTexCoord3iv@8, MultiTexCoord3ivARB, MultiTexCoord3ivARB@8)
+ GL_STUB_ALIAS(MultiTexCoord3s, _gloffset_MultiTexCoord3sARB, MultiTexCoord3s@16, MultiTexCoord3sARB, MultiTexCoord3sARB@16)
+ GL_STUB_ALIAS(MultiTexCoord3sv, _gloffset_MultiTexCoord3svARB, MultiTexCoord3sv@8, MultiTexCoord3svARB, MultiTexCoord3svARB@8)
+ GL_STUB_ALIAS(MultiTexCoord4d, _gloffset_MultiTexCoord4dARB, MultiTexCoord4d@36, MultiTexCoord4dARB, MultiTexCoord4dARB@36)
+ GL_STUB_ALIAS(MultiTexCoord4dv, _gloffset_MultiTexCoord4dvARB, MultiTexCoord4dv@8, MultiTexCoord4dvARB, MultiTexCoord4dvARB@8)
+ GL_STUB_ALIAS(MultiTexCoord4f, _gloffset_MultiTexCoord4fARB, MultiTexCoord4f@20, MultiTexCoord4fARB, MultiTexCoord4fARB@20)
+ GL_STUB_ALIAS(MultiTexCoord4fv, _gloffset_MultiTexCoord4fvARB, MultiTexCoord4fv@8, MultiTexCoord4fvARB, MultiTexCoord4fvARB@8)
+ GL_STUB_ALIAS(MultiTexCoord4i, _gloffset_MultiTexCoord4iARB, MultiTexCoord4i@20, MultiTexCoord4iARB, MultiTexCoord4iARB@20)
+ GL_STUB_ALIAS(MultiTexCoord4iv, _gloffset_MultiTexCoord4ivARB, MultiTexCoord4iv@8, MultiTexCoord4ivARB, MultiTexCoord4ivARB@8)
+ GL_STUB_ALIAS(MultiTexCoord4s, _gloffset_MultiTexCoord4sARB, MultiTexCoord4s@20, MultiTexCoord4sARB, MultiTexCoord4sARB@20)
+ GL_STUB_ALIAS(MultiTexCoord4sv, _gloffset_MultiTexCoord4svARB, MultiTexCoord4sv@8, MultiTexCoord4svARB, MultiTexCoord4svARB@8)
+ GL_STUB_ALIAS(LoadTransposeMatrixf, _gloffset_LoadTransposeMatrixfARB, LoadTransposeMatrixf@4, LoadTransposeMatrixfARB, LoadTransposeMatrixfARB@4)
+ GL_STUB_ALIAS(LoadTransposeMatrixd, _gloffset_LoadTransposeMatrixdARB, LoadTransposeMatrixd@4, LoadTransposeMatrixdARB, LoadTransposeMatrixdARB@4)
+ GL_STUB_ALIAS(MultTransposeMatrixf, _gloffset_MultTransposeMatrixfARB, MultTransposeMatrixf@4, MultTransposeMatrixfARB, MultTransposeMatrixfARB@4)
+ GL_STUB_ALIAS(MultTransposeMatrixd, _gloffset_MultTransposeMatrixdARB, MultTransposeMatrixd@4, MultTransposeMatrixdARB, MultTransposeMatrixdARB@4)
+ GL_STUB_ALIAS(SampleCoverage, _gloffset_SampleCoverageARB, SampleCoverage@8, SampleCoverageARB, SampleCoverageARB@8)
+ GL_STUB_ALIAS(DrawBuffersATI, _gloffset_DrawBuffersARB, DrawBuffersATI@8, DrawBuffersARB, DrawBuffersARB@8)
+ GL_STUB_ALIAS(SampleMaskEXT, _gloffset_SampleMaskSGIS, SampleMaskEXT@8, SampleMaskSGIS, SampleMaskSGIS@8)
+ GL_STUB_ALIAS(SamplePatternEXT, _gloffset_SamplePatternSGIS, SamplePatternEXT@4, SamplePatternSGIS, SamplePatternSGIS@4)
+ GL_STUB_ALIAS(PointParameterf, _gloffset_PointParameterfEXT, PointParameterf@8, PointParameterfEXT, PointParameterfEXT@8)
+ GL_STUB_ALIAS(PointParameterfARB, _gloffset_PointParameterfEXT, PointParameterfARB@8, PointParameterfEXT, PointParameterfEXT@8)
+ GL_STUB_ALIAS(PointParameterfSGIS, _gloffset_PointParameterfEXT, PointParameterfSGIS@8, PointParameterfEXT, PointParameterfEXT@8)
+ GL_STUB_ALIAS(PointParameterfv, _gloffset_PointParameterfvEXT, PointParameterfv@8, PointParameterfvEXT, PointParameterfvEXT@8)
+ GL_STUB_ALIAS(PointParameterfvARB, _gloffset_PointParameterfvEXT, PointParameterfvARB@8, PointParameterfvEXT, PointParameterfvEXT@8)
+ GL_STUB_ALIAS(PointParameterfvSGIS, _gloffset_PointParameterfvEXT, PointParameterfvSGIS@8, PointParameterfvEXT, PointParameterfvEXT@8)
+ GL_STUB_ALIAS(WindowPos2d, _gloffset_WindowPos2dMESA, WindowPos2d@16, WindowPos2dMESA, WindowPos2dMESA@16)
+ GL_STUB_ALIAS(WindowPos2dARB, _gloffset_WindowPos2dMESA, WindowPos2dARB@16, WindowPos2dMESA, WindowPos2dMESA@16)
+ GL_STUB_ALIAS(WindowPos2dv, _gloffset_WindowPos2dvMESA, WindowPos2dv@4, WindowPos2dvMESA, WindowPos2dvMESA@4)
+ GL_STUB_ALIAS(WindowPos2dvARB, _gloffset_WindowPos2dvMESA, WindowPos2dvARB@4, WindowPos2dvMESA, WindowPos2dvMESA@4)
+ GL_STUB_ALIAS(WindowPos2f, _gloffset_WindowPos2fMESA, WindowPos2f@8, WindowPos2fMESA, WindowPos2fMESA@8)
+ GL_STUB_ALIAS(WindowPos2fARB, _gloffset_WindowPos2fMESA, WindowPos2fARB@8, WindowPos2fMESA, WindowPos2fMESA@8)
+ GL_STUB_ALIAS(WindowPos2fv, _gloffset_WindowPos2fvMESA, WindowPos2fv@4, WindowPos2fvMESA, WindowPos2fvMESA@4)
+ GL_STUB_ALIAS(WindowPos2fvARB, _gloffset_WindowPos2fvMESA, WindowPos2fvARB@4, WindowPos2fvMESA, WindowPos2fvMESA@4)
+ GL_STUB_ALIAS(WindowPos2i, _gloffset_WindowPos2iMESA, WindowPos2i@8, WindowPos2iMESA, WindowPos2iMESA@8)
+ GL_STUB_ALIAS(WindowPos2iARB, _gloffset_WindowPos2iMESA, WindowPos2iARB@8, WindowPos2iMESA, WindowPos2iMESA@8)
+ GL_STUB_ALIAS(WindowPos2iv, _gloffset_WindowPos2ivMESA, WindowPos2iv@4, WindowPos2ivMESA, WindowPos2ivMESA@4)
+ GL_STUB_ALIAS(WindowPos2ivARB, _gloffset_WindowPos2ivMESA, WindowPos2ivARB@4, WindowPos2ivMESA, WindowPos2ivMESA@4)
+ GL_STUB_ALIAS(WindowPos2s, _gloffset_WindowPos2sMESA, WindowPos2s@8, WindowPos2sMESA, WindowPos2sMESA@8)
+ GL_STUB_ALIAS(WindowPos2sARB, _gloffset_WindowPos2sMESA, WindowPos2sARB@8, WindowPos2sMESA, WindowPos2sMESA@8)
+ GL_STUB_ALIAS(WindowPos2sv, _gloffset_WindowPos2svMESA, WindowPos2sv@4, WindowPos2svMESA, WindowPos2svMESA@4)
+ GL_STUB_ALIAS(WindowPos2svARB, _gloffset_WindowPos2svMESA, WindowPos2svARB@4, WindowPos2svMESA, WindowPos2svMESA@4)
+ GL_STUB_ALIAS(WindowPos3d, _gloffset_WindowPos3dMESA, WindowPos3d@24, WindowPos3dMESA, WindowPos3dMESA@24)
+ GL_STUB_ALIAS(WindowPos3dARB, _gloffset_WindowPos3dMESA, WindowPos3dARB@24, WindowPos3dMESA, WindowPos3dMESA@24)
+ GL_STUB_ALIAS(WindowPos3dv, _gloffset_WindowPos3dvMESA, WindowPos3dv@4, WindowPos3dvMESA, WindowPos3dvMESA@4)
+ GL_STUB_ALIAS(WindowPos3dvARB, _gloffset_WindowPos3dvMESA, WindowPos3dvARB@4, WindowPos3dvMESA, WindowPos3dvMESA@4)
+ GL_STUB_ALIAS(WindowPos3f, _gloffset_WindowPos3fMESA, WindowPos3f@12, WindowPos3fMESA, WindowPos3fMESA@12)
+ GL_STUB_ALIAS(WindowPos3fARB, _gloffset_WindowPos3fMESA, WindowPos3fARB@12, WindowPos3fMESA, WindowPos3fMESA@12)
+ GL_STUB_ALIAS(WindowPos3fv, _gloffset_WindowPos3fvMESA, WindowPos3fv@4, WindowPos3fvMESA, WindowPos3fvMESA@4)
+ GL_STUB_ALIAS(WindowPos3fvARB, _gloffset_WindowPos3fvMESA, WindowPos3fvARB@4, WindowPos3fvMESA, WindowPos3fvMESA@4)
+ GL_STUB_ALIAS(WindowPos3i, _gloffset_WindowPos3iMESA, WindowPos3i@12, WindowPos3iMESA, WindowPos3iMESA@12)
+ GL_STUB_ALIAS(WindowPos3iARB, _gloffset_WindowPos3iMESA, WindowPos3iARB@12, WindowPos3iMESA, WindowPos3iMESA@12)
+ GL_STUB_ALIAS(WindowPos3iv, _gloffset_WindowPos3ivMESA, WindowPos3iv@4, WindowPos3ivMESA, WindowPos3ivMESA@4)
+ GL_STUB_ALIAS(WindowPos3ivARB, _gloffset_WindowPos3ivMESA, WindowPos3ivARB@4, WindowPos3ivMESA, WindowPos3ivMESA@4)
+ GL_STUB_ALIAS(WindowPos3s, _gloffset_WindowPos3sMESA, WindowPos3s@12, WindowPos3sMESA, WindowPos3sMESA@12)
+ GL_STUB_ALIAS(WindowPos3sARB, _gloffset_WindowPos3sMESA, WindowPos3sARB@12, WindowPos3sMESA, WindowPos3sMESA@12)
+ GL_STUB_ALIAS(WindowPos3sv, _gloffset_WindowPos3svMESA, WindowPos3sv@4, WindowPos3svMESA, WindowPos3svMESA@4)
+ GL_STUB_ALIAS(WindowPos3svARB, _gloffset_WindowPos3svMESA, WindowPos3svARB@4, WindowPos3svMESA, WindowPos3svMESA@4)
+ GL_STUB_ALIAS(BlendFuncSeparate, _gloffset_BlendFuncSeparateEXT, BlendFuncSeparate@16, BlendFuncSeparateEXT, BlendFuncSeparateEXT@16)
+ GL_STUB_ALIAS(BlendFuncSeparateINGR, _gloffset_BlendFuncSeparateEXT, BlendFuncSeparateINGR@16, BlendFuncSeparateEXT, BlendFuncSeparateEXT@16)
+ GL_STUB_ALIAS(FogCoordf, _gloffset_FogCoordfEXT, FogCoordf@4, FogCoordfEXT, FogCoordfEXT@4)
+ GL_STUB_ALIAS(FogCoordfv, _gloffset_FogCoordfvEXT, FogCoordfv@4, FogCoordfvEXT, FogCoordfvEXT@4)
+ GL_STUB_ALIAS(FogCoordd, _gloffset_FogCoorddEXT, FogCoordd@8, FogCoorddEXT, FogCoorddEXT@8)
+ GL_STUB_ALIAS(FogCoorddv, _gloffset_FogCoorddvEXT, FogCoorddv@4, FogCoorddvEXT, FogCoorddvEXT@4)
+ GL_STUB_ALIAS(FogCoordPointer, _gloffset_FogCoordPointerEXT, FogCoordPointer@12, FogCoordPointerEXT, FogCoordPointerEXT@12)
+ GL_STUB_ALIAS(CompressedTexImage3D, _gloffset_CompressedTexImage3DARB, CompressedTexImage3D@36, CompressedTexImage3DARB, CompressedTexImage3DARB@36)
+ GL_STUB_ALIAS(CompressedTexImage2D, _gloffset_CompressedTexImage2DARB, CompressedTexImage2D@32, CompressedTexImage2DARB, CompressedTexImage2DARB@32)
+ GL_STUB_ALIAS(CompressedTexImage1D, _gloffset_CompressedTexImage1DARB, CompressedTexImage1D@28, CompressedTexImage1DARB, CompressedTexImage1DARB@28)
+ GL_STUB_ALIAS(CompressedTexSubImage3D, _gloffset_CompressedTexSubImage3DARB, CompressedTexSubImage3D@44, CompressedTexSubImage3DARB, CompressedTexSubImage3DARB@44)
+ GL_STUB_ALIAS(CompressedTexSubImage2D, _gloffset_CompressedTexSubImage2DARB, CompressedTexSubImage2D@36, CompressedTexSubImage2DARB, CompressedTexSubImage2DARB@36)
+ GL_STUB_ALIAS(CompressedTexSubImage1D, _gloffset_CompressedTexSubImage1DARB, CompressedTexSubImage1D@28, CompressedTexSubImage1DARB, CompressedTexSubImage1DARB@28)
+ GL_STUB_ALIAS(GetCompressedTexImage, _gloffset_GetCompressedTexImageARB, GetCompressedTexImage@12, GetCompressedTexImageARB, GetCompressedTexImageARB@12)
+ GL_STUB_ALIAS(SecondaryColor3b, _gloffset_SecondaryColor3bEXT, SecondaryColor3b@12, SecondaryColor3bEXT, SecondaryColor3bEXT@12)
+ GL_STUB_ALIAS(SecondaryColor3bv, _gloffset_SecondaryColor3bvEXT, SecondaryColor3bv@4, SecondaryColor3bvEXT, SecondaryColor3bvEXT@4)
+ GL_STUB_ALIAS(SecondaryColor3d, _gloffset_SecondaryColor3dEXT, SecondaryColor3d@24, SecondaryColor3dEXT, SecondaryColor3dEXT@24)
+ GL_STUB_ALIAS(SecondaryColor3dv, _gloffset_SecondaryColor3dvEXT, SecondaryColor3dv@4, SecondaryColor3dvEXT, SecondaryColor3dvEXT@4)
+ GL_STUB_ALIAS(SecondaryColor3f, _gloffset_SecondaryColor3fEXT, SecondaryColor3f@12, SecondaryColor3fEXT, SecondaryColor3fEXT@12)
+ GL_STUB_ALIAS(SecondaryColor3fv, _gloffset_SecondaryColor3fvEXT, SecondaryColor3fv@4, SecondaryColor3fvEXT, SecondaryColor3fvEXT@4)
+ GL_STUB_ALIAS(SecondaryColor3i, _gloffset_SecondaryColor3iEXT, SecondaryColor3i@12, SecondaryColor3iEXT, SecondaryColor3iEXT@12)
+ GL_STUB_ALIAS(SecondaryColor3iv, _gloffset_SecondaryColor3ivEXT, SecondaryColor3iv@4, SecondaryColor3ivEXT, SecondaryColor3ivEXT@4)
+ GL_STUB_ALIAS(SecondaryColor3s, _gloffset_SecondaryColor3sEXT, SecondaryColor3s@12, SecondaryColor3sEXT, SecondaryColor3sEXT@12)
+ GL_STUB_ALIAS(SecondaryColor3sv, _gloffset_SecondaryColor3svEXT, SecondaryColor3sv@4, SecondaryColor3svEXT, SecondaryColor3svEXT@4)
+ GL_STUB_ALIAS(SecondaryColor3ub, _gloffset_SecondaryColor3ubEXT, SecondaryColor3ub@12, SecondaryColor3ubEXT, SecondaryColor3ubEXT@12)
+ GL_STUB_ALIAS(SecondaryColor3ubv, _gloffset_SecondaryColor3ubvEXT, SecondaryColor3ubv@4, SecondaryColor3ubvEXT, SecondaryColor3ubvEXT@4)
+ GL_STUB_ALIAS(SecondaryColor3ui, _gloffset_SecondaryColor3uiEXT, SecondaryColor3ui@12, SecondaryColor3uiEXT, SecondaryColor3uiEXT@12)
+ GL_STUB_ALIAS(SecondaryColor3uiv, _gloffset_SecondaryColor3uivEXT, SecondaryColor3uiv@4, SecondaryColor3uivEXT, SecondaryColor3uivEXT@4)
+ GL_STUB_ALIAS(SecondaryColor3us, _gloffset_SecondaryColor3usEXT, SecondaryColor3us@12, SecondaryColor3usEXT, SecondaryColor3usEXT@12)
+ GL_STUB_ALIAS(SecondaryColor3usv, _gloffset_SecondaryColor3usvEXT, SecondaryColor3usv@4, SecondaryColor3usvEXT, SecondaryColor3usvEXT@4)
+ GL_STUB_ALIAS(SecondaryColorPointer, _gloffset_SecondaryColorPointerEXT, SecondaryColorPointer@16, SecondaryColorPointerEXT, SecondaryColorPointerEXT@16)
+ GL_STUB_ALIAS(BindProgramARB, _gloffset_BindProgramNV, BindProgramARB@8, BindProgramNV, BindProgramNV@8)
+ GL_STUB_ALIAS(DeleteProgramsARB, _gloffset_DeleteProgramsNV, DeleteProgramsARB@8, DeleteProgramsNV, DeleteProgramsNV@8)
+ GL_STUB_ALIAS(GenProgramsARB, _gloffset_GenProgramsNV, GenProgramsARB@8, GenProgramsNV, GenProgramsNV@8)
+ GL_STUB_ALIAS(GetVertexAttribPointervARB, _gloffset_GetVertexAttribPointervNV, GetVertexAttribPointervARB@12, GetVertexAttribPointervNV, GetVertexAttribPointervNV@12)
+ GL_STUB_ALIAS(IsProgramARB, _gloffset_IsProgramNV, IsProgramARB@4, IsProgramNV, IsProgramNV@4)
+ GL_STUB_ALIAS(PointParameteri, _gloffset_PointParameteriNV, PointParameteri@8, PointParameteriNV, PointParameteriNV@8)
+ GL_STUB_ALIAS(PointParameteriv, _gloffset_PointParameterivNV, PointParameteriv@8, PointParameterivNV, PointParameterivNV@8)
+ GL_STUB_ALIAS(MultiDrawArrays, _gloffset_MultiDrawArraysEXT, MultiDrawArrays@16, MultiDrawArraysEXT, MultiDrawArraysEXT@16)
+ GL_STUB_ALIAS(MultiDrawElements, _gloffset_MultiDrawElementsEXT, MultiDrawElements@20, MultiDrawElementsEXT, MultiDrawElementsEXT@20)
+ GL_STUB_ALIAS(BindBuffer, _gloffset_BindBufferARB, BindBuffer@8, BindBufferARB, BindBufferARB@8)
+ GL_STUB_ALIAS(BufferData, _gloffset_BufferDataARB, BufferData@16, BufferDataARB, BufferDataARB@16)
+ GL_STUB_ALIAS(BufferSubData, _gloffset_BufferSubDataARB, BufferSubData@16, BufferSubDataARB, BufferSubDataARB@16)
+ GL_STUB_ALIAS(DeleteBuffers, _gloffset_DeleteBuffersARB, DeleteBuffers@8, DeleteBuffersARB, DeleteBuffersARB@8)
+ GL_STUB_ALIAS(GenBuffers, _gloffset_GenBuffersARB, GenBuffers@8, GenBuffersARB, GenBuffersARB@8)
+ GL_STUB_ALIAS(GetBufferParameteriv, _gloffset_GetBufferParameterivARB, GetBufferParameteriv@12, GetBufferParameterivARB, GetBufferParameterivARB@12)
+ GL_STUB_ALIAS(GetBufferPointerv, _gloffset_GetBufferPointervARB, GetBufferPointerv@12, GetBufferPointervARB, GetBufferPointervARB@12)
+ GL_STUB_ALIAS(GetBufferSubData, _gloffset_GetBufferSubDataARB, GetBufferSubData@16, GetBufferSubDataARB, GetBufferSubDataARB@16)
+ GL_STUB_ALIAS(IsBuffer, _gloffset_IsBufferARB, IsBuffer@4, IsBufferARB, IsBufferARB@4)
+ GL_STUB_ALIAS(MapBuffer, _gloffset_MapBufferARB, MapBuffer@8, MapBufferARB, MapBufferARB@8)
+ GL_STUB_ALIAS(UnmapBuffer, _gloffset_UnmapBufferARB, UnmapBuffer@4, UnmapBufferARB, UnmapBufferARB@4)
+ GL_STUB_ALIAS(GenQueries, _gloffset_GenQueriesARB, GenQueries@8, GenQueriesARB, GenQueriesARB@8)
+ GL_STUB_ALIAS(DeleteQueries, _gloffset_DeleteQueriesARB, DeleteQueries@8, DeleteQueriesARB, DeleteQueriesARB@8)
+ GL_STUB_ALIAS(IsQuery, _gloffset_IsQueryARB, IsQuery@4, IsQueryARB, IsQueryARB@4)
+ GL_STUB_ALIAS(BeginQuery, _gloffset_BeginQueryARB, BeginQuery@8, BeginQueryARB, BeginQueryARB@8)
+ GL_STUB_ALIAS(EndQuery, _gloffset_EndQueryARB, EndQuery@4, EndQueryARB, EndQueryARB@4)
+ GL_STUB_ALIAS(GetQueryiv, _gloffset_GetQueryivARB, GetQueryiv@12, GetQueryivARB, GetQueryivARB@12)
+ GL_STUB_ALIAS(GetQueryObjectiv, _gloffset_GetQueryObjectivARB, GetQueryObjectiv@12, GetQueryObjectivARB, GetQueryObjectivARB@12)
+ GL_STUB_ALIAS(GetQueryObjectuiv, _gloffset_GetQueryObjectuivARB, GetQueryObjectuiv@12, GetQueryObjectuivARB, GetQueryObjectuivARB@12)
+ GL_STUB_ALIAS(BlendEquationSeparateATI, _gloffset_BlendEquationSeparateEXT, BlendEquationSeparateATI@8, BlendEquationSeparateEXT, BlendEquationSeparateEXT@8)
+
+ GLOBL GLNAME(gl_dispatch_functions_end)
+ HIDDEN(GLNAME(gl_dispatch_functions_end))
+ ALIGNTEXT16
+GLNAME(gl_dispatch_functions_end):
+
+#if defined(GLX_USE_TLS) && defined(__linux__)
+ .section ".note.ABI-tag", "a"
+ .p2align 2
+ .long 1f - 0f /* name length */
+ .long 3f - 2f /* data length */
+ .long 1 /* note length */
+0: .asciz "GNU" /* vendor name */
+1: .p2align 2
+2: .long 0 /* note data: the ABI tag */
+ .long 2,4,20 /* Minimum kernel version w/TLS */
+3: .p2align 2 /* pad out section */
+#endif /* GLX_USE_TLS */
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/mmx.h b/nx-X11/extras/Mesa/src/mesa/x86/mmx.h
new file mode 100644
index 000000000..b3a096725
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/mmx.h
@@ -0,0 +1,51 @@
+/* $Id: mmx.h,v 1.1.1.1 2004/06/16 09:19:36 anholt Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef ASM_MMX_H
+#define ASM_MMX_H
+
+extern void _ASMAPI
+_mesa_mmx_blend_transparency( GLcontext *ctx, GLuint n, const GLubyte mask[],
+ GLubyte rgba[][4], const GLubyte dest[][4] );
+
+extern void _ASMAPI
+_mesa_mmx_blend_add( GLcontext *ctx, GLuint n, const GLubyte mask[],
+ GLubyte rgba[][4], const GLubyte dest[][4] );
+
+extern void _ASMAPI
+_mesa_mmx_blend_min( GLcontext *ctx, GLuint n, const GLubyte mask[],
+ GLubyte rgba[][4], const GLubyte dest[][4] );
+
+extern void _ASMAPI
+_mesa_mmx_blend_max( GLcontext *ctx, GLuint n, const GLubyte mask[],
+ GLubyte rgba[][4], const GLubyte dest[][4] );
+
+extern void _ASMAPI
+_mesa_mmx_blend_modulate( GLcontext *ctx, GLuint n, const GLubyte mask[],
+ GLubyte rgba[][4], const GLubyte dest[][4] );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/mmx_blend.S b/nx-X11/extras/Mesa/src/mesa/x86/mmx_blend.S
new file mode 100644
index 000000000..f7326cdbe
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/mmx_blend.S
@@ -0,0 +1,366 @@
+
+/*
+ * Written by José Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+
+#ifdef USE_MMX_ASM
+#include "matypes.h"
+
+/* integer multiplication - alpha plus one
+ *
+ * makes the following approximation to the division (Sree)
+ *
+ * rgb*a/255 ~= (rgb*(a+1)) >> 256
+ *
+ * which is the fastest method that satisfies the following OpenGL criteria
+ *
+ * 0*0 = 0 and 255*255 = 255
+ *
+ * note that MX1 is a register with 0xffffffffffffffff constant which can be easily obtained making
+ *
+ * PCMPEQW ( MX1, MX1 )
+ */
+#define GMB_MULT_AP1( MP1, MA1, MP2, MA2, MX1 ) \
+ PSUBW ( MX1, MA1 ) /* a1 + 1 | a1 + 1 | a1 + 1 | a1 + 1 */ ;\
+ PMULLW ( MP1, MA1 ) /* t1 = p1*a1 */ ;\
+ ;\
+TWO(PSUBW ( MX1, MA2 )) /* a2 + 1 | a2 + 1 | a2 + 1 | a2 + 1 */ ;\
+TWO(PMULLW ( MP2, MA2 )) /* t2 = p2*a2 */ ;\
+ ;\
+ PSRLW ( CONST(8), MA1 ) /* t1 >> 8 ~= t1/255 */ ;\
+TWO(PSRLW ( CONST(8), MA2 )) /* t2 >> 8 ~= t2/255 */
+
+
+/* integer multiplication - geometric series
+ *
+ * takes the geometric series approximation to the division
+ *
+ * t/255 = (t >> 8) + (t >> 16) + (t >> 24) ..
+ *
+ * in this case just the first two terms to fit in 16bit arithmetic
+ *
+ * t/255 ~= (t + (t >> 8)) >> 8
+ *
+ * note that just by itself it doesn't satisfies the OpenGL criteria, as 255*255 = 254,
+ * so the special case a = 255 must be accounted or roundoff must be used
+ */
+#define GMB_MULT_GS( MP1, MA1, MP2, MA2 ) \
+ PMULLW ( MP1, MA1 ) /* t1 = p1*a1 */ ;\
+TWO(PMULLW ( MP2, MA2 )) /* t2 = p2*a2 */ ;\
+ ;\
+ MOVQ ( MA1, MP1 ) ;\
+ PSRLW ( CONST(8), MA1 ) /* t1 >> 8 */ ;\
+ ;\
+TWO(MOVQ ( MA2, MP2 )) ;\
+TWO(PSRLW ( CONST(8), MA2 )) /* t2 >> 8 */ ;\
+ ;\
+ PADDW ( MP1, MA1 ) /* t1 + (t1 >> 8) ~= (t1/255) << 8 */ ;\
+ PSRLW ( CONST(8), MA1 ) /* sa1 | sb1 | sg1 | sr1 */ ;\
+ ;\
+TWO(PADDW ( MP2, MA2 )) /* t2 + (t2 >> 8) ~= (t2/255) << 8 */ ;\
+TWO(PSRLW ( CONST(8), MA2 )) /* sa2 | sb2 | sg2 | sr2 */
+
+
+/* integer multiplication - geometric series plus rounding
+ *
+ * when using a geometric series division instead of truncating the result
+ * use roundoff in the approximation (Jim Blinn)
+ *
+ * t = rgb*a + 0x80
+ *
+ * achieving the exact results
+ *
+ * note that M80 is register with the 0x0080008000800080 constant
+ */
+#define GMB_MULT_GSR( MP1, MA1, MP2, MA2, M80 ) \
+ PMULLW ( MP1, MA1 ) /* t1 = p1*a1 */ ;\
+ PADDW ( M80, MA1 ) /* t1 += 0x80 */ ;\
+ ;\
+TWO(PMULLW ( MP2, MA2 )) /* t2 = p2*a2 */ ;\
+TWO(PADDW ( M80, MA2 )) /* t2 += 0x80 */ ;\
+ ;\
+ MOVQ ( MA1, MP1 ) ;\
+ PSRLW ( CONST(8), MA1 ) /* t1 >> 8 */ ;\
+ ;\
+TWO(MOVQ ( MA2, MP2 )) ;\
+TWO(PSRLW ( CONST(8), MA2 )) /* t2 >> 8 */ ;\
+ ;\
+ PADDW ( MP1, MA1 ) /* t1 + (t1 >> 8) ~= (t1/255) << 8 */ ;\
+ PSRLW ( CONST(8), MA1 ) /* sa1 | sb1 | sg1 | sr1 */ ;\
+ ;\
+TWO(PADDW ( MP2, MA2 )) /* t2 + (t2 >> 8) ~= (t2/255) << 8 */ ;\
+TWO(PSRLW ( CONST(8), MA2 )) /* sa2 | sb2 | sg2 | sr2 */
+
+
+/* linear interpolation - geometric series
+ */
+#define GMB_LERP_GS( MP1, MQ1, MA1, MP2, MQ2, MA2) \
+ PSUBW ( MQ1, MP1 ) /* pa1 - qa1 | pb1 - qb1 | pg1 - qg1 | pr1 - qr1 */ ;\
+ PSLLW ( CONST(8), MQ1 ) /* q1 << 8 */ ;\
+ PMULLW ( MP1, MA1 ) /* t1 = (q1 - p1)*pa1 */ ;\
+ ;\
+TWO(PSUBW ( MQ2, MP2 )) /* pa2 - qa2 | pb2 - qb2 | pg2 - qg2 | pr2 - qr2 */ ;\
+TWO(PSLLW ( CONST(8), MQ2 )) /* q2 << 8 */ ;\
+TWO(PMULLW ( MP2, MA2 )) /* t2 = (q2 - p2)*pa2 */ ;\
+ ;\
+ MOVQ ( MA1, MP1 ) ;\
+ PSRLW ( CONST(8), MA1 ) /* t1 >> 8 */ ;\
+ ;\
+TWO(MOVQ ( MA2, MP2 )) ;\
+TWO(PSRLW ( CONST(8), MA2 )) /* t2 >> 8 */ ;\
+ ;\
+ PADDW ( MP1, MA1 ) /* t1 + (t1 >> 8) ~= (t1/255) << 8 */ ;\
+TWO(PADDW ( MP2, MA2 )) /* t2 + (t2 >> 8) ~= (t2/255) << 8 */ ;\
+ ;\
+ PADDW ( MQ1, MA1 ) /* (t1/255 + q1) << 8 */ ;\
+TWO(PADDW ( MQ2, MA2 )) /* (t2/255 + q2) << 8 */ ;\
+ ;\
+ PSRLW ( CONST(8), MA1 ) /* sa1 | sb1 | sg1 | sr1 */ ;\
+TWO(PSRLW ( CONST(8), MA2 )) /* sa2 | sb2 | sg2 | sr2 */
+
+
+/* linear interpolation - geometric series with roundoff
+ *
+ * this is a generalization of Blinn's formula to signed arithmetic
+ *
+ * note that M80 is a register with the 0x0080008000800080 constant
+ */
+#define GMB_LERP_GSR( MP1, MQ1, MA1, MP2, MQ2, MA2, M80) \
+ PSUBW ( MQ1, MP1 ) /* pa1 - qa1 | pb1 - qb1 | pg1 - qg1 | pr1 - qr1 */ ;\
+ PSLLW ( CONST(8), MQ1 ) /* q1 << 8 */ ;\
+ PMULLW ( MP1, MA1 ) /* t1 = (q1 - p1)*pa1 */ ;\
+ ;\
+TWO(PSUBW ( MQ2, MP2 )) /* pa2 - qa2 | pb2 - qb2 | pg2 - qg2 | pr2 - qr2 */ ;\
+TWO(PSLLW ( CONST(8), MQ2 )) /* q2 << 8 */ ;\
+TWO(PMULLW ( MP2, MA2 )) /* t2 = (q2 - p2)*pa2 */ ;\
+ ;\
+ PSRLW ( CONST(15), MP1 ) /* q1 > p1 ? 1 : 0 */ ;\
+TWO(PSRLW ( CONST(15), MP2 )) /* q2 > q2 ? 1 : 0 */ ;\
+ ;\
+ PSLLW ( CONST(8), MP1 ) /* q1 > p1 ? 0x100 : 0 */ ;\
+TWO(PSLLW ( CONST(8), MP2 )) /* q2 > q2 ? 0x100 : 0 */ ;\
+ ;\
+ PSUBW ( MP1, MA1 ) /* t1 -=? 0x100 */ ;\
+TWO(PSUBW ( MP2, MA2 )) /* t2 -=? 0x100 */ ;\
+ ;\
+ PADDW ( M80, MA1 ) /* t1 += 0x80 */ ;\
+TWO(PADDW ( M80, MA2 )) /* t2 += 0x80 */ ;\
+ ;\
+ MOVQ ( MA1, MP1 ) ;\
+ PSRLW ( CONST(8), MA1 ) /* t1 >> 8 */ ;\
+ ;\
+TWO(MOVQ ( MA2, MP2 )) ;\
+TWO(PSRLW ( CONST(8), MA2 )) /* t2 >> 8 */ ;\
+ ;\
+ PADDW ( MP1, MA1 ) /* t1 + (t1 >> 8) ~= (t1/255) << 8 */ ;\
+TWO(PADDW ( MP2, MA2 )) /* t2 + (t2 >> 8) ~= (t2/255) << 8 */ ;\
+ ;\
+ PADDW ( MQ1, MA1 ) /* (t1/255 + q1) << 8 */ ;\
+TWO(PADDW ( MQ2, MA2 )) /* (t2/255 + q2) << 8 */ ;\
+ ;\
+ PSRLW ( CONST(8), MA1 ) /* sa1 | sb1 | sg1 | sr1 */ ;\
+TWO(PSRLW ( CONST(8), MA2 )) /* sa2 | sb2 | sg2 | sr2 */
+
+
+/* linear interpolation - geometric series with correction
+ *
+ * instead of the roundoff this adds a small correction to satisfy the OpenGL criteria
+ *
+ * t/255 ~= (t + (t >> 8) + (t >> 15)) >> 8
+ *
+ * note that although is faster than rounding off it doesn't give always the exact results
+ */
+#define GMB_LERP_GSC( MP1, MQ1, MA1, MP2, MQ2, MA2) \
+ PSUBW ( MQ1, MP1 ) /* pa1 - qa1 | pb1 - qb1 | pg1 - qg1 | pr1 - qr1 */ ;\
+ PSLLW ( CONST(8), MQ1 ) /* q1 << 8 */ ;\
+ PMULLW ( MP1, MA1 ) /* t1 = (q1 - p1)*pa1 */ ;\
+ ;\
+TWO(PSUBW ( MQ2, MP2 )) /* pa2 - qa2 | pb2 - qb2 | pg2 - qg2 | pr2 - qr2 */ ;\
+TWO(PSLLW ( CONST(8), MQ2 )) /* q2 << 8 */ ;\
+TWO(PMULLW ( MP2, MA2 )) /* t2 = (q2 - p2)*pa2 */ ;\
+ ;\
+ MOVQ ( MA1, MP1 ) ;\
+ PSRLW ( CONST(8), MA1 ) /* t1 >> 8 */ ;\
+ ;\
+TWO(MOVQ ( MA2, MP2 )) ;\
+TWO(PSRLW ( CONST(8), MA2 )) /* t2 >> 8 */ ;\
+ ;\
+ PADDW ( MA1, MP1 ) /* t1 + (t1 >> 8) ~= (t1/255) << 8 */ ;\
+ PSRLW ( CONST(7), MA1 ) /* t1 >> 15 */ ;\
+ ;\
+TWO(PADDW ( MA2, MP2 )) /* t2 + (t2 >> 8) ~= (t2/255) << 8 */ ;\
+TWO(PSRLW ( CONST(7), MA2 )) /* t2 >> 15 */ ;\
+ ;\
+ PADDW ( MP1, MA1 ) /* t1 + (t1 >> 8) + (t1 >>15) ~= (t1/255) << 8 */ ;\
+TWO(PADDW ( MP2, MA2 )) /* t2 + (t2 >> 8) + (t2 >>15) ~= (t2/255) << 8 */ ;\
+ ;\
+ PADDW ( MQ1, MA1 ) /* (t1/255 + q1) << 8 */ ;\
+TWO(PADDW ( MQ2, MA2 )) /* (t2/255 + q2) << 8 */ ;\
+ ;\
+ PSRLW ( CONST(8), MA1 ) /* sa1 | sb1 | sg1 | sr1 */ ;\
+TWO(PSRLW ( CONST(8), MA2 )) /* sa2 | sb2 | sg2 | sr2 */
+
+
+/* common blending setup code
+ *
+ * note that M00 is a register with 0x0000000000000000 constant which can be easily obtained making
+ *
+ * PXOR ( M00, M00 )
+ */
+#define GMB_LOAD(rgba, dest, MPP, MQQ) \
+ONE(MOVD ( REGIND(rgba), MPP )) /* | | | | qa1 | qb1 | qg1 | qr1 */ ;\
+ONE(MOVD ( REGIND(dest), MQQ )) /* | | | | pa1 | pb1 | pg1 | pr1 */ ;\
+ ;\
+TWO(MOVQ ( REGIND(rgba), MPP )) /* qa2 | qb2 | qg2 | qr2 | qa1 | qb1 | qg1 | qr1 */ ;\
+TWO(MOVQ ( REGIND(dest), MQQ )) /* pa2 | pb2 | pg2 | pr2 | pa1 | pb1 | pg1 | pr1 */
+
+#define GMB_UNPACK(MP1, MQ1, MP2, MQ2, M00) \
+TWO(MOVQ ( MP1, MP2 )) ;\
+TWO(MOVQ ( MQ1, MQ2 )) ;\
+ ;\
+ PUNPCKLBW ( M00, MQ1 ) /* qa1 | qb1 | qg1 | qr1 */ ;\
+TWO(PUNPCKHBW ( M00, MQ2 )) /* qa2 | qb2 | qg2 | qr2 */ ;\
+ PUNPCKLBW ( M00, MP1 ) /* pa1 | pb1 | pg1 | pr1 */ ;\
+TWO(PUNPCKHBW ( M00, MP2 )) /* pa2 | pb2 | pg2 | pr2 */
+
+#define GMB_ALPHA(MP1, MA1, MP2, MA2) \
+ MOVQ ( MP1, MA1 ) ;\
+TWO(MOVQ ( MP2, MA2 )) ;\
+ ;\
+ PUNPCKHWD ( MA1, MA1 ) /* pa1 | pa1 | | */ ;\
+TWO(PUNPCKHWD ( MA2, MA2 )) /* pa2 | pa2 | | */ ;\
+ PUNPCKHDQ ( MA1, MA1 ) /* pa1 | pa1 | pa1 | pa1 */ ;\
+TWO(PUNPCKHDQ ( MA2, MA2 )) /* pa2 | pa2 | pa2 | pa2 */
+
+#define GMB_PACK( MS1, MS2 ) \
+ PACKUSWB ( MS2, MS1 ) /* sa2 | sb2 | sg2 | sr2 | sa1 | sb1 | sg1 | sr1 */ ;\
+
+#define GMB_STORE(rgba, MSS ) \
+ONE(MOVD ( MSS, REGIND(rgba) )) /* | | | | sa1 | sb1 | sg1 | sr1 */ ;\
+TWO(MOVQ ( MSS, REGIND(rgba) )) /* sa2 | sb2 | sg2 | sr2 | sa1 | sb1 | sg1 | sr1 */
+
+
+ SEG_DATA
+
+ALIGNDATA8
+const_0080:
+ D_LONG 0x00800080, 0x00800080
+
+const_80:
+ D_LONG 0x80808080, 0x80808080
+
+ SEG_TEXT
+
+
+/* Blend transparency function
+ */
+
+#define TAG(x) CONCAT(x,_transparency)
+#define LLTAG(x) LLBL2(x,_transparency)
+
+#define INIT \
+ PXOR ( MM0, MM0 ) /* 0x0000 | 0x0000 | 0x0000 | 0x0000 */
+
+#define MAIN( rgba, dest ) \
+ GMB_LOAD( rgba, dest, MM1, MM2 ) ;\
+ GMB_UNPACK( MM1, MM2, MM4, MM5, MM0 ) ;\
+ GMB_ALPHA( MM1, MM3, MM4, MM6 ) ;\
+ GMB_LERP_GSC( MM1, MM2, MM3, MM4, MM5, MM6 ) ;\
+ GMB_PACK( MM3, MM6 ) ;\
+ GMB_STORE( rgba, MM3 )
+
+#include "mmx_blendtmp.h"
+
+
+/* Blend add function
+ *
+ * FIXME: Add some loop unrolling here...
+ */
+
+#define TAG(x) CONCAT(x,_add)
+#define LLTAG(x) LLBL2(x,_add)
+
+#define INIT
+
+#define MAIN( rgba, dest ) \
+ONE(MOVD ( REGIND(rgba), MM1 )) /* | | | | qa1 | qb1 | qg1 | qr1 */ ;\
+ONE(MOVD ( REGIND(dest), MM2 )) /* | | | | pa1 | pb1 | pg1 | pr1 */ ;\
+ONE(PADDUSB ( MM2, MM1 )) ;\
+ONE(MOVD ( MM1, REGIND(rgba) )) /* | | | | sa1 | sb1 | sg1 | sr1 */ ;\
+ ;\
+TWO(MOVQ ( REGIND(rgba), MM1 )) /* qa2 | qb2 | qg2 | qr2 | qa1 | qb1 | qg1 | qr1 */ ;\
+TWO(PADDUSB ( REGIND(dest), MM1 )) /* sa2 | sb2 | sg2 | sr2 | sa1 | sb1 | sg1 | sr1 */ ;\
+TWO(MOVQ ( MM1, REGIND(rgba) ))
+
+#include "mmx_blendtmp.h"
+
+
+/* Blend min function
+ */
+
+#define TAG(x) CONCAT(x,_min)
+#define LLTAG(x) LLBL2(x,_min)
+
+#define INIT \
+ MOVQ ( CONTENT(const_80), MM7 ) /* 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80*/
+
+#define MAIN( rgba, dest ) \
+ GMB_LOAD( rgba, dest, MM1, MM2 ) ;\
+ MOVQ ( MM1, MM3 ) ;\
+ MOVQ ( MM2, MM4 ) ;\
+ PXOR ( MM7, MM3 ) /* unsigned -> signed */ ;\
+ PXOR ( MM7, MM4 ) /* unsigned -> signed */ ;\
+ PCMPGTB ( MM3, MM4 ) /* q > p ? 0xff : 0x00 */ ;\
+ PAND ( MM4, MM1 ) /* q > p ? p : 0 */ ;\
+ PANDN ( MM2, MM4 ) /* q > p ? 0 : q */ ;\
+ POR ( MM1, MM4 ) /* q > p ? p : q */ ;\
+ GMB_STORE( rgba, MM4 )
+
+#include "mmx_blendtmp.h"
+
+
+/* Blend max function
+ */
+
+#define TAG(x) CONCAT(x,_max)
+#define LLTAG(x) LLBL2(x,_max)
+
+#define INIT \
+ MOVQ ( CONTENT(const_80), MM7 ) /* 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80| 0x80*/
+
+#define MAIN( rgba, dest ) \
+ GMB_LOAD( rgba, dest, MM1, MM2 ) ;\
+ MOVQ ( MM1, MM3 ) ;\
+ MOVQ ( MM2, MM4 ) ;\
+ PXOR ( MM7, MM3 ) /* unsigned -> signed */ ;\
+ PXOR ( MM7, MM4 ) /* unsigned -> signed */ ;\
+ PCMPGTB ( MM3, MM4 ) /* q > p ? 0xff : 0x00 */ ;\
+ PAND ( MM4, MM2 ) /* q > p ? q : 0 */ ;\
+ PANDN ( MM1, MM4 ) /* q > p ? 0 : p */ ;\
+ POR ( MM2, MM4 ) /* q > p ? p : q */ ;\
+ GMB_STORE( rgba, MM4 )
+
+#include "mmx_blendtmp.h"
+
+
+/* Blend modulate function
+ */
+
+#define TAG(x) CONCAT(x,_modulate)
+#define LLTAG(x) LLBL2(x,_modulate)
+
+#define INIT \
+ PXOR ( MM0, MM0 ) /* 0x0000 | 0x0000 | 0x0000 | 0x0000 */ ;\
+ MOVQ ( CONTENT(const_0080), MM7 ) /* 0x0080 | 0x0080 | 0x0080 | 0x0080 */
+
+#define MAIN( rgba, dest ) \
+ GMB_LOAD( rgba, dest, MM1, MM2 ) ;\
+ GMB_UNPACK( MM1, MM2, MM4, MM5, MM0 ) ;\
+ GMB_MULT_GSR( MM1, MM2, MM4, MM5, MM7 ) ;\
+ GMB_PACK( MM2, MM5 ) ;\
+ GMB_STORE( rgba, MM2 )
+
+#include "mmx_blendtmp.h"
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/mmx_blendtmp.h b/nx-X11/extras/Mesa/src/mesa/x86/mmx_blendtmp.h
new file mode 100644
index 000000000..c2fdeb62b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/mmx_blendtmp.h
@@ -0,0 +1,114 @@
+/*
+ * Written by José Fonseca <j_r_fonseca@yahoo.co.uk>
+ */
+
+
+/*
+ * void _mesa_mmx_blend( GLcontext *ctx,
+ * GLuint n,
+ * const GLubyte mask[],
+ * GLchan rgba[][4],
+ * CONST GLchan dest[][4] )
+ *
+ */
+ALIGNTEXT16
+GLOBL GLNAME( TAG(_mesa_mmx_blend) )
+HIDDEN( TAG(_mesa_mmx_blend) )
+GLNAME( TAG(_mesa_mmx_blend) ):
+
+ PUSH_L ( EBP )
+ MOV_L ( ESP, EBP )
+ PUSH_L ( ESI )
+ PUSH_L ( EDI )
+ PUSH_L ( EBX )
+
+ MOV_L ( REGOFF(12, EBP), ECX ) /* n */
+ CMP_L ( CONST(0), ECX)
+ JE ( LLTAG(GMB_return) )
+
+ MOV_L ( REGOFF(16, EBP), EBX ) /* mask */
+ MOV_L ( REGOFF(20, EBP), EDI ) /* rgba */
+ MOV_L ( REGOFF(24, EBP), ESI ) /* dest */
+
+ INIT
+
+ TEST_L ( CONST(4), EDI ) /* align rgba on an 8-byte boundary */
+ JZ ( LLTAG(GMB_align_end) )
+
+ CMP_B ( CONST(0), REGIND(EBX) ) /* *mask == 0 */
+ JE ( LLTAG(GMB_align_continue) )
+
+ /* runin */
+#define ONE(x) x
+#define TWO(x)
+ MAIN ( EDI, ESI )
+#undef ONE
+#undef TWO
+
+LLTAG(GMB_align_continue):
+
+ DEC_L ( ECX ) /* n -= 1 */
+ INC_L ( EBX ) /* mask += 1 */
+ ADD_L ( CONST(4), EDI ) /* rgba += 1 */
+ ADD_L ( CONST(4), ESI ) /* dest += 1 */
+
+LLTAG(GMB_align_end):
+
+ CMP_L ( CONST(2), ECX)
+ JB ( LLTAG(GMB_loop_end) )
+
+ALIGNTEXT16
+LLTAG(GMB_loop_begin):
+
+ CMP_W ( CONST(0), REGIND(EBX) ) /* *mask == 0 && *(mask + 1) == 0 */
+ JE ( LLTAG(GMB_loop_continue) )
+
+ /* main loop */
+#define ONE(x)
+#define TWO(x) x
+ MAIN ( EDI, ESI )
+#undef ONE
+#undef TWO
+
+LLTAG(GMB_loop_continue):
+
+ DEC_L ( ECX )
+ DEC_L ( ECX ) /* n -= 2 */
+ ADD_L ( CONST(2), EBX ) /* mask += 2 */
+ ADD_L ( CONST(8), EDI ) /* rgba += 2 */
+ ADD_L ( CONST(8), ESI ) /* dest += 2 */
+ CMP_L ( CONST(2), ECX )
+ JAE ( LLTAG(GMB_loop_begin) )
+
+LLTAG(GMB_loop_end):
+
+ CMP_L ( CONST(1), ECX )
+ JB ( LLTAG(GMB_done) )
+
+ CMP_B ( CONST(0), REGIND(EBX) ) /* *mask == 0 */
+ JE ( LLTAG(GMB_done) )
+
+ /* runout */
+#define ONE(x) x
+#define TWO(x)
+ MAIN ( EDI, ESI )
+#undef ONE
+#undef TWO
+
+LLTAG(GMB_done):
+
+ EMMS
+
+LLTAG(GMB_return):
+
+ POP_L ( EBX )
+ POP_L ( EDI )
+ POP_L ( ESI )
+ MOV_L ( EBP, ESP )
+ POP_L ( EBP )
+ RET
+
+#undef TAG
+#undef LLTAG
+#undef INIT
+#undef MAIN
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/norm_args.h b/nx-X11/extras/Mesa/src/mesa/x86/norm_args.h
new file mode 100644
index 000000000..cb18fba9b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/norm_args.h
@@ -0,0 +1,58 @@
+/* $Id: norm_args.h,v 1.1.1.1 2004/06/16 09:19:36 anholt Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * Normal transform function interface for assembly code. Simply define
+ * FRAME_OFFSET to the number of bytes pushed onto the stack before
+ * using the ARG_* argument macros.
+ *
+ * Gareth Hughes
+ */
+
+#ifndef __NORM_ARGS_H__
+#define __NORM_ARGS_H__
+
+/* Offsets for normal_func arguments
+ *
+ * typedef void (*normal_func)( CONST GLmatrix *mat,
+ * GLfloat scale,
+ * CONST GLvector4f *in,
+ * CONST GLfloat lengths[],
+ * GLvector4f *dest );
+ */
+#define OFFSET_MAT 4
+#define OFFSET_SCALE 8
+#define OFFSET_IN 12
+#define OFFSET_LENGTHS 16
+#define OFFSET_DEST 20
+
+#define ARG_MAT REGOFF(FRAME_OFFSET+OFFSET_MAT, ESP)
+#define ARG_SCALE REGOFF(FRAME_OFFSET+OFFSET_SCALE, ESP)
+#define ARG_IN REGOFF(FRAME_OFFSET+OFFSET_IN, ESP)
+#define ARG_LENGTHS REGOFF(FRAME_OFFSET+OFFSET_LENGTHS, ESP)
+#define ARG_DEST REGOFF(FRAME_OFFSET+OFFSET_DEST, ESP)
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/read_rgba_span_x86.S b/nx-X11/extras/Mesa/src/mesa/x86/read_rgba_span_x86.S
new file mode 100644
index 000000000..6b8036e5b
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/read_rgba_span_x86.S
@@ -0,0 +1,689 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file read_rgba_span_x86.S
+ * Optimized routines to transfer pixel data from the framebuffer to a
+ * buffer in main memory.
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+ .file "read_rgba_span_x86.S"
+#if !defined(__DJGPP__) && !defined(__MINGW32__) /* this one cries for assyntax.h */
+ .section .rodata
+ .align 16
+ .type mask, @object
+ .size mask, 32
+mask:
+ .long 0xff00ff00
+ .long 0xff00ff00
+ .long 0xff00ff00
+ .long 0xff00ff00
+ .long 0x00ff0000
+ .long 0x00ff0000
+ .long 0x00ff0000
+ .long 0x00ff0000
+
+
+/* I implemented these as macros because the appear in quite a few places,
+ * and I've tweaked them a number of times. I got tired of changing every
+ * place they appear. :)
+ */
+
+#define DO_ONE_PIXEL() \
+ movl (%ebx), %eax ; \
+ addl $4, %ebx ; \
+ bswap %eax /* ARGB -> BGRA */ ; \
+ rorl $8, %eax /* BGRA -> ABGR */ ; \
+ movl %eax, (%ecx) /* ABGR -> R, G, B, A */ ; \
+ addl $4, %ecx
+
+#define DO_ONE_LAST_PIXEL() \
+ movl (%ebx), %eax ; \
+ bswap %eax /* ARGB -> BGRA */ ; \
+ rorl $8, %eax /* BGRA -> ABGR */ ; \
+ movl %eax, (%ecx) /* ABGR -> R, G, B, A */ ; \
+
+
+/**
+ * MMX optimized version of the BGRA8888_REV to RGBA copy routine.
+ *
+ * \warning
+ * This function assumes that the caller will issue the EMMS instruction
+ * at the correct places.
+ */
+
+.globl _generic_read_RGBA_span_BGRA8888_REV_MMX
+.hidden _generic_read_RGBA_span_BGRA8888_REV_MMX
+ .type _generic_read_RGBA_span_BGRA8888_REV_MMX, @function
+_generic_read_RGBA_span_BGRA8888_REV_MMX:
+ pushl %ebx
+
+#ifdef USE_INNER_EMMS
+ emms
+#endif
+ movq mask, %mm1
+ movq mask+16, %mm2
+
+ movl 8(%esp), %ebx /* source pointer */
+ movl 16(%esp), %edx /* number of pixels to copy */
+ movl 12(%esp), %ecx /* destination pointer */
+
+ testl %edx, %edx
+ jle .L20 /* Bail if there's nothing to do. */
+
+ movl %ebx, %eax
+
+ negl %eax
+ sarl $2, %eax
+ andl $1, %eax
+ je .L17
+
+ subl %eax, %edx
+ DO_ONE_PIXEL()
+.L17:
+
+ /* Would it be faster to unroll this loop once and process 4 pixels
+ * per pass, instead of just two?
+ */
+
+ movl %edx, %eax
+ shrl %eax
+ jmp .L18
+.L19:
+ movq (%ebx), %mm0
+ addl $8, %ebx
+
+ /* These 9 instructions do what PSHUFB (if there were such an
+ * instruction) could do in 1. :(
+ */
+
+ movq %mm0, %mm3
+ movq %mm0, %mm4
+
+ pand %mm2, %mm3
+ psllq $16, %mm4
+ psrlq $16, %mm3
+ pand %mm2, %mm4
+
+ pand %mm1, %mm0
+ por %mm4, %mm3
+ por %mm3, %mm0
+
+ movq %mm0, (%ecx)
+ addl $8, %ecx
+ subl $1, %eax
+.L18:
+ jne .L19
+
+#ifdef USE_INNER_EMMS
+ emms
+#endif
+
+ /* At this point there are either 1 or 0 pixels remaining to be
+ * converted. Convert the last pixel, if needed.
+ */
+
+ testl $1, %edx
+ je .L20
+
+ DO_ONE_LAST_PIXEL()
+
+.L20:
+ popl %ebx
+ ret
+ .size _generic_read_RGBA_span_BGRA8888_REV_MMX, .-_generic_read_RGBA_span_BGRA8888_REV_MMX
+
+
+/**
+ * SSE optimized version of the BGRA8888_REV to RGBA copy routine. SSE
+ * instructions are only actually used to read data from the framebuffer.
+ * In practice, the speed-up is pretty small.
+ *
+ * \todo
+ * Do some more testing and determine if there's any reason to have this
+ * function in addition to the MMX version.
+ *
+ * \warning
+ * This function assumes that the caller will issue the EMMS instruction
+ * at the correct places.
+ */
+
+.globl _generic_read_RGBA_span_BGRA8888_REV_SSE
+.hidden _generic_read_RGBA_span_BGRA8888_REV_SSE
+ .type _generic_read_RGBA_span_BGRA8888_REV_SSE, @function
+_generic_read_RGBA_span_BGRA8888_REV_SSE:
+ pushl %esi
+ pushl %ebx
+ pushl %ebp
+
+#ifdef USE_INNER_EMMS
+ emms
+#endif
+ movq mask, %mm1
+ movq mask+16, %mm2
+
+ movl 16(%esp), %ebx /* source pointer */
+ movl 24(%esp), %edx /* number of pixels to copy */
+ movl 20(%esp), %ecx /* destination pointer */
+
+ testl %edx, %edx
+ jle .L35 /* Bail if there's nothing to do. */
+
+ movl %esp, %ebp
+ subl $16, %esp
+ andl $0xfffffff0, %esp
+
+ movl %ebx, %eax
+ movl %edx, %esi
+
+ negl %eax
+ andl $15, %eax
+ sarl $2, %eax
+ cmpl %edx, %eax
+ cmovle %eax, %esi
+
+ subl %esi, %edx
+
+ testl $1, %esi
+ je .L32
+
+ DO_ONE_PIXEL()
+.L32:
+
+ testl $2, %esi
+ je .L31
+
+ movq (%ebx), %mm0
+ addl $8, %ebx
+
+ movq %mm0, %mm3
+ movq %mm0, %mm4
+
+ pand %mm2, %mm3
+ psllq $16, %mm4
+ psrlq $16, %mm3
+ pand %mm2, %mm4
+
+ pand %mm1, %mm0
+ por %mm4, %mm3
+ por %mm3, %mm0
+
+ movq %mm0, (%ecx)
+ addl $8, %ecx
+.L31:
+
+ movl %edx, %eax
+ shrl $2, %eax
+ jmp .L33
+.L34:
+ movaps (%ebx), %xmm0
+ addl $16, %ebx
+
+ /* This would be so much better if we could just move directly from
+ * an SSE register to an MMX register. Unfortunately, that
+ * functionality wasn't introduced until SSE2 with the MOVDQ2Q
+ * instruction.
+ */
+
+ movaps %xmm0, (%esp)
+ movq (%esp), %mm0
+ movq 8(%esp), %mm5
+
+ movq %mm0, %mm3
+ movq %mm0, %mm4
+ movq %mm5, %mm6
+ movq %mm5, %mm7
+
+ pand %mm2, %mm3
+ pand %mm2, %mm6
+
+ psllq $16, %mm4
+ psllq $16, %mm7
+
+ psrlq $16, %mm3
+ psrlq $16, %mm6
+
+ pand %mm2, %mm4
+ pand %mm2, %mm7
+
+ pand %mm1, %mm0
+ pand %mm1, %mm5
+
+ por %mm4, %mm3
+ por %mm7, %mm6
+
+ por %mm3, %mm0
+ por %mm6, %mm5
+
+ movq %mm0, (%ecx)
+ movq %mm5, 8(%ecx)
+ addl $16, %ecx
+
+ subl $1, %eax
+.L33:
+ jne .L34
+
+#ifdef USE_INNER_EMMS
+ emms
+#endif
+ movl %ebp, %esp
+
+ /* At this point there are either [0, 3] pixels remaining to be
+ * converted.
+ */
+
+ testl $2, %edx
+ je .L36
+
+ movq (%ebx), %mm0
+ addl $8, %ebx
+
+ movq %mm0, %mm3
+ movq %mm0, %mm4
+
+ pand %mm2, %mm3
+ psllq $16, %mm4
+ psrlq $16, %mm3
+ pand %mm2, %mm4
+
+ pand %mm1, %mm0
+ por %mm4, %mm3
+ por %mm3, %mm0
+
+ movq %mm0, (%ecx)
+ addl $8, %ecx
+.L36:
+
+ testl $1, %edx
+ je .L35
+
+ DO_ONE_LAST_PIXEL()
+.L35:
+ popl %ebp
+ popl %ebx
+ popl %esi
+ ret
+ .size _generic_read_RGBA_span_BGRA8888_REV_SSE, .-_generic_read_RGBA_span_BGRA8888_REV_SSE
+
+
+/**
+ * SSE2 optimized version of the BGRA8888_REV to RGBA copy routine.
+ */
+
+ .text
+.globl _generic_read_RGBA_span_BGRA8888_REV_SSE2
+.hidden _generic_read_RGBA_span_BGRA8888_REV_SSE2
+ .type _generic_read_RGBA_span_BGRA8888_REV_SSE2, @function
+_generic_read_RGBA_span_BGRA8888_REV_SSE2:
+ pushl %esi
+ pushl %ebx
+
+ movdqa mask, %xmm1
+ movdqa mask+16, %xmm2
+
+ movl 12(%esp), %ebx /* source pointer */
+ movl 20(%esp), %edx /* number of pixels to copy */
+ movl 16(%esp), %ecx /* destination pointer */
+
+ movl %ebx, %eax
+ movl %edx, %esi
+
+ testl %edx, %edx
+ jle .L46 /* Bail if there's nothing to do. */
+
+ /* If the source pointer isn't a multiple of 16 we have to process
+ * a few pixels the "slow" way to get the address aligned for
+ * the SSE fetch intsructions.
+ */
+
+ negl %eax
+ andl $15, %eax
+ sarl $2, %eax
+
+ cmpl %edx, %eax
+ cmovbe %eax, %esi
+ subl %esi, %edx
+
+ testl $1, %esi
+ je .L41
+
+ DO_ONE_PIXEL()
+.L41:
+ testl $2, %esi
+ je .L40
+
+ movq (%ebx), %xmm0
+ addl $8, %ebx
+
+ movdqa %xmm0, %xmm3
+ movdqa %xmm0, %xmm4
+ andps %xmm1, %xmm0
+
+ andps %xmm2, %xmm3
+ pslldq $2, %xmm4
+ psrldq $2, %xmm3
+ andps %xmm2, %xmm4
+
+ orps %xmm4, %xmm3
+ orps %xmm3, %xmm0
+
+ movq %xmm0, (%ecx)
+ addl $8, %ecx
+.L40:
+
+ /* Would it be worth having a specialized version of this loop for
+ * the case where the destination is 16-byte aligned? That version
+ * would be identical except that it could use movedqa instead of
+ * movdqu.
+ */
+
+ movl %edx, %eax
+ shrl $2, %eax
+ jmp .L42
+.L43:
+ movdqa (%ebx), %xmm0
+ addl $16, %ebx
+
+ movdqa %xmm0, %xmm3
+ movdqa %xmm0, %xmm4
+ andps %xmm1, %xmm0
+
+ andps %xmm2, %xmm3
+ pslldq $2, %xmm4
+ psrldq $2, %xmm3
+ andps %xmm2, %xmm4
+
+ orps %xmm4, %xmm3
+ orps %xmm3, %xmm0
+
+ movdqu %xmm0, (%ecx)
+ addl $16, %ecx
+ subl $1, %eax
+.L42:
+ jne .L43
+
+
+ /* There may be upto 3 pixels remaining to be copied. Take care
+ * of them now. We do the 2 pixel case first because the data
+ * will be aligned.
+ */
+
+ testl $2, %edx
+ je .L47
+
+ movq (%ebx), %xmm0
+
+ movdqa %xmm0, %xmm3
+ movdqa %xmm0, %xmm4
+ andps %xmm1, %xmm0
+
+ andps %xmm2, %xmm3
+ pslldq $2, %xmm4
+ psrldq $2, %xmm3
+ andps %xmm2, %xmm4
+
+ orps %xmm4, %xmm3
+ orps %xmm3, %xmm0
+
+ movq %xmm0, (%ecx)
+.L47:
+
+ testl $1, %edx
+ je .L46
+
+ DO_ONE_LAST_PIXEL()
+.L46:
+
+ popl %ebx
+ popl %esi
+ ret
+ .size _generic_read_RGBA_span_BGRA8888_REV_SSE2, .-_generic_read_RGBA_span_BGRA8888_REV_SSE2
+
+
+
+ .section .rodata
+
+ .align 16
+mask_565:
+ .word 0xf800
+ .word 0x07e0
+ .word 0x001f
+ .word 0x0000
+
+/* Setting SCALE_ADJUST to 5 gives a perfect match with the classic C
+ * implementation in Mesa. Setting SCALE_ADJUST to 0 is slightly faster but
+ * at a small cost to accuracy.
+ */
+
+#define SCALE_ADJUST 5
+#if SCALE_ADJUST == 5
+prescale:
+ .word 0x0001
+ .word 0x0010
+ .word 0x0200
+ .word 0x0000
+
+scale:
+ .word 0x20e8 /* (0x00ff0000 / 0x000007c0) + 1 */
+ .word 0x40c5 /* (0x00ff0000 / 0x000003f0) + 1 */
+ .word 0x839d /* (0x00ff0000 / 0x000001f0) + 1 */
+ .word 0x0000
+#elif SCALE_ADJUST == 0
+prescale:
+ .word 0x0001
+ .word 0x0020
+ .word 0x0800
+ .word 0x0000
+
+scale:
+ .word 0x0108 /* (0x00ff0000 / 0x0000f800) + 1 */
+ .word 0x0104 /* (0x00ff0000 / 0x0000fc00) + 1 */
+ .word 0x0108 /* (0x00ff0000 / 0x0000f800) + 1 */
+ .word 0x0000
+#else
+#error SCALE_ADJUST must either be 5 or 0.
+#endif
+
+
+alpha: .long 0x00000000
+ .long 0x00ff0000
+
+/**
+ * MMX optimized version of the RGB565 to RGBA copy routine.
+ */
+
+ .text
+ .globl _generic_read_RGBA_span_RGB565_MMX
+ .hidden _generic_read_RGBA_span_RGB565_MMX
+ .type _generic_read_RGBA_span_RGB565_MMX, @function
+
+_generic_read_RGBA_span_RGB565_MMX:
+
+#ifdef USE_INNER_EMMS
+ emms
+#endif
+
+ movl 4(%esp), %eax /* source pointer */
+ movl 8(%esp), %edx /* destination pointer */
+ movl 12(%esp), %ecx /* number of pixels to copy */
+
+ movq mask_565, %mm5
+ movq prescale, %mm6
+ movq scale, %mm7
+
+ sarl $2, %ecx
+ jle .L01 /* Bail early if the count is negative. */
+ jmp .L02
+
+.L03:
+ /* Fetch 4 RGB565 pixels into %mm4. Distribute the first and
+ * second pixels into the four words of %mm0 and %mm2.
+ */
+
+ movq (%eax), %mm4
+ addl $8, %eax
+
+ pshufw $0x00, %mm4, %mm0
+ pshufw $0x55, %mm4, %mm2
+
+
+ /* Mask the pixels so that each word of each register contains only
+ * one color component.
+ */
+
+ pand %mm5, %mm0
+ pand %mm5, %mm2
+
+
+ /* Adjust the component values so that they are as small as possible,
+ * but large enough so that we can multiply them by an unsigned 16-bit
+ * number and get a value as large as 0x00ff0000.
+ */
+
+ pmullw %mm6, %mm0
+ pmullw %mm6, %mm2
+#if SCALE_ADJUST > 0
+ psrlw $SCALE_ADJUST, %mm0
+ psrlw $SCALE_ADJUST, %mm2
+#endif
+
+ /* Scale the input component values to be on the range
+ * [0, 0x00ff0000]. This it the real magic of the whole routine.
+ */
+
+ pmulhuw %mm7, %mm0
+ pmulhuw %mm7, %mm2
+
+
+ /* Always set the alpha value to 0xff.
+ */
+
+ por alpha, %mm0
+ por alpha, %mm2
+
+
+ /* Pack the 16-bit values to 8-bit values and store the converted
+ * pixel data.
+ */
+
+ packuswb %mm2, %mm0
+ movq %mm0, (%edx)
+ addl $8, %edx
+
+
+
+ pshufw $0xaa, %mm4, %mm0
+ pshufw $0xff, %mm4, %mm2
+
+ pand %mm5, %mm0
+ pand %mm5, %mm2
+ pmullw %mm6, %mm0
+ pmullw %mm6, %mm2
+#if SCALE_ADJUST > 0
+ psrlw $SCALE_ADJUST, %mm0
+ psrlw $SCALE_ADJUST, %mm2
+#endif
+ pmulhuw %mm7, %mm0
+ pmulhuw %mm7, %mm2
+
+ por alpha, %mm0
+ por alpha, %mm2
+
+ packuswb %mm2, %mm0
+
+ movq %mm0, (%edx)
+ addl $8, %edx
+
+ subl $1, %ecx
+.L02:
+ jne .L03
+
+
+ /* At this point there can be at most 3 pixels left to process. If
+ * there is either 2 or 3 left, process 2.
+ */
+
+ movl 12(%esp), %ecx
+ testl $0x02, %ecx
+ je .L04
+
+ movd (%eax), %mm4
+ addl $4, %eax
+
+ pshufw $0x00, %mm4, %mm0
+ pshufw $0x55, %mm4, %mm2
+
+ pand %mm5, %mm0
+ pand %mm5, %mm2
+ pmullw %mm6, %mm0
+ pmullw %mm6, %mm2
+#if SCALE_ADJUST > 0
+ psrlw $SCALE_ADJUST, %mm0
+ psrlw $SCALE_ADJUST, %mm2
+#endif
+ pmulhuw %mm7, %mm0
+ pmulhuw %mm7, %mm2
+
+ por alpha, %mm0
+ por alpha, %mm2
+
+ packuswb %mm2, %mm0
+
+ movq %mm0, (%edx)
+ addl $8, %edx
+
+.L04:
+ /* At this point there can be at most 1 pixel left to process.
+ * Process it if needed.
+ */
+
+ testl $0x01, %ecx
+ je .L01
+
+ movzxw (%eax), %ecx
+ movd %ecx, %mm4
+
+ pshufw $0x00, %mm4, %mm0
+
+ pand %mm5, %mm0
+ pmullw %mm6, %mm0
+#if SCALE_ADJUST > 0
+ psrlw $SCALE_ADJUST, %mm0
+#endif
+ pmulhuw %mm7, %mm0
+
+ por alpha, %mm0
+
+ packuswb %mm0, %mm0
+
+ movd %mm0, (%edx)
+
+.L01:
+#ifdef USE_INNER_EMMS
+ emms
+#endif
+ ret
+#endif /* !defined(__DJGPP__) && !defined(__MINGW32__) */
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/read_rgba_span_x86.h b/nx-X11/extras/Mesa/src/mesa/x86/read_rgba_span_x86.h
new file mode 100644
index 000000000..564b1bb0f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/read_rgba_span_x86.h
@@ -0,0 +1,56 @@
+/*
+ * (C) Copyright IBM Corporation 2004
+ * 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
+ * IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/**
+ * \file read_rgba_span_x86.h
+ *
+ * \author Ian Romanick <idr@us.ibm.com>
+ */
+
+#ifndef READ_RGBA_SPAN_X86_H
+#define READ_RGBA_SPAN_X86_H
+
+#if defined(USE_SSE_ASM) || defined(USE_MMX_ASM)
+#include "x86/common_x86_asm.h"
+#endif
+
+#if defined(USE_SSE_ASM)
+extern void _generic_read_RGBA_span_BGRA8888_REV_SSE2( const unsigned char *,
+ unsigned char *, unsigned );
+#endif
+
+#if defined(USE_SSE_ASM)
+extern void _generic_read_RGBA_span_BGRA8888_REV_SSE( const unsigned char *,
+ unsigned char *, unsigned );
+#endif
+
+#if defined(USE_MMX_ASM)
+extern void _generic_read_RGBA_span_BGRA8888_REV_MMX( const unsigned char *,
+ unsigned char *, unsigned );
+
+extern void _generic_read_RGBA_span_RGB565_MMX( const unsigned char *,
+ unsigned char *, unsigned );
+#endif
+
+#endif /* READ_RGBA_SPAN_X86_H */
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/rtasm/x86sse.c b/nx-X11/extras/Mesa/src/mesa/x86/rtasm/x86sse.c
new file mode 100644
index 000000000..0c9ffe25f
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/rtasm/x86sse.c
@@ -0,0 +1,997 @@
+#if defined(USE_X86_ASM)
+
+#include "imports.h"
+#include "x86sse.h"
+
+#define DISASSEM 0
+#define X86_TWOB 0x0f
+
+/* Emit bytes to the instruction stream:
+ */
+static void emit_1b( struct x86_function *p, GLbyte b0 )
+{
+ *(GLbyte *)(p->csr++) = b0;
+}
+
+static void emit_1i( struct x86_function *p, GLint i0 )
+{
+ *(GLint *)(p->csr) = i0;
+ p->csr += 4;
+}
+
+static void disassem( struct x86_function *p, const char *fn )
+{
+#if DISASSEM && 0
+ if (fn && fn != p->fn) {
+ _mesa_printf("0x%x: %s\n", p->csr, fn);
+ p->fn = fn;
+ }
+#endif
+}
+
+static void emit_1ub_fn( struct x86_function *p, GLubyte b0, const char *fn )
+{
+ disassem(p, fn);
+ *(p->csr++) = b0;
+}
+
+static void emit_2ub_fn( struct x86_function *p, GLubyte b0, GLubyte b1, const char *fn )
+{
+ disassem(p, fn);
+ *(p->csr++) = b0;
+ *(p->csr++) = b1;
+}
+
+static void emit_3ub_fn( struct x86_function *p, GLubyte b0, GLubyte b1, GLubyte b2, const char *fn )
+{
+ disassem(p, fn);
+ *(p->csr++) = b0;
+ *(p->csr++) = b1;
+ *(p->csr++) = b2;
+}
+
+#define emit_1ub(p, b0) emit_1ub_fn(p, b0, __FUNCTION__)
+#define emit_2ub(p, b0, b1) emit_2ub_fn(p, b0, b1, __FUNCTION__)
+#define emit_3ub(p, b0, b1, b2) emit_3ub_fn(p, b0, b1, b2, __FUNCTION__)
+
+
+
+/* Build a modRM byte + possible displacement. No treatment of SIB
+ * indexing. BZZT - no way to encode an absolute address.
+ */
+static void emit_modrm( struct x86_function *p,
+ struct x86_reg reg,
+ struct x86_reg regmem )
+{
+ GLubyte val = 0;
+
+ assert(reg.mod == mod_REG);
+
+ val |= regmem.mod << 6; /* mod field */
+ val |= reg.idx << 3; /* reg field */
+ val |= regmem.idx; /* r/m field */
+
+ emit_1ub_fn(p, val, 0);
+
+ /* Oh-oh we've stumbled into the SIB thing.
+ */
+ if (regmem.file == file_REG32 &&
+ regmem.idx == reg_SP) {
+ emit_1ub_fn(p, 0x24, 0); /* simplistic! */
+ }
+
+ switch (regmem.mod) {
+ case mod_REG:
+ case mod_INDIRECT:
+ break;
+ case mod_DISP8:
+ emit_1b(p, regmem.disp);
+ break;
+ case mod_DISP32:
+ emit_1i(p, regmem.disp);
+ break;
+ default:
+ assert(0);
+ break;
+ }
+}
+
+
+static void emit_modrm_noreg( struct x86_function *p,
+ GLuint op,
+ struct x86_reg regmem )
+{
+ struct x86_reg dummy = x86_make_reg(file_REG32, op);
+ emit_modrm(p, dummy, regmem);
+}
+
+/* Many x86 instructions have two opcodes to cope with the situations
+ * where the destination is a register or memory reference
+ * respectively. This function selects the correct opcode based on
+ * the arguments presented.
+ */
+static void emit_op_modrm( struct x86_function *p,
+ GLubyte op_dst_is_reg,
+ GLubyte op_dst_is_mem,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ switch (dst.mod) {
+ case mod_REG:
+ emit_1ub_fn(p, op_dst_is_reg, 0);
+ emit_modrm(p, dst, src);
+ break;
+ case mod_INDIRECT:
+ case mod_DISP32:
+ case mod_DISP8:
+ assert(src.mod == mod_REG);
+ emit_1ub_fn(p, op_dst_is_mem, 0);
+ emit_modrm(p, src, dst);
+ break;
+ default:
+ assert(0);
+ break;
+ }
+}
+
+
+
+
+
+
+
+/* Create and manipulate registers and regmem values:
+ */
+struct x86_reg x86_make_reg( GLuint file,
+ GLuint idx )
+{
+ struct x86_reg reg;
+
+ reg.file = file;
+ reg.idx = idx;
+ reg.mod = mod_REG;
+ reg.disp = 0;
+
+ return reg;
+}
+
+struct x86_reg x86_make_disp( struct x86_reg reg,
+ GLint disp )
+{
+ assert(reg.file == file_REG32);
+
+ if (reg.mod == mod_REG)
+ reg.disp = disp;
+ else
+ reg.disp += disp;
+
+ if (reg.disp == 0)
+ reg.mod = mod_INDIRECT;
+ else if (reg.disp <= 127 && reg.disp >= -128)
+ reg.mod = mod_DISP8;
+ else
+ reg.mod = mod_DISP32;
+
+ return reg;
+}
+
+struct x86_reg x86_deref( struct x86_reg reg )
+{
+ return x86_make_disp(reg, 0);
+}
+
+struct x86_reg x86_get_base_reg( struct x86_reg reg )
+{
+ return x86_make_reg( reg.file, reg.idx );
+}
+
+GLubyte *x86_get_label( struct x86_function *p )
+{
+ return p->csr;
+}
+
+
+
+/***********************************************************************
+ * x86 instructions
+ */
+
+
+void x86_jcc( struct x86_function *p,
+ GLuint cc,
+ GLubyte *label )
+{
+ GLint offset = label - (x86_get_label(p) + 2);
+
+ if (offset <= 127 && offset >= -128) {
+ emit_1ub(p, 0x70 + cc);
+ emit_1b(p, (GLbyte) offset);
+ }
+ else {
+ offset = label - (x86_get_label(p) + 6);
+ emit_2ub(p, 0x0f, 0x80 + cc);
+ emit_1i(p, offset);
+ }
+}
+
+/* Always use a 32bit offset for forward jumps:
+ */
+GLubyte *x86_jcc_forward( struct x86_function *p,
+ GLuint cc )
+{
+ emit_2ub(p, 0x0f, 0x80 + cc);
+ emit_1i(p, 0);
+ return x86_get_label(p);
+}
+
+/* Fixup offset from forward jump:
+ */
+void x86_fixup_fwd_jump( struct x86_function *p,
+ GLubyte *fixup )
+{
+ *(int *)(fixup - 4) = x86_get_label(p) - fixup;
+}
+
+void x86_push( struct x86_function *p,
+ struct x86_reg reg )
+{
+ assert(reg.mod == mod_REG);
+ emit_1ub(p, 0x50 + reg.idx);
+ p->stack_offset += 4;
+}
+
+void x86_pop( struct x86_function *p,
+ struct x86_reg reg )
+{
+ assert(reg.mod == mod_REG);
+ emit_1ub(p, 0x58 + reg.idx);
+ p->stack_offset -= 4;
+}
+
+void x86_inc( struct x86_function *p,
+ struct x86_reg reg )
+{
+ assert(reg.mod == mod_REG);
+ emit_1ub(p, 0x40 + reg.idx);
+}
+
+void x86_dec( struct x86_function *p,
+ struct x86_reg reg )
+{
+ assert(reg.mod == mod_REG);
+ emit_1ub(p, 0x48 + reg.idx);
+}
+
+void x86_ret( struct x86_function *p )
+{
+ emit_1ub(p, 0xc3);
+}
+
+void x86_sahf( struct x86_function *p )
+{
+ emit_1ub(p, 0x9e);
+}
+
+void x86_mov( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_op_modrm( p, 0x8b, 0x89, dst, src );
+}
+
+void x86_xor( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_op_modrm( p, 0x33, 0x31, dst, src );
+}
+
+void x86_cmp( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_op_modrm( p, 0x3b, 0x39, dst, src );
+}
+
+void x86_lea( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_1ub(p, 0x8d);
+ emit_modrm( p, dst, src );
+}
+
+void x86_test( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_1ub(p, 0x85);
+ emit_modrm( p, dst, src );
+}
+
+
+
+/***********************************************************************
+ * SSE instructions
+ */
+
+
+void sse_movss( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_2ub(p, 0xF3, X86_TWOB);
+ emit_op_modrm( p, 0x10, 0x11, dst, src );
+}
+
+void sse_movaps( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_1ub(p, X86_TWOB);
+ emit_op_modrm( p, 0x28, 0x29, dst, src );
+}
+
+void sse_movups( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_1ub(p, X86_TWOB);
+ emit_op_modrm( p, 0x10, 0x11, dst, src );
+}
+
+void sse_movhps( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ assert(dst.mod != mod_REG || src.mod != mod_REG);
+ emit_1ub(p, X86_TWOB);
+ emit_op_modrm( p, 0x16, 0x17, dst, src ); /* cf movlhps */
+}
+
+void sse_movlps( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ assert(dst.mod != mod_REG || src.mod != mod_REG);
+ emit_1ub(p, X86_TWOB);
+ emit_op_modrm( p, 0x12, 0x13, dst, src ); /* cf movhlps */
+}
+
+void sse_maxps( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_2ub(p, X86_TWOB, 0x5F);
+ emit_modrm( p, dst, src );
+}
+
+void sse_divss( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_3ub(p, 0xF3, X86_TWOB, 0x5E);
+ emit_modrm( p, dst, src );
+}
+
+void sse_minps( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_2ub(p, X86_TWOB, 0x5D);
+ emit_modrm( p, dst, src );
+}
+
+void sse_subps( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_2ub(p, X86_TWOB, 0x5C);
+ emit_modrm( p, dst, src );
+}
+
+void sse_mulps( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_2ub(p, X86_TWOB, 0x59);
+ emit_modrm( p, dst, src );
+}
+
+void sse_addps( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_2ub(p, X86_TWOB, 0x58);
+ emit_modrm( p, dst, src );
+}
+
+void sse_addss( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_3ub(p, 0xF3, X86_TWOB, 0x58);
+ emit_modrm( p, dst, src );
+}
+
+void sse_andps( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_2ub(p, X86_TWOB, 0x54);
+ emit_modrm( p, dst, src );
+}
+
+
+void sse_rsqrtss( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_3ub(p, 0xF3, X86_TWOB, 0x52);
+ emit_modrm( p, dst, src );
+
+}
+
+void sse_movhlps( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ assert(dst.mod == mod_REG && src.mod == mod_REG);
+ emit_2ub(p, X86_TWOB, 0x12);
+ emit_modrm( p, dst, src );
+}
+
+void sse_movlhps( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ assert(dst.mod == mod_REG && src.mod == mod_REG);
+ emit_2ub(p, X86_TWOB, 0x16);
+ emit_modrm( p, dst, src );
+}
+
+
+void sse_cvtps2pi( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ assert(dst.file == file_MMX &&
+ (src.file == file_XMM || src.mod != mod_REG));
+
+ p->need_emms = 1;
+
+ emit_2ub(p, X86_TWOB, 0x2d);
+ emit_modrm( p, dst, src );
+}
+
+
+/* Shufps can also be used to implement a reduced swizzle when dest ==
+ * arg0.
+ */
+void sse_shufps( struct x86_function *p,
+ struct x86_reg dest,
+ struct x86_reg arg0,
+ GLubyte shuf)
+{
+ emit_2ub(p, X86_TWOB, 0xC6);
+ emit_modrm(p, dest, arg0);
+ emit_1ub(p, shuf);
+}
+
+void sse_cmpps( struct x86_function *p,
+ struct x86_reg dest,
+ struct x86_reg arg0,
+ GLubyte cc)
+{
+ emit_2ub(p, X86_TWOB, 0xC2);
+ emit_modrm(p, dest, arg0);
+ emit_1ub(p, cc);
+}
+
+/***********************************************************************
+ * SSE2 instructions
+ */
+
+/**
+ * Perform a reduced swizzle:
+ */
+void sse2_pshufd( struct x86_function *p,
+ struct x86_reg dest,
+ struct x86_reg arg0,
+ GLubyte shuf)
+{
+ emit_3ub(p, 0x66, X86_TWOB, 0x70);
+ emit_modrm(p, dest, arg0);
+ emit_1ub(p, shuf);
+}
+
+void sse2_cvtps2dq( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_3ub(p, 0x66, X86_TWOB, 0x5B);
+ emit_modrm( p, dst, src );
+}
+
+void sse2_packssdw( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_3ub(p, 0x66, X86_TWOB, 0x6B);
+ emit_modrm( p, dst, src );
+}
+
+void sse2_packsswb( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_3ub(p, 0x66, X86_TWOB, 0x63);
+ emit_modrm( p, dst, src );
+}
+
+void sse2_packuswb( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_3ub(p, 0x66, X86_TWOB, 0x67);
+ emit_modrm( p, dst, src );
+}
+
+void sse2_rcpss( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_3ub(p, 0xF3, X86_TWOB, 0x53);
+ emit_modrm( p, dst, src );
+}
+
+void sse2_movd( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ emit_2ub(p, 0x66, X86_TWOB);
+ emit_op_modrm( p, 0x6e, 0x7e, dst, src );
+}
+
+
+
+
+/***********************************************************************
+ * x87 instructions
+ */
+void x87_fist( struct x86_function *p, struct x86_reg dst )
+{
+ emit_1ub(p, 0xdb);
+ emit_modrm_noreg(p, 2, dst);
+}
+
+void x87_fistp( struct x86_function *p, struct x86_reg dst )
+{
+ emit_1ub(p, 0xdb);
+ emit_modrm_noreg(p, 3, dst);
+}
+
+void x87_fldz( struct x86_function *p )
+{
+ emit_2ub(p, 0xd9, 0xee);
+}
+
+
+void x87_fldcw( struct x86_function *p, struct x86_reg arg )
+{
+ assert(arg.file == file_REG32);
+ assert(arg.mod != mod_REG);
+ emit_1ub(p, 0xd9);
+ emit_modrm_noreg(p, 5, arg);
+}
+
+void x87_fld1( struct x86_function *p )
+{
+ emit_2ub(p, 0xd9, 0xe8);
+}
+
+void x87_fldl2e( struct x86_function *p )
+{
+ emit_2ub(p, 0xd9, 0xea);
+}
+
+void x87_fldln2( struct x86_function *p )
+{
+ emit_2ub(p, 0xd9, 0xed);
+}
+
+void x87_fwait( struct x86_function *p )
+{
+ emit_1ub(p, 0x9b);
+}
+
+void x87_fnclex( struct x86_function *p )
+{
+ emit_2ub(p, 0xdb, 0xe2);
+}
+
+void x87_fclex( struct x86_function *p )
+{
+ x87_fwait(p);
+ x87_fnclex(p);
+}
+
+
+static void x87_arith_op( struct x86_function *p, struct x86_reg dst, struct x86_reg arg,
+ GLubyte dst0ub0,
+ GLubyte dst0ub1,
+ GLubyte arg0ub0,
+ GLubyte arg0ub1,
+ GLubyte argmem_noreg)
+{
+ assert(dst.file == file_x87);
+
+ if (arg.file == file_x87) {
+ if (dst.idx == 0)
+ emit_2ub(p, dst0ub0, dst0ub1+arg.idx);
+ else if (arg.idx == 0)
+ emit_2ub(p, arg0ub0, arg0ub1+arg.idx);
+ else
+ assert(0);
+ }
+ else if (dst.idx == 0) {
+ assert(arg.file = file_REG32);
+ emit_1ub(p, 0xd8);
+ emit_modrm_noreg(p, argmem_noreg, arg);
+ }
+ else
+ assert(0);
+}
+
+void x87_fmul( struct x86_function *p, struct x86_reg dst, struct x86_reg arg )
+{
+ x87_arith_op(p, dst, arg,
+ 0xd8, 0xc8,
+ 0xdc, 0xc8,
+ 4);
+}
+
+void x87_fsub( struct x86_function *p, struct x86_reg dst, struct x86_reg arg )
+{
+ x87_arith_op(p, dst, arg,
+ 0xd8, 0xe0,
+ 0xdc, 0xe8,
+ 4);
+}
+
+void x87_fsubr( struct x86_function *p, struct x86_reg dst, struct x86_reg arg )
+{
+ x87_arith_op(p, dst, arg,
+ 0xd8, 0xe8,
+ 0xdc, 0xe0,
+ 5);
+}
+
+void x87_fadd( struct x86_function *p, struct x86_reg dst, struct x86_reg arg )
+{
+ x87_arith_op(p, dst, arg,
+ 0xd8, 0xc0,
+ 0xdc, 0xc0,
+ 0);
+}
+
+void x87_fdiv( struct x86_function *p, struct x86_reg dst, struct x86_reg arg )
+{
+ x87_arith_op(p, dst, arg,
+ 0xd8, 0xf0,
+ 0xdc, 0xf8,
+ 6);
+}
+
+void x87_fdivr( struct x86_function *p, struct x86_reg dst, struct x86_reg arg )
+{
+ x87_arith_op(p, dst, arg,
+ 0xd8, 0xf8,
+ 0xdc, 0xf0,
+ 7);
+}
+
+void x87_fmulp( struct x86_function *p, struct x86_reg dst )
+{
+ assert(dst.file == file_x87);
+ assert(dst.idx >= 1);
+ emit_2ub(p, 0xde, 0xc8+dst.idx);
+}
+
+void x87_fsubp( struct x86_function *p, struct x86_reg dst )
+{
+ assert(dst.file == file_x87);
+ assert(dst.idx >= 1);
+ emit_2ub(p, 0xde, 0xe8+dst.idx);
+}
+
+void x87_fsubrp( struct x86_function *p, struct x86_reg dst )
+{
+ assert(dst.file == file_x87);
+ assert(dst.idx >= 1);
+ emit_2ub(p, 0xde, 0xe0+dst.idx);
+}
+
+void x87_faddp( struct x86_function *p, struct x86_reg dst )
+{
+ assert(dst.file == file_x87);
+ assert(dst.idx >= 1);
+ emit_2ub(p, 0xde, 0xc0+dst.idx);
+}
+
+void x87_fdivp( struct x86_function *p, struct x86_reg dst )
+{
+ assert(dst.file == file_x87);
+ assert(dst.idx >= 1);
+ emit_2ub(p, 0xde, 0xf8+dst.idx);
+}
+
+void x87_fdivrp( struct x86_function *p, struct x86_reg dst )
+{
+ assert(dst.file == file_x87);
+ assert(dst.idx >= 1);
+ emit_2ub(p, 0xde, 0xf0+dst.idx);
+}
+
+void x87_fucom( struct x86_function *p, struct x86_reg arg )
+{
+ assert(arg.file == file_x87);
+ emit_2ub(p, 0xdd, 0xe0+arg.idx);
+}
+
+void x87_fucomp( struct x86_function *p, struct x86_reg arg )
+{
+ assert(arg.file == file_x87);
+ emit_2ub(p, 0xdd, 0xe8+arg.idx);
+}
+
+void x87_fucompp( struct x86_function *p )
+{
+ emit_2ub(p, 0xda, 0xe9);
+}
+
+void x87_fxch( struct x86_function *p, struct x86_reg arg )
+{
+ assert(arg.file == file_x87);
+ emit_2ub(p, 0xd9, 0xc8+arg.idx);
+}
+
+void x87_fabs( struct x86_function *p )
+{
+ emit_2ub(p, 0xd9, 0xe1);
+}
+
+void x87_fchs( struct x86_function *p )
+{
+ emit_2ub(p, 0xd9, 0xe0);
+}
+
+void x87_fcos( struct x86_function *p )
+{
+ emit_2ub(p, 0xd9, 0xff);
+}
+
+
+void x87_fprndint( struct x86_function *p )
+{
+ emit_2ub(p, 0xd9, 0xfc);
+}
+
+void x87_fscale( struct x86_function *p )
+{
+ emit_2ub(p, 0xd9, 0xfd);
+}
+
+void x87_fsin( struct x86_function *p )
+{
+ emit_2ub(p, 0xd9, 0xfe);
+}
+
+void x87_fsincos( struct x86_function *p )
+{
+ emit_2ub(p, 0xd9, 0xfb);
+}
+
+void x87_fsqrt( struct x86_function *p )
+{
+ emit_2ub(p, 0xd9, 0xfa);
+}
+
+void x87_fxtract( struct x86_function *p )
+{
+ emit_2ub(p, 0xd9, 0xf4);
+}
+
+/* st0 = (2^st0)-1
+ *
+ * Restrictions: -1.0 <= st0 <= 1.0
+ */
+void x87_f2xm1( struct x86_function *p )
+{
+ emit_2ub(p, 0xd9, 0xf0);
+}
+
+/* st1 = st1 * log2(st0);
+ * pop_stack;
+ */
+void x87_fyl2x( struct x86_function *p )
+{
+ emit_2ub(p, 0xd9, 0xf1);
+}
+
+/* st1 = st1 * log2(st0 + 1.0);
+ * pop_stack;
+ *
+ * A fast operation, with restrictions: -.29 < st0 < .29
+ */
+void x87_fyl2xp1( struct x86_function *p )
+{
+ emit_2ub(p, 0xd9, 0xf9);
+}
+
+
+void x87_fld( struct x86_function *p, struct x86_reg arg )
+{
+ if (arg.file == file_x87)
+ emit_2ub(p, 0xd9, 0xc0 + arg.idx);
+ else {
+ emit_1ub(p, 0xd9);
+ emit_modrm_noreg(p, 0, arg);
+ }
+}
+
+void x87_fst( struct x86_function *p, struct x86_reg dst )
+{
+ if (dst.file == file_x87)
+ emit_2ub(p, 0xdd, 0xd0 + dst.idx);
+ else {
+ emit_1ub(p, 0xd9);
+ emit_modrm_noreg(p, 2, dst);
+ }
+}
+
+void x87_fstp( struct x86_function *p, struct x86_reg dst )
+{
+ if (dst.file == file_x87)
+ emit_2ub(p, 0xdd, 0xd8 + dst.idx);
+ else {
+ emit_1ub(p, 0xd9);
+ emit_modrm_noreg(p, 3, dst);
+ }
+}
+
+void x87_fcom( struct x86_function *p, struct x86_reg dst )
+{
+ if (dst.file == file_x87)
+ emit_2ub(p, 0xd8, 0xd0 + dst.idx);
+ else {
+ emit_1ub(p, 0xd8);
+ emit_modrm_noreg(p, 2, dst);
+ }
+}
+
+void x87_fcomp( struct x86_function *p, struct x86_reg dst )
+{
+ if (dst.file == file_x87)
+ emit_2ub(p, 0xd8, 0xd8 + dst.idx);
+ else {
+ emit_1ub(p, 0xd8);
+ emit_modrm_noreg(p, 3, dst);
+ }
+}
+
+
+void x87_fnstsw( struct x86_function *p, struct x86_reg dst )
+{
+ assert(dst.file == file_REG32);
+
+ if (dst.idx == reg_AX &&
+ dst.mod == mod_REG)
+ emit_2ub(p, 0xdf, 0xe0);
+ else {
+ emit_1ub(p, 0xdd);
+ emit_modrm_noreg(p, 7, dst);
+ }
+}
+
+
+
+
+/***********************************************************************
+ * MMX instructions
+ */
+
+void mmx_emms( struct x86_function *p )
+{
+ assert(p->need_emms);
+ emit_2ub(p, 0x0f, 0x77);
+ p->need_emms = 0;
+}
+
+void mmx_packssdw( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ assert(dst.file == file_MMX &&
+ (src.file == file_MMX || src.mod != mod_REG));
+
+ p->need_emms = 1;
+
+ emit_2ub(p, X86_TWOB, 0x6b);
+ emit_modrm( p, dst, src );
+}
+
+void mmx_packuswb( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ assert(dst.file == file_MMX &&
+ (src.file == file_MMX || src.mod != mod_REG));
+
+ p->need_emms = 1;
+
+ emit_2ub(p, X86_TWOB, 0x67);
+ emit_modrm( p, dst, src );
+}
+
+void mmx_movd( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ p->need_emms = 1;
+ emit_1ub(p, X86_TWOB);
+ emit_op_modrm( p, 0x6e, 0x7e, dst, src );
+}
+
+void mmx_movq( struct x86_function *p,
+ struct x86_reg dst,
+ struct x86_reg src )
+{
+ p->need_emms = 1;
+ emit_1ub(p, X86_TWOB);
+ emit_op_modrm( p, 0x6f, 0x7f, dst, src );
+}
+
+
+/***********************************************************************
+ * Helper functions
+ */
+
+
+/* Retreive a reference to one of the function arguments, taking into
+ * account any push/pop activity:
+ */
+struct x86_reg x86_fn_arg( struct x86_function *p,
+ GLuint arg )
+{
+ return x86_make_disp(x86_make_reg(file_REG32, reg_SP),
+ p->stack_offset + arg * 4); /* ??? */
+}
+
+
+void x86_init_func( struct x86_function *p )
+{
+ p->store = _mesa_exec_malloc(1024);
+ p->csr = p->store;
+}
+
+void x86_release_func( struct x86_function *p )
+{
+ _mesa_exec_free(p->store);
+}
+
+
+void (*x86_get_func( struct x86_function *p ))(void)
+{
+ if (DISASSEM)
+ _mesa_printf("disassemble %p %p\n", p->store, p->csr);
+ return (void (*)())p->store;
+}
+
+#else
+
+void x86sse_dummy( void )
+{
+}
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/rtasm/x86sse.h b/nx-X11/extras/Mesa/src/mesa/x86/rtasm/x86sse.h
new file mode 100644
index 000000000..611d01e1c
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/rtasm/x86sse.h
@@ -0,0 +1,223 @@
+
+#ifndef _X86SSE_H_
+#define _X86SSE_H_
+
+#if defined(USE_X86_ASM)
+
+#include "glheader.h"
+
+/* It is up to the caller to ensure that instructions issued are
+ * suitable for the host cpu. There are no checks made in this module
+ * for mmx/sse/sse2 support on the cpu.
+ */
+struct x86_reg {
+ GLuint file:3;
+ GLuint idx:3;
+ GLuint mod:2; /* mod_REG if this is just a register */
+ GLint disp:24; /* only +/- 23bits of offset - should be enough... */
+};
+
+struct x86_function {
+ GLubyte *store;
+ GLubyte *csr;
+ GLuint stack_offset;
+ GLint need_emms;
+ const char *fn;
+};
+
+enum x86_reg_file {
+ file_REG32,
+ file_MMX,
+ file_XMM,
+ file_x87
+};
+
+/* Values for mod field of modr/m byte
+ */
+enum x86_reg_mod {
+ mod_INDIRECT,
+ mod_DISP8,
+ mod_DISP32,
+ mod_REG
+};
+
+enum x86_reg_name {
+ reg_AX,
+ reg_CX,
+ reg_DX,
+ reg_BX,
+ reg_SP,
+ reg_BP,
+ reg_SI,
+ reg_DI
+};
+
+
+enum x86_cc {
+ cc_O, /* overflow */
+ cc_NO, /* not overflow */
+ cc_NAE, /* not above or equal / carry */
+ cc_AE, /* above or equal / not carry */
+ cc_E, /* equal / zero */
+ cc_NE /* not equal / not zero */
+};
+
+enum sse_cc {
+ cc_Equal,
+ cc_LessThan,
+ cc_LessThanEqual,
+ cc_Unordered,
+ cc_NotEqual,
+ cc_NotLessThan,
+ cc_NotLessThanEqual,
+ cc_Ordered
+};
+
+#define cc_Z cc_E
+#define cc_NZ cc_NE
+
+/* Begin/end/retreive function creation:
+ */
+
+
+void x86_init_func( struct x86_function *p );
+void x86_release_func( struct x86_function *p );
+void (*x86_get_func( struct x86_function *p ))( void );
+
+
+
+/* Create and manipulate registers and regmem values:
+ */
+struct x86_reg x86_make_reg( enum x86_reg_file file,
+ enum x86_reg_name idx );
+
+struct x86_reg x86_make_disp( struct x86_reg reg,
+ GLint disp );
+
+struct x86_reg x86_deref( struct x86_reg reg );
+
+struct x86_reg x86_get_base_reg( struct x86_reg reg );
+
+
+/* Labels, jumps and fixup:
+ */
+GLubyte *x86_get_label( struct x86_function *p );
+
+void x86_jcc( struct x86_function *p,
+ enum x86_cc cc,
+ GLubyte *label );
+
+GLubyte *x86_jcc_forward( struct x86_function *p,
+ enum x86_cc cc );
+
+void x86_fixup_fwd_jump( struct x86_function *p,
+ GLubyte *fixup );
+
+
+/* Macro for sse_shufps() and sse2_pshufd():
+ */
+#define SHUF(_x,_y,_z,_w) (((_x)<<0) | ((_y)<<2) | ((_z)<<4) | ((_w)<<6))
+#define SHUF_NOOP RSW(0,1,2,3)
+#define GET_SHUF(swz, idx) (((swz) >> ((idx)*2)) & 0x3)
+
+void mmx_emms( struct x86_function *p );
+void mmx_movd( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void mmx_movq( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void mmx_packssdw( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void mmx_packuswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+
+void sse2_cvtps2dq( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse2_movd( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse2_packssdw( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse2_packsswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse2_packuswb( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse2_pshufd( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, GLubyte shuf );
+void sse2_rcpss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+
+void sse_addps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse_addss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse_cvtps2pi( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse_divss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse_andps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse_cmpps( struct x86_function *p, struct x86_reg dst, struct x86_reg src, GLubyte cc );
+void sse_maxps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse_minps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse_movaps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse_movhlps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse_movhps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse_movlhps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse_movlps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse_movss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse_movups( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse_mulps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse_subps( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse_rsqrtss( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void sse_shufps( struct x86_function *p, struct x86_reg dest, struct x86_reg arg0, GLubyte shuf );
+
+void x86_cmp( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void x86_dec( struct x86_function *p, struct x86_reg reg );
+void x86_inc( struct x86_function *p, struct x86_reg reg );
+void x86_lea( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void x86_mov( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void x86_pop( struct x86_function *p, struct x86_reg reg );
+void x86_push( struct x86_function *p, struct x86_reg reg );
+void x86_ret( struct x86_function *p );
+void x86_test( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void x86_xor( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
+void x86_sahf( struct x86_function *p );
+
+void x87_f2xm1( struct x86_function *p );
+void x87_fabs( struct x86_function *p );
+void x87_fadd( struct x86_function *p, struct x86_reg dst, struct x86_reg arg );
+void x87_faddp( struct x86_function *p, struct x86_reg dst );
+void x87_fchs( struct x86_function *p );
+void x87_fclex( struct x86_function *p );
+void x87_fcom( struct x86_function *p, struct x86_reg dst );
+void x87_fcomp( struct x86_function *p, struct x86_reg dst );
+void x87_fcos( struct x86_function *p );
+void x87_fdiv( struct x86_function *p, struct x86_reg dst, struct x86_reg arg );
+void x87_fdivp( struct x86_function *p, struct x86_reg dst );
+void x87_fdivr( struct x86_function *p, struct x86_reg dst, struct x86_reg arg );
+void x87_fdivrp( struct x86_function *p, struct x86_reg dst );
+void x87_fist( struct x86_function *p, struct x86_reg dst );
+void x87_fistp( struct x86_function *p, struct x86_reg dst );
+void x87_fld( struct x86_function *p, struct x86_reg arg );
+void x87_fld1( struct x86_function *p );
+void x87_fldcw( struct x86_function *p, struct x86_reg arg );
+void x87_fldl2e( struct x86_function *p );
+void x87_fldln2( struct x86_function *p );
+void x87_fldz( struct x86_function *p );
+void x87_fmul( struct x86_function *p, struct x86_reg dst, struct x86_reg arg );
+void x87_fmulp( struct x86_function *p, struct x86_reg dst );
+void x87_fnclex( struct x86_function *p );
+void x87_fprndint( struct x86_function *p );
+void x87_fscale( struct x86_function *p );
+void x87_fsin( struct x86_function *p );
+void x87_fsincos( struct x86_function *p );
+void x87_fsqrt( struct x86_function *p );
+void x87_fst( struct x86_function *p, struct x86_reg dst );
+void x87_fstp( struct x86_function *p, struct x86_reg dst );
+void x87_fsub( struct x86_function *p, struct x86_reg dst, struct x86_reg arg );
+void x87_fsubp( struct x86_function *p, struct x86_reg dst );
+void x87_fsubr( struct x86_function *p, struct x86_reg dst, struct x86_reg arg );
+void x87_fsubrp( struct x86_function *p, struct x86_reg dst );
+void x87_fxch( struct x86_function *p, struct x86_reg dst );
+void x87_fxtract( struct x86_function *p );
+void x87_fyl2x( struct x86_function *p );
+void x87_fyl2xp1( struct x86_function *p );
+void x87_fwait( struct x86_function *p );
+void x87_fnstsw( struct x86_function *p, struct x86_reg dst );
+void x87_fucompp( struct x86_function *p );
+void x87_fucomp( struct x86_function *p, struct x86_reg arg );
+void x87_fucom( struct x86_function *p, struct x86_reg arg );
+
+
+
+/* Retreive a reference to one of the function arguments, taking into
+ * account any push/pop activity. Note - doesn't track explict
+ * manipulation of ESP by other instructions.
+ */
+struct x86_reg x86_fn_arg( struct x86_function *p, GLuint arg );
+
+#endif
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/sse.c b/nx-X11/extras/Mesa/src/mesa/x86/sse.c
new file mode 100644
index 000000000..45852c4e1
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/sse.c
@@ -0,0 +1,123 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.0
+ *
+ * Copyright (C) 1999-2004 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.
+ */
+
+/*
+ * PentiumIII-SIMD (SSE) optimizations contributed by
+ * Andre Werthmann <wertmann@cs.uni-potsdam.de>
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "math/m_xform.h"
+#include "tnl/t_context.h"
+
+#include "sse.h"
+#include "common_x86_macros.h"
+
+#ifdef DEBUG
+#include "math/m_debug.h"
+#endif
+
+
+#ifdef USE_SSE_ASM
+DECLARE_XFORM_GROUP( sse, 2 )
+DECLARE_XFORM_GROUP( sse, 3 )
+
+#if 1
+/* Some functions are not written in SSE-assembly, because the fpu ones are faster */
+extern void _ASMAPI _mesa_sse_transform_normals_no_rot( NORM_ARGS );
+extern void _ASMAPI _mesa_sse_transform_rescale_normals( NORM_ARGS );
+extern void _ASMAPI _mesa_sse_transform_rescale_normals_no_rot( NORM_ARGS );
+
+extern void _ASMAPI _mesa_sse_transform_points4_general( XFORM_ARGS );
+extern void _ASMAPI _mesa_sse_transform_points4_3d( XFORM_ARGS );
+/* XXX this function segfaults, see below */
+extern void _ASMAPI _mesa_sse_transform_points4_identity( XFORM_ARGS );
+/* XXX this one works, see below */
+extern void _ASMAPI _mesa_x86_transform_points4_identity( XFORM_ARGS );
+#else
+DECLARE_NORM_GROUP( sse )
+#endif
+
+
+extern void _ASMAPI
+_mesa_v16_sse_general_xform( GLfloat *first_vert,
+ const GLfloat *m,
+ const GLfloat *src,
+ GLuint src_stride,
+ GLuint count );
+
+extern void _ASMAPI
+_mesa_sse_project_vertices( GLfloat *first,
+ GLfloat *last,
+ const GLfloat *m,
+ GLuint stride );
+
+extern void _ASMAPI
+_mesa_sse_project_clipped_vertices( GLfloat *first,
+ GLfloat *last,
+ const GLfloat *m,
+ GLuint stride,
+ const GLubyte *clipmask );
+#endif
+
+
+void _mesa_init_sse_transform_asm( void )
+{
+#ifdef USE_SSE_ASM
+ ASSIGN_XFORM_GROUP( sse, 2 );
+ ASSIGN_XFORM_GROUP( sse, 3 );
+
+#if 1
+ /* TODO: Finish these off.
+ */
+ _mesa_transform_tab[4][MATRIX_GENERAL] =
+ _mesa_sse_transform_points4_general;
+ _mesa_transform_tab[4][MATRIX_3D] =
+ _mesa_sse_transform_points4_3d;
+ /* XXX NOTE: _mesa_sse_transform_points4_identity segfaults with the
+ conformance tests, so use the x86 version.
+ */
+ _mesa_transform_tab[4][MATRIX_IDENTITY] =
+ _mesa_x86_transform_points4_identity;/*_mesa_sse_transform_points4_identity;*/
+
+ _mesa_normal_tab[NORM_TRANSFORM_NO_ROT] =
+ _mesa_sse_transform_normals_no_rot;
+ _mesa_normal_tab[NORM_TRANSFORM | NORM_RESCALE] =
+ _mesa_sse_transform_rescale_normals;
+ _mesa_normal_tab[NORM_TRANSFORM_NO_ROT | NORM_RESCALE] =
+ _mesa_sse_transform_rescale_normals_no_rot;
+#else
+ ASSIGN_XFORM_GROUP( sse, 4 );
+
+ ASSIGN_NORM_GROUP( sse );
+#endif
+
+#ifdef DEBUG
+ _math_test_all_transform_functions( "SSE" );
+ _math_test_all_normal_transform_functions( "SSE" );
+#endif
+#endif
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/sse.h b/nx-X11/extras/Mesa/src/mesa/x86/sse.h
new file mode 100644
index 000000000..447f192a8
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/sse.h
@@ -0,0 +1,39 @@
+/* $Id: sse.h,v 1.1.1.1 2004/06/16 09:19:36 anholt Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * PentiumIII-SIMD (SSE) optimizations contributed by
+ * Andre Werthmann <wertmann@cs.uni-potsdam.de>
+ */
+
+#ifndef __SSE_H__
+#define __SSE_H__
+
+#include "math/m_xform.h"
+
+void _mesa_init_sse_transform_asm( void );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/sse_normal.S b/nx-X11/extras/Mesa/src/mesa/x86/sse_normal.S
new file mode 100644
index 000000000..5bff8921e
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/sse_normal.S
@@ -0,0 +1,257 @@
+/* $Id: sse_normal.S,v 1.1.1.2 2005/07/31 16:46:39 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/** TODO:
+ * - insert PREFETCH instructions to avoid cache-misses !
+ * - some more optimizations are possible...
+ * - for 40-50% more performance in the SSE-functions, the
+ * data (trans-matrix, src_vert, dst_vert) needs to be 16byte aligned !
+ */
+
+#ifdef USE_SSE_ASM
+#include "matypes.h"
+#include "norm_args.h"
+
+ SEG_TEXT
+
+#define M(i) REGOFF(i * 4, EDX)
+#define S(i) REGOFF(i * 4, ESI)
+#define D(i) REGOFF(i * 4, EDI)
+#define STRIDE REGOFF(12, ESI)
+
+
+ALIGNTEXT16
+GLOBL GLNAME(_mesa_sse_transform_rescale_normals_no_rot)
+HIDDEN(_mesa_sse_transform_rescale_normals_no_rot)
+GLNAME(_mesa_sse_transform_rescale_normals_no_rot):
+
+#define FRAME_OFFSET 8
+ PUSH_L ( ESI )
+ PUSH_L ( EDI )
+
+ MOV_L ( ARG_IN, ESI ) /* ptr to source GLvector3f */
+ MOV_L ( ARG_DEST, EDI ) /* ptr to dest GLvector3f */
+
+ MOV_L ( ARG_MAT, EDX ) /* ptr to matrix */
+ MOV_L ( REGOFF(MATRIX_INV, EDX), EDX) /* matrix->inv */
+
+ MOV_L ( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L ( ECX, ECX )
+ JZ( LLBL(K_G3TRNNRR_finish) ) /* count was zero; go to finish */
+
+ MOV_L ( STRIDE, EAX ) /* stride */
+ MOV_L ( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest-count */
+
+ IMUL_L( CONST(16), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+ALIGNTEXT32
+ MOVSS ( M(0), XMM1 ) /* m0 */
+ MOVSS ( M(5), XMM2 ) /* m5 */
+ UNPCKLPS( XMM2, XMM1 ) /* m5 | m0 */
+ MOVSS ( ARG_SCALE, XMM0 ) /* scale */
+ SHUFPS ( CONST(0x0), XMM0, XMM0 ) /* scale | scale */
+ MULPS ( XMM0, XMM1 ) /* m5*scale | m0*scale */
+ MULSS ( M(10), XMM0 ) /* m10*scale */
+
+ALIGNTEXT32
+LLBL(K_G3TRNNRR_top):
+ MOVLPS ( S(0), XMM2 ) /* uy | ux */
+ MULPS ( XMM1, XMM2 ) /* uy*m5*scale | ux*m0*scale */
+ MOVLPS ( XMM2, D(0) ) /* ->D(1) | D(0) */
+
+ MOVSS ( S(2), XMM2 ) /* uz */
+ MULSS ( XMM0, XMM2 ) /* uz*m10*scale */
+ MOVSS ( XMM2, D(2) ) /* ->D(2) */
+
+LLBL(K_G3TRNNRR_skip):
+ ADD_L ( CONST(16), EDI )
+ ADD_L ( EAX, ESI )
+ CMP_L ( ECX, EDI )
+ JNE ( LLBL(K_G3TRNNRR_top) )
+
+LLBL(K_G3TRNNRR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME(_mesa_sse_transform_rescale_normals)
+HIDDEN(_mesa_sse_transform_rescale_normals)
+GLNAME(_mesa_sse_transform_rescale_normals):
+
+#define FRAME_OFFSET 8
+ PUSH_L ( ESI )
+ PUSH_L ( EDI )
+
+ MOV_L ( ARG_IN, ESI ) /* ptr to source GLvector3f */
+ MOV_L ( ARG_DEST, EDI ) /* ptr to dest GLvector3f */
+
+ MOV_L ( ARG_MAT, EDX ) /* ptr to matrix */
+ MOV_L ( REGOFF(MATRIX_INV, EDX), EDX) /* matrix->inv */
+
+ MOV_L ( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L ( ECX, ECX )
+ JZ( LLBL(K_G3TRNR_finish) ) /* count was zero; go to finish */
+
+ MOV_L ( STRIDE, EAX ) /* stride */
+ MOV_L ( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest-count */
+
+ IMUL_L( CONST(16), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+ALIGNTEXT32
+ MOVSS ( M(0), XMM0 ) /* m0 */
+ MOVSS ( M(4), XMM1 ) /* m4 */
+ UNPCKLPS( XMM1, XMM0 ) /* m4 | m0 */
+
+ MOVSS ( ARG_SCALE, XMM4 ) /* scale */
+ SHUFPS ( CONST(0x0), XMM4, XMM4 ) /* scale | scale */
+
+ MULPS ( XMM4, XMM0 ) /* m4*scale | m0*scale */
+ MOVSS ( M(1), XMM1 ) /* m1 */
+ MOVSS ( M(5), XMM2 ) /* m5 */
+ UNPCKLPS( XMM2, XMM1 ) /* m5 | m1 */
+ MULPS ( XMM4, XMM1 ) /* m5*scale | m1*scale */
+ MOVSS ( M(2), XMM2 ) /* m2 */
+ MOVSS ( M(6), XMM3 ) /* m6 */
+ UNPCKLPS( XMM3, XMM2 ) /* m6 | m2 */
+ MULPS ( XMM4, XMM2 ) /* m6*scale | m2*scale */
+
+ MOVSS ( M(8), XMM6 ) /* m8 */
+ MULSS ( ARG_SCALE, XMM6 ) /* m8*scale */
+ MOVSS ( M(9), XMM7 ) /* m9 */
+ MULSS ( ARG_SCALE, XMM7 ) /* m9*scale */
+
+ALIGNTEXT32
+LLBL(K_G3TRNR_top):
+ MOVSS ( S(0), XMM3 ) /* ux */
+ SHUFPS ( CONST(0x0), XMM3, XMM3 ) /* ux | ux */
+ MULPS ( XMM0, XMM3 ) /* ux*m4 | ux*m0 */
+ MOVSS ( S(1), XMM4 ) /* uy */
+ SHUFPS ( CONST(0x0), XMM4, XMM4 ) /* uy | uy */
+ MULPS ( XMM1, XMM4 ) /* uy*m5 | uy*m1 */
+ MOVSS ( S(2), XMM5 ) /* uz */
+ SHUFPS ( CONST(0x0), XMM5, XMM5 ) /* uz | uz */
+ MULPS ( XMM2, XMM5 ) /* uz*m6 | uz*m2 */
+
+ ADDPS ( XMM4, XMM3 )
+ ADDPS ( XMM5, XMM3 )
+ MOVLPS ( XMM3, D(0) )
+
+ MOVSS ( M(10), XMM3 ) /* m10 */
+ MULSS ( ARG_SCALE, XMM3 ) /* m10*scale */
+ MULSS ( S(2), XMM3 ) /* m10*scale*uz */
+ MOVSS ( S(1), XMM4 ) /* uy */
+ MULSS ( XMM7, XMM4 ) /* uy*m9*scale */
+ MOVSS ( S(0), XMM5 ) /* ux */
+ MULSS ( XMM6, XMM5 ) /* ux*m8*scale */
+
+ ADDSS ( XMM4, XMM3 )
+ ADDSS ( XMM5, XMM3 )
+ MOVSS ( XMM3, D(2) )
+
+LLBL(K_G3TRNR_skip):
+ ADD_L ( CONST(16), EDI )
+ ADD_L ( EAX, ESI )
+ CMP_L ( ECX, EDI )
+ JNE ( LLBL(K_G3TRNR_top) )
+
+LLBL(K_G3TRNR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+ALIGNTEXT16
+GLOBL GLNAME(_mesa_sse_transform_normals_no_rot)
+HIDDEN(_mesa_sse_transform_normals_no_rot)
+GLNAME(_mesa_sse_transform_normals_no_rot):
+
+#define FRAME_OFFSET 8
+ PUSH_L ( ESI )
+ PUSH_L ( EDI )
+
+ MOV_L ( ARG_IN, ESI ) /* ptr to source GLvector3f */
+ MOV_L ( ARG_DEST, EDI ) /* ptr to dest GLvector3f */
+
+ MOV_L ( ARG_MAT, EDX ) /* ptr to matrix */
+ MOV_L ( REGOFF(MATRIX_INV, EDX), EDX) /* matrix->inv */
+
+ MOV_L ( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L ( ECX, ECX )
+ JZ( LLBL(K_G3TNNRR_finish) ) /* count was zero; go to finish */
+
+ MOV_L ( STRIDE, EAX ) /* stride */
+ MOV_L ( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest-count */
+
+ IMUL_L( CONST(16), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+ALIGNTEXT32
+ MOVSS( M(0), XMM0 ) /* m0 */
+ MOVSS( M(5), XMM1 ) /* m5 */
+ UNPCKLPS( XMM1, XMM0 ) /* m5 | m0 */
+ MOVSS( M(10), XMM1 ) /* m10 */
+
+ALIGNTEXT32
+LLBL(K_G3TNNRR_top):
+ MOVLPS( S(0), XMM2 ) /* uy | ux */
+ MULPS( XMM0, XMM2 ) /* uy*m5 | ux*m0 */
+ MOVLPS( XMM2, D(0) )
+
+ MOVSS( S(2), XMM2 ) /* uz */
+ MULSS( XMM1, XMM2 ) /* uz*m10 */
+ MOVSS( XMM2, D(2) )
+
+LLBL(K_G3TNNRR_skip):
+ ADD_L ( CONST(16), EDI )
+ ADD_L ( EAX, ESI )
+ CMP_L ( ECX, EDI )
+ JNE ( LLBL(K_G3TNNRR_top) )
+
+LLBL(K_G3TNNRR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/sse_xform1.S b/nx-X11/extras/Mesa/src/mesa/x86/sse_xform1.S
new file mode 100644
index 000000000..17a61b410
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/sse_xform1.S
@@ -0,0 +1,442 @@
+/* $Id: sse_xform1.S,v 1.1.1.2 2005/07/31 16:46:39 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/** TODO:
+ * - insert PREFETCH instructions to avoid cache-misses !
+ * - some more optimizations are possible...
+ * - for 40-50% more performance in the SSE-functions, the
+ * data (trans-matrix, src_vert, dst_vert) needs to be 16byte aligned !
+ */
+
+#ifdef USE_SSE_ASM
+#include "matypes.h"
+#include "xform_args.h"
+
+ SEG_TEXT
+
+#define S(i) REGOFF(i * 4, ESI)
+#define D(i) REGOFF(i * 4, EDI)
+#define M(i) REGOFF(i * 4, EDX)
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points1_general)
+HIDDEN( _mesa_sse_transform_points1_general )
+GLNAME( _mesa_sse_transform_points1_general ):
+
+#define FRAME_OFFSET 8
+ PUSH_L ( ESI )
+ PUSH_L ( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ CMP_L( CONST(0), ECX ) /* count == 0 ? */
+ JE( LLBL(K_GTP1GR_finish) ) /* yes -> nothing to do. */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+
+ALIGNTEXT32
+ MOVAPS( M(0), XMM0 ) /* m3 | m2 | m1 | m0 */
+ MOVAPS( M(12), XMM1 ) /* m15 | m14 | m13 | m12 */
+
+ALIGNTEXT32
+LLBL(K_GTP1GR_top):
+ MOVSS( S(0), XMM2 ) /* ox */
+ SHUFPS( CONST(0x0), XMM2, XMM2 ) /* ox | ox | ox | ox */
+ MULPS( XMM0, XMM2 ) /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */
+ ADDPS( XMM1, XMM2 ) /* + | + | + | + */
+ MOVUPS( XMM2, D(0) )
+
+LLBL(K_GTP1GR_skip):
+ ADD_L ( CONST(16), EDI )
+ ADD_L ( EAX, ESI )
+ CMP_L ( ECX, EDI )
+ JNE ( LLBL(K_GTP1GR_top) )
+
+LLBL(K_GTP1GR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points1_identity)
+HIDDEN(_mesa_sse_transform_points1_identity)
+GLNAME( _mesa_sse_transform_points1_identity ):
+
+#define FRAME_OFFSET 8
+ PUSH_L ( ESI )
+ PUSH_L ( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP1IR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_1), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(1), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+ CMP_L( ESI, EDI )
+ JE( LLBL(K_GTP1IR_finish) )
+
+
+ALIGNTEXT32
+LLBL(K_GTP1IR_top):
+ MOV_L( S(0), EDX )
+ MOV_L( EDX, D(0) )
+
+LLBL(K_GTP1IR_skip):
+ ADD_L ( CONST(16), EDI )
+ ADD_L ( EAX, ESI )
+ CMP_L ( ECX, EDI )
+ JNE ( LLBL(K_GTP1IR_top) )
+
+LLBL(K_GTP1IR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points1_3d_no_rot)
+HIDDEN(_mesa_sse_transform_points1_3d_no_rot)
+GLNAME(_mesa_sse_transform_points1_3d_no_rot):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP13DNRR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+
+ALIGNTEXT32
+ MOVSS( M(0), XMM0 ) /* m0 */
+ MOVSS( M(12), XMM1 ) /* m12 */
+ MOVSS( M(13), XMM2 ) /* m13 */
+ MOVSS( M(14), XMM3 ) /* m14 */
+
+ALIGNTEXT32
+LLBL(K_GTP13DNRR_top):
+ MOVSS( S(0), XMM4 ) /* ox */
+ MULSS( XMM0, XMM4 ) /* ox*m0 */
+ ADDSS( XMM1, XMM4 ) /* ox*m0+m12 */
+ MOVSS( XMM4, D(0) )
+
+ MOVSS( XMM2, D(1) )
+ MOVSS( XMM3, D(2) )
+
+LLBL(K_GTP13DNRR_skip):
+ ADD_L ( CONST(16), EDI )
+ ADD_L ( EAX, ESI )
+ CMP_L ( ECX, EDI )
+ JNE ( LLBL(K_GTP13DNRR_top) )
+
+LLBL(K_GTP13DNRR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points1_perspective)
+HIDDEN(_mesa_sse_transform_points1_perspective)
+GLNAME(_mesa_sse_transform_points1_perspective):
+
+#define FRAME_OFFSET 8
+ PUSH_L ( ESI )
+ PUSH_L ( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP13PR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+
+ALIGNTEXT32
+ XORPS( XMM0, XMM0 ) /* 0 | 0 | 0 | 0 */
+ MOVSS( M(0), XMM1 ) /* m0 */
+ MOVSS( M(14), XMM2 ) /* m14 */
+
+ALIGNTEXT32
+LLBL(K_GTP13PR_top):
+ MOVSS( S(0), XMM3 ) /* ox */
+ MULSS( XMM1, XMM3 ) /* ox*m0 */
+ MOVSS( XMM3, D(0) ) /* ox*m0->D(0) */
+ MOVSS( XMM2, D(2) ) /* m14->D(2) */
+
+ MOVSS( XMM0, D(1) )
+ MOVSS( XMM0, D(3) )
+
+LLBL(K_GTP13PR_skip):
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(K_GTP13PR_top) )
+
+LLBL(K_GTP13PR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points1_2d)
+HIDDEN(_mesa_sse_transform_points1_2d)
+GLNAME(_mesa_sse_transform_points1_2d):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP13P2DR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+ALIGNTEXT32
+ MOVLPS( M(0), XMM0 ) /* m1 | m0 */
+ MOVLPS( M(12), XMM1 ) /* m13 | m12 */
+
+ALIGNTEXT32
+LLBL(K_GTP13P2DR_top):
+ MOVSS( S(0), XMM2 ) /* ox */
+ SHUFPS( CONST(0x0), XMM2, XMM2 ) /* ox | ox | ox | ox */
+ MULPS( XMM0, XMM2 ) /* - | - | ox*m1 | ox*m0 */
+ ADDPS( XMM1, XMM2 ) /* - | - | ox*m1+m13 | ox*m0+m12 */
+ MOVLPS( XMM2, D(0) )
+
+LLBL(K_GTP13P2DR_skip):
+ ADD_L ( CONST(16), EDI )
+ ADD_L ( EAX, ESI )
+ CMP_L ( ECX, EDI )
+ JNE ( LLBL(K_GTP13P2DR_top) )
+
+LLBL(K_GTP13P2DR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points1_2d_no_rot)
+HIDDEN(_mesa_sse_transform_points1_2d_no_rot)
+GLNAME(_mesa_sse_transform_points1_2d_no_rot):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP13P2DNRR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+ALIGNTEXT32
+ MOVSS( M(0), XMM0 ) /* m0 */
+ MOVSS( M(12), XMM1 ) /* m12 */
+ MOVSS( M(13), XMM2 ) /* m13 */
+
+ALIGNTEXT32
+LLBL(K_GTP13P2DNRR_top):
+ MOVSS( S(0), XMM3 ) /* ox */
+ MULSS( XMM0, XMM3 ) /* ox*m0 */
+ ADDSS( XMM1, XMM3 ) /* ox*m0+m12 */
+ MOVSS( XMM3, D(0) )
+ MOVSS( XMM2, D(1) )
+
+LLBL(K_GTP13P2DNRR_skip):
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(K_GTP13P2DNRR_top) )
+
+LLBL(K_GTP13P2DNRR_finish):
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points1_3d)
+HIDDEN(_mesa_sse_transform_points1_3d)
+GLNAME(_mesa_sse_transform_points1_3d):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP13P3DR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+
+ALIGNTEXT32
+ MOVAPS( M(0), XMM0 ) /* m3 | m2 | m1 | m0 */
+ MOVAPS( M(12), XMM1 ) /* m15 | m14 | m13 | m12 */
+
+ALIGNTEXT32
+LLBL(K_GTP13P3DR_top):
+ MOVSS( S(0), XMM2 ) /* ox */
+ SHUFPS( CONST(0x0), XMM2, XMM2 ) /* ox | ox | ox | ox */
+ MULPS( XMM0, XMM2 ) /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */
+ ADDPS( XMM1, XMM2 ) /* +m15 | +m14 | +m13 | +m12 */
+ MOVLPS( XMM2, D(0) ) /* - | - | ->D(1)| ->D(0)*/
+ UNPCKHPS( XMM2, XMM2 ) /* ox*m3+m15 | ox*m3+m15 | ox*m2+m14 | ox*m2+m14 */
+ MOVSS( XMM2, D(2) )
+
+LLBL(K_GTP13P3DR_skip):
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(K_GTP13P3DR_top) )
+
+LLBL(K_GTP13P3DR_finish):
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/sse_xform2.S b/nx-X11/extras/Mesa/src/mesa/x86/sse_xform2.S
new file mode 100644
index 000000000..97c7e5d77
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/sse_xform2.S
@@ -0,0 +1,461 @@
+/* $Id: sse_xform2.S,v 1.1.1.2 2005/07/31 16:46:40 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/** TODO:
+ * - insert PREFETCH instructions to avoid cache-misses !
+ * - some more optimizations are possible...
+ * - for 40-50% more performance in the SSE-functions, the
+ * data (trans-matrix, src_vert, dst_vert) needs to be 16byte aligned !
+ */
+
+#ifdef USE_SSE_ASM
+#include "matypes.h"
+#include "xform_args.h"
+
+ SEG_TEXT
+
+#define S(i) REGOFF(i * 4, ESI)
+#define D(i) REGOFF(i * 4, EDI)
+#define M(i) REGOFF(i * 4, EDX)
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points2_general)
+HIDDEN (_mesa_sse_transform_points2_general)
+GLNAME( _mesa_sse_transform_points2_general ):
+
+#define FRAME_OFFSET 8
+ PUSH_L ( ESI )
+ PUSH_L ( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(K_GTP2GR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+ALIGNTEXT32
+ MOVAPS( M(0), XMM0 ) /* m3 | m2 | m1 | m0 */
+ MOVAPS( M(4), XMM1 ) /* m7 | m6 | m5 | m4 */
+ MOVAPS( M(12), XMM2 ) /* m15 | m14 | m13 | m12 */
+
+ALIGNTEXT32
+LLBL(K_GTP2GR_top):
+ MOVSS( S(0), XMM3 ) /* ox */
+ SHUFPS( CONST(0x0), XMM3, XMM3 ) /* ox | ox | ox | ox */
+ MULPS( XMM0, XMM3 ) /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */
+ MOVSS( S(1), XMM4 ) /* oy */
+ SHUFPS( CONST(0x0), XMM4, XMM4 ) /* oy | oy | oy | oy */
+ MULPS( XMM1, XMM4 ) /* oy*m7 | oy*m6 | oy*m5 | oy*m4 */
+
+ ADDPS( XMM4, XMM3 )
+ ADDPS( XMM2, XMM3 )
+ MOVAPS( XMM3, D(0) )
+
+LLBL(K_GTP2GR_skip):
+ ADD_L ( CONST(16), EDI )
+ ADD_L ( EAX, ESI )
+ CMP_L ( ECX, EDI )
+ JNE ( LLBL(K_GTP2GR_top) )
+
+LLBL(K_GTP2GR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points2_identity)
+HIDDEN(_mesa_sse_transform_points2_identity)
+GLNAME( _mesa_sse_transform_points2_identity ):
+
+#define FRAME_OFFSET 8
+ PUSH_L ( ESI )
+ PUSH_L ( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP2IR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+ CMP_L( ESI, EDI )
+ JE( LLBL(K_GTP2IR_finish) )
+
+
+ALIGNTEXT32
+LLBL(K_GTP2IR_top):
+ MOV_L ( S(0), EDX )
+ MOV_L ( EDX, D(0) )
+ MOV_L ( S(1), EDX )
+ MOV_L ( EDX, D(1) )
+
+LLBL(K_GTP2IR_skip):
+ ADD_L ( CONST(16), EDI )
+ ADD_L ( EAX, ESI )
+ CMP_L ( ECX, EDI )
+ JNE ( LLBL(K_GTP2IR_top) )
+
+LLBL(K_GTP2IR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points2_3d_no_rot)
+HIDDEN(_mesa_sse_transform_points2_3d_no_rot)
+GLNAME(_mesa_sse_transform_points2_3d_no_rot):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP23DNRR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+
+ALIGNTEXT32
+ MOVSS ( M(0), XMM1 ) /* - | - | - | m0 */
+ MOVSS ( M(5), XMM2 ) /* - | - | - | m5 */
+ UNPCKLPS ( XMM2, XMM1 ) /* - | - | m5 | m0 */
+ MOVLPS ( M(12), XMM2 ) /* - | - | m13 | m12 */
+ MOVSS ( M(14), XMM3 ) /* - | - | - | m14 */
+
+ALIGNTEXT32
+LLBL(K_GTP23DNRR_top):
+ MOVLPS ( S(0), XMM0 ) /* - | - | oy | ox */
+ MULPS ( XMM1, XMM0 ) /* - | - | oy*m5 | ox*m0 */
+ ADDPS ( XMM2, XMM0 ) /* - | - | +m13 | +m12 */
+ MOVLPS ( XMM0, D(0) ) /* -> D(1) | -> D(0) */
+
+ MOVSS ( XMM3, D(2) ) /* -> D(2) */
+
+LLBL(K_GTP23DNRR_skip):
+ ADD_L ( CONST(16), EDI )
+ ADD_L ( EAX, ESI )
+ CMP_L ( ECX, EDI )
+ JNE ( LLBL(K_GTP23DNRR_top) )
+
+LLBL(K_GTP23DNRR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points2_perspective)
+HIDDEN(_mesa_sse_transform_points2_perspective)
+GLNAME(_mesa_sse_transform_points2_perspective):
+
+#define FRAME_OFFSET 8
+ PUSH_L ( ESI )
+ PUSH_L ( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP23PR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+ALIGNTEXT32
+ MOVSS ( M(0), XMM1 ) /* - | - | - | m0 */
+ MOVSS ( M(5), XMM2 ) /* - | - | - | m5 */
+ UNPCKLPS ( XMM2, XMM1 ) /* - | - | m5 | m0 */
+ MOVSS ( M(14), XMM3 ) /* m14 */
+ XORPS ( XMM0, XMM0 ) /* 0 | 0 | 0 | 0 */
+
+ALIGNTEXT32
+LLBL(K_GTP23PR_top):
+ MOVLPS( S(0), XMM4 ) /* oy | ox */
+ MULPS( XMM1, XMM4 ) /* oy*m5 | ox*m0 */
+ MOVLPS( XMM4, D(0) ) /* ->D(1) | ->D(0) */
+ MOVSS( XMM3, D(2) ) /* ->D(2) */
+ MOVSS( XMM0, D(3) ) /* ->D(3) */
+
+LLBL(K_GTP23PR_skip):
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(K_GTP23PR_top) )
+
+LLBL(K_GTP23PR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points2_2d)
+HIDDEN(_mesa_sse_transform_points2_2d)
+GLNAME(_mesa_sse_transform_points2_2d):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP23P2DR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+ALIGNTEXT32
+ MOVLPS( M(0), XMM0 ) /* m1 | m0 */
+ MOVLPS( M(4), XMM1 ) /* m5 | m4 */
+ MOVLPS( M(12), XMM2 ) /* m13 | m12 */
+
+ALIGNTEXT32
+LLBL(K_GTP23P2DR_top):
+ MOVSS( S(0), XMM3 ) /* ox */
+ SHUFPS( CONST(0x0), XMM3, XMM3 ) /* ox | ox */
+ MULPS( XMM0, XMM3 ) /* ox*m1 | ox*m0 */
+
+ MOVSS( S(1), XMM4 ) /* oy */
+ SHUFPS( CONST(0x0), XMM4, XMM4 ) /* oy | oy */
+ MULPS( XMM1, XMM4 ) /* oy*m5 | oy*m4 */
+
+ ADDPS( XMM4, XMM3 )
+ ADDPS( XMM2, XMM3 )
+ MOVLPS( XMM3, D(0) ) /* ->D(1) | ->D(0) */
+
+LLBL(K_GTP23P2DR_skip):
+ ADD_L ( CONST(16), EDI )
+ ADD_L ( EAX, ESI )
+ CMP_L ( ECX, EDI )
+ JNE ( LLBL(K_GTP23P2DR_top) )
+
+LLBL(K_GTP23P2DR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points2_2d_no_rot)
+HIDDEN(_mesa_sse_transform_points2_2d_no_rot)
+GLNAME(_mesa_sse_transform_points2_2d_no_rot):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP23P2DNRR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+ALIGNTEXT32
+ MOVSS ( M(0), XMM1 ) /* m0 */
+ MOVSS ( M(5), XMM2 ) /* m5 */
+ UNPCKLPS ( XMM2, XMM1 ) /* m5 | m0 */
+ MOVLPS ( M(12), XMM2 ) /* m13 | m12 */
+
+ALIGNTEXT32
+LLBL(K_GTP23P2DNRR_top):
+ MOVLPS( S(0), XMM0 ) /* oy | ox */
+ MULPS( XMM1, XMM0 ) /* oy*m5 | ox*m0 */
+ ADDPS( XMM2, XMM0 ) /* +m13 | +m12 */
+ MOVLPS( XMM0, D(0) ) /* ->D(1) | ->D(0) */
+
+LLBL(K_GTP23P2DNRR_skip):
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(K_GTP23P2DNRR_top) )
+
+LLBL(K_GTP23P2DNRR_finish):
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points2_3d)
+HIDDEN(_mesa_sse_transform_points2_3d)
+GLNAME(_mesa_sse_transform_points2_3d):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP23P3DR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+ALIGNTEXT32
+ MOVAPS( M(0), XMM0 ) /* m2 | m1 | m0 */
+ MOVAPS( M(4), XMM1 ) /* m6 | m5 | m4 */
+ MOVAPS( M(12), XMM2 ) /* m14 | m13 | m12 */
+
+ALIGNTEXT32
+LLBL(K_GTP23P3DR_top):
+ MOVSS( S(0), XMM3 ) /* ox */
+ SHUFPS( CONST(0x0), XMM3, XMM3 ) /* ox | ox | ox */
+ MULPS( XMM0, XMM3 ) /* ox*m2 | ox*m1 | ox*m0 */
+
+ MOVSS( S(1), XMM4 ) /* oy */
+ SHUFPS( CONST(0x0), XMM4, XMM4 ) /* oy | oy | oy */
+ MULPS( XMM1, XMM4 ) /* oy*m6 | oy*m5 | oy*m4 */
+
+ ADDPS( XMM4, XMM3 )
+ ADDPS( XMM2, XMM3 )
+
+ MOVLPS( XMM3, D(0) ) /* ->D(1) | ->D(0) */
+ UNPCKHPS( XMM3, XMM3 )
+ MOVSS( XMM3, D(2) ) /* ->D(2) */
+
+LLBL(K_GTP23P3DR_skip):
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(K_GTP23P3DR_top) )
+
+LLBL(K_GTP23P3DR_finish):
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/sse_xform3.S b/nx-X11/extras/Mesa/src/mesa/x86/sse_xform3.S
new file mode 100644
index 000000000..0449d6858
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/sse_xform3.S
@@ -0,0 +1,507 @@
+/* $Id: sse_xform3.S,v 1.1.1.2 2005/07/31 16:46:39 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/** TODO:
+ * - insert PREFETCH instructions to avoid cache-misses !
+ * - some more optimizations are possible...
+ * - for 40-50% more performance in the SSE-functions, the
+ * data (trans-matrix, src_vert, dst_vert) needs to be 16byte aligned !
+ */
+
+#ifdef USE_SSE_ASM
+#include "matypes.h"
+#include "xform_args.h"
+
+ SEG_TEXT
+
+#define S(i) REGOFF(i * 4, ESI)
+#define D(i) REGOFF(i * 4, EDI)
+#define M(i) REGOFF(i * 4, EDX)
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points3_general)
+HIDDEN(_mesa_sse_transform_points3_general)
+GLNAME( _mesa_sse_transform_points3_general ):
+
+#define FRAME_OFFSET 8
+ PUSH_L ( ESI )
+ PUSH_L ( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ CMP_L ( CONST(0), ECX ) /* count == 0 ? */
+ JE ( LLBL(K_GTPGR_finish) ) /* yes -> nothing to do. */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+
+ALIGNTEXT32
+ MOVAPS ( REGOFF(0, EDX), XMM0 ) /* m0 | m1 | m2 | m3 */
+ MOVAPS ( REGOFF(16, EDX), XMM1 ) /* m4 | m5 | m6 | m7 */
+ MOVAPS ( REGOFF(32, EDX), XMM2 ) /* m8 | m9 | m10 | m11 */
+ MOVAPS ( REGOFF(48, EDX), XMM3 ) /* m12 | m13 | m14 | m15 */
+
+
+ALIGNTEXT32
+LLBL(K_GTPGR_top):
+ MOVSS ( REGOFF(0, ESI), XMM4 ) /* | | | ox */
+ SHUFPS ( CONST(0x0), XMM4, XMM4 ) /* ox | ox | ox | ox */
+ MOVSS ( REGOFF(4, ESI), XMM5 ) /* | | | oy */
+ SHUFPS ( CONST(0x0), XMM5, XMM5 ) /* oy | oy | oy | oy */
+ MOVSS ( REGOFF(8, ESI), XMM6 ) /* | | | oz */
+ SHUFPS ( CONST(0x0), XMM6, XMM6 ) /* oz | oz | oz | oz */
+
+ MULPS ( XMM0, XMM4 ) /* m3*ox | m2*ox | m1*ox | m0*ox */
+ MULPS ( XMM1, XMM5 ) /* m7*oy | m6*oy | m5*oy | m4*oy */
+ MULPS ( XMM2, XMM6 ) /* m11*oz | m10*oz | m9*oz | m8*oz */
+
+ ADDPS ( XMM5, XMM4 )
+ ADDPS ( XMM6, XMM4 )
+ ADDPS ( XMM3, XMM4 )
+
+ MOVAPS ( XMM4, REGOFF(0, EDI) )
+
+LLBL(K_GTPGR_skip):
+ ADD_L ( CONST(16), EDI )
+ ADD_L ( EAX, ESI )
+ CMP_L ( ECX, EDI )
+ JNE ( LLBL(K_GTPGR_top) )
+
+LLBL(K_GTPGR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points3_identity)
+HIDDEN(_mesa_sse_transform_points3_identity)
+GLNAME( _mesa_sse_transform_points3_identity ):
+
+#define FRAME_OFFSET 8
+ PUSH_L ( ESI )
+ PUSH_L ( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTPIR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+ CMP_L( ESI, EDI )
+ JE( LLBL(K_GTPIR_finish) )
+
+
+ALIGNTEXT32
+LLBL(K_GTPIR_top):
+ MOVLPS ( S(0), XMM0 )
+ MOVLPS ( XMM0, D(0) )
+ MOVSS ( S(2), XMM0 )
+ MOVSS ( XMM0, D(2) )
+
+LLBL(K_GTPIR_skip):
+ ADD_L ( CONST(16), EDI )
+ ADD_L ( EAX, ESI )
+ CMP_L ( ECX, EDI )
+ JNE ( LLBL(K_GTPIR_top) )
+
+LLBL(K_GTPIR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points3_3d_no_rot)
+HIDDEN(_mesa_sse_transform_points3_3d_no_rot)
+GLNAME(_mesa_sse_transform_points3_3d_no_rot):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP3DNRR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+
+ALIGNTEXT32
+ MOVSS ( M(0), XMM1 ) /* - | - | - | m0 */
+ MOVSS ( M(5), XMM2 ) /* - | - | - | m5 */
+ UNPCKLPS ( XMM2, XMM1 ) /* - | - | m5 | m0 */
+ MOVLPS ( M(12), XMM2 ) /* - | - | m13 | m12 */
+ MOVSS ( M(10), XMM3 ) /* - | - | - | m10 */
+ MOVSS ( M(14), XMM4 ) /* - | - | - | m14 */
+
+ALIGNTEXT32
+LLBL(K_GTP3DNRR_top):
+
+ MOVLPS ( S(0), XMM0 ) /* - | - | s1 | s0 */
+ MULPS ( XMM1, XMM0 ) /* - | - | s1*m5 | s0*m0 */
+ ADDPS ( XMM2, XMM0 ) /* - | - | +m13 | +m12 */
+ MOVLPS ( XMM0, D(0) ) /* -> D(1) | -> D(0) */
+
+ MOVSS ( S(2), XMM0 ) /* sz */
+ MULSS ( XMM3, XMM0 ) /* sz*m10 */
+ ADDSS ( XMM4, XMM0 ) /* +m14 */
+ MOVSS ( XMM0, D(2) ) /* -> D(2) */
+
+LLBL(K_GTP3DNRR_skip):
+ ADD_L ( CONST(16), EDI )
+ ADD_L ( EAX, ESI )
+ CMP_L ( ECX, EDI )
+ JNE ( LLBL(K_GTP3DNRR_top) )
+
+LLBL(K_GTP3DNRR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points3_perspective)
+HIDDEN(_mesa_sse_transform_points3_perspective)
+GLNAME(_mesa_sse_transform_points3_perspective):
+
+#define FRAME_OFFSET 8
+ PUSH_L ( ESI )
+ PUSH_L ( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP3PR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+ALIGNTEXT32
+ MOVSS ( M(0), XMM1 ) /* - | - | - | m0 */
+ MOVSS ( M(5), XMM2 ) /* - | - | - | m5 */
+ UNPCKLPS ( XMM2, XMM1 ) /* - | - | m5 | m0 */
+ MOVLPS ( M(8), XMM2 ) /* - | - | m9 | m8 */
+ MOVSS ( M(10), XMM3 ) /* m10 */
+ MOVSS ( M(14), XMM4 ) /* m14 */
+ XORPS ( XMM6, XMM6 ) /* 0 */
+
+ALIGNTEXT32
+LLBL(K_GTP3PR_top):
+ MOVLPS ( S(0), XMM0 ) /* oy | ox */
+ MULPS ( XMM1, XMM0 ) /* oy*m5 | ox*m0 */
+ MOVSS ( S(2), XMM5 ) /* oz */
+ SHUFPS ( CONST(0x0), XMM5, XMM5 ) /* oz | oz */
+ MULPS ( XMM2, XMM5 ) /* oz*m9 | oz*m8 */
+ ADDPS ( XMM5, XMM0 ) /* +oy*m5 | +ox*m0 */
+ MOVLPS ( XMM0, D(0) ) /* ->D(1) | ->D(0) */
+
+ MOVSS ( S(2), XMM0 ) /* oz */
+ MULSS ( XMM3, XMM0 ) /* oz*m10 */
+ ADDSS ( XMM4, XMM0 ) /* +m14 */
+ MOVSS ( XMM0, D(2) ) /* ->D(2) */
+
+ MOVSS ( S(2), XMM0 ) /* oz */
+ MOVSS ( XMM6, XMM5 ) /* 0 */
+ SUBPS ( XMM0, XMM5 ) /* -oz */
+ MOVSS ( XMM5, D(3) ) /* ->D(3) */
+
+LLBL(K_GTP3PR_skip):
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(K_GTP3PR_top) )
+
+LLBL(K_GTP3PR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points3_2d)
+HIDDEN(_mesa_sse_transform_points3_2d)
+GLNAME(_mesa_sse_transform_points3_2d):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP3P2DR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+ALIGNTEXT32
+ MOVLPS( M(0), XMM0 ) /* m1 | m0 */
+ MOVLPS( M(4), XMM1 ) /* m5 | m4 */
+ MOVLPS( M(12), XMM2 ) /* m13 | m12 */
+
+ALIGNTEXT32
+LLBL(K_GTP3P2DR_top):
+ MOVSS ( S(0), XMM3 ) /* ox */
+ SHUFPS ( CONST(0x0), XMM3, XMM3 ) /* ox | ox */
+ MULPS ( XMM0, XMM3 ) /* ox*m1 | ox*m0 */
+ MOVSS ( S(1), XMM4 ) /* oy */
+ SHUFPS ( CONST(0x0), XMM4, XMM4 ) /* oy | oy */
+ MULPS ( XMM1, XMM4 ) /* oy*m5 | oy*m4 */
+
+ ADDPS ( XMM4, XMM3 )
+ ADDPS ( XMM2, XMM3 )
+ MOVLPS ( XMM3, D(0) )
+
+ MOVSS ( S(2), XMM3 )
+ MOVSS ( XMM3, D(2) )
+
+LLBL(K_GTP3P2DR_skip):
+ ADD_L ( CONST(16), EDI )
+ ADD_L ( EAX, ESI )
+ CMP_L ( ECX, EDI )
+ JNE ( LLBL(K_GTP3P2DR_top) )
+
+LLBL(K_GTP3P2DR_finish):
+ POP_L ( EDI )
+ POP_L ( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points3_2d_no_rot)
+HIDDEN(_mesa_sse_transform_points3_2d_no_rot)
+GLNAME(_mesa_sse_transform_points3_2d_no_rot):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP3P2DNRR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+ALIGNTEXT32
+ MOVSS ( M(0), XMM1 ) /* m0 */
+ MOVSS ( M(5), XMM2 ) /* m5 */
+ UNPCKLPS ( XMM2, XMM1 ) /* m5 | m0 */
+ MOVLPS ( M(12), XMM2 ) /* m13 | m12 */
+
+ALIGNTEXT32
+LLBL(K_GTP3P2DNRR_top):
+ MOVLPS( S(0), XMM0 ) /* oy | ox */
+ MULPS( XMM1, XMM0 ) /* oy*m5 | ox*m0 */
+ ADDPS( XMM2, XMM0 ) /* +m13 | +m12 */
+ MOVLPS( XMM0, D(0) ) /* ->D(1) | ->D(0) */
+
+ MOVSS( S(2), XMM0 )
+ MOVSS( XMM0, D(2) )
+
+LLBL(K_GTP3P2DNRR_skip):
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(K_GTP3P2DNRR_top) )
+
+LLBL(K_GTP3P2DNRR_finish):
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT4
+GLOBL GLNAME(_mesa_sse_transform_points3_3d)
+HIDDEN(_mesa_sse_transform_points3_3d)
+GLNAME(_mesa_sse_transform_points3_3d):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( REGOFF(OFFSET_SOURCE+8, ESP), ESI ) /* ptr to source GLvector4f */
+ MOV_L( REGOFF(OFFSET_DEST+8, ESP), EDI ) /* ptr to dest GLvector4f */
+
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP3P3DR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) ) /* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+
+ALIGNTEXT32
+ MOVAPS( M(0), XMM0 ) /* m2 | m1 | m0 */
+ MOVAPS( M(4), XMM1 ) /* m6 | m5 | m4 */
+ MOVAPS( M(8), XMM2 ) /* m10 | m9 | m8 */
+ MOVAPS( M(12), XMM3 ) /* m14 | m13 | m12 */
+
+ALIGNTEXT32
+LLBL(K_GTP3P3DR_top):
+ MOVSS( S(0), XMM4 )
+ SHUFPS( CONST(0x0), XMM4, XMM4 ) /* ox | ox | ox */
+ MULPS( XMM0, XMM4 ) /* ox*m2 | ox*m1 | ox*m0 */
+
+ MOVSS( S(1), XMM5 )
+ SHUFPS( CONST(0x0), XMM5, XMM5 ) /* oy | oy | oy */
+ MULPS( XMM1, XMM5 ) /* oy*m6 | oy*m5 | oy*m4 */
+
+ MOVSS( S(2), XMM6 )
+ SHUFPS( CONST(0x0), XMM6, XMM6 ) /* oz | oz | oz */
+ MULPS( XMM2, XMM6 ) /* oz*m10 | oz*m9 | oz*m8 */
+
+ ADDPS( XMM5, XMM4 ) /* + | + | + */
+ ADDPS( XMM6, XMM4 ) /* + | + | + */
+ ADDPS( XMM3, XMM4 ) /* + | + | + */
+
+ MOVLPS( XMM4, D(0) ) /* => D(1) | => D(0) */
+ UNPCKHPS( XMM4, XMM4 )
+ MOVSS( XMM4, D(2) )
+
+LLBL(K_GTP3P3DR_skip):
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(K_GTP3P3DR_top) )
+
+LLBL(K_GTP3P3DR_finish):
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/sse_xform4.S b/nx-X11/extras/Mesa/src/mesa/x86/sse_xform4.S
new file mode 100644
index 000000000..2ac644ac7
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/sse_xform4.S
@@ -0,0 +1,231 @@
+/* $Id: sse_xform4.S,v 1.1.1.2 2005/07/31 16:46:39 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+#ifdef USE_SSE_ASM
+#include "matypes.h"
+#include "xform_args.h"
+
+ SEG_TEXT
+
+#define FRAME_OFFSET 8
+
+#define SRC(i) REGOFF(i * 4, ESI)
+#define DST(i) REGOFF(i * 4, EDI)
+#define MAT(i) REGOFF(i * 4, EDX)
+
+#define SELECT(r0, r1, r2, r3) CONST( r0 * 64 + r1 * 16 + r2 * 4 + r3 )
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_sse_transform_points4_general )
+HIDDEN(_mesa_sse_transform_points4_general)
+GLNAME( _mesa_sse_transform_points4_general ):
+
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX ) /* verify non-zero count */
+ JE( LLBL( sse_general_done ) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )/* set dest size */
+
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+
+ PREFETCHT0( REGIND(ESI) )
+
+ MOVAPS( MAT(0), XMM4 ) /* m3 | m2 | m1 | m0 */
+ MOVAPS( MAT(4), XMM5 ) /* m7 | m6 | m5 | m4 */
+ MOVAPS( MAT(8), XMM6 ) /* m11 | m10 | m9 | m8 */
+ MOVAPS( MAT(12), XMM7 ) /* m15 | m14 | m13 | m12 */
+
+ALIGNTEXT16
+LLBL( sse_general_loop ):
+
+ MOVSS( SRC(0), XMM0 ) /* ox */
+ SHUFPS( CONST(0x0), XMM0, XMM0 ) /* ox | ox | ox | ox */
+ MULPS( XMM4, XMM0 ) /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */
+
+ MOVSS( SRC(1), XMM1 ) /* oy */
+ SHUFPS( CONST(0x0), XMM1, XMM1 ) /* oy | oy | oy | oy */
+ MULPS( XMM5, XMM1 ) /* oy*m7 | oy*m6 | oy*m5 | oy*m4 */
+
+ MOVSS( SRC(2), XMM2 ) /* oz */
+ SHUFPS( CONST(0x0), XMM2, XMM2 ) /* oz | oz | oz | oz */
+ MULPS( XMM6, XMM2 ) /* oz*m11 | oz*m10 | oz*m9 | oz*m8 */
+
+ MOVSS( SRC(3), XMM3 ) /* ow */
+ SHUFPS( CONST(0x0), XMM3, XMM3 ) /* ow | ow | ow | ow */
+ MULPS( XMM7, XMM3 ) /* ow*m15 | ow*m14 | ow*m13 | ow*m12 */
+
+ ADDPS( XMM1, XMM0 ) /* ox*m3+oy*m7 | ... */
+ ADDPS( XMM2, XMM0 ) /* ox*m3+oy*m7+oz*m11 | ... */
+ ADDPS( XMM3, XMM0 ) /* ox*m3+oy*m7+oz*m11+ow*m15 | ... */
+ MOVAPS( XMM0, DST(0) ) /* ->D(3) | ->D(2) | ->D(1) | ->D(0) */
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+
+ DEC_L( ECX )
+ JNZ( LLBL( sse_general_loop ) )
+
+LLBL( sse_general_done ):
+
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+
+
+
+
+ALIGNTEXT4
+GLOBL GLNAME( _mesa_sse_transform_points4_3d )
+HIDDEN(_mesa_sse_transform_points4_3d)
+GLNAME( _mesa_sse_transform_points4_3d ):
+
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( ARG_SOURCE, ESI ) /* ptr to source GLvector4f */
+ MOV_L( ARG_DEST, EDI ) /* ptr to dest GLvector4f */
+
+ MOV_L( ARG_MATRIX, EDX ) /* ptr to matrix */
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX ) /* source count */
+
+ TEST_L( ECX, ECX)
+ JZ( LLBL(K_GTP43P3DR_finish) ) /* count was zero; go to finish */
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) )/* set dest size */
+
+ SHL_L( CONST(4), ECX ) /* count *= 16 */
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+ ADD_L( EDI, ECX ) /* count += dest ptr */
+
+ MOVAPS( MAT(0), XMM0 ) /* m3 | m2 | m1 | m0 */
+ MOVAPS( MAT(4), XMM1 ) /* m7 | m6 | m5 | m4 */
+ MOVAPS( MAT(8), XMM2 ) /* m11 | m10 | m9 | m8 */
+ MOVAPS( MAT(12), XMM3 ) /* m15 | m14 | m13 | m12 */
+
+ALIGNTEXT32
+LLBL( K_GTP43P3DR_top ):
+ MOVSS( SRC(0), XMM4 ) /* ox */
+ SHUFPS( CONST(0x0), XMM4, XMM4 ) /* ox | ox | ox | ox */
+ MULPS( XMM0, XMM4 ) /* ox*m3 | ox*m2 | ox*m1 | ox*m0 */
+
+ MOVSS( SRC(1), XMM5 ) /* oy */
+ SHUFPS( CONST(0x0), XMM5, XMM5 ) /* oy | oy | oy | oy */
+ MULPS( XMM1, XMM5 ) /* oy*m7 | oy*m6 | oy*m5 | oy*m4 */
+
+ MOVSS( SRC(2), XMM6 ) /* oz */
+ SHUFPS( CONST(0x0), XMM6, XMM6 ) /* oz | oz | oz | oz */
+ MULPS( XMM2, XMM6 ) /* oz*m11 | oz*m10 | oz*m9 | oz*m8 */
+
+ MOVSS( SRC(3), XMM7 ) /* ow */
+ SHUFPS( CONST(0x0), XMM7, XMM7 ) /* ow | ow | ow | ow */
+ MULPS( XMM3, XMM7 ) /* ow*m15 | ow*m14 | ow*m13 | ow*m12 */
+
+ ADDPS( XMM5, XMM4 ) /* ox*m3+oy*m7 | ... */
+ ADDPS( XMM6, XMM4 ) /* ox*m3+oy*m7+oz*m11 | ... */
+ ADDPS( XMM7, XMM4 ) /* ox*m3+oy*m7+oz*m11+ow*m15 | ... */
+ MOVAPS( XMM4, DST(0) ) /* ->D(3) | ->D(2) | ->D(1) | ->D(0) */
+
+ MOVSS( SRC(3), XMM4 ) /* ow */
+ MOVSS( XMM4, DST(3) ) /* ->D(3) */
+
+LLBL( K_GTP43P3DR_skip ):
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(K_GTP43P3DR_top) )
+
+LLBL( K_GTP43P3DR_finish ):
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_sse_transform_points4_identity )
+HIDDEN(_mesa_sse_transform_points4_identity)
+GLNAME( _mesa_sse_transform_points4_identity ):
+
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX ) /* verify non-zero count */
+ JE( LLBL( sse_identity_done ) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX ) /* stride */
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) ) /* set dest flags */
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) ) /* set dest count */
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )/* set dest size */
+
+ MOV_L( REGOFF(V4F_START, ESI), ESI ) /* ptr to first source vertex */
+ MOV_L( REGOFF(V4F_START, EDI), EDI ) /* ptr to first dest vertex */
+
+ALIGNTEXT16
+LLBL( sse_identity_loop ):
+
+ PREFETCHNTA( REGOFF(32, ESI) )
+
+ MOVAPS( REGIND(ESI), XMM0 )
+ ADD_L( EAX, ESI )
+
+ MOVAPS( XMM0, REGIND(EDI) )
+ ADD_L( CONST(16), EDI )
+
+ DEC_L( ECX )
+ JNZ( LLBL( sse_identity_loop ) )
+
+LLBL( sse_identity_done ):
+
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/x86.c b/nx-X11/extras/Mesa/src/mesa/x86/x86.c
new file mode 100644
index 000000000..aff71d224
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/x86.c
@@ -0,0 +1,96 @@
+/* $Id: x86.c,v 1.1.1.1 2004/06/16 09:19:37 anholt Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * Intel x86 assembly code by Josh Vanderhoof
+ */
+
+#include "glheader.h"
+#include "context.h"
+#include "math/m_xform.h"
+#include "tnl/t_context.h"
+
+#include "x86.h"
+#include "common_x86_macros.h"
+
+#ifdef DEBUG
+#include "math/m_debug.h"
+#endif
+
+
+#ifdef USE_X86_ASM
+DECLARE_XFORM_GROUP( x86, 2 )
+DECLARE_XFORM_GROUP( x86, 3 )
+DECLARE_XFORM_GROUP( x86, 4 )
+
+
+extern GLvector4f * _ASMAPI
+_mesa_x86_cliptest_points4( GLvector4f *clip_vec,
+ GLvector4f *proj_vec,
+ GLubyte clipMask[],
+ GLubyte *orMask,
+ GLubyte *andMask );
+
+extern GLvector4f * _ASMAPI
+_mesa_x86_cliptest_points4_np( GLvector4f *clip_vec,
+ GLvector4f *proj_vec,
+ GLubyte clipMask[],
+ GLubyte *orMask,
+ GLubyte *andMask );
+
+extern void _ASMAPI
+_mesa_v16_x86_cliptest_points4( GLfloat *first_vert,
+ GLfloat *last_vert,
+ GLubyte *or_mask,
+ GLubyte *and_mask,
+ GLubyte *clip_mask );
+
+extern void _ASMAPI
+_mesa_v16_x86_general_xform( GLfloat *dest,
+ const GLfloat *m,
+ const GLfloat *src,
+ GLuint src_stride,
+ GLuint count );
+#endif
+
+
+void _mesa_init_x86_transform_asm( void )
+{
+#ifdef USE_X86_ASM
+ ASSIGN_XFORM_GROUP( x86, 2 );
+ ASSIGN_XFORM_GROUP( x86, 3 );
+ ASSIGN_XFORM_GROUP( x86, 4 );
+
+ _mesa_clip_tab[4] = _mesa_x86_cliptest_points4;
+ _mesa_clip_np_tab[4] = _mesa_x86_cliptest_points4_np;
+
+#ifdef DEBUG
+ _math_test_all_transform_functions( "x86" );
+ _math_test_all_cliptest_functions( "x86" );
+#endif
+#endif
+}
+
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/x86.h b/nx-X11/extras/Mesa/src/mesa/x86/x86.h
new file mode 100644
index 000000000..920387707
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/x86.h
@@ -0,0 +1,36 @@
+/* $Id: x86.h,v 1.1.1.1 2004/06/16 09:19:37 anholt Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * Intel x86 assembly code by Josh Vanderhoof
+ */
+
+#ifndef __X86_H__
+#define __X86_H__
+
+extern void _mesa_init_x86_transform_asm( void );
+
+#endif
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/x86_cliptest.S b/nx-X11/extras/Mesa/src/mesa/x86/x86_cliptest.S
new file mode 100644
index 000000000..3fa9cb526
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/x86_cliptest.S
@@ -0,0 +1,403 @@
+/* $Id: x86_cliptest.S,v 1.1.1.2 2005/07/31 16:46:39 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * NOTE: Avoid using spaces in between '(' ')' and arguments, especially
+ * with macros like CONST, LLBL that expand to CONCAT(...). Putting spaces
+ * in there will break the build on some platforms.
+ */
+
+#include "matypes.h"
+#include "clip_args.h"
+
+#define SRC0 REGOFF(0, ESI)
+#define SRC1 REGOFF(4, ESI)
+#define SRC2 REGOFF(8, ESI)
+#define SRC3 REGOFF(12, ESI)
+#define DST0 REGOFF(0, EDI)
+#define DST1 REGOFF(4, EDI)
+#define DST2 REGOFF(8, EDI)
+#define DST3 REGOFF(12, EDI)
+#define MAT0 REGOFF(0, EDX)
+#define MAT1 REGOFF(4, EDX)
+#define MAT2 REGOFF(8, EDX)
+#define MAT3 REGOFF(12, EDX)
+
+
+/*
+ * Table for clip test.
+ *
+ * bit6 = SRC3 < 0
+ * bit5 = SRC2 < 0
+ * bit4 = abs(S(2)) > abs(S(3))
+ * bit3 = SRC1 < 0
+ * bit2 = abs(S(1)) > abs(S(3))
+ * bit1 = SRC0 < 0
+ * bit0 = abs(S(0)) > abs(S(3))
+ */
+
+ SEG_DATA
+
+clip_table:
+ D_BYTE 0x00, 0x01, 0x00, 0x02, 0x04, 0x05, 0x04, 0x06
+ D_BYTE 0x00, 0x01, 0x00, 0x02, 0x08, 0x09, 0x08, 0x0a
+ D_BYTE 0x20, 0x21, 0x20, 0x22, 0x24, 0x25, 0x24, 0x26
+ D_BYTE 0x20, 0x21, 0x20, 0x22, 0x28, 0x29, 0x28, 0x2a
+ D_BYTE 0x00, 0x01, 0x00, 0x02, 0x04, 0x05, 0x04, 0x06
+ D_BYTE 0x00, 0x01, 0x00, 0x02, 0x08, 0x09, 0x08, 0x0a
+ D_BYTE 0x10, 0x11, 0x10, 0x12, 0x14, 0x15, 0x14, 0x16
+ D_BYTE 0x10, 0x11, 0x10, 0x12, 0x18, 0x19, 0x18, 0x1a
+ D_BYTE 0x3f, 0x3d, 0x3f, 0x3e, 0x37, 0x35, 0x37, 0x36
+ D_BYTE 0x3f, 0x3d, 0x3f, 0x3e, 0x3b, 0x39, 0x3b, 0x3a
+ D_BYTE 0x2f, 0x2d, 0x2f, 0x2e, 0x27, 0x25, 0x27, 0x26
+ D_BYTE 0x2f, 0x2d, 0x2f, 0x2e, 0x2b, 0x29, 0x2b, 0x2a
+ D_BYTE 0x3f, 0x3d, 0x3f, 0x3e, 0x37, 0x35, 0x37, 0x36
+ D_BYTE 0x3f, 0x3d, 0x3f, 0x3e, 0x3b, 0x39, 0x3b, 0x3a
+ D_BYTE 0x1f, 0x1d, 0x1f, 0x1e, 0x17, 0x15, 0x17, 0x16
+ D_BYTE 0x1f, 0x1d, 0x1f, 0x1e, 0x1b, 0x19, 0x1b, 0x1a
+
+
+ SEG_TEXT
+
+/*
+ * _mesa_x86_cliptest_points4
+ *
+ * AL: ormask
+ * AH: andmask
+ * EBX: temp0
+ * ECX: temp1
+ * EDX: clipmask[]
+ * ESI: clip[]
+ * EDI: proj[]
+ * EBP: temp2
+ */
+
+#if defined(__ELF__) && defined(__PIC__) && defined(GNU_ASSEMBLER) && !defined(ELFPIC)
+#define ELFPIC
+#endif
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_cliptest_points4 )
+HIDDEN(_mesa_x86_cliptest_points4)
+GLNAME( _mesa_x86_cliptest_points4 ):
+
+#ifdef ELFPIC
+#define FRAME_OFFSET 20
+#else
+#define FRAME_OFFSET 16
+#endif
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+ PUSH_L( EBP )
+ PUSH_L( EBX )
+
+#ifdef ELFPIC
+ /* store pointer to clip_table on stack */
+ CALL( LLBL(ctp4_get_eip) )
+ ADD_L( CONST(_GLOBAL_OFFSET_TABLE_), EBX )
+ MOV_L( REGOFF(clip_table@GOT, EBX), EBX )
+ PUSH_L( EBX )
+ JMP( LLBL(ctp4_clip_table_ready) )
+
+LLBL(ctp4_get_eip):
+ /* store eip in ebx */
+ MOV_L( REGIND(ESP), EBX )
+ RET
+
+LLBL(ctp4_clip_table_ready):
+#endif
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_CLIP, EDX )
+ MOV_L( ARG_OR, EBX )
+
+ MOV_L( ARG_AND, EBP )
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) )
+ MOV_L( EAX, ARG_SOURCE ) /* put stride in ARG_SOURCE */
+
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDX, ECX )
+
+ MOV_L( ECX, ARG_CLIP ) /* put clipmask + count in ARG_CLIP */
+ CMP_L( ECX, EDX )
+
+ MOV_B( REGIND(EBX), AL )
+ MOV_B( REGIND(EBP), AH )
+
+ JZ( LLBL(ctp4_finish) )
+
+ALIGNTEXT16
+LLBL(ctp4_top):
+
+ FLD1 /* F3 */
+ FDIV_S( SRC3 ) /* GH: don't care about div-by-zero */
+
+ MOV_L( SRC3, EBP )
+ MOV_L( SRC2, EBX )
+
+ XOR_L( ECX, ECX )
+ ADD_L( EBP, EBP ) /* ebp = abs(S(3))*2 ; carry = sign of S(3) */
+
+ ADC_L( ECX, ECX )
+ ADD_L( EBX, EBX ) /* ebx = abs(S(2))*2 ; carry = sign of S(2) */
+
+ ADC_L( ECX, ECX )
+ CMP_L( EBX, EBP ) /* carry = abs(S(2))*2 > abs(S(3))*2 */
+
+ ADC_L( ECX, ECX )
+ MOV_L( SRC1, EBX )
+
+ ADD_L( EBX, EBX ) /* ebx = abs(S(1))*2 ; carry = sign of S(1) */
+
+ ADC_L( ECX, ECX )
+ CMP_L( EBX, EBP ) /* carry = abs(S(1))*2 > abs(S(3))*2 */
+
+ ADC_L( ECX, ECX )
+ MOV_L( SRC0, EBX )
+
+ ADD_L( EBX, EBX ) /* ebx = abs(S(0))*2 ; carry = sign of S(0) */
+
+ ADC_L( ECX, ECX )
+ CMP_L( EBX, EBP ) /* carry = abs(S(0))*2 > abs(S(3))*2 */
+
+ ADC_L( ECX, ECX )
+
+#ifdef ELFPIC
+ MOV_L( REGIND(ESP), EBP ) /* clip_table */
+
+ MOV_B( REGBI(EBP, ECX), CL )
+#else
+ MOV_B( REGOFF(clip_table,ECX), CL )
+#endif
+
+ OR_B( CL, AL )
+ AND_B( CL, AH )
+
+ TEST_B( CL, CL )
+ MOV_B( CL, REGIND(EDX) )
+
+ JZ( LLBL(ctp4_proj) )
+
+LLBL(ctp4_noproj):
+
+ FSTP( ST(0) ) /* */
+
+ MOV_L( CONST(0), DST0 )
+ MOV_L( CONST(0), DST1 )
+ MOV_L( CONST(0), DST2 )
+ MOV_L( CONST(0x3f800000), DST3 )
+
+ JMP( LLBL(ctp4_next) )
+
+LLBL(ctp4_proj):
+
+ FLD_S( SRC0 ) /* F0 F3 */
+ FMUL2( ST(1), ST0 )
+
+ FLD_S( SRC1 ) /* F1 F0 F3 */
+ FMUL2( ST(2), ST0 )
+
+ FLD_S( SRC2 ) /* F2 F1 F0 F3 */
+ FMUL2( ST(3), ST0 )
+
+ FXCH( ST(2) ) /* F0 F1 F2 F3 */
+ FSTP_S( DST0 ) /* F1 F2 F3 */
+ FSTP_S( DST1 ) /* F2 F3 */
+ FSTP_S( DST2 ) /* F3 */
+ FSTP_S( DST3 ) /* */
+
+LLBL(ctp4_next):
+
+ INC_L( EDX )
+ ADD_L( CONST(16), EDI )
+
+ ADD_L( ARG_SOURCE, ESI )
+ CMP_L( EDX, ARG_CLIP )
+
+ JNZ( LLBL(ctp4_top) )
+
+ MOV_L( ARG_OR, ECX )
+ MOV_L( ARG_AND, EDX )
+
+ MOV_B( AL, REGIND(ECX) )
+ MOV_B( AH, REGIND(EDX) )
+
+LLBL(ctp4_finish):
+
+ MOV_L( ARG_DEST, EAX )
+#ifdef ELFPIC
+ POP_L( ESI ) /* discard ptr to clip_table */
+#endif
+ POP_L( EBX )
+ POP_L( EBP )
+ POP_L( EDI )
+ POP_L( ESI )
+
+ RET
+
+
+
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_cliptest_points4_np )
+HIDDEN(_mesa_x86_cliptest_points4_np)
+GLNAME( _mesa_x86_cliptest_points4_np ):
+
+#ifdef ELFPIC
+#define FRAME_OFFSET 20
+#else
+#define FRAME_OFFSET 16
+#endif
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+ PUSH_L( EBP )
+ PUSH_L( EBX )
+
+#ifdef ELFPIC
+ /* store pointer to clip_table on stack */
+ CALL( LLBL(ctp4_np_get_eip) )
+ ADD_L( CONST(_GLOBAL_OFFSET_TABLE_), EBX )
+ MOV_L( REGOFF(clip_table@GOT, EBX), EBX )
+ PUSH_L( EBX )
+ JMP( LLBL(ctp4_np_clip_table_ready) )
+
+LLBL(ctp4_np_get_eip):
+ /* store eip in ebx */
+ MOV_L( REGIND(ESP), EBX )
+ RET
+
+LLBL(ctp4_np_clip_table_ready):
+#endif
+
+ MOV_L( ARG_SOURCE, ESI )
+ /* slot */
+
+ MOV_L( ARG_CLIP, EDX )
+ MOV_L( ARG_OR, EBX )
+
+ MOV_L( ARG_AND, EBP )
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( EAX, ARG_DEST ) /* put stride in ARG_DEST */
+ ADD_L( EDX, ECX )
+
+ MOV_L( ECX, EDI ) /* put clipmask + count in EDI */
+ CMP_L( ECX, EDX )
+
+ MOV_B( REGIND(EBX), AL )
+ MOV_B( REGIND(EBP), AH )
+
+ JZ( LLBL(ctp4_np_finish) )
+
+ALIGNTEXT16
+LLBL(ctp4_np_top):
+
+ MOV_L( SRC3, EBP )
+ MOV_L( SRC2, EBX )
+
+ XOR_L( ECX, ECX )
+ ADD_L( EBP, EBP ) /* ebp = abs(S(3))*2 ; carry = sign of S(3) */
+
+ ADC_L( ECX, ECX )
+ ADD_L( EBX, EBX ) /* ebx = abs(S(2))*2 ; carry = sign of S(2) */
+
+ ADC_L( ECX, ECX )
+ CMP_L( EBX, EBP ) /* carry = abs(S(2))*2 > abs(S(3))*2 */
+
+ ADC_L( ECX, ECX )
+ MOV_L( SRC1, EBX )
+
+ ADD_L( EBX, EBX ) /* ebx = abs(S(1))*2 ; carry = sign of S(1) */
+
+ ADC_L( ECX, ECX )
+ CMP_L( EBX, EBP ) /* carry = abs(S(1))*2 > abs(S(3))*2 */
+
+ ADC_L( ECX, ECX )
+ MOV_L( SRC0, EBX )
+
+ ADD_L( EBX, EBX ) /* ebx = abs(S(0))*2 ; carry = sign of S(0) */
+
+ ADC_L( ECX, ECX )
+ CMP_L( EBX, EBP ) /* carry = abs(S(0))*2 > abs(S(3))*2 */
+
+ ADC_L( ECX, ECX )
+
+#ifdef ELFPIC
+ MOV_L( REGIND(ESP), EBP ) /* clip_table */
+
+ MOV_B( REGBI(EBP, ECX), CL )
+#else
+ MOV_B( REGOFF(clip_table,ECX), CL )
+#endif
+
+ OR_B( CL, AL )
+ AND_B( CL, AH )
+
+ TEST_B( CL, CL )
+ MOV_B( CL, REGIND(EDX) )
+
+ INC_L( EDX )
+ /* slot */
+
+ ADD_L( ARG_DEST, ESI )
+ CMP_L( EDX, EDI )
+
+ JNZ( LLBL(ctp4_np_top) )
+
+ MOV_L( ARG_OR, ECX )
+ MOV_L( ARG_AND, EDX )
+
+ MOV_B( AL, REGIND(ECX) )
+ MOV_B( AH, REGIND(EDX) )
+
+LLBL(ctp4_np_finish):
+
+ MOV_L( ARG_SOURCE, EAX )
+#ifdef ELFPIC
+ POP_L( ESI ) /* discard ptr to clip_table */
+#endif
+ POP_L( EBX )
+ POP_L( EBP )
+ POP_L( EDI )
+ POP_L( ESI )
+
+ RET
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/x86_xform2.S b/nx-X11/extras/Mesa/src/mesa/x86/x86_xform2.S
new file mode 100644
index 000000000..61a031488
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/x86_xform2.S
@@ -0,0 +1,570 @@
+/* $Id: x86_xform2.S,v 1.1.1.2 2005/07/31 16:46:39 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * NOTE: Avoid using spaces in between '(' ')' and arguments, especially
+ * with macros like CONST, LLBL that expand to CONCAT(...). Putting spaces
+ * in there will break the build on some platforms.
+ */
+
+#include "matypes.h"
+#include "xform_args.h"
+
+ SEG_TEXT
+
+#define FP_ONE 1065353216
+#define FP_ZERO 0
+
+#define SRC0 REGOFF(0, ESI)
+#define SRC1 REGOFF(4, ESI)
+#define SRC2 REGOFF(8, ESI)
+#define SRC3 REGOFF(12, ESI)
+#define DST0 REGOFF(0, EDI)
+#define DST1 REGOFF(4, EDI)
+#define DST2 REGOFF(8, EDI)
+#define DST3 REGOFF(12, EDI)
+#define MAT0 REGOFF(0, EDX)
+#define MAT1 REGOFF(4, EDX)
+#define MAT2 REGOFF(8, EDX)
+#define MAT3 REGOFF(12, EDX)
+#define MAT4 REGOFF(16, EDX)
+#define MAT5 REGOFF(20, EDX)
+#define MAT6 REGOFF(24, EDX)
+#define MAT7 REGOFF(28, EDX)
+#define MAT8 REGOFF(32, EDX)
+#define MAT9 REGOFF(36, EDX)
+#define MAT10 REGOFF(40, EDX)
+#define MAT11 REGOFF(44, EDX)
+#define MAT12 REGOFF(48, EDX)
+#define MAT13 REGOFF(52, EDX)
+#define MAT14 REGOFF(56, EDX)
+#define MAT15 REGOFF(60, EDX)
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points2_general )
+HIDDEN(_mesa_x86_transform_points2_general)
+GLNAME( _mesa_x86_transform_points2_general ):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p2_gr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ALIGNTEXT16
+LLBL(x86_p2_gr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+ FLD_S( SRC0 ) /* F5 F4 */
+ FMUL_S( MAT1 )
+ FLD_S( SRC0 ) /* F6 F5 F4 */
+ FMUL_S( MAT2 )
+ FLD_S( SRC0 ) /* F7 F6 F5 F4 */
+ FMUL_S( MAT3 )
+
+ FLD_S( SRC1 ) /* F0 F7 F6 F5 F4 */
+ FMUL_S( MAT4 )
+ FLD_S( SRC1 ) /* F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT5 )
+ FLD_S( SRC1 ) /* F2 F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT6 )
+ FLD_S( SRC1 ) /* F3 F2 F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT7 )
+
+ FXCH( ST(3) ) /* F0 F2 F1 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(7) ) /* F2 F1 F3 F7 F6 F5 F4 */
+ FXCH( ST(1) ) /* F1 F2 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(5) ) /* F2 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F7 F6 F5 F4 */
+
+ FXCH( ST(3) ) /* F4 F6 F5 F7 */
+ FADD_S( MAT12 )
+ FXCH( ST(2) ) /* F5 F6 F4 F7 */
+ FADD_S( MAT13 )
+ FXCH( ST(1) ) /* F6 F5 F4 F7 */
+ FADD_S( MAT14 )
+ FXCH( ST(3) ) /* F7 F5 F4 F6 */
+ FADD_S( MAT15 )
+
+ FXCH( ST(2) ) /* F4 F5 F7 F6 */
+ FSTP_S( DST0 ) /* F5 F7 F6 */
+ FSTP_S( DST1 ) /* F7 F6 */
+ FXCH( ST(1) ) /* F6 F7 */
+ FSTP_S( DST2 ) /* F7 */
+ FSTP_S( DST3 ) /* */
+
+LLBL(x86_p2_gr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p2_gr_loop) )
+
+LLBL(x86_p2_gr_done):
+
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points2_perspective )
+HIDDEN(_mesa_x86_transform_points2_perspective)
+GLNAME( _mesa_x86_transform_points2_perspective ):
+
+#define FRAME_OFFSET 12
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+ PUSH_L( EBX )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p2_pr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ MOV_L( MAT14, EBX )
+
+ALIGNTEXT16
+LLBL(x86_p2_pr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+
+ FLD_S( SRC1 ) /* F1 F4 */
+ FMUL_S( MAT5 )
+
+ FXCH( ST(1) ) /* F4 F1 */
+ FSTP_S( DST0 ) /* F1 */
+ FSTP_S( DST1 ) /* */
+ MOV_L( EBX, DST2 )
+ MOV_L( CONST(FP_ZERO), DST3 )
+
+LLBL(x86_p2_pr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p2_pr_loop) )
+
+LLBL(x86_p2_pr_done):
+
+ POP_L( EBX )
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points2_3d )
+HIDDEN(_mesa_x86_transform_points2_3d)
+GLNAME( _mesa_x86_transform_points2_3d ):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p2_3dr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ALIGNTEXT16
+LLBL(x86_p2_3dr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+ FLD_S( SRC0 ) /* F5 F4 */
+ FMUL_S( MAT1 )
+ FLD_S( SRC0 ) /* F6 F5 F4 */
+ FMUL_S( MAT2 )
+
+ FLD_S( SRC1 ) /* F0 F6 F5 F4 */
+ FMUL_S( MAT4 )
+ FLD_S( SRC1 ) /* F1 F0 F6 F5 F4 */
+ FMUL_S( MAT5 )
+ FLD_S( SRC1 ) /* F2 F1 F0 F6 F5 F4 */
+ FMUL_S( MAT6 )
+
+ FXCH( ST(2) ) /* F0 F1 F2 F6 F5 F4 */
+ FADDP( ST0, ST(5) ) /* F1 F2 F6 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F2 F6 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F6 F5 F4 */
+
+ FXCH( ST(2) ) /* F4 F5 F6 */
+ FADD_S( MAT12 )
+ FXCH( ST(1) ) /* F5 F4 F6 */
+ FADD_S( MAT13 )
+ FXCH( ST(2) ) /* F6 F4 F5 */
+ FADD_S( MAT14 )
+
+ FXCH( ST(1) ) /* F4 F6 F5 */
+ FSTP_S( DST0 ) /* F6 F5 */
+ FXCH( ST(1) ) /* F5 F6 */
+ FSTP_S( DST1 ) /* F6 */
+ FSTP_S( DST2 ) /* */
+
+LLBL(x86_p2_3dr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p2_3dr_loop) )
+
+LLBL(x86_p2_3dr_done):
+
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points2_3d_no_rot )
+HIDDEN(_mesa_x86_transform_points2_3d_no_rot)
+GLNAME( _mesa_x86_transform_points2_3d_no_rot ):
+
+#define FRAME_OFFSET 12
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+ PUSH_L( EBX )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p2_3dnrr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ MOV_L( MAT14, EBX )
+
+ALIGNTEXT16
+LLBL(x86_p2_3dnrr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+
+ FLD_S( SRC1 ) /* F1 F4 */
+ FMUL_S( MAT5 )
+
+ FXCH( ST(1) ) /* F4 F1 */
+ FADD_S( MAT12 )
+ FLD_S( MAT13 ) /* F5 F4 F1 */
+ FXCH( ST(2) ) /* F1 F4 F5 */
+ FADDP( ST0, ST(2) ) /* F4 F5 */
+
+ FSTP_S( DST0 ) /* F5 */
+ FSTP_S( DST1 ) /* */
+ MOV_L( EBX, DST2 )
+
+LLBL(x86_p2_3dnrr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p2_3dnrr_loop) )
+
+LLBL(x86_p2_3dnrr_done):
+
+ POP_L( EBX )
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points2_2d )
+HIDDEN(_mesa_x86_transform_points2_2d)
+GLNAME( _mesa_x86_transform_points2_2d ):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p2_2dr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ALIGNTEXT16
+LLBL(x86_p2_2dr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+ FLD_S( SRC0 ) /* F5 F4 */
+ FMUL_S( MAT1 )
+
+ FLD_S( SRC1 ) /* F0 F5 F4 */
+ FMUL_S( MAT4 )
+ FLD_S( SRC1 ) /* F1 F0 F5 F4 */
+ FMUL_S( MAT5 )
+
+ FXCH( ST(1) ) /* F0 F1 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F1 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F5 F4 */
+
+ FXCH( ST(1) ) /* F4 F5 */
+ FADD_S( MAT12 )
+ FXCH( ST(1) ) /* F5 F4 */
+ FADD_S( MAT13 )
+
+ FXCH( ST(1) ) /* F4 F5 */
+ FSTP_S( DST0 ) /* F5 */
+ FSTP_S( DST1 ) /* */
+
+LLBL(x86_p2_2dr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p2_2dr_loop) )
+
+LLBL(x86_p2_2dr_done):
+
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT4
+GLOBL GLNAME( _mesa_x86_transform_points2_2d_no_rot )
+HIDDEN(_mesa_x86_transform_points2_2d_no_rot)
+GLNAME( _mesa_x86_transform_points2_2d_no_rot ):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p2_2dnrr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ALIGNTEXT16
+LLBL(x86_p2_2dnrr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+
+ FLD_S( SRC1 ) /* F1 F4 */
+ FMUL_S( MAT5 )
+
+ FXCH( ST(1) ) /* F4 F1 */
+ FADD_S( MAT12 )
+ FLD_S( MAT13 ) /* F5 F4 F1 */
+ FXCH( ST(2) ) /* F1 F4 F5 */
+ FADDP( ST0, ST(2) ) /* F4 F5 */
+
+ FSTP_S( DST0 ) /* F5 */
+ FSTP_S( DST1 ) /* */
+
+LLBL(x86_p2_2dnrr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p2_2dnrr_loop) )
+
+LLBL(x86_p2_2dnrr_done):
+
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points2_identity )
+HIDDEN(_mesa_x86_transform_points2_identity)
+GLNAME( _mesa_x86_transform_points2_identity ):
+
+#define FRAME_OFFSET 12
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+ PUSH_L( EBX )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p2_ir_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_2), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(2), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ CMP_L( ESI, EDI )
+ JE( LLBL(x86_p2_ir_done) )
+
+ALIGNTEXT16
+LLBL(x86_p2_ir_loop):
+
+ MOV_L( SRC0, EBX )
+ MOV_L( SRC1, EDX )
+
+ MOV_L( EBX, DST0 )
+ MOV_L( EDX, DST1 )
+
+LLBL(x86_p2_ir_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p2_ir_loop) )
+
+LLBL(x86_p2_ir_done):
+
+ POP_L( EBX )
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/x86_xform3.S b/nx-X11/extras/Mesa/src/mesa/x86/x86_xform3.S
new file mode 100644
index 000000000..04ef3a9ee
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/x86_xform3.S
@@ -0,0 +1,640 @@
+/* $Id: x86_xform3.S,v 1.1.1.2 2005/07/31 16:46:39 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * NOTE: Avoid using spaces in between '(' ')' and arguments, especially
+ * with macros like CONST, LLBL that expand to CONCAT(...). Putting spaces
+ * in there will break the build on some platforms.
+ */
+
+#include "matypes.h"
+#include "xform_args.h"
+
+ SEG_TEXT
+
+#define FP_ONE 1065353216
+#define FP_ZERO 0
+
+#define SRC0 REGOFF(0, ESI)
+#define SRC1 REGOFF(4, ESI)
+#define SRC2 REGOFF(8, ESI)
+#define SRC3 REGOFF(12, ESI)
+#define DST0 REGOFF(0, EDI)
+#define DST1 REGOFF(4, EDI)
+#define DST2 REGOFF(8, EDI)
+#define DST3 REGOFF(12, EDI)
+#define MAT0 REGOFF(0, EDX)
+#define MAT1 REGOFF(4, EDX)
+#define MAT2 REGOFF(8, EDX)
+#define MAT3 REGOFF(12, EDX)
+#define MAT4 REGOFF(16, EDX)
+#define MAT5 REGOFF(20, EDX)
+#define MAT6 REGOFF(24, EDX)
+#define MAT7 REGOFF(28, EDX)
+#define MAT8 REGOFF(32, EDX)
+#define MAT9 REGOFF(36, EDX)
+#define MAT10 REGOFF(40, EDX)
+#define MAT11 REGOFF(44, EDX)
+#define MAT12 REGOFF(48, EDX)
+#define MAT13 REGOFF(52, EDX)
+#define MAT14 REGOFF(56, EDX)
+#define MAT15 REGOFF(60, EDX)
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points3_general )
+HIDDEN(_mesa_x86_transform_points3_general)
+GLNAME( _mesa_x86_transform_points3_general ):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p3_gr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ALIGNTEXT16
+LLBL(x86_p3_gr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+ FLD_S( SRC0 ) /* F5 F4 */
+ FMUL_S( MAT1 )
+ FLD_S( SRC0 ) /* F6 F5 F4 */
+ FMUL_S( MAT2 )
+ FLD_S( SRC0 ) /* F7 F6 F5 F4 */
+ FMUL_S( MAT3 )
+
+ FLD_S( SRC1 ) /* F0 F7 F6 F5 F4 */
+ FMUL_S( MAT4 )
+ FLD_S( SRC1 ) /* F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT5 )
+ FLD_S( SRC1 ) /* F2 F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT6 )
+ FLD_S( SRC1 ) /* F3 F2 F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT7 )
+
+ FXCH( ST(3) ) /* F0 F2 F1 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(7) ) /* F2 F1 F3 F7 F6 F5 F4 */
+ FXCH( ST(1) ) /* F1 F2 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(5) ) /* F2 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F7 F6 F5 F4 */
+
+ FLD_S( SRC2 ) /* F0 F7 F6 F5 F4 */
+ FMUL_S( MAT8 )
+ FLD_S( SRC2 ) /* F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT9 )
+ FLD_S( SRC2 ) /* F2 F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT10 )
+ FLD_S( SRC2 ) /* F3 F2 F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT11 )
+
+ FXCH( ST(3) ) /* F0 F2 F1 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(7) ) /* F2 F1 F3 F7 F6 F5 F4 */
+ FXCH( ST(1) ) /* F1 F2 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(5) ) /* F2 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F7 F6 F5 F4 */
+
+ FXCH( ST(3) ) /* F4 F6 F5 F7 */
+ FADD_S( MAT12 )
+ FXCH( ST(2) ) /* F5 F6 F4 F7 */
+ FADD_S( MAT13 )
+ FXCH( ST(1) ) /* F6 F5 F4 F7 */
+ FADD_S( MAT14 )
+ FXCH( ST(3) ) /* F7 F5 F4 F6 */
+ FADD_S( MAT15 )
+
+ FXCH( ST(2) ) /* F4 F5 F7 F6 */
+ FSTP_S( DST0 ) /* F5 F7 F6 */
+ FSTP_S( DST1 ) /* F7 F6 */
+ FXCH( ST(1) ) /* F6 F7 */
+ FSTP_S( DST2 ) /* F7 */
+ FSTP_S( DST3 ) /* */
+
+LLBL(x86_p3_gr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p3_gr_loop) )
+
+LLBL(x86_p3_gr_done):
+
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points3_perspective )
+HIDDEN(_mesa_x86_transform_points3_perspective)
+GLNAME( _mesa_x86_transform_points3_perspective ):
+
+#define FRAME_OFFSET 12
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+ PUSH_L( EBX )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p3_pr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ALIGNTEXT16
+LLBL(x86_p3_pr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+
+ FLD_S( SRC1 ) /* F5 F4 */
+ FMUL_S( MAT5 )
+
+ FLD_S( SRC2 ) /* F0 F5 F4 */
+ FMUL_S( MAT8 )
+ FLD_S( SRC2 ) /* F1 F0 F5 F4 */
+ FMUL_S( MAT9 )
+ FLD_S( SRC2 ) /* F2 F1 F0 F5 F4 */
+ FMUL_S( MAT10 )
+
+ FXCH( ST(2) ) /* F0 F1 F2 F5 F4 */
+ FADDP( ST0, ST(4) ) /* F1 F2 F5 F4 */
+ FADDP( ST0, ST(2) ) /* F2 F5 F4 */
+ FLD_S( MAT14 ) /* F6 F2 F5 F4 */
+ FXCH( ST(1) ) /* F2 F6 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F6 F5 F4 */
+
+ MOV_L( SRC2, EBX )
+ XOR_L( CONST(-2147483648), EBX )/* change sign */
+
+ FXCH( ST(2) ) /* F4 F5 F6 */
+ FSTP_S( DST0 ) /* F5 F6 */
+ FSTP_S( DST1 ) /* F6 */
+ FSTP_S( DST2 ) /* */
+ MOV_L( EBX, DST3 )
+
+LLBL(x86_p3_pr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p3_pr_loop) )
+
+LLBL(x86_p3_pr_done):
+
+ POP_L( EBX )
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points3_3d )
+HIDDEN(_mesa_x86_transform_points3_3d)
+GLNAME( _mesa_x86_transform_points3_3d ):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p3_3dr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ALIGNTEXT16
+LLBL(x86_p3_3dr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+ FLD_S( SRC0 ) /* F5 F4 */
+ FMUL_S( MAT1 )
+ FLD_S( SRC0 ) /* F6 F5 F4 */
+ FMUL_S( MAT2 )
+
+ FLD_S( SRC1 ) /* F0 F6 F5 F4 */
+ FMUL_S( MAT4 )
+ FLD_S( SRC1 ) /* F1 F0 F6 F5 F4 */
+ FMUL_S( MAT5 )
+ FLD_S( SRC1 ) /* F2 F1 F0 F6 F5 F4 */
+ FMUL_S( MAT6 )
+
+ FXCH( ST(2) ) /* F0 F1 F2 F6 F5 F4 */
+ FADDP( ST0, ST(5) ) /* F1 F2 F6 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F2 F6 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F6 F5 F4 */
+
+ FLD_S( SRC2 ) /* F0 F6 F5 F4 */
+ FMUL_S( MAT8 )
+ FLD_S( SRC2 ) /* F1 F0 F6 F5 F4 */
+ FMUL_S( MAT9 )
+ FLD_S( SRC2 ) /* F2 F1 F0 F6 F5 F4 */
+ FMUL_S( MAT10 )
+
+ FXCH( ST(2) ) /* F0 F1 F2 F6 F5 F4 */
+ FADDP( ST0, ST(5) ) /* F1 F2 F6 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F2 F6 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F6 F5 F4 */
+
+ FXCH( ST(2) ) /* F4 F5 F6 */
+ FADD_S( MAT12 )
+ FXCH( ST(1) ) /* F5 F4 F6 */
+ FADD_S( MAT13 )
+ FXCH( ST(2) ) /* F6 F4 F5 */
+ FADD_S( MAT14 )
+
+ FXCH( ST(1) ) /* F4 F6 F5 */
+ FSTP_S( DST0 ) /* F6 F5 */
+ FXCH( ST(1) ) /* F5 F6 */
+ FSTP_S( DST1 ) /* F6 */
+ FSTP_S( DST2 ) /* */
+
+LLBL(x86_p3_3dr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p3_3dr_loop) )
+
+LLBL(x86_p3_3dr_done):
+
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points3_3d_no_rot )
+HIDDEN(_mesa_x86_transform_points3_3d_no_rot)
+GLNAME( _mesa_x86_transform_points3_3d_no_rot ):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p3_3dnrr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ALIGNTEXT16
+LLBL(x86_p3_3dnrr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+
+ FLD_S( SRC1 ) /* F1 F4 */
+ FMUL_S( MAT5 )
+
+ FLD_S( SRC2 ) /* F2 F1 F4 */
+ FMUL_S( MAT10 )
+
+ FXCH( ST(2) ) /* F4 F1 F2 */
+ FADD_S( MAT12 )
+ FLD_S( MAT13 ) /* F5 F4 F1 F2 */
+ FXCH( ST(2) ) /* F1 F4 F5 F2 */
+ FADDP( ST0, ST(2) ) /* F4 F5 F2 */
+ FLD_S( MAT14 ) /* F6 F4 F5 F2 */
+ FXCH( ST(3) ) /* F2 F4 F5 F6 */
+ FADDP( ST0, ST(3) ) /* F4 F5 F6 */
+
+ FSTP_S( DST0 ) /* F5 F6 */
+ FSTP_S( DST1 ) /* F6 */
+ FSTP_S( DST2 ) /* */
+
+LLBL(x86_p3_3dnrr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p3_3dnrr_loop) )
+
+LLBL(x86_p3_3dnrr_done):
+
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points3_2d )
+HIDDEN(_mesa_x86_transform_points3_2d)
+GLNAME( _mesa_x86_transform_points3_2d ):
+
+#define FRAME_OFFSET 12
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+ PUSH_L( EBX )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p3_2dr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ALIGNTEXT16
+LLBL(x86_p3_2dr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+ FLD_S( SRC0 ) /* F5 F4 */
+ FMUL_S( MAT1 )
+
+ FLD_S( SRC1 ) /* F0 F5 F4 */
+ FMUL_S( MAT4 )
+ FLD_S( SRC1 ) /* F1 F0 F5 F4 */
+ FMUL_S( MAT5 )
+
+ FXCH( ST(1) ) /* F0 F1 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F1 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F5 F4 */
+
+ FXCH( ST(1) ) /* F4 F5 */
+ FADD_S( MAT12 )
+ FXCH( ST(1) ) /* F5 F4 */
+ FADD_S( MAT13 )
+
+ MOV_L( SRC2, EBX )
+
+ FXCH( ST(1) ) /* F4 F5 */
+ FSTP_S( DST0 ) /* F5 */
+ FSTP_S( DST1 ) /* */
+ MOV_L( EBX, DST2 )
+
+LLBL(x86_p3_2dr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p3_2dr_loop) )
+
+LLBL(x86_p3_2dr_done):
+
+ POP_L( EBX )
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points3_2d_no_rot )
+HIDDEN(_mesa_x86_transform_points3_2d_no_rot)
+GLNAME( _mesa_x86_transform_points3_2d_no_rot ):
+
+#define FRAME_OFFSET 12
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+ PUSH_L( EBX )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p3_2dnrr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ALIGNTEXT16
+LLBL(x86_p3_2dnrr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+
+ FLD_S( SRC1 ) /* F1 F4 */
+ FMUL_S( MAT5 )
+
+ FXCH( ST(1) ) /* F4 F1 */
+ FADD_S( MAT12 )
+ FLD_S( MAT13 ) /* F5 F4 F1 */
+
+ FXCH( ST(2) ) /* F1 F4 F5 */
+ FADDP( ST0, ST(2) ) /* F4 F5 */
+
+ MOV_L( SRC2, EBX )
+
+ FSTP_S( DST0 ) /* F5 */
+ FSTP_S( DST1 ) /* */
+ MOV_L( EBX, DST2 )
+
+LLBL(x86_p3_2dnrr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p3_2dnrr_loop) )
+
+LLBL(x86_p3_2dnrr_done):
+
+ POP_L( EBX )
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points3_identity )
+HIDDEN(_mesa_x86_transform_points3_identity)
+GLNAME(_mesa_x86_transform_points3_identity ):
+
+#define FRAME_OFFSET 16
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+ PUSH_L( EBX )
+ PUSH_L( EBP )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p3_ir_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_3), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(3), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ CMP_L( ESI, EDI )
+ JE( LLBL(x86_p3_ir_done) )
+
+ALIGNTEXT16
+LLBL(x86_p3_ir_loop):
+
+#if 1
+ MOV_L( SRC0, EBX )
+ MOV_L( SRC1, EBP )
+ MOV_L( SRC2, EDX )
+
+ MOV_L( EBX, DST0 )
+ MOV_L( EBP, DST1 )
+ MOV_L( EDX, DST2 )
+#else
+ FLD_S( SRC0 )
+ FLD_S( SRC1 )
+ FLD_S( SRC2 )
+
+ FSTP_S( DST2 )
+ FSTP_S( DST1 )
+ FSTP_S( DST0 )
+#endif
+
+LLBL(x86_p3_ir_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p3_ir_loop) )
+
+LLBL(x86_p3_ir_done):
+
+ POP_L( EBP )
+ POP_L( EBX )
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/x86_xform4.S b/nx-X11/extras/Mesa/src/mesa/x86/x86_xform4.S
new file mode 100644
index 000000000..79e6b657a
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/x86_xform4.S
@@ -0,0 +1,673 @@
+/* $Id: x86_xform4.S,v 1.1.1.2 2005/07/31 16:46:39 ajax Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * NOTE: Avoid using spaces in between '(' ')' and arguments, especially
+ * with macros like CONST, LLBL that expand to CONCAT(...). Putting spaces
+ * in there will break the build on some platforms.
+ */
+
+#include "matypes.h"
+#include "xform_args.h"
+
+ SEG_TEXT
+
+#define FP_ONE 1065353216
+#define FP_ZERO 0
+
+#define SRC0 REGOFF(0, ESI)
+#define SRC1 REGOFF(4, ESI)
+#define SRC2 REGOFF(8, ESI)
+#define SRC3 REGOFF(12, ESI)
+#define DST0 REGOFF(0, EDI)
+#define DST1 REGOFF(4, EDI)
+#define DST2 REGOFF(8, EDI)
+#define DST3 REGOFF(12, EDI)
+#define MAT0 REGOFF(0, EDX)
+#define MAT1 REGOFF(4, EDX)
+#define MAT2 REGOFF(8, EDX)
+#define MAT3 REGOFF(12, EDX)
+#define MAT4 REGOFF(16, EDX)
+#define MAT5 REGOFF(20, EDX)
+#define MAT6 REGOFF(24, EDX)
+#define MAT7 REGOFF(28, EDX)
+#define MAT8 REGOFF(32, EDX)
+#define MAT9 REGOFF(36, EDX)
+#define MAT10 REGOFF(40, EDX)
+#define MAT11 REGOFF(44, EDX)
+#define MAT12 REGOFF(48, EDX)
+#define MAT13 REGOFF(52, EDX)
+#define MAT14 REGOFF(56, EDX)
+#define MAT15 REGOFF(60, EDX)
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points4_general )
+HIDDEN(_mesa_x86_transform_points4_general)
+GLNAME( _mesa_x86_transform_points4_general ):
+
+#define FRAME_OFFSET 8
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p4_gr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ALIGNTEXT16
+LLBL(x86_p4_gr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+ FLD_S( SRC0 ) /* F5 F4 */
+ FMUL_S( MAT1 )
+ FLD_S( SRC0 ) /* F6 F5 F4 */
+ FMUL_S( MAT2 )
+ FLD_S( SRC0 ) /* F7 F6 F5 F4 */
+ FMUL_S( MAT3 )
+
+ FLD_S( SRC1 ) /* F0 F7 F6 F5 F4 */
+ FMUL_S( MAT4 )
+ FLD_S( SRC1 ) /* F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT5 )
+ FLD_S( SRC1 ) /* F2 F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT6 )
+ FLD_S( SRC1 ) /* F3 F2 F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT7 )
+
+ FXCH( ST(3) ) /* F0 F2 F1 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(7) ) /* F2 F1 F3 F7 F6 F5 F4 */
+ FXCH( ST(1) ) /* F1 F2 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(5) ) /* F2 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F7 F6 F5 F4 */
+
+ FLD_S( SRC2 ) /* F0 F7 F6 F5 F4 */
+ FMUL_S( MAT8 )
+ FLD_S( SRC2 ) /* F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT9 )
+ FLD_S( SRC2 ) /* F2 F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT10 )
+ FLD_S( SRC2 ) /* F3 F2 F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT11 )
+
+ FXCH( ST(3) ) /* F0 F2 F1 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(7) ) /* F2 F1 F3 F7 F6 F5 F4 */
+ FXCH( ST(1) ) /* F1 F2 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(5) ) /* F2 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F7 F6 F5 F4 */
+
+ FLD_S( SRC3 ) /* F0 F7 F6 F5 F4 */
+ FMUL_S( MAT12 )
+ FLD_S( SRC3 ) /* F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT13 )
+ FLD_S( SRC3 ) /* F2 F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT14 )
+ FLD_S( SRC3 ) /* F3 F2 F1 F0 F7 F6 F5 F4 */
+ FMUL_S( MAT15 )
+
+ FXCH( ST(3) ) /* F0 F2 F1 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(7) ) /* F2 F1 F3 F7 F6 F5 F4 */
+ FXCH( ST(1) ) /* F1 F2 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(5) ) /* F2 F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F3 F7 F6 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F7 F6 F5 F4 */
+
+ FXCH( ST(3) ) /* F4 F6 F5 F7 */
+ FSTP_S( DST0 ) /* F6 F5 F7 */
+ FXCH( ST(1) ) /* F5 F6 F7 */
+ FSTP_S( DST1 ) /* F6 F7 */
+ FSTP_S( DST2 ) /* F7 */
+ FSTP_S( DST3 ) /* */
+
+LLBL(x86_p4_gr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p4_gr_loop) )
+
+LLBL(x86_p4_gr_done):
+
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points4_perspective )
+HIDDEN(_mesa_x86_transform_points4_perspective)
+GLNAME( _mesa_x86_transform_points4_perspective ):
+
+#define FRAME_OFFSET 12
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+ PUSH_L( EBX )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p4_pr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ALIGNTEXT16
+LLBL(x86_p4_pr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+
+ FLD_S( SRC1 ) /* F5 F4 */
+ FMUL_S( MAT5 )
+
+ FLD_S( SRC2 ) /* F0 F5 F4 */
+ FMUL_S( MAT8 )
+ FLD_S( SRC2 ) /* F1 F0 F5 F4 */
+ FMUL_S( MAT9 )
+ FLD_S( SRC2 ) /* F6 F1 F0 F5 F4 */
+ FMUL_S( MAT10 )
+
+ FXCH( ST(2) ) /* F0 F1 F6 F5 F4 */
+ FADDP( ST0, ST(4) ) /* F1 F6 F5 F4 */
+ FADDP( ST0, ST(2) ) /* F6 F5 F4 */
+
+ FLD_S( SRC3 ) /* F2 F6 F5 F4 */
+ FMUL_S( MAT14 )
+
+ FADDP( ST0, ST(1) ) /* F6 F5 F4 */
+
+ MOV_L( SRC2, EBX )
+ XOR_L( CONST(-2147483648), EBX )/* change sign */
+
+ FXCH( ST(2) ) /* F4 F5 F6 */
+ FSTP_S( DST0 ) /* F5 F6 */
+ FSTP_S( DST1 ) /* F6 */
+ FSTP_S( DST2 ) /* */
+ MOV_L( EBX, DST3 )
+
+LLBL(x86_p4_pr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p4_pr_loop) )
+
+LLBL(x86_p4_pr_done):
+
+ POP_L( EBX )
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points4_3d )
+HIDDEN(_mesa_x86_transform_points4_3d)
+GLNAME( _mesa_x86_transform_points4_3d ):
+
+#define FRAME_OFFSET 12
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+ PUSH_L( EBX )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p4_3dr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ALIGNTEXT16
+LLBL(x86_p4_3dr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+ FLD_S( SRC0 ) /* F5 F4 */
+ FMUL_S( MAT1 )
+ FLD_S( SRC0 ) /* F6 F5 F4 */
+ FMUL_S( MAT2 )
+
+ FLD_S( SRC1 ) /* F0 F6 F5 F4 */
+ FMUL_S( MAT4 )
+ FLD_S( SRC1 ) /* F1 F0 F6 F5 F4 */
+ FMUL_S( MAT5 )
+ FLD_S( SRC1 ) /* F2 F1 F0 F6 F5 F4 */
+ FMUL_S( MAT6 )
+
+ FXCH( ST(2) ) /* F0 F1 F2 F6 F5 F4 */
+ FADDP( ST0, ST(5) ) /* F1 F2 F6 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F2 F6 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F6 F5 F4 */
+
+ FLD_S( SRC2 ) /* F0 F6 F5 F4 */
+ FMUL_S( MAT8 )
+ FLD_S( SRC2 ) /* F1 F0 F6 F5 F4 */
+ FMUL_S( MAT9 )
+ FLD_S( SRC2 ) /* F2 F1 F0 F6 F5 F4 */
+ FMUL_S( MAT10 )
+
+ FXCH( ST(2) ) /* F0 F1 F2 F6 F5 F4 */
+ FADDP( ST0, ST(5) ) /* F1 F2 F6 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F2 F6 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F6 F5 F4 */
+
+ FLD_S( SRC3 ) /* F0 F6 F5 F4 */
+ FMUL_S( MAT12 )
+ FLD_S( SRC3 ) /* F1 F0 F6 F5 F4 */
+ FMUL_S( MAT13 )
+ FLD_S( SRC3 ) /* F2 F1 F0 F6 F5 F4 */
+ FMUL_S( MAT14 )
+
+ FXCH( ST(2) ) /* F0 F1 F2 F6 F5 F4 */
+ FADDP( ST0, ST(5) ) /* F1 F2 F6 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F2 F6 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F6 F5 F4 */
+
+ MOV_L( SRC3, EBX )
+
+ FXCH( ST(2) ) /* F4 F5 F6 */
+ FSTP_S( DST0 ) /* F5 F6 */
+ FSTP_S( DST1 ) /* F6 */
+ FSTP_S( DST2 ) /* */
+ MOV_L( EBX, DST3 )
+
+LLBL(x86_p4_3dr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p4_3dr_loop) )
+
+LLBL(x86_p4_3dr_done):
+
+ POP_L( EBX )
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME(_mesa_x86_transform_points4_3d_no_rot)
+HIDDEN(_mesa_x86_transform_points4_3d_no_rot)
+GLNAME(_mesa_x86_transform_points4_3d_no_rot):
+
+#define FRAME_OFFSET 12
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+ PUSH_L( EBX )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p4_3dnrr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ALIGNTEXT16
+LLBL(x86_p4_3dnrr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+
+ FLD_S( SRC1 ) /* F5 F4 */
+ FMUL_S( MAT5 )
+
+ FLD_S( SRC2 ) /* F6 F5 F4 */
+ FMUL_S( MAT10 )
+
+ FLD_S( SRC3 ) /* F0 F6 F5 F4 */
+ FMUL_S( MAT12 )
+ FLD_S( SRC3 ) /* F1 F0 F6 F5 F4 */
+ FMUL_S( MAT13 )
+ FLD_S( SRC3 ) /* F2 F1 F0 F6 F5 F4 */
+ FMUL_S( MAT14 )
+
+ FXCH( ST(2) ) /* F0 F1 F2 F6 F5 F4 */
+ FADDP( ST0, ST(5) ) /* F1 F2 F6 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F2 F6 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F6 F5 F4 */
+
+ MOV_L( SRC3, EBX )
+
+ FXCH( ST(2) ) /* F4 F5 F6 */
+ FSTP_S( DST0 ) /* F5 F6 */
+ FSTP_S( DST1 ) /* F6 */
+ FSTP_S( DST2 ) /* */
+ MOV_L( EBX, DST3 )
+
+LLBL(x86_p4_3dnrr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p4_3dnrr_loop) )
+
+LLBL(x86_p4_3dnrr_done):
+
+ POP_L( EBX )
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points4_2d )
+HIDDEN(_mesa_x86_transform_points4_2d)
+GLNAME( _mesa_x86_transform_points4_2d ):
+
+#define FRAME_OFFSET 16
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+ PUSH_L( EBX )
+ PUSH_L( EBP )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p4_2dr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ALIGNTEXT16
+LLBL(x86_p4_2dr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+ FLD_S( SRC0 ) /* F5 F4 */
+ FMUL_S( MAT1 )
+
+ FLD_S( SRC1 ) /* F0 F5 F4 */
+ FMUL_S( MAT4 )
+ FLD_S( SRC1 ) /* F1 F0 F5 F4 */
+ FMUL_S( MAT5 )
+
+ FXCH( ST(1) ) /* F0 F1 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F1 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F5 F4 */
+
+ FLD_S( SRC3 ) /* F0 F5 F4 */
+ FMUL_S( MAT12 )
+ FLD_S( SRC3 ) /* F1 F0 F5 F4 */
+ FMUL_S( MAT13 )
+
+ FXCH( ST(1) ) /* F0 F1 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F1 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F5 F4 */
+
+ MOV_L( SRC2, EBX )
+ MOV_L( SRC3, EBP )
+
+ FXCH( ST(1) ) /* F4 F5 */
+ FSTP_S( DST0 ) /* F5 */
+ FSTP_S( DST1 ) /* */
+ MOV_L( EBX, DST2 )
+ MOV_L( EBP, DST3 )
+
+LLBL(x86_p4_2dr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p4_2dr_loop) )
+
+LLBL(x86_p4_2dr_done):
+
+ POP_L( EBP )
+ POP_L( EBX )
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points4_2d_no_rot )
+HIDDEN(_mesa_x86_transform_points4_2d_no_rot)
+GLNAME( _mesa_x86_transform_points4_2d_no_rot ):
+
+#define FRAME_OFFSET 16
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+ PUSH_L( EBX )
+ PUSH_L( EBP )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p4_2dnrr_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ALIGNTEXT16
+LLBL(x86_p4_2dnrr_loop):
+
+ FLD_S( SRC0 ) /* F4 */
+ FMUL_S( MAT0 )
+
+ FLD_S( SRC1 ) /* F5 F4 */
+ FMUL_S( MAT5 )
+
+ FLD_S( SRC3 ) /* F0 F5 F4 */
+ FMUL_S( MAT12 )
+ FLD_S( SRC3 ) /* F1 F0 F5 F4 */
+ FMUL_S( MAT13 )
+
+ FXCH( ST(1) ) /* F0 F1 F5 F4 */
+ FADDP( ST0, ST(3) ) /* F1 F5 F4 */
+ FADDP( ST0, ST(1) ) /* F5 F4 */
+
+ MOV_L( SRC2, EBX )
+ MOV_L( SRC3, EBP )
+
+ FXCH( ST(1) ) /* F4 F5 */
+ FSTP_S( DST0 ) /* F5 */
+ FSTP_S( DST1 ) /* */
+ MOV_L( EBX, DST2 )
+ MOV_L( EBP, DST3 )
+
+LLBL(x86_p4_2dnrr_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p4_2dnrr_loop) )
+
+LLBL(x86_p4_2dnrr_done):
+
+ POP_L( EBP )
+ POP_L( EBX )
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
+#undef FRAME_OFFSET
+
+
+
+
+ALIGNTEXT16
+GLOBL GLNAME( _mesa_x86_transform_points4_identity )
+HIDDEN(_mesa_x86_transform_points4_identity)
+GLNAME( _mesa_x86_transform_points4_identity ):
+
+#define FRAME_OFFSET 12
+ PUSH_L( ESI )
+ PUSH_L( EDI )
+ PUSH_L( EBX )
+
+ MOV_L( ARG_SOURCE, ESI )
+ MOV_L( ARG_DEST, EDI )
+
+ MOV_L( ARG_MATRIX, EDX )
+ MOV_L( REGOFF(V4F_COUNT, ESI), ECX )
+
+ TEST_L( ECX, ECX )
+ JZ( LLBL(x86_p4_ir_done) )
+
+ MOV_L( REGOFF(V4F_STRIDE, ESI), EAX )
+ OR_L( CONST(VEC_SIZE_4), REGOFF(V4F_FLAGS, EDI) )
+
+ MOV_L( ECX, REGOFF(V4F_COUNT, EDI) )
+ MOV_L( CONST(4), REGOFF(V4F_SIZE, EDI) )
+
+ SHL_L( CONST(4), ECX )
+ MOV_L( REGOFF(V4F_START, ESI), ESI )
+
+ MOV_L( REGOFF(V4F_START, EDI), EDI )
+ ADD_L( EDI, ECX )
+
+ CMP_L( ESI, EDI )
+ JE( LLBL(x86_p4_ir_done) )
+
+ALIGNTEXT16
+LLBL(x86_p4_ir_loop):
+
+ MOV_L( SRC0, EBX )
+ MOV_L( SRC1, EDX )
+
+ MOV_L( EBX, DST0 )
+ MOV_L( EDX, DST1 )
+
+ MOV_L( SRC2, EBX )
+ MOV_L( SRC3, EDX )
+
+ MOV_L( EBX, DST2 )
+ MOV_L( EDX, DST3 )
+
+LLBL(x86_p4_ir_skip):
+
+ ADD_L( CONST(16), EDI )
+ ADD_L( EAX, ESI )
+ CMP_L( ECX, EDI )
+ JNE( LLBL(x86_p4_ir_loop) )
+
+LLBL(x86_p4_ir_done):
+
+ POP_L( EBX )
+ POP_L( EDI )
+ POP_L( ESI )
+ RET
diff --git a/nx-X11/extras/Mesa/src/mesa/x86/xform_args.h b/nx-X11/extras/Mesa/src/mesa/x86/xform_args.h
new file mode 100644
index 000000000..349e47ac6
--- /dev/null
+++ b/nx-X11/extras/Mesa/src/mesa/x86/xform_args.h
@@ -0,0 +1,52 @@
+/* $Id: xform_args.h,v 1.1.1.1 2004/06/16 09:19:37 anholt Exp $ */
+
+/*
+ * Mesa 3-D graphics library
+ * Version: 3.5
+ *
+ * Copyright (C) 1999-2001 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.
+ */
+
+/*
+ * Transform function interface for assembly code. Simply define
+ * FRAME_OFFSET to the number of bytes pushed onto the stack before
+ * using the ARG_* argument macros.
+ *
+ * Gareth Hughes
+ */
+
+#ifndef __XFORM_ARGS_H__
+#define __XFORM_ARGS_H__
+
+/* Offsets for transform_func arguments
+ *
+ * typedef void (*transform_func)( GLvector4f *to_vec,
+ * const GLfloat m[16],
+ * const GLvector4f *from_vec );
+ */
+#define OFFSET_DEST 4
+#define OFFSET_MATRIX 8
+#define OFFSET_SOURCE 12
+
+#define ARG_DEST REGOFF(FRAME_OFFSET+OFFSET_DEST, ESP)
+#define ARG_MATRIX REGOFF(FRAME_OFFSET+OFFSET_MATRIX, ESP)
+#define ARG_SOURCE REGOFF(FRAME_OFFSET+OFFSET_SOURCE, ESP)
+
+#endif
diff --git a/nx-X11/extras/Mesa/vms/analyze_map.com b/nx-X11/extras/Mesa/vms/analyze_map.com
new file mode 100644
index 000000000..d024ffcf9
--- /dev/null
+++ b/nx-X11/extras/Mesa/vms/analyze_map.com
@@ -0,0 +1,148 @@
+$! Analyze Map for OpenVMS AXP
+$!
+$! Originally found in the distribution of gv
+$! http://wwwthep.physik.uni-mainz.de/~plass/gv/
+$!
+$! 1-Jul-1999 : modified to be used with $BSS$ & $READONLY sections in the
+$! map-file by J. Jansen (joukj@hrem.stm.tudelft.nl)
+$!
+$ SET SYMBOL/GENERAL/SCOPE=(NOLOCAL,NOGLOBAL)
+$ SAY := "WRITE_ SYS$OUTPUT"
+$
+$ IF F$SEARCH("''P1'") .EQS. ""
+$ THEN
+$ SAY " ANALYZE_MAP.COM: Error, no mapfile provided"
+$ EXIT_
+$ ENDIF
+$ IF "''P2'" .EQS. ""
+$ THEN
+$ SAY " ANALYZE_MAP.COM: Error, no output file provided"
+$ EXIT_
+$ ENDIF
+$
+$ LINK_TMP = F$PARSE(P2,,,"DEVICE")+F$PARSE(P2,,,"DIRECTORY")+F$PARSE(P2,,,"NAME")+".TMP"
+$
+$ SAY " checking PSECT list in ''P2'"
+$ OPEN_/READ IN 'P1'
+$ LOOP_PSECT_SEARCH:
+$ READ_/END=EOF_PSECT IN REC
+$ LOOP_PSECT_SEARCH0:
+$ if F$EXTRACT(0,5,REC) .eqs. "$DATA" .or. F$EXTRACT(0,5,REC) .eqs. -
+ "$BSS$" .or. f$extract(0,10,rec) .eqs. "$READONLY$" then goto do_data
+$ if F$EXTRACT(0,14,REC) .eqs. "$READONLY_ADDR" then goto do_readonly
+$ goto LOOP_PSECT_SEARCH
+$ do_data:
+$ LAST = ""
+$ LOOP_PSECT:
+$ READ_/END=EOF_PSECT IN REC
+$ if F$EXTRACT(0,1,REC) .eqs. "$" .and. F$EXTRACT(0,5,REC) .nes. "$DATA" -
+ .and. F$EXTRACT(0,5,REC) .nes. "$BSS$" .and. f$extract(0,10,rec) -
+ .nes. "$READONLY$" then goto LOOP_PSECT_SEARCH0
+$ if REC - "NOPIC,OVR,REL,GBL,NOSHR,NOEXE, WRT,NOVEC" .nes. REC
+$ then
+$ J = F$LOCATE(" ",REC)
+$ S = F$EXTRACT(0,J,REC)
+$ IF S .EQS. LAST THEN GOTO LOOP_PSECT
+$ P$_'S= 1
+$ LAST = S
+$ endif
+$ if REC - "NOPIC,OVR,REL,GBL,NOSHR,NOEXE,NOWRT,NOVEC" .nes. REC
+$ then
+$ J = F$LOCATE(" ",REC)
+$ S = F$EXTRACT(0,J,REC)
+$ IF S .EQS. LAST THEN GOTO LOOP_PSECT
+$ P$_'S= 1
+$ LAST = S
+$ endif
+$ GOTO LOOP_PSECT
+$
+$ do_readonly:
+$ LAST = ""
+$ LOOP_PSECT3:
+$ READ_/END=EOF_PSECT IN REC
+$ if F$EXTRACT(0,1,REC) .eqs. "-" .or. F$EXTRACT(0,3,REC) .eqs. "NL:" then -
+ goto loop_psect3
+$ if F$EXTRACT(0,1,REC) .eqs. "$" .and. F$EXTRACT(0,14,REC) .nes. -
+ "$READONLY_ADDR" then goto LOOP_PSECT_SEARCH0
+$ if REC - "OCTA" .nes. REC
+$ then
+$ J = F$LOCATE(" ",REC)
+$ S = F$EXTRACT(0,J,REC)
+$ IF S .EQS. LAST THEN GOTO LOOP_PSECT3
+$ P$_'S= 1
+$ LAST = S
+$ endif
+$ GOTO LOOP_PSECT3
+$
+$ EOF_PSECT:
+$ CLOSE_ IN
+$
+$ SAY " appending list of UNIVERSAL procedures to ''P2'"
+$ SEARCH_/NOHIGH/WINDOW=(0,0) 'P1' " R-"/OUT='LINK_TMP
+$ OPEN_/READ IN 'LINK_TMP
+$ OPEN_/write OUT 'P2'
+$ WRITE_ OUT "!"
+$ WRITE_ OUT "! ### UNIVERSAL procedures and global definitions extracted from ''P1'"
+$ WRITE_ OUT "!"
+$ write_ OUT "case_sensitive=YES"
+$ LOOP_UNIVERSAL:
+$ READ_/END=EOF_UNIVERSAL IN REC
+$ J = F$LOCATE(" R-",REC)
+$ S = F$EXTRACT(J+3,F$length(rec),REC)
+$ J = F$LOCATE(" ",S)
+$ S = F$EXTRACT(0,J,S)
+$ PP$_'S= 1
+$ IF F$TYPE(P$_'S').EQS.""
+$ THEN
+$ WRITE_ OUT "symbol_vector = ("+S+" = PROCEDURE)"
+$ ELSE
+$ WRITE_ OUT "symbol_vector = ("+S+" = DATA)"
+$ ENDIF
+$ GOTO LOOP_UNIVERSAL
+$ EOF_UNIVERSAL:
+$ CLOSE_ IN
+$ CLOSE_ OUT
+$!
+$ SAY " creating PSECT list in ''P2'"
+$ OPEN_/READ IN 'P1'
+$ OPEN_/append OUT 'P2'
+$ WRITE_ OUT "!"
+$ WRITE_ OUT "! ### PSECT list extracted from ''P1'"
+$ WRITE_ OUT "!"
+$ LOOP_PSECT_SEARCH1:
+$ READ_/END=EOF_PSECT1 IN REC
+$ if F$EXTRACT(0,5,REC) .nes. "$DATA" .and. F$EXTRACT(0,5,REC) .nes. -
+ "$BSS$" .and. f$extract(0,10,rec) .nes. "$READONLY$" then goto -
+ LOOP_PSECT_SEARCH1
+$ LAST = ""
+$ LOOP_PSECT1:
+$ READ_/END=EOF_PSECT1 IN REC
+$ if F$EXTRACT(0,1,REC) .eqs. "$" .and. F$EXTRACT(0,5,REC) .nes. "$DATA" -
+ .and. F$EXTRACT(0,5,REC) .nes. "$BSS$" .and. f$extract(0,10,rec) -
+ .nes. "$READONLY$" then goto LOOP_PSECT_SEARCH1
+$ if REC - "NOPIC,OVR,REL,GBL,NOSHR,NOEXE, WRT,NOVEC" .nes. REC
+$ then
+$ J = F$LOCATE(" ",REC)
+$ S = F$EXTRACT(0,J,REC)
+$ IF S .EQS. LAST THEN GOTO LOOP_PSECT1
+$ IF F$TYPE(PP$_'S').nes."" then WRITE_ OUT "symbol_vector = (" + S + " = PSECT)"
+$ P$_'S= 1
+$ LAST = S
+$ endif
+$ if REC - "NOPIC,OVR,REL,GBL,NOSHR,NOEXE,NOWRT,NOVEC" .nes. REC
+$ then
+$ J = F$LOCATE(" ",REC)
+$ S = F$EXTRACT(0,J,REC)
+$ IF S .EQS. LAST THEN GOTO LOOP_PSECT1
+$ IF F$TYPE(PP$_'S').nes."" then WRITE_ OUT "symbol_vector = (" + S + " = PSECT)"
+$ P$_'S= 1
+$ LAST = S
+$ endif
+$ GOTO LOOP_PSECT1
+$
+$ EOF_PSECT1:
+$ CLOSE_ IN
+$ CLOSE_ OUT
+$ if f$search("''LINK_TMP'") .nes. "" then DELETE_/NOLOG/NOCONFIRM 'LINK_TMP';*
+$
+$ EXIT_
diff --git a/nx-X11/extras/Mesa/vms/xlib.opt b/nx-X11/extras/Mesa/vms/xlib.opt
new file mode 100644
index 000000000..acae358b5
--- /dev/null
+++ b/nx-X11/extras/Mesa/vms/xlib.opt
@@ -0,0 +1,2 @@
+sys$library:decw$xlibshr.exe/share
+sys$library:decw$xmulibshr.exe/share
diff --git a/nx-X11/extras/Mesa/vms/xlib_share.opt b/nx-X11/extras/Mesa/vms/xlib_share.opt
new file mode 100644
index 000000000..ebe039f01
--- /dev/null
+++ b/nx-X11/extras/Mesa/vms/xlib_share.opt
@@ -0,0 +1,7 @@
+[--.lib]libmesagl.exe/share
+[--.lib]libmesaglu.exe/share
+[--.lib]libglut.exe/share
+sys$library:decw$xlibshr.exe/share
+sys$library:decw$xmulibshr.exe/share
+sys$library:decw$xmlibshr12/share
+sys$library:decw$xtlibshrr5/share
diff --git a/nx-X11/extras/Mesa/windows/VC6/mesa/gdi/gdi.dsp b/nx-X11/extras/Mesa/windows/VC6/mesa/gdi/gdi.dsp
new file mode 100644
index 000000000..03389a66d
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC6/mesa/gdi/gdi.dsp
@@ -0,0 +1,141 @@
+# Microsoft Developer Studio Project File - Name="gdi" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=gdi - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "gdi.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "gdi.mak" CFG="gdi - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "gdi - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "gdi - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "gdi - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GDI_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../main" /I "../../../../include" /I "../../../../src/mesa" /I "../../../../src/mesa/main" /I "../../../../src/mesa/glapi" /I "../../../../src/mesa/swrast" /I "../../../../src/mesa/shader" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GDI_EXPORTS" /D "_DLL" /D "BUILD_GL32" /D "MESA_MINWARN" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 mesa.lib winmm.lib msvcrt.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /nodefaultlib /out:"Release/OPENGL32.DLL" /libpath:"../mesa/Release"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=if not exist ..\..\..\..\lib md ..\..\..\..\lib copy Release\OPENGL32.LIB ..\..\..\..\lib copy Release\OPENGL32.DLL ..\..\..\..\lib if exist ..\..\..\..\progs\demos copy Release\OPENGL32.DLL ..\..\..\..\progs\demos
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "gdi - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GDI_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "../../../../include" /I "../../../../src/mesa" /I "../../../../src/mesa/main" /I "../../../../src/mesa/glapi" /I "../../../../src/mesa/swrast" /I "../../../../src/mesa/shader" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GDI_EXPORTS" /D "_DLL" /D "BUILD_GL32" /D "MESA_MINWARN" /FR /FD /GZ /c
+# SUBTRACT CPP /YX /Yc /Yu
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 mesa.lib winmm.lib msvcrtd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /nodefaultlib /out:"Debug/OPENGL32.DLL" /pdbtype:sept /libpath:"../mesa/Debug"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=if not exist ..\..\..\..\lib md ..\..\..\..\lib copy Debug\OPENGL32.LIB ..\..\..\..\lib copy Debug\OPENGL32.DLL ..\..\..\..\lib if exist ..\..\..\..\progs\demos copy Debug\OPENGL32.DLL ..\..\..\..\progs\demos
+# End Special Build Tool
+
+!ENDIF
+
+# Begin Target
+
+# Name "gdi - Win32 Release"
+# Name "gdi - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\drivers\common\driverfuncs.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\drivers\windows\gdi\mesa.def
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\drivers\windows\gdi\wgl.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\drivers\windows\gdi\wmesa.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\drivers\windows\gdi\colors.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\drivers\common\driverfuncs.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\drivers\windows\gdi\wmesadef.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/nx-X11/extras/Mesa/windows/VC6/mesa/glu/compileDebug.txt b/nx-X11/extras/Mesa/windows/VC6/mesa/glu/compileDebug.txt
new file mode 100644
index 000000000..d14930224
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC6/mesa/glu/compileDebug.txt
@@ -0,0 +1,82 @@
+/nologo /W2 /GX- /Zi /Od /c /TP
+/I "../../../../include"
+/I "../../../../src/glu/sgi/include"
+/I "../../../../src/glu/sgi/libnurbs/interface"
+/I "../../../../src/glu/sgi/libnurbs/internals"
+/I "../../../../src/glu/sgi/libnurbs/nurbtess"
+/D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS"
+/D "_USRDLL" /D "GLU_EXPORTS" /D "BUILD_GL32" /D "LIBRARYBUILD"
+/Fo"Debug/" /Fd"Debug/" /GZ
+../../../../src/glu/sgi/libnurbs/interface/bezierEval.cc
+../../../../src/glu/sgi/libnurbs/interface/bezierPatch.cc
+../../../../src/glu/sgi/libnurbs/interface/bezierPatchMesh.cc
+../../../../src/glu/sgi/libnurbs/interface/glcurveval.cc
+../../../../src/glu/sgi/libnurbs/interface/glinterface.cc
+../../../../src/glu/sgi/libnurbs/interface/glrenderer.cc
+../../../../src/glu/sgi/libnurbs/interface/glsurfeval.cc
+../../../../src/glu/sgi/libnurbs/interface/incurveeval.cc
+../../../../src/glu/sgi/libnurbs/interface/insurfeval.cc
+../../../../src/glu/sgi/libnurbs/internals/arc.cc
+../../../../src/glu/sgi/libnurbs/internals/arcsorter.cc
+../../../../src/glu/sgi/libnurbs/internals/arctess.cc
+../../../../src/glu/sgi/libnurbs/internals/backend.cc
+../../../../src/glu/sgi/libnurbs/internals/basiccrveval.cc
+../../../../src/glu/sgi/libnurbs/internals/basicsurfeval.cc
+../../../../src/glu/sgi/libnurbs/internals/bin.cc
+../../../../src/glu/sgi/libnurbs/internals/bufpool.cc
+../../../../src/glu/sgi/libnurbs/internals/cachingeval.cc
+../../../../src/glu/sgi/libnurbs/internals/ccw.cc
+../../../../src/glu/sgi/libnurbs/internals/coveandtiler.cc
+../../../../src/glu/sgi/libnurbs/internals/curve.cc
+../../../../src/glu/sgi/libnurbs/internals/curvelist.cc
+../../../../src/glu/sgi/libnurbs/internals/curvesub.cc
+../../../../src/glu/sgi/libnurbs/internals/dataTransform.cc
+../../../../src/glu/sgi/libnurbs/internals/displaylist.cc
+../../../../src/glu/sgi/libnurbs/internals/flist.cc
+../../../../src/glu/sgi/libnurbs/internals/flistsorter.cc
+../../../../src/glu/sgi/libnurbs/internals/hull.cc
+../../../../src/glu/sgi/libnurbs/internals/intersect.cc
+../../../../src/glu/sgi/libnurbs/internals/knotvector.cc
+../../../../src/glu/sgi/libnurbs/internals/mapdesc.cc
+../../../../src/glu/sgi/libnurbs/internals/mapdescv.cc
+../../../../src/glu/sgi/libnurbs/internals/maplist.cc
+../../../../src/glu/sgi/libnurbs/internals/mesher.cc
+../../../../src/glu/sgi/libnurbs/internals/monoTriangulationBackend.cc
+../../../../src/glu/sgi/libnurbs/internals/monotonizer.cc
+../../../../src/glu/sgi/libnurbs/internals/mycode.cc
+../../../../src/glu/sgi/libnurbs/internals/nurbsinterfac.cc
+../../../../src/glu/sgi/libnurbs/internals/nurbstess.cc
+../../../../src/glu/sgi/libnurbs/internals/patch.cc
+../../../../src/glu/sgi/libnurbs/internals/patchlist.cc
+../../../../src/glu/sgi/libnurbs/internals/quilt.cc
+../../../../src/glu/sgi/libnurbs/internals/reader.cc
+../../../../src/glu/sgi/libnurbs/internals/renderhints.cc
+../../../../src/glu/sgi/libnurbs/internals/slicer.cc
+../../../../src/glu/sgi/libnurbs/internals/sorter.cc
+../../../../src/glu/sgi/libnurbs/internals/splitarcs.cc
+../../../../src/glu/sgi/libnurbs/internals/subdivider.cc
+../../../../src/glu/sgi/libnurbs/internals/tobezier.cc
+../../../../src/glu/sgi/libnurbs/internals/trimline.cc
+../../../../src/glu/sgi/libnurbs/internals/trimregion.cc
+../../../../src/glu/sgi/libnurbs/internals/trimvertpool.cc
+../../../../src/glu/sgi/libnurbs/internals/uarray.cc
+../../../../src/glu/sgi/libnurbs/internals/varray.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/directedLine.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/gridWrap.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/monoChain.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/monoPolyPart.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/monoTriangulation.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/partitionX.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/partitionY.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/polyDBG.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/polyUtil.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/primitiveStream.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/quicksort.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/rectBlock.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/sampleComp.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/sampleCompBot.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/sampleCompRight.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/sampleCompTop.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/sampleMonoPoly.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/sampledLine.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/searchTree.cc
diff --git a/nx-X11/extras/Mesa/windows/VC6/mesa/glu/compileRelease.txt b/nx-X11/extras/Mesa/windows/VC6/mesa/glu/compileRelease.txt
new file mode 100644
index 000000000..7f41952bd
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC6/mesa/glu/compileRelease.txt
@@ -0,0 +1,82 @@
+/nologo /W2 /GX- /O2 /c /TP
+/I "../../../../include"
+/I "../../../../src/glu/sgi/include"
+/I "../../../../src/glu/sgi/libnurbs/interface"
+/I "../../../../src/glu/sgi/libnurbs/internals"
+/I "../../../../src/glu/sgi/libnurbs/nurbtess"
+/D "WIN32" /D "_WINDOWS" /D "_MBCS"
+/D "_USRDLL" /D "GLU_EXPORTS" /D "BUILD_GL32" /D "LIBRARYBUILD"
+/Fo"Release/"
+../../../../src/glu/sgi/libnurbs/interface/bezierEval.cc
+../../../../src/glu/sgi/libnurbs/interface/bezierPatch.cc
+../../../../src/glu/sgi/libnurbs/interface/bezierPatchMesh.cc
+../../../../src/glu/sgi/libnurbs/interface/glcurveval.cc
+../../../../src/glu/sgi/libnurbs/interface/glinterface.cc
+../../../../src/glu/sgi/libnurbs/interface/glrenderer.cc
+../../../../src/glu/sgi/libnurbs/interface/glsurfeval.cc
+../../../../src/glu/sgi/libnurbs/interface/incurveeval.cc
+../../../../src/glu/sgi/libnurbs/interface/insurfeval.cc
+../../../../src/glu/sgi/libnurbs/internals/arc.cc
+../../../../src/glu/sgi/libnurbs/internals/arcsorter.cc
+../../../../src/glu/sgi/libnurbs/internals/arctess.cc
+../../../../src/glu/sgi/libnurbs/internals/backend.cc
+../../../../src/glu/sgi/libnurbs/internals/basiccrveval.cc
+../../../../src/glu/sgi/libnurbs/internals/basicsurfeval.cc
+../../../../src/glu/sgi/libnurbs/internals/bin.cc
+../../../../src/glu/sgi/libnurbs/internals/bufpool.cc
+../../../../src/glu/sgi/libnurbs/internals/cachingeval.cc
+../../../../src/glu/sgi/libnurbs/internals/ccw.cc
+../../../../src/glu/sgi/libnurbs/internals/coveandtiler.cc
+../../../../src/glu/sgi/libnurbs/internals/curve.cc
+../../../../src/glu/sgi/libnurbs/internals/curvelist.cc
+../../../../src/glu/sgi/libnurbs/internals/curvesub.cc
+../../../../src/glu/sgi/libnurbs/internals/dataTransform.cc
+../../../../src/glu/sgi/libnurbs/internals/displaylist.cc
+../../../../src/glu/sgi/libnurbs/internals/flist.cc
+../../../../src/glu/sgi/libnurbs/internals/flistsorter.cc
+../../../../src/glu/sgi/libnurbs/internals/hull.cc
+../../../../src/glu/sgi/libnurbs/internals/intersect.cc
+../../../../src/glu/sgi/libnurbs/internals/knotvector.cc
+../../../../src/glu/sgi/libnurbs/internals/mapdesc.cc
+../../../../src/glu/sgi/libnurbs/internals/mapdescv.cc
+../../../../src/glu/sgi/libnurbs/internals/maplist.cc
+../../../../src/glu/sgi/libnurbs/internals/mesher.cc
+../../../../src/glu/sgi/libnurbs/internals/monoTriangulationBackend.cc
+../../../../src/glu/sgi/libnurbs/internals/monotonizer.cc
+../../../../src/glu/sgi/libnurbs/internals/mycode.cc
+../../../../src/glu/sgi/libnurbs/internals/nurbsinterfac.cc
+../../../../src/glu/sgi/libnurbs/internals/nurbstess.cc
+../../../../src/glu/sgi/libnurbs/internals/patch.cc
+../../../../src/glu/sgi/libnurbs/internals/patchlist.cc
+../../../../src/glu/sgi/libnurbs/internals/quilt.cc
+../../../../src/glu/sgi/libnurbs/internals/reader.cc
+../../../../src/glu/sgi/libnurbs/internals/renderhints.cc
+../../../../src/glu/sgi/libnurbs/internals/slicer.cc
+../../../../src/glu/sgi/libnurbs/internals/sorter.cc
+../../../../src/glu/sgi/libnurbs/internals/splitarcs.cc
+../../../../src/glu/sgi/libnurbs/internals/subdivider.cc
+../../../../src/glu/sgi/libnurbs/internals/tobezier.cc
+../../../../src/glu/sgi/libnurbs/internals/trimline.cc
+../../../../src/glu/sgi/libnurbs/internals/trimregion.cc
+../../../../src/glu/sgi/libnurbs/internals/trimvertpool.cc
+../../../../src/glu/sgi/libnurbs/internals/uarray.cc
+../../../../src/glu/sgi/libnurbs/internals/varray.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/directedLine.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/gridWrap.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/monoChain.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/monoPolyPart.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/monoTriangulation.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/partitionX.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/partitionY.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/polyDBG.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/polyUtil.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/primitiveStream.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/quicksort.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/rectBlock.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/sampleComp.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/sampleCompBot.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/sampleCompRight.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/sampleCompTop.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/sampleMonoPoly.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/sampledLine.cc
+../../../../src/glu/sgi/libnurbs/nurbtess/searchTree.cc
diff --git a/nx-X11/extras/Mesa/windows/VC6/mesa/glu/glu.dsp b/nx-X11/extras/Mesa/windows/VC6/mesa/glu/glu.dsp
new file mode 100644
index 000000000..da035e998
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC6/mesa/glu/glu.dsp
@@ -0,0 +1,985 @@
+# Microsoft Developer Studio Project File - Name="glu" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=glu - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "glu.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "glu.mak" CFG="glu - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "glu - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "glu - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "glu - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GLU_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../../../include" /I "../../../../src/glu/sgi/include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GLU_EXPORTS" /D "BUILD_GL32" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 msvcrt.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib Release/glucc.lib /nologo /dll /machine:I386 /nodefaultlib /out:"Release/GLU32.DLL" /libpath:"../gdi/Release"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PreLink_Desc=C++ Compilations
+PreLink_Cmds=cl @compileRelease.txt LIB /OUT:Release/GLUCC.LIB @objectsRelease.txt
+PostBuild_Cmds=if not exist ..\..\..\..\lib md ..\..\..\..\lib copy Release\GLU32.LIB ..\..\..\..\lib copy Release\GLU32.DLL ..\..\..\..\lib if exist ..\..\..\..\progs\demos copy Release\GLU32.DLL ..\..\..\..\progs\demos
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "glu - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GLU_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "../../../../include" /I "../../../../src/glu/sgi/include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GLU_EXPORTS" /D "BUILD_GL32" /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 msvcrtd.lib winmm.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib Debug/glucc.lib /nologo /dll /incremental:no /debug /machine:I386 /nodefaultlib /out:"Debug/GLU32.DLL" /pdbtype:sept /libpath:"../gdi/Debug"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PreLink_Desc=C++ Compilations
+PreLink_Cmds=cl @compileDebug.txt LIB /OUT:Debug/GLUCC.LIB @objectsDebug.txt
+PostBuild_Cmds=if not exist ..\..\..\..\lib md ..\..\..\..\lib copy Debug\GLU32.LIB ..\..\..\..\lib copy Debug\GLU32.DLL ..\..\..\..\lib if exist ..\..\..\..\progs\demos copy Debug\GLU32.DLL ..\..\..\..\progs\demos
+# End Special Build Tool
+
+!ENDIF
+
+# Begin Target
+
+# Name "glu - Win32 Release"
+# Name "glu - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\dict.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libutil\error.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\geom.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\glu.def
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libutil\glue.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\memalloc.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\mesh.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libutil\mipmap.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\normal.c
+# End Source File
+# Begin Source File
+
+SOURCE="..\..\..\..\src\glu\sgi\libtess\priorityq-heap.c"
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\priorityq.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libutil\project.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libutil\quad.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libutil\registry.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\render.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\sweep.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\tess.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\tessmono.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\arc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\arcsorter.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\arctess.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\backend.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\basiccrveval.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\basicsurfeval.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\bezierarc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\bezierEval.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\bezierPatch.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\bezierPatchMesh.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\bin.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\bufpool.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\cachingeval.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\coveandtiler.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\curve.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\curvelist.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\dataTransform.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\defines.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\definitions.h
+# End Source File
+# Begin Source File
+
+SOURCE="..\..\..\..\src\glu\sgi\libtess\dict-list.h"
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\dict.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\directedLine.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\displaylist.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\displaymode.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\flist.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\flistsorter.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\geom.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\glcurveval.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\glimports.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\glimports.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\glrenderer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\glsurfeval.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libutil\gluint.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\include\gluos.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\gridline.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\gridtrimvertex.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\gridvertex.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\gridWrap.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\hull.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\jarcloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\knotvector.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\mapdesc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\maplist.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\memalloc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\mesh.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\mesher.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoChain.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoPolyPart.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\monotonizer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoTriangulation.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\myassert.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\mymath.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\mysetjmp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\mystdio.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\mystdio.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\mystdlib.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\mystdlib.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\mystring.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\normal.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\nurbsconsts.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\nurbstess.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\partitionX.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\partitionY.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\patch.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\patchlist.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\polyDBG.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\polyUtil.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\primitiveStream.h
+# End Source File
+# Begin Source File
+
+SOURCE="..\..\..\..\src\glu\sgi\libtess\priorityq-heap.h"
+# End Source File
+# Begin Source File
+
+SOURCE="..\..\..\..\src\glu\sgi\libtess\priorityq-sort.h"
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\priorityq.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\pwlarc.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\quicksort.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\quilt.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\reader.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\rectBlock.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\render.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\renderhints.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleComp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompBot.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompRight.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompTop.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampledLine.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleMonoPoly.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\searchTree.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\simplemath.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\slicer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\sorter.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\subdivider.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\sweep.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\tess.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\tessmono.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\trimline.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\trimregion.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\trimvertex.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\trimvertpool.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\types.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\uarray.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\varray.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\zlassert.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# Begin Group "C++ files"
+
+# PROP Default_Filter ".cc"
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\arc.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\arcsorter.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\arctess.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\backend.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\basiccrveval.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\basicsurfeval.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\bezierEval.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\bezierPatch.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\bezierPatchMesh.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\bin.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\bufpool.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\cachingeval.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\ccw.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\coveandtiler.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\curve.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\curvelist.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\curvesub.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\dataTransform.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\directedLine.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\displaylist.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\flist.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\flistsorter.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\glcurveval.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\glinterface.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\glrenderer.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\glsurfeval.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\gridWrap.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\hull.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\incurveeval.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\interface\insurfeval.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\intersect.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\knotvector.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\mapdesc.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\mapdescv.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\maplist.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\mesher.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoChain.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoPolyPart.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\monotonizer.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoTriangulation.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\monoTriangulationBackend.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\mycode.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\nurbsinterfac.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\nurbstess.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\partitionX.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\partitionY.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\patch.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\patchlist.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\polyDBG.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\polyUtil.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\primitiveStream.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\quicksort.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\quilt.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\reader.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libtess\README
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\rectBlock.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\renderhints.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleComp.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompBot.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompRight.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompTop.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampledLine.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleMonoPoly.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\nurbtess\searchTree.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\slicer.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\sorter.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\splitarcs.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\subdivider.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\tobezier.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\trimline.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\trimregion.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\trimvertpool.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\uarray.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glu\sgi\libnurbs\internals\varray.cc
+# PROP Exclude_From_Build 1
+# End Source File
+# End Group
+# Begin Source File
+
+SOURCE="..\..\..\..\src\glu\sgi\libtess\alg-outline"
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=.\compileDebug.txt
+# End Source File
+# Begin Source File
+
+SOURCE=.\compileRelease.txt
+# End Source File
+# Begin Source File
+
+SOURCE=.\objectsDebug.txt
+# End Source File
+# Begin Source File
+
+SOURCE=.\objectsRelease.txt
+# End Source File
+# End Target
+# End Project
diff --git a/nx-X11/extras/Mesa/windows/VC6/mesa/glu/objectsDebug.txt b/nx-X11/extras/Mesa/windows/VC6/mesa/glu/objectsDebug.txt
new file mode 100644
index 000000000..9fdce157c
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC6/mesa/glu/objectsDebug.txt
@@ -0,0 +1,73 @@
+Debug/bezierEval.obj
+Debug/bezierPatch.obj
+Debug/bezierPatchMesh.obj
+Debug/glcurveval.obj
+Debug/glinterface.obj
+Debug/glrenderer.obj
+Debug/glsurfeval.obj
+Debug/incurveeval.obj
+Debug/insurfeval.obj
+Debug/arc.obj
+Debug/arcsorter.obj
+Debug/arctess.obj
+Debug/backend.obj
+Debug/basiccrveval.obj
+Debug/basicsurfeval.obj
+Debug/bin.obj
+Debug/bufpool.obj
+Debug/cachingeval.obj
+Debug/ccw.obj
+Debug/coveandtiler.obj
+Debug/curve.obj
+Debug/curvelist.obj
+Debug/curvesub.obj
+Debug/dataTransform.obj
+Debug/displaylist.obj
+Debug/flist.obj
+Debug/flistsorter.obj
+Debug/hull.obj
+Debug/intersect.obj
+Debug/knotvector.obj
+Debug/mapdesc.obj
+Debug/mapdescv.obj
+Debug/maplist.obj
+Debug/mesher.obj
+Debug/monoTriangulationBackend.obj
+Debug/monotonizer.obj
+Debug/mycode.obj
+Debug/nurbsinterfac.obj
+Debug/nurbstess.obj
+Debug/patch.obj
+Debug/patchlist.obj
+Debug/quilt.obj
+Debug/reader.obj
+Debug/renderhints.obj
+Debug/slicer.obj
+Debug/sorter.obj
+Debug/splitarcs.obj
+Debug/subdivider.obj
+Debug/tobezier.obj
+Debug/trimline.obj
+Debug/trimregion.obj
+Debug/trimvertpool.obj
+Debug/uarray.obj
+Debug/varray.obj
+Debug/directedLine.obj
+Debug/gridWrap.obj
+Debug/monoChain.obj
+Debug/monoPolyPart.obj
+Debug/monoTriangulation.obj
+Debug/partitionX.obj
+Debug/partitionY.obj
+Debug/polyDBG.obj
+Debug/polyUtil.obj
+Debug/primitiveStream.obj
+Debug/quicksort.obj
+Debug/rectBlock.obj
+Debug/sampleComp.obj
+Debug/sampleCompBot.obj
+Debug/sampleCompRight.obj
+Debug/sampleCompTop.obj
+Debug/sampleMonoPoly.obj
+Debug/sampledLine.obj
+Debug/searchTree.obj
diff --git a/nx-X11/extras/Mesa/windows/VC6/mesa/glu/objectsRelease.txt b/nx-X11/extras/Mesa/windows/VC6/mesa/glu/objectsRelease.txt
new file mode 100644
index 000000000..2d1b384db
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC6/mesa/glu/objectsRelease.txt
@@ -0,0 +1,73 @@
+Release/bezierEval.obj
+Release/bezierPatch.obj
+Release/bezierPatchMesh.obj
+Release/glcurveval.obj
+Release/glinterface.obj
+Release/glrenderer.obj
+Release/glsurfeval.obj
+Release/incurveeval.obj
+Release/insurfeval.obj
+Release/arc.obj
+Release/arcsorter.obj
+Release/arctess.obj
+Release/backend.obj
+Release/basiccrveval.obj
+Release/basicsurfeval.obj
+Release/bin.obj
+Release/bufpool.obj
+Release/cachingeval.obj
+Release/ccw.obj
+Release/coveandtiler.obj
+Release/curve.obj
+Release/curvelist.obj
+Release/curvesub.obj
+Release/dataTransform.obj
+Release/displaylist.obj
+Release/flist.obj
+Release/flistsorter.obj
+Release/hull.obj
+Release/intersect.obj
+Release/knotvector.obj
+Release/mapdesc.obj
+Release/mapdescv.obj
+Release/maplist.obj
+Release/mesher.obj
+Release/monoTriangulationBackend.obj
+Release/monotonizer.obj
+Release/mycode.obj
+Release/nurbsinterfac.obj
+Release/nurbstess.obj
+Release/patch.obj
+Release/patchlist.obj
+Release/quilt.obj
+Release/reader.obj
+Release/renderhints.obj
+Release/slicer.obj
+Release/sorter.obj
+Release/splitarcs.obj
+Release/subdivider.obj
+Release/tobezier.obj
+Release/trimline.obj
+Release/trimregion.obj
+Release/trimvertpool.obj
+Release/uarray.obj
+Release/varray.obj
+Release/directedLine.obj
+Release/gridWrap.obj
+Release/monoChain.obj
+Release/monoPolyPart.obj
+Release/monoTriangulation.obj
+Release/partitionX.obj
+Release/partitionY.obj
+Release/polyDBG.obj
+Release/polyUtil.obj
+Release/primitiveStream.obj
+Release/quicksort.obj
+Release/rectBlock.obj
+Release/sampleComp.obj
+Release/sampleCompBot.obj
+Release/sampleCompRight.obj
+Release/sampleCompTop.obj
+Release/sampleMonoPoly.obj
+Release/sampledLine.obj
+Release/searchTree.obj
diff --git a/nx-X11/extras/Mesa/windows/VC6/mesa/mesa.dsw b/nx-X11/extras/Mesa/windows/VC6/mesa/mesa.dsw
new file mode 100644
index 000000000..a6da850c1
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC6/mesa/mesa.dsw
@@ -0,0 +1,74 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "gdi"=.\gdi\gdi.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name mesa
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "glu"=.\glu\glu.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name gdi
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Project: "mesa"=.\mesa\mesa.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "osmesa"=.\osmesa\osmesa.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+ Begin Project Dependency
+ Project_Dep_Name gdi
+ End Project Dependency
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/nx-X11/extras/Mesa/windows/VC6/mesa/mesa/mesa.dsp b/nx-X11/extras/Mesa/windows/VC6/mesa/mesa/mesa.dsp
new file mode 100644
index 000000000..ecdacef22
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC6/mesa/mesa/mesa.dsp
@@ -0,0 +1,1350 @@
+# Microsoft Developer Studio Project File - Name="mesa" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=mesa - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "mesa.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "mesa.mak" CFG="mesa - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "mesa - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "mesa - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "mesa - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "../../../../include" /I "../../../../src/mesa" /I "../../../../src/mesa/glapi" /I "../../../../src/mesa/main" /I "../../../../src/mesa/shader" /I "../../../../src/mesa/shader/slang" /I "../../../../src/mesa/shader/grammar" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "_DLL" /D "BUILD_GL32" /D "MESA_MINWARN" /YX /FD /Zm1000 /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ELSEIF "$(CFG)" == "mesa - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "../../../../include" /I "../../../../src/mesa" /I "../../../../src/mesa/glapi" /I "../../../../src/mesa/main" /I "../../../../src/mesa/shader" /I "../../../../src/mesa/shader/slang" /I "../../../../src/mesa/shader/grammar" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "_DLL" /D "BUILD_GL32" /D "MESA_MINWARN" /Fr /FD /GZ /Zm1000 /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+
+!ENDIF
+
+# Begin Target
+
+# Name "mesa - Win32 Release"
+# Name "mesa - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\array_cache\ac_context.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\array_cache\ac_import.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\accum.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\api_arrayelt.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\api_loopback.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\api_noop.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\api_validate.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\arbfragparse.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\arbprogparse.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\arbprogram.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\arbvertparse.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\atifragshader.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\attrib.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\blend.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\bufferobj.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\buffers.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\clip.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\colortab.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\context.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\convolve.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\debug.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\depth.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\dispatch.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\dlist.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\drawpix.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\enable.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\enums.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\eval.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\extensions.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\execmem.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\fbobject.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\feedback.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\fog.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\framebuffer.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\get.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\getstring.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\glapi\glapi.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\glapi\glthread.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\grammar\grammar.c
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\grammar\grammar_mesa.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\hash.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\hint.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\histogram.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\image.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\imports.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\light.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\lines.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_debug_clip.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_debug_norm.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_debug_xform.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_eval.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_matrix.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_translate.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_vector.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_xform.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\matrix.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\mm.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\nvfragparse.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\nvprogram.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\nvvertexec.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\nvvertparse.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\occlude.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\pixel.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\points.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\polygon.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\program.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\rastpos.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\renderbuffer.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_aaline.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_aatriangle.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_accum.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_alpha.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_atifragshader.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_bitmap.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_blend.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_buffers.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_context.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_copypix.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_depth.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_drawpix.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_feedback.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_fog.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_imaging.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_lines.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_logic.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_masking.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_nvfragprog.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_pixeltex.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_points.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_readpix.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_span.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_stencil.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_texstore.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_texture.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_triangle.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_zoom.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\shaderobjects.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\shaderobjects_3dlabs.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_assemble.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_assemble_assignment.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_assemble_conditional.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_assemble_constructor.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_assemble_typeinfo.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_compile.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_execute.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_preprocess.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_storage.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_utility.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast_setup\ss_context.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast_setup\ss_triangle.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\state.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\stencil.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_array_api.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_array_import.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_context.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_pipeline.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_save_api.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_save_loopback.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_save_playback.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vb_arbprogram.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vb_cull.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vb_fog.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vb_light.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vb_normals.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vb_points.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vb_program.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vb_render.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vb_texgen.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vb_texmat.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vb_vertex.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vertex.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vertex_generic.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vp_build.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vtx_api.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vtx_eval.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vtx_exec.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vtx_generic.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\texcompress.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\texcompress_fxt1.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\texcompress_s3tc.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\texenvprogram.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\texformat.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\teximage.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\texobj.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\texrender.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\texstate.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\texstore.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\varray.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\vsnprintf.c
+# PROP Exclude_From_Build 1
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\vtxfmt.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\array_cache\ac_context.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\array_cache\acache.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\accum.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\api_arrayelt.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\api_eval.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\api_loopback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\api_noop.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\api_validate.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\arbfragparse.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\arbprogparse.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\arbprogram.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\arbprogram_syn.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\arbvertparse.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\atifragshader.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\attrib.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\blend.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\bufferobj.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\buffers.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\clip.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\colormac.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\colortab.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\config.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\context.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\convolve.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\dd.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\debug.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\depth.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\dlist.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\drawpix.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\enable.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\enums.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\eval.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\extensions.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\fbobject.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\feedback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\fog.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\framebuffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\get.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\glapi\glapi.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\glapi\glapioffsets.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\glapi\glapitable.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\glapi\glapitemp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\glheader.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\glapi\glprocs.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\glapi\glthread.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\grammar\grammar.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\grammar\grammar_mesa.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\grammar\grammar_syn.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\hash.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\hint.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\histogram.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\image.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\imports.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\light.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\lines.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_clip_tmp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_copy_tmp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_debug.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_debug_util.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_dotprod_tmp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_eval.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_matrix.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_norm_tmp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_trans_tmp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_translate.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_vector.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_xform.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\m_xform_tmp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\macros.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\math\mathmod.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\matrix.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\mm.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\mtypes.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\nvfragparse.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\nvfragprog.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\nvprogram.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\nvvertexec.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\nvvertparse.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\nvvertprog.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\occlude.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\pixel.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\points.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\polygon.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\program.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\rastpos.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\renderbuffer.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_aaline.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_aalinetemp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_aatriangle.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_aatritemp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_accum.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_alpha.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_atifragshader.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_blend.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_context.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_depth.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_drawpix.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_feedback.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_fog.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_lines.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_linetemp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_logic.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_masking.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_nvfragprog.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_pixeltex.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_points.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_pointtemp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_span.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_spantemp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_stencil.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_texture.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_triangle.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_trispan.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_tritemp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\s_zoom.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\shaderobjects.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\shaderobjects_3dlabs.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\simple_list.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_assemble.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_assemble_assignment.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_assemble_conditional.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_assemble_constructor.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_assemble_typeinfo.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_compile.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_execute.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_mesa.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_preprocess.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_storage.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\slang_utility.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast_setup\ss_context.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast_setup\ss_triangle.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast_setup\ss_tritmp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast_setup\ss_vb.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\state.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\stencil.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast\swrast.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\swrast_setup\swrast_setup.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_array_api.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_array_import.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_context.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_pipeline.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_save_api.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vb_arbprogram.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vb_cliptmp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vb_lighttmp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vb_rendertmp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vertex.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vp_build.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\t_vtx_api.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\texcompress.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\texenvprogram.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\texformat.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\texformat_tmp.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\teximage.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\texobj.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\texrender.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\texstate.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\texstore.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\tnl\tnl.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\shader\slang\traverse_wrap.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\varray.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\version.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\vtxfmt.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\main\vtxfmt_tmp.h
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/nx-X11/extras/Mesa/windows/VC6/mesa/osmesa/osmesa.dsp b/nx-X11/extras/Mesa/windows/VC6/mesa/osmesa/osmesa.dsp
new file mode 100644
index 000000000..63c7b5503
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC6/mesa/osmesa/osmesa.dsp
@@ -0,0 +1,125 @@
+# Microsoft Developer Studio Project File - Name="osmesa" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=osmesa - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "osmesa.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "osmesa.mak" CFG="osmesa - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "osmesa - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "osmesa - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "osmesa - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OSMESA_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../../../include" /I "../../../../src/mesa" /I "../../../../src/mesa/main" /I "../../../../src/mesa/glapi" /I "../../../../src/mesa/swrast" /I "../../../../src/mesa/shader" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OSMESA_EXPORTS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 opengl32.lib winmm.lib msvcrt.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /nodefaultlib /out:"Release/OSMESA32.DLL" /libpath:"../gdi/Release"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=if not exist ..\..\..\..\lib md ..\..\..\..\lib copy Release\OSMESA32.LIB ..\..\..\..\lib copy Release\OSMESA32.DLL ..\..\..\..\lib if exist ..\..\..\..\progs\demos copy Release\OSMESA32.DLL ..\..\..\..\progs\demos
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "osmesa - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OSMESA_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "../../../../include" /I "../../../../src/mesa" /I "../../../../src/mesa/main" /I "../../../../src/mesa/glapi" /I "../../../../src/mesa/swrast" /I "../../../../src/mesa/shader" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "OSMESA_EXPORTS" /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 opengl32.lib winmm.lib msvcrtd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /debug /machine:I386 /nodefaultlib /out:"Debug/OSMESA32.DLL" /pdbtype:sept /libpath:"../gdi/Debug"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=if not exist ..\..\..\..\lib md ..\..\..\..\lib copy Debug\OSMESA32.LIB ..\..\..\..\lib copy Debug\OSMESA32.DLL ..\..\..\..\lib if exist ..\..\..\..\progs\demos copy Debug\OSMESA32.DLL ..\..\..\..\progs\demos
+# End Special Build Tool
+
+!ENDIF
+
+# Begin Target
+
+# Name "osmesa - Win32 Release"
+# Name "osmesa - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\drivers\common\driverfuncs.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\drivers\osmesa\osmesa.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\mesa\drivers\osmesa\osmesa.def
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/nx-X11/extras/Mesa/windows/VC6/progs/demos/gears.dsp b/nx-X11/extras/Mesa/windows/VC6/progs/demos/gears.dsp
new file mode 100644
index 000000000..af6b3a879
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC6/progs/demos/gears.dsp
@@ -0,0 +1,114 @@
+# Microsoft Developer Studio Project File - Name="gears" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=gears - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "gears.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "gears.mak" CFG="gears - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "gears - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "gears - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "gears - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "../../../../../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 glut32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"../glut/Release"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=copy Release\gears.exe ..\..\..\..\progs\demos
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "gears - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "../../../../../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 glut32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"../glut/Debug"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=copy Debug\gears.exe ..\..\..\..\progs\demos
+# End Special Build Tool
+
+!ENDIF
+
+# Begin Target
+
+# Name "gears - Win32 Release"
+# Name "gears - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\..\..\progs\demos\gears.c
+# ADD CPP /I "../../../../include"
+# SUBTRACT CPP /I "../../../../../include"
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/nx-X11/extras/Mesa/windows/VC6/progs/glut/glut.dsp b/nx-X11/extras/Mesa/windows/VC6/progs/glut/glut.dsp
new file mode 100644
index 000000000..04fb886c0
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC6/progs/glut/glut.dsp
@@ -0,0 +1,333 @@
+# Microsoft Developer Studio Project File - Name="glut" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=glut - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "glut.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "glut.mak" CFG="glut - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "glut - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "glut - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "glut - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GLUT_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "../../../../include" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_DLL" /D "_USRDLL" /D "GLUT_EXPORTS" /D "MESA" /D "BUILD_GL32" /FD /c
+# SUBTRACT CPP /YX
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 opengl32.lib glu32.lib winmm.lib msvcrt.lib oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /nodefaultlib /out:"Release/GLUT32.DLL" /libpath:"../../mesa/Release"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=if not exist ..\..\..\..\lib md ..\..\..\..\lib copy Release\GLUT32.LIB ..\..\..\..\lib copy Release\GLUT32.DLL ..\..\..\..\lib if exist ..\..\..\..\progs\demos copy Release\GLUT32.DLL ..\..\..\..\progs\demos
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "glut - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "GLUT_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "../../../../include" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_DLL" /D "_USRDLL" /D "GLUT_EXPORTS" /D "MESA" /D "BUILD_GL32" /FD /GZ /c
+# SUBTRACT CPP /YX
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 winmm.lib msvcrtd.lib oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib /nologo /dll /incremental:no /debug /machine:I386 /nodefaultlib /out:"Debug/GLUT32.DLL" /pdbtype:sept /libpath:"../../mesa/Debug"
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=if not exist ..\..\..\..\lib md ..\..\..\..\lib copy Debug\GLUT32.LIB ..\..\..\..\lib copy Debug\GLUT32.DLL ..\..\..\..\lib if exist ..\..\..\..\progs\demos copy Debug\GLUT32.DLL ..\..\..\..\progs\demos
+# End Special Build Tool
+
+!ENDIF
+
+# Begin Target
+
+# Name "glut - Win32 Release"
+# Name "glut - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_8x13.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_9x15.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_bitmap.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_bwidth.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_cindex.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_cmap.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_cursor.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_dials.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_dstr.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_event.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_ext.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_fbc.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_fullscrn.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_gamemode.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_get.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_hel10.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_hel12.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_hel18.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_init.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_input.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_joy.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_key.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_keyctrl.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_keyup.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_mesa.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_modifier.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_mroman.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_overlay.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_roman.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_shapes.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_space.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_stroke.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_swap.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_swidth.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_tablet.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_teapot.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_tr10.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_tr24.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_util.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_vidresize.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_warp.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_win.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glut_winmisc.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\win32_glx.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\win32_menu.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\win32_util.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\win32_winproc.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\win32_x11.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glutbitmap.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glutint.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glutstroke.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\glutwin32.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\stroke.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\win32_glx.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\..\..\src\glut\glx\win32_x11.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/nx-X11/extras/Mesa/windows/VC6/progs/progs.dsw b/nx-X11/extras/Mesa/windows/VC6/progs/progs.dsw
new file mode 100644
index 000000000..d220455e6
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC6/progs/progs.dsw
@@ -0,0 +1,41 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "gears"=.\demos\gears.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Project: "glut"=.\glut\glut.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/nx-X11/extras/Mesa/windows/VC7/mesa/gdi/gdi.vcproj b/nx-X11/extras/Mesa/windows/VC7/mesa/gdi/gdi.vcproj
new file mode 100644
index 000000000..82de75dc5
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC7/mesa/gdi/gdi.vcproj
@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding = "Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.00"
+ Name="gdi"
+ SccProjectName=""
+ SccLocalPath="">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="2"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/main,../../../../src/mesa/glapi,../../../../src/mesa/swrast,../../../../src/mesa/shader"
+ PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_USRDLL;GDI_EXPORTS;_DLL;BUILD_GL32;MESA_MINWARN"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ PrecompiledHeaderFile=".\Debug/gdi.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ BrowseInformation="1"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="3"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="mesa.lib winmm.lib msvcrtd.lib odbc32.lib odbccp32.lib"
+ OutputFile="Debug/OPENGL32.DLL"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+ AdditionalLibraryDirectories="../mesa/Debug"
+ IgnoreAllDefaultLibraries="TRUE"
+ ModuleDefinitionFile="..\..\..\..\src\mesa\drivers\windows\gdi\mesa.def"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile=".\Debug/OPENGL32.pdb"
+ ImportLibrary=".\Debug/OPENGL32.lib"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Debug/gdi.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib
+copy Debug\OPENGL32.LIB ..\..\..\..\lib
+copy Debug\OPENGL32.DLL ..\..\..\..\lib
+if exist ..\..\..\..\progs\demos copy Debug\OPENGL32.DLL ..\..\..\..\progs\demos
+"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="2"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../../main,../../../../include,../../../../src/mesa,../../../../src/mesa/main,../../../../src/mesa/glapi,../../../../src/mesa/swrast,../../../../src/mesa/shader"
+ PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;_USRDLL;GDI_EXPORTS;_DLL;BUILD_GL32;MESA_MINWARN"
+ StringPooling="TRUE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="TRUE"
+ PrecompiledHeaderFile=".\Release/gdi.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="mesa.lib winmm.lib msvcrt.lib odbc32.lib odbccp32.lib"
+ OutputFile="Release/OPENGL32.DLL"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+ AdditionalLibraryDirectories="../mesa/Release"
+ IgnoreAllDefaultLibraries="TRUE"
+ ModuleDefinitionFile="..\..\..\..\src\mesa\drivers\windows\gdi\mesa.def"
+ ProgramDatabaseFile=".\Release/OPENGL32.pdb"
+ ImportLibrary=".\Release/OPENGL32.lib"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/gdi.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib
+copy Release\OPENGL32.LIB ..\..\..\..\lib
+copy Release\OPENGL32.DLL ..\..\..\..\lib
+if exist ..\..\..\..\progs\demos copy Release\OPENGL32.DLL ..\..\..\..\progs\demos
+"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ </Configurations>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
+ <File
+ RelativePath="..\..\..\..\src\mesa\drivers\common\driverfuncs.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\drivers\windows\gdi\mesa.def">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\drivers\windows\gdi\wgl.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\drivers\windows\gdi\wmesa.c">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl">
+ <File
+ RelativePath="..\..\..\..\src\mesa\drivers\windows\gdi\colors.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\drivers\common\driverfuncs.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\drivers\windows\gdi\wmesadef.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/nx-X11/extras/Mesa/windows/VC7/mesa/glu/glu.vcproj b/nx-X11/extras/Mesa/windows/VC7/mesa/glu/glu.vcproj
new file mode 100644
index 000000000..e0c481e01
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC7/mesa/glu/glu.vcproj
@@ -0,0 +1,752 @@
+<?xml version="1.0" encoding = "Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.00"
+ Name="glu"
+ SccProjectName=""
+ SccLocalPath="">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="2"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../../../../include;../../../../src/glu/sgi/include;../../../../src/glu/sgi/libnurbs/interface;../../../../src/glu/sgi/libnurbs/internals;../../../../src/glu/sgi/libnurbs/nurbtess"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;GLU_EXPORTS;BUILD_GL32;LIBRARYBUILD"
+ StringPooling="TRUE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="TRUE"
+ PrecompiledHeaderFile=".\Release/glu.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="msvcrt.lib winmm.lib odbc32.lib odbccp32.lib opengl32.lib"
+ OutputFile="Release/GLU32.DLL"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+ AdditionalLibraryDirectories="../gdi/Release"
+ IgnoreAllDefaultLibraries="TRUE"
+ ModuleDefinitionFile="..\..\..\..\src\glu\sgi\glu.def"
+ ProgramDatabaseFile=".\Release/GLU32.pdb"
+ ImportLibrary=".\Release/GLU32.lib"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/glu.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib
+copy Release\GLU32.LIB ..\..\..\..\lib
+copy Release\GLU32.DLL ..\..\..\..\lib
+if exist ..\..\..\..\progs\demos copy Release\GLU32.DLL ..\..\..\..\progs\demos
+"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="2"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../include;../../../../src/glu/sgi/include;../../../../src/glu/sgi/libnurbs/interface;../../../../src/glu/sgi/libnurbs/internals;../../../../src/glu/sgi/libnurbs/nurbtess"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GLU_EXPORTS;BUILD_GL32;LIBRARYBUILD"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ PrecompiledHeaderFile=".\Debug/glu.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="msvcrtd.lib winmm.lib odbc32.lib odbccp32.lib opengl32.lib"
+ OutputFile="Debug/GLU32.DLL"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+ AdditionalLibraryDirectories="../gdi/Debug"
+ IgnoreAllDefaultLibraries="TRUE"
+ ModuleDefinitionFile="..\..\..\..\src\glu\sgi\glu.def"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile=".\Debug/GLU32.pdb"
+ ImportLibrary=".\Debug/GLU32.lib"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Debug/glu.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib
+copy Debug\GLU32.LIB ..\..\..\..\lib
+copy Debug\GLU32.DLL ..\..\..\..\lib
+if exist ..\..\..\..\progs\demos copy Debug\GLU32.DLL ..\..\..\..\progs\demos
+"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ </Configurations>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\dict.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libutil\error.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\geom.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\glu.def">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libutil\glue.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\memalloc.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\mesh.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libutil\mipmap.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\normal.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\priorityq-heap.c">
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="TRUE">
+ <Tool
+ Name="VCCLCompilerTool"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="TRUE">
+ <Tool
+ Name="VCCLCompilerTool"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\priorityq.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libutil\project.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libutil\quad.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libutil\registry.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\render.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\sweep.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\tess.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\tessmono.c">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl">
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arc.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arcsorter.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arctess.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\backend.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\basiccrveval.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\basicsurfeval.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierEval.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierPatch.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierPatchMesh.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\bezierarc.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\bin.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\bufpool.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\cachingeval.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\coveandtiler.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\curve.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\curvelist.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\dataTransform.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\defines.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\definitions.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\dict-list.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\dict.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\directedLine.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\displaylist.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\displaymode.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\flist.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\flistsorter.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\geom.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glcurveval.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\glimports.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glimports.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glrenderer.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glsurfeval.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libutil\gluint.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\include\gluos.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\gridWrap.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\gridline.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\gridtrimvertex.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\gridvertex.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\hull.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\jarcloc.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\knotvector.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mapdesc.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\maplist.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\memalloc.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\mesh.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mesher.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoChain.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoPolyPart.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoTriangulation.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\monotonizer.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\myassert.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mymath.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mysetjmp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\mystdio.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\mystdio.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\mystdlib.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\mystdlib.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mystring.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\normal.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\nurbsconsts.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\nurbstess.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\partitionX.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\partitionY.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\patch.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\patchlist.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\polyDBG.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\polyUtil.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\primitiveStream.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\priorityq-heap.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\priorityq-sort.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\priorityq.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\pwlarc.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\quicksort.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\quilt.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\reader.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\rectBlock.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\render.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\renderhints.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleComp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompBot.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompRight.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompTop.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleMonoPoly.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampledLine.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\searchTree.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\simplemath.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\slicer.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\sorter.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\subdivider.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\sweep.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\tess.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\tessmono.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimline.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimregion.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimvertex.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimvertpool.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\types.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\uarray.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\varray.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\zlassert.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="C++ files"
+ Filter=".cc">
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\README">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arc.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arcsorter.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\arctess.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\backend.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\basiccrveval.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\basicsurfeval.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierEval.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierPatch.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\bezierPatchMesh.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\bin.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\bufpool.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\cachingeval.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\ccw.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\coveandtiler.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\curve.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\curvelist.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\curvesub.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\dataTransform.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\directedLine.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\displaylist.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\flist.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\flistsorter.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glcurveval.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glinterface.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glrenderer.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\glsurfeval.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\gridWrap.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\hull.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\incurveeval.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\interface\insurfeval.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\intersect.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\knotvector.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mapdesc.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mapdescv.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\maplist.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mesher.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoChain.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoPolyPart.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\monoTriangulation.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\monoTriangulationBackend.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\monotonizer.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\mycode.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\nurbsinterfac.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\nurbstess.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\partitionX.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\partitionY.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\patch.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\patchlist.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\polyDBG.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\polyUtil.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\primitiveStream.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\quicksort.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\quilt.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\reader.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\rectBlock.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\renderhints.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleComp.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompBot.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompRight.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleCompTop.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampleMonoPoly.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\sampledLine.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\nurbtess\searchTree.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\slicer.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\sorter.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\splitarcs.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\subdivider.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\tobezier.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimline.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimregion.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\trimvertpool.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\uarray.cc">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libnurbs\internals\varray.cc">
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
+ </Filter>
+ <File
+ RelativePath="..\..\..\..\src\glu\sgi\libtess\alg-outline">
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/nx-X11/extras/Mesa/windows/VC7/mesa/mesa.sln b/nx-X11/extras/Mesa/windows/VC7/mesa/mesa.sln
new file mode 100644
index 000000000..ada5568f4
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC7/mesa/mesa.sln
@@ -0,0 +1,41 @@
+Microsoft Visual Studio Solution File, Format Version 7.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gdi", "gdi\gdi.vcproj", "{A1B24907-E196-4826-B6AF-26723629B633}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glu", "glu\glu.vcproj", "{2E50FDAF-430B-475B-AE6B-60B68F2875BA}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mesa", "mesa\mesa.vcproj", "{2120C974-2717-4709-B44F-D6E6D0A56448}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "osmesa", "osmesa\osmesa.vcproj", "{8D6CD423-383B-49E7-81BC-D20C70B07DF5}"
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ ConfigName.0 = Debug
+ ConfigName.1 = Release
+ EndGlobalSection
+ GlobalSection(ProjectDependencies) = postSolution
+ {A1B24907-E196-4826-B6AF-26723629B633}.0 = {2120C974-2717-4709-B44F-D6E6D0A56448}
+ {8D6CD423-383B-49E7-81BC-D20C70B07DF5}.0 = {A1B24907-E196-4826-B6AF-26723629B633}
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {A1B24907-E196-4826-B6AF-26723629B633}.Debug.ActiveCfg = Debug|Win32
+ {A1B24907-E196-4826-B6AF-26723629B633}.Debug.Build.0 = Debug|Win32
+ {A1B24907-E196-4826-B6AF-26723629B633}.Release.ActiveCfg = Release|Win32
+ {A1B24907-E196-4826-B6AF-26723629B633}.Release.Build.0 = Release|Win32
+ {2E50FDAF-430B-475B-AE6B-60B68F2875BA}.Debug.ActiveCfg = Debug|Win32
+ {2E50FDAF-430B-475B-AE6B-60B68F2875BA}.Debug.Build.0 = Debug|Win32
+ {2E50FDAF-430B-475B-AE6B-60B68F2875BA}.Release.ActiveCfg = Release|Win32
+ {2E50FDAF-430B-475B-AE6B-60B68F2875BA}.Release.Build.0 = Release|Win32
+ {2120C974-2717-4709-B44F-D6E6D0A56448}.Debug.ActiveCfg = Debug|Win32
+ {2120C974-2717-4709-B44F-D6E6D0A56448}.Debug.Build.0 = Debug|Win32
+ {2120C974-2717-4709-B44F-D6E6D0A56448}.Release.ActiveCfg = Release|Win32
+ {2120C974-2717-4709-B44F-D6E6D0A56448}.Release.Build.0 = Release|Win32
+ {8D6CD423-383B-49E7-81BC-D20C70B07DF5}.Debug.ActiveCfg = Debug|Win32
+ {8D6CD423-383B-49E7-81BC-D20C70B07DF5}.Debug.Build.0 = Debug|Win32
+ {8D6CD423-383B-49E7-81BC-D20C70B07DF5}.Release.ActiveCfg = Release|Win32
+ {8D6CD423-383B-49E7-81BC-D20C70B07DF5}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/nx-X11/extras/Mesa/windows/VC7/mesa/mesa/mesa.vcproj b/nx-X11/extras/Mesa/windows/VC7/mesa/mesa/mesa.vcproj
new file mode 100644
index 000000000..ed124b537
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC7/mesa/mesa/mesa.vcproj
@@ -0,0 +1,1084 @@
+<?xml version="1.0" encoding = "Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.00"
+ Name="mesa"
+ SccProjectName=""
+ SccLocalPath="">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="4"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/Zm1000 "
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang,../../../../src/mesa/shader/grammar"
+ PreprocessorDefinitions="NDEBUG,WIN32,_LIB,_DLL,BUILD_GL32,MESA_MINWARN"
+ StringPooling="TRUE"
+ RuntimeLibrary="4"
+ EnableFunctionLevelLinking="TRUE"
+ UsePrecompiledHeader="2"
+ PrecompiledHeaderFile=".\Release/mesa.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile=".\Release\mesa.lib"
+ SuppressStartupBanner="TRUE"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="4"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/Zm1000 "
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/glapi,../../../../src/mesa/main,../../../../src/mesa/shader,../../../../src/mesa/shader/slang,../../../../src/mesa/shader/grammar"
+ PreprocessorDefinitions="_DEBUG,WIN32,_LIB,_DLL,BUILD_GL32,MESA_MINWARN"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ PrecompiledHeaderFile=".\Debug/mesa.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ BrowseInformation="1"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="3"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLibrarianTool"
+ OutputFile=".\Debug\mesa.lib"
+ SuppressStartupBanner="TRUE"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
+ <File
+ RelativePath="..\..\..\..\src\mesa\array_cache\ac_context.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\array_cache\ac_import.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\accum.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\api_arrayelt.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\api_loopback.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\api_noop.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\api_validate.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\arbfragparse.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\arbprogparse.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\arbprogram.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\arbvertparse.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\atifragshader.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\attrib.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\blend.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\bufferobj.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\buffers.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\clip.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\colortab.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\context.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\convolve.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\debug.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\depth.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\dispatch.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\dlist.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\drawpix.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\enable.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\enums.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\eval.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\execmem.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\extensions.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\fbobject.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\feedback.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\fog.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\framebuffer.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\get.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\getstring.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\glapi\glapi.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\glapi\glthread.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar.c">
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="TRUE">
+ <Tool
+ Name="VCCLCompilerTool"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="TRUE">
+ <Tool
+ Name="VCCLCompilerTool"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_mesa.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\hash.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\hint.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\histogram.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\image.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\imports.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\light.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\lines.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_debug_clip.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_debug_norm.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_debug_xform.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_eval.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_matrix.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_translate.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_vector.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_xform.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\matrix.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\mm.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\nvfragparse.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\nvprogram.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\nvvertexec.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\nvvertparse.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\occlude.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\pixel.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\points.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\polygon.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\program.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\rastpos.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\renderbuffer.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_aaline.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_aatriangle.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_accum.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_alpha.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_atifragshader.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_bitmap.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_blend.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_buffers.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_context.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_copypix.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_depth.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_drawpix.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_feedback.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_fog.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_imaging.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_lines.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_logic.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_masking.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_nvfragprog.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_pixeltex.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_points.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_readpix.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_span.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_stencil.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_texstore.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_texture.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_triangle.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_zoom.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\shaderobjects.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\shaderobjects_3dlabs.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_assemble.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_assemble_assignment.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_assemble_conditional.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_assemble_constructor.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_assemble_typeinfo.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_execute.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_preprocess.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_storage.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_utility.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_context.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_triangle.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\state.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\stencil.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_array_api.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_array_import.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_context.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_pipeline.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_save_api.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_save_loopback.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_save_playback.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vb_arbprogram.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vb_cull.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vb_fog.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vb_light.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vb_normals.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vb_points.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vb_program.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vb_render.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vb_texgen.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vb_texmat.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vb_vertex.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vertex.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vertex_generic.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vp_build.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vtx_api.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vtx_eval.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vtx_exec.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vtx_generic.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\texcompress.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\texcompress_fxt1.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\texcompress_s3tc.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\texenvprogram.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\texformat.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\teximage.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\texobj.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\texrender.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\texstate.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\texstore.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\varray.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\vsnprintf.c">
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="TRUE">
+ <Tool
+ Name="VCCLCompilerTool"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="TRUE">
+ <Tool
+ Name="VCCLCompilerTool"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\vtxfmt.c">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl">
+ <File
+ RelativePath="..\..\..\..\src\mesa\array_cache\ac_context.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\array_cache\acache.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\accum.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\api_arrayelt.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\api_eval.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\api_loopback.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\api_noop.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\api_validate.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\arbfragparse.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\arbprogparse.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\arbprogram.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\arbprogram_syn.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\arbvertparse.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\atifragshader.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\attrib.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\blend.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\bufferobj.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\buffers.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\clip.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\colormac.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\colortab.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\config.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\context.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\convolve.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\dd.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\debug.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\depth.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\dlist.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\drawpix.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\enable.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\enums.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\eval.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\extensions.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\fbobject.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\feedback.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\fog.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\framebuffer.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\get.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\glapi\glapi.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\glapi\glapioffsets.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\glapi\glapitable.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\glapi\glapitemp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\glheader.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\glapi\glprocs.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\glapi\glthread.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_mesa.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\grammar\grammar_syn.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\hash.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\hint.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\histogram.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\image.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\imports.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\light.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\lines.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_clip_tmp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_copy_tmp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_debug.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_debug_util.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_dotprod_tmp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_eval.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_matrix.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_norm_tmp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_trans_tmp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_translate.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_vector.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_xform.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\m_xform_tmp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\macros.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\math\mathmod.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\matrix.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\mm.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\mtypes.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\nvfragparse.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\nvfragprog.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\nvprogram.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\nvvertexec.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\nvvertparse.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\nvvertprog.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\occlude.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\pixel.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\points.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\polygon.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\program.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\rastpos.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\renderbuffer.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_aaline.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_aalinetemp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_aatriangle.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_aatritemp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_accum.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_alpha.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_atifragshader.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_blend.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_context.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_depth.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_drawpix.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_feedback.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_fog.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_lines.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_linetemp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_logic.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_masking.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_nvfragprog.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_pixeltex.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_points.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_pointtemp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_span.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_spantemp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_stencil.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_texture.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_triangle.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_trispan.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_tritemp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\s_zoom.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\shaderobjects.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\shaderobjects_3dlabs.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\simple_list.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_assemble.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_assemble_assignment.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_assemble_conditional.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_assemble_constructor.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_assemble_typeinfo.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_compile.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_execute.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_mesa.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_preprocess.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_storage.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\slang_utility.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_context.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_triangle.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_tritmp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast_setup\ss_vb.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\state.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\stencil.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast\swrast.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\swrast_setup\swrast_setup.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_array_api.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_array_import.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_context.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_pipeline.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_save_api.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vb_arbprogram.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vb_cliptmp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vb_lighttmp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vb_rendertmp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vertex.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vp_build.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\t_vtx_api.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\texcompress.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\texenvprogram.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\texformat.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\texformat_tmp.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\teximage.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\texobj.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\texrender.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\texstate.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\texstore.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\tnl\tnl.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\shader\slang\traverse_wrap.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\varray.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\version.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\vtxfmt.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\main\vtxfmt_tmp.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/nx-X11/extras/Mesa/windows/VC7/mesa/osmesa/osmesa.vcproj b/nx-X11/extras/Mesa/windows/VC7/mesa/osmesa/osmesa.vcproj
new file mode 100644
index 000000000..266aff509
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC7/mesa/osmesa/osmesa.vcproj
@@ -0,0 +1,168 @@
+<?xml version="1.0" encoding = "Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.00"
+ Name="osmesa"
+ SccProjectName=""
+ SccLocalPath="">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="2"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/main,../../../../src/mesa/glapi,../../../../src/mesa/swrast,../../../../src/mesa/shader"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;OSMESA_EXPORTS"
+ StringPooling="TRUE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="TRUE"
+ PrecompiledHeaderFile=".\Release/osmesa.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="opengl32.lib winmm.lib msvcrt.lib odbc32.lib odbccp32.lib"
+ OutputFile="Release/OSMESA32.DLL"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+ AdditionalLibraryDirectories="../gdi/Release"
+ IgnoreAllDefaultLibraries="TRUE"
+ ModuleDefinitionFile="..\..\..\..\src\mesa\drivers\osmesa\osmesa.def"
+ ProgramDatabaseFile=".\Release/OSMESA32.pdb"
+ ImportLibrary=".\Release/OSMESA32.lib"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/osmesa.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib
+copy Release\OSMESA32.LIB ..\..\..\..\lib
+copy Release\OSMESA32.DLL ..\..\..\..\lib
+if exist ..\..\..\..\progs\demos copy Release\OSMESA32.DLL ..\..\..\..\progs\demos
+"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="2"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../include,../../../../src/mesa,../../../../src/mesa/main,../../../../src/mesa/glapi,../../../../src/mesa/swrast,../../../../src/mesa/shader"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;OSMESA_EXPORTS"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ PrecompiledHeaderFile=".\Debug/osmesa.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="3"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="opengl32.lib winmm.lib msvcrtd.lib odbc32.lib odbccp32.lib"
+ OutputFile="Debug/OSMESA32.DLL"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+ AdditionalLibraryDirectories="../gdi/Debug"
+ IgnoreAllDefaultLibraries="TRUE"
+ ModuleDefinitionFile="..\..\..\..\src\mesa\drivers\osmesa\osmesa.def"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile=".\Debug/OSMESA32.pdb"
+ ImportLibrary=".\Debug/OSMESA32.lib"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Debug/osmesa.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib
+copy Debug\OSMESA32.LIB ..\..\..\..\lib
+copy Debug\OSMESA32.DLL ..\..\..\..\lib
+if exist ..\..\..\..\progs\demos copy Debug\OSMESA32.DLL ..\..\..\..\progs\demos
+"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ </Configurations>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
+ <File
+ RelativePath="..\..\..\..\src\mesa\drivers\common\driverfuncs.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\drivers\osmesa\osmesa.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\mesa\drivers\osmesa\osmesa.def">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl">
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/nx-X11/extras/Mesa/windows/VC7/progs/demos/gears.vcproj b/nx-X11/extras/Mesa/windows/VC7/progs/demos/gears.vcproj
new file mode 100644
index 000000000..9880b2e08
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC7/progs/demos/gears.vcproj
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding = "Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.00"
+ Name="gears"
+ SccProjectName=""
+ SccLocalPath="">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="1"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../include"
+ PreprocessorDefinitions="WIN32,_DEBUG,_CONSOLE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ PrecompiledHeaderFile=".\Debug/gears.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="3"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="glut32.lib odbc32.lib odbccp32.lib"
+ OutputFile=".\Debug/gears.exe"
+ LinkIncremental="2"
+ SuppressStartupBanner="TRUE"
+ AdditionalLibraryDirectories="../glut/Debug"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile=".\Debug/gears.pdb"
+ SubSystem="1"/>
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\Debug/gears.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="copy Debug\gears.exe ..\..\..\..\progs\demos"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="1"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../../../../include"
+ PreprocessorDefinitions="WIN32,NDEBUG,_CONSOLE"
+ StringPooling="TRUE"
+ RuntimeLibrary="4"
+ EnableFunctionLevelLinking="TRUE"
+ PrecompiledHeaderFile=".\Release/gears.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="glut32.lib odbc32.lib odbccp32.lib"
+ OutputFile=".\Release/gears.exe"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+ AdditionalLibraryDirectories="../glut/Release"
+ ProgramDatabaseFile=".\Release/gears.pdb"
+ SubSystem="1"/>
+ <Tool
+ Name="VCMIDLTool"
+ TypeLibraryName=".\Release/gears.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="copy Release\gears.exe ..\..\..\..\progs\demos"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ </Configurations>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
+ <File
+ RelativePath="..\..\..\..\progs\demos\gears.c">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=""/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl">
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/nx-X11/extras/Mesa/windows/VC7/progs/glut/glut.vcproj b/nx-X11/extras/Mesa/windows/VC7/progs/glut/glut.vcproj
new file mode 100644
index 000000000..2d0dd351c
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC7/progs/glut/glut.vcproj
@@ -0,0 +1,322 @@
+<?xml version="1.0" encoding = "Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.00"
+ Name="glut"
+ SccProjectName=""
+ SccLocalPath="">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".\Debug"
+ IntermediateDirectory=".\Debug"
+ ConfigurationType="2"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="../../../../include"
+ PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;_DLL;_USRDLL;GLUT_EXPORTS;MESA;BUILD_GL32"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ PrecompiledHeaderFile=".\Debug/glut.pch"
+ AssemblerListingLocation=".\Debug/"
+ ObjectFile=".\Debug/"
+ ProgramDataBaseFileName=".\Debug/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ DebugInformationFormat="3"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="winmm.lib msvcrtd.lib oldnames.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib"
+ OutputFile="Debug/GLUT32.DLL"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+ AdditionalLibraryDirectories="../../mesa/Debug"
+ IgnoreAllDefaultLibraries="TRUE"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile=".\Debug/GLUT32.pdb"
+ ImportLibrary=".\Debug/GLUT32.lib"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="_DEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Debug/glut.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib
+copy Debug\GLUT32.LIB ..\..\..\..\lib
+copy Debug\GLUT32.DLL ..\..\..\..\lib
+if exist ..\..\..\..\progs\demos copy Debug\GLUT32.DLL ..\..\..\..\progs\demos
+"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="_DEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".\Release"
+ IntermediateDirectory=".\Release"
+ ConfigurationType="2"
+ UseOfMFC="0"
+ ATLMinimizesCRunTimeLibraryUsage="FALSE"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ InlineFunctionExpansion="1"
+ AdditionalIncludeDirectories="../../../../include"
+ PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;_DLL;_USRDLL;GLUT_EXPORTS;MESA;BUILD_GL32"
+ StringPooling="TRUE"
+ RuntimeLibrary="0"
+ EnableFunctionLevelLinking="TRUE"
+ PrecompiledHeaderFile=".\Release/glut.pch"
+ AssemblerListingLocation=".\Release/"
+ ObjectFile=".\Release/"
+ ProgramDataBaseFileName=".\Release/"
+ WarningLevel="3"
+ SuppressStartupBanner="TRUE"
+ CompileAs="0"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="/MACHINE:I386"
+ AdditionalDependencies="opengl32.lib glu32.lib winmm.lib msvcrt.lib oldnames.lib odbc32.lib odbccp32.lib"
+ OutputFile="Release/GLUT32.DLL"
+ LinkIncremental="1"
+ SuppressStartupBanner="TRUE"
+ AdditionalLibraryDirectories="../../mesa/Release"
+ IgnoreAllDefaultLibraries="TRUE"
+ ProgramDatabaseFile=".\Release/GLUT32.pdb"
+ ImportLibrary=".\Release/GLUT32.lib"/>
+ <Tool
+ Name="VCMIDLTool"
+ PreprocessorDefinitions="NDEBUG"
+ MkTypLibCompatible="TRUE"
+ SuppressStartupBanner="TRUE"
+ TargetEnvironment="1"
+ TypeLibraryName=".\Release/glut.tlb"/>
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine="if not exist ..\..\..\..\lib md ..\..\..\..\lib
+copy Release\GLUT32.LIB ..\..\..\..\lib
+copy Release\GLUT32.DLL ..\..\..\..\lib
+if exist ..\..\..\..\progs\demos copy Release\GLUT32.DLL ..\..\..\..\progs\demos
+"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"
+ PreprocessorDefinitions="NDEBUG"
+ Culture="1033"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ </Configuration>
+ </Configurations>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_8x13.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_9x15.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_bitmap.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_bwidth.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_cindex.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_cmap.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_cursor.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_dials.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_dstr.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_event.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_ext.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_fbc.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_fullscrn.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_gamemode.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_get.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_hel10.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_hel12.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_hel18.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_init.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_input.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_joy.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_key.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_keyctrl.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_keyup.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_mesa.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_modifier.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_mroman.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_overlay.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_roman.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_shapes.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_space.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_stroke.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_swap.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_swidth.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_tablet.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_teapot.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_tr10.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_tr24.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_util.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_vidresize.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_warp.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_win.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glut_winmisc.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\win32_glx.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\win32_menu.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\win32_util.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\win32_winproc.c">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\win32_x11.c">
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl">
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glutbitmap.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glutint.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glutstroke.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\glutwin32.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\stroke.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\win32_glx.h">
+ </File>
+ <File
+ RelativePath="..\..\..\..\src\glut\glx\win32_x11.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/nx-X11/extras/Mesa/windows/VC7/progs/progs.sln b/nx-X11/extras/Mesa/windows/VC7/progs/progs.sln
new file mode 100644
index 000000000..d94293e31
--- /dev/null
+++ b/nx-X11/extras/Mesa/windows/VC7/progs/progs.sln
@@ -0,0 +1,27 @@
+Microsoft Visual Studio Solution File, Format Version 7.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gears", "demos\gears.vcproj", "{3A7B0671-10F8-45D1-B012-F6D650F817CE}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "glut", "glut\glut.vcproj", "{0234F0D2-C8A6-4C4D-93E7-0E2248049C67}"
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ ConfigName.0 = Debug
+ ConfigName.1 = Release
+ EndGlobalSection
+ GlobalSection(ProjectDependencies) = postSolution
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {3A7B0671-10F8-45D1-B012-F6D650F817CE}.Debug.ActiveCfg = Debug|Win32
+ {3A7B0671-10F8-45D1-B012-F6D650F817CE}.Debug.Build.0 = Debug|Win32
+ {3A7B0671-10F8-45D1-B012-F6D650F817CE}.Release.ActiveCfg = Release|Win32
+ {3A7B0671-10F8-45D1-B012-F6D650F817CE}.Release.Build.0 = Release|Win32
+ {0234F0D2-C8A6-4C4D-93E7-0E2248049C67}.Debug.ActiveCfg = Debug|Win32
+ {0234F0D2-C8A6-4C4D-93E7-0E2248049C67}.Debug.Build.0 = Debug|Win32
+ {0234F0D2-C8A6-4C4D-93E7-0E2248049C67}.Release.ActiveCfg = Release|Win32
+ {0234F0D2-C8A6-4C4D-93E7-0E2248049C67}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal